From ffaa7419ece45799a353261dc4d4065e6f2041d7 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 5 Feb 2016 23:21:23 +0100 Subject: [PATCH 01/31] Fix Android compile on Windows --- makepanda/makepanda.py | 7 +++++-- makepanda/makepandacore.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 186cd589f2..5b9b31af36 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -457,7 +457,6 @@ SdkLocateMaya() SdkLocateMax() SdkLocateMacOSX(OSXTARGET) SdkLocatePython(RTDIST) -SdkLocateVisualStudio(MSVC_VERSION) SdkLocateWindows(WINDOWS_SDK) SdkLocatePhysX() SdkLocateSpeedTree() @@ -496,6 +495,7 @@ if RUNTIME and not HOST_URL: if GetHost() == 'windows' and GetTarget() == 'windows': COMPILER = "MSVC" + SdkLocateVisualStudio(MSVC_VERSION) else: COMPILER = "GCC" @@ -737,6 +737,9 @@ if (COMPILER=="GCC"): IncDirectory("ALWAYS", "/usr/PCBSD/local/include") LibDirectory("ALWAYS", "/usr/PCBSD/local/lib") + if GetTarget() != "windows": + PkgDisable("DIRECTCAM") + fcollada_libs = ("FColladaD", "FColladaSD", "FColladaS") # WARNING! The order of the ffmpeg libraries matters! ffmpeg_libs = ("libavformat", "libavcodec", "libavutil") @@ -4323,7 +4326,7 @@ if (GetTarget() == 'windows' and not RUNTIME): # DIRECTORY: panda/metalibs/pandadx9/ # -if PkgSkip("DX9")==0 and not RUNTIME: +if GetTarget() == 'windows' and PkgSkip("DX9")==0 and not RUNTIME: OPTS=['DIR:panda/src/dxgsg9', 'BUILDING:PANDADX', 'DX9', 'NVIDIACG', 'CGDX9'] TargetAdd('p3dxgsg9_dxGraphicsStateGuardian9.obj', opts=OPTS, input='dxGraphicsStateGuardian9.cxx') TargetAdd('p3dxgsg9_composite1.obj', opts=OPTS, input='p3dxgsg9_composite1.cxx') diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 43cf970c39..f395693c3f 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -2008,7 +2008,8 @@ def SdkLocateVisualStudio(version=10): print("Using Visual Studio %s" % (version)) def SdkLocateWindows(version = '7.1'): - if (GetHost() != "windows"): return + if GetTarget() != "windows" or GetHost() != "windows": + return version = version.upper() From 40739c6b5f314cd1aea4e0e66cc0f8f3ca40f8f3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 6 Feb 2016 11:46:56 +0100 Subject: [PATCH 02/31] Fix link issues and crashes with Android build --- makepanda/makepanda.py | 7 ++--- panda/src/android/config_android.h | 4 +-- panda/src/android/jni_NativeIStream.cxx | 12 ++++++--- .../androiddisplay/androidGraphicsWindow.cxx | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 27 ++++++++++++++----- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5b9b31af36..11868cf829 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1171,7 +1171,7 @@ def CompileCxx(obj,src,opts): if (opt=="ALWAYS") or (opt in opts): cmd += ' -D' + var + '=' + val for x in ipath: cmd += ' -I' + x - if not GetLinkAllStatic(): + if not GetLinkAllStatic() and 'NOHIDDEN' not in opts: cmd += ' -fvisibility=hidden' # Mac-specific flags. @@ -1627,7 +1627,8 @@ def CompileLink(dll, obj, opts): cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp' else: cmd = cxx + ' -shared' - if ("MODULE" not in opts): cmd += " -Wl,-soname=" + os.path.basename(dll) + if "MODULE" not in opts or GetTarget() == 'android': + cmd += " -Wl,-soname=" + os.path.basename(dll) cmd += ' -o ' + dll + ' -L' + GetOutputDir() + '/lib -L' + GetOutputDir() + '/tmp' for x in obj: @@ -4806,7 +4807,7 @@ if (not RUNTIME and GetTarget() == 'android'): TargetAdd('libp3android.dll', input=COMMON_PANDA_LIBS) TargetAdd('libp3android.dll', opts=['JNIGRAPHICS']) - TargetAdd('android_native_app_glue.obj', opts=OPTS, input='android_native_app_glue.c') + TargetAdd('android_native_app_glue.obj', opts=OPTS + ['NOHIDDEN'], input='android_native_app_glue.c') TargetAdd('android_main.obj', opts=OPTS, input='android_main.cxx') if (not RTDIST and PkgSkip("PVIEW")==0): diff --git a/panda/src/android/config_android.h b/panda/src/android/config_android.h index 201e631df5..298a6863f7 100644 --- a/panda/src/android/config_android.h +++ b/panda/src/android/config_android.h @@ -23,10 +23,10 @@ #include -NotifyCategoryDeclNoExport(android); +NotifyCategoryDecl(android, EXPORT_CLASS, EXPORT_TEMPL); extern void init_libandroid(); -extern struct android_app* panda_android_app; +extern EXPORT_CLASS struct android_app* panda_android_app; extern jclass jni_PandaActivity; extern jmethodID jni_PandaActivity_readBitmapHeader; diff --git a/panda/src/android/jni_NativeIStream.cxx b/panda/src/android/jni_NativeIStream.cxx index d6684dd7e7..949790bbe3 100644 --- a/panda/src/android/jni_NativeIStream.cxx +++ b/panda/src/android/jni_NativeIStream.cxx @@ -16,13 +16,19 @@ #include +#if __GNUC__ >= 4 +#define EXPORT_JNI extern "C" __attribute__((visibility("default"))) +#else +#define EXPORT_JNI extern "C" +#endif + //////////////////////////////////////////////////////////////////// // Function: NativeIStream::nativeGet // Access: Private, Static // Description: Reads a single character from the istream. // Should return -1 on EOF. //////////////////////////////////////////////////////////////////// -extern "C" jint +EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlong ptr) { std::istream *stream = (std::istream *) ptr; @@ -37,7 +43,7 @@ Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlon // the actual number of bytes that were read. // Should return -1 on EOF. //////////////////////////////////////////////////////////////////// -extern "C" jint +EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) { std::istream *stream = (std::istream *) ptr; jbyte *buffer = (jbyte *) env->GetPrimitiveArrayCritical(byte_array, NULL); @@ -63,7 +69,7 @@ Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlo // Description: Skips ahead N bytes in the stream. Returns the // actual number of skipped bytes. //////////////////////////////////////////////////////////////////// -extern "C" jlong +EXPORT_JNI jlong Java_org_panda3d_android_NativeIStream_nativeIgnore(JNIEnv *env, jclass clazz, jlong ptr, jlong offset) { std::istream *stream = (std::istream *) ptr; stream->ignore(offset); diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 6a134255e9..80499e0e12 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -30,7 +30,7 @@ #include #include -extern struct android_app* panda_android_app; +extern IMPORT_CLASS struct android_app* panda_android_app; TypeHandle AndroidGraphicsWindow::_type_handle; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 72115a9137..b2d5c5788b 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -6583,9 +6583,12 @@ do_issue_depth_test() { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: do_issue_alpha_test() { +#ifndef OPENGLES_1 if (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test)) { enable_alpha_test(false); - } else { + } else +#endif + { const AlphaTestAttrib *target_alpha_test; _target_rs->get_attrib_def(target_alpha_test); @@ -6846,9 +6849,13 @@ do_issue_blending() { unsigned int color_channels = target_color_write->get_channels() & _color_write_mask; + +#ifndef OPENGLES_1 if (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write)) { color_channels &= ~(ColorWriteAttrib::C_alpha); } +#endif + if (color_channels == ColorWriteAttrib::C_off) { int color_write_slot = ColorWriteAttrib::get_class_slot(); enable_multisample_alpha_one(false); @@ -9875,9 +9882,12 @@ set_state_and_transform(const RenderState *target, #ifdef SUPPORT_FIXED_FUNCTION int alpha_test_slot = AlphaTestAttrib::get_class_slot(); if (_target_rs->get_attrib(alpha_test_slot) != _state_rs->get_attrib(alpha_test_slot) || - !_state_mask.get_bit(alpha_test_slot) || - (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test) != - _state_shader->get_flag(ShaderAttrib::F_subsume_alpha_test))) { + !_state_mask.get_bit(alpha_test_slot) +#ifndef OPENGLES_1 + || (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test) != + _state_shader->get_flag(ShaderAttrib::F_subsume_alpha_test)) +#endif + ) { //PStatGPUTimer timer(this, _draw_set_state_alpha_test_pcollector); do_issue_alpha_test(); _state_mask.set_bit(alpha_test_slot); @@ -9981,9 +9991,12 @@ set_state_and_transform(const RenderState *target, _target_rs->get_attrib(color_blend_slot) != _state_rs->get_attrib(color_blend_slot) || !_state_mask.get_bit(transparency_slot) || !_state_mask.get_bit(color_write_slot) || - !_state_mask.get_bit(color_blend_slot) || - (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write) != - _state_shader->get_flag(ShaderAttrib::F_disable_alpha_write))) { + !_state_mask.get_bit(color_blend_slot) +#ifndef OPENGLES_1 + || (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write) != + _state_shader->get_flag(ShaderAttrib::F_disable_alpha_write)) +#endif + ) { //PStatGPUTimer timer(this, _draw_set_state_blending_pcollector); do_issue_blending(); _state_mask.set_bit(transparency_slot); From 8dfef999153c79b5dab6dee48e4cd44323d6558e Mon Sep 17 00:00:00 2001 From: tobspr Date: Sun, 7 Feb 2016 19:45:01 +0100 Subject: [PATCH 03/31] Fix swizzle masks on vector types --- panda/src/linmath/lpoint3_src.h | 4 ++++ panda/src/linmath/lpoint4_src.I | 22 ++++++++++++++++++++++ panda/src/linmath/lpoint4_src.h | 6 ++++++ panda/src/linmath/lvecBase3_src.h | 2 ++ panda/src/linmath/lvecBase4_src.h | 3 ++- panda/src/linmath/lvector3_src.h | 5 +++++ panda/src/linmath/lvector4_src.I | 20 ++++++++++++++++++++ panda/src/linmath/lvector4_src.h | 6 ++++++ 8 files changed, 67 insertions(+), 1 deletion(-) diff --git a/panda/src/linmath/lpoint3_src.h b/panda/src/linmath/lpoint3_src.h index 0be8774815..37b92266d6 100644 --- a/panda/src/linmath/lpoint3_src.h +++ b/panda/src/linmath/lpoint3_src.h @@ -42,6 +42,10 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint2) get_xz() const; INLINE_LINMATH FLOATNAME(LPoint2) get_yz() const; + MAKE_PROPERTY(xy, get_xy); + MAKE_PROPERTY(xz, get_xz); + MAKE_PROPERTY(yz, get_yz); + INLINE_LINMATH FLOATNAME(LPoint3) operator - () const; INLINE_LINMATH FLOATNAME(LVecBase3) diff --git a/panda/src/linmath/lpoint4_src.I b/panda/src/linmath/lpoint4_src.I index 0e37a0c533..d52b2eafa8 100644 --- a/panda/src/linmath/lpoint4_src.I +++ b/panda/src/linmath/lpoint4_src.I @@ -105,6 +105,28 @@ unit_w() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::unit_w(); } + +//////////////////////////////////////////////////////////////////// +// Function: LPoint4::get_xyz +// Access: Published +// Description: Returns the x, y and z component of this vector +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint4):: +get_xyz() const { + return FLOATNAME(LPoint3)(_v(0), _v(1), _v(2)); +} + +//////////////////////////////////////////////////////////////////// +// Function: LPoint4::get_xy +// Access: Published +// Description: Returns the x and y component of this vector +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint4):: +get_xy() const { + return FLOATNAME(LPoint2)(_v(0), _v(1)); +} + + //////////////////////////////////////////////////////////////////// // Function: LPoint4::unary - // Access: Public diff --git a/panda/src/linmath/lpoint4_src.h b/panda/src/linmath/lpoint4_src.h index a9c4ed59fe..d0702b2202 100644 --- a/panda/src/linmath/lpoint4_src.h +++ b/panda/src/linmath/lpoint4_src.h @@ -33,6 +33,12 @@ PUBLISHED: INLINE_LINMATH static const FLOATNAME(LPoint4) &unit_z(); INLINE_LINMATH static const FLOATNAME(LPoint4) &unit_w(); + INLINE_LINMATH FLOATNAME(LPoint3) get_xyz() const; + INLINE_LINMATH FLOATNAME(LPoint2) get_xy() const; + + MAKE_PROPERTY(xyz, get_xyz); + MAKE_PROPERTY(xy, get_xy); + INLINE_LINMATH FLOATNAME(LPoint4) operator - () const; INLINE_LINMATH FLOATNAME(LVecBase4) diff --git a/panda/src/linmath/lvecBase3_src.h b/panda/src/linmath/lvecBase3_src.h index f7641df367..ed7dfc5a7b 100644 --- a/panda/src/linmath/lvecBase3_src.h +++ b/panda/src/linmath/lvecBase3_src.h @@ -74,6 +74,8 @@ PUBLISHED: MAKE_PROPERTY(y, get_y, set_y); MAKE_PROPERTY(z, get_z, set_z); MAKE_PROPERTY(xy, get_xy); + MAKE_PROPERTY(xz, get_xz); + MAKE_PROPERTY(yz, get_yz); // These next functions add to an existing value. // i.e. foo.set_x(foo.get_x() + value) diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index 79b136eec1..3f43170eae 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -84,8 +84,9 @@ PUBLISHED: MAKE_PROPERTY(x, get_x, set_x); MAKE_PROPERTY(y, get_y, set_y); MAKE_PROPERTY(z, get_z, set_z); - MAKE_PROPERTY(xy, get_xy); + MAKE_PROPERTY(xyz, get_xyz); + MAKE_PROPERTY(xy, get_xy); // These next functions add to an existing value. // i.e. foo.set_x(foo.get_x() + value) diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index 926f5280bb..47ea8a0661 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -42,6 +42,11 @@ PUBLISHED: INLINE_LINMATH FLOATNAME(LVector2) get_xz() const; INLINE_LINMATH FLOATNAME(LVector2) get_yz() const; + MAKE_PROPERTY(xy, get_xy); + MAKE_PROPERTY(xz, get_xz); + MAKE_PROPERTY(yz, get_yz); + + INLINE_LINMATH FLOATNAME(LVector3) operator - () const; INLINE_LINMATH FLOATNAME(LVecBase3) operator + (const FLOATNAME(LVecBase3) &other) const; diff --git a/panda/src/linmath/lvector4_src.I b/panda/src/linmath/lvector4_src.I index 047b7b2232..25751638f2 100644 --- a/panda/src/linmath/lvector4_src.I +++ b/panda/src/linmath/lvector4_src.I @@ -105,6 +105,26 @@ unit_w() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::unit_w(); } +//////////////////////////////////////////////////////////////////// +// Function: LVector4::get_xyz +// Access: Published +// Description: Returns the x, y and z component of this vector +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector4):: +get_xyz() const { + return FLOATNAME(LVector3)(_v(0), _v(1), _v(2)); +} + +//////////////////////////////////////////////////////////////////// +// Function: LVector4::get_xy +// Access: Published +// Description: Returns the x and y component of this vector +//////////////////////////////////////////////////////////////////// +INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector4):: +get_xy() const { + return FLOATNAME(LVector2)(_v(0), _v(1)); +} + //////////////////////////////////////////////////////////////////// // Function: LVector4::unary - // Access: Public diff --git a/panda/src/linmath/lvector4_src.h b/panda/src/linmath/lvector4_src.h index a4cda0f612..722d60d708 100644 --- a/panda/src/linmath/lvector4_src.h +++ b/panda/src/linmath/lvector4_src.h @@ -33,6 +33,12 @@ PUBLISHED: INLINE_LINMATH static const FLOATNAME(LVector4) &unit_z(); INLINE_LINMATH static const FLOATNAME(LVector4) &unit_w(); + INLINE_LINMATH FLOATNAME(LVector3) get_xyz() const; + INLINE_LINMATH FLOATNAME(LVector2) get_xy() const; + + MAKE_PROPERTY(xyz, get_xyz); + MAKE_PROPERTY(xy, get_xy); + INLINE_LINMATH FLOATNAME(LVector4) operator - () const; INLINE_LINMATH FLOATNAME(LVecBase4) operator + (const FLOATNAME(LVecBase4) &other) const; From bb684b2a07eed439321c2f77e3c11cbb87af17bf Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 9 Feb 2016 12:33:57 +0100 Subject: [PATCH 04/31] Fix a few issues with obscure CPython-based deployments --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 2 +- dtool/src/pystub/pystub.cxx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 1c42584114..2686bb1ce6 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2788,7 +2788,7 @@ write_module_class(ostream &out, Object *obj) { // struct PyMethodDef *tp_methods; out << " Dtool_Methods_" << ClassName << ",\n"; // struct PyMemberDef *tp_members; - out << " standard_type_members,\n"; + out << " 0, // tp_members\n"; // struct PyGetSetDef *tp_getset; if (num_getset > 0) { diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index 399af3ef3a..4fa1a4ed6a 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -61,6 +61,7 @@ extern "C" { EXPCL_PYSTUB int PyGILState_Ensure(...); EXPCL_PYSTUB int PyGILState_Release(...); EXPCL_PYSTUB int PyImport_GetModuleDict(...); + EXPCL_PYSTUB int PyImport_ImportModule(...); EXPCL_PYSTUB int PyInt_AsLong(...); EXPCL_PYSTUB int PyInt_AsSsize_t(...); EXPCL_PYSTUB int PyInt_FromLong(...); @@ -169,6 +170,7 @@ extern "C" { EXPCL_PYSTUB int PyUnicode_InternInPlace(...); EXPCL_PYSTUB int PyUnicode_Type(...); EXPCL_PYSTUB int Py_BuildValue(...); + EXPCL_PYSTUB int Py_GetVersion(...); EXPCL_PYSTUB int Py_InitModule4(...); EXPCL_PYSTUB int Py_InitModule4_64(...); EXPCL_PYSTUB int Py_InitModule4TraceRefs(...); @@ -195,6 +197,7 @@ extern "C" { EXPCL_PYSTUB extern void *PyExc_ConnectionError; EXPCL_PYSTUB extern void *PyExc_Exception; EXPCL_PYSTUB extern void *PyExc_FutureWarning; + EXPCL_PYSTUB extern void *PyExc_ImportError; EXPCL_PYSTUB extern void *PyExc_IndexError; EXPCL_PYSTUB extern void *PyExc_OSError; EXPCL_PYSTUB extern void *PyExc_RuntimeError; @@ -258,6 +261,7 @@ int PyGen_Type(...) { return 0; } int PyGILState_Ensure(...) { return 0; } int PyGILState_Release(...) { return 0; } int PyImport_GetModuleDict(...) { return 0; } +int PyImport_ImportModule(...) { return 0; } int PyInt_AsLong(...) { return 0; } int PyInt_AsSsize_t(...) { return 0; } int PyInt_FromLong(...) { return 0; } @@ -365,6 +369,7 @@ int PyUnicode_GetSize(...) { return 0; } int PyUnicode_InternFromString(...) { return 0; } int PyUnicode_InternInPlace(...) { return 0; } int PyUnicode_Type(...) { return 0; } +int Py_GetVersion(...) { return 0; } int Py_BuildValue(...) { return 0; } int Py_InitModule4(...) { return 0; } int Py_InitModule4_64(...) { return 0; } @@ -397,6 +402,7 @@ void *PyExc_BufferError = (void *)NULL; void *PyExc_ConnectionError = (void *)NULL; void *PyExc_Exception = (void *)NULL; void *PyExc_FutureWarning = (void *)NULL; +void *PyExc_ImportError = (void *)NULL; void *PyExc_IndexError = (void *)NULL; void *PyExc_OSError = (void *)NULL; void *PyExc_RuntimeError = (void *)NULL; From e0e2d6d22227b6ca7ade8d222dbb6590296ebd16 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 11 Feb 2016 19:10:59 +0100 Subject: [PATCH 05/31] Ignore run() in emscripten --- direct/src/task/Task.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 266c823126..3308b6f192 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -483,6 +483,9 @@ class TaskManager: """Starts the task manager running. Does not return until an exception is encountered (including KeyboardInterrupt). """ + if PandaSystem.getPlatform() == 'emscripten': + return + # Set the clock to have last frame's time in case we were # Paused at the prompt for a long time t = self.globalClock.getFrameTime() From 591ce04ab1d119021f0693a0ec048227748ae020 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 11 Feb 2016 19:12:52 +0100 Subject: [PATCH 06/31] Work around black text issue in OpenGL ES 2 renderer --- panda/src/display/graphicsStateGuardian.cxx | 14 +++++++++++++ .../glstuff/glGraphicsStateGuardian_src.cxx | 21 ++++++++++++------- panda/src/glstuff/glShaderContext_src.cxx | 20 ++++++++++++++++++ panda/src/gobj/shader.cxx | 3 +++ panda/src/gobj/shader.h | 4 ++++ 5 files changed, 54 insertions(+), 8 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index f4808f36da..1fbdd40a69 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1239,6 +1239,20 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, return &LMatrix4::ident_mat(); } } + case Shader::SMO_tex_is_alpha_i: { + // This is a hack so we can support both F_alpha and other + // formats in the default shader, to fix font rendering in GLES2 + const TextureAttrib *ta; + if (_target_rs->get_attrib(ta) && + index < ta->get_num_on_stages()) { + TextureStage *ts = ta->get_on_stage(index); + PN_stdfloat v = (ta->get_on_texture(ts)->get_format() == Texture::F_alpha); + t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,v,v,v,0); + return &t; + } else { + return &LMatrix4::zeros_mat(); + } + } case Shader::SMO_plane_x: { const NodePath &np = _target_shader->get_shader_input_nodepath(name); nassertr(!np.is_empty(), &LMatrix4::zeros_mat()); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index b2d5c5788b..2a3a8bea80 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -155,14 +155,14 @@ static const string default_vshader = "attribute vec4 p3d_Color;\n" "attribute vec2 p3d_MultiTexCoord0;\n" "varying vec2 texcoord;\n" - "varying vec4 color;\n" + "varying lowp vec4 color;\n" #endif "uniform mat4 p3d_ModelViewProjectionMatrix;\n" "uniform vec4 p3d_ColorScale;\n" "void main(void) {\n" " gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n" " texcoord = p3d_MultiTexCoord0;\n" - " color = p3d_Color * p3d_ColorScale;\n" + " color = p3d_Color;\n" "}\n"; static const string default_fshader = @@ -171,18 +171,23 @@ static const string default_fshader = "in vec2 texcoord;\n" "in vec4 color;\n" "out vec4 p3d_FragColor;" + "uniform sampler2D p3d_Texture0;\n" + "uniform vec4 p3d_TexAlphaOnly;\n" #else "precision mediump float;\n" "varying vec2 texcoord;\n" - "varying vec4 color;\n" + "varying lowp vec4 color;\n" + "uniform lowp sampler2D p3d_Texture0;\n" + "uniform lowp vec4 p3d_TexAlphaOnly;\n" #endif - "uniform sampler2D p3d_Texture0;\n" "void main(void) {\n" #ifndef OPENGLES " p3d_FragColor = texture(p3d_Texture0, texcoord);\n" - " p3d_FragColor *= color;\n" + " p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering + " p3d_FragColor = color;\n" #else " gl_FragColor = texture2D(p3d_Texture0, texcoord).bgra;\n" + " gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering " gl_FragColor *= color;\n" #endif "}\n"; @@ -11549,9 +11554,9 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { // texture formats? switch (tex->get_format()) { case Texture::F_alpha: - glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_ONE); - glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_ONE); - glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ONE); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_ZERO); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, GL_ZERO); + glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, GL_ZERO); glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, GL_RED); break; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 7e4f973381..6c26a31974 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1198,6 +1198,22 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { _slider_table_size = param_size; return; } + if (noprefix == "TexAlphaOnly") { + Shader::ShaderMatSpec bind; + bind._id = arg_id; + bind._func = Shader::SMF_first; + bind._index = 0; + bind._part[0] = Shader::SMO_tex_is_alpha_i; + bind._arg[0] = NULL; + bind._dep[0] = Shader::SSD_general | Shader::SSD_texture | Shader::SSD_frame; + bind._part[1] = Shader::SMO_identity; + bind._arg[1] = NULL; + bind._dep[1] = Shader::SSD_NONE; + bind._piece = Shader::SMP_row3; + _shader->_mat_spec.push_back(bind); + _shader->_mat_deps |= bind._dep[0] | bind._dep[1]; + return; + } GLCAT.error() << "Unrecognized uniform name '" << param_name << "'!\n"; return; @@ -1850,6 +1866,10 @@ set_state_and_transform(const RenderState *target_rs, target_rs->get_attrib(TexMatrixAttrib::get_class_slot())) { altered |= Shader::SSD_tex_matrix; } + if (_state_rs->get_attrib(TextureAttrib::get_class_slot()) != + target_rs->get_attrib(TextureAttrib::get_class_slot())) { + altered |= Shader::SSD_texture; + } _state_rs = target_rs; } diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index ebac3dde33..a43b5147c1 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -509,6 +509,9 @@ cp_dependency(ShaderMatInput inp) { (inp == SMO_apiclip_to_apiview)) { dep |= SSD_projection; } + if (inp == SMO_tex_is_alpha_i) { + dep |= SSD_texture | SSD_frame; + } return dep; } diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 13b8f749a5..3ee510389c 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -201,6 +201,9 @@ public: // Additional properties for PBR materials SMO_attr_material2, + // Hack for text rendering. Don't use in user shaders. + SMO_tex_is_alpha_i, + SMO_INVALID }; @@ -297,6 +300,7 @@ public: SSD_tex_matrix = 0x200, SSD_frame = 0x400, SSD_projection = 0x800, + SSD_texture = 0x1000, }; enum ShaderBug { From 0d03207d1b0cb0f096b17bfcf129ad965286700f Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 12 Feb 2016 22:20:27 +0100 Subject: [PATCH 07/31] Dramatically reduce size of frozen/compiled code by pruning/masking unnecessary imports/code --- direct/src/directutil/Verify.py | 4 +- direct/src/gui/DirectGuiBase.py | 8 - direct/src/interval/ProjectileInterval.py | 7 - direct/src/showbase/ExceptionVarDump.py | 6 +- direct/src/showbase/GarbageReport.py | 6 +- direct/src/showbase/ObjectPool.py | 9 +- direct/src/showbase/PythonUtil.py | 1268 +++++++++------------ direct/src/showbase/ShowBase.py | 107 +- direct/src/showbase/Transitions.py | 2 +- direct/src/showutil/FreezeTool.py | 4 +- direct/src/stdpy/thread.py | 7 + direct/src/stdpy/threading.py | 173 +-- direct/src/stdpy/threading2.py | 153 ++- direct/src/task/Task.py | 20 +- 14 files changed, 767 insertions(+), 1007 deletions(-) diff --git a/direct/src/directutil/Verify.py b/direct/src/directutil/Verify.py index db28ac7909..8a1f41acb5 100755 --- a/direct/src/directutil/Verify.py +++ b/direct/src/directutil/Verify.py @@ -41,7 +41,9 @@ only when debugging (i.e. when it won't be checked-in) or where it helps you resist using assert for error handling. """ -wantVerifyPdb = 0 # Set to true to load pdb on failure. +from panda3d.core import ConfigVariableBool + +wantVerifyPdb = ConfigVariableBool('want-verify-pdb', False) # Set to true to load pdb on failure. def verify(assertion): diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index bb959a1601..41322bcdff 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -12,7 +12,6 @@ from OnscreenImage import * from direct.directtools.DirectUtil import ROUND_TO from direct.showbase import DirectObject from direct.task import Task -from direct.showbase.PythonUtil import recordCreationStackStr import types guiObjectCollector = PStatCollector("Client::GuiObjects") @@ -651,13 +650,6 @@ def toggleGuiGridSnap(): def setGuiGridSpacing(spacing): DirectGuiWidget.gridSpacing = spacing -# this should trigger off of __dev__, but it's not available at this point. -# __debug__ works because the production client is not __debug__ and the -# production AI doesn't create any GUI. -if get_config_showbase().GetBool('record-gui-creation-stack', __debug__): - # this will help track down the code that created DirectGui objects - # call obj.printCreationStackTrace() to figure out what code created it - DirectGuiBase = recordCreationStackStr(DirectGuiBase) class DirectGuiWidget(DirectGuiBase, NodePath): # Toggle if you wish widget's to snap to grid when draggin diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py index 39077bf1fe..d87253a5ad 100755 --- a/direct/src/interval/ProjectileInterval.py +++ b/direct/src/interval/ProjectileInterval.py @@ -72,13 +72,6 @@ class ProjectileInterval(Interval): self.projectileIntervalNum) ProjectileInterval.projectileIntervalNum += 1 - """ - # attempt to add info about the caller - file, line, func = PythonUtil.callerInfo() - if file is not None: - name += '-%s:%s:%s' % (file, line, func) - """ - args = (startPos, endPos, duration, startVel, endZ, wayPoint, timeToWayPoint, gravityMult) self.implicitStartPos = 0 diff --git a/direct/src/showbase/ExceptionVarDump.py b/direct/src/showbase/ExceptionVarDump.py index a9daafe272..f07161d1f7 100755 --- a/direct/src/showbase/ExceptionVarDump.py +++ b/direct/src/showbase/ExceptionVarDump.py @@ -1,4 +1,5 @@ -from panda3d.direct import get_config_showbase +__all__ = ["install"] + from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.PythonUtil import fastRepr import sys @@ -6,7 +7,6 @@ import types import traceback notify = directNotify.newCategory("ExceptionVarDump") -config = get_config_showbase() reentry = 0 @@ -187,7 +187,7 @@ def install(log, upload): wantStackDumpLog = log wantStackDumpUpload = upload - dumpOnExceptionInit = config.GetBool('variable-dump-on-exception-init', 0) + dumpOnExceptionInit = ConfigVariableBool('variable-dump-on-exception-init', False) if dumpOnExceptionInit: # this mode doesn't completely work because exception objects # thrown by the interpreter don't get created until the diff --git a/direct/src/showbase/GarbageReport.py b/direct/src/showbase/GarbageReport.py index 72dcaf13c7..72c46b4a0e 100755 --- a/direct/src/showbase/GarbageReport.py +++ b/direct/src/showbase/GarbageReport.py @@ -281,7 +281,7 @@ class GarbageReport(Job): if self._args.findCycles: s = ['===== GarbageReport: \'%s\' (%s %s) =====' % ( self._args.name, self.numCycles, - choice(self.numCycles == 1, 'cycle', 'cycles'))] + ('cycle' if self.numCycles == 1 else 'cycles'))] else: s = ['===== GarbageReport: \'%s\' =====' % ( self._args.name)] @@ -499,7 +499,7 @@ class GarbageReport(Job): rootId = index # check if the root object is one of the garbage instances (has __del__) objId = id(self.garbage[rootId]) - numDelInstances = choice(objId in self.garbageInstanceIds, 1, 0) + numDelInstances = int(objId in self.garbageInstanceIds) stateStack.push(([rootId], rootId, numDelInstances, 0)) while True: yield None @@ -535,7 +535,7 @@ class GarbageReport(Job): elif refId is not None: # check if this object is one of the garbage instances (has __del__) objId = id(self.garbage[refId]) - numDelInstances += choice(objId in self.garbageInstanceIds, 1, 0) + numDelInstances += int(objId in self.garbageInstanceIds) # this refId does not complete a cycle. Mark down # where we are in this list of referents, then # start looking through the referents of the new refId diff --git a/direct/src/showbase/ObjectPool.py b/direct/src/showbase/ObjectPool.py index 80109226ce..506a7e2ba5 100755 --- a/direct/src/showbase/ObjectPool.py +++ b/direct/src/showbase/ObjectPool.py @@ -5,7 +5,6 @@ __all__ = ['Diff', 'ObjectPool'] from direct.directnotify.DirectNotifyGlobal import directNotify from direct.showbase.PythonUtil import invertDictLossless, makeList, safeRepr from direct.showbase.PythonUtil import getNumberedTypedString, getNumberedTypedSortedString -from direct.showbase.PythonUtil import getNumberedTypedSortedStringWithReferrersGen import gc class Diff: @@ -97,7 +96,7 @@ class ObjectPool: s += '\n%s\t%s' % (count, typ) return s - def printObjsByType(self, printReferrers=False): + def printObjsByType(self): print 'Object Pool: Objects By Type' print '\n============================' counts = list(set(self._count2types.keys())) @@ -109,11 +108,7 @@ class ObjectPool: types = makeList(self._count2types[count]) for typ in types: print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])) - if printReferrers: - for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]): - print line - else: - print getNumberedTypedSortedString(self._type2objs[typ]) + print getNumberedTypedSortedString(self._type2objs[typ]) def containerLenStr(self): s = 'Object Pool: Container Lengths' diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 16ac46d487..3e8e8aa581 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -1,18 +1,14 @@ - -"""Undocumented Module""" +"""Contains miscellaneous utility functions and classes.""" __all__ = ['indent', -'StackTrace', 'traceFunctionCall', 'traceParentCall', 'printThisCall', 'doc', 'adjust', 'difference', 'intersection', 'union', 'sameElements', 'makeList', 'makeTuple', 'list2dict', 'invertDict', 'invertDictLossless', 'uniqueElements', 'disjoint', 'contains', 'replace', 'reduceAngle', 'fitSrcAngle2Dest', 'fitDestAngle2Src', -'closestDestAngle2', 'closestDestAngle', 'binaryRepr', 'profileFunc', -'profiled', 'startProfile', 'printProfile', 'getSetterName', +'closestDestAngle2', 'closestDestAngle', 'getSetterName', 'getSetter', 'Functor', 'Stack', 'Queue', 'bound', 'clamp', 'lerp', 'average', 'addListsByValue', 'boolEqual', 'lineupPos', 'formatElapsedSeconds', 'solveQuadratic', -'stackEntryInfo', 'lineInfo', 'callerInfo', 'lineTag', 'findPythonModule', 'mostDerivedLast', 'weightedChoice', 'randFloat', 'normalDistrib', 'weightedRand', 'randUint31', 'randInt32', 'randUint32', @@ -20,41 +16,36 @@ __all__ = ['indent', 'SingletonError', 'printListEnum', 'safeRepr', 'fastRepr', 'isDefaultValue', 'ScratchPad', 'Sync', 'itype', 'getNumberedTypedString', -'getNumberedTypedSortedString', 'getNumberedTypedSortedStringWithReferrers', -'getNumberedTypedSortedStringWithReferrersGen', +'getNumberedTypedSortedString', 'printNumberedTyped', 'DelayedCall', 'DelayedFunctor', -'FrameDelayedCall', 'SubframeCall', 'getBase', -'HotkeyBreaker','logMethodCalls','GoldenRatio', +'FrameDelayedCall', 'SubframeCall', 'getBase', 'GoldenRatio', 'GoldenRectangle', 'rad90', 'rad180', 'rad270', 'rad360', -'nullGen', 'loopGen', 'makeFlywheelGen', 'flywheel', 'choice', -'printStack', 'printReverseStack', 'listToIndex2item', 'listToItem2index', -'pandaBreak','pandaTrace','formatTimeCompact', -'deeptype','getProfileResultString','StdoutCapture','StdoutPassthrough', +'nullGen', 'loopGen', 'makeFlywheelGen', 'flywheel', +'listToIndex2item', 'listToItem2index', +'formatTimeCompact','deeptype','StdoutCapture','StdoutPassthrough', 'Averager', 'getRepository', 'formatTimeExact', 'startSuperLog', 'endSuperLog', 'typeName', 'safeTypeName', 'histogramDict', 'unescapeHtmlString'] +if __debug__: + __all__ += ['StackTrace', 'traceFunctionCall', 'traceParentCall', 'printThisCall', + 'stackEntryInfo', 'lineInfo', 'callerInfo', 'lineTag', + 'profileFunc', 'profiled', 'startProfile', 'printProfile', + 'getProfileResultString', 'printStack', 'printReverseStack'] + import types import string import math -import operator -import inspect import os import sys import random import time -import gc -#if __debug__: -import traceback import __builtin__ -from StringIO import StringIO -import marshal +import importlib __report_indent = 3 from panda3d.core import ConfigVariableBool -ScalarTypes = (types.FloatType, types.IntType, types.LongType) - """ # with one integer positional arg, this uses about 4/5 of the memory of the Functor class below def Functor(function, *args, **kArgs): @@ -92,15 +83,6 @@ class Functor: _kargs.update(kargs) return self._function(*(self._args + args), **_kargs) - # this method is used in place of __call__ if we are recording creation stacks - def _exceptionLoggedCreationStack__call__(self, *args, **kargs): - try: - return self._do__call__(*args, **kargs) - except Exception, e: - print '-->Functor creation stack (%s): %s' % ( - self.__name__, self.getCreationStackTraceCompactStr()) - raise - __call__ = _do__call__ def __repr__(self): @@ -186,113 +168,113 @@ def indent(stream, numIndents, str): stream.write(' ' * numIndents + str) -#if __debug__: #RAU accdg to Darren its's ok that StackTrace is not protected by __debug__ -# DCR: if somebody ends up using StackTrace in production, either -# A) it will be OK because it hardly ever gets called, or -# B) it will be easy to track it down (grep for StackTrace) -class StackTrace: - def __init__(self, label="", start=0, limit=None): - """ - label is a string (or anything that be be a string) - that is printed as part of the trace back. - This is just to make it easier to tell what the - stack trace is referring to. - start is an integer number of stack frames back - from the most recent. (This is automatically - bumped up by one to skip the __init__ call - to the StackTrace). - limit is an integer number of stack frames - to record (or None for unlimited). - """ - self.label = label - if limit is not None: - self.trace = traceback.extract_stack(sys._getframe(1+start), - limit=limit) - else: - self.trace = traceback.extract_stack(sys._getframe(1+start)) +if __debug__: + import traceback + import marshal - def compact(self): - r = '' - comma = ',' - for filename, lineNum, funcName, text in self.trace: - r += '%s.%s:%s%s' % (filename[:filename.rfind('.py')][filename.rfind('\\')+1:], funcName, lineNum, comma) - if len(r): - r = r[:-len(comma)] - return r - - def reverseCompact(self): - r = '' - comma = ',' - for filename, lineNum, funcName, text in self.trace: - r = '%s.%s:%s%s%s' % (filename[:filename.rfind('.py')][filename.rfind('\\')+1:], funcName, lineNum, comma, r) - if len(r): - r = r[:-len(comma)] - return r - - def __str__(self): - r = "Debug stack trace of %s (back %s frames):\n"%( - self.label, len(self.trace),) - for i in traceback.format_list(self.trace): - r+=i - r+="***** NOTE: This is not a crash. This is a debug stack trace. *****" - return r - -def printStack(): - print StackTrace(start=1).compact() - return True -def printReverseStack(): - print StackTrace(start=1).reverseCompact() - return True -def printVerboseStack(): - print StackTrace(start=1) - return True - -#----------------------------------------------------------------------------- - -def traceFunctionCall(frame): - """ - return a string that shows the call frame with calling arguments. - e.g. - foo(x=234, y=135) - """ - f = frame - co = f.f_code - dict = f.f_locals - n = co.co_argcount - if co.co_flags & 4: n = n+1 - if co.co_flags & 8: n = n+1 - r='' - if 'self' in dict: - r = '%s.'%(dict['self'].__class__.__name__,) - r+="%s("%(f.f_code.co_name,) - comma=0 # formatting, whether we should type a comma. - for i in range(n): - name = co.co_varnames[i] - if name=='self': - continue - if comma: - r+=', ' - else: - # ok, we skipped the first one, the rest get commas: - comma=1 - r+=name - r+='=' - if name in dict: - v=safeRepr(dict[name]) - if len(v)>2000: - # r+="" - r += (v[:2000] + "...") + class StackTrace: + def __init__(self, label="", start=0, limit=None): + """ + label is a string (or anything that be be a string) + that is printed as part of the trace back. + This is just to make it easier to tell what the + stack trace is referring to. + start is an integer number of stack frames back + from the most recent. (This is automatically + bumped up by one to skip the __init__ call + to the StackTrace). + limit is an integer number of stack frames + to record (or None for unlimited). + """ + self.label = label + if limit is not None: + self.trace = traceback.extract_stack(sys._getframe(1+start), + limit=limit) else: - r+=v - else: r+="*** undefined ***" - return r+')' + self.trace = traceback.extract_stack(sys._getframe(1+start)) -def traceParentCall(): - return traceFunctionCall(sys._getframe(2)) + def compact(self): + r = '' + comma = ',' + for filename, lineNum, funcName, text in self.trace: + r += '%s.%s:%s%s' % (filename[:filename.rfind('.py')][filename.rfind('\\')+1:], funcName, lineNum, comma) + if len(r): + r = r[:-len(comma)] + return r -def printThisCall(): - print traceFunctionCall(sys._getframe(1)) - return 1 # to allow "assert printThisCall()" + def reverseCompact(self): + r = '' + comma = ',' + for filename, lineNum, funcName, text in self.trace: + r = '%s.%s:%s%s%s' % (filename[:filename.rfind('.py')][filename.rfind('\\')+1:], funcName, lineNum, comma, r) + if len(r): + r = r[:-len(comma)] + return r + + def __str__(self): + r = "Debug stack trace of %s (back %s frames):\n"%( + self.label, len(self.trace),) + for i in traceback.format_list(self.trace): + r+=i + r+="***** NOTE: This is not a crash. This is a debug stack trace. *****" + return r + + def printStack(): + print StackTrace(start=1).compact() + return True + def printReverseStack(): + print StackTrace(start=1).reverseCompact() + return True + def printVerboseStack(): + print StackTrace(start=1) + return True + + #----------------------------------------------------------------------------- + + def traceFunctionCall(frame): + """ + return a string that shows the call frame with calling arguments. + e.g. + foo(x=234, y=135) + """ + f = frame + co = f.f_code + dict = f.f_locals + n = co.co_argcount + if co.co_flags & 4: n = n+1 + if co.co_flags & 8: n = n+1 + r='' + if 'self' in dict: + r = '%s.'%(dict['self'].__class__.__name__,) + r+="%s("%(f.f_code.co_name,) + comma=0 # formatting, whether we should type a comma. + for i in range(n): + name = co.co_varnames[i] + if name=='self': + continue + if comma: + r+=', ' + else: + # ok, we skipped the first one, the rest get commas: + comma=1 + r+=name + r+='=' + if name in dict: + v=safeRepr(dict[name]) + if len(v)>2000: + # r+="" + r += (v[:2000] + "...") + else: + r+=v + else: r+="*** undefined ***" + return r+')' + + def traceParentCall(): + return traceFunctionCall(sys._getframe(2)) + + def printThisCall(): + print traceFunctionCall(sys._getframe(1)) + return 1 # to allow "assert printThisCall()" # Magic numbers: These are the bit masks in func_code.co_flags that # reveal whether or not the function has a *arg or **kw argument. @@ -327,7 +309,6 @@ def adjust(command = None, dim = 1, parent = None, **kw): # Make sure we enable Tk # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. - import importlib Valuator = importlib.import_module('direct.tkwidgets.Valuator') # Set command if specified if command: @@ -579,19 +560,6 @@ def closestDestAngle(src, dest): # otherwise just go to the original destination return dest - -def binaryRepr(number, max_length = 32): - # This will only work reliably for relatively small numbers. - # Increase the value of max_length if you think you're going - # to use long integers - assert number < 2L << max_length - shifts = map (operator.rshift, max_length * [number], \ - range (max_length - 1, -1, -1)) - digits = map (operator.mod, shifts, max_length * [2]) - if not digits.count (1): return 0 - digits = digits [digits.index (1):] - return ''.join([repr(digit) for digit in digits]) - class StdoutCapture: # redirects stdout to a string def __init__(self): @@ -618,260 +586,263 @@ class StdoutPassthrough(StdoutCapture): self._oldStdout.write(string) # constant profile defaults -PyUtilProfileDefaultFilename = 'profiledata' -PyUtilProfileDefaultLines = 80 -PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls'] +if __debug__: + from StringIO import StringIO -_ProfileResultStr = '' + PyUtilProfileDefaultFilename = 'profiledata' + PyUtilProfileDefaultLines = 80 + PyUtilProfileDefaultSorts = ['cumulative', 'time', 'calls'] -def getProfileResultString(): - # if you called profile with 'log' not set to True, - # you can call this function to get the results as - # a string - global _ProfileResultStr - return _ProfileResultStr + _ProfileResultStr = '' -def profileFunc(callback, name, terse, log=True): - global _ProfileResultStr - if 'globalProfileFunc' in __builtin__.__dict__: - # rats. Python profiler is not re-entrant... - base.notify.warning( - 'PythonUtil.profileStart(%s): aborted, already profiling %s' - #'\nStack Trace:\n%s' - % (name, __builtin__.globalProfileFunc, - #StackTrace() - )) - return - __builtin__.globalProfileFunc = callback - __builtin__.globalProfileResult = [None] - prefix = '***** START PROFILE: %s *****' % name - if log: - print prefix - startProfile(cmd='globalProfileResult[0]=globalProfileFunc()', callInfo=(not terse), silent=not log) - suffix = '***** END PROFILE: %s *****' % name - if log: - print suffix - else: - _ProfileResultStr = '%s\n%s\n%s' % (prefix, _ProfileResultStr, suffix) - result = globalProfileResult[0] - del __builtin__.__dict__['globalProfileFunc'] - del __builtin__.__dict__['globalProfileResult'] - return result + def getProfileResultString(): + # if you called profile with 'log' not set to True, + # you can call this function to get the results as + # a string + global _ProfileResultStr + return _ProfileResultStr -def profiled(category=None, terse=False): - """ decorator for profiling functions - turn categories on and off via "want-profile-categoryName 1" - - e.g. - - @profiled('particles') - def loadParticles(): - ... - - want-profile-particles 1 - """ - assert type(category) in (types.StringType, types.NoneType), "must provide a category name for @profiled" - - # allow profiling in published versions - """ - try: - null = not __dev__ - except: - null = not __debug__ - if null: - # if we're not in __dev__, just return the function itself. This - # results in zero runtime overhead, since decorators are evaluated - # at module-load. - def nullDecorator(f): - return f - return nullDecorator - """ - - def profileDecorator(f): - def _profiled(*args, **kArgs): - name = '(%s) %s from %s' % (category, f.func_name, f.__module__) - - # showbase might not be loaded yet, so don't use - # base.config. Instead, query the ConfigVariableBool. - if (category is None) or ConfigVariableBool('want-profile-%s' % category, 0).getValue(): - return profileFunc(Functor(f, *args, **kArgs), name, terse) - else: - return f(*args, **kArgs) - _profiled.__doc__ = f.__doc__ - return _profiled - return profileDecorator - -# intercept profile-related file operations to avoid disk access -movedOpenFuncs = [] -movedDumpFuncs = [] -movedLoadFuncs = [] -profileFilenames = set() -profileFilenameList = Stack() -profileFilename2file = {} -profileFilename2marshalData = {} - -def _profileOpen(filename, *args, **kArgs): - # this is a replacement for the file open() builtin function - # for use during profiling, to intercept the file open - # operation used by the Python profiler and profile stats - # systems - if filename in profileFilenames: - # if this is a file related to profiling, create an - # in-RAM file object - if filename not in profileFilename2file: - file = StringIO() - file._profFilename = filename - profileFilename2file[filename] = file + def profileFunc(callback, name, terse, log=True): + global _ProfileResultStr + if 'globalProfileFunc' in __builtin__.__dict__: + # rats. Python profiler is not re-entrant... + base.notify.warning( + 'PythonUtil.profileStart(%s): aborted, already profiling %s' + #'\nStack Trace:\n%s' + % (name, __builtin__.globalProfileFunc, + #StackTrace() + )) + return + __builtin__.globalProfileFunc = callback + __builtin__.globalProfileResult = [None] + prefix = '***** START PROFILE: %s *****' % name + if log: + print prefix + startProfile(cmd='globalProfileResult[0]=globalProfileFunc()', callInfo=(not terse), silent=not log) + suffix = '***** END PROFILE: %s *****' % name + if log: + print suffix else: - file = profileFilename2file[filename] - else: - file = movedOpenFuncs[-1](filename, *args, **kArgs) - return file + _ProfileResultStr = '%s\n%s\n%s' % (prefix, _ProfileResultStr, suffix) + result = globalProfileResult[0] + del __builtin__.__dict__['globalProfileFunc'] + del __builtin__.__dict__['globalProfileResult'] + return result -def _profileMarshalDump(data, file): - # marshal.dump doesn't work with StringIO objects - # simulate it - if isinstance(file, StringIO) and hasattr(file, '_profFilename'): - if file._profFilename in profileFilenames: - profileFilename2marshalData[file._profFilename] = data - return None - return movedDumpFuncs[-1](data, file) + def profiled(category=None, terse=False): + """ decorator for profiling functions + turn categories on and off via "want-profile-categoryName 1" -def _profileMarshalLoad(file): - # marshal.load doesn't work with StringIO objects - # simulate it - if isinstance(file, StringIO) and hasattr(file, '_profFilename'): - if file._profFilename in profileFilenames: - return profileFilename2marshalData[file._profFilename] - return movedLoadFuncs[-1](file) + e.g. -def _installProfileCustomFuncs(filename): - assert filename not in profileFilenames - profileFilenames.add(filename) - profileFilenameList.push(filename) - movedOpenFuncs.append(__builtin__.open) - __builtin__.open = _profileOpen - movedDumpFuncs.append(marshal.dump) - marshal.dump = _profileMarshalDump - movedLoadFuncs.append(marshal.load) - marshal.load = _profileMarshalLoad + @profiled('particles') + def loadParticles(): + ... -def _getProfileResultFileInfo(filename): - return (profileFilename2file.get(filename, None), - profileFilename2marshalData.get(filename, None)) + want-profile-particles 1 + """ + assert type(category) in (types.StringType, types.NoneType), "must provide a category name for @profiled" -def _setProfileResultsFileInfo(filename, info): - f, m = info - if f: - profileFilename2file[filename] = f - if m: - profileFilename2marshalData[filename] = m + # allow profiling in published versions + """ + try: + null = not __dev__ + except: + null = not __debug__ + if null: + # if we're not in __dev__, just return the function itself. This + # results in zero runtime overhead, since decorators are evaluated + # at module-load. + def nullDecorator(f): + return f + return nullDecorator + """ -def _clearProfileResultFileInfo(filename): - profileFilename2file.pop(filename, None) - profileFilename2marshalData.pop(filename, None) + def profileDecorator(f): + def _profiled(*args, **kArgs): + name = '(%s) %s from %s' % (category, f.func_name, f.__module__) -def _removeProfileCustomFuncs(filename): - assert profileFilenameList.top() == filename - marshal.load = movedLoadFuncs.pop() - marshal.dump = movedDumpFuncs.pop() - __builtin__.open = movedOpenFuncs.pop() - profileFilenames.remove(filename) - profileFilenameList.pop() - profileFilename2file.pop(filename, None) - # don't let marshalled data pile up - profileFilename2marshalData.pop(filename, None) + # showbase might not be loaded yet, so don't use + # base.config. Instead, query the ConfigVariableBool. + if (category is None) or ConfigVariableBool('want-profile-%s' % category, 0).getValue(): + return profileFunc(Functor(f, *args, **kArgs), name, terse) + else: + return f(*args, **kArgs) + _profiled.__doc__ = f.__doc__ + return _profiled + return profileDecorator + + # intercept profile-related file operations to avoid disk access + movedOpenFuncs = [] + movedDumpFuncs = [] + movedLoadFuncs = [] + profileFilenames = set() + profileFilenameList = Stack() + profileFilename2file = {} + profileFilename2marshalData = {} + + def _profileOpen(filename, *args, **kArgs): + # this is a replacement for the file open() builtin function + # for use during profiling, to intercept the file open + # operation used by the Python profiler and profile stats + # systems + if filename in profileFilenames: + # if this is a file related to profiling, create an + # in-RAM file object + if filename not in profileFilename2file: + file = StringIO() + file._profFilename = filename + profileFilename2file[filename] = file + else: + file = profileFilename2file[filename] + else: + file = movedOpenFuncs[-1](filename, *args, **kArgs) + return file + + def _profileMarshalDump(data, file): + # marshal.dump doesn't work with StringIO objects + # simulate it + if isinstance(file, StringIO) and hasattr(file, '_profFilename'): + if file._profFilename in profileFilenames: + profileFilename2marshalData[file._profFilename] = data + return None + return movedDumpFuncs[-1](data, file) + + def _profileMarshalLoad(file): + # marshal.load doesn't work with StringIO objects + # simulate it + if isinstance(file, StringIO) and hasattr(file, '_profFilename'): + if file._profFilename in profileFilenames: + return profileFilename2marshalData[file._profFilename] + return movedLoadFuncs[-1](file) + + def _installProfileCustomFuncs(filename): + assert filename not in profileFilenames + profileFilenames.add(filename) + profileFilenameList.push(filename) + movedOpenFuncs.append(__builtin__.open) + __builtin__.open = _profileOpen + movedDumpFuncs.append(marshal.dump) + marshal.dump = _profileMarshalDump + movedLoadFuncs.append(marshal.load) + marshal.load = _profileMarshalLoad + + def _getProfileResultFileInfo(filename): + return (profileFilename2file.get(filename, None), + profileFilename2marshalData.get(filename, None)) + + def _setProfileResultsFileInfo(filename, info): + f, m = info + if f: + profileFilename2file[filename] = f + if m: + profileFilename2marshalData[filename] = m + + def _clearProfileResultFileInfo(filename): + profileFilename2file.pop(filename, None) + profileFilename2marshalData.pop(filename, None) + + def _removeProfileCustomFuncs(filename): + assert profileFilenameList.top() == filename + marshal.load = movedLoadFuncs.pop() + marshal.dump = movedDumpFuncs.pop() + __builtin__.open = movedOpenFuncs.pop() + profileFilenames.remove(filename) + profileFilenameList.pop() + profileFilename2file.pop(filename, None) + # don't let marshalled data pile up + profileFilename2marshalData.pop(filename, None) -# call this from the prompt, and break back out to the prompt -# to stop profiling -# -# OR to do inline profiling, you must make a globally-visible -# function to be profiled, i.e. to profile 'self.load()', do -# something like this: -# -# def func(self=self): -# self.load() -# import __builtin__ -# __builtin__.func = func -# PythonUtil.startProfile(cmd='func()', filename='profileData') -# del __builtin__.func -# -def _profileWithoutGarbageLeak(cmd, filename): - # The profile module isn't necessarily installed on every Python - # installation, so we import it here, instead of in the module - # scope. - import profile - # this is necessary because the profile module creates a memory leak - Profile = profile.Profile - statement = cmd - sort = -1 - retVal = None - #### COPIED FROM profile.run #### - prof = Profile() - try: - prof = prof.run(statement) - except SystemExit: - pass - if filename is not None: - prof.dump_stats(filename) - else: - #return prof.print_stats(sort) #DCR - retVal = prof.print_stats(sort) #DCR - ################################# - # eliminate the garbage leak - del prof.dispatcher - return retVal + # call this from the prompt, and break back out to the prompt + # to stop profiling + # + # OR to do inline profiling, you must make a globally-visible + # function to be profiled, i.e. to profile 'self.load()', do + # something like this: + # + # def func(self=self): + # self.load() + # import __builtin__ + # __builtin__.func = func + # PythonUtil.startProfile(cmd='func()', filename='profileData') + # del __builtin__.func + # + def _profileWithoutGarbageLeak(cmd, filename): + # The profile module isn't necessarily installed on every Python + # installation, so we import it here, instead of in the module + # scope. + import profile + # this is necessary because the profile module creates a memory leak + Profile = profile.Profile + statement = cmd + sort = -1 + retVal = None + #### COPIED FROM profile.run #### + prof = Profile() + try: + prof = prof.run(statement) + except SystemExit: + pass + if filename is not None: + prof.dump_stats(filename) + else: + #return prof.print_stats(sort) #DCR + retVal = prof.print_stats(sort) #DCR + ################################# + # eliminate the garbage leak + del prof.dispatcher + return retVal -def startProfile(filename=PyUtilProfileDefaultFilename, - lines=PyUtilProfileDefaultLines, - sorts=PyUtilProfileDefaultSorts, - silent=0, - callInfo=1, - useDisk=False, - cmd='run()'): - # uniquify the filename to allow multiple processes to profile simultaneously - filename = '%s.%s%s' % (filename, randUint31(), randUint31()) - if not useDisk: - # use a RAM file - _installProfileCustomFuncs(filename) - _profileWithoutGarbageLeak(cmd, filename) - if silent: - extractProfile(filename, lines, sorts, callInfo) - else: - printProfile(filename, lines, sorts, callInfo) - if not useDisk: - # discard the RAM file - _removeProfileCustomFuncs(filename) - else: - os.remove(filename) + def startProfile(filename=PyUtilProfileDefaultFilename, + lines=PyUtilProfileDefaultLines, + sorts=PyUtilProfileDefaultSorts, + silent=0, + callInfo=1, + useDisk=False, + cmd='run()'): + # uniquify the filename to allow multiple processes to profile simultaneously + filename = '%s.%s%s' % (filename, randUint31(), randUint31()) + if not useDisk: + # use a RAM file + _installProfileCustomFuncs(filename) + _profileWithoutGarbageLeak(cmd, filename) + if silent: + extractProfile(filename, lines, sorts, callInfo) + else: + printProfile(filename, lines, sorts, callInfo) + if not useDisk: + # discard the RAM file + _removeProfileCustomFuncs(filename) + else: + os.remove(filename) -# call these to see the results again, as a string or in the log -def printProfile(filename=PyUtilProfileDefaultFilename, - lines=PyUtilProfileDefaultLines, - sorts=PyUtilProfileDefaultSorts, - callInfo=1): - import pstats - s = pstats.Stats(filename) - s.strip_dirs() - for sort in sorts: - s.sort_stats(sort) - s.print_stats(lines) - if callInfo: - s.print_callees(lines) - s.print_callers(lines) + # call these to see the results again, as a string or in the log + def printProfile(filename=PyUtilProfileDefaultFilename, + lines=PyUtilProfileDefaultLines, + sorts=PyUtilProfileDefaultSorts, + callInfo=1): + import pstats + s = pstats.Stats(filename) + s.strip_dirs() + for sort in sorts: + s.sort_stats(sort) + s.print_stats(lines) + if callInfo: + s.print_callees(lines) + s.print_callers(lines) -# same args as printProfile -def extractProfile(*args, **kArgs): - global _ProfileResultStr - # capture print output - sc = StdoutCapture() - # print the profile output, redirected to the result string - printProfile(*args, **kArgs) - # make a copy of the print output - _ProfileResultStr = sc.getString() - # restore stdout to what it was before - sc.destroy() + # same args as printProfile + def extractProfile(*args, **kArgs): + global _ProfileResultStr + # capture print output + sc = StdoutCapture() + # print the profile output, redirected to the result string + printProfile(*args, **kArgs) + # make a copy of the print output + _ProfileResultStr = sc.getString() + # restore stdout to what it was before + sc.destroy() def getSetterName(valueName, prefix='set'): # getSetterName('color') -> 'setColor' @@ -1032,77 +1003,80 @@ def solveQuadratic(a, b, c): root2 = ((-b) + sqrtD) / twoA return [root1, root2] -def stackEntryInfo(depth=0, baseFileName=1): - """ - returns the sourcefilename, line number, and function name of - an entry in the stack. - 'depth' is how far back to go in the stack; 0 is the caller of this - function, 1 is the function that called the caller of this function, etc. - by default, strips off the path of the filename; override with baseFileName - returns (fileName, lineNum, funcName) --> (string, int, string) - returns (None, None, None) on error - """ - try: - stack = None - frame = None +if __debug__: + def stackEntryInfo(depth=0, baseFileName=1): + """ + returns the sourcefilename, line number, and function name of + an entry in the stack. + 'depth' is how far back to go in the stack; 0 is the caller of this + function, 1 is the function that called the caller of this function, etc. + by default, strips off the path of the filename; override with baseFileName + returns (fileName, lineNum, funcName) --> (string, int, string) + returns (None, None, None) on error + """ + import inspect + try: - stack = inspect.stack() - # add one to skip the frame associated with this function - frame = stack[depth+1] - filename = frame[1] - if baseFileName: - filename = os.path.basename(filename) - lineNum = frame[2] - funcName = frame[3] - result = (filename, lineNum, funcName) - finally: - del stack - del frame - except: - result = (None, None, None) + stack = None + frame = None + try: + stack = inspect.stack() + # add one to skip the frame associated with this function + frame = stack[depth+1] + filename = frame[1] + if baseFileName: + filename = os.path.basename(filename) + lineNum = frame[2] + funcName = frame[3] + result = (filename, lineNum, funcName) + finally: + del stack + del frame + except: + result = (None, None, None) - return result + return result -def lineInfo(baseFileName=1): - """ - returns the sourcefilename, line number, and function name of the - code that called this function - (answers the question: 'hey lineInfo, where am I in the codebase?') - see stackEntryInfo, above, for info on 'baseFileName' and return types - """ - return stackEntryInfo(1, baseFileName) + def lineInfo(baseFileName=1): + """ + returns the sourcefilename, line number, and function name of the + code that called this function + (answers the question: 'hey lineInfo, where am I in the codebase?') + see stackEntryInfo, above, for info on 'baseFileName' and return types + """ + return stackEntryInfo(1, baseFileName) -def callerInfo(baseFileName=1, howFarBack=0): - """ - returns the sourcefilename, line number, and function name of the - caller of the function that called this function - (answers the question: 'hey callerInfo, who called me?') - see stackEntryInfo, above, for info on 'baseFileName' and return types - """ - return stackEntryInfo(2+howFarBack, baseFileName) + def callerInfo(baseFileName=1, howFarBack=0): + """ + returns the sourcefilename, line number, and function name of the + caller of the function that called this function + (answers the question: 'hey callerInfo, who called me?') + see stackEntryInfo, above, for info on 'baseFileName' and return types + """ + return stackEntryInfo(2+howFarBack, baseFileName) -def lineTag(baseFileName=1, verbose=0, separator=':'): - """ - returns a string containing the sourcefilename and line number - of the code that called this function - (equivalent to lineInfo, above, with different return type) - see stackEntryInfo, above, for info on 'baseFileName' + def lineTag(baseFileName=1, verbose=0, separator=':'): + """ + returns a string containing the sourcefilename and line number + of the code that called this function + (equivalent to lineInfo, above, with different return type) + see stackEntryInfo, above, for info on 'baseFileName' - if 'verbose' is false, returns a compact string of the form - 'fileName:lineNum:funcName' - if 'verbose' is true, returns a longer string that matches the - format of Python stack trace dumps + if 'verbose' is false, returns a compact string of the form + 'fileName:lineNum:funcName' + if 'verbose' is true, returns a longer string that matches the + format of Python stack trace dumps - returns empty string on error - """ - fileName, lineNum, funcName = callerInfo(baseFileName) - if fileName is None: - return '' - if verbose: - return 'File "%s", line %s, in %s' % (fileName, lineNum, funcName) - else: - return '%s%s%s%s%s' % (fileName, separator, lineNum, separator, - funcName) + returns empty string on error + """ + fileName, lineNum, funcName = callerInfo(baseFileName) + if fileName is None: + return '' + if verbose: + return 'File "%s", line %s, in %s' % (fileName, lineNum, funcName) + else: + return '%s%s%s%s%s' % (fileName, separator, lineNum, separator, + funcName) def findPythonModule(module): # Look along the python load path for the indicated filename. @@ -1756,43 +1730,6 @@ def getNumberedTypedSortedString(items, maxLen=5000, numPrefix=''): s += format % (i, itype(items[i]), strs[i]) return s -def getNumberedTypedSortedStringWithReferrersGen(items, maxLen=10000, numPrefix=''): - """get a string that has each item of the list on its own line, - the items are stringwise-sorted, the object's referrers are shown, - and each item is numbered on the left from zero""" - digits = 0 - n = len(items) - while n > 0: - digits += 1 - n //= 10 - digits = digits - format = numPrefix + '%0' + '%s' % digits + 'i:%s @ %s \t%s' - snip = '' - strs = [] - for item in items: - strs.append(fastRepr(item)) - strs.sort() - for i in xrange(len(strs)): - item = items[i] - objStr = strs[i] - objStr += ', \tREFERRERS=[' - referrers = gc.get_referrers(item) - for ref in referrers: - objStr += '%s@%s, ' % (itype(ref), id(ref)) - objStr += ']' - if len(objStr) > maxLen: - objStr = '%s%s' % (objStr[:(maxLen-len(snip))], snip) - yield format % (i, itype(items[i]), id(items[i]), objStr) - -def getNumberedTypedSortedStringWithReferrers(items, maxLen=10000, numPrefix=''): - """get a string that has each item of the list on its own line, - the items are stringwise-sorted, the object's referrers are shown, - and each item is numbered on the left from zero""" - s = '' - for line in getNumberedTypedSortedStringWithReferrersGen(items, maxLen, numPrefix): - s += '%s\n' % line - return s - def printNumberedTyped(items, maxLen=5000): """print out each item of the list on its own line, with each item numbered on the left from zero""" @@ -2114,7 +2051,7 @@ def report(types = [], prefix = '', xform = None, notifyFunc = None, dConfigPara except NameError,e: return decorator - from direct.distributed.ClockDelta import globalClockDelta + globalClockDelta = importlib.import_module("direct.distributed.ClockDelta").globalClockDelta def decorator(f): def wrap(*args,**kwargs): @@ -2210,127 +2147,57 @@ def getRepository(): return simbase.air exceptionLoggedNotify = None +if __debug__: + def exceptionLogged(append=True): + """decorator that outputs the function name and all arguments + if an exception passes back through the stack frame + if append is true, string is appended to the __str__ output of + the exception. if append is false, string is printed to the log + directly. If the output will take up many lines, it's recommended + to set append to False so that the exception stack is not hidden + by the output of this decorator. + """ + try: + null = not __dev__ + except: + null = not __debug__ + if null: + # if we're not in __dev__, just return the function itself. This + # results in zero runtime overhead, since decorators are evaluated + # at module-load. + def nullDecorator(f): + return f + return nullDecorator -def exceptionLogged(append=True): - """decorator that outputs the function name and all arguments - if an exception passes back through the stack frame - if append is true, string is appended to the __str__ output of - the exception. if append is false, string is printed to the log - directly. If the output will take up many lines, it's recommended - to set append to False so that the exception stack is not hidden - by the output of this decorator. - """ - try: - null = not __dev__ - except: - null = not __debug__ - if null: - # if we're not in __dev__, just return the function itself. This - # results in zero runtime overhead, since decorators are evaluated - # at module-load. - def nullDecorator(f): - return f - return nullDecorator - - def _decoratorFunc(f, append=append): - global exceptionLoggedNotify - if exceptionLoggedNotify is None: - from direct.directnotify.DirectNotifyGlobal import directNotify - exceptionLoggedNotify = directNotify.newCategory("ExceptionLogged") - def _exceptionLogged(*args, **kArgs): - try: - return f(*args, **kArgs) - except Exception, e: + def _decoratorFunc(f, append=append): + global exceptionLoggedNotify + if exceptionLoggedNotify is None: + from direct.directnotify.DirectNotifyGlobal import directNotify + exceptionLoggedNotify = directNotify.newCategory("ExceptionLogged") + def _exceptionLogged(*args, **kArgs): try: - s = '%s(' % f.func_name - for arg in args: - s += '%s, ' % arg - for key, value in kArgs.items(): - s += '%s=%s, ' % (key, value) - if len(args) or len(kArgs): - s = s[:-2] - s += ')' - if append: - appendStr(e, '\n%s' % s) - else: - exceptionLoggedNotify.info(s) - except: - exceptionLoggedNotify.info( - '%s: ERROR IN PRINTING' % f.func_name) - raise - _exceptionLogged.__doc__ = f.__doc__ - return _exceptionLogged - return _decoratorFunc - -# class 'decorator' that records the stack at the time of creation -# be careful with this, it creates a StackTrace, and that can take a -# lot of CPU -def recordCreationStack(cls): - if not hasattr(cls, '__init__'): - raise 'recordCreationStack: class \'%s\' must define __init__' % cls.__name__ - cls.__moved_init__ = cls.__init__ - def __recordCreationStack_init__(self, *args, **kArgs): - self._creationStackTrace = StackTrace(start=1) - return self.__moved_init__(*args, **kArgs) - def getCreationStackTrace(self): - return self._creationStackTrace - def getCreationStackTraceCompactStr(self): - return self._creationStackTrace.compact() - def printCreationStackTrace(self): - print self._creationStackTrace - cls.__init__ = __recordCreationStack_init__ - cls.getCreationStackTrace = getCreationStackTrace - cls.getCreationStackTraceCompactStr = getCreationStackTraceCompactStr - cls.printCreationStackTrace = printCreationStackTrace - return cls - -# like recordCreationStack but stores the stack as a compact stack list-of-strings -# scales well for memory usage -def recordCreationStackStr(cls): - if not hasattr(cls, '__init__'): - raise 'recordCreationStackStr: class \'%s\' must define __init__' % cls.__name__ - cls.__moved_init__ = cls.__init__ - def __recordCreationStackStr_init__(self, *args, **kArgs): - # store as list of strings to conserve memory - self._creationStackTraceStrLst = StackTrace(start=1).compact().split(',') - return self.__moved_init__(*args, **kArgs) - def getCreationStackTraceCompactStr(self): - return ','.join(self._creationStackTraceStrLst) - def printCreationStackTrace(self): - print ','.join(self._creationStackTraceStrLst) - cls.__init__ = __recordCreationStackStr_init__ - cls.getCreationStackTraceCompactStr = getCreationStackTraceCompactStr - cls.printCreationStackTrace = printCreationStackTrace - return cls - - -# class 'decorator' that logs all method calls for a particular class -def logMethodCalls(cls): - if not hasattr(cls, 'notify'): - raise 'logMethodCalls: class \'%s\' must have a notify' % cls.__name__ - for name in dir(cls): - method = getattr(cls, name) - if hasattr(method, '__call__'): - def getLoggedMethodCall(method): - def __logMethodCall__(obj, *args, **kArgs): - s = '%s(' % method.__name__ - for arg in args: - try: - argStr = repr(arg) - except: - argStr = 'bad repr: %s' % arg.__class__ - s += '%s, ' % argStr - for karg, value in kArgs.items(): - s += '%s=%s, ' % (karg, repr(value)) - if len(args) or len(kArgs): - s = s[:-2] - s += ')' - obj.notify.info(s) - return method(obj, *args, **kArgs) - return __logMethodCall__ - setattr(cls, name, getLoggedMethodCall(method)) - __logMethodCall__ = None - return cls + return f(*args, **kArgs) + except Exception, e: + try: + s = '%s(' % f.func_name + for arg in args: + s += '%s, ' % arg + for key, value in kArgs.items(): + s += '%s=%s, ' % (key, value) + if len(args) or len(kArgs): + s = s[:-2] + s += ')' + if append: + appendStr(e, '\n%s' % s) + else: + exceptionLoggedNotify.info(s) + except: + exceptionLoggedNotify.info( + '%s: ERROR IN PRINTING' % f.func_name) + raise + _exceptionLogged.__doc__ = f.__doc__ + return _exceptionLogged + return _decoratorFunc # http://en.wikipedia.org/wiki/Golden_ratio GoldenRatio = (1. + math.sqrt(5.)) / 2. @@ -2342,45 +2209,6 @@ class GoldenRectangle: def getShorterEdge(longer): return longer / GoldenRatio -class HotkeyBreaker: - def __init__(self,breakKeys = []): - from direct.showbase.DirectObject import DirectObject - self.do = DirectObject() - self.breakKeys = {} - if not isinstance(breakKeys, (list,tuple)): - breakKeys = (breakKeys,) - for key in breakKeys: - self.addBreakKey(key) - - def addBreakKey(self,breakKey): - if __dev__: - self.do.accept(breakKey,self.breakFunc,extraArgs = [breakKey]) - - def removeBreakKey(self,breakKey): - if __dev__: - self.do.ignore(breakKey) - - def breakFunc(self,breakKey): - if __dev__: - self.breakKeys[breakKey] = True - - def setBreakPt(self, breakKey = None, persistent = False): - if __dev__: - if not breakKey: - import pdb;pdb.set_trace() - return True - else: - if self.breakKeys.get(breakKey,False): - if not persistent: - self.breakKeys.pop(breakKey) - import pdb;pdb.set_trace() - return True - return True - - def clearBreakPt(self, breakKey): - if __dev__: - return bool(self.breakKeys.pop(breakKey,None)) - def nullGen(): # generator that ends immediately if False: @@ -2480,40 +2308,42 @@ if __debug__ and __name__ == '__main__': assert obj2count[3] == 3 * 3 assert obj2count[4] == 4 * 3 -def quickProfile(name="unnamed"): - import pstats - def profileDecorator(f): - if(not config.GetBool("use-profiler",0)): - return f - def _profiled(*args, **kArgs): - # must do this in here because we don't have base/simbase - # at the time that PythonUtil is loaded - if(not config.GetBool("profile-debug",0)): - #dumb timings - st=globalClock.getRealTime() - f(*args,**kArgs) - s=globalClock.getRealTime()-st - print "Function %s.%s took %s seconds"%(f.__module__, f.__name__,s) - else: - import profile as prof, pstats - #detailed profile, stored in base.stats under ( - if(not hasattr(base,"stats")): - base.stats={} - if(not base.stats.get(name)): - base.stats[name]=[] +if __debug__: + def quickProfile(name="unnamed"): + import pstats + def profileDecorator(f): + if(not config.GetBool("use-profiler",0)): + return f + def _profiled(*args, **kArgs): + # must do this in here because we don't have base/simbase + # at the time that PythonUtil is loaded + if(not config.GetBool("profile-debug",0)): + #dumb timings + st=globalClock.getRealTime() + f(*args,**kArgs) + s=globalClock.getRealTime()-st + print "Function %s.%s took %s seconds"%(f.__module__, f.__name__,s) + else: + import profile as prof, pstats - prof.runctx('f(*args, **kArgs)', {'f':f,'args':args,'kArgs':kArgs},None,"t.prof") - s=pstats.Stats("t.prof") - #p=hotshot.Profile("t.prof") - #p.runctx('f(*args, **kArgs)', {'f':f,'args':args,'kArgs':kArgs},None) - #s = hotshot.stats.load("t.prof") - s.strip_dirs() - s.sort_stats("cumulative") - base.stats[name].append(s) + #detailed profile, stored in base.stats under ( + if(not hasattr(base,"stats")): + base.stats={} + if(not base.stats.get(name)): + base.stats[name]=[] - _profiled.__doc__ = f.__doc__ - return _profiled - return profileDecorator + prof.runctx('f(*args, **kArgs)', {'f':f,'args':args,'kArgs':kArgs},None,"t.prof") + s=pstats.Stats("t.prof") + #p=hotshot.Profile("t.prof") + #p.runctx('f(*args, **kArgs)', {'f':f,'args':args,'kArgs':kArgs},None) + #s = hotshot.stats.load("t.prof") + s.strip_dirs() + s.sort_stats("cumulative") + base.stats[name].append(s) + + _profiled.__doc__ = f.__doc__ + return _profiled + return profileDecorator def getTotalAnnounceTime(): td=0 @@ -2533,13 +2363,6 @@ def getAnnounceGenerateTime(stat): return val -def choice(condition, ifTrue, ifFalse): - # equivalent of C++ (condition ? ifTrue : ifFalse) - if condition: - return ifTrue - else: - return ifFalse - class MiniLog: def __init__(self, name): self.indent = 1 @@ -2611,14 +2434,6 @@ class HierarchyException(Exception): def __repr__(self): return 'HierarchyException(%s)' % (self.owner, ) -# __dev__ is not defined at import time, call this after it's defined -def recordFunctorCreationStacks(): - global Functor - if not hasattr(Functor, '_functorCreationStacksRecorded'): - Functor = recordCreationStackStr(Functor) - Functor._functorCreationStacksRecorded = True - Functor.__call__ = Functor._exceptionLoggedCreationStack__call__ - def formatTimeCompact(seconds): # returns string in format '1d3h22m43s' result = '' @@ -2735,57 +2550,6 @@ if __debug__ and __name__ == '__main__': testAlphabetCounter() del testAlphabetCounter -globalPdb = None - -traceCalled = False - -def setupPdb(): - import pdb; - class pandaPdb(pdb.Pdb): - def stop_here(self, frame): - global traceCalled - if(traceCalled): - result = pdb.Pdb.stop_here(self, frame) - if(result == True): - traceCalled = False - return result - if frame is self.stopframe: - return True - return False - global globalPdb - globalPdb = pandaPdb() - globalPdb.reset() - sys.settrace(globalPdb.trace_dispatch) - -def pandaTrace(): - if __dev__: - if not globalPdb: - setupPdb() - global traceCalled - globalPdb.set_trace(sys._getframe().f_back) - traceCalled = True - -packageMap = { - "toontown":"$TOONTOWN", - "direct":"$DIRECT", - "otp":"$OTP", - "pirates":"$PIRATES", -} - - -#assuming . dereferncing for nice linking to imports -def pandaBreak(dotpath, linenum, temporary = 0, cond = None): - if __dev__: - from panda3d.core import Filename - if not globalPdb: - setupPdb() - dirs = dotpath.split(".") - root = Filename.expandFrom(packageMap[dirs[0]]).toOsSpecific() - filename = root + "\\src" - for d in dirs[1:]: - filename="%s\\%s"%(filename,d) - print filename - globalPdb.set_break(filename+".py", linenum, temporary, cond) class Default: # represents 'use the default value' @@ -2917,18 +2681,20 @@ __builtin__.SerialMaskedGen = SerialMaskedGen __builtin__.ScratchPad = ScratchPad __builtin__.uniqueName = uniqueName __builtin__.serialNum = serialNum -__builtin__.profiled = profiled +if __debug__: + __builtin__.profiled = profiled + __builtin__.exceptionLogged = exceptionLogged __builtin__.itype = itype -__builtin__.exceptionLogged = exceptionLogged __builtin__.appendStr = appendStr __builtin__.bound = bound __builtin__.clamp = clamp __builtin__.lerp = lerp __builtin__.makeList = makeList __builtin__.makeTuple = makeTuple -__builtin__.printStack = printStack -__builtin__.printReverseStack = printReverseStack -__builtin__.printVerboseStack = printVerboseStack +if __debug__: + __builtin__.printStack = printStack + __builtin__.printReverseStack = printReverseStack + __builtin__.printVerboseStack = printVerboseStack __builtin__.DelayedCall = DelayedCall __builtin__.DelayedFunctor = DelayedFunctor __builtin__.FrameDelayedCall = FrameDelayedCall @@ -2942,8 +2708,8 @@ __builtin__.fastRepr = fastRepr __builtin__.nullGen = nullGen __builtin__.flywheel = flywheel __builtin__.loopGen = loopGen -__builtin__.StackTrace = StackTrace -__builtin__.choice = choice +if __debug__: + __builtin__.StackTrace = StackTrace __builtin__.report = report __builtin__.pstatcollect = pstatcollect __builtin__.MiniLog = MiniLog diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 523c225574..13ffbc7f45 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -26,24 +26,22 @@ from BulletinBoardGlobal import bulletinBoard from direct.task.TaskManagerGlobal import taskMgr from JobManagerGlobal import jobMgr from EventManagerGlobal import eventMgr -from PythonUtil import * -from direct.showbase import PythonUtil -#from direct.interval.IntervalManager import ivalMgr +#from PythonUtil import * from direct.interval import IntervalManager from direct.showbase.BufferViewer import BufferViewer from direct.task import Task -from direct.directutil import Verify -from direct.showbase import GarbageReport import sys import Loader import time import atexit +import importlib from direct.showbase import ExceptionVarDump import DirectObject import SfxPlayer if __debug__: + from direct.showbase import GarbageReport from direct.directutil import DeltaProfiler -import OnScreenDebug + import OnScreenDebug import AppRunnerGlobal def legacyRun(): @@ -73,7 +71,8 @@ class ShowBase(DirectObject.DirectObject): if logStackDump or uploadStackDump: ExceptionVarDump.install(logStackDump, uploadStackDump) - self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False) + if __debug__: + self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False) ## The directory containing the main Python file of this application. self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR") @@ -88,9 +87,6 @@ class ShowBase(DirectObject.DirectObject): #debug running multiplier self.debugRunningMultiplier = 4 - # Setup wantVerifyPdb as soon as reasonable: - Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0) - # [gjeon] to disable sticky keys if self.config.GetBool('disable-sticky-keys', 0): storeAccessibilityShortcutKeys() @@ -373,8 +369,8 @@ class ShowBase(DirectObject.DirectObject): builtins.wantUberdog = self.config.GetBool('want-uberdog', 1) if __debug__: builtins.deltaProfiler = DeltaProfiler.DeltaProfiler("ShowBase") - self.onScreenDebug = OnScreenDebug.OnScreenDebug() - builtins.onScreenDebug = self.onScreenDebug + self.onScreenDebug = OnScreenDebug.OnScreenDebug() + builtins.onScreenDebug = self.onScreenDebug if self.wantRender2dp: builtins.render2dp = self.render2dp @@ -388,10 +384,6 @@ class ShowBase(DirectObject.DirectObject): self.createBaseAudioManagers() - # set up recording of Functor creation stacks in __dev__ - if self.__dev__ and self.config.GetBool('record-functor-creation-stacks', False): - PythonUtil.recordFunctorCreationStacks() - if self.__dev__ or self.config.GetBool('want-e3-hacks', False): if self.config.GetBool('track-gui-items', True): # dict of guiId to gui item, for tracking down leaks @@ -465,7 +457,8 @@ class ShowBase(DirectObject.DirectObject): some Panda config settings. """ try: - import profile, pstats + profile = importlib.import_module('profile') + pstats = importlib.import_module('pstats') except ImportError: return @@ -1647,23 +1640,26 @@ class ShowBase(DirectObject.DirectObject): def addAngularIntegrator(self): if not self.physicsMgrAngular: - from panda3d.physics import AngularEulerIntegrator + physics = importlib.import_module('panda3d.physics') self.physicsMgrAngular = 1 - integrator = AngularEulerIntegrator() + integrator = physics.AngularEulerIntegrator() self.physicsMgr.attachAngularIntegrator(integrator) def enableParticles(self): if not self.particleMgrEnabled: + # Use importlib to prevent this import from being picked up + # by modulefinder when packaging an application. + if not self.particleMgr: - from direct.particles.ParticleManagerGlobal import particleMgr - self.particleMgr = particleMgr + PMG = importlib.import_module('direct.particles.ParticleManagerGlobal') + self.particleMgr = PMG.particleMgr self.particleMgr.setFrameStepping(1) if not self.physicsMgr: - from PhysicsManagerGlobal import physicsMgr - from panda3d.physics import LinearEulerIntegrator - self.physicsMgr = physicsMgr - integrator = LinearEulerIntegrator() + PMG = importlib.import_module('direct.showbase.PhysicsManagerGlobal') + physics = importlib.import_module('panda3d.physics') + self.physicsMgr = PMG.physicsMgr + integrator = physics.LinearEulerIntegrator() self.physicsMgr.attachLinearIntegrator(integrator) self.particleMgrEnabled = 1 @@ -1886,9 +1882,10 @@ class ShowBase(DirectObject.DirectObject): return Task.cont def __igLoop(self, state): - # We render the watch variables for the onScreenDebug as soon - # as we reasonably can before the renderFrame(). - self.onScreenDebug.render() + if __debug__: + # We render the watch variables for the onScreenDebug as soon + # as we reasonably can before the renderFrame(). + self.onScreenDebug.render() if self.recorder: self.recorder.recordFrame() @@ -1900,9 +1897,10 @@ class ShowBase(DirectObject.DirectObject): if self.multiClientSleep: time.sleep(0) - # We clear the text buffer for the onScreenDebug as soon - # as we reasonably can after the renderFrame(). - self.onScreenDebug.clear() + if __debug__: + # We clear the text buffer for the onScreenDebug as soon + # as we reasonably can after the renderFrame(). + self.onScreenDebug.clear() if self.recorder: self.recorder.playFrame() @@ -1925,9 +1923,10 @@ class ShowBase(DirectObject.DirectObject): def __igLoopSync(self, state): - # We render the watch variables for the onScreenDebug as soon - # as we reasonably can before the renderFrame(). - self.onScreenDebug.render() + if __debug__: + # We render the watch variables for the onScreenDebug as soon + # as we reasonably can before the renderFrame(). + self.onScreenDebug.render() if self.recorder: self.recorder.recordFrame() @@ -1941,9 +1940,10 @@ class ShowBase(DirectObject.DirectObject): if self.multiClientSleep: time.sleep(0) - # We clear the text buffer for the onScreenDebug as soon - # as we reasonably can after the renderFrame(). - self.onScreenDebug.clear() + if __debug__: + # We clear the text buffer for the onScreenDebug as soon + # as we reasonably can after the renderFrame(). + self.onScreenDebug.clear() if self.recorder: self.recorder.playFrame() @@ -2178,8 +2178,10 @@ class ShowBase(DirectObject.DirectObject): self.texmem = None return - from direct.showutil.TexMemWatcher import TexMemWatcher - self.texmem = TexMemWatcher() + # Use importlib to prevent this import from being picked up + # by modulefinder when packaging an application. + TMW = importlib.import_module('direct.showutil.TexMemWatcher') + self.texmem = TMW.TexMemWatcher() def toggleShowVertices(self): """ Toggles a mode that visualizes vertex density per screen @@ -2675,16 +2677,18 @@ class ShowBase(DirectObject.DirectObject): if not properties.getOpen(): # If the user closes the main window, we should exit. self.notify.info("User closed main window.") - if self.__autoGarbageLogging: - GarbageReport.b_checkForGarbageLeaks() + if __debug__: + if self.__autoGarbageLogging: + GarbageReport.b_checkForGarbageLeaks() self.userExit() if properties.getForeground() and not self.mainWinForeground: self.mainWinForeground = 1 elif not properties.getForeground() and self.mainWinForeground: self.mainWinForeground = 0 - if self.__autoGarbageLogging: - GarbageReport.b_checkForGarbageLeaks() + if __debug__: + if self.__autoGarbageLogging: + GarbageReport.b_checkForGarbageLeaks() if properties.getMinimized() and not self.mainWinMinimized: # If the main window is minimized, throw an event to @@ -2814,7 +2818,10 @@ class ShowBase(DirectObject.DirectObject): init_app_for_gui() - import wx + # Use importlib to prevent this import from being picked up + # by modulefinder when packaging an application. + wx = importlib.import_module('wx') + # Create a new base.wxApp. self.wxApp = wx.PySimpleApp(redirect = False) @@ -2889,8 +2896,10 @@ class ShowBase(DirectObject.DirectObject): # Don't do this twice. return - from Tkinter import tkinter - import Pmw + # Use importlib to prevent this import from being picked up + # by modulefinder when packaging an application. + tkinter = importlib.import_module('Tkinter').tkinter + Pmw = importlib.import_module('Pmw') # Create a new Tk root. self.tkRoot = Pmw.initialise() @@ -2953,8 +2962,10 @@ class ShowBase(DirectObject.DirectObject): self.startWx(fWantWx) self.wantDirect = fWantDirect if self.wantDirect: - from direct.directtools.DirectSession import DirectSession - self.direct = DirectSession() + # Use importlib to prevent this import from being picked up + # by modulefinder when packaging an application. + DirectSession = importlib.import_module('direct.directtools.DirectSession') + self.direct = DirectSession.DirectSession() self.direct.enable() builtins.direct = self.direct else: diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index 48c79aec1b..c60ac8c09e 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -3,7 +3,7 @@ __all__ = ['Transitions'] from panda3d.core import * -from direct.gui.DirectGui import * +from direct.gui.DirectGui import DirectFrame from direct.gui import DirectGuiGlobals as DGG from direct.interval.LerpInterval import LerpColorScaleInterval, LerpColorInterval, LerpScaleInterval, LerpPosInterval from direct.interval.MetaInterval import Sequence, Parallel diff --git a/direct/src/showutil/FreezeTool.py b/direct/src/showutil/FreezeTool.py index 7b1ee6ef6b..04f8dc8baf 100644 --- a/direct/src/showutil/FreezeTool.py +++ b/direct/src/showutil/FreezeTool.py @@ -30,8 +30,8 @@ isDebugBuild = (python.lower().endswith('_d')) # These are modules that Python always tries to import up-front. They # must be frozen in any main.exe. startupModules = [ - 'site', 'sitecustomize', 'os', 'encodings.cp1252', - 'encodings.latin_1', 'encodings.utf_8', 'io', 'org', + 'os', 'encodings.cp1252', + 'encodings.latin_1', 'encodings.utf_8', 'io', ] # These are missing modules that we've reported already this session. diff --git a/direct/src/stdpy/thread.py b/direct/src/stdpy/thread.py index ba85a6dcd1..f8291488d1 100644 --- a/direct/src/stdpy/thread.py +++ b/direct/src/stdpy/thread.py @@ -70,6 +70,13 @@ class LockType: def __exit__(self, t, v, tb): self.release() +# Helper to generate new thread names +_counter = 0 +def _newname(template="Thread-%d"): + global _counter + _counter = _counter + 1 + return template % _counter + _threads = {} _nextThreadId = 0 _threadsLock = core.Mutex('thread._threadsLock') diff --git a/direct/src/stdpy/threading.py b/direct/src/stdpy/threading.py index b3f2bc57bd..3fa576e712 100644 --- a/direct/src/stdpy/threading.py +++ b/direct/src/stdpy/threading.py @@ -42,6 +42,7 @@ __all__ = [ ] local = _thread._local +_newname = _thread._newname class ThreadBase: """ A base class for both Thread and ExternalThread in this @@ -98,8 +99,7 @@ class Thread(ThreadBase): self.__kwargs = kwargs if not name: - import threading2 - name = threading2._newname() + name = _newname() current = current_thread() self.__dict__['daemon'] = current.daemon @@ -404,106 +404,107 @@ def setprofile(func): def stack_size(size = None): raise ThreadError -def _test(): +if __debug__: + def _test(): + from collections import deque - from collections import deque - _sleep = core.Thread.sleep + _sleep = core.Thread.sleep - _VERBOSE = False + _VERBOSE = False - class _Verbose(object): + class _Verbose(object): - def __init__(self, verbose=None): - if verbose is None: - verbose = _VERBOSE - self.__verbose = verbose + def __init__(self, verbose=None): + if verbose is None: + verbose = _VERBOSE + self.__verbose = verbose - def _note(self, format, *args): - if self.__verbose: - format = format % args - format = "%s: %s\n" % ( - currentThread().getName(), format) - _sys.stderr.write(format) + def _note(self, format, *args): + if self.__verbose: + format = format % args + format = "%s: %s\n" % ( + currentThread().getName(), format) + _sys.stderr.write(format) - class BoundedQueue(_Verbose): + class BoundedQueue(_Verbose): - def __init__(self, limit): - _Verbose.__init__(self) - self.mon = Lock(name = "BoundedQueue.mon") - self.rc = Condition(self.mon) - self.wc = Condition(self.mon) - self.limit = limit - self.queue = deque() + def __init__(self, limit): + _Verbose.__init__(self) + self.mon = Lock(name = "BoundedQueue.mon") + self.rc = Condition(self.mon) + self.wc = Condition(self.mon) + self.limit = limit + self.queue = deque() - def put(self, item): - self.mon.acquire() - while len(self.queue) >= self.limit: - self._note("put(%s): queue full", item) - self.wc.wait() - self.queue.append(item) - self._note("put(%s): appended, length now %d", - item, len(self.queue)) - self.rc.notify() - self.mon.release() + def put(self, item): + self.mon.acquire() + while len(self.queue) >= self.limit: + self._note("put(%s): queue full", item) + self.wc.wait() + self.queue.append(item) + self._note("put(%s): appended, length now %d", + item, len(self.queue)) + self.rc.notify() + self.mon.release() - def get(self): - self.mon.acquire() - while not self.queue: - self._note("get(): queue empty") - self.rc.wait() - item = self.queue.popleft() - self._note("get(): got %s, %d left", item, len(self.queue)) - self.wc.notify() - self.mon.release() - return item + def get(self): + self.mon.acquire() + while not self.queue: + self._note("get(): queue empty") + self.rc.wait() + item = self.queue.popleft() + self._note("get(): got %s, %d left", item, len(self.queue)) + self.wc.notify() + self.mon.release() + return item - class ProducerThread(Thread): + class ProducerThread(Thread): - def __init__(self, queue, quota): - Thread.__init__(self, name="Producer") - self.queue = queue - self.quota = quota + def __init__(self, queue, quota): + Thread.__init__(self, name="Producer") + self.queue = queue + self.quota = quota - def run(self): - from random import random - counter = 0 - while counter < self.quota: - counter = counter + 1 - self.queue.put("%s.%d" % (self.getName(), counter)) - _sleep(random() * 0.00001) + def run(self): + from random import random + counter = 0 + while counter < self.quota: + counter = counter + 1 + self.queue.put("%s.%d" % (self.getName(), counter)) + _sleep(random() * 0.00001) - class ConsumerThread(Thread): + class ConsumerThread(Thread): - def __init__(self, queue, count): - Thread.__init__(self, name="Consumer") - self.queue = queue - self.count = count + def __init__(self, queue, count): + Thread.__init__(self, name="Consumer") + self.queue = queue + self.count = count - def run(self): - while self.count > 0: - item = self.queue.get() - print item - self.count = self.count - 1 + def run(self): + while self.count > 0: + item = self.queue.get() + print item + self.count = self.count - 1 - NP = 3 - QL = 4 - NI = 5 + NP = 3 + QL = 4 + NI = 5 - Q = BoundedQueue(QL) - P = [] - for i in range(NP): - t = ProducerThread(Q, NI) - t.setName("Producer-%d" % (i+1)) - P.append(t) - C = ConsumerThread(Q, NI*NP) - for t in P: - t.start() - _sleep(0.000001) - C.start() - for t in P: - t.join() - C.join() + Q = BoundedQueue(QL) + P = [] + for i in range(NP): + t = ProducerThread(Q, NI) + t.setName("Producer-%d" % (i+1)) + P.append(t) + C = ConsumerThread(Q, NI*NP) + for t in P: + t.start() + _sleep(0.000001) + C.start() + for t in P: + t.join() + C.join() -if __name__ == '__main__': - _test() + if __name__ == '__main__': + _test() diff --git a/direct/src/stdpy/threading2.py b/direct/src/stdpy/threading2.py index b45d893f6c..d03ac01c3c 100644 --- a/direct/src/stdpy/threading2.py +++ b/direct/src/stdpy/threading2.py @@ -16,13 +16,12 @@ implementation. """ import sys as _sys from direct.stdpy import thread -from direct.stdpy.thread import stack_size, _local as local +from direct.stdpy.thread import stack_size, _newname, _local as local from panda3d import core _sleep = core.Thread.sleep from time import time as _time from traceback import format_exc as _format_exc -from collections import deque # Rename some stuff so "from threading import *" is safe __all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event', @@ -377,13 +376,6 @@ class _Event(_Verbose): finally: self.__cond.release() -# Helper to generate new thread names -_counter = 0 -def _newname(template="Thread-%d"): - global _counter - _counter = _counter + 1 - return template % _counter - # Active thread administration _active_limbo_lock = _allocate_lock() _active = {} # maps thread id to Thread object @@ -741,88 +733,89 @@ _shutdown = _MainThread()._exitfunc # Self-test code +if __debug__: + def _test(): + from collections import deque -def _test(): + class BoundedQueue(_Verbose): - class BoundedQueue(_Verbose): + def __init__(self, limit): + _Verbose.__init__(self) + self.mon = RLock() + self.rc = Condition(self.mon) + self.wc = Condition(self.mon) + self.limit = limit + self.queue = deque() - def __init__(self, limit): - _Verbose.__init__(self) - self.mon = RLock() - self.rc = Condition(self.mon) - self.wc = Condition(self.mon) - self.limit = limit - self.queue = deque() + def put(self, item): + self.mon.acquire() + while len(self.queue) >= self.limit: + self._note("put(%s): queue full", item) + self.wc.wait() + self.queue.append(item) + self._note("put(%s): appended, length now %d", + item, len(self.queue)) + self.rc.notify() + self.mon.release() - def put(self, item): - self.mon.acquire() - while len(self.queue) >= self.limit: - self._note("put(%s): queue full", item) - self.wc.wait() - self.queue.append(item) - self._note("put(%s): appended, length now %d", - item, len(self.queue)) - self.rc.notify() - self.mon.release() + def get(self): + self.mon.acquire() + while not self.queue: + self._note("get(): queue empty") + self.rc.wait() + item = self.queue.popleft() + self._note("get(): got %s, %d left", item, len(self.queue)) + self.wc.notify() + self.mon.release() + return item - def get(self): - self.mon.acquire() - while not self.queue: - self._note("get(): queue empty") - self.rc.wait() - item = self.queue.popleft() - self._note("get(): got %s, %d left", item, len(self.queue)) - self.wc.notify() - self.mon.release() - return item + class ProducerThread(Thread): - class ProducerThread(Thread): + def __init__(self, queue, quota): + Thread.__init__(self, name="Producer") + self.queue = queue + self.quota = quota - def __init__(self, queue, quota): - Thread.__init__(self, name="Producer") - self.queue = queue - self.quota = quota - - def run(self): - from random import random - counter = 0 - while counter < self.quota: - counter = counter + 1 - self.queue.put("%s.%d" % (self.getName(), counter)) - _sleep(random() * 0.00001) + def run(self): + from random import random + counter = 0 + while counter < self.quota: + counter = counter + 1 + self.queue.put("%s.%d" % (self.getName(), counter)) + _sleep(random() * 0.00001) - class ConsumerThread(Thread): + class ConsumerThread(Thread): - def __init__(self, queue, count): - Thread.__init__(self, name="Consumer") - self.queue = queue - self.count = count + def __init__(self, queue, count): + Thread.__init__(self, name="Consumer") + self.queue = queue + self.count = count - def run(self): - while self.count > 0: - item = self.queue.get() - print item - self.count = self.count - 1 + def run(self): + while self.count > 0: + item = self.queue.get() + print item + self.count = self.count - 1 - NP = 3 - QL = 4 - NI = 5 + NP = 3 + QL = 4 + NI = 5 - Q = BoundedQueue(QL) - P = [] - for i in range(NP): - t = ProducerThread(Q, NI) - t.setName("Producer-%d" % (i+1)) - P.append(t) - C = ConsumerThread(Q, NI*NP) - for t in P: - t.start() - _sleep(0.000001) - C.start() - for t in P: - t.join() - C.join() + Q = BoundedQueue(QL) + P = [] + for i in range(NP): + t = ProducerThread(Q, NI) + t.setName("Producer-%d" % (i+1)) + P.append(t) + C = ConsumerThread(Q, NI*NP) + for t in P: + t.start() + _sleep(0.000001) + C.start() + for t in P: + t.join() + C.join() -if __name__ == '__main__': - _test() + if __name__ == '__main__': + _test() diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 3308b6f192..5d4a831f32 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -12,6 +12,7 @@ from direct.showbase.PythonUtil import * from direct.showbase.MessengerGlobal import messenger import types import random +import importlib try: import signal @@ -591,7 +592,6 @@ class TaskManager: def popupControls(self): # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. - import importlib TaskManagerPanel = importlib.import_module('direct.tkpanels.TaskManagerPanel') return TaskManagerPanel.TaskManagerPanel(self) @@ -602,8 +602,8 @@ class TaskManager: # Defer this import until we need it: some Python # distributions don't provide the profile and pstats modules. - from direct.showbase.ProfileSession import ProfileSession - return ProfileSession(name) + PS = importlib.import_module('direct.showbase.ProfileSession') + return PS.ProfileSession(name) def profileFrames(self, num=None, session=None, callback=None): if num is None: @@ -629,8 +629,8 @@ class TaskManager: self._profileFrames.set(profileFrames) if (not self._frameProfiler) and profileFrames: # import here due to import dependencies - from direct.task.FrameProfiler import FrameProfiler - self._frameProfiler = FrameProfiler() + FP = importlib.import_module('direct.task.FrameProfiler') + self._frameProfiler = FP.FrameProfiler() def getProfileTasks(self): return self._profileTasks.get() @@ -642,8 +642,8 @@ class TaskManager: self._profileTasks.set(profileTasks) if (not self._taskProfiler) and profileTasks: # import here due to import dependencies - from direct.task.TaskProfiler import TaskProfiler - self._taskProfiler = TaskProfiler() + TP = importlib.import_module('direct.task.TaskProfiler') + self._taskProfiler = TP.TaskProfiler() def logTaskProfiles(self, name=None): if self._taskProfiler: @@ -689,9 +689,9 @@ class TaskManager: # Defer this import until we need it: some Python # distributions don't provide the profile and pstats modules. - from direct.showbase.ProfileSession import ProfileSession - profileSession = ProfileSession('profiled-task-%s' % task.getName(), - Functor(profileInfo.taskFunc, *profileInfo.taskArgs)) + PS = importlib.import_module('direct.showbase.ProfileSession') + profileSession = PS.ProfileSession('profiled-task-%s' % task.getName(), + Functor(profileInfo.taskFunc, *profileInfo.taskArgs)) ret = profileSession.run() # set these values *after* profiling in case we're profiling the TaskProfiler From 1f32c1dff0b2786841bc1a27de27b3992561982f Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 13 Feb 2016 16:36:07 +0100 Subject: [PATCH 08/31] Fix typo in glGraphicsStateGuardian --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 2a3a8bea80..7c5fd7fc9f 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -184,7 +184,7 @@ static const string default_fshader = #ifndef OPENGLES " p3d_FragColor = texture(p3d_Texture0, texcoord);\n" " p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering - " p3d_FragColor = color;\n" + " p3d_FragColor *= color;\n" #else " gl_FragColor = texture2D(p3d_Texture0, texcoord).bgra;\n" " gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering From caa03c53dd2f96c8bb13a72e6be61b3af6e92759 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 15 Feb 2016 21:14:42 +0100 Subject: [PATCH 09/31] Interrogate cppparser improvements, C++11/14/17 additions: * Support trailing return type. * Ignore C++14 digit separators. * Parse C++14 binary number representations. * Support "using"-style type aliases. * Support decltype and auto with "new". * Remove silly "long float" and "long long float". * Support default visibility with class inheritance. * Remove -longlong hack since C++11 supports long long natively. * Support unary plus operator. * Preserve bitfield definitions. * Support constructor inits using braces. * Support override/final specifiers. * Ignore [[attributes]] in certain cases * Add support for typeid() in expressions * Parse (but ignore) lambda expressions * Differentiate between casts, add const_cast/reinterpret_cast * Support thread_local variables. --- dtool/src/cppparser/cppBison.cxx.prebuilt | 7517 +++++++++-------- dtool/src/cppparser/cppBison.h.prebuilt | 368 +- dtool/src/cppparser/cppBison.yxx | 594 +- dtool/src/cppparser/cppEnumType.cxx | 39 +- dtool/src/cppparser/cppEnumType.h | 2 + dtool/src/cppparser/cppExpression.cxx | 192 +- dtool/src/cppparser/cppExpression.h | 89 +- dtool/src/cppparser/cppExtensionType.cxx | 4 +- dtool/src/cppparser/cppFunctionType.cxx | 67 +- dtool/src/cppparser/cppFunctionType.h | 3 + dtool/src/cppparser/cppInstance.cxx | 17 +- dtool/src/cppparser/cppInstance.h | 3 + dtool/src/cppparser/cppInstanceIdentifier.cxx | 45 +- dtool/src/cppparser/cppInstanceIdentifier.h | 11 +- dtool/src/cppparser/cppPreprocessor.cxx | 86 +- dtool/src/cppparser/cppPreprocessor.h | 1 + dtool/src/cppparser/cppStructType.cxx | 22 +- dtool/src/cppparser/cppStructType.h | 1 + dtool/src/cppparser/cppToken.cxx | 4 + dtool/src/cppparser/cppTypedefType.cxx | 22 +- dtool/src/cppparser/cppTypedefType.h | 1 + dtool/src/dtoolbase/dtoolbase_cc.h | 4 +- dtool/src/interrogate/interrogate.cxx | 5 +- dtool/src/parser-inc/typeinfo | 23 +- 24 files changed, 5377 insertions(+), 3743 deletions(-) diff --git a/dtool/src/cppparser/cppBison.cxx.prebuilt b/dtool/src/cppparser/cppBison.cxx.prebuilt index d20ad47a8c..f77f3b77d6 100644 --- a/dtool/src/cppparser/cppBison.cxx.prebuilt +++ b/dtool/src/cppparser/cppBison.cxx.prebuilt @@ -328,95 +328,101 @@ extern int cppyydebug; UNARY_NOT = 281, UNARY_NEGATE = 282, UNARY_MINUS = 283, - UNARY_STAR = 284, - UNARY_REF = 285, - POINTSAT = 286, - SCOPE = 287, - PLUSPLUS = 288, - MINUSMINUS = 289, - TIMESEQUAL = 290, - DIVIDEEQUAL = 291, - MODEQUAL = 292, - PLUSEQUAL = 293, - MINUSEQUAL = 294, - OREQUAL = 295, - ANDEQUAL = 296, - XOREQUAL = 297, - LSHIFTEQUAL = 298, - RSHIFTEQUAL = 299, - KW_ALIGNAS = 300, - KW_ALIGNOF = 301, - KW_AUTO = 302, - KW_BEGIN_PUBLISH = 303, - KW_BLOCKING = 304, - KW_BOOL = 305, - KW_CATCH = 306, - KW_CHAR = 307, - KW_CHAR16_T = 308, - KW_CHAR32_T = 309, - KW_CLASS = 310, - KW_CONST = 311, - KW_CONSTEXPR = 312, - KW_DECLTYPE = 313, - KW_DEFAULT = 314, - KW_DELETE = 315, - KW_DOUBLE = 316, - KW_DYNAMIC_CAST = 317, - KW_ELSE = 318, - KW_END_PUBLISH = 319, - KW_ENUM = 320, - KW_EXTENSION = 321, - KW_EXTERN = 322, - KW_EXPLICIT = 323, - KW_PUBLISHED = 324, - KW_FALSE = 325, - KW_FLOAT = 326, - KW_FRIEND = 327, - KW_FOR = 328, - KW_GOTO = 329, - KW_IF = 330, - KW_INLINE = 331, - KW_INT = 332, - KW_LONG = 333, - KW_LONGLONG = 334, - KW_MAKE_PROPERTY = 335, - KW_MAKE_PROPERTY2 = 336, - KW_MAKE_SEQ = 337, - KW_MUTABLE = 338, - KW_NAMESPACE = 339, - KW_NEW = 340, - KW_NOEXCEPT = 341, - KW_NULLPTR = 342, - KW_OPERATOR = 343, - KW_PRIVATE = 344, - KW_PROTECTED = 345, - KW_PUBLIC = 346, - KW_REGISTER = 347, - KW_RETURN = 348, - KW_SHORT = 349, - KW_SIGNED = 350, - KW_SIZEOF = 351, - KW_STATIC = 352, - KW_STATIC_ASSERT = 353, - KW_STATIC_CAST = 354, - KW_STRUCT = 355, - KW_TEMPLATE = 356, - KW_THROW = 357, - KW_TRUE = 358, - KW_TRY = 359, - KW_TYPEDEF = 360, - KW_TYPENAME = 361, - KW_UNION = 362, - KW_UNSIGNED = 363, - KW_USING = 364, - KW_VIRTUAL = 365, - KW_VOID = 366, - KW_VOLATILE = 367, - KW_WCHAR_T = 368, - KW_WHILE = 369, - START_CPP = 370, - START_CONST_EXPR = 371, - START_TYPE = 372 + UNARY_PLUS = 284, + UNARY_STAR = 285, + UNARY_REF = 286, + POINTSAT = 287, + SCOPE = 288, + PLUSPLUS = 289, + MINUSMINUS = 290, + TIMESEQUAL = 291, + DIVIDEEQUAL = 292, + MODEQUAL = 293, + PLUSEQUAL = 294, + MINUSEQUAL = 295, + OREQUAL = 296, + ANDEQUAL = 297, + XOREQUAL = 298, + LSHIFTEQUAL = 299, + RSHIFTEQUAL = 300, + KW_ALIGNAS = 301, + KW_ALIGNOF = 302, + KW_AUTO = 303, + KW_BEGIN_PUBLISH = 304, + KW_BLOCKING = 305, + KW_BOOL = 306, + KW_CATCH = 307, + KW_CHAR = 308, + KW_CHAR16_T = 309, + KW_CHAR32_T = 310, + KW_CLASS = 311, + KW_CONST = 312, + KW_CONSTEXPR = 313, + KW_CONST_CAST = 314, + KW_DECLTYPE = 315, + KW_DEFAULT = 316, + KW_DELETE = 317, + KW_DOUBLE = 318, + KW_DYNAMIC_CAST = 319, + KW_ELSE = 320, + KW_END_PUBLISH = 321, + KW_ENUM = 322, + KW_EXTENSION = 323, + KW_EXTERN = 324, + KW_EXPLICIT = 325, + KW_PUBLISHED = 326, + KW_FALSE = 327, + KW_FINAL = 328, + KW_FLOAT = 329, + KW_FRIEND = 330, + KW_FOR = 331, + KW_GOTO = 332, + KW_IF = 333, + KW_INLINE = 334, + KW_INT = 335, + KW_LONG = 336, + KW_MAKE_PROPERTY = 337, + KW_MAKE_PROPERTY2 = 338, + KW_MAKE_SEQ = 339, + KW_MUTABLE = 340, + KW_NAMESPACE = 341, + KW_NEW = 342, + KW_NOEXCEPT = 343, + KW_NULLPTR = 344, + KW_OPERATOR = 345, + KW_OVERRIDE = 346, + KW_PRIVATE = 347, + KW_PROTECTED = 348, + KW_PUBLIC = 349, + KW_REGISTER = 350, + KW_REINTERPRET_CAST = 351, + KW_RETURN = 352, + KW_SHORT = 353, + KW_SIGNED = 354, + KW_SIZEOF = 355, + KW_STATIC = 356, + KW_STATIC_ASSERT = 357, + KW_STATIC_CAST = 358, + KW_STRUCT = 359, + KW_TEMPLATE = 360, + KW_THREAD_LOCAL = 361, + KW_THROW = 362, + KW_TRUE = 363, + KW_TRY = 364, + KW_TYPEDEF = 365, + KW_TYPEID = 366, + KW_TYPENAME = 367, + KW_UNION = 368, + KW_UNSIGNED = 369, + KW_USING = 370, + KW_VIRTUAL = 371, + KW_VOID = 372, + KW_VOLATILE = 373, + KW_WCHAR_T = 374, + KW_WHILE = 375, + START_CPP = 376, + START_CONST_EXPR = 377, + START_TYPE = 378 }; #endif /* Tokens. */ @@ -446,95 +452,101 @@ extern int cppyydebug; #define UNARY_NOT 281 #define UNARY_NEGATE 282 #define UNARY_MINUS 283 -#define UNARY_STAR 284 -#define UNARY_REF 285 -#define POINTSAT 286 -#define SCOPE 287 -#define PLUSPLUS 288 -#define MINUSMINUS 289 -#define TIMESEQUAL 290 -#define DIVIDEEQUAL 291 -#define MODEQUAL 292 -#define PLUSEQUAL 293 -#define MINUSEQUAL 294 -#define OREQUAL 295 -#define ANDEQUAL 296 -#define XOREQUAL 297 -#define LSHIFTEQUAL 298 -#define RSHIFTEQUAL 299 -#define KW_ALIGNAS 300 -#define KW_ALIGNOF 301 -#define KW_AUTO 302 -#define KW_BEGIN_PUBLISH 303 -#define KW_BLOCKING 304 -#define KW_BOOL 305 -#define KW_CATCH 306 -#define KW_CHAR 307 -#define KW_CHAR16_T 308 -#define KW_CHAR32_T 309 -#define KW_CLASS 310 -#define KW_CONST 311 -#define KW_CONSTEXPR 312 -#define KW_DECLTYPE 313 -#define KW_DEFAULT 314 -#define KW_DELETE 315 -#define KW_DOUBLE 316 -#define KW_DYNAMIC_CAST 317 -#define KW_ELSE 318 -#define KW_END_PUBLISH 319 -#define KW_ENUM 320 -#define KW_EXTENSION 321 -#define KW_EXTERN 322 -#define KW_EXPLICIT 323 -#define KW_PUBLISHED 324 -#define KW_FALSE 325 -#define KW_FLOAT 326 -#define KW_FRIEND 327 -#define KW_FOR 328 -#define KW_GOTO 329 -#define KW_IF 330 -#define KW_INLINE 331 -#define KW_INT 332 -#define KW_LONG 333 -#define KW_LONGLONG 334 -#define KW_MAKE_PROPERTY 335 -#define KW_MAKE_PROPERTY2 336 -#define KW_MAKE_SEQ 337 -#define KW_MUTABLE 338 -#define KW_NAMESPACE 339 -#define KW_NEW 340 -#define KW_NOEXCEPT 341 -#define KW_NULLPTR 342 -#define KW_OPERATOR 343 -#define KW_PRIVATE 344 -#define KW_PROTECTED 345 -#define KW_PUBLIC 346 -#define KW_REGISTER 347 -#define KW_RETURN 348 -#define KW_SHORT 349 -#define KW_SIGNED 350 -#define KW_SIZEOF 351 -#define KW_STATIC 352 -#define KW_STATIC_ASSERT 353 -#define KW_STATIC_CAST 354 -#define KW_STRUCT 355 -#define KW_TEMPLATE 356 -#define KW_THROW 357 -#define KW_TRUE 358 -#define KW_TRY 359 -#define KW_TYPEDEF 360 -#define KW_TYPENAME 361 -#define KW_UNION 362 -#define KW_UNSIGNED 363 -#define KW_USING 364 -#define KW_VIRTUAL 365 -#define KW_VOID 366 -#define KW_VOLATILE 367 -#define KW_WCHAR_T 368 -#define KW_WHILE 369 -#define START_CPP 370 -#define START_CONST_EXPR 371 -#define START_TYPE 372 +#define UNARY_PLUS 284 +#define UNARY_STAR 285 +#define UNARY_REF 286 +#define POINTSAT 287 +#define SCOPE 288 +#define PLUSPLUS 289 +#define MINUSMINUS 290 +#define TIMESEQUAL 291 +#define DIVIDEEQUAL 292 +#define MODEQUAL 293 +#define PLUSEQUAL 294 +#define MINUSEQUAL 295 +#define OREQUAL 296 +#define ANDEQUAL 297 +#define XOREQUAL 298 +#define LSHIFTEQUAL 299 +#define RSHIFTEQUAL 300 +#define KW_ALIGNAS 301 +#define KW_ALIGNOF 302 +#define KW_AUTO 303 +#define KW_BEGIN_PUBLISH 304 +#define KW_BLOCKING 305 +#define KW_BOOL 306 +#define KW_CATCH 307 +#define KW_CHAR 308 +#define KW_CHAR16_T 309 +#define KW_CHAR32_T 310 +#define KW_CLASS 311 +#define KW_CONST 312 +#define KW_CONSTEXPR 313 +#define KW_CONST_CAST 314 +#define KW_DECLTYPE 315 +#define KW_DEFAULT 316 +#define KW_DELETE 317 +#define KW_DOUBLE 318 +#define KW_DYNAMIC_CAST 319 +#define KW_ELSE 320 +#define KW_END_PUBLISH 321 +#define KW_ENUM 322 +#define KW_EXTENSION 323 +#define KW_EXTERN 324 +#define KW_EXPLICIT 325 +#define KW_PUBLISHED 326 +#define KW_FALSE 327 +#define KW_FINAL 328 +#define KW_FLOAT 329 +#define KW_FRIEND 330 +#define KW_FOR 331 +#define KW_GOTO 332 +#define KW_IF 333 +#define KW_INLINE 334 +#define KW_INT 335 +#define KW_LONG 336 +#define KW_MAKE_PROPERTY 337 +#define KW_MAKE_PROPERTY2 338 +#define KW_MAKE_SEQ 339 +#define KW_MUTABLE 340 +#define KW_NAMESPACE 341 +#define KW_NEW 342 +#define KW_NOEXCEPT 343 +#define KW_NULLPTR 344 +#define KW_OPERATOR 345 +#define KW_OVERRIDE 346 +#define KW_PRIVATE 347 +#define KW_PROTECTED 348 +#define KW_PUBLIC 349 +#define KW_REGISTER 350 +#define KW_REINTERPRET_CAST 351 +#define KW_RETURN 352 +#define KW_SHORT 353 +#define KW_SIGNED 354 +#define KW_SIZEOF 355 +#define KW_STATIC 356 +#define KW_STATIC_ASSERT 357 +#define KW_STATIC_CAST 358 +#define KW_STRUCT 359 +#define KW_TEMPLATE 360 +#define KW_THREAD_LOCAL 361 +#define KW_THROW 362 +#define KW_TRUE 363 +#define KW_TRY 364 +#define KW_TYPEDEF 365 +#define KW_TYPEID 366 +#define KW_TYPENAME 367 +#define KW_UNION 368 +#define KW_UNSIGNED 369 +#define KW_USING 370 +#define KW_VIRTUAL 371 +#define KW_VOID 372 +#define KW_VOLATILE 373 +#define KW_WCHAR_T 374 +#define KW_WHILE 375 +#define START_CPP 376 +#define START_CONST_EXPR 377 +#define START_TYPE 378 @@ -577,7 +589,7 @@ int cppyyparse (); /* Copy the second part of user declarations. */ /* Line 390 of yacc.c */ -#line 581 "built/tmp/cppBison.yxx.c" +#line 593 "built/tmp/cppBison.yxx.c" #ifdef short # undef short @@ -797,22 +809,22 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 79 +#define YYFINAL 85 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 4690 +#define YYLAST 5299 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 142 +#define YYNTOKENS 148 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 95 +#define YYNNTS 109 /* YYNRULES -- Number of rules. */ -#define YYNRULES 593 +#define YYNRULES 669 /* YYNRULES -- Number of states. */ -#define YYNSTATES 1101 +#define YYNSTATES 1311 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 372 +#define YYMAXUTOK 378 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -823,16 +835,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 140, 2, 2, 2, 133, 126, 2, - 136, 138, 131, 129, 119, 130, 135, 132, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 121, 120, - 127, 122, 128, 123, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 147, 2, 2, 2, 139, 132, 2, + 142, 144, 137, 135, 125, 136, 141, 138, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 127, 126, + 133, 128, 134, 129, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 137, 2, 141, 125, 2, 2, 2, 2, 2, + 2, 143, 2, 146, 131, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 118, 124, 139, 134, 2, 2, 2, + 2, 2, 2, 124, 130, 145, 140, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -857,7 +869,7 @@ static const yytype_uint8 yytranslate[] = 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 115, 116, 117 + 115, 116, 117, 118, 119, 120, 121, 122, 123 }; #if YYDEBUG @@ -866,322 +878,366 @@ static const yytype_uint8 yytranslate[] = static const yytype_uint16 yyprhs[] = { 0, 0, 3, 6, 9, 12, 14, 17, 20, 22, - 26, 31, 32, 38, 40, 42, 44, 46, 48, 50, - 53, 55, 57, 60, 63, 66, 69, 77, 87, 97, - 111, 121, 128, 133, 134, 138, 140, 143, 147, 150, - 153, 156, 159, 162, 165, 168, 171, 174, 177, 179, - 183, 187, 188, 193, 194, 200, 203, 208, 211, 216, - 217, 222, 223, 229, 233, 236, 241, 244, 249, 250, - 257, 258, 265, 266, 274, 275, 286, 287, 299, 300, - 309, 310, 320, 322, 324, 326, 329, 334, 340, 342, - 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, - 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, - 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, - 404, 406, 408, 410, 413, 416, 418, 420, 422, 424, - 425, 432, 435, 437, 439, 441, 445, 448, 453, 456, - 461, 465, 470, 472, 474, 476, 478, 481, 485, 488, - 491, 494, 497, 500, 504, 509, 513, 517, 518, 525, - 527, 529, 531, 535, 538, 540, 544, 546, 549, 551, - 554, 556, 560, 566, 570, 574, 578, 583, 585, 587, - 590, 592, 596, 600, 606, 610, 615, 621, 624, 626, - 628, 630, 632, 635, 638, 641, 644, 647, 651, 656, - 658, 660, 662, 665, 668, 671, 674, 677, 681, 686, - 694, 698, 700, 703, 706, 709, 712, 715, 719, 724, - 732, 734, 736, 739, 741, 743, 745, 748, 753, 758, - 760, 762, 764, 767, 769, 771, 773, 776, 781, 784, - 789, 791, 793, 795, 798, 801, 804, 806, 808, 811, - 815, 816, 822, 823, 831, 833, 835, 838, 842, 845, - 848, 851, 855, 859, 863, 867, 871, 875, 880, 885, - 888, 892, 894, 896, 898, 900, 904, 910, 912, 915, - 920, 922, 924, 926, 928, 929, 936, 937, 945, 950, - 956, 959, 963, 965, 967, 969, 971, 973, 975, 977, - 979, 981, 983, 985, 987, 989, 991, 994, 997, 1000, - 1003, 1005, 1008, 1010, 1014, 1017, 1019, 1020, 1023, 1025, - 1028, 1030, 1032, 1034, 1036, 1038, 1040, 1042, 1044, 1046, - 1048, 1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, - 1068, 1070, 1072, 1074, 1076, 1078, 1080, 1082, 1084, 1086, - 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, - 1108, 1110, 1112, 1114, 1116, 1118, 1120, 1122, 1124, 1126, - 1128, 1130, 1132, 1134, 1136, 1138, 1140, 1142, 1144, 1146, - 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166, - 1168, 1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, - 1188, 1190, 1192, 1194, 1196, 1198, 1200, 1202, 1204, 1206, - 1208, 1210, 1212, 1214, 1216, 1218, 1220, 1222, 1224, 1226, - 1228, 1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, - 1248, 1250, 1252, 1254, 1256, 1258, 1260, 1262, 1266, 1268, - 1270, 1272, 1274, 1276, 1280, 1282, 1287, 1295, 1303, 1308, - 1313, 1316, 1319, 1322, 1325, 1328, 1332, 1336, 1340, 1344, - 1348, 1352, 1356, 1360, 1364, 1368, 1372, 1376, 1380, 1384, - 1388, 1392, 1398, 1403, 1408, 1412, 1416, 1420, 1424, 1426, - 1431, 1439, 1447, 1452, 1457, 1462, 1467, 1472, 1477, 1482, - 1487, 1492, 1497, 1502, 1507, 1512, 1517, 1522, 1525, 1531, - 1534, 1537, 1540, 1543, 1546, 1550, 1554, 1558, 1562, 1566, - 1570, 1574, 1578, 1582, 1586, 1590, 1594, 1598, 1602, 1606, - 1610, 1614, 1618, 1624, 1629, 1634, 1638, 1642, 1646, 1650, - 1652, 1654, 1656, 1658, 1660, 1662, 1664, 1666, 1668, 1670, - 1675, 1683, 1691, 1696, 1701, 1704, 1710, 1713, 1716, 1719, - 1722, 1726, 1730, 1734, 1738, 1742, 1746, 1750, 1754, 1758, - 1762, 1766, 1770, 1774, 1778, 1782, 1786, 1790, 1794, 1800, - 1805, 1810, 1814, 1818, 1822, 1826, 1828, 1830, 1832, 1834, - 1836, 1838, 1840, 1842, 1844, 1846, 1849, 1852, 1854, 1856, - 1858, 1860, 1863, 1866 + 26, 31, 36, 37, 43, 45, 47, 49, 51, 53, + 55, 58, 60, 62, 65, 68, 71, 74, 82, 92, + 102, 116, 126, 134, 140, 141, 145, 147, 150, 154, + 157, 160, 163, 166, 169, 172, 175, 178, 181, 184, + 187, 194, 196, 200, 202, 207, 209, 213, 217, 221, + 222, 227, 228, 234, 237, 242, 245, 250, 251, 256, + 257, 263, 267, 270, 275, 278, 283, 284, 291, 292, + 299, 300, 308, 309, 321, 322, 335, 336, 345, 346, + 356, 358, 360, 362, 365, 368, 371, 374, 379, 385, + 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, + 407, 409, 411, 413, 415, 417, 419, 421, 423, 425, + 427, 429, 431, 433, 435, 437, 439, 441, 443, 445, + 447, 449, 451, 453, 455, 458, 461, 463, 465, 467, + 469, 470, 477, 480, 482, 484, 486, 490, 493, 498, + 501, 506, 510, 515, 517, 519, 521, 523, 526, 530, + 533, 536, 539, 542, 545, 549, 554, 558, 559, 566, + 569, 573, 575, 579, 584, 586, 588, 590, 594, 597, + 599, 603, 605, 607, 609, 613, 616, 618, 622, 624, + 627, 629, 632, 634, 638, 644, 648, 652, 654, 658, + 662, 666, 670, 675, 677, 679, 682, 684, 688, 692, + 698, 702, 707, 713, 716, 718, 720, 722, 724, 727, + 730, 733, 736, 739, 743, 748, 750, 752, 755, 758, + 761, 764, 767, 771, 776, 784, 788, 790, 793, 796, + 799, 802, 805, 809, 814, 816, 819, 822, 825, 828, + 831, 835, 840, 846, 856, 866, 876, 878, 880, 883, + 885, 887, 889, 892, 897, 902, 904, 906, 908, 911, + 913, 915, 917, 920, 925, 928, 933, 935, 937, 939, + 942, 945, 948, 953, 955, 957, 959, 962, 966, 967, + 973, 974, 983, 985, 987, 989, 991, 994, 998, 1000, + 1003, 1006, 1009, 1013, 1017, 1021, 1025, 1029, 1033, 1038, + 1043, 1046, 1050, 1052, 1054, 1056, 1058, 1062, 1068, 1070, + 1073, 1078, 1080, 1082, 1084, 1086, 1087, 1094, 1095, 1103, + 1108, 1114, 1118, 1124, 1129, 1131, 1133, 1135, 1137, 1139, + 1141, 1143, 1145, 1147, 1149, 1151, 1153, 1155, 1158, 1161, + 1164, 1167, 1169, 1171, 1174, 1176, 1177, 1180, 1182, 1185, + 1187, 1189, 1191, 1193, 1195, 1197, 1199, 1201, 1203, 1205, + 1207, 1209, 1211, 1213, 1215, 1217, 1219, 1221, 1223, 1225, + 1227, 1229, 1231, 1233, 1235, 1237, 1239, 1241, 1243, 1245, + 1247, 1249, 1251, 1253, 1255, 1257, 1259, 1261, 1263, 1265, + 1267, 1269, 1271, 1273, 1275, 1277, 1279, 1281, 1283, 1285, + 1287, 1289, 1291, 1293, 1295, 1297, 1299, 1301, 1303, 1305, + 1307, 1309, 1311, 1313, 1315, 1317, 1319, 1321, 1323, 1325, + 1327, 1329, 1331, 1333, 1335, 1337, 1339, 1341, 1343, 1345, + 1347, 1349, 1351, 1353, 1355, 1357, 1359, 1361, 1363, 1365, + 1367, 1369, 1371, 1373, 1375, 1377, 1379, 1381, 1383, 1385, + 1387, 1389, 1391, 1393, 1395, 1397, 1399, 1401, 1403, 1405, + 1407, 1409, 1411, 1413, 1415, 1417, 1419, 1421, 1423, 1425, + 1427, 1429, 1431, 1435, 1437, 1439, 1441, 1443, 1445, 1449, + 1451, 1456, 1464, 1472, 1480, 1488, 1493, 1498, 1501, 1504, + 1507, 1510, 1513, 1516, 1520, 1524, 1528, 1532, 1536, 1540, + 1544, 1548, 1552, 1556, 1560, 1564, 1568, 1572, 1576, 1580, + 1586, 1591, 1596, 1600, 1604, 1608, 1612, 1614, 1619, 1627, + 1635, 1643, 1651, 1656, 1661, 1666, 1671, 1676, 1681, 1686, + 1691, 1696, 1701, 1706, 1711, 1716, 1721, 1726, 1729, 1735, + 1740, 1745, 1748, 1751, 1754, 1757, 1760, 1763, 1767, 1771, + 1775, 1779, 1783, 1787, 1791, 1795, 1799, 1803, 1807, 1811, + 1815, 1819, 1823, 1827, 1831, 1835, 1841, 1846, 1851, 1855, + 1859, 1863, 1867, 1869, 1871, 1873, 1875, 1877, 1879, 1881, + 1883, 1885, 1887, 1889, 1898, 1910, 1912, 1917, 1925, 1933, + 1941, 1949, 1954, 1959, 1962, 1968, 1973, 1978, 1981, 1984, + 1987, 1990, 1993, 1997, 2001, 2005, 2009, 2013, 2017, 2021, + 2025, 2029, 2033, 2037, 2041, 2045, 2049, 2053, 2057, 2061, + 2065, 2071, 2076, 2081, 2085, 2089, 2093, 2097, 2099, 2101, + 2103, 2105, 2107, 2109, 2111, 2113, 2115, 2117, 2119, 2121, + 2123, 2127, 2129, 2131, 2134, 2136, 2138, 2141, 2144, 2146, + 2148, 2150, 2152, 2154, 2156, 2158, 2160, 2162, 2165, 2168 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 143, 0, -1, 115, 144, -1, 116, 229, -1, 117, - 198, -1, 236, -1, 144, 120, -1, 144, 149, -1, - 146, -1, 145, 119, 146, -1, 234, 136, 226, 138, - -1, -1, 152, 118, 148, 144, 139, -1, 153, -1, - 175, -1, 147, -1, 213, -1, 216, -1, 150, -1, - 105, 159, -1, 48, -1, 64, -1, 69, 121, -1, - 91, 121, -1, 90, 121, -1, 89, 121, -1, 80, - 136, 10, 119, 10, 138, 120, -1, 80, 136, 10, - 119, 10, 119, 10, 138, 120, -1, 81, 136, 10, - 119, 10, 119, 10, 138, 120, -1, 81, 136, 10, - 119, 10, 119, 10, 119, 10, 119, 10, 138, 120, - -1, 82, 136, 10, 119, 10, 119, 10, 138, 120, - -1, 98, 136, 229, 119, 235, 138, -1, 98, 136, - 229, 138, -1, -1, 72, 151, 149, -1, 236, -1, - 67, 152, -1, 67, 6, 152, -1, 97, 152, -1, - 76, 152, -1, 110, 152, -1, 68, 152, -1, 92, - 152, -1, 112, 152, -1, 83, 152, -1, 57, 152, - -1, 49, 152, -1, 66, 152, -1, 154, -1, 152, - 195, 120, -1, 152, 164, 187, -1, -1, 152, 197, - 155, 157, -1, -1, 152, 56, 197, 156, 158, -1, - 181, 187, -1, 181, 186, 119, 157, -1, 181, 187, - -1, 181, 186, 119, 158, -1, -1, 152, 197, 160, - 162, -1, -1, 152, 56, 197, 161, 163, -1, 152, - 164, 187, -1, 181, 187, -1, 181, 186, 119, 162, - -1, 181, 187, -1, 181, 186, 119, 163, -1, -1, - 10, 136, 165, 183, 138, 172, -1, -1, 11, 136, - 166, 183, 138, 172, -1, -1, 134, 234, 136, 167, - 183, 138, 172, -1, -1, 11, 136, 131, 181, 138, - 136, 168, 183, 138, 172, -1, -1, 11, 136, 12, - 131, 181, 138, 136, 169, 183, 138, 172, -1, -1, - 88, 194, 191, 136, 170, 183, 138, 172, -1, -1, - 88, 56, 194, 191, 136, 171, 183, 138, 172, -1, - 10, -1, 236, -1, 56, -1, 172, 86, -1, 172, - 102, 136, 138, -1, 172, 102, 136, 234, 138, -1, - 140, -1, 134, -1, 131, -1, 132, -1, 133, -1, - 129, -1, 130, -1, 124, -1, 126, -1, 125, -1, - 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, - 20, -1, 127, -1, 128, -1, 21, -1, 22, -1, - 122, -1, 119, -1, 33, -1, 34, -1, 35, -1, - 36, -1, 37, -1, 38, -1, 39, -1, 40, -1, - 41, -1, 42, -1, 43, -1, 44, -1, 31, -1, - 137, 141, -1, 136, 138, -1, 85, -1, 60, -1, - 153, -1, 175, -1, -1, 101, 176, 127, 177, 128, - 174, -1, 101, 153, -1, 236, -1, 178, -1, 179, - -1, 178, 119, 179, -1, 55, 234, -1, 55, 234, - 122, 198, -1, 106, 234, -1, 106, 234, 122, 198, - -1, 180, 192, 185, -1, 56, 180, 192, 185, -1, - 217, -1, 10, -1, 11, -1, 234, -1, 88, 173, - -1, 88, 6, 10, -1, 56, 181, -1, 112, 181, - -1, 131, 181, -1, 126, 181, -1, 16, 181, -1, - 12, 131, 181, -1, 181, 137, 225, 141, -1, 181, - 121, 4, -1, 136, 181, 138, -1, -1, 181, 136, - 182, 183, 138, 172, -1, 236, -1, 14, -1, 184, - -1, 184, 119, 14, -1, 184, 14, -1, 190, -1, - 184, 119, 190, -1, 236, -1, 122, 228, -1, 236, - -1, 122, 229, -1, 120, -1, 118, 221, 139, -1, - 121, 145, 118, 221, 139, -1, 122, 229, 120, -1, - 122, 59, 120, -1, 122, 60, 120, -1, 122, 118, - 188, 139, -1, 236, -1, 189, -1, 189, 119, -1, - 229, -1, 118, 188, 139, -1, 189, 119, 229, -1, - 189, 119, 118, 188, 139, -1, 194, 192, 186, -1, - 56, 194, 192, 186, -1, 56, 92, 194, 192, 186, - -1, 92, 190, -1, 231, -1, 236, -1, 10, -1, - 11, -1, 56, 191, -1, 112, 191, -1, 131, 191, - -1, 126, 191, -1, 16, 191, -1, 12, 131, 191, - -1, 191, 137, 225, 141, -1, 236, -1, 10, -1, - 11, -1, 56, 192, -1, 112, 192, -1, 131, 192, - -1, 126, 192, -1, 16, 192, -1, 12, 131, 192, - -1, 192, 137, 225, 141, -1, 136, 192, 138, 136, - 183, 138, 172, -1, 136, 192, 138, -1, 236, -1, - 56, 193, -1, 112, 193, -1, 131, 193, -1, 126, - 193, -1, 16, 193, -1, 12, 131, 193, -1, 193, - 137, 225, 141, -1, 136, 193, 138, 136, 183, 138, - 172, -1, 217, -1, 11, -1, 106, 234, -1, 199, - -1, 201, -1, 206, -1, 212, 234, -1, 211, 234, - 121, 208, -1, 58, 136, 229, 138, -1, 47, -1, - 217, -1, 11, -1, 106, 234, -1, 199, -1, 201, - -1, 206, -1, 212, 234, -1, 211, 234, 121, 208, - -1, 211, 234, -1, 58, 136, 229, 138, -1, 47, - -1, 217, -1, 11, -1, 106, 234, -1, 212, 234, - -1, 211, 234, -1, 195, -1, 10, -1, 194, 193, - -1, 56, 194, 193, -1, -1, 212, 118, 200, 144, - 139, -1, -1, 212, 234, 202, 203, 118, 144, 139, - -1, 236, -1, 204, -1, 121, 205, -1, 204, 119, - 205, -1, 91, 233, -1, 90, 233, -1, 89, 233, - -1, 110, 91, 233, -1, 110, 90, 233, -1, 110, - 89, 233, -1, 91, 110, 233, -1, 90, 110, 233, - -1, 89, 110, 233, -1, 207, 118, 210, 139, -1, - 211, 234, 121, 208, -1, 211, 234, -1, 211, 121, - 208, -1, 211, -1, 218, -1, 11, -1, 236, -1, - 209, 234, 119, -1, 209, 234, 122, 229, 119, -1, - 209, -1, 209, 234, -1, 209, 234, 122, 229, -1, - 65, -1, 55, -1, 100, -1, 107, -1, -1, 84, - 234, 118, 214, 144, 139, -1, -1, 76, 84, 234, - 118, 215, 144, 139, -1, 84, 118, 144, 139, -1, - 76, 84, 118, 144, 139, -1, 109, 234, -1, 109, - 84, 234, -1, 218, -1, 219, -1, 220, -1, 50, - -1, 52, -1, 113, -1, 53, -1, 54, -1, 94, - -1, 78, -1, 79, -1, 108, -1, 95, -1, 77, - -1, 94, 218, -1, 78, 218, -1, 108, 218, -1, - 95, 218, -1, 71, -1, 78, 71, -1, 61, -1, - 78, 78, 71, -1, 78, 61, -1, 111, -1, -1, - 222, 223, -1, 236, -1, 223, 224, -1, 3, -1, - 4, -1, 6, -1, 8, -1, 9, -1, 5, -1, - 10, -1, 11, -1, 12, -1, 7, -1, 14, -1, - 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, - 20, -1, 21, -1, 22, -1, 23, -1, 24, -1, - 31, -1, 32, -1, 33, -1, 34, -1, 35, -1, - 36, -1, 37, -1, 38, -1, 39, -1, 40, -1, - 41, -1, 42, -1, 43, -1, 44, -1, 45, -1, - 46, -1, 47, -1, 50, -1, 51, -1, 52, -1, - 53, -1, 54, -1, 55, -1, 56, -1, 57, -1, - 58, -1, 59, -1, 60, -1, 61, -1, 62, -1, - 63, -1, 65, -1, 67, -1, 68, -1, 70, -1, - 71, -1, 72, -1, 73, -1, 74, -1, 75, -1, - 76, -1, 77, -1, 78, -1, 83, -1, 84, -1, - 85, -1, 87, -1, 88, -1, 89, -1, 90, -1, - 91, -1, 69, -1, 92, -1, 93, -1, 94, -1, - 95, -1, 96, -1, 97, -1, 98, -1, 99, -1, - 100, -1, 102, -1, 103, -1, 104, -1, 105, -1, - 106, -1, 107, -1, 108, -1, 109, -1, 110, -1, - 111, -1, 112, -1, 113, -1, 114, -1, 129, -1, - 130, -1, 131, -1, 132, -1, 126, -1, 124, -1, - 125, -1, 140, -1, 134, -1, 122, -1, 133, -1, - 127, -1, 128, -1, 136, -1, 138, -1, 135, -1, - 119, -1, 120, -1, 121, -1, 137, -1, 141, -1, - 123, -1, 118, 223, 139, -1, 236, -1, 229, -1, - 236, -1, 227, -1, 229, -1, 227, 119, 229, -1, - 230, -1, 136, 198, 138, 228, -1, 99, 127, 198, - 128, 136, 227, 138, -1, 62, 127, 198, 128, 136, - 227, 138, -1, 96, 136, 198, 138, -1, 46, 136, - 198, 138, -1, 140, 228, -1, 134, 228, -1, 130, - 228, -1, 131, 228, -1, 126, 228, -1, 228, 131, - 228, -1, 228, 132, 228, -1, 228, 133, 228, -1, - 228, 129, 228, -1, 228, 130, 228, -1, 228, 124, - 228, -1, 228, 125, 228, -1, 228, 126, 228, -1, - 228, 15, 228, -1, 228, 16, 228, -1, 228, 17, - 228, -1, 228, 18, 228, -1, 228, 19, 228, -1, - 228, 20, 228, -1, 228, 21, 228, -1, 228, 22, - 228, -1, 228, 123, 228, 121, 228, -1, 228, 137, - 229, 141, -1, 228, 136, 227, 138, -1, 228, 136, - 138, -1, 228, 135, 228, -1, 228, 31, 228, -1, - 136, 227, 138, -1, 230, -1, 136, 198, 138, 229, - -1, 99, 127, 198, 128, 136, 227, 138, -1, 62, - 127, 198, 128, 136, 227, 138, -1, 11, 136, 226, - 138, -1, 77, 136, 226, 138, -1, 52, 136, 226, - 138, -1, 113, 136, 226, 138, -1, 53, 136, 226, - 138, -1, 54, 136, 226, 138, -1, 50, 136, 226, - 138, -1, 94, 136, 226, 138, -1, 78, 136, 226, - 138, -1, 108, 136, 226, 138, -1, 95, 136, 226, - 138, -1, 71, 136, 226, 138, -1, 61, 136, 226, - 138, -1, 96, 136, 198, 138, -1, 46, 136, 198, - 138, -1, 85, 196, -1, 85, 196, 136, 226, 138, - -1, 140, 229, -1, 134, 229, -1, 130, 229, -1, - 131, 229, -1, 126, 229, -1, 229, 131, 229, -1, - 229, 132, 229, -1, 229, 133, 229, -1, 229, 129, - 229, -1, 229, 130, 229, -1, 229, 124, 229, -1, - 229, 125, 229, -1, 229, 126, 229, -1, 229, 15, - 229, -1, 229, 16, 229, -1, 229, 17, 229, -1, - 229, 18, 229, -1, 229, 19, 229, -1, 229, 20, - 229, -1, 229, 127, 229, -1, 229, 128, 229, -1, - 229, 21, 229, -1, 229, 22, 229, -1, 229, 123, - 229, 121, 229, -1, 229, 137, 229, 141, -1, 229, - 136, 227, 138, -1, 229, 136, 138, -1, 229, 135, - 229, -1, 229, 31, 229, -1, 136, 227, 138, -1, - 4, -1, 103, -1, 70, -1, 5, -1, 3, -1, - 235, -1, 9, -1, 10, -1, 87, -1, 232, -1, - 136, 198, 138, 229, -1, 99, 127, 198, 128, 136, - 227, 138, -1, 62, 127, 198, 128, 136, 227, 138, - -1, 96, 136, 198, 138, -1, 46, 136, 198, 138, - -1, 85, 196, -1, 85, 196, 136, 226, 138, -1, - 140, 229, -1, 134, 229, -1, 130, 229, -1, 126, - 229, -1, 231, 131, 229, -1, 231, 132, 229, -1, - 231, 133, 229, -1, 231, 129, 229, -1, 231, 130, - 229, -1, 231, 124, 229, -1, 231, 125, 229, -1, - 231, 126, 229, -1, 231, 15, 229, -1, 231, 16, - 229, -1, 231, 17, 229, -1, 231, 18, 229, -1, - 231, 19, 229, -1, 231, 20, 229, -1, 231, 127, - 229, -1, 231, 128, 229, -1, 231, 21, 229, -1, - 231, 22, 229, -1, 231, 123, 229, 121, 229, -1, - 231, 137, 229, 141, -1, 231, 136, 227, 138, -1, - 231, 136, 138, -1, 231, 135, 229, -1, 231, 31, - 229, -1, 136, 227, 138, -1, 4, -1, 103, -1, - 70, -1, 5, -1, 3, -1, 235, -1, 9, -1, - 10, -1, 87, -1, 234, -1, 212, 234, -1, 106, - 234, -1, 10, -1, 11, -1, 6, -1, 8, -1, - 235, 6, -1, 235, 8, -1, -1 + 149, 0, -1, 121, 150, -1, 122, 246, -1, 123, + 214, -1, 256, -1, 150, 126, -1, 150, 155, -1, + 152, -1, 151, 125, 152, -1, 253, 142, 243, 144, + -1, 253, 124, 243, 145, -1, -1, 158, 124, 154, + 150, 145, -1, 161, -1, 184, -1, 153, -1, 230, + -1, 233, -1, 156, -1, 110, 167, -1, 49, -1, + 66, -1, 71, 127, -1, 94, 127, -1, 93, 127, + -1, 92, 127, -1, 82, 142, 253, 125, 10, 144, + 126, -1, 82, 142, 253, 125, 10, 125, 10, 144, + 126, -1, 83, 142, 253, 125, 10, 125, 10, 144, + 126, -1, 83, 142, 253, 125, 10, 125, 10, 125, + 10, 125, 10, 144, 126, -1, 84, 142, 253, 125, + 10, 125, 10, 144, 126, -1, 102, 142, 246, 125, + 255, 144, 126, -1, 102, 142, 246, 144, 126, -1, + -1, 75, 157, 155, -1, 256, -1, 69, 158, -1, + 69, 6, 158, -1, 101, 158, -1, 79, 158, -1, + 116, 158, -1, 70, 158, -1, 95, 158, -1, 118, + 158, -1, 85, 158, -1, 58, 158, -1, 50, 158, + -1, 68, 158, -1, 106, 158, -1, 143, 143, 159, + 146, 146, 158, -1, 160, -1, 160, 125, 159, -1, + 253, -1, 253, 142, 196, 144, -1, 162, -1, 158, + 211, 126, -1, 158, 172, 200, -1, 158, 175, 201, + -1, -1, 158, 213, 163, 165, -1, -1, 158, 57, + 213, 164, 166, -1, 192, 201, -1, 192, 199, 125, + 165, -1, 192, 201, -1, 192, 199, 125, 166, -1, + -1, 158, 213, 168, 170, -1, -1, 158, 57, 213, + 169, 171, -1, 158, 175, 201, -1, 192, 201, -1, + 192, 199, 125, 170, -1, 192, 201, -1, 192, 199, + 125, 171, -1, -1, 10, 142, 173, 194, 144, 181, + -1, -1, 11, 142, 174, 194, 144, 181, -1, -1, + 140, 253, 142, 176, 194, 144, 181, -1, -1, 11, + 142, 137, 190, 144, 142, 177, 194, 144, 181, 193, + -1, -1, 11, 142, 12, 137, 190, 144, 142, 178, + 194, 144, 181, 193, -1, -1, 90, 210, 206, 142, + 179, 194, 144, 181, -1, -1, 90, 57, 210, 206, + 142, 180, 194, 144, 181, -1, 10, -1, 256, -1, + 57, -1, 181, 88, -1, 181, 73, -1, 181, 91, + -1, 181, 85, -1, 181, 107, 142, 144, -1, 181, + 107, 142, 253, 144, -1, 147, -1, 140, -1, 137, + -1, 138, -1, 139, -1, 135, -1, 136, -1, 130, + -1, 132, -1, 131, -1, 15, -1, 16, -1, 17, + -1, 18, -1, 19, -1, 20, -1, 133, -1, 134, + -1, 21, -1, 22, -1, 128, -1, 125, -1, 34, + -1, 35, -1, 36, -1, 37, -1, 38, -1, 39, + -1, 40, -1, 41, -1, 42, -1, 43, -1, 44, + -1, 45, -1, 32, -1, 143, 146, -1, 142, 144, + -1, 87, -1, 62, -1, 161, -1, 184, -1, -1, + 105, 185, 133, 186, 134, 183, -1, 105, 161, -1, + 256, -1, 187, -1, 188, -1, 187, 125, 188, -1, + 56, 253, -1, 56, 253, 128, 214, -1, 112, 253, + -1, 112, 253, 128, 214, -1, 189, 207, 198, -1, + 57, 189, 207, 198, -1, 234, -1, 10, -1, 11, + -1, 254, -1, 90, 182, -1, 90, 6, 10, -1, + 57, 190, -1, 118, 190, -1, 137, 190, -1, 132, + 190, -1, 16, 190, -1, 12, 137, 190, -1, 190, + 143, 242, 146, -1, 142, 190, 144, -1, -1, 190, + 142, 191, 196, 144, 181, -1, 190, 193, -1, 190, + 127, 4, -1, 256, -1, 32, 212, 209, -1, 32, + 57, 212, 209, -1, 256, -1, 14, -1, 195, -1, + 195, 125, 14, -1, 195, 14, -1, 204, -1, 195, + 125, 204, -1, 256, -1, 14, -1, 197, -1, 197, + 125, 14, -1, 197, 14, -1, 205, -1, 197, 125, + 205, -1, 256, -1, 128, 245, -1, 256, -1, 128, + 246, -1, 126, -1, 124, 238, 145, -1, 127, 151, + 124, 238, 145, -1, 128, 61, 126, -1, 128, 62, + 126, -1, 126, -1, 124, 238, 145, -1, 128, 246, + 126, -1, 128, 61, 126, -1, 128, 62, 126, -1, + 128, 124, 202, 145, -1, 256, -1, 203, -1, 203, + 125, -1, 246, -1, 124, 202, 145, -1, 203, 125, + 246, -1, 203, 125, 124, 202, 145, -1, 210, 207, + 199, -1, 57, 210, 207, 199, -1, 57, 95, 210, + 207, 199, -1, 95, 204, -1, 204, -1, 248, -1, + 256, -1, 254, -1, 57, 206, -1, 118, 206, -1, + 137, 206, -1, 132, 206, -1, 16, 206, -1, 12, + 137, 206, -1, 206, 143, 242, 146, -1, 256, -1, + 254, -1, 57, 207, -1, 118, 207, -1, 137, 207, + -1, 132, 207, -1, 16, 207, -1, 12, 137, 207, + -1, 207, 143, 242, 146, -1, 142, 207, 144, 142, + 194, 144, 181, -1, 142, 207, 144, -1, 256, -1, + 57, 208, -1, 118, 208, -1, 137, 208, -1, 132, + 208, -1, 16, 208, -1, 12, 137, 208, -1, 208, + 143, 242, 146, -1, 256, -1, 57, 209, -1, 118, + 209, -1, 137, 208, -1, 132, 208, -1, 16, 208, + -1, 12, 137, 208, -1, 208, 143, 242, 146, -1, + 142, 194, 144, 181, 193, -1, 142, 137, 208, 144, + 142, 194, 144, 181, 193, -1, 142, 132, 208, 144, + 142, 194, 144, 181, 193, -1, 142, 16, 208, 144, + 142, 194, 144, 181, 193, -1, 234, -1, 11, -1, + 112, 253, -1, 215, -1, 217, -1, 223, -1, 229, + 253, -1, 228, 254, 127, 225, -1, 60, 142, 246, + 144, -1, 48, -1, 234, -1, 11, -1, 112, 253, + -1, 215, -1, 217, -1, 223, -1, 229, 253, -1, + 228, 254, 127, 225, -1, 228, 253, -1, 60, 142, + 246, 144, -1, 48, -1, 234, -1, 11, -1, 112, + 253, -1, 229, 253, -1, 228, 253, -1, 60, 142, + 246, 144, -1, 48, -1, 211, -1, 10, -1, 210, + 209, -1, 57, 210, 209, -1, -1, 229, 124, 216, + 150, 145, -1, -1, 229, 254, 218, 219, 220, 124, + 150, 145, -1, 256, -1, 73, -1, 256, -1, 221, + -1, 127, 222, -1, 221, 125, 222, -1, 252, -1, + 94, 252, -1, 93, 252, -1, 92, 252, -1, 116, + 94, 252, -1, 116, 93, 252, -1, 116, 92, 252, + -1, 94, 116, 252, -1, 93, 116, 252, -1, 92, + 116, 252, -1, 224, 124, 227, 145, -1, 228, 254, + 127, 225, -1, 228, 254, -1, 228, 127, 225, -1, + 228, -1, 235, -1, 11, -1, 256, -1, 226, 253, + 125, -1, 226, 253, 128, 246, 125, -1, 226, -1, + 226, 253, -1, 226, 253, 128, 246, -1, 67, -1, + 56, -1, 104, -1, 113, -1, -1, 86, 253, 124, + 231, 150, 145, -1, -1, 79, 86, 253, 124, 232, + 150, 145, -1, 86, 124, 150, 145, -1, 79, 86, + 124, 150, 145, -1, 115, 253, 126, -1, 115, 253, + 128, 214, 126, -1, 115, 86, 253, 126, -1, 235, + -1, 236, -1, 237, -1, 51, -1, 53, -1, 119, + -1, 54, -1, 55, -1, 98, -1, 81, -1, 114, + -1, 99, -1, 80, -1, 98, 235, -1, 81, 235, + -1, 114, 235, -1, 99, 235, -1, 74, -1, 63, + -1, 81, 63, -1, 117, -1, -1, 239, 240, -1, + 256, -1, 240, 241, -1, 3, -1, 4, -1, 6, + -1, 8, -1, 9, -1, 5, -1, 10, -1, 11, + -1, 12, -1, 7, -1, 14, -1, 15, -1, 16, + -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, + -1, 22, -1, 23, -1, 24, -1, 32, -1, 33, + -1, 34, -1, 35, -1, 36, -1, 37, -1, 38, + -1, 39, -1, 40, -1, 41, -1, 42, -1, 43, + -1, 44, -1, 45, -1, 46, -1, 47, -1, 48, + -1, 51, -1, 52, -1, 53, -1, 54, -1, 55, + -1, 56, -1, 57, -1, 58, -1, 59, -1, 60, + -1, 61, -1, 62, -1, 63, -1, 64, -1, 65, + -1, 67, -1, 69, -1, 70, -1, 72, -1, 73, + -1, 74, -1, 75, -1, 76, -1, 77, -1, 78, + -1, 79, -1, 80, -1, 81, -1, 85, -1, 86, + -1, 87, -1, 89, -1, 90, -1, 91, -1, 92, + -1, 93, -1, 94, -1, 71, -1, 95, -1, 96, + -1, 97, -1, 98, -1, 99, -1, 100, -1, 101, + -1, 102, -1, 103, -1, 104, -1, 106, -1, 107, + -1, 108, -1, 109, -1, 110, -1, 111, -1, 112, + -1, 113, -1, 114, -1, 115, -1, 116, -1, 117, + -1, 118, -1, 119, -1, 120, -1, 135, -1, 136, + -1, 137, -1, 138, -1, 132, -1, 130, -1, 131, + -1, 147, -1, 140, -1, 128, -1, 139, -1, 133, + -1, 134, -1, 142, -1, 144, -1, 141, -1, 125, + -1, 126, -1, 127, -1, 143, -1, 146, -1, 129, + -1, 124, 240, 145, -1, 256, -1, 246, -1, 256, + -1, 244, -1, 246, -1, 244, 125, 246, -1, 247, + -1, 142, 214, 144, 245, -1, 103, 133, 214, 134, + 142, 244, 144, -1, 64, 133, 214, 134, 142, 244, + 144, -1, 59, 133, 214, 134, 142, 244, 144, -1, + 96, 133, 214, 134, 142, 244, 144, -1, 100, 142, + 214, 144, -1, 47, 142, 214, 144, -1, 147, 245, + -1, 140, 245, -1, 136, 245, -1, 135, 245, -1, + 137, 245, -1, 132, 245, -1, 245, 137, 245, -1, + 245, 138, 245, -1, 245, 139, 245, -1, 245, 135, + 245, -1, 245, 136, 245, -1, 245, 130, 245, -1, + 245, 131, 245, -1, 245, 132, 245, -1, 245, 15, + 245, -1, 245, 16, 245, -1, 245, 17, 245, -1, + 245, 18, 245, -1, 245, 19, 245, -1, 245, 20, + 245, -1, 245, 21, 245, -1, 245, 22, 245, -1, + 245, 129, 245, 127, 245, -1, 245, 143, 246, 146, + -1, 245, 142, 244, 144, -1, 245, 142, 144, -1, + 245, 141, 245, -1, 245, 32, 245, -1, 142, 244, + 144, -1, 247, -1, 142, 214, 144, 246, -1, 103, + 133, 214, 134, 142, 244, 144, -1, 64, 133, 214, + 134, 142, 244, 144, -1, 59, 133, 214, 134, 142, + 244, 144, -1, 96, 133, 214, 134, 142, 244, 144, + -1, 11, 142, 243, 144, -1, 80, 142, 243, 144, + -1, 53, 142, 243, 144, -1, 119, 142, 243, 144, + -1, 54, 142, 243, 144, -1, 55, 142, 243, 144, + -1, 51, 142, 243, 144, -1, 98, 142, 243, 144, + -1, 81, 142, 243, 144, -1, 114, 142, 243, 144, + -1, 99, 142, 243, 144, -1, 74, 142, 243, 144, + -1, 63, 142, 243, 144, -1, 100, 142, 214, 144, + -1, 47, 142, 214, 144, -1, 87, 212, -1, 87, + 212, 142, 243, 144, -1, 111, 142, 214, 144, -1, + 111, 142, 246, 144, -1, 147, 246, -1, 140, 246, + -1, 136, 246, -1, 135, 246, -1, 137, 246, -1, + 132, 246, -1, 246, 137, 246, -1, 246, 138, 246, + -1, 246, 139, 246, -1, 246, 135, 246, -1, 246, + 136, 246, -1, 246, 130, 246, -1, 246, 131, 246, + -1, 246, 132, 246, -1, 246, 15, 246, -1, 246, + 16, 246, -1, 246, 17, 246, -1, 246, 18, 246, + -1, 246, 19, 246, -1, 246, 20, 246, -1, 246, + 133, 246, -1, 246, 134, 246, -1, 246, 21, 246, + -1, 246, 22, 246, -1, 246, 129, 246, 127, 246, + -1, 246, 143, 246, 146, -1, 246, 142, 244, 144, + -1, 246, 142, 144, -1, 246, 141, 246, -1, 246, + 32, 246, -1, 142, 244, 144, -1, 4, -1, 108, + -1, 72, -1, 5, -1, 3, -1, 255, -1, 9, + -1, 10, -1, 73, -1, 91, -1, 89, -1, 143, + 250, 146, 181, 193, 124, 238, 145, -1, 143, 250, + 146, 142, 194, 144, 181, 193, 124, 238, 145, -1, + 249, -1, 142, 214, 144, 246, -1, 103, 133, 214, + 134, 142, 244, 144, -1, 64, 133, 214, 134, 142, + 244, 144, -1, 59, 133, 214, 134, 142, 244, 144, + -1, 96, 133, 214, 134, 142, 244, 144, -1, 100, + 142, 214, 144, -1, 47, 142, 214, 144, -1, 87, + 212, -1, 87, 212, 142, 243, 144, -1, 111, 142, + 214, 144, -1, 111, 142, 246, 144, -1, 147, 246, + -1, 140, 246, -1, 136, 246, -1, 135, 246, -1, + 132, 246, -1, 248, 137, 246, -1, 248, 138, 246, + -1, 248, 139, 246, -1, 248, 135, 246, -1, 248, + 136, 246, -1, 248, 130, 246, -1, 248, 131, 246, + -1, 248, 132, 246, -1, 248, 15, 246, -1, 248, + 16, 246, -1, 248, 17, 246, -1, 248, 18, 246, + -1, 248, 19, 246, -1, 248, 20, 246, -1, 248, + 133, 246, -1, 248, 134, 246, -1, 248, 21, 246, + -1, 248, 22, 246, -1, 248, 129, 246, 127, 246, + -1, 248, 143, 246, 146, -1, 248, 142, 244, 144, + -1, 248, 142, 144, -1, 248, 141, 246, -1, 248, + 32, 246, -1, 142, 244, 144, -1, 4, -1, 108, + -1, 72, -1, 5, -1, 3, -1, 255, -1, 9, + -1, 10, -1, 73, -1, 91, -1, 89, -1, 256, + -1, 251, -1, 251, 125, 250, -1, 132, -1, 128, + -1, 132, 253, -1, 253, -1, 253, -1, 229, 253, + -1, 112, 253, -1, 10, -1, 11, -1, 73, -1, + 91, -1, 10, -1, 11, -1, 91, -1, 6, -1, + 8, -1, 255, 6, -1, 255, 8, -1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 406, 406, 407, 411, 418, 419, 420, 424, 425, - 429, 442, 441, 453, 454, 455, 456, 457, 458, 459, - 460, 473, 482, 486, 494, 498, 502, 513, 534, 556, - 589, 611, 622, 636, 635, 650, 654, 658, 669, 673, - 677, 681, 685, 689, 693, 697, 701, 705, 712, 716, - 725, 737, 736, 752, 751, 773, 781, 792, 801, 815, - 814, 830, 829, 844, 859, 865, 874, 881, 894, 893, - 918, 917, 942, 941, 972, 971, 990, 989, 1010, 1009, - 1041, 1040, 1066, 1079, 1083, 1087, 1091, 1095, 1102, 1106, - 1110, 1114, 1118, 1122, 1126, 1130, 1134, 1138, 1142, 1146, - 1150, 1154, 1158, 1162, 1166, 1170, 1174, 1178, 1182, 1186, - 1190, 1194, 1198, 1202, 1206, 1210, 1214, 1218, 1222, 1226, - 1230, 1234, 1238, 1242, 1246, 1250, 1254, 1261, 1262, 1267, - 1266, 1274, 1278, 1279, 1283, 1289, 1298, 1302, 1306, 1310, - 1314, 1320, 1330, 1334, 1339, 1351, 1355, 1369, 1384, 1389, - 1394, 1399, 1404, 1409, 1414, 1419, 1424, 1430, 1429, 1451, - 1455, 1460, 1464, 1469, 1477, 1482, 1490, 1494, 1501, 1505, - 1512, 1516, 1520, 1524, 1528, 1532, 1536, 1543, 1544, 1545, - 1549, 1552, 1553, 1554, 1558, 1563, 1569, 1575, 1579, 1589, - 1593, 1597, 1601, 1606, 1611, 1616, 1621, 1626, 1631, 1639, - 1643, 1647, 1651, 1656, 1661, 1666, 1671, 1676, 1681, 1686, - 1692, 1700, 1704, 1709, 1714, 1719, 1724, 1729, 1734, 1739, - 1748, 1752, 1760, 1764, 1768, 1772, 1776, 1792, 1808, 1817, - 1824, 1828, 1836, 1840, 1844, 1848, 1852, 1868, 1884, 1902, - 1911, 1918, 1922, 1930, 1934, 1950, 1969, 1973, 1981, 1987, - 1998, 1997, 2022, 2021, 2051, 2052, 2056, 2057, 2061, 2065, - 2069, 2073, 2077, 2081, 2085, 2089, 2093, 2100, 2108, 2112, - 2116, 2120, 2127, 2131, 2138, 2139, 2145, 2153, 2154, 2160, - 2169, 2176, 2180, 2184, 2192, 2191, 2214, 2213, 2236, 2237, - 2241, 2247, 2256, 2257, 2258, 2262, 2266, 2270, 2274, 2278, - 2282, 2287, 2292, 2297, 2302, 2307, 2311, 2316, 2325, 2330, - 2338, 2342, 2347, 2351, 2356, 2364, 2374, 2374, 2384, 2385, - 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, - 2399, 2399, 2399, 2400, 2400, 2400, 2400, 2401, 2401, 2401, - 2401, 2401, 2402, 2402, 2402, 2403, 2403, 2403, 2403, 2403, - 2404, 2404, 2404, 2404, 2404, 2405, 2405, 2405, 2405, 2405, - 2406, 2406, 2406, 2407, 2407, 2407, 2407, 2407, 2408, 2408, - 2408, 2408, 2408, 2409, 2409, 2409, 2410, 2410, 2410, 2410, - 2410, 2410, 2411, 2411, 2411, 2411, 2412, 2412, 2412, 2412, - 2412, 2413, 2413, 2413, 2413, 2414, 2414, 2414, 2414, 2414, - 2415, 2415, 2415, 2415, 2415, 2416, 2416, 2416, 2416, 2416, - 2417, 2417, 2417, 2417, 2417, 2420, 2420, 2420, 2420, 2420, - 2420, 2420, 2420, 2420, 2420, 2420, 2421, 2421, 2421, 2421, - 2421, 2421, 2421, 2421, 2421, 2421, 2422, 2422, 2426, 2430, - 2437, 2441, 2448, 2452, 2459, 2463, 2467, 2471, 2475, 2479, - 2483, 2487, 2491, 2495, 2499, 2503, 2507, 2511, 2515, 2519, - 2523, 2527, 2531, 2535, 2539, 2543, 2547, 2551, 2555, 2559, - 2563, 2567, 2571, 2575, 2579, 2583, 2587, 2591, 2599, 2603, - 2607, 2611, 2615, 2625, 2631, 2637, 2643, 2649, 2655, 2661, - 2668, 2675, 2682, 2689, 2695, 2701, 2705, 2709, 2713, 2717, - 2721, 2725, 2729, 2733, 2737, 2741, 2745, 2749, 2753, 2757, - 2761, 2765, 2769, 2773, 2777, 2781, 2785, 2789, 2793, 2797, - 2801, 2805, 2809, 2813, 2817, 2821, 2825, 2829, 2833, 2840, - 2844, 2848, 2852, 2856, 2860, 2864, 2868, 2872, 2886, 2890, - 2894, 2898, 2902, 2906, 2910, 2914, 2918, 2922, 2926, 2930, - 2934, 2938, 2942, 2946, 2950, 2954, 2958, 2962, 2966, 2970, - 2974, 2978, 2982, 2986, 2990, 2994, 2998, 3002, 3006, 3010, - 3014, 3018, 3022, 3026, 3030, 3037, 3041, 3045, 3049, 3053, - 3057, 3061, 3065, 3069, 3076, 3084, 3092, 3118, 3122, 3129, - 3133, 3137, 3143, 3154 + 0, 421, 421, 422, 426, 433, 434, 435, 439, 440, + 444, 448, 461, 460, 472, 473, 474, 475, 476, 477, + 478, 479, 492, 501, 505, 513, 517, 521, 532, 553, + 575, 608, 630, 641, 655, 654, 669, 673, 677, 688, + 692, 696, 700, 704, 708, 712, 716, 720, 724, 728, + 732, 740, 741, 745, 746, 750, 754, 763, 771, 783, + 782, 798, 797, 819, 827, 838, 847, 861, 860, 876, + 875, 890, 905, 911, 920, 927, 940, 939, 964, 963, + 991, 990, 1021, 1020, 1039, 1038, 1059, 1058, 1090, 1089, + 1115, 1128, 1132, 1136, 1140, 1144, 1148, 1153, 1157, 1168, + 1172, 1176, 1180, 1184, 1188, 1192, 1196, 1200, 1204, 1208, + 1212, 1216, 1220, 1224, 1228, 1232, 1236, 1240, 1244, 1248, + 1252, 1256, 1260, 1264, 1268, 1272, 1276, 1280, 1284, 1288, + 1292, 1296, 1300, 1304, 1308, 1312, 1316, 1320, 1327, 1328, + 1333, 1332, 1340, 1344, 1345, 1349, 1355, 1364, 1368, 1372, + 1376, 1380, 1386, 1396, 1400, 1405, 1417, 1421, 1435, 1450, + 1455, 1460, 1465, 1470, 1475, 1480, 1485, 1491, 1490, 1512, + 1522, 1532, 1536, 1540, 1549, 1553, 1558, 1562, 1567, 1575, + 1580, 1588, 1592, 1597, 1601, 1606, 1614, 1619, 1627, 1631, + 1638, 1642, 1649, 1653, 1657, 1661, 1665, 1672, 1676, 1680, + 1684, 1688, 1692, 1699, 1700, 1701, 1705, 1708, 1709, 1710, + 1714, 1719, 1725, 1731, 1742, 1746, 1756, 1760, 1764, 1769, + 1774, 1779, 1784, 1789, 1794, 1802, 1806, 1810, 1815, 1820, + 1825, 1830, 1835, 1840, 1845, 1851, 1859, 1863, 1868, 1873, + 1878, 1883, 1888, 1893, 1901, 1905, 1910, 1915, 1920, 1925, + 1930, 1935, 1940, 1946, 1953, 1960, 1970, 1974, 1982, 1986, + 1990, 1994, 1998, 2014, 2030, 2039, 2046, 2050, 2058, 2062, + 2066, 2070, 2074, 2090, 2106, 2124, 2133, 2140, 2144, 2152, + 2156, 2172, 2188, 2197, 2204, 2208, 2216, 2220, 2229, 2228, + 2253, 2252, 2282, 2283, 2290, 2291, 2295, 2296, 2300, 2304, + 2308, 2312, 2316, 2320, 2324, 2328, 2332, 2336, 2343, 2351, + 2355, 2359, 2363, 2370, 2374, 2381, 2382, 2388, 2396, 2397, + 2403, 2412, 2419, 2423, 2427, 2435, 2434, 2457, 2456, 2479, + 2480, 2484, 2490, 2497, 2506, 2507, 2508, 2512, 2516, 2520, + 2524, 2528, 2532, 2537, 2542, 2547, 2552, 2556, 2561, 2570, + 2575, 2583, 2587, 2591, 2599, 2609, 2609, 2619, 2620, 2624, + 2625, 2626, 2627, 2628, 2629, 2630, 2631, 2632, 2633, 2634, + 2634, 2634, 2635, 2635, 2635, 2635, 2636, 2636, 2636, 2636, + 2636, 2637, 2637, 2637, 2638, 2638, 2638, 2638, 2638, 2639, + 2639, 2639, 2639, 2639, 2640, 2640, 2640, 2640, 2640, 2641, + 2641, 2641, 2641, 2641, 2642, 2642, 2642, 2642, 2643, 2643, + 2643, 2643, 2643, 2644, 2644, 2644, 2644, 2644, 2645, 2645, + 2645, 2645, 2645, 2645, 2646, 2646, 2646, 2646, 2646, 2647, + 2647, 2647, 2647, 2648, 2648, 2648, 2648, 2649, 2649, 2649, + 2649, 2649, 2650, 2650, 2650, 2651, 2651, 2651, 2651, 2651, + 2652, 2652, 2652, 2652, 2652, 2653, 2653, 2653, 2653, 2653, + 2656, 2656, 2656, 2656, 2656, 2656, 2656, 2656, 2656, 2656, + 2656, 2657, 2657, 2657, 2657, 2657, 2657, 2657, 2657, 2657, + 2657, 2658, 2658, 2662, 2666, 2673, 2677, 2684, 2688, 2695, + 2699, 2703, 2707, 2711, 2715, 2719, 2723, 2727, 2731, 2735, + 2739, 2743, 2747, 2751, 2755, 2759, 2763, 2767, 2771, 2775, + 2779, 2783, 2787, 2791, 2795, 2799, 2803, 2807, 2811, 2815, + 2819, 2823, 2827, 2831, 2835, 2839, 2847, 2851, 2855, 2859, + 2863, 2867, 2871, 2881, 2887, 2893, 2899, 2905, 2911, 2917, + 2924, 2931, 2938, 2945, 2951, 2957, 2961, 2965, 2969, 2973, + 2984, 2995, 2999, 3003, 3007, 3011, 3015, 3019, 3023, 3027, + 3031, 3035, 3039, 3043, 3047, 3051, 3055, 3059, 3063, 3067, + 3071, 3075, 3079, 3083, 3087, 3091, 3095, 3099, 3103, 3107, + 3111, 3115, 3122, 3126, 3130, 3134, 3138, 3142, 3146, 3150, + 3154, 3160, 3166, 3170, 3174, 3188, 3192, 3196, 3200, 3204, + 3208, 3212, 3216, 3220, 3224, 3228, 3239, 3250, 3254, 3258, + 3262, 3266, 3270, 3274, 3278, 3282, 3286, 3290, 3294, 3298, + 3302, 3306, 3310, 3314, 3318, 3322, 3326, 3330, 3334, 3338, + 3342, 3346, 3350, 3354, 3358, 3362, 3366, 3373, 3377, 3381, + 3385, 3389, 3393, 3397, 3401, 3405, 3411, 3417, 3425, 3426, + 3427, 3431, 3432, 3433, 3434, 3438, 3446, 3454, 3482, 3486, + 3490, 3494, 3505, 3509, 3513, 3521, 3525, 3529, 3535, 3546 }; #endif @@ -1195,56 +1251,62 @@ static const char *const yytname[] = "IDENTIFIER", "TYPENAME_IDENTIFIER", "SCOPING", "TYPEDEFNAME", "ELLIPSIS", "OROR", "ANDAND", "EQCOMPARE", "NECOMPARE", "LECOMPARE", "GECOMPARE", "LSHIFT", "RSHIFT", "POINTSAT_STAR", "DOT_STAR", "UNARY", - "UNARY_NOT", "UNARY_NEGATE", "UNARY_MINUS", "UNARY_STAR", "UNARY_REF", - "POINTSAT", "SCOPE", "PLUSPLUS", "MINUSMINUS", "TIMESEQUAL", + "UNARY_NOT", "UNARY_NEGATE", "UNARY_MINUS", "UNARY_PLUS", "UNARY_STAR", + "UNARY_REF", "POINTSAT", "SCOPE", "PLUSPLUS", "MINUSMINUS", "TIMESEQUAL", "DIVIDEEQUAL", "MODEQUAL", "PLUSEQUAL", "MINUSEQUAL", "OREQUAL", "ANDEQUAL", "XOREQUAL", "LSHIFTEQUAL", "RSHIFTEQUAL", "KW_ALIGNAS", "KW_ALIGNOF", "KW_AUTO", "KW_BEGIN_PUBLISH", "KW_BLOCKING", "KW_BOOL", "KW_CATCH", "KW_CHAR", "KW_CHAR16_T", "KW_CHAR32_T", "KW_CLASS", - "KW_CONST", "KW_CONSTEXPR", "KW_DECLTYPE", "KW_DEFAULT", "KW_DELETE", - "KW_DOUBLE", "KW_DYNAMIC_CAST", "KW_ELSE", "KW_END_PUBLISH", "KW_ENUM", - "KW_EXTENSION", "KW_EXTERN", "KW_EXPLICIT", "KW_PUBLISHED", "KW_FALSE", - "KW_FLOAT", "KW_FRIEND", "KW_FOR", "KW_GOTO", "KW_IF", "KW_INLINE", - "KW_INT", "KW_LONG", "KW_LONGLONG", "KW_MAKE_PROPERTY", + "KW_CONST", "KW_CONSTEXPR", "KW_CONST_CAST", "KW_DECLTYPE", "KW_DEFAULT", + "KW_DELETE", "KW_DOUBLE", "KW_DYNAMIC_CAST", "KW_ELSE", "KW_END_PUBLISH", + "KW_ENUM", "KW_EXTENSION", "KW_EXTERN", "KW_EXPLICIT", "KW_PUBLISHED", + "KW_FALSE", "KW_FINAL", "KW_FLOAT", "KW_FRIEND", "KW_FOR", "KW_GOTO", + "KW_IF", "KW_INLINE", "KW_INT", "KW_LONG", "KW_MAKE_PROPERTY", "KW_MAKE_PROPERTY2", "KW_MAKE_SEQ", "KW_MUTABLE", "KW_NAMESPACE", - "KW_NEW", "KW_NOEXCEPT", "KW_NULLPTR", "KW_OPERATOR", "KW_PRIVATE", - "KW_PROTECTED", "KW_PUBLIC", "KW_REGISTER", "KW_RETURN", "KW_SHORT", - "KW_SIGNED", "KW_SIZEOF", "KW_STATIC", "KW_STATIC_ASSERT", - "KW_STATIC_CAST", "KW_STRUCT", "KW_TEMPLATE", "KW_THROW", "KW_TRUE", - "KW_TRY", "KW_TYPEDEF", "KW_TYPENAME", "KW_UNION", "KW_UNSIGNED", + "KW_NEW", "KW_NOEXCEPT", "KW_NULLPTR", "KW_OPERATOR", "KW_OVERRIDE", + "KW_PRIVATE", "KW_PROTECTED", "KW_PUBLIC", "KW_REGISTER", + "KW_REINTERPRET_CAST", "KW_RETURN", "KW_SHORT", "KW_SIGNED", "KW_SIZEOF", + "KW_STATIC", "KW_STATIC_ASSERT", "KW_STATIC_CAST", "KW_STRUCT", + "KW_TEMPLATE", "KW_THREAD_LOCAL", "KW_THROW", "KW_TRUE", "KW_TRY", + "KW_TYPEDEF", "KW_TYPEID", "KW_TYPENAME", "KW_UNION", "KW_UNSIGNED", "KW_USING", "KW_VIRTUAL", "KW_VOID", "KW_VOLATILE", "KW_WCHAR_T", "KW_WHILE", "START_CPP", "START_CONST_EXPR", "START_TYPE", "'{'", "','", "';'", "':'", "'='", "'?'", "'|'", "'^'", "'&'", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", "'%'", "'~'", "'.'", "'('", "'['", "')'", "'}'", - "'!'", "']'", "$accept", "grammar", "cpp", "constructor_inits", + "']'", "'!'", "$accept", "grammar", "cpp", "constructor_inits", "constructor_init", "extern_c", "$@1", "declaration", - "friend_declaration", "$@2", "storage_class", "type_like_declaration", + "friend_declaration", "$@2", "storage_class", "attribute_specifiers", + "attribute_specifier", "type_like_declaration", "multiple_var_declaration", "$@3", "$@4", "multiple_instance_identifiers", "multiple_const_instance_identifiers", "typedef_declaration", "$@5", "$@6", "typedef_instance_identifiers", - "typedef_const_instance_identifiers", "function_prototype", "$@7", "$@8", - "$@9", "$@10", "$@11", "$@12", "$@13", "function_post", - "function_operator", "more_template_declaration", "template_declaration", - "$@14", "template_formal_parameters", + "typedef_const_instance_identifiers", "constructor_prototype", "$@7", + "$@8", "function_prototype", "$@9", "$@10", "$@11", "$@12", "$@13", + "function_post", "function_operator", "more_template_declaration", + "template_declaration", "$@14", "template_formal_parameters", "template_nonempty_formal_parameters", "template_formal_parameter", "template_formal_parameter_type", "instance_identifier", "$@15", - "formal_parameter_list", "formal_parameters", + "instance_identifier_and_maybe_trailing_return_type", + "maybe_trailing_return_type", "function_parameter_list", + "function_parameters", "formal_parameter_list", "formal_parameters", "template_parameter_maybe_initialize", "maybe_initialize", + "maybe_initialize_or_constructor_body", "maybe_initialize_or_function_body", "structure_init", - "structure_init_body", "formal_parameter", + "structure_init_body", "function_parameter", "formal_parameter", "not_paren_formal_parameter_identifier", "formal_parameter_identifier", - "empty_instance_identifier", "type", "type_decl", "predefined_type", - "var_type_decl", "full_type", "anonymous_struct", "$@16", "named_struct", - "$@17", "maybe_class_derivation", "class_derivation", - "base_specification", "enum", "enum_decl", "enum_element_type", - "enum_body_trailing_comma", "enum_body", "enum_keyword", - "struct_keyword", "namespace_declaration", "$@18", "$@19", - "using_declaration", "simple_type", "simple_int_type", + "not_paren_empty_instance_identifier", "empty_instance_identifier", + "type", "type_decl", "predefined_type", "var_type_decl", "full_type", + "anonymous_struct", "$@16", "named_struct", "$@17", "maybe_final", + "maybe_class_derivation", "class_derivation", "base_specification", + "enum", "enum_decl", "enum_element_type", "enum_body_trailing_comma", + "enum_body", "enum_keyword", "struct_keyword", "namespace_declaration", + "$@18", "$@19", "using_declaration", "simple_type", "simple_int_type", "simple_float_type", "simple_void_type", "code", "$@20", "code_block", "element", "optional_const_expr", "optional_const_expr_comma", "const_expr_comma", "no_angle_bracket_const_expr", "const_expr", "const_operand", "formal_const_expr", "formal_const_operand", - "class_derivation_name", "name", "string_literal", "empty", YY_NULL + "capture_list", "capture", "class_derivation_name", "name", + "name_no_final", "string_literal", "empty", YY_NULL }; #endif @@ -1264,113 +1326,124 @@ static const yytype_uint16 yytoknum[] = 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, - 365, 366, 367, 368, 369, 370, 371, 372, 123, 44, - 59, 58, 61, 63, 124, 94, 38, 60, 62, 43, - 45, 42, 47, 37, 126, 46, 40, 91, 41, 125, - 33, 93 + 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, + 375, 376, 377, 378, 123, 44, 59, 58, 61, 63, + 124, 94, 38, 60, 62, 43, 45, 42, 47, 37, + 126, 46, 40, 91, 41, 125, 93, 33 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = +static const yytype_uint16 yyr1[] = { - 0, 142, 143, 143, 143, 144, 144, 144, 145, 145, - 146, 148, 147, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, - 149, 149, 149, 151, 150, 152, 152, 152, 152, 152, - 152, 152, 152, 152, 152, 152, 152, 152, 153, 153, - 153, 155, 154, 156, 154, 157, 157, 158, 158, 160, - 159, 161, 159, 159, 162, 162, 163, 163, 165, 164, - 166, 164, 167, 164, 168, 164, 169, 164, 170, 164, - 171, 164, 164, 172, 172, 172, 172, 172, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, - 173, 173, 173, 173, 173, 173, 173, 174, 174, 176, - 175, 175, 177, 177, 178, 178, 179, 179, 179, 179, - 179, 179, 180, 180, 180, 181, 181, 181, 181, 181, - 181, 181, 181, 181, 181, 181, 181, 182, 181, 183, - 183, 183, 183, 183, 184, 184, 185, 185, 186, 186, - 187, 187, 187, 187, 187, 187, 187, 188, 188, 188, - 189, 189, 189, 189, 190, 190, 190, 190, 190, 191, - 191, 191, 191, 191, 191, 191, 191, 191, 191, 192, - 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - 192, 193, 193, 193, 193, 193, 193, 193, 193, 193, - 194, 194, 194, 194, 194, 194, 194, 194, 194, 194, - 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, + 0, 148, 149, 149, 149, 150, 150, 150, 151, 151, + 152, 152, 154, 153, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, + 155, 155, 155, 155, 157, 156, 158, 158, 158, 158, + 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 158, 159, 159, 160, 160, 161, 161, 161, 161, 163, + 162, 164, 162, 165, 165, 166, 166, 168, 167, 169, + 167, 167, 170, 170, 171, 171, 173, 172, 174, 172, + 176, 175, 177, 175, 178, 175, 179, 175, 180, 175, + 175, 181, 181, 181, 181, 181, 181, 181, 181, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, + 182, 182, 182, 182, 182, 182, 182, 182, 183, 183, + 185, 184, 184, 186, 186, 187, 187, 188, 188, 188, + 188, 188, 188, 189, 189, 189, 190, 190, 190, 190, + 190, 190, 190, 190, 190, 190, 190, 191, 190, 192, + 192, 193, 193, 193, 194, 194, 194, 194, 194, 195, 195, 196, 196, 196, 196, 196, 197, 197, 198, 198, - 200, 199, 202, 201, 203, 203, 204, 204, 205, 205, - 205, 205, 205, 205, 205, 205, 205, 206, 207, 207, - 207, 207, 208, 208, 209, 209, 209, 210, 210, 210, - 211, 212, 212, 212, 214, 213, 215, 213, 213, 213, - 216, 216, 217, 217, 217, 218, 218, 218, 218, 218, - 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - 219, 219, 219, 219, 219, 220, 222, 221, 223, 223, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 225, 225, - 226, 226, 227, 227, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 230, - 230, 230, 230, 230, 230, 230, 230, 230, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, - 231, 231, 231, 231, 231, 232, 232, 232, 232, 232, - 232, 232, 232, 232, 233, 233, 233, 234, 234, 235, - 235, 235, 235, 236 + 199, 199, 200, 200, 200, 200, 200, 201, 201, 201, + 201, 201, 201, 202, 202, 202, 203, 203, 203, 203, + 204, 204, 204, 204, 205, 205, 206, 206, 206, 206, + 206, 206, 206, 206, 206, 207, 207, 207, 207, 207, + 207, 207, 207, 207, 207, 207, 208, 208, 208, 208, + 208, 208, 208, 208, 209, 209, 209, 209, 209, 209, + 209, 209, 209, 209, 209, 209, 210, 210, 210, 210, + 210, 210, 210, 210, 210, 210, 211, 211, 211, 211, + 211, 211, 211, 211, 211, 211, 211, 212, 212, 212, + 212, 212, 212, 212, 213, 213, 214, 214, 216, 215, + 218, 217, 219, 219, 220, 220, 221, 221, 222, 222, + 222, 222, 222, 222, 222, 222, 222, 222, 223, 224, + 224, 224, 224, 225, 225, 226, 226, 226, 227, 227, + 227, 228, 229, 229, 229, 231, 230, 232, 230, 230, + 230, 233, 233, 233, 234, 234, 234, 235, 235, 235, + 235, 235, 235, 235, 235, 235, 235, 235, 235, 235, + 235, 236, 236, 236, 237, 239, 238, 240, 240, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 241, 241, 241, 241, 241, 241, 241, + 241, 241, 241, 242, 242, 243, 243, 244, 244, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 247, 247, 247, 247, 247, 247, 247, 247, + 247, 247, 247, 247, 247, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 249, 249, 249, + 249, 249, 249, 249, 249, 249, 249, 249, 250, 250, + 250, 251, 251, 251, 251, 252, 252, 252, 253, 253, + 253, 253, 254, 254, 254, 255, 255, 255, 255, 256 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 2, 2, 2, 1, 2, 2, 1, 3, - 4, 0, 5, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 2, 2, 2, 2, 7, 9, 9, 13, - 9, 6, 4, 0, 3, 1, 2, 3, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, - 3, 0, 4, 0, 5, 2, 4, 2, 4, 0, - 4, 0, 5, 3, 2, 4, 2, 4, 0, 6, - 0, 6, 0, 7, 0, 10, 0, 11, 0, 8, - 0, 9, 1, 1, 1, 2, 4, 5, 1, 1, + 4, 4, 0, 5, 1, 1, 1, 1, 1, 1, + 2, 1, 1, 2, 2, 2, 2, 7, 9, 9, + 13, 9, 7, 5, 0, 3, 1, 2, 3, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 6, 1, 3, 1, 4, 1, 3, 3, 3, 0, + 4, 0, 5, 2, 4, 2, 4, 0, 4, 0, + 5, 3, 2, 4, 2, 4, 0, 6, 0, 6, + 0, 7, 0, 11, 0, 12, 0, 8, 0, 9, + 1, 1, 1, 2, 2, 2, 2, 4, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 2, 2, 1, 1, 1, 1, 0, - 6, 2, 1, 1, 1, 3, 2, 4, 2, 4, - 3, 4, 1, 1, 1, 1, 2, 3, 2, 2, - 2, 2, 2, 3, 4, 3, 3, 0, 6, 1, - 1, 1, 3, 2, 1, 3, 1, 2, 1, 2, - 1, 3, 5, 3, 3, 3, 4, 1, 1, 2, - 1, 3, 3, 5, 3, 4, 5, 2, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 3, 4, 1, - 1, 1, 2, 2, 2, 2, 2, 3, 4, 7, - 3, 1, 2, 2, 2, 2, 2, 3, 4, 7, - 1, 1, 2, 1, 1, 1, 2, 4, 4, 1, - 1, 1, 2, 1, 1, 1, 2, 4, 2, 4, - 1, 1, 1, 2, 2, 2, 1, 1, 2, 3, - 0, 5, 0, 7, 1, 1, 2, 3, 2, 2, - 2, 3, 3, 3, 3, 3, 3, 4, 4, 2, - 3, 1, 1, 1, 1, 3, 5, 1, 2, 4, - 1, 1, 1, 1, 0, 6, 0, 7, 4, 5, - 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 1, 2, 1, 3, 2, 1, 0, 2, 1, 2, + 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, + 0, 6, 2, 1, 1, 1, 3, 2, 4, 2, + 4, 3, 4, 1, 1, 1, 1, 2, 3, 2, + 2, 2, 2, 2, 3, 4, 3, 0, 6, 2, + 3, 1, 3, 4, 1, 1, 1, 3, 2, 1, + 3, 1, 1, 1, 3, 2, 1, 3, 1, 2, + 1, 2, 1, 3, 5, 3, 3, 1, 3, 3, + 3, 3, 4, 1, 1, 2, 1, 3, 3, 5, + 3, 4, 5, 2, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 3, 4, 1, 1, 2, 2, 2, + 2, 2, 3, 4, 7, 3, 1, 2, 2, 2, + 2, 2, 3, 4, 1, 2, 2, 2, 2, 2, + 3, 4, 5, 9, 9, 9, 1, 1, 2, 1, + 1, 1, 2, 4, 4, 1, 1, 1, 2, 1, + 1, 1, 2, 4, 2, 4, 1, 1, 1, 2, + 2, 2, 4, 1, 1, 1, 2, 3, 0, 5, + 0, 8, 1, 1, 1, 1, 2, 3, 1, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, + 2, 3, 1, 1, 1, 1, 3, 5, 1, 2, + 4, 1, 1, 1, 1, 0, 6, 0, 7, 4, + 5, 3, 5, 4, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 1, 1, 2, 1, 0, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1382,23 +1455,26 @@ static const yytype_uint8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, - 1, 1, 1, 3, 1, 4, 7, 7, 4, 4, - 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 5, 4, 4, 3, 3, 3, 3, 1, 4, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 3, 1, 1, 1, 1, 1, 3, 1, + 4, 7, 7, 7, 7, 4, 4, 2, 2, 2, + 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, + 4, 4, 3, 3, 3, 3, 1, 4, 7, 7, 7, 7, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 2, 5, 2, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, + 4, 4, 4, 4, 4, 4, 4, 2, 5, 4, + 4, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 5, 4, 4, 3, 3, 3, 3, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, - 7, 7, 4, 4, 2, 5, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, + 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 8, 11, 1, 4, 7, 7, 7, + 7, 4, 4, 2, 5, 4, 4, 2, 2, 2, + 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, - 4, 3, 3, 3, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, - 1, 2, 2, 0 + 5, 4, 4, 3, 3, 3, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 1, 1, 2, 1, 1, 2, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 0 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -1406,1340 +1482,1525 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint16 yydefact[] = { - 0, 593, 0, 0, 0, 593, 5, 533, 529, 532, - 589, 590, 535, 536, 0, 0, 0, 0, 0, 0, - 0, 0, 531, 0, 0, 0, 0, 537, 0, 0, - 0, 0, 530, 0, 0, 0, 0, 0, 0, 0, - 0, 3, 478, 534, 221, 229, 295, 296, 298, 299, - 281, 0, 0, 312, 280, 310, 305, 301, 302, 300, - 304, 282, 0, 283, 303, 315, 297, 593, 4, 223, - 224, 225, 0, 271, 0, 220, 292, 293, 294, 1, - 20, 593, 593, 21, 593, 593, 593, 0, 33, 593, - 0, 0, 0, 593, 0, 0, 0, 0, 593, 593, - 0, 593, 593, 0, 593, 593, 6, 15, 7, 18, - 0, 13, 48, 14, 16, 17, 35, 593, 0, 593, - 593, 593, 593, 593, 0, 593, 593, 593, 242, 0, - 497, 0, 0, 241, 593, 593, 0, 0, 593, 593, - 503, 501, 502, 500, 221, 295, 296, 298, 299, 312, - 310, 305, 301, 300, 304, 303, 297, 0, 0, 442, - 499, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 669, 0, 0, 0, 669, 5, 586, 582, 585, + 665, 666, 588, 589, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 584, 590, 0, 0, 0, 0, 592, + 591, 0, 0, 0, 0, 0, 583, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 669, 0, 3, 526, + 587, 257, 265, 337, 338, 340, 341, 322, 0, 0, + 352, 321, 351, 346, 343, 342, 345, 323, 0, 324, + 344, 354, 339, 669, 4, 259, 260, 261, 0, 312, + 0, 256, 334, 335, 336, 1, 21, 669, 669, 22, + 669, 669, 669, 0, 34, 669, 0, 0, 0, 669, + 0, 0, 0, 0, 669, 669, 0, 669, 669, 669, + 0, 669, 669, 6, 0, 16, 7, 19, 0, 14, + 55, 15, 17, 18, 36, 669, 0, 669, 669, 669, + 669, 0, 669, 0, 669, 669, 669, 278, 283, 0, + 0, 547, 0, 0, 277, 0, 669, 669, 0, 0, + 0, 669, 669, 556, 554, 553, 555, 552, 257, 337, + 338, 340, 341, 352, 351, 346, 343, 342, 345, 344, + 339, 0, 0, 487, 658, 659, 660, 661, 652, 651, + 0, 649, 654, 648, 551, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 591, 592, 593, 0, 314, 311, - 301, 307, 301, 306, 309, 587, 588, 222, 308, 0, - 593, 593, 593, 593, 593, 593, 248, 211, 593, 0, - 269, 250, 226, 593, 46, 45, 47, 593, 36, 41, - 22, 593, 0, 39, 0, 0, 0, 44, 593, 0, - 25, 24, 23, 42, 38, 0, 0, 131, 0, 0, - 19, 0, 290, 40, 43, 247, 231, 240, 0, 0, - 0, 0, 11, 0, 0, 246, 51, 233, 234, 235, - 271, 0, 230, 0, 441, 440, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 243, 593, 245, 244, - 0, 0, 0, 0, 0, 0, 0, 0, 528, 512, - 513, 514, 515, 516, 517, 520, 521, 527, 0, 509, - 510, 511, 518, 519, 507, 508, 504, 505, 506, 526, - 525, 0, 0, 249, 0, 313, 593, 216, 212, 213, - 215, 214, 0, 593, 277, 0, 274, 273, 270, 272, - 0, 593, 593, 37, 34, 593, 0, 0, 0, 0, - 593, 284, 0, 593, 0, 0, 246, 59, 291, 68, - 70, 247, 231, 53, 0, 0, 593, 232, 593, 0, - 316, 170, 0, 0, 50, 49, 0, 238, 236, 482, - 496, 488, 484, 486, 487, 494, 0, 493, 483, 490, - 0, 489, 492, 495, 0, 491, 485, 479, 443, 0, - 524, 523, 228, 217, 0, 0, 439, 438, 278, 267, - 227, 593, 0, 0, 255, 254, 593, 286, 0, 0, - 0, 288, 593, 0, 32, 143, 144, 0, 0, 0, - 0, 133, 134, 593, 142, 132, 61, 63, 0, 593, - 0, 0, 593, 0, 0, 593, 190, 191, 0, 593, - 593, 593, 593, 593, 0, 189, 593, 72, 0, 593, - 0, 8, 0, 0, 0, 593, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 52, 593, 145, 0, 0, - 498, 0, 522, 593, 218, 275, 0, 251, 0, 0, - 0, 0, 256, 593, 0, 289, 593, 0, 0, 0, - 593, 0, 136, 593, 138, 593, 0, 200, 201, 0, - 593, 593, 593, 593, 593, 593, 593, 199, 0, 60, - 593, 579, 575, 578, 581, 582, 160, 0, 0, 0, - 577, 0, 583, 0, 0, 0, 576, 0, 0, 0, - 0, 0, 0, 161, 164, 593, 188, 538, 580, 159, - 0, 0, 0, 54, 593, 239, 0, 593, 196, 192, - 193, 195, 194, 78, 593, 12, 593, 171, 317, 318, - 316, 0, 593, 174, 175, 593, 0, 178, 180, 177, - 173, 0, 152, 148, 0, 98, 99, 100, 101, 102, - 103, 106, 107, 122, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 121, 126, 125, 109, 108, - 95, 97, 96, 104, 105, 93, 94, 90, 91, 92, - 89, 0, 0, 88, 146, 149, 151, 150, 0, 0, - 0, 157, 593, 0, 55, 168, 237, 0, 0, 0, - 279, 0, 0, 0, 260, 584, 0, 259, 0, 258, - 0, 0, 0, 593, 257, 593, 0, 0, 0, 0, - 285, 31, 0, 593, 0, 127, 130, 128, 135, 593, - 206, 202, 203, 205, 204, 0, 0, 593, 140, 166, - 62, 593, 0, 64, 0, 0, 593, 0, 544, 187, - 0, 0, 549, 548, 547, 0, 0, 546, 593, 163, - 0, 593, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 667, 668, + 669, 0, 353, 343, 348, 347, 350, 258, 349, 0, + 669, 669, 669, 669, 669, 669, 0, 286, 244, 669, + 662, 663, 664, 0, 310, 658, 659, 661, 288, 262, + 290, 669, 47, 46, 48, 669, 37, 42, 23, 669, + 0, 40, 0, 0, 0, 45, 669, 0, 26, 25, + 24, 43, 39, 0, 0, 142, 0, 49, 0, 20, + 0, 0, 41, 44, 0, 285, 267, 276, 0, 0, + 0, 0, 12, 0, 0, 0, 284, 59, 269, 270, + 271, 312, 0, 266, 0, 486, 485, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 279, + 669, 281, 280, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 581, 653, 669, 669, 565, 566, + 567, 568, 569, 570, 573, 574, 580, 0, 562, 563, + 564, 571, 572, 560, 561, 557, 558, 559, 579, 578, + 0, 0, 287, 0, 669, 0, 669, 669, 669, 669, + 669, 249, 236, 0, 245, 0, 246, 248, 247, 175, + 669, 0, 0, 669, 669, 0, 176, 179, 669, 174, + 669, 318, 0, 315, 314, 311, 313, 0, 669, 669, + 38, 35, 669, 0, 0, 0, 0, 669, 325, 0, + 669, 285, 267, 0, 0, 284, 67, 0, 331, 0, + 0, 51, 53, 76, 78, 285, 267, 61, 0, 0, + 669, 268, 669, 0, 355, 192, 0, 0, 57, 355, + 197, 0, 58, 56, 0, 274, 310, 272, 532, 546, + 538, 534, 536, 537, 0, 544, 0, 543, 533, 540, + 0, 0, 0, 539, 542, 545, 0, 549, 550, 541, + 535, 527, 488, 92, 669, 669, 91, 650, 0, 577, + 576, 264, 250, 669, 241, 237, 238, 240, 239, 669, + 0, 0, 669, 213, 0, 0, 669, 178, 0, 0, + 669, 669, 669, 669, 669, 669, 669, 226, 225, 0, + 484, 483, 319, 308, 263, 669, 293, 669, 292, 669, + 327, 0, 0, 0, 329, 669, 0, 0, 154, 155, + 0, 0, 0, 0, 144, 145, 669, 153, 143, 0, + 69, 71, 0, 333, 0, 0, 0, 669, 669, 0, + 0, 669, 0, 0, 669, 0, 669, 669, 669, 669, + 669, 0, 217, 216, 669, 80, 0, 669, 0, 8, + 0, 0, 0, 0, 0, 0, 669, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 60, 669, 669, 156, + 0, 0, 0, 282, 548, 0, 0, 0, 0, 94, + 96, 93, 95, 0, 0, 171, 575, 242, 0, 0, + 669, 669, 0, 0, 669, 177, 180, 669, 231, 227, + 228, 230, 229, 0, 0, 669, 210, 190, 251, 316, + 0, 289, 0, 0, 295, 294, 330, 669, 0, 0, + 0, 669, 0, 33, 147, 669, 149, 669, 0, 669, + 0, 68, 669, 332, 669, 52, 641, 637, 640, 643, + 644, 182, 0, 0, 0, 639, 645, 0, 647, 646, + 0, 0, 0, 638, 0, 0, 0, 0, 0, 0, + 0, 0, 183, 214, 186, 215, 595, 642, 181, 0, + 0, 0, 0, 62, 669, 275, 0, 669, 222, 218, + 219, 221, 220, 86, 669, 13, 669, 193, 356, 357, + 355, 0, 669, 669, 195, 196, 198, 200, 201, 669, + 0, 204, 206, 203, 199, 0, 163, 159, 0, 109, + 110, 111, 112, 113, 114, 117, 118, 133, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, + 137, 136, 120, 119, 106, 108, 107, 115, 116, 104, + 105, 101, 102, 103, 100, 0, 0, 99, 157, 160, + 162, 161, 0, 0, 167, 669, 169, 0, 0, 63, + 273, 0, 0, 0, 0, 669, 0, 669, 0, 355, + 243, 669, 669, 211, 669, 669, 252, 232, 235, 191, + 0, 320, 0, 0, 0, 0, 0, 296, 0, 298, + 655, 669, 0, 669, 0, 0, 0, 0, 326, 0, + 0, 669, 0, 138, 141, 139, 146, 0, 151, 188, + 70, 669, 0, 72, 50, 0, 0, 0, 603, 0, + 0, 0, 0, 611, 610, 609, 608, 0, 0, 607, + 54, 185, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 593, 0, - 57, 80, 197, 593, 0, 0, 320, 321, 325, 322, - 329, 323, 324, 326, 327, 328, 330, 331, 332, 333, - 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, - 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, - 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, - 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, - 374, 392, 375, 376, 377, 378, 379, 380, 381, 382, - 383, 384, 385, 386, 387, 388, 389, 390, 391, 393, - 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, - 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, - 414, 593, 431, 432, 433, 424, 436, 420, 421, 419, - 426, 427, 415, 416, 417, 418, 425, 423, 430, 428, - 434, 429, 422, 435, 319, 0, 9, 0, 0, 176, - 179, 153, 147, 124, 123, 156, 155, 169, 593, 0, - 0, 481, 480, 593, 276, 586, 266, 585, 265, 264, - 263, 262, 261, 253, 287, 0, 26, 0, 0, 137, - 141, 139, 207, 210, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 167, 444, 0, 0, 66, 0, - 0, 593, 593, 0, 593, 0, 0, 0, 574, 84, - 69, 83, 162, 165, 0, 184, 558, 559, 560, 561, - 562, 563, 566, 567, 573, 0, 555, 556, 557, 564, - 565, 553, 554, 550, 551, 552, 572, 571, 0, 0, - 0, 74, 71, 0, 593, 0, 198, 593, 0, 172, - 10, 181, 593, 182, 0, 154, 56, 219, 0, 0, - 0, 0, 593, 0, 0, 0, 0, 454, 452, 453, - 451, 0, 0, 450, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 669, 0, 0, 669, + 0, 65, 88, 223, 669, 0, 0, 359, 360, 364, + 361, 368, 362, 363, 365, 366, 367, 369, 370, 371, + 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, + 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, + 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, + 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, + 412, 413, 414, 434, 415, 416, 417, 418, 419, 420, + 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, + 431, 432, 433, 435, 436, 437, 438, 439, 440, 441, + 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, + 452, 453, 454, 455, 456, 457, 458, 459, 669, 476, + 477, 478, 469, 481, 465, 466, 464, 471, 472, 460, + 461, 462, 463, 470, 468, 475, 473, 479, 474, 480, + 467, 358, 0, 9, 0, 0, 0, 202, 205, 164, + 158, 135, 134, 166, 170, 669, 0, 191, 0, 530, + 529, 531, 528, 669, 669, 172, 97, 0, 0, 0, + 212, 0, 0, 669, 233, 317, 0, 301, 0, 300, + 0, 299, 657, 0, 0, 0, 656, 669, 297, 328, + 0, 27, 0, 0, 32, 148, 152, 150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 208, 0, 65, 543, 593, - 185, 0, 0, 542, 0, 539, 85, 0, 169, 0, - 570, 569, 76, 593, 58, 0, 593, 73, 437, 0, - 593, 27, 0, 28, 30, 0, 0, 0, 0, 0, - 0, 477, 463, 464, 465, 466, 467, 468, 469, 470, - 476, 0, 460, 461, 462, 458, 459, 455, 456, 457, - 475, 474, 0, 0, 67, 186, 0, 545, 0, 0, - 568, 593, 0, 593, 79, 183, 158, 0, 593, 449, - 0, 448, 0, 445, 0, 473, 472, 0, 0, 86, - 0, 0, 593, 81, 0, 209, 0, 0, 471, 541, - 540, 87, 593, 75, 0, 0, 0, 77, 29, 447, - 446 + 0, 189, 489, 0, 74, 0, 0, 0, 0, 669, + 0, 0, 0, 0, 0, 0, 636, 184, 187, 620, + 621, 622, 623, 624, 625, 628, 629, 635, 0, 617, + 618, 619, 626, 627, 615, 616, 612, 613, 614, 634, + 633, 0, 0, 77, 0, 82, 79, 0, 669, 0, + 224, 669, 0, 194, 11, 10, 207, 669, 208, 0, + 165, 64, 0, 173, 98, 593, 669, 669, 669, 0, + 307, 306, 305, 304, 303, 302, 291, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 502, 500, 499, + 501, 498, 0, 0, 497, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 73, 602, 0, + 0, 0, 0, 601, 0, 605, 606, 596, 0, 632, + 631, 84, 669, 66, 0, 669, 81, 482, 0, 669, + 355, 669, 669, 669, 669, 28, 0, 29, 31, 0, + 0, 0, 0, 0, 0, 0, 525, 511, 512, 513, + 514, 515, 516, 517, 518, 524, 0, 508, 509, 510, + 506, 507, 503, 504, 505, 523, 522, 0, 0, 75, + 0, 0, 604, 0, 0, 630, 669, 0, 669, 87, + 209, 168, 0, 255, 254, 253, 234, 0, 496, 0, + 0, 0, 495, 0, 490, 0, 521, 520, 0, 0, + 0, 0, 0, 669, 89, 594, 0, 0, 0, 0, + 0, 519, 599, 598, 600, 597, 669, 669, 0, 0, + 0, 0, 0, 669, 83, 30, 493, 492, 494, 491, + 85 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 4, 5, 450, 451, 107, 358, 108, 109, 221, - 110, 111, 112, 366, 433, 465, 543, 240, 428, 508, - 509, 670, 254, 429, 432, 556, 1013, 1061, 723, 944, - 910, 614, 656, 113, 238, 420, 421, 422, 423, 466, - 858, 532, 533, 668, 623, 364, 566, 567, 534, 444, - 506, 206, 67, 346, 130, 256, 68, 69, 331, 70, - 332, 403, 404, 482, 71, 72, 328, 324, 325, 73, - 74, 114, 412, 486, 115, 75, 76, 77, 78, 448, - 449, 558, 844, 395, 263, 264, 894, 159, 42, 536, - 537, 634, 467, 43, 116 + -1, 4, 5, 558, 559, 115, 422, 116, 117, 249, + 118, 410, 411, 119, 120, 434, 542, 576, 683, 269, + 532, 640, 641, 820, 284, 538, 541, 285, 696, 1202, + 1256, 874, 1118, 465, 758, 814, 121, 266, 523, 524, + 525, 526, 577, 1015, 578, 594, 375, 376, 671, 672, + 818, 616, 428, 432, 710, 711, 377, 674, 551, 496, + 226, 227, 73, 405, 141, 287, 74, 75, 388, 76, + 389, 507, 623, 624, 797, 77, 78, 385, 381, 382, + 79, 80, 122, 515, 627, 123, 81, 82, 83, 84, + 556, 557, 698, 1001, 499, 294, 295, 1071, 173, 49, + 675, 676, 180, 181, 799, 800, 579, 50, 124 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -656 +#define YYPACT_NINF -755 static const yytype_int16 yypact[] = { - 351, -656, 2508, 3720, 19, 2632, -656, -656, -656, -656, - -656, -656, -656, -656, -135, -103, -99, -85, -60, -28, - -13, -27, -656, 11, 45, 74, 3926, -656, 83, 88, - 98, 16, -656, 105, 111, 2508, 2508, 2508, 2508, 1680, - 2508, 3135, -656, 109, -656, -656, -656, -656, -656, -656, - -656, 3906, 121, -656, -656, -656, -656, 4521, -656, 3527, - 3527, -656, 306, -656, 3527, -656, -656, 293, -656, -656, - -656, -656, 42, 20, 24, -656, -656, -656, -656, -656, - -656, 4578, 4578, -656, 4578, 2516, 4578, 43, -656, 4528, - 123, 135, 137, 4578, 64, 140, 154, 156, 4578, 4578, - 143, 4421, 4578, 47, 4578, 4578, -656, -656, -656, -656, - 2725, -656, -656, -656, -656, -656, -656, 2508, 3720, 2508, - 2508, 2508, 2508, 2508, 3720, 2508, 2508, 2508, -656, 306, - 150, 306, 306, -656, 2508, 2508, 3720, 3720, 2508, 2508, - 184, 184, 184, 184, -135, -99, -85, -60, -28, -13, - 11, 45, 4414, 1891, 3324, 3709, 111, 164, -76, 3135, - 184, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, - 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, - 2508, 2508, 2003, 2508, -656, -656, 293, 2508, -656, -656, - 3771, -656, 3527, -656, -656, -656, -656, -656, -656, 175, - 293, 293, 293, 293, 293, 293, 173, -656, -656, 3833, - 222, -656, 34, 4578, -656, -656, -656, 4578, -656, -656, - -656, 4471, 78, -656, 379, 381, 389, -656, -656, 296, - -656, -656, -656, -656, -656, 2508, 2795, -656, 269, 2857, - -656, 306, -656, -656, -656, 261, 279, -656, 3589, 289, - 3782, 306, -656, 306, 329, 310, -656, -656, -656, -656, - 20, 24, -656, 294, 307, -656, 315, 317, 324, 325, - 331, 340, 352, 345, 349, 355, -656, 2508, -656, -656, - 359, 360, 368, 361, 369, 370, 2508, 2508, -656, 3219, - 864, 3481, 3481, 738, 738, 532, 532, -656, 2977, 3340, - 3378, 3393, 738, 738, 215, 215, 184, 184, 184, -656, - -656, -73, 1037, 173, 2922, -656, 293, 173, 173, 173, - 173, 173, 186, 2508, 306, 371, -656, -656, -656, -656, - 3833, -656, 391, -656, -656, -656, 395, 401, 402, 404, - 3974, -656, 947, 3609, 3589, 329, -656, -656, -656, -656, - 9, -656, -656, -656, 2508, 3906, 182, -656, -656, 388, - -656, -656, 306, 1902, -656, -656, 244, 100, 34, -656, - -656, -656, -656, -656, -656, -656, 392, -656, -656, -656, - 387, -656, -656, -656, 393, -656, -656, 184, 3135, 2508, - -656, -656, -656, 173, 394, 390, 3135, -656, 192, -656, - 409, 4039, 277, 414, 416, -656, 4104, -656, 526, 527, - 528, -656, -656, 124, -656, -656, -656, 306, 3671, 306, - 413, 423, -656, 348, -656, -656, -656, -656, 244, 1133, - 417, 244, 1133, 244, 2956, 182, -656, -656, 418, 182, - 182, 182, 182, 182, 217, -656, 4169, -656, 405, -656, - 288, -656, 411, 425, 430, 2104, 2995, 420, 244, 244, - 2634, 244, 244, 244, 244, -656, 512, -656, 3833, 2508, - -656, 2508, 3135, 1133, -656, -656, 2508, -656, 595, 743, - 792, 386, -656, -656, 277, -656, -656, -71, 435, 439, - 4234, 53, 437, 348, 438, 4556, 3609, -656, -656, 434, - 348, 348, 348, 348, 348, 348, -114, -656, 244, -656, - 512, -656, -656, -656, -656, -656, -656, 436, 3844, 442, - -656, 3926, -656, 1791, 440, 443, -656, 2508, 2508, 2508, - 1680, 2508, 441, 26, -656, 348, 3169, -656, 109, -656, - 244, 191, 465, -656, 512, -656, 226, 182, 415, 415, - 415, 415, 415, -656, 2508, -656, 1133, -656, 1541, -656, - -656, 306, 2508, -656, -656, 2104, 432, 454, 3135, -656, - -656, 244, 284, 284, 567, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, 469, 468, -656, -656, 284, 284, 284, 248, 103, - 1902, -656, 2508, 459, -656, -656, 409, 76, 90, 472, - 3046, 306, 433, 306, -656, -656, 433, -656, 433, -656, - 433, 433, 433, 4299, -656, 4364, 570, 461, 601, 602, - -656, -656, 3720, -114, 3720, -656, -656, -656, -656, 348, - 476, 476, 476, 476, 476, 308, 675, 2508, -656, -656, - -656, 512, 497, -656, 3720, 3906, 348, 3720, 481, -656, - 3720, 3720, 184, 184, 184, 485, 93, 184, 563, -656, - 1244, -58, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, - 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, 2508, - 2508, 2508, 2508, 2205, 2508, 280, 620, 495, 563, 516, - -656, -656, 415, 1133, 496, 498, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, 500, -656, 503, 505, -656, - 2306, 284, -656, -656, -656, -656, -656, 2995, 1133, 501, - 244, -656, -656, 563, -656, -656, -656, -656, -656, -656, - -656, -656, -656, -656, -656, 507, -656, 107, 513, -656, - -656, -656, 476, 518, 519, 530, 523, 533, 675, 675, - 675, 675, 1680, 675, 3203, -656, 531, 552, -656, 244, - 538, 348, -58, 554, 2508, 550, 561, 2508, -656, -656, - 7, -656, -656, -656, 2508, -656, 3219, 864, 3481, 3481, - 738, 738, 532, 532, -656, 3012, 3340, 3378, 3393, 738, - 738, 215, 215, 184, 184, 184, -656, -656, 113, 1262, - 555, -656, 7, 244, 1133, 556, -656, 563, 1402, -656, - -656, -656, 2104, 3135, 558, -656, -656, 7, 572, 683, - 577, 578, 1133, 3720, 3720, 3720, 3720, 204, 204, 204, - 204, 562, 125, 204, 675, 675, 675, 675, 675, 675, - 675, 675, 675, 675, 675, 675, 675, 675, 675, 675, - 675, 675, 675, 2407, 2508, -656, 244, -656, -656, -58, - -656, 568, 565, -656, 573, 184, -656, 575, 3135, 2508, - -656, -656, -656, 1133, -656, 585, 563, 7, -656, 560, - 563, -656, 587, -656, -656, 586, 588, 597, 589, 600, - 675, -656, 3257, 1915, 3542, 3542, 1995, 1995, 583, 583, - -656, 3186, 3408, 3423, 3461, 241, 241, 204, 204, 204, - -656, -656, 131, 1698, -656, -656, 2508, -656, 2508, 28, - 3135, 1133, 591, 563, 7, -656, 7, 720, 563, -656, - 596, -656, 598, 204, 675, -656, -656, 146, 155, -656, - 593, 604, 563, 7, 608, 7, 2508, 2508, 3203, -656, - -656, -656, 563, 7, 613, 163, 169, 7, -656, -656, - -656 + 365, -755, 2777, 4408, 50, 2969, -755, -755, -755, -755, + -755, -755, -755, -755, -61, -39, 6, 23, 53, 63, + -34, 93, 10, -755, -755, 98, 102, 104, 4607, -755, + -755, 78, 114, 134, 141, 135, -755, 166, 182, 192, + 2777, 2777, 2777, 2777, 2777, 1416, 84, 2777, 3633, -755, + 117, -755, -755, -755, -755, -755, -755, -755, 4629, 195, + -755, -755, -755, -755, 2652, 2740, 2740, -755, 382, -755, + 2740, -755, -755, 185, -755, -755, -755, -755, 262, 126, + 69, -755, -755, -755, -755, -755, -755, 5156, 5156, -755, + 5156, 359, 5156, 247, -755, 5112, 218, 248, 258, 5156, + 290, 275, 279, 288, 5156, 5156, 299, 5126, 5156, 5156, + 360, 5156, 5156, -755, 302, -755, -755, -755, 3179, -755, + -755, -755, -755, -755, -755, 2777, 4408, 2777, 2777, 2777, + 2777, 4408, 2777, 4408, 2777, 2777, 2777, -755, -755, 311, + 382, 314, 382, 382, -755, 4408, 2777, 2777, 4408, 4408, + 1416, 2777, 2777, 90, 90, 90, 90, 90, -61, 6, + 23, 53, 63, 93, 98, 102, 2119, 2292, 2455, 2540, + 192, 330, -60, 3633, -755, -755, -755, -755, -755, 382, + 333, 373, -755, -755, 90, 2777, 2777, 2777, 2777, 2777, + 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, + 2777, 2777, 2777, 2777, 2777, 2777, 2217, 2777, -755, -755, + 185, 2777, -755, 2740, -755, -755, -755, -755, -755, 347, + 31, 185, 185, 31, 31, 3948, 356, -755, 366, -755, + -755, -755, -755, 1119, 388, 17, 45, 154, -755, -755, + -755, 5156, -755, -755, -755, 5156, -755, -755, -755, 5059, + 294, -755, 382, 382, 382, -755, -755, 399, -755, -755, + -755, -755, -755, 2777, 3083, -755, 397, -755, 3251, -755, + 382, 115, -755, -755, 382, 226, 384, -755, 4175, 396, + 4475, 382, -755, 382, 393, 238, 398, -755, -755, -755, + -755, 219, 69, -755, 395, 416, -755, 400, 406, 407, + 409, 417, 429, 428, 440, 431, 438, 439, 2777, -755, + 2777, -755, -755, 454, 448, 449, 451, 462, 458, 3356, + 460, 461, 2777, 2777, -755, -755, 64, 84, 3815, 3835, + 946, 946, 486, 486, 206, 206, -755, 3449, 3851, 3899, + 4036, 486, 486, 121, 121, 90, 90, 90, -755, -755, + -47, 1299, -755, 3377, 31, 473, 31, 31, 31, 31, + 31, 468, -755, 356, -755, 356, -755, 468, 468, -755, + 31, 4530, 4386, 31, 31, 469, 27, -755, 1148, -755, + 2777, 382, 467, -755, -755, -755, -755, 1119, -755, 543, + -755, -755, -755, 495, 492, 505, 506, 4681, -755, 1318, + 2876, 403, 478, 4175, 238, -755, -755, 507, -755, 4408, + 489, 511, 498, -755, 34, -755, -755, -755, 2777, 4629, + 500, -755, -755, 502, -755, -755, 382, 15, -755, -755, + -755, 2105, -755, -755, 786, -755, 527, -755, -755, -755, + -755, -755, -755, -755, 514, -755, 515, -755, -755, -755, + 3395, 517, 520, -755, -755, -755, 522, -755, -755, -755, + -755, 90, 3633, -755, 4247, 672, -755, -755, 2777, -755, + -755, -755, 468, 31, 468, 468, 468, 468, 468, 2777, + -4, 4629, 1148, -755, 12, 108, 608, -755, 4319, 529, + 1148, 1148, 1148, 1148, 1148, 1148, -45, -755, -755, 521, + 3633, -755, -12, -755, 544, 4735, -755, 546, -755, 4789, + -755, 665, 667, 669, -755, -755, 315, 556, -755, -755, + 382, 2204, 382, 550, 560, -755, 1148, -755, -755, 34, + -755, -755, 786, -755, 561, 542, 382, 1533, 4247, 552, + 786, 4247, 786, 3413, 500, 553, 500, 500, 500, 500, + 500, 293, -755, -755, 4843, -755, 547, -755, 334, -755, + -68, 568, 570, 562, 579, 583, 2329, 3578, 573, 786, + 786, 3082, 786, 786, 786, 786, -755, 186, 436, -755, + 1119, 2777, 2777, -755, -755, 2777, 2777, 588, 4552, -755, + -755, -755, -755, 592, 612, -755, 3633, 468, 593, 596, + 1148, -45, 599, 600, 672, -755, -755, 1148, 603, 603, + 603, 603, 603, 306, 2777, 2777, -755, -755, 604, -755, + 2777, -755, 2386, 624, 629, -755, -755, -755, -43, 630, + 633, 4897, 36, -755, 621, 1148, 631, 4286, 2876, -13, + 786, -755, 436, -755, 5156, -755, -755, -755, -755, -755, + -755, -755, 619, 632, 635, -755, -755, 4607, -755, -755, + 637, 646, 638, -755, 648, 2777, 2777, 2777, 2777, 1416, + 2777, 622, 57, -755, -755, 3651, -755, 117, -755, 628, + 786, 361, 647, -755, 436, -755, 324, 500, 649, 649, + 649, 649, 649, -755, 2777, -755, 4247, -755, 1843, -755, + -755, 382, 2777, 2777, -755, -755, -755, -755, -755, 2329, + 654, 650, 3633, -755, -755, 786, 328, 328, 763, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, 659, 658, -755, -755, 328, + 328, 328, 391, 801, -755, 2777, -755, 2105, 681, -755, + 544, 39, 66, 123, 149, 608, 4607, 185, 41, -755, + -755, 4247, -45, -755, 4247, 4247, -755, 603, 666, 3633, + 668, 3597, 587, 783, 897, 382, 493, -755, 382, -755, + -755, -755, 2386, 4951, 808, 695, 812, 814, -755, 699, + 4408, -13, 4408, -755, -755, -755, -755, 2889, -755, -755, + -755, 436, 701, -755, -755, 4408, 4408, 4408, 687, 4408, + 4408, 4408, 1416, 90, 90, 90, 90, 686, 152, 90, + -755, -755, 1988, 2777, 2777, 2777, 2777, 2777, 2777, 2777, + 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, 2777, + 2777, 2777, 2777, 2777, 2441, 2777, 608, 465, 689, 608, + 707, -755, -755, 649, 4247, 690, 691, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, -755, -755, -755, -755, -755, -755, -755, -755, + -755, -755, 696, -755, 697, 702, 700, -755, 2553, 328, + -755, -755, -755, -755, -755, 1533, 704, 3578, 786, -755, + -755, -755, -755, 672, 185, -755, -755, 703, 716, 708, + -755, 718, 719, 4247, -755, -755, 1030, -755, 1030, -755, + 1030, -755, -755, 1030, 1030, 1030, -755, 5005, -755, -755, + 720, -755, 163, 722, -755, -755, -755, -755, 727, 737, + 742, 745, 743, 753, 2889, 2889, 2889, 2889, 2889, 1416, + 2889, 3798, -755, 765, -755, 786, 744, 757, 758, 2777, + 759, 750, 764, 756, 3431, 2777, -755, -755, -755, 3815, + 3835, 946, 946, 486, 486, 206, 206, -755, 3615, 3851, + 3899, 4036, 486, 486, 121, 121, 90, 90, 90, -755, + -755, 236, 1553, 325, 760, -755, 325, 786, 4247, 761, + -755, 608, 1698, -755, -755, -755, -755, 2329, 3633, 767, + -755, -755, 779, -755, -755, -755, 608, 608, 608, 768, + -755, -755, -755, -755, -755, -755, -755, 787, 899, 788, + 790, 4408, 4408, 4408, 4408, 4408, 4408, 241, 241, 241, + 241, 241, 773, 250, 241, 2889, 2889, 2889, 2889, 2889, + 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, + 2889, 2889, 2889, 2889, 2665, 2777, 786, -755, -755, 777, + 778, 780, 784, -755, 785, -755, -755, 90, 2777, -755, + -755, -755, 4247, -755, 781, 608, 325, -755, 789, 608, + -755, 672, 672, 672, 608, -755, 797, -755, -755, 796, + 798, 807, 809, 806, 818, 2889, -755, 1224, 3882, 3244, + 3244, 2868, 2868, 510, 510, -755, 3669, 4052, 4069, 4078, + 674, 674, 241, 241, 241, -755, -755, 251, 2008, -755, + 2777, 2777, -755, 2777, 2777, 3633, 4247, 810, 608, 325, + -755, 325, 811, -755, -755, -755, 325, 919, -755, 800, + 816, 817, -755, 820, 241, 2889, -755, -755, 278, 282, + 286, 287, 825, 608, 325, -755, 827, 2777, 2777, 2777, + 2777, 3798, -755, -755, -755, -755, 608, 672, 804, 295, + 317, 318, 332, 672, -755, -755, -755, -755, -755, -755, + -755 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -656, -656, -196, -656, 174, -656, -656, 515, -656, -656, - 72, -97, -656, -656, -656, -113, -195, -656, -656, -656, - -149, -247, 522, -656, -656, -656, -656, -656, -656, -656, - -655, -656, -656, 256, -656, -656, -656, 259, 334, -381, - -656, -388, -656, 110, -508, -338, -559, -656, -501, -144, - -406, -132, -37, -92, 243, -147, -34, -61, -656, -19, - -656, -656, -656, 281, 0, -656, -289, -656, -656, 1, - 278, -656, -656, -656, -656, -6, -4, -656, -656, 206, - -656, -54, -656, -442, -110, -36, 118, 421, -150, -656, - -656, -374, 149, -387, -1 + -755, -755, -230, -755, 259, -755, -755, 723, -755, -755, + 207, 437, -755, -105, -755, -755, -755, -42, -142, -755, + -755, -755, -96, -206, -755, -755, -755, 713, -755, -755, + -755, -755, -755, -386, -755, -755, 345, -755, -755, -755, + 346, 464, -465, -755, -523, -541, -449, -755, -32, -755, + 175, -546, -755, -397, -693, -755, -341, 145, -480, -433, + 795, -197, -41, -98, -551, -166, 28, -70, -755, -65, + -755, -755, -755, -755, 188, -64, -755, -354, -755, -755, + 2, -7, -755, -755, -755, -755, 1, 21, -755, -755, + -428, -755, 13, -755, -445, -124, -27, 233, 526, -119, + -755, -755, 670, -755, -754, 821, 389, -502, -1 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -270 +#define YYTABLE_NINF -665 static const yytype_int16 yytable[] = { - 6, 117, 672, 158, 237, 157, 848, 427, 666, 267, - 268, 269, 270, 271, 186, 273, 274, 275, 255, 79, - 133, 430, 679, 667, 280, 281, 491, 131, 284, 285, - 195, 196, 340, 118, 195, 196, 719, 119, 195, 196, - 689, 400, 538, 287, 542, 538, 287, 510, 646, 257, - 541, 120, 544, 191, 313, 193, 194, 195, 196, 184, - 198, 185, 288, 942, 914, 390, 207, 647, 317, 318, - 319, 320, 321, 322, 195, 196, 121, 572, 573, 667, - 615, 616, 617, 618, 266, 629, 538, 653, 195, 196, - 272, 258, 347, 1006, 660, 661, 662, 663, 664, 665, - 124, 353, 282, 283, 262, 637, 639, 856, 122, 1007, - 259, 260, 724, 195, 196, 184, 265, 185, 265, 265, - 265, 265, 265, 123, 265, 265, 265, 671, 624, 691, - 10, 241, 11, 265, 265, 401, 538, 265, 265, 406, - 431, 209, 211, 137, 255, 690, 311, 125, 191, 193, - 194, 198, -252, 214, 215, -252, 216, 218, 219, 715, - 208, 223, 446, 897, 220, 227, 1079, 380, 725, 538, - 233, 234, 673, 236, 239, 257, 243, 244, 257, 626, - 859, 126, 228, 915, 393, 207, 191, 257, 191, 913, - 851, 651, 436, 437, 438, 287, 335, 426, 439, 207, - 207, 207, 207, 207, 207, 329, 720, 326, 957, 287, - 127, 197, 287, 356, 861, 169, 490, 258, -269, 134, - 258, 468, 210, 212, 135, 896, 959, 6, 862, 258, - 262, 908, 287, 262, 136, 982, 259, 260, 440, 259, - 260, 138, 262, 229, 287, 960, 169, 139, 259, 260, - 287, 1010, 242, 882, 195, 196, 457, 187, 866, 224, - 458, 230, 868, 1031, 869, 287, 870, 871, 872, 1075, - 902, 225, 982, 226, 287, 231, 265, 232, 276, 235, - 278, 279, 287, 257, 1089, 223, 277, 643, 287, 333, - 645, 546, 1017, 1090, 441, 548, 549, 550, 551, 552, - 459, 1099, 286, 538, 132, 199, 316, 1100, 442, 200, - 323, 475, 716, 443, 476, 207, 195, 196, 435, 181, - 182, 183, 397, 323, 394, 258, 329, 621, 622, 717, - 6, 405, 460, 898, 6, 945, 538, 424, 262, 992, - 993, 994, 425, 330, 259, 260, 178, 179, 180, 201, - 181, 182, 183, 553, 554, 445, 461, 6, 497, 498, - 499, 1064, 721, 554, 500, 1066, 478, 479, 480, 716, - 462, 336, 989, 990, 991, 463, 992, 993, 994, -82, - 464, -82, -82, -82, 621, 622, 855, 481, 261, 337, - 348, 338, 535, 1019, 1000, 535, 343, 349, 655, 339, - 357, 716, 359, 722, 501, 202, 560, 561, 1083, 367, - 368, 6, 424, 1085, 341, 350, 621, 622, 940, 203, - 621, 622, 507, 41, 204, 354, 287, 1093, 539, 205, - 365, 539, 369, 627, 445, 628, 535, 1097, 445, 445, - 445, 445, 445, 195, 196, 667, 883, 360, 559, 361, - 362, 363, 847, 370, 569, 371, 140, 141, 142, 143, - 502, 160, 372, 373, 329, 625, 1, 2, 3, 374, - 954, 538, 539, 398, 503, 640, 641, 642, 375, 504, - 376, 676, 6, 377, 505, 6, 535, 378, 50, 384, - 424, 1055, 507, 379, 686, 999, 685, 381, 382, 507, - 507, 507, 507, 507, 507, 669, 383, 385, 386, 625, - 399, 452, 402, 407, 261, 133, 895, 261, 510, 535, - 408, 409, 131, 410, 447, 470, 261, -268, 469, 471, - 473, 474, 483, 61, 507, 484, 487, 488, 489, 631, - 63, 495, 496, 625, 557, 563, 445, 562, 540, 547, - 564, 571, 554, 397, 648, 539, 1015, 538, 649, 652, - 654, 265, 544, 169, 569, 659, 492, 236, 494, 677, - 681, 849, 674, 850, 1025, 538, 680, 852, 860, 688, - 875, 876, 289, 290, 291, 292, 293, 294, 295, 296, - 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, - 307, 308, 309, 718, 312, 195, 196, 853, 314, 854, - 863, 877, 878, 667, 982, 671, 899, 904, 879, 909, - 881, 397, 261, 907, 856, 1062, 538, 635, 635, 635, - 360, 941, 361, 619, 620, 943, 947, 946, 901, 949, - 900, 950, 955, 903, 951, 958, 905, 906, 621, 622, - 50, 961, 669, 535, 962, 963, 342, 964, 507, 965, - 966, 176, 177, 178, 179, 180, 397, 181, 182, 183, - 625, 996, 995, 1081, 538, 507, 998, 938, 7, 8, - 9, 10, 1001, 11, 12, 13, 535, 911, 1003, 1004, - 625, 1012, 1021, 1022, 1016, 61, 1020, 1023, 1024, 1065, - 1030, 631, 63, 1057, 1056, 632, 1067, 387, 388, 1058, - 452, 1059, 987, 988, 989, 990, 991, 911, 992, 993, - 994, 884, 539, 1063, 1068, 1070, 1069, 1071, 1072, 1082, - 1084, 1091, 1086, 1098, 1087, 846, 334, 885, 895, 895, - 895, 895, 1092, 895, 396, 22, 1094, 956, 1014, 1054, - 997, 657, 493, 195, 196, 658, 633, 633, 633, 167, - 168, 345, 27, 880, 678, 644, 845, 948, 452, 169, - 0, 886, 0, 0, 887, 434, 0, 0, 32, 0, - 865, 635, 867, 0, 456, 635, 0, 635, 0, 635, - 635, 635, 0, 0, 1002, 0, 0, 0, 50, 132, - 0, 888, 195, 196, 0, 889, 890, 0, 0, 891, - 472, 892, 0, 0, 0, 893, 0, 0, 0, 0, - 559, 535, 0, 0, 895, 895, 895, 895, 895, 895, - 895, 895, 895, 895, 895, 895, 895, 895, 895, 895, - 895, 895, 895, 61, 0, 0, 0, 50, 0, 631, - 63, 0, 0, 636, 0, 0, 972, 539, 971, 0, - 0, 0, 911, 0, 0, 0, 0, 176, 177, 178, - 179, 180, 0, 181, 182, 183, 568, 0, 0, 0, - 895, 163, 164, 165, 166, 167, 168, 0, 0, 0, - 0, 0, 61, 0, 0, 169, 0, 630, 631, 63, - 507, 625, 638, 265, 0, 0, 0, 535, 0, 0, - 633, 0, 0, 0, 633, 0, 633, 0, 633, 633, - 633, 0, 0, 0, 895, 535, 0, 0, 0, 1026, - 1027, 1028, 1029, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 539, 0, 0, 911, 0, 682, 683, - 684, 569, 687, 0, 0, 0, 0, 1052, 0, 0, - 0, 539, 161, 162, 163, 164, 165, 166, 167, 168, - 0, 0, 0, 0, 0, 396, 535, 0, 169, 0, - 0, 0, 0, 0, 0, 0, 568, 0, 171, 172, - 173, 174, 175, 176, 177, 178, 179, 180, 625, 181, - 182, 183, 0, 0, 0, 0, 967, 968, 969, 970, - 0, 973, 539, 0, 0, 911, 0, 0, 0, 911, - 1077, 0, 1078, 0, 535, 0, 0, 0, 0, 0, + 6, 563, 265, 298, 299, 300, 301, 531, 303, 642, + 305, 306, 307, 352, 632, 587, 1006, 210, 172, 684, + 286, 143, 314, 315, 364, 366, 397, 320, 321, 144, + 142, 483, 768, 504, 598, 677, 766, 777, 1037, 1039, + 1041, 487, 208, 355, 209, 183, 539, 356, 288, 601, + 85, 174, 175, 289, 290, 783, 702, 608, 609, 610, + 611, 612, 613, 786, 686, 323, 688, 689, 690, 691, + 692, 841, 228, 171, 703, 681, 561, 562, 323, 235, + 236, 125, 804, 614, 324, 214, 215, 216, 357, 679, + -662, 218, 682, 639, 174, 175, 822, 469, 615, 131, + 604, 805, 406, 126, 716, 717, 828, 759, 760, 761, + 762, 292, 417, 619, 176, 817, 620, 821, -663, 293, + 291, 463, 193, 208, 296, 209, 296, 296, 296, 296, + 615, 296, 177, 296, 296, 296, 230, 231, 870, 479, + 599, -662, 176, 133, -662, 296, 296, 606, 127, 358, + 296, 296, 488, 193, 297, 479, 602, 176, 505, 302, + 237, 304, 509, 359, 323, 128, 286, 782, 360, -663, + 790, 540, -663, 313, 787, 177, 316, 317, 318, 350, + 809, 769, 842, 1019, 378, 1026, 451, 214, 215, 216, + 218, 323, 554, 238, 288, 129, 673, 219, 288, 289, + 290, 220, 811, 289, 290, 130, 464, 873, 288, 228, + 1020, 145, 178, 289, 290, 867, 179, 232, 588, 362, + 228, 228, 362, 362, 379, 1024, 770, -664, 383, 235, + 236, 205, 206, 207, 214, 132, 1030, 530, 193, 420, + 134, 408, 221, 409, 135, 823, 136, 876, 323, 875, + 1009, 479, 603, 233, 386, 6, 146, 292, 202, 203, + 204, 292, 205, 206, 207, 293, 291, 1021, 149, 293, + 291, 292, 1002, 1173, 323, 1073, 147, 323, -664, 293, + 291, -664, 1140, 148, 1141, 631, 1142, 871, 1148, 1143, + 1144, 1145, 176, 1022, 242, 243, 1086, 244, 246, 247, + 174, 175, 251, 222, 174, 175, 255, 1149, 150, 296, + 237, 261, 262, 763, 264, 267, 268, 223, 272, 273, + 1016, 10, 224, 11, 151, 466, 183, 225, 764, 765, + 482, 378, 1029, 288, 152, 1031, 1032, 211, 289, 290, + 677, 200, 201, 202, 203, 204, 233, 205, 206, 207, + -90, 1028, -90, 362, -90, 362, 362, 362, 362, 362, + 252, 323, 429, 176, 430, 245, 431, 176, 413, 362, + 174, 175, 362, 362, 248, 323, 323, 498, 544, 501, + 1199, 177, 1183, 1184, 1185, 177, 229, 6, 508, 1023, + 253, 6, 174, 175, 1226, 1276, 292, 803, 589, 528, + 254, 527, 258, 323, 293, 291, 259, 323, 386, 87, + 590, 323, 323, 591, 256, 260, 592, 88, 392, 553, + 323, 6, 1292, 378, 1074, 1119, 1293, 90, 91, 92, + 1294, 1295, 593, 176, 1208, 693, 694, 534, 241, 1306, + 600, 263, 323, 323, 99, 274, 270, 378, 251, 615, + 788, 177, 390, 308, 104, 176, 310, 323, 700, 701, + 105, 1307, 1308, 379, 595, 108, 872, 694, 234, 240, + 764, 765, 362, 177, 322, 111, 1309, 112, 501, 326, + 1113, 498, 1132, 1116, 354, 466, 1, 2, 3, 498, + 498, 498, 498, 498, 498, 617, 378, 378, 327, 380, + 378, 673, 114, 764, 765, 868, 625, 191, 192, -236, + 230, 231, 545, 677, 6, 387, 546, 424, 193, 425, + 426, 427, 527, 398, 433, 498, 414, -90, 48, -90, + 400, -90, 813, 764, 765, 1013, 678, 379, 418, 438, + 379, 323, 1173, 553, 439, 553, 553, 553, 553, 553, + 440, 441, 642, 442, 771, 772, 699, 547, 773, 774, + 429, 443, 430, 444, 767, 713, 153, 154, 155, 156, + 157, 1047, 445, 184, 446, 447, 595, 617, 1004, 1005, + 1025, 143, 448, 449, 1139, 1043, 1044, 1045, 452, 144, + 142, 232, 453, 454, 684, 455, 456, 174, 175, 498, + 617, 386, 457, 595, 459, 460, 498, 764, 765, 1114, + 473, 479, 503, 486, 501, 798, 506, 511, 548, 510, + 529, 200, 201, 202, 203, 204, 6, 205, 206, 207, + 512, 513, 549, 533, 498, 535, 536, 550, 819, 527, + 537, 617, 838, 57, 555, 1178, 1179, 1180, 1181, 1182, + 143, 1183, 1184, 1185, 580, 378, 581, 582, 144, 142, + 176, 584, 585, 821, 586, 463, 607, 618, -309, 1204, + 1263, 1264, 1265, 622, 673, 628, 319, 629, 177, 630, + 436, 240, 633, 617, 637, 638, 553, 643, 644, 680, + 687, 67, 697, 501, 704, 379, 705, 837, 1072, 795, + 69, 296, 296, 1036, 588, 707, 1173, 706, 713, 708, + 715, 328, 329, 330, 331, 332, 333, 334, 335, 336, + 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, + 347, 348, 775, 351, 778, 1206, 779, 353, 781, 780, + 378, 784, 785, 378, 378, 589, 615, -243, 801, 810, + 1211, 1212, 1213, 1257, 802, 806, 1304, 590, 807, 812, + 591, 825, 1310, 592, 501, 826, 840, 497, 827, 143, + 829, 831, 866, 1010, 466, 1008, 228, 144, 142, 593, + 379, 617, 1262, 379, 379, 798, 798, 798, 830, 399, + 832, 869, 694, 174, 175, 798, 230, 231, 568, 1007, + 6, 378, 569, 1011, 1012, 1014, 1018, 1282, 1033, 552, + 819, 1180, 1181, 1182, 1034, 1183, 1184, 1185, 1050, 1259, + 617, 1051, 1052, 1261, 1053, 1054, 1075, 1133, 1266, 1079, + 1085, 1115, 1117, 378, 450, 1121, 1120, 1111, 1055, 57, + 1057, 1123, 1124, 570, 264, 1126, 1125, 1134, 461, 462, + 1130, 824, 1136, 1076, 1077, 1078, 176, 1080, 1081, 1082, + 1083, 1135, 1137, 1138, 1147, 466, 1150, 182, 466, 1151, + 1152, 497, 1284, 379, 177, 1153, 571, 232, 1154, 497, + 497, 497, 497, 497, 497, 1155, 1156, 67, 1188, 217, + 1186, 1189, 1190, 1192, 1193, 795, 69, 1297, 1194, 1038, + 1195, 239, 1201, 1210, 572, 1205, 500, 174, 175, 1216, + 1303, 1209, 1214, 1215, 1217, 497, 1218, 1225, 573, 1250, + 1251, 257, 1267, 574, 1252, 1258, 1253, 1254, 575, 1286, + 1305, 271, 1269, 552, 1260, 552, 552, 552, 552, 552, + 1268, 1270, 1287, 1271, 543, 1072, 1072, 1072, 1072, 1072, + 1272, 1072, 1273, 57, 1283, 1191, 1285, 567, 1288, 1289, + 1003, 309, 1290, 311, 312, 189, 190, 191, 192, 1296, + 176, 1298, 391, 645, 378, 1203, 1131, 699, 193, 1187, + 1249, 404, 815, 1129, 816, 635, 1056, 1088, 177, 497, + 1048, 1122, 378, 0, 596, 0, 497, 467, 0, 0, + 325, 67, 0, 0, 0, 500, 0, 0, 0, 795, + 69, 0, 0, 1040, 678, 361, 363, 365, 367, 368, + 0, 0, 595, 228, 497, 0, 0, 0, 0, 798, + 0, 798, 379, 798, 0, 0, 798, 798, 798, 0, + 174, 175, 1163, 0, 0, 0, 1072, 1072, 1072, 1072, + 1072, 1072, 1072, 1072, 1072, 1072, 1072, 1072, 1072, 1072, + 1072, 1072, 1072, 1072, 1072, 0, 0, 0, 0, 0, + 0, 393, 0, 394, 395, 396, 552, 378, 296, 198, + 199, 200, 201, 202, 203, 204, 57, 205, 206, 207, + 0, 407, 712, 0, 0, 412, 0, 1162, 0, 0, + 0, 0, 421, 176, 423, 0, 1072, 0, 0, 0, + 0, 0, 435, 437, 0, 0, 0, 379, 0, 0, + 466, 177, 0, 0, 0, 0, 713, 0, 0, 0, + 384, 0, 0, 0, 67, 466, 466, 466, 0, 0, + 789, 500, 795, 69, 0, 0, 791, 0, 182, 472, + 0, 474, 475, 476, 477, 478, 1072, 1247, 230, 231, + 489, 378, 0, 0, 490, 480, 0, 0, 484, 485, + 53, 0, 54, 55, 56, 0, 0, 0, 0, 1219, + 1220, 1221, 1222, 1223, 1224, 0, 0, 0, 0, 0, + 0, 833, 834, 835, 836, 0, 839, 0, 0, 63, + 213, 379, 502, 0, 466, 491, 0, 0, 466, 0, + 595, 595, 595, 466, 0, 378, 0, 65, 66, 0, + 500, 0, 0, 1278, 1279, 0, 1280, 1281, 0, 0, + 0, 0, 0, 70, 0, 712, 0, 0, 72, 232, + 1166, 1167, 1168, 1169, 1170, 1171, 1172, 560, 0, 0, + 0, 0, 0, 0, 0, 379, 1173, 466, 0, 0, + 1299, 1300, 1301, 1302, 0, 0, 492, 0, 597, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 857, 0, 396, 0, 0, 0, 0, 0, 0, - 1095, 1096, 161, 162, 163, 164, 165, 166, 167, 168, - 539, 0, 911, 0, 0, 0, 413, 911, 169, 0, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 911, 181, 182, 183, 414, 0, 0, 396, 0, - 0, 911, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, - 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, - 1050, 0, 0, 916, 917, 918, 919, 920, 921, 922, - 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, - 933, 934, 935, 936, 0, 939, 511, 512, 513, 10, - 0, 11, 514, 515, 44, 0, 0, 516, 1073, 0, + 493, 0, 466, 0, 0, 494, 0, 0, 0, 0, + 495, 500, 0, 1017, 0, 466, 595, 1157, 1158, 1159, + 1160, 1161, 595, 1164, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 185, 186, 187, 188, 189, 190, + 191, 192, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 193, 0, 185, 186, 187, 188, 189, 190, 191, + 192, 634, 0, 636, 0, 0, 0, 0, 0, 0, + 193, 0, 0, 0, 1175, 1176, 1177, 412, 1084, 1178, + 1179, 1180, 1181, 1182, 0, 1183, 1184, 1185, 0, 1089, + 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, + 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, + 0, 1112, 0, 0, 0, 0, 0, 0, 1227, 1228, + 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, + 1239, 1240, 1241, 1242, 1243, 1244, 1245, 0, 0, 7, + 8, 9, 10, 0, 11, 12, 13, 158, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 0, + 205, 206, 207, 516, 0, 470, 0, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 1274, 205, + 206, 207, 517, 15, 52, 0, 0, 159, 0, 160, + 161, 162, 57, 58, 0, 20, 59, 0, 0, 163, + 22, 0, 0, 61, 0, 0, 0, 0, 23, 24, + 164, 0, 0, 0, 0, 0, 165, 166, 0, 0, + 0, 0, 0, 28, 0, 29, 0, 30, 1291, 0, + 0, 0, 31, 0, 167, 168, 34, 0, 0, 35, + 67, 0, 560, 0, 36, 0, 0, 37, 68, 69, + 169, 0, 0, 71, 1128, 170, 646, 647, 648, 10, + 0, 11, 649, 650, 51, 0, 0, 651, 40, 0, + 0, 41, 42, 43, 0, 0, 44, 0, 45, 46, + 0, 0, 0, 47, 0, 0, 0, 0, 185, 186, + 187, 188, 189, 190, 191, 192, 0, 0, 0, 0, + 652, 52, 0, 0, 53, 193, 54, 55, 56, 57, + 371, 0, 653, 59, 0, 0, 60, 654, 0, 1027, + 61, 0, 0, 0, 0, 655, 656, 62, 0, 0, + 0, 1197, 0, 63, 64, 0, 1042, 0, 0, 1046, + 657, 0, 658, 0, 659, 0, 0, 0, 372, 660, + 0, 65, 66, 661, 0, 0, 662, 67, 0, 0, + 0, 663, 0, 0, 664, 68, 69, 70, 0, 0, + 71, 0, 72, 712, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 665, 0, 0, 666, 667, + 0, 0, 0, 668, 0, 669, 0, 0, 0, 0, + 670, 0, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 0, 205, 206, 207, 0, 0, 1200, + 0, 877, 878, 879, 880, 881, 882, 883, 884, 885, + 886, 1248, 887, 888, 889, 890, 891, 892, 893, 894, + 895, 896, 897, 0, 1255, 0, 0, 0, 0, 0, + 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, + 908, 909, 910, 911, 912, 913, 914, 0, 0, 915, + 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, + 926, 927, 928, 929, 0, 930, 0, 931, 932, 933, + 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, + 0, 0, 0, 944, 945, 946, 0, 947, 948, 949, + 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, + 960, 961, 962, 0, 963, 964, 965, 966, 967, 968, + 969, 970, 971, 972, 973, 974, 975, 976, 977, 0, + 0, 0, 978, 979, 980, 981, 982, 983, 984, 985, + 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, + 996, 997, 998, 1207, 999, 1000, 877, 878, 879, 880, + 881, 882, 883, 884, 885, 886, 0, 887, 888, 889, + 890, 891, 892, 893, 894, 895, 896, 897, 0, 0, + 0, 0, 0, 0, 0, 898, 899, 900, 901, 902, + 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, + 913, 914, 0, 0, 915, 916, 917, 918, 919, 920, + 921, 922, 923, 924, 925, 926, 927, 928, 929, 0, + 930, 0, 931, 932, 933, 934, 935, 936, 937, 938, + 939, 940, 941, 942, 943, 0, 0, 0, 944, 945, + 946, 0, 947, 948, 949, 950, 951, 952, 953, 954, + 955, 956, 957, 958, 959, 960, 961, 962, 0, 963, + 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, + 974, 975, 976, 977, 0, 0, 0, 978, 979, 980, + 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, + 991, 992, 993, 994, 995, 996, 997, 998, 0, 999, + 1000, 646, 647, 648, 10, 0, 11, 649, 650, 51, + 0, 0, 1087, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 0, 181, 182, 183, 0, 0, 0, 391, 517, - 45, 0, 0, 46, 0, 47, 48, 49, 50, 518, - 0, 52, 1088, 0, 53, 519, 0, 0, 54, 0, - 0, 0, 0, 520, 55, 0, 0, 0, 1080, 0, - 56, 57, 58, 0, 0, 0, 0, 0, 521, 0, - 522, 0, 0, 0, 0, 523, 0, 59, 60, 524, - 0, 0, 525, 61, 0, 0, 526, 0, 0, 62, - 63, 64, 0, 0, 65, 0, 66, 511, 512, 513, - 10, 0, 11, 514, 515, 44, 0, 0, 912, 527, - 0, 0, 0, 528, 0, 0, 0, 529, 0, 530, - 0, 953, 0, 531, 0, 0, 0, 161, 162, 163, - 164, 165, 166, 167, 168, 0, 0, 0, 0, 0, - 517, 45, 0, 169, 46, 0, 47, 48, 49, 50, - 518, 0, 52, 0, 0, 53, 519, 0, 0, 54, - 0, 0, 0, 0, 520, 55, 0, 0, 0, 0, - 0, 56, 57, 58, 0, 0, 0, 0, 1005, 521, - 0, 522, 0, 0, 0, 1008, 523, 0, 59, 60, - 524, 0, 0, 525, 61, 0, 0, 526, 0, 0, - 62, 63, 64, 0, 0, 65, 0, 66, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 527, 0, 0, 568, 528, 0, 0, 0, 529, 0, - 530, 0, 0, 0, 531, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 0, 181, 182, 183, - 0, 0, 0, 1011, 0, 726, 727, 728, 729, 730, - 731, 732, 733, 734, 735, 1053, 736, 737, 738, 739, - 740, 741, 742, 743, 744, 745, 746, 0, 0, 0, - 1060, 0, 0, 747, 748, 749, 750, 751, 752, 753, - 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, - 0, 0, 764, 765, 766, 767, 768, 769, 770, 771, - 772, 773, 774, 775, 776, 777, 0, 778, 0, 779, - 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, - 790, 0, 0, 0, 0, 791, 792, 793, 0, 794, - 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, - 805, 806, 807, 0, 808, 809, 810, 811, 812, 813, - 814, 815, 816, 817, 818, 819, 820, 0, 0, 0, - 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, - 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, - 841, 1018, 842, 843, 726, 727, 728, 729, 730, 731, - 732, 733, 734, 735, 0, 736, 737, 738, 739, 740, - 741, 742, 743, 744, 745, 746, 0, 0, 0, 0, - 0, 0, 747, 748, 749, 750, 751, 752, 753, 754, - 755, 756, 757, 758, 759, 760, 761, 762, 763, 0, - 0, 764, 765, 766, 767, 768, 769, 770, 771, 772, - 773, 774, 775, 776, 777, 0, 778, 0, 779, 780, - 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, - 0, 0, 0, 0, 791, 792, 793, 0, 794, 795, - 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, - 806, 807, 0, 808, 809, 810, 811, 812, 813, 814, - 815, 816, 817, 818, 819, 820, 0, 0, 0, 821, - 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, - 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, - 0, 842, 843, 7, 8, 9, 10, 0, 11, 12, - 13, 144, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 161, 162, 163, 164, 165, 166, 167, - 168, 0, 0, 0, 0, 0, 15, 45, 0, 169, - 145, 0, 146, 147, 148, 50, 51, 0, 52, 0, - 0, 149, 21, 0, 0, 54, 0, 0, 0, 0, - 22, 150, 0, 0, 0, 0, 0, 151, 152, 58, - 0, 0, 0, 0, 0, 26, 0, 27, 0, 0, - 0, 0, 0, 0, 153, 154, 30, 0, 0, 31, - 61, 0, 0, 32, 0, 0, 62, 63, 155, 0, - 0, 65, 0, 156, 511, 512, 513, 10, 0, 11, - 514, 515, 44, 0, 0, 0, 35, 0, 0, 0, - 36, 37, 0, 0, 38, 0, 39, 0, 0, 0, - 40, 170, 171, 172, 173, 174, 175, 176, 177, 178, - 179, 180, 0, 181, 182, 183, 0, 517, 45, 1076, - 0, 46, 0, 47, 48, 49, 50, 518, 0, 52, - 0, 0, 53, 519, 0, 0, 54, 0, 0, 0, - 0, 520, 55, 0, 0, 0, 0, 0, 56, 57, - 58, 0, 0, 0, 0, 0, 521, 0, 522, 0, - 0, 0, 0, 523, 0, 59, 60, 524, 0, 0, - 525, 61, 0, 0, 526, 0, 0, 62, 63, 64, - 0, 0, 65, 0, 66, 7, 8, 9, 10, 0, - 11, 12, 13, 14, 0, 0, 0, 527, 0, 0, - 0, 528, 0, 0, 0, 529, 0, 530, 0, 0, - 0, 531, 976, 977, 978, 979, 980, 981, 0, 0, - 0, 46, 0, 47, 48, 49, 982, 0, 15, 0, - 0, 0, 16, 0, 17, 18, 19, 0, 0, 0, - 0, 453, 454, 20, 21, 0, 0, 0, 56, 192, - 58, 0, 22, 23, 0, 0, 0, 0, 0, 24, - 25, 0, 0, 0, 0, 59, 60, 26, 0, 27, - 0, 0, 0, 0, 0, 0, 28, 29, 30, 64, - 0, 31, 0, 0, 66, 32, 7, 8, 9, 10, - 33, 11, 12, 13, 14, 34, 980, 981, 0, 0, - 455, 0, 0, 0, 0, 0, 982, 134, 35, 0, - 0, 0, 36, 37, 0, 0, 38, 0, 39, 984, - 985, 986, 40, 0, 987, 988, 989, 990, 991, 15, - 992, 993, 994, 16, 0, 17, 18, 19, 0, 0, - 0, 0, 0, 0, 20, 21, 0, 0, 0, 0, - 0, 0, 0, 22, 23, 0, 0, 0, 0, 0, - 24, 25, 0, 0, 0, 0, 0, 0, 26, 0, - 27, 0, 0, 0, 0, 0, 0, 28, 29, 30, - 0, 0, 31, 0, 0, 0, 32, 7, 8, 9, - 10, 33, 11, 12, 13, 14, 34, 0, 0, 0, - 0, 0, 0, 0, 987, 988, 989, 990, 991, 35, - 992, 993, 994, 36, 37, 0, 0, 38, 0, 39, - 0, 310, 0, 40, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 185, 186, 187, 188, 189, 190, 191, + 192, 0, 0, 0, 0, 652, 52, 0, 0, 53, + 193, 54, 55, 56, 57, 371, 0, 653, 59, 0, + 0, 60, 654, 0, 0, 61, 0, 0, 0, 0, + 655, 656, 62, 0, 0, 0, 0, 0, 63, 64, + 0, 0, 0, 0, 0, 657, 0, 658, 0, 659, + 0, 0, 0, 372, 660, 0, 65, 66, 661, 0, + 0, 662, 67, 0, 0, 0, 663, 0, 0, 664, + 68, 69, 70, 0, 0, 71, 0, 72, 7, 8, + 9, 10, 0, 11, 12, 13, 14, 0, 0, 0, + 665, 0, 0, 666, 667, 0, 0, 0, 668, 0, + 669, 0, 0, 0, 0, 670, 0, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 0, 205, + 206, 207, 15, 0, 1277, 0, 16, 0, 17, 18, + 19, 0, 0, 0, 20, 0, 564, 565, 21, 22, + 53, 0, 54, 55, 56, 0, 0, 23, 24, 25, + 0, 0, 212, 0, 0, 26, 27, 0, 0, 0, + 0, 0, 28, 0, 29, 0, 30, 0, 0, 63, + 213, 31, 0, 32, 33, 34, 0, 0, 35, 0, + 0, 0, 0, 36, 518, 519, 37, 65, 66, 38, + 7, 8, 9, 10, 39, 11, 12, 13, 14, 566, + 0, 0, 0, 70, 0, 0, 0, 40, 72, 0, + 41, 42, 43, 0, 0, 44, 0, 45, 46, 0, + 0, 0, 47, 0, 0, 53, 0, 54, 55, 56, + 0, 136, 0, 0, 15, 0, 0, 60, 16, 0, + 17, 18, 19, 0, 0, 0, 20, 0, 62, 0, + 21, 22, 0, 0, 63, 64, 0, 0, 0, 23, + 24, 25, 0, 0, 0, 0, 0, 26, 27, 0, + 0, 0, 65, 66, 28, 0, 29, 0, 30, 0, + 0, 0, 0, 31, 0, 32, 33, 34, 70, 0, + 35, 71, 0, 72, 0, 36, 0, 0, 37, 0, + 0, 38, 7, 8, 9, 10, 39, 11, 12, 13, + 14, 0, 0, 53, 0, 54, 55, 56, 0, 40, + 0, 0, 41, 42, 43, 0, 0, 44, 0, 45, + 46, 349, 0, 0, 47, 0, 0, 0, 0, 0, + 0, 0, 63, 213, 0, 0, 15, 0, 0, 0, + 16, 0, 17, 18, 19, 0, 0, 0, 20, 0, + 65, 66, 21, 22, 0, 0, 174, 175, 0, 0, + 0, 23, 24, 25, 0, 0, 70, 0, 0, 26, + 27, 72, 0, 0, 0, 0, 28, 0, 29, 0, + 30, 0, 0, 0, 0, 31, 0, 32, 33, 34, + 0, 0, 35, 0, 146, 0, 0, 36, 0, 0, + 37, 0, 57, 38, 7, 8, 9, 10, 39, 11, + 12, 13, 14, 709, 0, 0, 0, 0, 0, 176, + 0, 40, 0, 0, 41, 42, 43, 0, 0, 44, + 0, 45, 46, 0, 0, 0, 47, 177, 792, 793, + 794, 0, 0, 0, 0, 0, 0, 0, 15, 0, + 67, 0, 16, 0, 17, 18, 19, 0, 795, 69, + 20, 0, 796, 0, 21, 22, 53, 0, 54, 55, + 56, 0, 0, 23, 24, 25, 0, 0, 0, 0, + 0, 26, 27, 0, 0, 0, 0, 0, 28, 0, + 29, 0, 30, 0, 0, 63, 213, 31, 0, 32, + 33, 34, 0, 0, 35, 0, 0, 0, 0, 36, + 0, 0, 37, 65, 66, 38, 7, 8, 9, 10, + 39, 11, 12, 13, 14, 0, 0, 0, 0, 70, + 0, 0, 0, 40, 72, 0, 41, 42, 43, 0, + 0, 44, 0, 45, 46, 1110, 0, 0, 47, 0, + 0, 53, 0, 54, 55, 56, 0, 147, 0, 0, 15, 0, 0, 0, 16, 0, 17, 18, 19, 0, - 0, 0, 0, 0, 0, 20, 21, 0, 0, 0, - 0, 0, 0, 0, 22, 23, 0, 0, 0, 0, - 0, 24, 25, 0, 0, 0, 0, 0, 0, 26, - 0, 27, 0, 0, 0, 0, 0, 0, 28, 29, - 30, 0, 0, 31, 0, 0, 0, 32, 7, 8, - 9, 10, 33, 11, 12, 13, 14, 34, 0, 0, - 0, 0, 565, 0, 0, 0, 0, 0, 0, 0, - 35, 0, 0, 0, 36, 37, 0, 0, 38, 0, - 39, 0, 0, 0, 40, 0, 0, 0, 0, 0, - 0, 15, 0, 0, 0, 16, 0, 17, 18, 19, - 0, 0, 0, 0, 0, 0, 20, 21, 0, 0, - 0, 0, 0, 0, 0, 22, 23, 0, 0, 0, - 0, 0, 24, 25, 0, 0, 0, 0, 0, 0, - 26, 0, 27, 0, 0, 0, 0, 0, 0, 28, - 29, 30, 0, 0, 31, 0, 0, 0, 32, 7, - 8, 9, 10, 33, 11, 12, 13, 14, 34, 0, + 0, 0, 20, 0, 0, 0, 21, 22, 0, 0, + 63, 213, 0, 0, 0, 23, 24, 25, 0, 0, + 0, 0, 0, 26, 27, 0, 0, 0, 65, 66, + 28, 0, 29, 0, 30, 0, 0, 0, 0, 31, + 0, 32, 33, 34, 70, 0, 35, 0, 0, 72, + 0, 36, 0, 0, 37, 0, 0, 38, 7, 8, + 9, 10, 39, 11, 12, 13, 14, 1127, 0, 0, + 0, 0, 151, 0, 0, 40, 0, 0, 41, 42, + 43, 0, 0, 44, 0, 45, 46, 0, 0, 0, + 47, 0, 0, 53, 0, 54, 55, 56, 0, 0, + 0, 0, 15, 0, 0, 212, 16, 0, 17, 18, + 19, 0, 0, 0, 20, 0, 0, 0, 21, 22, + 0, 0, 63, 213, 0, 0, 0, 23, 24, 25, + 0, 0, 0, 0, 0, 26, 27, 0, 0, 0, + 65, 66, 28, 0, 29, 0, 30, 0, 0, 0, + 0, 31, 0, 32, 33, 34, 70, 0, 35, 0, + 0, 72, 0, 36, 0, 0, 37, 0, 0, 38, + 7, 8, 9, 10, 39, 11, 12, 13, 14, 0, + 0, 53, 0, 54, 55, 56, 0, 40, 0, 0, + 41, 42, 43, 0, 0, 44, 0, 45, 46, 1246, + 0, 0, 47, 0, 0, 0, 0, 0, 0, 0, + 63, 213, 0, 0, 15, 0, 0, 0, 16, 0, + 17, 18, 19, 0, 0, 0, 20, 0, 65, 66, + 21, 22, 0, 0, 0, 0, 0, 0, 0, 23, + 24, 25, 0, 0, 70, 0, 0, 26, 27, 72, + 0, 0, 0, 0, 28, 0, 29, 0, 30, 0, + 0, 0, 0, 31, 0, 32, 33, 34, 0, 0, + 35, 0, 0, 0, 0, 36, 518, 519, 37, 1171, + 1172, 38, 7, 8, 9, 10, 39, 11, 12, 13, + 1173, 0, 0, 0, 0, 0, 0, 0, 0, 40, + 0, 0, 41, 42, 43, 0, 0, 44, 0, 45, + 46, 0, 0, 0, 47, 0, 0, 53, 0, 54, + 55, 56, 520, 521, 0, 0, 1058, 0, 0, 60, + 0, 0, 0, 0, 0, 0, 0, 0, 1059, 0, + 62, 0, 0, 1060, 0, 0, 63, 64, 0, 0, + 0, 23, 24, 0, 0, 0, 0, 0, 0, -2, + 0, 0, 0, 0, 65, 66, 0, 0, 29, 0, + 30, 0, 0, 0, 0, 1061, 0, 0, 522, 1062, + 70, 0, 1063, 71, 0, 72, 0, 36, 0, 0, + 0, 0, 0, 1178, 1179, 1180, 1181, 1182, 0, 1183, + 1184, 1185, 0, 0, 0, 0, 0, 0, 86, 87, + 0, 1064, 0, 0, 1065, 1066, 1067, 88, 0, 1068, + 0, 1069, 46, 0, 0, 89, 1070, 90, 91, 92, + 93, 0, 0, 0, 94, 0, 0, 0, 95, 0, + 0, 96, 97, 98, 99, 100, 0, 0, 0, 0, + 0, 101, 102, 103, 104, 0, 0, 0, 0, 0, + 105, 106, 0, 0, 107, 108, 0, 0, 0, 109, + 0, 0, 0, 0, 110, 111, 0, 112, 718, 0, + 0, 0, 0, 275, 276, 113, 0, 719, 720, 721, + 722, 723, 724, 725, 726, 0, 0, 0, 0, 0, + 0, 0, 114, 0, 727, 0, 728, 729, 730, 731, + 732, 733, 734, 735, 736, 737, 738, 739, 0, 0, + 0, 277, 0, 0, 53, 0, 54, 55, 56, 57, + 278, 0, 0, 279, 740, 0, 60, 0, 0, 0, + 61, 0, 0, 0, 0, 0, 0, 62, 0, 0, + 0, 0, 0, 63, 64, 0, 0, 0, 0, 741, + 0, 0, 0, 280, 0, 0, 0, 0, 0, 0, + 0, 65, 66, 0, 0, 0, 0, 67, 0, 275, + 276, 0, 0, 0, 0, 281, 69, 70, 0, 0, + 71, 0, 72, 0, 0, 0, 0, 742, 0, 0, + 743, 0, 744, 745, 746, 747, 748, 749, 750, 751, + 752, 753, 754, 283, 755, 756, 0, 277, 0, 757, + 53, 0, 54, 55, 56, 57, 278, 0, 0, 279, + 0, 0, 60, 0, 0, 0, 61, 0, 0, 0, + 0, 0, 0, 62, 0, 0, 0, 0, 0, 63, + 64, 401, 402, 1169, 1170, 1171, 1172, 0, 0, 280, + 0, 0, 0, 0, 0, 0, 1173, 65, 66, 0, + 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, + 0, 281, 69, 70, 0, 0, 71, 0, 72, 277, + 0, 0, 53, 282, 54, 55, 56, 57, 403, 0, + 0, 279, 0, 0, 60, 0, 0, 0, 61, 283, + 0, 0, 0, 0, 0, 62, 0, 0, 0, 0, + 0, 63, 64, 0, 0, 0, 0, 0, 0, 0, + 0, 280, 0, 0, 0, 0, 0, 0, 0, 65, + 66, 0, 0, 0, 0, 67, 0, 0, 0, 0, + 0, 0, 0, 281, 69, 70, 0, 0, 71, 0, + 72, 185, 186, 187, 188, 189, 190, 191, 192, 1178, + 1179, 1180, 1181, 1182, 0, 1183, 1184, 1185, 193, 0, + 0, 283, 185, 186, 187, 188, 189, 190, 191, 192, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, + 185, 186, 187, 188, 189, 190, 191, 192, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 193, 185, 186, + 187, 188, 189, 190, 191, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 193, 185, 186, 187, 188, + 189, 190, 191, 192, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 193, 185, 186, 187, 188, 189, 190, + 191, 192, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 193, 0, 0, 0, 194, 195, 196, 197, 198, + 199, 200, 201, 202, 203, 204, 0, 205, 206, 207, + 458, 0, 0, 0, 0, 0, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 0, 205, 206, + 207, 471, 0, 0, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 0, 205, 206, 207, 583, + 0, 0, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 0, 205, 206, 207, 685, 0, 0, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 0, 205, 206, 207, 1196, 468, 0, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 0, + 205, 206, 207, 185, 186, 187, 188, 189, 190, 191, + 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 193, 0, 185, 186, 187, 188, 189, 190, 191, 192, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 193, + 185, 186, 187, 188, 189, 190, 191, 192, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 193, 185, 186, + 187, 188, 189, 190, 191, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 193, 843, 844, 845, 846, + 847, 848, 849, 850, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 851, 1165, 1166, 1167, 1168, 1169, 1170, + 1171, 1172, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1173, 0, 0, 714, 0, 0, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 203, 204, 0, 205, + 206, 207, 1035, 0, 0, 0, 194, 195, 196, 197, + 198, 199, 200, 201, 202, 203, 204, 0, 205, 206, + 207, 0, 1198, 0, 194, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 0, 205, 206, 207, 0, + 0, 0, 194, 195, 196, 197, 198, 199, 200, 201, + 202, 203, 204, 0, 205, 206, 207, 0, 0, 0, + 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, + 862, 0, 863, 864, 865, 0, 1275, 0, 1174, 1175, + 1176, 1177, 0, 0, 1178, 1179, 1180, 1181, 1182, 0, + 1183, 1184, 1185, 1165, 1166, 1167, 1168, 1169, 1170, 1171, + 1172, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1173, 186, 187, 188, 189, 190, 191, 192, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 193, 0, 0, + 0, 0, 187, 188, 189, 190, 191, 192, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 193, 187, 188, + 189, 190, 191, 192, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 193, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1167, + 1168, 1169, 1170, 1171, 1172, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1173, 0, 187, 188, 189, 190, + 191, 192, 0, 0, 0, 0, 0, 1174, 1175, 1176, + 1177, 193, 0, 1178, 1179, 1180, 1181, 1182, 0, 1183, + 1184, 1185, 0, 0, 0, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 0, 205, 206, 207, 51, + 0, 0, 369, 0, 370, 195, 196, 197, 198, 199, + 200, 201, 202, 203, 204, 0, 205, 206, 207, 0, + 0, 0, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 0, 205, 206, 207, 0, 52, 0, 0, 53, + 0, 54, 55, 56, 57, 371, 0, 0, 59, 0, + 0, 60, 1175, 1176, 1177, 61, 0, 1178, 1179, 1180, + 1181, 1182, 62, 1183, 1184, 1185, 0, 0, 63, 64, + 0, 197, 198, 199, 200, 201, 202, 203, 204, 0, + 205, 206, 207, 372, 0, 0, 65, 66, 0, 0, + 0, 0, 67, 187, 188, 189, 190, 191, 192, 0, + 68, 69, 70, 0, 0, 71, 0, 72, 193, 1167, + 1168, 1169, 1170, 1171, 1172, 0, 0, 0, 0, 0, + 373, 0, 0, 0, 1173, 374, 1167, 1168, 1169, 1170, + 1171, 1172, 0, 0, 0, 1167, 1168, 1169, 1170, 1171, + 1172, 1173, 0, 0, 0, 0, 0, 0, 0, 0, + 1173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 35, 0, 0, 0, 36, 37, 0, 0, 38, - 0, 39, 0, 937, 0, 40, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, 16, 0, 17, 18, - 19, 0, 0, 0, 0, 0, 0, 20, 21, 0, - 0, 0, 0, 0, 0, 0, 22, 23, 0, 0, - 0, 0, 0, 24, 25, 0, 0, 0, 0, 0, - 0, 26, 0, 27, 0, 0, 0, 0, 0, 0, - 28, 29, 30, 0, 0, 31, 0, 0, 0, 32, - 7, 8, 9, 10, 33, 11, 12, 13, 14, 34, - 0, 0, 0, 0, 952, 0, 0, 0, 0, 0, - 0, 0, 35, 0, 0, 0, 36, 37, 0, 0, - 38, 0, 39, 0, 0, 0, 40, 0, 0, 0, - 0, 0, 0, 15, 0, 0, 0, 16, 0, 17, - 18, 19, 0, 0, 0, 0, 0, 0, 20, 21, - 0, 0, 0, 0, 0, 0, 0, 22, 23, 0, - 0, 0, 0, 0, 24, 25, 0, 0, 0, 0, - 0, 0, 26, 0, 27, 0, 0, 0, 0, 0, - 0, 28, 29, 30, 0, 0, 31, 0, 0, 0, - 32, 7, 8, 9, 10, 33, 11, 12, 13, 14, - 34, 0, 217, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 35, 0, 0, 0, 36, 37, 0, - 0, 38, 0, 39, 0, 1051, 0, 40, 0, 0, - 0, 0, 0, 0, 15, 0, 0, 0, 16, 0, - 17, 18, 19, 0, 0, 81, 0, 0, 0, 20, - 21, 0, 0, 82, 0, 0, 0, 0, 22, 23, - 0, 0, 84, 85, 86, 24, 25, 0, 0, 0, - 0, 0, 213, 26, 0, 27, 0, 0, 0, 93, - 0, 0, 28, 29, 30, 0, 0, 31, 98, 0, - 0, 32, 0, 99, 0, 0, 33, 0, 0, 0, - 0, 34, 0, 0, 0, 0, 104, 0, 105, 0, - 0, 0, -2, 0, 35, 0, 0, 0, 36, 37, - 574, 0, 38, 0, 39, 0, 0, 0, 40, 575, - 576, 577, 578, 579, 580, 581, 582, 0, 0, 0, - 0, 0, 0, 0, 0, 583, 0, 584, 585, 586, - 587, 588, 589, 590, 591, 592, 593, 594, 595, 0, - 80, 81, 0, 0, 0, 0, 0, 0, 0, 82, - 0, 0, 0, 0, 596, 0, 83, 0, 84, 85, - 86, 87, 0, 0, 88, 0, 0, 0, 89, 0, - 0, 0, 90, 91, 92, 93, 94, 0, 0, 597, - 0, 95, 96, 97, 98, 0, 0, 0, 0, 99, - 100, 0, 0, 101, 0, 245, 246, 102, 0, 0, - 0, 103, 104, 0, 105, 0, 0, 0, 0, 0, - 0, 0, 106, 598, 0, 0, 599, 0, 600, 601, - 602, 603, 604, 605, 606, 607, 608, 609, 610, 0, - 611, 612, 247, 0, 613, 46, 0, 47, 48, 49, - 50, 248, 0, 249, 0, 0, 53, 0, 0, 0, - 54, 0, 0, 0, 0, 0, 55, 0, 0, 0, - 0, 0, 56, 57, 58, 245, 246, 0, 0, 0, - 0, 0, 0, 250, 0, 0, 0, 0, 0, 59, - 60, 0, 0, 0, 0, 61, 0, 0, 0, 0, - 0, 251, 63, 64, 0, 0, 65, 0, 66, 0, - 0, 0, 247, 252, 0, 46, 0, 47, 48, 49, - 50, 248, 0, 249, 0, 0, 53, 0, 0, 253, - 54, 0, 0, 0, 0, 0, 55, 245, 246, 0, - 0, 0, 56, 57, 58, 0, 0, 0, 0, 0, - 0, 0, 0, 250, 0, 0, 0, 0, 0, 59, - 60, 0, 0, 0, 0, 61, 0, 0, 0, 0, - 0, 251, 63, 64, 247, 0, 65, 46, 66, 47, - 48, 49, 50, 344, 0, 249, 0, 0, 53, 0, - 0, 0, 54, 0, 0, 0, 0, 0, 55, 253, - 0, 0, 0, 0, 56, 57, 58, 161, 162, 163, - 164, 165, 166, 167, 168, 250, 0, 0, 0, 0, - 0, 59, 60, 169, 0, 0, 0, 61, 0, 0, - 0, 0, 0, 251, 63, 64, 0, 0, 65, 0, - 66, 161, 162, 163, 164, 165, 166, 167, 168, 0, - 0, 0, 0, 0, 0, 0, 0, 169, 0, 0, - 0, 253, 161, 162, 163, 164, 165, 166, 167, 168, - 0, 0, 0, 0, 0, 0, 0, 0, 169, 0, - 161, 162, 163, 164, 165, 166, 167, 168, 0, 0, - 0, 0, 0, 0, 0, 0, 169, 161, 162, 163, - 164, 165, 166, 167, 168, 0, 0, 0, 0, 0, - 0, 0, 0, 169, 0, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 0, 181, 182, 183, - 392, 161, 162, 163, 164, 165, 166, 167, 168, 0, - 0, 0, 0, 0, 0, 0, 0, 169, 0, 170, - 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, - 0, 181, 182, 183, 545, 0, 0, 0, 389, 0, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, - 180, 0, 181, 182, 183, 570, 0, 0, 170, 171, - 172, 173, 174, 175, 176, 177, 178, 179, 180, 0, - 181, 182, 183, 1009, 0, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 0, 181, 182, 183, - 161, 162, 163, 164, 165, 166, 167, 168, 0, 0, - 0, 0, 0, 0, 0, 864, 169, 0, 0, 170, - 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, - 0, 181, 182, 183, 692, 693, 694, 695, 696, 697, - 698, 699, 0, 0, 0, 0, 0, 0, 0, 0, - 700, 974, 975, 976, 977, 978, 979, 980, 981, 0, - 0, 0, 0, 0, 0, 0, 0, 982, 974, 975, - 976, 977, 978, 979, 980, 981, 0, 0, 0, 0, - 0, 0, 0, 0, 982, 162, 163, 164, 165, 166, - 167, 168, 0, 0, 0, 0, 0, 0, 0, 0, - 169, 0, 0, 0, 0, 0, 0, 0, 170, 171, - 172, 173, 174, 175, 176, 177, 178, 179, 180, 0, - 181, 182, 183, 975, 976, 977, 978, 979, 980, 981, - 0, 0, 0, 0, 0, 0, 0, 0, 982, 0, - 0, 0, 701, 702, 703, 704, 705, 706, 707, 708, - 709, 710, 711, 0, 712, 713, 714, 1074, 0, 983, - 984, 985, 986, 0, 0, 987, 988, 989, 990, 991, - 0, 992, 993, 994, 0, 0, 983, 984, 985, 986, - 0, 0, 987, 988, 989, 990, 991, 0, 992, 993, - 994, 0, 0, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 0, 181, 182, 183, 163, 164, 165, - 166, 167, 168, 0, 0, 0, 0, 0, 0, 0, - 0, 169, 0, 0, 46, 0, 47, 48, 49, 0, - 0, 984, 985, 986, 0, 0, 987, 988, 989, 990, - 991, 0, 992, 993, 994, 163, 164, 165, 166, 167, - 168, 56, 192, 58, 0, 0, 0, 0, 0, 169, - 163, 164, 165, 166, 167, 168, 0, 0, 59, 60, - 0, 0, 0, 0, 169, 976, 977, 978, 979, 980, - 981, 0, 64, 0, 0, 0, 0, 66, 0, 982, - 976, 977, 978, 979, 980, 981, 0, 0, 0, 0, - 0, 0, 0, 0, 982, 0, 0, 0, 0, 0, - 135, 0, 0, 0, 0, 172, 173, 174, 175, 176, - 177, 178, 179, 180, 0, 181, 182, 183, 976, 977, - 978, 979, 980, 981, 0, 0, 0, 0, 0, 0, - 0, 0, 982, 0, 0, 0, 0, 0, 0, 0, - 165, 166, 167, 168, 173, 174, 175, 176, 177, 178, - 179, 180, 169, 181, 182, 183, 0, 0, 0, 0, - 174, 175, 176, 177, 178, 179, 180, 0, 181, 182, - 183, 0, 0, 985, 986, 0, 0, 987, 988, 989, - 990, 991, 0, 992, 993, 994, 0, 0, 0, 986, - 0, 0, 987, 988, 989, 990, 991, 0, 992, 993, - 994, 978, 979, 980, 981, 0, 0, 0, 0, 0, - 0, 0, 0, 982, 0, 0, 0, 46, 0, 47, - 48, 49, 0, 0, 0, 0, 0, 0, 0, 0, - 987, 988, 989, 990, 991, 0, 992, 993, 994, 351, - 352, 0, 0, 0, 56, 192, 58, 0, 174, 175, - 176, 177, 178, 179, 180, 0, 181, 182, 183, 415, - 416, 59, 60, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 64, 247, 0, 0, 46, - 66, 47, 48, 49, 50, 0, 0, 249, 0, 0, - 53, 0, 0, 0, 54, 0, 0, 0, 0, 46, - 55, 47, 48, 49, 417, 418, 56, 57, 58, 0, - 53, 987, 988, 989, 990, 991, 0, 992, 993, 994, - 55, 415, 416, 59, 60, 0, 56, 57, 58, 61, - 0, 0, 0, 0, 0, 251, 63, 64, 0, 0, - 65, 0, 66, 59, 60, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 419, 0, 64, 0, 0, - 65, 46, 66, 47, 48, 49, 0, 0, 0, 0, - 0, 44, 53, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 55, 0, 0, 0, 0, 0, 56, 57, - 58, 0, 0, 0, 0, 0, 0, 0, 0, 46, - 0, 47, 48, 49, 0, 59, 60, 45, 0, 0, - 46, 0, 47, 48, 49, 50, 51, 0, 52, 64, - 0, 53, 65, 0, 66, 54, 56, 192, 58, 0, - 0, 55, 0, 44, 0, 0, 0, 56, 57, 58, - 0, 0, 0, 59, 60, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 59, 60, 0, 64, 0, 0, - 61, 46, 66, 47, 48, 49, 62, 63, 64, 45, - 0, 65, 46, 66, 47, 48, 49, 50, 355, 0, - 52, 0, 315, 53, 327, 138, 0, 54, 56, 192, - 58, 0, 0, 55, 0, 44, 0, 0, 0, 56, - 57, 58, 0, 0, 0, 59, 60, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 59, 60, 0, 64, - 0, 0, 61, 46, 66, 47, 48, 49, 62, 63, - 64, 45, 0, 65, 46, 66, 47, 48, 49, 50, - 0, 0, 52, 0, 0, 53, 0, 0, 0, 54, - 56, 192, 58, 0, 0, 55, 0, 44, 0, 0, - 0, 56, 57, 58, 0, 0, 0, 59, 60, 0, - 0, 0, 0, 0, 0, 0, 675, 128, 59, 60, - 0, 64, 0, 0, 61, 0, 66, 0, 0, 0, - 62, 63, 64, 45, 0, 65, 46, 66, 47, 48, - 49, 50, 0, 0, 52, 0, 0, 53, 0, 0, - 0, 54, 0, 0, 0, 0, 46, 55, 47, 48, - 49, 50, 0, 56, 57, 58, 0, 53, 0, 0, - 0, 54, 0, 0, 0, 0, 0, 55, 0, 0, - 59, 60, 0, 56, 57, 58, 61, 0, 0, 0, - 0, 0, 62, 63, 64, 0, 0, 65, 0, 66, - 59, 60, 80, 81, 0, 0, 61, 0, 0, 0, - 0, 82, 129, 63, 64, 0, 0, 65, 83, 66, - 84, 85, 86, 87, 0, 0, 88, 0, 0, 0, - 89, 0, 0, 0, 90, 91, 92, 93, 94, 0, - 0, 0, 0, 95, 96, 97, 98, 0, 0, 0, - 0, 99, 100, 0, 0, 101, 0, 0, 0, 102, - 0, 0, 0, 103, 104, 0, 105, 80, 81, 0, - 0, 0, 0, 0, 106, 0, 82, 0, 0, 0, - 0, 0, 0, 83, 0, 84, 85, 86, 87, 0, - 0, 88, 0, 411, 0, 89, 0, 0, 0, 90, - 91, 92, 93, 94, 0, 0, 0, 0, 95, 96, - 97, 98, 0, 0, 0, 0, 99, 100, 0, 0, - 101, 0, 0, 0, 102, 0, 0, 0, 103, 104, - 0, 105, 80, 81, 0, 0, 0, 0, 0, 106, - 0, 82, 0, 0, 0, 0, 0, 0, 83, 0, - 84, 85, 86, 87, 0, 0, 88, 0, 477, 0, - 89, 0, 0, 0, 90, 91, 92, 93, 94, 0, - 0, 0, 0, 95, 96, 97, 98, 0, 0, 0, - 0, 99, 100, 0, 0, 101, 0, 0, 0, 102, - 0, 0, 0, 103, 104, 0, 105, 80, 81, 0, - 0, 0, 0, 0, 106, 0, 82, 0, 0, 0, - 0, 0, 0, 83, 0, 84, 85, 86, 87, 0, - 0, 88, 0, 485, 0, 89, 0, 0, 0, 90, - 91, 92, 93, 94, 0, 0, 0, 0, 95, 96, - 97, 98, 0, 0, 0, 0, 99, 100, 0, 0, - 101, 0, 0, 0, 102, 0, 0, 0, 103, 104, - 0, 105, 80, 81, 0, 0, 0, 0, 0, 106, - 0, 82, 0, 0, 0, 0, 0, 0, 83, 0, - 84, 85, 86, 87, 0, 0, 88, 0, 555, 0, - 89, 0, 0, 0, 90, 91, 92, 93, 94, 0, - 0, 0, 0, 95, 96, 97, 98, 0, 0, 0, - 0, 99, 100, 0, 0, 101, 0, 0, 0, 102, - 0, 0, 0, 103, 104, 0, 105, 80, 81, 0, - 0, 0, 0, 0, 106, 0, 82, 0, 0, 0, - 0, 0, 0, 83, 0, 84, 85, 86, 87, 0, - 0, 88, 0, 650, 0, 89, 0, 0, 0, 90, - 91, 92, 93, 94, 0, 0, 0, 0, 95, 96, - 97, 98, 0, 0, 0, 0, 99, 100, 0, 0, - 101, 0, 0, 0, 102, 0, 0, 0, 103, 104, - 0, 105, 80, 81, 0, 0, 0, 0, 0, 106, - 0, 82, 0, 0, 0, 0, 0, 0, 83, 0, - 84, 85, 86, 87, 0, 0, 88, 0, 873, 0, - 89, 0, 0, 0, 90, 91, 92, 93, 94, 0, - 0, 0, 0, 95, 96, 97, 98, 0, 0, 0, - 0, 99, 100, 0, 46, 101, 47, 48, 49, 102, - 81, 0, 0, 103, 104, 188, 105, 0, 82, 0, - 0, 0, 0, 0, 106, 189, 0, 84, 85, 86, - 0, 56, 190, 58, 0, 0, 0, 213, 0, 0, - 0, 0, 0, 874, 93, 0, 0, 0, 59, 60, - 0, 0, 0, 98, 0, 0, 0, 0, 99, 80, - 81, 0, 64, 0, 0, 0, 0, 66, 82, 0, - 0, 104, 0, 105, 0, 83, 0, 84, 85, 86, - 87, 0, 0, 88, 0, 0, 0, 89, -129, 0, - 127, 90, 91, 92, 93, 94, 0, 0, 0, 0, - 95, 96, 97, 98, 0, 0, 0, 0, 99, 100, - 0, 46, 101, 47, 48, 49, 102, 81, 0, 0, - 103, 104, 188, 105, 0, 82, 0, 0, 0, 0, - 0, 0, 189, 0, 84, 85, 86, 0, 56, 190, - 58, 0, 0, 0, 213, 81, 0, 0, 0, 0, - 0, 93, 222, 82, 0, 59, 60, 0, 0, 0, - 98, 0, 84, 85, 86, 99, 0, 81, 0, 64, - 0, 0, 213, 0, 66, 82, 0, 0, 104, 93, - 105, 0, 0, 0, 84, 85, 86, 0, 98, 0, - 0, 0, 0, 99, 213, 0, 0, 101, 0, 0, - 0, 93, 0, 0, 0, 0, 104, 0, 105, 0, - 98, 0, 0, 0, 0, 99, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, - 105 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 198, + 199, 200, 201, 202, 203, 204, 0, 205, 206, 207, + 0, 0, 0, 1176, 1177, 415, 416, 1178, 1179, 1180, + 1181, 1182, 0, 1183, 1184, 1185, 0, 0, 0, 0, + 0, 1177, 0, 0, 1178, 1179, 1180, 1181, 1182, 0, + 1183, 1184, 1185, 1178, 1179, 1180, 1181, 1182, 0, 1183, + 1184, 1185, 0, 277, 0, 0, 53, 0, 54, 55, + 56, 57, 0, 0, 0, 279, 0, 0, 60, 0, + 0, 0, 61, 0, 0, 0, 0, 0, 0, 62, + 0, 0, 0, 0, 0, 63, 64, 0, 51, 0, + 0, 369, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 65, 66, 0, 0, 0, 0, 67, + 0, 0, 0, 0, 0, 0, 0, 281, 69, 70, + 0, 0, 71, 0, 72, 52, 0, 0, 53, 0, + 54, 55, 56, 57, 371, 0, 0, 59, 0, 0, + 60, 0, 0, 0, 61, 0, 0, 0, 0, 0, + 0, 62, 0, 0, 0, 0, 0, 63, 64, 0, + 51, 0, 0, 605, 0, 0, 87, 0, 0, 0, + 0, 0, 372, 0, 88, 65, 66, 0, 0, 0, + 0, 67, 0, 0, 90, 91, 92, 0, 0, 68, + 69, 70, 0, 0, 71, 241, 72, 52, 0, 0, + 53, 99, 54, 55, 56, 57, 371, 0, 0, 59, + 0, 104, 60, 0, 0, 0, 61, 105, 0, 0, + 0, 107, 108, 62, 0, 0, 0, 51, 0, 63, + 64, 0, 111, 0, 112, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 372, 0, 0, 65, 66, 51, + 0, 0, 0, 67, 0, 0, 0, 0, 0, 114, + 0, 68, 69, 70, 52, 0, 71, 53, 72, 54, + 55, 56, 57, 371, 0, 0, 59, 0, 0, 60, + 0, 0, 0, 61, 0, 0, 52, 0, 0, 53, + 62, 54, 55, 56, 57, 58, 63, 64, 59, 0, + 0, 60, 0, 0, 0, 61, 0, 0, 0, 0, + 0, 372, 62, 0, 65, 66, 51, 0, 63, 64, + 67, 0, 0, 0, 0, 0, 0, 0, 68, 69, + 70, 0, 0, 71, 0, 72, 65, 66, 0, 0, + 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, + 68, 69, 70, 52, 0, 71, 53, 72, 54, 55, + 56, 57, 419, 0, 0, 59, 0, 0, 60, 0, + 0, 51, 61, 0, 0, 0, 0, 0, 0, 62, + 0, 0, 0, 0, 0, 63, 64, 0, 0, 0, + 0, 0, 0, 137, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 65, 66, 0, 0, 0, 52, 67, + 0, 53, 0, 54, 55, 56, 57, 68, 69, 70, + 59, 0, 71, 60, 72, 0, 0, 61, 0, 0, + 138, 0, 0, 53, 62, 54, 55, 56, 57, 776, + 63, 64, 139, 0, 0, 60, 0, 0, 137, 61, + 0, 0, 0, 0, 0, 481, 62, 0, 65, 66, + 0, 0, 63, 64, 67, 0, 0, 0, 0, 0, + 51, 0, 68, 69, 70, 0, 0, 71, 0, 72, + 65, 66, 0, 0, 0, 138, 67, 0, 53, 0, + 54, 55, 56, 57, 140, 69, 70, 139, 0, 71, + 60, 72, 0, 0, 61, 0, 0, 52, 0, 0, + 53, 62, 54, 55, 56, 57, 0, 63, 64, 59, + 0, 0, 60, 0, 0, 0, 61, 0, 0, 0, + 0, 0, 0, 62, 0, 65, 66, 0, 0, 63, + 64, 67, 0, 0, 0, 0, 0, 0, 0, 140, + 69, 70, 0, 0, 71, 0, 72, 65, 66, 0, + 86, 87, 0, 67, 0, 0, 0, 0, 0, 88, + 0, 68, 69, 70, 0, 0, 71, 89, 72, 90, + 91, 92, 93, 0, 0, 0, 94, 0, 0, 0, + 95, 0, 0, 96, 97, 98, 99, 100, 0, 0, + 0, 0, 0, 101, 102, 103, 104, 0, 0, 0, + 0, 0, 105, 106, 86, 87, 107, 108, 0, 0, + 0, 109, 0, 88, 0, 0, 110, 111, 0, 112, + 0, 89, 0, 90, 91, 92, 93, 113, 0, 0, + 94, 0, 0, 0, 95, 0, 0, 96, 97, 98, + 99, 100, 0, 0, 114, 0, 514, 101, 102, 103, + 104, 0, 0, 0, 0, 0, 105, 106, 86, 87, + 107, 108, 0, 0, 0, 109, 0, 88, 0, 0, + 110, 111, 0, 112, 0, 89, 0, 90, 91, 92, + 93, 113, 0, 0, 94, 0, 0, 0, 95, 0, + 0, 96, 97, 98, 99, 100, 0, 0, 114, 0, + 621, 101, 102, 103, 104, 0, 0, 0, 0, 0, + 105, 106, 86, 87, 107, 108, 0, 0, 0, 109, + 0, 88, 0, 0, 110, 111, 0, 112, 0, 89, + 0, 90, 91, 92, 93, 113, 0, 0, 94, 0, + 0, 0, 95, 0, 0, 96, 97, 98, 99, 100, + 0, 0, 114, 0, 626, 101, 102, 103, 104, 0, + 0, 0, 0, 0, 105, 106, 86, 87, 107, 108, + 0, 0, 0, 109, 0, 88, 0, 0, 110, 111, + 0, 112, 0, 89, 0, 90, 91, 92, 93, 113, + 0, 0, 94, 0, 0, 0, 95, 0, 0, 96, + 97, 98, 99, 100, 0, 0, 114, 0, 695, 101, + 102, 103, 104, 0, 0, 0, 0, 0, 105, 106, + 86, 87, 107, 108, 0, 0, 0, 109, 0, 88, + 0, 0, 110, 111, 0, 112, 0, 89, 0, 90, + 91, 92, 93, 113, 0, 0, 94, 0, 0, 0, + 95, 0, 0, 96, 97, 98, 99, 100, 0, 0, + 114, 0, 808, 101, 102, 103, 104, 0, 0, 0, + 0, 0, 105, 106, 86, 87, 107, 108, 0, 0, + 0, 109, 0, 88, 0, 0, 110, 111, 0, 112, + 0, 89, 0, 90, 91, 92, 93, 113, 0, 0, + 94, 0, 0, 0, 95, 0, 0, 96, 97, 98, + 99, 100, 0, 0, 114, 0, 1049, 101, 102, 103, + 104, 0, 0, 0, 0, 0, 105, 106, 86, 87, + 107, 108, 0, 0, 0, 109, 0, 88, 0, 0, + 110, 111, 0, 112, 0, 89, 0, 90, 91, 92, + 93, 113, 0, 0, 94, 0, 0, 0, 95, 0, + 0, 96, 97, 98, 99, 100, 0, 0, 114, 0, + 1146, 101, 102, 103, 104, 0, 0, 0, 0, 0, + 105, 106, 87, 0, 107, 108, 0, 0, 0, 109, + 88, 0, 0, 0, 110, 111, 87, 112, 0, 0, + 90, 91, 92, 0, 88, 0, 0, 0, 0, 0, + 0, 241, 0, 0, 90, 91, 92, 99, 250, 0, + 0, 0, 114, 0, 0, 241, 87, 104, 0, 0, + 0, 99, 0, 105, 88, 0, 0, 0, 108, 0, + 0, 104, 0, 0, 90, 91, 92, 105, 111, 0, + 112, 0, 108, 0, 0, 241, 0, 0, 0, 0, + 0, 99, 111, 0, 112, 0, 0, 0, 0, 0, + 0, 104, 0, 0, 0, 114, 0, 105, 0, -140, + 0, 0, 108, 0, 0, 0, 0, 0, 0, 114, + 0, 0, 111, 0, 112, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 114 }; #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-656))) + (!!((Yystate) == (-755))) #define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int16 yycheck[] = { - 1, 136, 510, 39, 101, 39, 565, 345, 122, 119, - 120, 121, 122, 123, 51, 125, 126, 127, 110, 0, - 26, 12, 523, 137, 134, 135, 413, 26, 138, 139, - 10, 11, 228, 136, 10, 11, 544, 136, 10, 11, - 14, 330, 429, 119, 432, 432, 119, 428, 119, 110, - 431, 136, 433, 57, 186, 59, 60, 10, 11, 6, - 64, 8, 138, 718, 122, 138, 67, 138, 200, 201, - 202, 203, 204, 205, 10, 11, 136, 458, 459, 137, - 461, 462, 463, 464, 118, 473, 473, 493, 10, 11, - 124, 110, 239, 86, 500, 501, 502, 503, 504, 505, - 127, 248, 136, 137, 110, 479, 480, 4, 136, 102, - 110, 110, 554, 10, 11, 6, 117, 8, 119, 120, - 121, 122, 123, 136, 125, 126, 127, 508, 466, 535, - 6, 84, 8, 134, 135, 331, 523, 138, 139, 335, - 131, 121, 118, 127, 236, 119, 182, 136, 152, 153, - 154, 155, 118, 81, 82, 121, 84, 85, 86, 540, - 118, 89, 358, 671, 121, 93, 138, 277, 556, 556, - 98, 99, 510, 101, 102, 236, 104, 105, 239, 468, - 622, 136, 118, 691, 316, 186, 190, 248, 192, 690, - 571, 138, 10, 11, 12, 119, 118, 344, 16, 200, - 201, 202, 203, 204, 205, 209, 544, 208, 863, 119, - 136, 62, 119, 250, 138, 31, 412, 236, 118, 136, - 239, 121, 73, 74, 136, 667, 119, 228, 138, 248, - 236, 138, 119, 239, 136, 31, 236, 236, 56, 239, - 239, 136, 248, 94, 119, 138, 31, 136, 248, 248, - 119, 138, 103, 659, 10, 11, 12, 136, 632, 136, - 16, 121, 636, 138, 638, 119, 640, 641, 642, 138, - 676, 136, 31, 136, 119, 121, 277, 121, 129, 136, - 131, 132, 119, 344, 138, 213, 136, 483, 119, 217, - 486, 435, 947, 138, 112, 439, 440, 441, 442, 443, - 56, 138, 138, 690, 26, 12, 131, 138, 126, 16, - 137, 119, 121, 131, 122, 316, 10, 11, 355, 135, - 136, 137, 323, 137, 138, 344, 330, 136, 137, 138, - 331, 332, 88, 671, 335, 723, 723, 343, 344, 135, - 136, 137, 343, 121, 344, 344, 131, 132, 133, 56, - 135, 136, 137, 136, 137, 356, 112, 358, 10, 11, - 12, 1016, 136, 137, 16, 1020, 89, 90, 91, 121, - 126, 222, 131, 132, 133, 131, 135, 136, 137, 118, - 136, 120, 121, 122, 136, 137, 138, 110, 110, 10, - 241, 10, 429, 952, 902, 432, 127, 136, 495, 10, - 251, 121, 253, 547, 56, 112, 118, 119, 1063, 260, - 261, 412, 418, 1068, 118, 136, 136, 137, 138, 126, - 136, 137, 423, 2, 131, 136, 119, 1082, 429, 136, - 120, 432, 138, 469, 435, 471, 473, 1092, 439, 440, - 441, 442, 443, 10, 11, 137, 138, 118, 449, 120, - 121, 122, 562, 138, 455, 138, 35, 36, 37, 38, - 112, 40, 138, 138, 468, 466, 115, 116, 117, 138, - 858, 858, 473, 324, 126, 89, 90, 91, 138, 131, - 128, 518, 483, 138, 136, 486, 523, 138, 55, 128, - 496, 999, 493, 138, 530, 901, 530, 138, 138, 500, - 501, 502, 503, 504, 505, 506, 138, 138, 138, 510, - 139, 362, 121, 118, 236, 521, 666, 239, 899, 556, - 119, 119, 521, 119, 136, 138, 248, 118, 136, 136, - 136, 141, 118, 100, 535, 119, 10, 10, 10, 106, - 107, 128, 119, 544, 139, 120, 547, 136, 131, 131, - 120, 131, 137, 554, 119, 556, 944, 944, 119, 122, - 122, 562, 943, 31, 565, 131, 417, 495, 419, 127, - 127, 139, 136, 119, 962, 962, 136, 10, 119, 138, - 10, 120, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, - 179, 180, 181, 138, 183, 10, 11, 138, 187, 141, - 138, 10, 10, 137, 31, 996, 119, 136, 652, 56, - 654, 622, 344, 138, 4, 1013, 1013, 478, 479, 480, - 118, 136, 120, 121, 122, 119, 138, 141, 675, 139, - 674, 138, 141, 677, 139, 138, 680, 681, 136, 137, - 55, 138, 653, 690, 136, 136, 235, 127, 659, 136, - 127, 129, 130, 131, 132, 133, 667, 135, 136, 137, - 671, 119, 141, 1061, 1061, 676, 138, 713, 3, 4, - 5, 6, 128, 8, 9, 10, 723, 688, 138, 128, - 691, 136, 120, 10, 138, 100, 138, 120, 120, 139, - 138, 106, 107, 138, 136, 110, 119, 286, 287, 136, - 561, 136, 129, 130, 131, 132, 133, 718, 135, 136, - 137, 46, 723, 138, 138, 128, 138, 138, 128, 138, - 10, 138, 136, 120, 136, 561, 221, 62, 888, 889, - 890, 891, 138, 893, 323, 70, 138, 860, 943, 996, - 899, 495, 418, 10, 11, 496, 478, 479, 480, 21, - 22, 239, 87, 653, 521, 484, 560, 821, 619, 31, - -1, 96, -1, -1, 99, 354, -1, -1, 103, -1, - 631, 632, 633, -1, 363, 636, -1, 638, -1, 640, - 641, 642, -1, -1, 904, -1, -1, -1, 55, 521, - -1, 126, 10, 11, -1, 130, 131, -1, -1, 134, - 389, 136, -1, -1, -1, 140, -1, -1, -1, -1, - 821, 858, -1, -1, 974, 975, 976, 977, 978, 979, - 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, - 990, 991, 992, 100, -1, -1, -1, 55, -1, 106, - 107, -1, -1, 110, -1, -1, 892, 858, 892, -1, - -1, -1, 863, -1, -1, -1, -1, 129, 130, 131, - 132, 133, -1, 135, 136, 137, 455, -1, -1, -1, - 1030, 17, 18, 19, 20, 21, 22, -1, -1, -1, - -1, -1, 100, -1, -1, 31, -1, 476, 106, 107, - 901, 902, 110, 904, -1, -1, -1, 944, -1, -1, - 632, -1, -1, -1, 636, -1, 638, -1, 640, 641, - 642, -1, -1, -1, 1074, 962, -1, -1, -1, 963, - 964, 965, 966, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 944, -1, -1, 947, -1, 527, 528, - 529, 952, 531, -1, -1, -1, -1, 993, -1, -1, - -1, 962, 15, 16, 17, 18, 19, 20, 21, 22, - -1, -1, -1, -1, -1, 554, 1013, -1, 31, -1, - -1, -1, -1, -1, -1, -1, 565, -1, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 999, 135, - 136, 137, -1, -1, -1, -1, 888, 889, 890, 891, - -1, 893, 1013, -1, -1, 1016, -1, -1, -1, 1020, - 1056, -1, 1058, -1, 1061, -1, -1, -1, -1, -1, + 1, 429, 107, 127, 128, 129, 130, 404, 132, 532, + 134, 135, 136, 210, 516, 464, 709, 58, 45, 542, + 118, 28, 146, 147, 221, 222, 256, 151, 152, 28, + 28, 372, 578, 387, 479, 537, 577, 588, 792, 793, + 794, 14, 6, 12, 8, 46, 12, 16, 118, 482, + 0, 10, 11, 118, 118, 601, 124, 490, 491, 492, + 493, 494, 495, 604, 544, 125, 546, 547, 548, 549, + 550, 14, 73, 45, 142, 540, 61, 62, 125, 10, + 11, 142, 125, 128, 144, 64, 65, 66, 57, 538, + 73, 70, 541, 526, 10, 11, 642, 144, 143, 133, + 486, 144, 268, 142, 569, 570, 657, 572, 573, 574, + 575, 118, 278, 125, 73, 128, 128, 640, 73, 118, + 118, 57, 32, 6, 125, 8, 127, 128, 129, 130, + 143, 132, 91, 134, 135, 136, 10, 11, 684, 143, + 144, 124, 73, 133, 127, 146, 147, 488, 142, 118, + 151, 152, 125, 32, 126, 143, 144, 73, 388, 131, + 91, 133, 392, 132, 125, 142, 264, 600, 137, 124, + 615, 137, 127, 145, 607, 91, 148, 149, 150, 206, + 144, 578, 125, 144, 225, 144, 310, 166, 167, 168, + 169, 125, 422, 124, 264, 142, 537, 12, 268, 264, + 264, 16, 635, 268, 268, 142, 142, 687, 278, 210, + 144, 133, 128, 278, 278, 680, 132, 91, 32, 220, + 221, 222, 223, 224, 225, 776, 580, 73, 229, 10, + 11, 141, 142, 143, 213, 142, 782, 403, 32, 280, + 142, 126, 57, 128, 142, 642, 142, 696, 125, 694, + 715, 143, 144, 127, 233, 256, 142, 264, 137, 138, + 139, 268, 141, 142, 143, 264, 264, 144, 133, 268, + 268, 278, 700, 32, 125, 821, 142, 125, 124, 278, + 278, 127, 1036, 142, 1038, 515, 1040, 684, 125, 1043, + 1044, 1045, 73, 144, 87, 88, 144, 90, 91, 92, + 10, 11, 95, 118, 10, 11, 99, 144, 142, 310, + 91, 104, 105, 127, 107, 108, 109, 132, 111, 112, + 765, 6, 137, 8, 142, 326, 327, 142, 142, 143, + 371, 372, 781, 403, 142, 784, 785, 142, 403, 403, + 842, 135, 136, 137, 138, 139, 127, 141, 142, 143, + 124, 779, 126, 354, 128, 356, 357, 358, 359, 360, + 142, 125, 124, 73, 126, 6, 128, 73, 142, 370, + 10, 11, 373, 374, 127, 125, 125, 378, 419, 380, + 144, 91, 141, 142, 143, 91, 124, 388, 389, 775, + 142, 392, 10, 11, 144, 144, 403, 627, 73, 400, + 142, 400, 127, 125, 403, 403, 127, 125, 387, 50, + 85, 125, 125, 88, 124, 127, 91, 58, 124, 420, + 125, 422, 144, 464, 821, 874, 144, 68, 69, 70, + 144, 144, 107, 73, 1127, 142, 143, 409, 79, 144, + 481, 142, 125, 125, 85, 143, 86, 488, 241, 143, + 144, 91, 245, 142, 95, 73, 142, 125, 124, 125, + 101, 144, 144, 464, 465, 106, 142, 143, 79, 80, + 142, 143, 473, 91, 144, 116, 144, 118, 479, 146, + 866, 482, 1023, 869, 137, 486, 121, 122, 123, 490, + 491, 492, 493, 494, 495, 496, 537, 538, 125, 143, + 541, 842, 143, 142, 143, 144, 507, 21, 22, 143, + 10, 11, 12, 1015, 515, 127, 16, 124, 32, 126, + 127, 128, 521, 124, 126, 526, 142, 124, 2, 126, + 133, 128, 637, 142, 143, 144, 537, 538, 142, 144, + 541, 125, 32, 544, 144, 546, 547, 548, 549, 550, + 144, 144, 1075, 144, 581, 582, 557, 57, 585, 586, + 124, 144, 126, 134, 128, 566, 40, 41, 42, 43, + 44, 801, 144, 47, 134, 144, 577, 578, 702, 703, + 777, 588, 144, 144, 1033, 92, 93, 94, 134, 588, + 588, 91, 144, 144, 1117, 144, 134, 10, 11, 600, + 601, 580, 144, 604, 144, 144, 607, 142, 143, 144, + 137, 143, 145, 144, 615, 622, 73, 125, 118, 124, + 142, 135, 136, 137, 138, 139, 627, 141, 142, 143, + 125, 125, 132, 126, 635, 146, 125, 137, 639, 638, + 142, 642, 669, 56, 142, 135, 136, 137, 138, 139, + 657, 141, 142, 143, 127, 696, 142, 142, 657, 657, + 73, 144, 142, 1186, 142, 57, 137, 146, 124, 1118, + 1211, 1212, 1213, 127, 1015, 10, 150, 10, 91, 10, + 291, 292, 126, 684, 134, 125, 687, 126, 146, 137, + 137, 104, 145, 694, 126, 696, 126, 669, 817, 112, + 113, 702, 703, 116, 32, 126, 32, 145, 709, 126, + 137, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, + 204, 205, 144, 207, 142, 1121, 124, 211, 142, 146, + 781, 142, 142, 784, 785, 73, 143, 143, 124, 128, + 1136, 1137, 1138, 1202, 125, 125, 1297, 85, 125, 128, + 88, 142, 1303, 91, 765, 133, 144, 378, 133, 776, + 133, 133, 144, 10, 775, 125, 777, 776, 776, 107, + 781, 782, 1210, 784, 785, 792, 793, 794, 142, 263, + 142, 144, 143, 10, 11, 802, 10, 11, 12, 145, + 801, 842, 16, 144, 146, 4, 125, 1256, 142, 420, + 811, 137, 138, 139, 146, 141, 142, 143, 10, 1205, + 821, 126, 10, 1209, 10, 126, 125, 1024, 1214, 142, + 144, 142, 125, 874, 308, 144, 146, 864, 810, 56, + 812, 145, 145, 57, 637, 145, 144, 144, 322, 323, + 146, 644, 144, 825, 826, 827, 73, 829, 830, 831, + 832, 145, 144, 144, 144, 866, 144, 46, 869, 142, + 133, 482, 1258, 874, 91, 133, 90, 91, 133, 490, + 491, 492, 493, 494, 495, 142, 133, 104, 144, 68, + 125, 134, 134, 134, 144, 112, 113, 1283, 134, 116, + 144, 80, 142, 124, 118, 144, 380, 10, 11, 10, + 1296, 144, 144, 126, 126, 526, 126, 144, 132, 142, + 142, 100, 125, 137, 144, 144, 142, 142, 142, 10, + 126, 110, 134, 544, 145, 546, 547, 548, 549, 550, + 144, 134, 142, 134, 418, 1064, 1065, 1066, 1067, 1068, + 144, 1070, 134, 56, 144, 1079, 145, 431, 142, 142, + 701, 140, 142, 142, 143, 19, 20, 21, 22, 144, + 73, 144, 249, 536, 1015, 1117, 1018, 978, 32, 1075, + 1186, 268, 637, 1015, 638, 521, 811, 842, 91, 600, + 802, 978, 1033, -1, 468, -1, 607, 327, -1, -1, + 179, 104, -1, -1, -1, 479, -1, -1, -1, 112, + 113, -1, -1, 116, 1015, 220, 221, 222, 223, 224, + -1, -1, 1023, 1024, 635, -1, -1, -1, -1, 1036, + -1, 1038, 1033, 1040, -1, -1, 1043, 1044, 1045, -1, + 10, 11, 1069, -1, -1, -1, 1165, 1166, 1167, 1168, + 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, + 1179, 1180, 1181, 1182, 1183, -1, -1, -1, -1, -1, + -1, 250, -1, 252, 253, 254, 687, 1118, 1079, 133, + 134, 135, 136, 137, 138, 139, 56, 141, 142, 143, + -1, 270, 566, -1, -1, 274, -1, 1069, -1, -1, + -1, -1, 281, 73, 283, -1, 1225, -1, -1, -1, + -1, -1, 291, 292, -1, -1, -1, 1118, -1, -1, + 1121, 91, -1, -1, -1, -1, 1127, -1, -1, -1, + 11, -1, -1, -1, 104, 1136, 1137, 1138, -1, -1, + 614, 615, 112, 113, -1, -1, 620, -1, 327, 354, + -1, 356, 357, 358, 359, 360, 1275, 1184, 10, 11, + 12, 1202, -1, -1, 16, 370, -1, -1, 373, 374, + 51, -1, 53, 54, 55, -1, -1, -1, -1, 1151, + 1152, 1153, 1154, 1155, 1156, -1, -1, -1, -1, -1, + -1, 665, 666, 667, 668, -1, 670, -1, -1, 80, + 81, 1202, 381, -1, 1205, 57, -1, -1, 1209, -1, + 1211, 1212, 1213, 1214, -1, 1256, -1, 98, 99, -1, + 694, -1, -1, 1250, 1251, -1, 1253, 1254, -1, -1, + -1, -1, -1, 114, -1, 709, -1, -1, 119, 91, + 16, 17, 18, 19, 20, 21, 22, 426, -1, -1, + -1, -1, -1, -1, -1, 1256, 32, 1258, -1, -1, + 1287, 1288, 1289, 1290, -1, -1, 118, -1, 473, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 620, -1, 622, -1, -1, -1, -1, -1, -1, - 1086, 1087, 15, 16, 17, 18, 19, 20, 21, 22, - 1061, -1, 1063, -1, -1, -1, 119, 1068, 31, -1, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 1082, 135, 136, 137, 138, -1, -1, 667, -1, - -1, 1092, 974, 975, 976, 977, 978, 979, 980, 981, - 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, - 992, -1, -1, 692, 693, 694, 695, 696, 697, 698, - 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, - 709, 710, 711, 712, -1, 714, 3, 4, 5, 6, - -1, 8, 9, 10, 11, -1, -1, 14, 1030, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, -1, 135, 136, 137, -1, -1, -1, 141, 46, - 47, -1, -1, 50, -1, 52, 53, 54, 55, 56, - -1, 58, 1074, -1, 61, 62, -1, -1, 65, -1, - -1, -1, -1, 70, 71, -1, -1, -1, 1059, -1, - 77, 78, 79, -1, -1, -1, -1, -1, 85, -1, - 87, -1, -1, -1, -1, 92, -1, 94, 95, 96, - -1, -1, 99, 100, -1, -1, 103, -1, -1, 106, - 107, 108, -1, -1, 111, -1, 113, 3, 4, 5, - 6, -1, 8, 9, 10, 11, -1, -1, 14, 126, - -1, -1, -1, 130, -1, -1, -1, 134, -1, 136, - -1, 850, -1, 140, -1, -1, -1, 15, 16, 17, - 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, - 46, 47, -1, 31, 50, -1, 52, 53, 54, 55, - 56, -1, 58, -1, -1, 61, 62, -1, -1, 65, - -1, -1, -1, -1, 70, 71, -1, -1, -1, -1, - -1, 77, 78, 79, -1, -1, -1, -1, 907, 85, - -1, 87, -1, -1, -1, 914, 92, -1, 94, 95, - 96, -1, -1, 99, 100, -1, -1, 103, -1, -1, - 106, 107, 108, -1, -1, 111, -1, 113, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 126, -1, -1, 952, 130, -1, -1, -1, 134, -1, - 136, -1, -1, -1, 140, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, -1, 135, 136, 137, - -1, -1, -1, 141, -1, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 994, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, - 1009, -1, -1, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - -1, -1, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, -1, 65, -1, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, -1, -1, -1, -1, 83, 84, 85, -1, 87, - 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 98, 99, 100, -1, 102, 103, 104, 105, 106, 107, - 108, 109, 110, 111, 112, 113, 114, -1, -1, -1, - 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, - 138, 139, 140, 141, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, -1, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, - -1, -1, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, -1, - -1, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, -1, 65, -1, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - -1, -1, -1, -1, 83, 84, 85, -1, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 99, 100, -1, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, -1, -1, -1, 118, - 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, - 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, - -1, 140, 141, 3, 4, 5, 6, -1, 8, 9, - 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, + 132, -1, 1283, -1, -1, 137, -1, -1, -1, -1, + 142, 765, -1, 767, -1, 1296, 1297, 1064, 1065, 1066, + 1067, 1068, 1303, 1070, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 15, 16, 17, 18, 19, 20, + 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 32, -1, 15, 16, 17, 18, 19, 20, 21, + 22, 520, -1, 522, -1, -1, -1, -1, -1, -1, + 32, -1, -1, -1, 130, 131, 132, 536, 832, 135, + 136, 137, 138, 139, -1, 141, 142, 143, -1, 843, + 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, + 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, + -1, 865, -1, -1, -1, -1, -1, -1, 1165, 1166, + 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, + 1177, 1178, 1179, 1180, 1181, 1182, 1183, -1, -1, 3, + 4, 5, 6, -1, 8, 9, 10, 11, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, -1, + 141, 142, 143, 125, -1, 146, -1, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, 1225, 141, + 142, 143, 144, 47, 48, -1, -1, 51, -1, 53, + 54, 55, 56, 57, -1, 59, 60, -1, -1, 63, + 64, -1, -1, 67, -1, -1, -1, -1, 72, 73, + 74, -1, -1, -1, -1, -1, 80, 81, -1, -1, + -1, -1, -1, 87, -1, 89, -1, 91, 1275, -1, + -1, -1, 96, -1, 98, 99, 100, -1, -1, 103, + 104, -1, 701, -1, 108, -1, -1, 111, 112, 113, + 114, -1, -1, 117, 1008, 119, 3, 4, 5, 6, + -1, 8, 9, 10, 11, -1, -1, 14, 132, -1, + -1, 135, 136, 137, -1, -1, 140, -1, 142, 143, + -1, -1, -1, 147, -1, -1, -1, -1, 15, 16, + 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, + 47, 48, -1, -1, 51, 32, 53, 54, 55, 56, + 57, -1, 59, 60, -1, -1, 63, 64, -1, 778, + 67, -1, -1, -1, -1, 72, 73, 74, -1, -1, + -1, 1085, -1, 80, 81, -1, 795, -1, -1, 798, + 87, -1, 89, -1, 91, -1, -1, -1, 95, 96, + -1, 98, 99, 100, -1, -1, 103, 104, -1, -1, + -1, 108, -1, -1, 111, 112, 113, 114, -1, -1, + 117, -1, 119, 1127, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 132, -1, -1, 135, 136, + -1, -1, -1, 140, -1, 142, -1, -1, -1, -1, + 147, -1, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, -1, 141, 142, 143, -1, -1, 146, + -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 1185, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, -1, 1198, -1, -1, -1, -1, -1, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 45, 46, 47, 48, -1, -1, 51, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, -1, 67, -1, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + -1, -1, -1, 85, 86, 87, -1, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, -1, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, 120, -1, + -1, -1, 124, 125, 126, 127, 128, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, + 142, 143, 144, 145, 146, 147, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, -1, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, -1, -1, + -1, -1, -1, -1, -1, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, -1, -1, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, -1, + 67, -1, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, -1, -1, -1, 85, 86, + 87, -1, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, -1, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, 120, -1, -1, -1, 124, 125, 126, + 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, -1, 146, + 147, 3, 4, 5, 6, -1, 8, 9, 10, 11, + -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 16, 17, 18, 19, 20, 21, - 22, -1, -1, -1, -1, -1, 46, 47, -1, 31, - 50, -1, 52, 53, 54, 55, 56, -1, 58, -1, - -1, 61, 62, -1, -1, 65, -1, -1, -1, -1, - 70, 71, -1, -1, -1, -1, -1, 77, 78, 79, - -1, -1, -1, -1, -1, 85, -1, 87, -1, -1, - -1, -1, -1, -1, 94, 95, 96, -1, -1, 99, - 100, -1, -1, 103, -1, -1, 106, 107, 108, -1, - -1, 111, -1, 113, 3, 4, 5, 6, -1, 8, - 9, 10, 11, -1, -1, -1, 126, -1, -1, -1, - 130, 131, -1, -1, 134, -1, 136, -1, -1, -1, - 140, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, -1, 135, 136, 137, -1, 46, 47, 141, - -1, 50, -1, 52, 53, 54, 55, 56, -1, 58, - -1, -1, 61, 62, -1, -1, 65, -1, -1, -1, - -1, 70, 71, -1, -1, -1, -1, -1, 77, 78, - 79, -1, -1, -1, -1, -1, 85, -1, 87, -1, - -1, -1, -1, 92, -1, 94, 95, 96, -1, -1, - 99, 100, -1, -1, 103, -1, -1, 106, 107, 108, - -1, -1, 111, -1, 113, 3, 4, 5, 6, -1, - 8, 9, 10, 11, -1, -1, -1, 126, -1, -1, - -1, 130, -1, -1, -1, 134, -1, 136, -1, -1, - -1, 140, 17, 18, 19, 20, 21, 22, -1, -1, - -1, 50, -1, 52, 53, 54, 31, -1, 46, -1, - -1, -1, 50, -1, 52, 53, 54, -1, -1, -1, - -1, 59, 60, 61, 62, -1, -1, -1, 77, 78, - 79, -1, 70, 71, -1, -1, -1, -1, -1, 77, - 78, -1, -1, -1, -1, 94, 95, 85, -1, 87, - -1, -1, -1, -1, -1, -1, 94, 95, 96, 108, - -1, 99, -1, -1, 113, 103, 3, 4, 5, 6, - 108, 8, 9, 10, 11, 113, 21, 22, -1, -1, - 118, -1, -1, -1, -1, -1, 31, 136, 126, -1, - -1, -1, 130, 131, -1, -1, 134, -1, 136, 124, - 125, 126, 140, -1, 129, 130, 131, 132, 133, 46, - 135, 136, 137, 50, -1, 52, 53, 54, -1, -1, - -1, -1, -1, -1, 61, 62, -1, -1, -1, -1, - -1, -1, -1, 70, 71, -1, -1, -1, -1, -1, - 77, 78, -1, -1, -1, -1, -1, -1, 85, -1, - 87, -1, -1, -1, -1, -1, -1, 94, 95, 96, - -1, -1, 99, -1, -1, -1, 103, 3, 4, 5, - 6, 108, 8, 9, 10, 11, 113, -1, -1, -1, - -1, -1, -1, -1, 129, 130, 131, 132, 133, 126, - 135, 136, 137, 130, 131, -1, -1, 134, -1, 136, - -1, 138, -1, 140, -1, -1, -1, -1, -1, -1, - 46, -1, -1, -1, 50, -1, 52, 53, 54, -1, - -1, -1, -1, -1, -1, 61, 62, -1, -1, -1, - -1, -1, -1, -1, 70, 71, -1, -1, -1, -1, - -1, 77, 78, -1, -1, -1, -1, -1, -1, 85, - -1, 87, -1, -1, -1, -1, -1, -1, 94, 95, - 96, -1, -1, 99, -1, -1, -1, 103, 3, 4, - 5, 6, 108, 8, 9, 10, 11, 113, -1, -1, - -1, -1, 118, -1, -1, -1, -1, -1, -1, -1, - 126, -1, -1, -1, 130, 131, -1, -1, 134, -1, - 136, -1, -1, -1, 140, -1, -1, -1, -1, -1, - -1, 46, -1, -1, -1, 50, -1, 52, 53, 54, - -1, -1, -1, -1, -1, -1, 61, 62, -1, -1, - -1, -1, -1, -1, -1, 70, 71, -1, -1, -1, - -1, -1, 77, 78, -1, -1, -1, -1, -1, -1, - 85, -1, 87, -1, -1, -1, -1, -1, -1, 94, - 95, 96, -1, -1, 99, -1, -1, -1, 103, 3, - 4, 5, 6, 108, 8, 9, 10, 11, 113, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 126, -1, -1, -1, 130, 131, -1, -1, 134, - -1, 136, -1, 138, -1, 140, -1, -1, -1, -1, - -1, -1, 46, -1, -1, -1, 50, -1, 52, 53, - 54, -1, -1, -1, -1, -1, -1, 61, 62, -1, - -1, -1, -1, -1, -1, -1, 70, 71, -1, -1, - -1, -1, -1, 77, 78, -1, -1, -1, -1, -1, - -1, 85, -1, 87, -1, -1, -1, -1, -1, -1, - 94, 95, 96, -1, -1, 99, -1, -1, -1, 103, - 3, 4, 5, 6, 108, 8, 9, 10, 11, 113, - -1, -1, -1, -1, 118, -1, -1, -1, -1, -1, - -1, -1, 126, -1, -1, -1, 130, 131, -1, -1, - 134, -1, 136, -1, -1, -1, 140, -1, -1, -1, - -1, -1, -1, 46, -1, -1, -1, 50, -1, 52, - 53, 54, -1, -1, -1, -1, -1, -1, 61, 62, - -1, -1, -1, -1, -1, -1, -1, 70, 71, -1, - -1, -1, -1, -1, 77, 78, -1, -1, -1, -1, - -1, -1, 85, -1, 87, -1, -1, -1, -1, -1, - -1, 94, 95, 96, -1, -1, 99, -1, -1, -1, - 103, 3, 4, 5, 6, 108, 8, 9, 10, 11, - 113, -1, 6, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 126, -1, -1, -1, 130, 131, -1, - -1, 134, -1, 136, -1, 138, -1, 140, -1, -1, - -1, -1, -1, -1, 46, -1, -1, -1, 50, -1, - 52, 53, 54, -1, -1, 49, -1, -1, -1, 61, - 62, -1, -1, 57, -1, -1, -1, -1, 70, 71, - -1, -1, 66, 67, 68, 77, 78, -1, -1, -1, - -1, -1, 76, 85, -1, 87, -1, -1, -1, 83, - -1, -1, 94, 95, 96, -1, -1, 99, 92, -1, - -1, 103, -1, 97, -1, -1, 108, -1, -1, -1, - -1, 113, -1, -1, -1, -1, 110, -1, 112, -1, - -1, -1, 0, -1, 126, -1, -1, -1, 130, 131, - 6, -1, 134, -1, 136, -1, -1, -1, 140, 15, - 16, 17, 18, 19, 20, 21, 22, -1, -1, -1, - -1, -1, -1, -1, -1, 31, -1, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, -1, - 48, 49, -1, -1, -1, -1, -1, -1, -1, 57, - -1, -1, -1, -1, 60, -1, 64, -1, 66, 67, - 68, 69, -1, -1, 72, -1, -1, -1, 76, -1, - -1, -1, 80, 81, 82, 83, 84, -1, -1, 85, - -1, 89, 90, 91, 92, -1, -1, -1, -1, 97, - 98, -1, -1, 101, -1, 10, 11, 105, -1, -1, - -1, 109, 110, -1, 112, -1, -1, -1, -1, -1, - -1, -1, 120, 119, -1, -1, 122, -1, 124, 125, - 126, 127, 128, 129, 130, 131, 132, 133, 134, -1, - 136, 137, 47, -1, 140, 50, -1, 52, 53, 54, - 55, 56, -1, 58, -1, -1, 61, -1, -1, -1, - 65, -1, -1, -1, -1, -1, 71, -1, -1, -1, - -1, -1, 77, 78, 79, 10, 11, -1, -1, -1, - -1, -1, -1, 88, -1, -1, -1, -1, -1, 94, - 95, -1, -1, -1, -1, 100, -1, -1, -1, -1, - -1, 106, 107, 108, -1, -1, 111, -1, 113, -1, - -1, -1, 47, 118, -1, 50, -1, 52, 53, 54, - 55, 56, -1, 58, -1, -1, 61, -1, -1, 134, - 65, -1, -1, -1, -1, -1, 71, 10, 11, -1, - -1, -1, 77, 78, 79, -1, -1, -1, -1, -1, - -1, -1, -1, 88, -1, -1, -1, -1, -1, 94, - 95, -1, -1, -1, -1, 100, -1, -1, -1, -1, - -1, 106, 107, 108, 47, -1, 111, 50, 113, 52, - 53, 54, 55, 56, -1, 58, -1, -1, 61, -1, - -1, -1, 65, -1, -1, -1, -1, -1, 71, 134, - -1, -1, -1, -1, 77, 78, 79, 15, 16, 17, - 18, 19, 20, 21, 22, 88, -1, -1, -1, -1, - -1, 94, 95, 31, -1, -1, -1, 100, -1, -1, - -1, -1, -1, 106, 107, 108, -1, -1, 111, -1, - 113, 15, 16, 17, 18, 19, 20, 21, 22, -1, - -1, -1, -1, -1, -1, -1, -1, 31, -1, -1, - -1, 134, 15, 16, 17, 18, 19, 20, 21, 22, - -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, - 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, - -1, -1, -1, -1, -1, -1, 31, 15, 16, 17, + 22, -1, -1, -1, -1, 47, 48, -1, -1, 51, + 32, 53, 54, 55, 56, 57, -1, 59, 60, -1, + -1, 63, 64, -1, -1, 67, -1, -1, -1, -1, + 72, 73, 74, -1, -1, -1, -1, -1, 80, 81, + -1, -1, -1, -1, -1, 87, -1, 89, -1, 91, + -1, -1, -1, 95, 96, -1, 98, 99, 100, -1, + -1, 103, 104, -1, -1, -1, 108, -1, -1, 111, + 112, 113, 114, -1, -1, 117, -1, 119, 3, 4, + 5, 6, -1, 8, 9, 10, 11, -1, -1, -1, + 132, -1, -1, 135, 136, -1, -1, -1, 140, -1, + 142, -1, -1, -1, -1, 147, -1, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, -1, 141, + 142, 143, 47, -1, 146, -1, 51, -1, 53, 54, + 55, -1, -1, -1, 59, -1, 61, 62, 63, 64, + 51, -1, 53, 54, 55, -1, -1, 72, 73, 74, + -1, -1, 63, -1, -1, 80, 81, -1, -1, -1, + -1, -1, 87, -1, 89, -1, 91, -1, -1, 80, + 81, 96, -1, 98, 99, 100, -1, -1, 103, -1, + -1, -1, -1, 108, 10, 11, 111, 98, 99, 114, + 3, 4, 5, 6, 119, 8, 9, 10, 11, 124, + -1, -1, -1, 114, -1, -1, -1, 132, 119, -1, + 135, 136, 137, -1, -1, 140, -1, 142, 143, -1, + -1, -1, 147, -1, -1, 51, -1, 53, 54, 55, + -1, 142, -1, -1, 47, -1, -1, 63, 51, -1, + 53, 54, 55, -1, -1, -1, 59, -1, 74, -1, + 63, 64, -1, -1, 80, 81, -1, -1, -1, 72, + 73, 74, -1, -1, -1, -1, -1, 80, 81, -1, + -1, -1, 98, 99, 87, -1, 89, -1, 91, -1, + -1, -1, -1, 96, -1, 98, 99, 100, 114, -1, + 103, 117, -1, 119, -1, 108, -1, -1, 111, -1, + -1, 114, 3, 4, 5, 6, 119, 8, 9, 10, + 11, -1, -1, 51, -1, 53, 54, 55, -1, 132, + -1, -1, 135, 136, 137, -1, -1, 140, -1, 142, + 143, 144, -1, -1, 147, -1, -1, -1, -1, -1, + -1, -1, 80, 81, -1, -1, 47, -1, -1, -1, + 51, -1, 53, 54, 55, -1, -1, -1, 59, -1, + 98, 99, 63, 64, -1, -1, 10, 11, -1, -1, + -1, 72, 73, 74, -1, -1, 114, -1, -1, 80, + 81, 119, -1, -1, -1, -1, 87, -1, 89, -1, + 91, -1, -1, -1, -1, 96, -1, 98, 99, 100, + -1, -1, 103, -1, 142, -1, -1, 108, -1, -1, + 111, -1, 56, 114, 3, 4, 5, 6, 119, 8, + 9, 10, 11, 124, -1, -1, -1, -1, -1, 73, + -1, 132, -1, -1, 135, 136, 137, -1, -1, 140, + -1, 142, 143, -1, -1, -1, 147, 91, 92, 93, + 94, -1, -1, -1, -1, -1, -1, -1, 47, -1, + 104, -1, 51, -1, 53, 54, 55, -1, 112, 113, + 59, -1, 116, -1, 63, 64, 51, -1, 53, 54, + 55, -1, -1, 72, 73, 74, -1, -1, -1, -1, + -1, 80, 81, -1, -1, -1, -1, -1, 87, -1, + 89, -1, 91, -1, -1, 80, 81, 96, -1, 98, + 99, 100, -1, -1, 103, -1, -1, -1, -1, 108, + -1, -1, 111, 98, 99, 114, 3, 4, 5, 6, + 119, 8, 9, 10, 11, -1, -1, -1, -1, 114, + -1, -1, -1, 132, 119, -1, 135, 136, 137, -1, + -1, 140, -1, 142, 143, 144, -1, -1, 147, -1, + -1, 51, -1, 53, 54, 55, -1, 142, -1, -1, + 47, -1, -1, -1, 51, -1, 53, 54, 55, -1, + -1, -1, 59, -1, -1, -1, 63, 64, -1, -1, + 80, 81, -1, -1, -1, 72, 73, 74, -1, -1, + -1, -1, -1, 80, 81, -1, -1, -1, 98, 99, + 87, -1, 89, -1, 91, -1, -1, -1, -1, 96, + -1, 98, 99, 100, 114, -1, 103, -1, -1, 119, + -1, 108, -1, -1, 111, -1, -1, 114, 3, 4, + 5, 6, 119, 8, 9, 10, 11, 124, -1, -1, + -1, -1, 142, -1, -1, 132, -1, -1, 135, 136, + 137, -1, -1, 140, -1, 142, 143, -1, -1, -1, + 147, -1, -1, 51, -1, 53, 54, 55, -1, -1, + -1, -1, 47, -1, -1, 63, 51, -1, 53, 54, + 55, -1, -1, -1, 59, -1, -1, -1, 63, 64, + -1, -1, 80, 81, -1, -1, -1, 72, 73, 74, + -1, -1, -1, -1, -1, 80, 81, -1, -1, -1, + 98, 99, 87, -1, 89, -1, 91, -1, -1, -1, + -1, 96, -1, 98, 99, 100, 114, -1, 103, -1, + -1, 119, -1, 108, -1, -1, 111, -1, -1, 114, + 3, 4, 5, 6, 119, 8, 9, 10, 11, -1, + -1, 51, -1, 53, 54, 55, -1, 132, -1, -1, + 135, 136, 137, -1, -1, 140, -1, 142, 143, 144, + -1, -1, 147, -1, -1, -1, -1, -1, -1, -1, + 80, 81, -1, -1, 47, -1, -1, -1, 51, -1, + 53, 54, 55, -1, -1, -1, 59, -1, 98, 99, + 63, 64, -1, -1, -1, -1, -1, -1, -1, 72, + 73, 74, -1, -1, 114, -1, -1, 80, 81, 119, + -1, -1, -1, -1, 87, -1, 89, -1, 91, -1, + -1, -1, -1, 96, -1, 98, 99, 100, -1, -1, + 103, -1, -1, -1, -1, 108, 10, 11, 111, 21, + 22, 114, 3, 4, 5, 6, 119, 8, 9, 10, + 32, -1, -1, -1, -1, -1, -1, -1, -1, 132, + -1, -1, 135, 136, 137, -1, -1, 140, -1, 142, + 143, -1, -1, -1, 147, -1, -1, 51, -1, 53, + 54, 55, 56, 57, -1, -1, 47, -1, -1, 63, + -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, + 74, -1, -1, 64, -1, -1, 80, 81, -1, -1, + -1, 72, 73, -1, -1, -1, -1, -1, -1, 0, + -1, -1, -1, -1, 98, 99, -1, -1, 89, -1, + 91, -1, -1, -1, -1, 96, -1, -1, 112, 100, + 114, -1, 103, 117, -1, 119, -1, 108, -1, -1, + -1, -1, -1, 135, 136, 137, 138, 139, -1, 141, + 142, 143, -1, -1, -1, -1, -1, -1, 49, 50, + -1, 132, -1, -1, 135, 136, 137, 58, -1, 140, + -1, 142, 143, -1, -1, 66, 147, 68, 69, 70, + 71, -1, -1, -1, 75, -1, -1, -1, 79, -1, + -1, 82, 83, 84, 85, 86, -1, -1, -1, -1, + -1, 92, 93, 94, 95, -1, -1, -1, -1, -1, + 101, 102, -1, -1, 105, 106, -1, -1, -1, 110, + -1, -1, -1, -1, 115, 116, -1, 118, 6, -1, + -1, -1, -1, 10, 11, 126, -1, 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, - -1, -1, -1, 31, -1, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, -1, 135, 136, 137, - 138, 15, 16, 17, 18, 19, 20, 21, 22, -1, - -1, -1, -1, -1, -1, -1, -1, 31, -1, 123, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - -1, 135, 136, 137, 138, -1, -1, -1, 121, -1, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, -1, 135, 136, 137, 120, -1, -1, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, -1, - 135, 136, 137, 121, -1, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, -1, 135, 136, 137, + -1, -1, 143, -1, 32, -1, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 45, -1, -1, + -1, 48, -1, -1, 51, -1, 53, 54, 55, 56, + 57, -1, -1, 60, 62, -1, 63, -1, -1, -1, + 67, -1, -1, -1, -1, -1, -1, 74, -1, -1, + -1, -1, -1, 80, 81, -1, -1, -1, -1, 87, + -1, -1, -1, 90, -1, -1, -1, -1, -1, -1, + -1, 98, 99, -1, -1, -1, -1, 104, -1, 10, + 11, -1, -1, -1, -1, 112, 113, 114, -1, -1, + 117, -1, 119, -1, -1, -1, -1, 125, -1, -1, + 128, -1, 130, 131, 132, 133, 134, 135, 136, 137, + 138, 139, 140, 140, 142, 143, -1, 48, -1, 147, + 51, -1, 53, 54, 55, 56, 57, -1, -1, 60, + -1, -1, 63, -1, -1, -1, 67, -1, -1, -1, + -1, -1, -1, 74, -1, -1, -1, -1, -1, 80, + 81, 10, 11, 19, 20, 21, 22, -1, -1, 90, + -1, -1, -1, -1, -1, -1, 32, 98, 99, -1, + -1, -1, -1, 104, -1, -1, -1, -1, -1, -1, + -1, 112, 113, 114, -1, -1, 117, -1, 119, 48, + -1, -1, 51, 124, 53, 54, 55, 56, 57, -1, + -1, 60, -1, -1, 63, -1, -1, -1, 67, 140, + -1, -1, -1, -1, -1, 74, -1, -1, -1, -1, + -1, 80, 81, -1, -1, -1, -1, -1, -1, -1, + -1, 90, -1, -1, -1, -1, -1, -1, -1, 98, + 99, -1, -1, -1, -1, 104, -1, -1, -1, -1, + -1, -1, -1, 112, 113, 114, -1, -1, 117, -1, + 119, 15, 16, 17, 18, 19, 20, 21, 22, 135, + 136, 137, 138, 139, -1, 141, 142, 143, 32, -1, + -1, 140, 15, 16, 17, 18, 19, 20, 21, 22, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, - -1, -1, -1, -1, -1, 119, 31, -1, -1, 123, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - -1, 135, 136, 137, 15, 16, 17, 18, 19, 20, - 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, - 31, 15, 16, 17, 18, 19, 20, 21, 22, -1, - -1, -1, -1, -1, -1, -1, -1, 31, 15, 16, + -1, -1, -1, -1, -1, -1, -1, 32, 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, - -1, -1, -1, -1, 31, 16, 17, 18, 19, 20, - 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, - 31, -1, -1, -1, -1, -1, -1, -1, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, -1, - 135, 136, 137, 16, 17, 18, 19, 20, 21, 22, - -1, -1, -1, -1, -1, -1, -1, -1, 31, -1, - -1, -1, 123, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, -1, 135, 136, 137, 121, -1, 123, - 124, 125, 126, -1, -1, 129, 130, 131, 132, 133, - -1, 135, 136, 137, -1, -1, 123, 124, 125, 126, - -1, -1, 129, 130, 131, 132, 133, -1, 135, 136, - 137, -1, -1, 124, 125, 126, 127, 128, 129, 130, - 131, 132, 133, -1, 135, 136, 137, 17, 18, 19, - 20, 21, 22, -1, -1, -1, -1, -1, -1, -1, - -1, 31, -1, -1, 50, -1, 52, 53, 54, -1, - -1, 124, 125, 126, -1, -1, 129, 130, 131, 132, - 133, -1, 135, 136, 137, 17, 18, 19, 20, 21, - 22, 77, 78, 79, -1, -1, -1, -1, -1, 31, - 17, 18, 19, 20, 21, 22, -1, -1, 94, 95, - -1, -1, -1, -1, 31, 17, 18, 19, 20, 21, - 22, -1, 108, -1, -1, -1, -1, 113, -1, 31, - 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, - -1, -1, -1, -1, 31, -1, -1, -1, -1, -1, - 136, -1, -1, -1, -1, 125, 126, 127, 128, 129, - 130, 131, 132, 133, -1, 135, 136, 137, 17, 18, + -1, -1, -1, -1, -1, 32, 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, - -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, - 19, 20, 21, 22, 126, 127, 128, 129, 130, 131, - 132, 133, 31, 135, 136, 137, -1, -1, -1, -1, - 127, 128, 129, 130, 131, 132, 133, -1, 135, 136, - 137, -1, -1, 125, 126, -1, -1, 129, 130, 131, - 132, 133, -1, 135, 136, 137, -1, -1, -1, 126, - -1, -1, 129, 130, 131, 132, 133, -1, 135, 136, - 137, 19, 20, 21, 22, -1, -1, -1, -1, -1, - -1, -1, -1, 31, -1, -1, -1, 50, -1, 52, - 53, 54, -1, -1, -1, -1, -1, -1, -1, -1, - 129, 130, 131, 132, 133, -1, 135, 136, 137, 10, - 11, -1, -1, -1, 77, 78, 79, -1, 127, 128, - 129, 130, 131, 132, 133, -1, 135, 136, 137, 10, - 11, 94, 95, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 108, 47, -1, -1, 50, - 113, 52, 53, 54, 55, -1, -1, 58, -1, -1, - 61, -1, -1, -1, 65, -1, -1, -1, -1, 50, - 71, 52, 53, 54, 55, 56, 77, 78, 79, -1, - 61, 129, 130, 131, 132, 133, -1, 135, 136, 137, - 71, 10, 11, 94, 95, -1, 77, 78, 79, 100, - -1, -1, -1, -1, -1, 106, 107, 108, -1, -1, - 111, -1, 113, 94, 95, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 106, -1, 108, -1, -1, - 111, 50, 113, 52, 53, 54, -1, -1, -1, -1, - -1, 11, 61, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 71, -1, -1, -1, -1, -1, 77, 78, - 79, -1, -1, -1, -1, -1, -1, -1, -1, 50, - -1, 52, 53, 54, -1, 94, 95, 47, -1, -1, - 50, -1, 52, 53, 54, 55, 56, -1, 58, 108, - -1, 61, 111, -1, 113, 65, 77, 78, 79, -1, - -1, 71, -1, 11, -1, -1, -1, 77, 78, 79, - -1, -1, -1, 94, 95, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 94, 95, -1, 108, -1, -1, - 100, 50, 113, 52, 53, 54, 106, 107, 108, 47, - -1, 111, 50, 113, 52, 53, 54, 55, 56, -1, - 58, -1, 71, 61, 11, 136, -1, 65, 77, 78, - 79, -1, -1, 71, -1, 11, -1, -1, -1, 77, - 78, 79, -1, -1, -1, 94, 95, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 94, 95, -1, 108, - -1, -1, 100, 50, 113, 52, 53, 54, 106, 107, - 108, 47, -1, 111, 50, 113, 52, 53, 54, 55, - -1, -1, 58, -1, -1, 61, -1, -1, -1, 65, - 77, 78, 79, -1, -1, 71, -1, 11, -1, -1, - -1, 77, 78, 79, -1, -1, -1, 94, 95, -1, - -1, -1, -1, -1, -1, -1, 92, 11, 94, 95, - -1, 108, -1, -1, 100, -1, 113, -1, -1, -1, - 106, 107, 108, 47, -1, 111, 50, 113, 52, 53, - 54, 55, -1, -1, 58, -1, -1, 61, -1, -1, - -1, 65, -1, -1, -1, -1, 50, 71, 52, 53, - 54, 55, -1, 77, 78, 79, -1, 61, -1, -1, - -1, 65, -1, -1, -1, -1, -1, 71, -1, -1, - 94, 95, -1, 77, 78, 79, 100, -1, -1, -1, - -1, -1, 106, 107, 108, -1, -1, 111, -1, 113, - 94, 95, 48, 49, -1, -1, 100, -1, -1, -1, - -1, 57, 106, 107, 108, -1, -1, 111, 64, 113, - 66, 67, 68, 69, -1, -1, 72, -1, -1, -1, - 76, -1, -1, -1, 80, 81, 82, 83, 84, -1, - -1, -1, -1, 89, 90, 91, 92, -1, -1, -1, - -1, 97, 98, -1, -1, 101, -1, -1, -1, 105, - -1, -1, -1, 109, 110, -1, 112, 48, 49, -1, - -1, -1, -1, -1, 120, -1, 57, -1, -1, -1, - -1, -1, -1, 64, -1, 66, 67, 68, 69, -1, - -1, 72, -1, 139, -1, 76, -1, -1, -1, 80, - 81, 82, 83, 84, -1, -1, -1, -1, 89, 90, - 91, 92, -1, -1, -1, -1, 97, 98, -1, -1, - 101, -1, -1, -1, 105, -1, -1, -1, 109, 110, - -1, 112, 48, 49, -1, -1, -1, -1, -1, 120, - -1, 57, -1, -1, -1, -1, -1, -1, 64, -1, - 66, 67, 68, 69, -1, -1, 72, -1, 139, -1, - 76, -1, -1, -1, 80, 81, 82, 83, 84, -1, - -1, -1, -1, 89, 90, 91, 92, -1, -1, -1, - -1, 97, 98, -1, -1, 101, -1, -1, -1, 105, - -1, -1, -1, 109, 110, -1, 112, 48, 49, -1, - -1, -1, -1, -1, 120, -1, 57, -1, -1, -1, - -1, -1, -1, 64, -1, 66, 67, 68, 69, -1, - -1, 72, -1, 139, -1, 76, -1, -1, -1, 80, - 81, 82, 83, 84, -1, -1, -1, -1, 89, 90, - 91, 92, -1, -1, -1, -1, 97, 98, -1, -1, - 101, -1, -1, -1, 105, -1, -1, -1, 109, 110, - -1, 112, 48, 49, -1, -1, -1, -1, -1, 120, - -1, 57, -1, -1, -1, -1, -1, -1, 64, -1, - 66, 67, 68, 69, -1, -1, 72, -1, 139, -1, - 76, -1, -1, -1, 80, 81, 82, 83, 84, -1, - -1, -1, -1, 89, 90, 91, 92, -1, -1, -1, - -1, 97, 98, -1, -1, 101, -1, -1, -1, 105, - -1, -1, -1, 109, 110, -1, 112, 48, 49, -1, - -1, -1, -1, -1, 120, -1, 57, -1, -1, -1, - -1, -1, -1, 64, -1, 66, 67, 68, 69, -1, - -1, 72, -1, 139, -1, 76, -1, -1, -1, 80, - 81, 82, 83, 84, -1, -1, -1, -1, 89, 90, - 91, 92, -1, -1, -1, -1, 97, 98, -1, -1, - 101, -1, -1, -1, 105, -1, -1, -1, 109, 110, - -1, 112, 48, 49, -1, -1, -1, -1, -1, 120, - -1, 57, -1, -1, -1, -1, -1, -1, 64, -1, - 66, 67, 68, 69, -1, -1, 72, -1, 139, -1, - 76, -1, -1, -1, 80, 81, 82, 83, 84, -1, - -1, -1, -1, 89, 90, 91, 92, -1, -1, -1, - -1, 97, 98, -1, 50, 101, 52, 53, 54, 105, - 49, -1, -1, 109, 110, 61, 112, -1, 57, -1, - -1, -1, -1, -1, 120, 71, -1, 66, 67, 68, - -1, 77, 78, 79, -1, -1, -1, 76, -1, -1, - -1, -1, -1, 139, 83, -1, -1, -1, 94, 95, - -1, -1, -1, 92, -1, -1, -1, -1, 97, 48, - 49, -1, 108, -1, -1, -1, -1, 113, 57, -1, - -1, 110, -1, 112, -1, 64, -1, 66, 67, 68, - 69, -1, -1, 72, -1, -1, -1, 76, 127, -1, - 136, 80, 81, 82, 83, 84, -1, -1, -1, -1, - 89, 90, 91, 92, -1, -1, -1, -1, 97, 98, - -1, 50, 101, 52, 53, 54, 105, 49, -1, -1, - 109, 110, 61, 112, -1, 57, -1, -1, -1, -1, - -1, -1, 71, -1, 66, 67, 68, -1, 77, 78, - 79, -1, -1, -1, 76, 49, -1, -1, -1, -1, - -1, 83, 84, 57, -1, 94, 95, -1, -1, -1, - 92, -1, 66, 67, 68, 97, -1, 49, -1, 108, - -1, -1, 76, -1, 113, 57, -1, -1, 110, 83, - 112, -1, -1, -1, 66, 67, 68, -1, 92, -1, - -1, -1, -1, 97, 76, -1, -1, 101, -1, -1, - -1, 83, -1, -1, -1, -1, 110, -1, 112, -1, - 92, -1, -1, -1, -1, 97, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 110, -1, - 112 + -1, -1, -1, 32, 15, 16, 17, 18, 19, 20, + 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 32, -1, -1, -1, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, -1, 141, 142, 143, + 144, -1, -1, -1, -1, -1, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, -1, 141, 142, + 143, 144, -1, -1, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, -1, 141, 142, 143, 144, + -1, -1, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, -1, 141, 142, 143, 144, -1, -1, + 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, -1, 141, 142, 143, 144, 127, -1, 129, 130, + 131, 132, 133, 134, 135, 136, 137, 138, 139, -1, + 141, 142, 143, 15, 16, 17, 18, 19, 20, 21, + 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 32, -1, 15, 16, 17, 18, 19, 20, 21, 22, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, + 15, 16, 17, 18, 19, 20, 21, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 32, 15, 16, + 17, 18, 19, 20, 21, 22, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 32, 15, 16, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 32, 15, 16, 17, 18, 19, 20, + 21, 22, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 32, -1, -1, 126, -1, -1, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 138, 139, -1, 141, + 142, 143, 125, -1, -1, -1, 129, 130, 131, 132, + 133, 134, 135, 136, 137, 138, 139, -1, 141, 142, + 143, -1, 127, -1, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, -1, 141, 142, 143, -1, + -1, -1, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, -1, 141, 142, 143, -1, -1, -1, + 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, + 139, -1, 141, 142, 143, -1, 127, -1, 129, 130, + 131, 132, -1, -1, 135, 136, 137, 138, 139, -1, + 141, 142, 143, 15, 16, 17, 18, 19, 20, 21, + 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 32, 16, 17, 18, 19, 20, 21, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, + -1, -1, 17, 18, 19, 20, 21, 22, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 32, 17, 18, + 19, 20, 21, 22, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 32, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 17, + 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 32, -1, 17, 18, 19, 20, + 21, 22, -1, -1, -1, -1, -1, 129, 130, 131, + 132, 32, -1, 135, 136, 137, 138, 139, -1, 141, + 142, 143, -1, -1, -1, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, -1, 141, 142, 143, 11, + -1, -1, 14, -1, 16, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, -1, 141, 142, 143, -1, + -1, -1, 131, 132, 133, 134, 135, 136, 137, 138, + 139, -1, 141, 142, 143, -1, 48, -1, -1, 51, + -1, 53, 54, 55, 56, 57, -1, -1, 60, -1, + -1, 63, 130, 131, 132, 67, -1, 135, 136, 137, + 138, 139, 74, 141, 142, 143, -1, -1, 80, 81, + -1, 132, 133, 134, 135, 136, 137, 138, 139, -1, + 141, 142, 143, 95, -1, -1, 98, 99, -1, -1, + -1, -1, 104, 17, 18, 19, 20, 21, 22, -1, + 112, 113, 114, -1, -1, 117, -1, 119, 32, 17, + 18, 19, 20, 21, 22, -1, -1, -1, -1, -1, + 132, -1, -1, -1, 32, 137, 17, 18, 19, 20, + 21, 22, -1, -1, -1, 17, 18, 19, 20, 21, + 22, 32, -1, -1, -1, -1, -1, -1, -1, -1, + 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 133, + 134, 135, 136, 137, 138, 139, -1, 141, 142, 143, + -1, -1, -1, 131, 132, 10, 11, 135, 136, 137, + 138, 139, -1, 141, 142, 143, -1, -1, -1, -1, + -1, 132, -1, -1, 135, 136, 137, 138, 139, -1, + 141, 142, 143, 135, 136, 137, 138, 139, -1, 141, + 142, 143, -1, 48, -1, -1, 51, -1, 53, 54, + 55, 56, -1, -1, -1, 60, -1, -1, 63, -1, + -1, -1, 67, -1, -1, -1, -1, -1, -1, 74, + -1, -1, -1, -1, -1, 80, 81, -1, 11, -1, + -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 98, 99, -1, -1, -1, -1, 104, + -1, -1, -1, -1, -1, -1, -1, 112, 113, 114, + -1, -1, 117, -1, 119, 48, -1, -1, 51, -1, + 53, 54, 55, 56, 57, -1, -1, 60, -1, -1, + 63, -1, -1, -1, 67, -1, -1, -1, -1, -1, + -1, 74, -1, -1, -1, -1, -1, 80, 81, -1, + 11, -1, -1, 14, -1, -1, 50, -1, -1, -1, + -1, -1, 95, -1, 58, 98, 99, -1, -1, -1, + -1, 104, -1, -1, 68, 69, 70, -1, -1, 112, + 113, 114, -1, -1, 117, 79, 119, 48, -1, -1, + 51, 85, 53, 54, 55, 56, 57, -1, -1, 60, + -1, 95, 63, -1, -1, -1, 67, 101, -1, -1, + -1, 105, 106, 74, -1, -1, -1, 11, -1, 80, + 81, -1, 116, -1, 118, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 95, -1, -1, 98, 99, 11, + -1, -1, -1, 104, -1, -1, -1, -1, -1, 143, + -1, 112, 113, 114, 48, -1, 117, 51, 119, 53, + 54, 55, 56, 57, -1, -1, 60, -1, -1, 63, + -1, -1, -1, 67, -1, -1, 48, -1, -1, 51, + 74, 53, 54, 55, 56, 57, 80, 81, 60, -1, + -1, 63, -1, -1, -1, 67, -1, -1, -1, -1, + -1, 95, 74, -1, 98, 99, 11, -1, 80, 81, + 104, -1, -1, -1, -1, -1, -1, -1, 112, 113, + 114, -1, -1, 117, -1, 119, 98, 99, -1, -1, + -1, -1, 104, -1, -1, -1, -1, -1, -1, -1, + 112, 113, 114, 48, -1, 117, 51, 119, 53, 54, + 55, 56, 57, -1, -1, 60, -1, -1, 63, -1, + -1, 11, 67, -1, -1, -1, -1, -1, -1, 74, + -1, -1, -1, -1, -1, 80, 81, -1, -1, -1, + -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 98, 99, -1, -1, -1, 48, 104, + -1, 51, -1, 53, 54, 55, 56, 112, 113, 114, + 60, -1, 117, 63, 119, -1, -1, 67, -1, -1, + 48, -1, -1, 51, 74, 53, 54, 55, 56, 57, + 80, 81, 60, -1, -1, 63, -1, -1, 11, 67, + -1, -1, -1, -1, -1, 95, 74, -1, 98, 99, + -1, -1, 80, 81, 104, -1, -1, -1, -1, -1, + 11, -1, 112, 113, 114, -1, -1, 117, -1, 119, + 98, 99, -1, -1, -1, 48, 104, -1, 51, -1, + 53, 54, 55, 56, 112, 113, 114, 60, -1, 117, + 63, 119, -1, -1, 67, -1, -1, 48, -1, -1, + 51, 74, 53, 54, 55, 56, -1, 80, 81, 60, + -1, -1, 63, -1, -1, -1, 67, -1, -1, -1, + -1, -1, -1, 74, -1, 98, 99, -1, -1, 80, + 81, 104, -1, -1, -1, -1, -1, -1, -1, 112, + 113, 114, -1, -1, 117, -1, 119, 98, 99, -1, + 49, 50, -1, 104, -1, -1, -1, -1, -1, 58, + -1, 112, 113, 114, -1, -1, 117, 66, 119, 68, + 69, 70, 71, -1, -1, -1, 75, -1, -1, -1, + 79, -1, -1, 82, 83, 84, 85, 86, -1, -1, + -1, -1, -1, 92, 93, 94, 95, -1, -1, -1, + -1, -1, 101, 102, 49, 50, 105, 106, -1, -1, + -1, 110, -1, 58, -1, -1, 115, 116, -1, 118, + -1, 66, -1, 68, 69, 70, 71, 126, -1, -1, + 75, -1, -1, -1, 79, -1, -1, 82, 83, 84, + 85, 86, -1, -1, 143, -1, 145, 92, 93, 94, + 95, -1, -1, -1, -1, -1, 101, 102, 49, 50, + 105, 106, -1, -1, -1, 110, -1, 58, -1, -1, + 115, 116, -1, 118, -1, 66, -1, 68, 69, 70, + 71, 126, -1, -1, 75, -1, -1, -1, 79, -1, + -1, 82, 83, 84, 85, 86, -1, -1, 143, -1, + 145, 92, 93, 94, 95, -1, -1, -1, -1, -1, + 101, 102, 49, 50, 105, 106, -1, -1, -1, 110, + -1, 58, -1, -1, 115, 116, -1, 118, -1, 66, + -1, 68, 69, 70, 71, 126, -1, -1, 75, -1, + -1, -1, 79, -1, -1, 82, 83, 84, 85, 86, + -1, -1, 143, -1, 145, 92, 93, 94, 95, -1, + -1, -1, -1, -1, 101, 102, 49, 50, 105, 106, + -1, -1, -1, 110, -1, 58, -1, -1, 115, 116, + -1, 118, -1, 66, -1, 68, 69, 70, 71, 126, + -1, -1, 75, -1, -1, -1, 79, -1, -1, 82, + 83, 84, 85, 86, -1, -1, 143, -1, 145, 92, + 93, 94, 95, -1, -1, -1, -1, -1, 101, 102, + 49, 50, 105, 106, -1, -1, -1, 110, -1, 58, + -1, -1, 115, 116, -1, 118, -1, 66, -1, 68, + 69, 70, 71, 126, -1, -1, 75, -1, -1, -1, + 79, -1, -1, 82, 83, 84, 85, 86, -1, -1, + 143, -1, 145, 92, 93, 94, 95, -1, -1, -1, + -1, -1, 101, 102, 49, 50, 105, 106, -1, -1, + -1, 110, -1, 58, -1, -1, 115, 116, -1, 118, + -1, 66, -1, 68, 69, 70, 71, 126, -1, -1, + 75, -1, -1, -1, 79, -1, -1, 82, 83, 84, + 85, 86, -1, -1, 143, -1, 145, 92, 93, 94, + 95, -1, -1, -1, -1, -1, 101, 102, 49, 50, + 105, 106, -1, -1, -1, 110, -1, 58, -1, -1, + 115, 116, -1, 118, -1, 66, -1, 68, 69, 70, + 71, 126, -1, -1, 75, -1, -1, -1, 79, -1, + -1, 82, 83, 84, 85, 86, -1, -1, 143, -1, + 145, 92, 93, 94, 95, -1, -1, -1, -1, -1, + 101, 102, 50, -1, 105, 106, -1, -1, -1, 110, + 58, -1, -1, -1, 115, 116, 50, 118, -1, -1, + 68, 69, 70, -1, 58, -1, -1, -1, -1, -1, + -1, 79, -1, -1, 68, 69, 70, 85, 86, -1, + -1, -1, 143, -1, -1, 79, 50, 95, -1, -1, + -1, 85, -1, 101, 58, -1, -1, -1, 106, -1, + -1, 95, -1, -1, 68, 69, 70, 101, 116, -1, + 118, -1, 106, -1, -1, 79, -1, -1, -1, -1, + -1, 85, 116, -1, 118, -1, -1, -1, -1, -1, + -1, 95, -1, -1, -1, 143, -1, 101, -1, 133, + -1, -1, 106, -1, -1, -1, -1, -1, -1, 143, + -1, -1, 116, -1, 118, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 143 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = +static const yytype_uint16 yystos[] = { - 0, 115, 116, 117, 143, 144, 236, 3, 4, 5, - 6, 8, 9, 10, 11, 46, 50, 52, 53, 54, - 61, 62, 70, 71, 77, 78, 85, 87, 94, 95, - 96, 99, 103, 108, 113, 126, 130, 131, 134, 136, - 140, 229, 230, 235, 11, 47, 50, 52, 53, 54, - 55, 56, 58, 61, 65, 71, 77, 78, 79, 94, - 95, 100, 106, 107, 108, 111, 113, 194, 198, 199, - 201, 206, 207, 211, 212, 217, 218, 219, 220, 0, - 48, 49, 57, 64, 66, 67, 68, 69, 72, 76, - 80, 81, 82, 83, 84, 89, 90, 91, 92, 97, - 98, 101, 105, 109, 110, 112, 120, 147, 149, 150, - 152, 153, 154, 175, 213, 216, 236, 136, 136, 136, - 136, 136, 136, 136, 127, 136, 136, 136, 11, 106, - 196, 211, 212, 217, 136, 136, 136, 127, 136, 136, - 229, 229, 229, 229, 11, 50, 52, 53, 54, 61, - 71, 77, 78, 94, 95, 108, 113, 198, 227, 229, - 229, 15, 16, 17, 18, 19, 20, 21, 22, 31, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 135, 136, 137, 6, 8, 194, 136, 61, 71, - 78, 218, 78, 218, 218, 10, 11, 234, 218, 12, - 16, 56, 112, 126, 131, 136, 193, 236, 118, 121, - 234, 118, 234, 76, 152, 152, 152, 6, 152, 152, - 121, 151, 84, 152, 136, 136, 136, 152, 118, 234, - 121, 121, 121, 152, 152, 136, 152, 153, 176, 152, - 159, 84, 234, 152, 152, 10, 11, 47, 56, 58, - 88, 106, 118, 134, 164, 195, 197, 199, 201, 206, - 211, 212, 217, 226, 227, 236, 198, 226, 226, 226, - 226, 226, 198, 226, 226, 226, 234, 136, 234, 234, - 226, 226, 198, 198, 226, 226, 138, 119, 138, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 138, 227, 229, 193, 229, 71, 131, 193, 193, 193, - 193, 193, 193, 137, 209, 210, 236, 11, 208, 218, - 121, 200, 202, 152, 149, 118, 234, 10, 10, 10, - 144, 118, 229, 127, 56, 164, 195, 197, 234, 136, - 136, 10, 11, 197, 136, 56, 194, 234, 148, 234, - 118, 120, 121, 122, 187, 120, 155, 234, 234, 138, - 138, 138, 138, 138, 138, 138, 128, 138, 138, 138, - 226, 138, 138, 138, 128, 138, 138, 229, 229, 121, - 138, 141, 138, 193, 138, 225, 229, 236, 234, 139, - 208, 144, 121, 203, 204, 236, 144, 118, 119, 119, - 119, 139, 214, 119, 138, 10, 11, 55, 56, 106, - 177, 178, 179, 180, 217, 236, 197, 187, 160, 165, - 12, 131, 166, 156, 229, 194, 10, 11, 12, 16, - 56, 112, 126, 131, 191, 236, 144, 136, 221, 222, - 145, 146, 234, 59, 60, 118, 229, 12, 16, 56, - 88, 112, 126, 131, 136, 157, 181, 234, 121, 136, - 138, 136, 229, 136, 141, 119, 122, 139, 89, 90, - 91, 110, 205, 118, 119, 139, 215, 10, 10, 10, - 144, 235, 234, 180, 234, 128, 119, 10, 11, 12, - 16, 56, 112, 126, 131, 136, 192, 236, 161, 162, - 181, 3, 4, 5, 9, 10, 14, 46, 56, 62, - 70, 85, 87, 92, 96, 99, 103, 126, 130, 134, - 136, 140, 183, 184, 190, 194, 231, 232, 235, 236, - 131, 181, 183, 158, 181, 138, 191, 131, 191, 191, - 191, 191, 191, 136, 137, 139, 167, 139, 223, 236, - 118, 119, 136, 120, 120, 118, 188, 189, 229, 236, - 120, 131, 181, 181, 6, 15, 16, 17, 18, 19, - 20, 21, 22, 31, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 60, 85, 119, 122, - 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - 134, 136, 137, 140, 173, 181, 181, 181, 181, 121, - 122, 136, 137, 186, 187, 236, 208, 227, 227, 183, - 229, 106, 110, 212, 233, 234, 110, 233, 110, 233, - 89, 90, 91, 144, 205, 144, 119, 138, 119, 119, - 139, 138, 122, 192, 122, 153, 174, 175, 179, 131, - 192, 192, 192, 192, 192, 192, 122, 137, 185, 236, - 163, 181, 186, 187, 136, 92, 194, 127, 196, 190, - 136, 127, 229, 229, 229, 198, 227, 229, 138, 14, - 119, 192, 15, 16, 17, 18, 19, 20, 21, 22, - 31, 123, 124, 125, 126, 127, 128, 129, 130, 131, - 132, 133, 135, 136, 137, 181, 121, 138, 138, 186, - 187, 136, 191, 170, 225, 183, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 31, 32, 33, + 0, 121, 122, 123, 149, 150, 256, 3, 4, 5, + 6, 8, 9, 10, 11, 47, 51, 53, 54, 55, + 59, 63, 64, 72, 73, 74, 80, 81, 87, 89, + 91, 96, 98, 99, 100, 103, 108, 111, 114, 119, + 132, 135, 136, 137, 140, 142, 143, 147, 246, 247, + 255, 11, 48, 51, 53, 54, 55, 56, 57, 60, + 63, 67, 74, 80, 81, 98, 99, 104, 112, 113, + 114, 117, 119, 210, 214, 215, 217, 223, 224, 228, + 229, 234, 235, 236, 237, 0, 49, 50, 58, 66, + 68, 69, 70, 71, 75, 79, 82, 83, 84, 85, + 86, 92, 93, 94, 95, 101, 102, 105, 106, 110, + 115, 116, 118, 126, 143, 153, 155, 156, 158, 161, + 162, 184, 230, 233, 256, 142, 142, 142, 142, 142, + 142, 133, 142, 133, 142, 142, 142, 11, 48, 60, + 112, 212, 228, 229, 234, 133, 142, 142, 142, 133, + 142, 142, 142, 246, 246, 246, 246, 246, 11, 51, + 53, 54, 55, 63, 74, 80, 81, 98, 99, 114, + 119, 214, 244, 246, 10, 11, 73, 91, 128, 132, + 250, 251, 253, 256, 246, 15, 16, 17, 18, 19, + 20, 21, 22, 32, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 141, 142, 143, 6, 8, + 210, 142, 63, 81, 235, 235, 235, 253, 235, 12, + 16, 57, 118, 132, 137, 142, 208, 209, 256, 124, + 10, 11, 91, 127, 254, 10, 11, 91, 124, 253, + 254, 79, 158, 158, 158, 6, 158, 158, 127, 157, + 86, 158, 142, 142, 142, 158, 124, 253, 127, 127, + 127, 158, 158, 142, 158, 161, 185, 158, 158, 167, + 86, 253, 158, 158, 143, 10, 11, 48, 57, 60, + 90, 112, 124, 140, 172, 175, 211, 213, 215, 217, + 223, 228, 229, 234, 243, 244, 256, 214, 243, 243, + 243, 243, 214, 243, 214, 243, 243, 243, 142, 253, + 142, 253, 253, 214, 243, 243, 214, 214, 214, 246, + 243, 243, 144, 125, 144, 253, 146, 125, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 144, + 244, 246, 209, 246, 137, 12, 16, 57, 118, 132, + 137, 208, 256, 208, 209, 208, 209, 208, 208, 14, + 16, 57, 95, 132, 137, 194, 195, 204, 210, 256, + 143, 226, 227, 256, 11, 225, 235, 127, 216, 218, + 158, 155, 124, 253, 253, 253, 253, 150, 124, 246, + 133, 10, 11, 57, 175, 211, 213, 253, 126, 128, + 159, 160, 253, 142, 142, 10, 11, 213, 142, 57, + 210, 253, 154, 253, 124, 126, 127, 128, 200, 124, + 126, 128, 201, 126, 163, 253, 254, 253, 144, 144, + 144, 144, 144, 144, 134, 144, 134, 144, 144, 144, + 246, 243, 134, 144, 144, 144, 134, 144, 144, 144, + 144, 246, 246, 57, 142, 181, 256, 250, 127, 144, + 146, 144, 208, 137, 208, 208, 208, 208, 208, 143, + 208, 95, 210, 204, 208, 208, 144, 14, 125, 12, + 16, 57, 118, 132, 137, 142, 207, 254, 256, 242, + 246, 256, 253, 145, 225, 150, 73, 219, 256, 150, + 124, 125, 125, 125, 145, 231, 125, 144, 10, 11, + 56, 57, 112, 186, 187, 188, 189, 234, 256, 142, + 213, 201, 168, 126, 214, 146, 125, 142, 173, 12, + 137, 174, 164, 246, 210, 12, 16, 57, 118, 132, + 137, 206, 254, 256, 150, 142, 238, 239, 151, 152, + 253, 61, 62, 238, 61, 62, 124, 246, 12, 16, + 57, 90, 118, 132, 137, 142, 165, 190, 192, 254, + 127, 142, 142, 144, 144, 142, 142, 194, 32, 73, + 85, 88, 91, 107, 193, 256, 246, 208, 242, 144, + 210, 207, 144, 144, 181, 14, 204, 137, 207, 207, + 207, 207, 207, 207, 128, 143, 199, 256, 146, 125, + 128, 145, 127, 220, 221, 256, 145, 232, 10, 10, + 10, 150, 255, 126, 253, 189, 253, 134, 125, 207, + 169, 170, 192, 126, 146, 159, 3, 4, 5, 9, + 10, 14, 47, 59, 64, 72, 73, 87, 89, 91, + 96, 100, 103, 108, 111, 132, 135, 136, 140, 142, + 147, 196, 197, 204, 205, 248, 249, 255, 256, 194, + 137, 190, 194, 166, 192, 144, 206, 137, 206, 206, + 206, 206, 206, 142, 143, 145, 176, 145, 240, 256, + 124, 125, 124, 142, 126, 126, 145, 126, 126, 124, + 202, 203, 246, 256, 126, 137, 190, 190, 6, 15, + 16, 17, 18, 19, 20, 21, 22, 32, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, + 62, 87, 125, 128, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 142, 143, 147, 182, 190, + 190, 190, 190, 127, 142, 143, 193, 128, 199, 201, + 225, 244, 244, 244, 244, 144, 57, 212, 142, 124, + 146, 142, 207, 199, 142, 142, 193, 207, 144, 246, + 242, 246, 92, 93, 94, 112, 116, 222, 229, 252, + 253, 124, 125, 150, 125, 144, 125, 125, 145, 144, + 128, 207, 128, 161, 183, 184, 188, 128, 198, 256, + 171, 192, 199, 201, 158, 142, 133, 133, 212, 133, + 142, 133, 142, 246, 246, 246, 246, 214, 244, 246, + 144, 14, 125, 15, 16, 17, 18, 19, 20, 21, + 22, 32, 129, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 139, 141, 142, 143, 144, 190, 144, 144, + 199, 201, 142, 206, 179, 242, 194, 3, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 65, 67, - 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, - 78, 83, 84, 85, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, - 114, 118, 119, 120, 121, 122, 123, 124, 125, 126, - 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 137, 138, 140, 141, 224, 221, 146, 226, 188, 139, - 119, 181, 10, 138, 141, 138, 4, 229, 182, 225, - 119, 138, 138, 138, 119, 234, 233, 234, 233, 233, - 233, 233, 233, 139, 139, 10, 120, 10, 10, 198, - 185, 198, 192, 138, 46, 62, 96, 99, 126, 130, - 131, 134, 136, 140, 228, 230, 225, 186, 187, 119, - 198, 194, 192, 198, 136, 198, 198, 138, 138, 56, - 172, 236, 14, 190, 122, 186, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 229, 229, 229, - 229, 229, 229, 229, 229, 229, 229, 138, 227, 229, - 138, 136, 172, 119, 171, 183, 141, 138, 223, 139, - 138, 139, 118, 229, 183, 141, 157, 172, 138, 119, - 138, 138, 136, 136, 127, 136, 127, 228, 228, 228, - 228, 198, 227, 228, 15, 16, 17, 18, 19, 20, - 21, 22, 31, 123, 124, 125, 126, 129, 130, 131, - 132, 133, 135, 136, 137, 141, 119, 162, 138, 192, - 186, 128, 226, 138, 128, 229, 86, 102, 229, 121, - 138, 141, 136, 168, 158, 183, 138, 172, 139, 188, - 138, 120, 10, 120, 120, 183, 198, 198, 198, 198, - 138, 138, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 228, 228, 228, 228, 228, 228, 228, 228, 228, - 228, 138, 227, 229, 163, 186, 136, 138, 136, 136, - 229, 169, 183, 138, 172, 139, 172, 119, 138, 138, - 128, 138, 128, 228, 121, 138, 141, 227, 227, 138, - 234, 183, 138, 172, 10, 172, 136, 136, 228, 138, - 138, 138, 138, 172, 138, 227, 227, 172, 120, 138, - 138 + 44, 45, 46, 47, 48, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, + 67, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 85, 86, 87, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 103, 104, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, 124, 125, + 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 146, + 147, 241, 238, 152, 243, 243, 202, 145, 125, 190, + 10, 144, 146, 144, 4, 191, 242, 246, 125, 144, + 144, 144, 144, 181, 212, 209, 144, 253, 238, 194, + 199, 194, 194, 142, 146, 125, 116, 252, 116, 252, + 116, 252, 253, 92, 93, 94, 253, 150, 222, 145, + 10, 126, 10, 10, 126, 214, 198, 214, 47, 59, + 64, 96, 100, 103, 132, 135, 136, 137, 140, 142, + 147, 245, 247, 199, 201, 125, 214, 214, 214, 142, + 214, 214, 214, 214, 246, 144, 144, 14, 205, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, + 144, 244, 246, 181, 144, 142, 181, 125, 180, 194, + 146, 144, 240, 145, 145, 144, 145, 124, 246, 196, + 146, 165, 193, 209, 144, 145, 144, 144, 144, 194, + 252, 252, 252, 252, 252, 252, 145, 144, 125, 144, + 144, 142, 133, 133, 133, 142, 133, 245, 245, 245, + 245, 245, 214, 244, 245, 15, 16, 17, 18, 19, + 20, 21, 22, 32, 129, 130, 131, 132, 135, 136, + 137, 138, 139, 141, 142, 143, 125, 170, 144, 134, + 134, 243, 134, 144, 134, 144, 144, 246, 127, 144, + 146, 142, 177, 166, 194, 144, 181, 145, 202, 144, + 124, 181, 181, 181, 144, 126, 10, 126, 126, 214, + 214, 214, 214, 214, 214, 144, 144, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 245, 245, 245, 245, + 245, 245, 245, 245, 245, 245, 144, 244, 246, 171, + 142, 142, 144, 142, 142, 246, 178, 194, 144, 181, + 145, 181, 238, 193, 193, 193, 181, 125, 144, 134, + 134, 134, 144, 134, 245, 127, 144, 146, 244, 244, + 244, 244, 194, 144, 181, 145, 10, 142, 142, 142, + 142, 245, 144, 144, 144, 144, 144, 181, 144, 244, + 244, 244, 244, 181, 193, 126, 144, 144, 144, 144, + 193 }; #define yyerrok (yyerrstatus = 0) @@ -3662,7 +3923,7 @@ yyreduce: { case 3: /* Line 1792 of yacc.c */ -#line 408 "dtool/src/cppparser/cppBison.yxx" +#line 423 "dtool/src/cppparser/cppBison.yxx" { current_expr = (yyvsp[(2) - (2)].u.expr); } @@ -3670,7 +3931,7 @@ yyreduce: case 4: /* Line 1792 of yacc.c */ -#line 412 "dtool/src/cppparser/cppBison.yxx" +#line 427 "dtool/src/cppparser/cppBison.yxx" { current_type = (yyvsp[(2) - (2)].u.type); } @@ -3678,7 +3939,7 @@ yyreduce: case 10: /* Line 1792 of yacc.c */ -#line 430 "dtool/src/cppparser/cppBison.yxx" +#line 445 "dtool/src/cppparser/cppBison.yxx" { delete (yyvsp[(3) - (4)].u.expr); } @@ -3686,24 +3947,32 @@ yyreduce: case 11: /* Line 1792 of yacc.c */ -#line 442 "dtool/src/cppparser/cppBison.yxx" +#line 449 "dtool/src/cppparser/cppBison.yxx" + { + delete (yyvsp[(3) - (4)].u.expr); +} + break; + + case 12: +/* Line 1792 of yacc.c */ +#line 461 "dtool/src/cppparser/cppBison.yxx" { push_storage_class((current_storage_class & ~CPPInstance::SC_c_binding) | ((yyvsp[(1) - (2)].u.integer) & CPPInstance::SC_c_binding)); } break; - case 12: + case 13: /* Line 1792 of yacc.c */ -#line 447 "dtool/src/cppparser/cppBison.yxx" +#line 466 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } break; - case 20: + case 21: /* Line 1792 of yacc.c */ -#line 461 "dtool/src/cppparser/cppBison.yxx" +#line 480 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level != 0) { yyerror("Unclosed __begin_publish", publish_loc); @@ -3718,9 +3987,9 @@ yyreduce: } break; - case 21: + case 22: /* Line 1792 of yacc.c */ -#line 474 "dtool/src/cppparser/cppBison.yxx" +#line 493 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level != 1) { yyerror("Unmatched __end_publish", (yylsp[(1) - (1)])); @@ -3731,17 +4000,17 @@ yyreduce: } break; - case 22: + case 23: /* Line 1792 of yacc.c */ -#line 483 "dtool/src/cppparser/cppBison.yxx" +#line 502 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_published); } break; - case 23: + case 24: /* Line 1792 of yacc.c */ -#line 487 "dtool/src/cppparser/cppBison.yxx" +#line 506 "dtool/src/cppparser/cppBison.yxx" { if (publish_nest_level > 0) { current_scope->set_current_vis(V_published); @@ -3751,25 +4020,25 @@ yyreduce: } break; - case 24: + case 25: /* Line 1792 of yacc.c */ -#line 495 "dtool/src/cppparser/cppBison.yxx" +#line 514 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_protected); } break; - case 25: + case 26: /* Line 1792 of yacc.c */ -#line 499 "dtool/src/cppparser/cppBison.yxx" +#line 518 "dtool/src/cppparser/cppBison.yxx" { current_scope->set_current_vis(V_private); } break; - case 26: + case 27: /* Line 1792 of yacc.c */ -#line 503 "dtool/src/cppparser/cppBison.yxx" +#line 522 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *getter = (yyvsp[(5) - (7)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -3782,9 +4051,9 @@ yyreduce: } break; - case 27: + case 28: /* Line 1792 of yacc.c */ -#line 514 "dtool/src/cppparser/cppBison.yxx" +#line 533 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *getter = (yyvsp[(5) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -3807,9 +4076,9 @@ yyreduce: } break; - case 28: + case 29: /* Line 1792 of yacc.c */ -#line 535 "dtool/src/cppparser/cppBison.yxx" +#line 554 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *hasser = (yyvsp[(5) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) { @@ -3833,9 +4102,9 @@ yyreduce: } break; - case 29: + case 30: /* Line 1792 of yacc.c */ -#line 557 "dtool/src/cppparser/cppBison.yxx" +#line 576 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *hasser = (yyvsp[(5) - (13)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) { @@ -3870,9 +4139,9 @@ yyreduce: } break; - case 30: + case 31: /* Line 1792 of yacc.c */ -#line 590 "dtool/src/cppparser/cppBison.yxx" +#line 609 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *length_getter = (yyvsp[(5) - (9)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -3896,38 +4165,38 @@ yyreduce: } break; - case 31: -/* Line 1792 of yacc.c */ -#line 612 "dtool/src/cppparser/cppBison.yxx" - { - CPPExpression::Result result = (yyvsp[(3) - (6)].u.expr)->evaluate(); - if (result._type == CPPExpression::RT_error) { - yywarning("static_assert requires a constant expression", (yylsp[(3) - (6)])); - } else if (!result.as_boolean()) { - stringstream str; - str << *(yyvsp[(5) - (6)].u.expr); - yywarning("static_assert failed: " + str.str(), (yylsp[(3) - (6)])); - } -} - break; - case 32: /* Line 1792 of yacc.c */ -#line 623 "dtool/src/cppparser/cppBison.yxx" +#line 631 "dtool/src/cppparser/cppBison.yxx" { - // This alternative version of static_assert was introduced in C++17. - CPPExpression::Result result = (yyvsp[(3) - (4)].u.expr)->evaluate(); + CPPExpression::Result result = (yyvsp[(3) - (7)].u.expr)->evaluate(); if (result._type == CPPExpression::RT_error) { - yywarning("static_assert requires a constant expression", (yylsp[(3) - (4)])); + yywarning("static_assert requires a constant expression", (yylsp[(3) - (7)])); } else if (!result.as_boolean()) { - yywarning("static_assert failed", (yylsp[(3) - (4)])); + stringstream str; + str << *(yyvsp[(5) - (7)].u.expr); + yywarning("static_assert failed: " + str.str(), (yylsp[(3) - (7)])); } } break; case 33: /* Line 1792 of yacc.c */ -#line 636 "dtool/src/cppparser/cppBison.yxx" +#line 642 "dtool/src/cppparser/cppBison.yxx" + { + // This alternative version of static_assert was introduced in C++17. + CPPExpression::Result result = (yyvsp[(3) - (5)].u.expr)->evaluate(); + if (result._type == CPPExpression::RT_error) { + yywarning("static_assert requires a constant expression", (yylsp[(3) - (5)])); + } else if (!result.as_boolean()) { + yywarning("static_assert failed", (yylsp[(3) - (5)])); + } +} + break; + + case 34: +/* Line 1792 of yacc.c */ +#line 655 "dtool/src/cppparser/cppBison.yxx" { CPPScope *new_scope = new CPPScope(current_scope, CPPNameComponent("temp"), V_public); @@ -3935,34 +4204,34 @@ yyreduce: } break; - case 34: + case 35: /* Line 1792 of yacc.c */ -#line 642 "dtool/src/cppparser/cppBison.yxx" +#line 661 "dtool/src/cppparser/cppBison.yxx" { delete current_scope; pop_scope(); } break; - case 35: + case 36: /* Line 1792 of yacc.c */ -#line 651 "dtool/src/cppparser/cppBison.yxx" +#line 670 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = 0; } break; - case 36: + case 37: /* Line 1792 of yacc.c */ -#line 655 "dtool/src/cppparser/cppBison.yxx" +#line 674 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_extern; } break; - case 37: + case 38: /* Line 1792 of yacc.c */ -#line 659 "dtool/src/cppparser/cppBison.yxx" +#line 678 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(3) - (3)].u.integer) | (int)CPPInstance::SC_extern; if ((yyvsp[(2) - (3)].str) == "C") { @@ -3975,97 +4244,114 @@ yyreduce: } break; - case 38: + case 39: /* Line 1792 of yacc.c */ -#line 670 "dtool/src/cppparser/cppBison.yxx" +#line 689 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_static; } break; - case 39: + case 40: /* Line 1792 of yacc.c */ -#line 674 "dtool/src/cppparser/cppBison.yxx" +#line 693 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_inline; } break; - case 40: + case 41: /* Line 1792 of yacc.c */ -#line 678 "dtool/src/cppparser/cppBison.yxx" +#line 697 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_virtual; } break; - case 41: + case 42: /* Line 1792 of yacc.c */ -#line 682 "dtool/src/cppparser/cppBison.yxx" +#line 701 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_explicit; } break; - case 42: + case 43: /* Line 1792 of yacc.c */ -#line 686 "dtool/src/cppparser/cppBison.yxx" +#line 705 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_register; } break; - case 43: + case 44: /* Line 1792 of yacc.c */ -#line 690 "dtool/src/cppparser/cppBison.yxx" +#line 709 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_volatile; } break; - case 44: + case 45: /* Line 1792 of yacc.c */ -#line 694 "dtool/src/cppparser/cppBison.yxx" +#line 713 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_mutable; } break; - case 45: + case 46: /* Line 1792 of yacc.c */ -#line 698 "dtool/src/cppparser/cppBison.yxx" +#line 717 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_constexpr; } break; - case 46: + case 47: /* Line 1792 of yacc.c */ -#line 702 "dtool/src/cppparser/cppBison.yxx" +#line 721 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_blocking; } break; - case 47: + case 48: /* Line 1792 of yacc.c */ -#line 706 "dtool/src/cppparser/cppBison.yxx" +#line 725 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_extension; } break; - case 48: + case 49: /* Line 1792 of yacc.c */ -#line 713 "dtool/src/cppparser/cppBison.yxx" +#line 729 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.integer) = (yyvsp[(2) - (2)].u.integer) | (int)CPPInstance::SC_thread_local; +} + break; + + case 50: +/* Line 1792 of yacc.c */ +#line 733 "dtool/src/cppparser/cppBison.yxx" + { + // Ignore attribute specifiers for now. + (yyval.u.integer) = (yyvsp[(6) - (6)].u.integer); +} + break; + + case 55: +/* Line 1792 of yacc.c */ +#line 751 "dtool/src/cppparser/cppBison.yxx" { /* multiple_var_declaration adds itself to the scope. */ } break; - case 49: + case 56: /* Line 1792 of yacc.c */ -#line 717 "dtool/src/cppparser/cppBison.yxx" +#line 755 "dtool/src/cppparser/cppBison.yxx" { // We don't really care about the storage class here. In fact, it's // not actually legal to define a class or struct using a particular @@ -4076,9 +4362,9 @@ yyreduce: } break; - case 50: + case 57: /* Line 1792 of yacc.c */ -#line 726 "dtool/src/cppparser/cppBison.yxx" +#line 764 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (3)].u.instance) != (CPPInstance *)NULL) { (yyvsp[(2) - (3)].u.instance)->_storage_class |= (current_storage_class | (yyvsp[(1) - (3)].u.integer)); @@ -4088,105 +4374,21 @@ yyreduce: } break; - case 51: -/* Line 1792 of yacc.c */ -#line 737 "dtool/src/cppparser/cppBison.yxx" - { - // We don't need to push/pop type, because we can't nest - // multiple_var_declarations. - if ((yyvsp[(2) - (2)].u.decl)->as_type_declaration()) { - current_type = (yyvsp[(2) - (2)].u.decl)->as_type_declaration()->_type; - } else { - current_type = (yyvsp[(2) - (2)].u.decl)->as_type(); - } - push_storage_class((yyvsp[(1) - (2)].u.integer)); -} - break; - - case 52: -/* Line 1792 of yacc.c */ -#line 748 "dtool/src/cppparser/cppBison.yxx" - { - pop_storage_class(); -} - break; - - case 53: -/* Line 1792 of yacc.c */ -#line 752 "dtool/src/cppparser/cppBison.yxx" - { - // We don't need to push/pop type, because we can't nest - // multiple_var_declarations. - if ((yyvsp[(3) - (3)].u.decl)->as_type_declaration()) { - current_type = (yyvsp[(3) - (3)].u.decl)->as_type_declaration()->_type; - } else { - current_type = (yyvsp[(3) - (3)].u.decl)->as_type(); - } - push_storage_class((yyvsp[(1) - (3)].u.integer)); -} - break; - - case 54: -/* Line 1792 of yacc.c */ -#line 763 "dtool/src/cppparser/cppBison.yxx" - { - pop_storage_class(); -} - break; - - case 55: -/* Line 1792 of yacc.c */ -#line 774 "dtool/src/cppparser/cppBison.yxx" - { - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (2)]).file); - inst->set_initializer((yyvsp[(2) - (2)].u.expr)); - current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (2)])); -} - break; - - case 56: -/* Line 1792 of yacc.c */ -#line 782 "dtool/src/cppparser/cppBison.yxx" - { - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (4)]).file); - inst->set_initializer((yyvsp[(2) - (4)].u.expr)); - current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (4)])); -} - break; - - case 57: -/* Line 1792 of yacc.c */ -#line 793 "dtool/src/cppparser/cppBison.yxx" - { - (yyvsp[(1) - (2)].u.inst_ident)->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (2)]).file); - inst->set_initializer((yyvsp[(2) - (2)].u.expr)); - current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (2)])); -} - break; - case 58: /* Line 1792 of yacc.c */ -#line 802 "dtool/src/cppparser/cppBison.yxx" +#line 772 "dtool/src/cppparser/cppBison.yxx" { - (yyvsp[(1) - (4)].u.inst_ident)->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), - current_storage_class, - (yylsp[(1) - (4)]).file); - inst->set_initializer((yyvsp[(2) - (4)].u.expr)); - current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (4)])); + if ((yyvsp[(2) - (3)].u.instance) != (CPPInstance *)NULL) { + (yyvsp[(2) - (3)].u.instance)->_storage_class |= (current_storage_class | (yyvsp[(1) - (3)].u.integer)); + current_scope->add_declaration((yyvsp[(2) - (3)].u.instance), global_scope, current_lexer, (yylsp[(2) - (3)])); + (yyvsp[(2) - (3)].u.instance)->set_initializer((yyvsp[(3) - (3)].u.expr)); + } } break; case 59: /* Line 1792 of yacc.c */ -#line 815 "dtool/src/cppparser/cppBison.yxx" +#line 783 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -4201,7 +4403,7 @@ yyreduce: case 60: /* Line 1792 of yacc.c */ -#line 826 "dtool/src/cppparser/cppBison.yxx" +#line 794 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -4209,7 +4411,7 @@ yyreduce: case 61: /* Line 1792 of yacc.c */ -#line 830 "dtool/src/cppparser/cppBison.yxx" +#line 798 "dtool/src/cppparser/cppBison.yxx" { // We don't need to push/pop type, because we can't nest // multiple_var_declarations. @@ -4224,7 +4426,7 @@ yyreduce: case 62: /* Line 1792 of yacc.c */ -#line 841 "dtool/src/cppparser/cppBison.yxx" +#line 809 "dtool/src/cppparser/cppBison.yxx" { pop_storage_class(); } @@ -4232,7 +4434,103 @@ yyreduce: case 63: /* Line 1792 of yacc.c */ -#line 845 "dtool/src/cppparser/cppBison.yxx" +#line 820 "dtool/src/cppparser/cppBison.yxx" + { + CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), + current_storage_class, + (yylsp[(1) - (2)]).file); + inst->set_initializer((yyvsp[(2) - (2)].u.expr)); + current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (2)])); +} + break; + + case 64: +/* Line 1792 of yacc.c */ +#line 828 "dtool/src/cppparser/cppBison.yxx" + { + CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), + current_storage_class, + (yylsp[(1) - (4)]).file); + inst->set_initializer((yyvsp[(2) - (4)].u.expr)); + current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (4)])); +} + break; + + case 65: +/* Line 1792 of yacc.c */ +#line 839 "dtool/src/cppparser/cppBison.yxx" + { + (yyvsp[(1) - (2)].u.inst_ident)->add_modifier(IIT_const); + CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (2)].u.inst_ident), + current_storage_class, + (yylsp[(1) - (2)]).file); + inst->set_initializer((yyvsp[(2) - (2)].u.expr)); + current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (2)])); +} + break; + + case 66: +/* Line 1792 of yacc.c */ +#line 848 "dtool/src/cppparser/cppBison.yxx" + { + (yyvsp[(1) - (4)].u.inst_ident)->add_modifier(IIT_const); + CPPInstance *inst = new CPPInstance(current_type, (yyvsp[(1) - (4)].u.inst_ident), + current_storage_class, + (yylsp[(1) - (4)]).file); + inst->set_initializer((yyvsp[(2) - (4)].u.expr)); + current_scope->add_declaration(inst, global_scope, current_lexer, (yylsp[(1) - (4)])); +} + break; + + case 67: +/* Line 1792 of yacc.c */ +#line 861 "dtool/src/cppparser/cppBison.yxx" + { + // We don't need to push/pop type, because we can't nest + // multiple_var_declarations. + if ((yyvsp[(2) - (2)].u.decl)->as_type_declaration()) { + current_type = (yyvsp[(2) - (2)].u.decl)->as_type_declaration()->_type; + } else { + current_type = (yyvsp[(2) - (2)].u.decl)->as_type(); + } + push_storage_class((yyvsp[(1) - (2)].u.integer)); +} + break; + + case 68: +/* Line 1792 of yacc.c */ +#line 872 "dtool/src/cppparser/cppBison.yxx" + { + pop_storage_class(); +} + break; + + case 69: +/* Line 1792 of yacc.c */ +#line 876 "dtool/src/cppparser/cppBison.yxx" + { + // We don't need to push/pop type, because we can't nest + // multiple_var_declarations. + if ((yyvsp[(3) - (3)].u.decl)->as_type_declaration()) { + current_type = (yyvsp[(3) - (3)].u.decl)->as_type_declaration()->_type; + } else { + current_type = (yyvsp[(3) - (3)].u.decl)->as_type(); + } + push_storage_class((yyvsp[(1) - (3)].u.integer)); +} + break; + + case 70: +/* Line 1792 of yacc.c */ +#line 887 "dtool/src/cppparser/cppBison.yxx" + { + pop_storage_class(); +} + break; + + case 71: +/* Line 1792 of yacc.c */ +#line 891 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(2) - (3)].u.instance) != (CPPDeclaration *)NULL) { CPPInstance *inst = (yyvsp[(2) - (3)].u.instance)->as_instance(); @@ -4246,9 +4544,9 @@ yyreduce: } break; - case 64: + case 72: /* Line 1792 of yacc.c */ -#line 860 "dtool/src/cppparser/cppBison.yxx" +#line 906 "dtool/src/cppparser/cppBison.yxx" { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (2)].u.inst_ident), current_scope, (yylsp[(1) - (2)]).file); @@ -4256,9 +4554,9 @@ yyreduce: } break; - case 65: + case 73: /* Line 1792 of yacc.c */ -#line 866 "dtool/src/cppparser/cppBison.yxx" +#line 912 "dtool/src/cppparser/cppBison.yxx" { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, (yyvsp[(1) - (4)].u.inst_ident), current_scope, (yylsp[(1) - (4)]).file); @@ -4266,9 +4564,9 @@ yyreduce: } break; - case 66: + case 74: /* Line 1792 of yacc.c */ -#line 875 "dtool/src/cppparser/cppBison.yxx" +#line 921 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (2)].u.inst_ident)->add_modifier(IIT_const); CPPType *target_type = current_type; @@ -4277,9 +4575,9 @@ yyreduce: } break; - case 67: + case 75: /* Line 1792 of yacc.c */ -#line 882 "dtool/src/cppparser/cppBison.yxx" +#line 928 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(1) - (4)].u.inst_ident)->add_modifier(IIT_const); CPPType *target_type = current_type; @@ -4288,17 +4586,17 @@ yyreduce: } break; - case 68: + case 76: /* Line 1792 of yacc.c */ -#line 894 "dtool/src/cppparser/cppBison.yxx" +#line 940 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.identifier)->get_scope(current_scope, global_scope)); } break; - case 69: + case 77: /* Line 1792 of yacc.c */ -#line 898 "dtool/src/cppparser/cppBison.yxx" +#line 944 "dtool/src/cppparser/cppBison.yxx" { CPPType *type; if ((yyvsp[(1) - (6)].u.identifier)->get_simple_name() == current_scope->get_simple_name() || @@ -4320,17 +4618,17 @@ yyreduce: } break; - case 70: + case 78: /* Line 1792 of yacc.c */ -#line 918 "dtool/src/cppparser/cppBison.yxx" +#line 964 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.identifier)->get_scope(current_scope, global_scope)); } break; - case 71: + case 79: /* Line 1792 of yacc.c */ -#line 922 "dtool/src/cppparser/cppBison.yxx" +#line 968 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type; @@ -4350,17 +4648,17 @@ yyreduce: } break; - case 72: + case 80: /* Line 1792 of yacc.c */ -#line 942 "dtool/src/cppparser/cppBison.yxx" +#line 991 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(2) - (3)].u.identifier)->get_scope(current_scope, global_scope)); } break; - case 73: + case 81: /* Line 1792 of yacc.c */ -#line 946 "dtool/src/cppparser/cppBison.yxx" +#line 995 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); if ((yyvsp[(2) - (7)].u.identifier)->is_scoped()) { @@ -4381,43 +4679,17 @@ yyreduce: } break; - case 74: + case 82: /* Line 1792 of yacc.c */ -#line 972 "dtool/src/cppparser/cppBison.yxx" +#line 1021 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(4) - (6)].u.inst_ident)->get_scope(current_scope, global_scope)); } break; - case 75: + case 83: /* Line 1792 of yacc.c */ -#line 976 "dtool/src/cppparser/cppBison.yxx" - { - pop_scope(); - CPPType *type = (yyvsp[(1) - (10)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); - if (type == NULL) { - yyerror(string("internal error resolving type ") + (yyvsp[(1) - (10)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (10)])); - } - assert(type != NULL); - - CPPInstanceIdentifier *ii = (yyvsp[(4) - (10)].u.inst_ident); - ii->add_modifier(IIT_pointer); - ii->add_func_modifier((yyvsp[(8) - (10)].u.param_list), (yyvsp[(10) - (10)].u.integer)); - (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[(1) - (10)]).file); -} - break; - - case 76: -/* Line 1792 of yacc.c */ -#line 990 "dtool/src/cppparser/cppBison.yxx" - { - push_scope((yyvsp[(5) - (7)].u.inst_ident)->get_scope(current_scope, global_scope)); -} - break; - - case 77: -/* Line 1792 of yacc.c */ -#line 994 "dtool/src/cppparser/cppBison.yxx" +#line 1025 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); CPPType *type = (yyvsp[(1) - (11)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); @@ -4426,16 +4698,42 @@ yyreduce: } assert(type != NULL); - CPPInstanceIdentifier *ii = (yyvsp[(5) - (11)].u.inst_ident); - ii->add_scoped_pointer_modifier((yyvsp[(3) - (11)].u.identifier)); - ii->add_func_modifier((yyvsp[(9) - (11)].u.param_list), (yyvsp[(11) - (11)].u.integer)); + CPPInstanceIdentifier *ii = (yyvsp[(4) - (11)].u.inst_ident); + ii->add_modifier(IIT_pointer); + ii->add_func_modifier((yyvsp[(8) - (11)].u.param_list), (yyvsp[(10) - (11)].u.integer)); (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[(1) - (11)]).file); } break; - case 78: + case 84: /* Line 1792 of yacc.c */ -#line 1010 "dtool/src/cppparser/cppBison.yxx" +#line 1039 "dtool/src/cppparser/cppBison.yxx" + { + push_scope((yyvsp[(5) - (7)].u.inst_ident)->get_scope(current_scope, global_scope)); +} + break; + + case 85: +/* Line 1792 of yacc.c */ +#line 1043 "dtool/src/cppparser/cppBison.yxx" + { + pop_scope(); + CPPType *type = (yyvsp[(1) - (12)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); + if (type == NULL) { + yyerror(string("internal error resolving type ") + (yyvsp[(1) - (12)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (12)])); + } + assert(type != NULL); + + CPPInstanceIdentifier *ii = (yyvsp[(5) - (12)].u.inst_ident); + ii->add_scoped_pointer_modifier((yyvsp[(3) - (12)].u.identifier)); + ii->add_func_modifier((yyvsp[(9) - (12)].u.param_list), (yyvsp[(11) - (12)].u.integer)); + (yyval.u.instance) = new CPPInstance(type, ii, 0, (yylsp[(1) - (12)]).file); +} + break; + + case 86: +/* Line 1792 of yacc.c */ +#line 1059 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (4)].u.identifier) != NULL) { push_scope((yyvsp[(1) - (4)].u.identifier)->get_scope(current_scope, global_scope)); @@ -4443,9 +4741,9 @@ yyreduce: } break; - case 79: + case 87: /* Line 1792 of yacc.c */ -#line 1016 "dtool/src/cppparser/cppBison.yxx" +#line 1065 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (8)].u.identifier) != NULL) { pop_scope(); @@ -4472,9 +4770,9 @@ yyreduce: } break; - case 80: + case 88: /* Line 1792 of yacc.c */ -#line 1041 "dtool/src/cppparser/cppBison.yxx" +#line 1090 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (5)].u.identifier) != NULL) { push_scope((yyvsp[(1) - (5)].u.identifier)->get_scope(current_scope, global_scope)); @@ -4482,9 +4780,9 @@ yyreduce: } break; - case 81: + case 89: /* Line 1792 of yacc.c */ -#line 1047 "dtool/src/cppparser/cppBison.yxx" +#line 1096 "dtool/src/cppparser/cppBison.yxx" { if ((yyvsp[(1) - (9)].u.identifier) != NULL) { pop_scope(); @@ -4502,9 +4800,9 @@ yyreduce: } break; - case 82: + case 90: /* Line 1792 of yacc.c */ -#line 1067 "dtool/src/cppparser/cppBison.yxx" +#line 1116 "dtool/src/cppparser/cppBison.yxx" { CPPDeclaration *decl = (yyvsp[(1) - (1)].u.identifier)->find_symbol(current_scope, global_scope, current_lexer); @@ -4516,377 +4814,402 @@ yyreduce: } break; - case 83: + case 91: /* Line 1792 of yacc.c */ -#line 1080 "dtool/src/cppparser/cppBison.yxx" +#line 1129 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = 0; } break; - case 84: + case 92: /* Line 1792 of yacc.c */ -#line 1084 "dtool/src/cppparser/cppBison.yxx" +#line 1133 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (int)CPPFunctionType::F_const_method; } break; - case 85: + case 93: /* Line 1792 of yacc.c */ -#line 1088 "dtool/src/cppparser/cppBison.yxx" +#line 1137 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.integer) = (int)CPPFunctionType::F_noexcept; } break; - case 86: -/* Line 1792 of yacc.c */ -#line 1092 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.integer) = (yyvsp[(1) - (4)].u.integer); -} - break; - - case 87: -/* Line 1792 of yacc.c */ -#line 1096 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.integer) = (yyvsp[(1) - (5)].u.integer); -} - break; - - case 88: -/* Line 1792 of yacc.c */ -#line 1103 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "!"; -} - break; - - case 89: -/* Line 1792 of yacc.c */ -#line 1107 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "~"; -} - break; - - case 90: -/* Line 1792 of yacc.c */ -#line 1111 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "*"; -} - break; - - case 91: -/* Line 1792 of yacc.c */ -#line 1115 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "/"; -} - break; - - case 92: -/* Line 1792 of yacc.c */ -#line 1119 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "%"; -} - break; - - case 93: -/* Line 1792 of yacc.c */ -#line 1123 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.str) = "+"; -} - break; - case 94: /* Line 1792 of yacc.c */ -#line 1127 "dtool/src/cppparser/cppBison.yxx" +#line 1141 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "-"; + (yyval.u.integer) = (int)CPPFunctionType::F_final; } break; case 95: /* Line 1792 of yacc.c */ -#line 1131 "dtool/src/cppparser/cppBison.yxx" +#line 1145 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "|"; + (yyval.u.integer) = (int)CPPFunctionType::F_override; } break; case 96: /* Line 1792 of yacc.c */ -#line 1135 "dtool/src/cppparser/cppBison.yxx" +#line 1149 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "&"; + // Used for lambdas, currently ignored. + (yyval.u.integer) = 0; } break; case 97: /* Line 1792 of yacc.c */ -#line 1139 "dtool/src/cppparser/cppBison.yxx" +#line 1154 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "^"; + (yyval.u.integer) = (yyvsp[(1) - (4)].u.integer); } break; case 98: /* Line 1792 of yacc.c */ -#line 1143 "dtool/src/cppparser/cppBison.yxx" +#line 1158 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "||"; + (yyval.u.integer) = (yyvsp[(1) - (5)].u.integer); } break; case 99: /* Line 1792 of yacc.c */ -#line 1147 "dtool/src/cppparser/cppBison.yxx" +#line 1169 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "&&"; + (yyval.str) = "!"; } break; case 100: /* Line 1792 of yacc.c */ -#line 1151 "dtool/src/cppparser/cppBison.yxx" +#line 1173 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "=="; + (yyval.str) = "~"; } break; case 101: /* Line 1792 of yacc.c */ -#line 1155 "dtool/src/cppparser/cppBison.yxx" +#line 1177 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "!="; + (yyval.str) = "*"; } break; case 102: /* Line 1792 of yacc.c */ -#line 1159 "dtool/src/cppparser/cppBison.yxx" +#line 1181 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "<="; + (yyval.str) = "/"; } break; case 103: /* Line 1792 of yacc.c */ -#line 1163 "dtool/src/cppparser/cppBison.yxx" +#line 1185 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = ">="; + (yyval.str) = "%"; } break; case 104: /* Line 1792 of yacc.c */ -#line 1167 "dtool/src/cppparser/cppBison.yxx" +#line 1189 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "<"; + (yyval.str) = "+"; } break; case 105: /* Line 1792 of yacc.c */ -#line 1171 "dtool/src/cppparser/cppBison.yxx" +#line 1193 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = ">"; + (yyval.str) = "-"; } break; case 106: /* Line 1792 of yacc.c */ -#line 1175 "dtool/src/cppparser/cppBison.yxx" +#line 1197 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "<<"; + (yyval.str) = "|"; } break; case 107: /* Line 1792 of yacc.c */ -#line 1179 "dtool/src/cppparser/cppBison.yxx" +#line 1201 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = ">>"; + (yyval.str) = "&"; } break; case 108: /* Line 1792 of yacc.c */ -#line 1183 "dtool/src/cppparser/cppBison.yxx" +#line 1205 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "="; + (yyval.str) = "^"; } break; case 109: /* Line 1792 of yacc.c */ -#line 1187 "dtool/src/cppparser/cppBison.yxx" +#line 1209 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = ","; + (yyval.str) = "||"; } break; case 110: /* Line 1792 of yacc.c */ -#line 1191 "dtool/src/cppparser/cppBison.yxx" +#line 1213 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "++"; + (yyval.str) = "&&"; } break; case 111: /* Line 1792 of yacc.c */ -#line 1195 "dtool/src/cppparser/cppBison.yxx" +#line 1217 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "--"; + (yyval.str) = "=="; } break; case 112: /* Line 1792 of yacc.c */ -#line 1199 "dtool/src/cppparser/cppBison.yxx" +#line 1221 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "*="; + (yyval.str) = "!="; } break; case 113: /* Line 1792 of yacc.c */ -#line 1203 "dtool/src/cppparser/cppBison.yxx" +#line 1225 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "/="; + (yyval.str) = "<="; } break; case 114: /* Line 1792 of yacc.c */ -#line 1207 "dtool/src/cppparser/cppBison.yxx" +#line 1229 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "%="; + (yyval.str) = ">="; } break; case 115: /* Line 1792 of yacc.c */ -#line 1211 "dtool/src/cppparser/cppBison.yxx" +#line 1233 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "+="; + (yyval.str) = "<"; } break; case 116: /* Line 1792 of yacc.c */ -#line 1215 "dtool/src/cppparser/cppBison.yxx" +#line 1237 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "-="; + (yyval.str) = ">"; } break; case 117: /* Line 1792 of yacc.c */ -#line 1219 "dtool/src/cppparser/cppBison.yxx" +#line 1241 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "|="; + (yyval.str) = "<<"; } break; case 118: /* Line 1792 of yacc.c */ -#line 1223 "dtool/src/cppparser/cppBison.yxx" +#line 1245 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "&="; + (yyval.str) = ">>"; } break; case 119: /* Line 1792 of yacc.c */ -#line 1227 "dtool/src/cppparser/cppBison.yxx" +#line 1249 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "^="; + (yyval.str) = "="; } break; case 120: /* Line 1792 of yacc.c */ -#line 1231 "dtool/src/cppparser/cppBison.yxx" +#line 1253 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "<<="; + (yyval.str) = ","; } break; case 121: /* Line 1792 of yacc.c */ -#line 1235 "dtool/src/cppparser/cppBison.yxx" +#line 1257 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = ">>="; + (yyval.str) = "++"; } break; case 122: /* Line 1792 of yacc.c */ -#line 1239 "dtool/src/cppparser/cppBison.yxx" +#line 1261 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "->"; + (yyval.str) = "--"; } break; case 123: /* Line 1792 of yacc.c */ -#line 1243 "dtool/src/cppparser/cppBison.yxx" +#line 1265 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "[]"; + (yyval.str) = "*="; } break; case 124: /* Line 1792 of yacc.c */ -#line 1247 "dtool/src/cppparser/cppBison.yxx" +#line 1269 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "()"; + (yyval.str) = "/="; } break; case 125: /* Line 1792 of yacc.c */ -#line 1251 "dtool/src/cppparser/cppBison.yxx" +#line 1273 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "new"; + (yyval.str) = "%="; } break; case 126: /* Line 1792 of yacc.c */ -#line 1255 "dtool/src/cppparser/cppBison.yxx" +#line 1277 "dtool/src/cppparser/cppBison.yxx" { - (yyval.str) = "delete"; + (yyval.str) = "+="; +} + break; + + case 127: +/* Line 1792 of yacc.c */ +#line 1281 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "-="; +} + break; + + case 128: +/* Line 1792 of yacc.c */ +#line 1285 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "|="; } break; case 129: /* Line 1792 of yacc.c */ -#line 1267 "dtool/src/cppparser/cppBison.yxx" +#line 1289 "dtool/src/cppparser/cppBison.yxx" { - push_scope(new CPPTemplateScope(current_scope)); + (yyval.str) = "&="; } break; case 130: /* Line 1792 of yacc.c */ -#line 1271 "dtool/src/cppparser/cppBison.yxx" +#line 1293 "dtool/src/cppparser/cppBison.yxx" { - pop_scope(); + (yyval.str) = "^="; +} + break; + + case 131: +/* Line 1792 of yacc.c */ +#line 1297 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "<<="; +} + break; + + case 132: +/* Line 1792 of yacc.c */ +#line 1301 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = ">>="; +} + break; + + case 133: +/* Line 1792 of yacc.c */ +#line 1305 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "->"; } break; case 134: /* Line 1792 of yacc.c */ -#line 1284 "dtool/src/cppparser/cppBison.yxx" +#line 1309 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "[]"; +} + break; + + case 135: +/* Line 1792 of yacc.c */ +#line 1313 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "()"; +} + break; + + case 136: +/* Line 1792 of yacc.c */ +#line 1317 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "new"; +} + break; + + case 137: +/* Line 1792 of yacc.c */ +#line 1321 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.str) = "delete"; +} + break; + + case 140: +/* Line 1792 of yacc.c */ +#line 1333 "dtool/src/cppparser/cppBison.yxx" + { + push_scope(new CPPTemplateScope(current_scope)); +} + break; + + case 141: +/* Line 1792 of yacc.c */ +#line 1337 "dtool/src/cppparser/cppBison.yxx" + { + pop_scope(); +} + break; + + case 145: +/* Line 1792 of yacc.c */ +#line 1350 "dtool/src/cppparser/cppBison.yxx" { CPPTemplateScope *ts = current_scope->as_template_scope(); assert(ts != NULL); @@ -4894,9 +5217,9 @@ yyreduce: } break; - case 135: + case 146: /* Line 1792 of yacc.c */ -#line 1290 "dtool/src/cppparser/cppBison.yxx" +#line 1356 "dtool/src/cppparser/cppBison.yxx" { CPPTemplateScope *ts = current_scope->as_template_scope(); assert(ts != NULL); @@ -4904,41 +5227,41 @@ yyreduce: } break; - case 136: + case 147: /* Line 1792 of yacc.c */ -#line 1299 "dtool/src/cppparser/cppBison.yxx" +#line 1365 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (2)].u.identifier))); } break; - case 137: + case 148: /* Line 1792 of yacc.c */ -#line 1303 "dtool/src/cppparser/cppBison.yxx" +#line 1369 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type))); } break; - case 138: + case 149: /* Line 1792 of yacc.c */ -#line 1307 "dtool/src/cppparser/cppBison.yxx" +#line 1373 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (2)].u.identifier))); } break; - case 139: + case 150: /* Line 1792 of yacc.c */ -#line 1311 "dtool/src/cppparser/cppBison.yxx" +#line 1377 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPClassTemplateParameter((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type))); } break; - case 140: + case 151: /* Line 1792 of yacc.c */ -#line 1315 "dtool/src/cppparser/cppBison.yxx" +#line 1381 "dtool/src/cppparser/cppBison.yxx" { CPPInstance *inst = new CPPInstance((yyvsp[(1) - (3)].u.type), (yyvsp[(2) - (3)].u.inst_ident), 0, (yylsp[(2) - (3)]).file); inst->set_initializer((yyvsp[(3) - (3)].u.expr)); @@ -4946,9 +5269,9 @@ yyreduce: } break; - case 141: + case 152: /* Line 1792 of yacc.c */ -#line 1321 "dtool/src/cppparser/cppBison.yxx" +#line 1387 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (4)].u.inst_ident)->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance((yyvsp[(2) - (4)].u.type), (yyvsp[(3) - (4)].u.inst_ident), 0, (yylsp[(3) - (4)]).file); @@ -4957,26 +5280,26 @@ yyreduce: } break; - case 142: + case 153: /* Line 1792 of yacc.c */ -#line 1331 "dtool/src/cppparser/cppBison.yxx" +#line 1397 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; - case 143: + case 154: /* Line 1792 of yacc.c */ -#line 1335 "dtool/src/cppparser/cppBison.yxx" +#line 1401 "dtool/src/cppparser/cppBison.yxx" { yywarning("Not a type: " + (yyvsp[(1) - (1)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (1)])); (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_unknown)); } break; - case 144: + case 155: /* Line 1792 of yacc.c */ -#line 1340 "dtool/src/cppparser/cppBison.yxx" +#line 1406 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if ((yyval.u.type) == NULL) { @@ -4986,17 +5309,17 @@ yyreduce: } break; - case 145: + case 156: /* Line 1792 of yacc.c */ -#line 1352 "dtool/src/cppparser/cppBison.yxx" +#line 1418 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } break; - case 146: + case 157: /* Line 1792 of yacc.c */ -#line 1356 "dtool/src/cppparser/cppBison.yxx" +#line 1422 "dtool/src/cppparser/cppBison.yxx" { // For an operator function. We implement this simply by building a // ficticious name for the function; in other respects it's just @@ -5012,9 +5335,9 @@ yyreduce: } break; - case 147: + case 158: /* Line 1792 of yacc.c */ -#line 1370 "dtool/src/cppparser/cppBison.yxx" +#line 1436 "dtool/src/cppparser/cppBison.yxx" { // A C++11 literal operator. if (!(yyvsp[(2) - (3)].str).empty()) { @@ -5031,98 +5354,89 @@ yyreduce: } break; - case 148: + case 159: /* Line 1792 of yacc.c */ -#line 1385 "dtool/src/cppparser/cppBison.yxx" +#line 1451 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } break; - case 149: + case 160: /* Line 1792 of yacc.c */ -#line 1390 "dtool/src/cppparser/cppBison.yxx" +#line 1456 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } break; - case 150: + case 161: /* Line 1792 of yacc.c */ -#line 1395 "dtool/src/cppparser/cppBison.yxx" +#line 1461 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } break; - case 151: + case 162: /* Line 1792 of yacc.c */ -#line 1400 "dtool/src/cppparser/cppBison.yxx" +#line 1466 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } break; - case 152: + case 163: /* Line 1792 of yacc.c */ -#line 1405 "dtool/src/cppparser/cppBison.yxx" +#line 1471 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } break; - case 153: + case 164: /* Line 1792 of yacc.c */ -#line 1410 "dtool/src/cppparser/cppBison.yxx" +#line 1476 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); } break; - case 154: + case 165: /* Line 1792 of yacc.c */ -#line 1415 "dtool/src/cppparser/cppBison.yxx" +#line 1481 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); } break; - case 155: + case 166: /* Line 1792 of yacc.c */ -#line 1420 "dtool/src/cppparser/cppBison.yxx" - { - // bitfield definition. We ignore the bitfield for now. - (yyval.u.inst_ident) = (yyvsp[(1) - (3)].u.inst_ident); -} - break; - - case 156: -/* Line 1792 of yacc.c */ -#line 1425 "dtool/src/cppparser/cppBison.yxx" +#line 1486 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } break; - case 157: + case 167: /* Line 1792 of yacc.c */ -#line 1430 "dtool/src/cppparser/cppBison.yxx" +#line 1491 "dtool/src/cppparser/cppBison.yxx" { push_scope((yyvsp[(1) - (2)].u.inst_ident)->get_scope(current_scope, global_scope)); } break; - case 158: + case 168: /* Line 1792 of yacc.c */ -#line 1434 "dtool/src/cppparser/cppBison.yxx" +#line 1495 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); (yyval.u.inst_ident) = (yyvsp[(1) - (6)].u.inst_ident); @@ -5138,174 +5452,316 @@ yyreduce: } break; - case 159: + case 169: /* Line 1792 of yacc.c */ -#line 1452 "dtool/src/cppparser/cppBison.yxx" +#line 1513 "dtool/src/cppparser/cppBison.yxx" + { + // This is handled a bit awkwardly right now. Ideally it'd be wrapped + // up in the instance_identifier rule, but then more needs to happen in + // order to avoid shift/reduce conflicts. + if ((yyvsp[(2) - (2)].u.type) != NULL) { + (yyvsp[(1) - (2)].u.inst_ident)->add_trailing_return_type((yyvsp[(2) - (2)].u.type)); + } + (yyval.u.inst_ident) = (yyvsp[(1) - (2)].u.inst_ident); +} + break; + + case 170: +/* Line 1792 of yacc.c */ +#line 1523 "dtool/src/cppparser/cppBison.yxx" + { + // Bitfield definition. + (yyvsp[(1) - (3)].u.inst_ident)->_bit_width = (yyvsp[(3) - (3)].u.integer); + (yyval.u.inst_ident) = (yyvsp[(1) - (3)].u.inst_ident); +} + break; + + case 171: +/* Line 1792 of yacc.c */ +#line 1533 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = NULL; +} + break; + + case 172: +/* Line 1792 of yacc.c */ +#line 1537 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = (yyvsp[(3) - (3)].u.inst_ident)->unroll_type((yyvsp[(2) - (3)].u.type)); +} + break; + + case 173: +/* Line 1792 of yacc.c */ +#line 1541 "dtool/src/cppparser/cppBison.yxx" + { + (yyvsp[(4) - (4)].u.inst_ident)->add_modifier(IIT_const); + (yyval.u.type) = (yyvsp[(4) - (4)].u.inst_ident)->unroll_type((yyvsp[(3) - (4)].u.type)); +} + break; + + case 174: +/* Line 1792 of yacc.c */ +#line 1550 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; } break; - case 160: + case 175: /* Line 1792 of yacc.c */ -#line 1456 "dtool/src/cppparser/cppBison.yxx" +#line 1554 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_includes_ellipsis = true; } break; - case 161: + case 176: /* Line 1792 of yacc.c */ -#line 1461 "dtool/src/cppparser/cppBison.yxx" +#line 1559 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (1)].u.param_list); } break; - case 162: + case 177: /* Line 1792 of yacc.c */ -#line 1465 "dtool/src/cppparser/cppBison.yxx" +#line 1563 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } break; - case 163: + case 178: /* Line 1792 of yacc.c */ -#line 1470 "dtool/src/cppparser/cppBison.yxx" +#line 1568 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (2)].u.param_list); (yyval.u.param_list)->_includes_ellipsis = true; } break; - case 164: + case 179: /* Line 1792 of yacc.c */ -#line 1478 "dtool/src/cppparser/cppBison.yxx" +#line 1576 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = new CPPParameterList; (yyval.u.param_list)->_parameters.push_back((yyvsp[(1) - (1)].u.instance)); } break; - case 165: + case 180: /* Line 1792 of yacc.c */ -#line 1483 "dtool/src/cppparser/cppBison.yxx" +#line 1581 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); (yyval.u.param_list)->_parameters.push_back((yyvsp[(3) - (3)].u.instance)); } break; - case 166: + case 181: /* Line 1792 of yacc.c */ -#line 1491 "dtool/src/cppparser/cppBison.yxx" +#line 1589 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (CPPExpression *)NULL; + (yyval.u.param_list) = new CPPParameterList; } break; - case 167: + case 182: /* Line 1792 of yacc.c */ -#line 1495 "dtool/src/cppparser/cppBison.yxx" +#line 1593 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); + (yyval.u.param_list) = new CPPParameterList; + (yyval.u.param_list)->_includes_ellipsis = true; } break; - case 168: + case 183: /* Line 1792 of yacc.c */ -#line 1502 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (CPPExpression *)NULL; -} - break; - - case 169: -/* Line 1792 of yacc.c */ -#line 1506 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); -} - break; - - case 170: -/* Line 1792 of yacc.c */ -#line 1513 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (CPPExpression *)NULL; -} - break; - - case 171: -/* Line 1792 of yacc.c */ -#line 1517 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (CPPExpression *)NULL; -} - break; - - case 172: -/* Line 1792 of yacc.c */ -#line 1521 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (CPPExpression *)NULL; -} - break; - - case 173: -/* Line 1792 of yacc.c */ -#line 1525 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); -} - break; - - case 174: -/* Line 1792 of yacc.c */ -#line 1529 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); -} - break; - - case 175: -/* Line 1792 of yacc.c */ -#line 1533 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); -} - break; - - case 176: -/* Line 1792 of yacc.c */ -#line 1537 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (CPPExpression *)NULL; -} - break; - - case 180: -/* Line 1792 of yacc.c */ -#line 1550 "dtool/src/cppparser/cppBison.yxx" +#line 1598 "dtool/src/cppparser/cppBison.yxx" { + (yyval.u.param_list) = (yyvsp[(1) - (1)].u.param_list); } break; case 184: /* Line 1792 of yacc.c */ -#line 1559 "dtool/src/cppparser/cppBison.yxx" +#line 1602 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); + (yyval.u.param_list)->_includes_ellipsis = true; +} + break; + + case 185: +/* Line 1792 of yacc.c */ +#line 1607 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.param_list) = (yyvsp[(1) - (2)].u.param_list); + (yyval.u.param_list)->_includes_ellipsis = true; +} + break; + + case 186: +/* Line 1792 of yacc.c */ +#line 1615 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.param_list) = new CPPParameterList; + (yyval.u.param_list)->_parameters.push_back((yyvsp[(1) - (1)].u.instance)); +} + break; + + case 187: +/* Line 1792 of yacc.c */ +#line 1620 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.param_list) = (yyvsp[(1) - (3)].u.param_list); + (yyval.u.param_list)->_parameters.push_back((yyvsp[(3) - (3)].u.instance)); +} + break; + + case 188: +/* Line 1792 of yacc.c */ +#line 1628 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 189: +/* Line 1792 of yacc.c */ +#line 1632 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); +} + break; + + case 190: +/* Line 1792 of yacc.c */ +#line 1639 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 191: +/* Line 1792 of yacc.c */ +#line 1643 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(2) - (2)].u.expr); +} + break; + + case 192: +/* Line 1792 of yacc.c */ +#line 1650 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 193: +/* Line 1792 of yacc.c */ +#line 1654 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 194: +/* Line 1792 of yacc.c */ +#line 1658 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 195: +/* Line 1792 of yacc.c */ +#line 1662 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); +} + break; + + case 196: +/* Line 1792 of yacc.c */ +#line 1666 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); +} + break; + + case 197: +/* Line 1792 of yacc.c */ +#line 1673 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 198: +/* Line 1792 of yacc.c */ +#line 1677 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 199: +/* Line 1792 of yacc.c */ +#line 1681 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); +} + break; + + case 200: +/* Line 1792 of yacc.c */ +#line 1685 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_default()); +} + break; + + case 201: +/* Line 1792 of yacc.c */ +#line 1689 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_delete()); +} + break; + + case 202: +/* Line 1792 of yacc.c */ +#line 1693 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (CPPExpression *)NULL; +} + break; + + case 206: +/* Line 1792 of yacc.c */ +#line 1706 "dtool/src/cppparser/cppBison.yxx" + { +} + break; + + case 210: +/* Line 1792 of yacc.c */ +#line 1715 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.instance) = new CPPInstance((yyvsp[(1) - (3)].u.type), (yyvsp[(2) - (3)].u.inst_ident), 0, (yylsp[(2) - (3)]).file); (yyval.u.instance)->set_initializer((yyvsp[(3) - (3)].u.expr)); } break; - case 185: + case 211: /* Line 1792 of yacc.c */ -#line 1564 "dtool/src/cppparser/cppBison.yxx" +#line 1720 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (4)].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[(2) - (4)].u.type), (yyvsp[(3) - (4)].u.inst_ident), 0, (yylsp[(3) - (4)]).file); @@ -5313,9 +5769,9 @@ yyreduce: } break; - case 186: + case 212: /* Line 1792 of yacc.c */ -#line 1570 "dtool/src/cppparser/cppBison.yxx" +#line 1726 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(4) - (5)].u.inst_ident)->add_modifier(IIT_const); (yyval.u.instance) = new CPPInstance((yyvsp[(3) - (5)].u.type), (yyvsp[(4) - (5)].u.inst_ident), 0, (yylsp[(3) - (5)]).file); @@ -5323,17 +5779,25 @@ yyreduce: } break; - case 187: + case 213: /* Line 1792 of yacc.c */ -#line 1576 "dtool/src/cppparser/cppBison.yxx" +#line 1732 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.instance) = (yyvsp[(2) - (2)].u.instance); } break; - case 188: + case 214: /* Line 1792 of yacc.c */ -#line 1580 "dtool/src/cppparser/cppBison.yxx" +#line 1743 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.instance) = (yyvsp[(1) - (1)].u.instance); +} + break; + + case 215: +/* Line 1792 of yacc.c */ +#line 1747 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_parameter)); @@ -5342,183 +5806,167 @@ yyreduce: } break; - case 189: + case 216: /* Line 1792 of yacc.c */ -#line 1590 "dtool/src/cppparser/cppBison.yxx" +#line 1757 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } break; - case 190: + case 217: /* Line 1792 of yacc.c */ -#line 1594 "dtool/src/cppparser/cppBison.yxx" +#line 1761 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } break; - case 191: + case 218: /* Line 1792 of yacc.c */ -#line 1598 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); -} - break; - - case 192: -/* Line 1792 of yacc.c */ -#line 1602 "dtool/src/cppparser/cppBison.yxx" +#line 1765 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } break; - case 193: + case 219: /* Line 1792 of yacc.c */ -#line 1607 "dtool/src/cppparser/cppBison.yxx" +#line 1770 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } break; - case 194: + case 220: /* Line 1792 of yacc.c */ -#line 1612 "dtool/src/cppparser/cppBison.yxx" +#line 1775 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } break; - case 195: + case 221: /* Line 1792 of yacc.c */ -#line 1617 "dtool/src/cppparser/cppBison.yxx" +#line 1780 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } break; - case 196: + case 222: /* Line 1792 of yacc.c */ -#line 1622 "dtool/src/cppparser/cppBison.yxx" +#line 1785 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } break; - case 197: + case 223: /* Line 1792 of yacc.c */ -#line 1627 "dtool/src/cppparser/cppBison.yxx" +#line 1790 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); } break; - case 198: + case 224: /* Line 1792 of yacc.c */ -#line 1632 "dtool/src/cppparser/cppBison.yxx" +#line 1795 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); } break; - case 199: + case 225: /* Line 1792 of yacc.c */ -#line 1640 "dtool/src/cppparser/cppBison.yxx" +#line 1803 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } break; - case 200: + case 226: /* Line 1792 of yacc.c */ -#line 1644 "dtool/src/cppparser/cppBison.yxx" +#line 1807 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); } break; - case 201: + case 227: /* Line 1792 of yacc.c */ -#line 1648 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.inst_ident) = new CPPInstanceIdentifier((yyvsp[(1) - (1)].u.identifier)); -} - break; - - case 202: -/* Line 1792 of yacc.c */ -#line 1652 "dtool/src/cppparser/cppBison.yxx" +#line 1811 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } break; - case 203: + case 228: /* Line 1792 of yacc.c */ -#line 1657 "dtool/src/cppparser/cppBison.yxx" +#line 1816 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } break; - case 204: + case 229: /* Line 1792 of yacc.c */ -#line 1662 "dtool/src/cppparser/cppBison.yxx" +#line 1821 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } break; - case 205: + case 230: /* Line 1792 of yacc.c */ -#line 1667 "dtool/src/cppparser/cppBison.yxx" +#line 1826 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } break; - case 206: + case 231: /* Line 1792 of yacc.c */ -#line 1672 "dtool/src/cppparser/cppBison.yxx" +#line 1831 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } break; - case 207: + case 232: /* Line 1792 of yacc.c */ -#line 1677 "dtool/src/cppparser/cppBison.yxx" +#line 1836 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); } break; - case 208: + case 233: /* Line 1792 of yacc.c */ -#line 1682 "dtool/src/cppparser/cppBison.yxx" +#line 1841 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); } break; - case 209: + case 234: /* Line 1792 of yacc.c */ -#line 1687 "dtool/src/cppparser/cppBison.yxx" +#line 1846 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (7)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); @@ -5526,107 +5974,211 @@ yyreduce: } break; - case 210: + case 235: /* Line 1792 of yacc.c */ -#line 1693 "dtool/src/cppparser/cppBison.yxx" +#line 1852 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_paren); } break; - case 211: + case 236: /* Line 1792 of yacc.c */ -#line 1701 "dtool/src/cppparser/cppBison.yxx" +#line 1860 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } break; - case 212: + case 237: /* Line 1792 of yacc.c */ -#line 1705 "dtool/src/cppparser/cppBison.yxx" +#line 1864 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_const); } break; - case 213: + case 238: /* Line 1792 of yacc.c */ -#line 1710 "dtool/src/cppparser/cppBison.yxx" +#line 1869 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_volatile); } break; - case 214: + case 239: /* Line 1792 of yacc.c */ -#line 1715 "dtool/src/cppparser/cppBison.yxx" +#line 1874 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_pointer); } break; - case 215: + case 240: /* Line 1792 of yacc.c */ -#line 1720 "dtool/src/cppparser/cppBison.yxx" +#line 1879 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_reference); } break; - case 216: + case 241: /* Line 1792 of yacc.c */ -#line 1725 "dtool/src/cppparser/cppBison.yxx" +#line 1884 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); } break; - case 217: + case 242: /* Line 1792 of yacc.c */ -#line 1730 "dtool/src/cppparser/cppBison.yxx" +#line 1889 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); } break; - case 218: + case 243: /* Line 1792 of yacc.c */ -#line 1735 "dtool/src/cppparser/cppBison.yxx" +#line 1894 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); } break; - case 219: + case 244: /* Line 1792 of yacc.c */ -#line 1740 "dtool/src/cppparser/cppBison.yxx" +#line 1902 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.inst_ident) = (yyvsp[(2) - (7)].u.inst_ident); - (yyval.u.inst_ident)->add_modifier(IIT_paren); - (yyval.u.inst_ident)->add_func_modifier((yyvsp[(5) - (7)].u.param_list), (yyvsp[(7) - (7)].u.integer)); + (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } break; - case 220: + case 245: /* Line 1792 of yacc.c */ -#line 1749 "dtool/src/cppparser/cppBison.yxx" +#line 1906 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_const); +} + break; + + case 246: +/* Line 1792 of yacc.c */ +#line 1911 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_volatile); +} + break; + + case 247: +/* Line 1792 of yacc.c */ +#line 1916 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_pointer); +} + break; + + case 248: +/* Line 1792 of yacc.c */ +#line 1921 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_reference); +} + break; + + case 249: +/* Line 1792 of yacc.c */ +#line 1926 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(2) - (2)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); +} + break; + + case 250: +/* Line 1792 of yacc.c */ +#line 1931 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(3) - (3)].u.inst_ident); + (yyval.u.inst_ident)->add_scoped_pointer_modifier((yyvsp[(1) - (3)].u.identifier)); +} + break; + + case 251: +/* Line 1792 of yacc.c */ +#line 1936 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(1) - (4)].u.inst_ident); + (yyval.u.inst_ident)->add_array_modifier((yyvsp[(3) - (4)].u.expr)); +} + break; + + case 252: +/* Line 1792 of yacc.c */ +#line 1941 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = new CPPInstanceIdentifier((CPPIdentifier *)NULL); + (yyval.u.inst_ident)->add_modifier(IIT_paren); + (yyval.u.inst_ident)->add_func_modifier((yyvsp[(2) - (5)].u.param_list), (yyvsp[(4) - (5)].u.integer), (yyvsp[(5) - (5)].u.type)); +} + break; + + case 253: +/* Line 1792 of yacc.c */ +#line 1947 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(3) - (9)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_pointer); + (yyval.u.inst_ident)->add_modifier(IIT_paren); + (yyval.u.inst_ident)->add_func_modifier((yyvsp[(6) - (9)].u.param_list), (yyvsp[(8) - (9)].u.integer), (yyvsp[(9) - (9)].u.type)); +} + break; + + case 254: +/* Line 1792 of yacc.c */ +#line 1954 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(3) - (9)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_reference); + (yyval.u.inst_ident)->add_modifier(IIT_paren); + (yyval.u.inst_ident)->add_func_modifier((yyvsp[(6) - (9)].u.param_list), (yyvsp[(8) - (9)].u.integer), (yyvsp[(9) - (9)].u.type)); +} + break; + + case 255: +/* Line 1792 of yacc.c */ +#line 1961 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.inst_ident) = (yyvsp[(3) - (9)].u.inst_ident); + (yyval.u.inst_ident)->add_modifier(IIT_rvalue_reference); + (yyval.u.inst_ident)->add_modifier(IIT_paren); + (yyval.u.inst_ident)->add_func_modifier((yyvsp[(6) - (9)].u.param_list), (yyvsp[(8) - (9)].u.integer), (yyvsp[(9) - (9)].u.type)); +} + break; + + case 256: +/* Line 1792 of yacc.c */ +#line 1971 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; - case 221: + case 257: /* Line 1792 of yacc.c */ -#line 1753 "dtool/src/cppparser/cppBison.yxx" +#line 1975 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if ((yyval.u.type) == NULL) { @@ -5636,41 +6188,41 @@ yyreduce: } break; - case 222: + case 258: /* Line 1792 of yacc.c */ -#line 1761 "dtool/src/cppparser/cppBison.yxx" +#line 1983 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } break; - case 223: + case 259: /* Line 1792 of yacc.c */ -#line 1765 "dtool/src/cppparser/cppBison.yxx" +#line 1987 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); } break; - case 224: + case 260: /* Line 1792 of yacc.c */ -#line 1769 "dtool/src/cppparser/cppBison.yxx" +#line 1991 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); } break; - case 225: + case 261: /* Line 1792 of yacc.c */ -#line 1773 "dtool/src/cppparser/cppBison.yxx" +#line 1995 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.enum_type)); } break; - case 226: + case 262: /* Line 1792 of yacc.c */ -#line 1777 "dtool/src/cppparser/cppBison.yxx" +#line 1999 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5688,9 +6240,9 @@ yyreduce: } break; - case 227: + case 263: /* Line 1792 of yacc.c */ -#line 1793 "dtool/src/cppparser/cppBison.yxx" +#line 2015 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5708,9 +6260,9 @@ yyreduce: } break; - case 228: + case 264: /* Line 1792 of yacc.c */ -#line 1809 "dtool/src/cppparser/cppBison.yxx" +#line 2031 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(3) - (4)].u.expr)->determine_type(); if ((yyval.u.type) == (CPPType *)NULL) { @@ -5721,25 +6273,25 @@ yyreduce: } break; - case 229: + case 265: /* Line 1792 of yacc.c */ -#line 1818 "dtool/src/cppparser/cppBison.yxx" +#line 2040 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.type) = new CPPSimpleType(CPPSimpleType::T_auto); + (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } break; - case 230: + case 266: /* Line 1792 of yacc.c */ -#line 1825 "dtool/src/cppparser/cppBison.yxx" +#line 2047 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; - case 231: + case 267: /* Line 1792 of yacc.c */ -#line 1829 "dtool/src/cppparser/cppBison.yxx" +#line 2051 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if ((yyval.u.decl) == NULL) { @@ -5749,41 +6301,41 @@ yyreduce: } break; - case 232: + case 268: /* Line 1792 of yacc.c */ -#line 1837 "dtool/src/cppparser/cppBison.yxx" +#line 2059 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } break; - case 233: + case 269: /* Line 1792 of yacc.c */ -#line 1841 "dtool/src/cppparser/cppBison.yxx" +#line 2063 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = CPPType::new_type((yyvsp[(1) - (1)].u.struct_type)); } break; - case 234: + case 270: /* Line 1792 of yacc.c */ -#line 1845 "dtool/src/cppparser/cppBison.yxx" +#line 2067 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.struct_type))); } break; - case 235: + case 271: /* Line 1792 of yacc.c */ -#line 1849 "dtool/src/cppparser/cppBison.yxx" +#line 2071 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = new CPPTypeDeclaration(CPPType::new_type((yyvsp[(1) - (1)].u.enum_type))); } break; - case 236: + case 272: /* Line 1792 of yacc.c */ -#line 1853 "dtool/src/cppparser/cppBison.yxx" +#line 2075 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5801,9 +6353,9 @@ yyreduce: } break; - case 237: + case 273: /* Line 1792 of yacc.c */ -#line 1869 "dtool/src/cppparser/cppBison.yxx" +#line 2091 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5821,9 +6373,9 @@ yyreduce: } break; - case 238: + case 274: /* Line 1792 of yacc.c */ -#line 1885 "dtool/src/cppparser/cppBison.yxx" +#line 2107 "dtool/src/cppparser/cppBison.yxx" { yywarning(string("C++ does not permit forward declaration of untyped enum ") + (yyvsp[(2) - (2)].u.identifier)->get_fully_scoped_name(), (yylsp[(1) - (2)])); @@ -5843,9 +6395,9 @@ yyreduce: } break; - case 239: + case 275: /* Line 1792 of yacc.c */ -#line 1903 "dtool/src/cppparser/cppBison.yxx" +#line 2125 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = (yyvsp[(3) - (4)].u.expr)->determine_type(); if ((yyval.u.decl) == (CPPType *)NULL) { @@ -5856,25 +6408,25 @@ yyreduce: } break; - case 240: + case 276: /* Line 1792 of yacc.c */ -#line 1912 "dtool/src/cppparser/cppBison.yxx" +#line 2134 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.decl) = new CPPSimpleType(CPPSimpleType::T_auto); + (yyval.u.decl) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } break; - case 241: + case 277: /* Line 1792 of yacc.c */ -#line 1919 "dtool/src/cppparser/cppBison.yxx" +#line 2141 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; - case 242: + case 278: /* Line 1792 of yacc.c */ -#line 1923 "dtool/src/cppparser/cppBison.yxx" +#line 2145 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if ((yyval.u.type) == NULL) { @@ -5884,17 +6436,17 @@ yyreduce: } break; - case 243: + case 279: /* Line 1792 of yacc.c */ -#line 1931 "dtool/src/cppparser/cppBison.yxx" +#line 2153 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } break; - case 244: + case 280: /* Line 1792 of yacc.c */ -#line 1935 "dtool/src/cppparser/cppBison.yxx" +#line 2157 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5912,9 +6464,9 @@ yyreduce: } break; - case 245: + case 281: /* Line 1792 of yacc.c */ -#line 1951 "dtool/src/cppparser/cppBison.yxx" +#line 2173 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -5932,17 +6484,38 @@ yyreduce: } break; - case 246: + case 282: /* Line 1792 of yacc.c */ -#line 1970 "dtool/src/cppparser/cppBison.yxx" +#line 2189 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = (yyvsp[(3) - (4)].u.expr)->determine_type(); + if ((yyval.u.type) == (CPPType *)NULL) { + stringstream str; + str << *(yyvsp[(3) - (4)].u.expr); + yyerror("could not determine type of " + str.str(), (yylsp[(3) - (4)])); + } +} + break; + + case 283: +/* Line 1792 of yacc.c */ +#line 2198 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.type) = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); +} + break; + + case 284: +/* Line 1792 of yacc.c */ +#line 2205 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.decl) = (yyvsp[(1) - (1)].u.decl); } break; - case 247: + case 285: /* Line 1792 of yacc.c */ -#line 1974 "dtool/src/cppparser/cppBison.yxx" +#line 2209 "dtool/src/cppparser/cppBison.yxx" { yyerror(string("unknown type '") + (yyvsp[(1) - (1)].u.identifier)->get_fully_scoped_name() + "'", (yylsp[(1) - (1)])); @@ -5950,30 +6523,26 @@ yyreduce: } break; - case 248: + case 286: /* Line 1792 of yacc.c */ -#line 1982 "dtool/src/cppparser/cppBison.yxx" +#line 2217 "dtool/src/cppparser/cppBison.yxx" { - CPPInstance *inst = new CPPInstance((yyvsp[(1) - (2)].u.type), (yyvsp[(2) - (2)].u.inst_ident), 0, (yylsp[(1) - (2)]).file); - (yyval.u.type) = inst->_type; - delete inst; + (yyval.u.type) = (yyvsp[(2) - (2)].u.inst_ident)->unroll_type((yyvsp[(1) - (2)].u.type)); } break; - case 249: + case 287: /* Line 1792 of yacc.c */ -#line 1988 "dtool/src/cppparser/cppBison.yxx" +#line 2221 "dtool/src/cppparser/cppBison.yxx" { (yyvsp[(3) - (3)].u.inst_ident)->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance((yyvsp[(2) - (3)].u.type), (yyvsp[(3) - (3)].u.inst_ident), 0, (yylsp[(1) - (3)]).file); - (yyval.u.type) = inst->_type; - delete inst; + (yyval.u.type) = (yyvsp[(3) - (3)].u.inst_ident)->unroll_type((yyvsp[(2) - (3)].u.type)); } break; - case 250: + case 288: /* Line 1792 of yacc.c */ -#line 1998 "dtool/src/cppparser/cppBison.yxx" +#line 2229 "dtool/src/cppparser/cppBison.yxx" { CPPVisibility starting_vis = ((yyvsp[(1) - (2)].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; @@ -5989,9 +6558,9 @@ yyreduce: } break; - case 251: + case 289: /* Line 1792 of yacc.c */ -#line 2012 "dtool/src/cppparser/cppBison.yxx" +#line 2243 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; @@ -6000,9 +6569,9 @@ yyreduce: } break; - case 252: + case 290: /* Line 1792 of yacc.c */ -#line 2022 "dtool/src/cppparser/cppBison.yxx" +#line 2253 "dtool/src/cppparser/cppBison.yxx" { CPPVisibility starting_vis = ((yyvsp[(1) - (2)].u.extension_enum) == CPPExtensionType::T_class) ? V_private : V_public; @@ -6024,9 +6593,9 @@ yyreduce: } break; - case 253: + case 291: /* Line 1792 of yacc.c */ -#line 2042 "dtool/src/cppparser/cppBison.yxx" +#line 2273 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.struct_type) = current_struct; current_struct->_incomplete = false; @@ -6035,138 +6604,154 @@ yyreduce: } break; - case 258: + case 293: /* Line 1792 of yacc.c */ -#line 2062 "dtool/src/cppparser/cppBison.yxx" +#line 2284 "dtool/src/cppparser/cppBison.yxx" + { + current_struct->_final = true; +} + break; + + case 298: +/* Line 1792 of yacc.c */ +#line 2301 "dtool/src/cppparser/cppBison.yxx" + { + current_struct->append_derivation((yyvsp[(1) - (1)].u.type), V_unknown, false); +} + break; + + case 299: +/* Line 1792 of yacc.c */ +#line 2305 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_public, false); } break; - case 259: + case 300: /* Line 1792 of yacc.c */ -#line 2066 "dtool/src/cppparser/cppBison.yxx" +#line 2309 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_protected, false); } break; - case 260: + case 301: /* Line 1792 of yacc.c */ -#line 2070 "dtool/src/cppparser/cppBison.yxx" +#line 2313 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(2) - (2)].u.type), V_private, false); } break; - case 261: + case 302: /* Line 1792 of yacc.c */ -#line 2074 "dtool/src/cppparser/cppBison.yxx" +#line 2317 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_public, true); } break; - case 262: + case 303: /* Line 1792 of yacc.c */ -#line 2078 "dtool/src/cppparser/cppBison.yxx" +#line 2321 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_protected, true); } break; - case 263: + case 304: /* Line 1792 of yacc.c */ -#line 2082 "dtool/src/cppparser/cppBison.yxx" +#line 2325 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_private, true); } break; - case 264: + case 305: /* Line 1792 of yacc.c */ -#line 2086 "dtool/src/cppparser/cppBison.yxx" +#line 2329 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_public, true); } break; - case 265: + case 306: /* Line 1792 of yacc.c */ -#line 2090 "dtool/src/cppparser/cppBison.yxx" +#line 2333 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_protected, true); } break; - case 266: + case 307: /* Line 1792 of yacc.c */ -#line 2094 "dtool/src/cppparser/cppBison.yxx" +#line 2337 "dtool/src/cppparser/cppBison.yxx" { current_struct->append_derivation((yyvsp[(3) - (3)].u.type), V_private, true); } break; - case 267: + case 308: /* Line 1792 of yacc.c */ -#line 2101 "dtool/src/cppparser/cppBison.yxx" +#line 2344 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.enum_type) = current_enum; current_enum = NULL; } break; - case 268: + case 309: /* Line 1792 of yacc.c */ -#line 2109 "dtool/src/cppparser/cppBison.yxx" +#line 2352 "dtool/src/cppparser/cppBison.yxx" { current_enum = new CPPEnumType((yyvsp[(2) - (4)].u.identifier), (yyvsp[(4) - (4)].u.type), current_scope, (yylsp[(1) - (4)]).file); } break; - case 269: + case 310: /* Line 1792 of yacc.c */ -#line 2113 "dtool/src/cppparser/cppBison.yxx" +#line 2356 "dtool/src/cppparser/cppBison.yxx" { current_enum = new CPPEnumType((yyvsp[(2) - (2)].u.identifier), current_scope, (yylsp[(1) - (2)]).file); } break; - case 270: + case 311: /* Line 1792 of yacc.c */ -#line 2117 "dtool/src/cppparser/cppBison.yxx" +#line 2360 "dtool/src/cppparser/cppBison.yxx" { current_enum = new CPPEnumType(NULL, (yyvsp[(3) - (3)].u.type), current_scope, (yylsp[(1) - (3)]).file); } break; - case 271: + case 312: /* Line 1792 of yacc.c */ -#line 2121 "dtool/src/cppparser/cppBison.yxx" +#line 2364 "dtool/src/cppparser/cppBison.yxx" { current_enum = new CPPEnumType(NULL, current_scope, (yylsp[(1) - (1)]).file); } break; - case 272: + case 313: /* Line 1792 of yacc.c */ -#line 2128 "dtool/src/cppparser/cppBison.yxx" +#line 2371 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type((yyvsp[(1) - (1)].u.simple_type)); } break; - case 273: + case 314: /* Line 1792 of yacc.c */ -#line 2132 "dtool/src/cppparser/cppBison.yxx" +#line 2375 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); } break; - case 275: + case 316: /* Line 1792 of yacc.c */ -#line 2140 "dtool/src/cppparser/cppBison.yxx" +#line 2383 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (3)].u.identifier)->get_simple_name()); @@ -6174,9 +6759,9 @@ yyreduce: } break; - case 276: + case 317: /* Line 1792 of yacc.c */ -#line 2146 "dtool/src/cppparser/cppBison.yxx" +#line 2389 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (5)].u.identifier)->get_simple_name(), (yyvsp[(4) - (5)].u.expr)); @@ -6184,9 +6769,9 @@ yyreduce: } break; - case 278: + case 319: /* Line 1792 of yacc.c */ -#line 2155 "dtool/src/cppparser/cppBison.yxx" +#line 2398 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (2)].u.identifier)->get_simple_name()); @@ -6194,9 +6779,9 @@ yyreduce: } break; - case 279: + case 320: /* Line 1792 of yacc.c */ -#line 2161 "dtool/src/cppparser/cppBison.yxx" +#line 2404 "dtool/src/cppparser/cppBison.yxx" { assert(current_enum != NULL); CPPInstance *inst = current_enum->add_element((yyvsp[(2) - (4)].u.identifier)->get_simple_name(), (yyvsp[(4) - (4)].u.expr)); @@ -6204,41 +6789,41 @@ yyreduce: } break; - case 280: + case 321: /* Line 1792 of yacc.c */ -#line 2170 "dtool/src/cppparser/cppBison.yxx" +#line 2413 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_enum; } break; - case 281: + case 322: /* Line 1792 of yacc.c */ -#line 2177 "dtool/src/cppparser/cppBison.yxx" +#line 2420 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_class; } break; - case 282: + case 323: /* Line 1792 of yacc.c */ -#line 2181 "dtool/src/cppparser/cppBison.yxx" +#line 2424 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_struct; } break; - case 283: + case 324: /* Line 1792 of yacc.c */ -#line 2185 "dtool/src/cppparser/cppBison.yxx" +#line 2428 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.extension_enum) = CPPExtensionType::T_union; } break; - case 284: + case 325: /* Line 1792 of yacc.c */ -#line 2192 "dtool/src/cppparser/cppBison.yxx" +#line 2435 "dtool/src/cppparser/cppBison.yxx" { CPPScope *scope = (yyvsp[(2) - (3)].u.identifier)->find_scope(current_scope, global_scope, current_lexer); if (scope == NULL) { @@ -6258,17 +6843,17 @@ yyreduce: } break; - case 285: + case 326: /* Line 1792 of yacc.c */ -#line 2210 "dtool/src/cppparser/cppBison.yxx" +#line 2453 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); } break; - case 286: + case 327: /* Line 1792 of yacc.c */ -#line 2214 "dtool/src/cppparser/cppBison.yxx" +#line 2457 "dtool/src/cppparser/cppBison.yxx" { CPPScope *scope = (yyvsp[(3) - (4)].u.identifier)->find_scope(current_scope, global_scope, current_lexer); if (scope == NULL) { @@ -6289,139 +6874,141 @@ yyreduce: } break; - case 287: + case 328: /* Line 1792 of yacc.c */ -#line 2233 "dtool/src/cppparser/cppBison.yxx" +#line 2476 "dtool/src/cppparser/cppBison.yxx" { pop_scope(); } break; - case 290: + case 331: /* Line 1792 of yacc.c */ -#line 2242 "dtool/src/cppparser/cppBison.yxx" +#line 2485 "dtool/src/cppparser/cppBison.yxx" { - CPPUsing *using_decl = new CPPUsing((yyvsp[(2) - (2)].u.identifier), false, (yylsp[(1) - (2)]).file); - current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[(1) - (2)])); - current_scope->add_using(using_decl, global_scope, current_lexer); -} - break; - - case 291: -/* Line 1792 of yacc.c */ -#line 2248 "dtool/src/cppparser/cppBison.yxx" - { - CPPUsing *using_decl = new CPPUsing((yyvsp[(3) - (3)].u.identifier), true, (yylsp[(1) - (3)]).file); + CPPUsing *using_decl = new CPPUsing((yyvsp[(2) - (3)].u.identifier), false, (yylsp[(1) - (3)]).file); current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[(1) - (3)])); current_scope->add_using(using_decl, global_scope, current_lexer); } break; - case 295: + case 332: /* Line 1792 of yacc.c */ -#line 2263 "dtool/src/cppparser/cppBison.yxx" +#line 2491 "dtool/src/cppparser/cppBison.yxx" + { + // This is really just an alternative way to declare a typedef. + CPPTypedefType *typedef_type = new CPPTypedefType((yyvsp[(4) - (5)].u.type), (yyvsp[(2) - (5)].u.identifier), current_scope); + typedef_type->_using = true; + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, (yylsp[(1) - (5)])); +} + break; + + case 333: +/* Line 1792 of yacc.c */ +#line 2498 "dtool/src/cppparser/cppBison.yxx" + { + CPPUsing *using_decl = new CPPUsing((yyvsp[(3) - (4)].u.identifier), true, (yylsp[(1) - (4)]).file); + current_scope->add_declaration(using_decl, global_scope, current_lexer, (yylsp[(1) - (4)])); + current_scope->add_using(using_decl, global_scope, current_lexer); +} + break; + + case 337: +/* Line 1792 of yacc.c */ +#line 2513 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_bool); } break; - case 296: + case 338: /* Line 1792 of yacc.c */ -#line 2267 "dtool/src/cppparser/cppBison.yxx" +#line 2517 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char); } break; - case 297: + case 339: /* Line 1792 of yacc.c */ -#line 2271 "dtool/src/cppparser/cppBison.yxx" +#line 2521 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_wchar_t); } break; - case 298: + case 340: /* Line 1792 of yacc.c */ -#line 2275 "dtool/src/cppparser/cppBison.yxx" +#line 2525 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char16_t); } break; - case 299: + case 341: /* Line 1792 of yacc.c */ -#line 2279 "dtool/src/cppparser/cppBison.yxx" +#line 2529 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_char32_t); } break; - case 300: + case 342: /* Line 1792 of yacc.c */ -#line 2283 "dtool/src/cppparser/cppBison.yxx" +#line 2533 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_short); } break; - case 301: + case 343: /* Line 1792 of yacc.c */ -#line 2288 "dtool/src/cppparser/cppBison.yxx" +#line 2538 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long); } break; - case 302: + case 344: /* Line 1792 of yacc.c */ -#line 2293 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, - CPPSimpleType::F_longlong); -} - break; - - case 303: -/* Line 1792 of yacc.c */ -#line 2298 "dtool/src/cppparser/cppBison.yxx" +#line 2543 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_unsigned); } break; - case 304: + case 345: /* Line 1792 of yacc.c */ -#line 2303 "dtool/src/cppparser/cppBison.yxx" +#line 2548 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_signed); } break; - case 305: + case 346: /* Line 1792 of yacc.c */ -#line 2308 "dtool/src/cppparser/cppBison.yxx" +#line 2553 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_int); } break; - case 306: + case 347: /* Line 1792 of yacc.c */ -#line 2312 "dtool/src/cppparser/cppBison.yxx" +#line 2557 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_short; } break; - case 307: + case 348: /* Line 1792 of yacc.c */ -#line 2317 "dtool/src/cppparser/cppBison.yxx" +#line 2562 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); if ((yyval.u.simple_type)->_flags & CPPSimpleType::F_long) { @@ -6432,453 +7019,475 @@ yyreduce: } break; - case 308: + case 349: /* Line 1792 of yacc.c */ -#line 2326 "dtool/src/cppparser/cppBison.yxx" +#line 2571 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_unsigned; } break; - case 309: + case 350: /* Line 1792 of yacc.c */ -#line 2331 "dtool/src/cppparser/cppBison.yxx" +#line 2576 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = (yyvsp[(2) - (2)].u.simple_type); (yyval.u.simple_type)->_flags |= CPPSimpleType::F_signed; } break; - case 310: + case 351: /* Line 1792 of yacc.c */ -#line 2339 "dtool/src/cppparser/cppBison.yxx" +#line 2584 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float); } break; - case 311: + case 352: /* Line 1792 of yacc.c */ -#line 2343 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float, - CPPSimpleType::F_long); -} - break; - - case 312: -/* Line 1792 of yacc.c */ -#line 2348 "dtool/src/cppparser/cppBison.yxx" +#line 2588 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double); } break; - case 313: + case 353: /* Line 1792 of yacc.c */ -#line 2352 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_float, - CPPSimpleType::F_longlong); -} - break; - - case 314: -/* Line 1792 of yacc.c */ -#line 2357 "dtool/src/cppparser/cppBison.yxx" +#line 2592 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_double, CPPSimpleType::F_long); } break; - case 315: + case 354: /* Line 1792 of yacc.c */ -#line 2365 "dtool/src/cppparser/cppBison.yxx" +#line 2600 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.simple_type) = new CPPSimpleType(CPPSimpleType::T_void); } break; - case 316: + case 355: /* Line 1792 of yacc.c */ -#line 2374 "dtool/src/cppparser/cppBison.yxx" +#line 2609 "dtool/src/cppparser/cppBison.yxx" { current_lexer->_resolve_identifiers = false; } break; - case 317: + case 356: /* Line 1792 of yacc.c */ -#line 2378 "dtool/src/cppparser/cppBison.yxx" +#line 2613 "dtool/src/cppparser/cppBison.yxx" { current_lexer->_resolve_identifiers = true; } break; - case 414: + case 459: /* Line 1792 of yacc.c */ -#line 2418 "dtool/src/cppparser/cppBison.yxx" +#line 2654 "dtool/src/cppparser/cppBison.yxx" { } break; - case 438: + case 483: /* Line 1792 of yacc.c */ -#line 2427 "dtool/src/cppparser/cppBison.yxx" +#line 2663 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } break; - case 439: + case 484: /* Line 1792 of yacc.c */ -#line 2431 "dtool/src/cppparser/cppBison.yxx" +#line 2667 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 440: + case 485: /* Line 1792 of yacc.c */ -#line 2438 "dtool/src/cppparser/cppBison.yxx" +#line 2674 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (CPPExpression *)NULL; } break; - case 441: + case 486: /* Line 1792 of yacc.c */ -#line 2442 "dtool/src/cppparser/cppBison.yxx" +#line 2678 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 442: + case 487: /* Line 1792 of yacc.c */ -#line 2449 "dtool/src/cppparser/cppBison.yxx" +#line 2685 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 443: + case 488: /* Line 1792 of yacc.c */ -#line 2453 "dtool/src/cppparser/cppBison.yxx" +#line 2689 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(',', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 444: + case 489: /* Line 1792 of yacc.c */ -#line 2460 "dtool/src/cppparser/cppBison.yxx" +#line 2696 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 445: + case 490: /* Line 1792 of yacc.c */ -#line 2464 "dtool/src/cppparser/cppBison.yxx" +#line 2700 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); } break; - case 446: + case 491: /* Line 1792 of yacc.c */ -#line 2468 "dtool/src/cppparser/cppBison.yxx" +#line 2704 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_static_cast)); } break; - case 447: + case 492: /* Line 1792 of yacc.c */ -#line 2472 "dtool/src/cppparser/cppBison.yxx" +#line 2708 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_dynamic_cast)); } break; - case 448: + case 493: /* Line 1792 of yacc.c */ -#line 2476 "dtool/src/cppparser/cppBison.yxx" +#line 2712 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_const_cast)); +} + break; + + case 494: +/* Line 1792 of yacc.c */ +#line 2716 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_reinterpret_cast)); +} + break; + + case 495: +/* Line 1792 of yacc.c */ +#line 2720 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); } break; - case 449: + case 496: /* Line 1792 of yacc.c */ -#line 2480 "dtool/src/cppparser/cppBison.yxx" +#line 2724 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[(3) - (4)].u.type))); } break; - case 450: + case 497: /* Line 1792 of yacc.c */ -#line 2484 "dtool/src/cppparser/cppBison.yxx" +#line 2728 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); } break; - case 451: + case 498: /* Line 1792 of yacc.c */ -#line 2488 "dtool/src/cppparser/cppBison.yxx" +#line 2732 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); } break; - case 452: + case 499: /* Line 1792 of yacc.c */ -#line 2492 "dtool/src/cppparser/cppBison.yxx" +#line 2736 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); } break; - case 453: + case 500: /* Line 1792 of yacc.c */ -#line 2496 "dtool/src/cppparser/cppBison.yxx" +#line 2740 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 501: +/* Line 1792 of yacc.c */ +#line 2744 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); } break; - case 454: + case 502: /* Line 1792 of yacc.c */ -#line 2500 "dtool/src/cppparser/cppBison.yxx" +#line 2748 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); } break; - case 455: + case 503: /* Line 1792 of yacc.c */ -#line 2504 "dtool/src/cppparser/cppBison.yxx" +#line 2752 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 456: + case 504: /* Line 1792 of yacc.c */ -#line 2508 "dtool/src/cppparser/cppBison.yxx" +#line 2756 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 457: + case 505: /* Line 1792 of yacc.c */ -#line 2512 "dtool/src/cppparser/cppBison.yxx" +#line 2760 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 458: + case 506: /* Line 1792 of yacc.c */ -#line 2516 "dtool/src/cppparser/cppBison.yxx" +#line 2764 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 459: + case 507: /* Line 1792 of yacc.c */ -#line 2520 "dtool/src/cppparser/cppBison.yxx" +#line 2768 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 460: + case 508: /* Line 1792 of yacc.c */ -#line 2524 "dtool/src/cppparser/cppBison.yxx" +#line 2772 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 461: + case 509: /* Line 1792 of yacc.c */ -#line 2528 "dtool/src/cppparser/cppBison.yxx" +#line 2776 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 462: + case 510: /* Line 1792 of yacc.c */ -#line 2532 "dtool/src/cppparser/cppBison.yxx" +#line 2780 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 463: + case 511: /* Line 1792 of yacc.c */ -#line 2536 "dtool/src/cppparser/cppBison.yxx" +#line 2784 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 464: + case 512: /* Line 1792 of yacc.c */ -#line 2540 "dtool/src/cppparser/cppBison.yxx" +#line 2788 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 465: + case 513: /* Line 1792 of yacc.c */ -#line 2544 "dtool/src/cppparser/cppBison.yxx" +#line 2792 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 466: + case 514: /* Line 1792 of yacc.c */ -#line 2548 "dtool/src/cppparser/cppBison.yxx" +#line 2796 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 467: + case 515: /* Line 1792 of yacc.c */ -#line 2552 "dtool/src/cppparser/cppBison.yxx" +#line 2800 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 468: + case 516: /* Line 1792 of yacc.c */ -#line 2556 "dtool/src/cppparser/cppBison.yxx" +#line 2804 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 469: + case 517: /* Line 1792 of yacc.c */ -#line 2560 "dtool/src/cppparser/cppBison.yxx" +#line 2808 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 470: + case 518: /* Line 1792 of yacc.c */ -#line 2564 "dtool/src/cppparser/cppBison.yxx" +#line 2812 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 471: + case 519: /* Line 1792 of yacc.c */ -#line 2568 "dtool/src/cppparser/cppBison.yxx" +#line 2816 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); } break; - case 472: + case 520: /* Line 1792 of yacc.c */ -#line 2572 "dtool/src/cppparser/cppBison.yxx" +#line 2820 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 473: + case 521: /* Line 1792 of yacc.c */ -#line 2576 "dtool/src/cppparser/cppBison.yxx" +#line 2824 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; - case 474: + case 522: /* Line 1792 of yacc.c */ -#line 2580 "dtool/src/cppparser/cppBison.yxx" +#line 2828 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); } break; - case 475: + case 523: /* Line 1792 of yacc.c */ -#line 2584 "dtool/src/cppparser/cppBison.yxx" +#line 2832 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 476: + case 524: /* Line 1792 of yacc.c */ -#line 2588 "dtool/src/cppparser/cppBison.yxx" +#line 2836 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; - case 477: + case 525: /* Line 1792 of yacc.c */ -#line 2592 "dtool/src/cppparser/cppBison.yxx" +#line 2840 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); } break; - case 478: + case 526: /* Line 1792 of yacc.c */ -#line 2600 "dtool/src/cppparser/cppBison.yxx" +#line 2848 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 479: + case 527: /* Line 1792 of yacc.c */ -#line 2604 "dtool/src/cppparser/cppBison.yxx" +#line 2852 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); } break; - case 480: + case 528: /* Line 1792 of yacc.c */ -#line 2608 "dtool/src/cppparser/cppBison.yxx" +#line 2856 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_static_cast)); } break; - case 481: + case 529: /* Line 1792 of yacc.c */ -#line 2612 "dtool/src/cppparser/cppBison.yxx" +#line 2860 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_dynamic_cast)); } break; - case 482: + case 530: /* Line 1792 of yacc.c */ -#line 2616 "dtool/src/cppparser/cppBison.yxx" +#line 2864 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_const_cast)); +} + break; + + case 531: +/* Line 1792 of yacc.c */ +#line 2868 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_reinterpret_cast)); +} + break; + + case 532: +/* Line 1792 of yacc.c */ +#line 2872 "dtool/src/cppparser/cppBison.yxx" { // A constructor call. CPPType *type = (yyvsp[(1) - (4)].u.identifier)->find_type(current_scope, global_scope, false, current_lexer); @@ -6890,9 +7499,9 @@ yyreduce: } break; - case 483: + case 533: /* Line 1792 of yacc.c */ -#line 2626 "dtool/src/cppparser/cppBison.yxx" +#line 2882 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int)); @@ -6900,9 +7509,9 @@ yyreduce: } break; - case 484: + case 534: /* Line 1792 of yacc.c */ -#line 2632 "dtool/src/cppparser/cppBison.yxx" +#line 2888 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char)); @@ -6910,9 +7519,9 @@ yyreduce: } break; - case 485: + case 535: /* Line 1792 of yacc.c */ -#line 2638 "dtool/src/cppparser/cppBison.yxx" +#line 2894 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t)); @@ -6920,9 +7529,9 @@ yyreduce: } break; - case 486: + case 536: /* Line 1792 of yacc.c */ -#line 2644 "dtool/src/cppparser/cppBison.yxx" +#line 2900 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char16_t)); @@ -6930,9 +7539,9 @@ yyreduce: } break; - case 487: + case 537: /* Line 1792 of yacc.c */ -#line 2650 "dtool/src/cppparser/cppBison.yxx" +#line 2906 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char32_t)); @@ -6940,9 +7549,9 @@ yyreduce: } break; - case 488: + case 538: /* Line 1792 of yacc.c */ -#line 2656 "dtool/src/cppparser/cppBison.yxx" +#line 2912 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_bool)); @@ -6950,9 +7559,9 @@ yyreduce: } break; - case 489: + case 539: /* Line 1792 of yacc.c */ -#line 2662 "dtool/src/cppparser/cppBison.yxx" +#line 2918 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6961,9 +7570,9 @@ yyreduce: } break; - case 490: + case 540: /* Line 1792 of yacc.c */ -#line 2669 "dtool/src/cppparser/cppBison.yxx" +#line 2925 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6972,9 +7581,9 @@ yyreduce: } break; - case 491: + case 541: /* Line 1792 of yacc.c */ -#line 2676 "dtool/src/cppparser/cppBison.yxx" +#line 2932 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6983,9 +7592,9 @@ yyreduce: } break; - case 492: + case 542: /* Line 1792 of yacc.c */ -#line 2683 "dtool/src/cppparser/cppBison.yxx" +#line 2939 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_int, @@ -6994,9 +7603,9 @@ yyreduce: } break; - case 493: + case 543: /* Line 1792 of yacc.c */ -#line 2690 "dtool/src/cppparser/cppBison.yxx" +#line 2946 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_float)); @@ -7004,9 +7613,9 @@ yyreduce: } break; - case 494: + case 544: /* Line 1792 of yacc.c */ -#line 2696 "dtool/src/cppparser/cppBison.yxx" +#line 2952 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_double)); @@ -7014,721 +7623,869 @@ yyreduce: } break; - case 495: -/* Line 1792 of yacc.c */ -#line 2702 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 496: -/* Line 1792 of yacc.c */ -#line 2706 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 497: -/* Line 1792 of yacc.c */ -#line 2710 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); -} - break; - - case 498: -/* Line 1792 of yacc.c */ -#line 2714 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); -} - break; - - case 499: -/* Line 1792 of yacc.c */ -#line 2718 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 500: -/* Line 1792 of yacc.c */ -#line 2722 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 501: -/* Line 1792 of yacc.c */ -#line 2726 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 502: -/* Line 1792 of yacc.c */ -#line 2730 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 503: -/* Line 1792 of yacc.c */ -#line 2734 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); -} - break; - - case 504: -/* Line 1792 of yacc.c */ -#line 2738 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 505: -/* Line 1792 of yacc.c */ -#line 2742 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 506: -/* Line 1792 of yacc.c */ -#line 2746 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 507: -/* Line 1792 of yacc.c */ -#line 2750 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 508: -/* Line 1792 of yacc.c */ -#line 2754 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 509: -/* Line 1792 of yacc.c */ -#line 2758 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 510: -/* Line 1792 of yacc.c */ -#line 2762 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 511: -/* Line 1792 of yacc.c */ -#line 2766 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 512: -/* Line 1792 of yacc.c */ -#line 2770 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 513: -/* Line 1792 of yacc.c */ -#line 2774 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 514: -/* Line 1792 of yacc.c */ -#line 2778 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 515: -/* Line 1792 of yacc.c */ -#line 2782 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 516: -/* Line 1792 of yacc.c */ -#line 2786 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 517: -/* Line 1792 of yacc.c */ -#line 2790 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 518: -/* Line 1792 of yacc.c */ -#line 2794 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 519: -/* Line 1792 of yacc.c */ -#line 2798 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 520: -/* Line 1792 of yacc.c */ -#line 2802 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 521: -/* Line 1792 of yacc.c */ -#line 2806 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 522: -/* Line 1792 of yacc.c */ -#line 2810 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); -} - break; - - case 523: -/* Line 1792 of yacc.c */ -#line 2814 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); -} - break; - - case 524: -/* Line 1792 of yacc.c */ -#line 2818 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); -} - break; - - case 525: -/* Line 1792 of yacc.c */ -#line 2822 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); -} - break; - - case 526: -/* Line 1792 of yacc.c */ -#line 2826 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 527: -/* Line 1792 of yacc.c */ -#line 2830 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); -} - break; - - case 528: -/* Line 1792 of yacc.c */ -#line 2834 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); -} - break; - - case 529: -/* Line 1792 of yacc.c */ -#line 2841 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); -} - break; - - case 530: -/* Line 1792 of yacc.c */ -#line 2845 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(true); -} - break; - - case 531: -/* Line 1792 of yacc.c */ -#line 2849 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(false); -} - break; - - case 532: -/* Line 1792 of yacc.c */ -#line 2853 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); -} - break; - - case 533: -/* Line 1792 of yacc.c */ -#line 2857 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); -} - break; - - case 534: -/* Line 1792 of yacc.c */ -#line 2861 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 535: -/* Line 1792 of yacc.c */ -#line 2865 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 536: -/* Line 1792 of yacc.c */ -#line 2869 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); -} - break; - - case 537: -/* Line 1792 of yacc.c */ -#line 2873 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); -} - break; - - case 538: -/* Line 1792 of yacc.c */ -#line 2887 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); -} - break; - - case 539: -/* Line 1792 of yacc.c */ -#line 2891 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); -} - break; - - case 540: -/* Line 1792 of yacc.c */ -#line 2895 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); -} - break; - - case 541: -/* Line 1792 of yacc.c */ -#line 2899 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr))); -} - break; - - case 542: -/* Line 1792 of yacc.c */ -#line 2903 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 543: -/* Line 1792 of yacc.c */ -#line 2907 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[(3) - (4)].u.type))); -} - break; - - case 544: -/* Line 1792 of yacc.c */ -#line 2911 "dtool/src/cppparser/cppBison.yxx" - { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); -} - break; - case 545: /* Line 1792 of yacc.c */ -#line 2915 "dtool/src/cppparser/cppBison.yxx" +#line 2958 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); + (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); } break; case 546: /* Line 1792 of yacc.c */ -#line 2919 "dtool/src/cppparser/cppBison.yxx" +#line 2962 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); + (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[(3) - (4)].u.type))); } break; case 547: /* Line 1792 of yacc.c */ -#line 2923 "dtool/src/cppparser/cppBison.yxx" +#line 2966 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); } break; case 548: /* Line 1792 of yacc.c */ -#line 2927 "dtool/src/cppparser/cppBison.yxx" +#line 2970 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); } break; case 549: /* Line 1792 of yacc.c */ -#line 2931 "dtool/src/cppparser/cppBison.yxx" +#line 2974 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", (yylsp[(1) - (4)])); + } + (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[(3) - (4)].u.type), std_type_info)); } break; case 550: /* Line 1792 of yacc.c */ -#line 2935 "dtool/src/cppparser/cppBison.yxx" +#line 2985 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", (yylsp[(1) - (4)])); + } + (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[(3) - (4)].u.expr), std_type_info)); } break; case 551: /* Line 1792 of yacc.c */ -#line 2939 "dtool/src/cppparser/cppBison.yxx" +#line 2996 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); } break; case 552: /* Line 1792 of yacc.c */ -#line 2943 "dtool/src/cppparser/cppBison.yxx" +#line 3000 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); } break; case 553: /* Line 1792 of yacc.c */ -#line 2947 "dtool/src/cppparser/cppBison.yxx" +#line 3004 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); } break; case 554: /* Line 1792 of yacc.c */ -#line 2951 "dtool/src/cppparser/cppBison.yxx" +#line 3008 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[(2) - (2)].u.expr)); } break; case 555: /* Line 1792 of yacc.c */ -#line 2955 "dtool/src/cppparser/cppBison.yxx" +#line 3012 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_STAR, (yyvsp[(2) - (2)].u.expr)); } break; case 556: /* Line 1792 of yacc.c */ -#line 2959 "dtool/src/cppparser/cppBison.yxx" +#line 3016 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); } break; case 557: /* Line 1792 of yacc.c */ -#line 2963 "dtool/src/cppparser/cppBison.yxx" +#line 3020 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 558: /* Line 1792 of yacc.c */ -#line 2967 "dtool/src/cppparser/cppBison.yxx" +#line 3024 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 559: /* Line 1792 of yacc.c */ -#line 2971 "dtool/src/cppparser/cppBison.yxx" +#line 3028 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 560: /* Line 1792 of yacc.c */ -#line 2975 "dtool/src/cppparser/cppBison.yxx" +#line 3032 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 561: /* Line 1792 of yacc.c */ -#line 2979 "dtool/src/cppparser/cppBison.yxx" +#line 3036 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 562: /* Line 1792 of yacc.c */ -#line 2983 "dtool/src/cppparser/cppBison.yxx" +#line 3040 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 563: /* Line 1792 of yacc.c */ -#line 2987 "dtool/src/cppparser/cppBison.yxx" +#line 3044 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 564: /* Line 1792 of yacc.c */ -#line 2991 "dtool/src/cppparser/cppBison.yxx" +#line 3048 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 565: /* Line 1792 of yacc.c */ -#line 2995 "dtool/src/cppparser/cppBison.yxx" +#line 3052 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 566: /* Line 1792 of yacc.c */ -#line 2999 "dtool/src/cppparser/cppBison.yxx" +#line 3056 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 567: /* Line 1792 of yacc.c */ -#line 3003 "dtool/src/cppparser/cppBison.yxx" +#line 3060 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 568: /* Line 1792 of yacc.c */ -#line 3007 "dtool/src/cppparser/cppBison.yxx" +#line 3064 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); + (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 569: /* Line 1792 of yacc.c */ -#line 3011 "dtool/src/cppparser/cppBison.yxx" +#line 3068 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); + (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 570: /* Line 1792 of yacc.c */ -#line 3015 "dtool/src/cppparser/cppBison.yxx" +#line 3072 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); + (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 571: /* Line 1792 of yacc.c */ -#line 3019 "dtool/src/cppparser/cppBison.yxx" +#line 3076 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 572: /* Line 1792 of yacc.c */ -#line 3023 "dtool/src/cppparser/cppBison.yxx" +#line 3080 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 573: /* Line 1792 of yacc.c */ -#line 3027 "dtool/src/cppparser/cppBison.yxx" +#line 3084 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); + (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 574: /* Line 1792 of yacc.c */ -#line 3031 "dtool/src/cppparser/cppBison.yxx" +#line 3088 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); + (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 575: /* Line 1792 of yacc.c */ -#line 3038 "dtool/src/cppparser/cppBison.yxx" +#line 3092 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); + (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); } break; case 576: /* Line 1792 of yacc.c */ -#line 3042 "dtool/src/cppparser/cppBison.yxx" +#line 3096 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(true); + (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; case 577: /* Line 1792 of yacc.c */ -#line 3046 "dtool/src/cppparser/cppBison.yxx" +#line 3100 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(false); + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); } break; case 578: /* Line 1792 of yacc.c */ -#line 3050 "dtool/src/cppparser/cppBison.yxx" +#line 3104 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); } break; case 579: /* Line 1792 of yacc.c */ -#line 3054 "dtool/src/cppparser/cppBison.yxx" +#line 3108 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); + (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 580: /* Line 1792 of yacc.c */ -#line 3058 "dtool/src/cppparser/cppBison.yxx" +#line 3112 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); + (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); } break; case 581: /* Line 1792 of yacc.c */ -#line 3062 "dtool/src/cppparser/cppBison.yxx" +#line 3116 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); + (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); } break; case 582: /* Line 1792 of yacc.c */ -#line 3066 "dtool/src/cppparser/cppBison.yxx" +#line 3123 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); } break; case 583: /* Line 1792 of yacc.c */ -#line 3070 "dtool/src/cppparser/cppBison.yxx" +#line 3127 "dtool/src/cppparser/cppBison.yxx" { - (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); + (yyval.u.expr) = new CPPExpression(true); } break; case 584: /* Line 1792 of yacc.c */ -#line 3077 "dtool/src/cppparser/cppBison.yxx" +#line 3131 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(false); +} + break; + + case 585: +/* Line 1792 of yacc.c */ +#line 3135 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); +} + break; + + case 586: +/* Line 1792 of yacc.c */ +#line 3139 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); +} + break; + + case 587: +/* Line 1792 of yacc.c */ +#line 3143 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 588: +/* Line 1792 of yacc.c */ +#line 3147 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 589: +/* Line 1792 of yacc.c */ +#line 3151 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); +} + break; + + case 590: +/* Line 1792 of yacc.c */ +#line 3155 "dtool/src/cppparser/cppBison.yxx" + { + // A variable named "final". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[(1) - (1)])); + (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + break; + + case 591: +/* Line 1792 of yacc.c */ +#line 3161 "dtool/src/cppparser/cppBison.yxx" + { + // A variable named "override". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[(1) - (1)])); + (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + break; + + case 592: +/* Line 1792 of yacc.c */ +#line 3167 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); +} + break; + + case 593: +/* Line 1792 of yacc.c */ +#line 3171 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = NULL; +} + break; + + case 594: +/* Line 1792 of yacc.c */ +#line 3175 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = NULL; +} + break; + + case 595: +/* Line 1792 of yacc.c */ +#line 3189 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 596: +/* Line 1792 of yacc.c */ +#line 3193 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(2) - (4)].u.type), (yyvsp[(4) - (4)].u.expr))); +} + break; + + case 597: +/* Line 1792 of yacc.c */ +#line 3197 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_static_cast)); +} + break; + + case 598: +/* Line 1792 of yacc.c */ +#line 3201 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_dynamic_cast)); +} + break; + + case 599: +/* Line 1792 of yacc.c */ +#line 3205 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_const_cast)); +} + break; + + case 600: +/* Line 1792 of yacc.c */ +#line 3209 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::typecast_op((yyvsp[(3) - (7)].u.type), (yyvsp[(6) - (7)].u.expr), CPPExpression::T_reinterpret_cast)); +} + break; + + case 601: +/* Line 1792 of yacc.c */ +#line 3213 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::sizeof_func((yyvsp[(3) - (4)].u.type))); +} + break; + + case 602: +/* Line 1792 of yacc.c */ +#line 3217 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::alignof_func((yyvsp[(3) - (4)].u.type))); +} + break; + + case 603: +/* Line 1792 of yacc.c */ +#line 3221 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (2)].u.type))); +} + break; + + case 604: +/* Line 1792 of yacc.c */ +#line 3225 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::new_op((yyvsp[(2) - (5)].u.type), (yyvsp[(4) - (5)].u.expr))); +} + break; + + case 605: +/* Line 1792 of yacc.c */ +#line 3229 "dtool/src/cppparser/cppBison.yxx" + { + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", (yylsp[(1) - (4)])); + } + (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[(3) - (4)].u.type), std_type_info)); +} + break; + + case 606: +/* Line 1792 of yacc.c */ +#line 3240 "dtool/src/cppparser/cppBison.yxx" + { + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", (yylsp[(1) - (4)])); + } + (yyval.u.expr) = new CPPExpression(CPPExpression::typeid_op((yyvsp[(3) - (4)].u.expr), std_type_info)); +} + break; + + case 607: +/* Line 1792 of yacc.c */ +#line 3251 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NOT, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 608: +/* Line 1792 of yacc.c */ +#line 3255 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_NEGATE, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 609: +/* Line 1792 of yacc.c */ +#line 3259 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_MINUS, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 610: +/* Line 1792 of yacc.c */ +#line 3263 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_PLUS, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 611: +/* Line 1792 of yacc.c */ +#line 3267 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(UNARY_REF, (yyvsp[(2) - (2)].u.expr)); +} + break; + + case 612: +/* Line 1792 of yacc.c */ +#line 3271 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('*', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 613: +/* Line 1792 of yacc.c */ +#line 3275 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('/', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 614: +/* Line 1792 of yacc.c */ +#line 3279 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('%', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 615: +/* Line 1792 of yacc.c */ +#line 3283 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('+', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 616: +/* Line 1792 of yacc.c */ +#line 3287 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('-', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 617: +/* Line 1792 of yacc.c */ +#line 3291 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('|', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 618: +/* Line 1792 of yacc.c */ +#line 3295 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('^', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 619: +/* Line 1792 of yacc.c */ +#line 3299 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('&', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 620: +/* Line 1792 of yacc.c */ +#line 3303 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(OROR, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 621: +/* Line 1792 of yacc.c */ +#line 3307 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(ANDAND, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 622: +/* Line 1792 of yacc.c */ +#line 3311 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(EQCOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 623: +/* Line 1792 of yacc.c */ +#line 3315 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(NECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 624: +/* Line 1792 of yacc.c */ +#line 3319 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(LECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 625: +/* Line 1792 of yacc.c */ +#line 3323 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(GECOMPARE, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 626: +/* Line 1792 of yacc.c */ +#line 3327 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('<', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 627: +/* Line 1792 of yacc.c */ +#line 3331 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('>', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 628: +/* Line 1792 of yacc.c */ +#line 3335 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(LSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 629: +/* Line 1792 of yacc.c */ +#line 3339 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(RSHIFT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 630: +/* Line 1792 of yacc.c */ +#line 3343 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('?', (yyvsp[(1) - (5)].u.expr), (yyvsp[(3) - (5)].u.expr), (yyvsp[(5) - (5)].u.expr)); +} + break; + + case 631: +/* Line 1792 of yacc.c */ +#line 3347 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('[', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); +} + break; + + case 632: +/* Line 1792 of yacc.c */ +#line 3351 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (4)].u.expr), (yyvsp[(3) - (4)].u.expr)); +} + break; + + case 633: +/* Line 1792 of yacc.c */ +#line 3355 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('f', (yyvsp[(1) - (3)].u.expr)); +} + break; + + case 634: +/* Line 1792 of yacc.c */ +#line 3359 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression('.', (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 635: +/* Line 1792 of yacc.c */ +#line 3363 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(POINTSAT, (yyvsp[(1) - (3)].u.expr), (yyvsp[(3) - (3)].u.expr)); +} + break; + + case 636: +/* Line 1792 of yacc.c */ +#line 3367 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(2) - (3)].u.expr); +} + break; + + case 637: +/* Line 1792 of yacc.c */ +#line 3374 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); +} + break; + + case 638: +/* Line 1792 of yacc.c */ +#line 3378 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(true); +} + break; + + case 639: +/* Line 1792 of yacc.c */ +#line 3382 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(false); +} + break; + + case 640: +/* Line 1792 of yacc.c */ +#line 3386 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.integer)); +} + break; + + case 641: +/* Line 1792 of yacc.c */ +#line 3390 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.real)); +} + break; + + case 642: +/* Line 1792 of yacc.c */ +#line 3394 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 643: +/* Line 1792 of yacc.c */ +#line 3398 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); +} + break; + + case 644: +/* Line 1792 of yacc.c */ +#line 3402 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].u.identifier), current_scope, global_scope, current_lexer); +} + break; + + case 645: +/* Line 1792 of yacc.c */ +#line 3406 "dtool/src/cppparser/cppBison.yxx" + { + // A variable named "final". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("final", (yylsp[(1) - (1)])); + (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + break; + + case 646: +/* Line 1792 of yacc.c */ +#line 3412 "dtool/src/cppparser/cppBison.yxx" + { + // A variable named "override". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("override", (yylsp[(1) - (1)])); + (yyval.u.expr) = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + break; + + case 647: +/* Line 1792 of yacc.c */ +#line 3418 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.expr) = new CPPExpression(CPPExpression::get_nullptr()); +} + break; + + case 655: +/* Line 1792 of yacc.c */ +#line 3439 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(1) - (1)].u.identifier)->find_type(current_scope, global_scope, true); if (type == NULL) { @@ -7738,9 +8495,9 @@ yyreduce: } break; - case 585: + case 656: /* Line 1792 of yacc.c */ -#line 3085 "dtool/src/cppparser/cppBison.yxx" +#line 3447 "dtool/src/cppparser/cppBison.yxx" { CPPType *type = (yyvsp[(2) - (2)].u.identifier)->find_type(current_scope, global_scope, true, current_lexer); if (type == NULL) { @@ -7750,49 +8507,89 @@ yyreduce: } break; - case 586: + case 657: /* Line 1792 of yacc.c */ -#line 3093 "dtool/src/cppparser/cppBison.yxx" +#line 3455 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.type) = CPPType::new_type(new CPPTBDType((yyvsp[(2) - (2)].u.identifier))); } break; - case 587: + case 658: /* Line 1792 of yacc.c */ -#line 3119 "dtool/src/cppparser/cppBison.yxx" +#line 3483 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); } break; - case 588: + case 659: /* Line 1792 of yacc.c */ -#line 3123 "dtool/src/cppparser/cppBison.yxx" +#line 3487 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); } break; - case 589: + case 660: /* Line 1792 of yacc.c */ -#line 3130 "dtool/src/cppparser/cppBison.yxx" +#line 3491 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.identifier) = new CPPIdentifier("final", (yylsp[(1) - (1)])); +} + break; + + case 661: +/* Line 1792 of yacc.c */ +#line 3495 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[(1) - (1)])); +} + break; + + case 662: +/* Line 1792 of yacc.c */ +#line 3506 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); +} + break; + + case 663: +/* Line 1792 of yacc.c */ +#line 3510 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.identifier) = (yyvsp[(1) - (1)].u.identifier); +} + break; + + case 664: +/* Line 1792 of yacc.c */ +#line 3514 "dtool/src/cppparser/cppBison.yxx" + { + (yyval.u.identifier) = new CPPIdentifier("override", (yylsp[(1) - (1)])); +} + break; + + case 665: +/* Line 1792 of yacc.c */ +#line 3522 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = new CPPExpression((yyvsp[(1) - (1)].str)); } break; - case 590: + case 666: /* Line 1792 of yacc.c */ -#line 3134 "dtool/src/cppparser/cppBison.yxx" +#line 3526 "dtool/src/cppparser/cppBison.yxx" { (yyval.u.expr) = (yyvsp[(1) - (1)].u.expr); } break; - case 591: + case 667: /* Line 1792 of yacc.c */ -#line 3138 "dtool/src/cppparser/cppBison.yxx" +#line 3530 "dtool/src/cppparser/cppBison.yxx" { // The right string takes on the literal type of the left. (yyval.u.expr) = (yyvsp[(1) - (2)].u.expr); @@ -7800,9 +8597,9 @@ yyreduce: } break; - case 592: + case 668: /* Line 1792 of yacc.c */ -#line 3144 "dtool/src/cppparser/cppBison.yxx" +#line 3536 "dtool/src/cppparser/cppBison.yxx" { // We have to check that the two literal types match up. (yyval.u.expr) = (yyvsp[(1) - (2)].u.expr); @@ -7815,7 +8612,7 @@ yyreduce: /* Line 1792 of yacc.c */ -#line 7819 "built/tmp/cppBison.yxx.c" +#line 8616 "built/tmp/cppBison.yxx.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/dtool/src/cppparser/cppBison.h.prebuilt b/dtool/src/cppparser/cppBison.h.prebuilt index efb95b06a1..c7784f5edf 100644 --- a/dtool/src/cppparser/cppBison.h.prebuilt +++ b/dtool/src/cppparser/cppBison.h.prebuilt @@ -72,95 +72,101 @@ extern int cppyydebug; UNARY_NOT = 281, UNARY_NEGATE = 282, UNARY_MINUS = 283, - UNARY_STAR = 284, - UNARY_REF = 285, - POINTSAT = 286, - SCOPE = 287, - PLUSPLUS = 288, - MINUSMINUS = 289, - TIMESEQUAL = 290, - DIVIDEEQUAL = 291, - MODEQUAL = 292, - PLUSEQUAL = 293, - MINUSEQUAL = 294, - OREQUAL = 295, - ANDEQUAL = 296, - XOREQUAL = 297, - LSHIFTEQUAL = 298, - RSHIFTEQUAL = 299, - KW_ALIGNAS = 300, - KW_ALIGNOF = 301, - KW_AUTO = 302, - KW_BEGIN_PUBLISH = 303, - KW_BLOCKING = 304, - KW_BOOL = 305, - KW_CATCH = 306, - KW_CHAR = 307, - KW_CHAR16_T = 308, - KW_CHAR32_T = 309, - KW_CLASS = 310, - KW_CONST = 311, - KW_CONSTEXPR = 312, - KW_DECLTYPE = 313, - KW_DEFAULT = 314, - KW_DELETE = 315, - KW_DOUBLE = 316, - KW_DYNAMIC_CAST = 317, - KW_ELSE = 318, - KW_END_PUBLISH = 319, - KW_ENUM = 320, - KW_EXTENSION = 321, - KW_EXTERN = 322, - KW_EXPLICIT = 323, - KW_PUBLISHED = 324, - KW_FALSE = 325, - KW_FLOAT = 326, - KW_FRIEND = 327, - KW_FOR = 328, - KW_GOTO = 329, - KW_IF = 330, - KW_INLINE = 331, - KW_INT = 332, - KW_LONG = 333, - KW_LONGLONG = 334, - KW_MAKE_PROPERTY = 335, - KW_MAKE_PROPERTY2 = 336, - KW_MAKE_SEQ = 337, - KW_MUTABLE = 338, - KW_NAMESPACE = 339, - KW_NEW = 340, - KW_NOEXCEPT = 341, - KW_NULLPTR = 342, - KW_OPERATOR = 343, - KW_PRIVATE = 344, - KW_PROTECTED = 345, - KW_PUBLIC = 346, - KW_REGISTER = 347, - KW_RETURN = 348, - KW_SHORT = 349, - KW_SIGNED = 350, - KW_SIZEOF = 351, - KW_STATIC = 352, - KW_STATIC_ASSERT = 353, - KW_STATIC_CAST = 354, - KW_STRUCT = 355, - KW_TEMPLATE = 356, - KW_THROW = 357, - KW_TRUE = 358, - KW_TRY = 359, - KW_TYPEDEF = 360, - KW_TYPENAME = 361, - KW_UNION = 362, - KW_UNSIGNED = 363, - KW_USING = 364, - KW_VIRTUAL = 365, - KW_VOID = 366, - KW_VOLATILE = 367, - KW_WCHAR_T = 368, - KW_WHILE = 369, - START_CPP = 370, - START_CONST_EXPR = 371, - START_TYPE = 372 + UNARY_PLUS = 284, + UNARY_STAR = 285, + UNARY_REF = 286, + POINTSAT = 287, + SCOPE = 288, + PLUSPLUS = 289, + MINUSMINUS = 290, + TIMESEQUAL = 291, + DIVIDEEQUAL = 292, + MODEQUAL = 293, + PLUSEQUAL = 294, + MINUSEQUAL = 295, + OREQUAL = 296, + ANDEQUAL = 297, + XOREQUAL = 298, + LSHIFTEQUAL = 299, + RSHIFTEQUAL = 300, + KW_ALIGNAS = 301, + KW_ALIGNOF = 302, + KW_AUTO = 303, + KW_BEGIN_PUBLISH = 304, + KW_BLOCKING = 305, + KW_BOOL = 306, + KW_CATCH = 307, + KW_CHAR = 308, + KW_CHAR16_T = 309, + KW_CHAR32_T = 310, + KW_CLASS = 311, + KW_CONST = 312, + KW_CONSTEXPR = 313, + KW_CONST_CAST = 314, + KW_DECLTYPE = 315, + KW_DEFAULT = 316, + KW_DELETE = 317, + KW_DOUBLE = 318, + KW_DYNAMIC_CAST = 319, + KW_ELSE = 320, + KW_END_PUBLISH = 321, + KW_ENUM = 322, + KW_EXTENSION = 323, + KW_EXTERN = 324, + KW_EXPLICIT = 325, + KW_PUBLISHED = 326, + KW_FALSE = 327, + KW_FINAL = 328, + KW_FLOAT = 329, + KW_FRIEND = 330, + KW_FOR = 331, + KW_GOTO = 332, + KW_IF = 333, + KW_INLINE = 334, + KW_INT = 335, + KW_LONG = 336, + KW_MAKE_PROPERTY = 337, + KW_MAKE_PROPERTY2 = 338, + KW_MAKE_SEQ = 339, + KW_MUTABLE = 340, + KW_NAMESPACE = 341, + KW_NEW = 342, + KW_NOEXCEPT = 343, + KW_NULLPTR = 344, + KW_OPERATOR = 345, + KW_OVERRIDE = 346, + KW_PRIVATE = 347, + KW_PROTECTED = 348, + KW_PUBLIC = 349, + KW_REGISTER = 350, + KW_REINTERPRET_CAST = 351, + KW_RETURN = 352, + KW_SHORT = 353, + KW_SIGNED = 354, + KW_SIZEOF = 355, + KW_STATIC = 356, + KW_STATIC_ASSERT = 357, + KW_STATIC_CAST = 358, + KW_STRUCT = 359, + KW_TEMPLATE = 360, + KW_THREAD_LOCAL = 361, + KW_THROW = 362, + KW_TRUE = 363, + KW_TRY = 364, + KW_TYPEDEF = 365, + KW_TYPEID = 366, + KW_TYPENAME = 367, + KW_UNION = 368, + KW_UNSIGNED = 369, + KW_USING = 370, + KW_VIRTUAL = 371, + KW_VOID = 372, + KW_VOLATILE = 373, + KW_WCHAR_T = 374, + KW_WHILE = 375, + START_CPP = 376, + START_CONST_EXPR = 377, + START_TYPE = 378 }; #endif /* Tokens. */ @@ -190,95 +196,101 @@ extern int cppyydebug; #define UNARY_NOT 281 #define UNARY_NEGATE 282 #define UNARY_MINUS 283 -#define UNARY_STAR 284 -#define UNARY_REF 285 -#define POINTSAT 286 -#define SCOPE 287 -#define PLUSPLUS 288 -#define MINUSMINUS 289 -#define TIMESEQUAL 290 -#define DIVIDEEQUAL 291 -#define MODEQUAL 292 -#define PLUSEQUAL 293 -#define MINUSEQUAL 294 -#define OREQUAL 295 -#define ANDEQUAL 296 -#define XOREQUAL 297 -#define LSHIFTEQUAL 298 -#define RSHIFTEQUAL 299 -#define KW_ALIGNAS 300 -#define KW_ALIGNOF 301 -#define KW_AUTO 302 -#define KW_BEGIN_PUBLISH 303 -#define KW_BLOCKING 304 -#define KW_BOOL 305 -#define KW_CATCH 306 -#define KW_CHAR 307 -#define KW_CHAR16_T 308 -#define KW_CHAR32_T 309 -#define KW_CLASS 310 -#define KW_CONST 311 -#define KW_CONSTEXPR 312 -#define KW_DECLTYPE 313 -#define KW_DEFAULT 314 -#define KW_DELETE 315 -#define KW_DOUBLE 316 -#define KW_DYNAMIC_CAST 317 -#define KW_ELSE 318 -#define KW_END_PUBLISH 319 -#define KW_ENUM 320 -#define KW_EXTENSION 321 -#define KW_EXTERN 322 -#define KW_EXPLICIT 323 -#define KW_PUBLISHED 324 -#define KW_FALSE 325 -#define KW_FLOAT 326 -#define KW_FRIEND 327 -#define KW_FOR 328 -#define KW_GOTO 329 -#define KW_IF 330 -#define KW_INLINE 331 -#define KW_INT 332 -#define KW_LONG 333 -#define KW_LONGLONG 334 -#define KW_MAKE_PROPERTY 335 -#define KW_MAKE_PROPERTY2 336 -#define KW_MAKE_SEQ 337 -#define KW_MUTABLE 338 -#define KW_NAMESPACE 339 -#define KW_NEW 340 -#define KW_NOEXCEPT 341 -#define KW_NULLPTR 342 -#define KW_OPERATOR 343 -#define KW_PRIVATE 344 -#define KW_PROTECTED 345 -#define KW_PUBLIC 346 -#define KW_REGISTER 347 -#define KW_RETURN 348 -#define KW_SHORT 349 -#define KW_SIGNED 350 -#define KW_SIZEOF 351 -#define KW_STATIC 352 -#define KW_STATIC_ASSERT 353 -#define KW_STATIC_CAST 354 -#define KW_STRUCT 355 -#define KW_TEMPLATE 356 -#define KW_THROW 357 -#define KW_TRUE 358 -#define KW_TRY 359 -#define KW_TYPEDEF 360 -#define KW_TYPENAME 361 -#define KW_UNION 362 -#define KW_UNSIGNED 363 -#define KW_USING 364 -#define KW_VIRTUAL 365 -#define KW_VOID 366 -#define KW_VOLATILE 367 -#define KW_WCHAR_T 368 -#define KW_WHILE 369 -#define START_CPP 370 -#define START_CONST_EXPR 371 -#define START_TYPE 372 +#define UNARY_PLUS 284 +#define UNARY_STAR 285 +#define UNARY_REF 286 +#define POINTSAT 287 +#define SCOPE 288 +#define PLUSPLUS 289 +#define MINUSMINUS 290 +#define TIMESEQUAL 291 +#define DIVIDEEQUAL 292 +#define MODEQUAL 293 +#define PLUSEQUAL 294 +#define MINUSEQUAL 295 +#define OREQUAL 296 +#define ANDEQUAL 297 +#define XOREQUAL 298 +#define LSHIFTEQUAL 299 +#define RSHIFTEQUAL 300 +#define KW_ALIGNAS 301 +#define KW_ALIGNOF 302 +#define KW_AUTO 303 +#define KW_BEGIN_PUBLISH 304 +#define KW_BLOCKING 305 +#define KW_BOOL 306 +#define KW_CATCH 307 +#define KW_CHAR 308 +#define KW_CHAR16_T 309 +#define KW_CHAR32_T 310 +#define KW_CLASS 311 +#define KW_CONST 312 +#define KW_CONSTEXPR 313 +#define KW_CONST_CAST 314 +#define KW_DECLTYPE 315 +#define KW_DEFAULT 316 +#define KW_DELETE 317 +#define KW_DOUBLE 318 +#define KW_DYNAMIC_CAST 319 +#define KW_ELSE 320 +#define KW_END_PUBLISH 321 +#define KW_ENUM 322 +#define KW_EXTENSION 323 +#define KW_EXTERN 324 +#define KW_EXPLICIT 325 +#define KW_PUBLISHED 326 +#define KW_FALSE 327 +#define KW_FINAL 328 +#define KW_FLOAT 329 +#define KW_FRIEND 330 +#define KW_FOR 331 +#define KW_GOTO 332 +#define KW_IF 333 +#define KW_INLINE 334 +#define KW_INT 335 +#define KW_LONG 336 +#define KW_MAKE_PROPERTY 337 +#define KW_MAKE_PROPERTY2 338 +#define KW_MAKE_SEQ 339 +#define KW_MUTABLE 340 +#define KW_NAMESPACE 341 +#define KW_NEW 342 +#define KW_NOEXCEPT 343 +#define KW_NULLPTR 344 +#define KW_OPERATOR 345 +#define KW_OVERRIDE 346 +#define KW_PRIVATE 347 +#define KW_PROTECTED 348 +#define KW_PUBLIC 349 +#define KW_REGISTER 350 +#define KW_REINTERPRET_CAST 351 +#define KW_RETURN 352 +#define KW_SHORT 353 +#define KW_SIGNED 354 +#define KW_SIZEOF 355 +#define KW_STATIC 356 +#define KW_STATIC_ASSERT 357 +#define KW_STATIC_CAST 358 +#define KW_STRUCT 359 +#define KW_TEMPLATE 360 +#define KW_THREAD_LOCAL 361 +#define KW_THROW 362 +#define KW_TRUE 363 +#define KW_TRY 364 +#define KW_TYPEDEF 365 +#define KW_TYPEID 366 +#define KW_TYPENAME 367 +#define KW_UNION 368 +#define KW_UNSIGNED 369 +#define KW_USING 370 +#define KW_VIRTUAL 371 +#define KW_VOID 372 +#define KW_VOLATILE 373 +#define KW_WCHAR_T 374 +#define KW_WHILE 375 +#define START_CPP 376 +#define START_CONST_EXPR 377 +#define START_TYPE 378 diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index d66913450b..09991d8086 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -229,6 +229,7 @@ pop_struct() { %token UNARY_NOT %token UNARY_NEGATE %token UNARY_MINUS +%token UNARY_PLUS %token UNARY_STAR %token UNARY_REF %token POINTSAT @@ -259,6 +260,7 @@ pop_struct() { %token KW_CLASS %token KW_CONST %token KW_CONSTEXPR +%token KW_CONST_CAST %token KW_DECLTYPE %token KW_DEFAULT %token KW_DELETE @@ -272,6 +274,7 @@ pop_struct() { %token KW_EXPLICIT %token KW_PUBLISHED %token KW_FALSE +%token KW_FINAL %token KW_FLOAT %token KW_FRIEND %token KW_FOR @@ -280,7 +283,6 @@ pop_struct() { %token KW_INLINE %token KW_INT %token KW_LONG -%token KW_LONGLONG %token KW_MAKE_PROPERTY %token KW_MAKE_PROPERTY2 %token KW_MAKE_SEQ @@ -290,10 +292,12 @@ pop_struct() { %token KW_NOEXCEPT %token KW_NULLPTR %token KW_OPERATOR +%token KW_OVERRIDE %token KW_PRIVATE %token KW_PROTECTED %token KW_PUBLIC %token KW_REGISTER +%token KW_REINTERPRET_CAST %token KW_RETURN %token KW_SHORT %token KW_SIGNED @@ -303,10 +307,12 @@ pop_struct() { %token KW_STATIC_CAST %token KW_STRUCT %token KW_TEMPLATE +%token KW_THREAD_LOCAL %token KW_THROW %token KW_TRUE %token KW_TRY %token KW_TYPEDEF +%token KW_TYPEID %token KW_TYPENAME %token KW_UNION %token KW_UNSIGNED @@ -325,20 +331,27 @@ pop_struct() { %token START_TYPE %type storage_class +%type constructor_prototype %type function_prototype %type function_post %type function_operator %type template_formal_parameter %type template_formal_parameter_type %type instance_identifier +%type instance_identifier_and_maybe_trailing_return_type +%type function_parameter_list +%type function_parameters %type formal_parameter_list %type formal_parameters %type template_parameter_maybe_initialize %type maybe_initialize +%type maybe_initialize_or_constructor_body %type maybe_initialize_or_function_body +%type function_parameter %type formal_parameter %type not_paren_formal_parameter_identifier %type formal_parameter_identifier +%type not_paren_empty_instance_identifier %type empty_instance_identifier %type type %type type_decl @@ -356,8 +369,10 @@ pop_struct() { %type simple_void_type %type class_derivation_name %type enum_element_type +%type maybe_trailing_return_type /*%type typedefname*/ %type name +%type name_no_final %type string_literal /* We need to treat KW_OPERATOR as a scopable keyword. */ @@ -429,6 +444,10 @@ constructor_init: name '(' optional_const_expr_comma ')' { delete $3; +} + | name '{' optional_const_expr_comma '}' +{ + delete $3; } ; @@ -499,7 +518,7 @@ declaration: { current_scope->set_current_vis(V_private); } - | KW_MAKE_PROPERTY '(' IDENTIFIER ',' IDENTIFIER ')' ';' + | KW_MAKE_PROPERTY '(' name ',' IDENTIFIER ')' ';' { CPPDeclaration *getter = $5->find_symbol(current_scope, global_scope, current_lexer); @@ -510,7 +529,7 @@ declaration: CPPMakeProperty *make_property = new CPPMakeProperty($3, getter->as_function_group(), NULL, current_scope, @1.file); current_scope->add_declaration(make_property, global_scope, current_lexer, @1); } - | KW_MAKE_PROPERTY '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';' + | KW_MAKE_PROPERTY '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (getter == (CPPDeclaration *)NULL || getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -531,7 +550,7 @@ declaration: current_scope->add_declaration(make_property, global_scope, current_lexer, @1); } } - | KW_MAKE_PROPERTY2 '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';' + | KW_MAKE_PROPERTY2 '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *hasser = $5->find_symbol(current_scope, global_scope, current_lexer); if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) { @@ -553,7 +572,7 @@ declaration: current_scope->add_declaration(make_property, global_scope, current_lexer, @1); } } - | KW_MAKE_PROPERTY2 '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';' + | KW_MAKE_PROPERTY2 '(' name ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *hasser = $5->find_symbol(current_scope, global_scope, current_lexer); if (hasser == (CPPDeclaration *)NULL || hasser->get_subtype() != CPPDeclaration::ST_function_group) { @@ -586,7 +605,7 @@ declaration: current_scope->add_declaration(make_property, global_scope, current_lexer, @1); } } - | KW_MAKE_SEQ '(' IDENTIFIER ',' IDENTIFIER ',' IDENTIFIER ')' ';' + | KW_MAKE_SEQ '(' name ',' IDENTIFIER ',' IDENTIFIER ')' ';' { CPPDeclaration *length_getter = $5->find_symbol(current_scope, global_scope, current_lexer); if (length_getter == (CPPDeclaration *)NULL || length_getter->get_subtype() != CPPDeclaration::ST_function_group) { @@ -608,7 +627,7 @@ declaration: current_scope->add_declaration(make_seq, global_scope, current_lexer, @1); } } - | KW_STATIC_ASSERT '(' const_expr ',' string_literal ')' + | KW_STATIC_ASSERT '(' const_expr ',' string_literal ')' ';' { CPPExpression::Result result = $3->evaluate(); if (result._type == CPPExpression::RT_error) { @@ -619,7 +638,7 @@ declaration: yywarning("static_assert failed: " + str.str(), @3); } } - | KW_STATIC_ASSERT '(' const_expr ')' + | KW_STATIC_ASSERT '(' const_expr ')' ';' { // This alternative version of static_assert was introduced in C++17. CPPExpression::Result result = $3->evaluate(); @@ -706,6 +725,25 @@ storage_class: { $$ = $2 | (int)CPPInstance::SC_extension; } + | KW_THREAD_LOCAL storage_class +{ + $$ = $2 | (int)CPPInstance::SC_thread_local; +} + | '[' '[' attribute_specifiers ']' ']' storage_class +{ + // Ignore attribute specifiers for now. + $$ = $6; +} + ; + +attribute_specifiers: + attribute_specifier + | attribute_specifier ',' attribute_specifiers + ; + +attribute_specifier: + name + | name '(' formal_parameter_list ')' ; type_like_declaration: @@ -721,6 +759,14 @@ type_like_declaration: // parsing. current_scope->add_declaration($2, global_scope, current_lexer, @2); +} + | storage_class constructor_prototype maybe_initialize_or_constructor_body +{ + if ($2 != (CPPInstance *)NULL) { + $2->_storage_class |= (current_storage_class | $1); + current_scope->add_declaration($2, global_scope, current_lexer, @2); + $2->set_initializer($3); + } } | storage_class function_prototype maybe_initialize_or_function_body { @@ -770,7 +816,7 @@ multiple_var_declaration: ; multiple_instance_identifiers: - instance_identifier maybe_initialize_or_function_body + instance_identifier_and_maybe_trailing_return_type maybe_initialize_or_function_body { CPPInstance *inst = new CPPInstance(current_type, $1, current_storage_class, @@ -778,7 +824,7 @@ multiple_instance_identifiers: inst->set_initializer($2); current_scope->add_declaration(inst, global_scope, current_lexer, @1); } - | instance_identifier maybe_initialize ',' multiple_instance_identifiers + | instance_identifier_and_maybe_trailing_return_type maybe_initialize ',' multiple_instance_identifiers { CPPInstance *inst = new CPPInstance(current_type, $1, current_storage_class, @@ -789,7 +835,7 @@ multiple_instance_identifiers: ; multiple_const_instance_identifiers: - instance_identifier maybe_initialize_or_function_body + instance_identifier_and_maybe_trailing_return_type maybe_initialize_or_function_body { $1->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance(current_type, $1, @@ -798,7 +844,7 @@ multiple_const_instance_identifiers: inst->set_initializer($2); current_scope->add_declaration(inst, global_scope, current_lexer, @1); } - | instance_identifier maybe_initialize ',' multiple_const_instance_identifiers + | instance_identifier_and_maybe_trailing_return_type maybe_initialize ',' multiple_const_instance_identifiers { $1->add_modifier(IIT_const); CPPInstance *inst = new CPPInstance(current_type, $1, @@ -856,13 +902,13 @@ typedef_declaration: ; typedef_instance_identifiers: - instance_identifier maybe_initialize_or_function_body + instance_identifier_and_maybe_trailing_return_type maybe_initialize_or_function_body { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } - | instance_identifier maybe_initialize ',' typedef_instance_identifiers + | instance_identifier_and_maybe_trailing_return_type maybe_initialize ',' typedef_instance_identifiers { CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); @@ -871,14 +917,14 @@ typedef_instance_identifiers: ; typedef_const_instance_identifiers: - instance_identifier maybe_initialize_or_function_body + instance_identifier_and_maybe_trailing_return_type maybe_initialize_or_function_body { $1->add_modifier(IIT_const); CPPType *target_type = current_type; CPPTypedefType *typedef_type = new CPPTypedefType(target_type, $1, current_scope, @1.file); current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); } - | instance_identifier maybe_initialize ',' typedef_const_instance_identifiers + | instance_identifier_and_maybe_trailing_return_type maybe_initialize ',' typedef_const_instance_identifiers { $1->add_modifier(IIT_const); CPPType *target_type = current_type; @@ -887,14 +933,14 @@ typedef_const_instance_identifiers: } ; -function_prototype: +constructor_prototype: /* Functions with implicit return types, and constructors */ IDENTIFIER '(' { push_scope($1->get_scope(current_scope, global_scope)); } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post { CPPType *type; if ($1->get_simple_name() == current_scope->get_simple_name() || @@ -918,7 +964,7 @@ function_prototype: { push_scope($1->get_scope(current_scope, global_scope)); } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post { pop_scope(); CPPType *type; @@ -936,13 +982,16 @@ function_prototype: $$ = new CPPInstance(type, ii, 0, @1.file); } + ; + +function_prototype: /* Destructors */ - | '~' name '(' + '~' name '(' { push_scope($2->get_scope(current_scope, global_scope)); } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post { pop_scope(); if ($2->is_scoped()) { @@ -972,7 +1021,7 @@ function_prototype: { push_scope($4->get_scope(current_scope, global_scope)); } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post maybe_trailing_return_type { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); @@ -990,7 +1039,7 @@ function_prototype: { push_scope($5->get_scope(current_scope, global_scope)); } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post maybe_trailing_return_type { pop_scope(); CPPType *type = $1->find_type(current_scope, global_scope, false, current_lexer); @@ -1012,7 +1061,7 @@ function_prototype: push_scope($1->get_scope(current_scope, global_scope)); } } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post { if ($1 != NULL) { pop_scope(); @@ -1043,7 +1092,7 @@ function_prototype: push_scope($1->get_scope(current_scope, global_scope)); } } - formal_parameter_list ')' function_post + function_parameter_list ')' function_post { if ($1 != NULL) { pop_scope(); @@ -1087,6 +1136,19 @@ function_post: | function_post KW_NOEXCEPT { $$ = (int)CPPFunctionType::F_noexcept; +} + | function_post KW_FINAL +{ + $$ = (int)CPPFunctionType::F_final; +} + | function_post KW_OVERRIDE +{ + $$ = (int)CPPFunctionType::F_override; +} + | function_post KW_MUTABLE +{ + // Used for lambdas, currently ignored. + $$ = 0; } | function_post KW_THROW '(' ')' { @@ -1096,6 +1158,10 @@ function_post: { $$ = $1; } +/* | function_post '[' '[' attribute_specifiers ']' ']' +{ + $$ = $1; +}*/ ; function_operator: @@ -1348,7 +1414,7 @@ template_formal_parameter_type: instance_identifier: - name + name_no_final { $$ = new CPPInstanceIdentifier($1); } @@ -1415,11 +1481,6 @@ instance_identifier: { $$ = $1; $$->add_array_modifier($3); -} - | instance_identifier ':' INTEGER -{ - // bitfield definition. We ignore the bitfield for now. - $$ = $1; } | '(' instance_identifier ')' { @@ -1447,6 +1508,82 @@ instance_identifier: ; +instance_identifier_and_maybe_trailing_return_type: + instance_identifier maybe_trailing_return_type +{ + // This is handled a bit awkwardly right now. Ideally it'd be wrapped + // up in the instance_identifier rule, but then more needs to happen in + // order to avoid shift/reduce conflicts. + if ($2 != NULL) { + $1->add_trailing_return_type($2); + } + $$ = $1; +} + | instance_identifier ':' INTEGER +{ + // Bitfield definition. + $1->_bit_width = $3; + $$ = $1; +} + ; + + +maybe_trailing_return_type: + empty +{ + $$ = NULL; +} + | POINTSAT predefined_type empty_instance_identifier +{ + $$ = $3->unroll_type($2); +} + | POINTSAT KW_CONST predefined_type empty_instance_identifier +{ + $4->add_modifier(IIT_const); + $$ = $4->unroll_type($3); +} + ; + + +function_parameter_list: + empty +{ + $$ = new CPPParameterList; +} + | ELLIPSIS +{ + $$ = new CPPParameterList; + $$->_includes_ellipsis = true; +} + | function_parameters +{ + $$ = $1; +} + | function_parameters ',' ELLIPSIS +{ + $$ = $1; + $$->_includes_ellipsis = true; +} + | function_parameters ELLIPSIS +{ + $$ = $1; + $$->_includes_ellipsis = true; +} + ; + +function_parameters: + function_parameter +{ + $$ = new CPPParameterList; + $$->_parameters.push_back($1); +} + | function_parameters ',' function_parameter +{ + $$ = $1; + $$->_parameters.push_back($3); +} + ; + formal_parameter_list: empty { @@ -1508,7 +1645,7 @@ maybe_initialize: } ; -maybe_initialize_or_function_body: +maybe_initialize_or_constructor_body: ';' { $$ = (CPPExpression *)NULL; @@ -1520,6 +1657,25 @@ maybe_initialize_or_function_body: | ':' constructor_inits '{' code '}' { $$ = (CPPExpression *)NULL; +} + | '=' KW_DEFAULT ';' +{ + $$ = new CPPExpression(CPPExpression::get_default()); +} + | '=' KW_DELETE ';' +{ + $$ = new CPPExpression(CPPExpression::get_delete()); +} + ; + +maybe_initialize_or_function_body: + ';' +{ + $$ = (CPPExpression *)NULL; +} + | '{' code '}' +{ + $$ = (CPPExpression *)NULL; } | '=' const_expr ';' { @@ -1554,7 +1710,7 @@ structure_init_body: | structure_init_body ',' '{' structure_init '}' ; -formal_parameter: +function_parameter: type formal_parameter_identifier maybe_initialize { $$ = new CPPInstance($1, $2, 0, @2.file); @@ -1572,9 +1728,20 @@ formal_parameter: $$ = new CPPInstance($3, $4, 0, @3.file); $$->set_initializer($5); } - | KW_REGISTER formal_parameter + | KW_REGISTER function_parameter { $$ = $2; +} + ; + +/* A "formal parameter" is like a function parameter, except that it parses + * instance declarations (that look like functions declaration) as well, and + * as such accepts constexpr parameters. + */ +formal_parameter: + function_parameter +{ + $$ = $1; } | formal_const_expr { @@ -1590,11 +1757,7 @@ not_paren_formal_parameter_identifier: { $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } - | IDENTIFIER -{ - $$ = new CPPInstanceIdentifier($1); -} - | TYPENAME_IDENTIFIER + | name_no_final { $$ = new CPPInstanceIdentifier($1); } @@ -1640,11 +1803,7 @@ formal_parameter_identifier: { $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); } - | IDENTIFIER -{ - $$ = new CPPInstanceIdentifier($1); -} - | TYPENAME_IDENTIFIER + | name_no_final { $$ = new CPPInstanceIdentifier($1); } @@ -1683,7 +1842,7 @@ formal_parameter_identifier: $$ = $1; $$->add_array_modifier($3); } - | '(' formal_parameter_identifier ')' '(' formal_parameter_list ')' function_post + | '(' formal_parameter_identifier ')' '(' function_parameter_list ')' function_post { $$ = $2; $$->add_modifier(IIT_paren); @@ -1696,6 +1855,48 @@ formal_parameter_identifier: } ; +not_paren_empty_instance_identifier: + empty +{ + $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); +} + | KW_CONST not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $2; + $$->add_modifier(IIT_const); +} + | KW_VOLATILE not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $2; + $$->add_modifier(IIT_volatile); +} + | '*' not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $2; + $$->add_modifier(IIT_pointer); +} + | '&' not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $2; + $$->add_modifier(IIT_reference); +} + | ANDAND not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $2; + $$->add_modifier(IIT_rvalue_reference); +} + | SCOPING '*' not_paren_empty_instance_identifier %prec UNARY +{ + $$ = $3; + $$->add_scoped_pointer_modifier($1); +} + | not_paren_empty_instance_identifier '[' optional_const_expr ']' +{ + $$ = $1; + $$->add_array_modifier($3); +} + ; + empty_instance_identifier: empty { @@ -1711,36 +1912,57 @@ empty_instance_identifier: $$ = $2; $$->add_modifier(IIT_volatile); } - | '*' empty_instance_identifier %prec UNARY + | '*' not_paren_empty_instance_identifier %prec UNARY { $$ = $2; $$->add_modifier(IIT_pointer); } - | '&' empty_instance_identifier %prec UNARY + | '&' not_paren_empty_instance_identifier %prec UNARY { $$ = $2; $$->add_modifier(IIT_reference); } - | ANDAND empty_instance_identifier %prec UNARY + | ANDAND not_paren_empty_instance_identifier %prec UNARY { $$ = $2; $$->add_modifier(IIT_rvalue_reference); } - | SCOPING '*' empty_instance_identifier %prec UNARY + | SCOPING '*' not_paren_empty_instance_identifier %prec UNARY { $$ = $3; $$->add_scoped_pointer_modifier($1); } - | empty_instance_identifier '[' optional_const_expr ']' + | not_paren_empty_instance_identifier '[' optional_const_expr ']' { $$ = $1; $$->add_array_modifier($3); } - | '(' empty_instance_identifier ')' '(' formal_parameter_list ')' function_post + | '(' function_parameter_list ')' function_post maybe_trailing_return_type { - $$ = $2; + $$ = new CPPInstanceIdentifier((CPPIdentifier *)NULL); $$->add_modifier(IIT_paren); - $$->add_func_modifier($5, $7); + $$->add_func_modifier($2, $4, $5); +} + | '(' '*' not_paren_empty_instance_identifier ')' '(' function_parameter_list ')' function_post maybe_trailing_return_type +{ + $$ = $3; + $$->add_modifier(IIT_pointer); + $$->add_modifier(IIT_paren); + $$->add_func_modifier($6, $8, $9); +} + | '(' '&' not_paren_empty_instance_identifier ')' '(' function_parameter_list ')' function_post maybe_trailing_return_type +{ + $$ = $3; + $$->add_modifier(IIT_reference); + $$->add_modifier(IIT_paren); + $$->add_func_modifier($6, $8, $9); +} + | '(' ANDAND not_paren_empty_instance_identifier ')' '(' function_parameter_list ')' function_post maybe_trailing_return_type +{ + $$ = $3; + $$->add_modifier(IIT_rvalue_reference); + $$->add_modifier(IIT_paren); + $$->add_func_modifier($6, $8, $9); } ; @@ -1789,7 +2011,7 @@ type: $$ = et; } } - | enum_keyword name ':' enum_element_type + | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -1816,7 +2038,7 @@ type: } | KW_AUTO { - $$ = new CPPSimpleType(CPPSimpleType::T_auto); + $$ = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } ; @@ -1865,7 +2087,7 @@ type_decl: $$ = et; } } - | enum_keyword name ':' enum_element_type + | enum_keyword name_no_final ':' enum_element_type { CPPType *type = $2->find_type(current_scope, global_scope, false, current_lexer); if (type != NULL) { @@ -1910,7 +2132,7 @@ type_decl: } | KW_AUTO { - $$ = new CPPSimpleType(CPPSimpleType::T_auto); + $$ = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } ; @@ -1962,6 +2184,19 @@ predefined_type: } $$ = et; } +} + | KW_DECLTYPE '(' const_expr ')' +{ + $$ = $3->determine_type(); + if ($$ == (CPPType *)NULL) { + stringstream str; + str << *$3; + yyerror("could not determine type of " + str.str(), @3); + } +} + | KW_AUTO +{ + $$ = CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_auto)); } ; @@ -1980,16 +2215,12 @@ var_type_decl: full_type: type empty_instance_identifier { - CPPInstance *inst = new CPPInstance($1, $2, 0, @1.file); - $$ = inst->_type; - delete inst; + $$ = $2->unroll_type($1); } | KW_CONST type empty_instance_identifier { $3->add_modifier(IIT_const); - CPPInstance *inst = new CPPInstance($2, $3, 0, @1.file); - $$ = inst->_type; - delete inst; + $$ = $3->unroll_type($2); } ; @@ -2018,7 +2249,7 @@ anonymous_struct: ; named_struct: - struct_keyword name + struct_keyword name_no_final { CPPVisibility starting_vis = ($1 == CPPExtensionType::T_class) ? V_private : V_public; @@ -2038,7 +2269,7 @@ named_struct: push_scope(new_scope); push_struct(st); } - maybe_class_derivation '{' cpp '}' + maybe_final maybe_class_derivation '{' cpp '}' { $$ = current_struct; current_struct->_incomplete = false; @@ -2047,6 +2278,14 @@ named_struct: } ; +maybe_final: + empty + | KW_FINAL +{ + current_struct->_final = true; +} + ; + maybe_class_derivation: empty | class_derivation @@ -2058,7 +2297,11 @@ class_derivation: ; base_specification: - KW_PUBLIC class_derivation_name + class_derivation_name +{ + current_struct->append_derivation($1, V_unknown, false); +} + | KW_PUBLIC class_derivation_name { current_struct->append_derivation($2, V_public, false); } @@ -2105,11 +2348,11 @@ enum: ; enum_decl: - enum_keyword name ':' enum_element_type + enum_keyword name_no_final ':' enum_element_type { current_enum = new CPPEnumType($2, $4, current_scope, @1.file); } - | enum_keyword name + | enum_keyword name_no_final { current_enum = new CPPEnumType($2, current_scope, @1.file); } @@ -2238,13 +2481,20 @@ namespace_declaration: ; using_declaration: - KW_USING name + KW_USING name ';' { CPPUsing *using_decl = new CPPUsing($2, false, @1.file); current_scope->add_declaration(using_decl, global_scope, current_lexer, @1); current_scope->add_using(using_decl, global_scope, current_lexer); } - | KW_USING KW_NAMESPACE name + | KW_USING name '=' full_type ';' +{ + // This is really just an alternative way to declare a typedef. + CPPTypedefType *typedef_type = new CPPTypedefType($4, $2, current_scope); + typedef_type->_using = true; + current_scope->add_declaration(CPPType::new_type(typedef_type), global_scope, current_lexer, @1); +} + | KW_USING KW_NAMESPACE name ';' { CPPUsing *using_decl = new CPPUsing($3, true, @1.file); current_scope->add_declaration(using_decl, global_scope, current_lexer, @1); @@ -2288,11 +2538,6 @@ simple_int_type: { $$ = new CPPSimpleType(CPPSimpleType::T_int, CPPSimpleType::F_long); -} - | KW_LONGLONG -{ - $$ = new CPPSimpleType(CPPSimpleType::T_int, - CPPSimpleType::F_longlong); } | KW_UNSIGNED { @@ -2338,20 +2583,10 @@ simple_float_type: KW_FLOAT { $$ = new CPPSimpleType(CPPSimpleType::T_float); -} - | KW_LONG KW_FLOAT -{ - $$ = new CPPSimpleType(CPPSimpleType::T_float, - CPPSimpleType::F_long); } | KW_DOUBLE { $$ = new CPPSimpleType(CPPSimpleType::T_double); -} - | KW_LONG KW_LONG KW_FLOAT -{ - $$ = new CPPSimpleType(CPPSimpleType::T_float, - CPPSimpleType::F_longlong); } | KW_LONG KW_DOUBLE { @@ -2403,17 +2638,18 @@ element: | TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL | OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL | KW_ALIGNAS | KW_ALIGNOF | KW_AUTO | KW_BOOL | KW_CATCH - | KW_CHAR | KW_CHAR16_T | KW_CHAR32_T - | KW_CLASS | KW_CONST | KW_CONSTEXPR | KW_DECLTYPE | KW_DEFAULT + | KW_CHAR | KW_CHAR16_T | KW_CHAR32_T | KW_CLASS | KW_CONST + | KW_CONSTEXPR | KW_CONST_CAST | KW_DECLTYPE | KW_DEFAULT | KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM - | KW_EXTERN | KW_EXPLICIT | KW_FALSE - | KW_FLOAT | KW_FRIEND | KW_FOR | KW_GOTO | KW_IF | KW_INLINE - | KW_INT | KW_LONG | KW_MUTABLE | KW_NAMESPACE - | KW_NEW | KW_NULLPTR | KW_OPERATOR | KW_PRIVATE | KW_PROTECTED - | KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_RETURN - | KW_SHORT | KW_SIGNED | KW_SIZEOF | KW_STATIC | KW_STATIC_ASSERT - | KW_STATIC_CAST | KW_STRUCT | KW_THROW | KW_TRUE | KW_TRY - | KW_TYPEDEF | KW_TYPENAME | KW_UNION | KW_UNSIGNED | KW_USING + | KW_EXTERN | KW_EXPLICIT | KW_FALSE | KW_FINAL | KW_FLOAT + | KW_FRIEND | KW_FOR | KW_GOTO | KW_IF | KW_INLINE | KW_INT + | KW_LONG | KW_MUTABLE | KW_NAMESPACE | KW_NEW | KW_NULLPTR + | KW_OPERATOR | KW_OVERRIDE | KW_PRIVATE | KW_PROTECTED + | KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_REINTERPRET_CAST + | KW_RETURN | KW_SHORT | KW_SIGNED | KW_SIZEOF | KW_STATIC + | KW_STATIC_ASSERT | KW_STATIC_CAST | KW_STRUCT + | KW_THREAD_LOCAL | KW_THROW | KW_TRUE | KW_TRY | KW_TYPEDEF + | KW_TYPEID | KW_TYPENAME | KW_UNION | KW_UNSIGNED | KW_USING | KW_VIRTUAL | KW_VOID | KW_VOLATILE | KW_WCHAR_T | KW_WHILE { } @@ -2466,11 +2702,19 @@ no_angle_bracket_const_expr: } | KW_STATIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_static_cast)); } | KW_DYNAMIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_dynamic_cast)); +} + | KW_CONST_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_const_cast)); +} + | KW_REINTERPRET_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_reinterpret_cast)); } | KW_SIZEOF '(' full_type ')' %prec UNARY { @@ -2491,6 +2735,10 @@ no_angle_bracket_const_expr: | '-' no_angle_bracket_const_expr %prec UNARY { $$ = new CPPExpression(UNARY_MINUS, $2); +} + | '+' no_angle_bracket_const_expr %prec UNARY +{ + $$ = new CPPExpression(UNARY_PLUS, $2); } | '*' no_angle_bracket_const_expr %prec UNARY { @@ -2606,11 +2854,19 @@ const_expr: } | KW_STATIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_static_cast)); } | KW_DYNAMIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_dynamic_cast)); +} + | KW_CONST_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_const_cast)); +} + | KW_REINTERPRET_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_reinterpret_cast)); } | TYPENAME_IDENTIFIER '(' optional_const_expr_comma ')' { @@ -2713,6 +2969,28 @@ const_expr: | KW_NEW predefined_type '(' optional_const_expr_comma ')' %prec UNARY { $$ = new CPPExpression(CPPExpression::new_op($2, $4)); +} + | KW_TYPEID '(' full_type ')' +{ + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", @1); + } + $$ = new CPPExpression(CPPExpression::typeid_op($3, std_type_info)); +} + | KW_TYPEID '(' const_expr ')' +{ + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", @1); + } + $$ = new CPPExpression(CPPExpression::typeid_op($3, std_type_info)); } | '!' const_expr %prec UNARY { @@ -2725,6 +3003,10 @@ const_expr: | '-' const_expr %prec UNARY { $$ = new CPPExpression(UNARY_MINUS, $2); +} + | '+' const_expr %prec UNARY +{ + $$ = new CPPExpression(UNARY_PLUS, $2); } | '*' const_expr %prec UNARY { @@ -2868,10 +3150,30 @@ const_operand: | IDENTIFIER { $$ = new CPPExpression($1, current_scope, global_scope, current_lexer); +} + | KW_FINAL +{ + // A variable named "final". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("final", @1); + $$ = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + | KW_OVERRIDE +{ + // A variable named "override". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("override", @1); + $$ = new CPPExpression(ident, current_scope, global_scope, current_lexer); } | KW_NULLPTR { $$ = new CPPExpression(CPPExpression::get_nullptr()); +} + | '[' capture_list ']' function_post maybe_trailing_return_type '{' code '}' +{ + $$ = NULL; +} + | '[' capture_list ']' '(' function_parameter_list ')' function_post maybe_trailing_return_type '{' code '}' +{ + $$ = NULL; } ; @@ -2893,11 +3195,19 @@ formal_const_expr: } | KW_STATIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_static_cast)); } | KW_DYNAMIC_CAST '<' full_type '>' '(' const_expr_comma ')' { - $$ = new CPPExpression(CPPExpression::typecast_op($3, $6)); + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_dynamic_cast)); +} + | KW_CONST_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_const_cast)); +} + | KW_REINTERPRET_CAST '<' full_type '>' '(' const_expr_comma ')' +{ + $$ = new CPPExpression(CPPExpression::typecast_op($3, $6, CPPExpression::T_reinterpret_cast)); } | KW_SIZEOF '(' full_type ')' %prec UNARY { @@ -2914,6 +3224,28 @@ formal_const_expr: | KW_NEW predefined_type '(' optional_const_expr_comma ')' %prec UNARY { $$ = new CPPExpression(CPPExpression::new_op($2, $4)); +} + | KW_TYPEID '(' full_type ')' +{ + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", @1); + } + $$ = new CPPExpression(CPPExpression::typeid_op($3, std_type_info)); +} + | KW_TYPEID '(' const_expr ')' +{ + CPPIdentifier ident(""); + ident.add_name("std"); + ident.add_name("type_info"); + CPPType *std_type_info = ident.find_type(current_scope, global_scope, false, current_lexer); + if (!std_type_info) { + yywarning("cannot use typeid before including ", @1); + } + $$ = new CPPExpression(CPPExpression::typeid_op($3, std_type_info)); } | '!' const_expr %prec UNARY { @@ -2926,6 +3258,10 @@ formal_const_expr: | '-' const_expr %prec UNARY { $$ = new CPPExpression(UNARY_MINUS, $2); +} + | '+' const_expr %prec UNARY +{ + $$ = new CPPExpression(UNARY_PLUS, $2); } | '&' const_expr %prec UNARY { @@ -3065,6 +3401,18 @@ formal_const_operand: | IDENTIFIER { $$ = new CPPExpression($1, current_scope, global_scope, current_lexer); +} + | KW_FINAL +{ + // A variable named "final". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("final", @1); + $$ = new CPPExpression(ident, current_scope, global_scope, current_lexer); +} + | KW_OVERRIDE +{ + // A variable named "override". C++11 explicitly permits this. + CPPIdentifier *ident = new CPPIdentifier("override", @1); + $$ = new CPPExpression(ident, current_scope, global_scope, current_lexer); } | KW_NULLPTR { @@ -3072,6 +3420,20 @@ formal_const_operand: } ; +/* The contents of the [] list preceding a lambda expression. */ +capture_list: + empty + | capture + | capture ',' capture_list + ; + +capture: + '&' + | '=' + | '&' name + | name + ; + class_derivation_name: name { @@ -3114,6 +3476,8 @@ typedefname: */ +/* Note that we should also accept "final" and "override" as valid names, + * according to C++11. */ name: IDENTIFIER { @@ -3122,9 +3486,37 @@ name: | TYPENAME_IDENTIFIER { $$ = $1; +} + | KW_FINAL +{ + $$ = new CPPIdentifier("final", @1); +} + | KW_OVERRIDE +{ + $$ = new CPPIdentifier("override", @1); } ; + +/* A variant on name that's used for structs, where we disallow final + * to disambiguate the case of struct A final {}; + */ +name_no_final: + IDENTIFIER +{ + $$ = $1; +} + | TYPENAME_IDENTIFIER +{ + $$ = $1; +} + | KW_OVERRIDE +{ + $$ = new CPPIdentifier("override", @1); +} + ; + + string_literal: SIMPLE_STRING { diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index abb8e595ed..e596cb4359 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -58,6 +58,29 @@ CPPEnumType(CPPIdentifier *ident, CPPType *element_type, } } +//////////////////////////////////////////////////////////////////// +// Function: CPPEnumType::get_element_type +// Access: Public +// Description: Returns the integral type used to store enum values. +//////////////////////////////////////////////////////////////////// +CPPType *CPPEnumType:: +get_element_type() { + if (_element_type == NULL) { + // This enum is untyped. Use a suitable default, ie. 'int'. + // In the future, we might want to check whether it fits in an int. + static CPPType *default_element_type = NULL; + if (default_element_type == NULL) { + default_element_type = + CPPType::new_type(new CPPConstType(new CPPSimpleType(CPPSimpleType::T_int, 0))); + } + + return default_element_type; + } else { + // This enum has an explicit type, so use that. + return CPPType::new_type(new CPPConstType(_element_type)); + } +} + //////////////////////////////////////////////////////////////////// // Function: CPPEnumType::add_element // Access: Public @@ -67,22 +90,8 @@ CPPInstance *CPPEnumType:: add_element(const string &name, CPPExpression *value) { CPPIdentifier *ident = new CPPIdentifier(name); ident->_native_scope = _parent_scope; - CPPInstance *inst; - - static CPPType *default_element_type = NULL; - if (_element_type == NULL) { - // This enum is untyped. Use a suitable default, ie. 'int'. - if (default_element_type == NULL) { - default_element_type = - CPPType::new_type(new CPPConstType(new CPPSimpleType(CPPSimpleType::T_int, 0))); - } - - inst = new CPPInstance(default_element_type, ident); - } else { - // This enum has an explicit type, so use that. - inst = new CPPInstance(CPPType::new_type(new CPPConstType(_element_type)), ident); - } + CPPInstance *inst = new CPPInstance(get_element_type(), ident); inst->_storage_class |= CPPInstance::SC_constexpr; _elements.push_back(inst); diff --git a/dtool/src/cppparser/cppEnumType.h b/dtool/src/cppparser/cppEnumType.h index 7b63f475c6..1d592b337b 100644 --- a/dtool/src/cppparser/cppEnumType.h +++ b/dtool/src/cppparser/cppEnumType.h @@ -37,6 +37,8 @@ public: CPPEnumType(CPPIdentifier *ident, CPPType *element_type, CPPScope *current_scope, const CPPFile &file); + CPPType *get_element_type(); + CPPInstance *add_element(const string &name, CPPExpression *value = (CPPExpression *)NULL); diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 2c94ed7006..fc33ee03fa 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -356,9 +356,10 @@ CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, // operation. //////////////////////////////////////////////////////////////////// CPPExpression CPPExpression:: -typecast_op(CPPType *type, CPPExpression *op1) { +typecast_op(CPPType *type, CPPExpression *op1, Type cast_type) { + assert(cast_type >= T_typecast && cast_type <= T_reinterpret_cast); CPPExpression expr(0); - expr._type = T_typecast; + expr._type = cast_type; expr._u._typecast._to = type; expr._u._typecast._op1 = op1; return expr; @@ -410,6 +411,36 @@ new_op(CPPType *type, CPPExpression *op1) { return expr; } +//////////////////////////////////////////////////////////////////// +// Function: CPPExpression::named typeid_op constructor +// Access: Public, Static +// Description: Creates an expression that represents a use of the +// typeid operator. +//////////////////////////////////////////////////////////////////// +CPPExpression CPPExpression:: +typeid_op(CPPType *type, CPPType *std_type_info) { + CPPExpression expr(0); + expr._type = T_typeid_type; + expr._u._typeid._type = type; + expr._u._typeid._std_type_info = std_type_info; + return expr; +} + +//////////////////////////////////////////////////////////////////// +// Function: CPPExpression::named typeid_op constructor +// Access: Public, Static +// Description: Creates an expression that represents a use of the +// typeid operator. +//////////////////////////////////////////////////////////////////// +CPPExpression CPPExpression:: +typeid_op(CPPExpression *op1, CPPType *std_type_info) { + CPPExpression expr(0); + expr._type = T_typeid_expr; + expr._u._typeid._expr = op1; + expr._u._typeid._std_type_info = std_type_info; + return expr; +} + //////////////////////////////////////////////////////////////////// // Function: CPPExpression::named sizeof_func constructor // Access: Public, Static @@ -591,6 +622,10 @@ evaluate() const { return Result(); case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: assert(_u._typecast._op1 != NULL); r1 = _u._typecast._op1->evaluate(); if (r1._type != RT_error) { @@ -706,6 +741,9 @@ evaluate() const { case UNARY_MINUS: return (r1._type == RT_real) ? Result(-r1.as_real()) : Result(-r1.as_integer()); + case UNARY_PLUS: + return r1; + case UNARY_STAR: case UNARY_REF: return Result(); @@ -835,6 +873,10 @@ evaluate() const { case T_raw_literal: return Result(); + case T_typeid_type: + case T_typeid_expr: + return Result(); + default: cerr << "**invalid operand**\n"; abort(); @@ -940,6 +982,10 @@ determine_type() const { return (CPPType *)NULL; case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_default_construct: return _u._typecast._to; @@ -973,7 +1019,34 @@ determine_type() const { return int_type; case UNARY_MINUS: - return t1; + case UNARY_PLUS: + if (t1 != NULL) { + switch (t1->get_subtype()) { + case CPPDeclaration::ST_array: + // Decay into pointer. + return CPPType::new_type(new CPPPointerType(t1->as_array_type()->_element_type)); + + case CPPDeclaration::ST_enum: + // Convert into integral type. + return t1->as_enum_type()->get_element_type(); + + case CPPDeclaration::ST_simple: + { + CPPSimpleType *simple_type = t1->as_simple_type(); + if ((simple_type->_flags & CPPSimpleType::F_short) != 0 || + simple_type->_type == CPPSimpleType::T_bool || + simple_type->_type == CPPSimpleType::T_wchar_t || + simple_type->_type == CPPSimpleType::T_char16_t) { + // Integer promotion. + return int_type; + } + } + // Fall through. + default: + return t1; + } + } + return NULL; case UNARY_STAR: case '[': // Array element reference @@ -1059,6 +1132,10 @@ determine_type() const { } return NULL; + case T_typeid_type: + case T_typeid_expr: + return _u._typeid._std_type_info; + default: cerr << "**invalid operand**\n"; abort(); @@ -1103,6 +1180,10 @@ is_fully_specified() const { return _u._ident->is_fully_specified(); case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_new: return (_u._typecast._to->is_fully_specified() && @@ -1136,6 +1217,12 @@ is_fully_specified() const { case T_raw_literal: return _u._literal._value->is_fully_specified(); + case T_typeid_type: + return _u._typeid._type->is_fully_specified(); + + case T_typeid_expr: + return _u._typeid._expr->is_fully_specified(); + default: return true; } @@ -1215,6 +1302,10 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, break; case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_new: rep->_u._typecast._op1 = @@ -1254,6 +1345,20 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, any_changed = any_changed || (rep->_u._op._op1 != _u._op._op1); break; + case T_typeid_type: + rep->_u._typeid._type = + _u._typeid._type->substitute_decl(subst, current_scope, global_scope) + ->as_type(); + any_changed = any_changed || (rep->_u._typeid._type != _u._typeid._type); + break; + + case T_typeid_expr: + rep->_u._typeid._expr = + _u._typeid._expr->substitute_decl(subst, current_scope, global_scope) + ->as_expression(); + any_changed = any_changed || (rep->_u._typeid._expr != _u._typeid._expr); + break; + default: break; } @@ -1295,6 +1400,10 @@ is_tbd() const { return true; case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_new: case T_default_construct: @@ -1321,6 +1430,12 @@ is_tbd() const { } return false; + case T_typeid_type: + return _u._typeid._type->is_tbd(); + + case T_typeid_expr: + return _u._typeid._expr->is_tbd(); + default: return false; } @@ -1450,6 +1565,38 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { out << ")"; break; + case T_static_cast: + out << "static_cast<"; + _u._typecast._to->output(out, indent_level, scope, false); + out << ">("; + _u._typecast._op1->output(out, indent_level, scope, false); + out << ")"; + break; + + case T_dynamic_cast: + out << "dynamic_cast<"; + _u._typecast._to->output(out, indent_level, scope, false); + out << ">("; + _u._typecast._op1->output(out, indent_level, scope, false); + out << ")"; + break; + + case T_const_cast: + out << "const_cast<"; + _u._typecast._to->output(out, indent_level, scope, false); + out << ">("; + _u._typecast._op1->output(out, indent_level, scope, false); + out << ")"; + break; + + case T_reinterpret_cast: + out << "reinterpret_cast<"; + _u._typecast._to->output(out, indent_level, scope, false); + out << ">("; + _u._typecast._op1->output(out, indent_level, scope, false); + out << ")"; + break; + case T_construct: _u._typecast._to->output(out, indent_level, scope, false); out << "("; @@ -1507,6 +1654,11 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { _u._op._op1->output(out, indent_level, scope, false); break; + case UNARY_PLUS: + out << '+'; + _u._op._op1->output(out, indent_level, scope, false); + break; + case UNARY_STAR: out << "(* "; _u._op._op1->output(out, indent_level, scope, false); @@ -1599,11 +1751,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { break; case '.': - out << "("; _u._op._op1->output(out, indent_level, scope, false); out << "."; _u._op._op2->output(out, indent_level, scope, false); - out << ")"; break; case POINTSAT: @@ -1671,6 +1821,18 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { } break; + case T_typeid_type: + out << "typeid("; + _u._typeid._type->output(out, indent_level, scope, false); + out << ")"; + break; + + case T_typeid_expr: + out << "typeid("; + _u._typeid._expr->output(out, indent_level, scope, false); + out << ")"; + break; + case T_default: out << "default"; break; @@ -1802,6 +1964,10 @@ is_equal(const CPPDeclaration *other) const { return *_u._ident == *ot->_u._ident; case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_new: return _u._typecast._to == ot->_u._typecast._to && @@ -1832,6 +1998,12 @@ is_equal(const CPPDeclaration *other) const { return _str == ot->_str && _u._literal._operator == ot->_u._literal._operator; + case T_typeid_type: + return _u._typeid._type == ot->_u._typeid._type; + + case T_typeid_expr: + return _u._typeid._expr == ot->_u._typeid._expr; + default: cerr << "(** invalid operand type " << (int)_type << " **)"; } @@ -1885,6 +2057,10 @@ is_less(const CPPDeclaration *other) const { return *_u._ident < *ot->_u._ident; case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: case T_construct: case T_new: if (_u._typecast._to != ot->_u._typecast._to) { @@ -1925,6 +2101,12 @@ is_less(const CPPDeclaration *other) const { } return _str < ot->_str; + case T_typeid_type: + return _u._typeid._type < ot->_u._typeid._type; + + case T_typeid_expr: + return *_u._typeid._expr < *ot->_u._typeid._expr; + default: cerr << "(** invalid operand type " << (int)_type << " **)"; } diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index aebf5b2566..644f3c5a96 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -30,6 +30,43 @@ class CPPFunctionGroup; //////////////////////////////////////////////////////////////////// class CPPExpression : public CPPDeclaration { public: + enum Type { + T_nullptr, + T_boolean, + T_integer, + T_real, + T_string, + T_wstring, + T_u8string, + T_u16string, + T_u32string, + T_variable, + T_function, + T_unknown_ident, + T_typecast, + T_static_cast, + T_dynamic_cast, + T_const_cast, + T_reinterpret_cast, + T_construct, + T_default_construct, + T_new, + T_default_new, + T_sizeof, + T_alignof, + T_unary_operation, + T_binary_operation, + T_trinary_operation, + T_literal, + T_raw_literal, + T_typeid_type, + T_typeid_expr, + + // These are used when parsing =default and =delete methods. + T_default, + T_delete, + }; + CPPExpression(bool value); CPPExpression(unsigned long long value); CPPExpression(int value); @@ -41,9 +78,11 @@ public: CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2); CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, CPPExpression *op3); - static CPPExpression typecast_op(CPPType *type, CPPExpression *op1); + static CPPExpression typecast_op(CPPType *type, CPPExpression *op1, Type cast_type = T_typecast); static CPPExpression construct_op(CPPType *type, CPPExpression *op1); static CPPExpression new_op(CPPType *type, CPPExpression *op1 = NULL); + static CPPExpression typeid_op(CPPType *type, CPPType *std_type_info); + static CPPExpression typeid_op(CPPExpression *op1, CPPType *std_type_info); static CPPExpression sizeof_func(CPPType *type); static CPPExpression alignof_func(CPPType *type); @@ -102,38 +141,6 @@ public: virtual CPPExpression *as_expression(); - - enum Type { - T_nullptr, - T_boolean, - T_integer, - T_real, - T_string, - T_wstring, - T_u8string, - T_u16string, - T_u32string, - T_variable, - T_function, - T_unknown_ident, - T_typecast, - T_construct, - T_default_construct, - T_new, - T_default_new, - T_sizeof, - T_alignof, - T_unary_operation, - T_binary_operation, - T_trinary_operation, - T_literal, - T_raw_literal, - - // These are used when parsing =default and =delete methods. - T_default, - T_delete, - }; - Type _type; string _str; union { @@ -143,13 +150,18 @@ public: CPPInstance *_variable; CPPFunctionGroup *_fgroup; CPPIdentifier *_ident; - class { - public: + struct { + union { + CPPType *_type; + CPPExpression *_expr; + }; + CPPType *_std_type_info; + } _typeid; + struct { CPPType *_to; CPPExpression *_op1; } _typecast; - class { - public: + struct { // One of the yytoken values: a character, or something // like EQCOMPARE. int _operator; @@ -157,8 +169,7 @@ public: CPPExpression *_op2; CPPExpression *_op3; } _op; - class { - public: + struct { CPPInstance *_operator; CPPExpression *_value; } _literal; diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index 793e75986f..d4b7d171c2 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -214,10 +214,10 @@ is_equivalent(const CPPType &other) const { // Description: //////////////////////////////////////////////////////////////////// void CPPExtensionType:: -output(ostream &out, int, CPPScope *scope, bool) const { +output(ostream &out, int, CPPScope *scope, bool complete) const { if (_ident != NULL) { // If we have a name, use it. - if (cppparser_output_class_keyword) { + if (complete || cppparser_output_class_keyword) { out << _type << " "; } out << _ident->get_local_name(scope); diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index fa8cf3f291..be716f35c9 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -193,12 +193,44 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { void CPPFunctionType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { - _return_type->output(out, indent_level, scope, complete); - out << "("; - _parameters->output(out, scope, true, num_default_parameters); - out << ")"; - if (_flags & F_const_method) { - out << " const"; + + if (_flags & F_trailing_return_type) { + // It was declared using trailing return type, so let's format it that way. + out << "auto("; + _parameters->output(out, scope, true, num_default_parameters); + out << ")"; + if (_flags & F_const_method) { + out << " const"; + } + if (_flags & F_noexcept) { + out << " noexcept"; + } + if (_flags & F_final) { + out << " final"; + } + if (_flags & F_override) { + out << " override"; + } + out << " -> "; + _return_type->output(out, indent_level, scope, false); + + } else { + _return_type->output(out, indent_level, scope, complete); + out << "("; + _parameters->output(out, scope, true, num_default_parameters); + out << ")"; + if (_flags & F_const_method) { + out << " const"; + } + if (_flags & F_noexcept) { + out << " noexcept"; + } + if (_flags & F_final) { + out << " final"; + } + if (_flags & F_override) { + out << " override"; + } } } @@ -241,6 +273,18 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, // No return type for constructors and destructors. out << prename << name << str; + } else if (_flags & F_trailing_return_type) { + // It was declared using trailing return type, so let's format it that way. + out << "auto "; + + if (prename.empty()) { + out << name; + } else { + out << "(" << prename << name << ")"; + } + + out << str; + } else { if (prename.empty()) { _return_type->output_instance(out, indent_level, scope, complete, @@ -257,6 +301,17 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, if (_flags & F_noexcept) { out << " noexcept"; } + if (_flags & F_final) { + out << " final"; + } + if (_flags & F_override) { + out << " override"; + } + + if (_flags & F_trailing_return_type) { + out << " -> "; + _return_type->output(out, indent_level, scope, false); + } } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppFunctionType.h b/dtool/src/cppparser/cppFunctionType.h index 84e65e4444..d80c815b00 100644 --- a/dtool/src/cppparser/cppFunctionType.h +++ b/dtool/src/cppparser/cppFunctionType.h @@ -39,6 +39,9 @@ public: F_noexcept = 0x080, F_copy_constructor = 0x200, F_move_constructor = 0x400, + F_trailing_return_type = 0x800, + F_final = 0x1000, + F_override = 0x2000, }; CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index e41cbc36b3..7ac4792043 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -39,7 +39,8 @@ CPPInstance(CPPType *type, const string &name, int storage_class) : _type(type), _ident(new CPPIdentifier(name)), _storage_class(storage_class), - _alignment(NULL) + _alignment(NULL), + _bit_width(-1) { _initializer = NULL; } @@ -55,7 +56,8 @@ CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class) : _type(type), _ident(ident), _storage_class(storage_class), - _alignment(NULL) + _alignment(NULL), + _bit_width(-1) { _initializer = NULL; } @@ -79,6 +81,7 @@ CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, ii->_ident = NULL; _storage_class = storage_class; _initializer = NULL; + _bit_width = ii->_bit_width; CPPParameterList *params = ii->get_initializer(); if (params != (CPPParameterList *)NULL) { @@ -106,7 +109,8 @@ CPPInstance(const CPPInstance ©) : _ident(copy._ident), _initializer(copy._initializer), _storage_class(copy._storage_class), - _alignment(copy._alignment) + _alignment(copy._alignment), + _bit_width(copy._bit_width) { assert(_type != NULL); } @@ -612,6 +616,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, if (_storage_class & SC_constexpr) { out << "constexpr "; } + if (_storage_class & SC_thread_local) { + out << "thread_local "; + } string name; if (_ident != NULL) { @@ -627,6 +634,10 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, _type->output_instance(out, indent_level, scope, complete, "", name); } + if (_bit_width != -1) { + out << " : " << _bit_width; + } + if (_storage_class & SC_pure_virtual) { out << " = 0"; } diff --git a/dtool/src/cppparser/cppInstance.h b/dtool/src/cppparser/cppInstance.h index 34b95db33b..81578a1e35 100644 --- a/dtool/src/cppparser/cppInstance.h +++ b/dtool/src/cppparser/cppInstance.h @@ -64,6 +64,8 @@ public: // These are for =default and =delete functions. SC_defaulted = 0x4000, SC_deleted = 0x8000, + + SC_thread_local = 0x10000, }; CPPInstance(CPPType *type, const string &name, int storage_class = 0); @@ -119,6 +121,7 @@ public: int _storage_class; CPPExpression *_alignment; + int _bit_width; private: typedef map Instantiations; diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index ffef7523b9..044dc34d75 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -43,10 +43,11 @@ Modifier(CPPInstanceIdentifierType type) : // Description: //////////////////////////////////////////////////////////////////// CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier:: -func_type(CPPParameterList *params, int flags) { +func_type(CPPParameterList *params, int flags, CPPType *trailing_return_type) { Modifier mod(IIT_func); mod._func_params = params; mod._func_flags = flags; + mod._trailing_return_type = trailing_return_type; return mod; } @@ -93,7 +94,9 @@ initializer_type(CPPParameterList *params) { // Description: //////////////////////////////////////////////////////////////////// CPPInstanceIdentifier:: -CPPInstanceIdentifier(CPPIdentifier *ident) : _ident(ident) { +CPPInstanceIdentifier(CPPIdentifier *ident) : + _ident(ident), + _bit_width(-1) { } //////////////////////////////////////////////////////////////////// @@ -128,7 +131,7 @@ add_modifier(CPPInstanceIdentifierType type) { // Description: //////////////////////////////////////////////////////////////////// void CPPInstanceIdentifier:: -add_func_modifier(CPPParameterList *params, int flags) { +add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_type) { // As a special hack, if we added a parameter list to an operator // function, check if the parameter list is empty. If it is, this // is really a unary operator, so set the unary_op flag. Operators @@ -146,7 +149,12 @@ add_func_modifier(CPPParameterList *params, int flags) { flags |= CPPFunctionType::F_operator; } - _modifiers.push_back(Modifier::func_type(params, flags)); + if (trailing_return_type != NULL) { + // Remember whether trailing return type notation was used. + flags |= CPPFunctionType::F_trailing_return_type; + } + + _modifiers.push_back(Modifier::func_type(params, flags, trailing_return_type)); } //////////////////////////////////////////////////////////////////// @@ -188,6 +196,25 @@ add_initializer_modifier(CPPParameterList *params) { _modifiers.push_back(Modifier::initializer_type(params)); } +//////////////////////////////////////////////////////////////////// +// Function: CPPInstanceIdentifier::add_trailing_return_type +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +void CPPInstanceIdentifier:: +add_trailing_return_type(CPPType *type) { + // This is an awkward hack. Improve in the future. + if (!_modifiers.empty()) { + Modifier &mod = _modifiers.back(); + if (mod._type == IIT_func) { + mod._trailing_return_type = type; + mod._func_flags |= CPPFunctionType::F_trailing_return_type; + return; + } + } + cerr << "trailing return type can only be added to a function\n"; +} + //////////////////////////////////////////////////////////////////// // Function: CPPInstanceIdentifier::get_initializer // Access: Public @@ -237,6 +264,8 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPType *CPPInstanceIdentifier:: r_unroll_type(CPPType *start_type, CPPInstanceIdentifier::Modifiers::const_iterator mi) { + assert(start_type != NULL); + start_type = CPPType::new_type(start_type); if (mi == _modifiers.end()) { @@ -298,6 +327,14 @@ r_unroll_type(CPPType *start_type, case IIT_func: { CPPType *return_type = r_unroll_type(start_type, mi); + if (mod._trailing_return_type != (CPPType *)NULL) { + CPPSimpleType *simple_type = return_type->as_simple_type(); + if (simple_type != NULL && simple_type->_type == CPPSimpleType::T_auto) { + return_type = mod._trailing_return_type; + } else { + cerr << "function with trailing return type needs auto\n"; + } + } result = new CPPFunctionType(return_type, mod._func_params, mod._func_flags); } diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index afef5b675d..ee44ab8c0a 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -57,11 +57,14 @@ public: CPPType *unroll_type(CPPType *start_type); void add_modifier(CPPInstanceIdentifierType type); - void add_func_modifier(CPPParameterList *params, int flags); + void add_func_modifier(CPPParameterList *params, int flags, + CPPType *trailing_return_type = NULL); void add_scoped_pointer_modifier(CPPIdentifier *scoping); void add_array_modifier(CPPExpression *expr); void add_initializer_modifier(CPPParameterList *params); + void add_trailing_return_type(CPPType *type); + CPPParameterList *get_initializer() const; CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope, @@ -72,7 +75,8 @@ public: class Modifier { public: Modifier(CPPInstanceIdentifierType type); - static Modifier func_type(CPPParameterList *params, int flags); + static Modifier func_type(CPPParameterList *params, int flags, + CPPType *trailing_return_type); static Modifier array_type(CPPExpression *expr); static Modifier scoped_pointer_type(CPPIdentifier *scoping); static Modifier initializer_type(CPPParameterList *params); @@ -82,10 +86,13 @@ public: int _func_flags; CPPIdentifier *_scoping; CPPExpression *_expr; + CPPType *_trailing_return_type; }; typedef vector Modifiers; Modifiers _modifiers; + int _bit_width; + private: CPPType * r_unroll_type(CPPType *start_type, Modifiers::const_iterator mi); diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index bd18331e23..cef75dbe74 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1367,6 +1367,50 @@ skip_cpp_comment(int c) { return c; } +//////////////////////////////////////////////////////////////////// +// Function: CPPPreprocessor::skip_digit_separator +// Access: Private +// Description: Skips a C++14 digit separator that has just been +// found through peek(). +//////////////////////////////////////////////////////////////////// +int CPPPreprocessor:: +skip_digit_separator(int c) { + if (c != '\'') { + return c; + } + + get(); + c = peek(); + + if (isdigit(c)) { + return c; + } + + YYLTYPE loc; + loc.file = get_file(); + loc.first_line = get_line_number(); + loc.first_column = get_col_number(); + loc.last_line = loc.first_line; + loc.last_column = loc.first_column; + + if (c != '\'') { + // This assumes that this isn't a character constant directly follows + // a digit sequence, like 123'a' -- I can't think of a situation + // where that's legal anyway, though. + error("digit separator cannot occur at end of digit sequence", loc); + return c; + } + + while (c == '\'') { + get(); + ++loc.last_column; + c = peek(); + } + error("adjacent digit separators", loc); + + return c; +} + //////////////////////////////////////////////////////////////////// // Function: CPPPreprocessor::process_directive // Access: Private @@ -2395,7 +2439,8 @@ extract_manifest_args_inline(const string &name, int num_args, //////////////////////////////////////////////////////////////////// // Function: CPPPreprocessor::get_number // Access: Private -// Description: +// Description: Assuming that we've just read a digit or a period +// indicating the start of a number, read the rest. //////////////////////////////////////////////////////////////////// CPPToken CPPPreprocessor:: get_number(int c) { @@ -2410,16 +2455,16 @@ get_number(int c) { bool leading_zero = (c == '0'); bool decimal_point = (c == '.'); - c = peek(); + c = skip_digit_separator(peek()); - if (leading_zero && c == 'x') { + if (leading_zero && (c == 'x' || c == 'X')) { // Here we have a hex number. num += get(); c = peek(); while (c != EOF && (isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'f'))) { num += get(); - c = peek(); + c = skip_digit_separator(peek()); } loc.last_line = get_line_number(); @@ -2429,11 +2474,30 @@ get_number(int c) { result.u.integer = strtol(num.c_str(), (char **)NULL, 16); return get_literal(INTEGER, loc, num, result); + + } else if (leading_zero && (c == 'b' || c == 'B')) { + // A C++14-style binary number. + get(); + c = peek(); + string bin(1, (char)c); + + while (c != EOF && (c == '0' || c == '1')) { + bin += get(); + c = skip_digit_separator(peek()); + } + + loc.last_line = get_line_number(); + loc.last_column = get_col_number(); + + YYSTYPE result; + result.u.integer = strtol(bin.c_str(), (char **)NULL, 2); + + return get_literal(INTEGER, loc, bin, result); } while (c != EOF && isdigit(c)) { num += get(); - c = peek(); + c = skip_digit_separator(peek()); } if (c == '.' && !decimal_point) { @@ -2459,7 +2523,7 @@ get_number(int c) { } while (c != EOF && isdigit(c)) { num += get(); - c = peek(); + c = skip_digit_separator(peek()); } } @@ -2517,6 +2581,7 @@ check_keyword(const string &name) { if (name == "__const") return KW_CONST; if (name == "__const__") return KW_CONST; if (name == "constexpr") return KW_CONSTEXPR; + if (name == "const_cast") return KW_CONST_CAST; if (name == "decltype") return KW_DECLTYPE; if (name == "default") return KW_DEFAULT; if (name == "delete") return KW_DELETE; @@ -2530,6 +2595,7 @@ check_keyword(const string &name) { if (name == "explicit") return KW_EXPLICIT; if (name == "__published") return KW_PUBLISHED; if (name == "false") return KW_FALSE; + if (name == "final") return KW_FINAL; if (name == "float") return KW_FLOAT; if (name == "friend") return KW_FRIEND; if (name == "for") return KW_FOR; @@ -2549,10 +2615,12 @@ check_keyword(const string &name) { if (name == "nullptr") return KW_NULLPTR; if (name == "new") return KW_NEW; if (name == "operator") return KW_OPERATOR; + if (name == "override") return KW_OVERRIDE; if (name == "private") return KW_PRIVATE; if (name == "protected") return KW_PROTECTED; if (name == "public") return KW_PUBLIC; if (name == "register") return KW_REGISTER; + if (name == "reinterpret_cast") return KW_REINTERPRET_CAST; if (name == "return") return KW_RETURN; if (name == "short") return KW_SHORT; if (name == "signed") return KW_SIGNED; @@ -2562,10 +2630,12 @@ check_keyword(const string &name) { if (name == "static_cast") return KW_STATIC_CAST; if (name == "struct") return KW_STRUCT; if (name == "template") return KW_TEMPLATE; + if (name == "thread_local") return KW_THREAD_LOCAL; if (name == "throw") return KW_THROW; if (name == "true") return KW_TRUE; if (name == "try") return KW_TRY; if (name == "typedef") return KW_TYPEDEF; + if (name == "typeid") return KW_TYPEID; if (name == "typename") return KW_TYPENAME; if (name == "union") return KW_UNION; if (name == "unsigned") return KW_UNSIGNED; @@ -2589,10 +2659,6 @@ check_keyword(const string &name) { if (name == "xor") return '^'; if (name == "xor_eq") return XOREQUAL; - if (!cpp_longlong_keyword.empty() && name == cpp_longlong_keyword) { - return KW_LONGLONG; - } - return 0; } diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index bf1170d145..aa7b8ef89c 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -126,6 +126,7 @@ private: int skip_comment(int c); int skip_c_comment(int c); int skip_cpp_comment(int c); + int skip_digit_separator(int c); int process_directive(int c); int get_preprocessor_command(int c, string &command); diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index 9445963f1a..36e20a1f73 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -48,7 +48,8 @@ CPPStructType(CPPStructType::Type type, CPPIdentifier *ident, CPPScope *current_scope, CPPScope *scope, const CPPFile &file) : CPPExtensionType(type, ident, current_scope, file), - _scope(scope) + _scope(scope), + _final(false) { _subst_decl_recursive_protect = false; _incomplete = true; @@ -64,7 +65,8 @@ CPPStructType(const CPPStructType ©) : CPPExtensionType(copy), _scope(copy._scope), _incomplete(copy._incomplete), - _derivation(copy._derivation) + _derivation(copy._derivation), + _final(copy._final) { _subst_decl_recursive_protect = false; } @@ -80,6 +82,7 @@ operator = (const CPPStructType ©) { _scope = copy._scope; _incomplete = copy._incomplete; _derivation = copy._derivation; + _final = copy._final; } //////////////////////////////////////////////////////////////////// @@ -99,6 +102,15 @@ append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual) { def = base->as_typedef_type(); } + if (vis == V_unknown && base->as_extension_type() != NULL) { + // Default visibility. + if (base->as_extension_type()->_type == T_class) { + vis = V_private; + } else { + vis = V_public; + } + } + Base b; b._base = base; b._vis = vis; @@ -794,10 +806,14 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << _type; } + if (_final) { + out << " final"; + } + // Show any derivation we may have if (!_derivation.empty()) { Derivation::const_iterator di = _derivation.begin(); - out << ": " << *di; + out << " : " << *di; ++di; while (di != _derivation.end()) { out << ", " << *di; diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index 2d7df19526..c6b0a976ab 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -78,6 +78,7 @@ public: CPPScope *_scope; bool _incomplete; + bool _final; class Base { public: diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index 5f247fef68..30f0307ebe 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -200,6 +200,10 @@ output(ostream &out) const { out << "UNARY_MINUS"; break; + case UNARY_PLUS: + out << "UNARY_PLUS"; + break; + case UNARY_NEGATE: out << "UNARY_NEGATE"; break; diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index b8eeb4ee8e..9bb0f24e9b 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -25,7 +25,8 @@ CPPTypedefType:: CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope) : CPPType(CPPFile()), _type(type), - _ident(new CPPIdentifier(name)) + _ident(new CPPIdentifier(name)), + _using(false) { if (_ident != NULL) { _ident->_native_scope = current_scope; @@ -49,7 +50,8 @@ CPPTypedefType:: CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : CPPType(CPPFile()), _type(type), - _ident(ident) + _ident(ident), + _using(false) { if (_ident != NULL) { _ident->_native_scope = current_scope; @@ -68,8 +70,10 @@ CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : CPPTypedefType:: CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, CPPScope *current_scope, const CPPFile &file) : - CPPType(file) + CPPType(file), + _using(false) { + assert(ii != NULL); _type = ii->unroll_type(type); _ident = ii->_ident; ii->_ident = NULL; @@ -363,8 +367,14 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } if (complete) { - out << "typedef "; - _type->output_instance(out, indent_level, scope, false, "", name); + if (_using) { + // It was declared using the "using" keyword. + out << "using " << name << " = "; + _type->output(out, 0, scope, false); + } else { + out << "typedef "; + _type->output_instance(out, indent_level, scope, false, "", name); + } } else { out << name; } @@ -401,7 +411,7 @@ is_equal(const CPPDeclaration *other) const { const CPPTypedefType *ot = ((CPPDeclaration *)other)->as_typedef_type(); assert(ot != NULL); - return (*_type == *ot->_type) && (*_ident == *ot->_ident); + return (*_type == *ot->_type) && (*_ident == *ot->_ident) && (_using == ot->_using); } //////////////////////////////////////////////////////////////////// diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index 0fb46b2132..49ef52c250 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -65,6 +65,7 @@ public: CPPType *_type; CPPIdentifier *_ident; + bool _using; protected: virtual bool is_equal(const CPPDeclaration *other) const; diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 836a51f027..cd5e2c091b 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -36,8 +36,8 @@ using namespace std; #define TYPENAME typename #define CONSTEXPR constexpr #define NOEXCEPT noexcept -#define FINAL -#define OVERRIDE +#define FINAL final +#define OVERRIDE override #define MOVE(x) x #define DEFAULT_CTOR = default diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index 92b543f3e6..aead6ba481 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -272,10 +272,6 @@ void show_help() { << " function wrappers already, from some external source. This is most\n" << " useful in conjunction with -true-names.\n\n" - << " -longlong typename\n" - << " Specify the name of the 64-bit integer type for the current compiler.\n" - << " By default, this is \"long long\".\n\n" - << " -promiscuous\n" << " Export *all* public symbols, functions, and classes seen, even those\n" << " not explicitly marked to be published.\n\n" @@ -436,6 +432,7 @@ main(int argc, char **argv) { break; case CO_longlong: + cerr << "Warning: ignoring deprecated -longlong option.\n"; cpp_longlong_keyword = optarg; break; diff --git a/dtool/src/parser-inc/typeinfo b/dtool/src/parser-inc/typeinfo index 9144890d5a..a6cac9fc84 100644 --- a/dtool/src/parser-inc/typeinfo +++ b/dtool/src/parser-inc/typeinfo @@ -1,5 +1,22 @@ #pragma once -class type_info; -class bad_cast; -class bad_typeid; +#include + +namespace std { + class type_info { + public: + type_info(const type_info& rhs) = delete; + virtual ~type_info(); + + type_info &operator = (const type_info &rhs) = delete; + + bool operator ==(const type_info &rhs) const noexcept; + bool operator !=(const type_info &rhs) const noexcept; + bool before(const type_info &rhs) const noexcept; + size_t hash_code() const noexcept; + const char *name() const noexcept; + }; + + class bad_cast; + class bad_typeid; +} From 186f1b41b287e8a7646637cdf19e59007ad1ff76 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 16 Feb 2016 11:24:42 +0100 Subject: [PATCH 10/31] Fix for PDWORD_PTR --- dtool/src/parser-inc/windows.h | 3 ++- panda/src/express/trueClock.cxx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dtool/src/parser-inc/windows.h b/dtool/src/parser-inc/windows.h index bee8a5c25a..6ad9e3082a 100644 --- a/dtool/src/parser-inc/windows.h +++ b/dtool/src/parser-inc/windows.h @@ -53,7 +53,8 @@ typedef PVOID HANDLE; typedef HANDLE HGLOBAL; typedef HANDLE HWAVEIN; typedef HANDLE HWND; -typedef void *DWORD_PTR; +typedef ULONG_PTR DWORD_PTR; +typedef DWORD_PTR *PDWORD_PTR; typedef UINT_PTR WPARAM; typedef LONG_PTR LPARAM; typedef wchar_t WCHAR; diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index aeb2a28e56..9e55659a16 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -123,10 +123,10 @@ get_short_raw_time() { //////////////////////////////////////////////////////////////////// // Function: TrueClock::set_cpu_affinity, Win32 implementation // Access: Published -// Description: +// Description: //////////////////////////////////////////////////////////////////// typedef BOOL (WINAPI * PFNSETPROCESSAFFINITYMASK)(HANDLE, DWORD_PTR); -typedef BOOL (WINAPI * PFNGETPROCESSAFFINITYMASK)(HANDLE, PDWORD_PTR, PDWORD_PTR); +typedef BOOL (WINAPI * PFNGETPROCESSAFFINITYMASK)(HANDLE, DWORD_PTR*, DWORD_PTR*); bool TrueClock:: set_cpu_affinity(PN_uint32 mask) const { From 0fcfb8e372c71e5c15a20bfd064b51f8db831469 Mon Sep 17 00:00:00 2001 From: tobspr Date: Wed, 17 Feb 2016 09:03:51 +0100 Subject: [PATCH 11/31] New file headers, new comment style --- contrib/src/ai/aiBehaviors.cxx | 344 +- contrib/src/ai/aiBehaviors.h | 55 +- contrib/src/ai/aiCharacter.cxx | 37 +- contrib/src/ai/aiCharacter.h | 39 +- contrib/src/ai/aiGlobals.h | 25 +- contrib/src/ai/aiNode.cxx | 34 +- contrib/src/ai/aiNode.h | 73 +- contrib/src/ai/aiPathFinder.cxx | 167 +- contrib/src/ai/aiPathFinder.h | 37 +- contrib/src/ai/aiWorld.cxx | 102 +- contrib/src/ai/aiWorld.h | 51 +- contrib/src/ai/arrival.cxx | 50 +- contrib/src/ai/arrival.h | 30 +- contrib/src/ai/config_ai.cxx | 39 +- contrib/src/ai/config_ai.h | 26 +- contrib/src/ai/evade.cxx | 50 +- contrib/src/ai/evade.h | 25 +- contrib/src/ai/flee.cxx | 50 +- contrib/src/ai/flee.h | 25 +- contrib/src/ai/flock.cxx | 32 +- contrib/src/ai/flock.h | 41 +- contrib/src/ai/meshNode.cxx | 9 +- contrib/src/ai/meshNode.h | 42 +- contrib/src/ai/obstacleAvoidance.cxx | 60 +- contrib/src/ai/obstacleAvoidance.h | 25 +- contrib/src/ai/pathFind.cxx | 130 +- contrib/src/ai/pathFind.h | 41 +- contrib/src/ai/pathFollow.cxx | 53 +- contrib/src/ai/pursue.cxx | 38 +- contrib/src/ai/pursue.h | 25 +- contrib/src/ai/seek.cxx | 36 +- contrib/src/ai/seek.h | 25 +- contrib/src/ai/wander.cxx | 63 +- contrib/src/ai/wander.h | 25 +- contrib/src/contribbase/contribbase.cxx | 25 +- contrib/src/contribbase/contribbase.h | 12 +- contrib/src/contribbase/contribsymbols.h | 11 +- direct/metalibs/direct/direct.cxx | 17 +- direct/src/dcparse/dcparse.cxx | 33 +- direct/src/dcparser/dcArrayParameter.cxx | 300 +- direct/src/dcparser/dcArrayParameter.h | 43 +- direct/src/dcparser/dcAtomicField.I | 26 +- direct/src/dcparser/dcAtomicField.cxx | 258 +- direct/src/dcparser/dcAtomicField.h | 40 +- direct/src/dcparser/dcClass.I | 108 +- direct/src/dcparser/dcClass.cxx | 677 +-- direct/src/dcparser/dcClass.h | 59 +- direct/src/dcparser/dcClassParameter.cxx | 160 +- direct/src/dcparser/dcClassParameter.h | 37 +- direct/src/dcparser/dcDeclaration.cxx | 83 +- direct/src/dcparser/dcDeclaration.h | 43 +- direct/src/dcparser/dcField.I | 215 +- direct/src/dcparser/dcField.cxx | 328 +- direct/src/dcparser/dcField.h | 35 +- direct/src/dcparser/dcFile.I | 62 +- direct/src/dcparser/dcFile.cxx | 481 +- direct/src/dcparser/dcFile.h | 36 +- direct/src/dcparser/dcKeyword.cxx | 101 +- direct/src/dcparser/dcKeyword.h | 41 +- direct/src/dcparser/dcKeywordList.cxx | 166 +- direct/src/dcparser/dcKeywordList.h | 34 +- direct/src/dcparser/dcLexerDefs.h | 25 +- direct/src/dcparser/dcMolecularField.cxx | 160 +- direct/src/dcparser/dcMolecularField.h | 39 +- direct/src/dcparser/dcNumericRange.I | 208 +- direct/src/dcparser/dcNumericRange.h | 35 +- direct/src/dcparser/dcPackData.I | 161 +- direct/src/dcparser/dcPackData.cxx | 36 +- direct/src/dcparser/dcPackData.h | 33 +- direct/src/dcparser/dcPacker.I | 921 ++-- direct/src/dcparser/dcPacker.cxx | 699 ++- direct/src/dcparser/dcPacker.h | 80 +- direct/src/dcparser/dcPackerCatalog.I | 104 +- direct/src/dcparser/dcPackerCatalog.cxx | 258 +- direct/src/dcparser/dcPackerCatalog.h | 56 +- direct/src/dcparser/dcPackerInterface.I | 351 +- direct/src/dcparser/dcPackerInterface.cxx | 432 +- direct/src/dcparser/dcPackerInterface.h | 92 +- direct/src/dcparser/dcParameter.cxx | 235 +- direct/src/dcparser/dcParameter.h | 50 +- direct/src/dcparser/dcParser.yxx | 9 +- direct/src/dcparser/dcParserDefs.h | 42 +- direct/src/dcparser/dcPython.h | 33 +- direct/src/dcparser/dcSimpleParameter.cxx | 534 +- direct/src/dcparser/dcSimpleParameter.h | 71 +- direct/src/dcparser/dcSubatomicType.cxx | 25 +- direct/src/dcparser/dcSubatomicType.h | 50 +- direct/src/dcparser/dcSwitch.cxx | 476 +- direct/src/dcparser/dcSwitch.h | 57 +- direct/src/dcparser/dcSwitchParameter.cxx | 203 +- direct/src/dcparser/dcSwitchParameter.h | 35 +- direct/src/dcparser/dcTypedef.cxx | 148 +- direct/src/dcparser/dcTypedef.h | 35 +- direct/src/dcparser/dcbase.h | 77 +- direct/src/dcparser/dcindent.cxx | 32 +- direct/src/dcparser/dcindent.h | 42 +- direct/src/dcparser/dcmsgtypes.h | 31 +- direct/src/dcparser/hashGenerator.cxx | 72 +- direct/src/dcparser/hashGenerator.h | 33 +- direct/src/dcparser/primeNumberGenerator.cxx | 53 +- direct/src/dcparser/primeNumberGenerator.h | 42 +- direct/src/deadrec/config_deadrec.cxx | 40 +- direct/src/deadrec/config_deadrec.h | 27 +- direct/src/deadrec/smoothMover.I | 737 ++- direct/src/deadrec/smoothMover.cxx | 341 +- direct/src/deadrec/smoothMover.h | 114 +- direct/src/directbase/directbase.cxx | 25 +- direct/src/directbase/directbase.h | 12 +- direct/src/directbase/directsymbols.h | 11 +- direct/src/directbase/ppython.cxx | 20 +- direct/src/directd/directd.cxx | 120 +- direct/src/directd/directd.h | 189 +- direct/src/directdServer/directdClient.cxx | 29 +- direct/src/directdServer/directdClient.h | 32 +- direct/src/directdServer/directdServer.cxx | 37 +- direct/src/directdServer/directdServer.h | 43 +- direct/src/directscripts/Doxyfile.cxx | 2 +- direct/src/directscripts/doxygen_filter.py | 68 - .../src/distributed/cConnectionRepository.I | 385 +- .../src/distributed/cConnectionRepository.cxx | 374 +- .../src/distributed/cConnectionRepository.h | 72 +- .../distributed/cDistributedSmoothNodeBase.I | 173 +- .../cDistributedSmoothNodeBase.cxx | 142 +- .../distributed/cDistributedSmoothNodeBase.h | 41 +- direct/src/distributed/config_distributed.cxx | 40 +- direct/src/distributed/config_distributed.h | 26 +- direct/src/interval/cConstrainHprInterval.I | 42 +- direct/src/interval/cConstrainHprInterval.cxx | 65 +- direct/src/interval/cConstrainHprInterval.h | 35 +- .../src/interval/cConstrainPosHprInterval.I | 42 +- .../src/interval/cConstrainPosHprInterval.cxx | 67 +- .../src/interval/cConstrainPosHprInterval.h | 36 +- direct/src/interval/cConstrainPosInterval.I | 42 +- direct/src/interval/cConstrainPosInterval.cxx | 64 +- direct/src/interval/cConstrainPosInterval.h | 35 +- .../interval/cConstrainTransformInterval.I | 42 +- .../interval/cConstrainTransformInterval.cxx | 66 +- .../interval/cConstrainTransformInterval.h | 35 +- direct/src/interval/cConstraintInterval.I | 27 +- direct/src/interval/cConstraintInterval.cxx | 33 +- direct/src/interval/cConstraintInterval.h | 35 +- direct/src/interval/cInterval.I | 267 +- direct/src/interval/cInterval.cxx | 486 +- direct/src/interval/cInterval.h | 75 +- direct/src/interval/cIntervalManager.I | 59 +- direct/src/interval/cIntervalManager.cxx | 297 +- direct/src/interval/cIntervalManager.h | 55 +- direct/src/interval/cLerpAnimEffectInterval.I | 63 +- .../src/interval/cLerpAnimEffectInterval.cxx | 45 +- direct/src/interval/cLerpAnimEffectInterval.h | 52 +- direct/src/interval/cLerpInterval.I | 47 +- direct/src/interval/cLerpInterval.cxx | 53 +- direct/src/interval/cLerpInterval.h | 40 +- direct/src/interval/cLerpNodePathInterval.I | 479 +- direct/src/interval/cLerpNodePathInterval.cxx | 286 +- direct/src/interval/cLerpNodePathInterval.h | 43 +- direct/src/interval/cMetaInterval.I | 196 +- direct/src/interval/cMetaInterval.cxx | 711 ++- direct/src/interval/cMetaInterval.h | 60 +- direct/src/interval/config_interval.cxx | 40 +- direct/src/interval/config_interval.h | 25 +- direct/src/interval/hideInterval.I | 26 +- direct/src/interval/hideInterval.cxx | 61 +- direct/src/interval/hideInterval.h | 35 +- direct/src/interval/lerp_helpers.h | 59 +- direct/src/interval/lerpblend.cxx | 26 +- direct/src/interval/lerpblend.h | 25 +- direct/src/interval/showInterval.I | 26 +- direct/src/interval/showInterval.cxx | 61 +- direct/src/interval/showInterval.h | 35 +- direct/src/interval/waitInterval.I | 36 +- direct/src/interval/waitInterval.cxx | 43 +- direct/src/interval/waitInterval.h | 36 +- direct/src/motiontrail/cMotionTrail.cxx | 182 +- direct/src/motiontrail/cMotionTrail.h | 93 +- direct/src/motiontrail/config_motiontrail.cxx | 39 +- direct/src/motiontrail/config_motiontrail.h | 25 +- direct/src/plugin/binaryXml.cxx | 138 +- direct/src/plugin/binaryXml.h | 32 +- direct/src/plugin/fhandle.h | 29 +- direct/src/plugin/fileSpec.I | 119 +- direct/src/plugin/fileSpec.cxx | 298 +- direct/src/plugin/fileSpec.h | 41 +- direct/src/plugin/find_root_dir.cxx | 161 +- direct/src/plugin/find_root_dir.h | 25 +- direct/src/plugin/find_root_dir_assist.mm | 57 +- direct/src/plugin/get_tinyxml.h | 31 +- direct/src/plugin/get_twirl_data.cxx | 63 +- direct/src/plugin/get_twirl_data.h | 26 +- direct/src/plugin/handleStream.I | 104 +- direct/src/plugin/handleStream.cxx | 25 +- direct/src/plugin/handleStream.h | 37 +- direct/src/plugin/handleStreamBuf.I | 50 +- direct/src/plugin/handleStreamBuf.cxx | 160 +- direct/src/plugin/handleStreamBuf.h | 32 +- direct/src/plugin/is_pathsep.I | 36 +- direct/src/plugin/is_pathsep.h | 25 +- direct/src/plugin/load_plugin.cxx | 190 +- direct/src/plugin/load_plugin.h | 31 +- direct/src/plugin/mkdir_complete.cxx | 94 +- direct/src/plugin/mkdir_complete.h | 27 +- direct/src/plugin/p3dAuthSession.I | 26 +- direct/src/plugin/p3dAuthSession.cxx | 170 +- direct/src/plugin/p3dAuthSession.h | 39 +- direct/src/plugin/p3dBoolObject.cxx | 77 +- direct/src/plugin/p3dBoolObject.h | 33 +- direct/src/plugin/p3dCInstance.I | 35 +- direct/src/plugin/p3dCInstance.cxx | 41 +- direct/src/plugin/p3dCInstance.h | 34 +- direct/src/plugin/p3dCert.cxx | 204 +- direct/src/plugin/p3dCert.h | 58 +- direct/src/plugin/p3dCert_strings.cxx | 38 +- direct/src/plugin/p3dCert_strings.h | 25 +- direct/src/plugin/p3dCert_wx.cxx | 245 +- direct/src/plugin/p3dCert_wx.h | 65 +- direct/src/plugin/p3dConcreteSequence.cxx | 178 +- direct/src/plugin/p3dConcreteSequence.h | 42 +- direct/src/plugin/p3dConcreteStruct.cxx | 138 +- direct/src/plugin/p3dConcreteStruct.h | 43 +- direct/src/plugin/p3dConditionVar.I | 26 +- direct/src/plugin/p3dConditionVar.cxx | 90 +- direct/src/plugin/p3dConditionVar.h | 38 +- direct/src/plugin/p3dDownload.I | 155 +- direct/src/plugin/p3dDownload.cxx | 144 +- direct/src/plugin/p3dDownload.h | 45 +- direct/src/plugin/p3dFileDownload.I | 34 +- direct/src/plugin/p3dFileDownload.cxx | 98 +- direct/src/plugin/p3dFileDownload.h | 34 +- direct/src/plugin/p3dFileParams.I | 77 +- direct/src/plugin/p3dFileParams.cxx | 148 +- direct/src/plugin/p3dFileParams.h | 33 +- direct/src/plugin/p3dFloatObject.cxx | 86 +- direct/src/plugin/p3dFloatObject.h | 33 +- direct/src/plugin/p3dHost.I | 150 +- direct/src/plugin/p3dHost.cxx | 471 +- direct/src/plugin/p3dHost.h | 37 +- direct/src/plugin/p3dInstance.I | 183 +- direct/src/plugin/p3dInstance.cxx | 1737 +++---- direct/src/plugin/p3dInstance.h | 88 +- direct/src/plugin/p3dInstanceManager.I | 409 +- direct/src/plugin/p3dInstanceManager.cxx | 676 +-- direct/src/plugin/p3dInstanceManager.h | 56 +- direct/src/plugin/p3dIntObject.cxx | 78 +- direct/src/plugin/p3dIntObject.h | 33 +- direct/src/plugin/p3dMainObject.cxx | 355 +- direct/src/plugin/p3dMainObject.h | 70 +- direct/src/plugin/p3dMultifileReader.I | 89 +- direct/src/plugin/p3dMultifileReader.cxx | 221 +- direct/src/plugin/p3dMultifileReader.h | 41 +- direct/src/plugin/p3dNoneObject.cxx | 60 +- direct/src/plugin/p3dNoneObject.h | 35 +- direct/src/plugin/p3dObject.I | 42 +- direct/src/plugin/p3dObject.cxx | 334 +- direct/src/plugin/p3dObject.h | 48 +- direct/src/plugin/p3dOsxSplashWindow.I | 43 +- direct/src/plugin/p3dOsxSplashWindow.cxx | 311 +- direct/src/plugin/p3dOsxSplashWindow.h | 35 +- direct/src/plugin/p3dPackage.I | 209 +- direct/src/plugin/p3dPackage.cxx | 912 ++-- direct/src/plugin/p3dPackage.h | 54 +- direct/src/plugin/p3dPatchFinder.I | 26 +- direct/src/plugin/p3dPatchFinder.cxx | 238 +- direct/src/plugin/p3dPatchFinder.h | 62 +- direct/src/plugin/p3dPatchfileReader.I | 80 +- direct/src/plugin/p3dPatchfileReader.cxx | 114 +- direct/src/plugin/p3dPatchfileReader.h | 48 +- direct/src/plugin/p3dPythonMain.cxx | 53 +- direct/src/plugin/p3dPythonObject.cxx | 255 +- direct/src/plugin/p3dPythonObject.h | 39 +- direct/src/plugin/p3dPythonRun.I | 26 +- direct/src/plugin/p3dPythonRun.cxx | 607 +-- direct/src/plugin/p3dPythonRun.h | 94 +- direct/src/plugin/p3dReferenceCount.I | 86 +- direct/src/plugin/p3dReferenceCount.cxx | 25 +- direct/src/plugin/p3dReferenceCount.h | 37 +- direct/src/plugin/p3dSession.I | 71 +- direct/src/plugin/p3dSession.cxx | 753 ++- direct/src/plugin/p3dSession.h | 67 +- direct/src/plugin/p3dSplashWindow.I | 60 +- direct/src/plugin/p3dSplashWindow.cxx | 456 +- direct/src/plugin/p3dSplashWindow.h | 49 +- direct/src/plugin/p3dStringObject.cxx | 95 +- direct/src/plugin/p3dStringObject.h | 33 +- direct/src/plugin/p3dTemporaryFile.I | 34 +- direct/src/plugin/p3dTemporaryFile.cxx | 41 +- direct/src/plugin/p3dTemporaryFile.h | 43 +- direct/src/plugin/p3dUndefinedObject.cxx | 60 +- direct/src/plugin/p3dUndefinedObject.h | 37 +- direct/src/plugin/p3dWinSplashWindow.I | 43 +- direct/src/plugin/p3dWinSplashWindow.cxx | 374 +- direct/src/plugin/p3dWinSplashWindow.h | 33 +- direct/src/plugin/p3dWindowParams.I | 89 +- direct/src/plugin/p3dWindowParams.cxx | 64 +- direct/src/plugin/p3dWindowParams.h | 32 +- direct/src/plugin/p3dX11SplashWindow.I | 43 +- direct/src/plugin/p3dX11SplashWindow.cxx | 376 +- direct/src/plugin/p3dX11SplashWindow.h | 33 +- direct/src/plugin/p3d_lock.h | 43 +- direct/src/plugin/p3d_plugin.cxx | 99 +- direct/src/plugin/p3d_plugin.h | 60 +- direct/src/plugin/p3d_plugin_common.h | 42 +- direct/src/plugin/parse_color.cxx | 51 +- direct/src/plugin/parse_color.h | 26 +- direct/src/plugin/plugin_get_x11.h | 40 +- direct/src/plugin/run_p3dpython.cxx | 37 +- direct/src/plugin/run_p3dpython.h | 30 +- direct/src/plugin/wstring_encode.cxx | 39 +- direct/src/plugin/wstring_encode.h | 37 +- direct/src/plugin/xml_helpers.cxx | 37 +- direct/src/plugin/xml_helpers.h | 26 +- direct/src/plugin_activex/P3DActiveX.cpp | 33 +- direct/src/plugin_activex/P3DActiveX.h | 26 +- direct/src/plugin_activex/P3DActiveXCtrl.cpp | 88 +- direct/src/plugin_activex/P3DActiveXCtrl.h | 33 +- .../src/plugin_activex/P3DActiveXPropPage.cpp | 35 +- .../src/plugin_activex/P3DActiveXPropPage.h | 29 +- direct/src/plugin_activex/PPBrowserObject.cpp | 72 +- direct/src/plugin_activex/PPBrowserObject.h | 29 +- .../src/plugin_activex/PPDownloadCallback.cpp | 37 +- .../src/plugin_activex/PPDownloadCallback.h | 25 +- .../src/plugin_activex/PPDownloadRequest.cpp | 49 +- direct/src/plugin_activex/PPDownloadRequest.h | 31 +- direct/src/plugin_activex/PPInstance.cpp | 355 +- direct/src/plugin_activex/PPInstance.h | 25 +- direct/src/plugin_activex/PPInterface.cpp | 132 +- direct/src/plugin_activex/PPInterface.h | 27 +- direct/src/plugin_activex/PPLogger.cpp | 44 +- direct/src/plugin_activex/PPLogger.h | 26 +- direct/src/plugin_activex/PPPandaObject.cpp | 45 +- direct/src/plugin_activex/PPPandaObject.h | 31 +- direct/src/plugin_npapi/nppanda3d_common.h | 70 +- direct/src/plugin_npapi/ppBrowserObject.I | 26 +- direct/src/plugin_npapi/ppBrowserObject.cxx | 143 +- direct/src/plugin_npapi/ppBrowserObject.h | 45 +- direct/src/plugin_npapi/ppDownloadRequest.I | 35 +- direct/src/plugin_npapi/ppDownloadRequest.cxx | 26 +- direct/src/plugin_npapi/ppDownloadRequest.h | 40 +- direct/src/plugin_npapi/ppInstance.I | 43 +- direct/src/plugin_npapi/ppInstance.cxx | 1344 ++--- direct/src/plugin_npapi/ppInstance.h | 72 +- direct/src/plugin_npapi/ppPandaObject.I | 38 +- direct/src/plugin_npapi/ppPandaObject.cxx | 346 +- direct/src/plugin_npapi/ppPandaObject.h | 45 +- direct/src/plugin_npapi/ppToplevelObject.I | 26 +- direct/src/plugin_npapi/ppToplevelObject.cxx | 206 +- direct/src/plugin_npapi/ppToplevelObject.h | 38 +- direct/src/plugin_npapi/startup.cxx | 332 +- direct/src/plugin_npapi/startup.h | 25 +- direct/src/plugin_standalone/p3dEmbed.cxx | 87 +- direct/src/plugin_standalone/p3dEmbed.h | 34 +- direct/src/plugin_standalone/p3dEmbedMain.cxx | 26 +- direct/src/plugin_standalone/panda3d.I | 25 +- direct/src/plugin_standalone/panda3d.cxx | 328 +- direct/src/plugin_standalone/panda3d.h | 36 +- direct/src/plugin_standalone/panda3dBase.I | 46 +- direct/src/plugin_standalone/panda3dBase.cxx | 325 +- direct/src/plugin_standalone/panda3dBase.h | 56 +- direct/src/plugin_standalone/panda3dMac.I | 26 +- direct/src/plugin_standalone/panda3dMac.cxx | 65 +- direct/src/plugin_standalone/panda3dMac.h | 37 +- direct/src/plugin_standalone/panda3dMain.cxx | 25 +- .../src/plugin_standalone/panda3dWinMain.cxx | 42 +- direct/src/showbase/showBase.cxx | 136 +- direct/src/showbase/showBase.h | 47 +- direct/src/showbase/showBase_assist.mm | 7 +- dtool/metalibs/dtool/dtool.cxx | 19 +- dtool/metalibs/dtoolconfig/dtoolconfig.cxx | 19 +- dtool/src/cppparser/cppArrayType.cxx | 180 +- dtool/src/cppparser/cppArrayType.h | 32 +- dtool/src/cppparser/cppBison.yxx | 9 +- dtool/src/cppparser/cppBisonDefs.h | 69 +- .../cppparser/cppClassTemplateParameter.cxx | 92 +- .../src/cppparser/cppClassTemplateParameter.h | 33 +- dtool/src/cppparser/cppCommentBlock.cxx | 26 +- dtool/src/cppparser/cppCommentBlock.h | 39 +- dtool/src/cppparser/cppConstType.cxx | 179 +- dtool/src/cppparser/cppConstType.h | 32 +- dtool/src/cppparser/cppDeclaration.cxx | 324 +- dtool/src/cppparser/cppDeclaration.h | 32 +- dtool/src/cppparser/cppEnumType.cxx | 119 +- dtool/src/cppparser/cppEnumType.h | 32 +- dtool/src/cppparser/cppExpression.cxx | 459 +- dtool/src/cppparser/cppExpression.h | 35 +- dtool/src/cppparser/cppExpressionParser.cxx | 66 +- dtool/src/cppparser/cppExpressionParser.h | 34 +- dtool/src/cppparser/cppExtensionType.cxx | 173 +- dtool/src/cppparser/cppExtensionType.h | 36 +- dtool/src/cppparser/cppFile.cxx | 165 +- dtool/src/cppparser/cppFile.h | 38 +- dtool/src/cppparser/cppFunctionGroup.cxx | 79 +- dtool/src/cppparser/cppFunctionGroup.h | 42 +- dtool/src/cppparser/cppFunctionType.cxx | 229 +- dtool/src/cppparser/cppFunctionType.h | 33 +- dtool/src/cppparser/cppGlobals.cxx | 25 +- dtool/src/cppparser/cppGlobals.h | 35 +- dtool/src/cppparser/cppIdentifier.cxx | 301 +- dtool/src/cppparser/cppIdentifier.h | 32 +- dtool/src/cppparser/cppInstance.cxx | 295 +- dtool/src/cppparser/cppInstance.h | 45 +- dtool/src/cppparser/cppInstanceIdentifier.cxx | 197 +- dtool/src/cppparser/cppInstanceIdentifier.h | 39 +- dtool/src/cppparser/cppMakeProperty.cxx | 89 +- dtool/src/cppparser/cppMakeProperty.h | 38 +- dtool/src/cppparser/cppMakeSeq.cxx | 81 +- dtool/src/cppparser/cppMakeSeq.h | 38 +- dtool/src/cppparser/cppManifest.cxx | 133 +- dtool/src/cppparser/cppManifest.h | 39 +- dtool/src/cppparser/cppNameComponent.cxx | 141 +- dtool/src/cppparser/cppNameComponent.h | 25 +- dtool/src/cppparser/cppNamespace.cxx | 90 +- dtool/src/cppparser/cppNamespace.h | 36 +- dtool/src/cppparser/cppParameterList.cxx | 141 +- dtool/src/cppparser/cppParameterList.h | 39 +- dtool/src/cppparser/cppParser.cxx | 81 +- dtool/src/cppparser/cppParser.h | 53 +- dtool/src/cppparser/cppPointerType.cxx | 189 +- dtool/src/cppparser/cppPointerType.h | 32 +- dtool/src/cppparser/cppPreprocessor.cxx | 889 ++-- dtool/src/cppparser/cppPreprocessor.h | 56 +- dtool/src/cppparser/cppReferenceType.cxx | 179 +- dtool/src/cppparser/cppReferenceType.h | 32 +- dtool/src/cppparser/cppScope.cxx | 380 +- dtool/src/cppparser/cppScope.h | 32 +- dtool/src/cppparser/cppSimpleType.cxx | 145 +- dtool/src/cppparser/cppSimpleType.h | 65 +- dtool/src/cppparser/cppStructType.cxx | 394 +- dtool/src/cppparser/cppStructType.h | 32 +- dtool/src/cppparser/cppTBDType.cxx | 151 +- dtool/src/cppparser/cppTBDType.h | 39 +- .../cppparser/cppTemplateParameterList.cxx | 137 +- .../src/cppparser/cppTemplateParameterList.h | 41 +- dtool/src/cppparser/cppTemplateScope.cxx | 135 +- dtool/src/cppparser/cppTemplateScope.h | 37 +- dtool/src/cppparser/cppToken.cxx | 84 +- dtool/src/cppparser/cppToken.h | 32 +- dtool/src/cppparser/cppType.cxx | 332 +- dtool/src/cppparser/cppType.h | 35 +- dtool/src/cppparser/cppTypeDeclaration.cxx | 67 +- dtool/src/cppparser/cppTypeDeclaration.h | 38 +- dtool/src/cppparser/cppTypeParser.cxx | 66 +- dtool/src/cppparser/cppTypeParser.h | 34 +- dtool/src/cppparser/cppTypeProxy.cxx | 276 +- dtool/src/cppparser/cppTypeProxy.h | 37 +- dtool/src/cppparser/cppTypedefType.cxx | 268 +- dtool/src/cppparser/cppTypedefType.h | 32 +- dtool/src/cppparser/cppUsing.cxx | 58 +- dtool/src/cppparser/cppUsing.h | 32 +- dtool/src/cppparser/cppVisibility.cxx | 26 +- dtool/src/cppparser/cppVisibility.h | 26 +- dtool/src/dconfig/config_dconfig.cxx | 25 +- dtool/src/dconfig/config_dconfig.h | 25 +- dtool/src/dconfig/dconfig.I | 26 +- dtool/src/dconfig/dconfig.cxx | 25 +- dtool/src/dconfig/dconfig.h | 70 +- dtool/src/dconfig/test_config.cxx | 25 +- dtool/src/dconfig/test_expand.cxx | 25 +- dtool/src/dconfig/test_pfstream.cxx | 25 +- dtool/src/dconfig/test_searchpath.cxx | 31 +- dtool/src/dtoolbase/addHash.I | 51 +- dtool/src/dtoolbase/addHash.cxx | 33 +- dtool/src/dtoolbase/addHash.h | 37 +- dtool/src/dtoolbase/atomicAdjust.h | 38 +- dtool/src/dtoolbase/atomicAdjustDummyImpl.I | 131 +- dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx | 25 +- dtool/src/dtoolbase/atomicAdjustDummyImpl.h | 36 +- dtool/src/dtoolbase/atomicAdjustGccImpl.I | 146 +- dtool/src/dtoolbase/atomicAdjustGccImpl.h | 32 +- dtool/src/dtoolbase/atomicAdjustI386Impl.I | 154 +- dtool/src/dtoolbase/atomicAdjustI386Impl.cxx | 25 +- dtool/src/dtoolbase/atomicAdjustI386Impl.h | 43 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.I | 156 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx | 25 +- dtool/src/dtoolbase/atomicAdjustPosixImpl.h | 42 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.I | 169 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx | 25 +- dtool/src/dtoolbase/atomicAdjustWin32Impl.h | 33 +- dtool/src/dtoolbase/cmath.I | 324 +- dtool/src/dtoolbase/cmath.h | 38 +- dtool/src/dtoolbase/deletedBufferChain.I | 76 +- dtool/src/dtoolbase/deletedBufferChain.cxx | 79 +- dtool/src/dtoolbase/deletedBufferChain.h | 89 +- dtool/src/dtoolbase/deletedChain.h | 107 +- dtool/src/dtoolbase/dtool_platform.h | 12 +- dtool/src/dtoolbase/dtoolbase.cxx | 50 +- dtool/src/dtoolbase/dtoolbase.h | 65 +- dtool/src/dtoolbase/dtoolbase_cc.h | 78 +- dtool/src/dtoolbase/dtoolsymbols.h | 11 +- dtool/src/dtoolbase/epvector.h | 58 +- dtool/src/dtoolbase/fakestringstream.h | 32 +- dtool/src/dtoolbase/indent.I | 44 +- dtool/src/dtoolbase/indent.cxx | 33 +- dtool/src/dtoolbase/indent.h | 55 +- dtool/src/dtoolbase/lookup3.h | 28 +- dtool/src/dtoolbase/memoryBase.cxx | 25 +- dtool/src/dtoolbase/memoryBase.h | 58 +- dtool/src/dtoolbase/memoryHook.I | 163 +- dtool/src/dtoolbase/memoryHook.cxx | 319 +- dtool/src/dtoolbase/memoryHook.h | 54 +- dtool/src/dtoolbase/mutexDummyImpl.I | 66 +- dtool/src/dtoolbase/mutexDummyImpl.cxx | 25 +- dtool/src/dtoolbase/mutexDummyImpl.h | 35 +- dtool/src/dtoolbase/mutexImpl.h | 35 +- dtool/src/dtoolbase/mutexPosixImpl.I | 122 +- dtool/src/dtoolbase/mutexPosixImpl.cxx | 25 +- dtool/src/dtoolbase/mutexPosixImpl.h | 39 +- dtool/src/dtoolbase/mutexSpinlockImpl.I | 66 +- dtool/src/dtoolbase/mutexSpinlockImpl.cxx | 33 +- dtool/src/dtoolbase/mutexSpinlockImpl.h | 40 +- dtool/src/dtoolbase/mutexWin32Impl.I | 58 +- dtool/src/dtoolbase/mutexWin32Impl.cxx | 33 +- dtool/src/dtoolbase/mutexWin32Impl.h | 32 +- dtool/src/dtoolbase/nearly_zero.h | 78 +- dtool/src/dtoolbase/neverFreeMemory.I | 103 +- dtool/src/dtoolbase/neverFreeMemory.cxx | 63 +- dtool/src/dtoolbase/neverFreeMemory.h | 49 +- dtool/src/dtoolbase/numeric_types.h | 31 +- dtool/src/dtoolbase/pallocator.h | 70 +- dtool/src/dtoolbase/pdeque.h | 39 +- dtool/src/dtoolbase/plist.h | 41 +- dtool/src/dtoolbase/pmap.h | 79 +- dtool/src/dtoolbase/pset.h | 77 +- dtool/src/dtoolbase/pstrtod.cxx | 71 +- dtool/src/dtoolbase/pstrtod.h | 25 +- dtool/src/dtoolbase/pvector.h | 37 +- dtool/src/dtoolbase/register_type.I | 56 +- dtool/src/dtoolbase/register_type.cxx | 25 +- dtool/src/dtoolbase/register_type.h | 69 +- dtool/src/dtoolbase/selectThreadImpl.h | 58 +- dtool/src/dtoolbase/stl_compares.I | 195 +- dtool/src/dtoolbase/stl_compares.h | 168 +- dtool/src/dtoolbase/test_strtod.cxx | 25 +- dtool/src/dtoolbase/typeHandle.I | 289 +- dtool/src/dtoolbase/typeHandle.cxx | 72 +- dtool/src/dtoolbase/typeHandle.h | 134 +- dtool/src/dtoolbase/typeRegistry.I | 71 +- dtool/src/dtoolbase/typeRegistry.cxx | 475 +- dtool/src/dtoolbase/typeRegistry.h | 52 +- dtool/src/dtoolbase/typeRegistryNode.I | 87 +- dtool/src/dtoolbase/typeRegistryNode.cxx | 262 +- dtool/src/dtoolbase/typeRegistryNode.h | 56 +- dtool/src/dtoolbase/typedObject.I | 108 +- dtool/src/dtoolbase/typedObject.cxx | 58 +- dtool/src/dtoolbase/typedObject.h | 161 +- dtool/src/dtoolbase/version.h | 24 +- dtool/src/dtoolutil/config_dtoolutil.cxx | 39 +- dtool/src/dtoolutil/config_dtoolutil.h | 25 +- dtool/src/dtoolutil/dSearchPath.I | 76 +- dtool/src/dtoolutil/dSearchPath.cxx | 295 +- dtool/src/dtoolutil/dSearchPath.h | 40 +- dtool/src/dtoolutil/executionEnvironment.I | 141 +- dtool/src/dtoolutil/executionEnvironment.cxx | 277 +- dtool/src/dtoolutil/executionEnvironment.h | 38 +- dtool/src/dtoolutil/filename.I | 633 +-- dtool/src/dtoolutil/filename.cxx | 1605 +++--- dtool/src/dtoolutil/filename.h | 71 +- dtool/src/dtoolutil/filename_assist.h | 25 +- dtool/src/dtoolutil/filename_assist.mm | 89 +- dtool/src/dtoolutil/globPattern.I | 151 +- dtool/src/dtoolutil/globPattern.cxx | 165 +- dtool/src/dtoolutil/globPattern.h | 51 +- dtool/src/dtoolutil/lineStream.I | 74 +- dtool/src/dtoolutil/lineStream.cxx | 25 +- dtool/src/dtoolutil/lineStream.h | 49 +- dtool/src/dtoolutil/lineStreamBuf.I | 53 +- dtool/src/dtoolutil/lineStreamBuf.cxx | 86 +- dtool/src/dtoolutil/lineStreamBuf.h | 37 +- dtool/src/dtoolutil/load_dso.cxx | 41 +- dtool/src/dtoolutil/load_dso.h | 33 +- dtool/src/dtoolutil/pandaFileStream.I | 254 +- dtool/src/dtoolutil/pandaFileStream.cxx | 26 +- dtool/src/dtoolutil/pandaFileStream.h | 71 +- dtool/src/dtoolutil/pandaFileStreamBuf.cxx | 367 +- dtool/src/dtoolutil/pandaFileStreamBuf.h | 33 +- dtool/src/dtoolutil/pandaSystem.cxx | 469 +- dtool/src/dtoolutil/pandaSystem.h | 39 +- dtool/src/dtoolutil/panda_getopt.h | 12 +- dtool/src/dtoolutil/panda_getopt_impl.cxx | 253 +- dtool/src/dtoolutil/panda_getopt_impl.h | 24 +- dtool/src/dtoolutil/panda_getopt_long.h | 12 +- dtool/src/dtoolutil/pfstream.I | 25 +- dtool/src/dtoolutil/pfstream.cxx | 25 +- dtool/src/dtoolutil/pfstream.h | 27 +- dtool/src/dtoolutil/pfstreamBuf.cxx | 250 +- dtool/src/dtoolutil/pfstreamBuf.h | 31 +- dtool/src/dtoolutil/preprocess_argv.cxx | 53 +- dtool/src/dtoolutil/preprocess_argv.h | 26 +- dtool/src/dtoolutil/stringDecoder.I | 71 +- dtool/src/dtoolutil/stringDecoder.cxx | 88 +- dtool/src/dtoolutil/stringDecoder.h | 54 +- dtool/src/dtoolutil/string_utils.I | 26 +- dtool/src/dtoolutil/string_utils.cxx | 254 +- dtool/src/dtoolutil/string_utils.h | 31 +- dtool/src/dtoolutil/test_pfstream.cxx | 29 +- dtool/src/dtoolutil/test_touch.cxx | 25 +- dtool/src/dtoolutil/textEncoder.I | 488 +- dtool/src/dtoolutil/textEncoder.cxx | 187 +- dtool/src/dtoolutil/textEncoder.h | 59 +- dtool/src/dtoolutil/unicodeLatinMap.cxx | 61 +- dtool/src/dtoolutil/unicodeLatinMap.h | 47 +- dtool/src/dtoolutil/vector_int.cxx | 25 +- dtool/src/dtoolutil/vector_int.h | 39 +- dtool/src/dtoolutil/vector_src.cxx | 70 +- dtool/src/dtoolutil/vector_src.h | 83 +- dtool/src/dtoolutil/vector_string.cxx | 25 +- dtool/src/dtoolutil/vector_string.h | 39 +- dtool/src/dtoolutil/win32ArgParser.cxx | 225 +- dtool/src/dtoolutil/win32ArgParser.h | 42 +- dtool/src/interrogate/functionRemap.cxx | 303 +- dtool/src/interrogate/functionRemap.h | 43 +- dtool/src/interrogate/functionWriter.cxx | 73 +- dtool/src/interrogate/functionWriter.h | 37 +- .../functionWriterPtrFromPython.cxx | 85 +- .../interrogate/functionWriterPtrFromPython.h | 37 +- .../interrogate/functionWriterPtrToPython.cxx | 70 +- .../interrogate/functionWriterPtrToPython.h | 35 +- dtool/src/interrogate/functionWriters.cxx | 76 +- dtool/src/interrogate/functionWriters.h | 37 +- dtool/src/interrogate/interfaceMaker.cxx | 492 +- dtool/src/interrogate/interfaceMaker.h | 71 +- dtool/src/interrogate/interfaceMakerC.cxx | 181 +- dtool/src/interrogate/interfaceMakerC.h | 37 +- .../src/interrogate/interfaceMakerPython.cxx | 55 +- dtool/src/interrogate/interfaceMakerPython.h | 37 +- .../interfaceMakerPythonNative.cxx | 1403 +++-- .../interrogate/interfaceMakerPythonNative.h | 40 +- .../interrogate/interfaceMakerPythonObj.cxx | 230 +- .../src/interrogate/interfaceMakerPythonObj.h | 35 +- .../interfaceMakerPythonSimple.cxx | 205 +- .../interrogate/interfaceMakerPythonSimple.h | 48 +- dtool/src/interrogate/interrogate.cxx | 68 +- dtool/src/interrogate/interrogate.h | 25 +- dtool/src/interrogate/interrogateBuilder.cxx | 928 ++-- dtool/src/interrogate/interrogateBuilder.h | 37 +- dtool/src/interrogate/interrogate_module.cxx | 53 +- dtool/src/interrogate/parameterRemap.I | 104 +- dtool/src/interrogate/parameterRemap.cxx | 159 +- dtool/src/interrogate/parameterRemap.h | 54 +- .../parameterRemapBasicStringPtrToString.cxx | 85 +- .../parameterRemapBasicStringPtrToString.h | 41 +- .../parameterRemapBasicStringRefToString.cxx | 85 +- .../parameterRemapBasicStringRefToString.h | 41 +- .../parameterRemapBasicStringToString.cxx | 115 +- .../parameterRemapBasicStringToString.h | 41 +- .../parameterRemapCharStarToString.cxx | 41 +- .../parameterRemapCharStarToString.h | 41 +- .../parameterRemapConcreteToPointer.cxx | 107 +- .../parameterRemapConcreteToPointer.h | 35 +- .../parameterRemapConstToNonConst.cxx | 55 +- .../parameterRemapConstToNonConst.h | 37 +- .../interrogate/parameterRemapEnumToInt.cxx | 65 +- .../src/interrogate/parameterRemapEnumToInt.h | 34 +- .../interrogate/parameterRemapHandleToInt.cxx | 55 +- .../interrogate/parameterRemapHandleToInt.h | 43 +- .../interrogate/parameterRemapPTToPointer.cxx | 85 +- .../interrogate/parameterRemapPTToPointer.h | 34 +- .../parameterRemapReferenceToConcrete.cxx | 56 +- .../parameterRemapReferenceToConcrete.h | 37 +- .../parameterRemapReferenceToPointer.cxx | 65 +- .../parameterRemapReferenceToPointer.h | 35 +- dtool/src/interrogate/parameterRemapThis.cxx | 63 +- dtool/src/interrogate/parameterRemapThis.h | 33 +- .../interrogate/parameterRemapToString.cxx | 115 +- .../src/interrogate/parameterRemapToString.h | 61 +- .../interrogate/parameterRemapUnchanged.cxx | 33 +- .../src/interrogate/parameterRemapUnchanged.h | 34 +- dtool/src/interrogate/parse_file.cxx | 28 +- dtool/src/interrogate/typeManager.cxx | 1066 ++-- dtool/src/interrogate/typeManager.h | 38 +- .../interrogatedb/config_interrogatedb.cxx | 45 +- .../src/interrogatedb/config_interrogatedb.h | 25 +- dtool/src/interrogatedb/dtool_super_base.cxx | 25 +- dtool/src/interrogatedb/extension.h | 64 +- dtool/src/interrogatedb/indexRemapper.cxx | 78 +- dtool/src/interrogatedb/indexRemapper.h | 44 +- .../src/interrogatedb/interrogateComponent.I | 133 +- .../interrogatedb/interrogateComponent.cxx | 46 +- .../src/interrogatedb/interrogateComponent.h | 37 +- dtool/src/interrogatedb/interrogateDatabase.I | 102 +- .../src/interrogatedb/interrogateDatabase.cxx | 705 +-- dtool/src/interrogatedb/interrogateDatabase.h | 41 +- dtool/src/interrogatedb/interrogateElement.I | 165 +- .../src/interrogatedb/interrogateElement.cxx | 54 +- dtool/src/interrogatedb/interrogateElement.h | 34 +- dtool/src/interrogatedb/interrogateFunction.I | 163 +- .../src/interrogatedb/interrogateFunction.cxx | 78 +- dtool/src/interrogatedb/interrogateFunction.h | 48 +- .../interrogateFunctionWrapper.I | 164 +- .../interrogateFunctionWrapper.cxx | 70 +- .../interrogateFunctionWrapper.h | 38 +- dtool/src/interrogatedb/interrogateMakeSeq.I | 98 +- .../src/interrogatedb/interrogateMakeSeq.cxx | 54 +- dtool/src/interrogatedb/interrogateMakeSeq.h | 33 +- dtool/src/interrogatedb/interrogateManifest.I | 106 +- .../src/interrogatedb/interrogateManifest.cxx | 54 +- dtool/src/interrogatedb/interrogateManifest.h | 32 +- dtool/src/interrogatedb/interrogateType.I | 486 +- dtool/src/interrogatedb/interrogateType.cxx | 125 +- dtool/src/interrogatedb/interrogateType.h | 48 +- .../src/interrogatedb/interrogate_datafile.I | 48 +- .../interrogatedb/interrogate_datafile.cxx | 63 +- .../src/interrogatedb/interrogate_datafile.h | 29 +- .../interrogatedb/interrogate_interface.cxx | 328 +- .../src/interrogatedb/interrogate_interface.h | 557 +- .../src/interrogatedb/interrogate_request.cxx | 25 +- dtool/src/interrogatedb/interrogate_request.h | 12 +- dtool/src/interrogatedb/py_panda.cxx | 381 +- dtool/src/interrogatedb/py_panda.h | 151 +- dtool/src/newheader/newheader.cxx | 29 +- dtool/src/parser-inc/Cg/cg.h | 25 +- dtool/src/parser-inc/Cg/cgGL.h | 25 +- dtool/src/parser-inc/Max.h | 25 +- dtool/src/parser-inc/NxBoxController.h | 25 +- dtool/src/parser-inc/NxCapsuleController.h | 25 +- dtool/src/parser-inc/NxController.h | 25 +- dtool/src/parser-inc/NxControllerManager.h | 25 +- dtool/src/parser-inc/NxCooking.h | 25 +- dtool/src/parser-inc/NxExtended.h | 25 +- dtool/src/parser-inc/NxPhysics.h | 25 +- dtool/src/parser-inc/NxStream.h | 25 +- dtool/src/parser-inc/Python.h | 25 +- .../parser-inc/Rocket/Core/RenderInterface.h | 25 +- dtool/src/parser-inc/files.h | 25 +- dtool/src/parser-inc/ft2build.h | 25 +- dtool/src/parser-inc/hex.h | 25 +- dtool/src/parser-inc/iparamb2.h | 25 +- dtool/src/parser-inc/iparamm2.h | 25 +- dtool/src/parser-inc/iskin.h | 25 +- dtool/src/parser-inc/istdplug.h | 25 +- dtool/src/parser-inc/krb5.h | 25 +- dtool/src/parser-inc/libtar.h | 25 +- dtool/src/parser-inc/malloc.h | 25 +- dtool/src/parser-inc/math.h | 25 +- dtool/src/parser-inc/mmsystem.h | 25 +- dtool/src/parser-inc/netinet/ip.h | 25 +- dtool/src/parser-inc/netinet/tcp.h | 25 +- dtool/src/parser-inc/nurbs.hh | 25 +- dtool/src/parser-inc/ode.h | 25 +- dtool/src/parser-inc/ode/ode.h | 28 +- dtool/src/parser-inc/openssl/md5.h | 25 +- dtool/src/parser-inc/phyexp.h | 25 +- dtool/src/parser-inc/pthread.h | 25 +- dtool/src/parser-inc/py_panda.h | 25 +- dtool/src/parser-inc/rfftw.h | 25 +- dtool/src/parser-inc/setjmp.h | 25 +- dtool/src/parser-inc/stdcompare.h | 25 +- dtool/src/parser-inc/stddef.h | 25 +- dtool/src/parser-inc/stdint.h | 25 +- dtool/src/parser-inc/stdmat.h | 25 +- dtool/src/parser-inc/stdtypedefs.h | 25 +- dtool/src/parser-inc/ucontext.h | 25 +- dtool/src/parser-inc/windows.h | 25 +- dtool/src/parser-inc/zlib.h | 25 +- dtool/src/prc/androidLogStream.cxx | 102 +- dtool/src/prc/androidLogStream.h | 33 +- dtool/src/prc/bigEndian.h | 37 +- dtool/src/prc/configDeclaration.I | 229 +- dtool/src/prc/configDeclaration.cxx | 190 +- dtool/src/prc/configDeclaration.h | 39 +- dtool/src/prc/configFlags.I | 73 +- dtool/src/prc/configFlags.cxx | 32 +- dtool/src/prc/configFlags.h | 52 +- dtool/src/prc/configPage.I | 171 +- dtool/src/prc/configPage.cxx | 303 +- dtool/src/prc/configPage.h | 43 +- dtool/src/prc/configPageManager.I | 210 +- dtool/src/prc/configPageManager.cxx | 299 +- dtool/src/prc/configPageManager.h | 43 +- dtool/src/prc/configVariable.I | 295 +- dtool/src/prc/configVariable.cxx | 38 +- dtool/src/prc/configVariable.h | 48 +- dtool/src/prc/configVariableBase.I | 206 +- dtool/src/prc/configVariableBase.cxx | 64 +- dtool/src/prc/configVariableBase.h | 55 +- dtool/src/prc/configVariableBool.I | 128 +- dtool/src/prc/configVariableBool.cxx | 25 +- dtool/src/prc/configVariableBool.h | 33 +- dtool/src/prc/configVariableCore.I | 272 +- dtool/src/prc/configVariableCore.cxx | 334 +- dtool/src/prc/configVariableCore.h | 44 +- dtool/src/prc/configVariableDouble.I | 128 +- dtool/src/prc/configVariableDouble.cxx | 33 +- dtool/src/prc/configVariableDouble.h | 38 +- dtool/src/prc/configVariableEnum.I | 151 +- dtool/src/prc/configVariableEnum.cxx | 25 +- dtool/src/prc/configVariableEnum.h | 57 +- dtool/src/prc/configVariableFilename.I | 244 +- dtool/src/prc/configVariableFilename.cxx | 34 +- dtool/src/prc/configVariableFilename.h | 44 +- dtool/src/prc/configVariableInt.I | 129 +- dtool/src/prc/configVariableInt.cxx | 33 +- dtool/src/prc/configVariableInt.h | 38 +- dtool/src/prc/configVariableInt64.I | 125 +- dtool/src/prc/configVariableInt64.cxx | 33 +- dtool/src/prc/configVariableInt64.h | 34 +- dtool/src/prc/configVariableList.I | 103 +- dtool/src/prc/configVariableList.cxx | 41 +- dtool/src/prc/configVariableList.h | 52 +- dtool/src/prc/configVariableManager.I | 43 +- dtool/src/prc/configVariableManager.cxx | 259 +- dtool/src/prc/configVariableManager.h | 46 +- dtool/src/prc/configVariableSearchPath.I | 255 +- dtool/src/prc/configVariableSearchPath.cxx | 36 +- dtool/src/prc/configVariableSearchPath.h | 72 +- dtool/src/prc/configVariableString.I | 158 +- dtool/src/prc/configVariableString.cxx | 25 +- dtool/src/prc/configVariableString.h | 36 +- dtool/src/prc/config_prc.cxx | 25 +- dtool/src/prc/config_prc.h | 26 +- dtool/src/prc/encryptStream.I | 191 +- dtool/src/prc/encryptStream.cxx | 25 +- dtool/src/prc/encryptStream.h | 73 +- dtool/src/prc/encryptStreamBuf.I | 129 +- dtool/src/prc/encryptStreamBuf.cxx | 159 +- dtool/src/prc/encryptStreamBuf.h | 35 +- dtool/src/prc/littleEndian.h | 37 +- dtool/src/prc/nativeNumericData.I | 85 +- dtool/src/prc/nativeNumericData.cxx | 26 +- dtool/src/prc/nativeNumericData.h | 64 +- dtool/src/prc/notify.cxx | 381 +- dtool/src/prc/notifyCategory.I | 193 +- dtool/src/prc/notifyCategory.cxx | 150 +- dtool/src/prc/notifyCategory.h | 52 +- dtool/src/prc/notifyCategoryProxy.I | 222 +- dtool/src/prc/notifyCategoryProxy.h | 137 +- dtool/src/prc/notifySeverity.cxx | 25 +- dtool/src/prc/notifySeverity.h | 25 +- dtool/src/prc/pnotify.I | 80 +- dtool/src/prc/pnotify.h | 97 +- dtool/src/prc/prcKeyRegistry.I | 26 +- dtool/src/prc/prcKeyRegistry.cxx | 123 +- dtool/src/prc/prcKeyRegistry.h | 49 +- dtool/src/prc/reversedNumericData.I | 78 +- dtool/src/prc/reversedNumericData.cxx | 34 +- dtool/src/prc/reversedNumericData.h | 68 +- dtool/src/prc/streamReader.I | 252 +- dtool/src/prc/streamReader.cxx | 117 +- dtool/src/prc/streamReader.h | 35 +- dtool/src/prc/streamWrapper.I | 166 +- dtool/src/prc/streamWrapper.cxx | 213 +- dtool/src/prc/streamWrapper.h | 85 +- dtool/src/prc/streamWriter.I | 336 +- dtool/src/prc/streamWriter.cxx | 34 +- dtool/src/prc/streamWriter.h | 40 +- dtool/src/prckeys/makePrcKey.cxx | 127 +- dtool/src/prckeys/signPrcFile_src.cxx | 109 +- dtool/src/pystub/pystub.cxx | 25 +- dtool/src/pystub/pystub.h | 52 +- .../src/test_interrogate/test_interrogate.cxx | 37 +- dtool/src/test_interrogate/test_lib.cxx | 25 +- dtool/src/test_interrogate/test_lib.h | 25 +- panda/metalibs/panda/panda.cxx | 29 +- panda/metalibs/panda/panda.h | 10 +- panda/metalibs/pandabullet/pandabullet.cxx | 30 +- panda/metalibs/pandabullet/pandabullet.h | 9 +- panda/metalibs/pandadx9/pandadx9.cxx | 38 +- panda/metalibs/pandadx9/pandadx9.h | 9 +- panda/metalibs/pandaegg/pandaegg.cxx | 29 +- panda/metalibs/pandaegg/pandaegg.h | 10 +- panda/metalibs/pandaegg/pandaeggnopg.cxx | 29 +- panda/metalibs/pandaexpress/pandaexpress.cxx | 15 +- panda/metalibs/pandafx/pandafx.cxx | 29 +- panda/metalibs/pandafx/pandafx.h | 9 +- panda/metalibs/pandagl/pandagl.cxx | 38 +- panda/metalibs/pandagl/pandagl.h | 10 +- panda/metalibs/pandagles/pandagles.cxx | 38 +- panda/metalibs/pandagles/pandagles.h | 10 +- panda/metalibs/pandagles2/pandagles2.cxx | 38 +- panda/metalibs/pandagles2/pandagles2.h | 10 +- panda/metalibs/pandaode/pandaode.cxx | 29 +- panda/metalibs/pandaode/pandaode.h | 9 +- panda/metalibs/pandaphysics/pandaphysics.cxx | 29 +- panda/metalibs/pandaphysics/pandaphysics.h | 9 +- panda/metalibs/pandaphysx/pandaphysx.cxx | 29 +- panda/metalibs/pandaphysx/pandaphysx.h | 9 +- panda/src/android/NativeIStream.java | 34 +- panda/src/android/PandaActivity.java | 37 +- panda/src/android/android_main.cxx | 40 +- panda/src/android/config_android.cxx | 56 +- panda/src/android/config_android.h | 25 +- panda/src/android/jni_NativeIStream.cxx | 55 +- panda/src/android/pnmFileTypeAndroid.cxx | 113 +- panda/src/android/pnmFileTypeAndroid.h | 35 +- .../src/android/pnmFileTypeAndroidReader.cxx | 89 +- panda/src/android/pview.cxx | 44 +- .../src/androiddisplay/androidGraphicsPipe.I | 26 +- .../androiddisplay/androidGraphicsPipe.cxx | 113 +- .../src/androiddisplay/androidGraphicsPipe.h | 40 +- .../androidGraphicsStateGuardian.I | 36 +- .../androidGraphicsStateGuardian.cxx | 167 +- .../androidGraphicsStateGuardian.h | 34 +- .../androiddisplay/androidGraphicsWindow.I | 26 +- .../androiddisplay/androidGraphicsWindow.cxx | 262 +- .../androiddisplay/androidGraphicsWindow.h | 33 +- .../androiddisplay/config_androiddisplay.cxx | 46 +- .../androiddisplay/config_androiddisplay.h | 29 +- panda/src/audio/audio.h | 25 +- panda/src/audio/audioLoadRequest.I | 90 +- panda/src/audio/audioLoadRequest.cxx | 33 +- panda/src/audio/audioLoadRequest.h | 47 +- panda/src/audio/audioManager.I | 26 +- panda/src/audio/audioManager.cxx | 229 +- panda/src/audio/audioManager.h | 189 +- panda/src/audio/audioSound.I | 26 +- panda/src/audio/audioSound.cxx | 132 +- panda/src/audio/audioSound.h | 125 +- panda/src/audio/config_audio.cxx | 65 +- panda/src/audio/config_audio.h | 33 +- panda/src/audio/filterProperties.I | 142 +- panda/src/audio/filterProperties.cxx | 56 +- panda/src/audio/filterProperties.h | 54 +- panda/src/audio/nullAudioManager.cxx | 251 +- panda/src/audio/nullAudioManager.h | 43 +- panda/src/audio/nullAudioSound.cxx | 61 +- panda/src/audio/nullAudioSound.h | 61 +- panda/src/audio/test_audio.cxx | 27 +- panda/src/audiotraits/config_fmodAudio.cxx | 49 +- panda/src/audiotraits/config_fmodAudio.h | 24 +- panda/src/audiotraits/config_milesAudio.cxx | 49 +- panda/src/audiotraits/config_milesAudio.h | 24 +- panda/src/audiotraits/config_openalAudio.cxx | 49 +- panda/src/audiotraits/config_openalAudio.h | 24 +- panda/src/audiotraits/fmodAudioManager.cxx | 442 +- panda/src/audiotraits/fmodAudioManager.h | 187 +- panda/src/audiotraits/fmodAudioSound.I | 33 +- panda/src/audiotraits/fmodAudioSound.cxx | 570 +-- panda/src/audiotraits/fmodAudioSound.h | 174 +- panda/src/audiotraits/globalMilesManager.I | 54 +- panda/src/audiotraits/globalMilesManager.cxx | 249 +- panda/src/audiotraits/globalMilesManager.h | 41 +- panda/src/audiotraits/milesAudioManager.cxx | 630 +-- panda/src/audiotraits/milesAudioManager.h | 48 +- panda/src/audiotraits/milesAudioSample.I | 33 +- panda/src/audiotraits/milesAudioSample.cxx | 356 +- panda/src/audiotraits/milesAudioSample.h | 53 +- panda/src/audiotraits/milesAudioSequence.I | 26 +- panda/src/audiotraits/milesAudioSequence.cxx | 200 +- panda/src/audiotraits/milesAudioSequence.h | 44 +- panda/src/audiotraits/milesAudioSound.I | 26 +- panda/src/audiotraits/milesAudioSound.cxx | 165 +- panda/src/audiotraits/milesAudioSound.h | 69 +- panda/src/audiotraits/milesAudioStream.I | 26 +- panda/src/audiotraits/milesAudioStream.cxx | 171 +- panda/src/audiotraits/milesAudioStream.h | 45 +- panda/src/audiotraits/openalAudioManager.cxx | 523 +- panda/src/audiotraits/openalAudioManager.h | 95 +- panda/src/audiotraits/openalAudioSound.I | 78 +- panda/src/audiotraits/openalAudioSound.cxx | 428 +- panda/src/audiotraits/openalAudioSound.h | 87 +- panda/src/awesomium/AwMouseAndKeyboard.cxx | 27 +- panda/src/awesomium/AwMouseAndKeyboard.h | 35 +- panda/src/awesomium/WebBrowserTexture.cxx | 225 +- panda/src/awesomium/WebBrowserTexture.h | 50 +- panda/src/awesomium/awWebCore.I | 28 +- panda/src/awesomium/awWebCore.cxx | 32 +- panda/src/awesomium/awWebCore.h | 33 +- panda/src/awesomium/awWebView.I | 26 +- panda/src/awesomium/awWebView.cxx | 32 +- panda/src/awesomium/awWebView.h | 45 +- panda/src/awesomium/awWebViewListener.I | 25 +- panda/src/awesomium/awWebViewListener.cxx | 25 +- panda/src/awesomium/awWebViewListener.h | 41 +- panda/src/awesomium/awesomium_includes.h | 25 +- panda/src/awesomium/config_awesomium.cxx | 41 +- panda/src/awesomium/config_awesomium.h | 25 +- panda/src/bullet/bulletAllHitsRayResult.I | 47 +- panda/src/bullet/bulletAllHitsRayResult.cxx | 150 +- panda/src/bullet/bulletAllHitsRayResult.h | 41 +- .../bulletBaseCharacterControllerNode.I | 27 +- .../bulletBaseCharacterControllerNode.cxx | 134 +- .../bulletBaseCharacterControllerNode.h | 36 +- panda/src/bullet/bulletBodyNode.I | 219 +- panda/src/bullet/bulletBodyNode.cxx | 456 +- panda/src/bullet/bulletBodyNode.h | 35 +- panda/src/bullet/bulletBoxShape.I | 51 +- panda/src/bullet/bulletBoxShape.cxx | 108 +- panda/src/bullet/bulletBoxShape.h | 34 +- panda/src/bullet/bulletCapsuleShape.I | 66 +- panda/src/bullet/bulletCapsuleShape.cxx | 42 +- panda/src/bullet/bulletCapsuleShape.h | 35 +- .../bullet/bulletCharacterControllerNode.I | 51 +- .../bullet/bulletCharacterControllerNode.cxx | 172 +- .../bullet/bulletCharacterControllerNode.h | 36 +- panda/src/bullet/bulletClosestHitRayResult.I | 37 +- .../src/bullet/bulletClosestHitRayResult.cxx | 126 +- panda/src/bullet/bulletClosestHitRayResult.h | 32 +- .../src/bullet/bulletClosestHitSweepResult.I | 37 +- .../bullet/bulletClosestHitSweepResult.cxx | 100 +- .../src/bullet/bulletClosestHitSweepResult.h | 34 +- panda/src/bullet/bulletConeShape.I | 66 +- panda/src/bullet/bulletConeShape.cxx | 42 +- panda/src/bullet/bulletConeShape.h | 35 +- panda/src/bullet/bulletConeTwistConstraint.I | 50 +- .../src/bullet/bulletConeTwistConstraint.cxx | 158 +- panda/src/bullet/bulletConeTwistConstraint.h | 37 +- panda/src/bullet/bulletConstraint.I | 72 +- panda/src/bullet/bulletConstraint.cxx | 90 +- panda/src/bullet/bulletConstraint.h | 35 +- panda/src/bullet/bulletContactCallbackData.I | 90 +- .../src/bullet/bulletContactCallbackData.cxx | 34 +- panda/src/bullet/bulletContactCallbackData.h | 37 +- panda/src/bullet/bulletContactCallbacks.h | 46 +- panda/src/bullet/bulletContactResult.I | 98 +- panda/src/bullet/bulletContactResult.cxx | 82 +- panda/src/bullet/bulletContactResult.h | 43 +- panda/src/bullet/bulletConvexHullShape.I | 50 +- panda/src/bullet/bulletConvexHullShape.cxx | 108 +- panda/src/bullet/bulletConvexHullShape.h | 34 +- .../src/bullet/bulletConvexPointCloudShape.I | 58 +- .../bullet/bulletConvexPointCloudShape.cxx | 50 +- .../src/bullet/bulletConvexPointCloudShape.h | 35 +- panda/src/bullet/bulletCylinderShape.I | 74 +- panda/src/bullet/bulletCylinderShape.cxx | 50 +- panda/src/bullet/bulletCylinderShape.h | 35 +- panda/src/bullet/bulletDebugNode.I | 66 +- panda/src/bullet/bulletDebugNode.cxx | 273 +- panda/src/bullet/bulletDebugNode.h | 47 +- panda/src/bullet/bulletFilterCallbackData.I | 66 +- panda/src/bullet/bulletFilterCallbackData.cxx | 26 +- panda/src/bullet/bulletFilterCallbackData.h | 37 +- panda/src/bullet/bulletGenericConstraint.I | 50 +- panda/src/bullet/bulletGenericConstraint.cxx | 116 +- panda/src/bullet/bulletGenericConstraint.h | 39 +- panda/src/bullet/bulletGhostNode.I | 51 +- panda/src/bullet/bulletGhostNode.cxx | 74 +- panda/src/bullet/bulletGhostNode.h | 36 +- panda/src/bullet/bulletHeightfieldShape.I | 50 +- panda/src/bullet/bulletHeightfieldShape.cxx | 52 +- panda/src/bullet/bulletHeightfieldShape.h | 35 +- panda/src/bullet/bulletHelper.I | 42 +- panda/src/bullet/bulletHelper.cxx | 93 +- panda/src/bullet/bulletHelper.h | 36 +- panda/src/bullet/bulletHingeConstraint.I | 50 +- panda/src/bullet/bulletHingeConstraint.cxx | 207 +- panda/src/bullet/bulletHingeConstraint.h | 42 +- panda/src/bullet/bulletManifoldPoint.I | 218 +- panda/src/bullet/bulletManifoldPoint.cxx | 152 +- panda/src/bullet/bulletManifoldPoint.h | 32 +- panda/src/bullet/bulletMinkowskiSumShape.I | 106 +- panda/src/bullet/bulletMinkowskiSumShape.cxx | 42 +- panda/src/bullet/bulletMinkowskiSumShape.h | 35 +- panda/src/bullet/bulletMultiSphereShape.I | 74 +- panda/src/bullet/bulletMultiSphereShape.cxx | 42 +- panda/src/bullet/bulletMultiSphereShape.h | 35 +- panda/src/bullet/bulletPersistentManifold.I | 34 +- panda/src/bullet/bulletPersistentManifold.cxx | 90 +- panda/src/bullet/bulletPersistentManifold.h | 32 +- panda/src/bullet/bulletPlaneShape.I | 66 +- panda/src/bullet/bulletPlaneShape.cxx | 93 +- panda/src/bullet/bulletPlaneShape.h | 34 +- panda/src/bullet/bulletRigidBodyNode.I | 67 +- panda/src/bullet/bulletRigidBodyNode.cxx | 500 +- panda/src/bullet/bulletRigidBodyNode.h | 39 +- panda/src/bullet/bulletRotationalLimitMotor.I | 175 +- .../src/bullet/bulletRotationalLimitMotor.cxx | 52 +- panda/src/bullet/bulletRotationalLimitMotor.h | 32 +- panda/src/bullet/bulletShape.I | 90 +- panda/src/bullet/bulletShape.cxx | 74 +- panda/src/bullet/bulletShape.h | 35 +- panda/src/bullet/bulletSliderConstraint.I | 50 +- panda/src/bullet/bulletSliderConstraint.cxx | 236 +- panda/src/bullet/bulletSliderConstraint.h | 37 +- panda/src/bullet/bulletSoftBodyConfig.I | 418 +- panda/src/bullet/bulletSoftBodyConfig.cxx | 74 +- panda/src/bullet/bulletSoftBodyConfig.h | 32 +- panda/src/bullet/bulletSoftBodyControl.I | 59 +- panda/src/bullet/bulletSoftBodyControl.cxx | 58 +- panda/src/bullet/bulletSoftBodyControl.h | 40 +- panda/src/bullet/bulletSoftBodyMaterial.I | 100 +- panda/src/bullet/bulletSoftBodyMaterial.cxx | 34 +- panda/src/bullet/bulletSoftBodyMaterial.h | 32 +- panda/src/bullet/bulletSoftBodyNode.I | 101 +- panda/src/bullet/bulletSoftBodyNode.cxx | 510 +- panda/src/bullet/bulletSoftBodyNode.h | 51 +- panda/src/bullet/bulletSoftBodyShape.I | 40 +- panda/src/bullet/bulletSoftBodyShape.cxx | 50 +- panda/src/bullet/bulletSoftBodyShape.h | 35 +- panda/src/bullet/bulletSoftBodyWorldInfo.I | 42 +- panda/src/bullet/bulletSoftBodyWorldInfo.cxx | 122 +- panda/src/bullet/bulletSoftBodyWorldInfo.h | 32 +- panda/src/bullet/bulletSphereShape.I | 58 +- panda/src/bullet/bulletSphereShape.cxx | 92 +- panda/src/bullet/bulletSphereShape.h | 34 +- panda/src/bullet/bulletSphericalConstraint.I | 34 +- .../src/bullet/bulletSphericalConstraint.cxx | 84 +- panda/src/bullet/bulletSphericalConstraint.h | 47 +- panda/src/bullet/bulletTickCallbackData.I | 42 +- panda/src/bullet/bulletTickCallbackData.cxx | 26 +- panda/src/bullet/bulletTickCallbackData.h | 35 +- .../bullet/bulletTranslationalLimitMotor.I | 167 +- .../bullet/bulletTranslationalLimitMotor.cxx | 52 +- .../bullet/bulletTranslationalLimitMotor.h | 32 +- panda/src/bullet/bulletTriangleMesh.I | 50 +- panda/src/bullet/bulletTriangleMesh.cxx | 152 +- panda/src/bullet/bulletTriangleMesh.h | 36 +- panda/src/bullet/bulletTriangleMeshShape.I | 66 +- panda/src/bullet/bulletTriangleMeshShape.cxx | 113 +- panda/src/bullet/bulletTriangleMeshShape.h | 34 +- panda/src/bullet/bulletVehicle.I | 160 +- panda/src/bullet/bulletVehicle.cxx | 165 +- panda/src/bullet/bulletVehicle.h | 49 +- panda/src/bullet/bulletWheel.I | 116 +- panda/src/bullet/bulletWheel.cxx | 456 +- panda/src/bullet/bulletWheel.h | 42 +- panda/src/bullet/bulletWorld.I | 188 +- panda/src/bullet/bulletWorld.cxx | 433 +- panda/src/bullet/bulletWorld.h | 37 +- panda/src/bullet/bullet_includes.h | 25 +- panda/src/bullet/bullet_utils.I | 27 +- panda/src/bullet/bullet_utils.cxx | 131 +- panda/src/bullet/bullet_utils.h | 27 +- panda/src/bullet/config_bullet.cxx | 40 +- panda/src/bullet/config_bullet.h | 25 +- panda/src/cftalk/cfChannel.I | 26 +- panda/src/cftalk/cfChannel.cxx | 69 +- panda/src/cftalk/cfChannel.h | 35 +- panda/src/cftalk/cfCommand.I | 58 +- panda/src/cftalk/cfCommand.cxx | 100 +- panda/src/cftalk/cfCommand.h | 49 +- panda/src/cftalk/config_cftalk.cxx | 39 +- panda/src/cftalk/config_cftalk.h | 25 +- panda/src/chan/animBundle.I | 69 +- panda/src/chan/animBundle.cxx | 116 +- panda/src/chan/animBundle.h | 36 +- panda/src/chan/animBundleNode.I | 65 +- panda/src/chan/animBundleNode.cxx | 115 +- panda/src/chan/animBundleNode.h | 38 +- panda/src/chan/animChannel.I | 184 +- panda/src/chan/animChannel.cxx | 35 +- panda/src/chan/animChannel.h | 46 +- panda/src/chan/animChannelBase.I | 66 +- panda/src/chan/animChannelBase.cxx | 67 +- panda/src/chan/animChannelBase.h | 48 +- panda/src/chan/animChannelFixed.I | 72 +- panda/src/chan/animChannelFixed.h | 42 +- panda/src/chan/animChannelMatrixDynamic.I | 46 +- panda/src/chan/animChannelMatrixDynamic.cxx | 234 +- panda/src/chan/animChannelMatrixDynamic.h | 54 +- panda/src/chan/animChannelMatrixFixed.I | 26 +- panda/src/chan/animChannelMatrixFixed.cxx | 179 +- panda/src/chan/animChannelMatrixFixed.h | 39 +- panda/src/chan/animChannelMatrixXfmTable.I | 85 +- panda/src/chan/animChannelMatrixXfmTable.cxx | 266 +- panda/src/chan/animChannelMatrixXfmTable.h | 43 +- panda/src/chan/animChannelScalarDynamic.I | 26 +- panda/src/chan/animChannelScalarDynamic.cxx | 165 +- panda/src/chan/animChannelScalarDynamic.h | 57 +- panda/src/chan/animChannelScalarTable.I | 53 +- panda/src/chan/animChannelScalarTable.cxx | 200 +- panda/src/chan/animChannelScalarTable.h | 37 +- panda/src/chan/animControl.I | 136 +- panda/src/chan/animControl.cxx | 173 +- panda/src/chan/animControl.h | 62 +- panda/src/chan/animControlCollection.I | 132 +- panda/src/chan/animControlCollection.cxx | 205 +- panda/src/chan/animControlCollection.h | 46 +- panda/src/chan/animGroup.I | 25 +- panda/src/chan/animGroup.cxx | 257 +- panda/src/chan/animGroup.h | 41 +- panda/src/chan/animPreloadTable.I | 78 +- panda/src/chan/animPreloadTable.cxx | 172 +- panda/src/chan/animPreloadTable.h | 44 +- panda/src/chan/auto_bind.cxx | 83 +- panda/src/chan/auto_bind.h | 42 +- panda/src/chan/bindAnimRequest.I | 26 +- panda/src/chan/bindAnimRequest.cxx | 42 +- panda/src/chan/bindAnimRequest.h | 45 +- panda/src/chan/config_chan.cxx | 72 +- panda/src/chan/config_chan.h | 25 +- panda/src/chan/movingPart.I | 115 +- panda/src/chan/movingPart.h | 38 +- panda/src/chan/movingPartBase.I | 77 +- panda/src/chan/movingPartBase.cxx | 256 +- panda/src/chan/movingPartBase.h | 70 +- panda/src/chan/movingPartMatrix.I | 51 +- panda/src/chan/movingPartMatrix.cxx | 174 +- panda/src/chan/movingPartMatrix.h | 36 +- panda/src/chan/movingPartScalar.I | 51 +- panda/src/chan/movingPartScalar.cxx | 99 +- panda/src/chan/movingPartScalar.h | 36 +- panda/src/chan/partBundle.I | 262 +- panda/src/chan/partBundle.cxx | 673 +-- panda/src/chan/partBundle.h | 92 +- panda/src/chan/partBundleHandle.I | 60 +- panda/src/chan/partBundleHandle.cxx | 25 +- panda/src/chan/partBundleHandle.h | 52 +- panda/src/chan/partBundleNode.I | 90 +- panda/src/chan/partBundleNode.cxx | 141 +- panda/src/chan/partBundleNode.h | 47 +- panda/src/chan/partGroup.I | 52 +- panda/src/chan/partGroup.cxx | 490 +- panda/src/chan/partGroup.h | 56 +- panda/src/chan/partSubset.I | 26 +- panda/src/chan/partSubset.cxx | 149 +- panda/src/chan/partSubset.h | 38 +- panda/src/chan/vector_PartGroupStar.cxx | 25 +- panda/src/chan/vector_PartGroupStar.h | 40 +- panda/src/char/character.I | 35 +- panda/src/char/character.cxx | 834 ++- panda/src/char/character.h | 59 +- panda/src/char/characterJoint.I | 35 +- panda/src/char/characterJoint.cxx | 403 +- panda/src/char/characterJoint.h | 53 +- panda/src/char/characterJointBundle.I | 49 +- panda/src/char/characterJointBundle.cxx | 115 +- panda/src/char/characterJointBundle.h | 35 +- panda/src/char/characterJointEffect.I | 47 +- panda/src/char/characterJointEffect.cxx | 269 +- panda/src/char/characterJointEffect.h | 48 +- panda/src/char/characterSlider.cxx | 112 +- panda/src/char/characterSlider.h | 43 +- panda/src/char/characterVertexSlider.I | 36 +- panda/src/char/characterVertexSlider.cxx | 117 +- panda/src/char/characterVertexSlider.h | 35 +- panda/src/char/config_char.cxx | 45 +- panda/src/char/config_char.h | 25 +- panda/src/char/jointVertexTransform.I | 43 +- panda/src/char/jointVertexTransform.cxx | 162 +- panda/src/char/jointVertexTransform.h | 49 +- panda/src/cocoadisplay/cocoaGraphicsPipe.I | 44 +- panda/src/cocoadisplay/cocoaGraphicsPipe.h | 42 +- panda/src/cocoadisplay/cocoaGraphicsPipe.mm | 166 +- .../cocoadisplay/cocoaGraphicsStateGuardian.I | 37 +- .../cocoadisplay/cocoaGraphicsStateGuardian.h | 34 +- .../cocoaGraphicsStateGuardian.mm | 137 +- panda/src/cocoadisplay/cocoaGraphicsWindow.I | 42 +- panda/src/cocoadisplay/cocoaGraphicsWindow.h | 34 +- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 507 +- panda/src/cocoadisplay/cocoaPandaApp.h | 29 +- panda/src/cocoadisplay/cocoaPandaApp.mm | 27 +- panda/src/cocoadisplay/cocoaPandaView.h | 25 +- panda/src/cocoadisplay/cocoaPandaView.mm | 40 +- panda/src/cocoadisplay/cocoaPandaWindow.h | 25 +- panda/src/cocoadisplay/cocoaPandaWindow.mm | 25 +- .../cocoadisplay/cocoaPandaWindowDelegate.h | 27 +- .../cocoadisplay/cocoaPandaWindowDelegate.mm | 29 +- panda/src/cocoadisplay/config_cocoadisplay.h | 25 +- panda/src/cocoadisplay/config_cocoadisplay.mm | 39 +- panda/src/collada/colladaBindMaterial.cxx | 63 +- panda/src/collada/colladaBindMaterial.h | 33 +- panda/src/collada/colladaInput.I | 41 +- panda/src/collada/colladaInput.cxx | 96 +- panda/src/collada/colladaInput.h | 32 +- panda/src/collada/colladaLoader.I | 26 +- panda/src/collada/colladaLoader.cxx | 128 +- panda/src/collada/colladaLoader.h | 34 +- panda/src/collada/colladaPrimitive.I | 49 +- panda/src/collada/colladaPrimitive.cxx | 137 +- panda/src/collada/colladaPrimitive.h | 34 +- panda/src/collada/config_collada.cxx | 40 +- panda/src/collada/config_collada.h | 25 +- panda/src/collada/load_collada_file.cxx | 38 +- panda/src/collada/load_collada_file.h | 37 +- panda/src/collada/loaderFileTypeDae.cxx | 80 +- panda/src/collada/loaderFileTypeDae.h | 33 +- panda/src/collada/pre_collada_include.h | 33 +- panda/src/collide/collisionBox.I | 300 +- panda/src/collide/collisionBox.cxx | 468 +- panda/src/collide/collisionBox.h | 32 +- panda/src/collide/collisionEntry.I | 429 +- panda/src/collide/collisionEntry.cxx | 198 +- panda/src/collide/collisionEntry.h | 55 +- panda/src/collide/collisionFloorMesh.I | 61 +- panda/src/collide/collisionFloorMesh.cxx | 191 +- panda/src/collide/collisionFloorMesh.h | 34 +- panda/src/collide/collisionGeom.I | 42 +- panda/src/collide/collisionGeom.cxx | 63 +- panda/src/collide/collisionGeom.h | 46 +- panda/src/collide/collisionHandler.I | 46 +- panda/src/collide/collisionHandler.cxx | 78 +- panda/src/collide/collisionHandler.h | 42 +- panda/src/collide/collisionHandlerEvent.I | 296 +- panda/src/collide/collisionHandlerEvent.cxx | 143 +- panda/src/collide/collisionHandlerEvent.h | 43 +- panda/src/collide/collisionHandlerFloor.I | 92 +- panda/src/collide/collisionHandlerFloor.cxx | 135 +- panda/src/collide/collisionHandlerFloor.h | 43 +- .../src/collide/collisionHandlerFluidPusher.I | 26 +- .../collide/collisionHandlerFluidPusher.cxx | 139 +- .../src/collide/collisionHandlerFluidPusher.h | 38 +- panda/src/collide/collisionHandlerGravity.I | 232 +- panda/src/collide/collisionHandlerGravity.cxx | 142 +- panda/src/collide/collisionHandlerGravity.h | 43 +- .../collide/collisionHandlerHighestEvent.cxx | 74 +- .../collide/collisionHandlerHighestEvent.h | 43 +- panda/src/collide/collisionHandlerPhysical.I | 103 +- .../src/collide/collisionHandlerPhysical.cxx | 156 +- panda/src/collide/collisionHandlerPhysical.h | 42 +- panda/src/collide/collisionHandlerPusher.I | 42 +- panda/src/collide/collisionHandlerPusher.cxx | 161 +- panda/src/collide/collisionHandlerPusher.h | 40 +- panda/src/collide/collisionHandlerQueue.cxx | 120 +- panda/src/collide/collisionHandlerQueue.h | 43 +- panda/src/collide/collisionInvSphere.I | 59 +- panda/src/collide/collisionInvSphere.cxx | 194 +- panda/src/collide/collisionInvSphere.h | 42 +- panda/src/collide/collisionLevelState.I | 201 +- panda/src/collide/collisionLevelState.cxx | 25 +- panda/src/collide/collisionLevelState.h | 68 +- panda/src/collide/collisionLevelStateBase.I | 178 +- panda/src/collide/collisionLevelStateBase.cxx | 87 +- panda/src/collide/collisionLevelStateBase.h | 48 +- panda/src/collide/collisionLine.I | 63 +- panda/src/collide/collisionLine.cxx | 112 +- panda/src/collide/collisionLine.h | 37 +- panda/src/collide/collisionNode.I | 187 +- panda/src/collide/collisionNode.cxx | 355 +- panda/src/collide/collisionNode.h | 48 +- panda/src/collide/collisionParabola.I | 100 +- panda/src/collide/collisionParabola.cxx | 192 +- panda/src/collide/collisionParabola.h | 45 +- panda/src/collide/collisionPlane.I | 101 +- panda/src/collide/collisionPlane.cxx | 269 +- panda/src/collide/collisionPlane.h | 34 +- panda/src/collide/collisionPolygon.I | 228 +- panda/src/collide/collisionPolygon.cxx | 627 +-- panda/src/collide/collisionPolygon.h | 36 +- panda/src/collide/collisionRay.I | 126 +- panda/src/collide/collisionRay.cxx | 159 +- panda/src/collide/collisionRay.h | 40 +- panda/src/collide/collisionRecorder.I | 26 +- panda/src/collide/collisionRecorder.cxx | 88 +- panda/src/collide/collisionRecorder.h | 38 +- panda/src/collide/collisionSegment.I | 132 +- panda/src/collide/collisionSegment.cxx | 167 +- panda/src/collide/collisionSegment.h | 46 +- panda/src/collide/collisionSolid.I | 181 +- panda/src/collide/collisionSolid.cxx | 405 +- panda/src/collide/collisionSolid.h | 51 +- panda/src/collide/collisionSphere.I | 108 +- panda/src/collide/collisionSphere.cxx | 352 +- panda/src/collide/collisionSphere.h | 34 +- panda/src/collide/collisionTraverser.I | 88 +- panda/src/collide/collisionTraverser.cxx | 572 +-- panda/src/collide/collisionTraverser.h | 52 +- panda/src/collide/collisionTube.I | 136 +- panda/src/collide/collisionTube.cxx | 464 +- panda/src/collide/collisionTube.h | 44 +- panda/src/collide/collisionVisualizer.I | 119 +- panda/src/collide/collisionVisualizer.cxx | 202 +- panda/src/collide/collisionVisualizer.h | 45 +- panda/src/collide/config_collide.cxx | 39 +- panda/src/collide/config_collide.h | 25 +- panda/src/collide/test_collide.cxx | 26 +- panda/src/cull/binCullHandler.I | 34 +- panda/src/cull/binCullHandler.cxx | 36 +- panda/src/cull/binCullHandler.h | 42 +- panda/src/cull/config_cull.cxx | 39 +- panda/src/cull/config_cull.h | 25 +- panda/src/cull/cullBinBackToFront.I | 52 +- panda/src/cull/cullBinBackToFront.cxx | 83 +- panda/src/cull/cullBinBackToFront.h | 50 +- panda/src/cull/cullBinFixed.I | 52 +- panda/src/cull/cullBinFixed.cxx | 83 +- panda/src/cull/cullBinFixed.h | 53 +- panda/src/cull/cullBinFrontToBack.I | 52 +- panda/src/cull/cullBinFrontToBack.cxx | 83 +- panda/src/cull/cullBinFrontToBack.h | 50 +- panda/src/cull/cullBinStateSorted.I | 56 +- panda/src/cull/cullBinStateSorted.cxx | 83 +- panda/src/cull/cullBinStateSorted.h | 55 +- panda/src/cull/cullBinUnsorted.I | 34 +- panda/src/cull/cullBinUnsorted.cxx | 69 +- panda/src/cull/cullBinUnsorted.h | 44 +- panda/src/cull/drawCullHandler.I | 34 +- panda/src/cull/drawCullHandler.cxx | 40 +- panda/src/cull/drawCullHandler.h | 45 +- panda/src/device/analogNode.I | 128 +- panda/src/device/analogNode.cxx | 78 +- panda/src/device/analogNode.h | 58 +- panda/src/device/buttonNode.I | 111 +- panda/src/device/buttonNode.cxx | 86 +- panda/src/device/buttonNode.h | 50 +- panda/src/device/clientAnalogDevice.I | 92 +- panda/src/device/clientAnalogDevice.cxx | 54 +- panda/src/device/clientAnalogDevice.h | 45 +- panda/src/device/clientBase.I | 84 +- panda/src/device/clientBase.cxx | 171 +- panda/src/device/clientBase.h | 44 +- panda/src/device/clientButtonDevice.I | 120 +- panda/src/device/clientButtonDevice.cxx | 94 +- panda/src/device/clientButtonDevice.h | 41 +- panda/src/device/clientDevice.I | 99 +- panda/src/device/clientDevice.cxx | 113 +- panda/src/device/clientDevice.h | 37 +- panda/src/device/clientDialDevice.I | 94 +- panda/src/device/clientDialDevice.cxx | 37 +- panda/src/device/clientDialDevice.h | 47 +- panda/src/device/clientTrackerDevice.I | 44 +- panda/src/device/clientTrackerDevice.cxx | 26 +- panda/src/device/clientTrackerDevice.h | 35 +- panda/src/device/config_device.cxx | 40 +- panda/src/device/config_device.h | 25 +- panda/src/device/dialNode.I | 71 +- panda/src/device/dialNode.cxx | 68 +- panda/src/device/dialNode.h | 49 +- panda/src/device/mouseAndKeyboard.cxx | 87 +- panda/src/device/mouseAndKeyboard.h | 62 +- panda/src/device/trackerData.I | 192 +- panda/src/device/trackerData.cxx | 33 +- panda/src/device/trackerData.h | 32 +- panda/src/device/trackerNode.I | 128 +- panda/src/device/trackerNode.cxx | 80 +- panda/src/device/trackerNode.h | 38 +- panda/src/device/virtualMouse.cxx | 116 +- panda/src/device/virtualMouse.h | 43 +- panda/src/dgraph/config_dgraph.cxx | 25 +- panda/src/dgraph/config_dgraph.h | 25 +- panda/src/dgraph/dataGraphTraverser.I | 44 +- panda/src/dgraph/dataGraphTraverser.cxx | 126 +- panda/src/dgraph/dataGraphTraverser.h | 39 +- panda/src/dgraph/dataNode.I | 68 +- panda/src/dgraph/dataNode.cxx | 233 +- panda/src/dgraph/dataNode.h | 88 +- panda/src/dgraph/dataNodeTransmit.I | 87 +- panda/src/dgraph/dataNodeTransmit.cxx | 96 +- panda/src/dgraph/dataNodeTransmit.h | 39 +- panda/src/display/callbackGraphicsWindow.I | 264 +- panda/src/display/callbackGraphicsWindow.cxx | 232 +- panda/src/display/callbackGraphicsWindow.h | 48 +- panda/src/display/config_display.cxx | 48 +- panda/src/display/config_display.h | 25 +- panda/src/display/displayInformation.cxx | 555 +- panda/src/display/displayInformation.h | 46 +- panda/src/display/displayRegion.I | 998 ++-- panda/src/display/displayRegion.cxx | 674 +-- panda/src/display/displayRegion.h | 75 +- .../display/displayRegionCullCallbackData.I | 46 +- .../display/displayRegionCullCallbackData.cxx | 63 +- .../display/displayRegionCullCallbackData.h | 35 +- .../display/displayRegionDrawCallbackData.I | 47 +- .../display/displayRegionDrawCallbackData.cxx | 75 +- .../display/displayRegionDrawCallbackData.h | 35 +- panda/src/display/displaySearchParameters.cxx | 89 +- panda/src/display/displaySearchParameters.h | 32 +- panda/src/display/drawableRegion.I | 288 +- panda/src/display/drawableRegion.cxx | 173 +- panda/src/display/drawableRegion.h | 56 +- panda/src/display/frameBufferProperties.I | 451 +- panda/src/display/frameBufferProperties.cxx | 316 +- panda/src/display/frameBufferProperties.h | 35 +- panda/src/display/get_x11.h | 41 +- panda/src/display/graphicsBuffer.I | 26 +- panda/src/display/graphicsBuffer.cxx | 138 +- panda/src/display/graphicsBuffer.h | 45 +- panda/src/display/graphicsDevice.I | 36 +- panda/src/display/graphicsDevice.cxx | 64 +- panda/src/display/graphicsDevice.h | 41 +- panda/src/display/graphicsEngine.I | 210 +- panda/src/display/graphicsEngine.cxx | 1351 ++--- panda/src/display/graphicsEngine.h | 177 +- panda/src/display/graphicsOutput.I | 949 ++-- panda/src/display/graphicsOutput.cxx | 1176 ++--- panda/src/display/graphicsOutput.h | 112 +- panda/src/display/graphicsPipe.I | 128 +- panda/src/display/graphicsPipe.cxx | 149 +- panda/src/display/graphicsPipe.h | 64 +- panda/src/display/graphicsPipeSelection.I | 65 +- panda/src/display/graphicsPipeSelection.cxx | 239 +- panda/src/display/graphicsPipeSelection.h | 40 +- panda/src/display/graphicsStateGuardian.I | 1155 ++--- panda/src/display/graphicsStateGuardian.cxx | 1867 +++---- panda/src/display/graphicsStateGuardian.h | 85 +- .../src/display/graphicsStateGuardian_ext.cxx | 35 +- panda/src/display/graphicsStateGuardian_ext.h | 35 +- panda/src/display/graphicsThreadingModel.I | 171 +- panda/src/display/graphicsThreadingModel.cxx | 98 +- panda/src/display/graphicsThreadingModel.h | 38 +- panda/src/display/graphicsWindow.I | 104 +- panda/src/display/graphicsWindow.cxx | 703 +-- panda/src/display/graphicsWindow.h | 54 +- panda/src/display/graphicsWindowInputDevice.I | 245 +- .../src/display/graphicsWindowInputDevice.cxx | 277 +- panda/src/display/graphicsWindowInputDevice.h | 48 +- panda/src/display/graphicsWindowProc.cxx | 46 +- panda/src/display/graphicsWindowProc.h | 36 +- .../display/graphicsWindowProcCallbackData.I | 105 +- .../graphicsWindowProcCallbackData.cxx | 63 +- .../display/graphicsWindowProcCallbackData.h | 36 +- panda/src/display/graphicsWindow_ext.cxx | 42 +- panda/src/display/graphicsWindow_ext.h | 35 +- panda/src/display/nativeWindowHandle.I | 90 +- panda/src/display/nativeWindowHandle.cxx | 144 +- panda/src/display/nativeWindowHandle.h | 58 +- panda/src/display/pStatGPUTimer.I | 53 +- panda/src/display/pStatGPUTimer.h | 49 +- panda/src/display/parasiteBuffer.I | 26 +- panda/src/display/parasiteBuffer.cxx | 192 +- panda/src/display/parasiteBuffer.h | 78 +- panda/src/display/post_x11_include.h | 28 +- panda/src/display/pre_x11_include.h | 27 +- .../src/display/pythonGraphicsWindowProc.cxx | 61 +- panda/src/display/pythonGraphicsWindowProc.h | 34 +- panda/src/display/renderBuffer.h | 45 +- panda/src/display/standardMunger.I | 46 +- panda/src/display/standardMunger.cxx | 202 +- panda/src/display/standardMunger.h | 38 +- panda/src/display/stereoDisplayRegion.I | 44 +- panda/src/display/stereoDisplayRegion.cxx | 265 +- panda/src/display/stereoDisplayRegion.h | 51 +- panda/src/display/subprocessWindow.I | 26 +- panda/src/display/subprocessWindow.cxx | 263 +- panda/src/display/subprocessWindow.h | 56 +- panda/src/display/subprocessWindowBuffer.I | 161 +- panda/src/display/subprocessWindowBuffer.cxx | 164 +- panda/src/display/subprocessWindowBuffer.h | 79 +- panda/src/display/test_display.cxx | 25 +- panda/src/display/touchInfo.cxx | 25 +- panda/src/display/touchInfo.h | 34 +- panda/src/display/windowHandle.I | 75 +- panda/src/display/windowHandle.cxx | 134 +- panda/src/display/windowHandle.h | 61 +- panda/src/display/windowProperties.I | 761 ++- panda/src/display/windowProperties.cxx | 182 +- panda/src/display/windowProperties.h | 47 +- panda/src/distort/config_distort.cxx | 39 +- panda/src/distort/config_distort.h | 25 +- panda/src/distort/cylindricalLens.I | 50 +- panda/src/distort/cylindricalLens.cxx | 211 +- panda/src/distort/cylindricalLens.h | 61 +- panda/src/distort/fisheyeLens.I | 50 +- panda/src/distort/fisheyeLens.cxx | 246 +- panda/src/distort/fisheyeLens.h | 44 +- panda/src/distort/nonlinearImager.I | 26 +- panda/src/distort/nonlinearImager.cxx | 464 +- panda/src/distort/nonlinearImager.h | 125 +- panda/src/distort/oSphereLens.I | 50 +- panda/src/distort/oSphereLens.cxx | 167 +- panda/src/distort/oSphereLens.h | 50 +- panda/src/distort/pSphereLens.I | 50 +- panda/src/distort/pSphereLens.cxx | 168 +- panda/src/distort/pSphereLens.h | 57 +- panda/src/distort/projectionScreen.I | 303 +- panda/src/distort/projectionScreen.cxx | 504 +- panda/src/distort/projectionScreen.h | 69 +- panda/src/doc/sampleClass.I | 65 +- panda/src/doc/sampleClass.cxx | 61 +- panda/src/doc/sampleClass.h | 69 +- panda/src/downloader/bioPtr.I | 92 +- panda/src/downloader/bioPtr.cxx | 56 +- panda/src/downloader/bioPtr.h | 44 +- panda/src/downloader/bioStream.I | 98 +- panda/src/downloader/bioStream.cxx | 106 +- panda/src/downloader/bioStream.h | 68 +- panda/src/downloader/bioStreamBuf.cxx | 160 +- panda/src/downloader/bioStreamBuf.h | 33 +- panda/src/downloader/bioStreamPtr.I | 74 +- panda/src/downloader/bioStreamPtr.cxx | 33 +- panda/src/downloader/bioStreamPtr.h | 36 +- panda/src/downloader/chunkedStream.I | 50 +- panda/src/downloader/chunkedStream.cxx | 64 +- panda/src/downloader/chunkedStream.h | 44 +- panda/src/downloader/chunkedStreamBuf.I | 42 +- panda/src/downloader/chunkedStreamBuf.cxx | 118 +- panda/src/downloader/chunkedStreamBuf.h | 33 +- panda/src/downloader/config_downloader.cxx | 43 +- panda/src/downloader/config_downloader.h | 25 +- panda/src/downloader/decompressor.I | 25 +- panda/src/downloader/decompressor.cxx | 123 +- panda/src/downloader/decompressor.h | 35 +- panda/src/downloader/documentSpec.I | 323 +- panda/src/downloader/documentSpec.cxx | 64 +- panda/src/downloader/documentSpec.h | 43 +- panda/src/downloader/downloadDb.I | 162 +- panda/src/downloader/downloadDb.cxx | 618 +-- panda/src/downloader/downloadDb.h | 60 +- panda/src/downloader/download_utils.cxx | 25 +- panda/src/downloader/download_utils.h | 26 +- panda/src/downloader/extractor.I | 25 +- panda/src/downloader/extractor.cxx | 178 +- panda/src/downloader/extractor.h | 54 +- panda/src/downloader/httpAuthorization.I | 52 +- panda/src/downloader/httpAuthorization.cxx | 153 +- panda/src/downloader/httpAuthorization.h | 48 +- panda/src/downloader/httpBasicAuthorization.I | 25 +- .../src/downloader/httpBasicAuthorization.cxx | 68 +- panda/src/downloader/httpBasicAuthorization.h | 46 +- panda/src/downloader/httpChannel.I | 1113 ++-- panda/src/downloader/httpChannel.cxx | 1897 +++---- panda/src/downloader/httpChannel.h | 106 +- panda/src/downloader/httpClient.I | 203 +- panda/src/downloader/httpClient.cxx | 1004 ++-- panda/src/downloader/httpClient.h | 66 +- panda/src/downloader/httpCookie.I | 203 +- panda/src/downloader/httpCookie.cxx | 119 +- panda/src/downloader/httpCookie.h | 42 +- panda/src/downloader/httpDate.I | 171 +- panda/src/downloader/httpDate.cxx | 140 +- panda/src/downloader/httpDate.h | 39 +- .../src/downloader/httpDigestAuthorization.I | 37 +- .../downloader/httpDigestAuthorization.cxx | 165 +- .../src/downloader/httpDigestAuthorization.h | 48 +- panda/src/downloader/httpEntityTag.I | 154 +- panda/src/downloader/httpEntityTag.cxx | 49 +- panda/src/downloader/httpEntityTag.h | 37 +- panda/src/downloader/httpEnum.cxx | 32 +- panda/src/downloader/httpEnum.h | 43 +- panda/src/downloader/identityStream.I | 56 +- panda/src/downloader/identityStream.cxx | 66 +- panda/src/downloader/identityStream.h | 52 +- panda/src/downloader/identityStreamBuf.I | 42 +- panda/src/downloader/identityStreamBuf.cxx | 87 +- panda/src/downloader/identityStreamBuf.h | 33 +- panda/src/downloader/multiplexStream.I | 99 +- panda/src/downloader/multiplexStream.cxx | 26 +- panda/src/downloader/multiplexStream.h | 40 +- panda/src/downloader/multiplexStreamBuf.I | 26 +- panda/src/downloader/multiplexStreamBuf.cxx | 147 +- panda/src/downloader/multiplexStreamBuf.h | 35 +- panda/src/downloader/patcher.I | 33 +- panda/src/downloader/patcher.cxx | 73 +- panda/src/downloader/patcher.h | 32 +- panda/src/downloader/socketStream.I | 263 +- panda/src/downloader/socketStream.cxx | 164 +- panda/src/downloader/socketStream.h | 97 +- panda/src/downloader/stringStream.I | 87 +- panda/src/downloader/stringStream.cxx | 34 +- panda/src/downloader/stringStream.h | 37 +- panda/src/downloader/stringStreamBuf.I | 47 +- panda/src/downloader/stringStreamBuf.cxx | 149 +- panda/src/downloader/stringStreamBuf.h | 37 +- panda/src/downloader/stringStream_ext.cxx | 50 +- panda/src/downloader/stringStream_ext.h | 35 +- panda/src/downloader/urlSpec.I | 274 +- panda/src/downloader/urlSpec.cxx | 346 +- panda/src/downloader/urlSpec.h | 40 +- panda/src/downloader/virtualFileHTTP.I | 38 +- panda/src/downloader/virtualFileHTTP.cxx | 220 +- panda/src/downloader/virtualFileHTTP.h | 37 +- panda/src/downloader/virtualFileMountHTTP.I | 44 +- panda/src/downloader/virtualFileMountHTTP.cxx | 237 +- panda/src/downloader/virtualFileMountHTTP.h | 37 +- panda/src/downloadertools/apply_patch.cxx | 23 +- panda/src/downloadertools/build_patch.cxx | 27 +- panda/src/downloadertools/check_adler.cxx | 23 +- panda/src/downloadertools/check_crc.cxx | 23 +- panda/src/downloadertools/check_md5.cxx | 35 +- panda/src/downloadertools/multify.cxx | 102 +- panda/src/downloadertools/pdecrypt.cxx | 39 +- panda/src/downloadertools/pencrypt.cxx | 35 +- panda/src/downloadertools/punzip.cxx | 33 +- panda/src/downloadertools/pzip.cxx | 33 +- panda/src/downloadertools/show_ddb.cxx | 25 +- panda/src/dxgsg9/config_dxgsg9.cxx | 120 +- panda/src/dxgsg9/config_dxgsg9.h | 25 +- panda/src/dxgsg9/dxGeomMunger9.I | 39 +- panda/src/dxgsg9/dxGeomMunger9.cxx | 182 +- panda/src/dxgsg9/dxGeomMunger9.h | 49 +- panda/src/dxgsg9/dxGraphicsDevice9.cxx | 41 +- panda/src/dxgsg9/dxGraphicsDevice9.h | 35 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.I | 132 +- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 1759 +++---- panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 42 +- panda/src/dxgsg9/dxIndexBufferContext9.I | 25 +- panda/src/dxgsg9/dxIndexBufferContext9.cxx | 102 +- panda/src/dxgsg9/dxIndexBufferContext9.h | 33 +- panda/src/dxgsg9/dxInput9.cxx | 81 +- panda/src/dxgsg9/dxInput9.h | 30 +- panda/src/dxgsg9/dxOcclusionQueryContext9.I | 34 +- panda/src/dxgsg9/dxOcclusionQueryContext9.cxx | 84 +- panda/src/dxgsg9/dxOcclusionQueryContext9.h | 32 +- panda/src/dxgsg9/dxShaderContext9.I | 41 +- panda/src/dxgsg9/dxShaderContext9.cxx | 262 +- panda/src/dxgsg9/dxShaderContext9.h | 70 +- panda/src/dxgsg9/dxTextureContext9.I | 75 +- panda/src/dxgsg9/dxTextureContext9.cxx | 425 +- panda/src/dxgsg9/dxTextureContext9.h | 34 +- panda/src/dxgsg9/dxVertexBufferContext9.I | 25 +- panda/src/dxgsg9/dxVertexBufferContext9.cxx | 67 +- panda/src/dxgsg9/dxVertexBufferContext9.h | 33 +- panda/src/dxgsg9/dxgsg9base.h | 42 +- panda/src/dxgsg9/vertexElementArray.cxx | 26 +- panda/src/dxgsg9/vertexElementArray.h | 50 +- panda/src/dxgsg9/wdxGraphicsBuffer9.I | 40 +- panda/src/dxgsg9/wdxGraphicsBuffer9.cxx | 231 +- panda/src/dxgsg9/wdxGraphicsBuffer9.h | 46 +- panda/src/dxgsg9/wdxGraphicsPipe9.I | 25 +- panda/src/dxgsg9/wdxGraphicsPipe9.cxx | 261 +- panda/src/dxgsg9/wdxGraphicsPipe9.h | 36 +- panda/src/dxgsg9/wdxGraphicsWindow9.I | 26 +- panda/src/dxgsg9/wdxGraphicsWindow9.cxx | 464 +- panda/src/dxgsg9/wdxGraphicsWindow9.h | 33 +- panda/src/dxml/config_dxml.cxx | 25 +- panda/src/dxml/config_dxml.h | 25 +- panda/src/egg/config_egg.cxx | 39 +- panda/src/egg/config_egg.h | 25 +- panda/src/egg/eggAnimData.I | 122 +- panda/src/egg/eggAnimData.cxx | 34 +- panda/src/egg/eggAnimData.h | 34 +- panda/src/egg/eggAnimPreload.I | 116 +- panda/src/egg/eggAnimPreload.cxx | 35 +- panda/src/egg/eggAnimPreload.h | 33 +- panda/src/egg/eggAttributes.I | 149 +- panda/src/egg/eggAttributes.cxx | 99 +- panda/src/egg/eggAttributes.h | 45 +- panda/src/egg/eggBin.cxx | 65 +- panda/src/egg/eggBin.h | 38 +- panda/src/egg/eggBinMaker.cxx | 207 +- panda/src/egg/eggBinMaker.h | 361 +- panda/src/egg/eggComment.I | 83 +- panda/src/egg/eggComment.cxx | 34 +- panda/src/egg/eggComment.h | 37 +- panda/src/egg/eggCompositePrimitive.I | 108 +- panda/src/egg/eggCompositePrimitive.cxx | 303 +- panda/src/egg/eggCompositePrimitive.h | 37 +- panda/src/egg/eggCoordinateSystem.I | 60 +- panda/src/egg/eggCoordinateSystem.cxx | 35 +- panda/src/egg/eggCoordinateSystem.h | 37 +- panda/src/egg/eggCurve.I | 95 +- panda/src/egg/eggCurve.cxx | 45 +- panda/src/egg/eggCurve.h | 33 +- panda/src/egg/eggData.I | 231 +- panda/src/egg/eggData.cxx | 266 +- panda/src/egg/eggData.h | 48 +- panda/src/egg/eggExternalReference.I | 26 +- panda/src/egg/eggExternalReference.cxx | 66 +- panda/src/egg/eggExternalReference.h | 34 +- panda/src/egg/eggFilenameNode.I | 108 +- panda/src/egg/eggFilenameNode.cxx | 33 +- panda/src/egg/eggFilenameNode.h | 37 +- panda/src/egg/eggGroup.I | 900 ++-- panda/src/egg/eggGroup.cxx | 828 ++- panda/src/egg/eggGroup.h | 49 +- panda/src/egg/eggGroupNode.I | 42 +- panda/src/egg/eggGroupNode.cxx | 1158 ++--- panda/src/egg/eggGroupNode.h | 86 +- panda/src/egg/eggGroupNode_ext.cxx | 33 +- panda/src/egg/eggGroupNode_ext.h | 35 +- panda/src/egg/eggGroupUniquifier.cxx | 88 +- panda/src/egg/eggGroupUniquifier.h | 39 +- panda/src/egg/eggLine.I | 88 +- panda/src/egg/eggLine.cxx | 57 +- panda/src/egg/eggLine.h | 34 +- panda/src/egg/eggMaterial.I | 378 +- panda/src/egg/eggMaterial.cxx | 95 +- panda/src/egg/eggMaterial.h | 44 +- panda/src/egg/eggMaterialCollection.I | 25 +- panda/src/egg/eggMaterialCollection.cxx | 323 +- panda/src/egg/eggMaterialCollection.h | 55 +- panda/src/egg/eggMesher.I | 26 +- panda/src/egg/eggMesher.cxx | 354 +- panda/src/egg/eggMesher.h | 38 +- panda/src/egg/eggMesherEdge.I | 124 +- panda/src/egg/eggMesherEdge.cxx | 49 +- panda/src/egg/eggMesherEdge.h | 37 +- panda/src/egg/eggMesherFanMaker.I | 84 +- panda/src/egg/eggMesherFanMaker.cxx | 187 +- panda/src/egg/eggMesherFanMaker.h | 37 +- panda/src/egg/eggMesherStrip.I | 134 +- panda/src/egg/eggMesherStrip.cxx | 676 ++- panda/src/egg/eggMesherStrip.h | 51 +- panda/src/egg/eggMiscFuncs.I | 26 +- panda/src/egg/eggMiscFuncs.cxx | 57 +- panda/src/egg/eggMiscFuncs.h | 66 +- panda/src/egg/eggMorph.I | 93 +- panda/src/egg/eggMorph.h | 43 +- panda/src/egg/eggMorphList.I | 179 +- panda/src/egg/eggMorphList.cxx | 25 +- panda/src/egg/eggMorphList.h | 32 +- panda/src/egg/eggNameUniquifier.cxx | 124 +- panda/src/egg/eggNameUniquifier.h | 121 +- panda/src/egg/eggNamedObject.I | 50 +- panda/src/egg/eggNamedObject.cxx | 48 +- panda/src/egg/eggNamedObject.h | 33 +- panda/src/egg/eggNode.I | 321 +- panda/src/egg/eggNode.cxx | 400 +- panda/src/egg/eggNode.h | 41 +- panda/src/egg/eggNurbsCurve.I | 134 +- panda/src/egg/eggNurbsCurve.cxx | 103 +- panda/src/egg/eggNurbsCurve.h | 32 +- panda/src/egg/eggNurbsSurface.I | 305 +- panda/src/egg/eggNurbsSurface.cxx | 149 +- panda/src/egg/eggNurbsSurface.h | 32 +- panda/src/egg/eggObject.I | 26 +- panda/src/egg/eggObject.cxx | 166 +- panda/src/egg/eggObject.h | 34 +- panda/src/egg/eggParameters.cxx | 41 +- panda/src/egg/eggParameters.h | 71 +- panda/src/egg/eggPatch.I | 50 +- panda/src/egg/eggPatch.cxx | 34 +- panda/src/egg/eggPatch.h | 34 +- panda/src/egg/eggPoint.I | 123 +- panda/src/egg/eggPoint.cxx | 53 +- panda/src/egg/eggPoint.h | 34 +- panda/src/egg/eggPolygon.I | 95 +- panda/src/egg/eggPolygon.cxx | 183 +- panda/src/egg/eggPolygon.h | 32 +- panda/src/egg/eggPolysetMaker.cxx | 65 +- panda/src/egg/eggPolysetMaker.h | 49 +- panda/src/egg/eggPoolUniquifier.cxx | 44 +- panda/src/egg/eggPoolUniquifier.h | 40 +- panda/src/egg/eggPrimitive.I | 414 +- panda/src/egg/eggPrimitive.cxx | 786 ++- panda/src/egg/eggPrimitive.h | 72 +- panda/src/egg/eggRenderMode.I | 287 +- panda/src/egg/eggRenderMode.cxx | 154 +- panda/src/egg/eggRenderMode.h | 52 +- panda/src/egg/eggSAnimData.I | 82 +- panda/src/egg/eggSAnimData.cxx | 57 +- panda/src/egg/eggSAnimData.h | 36 +- panda/src/egg/eggSurface.I | 104 +- panda/src/egg/eggSurface.cxx | 26 +- panda/src/egg/eggSurface.h | 33 +- panda/src/egg/eggSwitchCondition.cxx | 59 +- panda/src/egg/eggSwitchCondition.h | 52 +- panda/src/egg/eggTable.I | 66 +- panda/src/egg/eggTable.cxx | 120 +- panda/src/egg/eggTable.h | 41 +- panda/src/egg/eggTexture.I | 1122 ++-- panda/src/egg/eggTexture.cxx | 458 +- panda/src/egg/eggTexture.h | 64 +- panda/src/egg/eggTextureCollection.I | 66 +- panda/src/egg/eggTextureCollection.cxx | 411 +- panda/src/egg/eggTextureCollection.h | 55 +- panda/src/egg/eggTransform.I | 290 +- panda/src/egg/eggTransform.cxx | 221 +- panda/src/egg/eggTransform.h | 50 +- panda/src/egg/eggTriangleFan.I | 50 +- panda/src/egg/eggTriangleFan.cxx | 107 +- panda/src/egg/eggTriangleFan.h | 35 +- panda/src/egg/eggTriangleStrip.I | 50 +- panda/src/egg/eggTriangleStrip.cxx | 80 +- panda/src/egg/eggTriangleStrip.h | 35 +- panda/src/egg/eggUserData.I | 50 +- panda/src/egg/eggUserData.cxx | 33 +- panda/src/egg/eggUserData.h | 46 +- panda/src/egg/eggUtilities.I | 95 +- panda/src/egg/eggUtilities.cxx | 41 +- panda/src/egg/eggUtilities.h | 60 +- panda/src/egg/eggVertex.I | 418 +- panda/src/egg/eggVertex.cxx | 586 +-- panda/src/egg/eggVertex.h | 64 +- panda/src/egg/eggVertexAux.I | 50 +- panda/src/egg/eggVertexAux.cxx | 87 +- panda/src/egg/eggVertexAux.h | 40 +- panda/src/egg/eggVertexPool.I | 131 +- panda/src/egg/eggVertexPool.cxx | 494 +- panda/src/egg/eggVertexPool.h | 88 +- panda/src/egg/eggVertexUV.I | 177 +- panda/src/egg/eggVertexUV.cxx | 106 +- panda/src/egg/eggVertexUV.h | 38 +- panda/src/egg/eggXfmAnimData.I | 175 +- panda/src/egg/eggXfmAnimData.cxx | 116 +- panda/src/egg/eggXfmAnimData.h | 40 +- panda/src/egg/eggXfmSAnim.I | 153 +- panda/src/egg/eggXfmSAnim.cxx | 360 +- panda/src/egg/eggXfmSAnim.h | 43 +- panda/src/egg/lexer.lxx | 11 +- panda/src/egg/lexerDefs.h | 25 +- panda/src/egg/parser.yxx | 9 +- panda/src/egg/parserDefs.h | 40 +- panda/src/egg/pt_EggMaterial.cxx | 25 +- panda/src/egg/pt_EggMaterial.h | 35 +- panda/src/egg/pt_EggTexture.cxx | 25 +- panda/src/egg/pt_EggTexture.h | 35 +- panda/src/egg/pt_EggVertex.cxx | 25 +- panda/src/egg/pt_EggVertex.h | 35 +- panda/src/egg/test_egg.cxx | 26 +- panda/src/egg/vector_PT_EggMaterial.cxx | 25 +- panda/src/egg/vector_PT_EggMaterial.h | 39 +- panda/src/egg/vector_PT_EggTexture.cxx | 25 +- panda/src/egg/vector_PT_EggTexture.h | 39 +- panda/src/egg/vector_PT_EggVertex.cxx | 25 +- panda/src/egg/vector_PT_EggVertex.h | 39 +- panda/src/egg2pg/animBundleMaker.cxx | 121 +- panda/src/egg2pg/animBundleMaker.h | 34 +- panda/src/egg2pg/characterMaker.cxx | 380 +- panda/src/egg2pg/characterMaker.h | 37 +- panda/src/egg2pg/config_egg2pg.cxx | 47 +- panda/src/egg2pg/config_egg2pg.h | 25 +- panda/src/egg2pg/deferredNodeProperty.cxx | 68 +- panda/src/egg2pg/deferredNodeProperty.h | 46 +- panda/src/egg2pg/eggBinner.cxx | 86 +- panda/src/egg2pg/eggBinner.h | 45 +- panda/src/egg2pg/eggLoader.I | 42 +- panda/src/egg2pg/eggLoader.cxx | 1240 ++--- panda/src/egg2pg/eggLoader.h | 65 +- panda/src/egg2pg/eggRenderState.I | 44 +- panda/src/egg2pg/eggRenderState.cxx | 204 +- panda/src/egg2pg/eggRenderState.h | 40 +- panda/src/egg2pg/eggSaver.I | 35 +- panda/src/egg2pg/eggSaver.cxx | 327 +- panda/src/egg2pg/eggSaver.h | 45 +- panda/src/egg2pg/egg_parametrics.cxx | 55 +- panda/src/egg2pg/egg_parametrics.h | 55 +- panda/src/egg2pg/load_egg_file.cxx | 56 +- panda/src/egg2pg/load_egg_file.h | 55 +- panda/src/egg2pg/loaderFileTypeEgg.cxx | 102 +- panda/src/egg2pg/loaderFileTypeEgg.h | 33 +- panda/src/egg2pg/save_egg_file.cxx | 44 +- panda/src/egg2pg/save_egg_file.h | 44 +- panda/src/egldisplay/config_egldisplay.cxx | 46 +- panda/src/egldisplay/config_egldisplay.h | 29 +- panda/src/egldisplay/eglGraphicsBuffer.cxx | 114 +- panda/src/egldisplay/eglGraphicsBuffer.h | 35 +- panda/src/egldisplay/eglGraphicsPipe.I | 74 +- panda/src/egldisplay/eglGraphicsPipe.cxx | 201 +- panda/src/egldisplay/eglGraphicsPipe.h | 39 +- panda/src/egldisplay/eglGraphicsPixmap.cxx | 110 +- panda/src/egldisplay/eglGraphicsPixmap.h | 37 +- .../src/egldisplay/eglGraphicsStateGuardian.I | 37 +- .../egldisplay/eglGraphicsStateGuardian.cxx | 156 +- .../src/egldisplay/eglGraphicsStateGuardian.h | 34 +- panda/src/egldisplay/eglGraphicsWindow.I | 34 +- panda/src/egldisplay/eglGraphicsWindow.cxx | 488 +- panda/src/egldisplay/eglGraphicsWindow.h | 33 +- panda/src/event/asyncTask.I | 259 +- panda/src/event/asyncTask.cxx | 481 +- panda/src/event/asyncTask.h | 41 +- panda/src/event/asyncTaskChain.I | 60 +- panda/src/event/asyncTaskChain.cxx | 821 ++- panda/src/event/asyncTaskChain.h | 73 +- panda/src/event/asyncTaskCollection.I | 52 +- panda/src/event/asyncTaskCollection.cxx | 207 +- panda/src/event/asyncTaskCollection.h | 41 +- panda/src/event/asyncTaskManager.I | 84 +- panda/src/event/asyncTaskManager.cxx | 425 +- panda/src/event/asyncTaskManager.h | 66 +- panda/src/event/asyncTaskPause.I | 26 +- panda/src/event/asyncTaskPause.cxx | 46 +- panda/src/event/asyncTaskPause.h | 38 +- panda/src/event/asyncTaskSequence.I | 61 +- panda/src/event/asyncTaskSequence.cxx | 133 +- panda/src/event/asyncTaskSequence.h | 47 +- panda/src/event/buttonEvent.I | 111 +- panda/src/event/buttonEvent.cxx | 61 +- panda/src/event/buttonEvent.h | 134 +- panda/src/event/buttonEventList.I | 87 +- panda/src/event/buttonEventList.cxx | 113 +- panda/src/event/buttonEventList.h | 39 +- panda/src/event/config_event.cxx | 25 +- panda/src/event/config_event.h | 25 +- panda/src/event/event.I | 60 +- panda/src/event/event.cxx | 121 +- panda/src/event/event.h | 45 +- panda/src/event/eventHandler.I | 41 +- panda/src/event/eventHandler.cxx | 188 +- panda/src/event/eventHandler.h | 47 +- panda/src/event/eventParameter.I | 277 +- panda/src/event/eventParameter.cxx | 33 +- panda/src/event/eventParameter.h | 50 +- panda/src/event/eventQueue.I | 37 +- panda/src/event/eventQueue.cxx | 91 +- panda/src/event/eventQueue.h | 37 +- panda/src/event/eventReceiver.cxx | 25 +- panda/src/event/eventReceiver.h | 39 +- panda/src/event/genericAsyncTask.I | 104 +- panda/src/event/genericAsyncTask.cxx | 116 +- panda/src/event/genericAsyncTask.h | 37 +- panda/src/event/pointerEvent.I | 76 +- panda/src/event/pointerEvent.cxx | 49 +- panda/src/event/pointerEvent.h | 33 +- panda/src/event/pointerEventList.I | 154 +- panda/src/event/pointerEventList.cxx | 139 +- panda/src/event/pointerEventList.h | 39 +- panda/src/event/pt_Event.cxx | 25 +- panda/src/event/pt_Event.h | 34 +- panda/src/event/pythonTask.I | 47 +- panda/src/event/pythonTask.cxx | 356 +- panda/src/event/pythonTask.h | 63 +- panda/src/event/test_task.cxx | 27 +- panda/src/event/throw_event.I | 27 +- panda/src/event/throw_event.h | 25 +- panda/src/express/buffer.I | 33 +- panda/src/express/buffer.cxx | 42 +- panda/src/express/buffer.h | 32 +- panda/src/express/checksumHashGenerator.I | 79 +- panda/src/express/checksumHashGenerator.cxx | 34 +- panda/src/express/checksumHashGenerator.h | 35 +- panda/src/express/circBuffer.I | 196 +- panda/src/express/circBuffer.h | 54 +- panda/src/express/compress_string.cxx | 146 +- panda/src/express/compress_string.h | 25 +- panda/src/express/config_express.cxx | 67 +- panda/src/express/config_express.h | 34 +- panda/src/express/copy_stream.cxx | 40 +- panda/src/express/copy_stream.h | 25 +- panda/src/express/datagram.I | 430 +- panda/src/express/datagram.cxx | 131 +- panda/src/express/datagram.h | 63 +- panda/src/express/datagramGenerator.I | 35 +- panda/src/express/datagramGenerator.cxx | 121 +- panda/src/express/datagramGenerator.h | 35 +- panda/src/express/datagramIterator.I | 292 +- panda/src/express/datagramIterator.cxx | 115 +- panda/src/express/datagramIterator.h | 45 +- panda/src/express/datagramSink.I | 35 +- panda/src/express/datagramSink.cxx | 119 +- panda/src/express/datagramSink.h | 36 +- panda/src/express/dcast.cxx | 45 +- panda/src/express/dcast.h | 77 +- panda/src/express/encrypt_string.cxx | 152 +- panda/src/express/encrypt_string.h | 31 +- panda/src/express/error_utils.cxx | 54 +- panda/src/express/error_utils.h | 26 +- panda/src/express/export_dtool.h | 33 +- panda/src/express/fileReference.I | 44 +- panda/src/express/fileReference.cxx | 25 +- panda/src/express/fileReference.h | 35 +- panda/src/express/filename_ext.cxx | 64 +- panda/src/express/filename_ext.h | 35 +- panda/src/express/globPattern_ext.cxx | 34 +- panda/src/express/globPattern_ext.h | 35 +- panda/src/express/hashGeneratorBase.I | 50 +- panda/src/express/hashGeneratorBase.cxx | 26 +- panda/src/express/hashGeneratorBase.h | 51 +- panda/src/express/hashVal.I | 190 +- panda/src/express/hashVal.cxx | 186 +- panda/src/express/hashVal.h | 34 +- panda/src/express/indirectLess.I | 34 +- panda/src/express/indirectLess.h | 38 +- panda/src/express/make_ca_bundle.cxx | 39 +- panda/src/express/memoryInfo.I | 91 +- panda/src/express/memoryInfo.cxx | 103 +- panda/src/express/memoryInfo.h | 48 +- panda/src/express/memoryUsage.I | 370 +- panda/src/express/memoryUsage.cxx | 545 +- panda/src/express/memoryUsage.h | 75 +- panda/src/express/memoryUsagePointerCounts.I | 95 +- .../src/express/memoryUsagePointerCounts.cxx | 58 +- panda/src/express/memoryUsagePointerCounts.h | 40 +- panda/src/express/memoryUsagePointers.I | 66 +- panda/src/express/memoryUsagePointers.cxx | 153 +- panda/src/express/memoryUsagePointers.h | 70 +- panda/src/express/memoryUsagePointers_ext.cxx | 47 +- panda/src/express/memoryUsagePointers_ext.h | 35 +- panda/src/express/multifile.I | 527 +- panda/src/express/multifile.cxx | 1713 +++---- panda/src/express/multifile.h | 32 +- panda/src/express/namable.I | 110 +- panda/src/express/namable.cxx | 25 +- panda/src/express/namable.h | 53 +- panda/src/express/nodePointerTo.I | 256 +- panda/src/express/nodePointerTo.cxx | 25 +- panda/src/express/nodePointerTo.h | 54 +- panda/src/express/nodePointerToBase.I | 125 +- panda/src/express/nodePointerToBase.cxx | 25 +- panda/src/express/nodePointerToBase.h | 50 +- panda/src/express/nodeReferenceCount.I | 264 +- panda/src/express/nodeReferenceCount.cxx | 53 +- panda/src/express/nodeReferenceCount.h | 70 +- panda/src/express/openSSLWrapper.I | 70 +- panda/src/express/openSSLWrapper.cxx | 202 +- panda/src/express/openSSLWrapper.h | 37 +- panda/src/express/ordered_vector.I | 746 ++- panda/src/express/ordered_vector.cxx | 25 +- panda/src/express/ordered_vector.h | 170 +- .../src/express/pStatCollectorForwardBase.cxx | 34 +- panda/src/express/pStatCollectorForwardBase.h | 43 +- panda/src/express/password_hash.cxx | 87 +- panda/src/express/password_hash.h | 29 +- panda/src/express/patchfile.I | 120 +- panda/src/express/patchfile.cxx | 626 +-- panda/src/express/patchfile.h | 62 +- panda/src/express/pointerTo.I | 290 +- panda/src/express/pointerTo.cxx | 25 +- panda/src/express/pointerTo.h | 192 +- panda/src/express/pointerToArray.I | 836 ++- panda/src/express/pointerToArray.cxx | 25 +- panda/src/express/pointerToArray.h | 209 +- panda/src/express/pointerToArrayBase.I | 147 +- panda/src/express/pointerToArrayBase.cxx | 25 +- panda/src/express/pointerToArrayBase.h | 73 +- panda/src/express/pointerToArray_ext.I | 153 +- panda/src/express/pointerToArray_ext.h | 61 +- panda/src/express/pointerToBase.I | 132 +- panda/src/express/pointerToBase.cxx | 25 +- panda/src/express/pointerToBase.h | 40 +- panda/src/express/pointerToVoid.I | 116 +- panda/src/express/pointerToVoid.cxx | 25 +- panda/src/express/pointerToVoid.h | 66 +- panda/src/express/profileTimer.I | 29 +- panda/src/express/profileTimer.cxx | 30 +- panda/src/express/profileTimer.h | 31 +- panda/src/express/pta_double.cxx | 25 +- panda/src/express/pta_double.h | 39 +- panda/src/express/pta_float.cxx | 25 +- panda/src/express/pta_float.h | 39 +- panda/src/express/pta_int.cxx | 25 +- panda/src/express/pta_int.h | 39 +- panda/src/express/pta_stdfloat.h | 25 +- panda/src/express/pta_uchar.cxx | 25 +- panda/src/express/pta_uchar.h | 39 +- panda/src/express/ramfile.I | 80 +- panda/src/express/ramfile.cxx | 65 +- panda/src/express/ramfile.h | 33 +- panda/src/express/ramfile_ext.cxx | 76 +- panda/src/express/ramfile_ext.h | 35 +- panda/src/express/referenceCount.I | 428 +- panda/src/express/referenceCount.cxx | 75 +- panda/src/express/referenceCount.h | 95 +- panda/src/express/streamReader_ext.cxx | 67 +- panda/src/express/streamReader_ext.h | 35 +- panda/src/express/streamWriter_ext.cxx | 34 +- panda/src/express/streamWriter_ext.h | 35 +- panda/src/express/subStream.I | 168 +- panda/src/express/subStream.cxx | 25 +- panda/src/express/subStream.h | 77 +- panda/src/express/subStreamBuf.cxx | 174 +- panda/src/express/subStreamBuf.h | 32 +- panda/src/express/subfileInfo.I | 111 +- panda/src/express/subfileInfo.cxx | 33 +- panda/src/express/subfileInfo.h | 37 +- panda/src/express/temporaryFile.I | 34 +- panda/src/express/temporaryFile.cxx | 34 +- panda/src/express/temporaryFile.h | 37 +- panda/src/express/test_ordered_vector.cxx | 29 +- panda/src/express/test_types.cxx | 30 +- panda/src/express/test_zstream.cxx | 33 +- panda/src/express/threadSafePointerTo.I | 208 +- panda/src/express/threadSafePointerTo.cxx | 25 +- panda/src/express/threadSafePointerTo.h | 83 +- panda/src/express/threadSafePointerToBase.I | 102 +- panda/src/express/threadSafePointerToBase.cxx | 25 +- panda/src/express/threadSafePointerToBase.h | 40 +- panda/src/express/trueClock.I | 83 +- panda/src/express/trueClock.cxx | 391 +- panda/src/express/trueClock.h | 74 +- panda/src/express/typeHandle_ext.cxx | 38 +- panda/src/express/typeHandle_ext.h | 35 +- panda/src/express/typedReferenceCount.I | 50 +- panda/src/express/typedReferenceCount.cxx | 26 +- panda/src/express/typedReferenceCount.h | 47 +- panda/src/express/typedef.h | 26 +- panda/src/express/vector_double.cxx | 25 +- panda/src/express/vector_double.h | 39 +- panda/src/express/vector_float.cxx | 25 +- panda/src/express/vector_float.h | 39 +- panda/src/express/vector_stdfloat.h | 26 +- panda/src/express/vector_uchar.cxx | 25 +- panda/src/express/vector_uchar.h | 39 +- panda/src/express/virtualFile.I | 77 +- panda/src/express/virtualFile.cxx | 464 +- panda/src/express/virtualFile.h | 36 +- panda/src/express/virtualFileComposite.I | 47 +- panda/src/express/virtualFileComposite.cxx | 80 +- panda/src/express/virtualFileComposite.h | 39 +- panda/src/express/virtualFileList.I | 99 +- panda/src/express/virtualFileList.cxx | 25 +- panda/src/express/virtualFileList.h | 33 +- panda/src/express/virtualFileMount.I | 64 +- panda/src/express/virtualFileMount.cxx | 338 +- panda/src/express/virtualFileMount.h | 38 +- .../express/virtualFileMountAndroidAsset.I | 42 +- .../express/virtualFileMountAndroidAsset.cxx | 262 +- .../express/virtualFileMountAndroidAsset.h | 35 +- panda/src/express/virtualFileMountMultifile.I | 43 +- .../src/express/virtualFileMountMultifile.cxx | 188 +- panda/src/express/virtualFileMountMultifile.h | 35 +- panda/src/express/virtualFileMountRamdisk.I | 60 +- panda/src/express/virtualFileMountRamdisk.cxx | 371 +- panda/src/express/virtualFileMountRamdisk.h | 44 +- panda/src/express/virtualFileMountSystem.I | 44 +- panda/src/express/virtualFileMountSystem.cxx | 305 +- panda/src/express/virtualFileMountSystem.h | 35 +- panda/src/express/virtualFileSimple.I | 55 +- panda/src/express/virtualFileSimple.cxx | 407 +- panda/src/express/virtualFileSimple.h | 39 +- panda/src/express/virtualFileSystem.I | 191 +- panda/src/express/virtualFileSystem.cxx | 803 ++- panda/src/express/virtualFileSystem.h | 63 +- panda/src/express/virtualFileSystem_ext.cxx | 64 +- panda/src/express/virtualFileSystem_ext.h | 36 +- panda/src/express/virtualFile_ext.cxx | 64 +- panda/src/express/virtualFile_ext.h | 36 +- panda/src/express/weakPointerCallback.I | 26 +- panda/src/express/weakPointerCallback.cxx | 33 +- panda/src/express/weakPointerCallback.h | 37 +- panda/src/express/weakPointerTo.I | 260 +- panda/src/express/weakPointerTo.cxx | 25 +- panda/src/express/weakPointerTo.h | 67 +- panda/src/express/weakPointerToBase.I | 318 +- panda/src/express/weakPointerToBase.cxx | 25 +- panda/src/express/weakPointerToBase.h | 44 +- panda/src/express/weakPointerToVoid.I | 102 +- panda/src/express/weakPointerToVoid.cxx | 25 +- panda/src/express/weakPointerToVoid.h | 35 +- panda/src/express/weakReferenceList.I | 26 +- panda/src/express/weakReferenceList.cxx | 80 +- panda/src/express/weakReferenceList.h | 44 +- panda/src/express/windowsRegistry.cxx | 175 +- panda/src/express/windowsRegistry.h | 39 +- panda/src/express/zStream.I | 97 +- panda/src/express/zStream.cxx | 25 +- panda/src/express/zStream.h | 71 +- panda/src/express/zStreamBuf.cxx | 137 +- panda/src/express/zStreamBuf.h | 49 +- panda/src/ffmpeg/config_ffmpeg.cxx | 41 +- panda/src/ffmpeg/config_ffmpeg.h | 25 +- panda/src/ffmpeg/ffmpegAudio.I | 26 +- panda/src/ffmpeg/ffmpegAudio.cxx | 57 +- panda/src/ffmpeg/ffmpegAudio.h | 34 +- panda/src/ffmpeg/ffmpegAudioCursor.I | 26 +- panda/src/ffmpeg/ffmpegAudioCursor.cxx | 104 +- panda/src/ffmpeg/ffmpegAudioCursor.h | 36 +- panda/src/ffmpeg/ffmpegVideo.I | 26 +- panda/src/ffmpeg/ffmpegVideo.cxx | 116 +- panda/src/ffmpeg/ffmpegVideo.h | 34 +- panda/src/ffmpeg/ffmpegVideoCursor.I | 36 +- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 594 +-- panda/src/ffmpeg/ffmpegVideoCursor.h | 45 +- panda/src/ffmpeg/ffmpegVirtualFile.I | 45 +- panda/src/ffmpeg/ffmpegVirtualFile.cxx | 149 +- panda/src/ffmpeg/ffmpegVirtualFile.h | 35 +- panda/src/framework/config_framework.cxx | 31 +- panda/src/framework/config_framework.h | 25 +- panda/src/framework/pandaFramework.I | 233 +- panda/src/framework/pandaFramework.cxx | 761 ++- panda/src/framework/pandaFramework.h | 39 +- panda/src/framework/windowFramework.I | 167 +- panda/src/framework/windowFramework.cxx | 619 +-- panda/src/framework/windowFramework.h | 42 +- panda/src/gles2gsg/config_gles2gsg.cxx | 39 +- panda/src/gles2gsg/config_gles2gsg.h | 25 +- panda/src/gles2gsg/gles2gsg.cxx | 31 +- panda/src/gles2gsg/gles2gsg.h | 35 +- panda/src/glesgsg/config_glesgsg.cxx | 39 +- panda/src/glesgsg/config_glesgsg.h | 25 +- panda/src/glesgsg/glesgsg.cxx | 31 +- panda/src/glesgsg/glesgsg.h | 39 +- panda/src/glgsg/config_glgsg.cxx | 39 +- panda/src/glgsg/config_glgsg.h | 25 +- panda/src/glgsg/glgsg.cxx | 31 +- panda/src/glgsg/glgsg.h | 35 +- panda/src/glstuff/glCgShaderContext_src.I | 60 +- panda/src/glstuff/glCgShaderContext_src.cxx | 249 +- panda/src/glstuff/glCgShaderContext_src.h | 33 +- panda/src/glstuff/glGeomContext_src.I | 42 +- panda/src/glstuff/glGeomContext_src.cxx | 78 +- panda/src/glstuff/glGeomContext_src.h | 44 +- panda/src/glstuff/glGeomMunger_src.I | 26 +- panda/src/glstuff/glGeomMunger_src.cxx | 177 +- panda/src/glstuff/glGeomMunger_src.h | 37 +- panda/src/glstuff/glGraphicsBuffer_src.I | 25 +- panda/src/glstuff/glGraphicsBuffer_src.cxx | 410 +- panda/src/glstuff/glGraphicsBuffer_src.h | 120 +- .../src/glstuff/glGraphicsStateGuardian_src.I | 513 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 2956 +++++------ .../src/glstuff/glGraphicsStateGuardian_src.h | 72 +- panda/src/glstuff/glImmediateModeSender_src.I | 192 +- .../src/glstuff/glImmediateModeSender_src.cxx | 333 +- panda/src/glstuff/glImmediateModeSender_src.h | 66 +- panda/src/glstuff/glIndexBufferContext_src.I | 34 +- .../src/glstuff/glIndexBufferContext_src.cxx | 54 +- panda/src/glstuff/glIndexBufferContext_src.h | 36 +- panda/src/glstuff/glLatencyQueryContext_src.I | 26 +- .../src/glstuff/glLatencyQueryContext_src.cxx | 55 +- panda/src/glstuff/glLatencyQueryContext_src.h | 38 +- .../src/glstuff/glOcclusionQueryContext_src.I | 34 +- .../glstuff/glOcclusionQueryContext_src.cxx | 80 +- .../src/glstuff/glOcclusionQueryContext_src.h | 33 +- panda/src/glstuff/glSamplerContext_src.cxx | 81 +- panda/src/glstuff/glSamplerContext_src.h | 35 +- panda/src/glstuff/glShaderContext_src.I | 60 +- panda/src/glstuff/glShaderContext_src.cxx | 456 +- panda/src/glstuff/glShaderContext_src.h | 46 +- panda/src/glstuff/glTextureContext_src.I | 34 +- panda/src/glstuff/glTextureContext_src.cxx | 122 +- panda/src/glstuff/glTextureContext_src.h | 39 +- panda/src/glstuff/glTimerQueryContext_src.I | 34 +- panda/src/glstuff/glTimerQueryContext_src.cxx | 93 +- panda/src/glstuff/glTimerQueryContext_src.h | 39 +- panda/src/glstuff/glVertexBufferContext_src.I | 36 +- .../src/glstuff/glVertexBufferContext_src.cxx | 54 +- panda/src/glstuff/glVertexBufferContext_src.h | 36 +- panda/src/glstuff/glmisc_src.cxx | 31 +- panda/src/glstuff/glmisc_src.h | 31 +- panda/src/glstuff/glpure.cxx | 31 +- panda/src/glstuff/glstuff_src.cxx | 33 +- panda/src/glstuff/glstuff_src.h | 53 +- panda/src/glstuff/glstuff_undef_src.h | 30 +- panda/src/glxdisplay/config_glxdisplay.cxx | 39 +- panda/src/glxdisplay/config_glxdisplay.h | 25 +- panda/src/glxdisplay/glxGraphicsBuffer.I | 26 +- panda/src/glxdisplay/glxGraphicsBuffer.cxx | 121 +- panda/src/glxdisplay/glxGraphicsBuffer.h | 35 +- panda/src/glxdisplay/glxGraphicsPipe.I | 26 +- panda/src/glxdisplay/glxGraphicsPipe.cxx | 99 +- panda/src/glxdisplay/glxGraphicsPipe.h | 50 +- panda/src/glxdisplay/glxGraphicsPixmap.I | 26 +- panda/src/glxdisplay/glxGraphicsPixmap.cxx | 118 +- panda/src/glxdisplay/glxGraphicsPixmap.h | 41 +- .../src/glxdisplay/glxGraphicsStateGuardian.I | 37 +- .../glxdisplay/glxGraphicsStateGuardian.cxx | 284 +- .../src/glxdisplay/glxGraphicsStateGuardian.h | 64 +- panda/src/glxdisplay/glxGraphicsWindow.I | 34 +- panda/src/glxdisplay/glxGraphicsWindow.cxx | 151 +- panda/src/glxdisplay/glxGraphicsWindow.h | 37 +- .../glxdisplay/posixGraphicsStateGuardian.I | 25 +- .../glxdisplay/posixGraphicsStateGuardian.cxx | 82 +- .../glxdisplay/posixGraphicsStateGuardian.h | 37 +- panda/src/gobj/adaptiveLru.I | 200 +- panda/src/gobj/adaptiveLru.cxx | 341 +- panda/src/gobj/adaptiveLru.h | 104 +- panda/src/gobj/animateVerticesRequest.I | 43 +- panda/src/gobj/animateVerticesRequest.cxx | 34 +- panda/src/gobj/animateVerticesRequest.h | 60 +- panda/src/gobj/bufferContext.I | 129 +- panda/src/gobj/bufferContext.cxx | 51 +- panda/src/gobj/bufferContext.h | 49 +- panda/src/gobj/bufferContextChain.I | 70 +- panda/src/gobj/bufferContextChain.cxx | 61 +- panda/src/gobj/bufferContextChain.h | 46 +- panda/src/gobj/bufferResidencyTracker.I | 58 +- panda/src/gobj/bufferResidencyTracker.cxx | 91 +- panda/src/gobj/bufferResidencyTracker.h | 50 +- panda/src/gobj/config_gobj.cxx | 29 +- panda/src/gobj/config_gobj.h | 25 +- panda/src/gobj/geom.I | 661 +-- panda/src/gobj/geom.cxx | 1069 ++-- panda/src/gobj/geom.h | 88 +- panda/src/gobj/geomCacheEntry.I | 54 +- panda/src/gobj/geomCacheEntry.cxx | 90 +- panda/src/gobj/geomCacheEntry.h | 39 +- panda/src/gobj/geomCacheManager.I | 90 +- panda/src/gobj/geomCacheManager.cxx | 70 +- panda/src/gobj/geomCacheManager.h | 80 +- panda/src/gobj/geomContext.I | 42 +- panda/src/gobj/geomContext.cxx | 25 +- panda/src/gobj/geomContext.h | 59 +- panda/src/gobj/geomEnums.cxx | 53 +- panda/src/gobj/geomEnums.h | 165 +- panda/src/gobj/geomLines.cxx | 153 +- panda/src/gobj/geomLines.h | 32 +- panda/src/gobj/geomLinestrips.cxx | 212 +- panda/src/gobj/geomLinestrips.h | 34 +- panda/src/gobj/geomMunger.I | 243 +- panda/src/gobj/geomMunger.cxx | 334 +- panda/src/gobj/geomMunger.h | 75 +- panda/src/gobj/geomPatches.cxx | 161 +- panda/src/gobj/geomPatches.h | 35 +- panda/src/gobj/geomPoints.cxx | 154 +- panda/src/gobj/geomPoints.h | 32 +- panda/src/gobj/geomPrimitive.I | 649 +-- panda/src/gobj/geomPrimitive.cxx | 1514 +++--- panda/src/gobj/geomPrimitive.h | 104 +- panda/src/gobj/geomTriangles.cxx | 187 +- panda/src/gobj/geomTriangles.h | 32 +- panda/src/gobj/geomTrifans.cxx | 156 +- panda/src/gobj/geomTrifans.h | 32 +- panda/src/gobj/geomTristrips.cxx | 275 +- panda/src/gobj/geomTristrips.h | 34 +- panda/src/gobj/geomVertexAnimationSpec.I | 165 +- panda/src/gobj/geomVertexAnimationSpec.cxx | 56 +- panda/src/gobj/geomVertexAnimationSpec.h | 54 +- panda/src/gobj/geomVertexArrayData.I | 492 +- panda/src/gobj/geomVertexArrayData.cxx | 571 +-- panda/src/gobj/geomVertexArrayData.h | 97 +- panda/src/gobj/geomVertexArrayData_ext.cxx | 97 +- panda/src/gobj/geomVertexArrayData_ext.h | 45 +- panda/src/gobj/geomVertexArrayFormat.I | 200 +- panda/src/gobj/geomVertexArrayFormat.cxx | 458 +- panda/src/gobj/geomVertexArrayFormat.h | 56 +- panda/src/gobj/geomVertexColumn.I | 297 +- panda/src/gobj/geomVertexColumn.cxx | 914 ++-- panda/src/gobj/geomVertexColumn.h | 63 +- panda/src/gobj/geomVertexData.I | 811 ++- panda/src/gobj/geomVertexData.cxx | 1225 ++--- panda/src/gobj/geomVertexData.h | 113 +- panda/src/gobj/geomVertexFormat.I | 539 +- panda/src/gobj/geomVertexFormat.cxx | 622 +-- panda/src/gobj/geomVertexFormat.h | 96 +- panda/src/gobj/geomVertexReader.I | 670 +-- panda/src/gobj/geomVertexReader.cxx | 91 +- panda/src/gobj/geomVertexReader.h | 92 +- panda/src/gobj/geomVertexRewriter.I | 341 +- panda/src/gobj/geomVertexRewriter.cxx | 35 +- panda/src/gobj/geomVertexRewriter.h | 54 +- panda/src/gobj/geomVertexWriter.I | 1459 +++--- panda/src/gobj/geomVertexWriter.cxx | 121 +- panda/src/gobj/geomVertexWriter.h | 113 +- panda/src/gobj/indexBufferContext.I | 103 +- panda/src/gobj/indexBufferContext.cxx | 41 +- panda/src/gobj/indexBufferContext.h | 51 +- panda/src/gobj/internalName.I | 524 +- panda/src/gobj/internalName.cxx | 250 +- panda/src/gobj/internalName.h | 78 +- panda/src/gobj/internalName_ext.cxx | 43 +- panda/src/gobj/internalName_ext.h | 35 +- panda/src/gobj/lens.I | 913 ++-- panda/src/gobj/lens.cxx | 1316 ++--- panda/src/gobj/lens.h | 79 +- panda/src/gobj/material.I | 331 +- panda/src/gobj/material.cxx | 352 +- panda/src/gobj/material.h | 58 +- panda/src/gobj/materialPool.I | 113 +- panda/src/gobj/materialPool.cxx | 87 +- panda/src/gobj/materialPool.h | 64 +- panda/src/gobj/matrixLens.I | 212 +- panda/src/gobj/matrixLens.cxx | 94 +- panda/src/gobj/matrixLens.h | 39 +- panda/src/gobj/occlusionQueryContext.I | 34 +- panda/src/gobj/occlusionQueryContext.cxx | 42 +- panda/src/gobj/occlusionQueryContext.h | 40 +- panda/src/gobj/orthographicLens.I | 50 +- panda/src/gobj/orthographicLens.cxx | 111 +- panda/src/gobj/orthographicLens.h | 44 +- panda/src/gobj/paramTexture.I | 135 +- panda/src/gobj/paramTexture.cxx | 149 +- panda/src/gobj/paramTexture.h | 51 +- panda/src/gobj/perspectiveLens.I | 58 +- panda/src/gobj/perspectiveLens.cxx | 150 +- panda/src/gobj/perspectiveLens.h | 32 +- panda/src/gobj/preparedGraphicsObjects.I | 101 +- panda/src/gobj/preparedGraphicsObjects.cxx | 1136 ++-- panda/src/gobj/preparedGraphicsObjects.h | 66 +- panda/src/gobj/queryContext.I | 34 +- panda/src/gobj/queryContext.cxx | 63 +- panda/src/gobj/queryContext.h | 52 +- panda/src/gobj/samplerContext.I | 34 +- panda/src/gobj/samplerContext.cxx | 42 +- panda/src/gobj/samplerContext.h | 50 +- panda/src/gobj/samplerState.I | 338 +- panda/src/gobj/samplerState.cxx | 213 +- panda/src/gobj/samplerState.h | 54 +- panda/src/gobj/savedContext.I | 33 +- panda/src/gobj/savedContext.cxx | 41 +- panda/src/gobj/savedContext.h | 38 +- panda/src/gobj/shader.I | 447 +- panda/src/gobj/shader.cxx | 904 ++-- panda/src/gobj/shader.h | 56 +- panda/src/gobj/shaderContext.I | 41 +- panda/src/gobj/shaderContext.cxx | 26 +- panda/src/gobj/shaderContext.h | 44 +- panda/src/gobj/simpleAllocator.I | 283 +- panda/src/gobj/simpleAllocator.cxx | 127 +- panda/src/gobj/simpleAllocator.h | 84 +- panda/src/gobj/simpleLru.I | 189 +- panda/src/gobj/simpleLru.cxx | 192 +- panda/src/gobj/simpleLru.h | 43 +- panda/src/gobj/sliderTable.I | 173 +- panda/src/gobj/sliderTable.cxx | 218 +- panda/src/gobj/sliderTable.h | 47 +- panda/src/gobj/test_gobj.cxx | 25 +- panda/src/gobj/texture.I | 2939 +++++------ panda/src/gobj/texture.cxx | 3179 +++++------- panda/src/gobj/texture.h | 142 +- panda/src/gobj/textureCollection.I | 74 +- panda/src/gobj/textureCollection.cxx | 207 +- panda/src/gobj/textureCollection.h | 34 +- panda/src/gobj/textureCollection_ext.cxx | 64 +- panda/src/gobj/textureCollection_ext.h | 35 +- panda/src/gobj/textureContext.I | 182 +- panda/src/gobj/textureContext.cxx | 41 +- panda/src/gobj/textureContext.h | 55 +- panda/src/gobj/texturePeeker.I | 74 +- panda/src/gobj/texturePeeker.cxx | 281 +- panda/src/gobj/texturePeeker.h | 50 +- panda/src/gobj/texturePool.I | 388 +- panda/src/gobj/texturePool.cxx | 431 +- panda/src/gobj/texturePool.h | 61 +- panda/src/gobj/texturePoolFilter.I | 26 +- panda/src/gobj/texturePoolFilter.cxx | 77 +- panda/src/gobj/texturePoolFilter.h | 69 +- panda/src/gobj/textureReloadRequest.I | 77 +- panda/src/gobj/textureReloadRequest.cxx | 46 +- panda/src/gobj/textureReloadRequest.h | 49 +- panda/src/gobj/textureStage.I | 676 +-- panda/src/gobj/textureStage.cxx | 192 +- panda/src/gobj/textureStage.h | 57 +- panda/src/gobj/textureStagePool.I | 137 +- panda/src/gobj/textureStagePool.cxx | 138 +- panda/src/gobj/textureStagePool.h | 53 +- panda/src/gobj/timerQueryContext.I | 34 +- panda/src/gobj/timerQueryContext.cxx | 47 +- panda/src/gobj/timerQueryContext.h | 32 +- panda/src/gobj/transformBlend.I | 354 +- panda/src/gobj/transformBlend.cxx | 182 +- panda/src/gobj/transformBlend.h | 40 +- panda/src/gobj/transformBlendTable.I | 149 +- panda/src/gobj/transformBlendTable.cxx | 242 +- panda/src/gobj/transformBlendTable.h | 72 +- panda/src/gobj/transformTable.I | 133 +- panda/src/gobj/transformTable.cxx | 202 +- panda/src/gobj/transformTable.h | 44 +- panda/src/gobj/userVertexSlider.I | 50 +- panda/src/gobj/userVertexSlider.cxx | 121 +- panda/src/gobj/userVertexSlider.h | 37 +- panda/src/gobj/userVertexTransform.I | 59 +- panda/src/gobj/userVertexTransform.cxx | 121 +- panda/src/gobj/userVertexTransform.h | 37 +- panda/src/gobj/vertexBufferContext.I | 104 +- panda/src/gobj/vertexBufferContext.cxx | 41 +- panda/src/gobj/vertexBufferContext.h | 52 +- panda/src/gobj/vertexDataBlock.I | 73 +- panda/src/gobj/vertexDataBlock.cxx | 25 +- panda/src/gobj/vertexDataBlock.h | 34 +- panda/src/gobj/vertexDataBook.I | 54 +- panda/src/gobj/vertexDataBook.cxx | 134 +- panda/src/gobj/vertexDataBook.h | 34 +- panda/src/gobj/vertexDataBuffer.I | 193 +- panda/src/gobj/vertexDataBuffer.cxx | 127 +- panda/src/gobj/vertexDataBuffer.h | 85 +- panda/src/gobj/vertexDataPage.I | 237 +- panda/src/gobj/vertexDataPage.cxx | 503 +- panda/src/gobj/vertexDataPage.h | 59 +- panda/src/gobj/vertexDataSaveFile.I | 90 +- panda/src/gobj/vertexDataSaveFile.cxx | 116 +- panda/src/gobj/vertexDataSaveFile.h | 46 +- panda/src/gobj/vertexSlider.I | 66 +- panda/src/gobj/vertexSlider.cxx | 138 +- panda/src/gobj/vertexSlider.h | 44 +- panda/src/gobj/vertexTransform.I | 66 +- panda/src/gobj/vertexTransform.cxx | 190 +- panda/src/gobj/vertexTransform.h | 40 +- panda/src/gobj/videoTexture.I | 63 +- panda/src/gobj/videoTexture.cxx | 219 +- panda/src/gobj/videoTexture.h | 43 +- panda/src/grutil/cardMaker.I | 172 +- panda/src/grutil/cardMaker.cxx | 154 +- panda/src/grutil/cardMaker.h | 36 +- panda/src/grutil/config_grutil.cxx | 39 +- panda/src/grutil/config_grutil.h | 27 +- panda/src/grutil/fisheyeMaker.I | 102 +- panda/src/grutil/fisheyeMaker.cxx | 170 +- panda/src/grutil/fisheyeMaker.h | 48 +- panda/src/grutil/frameRateMeter.I | 129 +- panda/src/grutil/frameRateMeter.cxx | 132 +- panda/src/grutil/frameRateMeter.h | 46 +- panda/src/grutil/geoMipTerrain.I | 480 +- panda/src/grutil/geoMipTerrain.cxx | 288 +- panda/src/grutil/geoMipTerrain.h | 53 +- panda/src/grutil/heightfieldTesselator.I | 152 +- panda/src/grutil/heightfieldTesselator.cxx | 207 +- panda/src/grutil/heightfieldTesselator.h | 93 +- panda/src/grutil/lineSegs.I | 175 +- panda/src/grutil/lineSegs.cxx | 195 +- panda/src/grutil/lineSegs.h | 39 +- panda/src/grutil/meshDrawer.I | 81 +- panda/src/grutil/meshDrawer.cxx | 213 +- panda/src/grutil/meshDrawer.h | 56 +- panda/src/grutil/meshDrawer2D.I | 91 +- panda/src/grutil/meshDrawer2D.cxx | 86 +- panda/src/grutil/meshDrawer2D.h | 36 +- panda/src/grutil/movieTexture.I | 83 +- panda/src/grutil/movieTexture.cxx | 571 +-- panda/src/grutil/movieTexture.h | 58 +- panda/src/grutil/multitexReducer.I | 114 +- panda/src/grutil/multitexReducer.cxx | 563 +- panda/src/grutil/multitexReducer.h | 67 +- panda/src/grutil/nodeVertexTransform.I | 45 +- panda/src/grutil/nodeVertexTransform.cxx | 54 +- panda/src/grutil/nodeVertexTransform.h | 42 +- panda/src/grutil/pfmVizzer.I | 269 +- panda/src/grutil/pfmVizzer.cxx | 511 +- panda/src/grutil/pfmVizzer.h | 44 +- panda/src/grutil/pipeOcclusionCullTraverser.I | 77 +- .../src/grutil/pipeOcclusionCullTraverser.cxx | 255 +- panda/src/grutil/pipeOcclusionCullTraverser.h | 63 +- panda/src/grutil/rigidBodyCombiner.I | 42 +- panda/src/grutil/rigidBodyCombiner.cxx | 224 +- panda/src/grutil/rigidBodyCombiner.h | 76 +- panda/src/grutil/sceneGraphAnalyzerMeter.I | 103 +- panda/src/grutil/sceneGraphAnalyzerMeter.cxx | 120 +- panda/src/grutil/sceneGraphAnalyzerMeter.h | 46 +- panda/src/gsgbase/config_gsgbase.cxx | 25 +- panda/src/gsgbase/config_gsgbase.h | 25 +- panda/src/gsgbase/displayRegionBase.I | 34 +- panda/src/gsgbase/displayRegionBase.cxx | 33 +- panda/src/gsgbase/displayRegionBase.h | 34 +- panda/src/gsgbase/graphicsOutputBase.I | 26 +- panda/src/gsgbase/graphicsOutputBase.cxx | 25 +- panda/src/gsgbase/graphicsOutputBase.h | 35 +- .../src/gsgbase/graphicsStateGuardianBase.cxx | 93 +- panda/src/gsgbase/graphicsStateGuardianBase.h | 90 +- panda/src/gsgbase/test_gsgbase.cxx | 25 +- panda/src/iphone/config_iphone.h | 25 +- panda/src/iphone/config_iphone.mm | 39 +- panda/src/iphone/iphone_runappmf_src.mm | 89 +- panda/src/iphone/pview_delegate.h | 35 +- panda/src/iphone/pview_delegate.mm | 71 +- panda/src/iphone/pview_main.mm | 39 +- .../src/iphonedisplay/config_iphonedisplay.h | 25 +- .../src/iphonedisplay/config_iphonedisplay.mm | 48 +- panda/src/iphonedisplay/eaglView.h | 31 +- panda/src/iphonedisplay/eaglView.mm | 69 +- panda/src/iphonedisplay/iPhoneGraphicsPipe.h | 37 +- panda/src/iphonedisplay/iPhoneGraphicsPipe.mm | 123 +- .../iPhoneGraphicsStateGuardian.h | 41 +- .../iPhoneGraphicsStateGuardian.mm | 76 +- .../src/iphonedisplay/iPhoneGraphicsWindow.I | 26 +- .../src/iphonedisplay/iPhoneGraphicsWindow.h | 37 +- .../src/iphonedisplay/iPhoneGraphicsWindow.mm | 294 +- panda/src/iphonedisplay/viewController.h | 35 +- panda/src/iphonedisplay/viewController.mm | 75 +- panda/src/linmath/aa_luse.h | 56 +- panda/src/linmath/cast_to_double.I | 26 +- panda/src/linmath/cast_to_double.h | 35 +- panda/src/linmath/cast_to_float.I | 26 +- panda/src/linmath/cast_to_float.h | 35 +- panda/src/linmath/compose_matrix.cxx | 25 +- panda/src/linmath/compose_matrix.h | 50 +- panda/src/linmath/compose_matrix_src.I | 72 +- panda/src/linmath/compose_matrix_src.cxx | 293 +- panda/src/linmath/compose_matrix_src.h | 37 +- panda/src/linmath/configVariableColor.I | 101 +- panda/src/linmath/configVariableColor.cxx | 33 +- panda/src/linmath/configVariableColor.h | 53 +- panda/src/linmath/config_linmath.cxx | 39 +- panda/src/linmath/config_linmath.h | 25 +- panda/src/linmath/coordinateSystem.cxx | 38 +- panda/src/linmath/coordinateSystem.h | 39 +- panda/src/linmath/dbl2fltnames.h | 34 +- panda/src/linmath/dblnames.h | 57 +- panda/src/linmath/deg_2_rad.I | 41 +- panda/src/linmath/deg_2_rad.h | 26 +- panda/src/linmath/flt2dblnames.h | 34 +- panda/src/linmath/fltnames.h | 57 +- panda/src/linmath/intnames.h | 57 +- panda/src/linmath/lcast_to.h | 42 +- panda/src/linmath/lcast_to_src.I | 23 +- panda/src/linmath/lcast_to_src.h | 25 +- panda/src/linmath/lmat_ops.h | 25 +- panda/src/linmath/lmat_ops_src.I | 96 +- panda/src/linmath/lmat_ops_src.h | 25 +- panda/src/linmath/lmatrix.cxx | 25 +- panda/src/linmath/lmatrix.h | 25 +- panda/src/linmath/lmatrix3_ext_src.I | 51 +- panda/src/linmath/lmatrix3_ext_src.h | 36 +- panda/src/linmath/lmatrix3_src.I | 916 ++-- panda/src/linmath/lmatrix3_src.cxx | 198 +- panda/src/linmath/lmatrix3_src.h | 64 +- panda/src/linmath/lmatrix4_ext_src.I | 53 +- panda/src/linmath/lmatrix4_ext_src.h | 36 +- panda/src/linmath/lmatrix4_src.I | 1093 ++-- panda/src/linmath/lmatrix4_src.cxx | 209 +- panda/src/linmath/lmatrix4_src.h | 59 +- panda/src/linmath/lmatrix_ext.h | 25 +- panda/src/linmath/lorientation.cxx | 26 +- panda/src/linmath/lorientation.h | 25 +- panda/src/linmath/lorientation_src.I | 93 +- panda/src/linmath/lorientation_src.cxx | 33 +- panda/src/linmath/lorientation_src.h | 32 +- panda/src/linmath/lpoint2.cxx | 25 +- panda/src/linmath/lpoint2.h | 25 +- panda/src/linmath/lpoint2_ext.h | 25 +- panda/src/linmath/lpoint2_ext_src.I | 49 +- panda/src/linmath/lpoint2_ext_src.h | 36 +- panda/src/linmath/lpoint2_src.I | 161 +- panda/src/linmath/lpoint2_src.cxx | 35 +- panda/src/linmath/lpoint2_src.h | 33 +- panda/src/linmath/lpoint3.cxx | 25 +- panda/src/linmath/lpoint3.h | 25 +- panda/src/linmath/lpoint3_ext.h | 25 +- panda/src/linmath/lpoint3_ext_src.I | 49 +- panda/src/linmath/lpoint3_ext_src.h | 36 +- panda/src/linmath/lpoint3_src.I | 239 +- panda/src/linmath/lpoint3_src.cxx | 34 +- panda/src/linmath/lpoint3_src.h | 42 +- panda/src/linmath/lpoint4.cxx | 25 +- panda/src/linmath/lpoint4.h | 25 +- panda/src/linmath/lpoint4_ext.h | 25 +- panda/src/linmath/lpoint4_ext_src.I | 49 +- panda/src/linmath/lpoint4_ext_src.h | 36 +- panda/src/linmath/lpoint4_src.I | 200 +- panda/src/linmath/lpoint4_src.cxx | 34 +- panda/src/linmath/lpoint4_src.h | 32 +- panda/src/linmath/lquaternion.cxx | 26 +- panda/src/linmath/lquaternion.h | 25 +- panda/src/linmath/lquaternion_src.I | 552 +- panda/src/linmath/lquaternion_src.cxx | 117 +- panda/src/linmath/lquaternion_src.h | 32 +- panda/src/linmath/lrotation.cxx | 26 +- panda/src/linmath/lrotation.h | 25 +- panda/src/linmath/lrotation_src.I | 126 +- panda/src/linmath/lrotation_src.cxx | 34 +- panda/src/linmath/lrotation_src.h | 32 +- panda/src/linmath/lsimpleMatrix.I | 82 +- panda/src/linmath/lsimpleMatrix.h | 45 +- panda/src/linmath/luse.I | 25 +- panda/src/linmath/luse.cxx | 25 +- panda/src/linmath/luse.h | 93 +- panda/src/linmath/lvec2_ops.h | 25 +- panda/src/linmath/lvec2_ops_src.I | 81 +- panda/src/linmath/lvec2_ops_src.h | 36 +- panda/src/linmath/lvec3_ops.h | 25 +- panda/src/linmath/lvec3_ops_src.I | 96 +- panda/src/linmath/lvec3_ops_src.h | 33 +- panda/src/linmath/lvec4_ops.h | 25 +- panda/src/linmath/lvec4_ops_src.I | 81 +- panda/src/linmath/lvec4_ops_src.h | 33 +- panda/src/linmath/lvecBase2.cxx | 25 +- panda/src/linmath/lvecBase2.h | 25 +- panda/src/linmath/lvecBase2_ext.h | 25 +- panda/src/linmath/lvecBase2_ext_src.I | 94 +- panda/src/linmath/lvecBase2_ext_src.h | 36 +- panda/src/linmath/lvecBase2_src.I | 585 +-- panda/src/linmath/lvecBase2_src.cxx | 33 +- panda/src/linmath/lvecBase2_src.h | 54 +- panda/src/linmath/lvecBase3.cxx | 25 +- panda/src/linmath/lvecBase3.h | 25 +- panda/src/linmath/lvecBase3_ext.h | 25 +- panda/src/linmath/lvecBase3_ext_src.I | 94 +- panda/src/linmath/lvecBase3_ext_src.h | 36 +- panda/src/linmath/lvecBase3_src.I | 719 +-- panda/src/linmath/lvecBase3_src.cxx | 35 +- panda/src/linmath/lvecBase3_src.h | 47 +- panda/src/linmath/lvecBase4.cxx | 25 +- panda/src/linmath/lvecBase4.h | 25 +- panda/src/linmath/lvecBase4_ext.h | 25 +- panda/src/linmath/lvecBase4_ext_src.I | 94 +- panda/src/linmath/lvecBase4_ext_src.h | 36 +- panda/src/linmath/lvecBase4_src.I | 765 ++- panda/src/linmath/lvecBase4_src.cxx | 42 +- panda/src/linmath/lvecBase4_src.h | 69 +- panda/src/linmath/lvector2.cxx | 25 +- panda/src/linmath/lvector2.h | 25 +- panda/src/linmath/lvector2_ext.h | 25 +- panda/src/linmath/lvector2_ext_src.I | 49 +- panda/src/linmath/lvector2_ext_src.h | 36 +- panda/src/linmath/lvector2_src.I | 173 +- panda/src/linmath/lvector2_src.cxx | 35 +- panda/src/linmath/lvector2_src.h | 32 +- panda/src/linmath/lvector3.cxx | 25 +- panda/src/linmath/lvector3.h | 25 +- panda/src/linmath/lvector3_ext.h | 25 +- panda/src/linmath/lvector3_ext_src.I | 49 +- panda/src/linmath/lvector3_ext_src.h | 36 +- panda/src/linmath/lvector3_src.I | 349 +- panda/src/linmath/lvector3_src.cxx | 35 +- panda/src/linmath/lvector3_src.h | 44 +- panda/src/linmath/lvector4.cxx | 25 +- panda/src/linmath/lvector4.h | 25 +- panda/src/linmath/lvector4_ext.h | 25 +- panda/src/linmath/lvector4_ext_src.I | 49 +- panda/src/linmath/lvector4_ext_src.h | 36 +- panda/src/linmath/lvector4_src.I | 192 +- panda/src/linmath/lvector4_src.cxx | 34 +- panda/src/linmath/lvector4_src.h | 32 +- panda/src/linmath/mathNumbers.I | 66 +- panda/src/linmath/mathNumbers.cxx | 26 +- panda/src/linmath/mathNumbers.h | 26 +- panda/src/linmath/test_math.cxx | 26 +- panda/src/mathutil/boundingBox.I | 110 +- panda/src/mathutil/boundingBox.cxx | 282 +- panda/src/mathutil/boundingBox.h | 40 +- panda/src/mathutil/boundingHexahedron.I | 66 +- panda/src/mathutil/boundingHexahedron.cxx | 244 +- panda/src/mathutil/boundingHexahedron.h | 40 +- panda/src/mathutil/boundingLine.I | 58 +- panda/src/mathutil/boundingLine.cxx | 132 +- panda/src/mathutil/boundingLine.h | 44 +- panda/src/mathutil/boundingPlane.I | 51 +- panda/src/mathutil/boundingPlane.cxx | 154 +- panda/src/mathutil/boundingPlane.h | 39 +- panda/src/mathutil/boundingSphere.I | 74 +- panda/src/mathutil/boundingSphere.cxx | 281 +- panda/src/mathutil/boundingSphere.h | 35 +- panda/src/mathutil/boundingVolume.I | 117 +- panda/src/mathutil/boundingVolume.cxx | 433 +- panda/src/mathutil/boundingVolume.h | 87 +- panda/src/mathutil/config_mathutil.cxx | 39 +- panda/src/mathutil/config_mathutil.h | 27 +- panda/src/mathutil/fftCompressor.cxx | 488 +- panda/src/mathutil/fftCompressor.h | 62 +- panda/src/mathutil/finiteBoundingVolume.cxx | 78 +- panda/src/mathutil/finiteBoundingVolume.h | 55 +- panda/src/mathutil/frustum.h | 30 +- panda/src/mathutil/frustum_src.I | 133 +- panda/src/mathutil/frustum_src.h | 32 +- panda/src/mathutil/geometricBoundingVolume.I | 102 +- .../src/mathutil/geometricBoundingVolume.cxx | 85 +- panda/src/mathutil/geometricBoundingVolume.h | 46 +- .../src/mathutil/intersectionBoundingVolume.I | 51 +- .../mathutil/intersectionBoundingVolume.cxx | 264 +- .../src/mathutil/intersectionBoundingVolume.h | 42 +- panda/src/mathutil/linmath_events.cxx | 25 +- panda/src/mathutil/linmath_events.h | 37 +- panda/src/mathutil/look_at.cxx | 25 +- panda/src/mathutil/look_at.h | 27 +- panda/src/mathutil/look_at_src.I | 26 +- panda/src/mathutil/look_at_src.cxx | 171 +- panda/src/mathutil/look_at_src.h | 46 +- panda/src/mathutil/mersenne.h | 37 +- panda/src/mathutil/omniBoundingVolume.I | 33 +- panda/src/mathutil/omniBoundingVolume.cxx | 185 +- panda/src/mathutil/omniBoundingVolume.h | 33 +- panda/src/mathutil/parabola.cxx | 25 +- panda/src/mathutil/parabola.h | 25 +- panda/src/mathutil/parabola_src.I | 111 +- panda/src/mathutil/parabola_src.cxx | 99 +- panda/src/mathutil/parabola_src.h | 42 +- panda/src/mathutil/perlinNoise.I | 62 +- panda/src/mathutil/perlinNoise.cxx | 66 +- panda/src/mathutil/perlinNoise.h | 37 +- panda/src/mathutil/perlinNoise2.I | 155 +- panda/src/mathutil/perlinNoise2.cxx | 60 +- panda/src/mathutil/perlinNoise2.h | 40 +- panda/src/mathutil/perlinNoise3.I | 155 +- panda/src/mathutil/perlinNoise3.cxx | 74 +- panda/src/mathutil/perlinNoise3.h | 40 +- panda/src/mathutil/plane.cxx | 25 +- panda/src/mathutil/plane.h | 25 +- panda/src/mathutil/plane_src.I | 206 +- panda/src/mathutil/plane_src.cxx | 138 +- panda/src/mathutil/plane_src.h | 34 +- panda/src/mathutil/pta_LMatrix3.cxx | 25 +- panda/src/mathutil/pta_LMatrix3.h | 53 +- panda/src/mathutil/pta_LMatrix3_ext.h | 25 +- panda/src/mathutil/pta_LMatrix4.cxx | 25 +- panda/src/mathutil/pta_LMatrix4.h | 67 +- panda/src/mathutil/pta_LMatrix4_ext.h | 25 +- panda/src/mathutil/pta_LVecBase2.cxx | 25 +- panda/src/mathutil/pta_LVecBase2.h | 67 +- panda/src/mathutil/pta_LVecBase2_ext.h | 25 +- panda/src/mathutil/pta_LVecBase3.cxx | 25 +- panda/src/mathutil/pta_LVecBase3.h | 67 +- panda/src/mathutil/pta_LVecBase3_ext.h | 25 +- panda/src/mathutil/pta_LVecBase4.cxx | 25 +- panda/src/mathutil/pta_LVecBase4.h | 88 +- panda/src/mathutil/pta_LVecBase4_ext.h | 25 +- panda/src/mathutil/randomizer.I | 96 +- panda/src/mathutil/randomizer.cxx | 26 +- panda/src/mathutil/randomizer.h | 32 +- panda/src/mathutil/rotate_to.cxx | 25 +- panda/src/mathutil/rotate_to.h | 40 +- panda/src/mathutil/rotate_to_src.cxx | 40 +- panda/src/mathutil/stackedPerlinNoise2.I | 77 +- panda/src/mathutil/stackedPerlinNoise2.cxx | 91 +- panda/src/mathutil/stackedPerlinNoise2.h | 36 +- panda/src/mathutil/stackedPerlinNoise3.I | 77 +- panda/src/mathutil/stackedPerlinNoise3.cxx | 91 +- panda/src/mathutil/stackedPerlinNoise3.h | 36 +- panda/src/mathutil/test_mathutil.cxx | 25 +- panda/src/mathutil/test_tri.cxx | 29 +- panda/src/mathutil/triangulator.I | 95 +- panda/src/mathutil/triangulator.cxx | 492 +- panda/src/mathutil/triangulator.h | 72 +- panda/src/mathutil/triangulator3.I | 68 +- panda/src/mathutil/triangulator3.cxx | 83 +- panda/src/mathutil/triangulator3.h | 39 +- panda/src/mathutil/unionBoundingVolume.I | 50 +- panda/src/mathutil/unionBoundingVolume.cxx | 280 +- panda/src/mathutil/unionBoundingVolume.h | 41 +- panda/src/movies/config_movies.cxx | 39 +- panda/src/movies/config_movies.h | 25 +- panda/src/movies/inkblotVideo.I | 26 +- panda/src/movies/inkblotVideo.cxx | 49 +- panda/src/movies/inkblotVideo.h | 33 +- panda/src/movies/inkblotVideoCursor.I | 26 +- panda/src/movies/inkblotVideoCursor.cxx | 68 +- panda/src/movies/inkblotVideoCursor.h | 37 +- panda/src/movies/microphoneAudio.I | 42 +- panda/src/movies/microphoneAudio.cxx | 80 +- panda/src/movies/microphoneAudio.h | 38 +- panda/src/movies/microphoneAudioDS.cxx | 123 +- panda/src/movies/movieAudio.I | 37 +- panda/src/movies/movieAudio.cxx | 64 +- panda/src/movies/movieAudio.h | 46 +- panda/src/movies/movieAudioCursor.I | 146 +- panda/src/movies/movieAudioCursor.cxx | 190 +- panda/src/movies/movieAudioCursor.h | 52 +- panda/src/movies/movieTypeRegistry.I | 37 +- panda/src/movies/movieTypeRegistry.cxx | 109 +- panda/src/movies/movieTypeRegistry.h | 36 +- panda/src/movies/movieVideo.I | 48 +- panda/src/movies/movieVideo.cxx | 100 +- panda/src/movies/movieVideo.h | 48 +- panda/src/movies/movieVideoCursor.I | 194 +- panda/src/movies/movieVideoCursor.cxx | 249 +- panda/src/movies/movieVideoCursor.h | 56 +- panda/src/movies/userDataAudio.I | 26 +- panda/src/movies/userDataAudio.cxx | 110 +- panda/src/movies/userDataAudio.h | 46 +- panda/src/movies/userDataAudioCursor.I | 26 +- panda/src/movies/userDataAudioCursor.cxx | 73 +- panda/src/movies/userDataAudioCursor.h | 36 +- panda/src/movies/vorbisAudio.I | 26 +- panda/src/movies/vorbisAudio.cxx | 57 +- panda/src/movies/vorbisAudio.h | 36 +- panda/src/movies/vorbisAudioCursor.I | 26 +- panda/src/movies/vorbisAudioCursor.cxx | 111 +- panda/src/movies/vorbisAudioCursor.h | 34 +- panda/src/movies/wavAudio.I | 26 +- panda/src/movies/wavAudio.cxx | 57 +- panda/src/movies/wavAudio.h | 36 +- panda/src/movies/wavAudioCursor.I | 26 +- panda/src/movies/wavAudioCursor.cxx | 82 +- panda/src/movies/wavAudioCursor.h | 34 +- .../nativenet/buffered_datagramconnection.cxx | 34 +- .../nativenet/buffered_datagramconnection.h | 107 +- panda/src/nativenet/buffered_datagramreader.I | 73 +- panda/src/nativenet/buffered_datagramreader.h | 9 +- panda/src/nativenet/buffered_datagramwriter.h | 58 +- panda/src/nativenet/config_nativenet.cxx | 40 +- panda/src/nativenet/config_nativenet.h | 26 +- panda/src/nativenet/membuffer.I | 81 +- panda/src/nativenet/membuffer.h | 14 - panda/src/nativenet/ringbuffer.I | 224 +- panda/src/nativenet/ringbuffer.h | 12 - panda/src/nativenet/socket_address.I | 193 +- panda/src/nativenet/socket_address.h | 23 +- panda/src/nativenet/socket_base.h | 2 - panda/src/nativenet/socket_fdset.h | 95 +- panda/src/nativenet/socket_ip.cxx | 25 +- panda/src/nativenet/socket_ip.h | 130 +- panda/src/nativenet/socket_portable.h | 27 +- panda/src/nativenet/socket_selector.h | 39 +- panda/src/nativenet/socket_tcp.cxx | 25 +- panda/src/nativenet/socket_tcp.h | 111 +- panda/src/nativenet/socket_tcp_listen.cxx | 25 +- panda/src/nativenet/socket_tcp_listen.h | 21 +- panda/src/nativenet/socket_tcp_ssl.cxx | 25 +- panda/src/nativenet/socket_tcp_ssl.h | 114 +- panda/src/nativenet/socket_udp.cxx | 25 +- panda/src/nativenet/socket_udp.h | 86 +- panda/src/nativenet/socket_udp_incoming.cxx | 25 +- panda/src/nativenet/socket_udp_incoming.h | 61 +- panda/src/nativenet/socket_udp_outgoing.cxx | 25 +- panda/src/nativenet/socket_udp_outgoing.h | 61 +- panda/src/nativenet/time_accumulator.h | 59 +- panda/src/nativenet/time_base.h | 67 +- panda/src/nativenet/time_clock.h | 225 +- panda/src/nativenet/time_general.h | 77 +- panda/src/nativenet/time_out.h | 69 +- panda/src/nativenet/time_span.h | 229 +- panda/src/net/config_net.cxx | 55 +- panda/src/net/config_net.h | 26 +- panda/src/net/connection.cxx | 352 +- panda/src/net/connection.h | 36 +- panda/src/net/connectionListener.cxx | 59 +- panda/src/net/connectionListener.h | 44 +- panda/src/net/connectionManager.cxx | 498 +- panda/src/net/connectionManager.h | 58 +- panda/src/net/connectionReader.I | 35 +- panda/src/net/connectionReader.cxx | 545 +- panda/src/net/connectionReader.h | 107 +- panda/src/net/connectionWriter.cxx | 297 +- panda/src/net/connectionWriter.h | 47 +- panda/src/net/datagramGeneratorNet.I | 26 +- panda/src/net/datagramGeneratorNet.cxx | 96 +- panda/src/net/datagramGeneratorNet.h | 38 +- panda/src/net/datagramQueue.cxx | 158 +- panda/src/net/datagramQueue.h | 37 +- panda/src/net/datagramSinkNet.I | 45 +- panda/src/net/datagramSinkNet.cxx | 70 +- panda/src/net/datagramSinkNet.h | 34 +- panda/src/net/datagramTCPHeader.I | 37 +- panda/src/net/datagramTCPHeader.cxx | 74 +- panda/src/net/datagramTCPHeader.h | 47 +- panda/src/net/datagramUDPHeader.I | 46 +- panda/src/net/datagramUDPHeader.cxx | 61 +- panda/src/net/datagramUDPHeader.h | 47 +- panda/src/net/datagram_ui.cxx | 25 +- panda/src/net/datagram_ui.h | 43 +- panda/src/net/fake_http_server.cxx | 30 +- panda/src/net/netAddress.cxx | 184 +- panda/src/net/netAddress.h | 35 +- panda/src/net/netDatagram.I | 49 +- panda/src/net/netDatagram.cxx | 121 +- panda/src/net/netDatagram.h | 54 +- panda/src/net/queuedConnectionListener.I | 49 +- panda/src/net/queuedConnectionListener.cxx | 117 +- panda/src/net/queuedConnectionListener.h | 40 +- panda/src/net/queuedConnectionManager.cxx | 126 +- panda/src/net/queuedConnectionManager.h | 50 +- panda/src/net/queuedConnectionReader.cxx | 161 +- panda/src/net/queuedConnectionReader.h | 43 +- panda/src/net/queuedReturn.I | 160 +- panda/src/net/queuedReturn.h | 38 +- panda/src/net/recentConnectionReader.cxx | 113 +- panda/src/net/recentConnectionReader.h | 47 +- panda/src/net/test_datagram.cxx | 25 +- panda/src/net/test_raw_server.cxx | 30 +- panda/src/net/test_spam_client.cxx | 30 +- panda/src/net/test_spam_server.cxx | 30 +- panda/src/net/test_tcp_client.cxx | 30 +- panda/src/net/test_tcp_server.cxx | 30 +- panda/src/net/test_udp.cxx | 30 +- panda/src/ode/config_ode.cxx | 43 +- panda/src/ode/config_ode.h | 25 +- panda/src/ode/odeAMotorJoint.I | 26 +- panda/src/ode/odeAMotorJoint.cxx | 31 +- panda/src/ode/odeAMotorJoint.h | 21 +- panda/src/ode/odeBallJoint.I | 25 +- panda/src/ode/odeBallJoint.cxx | 31 +- panda/src/ode/odeBallJoint.h | 21 +- panda/src/ode/odeBody.I | 46 +- panda/src/ode/odeBody.cxx | 27 +- panda/src/ode/odeBody.h | 48 +- panda/src/ode/odeBody_ext.I | 33 +- panda/src/ode/odeBody_ext.h | 35 +- panda/src/ode/odeBoxGeom.I | 26 +- panda/src/ode/odeBoxGeom.cxx | 25 +- panda/src/ode/odeBoxGeom.h | 32 +- panda/src/ode/odeCappedCylinderGeom.I | 25 +- panda/src/ode/odeCappedCylinderGeom.cxx | 25 +- panda/src/ode/odeCappedCylinderGeom.h | 32 +- panda/src/ode/odeCollisionEntry.I | 118 +- panda/src/ode/odeCollisionEntry.cxx | 34 +- panda/src/ode/odeCollisionEntry.h | 40 +- panda/src/ode/odeContact.I | 27 +- panda/src/ode/odeContact.cxx | 29 +- panda/src/ode/odeContact.h | 32 +- panda/src/ode/odeContactGeom.I | 25 +- panda/src/ode/odeContactGeom.cxx | 32 +- panda/src/ode/odeContactGeom.h | 42 +- panda/src/ode/odeContactJoint.I | 25 +- panda/src/ode/odeContactJoint.cxx | 31 +- panda/src/ode/odeContactJoint.h | 21 +- panda/src/ode/odeConvexGeom.I | 26 +- panda/src/ode/odeConvexGeom.cxx | 25 +- panda/src/ode/odeConvexGeom.h | 32 +- panda/src/ode/odeCylinderGeom.I | 25 +- panda/src/ode/odeCylinderGeom.cxx | 25 +- panda/src/ode/odeCylinderGeom.h | 32 +- panda/src/ode/odeFixedJoint.I | 25 +- panda/src/ode/odeFixedJoint.cxx | 31 +- panda/src/ode/odeFixedJoint.h | 21 +- panda/src/ode/odeGeom.I | 46 +- panda/src/ode/odeGeom.cxx | 48 +- panda/src/ode/odeGeom.h | 47 +- panda/src/ode/odeGeom_ext.I | 41 +- panda/src/ode/odeGeom_ext.cxx | 60 +- panda/src/ode/odeGeom_ext.h | 35 +- panda/src/ode/odeHashSpace.I | 25 +- panda/src/ode/odeHashSpace.cxx | 26 +- panda/src/ode/odeHashSpace.h | 33 +- panda/src/ode/odeHeightFieldGeom.h | 32 +- panda/src/ode/odeHelperStructs.h | 2 +- panda/src/ode/odeHinge2Joint.I | 27 +- panda/src/ode/odeHinge2Joint.cxx | 31 +- panda/src/ode/odeHinge2Joint.h | 22 +- panda/src/ode/odeHingeJoint.I | 26 +- panda/src/ode/odeHingeJoint.cxx | 31 +- panda/src/ode/odeHingeJoint.h | 21 +- panda/src/ode/odeJoint.I | 46 +- panda/src/ode/odeJoint.cxx | 57 +- panda/src/ode/odeJoint.h | 32 +- panda/src/ode/odeJointCollection.I | 52 +- panda/src/ode/odeJointCollection.cxx | 41 +- panda/src/ode/odeJointCollection.h | 36 +- panda/src/ode/odeJointGroup.I | 25 +- panda/src/ode/odeJointGroup.cxx | 25 +- panda/src/ode/odeJointGroup.h | 33 +- panda/src/ode/odeJoint_ext.cxx | 49 +- panda/src/ode/odeJoint_ext.h | 35 +- panda/src/ode/odeLMotorJoint.I | 27 +- panda/src/ode/odeLMotorJoint.cxx | 31 +- panda/src/ode/odeLMotorJoint.h | 21 +- panda/src/ode/odeMass.I | 31 +- panda/src/ode/odeMass.cxx | 35 +- panda/src/ode/odeMass.h | 34 +- panda/src/ode/odeNullJoint.I | 25 +- panda/src/ode/odeNullJoint.cxx | 31 +- panda/src/ode/odeNullJoint.h | 22 +- panda/src/ode/odePlane2dJoint.I | 25 +- panda/src/ode/odePlane2dJoint.cxx | 31 +- panda/src/ode/odePlane2dJoint.h | 21 +- panda/src/ode/odePlaneGeom.I | 25 +- panda/src/ode/odePlaneGeom.cxx | 25 +- panda/src/ode/odePlaneGeom.h | 32 +- panda/src/ode/odeQuadTreeSpace.I | 26 +- panda/src/ode/odeQuadTreeSpace.cxx | 26 +- panda/src/ode/odeQuadTreeSpace.h | 33 +- panda/src/ode/odeRayGeom.I | 26 +- panda/src/ode/odeRayGeom.cxx | 25 +- panda/src/ode/odeRayGeom.h | 32 +- panda/src/ode/odeSimpleSpace.I | 25 +- panda/src/ode/odeSimpleSpace.cxx | 26 +- panda/src/ode/odeSimpleSpace.h | 33 +- panda/src/ode/odeSliderJoint.I | 26 +- panda/src/ode/odeSliderJoint.cxx | 31 +- panda/src/ode/odeSliderJoint.h | 21 +- panda/src/ode/odeSpace.I | 47 +- panda/src/ode/odeSpace.cxx | 38 +- panda/src/ode/odeSpace.h | 36 +- panda/src/ode/odeSpace_ext.I | 49 +- panda/src/ode/odeSpace_ext.cxx | 42 +- panda/src/ode/odeSpace_ext.h | 35 +- panda/src/ode/odeSphereGeom.I | 26 +- panda/src/ode/odeSphereGeom.cxx | 25 +- panda/src/ode/odeSphereGeom.h | 32 +- panda/src/ode/odeSurfaceParameters.I | 27 +- panda/src/ode/odeSurfaceParameters.cxx | 29 +- panda/src/ode/odeSurfaceParameters.h | 34 +- panda/src/ode/odeTriMeshData.I | 25 +- panda/src/ode/odeTriMeshData.cxx | 37 +- panda/src/ode/odeTriMeshData.h | 50 +- panda/src/ode/odeTriMeshGeom.I | 28 +- panda/src/ode/odeTriMeshGeom.cxx | 25 +- panda/src/ode/odeTriMeshGeom.h | 34 +- panda/src/ode/odeUniversalJoint.I | 26 +- panda/src/ode/odeUniversalJoint.cxx | 31 +- panda/src/ode/odeUniversalJoint.h | 22 +- panda/src/ode/odeUtil.cxx | 83 +- panda/src/ode/odeUtil.h | 32 +- panda/src/ode/odeUtil_ext.cxx | 36 +- panda/src/ode/odeUtil_ext.h | 35 +- panda/src/ode/odeWorld.I | 46 +- panda/src/ode/odeWorld.cxx | 57 +- panda/src/ode/odeWorld.h | 48 +- panda/src/ode/ode_includes.h | 31 +- panda/src/osxdisplay/config_osxdisplay.cxx | 37 +- panda/src/osxdisplay/config_osxdisplay.h | 22 +- panda/src/osxdisplay/osxGraphicsBuffer.cxx | 97 +- panda/src/osxdisplay/osxGraphicsBuffer.h | 30 +- panda/src/osxdisplay/osxGraphicsPipe.cxx | 144 +- panda/src/osxdisplay/osxGraphicsPipe.h | 32 +- .../osxdisplay/osxGraphicsStateGuardian.cxx | 177 +- .../src/osxdisplay/osxGraphicsStateGuardian.h | 36 +- panda/src/osxdisplay/osxGraphicsWindow.I | 34 +- panda/src/osxdisplay/osxGraphicsWindow.h | 36 +- panda/src/osxdisplay/osxGraphicsWindow.mm | 628 +-- panda/src/pandabase/pandabase.cxx | 25 +- panda/src/pandabase/pandabase.h | 12 +- panda/src/pandabase/pandasymbols.h | 11 +- panda/src/parametrics/config_parametrics.cxx | 25 +- panda/src/parametrics/config_parametrics.h | 25 +- panda/src/parametrics/cubicCurveseg.cxx | 352 +- panda/src/parametrics/cubicCurveseg.h | 91 +- panda/src/parametrics/curveFitter.I | 51 +- panda/src/parametrics/curveFitter.cxx | 255 +- panda/src/parametrics/curveFitter.h | 32 +- panda/src/parametrics/hermiteCurve.cxx | 465 +- panda/src/parametrics/hermiteCurve.h | 77 +- panda/src/parametrics/nurbsBasisVector.I | 128 +- panda/src/parametrics/nurbsBasisVector.cxx | 61 +- panda/src/parametrics/nurbsBasisVector.h | 49 +- panda/src/parametrics/nurbsCurve.I | 34 +- panda/src/parametrics/nurbsCurve.cxx | 358 +- panda/src/parametrics/nurbsCurve.h | 69 +- panda/src/parametrics/nurbsCurveEvaluator.I | 223 +- panda/src/parametrics/nurbsCurveEvaluator.cxx | 200 +- panda/src/parametrics/nurbsCurveEvaluator.h | 50 +- panda/src/parametrics/nurbsCurveInterface.I | 84 +- panda/src/parametrics/nurbsCurveInterface.cxx | 78 +- panda/src/parametrics/nurbsCurveInterface.h | 40 +- panda/src/parametrics/nurbsCurveResult.I | 179 +- panda/src/parametrics/nurbsCurveResult.cxx | 198 +- panda/src/parametrics/nurbsCurveResult.h | 59 +- panda/src/parametrics/nurbsSurfaceEvaluator.I | 306 +- .../src/parametrics/nurbsSurfaceEvaluator.cxx | 245 +- panda/src/parametrics/nurbsSurfaceEvaluator.h | 41 +- panda/src/parametrics/nurbsSurfaceResult.I | 201 +- panda/src/parametrics/nurbsSurfaceResult.cxx | 200 +- panda/src/parametrics/nurbsSurfaceResult.h | 45 +- panda/src/parametrics/nurbsVertex.I | 99 +- panda/src/parametrics/nurbsVertex.cxx | 75 +- panda/src/parametrics/nurbsVertex.h | 49 +- panda/src/parametrics/parametricCurve.cxx | 548 +- panda/src/parametrics/parametricCurve.h | 42 +- .../parametrics/parametricCurveCollection.I | 106 +- .../parametrics/parametricCurveCollection.cxx | 485 +- .../parametrics/parametricCurveCollection.h | 44 +- panda/src/parametrics/piecewiseCurve.cxx | 395 +- panda/src/parametrics/piecewiseCurve.h | 41 +- panda/src/parametrics/ropeNode.I | 407 +- panda/src/parametrics/ropeNode.cxx | 487 +- panda/src/parametrics/ropeNode.h | 82 +- panda/src/parametrics/sheetNode.I | 130 +- panda/src/parametrics/sheetNode.cxx | 267 +- panda/src/parametrics/sheetNode.h | 50 +- panda/src/parametrics/test_parametrics.cxx | 9 +- panda/src/particlesystem/arcEmitter.I | 66 +- panda/src/particlesystem/arcEmitter.cxx | 83 +- panda/src/particlesystem/arcEmitter.h | 33 +- panda/src/particlesystem/baseParticle.I | 25 +- panda/src/particlesystem/baseParticle.cxx | 76 +- panda/src/particlesystem/baseParticle.h | 35 +- .../src/particlesystem/baseParticleEmitter.I | 121 +- .../particlesystem/baseParticleEmitter.cxx | 77 +- .../src/particlesystem/baseParticleEmitter.h | 30 +- .../src/particlesystem/baseParticleFactory.I | 110 +- .../particlesystem/baseParticleFactory.cxx | 76 +- .../src/particlesystem/baseParticleFactory.h | 32 +- .../src/particlesystem/baseParticleRenderer.I | 96 +- .../particlesystem/baseParticleRenderer.cxx | 116 +- .../src/particlesystem/baseParticleRenderer.h | 40 +- panda/src/particlesystem/boxEmitter.I | 57 +- panda/src/particlesystem/boxEmitter.cxx | 91 +- panda/src/particlesystem/boxEmitter.h | 36 +- .../colorInterpolationManager.I | 241 +- .../colorInterpolationManager.cxx | 282 +- .../colorInterpolationManager.h | 143 +- .../particlesystem/config_particlesystem.cxx | 40 +- .../particlesystem/config_particlesystem.h | 25 +- panda/src/particlesystem/discEmitter.I | 121 +- panda/src/particlesystem/discEmitter.cxx | 91 +- panda/src/particlesystem/discEmitter.h | 33 +- panda/src/particlesystem/emitters.h | 25 +- .../src/particlesystem/geomParticleRenderer.I | 179 +- .../particlesystem/geomParticleRenderer.cxx | 135 +- .../src/particlesystem/geomParticleRenderer.h | 29 +- panda/src/particlesystem/lineEmitter.I | 57 +- panda/src/particlesystem/lineEmitter.cxx | 91 +- panda/src/particlesystem/lineEmitter.h | 36 +- .../src/particlesystem/lineParticleRenderer.I | 68 +- .../particlesystem/lineParticleRenderer.cxx | 124 +- .../src/particlesystem/lineParticleRenderer.h | 36 +- panda/src/particlesystem/orientedParticle.I | 39 +- panda/src/particlesystem/orientedParticle.cxx | 102 +- panda/src/particlesystem/orientedParticle.h | 34 +- .../particlesystem/orientedParticleFactory.I | 53 +- .../orientedParticleFactory.cxx | 83 +- .../particlesystem/orientedParticleFactory.h | 33 +- .../src/particlesystem/particleCommonFuncs.h | 45 +- panda/src/particlesystem/particleSystem.I | 375 +- panda/src/particlesystem/particleSystem.cxx | 184 +- panda/src/particlesystem/particleSystem.h | 47 +- .../particlesystem/particleSystemManager.I | 53 +- .../particlesystem/particleSystemManager.cxx | 117 +- .../particlesystem/particleSystemManager.h | 37 +- panda/src/particlesystem/particlefactories.h | 25 +- panda/src/particlesystem/particles.h | 25 +- panda/src/particlesystem/pointEmitter.I | 33 +- panda/src/particlesystem/pointEmitter.cxx | 91 +- panda/src/particlesystem/pointEmitter.h | 36 +- panda/src/particlesystem/pointParticle.cxx | 99 +- panda/src/particlesystem/pointParticle.h | 34 +- .../particlesystem/pointParticleFactory.cxx | 83 +- .../src/particlesystem/pointParticleFactory.h | 32 +- .../particlesystem/pointParticleRenderer.I | 95 +- .../particlesystem/pointParticleRenderer.cxx | 124 +- .../particlesystem/pointParticleRenderer.h | 35 +- panda/src/particlesystem/rectangleEmitter.I | 57 +- panda/src/particlesystem/rectangleEmitter.cxx | 91 +- panda/src/particlesystem/rectangleEmitter.h | 36 +- panda/src/particlesystem/ringEmitter.I | 92 +- panda/src/particlesystem/ringEmitter.cxx | 91 +- panda/src/particlesystem/ringEmitter.h | 33 +- .../particlesystem/sparkleParticleRenderer.I | 102 +- .../sparkleParticleRenderer.cxx | 124 +- .../particlesystem/sparkleParticleRenderer.h | 32 +- .../src/particlesystem/sphereSurfaceEmitter.I | 41 +- .../particlesystem/sphereSurfaceEmitter.cxx | 91 +- .../src/particlesystem/sphereSurfaceEmitter.h | 36 +- .../src/particlesystem/sphereVolumeEmitter.I | 41 +- .../particlesystem/sphereVolumeEmitter.cxx | 95 +- .../src/particlesystem/sphereVolumeEmitter.h | 36 +- .../particlesystem/spriteParticleRenderer.I | 395 +- .../particlesystem/spriteParticleRenderer.cxx | 332 +- .../particlesystem/spriteParticleRenderer.h | 63 +- panda/src/particlesystem/tangentRingEmitter.I | 53 +- .../src/particlesystem/tangentRingEmitter.cxx | 91 +- panda/src/particlesystem/tangentRingEmitter.h | 38 +- panda/src/particlesystem/zSpinParticle.I | 55 +- panda/src/particlesystem/zSpinParticle.cxx | 118 +- panda/src/particlesystem/zSpinParticle.h | 43 +- .../src/particlesystem/zSpinParticleFactory.I | 88 +- .../particlesystem/zSpinParticleFactory.cxx | 83 +- .../src/particlesystem/zSpinParticleFactory.h | 32 +- panda/src/pgraph/accumulatedAttribs.I | 26 +- panda/src/pgraph/accumulatedAttribs.cxx | 121 +- panda/src/pgraph/accumulatedAttribs.h | 43 +- panda/src/pgraph/alphaTestAttrib.I | 51 +- panda/src/pgraph/alphaTestAttrib.cxx | 146 +- panda/src/pgraph/alphaTestAttrib.h | 35 +- panda/src/pgraph/antialiasAttrib.I | 69 +- panda/src/pgraph/antialiasAttrib.cxx | 240 +- panda/src/pgraph/antialiasAttrib.h | 37 +- panda/src/pgraph/attribNodeRegistry.I | 58 +- panda/src/pgraph/attribNodeRegistry.cxx | 201 +- panda/src/pgraph/attribNodeRegistry.h | 52 +- panda/src/pgraph/audioVolumeAttrib.I | 69 +- panda/src/pgraph/audioVolumeAttrib.cxx | 235 +- panda/src/pgraph/audioVolumeAttrib.h | 34 +- panda/src/pgraph/auxBitplaneAttrib.I | 44 +- panda/src/pgraph/auxBitplaneAttrib.cxx | 156 +- panda/src/pgraph/auxBitplaneAttrib.h | 99 +- panda/src/pgraph/auxSceneData.I | 91 +- panda/src/pgraph/auxSceneData.cxx | 41 +- panda/src/pgraph/auxSceneData.h | 46 +- panda/src/pgraph/bamFile.I | 49 +- panda/src/pgraph/bamFile.cxx | 311 +- panda/src/pgraph/bamFile.h | 52 +- panda/src/pgraph/billboardEffect.I | 151 +- panda/src/pgraph/billboardEffect.cxx | 285 +- panda/src/pgraph/billboardEffect.h | 42 +- panda/src/pgraph/cacheStats.I | 92 +- panda/src/pgraph/cacheStats.cxx | 61 +- panda/src/pgraph/cacheStats.h | 35 +- panda/src/pgraph/camera.I | 279 +- panda/src/pgraph/camera.cxx | 284 +- panda/src/pgraph/camera.h | 35 +- panda/src/pgraph/clipPlaneAttrib.I | 139 +- panda/src/pgraph/clipPlaneAttrib.cxx | 629 +-- panda/src/pgraph/clipPlaneAttrib.h | 60 +- panda/src/pgraph/colorAttrib.I | 71 +- panda/src/pgraph/colorAttrib.cxx | 185 +- panda/src/pgraph/colorAttrib.h | 36 +- panda/src/pgraph/colorBlendAttrib.I | 115 +- panda/src/pgraph/colorBlendAttrib.cxx | 187 +- panda/src/pgraph/colorBlendAttrib.h | 48 +- panda/src/pgraph/colorScaleAttrib.I | 102 +- panda/src/pgraph/colorScaleAttrib.cxx | 312 +- panda/src/pgraph/colorScaleAttrib.h | 36 +- panda/src/pgraph/colorWriteAttrib.I | 44 +- panda/src/pgraph/colorWriteAttrib.cxx | 138 +- panda/src/pgraph/colorWriteAttrib.h | 40 +- panda/src/pgraph/compassEffect.I | 57 +- panda/src/pgraph/compassEffect.cxx | 242 +- panda/src/pgraph/compassEffect.h | 84 +- panda/src/pgraph/config_pgraph.cxx | 45 +- panda/src/pgraph/config_pgraph.h | 25 +- panda/src/pgraph/cullBin.I | 60 +- panda/src/pgraph/cullBin.cxx | 126 +- panda/src/pgraph/cullBin.h | 47 +- panda/src/pgraph/cullBinAttrib.I | 59 +- panda/src/pgraph/cullBinAttrib.cxx | 148 +- panda/src/pgraph/cullBinAttrib.h | 38 +- panda/src/pgraph/cullBinEnums.h | 35 +- panda/src/pgraph/cullBinManager.I | 339 +- panda/src/pgraph/cullBinManager.cxx | 187 +- panda/src/pgraph/cullBinManager.h | 40 +- panda/src/pgraph/cullFaceAttrib.I | 63 +- panda/src/pgraph/cullFaceAttrib.cxx | 238 +- panda/src/pgraph/cullFaceAttrib.h | 36 +- panda/src/pgraph/cullHandler.I | 38 +- panda/src/pgraph/cullHandler.cxx | 70 +- panda/src/pgraph/cullHandler.h | 42 +- panda/src/pgraph/cullPlanes.I | 67 +- panda/src/pgraph/cullPlanes.cxx | 202 +- panda/src/pgraph/cullPlanes.h | 58 +- panda/src/pgraph/cullResult.I | 72 +- panda/src/pgraph/cullResult.cxx | 307 +- panda/src/pgraph/cullResult.h | 45 +- panda/src/pgraph/cullTraverser.I | 264 +- panda/src/pgraph/cullTraverser.cxx | 209 +- panda/src/pgraph/cullTraverser.h | 39 +- panda/src/pgraph/cullTraverserData.I | 159 +- panda/src/pgraph/cullTraverserData.cxx | 116 +- panda/src/pgraph/cullTraverserData.h | 49 +- panda/src/pgraph/cullableObject.I | 142 +- panda/src/pgraph/cullableObject.cxx | 231 +- panda/src/pgraph/cullableObject.h | 35 +- panda/src/pgraph/decalEffect.I | 35 +- panda/src/pgraph/decalEffect.cxx | 117 +- panda/src/pgraph/decalEffect.h | 38 +- panda/src/pgraph/depthOffsetAttrib.I | 65 +- panda/src/pgraph/depthOffsetAttrib.cxx | 202 +- panda/src/pgraph/depthOffsetAttrib.h | 88 +- panda/src/pgraph/depthTestAttrib.I | 43 +- panda/src/pgraph/depthTestAttrib.cxx | 138 +- panda/src/pgraph/depthTestAttrib.h | 35 +- panda/src/pgraph/depthWriteAttrib.I | 43 +- panda/src/pgraph/depthWriteAttrib.cxx | 138 +- panda/src/pgraph/depthWriteAttrib.h | 35 +- panda/src/pgraph/findApproxLevelEntry.I | 81 +- panda/src/pgraph/findApproxLevelEntry.cxx | 125 +- panda/src/pgraph/findApproxLevelEntry.h | 52 +- panda/src/pgraph/findApproxPath.I | 111 +- panda/src/pgraph/findApproxPath.cxx | 197 +- panda/src/pgraph/findApproxPath.h | 41 +- panda/src/pgraph/fog.I | 273 +- panda/src/pgraph/fog.cxx | 160 +- panda/src/pgraph/fog.h | 61 +- panda/src/pgraph/fogAttrib.I | 56 +- panda/src/pgraph/fogAttrib.cxx | 173 +- panda/src/pgraph/fogAttrib.h | 35 +- panda/src/pgraph/geomDrawCallbackData.I | 97 +- panda/src/pgraph/geomDrawCallbackData.cxx | 60 +- panda/src/pgraph/geomDrawCallbackData.h | 37 +- panda/src/pgraph/geomNode.I | 338 +- panda/src/pgraph/geomNode.cxx | 660 +-- panda/src/pgraph/geomNode.h | 54 +- panda/src/pgraph/geomTransformer.I | 108 +- panda/src/pgraph/geomTransformer.cxx | 770 ++- panda/src/pgraph/geomTransformer.h | 98 +- panda/src/pgraph/internalNameCollection.I | 52 +- panda/src/pgraph/internalNameCollection.cxx | 185 +- panda/src/pgraph/internalNameCollection.h | 34 +- panda/src/pgraph/lensNode.I | 109 +- panda/src/pgraph/lensNode.cxx | 204 +- panda/src/pgraph/lensNode.h | 41 +- panda/src/pgraph/light.I | 156 +- panda/src/pgraph/light.cxx | 196 +- panda/src/pgraph/light.h | 56 +- panda/src/pgraph/lightAttrib.I | 139 +- panda/src/pgraph/lightAttrib.cxx | 622 +-- panda/src/pgraph/lightAttrib.h | 59 +- panda/src/pgraph/lightRampAttrib.I | 59 +- panda/src/pgraph/lightRampAttrib.cxx | 308 +- panda/src/pgraph/lightRampAttrib.h | 51 +- panda/src/pgraph/loader.I | 250 +- panda/src/pgraph/loader.cxx | 180 +- panda/src/pgraph/loader.h | 51 +- panda/src/pgraph/loaderFileType.cxx | 134 +- panda/src/pgraph/loaderFileType.h | 38 +- panda/src/pgraph/loaderFileTypeBam.cxx | 100 +- panda/src/pgraph/loaderFileTypeBam.h | 33 +- panda/src/pgraph/loaderFileTypeRegistry.cxx | 137 +- panda/src/pgraph/loaderFileTypeRegistry.h | 34 +- panda/src/pgraph/materialAttrib.I | 57 +- panda/src/pgraph/materialAttrib.cxx | 175 +- panda/src/pgraph/materialAttrib.h | 40 +- panda/src/pgraph/materialCollection.I | 52 +- panda/src/pgraph/materialCollection.cxx | 196 +- panda/src/pgraph/materialCollection.h | 34 +- panda/src/pgraph/modelFlattenRequest.I | 66 +- panda/src/pgraph/modelFlattenRequest.cxx | 38 +- panda/src/pgraph/modelFlattenRequest.h | 52 +- panda/src/pgraph/modelLoadRequest.I | 78 +- panda/src/pgraph/modelLoadRequest.cxx | 45 +- panda/src/pgraph/modelLoadRequest.h | 51 +- panda/src/pgraph/modelNode.I | 139 +- panda/src/pgraph/modelNode.cxx | 237 +- panda/src/pgraph/modelNode.h | 51 +- panda/src/pgraph/modelPool.I | 221 +- panda/src/pgraph/modelPool.cxx | 141 +- panda/src/pgraph/modelPool.h | 64 +- panda/src/pgraph/modelRoot.I | 170 +- panda/src/pgraph/modelRoot.cxx | 81 +- panda/src/pgraph/modelRoot.h | 42 +- panda/src/pgraph/modelSaveRequest.I | 86 +- panda/src/pgraph/modelSaveRequest.cxx | 45 +- panda/src/pgraph/modelSaveRequest.h | 51 +- panda/src/pgraph/nodePath.I | 2212 ++++---- panda/src/pgraph/nodePath.cxx | 4545 +++++++---------- panda/src/pgraph/nodePath.h | 232 +- panda/src/pgraph/nodePathCollection.I | 113 +- panda/src/pgraph/nodePathCollection.cxx | 482 +- panda/src/pgraph/nodePathCollection.h | 39 +- panda/src/pgraph/nodePathCollection_ext.cxx | 79 +- panda/src/pgraph/nodePathCollection_ext.h | 35 +- panda/src/pgraph/nodePathComponent.I | 90 +- panda/src/pgraph/nodePathComponent.cxx | 147 +- panda/src/pgraph/nodePathComponent.h | 71 +- panda/src/pgraph/nodePath_ext.I | 149 +- panda/src/pgraph/nodePath_ext.cxx | 159 +- panda/src/pgraph/nodePath_ext.h | 35 +- panda/src/pgraph/occluderEffect.I | 85 +- panda/src/pgraph/occluderEffect.cxx | 175 +- panda/src/pgraph/occluderEffect.h | 45 +- panda/src/pgraph/occluderNode.I | 93 +- panda/src/pgraph/occluderNode.cxx | 269 +- panda/src/pgraph/occluderNode.h | 40 +- panda/src/pgraph/pandaNode.I | 1654 +++--- panda/src/pgraph/pandaNode.cxx | 2984 +++++------ panda/src/pgraph/pandaNode.h | 194 +- panda/src/pgraph/pandaNodeChain.I | 42 +- panda/src/pgraph/pandaNodeChain.cxx | 25 +- panda/src/pgraph/pandaNodeChain.h | 38 +- panda/src/pgraph/pandaNode_ext.cxx | 159 +- panda/src/pgraph/pandaNode_ext.h | 35 +- panda/src/pgraph/paramNodePath.I | 60 +- panda/src/pgraph/paramNodePath.cxx | 87 +- panda/src/pgraph/paramNodePath.h | 32 +- panda/src/pgraph/planeNode.I | 170 +- panda/src/pgraph/planeNode.cxx | 233 +- panda/src/pgraph/planeNode.h | 44 +- panda/src/pgraph/polylightEffect.I | 71 +- panda/src/pgraph/polylightEffect.cxx | 292 +- panda/src/pgraph/polylightEffect.h | 46 +- panda/src/pgraph/polylightNode.I | 364 +- panda/src/pgraph/polylightNode.cxx | 174 +- panda/src/pgraph/polylightNode.h | 46 +- panda/src/pgraph/portalClipper.I | 203 +- panda/src/pgraph/portalClipper.cxx | 160 +- panda/src/pgraph/portalClipper.h | 51 +- panda/src/pgraph/portalNode.I | 263 +- panda/src/pgraph/portalNode.cxx | 297 +- panda/src/pgraph/portalNode.h | 45 +- panda/src/pgraph/renderAttrib.I | 173 +- panda/src/pgraph/renderAttrib.cxx | 526 +- panda/src/pgraph/renderAttrib.h | 158 +- panda/src/pgraph/renderAttribRegistry.I | 163 +- panda/src/pgraph/renderAttribRegistry.cxx | 115 +- panda/src/pgraph/renderAttribRegistry.h | 51 +- panda/src/pgraph/renderEffect.I | 50 +- panda/src/pgraph/renderEffect.cxx | 408 +- panda/src/pgraph/renderEffect.h | 69 +- panda/src/pgraph/renderEffects.I | 199 +- panda/src/pgraph/renderEffects.cxx | 624 +-- panda/src/pgraph/renderEffects.h | 59 +- panda/src/pgraph/renderModeAttrib.I | 99 +- panda/src/pgraph/renderModeAttrib.cxx | 202 +- panda/src/pgraph/renderModeAttrib.h | 45 +- panda/src/pgraph/renderState.I | 566 +- panda/src/pgraph/renderState.cxx | 1213 ++--- panda/src/pgraph/renderState.h | 113 +- panda/src/pgraph/renderState_ext.cxx | 98 +- panda/src/pgraph/renderState_ext.h | 35 +- panda/src/pgraph/rescaleNormalAttrib.I | 57 +- panda/src/pgraph/rescaleNormalAttrib.cxx | 167 +- panda/src/pgraph/rescaleNormalAttrib.h | 42 +- panda/src/pgraph/sceneGraphReducer.I | 232 +- panda/src/pgraph/sceneGraphReducer.cxx | 461 +- panda/src/pgraph/sceneGraphReducer.h | 109 +- panda/src/pgraph/sceneSetup.I | 297 +- panda/src/pgraph/sceneSetup.cxx | 25 +- panda/src/pgraph/sceneSetup.h | 35 +- panda/src/pgraph/scissorAttrib.I | 64 +- panda/src/pgraph/scissorAttrib.cxx | 192 +- panda/src/pgraph/scissorAttrib.h | 54 +- panda/src/pgraph/scissorEffect.I | 97 +- panda/src/pgraph/scissorEffect.cxx | 270 +- panda/src/pgraph/scissorEffect.h | 41 +- panda/src/pgraph/shadeModelAttrib.I | 43 +- panda/src/pgraph/shadeModelAttrib.cxx | 169 +- panda/src/pgraph/shadeModelAttrib.h | 37 +- panda/src/pgraph/shaderAttrib.I | 259 +- panda/src/pgraph/shaderAttrib.cxx | 348 +- panda/src/pgraph/shaderAttrib.h | 43 +- panda/src/pgraph/shaderInput.I | 340 +- panda/src/pgraph/shaderInput.cxx | 94 +- panda/src/pgraph/shaderInput.h | 39 +- panda/src/pgraph/shaderPool.I | 136 +- panda/src/pgraph/shaderPool.cxx | 120 +- panda/src/pgraph/shaderPool.h | 37 +- panda/src/pgraph/showBoundsEffect.I | 46 +- panda/src/pgraph/showBoundsEffect.cxx | 115 +- panda/src/pgraph/showBoundsEffect.h | 40 +- panda/src/pgraph/stateMunger.I | 34 +- panda/src/pgraph/stateMunger.cxx | 49 +- panda/src/pgraph/stateMunger.h | 38 +- panda/src/pgraph/stencilAttrib.I | 33 +- panda/src/pgraph/stencilAttrib.cxx | 180 +- panda/src/pgraph/stencilAttrib.h | 44 +- panda/src/pgraph/test_pgraph.cxx | 31 +- panda/src/pgraph/texGenAttrib.I | 74 +- panda/src/pgraph/texGenAttrib.cxx | 360 +- panda/src/pgraph/texGenAttrib.h | 67 +- panda/src/pgraph/texMatrixAttrib.I | 101 +- panda/src/pgraph/texMatrixAttrib.cxx | 356 +- panda/src/pgraph/texMatrixAttrib.h | 36 +- panda/src/pgraph/texProjectorEffect.I | 80 +- panda/src/pgraph/texProjectorEffect.cxx | 331 +- panda/src/pgraph/texProjectorEffect.h | 85 +- panda/src/pgraph/textureAttrib.I | 287 +- panda/src/pgraph/textureAttrib.cxx | 538 +- panda/src/pgraph/textureAttrib.h | 47 +- panda/src/pgraph/textureStageCollection.I | 62 +- panda/src/pgraph/textureStageCollection.cxx | 208 +- panda/src/pgraph/textureStageCollection.h | 34 +- panda/src/pgraph/transformState.I | 1090 ++-- panda/src/pgraph/transformState.cxx | 1255 ++--- panda/src/pgraph/transformState.h | 99 +- panda/src/pgraph/transformState_ext.cxx | 113 +- panda/src/pgraph/transformState_ext.h | 35 +- panda/src/pgraph/transparencyAttrib.I | 44 +- panda/src/pgraph/transparencyAttrib.cxx | 146 +- panda/src/pgraph/transparencyAttrib.h | 54 +- panda/src/pgraph/weakNodePath.I | 227 +- panda/src/pgraph/weakNodePath.cxx | 33 +- panda/src/pgraph/weakNodePath.h | 47 +- panda/src/pgraph/workingNodePath.I | 94 +- panda/src/pgraph/workingNodePath.cxx | 97 +- panda/src/pgraph/workingNodePath.h | 70 +- panda/src/pgraphnodes/ambientLight.I | 25 +- panda/src/pgraphnodes/ambientLight.cxx | 151 +- panda/src/pgraphnodes/ambientLight.h | 39 +- panda/src/pgraphnodes/callbackNode.I | 174 +- panda/src/pgraphnodes/callbackNode.cxx | 240 +- panda/src/pgraphnodes/callbackNode.h | 34 +- panda/src/pgraphnodes/computeNode.I | 94 +- panda/src/pgraphnodes/computeNode.cxx | 215 +- panda/src/pgraphnodes/computeNode.h | 35 +- panda/src/pgraphnodes/config_pgraphnodes.cxx | 39 +- panda/src/pgraphnodes/config_pgraphnodes.h | 25 +- panda/src/pgraphnodes/directionalLight.I | 118 +- panda/src/pgraphnodes/directionalLight.cxx | 206 +- panda/src/pgraphnodes/directionalLight.h | 34 +- panda/src/pgraphnodes/fadeLodNode.I | 78 +- panda/src/pgraphnodes/fadeLodNode.cxx | 292 +- panda/src/pgraphnodes/fadeLodNode.h | 34 +- panda/src/pgraphnodes/fadeLodNodeData.cxx | 33 +- panda/src/pgraphnodes/fadeLodNodeData.h | 37 +- panda/src/pgraphnodes/lightLensNode.I | 80 +- panda/src/pgraphnodes/lightLensNode.cxx | 126 +- panda/src/pgraphnodes/lightLensNode.h | 41 +- panda/src/pgraphnodes/lightNode.I | 25 +- panda/src/pgraphnodes/lightNode.cxx | 103 +- panda/src/pgraphnodes/lightNode.h | 40 +- panda/src/pgraphnodes/lodNode.I | 402 +- panda/src/pgraphnodes/lodNode.cxx | 617 +-- panda/src/pgraphnodes/lodNode.h | 49 +- panda/src/pgraphnodes/lodNodeType.cxx | 27 +- panda/src/pgraphnodes/lodNodeType.h | 27 +- panda/src/pgraphnodes/nodeCullCallbackData.I | 60 +- .../src/pgraphnodes/nodeCullCallbackData.cxx | 61 +- panda/src/pgraphnodes/nodeCullCallbackData.h | 35 +- panda/src/pgraphnodes/pointLight.I | 116 +- panda/src/pgraphnodes/pointLight.cxx | 206 +- panda/src/pgraphnodes/pointLight.h | 34 +- panda/src/pgraphnodes/sceneGraphAnalyzer.I | 266 +- panda/src/pgraphnodes/sceneGraphAnalyzer.cxx | 172 +- panda/src/pgraphnodes/sceneGraphAnalyzer.h | 34 +- panda/src/pgraphnodes/selectiveChildNode.I | 53 +- panda/src/pgraphnodes/selectiveChildNode.cxx | 88 +- panda/src/pgraphnodes/selectiveChildNode.h | 42 +- panda/src/pgraphnodes/sequenceNode.I | 47 +- panda/src/pgraphnodes/sequenceNode.cxx | 241 +- panda/src/pgraphnodes/sequenceNode.h | 34 +- panda/src/pgraphnodes/shaderGenerator.I | 26 +- panda/src/pgraphnodes/shaderGenerator.cxx | 257 +- panda/src/pgraphnodes/shaderGenerator.h | 84 +- panda/src/pgraphnodes/spotlight.I | 127 +- panda/src/pgraphnodes/spotlight.cxx | 259 +- panda/src/pgraphnodes/spotlight.h | 49 +- panda/src/pgraphnodes/switchNode.I | 60 +- panda/src/pgraphnodes/switchNode.cxx | 243 +- panda/src/pgraphnodes/switchNode.h | 34 +- panda/src/pgraphnodes/uvScrollNode.I | 118 +- panda/src/pgraphnodes/uvScrollNode.cxx | 150 +- panda/src/pgraphnodes/uvScrollNode.h | 35 +- panda/src/pgui/config_pgui.cxx | 39 +- panda/src/pgui/config_pgui.h | 25 +- panda/src/pgui/pgButton.I | 117 +- panda/src/pgui/pgButton.cxx | 193 +- panda/src/pgui/pgButton.h | 39 +- panda/src/pgui/pgButtonNotify.I | 34 +- panda/src/pgui/pgButtonNotify.cxx | 33 +- panda/src/pgui/pgButtonNotify.h | 35 +- panda/src/pgui/pgCullTraverser.I | 34 +- panda/src/pgui/pgCullTraverser.cxx | 25 +- panda/src/pgui/pgCullTraverser.h | 43 +- panda/src/pgui/pgEntry.I | 697 +-- panda/src/pgui/pgEntry.cxx | 517 +- panda/src/pgui/pgEntry.h | 63 +- panda/src/pgui/pgFrameStyle.I | 257 +- panda/src/pgui/pgFrameStyle.cxx | 436 +- panda/src/pgui/pgFrameStyle.h | 32 +- panda/src/pgui/pgItem.I | 585 +-- panda/src/pgui/pgItem.cxx | 836 ++- panda/src/pgui/pgItem.h | 53 +- panda/src/pgui/pgItemNotify.I | 34 +- panda/src/pgui/pgItemNotify.cxx | 191 +- panda/src/pgui/pgItemNotify.h | 35 +- panda/src/pgui/pgMouseWatcherBackground.cxx | 81 +- panda/src/pgui/pgMouseWatcherBackground.h | 37 +- panda/src/pgui/pgMouseWatcherGroup.I | 45 +- panda/src/pgui/pgMouseWatcherGroup.cxx | 37 +- panda/src/pgui/pgMouseWatcherGroup.h | 38 +- panda/src/pgui/pgMouseWatcherParameter.I | 50 +- panda/src/pgui/pgMouseWatcherParameter.cxx | 41 +- panda/src/pgui/pgMouseWatcherParameter.h | 48 +- panda/src/pgui/pgMouseWatcherRegion.I | 26 +- panda/src/pgui/pgMouseWatcherRegion.cxx | 149 +- panda/src/pgui/pgMouseWatcherRegion.h | 37 +- panda/src/pgui/pgScrollFrame.I | 227 +- panda/src/pgui/pgScrollFrame.cxx | 239 +- panda/src/pgui/pgScrollFrame.h | 54 +- panda/src/pgui/pgSliderBar.I | 459 +- panda/src/pgui/pgSliderBar.cxx | 466 +- panda/src/pgui/pgSliderBar.h | 41 +- panda/src/pgui/pgSliderBarNotify.I | 34 +- panda/src/pgui/pgSliderBarNotify.cxx | 44 +- panda/src/pgui/pgSliderBarNotify.h | 35 +- panda/src/pgui/pgTop.I | 109 +- panda/src/pgui/pgTop.cxx | 160 +- panda/src/pgui/pgTop.h | 51 +- panda/src/pgui/pgVirtualFrame.I | 104 +- panda/src/pgui/pgVirtualFrame.cxx | 144 +- panda/src/pgui/pgVirtualFrame.h | 69 +- panda/src/pgui/pgWaitBar.I | 102 +- panda/src/pgui/pgWaitBar.cxx | 133 +- panda/src/pgui/pgWaitBar.h | 37 +- panda/src/pgui/test_pgentry.cxx | 27 +- panda/src/physics/actorNode.I | 41 +- panda/src/physics/actorNode.cxx | 94 +- panda/src/physics/actorNode.h | 54 +- panda/src/physics/angularEulerIntegrator.cxx | 101 +- panda/src/physics/angularEulerIntegrator.h | 36 +- panda/src/physics/angularForce.cxx | 83 +- panda/src/physics/angularForce.h | 34 +- panda/src/physics/angularIntegrator.cxx | 69 +- panda/src/physics/angularIntegrator.h | 41 +- panda/src/physics/angularVectorForce.I | 46 +- panda/src/physics/angularVectorForce.cxx | 91 +- panda/src/physics/angularVectorForce.h | 36 +- panda/src/physics/baseForce.I | 53 +- panda/src/physics/baseForce.cxx | 67 +- panda/src/physics/baseForce.h | 33 +- panda/src/physics/baseIntegrator.I | 39 +- panda/src/physics/baseIntegrator.cxx | 105 +- panda/src/physics/baseIntegrator.h | 42 +- panda/src/physics/config_physics.cxx | 39 +- panda/src/physics/config_physics.h | 31 +- panda/src/physics/forceNode.I | 53 +- panda/src/physics/forceNode.cxx | 114 +- panda/src/physics/forceNode.h | 37 +- panda/src/physics/forces.h | 25 +- panda/src/physics/linearControlForce.I | 73 +- panda/src/physics/linearControlForce.cxx | 83 +- panda/src/physics/linearControlForce.h | 40 +- panda/src/physics/linearCylinderVortexForce.I | 67 +- .../src/physics/linearCylinderVortexForce.cxx | 104 +- panda/src/physics/linearCylinderVortexForce.h | 44 +- panda/src/physics/linearDistanceForce.I | 81 +- panda/src/physics/linearDistanceForce.cxx | 67 +- panda/src/physics/linearDistanceForce.h | 34 +- panda/src/physics/linearEulerIntegrator.cxx | 115 +- panda/src/physics/linearEulerIntegrator.h | 36 +- panda/src/physics/linearForce.I | 67 +- panda/src/physics/linearForce.cxx | 81 +- panda/src/physics/linearForce.h | 36 +- panda/src/physics/linearFrictionForce.I | 39 +- panda/src/physics/linearFrictionForce.cxx | 90 +- panda/src/physics/linearFrictionForce.h | 34 +- panda/src/physics/linearIntegrator.cxx | 74 +- panda/src/physics/linearIntegrator.h | 43 +- panda/src/physics/linearJitterForce.cxx | 83 +- panda/src/physics/linearJitterForce.h | 36 +- panda/src/physics/linearNoiseForce.I | 82 +- panda/src/physics/linearNoiseForce.cxx | 97 +- panda/src/physics/linearNoiseForce.h | 34 +- panda/src/physics/linearRandomForce.I | 34 +- panda/src/physics/linearRandomForce.cxx | 75 +- panda/src/physics/linearRandomForce.h | 34 +- panda/src/physics/linearSinkForce.cxx | 91 +- panda/src/physics/linearSinkForce.h | 34 +- panda/src/physics/linearSourceForce.cxx | 91 +- panda/src/physics/linearSourceForce.h | 34 +- panda/src/physics/linearUserDefinedForce.I | 32 +- panda/src/physics/linearUserDefinedForce.cxx | 83 +- panda/src/physics/linearUserDefinedForce.h | 45 +- panda/src/physics/linearVectorForce.I | 57 +- panda/src/physics/linearVectorForce.cxx | 91 +- panda/src/physics/linearVectorForce.h | 34 +- panda/src/physics/physical.I | 189 +- panda/src/physics/physical.cxx | 132 +- panda/src/physics/physical.h | 49 +- panda/src/physics/physicalNode.I | 53 +- panda/src/physics/physicalNode.cxx | 92 +- panda/src/physics/physicalNode.h | 33 +- panda/src/physics/physicsCollisionHandler.I | 28 +- panda/src/physics/physicsCollisionHandler.cxx | 98 +- panda/src/physics/physicsCollisionHandler.h | 47 +- panda/src/physics/physicsManager.I | 121 +- panda/src/physics/physicsManager.cxx | 180 +- panda/src/physics/physicsManager.h | 52 +- panda/src/physics/physicsObject.I | 270 +- panda/src/physics/physicsObject.cxx | 138 +- panda/src/physics/physicsObject.h | 44 +- panda/src/physics/physicsObjectCollection.I | 52 +- panda/src/physics/physicsObjectCollection.cxx | 199 +- panda/src/physics/physicsObjectCollection.h | 39 +- panda/src/physics/test_physics.cxx | 30 +- panda/src/physx/config_physx.cxx | 40 +- panda/src/physx/config_physx.h | 25 +- panda/src/physx/physxActor.I | 60 +- panda/src/physx/physxActor.cxx | 1489 +++--- panda/src/physx/physxActor.h | 60 +- panda/src/physx/physxActorDesc.I | 60 +- panda/src/physx/physxActorDesc.cxx | 139 +- panda/src/physx/physxActorDesc.h | 32 +- panda/src/physx/physxBodyDesc.I | 60 +- panda/src/physx/physxBodyDesc.cxx | 325 +- panda/src/physx/physxBodyDesc.h | 33 +- panda/src/physx/physxBounds3.I | 43 +- panda/src/physx/physxBounds3.cxx | 203 +- panda/src/physx/physxBounds3.h | 39 +- panda/src/physx/physxBox.I | 43 +- panda/src/physx/physxBox.cxx | 107 +- panda/src/physx/physxBox.h | 39 +- panda/src/physx/physxBoxController.I | 44 +- panda/src/physx/physxBoxController.cxx | 58 +- panda/src/physx/physxBoxController.h | 36 +- panda/src/physx/physxBoxControllerDesc.I | 60 +- panda/src/physx/physxBoxControllerDesc.cxx | 49 +- panda/src/physx/physxBoxControllerDesc.h | 32 +- panda/src/physx/physxBoxForceFieldShape.I | 44 +- panda/src/physx/physxBoxForceFieldShape.cxx | 81 +- panda/src/physx/physxBoxForceFieldShape.h | 32 +- panda/src/physx/physxBoxForceFieldShapeDesc.I | 60 +- .../src/physx/physxBoxForceFieldShapeDesc.cxx | 49 +- panda/src/physx/physxBoxForceFieldShapeDesc.h | 32 +- panda/src/physx/physxBoxShape.I | 44 +- panda/src/physx/physxBoxShape.cxx | 81 +- panda/src/physx/physxBoxShape.h | 55 +- panda/src/physx/physxBoxShapeDesc.I | 60 +- panda/src/physx/physxBoxShapeDesc.cxx | 49 +- panda/src/physx/physxBoxShapeDesc.h | 32 +- panda/src/physx/physxCapsule.I | 51 +- panda/src/physx/physxCapsule.cxx | 128 +- panda/src/physx/physxCapsule.h | 32 +- panda/src/physx/physxCapsuleController.I | 44 +- panda/src/physx/physxCapsuleController.cxx | 74 +- panda/src/physx/physxCapsuleController.h | 63 +- panda/src/physx/physxCapsuleControllerDesc.I | 60 +- .../src/physx/physxCapsuleControllerDesc.cxx | 62 +- panda/src/physx/physxCapsuleControllerDesc.h | 32 +- panda/src/physx/physxCapsuleForceFieldShape.I | 44 +- .../src/physx/physxCapsuleForceFieldShape.cxx | 83 +- panda/src/physx/physxCapsuleForceFieldShape.h | 37 +- .../physx/physxCapsuleForceFieldShapeDesc.I | 60 +- .../physx/physxCapsuleForceFieldShapeDesc.cxx | 62 +- .../physx/physxCapsuleForceFieldShapeDesc.h | 32 +- panda/src/physx/physxCapsuleShape.I | 44 +- panda/src/physx/physxCapsuleShape.cxx | 83 +- panda/src/physx/physxCapsuleShape.h | 63 +- panda/src/physx/physxCapsuleShapeDesc.I | 60 +- panda/src/physx/physxCapsuleShapeDesc.cxx | 62 +- panda/src/physx/physxCapsuleShapeDesc.h | 32 +- panda/src/physx/physxCcdSkeleton.I | 60 +- panda/src/physx/physxCcdSkeleton.cxx | 60 +- panda/src/physx/physxCcdSkeleton.h | 39 +- panda/src/physx/physxCcdSkeletonDesc.I | 51 +- panda/src/physx/physxCcdSkeletonDesc.cxx | 107 +- panda/src/physx/physxCcdSkeletonDesc.h | 32 +- panda/src/physx/physxCloth.I | 60 +- panda/src/physx/physxCloth.cxx | 474 +- panda/src/physx/physxCloth.h | 36 +- panda/src/physx/physxClothDesc.I | 60 +- panda/src/physx/physxClothDesc.cxx | 263 +- panda/src/physx/physxClothDesc.h | 34 +- panda/src/physx/physxClothMesh.I | 60 +- panda/src/physx/physxClothMesh.cxx | 58 +- panda/src/physx/physxClothMesh.h | 36 +- panda/src/physx/physxClothMeshDesc.I | 67 +- panda/src/physx/physxClothMeshDesc.cxx | 99 +- panda/src/physx/physxClothMeshDesc.h | 32 +- panda/src/physx/physxClothNode.I | 44 +- panda/src/physx/physxClothNode.cxx | 74 +- panda/src/physx/physxClothNode.h | 35 +- panda/src/physx/physxConstraintDominance.I | 59 +- panda/src/physx/physxConstraintDominance.cxx | 58 +- panda/src/physx/physxConstraintDominance.h | 43 +- panda/src/physx/physxContactPair.I | 43 +- panda/src/physx/physxContactPair.cxx | 137 +- panda/src/physx/physxContactPair.h | 38 +- panda/src/physx/physxContactPoint.I | 45 +- panda/src/physx/physxContactPoint.cxx | 90 +- panda/src/physx/physxContactPoint.h | 37 +- panda/src/physx/physxContactReport.I | 43 +- panda/src/physx/physxContactReport.cxx | 58 +- panda/src/physx/physxContactReport.h | 33 +- panda/src/physx/physxController.I | 52 +- panda/src/physx/physxController.cxx | 241 +- panda/src/physx/physxController.h | 35 +- panda/src/physx/physxControllerDesc.I | 36 +- panda/src/physx/physxControllerDesc.cxx | 137 +- panda/src/physx/physxControllerDesc.h | 32 +- panda/src/physx/physxControllerReport.I | 59 +- panda/src/physx/physxControllerReport.cxx | 74 +- panda/src/physx/physxControllerReport.h | 33 +- panda/src/physx/physxControllerShapeHit.I | 82 +- panda/src/physx/physxControllerShapeHit.cxx | 27 +- panda/src/physx/physxControllerShapeHit.h | 35 +- panda/src/physx/physxControllersHit.I | 50 +- panda/src/physx/physxControllersHit.cxx | 27 +- panda/src/physx/physxControllersHit.h | 35 +- panda/src/physx/physxConvexForceFieldShape.I | 44 +- .../src/physx/physxConvexForceFieldShape.cxx | 51 +- panda/src/physx/physxConvexForceFieldShape.h | 36 +- .../physx/physxConvexForceFieldShapeDesc.I | 60 +- .../physx/physxConvexForceFieldShapeDesc.cxx | 35 +- .../physx/physxConvexForceFieldShapeDesc.h | 32 +- panda/src/physx/physxConvexMesh.I | 60 +- panda/src/physx/physxConvexMesh.cxx | 58 +- panda/src/physx/physxConvexMesh.h | 39 +- panda/src/physx/physxConvexMeshDesc.I | 51 +- panda/src/physx/physxConvexMeshDesc.cxx | 87 +- panda/src/physx/physxConvexMeshDesc.h | 32 +- panda/src/physx/physxConvexShape.I | 44 +- panda/src/physx/physxConvexShape.cxx | 51 +- panda/src/physx/physxConvexShape.h | 37 +- panda/src/physx/physxConvexShapeDesc.I | 60 +- panda/src/physx/physxConvexShapeDesc.cxx | 35 +- panda/src/physx/physxConvexShapeDesc.h | 32 +- panda/src/physx/physxCylindricalJoint.I | 44 +- panda/src/physx/physxCylindricalJoint.cxx | 60 +- panda/src/physx/physxCylindricalJoint.h | 39 +- panda/src/physx/physxCylindricalJointDesc.I | 60 +- panda/src/physx/physxCylindricalJointDesc.cxx | 26 +- panda/src/physx/physxCylindricalJointDesc.h | 33 +- panda/src/physx/physxD6Joint.I | 44 +- panda/src/physx/physxD6Joint.cxx | 92 +- panda/src/physx/physxD6Joint.h | 43 +- panda/src/physx/physxD6JointDesc.I | 60 +- panda/src/physx/physxD6JointDesc.cxx | 443 +- panda/src/physx/physxD6JointDesc.h | 32 +- panda/src/physx/physxDebugGeomNode.I | 300 +- panda/src/physx/physxDebugGeomNode.cxx | 58 +- panda/src/physx/physxDebugGeomNode.h | 38 +- panda/src/physx/physxDistanceJoint.I | 44 +- panda/src/physx/physxDistanceJoint.cxx | 60 +- panda/src/physx/physxDistanceJoint.h | 38 +- panda/src/physx/physxDistanceJointDesc.I | 60 +- panda/src/physx/physxDistanceJointDesc.cxx | 95 +- panda/src/physx/physxDistanceJointDesc.h | 33 +- panda/src/physx/physxEnums.cxx | 28 +- panda/src/physx/physxEnums.h | 52 +- panda/src/physx/physxFileStream.cxx | 138 +- panda/src/physx/physxFileStream.h | 32 +- panda/src/physx/physxFixedJoint.I | 44 +- panda/src/physx/physxFixedJoint.cxx | 60 +- panda/src/physx/physxFixedJoint.h | 38 +- panda/src/physx/physxFixedJointDesc.I | 60 +- panda/src/physx/physxFixedJointDesc.cxx | 26 +- panda/src/physx/physxFixedJointDesc.h | 35 +- panda/src/physx/physxForceField.I | 60 +- panda/src/physx/physxForceField.cxx | 98 +- panda/src/physx/physxForceField.h | 48 +- panda/src/physx/physxForceFieldDesc.I | 60 +- panda/src/physx/physxForceFieldDesc.cxx | 170 +- panda/src/physx/physxForceFieldDesc.h | 32 +- panda/src/physx/physxForceFieldShape.I | 52 +- panda/src/physx/physxForceFieldShape.cxx | 110 +- panda/src/physx/physxForceFieldShape.h | 35 +- panda/src/physx/physxForceFieldShapeDesc.I | 44 +- panda/src/physx/physxForceFieldShapeDesc.cxx | 82 +- panda/src/physx/physxForceFieldShapeDesc.h | 33 +- panda/src/physx/physxForceFieldShapeGroup.I | 60 +- panda/src/physx/physxForceFieldShapeGroup.cxx | 124 +- panda/src/physx/physxForceFieldShapeGroup.h | 36 +- .../src/physx/physxForceFieldShapeGroupDesc.I | 60 +- .../physx/physxForceFieldShapeGroupDesc.cxx | 71 +- .../src/physx/physxForceFieldShapeGroupDesc.h | 32 +- panda/src/physx/physxGroupsMask.I | 131 +- panda/src/physx/physxGroupsMask.cxx | 80 +- panda/src/physx/physxGroupsMask.h | 32 +- panda/src/physx/physxHeightField.I | 60 +- panda/src/physx/physxHeightField.cxx | 66 +- panda/src/physx/physxHeightField.h | 67 +- panda/src/physx/physxHeightFieldDesc.I | 77 +- panda/src/physx/physxHeightFieldDesc.cxx | 77 +- panda/src/physx/physxHeightFieldDesc.h | 38 +- panda/src/physx/physxHeightFieldShape.I | 44 +- panda/src/physx/physxHeightFieldShape.cxx | 51 +- panda/src/physx/physxHeightFieldShape.h | 55 +- panda/src/physx/physxHeightFieldShapeDesc.I | 52 +- panda/src/physx/physxHeightFieldShapeDesc.cxx | 96 +- panda/src/physx/physxHeightFieldShapeDesc.h | 32 +- panda/src/physx/physxJoint.I | 52 +- panda/src/physx/physxJoint.cxx | 270 +- panda/src/physx/physxJoint.h | 38 +- panda/src/physx/physxJointDesc.I | 44 +- panda/src/physx/physxJointDesc.cxx | 199 +- panda/src/physx/physxJointDesc.h | 32 +- panda/src/physx/physxJointDriveDesc.I | 51 +- panda/src/physx/physxJointDriveDesc.cxx | 90 +- panda/src/physx/physxJointDriveDesc.h | 33 +- panda/src/physx/physxJointLimitDesc.I | 51 +- panda/src/physx/physxJointLimitDesc.cxx | 74 +- panda/src/physx/physxJointLimitDesc.h | 32 +- panda/src/physx/physxJointLimitSoftDesc.I | 51 +- panda/src/physx/physxJointLimitSoftDesc.cxx | 90 +- panda/src/physx/physxJointLimitSoftDesc.h | 32 +- panda/src/physx/physxKitchen.I | 43 +- panda/src/physx/physxKitchen.cxx | 130 +- panda/src/physx/physxKitchen.h | 32 +- .../physx/physxLinearInterpolationValues.I | 43 +- .../physx/physxLinearInterpolationValues.cxx | 84 +- .../physx/physxLinearInterpolationValues.h | 32 +- panda/src/physx/physxManager.I | 179 +- panda/src/physx/physxManager.cxx | 295 +- panda/src/physx/physxManager.h | 35 +- panda/src/physx/physxMask.I | 51 +- panda/src/physx/physxMask.cxx | 80 +- panda/src/physx/physxMask.h | 32 +- panda/src/physx/physxMaterial.I | 60 +- panda/src/physx/physxMaterial.cxx | 295 +- panda/src/physx/physxMaterial.h | 69 +- panda/src/physx/physxMaterialDesc.I | 60 +- panda/src/physx/physxMaterialDesc.cxx | 227 +- panda/src/physx/physxMaterialDesc.h | 32 +- panda/src/physx/physxMemoryReadBuffer.cxx | 90 +- panda/src/physx/physxMemoryReadBuffer.h | 32 +- panda/src/physx/physxMemoryWriteBuffer.cxx | 90 +- panda/src/physx/physxMemoryWriteBuffer.h | 32 +- panda/src/physx/physxMeshHash.I | 68 +- panda/src/physx/physxMeshHash.cxx | 112 +- panda/src/physx/physxMeshHash.h | 35 +- panda/src/physx/physxMeshPool.I | 43 +- panda/src/physx/physxMeshPool.cxx | 128 +- panda/src/physx/physxMeshPool.h | 39 +- panda/src/physx/physxMotorDesc.I | 51 +- panda/src/physx/physxMotorDesc.cxx | 74 +- panda/src/physx/physxMotorDesc.h | 39 +- panda/src/physx/physxObject.I | 94 +- panda/src/physx/physxObject.cxx | 26 +- panda/src/physx/physxObject.h | 35 +- panda/src/physx/physxObjectCollection.I | 87 +- panda/src/physx/physxObjectCollection.cxx | 26 +- panda/src/physx/physxObjectCollection.h | 32 +- panda/src/physx/physxOverlapReport.I | 43 +- panda/src/physx/physxOverlapReport.cxx | 68 +- panda/src/physx/physxOverlapReport.h | 37 +- panda/src/physx/physxPlane.I | 51 +- panda/src/physx/physxPlane.cxx | 130 +- panda/src/physx/physxPlane.h | 32 +- panda/src/physx/physxPlaneShape.I | 44 +- panda/src/physx/physxPlaneShape.cxx | 65 +- panda/src/physx/physxPlaneShape.h | 77 +- panda/src/physx/physxPlaneShapeDesc.I | 60 +- panda/src/physx/physxPlaneShapeDesc.cxx | 37 +- panda/src/physx/physxPlaneShapeDesc.h | 32 +- panda/src/physx/physxPointInPlaneJoint.I | 44 +- panda/src/physx/physxPointInPlaneJoint.cxx | 60 +- panda/src/physx/physxPointInPlaneJoint.h | 45 +- panda/src/physx/physxPointInPlaneJointDesc.I | 60 +- .../src/physx/physxPointInPlaneJointDesc.cxx | 26 +- panda/src/physx/physxPointInPlaneJointDesc.h | 33 +- panda/src/physx/physxPointOnLineJoint.I | 44 +- panda/src/physx/physxPointOnLineJoint.cxx | 60 +- panda/src/physx/physxPointOnLineJoint.h | 44 +- panda/src/physx/physxPointOnLineJointDesc.I | 60 +- panda/src/physx/physxPointOnLineJointDesc.cxx | 26 +- panda/src/physx/physxPointOnLineJointDesc.h | 33 +- panda/src/physx/physxPrismaticJoint.I | 44 +- panda/src/physx/physxPrismaticJoint.cxx | 60 +- panda/src/physx/physxPrismaticJoint.h | 39 +- panda/src/physx/physxPrismaticJointDesc.I | 60 +- panda/src/physx/physxPrismaticJointDesc.cxx | 26 +- panda/src/physx/physxPrismaticJointDesc.h | 33 +- panda/src/physx/physxPulleyJoint.I | 44 +- panda/src/physx/physxPulleyJoint.cxx | 139 +- panda/src/physx/physxPulleyJoint.h | 38 +- panda/src/physx/physxPulleyJointDesc.I | 60 +- panda/src/physx/physxPulleyJointDesc.cxx | 125 +- panda/src/physx/physxPulleyJointDesc.h | 33 +- panda/src/physx/physxRay.I | 43 +- panda/src/physx/physxRay.cxx | 81 +- panda/src/physx/physxRay.h | 34 +- panda/src/physx/physxRaycastHit.I | 43 +- panda/src/physx/physxRaycastHit.cxx | 66 +- panda/src/physx/physxRaycastHit.h | 35 +- panda/src/physx/physxRaycastReport.I | 43 +- panda/src/physx/physxRaycastReport.cxx | 70 +- panda/src/physx/physxRaycastReport.h | 35 +- panda/src/physx/physxRevoluteJoint.I | 44 +- panda/src/physx/physxRevoluteJoint.cxx | 298 +- panda/src/physx/physxRevoluteJoint.h | 43 +- panda/src/physx/physxRevoluteJointDesc.I | 60 +- panda/src/physx/physxRevoluteJointDesc.cxx | 160 +- panda/src/physx/physxRevoluteJointDesc.h | 33 +- panda/src/physx/physxScene.I | 76 +- panda/src/physx/physxScene.cxx | 998 ++-- panda/src/physx/physxScene.h | 56 +- panda/src/physx/physxSceneDesc.I | 60 +- panda/src/physx/physxSceneDesc.cxx | 258 +- panda/src/physx/physxSceneDesc.h | 32 +- panda/src/physx/physxSceneStats2.I | 67 +- panda/src/physx/physxSceneStats2.cxx | 42 +- panda/src/physx/physxSceneStats2.h | 32 +- panda/src/physx/physxSegment.I | 51 +- panda/src/physx/physxSegment.cxx | 120 +- panda/src/physx/physxSegment.h | 32 +- panda/src/physx/physxShape.I | 52 +- panda/src/physx/physxShape.cxx | 344 +- panda/src/physx/physxShape.h | 35 +- panda/src/physx/physxShapeDesc.I | 44 +- panda/src/physx/physxShapeDesc.cxx | 246 +- panda/src/physx/physxShapeDesc.h | 35 +- panda/src/physx/physxSoftBody.I | 60 +- panda/src/physx/physxSoftBody.cxx | 629 +-- panda/src/physx/physxSoftBody.h | 138 +- panda/src/physx/physxSoftBodyDesc.I | 60 +- panda/src/physx/physxSoftBodyDesc.cxx | 295 +- panda/src/physx/physxSoftBodyDesc.h | 34 +- panda/src/physx/physxSoftBodyMesh.I | 60 +- panda/src/physx/physxSoftBodyMesh.cxx | 58 +- panda/src/physx/physxSoftBodyMesh.h | 36 +- panda/src/physx/physxSoftBodyMeshDesc.I | 59 +- panda/src/physx/physxSoftBodyMeshDesc.cxx | 76 +- panda/src/physx/physxSoftBodyMeshDesc.h | 32 +- panda/src/physx/physxSoftBodyNode.I | 44 +- panda/src/physx/physxSoftBodyNode.cxx | 113 +- panda/src/physx/physxSoftBodyNode.h | 36 +- panda/src/physx/physxSphere.I | 51 +- panda/src/physx/physxSphere.cxx | 105 +- panda/src/physx/physxSphere.h | 33 +- panda/src/physx/physxSphereForceFieldShape.I | 44 +- .../src/physx/physxSphereForceFieldShape.cxx | 67 +- panda/src/physx/physxSphereForceFieldShape.h | 36 +- .../physx/physxSphereForceFieldShapeDesc.I | 60 +- .../physx/physxSphereForceFieldShapeDesc.cxx | 42 +- .../physx/physxSphereForceFieldShapeDesc.h | 32 +- panda/src/physx/physxSphereShape.I | 44 +- panda/src/physx/physxSphereShape.cxx | 67 +- panda/src/physx/physxSphereShape.h | 56 +- panda/src/physx/physxSphereShapeDesc.I | 60 +- panda/src/physx/physxSphereShapeDesc.cxx | 42 +- panda/src/physx/physxSphereShapeDesc.h | 32 +- panda/src/physx/physxSphericalJoint.I | 44 +- panda/src/physx/physxSphericalJoint.cxx | 92 +- panda/src/physx/physxSphericalJoint.h | 42 +- panda/src/physx/physxSphericalJointDesc.I | 60 +- panda/src/physx/physxSphericalJointDesc.cxx | 188 +- panda/src/physx/physxSphericalJointDesc.h | 33 +- panda/src/physx/physxSpringDesc.I | 51 +- panda/src/physx/physxSpringDesc.cxx | 74 +- panda/src/physx/physxSpringDesc.h | 35 +- panda/src/physx/physxTriangleMesh.I | 60 +- panda/src/physx/physxTriangleMesh.cxx | 58 +- panda/src/physx/physxTriangleMesh.h | 36 +- panda/src/physx/physxTriangleMeshDesc.I | 51 +- panda/src/physx/physxTriangleMeshDesc.cxx | 107 +- panda/src/physx/physxTriangleMeshDesc.h | 32 +- panda/src/physx/physxTriangleMeshShape.I | 44 +- panda/src/physx/physxTriangleMeshShape.cxx | 51 +- panda/src/physx/physxTriangleMeshShape.h | 37 +- panda/src/physx/physxTriangleMeshShapeDesc.I | 60 +- .../src/physx/physxTriangleMeshShapeDesc.cxx | 35 +- panda/src/physx/physxTriangleMeshShapeDesc.h | 32 +- panda/src/physx/physxTriggerReport.I | 43 +- panda/src/physx/physxTriggerReport.cxx | 58 +- panda/src/physx/physxTriggerReport.h | 33 +- panda/src/physx/physxUtilLib.I | 43 +- panda/src/physx/physxUtilLib.cxx | 786 ++- panda/src/physx/physxUtilLib.h | 32 +- panda/src/physx/physxVehicle.I | 60 +- panda/src/physx/physxVehicle.cxx | 74 +- panda/src/physx/physxVehicle.h | 43 +- panda/src/physx/physxVehicleDesc.I | 59 +- panda/src/physx/physxVehicleDesc.cxx | 34 +- panda/src/physx/physxVehicleDesc.h | 32 +- panda/src/physx/physxWheel.I | 60 +- panda/src/physx/physxWheel.cxx | 73 +- panda/src/physx/physxWheel.h | 44 +- panda/src/physx/physxWheelDesc.I | 59 +- panda/src/physx/physxWheelDesc.cxx | 34 +- panda/src/physx/physxWheelDesc.h | 32 +- panda/src/physx/physxWheelShape.I | 44 +- panda/src/physx/physxWheelShape.cxx | 231 +- panda/src/physx/physxWheelShape.h | 99 +- panda/src/physx/physxWheelShapeDesc.I | 52 +- panda/src/physx/physxWheelShapeDesc.cxx | 168 +- panda/src/physx/physxWheelShapeDesc.h | 32 +- panda/src/physx/physx_includes.h | 25 +- panda/src/pipeline/asyncTaskBase.I | 26 +- panda/src/pipeline/asyncTaskBase.cxx | 71 +- panda/src/pipeline/asyncTaskBase.h | 37 +- panda/src/pipeline/blockerSimple.I | 42 +- panda/src/pipeline/blockerSimple.h | 37 +- panda/src/pipeline/conditionVar.I | 94 +- panda/src/pipeline/conditionVar.cxx | 25 +- panda/src/pipeline/conditionVar.h | 72 +- panda/src/pipeline/conditionVarDebug.I | 55 +- panda/src/pipeline/conditionVarDebug.cxx | 155 +- panda/src/pipeline/conditionVarDebug.h | 46 +- panda/src/pipeline/conditionVarDirect.I | 169 +- panda/src/pipeline/conditionVarDirect.cxx | 35 +- panda/src/pipeline/conditionVarDirect.h | 46 +- panda/src/pipeline/conditionVarDummyImpl.I | 74 +- panda/src/pipeline/conditionVarDummyImpl.cxx | 25 +- panda/src/pipeline/conditionVarDummyImpl.h | 35 +- panda/src/pipeline/conditionVarFull.I | 83 +- panda/src/pipeline/conditionVarFull.cxx | 25 +- panda/src/pipeline/conditionVarFull.h | 73 +- panda/src/pipeline/conditionVarFullDebug.I | 55 +- panda/src/pipeline/conditionVarFullDebug.cxx | 178 +- panda/src/pipeline/conditionVarFullDebug.h | 46 +- panda/src/pipeline/conditionVarFullDirect.I | 192 +- panda/src/pipeline/conditionVarFullDirect.cxx | 35 +- panda/src/pipeline/conditionVarFullDirect.h | 46 +- .../src/pipeline/conditionVarFullWin32Impl.I | 106 +- .../pipeline/conditionVarFullWin32Impl.cxx | 25 +- .../src/pipeline/conditionVarFullWin32Impl.h | 58 +- panda/src/pipeline/conditionVarImpl.h | 28 +- panda/src/pipeline/conditionVarPosixImpl.I | 66 +- panda/src/pipeline/conditionVarPosixImpl.cxx | 35 +- panda/src/pipeline/conditionVarPosixImpl.h | 32 +- panda/src/pipeline/conditionVarSimpleImpl.I | 58 +- panda/src/pipeline/conditionVarSimpleImpl.cxx | 73 +- panda/src/pipeline/conditionVarSimpleImpl.h | 33 +- panda/src/pipeline/conditionVarSpinlockImpl.I | 58 +- .../src/pipeline/conditionVarSpinlockImpl.cxx | 33 +- panda/src/pipeline/conditionVarSpinlockImpl.h | 40 +- panda/src/pipeline/conditionVarWin32Impl.I | 66 +- panda/src/pipeline/conditionVarWin32Impl.cxx | 25 +- panda/src/pipeline/conditionVarWin32Impl.h | 49 +- panda/src/pipeline/config_pipeline.cxx | 39 +- panda/src/pipeline/config_pipeline.h | 26 +- panda/src/pipeline/contextSwitch.h | 18 +- panda/src/pipeline/cycleData.I | 34 +- panda/src/pipeline/cycleData.cxx | 111 +- panda/src/pipeline/cycleData.h | 58 +- panda/src/pipeline/cycleDataLockedReader.I | 183 +- panda/src/pipeline/cycleDataLockedReader.cxx | 25 +- panda/src/pipeline/cycleDataLockedReader.h | 69 +- .../src/pipeline/cycleDataLockedStageReader.I | 183 +- .../pipeline/cycleDataLockedStageReader.cxx | 25 +- .../src/pipeline/cycleDataLockedStageReader.h | 43 +- panda/src/pipeline/cycleDataReader.I | 171 +- panda/src/pipeline/cycleDataReader.cxx | 25 +- panda/src/pipeline/cycleDataReader.h | 56 +- panda/src/pipeline/cycleDataStageReader.I | 151 +- panda/src/pipeline/cycleDataStageReader.cxx | 25 +- panda/src/pipeline/cycleDataStageReader.h | 41 +- panda/src/pipeline/cycleDataStageWriter.I | 233 +- panda/src/pipeline/cycleDataStageWriter.cxx | 25 +- panda/src/pipeline/cycleDataStageWriter.h | 45 +- panda/src/pipeline/cycleDataWriter.I | 283 +- panda/src/pipeline/cycleDataWriter.cxx | 25 +- panda/src/pipeline/cycleDataWriter.h | 52 +- panda/src/pipeline/cyclerHolder.I | 58 +- panda/src/pipeline/cyclerHolder.cxx | 25 +- panda/src/pipeline/cyclerHolder.h | 37 +- panda/src/pipeline/externalThread.cxx | 61 +- panda/src/pipeline/externalThread.h | 35 +- panda/src/pipeline/genericThread.I | 64 +- panda/src/pipeline/genericThread.cxx | 49 +- panda/src/pipeline/genericThread.h | 35 +- panda/src/pipeline/lightMutex.I | 74 +- panda/src/pipeline/lightMutex.cxx | 25 +- panda/src/pipeline/lightMutex.h | 60 +- panda/src/pipeline/lightMutexDirect.I | 153 +- panda/src/pipeline/lightMutexDirect.cxx | 35 +- panda/src/pipeline/lightMutexDirect.h | 45 +- panda/src/pipeline/lightMutexHolder.I | 77 +- panda/src/pipeline/lightMutexHolder.cxx | 25 +- panda/src/pipeline/lightMutexHolder.h | 32 +- panda/src/pipeline/lightReMutex.I | 66 +- panda/src/pipeline/lightReMutex.cxx | 25 +- panda/src/pipeline/lightReMutex.h | 40 +- panda/src/pipeline/lightReMutexDirect.I | 191 +- panda/src/pipeline/lightReMutexDirect.cxx | 35 +- panda/src/pipeline/lightReMutexDirect.h | 36 +- panda/src/pipeline/lightReMutexHolder.I | 88 +- panda/src/pipeline/lightReMutexHolder.cxx | 25 +- panda/src/pipeline/lightReMutexHolder.h | 32 +- panda/src/pipeline/mainThread.cxx | 43 +- panda/src/pipeline/mainThread.h | 35 +- panda/src/pipeline/mutexDebug.I | 155 +- panda/src/pipeline/mutexDebug.cxx | 199 +- panda/src/pipeline/mutexDebug.h | 35 +- panda/src/pipeline/mutexDirect.I | 163 +- panda/src/pipeline/mutexDirect.cxx | 35 +- panda/src/pipeline/mutexDirect.h | 36 +- panda/src/pipeline/mutexHolder.I | 92 +- panda/src/pipeline/mutexHolder.cxx | 25 +- panda/src/pipeline/mutexHolder.h | 46 +- panda/src/pipeline/mutexSimpleImpl.I | 77 +- panda/src/pipeline/mutexSimpleImpl.cxx | 59 +- panda/src/pipeline/mutexSimpleImpl.h | 55 +- panda/src/pipeline/mutexTrueImpl.h | 51 +- panda/src/pipeline/pipeline.I | 76 +- panda/src/pipeline/pipeline.cxx | 220 +- panda/src/pipeline/pipeline.h | 52 +- panda/src/pipeline/pipelineCycler.I | 313 +- panda/src/pipeline/pipelineCycler.cxx | 25 +- panda/src/pipeline/pipelineCycler.h | 114 +- panda/src/pipeline/pipelineCyclerBase.h | 33 +- panda/src/pipeline/pipelineCyclerDummyImpl.I | 473 +- .../src/pipeline/pipelineCyclerDummyImpl.cxx | 25 +- panda/src/pipeline/pipelineCyclerDummyImpl.h | 58 +- panda/src/pipeline/pipelineCyclerLinks.I | 91 +- panda/src/pipeline/pipelineCyclerLinks.h | 47 +- .../src/pipeline/pipelineCyclerTrivialImpl.I | 448 +- .../pipeline/pipelineCyclerTrivialImpl.cxx | 25 +- .../src/pipeline/pipelineCyclerTrivialImpl.h | 68 +- panda/src/pipeline/pipelineCyclerTrueImpl.I | 449 +- panda/src/pipeline/pipelineCyclerTrueImpl.cxx | 223 +- panda/src/pipeline/pipelineCyclerTrueImpl.h | 68 +- panda/src/pipeline/pmutex.I | 74 +- panda/src/pipeline/pmutex.cxx | 25 +- panda/src/pipeline/pmutex.h | 62 +- panda/src/pipeline/psemaphore.I | 106 +- panda/src/pipeline/psemaphore.cxx | 33 +- panda/src/pipeline/psemaphore.h | 44 +- panda/src/pipeline/pythonThread.cxx | 66 +- panda/src/pipeline/pythonThread.h | 37 +- panda/src/pipeline/reMutex.I | 66 +- panda/src/pipeline/reMutex.cxx | 25 +- panda/src/pipeline/reMutex.h | 44 +- panda/src/pipeline/reMutexDirect.I | 243 +- panda/src/pipeline/reMutexDirect.cxx | 115 +- panda/src/pipeline/reMutexDirect.h | 36 +- panda/src/pipeline/reMutexHolder.I | 87 +- panda/src/pipeline/reMutexHolder.cxx | 25 +- panda/src/pipeline/reMutexHolder.h | 32 +- panda/src/pipeline/test_atomic.cxx | 27 +- panda/src/pipeline/test_concurrency.cxx | 47 +- panda/src/pipeline/test_delete.cxx | 29 +- panda/src/pipeline/test_diners.cxx | 37 +- panda/src/pipeline/test_mutex.cxx | 31 +- panda/src/pipeline/test_setjmp.cxx | 34 +- panda/src/pipeline/test_threaddata.cxx | 29 +- panda/src/pipeline/thread.I | 344 +- panda/src/pipeline/thread.cxx | 417 +- panda/src/pipeline/thread.h | 46 +- panda/src/pipeline/threadDummyImpl.I | 144 +- panda/src/pipeline/threadDummyImpl.cxx | 44 +- panda/src/pipeline/threadDummyImpl.h | 35 +- panda/src/pipeline/threadImpl.h | 25 +- panda/src/pipeline/threadPosixImpl.I | 117 +- panda/src/pipeline/threadPosixImpl.cxx | 136 +- panda/src/pipeline/threadPosixImpl.h | 32 +- panda/src/pipeline/threadPriority.cxx | 25 +- panda/src/pipeline/threadPriority.h | 31 +- panda/src/pipeline/threadSimpleImpl.I | 129 +- panda/src/pipeline/threadSimpleImpl.cxx | 149 +- panda/src/pipeline/threadSimpleImpl.h | 86 +- panda/src/pipeline/threadSimpleManager.I | 64 +- panda/src/pipeline/threadSimpleManager.cxx | 425 +- panda/src/pipeline/threadSimpleManager.h | 74 +- panda/src/pipeline/threadWin32Impl.I | 117 +- panda/src/pipeline/threadWin32Impl.cxx | 124 +- panda/src/pipeline/threadWin32Impl.h | 32 +- panda/src/pnmimage/config_pnmimage.cxx | 39 +- panda/src/pnmimage/config_pnmimage.h | 25 +- panda/src/pnmimage/convert_srgb.I | 172 +- panda/src/pnmimage/convert_srgb.cxx | 28 +- panda/src/pnmimage/convert_srgb.h | 37 +- panda/src/pnmimage/convert_srgb_sse2.cxx | 67 +- panda/src/pnmimage/pfmFile.I | 562 +- panda/src/pnmimage/pfmFile.cxx | 1129 ++-- panda/src/pnmimage/pfmFile.h | 35 +- panda/src/pnmimage/pfmFile_ext.cxx | 57 +- panda/src/pnmimage/pfmFile_ext.h | 35 +- panda/src/pnmimage/pnm-image-filter-core.cxx | 30 +- .../pnmimage/pnm-image-filter-sparse-core.cxx | 36 +- panda/src/pnmimage/pnm-image-filter.cxx | 257 +- panda/src/pnmimage/pnmBrush.I | 64 +- panda/src/pnmimage/pnmBrush.cxx | 86 +- panda/src/pnmimage/pnmBrush.h | 53 +- panda/src/pnmimage/pnmFileType.cxx | 152 +- panda/src/pnmimage/pnmFileType.h | 36 +- panda/src/pnmimage/pnmFileTypeRegistry.cxx | 164 +- panda/src/pnmimage/pnmFileTypeRegistry.h | 34 +- panda/src/pnmimage/pnmImage.I | 1183 ++--- panda/src/pnmimage/pnmImage.cxx | 1085 ++-- panda/src/pnmimage/pnmImage.h | 126 +- panda/src/pnmimage/pnmImageHeader.I | 512 +- panda/src/pnmimage/pnmImageHeader.cxx | 315 +- panda/src/pnmimage/pnmImageHeader.h | 58 +- panda/src/pnmimage/pnmPainter.I | 119 +- panda/src/pnmimage/pnmPainter.cxx | 82 +- panda/src/pnmimage/pnmPainter.h | 44 +- panda/src/pnmimage/pnmReader.I | 68 +- panda/src/pnmimage/pnmReader.cxx | 207 +- panda/src/pnmimage/pnmReader.h | 38 +- panda/src/pnmimage/pnmWriter.I | 106 +- panda/src/pnmimage/pnmWriter.cxx | 203 +- panda/src/pnmimage/pnmWriter.h | 44 +- panda/src/pnmimage/pnmimage_base.cxx | 78 +- panda/src/pnmimage/pnmimage_base.h | 43 +- panda/src/pnmimagetypes/bmp.h | 10 +- .../pnmimagetypes/config_pnmimagetypes.cxx | 47 +- .../src/pnmimagetypes/config_pnmimagetypes.h | 29 +- panda/src/pnmimagetypes/pnmFileTypeBMP.cxx | 148 +- panda/src/pnmimagetypes/pnmFileTypeBMP.h | 32 +- .../pnmimagetypes/pnmFileTypeBMPReader.cxx | 57 +- .../pnmimagetypes/pnmFileTypeBMPWriter.cxx | 87 +- panda/src/pnmimagetypes/pnmFileTypeIMG.cxx | 250 +- panda/src/pnmimagetypes/pnmFileTypeIMG.h | 34 +- panda/src/pnmimagetypes/pnmFileTypeJPG.cxx | 148 +- panda/src/pnmimagetypes/pnmFileTypeJPG.h | 37 +- .../pnmimagetypes/pnmFileTypeJPGReader.cxx | 94 +- .../pnmimagetypes/pnmFileTypeJPGWriter.cxx | 84 +- panda/src/pnmimagetypes/pnmFileTypePNG.cxx | 395 +- panda/src/pnmimagetypes/pnmFileTypePNG.h | 48 +- panda/src/pnmimagetypes/pnmFileTypePNM.cxx | 397 +- panda/src/pnmimagetypes/pnmFileTypePNM.h | 35 +- panda/src/pnmimagetypes/pnmFileTypePfm.cxx | 238 +- panda/src/pnmimagetypes/pnmFileTypePfm.h | 38 +- panda/src/pnmimagetypes/pnmFileTypeSGI.cxx | 148 +- panda/src/pnmimagetypes/pnmFileTypeSGI.h | 34 +- .../pnmimagetypes/pnmFileTypeSGIReader.cxx | 90 +- .../pnmimagetypes/pnmFileTypeSGIWriter.cxx | 111 +- .../pnmimagetypes/pnmFileTypeSoftImage.cxx | 270 +- .../src/pnmimagetypes/pnmFileTypeSoftImage.h | 34 +- panda/src/pnmimagetypes/pnmFileTypeTGA.cxx | 235 +- panda/src/pnmimagetypes/pnmFileTypeTGA.h | 34 +- panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx | 469 +- panda/src/pnmimagetypes/pnmFileTypeTIFF.h | 32 +- panda/src/pnmimagetypes/sgi.h | 9 +- panda/src/pnmtext/config_pnmtext.cxx | 39 +- panda/src/pnmtext/config_pnmtext.h | 25 +- panda/src/pnmtext/freetypeFace.I | 26 +- panda/src/pnmtext/freetypeFace.cxx | 96 +- panda/src/pnmtext/freetypeFace.h | 40 +- panda/src/pnmtext/freetypeFont.I | 327 +- panda/src/pnmtext/freetypeFont.cxx | 295 +- panda/src/pnmtext/freetypeFont.h | 43 +- panda/src/pnmtext/pnmTextGlyph.I | 116 +- panda/src/pnmtext/pnmTextGlyph.cxx | 152 +- panda/src/pnmtext/pnmTextGlyph.h | 36 +- panda/src/pnmtext/pnmTextMaker.I | 170 +- panda/src/pnmtext/pnmTextMaker.cxx | 134 +- panda/src/pnmtext/pnmTextMaker.h | 40 +- panda/src/pstatclient/config_pstats.cxx | 44 +- panda/src/pstatclient/config_pstats.h | 25 +- panda/src/pstatclient/pStatClient.I | 317 +- panda/src/pstatclient/pStatClient.cxx | 647 +-- panda/src/pstatclient/pStatClient.h | 83 +- .../pstatclient/pStatClientControlMessage.cxx | 51 +- .../pstatclient/pStatClientControlMessage.h | 36 +- panda/src/pstatclient/pStatClientImpl.I | 126 +- panda/src/pstatclient/pStatClientImpl.cxx | 210 +- panda/src/pstatclient/pStatClientImpl.h | 55 +- panda/src/pstatclient/pStatClientVersion.I | 61 +- panda/src/pstatclient/pStatClientVersion.cxx | 33 +- panda/src/pstatclient/pStatClientVersion.h | 36 +- panda/src/pstatclient/pStatCollector.I | 578 +-- panda/src/pstatclient/pStatCollector.cxx | 25 +- panda/src/pstatclient/pStatCollector.h | 69 +- panda/src/pstatclient/pStatCollectorDef.cxx | 71 +- panda/src/pstatclient/pStatCollectorDef.h | 35 +- panda/src/pstatclient/pStatCollectorForward.I | 35 +- .../src/pstatclient/pStatCollectorForward.cxx | 34 +- panda/src/pstatclient/pStatCollectorForward.h | 37 +- panda/src/pstatclient/pStatFrameData.I | 207 +- panda/src/pstatclient/pStatFrameData.cxx | 55 +- panda/src/pstatclient/pStatFrameData.h | 38 +- panda/src/pstatclient/pStatProperties.cxx | 134 +- panda/src/pstatclient/pStatProperties.h | 26 +- .../pstatclient/pStatServerControlMessage.cxx | 51 +- .../pstatclient/pStatServerControlMessage.h | 36 +- panda/src/pstatclient/pStatThread.I | 118 +- panda/src/pstatclient/pStatThread.cxx | 35 +- panda/src/pstatclient/pStatThread.h | 36 +- panda/src/pstatclient/pStatTimer.I | 50 +- panda/src/pstatclient/pStatTimer.h | 43 +- panda/src/pstatclient/test_client.cxx | 34 +- panda/src/putil/animInterface.I | 330 +- panda/src/putil/animInterface.cxx | 311 +- panda/src/putil/animInterface.h | 45 +- panda/src/putil/autoTextureScale.cxx | 31 +- panda/src/putil/autoTextureScale.h | 25 +- panda/src/putil/bam.h | 101 +- panda/src/putil/bamCache.I | 321 +- panda/src/putil/bamCache.cxx | 405 +- panda/src/putil/bamCache.h | 53 +- panda/src/putil/bamCacheIndex.I | 36 +- panda/src/putil/bamCacheIndex.cxx | 171 +- panda/src/putil/bamCacheIndex.h | 48 +- panda/src/putil/bamCacheRecord.I | 239 +- panda/src/putil/bamCacheRecord.cxx | 181 +- panda/src/putil/bamCacheRecord.h | 54 +- panda/src/putil/bamEnums.cxx | 35 +- panda/src/putil/bamEnums.h | 65 +- panda/src/putil/bamReader.I | 297 +- panda/src/putil/bamReader.cxx | 1030 ++-- panda/src/putil/bamReader.h | 167 +- panda/src/putil/bamReaderParam.I | 59 +- panda/src/putil/bamReaderParam.cxx | 25 +- panda/src/putil/bamReaderParam.h | 35 +- panda/src/putil/bamWriter.I | 128 +- panda/src/putil/bamWriter.cxx | 520 +- panda/src/putil/bamWriter.h | 128 +- panda/src/putil/bitArray.I | 396 +- panda/src/putil/bitArray.cxx | 404 +- panda/src/putil/bitArray.h | 39 +- panda/src/putil/bitMask.I | 739 +-- panda/src/putil/bitMask.cxx | 25 +- panda/src/putil/bitMask.h | 35 +- panda/src/putil/buttonHandle.I | 212 +- panda/src/putil/buttonHandle.cxx | 72 +- panda/src/putil/buttonHandle.h | 41 +- panda/src/putil/buttonMap.I | 129 +- panda/src/putil/buttonMap.cxx | 49 +- panda/src/putil/buttonMap.h | 41 +- panda/src/putil/buttonRegistry.I | 63 +- panda/src/putil/buttonRegistry.cxx | 146 +- panda/src/putil/buttonRegistry.h | 41 +- panda/src/putil/cPointerCallbackObject.I | 34 +- panda/src/putil/cPointerCallbackObject.cxx | 39 +- panda/src/putil/cPointerCallbackObject.h | 35 +- .../putil/cachedTypedWritableReferenceCount.I | 251 +- .../cachedTypedWritableReferenceCount.cxx | 53 +- .../putil/cachedTypedWritableReferenceCount.h | 56 +- panda/src/putil/callbackData.I | 34 +- panda/src/putil/callbackData.cxx | 45 +- panda/src/putil/callbackData.h | 45 +- panda/src/putil/callbackObject.I | 34 +- panda/src/putil/callbackObject.cxx | 46 +- panda/src/putil/callbackObject.h | 40 +- panda/src/putil/callbackObject_ext.I | 39 +- panda/src/putil/callbackObject_ext.h | 44 +- panda/src/putil/clockObject.I | 328 +- panda/src/putil/clockObject.cxx | 437 +- panda/src/putil/clockObject.h | 74 +- panda/src/putil/collideMask.h | 68 +- panda/src/putil/colorSpace.cxx | 25 +- panda/src/putil/colorSpace.h | 49 +- panda/src/putil/compareTo.I | 34 +- panda/src/putil/compareTo.h | 38 +- panda/src/putil/config_util.cxx | 58 +- panda/src/putil/config_util.h | 34 +- panda/src/putil/configurable.cxx | 25 +- panda/src/putil/configurable.h | 55 +- panda/src/putil/copyOnWriteObject.I | 164 +- panda/src/putil/copyOnWriteObject.cxx | 41 +- panda/src/putil/copyOnWriteObject.h | 65 +- panda/src/putil/copyOnWritePointer.I | 285 +- panda/src/putil/copyOnWritePointer.cxx | 79 +- panda/src/putil/copyOnWritePointer.h | 57 +- panda/src/putil/datagramInputFile.I | 60 +- panda/src/putil/datagramInputFile.cxx | 212 +- panda/src/putil/datagramInputFile.h | 35 +- panda/src/putil/datagramOutputFile.I | 60 +- panda/src/putil/datagramOutputFile.cxx | 192 +- panda/src/putil/datagramOutputFile.h | 35 +- panda/src/putil/doubleBitMask.I | 577 +-- panda/src/putil/doubleBitMask.cxx | 25 +- panda/src/putil/doubleBitMask.h | 40 +- panda/src/putil/drawMask.h | 31 +- panda/src/putil/factory.I | 105 +- panda/src/putil/factory.h | 56 +- panda/src/putil/factoryBase.I | 70 +- panda/src/putil/factoryBase.cxx | 227 +- panda/src/putil/factoryBase.h | 50 +- panda/src/putil/factoryParam.I | 57 +- panda/src/putil/factoryParam.cxx | 25 +- panda/src/putil/factoryParam.h | 43 +- panda/src/putil/factoryParams.I | 39 +- panda/src/putil/factoryParams.cxx | 88 +- panda/src/putil/factoryParams.h | 46 +- panda/src/putil/firstOfPairCompare.I | 42 +- panda/src/putil/firstOfPairCompare.h | 38 +- panda/src/putil/firstOfPairLess.I | 33 +- panda/src/putil/firstOfPairLess.h | 37 +- panda/src/putil/globalPointerRegistry.I | 80 +- panda/src/putil/globalPointerRegistry.cxx | 75 +- panda/src/putil/globalPointerRegistry.h | 91 +- panda/src/putil/indirectCompareNames.I | 34 +- panda/src/putil/indirectCompareNames.h | 41 +- panda/src/putil/indirectCompareSort.I | 34 +- panda/src/putil/indirectCompareSort.h | 38 +- panda/src/putil/indirectCompareTo.I | 34 +- panda/src/putil/indirectCompareTo.h | 38 +- panda/src/putil/ioPtaDatagramFloat.cxx | 41 +- panda/src/putil/ioPtaDatagramFloat.h | 39 +- panda/src/putil/ioPtaDatagramInt.cxx | 42 +- panda/src/putil/ioPtaDatagramInt.h | 38 +- panda/src/putil/ioPtaDatagramShort.cxx | 41 +- panda/src/putil/ioPtaDatagramShort.h | 39 +- panda/src/putil/iterator_types.h | 59 +- panda/src/putil/keyboardButton.cxx | 58 +- panda/src/putil/keyboardButton.h | 35 +- panda/src/putil/linkedListNode.I | 110 +- panda/src/putil/linkedListNode.cxx | 25 +- panda/src/putil/linkedListNode.h | 50 +- panda/src/putil/load_prc_file.cxx | 120 +- panda/src/putil/load_prc_file.h | 106 +- panda/src/putil/loaderOptions.I | 135 +- panda/src/putil/loaderOptions.cxx | 68 +- panda/src/putil/loaderOptions.h | 37 +- panda/src/putil/modifierButtons.I | 148 +- panda/src/putil/modifierButtons.cxx | 311 +- panda/src/putil/modifierButtons.h | 36 +- panda/src/putil/mouseButton.cxx | 145 +- panda/src/putil/mouseButton.h | 35 +- panda/src/putil/mouseData.I | 74 +- panda/src/putil/mouseData.cxx | 33 +- panda/src/putil/mouseData.h | 37 +- panda/src/putil/nameUniquifier.I | 88 +- panda/src/putil/nameUniquifier.cxx | 95 +- panda/src/putil/nameUniquifier.h | 39 +- panda/src/putil/nodeCachedReferenceCount.I | 252 +- panda/src/putil/nodeCachedReferenceCount.cxx | 53 +- panda/src/putil/nodeCachedReferenceCount.h | 95 +- panda/src/putil/paramValue.I | 167 +- panda/src/putil/paramValue.cxx | 49 +- panda/src/putil/paramValue.h | 66 +- panda/src/putil/pbitops.I | 185 +- panda/src/putil/pbitops.cxx | 35 +- panda/src/putil/pbitops.h | 31 +- panda/src/putil/portalMask.h | 32 +- panda/src/putil/pta_ushort.cxx | 25 +- panda/src/putil/pta_ushort.h | 39 +- panda/src/putil/pythonCallbackObject.I | 26 +- panda/src/putil/pythonCallbackObject.cxx | 91 +- panda/src/putil/pythonCallbackObject.h | 35 +- panda/src/putil/simpleHashMap.I | 392 +- panda/src/putil/simpleHashMap.cxx | 25 +- panda/src/putil/simpleHashMap.h | 42 +- panda/src/putil/sparseArray.I | 474 +- panda/src/putil/sparseArray.cxx | 322 +- panda/src/putil/sparseArray.h | 67 +- panda/src/putil/test_bam.cxx | 29 +- panda/src/putil/test_bam.h | 29 +- panda/src/putil/test_bamRead.cxx | 25 +- panda/src/putil/test_bamWrite.cxx | 28 +- panda/src/putil/test_filename.cxx | 27 +- panda/src/putil/test_glob.cxx | 27 +- panda/src/putil/test_linestream.cxx | 27 +- panda/src/putil/timedCycle.I | 66 +- panda/src/putil/timedCycle.cxx | 47 +- panda/src/putil/timedCycle.h | 40 +- panda/src/putil/typedWritable.I | 103 +- panda/src/putil/typedWritable.cxx | 263 +- panda/src/putil/typedWritable.h | 43 +- panda/src/putil/typedWritableReferenceCount.I | 50 +- .../src/putil/typedWritableReferenceCount.cxx | 61 +- panda/src/putil/typedWritableReferenceCount.h | 46 +- panda/src/putil/typedWritable_ext.cxx | 154 +- panda/src/putil/typedWritable_ext.h | 35 +- panda/src/putil/uniqueIdAllocator.cxx | 137 +- panda/src/putil/uniqueIdAllocator.h | 92 +- panda/src/putil/updateSeq.I | 250 +- panda/src/putil/updateSeq.cxx | 25 +- panda/src/putil/updateSeq.h | 58 +- panda/src/putil/vector_typedWritable.cxx | 25 +- panda/src/putil/vector_typedWritable.h | 39 +- panda/src/putil/vector_ulong.cxx | 25 +- panda/src/putil/vector_ulong.h | 39 +- panda/src/putil/vector_ushort.cxx | 25 +- panda/src/putil/vector_ushort.h | 39 +- panda/src/putil/vector_writable.cxx | 24 +- panda/src/putil/vector_writable.h | 39 +- panda/src/putil/weakKeyHashMap.I | 431 +- panda/src/putil/weakKeyHashMap.cxx | 25 +- panda/src/putil/weakKeyHashMap.h | 46 +- panda/src/putil/writableConfigurable.cxx | 25 +- panda/src/putil/writableConfigurable.h | 64 +- panda/src/putil/writableParam.I | 66 +- panda/src/putil/writableParam.cxx | 25 +- panda/src/putil/writableParam.h | 38 +- panda/src/recorder/config_recorder.cxx | 25 +- panda/src/recorder/config_recorder.h | 25 +- panda/src/recorder/mouseRecorder.cxx | 189 +- panda/src/recorder/mouseRecorder.h | 42 +- panda/src/recorder/recorderBase.I | 51 +- panda/src/recorder/recorderBase.cxx | 93 +- panda/src/recorder/recorderBase.h | 77 +- panda/src/recorder/recorderController.I | 302 +- panda/src/recorder/recorderController.cxx | 125 +- panda/src/recorder/recorderController.h | 49 +- panda/src/recorder/recorderFrame.I | 50 +- panda/src/recorder/recorderFrame.cxx | 132 +- panda/src/recorder/recorderFrame.h | 42 +- panda/src/recorder/recorderHeader.I | 58 +- panda/src/recorder/recorderHeader.cxx | 77 +- panda/src/recorder/recorderHeader.h | 39 +- panda/src/recorder/recorderTable.I | 79 +- panda/src/recorder/recorderTable.cxx | 142 +- panda/src/recorder/recorderTable.h | 44 +- panda/src/recorder/socketStreamRecorder.I | 122 +- panda/src/recorder/socketStreamRecorder.cxx | 117 +- panda/src/recorder/socketStreamRecorder.h | 49 +- panda/src/rocket/config_rocket.cxx | 39 +- panda/src/rocket/config_rocket.h | 25 +- panda/src/rocket/rocketFileInterface.cxx | 83 +- panda/src/rocket/rocketFileInterface.h | 34 +- panda/src/rocket/rocketInputHandler.cxx | 91 +- panda/src/rocket/rocketInputHandler.h | 34 +- panda/src/rocket/rocketRegion.I | 95 +- panda/src/rocket/rocketRegion.cxx | 90 +- panda/src/rocket/rocketRegion.h | 34 +- panda/src/rocket/rocketRegion_ext.cxx | 41 +- panda/src/rocket/rocketRegion_ext.h | 35 +- panda/src/rocket/rocketRenderInterface.cxx | 150 +- panda/src/rocket/rocketRenderInterface.h | 33 +- panda/src/rocket/rocketSystemInterface.cxx | 48 +- panda/src/rocket/rocketSystemInterface.h | 35 +- panda/src/skel/basicSkel.I | 58 +- panda/src/skel/basicSkel.cxx | 47 +- panda/src/skel/basicSkel.h | 46 +- panda/src/skel/config_skel.cxx | 40 +- panda/src/skel/config_skel.h | 27 +- panda/src/skel/typedSkel.I | 58 +- panda/src/skel/typedSkel.cxx | 47 +- panda/src/skel/typedSkel.h | 46 +- panda/src/speedtree/config_speedtree.cxx | 53 +- panda/src/speedtree/config_speedtree.h | 27 +- panda/src/speedtree/loaderFileTypeSrt.cxx | 73 +- panda/src/speedtree/loaderFileTypeSrt.h | 38 +- panda/src/speedtree/loaderFileTypeStf.cxx | 73 +- panda/src/speedtree/loaderFileTypeStf.h | 36 +- panda/src/speedtree/speedTreeNode.I | 237 +- panda/src/speedtree/speedTreeNode.cxx | 886 ++-- panda/src/speedtree/speedTreeNode.h | 67 +- panda/src/speedtree/speedtree_api.cxx | 25 +- panda/src/speedtree/speedtree_api.h | 30 +- panda/src/speedtree/stBasicTerrain.I | 144 +- panda/src/speedtree/stBasicTerrain.cxx | 270 +- panda/src/speedtree/stBasicTerrain.h | 43 +- panda/src/speedtree/stTerrain.I | 139 +- panda/src/speedtree/stTerrain.cxx | 226 +- panda/src/speedtree/stTerrain.h | 55 +- panda/src/speedtree/stTransform.I | 178 +- panda/src/speedtree/stTransform.cxx | 68 +- panda/src/speedtree/stTransform.h | 35 +- panda/src/speedtree/stTree.I | 64 +- panda/src/speedtree/stTree.cxx | 64 +- panda/src/speedtree/stTree.h | 34 +- panda/src/testbed/pgrid.cxx | 68 +- panda/src/testbed/pview.cxx | 64 +- panda/src/testbed/test_lod.cxx | 29 +- panda/src/testbed/test_map.cxx | 40 +- panda/src/testbed/test_texmem.cxx | 37 +- panda/src/testbed/text_test.cxx | 23 +- panda/src/text/config_text.cxx | 43 +- panda/src/text/config_text.h | 25 +- panda/src/text/default_font.cxx | 74 +- panda/src/text/default_font.h | 26 +- panda/src/text/dynamicTextFont.I | 561 +- panda/src/text/dynamicTextFont.cxx | 439 +- panda/src/text/dynamicTextFont.h | 45 +- panda/src/text/dynamicTextGlyph.I | 163 +- panda/src/text/dynamicTextGlyph.cxx | 76 +- panda/src/text/dynamicTextGlyph.h | 39 +- panda/src/text/dynamicTextPage.I | 59 +- panda/src/text/dynamicTextPage.cxx | 119 +- panda/src/text/dynamicTextPage.h | 37 +- panda/src/text/fontPool.I | 135 +- panda/src/text/fontPool.cxx | 143 +- panda/src/text/fontPool.h | 43 +- panda/src/text/geomTextGlyph.I | 26 +- panda/src/text/geomTextGlyph.cxx | 176 +- panda/src/text/geomTextGlyph.h | 40 +- panda/src/text/staticTextFont.I | 26 +- panda/src/text/staticTextFont.cxx | 160 +- panda/src/text/staticTextFont.h | 39 +- panda/src/text/textAssembler.I | 467 +- panda/src/text/textAssembler.cxx | 1034 ++-- panda/src/text/textAssembler.h | 72 +- panda/src/text/textFont.I | 105 +- panda/src/text/textFont.cxx | 120 +- panda/src/text/textFont.h | 42 +- panda/src/text/textGlyph.I | 129 +- panda/src/text/textGlyph.cxx | 160 +- panda/src/text/textGlyph.h | 37 +- panda/src/text/textGraphic.I | 141 +- panda/src/text/textGraphic.cxx | 25 +- panda/src/text/textGraphic.h | 60 +- panda/src/text/textNode.I | 1305 ++--- panda/src/text/textNode.cxx | 565 +- panda/src/text/textNode.h | 90 +- panda/src/text/textProperties.I | 870 ++-- panda/src/text/textProperties.cxx | 148 +- panda/src/text/textProperties.h | 62 +- panda/src/text/textPropertiesManager.I | 26 +- panda/src/text/textPropertiesManager.cxx | 247 +- panda/src/text/textPropertiesManager.h | 75 +- panda/src/tform/buttonThrower.I | 447 +- panda/src/tform/buttonThrower.cxx | 274 +- panda/src/tform/buttonThrower.h | 46 +- panda/src/tform/config_tform.cxx | 25 +- panda/src/tform/config_tform.h | 25 +- panda/src/tform/driveInterface.I | 375 +- panda/src/tform/driveInterface.cxx | 187 +- panda/src/tform/driveInterface.h | 58 +- panda/src/tform/mouseInterfaceNode.I | 37 +- panda/src/tform/mouseInterfaceNode.cxx | 118 +- panda/src/tform/mouseInterfaceNode.h | 41 +- panda/src/tform/mouseSubregion.I | 86 +- panda/src/tform/mouseSubregion.cxx | 67 +- panda/src/tform/mouseSubregion.h | 44 +- panda/src/tform/mouseWatcher.I | 700 +-- panda/src/tform/mouseWatcher.cxx | 709 ++- panda/src/tform/mouseWatcher.h | 79 +- panda/src/tform/mouseWatcherBase.cxx | 260 +- panda/src/tform/mouseWatcherBase.h | 45 +- panda/src/tform/mouseWatcherGroup.cxx | 25 +- panda/src/tform/mouseWatcherGroup.h | 37 +- panda/src/tform/mouseWatcherParameter.I | 295 +- panda/src/tform/mouseWatcherParameter.cxx | 33 +- panda/src/tform/mouseWatcherParameter.h | 37 +- panda/src/tform/mouseWatcherRegion.I | 192 +- panda/src/tform/mouseWatcherRegion.cxx | 150 +- panda/src/tform/mouseWatcherRegion.h | 38 +- panda/src/tform/trackball.cxx | 350 +- panda/src/tform/trackball.h | 55 +- panda/src/tform/transform2sg.cxx | 72 +- panda/src/tform/transform2sg.h | 39 +- panda/src/tinydisplay/config_tinydisplay.cxx | 48 +- panda/src/tinydisplay/config_tinydisplay.h | 25 +- panda/src/tinydisplay/store_pixel.cxx | 25 +- panda/src/tinydisplay/store_pixel.h | 25 +- panda/src/tinydisplay/tinyGeomMunger.I | 26 +- panda/src/tinydisplay/tinyGeomMunger.cxx | 92 +- panda/src/tinydisplay/tinyGeomMunger.h | 37 +- panda/src/tinydisplay/tinyGraphicsBuffer.I | 35 +- panda/src/tinydisplay/tinyGraphicsBuffer.cxx | 108 +- panda/src/tinydisplay/tinyGraphicsBuffer.h | 35 +- .../tinydisplay/tinyGraphicsStateGuardian.I | 35 +- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 962 ++-- .../tinydisplay/tinyGraphicsStateGuardian.h | 57 +- .../tinydisplay/tinyOffscreenGraphicsPipe.I | 26 +- .../tinydisplay/tinyOffscreenGraphicsPipe.cxx | 78 +- .../tinydisplay/tinyOffscreenGraphicsPipe.h | 34 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.I | 26 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx | 114 +- panda/src/tinydisplay/tinyOsxGraphicsPipe.h | 40 +- panda/src/tinydisplay/tinyOsxGraphicsWindow.I | 27 +- panda/src/tinydisplay/tinyOsxGraphicsWindow.h | 51 +- .../src/tinydisplay/tinyOsxGraphicsWindow.mm | 765 ++- panda/src/tinydisplay/tinySDLGraphicsPipe.I | 26 +- panda/src/tinydisplay/tinySDLGraphicsPipe.cxx | 78 +- panda/src/tinydisplay/tinySDLGraphicsPipe.h | 34 +- panda/src/tinydisplay/tinySDLGraphicsWindow.I | 26 +- .../src/tinydisplay/tinySDLGraphicsWindow.cxx | 254 +- panda/src/tinydisplay/tinySDLGraphicsWindow.h | 34 +- panda/src/tinydisplay/tinyTextureContext.I | 42 +- panda/src/tinydisplay/tinyTextureContext.cxx | 50 +- panda/src/tinydisplay/tinyTextureContext.h | 32 +- panda/src/tinydisplay/tinyWinGraphicsPipe.I | 26 +- panda/src/tinydisplay/tinyWinGraphicsPipe.cxx | 88 +- panda/src/tinydisplay/tinyWinGraphicsPipe.h | 35 +- panda/src/tinydisplay/tinyWinGraphicsWindow.I | 26 +- .../src/tinydisplay/tinyWinGraphicsWindow.cxx | 174 +- panda/src/tinydisplay/tinyWinGraphicsWindow.h | 36 +- panda/src/tinydisplay/tinyXGraphicsPipe.I | 26 +- panda/src/tinydisplay/tinyXGraphicsPipe.cxx | 90 +- panda/src/tinydisplay/tinyXGraphicsPipe.h | 35 +- panda/src/tinydisplay/tinyXGraphicsWindow.I | 26 +- panda/src/tinydisplay/tinyXGraphicsWindow.cxx | 284 +- panda/src/tinydisplay/tinyXGraphicsWindow.h | 40 +- panda/src/vision/arToolKit.I | 39 +- panda/src/vision/arToolKit.cxx | 138 +- panda/src/vision/arToolKit.h | 67 +- panda/src/vision/config_vision.cxx | 40 +- panda/src/vision/config_vision.h | 26 +- panda/src/vision/openCVTexture.I | 70 +- panda/src/vision/openCVTexture.cxx | 360 +- panda/src/vision/openCVTexture.h | 55 +- panda/src/vision/webcamVideo.I | 73 +- panda/src/vision/webcamVideo.cxx | 79 +- panda/src/vision/webcamVideo.h | 34 +- panda/src/vision/webcamVideoCursorOpenCV.cxx | 103 +- panda/src/vision/webcamVideoCursorOpenCV.h | 32 +- panda/src/vision/webcamVideoCursorV4L.cxx | 55 +- panda/src/vision/webcamVideoCursorV4L.h | 32 +- panda/src/vision/webcamVideoDS.cxx | 344 +- panda/src/vision/webcamVideoOpenCV.cxx | 58 +- panda/src/vision/webcamVideoOpenCV.h | 37 +- panda/src/vision/webcamVideoV4L.cxx | 55 +- panda/src/vision/webcamVideoV4L.h | 32 +- panda/src/vrpn/config_vrpn.cxx | 25 +- panda/src/vrpn/config_vrpn.h | 25 +- panda/src/vrpn/vrpnAnalog.I | 56 +- panda/src/vrpn/vrpnAnalog.cxx | 88 +- panda/src/vrpn/vrpnAnalog.h | 54 +- panda/src/vrpn/vrpnAnalogDevice.I | 37 +- panda/src/vrpn/vrpnAnalogDevice.cxx | 41 +- panda/src/vrpn/vrpnAnalogDevice.h | 39 +- panda/src/vrpn/vrpnButton.I | 56 +- panda/src/vrpn/vrpnButton.cxx | 88 +- panda/src/vrpn/vrpnButton.h | 53 +- panda/src/vrpn/vrpnButtonDevice.I | 37 +- panda/src/vrpn/vrpnButtonDevice.cxx | 41 +- panda/src/vrpn/vrpnButtonDevice.h | 39 +- panda/src/vrpn/vrpnClient.I | 134 +- panda/src/vrpn/vrpnClient.cxx | 479 +- panda/src/vrpn/vrpnClient.h | 37 +- panda/src/vrpn/vrpnDial.I | 55 +- panda/src/vrpn/vrpnDial.cxx | 88 +- panda/src/vrpn/vrpnDial.h | 53 +- panda/src/vrpn/vrpnDialDevice.I | 37 +- panda/src/vrpn/vrpnDialDevice.cxx | 41 +- panda/src/vrpn/vrpnDialDevice.h | 39 +- panda/src/vrpn/vrpnTracker.I | 56 +- panda/src/vrpn/vrpnTracker.cxx | 110 +- panda/src/vrpn/vrpnTracker.h | 53 +- panda/src/vrpn/vrpnTrackerDevice.I | 61 +- panda/src/vrpn/vrpnTrackerDevice.cxx | 41 +- panda/src/vrpn/vrpnTrackerDevice.h | 48 +- panda/src/vrpn/vrpn_interface.h | 25 +- panda/src/wgldisplay/config_wgldisplay.cxx | 39 +- panda/src/wgldisplay/config_wgldisplay.h | 25 +- panda/src/wgldisplay/wglGraphicsBuffer.I | 25 +- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 265 +- panda/src/wgldisplay/wglGraphicsBuffer.h | 49 +- panda/src/wgldisplay/wglGraphicsPipe.I | 26 +- panda/src/wgldisplay/wglGraphicsPipe.cxx | 147 +- panda/src/wgldisplay/wglGraphicsPipe.h | 35 +- .../src/wgldisplay/wglGraphicsStateGuardian.I | 122 +- .../wgldisplay/wglGraphicsStateGuardian.cxx | 325 +- .../src/wgldisplay/wglGraphicsStateGuardian.h | 48 +- panda/src/wgldisplay/wglGraphicsWindow.I | 25 +- panda/src/wgldisplay/wglGraphicsWindow.cxx | 231 +- panda/src/wgldisplay/wglGraphicsWindow.h | 35 +- panda/src/windisplay/config_windisplay.cxx | 39 +- panda/src/windisplay/config_windisplay.h | 25 +- panda/src/windisplay/winDetectDx.h | 79 +- panda/src/windisplay/winDetectDx9.cxx | 25 +- panda/src/windisplay/winGraphicsPipe.I | 27 +- panda/src/windisplay/winGraphicsPipe.cxx | 64 +- panda/src/windisplay/winGraphicsPipe.h | 47 +- panda/src/windisplay/winGraphicsWindow.I | 116 +- panda/src/windisplay/winGraphicsWindow.cxx | 1165 ++--- panda/src/windisplay/winGraphicsWindow.h | 105 +- panda/src/x11display/config_x11display.cxx | 41 +- panda/src/x11display/config_x11display.h | 25 +- panda/src/x11display/x11GraphicsPipe.I | 122 +- panda/src/x11display/x11GraphicsPipe.cxx | 158 +- panda/src/x11display/x11GraphicsPipe.h | 40 +- panda/src/x11display/x11GraphicsWindow.I | 34 +- panda/src/x11display/x11GraphicsWindow.cxx | 554 +- panda/src/x11display/x11GraphicsWindow.h | 38 +- pandatool/src/assimp/assimpLoader.I | 26 +- pandatool/src/assimp/assimpLoader.cxx | 193 +- pandatool/src/assimp/assimpLoader.h | 35 +- pandatool/src/assimp/config_assimp.cxx | 39 +- pandatool/src/assimp/config_assimp.h | 25 +- pandatool/src/assimp/loaderFileTypeAssimp.cxx | 87 +- pandatool/src/assimp/loaderFileTypeAssimp.h | 35 +- pandatool/src/assimp/pandaIOStream.cxx | 81 +- pandatool/src/assimp/pandaIOStream.h | 35 +- pandatool/src/assimp/pandaIOSystem.cxx | 77 +- pandatool/src/assimp/pandaIOSystem.h | 33 +- pandatool/src/assimp/pandaLogger.cxx | 67 +- pandatool/src/assimp/pandaLogger.h | 34 +- pandatool/src/bam/bamInfo.cxx | 146 +- pandatool/src/bam/bamInfo.h | 32 +- pandatool/src/bam/bamToEgg.cxx | 53 +- pandatool/src/bam/bamToEgg.h | 35 +- pandatool/src/bam/eggToBam.cxx | 161 +- pandatool/src/bam/eggToBam.h | 32 +- pandatool/src/bam/ptsToBam.cxx | 90 +- pandatool/src/bam/ptsToBam.h | 32 +- .../src/converter/eggToSomethingConverter.I | 85 +- .../src/converter/eggToSomethingConverter.cxx | 82 +- .../src/converter/eggToSomethingConverter.h | 44 +- .../src/converter/somethingToEggConverter.I | 474 +- .../src/converter/somethingToEggConverter.cxx | 162 +- .../src/converter/somethingToEggConverter.h | 53 +- pandatool/src/cvscopy/cvsCopy.cxx | 233 +- pandatool/src/cvscopy/cvsCopy.h | 37 +- pandatool/src/cvscopy/cvsSourceDirectory.cxx | 133 +- pandatool/src/cvscopy/cvsSourceDirectory.h | 51 +- pandatool/src/cvscopy/cvsSourceTree.cxx | 340 +- pandatool/src/cvscopy/cvsSourceTree.h | 58 +- pandatool/src/cvscopy/testCopy.cxx | 54 +- pandatool/src/cvscopy/testCopy.h | 34 +- pandatool/src/daeegg/config_daeegg.cxx | 42 +- pandatool/src/daeegg/config_daeegg.h | 25 +- pandatool/src/daeegg/daeCharacter.cxx | 121 +- pandatool/src/daeegg/daeCharacter.h | 32 +- pandatool/src/daeegg/daeMaterials.cxx | 147 +- pandatool/src/daeegg/daeMaterials.h | 51 +- pandatool/src/daeegg/daeToEggConverter.cxx | 134 +- pandatool/src/daeegg/daeToEggConverter.h | 34 +- pandatool/src/daeegg/fcollada_utils.h | 29 +- pandatool/src/daeegg/pre_fcollada_include.h | 29 +- pandatool/src/daeprogs/daeToEgg.cxx | 41 +- pandatool/src/daeprogs/daeToEgg.h | 35 +- pandatool/src/daeprogs/eggToDAE.cxx | 60 +- pandatool/src/daeprogs/eggToDAE.h | 35 +- pandatool/src/dxf/dxfFile.cxx | 329 +- pandatool/src/dxf/dxfFile.h | 86 +- pandatool/src/dxf/dxfLayer.cxx | 41 +- pandatool/src/dxf/dxfLayer.h | 43 +- pandatool/src/dxf/dxfLayerMap.cxx | 44 +- pandatool/src/dxf/dxfLayerMap.h | 37 +- pandatool/src/dxf/dxfVertex.cxx | 37 +- pandatool/src/dxf/dxfVertex.h | 42 +- pandatool/src/dxfegg/dxfToEggConverter.cxx | 138 +- pandatool/src/dxfegg/dxfToEggConverter.h | 36 +- pandatool/src/dxfegg/dxfToEggLayer.cxx | 79 +- pandatool/src/dxfegg/dxfToEggLayer.h | 41 +- pandatool/src/dxfprogs/dxfPoints.cxx | 64 +- pandatool/src/dxfprogs/dxfPoints.h | 35 +- pandatool/src/dxfprogs/dxfToEgg.cxx | 41 +- pandatool/src/dxfprogs/dxfToEgg.h | 37 +- pandatool/src/dxfprogs/eggToDXF.cxx | 85 +- pandatool/src/dxfprogs/eggToDXF.h | 33 +- pandatool/src/dxfprogs/eggToDXFLayer.cxx | 143 +- pandatool/src/dxfprogs/eggToDXFLayer.h | 33 +- pandatool/src/egg-mkfont/eggMakeFont.cxx | 250 +- pandatool/src/egg-mkfont/eggMakeFont.h | 43 +- pandatool/src/egg-mkfont/rangeDescription.I | 67 +- pandatool/src/egg-mkfont/rangeDescription.cxx | 109 +- pandatool/src/egg-mkfont/rangeDescription.h | 36 +- pandatool/src/egg-mkfont/rangeIterator.I | 45 +- pandatool/src/egg-mkfont/rangeIterator.cxx | 55 +- pandatool/src/egg-mkfont/rangeIterator.h | 35 +- .../src/egg-optchar/config_egg_optchar.cxx | 39 +- .../src/egg-optchar/config_egg_optchar.h | 25 +- pandatool/src/egg-optchar/eggOptchar.cxx | 563 +- pandatool/src/egg-optchar/eggOptchar.h | 39 +- .../src/egg-optchar/eggOptcharUserData.I | 84 +- .../src/egg-optchar/eggOptcharUserData.cxx | 25 +- .../src/egg-optchar/eggOptcharUserData.h | 35 +- pandatool/src/egg-optchar/vertexMembership.I | 58 +- .../src/egg-optchar/vertexMembership.cxx | 25 +- pandatool/src/egg-optchar/vertexMembership.h | 35 +- pandatool/src/egg-palettize/eggPalettize.cxx | 138 +- pandatool/src/egg-palettize/eggPalettize.h | 43 +- pandatool/src/egg-palettize/txaFileFilter.I | 26 +- pandatool/src/egg-palettize/txaFileFilter.cxx | 72 +- pandatool/src/egg-palettize/txaFileFilter.h | 65 +- pandatool/src/egg-qtess/config_egg_qtess.cxx | 25 +- pandatool/src/egg-qtess/config_egg_qtess.h | 25 +- pandatool/src/egg-qtess/eggQtess.cxx | 93 +- pandatool/src/egg-qtess/eggQtess.h | 39 +- pandatool/src/egg-qtess/isoPlacer.I | 42 +- pandatool/src/egg-qtess/isoPlacer.cxx | 84 +- pandatool/src/egg-qtess/isoPlacer.h | 35 +- pandatool/src/egg-qtess/qtessGlobals.cxx | 25 +- pandatool/src/egg-qtess/qtessGlobals.h | 36 +- pandatool/src/egg-qtess/qtessInputEntry.I | 155 +- pandatool/src/egg-qtess/qtessInputEntry.cxx | 194 +- pandatool/src/egg-qtess/qtessInputEntry.h | 36 +- pandatool/src/egg-qtess/qtessInputFile.I | 48 +- pandatool/src/egg-qtess/qtessInputFile.cxx | 128 +- pandatool/src/egg-qtess/qtessInputFile.h | 34 +- pandatool/src/egg-qtess/qtessSurface.I | 173 +- pandatool/src/egg-qtess/qtessSurface.cxx | 241 +- pandatool/src/egg-qtess/qtessSurface.h | 64 +- pandatool/src/egg-qtess/subdivSegment.I | 67 +- pandatool/src/egg-qtess/subdivSegment.cxx | 42 +- pandatool/src/egg-qtess/subdivSegment.h | 35 +- pandatool/src/eggbase/eggBase.cxx | 198 +- pandatool/src/eggbase/eggBase.h | 45 +- pandatool/src/eggbase/eggConverter.cxx | 47 +- pandatool/src/eggbase/eggConverter.h | 37 +- pandatool/src/eggbase/eggFilter.cxx | 58 +- pandatool/src/eggbase/eggFilter.h | 37 +- pandatool/src/eggbase/eggMakeSomething.cxx | 34 +- pandatool/src/eggbase/eggMakeSomething.h | 35 +- pandatool/src/eggbase/eggMultiBase.cxx | 89 +- pandatool/src/eggbase/eggMultiBase.h | 43 +- pandatool/src/eggbase/eggMultiFilter.cxx | 90 +- pandatool/src/eggbase/eggMultiFilter.h | 38 +- pandatool/src/eggbase/eggReader.cxx | 197 +- pandatool/src/eggbase/eggReader.h | 38 +- pandatool/src/eggbase/eggSingleBase.cxx | 84 +- pandatool/src/eggbase/eggSingleBase.h | 45 +- pandatool/src/eggbase/eggToSomething.cxx | 102 +- pandatool/src/eggbase/eggToSomething.h | 37 +- pandatool/src/eggbase/eggWriter.cxx | 139 +- pandatool/src/eggbase/eggWriter.h | 36 +- pandatool/src/eggbase/somethingToEgg.cxx | 152 +- pandatool/src/eggbase/somethingToEgg.h | 37 +- .../src/eggcharbase/config_eggcharbase.cxx | 39 +- .../src/eggcharbase/config_eggcharbase.h | 28 +- pandatool/src/eggcharbase/eggBackPointer.cxx | 72 +- pandatool/src/eggcharbase/eggBackPointer.h | 50 +- .../src/eggcharbase/eggCharacterCollection.I | 122 +- .../eggcharbase/eggCharacterCollection.cxx | 348 +- .../src/eggcharbase/eggCharacterCollection.h | 41 +- pandatool/src/eggcharbase/eggCharacterData.I | 195 +- .../src/eggcharbase/eggCharacterData.cxx | 280 +- pandatool/src/eggcharbase/eggCharacterData.h | 74 +- pandatool/src/eggcharbase/eggCharacterDb.I | 42 +- pandatool/src/eggcharbase/eggCharacterDb.cxx | 84 +- pandatool/src/eggcharbase/eggCharacterDb.h | 48 +- .../src/eggcharbase/eggCharacterFilter.cxx | 87 +- .../src/eggcharbase/eggCharacterFilter.h | 46 +- pandatool/src/eggcharbase/eggComponentData.I | 63 +- .../src/eggcharbase/eggComponentData.cxx | 109 +- pandatool/src/eggcharbase/eggComponentData.h | 45 +- pandatool/src/eggcharbase/eggJointData.I | 113 +- pandatool/src/eggcharbase/eggJointData.cxx | 401 +- pandatool/src/eggcharbase/eggJointData.h | 39 +- .../src/eggcharbase/eggJointNodePointer.cxx | 195 +- .../src/eggcharbase/eggJointNodePointer.h | 34 +- pandatool/src/eggcharbase/eggJointPointer.I | 26 +- pandatool/src/eggcharbase/eggJointPointer.cxx | 120 +- pandatool/src/eggcharbase/eggJointPointer.h | 43 +- .../src/eggcharbase/eggMatrixTablePointer.cxx | 201 +- .../src/eggcharbase/eggMatrixTablePointer.h | 43 +- .../src/eggcharbase/eggScalarTablePointer.cxx | 87 +- .../src/eggcharbase/eggScalarTablePointer.h | 41 +- pandatool/src/eggcharbase/eggSliderData.I | 25 +- pandatool/src/eggcharbase/eggSliderData.cxx | 60 +- pandatool/src/eggcharbase/eggSliderData.h | 41 +- .../src/eggcharbase/eggSliderPointer.cxx | 26 +- pandatool/src/eggcharbase/eggSliderPointer.h | 35 +- .../src/eggcharbase/eggVertexPointer.cxx | 64 +- pandatool/src/eggcharbase/eggVertexPointer.h | 37 +- pandatool/src/eggprogs/eggCrop.cxx | 74 +- pandatool/src/eggprogs/eggCrop.h | 36 +- pandatool/src/eggprogs/eggListTextures.cxx | 41 +- pandatool/src/eggprogs/eggListTextures.h | 34 +- pandatool/src/eggprogs/eggMakeTube.cxx | 97 +- pandatool/src/eggprogs/eggMakeTube.h | 35 +- pandatool/src/eggprogs/eggRename.cxx | 41 +- pandatool/src/eggprogs/eggRename.h | 36 +- pandatool/src/eggprogs/eggRetargetAnim.cxx | 75 +- pandatool/src/eggprogs/eggRetargetAnim.h | 38 +- pandatool/src/eggprogs/eggTextureCards.cxx | 158 +- pandatool/src/eggprogs/eggTextureCards.h | 37 +- pandatool/src/eggprogs/eggToC.cxx | 83 +- pandatool/src/eggprogs/eggToC.h | 32 +- pandatool/src/eggprogs/eggTopstrip.cxx | 113 +- pandatool/src/eggprogs/eggTopstrip.h | 39 +- pandatool/src/eggprogs/eggTrans.cxx | 41 +- pandatool/src/eggprogs/eggTrans.h | 36 +- pandatool/src/flt/config_flt.cxx | 40 +- pandatool/src/flt/config_flt.h | 25 +- pandatool/src/flt/fltBead.cxx | 248 +- pandatool/src/flt/fltBead.h | 40 +- pandatool/src/flt/fltBeadID.cxx | 121 +- pandatool/src/flt/fltBeadID.h | 35 +- pandatool/src/flt/fltCurve.I | 43 +- pandatool/src/flt/fltCurve.cxx | 59 +- pandatool/src/flt/fltCurve.h | 34 +- pandatool/src/flt/fltError.cxx | 25 +- pandatool/src/flt/fltError.h | 28 +- pandatool/src/flt/fltExternalReference.cxx | 105 +- pandatool/src/flt/fltExternalReference.h | 36 +- pandatool/src/flt/fltEyepoint.cxx | 49 +- pandatool/src/flt/fltEyepoint.h | 36 +- pandatool/src/flt/fltFace.I | 26 +- pandatool/src/flt/fltFace.cxx | 59 +- pandatool/src/flt/fltFace.h | 34 +- pandatool/src/flt/fltGeometry.I | 100 +- pandatool/src/flt/fltGeometry.cxx | 138 +- pandatool/src/flt/fltGeometry.h | 39 +- pandatool/src/flt/fltGroup.cxx | 59 +- pandatool/src/flt/fltGroup.h | 34 +- pandatool/src/flt/fltHeader.cxx | 1009 ++-- pandatool/src/flt/fltHeader.h | 64 +- pandatool/src/flt/fltInstanceDefinition.cxx | 59 +- pandatool/src/flt/fltInstanceDefinition.h | 44 +- pandatool/src/flt/fltInstanceRef.cxx | 94 +- pandatool/src/flt/fltInstanceRef.h | 40 +- pandatool/src/flt/fltLOD.cxx | 59 +- pandatool/src/flt/fltLOD.h | 34 +- .../src/flt/fltLightSourceDefinition.cxx | 59 +- pandatool/src/flt/fltLightSourceDefinition.h | 43 +- pandatool/src/flt/fltLocalVertexPool.I | 25 +- pandatool/src/flt/fltLocalVertexPool.cxx | 74 +- pandatool/src/flt/fltLocalVertexPool.h | 40 +- pandatool/src/flt/fltMaterial.cxx | 85 +- pandatool/src/flt/fltMaterial.h | 34 +- pandatool/src/flt/fltMesh.I | 25 +- pandatool/src/flt/fltMesh.cxx | 85 +- pandatool/src/flt/fltMesh.h | 35 +- pandatool/src/flt/fltMeshPrimitive.I | 25 +- pandatool/src/flt/fltMeshPrimitive.cxx | 62 +- pandatool/src/flt/fltMeshPrimitive.h | 35 +- pandatool/src/flt/fltObject.cxx | 59 +- pandatool/src/flt/fltObject.h | 34 +- pandatool/src/flt/fltOpcode.cxx | 25 +- pandatool/src/flt/fltOpcode.h | 26 +- pandatool/src/flt/fltPackedColor.I | 75 +- pandatool/src/flt/fltPackedColor.cxx | 49 +- pandatool/src/flt/fltPackedColor.h | 37 +- pandatool/src/flt/fltRecord.I | 25 +- pandatool/src/flt/fltRecord.cxx | 451 +- pandatool/src/flt/fltRecord.h | 42 +- pandatool/src/flt/fltRecordReader.cxx | 127 +- pandatool/src/flt/fltRecordReader.h | 40 +- pandatool/src/flt/fltRecordWriter.cxx | 111 +- pandatool/src/flt/fltRecordWriter.h | 36 +- pandatool/src/flt/fltTexture.cxx | 170 +- pandatool/src/flt/fltTexture.h | 34 +- pandatool/src/flt/fltTrackplane.cxx | 49 +- pandatool/src/flt/fltTrackplane.h | 36 +- .../src/flt/fltTransformGeneralMatrix.cxx | 75 +- pandatool/src/flt/fltTransformGeneralMatrix.h | 37 +- pandatool/src/flt/fltTransformPut.cxx | 127 +- pandatool/src/flt/fltTransformPut.h | 37 +- pandatool/src/flt/fltTransformRecord.cxx | 43 +- pandatool/src/flt/fltTransformRecord.h | 39 +- .../src/flt/fltTransformRotateAboutEdge.cxx | 104 +- .../src/flt/fltTransformRotateAboutEdge.h | 34 +- .../src/flt/fltTransformRotateAboutPoint.cxx | 103 +- .../src/flt/fltTransformRotateAboutPoint.h | 34 +- pandatool/src/flt/fltTransformRotateScale.cxx | 141 +- pandatool/src/flt/fltTransformRotateScale.h | 36 +- pandatool/src/flt/fltTransformScale.cxx | 112 +- pandatool/src/flt/fltTransformScale.h | 33 +- pandatool/src/flt/fltTransformTranslate.cxx | 99 +- pandatool/src/flt/fltTransformTranslate.h | 32 +- pandatool/src/flt/fltUnsupportedRecord.cxx | 72 +- pandatool/src/flt/fltUnsupportedRecord.h | 34 +- pandatool/src/flt/fltVectorRecord.cxx | 68 +- pandatool/src/flt/fltVectorRecord.h | 39 +- pandatool/src/flt/fltVertex.I | 49 +- pandatool/src/flt/fltVertex.cxx | 121 +- pandatool/src/flt/fltVertex.h | 45 +- pandatool/src/flt/fltVertexList.cxx | 104 +- pandatool/src/flt/fltVertexList.h | 35 +- pandatool/src/fltegg/fltToEggConverter.I | 26 +- pandatool/src/fltegg/fltToEggConverter.cxx | 374 +- pandatool/src/fltegg/fltToEggConverter.h | 45 +- pandatool/src/fltegg/fltToEggLevelState.I | 49 +- pandatool/src/fltegg/fltToEggLevelState.cxx | 103 +- pandatool/src/fltegg/fltToEggLevelState.h | 34 +- pandatool/src/fltprogs/eggToFlt.cxx | 154 +- pandatool/src/fltprogs/eggToFlt.h | 39 +- pandatool/src/fltprogs/fltCopy.cxx | 99 +- pandatool/src/fltprogs/fltCopy.h | 35 +- pandatool/src/fltprogs/fltInfo.cxx | 58 +- pandatool/src/fltprogs/fltInfo.h | 34 +- pandatool/src/fltprogs/fltToEgg.cxx | 45 +- pandatool/src/fltprogs/fltToEgg.h | 36 +- pandatool/src/fltprogs/fltTrans.cxx | 53 +- pandatool/src/fltprogs/fltTrans.h | 36 +- pandatool/src/gtk-stats/gtkStats.cxx | 53 +- pandatool/src/gtk-stats/gtkStats.h | 26 +- pandatool/src/gtk-stats/gtkStatsChartMenu.cxx | 144 +- pandatool/src/gtk-stats/gtkStatsChartMenu.h | 34 +- pandatool/src/gtk-stats/gtkStatsGraph.cxx | 416 +- pandatool/src/gtk-stats/gtkStatsGraph.h | 68 +- pandatool/src/gtk-stats/gtkStatsLabel.cxx | 181 +- pandatool/src/gtk-stats/gtkStatsLabel.h | 60 +- .../src/gtk-stats/gtkStatsLabelStack.cxx | 120 +- pandatool/src/gtk-stats/gtkStatsLabelStack.h | 34 +- pandatool/src/gtk-stats/gtkStatsMenuId.h | 39 +- pandatool/src/gtk-stats/gtkStatsMonitor.I | 42 +- pandatool/src/gtk-stats/gtkStatsMonitor.cxx | 351 +- pandatool/src/gtk-stats/gtkStatsMonitor.h | 40 +- pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx | 344 +- pandatool/src/gtk-stats/gtkStatsPianoRoll.h | 42 +- pandatool/src/gtk-stats/gtkStatsServer.cxx | 33 +- pandatool/src/gtk-stats/gtkStatsServer.h | 34 +- .../src/gtk-stats/gtkStatsStripChart.cxx | 428 +- pandatool/src/gtk-stats/gtkStatsStripChart.h | 47 +- pandatool/src/imagebase/imageBase.cxx | 42 +- pandatool/src/imagebase/imageBase.h | 45 +- pandatool/src/imagebase/imageFilter.cxx | 46 +- pandatool/src/imagebase/imageFilter.h | 37 +- pandatool/src/imagebase/imageReader.cxx | 41 +- pandatool/src/imagebase/imageReader.h | 36 +- pandatool/src/imagebase/imageWriter.I | 35 +- pandatool/src/imagebase/imageWriter.cxx | 58 +- pandatool/src/imagebase/imageWriter.h | 36 +- .../src/imageprogs/imageFixHiddenColor.I | 26 +- .../src/imageprogs/imageFixHiddenColor.cxx | 48 +- .../src/imageprogs/imageFixHiddenColor.h | 34 +- pandatool/src/imageprogs/imageInfo.cxx | 65 +- pandatool/src/imageprogs/imageInfo.h | 36 +- pandatool/src/imageprogs/imageResize.I | 104 +- pandatool/src/imageprogs/imageResize.cxx | 51 +- pandatool/src/imageprogs/imageResize.h | 35 +- pandatool/src/imageprogs/imageTrans.cxx | 58 +- pandatool/src/imageprogs/imageTrans.h | 38 +- .../src/imageprogs/imageTransformColors.I | 26 +- .../src/imageprogs/imageTransformColors.cxx | 121 +- .../src/imageprogs/imageTransformColors.h | 37 +- pandatool/src/lwo/config_lwo.cxx | 40 +- pandatool/src/lwo/config_lwo.h | 25 +- pandatool/src/lwo/iffChunk.I | 50 +- pandatool/src/lwo/iffChunk.cxx | 52 +- pandatool/src/lwo/iffChunk.h | 36 +- pandatool/src/lwo/iffGenericChunk.I | 50 +- pandatool/src/lwo/iffGenericChunk.cxx | 50 +- pandatool/src/lwo/iffGenericChunk.h | 37 +- pandatool/src/lwo/iffId.I | 97 +- pandatool/src/lwo/iffId.cxx | 33 +- pandatool/src/lwo/iffId.h | 37 +- pandatool/src/lwo/iffInputFile.I | 75 +- pandatool/src/lwo/iffInputFile.cxx | 208 +- pandatool/src/lwo/iffInputFile.h | 35 +- pandatool/src/lwo/lwoBoundingBox.cxx | 49 +- pandatool/src/lwo/lwoBoundingBox.h | 35 +- pandatool/src/lwo/lwoChunk.cxx | 25 +- pandatool/src/lwo/lwoChunk.h | 39 +- pandatool/src/lwo/lwoClip.cxx | 61 +- pandatool/src/lwo/lwoClip.h | 36 +- .../src/lwo/lwoDiscontinuousVertexMap.cxx | 74 +- pandatool/src/lwo/lwoDiscontinuousVertexMap.h | 37 +- pandatool/src/lwo/lwoGroupChunk.cxx | 74 +- pandatool/src/lwo/lwoGroupChunk.h | 36 +- pandatool/src/lwo/lwoHeader.I | 45 +- pandatool/src/lwo/lwoHeader.cxx | 57 +- pandatool/src/lwo/lwoHeader.h | 34 +- pandatool/src/lwo/lwoInputFile.I | 49 +- pandatool/src/lwo/lwoInputFile.cxx | 85 +- pandatool/src/lwo/lwoInputFile.h | 35 +- pandatool/src/lwo/lwoLayer.cxx | 59 +- pandatool/src/lwo/lwoLayer.h | 40 +- pandatool/src/lwo/lwoPoints.cxx | 65 +- pandatool/src/lwo/lwoPoints.h | 35 +- pandatool/src/lwo/lwoPolygonTags.cxx | 69 +- pandatool/src/lwo/lwoPolygonTags.h | 39 +- pandatool/src/lwo/lwoPolygons.cxx | 76 +- pandatool/src/lwo/lwoPolygons.h | 47 +- pandatool/src/lwo/lwoStillImage.cxx | 49 +- pandatool/src/lwo/lwoStillImage.h | 34 +- pandatool/src/lwo/lwoSurface.cxx | 61 +- pandatool/src/lwo/lwoSurface.h | 39 +- pandatool/src/lwo/lwoSurfaceBlock.cxx | 61 +- pandatool/src/lwo/lwoSurfaceBlock.h | 37 +- pandatool/src/lwo/lwoSurfaceBlockAxis.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockAxis.h | 39 +- pandatool/src/lwo/lwoSurfaceBlockChannel.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockChannel.h | 37 +- pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockCoordSys.h | 37 +- pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockEnabled.h | 37 +- pandatool/src/lwo/lwoSurfaceBlockHeader.cxx | 61 +- pandatool/src/lwo/lwoSurfaceBlockHeader.h | 36 +- pandatool/src/lwo/lwoSurfaceBlockImage.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockImage.h | 37 +- pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockOpacity.h | 37 +- .../src/lwo/lwoSurfaceBlockProjection.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockProjection.h | 39 +- pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockRefObj.h | 36 +- pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockRepeat.h | 41 +- pandatool/src/lwo/lwoSurfaceBlockTMap.cxx | 61 +- pandatool/src/lwo/lwoSurfaceBlockTMap.h | 36 +- .../src/lwo/lwoSurfaceBlockTransform.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockTransform.h | 41 +- pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockVMapName.h | 36 +- pandatool/src/lwo/lwoSurfaceBlockWrap.cxx | 49 +- pandatool/src/lwo/lwoSurfaceBlockWrap.h | 35 +- pandatool/src/lwo/lwoSurfaceColor.cxx | 49 +- pandatool/src/lwo/lwoSurfaceColor.h | 35 +- pandatool/src/lwo/lwoSurfaceParameter.cxx | 49 +- pandatool/src/lwo/lwoSurfaceParameter.h | 38 +- pandatool/src/lwo/lwoSurfaceSidedness.cxx | 49 +- pandatool/src/lwo/lwoSurfaceSidedness.h | 37 +- .../src/lwo/lwoSurfaceSmoothingAngle.cxx | 49 +- pandatool/src/lwo/lwoSurfaceSmoothingAngle.h | 36 +- pandatool/src/lwo/lwoTags.cxx | 65 +- pandatool/src/lwo/lwoTags.h | 44 +- pandatool/src/lwo/lwoVertexMap.cxx | 70 +- pandatool/src/lwo/lwoVertexMap.h | 37 +- pandatool/src/lwo/test_lwo.cxx | 25 +- pandatool/src/lwoegg/cLwoClip.I | 49 +- pandatool/src/lwoegg/cLwoClip.cxx | 33 +- pandatool/src/lwoegg/cLwoClip.h | 37 +- pandatool/src/lwoegg/cLwoLayer.I | 45 +- pandatool/src/lwoegg/cLwoLayer.cxx | 46 +- pandatool/src/lwoegg/cLwoLayer.h | 37 +- pandatool/src/lwoegg/cLwoPoints.I | 34 +- pandatool/src/lwoegg/cLwoPoints.cxx | 69 +- pandatool/src/lwoegg/cLwoPoints.h | 41 +- pandatool/src/lwoegg/cLwoPolygons.I | 34 +- pandatool/src/lwoegg/cLwoPolygons.cxx | 136 +- pandatool/src/lwoegg/cLwoPolygons.h | 41 +- pandatool/src/lwoegg/cLwoSurface.I | 62 +- pandatool/src/lwoegg/cLwoSurface.cxx | 232 +- pandatool/src/lwoegg/cLwoSurface.h | 37 +- pandatool/src/lwoegg/cLwoSurfaceBlock.I | 25 +- pandatool/src/lwoegg/cLwoSurfaceBlock.cxx | 46 +- pandatool/src/lwoegg/cLwoSurfaceBlock.h | 37 +- pandatool/src/lwoegg/cLwoSurfaceBlockTMap.I | 25 +- pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx | 44 +- pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h | 37 +- pandatool/src/lwoegg/lwoToEggConverter.I | 25 +- pandatool/src/lwoegg/lwoToEggConverter.cxx | 218 +- pandatool/src/lwoegg/lwoToEggConverter.h | 39 +- pandatool/src/lwoprogs/lwoScan.cxx | 49 +- pandatool/src/lwoprogs/lwoScan.h | 34 +- pandatool/src/lwoprogs/lwoToEgg.cxx | 41 +- pandatool/src/lwoprogs/lwoToEgg.h | 34 +- pandatool/src/maxegg/maxEgg.cxx | 70 +- pandatool/src/maxegg/maxEgg.h | 20 +- pandatool/src/maxegg/maxEggLoader.cxx | 61 +- pandatool/src/maxegg/maxEggLoader.h | 26 +- pandatool/src/maxegg/maxNodeDesc.cxx | 162 +- pandatool/src/maxegg/maxNodeDesc.h | 40 +- pandatool/src/maxegg/maxNodeTree.cxx | 272 +- pandatool/src/maxegg/maxNodeTree.h | 42 +- pandatool/src/maxegg/maxOptionsDialog.cxx | 86 +- pandatool/src/maxegg/maxOptionsDialog.h | 16 +- pandatool/src/maxegg/maxToEggConverter.cxx | 699 ++- pandatool/src/maxegg/maxToEggConverter.h | 58 +- pandatool/src/maxprogs/maxEggImport.cxx | 62 +- pandatool/src/maya/config_maya.cxx | 40 +- pandatool/src/maya/config_maya.h | 25 +- pandatool/src/maya/mayaApi.cxx | 255 +- pandatool/src/maya/mayaApi.h | 37 +- pandatool/src/maya/mayaShader.cxx | 229 +- pandatool/src/maya/mayaShader.h | 49 +- pandatool/src/maya/mayaShaderColorDef.cxx | 322 +- pandatool/src/maya/mayaShaderColorDef.h | 88 +- pandatool/src/maya/mayaShaders.cxx | 131 +- pandatool/src/maya/mayaShaders.h | 38 +- pandatool/src/maya/maya_funcs.I | 40 +- pandatool/src/maya/maya_funcs.cxx | 206 +- pandatool/src/maya/maya_funcs.h | 31 +- pandatool/src/maya/post_maya_include.h | 29 +- pandatool/src/maya/pre_maya_include.h | 64 +- pandatool/src/mayaegg/config_mayaegg.cxx | 60 +- pandatool/src/mayaegg/config_mayaegg.h | 25 +- pandatool/src/mayaegg/mayaBlendDesc.cxx | 70 +- pandatool/src/mayaegg/mayaBlendDesc.h | 46 +- pandatool/src/mayaegg/mayaEggGroupUserData.I | 52 +- .../src/mayaegg/mayaEggGroupUserData.cxx | 25 +- pandatool/src/mayaegg/mayaEggGroupUserData.h | 35 +- pandatool/src/mayaegg/mayaEggLoader.cxx | 169 +- pandatool/src/mayaegg/mayaEggLoader.h | 26 +- pandatool/src/mayaegg/mayaNodeDesc.cxx | 353 +- pandatool/src/mayaegg/mayaNodeDesc.h | 41 +- pandatool/src/mayaegg/mayaNodeTree.cxx | 372 +- pandatool/src/mayaegg/mayaNodeTree.h | 37 +- pandatool/src/mayaegg/mayaToEggConverter.cxx | 1425 +++--- pandatool/src/mayaegg/mayaToEggConverter.h | 69 +- pandatool/src/mayaprogs/blend_test.cxx | 6 +- pandatool/src/mayaprogs/config_mayaloader.cxx | 39 +- pandatool/src/mayaprogs/eggToMaya.cxx | 63 +- pandatool/src/mayaprogs/eggToMaya.h | 33 +- pandatool/src/mayaprogs/mayaCopy.cxx | 170 +- pandatool/src/mayaprogs/mayaCopy.h | 33 +- pandatool/src/mayaprogs/mayaEggImport.cxx | 51 +- pandatool/src/mayaprogs/mayaPview.cxx | 131 +- pandatool/src/mayaprogs/mayaPview.h | 35 +- pandatool/src/mayaprogs/mayaSavePview.cxx | 77 +- pandatool/src/mayaprogs/mayaSavePview.h | 74 +- pandatool/src/mayaprogs/mayaToEgg.cxx | 134 +- pandatool/src/mayaprogs/mayaToEgg.h | 34 +- pandatool/src/mayaprogs/mayaToEgg_client.cxx | 37 +- pandatool/src/mayaprogs/mayaToEgg_client.h | 32 +- pandatool/src/mayaprogs/mayaToEgg_server.cxx | 143 +- pandatool/src/mayaprogs/mayaToEgg_server.h | 34 +- pandatool/src/mayaprogs/mayapath.cxx | 116 +- pandatool/src/mayaprogs/normal_test.cxx | 16 +- pandatool/src/miscprogs/binToC.cxx | 55 +- pandatool/src/miscprogs/binToC.h | 37 +- pandatool/src/objegg/config_objegg.cxx | 40 +- pandatool/src/objegg/config_objegg.h | 25 +- pandatool/src/objegg/eggToObjConverter.cxx | 234 +- pandatool/src/objegg/eggToObjConverter.h | 34 +- pandatool/src/objegg/objToEggConverter.I | 58 +- pandatool/src/objegg/objToEggConverter.cxx | 401 +- pandatool/src/objegg/objToEggConverter.h | 37 +- pandatool/src/objprogs/eggToObj.cxx | 54 +- pandatool/src/objprogs/eggToObj.h | 32 +- pandatool/src/objprogs/objToEgg.cxx | 41 +- pandatool/src/objprogs/objToEgg.h | 35 +- .../src/palettizer/config_palettizer.cxx | 43 +- pandatool/src/palettizer/config_palettizer.h | 25 +- pandatool/src/palettizer/destTextureImage.cxx | 117 +- pandatool/src/palettizer/destTextureImage.h | 36 +- pandatool/src/palettizer/eggFile.cxx | 559 +- pandatool/src/palettizer/eggFile.h | 44 +- pandatool/src/palettizer/filenameUnifier.cxx | 118 +- pandatool/src/palettizer/filenameUnifier.h | 43 +- pandatool/src/palettizer/imageFile.cxx | 330 +- pandatool/src/palettizer/imageFile.h | 38 +- pandatool/src/palettizer/omitReason.cxx | 25 +- pandatool/src/palettizer/omitReason.h | 47 +- pandatool/src/palettizer/pal_string_utils.cxx | 35 +- pandatool/src/palettizer/pal_string_utils.h | 26 +- pandatool/src/palettizer/paletteGroup.cxx | 568 +- pandatool/src/palettizer/paletteGroup.h | 49 +- pandatool/src/palettizer/paletteGroups.cxx | 247 +- pandatool/src/palettizer/paletteGroups.h | 40 +- pandatool/src/palettizer/paletteImage.cxx | 535 +- pandatool/src/palettizer/paletteImage.h | 51 +- pandatool/src/palettizer/palettePage.cxx | 220 +- pandatool/src/palettizer/palettePage.h | 43 +- pandatool/src/palettizer/palettizer.cxx | 571 +-- pandatool/src/palettizer/palettizer.h | 58 +- .../src/palettizer/sourceTextureImage.cxx | 191 +- pandatool/src/palettizer/sourceTextureImage.h | 35 +- pandatool/src/palettizer/textureImage.cxx | 750 ++- pandatool/src/palettizer/textureImage.h | 58 +- .../src/palettizer/textureMemoryCounter.cxx | 122 +- .../src/palettizer/textureMemoryCounter.h | 37 +- pandatool/src/palettizer/texturePlacement.cxx | 698 +-- pandatool/src/palettizer/texturePlacement.h | 47 +- pandatool/src/palettizer/texturePosition.cxx | 93 +- pandatool/src/palettizer/texturePosition.h | 40 +- .../src/palettizer/textureProperties.cxx | 365 +- pandatool/src/palettizer/textureProperties.h | 39 +- pandatool/src/palettizer/textureReference.cxx | 576 +-- pandatool/src/palettizer/textureReference.h | 39 +- pandatool/src/palettizer/textureRequest.cxx | 42 +- pandatool/src/palettizer/textureRequest.h | 36 +- pandatool/src/palettizer/txaFile.cxx | 249 +- pandatool/src/palettizer/txaFile.h | 36 +- pandatool/src/palettizer/txaLine.cxx | 144 +- pandatool/src/palettizer/txaLine.h | 38 +- .../src/pandatoolbase/animationConvert.cxx | 49 +- .../src/pandatoolbase/animationConvert.h | 35 +- .../pandatoolbase/config_pandatoolbase.cxx | 40 +- .../src/pandatoolbase/config_pandatoolbase.h | 25 +- pandatool/src/pandatoolbase/distanceUnit.cxx | 85 +- pandatool/src/pandatoolbase/distanceUnit.h | 35 +- pandatool/src/pandatoolbase/pandatoolbase.cxx | 25 +- pandatool/src/pandatoolbase/pandatoolbase.h | 12 +- .../src/pandatoolbase/pandatoolsymbols.h | 11 +- pandatool/src/pandatoolbase/pathReplace.I | 156 +- pandatool/src/pandatoolbase/pathReplace.cxx | 249 +- pandatool/src/pandatoolbase/pathReplace.h | 66 +- pandatool/src/pandatoolbase/pathStore.cxx | 51 +- pandatool/src/pandatoolbase/pathStore.h | 35 +- pandatool/src/pfmprogs/config_pfm.cxx | 40 +- pandatool/src/pfmprogs/config_pfm.h | 25 +- pandatool/src/pfmprogs/pfmBba.cxx | 66 +- pandatool/src/pfmprogs/pfmBba.h | 32 +- pandatool/src/pfmprogs/pfmTrans.cxx | 142 +- pandatool/src/pfmprogs/pfmTrans.h | 32 +- pandatool/src/progbase/programBase.I | 35 +- pandatool/src/progbase/programBase.cxx | 819 ++- pandatool/src/progbase/programBase.h | 39 +- pandatool/src/progbase/test_prog.cxx | 25 +- pandatool/src/progbase/withOutputFile.I | 36 +- pandatool/src/progbase/withOutputFile.cxx | 134 +- pandatool/src/progbase/withOutputFile.h | 44 +- pandatool/src/progbase/wordWrapStream.cxx | 33 +- pandatool/src/progbase/wordWrapStream.h | 47 +- pandatool/src/progbase/wordWrapStreamBuf.I | 43 +- pandatool/src/progbase/wordWrapStreamBuf.cxx | 84 +- pandatool/src/progbase/wordWrapStreamBuf.h | 34 +- pandatool/src/pstatserver/pStatClientData.cxx | 292 +- pandatool/src/pstatserver/pStatClientData.h | 39 +- pandatool/src/pstatserver/pStatGraph.I | 149 +- pandatool/src/pstatserver/pStatGraph.cxx | 205 +- pandatool/src/pstatserver/pStatGraph.h | 41 +- pandatool/src/pstatserver/pStatListener.cxx | 46 +- pandatool/src/pstatserver/pStatListener.h | 35 +- pandatool/src/pstatserver/pStatMonitor.I | 91 +- pandatool/src/pstatserver/pStatMonitor.cxx | 303 +- pandatool/src/pstatserver/pStatMonitor.h | 56 +- pandatool/src/pstatserver/pStatPianoRoll.I | 81 +- pandatool/src/pstatserver/pStatPianoRoll.cxx | 217 +- pandatool/src/pstatserver/pStatPianoRoll.h | 45 +- pandatool/src/pstatserver/pStatReader.cxx | 178 +- pandatool/src/pstatserver/pStatReader.h | 41 +- pandatool/src/pstatserver/pStatServer.cxx | 265 +- pandatool/src/pstatserver/pStatServer.h | 51 +- pandatool/src/pstatserver/pStatStripChart.I | 189 +- pandatool/src/pstatserver/pStatStripChart.cxx | 532 +- pandatool/src/pstatserver/pStatStripChart.h | 46 +- pandatool/src/pstatserver/pStatThreadData.I | 35 +- pandatool/src/pstatserver/pStatThreadData.cxx | 258 +- pandatool/src/pstatserver/pStatThreadData.h | 43 +- pandatool/src/pstatserver/pStatView.I | 99 +- pandatool/src/pstatserver/pStatView.cxx | 321 +- pandatool/src/pstatserver/pStatView.h | 42 +- pandatool/src/pstatserver/pStatViewLevel.I | 46 +- pandatool/src/pstatserver/pStatViewLevel.cxx | 71 +- pandatool/src/pstatserver/pStatViewLevel.h | 40 +- pandatool/src/ptloader/config_ptloader.cxx | 58 +- pandatool/src/ptloader/config_ptloader.h | 25 +- .../src/ptloader/loaderFileTypePandatool.cxx | 140 +- .../src/ptloader/loaderFileTypePandatool.h | 38 +- pandatool/src/softegg/config_softegg.cxx | 55 +- pandatool/src/softegg/config_softegg.h | 25 +- pandatool/src/softegg/soft2Egg.c | 922 ++-- pandatool/src/softegg/softEggGroupUserData.I | 52 +- .../src/softegg/softEggGroupUserData.cxx | 25 +- pandatool/src/softegg/softEggGroupUserData.h | 35 +- pandatool/src/softegg/softNodeDesc.cxx | 436 +- pandatool/src/softegg/softNodeDesc.h | 43 +- pandatool/src/softegg/softNodeTree.cxx | 301 +- pandatool/src/softegg/softNodeTree.h | 38 +- pandatool/src/softegg/softToEggConverter.cxx | 620 +-- pandatool/src/softegg/softToEggConverter.h | 46 +- pandatool/src/softprogs/softCVS.cxx | 243 +- pandatool/src/softprogs/softCVS.h | 35 +- pandatool/src/softprogs/softFilename.cxx | 238 +- pandatool/src/softprogs/softFilename.h | 44 +- pandatool/src/text-stats/textMonitor.I | 26 +- pandatool/src/text-stats/textMonitor.cxx | 151 +- pandatool/src/text-stats/textMonitor.h | 40 +- pandatool/src/text-stats/textStats.cxx | 59 +- pandatool/src/text-stats/textStats.h | 41 +- pandatool/src/vrml/parse_vrml.cxx | 58 +- pandatool/src/vrml/parse_vrml.h | 23 +- pandatool/src/vrml/standard_nodes.cxx | 41 +- pandatool/src/vrml/standard_nodes.h | 26 +- pandatool/src/vrml/vrmlLexerDefs.h | 25 +- pandatool/src/vrml/vrmlNode.cxx | 25 +- pandatool/src/vrml/vrmlNode.h | 23 +- pandatool/src/vrml/vrmlParser.yxx | 25 +- pandatool/src/vrml/vrmlParserDefs.h | 25 +- pandatool/src/vrmlegg/indexedFaceSet.cxx | 249 +- pandatool/src/vrmlegg/indexedFaceSet.h | 32 +- pandatool/src/vrmlegg/vrmlAppearance.cxx | 25 +- pandatool/src/vrmlegg/vrmlAppearance.h | 23 +- pandatool/src/vrmlegg/vrmlToEggConverter.cxx | 220 +- pandatool/src/vrmlegg/vrmlToEggConverter.h | 38 +- pandatool/src/vrmlprogs/vrmlToEgg.cxx | 41 +- pandatool/src/vrmlprogs/vrmlToEgg.h | 37 +- pandatool/src/vrmlprogs/vrmlTrans.cxx | 53 +- pandatool/src/vrmlprogs/vrmlTrans.h | 36 +- pandatool/src/win-stats/winStats.cxx | 58 +- pandatool/src/win-stats/winStats.h | 26 +- pandatool/src/win-stats/winStatsChartMenu.cxx | 132 +- pandatool/src/win-stats/winStatsChartMenu.h | 34 +- pandatool/src/win-stats/winStatsGraph.cxx | 311 +- pandatool/src/win-stats/winStatsGraph.h | 38 +- pandatool/src/win-stats/winStatsLabel.cxx | 192 +- pandatool/src/win-stats/winStatsLabel.h | 38 +- .../src/win-stats/winStatsLabelStack.cxx | 215 +- pandatool/src/win-stats/winStatsLabelStack.h | 34 +- pandatool/src/win-stats/winStatsMenuId.h | 39 +- pandatool/src/win-stats/winStatsMonitor.I | 42 +- pandatool/src/win-stats/winStatsMonitor.cxx | 424 +- pandatool/src/win-stats/winStatsMonitor.h | 36 +- pandatool/src/win-stats/winStatsPianoRoll.cxx | 314 +- pandatool/src/win-stats/winStatsPianoRoll.h | 38 +- pandatool/src/win-stats/winStatsServer.cxx | 33 +- pandatool/src/win-stats/winStatsServer.h | 34 +- .../src/win-stats/winStatsStripChart.cxx | 412 +- pandatool/src/win-stats/winStatsStripChart.h | 37 +- pandatool/src/xfile/config_xfile.cxx | 47 +- pandatool/src/xfile/config_xfile.h | 25 +- pandatool/src/xfile/standard_templates.cxx | 45 +- pandatool/src/xfile/standard_templates.h | 26 +- pandatool/src/xfile/windowsGuid.I | 100 +- pandatool/src/xfile/windowsGuid.cxx | 56 +- pandatool/src/xfile/windowsGuid.h | 44 +- pandatool/src/xfile/xFile.I | 26 +- pandatool/src/xfile/xFile.cxx | 282 +- pandatool/src/xfile/xFile.h | 43 +- pandatool/src/xfile/xFileArrayDef.I | 73 +- pandatool/src/xfile/xFileArrayDef.cxx | 65 +- pandatool/src/xfile/xFileArrayDef.h | 36 +- pandatool/src/xfile/xFileDataDef.I | 79 +- pandatool/src/xfile/xFileDataDef.cxx | 231 +- pandatool/src/xfile/xFileDataDef.h | 71 +- pandatool/src/xfile/xFileDataNode.I | 69 +- pandatool/src/xfile/xFileDataNode.cxx | 77 +- pandatool/src/xfile/xFileDataNode.h | 49 +- pandatool/src/xfile/xFileDataNodeReference.I | 34 +- .../src/xfile/xFileDataNodeReference.cxx | 117 +- pandatool/src/xfile/xFileDataNodeReference.h | 46 +- pandatool/src/xfile/xFileDataNodeTemplate.I | 26 +- pandatool/src/xfile/xFileDataNodeTemplate.cxx | 179 +- pandatool/src/xfile/xFileDataNodeTemplate.h | 44 +- pandatool/src/xfile/xFileDataObject.I | 362 +- pandatool/src/xfile/xFileDataObject.cxx | 288 +- pandatool/src/xfile/xFileDataObject.h | 48 +- pandatool/src/xfile/xFileDataObjectArray.I | 34 +- pandatool/src/xfile/xFileDataObjectArray.cxx | 86 +- pandatool/src/xfile/xFileDataObjectArray.h | 34 +- pandatool/src/xfile/xFileDataObjectDouble.I | 26 +- pandatool/src/xfile/xFileDataObjectDouble.cxx | 104 +- pandatool/src/xfile/xFileDataObjectDouble.h | 37 +- pandatool/src/xfile/xFileDataObjectInteger.I | 26 +- .../src/xfile/xFileDataObjectInteger.cxx | 87 +- pandatool/src/xfile/xFileDataObjectInteger.h | 37 +- pandatool/src/xfile/xFileDataObjectString.I | 26 +- pandatool/src/xfile/xFileDataObjectString.cxx | 85 +- pandatool/src/xfile/xFileDataObjectString.h | 37 +- pandatool/src/xfile/xFileNode.I | 80 +- pandatool/src/xfile/xFileNode.cxx | 370 +- pandatool/src/xfile/xFileNode.h | 51 +- pandatool/src/xfile/xFileParseData.I | 26 +- pandatool/src/xfile/xFileParseData.cxx | 49 +- pandatool/src/xfile/xFileParseData.h | 54 +- pandatool/src/xfile/xFileTemplate.I | 97 +- pandatool/src/xfile/xFileTemplate.cxx | 123 +- pandatool/src/xfile/xFileTemplate.h | 41 +- pandatool/src/xfile/xLexerDefs.h | 27 +- pandatool/src/xfile/xParser.yxx | 9 +- pandatool/src/xfile/xParserDefs.h | 40 +- pandatool/src/xfileegg/xFileAnimationSet.I | 53 +- pandatool/src/xfileegg/xFileAnimationSet.cxx | 93 +- pandatool/src/xfileegg/xFileAnimationSet.h | 41 +- pandatool/src/xfileegg/xFileFace.cxx | 45 +- pandatool/src/xfileegg/xFileFace.h | 33 +- pandatool/src/xfileegg/xFileMaker.cxx | 145 +- pandatool/src/xfileegg/xFileMaker.h | 34 +- pandatool/src/xfileegg/xFileMaterial.cxx | 110 +- pandatool/src/xfileegg/xFileMaterial.h | 35 +- pandatool/src/xfileegg/xFileMesh.cxx | 368 +- pandatool/src/xfileegg/xFileMesh.h | 33 +- pandatool/src/xfileegg/xFileNormal.cxx | 53 +- pandatool/src/xfileegg/xFileNormal.h | 38 +- .../src/xfileegg/xFileToEggConverter.cxx | 396 +- pandatool/src/xfileegg/xFileToEggConverter.h | 46 +- pandatool/src/xfileegg/xFileVertex.cxx | 53 +- pandatool/src/xfileegg/xFileVertex.h | 34 +- pandatool/src/xfileegg/xFileVertexPool.h | 37 +- pandatool/src/xfileprogs/eggToX.cxx | 41 +- pandatool/src/xfileprogs/eggToX.h | 35 +- pandatool/src/xfileprogs/xFileToEgg.cxx | 43 +- pandatool/src/xfileprogs/xFileToEgg.h | 34 +- pandatool/src/xfileprogs/xFileTrans.cxx | 53 +- pandatool/src/xfileprogs/xFileTrans.h | 36 +- 5633 files changed, 249886 insertions(+), 351170 deletions(-) delete mode 100644 direct/src/directscripts/doxygen_filter.py diff --git a/contrib/src/ai/aiBehaviors.cxx b/contrib/src/ai/aiBehaviors.cxx index 3981c6991b..727e7e12f4 100644 --- a/contrib/src/ai/aiBehaviors.cxx +++ b/contrib/src/ai/aiBehaviors.cxx @@ -1,16 +1,15 @@ -// Filename: aiBehaviors.cxx -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiBehaviors.cxx + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #include "aiBehaviors.h" @@ -47,12 +46,11 @@ AIBehaviors::~AIBehaviors() { } -//////////////////////////////////////////////////////////////////// -// Function: is_conflict -// Description: Checks for conflict between steering forces. -// If there is a conflict it returns 'true' and sets _conflict to 'true'. -// If there is no conflict it returns 'false' and sets _conflict to 'false'. -//////////////////////////////////////////////////////////////////// +/** + * Checks for conflict between steering forces. If there is a conflict it + * returns 'true' and sets _conflict to 'true'. If there is no conflict it + * returns 'false' and sets _conflict to 'false'. + */ bool AIBehaviors::is_conflict() { int value = int(is_on(_seek)) + int(is_on(_flee)) + int(is_on(_pursue)) + int(is_on(_evade)) + int(is_on(_wander)) + int(is_on(_flock))+ int(is_on(_obstacle_avoidance)); @@ -98,12 +96,11 @@ bool AIBehaviors::is_conflict() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: accumulate_force -// Description: This function updates the individual steering forces for each of the ai characters. -// These accumulated forces are eventually what comprise the resultant -// steering force of the character. -//////////////////////////////////////////////////////////////////// +/** + * This function updates the individual steering forces for each of the ai + * characters. These accumulated forces are eventually what comprise the + * resultant steering force of the character. + */ void AIBehaviors::accumulate_force(string force_type, LVecBase3 force) { @@ -153,13 +150,12 @@ void AIBehaviors::accumulate_force(string force_type, LVecBase3 force) { } -//////////////////////////////////////////////////////////////////// -// Function: calculate_prioritized -// Description: This function updates the main steering force for the ai character using -// the accumulate function and checks for max force and arrival force. -// It finally returns this steering force which is accessed by the update -// function in the AICharacter class. -//////////////////////////////////////////////////////////////////// +/** + * This function updates the main steering force for the ai character using + * the accumulate function and checks for max force and arrival force. It + * finally returns this steering force which is accessed by the update + * function in the AICharacter class. + */ LVecBase3 AIBehaviors::calculate_prioritized() { LVecBase3 force; @@ -305,10 +301,9 @@ LVecBase3 AIBehaviors::calculate_prioritized() { return _steering_force; } -//////////////////////////////////////////////////////////////////// -// Function: remove_ai -// Description: This function removes individual or all the AIs. -//////////////////////////////////////////////////////////////////// +/** + * This function removes individual or all the AIs. + */ void AIBehaviors::remove_ai(string ai_type) { switch(char_to_int(ai_type)) { case 0: { @@ -422,10 +417,9 @@ void AIBehaviors::remove_ai(string ai_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: pause_ai -// Description: This function pauses individual or all the AIs. -//////////////////////////////////////////////////////////////////// +/** + * This function pauses individual or all the AIs. + */ void AIBehaviors::pause_ai(string ai_type) { switch(char_to_int(ai_type)) { case 0: { @@ -521,10 +515,9 @@ void AIBehaviors::pause_ai(string ai_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: resume_ai -// Description: This function resumes individual or all the AIs -//////////////////////////////////////////////////////////////////// +/** + * This function resumes individual or all the AIs + */ void AIBehaviors::resume_ai(string ai_type) { switch(char_to_int(ai_type)) { case 0: { @@ -615,12 +608,11 @@ void AIBehaviors::resume_ai(string ai_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: seek -// Description: This function activates seek and makes an object of the Seek class. -// This is the function we want the user to call for seek to be done. -// This function is overloaded to accept a NodePath or an LVecBase3. -//////////////////////////////////////////////////////////////////// +/** + * This function activates seek and makes an object of the Seek class. This + * is the function we want the user to call for seek to be done. This + * function is overloaded to accept a NodePath or an LVecBase3. + */ void AIBehaviors::seek(NodePath target_object, float seek_wt) { _seek_obj = new Seek(_ai_char, target_object, seek_wt); turn_on("seek"); @@ -631,11 +623,10 @@ void AIBehaviors::seek(LVecBase3 pos, float seek_wt) { turn_on("seek"); } -//////////////////////////////////////////////////////////////////// -// Function: flee -// Description: This function activates flee_activate and creates an object of the Flee class. -// This function is overloaded to accept a NodePath or an LVecBase3. -//////////////////////////////////////////////////////////////////// +/** + * This function activates flee_activate and creates an object of the Flee + * class. This function is overloaded to accept a NodePath or an LVecBase3. + */ void AIBehaviors::flee(NodePath target_object, double panic_distance, double relax_distance, float flee_wt) { _flee_obj = new Flee(_ai_char, target_object, panic_distance, relax_distance, flee_wt); _flee_list.insert(_flee_list.end(), *_flee_obj); @@ -650,21 +641,19 @@ void AIBehaviors::flee(LVecBase3 pos, double panic_distance, double relax_distan turn_on("flee_activate"); } -//////////////////////////////////////////////////////////////////// -// Function: pursue -// Description: This function activates pursue. -// This is the function we want the user to call for pursue to be done. -//////////////////////////////////////////////////////////////////// +/** + * This function activates pursue. This is the function we want the user to + * call for pursue to be done. + */ void AIBehaviors::pursue(NodePath target_object, float pursue_wt) { _pursue_obj = new Pursue(_ai_char, target_object, pursue_wt); turn_on("pursue"); } -//////////////////////////////////////////////////////////////////// -// Function: evade -// Description: This function activates evade_activate. -//////////////////////////////////////////////////////////////////// +/** + * This function activates evade_activate. + */ void AIBehaviors::evade(NodePath target_object, double panic_distance, double relax_distance, float evade_wt) { _evade_obj = new Evade(_ai_char, target_object, panic_distance, relax_distance, evade_wt); _evade_list.insert(_evade_list.end(), *_evade_obj); @@ -672,11 +661,10 @@ void AIBehaviors::evade(NodePath target_object, double panic_distance, double re turn_on("evade_activate"); } -//////////////////////////////////////////////////////////////////// -// Function: arrival -// Description: This function activates arrival. -// This is the function we want the user to call for arrival to be done. -//////////////////////////////////////////////////////////////////// +/** + * This function activates arrival. This is the function we want the user to + * call for arrival to be done. + */ void AIBehaviors::arrival(double distance) { if(_pursue_obj) { _arrival_obj = new Arrival(_ai_char, distance); @@ -693,11 +681,10 @@ void AIBehaviors::arrival(double distance) { } } -//////////////////////////////////////////////////////////////////// -// Function: flock -// Description: This function activates flock. -// This is the function we want the user to call for flock to be done. -//////////////////////////////////////////////////////////////////// +/** + * This function activates flock. This is the function we want the user to + * call for flock to be done. + */ void AIBehaviors::flock(float flock_wt) { _flock_weight = flock_wt; @@ -705,11 +692,10 @@ void AIBehaviors::flock(float flock_wt) { turn_on("flock_activate"); } -//////////////////////////////////////////////////////////////////// -// Function: flock_activate -// Description: This function checks whether any other behavior exists to work with flock. -// When this is true, it calls the do_flock function. -//////////////////////////////////////////////////////////////////// +/** + * This function checks whether any other behavior exists to work with flock. + * When this is true, it calls the do_flock function. + */ void AIBehaviors::flock_activate() { if(is_on(_seek) || is_on(_flee) || is_on(_pursue) || is_on(_evade) || is_on(_wander)) { turn_off("flock_activate"); @@ -717,18 +703,17 @@ void AIBehaviors::flock_activate() { } } -//////////////////////////////////////////////////////////////////// -// Function: do_flock -// Description: This function contains the logic for flocking behavior. This is -// an emergent behavior and is obtained by combining three other -// behaviors which are separation, cohesion and alignment based on -// Craig Reynold's algorithm. Also, this behavior does not work by -// itself. It works only when combined with other steering behaviors -// such as wander, pursue, evade, seek and flee. -//////////////////////////////////////////////////////////////////// +/** + * This function contains the logic for flocking behavior. This is an + * emergent behavior and is obtained by combining three other behaviors which + * are separation, cohesion and alignment based on Craig Reynold's algorithm. + * Also, this behavior does not work by itself. It works only when combined + * with other steering behaviors such as wander, pursue, evade, seek and flee. + */ LVecBase3 AIBehaviors::do_flock() { - //! Initialize variables required to compute the flocking force on the ai char. + // ! Initialize variables required to compute the flocking force on the ai + // char. unsigned int neighbor_count = 0; LVecBase3 separation_force = LVecBase3(0.0, 0.0, 0.0); LVecBase3 alignment_force = LVecBase3(0.0, 0.0, 0.0); @@ -738,38 +723,40 @@ LVecBase3 AIBehaviors::do_flock() { LVecBase3 avg_center_of_mass = LVecBase3(0.0, 0.0, 0.0); LVecBase3 total_center_of_mass = LVecBase3(0.0, 0.0, 0.0); - //! Loop through all the other AI units in the flock to check if they are neigbours. + // ! Loop through all the other AI units in the flock to check if they are + // neigbours. for(unsigned int i = 0; i < _flock_group->_ai_char_list.size(); i++) { if(_flock_group->_ai_char_list[i]->_name != _ai_char->_name) { - //! Using visibilty cone to detect neighbors. + // ! Using visibilty cone to detect neighbors. LVecBase3 dist_vect = _flock_group->_ai_char_list[i]->_ai_char_np.get_pos() - _ai_char->_ai_char_np.get_pos(); LVecBase3 ai_char_heading = _ai_char->get_velocity(); ai_char_heading.normalize(); - //! Check if the current unit is a neighbor. + // ! Check if the current unit is a neighbor. if(dist_vect.dot(ai_char_heading) > ((dist_vect.length()) * (ai_char_heading.length()) * cos(_flock_group->_flock_vcone_angle * (_PI / 180))) && (dist_vect.length() < _flock_group->_flock_vcone_radius)) { - //! Separation force calculation. + // ! Separation force calculation. LVecBase3 ai_char_to_units = _ai_char->_ai_char_np.get_pos() - _flock_group->_ai_char_list[i]->_ai_char_np.get_pos(); float to_units_dist = ai_char_to_units.length(); ai_char_to_units.normalize(); separation_force += (ai_char_to_units / to_units_dist); - //! Calculating the total heading and center of mass of all the neighbors. + // ! Calculating the total heading and center of mass of all the + // neighbors. LVecBase3 neighbor_heading = _flock_group->_ai_char_list[i]->get_velocity(); neighbor_heading.normalize(); total_neighbor_heading += neighbor_heading; total_center_of_mass += _flock_group->_ai_char_list[i]->_ai_char_np.get_pos(); - //! Update the neighbor count. + // ! Update the neighbor count. ++neighbor_count; } } } if(neighbor_count > 0) { - //! Alignment force calculation + // ! Alignment force calculation avg_neighbor_heading = total_neighbor_heading / neighbor_count; LVector3 ai_char_heading = _ai_char->get_velocity(); ai_char_heading.normalize(); @@ -777,7 +764,7 @@ LVecBase3 AIBehaviors::do_flock() { avg_neighbor_heading.normalize(); alignment_force = avg_neighbor_heading; - //! Cohesion force calculation + // ! Cohesion force calculation avg_center_of_mass = total_center_of_mass / neighbor_count; LVecBase3 cohesion_dir = avg_center_of_mass - _ai_char->_ai_char_np.get_pos(); cohesion_dir.normalize(); @@ -790,115 +777,105 @@ LVecBase3 AIBehaviors::do_flock() { return(LVecBase3(0.0, 0.0, 0.0)); } - //! Calculate the resultant force on the ai character by taking into account the separation, alignment and cohesion - //! forces along with their corresponding weights. + // ! Calculate the resultant force on the ai character by taking into + // account the separation, alignment and cohesion ! forces along with their + // corresponding weights. return (separation_force * _flock_group->_separation_wt + avg_neighbor_heading * _flock_group->_alignment_wt + cohesion_force * _flock_group->_cohesion_wt); } -//////////////////////////////////////////////////////////////////// -// Function: wander -// Description: This function activates wander. -// This is the function we want the user to call for flock to be done. -//////////////////////////////////////////////////////////////////// +/** + * This function activates wander. This is the function we want the user to + * call for flock to be done. + */ void AIBehaviors::wander(double wander_radius, int flag, double aoe, float wander_weight) { _wander_obj = new Wander(_ai_char, wander_radius, flag, aoe, wander_weight); turn_on("wander"); } -//////////////////////////////////////////////////////////////////// -// Function: obstacle avoidance -// Description: This function activates obstacle avoidance for a given character. -// This is the function we want the user to call for -// obstacle avoidance to be performed. -//////////////////////////////////////////////////////////////////// +/** + * This function activates obstacle avoidance for a given character. This is + * the function we want the user to call for obstacle avoidance to be + * performed. + */ void AIBehaviors::obstacle_avoidance(float obstacle_avoidance_weight) { _obstacle_avoidance_obj = new ObstacleAvoidance(_ai_char, obstacle_avoidance_weight); turn_on("obstacle_avoidance_activate"); } -//////////////////////////////////////////////////////////////////// -// Function: path_follow -// Description: This function activates path following. -// This is the function we want the user to call for path following. -//////////////////////////////////////////////////////////////////// +/** + * This function activates path following. This is the function we want the + * user to call for path following. + */ void AIBehaviors::path_follow(float follow_wt) { _path_follow_obj = new PathFollow(_ai_char, follow_wt); } -//////////////////////////////////////////////////////////////////// -// Function: add_to_path -// Description: This function adds positions to the path to follow. -//////////////////////////////////////////////////////////////////// +/** + * This function adds positions to the path to follow. + */ void AIBehaviors::add_to_path(LVecBase3 pos) { _path_follow_obj->add_to_path(pos); } -//////////////////////////////////////////////////////////////////// -// Function: start_follow -// Description: This function starts the path follower. -//////////////////////////////////////////////////////////////////// +/** + * This function starts the path follower. + */ void AIBehaviors::start_follow(string type) { _path_follow_obj->start(type); } -//////////////////////////////////////////////////////////////////// -// Function: init_path_find -// Description: This function activates path finding in the character. -// This function accepts the meshdata in .csv format. -// -//////////////////////////////////////////////////////////////////// +/** + * This function activates path finding in the character. This function + * accepts the meshdata in .csv format. + * + */ void AIBehaviors::init_path_find(const char* navmesh_filename) { _path_find_obj = new PathFind(_ai_char); _path_find_obj->set_path_find(navmesh_filename); } -//////////////////////////////////////////////////////////////////// -// Function: path_find_to (for pathfinding towards a static position) -// Description: This function checks for the source and target in the navigation mesh -// for its availability and then finds the best path via the A* algorithm -// Then it calls the path follower to make the object follow the path. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for the source and target in the navigation mesh for + * its availability and then finds the best path via the A* algorithm Then it + * calls the path follower to make the object follow the path. + */ void AIBehaviors::path_find_to(LVecBase3 pos, string type) { _path_find_obj->path_find(pos, type); } -//////////////////////////////////////////////////////////////////// -// Function: path_find_to (for pathfinding towards a moving target (a NodePath)) -// Description: This function checks for the source and target in the navigation mesh -// for its availability and then finds the best path via the A* algorithm -// Then it calls the path follower to make the object follow the path. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for the source and target in the navigation mesh for + * its availability and then finds the best path via the A* algorithm Then it + * calls the path follower to make the object follow the path. + */ void AIBehaviors::path_find_to(NodePath target, string type) { _path_find_obj->path_find(target, type); } -//////////////////////////////////////////////////////////////////// -// Function: add_static_obstacle -// Description: This function allows the user to dynamically add obstacles to the -// game environment. The function will update the nodes within the -// bounding volume of the obstacle as non-traversable. Hence will not be -// considered by the pathfinding algorithm. -//////////////////////////////////////////////////////////////////// +/** + * This function allows the user to dynamically add obstacles to the game + * environment. The function will update the nodes within the bounding volume + * of the obstacle as non-traversable. Hence will not be considered by the + * pathfinding algorithm. + */ void AIBehaviors::add_static_obstacle(NodePath obstacle) { _path_find_obj->add_obstacle_to_mesh(obstacle); } -//////////////////////////////////////////////////////////////////// -// Function: add_dynamic_obstacle -// Description: This function starts the pathfinding obstacle navigation for the -// passed in obstacle. -//////////////////////////////////////////////////////////////////// +/** + * This function starts the pathfinding obstacle navigation for the passed in + * obstacle. + */ void AIBehaviors::add_dynamic_obstacle(NodePath obstacle) { _path_find_obj->dynamic_avoid(obstacle); } -//////////////////////////////////////////////////////////////////// -// Function: behavior_status -// Description: This function returns the status of an AI Type whether it is active, -// paused or disabled. It returns -1 if an invalid string is passed. -//////////////////////////////////////////////////////////////////// +/** + * This function returns the status of an AI Type whether it is active, paused + * or disabled. It returns -1 if an invalid string is passed. + */ string AIBehaviors::behavior_status(string ai_type) { switch(char_to_int(ai_type)) { case 1: @@ -1113,11 +1090,10 @@ string AIBehaviors::behavior_status(string ai_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: char_to_int -// Description: This function is used to derive int values from the ai types strings. -// Returns -1 if an invalid string is passed. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to derive int values from the ai types strings. + * Returns -1 if an invalid string is passed. + */ int AIBehaviors::char_to_int(string ai_type) { if(ai_type == "all") { return 0; @@ -1174,10 +1150,9 @@ int AIBehaviors::char_to_int(string ai_type) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: turn_on -// Description: This function turns on any aiBehavior which is passed as a string. -//////////////////////////////////////////////////////////////////// +/** + * This function turns on any aiBehavior which is passed as a string. + */ void AIBehaviors::turn_on(string ai_type) { switch(char_to_int(ai_type)) { case 1: { @@ -1237,10 +1212,9 @@ void AIBehaviors::turn_on(string ai_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: turn_off -// Description: This function turns off any aiBehavior which is passed as a string. -//////////////////////////////////////////////////////////////////// +/** + * This function turns off any aiBehavior which is passed as a string. + */ void AIBehaviors::turn_off(string ai_type) { switch(char_to_int(ai_type)) { case 1: { @@ -1342,18 +1316,16 @@ switch(char_to_int(ai_type)) { } } -//////////////////////////////////////////////////////////////////// -// Function: is_on -// Description: This function returns true if an aiBehavior is on -//////////////////////////////////////////////////////////////////// +/** + * This function returns true if an aiBehavior is on + */ bool AIBehaviors::is_on(_behavior_type bt) { return (_behaviors_flags & bt) == bt; } -//////////////////////////////////////////////////////////////////// -// Function: is_on -// Description: This function returns true if pathfollow or pathfinding is on -//////////////////////////////////////////////////////////////////// +/** + * This function returns true if pathfollow or pathfinding is on + */ bool AIBehaviors::is_on(string ai_type) { if(ai_type == "pathfollow") { if(_path_follow_obj) { @@ -1376,18 +1348,16 @@ bool AIBehaviors::is_on(string ai_type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: is_off -// Description: This function returns true if an aiBehavior is off -//////////////////////////////////////////////////////////////////// +/** + * This function returns true if an aiBehavior is off + */ bool AIBehaviors::is_off(_behavior_type bt) { return ((_behaviors_flags | bt) == bt); } -//////////////////////////////////////////////////////////////////// -// Function: is_off -// Description: This function returns true if pathfollow or pathfinding is off -//////////////////////////////////////////////////////////////////// +/** + * This function returns true if pathfollow or pathfinding is off + */ bool AIBehaviors::is_off(string ai_type) { if(ai_type == "pathfollow") { if(_path_follow_obj && _path_follow_obj->_start) { diff --git a/contrib/src/ai/aiBehaviors.h b/contrib/src/ai/aiBehaviors.h index e8e4207d1e..3c11b5e7a8 100644 --- a/contrib/src/ai/aiBehaviors.h +++ b/contrib/src/ai/aiBehaviors.h @@ -1,16 +1,15 @@ -// Filename: aiBehaviors.h -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiBehaviors.h + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #pragma warning (disable:4996) #pragma warning (disable:4005) @@ -36,15 +35,16 @@ class ObstacleAvoidance; typedef list > ListFlee; typedef list > ListEvade; -//////////////////////////////////////////////////////////////////// -// Class : AIBehaviors -// Description : This class implements all the steering behaviors of the AI framework, such as -// seek, flee, pursue, evade, wander and flock. Each steering behavior has a weight which is used when more than -// one type of steering behavior is acting on the same ai character. The weight decides the contribution of each -// type of steering behavior. The AICharacter class has a handle to an object of this class and this allows to -// invoke the steering behaviors via the AICharacter. This class also provides functionality such as pausing, resuming -// and removing the AI behaviors of an AI character at anytime. -//////////////////////////////////////////////////////////////////// +/** + * This class implements all the steering behaviors of the AI framework, such + * as seek, flee, pursue, evade, wander and flock. Each steering behavior has + * a weight which is used when more than one type of steering behavior is + * acting on the same ai character. The weight decides the contribution of + * each type of steering behavior. The AICharacter class has a handle to an + * object of this class and this allows to invoke the steering behaviors via + * the AICharacter. This class also provides functionality such as pausing, + * resuming and removing the AI behaviors of an AI character at anytime. + */ class EXPCL_PANDAAI AIBehaviors { public: enum _behavior_type { @@ -76,7 +76,8 @@ public: Flee *_flee_obj; LVecBase3 _flee_force; - //! This list is used if the ai character needs to flee from multiple onjects. + // ! This list is used if the ai character needs to flee from multiple + // onjects. ListFlee _flee_list; ListFlee::iterator _flee_itr; @@ -86,14 +87,16 @@ public: Evade *_evade_obj; LVecBase3 _evade_force; - //! This list is used if the ai character needs to evade from multiple onjects. + // ! This list is used if the ai character needs to evade from multiple + // onjects. ListEvade _evade_list; ListEvade::iterator _evade_itr; Arrival *_arrival_obj; LVecBase3 _arrival_force; - //! Since Flock is a collective behavior the variables are declared within the AIBehaviors class. + // ! Since Flock is a collective behavior the variables are declared within + // the AIBehaviors class. float _flock_weight; LVecBase3 _flock_force; bool _flock_done; @@ -159,7 +162,7 @@ PUBLISHED: void path_find_to(NodePath target, string type = "normal"); void add_static_obstacle(NodePath obstacle); void add_dynamic_obstacle(NodePath obstacle); - // + void remove_ai(string ai_type); void pause_ai(string ai_type); diff --git a/contrib/src/ai/aiCharacter.cxx b/contrib/src/ai/aiCharacter.cxx index b5c2736f56..7009a353f1 100644 --- a/contrib/src/ai/aiCharacter.cxx +++ b/contrib/src/ai/aiCharacter.cxx @@ -1,16 +1,15 @@ -// Filename: aiCharacter.cxx -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiCharacter.cxx + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #include "aiCharacter.h" @@ -34,13 +33,11 @@ AICharacter::AICharacter(string model_name, NodePath model_np, double mass, doub AICharacter::~AICharacter() { } -//////////////////////////////////////////////////////////////////// -// Function: update -// Description: Each character's update will update its AI and -// physics based on his resultant steering force. -// This also makes the character look in the direction -// of the force. -//////////////////////////////////////////////////////////////////// +/** + * Each character's update will update its AI and physics based on his + * resultant steering force. This also makes the character look in the + * direction of the force. + */ void AICharacter:: update() { if (!_steering->is_off(_steering->_none)) { diff --git a/contrib/src/ai/aiCharacter.h b/contrib/src/ai/aiCharacter.h index 259518fe83..5d2b2c1d51 100644 --- a/contrib/src/ai/aiCharacter.h +++ b/contrib/src/ai/aiCharacter.h @@ -1,16 +1,15 @@ -// Filename: aiCharacter.h -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiCharacter.h + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #pragma warning (disable:4996) #pragma warning (disable:4005) @@ -22,14 +21,12 @@ #include "aiBehaviors.h" -//////////////////////////////////////////////////////////////////// -// Class : AICharacter -// Description : This class is used for creating the AI characters. -// It assigns both physics and AI attributes to the -// character. It also has an update function which -// updates the physics and AI of the character. -// This update function is called by the AIWorld update. -//////////////////////////////////////////////////////////////////// +/** + * This class is used for creating the AI characters. It assigns both physics + * and AI attributes to the character. It also has an update function which + * updates the physics and AI of the character. This update function is + * called by the AIWorld update. + */ class AIBehaviors; class AIWorld; diff --git a/contrib/src/ai/aiGlobals.h b/contrib/src/ai/aiGlobals.h index 29a0ac0ccc..749cb9ec21 100644 --- a/contrib/src/ai/aiGlobals.h +++ b/contrib/src/ai/aiGlobals.h @@ -1,16 +1,15 @@ -// Filename: aiGlobals.h -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiGlobals.h + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #pragma warning (disable:4996) #pragma warning (disable:4005) diff --git a/contrib/src/ai/aiNode.cxx b/contrib/src/ai/aiNode.cxx index 713d349f7e..a37927ae63 100644 --- a/contrib/src/ai/aiNode.cxx +++ b/contrib/src/ai/aiNode.cxx @@ -1,16 +1,15 @@ -// Filename: aiNode.cxx -// Created by: Deepak, John, Navin (19Nov2009) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiNode.cxx + * @author Deepak, John, Navin + * @date 2009-11-19 + */ #include "aiNode.h" @@ -37,11 +36,10 @@ AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) AINode::~AINode() { } -//////////////////////////////////////////////////////////////////// -// Function: contains -// Description: This is a handy function which returns true if the -// passed position is within the node's dimensions. -//////////////////////////////////////////////////////////////////// +/** + * This is a handy function which returns true if the passed position is + * within the node's dimensions. + */ bool AINode::contains(float x, float y) { if (_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x && _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) { diff --git a/contrib/src/ai/aiNode.h b/contrib/src/ai/aiNode.h index d0af520b88..ab0c48c1c7 100644 --- a/contrib/src/ai/aiNode.h +++ b/contrib/src/ai/aiNode.h @@ -1,40 +1,33 @@ -// Filename: aiNode.h -// Created by: Deepak, John, Navin (18Nov2009) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiNode.h + * @author Deepak, John, Navin + * @date 2009-11-18 + */ #ifndef AINODE_H #define AINODE_H #include "aiGlobals.h" -//////////////////////////////////////////////////////////////////// -// Class : AINode -// Description : This class is used to assign the nodes on the mesh. -// It holds all the data necessary to compute A* -// algorithm. It also maintains a lot of vital -// information such as the neighbor nodes of each -// node and also its position on the mesh. -// Note: The Mesh Generator which is a standalone -// tool makes use of this class to generate the nodes -// on the mesh. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to assign the nodes on the mesh. It holds all the data + * necessary to compute A* algorithm. It also maintains a lot of vital + * information such as the neighbor nodes of each node and also its position + * on the mesh. Note: The Mesh Generator which is a standalone tool makes use + * of this class to generate the nodes on the mesh. + */ class EXPCL_PANDAAI AINode { public: - // This variable specifies the node status whether open, close - // or neutral. - // open = belongs to _open_list. - // close = belongs to _closed_list. - // neutral = unexamined node. + // This variable specifies the node status whether open, close or neutral. + // open = belongs to _open_list. close = belongs to _closed_list. neutral + // = unexamined node. enum Status { ST_open, ST_close, @@ -42,15 +35,13 @@ public: }; Status _status; - // This variable specifies whether the node is an obtacle or not. - // Used for dynamic obstacle addition to the environment. - // obstacle = false + // This variable specifies whether the node is an obtacle or not. Used for + // dynamic obstacle addition to the environment. obstacle = false // navigational = true bool _type; - // The score is used to compute the traversal expense to nodes - // when using A*. - // _score = _cost + heuristic + // The score is used to compute the traversal expense to nodes when using + // A*. _score = _cost + heuristic int _score; int _cost; int _heuristic; @@ -64,16 +55,14 @@ public: // Position of the node in 3D space. LVecBase3 _position; - // Dimensions of each face / cell on the mesh. - // Height is given in case of expansion to a 3d mesh. Currently - // not used. + // Dimensions of each face cell on the mesh. Height is given in case of + // expansion to a 3d mesh. Currently not used. float _width, _length ,_height; AINode *_neighbours[8]; // anti-clockwise from top left corner. - // The _next pointer is used for traversal during mesh - // generation from the model. - // Note: The data in this member is discarded when mesh data - // is written into navmesh.csv file. + // The _next pointer is used for traversal during mesh generation from the + // model. Note: The data in this member is discarded when mesh data is + // written into navmesh.csv file. AINode *_next; PUBLISHED: diff --git a/contrib/src/ai/aiPathFinder.cxx b/contrib/src/ai/aiPathFinder.cxx index f465028ec3..58f11bfc39 100644 --- a/contrib/src/ai/aiPathFinder.cxx +++ b/contrib/src/ai/aiPathFinder.cxx @@ -1,16 +1,15 @@ -// Filename: aiPathFinder.cxx -// Created by: Deepak, John, Navin (10Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiPathFinder.cxx + * @author Deepak, John, Navin + * @date 2009-11-10 + */ #include "aiPathFinder.h" @@ -21,17 +20,17 @@ PathFinder::PathFinder(NavMesh nav_mesh) { PathFinder::~PathFinder() { } -//////////////////////////////////////////////////////////////////// -// Function: find_path -// Description: This function initializes the pathfinding process by accepting the -// source and destination nodes. It then calls the generate_path(). -//////////////////////////////////////////////////////////////////// +/** + * This function initializes the pathfinding process by accepting the source + * and destination nodes. It then calls the generate_path(). + */ void PathFinder::find_path(Node *src_node, Node *dest_node) { _src_node = src_node; _dest_node = dest_node; // Add a dummy node as the first element of the open list with score = -1. - // Inorder to implement a binary heap the index of the elements should never be 0. + // Inorder to implement a binary heap the index of the elements should never + // be 0. Node *_dummy_node = new Node(-1, -1, LVecBase3(0.0, 0.0, 0.0), 0, 0, 0); _dummy_node->_status = _dummy_node->open; _dummy_node->_score = -1; @@ -44,14 +43,13 @@ void PathFinder::find_path(Node *src_node, Node *dest_node) { generate_path(); } -//////////////////////////////////////////////////////////////////// -// Function: generate_path -// Description: This function performs the pathfinding process using the A* algorithm. -// It updates the openlist and closelist. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the pathfinding process using the A* algorithm. It + * updates the openlist and closelist. + */ void PathFinder::generate_path() { - // All the A* algorithm is implemented here. - // The check is > 1 due to the existence of the dummy node. + // All the A* algorithm is implemented here. The check is > 1 due to the + // existence of the dummy node. while(_open_list.size() > 1) { // The first element of the open list will always be the optimal node. // This is because the open list is a binary heap with element having the @@ -80,11 +78,10 @@ void PathFinder::generate_path() { _closed_list.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: identify_neighbors -// Description: This function traverses through the 8 neigbors of the parent node and -// then adds the neighbors to the _open_list based on A* criteria. -//////////////////////////////////////////////////////////////////// +/** + * This function traverses through the 8 neigbors of the parent node and then + * adds the neighbors to the _open_list based on A* criteria. + */ void PathFinder::identify_neighbors(Node *parent_node) { // Remove the parent node from the open_list so that it is not considered // while adding new nodes to the open list heap. @@ -104,25 +101,21 @@ void PathFinder::identify_neighbors(Node *parent_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: calc_node_score -// Description: This function calculates the score of each node. -// Score = Cost + Heuristics. -//////////////////////////////////////////////////////////////////// +/** + * This function calculates the score of each node. Score = Cost + + * Heuristics. + */ void PathFinder::calc_node_score(Node *nd) { nd->_cost = calc_cost_frm_src(nd); nd->_heuristic = calc_heuristic(nd); nd->_score = nd->_cost + nd->_heuristic; } -//////////////////////////////////////////////////////////////////// -// Function: calc_cost_frm_src -// Description: This function calculates the cost of each node by -// finding out the number of node traversals required -// to reach the source node. Diagonal traversals have -// cost = 14. Horizontal and vertical traversals have -// cost = 10. -//////////////////////////////////////////////////////////////////// +/** + * This function calculates the cost of each node by finding out the number of + * node traversals required to reach the source node. Diagonal traversals + * have cost = 14. Horizontal and vertical traversals have cost = 10. + */ int PathFinder::calc_cost_frm_src(Node *nd) { int cost = 0; Node *start_node = nd; @@ -145,14 +138,11 @@ int PathFinder::calc_cost_frm_src(Node *nd) { return cost; } -//////////////////////////////////////////////////////////////////// -// Function: calc_heuristic -// Description: This function calculates the heuristic of the nodes -// using Manhattan method. All it does is predict the -// number of node traversals required to reach the -// target node. No diagonal traversals are allowed in -// this technique. -//////////////////////////////////////////////////////////////////// +/** + * This function calculates the heuristic of the nodes using Manhattan method. + * All it does is predict the number of node traversals required to reach the + * target node. No diagonal traversals are allowed in this technique. + */ int PathFinder::calc_heuristic(Node *nd) { int row_diff = abs(_dest_node->_grid_x - nd->_grid_x); int col_diff = abs(_dest_node->_grid_y - nd->_grid_y); @@ -161,10 +151,9 @@ int PathFinder::calc_heuristic(Node *nd) { return heuristic; } -//////////////////////////////////////////////////////////////////// -// Function: is_diagonal_node -// Description: This function checks if the traversal from a node is diagonal. -//////////////////////////////////////////////////////////////////// +/** + * This function checks if the traversal from a node is diagonal. + */ bool PathFinder::is_diagonal_node(Node *nd) { // Calculate the row and column differences between child and parent nodes. float row_diff = nd->_grid_x - nd->_prv_node->_grid_x; @@ -179,11 +168,10 @@ bool PathFinder::is_diagonal_node(Node *nd) { } } -//////////////////////////////////////////////////////////////////// -// Function: add_to_olist -// Description: This function adds a node to the open list heap. -// A binay heap is maintained to improve the search. -//////////////////////////////////////////////////////////////////// +/** + * This function adds a node to the open list heap. A binay heap is + * maintained to improve the search. + */ void PathFinder::add_to_olist(Node *nd) { // Variables required to search the binary heap. Node *child_node, *parent_node; @@ -195,9 +183,10 @@ void PathFinder::add_to_olist(Node *nd) { _open_list.push_back(nd); // Find the parent and child nodes and create temporary nodes out of them. - // In a binary heap the children of a parent node are always i*2 and i*2 + 1, - // where i is the index of the parent node in the heap. And hence, the parent - // of a node can be easily found out by dividing by 2 and rounding it. + // In a binary heap the children of a parent node are always i*2 and i*2 + + // 1, where i is the index of the parent node in the heap. And hence, the + // parent of a node can be easily found out by dividing by 2 and rounding + // it. child_idx = _open_list.size() - 1; parent_idx = child_idx / 2; child_node = _open_list[child_idx]; @@ -219,28 +208,29 @@ void PathFinder::add_to_olist(Node *nd) { parent_node = _open_list[parent_idx]; } - // At this point the Node with the smallest score will be at the top of the heap. + // At this point the Node with the smallest score will be at the top of the + // heap. } -//////////////////////////////////////////////////////////////////// -// Function: remove_from_olist -// Description: This function removes a node from the open list. -// During the removal the binary heap is maintained. -//////////////////////////////////////////////////////////////////// +/** + * This function removes a node from the open list. During the removal the + * binary heap is maintained. + */ void PathFinder::remove_from_olist() { // Variables for maintaining the binary heap. Node *child_node, *child_node_1, *child_node_2; int child_idx, child_idx_1, child_idx_2; - // Remove the Node at index 1 from the open list binary heap. - // Note: Node at index 0 of open list is a dummy node. + // Remove the Node at index 1 from the open list binary heap. Note: Node at + // index 0 of open list is a dummy node. _open_list.erase(_open_list.begin() + 1); if(_open_list.size() > 1) { // Store the last element in the open list to a temp_node. Node *temp_node = _open_list[_open_list.size() - 1]; - // Shift the elements of the open list to the right by 1 element circularly, excluding element at 0 index. + // Shift the elements of the open list to the right by 1 element + // circularly, excluding element at 0 index. for(int i = _open_list.size() - 1; i > 1; --i) { _open_list[i] = _open_list[i - 1]; } @@ -251,7 +241,8 @@ void PathFinder::remove_from_olist() { // Set the iterator for traversing the node from index 1 in the heap. unsigned int k = 1; - // This loop traverses down the open list till the node reaches the correct position in the binary heap. + // This loop traverses down the open list till the node reaches the + // correct position in the binary heap. while(true) { if((k * 2 + 1) < _open_list.size()) { // Two children exists for the parent node. @@ -311,13 +302,13 @@ void PathFinder::remove_from_olist() { } } - // At this point the Node was succesfully removed and the binary heap re-arranged. + // At this point the Node was succesfully removed and the binary heap re- + // arranged. } -//////////////////////////////////////////////////////////////////// -// Function: add_to_clist -// Description: This function adds a node to the closed list. -//////////////////////////////////////////////////////////////////// +/** + * This function adds a node to the closed list. + */ void PathFinder::add_to_clist(Node *nd) { // Set the status as closed. nd->_status = nd->close; @@ -325,10 +316,9 @@ void PathFinder::add_to_clist(Node *nd) { _closed_list.push_back(nd); } -//////////////////////////////////////////////////////////////////// -// Function: remove_from_clist -// Description: This function removes a node from the closed list. -//////////////////////////////////////////////////////////////////// +/** + * This function removes a node from the closed list. + */ void PathFinder::remove_from_clist(int r, int c) { for(unsigned int i = 0; i < _closed_list.size(); ++i) { if(_closed_list[i]->_grid_x == r && _closed_list[i]->_grid_y == c) { @@ -338,12 +328,11 @@ void PathFinder::remove_from_clist(int r, int c) { } } -//////////////////////////////////////////////////////////////////// -// Function: find_in_mesh -// Description: This function allows the user to pass a position and it returns the -// corresponding node on the navigation mesh. A very useful function as -// it allows for dynamic updation of the mesh based on position. -//////////////////////////////////////////////////////////////////// +/** + * This function allows the user to pass a position and it returns the + * corresponding node on the navigation mesh. A very useful function as it + * allows for dynamic updation of the mesh based on position. + */ Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size) { int size = grid_size; float x = pos[0]; diff --git a/contrib/src/ai/aiPathFinder.h b/contrib/src/ai/aiPathFinder.h index 5f46e05302..1595cb2777 100644 --- a/contrib/src/ai/aiPathFinder.h +++ b/contrib/src/ai/aiPathFinder.h @@ -1,16 +1,15 @@ -// Filename: aiPathFinder.h -// Created by: Deepak, John, Navin (10Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiPathFinder.h + * @author Deepak, John, Navin + * @date 2009-11-10 + */ #ifndef _PATHFINDER_H #define _PATHFINDER_H @@ -24,13 +23,11 @@ typedef vector NavMesh; Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size); -//////////////////////////////////////////////////////////////////// -// Class : PathFinder -// Description : This class implements pathfinding using A* algorithm. -// It also uses a Binary Heap search to search the -// open list. The heuristics are calculated using -// the manhattan method. -//////////////////////////////////////////////////////////////////// +/** + * This class implements pathfinding using A* algorithm. It also uses a + * Binary Heap search to search the open list. The heuristics are calculated + * using the manhattan method. + */ class EXPCL_PANDAAI PathFinder { public: Node *_src_node; diff --git a/contrib/src/ai/aiWorld.cxx b/contrib/src/ai/aiWorld.cxx index 129a737e69..6abac9f990 100644 --- a/contrib/src/ai/aiWorld.cxx +++ b/contrib/src/ai/aiWorld.cxx @@ -1,16 +1,15 @@ -// Filename: aiWorld.cxx -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiWorld.cxx + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #include "aiWorld.h" @@ -55,11 +54,10 @@ void AIWorld::print_list() { _ai_char_pool->print_list(); } -//////////////////////////////////////////////////////////////////// -// Function: update -// Description: The AIWorld update function calls the update function of all the -// AI characters which have been added to the AIWorld. -//////////////////////////////////////////////////////////////////// +/** + * The AIWorld update function calls the update function of all the AI + * characters which have been added to the AIWorld. + */ void AIWorld::update() { AICharPool::node *ai_pool; ai_pool = _ai_char_pool->_head; @@ -70,12 +68,11 @@ void AIWorld::update() { } } -//////////////////////////////////////////////////////////////////// -// Function: add_flock -// Description: This function adds all the AI characters in the Flock object to -// the AICharPool. This function allows adding the AI characetrs as -// part of a flock. -//////////////////////////////////////////////////////////////////// +/** + * This function adds all the AI characters in the Flock object to the + * AICharPool. This function allows adding the AI characetrs as part of a + * flock. + */ void AIWorld::add_flock(Flock *flock) { // Add all the ai_characters in the flock to the AIWorld. for(unsigned int i = 0; i < flock->_ai_char_list.size(); ++i) { @@ -85,10 +82,9 @@ void AIWorld::add_flock(Flock *flock) { _flock_pool.push_back(flock); } -//////////////////////////////////////////////////////////////////// -// Function: get_flock -// Description: This function returns a handle to the Flock whose id is passed. -//////////////////////////////////////////////////////////////////// +/** + * This function returns a handle to the Flock whose id is passed. + */ Flock AIWorld::get_flock(unsigned int flock_id) { for(unsigned int i=0; i < _flock_pool.size(); ++i) { if(_flock_pool[i]->get_id() == flock_id) { @@ -99,10 +95,9 @@ Flock AIWorld::get_flock(unsigned int flock_id) { return *null_flock; } -//////////////////////////////////////////////////////////////////// -// Function: remove_flock -// Description: This function removes the flock behavior completely. -//////////////////////////////////////////////////////////////////// +/** + * This function removes the flock behavior completely. + */ void AIWorld::remove_flock(unsigned int flock_id) { for(unsigned int i = 0; i < _flock_pool.size(); ++i) { if(_flock_pool[i]->get_id() == flock_id) { @@ -117,11 +112,10 @@ void AIWorld::remove_flock(unsigned int flock_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: flock_off -// Description: This function turns off the flock behavior temporarily. Similar to -// pausing the behavior. -//////////////////////////////////////////////////////////////////// +/** + * This function turns off the flock behavior temporarily. Similar to pausing + * the behavior. + */ void AIWorld::flock_off(unsigned int flock_id) { for(unsigned int i = 0; i < _flock_pool.size(); ++i) { if(_flock_pool[i]->get_id() == flock_id) { @@ -134,10 +128,9 @@ void AIWorld::flock_off(unsigned int flock_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: flock_on -// Description: This function turns on the flock behavior. -//////////////////////////////////////////////////////////////////// +/** + * This function turns on the flock behavior. + */ void AIWorld::flock_on(unsigned int flock_id) { for(unsigned int i = 0; i < _flock_pool.size(); ++i) { if(_flock_pool[i]->get_id() == flock_id) { @@ -216,11 +209,10 @@ void AICharPool::del(string name) { } } -//////////////////////////////////////////////////////////////////// -// Function: print_list -// Description: This function prints the ai characters in the AICharPool. Used for -// debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * This function prints the ai characters in the AICharPool. Used for + * debugging purposes. + */ void AICharPool::print_list() { node* q; q = _head; @@ -230,20 +222,18 @@ void AICharPool::print_list() { } } -//////////////////////////////////////////////////////////////////// -// Function: add_obstacle -// Description: This function adds the nodepath as an obstacle that is needed -// by the obstacle avoidance behavior. -//////////////////////////////////////////////////////////////////// +/** + * This function adds the nodepath as an obstacle that is needed by the + * obstacle avoidance behavior. + */ void AIWorld::add_obstacle(NodePath obstacle) { _obstacles.push_back(obstacle); } -//////////////////////////////////////////////////////////////////// -// Function: remove_obstacle -// Description: This function removes the nodepath from the obstacles list that is needed -// by the obstacle avoidance behavior. -//////////////////////////////////////////////////////////////////// +/** + * This function removes the nodepath from the obstacles list that is needed + * by the obstacle avoidance behavior. + */ void AIWorld::remove_obstacle(NodePath obstacle) { for(unsigned int i = 0; i <= _obstacles.size(); ++i) { if(_obstacles[i] == obstacle) { diff --git a/contrib/src/ai/aiWorld.h b/contrib/src/ai/aiWorld.h index 58b0fbae20..95115355ba 100644 --- a/contrib/src/ai/aiWorld.h +++ b/contrib/src/ai/aiWorld.h @@ -1,16 +1,15 @@ -// Filename: aiWorld.h -// Created by: Deepak, John, Navin (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aiWorld.h + * @author Deepak, John, Navin + * @date 2009-09-08 + */ #pragma warning (disable:4996) #pragma warning (disable:4005) @@ -27,12 +26,11 @@ class AICharacter; class Flock; -//////////////////////////////////////////////////////////////////// -// Class : AICharPool -// Description : This class implements a linked list of AI Characters allowing -// the user to add and delete characters from the linked list. -// This will be used in the AIWorld class. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a linked list of AI Characters allowing the user to + * add and delete characters from the linked list. This will be used in the + * AIWorld class. + */ class EXPCL_PANDAAI AICharPool { public: struct node { @@ -49,14 +47,13 @@ class EXPCL_PANDAAI AICharPool { }; -//////////////////////////////////////////////////////////////////// -// Class : AIWorld -// Description : A class that implements the virtual AI world which keeps track -// of the AI characters active at any given time. It contains a linked -// list of AI characters, obstactle data and unique name for each -// character. It also updates each characters state. The AI characters -// can also be added to the world as flocks. -//////////////////////////////////////////////////////////////////// +/** + * A class that implements the virtual AI world which keeps track of the AI + * characters active at any given time. It contains a linked list of AI + * characters, obstactle data and unique name for each character. It also + * updates each characters state. The AI characters can also be added to the + * world as flocks. + */ class EXPCL_PANDAAI AIWorld { private: AICharPool * _ai_char_pool; diff --git a/contrib/src/ai/arrival.cxx b/contrib/src/ai/arrival.cxx index 83c4468bbc..f9fba9438a 100644 --- a/contrib/src/ai/arrival.cxx +++ b/contrib/src/ai/arrival.cxx @@ -1,16 +1,15 @@ -// Filename: arrival.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arrival.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "arrival.h" @@ -24,14 +23,12 @@ Arrival::Arrival(AICharacter *ai_ch, double distance) { Arrival::~Arrival() { } -//////////////////////////////////////////////////////////////////// -// Function: do_arrival -// Description: This function performs the arrival and returns an arrival force which is used -// in the calculate_prioritized function. -// In case the steering force = 0, it resets to arrival_activate. -// The arrival behavior works only when seek or pursue is active. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the arrival and returns an arrival force which is + * used in the calculate_prioritized function. In case the steering force = + * 0, it resets to arrival_activate. The arrival behavior works only when + * seek or pursue is active. This function is not to be used by the user. + */ LVecBase3 Arrival::do_arrival() { LVecBase3 direction_to_target; double distance; @@ -84,12 +81,11 @@ LVecBase3 Arrival::do_arrival() { return(LVecBase3(0.0, 0.0, 0.0)); } -//////////////////////////////////////////////////////////////////// -// Function: arrival_activate -// Description: This function checks for whether the target is within the arrival distance. -// When this is true, it calls the do_arrival function and sets the arrival direction. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for whether the target is within the arrival distance. + * When this is true, it calls the do_arrival function and sets the arrival + * direction. This function is not to be used by the user. + */ void Arrival::arrival_activate() { LVecBase3 dirn; if(_arrival_type) { diff --git a/contrib/src/ai/arrival.h b/contrib/src/ai/arrival.h index 02864ac614..85a2979e37 100644 --- a/contrib/src/ai/arrival.h +++ b/contrib/src/ai/arrival.h @@ -1,16 +1,15 @@ -// Filename: arrival.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arrival.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _ARRIVAL_H #define _ARRIVAL_H @@ -31,9 +30,8 @@ public: LVecBase3 _arrival_direction; bool _arrival_done; - // This flag specifies if the arrival behavior is being used with seek or pursue behavior. - // True = used with pursue. - // False = used with seek. + // This flag specifies if the arrival behavior is being used with seek or + // pursue behavior. True = used with pursue. False = used with seek. bool _arrival_type; Arrival(AICharacter *ai_ch, double distance = 10.0); diff --git a/contrib/src/ai/config_ai.cxx b/contrib/src/ai/config_ai.cxx index 4831a1c6d9..5ade7ffa06 100644 --- a/contrib/src/ai/config_ai.cxx +++ b/contrib/src/ai/config_ai.cxx @@ -1,16 +1,15 @@ -// Filename: config_ai.cxx -// Created by: Pandai (13Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ai.cxx + * @author Pandai + * @date 2009-09-13 + */ #include "config_ai.h" #include "aiWorld.h" @@ -37,14 +36,12 @@ ConfigureFn(config_ai) { init_libai(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libai -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libai() { static bool initialized = false; diff --git a/contrib/src/ai/config_ai.h b/contrib/src/ai/config_ai.h index eb4928e353..649e4e855c 100644 --- a/contrib/src/ai/config_ai.h +++ b/contrib/src/ai/config_ai.h @@ -1,16 +1,15 @@ -// Filename: config_ai.h -// Created by: Pandai (13Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ai.h + * @author Pandai + * @date 2009-09-13 + */ #ifndef CONFIG_AI_H #define CONFIG_AI_H @@ -23,4 +22,3 @@ NotifyCategoryDecl(ai, EXPCL_PANDAAI, EXPTP_PANDAAI); extern EXPCL_PANDAAI void init_libai(); #endif - diff --git a/contrib/src/ai/evade.cxx b/contrib/src/ai/evade.cxx index 0c9fcae21d..0e63512a47 100644 --- a/contrib/src/ai/evade.cxx +++ b/contrib/src/ai/evade.cxx @@ -1,16 +1,15 @@ -// Filename: evade.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file evade.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "evade.h" @@ -30,14 +29,12 @@ Evade::Evade(AICharacter *ai_ch, NodePath target_object, double panic_distance, Evade::~Evade() { } -//////////////////////////////////////////////////////////////////// -// Function: do_evade -// Description: This function performs the evade and returns an evade force which is used -// in the calculate_prioritized function. -// In case the AICharacter is past the (panic + relax) distance, -// it resets to evade_activate. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the evade and returns an evade force which is used + * in the calculate_prioritized function. In case the AICharacter is past the + * (panic + relax) distance, it resets to evade_activate. This function is + * not to be used by the user. + */ LVecBase3 Evade::do_evade() { assert(_evade_target && "evade target not assigned"); @@ -62,12 +59,11 @@ LVecBase3 Evade::do_evade() { } } -//////////////////////////////////////////////////////////////////// -// Function: evade_activate -// Description: This function checks for whether the target is within the panic distance. -// When this is true, it calls the do_evade function and sets the evade direction. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for whether the target is within the panic distance. + * When this is true, it calls the do_evade function and sets the evade + * direction. This function is not to be used by the user. + */ void Evade::evade_activate() { _evade_direction = (_ai_char->_ai_char_np.get_pos(_ai_char->_window_render) - _evade_target.get_pos(_ai_char->_window_render)); double distance = _evade_direction.length(); diff --git a/contrib/src/ai/evade.h b/contrib/src/ai/evade.h index 50ad316c92..15065aac38 100644 --- a/contrib/src/ai/evade.h +++ b/contrib/src/ai/evade.h @@ -1,16 +1,15 @@ -// Filename: evade.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file evade.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _EVADE_H #define _EVADE_H diff --git a/contrib/src/ai/flee.cxx b/contrib/src/ai/flee.cxx index 192a936ce9..dac01b05f7 100644 --- a/contrib/src/ai/flee.cxx +++ b/contrib/src/ai/flee.cxx @@ -1,16 +1,15 @@ -// Filename: flee.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file flee.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "flee.h" @@ -45,14 +44,12 @@ Flee::Flee(AICharacter *ai_ch, LVecBase3 pos, double panic_distance, Flee::~Flee() { } -//////////////////////////////////////////////////////////////////// -// Function: do_flee -// Description: This function performs the flee and returns a flee force which is used -// in the calculate_prioritized function. -// In case the AICharacter is past the (panic + relax) distance, -// it resets to flee_activate. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the flee and returns a flee force which is used in + * the calculate_prioritized function. In case the AICharacter is past the + * (panic + relax) distance, it resets to flee_activate. This function is not + * to be used by the user. + */ LVecBase3 Flee::do_flee() { LVecBase3 dirn; double distance; @@ -76,12 +73,11 @@ LVecBase3 Flee::do_flee() { } } -//////////////////////////////////////////////////////////////////// -// Function: flee_activate -// Description: This function checks for whether the target is within the panic distance. -// When this is true, it calls the do_flee function and sets the flee direction. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for whether the target is within the panic distance. + * When this is true, it calls the do_flee function and sets the flee + * direction. This function is not to be used by the user. + */ void Flee::flee_activate() { LVecBase3 dirn; double distance; diff --git a/contrib/src/ai/flee.h b/contrib/src/ai/flee.h index 98a08b8127..e0a4bdada6 100644 --- a/contrib/src/ai/flee.h +++ b/contrib/src/ai/flee.h @@ -1,16 +1,15 @@ -// Filename: flee.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file flee.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _FLEE_H #define _FLEE_H diff --git a/contrib/src/ai/flock.cxx b/contrib/src/ai/flock.cxx index 70d52dcb26..fd7f9fd306 100644 --- a/contrib/src/ai/flock.cxx +++ b/contrib/src/ai/flock.cxx @@ -1,16 +1,15 @@ -// Filename: flock.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file flock.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "flock.h" @@ -27,10 +26,9 @@ Flock::Flock(unsigned int flock_id, double vcone_angle, double vcone_radius, uns Flock::~Flock() { } -//////////////////////////////////////////////////////////////////// -// Function: add_ai_char -// Description: This function adds AI characters to the flock. -//////////////////////////////////////////////////////////////////// +/** + * This function adds AI characters to the flock. + */ void Flock::add_ai_char(AICharacter *ai_char) { ai_char->_ai_char_flock_id = _flock_id; ai_char->_steering->_flock_group = this; diff --git a/contrib/src/ai/flock.h b/contrib/src/ai/flock.h index 6eb318b0bd..58595310d6 100644 --- a/contrib/src/ai/flock.h +++ b/contrib/src/ai/flock.h @@ -1,16 +1,15 @@ -// Filename: flock.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file flock.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _FLOCK_H #define _FLOCK_H @@ -20,22 +19,22 @@ class AICharacter; -//////////////////////////////////////////////////////////////////// -// Class : Flock -// Description : This class is used to define the flock attributes and the AI characters -// which are part of the flock. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to define the flock attributes and the AI characters + * which are part of the flock. + */ class EXPCL_PANDAAI Flock { private: unsigned int _flock_id; public: - // Variables which will hold the parameters of the ai character's visibilty cone. + // Variables which will hold the parameters of the ai character's visibilty + // cone. double _flock_vcone_angle; double _flock_vcone_radius; - // Variables to specify weights of separation, cohesion and alignment behaviors and thus - // create variable flock behavior. + // Variables to specify weights of separation, cohesion and alignment + // behaviors and thus create variable flock behavior. unsigned int _separation_wt; unsigned int _cohesion_wt; unsigned int _alignment_wt; diff --git a/contrib/src/ai/meshNode.cxx b/contrib/src/ai/meshNode.cxx index f846ac14b1..043dc5b60c 100644 --- a/contrib/src/ai/meshNode.cxx +++ b/contrib/src/ai/meshNode.cxx @@ -24,11 +24,10 @@ Node::Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) { Node::~Node() { } -//////////////////////////////////////////////////////////////////// -// Function: contains -// Description: This is a handy function which returns true if the passed position is -// within the node's dimensions. -//////////////////////////////////////////////////////////////////// +/** + * This is a handy function which returns true if the passed position is + * within the node's dimensions. + */ bool Node::contains(float x, float y) { if(_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x && _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) { diff --git a/contrib/src/ai/meshNode.h b/contrib/src/ai/meshNode.h index e74641c649..01d9ec3154 100644 --- a/contrib/src/ai/meshNode.h +++ b/contrib/src/ai/meshNode.h @@ -4,29 +4,24 @@ #include "aiGlobals.h" -//////////////////////////////////////////////////////////////////// -// Class : Node -// Description : This class is used to assign the nodes on the mesh. -// It holds all the data necessary to compute A* -// algorithm. It also maintains a lot of vital -// information such as the neighbor nodes of each node -// and also its position on the mesh. -// -// Note: The Mesh Generator which is a stand alone tool -// makes use of this class to generate the nodes on the -// mesh. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to assign the nodes on the mesh. It holds all the data + * necessary to compute A* algorithm. It also maintains a lot of vital + * information such as the neighbor nodes of each node and also its position + * on the mesh. + * + * Note: The Mesh Generator which is a stand alone tool makes use of this + * class to generate the nodes on the mesh. + */ class EXPCL_PANDAAI Node { public: - // This variable specifies whether the node is an obtacle or not. - // Used for dynamic obstacle addition to the environment. - // obstacle = false + // This variable specifies whether the node is an obtacle or not. Used + // for dynamic obstacle addition to the environment. obstacle = false // navigational = true bool _type; // This variable specifies the node status whether open, close or neutral. - // open = belongs to _open_list. - // close = belongs to _closed_list. + // open = belongs to _open_list. close = belongs to _closed_list. // neutral = unexamined node. enum Status { open, @@ -35,8 +30,8 @@ public: }; Status _status; - // The score is used to compute the traversal expense to nodes when using A*. - // _score = _cost + heuristic + // The score is used to compute the traversal expense to nodes when using + // A*. _score = _cost + heuristic int _score; int _cost; int _heuristic; @@ -50,13 +45,14 @@ public: // Position of the node in 3D space. LVecBase3 _position; - // Dimensions of each face / cell on the mesh. - // Height is given in case of expansion to a 3d mesh. Currently not used. + // Dimensions of each face cell on the mesh. Height is given in case of + // expansion to a 3d mesh. Currently not used. float _width, _length ,_height; Node *_neighbours[8]; // anti-clockwise from top left corner. - // The _next pointer is used for traversal during mesh generation from the model. - // Note: The data in this member is discarded when mesh data is written into navmesh.csv file. + // The _next pointer is used for traversal during mesh generation from the + // model. Note: The data in this member is discarded when mesh data is + // written into navmesh.csv file. Node *_next; Node(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h); diff --git a/contrib/src/ai/obstacleAvoidance.cxx b/contrib/src/ai/obstacleAvoidance.cxx index 0f86122a15..7160baa096 100644 --- a/contrib/src/ai/obstacleAvoidance.cxx +++ b/contrib/src/ai/obstacleAvoidance.cxx @@ -1,16 +1,15 @@ -// Filename: obstacleAvoidance.cxx -// Created by: Deepak, John, Navin (10Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file obstacleAvoidance.cxx + * @author Deepak, John, Navin + * @date 2009-11-10 + */ #include "obstacleAvoidance.h" @@ -24,11 +23,10 @@ ObstacleAvoidance:: ~ObstacleAvoidance() { } -//////////////////////////////////////////////////////////////////// -// Function: obstacle_detection -// Description: This function checks if an obstacle is near to the AICharacter and -// if an obstacle is detected returns true -//////////////////////////////////////////////////////////////////// +/** + * This function checks if an obstacle is near to the AICharacter and if an + * obstacle is detected returns true + */ bool ObstacleAvoidance:: obstacle_detection() { // Calculate the volume of the AICharacter with respect to render @@ -43,7 +41,8 @@ obstacle_detection() { PT(BoundingVolume) bounds = _ai_char->_world->_obstacles[i].get_bounds(); CPT(BoundingSphere) bsphere = bounds->as_bounding_sphere(); LVecBase3 near_obstacle = _ai_char->_world->_obstacles[i].get_pos() - _ai_char->get_node_path().get_pos(); - // Check if it's the nearest obstacle, If so initialize as the nearest obstacle + // Check if it's the nearest obstacle, If so initialize as the nearest + // obstacle if((near_obstacle.length() < distance) && (_ai_char->_world->_obstacles[i].get_pos() != _ai_char->get_node_path().get_pos())) { _nearest_obstacle = _ai_char->_world->_obstacles[i]; distance = near_obstacle.length(); @@ -59,18 +58,17 @@ obstacle_detection() { LVecBase3 project = (to_obstacle.dot(line_vector) * line_vector) / line_vector.length_squared(); LVecBase3 perp = project - to_obstacle; - // If the nearest obstacle will collide with our AICharacter then send obstacle detection as true + // If the nearest obstacle will collide with our AICharacter then send + // obstacle detection as true if (_nearest_obstacle && (perp.length() < expanded_radius - np_sphere->get_radius()) && (project.length() < feeler.length())) { return true; } return false; } -//////////////////////////////////////////////////////////////////// -// Function: obstacle_avoidance_activate -// Description: This function activates obstacle_avoidance if a obstacle -// is detected -//////////////////////////////////////////////////////////////////// +/** + * This function activates obstacle_avoidance if a obstacle is detected + */ void ObstacleAvoidance:: obstacle_avoidance_activate() { if (obstacle_detection()) { @@ -79,13 +77,11 @@ obstacle_avoidance_activate() { } } -//////////////////////////////////////////////////////////////////// -// Function: do_obstacle_avoidance -// Description: This function returns the force necessary by the AICharacter to -// avoid the nearest obstacle detected by obstacle_detection -// function -// NOTE : This assumes the obstacles are spherical -//////////////////////////////////////////////////////////////////// +/** + * This function returns the force necessary by the AICharacter to avoid the + * nearest obstacle detected by obstacle_detection function NOTE : This + * assumes the obstacles are spherical + */ LVecBase3 ObstacleAvoidance:: do_obstacle_avoidance() { LVecBase3 offset = _ai_char->get_node_path().get_pos() - _nearest_obstacle.get_pos(); diff --git a/contrib/src/ai/obstacleAvoidance.h b/contrib/src/ai/obstacleAvoidance.h index aeba5fe21b..e45f35ea1b 100644 --- a/contrib/src/ai/obstacleAvoidance.h +++ b/contrib/src/ai/obstacleAvoidance.h @@ -1,16 +1,15 @@ -// Filename: obstacleAvoidance.h -// Created by: Deepak, John, Navin (10Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file obstacleAvoidance.h + * @author Deepak, John, Navin + * @date 2009-11-10 + */ #ifndef OBSTACLE_AVOIDANCE_H #define OBSTACLE_AVOIDANCE_H diff --git a/contrib/src/ai/pathFind.cxx b/contrib/src/ai/pathFind.cxx index 4ae0eebf0d..39093da197 100644 --- a/contrib/src/ai/pathFind.cxx +++ b/contrib/src/ai/pathFind.cxx @@ -1,3 +1,15 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathFind.cxx + * @author Deepak, John, Navin + * @date 2009-10-12 + */ #include "pathFind.h" @@ -18,10 +30,9 @@ PathFind::PathFind(AICharacter *ai_ch) { PathFind::~PathFind() { } -//////////////////////////////////////////////////////////////////// -// Function: create_nav_mesh -// Description: This function recreates the navigation mesh from the .csv file -//////////////////////////////////////////////////////////////////// +/** + * This function recreates the navigation mesh from the .csv file + */ void PathFind::create_nav_mesh(const char* navmesh_filename) { // Stage variables. int grid_x, grid_y; @@ -59,8 +70,9 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { getline(nav_mesh_file, line); stringstream linestream (line); - // Stores all the data members in the line to the array. - // Data structure: NULL,NodeType,GridX,GridY,Length,Width,Height,PosX,PosY,PosZ + // Stores all the data members in the line to the array. Data + // structure: + // NULL,NodeType,GridX,GridY,Length,Width,Height,PosX,PosY,PosZ for(int i = 0; i < 10; ++i) { getline(linestream, fields[i], ','); } @@ -83,7 +95,8 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { // End of file reached at this point. nav_mesh_file.close(); - // Assign the neighbor nodes for each of the main nodes that just got populated into the stage mesh. + // Assign the neighbor nodes for each of the main nodes that just got + // populated into the stage mesh. assign_neighbor_nodes(navmesh_filename); } } @@ -93,11 +106,10 @@ void PathFind::create_nav_mesh(const char* navmesh_filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: assign_neighbor_nodes -// Description: This function assigns the neighbor nodes for each -// main node present in _nav_mesh. -//////////////////////////////////////////////////////////////////// +/** + * This function assigns the neighbor nodes for each main node present in + * _nav_mesh. + */ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ ifstream nav_mesh_file (navmesh_filename); @@ -131,8 +143,9 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ gd_yn = atoi(fields_n[3].c_str()); if(fields_n[0] == "0" && fields_n[1] == "1") { - // Usable neighbor for main node. - // TODO: The indices of the vector are inverted when compared to the values of the nodes on actual grid. Fix this! + // Usable neighbor for main node. TODO: The indices of the vector + // are inverted when compared to the values of the nodes on actual + // grid. Fix this! _nav_mesh[gd_y][gd_x]->_neighbours[i] = _nav_mesh[gd_yn][gd_xn]; } else if(fields_n[0] == "1" && fields_n[1] == "1") { @@ -155,11 +168,10 @@ void PathFind::assign_neighbor_nodes(const char* navmesh_filename){ } } -//////////////////////////////////////////////////////////////////// -// Function: set_path_find -// Description: This function starts the path finding process after reading the given -// navigation mesh. -//////////////////////////////////////////////////////////////////// +/** + * This function starts the path finding process after reading the given + * navigation mesh. + */ void PathFind::set_path_find(const char* navmesh_filename) { create_nav_mesh(navmesh_filename); @@ -177,12 +189,11 @@ void PathFind::set_path_find(const char* navmesh_filename) { _path_finder_obj = new PathFinder(_nav_mesh); } -//////////////////////////////////////////////////////////////////// -// Function: path_find (for pathfinding towards a static position) -// Description: This function checks for the source and target in the navigation mesh -// for its availability and then finds the best path via the A* algorithm -// Then it calls the path follower to make the object follow the path. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for the source and target in the navigation mesh for + * its availability and then finds the best path via the A* algorithm Then it + * calls the path follower to make the object follow the path. + */ void PathFind::path_find(LVecBase3 pos, string type) { if(type == "addPath") { if(_ai_char->_steering->_path_follow_obj) { @@ -216,12 +227,11 @@ void PathFind::path_find(LVecBase3 pos, string type) { } } -//////////////////////////////////////////////////////////////////// -// Function: path_find (for pathfinding towards a moving target (a NodePath)) -// Description: This function checks for the source and target in the navigation mesh -// for its availability and then finds the best path via the A* algorithm -// Then it calls the path follower to make the object follow the path. -//////////////////////////////////////////////////////////////////// +/** + * This function checks for the source and target in the navigation mesh for + * its availability and then finds the best path via the A* algorithm Then it + * calls the path follower to make the object follow the path. + */ void PathFind::path_find(NodePath target, string type) { if(type == "addPath") { if(_ai_char->_steering->_path_follow_obj) { @@ -260,10 +270,9 @@ void PathFind::path_find(NodePath target, string type) { } } -//////////////////////////////////////////////////////////////////// -// Function: clear_path -// Description: Helper function to restore the path and mesh to its initial state -//////////////////////////////////////////////////////////////////// +/** + * Helper function to restore the path and mesh to its initial state + */ void PathFind::clear_path() { // Initialize to zero for(int i = 0; i < _grid_size; ++i) { @@ -284,12 +293,11 @@ void PathFind::clear_path() { } } -//////////////////////////////////////////////////////////////////// -// Function: trace_path -// Description: This function is the function which sends the path information one by -// one to the path follower so that it can store the path needed to be -// traversed by the pathfinding object -//////////////////////////////////////////////////////////////////// +/** + * This function is the function which sends the path information one by one + * to the path follower so that it can store the path needed to be traversed + * by the pathfinding object + */ void PathFind::trace_path(Node* src) { if(_ai_char->_pf_guide) { _parent->remove_all_children(); @@ -313,13 +321,12 @@ void PathFind::trace_path(Node* src) { } } -//////////////////////////////////////////////////////////////////// -// Function: add_obstacle_to_mesh -// Description: This function allows the user to dynamically add obstacles to the -// game environment. The function will update the nodes within the -// bounding volume of the obstacle as non-traversable. Hence will not be -// considered by the pathfinding algorithm. -//////////////////////////////////////////////////////////////////// +/** + * This function allows the user to dynamically add obstacles to the game + * environment. The function will update the nodes within the bounding volume + * of the obstacle as non-traversable. Hence will not be considered by the + * pathfinding algorithm. + */ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { PT(BoundingVolume) np_bounds = obstacle.get_bounds(); CPT(BoundingSphere) np_sphere = np_bounds->as_bounding_sphere(); @@ -347,11 +354,10 @@ void PathFind::add_obstacle_to_mesh(NodePath obstacle) { } } -//////////////////////////////////////////////////////////////////// -// Function: do_dynamic_avoid() -// Description: This function does the updation of the collisions to the mesh based -// on the new positions of the obstacles. -//////////////////////////////////////////////////////////////////// +/** + * This function does the updation of the collisions to the mesh based on the + * new positions of the obstacles. + */ void PathFind::do_dynamic_avoid() { clear_previous_obstacles(); _previous_obstacles.clear(); @@ -360,22 +366,20 @@ void PathFind::do_dynamic_avoid() { } } -//////////////////////////////////////////////////////////////////// -// Function: clear_previous_obstacles() -// Description: Helper function to reset the collisions if the obstacle is not on the -// node anymore -//////////////////////////////////////////////////////////////////// +/** + * Helper function to reset the collisions if the obstacle is not on the node + * anymore + */ void PathFind::clear_previous_obstacles(){ for(unsigned int i = 0; i < _previous_obstacles.size(); i = i + 2) { _nav_mesh[_previous_obstacles[i]][_previous_obstacles[i + 1]]->_type = true; } } -//////////////////////////////////////////////////////////////////// -// Function: dynamic_avoid -// Description: This function starts the pathfinding obstacle navigation for the -// passed in obstacle. -//////////////////////////////////////////////////////////////////// +/** + * This function starts the pathfinding obstacle navigation for the passed in + * obstacle. + */ void PathFind::dynamic_avoid(NodePath obstacle) { _dynamic_avoid = true; _dynamic_obstacle.insert(_dynamic_obstacle.end(), obstacle); diff --git a/contrib/src/ai/pathFind.h b/contrib/src/ai/pathFind.h index 4306e9378c..eb82f9ff99 100644 --- a/contrib/src/ai/pathFind.h +++ b/contrib/src/ai/pathFind.h @@ -1,16 +1,15 @@ -// Filename: pathFind.h -// Created by: Deepak, John, Navin (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathFind.h + * @author Deepak, John, Navin + * @date 2009-10-12 + */ #ifndef _PATHFIND_H #define _PATHFIND_H @@ -22,15 +21,12 @@ class AICharacter; -//////////////////////////////////////////////////////////////////// -// Class : PathFind -// Description : This class contains all the members and functions -// that are required to form an interface between -// the AIBehaviors class and the PathFinder class. -// An object (pointer) of this class is provided in -// the AIBehaviors class. It is only via this object -// that the user can activate pathfinding. -//////////////////////////////////////////////////////////////////// +/** + * This class contains all the members and functions that are required to form + * an interface between the AIBehaviors class and the PathFinder class. An + * object (pointer) of this class is provided in the AIBehaviors class. It is + * only via this object that the user can activate pathfinding. + */ class EXPCL_PANDAAI PathFind { public: AICharacter *_ai_char; @@ -67,4 +63,3 @@ public: }; #endif - diff --git a/contrib/src/ai/pathFollow.cxx b/contrib/src/ai/pathFollow.cxx index 1927d73750..576bb04f75 100644 --- a/contrib/src/ai/pathFollow.cxx +++ b/contrib/src/ai/pathFollow.cxx @@ -12,19 +12,17 @@ PathFollow::PathFollow(AICharacter *ai_ch, float follow_wt) { PathFollow::~PathFollow() { } -//////////////////////////////////////////////////////////////////// -// Function: add_to_path -// Description: This function adds the positions generated from a pathfind or a simple -// path follow behavior to the _path list. -//////////////////////////////////////////////////////////////////// +/** + * This function adds the positions generated from a pathfind or a simple path + * follow behavior to the _path list. + */ void PathFollow::add_to_path(LVecBase3 pos) { _path.push_back(pos); } -//////////////////////////////////////////////////////////////////// -// Function: start -// Description: This function initiates the path follow behavior. -//////////////////////////////////////////////////////////////////// +/** + * This function initiates the path follow behavior. + */ void PathFollow::start(string type) { _type = type; _start = true; @@ -37,21 +35,20 @@ void PathFollow::start(string type) { } } -//////////////////////////////////////////////////////////////////// -// Function: do_follow -// Description: This function allows continuous path finding by ai chars. There are 2 -// ways in which this is implemented. -// 1. The character re-calculates the optimal path everytime the target -// changes its position. Less computationally expensive. -// 2. The character continuosly re-calculates its optimal path to the -// target. This is used in a scenario where the ai chars have to avoid -// other ai chars. More computationally expensive. -//////////////////////////////////////////////////////////////////// +/** + * This function allows continuous path finding by ai chars. There are 2 ways + * in which this is implemented. 1. The character re-calculates the optimal + * path everytime the target changes its position. Less computationally + * expensive. 2. The character continuosly re-calculates its optimal path to + * the target. This is used in a scenario where the ai chars have to avoid + * other ai chars. More computationally expensive. + */ void PathFollow::do_follow() { if((_myClock->get_real_time() - _time) > 0.5) { if(_type=="pathfind") { - // This 'if' statement when 'true' causes the path to be re-calculated irrespective of target position. - // This is done when _dynamice_avoid is active. More computationally expensive. + // This 'if' statement when 'true' causes the path to be re-calculated + // irrespective of target position. This is done when _dynamice_avoid + // is active. More computationally expensive. if(_ai_char->_steering->_path_find_obj->_dynamic_avoid) { _ai_char->_steering->_path_find_obj->do_dynamic_avoid(); if(check_if_possible()) { @@ -68,8 +65,9 @@ void PathFollow::do_follow() { } } } - // This 'if' statement causes the path to be re-calculated only when there is a change in target position. - // Less computationally expensive. + // This 'if' statement causes the path to be re-calculated only when + // there is a change in target position. Less computationally + // expensive. else if(_ai_char->_steering->_path_find_obj->_path_find_target.get_pos(_ai_char->_window_render) != _ai_char->_steering->_path_find_obj->_prev_position) { if(check_if_possible()) { @@ -100,11 +98,10 @@ void PathFollow::do_follow() { } } -//////////////////////////////////////////////////////////////////// -// Function: check_if_possible -// Description: This function checks if the current positions of the ai char and the -// target char can be used to generate an optimal path. -//////////////////////////////////////////////////////////////////// +/** + * This function checks if the current positions of the ai char and the target + * char can be used to generate an optimal path. + */ bool PathFollow::check_if_possible() { Node* src = find_in_mesh(_ai_char->_steering->_path_find_obj->_nav_mesh, _ai_char->_ai_char_np.get_pos(_ai_char->_window_render), _ai_char->_steering->_path_find_obj->_grid_size); LVecBase3 _prev_position = _ai_char->_steering->_path_find_obj->_path_find_target.get_pos(_ai_char->_window_render); diff --git a/contrib/src/ai/pursue.cxx b/contrib/src/ai/pursue.cxx index 2e7d24d830..f963e405a7 100644 --- a/contrib/src/ai/pursue.cxx +++ b/contrib/src/ai/pursue.cxx @@ -1,16 +1,15 @@ -// Filename: pursue.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pursue.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "pursue.h" @@ -28,13 +27,12 @@ Pursue:: ~Pursue() { } -//////////////////////////////////////////////////////////////////// -// Function: do_pursue -// Description: This function performs the pursue and returns a pursue force which is used -// in the calculate_prioritized function. -// In case the target has been reached it resets the forces to 0 so that the character stops. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the pursue and returns a pursue force which is used + * in the calculate_prioritized function. In case the target has been reached + * it resets the forces to 0 so that the character stops. This function is + * not to be used by the user. + */ LVecBase3 Pursue:: do_pursue() { assert(_pursue_target && "pursue target not assigned"); diff --git a/contrib/src/ai/pursue.h b/contrib/src/ai/pursue.h index 6e63682fd6..feae5bf607 100644 --- a/contrib/src/ai/pursue.h +++ b/contrib/src/ai/pursue.h @@ -1,16 +1,15 @@ -// Filename: pursue.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pursue.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _PURSUE_H #define _PURSUE_H diff --git a/contrib/src/ai/seek.cxx b/contrib/src/ai/seek.cxx index 4a2e2f0abc..78670962c5 100644 --- a/contrib/src/ai/seek.cxx +++ b/contrib/src/ai/seek.cxx @@ -1,16 +1,15 @@ -// Filename: seek.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file seek.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "seek.h" @@ -41,12 +40,11 @@ Seek::Seek(AICharacter *ai_ch, LVecBase3 pos, float seek_wt) { Seek::~Seek() { } -//////////////////////////////////////////////////////////////////// -// Function: do_seek -// Description: This function performs the seek and returns a seek force which is used -// in the calculate_prioritized function. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the seek and returns a seek force which is used in + * the calculate_prioritized function. This function is not to be used by the + * user. + */ LVecBase3 Seek::do_seek() { double target_distance = (_seek_position - _ai_char->_ai_char_np.get_pos(_ai_char->_window_render)).length(); diff --git a/contrib/src/ai/seek.h b/contrib/src/ai/seek.h index 8cd9fba6db..1d1b528921 100644 --- a/contrib/src/ai/seek.h +++ b/contrib/src/ai/seek.h @@ -1,16 +1,15 @@ -// Filename: seek.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file seek.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _SEEK_H #define _SEEK_H diff --git a/contrib/src/ai/wander.cxx b/contrib/src/ai/wander.cxx index c3ddc63c0c..b0ce6aee76 100644 --- a/contrib/src/ai/wander.cxx +++ b/contrib/src/ai/wander.cxx @@ -1,33 +1,29 @@ -// Filename: wander.cxx -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wander.cxx + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #include "wander.h" -//////////////////////////////////////////////////////////////////// -// Function: rand_float -// Description: This function creates a random float point number -//////////////////////////////////////////////////////////////////// +/** + * This function creates a random float point number + */ double rand_float() { const static double rand_max = 0x7fff; return ((rand()) / (rand_max + 1.0)); } -//////////////////////////////////////////////////////////////////// -// Function: random_clamped -// Description: This function returns a random floating point number in the range -// -1 to 1. -//////////////////////////////////////////////////////////////////// +/** + * This function returns a random floating point number in the range -1 to 1. + */ double random_clamped() { return (rand_float() - rand_float()); } @@ -42,12 +38,9 @@ Wander::Wander(AICharacter *ai_ch, double wander_radius,int flag, double aoe, fl // Area around which the character should wander _area_of_effect = aoe; _init_pos = _ai_char->get_node_path().get_pos(_ai_char->get_char_render()); - // _flag is used by Wander to wander in a given axis - // Value 0 - XY axes wander - // Value 1 - YZ axes wander - // Value 2 - XZ axes wander - // Value 3 - XYZ axes wander - // default is XY axes + // _flag is used by Wander to wander in a given axis Value 0 - XY axes + // wander Value 1 - YZ axes wander Value 2 - XZ axes wander Value 3 - XYZ + // axes wander default is XY axes switch(_flag) { case 0: { _wander_target = LVecBase3(_wander_radius * cos(theta), _wander_radius * sin(theta),0); @@ -75,15 +68,15 @@ Wander::Wander(AICharacter *ai_ch, double wander_radius,int flag, double aoe, fl Wander::~Wander() { } -//////////////////////////////////////////////////////////////////// -// Function: do_wander -// Description: This function performs the wander and returns the wander force which is used -// in the calculate_prioritized function. -// This function is not to be used by the user. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the wander and returns the wander force which is + * used in the calculate_prioritized function. This function is not to be + * used by the user. + */ LVecBase3 Wander::do_wander() { LVecBase3 present_pos = _ai_char->get_node_path().get_pos(_ai_char->get_char_render()); - // Create the random slices to enable random movement of wander for x,y,z respectively + // Create the random slices to enable random movement of wander for x,y,z + // respectively double time_slice_1 = random_clamped() * 1.5; double time_slice_2 = random_clamped() * 1.5; double time_slice_3 = random_clamped() * 1.5; diff --git a/contrib/src/ai/wander.h b/contrib/src/ai/wander.h index 572e2f98d5..240c56078a 100644 --- a/contrib/src/ai/wander.h +++ b/contrib/src/ai/wander.h @@ -1,16 +1,15 @@ -// Filename: wander.h -// Created by: Deepak, John, Navin (24Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wander.h + * @author Deepak, John, Navin + * @date 2009-10-24 + */ #ifndef _WANDER_H #define _WANDER_H diff --git a/contrib/src/contribbase/contribbase.cxx b/contrib/src/contribbase/contribbase.cxx index 2c1d4ae339..86496bc3a8 100644 --- a/contrib/src/contribbase/contribbase.cxx +++ b/contrib/src/contribbase/contribbase.cxx @@ -1,15 +1,14 @@ -// Filename: contribbase.cxx -// Created by: rdb (26Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file contribbase.cxx + * @author rdb + * @date 2010-04-26 + */ #include "contribbase.h" diff --git a/contrib/src/contribbase/contribbase.h b/contrib/src/contribbase/contribbase.h index 037846da2a..a5891a5ee5 100644 --- a/contrib/src/contribbase/contribbase.h +++ b/contrib/src/contribbase/contribbase.h @@ -1,8 +1,4 @@ -/* Filename: contribbase.h - * Created by: rdb (30Dec09) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contribbase.h + * @author rdb + * @date 2009-12-30 + */ /* This file is included at the beginning of every header file and/or C or C++ file. It must be compilable for C as well as C++ files, @@ -23,4 +22,3 @@ #include "contribsymbols.h" #endif - diff --git a/contrib/src/contribbase/contribsymbols.h b/contrib/src/contribbase/contribsymbols.h index 5d57d20ea6..3384d0a3e5 100644 --- a/contrib/src/contribbase/contribsymbols.h +++ b/contrib/src/contribbase/contribsymbols.h @@ -1,8 +1,4 @@ -/* Filename: contribsymbols.h - * Created by: rdb (30Dec09) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contribsymbols.h + * @author rdb + * @date 2009-12-30 + */ #ifndef CONTRIBSYMBOLS_H #define CONTRIBSYMBOLS_H diff --git a/direct/metalibs/direct/direct.cxx b/direct/metalibs/direct/direct.cxx index eecbfba8c7..41594bf60d 100644 --- a/direct/metalibs/direct/direct.cxx +++ b/direct/metalibs/direct/direct.cxx @@ -1,9 +1,10 @@ -// Filename: direct.cxx -// Created by: drose (18May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file direct.cxx + * @author drose + * @date 2000-05-18 + */ -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libdirect.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libdirect. +// This is a dummy file whose sole purpose is to give the compiler something +// to compile when making libdirect.so in NO_DEFER mode, which generates an +// empty library that itself links with all the other shared libraries that +// make up libdirect. diff --git a/direct/src/dcparse/dcparse.cxx b/direct/src/dcparse/dcparse.cxx index 28a828b459..3d02ef669c 100644 --- a/direct/src/dcparse/dcparse.cxx +++ b/direct/src/dcparse/dcparse.cxx @@ -1,16 +1,15 @@ -// Filename: dcparse.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcparse.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcbase.h" #include "dcFile.h" @@ -22,7 +21,7 @@ void usage() { - cerr << + cerr << "\n" "Usage:\n\n" "dcparse [options] [file1 file2 ...]\n" @@ -32,7 +31,7 @@ usage() { void help() { usage(); - cerr << + cerr << "This program reads one or more DC files, which are used to describe the\n" "communication channels in the distributed class system. By default,\n" "the file(s) are read and concatenated, and a single hash code is printed\n" @@ -58,7 +57,7 @@ help() { } void -write_class_hierarchy(int indent_level, const DCFile &file, +write_class_hierarchy(int indent_level, const DCFile &file, const DCClass *this_dclass) { indent(cout, indent_level) << this_dclass->get_name() << "\n"; @@ -117,7 +116,7 @@ write_complete_field_list(const DCFile &file) { int main(int argc, char *argv[]) { - // extern char *optarg; + // extern char *optarg; extern int optind; const char *optstr = "bvcfh"; diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index 5374f8ce6d..7485a34a5d 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -1,27 +1,24 @@ -// Filename: dcArrayParameter.cxx -// Created by: drose (17Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcArrayParameter.cxx + * @author drose + * @date 2004-06-17 + */ #include "dcArrayParameter.h" #include "dcSimpleParameter.h" #include "dcClassParameter.h" #include "hashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCArrayParameter:: DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) : _element_type(element_type), @@ -41,10 +38,10 @@ DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) : _has_fixed_byte_size = true; _fixed_byte_size = _array_size * _element_type->get_fixed_byte_size(); _has_fixed_structure = true; - + } else { - // We only need to store the length bytes if the array has a - // variable size. + // We only need to store the length bytes if the array has a variable + // size. _num_length_bytes = 2; } @@ -63,20 +60,18 @@ DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size) : DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); if (simple_type != (DCSimpleParameter *)NULL) { if (simple_type->get_type() == ST_char) { - // We make a special case for char[] arrays: these we format as - // a string. (It will still accept an array of ints packed into - // it.) We don't make this special case for uint8[] or int8[] - // arrays, although we will accept a string packed in for them. + // We make a special case for char[] arrays: these we format as a + // string. (It will still accept an array of ints packed into it.) We + // don't make this special case for uint8[] or int8[] arrays, although + // we will accept a string packed in for them. _pack_type = PT_string; } } } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCArrayParameter:: DCArrayParameter(const DCArrayParameter ©) : DCParameter(copy), @@ -86,91 +81,71 @@ DCArrayParameter(const DCArrayParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCArrayParameter:: ~DCArrayParameter() { delete _element_type; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::as_array_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCArrayParameter *DCArrayParameter:: as_array_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::as_array_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCArrayParameter *DCArrayParameter:: as_array_parameter() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::make_copy -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCArrayParameter:: make_copy() const { return new DCArrayParameter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::is_valid -// Access: Published, Virtual -// Description: Returns false if the type is an invalid type -// (e.g. declared from an undefined typedef), true if -// it is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the type is an invalid type (e.g. declared from an + * undefined typedef), true if it is valid. + */ bool DCArrayParameter:: is_valid() const { return _element_type->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::get_element_type -// Access: Published -// Description: Returns the type of the individual elements of this -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the individual elements of this array. + */ DCParameter *DCArrayParameter:: get_element_type() const { return _element_type; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::get_array_size -// Access: Published -// Description: Returns the fixed number of elements in this array, -// or -1 if the array may contain a variable number of -// elements. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fixed number of elements in this array, or -1 if the array may + * contain a variable number of elements. + */ int DCArrayParameter:: get_array_size() const { return _array_size; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::append_array_specification -// Access: Public, Virtual -// Description: Returns the type represented by this_type[size]. -// -// In the case of a DCArrayParameter, this means it -// modifies the current type to append the array -// specification on the innermost type, and returns this -// same pointer again. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type represented by this_type[size]. + * + * In the case of a DCArrayParameter, this means it modifies the current type + * to append the array specification on the innermost type, and returns this + * same pointer again. + */ DCParameter *DCArrayParameter:: append_array_specification(const DCUnsignedIntRange &size) { if (get_typedef() != (DCTypedef *)NULL) { @@ -183,16 +158,12 @@ append_array_specification(const DCUnsignedIntRange &size) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::calc_num_nested_fields -// Access: Public, Virtual -// Description: This flavor of get_num_nested_fields is used during -// unpacking. It returns the number of nested fields to -// expect, given a certain length in bytes (as read from -// the get_num_length_bytes() stored in the stream on the -// pack). This will only be called if -// get_num_length_bytes() returns nonzero. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_num_nested_fields is used during unpacking. It returns + * the number of nested fields to expect, given a certain length in bytes (as + * read from the get_num_length_bytes() stored in the stream on the pack). + * This will only be called if get_num_length_bytes() returns nonzero. + */ int DCArrayParameter:: calc_num_nested_fields(size_t length_bytes) const { if (_element_type->has_fixed_byte_size()) { @@ -201,43 +172,34 @@ calc_num_nested_fields(size_t length_bytes) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCArrayParameter:: get_nested_field(int) const { return _element_type; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::validate_num_nested_fields -// Access: Public, Virtual -// Description: After a number of fields have been packed via push() -// .. pack_*() .. pop(), this is called to confirm that -// the number of nested fields that were added is valid -// for this type. This is primarily useful for array -// types with dynamic ranges that can't validate the -// number of fields any other way. -//////////////////////////////////////////////////////////////////// +/** + * After a number of fields have been packed via push() .. pack_*() .. pop(), + * this is called to confirm that the number of nested fields that were added + * is valid for this type. This is primarily useful for array types with + * dynamic ranges that can't validate the number of fields any other way. + */ bool DCArrayParameter:: validate_num_nested_fields(int num_nested_fields) const { bool range_error = false; _array_size_range.validate(num_nested_fields, range_error); - + return !range_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::output_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCArrayParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { @@ -246,22 +208,19 @@ output_instance(ostream &out, bool brief, const string &prename, } else { ostringstream strm; - + strm << "["; _array_size_range.output(strm); strm << "]"; - - _element_type->output_instance(out, brief, prename, name, + + _element_type->output_instance(out, brief, prename, name, postname + strm.str()); } } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this type into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this type into the hash. + */ void DCArrayParameter:: generate_hash(HashGenerator &hashgen) const { DCParameter::generate_hash(hashgen); @@ -269,17 +228,13 @@ generate_hash(HashGenerator &hashgen) const { _array_size_range.generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::pack_string -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCArrayParameter:: pack_string(DCPackData &pack_data, const string &value, bool &pack_error, bool &range_error) const { - // We can only pack a string if the array element type is char or - // int8. + // We can only pack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); if (simple_type == (DCSimpleParameter *)NULL) { pack_error = true; @@ -305,27 +260,23 @@ pack_string(DCPackData &pack_data, const string &value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::pack_default_value -// Access: Public, Virtual -// Description: Packs the arrayParameter's specified default value (or a -// sensible default if no value is specified) into the -// stream. Returns true if the default value is packed, -// false if the arrayParameter doesn't know how to pack its -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the arrayParameter's specified default value (or a sensible default + * if no value is specified) into the stream. Returns true if the default + * value is packed, false if the arrayParameter doesn't know how to pack its + * default value. + */ bool DCArrayParameter:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { - // We only want to call up if the DCField can pack the value - // immediately--we don't trust the DCField to generate the default - // value (since it doesn't know how large the minimum length array - // is). + // We only want to call up if the DCField can pack the value immediately--we + // don't trust the DCField to generate the default value (since it doesn't + // know how large the minimum length array is). if (_has_default_value && !_default_value_stale) { return DCField::pack_default_value(pack_data, pack_error); } - // If a default value is not specified for a variable-length array, - // the default is the minimum array. + // If a default value is not specified for a variable-length array, the + // default is the minimum array. unsigned int minimum_length = 0; if (!_array_size_range.is_empty()) { minimum_length = _array_size_range.get_min(0); @@ -347,17 +298,13 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::unpack_string -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCArrayParameter:: unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const { - // We can only unpack a string if the array element type is char or - // int8. + // We can only unpack a string if the array element type is char or int8. DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); if (simple_type == (DCSimpleParameter *)NULL) { pack_error = true; @@ -390,47 +337,38 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCArrayParameter:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_array_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::do_check_match_simple_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// simple parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated simple parameter, false + * otherwise. + */ bool DCArrayParameter:: do_check_match_simple_parameter(const DCSimpleParameter *other) const { return ((const DCPackerInterface *)other)->do_check_match_array_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::do_check_match_class_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// class parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated class parameter, false + * otherwise. + */ bool DCArrayParameter:: do_check_match_class_parameter(const DCClassParameter *other) const { return ((const DCPackerInterface *)other)->do_check_match_array_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCArrayParameter::do_check_match_array_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// array parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated array parameter, false + * otherwise. + */ bool DCArrayParameter:: do_check_match_array_parameter(const DCArrayParameter *other) const { if (_array_size != other->_array_size) { diff --git a/direct/src/dcparser/dcArrayParameter.h b/direct/src/dcparser/dcArrayParameter.h index 10c75d1185..fa9e6e925a 100644 --- a/direct/src/dcparser/dcArrayParameter.h +++ b/direct/src/dcparser/dcArrayParameter.h @@ -1,16 +1,15 @@ -// Filename: dcArrayParameter.h -// Created by: drose (17Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcArrayParameter.h + * @author drose + * @date 2004-06-17 + */ #ifndef DCARRAYPARAMETER_H #define DCARRAYPARAMETER_H @@ -19,16 +18,14 @@ #include "dcParameter.h" #include "dcNumericRange.h" -//////////////////////////////////////////////////////////////////// -// Class : DCArrayParameter -// Description : This represents an array of some other kind of -// object, meaning this parameter type accepts an -// arbitrary (or possibly fixed) number of nested -// fields, all of which are of the same type. -//////////////////////////////////////////////////////////////////// +/** + * This represents an array of some other kind of object, meaning this + * parameter type accepts an arbitrary (or possibly fixed) number of nested + * fields, all of which are of the same type. + */ class EXPCL_DIRECT DCArrayParameter : public DCParameter { public: - DCArrayParameter(DCParameter *element_type, + DCArrayParameter(DCParameter *element_type, const DCUnsignedIntRange &size = DCUnsignedIntRange()); DCArrayParameter(const DCArrayParameter ©); virtual ~DCArrayParameter(); @@ -49,13 +46,13 @@ public: virtual DCPackerInterface *get_nested_field(int n) const; virtual bool validate_num_nested_fields(int num_nested_fields) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, + virtual void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; virtual void pack_string(DCPackData &pack_data, const string &value, bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; - virtual void unpack_string(const char *data, size_t length, size_t &p, + virtual void unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const; protected: diff --git a/direct/src/dcparser/dcAtomicField.I b/direct/src/dcparser/dcAtomicField.I index f2a88dc2c0..3acfb16755 100644 --- a/direct/src/dcparser/dcAtomicField.I +++ b/direct/src/dcparser/dcAtomicField.I @@ -1,14 +1,12 @@ -// Filename: dcAtomicField.I -// Created by: drose (15Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcAtomicField.I + * @author drose + * @date 2006-08-15 + */ diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index 4faaf33310..0d2ace8f35 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -1,16 +1,15 @@ -// Filename: dcAtomicField.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcAtomicField.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcAtomicField.h" #include "hashGenerator.h" @@ -20,139 +19,110 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCAtomicField:: DCAtomicField(const string &name, DCClass *dclass, - bool bogus_field) : + bool bogus_field) : DCField(name, dclass) { _bogus_field = bogus_field; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCAtomicField:: ~DCAtomicField() { - Elements::iterator ei; + Elements::iterator ei; for (ei = _elements.begin(); ei != _elements.end(); ++ei) { delete (*ei); } _elements.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::as_atomic_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to an atomic -// field pointer, if this is in fact an atomic field; -// otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to an atomic field pointer, if + * this is in fact an atomic field; otherwise, returns NULL. + */ DCAtomicField *DCAtomicField:: as_atomic_field() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::as_atomic_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to an atomic -// field pointer, if this is in fact an atomic field; -// otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to an atomic field pointer, if + * this is in fact an atomic field; otherwise, returns NULL. + */ const DCAtomicField *DCAtomicField:: as_atomic_field() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_num_elements -// Access: Published -// Description: Returns the number of elements (parameters) of the -// atomic field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements (parameters) of the atomic field. + */ int DCAtomicField:: get_num_elements() const { return _elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_element -// Access: Published -// Description: Returns the parameter object describing the -// nth element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parameter object describing the nth element. + */ DCParameter *DCAtomicField:: get_element(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), NULL); return _elements[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_element_default -// Access: Published -// Description: Returns the pre-formatted default value associated -// with the nth element of the field. This is only -// valid if has_element_default() returns true, in which -// case this string represents the bytes that should be -// assigned to the field as a default value. -// -// If the element is an array-type element, the returned -// value will include the two-byte length preceding the -// array data. -// -// This is deprecated; use get_element() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pre-formatted default value associated with the nth element of + * the field. This is only valid if has_element_default() returns true, in + * which case this string represents the bytes that should be assigned to the + * field as a default value. + * + * If the element is an array-type element, the returned value will include + * the two-byte length preceding the array data. + * + * This is deprecated; use get_element() instead. + */ string DCAtomicField:: get_element_default(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), string()); return _elements[n]->get_default_value(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::has_element_default -// Access: Published -// Description: Returns true if the nth element of the field has a -// default value specified, false otherwise. -// -// This is deprecated; use get_element() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth element of the field has a default value specified, + * false otherwise. + * + * This is deprecated; use get_element() instead. + */ bool DCAtomicField:: has_element_default(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), false); return _elements[n]->has_default_value(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_element_name -// Access: Published -// Description: Returns the name of the nth element of the field. -// This name is strictly for documentary purposes; it -// does not generally affect operation. If a name is -// not specified, this will be the empty string. -// -// This method is deprecated; use -// get_element()->get_name() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth element of the field. This name is strictly + * for documentary purposes; it does not generally affect operation. If a + * name is not specified, this will be the empty string. + * + * This method is deprecated; use get_element()->get_name() instead. + */ string DCAtomicField:: get_element_name(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), string()); return _elements[n]->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_element_type -// Access: Published -// Description: Returns the numeric type of the nth element of the -// field. This method is deprecated; use -// get_element() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the numeric type of the nth element of the field. This method is + * deprecated; use get_element() instead. + */ DCSubatomicType DCAtomicField:: get_element_type(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), ST_invalid); @@ -161,18 +131,14 @@ get_element_type(int n) const { return simple_parameter->get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_element_divisor -// Access: Published -// Description: Returns the divisor associated with the nth element -// of the field. This implements an implicit -// fixed-point system; floating-point values are to be -// multiplied by this value before encoding into a -// packet, and divided by this number after decoding. -// -// This method is deprecated; use -// get_element()->get_divisor() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the divisor associated with the nth element of the field. This + * implements an implicit fixed-point system; floating-point values are to be + * multiplied by this value before encoding into a packet, and divided by this + * number after decoding. + * + * This method is deprecated; use get_element()->get_divisor() instead. + */ int DCAtomicField:: get_element_divisor(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), 1); @@ -181,11 +147,9 @@ get_element_divisor(int n) const { return simple_parameter->get_divisor(); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCAtomicField:: output(ostream &out, bool brief) const { out << _name << "("; @@ -205,12 +169,10 @@ output(ostream &out, bool brief) const { output_keywords(out); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::write -// Access: Public, Virtual -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCAtomicField:: write(ostream &out, bool brief, int indent_level) const { indent(out, indent_level); @@ -222,12 +184,9 @@ write(ostream &out, bool brief, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this field into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this field into the hash. + */ void DCAtomicField:: generate_hash(HashGenerator &hashgen) const { DCField::generate_hash(hashgen); @@ -241,28 +200,22 @@ generate_hash(HashGenerator &hashgen) const { DCKeywordList::generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCAtomicField:: get_nested_field(int n) const { nassertr(n >= 0 && n < (int)_elements.size(), NULL); return _elements[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::add_element -// Access: Public -// Description: Adds a new element (parameter) to the field. -// Normally this is called only during parsing. The -// DCAtomicField object becomes the owner of the new -// pointer and will delete it upon destruction. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new element (parameter) to the field. Normally this is called only + * during parsing. The DCAtomicField object becomes the owner of the new + * pointer and will delete it upon destruction. + */ void DCAtomicField:: add_element(DCParameter *element) { _elements.push_back(element); @@ -285,25 +238,20 @@ add_element(DCParameter *element) { _default_value_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCAtomicField:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_atomic_field(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::do_check_match_atomic_field -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// atomic field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated atomic field, false + * otherwise. + */ bool DCAtomicField:: do_check_match_atomic_field(const DCAtomicField *other) const { if (_elements.size() != other->_elements.size()) { @@ -318,11 +266,9 @@ do_check_match_atomic_field(const DCAtomicField *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCAtomicField::output_element -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCAtomicField:: output_element(ostream &out, bool brief, DCParameter *element) const { element->output(out, brief); diff --git a/direct/src/dcparser/dcAtomicField.h b/direct/src/dcparser/dcAtomicField.h index a26317d5cf..b03d8ed290 100644 --- a/direct/src/dcparser/dcAtomicField.h +++ b/direct/src/dcparser/dcAtomicField.h @@ -1,16 +1,15 @@ -// Filename: dcAtomicField.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcAtomicField.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCATOMICFIELD_H #define DCATOMICFIELD_H @@ -20,17 +19,14 @@ #include "dcSubatomicType.h" #include "dcParameter.h" -// Must use math.h instead of cmath.h so this can compile outside of -// Panda. +// Must use math.h instead of cmath.h so this can compile outside of Panda. #include -//////////////////////////////////////////////////////////////////// -// Class : DCAtomicField -// Description : A single atomic field of a Distributed Class, as read -// from a .dc file. This defines an interface to the -// Distributed Class, and is always implemented as a -// remote procedure method. -//////////////////////////////////////////////////////////////////// +/** + * A single atomic field of a Distributed Class, as read from a .dc file. + * This defines an interface to the Distributed Class, and is always + * implemented as a remote procedure method. + */ class EXPCL_DIRECT DCAtomicField : public DCField { public: DCAtomicField(const string &name, DCClass *dclass, bool bogus_field); diff --git a/direct/src/dcparser/dcClass.I b/direct/src/dcparser/dcClass.I index 78d84cc66b..a33fe53bc5 100644 --- a/direct/src/dcparser/dcClass.I +++ b/direct/src/dcparser/dcClass.I @@ -1,87 +1,68 @@ -// Filename: dcClass.I -// Created by: drose (15Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcClass.I + * @author drose + * @date 2004-09-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_dc_file -// Access: Published -// Description: Returns the DCFile object that contains the class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCFile object that contains the class. + */ INLINE DCFile *DCClass:: get_dc_file() const { return _dc_file; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_name -// Access: Published -// Description: Returns the name of this class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this class. + */ INLINE const string &DCClass:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_number -// Access: Published -// Description: Returns a unique index number associated with this -// class. This is defined implicitly when the .dc -// file(s) are read. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique index number associated with this class. This is defined + * implicitly when the .dc file(s) are read. + */ INLINE int DCClass:: get_number() const { return _number; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::is_struct -// Access: Published -// Description: Returns true if the class has been identified with -// the "struct" keyword in the dc file, false if it was -// declared with "dclass". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the class has been identified with the "struct" keyword in + * the dc file, false if it was declared with "dclass". + */ INLINE bool DCClass:: is_struct() const { return _is_struct; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::is_bogus_class -// Access: Published -// Description: Returns true if the class has been flagged as a bogus -// class. This is set for classes that are generated by -// the parser as placeholder for missing classes, as -// when reading a partial file; it should not occur in a -// normal valid dc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the class has been flagged as a bogus class. This is set + * for classes that are generated by the parser as placeholder for missing + * classes, as when reading a partial file; it should not occur in a normal + * valid dc file. + */ INLINE bool DCClass:: is_bogus_class() const { return _bogus_class; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::start_generate -// Access: Published -// Description: Starts the PStats timer going on the "generate" task, -// that is, marks the beginning of the process of -// generating a new object, for the purposes of timing -// this process. -// -// This should balance with a corresponding call to -// stop_generate(). -//////////////////////////////////////////////////////////////////// +/** + * Starts the PStats timer going on the "generate" task, that is, marks the + * beginning of the process of generating a new object, for the purposes of + * timing this process. + * + * This should balance with a corresponding call to stop_generate(). + */ INLINE void DCClass:: start_generate() { #ifdef WITHIN_PANDA @@ -89,13 +70,10 @@ start_generate() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::stop_generate -// Access: Published -// Description: Stops the PStats timer on the "generate" task. -// This should balance with a preceding call to -// start_generate(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the PStats timer on the "generate" task. This should balance with a + * preceding call to start_generate(). + */ INLINE void DCClass:: stop_generate() { #ifdef WITHIN_PANDA diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 0262f69fb1..513d13fd90 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -1,16 +1,15 @@ -// Filename: dcClass.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcClass.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcClass.h" #include "dcFile.h" @@ -66,11 +65,9 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: DCClass::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClass:: DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : #ifdef WITHIN_PANDA @@ -91,11 +88,9 @@ DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClass:: ~DCClass() { if (_constructor != (DCField *)NULL) { @@ -113,91 +108,71 @@ DCClass:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::as_class -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClass *DCClass:: as_class() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::as_class -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCClass *DCClass:: as_class() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_num_parents -// Access: Published -// Description: Returns the number of base classes this class -// inherits from. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of base classes this class inherits from. + */ int DCClass:: get_num_parents() const { return _parents.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_parent -// Access: Published -// Description: Returns the nth parent class this class inherits -// from. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent class this class inherits from. + */ DCClass *DCClass:: get_parent(int n) const { nassertr(n >= 0 && n < (int)_parents.size(), NULL); return _parents[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::has_constructor -// Access: Published -// Description: Returns true if this class has a constructor method, -// false if it just uses the default constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this class has a constructor method, false if it just uses + * the default constructor. + */ bool DCClass:: has_constructor() const { return (_constructor != (DCField *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_constructor -// Access: Published -// Description: Returns the constructor method for this class if it -// is defined, or NULL if the class uses the default -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the constructor method for this class if it is defined, or NULL if + * the class uses the default constructor. + */ DCField *DCClass:: get_constructor() const { return _constructor; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_num_fields -// Access: Published -// Description: Returns the number of fields defined directly in this -// class, ignoring inheritance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of fields defined directly in this class, ignoring + * inheritance. + */ int DCClass:: get_num_fields() const { return _fields.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_field -// Access: Published -// Description: Returns the nth field in the class. This is not -// necessarily the field with index n; this is the nth -// field defined in the class directly, ignoring -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth field in the class. This is not necessarily the field with + * index n; this is the nth field defined in the class directly, ignoring + * inheritance. + */ DCField *DCClass:: get_field(int n) const { #ifndef NDEBUG //[ @@ -212,16 +187,12 @@ get_field(int n) const { return _fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_field_by_name -// Access: Published -// Description: Returns a pointer to the DCField that shares the -// indicated name. If the named field is not found in -// the current class, the parent classes will be -// searched, so the value returned may not actually be a -// field within this class. Returns NULL if there is no -// such field defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the DCField that shares the indicated name. If the + * named field is not found in the current class, the parent classes will be + * searched, so the value returned may not actually be a field within this + * class. Returns NULL if there is no such field defined. + */ DCField *DCClass:: get_field_by_name(const string &name) const { FieldsByName::const_iterator ni; @@ -243,16 +214,12 @@ get_field_by_name(const string &name) const { return (DCField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_field_by_index -// Access: Published -// Description: Returns a pointer to the DCField that has the -// indicated index number. If the numbered field is not -// found in the current class, the parent classes will -// be searched, so the value returned may not actually -// be a field within this class. Returns NULL if there -// is no such field defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the DCField that has the indicated index number. If + * the numbered field is not found in the current class, the parent classes + * will be searched, so the value returned may not actually be a field within + * this class. Returns NULL if there is no such field defined. + */ DCField *DCClass:: get_field_by_index(int index_number) const { FieldsByIndex::const_iterator ni; @@ -276,12 +243,10 @@ get_field_by_index(int index_number) const { return (DCField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_num_inherited_fields -// Access: Published -// Description: Returns the total number of field fields defined in -// this class and all ancestor classes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of field fields defined in this class and all + * ancestor classes. + */ int DCClass:: get_num_inherited_fields() const { if (dc_multiple_inheritance && dc_virtual_inheritance && @@ -291,9 +256,8 @@ get_num_inherited_fields() const { ((DCClass *)this)->rebuild_inherited_fields(); } - // This assertion causes trouble when we are only parsing an - // incomplete DC file. - //nassertr(is_bogus_class() || !_inherited_fields.empty(), 0); + // This assertion causes trouble when we are only parsing an incomplete DC + // file. nassertr(is_bogus_class() || !_inherited_fields.empty(), 0); return (int)_inherited_fields.size(); } else { @@ -308,18 +272,14 @@ get_num_inherited_fields() const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_inherited_field -// Access: Published -// Description: Returns the nth field field in the class and all of -// its ancestors. -// -// This *used* to be the same thing as -// get_field_by_index(), back when the fields were -// numbered sequentially within a class's inheritance -// hierarchy. Now that fields have a globally unique -// index number, this is no longer true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth field field in the class and all of its ancestors. + * + * This *used* to be the same thing as get_field_by_index(), back when the + * fields were numbered sequentially within a class's inheritance hierarchy. + * Now that fields have a globally unique index number, this is no longer + * true. + */ DCField *DCClass:: get_inherited_field(int n) const { if (dc_multiple_inheritance && dc_virtual_inheritance && @@ -346,14 +306,11 @@ get_inherited_field(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::inherits_from_bogus_class -// Access: Published -// Description: Returns true if this class, or any class in the -// inheritance heirarchy for this class, is a "bogus" -// class--a forward reference to an as-yet-undefined -// class. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this class, or any class in the inheritance heirarchy for + * this class, is a "bogus" class--a forward reference to an as-yet-undefined + * class. + */ bool DCClass:: inherits_from_bogus_class() const { if (is_bogus_class()) { @@ -370,12 +327,9 @@ inherits_from_bogus_class() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::output -// Access: Published, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCClass:: output(ostream &out) const { if (_is_struct) { @@ -389,12 +343,10 @@ output(ostream &out) const { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::has_class_def -// Access: Published -// Description: Returns true if the DCClass object has an associated -// Python class definition, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the DCClass object has an associated Python class + * definition, false otherwise. + */ bool DCClass:: has_class_def() const { return (_class_def != NULL); @@ -402,13 +354,10 @@ has_class_def() const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::set_class_def -// Access: Published -// Description: Sets the class object associated with this -// DistributedClass. This object will be used to -// construct new instances of the class. -//////////////////////////////////////////////////////////////////// +/** + * Sets the class object associated with this DistributedClass. This object + * will be used to construct new instances of the class. + */ void DCClass:: set_class_def(PyObject *class_def) { Py_XINCREF(class_def); @@ -418,13 +367,10 @@ set_class_def(PyObject *class_def) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_class_def -// Access: Published -// Description: Returns the class object that was previously -// associated with this DistributedClass. This will -// return a new reference to the object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the class object that was previously associated with this + * DistributedClass. This will return a new reference to the object. + */ PyObject *DCClass:: get_class_def() const { if (_class_def == NULL) { @@ -438,12 +384,10 @@ get_class_def() const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::has_owner_class_def -// Access: Published -// Description: Returns true if the DCClass object has an associated -// Python owner class definition, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the DCClass object has an associated Python owner class + * definition, false otherwise. + */ bool DCClass:: has_owner_class_def() const { return (_owner_class_def != NULL); @@ -451,13 +395,10 @@ has_owner_class_def() const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::set_owner_class_def -// Access: Published -// Description: Sets the owner class object associated with this -// DistributedClass. This object will be used to -// construct new owner instances of the class. -//////////////////////////////////////////////////////////////////// +/** + * Sets the owner class object associated with this DistributedClass. This + * object will be used to construct new owner instances of the class. + */ void DCClass:: set_owner_class_def(PyObject *owner_class_def) { Py_XINCREF(owner_class_def); @@ -467,13 +408,10 @@ set_owner_class_def(PyObject *owner_class_def) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::get_owner_class_def -// Access: Published -// Description: Returns the owner class object that was previously -// associated with this DistributedClass. This will -// return a new reference to the object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the owner class object that was previously associated with this + * DistributedClass. This will return a new reference to the object. + */ PyObject *DCClass:: get_owner_class_def() const { if (_owner_class_def == NULL) { @@ -487,13 +425,10 @@ get_owner_class_def() const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::receive_update -// Access: Published -// Description: Extracts the update message out of the packer and -// applies it to the indicated object by calling the -// appropriate method. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the update message out of the packer and applies it to the + * indicated object by calling the appropriate method. + */ void DCClass:: receive_update(PyObject *distobj, DatagramIterator &di) const { #ifdef WITHIN_PANDA @@ -525,14 +460,11 @@ receive_update(PyObject *distobj, DatagramIterator &di) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::receive_update_broadcast_required -// Access: Published -// Description: Processes a big datagram that includes all of the -// "required" fields that are sent along with a normal -// "generate with required" message. This is all of the -// atomic fields that are marked "broadcast required". -//////////////////////////////////////////////////////////////////// +/** + * Processes a big datagram that includes all of the "required" fields that + * are sent along with a normal "generate with required" message. This is all + * of the atomic fields that are marked "broadcast required". + */ void DCClass:: receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const { #ifdef WITHIN_PANDA @@ -561,15 +493,12 @@ receive_update_broadcast_required(PyObject *distobj, DatagramIterator &di) const #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::receive_update_broadcast_required_owner -// Access: Published -// Description: Processes a big datagram that includes all of the -// "required" fields that are sent along with a normal -// "generate with required" message. This is all of the -// atomic fields that are marked "broadcast ownrecv". Should -// be used for 'owner-view' objects. -//////////////////////////////////////////////////////////////////// +/** + * Processes a big datagram that includes all of the "required" fields that + * are sent along with a normal "generate with required" message. This is all + * of the atomic fields that are marked "broadcast ownrecv". Should be used + * for 'owner-view' objects. + */ void DCClass:: receive_update_broadcast_required_owner(PyObject *distobj, DatagramIterator &di) const { @@ -590,8 +519,8 @@ receive_update_broadcast_required_owner(PyObject *distobj, if (field->is_ownrecv()) { field->receive_update(packer, distobj); } else { - // It's not an ownrecv field; skip over it. It's difficult - // to filter this on the server, ask Roger for the reason. + // It's not an ownrecv field; skip over it. It's difficult to filter + // this on the server, ask Roger for the reason. packer.unpack_skip(); } if (!packer.end_unpack()) { @@ -605,14 +534,11 @@ receive_update_broadcast_required_owner(PyObject *distobj, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::receive_update_all_required -// Access: Published -// Description: Processes a big datagram that includes all of the -// "required" fields that are sent when an avatar is -// created. This is all of the atomic fields that are -// marked "required", whether they are broadcast or not. -//////////////////////////////////////////////////////////////////// +/** + * Processes a big datagram that includes all of the "required" fields that + * are sent when an avatar is created. This is all of the atomic fields that + * are marked "required", whether they are broadcast or not. + */ void DCClass:: receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { #ifdef WITHIN_PANDA @@ -641,12 +567,10 @@ receive_update_all_required(PyObject *distobj, DatagramIterator &di) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::receive_update_other -// Access: Published -// Description: Processes a datagram that lists some additional -// fields that are broadcast in one chunk. -//////////////////////////////////////////////////////////////////// +/** + * Processes a datagram that lists some additional fields that are broadcast + * in one chunk. + */ void DCClass:: receive_update_other(PyObject *distobj, DatagramIterator &di) const { #ifdef WITHIN_PANDA @@ -660,12 +584,9 @@ receive_update_other(PyObject *distobj, DatagramIterator &di) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::direct_update -// Access: Published -// Description: Processes an update for a named field from a packed -// value blob. -//////////////////////////////////////////////////////////////////// +/** + * Processes an update for a named field from a packed value blob. + */ void DCClass:: direct_update(PyObject *distobj, const string &field_name, const string &value_blob) { @@ -681,12 +602,9 @@ direct_update(PyObject *distobj, const string &field_name, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::direct_update -// Access: Published -// Description: Processes an update for a named field from a packed -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Processes an update for a named field from a packed datagram. + */ void DCClass:: direct_update(PyObject *distobj, const string &field_name, const Datagram &datagram) { @@ -695,18 +613,14 @@ direct_update(PyObject *distobj, const string &field_name, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::pack_required_field -// Access: Published -// Description: Looks up the current value of the indicated field by -// calling the appropriate get*() function, then packs -// that value into the datagram. This field is -// presumably either a required field or a specified -// optional field, and we are building up a datagram for -// the generate-with-required message. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the current value of the indicated field by calling the + * appropriate get*() function, then packs that value into the datagram. This + * field is presumably either a required field or a specified optional field, + * and we are building up a datagram for the generate-with-required message. + * + * Returns true on success, false on failure. + */ bool DCClass:: pack_required_field(Datagram &datagram, PyObject *distobj, const DCField *field) const { @@ -725,30 +639,26 @@ pack_required_field(Datagram &datagram, PyObject *distobj, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::pack_required_field -// Access: Published -// Description: Looks up the current value of the indicated field by -// calling the appropriate get*() function, then packs -// that value into the packer. This field is -// presumably either a required field or a specified -// optional field, and we are building up a datagram for -// the generate-with-required message. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the current value of the indicated field by calling the + * appropriate get*() function, then packs that value into the packer. This + * field is presumably either a required field or a specified optional field, + * and we are building up a datagram for the generate-with-required message. + * + * Returns true on success, false on failure. + */ bool DCClass:: pack_required_field(DCPacker &packer, PyObject *distobj, const DCField *field) const { const DCParameter *parameter = field->as_parameter(); if (parameter != (DCParameter *)NULL) { - // This is the easy case: to pack a parameter, we just look on the - // class object for the data element. + // This is the easy case: to pack a parameter, we just look on the class + // object for the data element. string field_name = field->get_name(); if (!PyObject_HasAttrString(distobj, (char *)field_name.c_str())) { - // If the attribute is not defined, but the field has a default - // value specified, quietly pack the default value. + // If the attribute is not defined, but the field has a default value + // specified, quietly pack the default value. if (field->has_default_value()) { packer.pack_default_value(); return true; @@ -784,10 +694,9 @@ pack_required_field(DCPacker &packer, PyObject *distobj, const DCAtomicField *atom = field->as_atomic_field(); nassertr(atom != (DCAtomicField *)NULL, false); - // We need to get the initial value of this field. There isn't a - // good, robust way to get this; presently, we just mangle the - // "setFoo()" name of the required field into "getFoo()" and call - // that. + // We need to get the initial value of this field. There isn't a good, + // robust way to get this; presently, we just mangle the "setFoo()" name of + // the required field into "getFoo()" and call that. string setter_name = atom->get_name(); if (setter_name.empty()) { @@ -798,8 +707,8 @@ pack_required_field(DCPacker &packer, PyObject *distobj, } if (atom->get_num_elements() == 0) { - // It sure doesn't make sense to have a required field with no - // parameters. What data, exactly, is required? + // It sure doesn't make sense to have a required field with no parameters. + // What data, exactly, is required? ostringstream strm; strm << "Required field " << setter_name << " has no parameters!"; nassert_raise(strm.str()); @@ -808,22 +717,20 @@ pack_required_field(DCPacker &packer, PyObject *distobj, string getter_name = setter_name; if (setter_name.substr(0, 3) == "set") { - // If the original method started with "set", we mangle this - // directly to "get". + // If the original method started with "set", we mangle this directly to + // "get". getter_name[0] = 'g'; } else { - // Otherwise, we add a "get" prefix, and capitalize the next - // letter. + // Otherwise, we add a "get" prefix, and capitalize the next letter. getter_name = "get" + setter_name; getter_name[3] = toupper(getter_name[3]); } - // Now we have to look up the getter on the distributed object - // and call it. + // Now we have to look up the getter on the distributed object and call it. if (!PyObject_HasAttrString(distobj, (char *)getter_name.c_str())) { - // As above, if there's no getter but the field has a default - // value specified, quietly pack the default value. + // As above, if there's no getter but the field has a default value + // specified, quietly pack the default value. if (field->has_default_value()) { packer.pack_default_value(); return true; @@ -846,22 +753,21 @@ pack_required_field(DCPacker &packer, PyObject *distobj, Py_DECREF(empty_args); Py_DECREF(func); if (result == (PyObject *)NULL) { - // We don't set this as an exception, since presumably the Python - // method itself has already triggered a Python exception. + // We don't set this as an exception, since presumably the Python method + // itself has already triggered a Python exception. cerr << "Error when calling " << getter_name << "\n"; return false; } if (atom->get_num_elements() == 1) { - // In this case, we expect the getter to return one object, - // which we wrap up in a tuple. + // In this case, we expect the getter to return one object, which we wrap + // up in a tuple. PyObject *tuple = PyTuple_New(1); PyTuple_SET_ITEM(tuple, 0, result); result = tuple; } else { - // Otherwise, it had better already be a sequence or tuple of some - // sort. + // Otherwise, it had better already be a sequence or tuple of some sort. if (!PySequence_Check(result)) { ostringstream strm; strm << "Since dclass " << get_name() << " method " << setter_name @@ -881,13 +787,10 @@ pack_required_field(DCPacker &packer, PyObject *distobj, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::client_format_update -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update for the indicated distributed -// object from the client. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update for + * the indicated distributed object from the client. + */ Datagram DCClass:: client_format_update(const string &field_name, DOID_TYPE do_id, PyObject *args) const { @@ -905,13 +808,10 @@ client_format_update(const string &field_name, DOID_TYPE do_id, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::ai_format_update -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update for the indicated distributed -// object from the AI. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update for + * the indicated distributed object from the AI. + */ Datagram DCClass:: ai_format_update(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const { @@ -929,14 +829,11 @@ ai_format_update(const string &field_name, DOID_TYPE do_id, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::ai_format_update_msg_type -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update, using the indicated msg type -// for the indicated distributed -// object from the AI. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update, + * using the indicated msg type for the indicated distributed object from the + * AI. + */ Datagram DCClass:: ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const { @@ -954,19 +851,16 @@ ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::client_format_generate_CMU -// Access: Published -// Description: Generates a datagram containing the message necessary -// to generate a new distributed object from the client. -// This requires querying the object for the initial -// value of its required fields. -// -// optional_fields is a list of fieldNames to generate -// in addition to the normal required fields. -// -// This method is only called by the CMU implementation. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to generate a new + * distributed object from the client. This requires querying the object for + * the initial value of its required fields. + * + * optional_fields is a list of fieldNames to generate in addition to the + * normal required fields. + * + * This method is only called by the CMU implementation. + */ Datagram DCClass:: client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE zone_id, @@ -1029,17 +923,14 @@ client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::ai_format_generate -// Access: Published -// Description: Generates a datagram containing the message necessary -// to generate a new distributed object from the AI. -// This requires querying the object for the initial -// value of its required fields. -// -// optional_fields is a list of fieldNames to generate -// in addition to the normal required fields. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to generate a new + * distributed object from the AI. This requires querying the object for the + * initial value of its required fields. + * + * optional_fields is a list of fieldNames to generate in addition to the + * normal required fields. + */ Datagram DCClass:: ai_format_generate(PyObject *distobj, DOID_TYPE do_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, @@ -1050,7 +941,7 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, packer.raw_pack_uint8(1); packer.RAW_PACK_CHANNEL(district_channel_id); packer.RAW_PACK_CHANNEL(from_channel_id); - //packer.raw_pack_uint8('A'); + // packer.raw_pack_uint8('A'); bool has_optional_fields = (PyObject_IsTrue(optional_fields) != 0); @@ -1060,9 +951,8 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, packer.raw_pack_uint16(STATESERVER_OBJECT_GENERATE_WITH_REQUIRED); } - // Parent is a bit overloaded; this parent is not about inheritance, - // this one is about the visibility container parent, i.e. the zone - // parent: + // Parent is a bit overloaded; this parent is not about inheritance, this + // one is about the visibility container parent, i.e. the zone parent: if (parent_id) { packer.raw_pack_uint32(parent_id); } @@ -1120,15 +1010,12 @@ ai_format_generate(PyObject *distobj, DOID_TYPE do_id, } #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::ai_database_generate_context -// Access: Published -// Description: Generates a datagram containing the message necessary -// to create a new database distributed object from the AI. -// -// First Pass is to only include required values -// (with Defaults). -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to create a new + * database distributed object from the AI. + * + * First Pass is to only include required values (with Defaults). + */ Datagram DCClass:: ai_database_generate_context( unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, @@ -1139,7 +1026,7 @@ ai_database_generate_context( packer.raw_pack_uint8(1); packer.RAW_PACK_CHANNEL(database_server_id); packer.RAW_PACK_CHANNEL(from_channel_id); - //packer.raw_pack_uint8('A'); + // packer.raw_pack_uint8('A'); packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT); packer.raw_pack_uint32(parent_id); packer.raw_pack_uint32(zone_id); @@ -1163,16 +1050,6 @@ ai_database_generate_context( #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -// TODO: remove this once Skyler has things working with the new server -//////////////////////////////////////////////////////////////////// -// Function: DCClass::ai_database_generate_context_old -// Access: Published -// Description: Generates a datagram containing the message necessary -// to create a new database distributed object from the AI. -// -// First Pass is to only include required values -// (with Defaults). -//////////////////////////////////////////////////////////////////// Datagram DCClass:: ai_database_generate_context_old( unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, @@ -1182,7 +1059,7 @@ ai_database_generate_context_old( packer.raw_pack_uint8(1); packer.RAW_PACK_CHANNEL(database_server_id); packer.RAW_PACK_CHANNEL(from_channel_id); - //packer.raw_pack_uint8('A'); + // packer.raw_pack_uint8('A'); packer.raw_pack_uint16(STATESERVER_OBJECT_CREATE_WITH_REQUIRED_CONTEXT); packer.raw_pack_uint32(parent_id); packer.raw_pack_uint32(zone_id); @@ -1204,23 +1081,18 @@ ai_database_generate_context_old( } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCClass::output -// Access: Public, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCClass:: output(ostream &out, bool brief) const { output_instance(out, brief, "", "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::write -// Access: Public, Virtual -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCClass:: write(ostream &out, bool brief, int indent_level) const { indent(out, indent_level); @@ -1277,12 +1149,10 @@ write(ostream &out, bool brief, int indent_level) const { indent(out, indent_level) << "};\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::output_instance -// Access: Public -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCClass:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { @@ -1326,12 +1196,9 @@ output_instance(ostream &out, bool brief, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this class into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this class into the hash. + */ void DCClass:: generate_hash(HashGenerator &hashgen) const { hashgen.add_string(_name); @@ -1357,23 +1224,19 @@ generate_hash(HashGenerator &hashgen) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::clear_inherited_fields -// Access: Public -// Description: Empties the list of inherited fields for the class, -// so that it may be rebuilt. This is normally only -// called by DCFile::rebuild_inherited_fields(). -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of inherited fields for the class, so that it may be + * rebuilt. This is normally only called by + * DCFile::rebuild_inherited_fields(). + */ void DCClass:: clear_inherited_fields() { _inherited_fields.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::rebuild_inherited_fields -// Access: Public -// Description: Recomputes the list of inherited fields for the class. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the list of inherited fields for the class. + */ void DCClass:: rebuild_inherited_fields() { typedef pset Names; @@ -1381,8 +1244,8 @@ rebuild_inherited_fields() { _inherited_fields.clear(); - // First, all of the inherited fields from our parent are at the top - // of the list. + // First, all of the inherited fields from our parent are at the top of the + // list. Parents::const_iterator pi; for (pi = _parents.begin(); pi != _parents.end(); ++pi) { const DCClass *parent = (*pi); @@ -1405,10 +1268,10 @@ rebuild_inherited_fields() { } } - // Now add the local fields at the end of the list. If any fields - // in this list were already defined by a parent, we will shadow the - // parent definition (that is, remove the parent's field from our - // list of inherited fields). + // Now add the local fields at the end of the list. If any fields in this + // list were already defined by a parent, we will shadow the parent + // definition (that is, remove the parent's field from our list of inherited + // fields). Fields::const_iterator fi; for (fi = _fields.begin(); fi != _fields.end(); ++fi) { DCField *field = (*fi); @@ -1419,8 +1282,8 @@ rebuild_inherited_fields() { } else { bool inserted = names.insert(field->get_name()).second; if (!inserted) { - // This local field shadows an inherited field. Remove the - // parent's field from our list. + // This local field shadows an inherited field. Remove the parent's + // field from our list. shadow_inherited_field(field->get_name()); } @@ -1435,14 +1298,11 @@ rebuild_inherited_fields() { } } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::shadow_inherited_field -// Access: Private -// Description: This is called only by rebuild_inherited_fields(). -// It removes the named field from the list of -// _inherited_fields, presumably in preparation for -// adding a new definition below. -//////////////////////////////////////////////////////////////////// +/** + * This is called only by rebuild_inherited_fields(). It removes the named + * field from the list of _inherited_fields, presumably in preparation for + * adding a new definition below. + */ void DCClass:: shadow_inherited_field(const string &name) { Fields::iterator fi; @@ -1458,15 +1318,12 @@ shadow_inherited_field(const string &name) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::add_field -// Access: Public -// Description: Adds the newly-allocated field to the class. The -// class becomes the owner of the pointer and will -// delete it when it destructs. Returns true if the -// field is successfully added, or false if there was a -// name conflict or some other problem. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-allocated field to the class. The class becomes the owner + * of the pointer and will delete it when it destructs. Returns true if the + * field is successfully added, or false if there was a name conflict or some + * other problem. + */ bool DCClass:: add_field(DCField *field) { nassertr(field->get_class() == this || field->get_class() == NULL, false); @@ -1519,27 +1376,21 @@ add_field(DCField *field) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::add_parent -// Access: Public -// Description: Adds a new parent to the inheritance hierarchy of the -// class. This is normally called only during parsing. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new parent to the inheritance hierarchy of the class. This is + * normally called only during parsing. + */ void DCClass:: add_parent(DCClass *parent) { _parents.push_back(parent); _dc_file->mark_inherited_fields_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: DCClass::set_number -// Access: Public -// Description: Assigns the unique number to this class. This is -// normally called only by the DCFile interface as the -// class is added. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the unique number to this class. This is normally called only by + * the DCFile interface as the class is added. + */ void DCClass:: set_number(int number) { _number = number; } - diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index 8d2558a4d7..94d077b540 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -1,16 +1,15 @@ -// Filename: dcClass.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcClass.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCCLASS_H #define DCCLASS_H @@ -39,14 +38,12 @@ static const bool dc_sort_inheritance_by_file = false; class HashGenerator; class DCParameter; -//////////////////////////////////////////////////////////////////// -// Class : DCClass -// Description : Defines a particular DistributedClass as read from an -// input .dc file. -//////////////////////////////////////////////////////////////////// +/** + * Defines a particular DistributedClass as read from an input .dc file. + */ class EXPCL_DIRECT DCClass : public DCDeclaration { public: - DCClass(DCFile *dc_file, const string &name, + DCClass(DCFile *dc_file, const string &name, bool is_struct, bool bogus_class); ~DCClass(); @@ -61,7 +58,7 @@ PUBLISHED: int get_num_parents() const; DCClass *get_parent(int n) const; - + bool has_constructor() const; DCField *get_constructor() const; @@ -82,7 +79,7 @@ PUBLISHED: INLINE void stop_generate(); virtual void output(ostream &out) const; - + #ifdef HAVE_PYTHON bool has_class_def() const; void set_class_def(PyObject *class_def); @@ -97,40 +94,40 @@ PUBLISHED: void receive_update_all_required(PyObject *distobj, DatagramIterator &di) const; void receive_update_other(PyObject *distobj, DatagramIterator &di) const; - void direct_update(PyObject *distobj, const string &field_name, + void direct_update(PyObject *distobj, const string &field_name, const string &value_blob); - void direct_update(PyObject *distobj, const string &field_name, + void direct_update(PyObject *distobj, const string &field_name, const Datagram &datagram); - bool pack_required_field(Datagram &datagram, PyObject *distobj, + bool pack_required_field(Datagram &datagram, PyObject *distobj, const DCField *field) const; - bool pack_required_field(DCPacker &packer, PyObject *distobj, + bool pack_required_field(DCPacker &packer, PyObject *distobj, const DCField *field) const; Datagram client_format_update(const string &field_name, DOID_TYPE do_id, PyObject *args) const; - Datagram ai_format_update(const string &field_name, DOID_TYPE do_id, + Datagram ai_format_update(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const; - Datagram ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, + Datagram ai_format_update_msg_type(const string &field_name, DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const; Datagram ai_format_generate(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE district_channel_id, CHANNEL_TYPE from_channel_id, PyObject *optional_fields) const; - Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, + Datagram client_format_generate_CMU(PyObject *distobj, DOID_TYPE do_id, ZONEID_TYPE zone_id, PyObject *optional_fields) const; Datagram ai_database_generate_context(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE owner_channel, CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const; Datagram ai_database_generate_context_old(unsigned int context_id, DOID_TYPE parent_id, ZONEID_TYPE zone_id, CHANNEL_TYPE database_server_id, CHANNEL_TYPE from_channel_id) const; - -#endif + +#endif public: virtual void output(ostream &out, bool brief) const; virtual void write(ostream &out, bool brief, int indent_level) const; - void output_instance(ostream &out, bool brief, const string &prename, + void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; void generate_hash(HashGenerator &hashgen) const; void clear_inherited_fields(); diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index 143b8d35dc..be5ca00283 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -1,27 +1,24 @@ -// Filename: dcClassParameter.cxx -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcClassParameter.cxx + * @author drose + * @date 2004-06-18 + */ #include "dcClassParameter.h" #include "dcClass.h" #include "dcArrayParameter.h" #include "hashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClassParameter:: DCClassParameter(const DCClass *dclass) : _dclass(dclass) @@ -48,9 +45,8 @@ DCClassParameter(const DCClass *dclass) : } _num_nested_fields = _nested_fields.size(); - // If all of the nested fields have a fixed byte size, then so does - // the class (and its byte size is the sum of all of the nested - // fields). + // If all of the nested fields have a fixed byte size, then so does the + // class (and its byte size is the sum of all of the nested fields). _has_fixed_byte_size = true; _fixed_byte_size = 0; _has_fixed_structure = true; @@ -64,11 +60,9 @@ DCClassParameter(const DCClass *dclass) : } } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClassParameter:: DCClassParameter(const DCClassParameter ©) : DCParameter(copy), @@ -77,80 +71,64 @@ DCClassParameter(const DCClassParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClassParameter *DCClassParameter:: as_class_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCClassParameter *DCClassParameter:: as_class_parameter() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::make_copy -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCClassParameter:: make_copy() const { return new DCClassParameter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::is_valid -// Access: Published, Virtual -// Description: Returns false if the type is an invalid type -// (e.g. declared from an undefined typedef), true if -// it is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the type is an invalid type (e.g. declared from an + * undefined typedef), true if it is valid. + */ bool DCClassParameter:: is_valid() const { return !_dclass->is_bogus_class(); } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::get_class -// Access: Published -// Description: Returns the class object this parameter represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the class object this parameter represents. + */ const DCClass *DCClassParameter:: get_class() const { return _dclass; } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCClassParameter:: get_nested_field(int n) const { nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); return _nested_fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::output_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCClassParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != (DCTypedef *)NULL) { output_typedef_name(out, brief, prename, name, postname); @@ -160,37 +138,29 @@ output_instance(ostream &out, bool brief, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this type into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this type into the hash. + */ void DCClassParameter:: generate_hash(HashGenerator &hashgen) const { DCParameter::generate_hash(hashgen); _dclass->generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCClassParameter:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_class_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::do_check_match_class_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// class parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated class parameter, false + * otherwise. + */ bool DCClassParameter:: do_check_match_class_parameter(const DCClassParameter *other) const { if (_nested_fields.size() != other->_nested_fields.size()) { @@ -205,17 +175,15 @@ do_check_match_class_parameter(const DCClassParameter *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCClassParameter::do_check_match_array_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// array parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated array parameter, false + * otherwise. + */ bool DCClassParameter:: do_check_match_array_parameter(const DCArrayParameter *other) const { if ((int)_nested_fields.size() != other->get_array_size()) { - // We can only match a fixed-size array whose size happens to - // exactly match our number of fields. + // We can only match a fixed-size array whose size happens to exactly + // match our number of fields. return false; } diff --git a/direct/src/dcparser/dcClassParameter.h b/direct/src/dcparser/dcClassParameter.h index 941186fd20..913ed20a6e 100644 --- a/direct/src/dcparser/dcClassParameter.h +++ b/direct/src/dcparser/dcClassParameter.h @@ -1,16 +1,15 @@ -// Filename: dcClassParameter.h -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcClassParameter.h + * @author drose + * @date 2004-06-18 + */ #ifndef DCCLASSPARAMETER_H #define DCCLASSPARAMETER_H @@ -20,12 +19,10 @@ class DCClass; -//////////////////////////////////////////////////////////////////// -// Class : DCClassParameter -// Description : This represents a class (or struct) object used as a -// parameter itself. This means that all the fields of -// the class get packed into the message. -//////////////////////////////////////////////////////////////////// +/** + * This represents a class (or struct) object used as a parameter itself. + * This means that all the fields of the class get packed into the message. + */ class EXPCL_DIRECT DCClassParameter : public DCParameter { public: DCClassParameter(const DCClass *dclass); @@ -42,7 +39,7 @@ PUBLISHED: public: virtual DCPackerInterface *get_nested_field(int n) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, + virtual void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; diff --git a/direct/src/dcparser/dcDeclaration.cxx b/direct/src/dcparser/dcDeclaration.cxx index c3bc368f13..fd86238b4a 100644 --- a/direct/src/dcparser/dcDeclaration.cxx +++ b/direct/src/dcparser/dcDeclaration.cxx @@ -1,86 +1,69 @@ -// Filename: dcDeclaration.cxx -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcDeclaration.cxx + * @author drose + * @date 2004-06-18 + */ #include "dcDeclaration.h" -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCDeclaration:: ~DCDeclaration() { } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::as_class -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClass *DCDeclaration:: as_class() { return (DCClass *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::as_class -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCClass *DCDeclaration:: as_class() const { return (DCClass *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::as_switch -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch *DCDeclaration:: as_switch() { return (DCSwitch *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::as_switch -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSwitch *DCDeclaration:: as_switch() const { return (DCSwitch *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration::output -// Access: Published, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCDeclaration:: output(ostream &out) const { output(out, true); } -//////////////////////////////////////////////////////////////////// -// Function: DCDeclaration:: -// Access: Published -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCDeclaration:: write(ostream &out, int indent_level) const { write(out, false, indent_level); diff --git a/direct/src/dcparser/dcDeclaration.h b/direct/src/dcparser/dcDeclaration.h index 1e521831fa..ced47b3737 100644 --- a/direct/src/dcparser/dcDeclaration.h +++ b/direct/src/dcparser/dcDeclaration.h @@ -1,16 +1,15 @@ -// Filename: dcDeclaration.h -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcDeclaration.h + * @author drose + * @date 2004-06-18 + */ #ifndef DCDECLARATION_H #define DCDECLARATION_H @@ -20,16 +19,13 @@ class DCClass; class DCSwitch; -//////////////////////////////////////////////////////////////////// -// Class : DCDeclaration -// Description : This is a common interface for a declaration in a DC -// file. Currently, this is either a class or a typedef -// declaration (import declarations are still collected -// together at the top, and don't inherit from this -// object). Its only purpose is so that classes and -// typedefs can be stored in one list together so they -// can be ordered correctly on output. -//////////////////////////////////////////////////////////////////// +/** + * This is a common interface for a declaration in a DC file. Currently, this + * is either a class or a typedef declaration (import declarations are still + * collected together at the top, and don't inherit from this object). Its + * only purpose is so that classes and typedefs can be stored in one list + * together so they can be ordered correctly on output. + */ class EXPCL_DIRECT DCDeclaration { public: virtual ~DCDeclaration(); @@ -54,4 +50,3 @@ INLINE ostream &operator << (ostream &out, const DCDeclaration &decl) { } #endif - diff --git a/direct/src/dcparser/dcField.I b/direct/src/dcparser/dcField.I index c056d26b2a..24a14cff08 100644 --- a/direct/src/dcparser/dcField.I +++ b/direct/src/dcparser/dcField.I @@ -1,61 +1,47 @@ -// Filename: dcField.I -// Created by: drose (10Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcField.I + * @author drose + * @date 2006-01-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCField::get_number -// Access: Published -// Description: Returns a unique index number associated with this -// field. This is defined implicitly when the .dc -// file(s) are read. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique index number associated with this field. This is defined + * implicitly when the .dc file(s) are read. + */ INLINE int DCField:: get_number() const { return _number; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::get_class -// Access: Published -// Description: Returns the DCClass pointer for the class that -// contains this field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCClass pointer for the class that contains this field. + */ INLINE DCClass *DCField:: get_class() const { return _dclass; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::has_default_value -// Access: Published -// Description: Returns true if a default value has been explicitly -// established for this field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a default value has been explicitly established for this + * field, false otherwise. + */ INLINE bool DCField:: has_default_value() const { return _has_default_value; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::get_default_value -// Access: Published -// Description: Returns the default value for this field. If a -// default value has been explicitly set -// (e.g. has_default_value() returns true), returns that -// value; otherwise, returns an implicit default for the -// field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default value for this field. If a default value has been + * explicitly set (e.g. has_default_value() returns true), returns that + * value; otherwise, returns an implicit default for the field. + */ INLINE const string &DCField:: get_default_value() const { if (_default_value_stale) { @@ -64,170 +50,127 @@ get_default_value() const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_bogus_field -// Access: Published -// Description: Returns true if the field has been flagged as a bogus -// field. This is set for fields that are generated by -// the parser as placeholder for missing fields, as -// when reading a partial file; it should not occur in a -// normal valid dc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the field has been flagged as a bogus field. This is set + * for fields that are generated by the parser as placeholder for missing + * fields, as when reading a partial file; it should not occur in a normal + * valid dc file. + */ INLINE bool DCField:: is_bogus_field() const { return _bogus_field; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_required -// Access: Published -// Description: Returns true if the "required" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "required" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_required() const { return has_keyword("required"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_broadcast -// Access: Published -// Description: Returns true if the "broadcast" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "broadcast" flag is set for this field, false + * otherwise. + */ INLINE bool DCField:: is_broadcast() const { return has_keyword("broadcast"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_ram -// Access: Published -// Description: Returns true if the "ram" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "ram" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_ram() const { return has_keyword("ram"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_db -// Access: Published -// Description: Returns true if the "db" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "db" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_db() const { return has_keyword("db"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_clsend -// Access: Published -// Description: Returns true if the "clsend" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "clsend" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_clsend() const { return has_keyword("clsend"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_clrecv -// Access: Published -// Description: Returns true if the "clrecv" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "clrecv" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_clrecv() const { return has_keyword("clrecv"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_ownsend -// Access: Published -// Description: Returns true if the "ownsend" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "ownsend" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_ownsend() const { return has_keyword("ownsend"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_ownrecv -// Access: Published -// Description: Returns true if the "ownrecv" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "ownrecv" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_ownrecv() const { return has_keyword("ownrecv"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::is_airecv -// Access: Published -// Description: Returns true if the "airecv" flag is set for this -// field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "airecv" flag is set for this field, false otherwise. + */ INLINE bool DCField:: is_airecv() const { return has_keyword("airecv"); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::output -// Access: Published -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ INLINE void DCField:: output(ostream &out) const { output(out, true); } -//////////////////////////////////////////////////////////////////// -// Function: DCField:: -// Access: Published -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ INLINE void DCField:: write(ostream &out, int indent_level) const { write(out, false, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::set_number -// Access: Public -// Description: Assigns the unique number to this field. This is -// normally called only by the DCClass interface as the -// field is added. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the unique number to this field. This is normally called only by + * the DCClass interface as the field is added. + */ INLINE void DCField:: set_number(int number) { _number = number; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::set_class -// Access: Public -// Description: Assigns the class pointer to this field. This is -// normally called only by the DCClass interface as the -// field is added. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the class pointer to this field. This is normally called only by + * the DCClass interface as the field is added. + */ INLINE void DCField:: set_class(DCClass *dclass) { _dclass = dclass; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::set_default_value -// Access: Public -// Description: Establishes a default value for this field. -//////////////////////////////////////////////////////////////////// +/** + * Establishes a default value for this field. + */ INLINE void DCField:: set_default_value(const string &default_value) { _default_value = default_value; diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 59701a6df2..88b9786f51 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -1,16 +1,15 @@ -// Filename: dcField.cxx -// Created by: drose (11Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcField.cxx + * @author drose + * @date 2000-10-11 + */ #include "dcField.h" #include "dcFile.h" @@ -27,13 +26,11 @@ #include "pStatTimer.h" #endif -//////////////////////////////////////////////////////////////////// -// Function: DCField::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCField:: -DCField() : +DCField() : _dclass(NULL) #ifdef WITHIN_PANDA , @@ -55,13 +52,11 @@ DCField() : _has_fixed_structure = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCField:: -DCField(const string &name, DCClass *dclass) : +DCField(const string &name, DCClass *dclass) : DCPackerInterface(name), _dclass(dclass) #ifdef WITHIN_PANDA @@ -84,110 +79,86 @@ DCField(const string &name, DCClass *dclass) : _has_fixed_structure = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCField:: ~DCField() { } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_field -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCField *DCField:: as_field() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_field -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCField *DCField:: as_field() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_atomic_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to an atomic -// field pointer, if this is in fact an atomic field; -// otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to an atomic field pointer, if + * this is in fact an atomic field; otherwise, returns NULL. + */ DCAtomicField *DCField:: as_atomic_field() { return (DCAtomicField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_atomic_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to an atomic -// field pointer, if this is in fact an atomic field; -// otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to an atomic field pointer, if + * this is in fact an atomic field; otherwise, returns NULL. + */ const DCAtomicField *DCField:: as_atomic_field() const { return (DCAtomicField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_molecular_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to a -// molecular field pointer, if this is in fact a -// molecular field; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to a molecular field pointer, if + * this is in fact a molecular field; otherwise, returns NULL. + */ DCMolecularField *DCField:: as_molecular_field() { return (DCMolecularField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_molecular_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to a -// molecular field pointer, if this is in fact a -// molecular field; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to a molecular field pointer, if + * this is in fact a molecular field; otherwise, returns NULL. + */ const DCMolecularField *DCField:: as_molecular_field() const { return (DCMolecularField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCField:: as_parameter() { return (DCParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::as_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCParameter *DCField:: as_parameter() const { return (DCParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::format_data -// Access: Published -// Description: Given a blob that represents the packed data for this -// field, returns a string formatting it for human -// consumption. Returns empty string if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Given a blob that represents the packed data for this field, returns a + * string formatting it for human consumption. Returns empty string if there + * is an error. + */ string DCField:: format_data(const string &packed_data, bool show_field_names) { DCPacker packer; @@ -200,15 +171,11 @@ format_data(const string &packed_data, bool show_field_names) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::parse_string -// Access: Published -// Description: Given a human-formatted string (for instance, as -// returned by format_data(), above) that represents the -// value of this field, parse the string and return the -// corresponding packed data. Returns empty string if -// there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Given a human-formatted string (for instance, as returned by format_data(), + * above) that represents the value of this field, parse the string and return + * the corresponding packed data. Returns empty string if there is an error. + */ string DCField:: parse_string(const string &formatted_string) { DCPacker packer; @@ -225,14 +192,11 @@ parse_string(const string &formatted_string) { return packer.get_string(); } -//////////////////////////////////////////////////////////////////// -// Function: DCField::validate_ranges -// Access: Published -// Description: Verifies that all of the packed values in the field -// data are within the specified ranges and that there -// are no extra bytes on the end of the record. Returns -// true if all fields are valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that all of the packed values in the field data are within the + * specified ranges and that there are no extra bytes on the end of the + * record. Returns true if all fields are valid, false otherwise. + */ bool DCField:: validate_ranges(const string &packed_data) const { DCPacker packer; @@ -247,16 +211,12 @@ validate_ranges(const string &packed_data) const { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::pack_args -// Access: Published -// Description: Packs the Python arguments from the indicated tuple -// into the packer. Returns true on success, false on -// failure. -// -// It is assumed that the packer is currently positioned -// on this field. -//////////////////////////////////////////////////////////////////// +/** + * Packs the Python arguments from the indicated tuple into the packer. + * Returns true on success, false on failure. + * + * It is assumed that the packer is currently positioned on this field. + */ bool DCField:: pack_args(DCPacker &packer, PyObject *sequence) const { nassertr(!packer.had_error(), false); @@ -289,8 +249,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { } } else { - // If it's a molecular or atomic field, the value should be a - // sequence. + // If it's a molecular or atomic field, the value should be a sequence. PyObject *tuple = PySequence_Tuple(sequence); if (tuple == (PyObject *)NULL) { strm << "Value for " << get_name() << " not a sequence: " \ @@ -307,7 +266,7 @@ pack_args(DCPacker &packer, PyObject *sequence) const { << get_pystr(sequence); exc_type = PyExc_ValueError; } - + Py_DECREF(tuple); } } @@ -320,16 +279,12 @@ pack_args(DCPacker &packer, PyObject *sequence) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::unpack_args -// Access: Published -// Description: Unpacks the values from the packer, beginning at -// the current point in the unpack_buffer, into a Python -// tuple and returns the tuple. -// -// It is assumed that the packer is currently positioned -// on this field. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the values from the packer, beginning at the current point in the + * unpack_buffer, into a Python tuple and returns the tuple. + * + * It is assumed that the packer is currently positioned on this field. + */ PyObject *DCField:: unpack_args(DCPacker &packer) const { nassertr(!packer.had_error(), NULL); @@ -364,11 +319,11 @@ unpack_args(DCPacker &packer) const { exc_type = PyExc_RuntimeError; } else { - strm << "Value outside specified range when unpacking field " + strm << "Value outside specified range when unpacking field " << get_name() << ": " << get_pystr(object); exc_type = PyExc_ValueError; } - + string message = strm.str(); PyErr_SetString(exc_type, message.c_str()); } @@ -379,18 +334,14 @@ unpack_args(DCPacker &packer) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::receive_update -// Access: Published -// Description: Extracts the update message out of the datagram and -// applies it to the indicated object by calling the -// appropriate method. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the update message out of the datagram and applies it to the + * indicated object by calling the appropriate method. + */ void DCField:: receive_update(DCPacker &packer, PyObject *distobj) const { if (as_parameter() != (DCParameter *)NULL) { - // If it's a parameter-type field, just store a new value on the - // object. + // If it's a parameter-type field, just store a new value on the object. PyObject *value = unpack_args(packer); if (value != (PyObject *)NULL) { PyObject_SetAttrString(distobj, (char *)_name.c_str(), value); @@ -402,9 +353,8 @@ receive_update(DCPacker &packer, PyObject *distobj) const { // corresponding method. if (!PyObject_HasAttrString(distobj, (char *)_name.c_str())) { - // If there's no Python method to receive this message, don't - // bother unpacking it to a Python tuple--just skip past the - // message. + // If there's no Python method to receive this message, don't bother + // unpacking it to a Python tuple--just skip past the message. packer.unpack_skip(); } else { @@ -415,7 +365,7 @@ receive_update(DCPacker &packer, PyObject *distobj) const { if (args != (PyObject *)NULL) { PyObject *func = PyObject_GetAttrString(distobj, (char *)_name.c_str()); nassertv(func != (PyObject *)NULL); - + PyObject *result; { #ifdef WITHIN_PANDA @@ -433,13 +383,10 @@ receive_update(DCPacker &packer, PyObject *distobj) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::client_format_update -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update for the indicated distributed -// object from the client. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update for + * the indicated distributed object from the client. + */ Datagram DCField:: client_format_update(DOID_TYPE do_id, PyObject *args) const { DCPacker packer; @@ -459,13 +406,10 @@ client_format_update(DOID_TYPE do_id, PyObject *args) const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::ai_format_update -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update for the indicated distributed -// object from the AI. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update for + * the indicated distributed object from the AI. + */ Datagram DCField:: ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyObject *args) const { DCPacker packer; @@ -488,14 +432,10 @@ ai_format_update(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, PyOb #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::ai_format_update_msg_type -// Access: Published -// Description: Generates a datagram containing the message necessary -// to send an update, with the msg type, -// for the indicated distributed -// object from the AI. -//////////////////////////////////////////////////////////////////// +/** + * Generates a datagram containing the message necessary to send an update, + * with the msg type, for the indicated distributed object from the AI. + */ Datagram DCField:: ai_format_update_msg_type(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const { DCPacker packer; @@ -518,41 +458,33 @@ ai_format_update_msg_type(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this field into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this field into the hash. + */ void DCField:: generate_hash(HashGenerator &hashgen) const { - // It shouldn't be necessary to explicitly add _number to the - // hash--this is computed based on the relative position of this - // field with the other fields, so adding it explicitly will be - // redundant. However, the field name is significant. + // It shouldn't be necessary to explicitly add _number to the hash--this is + // computed based on the relative position of this field with the other + // fields, so adding it explicitly will be redundant. However, the field + // name is significant. hashgen.add_string(_name); - // Actually, we add _number anyway, since we need to ensure the hash - // code comes out different in the dc_multiple_inheritance case. + // Actually, we add _number anyway, since we need to ensure the hash code + // comes out different in the dc_multiple_inheritance case. if (dc_multiple_inheritance) { hashgen.add_int(_number); } } -//////////////////////////////////////////////////////////////////// -// Function: DCField::pack_default_value -// Access: Public, Virtual -// Description: Packs the field's specified default value (or a -// sensible default if no value is specified) into the -// stream. Returns true if the default value is packed, -// false if the field doesn't know how to pack its -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the field's specified default value (or a sensible default if no + * value is specified) into the stream. Returns true if the default value is + * packed, false if the field doesn't know how to pack its default value. + */ bool DCField:: pack_default_value(DCPackData &pack_data, bool &) const { // The default behavior is to pack the default value if we got it; - // otherwise, to return false and let the packer visit our nested - // elements. + // otherwise, to return false and let the packer visit our nested elements. if (!_default_value_stale) { pack_data.append_data(_default_value.data(), _default_value.length()); return true; @@ -561,11 +493,9 @@ pack_default_value(DCPackData &pack_data, bool &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCField::set_name -// Access: Public, Virtual -// Description: Sets the name of this field. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of this field. + */ void DCField:: set_name(const string &name) { DCPackerInterface::set_name(name); @@ -575,12 +505,9 @@ set_name(const string &name) { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::get_pystr -// Access: Public, Static -// Description: Returns the string representation of the indicated -// Python object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string representation of the indicated Python object. + */ string DCField:: get_pystr(PyObject *value) { if (value == NULL) { @@ -626,12 +553,9 @@ get_pystr(PyObject *value) { } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCField::refresh_default_value -// Access: Protected -// Description: Recomputes the default value of the field by -// repacking it. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the default value of the field by repacking it. + */ void DCField:: refresh_default_value() { DCPacker packer; diff --git a/direct/src/dcparser/dcField.h b/direct/src/dcparser/dcField.h index 59717ad71b..2bf2b5e840 100644 --- a/direct/src/dcparser/dcField.h +++ b/direct/src/dcparser/dcField.h @@ -1,16 +1,15 @@ -// Filename: dcField.h -// Created by: drose (11Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcField.h + * @author drose + * @date 2000-10-11 + */ #ifndef DCFIELD_H #define DCFIELD_H @@ -32,11 +31,9 @@ class DCSwitch; class DCClass; class HashGenerator; -//////////////////////////////////////////////////////////////////// -// Class : DCField -// Description : A single field of a Distributed Class, either atomic -// or molecular. -//////////////////////////////////////////////////////////////////// +/** + * A single field of a Distributed Class, either atomic or molecular. + */ class EXPCL_DIRECT DCField : public DCPackerInterface, public DCKeywordList { public: DCField(); @@ -90,7 +87,7 @@ PUBLISHED: PyObject *args) const; Datagram ai_format_update_msg_type(DOID_TYPE do_id, CHANNEL_TYPE to_id, CHANNEL_TYPE from_id, int msg_type, PyObject *args) const; -#endif +#endif public: virtual void output(ostream &out, bool brief) const=0; diff --git a/direct/src/dcparser/dcFile.I b/direct/src/dcparser/dcFile.I index 1d366dbcce..e5297e4e64 100644 --- a/direct/src/dcparser/dcFile.I +++ b/direct/src/dcparser/dcFile.I @@ -1,37 +1,29 @@ -// Filename: dcFile.I -// Created by: drose (10Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcFile.I + * @author drose + * @date 2006-01-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCFile::all_objects_valid -// Access: Published -// Description: Returns true if all of the classes read from the DC -// file were defined and valid, or false if any of them -// were undefined ("bogus classes"). If this is true, -// we might have read a partial file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the classes read from the DC file were defined and + * valid, or false if any of them were undefined ("bogus classes"). If this + * is true, we might have read a partial file. + */ INLINE bool DCFile:: all_objects_valid() const { return _all_objects_valid; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::check_inherited_fields -// Access: Public -// Description: Rebuilds all of the inherited fields tables, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds all of the inherited fields tables, if necessary. + */ INLINE void DCFile:: check_inherited_fields() { if (_inherited_fields_stale) { @@ -39,15 +31,11 @@ check_inherited_fields() { } } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::mark_inherited_fields_stale -// Access: Public -// Description: Indicates that something has changed in one or more -// of the inheritance chains or the set of fields; the -// next time check_inherited_fields() is called, the -// inherited fields tables of all classes will be -// rebuilt. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that something has changed in one or more of the inheritance + * chains or the set of fields; the next time check_inherited_fields() is + * called, the inherited fields tables of all classes will be rebuilt. + */ INLINE void DCFile:: mark_inherited_fields_stale() { _inherited_fields_stale = true; diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 2fca478b7c..9dc7009dca 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -1,16 +1,15 @@ -// Filename: dcFile.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcFile.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcFile.h" #include "dcClass.h" @@ -30,11 +29,9 @@ #endif -//////////////////////////////////////////////////////////////////// -// Function: DCFile::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCFile:: DCFile() { _all_objects_valid = true; @@ -43,22 +40,18 @@ DCFile() { setup_default_keywords(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCFile:: ~DCFile() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::clear -// Access: Published -// Description: Removes all of the classes defined within the DCFile -// and prepares it for reading a new file. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the classes defined within the DCFile and prepares it for + * reading a new file. + */ void DCFile:: clear() { Declarations::iterator di; @@ -68,7 +61,7 @@ clear() { for (di = _things_to_delete.begin(); di != _things_to_delete.end(); ++di) { delete (*di); } - + _classes.clear(); _imports.clear(); _things_by_name.clear(); @@ -85,13 +78,10 @@ clear() { #ifdef WITHIN_PANDA -//////////////////////////////////////////////////////////////////// -// Function: DCFile::read_all -// Access: Published -// Description: This special method reads all of the .dc files named -// by the "dc-file" config.prc variable, and loads them -// into the DCFile namespace. -//////////////////////////////////////////////////////////////////// +/** + * This special method reads all of the .dc files named by the "dc-file" + * config.prc variable, and loads them into the DCFile namespace. + */ bool DCFile:: read_all() { static ConfigVariableList dc_files @@ -104,8 +94,8 @@ read_all() { int size = dc_files.size(); - // Load the DC files in opposite order, because we want to load the - // least-important (most fundamental) files first. + // Load the DC files in opposite order, because we want to load the least- + // important (most fundamental) files first. for (int i = size - 1; i >= 0; --i) { string dc_file = ExecutionEnvironment::expand_string(dc_files[i]); Filename filename = Filename::from_os_specific(dc_file); @@ -119,18 +109,14 @@ read_all() { #endif // WITHIN_PANDA -//////////////////////////////////////////////////////////////////// -// Function: DCFile::read -// Access: Published -// Description: Opens and reads the indicated .dc file by name. The -// distributed classes defined in the file will be -// appended to the set of distributed classes already -// recorded, if any. -// -// Returns true if the file is successfully read, false -// if there was an error (in which case the file might -// have been partially read). -//////////////////////////////////////////////////////////////////// +/** + * Opens and reads the indicated .dc file by name. The distributed classes + * defined in the file will be appended to the set of distributed classes + * already recorded, if any. + * + * Returns true if the file is successfully read, false if there was an error + * (in which case the file might have been partially read). + */ bool DCFile:: read(Filename filename) { #ifdef WITHIN_PANDA @@ -142,13 +128,13 @@ read(Filename filename) { return false; } bool okflag = read(*in, filename); - - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the in pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the in + // pointer does not call the appropriate global delete function; instead + // apparently calling the system delete function. So we call the delete + // function by hand instead. vfs->close_read_file(in); - + return okflag; #else // WITHIN_PANDA @@ -166,22 +152,16 @@ read(Filename filename) { #endif // WITHIN_PANDA } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::read -// Access: Published -// Description: Parses the already-opened input stream for -// distributed class descriptions. The filename -// parameter is optional and is only used when reporting -// errors. -// -// The distributed classes defined in the file will be -// appended to the set of distributed classes already -// recorded, if any. -// -// Returns true if the file is successfully read, false -// if there was an error (in which case the file might -// have been partially read). -//////////////////////////////////////////////////////////////////// +/** + * Parses the already-opened input stream for distributed class descriptions. + * The filename parameter is optional and is only used when reporting errors. + * + * The distributed classes defined in the file will be appended to the set of + * distributed classes already recorded, if any. + * + * Returns true if the file is successfully read, false if there was an error + * (in which case the file might have been partially read). + */ bool DCFile:: read(istream &in, const string &filename) { cerr << "DCFile::read of " << filename << "\n"; @@ -192,16 +172,12 @@ read(istream &in, const string &filename) { return (dc_error_count() == 0); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::write -// Access: Published -// Description: Opens the indicated filename for output and writes a -// parseable description of all the known distributed -// classes to the file. -// -// Returns true if the description is successfully -// written, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for output and writes a parseable description + * of all the known distributed classes to the file. + * + * Returns true if the description is successfully written, false otherwise. + */ bool DCFile:: write(Filename filename, bool brief) const { pofstream out; @@ -220,15 +196,12 @@ write(Filename filename, bool brief) const { return write(out, brief); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::write -// Access: Published -// Description: Writes a parseable description of all the known -// distributed classes to the stream. -// -// Returns true if the description is successfully -// written, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes a parseable description of all the known distributed classes to the + * stream. + * + * Returns true if the description is successfully written, false otherwise. + */ bool DCFile:: write(ostream &out, bool brief) const { if (!_imports.empty()) { @@ -261,34 +234,27 @@ write(ostream &out, bool brief) const { return !out.fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_num_classes -// Access: Published -// Description: Returns the number of classes read from the .dc -// file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of classes read from the .dc file(s). + */ int DCFile:: get_num_classes() const { return _classes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_class -// Access: Published -// Description: Returns the nth class read from the .dc file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth class read from the .dc file(s). + */ DCClass *DCFile:: get_class(int n) const { nassertr(n >= 0 && n < (int)_classes.size(), NULL); return _classes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_class_by_name -// Access: Published -// Description: Returns the class that has the indicated name, or -// NULL if there is no such class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the class that has the indicated name, or NULL if there is no such + * class. + */ DCClass *DCFile:: get_class_by_name(const string &name) const { ThingsByName::const_iterator ni; @@ -300,12 +266,10 @@ get_class_by_name(const string &name) const { return (DCClass *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_switch_by_name -// Access: Published -// Description: Returns the switch that has the indicated name, or -// NULL if there is no such switch. -//////////////////////////////////////////////////////////////////// +/** + * Returns the switch that has the indicated name, or NULL if there is no such + * switch. + */ DCSwitch *DCFile:: get_switch_by_name(const string &name) const { ThingsByName::const_iterator ni; @@ -317,18 +281,14 @@ get_switch_by_name(const string &name) const { return (DCSwitch *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_field_by_index -// Access: Published, Static -// Description: Returns a pointer to the one DCField that has the -// indicated index number, of all the DCFields across -// all classes in the file. -// -// This method is only valid if dc-multiple-inheritance -// is set true in the Config.prc file. Without this -// setting, different DCFields may share the same index -// number, so this global lookup is not possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the one DCField that has the indicated index number, + * of all the DCFields across all classes in the file. + * + * This method is only valid if dc-multiple-inheritance is set true in the + * Config.prc file. Without this setting, different DCFields may share the + * same index number, so this global lookup is not possible. + */ DCField *DCFile:: get_field_by_index(int index_number) const { nassertr(dc_multiple_inheritance, NULL); @@ -336,53 +296,42 @@ get_field_by_index(int index_number) const { if (index_number >= 0 && index_number < (int)_fields_by_index.size()) { return _fields_by_index[index_number]; } - + return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_num_import_modules -// Access: Published -// Description: Returns the number of import lines read from the .dc -// file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of import lines read from the .dc file(s). + */ int DCFile:: get_num_import_modules() const { return _imports.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_import_module -// Access: Published -// Description: Returns the module named by the nth import line read -// from the .dc file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the module named by the nth import line read from the .dc file(s). + */ string DCFile:: get_import_module(int n) const { nassertr(n >= 0 && n < (int)_imports.size(), string()); return _imports[n]._module; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_num_import_symbols -// Access: Published -// Description: Returns the number of symbols explicitly imported by -// the nth import line. If this is 0, the line is -// "import modulename"; if it is more than 0, the line -// is "from modulename import symbol, symbol ... ". -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of symbols explicitly imported by the nth import line. + * If this is 0, the line is "import modulename"; if it is more than 0, the + * line is "from modulename import symbol, symbol ... ". + */ int DCFile:: get_num_import_symbols(int n) const { nassertr(n >= 0 && n < (int)_imports.size(), 0); return _imports[n]._symbols.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_import_symbol -// Access: Published -// Description: Returns the ith symbol named by the nth import line -// read from the .dc file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith symbol named by the nth import line read from the .dc + * file(s). + */ string DCFile:: get_import_symbol(int n, int i) const { nassertr(n >= 0 && n < (int)_imports.size(), string()); @@ -390,34 +339,27 @@ get_import_symbol(int n, int i) const { return _imports[n]._symbols[i]; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_num_typedefs -// Access: Published -// Description: Returns the number of typedefs read from the .dc -// file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of typedefs read from the .dc file(s). + */ int DCFile:: get_num_typedefs() const { return _typedefs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_typedef -// Access: Published -// Description: Returns the nth typedef read from the .dc file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth typedef read from the .dc file(s). + */ DCTypedef *DCFile:: get_typedef(int n) const { nassertr(n >= 0 && n < (int)_typedefs.size(), NULL); return _typedefs[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_typedef_by_name -// Access: Published -// Description: Returns the typedef that has the indicated name, or -// NULL if there is no such typedef name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the typedef that has the indicated name, or NULL if there is no + * such typedef name. + */ DCTypedef *DCFile:: get_typedef_by_name(const string &name) const { TypedefsByName::const_iterator ni; @@ -429,41 +371,34 @@ get_typedef_by_name(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_num_keywords -// Access: Published -// Description: Returns the number of keywords read from the .dc -// file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of keywords read from the .dc file(s). + */ int DCFile:: get_num_keywords() const { return _keywords.get_num_keywords(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_keyword -// Access: Published -// Description: Returns the nth keyword read from the .dc file(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth keyword read from the .dc file(s). + */ const DCKeyword *DCFile:: get_keyword(int n) const { return _keywords.get_keyword(n); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_keyword_by_name -// Access: Published -// Description: Returns the keyword that has the indicated name, or -// NULL if there is no such keyword name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the keyword that has the indicated name, or NULL if there is no + * such keyword name. + */ const DCKeyword *DCFile:: get_keyword_by_name(const string &name) const { const DCKeyword *keyword = _keywords.get_keyword_by_name(name); if (keyword == (const DCKeyword *)NULL) { keyword = _default_keywords.get_keyword_by_name(name); if (keyword != (const DCKeyword *)NULL) { - // One of the historical default keywords was used, but wasn't - // defined. Define it implicitly right now. + // One of the historical default keywords was used, but wasn't defined. + // Define it implicitly right now. ((DCFile *)this)->_keywords.add_keyword(keyword); } } @@ -471,15 +406,12 @@ get_keyword_by_name(const string &name) const { return keyword; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::get_hash -// Access: Published -// Description: Returns a 32-bit hash index associated with this -// file. This number is guaranteed to be consistent if -// the contents of the file have not changed, and it is -// very likely to be different if the contents of the -// file do change. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 32-bit hash index associated with this file. This number is + * guaranteed to be consistent if the contents of the file have not changed, + * and it is very likely to be different if the contents of the file do + * change. + */ unsigned long DCFile:: get_hash() const { HashGenerator hashgen; @@ -487,12 +419,9 @@ get_hash() const { return hashgen.get_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this file into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this file into the hash. + */ void DCFile:: generate_hash(HashGenerator &hashgen) const { if (dc_virtual_inheritance) { @@ -511,21 +440,18 @@ generate_hash(HashGenerator &hashgen) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_class -// Access: Public -// Description: Adds the newly-allocated distributed class definition -// to the file. The DCFile becomes the owner of the -// pointer and will delete it when it destructs. -// Returns true if the class is successfully added, or -// false if there was a name conflict. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-allocated distributed class definition to the file. The + * DCFile becomes the owner of the pointer and will delete it when it + * destructs. Returns true if the class is successfully added, or false if + * there was a name conflict. + */ bool DCFile:: add_class(DCClass *dclass) { if (!dclass->get_name().empty()) { bool inserted = _things_by_name.insert (ThingsByName::value_type(dclass->get_name(), dclass)).second; - + if (!inserted) { return false; } @@ -549,21 +475,18 @@ add_class(DCClass *dclass) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_switch -// Access: Public -// Description: Adds the newly-allocated switch definition -// to the file. The DCFile becomes the owner of the -// pointer and will delete it when it destructs. -// Returns true if the switch is successfully added, or -// false if there was a name conflict. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-allocated switch definition to the file. The DCFile becomes + * the owner of the pointer and will delete it when it destructs. Returns + * true if the switch is successfully added, or false if there was a name + * conflict. + */ bool DCFile:: add_switch(DCSwitch *dswitch) { if (!dswitch->get_name().empty()) { bool inserted = _things_by_name.insert (ThingsByName::value_type(dswitch->get_name(), dswitch)).second; - + if (!inserted) { return false; } @@ -574,14 +497,11 @@ add_switch(DCSwitch *dswitch) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_import_module -// Access: Public -// Description: Adds a new name to the list of names of Python -// modules that are to be imported by the client or AI -// to define the code that is associated with the class -// interfaces named within the .dc file. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new name to the list of names of Python modules that are to be + * imported by the client or AI to define the code that is associated with the + * class interfaces named within the .dc file. + */ void DCFile:: add_import_module(const string &import_module) { Import import; @@ -589,30 +509,24 @@ add_import_module(const string &import_module) { _imports.push_back(import); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_import_symbol -// Access: Public -// Description: Adds a new name to the list of symbols that are to be -// explicitly imported from the most-recently added -// module, e.g. "from module_name import symbol". If -// the list of symbols is empty, the syntax is taken to -// be "import module_name". -//////////////////////////////////////////////////////////////////// +/** + * Adds a new name to the list of symbols that are to be explicitly imported + * from the most-recently added module, e.g. "from module_name import + * symbol". If the list of symbols is empty, the syntax is taken to be + * "import module_name". + */ void DCFile:: add_import_symbol(const string &import_symbol) { nassertv(!_imports.empty()); _imports.back()._symbols.push_back(import_symbol); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_typedef -// Access: Public -// Description: Adds the newly-allocated distributed typedef definition -// to the file. The DCFile becomes the owner of the -// pointer and will delete it when it destructs. -// Returns true if the typedef is successfully added, or -// false if there was a name conflict. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-allocated distributed typedef definition to the file. The + * DCFile becomes the owner of the pointer and will delete it when it + * destructs. Returns true if the typedef is successfully added, or false if + * there was a name conflict. + */ bool DCFile:: add_typedef(DCTypedef *dtypedef) { bool inserted = _typedefs_by_name.insert @@ -638,14 +552,11 @@ add_typedef(DCTypedef *dtypedef) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_keyword -// Access: Public -// Description: Adds the indicated keyword string to the list of -// keywords known to the DCFile. These keywords may -// then be added to DCFields. It is not an error to add -// a particular keyword more than once. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated keyword string to the list of keywords known to the + * DCFile. These keywords may then be added to DCFields. It is not an error + * to add a particular keyword more than once. + */ bool DCFile:: add_keyword(const string &name) { DCKeyword *keyword = new DCKeyword(name); @@ -660,40 +571,31 @@ add_keyword(const string &name) { return added; } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::add_thing_to_delete -// Access: Public -// Description: Adds the indicated declaration to the list of -// declarations that are not reported with the file, but -// will be deleted when the DCFile object destructs. -// That is, transfers ownership of the indicated pointer -// to the DCFile. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated declaration to the list of declarations that are not + * reported with the file, but will be deleted when the DCFile object + * destructs. That is, transfers ownership of the indicated pointer to the + * DCFile. + */ void DCFile:: add_thing_to_delete(DCDeclaration *decl) { _things_to_delete.push_back(decl); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::set_new_index_number -// Access: Public -// Description: Sets the next sequential available index number on -// the indicated field. This is only meant to be called -// by DCClass::add_field(), while the dc file is being -// parsed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the next sequential available index number on the indicated field. + * This is only meant to be called + */ void DCFile:: set_new_index_number(DCField *field) { field->set_number((int)_fields_by_index.size()); _fields_by_index.push_back(field); } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::setup_default_keywords -// Access: Private -// Description: Adds an entry for each of the default keywords that -// are defined for every DCFile for legacy reasons. -//////////////////////////////////////////////////////////////////// +/** + * Adds an entry for each of the default keywords that are defined for every + * DCFile for legacy reasons. + */ void DCFile:: setup_default_keywords() { struct KeywordDef { @@ -715,21 +617,18 @@ setup_default_keywords() { _default_keywords.clear_keywords(); for (int i = 0; default_keywords[i].name != NULL; ++i) { - DCKeyword *keyword = - new DCKeyword(default_keywords[i].name, + DCKeyword *keyword = + new DCKeyword(default_keywords[i].name, default_keywords[i].flag); - + _default_keywords.add_keyword(keyword); _things_to_delete.push_back(keyword); } } -//////////////////////////////////////////////////////////////////// -// Function: DCFile::rebuild_inherited_fields -// Access: Private -// Description: Reconstructs the inherited fields table of all -// classes. -//////////////////////////////////////////////////////////////////// +/** + * Reconstructs the inherited fields table of all classes. + */ void DCFile:: rebuild_inherited_fields() { _inherited_fields_stale = false; diff --git a/direct/src/dcparser/dcFile.h b/direct/src/dcparser/dcFile.h index 8ea671faba..ec3f431aa7 100644 --- a/direct/src/dcparser/dcFile.h +++ b/direct/src/dcparser/dcFile.h @@ -1,16 +1,15 @@ -// Filename: dcFile.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcFile.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCFILE_H #define DCFILE_H @@ -26,11 +25,10 @@ class DCTypedef; class DCKeyword; class DCDeclaration; -//////////////////////////////////////////////////////////////////// -// Class : DCFile -// Description : Represents the complete list of Distributed Class -// descriptions as read from a .dc file. -//////////////////////////////////////////////////////////////////// +/** + * Represents the complete list of Distributed Class descriptions as read from + * a .dc file. + */ class EXPCL_DIRECT DCFile { PUBLISHED: DCFile(); @@ -129,5 +127,3 @@ private: #include "dcFile.I" #endif - - diff --git a/direct/src/dcparser/dcKeyword.cxx b/direct/src/dcparser/dcKeyword.cxx index 1c5ecb83af..17dcab8df2 100644 --- a/direct/src/dcparser/dcKeyword.cxx +++ b/direct/src/dcparser/dcKeyword.cxx @@ -1,26 +1,23 @@ -// Filename: dcKeyword.cxx -// Created by: drose (22Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcKeyword.cxx + * @author drose + * @date 2005-07-22 + */ #include "dcKeyword.h" #include "hashGenerator.h" #include "dcindent.h" -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCKeyword:: DCKeyword(const string &name, int historical_flag) : _name(name), @@ -28,79 +25,61 @@ DCKeyword(const string &name, int historical_flag) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCKeyword:: ~DCKeyword() { } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::get_name -// Access: Published -// Description: Returns the name of this keyword. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this keyword. + */ const string &DCKeyword:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::get_historical_flag -// Access: Public -// Description: Returns the bitmask associated with this keyword, if -// any. This is the value that was historically -// associated with this keyword, and was used to -// generate a hash code before we had user-customizable -// keywords. It will return ~0 if this is not an -// historical keyword. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bitmask associated with this keyword, if any. This is the + * value that was historically associated with this keyword, and was used to + * generate a hash code before we had user-customizable keywords. It will + * return ~0 if this is not an historical keyword. + */ int DCKeyword:: get_historical_flag() const { return _historical_flag; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::clear_historical_flag -// Access: Public -// Description: Resets the historical flag to ~0, as if the keyword -// were not one of the historically defined keywords. -//////////////////////////////////////////////////////////////////// +/** + * Resets the historical flag to ~0, as if the keyword were not one of the + * historically defined keywords. + */ void DCKeyword:: clear_historical_flag() { _historical_flag = ~0; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::output -// Access: Public, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCKeyword:: output(ostream &out, bool brief) const { out << "keyword " << _name; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCKeyword:: write(ostream &out, bool, int indent_level) const { indent(out, indent_level) << "keyword " << _name << ";\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeyword::generate_hash -// Access: Public -// Description: Accumulates the properties of this keyword into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this keyword into the hash. + */ void DCKeyword:: generate_hash(HashGenerator &hashgen) const { hashgen.add_string(_name); diff --git a/direct/src/dcparser/dcKeyword.h b/direct/src/dcparser/dcKeyword.h index 32c8a0dd24..aa074c6f37 100644 --- a/direct/src/dcparser/dcKeyword.h +++ b/direct/src/dcparser/dcKeyword.h @@ -1,16 +1,15 @@ -// Filename: dcKeyword.h -// Created by: drose (22Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcKeyword.h + * @author drose + * @date 2005-07-22 + */ #ifndef DCKEYWORD_H #define DCKEYWORD_H @@ -21,13 +20,11 @@ class DCParameter; class HashGenerator; -//////////////////////////////////////////////////////////////////// -// Class : DCKeyword -// Description : This represents a single keyword declaration in the -// dc file. It is used to define a communication -// property associated with a field, for instance -// "broadcast" or "airecv". -//////////////////////////////////////////////////////////////////// +/** + * This represents a single keyword declaration in the dc file. It is used to + * define a communication property associated with a field, for instance + * "broadcast" or "airecv". + */ class EXPCL_DIRECT DCKeyword : public DCDeclaration { public: DCKeyword(const string &name, int historical_flag = ~0); @@ -47,8 +44,8 @@ public: private: const string _name; - // This flag is only kept for historical reasons, so we can preserve - // the file's hash code if no new flags are in use. + // This flag is only kept for historical reasons, so we can preserve the + // file's hash code if no new flags are in use. int _historical_flag; }; diff --git a/direct/src/dcparser/dcKeywordList.cxx b/direct/src/dcparser/dcKeywordList.cxx index f45884567b..d3f2d0347e 100644 --- a/direct/src/dcparser/dcKeywordList.cxx +++ b/direct/src/dcparser/dcKeywordList.cxx @@ -1,37 +1,32 @@ -// Filename: dcKeywordList.cxx -// Created by: drose (25Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcKeywordList.cxx + * @author drose + * @date 2005-07-25 + */ #include "dcKeywordList.h" #include "dcKeyword.h" #include "hashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCKeywordList:: DCKeywordList() : _flags(0) { } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCKeywordList:: DCKeywordList(const DCKeywordList ©) : _keywords(copy._keywords), @@ -40,11 +35,9 @@ DCKeywordList(const DCKeywordList ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCKeywordList:: operator = (const DCKeywordList ©) { _keywords = copy._keywords; @@ -52,67 +45,52 @@ operator = (const DCKeywordList ©) { _flags = copy._flags; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCKeywordList:: ~DCKeywordList() { nassertv(_keywords_by_name.size() == _keywords.size()); } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::has_keyword -// Access: Published -// Description: Returns true if this list includes the indicated -// keyword, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this list includes the indicated keyword, false otherwise. + */ bool DCKeywordList:: has_keyword(const string &name) const { return (_keywords_by_name.find(name) != _keywords_by_name.end()); } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::has_keyword -// Access: Published -// Description: Returns true if this list includes the indicated -// keyword, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this list includes the indicated keyword, false otherwise. + */ bool DCKeywordList:: has_keyword(const DCKeyword *keyword) const { return has_keyword(keyword->get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::get_num_keywords -// Access: Published -// Description: Returns the number of keywords in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of keywords in the list. + */ int DCKeywordList:: get_num_keywords() const { nassertr(_keywords_by_name.size() == _keywords.size(), 0); return _keywords.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::get_keyword -// Access: Published -// Description: Returns the nth keyword in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth keyword in the list. + */ const DCKeyword *DCKeywordList:: get_keyword(int n) const { nassertr(n >= 0 && n < (int)_keywords.size(), NULL); return _keywords[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::get_keyword_by_name -// Access: Published -// Description: Returns the keyword in the list with the indicated -// name, or NULL if there is no keyword in the list with -// that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the keyword in the list with the indicated name, or NULL if there + * is no keyword in the list with that name. + */ const DCKeyword *DCKeywordList:: get_keyword_by_name(const string &name) const { KeywordsByName::const_iterator ni; @@ -124,35 +102,27 @@ get_keyword_by_name(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::compare_keywords -// Access: Published -// Description: Returns true if this list has the same keywords -// as the other list, false if some keywords differ. -// Order is not considered important. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this list has the same keywords as the other list, false if + * some keywords differ. Order is not considered important. + */ bool DCKeywordList:: compare_keywords(const DCKeywordList &other) const { return _keywords_by_name == other._keywords_by_name; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::copy_keywords -// Access: Public -// Description: Replaces this keyword list with those from the other -// list. -//////////////////////////////////////////////////////////////////// +/** + * Replaces this keyword list with those from the other list. + */ void DCKeywordList:: copy_keywords(const DCKeywordList &other) { (*this) = other; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::add_keyword -// Access: Public -// Description: Adds the indicated keyword to the list. Returns true -// if it is added, false if it was already there. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated keyword to the list. Returns true if it is added, false + * if it was already there. + */ bool DCKeywordList:: add_keyword(const DCKeyword *keyword) { bool inserted = _keywords_by_name.insert(KeywordsByName::value_type(keyword->get_name(), keyword)).second; @@ -164,11 +134,9 @@ add_keyword(const DCKeyword *keyword) { return inserted; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::clear_keywords -// Access: Public -// Description: Removes all keywords from the field. -//////////////////////////////////////////////////////////////////// +/** + * Removes all keywords from the field. + */ void DCKeywordList:: clear_keywords() { _keywords.clear(); @@ -176,11 +144,9 @@ clear_keywords() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::output_keywords -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCKeywordList:: output_keywords(ostream &out) const { Keywords::const_iterator ki; @@ -189,23 +155,19 @@ output_keywords(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCKeywordList::generate_hash -// Access: Public -// Description: Accumulates the properties of these keywords into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of these keywords into the hash. + */ void DCKeywordList:: generate_hash(HashGenerator &hashgen) const { if (_flags != ~0) { - // All of the flags are historical flags only, so add just the - // flags bitmask to keep the hash code the same as it has - // historically been. + // All of the flags are historical flags only, so add just the flags + // bitmask to keep the hash code the same as it has historically been. hashgen.add_int(_flags); } else { - // There is at least one custom flag, so go ahead and make the - // hash code reflect it. + // There is at least one custom flag, so go ahead and make the hash code + // reflect it. hashgen.add_int(_keywords_by_name.size()); KeywordsByName::const_iterator ni; diff --git a/direct/src/dcparser/dcKeywordList.h b/direct/src/dcparser/dcKeywordList.h index 81999934ef..b5e35b3247 100644 --- a/direct/src/dcparser/dcKeywordList.h +++ b/direct/src/dcparser/dcKeywordList.h @@ -1,16 +1,15 @@ -// Filename: dcKeywordList.h -// Created by: drose (25Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcKeywordList.h + * @author drose + * @date 2005-07-25 + */ #ifndef DCKEYWORDLIST_H #define DCKEYWORDLIST_H @@ -20,11 +19,10 @@ class DCKeyword; class HashGenerator; -//////////////////////////////////////////////////////////////////// -// Class : DCKeywordList -// Description : This is a list of keywords (see DCKeyword) that may -// be set on a particular field. -//////////////////////////////////////////////////////////////////// +/** + * This is a list of keywords (see DCKeyword) that may be set on a particular + * field. + */ class EXPCL_DIRECT DCKeywordList { public: DCKeywordList(); diff --git a/direct/src/dcparser/dcLexerDefs.h b/direct/src/dcparser/dcLexerDefs.h index 34d058d58b..8c480ad98a 100644 --- a/direct/src/dcparser/dcLexerDefs.h +++ b/direct/src/dcparser/dcLexerDefs.h @@ -1,16 +1,15 @@ -// Filename: dcLexerDefs.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcLexerDefs.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCLEXERDEFS_H #define DCLEXERDEFS_H diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index ea71e40316..4bb0c3241f 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -1,16 +1,15 @@ -// Filename: dcMolecularField.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcMolecularField.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcMolecularField.h" #include "dcAtomicField.h" @@ -19,76 +18,58 @@ -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCMolecularField:: DCMolecularField(const string &name, DCClass *dclass) : DCField(name, dclass) { _got_keywords = false; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::as_molecular_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to a -// molecular field pointer, if this is in fact a -// molecular field; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to a molecular field pointer, if + * this is in fact a molecular field; otherwise, returns NULL. + */ DCMolecularField *DCMolecularField:: as_molecular_field() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::as_molecular_field -// Access: Published, Virtual -// Description: Returns the same field pointer converted to a -// molecular field pointer, if this is in fact a -// molecular field; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same field pointer converted to a molecular field pointer, if + * this is in fact a molecular field; otherwise, returns NULL. + */ const DCMolecularField *DCMolecularField:: as_molecular_field() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::get_num_atomics -// Access: Published -// Description: Returns the number of atomic fields that make up this -// molecular field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of atomic fields that make up this molecular field. + */ int DCMolecularField:: get_num_atomics() const { return _fields.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::get_atomic -// Access: Published -// Description: Returns the nth atomic field that makes up this -// molecular field. This may or may not be a field of -// this particular class; it might be defined in a -// parent class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth atomic field that makes up this molecular field. This may + * or may not be a field of this particular class; it might be defined in a + * parent class. + */ DCAtomicField *DCMolecularField:: get_atomic(int n) const { nassertr(n >= 0 && n < (int)_fields.size(), NULL); return _fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::add_atomic -// Access: Public -// Description: Adds the indicated atomic field to the end of the -// list of atomic fields that make up the molecular -// field. This is normally called only during parsing -// of the dc file. The atomic field should be fully -// defined by this point; you should not modify the -// atomic field (e.g. by adding more elements) after -// adding it to a molecular field. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated atomic field to the end of the list of atomic fields + * that make up the molecular field. This is normally called only during + * parsing of the dc file. The atomic field should be fully defined by this + * point; you should not modify the atomic field (e.g. by adding more + * elements) after adding it to a molecular field. + */ void DCMolecularField:: add_atomic(DCAtomicField *atomic) { if (!atomic->is_bogus_field()) { @@ -124,11 +105,9 @@ add_atomic(DCAtomicField *atomic) { _default_value_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCMolecularField:: output(ostream &out, bool brief) const { out << _name; @@ -142,16 +121,14 @@ output(ostream &out, bool brief) const { ++fi; } } - + out << ";"; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::write -// Access: Public, Virtual -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCMolecularField:: write(ostream &out, bool brief, int indent_level) const { indent(out, indent_level); @@ -163,12 +140,9 @@ write(ostream &out, bool brief, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this field into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this field into the hash. + */ void DCMolecularField:: generate_hash(HashGenerator &hashgen) const { DCField::generate_hash(hashgen); @@ -180,39 +154,31 @@ generate_hash(HashGenerator &hashgen) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCMolecularField:: get_nested_field(int n) const { nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); return _nested_fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCMolecularField:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_molecular_field(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCMolecularField::do_check_match_molecular_field -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// molecular field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated molecular field, false + * otherwise. + */ bool DCMolecularField:: do_check_match_molecular_field(const DCMolecularField *other) const { if (_nested_fields.size() != other->_nested_fields.size()) { diff --git a/direct/src/dcparser/dcMolecularField.h b/direct/src/dcparser/dcMolecularField.h index 83ce9bce96..8b2d056bdd 100644 --- a/direct/src/dcparser/dcMolecularField.h +++ b/direct/src/dcparser/dcMolecularField.h @@ -1,16 +1,15 @@ -// Filename: dcMolecularField.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcMolecularField.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCMOLECULARFIELD_H #define DCMOLECULARFIELD_H @@ -21,13 +20,11 @@ class DCAtomicField; class DCParameter; -//////////////////////////////////////////////////////////////////// -// Class : DCMolecularField -// Description : A single molecular field of a Distributed Class, as -// read from a .dc file. This represents a combination -// of two or more related atomic fields, that will often -// be treated as a unit. -//////////////////////////////////////////////////////////////////// +/** + * A single molecular field of a Distributed Class, as read from a .dc file. + * This represents a combination of two or more related atomic fields, that + * will often be treated as a unit. + */ class EXPCL_DIRECT DCMolecularField : public DCField { public: DCMolecularField(const string &name, DCClass *dclass); @@ -66,5 +63,3 @@ private: }; #endif - - diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I index e0b4ec9029..debc9bbcd5 100644 --- a/direct/src/dcparser/dcNumericRange.I +++ b/direct/src/dcparser/dcNumericRange.I @@ -1,44 +1,36 @@ -// Filename: dcNumericRange.I -// Created by: drose (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcNumericRange.I + * @author drose + * @date 2004-06-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DCNumericRange:: DCNumericRange() { } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DCNumericRange:: DCNumericRange(Number min, Number max) { add_range(min, max); } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DCNumericRange:: DCNumericRange(const DCNumericRange ©) : @@ -46,23 +38,19 @@ DCNumericRange(const DCNumericRange ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DCNumericRange:: operator = (const DCNumericRange ©) { _ranges = copy._ranges; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::is_in_range -// Access: Public -// Description: Returns true if the indicated number is within the -// specified range, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated number is within the specified range, false + * otherwise. + */ template bool DCNumericRange:: is_in_range(Number num) const { @@ -80,14 +68,11 @@ is_in_range(Number num) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::validate -// Access: Public -// Description: Convenience function to validate the indicated -// number. If the number is within the specified range, -// does nothing; otherwise, if it is outside the range, -// sets range_error to true. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function to validate the indicated number. If the number is + * within the specified range, does nothing; otherwise, if it is outside the + * range, sets range_error to true. + */ template INLINE void DCNumericRange:: validate(Number num, bool &range_error) const { @@ -96,24 +81,20 @@ validate(Number num, bool &range_error) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::has_one_value -// Access: Public -// Description: Returns true if the numeric range specifies exactly -// one legal value, false if multiple values are legal. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the numeric range specifies exactly one legal value, false + * if multiple values are legal. + */ template INLINE bool DCNumericRange:: has_one_value() const { return _ranges.size() == 1 && _ranges[0]._min == _ranges[0]._max; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::get_one_value -// Access: Public -// Description: If has_one_value() returns true, this returns the one -// legal value accepted by the numeric range. -//////////////////////////////////////////////////////////////////// +/** + * If has_one_value() returns true, this returns the one legal value accepted + * by the numeric range. + */ template INLINE TYPENAME DCNumericRange::Number DCNumericRange:: get_one_value() const { @@ -121,11 +102,9 @@ get_one_value() const { return _ranges[0]._min; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::generate_hash -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void DCNumericRange:: generate_hash(HashGenerator &hashgen) const { @@ -133,19 +112,17 @@ generate_hash(HashGenerator &hashgen) const { hashgen.add_int(_ranges.size()); TYPENAME Ranges::const_iterator ri; for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { - // We don't account for the fractional part of floating-point - // ranges here. Shouldn't be a real issue. + // We don't account for the fractional part of floating-point ranges + // here. Shouldn't be a real issue. hashgen.add_int((int)(*ri)._min); hashgen.add_int((int)(*ri)._max); } } } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void DCNumericRange:: output(ostream &out, Number divisor) const { @@ -162,12 +139,10 @@ output(ostream &out, Number divisor) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::output_char -// Access: Public -// Description: Outputs the range, formatting the numeric values as -// quoted ASCII characters. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the range, formatting the numeric values as quoted ASCII + * characters. + */ template void DCNumericRange:: output_char(ostream &out, Number divisor) const { @@ -189,30 +164,25 @@ output_char(ostream &out, Number divisor) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DCNumericRange:: clear() { _ranges.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::add_range -// Access: Public -// Description: Adds a new minmax to the list of ranges. This is -// normally called only during dc file parsing. Returns -// true if successful, or false if the new minmax -// overlaps an existing minmax. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new minmax to the list of ranges. This is normally called only + * during dc file parsing. Returns true if successful, or false if the new + * minmax overlaps an existing minmax. + */ template bool DCNumericRange:: add_range(Number min, Number max) { - // Check for an overlap. This is probably indicative of a typo and - // should be reported. + // Check for an overlap. This is probably indicative of a typo and should + // be reported. if (max < min) { return false; } @@ -234,36 +204,28 @@ add_range(Number min, Number max) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::is_empty -// Access: Private -// Description: Returns true if the range contains no elements (and -// thus allows all numbers), false if it contains at -// least one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the range contains no elements (and thus allows all + * numbers), false if it contains at least one. + */ template INLINE bool DCNumericRange:: is_empty() const { return _ranges.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::get_num_ranges -// Access: Private -// Description: Returns the number of minmax components in the range -// description. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of minmax components in the range description. + */ template INLINE int DCNumericRange:: get_num_ranges() const { return _ranges.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::get_min -// Access: Private -// Description: Returns the minimum value defined by the nth component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum value defined by the nth component. + */ template INLINE TYPENAME DCNumericRange::Number DCNumericRange:: get_min(int n) const { @@ -271,11 +233,9 @@ get_min(int n) const { return _ranges[n]._min; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::get_max -// Access: Private -// Description: Returns the maximum value defined by the nth component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum value defined by the nth component. + */ template INLINE TYPENAME DCNumericRange::Number DCNumericRange:: get_max(int n) const { @@ -283,11 +243,9 @@ get_max(int n) const { return _ranges[n]._max; } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::output_minmax -// Access: Private -// Description: Outputs a single element of the range description. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a single element of the range description. + */ template INLINE void DCNumericRange:: output_minmax(ostream &out, Number divisor, const MinMax &range) const { @@ -308,11 +266,9 @@ output_minmax(ostream &out, Number divisor, const MinMax &range) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCNumericRange::output_minmax_char -// Access: Private -// Description: Outputs a single element of the range description. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a single element of the range description. + */ template INLINE void DCNumericRange:: output_minmax_char(ostream &out, const MinMax &range) const { diff --git a/direct/src/dcparser/dcNumericRange.h b/direct/src/dcparser/dcNumericRange.h index 66b2722e89..f872f39a7a 100644 --- a/direct/src/dcparser/dcNumericRange.h +++ b/direct/src/dcparser/dcNumericRange.h @@ -1,16 +1,15 @@ -// Filename: dcNumericRange.h -// Created by: drose (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcNumericRange.h + * @author drose + * @date 2004-06-21 + */ #ifndef DCNUMERICRANGE_H #define DCNUMERICRANGE_H @@ -19,12 +18,10 @@ #include "hashGenerator.h" #include "dcPacker.h" -//////////////////////////////////////////////////////////////////// -// Class : DCNumericRange -// Description : Represents a range of legal integer or floating-point -// values. This is used to constrain simple numeric -// types, as well as array sizes. -//////////////////////////////////////////////////////////////////// +/** + * Represents a range of legal integer or floating-point values. This is used + * to constrain simple numeric types, as well as array sizes. + */ template class DCNumericRange { public: diff --git a/direct/src/dcparser/dcPackData.I b/direct/src/dcparser/dcPackData.I index 3ff6ce705b..3766f64d2f 100644 --- a/direct/src/dcparser/dcPackData.I +++ b/direct/src/dcparser/dcPackData.I @@ -1,23 +1,19 @@ -// Filename: dcPackData.I -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackData.I + * @author drose + * @date 2004-06-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DCPackData:: DCPackData() { _buffer = NULL; @@ -25,11 +21,9 @@ DCPackData() { _used_length = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DCPackData:: ~DCPackData() { if (_buffer != (const char *)NULL) { @@ -37,129 +31,100 @@ INLINE DCPackData:: } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::clear -// Access: Published -// Description: Empties the contents of the data (without necessarily -// freeing its allocated memory). -//////////////////////////////////////////////////////////////////// +/** + * Empties the contents of the data (without necessarily freeing its allocated + * memory). + */ INLINE void DCPackData:: clear() { _used_length = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::append_data -// Access: Public -// Description: Adds the indicated bytes to the end of the data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated bytes to the end of the data. + */ INLINE void DCPackData:: append_data(const char *buffer, size_t size) { set_used_length(_used_length + size); memcpy(_buffer + _used_length - size, buffer, size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::get_write_pointer -// Access: Public -// Description: Adds the indicated number of bytes to the end of the -// data without initializing them, and returns a pointer -// to the beginning of the new data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated number of bytes to the end of the data without + * initializing them, and returns a pointer to the beginning of the new data. + */ INLINE char *DCPackData:: get_write_pointer(size_t size) { set_used_length(_used_length + size); return _buffer + _used_length - size; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::append_junk -// Access: Public -// Description: Adds some uninitialized bytes to the end of the data. -//////////////////////////////////////////////////////////////////// +/** + * Adds some uninitialized bytes to the end of the data. + */ INLINE void DCPackData:: append_junk(size_t size) { set_used_length(_used_length + size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::rewrite_data -// Access: Public -// Description: Changes the data at the indicated position to the -// given value. It is an error if there are not at -// least position + size bytes in the data. -//////////////////////////////////////////////////////////////////// +/** + * Changes the data at the indicated position to the given value. It is an + * error if there are not at least position + size bytes in the data. + */ INLINE void DCPackData:: rewrite_data(size_t position, const char *buffer, size_t size) { nassertv(position + size <= _used_length); memcpy(_buffer + position, buffer, size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::get_rewrite_pointer -// Access: Public -// Description: Returns a pointer into the middle of the data at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer into the middle of the data at the indicated point. + */ INLINE char *DCPackData:: get_rewrite_pointer(size_t position, size_t size) { nassertr(position + size <= _used_length, NULL); return _buffer + position; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::get_string -// Access: Published -// Description: Returns the data buffer as a string. Also see -// get_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the data buffer as a string. Also see get_data(). + */ INLINE string DCPackData:: get_string() const { return string(_buffer, _used_length); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::get_length -// Access: Published -// Description: Returns the current length of the buffer. This is -// the number of useful bytes stored in the buffer, not -// the amount of memory it takes up. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current length of the buffer. This is the number of useful + * bytes stored in the buffer, not the amount of memory it takes up. + */ INLINE size_t DCPackData:: get_length() const { return _used_length; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::get_data -// Access: Public -// Description: Returns the beginning of the data buffer. The buffer -// is not null-terminated, but see also get_string(). -// This may (or may not) return NULL if the buffer is -// empty. -// -// This may be used in conjunction with get_length() to -// copy all of the bytes out of the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the beginning of the data buffer. The buffer is not null- + * terminated, but see also get_string(). This may (or may not) return NULL if + * the buffer is empty. + * + * This may be used in conjunction with get_length() to copy all of the bytes + * out of the buffer. + */ INLINE const char *DCPackData:: get_data() const { return _buffer; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::take_data -// Access: Public -// Description: Returns the pointer to the beginning of the data -// buffer, and transfers ownership of the buffer to the -// caller. The caller is now responsible for ultimately -// freeing the returned pointer with delete[], if it is -// non-NULL. This may (or may not) return NULL if the -// buffer is empty. -// -// This also empties the DCPackData structure, and sets -// its length to zero (so you should call get_length() -// before calling this method). -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the beginning of the data buffer, and transfers + * ownership of the buffer to the caller. The caller is now responsible for + * ultimately freeing the returned pointer with delete[], if it is non-NULL. + * This may (or may not) return NULL if the buffer is empty. + * + * This also empties the DCPackData structure, and sets its length to zero (so + * you should call get_length() before calling this method). + */ INLINE char *DCPackData:: take_data() { char *data = _buffer; diff --git a/direct/src/dcparser/dcPackData.cxx b/direct/src/dcparser/dcPackData.cxx index 11e0fc3411..4276c735f4 100644 --- a/direct/src/dcparser/dcPackData.cxx +++ b/direct/src/dcparser/dcPackData.cxx @@ -1,28 +1,24 @@ -// Filename: dcPackData.cxx -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackData.cxx + * @author drose + * @date 2004-06-15 + */ #include "dcPackData.h" static const size_t extra_size = 50; -//////////////////////////////////////////////////////////////////// -// Function: DCPackData::set_used_length -// Access: Private -// Description: Ensures that the buffer has at least size bytes, and -// sets the _used_length to the indicated value; grows -// the buffer if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the buffer has at least size bytes, and sets the _used_length + * to the indicated value; grows the buffer if it does not. + */ void DCPackData:: set_used_length(size_t size) { if (size > _allocated_size) { diff --git a/direct/src/dcparser/dcPackData.h b/direct/src/dcparser/dcPackData.h index 2166e96ce9..9d19548591 100644 --- a/direct/src/dcparser/dcPackData.h +++ b/direct/src/dcparser/dcPackData.h @@ -1,27 +1,24 @@ -// Filename: dcPackData.h -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackData.h + * @author drose + * @date 2004-06-15 + */ #ifndef DCPACKDATA_H #define DCPACKDATA_H #include "dcbase.h" -//////////////////////////////////////////////////////////////////// -// Class : DCPackData -// Description : This is a block of data that receives the results of -// DCPacker. -//////////////////////////////////////////////////////////////////// +/** + * This is a block of data that receives the results of DCPacker. + */ class EXPCL_DIRECT DCPackData { PUBLISHED: INLINE DCPackData(); diff --git a/direct/src/dcparser/dcPacker.I b/direct/src/dcparser/dcPacker.I index 10f202e307..bb9a10daf9 100644 --- a/direct/src/dcparser/dcPacker.I +++ b/direct/src/dcparser/dcPacker.I @@ -1,26 +1,21 @@ -// Filename: dcPacker.I -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPacker.I + * @author drose + * @date 2004-06-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::clear_data -// Access: Published -// Description: Empties the data in the pack buffer and unpack -// buffer. This should be called between calls to -// begin_pack(), unless you want to concatenate all of -// the pack results together. -//////////////////////////////////////////////////////////////////// +/** + * Empties the data in the pack buffer and unpack buffer. This should be + * called between calls to begin_pack(), unless you want to concatenate all of + * the pack results together. + */ INLINE void DCPacker:: clear_data() { _pack_data.clear(); @@ -32,15 +27,12 @@ clear_data() { _unpack_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::has_nested_fields -// Access: Published -// Description: Returns true if the current field has any nested -// fields (and thus expects a push() .. pop() -// interface), or false otherwise. If this returns -// true, get_num_nested_fields() may be called to -// determine how many nested fields are expected. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current field has any nested fields (and thus expects a + * push() .. pop() interface), or false otherwise. If this returns true, + * get_num_nested_fields() may be called to determine how many nested fields + * are expected. + */ INLINE bool DCPacker:: has_nested_fields() const { if (_current_field == NULL) { @@ -50,97 +42,74 @@ has_nested_fields() const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_num_nested_fields -// Access: Published -// Description: Returns the number of nested fields associated with -// the current field, if has_nested_fields() returned -// true. -// -// The return value may be -1 to indicate that a -// variable number of nested fields are accepted by this -// field type (e.g. a variable-length array). -// -// Note that this method is unreliable to determine how -// many fields you must traverse before you can call -// pop(), since particularly in the presence of a -// DCSwitch, it may change during traversal. Use -// more_nested_fields() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested fields associated with the current field, if + * has_nested_fields() returned true. + * + * The return value may be -1 to indicate that a variable number of nested + * fields are accepted by this field type (e.g. a variable-length array). + * + * Note that this method is unreliable to determine how many fields you must + * traverse before you can call pop(), since particularly in the presence of a + * DCSwitch, it may change during traversal. Use more_nested_fields() + * instead. + */ INLINE int DCPacker:: get_num_nested_fields() const { return _num_nested_fields; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::more_nested_fields -// Access: Published -// Description: Returns true if there are more nested fields to pack -// or unpack in the current push sequence, false if it -// is time to call pop(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are more nested fields to pack or unpack in the + * current push sequence, false if it is time to call pop(). + */ INLINE bool DCPacker:: more_nested_fields() const { return (_current_field != (DCPackerInterface *)NULL && !_pack_error); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_current_parent -// Access: Published -// Description: Returns the field that we left in our last call to -// push(): the owner of the current level of fields. -// This may be NULL at the beginning of the pack -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the field that we left in our last call to push(): the owner of the + * current level of fields. This may be NULL at the beginning of the pack + * operation. + */ INLINE const DCPackerInterface *DCPacker:: get_current_parent() const { return _current_parent; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_current_field -// Access: Published -// Description: Returns the field that will be referenced by the next -// call to pack_*() or unpack_*(). This will be NULL if -// we have unpacked (or packed) all fields, or if it is -// time to call pop(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the field that will be referenced by the next call to pack_*() or + * unpack_*(). This will be NULL if we have unpacked (or packed) all fields, + * or if it is time to call pop(). + */ INLINE const DCPackerInterface *DCPacker:: get_current_field() const { return _current_field; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_last_switch -// Access: Published -// Description: Returns a pointer to the last DCSwitch instance that -// we have passed by and selected one case of during the -// pack/unpack process. Each time we encounter a new -// DCSwitch and select a case, this will change state. -// -// This may be used to detect when a DCSwitch has been -// selected. At the moment this changes state, -// get_current_parent() will contain the particular -// SwitchCase that was selected by the switch. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the last DCSwitch instance that we have passed by and + * selected one case of during the pack/unpack process. Each time we + * encounter a new DCSwitch and select a case, this will change state. + * + * This may be used to detect when a DCSwitch has been selected. At the + * moment this changes state, get_current_parent() will contain the particular + * SwitchCase that was selected by the switch. + */ INLINE const DCSwitchParameter *DCPacker:: get_last_switch() const { return _last_switch; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_pack_type -// Access: Published -// Description: Returns the type of value expected by the current -// field. See the enumerated type definition at the top -// of DCPackerInterface.h. If this returns one of -// PT_double, PT_int, PT_int64, or PT_string, then you -// should call the corresponding pack_double(), -// pack_int() function (or unpack_double(), -// unpack_int(), etc.) to transfer data. Otherwise, you -// should call push() and begin packing or unpacking the -// nested fields. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of value expected by the current field. See the + * enumerated type definition at the top of DCPackerInterface.h. If this + * returns one of PT_double, PT_int, PT_int64, or PT_string, then you should + * call the corresponding pack_double(), pack_int() function (or + * unpack_double(), unpack_int(), etc.) to transfer data. Otherwise, you + * should call push() and begin packing or unpacking the nested fields. + */ INLINE DCPackType DCPacker:: get_pack_type() const { if (_current_field == NULL) { @@ -150,13 +119,10 @@ get_pack_type() const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_current_field_name -// Access: Published -// Description: Returns the name of the current field, if it has a -// name, or the empty string if the field does not have -// a name or there is no current field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the current field, if it has a name, or the empty + * string if the field does not have a name or there is no current field. + */ INLINE string DCPacker:: get_current_field_name() const { if (_current_field == NULL) { @@ -166,12 +132,9 @@ get_current_field_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_double -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_double(double value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -183,12 +146,9 @@ pack_double(double value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_int -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_int(int value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -200,12 +160,9 @@ pack_int(int value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_uint -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_uint(unsigned int value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -217,12 +174,9 @@ pack_uint(unsigned int value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_int64 -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_int64(PN_int64 value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -234,12 +188,9 @@ pack_int64(PN_int64 value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_uint64 -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_uint64(PN_uint64 value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -251,12 +202,9 @@ pack_uint64(PN_uint64 value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_string -// Access: Published -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ INLINE void DCPacker:: pack_string(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -268,13 +216,10 @@ pack_string(const string &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_literal_value -// Access: Published -// Description: Adds the indicated string value into the stream, -// representing a single pre-packed field element, or a -// whole group of field elements at once. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated string value into the stream, representing a single pre- + * packed field element, or a whole group of field elements at once. + */ INLINE void DCPacker:: pack_literal_value(const string &value) { nassertv(_mode == M_pack || _mode == M_repack); @@ -286,12 +231,9 @@ pack_literal_value(const string &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_double -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE double DCPacker:: unpack_double() { double value = 0.0; @@ -300,7 +242,7 @@ unpack_double() { _pack_error = true; } else { - _current_field->unpack_double(_unpack_data, _unpack_length, _unpack_p, + _current_field->unpack_double(_unpack_data, _unpack_length, _unpack_p, value, _pack_error, _range_error); advance(); } @@ -308,12 +250,9 @@ unpack_double() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_int -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE int DCPacker:: unpack_int() { int value = 0; @@ -330,12 +269,9 @@ unpack_int() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_uint -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE unsigned int DCPacker:: unpack_uint() { unsigned int value = 0; @@ -352,12 +288,9 @@ unpack_uint() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_int64 -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE PN_int64 DCPacker:: unpack_int64() { PN_int64 value = 0; @@ -374,12 +307,9 @@ unpack_int64() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_uint64 -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE PN_uint64 DCPacker:: unpack_uint64() { PN_uint64 value = 0; @@ -396,12 +326,9 @@ unpack_uint64() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_string -// Access: Published -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE string DCPacker:: unpack_string() { string value; @@ -418,13 +345,10 @@ unpack_string() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_literal_value -// Access: Published -// Description: Returns the literal string that represents the packed -// value of the current field, and advances the field -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the literal string that represents the packed value of the current + * field, and advances the field pointer. + */ INLINE string DCPacker:: unpack_literal_value() { size_t start = _unpack_p; @@ -433,12 +357,9 @@ unpack_literal_value() { return string(_unpack_data + start, _unpack_p - start); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_double -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_double(double &value) { nassertv(_mode == M_unpack); @@ -446,18 +367,15 @@ unpack_double(double &value) { _pack_error = true; } else { - _current_field->unpack_double(_unpack_data, _unpack_length, _unpack_p, + _current_field->unpack_double(_unpack_data, _unpack_length, _unpack_p, value, _pack_error, _range_error); advance(); } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_int -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_int(int &value) { nassertv(_mode == M_unpack); @@ -471,12 +389,9 @@ unpack_int(int &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_uint -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_uint(unsigned int &value) { nassertv(_mode == M_unpack); @@ -490,12 +405,9 @@ unpack_uint(unsigned int &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_int64 -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_int64(PN_int64 &value) { nassertv(_mode == M_unpack); @@ -509,12 +421,9 @@ unpack_int64(PN_int64 &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_uint64 -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_uint64(PN_uint64 &value) { nassertv(_mode == M_unpack); @@ -528,12 +437,9 @@ unpack_uint64(PN_uint64 &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_string -// Access: Public -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ INLINE void DCPacker:: unpack_string(string &value) { nassertv(_mode == M_unpack); @@ -547,13 +453,10 @@ unpack_string(string &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_literal_value -// Access: Public -// Description: Returns the literal string that represents the packed -// value of the current field, and advances the field -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the literal string that represents the packed value of the current + * field, and advances the field pointer. + */ INLINE void DCPacker:: unpack_literal_value(string &value) { size_t start = _unpack_p; @@ -562,347 +465,262 @@ unpack_literal_value(string &value) { value.assign(_unpack_data + start, _unpack_p - start); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::had_parse_error -// Access: Published -// Description: Returns true if there has been an parse error -// since the most recent call to begin(); this can only -// happen if you call parse_and_pack(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there has been an parse error since the most recent call to + * begin(); this can only happen if you call parse_and_pack(). + */ INLINE bool DCPacker:: had_parse_error() const { return _parse_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::had_pack_error -// Access: Published -// Description: Returns true if there has been an packing error -// since the most recent call to begin(); in particular, -// this may be called after end() has returned false to -// determine the nature of the failure. -// -// A return value of true indicates there was a push/pop -// mismatch, or the push/pop structure did not match the -// data structure, or there were the wrong number of -// elements in a nested push/pop structure, or on unpack -// that the data stream was truncated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there has been an packing error since the most recent call + * to begin(); in particular, this may be called after end() has returned + * false to determine the nature of the failure. + * + * A return value of true indicates there was a push/pop mismatch, or the + * push/pop structure did not match the data structure, or there were the + * wrong number of elements in a nested push/pop structure, or on unpack that + * the data stream was truncated. + */ INLINE bool DCPacker:: had_pack_error() const { return _pack_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::had_range_error -// Access: Published -// Description: Returns true if there has been an range validation -// error since the most recent call to begin(); in -// particular, this may be called after end() has -// returned false to determine the nature of the -// failure. -// -// A return value of true indicates a value that was -// packed or unpacked did not fit within the specified -// legal range for a parameter, or within the limits of -// the field size. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there has been an range validation error since the most + * recent call to begin(); in particular, this may be called after end() has + * returned false to determine the nature of the failure. + * + * A return value of true indicates a value that was packed or unpacked did + * not fit within the specified legal range for a parameter, or within the + * limits of the field size. + */ INLINE bool DCPacker:: had_range_error() const { return _range_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::had_error -// Access: Published -// Description: Returns true if there has been any error (either a -// pack error or a range error) since the most recent -// call to begin(). If this returns true, then the -// matching call to end() will indicate an error -// (false). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there has been any error (either a pack error or a range + * error) since the most recent call to begin(). If this returns true, then + * the matching call to end() will indicate an error (false). + */ INLINE bool DCPacker:: had_error() const { return _range_error || _pack_error || _parse_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_num_unpacked_bytes -// Access: Published -// Description: Returns the number of bytes that have been unpacked -// so far, or after unpack_end(), the total number of -// bytes that were unpacked at all. This can be used to -// validate that all of the bytes in the buffer were -// actually unpacked (which is not otherwise considered -// an error). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that have been unpacked so far, or after + * unpack_end(), the total number of bytes that were unpacked at all. This + * can be used to validate that all of the bytes in the buffer were actually + * unpacked (which is not otherwise considered an error). + */ INLINE size_t DCPacker:: get_num_unpacked_bytes() const { return _unpack_p; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_length -// Access: Published -// Description: Returns the current length of the buffer. This is -// the number of useful bytes stored in the buffer, not -// the amount of memory it takes up. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current length of the buffer. This is the number of useful + * bytes stored in the buffer, not the amount of memory it takes up. + */ INLINE size_t DCPacker:: get_length() const { return _pack_data.get_length(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_string -// Access: Published -// Description: Returns the packed data buffer as a string. Also see -// get_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the packed data buffer as a string. Also see get_data(). + */ INLINE string DCPacker:: get_string() const { return _pack_data.get_string(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_unpack_length -// Access: Published -// Description: Returns the total number of bytes in the unpack data -// buffer. This is the buffer used when unpacking; it -// is separate from the pack data returned by -// get_length(), which is filled during packing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes in the unpack data buffer. This is the + * buffer used when unpacking; it is separate from the pack data returned by + * get_length(), which is filled during packing. + */ INLINE size_t DCPacker:: get_unpack_length() const { return _unpack_length; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_unpack_string -// Access: Published -// Description: Returns the unpack data buffer, as a string. -// This is the buffer used when unpacking; it is -// separate from the pack data returned by get_string(), -// which is filled during packing. Also see -// get_unpack_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the unpack data buffer, as a string. This is the buffer used when + * unpacking; it is separate from the pack data returned by get_string(), + * which is filled during packing. Also see get_unpack_data(). + */ INLINE string DCPacker:: get_unpack_string() const { return string(_unpack_data, _unpack_length); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_string -// Access: Published -// Description: Copies the packed data into the indicated string. -// Also see get_data(). -//////////////////////////////////////////////////////////////////// +/** + * Copies the packed data into the indicated string. Also see get_data(). + */ INLINE void DCPacker:: get_string(string &data) const { data.assign(_pack_data.get_data(), _pack_data.get_length()); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_data -// Access: Public -// Description: Returns the beginning of the data buffer. The buffer -// is not null-terminated, but see also get_string(). -// -// This may be used in conjunction with get_length() to -// copy all of the bytes out of the buffer. Also see -// take_data() to get the packed data without a copy -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the beginning of the data buffer. The buffer is not null- + * terminated, but see also get_string(). + * + * This may be used in conjunction with get_length() to copy all of the bytes + * out of the buffer. Also see take_data() to get the packed data without a + * copy operation. + */ INLINE const char *DCPacker:: get_data() const { return _pack_data.get_data(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::take_data -// Access: Public -// Description: Returns the pointer to the beginning of the data -// buffer, and transfers ownership of the buffer to the -// caller. The caller is now responsible for ultimately -// freeing the returned pointer with delete[], if it is -// non-NULL. This may (or may not) return NULL if the -// buffer is empty. -// -// This also empties the DCPackData structure, and sets -// its length to zero (so you should call get_length() -// before calling this method). -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the beginning of the data buffer, and transfers + * ownership of the buffer to the caller. The caller is now responsible for + * ultimately freeing the returned pointer with delete[], if it is non-NULL. + * This may (or may not) return NULL if the buffer is empty. + * + * This also empties the DCPackData structure, and sets its length to zero (so + * you should call get_length() before calling this method). + */ INLINE char *DCPacker:: take_data() { return _pack_data.take_data(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::append_data -// Access: Public -// Description: Adds the indicated bytes to the end of the data. -// This may only be called between packing sessions. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated bytes to the end of the data. This may only be called + * between packing sessions. + */ INLINE void DCPacker:: append_data(const char *buffer, size_t size) { nassertv(_mode == M_idle); _pack_data.append_data(buffer, size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_write_pointer -// Access: Public -// Description: Adds the indicated number of bytes to the end of the -// data without initializing them, and returns a pointer -// to the beginning of the new data. This may only be -// called between packing sessions. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated number of bytes to the end of the data without + * initializing them, and returns a pointer to the beginning of the new data. + * This may only be called between packing sessions. + */ INLINE char *DCPacker:: get_write_pointer(size_t size) { nassertr(_mode == M_idle, NULL); return _pack_data.get_write_pointer(size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_unpack_data -// Access: Public -// Description: Returns a read pointer to the unpack data buffer. -// This is the buffer used when unpacking; it is -// separate from the pack data returned by get_data(), -// which is filled during packing. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read pointer to the unpack data buffer. This is the buffer used + * when unpacking; it is separate from the pack data returned by get_data(), + * which is filled during packing. + */ INLINE const char *DCPacker:: get_unpack_data() const { return _unpack_data; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::StackElement::get_num_stack_elements_ever_allocated -// Access: Published, Static -// Description: Returns the number of DCPacker::StackElement pointers -// ever simultaneously allocated; these are now either -// in active use or have been recycled into the deleted -// DCPacker::StackElement pool to be used again. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of DCPacker::StackElement pointers ever simultaneously + * allocated; these are now either in active use or have been recycled into + * the deleted DCPacker::StackElement pool to be used again. + */ INLINE int DCPacker:: get_num_stack_elements_ever_allocated() { return StackElement::_num_ever_allocated; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_int8 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_int8(int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_int8(_pack_data.get_write_pointer(1), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_int16 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_int16(int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_int16(_pack_data.get_write_pointer(2), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_int32 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_int32(int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_int32(_pack_data.get_write_pointer(4), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_int64 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_int64(PN_int64 value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_int64(_pack_data.get_write_pointer(8), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_uint8 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_uint8(unsigned int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_uint8(_pack_data.get_write_pointer(1), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_uint16 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_uint16(unsigned int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_uint16(_pack_data.get_write_pointer(2), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_uint32 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_uint32(unsigned int value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_uint32(_pack_data.get_write_pointer(4), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_uint64 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_uint64(PN_uint64 value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_uint64(_pack_data.get_write_pointer(8), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_float64 -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_float64(double value) { nassertv(_mode == M_idle); DCPackerInterface::do_pack_float64(_pack_data.get_write_pointer(8), value); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_pack_string -// Access: Published -// Description: Packs the data into the buffer between packing -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Packs the data into the buffer between packing sessions. + */ INLINE void DCPacker:: raw_pack_string(const string &value) { nassertv(_mode == M_idle); @@ -910,12 +728,9 @@ raw_pack_string(const string &value) { _pack_data.append_data(value.data(), value.length()); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int8 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE int DCPacker:: raw_unpack_int8() { int value = 0; @@ -923,12 +738,9 @@ raw_unpack_int8() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int16 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE int DCPacker:: raw_unpack_int16() { int value = 0; @@ -936,12 +748,9 @@ raw_unpack_int16() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int32 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE int DCPacker:: raw_unpack_int32() { int value = 0; @@ -949,12 +758,9 @@ raw_unpack_int32() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int64 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE PN_int64 DCPacker:: raw_unpack_int64() { PN_int64 value = 0; @@ -962,12 +768,9 @@ raw_unpack_int64() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int8 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_int8(int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -979,12 +782,9 @@ raw_unpack_int8(int &value) { _unpack_p++; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int16 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_int16(int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -996,12 +796,9 @@ raw_unpack_int16(int &value) { _unpack_p += 2; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int32 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_int32(int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1013,12 +810,9 @@ raw_unpack_int32(int &value) { _unpack_p += 4; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint8 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE unsigned int DCPacker:: raw_unpack_uint8() { unsigned int value = 0; @@ -1026,12 +820,9 @@ raw_unpack_uint8() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint16 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE unsigned int DCPacker:: raw_unpack_uint16() { unsigned int value = 0; @@ -1039,12 +830,9 @@ raw_unpack_uint16() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint32 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE unsigned int DCPacker:: raw_unpack_uint32() { unsigned int value = 0; @@ -1052,12 +840,9 @@ raw_unpack_uint32() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint64 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE PN_uint64 DCPacker:: raw_unpack_uint64() { PN_uint64 value = 0; @@ -1065,12 +850,9 @@ raw_unpack_uint64() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_float64 -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE double DCPacker:: raw_unpack_float64() { double value = 0; @@ -1078,12 +860,9 @@ raw_unpack_float64() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_string -// Access: Published -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE string DCPacker:: raw_unpack_string() { string value; @@ -1091,12 +870,9 @@ raw_unpack_string() { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_int64 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_int64(PN_int64 &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1108,12 +884,9 @@ raw_unpack_int64(PN_int64 &value) { _unpack_p += 8; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint8 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_uint8(unsigned int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1125,12 +898,9 @@ raw_unpack_uint8(unsigned int &value) { _unpack_p++; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint16 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_uint16(unsigned int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1142,12 +912,9 @@ raw_unpack_uint16(unsigned int &value) { _unpack_p += 2; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint32 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_uint32(unsigned int &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1159,12 +926,9 @@ raw_unpack_uint32(unsigned int &value) { _unpack_p += 4; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_uint64 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_uint64(PN_uint64 &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1176,12 +940,9 @@ raw_unpack_uint64(PN_uint64 &value) { _unpack_p += 8; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_float64 -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_float64(double &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1193,12 +954,9 @@ raw_unpack_float64(double &value) { _unpack_p += 8; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::raw_unpack_string -// Access: Public -// Description: Unpacks the data from the buffer between unpacking -// sessions. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the data from the buffer between unpacking sessions. + */ INLINE void DCPacker:: raw_unpack_string(string &value) { nassertv(_mode == M_idle && _unpack_data != NULL); @@ -1213,23 +971,20 @@ raw_unpack_string(string &value) { _unpack_p += string_length; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::advance -// Access: Private -// Description: Advances to the next field after a call to -// pack_value() or pop(). -//////////////////////////////////////////////////////////////////// +/** + * Advances to the next field after a call to pack_value() or pop(). + */ INLINE void DCPacker:: advance() { _current_field_index++; if (_num_nested_fields >= 0 && _current_field_index >= _num_nested_fields) { - // Done with all the fields on this parent. The caller must now - // call pop(). + // Done with all the fields on this parent. The caller must now call + // pop(). _current_field = NULL; - // But if the parent is a switch record, we make a special case so - // we can get the alternate fields. + // But if the parent is a switch record, we make a special case so we can + // get the alternate fields. if (_current_parent != (DCPackerInterface *)NULL) { const DCSwitchParameter *switch_parameter = ((DCPackerInterface *)_current_parent)->as_switch_parameter(); if (switch_parameter != (DCSwitchParameter *)NULL) { @@ -1238,8 +993,8 @@ advance() { } } else if (_pop_marker != 0 && _unpack_p >= _pop_marker) { - // Done with all the fields on this parent. The caller must now - // call pop(). + // Done with all the fields on this parent. The caller must now call + // pop(). _current_field = NULL; } else { @@ -1248,13 +1003,10 @@ advance() { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::StackElement::operator new -// Access: Public -// Description: Allocates the memory for a new DCPacker::StackElement. -// This is specialized here to provide for fast -// allocation of these things. -//////////////////////////////////////////////////////////////////// +/** + * Allocates the memory for a new DCPacker::StackElement. This is specialized + * here to provide for fast allocation of these things. + */ INLINE void *DCPacker::StackElement:: operator new(size_t size) { if (_deleted_chain != (DCPacker::StackElement *)NULL) { @@ -1268,13 +1020,10 @@ operator new(size_t size) { return ::operator new(size); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::StackElement::operator delete -// Access: Public -// Description: Frees the memory for a deleted DCPacker::StackElement. -// This is specialized here to provide for fast -// allocation of these things. -//////////////////////////////////////////////////////////////////// +/** + * Frees the memory for a deleted DCPacker::StackElement. This is specialized + * here to provide for fast allocation of these things. + */ INLINE void DCPacker::StackElement:: operator delete(void *ptr) { StackElement *obj = (StackElement *)ptr; diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index c0e711ecc6..6b789c945c 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -1,16 +1,15 @@ -// Filename: dcPacker.cxx -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPacker.cxx + * @author drose + * @date 2004-06-15 + */ #include "dcPacker.h" #include "dcSwitch.h" @@ -27,11 +26,9 @@ DCPacker::StackElement *DCPacker::StackElement::_deleted_chain = NULL; int DCPacker::StackElement::_num_ever_allocated = 0; -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCPacker:: DCPacker() { _mode = M_idle; @@ -44,38 +41,32 @@ DCPacker() { _pack_error = false; _range_error = false; _stack = NULL; - + clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCPacker:: ~DCPacker() { clear_data(); clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::begin_pack -// Access: Published -// Description: Begins a packing session. The parameter is the DC -// object that describes the packing format; it may be a -// DCParameter or DCField. -// -// Unless you call clear_data() between sessions, -// multiple packing sessions will be concatenated -// together into the same buffer. If you wish to add -// bytes to the buffer between packing sessions, use -// append_data() or get_write_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * Begins a packing session. The parameter is the DC object that describes + * the packing format; it may be a DCParameter or DCField. + * + * Unless you call clear_data() between sessions, multiple packing sessions + * will be concatenated together into the same buffer. If you wish to add + * bytes to the buffer between packing sessions, use append_data() or + * get_write_pointer(). + */ void DCPacker:: begin_pack(const DCPackerInterface *root) { nassertv(_mode == M_idle); - + _mode = M_pack; _parse_error = false; _pack_error = false; @@ -91,18 +82,16 @@ begin_pack(const DCPackerInterface *root) { _num_nested_fields = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::end_pack -// Access: Published, Virtual -// Description: Finishes a packing session. -// -// The return value is true on success, or false if -// there has been some error during packing. -//////////////////////////////////////////////////////////////////// +/** + * Finishes a packing session. + * + * The return value is true on success, or false if there has been some error + * during packing. + */ bool DCPacker:: end_pack() { nassertr(_mode == M_pack, false); - + _mode = M_idle; if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { @@ -114,13 +103,10 @@ end_pack() { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::set_unpack_data -// Access: Public -// Description: Sets up the unpack_data pointer. You may call this -// before calling the version of begin_unpack() that -// takes only one parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the unpack_data pointer. You may call this before calling the + * version of begin_unpack() that takes only one parameter. + */ void DCPacker:: set_unpack_data(const string &data) { nassertv(_mode == M_idle); @@ -130,15 +116,12 @@ set_unpack_data(const string &data) { set_unpack_data(buffer, data.length(), true); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::set_unpack_data -// Access: Public -// Description: Sets up the unpack_data pointer. You may call this -// before calling the version of begin_unpack() that -// takes only one parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the unpack_data pointer. You may call this before calling the + * version of begin_unpack() that takes only one parameter. + */ void DCPacker:: -set_unpack_data(const char *unpack_data, size_t unpack_length, +set_unpack_data(const char *unpack_data, size_t unpack_length, bool owns_unpack_data) { nassertv(_mode == M_idle); @@ -151,24 +134,20 @@ set_unpack_data(const char *unpack_data, size_t unpack_length, _unpack_p = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::begin_unpack -// Access: Public -// Description: Begins an unpacking session. You must have -// previously called set_unpack_data() to specify a -// buffer to unpack. -// -// If there was data left in the buffer after a previous -// begin_unpack() .. end_unpack() session, the new -// session will resume from the current point. This -// method may be used, therefore, to unpack a sequence -// of objects from the same buffer. -//////////////////////////////////////////////////////////////////// +/** + * Begins an unpacking session. You must have previously called + * set_unpack_data() to specify a buffer to unpack. + * + * If there was data left in the buffer after a previous begin_unpack() .. + * end_unpack() session, the new session will resume from the current point. + * This method may be used, therefore, to unpack a sequence of objects from + * the same buffer. + */ void DCPacker:: begin_unpack(const DCPackerInterface *root) { nassertv(_mode == M_idle); nassertv(_unpack_data != NULL); - + _mode = M_unpack; _parse_error = false; _pack_error = false; @@ -184,28 +163,24 @@ begin_unpack(const DCPackerInterface *root) { _num_nested_fields = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::end_unpack -// Access: Published -// Description: Finishes the unpacking session. -// -// The return value is true on success, or false if -// there has been some error during unpacking (or if all -// fields have not been unpacked). -//////////////////////////////////////////////////////////////////// +/** + * Finishes the unpacking session. + * + * The return value is true on success, or false if there has been some error + * during unpacking (or if all fields have not been unpacked). + */ bool DCPacker:: end_unpack() { nassertr(_mode == M_unpack, false); - + _mode = M_idle; if (_stack != NULL || _current_field != NULL || _current_parent != NULL) { - // This happens if we have not unpacked all of the fields. - // However, this is not an error if we have called seek() during - // the unpack session (in which case the _catalog will be - // non-NULL). On the other hand, if the catalog is still NULL, - // then we have never called seek() and it is an error not to - // unpack all values. + // This happens if we have not unpacked all of the fields. However, this + // is not an error if we have called seek() during the unpack session (in + // which case the _catalog will be non-NULL). On the other hand, if the + // catalog is still NULL, then we have never called seek() and it is an + // error not to unpack all values. if (_catalog == (DCPackerCatalog *)NULL) { _pack_error = true; } @@ -216,38 +191,32 @@ end_unpack() { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::begin_repack -// Access: Public -// Description: Begins a repacking session. You must have previously -// called set_unpack_data() to specify a buffer to -// unpack. -// -// Unlike begin_pack() or begin_unpack() you may not -// concatenate the results of multiple begin_repack() -// sessions in one buffer. -// -// Also, unlike in packing or unpacking modes, you may -// not walk through the fields from beginning to end, or -// even pack two consecutive fields at once. Instead, -// you must call seek() for each field you wish to -// modify and pack only that one field; then call seek() -// again to modify another field. -//////////////////////////////////////////////////////////////////// +/** + * Begins a repacking session. You must have previously called + * set_unpack_data() to specify a buffer to unpack. + * + * Unlike begin_pack() or begin_unpack() you may not concatenate the results + * of multiple begin_repack() sessions in one buffer. + * + * Also, unlike in packing or unpacking modes, you may not walk through the + * fields from beginning to end, or even pack two consecutive fields at once. + * Instead, you must call seek() for each field you wish to modify and pack + * only that one field; then call seek() again to modify another field. + */ void DCPacker:: begin_repack(const DCPackerInterface *root) { nassertv(_mode == M_idle); nassertv(_unpack_data != NULL); nassertv(_unpack_p == 0); - + _mode = M_repack; _parse_error = false; _pack_error = false; _range_error = false; _pack_data.clear(); - // In repack mode, we immediately get the catalog, since we know - // we'll need it. + // In repack mode, we immediately get the catalog, since we know we'll need + // it. _root = root; _catalog = _root->get_catalog(); _live_catalog = _catalog->get_live_catalog(_unpack_data, _unpack_length); @@ -255,48 +224,42 @@ begin_repack(const DCPackerInterface *root) { _pack_error = true; } - // We don't begin at the first field in repack mode. Instead, you - // must explicitly call seek(). + // We don't begin at the first field in repack mode. Instead, you must + // explicitly call seek(). _current_field = NULL; _current_parent = NULL; _current_field_index = 0; _num_nested_fields = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::end_repack -// Access: Published -// Description: Finishes the repacking session. -// -// The return value is true on success, or false if -// there has been some error during repacking (or if all -// fields have not been repacked). -//////////////////////////////////////////////////////////////////// +/** + * Finishes the repacking session. + * + * The return value is true on success, or false if there has been some error + * during repacking (or if all fields have not been repacked). + */ bool DCPacker:: end_repack() { nassertr(_mode == M_repack, false); // Put the rest of the data onto the pack stream. _pack_data.append_data(_unpack_data + _unpack_p, _unpack_length - _unpack_p); - + _mode = M_idle; clear(); return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::seek -// Access: Published -// Description: Sets the current unpack (or repack) position to the -// named field. In unpack mode, the next call to -// unpack_*() or push() will begin to read the named -// field. In repack mode, the next call to pack_*() or -// push() will modify the named field. -// -// Returns true if successful, false if the field is not -// known (or if the packer is in an invalid mode). -//////////////////////////////////////////////////////////////////// +/** + * Sets the current unpack (or repack) position to the named field. In unpack + * mode, the next call to unpack_*() or push() will begin to read the named + * field. In repack mode, the next call to pack_*() or push() will modify the + * named field. + * + * Returns true if successful, false if the field is not known (or if the + * packer is in an invalid mode). + */ bool DCPacker:: seek(const string &field_name) { if (_catalog == (DCPackerCatalog *)NULL) { @@ -308,7 +271,7 @@ seek(const string &field_name) { _pack_error = true; return false; } - + int seek_index = _live_catalog->find_entry_by_name(field_name); if (seek_index < 0) { // The field was not known. @@ -319,18 +282,14 @@ seek(const string &field_name) { return seek(seek_index); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::seek -// Access: Published -// Description: Seeks to the field indentified by seek_index, which -// was returned by an earlier call to -// DCField::find_seek_index() to get the index of some -// nested field. Also see the version of seek() that -// accepts a field name. -// -// Returns true if successful, false if the field is not -// known (or if the packer is in an invalid mode). -//////////////////////////////////////////////////////////////////// +/** + * Seeks to the field indentified by seek_index, which was returned by an + * earlier call to DCField::find_seek_index() to get the index of some nested + * field. Also see the version of seek() that accepts a field name. + * + * Returns true if successful, false if the field is not known (or if the + * packer is in an invalid mode). + */ bool DCPacker:: seek(int seek_index) { if (_catalog == (DCPackerCatalog *)NULL) { @@ -342,7 +301,7 @@ seek(int seek_index) { _pack_error = true; return false; } - + if (_mode == M_unpack) { const DCPackerCatalog::Entry &entry = _live_catalog->get_entry(seek_index); @@ -355,10 +314,10 @@ seek(int seek_index) { _num_nested_fields = _current_parent->get_num_nested_fields(); _unpack_p = _live_catalog->get_begin(seek_index); - // We don't really need _push_marker and _pop_marker now, except - // that we should set _push_marker in case we have just seeked to - // a switch parameter, and we should set _pop_marker to 0 just so - // it won't get in the way. + // We don't really need _push_marker and _pop_marker now, except that we + // should set _push_marker in case we have just seeked to a switch + // parameter, and we should set _pop_marker to 0 just so it won't get in + // the way. _push_marker = _unpack_p; _pop_marker = 0; @@ -368,27 +327,27 @@ seek(int seek_index) { nassertr(_catalog != (DCPackerCatalog *)NULL, false); if (_stack != NULL || _current_field != NULL) { - // It is an error to reseek while the stack is nonempty--that - // means we haven't finished packing the current field. + // It is an error to reseek while the stack is nonempty--that means we + // haven't finished packing the current field. _pack_error = true; return false; } const DCPackerCatalog::Entry &entry = _live_catalog->get_entry(seek_index); if (entry._parent->as_switch_parameter() != (DCSwitchParameter *)NULL) { - // If the parent is a DCSwitch, that can only mean that the - // seeked field is a switch parameter. We can't support seeking - // to a switch parameter and modifying it directly--what would - // happen to all of the related fields? Instead, you'll have to - // seek to the switch itself and repack the whole entity. + // If the parent is a DCSwitch, that can only mean that the seeked field + // is a switch parameter. We can't support seeking to a switch + // parameter and modifying it directly--what would happen to all of the + // related fields? Instead, you'll have to seek to the switch itself + // and repack the whole entity. _pack_error = true; return false; } size_t begin = _live_catalog->get_begin(seek_index); if (begin < _unpack_p) { - // Whoops, we are seeking fields out-of-order. That means we - // need to write the entire record and start again. + // Whoops, we are seeking fields out-of-order. That means we need to + // write the entire record and start again. _pack_data.append_data(_unpack_data + _unpack_p, _unpack_length - _unpack_p); size_t length = _pack_data.get_length(); char *buffer = _pack_data.take_data(); @@ -406,21 +365,21 @@ seek(int seek_index) { begin = _live_catalog->get_begin(seek_index); } - // Now copy the bytes from _unpack_p to begin from the - // _unpack_data to the _pack_data. These are the bytes we just - // skipped over with the call to seek(). + // Now copy the bytes from _unpack_p to begin from the _unpack_data to the + // _pack_data. These are the bytes we just skipped over with the call to + // seek(). _pack_data.append_data(_unpack_data + _unpack_p, begin - _unpack_p); - // And set the packer up to pack the indicated field (but no - // subsequent fields). + // And set the packer up to pack the indicated field (but no subsequent + // fields). _current_field = entry._field; _current_parent = entry._parent; _current_field_index = entry._field_index; _num_nested_fields = 1; _unpack_p = _live_catalog->get_end(seek_index); - // Set up push_marker and pop_marker so we won't try to advance - // beyond this field. + // Set up push_marker and pop_marker so we won't try to advance beyond + // this field. _push_marker = begin; _pop_marker = _live_catalog->get_end(seek_index); @@ -432,18 +391,16 @@ seek(int seek_index) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::push -// Access: Published -// Description: Marks the beginning of a nested series of fields. -// -// This must be called before filling the elements of an -// array or the individual fields in a structure field. -// It must also be balanced by a matching pop(). -// -// It is necessary to use push() / pop() only if -// has_nested_fields() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Marks the beginning of a nested series of fields. + * + * This must be called before filling the elements of an array or the + * individual fields in a structure field. It must also be balanced by a + * matching pop(). + * + * It is necessary to use push() / pop() only if has_nested_fields() returns + * true. + */ void DCPacker:: push() { if (!has_nested_fields()) { @@ -460,21 +417,19 @@ push() { _current_parent = _current_field; - // Now deal with the length prefix that might or might not be - // before a sequence of nested fields. + // Now deal with the length prefix that might or might not be before a + // sequence of nested fields. int num_nested_fields = _current_parent->get_num_nested_fields(); size_t length_bytes = _current_parent->get_num_length_bytes(); - + if (_mode == M_pack || _mode == M_repack) { - // Reserve length_bytes for when we figure out what the length - // is. + // Reserve length_bytes for when we figure out what the length is. _push_marker = _pack_data.get_length(); _pop_marker = 0; _pack_data.append_junk(length_bytes); } else if (_mode == M_unpack) { - // Read length_bytes to determine the end of this nested - // sequence. + // Read length_bytes to determine the end of this nested sequence. _push_marker = _unpack_p; _pop_marker = 0; @@ -494,9 +449,9 @@ push() { _unpack_p += 2; } _pop_marker = _unpack_p + length; - - // The explicit length trumps the number of nested fields - // reported by get_num_nested_fields(). + + // The explicit length trumps the number of nested fields reported + // by get_num_nested_fields(). if (length == 0) { num_nested_fields = 0; } else { @@ -516,30 +471,27 @@ push() { if (_num_nested_fields >= 0 && _current_field_index >= _num_nested_fields) { _current_field = NULL; - + } else { _current_field = _current_parent->get_nested_field(_current_field_index); } } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pop -// Access: Published -// Description: Marks the end of a nested series of fields. -// -// This must be called to match a previous push() only -// after all the expected number of nested fields have -// been packed. It is an error to call it too early, or -// too late. -//////////////////////////////////////////////////////////////////// +/** + * Marks the end of a nested series of fields. + * + * This must be called to match a previous push() only after all the expected + * number of nested fields have been packed. It is an error to call it too + * early, or too late. + */ void DCPacker:: pop() { if (_current_field != NULL && _num_nested_fields >= 0) { // Oops, didn't pack or unpack enough values. _pack_error = true; - } else if (_mode == M_unpack && _pop_marker != 0 && + } else if (_mode == M_unpack && _pop_marker != 0 && _unpack_p != _pop_marker) { // Didn't unpack the right number of values. _pack_error = true; @@ -586,13 +538,10 @@ pop() { advance(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_default_value -// Access: Published -// Description: Adds the default value for the current element into -// the stream. If no default has been set for the -// current element, creates a sensible default. -//////////////////////////////////////////////////////////////////// +/** + * Adds the default value for the current element into the stream. If no + * default has been set for the current element, creates a sensible default. + */ void DCPacker:: pack_default_value() { nassertv(_mode == M_pack || _mode == M_repack); @@ -603,8 +552,8 @@ pack_default_value() { advance(); } else { - // If the single field didn't know how to pack a default value, - // try packing nested fields. + // If the single field didn't know how to pack a default value, try + // packing nested fields. push(); while (more_nested_fields()) { pack_default_value(); @@ -614,14 +563,11 @@ pack_default_value() { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_validate -// Access: Published -// Description: Internally unpacks the current numeric or string -// value and validates it against the type range limits, -// but does not return the value. If the current field -// contains nested fields, validates all of them. -//////////////////////////////////////////////////////////////////// +/** + * Internally unpacks the current numeric or string value and validates it + * against the type range limits, but does not return the value. If the + * current field contains nested fields, validates all of them. + */ void DCPacker:: unpack_validate() { nassertv(_mode == M_unpack); @@ -633,8 +579,8 @@ unpack_validate() { _pack_error, _range_error)) { advance(); } else { - // If the single field couldn't be validated, try validating - // nested fields. + // If the single field couldn't be validated, try validating nested + // fields. push(); while (more_nested_fields()) { unpack_validate(); @@ -644,13 +590,10 @@ unpack_validate() { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_skip -// Access: Published -// Description: Skips the current field without unpacking it and -// advances to the next field. If the current field -// contains nested fields, skips all of them. -//////////////////////////////////////////////////////////////////// +/** + * Skips the current field without unpacking it and advances to the next + * field. If the current field contains nested fields, skips all of them. + */ void DCPacker:: unpack_skip() { nassertv(_mode == M_unpack); @@ -674,22 +617,19 @@ unpack_skip() { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_object -// Access: Published -// Description: Packs the Python object of whatever type into the -// packer. Each numeric object and string object maps -// to the corresponding pack_value() call; a tuple or -// sequence maps to a push() followed by all of the -// tuple's contents followed by a pop(). -//////////////////////////////////////////////////////////////////// +/** + * Packs the Python object of whatever type into the packer. Each numeric + * object and string object maps to the corresponding pack_value() call; a + * tuple or sequence maps to a push() followed by all of the tuple's contents + * followed by a pop(). + */ void DCPacker:: pack_object(PyObject *object) { nassertv(_mode == M_pack || _mode == M_repack); DCPackType pack_type = get_pack_type(); - // had to add this for basic 64 and unsigned data to get packed right .. - // Not sure if we can just do the rest this way.. + // had to add this for basic 64 and unsigned data to get packed right .. Not + // sure if we can just do the rest this way.. switch(pack_type) { @@ -791,10 +731,10 @@ pack_object(PyObject *object) { } #endif } else { - // For some reason, PySequence_Check() is incorrectly reporting - // that a class instance is a sequence, even if it doesn't provide - // __len__, so we double-check by testing for __len__ explicitly. - bool is_sequence = + // For some reason, PySequence_Check() is incorrectly reporting that a + // class instance is a sequence, even if it doesn't provide __len__, so we + // double-check by testing for __len__ explicitly. + bool is_sequence = (PySequence_Check(object) != 0) && (PyObject_HasAttrString(object, "__len__") != 0); bool is_instance = false; @@ -805,7 +745,7 @@ pack_object(PyObject *object) { const DCClassParameter *class_param = get_current_field()->as_class_parameter(); if (class_param != (DCClassParameter *)NULL) { dclass = class_param->get_class(); - + if (dclass->has_class_def()) { PyObject *class_def = dclass->get_class_def(); is_instance = (PyObject_IsInstance(object, dclass->get_class_def()) != 0); @@ -814,31 +754,30 @@ pack_object(PyObject *object) { } } - // If dclass is not NULL, the packer is expecting a class object. - // There are then two cases: (1) the user has supplied a matching - // class object, or (2) the user has supplied a sequence object. - // Unfortunately, it may be difficult to differentiate these two - // cases, since a class object may also be a sequence object. + // If dclass is not NULL, the packer is expecting a class object. There + // are then two cases: (1) the user has supplied a matching class object, + // or (2) the user has supplied a sequence object. Unfortunately, it may + // be difficult to differentiate these two cases, since a class object may + // also be a sequence object. // The rule to differentiate them is: - // (1) If the supplied class object is an instance of the expected - // class object, it is considered to be a class object. + // (1) If the supplied class object is an instance of the expected class + // object, it is considered to be a class object. - // (2) Otherwise, if the supplied class object has a __len__() - // method (i.e. PySequence_Check() returns true), then it is - // considered to be a sequence. + // (2) Otherwise, if the supplied class object has a __len__() method + // (i.e. PySequence_Check() returns true), then it is considered to be a + // sequence. // (3) Otherwise, it is considered to be a class object. if (dclass != (DCClass *)NULL && (is_instance || !is_sequence)) { - // The supplied object is either an instance of the expected - // class object, or it is not a sequence--this is case (1) or - // (3). + // The supplied object is either an instance of the expected class + // object, or it is not a sequence--this is case (1) or (3). pack_class_object(dclass, object); } else if (is_sequence) { - // The supplied object is not an instance of the expected class - // object, but it is a sequence. This is case (2). + // The supplied object is not an instance of the expected class object, + // but it is a sequence. This is case (2). push(); int size = PySequence_Size(object); for (int i = 0; i < size; ++i) { @@ -852,9 +791,8 @@ pack_object(PyObject *object) { } pop(); } else { - // The supplied object is not a sequence, and we weren't - // expecting a class parameter. This is none of the above, an - // error. + // The supplied object is not a sequence, and we weren't expecting a + // class parameter. This is none of the above, an error. ostringstream strm; strm << "Don't know how to pack object: " << DCField::get_pystr(object); @@ -866,15 +804,12 @@ pack_object(PyObject *object) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_object -// Access: Published -// Description: Unpacks a Python object of the appropriate type from -// the stream for the current field. This may be an -// integer or a string for a simple field object; if the -// current field represents a list of fields it will be -// a tuple. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks a Python object of the appropriate type from the stream for the + * current field. This may be an integer or a string for a simple field + * object; if the current field represents a list of fields it will be a + * tuple. + */ PyObject *DCPacker:: unpack_object() { PyObject *object = NULL; @@ -894,7 +829,7 @@ unpack_object() { object = PyFloat_FromDouble(value); } break; - + case PT_int: { int value = unpack_int(); @@ -905,7 +840,7 @@ unpack_object() { #endif } break; - + case PT_uint: { unsigned int value = unpack_uint(); @@ -920,14 +855,14 @@ unpack_object() { #endif } break; - + case PT_int64: { PN_int64 value = unpack_int64(); object = PyLong_FromLongLong(value); } break; - + case PT_uint64: { PN_uint64 value = unpack_uint64(); @@ -964,9 +899,8 @@ unpack_object() { if (class_param != (DCClassParameter *)NULL) { const DCClass *dclass = class_param->get_class(); if (dclass->has_class_def()) { - // If we know what kind of class object this is and it has a - // valid constructor, create the class object instead of - // just a tuple. + // If we know what kind of class object this is and it has a valid + // constructor, create the class object instead of just a tuple. object = unpack_class_object(dclass); if (object == (PyObject *)NULL) { cerr << "Unable to construct object of class " @@ -979,8 +913,8 @@ unpack_object() { } // Fall through (if no constructor) - // If we don't know what kind of class object it is, or it doesn't - // have a constructor, fall through and make a tuple. + // If we don't know what kind of class object it is, or it doesn't have a + // constructor, fall through and make a tuple. default: { // First, build up a list from the nested objects. @@ -995,8 +929,8 @@ unpack_object() { pop(); if (pack_type != PT_array) { - // For these other kinds of objects, we'll convert the list - // into a tuple. + // For these other kinds of objects, we'll convert the list into a + // tuple. PyObject *tuple = PyList_AsTuple(object); Py_DECREF(object); object = tuple; @@ -1011,26 +945,22 @@ unpack_object() { #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::parse_and_pack -// Access: Published -// Description: Parses an object's value according to the DC file -// syntax (e.g. as a default value string) and packs it. -// Returns true on success, false on a parse error. -//////////////////////////////////////////////////////////////////// +/** + * Parses an object's value according to the DC file syntax (e.g. as a + * default value string) and packs it. Returns true on success, false on a + * parse error. + */ bool DCPacker:: parse_and_pack(const string &formatted_object) { istringstream strm(formatted_object); return parse_and_pack(strm); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::parse_and_pack -// Access: Published -// Description: Parses an object's value according to the DC file -// syntax (e.g. as a default value string) and packs it. -// Returns true on success, false on a parse error. -//////////////////////////////////////////////////////////////////// +/** + * Parses an object's value according to the DC file syntax (e.g. as a + * default value string) and packs it. Returns true on success, false on a + * parse error. + */ bool DCPacker:: parse_and_pack(istream &in) { dc_init_parser_parameter_value(in, "parse_and_pack", *this); @@ -1045,13 +975,10 @@ parse_and_pack(istream &in) { return !parse_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_and_format -// Access: Published -// Description: Unpacks an object and formats its value into a syntax -// suitable for parsing in the dc file (e.g. as a -// default value), or as an input to parse_object. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks an object and formats its value into a syntax suitable for parsing + * in the dc file (e.g. as a default value), or as an input to parse_object. + */ string DCPacker:: unpack_and_format(bool show_field_names) { ostringstream strm; @@ -1059,13 +986,10 @@ unpack_and_format(bool show_field_names) { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_and_format -// Access: Published -// Description: Unpacks an object and formats its value into a syntax -// suitable for parsing in the dc file (e.g. as a -// default value), or as an input to parse_object. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks an object and formats its value into a syntax suitable for parsing + * in the dc file (e.g. as a default value), or as an input to parse_object. + */ void DCPacker:: unpack_and_format(ostream &out, bool show_field_names) { DCPackType pack_type = get_pack_type(); @@ -1073,7 +997,7 @@ unpack_and_format(ostream &out, bool show_field_names) { if (show_field_names && !get_current_field_name().empty()) { nassertv(_current_field != (DCPackerInterface *)NULL); const DCField *field = _current_field->as_field(); - if (field != (DCField *)NULL && + if (field != (DCField *)NULL && field->as_parameter() != (DCParameter *)NULL) { out << field->get_name() << " = "; } @@ -1087,19 +1011,19 @@ unpack_and_format(ostream &out, bool show_field_names) { case PT_double: out << unpack_double(); break; - + case PT_int: out << unpack_int(); break; - + case PT_uint: out << unpack_uint(); break; - + case PT_int64: out << unpack_int64(); break; - + case PT_uint64: out << unpack_uint64(); break; @@ -1160,11 +1084,9 @@ unpack_and_format(ostream &out, bool show_field_names) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::enquote_string -// Access: Public, Static -// Description: Outputs the indicated string within quotation marks. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated string within quotation marks. + */ void DCPacker:: enquote_string(ostream &out, char quote_mark, const string &str) { out << quote_mark; @@ -1186,11 +1108,9 @@ enquote_string(ostream &out, char quote_mark, const string &str) { out << quote_mark; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::output_hex_string -// Access: Public, Static -// Description: Outputs the indicated string as a hex constant. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated string as a hex constant. + */ void DCPacker:: output_hex_string(ostream &out, const string &str) { out << '<'; @@ -1204,21 +1124,17 @@ output_hex_string(ostream &out, const string &str) { out << '>'; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::handle_switch -// Access: Private -// Description: When we advance past the key field on a switch -// record, we suddenly have more fields available--all -// the appropriate alternate fields in the switch. -// -// This function is called when we detect this -// condition; it switches the _current_parent to the -// appropriate case of the switch record. -//////////////////////////////////////////////////////////////////// +/** + * When we advance past the key field on a switch record, we suddenly have + * more fields available--all the appropriate alternate fields in the switch. + * + * This function is called when we detect this condition; it switches the + * _current_parent to the appropriate case of the switch record. + */ void DCPacker:: handle_switch(const DCSwitchParameter *switch_parameter) { - // First, get the value from the key. This is either found in the - // unpack or the pack data, depending on what mode we're in. + // First, get the value from the key. This is either found in the unpack or + // the pack data, depending on what mode we're in. const DCPackerInterface *new_parent = NULL; if (_mode == M_pack || _mode == M_repack) { @@ -1239,9 +1155,9 @@ handle_switch(const DCSwitchParameter *switch_parameter) { _last_switch = switch_parameter; - // Now substitute in the switch case for the previous parent (which - // replaces the switch node itself). This will suddenly make a slew - // of new fields appear. + // Now substitute in the switch case for the previous parent (which replaces + // the switch node itself). This will suddenly make a slew of new fields + // appear. _current_parent = new_parent; _num_nested_fields = _current_parent->get_num_nested_fields(); @@ -1251,12 +1167,9 @@ handle_switch(const DCSwitchParameter *switch_parameter) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::clear -// Access: Private -// Description: Resets the data structures after a pack or unpack -// sequence. -//////////////////////////////////////////////////////////////////// +/** + * Resets the data structures after a pack or unpack sequence. + */ void DCPacker:: clear() { clear_stack(); @@ -1276,11 +1189,9 @@ clear() { _root = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::clear_stack -// Access: Private -// Description: Empties the stack. -//////////////////////////////////////////////////////////////////// +/** + * Empties the stack. + */ void DCPacker:: clear_stack() { while (_stack != (StackElement *)NULL) { @@ -1291,13 +1202,11 @@ clear_stack() { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::pack_class_object -// Access: Private -// Description: Given that the current element is a ClassParameter -// for a Python class object, try to extract the -// appropriate values from the class object and pack in. -//////////////////////////////////////////////////////////////////// +/** + * Given that the current element is a ClassParameter for a Python class + * object, try to extract the appropriate values from the class object and + * pack in. + */ void DCPacker:: pack_class_object(const DCClass *dclass, PyObject *object) { push(); @@ -1311,13 +1220,10 @@ pack_class_object(const DCClass *dclass, PyObject *object) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::unpack_class_object -// Access: Private -// Description: Given that the current element is a ClassParameter -// for a Python class for which we have a valid -// constructor, unpack it and fill in its values. -//////////////////////////////////////////////////////////////////// +/** + * Given that the current element is a ClassParameter for a Python class for + * which we have a valid constructor, unpack it and fill in its values. + */ PyObject *DCPacker:: unpack_class_object(const DCClass *dclass) { PyObject *class_def = dclass->get_class_def(); @@ -1326,8 +1232,8 @@ unpack_class_object(const DCClass *dclass) { PyObject *object = NULL; if (!dclass->has_constructor()) { - // If the class uses a default constructor, go ahead and create - // the Python object for it now. + // If the class uses a default constructor, go ahead and create the Python + // object for it now. object = PyObject_CallObject(class_def, NULL); if (object == (PyObject *)NULL) { return NULL; @@ -1362,14 +1268,12 @@ unpack_class_object(const DCClass *dclass) { #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::set_class_element -// Access: Private -// Description: Unpacks the current element and stuffs it on the -// Python class object in whatever way is appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current element and stuffs it on the Python class object in + * whatever way is appropriate. + */ void DCPacker:: -set_class_element(PyObject *class_def, PyObject *&object, +set_class_element(PyObject *class_def, PyObject *&object, const DCField *field) { string field_name = field->get_name(); DCPackType pack_type = get_pack_type(); @@ -1378,9 +1282,8 @@ set_class_element(PyObject *class_def, PyObject *&object, switch (pack_type) { case PT_class: case PT_switch: - // If the field has no name, but it is one of these container - // objects, we want to unpack its nested objects directly into - // the class. + // If the field has no name, but it is one of these container objects, + // we want to unpack its nested objects directly into the class. push(); while (more_nested_fields()) { const DCField *field = get_current_field()->as_field(); @@ -1397,16 +1300,16 @@ set_class_element(PyObject *class_def, PyObject *&object, } } else { - // If the field does have a name, we will want to store it on the - // class, either by calling a method (for a PT_field pack_type) or - // by setting a value (for any other kind of pack_type). + // If the field does have a name, we will want to store it on the class, + // either by calling a method (for a PT_field pack_type) or by setting a + // value (for any other kind of pack_type). PyObject *element = unpack_object(); if (pack_type == PT_field) { if (object == (PyObject *)NULL) { - // If the object hasn't been constructed yet, assume this is - // the constructor. + // If the object hasn't been constructed yet, assume this is the + // constructor. object = PyObject_CallObject(class_def, element); } else { @@ -1419,7 +1322,7 @@ set_class_element(PyObject *class_def, PyObject *&object, } } } - + } else { nassertv(object != (PyObject *)NULL); PyObject_SetAttrString(object, (char *)field_name.c_str(), element); @@ -1432,14 +1335,11 @@ set_class_element(PyObject *class_def, PyObject *&object, #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: DCPacker::get_class_element -// Access: Private -// Description: Gets the current element from the Python object and -// packs it. -//////////////////////////////////////////////////////////////////// +/** + * Gets the current element from the Python object and packs it. + */ void DCPacker:: -get_class_element(const DCClass *dclass, PyObject *object, +get_class_element(const DCClass *dclass, PyObject *object, const DCField *field) { string field_name = field->get_name(); DCPackType pack_type = get_pack_type(); @@ -1448,9 +1348,8 @@ get_class_element(const DCClass *dclass, PyObject *object, switch (pack_type) { case PT_class: case PT_switch: - // If the field has no name, but it is one of these container - // objects, we want to get its nested objects directly from - // the class. + // If the field has no name, but it is one of these container objects, + // we want to get its nested objects directly from the class. push(); while (more_nested_fields() && !_pack_error) { const DCField *field = get_current_field()->as_field(); @@ -1466,9 +1365,9 @@ get_class_element(const DCClass *dclass, PyObject *object, } } else { - // If the field does have a name, we will want to get it from the - // class and pack it. It just so happens that there's already a - // method that does this on DCClass. + // If the field does have a name, we will want to get it from the class + // and pack it. It just so happens that there's already a method that + // does this on DCClass. if (!dclass->pack_required_field(*this, object, field)) { _pack_error = true; diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index bbbcb3e2d3..df391a8e48 100644 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -1,16 +1,15 @@ -// Filename: dcPacker.h -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPacker.h + * @author drose + * @date 2004-06-15 + */ #ifndef DCPACKER_H #define DCPACKER_H @@ -25,16 +24,13 @@ class DCClass; class DCSwitchParameter; -//////////////////////////////////////////////////////////////////// -// Class : DCPacker -// Description : This class can be used for packing a series of -// numeric and string data into a binary stream, -// according to the DC specification. -// -// See also direct/src/doc/dcPacker.txt for a more -// complete description and examples of using this -// class. -//////////////////////////////////////////////////////////////////// +/** + * This class can be used for packing a series of numeric and string data into + * a binary stream, according to the DC specification. + * + * See also direct/src/doc/dcPacker.txt for a more complete description and + * examples of using this class. + */ class EXPCL_DIRECT DCPacker { PUBLISHED: DCPacker(); @@ -47,7 +43,7 @@ PUBLISHED: void set_unpack_data(const string &data); public: - void set_unpack_data(const char *unpack_data, size_t unpack_length, + void set_unpack_data(const char *unpack_data, size_t unpack_length, bool owns_unpack_data); PUBLISHED: @@ -93,8 +89,8 @@ PUBLISHED: void unpack_skip(); public: - // The following are variants on the above unpack() calls that pass - // the result back by reference instead of as a return value. + // The following are variants on the above unpack() calls that pass the + // result back by reference instead of as a return value. INLINE void unpack_double(double &value); INLINE void unpack_int(int &value); INLINE void unpack_uint(unsigned int &value); @@ -138,9 +134,9 @@ public: PUBLISHED: INLINE static int get_num_stack_elements_ever_allocated(); - // The following methods are used only for packing (or unpacking) - // raw data into the buffer between packing sessions (e.g. between - // calls to end_pack() and the next begin_pack()). + // The following methods are used only for packing (or unpacking) raw data + // into the buffer between packing sessions (e.g. between calls to + // end_pack() and the next begin_pack()). INLINE void raw_pack_int8(int value); INLINE void raw_pack_int16(int value); @@ -153,11 +149,11 @@ PUBLISHED: INLINE void raw_pack_float64(double value); INLINE void raw_pack_string(const string &value); -// this is a hack to allw me to get in and out of 32bit Mode Faster -// need to agree with channel_type in dcbase.h +// this is a hack to allw me to get in and out of 32bit Mode Faster need to +// agree with channel_type in dcbase.h #define RAW_PACK_CHANNEL(in) raw_pack_uint64(in) #define RAW_UNPACK_CHANNEL() raw_unpack_uint64() - + INLINE int raw_unpack_int8(); INLINE int raw_unpack_int16(); @@ -195,9 +191,9 @@ private: #ifdef HAVE_PYTHON void pack_class_object(const DCClass *dclass, PyObject *object); PyObject *unpack_class_object(const DCClass *dclass); - void set_class_element(PyObject *class_def, PyObject *&object, + void set_class_element(PyObject *class_def, PyObject *&object, const DCField *field); - void get_class_element(const DCClass *dclass, PyObject *object, + void get_class_element(const DCClass *dclass, PyObject *object, const DCField *field); #endif @@ -222,8 +218,8 @@ private: class EXPCL_DIRECT StackElement { public: - // As an optimization, we implement operator new and delete here - // to minimize allocation overhead during push() and pop(). + // As an optimization, we implement operator new and delete here to + // minimize allocation overhead during push() and pop(). INLINE void *operator new(size_t size); INLINE void operator delete(void *ptr); @@ -242,14 +238,12 @@ private: const DCPackerInterface *_current_parent; int _current_field_index; - // _push_marker marks the beginning of the push record (so we can go - // back and write in the length later, or figure out the switch - // parameter). + // _push_marker marks the beginning of the push record (so we can go back + // and write in the length later, or figure out the switch parameter). size_t _push_marker; - // _pop_marker is used in unpack mode with certain data structures - // (like dynamic arrays) to mark the end of the push record (so we - // know when we've reached the end). It is zero when it is not in - // use. + // _pop_marker is used in unpack mode with certain data structures (like + // dynamic arrays) to mark the end of the push record (so we know when we've + // reached the end). It is zero when it is not in use. size_t _pop_marker; int _num_nested_fields; const DCSwitchParameter *_last_switch; diff --git a/direct/src/dcparser/dcPackerCatalog.I b/direct/src/dcparser/dcPackerCatalog.I index 3862e78ed2..657609927d 100644 --- a/direct/src/dcparser/dcPackerCatalog.I +++ b/direct/src/dcparser/dcPackerCatalog.I @@ -1,104 +1,82 @@ -// Filename: dcPackerCatalog.I -// Created by: drose (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerCatalog.I + * @author drose + * @date 2004-06-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::get_begin -// Access: Public -// Description: Returns the beginning of the indicated field within -// the live data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the beginning of the indicated field within the live data. + */ INLINE size_t DCPackerCatalog::LiveCatalog:: get_begin(int n) const { nassertr(n >= 0 && n < (int)_live_entries.size(), 0); return _live_entries[n]._begin; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::get_end -// Access: Public -// Description: Returns the end of the indicated field (the byte -// position of the first following field) within the -// live data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the end of the indicated field (the byte position of the first + * following field) within the live data. + */ INLINE size_t DCPackerCatalog::LiveCatalog:: get_end(int n) const { nassertr(n >= 0 && n < (int)_live_entries.size(), 0); return _live_entries[n]._end; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::get_num_entries -// Access: Public -// Description: Returns the number of entries in the catalog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the catalog. + */ INLINE int DCPackerCatalog::LiveCatalog:: get_num_entries() const { return _catalog->get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::get_entry -// Access: Public -// Description: Returns the nth entry in the catalog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth entry in the catalog. + */ INLINE const DCPackerCatalog::Entry &DCPackerCatalog::LiveCatalog:: get_entry(int n) const { return _catalog->get_entry(n); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::find_entry_by_name -// Access: Public -// Description: Returns the index number of the entry with the -// indicated name, or -1 if no entry has the indicated -// name. The return value is suitable for passing to -// get_entry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the entry with the indicated name, or -1 if no + * entry has the indicated name. The return value is suitable for passing to + * get_entry(). + */ int DCPackerCatalog::LiveCatalog:: find_entry_by_name(const string &name) const { return _catalog->find_entry_by_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::LiveCatalog::find_entry_by_field -// Access: Public -// Description: Returns the index number of the entry with the -// indicated field, or -1 if no entry has the indicated -// field. The return value is suitable for passing to -// get_entry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the entry with the indicated field, or -1 if no + * entry has the indicated field. The return value is suitable for passing to + * get_entry(). + */ int DCPackerCatalog::LiveCatalog:: find_entry_by_field(const DCPackerInterface *field) const { return _catalog->find_entry_by_field(field); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::get_num_entries -// Access: Public -// Description: Returns the number of entries in the catalog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the catalog. + */ INLINE int DCPackerCatalog:: get_num_entries() const { return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::get_entry -// Access: Public -// Description: Returns the nth entry in the catalog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth entry in the catalog. + */ INLINE const DCPackerCatalog::Entry &DCPackerCatalog:: get_entry(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), _entries[0]); diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index ca5e001ede..0f13322009 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -1,39 +1,32 @@ -// Filename: dcPackerCatalog.cxx -// Created by: drose (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerCatalog.cxx + * @author drose + * @date 2004-06-21 + */ #include "dcPackerCatalog.h" #include "dcPackerInterface.h" #include "dcPacker.h" #include "dcSwitchParameter.h" -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::Constructor -// Access: Private -// Description: The catalog is created only by -// DCPackerInterface::get_catalog(). -//////////////////////////////////////////////////////////////////// +/** + * The catalog is created only by DCPackerInterface::get_catalog(). + */ DCPackerCatalog:: DCPackerCatalog(const DCPackerInterface *root) : _root(root) { _live_catalog = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::Copy Constructor -// Access: Private -// Description: The copy constructor is used only internally, in -// update_switch_fields(). -//////////////////////////////////////////////////////////////////// +/** + * The copy constructor is used only internally, in update_switch_fields(). + */ DCPackerCatalog:: DCPackerCatalog(const DCPackerCatalog ©) : _root(copy._root), @@ -44,12 +37,9 @@ DCPackerCatalog(const DCPackerCatalog ©) : _live_catalog = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::Destructor -// Access: Private -// Description: The catalog is destroyed only by -// ~DCPackerInterface(). -//////////////////////////////////////////////////////////////////// +/** + * The catalog is destroyed only by ~DCPackerInterface(). + */ DCPackerCatalog:: ~DCPackerCatalog() { if (_live_catalog != (LiveCatalog *)NULL) { @@ -62,14 +52,11 @@ DCPackerCatalog:: } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::find_entry_by_name -// Access: Public -// Description: Returns the index number of the entry with the -// indicated name, or -1 if no entry has the indicated -// name. The return value is suitable for passing to -// get_entry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the entry with the indicated name, or -1 if no + * entry has the indicated name. The return value is suitable for passing to + * get_entry(). + */ int DCPackerCatalog:: find_entry_by_name(const string &name) const { EntriesByName::const_iterator ni; @@ -80,14 +67,11 @@ find_entry_by_name(const string &name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::find_entry_by_field -// Access: Public -// Description: Returns the index number of the entry with the -// indicated field, or -1 if no entry has the indicated -// field. The return value is suitable for passing to -// get_entry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the entry with the indicated field, or -1 if no + * entry has the indicated field. The return value is suitable for passing to + * get_entry(). + */ int DCPackerCatalog:: find_entry_by_field(const DCPackerInterface *field) const { EntriesByField::const_iterator ni; @@ -98,23 +82,19 @@ find_entry_by_field(const DCPackerInterface *field) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::get_live_catalog -// Access: Public -// Description: Returns a LiveCatalog object indicating the positions -// within the indicated data record of each field within -// the catalog. If the catalog's fields are all -// fixed-width, this may return a statically-allocated -// LiveCatalog object that is the same for all data -// records; otherwise, it will allocate a new -// LiveCatalog object that must be freed with a later -// call to release_live_catalog(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a LiveCatalog object indicating the positions within the indicated + * data record of each field within the catalog. If the catalog's fields are + * all fixed-width, this may return a statically-allocated LiveCatalog object + * that is the same for all data records; otherwise, it will allocate a new + * LiveCatalog object that must be freed with a later call to + * release_live_catalog(). + */ const DCPackerCatalog::LiveCatalog *DCPackerCatalog:: get_live_catalog(const char *data, size_t length) const { if (_live_catalog != (LiveCatalog *)NULL) { - // Return the previously-allocated live catalog; it will be the - // same as this one since it's based on a fixed-length field. + // Return the previously-allocated live catalog; it will be the same as + // this one since it's based on a fixed-length field. return _live_catalog; } @@ -127,7 +107,7 @@ get_live_catalog(const char *data, size_t length) const { for (size_t i = 0; i < _entries.size(); i++) { live_catalog->_live_entries.push_back(zero_entry); } - + DCPacker packer; packer.set_unpack_data(data, length, false); packer.begin_unpack(_root); @@ -141,27 +121,23 @@ get_live_catalog(const char *data, size_t length) const { } if (_root->has_fixed_structure()) { - // If our root field has a fixed structure, then the live catalog - // will always be the same every time, so we might as well keep - // this one around as an optimization. + // If our root field has a fixed structure, then the live catalog will + // always be the same every time, so we might as well keep this one around + // as an optimization. ((DCPackerCatalog *)this)->_live_catalog = live_catalog; } return live_catalog; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::release_live_catalog -// Access: Public -// Description: Releases the LiveCatalog object that was returned by -// an earlier call to get_live_catalog(). If this -// represents a newly-allocated live catalog, it will -// free it; otherwise, it will do nothing. -// -// It is therefore always correct (and necessary) to -// match a call to get_live_catalog() with a later call -// to release_live_catalog(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the LiveCatalog object that was returned by an earlier call to + * get_live_catalog(). If this represents a newly-allocated live catalog, it + * will free it; otherwise, it will do nothing. + * + * It is therefore always correct (and necessary) to match a call to + * get_live_catalog() with a later call to release_live_catalog(). + */ void DCPackerCatalog:: release_live_catalog(const DCPackerCatalog::LiveCatalog *live_catalog) const { if (live_catalog != _live_catalog) { @@ -169,12 +145,10 @@ release_live_catalog(const DCPackerCatalog::LiveCatalog *live_catalog) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::add_entry -// Access: Private -// Description: Called only by DCPackerInterface::r_fill_catalog(), -// this adds a new entry to the catalog. -//////////////////////////////////////////////////////////////////// +/** + * Called only by DCPackerInterface::r_fill_catalog(), this adds a new entry + * to the catalog. + */ void DCPackerCatalog:: add_entry(const string &name, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index) { @@ -188,31 +162,27 @@ add_entry(const string &name, const DCPackerInterface *field, _entries.push_back(entry); _entries_by_field.insert(EntriesByField::value_type(field, entry_index)); - // Add an entry for the fully-qualified field name - // (e.g. dna.topTex). If there was another entry for this name - // previously, completely replace it--the fully-qualified name is - // supposed to be unique and trumps the local field names (which are - // not necessarily unique). + // Add an entry for the fully-qualified field name (e.g. dna.topTex). If + // there was another entry for this name previously, completely replace it-- + // the fully-qualified name is supposed to be unique and trumps the local + // field names (which are not necessarily unique). _entries_by_name[name] = entry_index; // We'll also add an entry for the local field name, for the user's - // convenience. This won't override a fully-qualified name that - // might already have been recorded, and a fully-qualified name - // discovered later that conflicts with this name will replace it. + // convenience. This won't override a fully-qualified name that might + // already have been recorded, and a fully-qualified name discovered later + // that conflicts with this name will replace it. string local_name = field->get_name(); if (local_name != name) { _entries_by_name.insert(EntriesByName::value_type(local_name, entry_index)); } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::r_fill_catalog -// Access: Private -// Description: Called by DCPackerInterface to recursively fill up a -// newly-allocated reference catalog. Also called by -// update_switch_fields to append fields to a catalog -// after a DCSwitch node is selected. -//////////////////////////////////////////////////////////////////// +/** + * Called by DCPackerInterface to recursively fill up a newly-allocated + * reference catalog. Also called by update_switch_fields to append fields to + * a catalog after a DCSwitch node is selected. + */ void DCPackerCatalog:: r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index) { @@ -230,9 +200,8 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, if (switch_parameter != (DCSwitchParameter *)NULL) { // If we come upon a DCSwitch while building the catalog, save the // name_prefix at this point so we'll have it again when we later - // encounter the switch while unpacking a live record (and so we - // can return to this point in the recursion from - // update_switch_fields). + // encounter the switch while unpacking a live record (and so we can + // return to this point in the recursion from update_switch_fields). _switch_prefixes[switch_parameter] = next_name_prefix; } @@ -249,13 +218,10 @@ r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::r_fill_live_catalog -// Access: Private -// Description: Recursively walks through all of the fields on the -// catalog and fills the live catalog with the -// appropriate offsets. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through all of the fields on the catalog and fills the + * live catalog with the appropriate offsets. + */ void DCPackerCatalog:: r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, const DCSwitchParameter *&last_switch) const { @@ -267,7 +233,7 @@ r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, live_catalog->_live_entries[field_index]._begin = packer.get_num_unpacked_bytes(); } - if (packer.has_nested_fields() && + if (packer.has_nested_fields() && (packer.get_pack_type() != PT_string && packer.get_pack_type() != PT_blob)) { packer.push(); while (packer.more_nested_fields()) { @@ -284,48 +250,42 @@ r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, } if (last_switch != packer.get_last_switch()) { - // We've just invoked a new DCSwitch. That means we must add the - // new fields revealed by the switch to the reference catalog. + // We've just invoked a new DCSwitch. That means we must add the new + // fields revealed by the switch to the reference catalog. last_switch = packer.get_last_switch(); const DCPackerInterface *switch_case = packer.get_current_parent(); nassertv(switch_case != (DCPackerInterface *)NULL); - const DCPackerCatalog *switch_catalog = + const DCPackerCatalog *switch_catalog = live_catalog->_catalog->update_switch_fields(last_switch, switch_case); nassertv(switch_catalog != (DCPackerCatalog *)NULL); live_catalog->_catalog = switch_catalog; - // And we also have to expand the live catalog to hold the new - // entries. + // And we also have to expand the live catalog to hold the new entries. LiveCatalogEntry zero_entry; zero_entry._begin = 0; zero_entry._end = 0; - for (size_t i = live_catalog->_live_entries.size(); - i < switch_catalog->_entries.size(); + for (size_t i = live_catalog->_live_entries.size(); + i < switch_catalog->_entries.size(); i++) { live_catalog->_live_entries.push_back(zero_entry); } } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerCatalog::update_switch_fields -// Access: Private -// Description: Returns a new DCPackerCatalog that includes all of -// the fields in this object, with the addition of the -// fields named by switch_case. -// -// This is used to implement switches, which change the -// set of fields they make available according to the -// data in the record, and therefore present a different -// catalog under different circumstances. -// -// This returned pointer is allocated one time for each -// different switch_case instance; if a given same -// switch_case is supplied twice, the same pointer is -// returned both times. The ownership of the returned -// pointer is kept by this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new DCPackerCatalog that includes all of the fields in this + * object, with the addition of the fields named by switch_case. + * + * This is used to implement switches, which change the set of fields they + * make available according to the data in the record, and therefore present a + * different catalog under different circumstances. + * + * This returned pointer is allocated one time for each different switch_case + * instance; if a given same switch_case is supplied twice, the same pointer + * is returned both times. The ownership of the returned pointer is kept by + * this object. + */ const DCPackerCatalog *DCPackerCatalog:: update_switch_fields(const DCSwitchParameter *switch_parameter, const DCPackerInterface *switch_case) const { @@ -334,28 +294,26 @@ update_switch_fields(const DCSwitchParameter *switch_parameter, return (*si).second; } - // Look up the name_prefix will we use for all of the fields that - // descend from this switch. This should be stored in this record - // because we must have come across the DCSwitch when building the - // catalog the first time. + // Look up the name_prefix will we use for all of the fields that descend + // from this switch. This should be stored in this record because we must + // have come across the DCSwitch when building the catalog the first time. SwitchPrefixes::const_iterator pi = _switch_prefixes.find(switch_parameter); if (pi == _switch_prefixes.end()) { - // If it's not stored in the record, the switch must be hidden - // within some non-seekable object, like an array; in this case, - // never mind. + // If it's not stored in the record, the switch must be hidden within some + // non-seekable object, like an array; in this case, never mind. return this; } string name_prefix = (*pi).second; - // Start by creating a new DCPackerCatalog object that contains all - // of the fields that this one contains. + // Start by creating a new DCPackerCatalog object that contains all of the + // fields that this one contains. DCPackerCatalog *switch_catalog = new DCPackerCatalog(*this); - // Now record all of the fields of the switch case in the new - // catalog. We start with the second field of the switch case, - // since the first field will be the switch parameter itself, which - // we would have already recorded the first time around. + // Now record all of the fields of the switch case in the new catalog. We + // start with the second field of the switch case, since the first field + // will be the switch parameter itself, which we would have already recorded + // the first time around. int num_nested = switch_case->get_num_nested_fields(); for (int i = 1; i < num_nested; i++) { DCPackerInterface *nested = switch_case->get_nested_field(i); @@ -364,8 +322,8 @@ update_switch_fields(const DCSwitchParameter *switch_parameter, } } - // Store the newly-generated switch catalog in the record so the - // same pointer can be returned in the future. + // Store the newly-generated switch catalog in the record so the same + // pointer can be returned in the future. ((DCPackerCatalog *)this)->_switch_catalogs[switch_case] = switch_catalog; return switch_catalog; diff --git a/direct/src/dcparser/dcPackerCatalog.h b/direct/src/dcparser/dcPackerCatalog.h index 09c635ffc4..70c75e2d1a 100644 --- a/direct/src/dcparser/dcPackerCatalog.h +++ b/direct/src/dcparser/dcPackerCatalog.h @@ -1,16 +1,15 @@ -// Filename: dcPackerCatalog.h -// Created by: drose (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerCatalog.h + * @author drose + * @date 2004-06-21 + */ #ifndef DCPACKERCATALOG_H #define DCPACKERCATALOG_H @@ -21,14 +20,12 @@ class DCPackerInterface; class DCPacker; class DCSwitchParameter; -//////////////////////////////////////////////////////////////////// -// Class : DCPackerCatalog -// Description : This object contains the names of all of the nested -// fields available within a particular field. It is -// created on demand when a catalog is first requested -// from a particular field; its ownership is retained by -// the field so it must not be deleted. -//////////////////////////////////////////////////////////////////// +/** + * This object contains the names of all of the nested fields available within + * a particular field. It is created on demand when a catalog is first + * requested from a particular field; its ownership is retained by the field + * so it must not be deleted. + */ class EXPCL_DIRECT DCPackerCatalog { private: DCPackerCatalog(const DCPackerInterface *root); @@ -36,8 +33,8 @@ private: ~DCPackerCatalog(); public: - // The Entry class records the static catalog data: the name of each - // field and its relationship to its parent. + // The Entry class records the static catalog data: the name of each field + // and its relationship to its parent. class Entry { public: string _name; @@ -46,10 +43,9 @@ public: int _field_index; }; - // The LiveCatalog class adds the dynamic catalog data: the actual - // location of each field within the data record. This might be - // different for different data records (since some data fields have - // a dynamic length). + // The LiveCatalog class adds the dynamic catalog data: the actual location + // of each field within the data record. This might be different for + // different data records (since some data fields have a dynamic length). class LiveCatalogEntry { public: size_t _begin; @@ -84,7 +80,7 @@ public: private: void add_entry(const string &name, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index); - + void r_fill_catalog(const string &name_prefix, const DCPackerInterface *field, const DCPackerInterface *parent, int field_index); void r_fill_live_catalog(LiveCatalog *live_catalog, DCPacker &packer, @@ -92,11 +88,11 @@ private: const DCPackerCatalog *update_switch_fields(const DCSwitchParameter *dswitch, const DCPackerInterface *switch_case) const; - + const DCPackerInterface *_root; LiveCatalog *_live_catalog; - + typedef pvector Entries; Entries _entries; diff --git a/direct/src/dcparser/dcPackerInterface.I b/direct/src/dcparser/dcPackerInterface.I index 49765d85b2..e9ab9f2fb8 100644 --- a/direct/src/dcparser/dcPackerInterface.I +++ b/direct/src/dcparser/dcPackerInterface.I @@ -1,172 +1,135 @@ -// Filename: dcPackerInterface.I -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerInterface.I + * @author drose + * @date 2004-06-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_name -// Access: Published -// Description: Returns the name of this field, or empty string -// if the field is unnamed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this field, or empty string if the field is unnamed. + */ INLINE const string &DCPackerInterface:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::check_match -// Access: Published -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ INLINE bool DCPackerInterface:: check_match(const DCPackerInterface *other) const { return do_check_match(other); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::has_fixed_byte_size -// Access: Public -// Description: Returns true if this field type always packs to the -// same number of bytes, false if it is variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field type always packs to the same number of bytes, + * false if it is variable. + */ INLINE bool DCPackerInterface:: has_fixed_byte_size() const { return _has_fixed_byte_size; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_fixed_byte_size -// Access: Public -// Description: If has_fixed_byte_size() returns true, this returns -// the number of bytes this field type will use. -//////////////////////////////////////////////////////////////////// +/** + * If has_fixed_byte_size() returns true, this returns the number of bytes + * this field type will use. + */ INLINE size_t DCPackerInterface:: get_fixed_byte_size() const { return _fixed_byte_size; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::has_fixed_structure -// Access: Public -// Description: Returns true if this field type always has the same -// structure regardless of the data in the stream, or -// false if its structure may vary. This is almost, but -// not quite, the same thing as has_fixed_byte_size. -// The difference is that a DCSwitch may have multiple -// cases all with the same byte size, but they will -// still (presumably) have different structures, in the -// sense that the actual list of fields varies according -// to the live data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field type always has the same structure regardless of + * the data in the stream, or false if its structure may vary. This is + * almost, but not quite, the same thing as has_fixed_byte_size. The + * difference is that a DCSwitch may have multiple cases all with the same + * byte size, but they will still (presumably) have different structures, in + * the sense that the actual list of fields varies according to the live data. + */ INLINE bool DCPackerInterface:: has_fixed_structure() const { return _has_fixed_structure; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::has_range_limits -// Access: Public -// Description: Returns true if this field, or any sub-field of this -// field, has a limit imposed in the DC file on its -// legal values. If this is false, then -// unpack_validate() is trivial. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field, or any sub-field of this field, has a limit + * imposed in the DC file on its legal values. If this is false, then + * unpack_validate() is trivial. + */ INLINE bool DCPackerInterface:: has_range_limits() const { return _has_range_limits; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_num_length_bytes -// Access: Public -// Description: Returns the number of bytes that should be written -// into the stream on a push() to record the number of -// bytes in the record up until the next pop(). This is -// only meaningful if _has_nested_fields is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that should be written into the stream on a + * push() to record the number of bytes in the record up until the next pop(). + * This is only meaningful if _has_nested_fields is true. + */ INLINE size_t DCPackerInterface:: get_num_length_bytes() const { return _num_length_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::has_nested_fields -// Access: Public -// Description: Returns true if this field type has any nested fields -// (and thus expects a push() .. pop() interface to the -// DCPacker), or false otherwise. If this returns true, -// get_num_nested_fields() may be called to determine -// how many nested fields are expected. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field type has any nested fields (and thus expects a + * push() .. pop() interface to the DCPacker), or false otherwise. If this + * returns true, get_num_nested_fields() may be called to determine how many + * nested fields are expected. + */ INLINE bool DCPackerInterface:: has_nested_fields() const { return _has_nested_fields; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_num_nested_fields -// Access: Public -// Description: Returns the number of nested fields required by this -// field type. These may be array elements or structure -// elements. The return value may be -1 to indicate the -// number of nested fields is variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested fields required by this field type. These may + * be array elements or structure elements. The return value may be -1 to + * indicate the number of nested fields is variable. + */ INLINE int DCPackerInterface:: get_num_nested_fields() const { return _num_nested_fields; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_pack_type -// Access: Public -// Description: Returns the type of value expected by this field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of value expected by this field. + */ INLINE DCPackType DCPackerInterface:: get_pack_type() const { return _pack_type; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_int8 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_int8(char *buffer, int value) { buffer[0] = (char)(value & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_int16 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_int16(char *buffer, int value) { buffer[0] = (char)(value & 0xff); buffer[1] = (char)((value >> 8) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_int32 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_int32(char *buffer, int value) { buffer[0] = (char)(value & 0xff); @@ -175,11 +138,9 @@ do_pack_int32(char *buffer, int value) { buffer[3] = (char)((value >> 24) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_int64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_int64(char *buffer, PN_int64 value) { buffer[0] = (char)(value & 0xff); @@ -192,32 +153,26 @@ do_pack_int64(char *buffer, PN_int64 value) { buffer[7] = (char)((value >> 56) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_uint8 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_uint8(char *buffer, unsigned int value) { buffer[0] = (char)(value & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_uint16 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_uint16(char *buffer, unsigned int value) { buffer[0] = (char)(value & 0xff); buffer[1] = (char)((value >> 8) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_uint32 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_uint32(char *buffer, unsigned int value) { buffer[0] = (char)(value & 0xff); @@ -226,11 +181,9 @@ do_pack_uint32(char *buffer, unsigned int value) { buffer[3] = (char)((value >> 24) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_uint64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_uint64(char *buffer, PN_uint64 value) { buffer[0] = (char)(value & 0xff); @@ -243,11 +196,9 @@ do_pack_uint64(char *buffer, PN_uint64 value) { buffer[7] = (char)((value >> 56) & 0xff); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_pack_float64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DCPackerInterface:: do_pack_float64(char *buffer, double value) { #ifdef WORDS_BIGENDIAN @@ -262,32 +213,26 @@ do_pack_float64(char *buffer, double value) { } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_int8 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DCPackerInterface:: do_unpack_int8(const char *buffer) { return (int)(signed char)buffer[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_int16 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DCPackerInterface:: do_unpack_int16(const char *buffer) { return (int)((unsigned int)(unsigned char)buffer[0] | ((int)(signed char)buffer[1] << 8)); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_int32 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DCPackerInterface:: do_unpack_int32(const char *buffer) { return (int)((unsigned int)(unsigned char)buffer[0] | @@ -296,11 +241,9 @@ do_unpack_int32(const char *buffer) { ((int)(signed char)buffer[3] << 24)); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_int64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_int64 DCPackerInterface:: do_unpack_int64(const char *buffer) { return (PN_int64)((PN_uint64)(unsigned char)buffer[0] | @@ -312,32 +255,26 @@ do_unpack_int64(const char *buffer) { ((PN_uint64)(unsigned char)buffer[6] << 48) | ((PN_int64)(signed char)buffer[7] << 54)); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_uint8 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int DCPackerInterface:: do_unpack_uint8(const char *buffer) { return (unsigned int)(unsigned char)buffer[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_uint16 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int DCPackerInterface:: do_unpack_uint16(const char *buffer) { return ((unsigned int)(unsigned char)buffer[0] | ((unsigned int)(unsigned char)buffer[1] << 8)); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_uint32 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int DCPackerInterface:: do_unpack_uint32(const char *buffer) { return ((unsigned int)(unsigned char)buffer[0] | @@ -346,11 +283,9 @@ do_unpack_uint32(const char *buffer) { ((unsigned int)(unsigned char)buffer[3] << 24)); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_uint64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_uint64 DCPackerInterface:: do_unpack_uint64(const char *buffer) { return ((PN_uint64)(unsigned char)buffer[0] | @@ -364,16 +299,14 @@ do_unpack_uint64(const char *buffer) { } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_unpack_float64 -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double DCPackerInterface:: do_unpack_float64(const char *buffer) { #ifdef WORDS_BIGENDIAN char reverse[8]; - + // Reverse the byte ordering for big-endian machines. for (size_t i = 0; i < 8; i++) { reverse[i] = buffer[7 - i]; @@ -381,37 +314,33 @@ do_unpack_float64(const char *buffer) { return *(double *)reverse; #else return *(double *)buffer; -#endif // WORDS_BIGENDIAN +#endif // WORDS_BIGENDIAN } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::validate_int_limits -// Access: Public, Static -// Description: Confirms that the signed value fits within num_bits -// bits. Sets range_error true if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Confirms that the signed value fits within num_bits bits. Sets range_error + * true if it does not. + */ INLINE void DCPackerInterface:: validate_int_limits(int value, int num_bits, bool &range_error) { - // What we're really checking is that all of the bits above the - // lower (num_bits - 1) bits are the same--either all 1 or all 0. + // What we're really checking is that all of the bits above the lower + // (num_bits - 1) bits are the same--either all 1 or all 0. // First, turn on the lower (num_bits - 1). int mask = ((int)1 << (num_bits - 1)) - 1; value |= mask; - // The result should be either mask (all high bits are 0) or -1 (all - // high bits are 1). If it is anything else we have a range error. + // The result should be either mask (all high bits are 0) or -1 (all high + // bits are 1). If it is anything else we have a range error. if (value != mask && value != -1) { range_error = true; } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::validate_int64_limits -// Access: Public, Static -// Description: Confirms that the signed value fits within num_bits -// bits. Sets range_error true if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Confirms that the signed value fits within num_bits bits. Sets range_error + * true if it does not. + */ INLINE void DCPackerInterface:: validate_int64_limits(PN_int64 value, int num_bits, bool &range_error) { PN_int64 mask = ((PN_int64)1 << (num_bits - 1)) - 1; @@ -422,16 +351,14 @@ validate_int64_limits(PN_int64 value, int num_bits, bool &range_error) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::validate_uint_limits -// Access: Public, Static -// Description: Confirms that the unsigned value fits within num_bits -// bits. Sets range_error true if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Confirms that the unsigned value fits within num_bits bits. Sets + * range_error true if it does not. + */ INLINE void DCPackerInterface:: validate_uint_limits(unsigned int value, int num_bits, bool &range_error) { - // Here we're really checking that all of the bits above the lower - // num_bits bits are all 0. + // Here we're really checking that all of the bits above the lower num_bits + // bits are all 0. unsigned int mask = ((unsigned int)1 << num_bits) - 1; value &= ~mask; @@ -441,12 +368,10 @@ validate_uint_limits(unsigned int value, int num_bits, bool &range_error) { } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::validate_uint64_limits -// Access: Public, Static -// Description: Confirms that the unsigned value fits within num_bits -// bits. Sets range_error true if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Confirms that the unsigned value fits within num_bits bits. Sets + * range_error true if it does not. + */ INLINE void DCPackerInterface:: validate_uint64_limits(PN_uint64 value, int num_bits, bool &range_error) { PN_uint64 mask = ((PN_uint64)1 << num_bits) - 1; diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index 19ba983985..796d11039a 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -1,16 +1,15 @@ -// Filename: dcPackerInterface.cxx -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerInterface.cxx + * @author drose + * @date 2004-06-15 + */ #include "dcPackerInterface.h" #include "dcPackerCatalog.h" @@ -18,11 +17,9 @@ #include "dcParserDefs.h" #include "dcLexerDefs.h" -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCPackerInterface:: DCPackerInterface(const string &name) : _name(name) @@ -38,11 +35,9 @@ DCPackerInterface(const string &name) : _catalog = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCPackerInterface:: DCPackerInterface(const DCPackerInterface ©) : _name(copy._name), @@ -58,11 +53,9 @@ DCPackerInterface(const DCPackerInterface ©) : _catalog = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCPackerInterface:: ~DCPackerInterface() { if (_catalog != (DCPackerCatalog *)NULL) { @@ -70,99 +63,78 @@ DCPackerInterface:: } } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::find_seek_index -// Access: Published -// Description: Returns the index number to be passed to a future -// call to DCPacker::seek() to seek directly to the -// named field without having to look up the field name -// in a table later, or -1 if the named field cannot be -// found. -// -// If the named field is nested within a switch or some -// similar dynamic structure that reveals different -// fields based on the contents of the data, this -// mechanism cannot be used to pre-fetch the field index -// number--you must seek for the field by name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number to be passed to a future call to DCPacker::seek() + * to seek directly to the named field without having to look up the field + * name in a table later, or -1 if the named field cannot be found. + * + * If the named field is nested within a switch or some similar dynamic + * structure that reveals different fields based on the contents of the data, + * this mechanism cannot be used to pre-fetch the field index number--you must + * seek for the field by name. + */ int DCPackerInterface:: find_seek_index(const string &name) const { return get_catalog()->find_entry_by_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_field -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCField *DCPackerInterface:: as_field() { return (DCField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_field -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCField *DCPackerInterface:: as_field() const { return (DCField *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitchParameter *DCPackerInterface:: as_switch_parameter() { return (DCSwitchParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSwitchParameter *DCPackerInterface:: as_switch_parameter() const { return (DCSwitchParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClassParameter *DCPackerInterface:: as_class_parameter() { return (DCClassParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCClassParameter *DCPackerInterface:: as_class_parameter() const { return (DCClassParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::check_match -// Access: Published -// Description: Returns true if this interface is bitwise the same as -// the interface described with the indicated formatted -// string, e.g. "(uint8, uint8, int16)", or false -// otherwise. -// -// If DCFile is not NULL, it specifies the DCFile that -// was previously loaded, from which some predefined -// structs and typedefs may be referenced in the -// description string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this interface is bitwise the same as the interface + * described with the indicated formatted string, e.g. "(uint8, uint8, + * int16)", or false otherwise. + * + * If DCFile is not NULL, it specifies the DCFile that was previously loaded, + * from which some predefined structs and typedefs may be referenced in the + * description string. + */ bool DCPackerInterface:: check_match(const string &description, DCFile *dcfile) const { bool match = false; @@ -186,214 +158,158 @@ check_match(const string &description, DCFile *dcfile) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::set_name -// Access: Public, Virtual -// Description: Sets the name of this field. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of this field. + */ void DCPackerInterface:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::calc_num_nested_fields -// Access: Public, Virtual -// Description: This flavor of get_num_nested_fields is used during -// unpacking. It returns the number of nested fields to -// expect, given a certain length in bytes (as read from -// the _num_length_bytes stored in the stream on the -// push). This will only be called if _num_length_bytes -// is nonzero. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_num_nested_fields is used during unpacking. It returns + * the number of nested fields to expect, given a certain length in bytes (as + * read from the _num_length_bytes stored in the stream on the push). This + * will only be called if _num_length_bytes is nonzero. + */ int DCPackerInterface:: calc_num_nested_fields(size_t) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCPackerInterface:: get_nested_field(int) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::validate_num_nested_fields -// Access: Public, Virtual -// Description: After a number of fields have been packed via push() -// .. pack_*() .. pop(), this is called to confirm that -// the number of nested fields that were added is valid -// for this type. This is primarily useful for array -// types with dynamic ranges that can't validate the -// number of fields any other way. -//////////////////////////////////////////////////////////////////// +/** + * After a number of fields have been packed via push() .. pack_*() .. pop(), + * this is called to confirm that the number of nested fields that were added + * is valid for this type. This is primarily useful for array types with + * dynamic ranges that can't validate the number of fields any other way. + */ bool DCPackerInterface:: validate_num_nested_fields(int) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_double -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_double(DCPackData &, double, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_int -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_int(DCPackData &, int, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_uint -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_uint(DCPackData &, unsigned int, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_int64 -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_int64(DCPackData &, PN_int64, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_uint64 -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_uint64(DCPackData &, PN_uint64, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_string -// Access: Public, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCPackerInterface:: pack_string(DCPackData &, const string &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::pack_default_value -// Access: Public, Virtual -// Description: Packs the field's specified default value (or a -// sensible default if no value is specified) into the -// stream. Returns true if the default value is packed, -// false if the field doesn't know how to pack its -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the field's specified default value (or a sensible default if no + * value is specified) into the stream. Returns true if the default value is + * packed, false if the field doesn't know how to pack its default value. + */ bool DCPackerInterface:: pack_default_value(DCPackData &, bool &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_double -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_double(const char *, size_t, size_t &, double &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_int -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_int(const char *, size_t, size_t &, int &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_uint -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_uint(const char *, size_t, size_t &, unsigned int &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_int64 -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_int64(const char *, size_t, size_t &, PN_int64 &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_uint64 -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_uint64(const char *, size_t, size_t &, PN_uint64 &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_string -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCPackerInterface:: unpack_string(const char *, size_t, size_t &, string &, bool &pack_error, bool &) const { pack_error = true; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_validate -// Access: Public, Virtual -// Description: Internally unpacks the current numeric or string -// value and validates it against the type range limits, -// but does not return the value. Returns true on -// success, false on failure (e.g. we don't know how to -// validate this field). -//////////////////////////////////////////////////////////////////// +/** + * Internally unpacks the current numeric or string value and validates it + * against the type range limits, but does not return the value. Returns true + * on success, false on failure (e.g. we don't know how to validate this + * field). + */ bool DCPackerInterface:: unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &) const { @@ -403,14 +319,11 @@ unpack_validate(const char *data, size_t length, size_t &p, return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::unpack_skip -// Access: Public, Virtual -// Description: Increments p to the end of the current field without -// actually unpacking any data or performing any range -// validation. Returns true on success, false on -// failure (e.g. we don't know how to skip this field). -//////////////////////////////////////////////////////////////////// +/** + * Increments p to the end of the current field without actually unpacking any + * data or performing any range validation. Returns true on success, false on + * failure (e.g. we don't know how to skip this field). + */ bool DCPackerInterface:: unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const { @@ -427,7 +340,7 @@ unpack_skip(const char *data, size_t length, size_t &p, // If we have a length prefix, use that for skipping. if (p + _num_length_bytes > length) { pack_error = true; - + } else { if (_num_length_bytes == 4) { size_t this_length = do_unpack_uint32(data + p); @@ -443,17 +356,15 @@ unpack_skip(const char *data, size_t length, size_t &p, return true; } - // Otherwise, we don't know how to skip this field (presumably it - // can be skipped by skipping over its nested fields individually). + // Otherwise, we don't know how to skip this field (presumably it can be + // skipped by skipping over its nested fields individually). return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::get_catalog -// Access: Public -// Description: Returns the DCPackerCatalog associated with this -// field, listing all of the nested fields by name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerCatalog associated with this field, listing all of the + * nested fields by name. + */ const DCPackerCatalog *DCPackerInterface:: get_catalog() const { if (_catalog == (DCPackerCatalog *)NULL) { @@ -462,78 +373,63 @@ get_catalog() const { return _catalog; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_simple_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// simple parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated simple parameter, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_simple_parameter(const DCSimpleParameter *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_class_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// class parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated class parameter, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_class_parameter(const DCClassParameter *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_switch_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// switch parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated switch parameter, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_switch_parameter(const DCSwitchParameter *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_array_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// array parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated array parameter, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_array_parameter(const DCArrayParameter *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_atomic_field -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// atomic field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated atomic field, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_atomic_field(const DCAtomicField *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::do_check_match_molecular_field -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// molecular field, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated molecular field, false + * otherwise. + */ bool DCPackerInterface:: do_check_match_molecular_field(const DCMolecularField *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCPackerInterface::make_catalog -// Access: Private -// Description: Called internally to create a new DCPackerCatalog -// object. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to create a new DCPackerCatalog object. + */ void DCPackerInterface:: make_catalog() { nassertv(_catalog == (DCPackerCatalog *)NULL); diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index c535ccb7c3..788feb3fe7 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -1,16 +1,15 @@ -// Filename: dcPackerInterface.h -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPackerInterface.h + * @author drose + * @date 2004-06-15 + */ #ifndef DCPACKERINTERFACE_H #define DCPACKERINTERFACE_H @@ -30,16 +29,16 @@ class DCPackData; class DCPackerCatalog; BEGIN_PUBLISH -// This enumerated type is returned by get_pack_type() and represents -// the best choice for a subsequent call to pack_*() or unpack_*(). +// This enumerated type is returned by get_pack_type() and represents the best +// choice for a subsequent call to pack_*() or unpack_*(). enum DCPackType { // This one should never be returned in a normal situation. PT_invalid, - // These PackTypes are all fundamental types, and should be packed - // (or unpacked) with the corresponding call to pack_double(), - // pack_int(), etc. PT_blob is the same as PT_string, but implies - // that the string contains binary data. + // These PackTypes are all fundamental types, and should be packed (or + // unpacked) with the corresponding call to pack_double(), pack_int(), etc. + // PT_blob is the same as PT_string, but implies that the string contains + // binary data. PT_double, PT_int, PT_uint, @@ -48,9 +47,9 @@ enum DCPackType { PT_string, PT_blob, - // The remaining PackTypes imply a need to call push() and pop(). - // They are all variants on the same thing: a list of nested fields, - // but the PackType provides a bit of a semantic context. + // The remaining PackTypes imply a need to call push() and pop(). They are + // all variants on the same thing: a list of nested fields, but the PackType + // provides a bit of a semantic context. PT_array, PT_field, PT_class, @@ -58,16 +57,13 @@ enum DCPackType { }; END_PUBLISH -//////////////////////////////////////////////////////////////////// -// Class : DCPackerInterface -// Description : This defines the internal interface for packing -// values into a DCField. The various different DC -// objects inherit from this. -// -// Normally these methods are called only by the -// DCPacker object; the user wouldn't normally call -// these directly. -//////////////////////////////////////////////////////////////////// +/** + * This defines the internal interface for packing values into a DCField. The + * various different DC objects inherit from this. + * + * Normally these methods are called only by the DCPacker object; the user + * wouldn't normally call these directly. + */ class EXPCL_DIRECT DCPackerInterface { public: DCPackerInterface(const string &name = string()); @@ -119,26 +115,26 @@ public: bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; - virtual void unpack_double(const char *data, size_t length, size_t &p, + virtual void unpack_double(const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const; - virtual void unpack_int(const char *data, size_t length, size_t &p, + virtual void unpack_int(const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const; - virtual void unpack_uint(const char *data, size_t length, size_t &p, + virtual void unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const; - virtual void unpack_int64(const char *data, size_t length, size_t &p, + virtual void unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value, bool &pack_error, bool &range_error) const; - virtual void unpack_uint64(const char *data, size_t length, size_t &p, + virtual void unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value, bool &pack_error, bool &range_error) const; - virtual void unpack_string(const char *data, size_t length, size_t &p, + virtual void unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const; - virtual bool unpack_validate(const char *data, size_t length, size_t &p, + virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const; - // These are the low-level interfaces for packing and unpacking - // numbers from a buffer. You're responsible for making sure the - // buffer has enough room, and for incrementing the pointer. + // These are the low-level interfaces for packing and unpacking numbers from + // a buffer. You're responsible for making sure the buffer has enough room, + // and for incrementing the pointer. INLINE static void do_pack_int8(char *buffer, int value); INLINE static void do_pack_int16(char *buffer, int value); INLINE static void do_pack_int32(char *buffer, int value); @@ -159,13 +155,13 @@ public: INLINE static PN_uint64 do_unpack_uint64(const char *buffer); INLINE static double do_unpack_float64(const char *buffer); - INLINE static void validate_int_limits(int value, int num_bits, + INLINE static void validate_int_limits(int value, int num_bits, bool &range_error); - INLINE static void validate_int64_limits(PN_int64 value, int num_bits, + INLINE static void validate_int64_limits(PN_int64 value, int num_bits, bool &range_error); - INLINE static void validate_uint_limits(unsigned int value, int num_bits, + INLINE static void validate_uint_limits(unsigned int value, int num_bits, bool &range_error); - INLINE static void validate_uint64_limits(PN_uint64 value, int num_bits, + INLINE static void validate_uint64_limits(PN_uint64 value, int num_bits, bool &range_error); const DCPackerCatalog *get_catalog() const; @@ -174,8 +170,8 @@ protected: virtual bool do_check_match(const DCPackerInterface *other) const=0; public: - // These are declared public just so the derived classes can call - // them easily. They're not intended to be called directly. + // These are declared public just so the derived classes can call them + // easily. They're not intended to be called directly. virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const; virtual bool do_check_match_class_parameter(const DCClassParameter *other) const; diff --git a/direct/src/dcparser/dcParameter.cxx b/direct/src/dcparser/dcParameter.cxx index 84ba6d3106..a1fcfecca7 100644 --- a/direct/src/dcparser/dcParameter.cxx +++ b/direct/src/dcparser/dcParameter.cxx @@ -1,16 +1,15 @@ -// Filename: dcParameter.cxx -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcParameter.cxx + * @author drose + * @date 2004-06-15 + */ #include "dcParameter.h" #include "dcArrayParameter.h" @@ -18,11 +17,9 @@ #include "dcindent.h" #include "dcTypedef.h" -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter:: DCParameter() { _typedef = NULL; @@ -31,11 +28,9 @@ DCParameter() { _num_nested_fields = -1; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter:: DCParameter(const DCParameter ©) : DCField(copy), @@ -43,157 +38,125 @@ DCParameter(const DCParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter:: ~DCParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCParameter:: as_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCParameter *DCParameter:: as_parameter() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_simple_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSimpleParameter *DCParameter:: as_simple_parameter() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_simple_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSimpleParameter *DCParameter:: as_simple_parameter() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCClassParameter *DCParameter:: as_class_parameter() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_class_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCClassParameter *DCParameter:: as_class_parameter() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitchParameter *DCParameter:: as_switch_parameter() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSwitchParameter *DCParameter:: as_switch_parameter() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_array_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCArrayParameter *DCParameter:: as_array_parameter() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::as_array_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCArrayParameter *DCParameter:: as_array_parameter() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::get_typedef -// Access: Published -// Description: If this type has been referenced from a typedef, -// returns the DCTypedef instance, or NULL if the -// type was declared on-the-fly. -//////////////////////////////////////////////////////////////////// +/** + * If this type has been referenced from a typedef, returns the DCTypedef + * instance, or NULL if the type was declared on-the-fly. + */ const DCTypedef *DCParameter:: get_typedef() const { return _typedef; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::set_typedef -// Access: Public -// Description: Records the DCTypedef object that generated this -// parameter. This is normally called only from -// DCTypedef::make_new_parameter(). -//////////////////////////////////////////////////////////////////// +/** + * Records the DCTypedef object that generated this parameter. This is + * normally called only from DCTypedef::make_new_parameter(). + */ void DCParameter:: set_typedef(const DCTypedef *dtypedef) { _typedef = dtypedef; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::append_array_specification -// Access: Public, Virtual -// Description: Returns the type represented by this_type[size]. -// -// In the case of a generic DCParameter, this means it -// returns a DCArrayParameter wrapped around this type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type represented by this_type[size]. + * + * In the case of a generic DCParameter, this means it returns a + * DCArrayParameter wrapped around this type. + */ DCParameter *DCParameter:: append_array_specification(const DCUnsignedIntRange &size) { return new DCArrayParameter(this, size); } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCParameter:: output(ostream &out, bool brief) const { string name; @@ -203,28 +166,23 @@ output(ostream &out, bool brief) const { output_instance(out, brief, "", name, ""); } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCParameter:: write(ostream &out, bool brief, int indent_level) const { - // we must always output the name when the parameter occurs by - // itself within a class, so we pass get_name() even if brief is - // true. + // we must always output the name when the parameter occurs by itself within + // a class, so we pass get_name() even if brief is true. write_instance(out, brief, indent_level, "", get_name(), ""); } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::write_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCParameter:: write_instance(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, + const string &prename, const string &name, const string &postname) const { indent(out, indent_level); output_instance(out, brief, prename, name, postname); @@ -236,12 +194,10 @@ write_instance(ostream &out, bool brief, int indent_level, out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::output_typedef_name -// Access: Public -// Description: Formats the instance like output_instance, but uses -// the typedef name instead. -//////////////////////////////////////////////////////////////////// +/** + * Formats the instance like output_instance, but uses the typedef name + * instead. + */ void DCParameter:: output_typedef_name(ostream &out, bool, const string &prename, const string &name, const string &postname) const { @@ -251,15 +207,13 @@ output_typedef_name(ostream &out, bool, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::write_typedef_name -// Access: Public -// Description: Formats the instance like write_instance, but uses -// the typedef name instead. -//////////////////////////////////////////////////////////////////// +/** + * Formats the instance like write_instance, but uses the typedef name + * instead. + */ void DCParameter:: -write_typedef_name(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, +write_typedef_name(ostream &out, bool brief, int indent_level, + const string &prename, const string &name, const string &postname) const { indent(out, indent_level) << get_typedef()->get_name(); @@ -274,16 +228,13 @@ write_typedef_name(ostream &out, bool brief, int indent_level, out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCParameter::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this type into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this type into the hash. + */ void DCParameter:: generate_hash(HashGenerator &hashgen) const { - // We specifically don't call up to DCField::generate_hash(), since - // the parameter name is not actually significant to the hash. + // We specifically don't call up to DCField::generate_hash(), since the + // parameter name is not actually significant to the hash. if (get_num_keywords() != 0) { DCKeywordList::generate_hash(hashgen); diff --git a/direct/src/dcparser/dcParameter.h b/direct/src/dcparser/dcParameter.h index de7c1a736b..d8765f4d54 100644 --- a/direct/src/dcparser/dcParameter.h +++ b/direct/src/dcparser/dcParameter.h @@ -1,16 +1,15 @@ -// Filename: dcParameter.h -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcParameter.h + * @author drose + * @date 2004-06-15 + */ #ifndef DCPARAMETER_H #define DCPARAMETER_H @@ -25,17 +24,14 @@ class DCArrayParameter; class DCTypedef; class HashGenerator; -//////////////////////////////////////////////////////////////////// -// Class : DCParameter -// Description : Represents the type specification for a single -// parameter within a field specification. This may be -// a simple type, or it may be a class or an array -// reference. -// -// This may also be a typedef reference to another type, -// which has the same properties as the referenced type, -// but a different name. -//////////////////////////////////////////////////////////////////// +/** + * Represents the type specification for a single parameter within a field + * specification. This may be a simple type, or it may be a class or an array + * reference. + * + * This may also be a typedef reference to another type, which has the same + * properties as the referenced type, but a different name. + */ class EXPCL_DIRECT DCParameter : public DCField { protected: DCParameter(); @@ -66,15 +62,15 @@ public: virtual void output(ostream &out, bool brief) const; virtual void write(ostream &out, bool brief, int indent_level) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, + virtual void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const=0; virtual void write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, const string &postname) const; - void output_typedef_name(ostream &out, bool brief, const string &prename, + void output_typedef_name(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; void write_typedef_name(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, + const string &prename, const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index d73817da84..5c39b398e4 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -1,7 +1,8 @@ -// Filename: dcParser.yxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file dcParser.yxx + * @author drose + * @date 2000-10-05 + */ %{ #include "dcLexerDefs.h" diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index 4bf81422ba..4b50553bcf 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -1,16 +1,15 @@ -// Filename: dcParserDefs.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcParserDefs.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCPARSERDEFS_H #define DCPARSERDEFS_H @@ -28,7 +27,7 @@ class DCKeyword; class DCPacker; void dc_init_parser(istream &in, const string &filename, DCFile &file); -void dc_init_parser_parameter_value(istream &in, const string &filename, +void dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer); void dc_init_parser_parameter_description(istream &in, const string &filename, DCFile *file); @@ -38,12 +37,11 @@ int dcyyparse(); extern DCFile *dc_file; -// This structure holds the return value for each token. -// Traditionally, this is a union, and is declared with the %union -// declaration in the parser.y file, but unions are pretty worthless -// in C++ (you can't include an object that has member functions in a -// union), so we'll use a class instead. That means we need to -// declare it externally, here. +// This structure holds the return value for each token. Traditionally, this +// is a union, and is declared with the %union declaration in the parser.y +// file, but unions are pretty worthless in C++ (you can't include an object +// that has member functions in a union), so we'll use a class instead. That +// means we need to declare it externally, here. class DCTokenType { public: @@ -65,8 +63,8 @@ public: string str; }; -// The yacc-generated code expects to use the symbol 'YYSTYPE' to -// refer to the above class. +// The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the +// above class. #define YYSTYPE DCTokenType #endif diff --git a/direct/src/dcparser/dcPython.h b/direct/src/dcparser/dcPython.h index f04aa11e6b..513f1b008e 100644 --- a/direct/src/dcparser/dcPython.h +++ b/direct/src/dcparser/dcPython.h @@ -1,22 +1,21 @@ -// Filename: dcPython.h -// Created by: drose (22Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcPython.h + * @author drose + * @date 2004-06-22 + */ #ifndef DCPYTHON_H #define DCPYTHON_H -// The only purpose of this file is to serve as a common place to put -// the nonsense associated with #including . +// The only purpose of this file is to serve as a common place to put the +// nonsense associated with #including . #ifdef HAVE_PYTHON @@ -33,8 +32,8 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif -// Several interfaces in this module that use Python also require -// these header files, so we might as well pick them up too. +// Several interfaces in this module that use Python also require these header +// files, so we might as well pick them up too. #include "datagram.h" #include "datagramIterator.h" diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index 1f947edccf..54f6ab0007 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -1,16 +1,15 @@ -// Filename: dcSimpleParameter.cxx -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSimpleParameter.cxx + * @author drose + * @date 2004-06-15 + */ #include "dcSimpleParameter.h" #include "dcPackData.h" @@ -24,11 +23,9 @@ DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL; -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSimpleParameter:: DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _type(type), @@ -41,9 +38,9 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _bytes_per_element = 0; _num_length_bytes = 2; - // Check for one of the built-in array types. For these types, we - // must present a packing interface that has a variable number of - // nested fields of the appropriate type. + // Check for one of the built-in array types. For these types, we must + // present a packing interface that has a variable number of nested fields + // of the appropriate type. switch (_type) { case ST_int8array: _pack_type = PT_array; @@ -97,16 +94,15 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _num_length_bytes = 4; // fall through case ST_blob: - // For blob and string, we will present an array interface - // as an array of uint8, but we will also accept a set_value() - // with a string parameter. + // For blob and string, we will present an array interface as an array of + // uint8, but we will also accept a set_value() with a string parameter. _pack_type = PT_blob; _nested_type = ST_uint8; _has_nested_fields = true; _bytes_per_element = 1; break; - case ST_string: + case ST_string: _pack_type = PT_string; _nested_type = ST_char; _has_nested_fields = true; @@ -185,9 +181,8 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : _nested_field = create_nested_field(_nested_type, _divisor); } else if (_type == ST_uint32uint8array) { - // This one is a special case. We must create a special nested - // type that accepts a uint32 followed by a uint8 for each - // element. + // This one is a special case. We must create a special nested type that + // accepts a uint32 followed by a uint8 for each element. _nested_field = create_uint32uint8_type(); } else { @@ -195,11 +190,9 @@ DCSimpleParameter(DCSubatomicType type, unsigned int divisor) : } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSimpleParameter:: DCSimpleParameter(const DCSimpleParameter ©) : DCParameter(copy), @@ -221,123 +214,94 @@ DCSimpleParameter(const DCSimpleParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::as_simple_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSimpleParameter *DCSimpleParameter:: as_simple_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::as_simple_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSimpleParameter *DCSimpleParameter:: as_simple_parameter() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::make_copy -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCSimpleParameter:: make_copy() const { return new DCSimpleParameter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::is_valid -// Access: Published, Virtual -// Description: Returns false if the type is an invalid type -// (e.g. declared from an undefined typedef), true if -// it is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the type is an invalid type (e.g. declared from an + * undefined typedef), true if it is valid. + */ bool DCSimpleParameter:: is_valid() const { return _type != ST_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::get_type -// Access: Published -// Description: Returns the particular subatomic type represented by -// this instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular subatomic type represented by this instance. + */ DCSubatomicType DCSimpleParameter:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::has_modulus -// Access: Published -// Description: Returns true if there is a modulus associated, false -// otherwise., -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a modulus associated, false otherwise., + */ bool DCSimpleParameter:: has_modulus() const { return _has_modulus; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::get_modulus -// Access: Published -// Description: Returns the modulus associated with this type, if -// any. It is an error to call this if has_modulus() -// returned false. -// -// If present, this is the modulus that is used to -// constrain the numeric value of the field before it is -// packed (and range-checked). -//////////////////////////////////////////////////////////////////// +/** + * Returns the modulus associated with this type, if any. It is an error to + * call this if has_modulus() returned false. + * + * If present, this is the modulus that is used to constrain the numeric value + * of the field before it is packed (and range-checked). + */ double DCSimpleParameter:: get_modulus() const { return _orig_modulus; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::get_divisor -// Access: Published -// Description: Returns the divisor associated with this type. This -// is 1 by default, but if this is other than one it -// represents the scale to apply when packing and -// unpacking numeric values (to store fixed-point values -// in an integer field). It is only meaningful for -// numeric-type fields. -//////////////////////////////////////////////////////////////////// +/** + * Returns the divisor associated with this type. This is 1 by default, but + * if this is other than one it represents the scale to apply when packing and + * unpacking numeric values (to store fixed-point values in an integer field). + * It is only meaningful for numeric-type fields. + */ int DCSimpleParameter:: get_divisor() const { return _divisor; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::is_numeric_type -// Access: Public -// Description: Returns true if the type is a numeric type (and -// therefore can accept a divisor and/or a modulus), or -// false if it is some string-based type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is a numeric type (and therefore can accept a + * divisor and/or a modulus), or false if it is some string-based type. + */ bool DCSimpleParameter:: is_numeric_type() const { return !(_pack_type == PT_string || _pack_type == PT_blob); } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::set_modulus -// Access: Public -// Description: Assigns the indicated modulus to the simple type. -// Any packed value will be constrained to be within [0, -// modulus). -// -// Returns true if assigned, false if this type cannot -// accept a modulus or if the modulus is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the indicated modulus to the simple type. Any packed value will be + * constrained to be within [0, modulus). + * + * Returns true if assigned, false if this type cannot accept a modulus or if + * the modulus is invalid. + */ bool DCSimpleParameter:: set_modulus(double modulus) { if (_pack_type == PT_string || _pack_type == PT_blob || modulus <= 0.0) { @@ -352,8 +316,8 @@ set_modulus(double modulus) { _uint64_modulus = (PN_uint64)floor(_double_modulus + 0.5); _uint_modulus = (unsigned int)_uint64_modulus; - // Check the range. The legitimate range for a modulus value is 1 - // through (maximum_value + 1). + // Check the range. The legitimate range for a modulus value is 1 through + // (maximum_value + 1). switch (_type) { case ST_int8: case ST_int8array: @@ -369,7 +333,7 @@ set_modulus(double modulus) { case ST_int32array: validate_uint64_limits(_uint64_modulus - 1, 31, range_error); break; - + case ST_int64: validate_uint64_limits(_uint64_modulus - 1, 63, range_error); break; @@ -389,7 +353,7 @@ set_modulus(double modulus) { case ST_uint32array: validate_uint64_limits(_uint64_modulus - 1, 32, range_error); break; - + case ST_uint64: case ST_float64: break; @@ -401,13 +365,11 @@ set_modulus(double modulus) { return !range_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::set_divisor -// Access: Public -// Description: Assigns the indicated divisor to the simple type. -// Returns true if assigned, false if this type cannot -// accept a divisor or if the divisor is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the indicated divisor to the simple type. Returns true if + * assigned, false if this type cannot accept a divisor or if the divisor is + * invalid. + */ bool DCSimpleParameter:: set_divisor(unsigned int divisor) { if (_pack_type == PT_string || _pack_type == PT_blob || divisor == 0) { @@ -431,16 +393,12 @@ set_divisor(unsigned int divisor) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::set_range -// Access: Public -// Description: Sets the parameter with the indicated range. A -// DCDoubleRange is used for specification, since this -// is the most generic type; but it is converted to the -// appropriate type internally. The return value is -// true if successful, or false if the range is -// inappropriate for the type. -//////////////////////////////////////////////////////////////////// +/** + * Sets the parameter with the indicated range. A DCDoubleRange is used for + * specification, since this is the most generic type; but it is converted to + * the appropriate type internally. The return value is true if successful, + * or false if the range is inappropriate for the type. + */ bool DCSimpleParameter:: set_range(const DCDoubleRange &range) { bool range_error = false; @@ -462,7 +420,7 @@ set_range(const DCDoubleRange &range) { _int_range.add_range((int)min, (int)max); } break; - + case ST_int16: case ST_int16array: _int_range.clear(); @@ -474,7 +432,7 @@ set_range(const DCDoubleRange &range) { _int_range.add_range((int)min, (int)max); } break; - + case ST_int32: case ST_int32array: _int_range.clear(); @@ -486,7 +444,7 @@ set_range(const DCDoubleRange &range) { _int_range.add_range((int)min, (int)max); } break; - + case ST_int64: _int64_range.clear(); for (i = 0; i < num_ranges; i++) { @@ -495,7 +453,7 @@ set_range(const DCDoubleRange &range) { _int64_range.add_range(min, max); } break; - + case ST_char: case ST_uint8: case ST_uint8array: @@ -508,7 +466,7 @@ set_range(const DCDoubleRange &range) { _uint_range.add_range((unsigned int)min, (unsigned int)max); } break; - + case ST_uint16: case ST_uint16array: _uint_range.clear(); @@ -520,7 +478,7 @@ set_range(const DCDoubleRange &range) { _uint_range.add_range((unsigned int)min, (unsigned int)max); } break; - + case ST_uint32: case ST_uint32array: _uint_range.clear(); @@ -532,7 +490,7 @@ set_range(const DCDoubleRange &range) { _uint_range.add_range((unsigned int)min, (unsigned int)max); } break; - + case ST_uint64: _uint64_range.clear(); for (i = 0; i < num_ranges; i++) { @@ -562,8 +520,8 @@ set_range(const DCDoubleRange &range) { _uint_range.add_range((unsigned int)min, (unsigned int)max); } if (_uint_range.has_one_value()) { - // If we now have a fixed-length string requirement, we don't - // need a leading number of bytes. + // If we now have a fixed-length string requirement, we don't need a + // leading number of bytes. _num_length_bytes = 0; _has_fixed_byte_size = true; _fixed_byte_size = _uint_range.get_one_value(); @@ -585,8 +543,8 @@ set_range(const DCDoubleRange &range) { _uint_range.add_range((unsigned int)min, (unsigned int)max); } if (_uint_range.has_one_value()) { - // If we now have a fixed-length string requirement, we don't - // need a leading number of bytes. + // If we now have a fixed-length string requirement, we don't need a + // leading number of bytes. _num_length_bytes = 0; _has_fixed_byte_size = true; _fixed_byte_size = _uint_range.get_one_value(); @@ -605,16 +563,12 @@ set_range(const DCDoubleRange &range) { return !range_error; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::calc_num_nested_fields -// Access: Public, Virtual -// Description: This flavor of get_num_nested_fields is used during -// unpacking. It returns the number of nested fields to -// expect, given a certain length in bytes (as read from -// the _num_length_bytes stored in the stream on the -// push). This will only be called if _num_length_bytes -// is nonzero. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_num_nested_fields is used during unpacking. It returns + * the number of nested fields to expect, given a certain length in bytes (as + * read from the _num_length_bytes stored in the stream on the push). This + * will only be called if _num_length_bytes is nonzero. + */ int DCSimpleParameter:: calc_num_nested_fields(size_t length_bytes) const { if (_bytes_per_element != 0) { @@ -623,25 +577,19 @@ calc_num_nested_fields(size_t length_bytes) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCSimpleParameter:: get_nested_field(int) const { return _nested_field; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_double -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_double(DCPackData &pack_data, double value, bool &pack_error, bool &range_error) const { @@ -675,7 +623,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_int16(pack_data.get_write_pointer(2), int_value); } break; - + case ST_int32: { int int_value = (int)floor(real_value + 0.5); @@ -683,7 +631,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_int32(pack_data.get_write_pointer(4), int_value); } break; - + case ST_int64: { PN_int64 int64_value = (PN_int64)floor(real_value + 0.5); @@ -691,7 +639,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_int64(pack_data.get_write_pointer(8), int64_value); } break; - + case ST_char: case ST_uint8: { @@ -701,7 +649,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_uint8(pack_data.get_write_pointer(1), int_value); } break; - + case ST_uint16: { unsigned int int_value = (unsigned int)floor(real_value + 0.5); @@ -710,7 +658,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_uint16(pack_data.get_write_pointer(2), int_value); } break; - + case ST_uint32: { unsigned int int_value = (unsigned int)floor(real_value + 0.5); @@ -718,7 +666,7 @@ pack_double(DCPackData &pack_data, double value, do_pack_uint32(pack_data.get_write_pointer(4), int_value); } break; - + case ST_uint64: { PN_uint64 int64_value = (PN_uint64)floor(real_value + 0.5); @@ -737,20 +685,17 @@ pack_double(DCPackData &pack_data, double value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_int -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_int(DCPackData &pack_data, int value, bool &pack_error, bool &range_error) const { int int_value = value * _divisor; if (value != 0 && (int_value / value) != (int)_divisor) { - // If we've experienced overflow after applying the divisor, pack - // it as an int64 instead. + // If we've experienced overflow after applying the divisor, pack it as an + // int64 instead. pack_int64(pack_data, (PN_int64)value, pack_error, range_error); return; } @@ -831,12 +776,9 @@ pack_int(DCPackData &pack_data, int value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_uint -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_uint(DCPackData &pack_data, unsigned int value, bool &pack_error, bool &range_error) const { @@ -913,12 +855,9 @@ pack_uint(DCPackData &pack_data, unsigned int value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_int64 -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_int64(DCPackData &pack_data, PN_int64 value, bool &pack_error, bool &range_error) const { @@ -1001,12 +940,9 @@ pack_int64(DCPackData &pack_data, PN_int64 value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_uint64 -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_uint64(DCPackData &pack_data, PN_uint64 value, bool &pack_error, bool &range_error) const { @@ -1085,12 +1021,9 @@ pack_uint64(DCPackData &pack_data, PN_uint64 value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_string -// Access: Published, Virtual -// Description: Packs the indicated numeric or string value into the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Packs the indicated numeric or string value into the stream. + */ void DCSimpleParameter:: pack_string(DCPackData &pack_data, const string &value, bool &pack_error, bool &range_error) const { @@ -1134,15 +1067,12 @@ pack_string(DCPackData &pack_data, const string &value, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::pack_default_value -// Access: Public, Virtual -// Description: Packs the simpleParameter's specified default value (or a -// sensible default if no value is specified) into the -// stream. Returns true if the default value is packed, -// false if the simpleParameter doesn't know how to pack its -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the simpleParameter's specified default value (or a sensible default + * if no value is specified) into the stream. Returns true if the default + * value is packed, false if the simpleParameter doesn't know how to pack its + * default value. + */ bool DCSimpleParameter:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { if (has_default_value()) { @@ -1150,15 +1080,15 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { } if (_has_nested_fields) { - // If the simple type is an array (or string) type, pack the - // appropriate length array, with code similar to + // If the simple type is an array (or string) type, pack the appropriate + // length array, with code similar to // DCArrayParameter::pack_default_value(). unsigned int minimum_length = 0; if (!_uint_range.is_empty()) { minimum_length = _uint_range.get_min(0); } - + DCPacker packer; packer.begin_pack(this); packer.push(); @@ -1168,14 +1098,14 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { packer.pop(); if (!packer.end_pack()) { pack_error = true; - + } else { pack_data.append_data(packer.get_data(), packer.get_length()); } } else { - // Otherwise, if it's just a simple numeric type, pack a zero or - // the minimum value. + // Otherwise, if it's just a simple numeric type, pack a zero or the + // minimum value. switch (_type) { case ST_int8: case ST_int16: @@ -1213,7 +1143,7 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { pack_uint64(pack_data, _uint64_range.get_min(0), pack_error, pack_error); } break; - + case ST_float64: if (_double_range.is_in_range(0.0)) { pack_double(pack_data, 0.0, pack_error, pack_error); @@ -1221,7 +1151,7 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { pack_double(pack_data, _double_range.get_min(0), pack_error, pack_error); } break; - + default: pack_error = true; } @@ -1231,12 +1161,9 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_double -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_double(const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const { @@ -1370,12 +1297,9 @@ unpack_double(const char *data, size_t length, size_t &p, double &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_int -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_int(const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const { @@ -1511,12 +1435,9 @@ unpack_int(const char *data, size_t length, size_t &p, int &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_uint -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const { @@ -1660,12 +1581,9 @@ unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_int64 -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value, bool &pack_error, bool &range_error) const { @@ -1800,12 +1718,9 @@ unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_uint64 -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value, bool &pack_error, bool &range_error) const { @@ -1949,12 +1864,9 @@ unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_string -// Access: Public, Virtual -// Description: Unpacks the current numeric or string value from the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the current numeric or string value from the stream. + */ void DCSimpleParameter:: unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const { @@ -1995,7 +1907,7 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, string_length = do_unpack_uint16(data + p); p += 2; break; - + case ST_blob32: if (p + 4 > length) { pack_error = true; @@ -2004,7 +1916,7 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, string_length = do_unpack_uint32(data + p); p += 4; break; - + default: pack_error = true; return; @@ -2023,18 +1935,15 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, return; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_validate -// Access: Public, Virtual -// Description: Internally unpacks the current numeric or string -// value and validates it against the type range limits, -// but does not return the value. Returns true on -// success, false on failure (e.g. we don't know how to -// validate this field). -//////////////////////////////////////////////////////////////////// +/** + * Internally unpacks the current numeric or string value and validates it + * against the type range limits, but does not return the value. Returns true + * on success, false on failure (e.g. we don't know how to validate this + * field). + */ bool DCSimpleParameter:: unpack_validate(const char *data, size_t length, size_t &p, - bool &pack_error, bool &range_error) const { + bool &pack_error, bool &range_error) const { if (!_has_range_limits) { return unpack_skip(data, length, p, pack_error); } @@ -2186,16 +2095,13 @@ unpack_validate(const char *data, size_t length, size_t &p, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::unpack_skip -// Access: Public, Virtual -// Description: Increments p to the end of the current field without -// actually unpacking any data or performing any range -// validation. Returns true on success, false on -// failure (e.g. we don't know how to skip this field). -//////////////////////////////////////////////////////////////////// +/** + * Increments p to the end of the current field without actually unpacking any + * data or performing any range validation. Returns true on success, false on + * failure (e.g. we don't know how to skip this field). + */ bool DCSimpleParameter:: -unpack_skip(const char *data, size_t length, size_t &p, +unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const { size_t string_length; @@ -2260,12 +2166,10 @@ unpack_skip(const char *data, size_t length, size_t &p, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::output_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCSimpleParameter:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { @@ -2291,7 +2195,7 @@ output_instance(ostream &out, bool brief, const string &prename, out << ")"; } break; - + case ST_int64: if (!_int64_range.is_empty()) { out << "("; @@ -2299,7 +2203,7 @@ output_instance(ostream &out, bool brief, const string &prename, out << ")"; } break; - + case ST_uint8: case ST_uint16: case ST_uint32: @@ -2317,7 +2221,7 @@ output_instance(ostream &out, bool brief, const string &prename, out << ")"; } break; - + case ST_uint64: if (!_uint64_range.is_empty()) { out << "("; @@ -2351,12 +2255,9 @@ output_instance(ostream &out, bool brief, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this type into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this type into the hash. + */ void DCSimpleParameter:: generate_hash(HashGenerator &hashgen) const { DCParameter::generate_hash(hashgen); @@ -2374,25 +2275,20 @@ generate_hash(HashGenerator &hashgen) const { _double_range.generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCSimpleParameter:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_simple_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::do_check_match_simple_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// simple parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated simple parameter, false + * otherwise. + */ bool DCSimpleParameter:: do_check_match_simple_parameter(const DCSimpleParameter *other) const { if (_divisor != other->_divisor) { @@ -2403,8 +2299,7 @@ do_check_match_simple_parameter(const DCSimpleParameter *other) const { return true; } - // Check for certain types that are considered equivalent to each - // other. + // Check for certain types that are considered equivalent to each other. switch (_type) { case ST_uint8: case ST_char: @@ -2435,12 +2330,10 @@ do_check_match_simple_parameter(const DCSimpleParameter *other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::do_check_match_array_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// array parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated array parameter, false + * otherwise. + */ bool DCSimpleParameter:: do_check_match_array_parameter(const DCArrayParameter *other) const { if (other->get_array_size() != -1) { @@ -2455,13 +2348,10 @@ do_check_match_array_parameter(const DCArrayParameter *other) const { return _nested_field->check_match(other->get_element_type()); } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::create_nested_field -// Access: Private, Static -// Description: Creates the one instance of the DCSimpleParameter -// corresponding to this combination of type and divisor -// if it is not already created. -//////////////////////////////////////////////////////////////////// +/** + * Creates the one instance of the DCSimpleParameter corresponding to this + * combination of type and divisor if it is not already created. + */ DCSimpleParameter *DCSimpleParameter:: create_nested_field(DCSubatomicType type, unsigned int divisor) { DivisorMap &divisor_map = _nested_field_map[type]; @@ -2476,12 +2366,10 @@ create_nested_field(DCSubatomicType type, unsigned int divisor) { return nested_field; } -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::create_uint32uint8_type -// Access: Private, Static -// Description: Creates the one instance of the Uint32Uint8Type -// object if it is not already created. -//////////////////////////////////////////////////////////////////// +/** + * Creates the one instance of the Uint32Uint8Type object if it is not already + * created. + */ DCPackerInterface *DCSimpleParameter:: create_uint32uint8_type() { if (_uint32uint8_type == NULL) { diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index 8c39d4c5c2..3a8d53c2aa 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -1,16 +1,15 @@ -// Filename: dcSimpleParameter.h -// Created by: drose (15Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSimpleParameter.h + * @author drose + * @date 2004-06-15 + */ #ifndef DCSIMPLEPARAMETER_H #define DCSIMPLEPARAMETER_H @@ -20,15 +19,12 @@ #include "dcSubatomicType.h" #include "dcNumericRange.h" -//////////////////////////////////////////////////////////////////// -// Class : DCSimpleParameter -// Description : This is the most fundamental kind of parameter type: -// a single number or string, one of the DCSubatomicType -// elements. It may also optionally have a divisor, -// which is meaningful only for the numeric type -// elements (and represents a fixed-point numeric -// convention). -//////////////////////////////////////////////////////////////////// +/** + * This is the most fundamental kind of parameter type: a single number or + * string, one of the DCSubatomicType elements. It may also optionally have a + * divisor, which is meaningful only for the numeric type elements (and + * represents a fixed-point numeric convention). + */ class EXPCL_DIRECT DCSimpleParameter : public DCParameter { public: DCSimpleParameter(DCSubatomicType type, unsigned int divisor = 1); @@ -68,24 +64,24 @@ public: bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; - virtual void unpack_double(const char *data, size_t length, size_t &p, + virtual void unpack_double(const char *data, size_t length, size_t &p, double &value, bool &pack_error, bool &range_error) const; - virtual void unpack_int(const char *data, size_t length, size_t &p, + virtual void unpack_int(const char *data, size_t length, size_t &p, int &value, bool &pack_error, bool &range_error) const; - virtual void unpack_uint(const char *data, size_t length, size_t &p, + virtual void unpack_uint(const char *data, size_t length, size_t &p, unsigned int &value, bool &pack_error, bool &range_error) const; - virtual void unpack_int64(const char *data, size_t length, size_t &p, + virtual void unpack_int64(const char *data, size_t length, size_t &p, PN_int64 &value, bool &pack_error, bool &range_error) const; - virtual void unpack_uint64(const char *data, size_t length, size_t &p, + virtual void unpack_uint64(const char *data, size_t length, size_t &p, PN_uint64 &value, bool &pack_error, bool &range_error) const; - virtual void unpack_string(const char *data, size_t length, size_t &p, + virtual void unpack_string(const char *data, size_t length, size_t &p, string &value, bool &pack_error, bool &range_error) const; - virtual bool unpack_validate(const char *data, size_t length, size_t &p, + virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, bool &pack_error) const; - virtual void output_instance(ostream &out, bool brief, const string &prename, + virtual void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; @@ -95,7 +91,7 @@ protected: virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; private: - static DCSimpleParameter *create_nested_field(DCSubatomicType type, + static DCSimpleParameter *create_nested_field(DCSubatomicType type, unsigned int divisor); static DCPackerInterface *create_uint32uint8_type(); @@ -107,15 +103,15 @@ private: DCPackerInterface *_nested_field; size_t _bytes_per_element; - // The rest of this is to maintain the static list of - // DCPackerInterface objects for _nested_field, above. We allocate - // each possible object once, and don't delete it. + // The rest of this is to maintain the static list of DCPackerInterface + // objects for _nested_field, above. We allocate each possible object once, + // and don't delete it. typedef pmap DivisorMap; typedef pmap NestedFieldMap; static NestedFieldMap _nested_field_map; - // These are the range and modulus values as specified by the user, - // unscaled by the divisor. + // These are the range and modulus values as specified by the user, unscaled + // by the divisor. DCDoubleRange _orig_range; bool _has_modulus; double _orig_modulus; @@ -127,8 +123,7 @@ private: DCUnsignedInt64Range _uint64_range; DCDoubleRange _double_range; - // All of these modulus values will be filled in, regardless of the - // type. + // All of these modulus values will be filled in, regardless of the type. unsigned int _uint_modulus; PN_uint64 _uint64_modulus; double _double_modulus; diff --git a/direct/src/dcparser/dcSubatomicType.cxx b/direct/src/dcparser/dcSubatomicType.cxx index e568a3c94b..1489fe3a3f 100644 --- a/direct/src/dcparser/dcSubatomicType.cxx +++ b/direct/src/dcparser/dcSubatomicType.cxx @@ -1,16 +1,15 @@ -// Filename: dcSubatomicType.cxx -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSubatomicType.cxx + * @author drose + * @date 2000-10-05 + */ #include "dcSubatomicType.h" diff --git a/direct/src/dcparser/dcSubatomicType.h b/direct/src/dcparser/dcSubatomicType.h index 3b77523d42..383533857b 100644 --- a/direct/src/dcparser/dcSubatomicType.h +++ b/direct/src/dcparser/dcSubatomicType.h @@ -1,16 +1,15 @@ -// Filename: dcSubatomicType.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSubatomicType.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCSUBATOMICTYPE_H #define DCSUBATOMICTYPE_H @@ -18,13 +17,11 @@ #include "dcbase.h" BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Enum : DCSubatomicType -// Description : This defines the numeric type of each element of a -// DCAtomicField; that is, the particular values that -// will get added to the message when the atomic field -// method is called. -//////////////////////////////////////////////////////////////////// +/** + * This defines the numeric type of each element of a DCAtomicField; that is, + * the particular values that will get added to the message when the atomic + * field method is called. + */ enum DCSubatomicType { ST_int8, ST_int16, @@ -49,16 +46,15 @@ enum DCSubatomicType { ST_int8array, ST_uint8array, - // A special-purpose array: a list of alternating uint32 and uint8 - // values. In Python, this becomes a list of 2-tuples. + // A special-purpose array: a list of alternating uint32 and uint8 values. + // In Python, this becomes a list of 2-tuples. ST_uint32uint8array, - // Equivalent to uint8, except that it suggests a pack_type of - // PT_string. + // Equivalent to uint8, except that it suggests a pack_type of PT_string. ST_char, - // New additions should be added at the end to prevent the file hash - // code from changing. + // New additions should be added at the end to prevent the file hash code + // from changing. ST_invalid }; @@ -67,5 +63,3 @@ END_PUBLISH ostream &operator << (ostream &out, DCSubatomicType type); #endif - - diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index ad03554a54..0215a9919c 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -1,16 +1,15 @@ -// Filename: dcSwitch.cxx -// Created by: drose (23Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSwitch.cxx + * @author drose + * @date 2004-06-23 + */ #include "dcSwitch.h" #include "dcField.h" @@ -19,13 +18,10 @@ #include "dcindent.h" #include "dcPacker.h" -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::Constructor -// Access: Public -// Description: The key_parameter must be recently allocated via -// new; it will be deleted via delete when the switch -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * The key_parameter must be recently allocated via new; it will be deleted + * via delete when the switch destructs. + */ DCSwitch:: DCSwitch(const string &name, DCField *key_parameter) : _name(name), @@ -35,11 +31,9 @@ DCSwitch(const string &name, DCField *key_parameter) : _fields_added = false; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch:: ~DCSwitch() { nassertv(_key_parameter != (DCField *)NULL); @@ -64,68 +58,53 @@ DCSwitch:: } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::as_switch -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch *DCSwitch:: as_switch() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::as_switch -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSwitch *DCSwitch:: as_switch() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_name -// Access: Published -// Description: Returns the name of this switch. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this switch. + */ const string &DCSwitch:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_key_parameter -// Access: Published -// Description: Returns the key parameter on which the switch is -// based. The value of this parameter in the record -// determines which one of the several cases within the -// switch will be used. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key parameter on which the switch is based. The value of this + * parameter in the record determines which one of the several cases within + * the switch will be used. + */ DCField *DCSwitch:: get_key_parameter() const { return _key_parameter; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_num_cases -// Access: Published -// Description: Returns the number of different cases within the -// switch. The legal values for case_index range from 0 -// to get_num_cases() - 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different cases within the switch. The legal values + * for case_index range from 0 to get_num_cases() - 1. + */ int DCSwitch:: get_num_cases() const { return _cases.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_case_by_value -// Access: Published -// Description: Returns the index number of the case with the -// indicated packed value, or -1 if no case has this -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the case with the indicated packed value, or -1 + * if no case has this value. + */ int DCSwitch:: get_case_by_value(const string &case_value) const { CasesByValue::const_iterator vi; @@ -137,56 +116,45 @@ get_case_by_value(const string &case_value) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_case -// Access: Published -// Description: Returns the DCPackerInterface that packs the nth case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface that packs the nth case. + */ DCPackerInterface *DCSwitch:: get_case(int n) const { nassertr(n >= 0 && n < (int)_cases.size(), NULL); return _cases[n]->_fields; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_default_case -// Access: Published -// Description: Returns the DCPackerInterface that packs the default -// case, or NULL if there is no default case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface that packs the default case, or NULL if there + * is no default case. + */ DCPackerInterface *DCSwitch:: get_default_case() const { return _default_case; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_value -// Access: Published -// Description: Returns the packed value associated with the -// indicated case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the packed value associated with the indicated case. + */ string DCSwitch:: get_value(int case_index) const { nassertr(case_index >= 0 && case_index < (int)_cases.size(), string()); return _cases[case_index]->_value; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_num_fields -// Access: Published -// Description: Returns the number of fields in the indicated case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of fields in the indicated case. + */ int DCSwitch:: get_num_fields(int case_index) const { nassertr(case_index >= 0 && case_index < (int)_cases.size(), 0); return _cases[case_index]->_fields->_fields.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_num_fields -// Access: Published -// Description: Returns the nth field in the indicated case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth field in the indicated case. + */ DCField *DCSwitch:: get_field(int case_index, int n) const { nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); @@ -194,12 +162,10 @@ get_field(int case_index, int n) const { return _cases[case_index]->_fields->_fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::get_field_by_name -// Access: Published -// Description: Returns the field with the given name from the -// indicated case, or NULL if no field has this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the field with the given name from the indicated case, or NULL if + * no field has this name. + */ DCField *DCSwitch:: get_field_by_name(int case_index, const string &name) const { nassertr(case_index >= 0 && case_index < (int)_cases.size(), NULL); @@ -214,26 +180,20 @@ get_field_by_name(int case_index, const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::is_field_valid -// Access: Public -// Description: Returns true if it is valid to add a new field at -// this point (implying that a case or default has been -// added already), or false if not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is valid to add a new field at this point (implying that + * a case or default has been added already), or false if not. + */ bool DCSwitch:: is_field_valid() const { return !_current_fields.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::add_case -// Access: Public -// Description: Adds a new case to the switch with the indicated -// value, and returns the new case_index. If the value -// has already been used for another case, returns -1. -// This is normally called only by the parser. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new case to the switch with the indicated value, and returns the new + * case_index. If the value has already been used for another case, returns + * -1. This is normally called only by the parser. + */ int DCSwitch:: add_case(const string &value) { int case_index = (int)_cases.size(); @@ -248,28 +208,22 @@ add_case(const string &value) { return case_index; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::add_invalid_case -// Access: Public -// Description: Adds a new case to the switch that will never be -// matched. This is only used by the parser, to handle -// an error condition more gracefully without bitching -// the parsing (which behaves differently according to -// whether a case has been encountered or not). -//////////////////////////////////////////////////////////////////// +/** + * Adds a new case to the switch that will never be matched. This is only + * used by the parser, to handle an error condition more gracefully without + * bitching the parsing (which behaves differently according to whether a case + * has been encountered or not). + */ void DCSwitch:: add_invalid_case() { start_new_case(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::add_default -// Access: Public -// Description: Adds a default case to the switch. Returns true if -// the case is successfully added, or false if it had -// already been added. This is normally called only by -// the parser. -//////////////////////////////////////////////////////////////////// +/** + * Adds a default case to the switch. Returns true if the case is + * successfully added, or false if it had already been added. This is + * normally called only by the parser. + */ bool DCSwitch:: add_default() { if (_default_case != (SwitchFields *)NULL) { @@ -282,17 +236,13 @@ add_default() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::add_field -// Access: Public -// Description: Adds a field to the currently active cases (those -// that have been added via add_case() or add_default(), -// since the last call to add_break()). Returns true if -// successful, false if the field duplicates a field -// already named within this case. It is an error to -// call this before calling add_case() or add_default(). -// This is normally called only by the parser. -//////////////////////////////////////////////////////////////////// +/** + * Adds a field to the currently active cases (those that have been added via + * add_case() or add_default(), since the last call to add_break()). Returns + * true if successful, false if the field duplicates a field already named + * within this case. It is an error to call this before calling add_case() or + * add_default(). This is normally called only by the parser. + */ bool DCSwitch:: add_field(DCField *field) { nassertr(!_current_fields.empty(), false); @@ -312,27 +262,21 @@ add_field(DCField *field) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::add_break -// Access: Public -// Description: Adds a break statement to the switch. This closes -// the currently open cases and prepares for a new, -// unrelated case. -//////////////////////////////////////////////////////////////////// +/** + * Adds a break statement to the switch. This closes the currently open cases + * and prepares for a new, unrelated case. + */ void DCSwitch:: add_break() { _current_fields.clear(); _fields_added = false; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::apply_switch -// Access: Public -// Description: Returns the DCPackerInterface that presents the -// alternative fields for the case indicated by the -// given packed value string, or NULL if the value -// string does not match one of the expected cases. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface that presents the alternative fields for the + * case indicated by the given packed value string, or NULL if the value + * string does not match one of the expected cases. + */ const DCPackerInterface *DCSwitch:: apply_switch(const char *value_data, size_t length) const { CasesByValue::const_iterator vi; @@ -350,34 +294,27 @@ apply_switch(const char *value_data, size_t length) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::output -// Access: Public, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCSwitch:: output(ostream &out, bool brief) const { output_instance(out, brief, "", "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::write -// Access: Public, Virtual -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCSwitch:: write(ostream &out, bool brief, int indent_level) const { write_instance(out, brief, indent_level, "", "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::output_instance -// Access: Public -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCSwitch:: output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { @@ -418,12 +355,10 @@ output_instance(ostream &out, bool brief, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::write_instance -// Access: Public, Virtual -// Description: Generates a parseable description of the object to -// the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates a parseable description of the object to the indicated output + * stream. + */ void DCSwitch:: write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, @@ -470,12 +405,9 @@ write_instance(ostream &out, bool brief, int indent_level, out << ";\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this switch into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this switch into the hash. + */ void DCSwitch:: generate_hash(HashGenerator &hashgen) const { hashgen.add_string(_name); @@ -506,30 +438,26 @@ generate_hash(HashGenerator &hashgen) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::pack_default_value -// Access: Public -// Description: Packs the switchParameter's specified default value -// (or a sensible default if no value is specified) into -// the stream. Returns true if the default value is -// packed, false if the switchParameter doesn't know how -// to pack its default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the switchParameter's specified default value (or a sensible default + * if no value is specified) into the stream. Returns true if the default + * value is packed, false if the switchParameter doesn't know how to pack its + * default value. + */ bool DCSwitch:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { SwitchFields *fields = NULL; DCPacker packer; packer.begin_pack(_key_parameter); if (!_cases.empty()) { - // If we have any cases, the first case is always the default - // case, regardless of the default value specified by the key - // parameter. That's just the easiest to code. + // If we have any cases, the first case is always the default case, + // regardless of the default value specified by the key parameter. That's + // just the easiest to code. packer.pack_literal_value(_cases[0]->_value); fields = _cases[0]->_fields; } else { - // If we don't have any cases, just pack the key parameter's - // default. + // If we don't have any cases, just pack the key parameter's default. packer.pack_default_value(); fields = _default_case; } @@ -557,15 +485,12 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::do_check_match_switch -// Access: Public -// Description: Returns true if this switch matches the indicated -// other switch--that is, the two switches are bitwise -// equivalent--false otherwise. This is only intended -// to be called internally from -// DCSwitchParameter::do_check_match_switch_parameter(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this switch matches the indicated other switch--that is, + * the two switches are bitwise equivalent--false otherwise. This is only + * intended to be called internally from + * DCSwitchParameter::do_check_match_switch_parameter(). + */ bool DCSwitch:: do_check_match_switch(const DCSwitch *other) const { if (!_key_parameter->check_match(other->_key_parameter)) { @@ -597,23 +522,19 @@ do_check_match_switch(const DCSwitch *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::start_new_case -// Access: Private -// Description: Creates a new field set for the new case, or shares -// the field set with the previous case, as appropriate. -// Returns the appropriate field set. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new field set for the new case, or shares the field set with the + * previous case, as appropriate. Returns the appropriate field set. + */ DCSwitch::SwitchFields *DCSwitch:: start_new_case() { SwitchFields *fields = NULL; if (_current_fields.empty() || _fields_added) { - // If we have recently encountered a break (which removes all of - // the current field sets) or if we have already added at least - // one field to the previous case without an intervening break, - // then we can't share the field set with the previous case. - // Create a new one. + // If we have recently encountered a break (which removes all of the + // current field sets) or if we have already added at least one field to + // the previous case without an intervening break, then we can't share the + // field set with the previous case. Create a new one. fields = new SwitchFields(_name); fields->add_field(_key_parameter); @@ -631,11 +552,9 @@ start_new_case() { } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch::SwitchFields:: SwitchFields(const string &name) : DCPackerInterface(name) @@ -651,40 +570,32 @@ SwitchFields(const string &name) : _has_default_value = false; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch::SwitchFields:: ~SwitchFields() { - // We don't delete any of the nested fields here, since they might - // be shared by multiple SwitchFields objects. Instead, we delete - // them in the DCSwitch destructor. + // We don't delete any of the nested fields here, since they might be shared + // by multiple SwitchFields objects. Instead, we delete them in the + // DCSwitch destructor. } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCSwitch::SwitchFields:: get_nested_field(int n) const { nassertr(n >= 0 && n < (int)_fields.size(), NULL); return _fields[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::add_field -// Access: Public -// Description: Adds a field to this case. Returns true if -// successful, false if the field duplicates a field -// already named within this case. This is normally -// called only by the parser. -//////////////////////////////////////////////////////////////////// +/** + * Adds a field to this case. Returns true if successful, false if the field + * duplicates a field already named within this case. This is normally called + * only by the parser. + */ bool DCSwitch::SwitchFields:: add_field(DCField *field) { if (!field->get_name().empty()) { @@ -717,14 +628,11 @@ add_field(DCField *field) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::do_check_match_switch_case -// Access: Public -// Description: Returns true if this case matches the indicated -// case, false otherwise. This is only intended to be -// called internally from -// DCSwitch::do_check_match_switch(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this case matches the indicated case, false otherwise. + * This is only intended to be called internally from + * DCSwitch::do_check_match_switch(). + */ bool DCSwitch::SwitchFields:: do_check_match_switch_case(const DCSwitch::SwitchFields *other) const { if (_fields.size() != other->_fields.size()) { @@ -739,11 +647,9 @@ do_check_match_switch_case(const DCSwitch::SwitchFields *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCSwitch::SwitchFields:: output(ostream &out, bool brief) const { Fields::const_iterator fi; @@ -759,11 +665,9 @@ output(ostream &out, bool brief) const { out << "break; "; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCSwitch::SwitchFields:: write(ostream &out, bool brief, int indent_level) const { Fields::const_iterator fi; @@ -779,14 +683,11 @@ write(ostream &out, bool brief, int indent_level) const { << "break;\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchFields::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCSwitch::SwitchFields:: do_check_match(const DCPackerInterface *) const { // This should never be called on a SwitchFields. @@ -794,11 +695,9 @@ do_check_match(const DCPackerInterface *) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchCase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch::SwitchCase:: SwitchCase(const string &value, DCSwitch::SwitchFields *fields) : _value(value), @@ -806,23 +705,18 @@ SwitchCase(const string &value, DCSwitch::SwitchFields *fields) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchCase::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitch::SwitchCase:: ~SwitchCase() { } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitch::SwitchCase::do_check_match_switch_case -// Access: Public -// Description: Returns true if this case matches the indicated -// case, false otherwise. This is only intended to be -// called internally from -// DCSwitch::do_check_match_switch(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this case matches the indicated case, false otherwise. + * This is only intended to be called internally from + * DCSwitch::do_check_match_switch(). + */ bool DCSwitch::SwitchCase:: do_check_match_switch_case(const DCSwitch::SwitchCase *other) const { return _fields->do_check_match_switch_case(other->_fields); diff --git a/direct/src/dcparser/dcSwitch.h b/direct/src/dcparser/dcSwitch.h index ac31ee13e2..355edd2403 100644 --- a/direct/src/dcparser/dcSwitch.h +++ b/direct/src/dcparser/dcSwitch.h @@ -1,16 +1,15 @@ -// Filename: dcSwitch.h -// Created by: drose (23Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSwitch.h + * @author drose + * @date 2004-06-23 + */ #ifndef DCSWITCH_H #define DCSWITCH_H @@ -23,13 +22,11 @@ class DCParameter; class HashGenerator; class DCField; -//////////////////////////////////////////////////////////////////// -// Class : DCSwitch -// Description : This represents a switch statement, which can appear -// inside a class body and represents two or more -// alternative unpacking schemes based on the first -// field read. -//////////////////////////////////////////////////////////////////// +/** + * This represents a switch statement, which can appear inside a class body + * and represents two or more alternative unpacking schemes based on the first + * field read. + */ class EXPCL_DIRECT DCSwitch : public DCDeclaration { public: DCSwitch(const string &name, DCField *key_parameter); @@ -64,7 +61,7 @@ public: virtual void output(ostream &out, bool brief) const; virtual void write(ostream &out, bool brief, int indent_level) const; - void output_instance(ostream &out, bool brief, const string &prename, + void output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const; void write_instance(ostream &out, bool brief, int indent_level, const string &prename, const string &name, @@ -122,20 +119,20 @@ private: Cases _cases; SwitchFields *_default_case; - // All SwitchFields created and used by the DCSwitch object are also - // stored here; this is the vector that "owns" the pointers. + // All SwitchFields created and used by the DCSwitch object are also stored + // here; this is the vector that "owns" the pointers. typedef pvector CaseFields; CaseFields _case_fields; - // All nested DCField objects that have been added to one or more of - // the above SwitchFields are also recorded here; this is the vector - // that "owns" these pointers. + // All nested DCField objects that have been added to one or more of the + // above SwitchFields are also recorded here; this is the vector that "owns" + // these pointers. Fields _nested_fields; - // These are the SwitchFields that are currently being filled up - // during this stage of the parser. There might be more than one at - // a time, if we have multiple cases being introduced in the middle - // of a series of fields (without a break statement intervening). + // These are the SwitchFields that are currently being filled up during this + // stage of the parser. There might be more than one at a time, if we have + // multiple cases being introduced in the middle of a series of fields + // (without a break statement intervening). CaseFields _current_fields; bool _fields_added; diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index c558ead54b..0dcc741861 100644 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -1,26 +1,23 @@ -// Filename: dcSwitchParameter.cxx -// Created by: drose (18Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSwitchParameter.cxx + * @author drose + * @date 2004-06-18 + */ #include "dcSwitchParameter.h" #include "dcSwitch.h" #include "hashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitchParameter:: DCSwitchParameter(const DCSwitch *dswitch) : _dswitch(dswitch) @@ -31,10 +28,10 @@ DCSwitchParameter(const DCSwitch *dswitch) : _fixed_byte_size = 0; _has_fixed_structure = false; - // The DCSwitch presents just one nested field initially, which is - // the key parameter. When we pack or unpack that, the DCPacker - // calls apply_switch(), which returns a new record that presents - // the remaining nested fields. + // The DCSwitch presents just one nested field initially, which is the key + // parameter. When we pack or unpack that, the DCPacker calls + // apply_switch(), which returns a new record that presents the remaining + // nested fields. _has_nested_fields = true; _num_nested_fields = 1; @@ -51,12 +48,12 @@ DCSwitchParameter(const DCSwitch *dswitch) : // Consider each case for fixed size, etc. for (int i = 0; i < num_cases; i++) { - const DCSwitch::SwitchFields *fields = + const DCSwitch::SwitchFields *fields = (const DCSwitch::SwitchFields *)_dswitch->get_case(i); - - if (!fields->has_fixed_byte_size() || + + if (!fields->has_fixed_byte_size() || fields->get_fixed_byte_size() != _fixed_byte_size) { - + // Nope, we have a variable byte size. _has_fixed_byte_size = false; } @@ -67,24 +64,22 @@ DCSwitchParameter(const DCSwitch *dswitch) : } // Also consider the default case, if there is one. - const DCSwitch::SwitchFields *fields = + const DCSwitch::SwitchFields *fields = (DCSwitch::SwitchFields *)_dswitch->get_default_case(); if (fields != (DCSwitch::SwitchFields *)NULL) { - if (!fields->has_fixed_byte_size() || + if (!fields->has_fixed_byte_size() || fields->get_fixed_byte_size() != _fixed_byte_size) { _has_fixed_byte_size = false; } - + _has_range_limits = _has_range_limits || fields->has_range_limits(); _has_default_value = _has_default_value || fields->_has_default_value; } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitchParameter:: DCSwitchParameter(const DCSwitchParameter ©) : DCParameter(copy), @@ -92,92 +87,73 @@ DCSwitchParameter(const DCSwitchParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCSwitchParameter *DCSwitchParameter:: as_switch_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::as_switch_parameter -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DCSwitchParameter *DCSwitchParameter:: as_switch_parameter() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::make_copy -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCParameter *DCSwitchParameter:: make_copy() const { return new DCSwitchParameter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::is_valid -// Access: Published, Virtual -// Description: Returns false if the type is an invalid type -// (e.g. declared from an undefined typedef), true if -// it is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the type is an invalid type (e.g. declared from an + * undefined typedef), true if it is valid. + */ bool DCSwitchParameter:: is_valid() const { return true; //_dswitch->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::get_switch -// Access: Published -// Description: Returns the switch object this parameter represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the switch object this parameter represents. + */ const DCSwitch *DCSwitchParameter:: get_switch() const { return _dswitch; } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::get_nested_field -// Access: Public, Virtual -// Description: Returns the DCPackerInterface object that represents -// the nth nested field. This may return NULL if there -// is no such field (but it shouldn't do this if n is in -// the range 0 <= n < get_num_nested_fields()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface object that represents the nth nested field. + * This may return NULL if there is no such field (but it shouldn't do this if + * n is in the range 0 <= n < get_num_nested_fields()). + */ DCPackerInterface *DCSwitchParameter:: get_nested_field(int) const { return _dswitch->get_key_parameter(); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::apply_switch -// Access: Public -// Description: Returns the DCPackerInterface that presents the -// alternative fields for the case indicated by the -// given packed value string, or NULL if the value -// string does not match one of the expected cases. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCPackerInterface that presents the alternative fields for the + * case indicated by the given packed value string, or NULL if the value + * string does not match one of the expected cases. + */ const DCPackerInterface *DCSwitchParameter:: apply_switch(const char *value_data, size_t length) const { return _dswitch->apply_switch(value_data, length); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::output_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCSwitchParameter:: -output_instance(ostream &out, bool brief, const string &prename, +output_instance(ostream &out, bool brief, const string &prename, const string &name, const string &postname) const { if (get_typedef() != (DCTypedef *)NULL) { output_typedef_name(out, brief, prename, name, postname); @@ -187,15 +163,13 @@ output_instance(ostream &out, bool brief, const string &prename, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::write_instance -// Access: Public, Virtual -// Description: Formats the parameter in the C++-like dc syntax as a -// typename and identifier. -//////////////////////////////////////////////////////////////////// +/** + * Formats the parameter in the C++-like dc syntax as a typename and + * identifier. + */ void DCSwitchParameter:: write_instance(ostream &out, bool brief, int indent_level, - const string &prename, const string &name, + const string &prename, const string &name, const string &postname) const { if (get_typedef() != (DCTypedef *)NULL) { write_typedef_name(out, brief, indent_level, prename, name, postname); @@ -205,27 +179,21 @@ write_instance(ostream &out, bool brief, int indent_level, } } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::generate_hash -// Access: Public, Virtual -// Description: Accumulates the properties of this type into the -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the properties of this type into the hash. + */ void DCSwitchParameter:: generate_hash(HashGenerator &hashgen) const { DCParameter::generate_hash(hashgen); _dswitch->generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::pack_default_value -// Access: Public, Virtual -// Description: Packs the switchParameter's specified default value (or a -// sensible default if no value is specified) into the -// stream. Returns true if the default value is packed, -// false if the switchParameter doesn't know how to pack its -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Packs the switchParameter's specified default value (or a sensible default + * if no value is specified) into the stream. Returns true if the default + * value is packed, false if the switchParameter doesn't know how to pack its + * default value. + */ bool DCSwitchParameter:: pack_default_value(DCPackData &pack_data, bool &pack_error) const { if (has_default_value()) { @@ -235,25 +203,20 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return _dswitch->pack_default_value(pack_data, pack_error); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::do_check_match -// Access: Protected, Virtual -// Description: Returns true if the other interface is bitwise the -// same as this one--that is, a uint32 only matches a -// uint32, etc. Names of components, and range limits, -// are not compared. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the other interface is bitwise the same as this one--that + * is, a uint32 only matches a uint32, etc. Names of components, and range + * limits, are not compared. + */ bool DCSwitchParameter:: do_check_match(const DCPackerInterface *other) const { return other->do_check_match_switch_parameter(this); } -//////////////////////////////////////////////////////////////////// -// Function: DCSwitchParameter::do_check_match_switch_parameter -// Access: Protected, Virtual -// Description: Returns true if this field matches the indicated -// switch parameter, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this field matches the indicated switch parameter, false + * otherwise. + */ bool DCSwitchParameter:: do_check_match_switch_parameter(const DCSwitchParameter *other) const { return _dswitch->do_check_match_switch(other->_dswitch); diff --git a/direct/src/dcparser/dcSwitchParameter.h b/direct/src/dcparser/dcSwitchParameter.h index 53d86796df..4456cfd6a5 100644 --- a/direct/src/dcparser/dcSwitchParameter.h +++ b/direct/src/dcparser/dcSwitchParameter.h @@ -1,16 +1,15 @@ -// Filename: dcSwitchParameter.h -// Created by: drose (29Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcSwitchParameter.h + * @author drose + * @date 2004-06-29 + */ #ifndef DCSWITCHPARAMETER_H #define DCSWITCHPARAMETER_H @@ -20,12 +19,10 @@ class DCSwitch; -//////////////////////////////////////////////////////////////////// -// Class : DCSwitchParameter -// Description : This represents a switch object used as a -// parameter itself, which packs the appropriate fields -// of the switch into the message. -//////////////////////////////////////////////////////////////////// +/** + * This represents a switch object used as a parameter itself, which packs the + * appropriate fields of the switch into the message. + */ class EXPCL_DIRECT DCSwitchParameter : public DCParameter { public: DCSwitchParameter(const DCSwitch *dswitch); diff --git a/direct/src/dcparser/dcTypedef.cxx b/direct/src/dcparser/dcTypedef.cxx index 7f75377152..cc45f74d49 100644 --- a/direct/src/dcparser/dcTypedef.cxx +++ b/direct/src/dcparser/dcTypedef.cxx @@ -1,29 +1,25 @@ -// Filename: dcTypedef.cxx -// Created by: drose (17Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcTypedef.cxx + * @author drose + * @date 2004-06-17 + */ #include "dcTypedef.h" #include "dcParameter.h" #include "dcSimpleParameter.h" #include "dcindent.h" -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::Constructor -// Access: Public -// Description: The DCTypedef object becomes the owner of the -// supplied parameter pointer and will delete it upon -// destruction. -//////////////////////////////////////////////////////////////////// +/** + * The DCTypedef object becomes the owner of the supplied parameter pointer + * and will delete it upon destruction. + */ DCTypedef:: DCTypedef(DCParameter *parameter, bool implicit) : _parameter(parameter), @@ -33,11 +29,9 @@ DCTypedef(DCParameter *parameter, bool implicit) : { } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::Constructor -// Access: Public -// Description: Creates a bogus typedef reference. -//////////////////////////////////////////////////////////////////// +/** + * Creates a bogus typedef reference. + */ DCTypedef:: DCTypedef(const string &name) : _parameter(new DCSimpleParameter(ST_invalid)), @@ -48,44 +42,34 @@ DCTypedef(const string &name) : _parameter->set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DCTypedef:: ~DCTypedef() { delete _parameter; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::get_number -// Access: Published -// Description: Returns a unique index number associated with this -// typedef definition. This is defined implicitly when -// the .dc file(s) are read. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique index number associated with this typedef definition. + * This is defined implicitly when the .dc file(s) are read. + */ int DCTypedef:: get_number() const { return _number; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::get_name -// Access: Published -// Description: Returns the name of this typedef. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this typedef. + */ const string &DCTypedef:: get_name() const { return _parameter->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::get_description -// Access: Published -// Description: Returns a brief decription of the typedef, useful for -// human consumption. -//////////////////////////////////////////////////////////////////// +/** + * Returns a brief decription of the typedef, useful for human consumption. + */ string DCTypedef:: get_description() const { ostringstream strm; @@ -93,38 +77,30 @@ get_description() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::is_bogus_typedef -// Access: Public -// Description: Returns true if the typedef has been flagged as a bogus -// typedef. This is set for typedefs that are generated by -// the parser as placeholder for missing typedefs, as -// when reading a partial file; it should not occur in a -// normal valid dc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the typedef has been flagged as a bogus typedef. This is + * set for typedefs that are generated by the parser as placeholder for + * missing typedefs, as when reading a partial file; it should not occur in a + * normal valid dc file. + */ bool DCTypedef:: is_bogus_typedef() const { return _bogus_typedef; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::is_implicit_typedef -// Access: Public -// Description: Returns true if the typedef has been flagged as an -// implicit typedef, meaning it was created for a -// DCClass that was referenced inline as a type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the typedef has been flagged as an implicit typedef, + * meaning it was created for a DCClass that was referenced inline as a type. + */ bool DCTypedef:: is_implicit_typedef() const { return _implicit_typedef; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::make_new_parameter -// Access: Public -// Description: Returns a newly-allocated DCParameter object that -// uses the same type as that named by the typedef. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated DCParameter object that uses the same type as + * that named by the typedef. + */ DCParameter *DCTypedef:: make_new_parameter() const { DCParameter *new_parameter = _parameter->make_copy(); @@ -133,42 +109,34 @@ make_new_parameter() const { return new_parameter; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::set_number -// Access: Public -// Description: Assigns the unique number to this typedef. This is -// normally called only by the DCFile interface as the -// typedef is added. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the unique number to this typedef. This is normally called only by + * the DCFile interface as the typedef is added. + */ void DCTypedef:: set_number(int number) { _number = number; } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::output -// Access: Public, Virtual -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DCTypedef:: output(ostream &out, bool brief) const { out << "typedef "; _parameter->output(out, false); } -//////////////////////////////////////////////////////////////////// -// Function: DCTypedef::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DCTypedef:: write(ostream &out, bool brief, int indent_level) const { indent(out, indent_level) << "typedef "; - // We need to preserve the parameter name in the typedef (this is - // the typedef name); hence, we pass brief = false to output(). + // We need to preserve the parameter name in the typedef (this is the + // typedef name); hence, we pass brief = false to output(). _parameter->output(out, false); out << ";"; diff --git a/direct/src/dcparser/dcTypedef.h b/direct/src/dcparser/dcTypedef.h index cd0f6b1c74..515df985af 100644 --- a/direct/src/dcparser/dcTypedef.h +++ b/direct/src/dcparser/dcTypedef.h @@ -1,16 +1,15 @@ -// Filename: dcTypedef.h -// Created by: drose (17Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcTypedef.h + * @author drose + * @date 2004-06-17 + */ #ifndef DCTYPEDEF_H #define DCTYPEDEF_H @@ -20,12 +19,10 @@ class DCParameter; -//////////////////////////////////////////////////////////////////// -// Class : DCTypedef -// Description : This represents a single typedef declaration in the -// dc file. It assigns a particular type to a new name, -// just like a C typedef. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single typedef declaration in the dc file. It assigns a + * particular type to a new name, just like a C typedef. + */ class EXPCL_DIRECT DCTypedef : public DCDeclaration { public: DCTypedef(DCParameter *parameter, bool implicit = false); diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index 0e99efea8c..2e28fca2ef 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -1,30 +1,29 @@ -// Filename: dcbase.h -// Created by: drose (05Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcbase.h + * @author drose + * @date 2000-10-05 + */ #ifndef DCBASE_H #define DCBASE_H -// This file defines a few headers and stuff necessary for compilation -// of the files in this directory. This is different from most of the -// other source directories within Panda, since the dcparser is -// designed to be compilable outside of Panda (for use by the server -// code). Therefore, it must not depend on including any of the Panda -// header files, and we have to duplicate some setup stuff here. +// This file defines a few headers and stuff necessary for compilation of the +// files in this directory. This is different from most of the other source +// directories within Panda, since the dcparser is designed to be compilable +// outside of Panda (for use by the server code). Therefore, it must not +// depend on including any of the Panda header files, and we have to duplicate +// some setup stuff here. #ifdef WITHIN_PANDA -// On the other hand, if WITHIN_PANDA is defined, we *are* safely -// within the Panda environment. +// On the other hand, if WITHIN_PANDA is defined, we *are* safely within the +// Panda environment. #include "directbase.h" #include "pnotify.h" @@ -51,9 +50,9 @@ #include #include -// These header files are needed to compile dcLexer.cxx, the output -// from flex. flex doesn't create a perfectly windows-friendly source -// file right out of the box. +// These header files are needed to compile dcLexer.cxx, the output from flex. +// flex doesn't create a perfectly windows-friendly source file right out of +// the box. #ifdef WIN32 #include #include @@ -66,35 +65,35 @@ using namespace std; #define INLINE inline #define TYPENAME typename -// These symbols are used within the Panda environment for exporting -// classes and functions to the scripting language. They're largely -// meaningless if we're not compiling within Panda. +// These symbols are used within the Panda environment for exporting classes +// and functions to the scripting language. They're largely meaningless if +// we're not compiling within Panda. #define PUBLISHED public #define BEGIN_PUBLISH #define END_PUBLISH #define BLOCKING -// Panda defines some assert-type macros. We map those to the -// standard assert macro outside of Panda. +// Panda defines some assert-type macros. We map those to the standard assert +// macro outside of Panda. #define nassertr(condition, return_value) assert(condition) #define nassertr_always(condition, return_value) assert(condition) #define nassertv(condition) assert(condition) #define nassertv_always(condition) assert(condition) -// Panda defines these export symbols for building DLL's. Outside of -// Panda, we assume we're not putting this code in a DLL, so we define -// them to nothing. +// Panda defines these export symbols for building DLL's. Outside of Panda, +// we assume we're not putting this code in a DLL, so we define them to +// nothing. #define EXPCL_DIRECT #define EXPTP_DIRECT -// Panda defines a special Filename class. We'll use an ordinary -// string instead. +// Panda defines a special Filename class. We'll use an ordinary string +// instead. typedef string Filename; -// Panda defines WORDS_BIGENDIAN on a bigendian machine; otherwise, -// the machine is assumed to be littleendian. Outside of Panda, -// you're responsible for defining this yourself if necessary. -//#define WORDS_BIGENDIAN +// Panda defines WORDS_BIGENDIAN on a bigendian machine; otherwise, the +// machine is assumed to be littleendian. Outside of Panda, you're +// responsible for defining this yourself if necessary. #define +// WORDS_BIGENDIAN #include #include @@ -121,7 +120,7 @@ typedef fstream pfstream; #endif // WITHIN_PANDA -//typedef unsigned long CHANNEL_TYPE; +// typedef unsigned long CHANNEL_TYPE; typedef PN_uint64 CHANNEL_TYPE; typedef PN_uint32 DOID_TYPE; typedef PN_uint32 ZONEID_TYPE; diff --git a/direct/src/dcparser/dcindent.cxx b/direct/src/dcparser/dcindent.cxx index 1719f9bb26..ae466667ac 100644 --- a/direct/src/dcparser/dcindent.cxx +++ b/direct/src/dcparser/dcindent.cxx @@ -1,25 +1,23 @@ -// Filename: dcindent.cxx -// Created by: drose (05May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcindent.cxx + * @author drose + * @date 2000-05-05 + */ #include "dcindent.h" #ifndef WITHIN_PANDA -//////////////////////////////////////////////////////////////////// -// Function: indent -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & indent(ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { diff --git a/direct/src/dcparser/dcindent.h b/direct/src/dcparser/dcindent.h index dd505be657..48cfddb7d7 100644 --- a/direct/src/dcparser/dcindent.h +++ b/direct/src/dcparser/dcindent.h @@ -1,16 +1,15 @@ -// Filename: dcindent.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcindent.h + * @author drose + * @date 1999-01-16 + */ #ifndef DCINDENT_H #define DCINDENT_H @@ -18,21 +17,18 @@ #include "dcbase.h" #ifdef WITHIN_PANDA -// If we're compiling this within Panda, we use the function defined -// there. +// If we're compiling this within Panda, we use the function defined there. #include "indent.h" #else // Otherwise, we must define it for ourselves. -//////////////////////////////////////////////////////////////////// -// Function: indent -// Description: A handy function for doing text formatting. This -// function simply outputs the indicated number of -// spaces to the given output stream, returning the -// stream itself. Useful for indenting a series of -// lines of text by a given amount. -//////////////////////////////////////////////////////////////////// +/** + * A handy function for doing text formatting. This function simply outputs + * the indicated number of spaces to the given output stream, returning the + * stream itself. Useful for indenting a series of lines of text by a given + * amount. + */ ostream & indent(ostream &out, int indent_level); diff --git a/direct/src/dcparser/dcmsgtypes.h b/direct/src/dcparser/dcmsgtypes.h index 0911a03585..e5bbe81614 100644 --- a/direct/src/dcparser/dcmsgtypes.h +++ b/direct/src/dcparser/dcmsgtypes.h @@ -1,23 +1,21 @@ -// Filename: dcmsgtypes.h -// Created by: drose (18May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcmsgtypes.h + * @author drose + * @date 2004-05-18 + */ #ifndef DCMSGTYPES_H #define DCMSGTYPES_H -// This file defines the server message types used within this module. -// It duplicates some symbols defined in MsgTypes.py and -// AIMsgTypes.py. +// This file defines the server message types used within this module. It +// duplicates some symbols defined in MsgTypes.py and AIMsgTypes.py. #define CLIENT_OBJECT_UPDATE_FIELD 24 #define CLIENT_CREATE_OBJECT_REQUIRED 34 @@ -33,4 +31,3 @@ #define CLIENT_OBJECT_GENERATE_CMU 9002 #endif - diff --git a/direct/src/dcparser/hashGenerator.cxx b/direct/src/dcparser/hashGenerator.cxx index 2d3b2bb77f..b5a092f95c 100644 --- a/direct/src/dcparser/hashGenerator.cxx +++ b/direct/src/dcparser/hashGenerator.cxx @@ -1,47 +1,42 @@ -// Filename: hashGenerator.cxx -// Created by: drose (22Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashGenerator.cxx + * @author drose + * @date 2001-03-22 + */ #include "hashGenerator.h" #include "primeNumberGenerator.h" -// We multiply each consecutive integer by the next prime number and -// add it to the total. This will generate pretty evenly-distributed -// hash numbers for an arbitrary sequence of ints. +// We multiply each consecutive integer by the next prime number and add it to +// the total. This will generate pretty evenly-distributed hash numbers for +// an arbitrary sequence of ints. -// We do recycle the prime number table at some point, just to keep it -// from growing insanely large, however (and to avoid wasting time -// computing large prime numbers unnecessarily), and we also truncate -// the result to the low-order 32 bits. +// We do recycle the prime number table at some point, just to keep it from +// growing insanely large, however (and to avoid wasting time computing large +// prime numbers unnecessarily), and we also truncate the result to the low- +// order 32 bits. static const int max_prime_numbers = 10000; -//////////////////////////////////////////////////////////////////// -// Function: HashGenerator::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HashGenerator:: HashGenerator() { _hash = 0; _index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: HashGenerator::add_int -// Access: Public -// Description: Adds another integer to the hash so far. -//////////////////////////////////////////////////////////////////// +/** + * Adds another integer to the hash so far. + */ void HashGenerator:: add_int(int num) { nassertv(_index >= 0 && _index < max_prime_numbers); @@ -49,12 +44,9 @@ add_int(int num) { _index = (_index + 1) % max_prime_numbers; } -//////////////////////////////////////////////////////////////////// -// Function: HashGenerator::add_string -// Access: Public -// Description: Adds a string to the hash, by breaking it down into a -// sequence of integers. -//////////////////////////////////////////////////////////////////// +/** + * Adds a string to the hash, by breaking it down into a sequence of integers. + */ void HashGenerator:: add_string(const string &str) { add_int(str.length()); @@ -64,11 +56,9 @@ add_string(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: HashGenerator::get_hash -// Access: Public -// Description: Returns the hash number generated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the hash number generated. + */ unsigned long HashGenerator:: get_hash() const { return (unsigned long)(_hash & 0xffffffff); diff --git a/direct/src/dcparser/hashGenerator.h b/direct/src/dcparser/hashGenerator.h index 49a51c50c4..6137196a39 100644 --- a/direct/src/dcparser/hashGenerator.h +++ b/direct/src/dcparser/hashGenerator.h @@ -1,16 +1,15 @@ -// Filename: hashGenerator.h -// Created by: drose (22Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashGenerator.h + * @author drose + * @date 2001-03-22 + */ #ifndef DCHASHGENERATOR_H #define DCHASHGENERATOR_H @@ -18,11 +17,9 @@ #include "dcbase.h" #include "primeNumberGenerator.h" -//////////////////////////////////////////////////////////////////// -// Class : HashGenerator -// Description : This class generates an arbitrary hash number from a -// sequence of ints. -//////////////////////////////////////////////////////////////////// +/** + * This class generates an arbitrary hash number from a sequence of ints. + */ class HashGenerator { public: HashGenerator(); diff --git a/direct/src/dcparser/primeNumberGenerator.cxx b/direct/src/dcparser/primeNumberGenerator.cxx index 8b279cf488..be3e34d4e9 100644 --- a/direct/src/dcparser/primeNumberGenerator.cxx +++ b/direct/src/dcparser/primeNumberGenerator.cxx @@ -1,48 +1,41 @@ -// Filename: primeNumberGenerator.cxx -// Created by: drose (22Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file primeNumberGenerator.cxx + * @author drose + * @date 2001-03-22 + */ #include "primeNumberGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: PrimeNumberGenerator::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PrimeNumberGenerator:: PrimeNumberGenerator() { _primes.push_back(2); } -//////////////////////////////////////////////////////////////////// -// Function: PrimeNumberGenerator::Indexing operator -// Access: Public -// Description: Returns the nth prime number. this[0] returns 2, -// this[1] returns 3; successively larger values of n -// return larger prime numbers, up to the largest prime -// number that can be represented in an int. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth prime number. this[0] returns 2, this[1] returns 3; + * successively larger values of n return larger prime numbers, up to the + * largest prime number that can be represented in an int. + */ int PrimeNumberGenerator:: operator [] (int n) { nassertr(n >= 0, 0); - // Compute the prime numbers between the last-computed prime number - // and n. + // Compute the prime numbers between the last-computed prime number and n. int candidate = _primes.back() + 1; while ((int)_primes.size() <= n) { - // Is candidate prime? It is not if any one of the already-found - // prime numbers (up to its square root) divides it evenly. + // Is candidate prime? It is not if any one of the already-found prime + // numbers (up to its square root) divides it evenly. bool maybe_prime = true; int j = 0; while (maybe_prime && _primes[j] * _primes[j] <= candidate) { diff --git a/direct/src/dcparser/primeNumberGenerator.h b/direct/src/dcparser/primeNumberGenerator.h index 88a8e14e15..d66a6f536d 100644 --- a/direct/src/dcparser/primeNumberGenerator.h +++ b/direct/src/dcparser/primeNumberGenerator.h @@ -1,16 +1,15 @@ -// Filename: primeNumberGenerator.h -// Created by: drose (22Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file primeNumberGenerator.h + * @author drose + * @date 2001-03-22 + */ #ifndef PRIMENUMBERGENERATOR_H #define PRIMENUMBERGENERATOR_H @@ -18,22 +17,19 @@ #include "dcbase.h" #ifdef WITHIN_PANDA -// We only have the vector_int header file if we're compiling this -// package within the normal Panda environment. +// We only have the vector_int header file if we're compiling this package +// within the normal Panda environment. #include "vector_int.h" #else typedef vector vector_int; #endif -//////////////////////////////////////////////////////////////////// -// Class : PrimeNumberGenerator -// Description : This class generates a table of prime numbers, up to -// the limit of an int. For a given integer n, it will -// return the nth prime number. This will involve a -// recompute step only if n is greater than any previous -// n. -//////////////////////////////////////////////////////////////////// +/** + * This class generates a table of prime numbers, up to the limit of an int. + * For a given integer n, it will return the nth prime number. This will + * involve a recompute step only if n is greater than any previous n. + */ class PrimeNumberGenerator { public: PrimeNumberGenerator(); diff --git a/direct/src/deadrec/config_deadrec.cxx b/direct/src/deadrec/config_deadrec.cxx index 320735c369..72c8c15a14 100644 --- a/direct/src/deadrec/config_deadrec.cxx +++ b/direct/src/deadrec/config_deadrec.cxx @@ -1,16 +1,15 @@ -// Filename: config_deadrec.cxx -// Created by: drose (23Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_deadrec.cxx + * @author drose + * @date 2006-10-23 + */ #include "config_deadrec.h" @@ -29,14 +28,12 @@ ConfigVariableBool accept_clock_skew "SmoothMover::get_accept_clock_skew().")); -//////////////////////////////////////////////////////////////////// -// Function: init_libdeadrec -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdeadrec() { static bool initialized = false; @@ -45,4 +42,3 @@ init_libdeadrec() { } initialized = true; } - diff --git a/direct/src/deadrec/config_deadrec.h b/direct/src/deadrec/config_deadrec.h index 47e4502b81..df1b656e32 100644 --- a/direct/src/deadrec/config_deadrec.h +++ b/direct/src/deadrec/config_deadrec.h @@ -1,16 +1,15 @@ -// Filename: config_deadrec.h -// Created by: drose (23Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_deadrec.h + * @author drose + * @date 2006-10-23 + */ #ifndef CONFIG_DEADREC_H #define CONFIG_DEADREC_H @@ -26,5 +25,3 @@ extern ConfigVariableBool accept_clock_skew; extern EXPCL_DIRECT void init_libdeadrec(); #endif - - diff --git a/direct/src/deadrec/smoothMover.I b/direct/src/deadrec/smoothMover.I index 0f91e90f3a..2e9fad4780 100644 --- a/direct/src/deadrec/smoothMover.I +++ b/direct/src/deadrec/smoothMover.I @@ -1,63 +1,49 @@ -// Filename: smoothMover.I -// Created by: drose (19Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file smoothMover.I + * @author drose + * @date 2001-10-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_pos -// Access: Published -// Description: Specifies the position of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with hpr and -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_pos(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position of the SmoothMover at a particular time in the past. + * When mark_position() is called, this will be recorded (along with hpr and + * timestamp) in a position report, which will then be used along with all + * other position reports to determine the smooth position at any particular + * instant. + * + * The return value is true if any parameter has changed since the last call + * to set_pos(), or false if they are the same. + */ INLINE bool SmoothMover:: set_pos(const LVecBase3 &pos) { return set_x(pos[0]) | set_y(pos[1]) | set_z(pos[2]); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_pos -// Access: Published -// Description: Specifies the position of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with hpr and -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_pos(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position of the SmoothMover at a particular time in the past. + * When mark_position() is called, this will be recorded (along with hpr and + * timestamp) in a position report, which will then be used along with all + * other position reports to determine the smooth position at any particular + * instant. + * + * The return value is true if any parameter has changed since the last call + * to set_pos(), or false if they are the same. + */ INLINE bool SmoothMover:: set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return set_x(x) | set_y(y) | set_z(z); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_x -// Access: Published -// Description: Sets the X position only. See set_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the X position only. See set_pos(). + */ INLINE bool SmoothMover:: set_x(PN_stdfloat x) { bool result = (x != _sample._pos[0]); @@ -70,11 +56,9 @@ set_x(PN_stdfloat x) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_y -// Access: Published -// Description: Sets the Y position only. See set_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the Y position only. See set_pos(). + */ INLINE bool SmoothMover:: set_y(PN_stdfloat y) { bool result = (y != _sample._pos[1]); @@ -87,11 +71,9 @@ set_y(PN_stdfloat y) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_z -// Access: Published -// Description: Sets the Z position only. See set_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the Z position only. See set_pos(). + */ INLINE bool SmoothMover:: set_z(PN_stdfloat z) { bool result = (z != _sample._pos[2]); @@ -104,51 +86,39 @@ set_z(PN_stdfloat z) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_hpr -// Access: Published -// Description: Specifies the orientation of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with hpr and -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_hpr(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the orientation of the SmoothMover at a particular time in the + * past. When mark_position() is called, this will be recorded (along with + * hpr and timestamp) in a position report, which will then be used along with + * all other position reports to determine the smooth position at any + * particular instant. + * + * The return value is true if any parameter has changed since the last call + * to set_hpr(), or false if they are the same. + */ INLINE bool SmoothMover:: set_hpr(const LVecBase3 &hpr) { return set_h(hpr[0]) | set_p(hpr[1]) | set_r(hpr[2]); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_hpr -// Access: Published -// Description: Specifies the orientation of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with hpr and -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_hpr(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the orientation of the SmoothMover at a particular time in the + * past. When mark_position() is called, this will be recorded (along with + * hpr and timestamp) in a position report, which will then be used along with + * all other position reports to determine the smooth position at any + * particular instant. + * + * The return value is true if any parameter has changed since the last call + * to set_hpr(), or false if they are the same. + */ INLINE bool SmoothMover:: set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { return set_h(h) | set_p(p) | set_r(r); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_h -// Access: Published -// Description: Sets the heading only. See set_hpr(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the heading only. See set_hpr(). + */ INLINE bool SmoothMover:: set_h(PN_stdfloat h) { bool result = (h != _sample._hpr[0]); @@ -161,15 +131,13 @@ set_h(PN_stdfloat h) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_p -// Access: Published -// Description: Sets the pitch only. See set_hpr(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the pitch only. See set_hpr(). + */ INLINE bool SmoothMover:: set_p(PN_stdfloat p) { bool result = (p != _sample._hpr[1]); - /* + /* if (deadrec_cat.is_debug()) { deadrec_cat.debug() << "set_p " << p << "\n"; } @@ -178,11 +146,9 @@ set_p(PN_stdfloat p) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_r -// Access: Published -// Description: Sets the roll only. See set_hpr(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the roll only. See set_hpr(). + */ INLINE bool SmoothMover:: set_r(PN_stdfloat r) { bool result = (r != _sample._hpr[2]); @@ -195,83 +161,63 @@ set_r(PN_stdfloat r) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_pos_hpr -// Access: Published -// Description: Specifies the position and orientation of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_pos_hpr(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position and orientation of the SmoothMover at a particular + * time in the past. When mark_position() is called, this will be recorded + * (along with timestamp) in a position report, which will then be used along + * with all other position reports to determine the smooth position at any + * particular instant. + * + * The return value is true if any parameter has changed since the last call + * to set_pos_hpr(), or false if they are the same. + */ INLINE bool SmoothMover:: set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { return (set_x(pos[0]) | set_y(pos[1]) | set_z(pos[2]) | set_h(hpr[0]) | set_p(hpr[1]) | set_r(hpr[2])); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_pos_hpr -// Access: Published -// Description: Specifies the position of the SmoothMover at a -// particular time in the past. When mark_position() is -// called, this will be recorded (along with -// timestamp) in a position report, which will then be -// used along with all other position reports to -// determine the smooth position at any particular -// instant. -// -// The return value is true if any parameter has changed -// since the last call to set_pos_hpr(), or false if they -// are the same. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position of the SmoothMover at a particular time in the past. + * When mark_position() is called, this will be recorded (along with + * timestamp) in a position report, which will then be used along with all + * other position reports to determine the smooth position at any particular + * instant. + * + * The return value is true if any parameter has changed since the last call + * to set_pos_hpr(), or false if they are the same. + */ INLINE bool SmoothMover:: set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { return set_x(x) | set_y(y) | set_z(z) | set_h(h) | set_p(p) | set_r(r); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_sample_pos -// Access: Published -// Description: Returns the current position of the working sample -// point. This position is updated periodically by -// set_x(), set_y(), etc., and its current value is -// copied to the sample point table when -// mark_position() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of the working sample point. This position is + * updated periodically by set_x(), set_y(), etc., and its current value is + * copied to the sample point table when mark_position() is called. + */ INLINE const LPoint3 &SmoothMover:: get_sample_pos() const { return _sample._pos; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_sample_hpr -// Access: Published -// Description: Returns the current orientation of the working sample -// point. This orientation is updated periodically by -// set_h(), set_p(), etc., and its current value is -// copied to the sample point table when -// mark_position() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current orientation of the working sample point. This + * orientation is updated periodically by set_h(), set_p(), etc., and its + * current value is copied to the sample point table when mark_position() is + * called. + */ INLINE const LVecBase3 &SmoothMover:: get_sample_hpr() const { return _sample._hpr; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_phony_timestamp -// Access: Published -// Description: Lies and specifies that the current position report -// was received now. This is usually used for very old -// position reports for which we're not sure of the -// actual receipt time. -//////////////////////////////////////////////////////////////////// +/** + * Lies and specifies that the current position report was received now. This + * is usually used for very old position reports for which we're not sure of + * the actual receipt time. + */ INLINE void SmoothMover:: set_phony_timestamp(double timestamp, bool period_adjust) { double now = ClockObject::get_global_clock()->get_frame_time(); @@ -279,8 +225,8 @@ set_phony_timestamp(double timestamp, bool period_adjust) { // we were given a specific timestamp to use now = timestamp; - // adjust by _delay when creating the timestamp since other - // timestamps received from network updates are adjusted by this + // adjust by _delay when creating the timestamp since other timestamps + // received from network updates are adjusted by this if (period_adjust) { _sample._timestamp = now - _expected_broadcast_period; } @@ -292,13 +238,11 @@ set_phony_timestamp(double timestamp, bool period_adjust) { } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_timestamp -// Access: Published -// Description: Specifies the time that the current position report -// applies. This should be called, along with set_pos() -// and set_hpr(), before a call to mark_position(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the time that the current position report applies. This should + * be called, along with set_pos() and set_hpr(), before a call to + * mark_position(). + */ INLINE void SmoothMover:: set_timestamp(double timestamp) { /* @@ -312,127 +256,102 @@ set_timestamp(double timestamp) { record_timestamp_delay(timestamp); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::has_most_recent_timestamp -// Access: Published -// Description: Returns true if we have most recently recorded timestamp -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have most recently recorded timestamp + */ INLINE bool SmoothMover:: has_most_recent_timestamp() const { return _has_most_recent_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_most_recent_timestamp -// Access: Published -// Description: Returns most recently recorded timestamp -//////////////////////////////////////////////////////////////////// +/** + * Returns most recently recorded timestamp + */ INLINE double SmoothMover:: get_most_recent_timestamp() const { return _most_recent_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_smooth_position -// Access: Published -// Description: Computes the smoothed position (and orientation) of -// the mover at the indicated point in time, based on -// the previous position reports. After this call has -// been made, get_smooth_pos() etc. may be called to -// retrieve the smoothed position. -// -// With no parameter, the function uses -// ClockObject::get_frame_time() as the default time. -//////////////////////////////////////////////////////////////////// +/** + * Computes the smoothed position (and orientation) of the mover at the + * indicated point in time, based on the previous position reports. After + * this call has been made, get_smooth_pos() etc. may be called to retrieve + * the smoothed position. + * + * With no parameter, the function uses ClockObject::get_frame_time() as the + * default time. + */ INLINE bool SmoothMover:: compute_smooth_position() { return compute_smooth_position(ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_pos -// Access: Published -// Description: Returns the smoothed position as computed by a -// previous call to compute_smooth_position(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the smoothed position as computed by a previous call to + * compute_smooth_position(). + */ INLINE const LPoint3 &SmoothMover:: get_smooth_pos() const { return _smooth_pos; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_forward_axis -// Access: Published -// Description: Returns the smoothed position as computed by a -// previous call to compute_smooth_position(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the smoothed position as computed by a previous call to + * compute_smooth_position(). + */ INLINE const LVecBase3 &SmoothMover:: get_forward_axis() const { return _forward_axis; } - -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_hpr -// Access: Published -// Description: Returns the smoothed orientation as computed by a -// previous call to compute_smooth_position(). -//////////////////////////////////////////////////////////////////// + +/** + * Returns the smoothed orientation as computed by a previous call to + * compute_smooth_position(). + */ INLINE const LVecBase3 &SmoothMover:: get_smooth_hpr() const { return _smooth_hpr; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::apply_smooth_pos -// Access: Published -// Description: Applies the smoothed position to the indicated -// NodePath. This is equivalent to calling -// node.set_pos(smooth_mover->get_smooth_pos()). It -// exists as an optimization only, to avoid the overhead -// of passing the return value through Python. -//////////////////////////////////////////////////////////////////// +/** + * Applies the smoothed position to the indicated NodePath. This is + * equivalent to calling node.set_pos(smooth_mover->get_smooth_pos()). It + * exists as an optimization only, to avoid the overhead of passing the return + * value through Python. + */ INLINE void SmoothMover:: apply_smooth_pos(NodePath &node) const { node.set_pos(get_smooth_pos()); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::apply_smooth_pos_hpr -// Access: Published -// Description: Applies the smoothed position and orientation to the -// indicated NodePath. This is equivalent to calling -// node.set_pos_hpr(smooth_mover->get_smooth_pos(), -// smooth_mover->get_smooth_hpr()). It exists as an -// optimization only, to avoid the overhead of passing -// the return value through Python. -//////////////////////////////////////////////////////////////////// +/** + * Applies the smoothed position and orientation to the indicated NodePath. + * This is equivalent to calling + * node.set_pos_hpr(smooth_mover->get_smooth_pos(), + * smooth_mover->get_smooth_hpr()). It exists as an optimization only, to + * avoid the overhead of passing the return value through Python. + */ INLINE void SmoothMover:: apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node) const { pos_node.set_pos(get_smooth_pos()); hpr_node.set_hpr(get_smooth_hpr()); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::apply_smooth_hpr -// Access: Published -// Description: Applies the smoothed orientation to the indicated -// NodePath. This is equivalent to calling -// node.set_hpr(smooth_mover->get_smooth_hpr()). It -// exists as an optimization only, to avoid the overhead -// of passing the return value through Python. -//////////////////////////////////////////////////////////////////// +/** + * Applies the smoothed orientation to the indicated NodePath. This is + * equivalent to calling node.set_hpr(smooth_mover->get_smooth_hpr()). It + * exists as an optimization only, to avoid the overhead of passing the return + * value through Python. + */ INLINE void SmoothMover:: apply_smooth_hpr(NodePath &node) const { node.set_hpr(get_smooth_hpr()); } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_and_apply_smooth_pos -// Access: Published -// Description: A further optimization to reduce Python calls. This -// computes the smooth position and applies it to the -// indicated node in one call. -//////////////////////////////////////////////////////////////////// +/** + * A further optimization to reduce Python calls. This computes the smooth + * position and applies it to the indicated node in one call. + */ INLINE void SmoothMover:: compute_and_apply_smooth_pos(NodePath &node) { if (compute_smooth_position()) { @@ -440,14 +359,11 @@ compute_and_apply_smooth_pos(NodePath &node) { } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_and_apply_smooth_pos_hpr -// Access: Published -// Description: A further optimization to reduce Python calls. This -// computes the smooth position and applies it to the -// indicated node or nodes in one call. The pos_node -// and hpr_node might be the same NodePath. -//////////////////////////////////////////////////////////////////// +/** + * A further optimization to reduce Python calls. This computes the smooth + * position and applies it to the indicated node or nodes in one call. The + * pos_node and hpr_node might be the same NodePath. + */ INLINE void SmoothMover:: compute_and_apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node) { if (compute_smooth_position()) { @@ -456,14 +372,11 @@ compute_and_apply_smooth_pos_hpr(NodePath &pos_node, NodePath &hpr_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_and_apply_smooth_pos_hpr -// Access: Published -// Description: A further optimization to reduce Python calls. This -// computes the smooth position and applies it to the -// indicated node or nodes in one call. The pos_node -// and hpr_node might be the same NodePath. -//////////////////////////////////////////////////////////////////// +/** + * A further optimization to reduce Python calls. This computes the smooth + * position and applies it to the indicated node or nodes in one call. The + * pos_node and hpr_node might be the same NodePath. + */ INLINE void SmoothMover:: compute_and_apply_smooth_hpr(NodePath &hpr_node) { if (compute_smooth_position()) { @@ -471,293 +384,229 @@ compute_and_apply_smooth_hpr(NodePath &hpr_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_forward_velocity -// Access: Published -// Description: Returns the speed at which the avatar is moving, in -// feet per second, along its own forward axis (after -// applying the avatar's hpr). This will be a positive -// number if the avatar is moving forward, and a -// negative number if it is moving backward. -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed at which the avatar is moving, in feet per second, along + * its own forward axis (after applying the avatar's hpr). This will be a + * positive number if the avatar is moving forward, and a negative number if + * it is moving backward. + */ INLINE PN_stdfloat SmoothMover:: get_smooth_forward_velocity() const { return _smooth_forward_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_lateral_velocity -// Access: Published -// Description: Returns the speed at which the avatar is moving, in -// feet per second, along its own lateral axis (after -// applying the avatar's hpr). This will be a positive -// number if the avatar is moving right, and a -// negative number if it is moving left. -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed at which the avatar is moving, in feet per second, along + * its own lateral axis (after applying the avatar's hpr). This will be a + * positive number if the avatar is moving right, and a negative number if it + * is moving left. + */ INLINE PN_stdfloat SmoothMover:: get_smooth_lateral_velocity() const { return _smooth_lateral_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_rotational_velocity -// Access: Published -// Description: Returns the speed at which the avatar is rotating in -// the horizontal plane (i.e. heading), in degrees per -// second. This may be positive or negative, according -// to the direction of rotation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed at which the avatar is rotating in the horizontal plane + * (i.e. heading), in degrees per second. This may be positive or negative, + * according to the direction of rotation. + */ INLINE PN_stdfloat SmoothMover:: get_smooth_rotational_velocity() const { return _smooth_rotational_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_smooth_mode -// Access: Published, Static -// Description: Sets the smoothing mode of all SmoothMovers in the -// world. If this is SM_off, no smoothing or prediction -// will be performed, and get_smooth_pos() will simply -// return the position last set by mark_position(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the smoothing mode of all SmoothMovers in the world. If this is + * SM_off, no smoothing or prediction will be performed, and get_smooth_pos() + * will simply return the position last set by mark_position(). + */ INLINE void SmoothMover:: set_smooth_mode(SmoothMover::SmoothMode mode) { _smooth_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_smooth_mode -// Access: Published, Static -// Description: Returns the smoothing mode of all SmoothMovers in the -// world. See set_smooth_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the smoothing mode of all SmoothMovers in the world. See + * set_smooth_mode(). + */ INLINE SmoothMover::SmoothMode SmoothMover:: get_smooth_mode() { return _smooth_mode; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_prediction_mode -// Access: Published, Static -// Description: Sets the predictioning mode of all SmoothMovers in the -// world. If this is PM_off, no prediction will be -// performed, but smoothing might still be performed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the predictioning mode of all SmoothMovers in the world. If this is + * PM_off, no prediction will be performed, but smoothing might still be + * performed. + */ INLINE void SmoothMover:: set_prediction_mode(SmoothMover::PredictionMode mode) { _prediction_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_prediction_mode -// Access: Published, Static -// Description: Returns the predictioning mode of all SmoothMovers in the -// world. See set_prediction_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the predictioning mode of all SmoothMovers in the world. See + * set_prediction_mode(). + */ INLINE SmoothMover::PredictionMode SmoothMover:: get_prediction_mode() { return _prediction_mode; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_delay -// Access: Published, Static -// Description: Sets the amount of time, in seconds, to delay the -// computed position of a SmoothMover. This is -// particularly useful when the prediction mode is off, -// because it can allow the apparent motion of an avatar -// to appear smooth without relying on prediction, at -// the cost of introducing additional lag in the -// avatar's apparent position. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time, in seconds, to delay the computed position of a + * SmoothMover. This is particularly useful when the prediction mode is off, + * because it can allow the apparent motion of an avatar to appear smooth + * without relying on prediction, at the cost of introducing additional lag in + * the avatar's apparent position. + */ INLINE void SmoothMover:: set_delay(double delay) { _delay = delay; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_delay -// Access: Published, Static -// Description: Returns the amount of time, in seconds, to delay the -// computed position of a SmoothMover. See set_delay(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, to delay the computed position of a + * SmoothMover. See set_delay(). + */ INLINE double SmoothMover:: get_delay() { return _delay; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_accept_clock_skew -// Access: Published, Static -// Description: Sets the 'accept clock skew' flag. When this flag is -// true, clock skew from the other clients will be -// tolerated by delaying each smooth mover's position an -// additional amount, on top of that specified by -// set_delay(), based on the measured average latency -// for timestamp messages received by the client. -// -// In this way, if the other client has significant -// clock skew with respect to our clock, it will be -// evident as a large positive or negative average -// latency for timestamps. By subtracting out this -// average latency, we compensate for poor clock sync. -//////////////////////////////////////////////////////////////////// +/** + * Sets the 'accept clock skew' flag. When this flag is true, clock skew from + * the other clients will be tolerated by delaying each smooth mover's + * position an additional amount, on top of that specified by set_delay(), + * based on the measured average latency for timestamp messages received by + * the client. + * + * In this way, if the other client has significant clock skew with respect to + * our clock, it will be evident as a large positive or negative average + * latency for timestamps. By subtracting out this average latency, we + * compensate for poor clock sync. + */ INLINE void SmoothMover:: set_accept_clock_skew(bool flag) { _accept_clock_skew = flag; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_accept_clock_skew -// Access: Published, Static -// Description: Returns the current state of the 'accept clock skew' -// flag. See set_accept_clock_skew(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the 'accept clock skew' flag. See + * set_accept_clock_skew(). + */ INLINE bool SmoothMover:: get_accept_clock_skew() { return _accept_clock_skew; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_max_position_age -// Access: Published, Static -// Description: Sets the maximum amount of time a position is allowed -// to remain unchanged before assuming it represents the -// avatar actually standing still. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum amount of time a position is allowed to remain unchanged + * before assuming it represents the avatar actually standing still. + */ INLINE void SmoothMover:: set_max_position_age(double age) { _max_position_age = age; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_max_position_age -// Access: Published, Static -// Description: Returns the maximum amount of time a position is -// allowed to remain unchanged before assuming it -// represents the avatar actually standing still. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum amount of time a position is allowed to remain + * unchanged before assuming it represents the avatar actually standing still. + */ INLINE double SmoothMover:: get_max_position_age() { return _max_position_age; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_expected_broadcast_period -// Access: Published, Static -// Description: Sets the interval at which we expect the SmoothNodes -// to broadcast their position, in elapsed seconds. -// This controls the length of time we assume the object -// has truly stopped, when we receive a long sequence of -// no updates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the interval at which we expect the SmoothNodes to broadcast their + * position, in elapsed seconds. This controls the length of time we assume + * the object has truly stopped, when we receive a long sequence of no + * updates. + */ INLINE void SmoothMover:: set_expected_broadcast_period(double period) { _expected_broadcast_period = period; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_expected_broadcast_period -// Access: Published, Static -// Description: Returns the interval at which we expect the SmoothNodes -// to broadcast their position, in elapsed seconds. See -// set_expected_broadcast_period(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval at which we expect the SmoothNodes to broadcast their + * position, in elapsed seconds. See set_expected_broadcast_period(). + */ INLINE double SmoothMover:: get_expected_broadcast_period() { return _expected_broadcast_period; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_reset_velocity_age -// Access: Published, Static -// Description: Sets the amount of time that should elapse after the -// last position report before the velocity is reset to -// 0. This is similar to max_position_age, but it is -// only used to determine the resetting of the reported -// velocity. It should always be greater than or equal -// to max_position_age. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time that should elapse after the last position report + * before the velocity is reset to 0. This is similar to max_position_age, + * but it is only used to determine the resetting of the reported velocity. + * It should always be greater than or equal to max_position_age. + */ INLINE void SmoothMover:: set_reset_velocity_age(double age) { _reset_velocity_age = age; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_reset_velocity_age -// Access: Published, Static -// Description: Returns the amount of time that should elapse after -// the last position report before the velocity is reset -// to 0. See set_reset_velocity_age(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time that should elapse after the last position + * report before the velocity is reset to 0. See set_reset_velocity_age(). + */ INLINE double SmoothMover:: get_reset_velocity_age() { return _reset_velocity_age; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_directional_velocity -// Access: Published, Static -// Description: Sets the flag that indicates whether the avatar's -// direction is considered in computing the velocity. -// When this is true, velocity is automatically -// decomposed into a forward and a lateral velocity (and -// both may be positive or negative); when it is false, -// all velocity is always returned as forward velocity -// (and it is always positive). -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the avatar's direction is considered + * in computing the velocity. When this is true, velocity is automatically + * decomposed into a forward and a lateral velocity (and both may be positive + * or negative); when it is false, all velocity is always returned as forward + * velocity (and it is always positive). + */ INLINE void SmoothMover:: set_directional_velocity(bool flag) { _directional_velocity = flag; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_directional_velocity -// Access: Published, Static -// Description: Returns the current state of the 'directional -// velocity' flag. See set_directional_velocity(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the 'directional velocity' flag. See + * set_directional_velocity(). + */ INLINE bool SmoothMover:: get_directional_velocity() { return _directional_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_default_to_standing_still -// Access: Published, Static -// Description: Sets the flag that indicates whether to assume that -// the node stopped moving during periods when we don't -// get enough position updates. If true, the object will -// stand still momentarily. If false, the object will -// continuously lerp between the position updates that -// we did get. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether to assume that the node stopped moving + * during periods when we don't get enough position updates. If true, the + * object will stand still momentarily. If false, the object will + * continuously lerp between the position updates that we did get. + */ INLINE void SmoothMover:: set_default_to_standing_still(bool flag) { _default_to_standing_still = flag; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_default_to_standing_still -// Access: Published, Static -// Description: Returns the current state of the 'default to standing -// still' flag. See set_default_to_standing_still(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the 'default to standing still' flag. See + * set_default_to_standing_still(). + */ INLINE bool SmoothMover:: get_default_to_standing_still() { return _default_to_standing_still; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_avg_timestamp_delay -// Access: Private -// Description: Returns the average delay observed in the last n -// timestamps received from this client, in seconds. -// This number represents the combination of the network -// lag from this client, as well as the client's clock -// skew relative to our clock. It could be negative if -// the client's clock is running faster than our clock. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average delay observed in the last n timestamps received from + * this client, in seconds. This number represents the combination of the + * network lag from this client, as well as the client's clock skew relative + * to our clock. It could be negative if the client's clock is running faster + * than our clock. + */ INLINE double SmoothMover:: get_avg_timestamp_delay() const { nassertr(!_timestamp_delays.empty(), 0.0); diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index 87e09e874f..727f10f9b3 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -1,26 +1,23 @@ -// Filename: smoothMover.cxx -// Created by: drose (19Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file smoothMover.cxx + * @author drose + * @date 2001-10-19 + */ #include "smoothMover.h" #include "pnotify.h" #include "config_deadrec.h" -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SmoothMover:: SmoothMover() { _sample._pos.set(0.0, 0.0, 0.0); @@ -45,8 +42,8 @@ SmoothMover() { _last_point_after = -1; _net_timestamp_delay = 0; - // Record one delay of 0 on the top of the delays array, just to - // guarantee that the array is never completely empty. + // Record one delay of 0 on the top of the delays array, just to guarantee + // that the array is never completely empty. _timestamp_delays.push_back(0); _last_heard_from = 0.0; @@ -62,27 +59,21 @@ SmoothMover() { _reset_velocity_age = 0.3; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SmoothMover:: ~SmoothMover() { } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::mark_position -// Access: Published -// Description: Stores the position, orientation, and timestamp (if -// relevant) indicated by previous calls to set_pos(), -// set_hpr(), and set_timestamp() in a new position -// report. -// -// When compute_smooth_position() is called, it uses -// these stored position reports to base its computation -// of the known position. -//////////////////////////////////////////////////////////////////// +/** + * Stores the position, orientation, and timestamp (if relevant) indicated by + * previous calls to set_pos(), set_hpr(), and set_timestamp() in a new + * position report. + * + * When compute_smooth_position() is called, it uses these stored position + * reports to base its computation of the known position. + */ void SmoothMover:: mark_position() { /* @@ -91,12 +82,12 @@ mark_position() { } */ if (_smooth_mode == SM_off) { - // With smoothing disabled, mark_position() simply stores its - // current position in the smooth_position members. + // With smoothing disabled, mark_position() simply stores its current + // position in the smooth_position members. - // In this mode, we also ignore the supplied timestamp, and just - // use the current frame time--there's no need to risk trusting - // the timestamp from another client. + // In this mode, we also ignore the supplied timestamp, and just use the + // current frame time--there's no need to risk trusting the timestamp from + // another client. double timestamp = ClockObject::get_global_clock()->get_frame_time(); // We also need to compute the velocity here. @@ -117,8 +108,7 @@ mark_position() { } } else { - // Otherwise, smoothing is in effect and we store a true position - // report. + // Otherwise, smoothing is in effect and we store a true position report. if (!_points.empty() && _points.back()._timestamp > _sample._timestamp) { if (deadrec_cat.is_debug()) { @@ -127,8 +117,8 @@ mark_position() { << _sample._timestamp << "\n"; } - // If we get a timestamp out of order, one of us must have just - // reset our clock. Flush the sequence and start again. + // If we get a timestamp out of order, one of us must have just reset + // our clock. Flush the sequence and start again. _points.clear(); // That invalidates the index numbers. @@ -142,8 +132,8 @@ mark_position() { deadrec_cat.debug() << "*** same timestamp\n"; } - // If the new timestamp is the same as the last timestamp, the - // value simply replaces the previous value. + // If the new timestamp is the same as the last timestamp, the value + // simply replaces the previous value. _points.back() = _sample; } else if ((int)_points.size() >= max_position_reports) { @@ -151,8 +141,7 @@ mark_position() { deadrec_cat.debug() << "*** dropped oldest position report\n"; } - // If we have too many position reports, throw away the oldest - // one. + // If we have too many position reports, throw away the oldest one. _points.pop_front(); --_last_point_before; @@ -165,18 +154,15 @@ mark_position() { _points.push_back(_sample); } } - //cout << "mark_position: " << _points.back()._pos << endl; + // cout << "mark_position: " << _points.back()._pos << endl; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::clear_positions -// Access: Published -// Description: Erases all the old position reports. This should be -// done, for instance, prior to teleporting the avatar -// to a new position; otherwise, the smoother might try -// to lerp the avatar there. If reset_velocity is true, -// the velocity is also reset to 0. -//////////////////////////////////////////////////////////////////// +/** + * Erases all the old position reports. This should be done, for instance, + * prior to teleporting the avatar to a new position; otherwise, the smoother + * might try to lerp the avatar there. If reset_velocity is true, the + * velocity is also reset to 0. + */ void SmoothMover:: clear_positions(bool reset_velocity) { if (deadrec_cat.is_debug()) { @@ -197,20 +183,16 @@ clear_positions(bool reset_velocity) { } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_smooth_position -// Access: Published -// Description: Computes the smoothed position (and orientation) of -// the mover at the indicated point in time, based on -// the previous position reports. After this call has -// been made, get_smooth_pos() etc. may be called to -// retrieve the smoothed position. -// -// The return value is true if the value has changed (or -// might have changed) since the last call to -// compute_smooth_position(), or false if it remains the -// same. -//////////////////////////////////////////////////////////////////// +/** + * Computes the smoothed position (and orientation) of the mover at the + * indicated point in time, based on the previous position reports. After + * this call has been made, get_smooth_pos() etc. may be called to retrieve + * the smoothed position. + * + * The return value is true if the value has changed (or might have changed) + * since the last call to compute_smooth_position(), or false if it remains + * the same. + */ bool SmoothMover:: compute_smooth_position(double timestamp) { if (deadrec_cat.is_spam()) { @@ -219,9 +201,9 @@ compute_smooth_position(double timestamp) { } if (_points.empty()) { - // With no position reports available, this function does nothing, - // except to make sure that our velocity gets reset to zero after - // a period of time. + // With no position reports available, this function does nothing, except + // to make sure that our velocity gets reset to zero after a period of + // time. if (_smooth_position_known) { double age = timestamp - _smooth_timestamp; @@ -245,9 +227,8 @@ compute_smooth_position(double timestamp) { return result; } if (_smooth_mode == SM_off) { - // With smoothing disabled, this function also does nothing, - // except to ensure that any old bogus position reports are - // cleared. + // With smoothing disabled, this function also does nothing, except to + // ensure that any old bogus position reports are cleared. clear_positions(false); bool result = _smooth_position_changed; _smooth_position_changed = false; @@ -269,7 +250,7 @@ compute_smooth_position(double timestamp) { if (deadrec_cat.is_spam()) { deadrec_cat.spam() << "time = " << timestamp << ", " << _points.size() - << " points, last = " << _last_point_before << ", " + << " points, last = " << _last_point_before << ", " << _last_point_after << "\n"; deadrec_cat.spam(false) << " "; @@ -289,8 +270,8 @@ compute_smooth_position(double timestamp) { int num_points = _points.size(); int i; - // Find the newest of the points before the indicated time. Assume - // that this will be no older than _last_point_before. + // Find the newest of the points before the indicated time. Assume that + // this will be no older than _last_point_before. i = max(0, _last_point_before); while (i < num_points && _points[i]._timestamp < timestamp) { point_before = i; @@ -299,8 +280,8 @@ compute_smooth_position(double timestamp) { } point_way_before = max(point_before - 1, -1); - // Now the next point is presumably the oldest point after the - // indicated time. + // Now the next point is presumably the oldest point after the indicated + // time. if (i < num_points) { point_after = i; timestamp_after = _points[i]._timestamp; @@ -315,7 +296,7 @@ compute_smooth_position(double timestamp) { if (point_before < 0) { nassertr(point_after >= 0, false); // If we only have an after point, we have to start there. - bool result = !(_last_point_before == point_before && + bool result = !(_last_point_before == point_before && _last_point_after == point_after); const SamplePoint &point = _points[point_after]; set_smooth_pos(point._pos, point._hpr, timestamp); @@ -326,7 +307,7 @@ compute_smooth_position(double timestamp) { _last_point_after = point_after; if (deadrec_cat.is_spam()) { deadrec_cat.spam() - << " only an after point: " << _last_point_before << ", " + << " only an after point: " << _last_point_before << ", " << _last_point_after << "\n"; } return result; @@ -335,23 +316,21 @@ compute_smooth_position(double timestamp) { bool result = true; if (point_after < 0 && _prediction_mode != PM_off) { - // With prediction in effect, we're allowed to anticipate where - // the avatar is going by a tiny bit, if we don't have current - // enough data. This works only if we have at least two points of - // old data. + // With prediction in effect, we're allowed to anticipate where the avatar + // is going by a tiny bit, if we don't have current enough data. This + // works only if we have at least two points of old data. if (point_way_before >= 0) { - // To implement simple prediction, we simply back up in time to - // the previous two timestamps, and base our linear - // interpolation off of those two, extending into the future. + // To implement simple prediction, we simply back up in time to the + // previous two timestamps, and base our linear interpolation off of + // those two, extending into the future. SamplePoint &point = _points[point_way_before]; point_after = point_before; timestamp_after = timestamp_before; point_before = point_way_before; timestamp_before = point._timestamp; - + if (timestamp > timestamp_after + _max_position_age) { - // Don't allow the prediction to get too far into the - // future. + // Don't allow the prediction to get too far into the future. timestamp = timestamp_after + _max_position_age; } } @@ -361,8 +340,8 @@ compute_smooth_position(double timestamp) { // If we only have a before point even after we've checked for the // possibility of using prediction, then we have to stop there. if (point_way_before >= 0) { - // Use the previous two points, if we've got 'em, so we can - // still reflect the avatar's velocity. + // Use the previous two points, if we've got 'em, so we can still + // reflect the avatar's velocity. if (deadrec_cat.is_spam()) { deadrec_cat.spam() << " previous two\n"; @@ -390,7 +369,7 @@ compute_smooth_position(double timestamp) { _smooth_rotational_velocity = 0.0; } - result = !(_last_point_before == point_before && + result = !(_last_point_before == point_before && _last_point_after == point_after); } else { // If we have two points, we can linearly interpolate between them. @@ -400,7 +379,7 @@ compute_smooth_position(double timestamp) { } SamplePoint &point_b = _points[point_before]; const SamplePoint &point_a = _points[point_after]; - + if (point_b._pos == point_a._pos && point_b._hpr == point_a._hpr) { // The points are equivalent, so just return that. if (deadrec_cat.is_spam()) { @@ -417,11 +396,11 @@ compute_smooth_position(double timestamp) { } else { // The points are different, so we have to do some work. double age = (point_a._timestamp - point_b._timestamp); - + if (_default_to_standing_still && (age > _max_position_age)) { - // If the first point is too old, assume there were a lot of - // implicit standing still messages that weren't sent. Insert a new - // sample point to reflect this. + // If the first point is too old, assume there were a lot of implicit + // standing still messages that weren't sent. Insert a new sample + // point to reflect this. if (deadrec_cat.is_spam()) { deadrec_cat.spam() << " first point too old: age = " << age << "\n"; @@ -435,7 +414,7 @@ compute_smooth_position(double timestamp) { } if (new_point._timestamp > point_b._timestamp) { _points.insert(_points.begin() + point_after, new_point); - + // Now we've monkeyed with the sequence. Start over. if (deadrec_cat.is_spam()) { deadrec_cat.spam() @@ -458,9 +437,9 @@ compute_smooth_position(double timestamp) { _last_point_after = point_after; - // Assume we'll never get another compute_smooth_position() request - // for an older time than this, and remove all the timestamps at the - // head of the queue up to but not including point_way_before. + // Assume we'll never get another compute_smooth_position() request for an + // older time than this, and remove all the timestamps at the head of the + // queue up to but not including point_way_before. while (point_way_before > 0) { nassertr(!_points.empty(), result); _points.pop_front(); @@ -470,30 +449,28 @@ compute_smooth_position(double timestamp) { --_last_point_after; if (deadrec_cat.is_spam()) { deadrec_cat.spam() - << " popping old point: " << _last_point_before << ", " + << " popping old point: " << _last_point_before << ", " << _last_point_after << "\n"; } } - // If we are not using prediction mode, we can also remove - // point_way_before. + // If we are not using prediction mode, we can also remove point_way_before. if (_prediction_mode == PM_off) { if (point_way_before == 0) { nassertr(!_points.empty(), result); _points.pop_front(); - + --point_way_before; --_last_point_before; --_last_point_after; if (deadrec_cat.is_spam()) { deadrec_cat.spam() - << " popping way_before point: " << _last_point_before << ", " + << " popping way_before point: " << _last_point_before << ", " << _last_point_after << "\n"; } } - // And if there's only one point left, remove even that one - // after a while. + // And if there's only one point left, remove even that one after a while. /* jbutler: commented this out, seems to cause the smoothing pop that occurs when this object is stopped for a while then starts moving again if (_points.size() == 1) { @@ -521,17 +498,13 @@ compute_smooth_position(double timestamp) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::get_latest_position -// Access: Published -// Description: Updates the smooth_pos (and smooth_hpr, etc.) members -// to reflect the absolute latest position known for -// this avatar. This may result in a pop to the most -// recent position. -// -// Returns true if the latest position is known, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Updates the smooth_pos (and smooth_hpr, etc.) members to reflect the + * absolute latest position known for this avatar. This may result in a pop + * to the most recent position. + * + * Returns true if the latest position is known, false otherwise. + */ bool SmoothMover:: get_latest_position() { if (deadrec_cat.is_debug()) { @@ -550,38 +523,32 @@ get_latest_position() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SmoothMover:: output(ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points."; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SmoothMover:: write(ostream &out) const { out << "SmoothMover, " << _points.size() << " sample points:\n"; int num_points = _points.size(); for (int i = 0; i < num_points; i++) { const SamplePoint &point = _points[i]; - out << " " << i << ". time = " << point._timestamp << " pos = " + out << " " << i << ". time = " << point._timestamp << " pos = " << point._pos << " hpr = " << point._hpr << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::set_smooth_pos -// Access: Private -// Description: Sets the computed smooth position and orientation for -// the indicated timestamp. -//////////////////////////////////////////////////////////////////// +/** + * Sets the computed smooth position and orientation for the indicated + * timestamp. + */ void SmoothMover:: set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, double timestamp) { @@ -605,12 +572,10 @@ set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, _smooth_position_known = true; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::linear_interpolate -// Access: Private -// Description: Interpolates the smooth position linearly between the -// two bracketing position reports. -//////////////////////////////////////////////////////////////////// +/** + * Interpolates the smooth position linearly between the two bracketing + * position reports. + */ void SmoothMover:: linear_interpolate(int point_before, int point_after, double timestamp) { SamplePoint &point_b = _points[point_before]; @@ -627,15 +592,15 @@ linear_interpolate(int point_before, int point_after, double timestamp) { cout << endl; */ - if (point_before == _last_point_before && + if (point_before == _last_point_before && point_after == _last_point_after) { if (deadrec_cat.is_spam()) { deadrec_cat.spam() << " same two points\n"; } - // If these are the same two points we found last time (which is - // likely), we can save a bit of work. + // If these are the same two points we found last time (which is likely), + // we can save a bit of work. double t = (timestamp - point_b._timestamp) / age; if (deadrec_cat.is_spam()) { @@ -650,8 +615,8 @@ linear_interpolate(int point_before, int point_after, double timestamp) { // The velocity remains the same as last time. } else { - // To interpolate the hpr's, we must first make sure that both - // angles are on the same side of the discontinuity. + // To interpolate the hpr's, we must first make sure that both angles are + // on the same side of the discontinuity. for (int j = 0; j < 3; j++) { if ((point_b._hpr[j] - point_a._hpr[j]) > 180.0) { point_b._hpr[j] -= 360.0; @@ -659,7 +624,7 @@ linear_interpolate(int point_before, int point_after, double timestamp) { point_b._hpr[j] += 360.0; } } - + double t = (timestamp - point_b._timestamp) / age; LVector3 pos_delta = point_a._pos - point_b._pos; LVecBase3 hpr_delta = point_a._hpr - point_b._hpr; @@ -669,51 +634,47 @@ linear_interpolate(int point_before, int point_after, double timestamp) { << " interp " << t << ": " << point_b._pos << " to " << point_a._pos << "\n"; } - set_smooth_pos(point_b._pos + t * pos_delta, - point_b._hpr + t * hpr_delta, + set_smooth_pos(point_b._pos + t * pos_delta, + point_b._hpr + t * hpr_delta, timestamp); compute_velocity(pos_delta, hpr_delta, age); } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::compute_velocity -// Access: Private -// Description: Computes the forward and rotational velocities of the -// moving object. -//////////////////////////////////////////////////////////////////// +/** + * Computes the forward and rotational velocities of the moving object. + */ void SmoothMover:: compute_velocity(const LVector3 &pos_delta, const LVecBase3 &hpr_delta, double age) { _smooth_rotational_velocity = hpr_delta[0] / age; if (_directional_velocity) { - // To get just the forward component of velocity, we need to project - // the velocity vector onto the y axis, as rotated by the current - // hpr. + // To get just the forward component of velocity, we need to project the + // velocity vector onto the y axis, as rotated by the current hpr. if (!_computed_forward_axis) { LMatrix3 rot_mat; compose_matrix(rot_mat, LVecBase3(1.0, 1.0, 1.0), _smooth_hpr); _forward_axis = LVector3(0.0, 1.0, 0.0) * rot_mat; - + if (deadrec_cat.is_spam()) { deadrec_cat.spam() << " compute forward_axis = " << _forward_axis << "\n"; } } - + LVector3 lateral_axis = _forward_axis.cross(LVector3(0.0,0.0,1.0)); - + PN_stdfloat forward_distance = pos_delta.dot(_forward_axis); PN_stdfloat lateral_distance = pos_delta.dot(lateral_axis); - + _smooth_forward_velocity = forward_distance / age; _smooth_lateral_velocity = lateral_distance / age; } else { _smooth_forward_velocity = pos_delta.length(); _smooth_lateral_velocity = 0.0f; - } + } if (deadrec_cat.is_spam()) { deadrec_cat.spam() @@ -721,21 +682,17 @@ compute_velocity(const LVector3 &pos_delta, const LVecBase3 &hpr_delta, } } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::record_timestamp_delay -// Access: Private -// Description: Records the delay measured in receiving this -// particular timestamp. The average delay of the last -// n timestamps will be used to smooth the motion -// properly. -//////////////////////////////////////////////////////////////////// +/** + * Records the delay measured in receiving this particular timestamp. The + * average delay of the last n timestamps will be used to smooth the motion + * properly. + */ void SmoothMover:: record_timestamp_delay(double timestamp) { double now = ClockObject::get_global_clock()->get_frame_time(); - // Convert the delay to an integer number of milliseconds. Integers - // are better than doubles because they don't accumulate errors over - // time. + // Convert the delay to an integer number of milliseconds. Integers are + // better than doubles because they don't accumulate errors over time. int delay = (int)((now - timestamp) * 1000.0); if (_timestamp_delays.full()) { _net_timestamp_delay -= _timestamp_delays.front(); @@ -747,26 +704,24 @@ record_timestamp_delay(double timestamp) { _last_heard_from = now; } -//////////////////////////////////////////////////////////////////// -// Function: SmoothMover::handle_wrt_reparent -// Access: Private -// Description: Node is being wrtReparented, update recorded -// sample positions to reflect new parent -//////////////////////////////////////////////////////////////////// +/** + * Node is being wrtReparented, update recorded sample positions to reflect + * new parent + */ void SmoothMover:: handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent) { Points::iterator pi; NodePath np = old_parent.attach_new_node("smoothMoverWrtReparent"); - //cout << "handle_wrt_reparent: "; + // cout << "handle_wrt_reparent: "; for (pi = _points.begin(); pi != _points.end(); pi++) { np.set_pos_hpr((*pi)._pos, (*pi)._hpr); (*pi)._pos = np.get_pos(new_parent); (*pi)._hpr = np.get_hpr(new_parent); - //cout << "(" << (*pi)._pos << "), "; + // cout << "(" << (*pi)._pos << "), "; } - //cout << endl; - + // cout << endl; + np.set_pos_hpr(_sample._pos, _sample._hpr); _sample._pos = np.get_pos(new_parent); _sample._hpr = np.get_hpr(new_parent); diff --git a/direct/src/deadrec/smoothMover.h b/direct/src/deadrec/smoothMover.h index 663f6623bd..e9ca5dc76e 100644 --- a/direct/src/deadrec/smoothMover.h +++ b/direct/src/deadrec/smoothMover.h @@ -1,16 +1,15 @@ -// Filename: smoothMover.h -// Created by: drose (19Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file smoothMover.h + * @author drose + * @date 2001-10-19 + */ #ifndef SMOOTHMOVER_H #define SMOOTHMOVER_H @@ -26,34 +25,28 @@ static const int max_position_reports = 10; static const int max_timestamp_delays = 10; -//////////////////////////////////////////////////////////////////// -// Class : SmoothMover -// Description : This class handles smoothing of sampled motion points -// over time, e.g. for smoothing the apparent movement -// of remote avatars, whose positions are sent via -// occasional telemetry updates. -// -// It can operate in any of three modes: off, in which -// it does not smooth any motion but provides the last -// position it was told; smoothing only, in which it -// smooths motion information but never tries to -// anticipate where the avatar might be going; or full -// prediction, in which it smooths motion as well as -// tries to predict the avatar's position in lead of the -// last position update. The assumption is that all -// SmoothMovers in the world will be operating in the -// same mode together. -//////////////////////////////////////////////////////////////////// +/** + * This class handles smoothing of sampled motion points over time, e.g. for + * smoothing the apparent movement of remote avatars, whose positions are sent + * via occasional telemetry updates. + * + * It can operate in any of three modes: off, in which it does not smooth any + * motion but provides the last position it was told; smoothing only, in which + * it smooths motion information but never tries to anticipate where the + * avatar might be going; or full prediction, in which it smooths motion as + * well as tries to predict the avatar's position in lead of the last position + * update. The assumption is that all SmoothMovers in the world will be + * operating in the same mode together. + */ class EXPCL_DIRECT SmoothMover { PUBLISHED: SmoothMover(); ~SmoothMover(); // These methods are used to specify each position update. Call the - // appropriate set_* function(s), as needed, and then call - // mark_position(). The return value of each function is true if - // the parameter value has changed, or false if it remains the same - // as last time. + // appropriate set_* function(s), as needed, and then call mark_position(). + // The return value of each function is true if the parameter value has + // changed, or false if it remains the same as last time. INLINE bool set_pos(const LVecBase3 &pos); INLINE bool set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); INLINE bool set_x(PN_stdfloat x); @@ -75,7 +68,7 @@ PUBLISHED: INLINE void set_phony_timestamp(double timestamp = 0.0, bool period_adjust = false); INLINE void set_timestamp(double timestamp); - + INLINE bool has_most_recent_timestamp() const; INLINE double get_most_recent_timestamp() const; @@ -113,9 +106,8 @@ PUBLISHED: enum PredictionMode { PM_off, PM_on, - // Similarly for other kinds of prediction modes. I don't know - // why, though; linear interpolation seems to work pretty darn - // well. + // Similarly for other kinds of prediction modes. I don't know why, + // though; linear interpolation seems to work pretty darn well. }; INLINE void set_smooth_mode(SmoothMode mode); @@ -124,26 +116,26 @@ PUBLISHED: INLINE void set_prediction_mode(PredictionMode mode); INLINE PredictionMode get_prediction_mode(); - INLINE void set_delay(double delay); - INLINE double get_delay(); + INLINE void set_delay(double delay); + INLINE double get_delay(); - INLINE void set_accept_clock_skew(bool flag); - INLINE bool get_accept_clock_skew(); + INLINE void set_accept_clock_skew(bool flag); + INLINE bool get_accept_clock_skew(); - INLINE void set_max_position_age(double age); - INLINE double get_max_position_age(); + INLINE void set_max_position_age(double age); + INLINE double get_max_position_age(); - INLINE void set_expected_broadcast_period(double period); - INLINE double get_expected_broadcast_period(); + INLINE void set_expected_broadcast_period(double period); + INLINE double get_expected_broadcast_period(); - INLINE void set_reset_velocity_age(double age); - INLINE double get_reset_velocity_age(); + INLINE void set_reset_velocity_age(double age); + INLINE double get_reset_velocity_age(); - INLINE void set_directional_velocity(bool flag); - INLINE bool get_directional_velocity(); + INLINE void set_directional_velocity(bool flag); + INLINE bool get_directional_velocity(); - INLINE void set_default_to_standing_still(bool flag); - INLINE bool get_default_to_standing_still(); + INLINE void set_default_to_standing_still(bool flag); + INLINE bool get_default_to_standing_still(); void output(ostream &out) const; void write(ostream &out) const; @@ -152,7 +144,7 @@ private: void set_smooth_pos(const LPoint3 &pos, const LVecBase3 &hpr, double timestamp); void linear_interpolate(int point_before, int point_after, double timestamp); - void compute_velocity(const LVector3 &pos_delta, + void compute_velocity(const LVector3 &pos_delta, const LVecBase3 &hpr_delta, double age); @@ -160,8 +152,7 @@ private: INLINE double get_avg_timestamp_delay() const; public: - // This internal class is declared public to work around compiler - // issues. + // This internal class is declared public to work around compiler issues. class SamplePoint { public: LPoint3 _pos; @@ -187,17 +178,16 @@ private: bool _has_most_recent_timestamp; double _most_recent_timestamp; - // typedef CircBuffer Points; + // typedef CircBuffer Points; typedef pdeque Points; Points _points; int _last_point_before; int _last_point_after; - // This array is used to record the average delay in receiving - // timestamps from a particular client, in milliseconds. This value - // will measure both the latency and clock skew from that client, - // allowing us to present smooth motion in spite of extreme latency - // or poor clock synchronization. + // This array is used to record the average delay in receiving timestamps + // from a particular client, in milliseconds. This value will measure both + // the latency and clock skew from that client, allowing us to present + // smooth motion in spite of extreme latency or poor clock synchronization. typedef CircBuffer TimestampDelays; TimestampDelays _timestamp_delays; int _net_timestamp_delay; diff --git a/direct/src/directbase/directbase.cxx b/direct/src/directbase/directbase.cxx index 1230878a13..b6ee6009f5 100644 --- a/direct/src/directbase/directbase.cxx +++ b/direct/src/directbase/directbase.cxx @@ -1,15 +1,14 @@ -// Filename: directbase.cxx -// Created by: drose (15Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directbase.cxx + * @author drose + * @date 2000-09-15 + */ #include "directbase.h" diff --git a/direct/src/directbase/directbase.h b/direct/src/directbase/directbase.h index ed540df4ab..07ae2cc03f 100644 --- a/direct/src/directbase/directbase.h +++ b/direct/src/directbase/directbase.h @@ -1,8 +1,4 @@ -/* Filename: directbase.h - * Created by: drose (12Sep00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file directbase.h + * @author drose + * @date 2000-09-12 + */ /* This file is included at the beginning of every header file and/or C or C++ file. It must be compilable for C as well as C++ files, @@ -23,4 +22,3 @@ #include "directsymbols.h" #endif - diff --git a/direct/src/directbase/directsymbols.h b/direct/src/directbase/directsymbols.h index 26a34e7156..4eb2202c1f 100644 --- a/direct/src/directbase/directsymbols.h +++ b/direct/src/directbase/directsymbols.h @@ -1,8 +1,4 @@ -/* Filename: directsymbols.h - * Created by: drose (18Feb00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file directsymbols.h + * @author drose + * @date 2000-02-18 + */ #ifndef DIRECTSYMBOLS_H #define DIRECTSYMBOLS_H diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx index 176116715d..e460de766c 100644 --- a/direct/src/directbase/ppython.cxx +++ b/direct/src/directbase/ppython.cxx @@ -1,11 +1,7 @@ -//////////////////////////////////////////////////////////////////// -// -// This is a little wrapper to make it easy to run a python -// program from the command line. Basically, it just interfaces -// to the Python API and imports the module that was specified -// by the IMPORT_MODULE preprocessor definition when it was compiled. -// -//////////////////////////////////////////////////////////////////// +// This is a little wrapper to make it easy to run a python program from the +// command line. Basically, it just interfaces to the Python API and imports +// the module that was specified by the IMPORT_MODULE preprocessor definition +// when it was compiled. #include "dtoolbase.h" @@ -25,8 +21,8 @@ #define IMPORT_MODULE_STR STRINGIFY(IMPORT_MODULE) #if defined(_WIN32) && PY_MAJOR_VERSION >= 3 -// As Py_SetProgramName expects a wchar_t*, -// it's easiest to just use the wmain entry point. +// As Py_SetProgramName expects a wchar_t*, it's easiest to just use the wmain +// entry point. int wmain(int argc, wchar_t *argv[]) { Py_SetProgramName(argv[0]); @@ -51,8 +47,8 @@ int main(int argc, char *argv[]) { Py_SetProgramName(argv[0]); #endif - // On Windows, we need to set pythonhome correctly. We'll try to - // find ppython.exe on the path and set pythonhome to its location. + // On Windows, we need to set pythonhome correctly. We'll try to find + // ppython.exe on the path and set pythonhome to its location. #ifdef _WIN32 #if PY_MAJOR_VERSION >= 3 // Py_SetPythonHome expects a wchar_t in Python 3. diff --git a/direct/src/directd/directd.cxx b/direct/src/directd/directd.cxx index 3ac99ceedf..111a4fd847 100644 --- a/direct/src/directd/directd.cxx +++ b/direct/src/directd/directd.cxx @@ -1,17 +1,16 @@ -// Filename: directd.cxx -// Created by: skyler 2002.04.08 -// Based on test_tcp_*.* by drose. -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directd.cxx + * @author skyler + * @date 2002-04-08 + * Based on test_tcp_*.* by drose. + */ // This define tells the windows headers to include job objects: #define _WIN32_WINNT 0x0500 @@ -20,14 +19,10 @@ /*#include "pandaFramework.h" #include "queuedConnectionManager.h"*/ -//#include -//#include -//#include "pandabase.h" +// #include #include #include "pandabase.h" -//#include "queuedConnectionManager.h" -//#include "queuedConnectionListener.h" -//#include "queuedConnectionReader.h" -//#include "connectionWriter.h" +// #include "queuedConnectionManager.h" #include "queuedConnectionListener.h" +// #include "queuedConnectionReader.h" #include "connectionWriter.h" #include "netAddress.h" #include "connection.h" #include "datagramIterator.h" @@ -36,11 +31,12 @@ #include "pset.h" namespace { - // ...This section is part of the old stuff from the original implementation. - // The new stuff that uses job objects doesn't need this stuff: + // ...This section is part of the old stuff from the original + // implementation. The new stuff that uses job objects doesn't need this + // stuff: // The following is from an MSDN example: - + #define TA_FAILED 0 #define TA_SUCCESS_CLEAN 1 #define TA_SUCCESS_KILL 2 @@ -74,25 +70,25 @@ namespace { TA_SUCCESS_CLEAN - If the process was shutdown using WM_CLOSE. TA_SUCCESS_KILL - if the process was shut down with TerminateProcess(). - */ + */ DWORD WINAPI TerminateApp(DWORD dwPID, DWORD dwTimeout) { HANDLE hProc; DWORD dwRet; - // If we can't open the process with PROCESS_TERMINATE rights, - // then we give up immediately. + // If we can't open the process with PROCESS_TERMINATE rights, then we + // give up immediately. hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, dwPID); if(hProc == NULL) { return TA_FAILED; } - // TerminateAppEnum() posts WM_CLOSE to all windows whose PID - // matches your process's. + // TerminateAppEnum() posts WM_CLOSE to all windows whose PID matches your + // process's. EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM)dwPID); - // Wait on the handle. If it signals, great. If it times out, - // then you kill it. + // Wait on the handle. If it signals, great. If it times out, then you + // kill it. if(WaitForSingleObject(hProc, dwTimeout)!=WAIT_OBJECT_0) { dwRet=(TerminateProcess(hProc,0)?TA_SUCCESS_KILL:TA_FAILED); } else { @@ -110,13 +106,13 @@ namespace { DWORD StartApp(const string& cmd) { DWORD pid=0; - STARTUPINFO si; - PROCESS_INFORMATION pi; + STARTUPINFO si; + PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); + si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), - 0, 0, 1, NORMAL_PRIORITY_CLASS, + if (CreateProcess(NULL, (char*)cmd.c_str(), + 0, 0, 1, NORMAL_PRIORITY_CLASS, 0, 0, &si, &pi)) { pid=pi.dwProcessId; CloseHandle(pi.hProcess); @@ -141,11 +137,11 @@ DirectD::~DirectD() { _cm.close_connection((*ci)); } _connections.clear(); - + kill_all(); } -int +int DirectD::client_ready(const string& server_host, int port, const string& cmd) { stringstream ss; @@ -154,7 +150,7 @@ DirectD::client_ready(const string& server_host, int port, return 0; } -int +int DirectD::tell_server(const string& server_host, int port, const string& cmd) { send_one_message(server_host, port, cmd); @@ -176,15 +172,14 @@ DirectD::wait_for_servers(int count, int timeout_ms) { The following can be more generalized with a little work. check_for_datagrams() could take a handler function as an arugment, maybe. */ - ////check_for_datagrams(); - // Process all available datagrams. + // check_for_datagrams(); Process all available datagrams. while (_reader.data_available()) { NetDatagram datagram; if (_reader.get_data(datagram)) { cout << count << ": Server at " << datagram.get_address() << " is ready." << endl; datagram.dump_hex(nout); - //handle_datagram(datagram); + // handle_datagram(datagram); DatagramIterator di(datagram); string s=di.get_string(); if (s=="r" && !--count) { @@ -194,15 +189,15 @@ DirectD::wait_for_servers(int count, int timeout_ms) { } // Yield the timeslice before we poll again. - //PR_Sleep(PR_MillisecondsToInterval(wait_ms)); + // PR_Sleep(PR_MillisecondsToInterval(wait_ms)); Sleep(wait_ms); } - // We've waited long enough, assume they're not going to be - // ready in the time we want them: + // We've waited long enough, assume they're not going to be ready in the + // time we want them: return false; } -int +int DirectD::server_ready(const string& client_host, int port) { send_one_message(client_host, port, "r"); return 0; @@ -224,24 +219,24 @@ DirectD::start_app(const string& cmd) { } } DWORD pid=0; - STARTUPINFO si; - PROCESS_INFORMATION pi; + STARTUPINFO si; + PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(STARTUPINFO)); - si.cb = sizeof(STARTUPINFO); + si.cb = sizeof(STARTUPINFO); ZeroMemory(&pi, sizeof(PROCESS_INFORMATION)); - if (CreateProcess(NULL, (char*)cmd.c_str(), - 0, 0, 1, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, + if (CreateProcess(NULL, (char*)cmd.c_str(), + 0, 0, 1, NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED, 0, 0, &si, &pi)) { - // The process must be created with CREATE_SUSPENDED to - // give us a chance to get the handle into our sgJobObject - // before the child processes starts sub-processes. + // The process must be created with CREATE_SUSPENDED to give us a chance + // to get the handle into our sgJobObject before the child processes + // starts sub-processes. if (!AssignProcessToJobObject(_jobObject, pi.hProcess)) { // ...The assign failed. cerr<<"StartJob AssignProcessToJobObject Error: "<get_address().get_port() << " and IP " << c->get_address() << "\n"; - //_reader.add_connection(c); - + // _reader.add_connection(c); + NetDatagram datagram; datagram.add_string(message); _writer.send(datagram, c); - - //PR_Sleep(PR_MillisecondsToInterval(200)); - //wait_for_servers(1, 10*1000); - //_reader.remove_connection(c); + + // PR_Sleep(PR_MillisecondsToInterval(200)); wait_for_servers(1, 10*1000); + // _reader.remove_connection(c); _cm.close_connection(c); } diff --git a/direct/src/directd/directd.h b/direct/src/directd/directd.h index 4add16a399..3aff05e9df 100644 --- a/direct/src/directd/directd.h +++ b/direct/src/directd/directd.h @@ -1,16 +1,15 @@ -// Filename: directd.h -// Created by: skyler 2002.04.08 -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directd.h + * @author skyler + * @date 2002-04-08 + */ #include #include "pandabase.h" @@ -29,106 +28,100 @@ typedef int HANDLE; #endif //] -//////////////////////////////////////////////////////////////////// -// Class : DirectD -// Description : DirectD is a client/server app for starting panda/direct. -// -// Usage: -// Start a directd server on each of the machines you -// which to start panda on. -// -// Start a directd client on the controlling machine or -// import ShowBaseGlobal with the xxxxx flag in your -// Configrc. The client will connect each of the servers -// in the xxxxx list in your Configrc. -// -// There are two API groups in this class, they are: -// -// listen_to() -// client_ready() or tell_server() -// wait_for_servers() -// server_ready() -// -// and: -// -// connect_to() -// send_command() -// disconnect_from() -// -// The second group was from a more general implementation -// of DirectD. The first group summarizes the main intents -// of DirectD. -// Both groups are presented in order chronologically by their -// intended usage. -// The first group will probably provide everthing needed for -// DirectD. -//////////////////////////////////////////////////////////////////// +/** + * DirectD is a client/server app for starting panda/direct. + * + * Usage: Start a directd server on each of the machines you which to start + * panda on. + * + * Start a directd client on the controlling machine or import ShowBaseGlobal + * with the xxxxx flag in your Configrc. The client will connect each of the + * servers in the xxxxx list in your Configrc. + * + * There are two API groups in this class, they are: + * + * listen_to() client_ready() or tell_server() wait_for_servers() + * server_ready() + * + * and: + * + * connect_to() send_command() disconnect_from() + * + * The second group was from a more general implementation of DirectD. The + * first group summarizes the main intents of DirectD. Both groups are + * presented in order chronologically by their intended usage. The first + * group will probably provide everthing needed for DirectD. + */ class EXPCL_DIRECT DirectD { PUBLISHED: DirectD(); ~DirectD(); - // Description: Call listen_to in the server. - // port is a rendezvous port. - // - // backlog refers to how many connections can queue up - // before you handle them. Consider setting backlog to - // the count you send to wait_for_servers(); or higher. +/** + * Call listen_to in the server. port is a rendezvous port. + * + * backlog refers to how many connections can queue up before you handle them. + * Consider setting backlog to the count you send to wait_for_servers(); or + * higher. + */ void listen_to(int port, int backlog=8); - // Description: Call this function from the client when - // import ShowbaseGlobal is nearly finished. - // cmd: a cli command that will be executed on the remote - // machine. - // A new connection will be created and closed. If you - // want to send more than one command, you should use - // connect_to(), send_command(), and disconnect_from(). +/** + * Call this function from the client when import ShowbaseGlobal is nearly + * finished. cmd: a cli command that will be executed on the remote machine. + * A new connection will be created and closed. If you want to send more than + * one command, you should use connect_to(), send_command(), and + * disconnect_from(). + */ int client_ready(const string& server_host, int port, const string& cmd); - // Description: Tell the server to do the command cmd. - // cmd is one of the following: - // "k[]" Kill the most recent application - // started with client_ready() or "!". - // Or kill the nth most recent or 'a' for All. - // E.g. "k", "k0", "k2", "ka". - // "q" Tell the server to quit. - // "!cmd" Exectue the cmd on the server (this - // is a dos shell command; if you want - // a bash command, include bash in the - // command e.g. "!bash pwd"). When you call - // client_ready(), it prefixes "!" for you. - // A new connection will be created and closed. +/** + * Tell the server to do the command cmd. cmd is one of the following: + * "k[]" Kill the most recent application started with client_ready() or + * "!". Or kill the nth most recent or 'a' for All. E.g. "k", "k0", "k2", + * "ka". "q" Tell the server to quit. "!cmd" Exectue the cmd on + * the server (this is a dos shell command; if you want a bash command, + * include bash in the command e.g. "!bash pwd"). When you call + * client_ready(), it prefixes "!" for you. A new connection will be created + * and closed. + */ int tell_server(const string& server_host, int port, const string& cmd); - // Description: Call this function from the client after - // calling client_ready() calls. - // - // Call listen_to(port) prior to calling - // wait_for_servers() (or better yet, prior - // to calling client_ready()). - // - // timeout_ms defaults to two minutes. +/** + * Call this function from the client after calling client_ready() + * calls. + * + * Call listen_to(port) prior to calling wait_for_servers() (or better yet, + * prior to calling client_ready()). + * + * timeout_ms defaults to two minutes. + */ bool wait_for_servers(int count, int timeout_ms=2*60*1000); - // Description: Call this function from the server when - // import ShowbaseGlobal is nearly finished. +/** + * Call this function from the server when import ShowbaseGlobal is nearly + * finished. + */ int server_ready(const string& client_host, int port); - // Description: Call connect_to from client for each server. - // returns the port number of the connection (which - // is different from the rendezvous port used in the - // second argument). The return value can be used - // for the port arguemnt in disconnect_from(). +/** + * Call connect_to from client for each server. returns the port number of + * the connection (which is different from the rendezvous port used in the + * second argument). The return value can be used for the port arguemnt in + * disconnect_from(). + */ int connect_to(const string& server_host, int port); - // Description: This is the counterpart to connect_to(). Pass - // the same server_host as for connect_to(), but pass - // the return value from connect_to() for the port, - // not the port passed to connect_to(). +/** + * This is the counterpart to connect_to(). Pass the same server_host as for + * connect_to(), but pass the return value from connect_to() for the port, not + * the port passed to connect_to(). + */ void disconnect_from(const string& server_host, int port); - // Description: Send the same command string to all current - // connections. +/** + * Send the same command string to all current connections. + */ void send_command(const string& cmd); protected: @@ -145,11 +138,9 @@ protected: ConnectionWriter _writer; QueuedConnectionListener _listener; - // Start of old stuff: - // This is used to switch to the original method of - // starting applications. It can be used on old systems - // that don't support job objects. Eventually this stuff - // should be removed. + // Start of old stuff: This is used to switch to the original method of + // starting applications. It can be used on old systems that don't support + // job objects. Eventually this stuff should be removed. bool _useOldStuff; typedef pvector< long /*intptr_t*/ > PidStack; PidStack _pids; diff --git a/direct/src/directdServer/directdClient.cxx b/direct/src/directdServer/directdClient.cxx index f0325e2da5..550c3f2862 100644 --- a/direct/src/directdServer/directdClient.cxx +++ b/direct/src/directdServer/directdClient.cxx @@ -1,16 +1,15 @@ -// Filename: directdClient.cxx -// Created by: skyler 2002.04.08 -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directdClient.cxx + * @author skyler + * @date 2002-04-08 + */ #include "directdClient.h" @@ -46,7 +45,7 @@ DirectDClient::cli_command(const string& cmd) { void DirectDClient::run_client(const string& host, int port) { nout<<"client"< 0; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_want_message_bundling -// Access: Published -// Description: Enable/disable outbound message bundling -//////////////////////////////////////////////////////////////////// +/** + * Enable/disable outbound message bundling + */ INLINE void CConnectionRepository:: set_want_message_bundling(bool flag) { ReMutexHolder holder(_lock); - // don't allow enable/disable while bundling + // don't allow enabledisable while bundling nassertv(_bundling_msgs == 0); _want_message_bundling = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_want_message_bundling -// Access: Published -// Description: Returns true if message bundling enabled -//////////////////////////////////////////////////////////////////// +/** + * Returns true if message bundling enabled + */ INLINE bool CConnectionRepository:: get_want_message_bundling() const { ReMutexHolder holder(_lock); return _want_message_bundling; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_in_quiet_zone -// Access: Published -// Description: Enables/disables quiet zone mode -//////////////////////////////////////////////////////////////////// +/** + * Enables/disables quiet zone mode + */ INLINE void CConnectionRepository:: set_in_quiet_zone(bool flag) { ReMutexHolder holder(_lock); _in_quiet_zone = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_in_quiet_zone -// Access: Published -// Description: Returns true if repository is in quiet zone mode -//////////////////////////////////////////////////////////////////// +/** + * Returns true if repository is in quiet zone mode + */ INLINE bool CConnectionRepository:: get_in_quiet_zone() const { ReMutexHolder holder(_lock); return _in_quiet_zone; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_simulated_disconnect -// Access: Published -// Description: Sets the simulated disconnect flag. While this is -// true, no datagrams will be retrieved from or sent to -// the server. The idea is to simulate a temporary -// network outage. -//////////////////////////////////////////////////////////////////// +/** + * Sets the simulated disconnect flag. While this is true, no datagrams will + * be retrieved from or sent to the server. The idea is to simulate a + * temporary network outage. + */ INLINE void CConnectionRepository:: set_simulated_disconnect(bool simulated_disconnect) { _simulated_disconnect = simulated_disconnect; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_simulated_disconnect -// Access: Published -// Description: Returns the simulated disconnect flag. While this is -// true, no datagrams will be retrieved from or sent to -// the server. The idea is to simulate a temporary -// network outage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the simulated disconnect flag. While this is true, no datagrams + * will be retrieved from or sent to the server. The idea is to simulate a + * temporary network outage. + */ INLINE bool CConnectionRepository:: get_simulated_disconnect() const { return _simulated_disconnect; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::toggle_verbose -// Access: Published -// Description: Toggles the current setting of the verbose flag. -// When true, this describes every message going back -// and forth on the wire. -//////////////////////////////////////////////////////////////////// +/** + * Toggles the current setting of the verbose flag. When true, this describes + * every message going back and forth on the wire. + */ INLINE void CConnectionRepository:: toggle_verbose() { _verbose = !_verbose; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_verbose -// Access: Published -// Description: Directly sets the verbose flag. When true, this -// describes every message going back and forth on the -// wire. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the verbose flag. When true, this describes every message + * going back and forth on the wire. + */ INLINE void CConnectionRepository:: set_verbose(bool verbose) { _verbose = verbose; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_verbose -// Access: Published -// Description: Returns the current setting of the verbose flag. -// When true, this describes every message going back -// and forth on the wire. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the verbose flag. When true, this describes + * every message going back and forth on the wire. + */ INLINE bool CConnectionRepository:: get_verbose() const { return _verbose; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_time_warning -// Access: Published -// Description: Directly sets the time_warning field. When non zero, this -// describes every message going back and forth on the -// wire when the msg handling time is over it -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the time_warning field. When non zero, this describes every + * message going back and forth on the wire when the msg handling time is over + * it + */ INLINE void CConnectionRepository:: set_time_warning(float time_warning) { _time_warning = time_warning; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_time_warning -// Access: Published -// Description: Returns the current setting of the time_warning field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the time_warning field. + */ INLINE float CConnectionRepository:: get_time_warning() const { return _time_warning; diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index e39a59f13e..4d615b2179 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -1,16 +1,15 @@ -// Filename: cConnectionRepository.cxx -// Created by: drose (17May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConnectionRepository.cxx + * @author drose + * @date 2004-05-17 + */ #include "cConnectionRepository.h" #include "dcmsgtypes.h" @@ -35,11 +34,9 @@ const string CConnectionRepository::_overflow_event_name = "CRDatagramOverflow"; PStatCollector CConnectionRepository::_update_pcollector("App:Show code:readerPollTask:Update"); #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CConnectionRepository:: CConnectionRepository(bool has_owner_view, bool threaded_net) : _lock("CConnectionRepository::_lock"), @@ -62,7 +59,7 @@ CConnectionRepository(bool has_owner_view, bool threaded_net) : _simulated_disconnect(false), _verbose(distributed_cat.is_spam()), _time_warning(0.0), -// _msg_channels(), +// _msg_channels(), _msg_sender(0), _msg_type(0), _has_owner_view(has_owner_view), @@ -79,25 +76,20 @@ CConnectionRepository(bool has_owner_view, bool threaded_net) : _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CConnectionRepository:: ~CConnectionRepository() { disconnect(); } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_tcp_header_size -// Access: Public -// Description: Sets the header size of TCP packets. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size of TCP packets. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ void CConnectionRepository:: set_tcp_header_size(int tcp_header_size) { _tcp_header_size = tcp_header_size; @@ -115,14 +107,11 @@ set_tcp_header_size(int tcp_header_size) { } #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::set_connection_http -// Access: Published -// Description: Once a connection has been established via the HTTP -// interface, gets the connection and uses it. The -// supplied HTTPChannel object must have a connection -// available via get_connection(). -//////////////////////////////////////////////////////////////////// +/** + * Once a connection has been established via the HTTP interface, gets the + * connection and uses it. The supplied HTTPChannel object must have a + * connection available via get_connection(). + */ void CConnectionRepository:: set_connection_http(HTTPChannel *channel) { ReMutexHolder holder(_lock); @@ -140,13 +129,10 @@ set_connection_http(HTTPChannel *channel) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::get_stream -// Access: Published -// Description: Returns the SocketStream that internally represents -// the already-established HTTP connection. Returns -// NULL if there is no current HTTP connection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SocketStream that internally represents the already-established + * HTTP connection. Returns NULL if there is no current HTTP connection. + */ SocketStream *CConnectionRepository:: get_stream() { ReMutexHolder holder(_lock); @@ -157,13 +143,10 @@ get_stream() { #ifdef HAVE_NET -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::try_connect_net -// Access: Published -// Description: Uses Panda's "net" library to try to connect to the -// server and port named in the indicated URL. Returns -// true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Uses Panda's "net" library to try to connect to the server and port named + * in the indicated URL. Returns true if successful, false otherwise. + */ bool CConnectionRepository:: try_connect_net(const URLSpec &url) { ReMutexHolder holder(_lock); @@ -185,12 +168,10 @@ try_connect_net(const URLSpec &url) { #endif // HAVE_NET #ifdef WANT_NATIVE_NET -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::connect_native -// Access: Published -// Description: Connects to the server using Panda's low-level and -// fast "native net" library. -//////////////////////////////////////////////////////////////////// +/** + * Connects to the server using Panda's low-level and fast "native net" + * library. + */ bool CConnectionRepository:: connect_native(const URLSpec &url) { ReMutexHolder holder(_lock); @@ -206,23 +187,19 @@ connect_native(const URLSpec &url) { #endif //WANT NATIVE NET #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::start_delay -// Access: Published -// Description: Enables a simulated network latency. All datagrams -// received from this point on will be held for a random -// interval of least min_delay seconds, and no more than -// max_delay seconds, before being visible. It is as if -// datagrams suddenly took much longer to arrive. -// -// This should *only* be called if the underlying socket -// is non-blocking. If you call this on a blocking -// socket, it will force all datagrams to be held up -// until the socket closes. -// -// This has no effect if the connection method is via -// the "native net" library. -//////////////////////////////////////////////////////////////////// +/** + * Enables a simulated network latency. All datagrams received from this + * point on will be held for a random interval of least min_delay seconds, and + * no more than max_delay seconds, before being visible. It is as if + * datagrams suddenly took much longer to arrive. + * + * This should *only* be called if the underlying socket is non-blocking. If + * you call this on a blocking socket, it will force all datagrams to be held + * up until the socket closes. + * + * This has no effect if the connection method is via the "native net" + * library. + */ void CConnectionRepository:: start_delay(double min_delay, double max_delay) { ReMutexHolder holder(_lock); @@ -243,13 +220,11 @@ start_delay(double min_delay, double max_delay) { #endif // SIMULATE_NETWORK_DELAY #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::stop_delay -// Access: Published -// Description: Disables the simulated network latency started by a -// previous call to start_delay(). Datagrams will once -// again be visible as soon as they are received. -//////////////////////////////////////////////////////////////////// +/** + * Disables the simulated network latency started by a previous call to + * start_delay(). Datagrams will once again be visible as soon as they are + * received. + */ void CConnectionRepository:: stop_delay() { ReMutexHolder holder(_lock); @@ -265,15 +240,11 @@ stop_delay() { } #endif // SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::check_datagram -// Access: Published -// Description: Returns true if a new datagram is available, false -// otherwise. If the return value is true, the new -// datagram may be retrieved via get_datagram(), or -// preferably, with get_datagram_iterator() and -// get_msg_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a new datagram is available, false otherwise. If the + * return value is true, the new datagram may be retrieved via get_datagram(), + * or preferably, with get_datagram_iterator() and get_msg_type(). + */ bool CConnectionRepository:: check_datagram() { ReMutexHolder holder(_lock); @@ -305,9 +276,8 @@ check_datagram() { _msg_sender = _di.get_uint64(); #ifdef HAVE_PYTHON - // For now, we need to stuff this field onto the Python - // structure, to support legacy code that expects to find it - // there. + // For now, we need to stuff this field onto the Python structure, to + // support legacy code that expects to find it there. if (_python_repository != (PyObject *)NULL) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_STATE gstate; @@ -360,16 +330,12 @@ check_datagram() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::is_connected -// Access: Published -// Description: Returns true if the connection to the gameserver is -// established and still good, false if we are not -// connected. A false value means either (a) we never -// successfully connected, (b) we explicitly called -// disconnect(), or (c) we were connected, but the -// connection was spontaneously lost. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the connection to the gameserver is established and still + * good, false if we are not connected. A false value means either (a) we + * never successfully connected, (b) we explicitly called disconnect(), or (c) + * we were connected, but the connection was spontaneously lost. + */ bool CConnectionRepository:: is_connected() { ReMutexHolder holder(_lock); @@ -411,14 +377,11 @@ is_connected() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::send_datagram -// Access: Published -// Description: Queues the indicated datagram for sending to the -// server. It may not get sent immediately if -// collect_tcp is in effect; call flush() to guarantee -// it is sent now. -//////////////////////////////////////////////////////////////////// +/** + * Queues the indicated datagram for sending to the server. It may not get + * sent immediately if collect_tcp is in effect; call flush() to guarantee it + * is sent now. + */ bool CConnectionRepository:: send_datagram(const Datagram &dg) { ReMutexHolder holder(_lock); @@ -467,24 +430,20 @@ send_datagram(const Datagram &dg) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::start_message_bundle -// Access: Published -// Description: Send a set of messages to the state server that will -// be processed atomically. For instance, you can do a -// combined setLocation/setPos and prevent race -// conditions where clients briefly get the setLocation -// but not the setPos, because the state server hasn't -// processed the setPos yet -//////////////////////////////////////////////////////////////////// +/** + * Send a set of messages to the state server that will be processed + * atomically. For instance, you can do a combined setLocation/setPos and + * prevent race conditions where clients briefly get the setLocation but not + * the setPos, because the state server hasn't processed the setPos yet + */ void CConnectionRepository:: start_message_bundle() { ReMutexHolder holder(_lock); - // store up network messages until sendMessageBundle is called - // all updates in between must be sent from the same doId (updates - // must all affect the same DistributedObject) - // it is an error to call this again before calling sendMessageBundle + // store up network messages until sendMessageBundle is called all updates + // in between must be sent from the same doId (updates must all affect the + // same DistributedObject) it is an error to call this again before calling + // sendMessageBundle if (get_verbose()) { nout << "CR::SEND:BUNDLE_START(" << _bundling_msgs << ")" << endl; } @@ -494,12 +453,9 @@ start_message_bundle() { ++_bundling_msgs; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::send_message_bundle -// Access: Published -// Description: Send network messages queued up since -// startMessageBundle was called. -//////////////////////////////////////////////////////////////////// +/** + * Send network messages queued up since startMessageBundle was called. + */ void CConnectionRepository:: send_message_bundle(unsigned int channel, unsigned int sender_channel) { ReMutexHolder holder(_lock); @@ -529,12 +485,9 @@ send_message_bundle(unsigned int channel, unsigned int sender_channel) { } } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::abandon_message_bundles -// Access: Published -// Description: throw out any msgs that have been queued up for -// message bundles -//////////////////////////////////////////////////////////////////// +/** + * throw out any msgs that have been queued up for message bundles + */ void CConnectionRepository:: abandon_message_bundles() { ReMutexHolder holder(_lock); @@ -544,11 +497,9 @@ abandon_message_bundles() { _bundle_msgs.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::bundle_msg -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CConnectionRepository:: bundle_msg(const Datagram &dg) { ReMutexHolder holder(_lock); @@ -557,13 +508,10 @@ bundle_msg(const Datagram &dg) { _bundle_msgs.push_back(dg.get_message()); } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::consider_flush -// Access: Published -// Description: Sends the most recently queued data if enough time -// has elapsed. This only has meaning if -// set_collect_tcp() has been set to true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data if enough time has elapsed. This only + * has meaning if set_collect_tcp() has been set to true. + */ bool CConnectionRepository:: consider_flush() { ReMutexHolder holder(_lock); @@ -592,13 +540,10 @@ consider_flush() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::flush -// Access: Published -// Description: Sends the most recently queued data now. This only -// has meaning if set_collect_tcp() has been set to -// true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data now. This only has meaning if + * set_collect_tcp() has been set to true. + */ bool CConnectionRepository:: flush() { ReMutexHolder holder(_lock); @@ -626,11 +571,9 @@ flush() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::disconnect -// Access: Published -// Description: Closes the connection to the server. -//////////////////////////////////////////////////////////////////// +/** + * Closes the connection to the server. + */ void CConnectionRepository:: disconnect() { ReMutexHolder holder(_lock); @@ -659,12 +602,9 @@ disconnect() { _simulated_disconnect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::shutdown -// Access: Published -// Description: May be called at application shutdown to ensure all -// threads are cleaned up. -//////////////////////////////////////////////////////////////////// +/** + * May be called at application shutdown to ensure all threads are cleaned up. + */ void CConnectionRepository:: shutdown() { disconnect(); @@ -675,12 +615,10 @@ shutdown() { #endif // HAVE_NET } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::do_check_datagram -// Access: Private -// Description: The private implementation of check_datagram(), this -// gets one datagram if it is available. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of check_datagram(), this gets one datagram if + * it is available. + */ bool CConnectionRepository:: do_check_datagram() { #ifdef WANT_NATIVE_NET @@ -710,16 +648,12 @@ do_check_datagram() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::handle_update_field -// Access: Private -// Description: Directly handles an update message on a field. -// Python never touches the datagram; it just gets its -// distributed method called with the appropriate -// parameters. Returns true if everything is ok, false -// if there was an error processing the field's update -// method. -//////////////////////////////////////////////////////////////////// +/** + * Directly handles an update message on a field. Python never touches the + * datagram; it just gets its distributed method called with the appropriate + * parameters. Returns true if everything is ok, false if there was an error + * processing the field's update method. + */ bool CConnectionRepository:: handle_update_field() { #ifdef HAVE_PYTHON @@ -757,16 +691,16 @@ handle_update_field() { DCClass *dclass = (DCClass *)PyLong_AsLong(dclass_this); Py_DECREF(dclass_this); - // If in quiet zone mode, throw update away unless distobj - // has 'neverDisable' attribute set to non-zero + // If in quiet zone mode, throw update away unless distobj has + // 'neverDisable' attribute set to non-zero if (_in_quiet_zone) { PyObject *neverDisable = PyObject_GetAttrString(distobj, "neverDisable"); nassertr(neverDisable != NULL, false); unsigned int cNeverDisable = PyLong_AsLong(neverDisable); if (!cNeverDisable) { - // in quiet zone and distobj is disable-able - // drop update on the floor + // in quiet zone and distobj is disable-able drop update on the + // floor #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif @@ -774,10 +708,10 @@ handle_update_field() { } } - // It's a good idea to ensure the reference count to distobj is - // raised while we call the update method--otherwise, the update - // method might get into trouble if it tried to delete the - // object from the doId2do map. + // It's a good idea to ensure the reference count to distobj is raised + // while we call the update method--otherwise, the update method might + // get into trouble if it tried to delete the object from the doId2do + // map. Py_INCREF(distobj); dclass->receive_update(distobj, _di); Py_DECREF(distobj); @@ -800,17 +734,14 @@ handle_update_field() { } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::handle_update_field_owner -// Access: Private -// Description: Directly handles an update message on a field. -// Supports 'owner' views of objects, separate from 'visible' -// view, and forwards fields to the appropriate view(s) based -// on DC flags. Python never touches the datagram; it just -// gets its distributed method called with the appropriate -// parameters. Returns true if everything is ok, false if -// there was an error processing the field's update method. -//////////////////////////////////////////////////////////////////// +/** + * Directly handles an update message on a field. Supports 'owner' views of + * objects, separate from 'visible' view, and forwards fields to the + * appropriate view(s) based on DC flags. Python never touches the datagram; + * it just gets its distributed method called with the appropriate parameters. + * Returns true if everything is ok, false if there was an error processing + * the field's update method. + */ bool CConnectionRepository:: handle_update_field_owner() { #ifdef HAVE_PYTHON @@ -859,8 +790,8 @@ handle_update_field_owner() { if (field->is_ownrecv()) { // It's a good idea to ensure the reference count to distobjOV is // raised while we call the update method--otherwise, the update - // method might get into trouble if it tried to delete the - // object from the doId2do map. + // method might get into trouble if it tried to delete the object from + // the doId2do map. Py_INCREF(distobjOV); // make a copy of the datagram iterator so that we can use the main // iterator for the non-owner update @@ -899,10 +830,10 @@ handle_update_field_owner() { int field_id = packer.raw_unpack_uint16(); DCField *field = dclass->get_field_by_index(field_id); if (true) {//field->is_broadcast()) { - // It's a good idea to ensure the reference count to distobj is - // raised while we call the update method--otherwise, the update - // method might get into trouble if it tried to delete the - // object from the doId2do map. + // It's a good idea to ensure the reference count to distobj is raised + // while we call the update method--otherwise, the update method might + // get into trouble if it tried to delete the object from the doId2do + // map. Py_INCREF(distobj); dclass->receive_update(distobj, _di); Py_DECREF(distobj); @@ -925,13 +856,10 @@ handle_update_field_owner() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CConnectionRepository::describe_message -// Access: Private -// Description: Unpacks the message and reformats it for user -// consumption, writing a description on the indicated -// output stream. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks the message and reformats it for user consumption, writing a + * description on the indicated output stream. + */ void CConnectionRepository:: describe_message(ostream &out, const string &prefix, const Datagram &dg) const { @@ -959,8 +887,8 @@ describe_message(ostream &out, const string &prefix, } if (!is_update) { - // figure out the name of the message - // TODO: print out the arguments to the message + // figure out the name of the message TODO: print out the arguments to the + // message string msgName; #ifdef HAVE_PYTHON @@ -998,8 +926,8 @@ describe_message(ostream &out, const string &prefix, dg.dump_hex(out, 2); } else { - // It's an update message. Figure out what dclass the object is - // based on its doId, so we can decode the rest of the message. + // It's an update message. Figure out what dclass the object is based on + // its doId, so we can decode the rest of the message. do_id = packer.raw_unpack_uint32(); DCClass *dclass = NULL; diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index 06f581764c..8d62c21d86 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -1,16 +1,15 @@ -// Filename: cConnectionRepository.h -// Created by: drose (17May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConnectionRepository.h + * @author drose + * @date 2004-05-17 + */ #ifndef CCONNECTIONREPOSITORY_H #define CCONNECTIONREPOSITORY_H @@ -43,36 +42,33 @@ class URLSpec; class HTTPChannel; class SocketStream; -//////////////////////////////////////////////////////////////////// -// Class : CConnectionRepository -// Description : This class implements the C++ side of the -// ConnectionRepository object. In particular, it -// manages the connection to the server once it has been -// opened (but does not open it directly). It manages -// reading and writing datagrams on the connection and -// monitoring for unexpected disconnects as well as -// handling intentional disconnects. -// -// Certain server messages, like field updates, are -// handled entirely within the C++ layer, while server -// messages that are not understood by the C++ layer are -// returned up to the Python layer for processing. -//////////////////////////////////////////////////////////////////// +/** + * This class implements the C++ side of the ConnectionRepository object. In + * particular, it manages the connection to the server once it has been opened + * (but does not open it directly). It manages reading and writing datagrams + * on the connection and monitoring for unexpected disconnects as well as + * handling intentional disconnects. + * + * Certain server messages, like field updates, are handled entirely within + * the C++ layer, while server messages that are not understood by the C++ + * layer are returned up to the Python layer for processing. + */ class EXPCL_DIRECT CConnectionRepository { PUBLISHED: CConnectionRepository(bool has_owner_view = false, bool threaded_net = false); ~CConnectionRepository(); - // Any methods of this class that acquire _lock (which is most of - // them) *must* be tagged BLOCKING, to avoid risk of a race - // condition in Python when running in true threaded mode. The - // BLOCKING tag releases the Python GIL during the function call, - // and we re-acquire it when needed within these functions to call - // out to Python. If any functions acquire _lock while already - // holding the Python GIL, there could be a deadlock between these - // functions and the ones that are acquiring the GIL while already - // holding _lock. +/* + * Any methods of this class that acquire _lock (which is most of them) *must* + * be tagged BLOCKING, to avoid risk of a race condition in Python when + * running in true threaded mode. The BLOCKING tag releases the Python GIL + * during the function call, and we re-acquire it when needed within these + * functions to call out to Python. If any functions acquire _lock while + * already holding the Python GIL, there could be a deadlock between these + * functions and the ones that are acquiring the GIL while already holding + * _lock. + */ INLINE DCFile &get_dc_file(); @@ -123,7 +119,7 @@ PUBLISHED: BLOCKING INLINE CHANNEL_TYPE get_msg_channel(int offset = 0) const; BLOCKING INLINE int get_msg_channel_count() const; BLOCKING INLINE CHANNEL_TYPE get_msg_sender() const; -// INLINE unsigned char get_sec_code() const; +// INLINE unsigned char get_sec_code() const; BLOCKING INLINE unsigned int get_msg_type() const; INLINE static const string &get_overflow_event_name(); diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.I b/direct/src/distributed/cDistributedSmoothNodeBase.I index a04b8b2b00..5eba579e2b 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.I +++ b/direct/src/distributed/cDistributedSmoothNodeBase.I @@ -1,24 +1,20 @@ -// Filename: cDistributedSmoothNodeBase.I -// Created by: drose (03Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cDistributedSmoothNodeBase.I + * @author drose + * @date 2004-09-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::set_repository -// Access: Published, Static -// Description: Tells the C++ instance definition about the AI or Client -// repository, used for sending datagrams. -//////////////////////////////////////////////////////////////////// +/** + * Tells the C++ instance definition about the AI or Client repository, used + * for sending datagrams. + */ INLINE void CDistributedSmoothNodeBase:: set_repository(CConnectionRepository *repository, bool is_ai, CHANNEL_TYPE ai_id) { @@ -28,80 +24,66 @@ set_repository(CConnectionRepository *repository, } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::set_clock_delta -// Access: Published, Static -// Description: Tells the C++ instance definition about the global -// ClockDelta object. -//////////////////////////////////////////////////////////////////// +/** + * Tells the C++ instance definition about the global ClockDelta object. + */ INLINE void CDistributedSmoothNodeBase:: set_clock_delta(PyObject *clock_delta) { _clock_delta = clock_delta; } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::only_changed -// Access: Private, Static -// Description: Returns true if at least some of the bits of compare -// are set in flags, but no bits outside of compare are -// set. That is to say, that the only things that are -// changed are the bits indicated in compare. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if at least some of the bits of compare are set in flags, but + * no bits outside of compare are set. That is to say, that the only things + * that are changed are the bits indicated in compare. + */ INLINE bool CDistributedSmoothNodeBase:: only_changed(int flags, int compare) { return (flags & compare) != 0 && (flags & ~compare) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmStop -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmStop() { - //cout << "d_setSmStop" << endl; + // cout << "d_setSmStop" << endl; DCPacker packer; begin_send_update(packer, "setSmStop"); finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmH -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmH(PN_stdfloat h) { - //cout << "d_setSmH: " << h << endl; + // cout << "d_setSmH: " << h << endl; DCPacker packer; begin_send_update(packer, "setSmH"); packer.pack_double(h); finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmZ -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmZ(PN_stdfloat z) { - //cout << "d_setSmZ: " << z << endl; + // cout << "d_setSmZ: " << z << endl; DCPacker packer; begin_send_update(packer, "setSmZ"); packer.pack_double(z); finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmXY -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmXY(PN_stdfloat x, PN_stdfloat y) { - //cout << "d_setSmXY: " << x << ", " << y << endl; + // cout << "d_setSmXY: " << x << ", " << y << endl; DCPacker packer; begin_send_update(packer, "setSmXY"); packer.pack_double(x); @@ -109,14 +91,12 @@ d_setSmXY(PN_stdfloat x, PN_stdfloat y) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmXZ -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmXZ(PN_stdfloat x, PN_stdfloat z) { - //cout << "d_setSmXZ: " << x << ", " << z << endl; + // cout << "d_setSmXZ: " << x << ", " << z << endl; DCPacker packer; begin_send_update(packer, "setSmXZ"); packer.pack_double(x); @@ -124,14 +104,12 @@ d_setSmXZ(PN_stdfloat x, PN_stdfloat z) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmPos -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { - //cout << "d_setSmXYZ: " << x << ", " << y << ", " << z << endl; + // cout << "d_setSmXYZ: " << x << ", " << y << ", " << z << endl; DCPacker packer; begin_send_update(packer, "setSmPos"); packer.pack_double(x); @@ -140,14 +118,12 @@ d_setSmPos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmHpr -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { - //cout << "d_setSmHPR: " << h << ", " << p << ", " << r << endl; + // cout << "d_setSmHPR: " << h << ", " << p << ", " << r << endl; DCPacker packer; begin_send_update(packer, "setSmHpr"); packer.pack_double(h); @@ -156,14 +132,12 @@ d_setSmHpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmXYH -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h) { - //cout << "d_setSmXYH: " << x << ", " << y << ", " << h << endl; + // cout << "d_setSmXYH: " << x << ", " << y << ", " << h << endl; DCPacker packer; begin_send_update(packer, "setSmXYH"); packer.pack_double(x); @@ -172,14 +146,13 @@ d_setSmXYH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat h) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmXYZH -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h) { - //cout << "d_setSmXYZH: " << x << ", " << y << ", " << z << ", " << h << endl; + // cout << "d_setSmXYZH: " << x << ", " << y << ", " << z << ", " << h << + // endl; DCPacker packer; begin_send_update(packer, "setSmXYZH"); packer.pack_double(x); @@ -189,14 +162,13 @@ d_setSmXYZH(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h) { finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmPosHpr -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { - //cout << "d_setSmPosHpr: " << x << ", " << y << ", " << z << ", " << h << ", " << p << ", " << r << endl; + // cout << "d_setSmPosHpr: " << x << ", " << y << ", " << z << ", " << h << + // ", " << p << ", " << r << endl; DCPacker packer; begin_send_update(packer, "setSmPosHpr"); packer.pack_double(x); @@ -208,15 +180,13 @@ d_setSmPosHpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_std finish_send_update(packer); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::d_setSmPosHprL -// send out pos, hpr, and location info (zoneId) -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CDistributedSmoothNodeBase:: d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_uint64 l) { - //cout << "d_setSmPosHprL: " << x << ", " << y << ", " << z << ", " << h << ", " << p << ", " << r << l << endl; + // cout << "d_setSmPosHprL: " << x << ", " << y << ", " << z << ", " << h << + // ", " << p << ", " << r << l << endl; DCPacker packer; begin_send_update(packer, "setSmPosHprL"); packer.pack_uint64(_currL[0]); @@ -228,4 +198,3 @@ d_setSmPosHprL(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_st packer.pack_double(r); finish_send_update(packer); } - diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.cxx b/direct/src/distributed/cDistributedSmoothNodeBase.cxx index 1f2518f1d3..45b65353ee 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.cxx +++ b/direct/src/distributed/cDistributedSmoothNodeBase.cxx @@ -1,16 +1,15 @@ -// Filename: cDistributedSmoothNodeBase.cxx -// Created by: drose (03Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cDistributedSmoothNodeBase.cxx + * @author drose + * @date 2004-09-03 + */ #include "cDistributedSmoothNodeBase.h" #include "cConnectionRepository.h" @@ -22,11 +21,9 @@ static const PN_stdfloat smooth_node_epsilon = 0.01; static const double network_time_precision = 100.0; // Matches ClockDelta.py -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CDistributedSmoothNodeBase:: CDistributedSmoothNodeBase() { _repository = NULL; @@ -41,24 +38,19 @@ CDistributedSmoothNodeBase() { _currL[1] = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CDistributedSmoothNodeBase:: ~CDistributedSmoothNodeBase() { } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::initialize -// Access: Published -// Description: Initializes the internal structures from some -// constructs that are normally stored only in Python. -// Also reads the current node's pos & hpr values in -// preparation for transmitting them via one of the -// broadcast_pos_hpr_*() methods. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the internal structures from some constructs that are normally + * stored only in Python. Also reads the current node's pos & hpr values in + * preparation for transmitting them via one of the broadcast_pos_hpr_*() + * methods. + */ void CDistributedSmoothNodeBase:: initialize(const NodePath &node_path, DCClass *dclass, CHANNEL_TYPE do_id) { _node_path = node_path; @@ -72,25 +64,20 @@ initialize(const NodePath &node_path, DCClass *dclass, CHANNEL_TYPE do_id) { _store_stop = false; } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::send_everything -// Access: Published -// Description: Broadcasts the current pos/hpr in its complete form. -//////////////////////////////////////////////////////////////////// +/** + * Broadcasts the current pos/hpr in its complete form. + */ void CDistributedSmoothNodeBase:: send_everything() { _currL[0] = _currL[1]; - d_setSmPosHprL(_store_xyz[0], _store_xyz[1], _store_xyz[2], + d_setSmPosHprL(_store_xyz[0], _store_xyz[1], _store_xyz[2], _store_hpr[0], _store_hpr[1], _store_hpr[2], _currL[0]); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::broadcast_pos_hpr_full -// Access: Published -// Description: Examines the complete pos/hpr information to see -// which of the six elements have changed, and -// broadcasts the appropriate messages. -//////////////////////////////////////////////////////////////////// +/** + * Examines the complete pos/hpr information to see which of the six elements + * have changed, and broadcasts the appropriate messages. + */ void CDistributedSmoothNodeBase:: broadcast_pos_hpr_full() { LPoint3 xyz = _node_path.get_pos(); @@ -129,12 +116,12 @@ broadcast_pos_hpr_full() { } if (_currL[0] != _currL[1]) { - // location (zoneId) has changed, send out all info - // copy over 'set' location over to 'sent' location + // location (zoneId) has changed, send out all info copy over 'set' + // location over to 'sent' location _currL[0] = _currL[1]; // Any other change _store_stop = false; - d_setSmPosHprL(_store_xyz[0], _store_xyz[1], _store_xyz[2], + d_setSmPosHprL(_store_xyz[0], _store_xyz[1], _store_xyz[2], _store_hpr[0], _store_hpr[1], _store_hpr[2], _currL[0]); } else if (flags == 0) { @@ -187,17 +174,15 @@ broadcast_pos_hpr_full() { } else { // Any other change _store_stop = false; - d_setSmPosHpr(_store_xyz[0], _store_xyz[1], _store_xyz[2], + d_setSmPosHpr(_store_xyz[0], _store_xyz[1], _store_xyz[2], _store_hpr[0], _store_hpr[1], _store_hpr[2]); } } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::broadcast_pos_hpr_xyh -// Access: Published -// Description: Examines only X, Y, and H of the pos/hpr information, -// and broadcasts the appropriate messages. -//////////////////////////////////////////////////////////////////// +/** + * Examines only X, Y, and H of the pos/hpr information, and broadcasts the + * appropriate messages. + */ void CDistributedSmoothNodeBase:: broadcast_pos_hpr_xyh() { LPoint3 xyz = _node_path.get_pos(); @@ -244,12 +229,10 @@ broadcast_pos_hpr_xyh() { } } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::broadcast_pos_hpr_xy -// Access: Published -// Description: Examines only X and Y of the pos/hpr information, -// and broadcasts the appropriate messages. -//////////////////////////////////////////////////////////////////// +/** + * Examines only X and Y of the pos/hpr information, and broadcasts the + * appropriate messages. + */ void CDistributedSmoothNodeBase:: broadcast_pos_hpr_xy() { LPoint3 xyz = _node_path.get_pos(); @@ -280,13 +263,10 @@ broadcast_pos_hpr_xy() { } } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::begin_send_update -// Access: Private -// Description: Fills up the packer with the data appropriate for -// sending an update on the indicated field name, up -// until the arguments. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the packer with the data appropriate for sending an update on the + * indicated field name, up until the arguments. + */ void CDistributedSmoothNodeBase:: begin_send_update(DCPacker &packer, const string &field_name) { DCField *field = _dclass->get_field_by_name(field_name); @@ -297,7 +277,7 @@ begin_send_update(DCPacker &packer, const string &field_name) { packer.raw_pack_uint8(1); packer.RAW_PACK_CHANNEL(_do_id); packer.RAW_PACK_CHANNEL(_ai_id); - //packer.raw_pack_uint8('A'); + // packer.raw_pack_uint8('A'); packer.raw_pack_uint16(STATESERVER_OBJECT_UPDATE_FIELD); packer.raw_pack_uint32(_do_id); packer.raw_pack_uint16(field->get_number()); @@ -312,11 +292,9 @@ begin_send_update(DCPacker &packer, const string &field_name) { packer.push(); } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::finish_send_update -// Access: Private -// Description: Appends the timestamp and sends the update. -//////////////////////////////////////////////////////////////////// +/** + * Appends the timestamp and sends the update. + */ void CDistributedSmoothNodeBase:: finish_send_update(DCPacker &packer) { #ifdef HAVE_PYTHON @@ -332,8 +310,8 @@ finish_send_update(DCPacker &packer) { double local_time = ClockObject::get_global_clock()->get_real_time(); int network_time = (int)cfloor(((local_time - delta) * network_time_precision) + 0.5); - // Preserves the lower NetworkTimeBits of the networkTime value, - // and extends the sign bit all the way up. + // Preserves the lower NetworkTimeBits of the networkTime value, and extends + // the sign bit all the way up. network_time = ((network_time + 0x8000) & 0xFFFF) - 0x8000; packer.pack_int(network_time); @@ -376,14 +354,9 @@ finish_send_update(DCPacker &packer) { } } -//////////////////////////////////////////////////////////////////// -// Function: CDistributedSmoothNodeBase::set_curr_l -// published function to set current location for -// this object, this location is then sent out along -// with the next position broadcast -// Access: Private -// Description: Appends the timestamp and sends the update. -//////////////////////////////////////////////////////////////////// +/** + * Appends the timestamp and sends the update. + */ void CDistributedSmoothNodeBase:: set_curr_l(PN_uint64 l) { _currL[1] = l; @@ -393,4 +366,3 @@ void CDistributedSmoothNodeBase:: print_curr_l() { cout << "printCurrL: sent l: " << _currL[1] << " last set l: " << _currL[0] << "\n"; } - diff --git a/direct/src/distributed/cDistributedSmoothNodeBase.h b/direct/src/distributed/cDistributedSmoothNodeBase.h index 9bb8e6744c..b59bd9af2a 100644 --- a/direct/src/distributed/cDistributedSmoothNodeBase.h +++ b/direct/src/distributed/cDistributedSmoothNodeBase.h @@ -1,16 +1,15 @@ -// Filename: cDistributedSmoothNodeBase.h -// Created by: drose (03Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cDistributedSmoothNodeBase.h + * @author drose + * @date 2004-09-03 + */ #ifndef CDISTRIBUTEDSMOOTHNODEBASE_H #define CDISTRIBUTEDSMOOTHNODEBASE_H @@ -25,17 +24,15 @@ class DCClass; class CConnectionRepository; -//////////////////////////////////////////////////////////////////// -// Class : CDistributedSmoothNodeBase -// Description : This class defines some basic methods of -// DistributedSmoothNodeBase which have been moved into -// C++ as a performance optimization. -//////////////////////////////////////////////////////////////////// +/** + * This class defines some basic methods of DistributedSmoothNodeBase which + * have been moved into C++ as a performance optimization. + */ class EXPCL_DIRECT CDistributedSmoothNodeBase { PUBLISHED: CDistributedSmoothNodeBase(); ~CDistributedSmoothNodeBase(); - + INLINE void set_repository(CConnectionRepository *repository, bool is_ai, CHANNEL_TYPE ai_id); @@ -98,8 +95,8 @@ private: LPoint3 _store_xyz; LVecBase3 _store_hpr; bool _store_stop; - // contains most recently sent location info as - // index 0, index 1 contains most recently set location info + // contains most recently sent location info as index 0, index 1 contains + // most recently set location info PN_uint64 _currL[2]; }; diff --git a/direct/src/distributed/config_distributed.cxx b/direct/src/distributed/config_distributed.cxx index 93fe7a4a8e..9420bd05df 100644 --- a/direct/src/distributed/config_distributed.cxx +++ b/direct/src/distributed/config_distributed.cxx @@ -1,16 +1,15 @@ -// Filename: config_distributed.cxx -// Created by: drose (19May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_distributed.cxx + * @author drose + * @date 2004-05-19 + */ #include "config_distributed.h" #include "dconfig.h" @@ -47,14 +46,12 @@ ConfigVariableBool handle_datagrams_internally "for performance reasons. When it is false, all datagrams " "are handled by the Python implementation.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libdistributed -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdistributed() { static bool initialized = false; @@ -64,4 +61,3 @@ init_libdistributed() { initialized = true; } - diff --git a/direct/src/distributed/config_distributed.h b/direct/src/distributed/config_distributed.h index a0d4446911..1ffbc39df9 100644 --- a/direct/src/distributed/config_distributed.h +++ b/direct/src/distributed/config_distributed.h @@ -1,16 +1,15 @@ -// Filename: config_distributed.h -// Created by: drose (19May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_distributed.h + * @author drose + * @date 2004-05-19 + */ #ifndef CONFIG_DISTRIBUTED_H #define CONFIG_DISTRIBUTED_H @@ -32,4 +31,3 @@ extern ConfigVariableBool handle_datagrams_internally; extern EXPCL_DIRECT void init_libdistributed(); #endif - diff --git a/direct/src/interval/cConstrainHprInterval.I b/direct/src/interval/cConstrainHprInterval.I index eec191960d..a851f70428 100644 --- a/direct/src/interval/cConstrainHprInterval.I +++ b/direct/src/interval/cConstrainHprInterval.I @@ -1,33 +1,27 @@ -// Filename: cConstrainHprInterval.I -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainHprInterval.I + * @author pratt + * @date 2008-03-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CConstrainHprInterval::get_node -// Access: Published -// Description: Returns the "source" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "source" node. + */ INLINE const NodePath &CConstrainHprInterval:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainHprInterval::get_target -// Access: Published -// Description: Returns the "target" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "target" node. + */ INLINE const NodePath &CConstrainHprInterval:: get_target() const { return _target; diff --git a/direct/src/interval/cConstrainHprInterval.cxx b/direct/src/interval/cConstrainHprInterval.cxx index 0ebd7e0d95..bfd6f6d86d 100644 --- a/direct/src/interval/cConstrainHprInterval.cxx +++ b/direct/src/interval/cConstrainHprInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cConstrainHprInterval.cxx -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainHprInterval.cxx + * @author pratt + * @date 2008-03-10 + */ #include "cConstrainHprInterval.h" #include "config_interval.h" @@ -18,18 +17,14 @@ TypeHandle CConstrainHprInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CConstrainHprInterval::Constructor -// Access: Published -// Description: Constructs a constraint interval that will constrain -// the orientation of one node to the orientation of -// another, possibly with an added rotation. -// -// If wrt is true, the node's orientation will be -// transformed into the target node's parent's space -// before being copied. If wrt is false, the target -// node's local orientation will be copied unaltered. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a constraint interval that will constrain the orientation of one + * node to the orientation of another, possibly with an added rotation. + * + * If wrt is true, the node's orientation will be transformed into the target + * node's parent's space before being copied. If wrt is false, the target + * node's local orientation will be copied unaltered. + */ CConstrainHprInterval:: CConstrainHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, @@ -42,13 +37,11 @@ CConstrainHprInterval(const string &name, double duration, _quatOffset.set_hpr(hprOffset); } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainHprInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CConstrainHprInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -72,11 +65,9 @@ priv_step(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainHprInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CConstrainHprInterval:: output(ostream &out) const { out << get_name() << ":"; diff --git a/direct/src/interval/cConstrainHprInterval.h b/direct/src/interval/cConstrainHprInterval.h index c1034b13e3..42c52df558 100644 --- a/direct/src/interval/cConstrainHprInterval.h +++ b/direct/src/interval/cConstrainHprInterval.h @@ -1,16 +1,15 @@ -// Filename: cConstrainHprInterval.h -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainHprInterval.h + * @author pratt + * @date 2008-03-10 + */ #ifndef CCONSTRAINHPRINTERVAL_H #define CCONSTRAINHPRINTERVAL_H @@ -21,11 +20,10 @@ #include "lvecBase3.h" #include "lquaternion.h" -//////////////////////////////////////////////////////////////////// -// Class : CConstrainHprInterval -// Description : A constraint interval that will constrain the -// orientation of one node to the orientation of another. -//////////////////////////////////////////////////////////////////// +/** + * A constraint interval that will constrain the orientation of one node to + * the orientation of another. + */ class EXPCL_DIRECT CConstrainHprInterval : public CConstraintInterval { PUBLISHED: CConstrainHprInterval(const string &name, double duration, @@ -65,4 +63,3 @@ private: #include "cConstrainHprInterval.I" #endif - diff --git a/direct/src/interval/cConstrainPosHprInterval.I b/direct/src/interval/cConstrainPosHprInterval.I index 4ef0f171f1..c2859279c5 100644 --- a/direct/src/interval/cConstrainPosHprInterval.I +++ b/direct/src/interval/cConstrainPosHprInterval.I @@ -1,33 +1,27 @@ -// Filename: cConstrainPosHprInterval.I -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosHprInterval.I + * @author pratt + * @date 2008-03-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosHprInterval::get_node -// Access: Published -// Description: Returns the "source" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "source" node. + */ INLINE const NodePath &CConstrainPosHprInterval:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosHprInterval::get_target -// Access: Published -// Description: Returns the "target" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "target" node. + */ INLINE const NodePath &CConstrainPosHprInterval:: get_target() const { return _target; diff --git a/direct/src/interval/cConstrainPosHprInterval.cxx b/direct/src/interval/cConstrainPosHprInterval.cxx index 14eb9714bf..7b0944c3e4 100644 --- a/direct/src/interval/cConstrainPosHprInterval.cxx +++ b/direct/src/interval/cConstrainPosHprInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cConstrainPosHprInterval.cxx -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosHprInterval.cxx + * @author pratt + * @date 2008-03-10 + */ #include "cConstrainPosHprInterval.h" #include "config_interval.h" @@ -18,19 +17,15 @@ TypeHandle CConstrainPosHprInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosHprInterval::Constructor -// Access: Published -// Description: Constructs a constraint interval that will constrain -// the position and orientation of one node to the -// position and orientation of another. -// -// If wrt is true, the node's position and orientation -// will be transformed into the target node's parent's -// space before being copied. If wrt is false, the -// target node's local position and orientation will be -// copied unaltered. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a constraint interval that will constrain the position and + * orientation of one node to the position and orientation of another. + * + * If wrt is true, the node's position and orientation will be transformed + * into the target node's parent's space before being copied. If wrt is + * false, the target node's local position and orientation will be copied + * unaltered. + */ CConstrainPosHprInterval:: CConstrainPosHprInterval(const string &name, double duration, const NodePath &node, const NodePath &target, @@ -45,13 +40,11 @@ CConstrainPosHprInterval(const string &name, double duration, _quatOffset.set_hpr(hprOffset); } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosHprInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CConstrainPosHprInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -75,11 +68,9 @@ priv_step(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosHprInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CConstrainPosHprInterval:: output(ostream &out) const { out << get_name() << ":"; diff --git a/direct/src/interval/cConstrainPosHprInterval.h b/direct/src/interval/cConstrainPosHprInterval.h index 13fb173103..fcdcd39c32 100644 --- a/direct/src/interval/cConstrainPosHprInterval.h +++ b/direct/src/interval/cConstrainPosHprInterval.h @@ -1,16 +1,15 @@ -// Filename: cConstrainPosHprInterval.h -// Created by: pratt (10Mar08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosHprInterval.h + * @author pratt + * @date 2008-03-10 + */ #ifndef CCONSTRAINPOSHPRINTERVAL_H #define CCONSTRAINPOSHPRINTERVAL_H @@ -21,12 +20,10 @@ #include "lvecBase3.h" #include "lquaternion.h" -//////////////////////////////////////////////////////////////////// -// Class : CConstrainPosHprInterval -// Description : A constraint interval that will constrain the -// position and orientation of one node to the -// position and orientation of another. -//////////////////////////////////////////////////////////////////// +/** + * A constraint interval that will constrain the position and orientation of + * one node to the position and orientation of another. + */ class EXPCL_DIRECT CConstrainPosHprInterval : public CConstraintInterval { PUBLISHED: CConstrainPosHprInterval(const string &name, double duration, @@ -68,4 +65,3 @@ private: #include "cConstrainPosHprInterval.I" #endif - diff --git a/direct/src/interval/cConstrainPosInterval.I b/direct/src/interval/cConstrainPosInterval.I index 119732ac01..a7256c04c9 100644 --- a/direct/src/interval/cConstrainPosInterval.I +++ b/direct/src/interval/cConstrainPosInterval.I @@ -1,33 +1,27 @@ -// Filename: cConstrainPosInterval.I -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosInterval.I + * @author pratt + * @date 2006-09-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosInterval::get_node -// Access: Published -// Description: Returns the "source" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "source" node. + */ INLINE const NodePath &CConstrainPosInterval:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosInterval::get_target -// Access: Published -// Description: Returns the "target" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "target" node. + */ INLINE const NodePath &CConstrainPosInterval:: get_target() const { return _target; diff --git a/direct/src/interval/cConstrainPosInterval.cxx b/direct/src/interval/cConstrainPosInterval.cxx index 09f7286b5d..fe8f235654 100644 --- a/direct/src/interval/cConstrainPosInterval.cxx +++ b/direct/src/interval/cConstrainPosInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cConstrainPosInterval.cxx -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosInterval.cxx + * @author pratt + * @date 2006-09-29 + */ #include "cConstrainPosInterval.h" #include "config_interval.h" @@ -18,17 +17,14 @@ TypeHandle CConstrainPosInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosInterval::Constructor -// Access: Published -// Description: Constructs a constraint interval that will constrain -// the position of one node to the position of another. -// -// If wrt is true, the node's position will be -// transformed into the target node's parent's space -// before being copied. If wrt is false, the target -// node's local position will be copied unaltered. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a constraint interval that will constrain the position of one + * node to the position of another. + * + * If wrt is true, the node's position will be transformed into the target + * node's parent's space before being copied. If wrt is false, the target + * node's local position will be copied unaltered. + */ CConstrainPosInterval:: CConstrainPosInterval(const string &name, double duration, const NodePath &node, const NodePath &target, @@ -41,13 +37,11 @@ CConstrainPosInterval(const string &name, double duration, { } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CConstrainPosInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -75,11 +69,9 @@ priv_step(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainPosInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CConstrainPosInterval:: output(ostream &out) const { out << get_name() << ":"; diff --git a/direct/src/interval/cConstrainPosInterval.h b/direct/src/interval/cConstrainPosInterval.h index 1782cdc177..aa05a0f427 100644 --- a/direct/src/interval/cConstrainPosInterval.h +++ b/direct/src/interval/cConstrainPosInterval.h @@ -1,16 +1,15 @@ -// Filename: cConstrainPosInterval.h -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainPosInterval.h + * @author pratt + * @date 2006-09-29 + */ #ifndef CCONSTRAINPOSINTERVAL_H #define CCONSTRAINPOSINTERVAL_H @@ -20,11 +19,10 @@ #include "nodePath.h" #include "lvecBase3.h" -//////////////////////////////////////////////////////////////////// -// Class : CConstrainPosInterval -// Description : A constraint interval that will constrain the -// position of one node to the position of another. -//////////////////////////////////////////////////////////////////// +/** + * A constraint interval that will constrain the position of one node to the + * position of another. + */ class EXPCL_DIRECT CConstrainPosInterval : public CConstraintInterval { PUBLISHED: CConstrainPosInterval(const string &name, double duration, @@ -64,4 +62,3 @@ private: #include "cConstrainPosInterval.I" #endif - diff --git a/direct/src/interval/cConstrainTransformInterval.I b/direct/src/interval/cConstrainTransformInterval.I index b57863b151..36d234b7e4 100644 --- a/direct/src/interval/cConstrainTransformInterval.I +++ b/direct/src/interval/cConstrainTransformInterval.I @@ -1,33 +1,27 @@ -// Filename: cConstrainTransformInterval.I -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainTransformInterval.I + * @author pratt + * @date 2006-09-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CConstrainTransformInterval::get_node -// Access: Published -// Description: Returns the "source" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "source" node. + */ INLINE const NodePath &CConstrainTransformInterval:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainTransformInterval::get_target -// Access: Published -// Description: Returns the "target" node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "target" node. + */ INLINE const NodePath &CConstrainTransformInterval:: get_target() const { return _target; diff --git a/direct/src/interval/cConstrainTransformInterval.cxx b/direct/src/interval/cConstrainTransformInterval.cxx index 69ee31b523..f816f3bbc1 100644 --- a/direct/src/interval/cConstrainTransformInterval.cxx +++ b/direct/src/interval/cConstrainTransformInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cConstrainTransformInterval.cxx -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainTransformInterval.cxx + * @author pratt + * @date 2006-09-29 + */ #include "cConstrainTransformInterval.h" #include "transformState.h" @@ -18,18 +17,15 @@ TypeHandle CConstrainTransformInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CConstrainTransformInterval::Constructor -// Access: Published -// Description: Constructs a constraint interval that will constrain -// the transform of one node to the transform of another. -// To clarify, the transform of node will be copied to target. -// -// If wrt is true, the node's transform will be -// transformed into the target node's parent's space -// before being copied. If wrt is false, the node's -// local transform will be copied unaltered. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a constraint interval that will constrain the transform of one + * node to the transform of another. To clarify, the transform of node will + * be copied to target. + * + * If wrt is true, the node's transform will be transformed into the target + * node's parent's space before being copied. If wrt is false, the node's + * local transform will be copied unaltered. + */ CConstrainTransformInterval:: CConstrainTransformInterval(const string &name, double duration, const NodePath &node, const NodePath &target, @@ -41,13 +37,11 @@ CConstrainTransformInterval(const string &name, double duration, { } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainTransformInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CConstrainTransformInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -74,11 +68,9 @@ priv_step(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CConstrainTransformInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CConstrainTransformInterval:: output(ostream &out) const { out << get_name() << ":"; diff --git a/direct/src/interval/cConstrainTransformInterval.h b/direct/src/interval/cConstrainTransformInterval.h index b6dcbc47ca..b8bfc2c06f 100644 --- a/direct/src/interval/cConstrainTransformInterval.h +++ b/direct/src/interval/cConstrainTransformInterval.h @@ -1,16 +1,15 @@ -// Filename: cConstrainTransformInterval.h -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstrainTransformInterval.h + * @author pratt + * @date 2006-09-29 + */ #ifndef CCONSTRAINTRANSFORMINTERVAL_H #define CCONSTRAINTRANSFORMINTERVAL_H @@ -19,11 +18,10 @@ #include "cConstraintInterval.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : CConstrainTransformInterval -// Description : A constraint interval that will constrain the -// transform of one node to the transform of another. -//////////////////////////////////////////////////////////////////// +/** + * A constraint interval that will constrain the transform of one node to the + * transform of another. + */ class EXPCL_DIRECT CConstrainTransformInterval : public CConstraintInterval { PUBLISHED: CConstrainTransformInterval(const string &name, double duration, @@ -62,4 +60,3 @@ private: #include "cConstrainTransformInterval.I" #endif - diff --git a/direct/src/interval/cConstraintInterval.I b/direct/src/interval/cConstraintInterval.I index 4c14f6fd20..05fd62a661 100644 --- a/direct/src/interval/cConstraintInterval.I +++ b/direct/src/interval/cConstraintInterval.I @@ -1,15 +1,12 @@ -// Filename: cConstraintInterval.I -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstraintInterval.I + * @author pratt + * @date 2006-09-29 + */ diff --git a/direct/src/interval/cConstraintInterval.cxx b/direct/src/interval/cConstraintInterval.cxx index b5da5ec560..708caed9fa 100644 --- a/direct/src/interval/cConstraintInterval.cxx +++ b/direct/src/interval/cConstraintInterval.cxx @@ -1,26 +1,23 @@ -// Filename: cConstraintInterval.cxx -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstraintInterval.cxx + * @author pratt + * @date 2006-09-29 + */ #include "cConstraintInterval.h" TypeHandle CConstraintInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CConstraintInterval::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CConstraintInterval:: CConstraintInterval(const string &name, double duration) : CInterval(name, duration, true) diff --git a/direct/src/interval/cConstraintInterval.h b/direct/src/interval/cConstraintInterval.h index 2c34de9dc2..32f90ed978 100644 --- a/direct/src/interval/cConstraintInterval.h +++ b/direct/src/interval/cConstraintInterval.h @@ -1,16 +1,15 @@ -// Filename: cConstraintInterval.h -// Created by: pratt (29Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cConstraintInterval.h + * @author pratt + * @date 2006-09-29 + */ #ifndef CCONSTRAINTINTERVAL_H #define CCONSTRAINTINTERVAL_H @@ -18,11 +17,10 @@ #include "directbase.h" #include "cInterval.h" -//////////////////////////////////////////////////////////////////// -// Class : CConstraintInterval -// Description : The base class for a family of intervals that -// constrain some property to a value over time. -//////////////////////////////////////////////////////////////////// +/** + * The base class for a family of intervals that constrain some property to a + * value over time. + */ class EXPCL_DIRECT CConstraintInterval : public CInterval { PUBLISHED: bool bogus_variable; @@ -51,4 +49,3 @@ private: #include "cConstraintInterval.I" #endif - diff --git a/direct/src/interval/cInterval.I b/direct/src/interval/cInterval.I index aa2bf3fab1..7650bddbee 100644 --- a/direct/src/interval/cInterval.I +++ b/direct/src/interval/cInterval.I @@ -1,233 +1,179 @@ -// Filename: cInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cInterval.I + * @author drose + * @date 2002-08-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_name -// Access: Published -// Description: Returns the interval's name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval's name. + */ INLINE const string &CInterval:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_duration -// Access: Published -// Description: Returns the duration of the interval in seconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the duration of the interval in seconds. + */ INLINE double CInterval:: get_duration() const { recompute(); return _duration; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_open_ended -// Access: Published -// Description: Returns the state of the "open_ended" flag. This is -// primarily intended for instantaneous intervals like -// FunctionIntervals; it indicates true if the interval -// has some lasting effect that should be applied even -// if the interval doesn't get started until after its -// finish time, or false if the interval is a transitive -// thing that doesn't need to be called late. -//////////////////////////////////////////////////////////////////// +/** + * Returns the state of the "open_ended" flag. This is primarily intended for + * instantaneous intervals like FunctionIntervals; it indicates true if the + * interval has some lasting effect that should be applied even if the + * interval doesn't get started until after its finish time, or false if the + * interval is a transitive thing that doesn't need to be called late. + */ INLINE bool CInterval:: get_open_ended() const { return _open_ended; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_state -// Access: Published -// Description: Indicates the state the interval believes it is in: -// whether it has been started, is currently in the -// middle, or has been finalized. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the state the interval believes it is in: whether it has been + * started, is currently in the middle, or has been finalized. + */ INLINE CInterval::State CInterval:: get_state() const { return _state; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::is_stopped -// Access: Published -// Description: Returns true if the interval is in either its initial -// or final states (but not in a running or paused -// state). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the interval is in either its initial or final states (but + * not in a running or paused state). + */ INLINE bool CInterval:: is_stopped() const { return (_state == S_initial || _state == S_final); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_done_event -// Access: Published -// Description: Sets the event that is generated whenever the -// interval reaches its final state, whether it is -// explicitly finished or whether it gets there on its -// own. -//////////////////////////////////////////////////////////////////// +/** + * Sets the event that is generated whenever the interval reaches its final + * state, whether it is explicitly finished or whether it gets there on its + * own. + */ INLINE void CInterval:: set_done_event(const string &event) { _done_event = event; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_done_event -// Access: Published -// Description: Returns the event that is generated whenever the -// interval reaches its final state, whether it is -// explicitly finished or whether it gets there on its -// own. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event that is generated whenever the interval reaches its final + * state, whether it is explicitly finished or whether it gets there on its + * own. + */ INLINE const string &CInterval:: get_done_event() const { return _done_event; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_t -// Access: Published -// Description: Returns the current time of the interval: the last -// value of t passed to priv_initialize(), priv_step(), or -// priv_finalize(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current time of the interval: the last value of t passed to + * priv_initialize(), priv_step(), or priv_finalize(). + */ INLINE double CInterval:: get_t() const { return _curr_t; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_auto_pause -// Access: Published -// Description: Changes the state of the 'auto_pause' flag. If -// this is true, the interval may be arbitrarily -// interrupted when the system needs to reset due to -// some external event by calling -// CIntervalManager::interrupt(). If this -// is false (the default), the interval must always be -// explicitly finished or paused. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the 'auto_pause' flag. If this is true, the interval + * may be arbitrarily interrupted when the system needs to reset due to some + * external event by calling CIntervalManager::interrupt(). If this is false + * (the default), the interval must always be explicitly finished or paused. + */ INLINE void CInterval:: set_auto_pause(bool auto_pause) { _auto_pause = auto_pause; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_auto_pause -// Access: Published -// Description: Returns the state of the 'auto_pause' flag. See -// set_auto_pause(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the state of the 'auto_pause' flag. See set_auto_pause(). + */ INLINE bool CInterval:: get_auto_pause() const { return _auto_pause; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_auto_finish -// Access: Published -// Description: Changes the state of the 'auto_finish' flag. If -// this is true, the interval may be arbitrarily -// finished when the system needs to reset due to -// some external event by calling -// CIntervalManager::interrupt(). If this -// is false (the default), the interval must always be -// explicitly finished or paused. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the 'auto_finish' flag. If this is true, the interval + * may be arbitrarily finished when the system needs to reset due to some + * external event by calling CIntervalManager::interrupt(). If this is false + * (the default), the interval must always be explicitly finished or paused. + */ INLINE void CInterval:: set_auto_finish(bool auto_finish) { _auto_finish = auto_finish; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_auto_finish -// Access: Published -// Description: Returns the state of the 'auto_finish' flag. See -// set_auto_finish(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the state of the 'auto_finish' flag. See set_auto_finish(). + */ INLINE bool CInterval:: get_auto_finish() const { return _auto_finish; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_wants_t_callback -// Access: Published -// Description: Changes the state of the 'wants_t_callback' flag. If -// this is true, the interval will be returned by -// CIntervalManager::get_event() each time the -// interval's time value has been changed, regardless of -// whether it has any external events. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the 'wants_t_callback' flag. If this is true, the + * interval will be returned by CIntervalManager::get_event() each time the + * interval's time value has been changed, regardless of whether it has any + * external events. + */ INLINE void CInterval:: set_wants_t_callback(bool wants_t_callback) { _wants_t_callback = wants_t_callback; _last_t_callback = -1.0; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_wants_t_callback -// Access: Published -// Description: Returns the state of the 'wants_t_callback' flag. -// See set_wants_t_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the state of the 'wants_t_callback' flag. See + * set_wants_t_callback(). + */ INLINE bool CInterval:: get_wants_t_callback() const { return _wants_t_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_manager -// Access: Published -// Description: Indicates the CIntervalManager object which will be -// responsible for playing this interval. This defaults -// to the global CIntervalManager; you should need to -// change this only if you have special requirements for -// playing this interval. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the CIntervalManager object which will be responsible for playing + * this interval. This defaults to the global CIntervalManager; you should + * need to change this only if you have special requirements for playing this + * interval. + */ INLINE void CInterval:: set_manager(CIntervalManager *manager) { _manager = manager; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_manager -// Access: Published -// Description: Returns the CIntervalManager object which will be -// responsible for playing this interval. Note that -// this can only return a C++ object; if the particular -// CIntervalManager object has been extended in the -// scripting language, this will return the encapsulated -// C++ object, not the full extended object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CIntervalManager object which will be responsible for playing + * this interval. Note that this can only return a C++ object; if the + * particular CIntervalManager object has been extended in the scripting + * language, this will return the encapsulated C++ object, not the full + * extended object. + */ INLINE CIntervalManager *CInterval:: get_manager() const { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::check_t_callback -// Access: Public -// Description: Returns true if the wants_t_callback() flag is true -// and the interval's t value has changed since the last -// call to check_t_callback(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the wants_t_callback() flag is true and the interval's t + * value has changed since the last call to check_t_callback(), false + * otherwise. + */ INLINE bool CInterval:: check_t_callback() { if (get_wants_t_callback() && get_t() != _last_t_callback) { @@ -237,11 +183,9 @@ check_t_callback() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::recompute -// Access: Protected -// Description: Calls do_recompute() if the dirty flag has been set. -//////////////////////////////////////////////////////////////////// +/** + * Calls do_recompute() if the dirty flag has been set. + */ INLINE void CInterval:: recompute() const { if (_dirty) { @@ -249,12 +193,9 @@ recompute() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::check_stopped -// Access: Protected -// Description: Issues a warning if our internal state is not in -// one of the stopped states. -//////////////////////////////////////////////////////////////////// +/** + * Issues a warning if our internal state is not in one of the stopped states. + */ INLINE void CInterval:: check_stopped(TypeHandle type, const char *method_name) const { if (_state == S_started) { @@ -265,12 +206,9 @@ check_stopped(TypeHandle type, const char *method_name) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::check_started -// Access: Protected -// Description: Issues a warning if our internal state is not in -// one of the started states. -//////////////////////////////////////////////////////////////////// +/** + * Issues a warning if our internal state is not in one of the started states. + */ INLINE void CInterval:: check_started(TypeHandle type, const char *method_name) const { if (_state != S_started && _state != S_paused) { @@ -286,4 +224,3 @@ operator << (ostream &out, const CInterval &ival) { ival.output(out); return out; } - diff --git a/direct/src/interval/cInterval.cxx b/direct/src/interval/cInterval.cxx index e241ee6a5d..84325720ab 100644 --- a/direct/src/interval/cInterval.cxx +++ b/direct/src/interval/cInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "cInterval.h" #include "cIntervalManager.h" @@ -33,11 +32,9 @@ get_pstats_name(const string &name) { return pname; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CInterval:: CInterval(const string &name, double duration, bool open_ended) : _state(S_initial), @@ -70,11 +67,9 @@ CInterval(const string &name, double duration, bool open_ended) : } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CInterval:: ~CInterval() { if (interval_cat.is_spam()) { @@ -83,20 +78,16 @@ CInterval:: } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_t -// Access: Published -// Description: Explicitly sets the time within the interval. -// Normally, you would use start() .. finish() to let -// the time play normally, but this may be used to set -// the time to some particular value. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the time within the interval. Normally, you would use + * start() .. finish() to let the time play normally, but this may be used to + * set the time to some particular value. + */ void CInterval:: set_t(double t) { - // There doesn't seem to be any reason to clamp this, and it - // breaks looping intervals. The interval code should properly - // handle t values outside the proper range. - //t = min(max(t, 0.0), get_duration()); + // There doesn't seem to be any reason to clamp this, and it breaks looping + // intervals. The interval code should properly handle t values outside the + // proper range. t = min(max(t, 0.0), get_duration()); switch (get_state()) { case S_initial: @@ -118,10 +109,10 @@ set_t(double t) { break; case S_paused: - // Support modifying t while the interval is paused. In this - // case, we simply step to the new value of t; but this will - // change the state to S_started, so we must then change it back - // to S_paused by hand (because we're still paused). + // Support modifying t while the interval is paused. In this case, we + // simply step to the new value of t; but this will change the state to + // S_started, so we must then change it back to S_paused by hand (because + // we're still paused). priv_step(t); priv_interrupt(); break; @@ -137,47 +128,35 @@ set_t(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::start -// Access: Published -// Description: Starts the interval playing by registering it with -// the current CIntervalManager. The interval will -// play to the end and stop. -// -// If end_t is less than zero, it indicates the end of -// the interval. -//////////////////////////////////////////////////////////////////// +/** + * Starts the interval playing by registering it with the current + * CIntervalManager. The interval will play to the end and stop. + * + * If end_t is less than zero, it indicates the end of the interval. + */ void CInterval:: start(double start_t, double end_t, double play_rate) { setup_play(start_t, end_t, play_rate, false); _manager->add_c_interval(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::loop -// Access: Published -// Description: Starts the interval playing by registering it with -// the current CIntervalManager. The interval will -// play until it is interrupted with finish() or -// pause(), looping back to start_t when it reaches -// end_t. -// -// If end_t is less than zero, it indicates the end of -// the interval. -//////////////////////////////////////////////////////////////////// +/** + * Starts the interval playing by registering it with the current + * CIntervalManager. The interval will play until it is interrupted with + * finish() or pause(), looping back to start_t when it reaches end_t. + * + * If end_t is less than zero, it indicates the end of the interval. + */ void CInterval:: loop(double start_t, double end_t, double play_rate) { setup_play(start_t, end_t, play_rate, true); _manager->add_c_interval(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::pause -// Access: Published -// Description: Stops the interval from playing but leaves it in its -// current state. It may later be resumed from this -// point by calling resume(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the interval from playing but leaves it in its current state. It may + * later be resumed from this point by calling resume(). + */ double CInterval:: pause() { if (get_state() == S_started) { @@ -190,24 +169,20 @@ pause() { return get_t(); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::resume -// Access: Published -// Description: Restarts the interval from its current point after a -// previous call to pause(). -//////////////////////////////////////////////////////////////////// +/** + * Restarts the interval from its current point after a previous call to + * pause(). + */ void CInterval:: resume() { setup_resume(); _manager->add_c_interval(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::resume -// Access: Published -// Description: Restarts the interval from the indicated point after a -// previous call to pause(). -//////////////////////////////////////////////////////////////////// +/** + * Restarts the interval from the indicated point after a previous call to + * pause(). + */ void CInterval:: resume(double start_t) { set_t(start_t); @@ -215,26 +190,20 @@ resume(double start_t) { _manager->add_c_interval(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::resume_until -// Access: Published -// Description: Restarts the interval from the current point after a -// previous call to pause() (or a previous -// play-to-point-and-stop), to play until the indicated -// point and then stop. -//////////////////////////////////////////////////////////////////// +/** + * Restarts the interval from the current point after a previous call to + * pause() (or a previous play-to-point-and-stop), to play until the indicated + * point and then stop. + */ void CInterval:: resume_until(double end_t) { setup_resume_until(end_t); _manager->add_c_interval(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::finish -// Access: Published -// Description: Stops the interval from playing and sets it to its -// final state. -//////////////////////////////////////////////////////////////////// +/** + * Stops the interval from playing and sets it to its final state. + */ void CInterval:: finish() { switch (get_state()) { @@ -255,15 +224,12 @@ finish() { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::clear_to_initial -// Access: Published -// Description: Pauses the interval, if it is playing, and resets its -// state to its initial state, abandoning any state -// changes already in progress in the middle of the -// interval. Calling this is like pausing the interval -// and discarding it, creating a new one in its place. -//////////////////////////////////////////////////////////////////// +/** + * Pauses the interval, if it is playing, and resets its state to its initial + * state, abandoning any state changes already in progress in the middle of + * the interval. Calling this is like pausing the interval and discarding it, + * creating a new one in its place. + */ void CInterval:: clear_to_initial() { pause(); @@ -272,38 +238,30 @@ clear_to_initial() { _curr_t = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::is_playing -// Access: Published -// Description: Returns true if the interval is currently playing, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the interval is currently playing, false otherwise. + */ bool CInterval:: is_playing() const { int index = _manager->find_c_interval(this->get_name()); return (index >= 0); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::get_play_rate -// Access: Published -// Description: Returns the play rate as set by the last call to -// start(), loop(), or set_play_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the play rate as set by the last call to start(), loop(), or + * set_play_rate(). + */ double CInterval:: get_play_rate() const { return _play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::set_play_rate -// Access: Published -// Description: Changes the play rate of the interval. If the -// interval is already started, this changes its speed -// on-the-fly. Note that since play_rate is a parameter -// to start() and loop(), the next call to start() or -// loop() will reset this parameter. -//////////////////////////////////////////////////////////////////// +/** + * Changes the play rate of the interval. If the interval is already started, + * this changes its speed on-the-fly. Note that since play_rate is a + * parameter to start() and loop(), the next call to start() or loop() will + * reset this parameter. + */ void CInterval:: set_play_rate(double play_rate) { if (is_playing()) { @@ -315,12 +273,9 @@ set_play_rate(double play_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_do_event -// Access: Published -// Description: Calls the appropriate event function indicated by the -// EventType. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate event function indicated by the EventType. + */ void CInterval:: priv_do_event(double t, EventType event) { PStatTimer timer(_ival_pcollector); @@ -362,14 +317,11 @@ priv_do_event(double t, EventType event) { << "Invalid event type: " << (int)event << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_initialize -// Access: Published, Virtual -// Description: This replaces the first call to priv_step(), and indicates -// that the interval has just begun. This may be -// overridden by derived classes that need to do some -// explicit initialization on the first call. -//////////////////////////////////////////////////////////////////// +/** + * This replaces the first call to priv_step(), and indicates that the + * interval has just begun. This may be overridden by derived classes that + * need to do some explicit initialization on the first call. + */ void CInterval:: priv_initialize(double t) { check_stopped(get_class_type(), "priv_initialize"); @@ -378,14 +330,11 @@ priv_initialize(double t) { priv_step(t); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_initialize() .. priv_step() -// .. priv_finalize(), when everything is to happen within -// one frame. The interval should initialize itself, -// then leave itself in the final state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_initialize() .. priv_step() .. + * priv_finalize(), when everything is to happen within one frame. The + * interval should initialize itself, then leave itself in the final state. + */ void CInterval:: priv_instant() { check_stopped(get_class_type(), "priv_instant"); @@ -396,13 +345,11 @@ priv_instant() { interval_done(); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -410,14 +357,11 @@ priv_step(double t) { _curr_t = t; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_finalize -// Access: Published, Virtual -// Description: This is called to stop an interval, forcing it to -// whatever state it would be after it played all the -// way through. It's generally invoked by -// set_final_t(). -//////////////////////////////////////////////////////////////////// +/** + * This is called to stop an interval, forcing it to whatever state it would + * be after it played all the way through. It's generally invoked by + * set_final_t(). + */ void CInterval:: priv_finalize() { check_started(get_class_type(), "priv_finalize"); @@ -427,14 +371,11 @@ priv_finalize() { interval_done(); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::reverse_initialize -// Access: Published, Virtual -// Description: Similar to priv_initialize(), but this is called when the -// interval is being played backwards; it indicates that -// the interval should start at the finishing state and -// undo any intervening intervals. -//////////////////////////////////////////////////////////////////// +/** + * Similar to priv_initialize(), but this is called when the interval is being + * played backwards; it indicates that the interval should start at the + * finishing state and undo any intervening intervals. + */ void CInterval:: priv_reverse_initialize(double t) { check_stopped(get_class_type(), "priv_reverse_initialize"); @@ -443,15 +384,12 @@ priv_reverse_initialize(double t) { priv_step(t); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::reverse_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_reverse_initialize() -// .. priv_step() .. priv_reverse_finalize(), when everything is -// to happen within one frame. The interval should -// initialize itself, then leave itself in the initial -// state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_reverse_initialize() .. priv_step() .. + * priv_reverse_finalize(), when everything is to happen within one frame. + * The interval should initialize itself, then leave itself in the initial + * state. + */ void CInterval:: priv_reverse_instant() { check_stopped(get_class_type(), "priv_reverse_instant"); @@ -461,13 +399,10 @@ priv_reverse_instant() { _state = S_initial; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::reverse_finalize -// Access: Published, Virtual -// Description: Called generally following a priv_reverse_initialize(), -// this indicates the interval should set itself to the -// initial state. -//////////////////////////////////////////////////////////////////// +/** + * Called generally following a priv_reverse_initialize(), this indicates the + * interval should set itself to the initial state. + */ void CInterval:: priv_reverse_finalize() { check_started(get_class_type(), "priv_reverse_finalize"); @@ -475,31 +410,25 @@ priv_reverse_finalize() { _state = S_initial; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::priv_interrupt -// Access: Published, Virtual -// Description: This is called while the interval is playing to -// indicate that it is about to be interrupted; that is, -// priv_step() will not be called for a length of time. But -// the interval should remain in its current state in -// anticipation of being eventually restarted when the -// calls to priv_step() eventually resume. -// -// The purpose of this function is to allow self-running -// intervals like sound intervals to stop the actual -// sound playback during the pause. -//////////////////////////////////////////////////////////////////// +/** + * This is called while the interval is playing to indicate that it is about + * to be interrupted; that is, priv_step() will not be called for a length of + * time. But the interval should remain in its current state in anticipation + * of being eventually restarted when the calls to priv_step() eventually + * resume. + * + * The purpose of this function is to allow self-running intervals like sound + * intervals to stop the actual sound playback during the pause. + */ void CInterval:: priv_interrupt() { check_started(get_class_type(), "priv_interrupt"); _state = S_paused; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CInterval:: output(ostream &out) const { out << get_name(); @@ -508,32 +437,25 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CInterval:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::setup_play -// Access: Published -// Description: Called to prepare the interval for automatic timed -// playback, e.g. via a Python task. The interval will -// be played from start_t to end_t, at a time factor -// specified by play_rate. start_t must always be less -// than end_t (except for the exception for end_t == -1, -// below), but if play_rate is negative the interval -// will be played backwards. -// -// Specify end_t of -1 to play the entire interval from -// start_t. -// -// Call step_play() repeatedly to execute the interval. -//////////////////////////////////////////////////////////////////// +/** + * Called to prepare the interval for automatic timed playback, e.g. via a + * Python task. The interval will be played from start_t to end_t, at a time + * factor specified by play_rate. start_t must always be less than end_t + * (except for the exception for end_t == -1, below), but if play_rate is + * negative the interval will be played backwards. + * + * Specify end_t of -1 to play the entire interval from start_t. + * + * Call step_play() repeatedly to execute the interval. + */ void CInterval:: setup_play(double start_t, double end_t, double play_rate, bool do_loop) { nassertv(start_t < end_t || end_t < 0.0); @@ -566,13 +488,10 @@ setup_play(double start_t, double end_t, double play_rate, bool do_loop) { _loop_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::setup_resume -// Access: Published -// Description: Called to prepare the interval for restarting at the -// current point within the interval after an -// interruption. -//////////////////////////////////////////////////////////////////// +/** + * Called to prepare the interval for restarting at the current point within + * the interval after an interruption. + */ void CInterval:: setup_resume() { double now = ClockObject::get_global_clock()->get_frame_time(); @@ -585,14 +504,11 @@ setup_resume() { _loop_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::setup_resume_until -// Access: Published -// Description: Called to prepare the interval for restarting from -// the current point after a previous call to pause() -// (or a previous play-to-point-and-stop), to play until -// the indicated point and then stop. -//////////////////////////////////////////////////////////////////// +/** + * Called to prepare the interval for restarting from the current point after + * a previous call to pause() (or a previous play-to-point-and-stop), to play + * until the indicated point and then stop. + */ void CInterval:: setup_resume_until(double end_t) { double duration = get_duration(); @@ -608,15 +524,13 @@ setup_resume_until(double end_t) { setup_resume(); } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::step_play -// Access: Published -// Description: Should be called once per frame to execute the -// automatic timed playback begun with setup_play(). -// -// Returns true if the interval should continue, false -// if it is done and should stop. -//////////////////////////////////////////////////////////////////// +/** + * Should be called once per frame to execute the automatic timed playback + * begun with setup_play(). + * + * Returns true if the interval should continue, false if it is done and + * should stop. + */ bool CInterval:: step_play() { PStatTimer timer(_ival_pcollector); @@ -628,7 +542,7 @@ step_play() { if (_end_t_at_end) { _end_t = get_duration(); } - + if (t < _end_t) { // In the middle of the interval, not a problem. if (is_stopped()) { @@ -636,12 +550,11 @@ step_play() { } else { priv_step(t); } - + } else { // Past the ending point; time to finalize. if (_end_t_at_end) { - // Only finalize if the playback cycle includes the whole - // interval. + // Only finalize if the playback cycle includes the whole interval. if (is_stopped()) { if (get_open_ended() || _loop_count != 0) { priv_instant(); @@ -656,16 +569,14 @@ step_play() { priv_step(_end_t); } } - - // Advance the clock for the next loop cycle. We might have to - // advance multiple times if we skipped several cycles in the past - // frame. - + + // Advance the clock for the next loop cycle. We might have to advance + // multiple times if we skipped several cycles in the past frame. + if (_end_t == _start_t) { - // If the interval has no length, we loop exactly once each - // time. + // If the interval has no length, we loop exactly once each time. _loop_count++; - + } else { // Otherwise, figure out how many loops we need to skip. double time_per_loop = (_end_t - _start_t) / _play_rate; @@ -678,7 +589,7 @@ step_play() { } else { // Playing backwards. double t = (now - _clock_start) * _play_rate + _end_t; - + if (t >= _start_t) { // In the middle of the interval, not a problem. if (is_stopped()) { @@ -686,12 +597,11 @@ step_play() { } else { priv_step(t); } - + } else { // Past the ending point; time to finalize. if (_start_t_at_start) { - // Only finalize if the playback cycle includes the whole - // interval. + // Only finalize if the playback cycle includes the whole interval. if (is_stopped()) { if (get_open_ended() || _loop_count != 0) { priv_reverse_instant(); @@ -706,16 +616,14 @@ step_play() { priv_step(_start_t); } } - - // Advance the clock for the next loop cycle. We might have to - // advance multiple times if we skipped several cycles in the past - // frame. - + + // Advance the clock for the next loop cycle. We might have to advance + // multiple times if we skipped several cycles in the past frame. + if (_end_t == _start_t) { - // If the interval has no length, we loop exactly once each - // time. + // If the interval has no length, we loop exactly once each time. _loop_count++; - + } else { // Otherwise, figure out how many loops we need to skip. double time_per_loop = (_end_t - _start_t) / -_play_rate; @@ -735,13 +643,10 @@ step_play() { return should_continue; } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::mark_dirty -// Access: Public -// Description: Called by a derived class to indicate the interval has -// been changed internally and must be recomputed before -// its duration may be returned. -//////////////////////////////////////////////////////////////////// +/** + * Called by a derived class to indicate the interval has been changed + * internally and must be recomputed before its duration may be returned. + */ void CInterval:: mark_dirty() { if (!_dirty) { @@ -753,12 +658,9 @@ mark_dirty() { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::interval_done -// Access: Protected -// Description: Called internally whenever the interval reaches its -// final state. -//////////////////////////////////////////////////////////////////// +/** + * Called internally whenever the interval reaches its final state. + */ void CInterval:: interval_done() { if (!_done_event.empty()) { @@ -766,13 +668,10 @@ interval_done() { } } -//////////////////////////////////////////////////////////////////// -// Function: CInterval::do_recompute -// Access: Protected, Virtual -// Description: Does whatever processing is necessary to recompute -// the interval after a call to mark_dirty() has -// indicated a recomputation is necessary. -//////////////////////////////////////////////////////////////////// +/** + * Does whatever processing is necessary to recompute the interval after a + * call to mark_dirty() has indicated a recomputation is necessary. + */ void CInterval:: do_recompute() { _dirty = false; @@ -796,4 +695,3 @@ operator << (ostream &out, CInterval::State state) { return out << "**invalid state(" << (int)state << ")**"; } - diff --git a/direct/src/interval/cInterval.h b/direct/src/interval/cInterval.h index 03b3f26b1d..d62eadc0c7 100644 --- a/direct/src/interval/cInterval.h +++ b/direct/src/interval/cInterval.h @@ -1,16 +1,15 @@ -// Filename: cInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CINTERVAL_H #define CINTERVAL_H @@ -23,19 +22,16 @@ class CIntervalManager; -//////////////////////////////////////////////////////////////////// -// Class : CInterval -// Description : The base class for timeline components. A CInterval -// represents a single action, event, or collection of -// nested intervals that will be performed at some -// specific time or over a period of time. -// -// This is essentially similar to the Python "Interval" -// class, but it is implemented in C++ (hence the name). -// Intervals that may be implemented in C++ will inherit -// from this class; Intervals that must be implemented -// in Python will inherit from the similar Python class. -//////////////////////////////////////////////////////////////////// +/** + * The base class for timeline components. A CInterval represents a single + * action, event, or collection of nested intervals that will be performed at + * some specific time or over a period of time. + * + * This is essentially similar to the Python "Interval" class, but it is + * implemented in C++ (hence the name). Intervals that may be implemented in + * C++ will inherit from this class; Intervals that must be implemented in + * Python will inherit from the similar Python class. + */ class EXPCL_DIRECT CInterval : public TypedReferenceCount { public: CInterval(const string &name, double duration, bool open_ended); @@ -97,14 +93,13 @@ PUBLISHED: double get_play_rate() const; void set_play_rate(double play_rate); - // These functions control the actual playback of the interval. - // Don't call them directly; they're intended to be called from a - // supervising object, e.g. the Python start() .. finish() - // interface. + // These functions control the actual playback of the interval. Don't call + // them directly; they're intended to be called from a supervising object, + // e.g. the Python start() .. finish() interface. - // These cannot be declared private because they must be accessible - // to Python, but the method names are prefixed with priv_ to remind - // you that you probably don't want to be using them directly. + // These cannot be declared private because they must be accessible to + // Python, but the method names are prefixed with priv_ to remind you that + // you probably don't want to be using them directly. void priv_do_event(double t, EventType event); virtual void priv_initialize(double t); virtual void priv_instant(); @@ -172,21 +167,20 @@ protected: double _play_rate; bool _do_loop; int _loop_count; - + private: bool _open_ended; bool _dirty; - // We keep a record of the "parent" intervals (that is, any - // CMetaInterval objects that keep a pointer to this one) strictly - // so we can mark all of our parents dirty when this interval gets - // dirty. + // We keep a record of the "parent" intervals (that is, any CMetaInterval + // objects that keep a pointer to this one) strictly so we can mark all of + // our parents dirty when this interval gets dirty. typedef pvector Parents; Parents _parents; static PStatCollector _root_pcollector; PStatCollector _ival_pcollector; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -213,6 +207,3 @@ EXPCL_DIRECT ostream &operator << (ostream &out, CInterval::State state); #include "cInterval.I" #endif - - - diff --git a/direct/src/interval/cIntervalManager.I b/direct/src/interval/cIntervalManager.I index 7063f64583..44ca1062cc 100644 --- a/direct/src/interval/cIntervalManager.I +++ b/direct/src/interval/cIntervalManager.I @@ -1,42 +1,34 @@ -// Filename: cIntervalManager.I -// Created by: drose (10Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cIntervalManager.I + * @author drose + * @date 2002-09-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::set_event_queue -// Access: Published -// Description: Specifies a custom event queue to be used for -// throwing done events from intervals as they finish. -// If this is not specified, the global event queue is -// used. -// -// The caller maintains ownership of the EventQueue -// object; it is the caller's responsibility to ensure -// that the supplied EventQueue does not destruct during -// the lifetime of the CIntervalManager. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a custom event queue to be used for throwing done events from + * intervals as they finish. If this is not specified, the global event queue + * is used. + * + * The caller maintains ownership of the EventQueue object; it is the caller's + * responsibility to ensure that the supplied EventQueue does not destruct + * during the lifetime of the CIntervalManager. + */ INLINE void CIntervalManager:: set_event_queue(EventQueue *event_queue) { _event_queue = event_queue; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_event_queue -// Access: Published -// Description: Returns the custom event queue to be used for -// throwing done events from intervals as they finish. -//////////////////////////////////////////////////////////////////// +/** + * Returns the custom event queue to be used for throwing done events from + * intervals as they finish. + */ INLINE EventQueue *CIntervalManager:: get_event_queue() const { return _event_queue; @@ -47,4 +39,3 @@ operator << (ostream &out, const CIntervalManager &ival_mgr) { ival_mgr.output(out); return out; } - diff --git a/direct/src/interval/cIntervalManager.cxx b/direct/src/interval/cIntervalManager.cxx index 4b4a021a82..bd6189b349 100644 --- a/direct/src/interval/cIntervalManager.cxx +++ b/direct/src/interval/cIntervalManager.cxx @@ -1,16 +1,15 @@ -// Filename: cIntervalManager.cxx -// Created by: drose (10Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cIntervalManager.cxx + * @author drose + * @date 2002-09-10 + */ #include "cIntervalManager.h" #include "cMetaInterval.h" @@ -20,11 +19,9 @@ CIntervalManager *CIntervalManager::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CIntervalManager:: CIntervalManager() { _first_slot = 0; @@ -32,49 +29,41 @@ CIntervalManager() { _event_queue = EventQueue::get_global_event_queue(); } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CIntervalManager:: ~CIntervalManager() { nassertv(_name_index.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::add_c_interval -// Access: Published -// Description: Adds the interval to the manager, and returns a -// unique index for the interval. This index will be -// unique among all the currently added intervals, but -// not unique across all intervals ever added to the -// manager. The maximum index value will never exceed -// the maximum number of intervals added at any given -// time. -// -// If the external flag is true, the interval is -// understood to also be stored in the scripting -// language data structures. In this case, it will be -// available for information returned by -// get_next_event() and get_next_removal(). If external -// is false, the interval's index will never be returned -// by these two functions. -//////////////////////////////////////////////////////////////////// +/** + * Adds the interval to the manager, and returns a unique index for the + * interval. This index will be unique among all the currently added + * intervals, but not unique across all intervals ever added to the manager. + * The maximum index value will never exceed the maximum number of intervals + * added at any given time. + * + * If the external flag is true, the interval is understood to also be stored + * in the scripting language data structures. In this case, it will be + * available for information returned by get_next_event() and + * get_next_removal(). If external is false, the interval's index will never + * be returned by these two functions. + */ int CIntervalManager:: add_c_interval(CInterval *interval, bool external) { MutexHolder holder(_lock); - // First, check the name index. If we already have an interval by - // this name, it gets finished and removed. + // First, check the name index. If we already have an interval by this + // name, it gets finished and removed. NameIndex::iterator ni = _name_index.find(interval->get_name()); if (ni != _name_index.end()) { int old_index = (*ni).second; nassertr(old_index >= 0 && old_index < (int)_intervals.size(), -1) CInterval *old_interval = _intervals[old_index]._interval; if (old_interval == interval) { - // No, it's the same interval that was already here. In this - // case, don't finish the interval; just return it. + // No, it's the same interval that was already here. In this case, + // don't finish the interval; just return it. return old_index; } finish_interval(old_interval); @@ -108,18 +97,16 @@ add_c_interval(CInterval *interval, bool external) { def._flags |= F_meta_interval; } def._next_slot = -1; - + _name_index[interval->get_name()] = slot; nassertr(_first_slot >= 0, slot); return slot; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::find_c_interval -// Access: Published -// Description: Returns the index associated with the named interval, -// if there is such an interval, or -1 if there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index associated with the named interval, if there is such an + * interval, or -1 if there is not. + */ int CIntervalManager:: find_c_interval(const string &name) const { MutexHolder holder(_lock); @@ -131,11 +118,9 @@ find_c_interval(const string &name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_c_interval -// Access: Published -// Description: Returns the interval associated with the given index. -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval associated with the given index. + */ CInterval *CIntervalManager:: get_c_interval(int index) const { MutexHolder holder(_lock); @@ -144,14 +129,11 @@ get_c_interval(int index) const { return _intervals[index]._interval; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::remove_c_interval -// Access: Published -// Description: Removes the indicated interval from the queue -// immediately. It will not be returned from -// get_next_removal(), and none of its pending events, -// if any, will be returned by get_next_event(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated interval from the queue immediately. It will not be + * returned from get_next_removal(), and none of its pending events, if any, + * will be returned by get_next_event(). + */ void CIntervalManager:: remove_c_interval(int index) { MutexHolder holder(_lock); @@ -170,17 +152,14 @@ remove_c_interval(int index) { _first_slot = index; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::interrupt -// Access: Published -// Description: Pauses or finishes (removes from the active queue) -// all intervals tagged with auto_pause or auto_finish -// set to true. These are intervals that someone fired -// up but won't necessarily expect to clean up; they can -// be interrupted at will when necessary. -// -// Returns the number of intervals affected. -//////////////////////////////////////////////////////////////////// +/** + * Pauses or finishes (removes from the active queue) all intervals tagged + * with auto_pause or auto_finish set to true. These are intervals that + * someone fired up but won't necessarily expect to clean up; they can be + * interrupted at will when necessary. + * + * Returns the number of intervals affected. + */ int CIntervalManager:: interrupt() { MutexHolder holder(_lock); @@ -215,10 +194,10 @@ interrupt() { case CInterval::S_initial: def._interval->priv_instant(); break; - + case CInterval::S_final: break; - + default: def._interval->priv_finalize(); } @@ -241,11 +220,9 @@ interrupt() { return num_paused; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_num_intervals -// Access: Published -// Description: Returns the number of currently active intervals. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of currently active intervals. + */ int CIntervalManager:: get_num_intervals() const { MutexHolder holder(_lock); @@ -253,16 +230,12 @@ get_num_intervals() const { return _name_index.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_max_index -// Access: Published -// Description: Returns one more than the largest interval index -// number in the manager. If you walk through all the -// values between (0, get_max_index()] and call -// get_c_interval() on each number, you will retrieve -// all of the managed intervals (and possibly a number -// of NULL pointers as well). -//////////////////////////////////////////////////////////////////// +/** + * Returns one more than the largest interval index number in the manager. If + * you walk through all the values between (0, get_max_index()] and call + * get_c_interval() on each number, you will retrieve all of the managed + * intervals (and possibly a number of NULL pointers as well). + */ int CIntervalManager:: get_max_index() const { MutexHolder holder(_lock); @@ -270,20 +243,16 @@ get_max_index() const { return _intervals.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::step -// Access: Published -// Description: This should be called every frame to do the -// processing for all the active intervals. It will -// call step_play() for each interval that has been -// added and that has not yet been removed. -// -// After each call to step(), the scripting language -// should call get_next_event() and get_next_removal() -// repeatedly to process all the high-level -// (e.g. Python-interval-based) events and to manage the -// high-level list of intervals. -//////////////////////////////////////////////////////////////////// +/** + * This should be called every frame to do the processing for all the active + * intervals. It will call step_play() for each interval that has been added + * and that has not yet been removed. + * + * After each call to step(), the scripting language should call + * get_next_event() and get_next_removal() repeatedly to process all the high- + * level (e.g. Python-interval-based) events and to manage the high-level + * list of intervals. + */ void CIntervalManager:: step() { MutexHolder holder(_lock); @@ -295,8 +264,8 @@ step() { const IntervalDef &def = _intervals[index]; nassertv(def._interval != (CInterval *)NULL); if (!def._interval->step_play()) { - // This interval is finished and wants to be removed from the - // active list. + // This interval is finished and wants to be removed from the active + // list. NameIndex::iterator prev; prev = ni; ++ni; @@ -312,23 +281,18 @@ step() { _next_event_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_next_event -// Access: Published -// Description: This should be called by the scripting language after -// each call to step(). It returns the index number of -// the next interval that has events requiring servicing -// by the scripting language, or -1 if no more intervals -// have any events pending. -// -// If this function returns something other than -1, it -// is the scripting language's responsibility to query -// the indicated interval for its next event via -// get_event_index(), and eventually pop_event(). -// -// Then get_next_event() should be called again until it -// returns -1. -//////////////////////////////////////////////////////////////////// +/** + * This should be called by the scripting language after each call to step(). + * It returns the index number of the next interval that has events requiring + * servicing by the scripting language, or -1 if no more intervals have any + * events pending. + * + * If this function returns something other than -1, it is the scripting + * language's responsibility to query the indicated interval for its next + * event via get_event_index(), and eventually pop_event(). + * + * Then get_next_event() should be called again until it returns -1. + */ int CIntervalManager:: get_next_event() { MutexHolder holder(_lock); @@ -336,7 +300,7 @@ get_next_event() { while (_next_event_index < (int)_intervals.size()) { IntervalDef &def = _intervals[_next_event_index]; if (def._interval != (CInterval *)NULL) { - if ((def._flags & F_external) != 0 && + if ((def._flags & F_external) != 0 && def._interval->check_t_callback()) { return _next_event_index; } @@ -355,19 +319,15 @@ get_next_event() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_next_removal -// Access: Published -// Description: This should be called by the scripting language after -// each call to step(). It returns the index number of -// an interval that was recently removed, or -1 if no -// intervals were removed. -// -// If this returns something other than -1, the -// scripting language should clean up its own data -// structures accordingly, and then call -// get_next_removal() again. -//////////////////////////////////////////////////////////////////// +/** + * This should be called by the scripting language after each call to step(). + * It returns the index number of an interval that was recently removed, or -1 + * if no intervals were removed. + * + * If this returns something other than -1, the scripting language should + * clean up its own data structures accordingly, and then call + * get_next_removal() again. + */ int CIntervalManager:: get_next_removal() { MutexHolder holder(_lock); @@ -387,11 +347,9 @@ get_next_removal() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CIntervalManager:: output(ostream &out) const { MutexHolder holder(_lock); @@ -399,17 +357,15 @@ output(ostream &out) const { out << "CIntervalManager, " << (int)_name_index.size() << " intervals."; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CIntervalManager:: write(ostream &out) const { MutexHolder holder(_lock); - // We need to write this line so that it's clear what's going on - // when there are no intervals in the list. + // We need to write this line so that it's clear what's going on when there + // are no intervals in the list. out << (int)_name_index.size() << " intervals.\n"; NameIndex::const_iterator ni; @@ -434,12 +390,9 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::get_global_ptr -// Access: Published, Static -// Description: Returns the pointer to the one global -// CIntervalManager object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the one global CIntervalManager object. + */ CIntervalManager *CIntervalManager:: get_global_ptr() { if (_global_ptr == (CIntervalManager *)NULL) { @@ -448,12 +401,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::finish_interval -// Access: Private -// Description: Explicitly finishes the indicated interval in -// preparation for moving it to the removed queue. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly finishes the indicated interval in preparation for moving it to + * the removed queue. + */ void CIntervalManager:: finish_interval(CInterval *interval) { switch (interval->get_state()) { @@ -469,15 +420,11 @@ finish_interval(CInterval *interval) { } } -//////////////////////////////////////////////////////////////////// -// Function: CIntervalManager::remove_index -// Access: Private -// Description: Removes the indicated index number from the active -// list, either by moving it to the removed queue if it -// is flagged external, or by simply making the slot -// available again if it is not. Assumes the lock is -// already held. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated index number from the active list, either by moving + * it to the removed queue if it is flagged external, or by simply making the + * slot available again if it is not. Assumes the lock is already held. + */ void CIntervalManager:: remove_index(int index) { nassertv(_lock.debug_is_locked()); @@ -489,5 +436,5 @@ remove_index(int index) { def._interval = (CInterval *)NULL; def._next_slot = _first_slot; _first_slot = index; - } + } } diff --git a/direct/src/interval/cIntervalManager.h b/direct/src/interval/cIntervalManager.h index 3aa00d8049..26616dce91 100644 --- a/direct/src/interval/cIntervalManager.h +++ b/direct/src/interval/cIntervalManager.h @@ -1,16 +1,15 @@ -// Filename: cIntervalManager.h -// Created by: drose (10Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cIntervalManager.h + * @author drose + * @date 2002-09-10 + */ #ifndef CINTERVALMANAGER_H #define CINTERVALMANAGER_H @@ -25,21 +24,18 @@ class EventQueue; -//////////////////////////////////////////////////////////////////// -// Class : CIntervalManager -// Description : This object holds a number of currently-playing -// intervals and is responsible for advancing them each -// frame as needed. -// -// There is normally only one IntervalManager object in -// the world, and it is the responsibility of the -// scripting language to call step() on this object once -// each frame, and to then process the events indicated by -// get_next_event(). -// -// It is also possible to create multiple -// IntervalManager objects for special needs. -//////////////////////////////////////////////////////////////////// +/** + * This object holds a number of currently-playing intervals and is + * responsible for advancing them each frame as needed. + * + * There is normally only one IntervalManager object in the world, and it is + * the responsibility of the scripting language to call step() on this object + * once each frame, and to then process the events indicated by + * get_next_event(). + * + * It is also possible to create multiple IntervalManager objects for special + * needs. + */ class EXPCL_DIRECT CIntervalManager { PUBLISHED: CIntervalManager(); @@ -102,6 +98,3 @@ INLINE ostream &operator << (ostream &out, const CInterval &ival_mgr); #include "cIntervalManager.I" #endif - - - diff --git a/direct/src/interval/cLerpAnimEffectInterval.I b/direct/src/interval/cLerpAnimEffectInterval.I index 33d78a9693..cc9c42adf8 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.I +++ b/direct/src/interval/cLerpAnimEffectInterval.I @@ -1,52 +1,43 @@ -// Filename: cLerpAnimEffectInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpAnimEffectInterval.I + * @author drose + * @date 2002-08-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLerpAnimEffectInterval::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLerpAnimEffectInterval:: -CLerpAnimEffectInterval(const string &name, double duration, +CLerpAnimEffectInterval(const string &name, double duration, CLerpInterval::BlendType blend_type) : CLerpInterval(name, duration, blend_type) { } -//////////////////////////////////////////////////////////////////// -// Function: CLerpAnimEffectInterval::add_control -// Access: Published -// Description: Adds another AnimControl to the list of AnimControls -// affected by the lerp. This control will be lerped -// from begin_effect to end_effect over the period of -// the lerp. -// -// The AnimControl name parameter is only used when -// formatting the interval for output. -//////////////////////////////////////////////////////////////////// +/** + * Adds another AnimControl to the list of AnimControls affected by the lerp. + * This control will be lerped from begin_effect to end_effect over the period + * of the lerp. + * + * The AnimControl name parameter is only used when formatting the interval + * for output. + */ INLINE void CLerpAnimEffectInterval:: add_control(AnimControl *control, const string &name, float begin_effect, float end_effect) { _controls.push_back(ControlDef(control, name, begin_effect, end_effect)); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpAnimEffectInterval::ControlDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLerpAnimEffectInterval::ControlDef:: ControlDef(AnimControl *control, const string &name, float begin_effect, float end_effect) : diff --git a/direct/src/interval/cLerpAnimEffectInterval.cxx b/direct/src/interval/cLerpAnimEffectInterval.cxx index 9873a0e13e..d91bf8612e 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.cxx +++ b/direct/src/interval/cLerpAnimEffectInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cLerpAnimEffectInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpAnimEffectInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "cLerpAnimEffectInterval.h" #include "lerp_helpers.h" @@ -18,13 +17,11 @@ TypeHandle CLerpAnimEffectInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLerpAnimEffectInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CLerpAnimEffectInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -42,11 +39,9 @@ priv_step(double t) { _curr_t = t; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpAnimEffectInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLerpAnimEffectInterval:: output(ostream &out) const { out << get_name() << ": "; diff --git a/direct/src/interval/cLerpAnimEffectInterval.h b/direct/src/interval/cLerpAnimEffectInterval.h index 6f3ed26914..8a4148baef 100644 --- a/direct/src/interval/cLerpAnimEffectInterval.h +++ b/direct/src/interval/cLerpAnimEffectInterval.h @@ -1,16 +1,15 @@ -// Filename: cLerpAnimEffectInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpAnimEffectInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CLERPANIMEFFECTINTERVAL_H #define CLERPANIMEFFECTINTERVAL_H @@ -21,20 +20,18 @@ #include "pointerTo.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : CLerpAnimEffectInterval -// Description : This interval lerps between different amounts of -// control effects for various AnimControls that might -// be playing on an actor. It's used to change the -// blending amount between multiple animations. -// -// The idea is to start all the animations playing -// first, then use a CLerpAnimEffectInterval to adjust -// the degree to which each animation affects the actor. -//////////////////////////////////////////////////////////////////// +/** + * This interval lerps between different amounts of control effects for + * various AnimControls that might be playing on an actor. It's used to + * change the blending amount between multiple animations. + * + * The idea is to start all the animations playing first, then use a + * CLerpAnimEffectInterval to adjust the degree to which each animation + * affects the actor. + */ class EXPCL_DIRECT CLerpAnimEffectInterval : public CLerpInterval { PUBLISHED: - INLINE CLerpAnimEffectInterval(const string &name, double duration, + INLINE CLerpAnimEffectInterval(const string &name, double duration, BlendType blend_type); INLINE void add_control(AnimControl *control, const string &name, @@ -54,10 +51,10 @@ private: float _begin_effect; float _end_effect; }; - + typedef pvector Controls; Controls _controls; - + public: static TypeHandle get_class_type() { @@ -80,4 +77,3 @@ private: #include "cLerpAnimEffectInterval.I" #endif - diff --git a/direct/src/interval/cLerpInterval.I b/direct/src/interval/cLerpInterval.I index b99ff41e9d..04b37b438a 100644 --- a/direct/src/interval/cLerpInterval.I +++ b/direct/src/interval/cLerpInterval.I @@ -1,38 +1,31 @@ -// Filename: cLerpInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpInterval.I + * @author drose + * @date 2002-08-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLerpInterval::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLerpInterval:: -CLerpInterval(const string &name, double duration, +CLerpInterval(const string &name, double duration, CLerpInterval::BlendType blend_type) : CInterval(name, duration, true), _blend_type(blend_type) { } -//////////////////////////////////////////////////////////////////// -// Function: CLerpInterval::get_blend_type -// Access: Published -// Description: Returns the blend type specified for the interval. -// This controls how the linear interpolation behaves -// near the beginning and end of the lerp period. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blend type specified for the interval. This controls how the + * linear interpolation behaves near the beginning and end of the lerp period. + */ INLINE CLerpInterval::BlendType CLerpInterval:: get_blend_type() const { return _blend_type; diff --git a/direct/src/interval/cLerpInterval.cxx b/direct/src/interval/cLerpInterval.cxx index b1b559866b..b1eec3a135 100644 --- a/direct/src/interval/cLerpInterval.cxx +++ b/direct/src/interval/cLerpInterval.cxx @@ -1,29 +1,25 @@ -// Filename: cLerpInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "cLerpInterval.h" #include "string_utils.h" TypeHandle CLerpInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLerpInterval::string_blend_type -// Access: Published, Static -// Description: Returns the BlendType enumerated value corresponding -// to the indicated string, or BT_invalid if the string -// doesn't match anything. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BlendType enumerated value corresponding to the indicated + * string, or BT_invalid if the string doesn't match anything. + */ CLerpInterval::BlendType CLerpInterval:: string_blend_type(const string &blend_type) { if (blend_type == "easeIn") { @@ -39,20 +35,17 @@ string_blend_type(const string &blend_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLerpInterval::compute_delta -// Access: Protected -// Description: Given a t value in the range [0, get_duration()], -// returns the corresponding delta value clamped to the -// range [0, 1], after scaling by duration and applying -// the blend type. -//////////////////////////////////////////////////////////////////// +/** + * Given a t value in the range [0, get_duration()], returns the corresponding + * delta value clamped to the range [0, 1], after scaling by duration and + * applying the blend type. + */ double CLerpInterval:: compute_delta(double t) const { double duration = get_duration(); if (duration == 0.0) { - // If duration is 0, the lerp works as a set. Thus, the delta is - // always 1.0, the terminating value. + // If duration is 0, the lerp works as a set. Thus, the delta is always + // 1.0, the terminating value. return 1.0; } t /= duration; diff --git a/direct/src/interval/cLerpInterval.h b/direct/src/interval/cLerpInterval.h index 1c8d322869..6a6abbe5c9 100644 --- a/direct/src/interval/cLerpInterval.h +++ b/direct/src/interval/cLerpInterval.h @@ -1,16 +1,15 @@ -// Filename: cLerpInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CLERPINTERVAL_H #define CLERPINTERVAL_H @@ -18,12 +17,10 @@ #include "directbase.h" #include "cInterval.h" -//////////////////////////////////////////////////////////////////// -// Class : CLerpInterval -// Description : The base class for a family of intervals that -// linearly interpolate one or more numeric values over -// time. -//////////////////////////////////////////////////////////////////// +/** + * The base class for a family of intervals that linearly interpolate one or + * more numeric values over time. + */ class EXPCL_DIRECT CLerpInterval : public CInterval { PUBLISHED: enum BlendType { @@ -35,7 +32,7 @@ PUBLISHED: }; public: - INLINE CLerpInterval(const string &name, double duration, + INLINE CLerpInterval(const string &name, double duration, BlendType blend_type); PUBLISHED: @@ -49,7 +46,7 @@ protected: private: BlendType _blend_type; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -71,4 +68,3 @@ private: #include "cLerpInterval.I" #endif - diff --git a/direct/src/interval/cLerpNodePathInterval.I b/direct/src/interval/cLerpNodePathInterval.I index 08e870fcaf..03c90753cb 100644 --- a/direct/src/interval/cLerpNodePathInterval.I +++ b/direct/src/interval/cLerpNodePathInterval.I @@ -1,50 +1,40 @@ -// Filename: cLerpNodePathInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpNodePathInterval.I + * @author drose + * @date 2002-08-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::get_node -// Access: Published -// Description: Returns the node being lerped. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node being lerped. + */ INLINE const NodePath &CLerpNodePathInterval:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::get_other -// Access: Published -// Description: Returns the "other" node, which the lerped node is -// being moved relative to. If this is an empty node -// path, the lerped node is being moved in its own -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "other" node, which the lerped node is being moved relative to. + * If this is an empty node path, the lerped node is being moved in its own + * coordinate system. + */ INLINE const NodePath &CLerpNodePathInterval:: get_other() const { return _other; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_pos -// Access: Published -// Description: Indicates the initial position of the lerped node. -// This is meaningful only if set_end_pos() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// position at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial position of the lerped node. This is meaningful only + * if set_end_pos() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual position at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_pos(const LVecBase3 &pos) { nassertv(!pos.is_nan()); @@ -52,15 +42,12 @@ set_start_pos(const LVecBase3 &pos) { _flags |= F_start_pos; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_pos -// Access: Published -// Description: Indicates that the position of the node should be -// lerped, and specifies the final position of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's position will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the position of the node should be lerped, and specifies the + * final position of the node. This should be called before + * priv_initialize(). If this is not called, the node's position will not be + * affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_pos(const LVecBase3 &pos) { nassertv(!pos.is_nan()); @@ -68,16 +55,12 @@ set_end_pos(const LVecBase3 &pos) { _flags |= F_end_pos; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_hpr -// Access: Published -// Description: Indicates the initial rotation of the lerped node. -// This is meaningful only if either set_end_hpr() or -// set_end_quat() is also called. This parameter is -// optional; if unspecified, the value will be taken -// from the node's actual rotation at the time the lerp -// is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial rotation of the lerped node. This is meaningful only + * if either set_end_hpr() or set_end_quat() is also called. This parameter + * is optional; if unspecified, the value will be taken from the node's actual + * rotation at the time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_hpr(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); @@ -85,17 +68,15 @@ set_start_hpr(const LVecBase3 &hpr) { _flags = (_flags & ~(F_slerp_setup | F_start_quat)) | F_start_hpr; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_hpr -// Access: Published -// Description: Indicates that the rotation of the node should be -// lerped, and specifies the final rotation of the node. -// This should be called before priv_initialize(). -// -// This replaces a previous call to set_end_quat(). If -// neither set_end_hpr() nor set_end_quat() is called, -// the node's rotation will not be affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the rotation of the node should be lerped, and specifies the + * final rotation of the node. This should be called before + * priv_initialize(). + * + * This replaces a previous call to set_end_quat(). If neither set_end_hpr() + * nor set_end_quat() is called, the node's rotation will not be affected by + * the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_hpr(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); @@ -103,19 +84,16 @@ set_end_hpr(const LVecBase3 &hpr) { _flags = (_flags & ~F_end_quat) | F_end_hpr; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_hpr -// Access: Published -// Description: Indicates that the rotation of the node should be -// lerped, and specifies the final rotation of the node. -// This should be called before priv_initialize(). -// -// This special function is overloaded to accept a -// quaternion, even though the function name is -// set_end_hpr(). The quaternion will be implicitly -// converted to a HPR trio, and the lerp will be -// performed in HPR space, componentwise. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the rotation of the node should be lerped, and specifies the + * final rotation of the node. This should be called before + * priv_initialize(). + * + * This special function is overloaded to accept a quaternion, even though the + * function name is set_end_hpr(). The quaternion will be implicitly + * converted to a HPR trio, and the lerp will be performed in HPR space, + * componentwise. + */ INLINE void CLerpNodePathInterval:: set_end_hpr(const LQuaternion &quat) { nassertv(!quat.is_nan()); @@ -123,16 +101,12 @@ set_end_hpr(const LQuaternion &quat) { _flags = (_flags & ~F_end_quat) | F_end_hpr; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_quat -// Access: Published -// Description: Indicates the initial rotation of the lerped node. -// This is meaningful only if either set_end_quat() or -// set_end_hpr() is also called. This parameter is -// optional; if unspecified, the value will be taken -// from the node's actual rotation at the time the lerp -// is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial rotation of the lerped node. This is meaningful only + * if either set_end_quat() or set_end_hpr() is also called. This parameter + * is optional; if unspecified, the value will be taken from the node's actual + * rotation at the time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_quat(const LQuaternion &quat) { nassertv(!quat.is_nan()); @@ -140,23 +114,20 @@ set_start_quat(const LQuaternion &quat) { _flags = (_flags & ~(F_slerp_setup | F_start_hpr)) | F_start_quat; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_quat -// Access: Published -// Description: Indicates that the rotation of the node should be -// lerped, and specifies the final rotation of the node. -// This should be called before priv_initialize(). -// -// This replaces a previous call to set_end_hpr(). If -// neither set_end_quat() nor set_end_hpr() is called, -// the node's rotation will not be affected by the lerp. -// -// This special function is overloaded to accept a HPR -// trio, even though the function name is -// set_end_quat(). The HPR will be implicitly converted -// to a quaternion, and the lerp will be performed in -// quaternion space, as a spherical lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the rotation of the node should be lerped, and specifies the + * final rotation of the node. This should be called before + * priv_initialize(). + * + * This replaces a previous call to set_end_hpr(). If neither set_end_quat() + * nor set_end_hpr() is called, the node's rotation will not be affected by + * the lerp. + * + * This special function is overloaded to accept a HPR trio, even though the + * function name is set_end_quat(). The HPR will be implicitly converted to a + * quaternion, and the lerp will be performed in quaternion space, as a + * spherical lerp. + */ INLINE void CLerpNodePathInterval:: set_end_quat(const LVecBase3 &hpr) { nassertv(!hpr.is_nan()); @@ -164,17 +135,15 @@ set_end_quat(const LVecBase3 &hpr) { _flags = (_flags & ~(F_slerp_setup | F_end_hpr)) | F_end_quat; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_quat -// Access: Published -// Description: Indicates that the rotation of the node should be -// lerped, and specifies the final rotation of the node. -// This should be called before priv_initialize(). -// -// This replaces a previous call to set_end_hpr(). If -// neither set_end_quat() nor set_end_hpr() is called, -// the node's rotation will not be affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the rotation of the node should be lerped, and specifies the + * final rotation of the node. This should be called before + * priv_initialize(). + * + * This replaces a previous call to set_end_hpr(). If neither set_end_quat() + * nor set_end_hpr() is called, the node's rotation will not be affected by + * the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_quat(const LQuaternion &quat) { nassertv(!quat.is_nan()); @@ -182,15 +151,12 @@ set_end_quat(const LQuaternion &quat) { _flags = (_flags & ~(F_slerp_setup | F_end_hpr)) | F_end_quat; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_scale -// Access: Published -// Description: Indicates the initial scale of the lerped node. -// This is meaningful only if set_end_scale() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// scale at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial scale of the lerped node. This is meaningful only if + * set_end_scale() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual scale at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_scale(const LVecBase3 &scale) { nassertv(!scale.is_nan()); @@ -198,30 +164,23 @@ set_start_scale(const LVecBase3 &scale) { _flags |= F_start_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_scale -// Access: Published -// Description: Indicates the initial scale of the lerped node. -// This is meaningful only if set_end_scale() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// scale at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial scale of the lerped node. This is meaningful only if + * set_end_scale() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual scale at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_scale(PN_stdfloat scale) { nassertv(!cnan(scale)); set_start_scale(LVecBase3(scale, scale, scale)); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_scale -// Access: Published -// Description: Indicates that the scale of the node should be -// lerped, and specifies the final scale of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's scale will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the scale of the node should be lerped, and specifies the + * final scale of the node. This should be called before priv_initialize(). + * If this is not called, the node's scale will not be affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_scale(const LVecBase3 &scale) { nassertv(!scale.is_nan()); @@ -229,30 +188,23 @@ set_end_scale(const LVecBase3 &scale) { _flags |= F_end_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_scale -// Access: Published -// Description: Indicates that the scale of the node should be -// lerped, and specifies the final scale of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's scale will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the scale of the node should be lerped, and specifies the + * final scale of the node. This should be called before priv_initialize(). + * If this is not called, the node's scale will not be affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_scale(PN_stdfloat scale) { nassertv(!cnan(scale)); set_end_scale(LVecBase3(scale, scale, scale)); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_shear -// Access: Published -// Description: Indicates the initial shear of the lerped node. -// This is meaningful only if set_end_shear() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// shear at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial shear of the lerped node. This is meaningful only if + * set_end_shear() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual shear at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_shear(const LVecBase3 &shear) { nassertv(!shear.is_nan()); @@ -260,15 +212,11 @@ set_start_shear(const LVecBase3 &shear) { _flags |= F_start_shear; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_shear -// Access: Published -// Description: Indicates that the shear of the node should be -// lerped, and specifies the final shear of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's shear will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the shear of the node should be lerped, and specifies the + * final shear of the node. This should be called before priv_initialize(). + * If this is not called, the node's shear will not be affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_shear(const LVecBase3 &shear) { nassertv(!shear.is_nan()); @@ -276,15 +224,12 @@ set_end_shear(const LVecBase3 &shear) { _flags |= F_end_shear; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_color -// Access: Published -// Description: Indicates the initial color of the lerped node. -// This is meaningful only if set_end_color() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// color at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial color of the lerped node. This is meaningful only if + * set_end_color() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual color at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_color(const LVecBase4 &color) { nassertv(!color.is_nan()); @@ -292,15 +237,11 @@ set_start_color(const LVecBase4 &color) { _flags |= F_start_color; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_color -// Access: Published -// Description: Indicates that the color of the node should be -// lerped, and specifies the final color of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's color will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the color of the node should be lerped, and specifies the + * final color of the node. This should be called before priv_initialize(). + * If this is not called, the node's color will not be affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_color(const LVecBase4 &color) { nassertv(!color.is_nan()); @@ -308,15 +249,12 @@ set_end_color(const LVecBase4 &color) { _flags |= F_end_color; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_color_scale -// Access: Published -// Description: Indicates the initial color scale of the lerped node. -// This is meaningful only if set_end_color_scale() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// color scale at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial color scale of the lerped node. This is meaningful + * only if set_end_color_scale() is also called. This parameter is optional; + * if unspecified, the value will be taken from the node's actual color scale + * at the time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_color_scale(const LVecBase4 &color_scale) { nassertv(!color_scale.is_nan()); @@ -324,15 +262,12 @@ set_start_color_scale(const LVecBase4 &color_scale) { _flags |= F_start_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_color_scale -// Access: Published -// Description: Indicates that the color scale of the node should be -// lerped, and specifies the final color scale of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's color scale will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the color scale of the node should be lerped, and specifies + * the final color scale of the node. This should be called before + * priv_initialize(). If this is not called, the node's color scale will not + * be affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_color_scale(const LVecBase4 &color_scale) { nassertv(!color_scale.is_nan()); @@ -340,27 +275,22 @@ set_end_color_scale(const LVecBase4 &color_scale) { _flags |= F_end_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_texture_stage -// Access: Published -// Description: Indicates the texture stage that is adjusted by -// tex_offset, tex_rotate, and/or tex_scale. If this is -// not set, the default is the default texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the texture stage that is adjusted by tex_offset, tex_rotate, + * and/or tex_scale. If this is not set, the default is the default texture + * stage. + */ INLINE void CLerpNodePathInterval:: set_texture_stage(TextureStage *stage) { _texture_stage = stage; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_tex_offset -// Access: Published -// Description: Indicates the initial UV offset of the lerped node. -// This is meaningful only if set_end_tex_offset() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// UV offset at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial UV offset of the lerped node. This is meaningful + * only if set_end_tex_offset() is also called. This parameter is optional; + * if unspecified, the value will be taken from the node's actual UV offset at + * the time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_tex_offset(const LVecBase2 &tex_offset) { nassertv(!tex_offset.is_nan()); @@ -368,15 +298,12 @@ set_start_tex_offset(const LVecBase2 &tex_offset) { _flags |= F_start_tex_offset; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_tex_offset -// Access: Published -// Description: Indicates that the UV offset of the node should be -// lerped, and specifies the final UV offset of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's UV offset will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the UV offset of the node should be lerped, and specifies + * the final UV offset of the node. This should be called before + * priv_initialize(). If this is not called, the node's UV offset will not be + * affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_tex_offset(const LVecBase2 &tex_offset) { nassertv(!tex_offset.is_nan()); @@ -384,15 +311,12 @@ set_end_tex_offset(const LVecBase2 &tex_offset) { _flags |= F_end_tex_offset; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_tex_rotate -// Access: Published -// Description: Indicates the initial UV rotate of the lerped node. -// This is meaningful only if set_end_tex_rotate() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// UV rotate at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial UV rotate of the lerped node. This is meaningful + * only if set_end_tex_rotate() is also called. This parameter is optional; + * if unspecified, the value will be taken from the node's actual UV rotate at + * the time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_tex_rotate(PN_stdfloat tex_rotate) { nassertv(!cnan(tex_rotate)); @@ -400,15 +324,12 @@ set_start_tex_rotate(PN_stdfloat tex_rotate) { _flags |= F_start_tex_rotate; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_tex_rotate -// Access: Published -// Description: Indicates that the UV rotate of the node should be -// lerped, and specifies the final UV rotate of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's UV rotate will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the UV rotate of the node should be lerped, and specifies + * the final UV rotate of the node. This should be called before + * priv_initialize(). If this is not called, the node's UV rotate will not be + * affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_tex_rotate(PN_stdfloat tex_rotate) { nassertv(!cnan(tex_rotate)); @@ -416,15 +337,12 @@ set_end_tex_rotate(PN_stdfloat tex_rotate) { _flags |= F_end_tex_rotate; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_start_tex_scale -// Access: Published -// Description: Indicates the initial UV scale of the lerped node. -// This is meaningful only if set_end_tex_scale() is also -// called. This parameter is optional; if unspecified, -// the value will be taken from the node's actual -// UV scale at the time the lerp is performed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the initial UV scale of the lerped node. This is meaningful only + * if set_end_tex_scale() is also called. This parameter is optional; if + * unspecified, the value will be taken from the node's actual UV scale at the + * time the lerp is performed. + */ INLINE void CLerpNodePathInterval:: set_start_tex_scale(const LVecBase2 &tex_scale) { nassertv(!tex_scale.is_nan()); @@ -432,15 +350,12 @@ set_start_tex_scale(const LVecBase2 &tex_scale) { _flags |= F_start_tex_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_end_tex_scale -// Access: Published -// Description: Indicates that the UV scale of the node should be -// lerped, and specifies the final UV scale of the node. -// This should be called before priv_initialize(). If this -// is not called, the node's UV scale will not be -// affected by the lerp. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the UV scale of the node should be lerped, and specifies the + * final UV scale of the node. This should be called before + * priv_initialize(). If this is not called, the node's UV scale will not be + * affected by the lerp. + */ INLINE void CLerpNodePathInterval:: set_end_tex_scale(const LVecBase2 &tex_scale) { nassertv(!tex_scale.is_nan()); @@ -448,28 +363,22 @@ set_end_tex_scale(const LVecBase2 &tex_scale) { _flags |= F_end_tex_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::set_override -// Access: Published -// Description: Changes the override value that will be associated -// with any state changes applied by the lerp. If this -// lerp is changing state (for instance, a color lerp or -// a tex matrix lerp), then the new attributes created -// by this lerp will be assigned the indicated override -// value when they are applied to the node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the override value that will be associated with any state changes + * applied by the lerp. If this lerp is changing state (for instance, a color + * lerp or a tex matrix lerp), then the new attributes created by this lerp + * will be assigned the indicated override value when they are applied to the + * node. + */ INLINE void CLerpNodePathInterval:: set_override(int override) { _override = override; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::get_override -// Access: Published -// Description: Returns the override value that will be associated -// with any state changes applied by the lerp. See -// set_override(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the override value that will be associated with any state changes + * applied by the lerp. See set_override(). + */ INLINE int CLerpNodePathInterval:: get_override() const { return _override; diff --git a/direct/src/interval/cLerpNodePathInterval.cxx b/direct/src/interval/cLerpNodePathInterval.cxx index 4eb3dbdcda..8c9423106f 100644 --- a/direct/src/interval/cLerpNodePathInterval.cxx +++ b/direct/src/interval/cLerpNodePathInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cLerpNodePathInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpNodePathInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "cLerpNodePathInterval.h" #include "lerp_helpers.h" @@ -24,39 +23,31 @@ TypeHandle CLerpNodePathInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::Constructor -// Access: Published -// Description: Constructs a lerp interval that will lerp some -// properties on the indicated node, possibly relative -// to the indicated other node (if other is nonempty). -// -// You must call set_end_pos(), etc. for the various -// properties you wish to lerp before the first call to -// priv_initialize(). If you want to set a starting value -// for any of the properties, you may call -// set_start_pos(), etc.; otherwise, the starting value -// is taken from the actual node's value at the time the -// lerp is performed. -// -// The starting values may be explicitly specified or -// omitted. The value of bake_in_start determines the -// behavior if the starting values are omitted. If -// bake_in_start is true, the values are obtained the -// first time the lerp runs, and thenceforth are stored -// within the interval. If bake_in_start is false, the -// starting value is computed each frame, based on -// assuming the current value represents the value set -// from the last time the interval was run. This -// "smart" behavior allows code to manipulate the object -// event while it is being lerped, and the lerp -// continues to apply in a sensible way. -// -// If fluid is true, the prev_transform is not adjusted -// by the lerp; otherwise, it is reset. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a lerp interval that will lerp some properties on the indicated + * node, possibly relative to the indicated other node (if other is nonempty). + * + * You must call set_end_pos(), etc. for the various properties you wish to + * lerp before the first call to priv_initialize(). If you want to set a + * starting value for any of the properties, you may call set_start_pos(), + * etc.; otherwise, the starting value is taken from the actual node's value + * at the time the lerp is performed. + * + * The starting values may be explicitly specified or omitted. The value of + * bake_in_start determines the behavior if the starting values are omitted. + * If bake_in_start is true, the values are obtained the first time the lerp + * runs, and thenceforth are stored within the interval. If bake_in_start is + * false, the starting value is computed each frame, based on assuming the + * current value represents the value set from the last time the interval was + * run. This "smart" behavior allows code to manipulate the object event + * while it is being lerped, and the lerp continues to apply in a sensible + * way. + * + * If fluid is true, the prev_transform is not adjusted by the lerp; + * otherwise, it is reset. + */ CLerpNodePathInterval:: -CLerpNodePathInterval(const string &name, double duration, +CLerpNodePathInterval(const string &name, double duration, CLerpInterval::BlendType blend_type, bool bake_in_start, bool fluid, const NodePath &node, const NodePath &other) : @@ -77,14 +68,11 @@ CLerpNodePathInterval(const string &name, double duration, _prev_d = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::initialize -// Access: Published, Virtual -// Description: This replaces the first call to priv_step(), and indicates -// that the interval has just begun. This may be -// overridden by derived classes that need to do some -// explicit initialization on the first call. -//////////////////////////////////////////////////////////////////// +/** + * This replaces the first call to priv_step(), and indicates that the + * interval has just begun. This may be overridden by derived classes that + * need to do some explicit initialization on the first call. + */ void CLerpNodePathInterval:: priv_initialize(double t) { check_stopped(get_class_type(), "priv_initialize"); @@ -94,14 +82,11 @@ priv_initialize(double t) { priv_step(t); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_initialize() .. priv_step() -// .. priv_finalize(), when everything is to happen within -// one frame. The interval should initialize itself, -// then leave itself in the final state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_initialize() .. priv_step() .. + * priv_finalize(), when everything is to happen within one frame. The + * interval should initialize itself, then leave itself in the final state. + */ void CLerpNodePathInterval:: priv_instant() { check_stopped(get_class_type(), "priv_instant"); @@ -112,13 +97,11 @@ priv_instant() { _state = S_final; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CLerpNodePathInterval:: priv_step(double t) { check_started(get_class_type(), "priv_step"); @@ -136,11 +119,11 @@ priv_step(double t) { // If there is no other node, it's a local transform lerp. transform = _node.get_transform(); } else { - // If there *is* another node, we get the transform relative to - // that node. + // If there *is* another node, we get the transform relative to that + // node. transform = _node.get_transform(_other); } - + LPoint3 pos; LVecBase3 hpr; LQuaternion quat; @@ -203,8 +186,8 @@ priv_step(double t) { } setup_slerp(); - // In this case, clear the slerp_setup flag because we need - // to re-setup the slerp each time. + // In this case, clear the slerp_setup flag because we need to re- + // setup the slerp each time. _flags &= ~F_slerp_setup; } } @@ -238,11 +221,10 @@ priv_step(double t) { } } - // Now apply the modifications back to the transform. We want to - // be a little careful here, because we don't want to assume the - // transform has hpr/scale components if they're not needed. And - // in any case, we only want to apply the components that we - // computed, above. + // Now apply the modifications back to the transform. We want to be a + // little careful here, because we don't want to assume the transform has + // hprscale components if they're not needed. And in any case, we only + // want to apply the components that we computed, above. unsigned int transform_flags = _flags & (F_end_pos | F_end_hpr | F_end_quat | F_end_scale); switch (transform_flags) { case 0: @@ -387,8 +369,8 @@ priv_step(double t) { if ((_flags & F_fluid) != 0) { // If we have the fluid flag set, we shouldn't mess with the prev - // transform. Therefore, restore it to what it was before we - // started messing with it. + // transform. Therefore, restore it to what it was before we started + // messing with it. _node.set_prev_transform(prev_transform); } @@ -397,19 +379,19 @@ priv_step(double t) { CPT(RenderState) state; if (_other.is_empty()) { - // If there is no other node, it's a local state lerp. This is - // most common. + // If there is no other node, it's a local state lerp. This is most + // common. state = _node.get_state(); } else { - // If there *is* another node, we get the state relative to that - // node. This is weird, but you could lerp color (for instance) - // relative to some other node's color. + // If there *is* another node, we get the state relative to that node. + // This is weird, but you could lerp color (for instance) relative to + // some other node's color. state = _node.get_state(_other); } - - // Unlike in the transform case above, we can go ahead and modify - // the state immediately with each attribute change, since these - // attributes don't interrelate. + + // Unlike in the transform case above, we can go ahead and modify the + // state immediately with each attribute change, since these attributes + // don't interrelate. if ((_flags & F_end_color) != 0) { LColor color; @@ -455,7 +437,7 @@ priv_step(double t) { } state = state->add_attrib(ColorScaleAttrib::make(color_scale), _override); - } + } if ((_flags & (F_end_tex_offset | F_end_tex_rotate | F_end_tex_scale)) != 0) { // We have a UV lerp. @@ -478,7 +460,7 @@ priv_step(double t) { lerp_value(tex_offset, d, _start_tex_offset, _end_tex_offset); } else { tex_offset = transform->get_pos2d(); - lerp_value_from_prev(tex_offset, d, _prev_d, tex_offset, + lerp_value_from_prev(tex_offset, d, _prev_d, tex_offset, _end_tex_offset); } @@ -492,7 +474,7 @@ priv_step(double t) { lerp_value(tex_rotate, d, _start_tex_rotate, _end_tex_rotate); } else { tex_rotate = transform->get_rotate2d(); - lerp_value_from_prev(tex_rotate, d, _prev_d, tex_rotate, + lerp_value_from_prev(tex_rotate, d, _prev_d, tex_rotate, _end_tex_rotate); } @@ -506,7 +488,7 @@ priv_step(double t) { lerp_value(tex_scale, d, _start_tex_scale, _end_tex_scale); } else { tex_scale = transform->get_scale2d(); - lerp_value_from_prev(tex_scale, d, _prev_d, tex_scale, + lerp_value_from_prev(tex_scale, d, _prev_d, tex_scale, _end_tex_scale); } @@ -515,7 +497,7 @@ priv_step(double t) { // Apply the modified transform back to the state. state = state->set_attrib(tma->add_stage(_texture_stage, transform, _override)); - } + } // Now apply the new state back to the node. @@ -528,14 +510,11 @@ priv_step(double t) { _curr_t = t; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::reverse_initialize -// Access: Published, Virtual -// Description: Similar to priv_initialize(), but this is called when the -// interval is being played backwards; it indicates that -// the interval should start at the finishing state and -// undo any intervening intervals. -//////////////////////////////////////////////////////////////////// +/** + * Similar to priv_initialize(), but this is called when the interval is being + * played backwards; it indicates that the interval should start at the + * finishing state and undo any intervening intervals. + */ void CLerpNodePathInterval:: priv_reverse_initialize(double t) { check_stopped(get_class_type(), "priv_reverse_initialize"); @@ -545,15 +524,12 @@ priv_reverse_initialize(double t) { priv_step(t); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::reverse_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_reverse_initialize() -// .. priv_step() .. priv_reverse_finalize(), when everything is -// to happen within one frame. The interval should -// initialize itself, then leave itself in the initial -// state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_reverse_initialize() .. priv_step() .. + * priv_reverse_finalize(), when everything is to happen within one frame. + * The interval should initialize itself, then leave itself in the initial + * state. + */ void CLerpNodePathInterval:: priv_reverse_instant() { check_stopped(get_class_type(), "priv_reverse_initialize"); @@ -564,11 +540,9 @@ priv_reverse_instant() { _state = S_initial; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLerpNodePathInterval:: output(ostream &out) const { out << get_name() << ":"; @@ -632,14 +606,11 @@ output(ostream &out) const { out << " dur " << get_duration(); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::setup_slerp -// Access: Private -// Description: Sets up a spherical lerp from _start_quat to -// _end_quat. This precomputes some important values -// (like the angle between the quaternions) and sets up -// the _slerp method pointer. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a spherical lerp from _start_quat to _end_quat. This precomputes + * some important values (like the angle between the quaternions) and sets up + * the _slerp method pointer. + */ void CLerpNodePathInterval:: setup_slerp() { if (_start_quat.dot(_end_quat) < 0.0f) { @@ -650,31 +621,29 @@ setup_slerp() { _slerp_angle = _start_quat.angle_rad(_end_quat); if (_slerp_angle < 0.1f) { - // If the angle is small, use sin(angle)/angle as the denominator, - // to provide better behavior with small divisors. This is Don - // Hatch's suggestion from http://www.hadron.org/~hatch/rightway.php . + // If the angle is small, use sin(angle)angle as the denominator, to + // provide better behavior with small divisors. This is Don Hatch's + // suggestion from http:www.hadron.org~hatchrightway.php . _slerp_denom = csin_over_x(_slerp_angle); _slerp = &CLerpNodePathInterval::slerp_angle_0; } else if (_slerp_angle > 3.14) { - // If the angle is close to 180 degrees, the lerp is ambiguous. - // which plane should we lerp through? Better pick an - // intermediate point to resolve the ambiguity up front. + // If the angle is close to 180 degrees, the lerp is ambiguous. which + // plane should we lerp through? Better pick an intermediate point to + // resolve the ambiguity up front. - // We pick it by choosing a linear point between the quats and - // normalizing it out; this will give an arbitrary point when the - // angle is exactly 180, but will behave sanely as the angle - // approaches 180. + // We pick it by choosing a linear point between the quats and normalizing + // it out; this will give an arbitrary point when the angle is exactly + // 180, but will behave sanely as the angle approaches 180. _slerp_c = (_start_quat + _end_quat); _slerp_c.normalize(); _slerp_angle = _end_quat.angle_rad(_slerp_c); _slerp_denom = csin(_slerp_angle); _slerp = &CLerpNodePathInterval::slerp_angle_180; - + } else { - // Otherwise, use the original Shoemake equation for spherical - // lerp. + // Otherwise, use the original Shoemake equation for spherical lerp. _slerp_denom = csin(_slerp_angle); _slerp = &CLerpNodePathInterval::slerp_basic; } @@ -683,13 +652,11 @@ setup_slerp() { _flags |= F_slerp_setup; } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::slerp_basic -// Access: Private -// Description: Implements Ken Shoemake's spherical lerp equation. -// This is appropriate when the angle between the -// quaternions is not near one extreme or the other. -//////////////////////////////////////////////////////////////////// +/** + * Implements Ken Shoemake's spherical lerp equation. This is appropriate + * when the angle between the quaternions is not near one extreme or the + * other. + */ void CLerpNodePathInterval:: slerp_basic(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); @@ -708,13 +675,10 @@ slerp_basic(LQuaternion &result, PN_stdfloat t) const { nassertv(!result.is_nan()); } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::slerp_angle_0 -// Access: Private -// Description: Implements Don Hatch's modified spherical lerp -// equation, appropriate for when the angle between the -// quaternions approaches zero. -//////////////////////////////////////////////////////////////////// +/** + * Implements Don Hatch's modified spherical lerp equation, appropriate for + * when the angle between the quaternions approaches zero. + */ void CLerpNodePathInterval:: slerp_angle_0(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); @@ -734,13 +698,11 @@ slerp_angle_0(LQuaternion &result, PN_stdfloat t) const { } -//////////////////////////////////////////////////////////////////// -// Function: CLerpNodePathInterval::slerp_angle_180 -// Access: Private -// Description: Implements a two-part slerp, to an intermediate point -// and out again, appropriate for when the angle between -// the quaternions approaches 180 degrees. -//////////////////////////////////////////////////////////////////// +/** + * Implements a two-part slerp, to an intermediate point and out again, + * appropriate for when the angle between the quaternions approaches 180 + * degrees. + */ void CLerpNodePathInterval:: slerp_angle_180(LQuaternion &result, PN_stdfloat t) const { nassertv(_slerp_denom != 0.0f); @@ -757,10 +719,10 @@ slerp_angle_180(LQuaternion &result, PN_stdfloat t) const { interval_cat.spam() << "slerp_angle_180, first half (t = " << t << "), angle = " << _slerp_angle << "\n_start_quat = " << _start_quat - << ", _slerp_c = " << _slerp_c << ", denom = " + << ", _slerp_c = " << _slerp_c << ", denom = " << _slerp_denom << "\n"; } - + result = (csin(tia) * _start_quat + csin(ta) * _slerp_c) / _slerp_denom; } else { @@ -775,10 +737,10 @@ slerp_angle_180(LQuaternion &result, PN_stdfloat t) const { interval_cat.spam() << "slerp_angle_180, second half (t = " << t << "), angle = " << _slerp_angle << "\n_slerp_c = " << _slerp_c - << ", _end_quat = " << _end_quat << ", denom = " + << ", _end_quat = " << _end_quat << ", denom = " << _slerp_denom << "\n"; } - + result = (csin(tia) * _slerp_c + csin(ta) * _end_quat) / _slerp_denom; } diff --git a/direct/src/interval/cLerpNodePathInterval.h b/direct/src/interval/cLerpNodePathInterval.h index eeef2cf12b..06b09deb3b 100644 --- a/direct/src/interval/cLerpNodePathInterval.h +++ b/direct/src/interval/cLerpNodePathInterval.h @@ -1,16 +1,15 @@ -// Filename: cLerpNodePathInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLerpNodePathInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CLERPNODEPATHINTERVAL_H #define CLERPNODEPATHINTERVAL_H @@ -20,14 +19,13 @@ #include "nodePath.h" #include "textureStage.h" -//////////////////////////////////////////////////////////////////// -// Class : CLerpNodePathInterval -// Description : An interval that lerps one or more properties (like -// pos, hpr, etc.) on a NodePath over time. -//////////////////////////////////////////////////////////////////// +/** + * An interval that lerps one or more properties (like pos, hpr, etc.) on a + * NodePath over time. + */ class EXPCL_DIRECT CLerpNodePathInterval : public CLerpInterval { PUBLISHED: - CLerpNodePathInterval(const string &name, double duration, + CLerpNodePathInterval(const string &name, double duration, BlendType blend_type, bool bake_in_start, bool fluid, const NodePath &node, const NodePath &other); @@ -103,10 +101,10 @@ private: F_fluid = 0x10000000, F_bake_in_start = 0x20000000, - + F_slerp_setup = 0x40000000, }; - + unsigned int _flags; LPoint3 _start_pos, _end_pos; LVecBase3 _start_hpr, _end_hpr; @@ -132,7 +130,7 @@ private: // Define a pointer to one of the above three methods. void (CLerpNodePathInterval::*_slerp)(LQuaternion &result, PN_stdfloat t) const; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -154,4 +152,3 @@ private: #include "cLerpNodePathInterval.I" #endif - diff --git a/direct/src/interval/cMetaInterval.I b/direct/src/interval/cMetaInterval.I index 72b0359bb1..ae30cd9792 100644 --- a/direct/src/interval/cMetaInterval.I +++ b/direct/src/interval/cMetaInterval.I @@ -1,78 +1,61 @@ -// Filename: cMetaInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cMetaInterval.I + * @author drose + * @date 2002-08-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::set_precision -// Access: Published -// Description: Indicates the precision with which time measurements -// are compared. For numerical accuracy, all -// floating-point time values are converted to integer -// values internally by scaling by the precision factor. -// The larger the number given here, the smaller the -// delta of time that can be differentiated; the -// limit is the maximum integer that can be represented -// in the system. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the precision with which time measurements are compared. For + * numerical accuracy, all floating-point time values are converted to integer + * values internally by scaling by the precision factor. The larger the + * number given here, the smaller the delta of time that can be + * differentiated; the limit is the maximum integer that can be represented in + * the system. + */ INLINE void CMetaInterval:: set_precision(double precision) { _precision = precision; mark_dirty(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_precision -// Access: Published -// Description: Returns the precision with which time measurements -// are compared. See set_precision(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the precision with which time measurements are compared. See + * set_precision(). + */ INLINE double CMetaInterval:: get_precision() const { return _precision; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_num_defs -// Access: Published -// Description: Returns the number of interval and push/pop -// definitions that have been added to the meta -// interval. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of interval and push/pop definitions that have been + * added to the meta interval. + */ INLINE int CMetaInterval:: get_num_defs() const { return (int)_defs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_def_type -// Access: Published -// Description: Returns the type of the nth interval definition that -// has been added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the nth interval definition that has been added. + */ INLINE CMetaInterval::DefType CMetaInterval:: get_def_type(int n) const { nassertr(n >= 0 && n < (int)_defs.size(), DT_c_interval); return _defs[n]._type; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_c_interval -// Access: Published -// Description: Return the CInterval pointer associated with the nth -// interval definition. It is only valid to call this -// if get_def_type(n) returns DT_c_interval. -//////////////////////////////////////////////////////////////////// +/** + * Return the CInterval pointer associated with the nth interval definition. + * It is only valid to call this if get_def_type(n) returns DT_c_interval. + */ INLINE CInterval *CMetaInterval:: get_c_interval(int n) const { nassertr(n >= 0 && n < (int)_defs.size(), NULL); @@ -80,13 +63,11 @@ get_c_interval(int n) const { return _defs[n]._c_interval; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_ext_index -// Access: Published -// Description: Return the external interval index number associated -// with the nth interval definition. It is only valid -// to call this if get_def_type(n) returns DT_ext_index. -//////////////////////////////////////////////////////////////////// +/** + * Return the external interval index number associated with the nth interval + * definition. It is only valid to call this if get_def_type(n) returns + * DT_ext_index. + */ INLINE int CMetaInterval:: get_ext_index(int n) const { nassertr(n >= 0 && n < (int)_defs.size(), -1); @@ -94,28 +75,22 @@ get_ext_index(int n) const { return _defs[n]._ext_index; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::is_event_ready -// Access: Published -// Description: Returns true if a recent call to priv_initialize(), -// priv_step(), or priv_finalize() has left some external -// intervals ready to play. If this returns true, call -// get_event_index(), get_event_t(), and pop_event() to -// retrieve the relevant information. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a recent call to priv_initialize(), priv_step(), or + * priv_finalize() has left some external intervals ready to play. If this + * returns true, call get_event_index(), get_event_t(), and pop_event() to + * retrieve the relevant information. + */ INLINE bool CMetaInterval:: is_event_ready() { return service_event_queue(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_event_index -// Access: Published -// Description: If a previous call to is_event_ready() returned -// true, this returns the index number (added via -// add_event_index()) of the external interval that needs -// to be played. -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to is_event_ready() returned true, this returns the + * index number (added via add_event_index()) of the external interval that + * needs to be played. + */ INLINE int CMetaInterval:: get_event_index() const { nassertr(!_event_queue.empty(), -1); @@ -125,63 +100,50 @@ get_event_index() const { return def._ext_index; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_event_t -// Access: Published -// Description: If a previous call to is_event_ready() returned -// true, this returns the t value that should be fed to -// the given interval. -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to is_event_ready() returned true, this returns the t + * value that should be fed to the given interval. + */ INLINE double CMetaInterval:: get_event_t() const { nassertr(!_event_queue.empty(), 0.0f); return int_to_double_time(_event_queue.front()._time); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_event_type -// Access: Published -// Description: If a previous call to is_event_ready() returned -// true, this returns the type of the event (initialize, -// step, finalize, etc.) for the given interval. -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to is_event_ready() returned true, this returns the type + * of the event (initialize, step, finalize, etc.) for the given interval. + */ INLINE CInterval::EventType CMetaInterval:: get_event_type() const { nassertr(!_event_queue.empty(), ET_step); return _event_queue.front()._event_type; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::double_to_int_time -// Access: Private -// Description: Converts from an external double time value or offset -// in seconds to an internal integer value or offset. -//////////////////////////////////////////////////////////////////// +/** + * Converts from an external double time value or offset in seconds to an + * internal integer value or offset. + */ INLINE int CMetaInterval:: double_to_int_time(double t) const { // Use floor() just in case there are negative values involved. return (int)floor(t * _precision + 0.5); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::int_to_double_time -// Access: Private -// Description: Converts from an internal integer time value or -// offset to an external double time value or offset in -// seconds. -//////////////////////////////////////////////////////////////////// +/** + * Converts from an internal integer time value or offset to an external + * double time value or offset in seconds. + */ INLINE double CMetaInterval:: int_to_double_time(int time) const { return (double)time / _precision; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::PlaybackEvent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CMetaInterval::PlaybackEvent:: -PlaybackEvent(int time, int n, +PlaybackEvent(int time, int n, CMetaInterval::PlaybackEventType type) : _time(time), _n(n), @@ -190,21 +152,17 @@ PlaybackEvent(int time, int n, _begin_event = this; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::PlaybackEvent::Ordering operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CMetaInterval::PlaybackEvent:: operator < (const CMetaInterval::PlaybackEvent &other) const { return _time < other._time; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::EventQueueEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CMetaInterval::EventQueueEntry:: EventQueueEntry(int n, CInterval::EventType event_type, int time) : _n(n), diff --git a/direct/src/interval/cMetaInterval.cxx b/direct/src/interval/cMetaInterval.cxx index 2329c2cf54..dd5f1386f2 100644 --- a/direct/src/interval/cMetaInterval.cxx +++ b/direct/src/interval/cMetaInterval.cxx @@ -1,16 +1,15 @@ -// Filename: cMetaInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cMetaInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "cMetaInterval.h" #include "waitInterval.h" @@ -24,11 +23,9 @@ TypeHandle CMetaInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CMetaInterval:: CMetaInterval(const string &name) : CInterval(name, 0.0, true) @@ -39,26 +36,21 @@ CMetaInterval(const string &name) : _processing_events = false; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CMetaInterval:: ~CMetaInterval() { clear_intervals(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::clear_intervals -// Access: Published -// Description: Resets the list of intervals and prepares for -// receiving a new list. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of intervals and prepares for receiving a new list. + */ void CMetaInterval:: clear_intervals() { - // Better not do this unless you have serviced all of the - // outstanding events! + // Better not do this unless you have serviced all of the outstanding + // events! bool lost_events = false; if (!_event_queue.empty()) { interval_cat.warning() @@ -69,13 +61,13 @@ clear_intervals() { clear_events(); - // Go through all of our nested intervals and remove ourselves as - // their parent. + // Go through all of our nested intervals and remove ourselves as their + // parent. Defs::iterator di; for (di = _defs.begin(); di != _defs.end(); ++di) { IntervalDef &def = (*di); if (def._c_interval != (CInterval *)NULL) { - CInterval::Parents::iterator pi = + CInterval::Parents::iterator pi = find(def._c_interval->_parents.begin(), def._c_interval->_parents.end(), this); @@ -95,18 +87,14 @@ clear_intervals() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::push_level -// Access: Published -// Description: Marks the beginning of a nested level of child -// intervals. Within the nested level, a RelativeStart -// time of RS_level_begin refers to the start of the -// level, and the first interval added within the level -// is always relative to the start of the level. -// -// The return value is the index of the def entry -// created by this push. -//////////////////////////////////////////////////////////////////// +/** + * Marks the beginning of a nested level of child intervals. Within the + * nested level, a RelativeStart time of RS_level_begin refers to the start of + * the level, and the first interval added within the level is always relative + * to the start of the level. + * + * The return value is the index of the def entry created by this push. + */ int CMetaInterval:: push_level(const string &name, double rel_time, RelativeStart rel_to) { nassertr(_event_queue.empty() && !_processing_events, -1); @@ -123,18 +111,15 @@ push_level(const string &name, double rel_time, RelativeStart rel_to) { return (int)_defs.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::add_c_interval -// Access: Published -// Description: Adds a new CInterval to the list. The interval will -// be played when the indicated time (relative to the -// given point) has been reached. -// -// The return value is the index of the def entry -// representing the new interval. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new CInterval to the list. The interval will be played when the + * indicated time (relative to the given point) has been reached. + * + * The return value is the index of the def entry representing the new + * interval. + */ int CMetaInterval:: -add_c_interval(CInterval *c_interval, +add_c_interval(CInterval *c_interval, double rel_time, RelativeStart rel_to) { nassertr(_event_queue.empty() && !_processing_events, -1); nassertr(c_interval != (CInterval *)NULL, -1); @@ -152,28 +137,22 @@ add_c_interval(CInterval *c_interval, return (int)_defs.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::add_ext_index -// Access: Published -// Description: Adds a new external interval to the list. This -// represents some object in the external scripting -// language that has properties similar to a CInterval -// (for instance, a Python Interval object). -// -// The CMetaInterval object cannot play this external -// interval directly, but it records a placeholder for -// it and will ask the scripting language to play it -// when it is time, via is_event_ready() and related -// methods. -// -// The ext_index number itself is simply a handle that -// the scripting language makes up and associates with -// its interval object somehow. The CMetaInterval -// object does not attempt to interpret this value. -// -// The return value is the index of the def entry -// representing the new interval. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new external interval to the list. This represents some object in + * the external scripting language that has properties similar to a CInterval + * (for instance, a Python Interval object). + * + * The CMetaInterval object cannot play this external interval directly, but + * it records a placeholder for it and will ask the scripting language to play + * it when it is time, via is_event_ready() and related methods. + * + * The ext_index number itself is simply a handle that the scripting language + * makes up and associates with its interval object somehow. The + * CMetaInterval object does not attempt to interpret this value. + * + * The return value is the index of the def entry representing the new + * interval. + */ int CMetaInterval:: add_ext_index(int ext_index, const string &name, double duration, bool open_ended, @@ -194,18 +173,14 @@ add_ext_index(int ext_index, const string &name, double duration, return (int)_defs.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::pop_level -// Access: Published -// Description: Finishes a level marked by a previous call to -// push_level(), and returns to the previous level. -// -// If the duration is not negative, it represents a -// phony duration to assign to the level, for the -// purposes of sequencing later intervals. Otherwise, -// the level's duration is computed based on the -// intervals within the level. -//////////////////////////////////////////////////////////////////// +/** + * Finishes a level marked by a previous call to push_level(), and returns to + * the previous level. + * + * If the duration is not negative, it represents a phony duration to assign + * to the level, for the purposes of sequencing later intervals. Otherwise, + * the level's duration is computed based on the intervals within the level. + */ int CMetaInterval:: pop_level(double duration) { nassertr(_event_queue.empty() && !_processing_events, -1); @@ -221,21 +196,15 @@ pop_level(double duration) { return (int)_defs.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::set_interval_start_time -// Access: Published -// Description: Adjusts the start time of the child interval with the -// given name, if found. This may be either a C++ -// interval added via add_c_interval(), or an external -// interval added via add_ext_index(); the name must -// match exactly. -// -// If the interval is found, its start time is adjusted, -// and all subsequent intervals are adjusting -// accordingly, and true is returned. If a matching -// interval is not found, nothing is changed and false -// is returned. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the start time of the child interval with the given name, if found. + * This may be either a C++ interval added via add_c_interval(), or an + * external interval added via add_ext_index(); the name must match exactly. + * + * If the interval is found, its start time is adjusted, and all subsequent + * intervals are adjusting accordingly, and true is returned. If a matching + * interval is not found, nothing is changed and false is returned. + */ bool CMetaInterval:: set_interval_start_time(const string &name, double rel_time, CMetaInterval::RelativeStart rel_to) { @@ -269,14 +238,11 @@ set_interval_start_time(const string &name, double rel_time, return false; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_interval_start_time -// Access: Published -// Description: Returns the actual start time, relative to the -// beginning of the interval, of the child interval with -// the given name, if found, or -1 if the interval is -// not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual start time, relative to the beginning of the interval, + * of the child interval with the given name, if found, or -1 if the interval + * is not found. + */ double CMetaInterval:: get_interval_start_time(const string &name) const { recompute(); @@ -306,14 +272,11 @@ get_interval_start_time(const string &name) const { return -1.0; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_interval_end_time -// Access: Published -// Description: Returns the actual end time, relative to the -// beginning of the interval, of the child interval with -// the given name, if found, or -1 if the interval is -// not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual end time, relative to the beginning of the interval, of + * the child interval with the given name, if found, or -1 if the interval is + * not found. + */ double CMetaInterval:: get_interval_end_time(const string &name) const { recompute(); @@ -346,14 +309,11 @@ get_interval_end_time(const string &name) const { return -1.0; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::initialize -// Access: Published, Virtual -// Description: This replaces the first call to priv_step(), and indicates -// that the interval has just begun. This may be -// overridden by derived classes that need to do some -// explicit initialization on the first call. -//////////////////////////////////////////////////////////////////// +/** + * This replaces the first call to priv_step(), and indicates that the + * interval has just begun. This may be overridden by derived classes that + * need to do some explicit initialization on the first call. + */ void CMetaInterval:: priv_initialize(double t) { if (_processing_events) { @@ -362,10 +322,9 @@ priv_initialize(double t) { } check_stopped(get_class_type(), "priv_initialize"); - // It may be tempting to flush the event_queue here, but don't do - // it. Those are events that must still be serviced from some - // previous interval operation. Throwing them away would be a - // mistake. + // It may be tempting to flush the event_queue here, but don't do it. Those + // are events that must still be serviced from some previous interval + // operation. Throwing them away would be a mistake. recompute(); _next_event_index = 0; @@ -374,10 +333,10 @@ priv_initialize(double t) { int now = double_to_int_time(t); /* - // One special case: if we step to t == 0.0, it really means to the - // very beginning of the interval, *before* any events that occurred - // at time 0. (Most of the time, stepping to a particular time - // means *after* any events that occurred at that time.) + // One special case: if we step to t == 0.0, it really means to the very + // beginning of the interval, *before* any events that occurred at time 0. + // (Most of the time, stepping to a particular time means *after* any events + // that occurred at that time.) if (t == 0.0) { now = -1; } @@ -390,7 +349,7 @@ priv_initialize(double t) { _events[_next_event_index]->_time <= now) { PlaybackEvent *event = _events[_next_event_index]; _next_event_index++; - + // Do the indicated event. do_event_forward(event, new_active, true); } @@ -401,14 +360,11 @@ priv_initialize(double t) { _state = S_started; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_initialize() .. priv_step() -// .. priv_finalize(), when everything is to happen within -// one frame. The interval should initialize itself, -// then leave itself in the final state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_initialize() .. priv_step() .. + * priv_finalize(), when everything is to happen within one frame. The + * interval should initialize itself, then leave itself in the final state. + */ void CMetaInterval:: priv_instant() { if (_processing_events) { @@ -420,8 +376,8 @@ priv_instant() { recompute(); _active.clear(); - // Apply all of the events. This just means we invoke "instant" for - // any end or instant event, ignoring the begin events. + // Apply all of the events. This just means we invoke "instant" for any end + // or instant event, ignoring the begin events. _processing_events = true; PlaybackEvents::iterator ei; for (ei = _events.begin(); ei != _events.end(); ++ei) { @@ -443,13 +399,11 @@ priv_instant() { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void CMetaInterval:: priv_step(double t) { if (_processing_events) { @@ -461,17 +415,16 @@ priv_step(double t) { int now = double_to_int_time(t); /* - // One special case: if we step to t == 0.0, it really means to the - // very beginning of the interval, *before* any events that occurred - // at time 0. (Most of the time, stepping to a particular time - // means *after* any events that occurred at that time.) + // One special case: if we step to t == 0.0, it really means to the very + // beginning of the interval, *before* any events that occurred at time 0. + // (Most of the time, stepping to a particular time means *after* any events + // that occurred at that time.) if (t == 0.0) { now = -1; } */ - // Now look for events between the last time we ran and the current - // time. + // Now look for events between the last time we ran and the current time. _processing_events = true; if (_next_event_index < _events.size() && @@ -492,7 +445,7 @@ priv_step(double t) { } else { // A less usual case: time is decreasing. ActiveEvents new_active; - while (_next_event_index > 0 && + while (_next_event_index > 0 && _events[_next_event_index - 1]->_time > now) { _next_event_index--; PlaybackEvent *event = _events[_next_event_index]; @@ -508,13 +461,11 @@ priv_step(double t) { _state = S_started; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::finalize -// Access: Published, Virtual -// Description: This is called when an interval is interrupted. It -// should advance the time as if priv_step() were called, and -// also perform whatever cleanup might be required. -//////////////////////////////////////////////////////////////////// +/** + * This is called when an interval is interrupted. It should advance the time + * as if priv_step() were called, and also perform whatever cleanup might be + * required. + */ void CMetaInterval:: priv_finalize() { if (_processing_events) { @@ -550,14 +501,11 @@ priv_finalize() { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::reverse_initialize -// Access: Published, Virtual -// Description: Similar to priv_initialize(), but this is called when the -// interval is being played backwards; it indicates that -// the interval should start at the finishing state and -// undo any intervening intervals. -//////////////////////////////////////////////////////////////////// +/** + * Similar to priv_initialize(), but this is called when the interval is being + * played backwards; it indicates that the interval should start at the + * finishing state and undo any intervening intervals. + */ void CMetaInterval:: priv_reverse_initialize(double t) { if (_processing_events) { @@ -566,10 +514,9 @@ priv_reverse_initialize(double t) { } check_stopped(get_class_type(), "priv_reverse_initialize"); - // It may be tempting to flush the event_queue here, but don't do - // it. Those are events that must still be serviced from some - // previous interval operation. Throwing them away would be a - // mistake. + // It may be tempting to flush the event_queue here, but don't do it. Those + // are events that must still be serviced from some previous interval + // operation. Throwing them away would be a mistake. recompute(); _next_event_index = _events.size(); @@ -578,10 +525,10 @@ priv_reverse_initialize(double t) { int now = double_to_int_time(t); /* - // One special case: if we step to t == 0.0, it really means to the - // very beginning of the interval, *before* any events that occurred - // at time 0. (Most of the time, stepping to a particular time - // means *after* any events that occurred at that time.) + // One special case: if we step to t == 0.0, it really means to the very + // beginning of the interval, *before* any events that occurred at time 0. + // (Most of the time, stepping to a particular time means *after* any events + // that occurred at that time.) if (t == 0.0) { now = -1; } @@ -590,11 +537,11 @@ priv_reverse_initialize(double t) { // Now look for events from the end down to the current time. _processing_events = true; ActiveEvents new_active; - while (_next_event_index > 0 && + while (_next_event_index > 0 && _events[_next_event_index - 1]->_time > now) { _next_event_index--; PlaybackEvent *event = _events[_next_event_index]; - + // Do the indicated event. do_event_reverse(event, new_active, true); } @@ -605,15 +552,12 @@ priv_reverse_initialize(double t) { _state = S_started; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::reverse_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_reverse_initialize() -// .. priv_step() .. priv_reverse_finalize(), when everything is -// to happen within one frame. The interval should -// initialize itself, then leave itself in the initial -// state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_reverse_initialize() .. priv_step() .. + * priv_reverse_finalize(), when everything is to happen within one frame. + * The interval should initialize itself, then leave itself in the initial + * state. + */ void CMetaInterval:: priv_reverse_instant() { if (_processing_events) { @@ -625,8 +569,8 @@ priv_reverse_instant() { recompute(); _active.clear(); - // Apply all of the events. This just means we invoke "instant" for - // any end or instant event, ignoring the begin events. + // Apply all of the events. This just means we invoke "instant" for any end + // or instant event, ignoring the begin events. _processing_events = true; PlaybackEvents::reverse_iterator ei; for (ei = _events.rbegin(); ei != _events.rend(); ++ei) { @@ -642,13 +586,10 @@ priv_reverse_instant() { _state = S_initial; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::reverse_finalize -// Access: Published, Virtual -// Description: Called generally following a priv_reverse_initialize(), -// this indicates the interval should set itself to the -// initial state. -//////////////////////////////////////////////////////////////////// +/** + * Called generally following a priv_reverse_initialize(), this indicates the + * interval should set itself to the initial state. + */ void CMetaInterval:: priv_reverse_finalize() { if (_processing_events) { @@ -677,20 +618,16 @@ priv_reverse_finalize() { _state = S_initial; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::interrupt -// Access: Published, Virtual -// Description: This is called while the interval is playing to -// indicate that it is about to be interrupted; that is, -// priv_step() will not be called for a length of time. But -// the interval should remain in its current state in -// anticipation of being eventually restarted when the -// calls to priv_step() eventually resume. -// -// The purpose of this function is to allow self-running -// intervals like sound intervals to stop the actual -// sound playback during the pause. -//////////////////////////////////////////////////////////////////// +/** + * This is called while the interval is playing to indicate that it is about + * to be interrupted; that is, priv_step() will not be called for a length of + * time. But the interval should remain in its current state in anticipation + * of being eventually restarted when the calls to priv_step() eventually + * resume. + * + * The purpose of this function is to allow self-running intervals like sound + * intervals to stop the actual sound playback during the pause. + */ void CMetaInterval:: priv_interrupt() { if (_processing_events) { @@ -711,16 +648,12 @@ priv_interrupt() { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::pop_event -// Access: Published -// Description: Acknowledges that the external interval on the top of -// the queue has been extracted, and is about to be -// serviced by the scripting language. This prepares -// the interval so the next call to is_event_ready() -// will return information about the next external -// interval on the queue, if any. -//////////////////////////////////////////////////////////////////// +/** + * Acknowledges that the external interval on the top of the queue has been + * extracted, and is about to be serviced by the scripting language. This + * prepares the interval so the next call to is_event_ready() will return + * information about the next external interval on the queue, if any. + */ void CMetaInterval:: pop_event() { #ifndef NDEBUG @@ -732,11 +665,9 @@ pop_event() { _event_queue.pop_front(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CMetaInterval:: write(ostream &out, int indent_level) const { recompute(); @@ -763,12 +694,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::timeline -// Access: Published -// Description: Outputs a list of all events in the order in which -// they occur. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of all events in the order in which they occur. + */ void CMetaInterval:: timeline(ostream &out) const { recompute(); @@ -810,12 +738,10 @@ timeline(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::do_recompute -// Access: Protected, Virtual -// Description: Recomputes all of the events (and the duration) -// according to the set of interval defs. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all of the events (and the duration) according to the set of + * interval defs. + */ void CMetaInterval:: do_recompute() { _dirty = false; @@ -828,18 +754,15 @@ do_recompute() { << "CMetaInterval pushes don't match pops.\n"; } - // We do a stable_sort() to guarantee ordering of events that have - // the same start time. These must be invoked in the order in which - // they appear. + // We do a stable_sort() to guarantee ordering of events that have the same + // start time. These must be invoked in the order in which they appear. stable_sort(_events.begin(), _events.end(), IndirectLess()); _duration = int_to_double_time(_end_time); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::clear_events -// Access: Private -// Description: Removes all entries from the _events list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all entries from the _events list. + */ void CMetaInterval:: clear_events() { PlaybackEvents::iterator ei; @@ -851,37 +774,33 @@ clear_events() { _active.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::do_event_forward -// Access: Private -// Description: Process a single event in the interval, moving -// forwards in time. If the event represents a new -// begin, adds it to the new_active list; if it is an -// end, finalizes it. -// -// If is_initial is true, it is as if we are in -// initialize or finalize: instant events will be -// invoked only if they are marked open_ended. -//////////////////////////////////////////////////////////////////// +/** + * Process a single event in the interval, moving forwards in time. If the + * event represents a new begin, adds it to the new_active list; if it is an + * end, finalizes it. + * + * If is_initial is true, it is as if we are in initialize or finalize: + * instant events will be invoked only if they are marked open_ended. + */ void CMetaInterval:: -do_event_forward(CMetaInterval::PlaybackEvent *event, +do_event_forward(CMetaInterval::PlaybackEvent *event, CMetaInterval::ActiveEvents &new_active, bool is_initial) { switch (event->_type) { case PET_begin: nassertv(event->_begin_event == event); new_active.push_back(event); break; - + case PET_end: { - // Erase the event from either the new active or the current - // active lists. + // Erase the event from either the new active or the current active + // lists. ActiveEvents::iterator ai; ai = find(new_active.begin(), new_active.end(), event->_begin_event); if (ai != new_active.end()) { new_active.erase(ai); - // This interval was new this frame; we must invoke it as - // an instant event. + // This interval was new this frame; we must invoke it as an instant + // event. enqueue_event(event->_n, ET_instant, is_initial); } else { @@ -891,8 +810,8 @@ do_event_forward(CMetaInterval::PlaybackEvent *event, enqueue_event(event->_n, ET_finalize, is_initial); } else { - // Hmm, this event wasn't on either list. Maybe there was a - // start event on the list whose time was less than 0. + // Hmm, this event wasn't on either list. Maybe there was a start + // event on the list whose time was less than 0. interval_cat.error() << "Event " << event->_begin_event->_n << " not on active list.\n"; nassertv(false); @@ -900,7 +819,7 @@ do_event_forward(CMetaInterval::PlaybackEvent *event, } } break; - + case PET_instant: nassertv(event->_begin_event == event); enqueue_event(event->_n, ET_instant, is_initial); @@ -908,15 +827,12 @@ do_event_forward(CMetaInterval::PlaybackEvent *event, } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::finish_events_forward -// Access: Private -// Description: After walking through the event list and adding a -// bunch of new events to new_active, finished up by -// calling priv_step() on all of the events still in _active -// and priv_initialize() on all the events in new_active, -// then copying the events from new_active to active. -//////////////////////////////////////////////////////////////////// +/** + * After walking through the event list and adding a bunch of new events to + * new_active, finished up by calling priv_step() on all of the events still + * in _active and priv_initialize() on all the events in new_active, then + * copying the events from new_active to active. + */ void CMetaInterval:: finish_events_forward(int now, CMetaInterval::ActiveEvents &new_active) { // Do whatever's still active. @@ -925,7 +841,7 @@ finish_events_forward(int now, CMetaInterval::ActiveEvents &new_active) { PlaybackEvent *event = (*ai); enqueue_event(event->_n, ET_step, false, now - event->_time); } - + // Initialize whatever new intervals we came across. for (ai = new_active.begin(); ai != new_active.end(); ++ai) { PlaybackEvent *event = (*ai); @@ -934,35 +850,30 @@ finish_events_forward(int now, CMetaInterval::ActiveEvents &new_active) { } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::do_event_reverse -// Access: Private -// Description: Process a single event in the interval, moving -// backwards in time. This undoes the indicated event. -// If the event represents a new begin, adds it to the -// new_active list; if it is an end, finalizes it. -// -// If is_initial is true, it is as if we are in -// reverse_initialize or reverse_finalize: instant -// events will be invoked only if they are marked -// open_ended. -//////////////////////////////////////////////////////////////////// +/** + * Process a single event in the interval, moving backwards in time. This + * undoes the indicated event. If the event represents a new begin, adds it + * to the new_active list; if it is an end, finalizes it. + * + * If is_initial is true, it is as if we are in reverse_initialize or + * reverse_finalize: instant events will be invoked only if they are marked + * open_ended. + */ void CMetaInterval:: -do_event_reverse(CMetaInterval::PlaybackEvent *event, +do_event_reverse(CMetaInterval::PlaybackEvent *event, CMetaInterval::ActiveEvents &new_active, bool is_initial) { // Undo the indicated event. switch (event->_type) { case PET_begin: { nassertv(event->_begin_event == event); - // Erase the event from either the new active or the current - // active lists. + // Erase the event from either the new active or the current active + // lists. ActiveEvents::iterator ai; ai = find(new_active.begin(), new_active.end(), event); if (ai != new_active.end()) { new_active.erase(ai); - // This interval was new this frame; we invoke it as an - // instant event. + // This interval was new this frame; we invoke it as an instant event. enqueue_event(event->_n, ET_reverse_instant, is_initial); } else { @@ -972,9 +883,8 @@ do_event_reverse(CMetaInterval::PlaybackEvent *event, enqueue_event(event->_n, ET_reverse_finalize, is_initial); } else { - // Hmm, this event wasn't on either list. Maybe there was a - // stop event on the list whose time was greater than the - // total, somehow. + // Hmm, this event wasn't on either list. Maybe there was a stop + // event on the list whose time was greater than the total, somehow. interval_cat.error() << "Event " << event->_n << " not on active list.\n"; nassertv(false); @@ -982,11 +892,11 @@ do_event_reverse(CMetaInterval::PlaybackEvent *event, } } break; - + case PET_end: new_active.push_front(event->_begin_event); break; - + case PET_instant: nassertv(event->_begin_event == event); enqueue_event(event->_n, ET_reverse_instant, is_initial); @@ -994,16 +904,12 @@ do_event_reverse(CMetaInterval::PlaybackEvent *event, } } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::finish_events_reverse -// Access: Private -// Description: After walking through the event list and adding a -// bunch of new events to new_active, finishes up by -// calling priv_step() on all of the events still in _active -// and priv_reverse_initialize() on all the events in -// new_active, then copying the events from new_active -// to active. -//////////////////////////////////////////////////////////////////// +/** + * After walking through the event list and adding a bunch of new events to + * new_active, finishes up by calling priv_step() on all of the events still + * in _active and priv_reverse_initialize() on all the events in new_active, + * then copying the events from new_active to active. + */ void CMetaInterval:: finish_events_reverse(int now, CMetaInterval::ActiveEvents &new_active) { // Do whatever's still active. @@ -1012,7 +918,7 @@ finish_events_reverse(int now, CMetaInterval::ActiveEvents &new_active) { PlaybackEvent *event = (*ai); enqueue_event(event->_n, ET_step, false, now - event->_time); } - + // Initialize whatever new intervals we came across. for (ai = new_active.begin(); ai != new_active.end(); ++ai) { PlaybackEvent *event = (*ai); @@ -1020,23 +926,19 @@ finish_events_reverse(int now, CMetaInterval::ActiveEvents &new_active) { _active.push_front(event); } } - -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::enqueue_event -// Access: Private -// Description: Enqueues the indicated interval for invocation after -// we have finished scanning for events that need -// processing this frame. -// -// is_initial is only relevant for event types -// ET_instant or ET_reverse_instant, and indicates -// whether we are in the priv_initialize() (or -// priv_reverse_initialize()) call, and should therefore only -// invoke open-ended intervals. -// -// time is only relevant for ET_initialize, -// ET_reverse_initialize, and ET_step. -//////////////////////////////////////////////////////////////////// + +/** + * Enqueues the indicated interval for invocation after we have finished + * scanning for events that need processing this frame. + * + * is_initial is only relevant for event types ET_instant or + * ET_reverse_instant, and indicates whether we are in the priv_initialize() + * (or priv_reverse_initialize()) call, and should therefore only invoke open- + * ended intervals. + * + * time is only relevant for ET_initialize, ET_reverse_initialize, and + * ET_step. + */ void CMetaInterval:: enqueue_event(int n, CInterval::EventType event_type, bool is_initial, int time) { nassertv(n >= 0 && n < (int)_defs.size()); @@ -1046,15 +948,14 @@ enqueue_event(int n, CInterval::EventType event_type, bool is_initial, int time) if (is_initial && (event_type == ET_instant || event_type == ET_reverse_instant) && !def._c_interval->get_open_ended()) { - // Ignore a non-open-ended interval that we skipped completely - // past on priv_initialize(). + // Ignore a non-open-ended interval that we skipped completely past on + // priv_initialize(). return; } else { if (_event_queue.empty()) { - // if the event queue is empty, we can process this C++ - // interval immediately. We only need to defer it if there - // are external (e.g. Python) intervals in the queue that need - // to be processed first. + // if the event queue is empty, we can process this C++ interval + // immediately. We only need to defer it if there are external (e.g. + // Python) intervals in the queue that need to be processed first. def._c_interval->priv_do_event(int_to_double_time(time), event_type); return; } @@ -1065,8 +966,8 @@ enqueue_event(int n, CInterval::EventType event_type, bool is_initial, int time) if (is_initial && (event_type == ET_instant || event_type == ET_reverse_instant) && !def._ext_open_ended) { - // Ignore a non-open-ended interval that we skipped completely - // past on priv_initialize(). + // Ignore a non-open-ended interval that we skipped completely past on + // priv_initialize(). return; } break; @@ -1079,17 +980,14 @@ enqueue_event(int n, CInterval::EventType event_type, bool is_initial, int time) _event_queue.push_back(EventQueueEntry(n, event_type, time)); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::enqueue_self_event -// Access: Private -// Description: Enqueues a reference to *this* interval. This is -// called only when the interval is recursively -// re-entered; the request will be serviced when the -// current request is done processing. -// -// time is only relevant for ET_initialize, -// ET_reverse_initialize, and ET_step. -//////////////////////////////////////////////////////////////////// +/** + * Enqueues a reference to *this* interval. This is called only when the + * interval is recursively re-entered; the request will be serviced when the + * current request is done processing. + * + * time is only relevant for ET_initialize, ET_reverse_initialize, and + * ET_step. + */ void CMetaInterval:: enqueue_self_event(CInterval::EventType event_type, double t) { interval_cat.info() @@ -1098,29 +996,22 @@ enqueue_self_event(CInterval::EventType event_type, double t) { _event_queue.push_back(EventQueueEntry(-1, event_type, time)); } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::enqueue_done_event -// Access: Private -// Description: Enqueues a special "event" that simply marks the end -// of processing of the interval; the interval's done -// event should be thrown now, if it is defined. -//////////////////////////////////////////////////////////////////// +/** + * Enqueues a special "event" that simply marks the end of processing of the + * interval; the interval's done event should be thrown now, if it is defined. + */ void CMetaInterval:: enqueue_done_event() { _event_queue.push_back(EventQueueEntry(-2, ET_finalize, 0)); } - -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::service_event_queue -// Access: Private -// Description: Invokes whatever C++ intervals might be at the head -// of the queue, and prepares for passing an external -// interval to the scripting language. -// -// The return value is true if there remains at least -// one external event to be serviced, false if all -// events are handled. -//////////////////////////////////////////////////////////////////// + +/** + * Invokes whatever C++ intervals might be at the head of the queue, and + * prepares for passing an external interval to the scripting language. + * + * The return value is true if there remains at least one external event to be + * serviced, false if all events are handled. + */ bool CMetaInterval:: service_event_queue() { while (!_event_queue.empty()) { @@ -1131,8 +1022,8 @@ service_event_queue() { priv_do_event(int_to_double_time(entry._time), entry._event_type); } else if (entry._n == -2) { - // Index -2 is a special code to indicate the interval is now - // done, and its done event should be thrown. + // Index -2 is a special code to indicate the interval is now done, and + // its done event should be thrown. interval_done(); } else { @@ -1143,11 +1034,11 @@ service_event_queue() { // Handle the C++ event. def._c_interval->priv_do_event(int_to_double_time(entry._time), entry._event_type); break; - + case DT_ext_index: // Here's an external event; leave it there and return. return true; - + default: nassertr(false, false); return false; @@ -1161,21 +1052,17 @@ service_event_queue() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::recompute_level -// Access: Private -// Description: Recursively recomputes a complete level (delimited by -// push/pop definitions). -// -// The value n on entry refers to the first entry after -// the push; the return value will reference the -// matching pop, or an index greater than the last -// element in the array if there was no matching pop. -// -// The level_begin value indicates the begin time of -// this level. On return, level_end is filled with the -// end time of this level. -//////////////////////////////////////////////////////////////////// +/** + * Recursively recomputes a complete level (delimited by push/pop + * definitions). + * + * The value n on entry refers to the first entry after the push; the return + * value will reference the matching pop, or an index greater than the last + * element in the array if there was no matching pop. + * + * The level_begin value indicates the begin time of this level. On return, + * level_end is filled with the end time of this level. + */ int CMetaInterval:: recompute_level(int n, int level_begin, int &level_end) { level_end = level_begin; @@ -1193,8 +1080,8 @@ recompute_level(int n, int level_begin, int &level_end) { end_time = begin_time + double_to_int_time(def._c_interval->get_duration()); if (def._c_interval->is_exact_type(WaitInterval::get_class_type())) { - // Don't bother enqueuing events for WaitIntervals; they're - // just there to fill up time. + // Don't bother enqueuing events for WaitIntervals; they're just there + // to fill up time. } else { if (begin_time == end_time) { @@ -1248,21 +1135,18 @@ recompute_level(int n, int level_begin, int &level_end) { level_end = level_begin + double_to_int_time(def._ext_duration); } - // The final pop "begins" at the level end time, just for clarity - // on output. + // The final pop "begins" at the level end time, just for clarity on + // output. def._actual_begin_time = level_end; } return n; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::get_begin_time -// Access: Private -// Description: Returns the integer begin time indicated by the given -// IntervalDef, given the indicated level begin, -// previous begin, and previous end times. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer begin time indicated by the given IntervalDef, given + * the indicated level begin, previous begin, and previous end times. + */ int CMetaInterval:: get_begin_time(const CMetaInterval::IntervalDef &def, int level_begin, int previous_begin, int previous_end) { @@ -1281,14 +1165,11 @@ get_begin_time(const CMetaInterval::IntervalDef &def, int level_begin, return previous_end; } -//////////////////////////////////////////////////////////////////// -// Function: CMetaInterval::write_event_desc -// Access: Private -// Description: Formats an event for output, for write() or -// timeline(). -//////////////////////////////////////////////////////////////////// +/** + * Formats an event for output, for write() or timeline(). + */ void CMetaInterval:: -write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, +write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, int &extra_indent_level) const { switch (def._type) { case DT_c_interval: @@ -1299,7 +1180,7 @@ write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, } out << "\n"; break; - + case DT_ext_index: indent(out, extra_indent_level) << "*" << def._ext_name; @@ -1311,13 +1192,13 @@ write_event_desc(ostream &out, const CMetaInterval::IntervalDef &def, } out<< "\n"; break; - + case DT_push_level: indent(out, extra_indent_level) << def._ext_name << " {\n"; extra_indent_level += 2; break; - + case DT_pop_level: extra_indent_level -= 2; indent(out, extra_indent_level) diff --git a/direct/src/interval/cMetaInterval.h b/direct/src/interval/cMetaInterval.h index 0af6b827f0..4f4e246045 100644 --- a/direct/src/interval/cMetaInterval.h +++ b/direct/src/interval/cMetaInterval.h @@ -1,16 +1,15 @@ -// Filename: cMetaInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cMetaInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CMETAINTERVAL_H #define CMETAINTERVAL_H @@ -25,12 +24,11 @@ #include "pset.h" #include -//////////////////////////////////////////////////////////////////// -// Class : CMetaInterval -// Description : This interval contains a list of nested intervals, -// each of which has its own begin and end times. Some -// of them may overlap and some of them may not. -//////////////////////////////////////////////////////////////////// +/** + * This interval contains a list of nested intervals, each of which has its + * own begin and end times. Some of them may overlap and some of them may + * not. + */ class EXPCL_DIRECT CMetaInterval : public CInterval { PUBLISHED: CMetaInterval(const string &name); @@ -48,15 +46,15 @@ PUBLISHED: void clear_intervals(); int push_level(const string &name, double rel_time, RelativeStart rel_to); - int add_c_interval(CInterval *c_interval, - double rel_time = 0.0f, + int add_c_interval(CInterval *c_interval, + double rel_time = 0.0f, RelativeStart rel_to = RS_previous_end); int add_ext_index(int ext_index, const string &name, double duration, bool open_ended, double rel_time, RelativeStart rel_to); int pop_level(double duration = -1.0); - bool set_interval_start_time(const string &name, double rel_time, + bool set_interval_start_time(const string &name, double rel_time, RelativeStart rel_to = RS_level_begin); double get_interval_start_time(const string &name) const; double get_interval_end_time(const string &name) const; @@ -134,9 +132,9 @@ private: typedef pvector Defs; typedef pvector PlaybackEvents; - // ActiveEvents must be either a list or a vector--something that - // preserves order--so we can call priv_step() on the currently - // active intervals in the order they were encountered. + // ActiveEvents must be either a list or a vector--something that preserves + // order--so we can call priv_step() on the currently active intervals in + // the order they were encountered. typedef plist ActiveEvents; typedef pdeque EventQueue; @@ -161,7 +159,7 @@ private: int get_begin_time(const IntervalDef &def, int level_begin, int previous_begin, int previous_end); - void write_event_desc(ostream &out, const IntervalDef &def, + void write_event_desc(ostream &out, const IntervalDef &def, int &extra_indent_level) const; @@ -178,12 +176,11 @@ private: // This is the queue of events that have occurred due to a recent // priv_initialize(), priv_step(), etc., but have not yet been serviced, due - // to an embedded external (e.g. Python) interval that the scripting - // language must service. This queue should be considered precious, - // and should never be arbitrarily flushed without servicing all of - // its events. + // to an embedded external (e.g. Python) interval that the scripting + // language must service. This queue should be considered precious, and + // should never be arbitrarily flushed without servicing all of its events. EventQueue _event_queue; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -205,4 +202,3 @@ private: #include "cMetaInterval.I" #endif - diff --git a/direct/src/interval/config_interval.cxx b/direct/src/interval/config_interval.cxx index 00e8a844b3..d88711c8b9 100644 --- a/direct/src/interval/config_interval.cxx +++ b/direct/src/interval/config_interval.cxx @@ -1,16 +1,15 @@ -// Filename: config_interval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_interval.cxx + * @author drose + * @date 2002-08-27 + */ #include "config_interval.h" #include "cInterval.h" @@ -48,14 +47,12 @@ ConfigVariableBool verify_intervals "functions are called out-of-order.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libinterval -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libinterval() { static bool initialized = false; @@ -83,4 +80,3 @@ init_libinterval() { EaseInOutBlendType::init_type(); NoBlendType::init_type(); } - diff --git a/direct/src/interval/config_interval.h b/direct/src/interval/config_interval.h index 5c4af0bf33..8695f4b140 100644 --- a/direct/src/interval/config_interval.h +++ b/direct/src/interval/config_interval.h @@ -1,16 +1,15 @@ -// Filename: config_interval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_interval.h + * @author drose + * @date 2002-08-27 + */ #ifndef CONFIG_INTERVAL_H #define CONFIG_INTERVAL_H diff --git a/direct/src/interval/hideInterval.I b/direct/src/interval/hideInterval.I index 5427808d5f..296c04c791 100644 --- a/direct/src/interval/hideInterval.I +++ b/direct/src/interval/hideInterval.I @@ -1,14 +1,12 @@ -// Filename: hideInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hideInterval.I + * @author drose + * @date 2002-08-27 + */ diff --git a/direct/src/interval/hideInterval.cxx b/direct/src/interval/hideInterval.cxx index 8693fb6606..ed335dc307 100644 --- a/direct/src/interval/hideInterval.cxx +++ b/direct/src/interval/hideInterval.cxx @@ -1,27 +1,24 @@ -// Filename: hideInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hideInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "hideInterval.h" int HideInterval::_unique_index; TypeHandle HideInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: HideInterval::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HideInterval:: HideInterval(const NodePath &node, const string &name) : CInterval(name, 0.0, true), @@ -36,14 +33,11 @@ HideInterval(const NodePath &node, const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: HideInterval::instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_initialize() .. priv_step() -// .. priv_finalize(), when everything is to happen within -// one frame. The interval should initialize itself, -// then leave itself in the final state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_initialize() .. priv_step() .. + * priv_finalize(), when everything is to happen within one frame. The + * interval should initialize itself, then leave itself in the final state. + */ void HideInterval:: priv_instant() { check_stopped(get_class_type(), "priv_instant"); @@ -51,15 +45,12 @@ priv_instant() { _state = S_final; } -//////////////////////////////////////////////////////////////////// -// Function: HideInterval::reverse_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_reverse_initialize() -// .. priv_step() .. priv_reverse_finalize(), when everything is -// to happen within one frame. The interval should -// initialize itself, then leave itself in the initial -// state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_reverse_initialize() .. priv_step() .. + * priv_reverse_finalize(), when everything is to happen within one frame. + * The interval should initialize itself, then leave itself in the initial + * state. + */ void HideInterval:: priv_reverse_instant() { check_stopped(get_class_type(), "priv_reverse_instant"); diff --git a/direct/src/interval/hideInterval.h b/direct/src/interval/hideInterval.h index a96158a6c6..6b57ef7237 100644 --- a/direct/src/interval/hideInterval.h +++ b/direct/src/interval/hideInterval.h @@ -1,16 +1,15 @@ -// Filename: hideInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hideInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef HIDEINTERVAL_H #define HIDEINTERVAL_H @@ -19,10 +18,9 @@ #include "cInterval.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : HideInterval -// Description : An interval that calls NodePath::hide(). -//////////////////////////////////////////////////////////////////// +/** + * An interval that calls NodePath::hide(). + */ class EXPCL_DIRECT HideInterval : public CInterval { PUBLISHED: HideInterval(const NodePath &node, const string &name = string()); @@ -33,7 +31,7 @@ PUBLISHED: private: NodePath _node; static int _unique_index; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -55,4 +53,3 @@ private: #include "hideInterval.I" #endif - diff --git a/direct/src/interval/lerp_helpers.h b/direct/src/interval/lerp_helpers.h index e43cb8fbef..a2be32683f 100644 --- a/direct/src/interval/lerp_helpers.h +++ b/direct/src/interval/lerp_helpers.h @@ -1,33 +1,27 @@ -// Filename: lerp_helpers.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lerp_helpers.h + * @author drose + * @date 2002-08-27 + */ #ifndef LERP_HELPERS_H #define LERP_HELPERS_H #include "directbase.h" -// -// The functions defined here include some trivial template functions -// for handling basic lerp computations, common to several .cxx files -// here. -// +// The functions defined here include some trivial template functions for +// handling basic lerp computations, common to several .cxx files here. -//////////////////////////////////////////////////////////////////// -// Function: lerp_value -// Description: Applies the linear lerp computation for a single -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Applies the linear lerp computation for a single parameter. + */ template INLINE void lerp_value(NumericType ¤t_value, @@ -37,15 +31,13 @@ lerp_value(NumericType ¤t_value, current_value = starting_value + d * (ending_value - starting_value); } -//////////////////////////////////////////////////////////////////// -// Function: lerp_value_from_prev -// Description: Applies the linear lerp computation for a single -// parameter, when the starting value is implicit. -// -// This computes the new value based on assuming the -// prev_value represents the value computed at delta -// prev_d. -//////////////////////////////////////////////////////////////////// +/** + * Applies the linear lerp computation for a single parameter, when the + * starting value is implicit. + * + * This computes the new value based on assuming the prev_value represents the + * value computed at delta prev_d. + */ template INLINE void lerp_value_from_prev(NumericType ¤t_value, @@ -55,7 +47,7 @@ lerp_value_from_prev(NumericType ¤t_value, if (prev_d == 1.0) { current_value = ending_value; } else { - NumericType starting_value = + NumericType starting_value = (prev_value - prev_d * ending_value) / (1.0 - prev_d); current_value = starting_value + d * (ending_value - starting_value); } @@ -63,4 +55,3 @@ lerp_value_from_prev(NumericType ¤t_value, #endif - diff --git a/direct/src/interval/lerpblend.cxx b/direct/src/interval/lerpblend.cxx index 6cf72e521b..8c1ab6646e 100644 --- a/direct/src/interval/lerpblend.cxx +++ b/direct/src/interval/lerpblend.cxx @@ -1,16 +1,15 @@ -// Filename: lerpblend.cxx -// Created by: frang (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lerpblend.cxx + * @author frang + * @date 2000-05-30 + */ #include "lerpblend.h" @@ -90,4 +89,3 @@ NoBlendType& NoBlendType::operator=(const NoBlendType& c) { PN_stdfloat NoBlendType::operator()(PN_stdfloat t) { return t; } - diff --git a/direct/src/interval/lerpblend.h b/direct/src/interval/lerpblend.h index eb8e0555d3..f5c583ace9 100644 --- a/direct/src/interval/lerpblend.h +++ b/direct/src/interval/lerpblend.h @@ -1,16 +1,15 @@ -// Filename: lerpblend.h -// Created by: frang (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lerpblend.h + * @author frang + * @date 2000-05-30 + */ #ifndef __LERPBLEND_H__ #define __LERPBLEND_H__ diff --git a/direct/src/interval/showInterval.I b/direct/src/interval/showInterval.I index 37ceec0694..21338ac11e 100644 --- a/direct/src/interval/showInterval.I +++ b/direct/src/interval/showInterval.I @@ -1,14 +1,12 @@ -// Filename: showInterval.I -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showInterval.I + * @author drose + * @date 2002-08-27 + */ diff --git a/direct/src/interval/showInterval.cxx b/direct/src/interval/showInterval.cxx index d5d55590a6..53bc7d2346 100644 --- a/direct/src/interval/showInterval.cxx +++ b/direct/src/interval/showInterval.cxx @@ -1,27 +1,24 @@ -// Filename: showInterval.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showInterval.cxx + * @author drose + * @date 2002-08-27 + */ #include "showInterval.h" int ShowInterval::_unique_index; TypeHandle ShowInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ShowInterval::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShowInterval:: ShowInterval(const NodePath &node, const string &name) : CInterval(name, 0.0, true), @@ -36,14 +33,11 @@ ShowInterval(const NodePath &node, const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: ShowInterval::instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_initialize() .. priv_step() -// .. priv_finalize(), when everything is to happen within -// one frame. The interval should initialize itself, -// then leave itself in the final state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_initialize() .. priv_step() .. + * priv_finalize(), when everything is to happen within one frame. The + * interval should initialize itself, then leave itself in the final state. + */ void ShowInterval:: priv_instant() { check_stopped(get_class_type(), "priv_instant"); @@ -51,15 +45,12 @@ priv_instant() { _state = S_final; } -//////////////////////////////////////////////////////////////////// -// Function: ShowInterval::reverse_instant -// Access: Published, Virtual -// Description: This is called in lieu of priv_reverse_initialize() -// .. priv_step() .. priv_reverse_finalize(), when everything is -// to happen within one frame. The interval should -// initialize itself, then leave itself in the initial -// state. -//////////////////////////////////////////////////////////////////// +/** + * This is called in lieu of priv_reverse_initialize() .. priv_step() .. + * priv_reverse_finalize(), when everything is to happen within one frame. + * The interval should initialize itself, then leave itself in the initial + * state. + */ void ShowInterval:: priv_reverse_instant() { check_stopped(get_class_type(), "priv_reverse_instant"); diff --git a/direct/src/interval/showInterval.h b/direct/src/interval/showInterval.h index d0103f27a0..3ed7d55649 100644 --- a/direct/src/interval/showInterval.h +++ b/direct/src/interval/showInterval.h @@ -1,16 +1,15 @@ -// Filename: showInterval.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showInterval.h + * @author drose + * @date 2002-08-27 + */ #ifndef SHOWINTERVAL_H #define SHOWINTERVAL_H @@ -19,10 +18,9 @@ #include "cInterval.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : ShowInterval -// Description : An interval that calls NodePath::show(). -//////////////////////////////////////////////////////////////////// +/** + * An interval that calls NodePath::show(). + */ class EXPCL_DIRECT ShowInterval : public CInterval { PUBLISHED: ShowInterval(const NodePath &node, const string &name = string()); @@ -33,7 +31,7 @@ PUBLISHED: private: NodePath _node; static int _unique_index; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -55,4 +53,3 @@ private: #include "showInterval.I" #endif - diff --git a/direct/src/interval/waitInterval.I b/direct/src/interval/waitInterval.I index 19b6d2da9a..bea7a68a6c 100644 --- a/direct/src/interval/waitInterval.I +++ b/direct/src/interval/waitInterval.I @@ -1,24 +1,20 @@ -// Filename: waitInterval.I -// Created by: drose (12Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file waitInterval.I + * @author drose + * @date 2002-09-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WaitInterval::Constructor -// Access: Published -// Description: All Wait intervals have the same name. No one really -// cares if their names are unique, after all. -//////////////////////////////////////////////////////////////////// +/** + * All Wait intervals have the same name. No one really cares if their names + * are unique, after all. + */ INLINE WaitInterval:: WaitInterval(double duration) : CInterval("Wait", duration, true) diff --git a/direct/src/interval/waitInterval.cxx b/direct/src/interval/waitInterval.cxx index 8a3cebebe8..4a2cc7a824 100644 --- a/direct/src/interval/waitInterval.cxx +++ b/direct/src/interval/waitInterval.cxx @@ -1,36 +1,33 @@ -// Filename: waitInterval.cxx -// Created by: drose (12Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file waitInterval.cxx + * @author drose + * @date 2002-09-12 + */ #include "waitInterval.h" #include "config_interval.h" TypeHandle WaitInterval::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WaitInterval::priv_step -// Access: Published, Virtual -// Description: Advances the time on the interval. The time may -// either increase (the normal case) or decrease -// (e.g. if the interval is being played by a slider). -//////////////////////////////////////////////////////////////////// +/** + * Advances the time on the interval. The time may either increase (the + * normal case) or decrease (e.g. if the interval is being played by a + * slider). + */ void WaitInterval:: priv_step(double t) { - // The WaitInterval is normally not run directly; it just fills up - // time when constructing a MetaInterval (specifically, a Sequence). + // The WaitInterval is normally not run directly; it just fills up time when + // constructing a MetaInterval (specifically, a Sequence). #ifndef NDEBUG if (verify_intervals) { - interval_cat.info() + interval_cat.info() << "running WaitInterval. Intentional?\n"; } #endif diff --git a/direct/src/interval/waitInterval.h b/direct/src/interval/waitInterval.h index 0cc51f00b4..a1fd57793b 100644 --- a/direct/src/interval/waitInterval.h +++ b/direct/src/interval/waitInterval.h @@ -1,16 +1,15 @@ -// Filename: waitInterval.h -// Created by: drose (12Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file waitInterval.h + * @author drose + * @date 2002-09-12 + */ #ifndef WAITINTERVAL_H #define WAITINTERVAL_H @@ -18,12 +17,10 @@ #include "directbase.h" #include "cInterval.h" -//////////////////////////////////////////////////////////////////// -// Class : WaitInterval -// Description : This interval does absolutely nothing, and is mainly -// useful for marking time between other intervals -// within a sequence. -//////////////////////////////////////////////////////////////////// +/** + * This interval does absolutely nothing, and is mainly useful for marking + * time between other intervals within a sequence. + */ class EXPCL_DIRECT WaitInterval : public CInterval { PUBLISHED: INLINE WaitInterval(double duration); @@ -51,4 +48,3 @@ private: #include "waitInterval.I" #endif - diff --git a/direct/src/motiontrail/cMotionTrail.cxx b/direct/src/motiontrail/cMotionTrail.cxx index 9cb163e36c..988a59c5dc 100644 --- a/direct/src/motiontrail/cMotionTrail.cxx +++ b/direct/src/motiontrail/cMotionTrail.cxx @@ -1,16 +1,15 @@ -// Filename: cMotionTrail.cxx -// Created by: aignacio (29Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cMotionTrail.cxx + * @author aignacio + * @date 2007-01-29 + */ #include "directbase.h" #include "cMotionTrail.h" @@ -20,11 +19,9 @@ TypeHandle CMotionTrail::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::Constructor -// Access: Published -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ CMotionTrail:: CMotionTrail ( ) { @@ -68,61 +65,49 @@ CMotionTrail ( ) { _vertex_array = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::Destructor -// Access: Published -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ CMotionTrail:: ~CMotionTrail ( ) { } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::reset -// Access: Published -// Description: Reset the frame sample history. -//////////////////////////////////////////////////////////////////// +/** + * Reset the frame sample history. + */ void CMotionTrail:: reset ( ) { _frame_list.clear ( ); } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::reset_vertex_list -// Access: Published -// Description: Reset the vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Reset the vertex list. + */ void CMotionTrail:: reset_vertex_list ( ) { _vertex_list.clear ( ); } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::enable -// Access: Published -// Description: Enable/disable the motion trail. -//////////////////////////////////////////////////////////////////// +/** + * Enable/disable the motion trail. + */ void CMotionTrail:: enable (bool enable) { _enable = enable; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::set_geom_node -// Access: Published -// Description: Set the GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Set the GeomNode. + */ void CMotionTrail:: set_geom_node (GeomNode *geom_node) { _geom_node = geom_node; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::add_vertex -// Access: Published -// Description: Add a vertex. -//////////////////////////////////////////////////////////////////// +/** + * Add a vertex. + */ void CMotionTrail:: add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_stdfloat v) { @@ -138,31 +123,25 @@ add_vertex (LVector4 *vertex, LVector4 *start_color, LVector4 *end_color, PN_std _vertex_list.push_back (motion_trail_vertex); } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::set_parameters -// Access: Published -// Description: Set motion trail parameters. -// -// sampling_time = Can be used to specify a lower -// sampling rate than the frame rate. Use 0.0 with -// nurbs. -// -// time_window = a component for the "length" of the -// motion trail. The motion trail length = -// time_window * velocity of the object. -// -// use_texture = texture option on/off. -// -// calculate_relative_matrix = calculate relative -// matrix on/off. -// -// use_nurbs = nurbs option on/off -// -// resolution_distance = the distance used to -// determine the number of geometry samples. -// samples = motion trail length / resolution_distance. -// Applicable only if nurbs is on. -//////////////////////////////////////////////////////////////////// +/** + * Set motion trail parameters. + * + * sampling_time = Can be used to specify a lower sampling rate than the frame + * rate. Use 0.0 with nurbs. + * + * time_window = a component for the "length" of the motion trail. The motion + * trail length = time_window * velocity of the object. + * + * use_texture = texture option on/off. + * + * calculate_relative_matrix = calculate relative matrix on/off. + * + * use_nurbs = nurbs option on/off + * + * resolution_distance = the distance used to determine the number of geometry + * samples. samples = motion trail length / resolution_distance. Applicable + * only if nurbs is on. + */ void CMotionTrail:: set_parameters (PN_stdfloat sampling_time, PN_stdfloat time_window, bool use_texture, bool calculate_relative_matrix, bool use_nurbs, PN_stdfloat resolution_distance) { @@ -174,11 +153,9 @@ set_parameters (PN_stdfloat sampling_time, PN_stdfloat time_window, bool use_tex _resolution_distance = resolution_distance; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::check_for_update -// Access: Published -// Description: Check if a sample can be submitted. -//////////////////////////////////////////////////////////////////// +/** + * Check if a sample can be submitted. + */ int CMotionTrail:: check_for_update (PN_stdfloat current_time) { @@ -205,11 +182,9 @@ PN_stdfloat one_minus_x (PN_stdfloat x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::begin_geometry -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CMotionTrail:: begin_geometry ( ) { @@ -223,9 +198,9 @@ begin_geometry ( ) { format = GeomVertexFormat::get_v3c4 ( ); } - // Clear the previous writers before we create a new vertex data - // object--this seems to work around an ordering problem in the - // low-level vertex data destructors. + // Clear the previous writers before we create a new vertex data object-- + // this seems to work around an ordering problem in the low-level vertex + // data destructors. _vertex_writer.clear(); _color_writer.clear(); _texture_writer.clear(); @@ -240,11 +215,9 @@ begin_geometry ( ) { _triangles = new GeomTriangles (Geom::UH_static); } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::add_geometry_quad -// Access: Public -// Description: LVector3 vertex version. -//////////////////////////////////////////////////////////////////// +/** + * LVector3 vertex version. + */ void CMotionTrail:: add_geometry_quad (LVector3 &v0, LVector3 &v1, LVector3 &v2, LVector3 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3) { @@ -281,11 +254,9 @@ add_geometry_quad (LVector3 &v0, LVector3 &v1, LVector3 &v2, LVector3 &v3, LVect _vertex_index += 4; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::add_geometry_quad -// Access: Public -// Description: LVector4 vertex version. -//////////////////////////////////////////////////////////////////// +/** + * LVector4 vertex version. + */ void CMotionTrail:: add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVector4 &c0, LVector4 &c1, LVector4 &c2, LVector4 &c3, LVector2 &t0, LVector2 &t1, LVector2 &t2, LVector2 &t3) { @@ -322,11 +293,9 @@ add_geometry_quad (LVector4 &v0, LVector4 &v1, LVector4 &v2, LVector4 &v3, LVect _vertex_index += 4; } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::end_geometry -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CMotionTrail::end_geometry ( ) { static CPT(RenderState) state; if (state == (RenderState *)NULL) { @@ -344,11 +313,9 @@ void CMotionTrail::end_geometry ( ) { } } -//////////////////////////////////////////////////////////////////// -// Function: CMotionTrail::update_motion_trail -// Access: Published -// Description: See class header comments. -//////////////////////////////////////////////////////////////////// +/** + * See class header comments. + */ void CMotionTrail:: update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { @@ -474,7 +441,8 @@ update_motion_trail (PN_stdfloat current_time, LMatrix4 *transform) { total_vertex_segments = total_vertices - 1; total_distance = 0.0f; - // reset NurbsCurveEvaluators for each vertex (the starting point for the trail) + // reset NurbsCurveEvaluators for each vertex (the starting point for + // the trail) { CMotionTrailVertex *motion_trail_vertex; PT(NurbsCurveEvaluator) nurbs_curve_evaluator; diff --git a/direct/src/motiontrail/cMotionTrail.h b/direct/src/motiontrail/cMotionTrail.h index 7ca61a2951..ef05b4b1c0 100644 --- a/direct/src/motiontrail/cMotionTrail.h +++ b/direct/src/motiontrail/cMotionTrail.h @@ -1,16 +1,15 @@ -// Filename: cMotionTrail.h -// Created by: aignacio (29Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cMotionTrail.h + * @author aignacio + * @date 2007-01-29 + */ #ifndef CMOTIONTRAIL_H #define CMOTIONTRAIL_H @@ -42,46 +41,34 @@ public: PN_stdfloat _time; }; -//////////////////////////////////////////////////////////////////// -// Class : CMotionTrail -// Description : The method used in creating the motion trail is -// based on taking samples of time and transformations -// (the position and orientation matrix) in real-time. -// The method also requires a number of vertices -// (positions) that determines "shape" of the motion -// trail (i.e. the edge of a blade). A start color -// and end color is also required for each vertex. -// The color is interpolated as function of time. -// The colors are typically used to fade the motion -// trail so the end color is typically black. -// -// The vertices are submitted via the "add_vertex" -// function. For each frame, a sample is submited via -// the "update_motion_trail" function. During the -// "update_motion_trail" function, the motion trail -// geometry is created dynamically from the sample -// history and the vertices. -// -// The user must specifiy a GeomNode via -// "set_geom_node". -// -// The duration of the sample history is specified by -// a time window. A larger time window creates longer -// motion trails (given constant speed). Samples that -// are no longer within the time window are -// automatically discarded. -// -// The nurbs option can be used to create smooth -// interpolated curves from the samples. The nurbs -// option is useful for animations that lack sampling -// to begin with, animations that move very quickly, -// or low frame rates. -// -// The texture option be used to create variation to -// the motion trail. The u coordinate of the texture -// corresponds to time and the v coordinate -// corresponds to the "shape" of the motion trail. -//////////////////////////////////////////////////////////////////// +/** + * The method used in creating the motion trail is based on taking samples of + * time and transformations (the position and orientation matrix) in real- + * time. The method also requires a number of vertices (positions) that + * determines "shape" of the motion trail (i.e. the edge of a blade). A + * start color and end color is also required for each vertex. The color is + * interpolated as function of time. The colors are typically used to fade + * the motion trail so the end color is typically black. + * + * The vertices are submitted via the "add_vertex" function. For each frame, + * a sample is submited via the "update_motion_trail" function. During the + * "update_motion_trail" function, the motion trail geometry is created + * dynamically from the sample history and the vertices. + * + * The user must specifiy a GeomNode via "set_geom_node". + * + * The duration of the sample history is specified by a time window. A larger + * time window creates longer motion trails (given constant speed). Samples + * that are no longer within the time window are automatically discarded. + * + * The nurbs option can be used to create smooth interpolated curves from the + * samples. The nurbs option is useful for animations that lack sampling to + * begin with, animations that move very quickly, or low frame rates. + * + * The texture option be used to create variation to the motion trail. The u + * coordinate of the texture corresponds to time and the v coordinate + * corresponds to the "shape" of the motion trail. + */ class EXPCL_DIRECT CMotionTrail : public TypedReferenceCount { PUBLISHED: CMotionTrail(); diff --git a/direct/src/motiontrail/config_motiontrail.cxx b/direct/src/motiontrail/config_motiontrail.cxx index dfcfe21e6d..c805ae1319 100644 --- a/direct/src/motiontrail/config_motiontrail.cxx +++ b/direct/src/motiontrail/config_motiontrail.cxx @@ -1,16 +1,15 @@ -// Filename: config_motiontrail.cxx -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_motiontrail.cxx + * @author drose + * @date 2002-08-27 + */ #include "config_motiontrail.h" #include "dconfig.h" @@ -24,14 +23,12 @@ ConfigureFn(config_motiontrail) { init_libmotiontrail(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libmotiontrail -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmotiontrail() { static bool initialized = false; diff --git a/direct/src/motiontrail/config_motiontrail.h b/direct/src/motiontrail/config_motiontrail.h index 09215deda5..79c516d41c 100644 --- a/direct/src/motiontrail/config_motiontrail.h +++ b/direct/src/motiontrail/config_motiontrail.h @@ -1,16 +1,15 @@ -// Filename: config_motiontrail.h -// Created by: drose (27Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_motiontrail.h + * @author drose + * @date 2002-08-27 + */ #ifndef CONFIG_MOTIONTRAIL_H #define CONFIG_MOTIONTRAIL_H diff --git a/direct/src/plugin/binaryXml.cxx b/direct/src/plugin/binaryXml.cxx index df882b9bcd..6363f12d8e 100644 --- a/direct/src/plugin/binaryXml.cxx +++ b/direct/src/plugin/binaryXml.cxx @@ -1,16 +1,15 @@ -// Filename: binaryXml.cxx -// Created by: drose (13Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binaryXml.cxx + * @author drose + * @date 2009-07-13 + */ #include "binaryXml.h" #include "p3d_lock.h" @@ -30,20 +29,19 @@ enum NodeType { NT_text, }; -// This typedef defines a 32-bit unsigned integer. It's used for -// passing values through the binary XML stream. +// This typedef defines a 32-bit unsigned integer. It's used for passing +// values through the binary XML stream. typedef unsigned int xml_uint32; -// These are both prime numbers, though I don't know if that really -// matters. Mainly, they're big random numbers. +// These are both prime numbers, though I don't know if that really matters. +// Mainly, they're big random numbers. static const xml_uint32 length_nonce1 = 812311453; static const xml_uint32 length_nonce2 = 612811373; -//////////////////////////////////////////////////////////////////// -// Function: init_xml -// Description: Should be called before spawning any threads to -// ensure the lock is initialized. -//////////////////////////////////////////////////////////////////// +/** + * Should be called before spawning any threads to ensure the lock is + * initialized. + */ void init_xml() { if (!xml_lock_initialized) { @@ -52,22 +50,19 @@ init_xml() { } } -//////////////////////////////////////////////////////////////////// -// Function: write_xml_node -// Description: Recursively writes a node and all of its children to -// the given stream. -//////////////////////////////////////////////////////////////////// +/** + * Recursively writes a node and all of its children to the given stream. + */ static void write_xml_node(ostream &out, TiXmlNode *xnode) { const string &value = xnode->ValueStr(); xml_uint32 value_length = value.length(); xml_uint32 value_proof = (value_length + length_nonce1) * length_nonce2; - // We write out not only value_length, but the same value again - // hashed by length_nonce1 and 2 (and truncated back to xml_uint32), - // just to prove to the reader that we're still on the same page. - // We do this only on the top node; we don't bother for the nested - // nodes. + // We write out not only value_length, but the same value again hashed by + // length_nonce1 and 2 (and truncated back to xml_uint32), just to prove to + // the reader that we're still on the same page. We do this only on the top + // node; we don't bother for the nested nodes. out.write((char *)&value_length, sizeof(value_length)); out.write((char *)&value_proof, sizeof(value_proof)); out.write(value.data(), value_length); @@ -99,17 +94,17 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { while (xattrib != NULL) { // We have an attribute. out.put((char)true); - + string name = xattrib->Name(); xml_uint32 name_length = name.length(); out.write((char *)&name_length, sizeof(name_length)); out.write(name.data(), name_length); - + const string &value = xattrib->ValueStr(); xml_uint32 value_length = value.length(); out.write((char *)&value_length, sizeof(value_length)); out.write(value.data(), value_length); - + xattrib = xattrib->Next(); } @@ -125,18 +120,16 @@ write_xml_node(ostream &out, TiXmlNode *xnode) { write_xml_node(out, xchild); xchild = xchild->NextSibling(); } - + // The end of the children list. out.put((char)false); } -//////////////////////////////////////////////////////////////////// -// Function: read_xml_node -// Description: Recursively reads a node and all of its children to -// the given stream. Returns the newly-allocated node. -// The caller is responsible for eventually deleting the -// return value. Returns NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Recursively reads a node and all of its children to the given stream. + * Returns the newly-allocated node. The caller is responsible for eventually + * deleting the return value. Returns NULL on error. + */ static TiXmlNode * read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, ostream &logfile) { @@ -152,12 +145,12 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, return NULL; } if (value_proof != value_proof_expect) { - // Hey, we ran into garbage: the proof value didn't match our - // expected proof value. + // Hey, we ran into garbage: the proof value didn't match our expected + // proof value. logfile << "Garbage on XML stream!\n"; - // Print out the garbage; maybe it will help the developer figure - // out where it came from. + // Print out the garbage; maybe it will help the developer figure out + // where it came from. logfile << "Begin garbage:\n"; ostringstream strm; strm.write((char *)&value_length, sizeof(value_length)); @@ -248,7 +241,7 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, // Now read all of the children. bool got_child = (bool)(in.get() != 0); - + while (got_child && in && !in.eof()) { // We have a child. TiXmlNode *xchild = read_xml_node(in, buffer, buffer_length, logfile); @@ -264,11 +257,9 @@ read_xml_node(istream &in, char *&buffer, xml_uint32 &buffer_length, -//////////////////////////////////////////////////////////////////// -// Function: write_xml -// Description: Writes the indicated TinyXml document to the given -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated TinyXml document to the given stream. + */ void write_xml(ostream &out, TiXmlDocument *doc, ostream &logfile) { assert(xml_lock_initialized); @@ -291,8 +282,8 @@ write_xml(ostream &out, TiXmlDocument *doc, ostream &logfile) { out << flush; if (debug_xml_output) { - // Write via ostringstream, so it all goes in one operation, to - // help out the interleaving from multiple threads. + // Write via ostringstream, so it all goes in one operation, to help out + // the interleaving from multiple threads. ostringstream logout; logout << "sent: " << *doc << "\n"; logfile << logout.str() << flush; @@ -301,27 +292,24 @@ write_xml(ostream &out, TiXmlDocument *doc, ostream &logfile) { RELEASE_LOCK(xml_lock); } -//////////////////////////////////////////////////////////////////// -// Function: read_xml -// Description: Reads a TinyXml document from the given stream, and -// returns it. If the document is not yet available, -// blocks until it is, or until there is an error -// condition on the input. -// -// The return value is NULL if there is an error, or the -// newly-allocated document if it is successfully read. -// If not NULL, the document has been allocated with -// new, and should be eventually freed by the caller -// with delete. -//////////////////////////////////////////////////////////////////// +/** + * Reads a TinyXml document from the given stream, and returns it. If the + * document is not yet available, blocks until it is, or until there is an + * error condition on the input. + * + * The return value is NULL if there is an error, or the newly-allocated + * document if it is successfully read. If not NULL, the document has been + * allocated with new, and should be eventually freed by the caller with + * delete. + */ TiXmlDocument * read_xml(istream &in, ostream &logfile) { - // We don't acquire xml_lock while reading. We can't, because our - // XML readers are all designed to block until data is available, - // and they can't block while holding the lock. + // We don't acquire xml_lock while reading. We can't, because our XML + // readers are all designed to block until data is available, and they can't + // block while holding the lock. - // Fortunately, there should be only one reader at a time, so a lock - // isn't really needed here. + // Fortunately, there should be only one reader at a time, so a lock isn't + // really needed here. #if DO_BINARY_XML // binary read. @@ -347,8 +335,8 @@ read_xml(istream &in, ostream &logfile) { #endif if (debug_xml_output) { - // Write via ostringstream, so it all goes in one operation, to - // help out the interleaving from multiple threads. + // Write via ostringstream, so it all goes in one operation, to help out + // the interleaving from multiple threads. ostringstream logout; logout << "received: " << *doc << "\n"; logfile << logout.str() << flush; diff --git a/direct/src/plugin/binaryXml.h b/direct/src/plugin/binaryXml.h index f1077f7747..4bdd9d29cf 100644 --- a/direct/src/plugin/binaryXml.h +++ b/direct/src/plugin/binaryXml.h @@ -1,16 +1,15 @@ -// Filename: binaryXml.h -// Created by: drose (13Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binaryXml.h + * @author drose + * @date 2009-07-13 + */ #ifndef BINARYXML_H #define BINARYXML_H @@ -21,10 +20,9 @@ using namespace std; -// A pair of functions to input and output the TinyXml constructs on -// the indicated streams. We could, of course, use the TinyXml output -// operators, but this is a smidge more efficient and gives us more -// control. +// A pair of functions to input and output the TinyXml constructs on the +// indicated streams. We could, of course, use the TinyXml output operators, +// but this is a smidge more efficient and gives us more control. void init_xml(); void write_xml(ostream &out, TiXmlDocument *doc, ostream &logfile); diff --git a/direct/src/plugin/fhandle.h b/direct/src/plugin/fhandle.h index 7f71b810dd..90459efbe1 100644 --- a/direct/src/plugin/fhandle.h +++ b/direct/src/plugin/fhandle.h @@ -1,22 +1,21 @@ -// Filename: fhandle.h -// Created by: drose (29Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fhandle.h + * @author drose + * @date 2009-08-29 + */ #ifndef FHANDLE_H #define FHANDLE_H -// This header file simply defines the FHandle type, which is used to -// pass around a handle to an open file object. +// This header file simply defines the FHandle type, which is used to pass +// around a handle to an open file object. #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN diff --git a/direct/src/plugin/fileSpec.I b/direct/src/plugin/fileSpec.I index 5d7ffe53e3..e82e099fb8 100644 --- a/direct/src/plugin/fileSpec.I +++ b/direct/src/plugin/fileSpec.I @@ -1,106 +1,82 @@ -// Filename: fileSpec.I -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileSpec.I + * @author drose + * @date 2009-06-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::get_filename -// Access: Public -// Description: Returns the relative path to this file on disk, -// within the package root directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative path to this file on disk, within the package root + * directory. + */ inline const string &FileSpec:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::set_filename -// Access: Public -// Description: Changes the relative path to this file on disk, -// within the package root directory. -//////////////////////////////////////////////////////////////////// +/** + * Changes the relative path to this file on disk, within the package root + * directory. + */ inline void FileSpec:: set_filename(const string &filename) { _filename = filename; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::get_pathname -// Access: Public -// Description: Returns the full path to this file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path to this file on disk. + */ inline string FileSpec:: get_pathname(const string &package_dir) const { return package_dir + "/" + _filename; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::get_size -// Access: Public -// Description: Returns the expected size of this file on disk, in -// bytes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the expected size of this file on disk, in bytes. + */ inline size_t FileSpec:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::get_timestamp -// Access: Public -// Description: Returns the expected last-modify timestamp of this -// file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the expected last-modify timestamp of this file on disk. + */ inline time_t FileSpec:: get_timestamp() const { return _timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::has_hash -// Access: Public -// Description: Returns true if we have successfully read a hash -// value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have successfully read a hash value, false otherwise. + */ inline bool FileSpec:: has_hash() const { return _got_hash; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::get_actual_file -// Access: Public -// Description: After a call to quick_verify() or full_verify(), this -// method *may* return a pointer to a FileSpec that -// represents the actual data read on disk, or it may -// return NULL. If this returns a non-NULL value, you -// may use it to extract the md5 hash of the existing -// file, thus saving the effort of performing the hash -// twice. -//////////////////////////////////////////////////////////////////// +/** + * After a call to quick_verify() or full_verify(), this method *may* return a + * pointer to a FileSpec that represents the actual data read on disk, or it + * may return NULL. If this returns a non-NULL value, you may use it to + * extract the md5 hash of the existing file, thus saving the effort of + * performing the hash twice. + */ inline const FileSpec *FileSpec:: get_actual_file() const { return _actual_file; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::decode_hexdigit -// Access: Private -// Description: Returns the integer value corresponding to the -// indicated hex digit. Returns -1 if it is not a hex -// digit. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value corresponding to the indicated hex digit. + * Returns -1 if it is not a hex digit. + */ inline int FileSpec:: decode_hexdigit(char c) { if (isdigit(c)) { @@ -114,12 +90,9 @@ decode_hexdigit(char c) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::encode_hexdigit -// Access: Private -// Description: Returns the hex digit corresponding to the -// indicated integer value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the hex digit corresponding to the indicated integer value. + */ inline char FileSpec:: encode_hexdigit(int c) { if (c >= 10) { diff --git a/direct/src/plugin/fileSpec.cxx b/direct/src/plugin/fileSpec.cxx index a67346722e..58194c10f2 100644 --- a/direct/src/plugin/fileSpec.cxx +++ b/direct/src/plugin/fileSpec.cxx @@ -1,16 +1,15 @@ -// Filename: fileSpec.cxx -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileSpec.cxx + * @author drose + * @date 2009-06-29 + */ #include "fileSpec.h" #include "wstring_encode.h" @@ -34,11 +33,9 @@ #endif -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FileSpec:: FileSpec() { _size = 0; @@ -48,11 +45,9 @@ FileSpec() { _actual_file = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FileSpec:: FileSpec(const FileSpec ©) : _filename(copy._filename), @@ -64,11 +59,9 @@ FileSpec(const FileSpec ©) : _actual_file = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FileSpec:: operator = (const FileSpec ©) { _filename = copy._filename; @@ -78,11 +71,9 @@ operator = (const FileSpec ©) { _got_hash = copy._got_hash; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FileSpec:: ~FileSpec() { if (_actual_file != NULL) { @@ -90,11 +81,9 @@ FileSpec:: } } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::load_xml -// Access: Public -// Description: Reads the data from the indicated XML file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data from the indicated XML file. + */ void FileSpec:: load_xml(TiXmlElement *xelement) { const char *filename = xelement->Attribute("filename"); @@ -122,11 +111,9 @@ load_xml(TiXmlElement *xelement) { } } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::store_xml -// Access: Public -// Description: Stores the data to the indicated XML file. -//////////////////////////////////////////////////////////////////// +/** + * Stores the data to the indicated XML file. + */ void FileSpec:: store_xml(TiXmlElement *xelement) { if (!_filename.empty()) { @@ -146,29 +133,22 @@ store_xml(TiXmlElement *xelement) { } } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::quick_verify -// Access: Public -// Description: Performs a quick test to ensure the file has not been -// modified. This test is vulnerable to people -// maliciously attempting to fool the program (by -// setting datestamps etc.). -// -// Returns true if it is intact, false if it needs to be -// redownloaded. -//////////////////////////////////////////////////////////////////// +/** + * Performs a quick test to ensure the file has not been modified. This test + * is vulnerable to people maliciously attempting to fool the program (by + * setting datestamps etc.). + * + * Returns true if it is intact, false if it needs to be redownloaded. + */ bool FileSpec:: quick_verify(const string &package_dir) { return quick_verify_pathname(get_pathname(package_dir)); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::quick_verify_pathname -// Access: Public -// Description: Works like quick_verify(), above, with an explicit -// pathname. Useful for verifying the copy of a file in -// a temporary location. -//////////////////////////////////////////////////////////////////// +/** + * Works like quick_verify(), above, with an explicit pathname. Useful for + * verifying the copy of a file in a temporary location. + */ bool FileSpec:: quick_verify_pathname(const string &pathname) { if (_actual_file != NULL) { @@ -189,37 +169,36 @@ quick_verify_pathname(const string &pathname) { #endif // _WIN32 if (result != 0) { - //cerr << "file not found: " << _filename << "\n"; + // cerr << "file not found: " << _filename << "\n"; return false; } if (st.st_size != _size) { - // If the size is wrong, the file fails. - //cerr << "size wrong: " << _filename << "\n"; + // If the size is wrong, the file fails. cerr << "size wrong: " << + // _filename << "\n"; return false; } if (st.st_mtime == _timestamp) { - // If the size is right and the timestamp is right, the file passes. - //cerr << "file ok: " << _filename << "\n"; + // If the size is right and the timestamp is right, the file passes. cerr + // << "file ok: " << _filename << "\n"; return true; } - //cerr << "modification time wrong: " << _filename << "\n"; + // cerr << "modification time wrong: " << _filename << "\n"; - // If the size is right but the timestamp is wrong, the file - // soft-fails. We follow this up with a hash check. + // If the size is right but the timestamp is wrong, the file soft-fails. We + // follow this up with a hash check. if (!priv_check_hash(pathname, &st)) { - // Hard fail, the hash is wrong. - //cerr << "hash check wrong: " << _filename << "\n"; + // Hard fail, the hash is wrong. cerr << "hash check wrong: " << + // _filename << "\n"; return false; } - //cerr << "hash check ok: " << _filename << "\n"; + // cerr << "hash check ok: " << _filename << "\n"; - // The hash is OK after all. Change the file's timestamp back to - // what we expect it to be, so we can quick-verify it successfully - // next time. + // The hash is OK after all. Change the file's timestamp back to what we + // expect it to be, so we can quick-verify it successfully next time. utimbuf utb; utb.actime = st.st_atime; utb.modtime = _timestamp; @@ -233,17 +212,13 @@ quick_verify_pathname(const string &pathname) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::full_verify -// Access: Public -// Description: Performs a more thorough test to ensure the file has -// not been modified. This test is less vulnerable to -// malicious attacks, since it reads and verifies the -// entire file. -// -// Returns true if it is intact, false if it needs to be -// redownloaded. -//////////////////////////////////////////////////////////////////// +/** + * Performs a more thorough test to ensure the file has not been modified. + * This test is less vulnerable to malicious attacks, since it reads and + * verifies the entire file. + * + * Returns true if it is intact, false if it needs to be redownloaded. + */ bool FileSpec:: full_verify(const string &package_dir) { if (_actual_file != NULL) { @@ -265,27 +240,26 @@ full_verify(const string &package_dir) { #endif // _WIN32 if (result != 0) { - //cerr << "file not found: " << _filename << "\n"; + // cerr << "file not found: " << _filename << "\n"; return false; } if (st.st_size != _size) { - // If the size is wrong, the file fails. - //cerr << "size wrong: " << _filename << "\n"; + // If the size is wrong, the file fails. cerr << "size wrong: " << + // _filename << "\n"; return false; } if (!priv_check_hash(pathname, &st)) { - // Hard fail, the hash is wrong. - //cerr << "hash check wrong: " << _filename << "\n"; + // Hard fail, the hash is wrong. cerr << "hash check wrong: " << + // _filename << "\n"; return false; } - //cerr << "hash check ok: " << _filename << "\n"; + // cerr << "hash check ok: " << _filename << "\n"; - // The hash is OK. If the timestamp is wrong, change it back to - // what we expect it to be, so we can quick-verify it successfully - // next time. + // The hash is OK. If the timestamp is wrong, change it back to what we + // expect it to be, so we can quick-verify it successfully next time. if (st.st_mtime != _timestamp) { utimbuf utb; @@ -297,17 +271,14 @@ full_verify(const string &package_dir) { utime(pathname.c_str(), &utb); #endif // _WIN32 } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::force_get_actual_file -// Access: Public -// Description: Returns a FileSpec that represents the actual data -// read on disk. This will read the disk to determine -// the data if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FileSpec that represents the actual data read on disk. This will + * read the disk to determine the data if necessary. + */ const FileSpec *FileSpec:: force_get_actual_file(const string &pathname) { if (_actual_file == NULL) { @@ -328,12 +299,9 @@ force_get_actual_file(const string &pathname) { return _actual_file; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::check_hash -// Access: Public -// Description: Returns true if the file has the expected md5 hash, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has the expected md5 hash, false otherwise. + */ bool FileSpec:: check_hash(const string &pathname) const { FileSpec other; @@ -344,12 +312,10 @@ check_hash(const string &pathname) const { return (memcmp(_hash, other._hash, hash_size) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::read_hash -// Access: Public -// Description: Computes the hash from the indicated pathname and -// stores it within the FileSpec. -//////////////////////////////////////////////////////////////////// +/** + * Computes the hash from the indicated pathname and stores it within the + * FileSpec. + */ bool FileSpec:: read_hash(const string &pathname) { memset(_hash, 0, hash_size); @@ -364,9 +330,9 @@ read_hash(const string &pathname) { #else // _WIN32 stream.open(pathname.c_str(), ios::in | ios::binary); #endif // _WIN32 - + if (!stream) { - //cerr << "unable to read " << pathname << "\n"; + // cerr << "unable to read " << pathname << "\n"; return false; } @@ -390,13 +356,10 @@ read_hash(const string &pathname) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::read_hash_stream -// Access: Public -// Description: Reads the hash from the next 16 bytes on the -// indicated istream, in the same unusual order observed -// by Panda's HashVal::read_stream() method. -//////////////////////////////////////////////////////////////////// +/** + * Reads the hash from the next 16 bytes on the indicated istream, in the same + * unusual order observed by Panda's HashVal::read_stream() method. + */ bool FileSpec:: read_hash_stream(istream &in) { for (int i = 0; i < hash_size; i += 4) { @@ -413,22 +376,18 @@ read_hash_stream(istream &in) { return !in.fail(); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::compare_hash -// Access: Public -// Description: Returns < 0 if this hash sorts before the other -// hash, > 0 if it sorts after, 0 if they are the same. -//////////////////////////////////////////////////////////////////// +/** + * Returns < 0 if this hash sorts before the other hash, > 0 if it sorts + * after, 0 if they are the same. + */ int FileSpec:: compare_hash(const FileSpec &other) const { return memcmp(_hash, other._hash, hash_size); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::write -// Access: Public -// Description: Describes the data in the FileSpec. -//////////////////////////////////////////////////////////////////// +/** + * Describes the data in the FileSpec. + */ void FileSpec:: write(ostream &out) const { out << "filename: " << _filename << ", " << _size << " bytes, " @@ -439,29 +398,23 @@ write(ostream &out) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::output_hash -// Access: Public -// Description: Writes just the hash code. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the hash code. + */ void FileSpec:: output_hash(ostream &out) const { stream_hex(out, _hash, hash_size); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::priv_check_hash -// Access: Private -// Description: Returns true if the file has the expected md5 hash, -// false otherwise. Updates _actual_file with the data -// read from disk, including the hash, for future -// reference. -// -// The parameter stp is a pointer to a stat structure. -// It's declared as a void * to get around issues with -// the nonstandard declaration of this structure in -// Windows. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has the expected md5 hash, false otherwise. + * Updates _actual_file with the data read from disk, including the hash, for + * future reference. + * + * The parameter stp is a pointer to a stat structure. It's declared as a + * void * to get around issues with the nonstandard declaration of this + * structure in Windows. + */ bool FileSpec:: priv_check_hash(const string &pathname, void *stp) { const struct stat &st = *(const struct stat *)stp; @@ -478,16 +431,12 @@ priv_check_hash(const string &pathname, void *stp) { return (memcmp(_hash, _actual_file->_hash, hash_size) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::decode_hex -// Access: Private, Static -// Description: Decodes the hex string in source into the character -// array in dest. dest must have has least size bytes; -// source must have size * 2 bytes. -// -// Returns true on success, false if there was a non-hex -// digit in the string. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the hex string in source into the character array in dest. dest + * must have has least size bytes; source must have size * 2 bytes. + * + * Returns true on success, false if there was a non-hex digit in the string. + */ bool FileSpec:: decode_hex(unsigned char *dest, const char *source, size_t size) { for (size_t i = 0; i < size; ++i) { @@ -502,14 +451,11 @@ decode_hex(unsigned char *dest, const char *source, size_t size) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::encode_hex -// Access: Private, Static -// Description: Encodes a character array into a hex string for -// output. dest must have at least size * 2 bytes; -// source must have size bytes. The result is not -// null-terminated. -//////////////////////////////////////////////////////////////////// +/** + * Encodes a character array into a hex string for output. dest must have at + * least size * 2 bytes; source must have size bytes. The result is not null- + * terminated. + */ void FileSpec:: encode_hex(char *dest, const unsigned char *source, size_t size) { for (size_t i = 0; i < size; ++i) { @@ -520,12 +466,10 @@ encode_hex(char *dest, const unsigned char *source, size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: FileSpec::stream_hex -// Access: Private, Static -// Description: Writes the indicated buffer as a string of hex -// characters to the given ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated buffer as a string of hex characters to the given + * ostream. + */ void FileSpec:: stream_hex(ostream &out, const unsigned char *source, size_t size) { for (size_t i = 0; i < size; ++i) { diff --git a/direct/src/plugin/fileSpec.h b/direct/src/plugin/fileSpec.h index 55e5bea09f..8dc39aebcf 100644 --- a/direct/src/plugin/fileSpec.h +++ b/direct/src/plugin/fileSpec.h @@ -1,16 +1,15 @@ -// Filename: fileSpec.h -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileSpec.h + * @author drose + * @date 2009-06-29 + */ #ifndef FILESPEC_H #define FILESPEC_H @@ -19,13 +18,11 @@ #include using namespace std; -//////////////////////////////////////////////////////////////////// -// Class : FileSpec -// Description : This simple class is used both within the core API in -// this module, as well as within the plugin_npapi -// plugin implementation, to represent a file on disk -// that may need to be verified or (re)downloaded. -//////////////////////////////////////////////////////////////////// +/** + * This simple class is used both within the core API in this module, as well + * as within the plugin_npapi plugin implementation, to represent a file on + * disk that may need to be verified or (re)downloaded. + */ class FileSpec { public: FileSpec(); @@ -42,13 +39,13 @@ public: inline size_t get_size() const; inline time_t get_timestamp() const; inline bool has_hash() const; - + bool quick_verify(const string &package_dir); bool quick_verify_pathname(const string &pathname); bool full_verify(const string &package_dir); inline const FileSpec *get_actual_file() const; const FileSpec *force_get_actual_file(const string &pathname); - + bool check_hash(const string &pathname) const; bool read_hash(const string &pathname); bool read_hash_stream(istream &in); diff --git a/direct/src/plugin/find_root_dir.cxx b/direct/src/plugin/find_root_dir.cxx index f2750ca91c..0cf4546a0e 100644 --- a/direct/src/plugin/find_root_dir.cxx +++ b/direct/src/plugin/find_root_dir.cxx @@ -1,16 +1,15 @@ -// Filename: find_root_dir.cxx -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file find_root_dir.cxx + * @author drose + * @date 2009-06-29 + */ #include "find_root_dir.h" #include "mkdir_complete.h" @@ -34,17 +33,15 @@ const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } DEFINE_KNOWN_FOLDER(FOLDERID_LocalAppData, 0xF1B32785, 0x6FBA, 0x4FCF, 0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91); DEFINE_KNOWN_FOLDER(FOLDERID_LocalAppDataLow, 0xA520A1A4, 0x1780, 0x4FF6, 0xBD, 0x18, 0x16, 0x73, 0x43, 0xC5, 0xAF, 0x16); -DEFINE_KNOWN_FOLDER(FOLDERID_InternetCache, 0x352481E8, 0x33BE, 0x4251, 0xBA, 0x85, 0x60, 0x07, 0xCA, 0xED, 0xCF, 0x9D); +DEFINE_KNOWN_FOLDER(FOLDERID_InternetCache, 0x352481E8, 0x33BE, 0x4251, 0xBA, 0x85, 0x60, 0x07, 0xCA, 0xED, 0xCF, 0x9D); #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: get_csidl_dir_w -// Description: A wrapper around SHGetSpecialFolderPath(), to return -// the Panda3D directory under the indicated CSIDL -// folder. -//////////////////////////////////////////////////////////////////// +/** + * A wrapper around SHGetSpecialFolderPath(), to return the Panda3D directory + * under the indicated CSIDL folder. + */ static wstring get_csidl_dir_w(int csidl) { static const int buffer_size = MAX_PATH; @@ -52,7 +49,7 @@ get_csidl_dir_w(int csidl) { if (SHGetSpecialFolderPathW(NULL, buffer, csidl, true)) { wstring root = buffer; root += wstring(L"/Panda3D"); - + if (mkdir_complete_w(root, cerr)) { return root; } @@ -64,15 +61,14 @@ get_csidl_dir_w(int csidl) { #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: find_root_dir_default_w -// Description: Wide-character implementation of -// find_root_dir_default(), only needed for Windows. -//////////////////////////////////////////////////////////////////// +/** + * Wide-character implementation of find_root_dir_default(), only needed for + * Windows. + */ static wstring find_root_dir_default_w() { - // First, use IEIsProtectedModeProcess() to determine if we are - // running in IE's "protected mode" under Vista. + // First, use IEIsProtectedModeProcess() to determine if we are running in + // IE's "protected mode" under Vista. wstring root; bool is_protected = false; @@ -86,24 +82,24 @@ find_root_dir_default_w() { if (hr == S_OK) { is_protected = (result != 0); } - // Any other return value means some error, especially - // E_NOTIMPL, which means we're not running under Vista. In - // this case we can assume we're not running in protected mode. + // Any other return value means some error, especially E_NOTIMPL, which + // means we're not running under Vista. In this case we can assume + // we're not running in protected mode. } if (is_protected) { // If we *are* running in protected mode, we need to use // FOLDERID_LocalAppDataLow. - - // We should be able to use IEGetWriteableFolderPath() to query - // this folder, but for some reason, that function returns - // E_ACCESSDENIED on FOLDERID_LocalAppDataLow, even though this is - // certainly a folder we have write access to. - - // Well, SHGetKnownFolderPath() does work. This function only - // exists on Vista and above, though, so we still have to pull it - // out of the DLL instead of hard-linking it. - + + // We should be able to use IEGetWriteableFolderPath() to query this + // folder, but for some reason, that function returns E_ACCESSDENIED on + // FOLDERID_LocalAppDataLow, even though this is certainly a folder we + // have write access to. + + // Well, SHGetKnownFolderPath() does work. This function only exists on + // Vista and above, though, so we still have to pull it out of the DLL + // instead of hard-linking it. + HMODULE shell32 = LoadLibrary("shell32.dll"); if (shell32 != NULL) { typedef HRESULT STDAPICALLTYPE SHGetKnownFolderPath(REFGUID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); @@ -111,11 +107,11 @@ find_root_dir_default_w() { if (func != NULL) { LPWSTR cache_path = NULL; HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, 0, NULL, &cache_path); - + if (SUCCEEDED(hr)) { root = cache_path; CoTaskMemFree(cache_path); - + root += wstring(L"/Panda3D"); if (mkdir_complete_w(root, cerr)) { FreeLibrary(shell32); @@ -126,17 +122,17 @@ find_root_dir_default_w() { } FreeLibrary(shell32); } - - // Couldn't get FOLDERID_LocalAppDataLow for some reason. We're - // in fallback mode now. Use IEGetWriteableFolderPath to get - // the standard cache folder. + + // Couldn't get FOLDERID_LocalAppDataLow for some reason. We're in + // fallback mode now. Use IEGetWriteableFolderPath to get the standard + // cache folder. typedef HRESULT STDAPICALLTYPE IEGetWriteableFolderPath(REFGUID clsidFolderID, LPWSTR* lppwstrPath); IEGetWriteableFolderPath *func = (IEGetWriteableFolderPath *)GetProcAddress(ieframe, "IEGetWriteableFolderPath"); if (func != NULL) { LPWSTR cache_path = NULL; - // Since we're here, we'll start by asking for - // LocalAppDataLow, even though I know it doesn't work. + // Since we're here, we'll start by asking for LocalAppDataLow, even + // though I know it doesn't work. HRESULT hr = (*func)(FOLDERID_LocalAppDataLow, &cache_path); if (FAILED(hr)) { // This one should work. @@ -150,7 +146,7 @@ find_root_dir_default_w() { if (mkdir_complete_w(root, cerr)) { FreeLibrary(ieframe); return root; - } + } } } } @@ -158,26 +154,28 @@ find_root_dir_default_w() { FreeLibrary(ieframe); } - // All right, here we are in the normal, unprotected mode. This is - // also the normal XP codepath. + // All right, here we are in the normal, unprotected mode. This is also the + // normal XP codepath. - // e.g., c:/Documents and Settings//Local Settings/Application Data/Panda3D + // e.g., c:Documents and SettingsLocal SettingsApplication + // DataPanda3D root = get_csidl_dir_w(CSIDL_LOCAL_APPDATA); if (!root.empty()) { return root; } - // For some crazy reason, we can't get CSIDL_LOCAL_APPDATA. Fall - // back to the cache folder. + // For some crazy reason, we can't get CSIDL_LOCAL_APPDATA. Fall back to + // the cache folder. - // e.g. c:/Documents and Settings//Local Settings/Temporary Internet Files/Panda3D + // e.g. c:Documents and SettingsLocal SettingsTemporary Internet + // FilesPanda3D root = get_csidl_dir_w(CSIDL_INTERNET_CACHE); if (!root.empty()) { return root; } - - // If we couldn't get any of those folders, huh. Punt and try for - // the old standby GetTempPath, for lack of anything better. + + // If we couldn't get any of those folders, huh. Punt and try for the old + // standby GetTempPath, for lack of anything better. static const int buffer_size = MAX_PATH; wchar_t buffer[buffer_size]; if (GetTempPathW(buffer_size, buffer) != 0) { @@ -193,11 +191,10 @@ find_root_dir_default_w() { #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: find_root_dir_default -// Description: Returns the path to the system-default for the root -// directory. This is where we look first. -//////////////////////////////////////////////////////////////////// +/** + * Returns the path to the system-default for the root directory. This is + * where we look first. + */ static string find_root_dir_default() { #ifdef _WIN32 @@ -210,14 +207,14 @@ find_root_dir_default() { } #elif defined(__APPLE__) - // e.g., /Users//Library/Caches/Panda3D + // e.g., UsersLibraryCachesPanda3D string root = find_osx_root_dir(); if (!root.empty()) { return root; } #else // The Linux/*BSD case - // e.g., /home//.panda3d + // e.g., home.panda3d string root; const passwd *pwdata = getpwuid(getuid()); @@ -232,7 +229,7 @@ find_root_dir_default() { } else { root = pwdata->pw_dir; } - + root += "/.panda3d"; if (mkdir(root.c_str(), 0700) == 0 || errno == EEXIST) { return root; @@ -245,17 +242,16 @@ find_root_dir_default() { } -//////////////////////////////////////////////////////////////////// -// Function: find_root_dir_actual -// Description: Returns the path to the installable Panda3D directory -// on the user's machine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the path to the installable Panda3D directory on the user's + * machine. + */ static string find_root_dir_actual() { string root = find_root_dir_default(); - // Now look for a config.xml file in that directory, which might - // redirect us elsewhere. + // Now look for a config.xml file in that directory, which might redirect us + // elsewhere. string config_filename = root + "/config.xml"; TiXmlDocument doc(config_filename); if (!doc.LoadFile()) { @@ -284,22 +280,21 @@ find_root_dir_actual() { return new_root; } -//////////////////////////////////////////////////////////////////// -// Function: find_root_dir -// Description: This is the public interface to the above functions. -//////////////////////////////////////////////////////////////////// +/** + * This is the public interface to the above functions. + */ string find_root_dir() { string root = find_root_dir_actual(); #ifdef _WIN32 - // Now map that (possibly utf-8) filename into its 8.3 equivalent, - // so we can safely pass it around to Python and other tools that - // might not understand Unicode filenames. Silly Windows, creating - // an entirely new and incompatible kind of filename. + // Now map that (possibly utf-8) filename into its 8.3 equivalent, so we can + // safely pass it around to Python and other tools that might not understand + // Unicode filenames. Silly Windows, creating an entirely new and + // incompatible kind of filename. wstring root_w; string_to_wstring(root_w, root); - + DWORD length = GetShortPathNameW(root_w.c_str(), NULL, 0); wchar_t *short_name = new wchar_t[length]; GetShortPathNameW(root_w.c_str(), short_name, length); diff --git a/direct/src/plugin/find_root_dir.h b/direct/src/plugin/find_root_dir.h index 55d9381621..cdbb25ec91 100644 --- a/direct/src/plugin/find_root_dir.h +++ b/direct/src/plugin/find_root_dir.h @@ -1,16 +1,15 @@ -// Filename: find_root_dir.h -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file find_root_dir.h + * @author drose + * @date 2009-06-29 + */ #ifndef FIND_ROOT_DIR_H #define FIND_ROOT_DIR_H diff --git a/direct/src/plugin/find_root_dir_assist.mm b/direct/src/plugin/find_root_dir_assist.mm index fb43c845d7..e4eed157a6 100644 --- a/direct/src/plugin/find_root_dir_assist.mm +++ b/direct/src/plugin/find_root_dir_assist.mm @@ -1,16 +1,15 @@ -// Filename: find_root_dir_assist.mm -// Created by: drose (13Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file find_root_dir_assist.mm + * @author drose + * @date 2009-04-13 + */ #include "find_root_dir.h" @@ -19,10 +18,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: NSString_to_cpp_string -// Description: Copy the Objective-C string to a C++ string. -//////////////////////////////////////////////////////////////////// +/** + * Copy the Objective-C string to a C++ string. + */ static string NSString_to_cpp_string(NSString *str) { size_t length = [str length]; @@ -34,14 +32,13 @@ NSString_to_cpp_string(NSString *str) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: call_NSSearchPathForDirectories -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static string call_NSSearchPathForDirectories(NSSearchPathDirectory dirkey, NSSearchPathDomainMask domain) { - // Ensure that Carbon has been initialized, and that we have an - // auto-release pool. + // Ensure that Carbon has been initialized, and that we have an auto-release + // pool. NSApplicationLoad(); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -55,10 +52,9 @@ call_NSSearchPathForDirectories(NSSearchPathDirectory dirkey, NSSearchPathDomain return result; } -//////////////////////////////////////////////////////////////////// -// Function: get_osx_home_directory -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static string get_osx_home_directory() { NSApplicationLoad(); @@ -71,10 +67,9 @@ get_osx_home_directory() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: find_osx_root_dir -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string find_osx_root_dir() { string result = call_NSSearchPathForDirectories(NSCachesDirectory, NSUserDomainMask); diff --git a/direct/src/plugin/get_tinyxml.h b/direct/src/plugin/get_tinyxml.h index 4ca3106047..12f12f054d 100644 --- a/direct/src/plugin/get_tinyxml.h +++ b/direct/src/plugin/get_tinyxml.h @@ -1,23 +1,22 @@ -// Filename: get_tinyxml.h -// Created by: drose (01Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file get_tinyxml.h + * @author drose + * @date 2009-07-01 + */ #ifndef GET_TINYXML_H #define GET_TINYXML_H -// This header file exists just to include tinyxml.h safely. We need -// this since tinyxml.h requires having the symbol TIXML_USE_STL -// already defined before you include it. +// This header file exists just to include tinyxml.h safely. We need this +// since tinyxml.h requires having the symbol TIXML_USE_STL already defined +// before you include it. #ifndef TIXML_USE_STL #define TIXML_USE_STL diff --git a/direct/src/plugin/get_twirl_data.cxx b/direct/src/plugin/get_twirl_data.cxx index d0a5ad2d74..1022790978 100644 --- a/direct/src/plugin/get_twirl_data.cxx +++ b/direct/src/plugin/get_twirl_data.cxx @@ -1,16 +1,15 @@ -// Filename: get_twirl_data.cxx -// Created by: drose (24Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file get_twirl_data.cxx + * @author drose + * @date 2011-08-24 + */ #include "get_twirl_data.h" #include "string.h" @@ -38,9 +37,8 @@ static twirl_flip twirl_flip_table[twirl_num_steps + 1] = { { 3, false, false, false } // the "failed" icon }; -// These tables are the raw data for the twirl icon data. They're -// extracted with bin2c from the three layers of twirl.xcf, in this -// directory. +// These tables are the raw data for the twirl icon data. They're extracted +// with bin2c from the three layers of twirl.xcf, in this directory. static const unsigned char twirl_0_data[] = { 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xff, 0xfe, 0xfe, 0xfe, 0xfe, 0xff, @@ -902,24 +900,20 @@ static const unsigned char * const twirl_data[4] = { }; -//////////////////////////////////////////////////////////////////// -// Function: get_twirl_data -// Description: Fills the indicated data array with a string of -// twirl_width * twirl_height * 3 bytes, representing -// the RGB pixel values of the twirl_width x -// twirl_height image at frame number step of -// twirl_num_steps frames. The specified fg and bg -// colors are applied to the array appropriately. -// -// Returns true on success, false on failure. On false, -// the array is initialized with zero. -// -// You must pass data_length = twirl_width * -// twirl_height * 3; this value is passed as a sanity -// check on array size. You should pass step so that 0 -// <= step < twirl_num_steps + 1. (The special value of -// step == twirl_num_steps returns the "failed" icon.) -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated data array with a string of twirl_width * twirl_height + * * 3 bytes, representing the RGB pixel values of the twirl_width x + * twirl_height image at frame number step of twirl_num_steps frames. The + * specified fg and bg colors are applied to the array appropriately. + * + * Returns true on success, false on failure. On false, the array is + * initialized with zero. + * + * You must pass data_length = twirl_width * twirl_height * 3; this value is + * passed as a sanity check on array size. You should pass step so that 0 <= + * step < twirl_num_steps + 1. (The special value of step == twirl_num_steps + * returns the "failed" icon.) + */ bool get_twirl_data(unsigned char data[], size_t data_length, int step, int fg_r, int fg_g, int fg_b, @@ -967,4 +961,3 @@ get_twirl_data(unsigned char data[], size_t data_length, int step, return true; } - diff --git a/direct/src/plugin/get_twirl_data.h b/direct/src/plugin/get_twirl_data.h index f9c9d81577..3b021a01e4 100644 --- a/direct/src/plugin/get_twirl_data.h +++ b/direct/src/plugin/get_twirl_data.h @@ -1,16 +1,15 @@ -// Filename: get_twirl_data.h -// Created by: drose (24Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file get_twirl_data.h + * @author drose + * @date 2011-08-24 + */ #ifndef GET_TWIRL_DATA_H #define GET_TWIRL_DATA_H @@ -26,4 +25,3 @@ bool get_twirl_data(unsigned char data[], size_t data_length, int step, int bg_r, int bg_g, int bg_b); #endif - diff --git a/direct/src/plugin/handleStream.I b/direct/src/plugin/handleStream.I index 5c215e9099..5003b98e82 100644 --- a/direct/src/plugin/handleStream.I +++ b/direct/src/plugin/handleStream.I @@ -1,43 +1,35 @@ -// Filename: handleStream.I -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStream.I + * @author drose + * @date 2009-06-05 + */ -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline HandleStream:: HandleStream() : iostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline HandleStream:: ~HandleStream() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::open_read -// Access: Public -// Description: Attempts to open the given handle for input. The -// stream may not be simultaneously open for input and -// output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the given handle for input. The stream may not be + * simultaneously open for input and output. + */ inline void HandleStream:: open_read(FHandle handle) { clear((ios::iostate)0); @@ -47,13 +39,10 @@ open_read(FHandle handle) { } } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::open_write -// Access: Public -// Description: Attempts to open the given handle for output. The -// stream may not be simultaneously open for input and -// output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the given handle for output. The stream may not be + * simultaneously open for input and output. + */ inline void HandleStream:: open_write(FHandle handle) { clear((ios::iostate)0); @@ -63,47 +52,36 @@ open_write(FHandle handle) { } } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::close -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void HandleStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::close_handle -// Access: Public -// Description: Closes the underlying handle, *without* attempting to -// flush the stream. -//////////////////////////////////////////////////////////////////// +/** + * Closes the underlying handle, *without* attempting to flush the stream. + */ inline void HandleStream:: close_handle() { _buf.close_handle(); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::get_handle -// Access: Public -// Description: Returns the handle that was passed to open_read() or -// open_write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the handle that was passed to open_read() or open_write(). + */ inline FHandle HandleStream:: get_handle() const { return _buf.get_handle(); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStream::has_gdata -// Access: Public -// Description: Returns true if there is data in the stream's "get" -// buffer, meaning that at least one character can be -// extracted from the stream without making an OS read() -// call. Returns false if the get buffer is empty, -// meaning the next read call will hit the OS. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is data in the stream's "get" buffer, meaning that at + * least one character can be extracted from the stream without making an OS + * read() call. Returns false if the get buffer is empty, meaning the next + * read call will hit the OS. + */ inline bool HandleStream:: has_gdata() const { return _buf.has_gdata(); diff --git a/direct/src/plugin/handleStream.cxx b/direct/src/plugin/handleStream.cxx index 36ed98522a..5d6580f493 100644 --- a/direct/src/plugin/handleStream.cxx +++ b/direct/src/plugin/handleStream.cxx @@ -1,15 +1,14 @@ -// Filename: handleStream.cxx -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStream.cxx + * @author drose + * @date 2009-06-05 + */ #include "handleStream.h" diff --git a/direct/src/plugin/handleStream.h b/direct/src/plugin/handleStream.h index 0b7b0b2804..abe8b0dee3 100644 --- a/direct/src/plugin/handleStream.h +++ b/direct/src/plugin/handleStream.h @@ -1,29 +1,26 @@ -// Filename: handleStream.h -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStream.h + * @author drose + * @date 2009-06-05 + */ #ifndef HANDLESTREAM_H #define HANDLESTREAM_H #include "handleStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : HandleStream -// Description : Implements a C++ stream object suitable for reading -// from and writing to Windows' HANDLE objects, or Posix -// file descriptors. This is necessary to map low-level -// pipes into an iostream for tinyxml. -//////////////////////////////////////////////////////////////////// +/** + * Implements a C++ stream object suitable for reading from and writing to + * Windows' HANDLE objects, or Posix file descriptors. This is necessary to + * map low-level pipes into an iostream for tinyxml. + */ class HandleStream : public iostream { public: inline HandleStream(); diff --git a/direct/src/plugin/handleStreamBuf.I b/direct/src/plugin/handleStreamBuf.I index c55d808822..24036ee9d3 100644 --- a/direct/src/plugin/handleStreamBuf.I +++ b/direct/src/plugin/handleStreamBuf.I @@ -1,38 +1,30 @@ -// Filename: handleStreamBuf.I -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStreamBuf.I + * @author drose + * @date 2009-06-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::get_handle -// Access: Public -// Description: Returns the handle that was passed to open_read() or -// open_write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the handle that was passed to open_read() or open_write(). + */ inline FHandle HandleStreamBuf:: get_handle() const { return _handle; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::has_gdata -// Access: Public -// Description: Returns true if there is data in the stream's "get" -// buffer, meaning that at least one character can be -// extracted from the stream without making an OS read() -// call. Returns false if the get buffer is empty, -// meaning the next read call will hit the OS. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is data in the stream's "get" buffer, meaning that at + * least one character can be extracted from the stream without making an OS + * read() call. Returns false if the get buffer is empty, meaning the next + * read call will hit the OS. + */ inline bool HandleStreamBuf:: has_gdata() const { return (egptr() != gptr()); diff --git a/direct/src/plugin/handleStreamBuf.cxx b/direct/src/plugin/handleStreamBuf.cxx index e1d1ba8a47..c3aa4dc76f 100644 --- a/direct/src/plugin/handleStreamBuf.cxx +++ b/direct/src/plugin/handleStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: handleStreamBuf.cxx -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStreamBuf.cxx + * @author drose + * @date 2009-06-05 + */ #include "handleStreamBuf.h" @@ -31,16 +30,14 @@ static const size_t handle_buffer_size = 4096; -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HandleStreamBuf:: HandleStreamBuf() { _is_open_read = false; _is_open_write = false; - + _handle = invalid_fhandle; INIT_LOCK(_lock); @@ -51,11 +48,9 @@ HandleStreamBuf() { setp(_buffer, ebuf); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HandleStreamBuf:: ~HandleStreamBuf() { close(); @@ -65,13 +60,10 @@ HandleStreamBuf:: DESTROY_LOCK(_lock); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::open_read -// Access: Public -// Description: Attempts to open the given handle for input. The -// stream may not be simultaneously open for input and -// output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the given handle for input. The stream may not be + * simultaneously open for input and output. + */ void HandleStreamBuf:: open_read(FHandle handle) { close(); @@ -80,13 +72,10 @@ open_read(FHandle handle) { _is_open_read = true; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::open_write -// Access: Public -// Description: Attempts to open the given handle for output. The -// stream may not be simultaneously open for input and -// output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the given handle for output. The stream may not be + * simultaneously open for input and output. + */ void HandleStreamBuf:: open_write(FHandle handle) { close(); @@ -95,33 +84,25 @@ open_write(FHandle handle) { _is_open_write = true; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::is_open_read -// Access: Public -// Description: Returns true if the file is open for input, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file is open for input, false otherwise. + */ bool HandleStreamBuf:: is_open_read() const { return _is_open_read; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::is_open_write -// Access: Public -// Description: Returns true if the file is open for output, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file is open for output, false otherwise. + */ bool HandleStreamBuf:: is_open_write() const { return _is_open_write; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::close -// Access: Public -// Description: Empties the buffer and closes the file. -//////////////////////////////////////////////////////////////////// +/** + * Empties the buffer and closes the file. + */ void HandleStreamBuf:: close() { // Make sure the write buffer is flushed. @@ -133,12 +114,9 @@ close() { gbump(egptr() - gptr()); } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::close_handle -// Access: Public -// Description: Closes the underlying handle, *without* attempting to -// flush the stream. -//////////////////////////////////////////////////////////////////// +/** + * Closes the underlying handle, *without* attempting to flush the stream. + */ void HandleStreamBuf:: close_handle() { #ifdef _WIN32 @@ -157,12 +135,10 @@ close_handle() { _is_open_write = false; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int HandleStreamBuf:: overflow(int ch) { ACQUIRE_LOCK(_lock); @@ -199,12 +175,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int HandleStreamBuf:: sync() { ACQUIRE_LOCK(_lock); @@ -223,12 +197,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int HandleStreamBuf:: underflow() { ACQUIRE_LOCK(_lock); @@ -263,13 +235,10 @@ underflow() { return next; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::read_chars -// Access: Private -// Description: Attempts to extract the indicated number of -// characters from the current file position. Returns -// the number of characters extracted. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to extract the indicated number of characters from the current + * file position. Returns the number of characters extracted. + */ size_t HandleStreamBuf:: read_chars(char *start, size_t length) { if (length == 0 || !_is_open_read) { @@ -283,7 +252,7 @@ read_chars(char *start, size_t length) { if (length == 0) { return 0; } - + #ifdef _WIN32 // Windows case. DWORD bytes_read = 0; @@ -299,7 +268,7 @@ read_chars(char *start, size_t length) { } length = bytes_read; - + #else // Posix case. ssize_t result = ::read(_handle, start, length); @@ -314,12 +283,9 @@ read_chars(char *start, size_t length) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: HandleStreamBuf::write_chars -// Access: Private -// Description: Outputs the indicated stream of characters to the -// current file position. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated stream of characters to the current file position. + */ size_t HandleStreamBuf:: write_chars(const char *start, size_t length) { if (length == 0) { @@ -334,7 +300,7 @@ write_chars(const char *start, size_t length) { if (length == 0 || !_is_open_write) { return 0; } - + #ifdef _WIN32 // Windows case. DWORD bytes_written = 0; @@ -350,7 +316,7 @@ write_chars(const char *start, size_t length) { return bytes_written; } assert(bytes_written == length); - + #else // Posix case. size_t remaining = length; @@ -362,7 +328,7 @@ write_chars(const char *start, size_t length) { } return length - remaining; } - + start += result; remaining -= result; } diff --git a/direct/src/plugin/handleStreamBuf.h b/direct/src/plugin/handleStreamBuf.h index ae5e4940b9..68486ec69f 100644 --- a/direct/src/plugin/handleStreamBuf.h +++ b/direct/src/plugin/handleStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: handleStreamBuf.h -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file handleStreamBuf.h + * @author drose + * @date 2009-06-05 + */ #ifndef HANDLESTREAMBUF_H #define HANDLESTREAMBUF_H @@ -21,10 +20,9 @@ using namespace std; -//////////////////////////////////////////////////////////////////// -// Class : HandleStreamBuf -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class HandleStreamBuf : public streambuf { public: HandleStreamBuf(); diff --git a/direct/src/plugin/is_pathsep.I b/direct/src/plugin/is_pathsep.I index 129ee105ed..3dd35068b8 100644 --- a/direct/src/plugin/is_pathsep.I +++ b/direct/src/plugin/is_pathsep.I @@ -1,24 +1,20 @@ -// Filename: is_pathsep.I -// Created by: drose (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file is_pathsep.I + * @author drose + * @date 2009-07-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: is_pathsep -// Description: Returns true if the indicated character is a path -// separator character (e.g. slash or backslash), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is a path separator character (e.g. + * slash or backslash), false otherwise. + */ inline bool is_pathsep(int ch) { if (ch == '/') { diff --git a/direct/src/plugin/is_pathsep.h b/direct/src/plugin/is_pathsep.h index 920426f3d3..d1e326ee2d 100644 --- a/direct/src/plugin/is_pathsep.h +++ b/direct/src/plugin/is_pathsep.h @@ -1,16 +1,15 @@ -// Filename: is_pathsep.h -// Created by: drose (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file is_pathsep.h + * @author drose + * @date 2009-07-07 + */ #ifndef IS_PATHSEP_H #define IS_PATHSEP_H diff --git a/direct/src/plugin/load_plugin.cxx b/direct/src/plugin/load_plugin.cxx index 8a8e5ef179..f5a730eacb 100644 --- a/direct/src/plugin/load_plugin.cxx +++ b/direct/src/plugin/load_plugin.cxx @@ -1,16 +1,15 @@ -// Filename: load_plugin.cxx -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_plugin.cxx + * @author drose + * @date 2009-06-19 + */ #include "load_plugin.h" #include "p3d_plugin_config.h" @@ -85,25 +84,21 @@ static bool plugin_loaded = false; static bool dso_needs_unload = false; -//////////////////////////////////////////////////////////////////// -// Function: get_plugin_basename -// Description: Returns the default plugin filename, without any -// directory path (but including the extension -// appropriate to this platform). -//////////////////////////////////////////////////////////////////// +/** + * Returns the default plugin filename, without any directory path (but + * including the extension appropriate to this platform). + */ string get_plugin_basename() { return default_plugin_filename + dll_ext; } -//////////////////////////////////////////////////////////////////// -// Function: find_extension_dot -// Description: Returns the position in the string of the dot before -// the filename extension; that is, the position of the -// rightmost dot that is right of the rightmost slash -// (or backslash, on Windows). Returns string::npos if -// there is no extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position in the string of the dot before the filename + * extension; that is, the position of the rightmost dot that is right of the + * rightmost slash (or backslash, on Windows). Returns string::npos if there + * is no extension. + */ static size_t find_extension_dot(const string &filename) { size_t p = filename.length(); @@ -120,22 +115,19 @@ find_extension_dot(const string &filename) { // Forward reference for function defined below. static void unload_dso(); -//////////////////////////////////////////////////////////////////// -// Function: load_plugin -// Description: Loads the plugin and assigns all of the function -// pointers. Returns true on success, false on failure. -// If load_plugin() has already been called -// successfully, this returns true immediately, without -// parsing any parameters. -// -// If p3d_plugin_filename is empty, the module is -// assumed to be already loaded (or statically linked -// in), and the symbols are located within the current -// address space. -//////////////////////////////////////////////////////////////////// +/** + * Loads the plugin and assigns all of the function pointers. Returns true on + * success, false on failure. If load_plugin() has already been called + * successfully, this returns true immediately, without parsing any + * parameters. + * + * If p3d_plugin_filename is empty, the module is assumed to be already loaded + * (or statically linked in), and the symbols are located within the current + * address space. + */ bool -load_plugin(const string &p3d_plugin_filename, - const string &contents_filename, const string &host_url, +load_plugin(const string &p3d_plugin_filename, + const string &contents_filename, const string &host_url, P3D_verify_contents verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, @@ -158,16 +150,16 @@ load_plugin(const string &p3d_plugin_filename, // If a filename is supplied, attempt to load it as a dynamic library. // On Windows, the filename passed to LoadLibrary() must have an - // extension, or a default ".DLL" will be implicitly added. If the - // file actually has no extension, we must add "." to avoid this. - + // extension, or a default ".DLL" will be implicitly added. If the file + // actually has no extension, we must add "." to avoid this. + // Check whether the filename has an extension. size_t extension_dot = find_extension_dot(filename); if (extension_dot == string::npos) { // No extension. filename += "."; } - + SetErrorMode(0); wstring filename_w; if (string_to_wstring(filename_w, filename)) { @@ -178,8 +170,8 @@ load_plugin(const string &p3d_plugin_filename, if (module == NULL) { // Couldn't load the DLL. - logfile - << "Couldn't load " << filename << ", error = " + logfile + << "Couldn't load " << filename << ", error = " << GetLastError() << "\n"; return false; } @@ -211,15 +203,15 @@ load_plugin(const string &p3d_plugin_filename, #endif // _WIN32 // Now get all of the function pointers. - P3D_initialize_ptr = (P3D_initialize_func *)get_func(module, "P3D_initialize"); - P3D_finalize_ptr = (P3D_finalize_func *)get_func(module, "P3D_finalize"); - P3D_set_plugin_version_ptr = (P3D_set_plugin_version_func *)get_func(module, "P3D_set_plugin_version"); - P3D_set_super_mirror_ptr = (P3D_set_super_mirror_func *)get_func(module, "P3D_set_super_mirror"); - P3D_new_instance_ptr = (P3D_new_instance_func *)get_func(module, "P3D_new_instance"); - P3D_instance_start_ptr = (P3D_instance_start_func *)get_func(module, "P3D_instance_start"); - P3D_instance_start_stream_ptr = (P3D_instance_start_stream_func *)get_func(module, "P3D_instance_start_stream"); - P3D_instance_finish_ptr = (P3D_instance_finish_func *)get_func(module, "P3D_instance_finish"); - P3D_instance_setup_window_ptr = (P3D_instance_setup_window_func *)get_func(module, "P3D_instance_setup_window"); + P3D_initialize_ptr = (P3D_initialize_func *)get_func(module, "P3D_initialize"); + P3D_finalize_ptr = (P3D_finalize_func *)get_func(module, "P3D_finalize"); + P3D_set_plugin_version_ptr = (P3D_set_plugin_version_func *)get_func(module, "P3D_set_plugin_version"); + P3D_set_super_mirror_ptr = (P3D_set_super_mirror_func *)get_func(module, "P3D_set_super_mirror"); + P3D_new_instance_ptr = (P3D_new_instance_func *)get_func(module, "P3D_new_instance"); + P3D_instance_start_ptr = (P3D_instance_start_func *)get_func(module, "P3D_instance_start"); + P3D_instance_start_stream_ptr = (P3D_instance_start_stream_func *)get_func(module, "P3D_instance_start_stream"); + P3D_instance_finish_ptr = (P3D_instance_finish_func *)get_func(module, "P3D_instance_finish"); + P3D_instance_setup_window_ptr = (P3D_instance_setup_window_func *)get_func(module, "P3D_instance_setup_window"); P3D_object_get_type_ptr = (P3D_object_get_type_func *)get_func(module, "P3D_object_get_type"); P3D_object_get_bool_ptr = (P3D_object_get_bool_func *)get_func(module, "P3D_object_get_bool"); @@ -244,18 +236,18 @@ load_plugin(const string &p3d_plugin_filename, P3D_instance_get_panda_script_object_ptr = (P3D_instance_get_panda_script_object_func *)get_func(module, "P3D_instance_get_panda_script_object"); P3D_instance_set_browser_script_object_ptr = (P3D_instance_set_browser_script_object_func *)get_func(module, "P3D_instance_set_browser_script_object"); - P3D_instance_get_request_ptr = (P3D_instance_get_request_func *)get_func(module, "P3D_instance_get_request"); - P3D_check_request_ptr = (P3D_check_request_func *)get_func(module, "P3D_check_request"); - P3D_request_finish_ptr = (P3D_request_finish_func *)get_func(module, "P3D_request_finish"); - P3D_instance_feed_url_stream_ptr = (P3D_instance_feed_url_stream_func *)get_func(module, "P3D_instance_feed_url_stream"); - P3D_instance_handle_event_ptr = (P3D_instance_handle_event_func *)get_func(module, "P3D_instance_handle_event"); + P3D_instance_get_request_ptr = (P3D_instance_get_request_func *)get_func(module, "P3D_instance_get_request"); + P3D_check_request_ptr = (P3D_check_request_func *)get_func(module, "P3D_check_request"); + P3D_request_finish_ptr = (P3D_request_finish_func *)get_func(module, "P3D_request_finish"); + P3D_instance_feed_url_stream_ptr = (P3D_instance_feed_url_stream_func *)get_func(module, "P3D_instance_feed_url_stream"); + P3D_instance_handle_event_ptr = (P3D_instance_handle_event_func *)get_func(module, "P3D_instance_handle_event"); #undef get_func // Successfully loaded. plugin_loaded = true; - if (!init_plugin(contents_filename, host_url, + if (!init_plugin(contents_filename, host_url, verify_contents, platform, log_directory, log_basename, trusted_environment, console_environment, @@ -267,18 +259,16 @@ load_plugin(const string &p3d_plugin_filename, return true; } -//////////////////////////////////////////////////////////////////// -// Function: init_plugin -// Description: Ensures all the required function pointers have been -// set, and then calls P3D_initialize() on the -// recently-loaded plugin. Returns true on success, -// false on failure. -// -// It is not necessary to call this after calling -// load_plugin(); it is called implicitly. -//////////////////////////////////////////////////////////////////// +/** + * Ensures all the required function pointers have been set, and then calls + * P3D_initialize() on the recently-loaded plugin. Returns true on success, + * false on failure. + * + * It is not necessary to call this after calling load_plugin(); it is called + * implicitly. + */ bool -init_plugin(const string &contents_filename, const string &host_url, +init_plugin(const string &contents_filename, const string &host_url, P3D_verify_contents verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, @@ -319,13 +309,13 @@ init_plugin(const string &contents_filename, const string &host_url, P3D_new_string_object_ptr == NULL || P3D_instance_get_panda_script_object_ptr == NULL || P3D_instance_set_browser_script_object_ptr == NULL || - + P3D_instance_get_request_ptr == NULL || P3D_check_request_ptr == NULL || P3D_request_finish_ptr == NULL || P3D_instance_feed_url_stream_ptr == NULL || P3D_instance_handle_event_ptr == NULL) { - + logfile << "Some function pointers not found:" << "\nP3D_initialize_ptr = " << P3D_initialize_ptr @@ -371,8 +361,8 @@ init_plugin(const string &contents_filename, const string &host_url, return false; } - // A bit of extra hand-hacked compatibility for using newer plug-ins - // with an older version of the core API. + // A bit of extra hand-hacked compatibility for using newer plug-ins with an + // older version of the core API. int api_version = P3D_API_VERSION; if (api_version == 17 && start_dir.empty()) { api_version = 16; @@ -384,12 +374,12 @@ init_plugin(const string &contents_filename, const string &host_url, if (!P3D_initialize_ptr(api_version, contents_filename.c_str(), host_url.c_str(), verify_contents, platform.c_str(), log_directory.c_str(), log_basename.c_str(), - trusted_environment, console_environment, + trusted_environment, console_environment, root_dir.c_str(), host_dir.c_str(), start_dir.c_str())) { // Oops, failure to initialize. logfile - << "Failed to initialize plugin (passed API version " + << "Failed to initialize plugin (passed API version " << api_version << ")\n"; return false; } @@ -397,11 +387,10 @@ init_plugin(const string &contents_filename, const string &host_url, return true; } -//////////////////////////////////////////////////////////////////// -// Function: unload_plugin -// Description: Calls finalize, then removes the plugin from memory -// space and clears all of the pointers. -//////////////////////////////////////////////////////////////////// +/** + * Calls finalize, then removes the plugin from memory space and clears all of + * the pointers. + */ void unload_plugin(ostream &logfile) { if (!plugin_loaded) { @@ -412,29 +401,26 @@ unload_plugin(ostream &logfile) { unload_dso(); } -//////////////////////////////////////////////////////////////////// -// Function: unload_dso -// Description: Removes the plugin from memory space and clears all -// of the pointers. This is only intended to be called -// by load_plugin(), above, in the specific case that -// the plugin loaded but could not successfully -// initialize itself. All user code should call -// unload_plugin(), above, which first calls -// P3D_finalize(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the plugin from memory space and clears all of the pointers. This + * is only intended to be called by load_plugin(), above, in the specific case + * that the plugin loaded but could not successfully initialize itself. All + * user code should call unload_plugin(), above, which first calls + * P3D_finalize(). + */ static void unload_dso() { if (dso_needs_unload) { assert(module != NULL); #ifdef _WIN32 FreeLibrary(module); -#else +#else dlclose(module); #endif module = NULL; dso_needs_unload = false; } - + P3D_initialize_ptr = NULL; P3D_finalize_ptr = NULL; P3D_set_plugin_version_ptr = NULL; @@ -478,12 +464,10 @@ unload_dso() { plugin_loaded = false; } -//////////////////////////////////////////////////////////////////// -// Function: is_plugin_loaded -// Description: Returns true if the plugin has been loaded -// successfully by a previous call to load_plugin(), -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the plugin has been loaded successfully by a previous call + * to load_plugin(), false otherwise. + */ bool is_plugin_loaded() { return plugin_loaded; diff --git a/direct/src/plugin/load_plugin.h b/direct/src/plugin/load_plugin.h index f9f89565e5..b6a41a3f9c 100644 --- a/direct/src/plugin/load_plugin.h +++ b/direct/src/plugin/load_plugin.h @@ -1,16 +1,15 @@ -// Filename: load_plugin.h -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_plugin.h + * @author drose + * @date 2009-06-19 + */ #ifndef LOAD_PLUGIN_H #define LOAD_PLUGIN_H @@ -61,8 +60,8 @@ extern P3D_instance_feed_url_stream_func *P3D_instance_feed_url_stream_ptr; extern P3D_instance_handle_event_func *P3D_instance_handle_event_ptr; string get_plugin_basename(); -bool -load_plugin(const string &p3d_plugin_filename, +bool +load_plugin(const string &p3d_plugin_filename, const string &contents_filename, const string &host_url, P3D_verify_contents verify_contents, const string &platform, const string &log_directory, const string &log_basename, @@ -70,7 +69,7 @@ load_plugin(const string &p3d_plugin_filename, const string &root_dir, const string &host_dir, const string &start_dir, ostream &logfile); bool -init_plugin(const string &contents_filename, const string &host_url, +init_plugin(const string &contents_filename, const string &host_url, P3D_verify_contents verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, bool console_environment, diff --git a/direct/src/plugin/mkdir_complete.cxx b/direct/src/plugin/mkdir_complete.cxx index f2fb93e7b0..9422ea2e32 100644 --- a/direct/src/plugin/mkdir_complete.cxx +++ b/direct/src/plugin/mkdir_complete.cxx @@ -1,16 +1,15 @@ -// Filename: mkdir_complete.cxx -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mkdir_complete.cxx + * @author drose + * @date 2009-06-29 + */ #include "mkdir_complete.h" #include "is_pathsep.h" @@ -27,12 +26,10 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: get_dirname -// Description: Returns the directory component of the indicated -// pathname, or the empty string if there is no -// directory prefix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory component of the indicated pathname, or the empty + * string if there is no directory prefix. + */ static string get_dirname(const string &filename) { size_t p = filename.length(); @@ -47,11 +44,10 @@ get_dirname(const string &filename) { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: get_dirname_w -// Description: The wide-character implementation of get_dirname(). -// Only implemented (and needed) on Windows. -//////////////////////////////////////////////////////////////////// +/** + * The wide-character implementation of get_dirname(). Only implemented (and + * needed) on Windows. + */ static wstring get_dirname_w(const wstring &filename) { size_t p = filename.length(); @@ -68,13 +64,11 @@ get_dirname_w(const wstring &filename) { -//////////////////////////////////////////////////////////////////// -// Function: mkdir_complete -// Description: Creates a new directory, with normal access -// privileges. Returns true on success, false on -// failure. Will create intervening directories if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new directory, with normal access privileges. Returns true on + * success, false on failure. Will create intervening directories if + * necessary. + */ bool mkdir_complete(const string &dirname, ostream &logfile) { #ifdef _WIN32 @@ -105,8 +99,8 @@ mkdir_complete(const string &dirname, ostream &logfile) { // Got it! return true; } - // Couldn't create the directory. :( - logfile + // Couldn't create the directory. :( + logfile << "Couldn't create " << dirname << ": " << strerror(errno) << "\n"; } } @@ -115,13 +109,11 @@ mkdir_complete(const string &dirname, ostream &logfile) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: mkfile_complete -// Description: Creates a new file with normal access -// priviledges. Returns true on success, false on -// failure. This will create intervening directories if -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new file with normal access priviledges. Returns true on + * success, false on failure. This will create intervening directories if + * needed. + */ bool mkfile_complete(const string &filename, ostream &logfile) { #ifdef _WIN32 @@ -156,12 +148,10 @@ mkfile_complete(const string &filename, ostream &logfile) { #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: mkdir_complete_w -// Description: The wide-character implementation of -// mkdir_complete(). Only implemented (and needed) on -// Windows. -//////////////////////////////////////////////////////////////////// +/** + * The wide-character implementation of mkdir_complete(). Only implemented + * (and needed) on Windows. + */ bool mkdir_complete_w(const wstring &dirname, ostream &logfile) { if (CreateDirectoryW(dirname.c_str(), NULL) != 0) { @@ -185,7 +175,7 @@ mkdir_complete_w(const wstring &dirname, ostream &logfile) { // Got it! return true; } - logfile + logfile << "Couldn't create " << dirname << "\n"; } } @@ -194,12 +184,10 @@ mkdir_complete_w(const wstring &dirname, ostream &logfile) { #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: mkfile_complete_w -// Description: The wide-character implementation of -// mkfile_complete(). Only implemented (and needed) on -// Windows. -//////////////////////////////////////////////////////////////////// +/** + * The wide-character implementation of mkfile_complete(). Only implemented + * (and needed) on Windows. + */ bool mkfile_complete_w(const wstring &filename, ostream &logfile) { // Make sure we delete any previously-existing file first. diff --git a/direct/src/plugin/mkdir_complete.h b/direct/src/plugin/mkdir_complete.h index e9d9d80871..9b9521a9bd 100644 --- a/direct/src/plugin/mkdir_complete.h +++ b/direct/src/plugin/mkdir_complete.h @@ -1,16 +1,15 @@ -// Filename: mkdir_complete.h -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mkdir_complete.h + * @author drose + * @date 2009-06-29 + */ #ifndef MKDIR_COMPLETE_H #define MKDIR_COMPLETE_H @@ -28,5 +27,3 @@ bool mkfile_complete_w(const wstring &dirname, ostream &logfile); #endif // _WIN32 #endif - - diff --git a/direct/src/plugin/p3dAuthSession.I b/direct/src/plugin/p3dAuthSession.I index e36c737988..0e451a8f87 100644 --- a/direct/src/plugin/p3dAuthSession.I +++ b/direct/src/plugin/p3dAuthSession.I @@ -1,14 +1,12 @@ -// Filename: p3dAuthSession.I -// Created by: drose (17Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dAuthSession.I + * @author drose + * @date 2009-09-17 + */ diff --git a/direct/src/plugin/p3dAuthSession.cxx b/direct/src/plugin/p3dAuthSession.cxx index 8fe825f853..46678c19ad 100644 --- a/direct/src/plugin/p3dAuthSession.cxx +++ b/direct/src/plugin/p3dAuthSession.cxx @@ -1,16 +1,15 @@ -// Filename: p3dAuthSession.cxx -// Created by: drose (17Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dAuthSession.cxx + * @author drose + * @date 2009-09-17 + */ #include "p3dAuthSession.h" #include "p3dInstance.h" @@ -31,11 +30,9 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DAuthSession:: P3DAuthSession(P3DInstance *inst) : _inst(inst) @@ -66,8 +63,8 @@ P3DAuthSession(P3DInstance *inst) : inst->_mf_reader.get_signature(0); if (cert_chain.size() > 0) { - // Save the cert_dir, this is where the p3dcert program will - // need to write the cert when it is approved. + // Save the cert_dir, this is where the p3dcert program will need to + // write the cert when it is approved. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _cert_dir = inst_mgr->get_cert_dir(cert_chain[0]._cert); } @@ -84,11 +81,9 @@ P3DAuthSession(P3DInstance *inst) : } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DAuthSession:: ~P3DAuthSession() { shutdown(false); @@ -98,16 +93,14 @@ P3DAuthSession:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::shutdown -// Access: Public -// Description: Terminates the session by killing the subprocess. -//////////////////////////////////////////////////////////////////// +/** + * Terminates the session by killing the subprocess. + */ void P3DAuthSession:: shutdown(bool send_message) { if (!send_message) { - // If we're not to send the instance the shutdown message as a - // result of this, then clear the _inst pointer now. + // If we're not to send the instance the shutdown message as a result of + // this, then clear the _inst pointer now. _inst = NULL; } @@ -120,9 +113,9 @@ shutdown(bool send_message) { #else // _WIN32 kill(_p3dcert_pid, SIGKILL); - // Wait a few milliseconds for the process to exit, and then get - // its return status to clean up the zombie status. If we don't - // wait long enough, don't sweat it. + // Wait a few milliseconds for the process to exit, and then get its + // return status to clean up the zombie status. If we don't wait long + // enough, don't sweat it. struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 100000; @@ -135,20 +128,17 @@ shutdown(bool send_message) { } _p3dcert_started = false; - // Now that the process has stopped, the thread should stop itself - // quickly too. + // Now that the process has stopped, the thread should stop itself quickly + // too. join_wait_thread(); // We're no longer bound to any particular instance. _inst = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::start_p3dcert -// Access: Private -// Description: Starts the p3dcert program running in a child -// process. -//////////////////////////////////////////////////////////////////// +/** + * Starts the p3dcert program running in a child process. + */ void P3DAuthSession:: start_p3dcert() { if (_p3dcert_started) { @@ -268,24 +258,19 @@ start_p3dcert() { spawn_wait_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::spawn_wait_thread -// Access: Private -// Description: Starts the wait thread. This thread is responsible -// for waiting for the process to finish, and notifying -// the instance when it does. -//////////////////////////////////////////////////////////////////// +/** + * Starts the wait thread. This thread is responsible for waiting for the + * process to finish, and notifying the instance when it does. + */ void P3DAuthSession:: spawn_wait_thread() { SPAWN_THREAD(_wait_thread, wt_thread_run, this); _started_wait_thread = true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::join_wait_thread -// Access: Private -// Description: Waits for the wait thread to stop. -//////////////////////////////////////////////////////////////////// +/** + * Waits for the wait thread to stop. + */ void P3DAuthSession:: join_wait_thread() { if (!_started_wait_thread) { @@ -296,14 +281,10 @@ join_wait_thread() { _started_wait_thread = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::write_env -// Access: Private -// Description: Writes _env, which is formatted as a string -// containing zero-byte-terminated environment -// defintions, to the nout stream, one definition per -// line. -//////////////////////////////////////////////////////////////////// +/** + * Writes _env, which is formatted as a string containing zero-byte-terminated + * environment defintions, to the nout stream, one definition per line. + */ void P3DAuthSession:: write_env() const { size_t p = 0; @@ -317,11 +298,9 @@ write_env() const { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::wt_thread_run -// Access: Private -// Description: The main function for the wait thread. -//////////////////////////////////////////////////////////////////// +/** + * The main function for the wait thread. + */ void P3DAuthSession:: wt_thread_run() { // All we do here is wait for the process to terminate. @@ -366,16 +345,13 @@ wt_thread_run() { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::win_create_process -// Access: Private -// Description: Creates a sub-process to run _p3dcert_exe, with -// the appropriate command-line arguments, and the -// environment string defined in _env. -// -// Returns the handle to the created process on success, -// or INVALID_HANDLE_VALUE on falure. -//////////////////////////////////////////////////////////////////// +/** + * Creates a sub-process to run _p3dcert_exe, with the appropriate command- + * line arguments, and the environment string defined in _env. + * + * Returns the handle to the created process on success, or + * INVALID_HANDLE_VALUE on falure. + */ HANDLE P3DAuthSession:: win_create_process() { // Make sure we see an error dialog if there is a missing DLL. @@ -391,25 +367,25 @@ win_create_process() { const char *start_dir_cstr = _start_dir.c_str(); - // Construct the command-line string, containing the quoted - // command-line arguments. + // Construct the command-line string, containing the quoted command-line + // arguments. ostringstream stream; stream << "\"" << _p3dcert_exe << "\" \"" << _cert_filename->get_filename() << "\" \"" << _cert_dir << "\""; - // I'm not sure why CreateProcess wants a non-const char pointer for - // its command-line string, but I'm not taking chances. It gets a - // non-const char array that it can modify. + // I'm not sure why CreateProcess wants a non-const char pointer for its + // command-line string, but I'm not taking chances. It gets a non-const + // char array that it can modify. string command_line_str = stream.str(); char *command_line = new char[command_line_str.size() + 1]; memcpy(command_line, command_line_str.c_str(), command_line_str.size() + 1); nout << "Command line: " << command_line_str << "\n"; - // Something about p3dCert_wx tends to become crashy when we call it - // from CreateProcessW(). Something about the way wx parses the - // command-line parameters? Well, whatever, we don't really need - // the Unicode form anyway. + // Something about p3dCert_wx tends to become crashy when we call it from + // CreateProcessW(). Something about the way wx parses the command-line + // parameters? Well, whatever, we don't really need the Unicode form + // anyway. PROCESS_INFORMATION process_info; BOOL result = CreateProcess (_p3dcert_exe.c_str(), command_line, NULL, NULL, TRUE, @@ -431,16 +407,12 @@ win_create_process() { #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: P3DAuthSession::posix_create_process -// Access: Private -// Description: Creates a sub-process to run _p3dcert_exe, with -// the appropriate command-line arguments, and the -// environment string defined in _env. -// -// Returns the pid of the created process on success, or -// -1 on falure. -//////////////////////////////////////////////////////////////////// +/** + * Creates a sub-process to run _p3dcert_exe, with the appropriate command- + * line arguments, and the environment string defined in _env. + * + * Returns the pid of the created process on success, or -1 on falure. + */ int P3DAuthSession:: posix_create_process() { // Fork and exec. @@ -455,8 +427,8 @@ posix_create_process() { if (chdir(_start_dir.c_str()) < 0) { nout << "Could not chdir to " << _start_dir << "\n"; - // This is a warning, not an error. We don't actually care - // that much about the starting directory. + // This is a warning, not an error. We don't actually care that much + // about the starting directory. } // build up an array of char strings for the environment. diff --git a/direct/src/plugin/p3dAuthSession.h b/direct/src/plugin/p3dAuthSession.h index b653e4780d..3df7894279 100644 --- a/direct/src/plugin/p3dAuthSession.h +++ b/direct/src/plugin/p3dAuthSession.h @@ -1,16 +1,15 @@ -// Filename: p3dAuthSession.h -// Created by: drose (17Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dAuthSession.h + * @author drose + * @date 2009-09-17 + */ #ifndef P3DAUTHSESSION_H #define P3DAUTHSESSION_H @@ -23,14 +22,12 @@ class P3DInstance; -//////////////////////////////////////////////////////////////////// -// Class : P3DAuthSession -// Description : This is an instance of a p3dcert program running in a -// subprocess. There's no communication with the -// process, or none of that complicated stuff the -// P3DSession has to do; all we do here is fire off the -// process, then wait for it to exit. -//////////////////////////////////////////////////////////////////// +/** + * This is an instance of a p3dcert program running in a subprocess. There's + * no communication with the process, or none of that complicated stuff the + * P3DSession has to do; all we do here is fire off the process, then wait for + * it to exit. + */ class P3DAuthSession : public P3DReferenceCount { public: P3DAuthSession(P3DInstance *inst); diff --git a/direct/src/plugin/p3dBoolObject.cxx b/direct/src/plugin/p3dBoolObject.cxx index 6f82e7354d..87736ba216 100644 --- a/direct/src/plugin/p3dBoolObject.cxx +++ b/direct/src/plugin/p3dBoolObject.cxx @@ -1,33 +1,28 @@ -// Filename: p3dBoolObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dBoolObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dBoolObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DBoolObject:: P3DBoolObject(bool value) : _value(value) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DBoolObject:: P3DBoolObject(const P3DBoolObject ©) : P3DObject(copy), @@ -35,44 +30,34 @@ P3DBoolObject(const P3DBoolObject ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DBoolObject:: get_type() { return P3D_OT_bool; } -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DBoolObject:: get_bool() { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DBoolObject:: get_int() { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DBoolObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DBoolObject:: make_string(string &value) { if (_value) { diff --git a/direct/src/plugin/p3dBoolObject.h b/direct/src/plugin/p3dBoolObject.h index e07bf8f691..83a950cb76 100644 --- a/direct/src/plugin/p3dBoolObject.h +++ b/direct/src/plugin/p3dBoolObject.h @@ -1,16 +1,15 @@ -// Filename: p3dBoolObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dBoolObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DBOOLOBJECT_H #define P3DBOOLOBJECT_H @@ -18,10 +17,9 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DBoolObject -// Description : An object type that contains a boolean value. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains a boolean value. + */ class P3DBoolObject : public P3DObject { public: P3DBoolObject(bool value); @@ -38,4 +36,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dCInstance.I b/direct/src/plugin/p3dCInstance.I index 4afd8c3ed1..34edfd6b62 100644 --- a/direct/src/plugin/p3dCInstance.I +++ b/direct/src/plugin/p3dCInstance.I @@ -1,24 +1,19 @@ -// Filename: p3dCInstance.I -// Created by: drose (08Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCInstance.I + * @author drose + * @date 2009-06-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DCInstance::get_instance_id -// Access: Public -// Description: Returns a unique integer for each instance in the -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique integer for each instance in the system. + */ inline int P3DCInstance:: get_instance_id() const { return _instance_id; diff --git a/direct/src/plugin/p3dCInstance.cxx b/direct/src/plugin/p3dCInstance.cxx index 70f6d458ec..d6ecf259f1 100644 --- a/direct/src/plugin/p3dCInstance.cxx +++ b/direct/src/plugin/p3dCInstance.cxx @@ -1,25 +1,22 @@ -// Filename: p3dCInstance.cxx -// Created by: drose (08Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCInstance.cxx + * @author drose + * @date 2009-06-08 + */ #include "p3dCInstance.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DCInstance::Constructor -// Access: Public -// Description: Constructs a new Instance from an XML description. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new Instance from an XML description. + */ P3DCInstance:: P3DCInstance(TiXmlElement *xinstance) : _func(NULL) @@ -27,11 +24,9 @@ P3DCInstance(TiXmlElement *xinstance) : xinstance->Attribute("instance_id", &_instance_id); } -//////////////////////////////////////////////////////////////////// -// Function: P3DCInstance::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DCInstance:: ~P3DCInstance() { } diff --git a/direct/src/plugin/p3dCInstance.h b/direct/src/plugin/p3dCInstance.h index 2e21528c67..40708f7d0c 100644 --- a/direct/src/plugin/p3dCInstance.h +++ b/direct/src/plugin/p3dCInstance.h @@ -1,16 +1,15 @@ -// Filename: p3dCInstance.h -// Created by: drose (08Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCInstance.h + * @author drose + * @date 2009-06-08 + */ #ifndef P3DCINSTANCE_H #define P3DCINSTANCE_H @@ -26,11 +25,10 @@ class P3DSession; -//////////////////////////////////////////////////////////////////// -// Class : P3DCInstance -// Description : This is an instance of a Panda3D window, as seen in -// the child-level process. -//////////////////////////////////////////////////////////////////// +/** + * This is an instance of a Panda3D window, as seen in the child-level + * process. + */ class P3DCInstance : public P3D_instance { public: P3DCInstance(TiXmlElement *xinstance); diff --git a/direct/src/plugin/p3dCert.cxx b/direct/src/plugin/p3dCert.cxx index 0d84e1058e..bae39a3c76 100644 --- a/direct/src/plugin/p3dCert.cxx +++ b/direct/src/plugin/p3dCert.cxx @@ -1,16 +1,15 @@ -// Filename: p3dCert.cxx -// Created by: rdb (08Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert.cxx + * @author rdb + * @date 2011-03-08 + */ #include "p3dCert.h" #include "p3dCert_strings.h" @@ -51,8 +50,8 @@ static LanguageIndex li = LI_default; #if defined(_WIN32) static LanguageIndex detect_language() { - // This function was introduced in Windows Vista; it may not be available - // on older systems. + // This function was introduced in Windows Vista; it may not be available on + // older systems. typedef BOOL (*GUPL)(DWORD, PULONG, PZZWSTR, PULONG); GUPL pGetUserPreferredUILanguages = (GUPL)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), TEXT("GetUserPreferredUILanguages")); @@ -231,11 +230,9 @@ int main(int argc, char **argv) { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ #ifdef _WIN32 AuthDialog:: AuthDialog(const wstring &cert_filename, const wstring &cert_dir) : @@ -262,11 +259,9 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : layout(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AuthDialog:: ~AuthDialog() { if (_view_cert_dialog != NULL) { @@ -283,22 +278,18 @@ AuthDialog:: } } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "Run" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Run" button. + */ void AuthDialog:: run_clicked(Fl_Widget *w, void *data) { AuthDialog *dlg = (AuthDialog *) data; dlg->approve_cert(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "View Certificate" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "View Certificate" button. + */ void AuthDialog:: view_cert_clicked(Fl_Widget *w, void *data) { AuthDialog *dlg = (AuthDialog *) data; @@ -311,24 +302,19 @@ view_cert_clicked(Fl_Widget *w, void *data) { dlg->_view_cert_dialog->show(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "Cancel" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Cancel" button. + */ void AuthDialog:: cancel_clicked(Fl_Widget *w, void *data) { AuthDialog *dlg = (AuthDialog *) data; dlg->hide(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::approve_cert -// Access: Public -// Description: Writes the certificate into the _cert_dir, so -// that it will be found by the P3DInstanceManager and -// known to be approved. -//////////////////////////////////////////////////////////////////// +/** + * Writes the certificate into the _cert_dir, so that it will be found by the + * P3DInstanceManager and known to be approved. + */ void AuthDialog:: approve_cert() { assert(_cert != NULL); @@ -344,8 +330,8 @@ approve_cert() { int i = 1; size_t buf_length = _cert_dir.length() + 100; - // Sure, there's a slight race condition right now: another process - // might attempt to create the same filename. So what. + // Sure, there's a slight race condition right now: another process might + // attempt to create the same filename. So what. FILE *fp = NULL; #ifdef _WIN32 @@ -388,12 +374,10 @@ approve_cert() { hide(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::read_cert_file -// Access: Private -// Description: Reads the list of certificates in the pem filename -// passed on the command line into _cert and _stack. -//////////////////////////////////////////////////////////////////// +/** + * Reads the list of certificates in the pem filename passed on the command + * line into _cert and _stack. + */ #ifdef _WIN32 void AuthDialog:: read_cert_file(const wstring &cert_filename) { @@ -439,12 +423,10 @@ read_cert_file(const string &cert_filename) { fclose(fp); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::get_friendly_name -// Access: Private -// Description: Extracts the "friendly name" from the certificate: -// the common name or email name. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the "friendly name" from the certificate: the common name or email + * name. + */ void AuthDialog:: get_friendly_name() { if (_cert == NULL) { @@ -468,15 +450,15 @@ get_friendly_name() { if (xname != NULL) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { - // We just get the first common name. I guess it's possible to - // have more than one; not sure what that means in this context. + // We just get the first common name. I guess it's possible to have + // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); if (xentry != NULL) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); if (data != NULL) { - // We use "print" to dump the output to a memory BIO. Is - // there an easier way to decode the ASN1_STRING? Curse - // these incomplete docs. + // We use "print" to dump the output to a memory BIO. Is there an + // easier way to decode the ASN1_STRING? Curse these incomplete + // docs. BIO *mbio = BIO_new(BIO_s_mem()); ASN1_STRING_print_ex(mbio, data, ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB); @@ -492,12 +474,10 @@ get_friendly_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::verify_cert -// Access: Private -// Description: Checks whether the certificate is valid by the chain -// and initializes _verify_status accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the certificate is valid by the chain and initializes + * _verify_status accordingly. + */ void AuthDialog:: verify_cert() { if (_cert == NULL) { @@ -531,19 +511,15 @@ verify_cert() { << ", verify_result = " << _verify_result << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::load_certificates_from_der_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be DER-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be DER- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ int AuthDialog:: load_certificates_from_der_ram(X509_STORE *store, const char *data, size_t data_size) { @@ -569,11 +545,9 @@ load_certificates_from_der_ram(X509_STORE *store, return count; } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::layout -// Access: Private -// Description: Arranges the text and controls within the dialog. -//////////////////////////////////////////////////////////////////// +/** + * Arranges the text and controls within the dialog. + */ void AuthDialog:: layout() { get_text(_header, sizeof _header, _text, sizeof _text); @@ -635,12 +609,10 @@ layout() { set_modal(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::get_text -// Access: Private -// Description: Fills in the text appropriate to display in the -// dialog box, based on the certificate read so far. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the text appropriate to display in the dialog box, based on the + * certificate read so far. + */ void AuthDialog:: get_text(char *header, size_t hlen, char *text, size_t tlen) { switch (_verify_result) { @@ -679,11 +651,9 @@ get_text(char *header, size_t hlen, char *text, size_t tlen) { } } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ViewCertDialog:: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : Fl_Window(600, 400, show_cert_title[li]), @@ -697,11 +667,9 @@ ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : layout(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ViewCertDialog:: ~ViewCertDialog() { if (_auth_dialog != NULL) { @@ -709,11 +677,9 @@ ViewCertDialog:: } } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::run_clicked -// Access: Public -// Description: The user clicks the "Run" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Run" button. + */ void ViewCertDialog:: run_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; @@ -723,11 +689,9 @@ run_clicked(Fl_Widget *w, void *data) { dlg->hide(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::run_clicked -// Access: Public -// Description: The user clicks the "Cancel" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Cancel" button. + */ void ViewCertDialog:: cancel_clicked(Fl_Widget *w, void *data) { ViewCertDialog *dlg = (ViewCertDialog *) data; @@ -737,11 +701,9 @@ cancel_clicked(Fl_Widget *w, void *data) { dlg->hide(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::layout -// Access: Private -// Description: Arranges the text and controls within the dialog. -//////////////////////////////////////////////////////////////////// +/** + * Arranges the text and controls within the dialog. + */ void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. diff --git a/direct/src/plugin/p3dCert.h b/direct/src/plugin/p3dCert.h index abc5deed4e..d5dbdd76a4 100644 --- a/direct/src/plugin/p3dCert.h +++ b/direct/src/plugin/p3dCert.h @@ -1,16 +1,15 @@ -// Filename: p3dCert.h -// Created by: rdb (08Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert.h + * @author rdb + * @date 2011-03-08 + */ #ifndef P3DCERT_H #define P3DCERT_H @@ -31,26 +30,23 @@ using namespace std; class ViewCertDialog; #ifndef STACK_OF - // At some point, presumably in 1.0.0, openssl went to the - // STACK_OF() macro system to typedef the contents of a stack. - // Unfortunately, that new API is different. We define some macros - // here here for backward compatiblity. + // At some point, presumably in 1.0.0, openssl went to the STACK_OF() macro + // system to typedef the contents of a stack. Unfortunately, that new API + // is different. We define some macros here here for backward compatiblity. #define STACK_OF(type) STACK #define sk_X509_push(stack, item) sk_push((stack), (char *)(item)) #define sk_X509_free(stack) sk_free(stack) #define sk_X509_new(cmp) sk_new(cmp) #endif -//////////////////////////////////////////////////////////////////// -// Class : AuthDialog -// Description : This is the primary dialog of this application. -// -// This dialog is presented to the user when he/she -// clicks on the red authorization button on the splash -// window. It tells the user the status of the -// application's signature, and invites the user to -// approve the signature or cancel. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary dialog of this application. + * + * This dialog is presented to the user when he/she clicks on the red + * authorization button on the splash window. It tells the user the status of + * the application's signature, and invites the user to approve the signature + * or cancel. + */ class AuthDialog : public Fl_Window { public: #ifdef _WIN32 @@ -100,11 +96,9 @@ private: int _verify_result; }; -//////////////////////////////////////////////////////////////////// -// Class : ViewCertDialog -// Description : This is the detailed view of the particular -// certificate. -//////////////////////////////////////////////////////////////////// +/** + * This is the detailed view of the particular certificate. + */ class ViewCertDialog : public Fl_Window { public: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert); diff --git a/direct/src/plugin/p3dCert_strings.cxx b/direct/src/plugin/p3dCert_strings.cxx index d29bc9c00a..575dee34b0 100644 --- a/direct/src/plugin/p3dCert_strings.cxx +++ b/direct/src/plugin/p3dCert_strings.cxx @@ -1,31 +1,27 @@ -// Filename: p3dCert_strings.cxx -// Created by: rdb (25Mar15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert_strings.cxx + * @author rdb + * @date 2015-03-25 + */ #include "p3dCert_strings.h" -// Translations kindly provided by: -// eng: drwr -// nld: rdb -// deu: Sebastian Hoffmann -// spa: Imanol Celaya -// ita: Flavio Clava -// rus: montreal +// Translations kindly provided by: eng: drwr nld: rdb deu: Sebastian Hoffmann +// spa: Imanol Celaya ita: Flavio Clava rus: montreal const char *language_codes[LI_COUNT] = {"en", "nl", "de", "es", "it", "eo", "ru"}; -// https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693%28v=vs.85%29.aspx +// https:msdn.microsoft.comen- +// uslibrarywindowsdesktopdd318693%28v=vs.85%29.aspx const unsigned char language_ids[LI_COUNT] = {0x09, 0x13, 0x07, 0x0A, 0x10, 0x8F, 0x19}; diff --git a/direct/src/plugin/p3dCert_strings.h b/direct/src/plugin/p3dCert_strings.h index 064a04360e..7e6d391e2a 100644 --- a/direct/src/plugin/p3dCert_strings.h +++ b/direct/src/plugin/p3dCert_strings.h @@ -1,16 +1,15 @@ -// Filename: p3dCert_strings.h -// Created by: rdb (25Mar15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert_strings.h + * @author rdb + * @date 2015-03-25 + */ enum LanguageIndex { LI_en, // English diff --git a/direct/src/plugin/p3dCert_wx.cxx b/direct/src/plugin/p3dCert_wx.cxx index fa3d63292f..ae373bb5ba 100644 --- a/direct/src/plugin/p3dCert_wx.cxx +++ b/direct/src/plugin/p3dCert_wx.cxx @@ -1,16 +1,15 @@ -// Filename: p3dCert_wx.cxx -// Created by: drose (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert_wx.cxx + * @author drose + * @date 2009-09-11 + */ #include "p3dCert_wx.h" #include "wstring_encode.h" @@ -74,20 +73,16 @@ no_cert_text = _T("Click Cancel to avoid running this application."); -// wxWidgets boilerplate macro to define main() and start up the -// application. +// wxWidgets boilerplate macro to define main() and start up the application. IMPLEMENT_APP(P3DCertApp) -//////////////////////////////////////////////////////////////////// -// Function: P3DCertApp::OnInit -// Access: Public, Virtual -// Description: The "main" of a wx application. This is the first -// entry point. -//////////////////////////////////////////////////////////////////// +/** + * The "main" of a wx application. This is the first entry point. + */ bool P3DCertApp:: OnInit() { - // call the base class initialization method, currently it only parses a - // few common command-line options but it could be do more in the future + // call the base class initialization method, currently it only parses a few + // common command-line options but it could be do more in the future if (!wxApp::OnInit()) { return false; } @@ -104,24 +99,18 @@ OnInit() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DCertApp::OnInitCmdLine -// Access: Public, Virtual -// Description: A callback to initialize the parser with the command -// line options. -//////////////////////////////////////////////////////////////////// +/** + * A callback to initialize the parser with the command line options. + */ void P3DCertApp:: OnInitCmdLine(wxCmdLineParser &parser) { parser.AddParam(); parser.AddParam(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DCertApp::OnCmdLineParsed -// Access: Public, Virtual -// Description: A callback after the successful parsing of the -// command line. -//////////////////////////////////////////////////////////////////// +/** + * A callback after the successful parsing of the command line. + */ bool P3DCertApp:: OnCmdLineParsed(wxCmdLineParser &parser) { _cert_filename = (const char *)parser.GetParam(0).mb_str(); @@ -139,16 +128,14 @@ BEGIN_EVENT_TABLE(AuthDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, AuthDialog::cancel_clicked) END_EVENT_TABLE() -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AuthDialog:: AuthDialog(const string &cert_filename, const string &cert_dir) : - // I hate stay-on-top dialogs, but if we don't set this flag, it - // doesn't come to the foreground on OSX, and might be lost behind - // the browser window. + // I hate stay-on-top dialogs, but if we don't set this flag, it doesn't + // come to the foreground on OSX, and might be lost behind the browser + // window. wxDialog(NULL, wxID_ANY, _T("New Panda3D Application"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP), _cert_dir(cert_dir) @@ -165,11 +152,9 @@ AuthDialog(const string &cert_filename, const string &cert_dir) : layout(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AuthDialog:: ~AuthDialog() { if (_view_cert_dialog != NULL) { @@ -186,21 +171,17 @@ AuthDialog:: } } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "Run" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Run" button. + */ void AuthDialog:: run_clicked(wxCommandEvent &event) { approve_cert(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "View Certificate" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "View Certificate" button. + */ void AuthDialog:: view_cert_clicked(wxCommandEvent &event) { if (_view_cert_dialog != NULL) { @@ -211,23 +192,18 @@ view_cert_clicked(wxCommandEvent &event) { _view_cert_dialog->Show(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::run_clicked -// Access: Public -// Description: The user clicks the "Cancel" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Cancel" button. + */ void AuthDialog:: cancel_clicked(wxCommandEvent &event) { Destroy(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::approve_cert -// Access: Public -// Description: Writes the certificate into the _cert_dir, so -// that it will be found by the P3DInstanceManager and -// known to be approved. -//////////////////////////////////////////////////////////////////// +/** + * Writes the certificate into the _cert_dir, so that it will be found by the + * P3DInstanceManager and known to be approved. + */ void AuthDialog:: approve_cert() { assert(_cert != NULL); @@ -265,8 +241,8 @@ approve_cert() { ++i; } - // Sure, there's a slight race condition right now: another process - // might attempt to create the same filename. So what. + // Sure, there's a slight race condition right now: another process might + // attempt to create the same filename. So what. FILE *fp = NULL; #ifdef _WIN32 fp = _wfopen(buf_w.c_str(), L"w"); @@ -281,12 +257,10 @@ approve_cert() { Destroy(); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::read_cert_file -// Access: Private -// Description: Reads the list of certificates in the pem filename -// passed on the command line into _cert and _stack. -//////////////////////////////////////////////////////////////////// +/** + * Reads the list of certificates in the pem filename passed on the command + * line into _cert and _stack. + */ void AuthDialog:: read_cert_file(const string &cert_filename) { FILE *fp = NULL; @@ -321,12 +295,10 @@ read_cert_file(const string &cert_filename) { fclose(fp); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::get_friendly_name -// Access: Private -// Description: Extracts the "friendly name" from the certificate: -// the common name or email name. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the "friendly name" from the certificate: the common name or email + * name. + */ void AuthDialog:: get_friendly_name() { if (_cert == NULL) { @@ -350,15 +322,15 @@ get_friendly_name() { if (xname != NULL) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { - // We just get the first common name. I guess it's possible to - // have more than one; not sure what that means in this context. + // We just get the first common name. I guess it's possible to have + // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); if (xentry != NULL) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); if (data != NULL) { - // We use "print" to dump the output to a memory BIO. Is - // there an easier way to decode the ASN1_STRING? Curse - // these incomplete docs. + // We use "print" to dump the output to a memory BIO. Is there an + // easier way to decode the ASN1_STRING? Curse these incomplete + // docs. BIO *mbio = BIO_new(BIO_s_mem()); ASN1_STRING_print_ex(mbio, data, ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB); @@ -374,12 +346,10 @@ get_friendly_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::verify_cert -// Access: Private -// Description: Checks whether the certificate is valid by the chain -// and initializes _verify_status accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the certificate is valid by the chain and initializes + * _verify_status accordingly. + */ void AuthDialog:: verify_cert() { if (_cert == NULL) { @@ -413,19 +383,15 @@ verify_cert() { << ", verify_result = " << _verify_result << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::load_certificates_from_der_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be DER-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be DER- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ int AuthDialog:: load_certificates_from_der_ram(X509_STORE *store, const char *data, size_t data_size) { @@ -451,11 +417,9 @@ load_certificates_from_der_ram(X509_STORE *store, return count; } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::layout -// Access: Private -// Description: Arranges the text and controls within the dialog. -//////////////////////////////////////////////////////////////////// +/** + * Arranges the text and controls within the dialog. + */ void AuthDialog:: layout() { wxString header, text; @@ -482,7 +446,7 @@ layout() { text1->Wrap(400); vsizer->Add(text1, 0, wxCENTER | wxALL, 10); - // Create the run / cancel buttons. + // Create the run cancel buttons. wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL); if (_verify_result == 0 && _cert != NULL) { @@ -505,12 +469,10 @@ layout() { vsizer->Fit(this); } -//////////////////////////////////////////////////////////////////// -// Function: AuthDialog::get_text -// Access: Private -// Description: Fills in the text appropriate to display in the -// dialog box, based on the certificate read so far. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the text appropriate to display in the dialog box, based on the + * certificate read so far. + */ void AuthDialog:: get_text(wxString &header, wxString &text) { switch (_verify_result) { @@ -555,11 +517,9 @@ BEGIN_EVENT_TABLE(ViewCertDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, ViewCertDialog::cancel_clicked) END_EVENT_TABLE() -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ViewCertDialog:: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert) : wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, @@ -570,11 +530,9 @@ wxDialog(NULL, wxID_ANY, _T("View Certificate"), wxDefaultPosition, layout(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ViewCertDialog:: ~ViewCertDialog() { if (_auth_dialog != NULL) { @@ -582,11 +540,9 @@ ViewCertDialog:: } } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::run_clicked -// Access: Public -// Description: The user clicks the "Run" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Run" button. + */ void ViewCertDialog:: run_clicked(wxCommandEvent &event) { if (_auth_dialog != NULL){ @@ -595,11 +551,9 @@ run_clicked(wxCommandEvent &event) { Destroy(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::run_clicked -// Access: Public -// Description: The user clicks the "Cancel" button. -//////////////////////////////////////////////////////////////////// +/** + * The user clicks the "Cancel" button. + */ void ViewCertDialog:: cancel_clicked(wxCommandEvent &event) { if (_auth_dialog != NULL){ @@ -608,11 +562,9 @@ cancel_clicked(wxCommandEvent &event) { Destroy(); } -//////////////////////////////////////////////////////////////////// -// Function: ViewCertDialog::layout -// Access: Private -// Description: Arranges the text and controls within the dialog. -//////////////////////////////////////////////////////////////////// +/** + * Arranges the text and controls within the dialog. + */ void ViewCertDialog:: layout() { // Format the certificate text for display in the dialog. @@ -642,7 +594,7 @@ layout() { vsizer->Add(slwin, 1, wxEXPAND | wxALL, 10); - // Create the run / cancel buttons. + // Create the run cancel buttons. wxBoxSizer *bsizer = new wxBoxSizer(wxHORIZONTAL); wxButton *run_button = new wxButton(panel, wxID_OK, _T("Run")); @@ -662,4 +614,3 @@ layout() { GetSize(&width, &height); SetSize(max(width, 600), max(height, 400)); } - diff --git a/direct/src/plugin/p3dCert_wx.h b/direct/src/plugin/p3dCert_wx.h index 94e2a4bd7b..05f0053b74 100644 --- a/direct/src/plugin/p3dCert_wx.h +++ b/direct/src/plugin/p3dCert_wx.h @@ -1,16 +1,15 @@ -// Filename: p3dCert_wx.h -// Created by: drose (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dCert_wx.h + * @author drose + * @date 2009-09-11 + */ #ifndef P3DCERT_WX_H #define P3DCERT_WX_H @@ -30,20 +29,18 @@ using namespace std; class ViewCertDialog; #ifndef STACK_OF - // At some point, presumably in 1.0.0, openssl went to the - // STACK_OF() macro system to typedef the contents of a stack. - // Unfortunately, that new API is different. We define some macros - // here here for backward compatiblity. + // At some point, presumably in 1.0.0, openssl went to the STACK_OF() macro + // system to typedef the contents of a stack. Unfortunately, that new API + // is different. We define some macros here here for backward compatiblity. #define STACK_OF(type) STACK #define sk_X509_push(stack, item) sk_push((stack), (char *)(item)) #define sk_X509_free(stack) sk_free(stack) #define sk_X509_new(cmp) sk_new(cmp) #endif -//////////////////////////////////////////////////////////////////// -// Class : P3DCertApp -// Description : This is the wxApp that drives this application. -//////////////////////////////////////////////////////////////////// +/** + * This is the wxApp that drives this application. + */ class P3DCertApp : public wxApp { public: virtual bool OnInit(); @@ -55,16 +52,14 @@ private: string _cert_dir; }; -//////////////////////////////////////////////////////////////////// -// Class : AuthDialog -// Description : This is the primary dialog of this application. -// -// This dialog is presented to the user when he/she -// clicks on the red authorization button on the splash -// window. It tells the user the status of the -// application's signature, and invites the user to -// approve the signature or cancel. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary dialog of this application. + * + * This dialog is presented to the user when he/she clicks on the red + * authorization button on the splash window. It tells the user the status of + * the application's signature, and invites the user to approve the signature + * or cancel. + */ class AuthDialog : public wxDialog { public: AuthDialog(const string &cert_filename, const string &cert_dir); @@ -101,11 +96,9 @@ private: int _verify_result; }; -//////////////////////////////////////////////////////////////////// -// Class : ViewCertDialog -// Description : This is the detailed view of the particular -// certificate. -//////////////////////////////////////////////////////////////////// +/** + * This is the detailed view of the particular certificate. + */ class ViewCertDialog : public wxDialog { public: ViewCertDialog(AuthDialog *auth_dialog, X509 *cert); diff --git a/direct/src/plugin/p3dConcreteSequence.cxx b/direct/src/plugin/p3dConcreteSequence.cxx index cee67ff306..946afd05cd 100644 --- a/direct/src/plugin/p3dConcreteSequence.cxx +++ b/direct/src/plugin/p3dConcreteSequence.cxx @@ -1,34 +1,29 @@ -// Filename: p3dConcreteSequence.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConcreteSequence.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dConcreteSequence.h" #include "p3dSession.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConcreteSequence:: -P3DConcreteSequence() { +P3DConcreteSequence() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConcreteSequence:: ~P3DConcreteSequence() { Elements::iterator ei; @@ -37,44 +32,35 @@ P3DConcreteSequence:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::is_sequence_object -// Access: Public, Virtual -// Description: Returns true if this is actually an instance of a -// P3DConcreteSequence, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is actually an instance of a P3DConcreteSequence, + * false otherwise. + */ bool P3DConcreteSequence:: is_sequence_object() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DConcreteSequence:: get_type() { return P3D_OT_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DConcreteSequence:: get_bool() { return !_elements.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DConcreteSequence:: make_string(string &value) { ostringstream strm; @@ -90,13 +76,10 @@ make_string(string &value) { value = strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_property -// Access: Public, Virtual -// Description: Returns the named property element in the object. The -// return value is a new-reference P3D_object, or NULL -// on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * new-reference P3D_object, or NULL on error. + */ P3D_object *P3DConcreteSequence:: get_property(const string &property) { // We only understand integer "property" names. @@ -109,13 +92,10 @@ get_property(const string &property) { return get_element(index); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::set_property -// Access: Public, Virtual -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool P3DConcreteSequence:: set_property(const string &property, P3D_object *value) { // We only understand integer "property" names. @@ -128,16 +108,12 @@ set_property(const string &property, P3D_object *value) { return set_element(index, value); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::fill_xml -// Access: Public, Virtual -// Description: If this object has a valid XML representation for the -// indicated session (that hasn't already been -// implemented by the generic code in P3DSession), this -// method will apply it to the indicated "value" element -// and return true. Otherwise, this method will leave -// the element unchanged and return false. -//////////////////////////////////////////////////////////////////// +/** + * If this object has a valid XML representation for the indicated session + * (that hasn't already been implemented by the generic code in P3DSession), + * this method will apply it to the indicated "value" element and return true. + * Otherwise, this method will leave the element unchanged and return false. + */ bool P3DConcreteSequence:: fill_xml(TiXmlElement *xvalue, P3DSession *session) { xvalue->SetAttribute("type", "concrete_sequence"); @@ -149,14 +125,11 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_object_array -// Access: Public -// Description: Returns a pointer to the array of objects represented -// by this object. Most objects represent only -// themselves, but a P3DConcreteSequence represents its -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the array of objects represented by this object. Most + * objects represent only themselves, but a P3DConcreteSequence represents its + * list. + */ P3D_object **P3DConcreteSequence:: get_object_array() { if (_elements.empty()) { @@ -165,34 +138,26 @@ get_object_array() { return &_elements[0]; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_object_array_size -// Access: Public -// Description: Returns the number of elements in the array returned -// by get_object_array(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the array returned by get_object_array(). + */ int P3DConcreteSequence:: get_object_array_size() { return _elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_length -// Access: Public -// Description: Returns the number of items in the sequence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of items in the sequence. + */ int P3DConcreteSequence:: get_length() const { return _elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::get_element -// Access: Public -// Description: Returns the nth item in the sequence. The -// return value is a new-reference P3DObject object, or -// NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth item in the sequence. The return value is a new-reference + * P3DObject object, or NULL on error. + */ P3D_object *P3DConcreteSequence:: get_element(int n) const { if (n >= 0 && n < (int)_elements.size()) { @@ -203,13 +168,10 @@ get_element(int n) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::set_element -// Access: Public -// Description: Modifies (or deletes, if value is NULL) the nth item -// in the sequence. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the nth item in the sequence. + * Returns true on success, false on failure. + */ bool P3DConcreteSequence:: set_element(int n, P3D_object *value) { if (value == NULL) { @@ -241,11 +203,9 @@ set_element(int n, P3D_object *value) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteSequence::append -// Access: Public, Virtual -// Description: Adds a new element to the end of the list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new element to the end of the list. + */ void P3DConcreteSequence:: append(P3D_object *value) { _elements.push_back(value); diff --git a/direct/src/plugin/p3dConcreteSequence.h b/direct/src/plugin/p3dConcreteSequence.h index aab08b57c0..e77b08b823 100644 --- a/direct/src/plugin/p3dConcreteSequence.h +++ b/direct/src/plugin/p3dConcreteSequence.h @@ -1,16 +1,15 @@ -// Filename: p3dConcreteSequence.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConcreteSequence.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DCONCRETESEQUENCE_H #define P3DCONCRETESEQUENCE_H @@ -18,15 +17,13 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DConcreteSequence -// Description : An object type that contains a sequence of objects, -// which is passed by value between Python and -// JavaScript, so may be more optimal for small lists -// that are accessed repeatedly. -// -// This is converted from a Python "tuple" object. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains a sequence of objects, which is passed by + * value between Python and JavaScript, so may be more optimal for small lists + * that are accessed repeatedly. + * + * This is converted from a Python "tuple" object. + */ class P3DConcreteSequence : public P3DObject { public: P3DConcreteSequence(); @@ -57,4 +54,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dConcreteStruct.cxx b/direct/src/plugin/p3dConcreteStruct.cxx index 6e00447a87..f85119cd2d 100644 --- a/direct/src/plugin/p3dConcreteStruct.cxx +++ b/direct/src/plugin/p3dConcreteStruct.cxx @@ -1,33 +1,28 @@ -// Filename: p3dConcreteStruct.cxx -// Created by: drose (14Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConcreteStruct.cxx + * @author drose + * @date 2009-07-14 + */ #include "p3dConcreteStruct.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConcreteStruct:: -P3DConcreteStruct() { +P3DConcreteStruct() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConcreteStruct:: ~P3DConcreteStruct() { Elements::iterator ei; @@ -36,33 +31,26 @@ P3DConcreteStruct:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DConcreteStruct:: get_type() { return P3D_OT_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DConcreteStruct:: get_bool() { return !_elements.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DConcreteStruct:: make_string(string &value) { ostringstream strm; @@ -82,13 +70,10 @@ make_string(string &value) { value = strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::get_property -// Access: Public, Virtual -// Description: Returns the named property element in the object. The -// return value is a new-reference P3D_object, or NULL -// on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * new-reference P3D_object, or NULL on error. + */ P3D_object *P3DConcreteStruct:: get_property(const string &property) { Elements::const_iterator ei = _elements.find(property); @@ -100,13 +85,10 @@ get_property(const string &property) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::set_property -// Access: Public, Virtual -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool P3DConcreteStruct:: set_property(const string &property, P3D_object *value) { if (value == NULL) { @@ -134,12 +116,9 @@ set_property(const string &property, P3D_object *value) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::has_method -// Access: Public, Virtual -// Description: Returns true if the named method exists on this -// object, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named method exists on this object, false otherwise. + */ bool P3DConcreteStruct:: has_method(const string &method_name) { if (method_name == "toString") { @@ -149,19 +128,14 @@ has_method(const string &method_name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::call -// Access: Public, Virtual -// Description: Invokes the named method on the object, passing the -// indicated parameters. If the method name is empty, -// invokes the object itself. -// -// If needs_response is true, the return value is a -// new-reference P3D_object on success, or NULL on -// failure. If needs_response is false, the return -// value is always NULL, and there is no way to -// determine success or failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes the named method on the object, passing the indicated parameters. + * If the method name is empty, invokes the object itself. + * + * If needs_response is true, the return value is a new-reference P3D_object + * on success, or NULL on failure. If needs_response is false, the return + * value is always NULL, and there is no way to determine success or failure. + */ P3D_object *P3DConcreteStruct:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { @@ -182,16 +156,12 @@ call(const string &method_name, bool needs_response, } -//////////////////////////////////////////////////////////////////// -// Function: P3DConcreteStruct::fill_xml -// Access: Public, Virtual -// Description: If this object has a valid XML representation for the -// indicated session (that hasn't already been -// implemented by the generic code in P3DSession), this -// method will apply it to the indicated "value" element -// and return true. Otherwise, this method will leave -// the element unchanged and return false. -//////////////////////////////////////////////////////////////////// +/** + * If this object has a valid XML representation for the indicated session + * (that hasn't already been implemented by the generic code in P3DSession), + * this method will apply it to the indicated "value" element and return true. + * Otherwise, this method will leave the element unchanged and return false. + */ bool P3DConcreteStruct:: fill_xml(TiXmlElement *xvalue, P3DSession *session) { xvalue->SetAttribute("type", "concrete_struct"); diff --git a/direct/src/plugin/p3dConcreteStruct.h b/direct/src/plugin/p3dConcreteStruct.h index 3f9fd7762b..565bb35ae3 100644 --- a/direct/src/plugin/p3dConcreteStruct.h +++ b/direct/src/plugin/p3dConcreteStruct.h @@ -1,16 +1,15 @@ -// Filename: p3dConcreteStruct.h -// Created by: drose (14Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConcreteStruct.h + * @author drose + * @date 2009-07-14 + */ #ifndef P3DCONCRETESTRUCT_H #define P3DCONCRETESTRUCT_H @@ -18,16 +17,13 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DConcreteStruct -// Description : A simple object that contains a standard mapping of -// string -> element. It is passed by value between -// Python and Javascript, so it may be more optimal for -// relatively small objects. -// -// Methods are not supported, other than built-in -// methods like toString(). -//////////////////////////////////////////////////////////////////// +/** + * A simple object that contains a standard mapping of string -> element. It + * is passed by value between Python and Javascript, so it may be more optimal + * for relatively small objects. + * + * Methods are not supported, other than built-in methods like toString(). + */ class P3DConcreteStruct : public P3DObject { public: P3DConcreteStruct(); @@ -53,4 +49,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dConditionVar.I b/direct/src/plugin/p3dConditionVar.I index d987a00c57..08ae4ffe7e 100644 --- a/direct/src/plugin/p3dConditionVar.I +++ b/direct/src/plugin/p3dConditionVar.I @@ -1,14 +1,12 @@ -// Filename: p3dConditionVar.I -// Created by: drose (02Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConditionVar.I + * @author drose + * @date 2009-07-02 + */ diff --git a/direct/src/plugin/p3dConditionVar.cxx b/direct/src/plugin/p3dConditionVar.cxx index 788b4327e1..341e8be905 100644 --- a/direct/src/plugin/p3dConditionVar.cxx +++ b/direct/src/plugin/p3dConditionVar.cxx @@ -1,16 +1,15 @@ -// Filename: p3dConditionVar.cxx -// Created by: drose (02Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConditionVar.cxx + * @author drose + * @date 2009-07-02 + */ #include "p3dConditionVar.h" @@ -20,11 +19,9 @@ #endif #include -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConditionVar:: P3DConditionVar() { #ifdef _WIN32 @@ -47,11 +44,9 @@ P3DConditionVar() { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DConditionVar:: ~P3DConditionVar() { #ifdef _WIN32 @@ -68,12 +63,10 @@ P3DConditionVar:: #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::acquire -// Access: Public -// Description: Acquires the internal lock. The lock should be held -// during any calls to wait() or notify(). -//////////////////////////////////////////////////////////////////// +/** + * Acquires the internal lock. The lock should be held during any calls to + * wait() or notify(). + */ void P3DConditionVar:: acquire() { #ifdef _WIN32 @@ -86,13 +79,10 @@ acquire() { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::wait -// Access: Public -// Description: Requires the lock to be held on entry. Releases the -// lock, waits for another thread to call notify(), then -// reacquires the lock on exit. -//////////////////////////////////////////////////////////////////// +/** + * Requires the lock to be held on entry. Releases the lock, waits for + * another thread to call notify(), then reacquires the lock on exit. + */ void P3DConditionVar:: wait() { #ifdef _WIN32 @@ -110,12 +100,9 @@ wait() { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::wait -// Access: Public -// Description: As above, but waits no longer than timeout seconds -// before returning. -//////////////////////////////////////////////////////////////////// +/** + * As above, but waits no longer than timeout seconds before returning. + */ void P3DConditionVar:: wait(double timeout) { #ifdef _WIN32 @@ -152,13 +139,10 @@ wait(double timeout) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::notify -// Access: Public -// Description: Waits a single thread blocked on wait(), if any. If -// no threads are waiting, the event is lost. The lock -// should be held during this call. -//////////////////////////////////////////////////////////////////// +/** + * Waits a single thread blocked on wait(), if any. If no threads are + * waiting, the event is lost. The lock should be held during this call. + */ void P3DConditionVar:: notify() { #ifdef _WIN32 @@ -171,11 +155,9 @@ notify() { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DConditionVar::release -// Access: Public -// Description: Releases the internal lock. -//////////////////////////////////////////////////////////////////// +/** + * Releases the internal lock. + */ void P3DConditionVar:: release() { #ifdef _WIN32 diff --git a/direct/src/plugin/p3dConditionVar.h b/direct/src/plugin/p3dConditionVar.h index 68e78edf1f..f4de8f549d 100644 --- a/direct/src/plugin/p3dConditionVar.h +++ b/direct/src/plugin/p3dConditionVar.h @@ -1,28 +1,26 @@ -// Filename: p3dConditionVar.h -// Created by: drose (02Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dConditionVar.h + * @author drose + * @date 2009-07-02 + */ #ifndef P3DCONDITIONVAR_H #define P3DCONDITIONVAR_H #include "p3d_plugin_common.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DConditionVar -// Description : A simple condition-variable like object. It doesn't -// support the full condition-var semantics, but it -// works well enough with one waiter and one signaller. -//////////////////////////////////////////////////////////////////// +/** + * A simple condition-variable like object. It doesn't support the full + * condition-var semantics, but it works well enough with one waiter and one + * signaller. + */ class P3DConditionVar { public: P3DConditionVar(); @@ -33,7 +31,7 @@ public: void wait(double timeout); void notify(); void release(); - + private: #ifdef _WIN32 CRITICAL_SECTION _lock; diff --git a/direct/src/plugin/p3dDownload.I b/direct/src/plugin/p3dDownload.I index 5eff54903c..e32370669c 100644 --- a/direct/src/plugin/p3dDownload.I +++ b/direct/src/plugin/p3dDownload.I @@ -1,57 +1,46 @@ -// Filename: p3dDownload.I -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dDownload.I + * @author drose + * @date 2009-06-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_url -// Access: Public -// Description: Returns the URL that we are querying. -//////////////////////////////////////////////////////////////////// +/** + * Returns the URL that we are querying. + */ const string &P3DDownload:: get_url() const { return _url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::set_instance -// Access: Public -// Description: Specifies the particular P3DInstance that is -// responsible for downloading this object. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular P3DInstance that is responsible for downloading + * this object. + */ inline void P3DDownload:: set_instance(P3DInstance *instance) { _instance = instance; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_instance -// Access: Public -// Description: Returns the particular P3DInstance that is -// responsible for downloading this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular P3DInstance that is responsible for downloading this + * object. + */ inline P3DInstance *P3DDownload:: get_instance() const { return _instance; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_download_progress -// Access: Public -// Description: Returns an indication of the progress through the -// download file, 0.0 to 1.0. Returns 1.0 if the size -// of the file is not known. -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the progress through the download file, 0.0 to + * 1.0. Returns 1.0 if the size of the file is not known. + */ inline double P3DDownload:: get_download_progress() const { if (_total_expected_data == 0) { @@ -61,98 +50,76 @@ get_download_progress() const { return (double)_total_data / (double)_total_expected_data; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::is_download_progress_known -// Access: Public -// Description: Returns true if the download progress is known, or -// false if it is unknown because the server hasn't told -// us the total size it will be feeding us. If this is -// false, get_download_progress() will generally always -// return 1.0; use get_total_bytes() to measure progress -// in this case. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the download progress is known, or false if it is unknown + * because the server hasn't told us the total size it will be feeding us. If + * this is false, get_download_progress() will generally always return 1.0; + * use get_total_bytes() to measure progress in this case. + */ inline bool P3DDownload:: is_download_progress_known() const { return _progress_known; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_total_data -// Access: Public -// Description: Returns the total number of bytes downloaded so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes downloaded so far. + */ inline size_t P3DDownload:: get_total_data() const { return _total_data; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::set_total_expected_data -// Access: Public -// Description: Sets the total number of bytes expected to be -// downloaded. This is used to compute the progress. -// Normally, this can be set from the download server, -// but there may be cases when the download server -// doesn't accurately report it. -//////////////////////////////////////////////////////////////////// +/** + * Sets the total number of bytes expected to be downloaded. This is used to + * compute the progress. Normally, this can be set from the download server, + * but there may be cases when the download server doesn't accurately report + * it. + */ inline void P3DDownload:: set_total_expected_data(size_t expected_data) { _total_expected_data = expected_data; _progress_known = true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_download_finished -// Access: Public -// Description: Returns true if the download has finished, either -// successfully or otherwise, or false if it is still in -// progress. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the download has finished, either successfully or + * otherwise, or false if it is still in progress. + */ inline bool P3DDownload:: get_download_finished() const { return _status != P3D_RC_in_progress; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_download_success -// Access: Public -// Description: Returns true if the download has finished -// successfully, or false if it is still in progress or -// if it has failed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the download has finished successfully, or false if it is + * still in progress or if it has failed. + */ inline bool P3DDownload:: get_download_success() const { return _status == P3D_RC_done; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_download_terminated -// Access: Public -// Description: Returns true if the download has failed because the -// instance is about to be shut down, or false if it -// hasn't failed, or failed for some other reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the download has failed because the instance is about to be + * shut down, or false if it hasn't failed, or failed for some other reason. + */ inline bool P3DDownload:: get_download_terminated() const { return _status == P3D_RC_shutdown; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::set_download_id -// Access: Public -// Description: Called only by P3DInstance to set a unique ID for -// this particular download object. -//////////////////////////////////////////////////////////////////// +/** + * Called only by P3DInstance to set a unique ID for this particular download + * object. + */ inline void P3DDownload:: set_download_id(int download_id) { _download_id = download_id; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::get_download_id -// Access: Public -// Description: Returns the unique ID set by the P3DInstance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the unique ID set by the P3DInstance. + */ inline int P3DDownload:: get_download_id() const { return _download_id; diff --git a/direct/src/plugin/p3dDownload.cxx b/direct/src/plugin/p3dDownload.cxx index f5aae868e9..9b1af6ba7d 100644 --- a/direct/src/plugin/p3dDownload.cxx +++ b/direct/src/plugin/p3dDownload.cxx @@ -1,24 +1,21 @@ -// Filename: p3dDownload.cxx -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dDownload.cxx + * @author drose + * @date 2009-06-11 + */ #include "p3dDownload.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DDownload:: P3DDownload() { _status = P3D_RC_in_progress; @@ -27,17 +24,15 @@ P3DDownload() { _total_expected_data = 0; _last_reported_time = 0; _progress_known = false; - + _canceled = false; _download_id = 0; _instance = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DDownload:: P3DDownload(const P3DDownload ©) : _url(copy._url), @@ -48,75 +43,63 @@ P3DDownload(const P3DDownload ©) : _http_status_code = 0; _total_data = 0; _last_reported_time = 0; - + _canceled = false; _download_id = 0; _instance = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DDownload:: ~P3DDownload() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::set_url -// Access: Public -// Description: Supplies the source URL for the download. -//////////////////////////////////////////////////////////////////// +/** + * Supplies the source URL for the download. + */ void P3DDownload:: set_url(const string &url) { _url = url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::cancel -// Access: Public -// Description: Cancels a running download. download_finished() will -// not be called, but the P3DDownload object itself will -// eventually be deleted by its owning P3DInstance. -//////////////////////////////////////////////////////////////////// +/** + * Cancels a running download. download_finished() will not be called, but + * the P3DDownload object itself will eventually be deleted by its owning + * P3DInstance. + */ void P3DDownload:: cancel() { _canceled = true; if (_status == P3D_RC_in_progress) { _status = P3D_RC_generic_error; - } + } } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::clear -// Access: Public -// Description: Resets the download to its initial state, for -// re-trying the same download. -//////////////////////////////////////////////////////////////////// +/** + * Resets the download to its initial state, for re-trying the same download. + */ void P3DDownload:: clear() { _status = P3D_RC_in_progress; _http_status_code = 0; _total_data = 0; _last_reported_time = 0; - + _canceled = false; _download_id = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::feed_url_stream -// Access: Public -// Description: Called by P3DInstance as more data arrives from the -// host. Returns true on success, false if the download -// should be aborted. -//////////////////////////////////////////////////////////////////// +/** + * Called by P3DInstance as more data arrives from the host. Returns true on + * success, false if the download should be aborted. + */ bool P3DDownload:: feed_url_stream(P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const unsigned char *this_data, + const unsigned char *this_data, size_t this_data_size) { if (_canceled) { return false; @@ -138,15 +121,15 @@ feed_url_stream(P3D_result_code result_code, total_expected_data = max(total_expected_data, _total_data); if (total_expected_data > _total_expected_data) { - // If the expected data grows during the download, we don't really - // know how much we're getting. + // If the expected data grows during the download, we don't really know + // how much we're getting. _progress_known = false; _total_expected_data = total_expected_data; } - if (_total_expected_data > 0 && + if (_total_expected_data > 0 && (double)_total_data / (double)_total_expected_data < 0.9) { - // But if we're not close to our target yet, let's say we do know - // (at least until we get there and the target moves again). + // But if we're not close to our target yet, let's say we do know (at + // least until we get there and the target moves again). _progress_known = true; } @@ -164,23 +147,19 @@ feed_url_stream(P3D_result_code result_code, } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::receive_data -// Access: Protected, Virtual -// Description: Called as new data is downloaded. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Called as new data is downloaded. Returns true on success, false on + * failure. + */ bool P3DDownload:: receive_data(const unsigned char *this_data, size_t this_data_size) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::download_progress -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate an occasional -// callback as new data comes in. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate an occasional callback as new data + * comes in. + */ void P3DDownload:: download_progress() { time_t now = time(NULL); @@ -196,14 +175,11 @@ download_progress() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DDownload::download_finished -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate a callback -// when the download finishes, either successfully or -// otherwise. The bool parameter is true if the -// download was successful. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate a callback when the download + * finishes, either successfully or otherwise. The bool parameter is true if + * the download was successful. + */ void P3DDownload:: download_finished(bool success) { nout << "Downloaded " << get_url() << ": "; diff --git a/direct/src/plugin/p3dDownload.h b/direct/src/plugin/p3dDownload.h index b7adffe595..e36d5b19c5 100644 --- a/direct/src/plugin/p3dDownload.h +++ b/direct/src/plugin/p3dDownload.h @@ -1,16 +1,15 @@ -// Filename: p3dDownload.h -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dDownload.h + * @author drose + * @date 2009-06-11 + */ #ifndef P3DDOWNLOAD_H #define P3DDOWNLOAD_H @@ -21,14 +20,12 @@ class P3DInstance; #include -//////////////////////////////////////////////////////////////////// -// Class : P3DDownload -// Description : This represents a request to download a single file -// from a URL, with no particular destination. It is -// intended to be used as an abstract base class; to use -// it, subclass it and redefine the appropriate callback -// methods. -//////////////////////////////////////////////////////////////////// +/** + * This represents a request to download a single file from a URL, with no + * particular destination. It is intended to be used as an abstract base + * class; to use it, subclass it and redefine the appropriate callback + * methods. + */ class P3DDownload : public P3DReferenceCount { public: P3DDownload(); @@ -58,10 +55,10 @@ public: inline int get_download_id() const; bool feed_url_stream(P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const unsigned char *this_data, - size_t this_data_size); + const unsigned char *this_data, + size_t this_data_size); protected: virtual bool receive_data(const unsigned char *this_data, diff --git a/direct/src/plugin/p3dFileDownload.I b/direct/src/plugin/p3dFileDownload.I index aa6c0a7dbf..187db8945d 100644 --- a/direct/src/plugin/p3dFileDownload.I +++ b/direct/src/plugin/p3dFileDownload.I @@ -1,23 +1,19 @@ -// Filename: p3dFileDownload.I -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileDownload.I + * @author drose + * @date 2009-06-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::get_filename -// Access: Public -// Description: Returns the filename that we are downloading into. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that we are downloading into. + */ const string &P3DFileDownload:: get_filename() const { return _filename; diff --git a/direct/src/plugin/p3dFileDownload.cxx b/direct/src/plugin/p3dFileDownload.cxx index 68631f5e3c..2d1a85497e 100644 --- a/direct/src/plugin/p3dFileDownload.cxx +++ b/direct/src/plugin/p3dFileDownload.cxx @@ -1,49 +1,42 @@ -// Filename: p3dFileDownload.cxx -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileDownload.cxx + * @author drose + * @date 2009-06-11 + */ #include "p3dFileDownload.h" #include "p3dInstanceManager.h" #include "mkdir_complete.h" #include "wstring_encode.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFileDownload:: P3DFileDownload() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFileDownload:: -P3DFileDownload(const P3DFileDownload ©) : +P3DFileDownload(const P3DFileDownload ©) : P3DDownload(copy) { // We don't copy the filename. You have to copy it yourself. } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::set_filename -// Access: Public -// Description: Supplies the target local filename for the download. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Supplies the target local filename for the download. Returns true on + * success, false on failure. + */ bool P3DFileDownload:: set_filename(const string &filename) { _filename = filename; @@ -51,12 +44,10 @@ set_filename(const string &filename) { return open_file(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::open_file -// Access: Protected, Virtual -// Description: Opens the local file for receiving the download. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the local file for receiving the download. Returns true on success, + * false on failure. + */ bool P3DFileDownload:: open_file() { if (!mkfile_complete(_filename, nout)) { @@ -77,26 +68,22 @@ open_file() { nout << "Failed to open " << _filename << " in write mode\n"; return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::close_file -// Access: Protected -// Description: Closes the local file. -//////////////////////////////////////////////////////////////////// +/** + * Closes the local file. + */ void P3DFileDownload:: close_file() { _file.close(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::receive_data -// Access: Protected, Virtual -// Description: Called as new data is downloaded. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Called as new data is downloaded. Returns true on success, false on + * failure. + */ bool P3DFileDownload:: receive_data(const unsigned char *this_data, size_t this_data_size) { _file.write((const char *)this_data, this_data_size); @@ -104,18 +91,15 @@ receive_data(const unsigned char *this_data, size_t this_data_size) { if (!_file) { return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileDownload::download_finished -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate a callback -// when the download finishes, either successfully or -// otherwise. The bool parameter is true if the -// download was successful. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate a callback when the download + * finishes, either successfully or otherwise. The bool parameter is true if + * the download was successful. + */ void P3DFileDownload:: download_finished(bool success) { P3DDownload::download_finished(success); diff --git a/direct/src/plugin/p3dFileDownload.h b/direct/src/plugin/p3dFileDownload.h index 1caaeffff0..f256706ac6 100644 --- a/direct/src/plugin/p3dFileDownload.h +++ b/direct/src/plugin/p3dFileDownload.h @@ -1,16 +1,15 @@ -// Filename: p3dFileDownload.h -// Created by: drose (11Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileDownload.h + * @author drose + * @date 2009-06-11 + */ #ifndef P3DFILEDOWNLOAD_H #define P3DFILEDOWNLOAD_H @@ -20,11 +19,10 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : P3DFileDownload -// Description : This is a specialization on P3DDownload that -// specifically writes a disk file. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on P3DDownload that specifically writes a disk + * file. + */ class P3DFileDownload : public P3DDownload { public: P3DFileDownload(); diff --git a/direct/src/plugin/p3dFileParams.I b/direct/src/plugin/p3dFileParams.I index d3c9a41858..e7eb45788d 100644 --- a/direct/src/plugin/p3dFileParams.I +++ b/direct/src/plugin/p3dFileParams.I @@ -1,76 +1,61 @@ -// Filename: p3dFileParams.I -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileParams.I + * @author drose + * @date 2009-06-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_p3d_filename -// Access: Public -// Description: Returns the filename that was passed to -// set_p3d_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that was passed to set_p3d_filename(). + */ inline const string &P3DFileParams:: get_p3d_filename() const { return _p3d_filename; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_p3d_offset -// Access: Public -// Description: Returns the p3d file offset, the location -// in the file where the p3d data starts. -//////////////////////////////////////////////////////////////////// +/** + * Returns the p3d file offset, the location in the file where the p3d data + * starts. + */ inline int P3DFileParams:: get_p3d_offset() const { return _p3d_offset; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_p3d_url -// Access: Public -// Description: Returns the string that was passed to set_p3d_url(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that was passed to set_p3d_url(). + */ inline const string &P3DFileParams:: get_p3d_url() const { return _p3d_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_num_tokens -// Access: Public -// Description: Returns the number of tokens in the params. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of tokens in the params. + */ inline int P3DFileParams:: get_num_tokens() const { return _tokens.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_token_keyword -// Access: Public -// Description: Returns the keyword of the nth token. -//////////////////////////////////////////////////////////////////// +/** + * Returns the keyword of the nth token. + */ inline const string &P3DFileParams:: get_token_keyword(int n) const { assert(n >= 0 && n < (int)_tokens.size()); return _tokens[n]._keyword; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::get_token_value -// Access: Public -// Description: Returns the value of the nth token. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the nth token. + */ inline const string &P3DFileParams:: get_token_value(int n) const { assert(n >= 0 && n < (int)_tokens.size()); diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index a5e2bddb50..128520d993 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -1,34 +1,29 @@ -// Filename: p3dFileParams.cxx -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileParams.cxx + * @author drose + * @date 2009-06-23 + */ #include "p3dFileParams.h" #include -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFileParams:: P3DFileParams() : _p3d_offset(0) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFileParams:: P3DFileParams(const P3DFileParams ©) : _p3d_filename(copy._p3d_filename), @@ -39,11 +34,9 @@ P3DFileParams(const P3DFileParams ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DFileParams:: operator = (const P3DFileParams &other) { _p3d_filename = other._p3d_filename; @@ -53,44 +46,35 @@ operator = (const P3DFileParams &other) { _args = other._args; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_p3d_filename -// Access: Public -// Description: Specifies the file that contains the instance data. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the file that contains the instance data. + */ void P3DFileParams:: set_p3d_filename(const string &p3d_filename) { _p3d_filename = p3d_filename; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_p3d_offset -// Access: Public -// Description: Specifies the location in the file where -// the p3d file data starts. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the location in the file where the p3d file data starts. + */ void P3DFileParams:: set_p3d_offset(const int &p3d_offset) { _p3d_offset = p3d_offset; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_p3d_url -// Access: Public -// Description: Specifies the original URL that hosted the p3d file, -// if any. This is for documentation purposes only; it -// is communicated to the child Panda3D process. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the original URL that hosted the p3d file, if any. This is for + * documentation purposes only; it is communicated to the child Panda3D + * process. + */ void P3DFileParams:: set_p3d_url(const string &p3d_url) { _p3d_url = p3d_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_tokens -// Access: Public -// Description: Replaces all the tokens associated with the instance. -//////////////////////////////////////////////////////////////////// +/** + * Replaces all the tokens associated with the instance. + */ void P3DFileParams:: set_tokens(const P3D_token tokens[], size_t num_tokens) { _tokens.clear(); @@ -100,17 +84,14 @@ set_tokens(const P3D_token tokens[], size_t num_tokens) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_token -// Access: Public -// Description: Sets an individual token value. -//////////////////////////////////////////////////////////////////// +/** + * Sets an individual token value. + */ void P3DFileParams:: set_token(const char *keyword, const char *value) { Token token; if (keyword != NULL) { - // Make the token lowercase, since HTML is case-insensitive but - // we're not. + // Make the token lowercase, since HTML is case-insensitive but we're not. for (const char *p = keyword; *p; ++p) { token._keyword += tolower(*p); } @@ -121,12 +102,9 @@ set_token(const char *keyword, const char *value) { _tokens.push_back(token); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::set_args -// Access: Public -// Description: Specifies the command-line arguments associated with -// the instance. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the command-line arguments associated with the instance. + */ void P3DFileParams:: set_args(int argc, const char *argv[]) { _args.clear(); @@ -140,13 +118,10 @@ set_args(int argc, const char *argv[]) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::lookup_token -// Access: Public -// Description: Returns the value associated with the first -// appearance of the named token, or empty string if the -// token does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the first appearance of the named token, + * or empty string if the token does not appear. + */ string P3DFileParams:: lookup_token(const string &keyword) const { Tokens::const_iterator ti; @@ -159,25 +134,19 @@ lookup_token(const string &keyword) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::lookup_token_int -// Access: Public -// Description: Returns the integer value associated with the first -// appearance of the named token, or zero if the -// token does not appear or is not an integer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value associated with the first appearance of the named + * token, or zero if the token does not appear or is not an integer. + */ int P3DFileParams:: lookup_token_int(const string &keyword) const { string value = lookup_token(keyword); return atoi(value.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::has_token -// Access: Public -// Description: Returns true if the named token appears in the list, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named token appears in the list, false otherwise. + */ bool P3DFileParams:: has_token(const string &keyword) const { Tokens::const_iterator ti; @@ -190,13 +159,10 @@ has_token(const string &keyword) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFileParams::make_xml -// Access: Public -// Description: Returns a newly-allocated XML structure that -// corresponds to the file parameter data within this -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated XML structure that corresponds to the file + * parameter data within this instance. + */ TiXmlElement *P3DFileParams:: make_xml() { TiXmlElement *xfparams = new TiXmlElement("fparams"); diff --git a/direct/src/plugin/p3dFileParams.h b/direct/src/plugin/p3dFileParams.h index cebe1e3a6a..1cb54d1b3a 100644 --- a/direct/src/plugin/p3dFileParams.h +++ b/direct/src/plugin/p3dFileParams.h @@ -1,16 +1,15 @@ -// Filename: p3dFileParams.h -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFileParams.h + * @author drose + * @date 2009-06-23 + */ #ifndef P3DFILEPARAMS_H #define P3DFILEPARAMS_H @@ -19,11 +18,9 @@ #include "get_tinyxml.h" #include -//////////////////////////////////////////////////////////////////// -// Class : P3DFileParams -// Description : Encapsulates the file parameters: the p3d_filename, -// and extra tokens. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the file parameters: the p3d_filename, and extra tokens. + */ class P3DFileParams { public: P3DFileParams(); diff --git a/direct/src/plugin/p3dFloatObject.cxx b/direct/src/plugin/p3dFloatObject.cxx index 2de0343fe3..2581c44282 100644 --- a/direct/src/plugin/p3dFloatObject.cxx +++ b/direct/src/plugin/p3dFloatObject.cxx @@ -1,33 +1,28 @@ -// Filename: p3dFloatObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFloatObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dFloatObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFloatObject:: P3DFloatObject(double value) : _value(value) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DFloatObject:: P3DFloatObject(const P3DFloatObject ©) : P3DObject(copy), @@ -35,55 +30,42 @@ P3DFloatObject(const P3DFloatObject ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DFloatObject:: get_type() { return P3D_OT_float; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DFloatObject:: get_bool() { return (_value != 0.0); } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DFloatObject:: get_int() { return (int)_value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::get_float -// Access: Public, Virtual -// Description: Returns the object value coerced to a floating-point -// value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a floating-point value, if possible. + */ double P3DFloatObject:: get_float() { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DFloatObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DFloatObject:: make_string(string &value) { ostringstream strm; diff --git a/direct/src/plugin/p3dFloatObject.h b/direct/src/plugin/p3dFloatObject.h index e397993404..1fbb79251b 100644 --- a/direct/src/plugin/p3dFloatObject.h +++ b/direct/src/plugin/p3dFloatObject.h @@ -1,16 +1,15 @@ -// Filename: p3dFloatObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dFloatObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DFLOATOBJECT_H #define P3DFLOATOBJECT_H @@ -18,10 +17,9 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DFloatObject -// Description : An object type that contains a floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains a floating-point value. + */ class P3DFloatObject : public P3DObject { public: P3DFloatObject(double value); @@ -39,4 +37,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dHost.I b/direct/src/plugin/p3dHost.I index 3adad28e98..f7e4640b66 100644 --- a/direct/src/plugin/p3dHost.I +++ b/direct/src/plugin/p3dHost.I @@ -1,135 +1,105 @@ -// Filename: p3dHost.I -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dHost.I + * @author drose + * @date 2009-08-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::has_host_dir -// Access: Public -// Description: Returns true if the host_dir has already been set, -// false if not. If this returns true it is safe to -// call get_host_dir(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the host_dir has already been set, false if not. If this + * returns true it is safe to call get_host_dir(). + */ inline bool P3DHost:: has_host_dir() const { return (!_host_dir.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_host_dir -// Access: Public -// Description: Returns the local directory into which files -// downloaded from this host will be installed. It may -// not be safe to call this before the host has fully -// bootstrapped; if there is some danger of calling this -// early in the initialization process, you should check -// has_host_dir() first. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local directory into which files downloaded from this host will + * be installed. It may not be safe to call this before the host has fully + * bootstrapped; if there is some danger of calling this early in the + * initialization process, you should check has_host_dir() first. + */ inline const string &P3DHost:: get_host_dir() const { assert(has_host_dir()); return _host_dir; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_host_url -// Access: Public -// Description: Returns the root URL of this particular host, as -// passed from the package file. This is a unique -// string that identifies each host. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root URL of this particular host, as passed from the package + * file. This is a unique string that identifies each host. + */ inline const string &P3DHost:: get_host_url() const { return _host_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_host_url_prefix -// Access: Public -// Description: Returns the root URL of this host, for constructing -// the URL to download contents.xml only. This is the -// same as get_host_url(), except it is guaranteed to -// end in a slash character. -// -// Also see get_download_url_prefix(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the root URL of this host, for constructing the URL to download + * contents.xml only. This is the same as get_host_url(), except it is + * guaranteed to end in a slash character. + * + * Also see get_download_url_prefix(). + */ inline const string &P3DHost:: get_host_url_prefix() const { return _host_url_prefix; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_download_url_prefix -// Access: Public -// Description: Returns the root URL of this host, for downloading -// everything other than the contents.xml file. This is -// often the same as get_host_url_prefix(), but it may -// be different in the case of an https server for -// contents.xml. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root URL of this host, for downloading everything other than + * the contents.xml file. This is often the same as get_host_url_prefix(), + * but it may be different in the case of an https server for contents.xml. + */ inline const string &P3DHost:: get_download_url_prefix() const { return _download_url_prefix; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_descriptive_name -// Access: Public -// Description: Returns the descriptive name provided for this host, -// if any. Returns the url if no descriptive name is -// provided. This will be available after -// read_contents_file() has been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the descriptive name provided for this host, if any. Returns the + * url if no descriptive name is provided. This will be available after + * read_contents_file() has been called. + */ inline const string &P3DHost:: get_descriptive_name() const { return _descriptive_name; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::has_contents_file -// Access: Public -// Description: Returns true if a contents.xml file has been -// successfully read for this host, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a contents.xml file has been successfully read for this + * host, false otherwise. + */ inline bool P3DHost:: has_contents_file() const { return (_xcontents != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_contents_iseq -// Access: Public -// Description: Returns a number that increments whenever a new -// version of the contents.xml file has been read. This -// number is local to the session only; it has nothing -// to do with the "seq" value written into the -// contents.xml file itself. -// -// This can be used by packages to determine whether -// they need to redownload from scratch. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number that increments whenever a new version of the contents.xml + * file has been read. This number is local to the session only; it has + * nothing to do with the "seq" value written into the contents.xml file + * itself. + * + * This can be used by packages to determine whether they need to redownload + * from scratch. + */ inline int P3DHost:: get_contents_iseq() const { return _contents_iseq; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::check_contents_hash -// Access: Public -// Description: Returns true if the indicated pathname has the same -// md5 hash as the contents.xml file (as provided by the -// server), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated pathname has the same md5 hash as the + * contents.xml file (as provided by the server), false otherwise. + */ inline bool P3DHost:: check_contents_hash(const string &pathname) const { return _contents_spec.check_hash(pathname); diff --git a/direct/src/plugin/p3dHost.cxx b/direct/src/plugin/p3dHost.cxx index 68e74b7b98..054dbe6166 100644 --- a/direct/src/plugin/p3dHost.cxx +++ b/direct/src/plugin/p3dHost.cxx @@ -1,16 +1,15 @@ -// Filename: p3dHost.cxx -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dHost.cxx + * @author drose + * @date 2009-08-21 + */ #include "p3dHost.h" #include "p3dInstanceManager.h" @@ -26,15 +25,12 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::Constructor -// Access: Private -// Description: Use P3DInstanceManager::get_host() to construct a -// new P3DHost. -//////////////////////////////////////////////////////////////////// +/** + * Use P3DInstanceManager::get_host() to construct a new P3DHost. + */ P3DHost:: P3DHost(const string &host_url, const string &host_dir) : - _host_url(host_url), + _host_url(host_url), _host_dir(host_dir) { // Ensure that the download URL ends with a slash. @@ -51,11 +47,9 @@ P3DHost(const string &host_url, const string &host_dir) : _contents_iseq = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::Destructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DHost:: ~P3DHost() { if (_xcontents != NULL) { @@ -83,28 +77,21 @@ P3DHost:: _failed_packages.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_alt_host -// Access: Public -// Description: Returns the pre-defined alternate host with the -// indicated token, if one is defined for this token, or -// the original host if there is no alternate host -// defined for this token. -// -// This is intended to implement test versions and the -// like, for instance in which a particular p3d file may -// reference a package on one particular host, but there -// is an alternate version to be tested on a different -// host. The HTML code that embeds the p3d file can -// choose to set the alt_host token to redirect the p3d -// file to the alternate host. -// -// The actual URL for the alternate host is embedded -// within the host's contents.xml as a security measure, -// to prevent people from tricking a p3d file into -// running untrusted code by redirecting it to an -// arbitrary URL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pre-defined alternate host with the indicated token, if one is + * defined for this token, or the original host if there is no alternate host + * defined for this token. + * + * This is intended to implement test versions and the like, for instance in + * which a particular p3d file may reference a package on one particular host, + * but there is an alternate version to be tested on a different host. The + * HTML code that embeds the p3d file can choose to set the alt_host token to + * redirect the p3d file to the alternate host. + * + * The actual URL for the alternate host is embedded within the host's + * contents.xml as a security measure, to prevent people from tricking a p3d + * file into running untrusted code by redirecting it to an arbitrary URL. + */ P3DHost *P3DHost:: get_alt_host(const string &alt_host) { assert(_xcontents != NULL); @@ -118,19 +105,16 @@ get_alt_host(const string &alt_host) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::has_current_contents_file -// Access: Public -// Description: Returns true if a contents.xml file has been -// successfully read for this host and is still current, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a contents.xml file has been successfully read for this + * host and is still current, false otherwise. + */ bool P3DHost:: has_current_contents_file(P3DInstanceManager *inst_mgr) const { if (inst_mgr->get_verify_contents() == P3D_VC_never || inst_mgr->get_verify_contents() == P3D_VC_none) { - // If we're not asking to verify contents, then contents.xml files - // never expire. + // If we're not asking to verify contents, then contents.xml files never + // expire. return has_contents_file(); } @@ -138,14 +122,11 @@ has_current_contents_file(P3DInstanceManager *inst_mgr) const { return now < _contents_expiration && (_xcontents != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::read_contents_file -// Access: Public -// Description: Reads the contents.xml file in the standard -// filename, if possible. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the contents.xml file in the standard filename, if possible. + * + * Returns true on success, false on failure. + */ bool P3DHost:: read_contents_file() { if (_host_dir.empty()) { @@ -157,16 +138,13 @@ read_contents_file() { return read_contents_file(standard_filename, false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::read_contents_file -// Access: Public -// Description: Reads the contents.xml file in the indicated -// filename. On success, writes the contents.xml file -// into the standard location (if it's not there -// already). -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the contents.xml file in the indicated filename. On success, writes + * the contents.xml file into the standard location (if it's not there + * already). + * + * Returns true on success, false on failure. + */ bool P3DHost:: read_contents_file(const string &contents_filename, bool fresh_download) { TiXmlDocument doc(contents_filename.c_str()); @@ -189,8 +167,8 @@ read_contents_file(const string &contents_filename, bool fresh_download) { int max_age = P3D_CONTENTS_DEFAULT_MAX_AGE; xcontents->Attribute("max_age", &max_age); - // Get the latest possible expiration time, based on the max_age - // indication. Any expiration time later than this is in error. + // Get the latest possible expiration time, based on the max_age indication. + // Any expiration time later than this is in error. time_t now = time(NULL); _contents_expiration = now + (time_t)max_age; @@ -263,14 +241,14 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - + if (_host_dir.empty()) { determine_host_dir(""); } assert(!_host_dir.empty()); - + string standard_filename = _host_dir + "/contents.xml"; - + if (inst_mgr->get_verify_contents() != P3D_VC_never) { mkdir_complete(_host_dir, nout); @@ -279,7 +257,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { nout << "Couldn't save to " << standard_filename << "\n"; } } else { - if (standardize_filename(standard_filename) != + if (standardize_filename(standard_filename) != standardize_filename(contents_filename)) { if (!copy_file(contents_filename, standard_filename)) { nout << "Couldn't copy to " << standard_filename << "\n"; @@ -288,11 +266,10 @@ read_contents_file(const string &contents_filename, bool fresh_download) { } if (_host_url == inst_mgr->get_host_url()) { - // If this is also the plugin host, then copy the contents.xml - // file into the root Panda directory as well, for the next plugin - // iteration. + // If this is also the plugin host, then copy the contents.xml file into + // the root Panda directory as well, for the next plugin iteration. string top_filename = inst_mgr->get_root_dir() + "/contents.xml"; - if (standardize_filename(top_filename) != + if (standardize_filename(top_filename) != standardize_filename(standard_filename)) { if (!copy_file(standard_filename, top_filename)) { nout << "Couldn't copy to " << top_filename << "\n"; @@ -304,13 +281,10 @@ read_contents_file(const string &contents_filename, bool fresh_download) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::read_xhost -// Access: Public -// Description: Reads the host data from the (or ) -// entry in the contents.xml file, or from a -// p3d_info.xml file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the host data from the (or ) entry in the + * contents.xml file, or from a p3d_info.xml file. + */ void P3DHost:: read_xhost(TiXmlElement *xhost) { const char *descriptive_name = xhost->Attribute("descriptive_name"); @@ -326,8 +300,8 @@ read_xhost(TiXmlElement *xhost) { determine_host_dir(host_dir_basename); } - // Get the "download" URL, which is the source from which we - // download everything other than the contents.xml file. + // Get the "download" URL, which is the source from which we download + // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); if (download_url != NULL) { _download_url_prefix = download_url; @@ -339,7 +313,7 @@ read_xhost(TiXmlElement *xhost) { } else { _download_url_prefix = _host_url_prefix; } - + TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); while (xmirror != NULL) { const char *url = xmirror->Attribute("url"); @@ -350,36 +324,32 @@ read_xhost(TiXmlElement *xhost) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_package -// Access: Public -// Description: Returns a (possibly shared) pointer to the indicated -// package. -// -// The package_seq value should be the expected minimum -// package_seq value for the indicated package. If the -// given seq value is higher than the package_seq value -// in the contents.xml file cached for the host, it is a -// sign that the contents.xml file is out of date and -// needs to be redownloaded. -//////////////////////////////////////////////////////////////////// +/** + * Returns a (possibly shared) pointer to the indicated package. + * + * The package_seq value should be the expected minimum package_seq value for + * the indicated package. If the given seq value is higher than the + * package_seq value in the contents.xml file cached for the host, it is a + * sign that the contents.xml file is out of date and needs to be + * redownloaded. + */ P3DPackage *P3DHost:: get_package(const string &package_name, const string &package_version, - const string &package_platform, const string &package_seq, + const string &package_platform, const string &package_seq, const string &alt_host) { if (!alt_host.empty()) { if (_xcontents != NULL) { // If we're asking for an alt host and we've already read our - // contents.xml file, then we already know all of our hosts, and - // we can start the package off with the correct host immediately. + // contents.xml file, then we already know all of our hosts, and we can + // start the package off with the correct host immediately. P3DHost *new_host = get_alt_host(alt_host); - return new_host->get_package(package_name, package_version, + return new_host->get_package(package_name, package_version, package_platform, package_seq); } - // If we haven't read contents.xml yet, we need to create the - // package first, then let it be responsible for downloading our - // contents.xml, and it can migrate to its alt_host after that. + // If we haven't read contents.xml yet, we need to create the package + // first, then let it be responsible for downloading our contents.xml, and + // it can migrate to its alt_host after that. } string key = package_name + "_" + package_version; @@ -407,8 +377,8 @@ get_package(const string &package_name, const string &package_version, if (package != NULL) { if (package->get_failed()) { - // If the package has previously failed, move it aside and try - // again (maybe it just failed because the user interrupted it). + // If the package has previously failed, move it aside and try again + // (maybe it just failed because the user interrupted it). nout << "Package " << key << " has previously failed; trying again.\n"; _failed_packages.push_back(package); ppackages.erase(ppi); @@ -417,16 +387,16 @@ get_package(const string &package_name, const string &package_version, } if (package == NULL) { - package = + package = new P3DPackage(this, package_name, package_version, package_platform, alt_host); ppackages.push_back(package); } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!package_seq.empty() && has_current_contents_file(inst_mgr)) { - // If we were given a specific package_seq file to verify, and we - // believe we have a valid contents.xml file, then check the seq - // value in the contents. + // If we were given a specific package_seq file to verify, and we believe + // we have a valid contents.xml file, then check the seq value in the + // contents. FileSpec desc_file; string seq; bool solo; @@ -435,27 +405,23 @@ get_package(const string &package_name, const string &package_version, nout << package_name << ": asked for seq " << package_seq << ", we have seq " << seq << "\n"; if (compare_seq(package_seq, seq) > 0) { - // The requested seq value is higher than the one we have on - // file; our contents.xml file must be out of date after all. + // The requested seq value is higher than the one we have on file; our + // contents.xml file must be out of date after all. nout << "expiring contents.xml for " << get_host_url() << "\n"; _contents_expiration = 0; } } } - + return package; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::choose_suitable_platform -// Access: Public -// Description: Chooses the most appropriate platform for the -// indicated package based on what this hardware -// supports and what is actually available. Also fills -// in per_platform, which is a boolean value indicating -// whether the directory structure contains the platform -// directory or not. -//////////////////////////////////////////////////////////////////// +/** + * Chooses the most appropriate platform for the indicated package based on + * what this hardware supports and what is actually available. Also fills in + * per_platform, which is a boolean value indicating whether the directory + * structure contains the platform directory or not. + */ bool P3DHost:: choose_suitable_platform(string &selected_platform, bool &per_platform, @@ -470,8 +436,8 @@ choose_suitable_platform(string &selected_platform, TiXmlElement *xpackage; - // If the platform is initially unspecified, we allow searching for - // any available supported platform. + // If the platform is initially unspecified, we allow searching for any + // available supported platform. if (package_platform == "") { int num_supported_platforms = inst_mgr->get_num_supported_platforms(); for (int pi = 0; pi < num_supported_platforms; ++pi) { @@ -488,7 +454,7 @@ choose_suitable_platform(string &selected_platform, version = ""; } if (name != NULL && - package_name == name && + package_name == name && supported_platform == platform && package_version == version) { // Here's the matching package definition. @@ -496,7 +462,7 @@ choose_suitable_platform(string &selected_platform, per_platform = parse_bool_attrib(xpackage, "per_platform", false); return true; } - + xpackage = xpackage->NextSiblingElement("package"); } } @@ -515,7 +481,7 @@ choose_suitable_platform(string &selected_platform, version = ""; } if (name != NULL && - package_name == name && + package_name == name && package_platform == platform && package_version == version) { // Here's the matching package definition. @@ -541,7 +507,7 @@ choose_suitable_platform(string &selected_platform, version = ""; } if (name != NULL && - package_name == name && + package_name == name && *platform == '\0' && package_version == version) { selected_platform = platform; @@ -556,16 +522,12 @@ choose_suitable_platform(string &selected_platform, return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::get_package_desc_file -// Access: Public -// Description: Fills the indicated FileSpec with the hash -// information for the package's desc file, and also -// determines the package's platform. Returns true if -// successful, false if the package is unknown. This -// requires has_contents_file() to return true in order -// to be successful. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated FileSpec with the hash information for the package's + * desc file, and also determines the package's platform. Returns true if + * successful, false if the package is unknown. This requires + * has_contents_file() to return true in order to be successful. + */ bool P3DHost:: get_package_desc_file(FileSpec &desc_file, // out string &package_seq, // out @@ -579,8 +541,8 @@ get_package_desc_file(FileSpec &desc_file, // out P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - // Scan the contents data for the indicated package. We expect to - // match the platform precisely, because we previously called + // Scan the contents data for the indicated package. We expect to match the + // platform precisely, because we previously called // choose_suitable_platform(). TiXmlElement *xpackage = _xcontents->FirstChildElement("package"); while (xpackage != NULL) { @@ -599,7 +561,7 @@ get_package_desc_file(FileSpec &desc_file, // out seq = ""; } if (name != NULL && platform != NULL && - package_name == name && + package_name == name && package_platform == platform && package_version == version) { // Here's the matching package definition. @@ -619,14 +581,11 @@ get_package_desc_file(FileSpec &desc_file, // out return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::forget_package -// Access: Public -// Description: Removes the indicated package from the cache of -// packages known by this host. This is invoked from -// the Python side by AppRunner.deletePackages(), so -// that we remove the package before deleting its files. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated package from the cache of packages known by this + * host. This is invoked from the Python side by AppRunner.deletePackages(), + * so that we remove the package before deleting its files. + */ void P3DHost:: forget_package(P3DPackage *package, const string &alt_host) { string key = package->get_package_name() + "_" + package->get_package_version(); @@ -636,21 +595,18 @@ forget_package(P3DPackage *package, const string &alt_host) { PlatformPackages::iterator ppi = find(ppackages.begin(), ppackages.end(), package); if (ppi != ppackages.end()) { - // Hmm, this is a memory leak. But we allow it to remain, since - // it's an unusual circumstance (uninstalling), and it's safer to - // leak than to risk a floating pointer. + // Hmm, this is a memory leak. But we allow it to remain, since it's an + // unusual circumstance (uninstalling), and it's safer to leak than to + // risk a floating pointer. ppackages.erase(ppi); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::migrate_package_host -// Access: Public -// Description: This is called by P3DPackage when it migrates from -// this host to its final alt_host, after downloading -// the contents.xml file for this file and learning the -// true URL for its target alt_host. -//////////////////////////////////////////////////////////////////// +/** + * This is called by P3DPackage when it migrates from this host to its final + * alt_host, after downloading the contents.xml file for this file and + * learning the true URL for its target alt_host. + */ void P3DHost:: migrate_package_host(P3DPackage *package, const string &alt_host, P3DHost *new_host) { assert(new_host != this); @@ -669,14 +625,11 @@ migrate_package_host(P3DPackage *package, const string &alt_host, P3DHost *new_h new_ppackages.push_back(package); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::choose_random_mirrors -// Access: Public -// Description: Selects num_mirrors elements, chosen at random, from -// the _mirrors list. Adds the selected mirrors to -// result. If there are fewer than num_mirrors elements -// in the list, adds only as many mirrors as we can get. -//////////////////////////////////////////////////////////////////// +/** + * Selects num_mirrors elements, chosen at random, from the _mirrors list. + * Adds the selected mirrors to result. If there are fewer than num_mirrors + * elements in the list, adds only as many mirrors as we can get. + */ void P3DHost:: choose_random_mirrors(vector &result, int num_mirrors) { vector selected; @@ -694,42 +647,35 @@ choose_random_mirrors(vector &result, int num_mirrors) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::add_mirror -// Access: Public -// Description: Adds a new URL to serve as a mirror for this host. -// The mirrors will be consulted first, before -// consulting the host directly. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new URL to serve as a mirror for this host. The mirrors will be + * consulted first, before consulting the host directly. + */ void P3DHost:: add_mirror(string mirror_url) { // Ensure the URL ends in a slash. if (!mirror_url.empty() && mirror_url[mirror_url.size() - 1] != '/') { mirror_url += '/'; } - - // Add it to the _mirrors list, but only if it's not already - // there. + + // Add it to the _mirrors list, but only if it's not already there. if (find(_mirrors.begin(), _mirrors.end(), mirror_url) == _mirrors.end()) { _mirrors.push_back(mirror_url); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::uninstall -// Access: Public -// Description: Removes the host directory and all its contents -// from the user's hard disk. -//////////////////////////////////////////////////////////////////// +/** + * Removes the host directory and all its contents from the user's hard disk. + */ void P3DHost:: uninstall() { if (_host_dir.empty()) { nout << "Cannot uninstall " << _descriptive_name << ": host directory not yet known.\n"; return; } - + P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - + // Check if we're even allowed to. if (inst_mgr->get_verify_contents() == P3D_VC_never) { nout << "Not allowed to uninstall " << _descriptive_name << ".\n"; @@ -757,16 +703,12 @@ uninstall() { inst_mgr->forget_host(this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::determine_host_dir -// Access: Private -// Description: Hashes the host_url into a (mostly) unique directory -// string, which will be the root of the host's install -// tree. Stores the result in _host_dir. -// -// This code is duplicated in Python, in -// HostInfo.determineHostDir(). -//////////////////////////////////////////////////////////////////// +/** + * Hashes the host_url into a (mostly) unique directory string, which will be + * the root of the host's install tree. Stores the result in _host_dir. + * + * This code is duplicated in Python, in HostInfo.determineHostDir(). + */ void P3DHost:: determine_host_dir(const string &host_dir_basename) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -784,11 +726,10 @@ determine_host_dir(const string &host_dir_basename) { string hostname; // Look for a server name in the URL. Including this string in the - // directory name makes it friendlier for people browsing the - // directory. + // directory name makes it friendlier for people browsing the directory. - // We can't use URLSpec here, because we don't link with Panda3D. - // We have to do it by hand. + // We can't use URLSpec here, because we don't link with Panda3D. We have to + // do it by hand. size_t p = _host_url.find("://"); if (p != string::npos) { size_t start = p + 3; @@ -809,14 +750,15 @@ determine_host_dir(const string &host_dir_basename) { hostname = _host_url.substr(start, end - start); } - // Now build a hash string of the whole URL. We'll use MD5 to get a - // pretty good hash, with a minimum chance of collision. Even if - // there is a hash collision, though, it's not the end of the world; - // it just means that both hosts will dump their packages into the - // same directory, and they'll fight over the toplevel contents.xml - // file. Assuming they use different version numbers (which should - // be safe since they have the same hostname), there will be minimal - // redownloading. +/* + * Now build a hash string of the whole URL. We'll use MD5 to get a pretty + * good hash, with a minimum chance of collision. Even if there is a hash + * collision, though, it's not the end of the world; it just means that both + * hosts will dump their packages into the same directory, and they'll fight + * over the toplevel contents.xml file. Assuming they use different version + * numbers (which should be safe since they have the same hostname), there + * will be minimal redownloading. + */ static const size_t hash_size = 16; unsigned char md[hash_size]; @@ -827,8 +769,8 @@ determine_host_dir(const string &host_dir_basename) { _host_dir += hostname; _host_dir += "_"; - // If we successfully got a hostname, we don't really need the - // full hash. We'll keep half of it. + // If we successfully got a hostname, we don't really need the full hash. + // We'll keep half of it. keep_hash = keep_hash / 2; } @@ -846,15 +788,12 @@ determine_host_dir(const string &host_dir_basename) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::standardize_filename -// Access: Private, Static -// Description: Attempts to change the filename into some standard -// form for comparison with other filenames. On a -// case-insensitive filesystem, this converts the -// filename to lowercase. On Windows, it further -// replaces forward slashes with backslashes. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to change the filename into some standard form for comparison with + * other filenames. On a case-insensitive filesystem, this converts the + * filename to lowercase. On Windows, it further replaces forward slashes + * with backslashes. + */ string P3DHost:: standardize_filename(const string &filename) { #if defined(_WIN32) || defined(__APPLE__) @@ -876,12 +815,10 @@ standardize_filename(const string &filename) { #endif // _WIN32 || __APPLE__ } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::copy_file -// Access: Private, Static -// Description: Copies the data in the file named by from_filename -// into the file named by to_filename. -//////////////////////////////////////////////////////////////////// +/** + * Copies the data in the file named by from_filename into the file named by + * to_filename. + */ bool P3DHost:: copy_file(const string &from_filename, const string &to_filename) { #ifdef _WIN32 @@ -891,10 +828,10 @@ copy_file(const string &from_filename, const string &to_filename) { in.open(from_filename_w.c_str(), ios::in | ios::binary); } - // Copy to a temporary file first, in case (a) the filenames - // actually refer to the same file, or (b) in case we have different - // processes writing to the same file, and (c) to prevent - // partially overwriting the file should something go wrong. + // Copy to a temporary file first, in case (a) the filenames actually refer + // to the same file, or (b) in case we have different processes writing to + // the same file, and (c) to prevent partially overwriting the file should + // something go wrong. ostringstream strm; strm << to_filename << ".t"; strm << GetCurrentProcessId() << "_" << GetCurrentThreadId(); @@ -904,10 +841,10 @@ copy_file(const string &from_filename, const string &to_filename) { if (string_to_wstring(temp_filename_w, temp_filename)) { out.open(temp_filename_w.c_str(), ios::out | ios::binary); } - + static const size_t buffer_size = 4096; char buffer[buffer_size]; - + in.read(buffer, buffer_size); streamsize count = in.gcount(); while (count != 0) { @@ -946,10 +883,10 @@ copy_file(const string &from_filename, const string &to_filename) { ifstream in; in.open(from_filename.c_str(), ios::in | ios::binary); - // Copy to a temporary file first, in case (a) the filenames - // actually refer to the same file, or (b) in case we have different - // processes writing to the same file, and (c) to prevent - // partially overwriting the file should something go wrong. + // Copy to a temporary file first, in case (a) the filenames actually refer + // to the same file, or (b) in case we have different processes writing to + // the same file, and (c) to prevent partially overwriting the file should + // something go wrong. ostringstream strm; strm << to_filename << ".t"; strm << getpid(); @@ -957,10 +894,10 @@ copy_file(const string &from_filename, const string &to_filename) { string temp_filename = strm.str(); ofstream out; out.open(temp_filename.c_str(), ios::out | ios::binary); - + static const size_t buffer_size = 4096; char buffer[buffer_size]; - + in.read(buffer, buffer_size); size_t count = in.gcount(); while (count != 0) { @@ -993,17 +930,14 @@ copy_file(const string &from_filename, const string &to_filename) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::save_xml_file -// Access: Private, Static -// Description: Stores the XML document to the file named by -// to_filename, safely. -//////////////////////////////////////////////////////////////////// +/** + * Stores the XML document to the file named by to_filename, safely. + */ bool P3DHost:: save_xml_file(TiXmlDocument *doc, const string &to_filename) { - // Save to a temporary file first, in case (a) we have different - // processes writing to the same file, and (b) to prevent partially - // overwriting the file should something go wrong. + // Save to a temporary file first, in case (a) we have different processes + // writing to the same file, and (b) to prevent partially overwriting the + // file should something go wrong. #ifdef _WIN32 ostringstream strm; @@ -1058,13 +992,10 @@ save_xml_file(TiXmlDocument *doc, const string &to_filename) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::compare_seq -// Access: Private, Static -// Description: Compares the two dotted-integer sequence values -// numerically. Returns -1 if seq_a sorts first, 1 if -// seq_b sorts first, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Compares the two dotted-integer sequence values numerically. Returns -1 if + * seq_a sorts first, 1 if seq_b sorts first, 0 if they are equivalent. + */ int P3DHost:: compare_seq(const string &seq_a, const string &seq_b) { const char *num_a = seq_a.c_str(); @@ -1092,13 +1023,11 @@ compare_seq(const string &seq_a, const string &seq_b) { return comp; } -//////////////////////////////////////////////////////////////////// -// Function: P3DHost::compare_seq_int -// Access: Private, Static -// Description: Numerically compares the formatted integer value at -// num_a with num_b. Increments both num_a and num_b to -// the next character following the valid integer. -//////////////////////////////////////////////////////////////////// +/** + * Numerically compares the formatted integer value at num_a with num_b. + * Increments both num_a and num_b to the next character following the valid + * integer. + */ int P3DHost:: compare_seq_int(const char *&num_a, const char *&num_b) { long int a; diff --git a/direct/src/plugin/p3dHost.h b/direct/src/plugin/p3dHost.h index b69922c3e2..adc66501c7 100644 --- a/direct/src/plugin/p3dHost.h +++ b/direct/src/plugin/p3dHost.h @@ -1,16 +1,15 @@ -// Filename: p3dHost.h -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dHost.h + * @author drose + * @date 2009-08-21 + */ #ifndef P3DHOST_H #define P3DHOST_H @@ -23,11 +22,9 @@ class FileSpec; class P3DInstanceManager; class P3DPackage; -//////////////////////////////////////////////////////////////////// -// Class : P3DHost -// Description : Represents a particular download host serving up -// Panda3D packages. -//////////////////////////////////////////////////////////////////// +/** + * Represents a particular download host serving up Panda3D packages. + */ class P3DHost { private: P3DHost(const string &host_url, const string &host_dir = ""); @@ -52,7 +49,7 @@ public: bool read_contents_file(const string &contents_filename, bool fresh_download); void read_xhost(TiXmlElement *xhost); - P3DPackage *get_package(const string &package_name, + P3DPackage *get_package(const string &package_name, const string &package_version, const string &package_platform, const string &package_seq, @@ -62,7 +59,7 @@ public: const string &package_name, const string &package_version, const string &package_platform); - bool get_package_desc_file(FileSpec &desc_file, + bool get_package_desc_file(FileSpec &desc_file, string &package_seq, bool &package_solo, const string &package_name, diff --git a/direct/src/plugin/p3dInstance.I b/direct/src/plugin/p3dInstance.I index c88f10c3cf..4168f68ac8 100644 --- a/direct/src/plugin/p3dInstance.I +++ b/direct/src/plugin/p3dInstance.I @@ -1,160 +1,125 @@ -// Filename: p3dInstance.I -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstance.I + * @author drose + * @date 2009-05-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_fparams -// Access: Public -// Description: Returns the current file parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file parameters. + */ inline const P3DFileParams &P3DInstance:: get_fparams() const { return _fparams; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_wparams -// Access: Public -// Description: Returns the current window parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current window parameters. + */ inline const P3DWindowParams &P3DInstance:: get_wparams() const { return _wparams; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_instance_id -// Access: Public -// Description: Returns a unique integer for each instance in the -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique integer for each instance in the system. + */ inline int P3DInstance:: get_instance_id() const { return _instance_id; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_session_key -// Access: Public -// Description: Returns a string that uniquely identifies this -// session. This is a constructed string that includes -// the supplied session_name, the python and panda -// version, and the publisher, as well as any other -// relevant details; it is guaranteed to be unique for -// each unique session required for different -// P3DInstances. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that uniquely identifies this session. This is a + * constructed string that includes the supplied session_name, the python and + * panda version, and the publisher, as well as any other relevant details; it + * is guaranteed to be unique for each unique session required for different + * P3DInstances. + */ inline const string &P3DInstance:: get_session_key() const { return _session_key; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_session_platform -// Access: Public -// Description: Returns the platform of this particular session. -// Before the panda3d package has been seen, this is the -// empty string; once we have downloaded the info file -// for the panda3d package, it is filled in with -// whatever platform is provided (that we're also -// runtime-compatible with). -// -// Presumably all of the platform-specific packages that -// are downloaded subsequently must be of the exact same -// platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the platform of this particular session. Before the panda3d + * package has been seen, this is the empty string; once we have downloaded + * the info file for the panda3d package, it is filled in with whatever + * platform is provided (that we're also runtime-compatible with). + * + * Presumably all of the platform-specific packages that are downloaded + * subsequently must be of the exact same platform. + */ inline const string &P3DInstance:: get_session_platform() const { return _session_platform; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_session -// Access: Public -// Description: Returns the P3DSession that is hosting this instance, -// or NULL if the instance is not running. -//////////////////////////////////////////////////////////////////// +/** + * Returns the P3DSession that is hosting this instance, or NULL if the + * instance is not running. + */ inline P3DSession *P3DInstance:: get_session() const { return _session; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_request_ready_func -// Access: Public -// Description: Returns a pointer to the asynchronous notification -// function that was passed to the constructor, if any, -// or NULL if asynchronous notifications are not -// required. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the asynchronous notification function that was passed + * to the constructor, if any, or NULL if asynchronous notifications are not + * required. + */ inline P3D_request_ready_func *P3DInstance:: get_request_ready_func() const { return _func; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::is_trusted -// Access: Public -// Description: Returns true if this instance's p3d file is trusted -// and ready to launch, false if it needs to be approved -// by the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this instance's p3d file is trusted and ready to launch, + * false if it needs to be approved by the user. + */ inline bool P3DInstance:: is_trusted() const { return _p3d_trusted; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_matches_script_origin -// Access: Public -// Description: Returns true if this instance is allowed to be -// scripted by its embedding web page, false otherwise. -// This may not be known until the p3d file has been -// fully downloaded and opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this instance is allowed to be scripted by its embedding + * web page, false otherwise. This may not be known until the p3d file has + * been fully downloaded and opened. + */ inline bool P3DInstance:: get_matches_script_origin() const { return _matches_script_origin; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::is_started -// Access: Public -// Description: Returns true if this instance has already been -// started within some session, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this instance has already been started within some session, + * false otherwise. + */ inline bool P3DInstance:: is_started() const { return (_session != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::is_failed -// Access: Public -// Description: Returns true if this instance has tried and failed to -// launch for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this instance has tried and failed to launch for some + * reason. + */ inline bool P3DInstance:: is_failed() const { return _failed; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ImageFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DInstance::ImageFile:: ImageFile() { _use_standard_image = true; @@ -162,21 +127,17 @@ ImageFile() { _image_placement = P3DSplashWindow::IP_none; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ImageFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DInstance::ImageFile:: ~ImageFile() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ImageFile::cleanup -// Access: Public -// Description: Removes the temporary file, if any. -//////////////////////////////////////////////////////////////////// +/** + * Removes the temporary file, if any. + */ inline void P3DInstance::ImageFile:: cleanup() { if (_temp_filename != NULL) { diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 87fbf64dee..b3f96b3f9c 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -1,16 +1,15 @@ -// Filename: p3dInstance.cxx -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstance.cxx + * @author drose + * @date 2009-05-29 + */ #include "p3dInstance.h" #include "p3dInstanceManager.h" @@ -60,12 +59,12 @@ typedef P3DX11SplashWindow SplashWindowType; typedef P3DSplashWindow SplashWindowType; #endif -// The amount of time (in seconds) over which we average the total -// download time, for smoothing out the time estimate. +// The amount of time (in seconds) over which we average the total download +// time, for smoothing out the time estimate. static const double time_average = 10.0; -// These are the various image files we might download for use in the -// splash window. This list must match the ImageType enum. +// These are the various image files we might download for use in the splash +// window. This list must match the ImageType enum. const char *P3DInstance::_image_type_names[P3DInstance::IT_num_image_types] = { "download", "unauth", @@ -91,14 +90,12 @@ write_str(ostream &out, const wchar_t *str) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstance:: -P3DInstance(P3D_request_ready_func *func, - const P3D_token tokens[], size_t num_tokens, +P3DInstance(P3D_request_ready_func *func, + const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data) : _func(func) { @@ -159,7 +156,7 @@ P3DInstance(P3D_request_ready_func *func, _download_started = false; _download_complete = false; _instance_started = false; - + INIT_LOCK(_request_lock); _requested_stop = false; @@ -173,8 +170,8 @@ P3DInstance(P3D_request_ready_func *func, _buffer_color_space = NULL; _buffer_image = NULL; - // We have to start with _mouse_active true; firefox doesn't send - // activate events. + // We have to start with _mouse_active true; firefox doesn't send activate + // events. _mouse_active = true; _modifiers = 0; _frame_timer = NULL; @@ -199,14 +196,14 @@ P3DInstance(P3D_request_ready_func *func, if (!inst_mgr->get_plugin_official_version()) { stream << "c"; } - - // The plugin version as a single number, with three digits reserved - // for each component. - int numeric_version = - inst_mgr->get_plugin_major_version() * 1000000 + - inst_mgr->get_plugin_minor_version() * 1000 + + + // The plugin version as a single number, with three digits reserved for + // each component. + int numeric_version = + inst_mgr->get_plugin_major_version() * 1000000 + + inst_mgr->get_plugin_minor_version() * 1000 + inst_mgr->get_plugin_sequence_version(); - if (!inst_mgr->get_plugin_official_version()) { + if (!inst_mgr->get_plugin_official_version()) { // Subtract 1 if we are not an official version. --numeric_version; } @@ -231,24 +228,24 @@ P3DInstance(P3D_request_ready_func *func, _main_object->set_bool_property("trustedEnvironment", (int)inst_mgr->get_trusted_environment()); _main_object->set_bool_property("consoleEnvironment", (int)inst_mgr->get_console_environment()); - // We'll start off with the "download" image displayed in the splash - // window (when it opens), until we get stuff downloaded. + // We'll start off with the "download" image displayed in the splash window + // (when it opens), until we get stuff downloaded. set_background_image(IT_download); - // We'd better ask for the image package up front, even if it turns - // out we don't need it for this particular app. We'll probably use - // it eventually, and it's good to have it loaded early, so we can - // put up a splash image (for instance, the above IT_download image) - // while we download the real contents. + // We'd better ask for the image package up front, even if it turns out we + // don't need it for this particular app. We'll probably use it eventually, + // and it's good to have it loaded early, so we can put up a splash image + // (for instance, the above IT_download image) while we download the real + // contents. P3DHost *host = inst_mgr->get_host(inst_mgr->get_host_url()); _image_package = host->get_package("images", "", "", ""); if (_image_package != NULL) { _image_package->add_instance(this); } - // Check if the window size has been explicitly set to 0. This - // means we have an explicitly hidden plugin, and we should be - // prepared not to get a wparams from the browser. + // Check if the window size has been explicitly set to 0. This means we + // have an explicitly hidden plugin, and we should be prepared not to get a + // wparams from the browser. if (_fparams.has_token("width") && _fparams.has_token("height") && (_fparams.lookup_token_int("width") == 0 || _fparams.lookup_token_int("height") == 0)) { @@ -259,11 +256,9 @@ P3DInstance(P3D_request_ready_func *func, } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstance:: ~P3DInstance() { assert(_session == NULL); @@ -294,16 +289,13 @@ P3DInstance:: DESTROY_LOCK(_request_lock); - // TODO: Is it possible for someone to delete an instance while a - // download is still running? Who will crash when this happens? + // TODO: Is it possible for someone to delete an instance while a download + // is still running? Who will crash when this happens? } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::cleanup -// Access: Public -// Description: Invalidates the instance and removes any structures -// prior to deleting. -//////////////////////////////////////////////////////////////////// +/** + * Invalidates the instance and removes any structures prior to deleting. + */ void P3DInstance:: cleanup() { _failed = true; @@ -313,13 +305,12 @@ cleanup() { p3d_unref_delete(_auth_session); _auth_session = NULL; } - + for (int i = 0; i < (int)IT_num_image_types; ++i) { _image_files[i].cleanup(); } - // Tell all of the packages that we're no longer in business for - // them. + // Tell all of the packages that we're no longer in business for them. Packages::iterator pi; for (pi = _packages.begin(); pi != _packages.end(); ++pi) { (*pi)->remove_instance(this); @@ -349,7 +340,7 @@ cleanup() { delete _temp_p3d_filename; _temp_p3d_filename = NULL; } - + if (_xpackage != NULL) { delete _xpackage; _xpackage = NULL; @@ -363,7 +354,7 @@ cleanup() { } free_swbuffer(); -#endif +#endif TiXmlDocument *doc = NULL; ACQUIRE_LOCK(_request_lock); @@ -390,20 +381,15 @@ cleanup() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_p3d_url -// Access: Public -// Description: Specifies a URL that should be contacted to download -// the instance data. Normally this, or -// set_p3d_filename() or make_p3d_stream(), is only -// called once. -// -// The instance data at the other end of this URL is -// key. We can't start the instance until we have -// downloaded the instance file and examined the -// p3d_info.xml, and we know what Python version we need -// and so forth. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a URL that should be contacted to download the instance data. + * Normally this, or set_p3d_filename() or make_p3d_stream(), is only called + * once. + * + * The instance data at the other end of this URL is key. We can't start the + * instance until we have downloaded the instance file and examined the + * p3d_info.xml, and we know what Python version we need and so forth. + */ void P3DInstance:: set_p3d_url(const string &p3d_url) { if (p3d_url.empty()) { @@ -413,8 +399,8 @@ set_p3d_url(const string &p3d_url) { } _fparams.set_p3d_url(p3d_url); - // Save the last part of the URL as the p3d_basename, for reporting - // purposes or whatever. + // Save the last part of the URL as the p3d_basename, for reporting purposes + // or whatever. determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. @@ -425,8 +411,8 @@ set_p3d_url(const string &p3d_url) { // Maybe it's time to open a splash window now. make_splash_window(); - // Mark the time we started downloading, so we'll know when to reveal - // the progress bar, and we can predict the total download time. + // Mark the time we started downloading, so we'll know when to reveal the + // progress bar, and we can predict the total download time. #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else @@ -446,19 +432,16 @@ set_p3d_url(const string &p3d_url) { start_download(download); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::make_p3d_stream -// Access: Public -// Description: Indicates an intention to transmit the p3d data as a -// stream. Should return a new unique stream ID to -// receive it. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an intention to transmit the p3d data as a stream. Should return + * a new unique stream ID to receive it. + */ int P3DInstance:: make_p3d_stream(const string &p3d_url) { _fparams.set_p3d_url(p3d_url); - // Save the last part of the URL as the p3d_basename, for reporting - // purposes or whatever. + // Save the last part of the URL as the p3d_basename, for reporting purposes + // or whatever. determine_p3d_basename(p3d_url); // Make a temporary file to receive the instance data. @@ -469,8 +452,8 @@ make_p3d_stream(const string &p3d_url) { // Maybe it's time to open a splash window now. make_splash_window(); - // Mark the time we started downloading, so we'll know when to reveal - // the progress bar. + // Mark the time we started downloading, so we'll know when to reveal the + // progress bar. #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else @@ -490,25 +473,20 @@ make_p3d_stream(const string &p3d_url) { return start_download(download, false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_p3d_filename -// Access: Public -// Description: Specifies the file that contains the instance data. -// Normally this is only called once. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the file that contains the instance data. Normally this is only + * called once. + */ void P3DInstance:: set_p3d_filename(const string &p3d_filename, const int &p3d_offset) { determine_p3d_basename(p3d_filename); priv_set_p3d_filename(p3d_filename, p3d_offset); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_wparams -// Access: Public -// Description: Changes the window parameters, e.g. to resize or -// reposition the window; or sets the parameters for the -// first time, creating the initial window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window parameters, e.g. to resize or reposition the window; or + * sets the parameters for the first time, creating the initial window. + */ void P3DInstance:: set_wparams(const P3DWindowParams &wparams) { bool prev_got_wparams = _got_wparams; @@ -520,9 +498,8 @@ set_wparams(const P3DWindowParams &wparams) { << "\n"; if (_hidden || _wparams.get_win_width() == 0 || _wparams.get_win_height() == 0) { - // If we're a hidden app, or if the window has no size, then it is - // really a hidden window, regardless of what type it claims to - // be. + // If we're a hidden app, or if the window has no size, then it is really + // a hidden window, regardless of what type it claims to be. _wparams.set_window_type(P3D_WT_hidden); } @@ -534,18 +511,18 @@ set_wparams(const P3DWindowParams &wparams) { make_splash_window(); } } - - // It doesn't make much sense to go further than this point - // if the instance is already in the failed state. + + // It doesn't make much sense to go further than this point if the instance + // is already in the failed state. if (is_failed()) { return; } - + if (_wparams.get_window_type() != P3D_WT_hidden) { #ifdef __APPLE__ - // On Mac, we have to communicate the results of the rendering - // back via shared memory, instead of directly parenting windows - // to the browser. Set up this mechanism. + // On Mac, we have to communicate the results of the rendering back via + // shared memory, instead of directly parenting windows to the browser. + // Set up this mechanism. int x_size = _wparams.get_win_width(); int y_size = _wparams.get_win_height(); if (x_size != 0 && y_size != 0) { @@ -554,7 +531,7 @@ set_wparams(const P3DWindowParams &wparams) { // We need to open a new shared buffer. alloc_swbuffer(); } - + if (_swbuffer == NULL) { nout << "Could not open swbuffer\n"; } @@ -569,7 +546,7 @@ set_wparams(const P3DWindowParams &wparams) { xcommand->SetAttribute("cmd", "setup_window"); xcommand->SetAttribute("instance_id", get_instance_id()); TiXmlElement *xwparams = _wparams.make_xml(this); - + doc->LinkEndChild(xcommand); xcommand->LinkEndChild(xwparams); @@ -584,28 +561,21 @@ set_wparams(const P3DWindowParams &wparams) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_panda_script_object -// Access: Public -// Description: Returns a pointer to the top-level scriptable object -// of the instance, to be used by JavaScript code in the -// browser to control this program. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the top-level scriptable object of the instance, to be + * used by JavaScript code in the browser to control this program. + */ P3D_object *P3DInstance:: get_panda_script_object() const { nout << "get_panda_script_object\n"; return _main_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_browser_script_object -// Access: Public -// Description: Stores a pointer to the top-level window object -// of the browser, to be used by Panda code to control -// JavaScript. The new object's reference count is -// incremented, and the previous object's is -// decremented. -//////////////////////////////////////////////////////////////////// +/** + * Stores a pointer to the top-level window object of the browser, to be used + * by Panda code to control JavaScript. The new object's reference count is + * incremented, and the previous object's is decremented. + */ void P3DInstance:: set_browser_script_object(P3D_object *browser_script_object) { nout << "set_browser_script_object\n"; @@ -621,9 +591,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } } - // Query the origin: protocol, hostname, and port. We'll use this to - // limit access to the scripting interfaces for a particular p3d - // file. + // Query the origin: protocol, hostname, and port. We'll use this to limit + // access to the scripting interfaces for a particular p3d file. _origin_protocol.clear(); _origin_hostname.clear(); _origin_port.clear(); @@ -665,8 +634,8 @@ set_browser_script_object(P3D_object *browser_script_object) { } if (_origin_port.empty()) { - // Maybe the actual URL doesn't include the port, in which - // case it is implicit. + // Maybe the actual URL doesn't include the port, in which case it is + // implicit. if (_origin_protocol == "http:") { _origin_port = "80"; } else if (_origin_protocol == "https:") { @@ -686,26 +655,21 @@ set_browser_script_object(P3D_object *browser_script_object) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::has_request -// Access: Public -// Description: Returns true if the instance has any pending requests -// at the time of this call, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the instance has any pending requests at the time of this + * call, false otherwise. + */ bool P3DInstance:: has_request() { return _request_pending; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_request -// Access: Public -// Description: Returns a newly-allocated P3D_request corresponding -// to the pending request for the host, or NULL if there -// is no pending request. If the return value is -// non-NULL, it should eventually be passed back to -// finish_request() for cleanup. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated P3D_request corresponding to the pending request + * for the host, or NULL if there is no pending request. If the return value + * is non-NULL, it should eventually be passed back to finish_request() for + * cleanup. + */ P3D_request *P3DInstance:: get_request() { bake_requests(); @@ -736,8 +700,8 @@ get_request() { case P3D_RT_stop: { - // We also send an implicit message when Python requests itself - // to shutdown. + // We also send an implicit message when Python requests itself to + // shutdown. _main_object->set_pyobj(NULL); _main_object->set_string_property("status", "stopped"); @@ -753,8 +717,7 @@ get_request() { case P3D_RT_callback: { - // And when the callback request is extracted, we make the - // callback. + // And when the callback request is extracted, we make the callback. P3D_callback_func *func = request->_request._callback._func; void *data = request->_request._callback._data; (*func)(data); @@ -791,20 +754,17 @@ get_request() { return request; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::bake_requests -// Access: Public -// Description: Copies requests from the _raw_requests queue, which -// is built up in one or more sub-threads, into the -// _baked_requests queue, which is publicly presented -// to the browser. Along the way, some requests (like -// script requests) are handled immediately. -// -// At the end of this call, _baked_requests will contain -// the current set of requests pending for the browser. -// -// This method should only be called in the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Copies requests from the _raw_requests queue, which is built up in one or + * more sub-threads, into the _baked_requests queue, which is publicly + * presented to the browser. Along the way, some requests (like script + * requests) are handled immediately. + * + * At the end of this call, _baked_requests will contain the current set of + * requests pending for the browser. + * + * This method should only be called in the main thread. + */ void P3DInstance:: bake_requests() { while (true) { @@ -816,33 +776,29 @@ bake_requests() { _raw_requests.pop_front(); } RELEASE_LOCK(_request_lock); - + if (doc == NULL) { // No more requests to process right now. return; } - // Now we've got a request in XML form; convert it to P3D_request - // form. + // Now we've got a request in XML form; convert it to P3D_request form. TiXmlElement *xrequest = doc->FirstChildElement("request"); assert(xrequest != (TiXmlElement *)NULL); P3D_request *request = make_p3d_request(xrequest); delete doc; - + if (request != NULL) { _baked_requests.push_back(request); } } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_raw_request -// Access: Public -// Description: May be called in any thread to add a new XML request -// to the pending_request queue for this instance. The -// XML document will be deleted when the request is -// eventually handled. -//////////////////////////////////////////////////////////////////// +/** + * May be called in any thread to add a new XML request to the pending_request + * queue for this instance. The XML document will be deleted when the request + * is eventually handled. + */ void P3DInstance:: add_raw_request(TiXmlDocument *doc) { ACQUIRE_LOCK(_request_lock); @@ -850,9 +806,8 @@ add_raw_request(TiXmlDocument *doc) { _request_pending = true; RELEASE_LOCK(_request_lock); - // We don't decode the XML yet, since we might be running in any - // thread here. We'll decode it in the main thread, where it's - // safe. + // We don't decode the XML yet, since we might be running in any thread + // here. We'll decode it in the main thread, where it's safe. // Tell the world we've got a new request. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -862,14 +817,11 @@ add_raw_request(TiXmlDocument *doc) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_baked_request -// Access: Public -// Description: May be called in the main thread only to add a new -// request to the baked_request queue. This request -// queue is directly passed on the browser without -// further processing at this level. -//////////////////////////////////////////////////////////////////// +/** + * May be called in the main thread only to add a new request to the + * baked_request queue. This request queue is directly passed on the browser + * without further processing at this level. + */ void P3DInstance:: add_baked_request(P3D_request *request) { assert(request->_instance == NULL); @@ -884,14 +836,11 @@ add_baked_request(P3D_request *request) { inst_mgr->signal_request_ready(this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::finish_request -// Access: Public, Static -// Description: Deallocates a previously-returned request from -// get_request(). If handled is true, the request has -// been handled by the host; otherwise, it has been -// ignored. -//////////////////////////////////////////////////////////////////// +/** + * Deallocates a previously-returned request from get_request(). If handled + * is true, the request has been handled by the host; otherwise, it has been + * ignored. + */ void P3DInstance:: finish_request(P3D_request *request, bool handled) { assert(request != NULL); @@ -902,7 +851,7 @@ finish_request(P3D_request *request, bool handled) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (inst_mgr->validate_instance(request->_instance) == NULL) { - // nout << "Ignoring unknown request " << request << "\n"; + // nout << "Ignoring unknown request " << request << "\n"; return; } @@ -949,19 +898,16 @@ finish_request(P3D_request *request, bool handled) { delete request; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::feed_url_stream -// Access: Public -// Description: Called by the host in response to a get_url request, -// this sends the data retrieved from the requested URL, -// a piece at a time. -//////////////////////////////////////////////////////////////////// +/** + * Called by the host in response to a get_url request, this sends the data + * retrieved from the requested URL, a piece at a time. + */ bool P3DInstance:: feed_url_stream(int unique_id, P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const unsigned char *this_data, + const unsigned char *this_data, size_t this_data_size) { Downloads::iterator di = _downloads.find(unique_id); if (di == _downloads.end()) { @@ -988,12 +934,10 @@ feed_url_stream(int unique_id, return download_ok; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::handle_event -// Access: Public -// Description: Responds to the os-generated window event. Returns -// true if the event is handled, false if ignored. -//////////////////////////////////////////////////////////////////// +/** + * Responds to the os-generated window event. Returns true if the event is + * handled, false if ignored. + */ bool P3DInstance:: handle_event(const P3D_event_data &event) { bool retval = false; @@ -1016,18 +960,14 @@ handle_event(const P3D_event_data &event) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_log_pathname -// Access: Public -// Description: Returns the log filename for this particular session, -// if the session was started and if it has a log file. -// Returns empty string if the session never started or -// if it lacks a log file. -// -// This is the same value returned by -// P3DSession::get_log_pathname(), except that it -// remains valid even after the session has closed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the log filename for this particular session, if the session was + * started and if it has a log file. Returns empty string if the session + * never started or if it lacks a log file. + * + * This is the same value returned by P3DSession::get_log_pathname(), except + * that it remains valid even after the session has closed. + */ const string &P3DInstance:: get_log_pathname() const { if (_session != NULL) { @@ -1036,40 +976,35 @@ get_log_pathname() const { return _log_pathname; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_package -// Access: Public -// Description: Adds the package to the list of packages used by this -// instance. The instance will share responsibility for -// downloading the package with any of the other -// instances that use the same package. -// -// The seq value should be the expected minimum -// package_seq value for the indicated package. If the -// given seq value is higher than the package_seq value -// in the contents.xml file cached for the host, it is a -// sign that the contents.xml file is out of date and -// needs to be redownloaded. -//////////////////////////////////////////////////////////////////// +/** + * Adds the package to the list of packages used by this instance. The + * instance will share responsibility for downloading the package with any of + * the other instances that use the same package. + * + * The seq value should be the expected minimum package_seq value for the + * indicated package. If the given seq value is higher than the package_seq + * value in the contents.xml file cached for the host, it is a sign that the + * contents.xml file is out of date and needs to be redownloaded. + */ void P3DInstance:: add_package(const string &name, const string &version, const string &seq, P3DHost *host) { string alt_host = _fparams.lookup_token("alt_host"); - // Look up in the p3d_info.xml file to see if this p3d file has - // a specific alt_host indication for this host_url. + // Look up in the p3d_info.xml file to see if this p3d file has a specific + // alt_host indication for this host_url. string alt_host_url = find_alt_host_url(host->get_host_url(), alt_host); if (!alt_host_url.empty()) { - // If it does, we go ahead and switch to that host now, - // instead of bothering to contact the original host. + // If it does, we go ahead and switch to that host now, instead of + // bothering to contact the original host. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); host = inst_mgr->get_host(alt_host_url); alt_host.clear(); } if (!host->has_contents_file()) { - // Since we haven't downloaded this host's contents.xml file yet, - // get its additional host information. + // Since we haven't downloaded this host's contents.xml file yet, get its + // additional host information. get_host_info(host); } @@ -1077,15 +1012,12 @@ add_package(const string &name, const string &version, const string &seq, seq, alt_host); add_package(package); } - -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_package -// Access: Public -// Description: Adds the package to the list of packages used by this -// instance. The instance will share responsibility for -// downloading the package with any of the other -// instances that use the same package. -//////////////////////////////////////////////////////////////////// + +/** + * Adds the package to the list of packages used by this instance. The + * instance will share responsibility for downloading the package with any of + * the other instances that use the same package. + */ void P3DInstance:: add_package(P3DPackage *package) { if (find(_packages.begin(), _packages.end(), package) != _packages.end()) { @@ -1099,20 +1031,17 @@ add_package(P3DPackage *package) { _packages.push_back(package); - // This call must be at the end of this method, because it might - // ultimately start the application before it returns (if this was - // the last required package). + // This call must be at the end of this method, because it might ultimately + // start the application before it returns (if this was the last required + // package). package->add_instance(this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::remove_package -// Access: Public -// Description: Indicates that the given package is destructing and -// this instance should no longer retain a pointer to -// it. This is normally called only by the P3DPackage -// destructor, and it invalidates the instance. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given package is destructing and this instance should no + * longer retain a pointer to it. This is normally called only by the + * P3DPackage destructor, and it invalidates the instance. + */ void P3DInstance:: remove_package(P3DPackage *package) { Packages::iterator pi = find(_packages.begin(), _packages.end(), package); @@ -1139,14 +1068,11 @@ remove_package(P3DPackage *package) { set_failed(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_packages_info_ready -// Access: Public -// Description: Returns true if all of the packages required by the -// instance have their information available and are -// ready to be downloaded, false if one or more of them -// is still waiting for information (or has failed). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the packages required by the instance have their + * information available and are ready to be downloaded, false if one or more + * of them is still waiting for information (or has failed). + */ bool P3DInstance:: get_packages_info_ready() const { if (!_packages_specified) { @@ -1164,15 +1090,11 @@ get_packages_info_ready() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_packages_ready -// Access: Public -// Description: Returns true if all of the packages required by the -// instance (as specified in previous calls to -// add_package()) have been fully downloaded and are -// ready to run, or false if one or more of them still -// requires downloading. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the packages required by the instance (as specified + * in previous calls to add_package()) have been fully downloaded and are + * ready to run, or false if one or more of them still requires downloading. + */ bool P3DInstance:: get_packages_ready() const { if (!_packages_specified) { @@ -1190,13 +1112,10 @@ get_packages_ready() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_packages_failed -// Access: Public -// Description: Returns true if any of the packages required by the -// instance have failed to download (and thus we will -// never be ready). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the packages required by the instance have failed to + * download (and thus we will never be ready). + */ bool P3DInstance:: get_packages_failed() const { Packages::const_iterator pi; @@ -1209,27 +1128,22 @@ get_packages_failed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::start_download -// Access: Public -// Description: Adds a newly-allocated P3DDownload object to the -// download queue, and issues the request to start it -// downloading. As the download data comes in, it will -// be fed to the download object. -// -// This increments the P3DDownload object's reference -// count, and will decrement it (and possibly delete the -// object) after download_finished() has been called. -// -// add_request should be true to actually request the -// URL from the plugin, or false not to. Normally, this -// should always be set true, except in the one special -// case of make_p3d_stream(), in which case the plugin -// is already prepared to send the stream and doesn't -// need to have it requested. -// -// Returns the unique ID of this stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a newly-allocated P3DDownload object to the download queue, and issues + * the request to start it downloading. As the download data comes in, it + * will be fed to the download object. + * + * This increments the P3DDownload object's reference count, and will + * decrement it (and possibly delete the object) after download_finished() has + * been called. + * + * add_request should be true to actually request the URL from the plugin, or + * false not to. Normally, this should always be set true, except in the one + * special case of make_p3d_stream(), in which case the plugin is already + * prepared to send the stream and doesn't need to have it requested. + * + * Returns the unique ID of this stream. + */ int P3DInstance:: start_download(P3DDownload *download, bool add_request) { assert(download->get_download_id() == 0); @@ -1251,29 +1165,26 @@ start_download(P3DDownload *download, bool add_request) { bool inserted = _downloads.insert(Downloads::value_type(download_id, download)).second; assert(inserted); - // add_request will be false only for the initial p3d stream, which - // the plugin already knows about. For all other download streams, - // add_request is true in order to ask the plugin for the stream. + // add_request will be false only for the initial p3d stream, which the + // plugin already knows about. For all other download streams, add_request + // is true in order to ask the plugin for the stream. if (add_request) { P3D_request *request = new P3D_request; request->_instance = NULL; request->_request_type = P3D_RT_get_url; request->_request._get_url._url = strdup(download->get_url().c_str()); request->_request._get_url._unique_id = download_id; - + add_baked_request(request); } return download_id; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::request_stop_sub_thread -// Access: Public -// Description: Asks the host to shut down this particular instance, -// presumably because the user has indicated it should -// exit. This call may be made in any thread. -//////////////////////////////////////////////////////////////////// +/** + * Asks the host to shut down this particular instance, presumably because the + * user has indicated it should exit. This call may be made in any thread. + */ void P3DInstance:: request_stop_sub_thread() { // Atomically check _requested_stop. @@ -1291,18 +1202,16 @@ request_stop_sub_thread() { TiXmlElement *xrequest = new TiXmlElement("request"); xrequest->SetAttribute("rtype", "stop"); doc->LinkEndChild(xrequest); - + add_raw_request(doc); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::request_stop_main_thread -// Access: Public -// Description: Asks the host to shut down this particular instance, -// presumably because the user has indicated it should -// exit. This call may only be made in the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Asks the host to shut down this particular instance, presumably because the + * user has indicated it should exit. This call may only be made in the main + * thread. + */ void P3DInstance:: request_stop_main_thread() { // Atomically check _requested_stop. @@ -1324,13 +1233,10 @@ request_stop_main_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::request_refresh -// Access: Public -// Description: Asks the host to refresh the plugin window. This is -// only relevant for windowless plugins, for instance, -// the way OSX plugins always run. -//////////////////////////////////////////////////////////////////// +/** + * Asks the host to refresh the plugin window. This is only relevant for + * windowless plugins, for instance, the way OSX plugins always run. + */ void P3DInstance:: request_refresh() { P3D_request *request = new P3D_request; @@ -1339,11 +1245,9 @@ request_refresh() { add_baked_request(request); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::request_callback -// Access: Public -// Description: Asks the host to make a callback later. -//////////////////////////////////////////////////////////////////// +/** + * Asks the host to make a callback later. + */ void P3DInstance:: request_callback(P3D_callback_func *func, void *data) { P3D_request *request = new P3D_request; @@ -1354,12 +1258,10 @@ request_callback(P3D_callback_func *func, void *data) { add_baked_request(request); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::make_xml -// Access: Public -// Description: Returns a newly-allocated XML structure that -// corresponds to the data within this instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated XML structure that corresponds to the data within + * this instance. + */ TiXmlElement *P3DInstance:: make_xml() { assert(_got_fparams); @@ -1372,8 +1274,8 @@ make_xml() { xinstance->SetAttribute("log_directory", inst_mgr->get_log_directory()); xinstance->SetAttribute("verify_contents", (int)inst_mgr->get_verify_contents()); - // Tell the Panda process that it was started by a plugin that knows - // about the new per_platform flag. + // Tell the Panda process that it was started by a plugin that knows about + // the new per_platform flag. xinstance->SetAttribute("respect_per_platform", 1); if (!inst_mgr->get_super_mirror().empty()) { @@ -1402,14 +1304,11 @@ make_xml() { return xinstance; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::splash_button_clicked_sub_thread -// Access: Public -// Description: Called by the P3DSplashWindow code (maybe in a -// sub-thread) when the user clicks the button visible -// on the splash window. This will forward the event to -// the main thread via the request callback mechanism. -//////////////////////////////////////////////////////////////////// +/** + * Called by the P3DSplashWindow code (maybe in a sub-thread) when the user + * clicks the button visible on the splash window. This will forward the + * event to the main thread via the request callback mechanism. + */ void P3DInstance:: splash_button_clicked_sub_thread() { TiXmlDocument *doc = new TiXmlDocument; @@ -1421,14 +1320,11 @@ splash_button_clicked_sub_thread() { add_raw_request(doc); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::splash_button_clicked_main_thread -// Access: Public -// Description: Called only in the main thread, indirectly from -// splash_button_clicked_sub_thread(), as the result of -// the user clicking on the button visible in the splash -// window. -//////////////////////////////////////////////////////////////////// +/** + * Called only in the main thread, indirectly from + * splash_button_clicked_sub_thread(), as the result of the user clicking on + * the button visible in the splash window. + */ void P3DInstance:: splash_button_clicked_main_thread() { if (is_failed()) { @@ -1446,12 +1342,10 @@ splash_button_clicked_main_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::auth_button_clicked -// Access: Public -// Description: Called to authorize the p3d file by the user clicking -// the red "auth" button. -//////////////////////////////////////////////////////////////////// +/** + * Called to authorize the p3d file by the user clicking the red "auth" + * button. + */ void P3DInstance:: auth_button_clicked() { // Delete the previous session and create a new one. @@ -1460,19 +1354,16 @@ auth_button_clicked() { p3d_unref_delete(_auth_session); _auth_session = NULL; } - + P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _auth_session = inst_mgr->authorize_instance(this); _auth_session->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::play_button_clicked -// Access: Public -// Description: Called to start the game by the user clicking the -// green "play" button, or by JavaScript calling -// play(). -//////////////////////////////////////////////////////////////////// +/** + * Called to start the game by the user clicking the green "play" button, or + * by JavaScript calling play(). + */ void P3DInstance:: play_button_clicked() { if (_session == NULL && _p3d_trusted) { @@ -1493,13 +1384,11 @@ play_button_clicked() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::auth_finished_sub_thread -// Access: Public -// Description: Called by the P3DAuthSession code in a sub-thread -// when the auth dialog exits (for instance, because the -// user approved the certificate, or cancelled). -//////////////////////////////////////////////////////////////////// +/** + * Called by the P3DAuthSession code in a sub-thread when the auth dialog + * exits (for instance, because the user approved the certificate, or + * cancelled). + */ void P3DInstance:: auth_finished_sub_thread() { TiXmlDocument *doc = new TiXmlDocument; @@ -1511,38 +1400,30 @@ auth_finished_sub_thread() { add_raw_request(doc); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::auth_finished_main_thread -// Access: Public -// Description: Called only in the main thread, indirectly from -// auth_finished_sub_thread(), as the result of -// the user closing the auth dialog. -//////////////////////////////////////////////////////////////////// +/** + * Called only in the main thread, indirectly from auth_finished_sub_thread(), + * as the result of the user closing the auth dialog. + */ void P3DInstance:: auth_finished_main_thread() { - // Set this flag to indicate that the user has clicked on the red - // "auth" button. This eliminates the need to click on the green - // "start" button. + // Set this flag to indicate that the user has clicked on the red "auth" + // button. This eliminates the need to click on the green "start" button. _auth_button_clicked = true; - // After the authorization program has returned, check the signature - // again. + // After the authorization program has returned, check the signature again. check_p3d_signature(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::uninstall_packages -// Access: Public -// Description: Stops the instance (if it is running) and deletes any -// packages referenced by the instance. This is -// normally called by JavaScript, via -// P3DMainObject::call_uninstall(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the instance (if it is running) and deletes any packages referenced + * by the instance. This is normally called by JavaScript, via + * P3DMainObject::call_uninstall(). + */ bool P3DInstance:: uninstall_packages() { if (_packages.empty()) { - // If we have no packages (for instance, because we're untrusted), - // we can't uninstall anything. + // If we have no packages (for instance, because we're untrusted), we + // can't uninstall anything. nout << "Uninstall failed: no packages.\n"; return false; } @@ -1558,8 +1439,8 @@ uninstall_packages() { } } - // Also clean up the start directory, if we have a custom start dir. - // We won't do this if verify_contents is 'none'. + // Also clean up the start directory, if we have a custom start dir. We + // won't do this if verify_contents is 'none'. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (inst_mgr->get_verify_contents() != P3D_VC_never) { string start_dir_suffix = get_start_dir_suffix(); @@ -1573,21 +1454,17 @@ uninstall_packages() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::uninstall_host -// Access: Public -// Description: Stops the instance (if it is running) and deletes all -// packages downloaded from any of the host(s) -// referenced by the instance. This is a more -// aggressive uninstall than uninstall_packages(). This -// is normally called by JavaScript, via -// P3DMainObject::call_uninstall(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the instance (if it is running) and deletes all packages downloaded + * from any of the host(s) referenced by the instance. This is a more + * aggressive uninstall than uninstall_packages(). This is normally called by + * JavaScript, via P3DMainObject::call_uninstall(). + */ bool P3DInstance:: uninstall_host() { if (_packages.empty()) { - // If we have no packages (for instance, because we're untrusted), - // we can't uninstall anything. + // If we have no packages (for instance, because we're untrusted), we + // can't uninstall anything. nout << "Uninstall failed: no packages.\n"; return false; } @@ -1616,14 +1493,11 @@ uninstall_host() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::priv_set_p3d_filename -// Access: Private -// Description: The private implementation of set_p3d_filename(), -// this does all the work except for updating -// p3d_basename. It is intended to be called -// internally, and might be passed a temporary filename. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of set_p3d_filename(), this does all the work + * except for updating p3d_basename. It is intended to be called internally, + * and might be passed a temporary filename. + */ void P3DInstance:: priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset) { if (!_fparams.get_p3d_filename().empty()) { @@ -1641,9 +1515,9 @@ priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset) { _main_object->set_float_property("instanceDownloadProgress", 1.0); - // Generate a special notification: onpluginload, indicating the - // plugin has read its parameters and is ready to be queried (even - // if Python has not yet started). + // Generate a special notification: onpluginload, indicating the plugin has + // read its parameters and is ready to be queried (even if Python has not + // yet started). send_notify("onpluginload"); if (!_mf_reader.open_read(_fparams.get_p3d_filename(), _fparams.get_p3d_offset())) { @@ -1660,11 +1534,9 @@ priv_set_p3d_filename(const string &p3d_filename, const int &p3d_offset) { check_p3d_signature(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::determine_p3d_basename -// Access: Private -// Description: Determines _p3d_basename from the indicated URL. -//////////////////////////////////////////////////////////////////// +/** + * Determines _p3d_basename from the indicated URL. + */ void P3DInstance:: determine_p3d_basename(const string &p3d_url) { string file_part = p3d_url; @@ -1681,14 +1553,11 @@ determine_p3d_basename(const string &p3d_url) { nout << "p3d_basename = " << _p3d_basename << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::check_matches_origin -// Access: Private -// Description: Returns true if the indicated origin_match string, -// one of either run_origin or script_origin from the -// p3d_info.xml file, matches the origin of the page -// that embedded the p3d file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated origin_match string, one of either run_origin + * or script_origin from the p3d_info.xml file, matches the origin of the page + * that embedded the p3d file. + */ bool P3DInstance:: check_matches_origin(const string &origin_match) { // First, separate the string up at the semicolons. @@ -1710,12 +1579,10 @@ check_matches_origin(const string &origin_match) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::check_matches_origin_one -// Access: Private -// Description: Called for each semicolon-delimited string within -// origin_match passed to check_matches_origin(). -//////////////////////////////////////////////////////////////////// +/** + * Called for each semicolon-delimited string within origin_match passed to + * check_matches_origin(). + */ bool P3DInstance:: check_matches_origin_one(const string &origin_match) { // Do we have a protocol? @@ -1728,8 +1595,8 @@ check_matches_origin_one(const string &origin_match) { return false; } p = colon + 2; - // We'll support both http://hostname and http:/hostname, in case - // the user is sloppy. + // We'll support both http:hostname and http:hostname, in case the user is + // sloppy. if (p < origin_match.length() && origin_match[p] == '/') { ++p; } @@ -1755,15 +1622,12 @@ check_matches_origin_one(const string &origin_match) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::check_matches_hostname -// Access: Private -// Description: Matches the hostname of check_matches_origin: -// the individual components of the hostname are matched -// independently, with '**.' allowed at the beginning to -// indicate zero or more prefixes. Returns true on -// match, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Matches the hostname of check_matches_origin: the individual components of + * the hostname are matched independently, with '**.' allowed at the beginning + * to indicate zero or more prefixes. Returns true on match, false on + * failure. + */ bool P3DInstance:: check_matches_hostname(const string &orig, const string &match) { // First, separate both strings up at the dots. @@ -1773,14 +1637,13 @@ check_matches_hostname(const string &orig, const string &match) { vector match_components; separate_components(match_components, match); - // If the first component of match is "**", it means we accept any - // number, zero or more, of components at the beginning of the - // hostname. + // If the first component of match is "**", it means we accept any number, + // zero or more, of components at the beginning of the hostname. if (!match_components.empty() && match_components[0] == "**") { // Remove the leading "**" match_components.erase(match_components.begin()); - // Then remove any extra components from the beginning of - // orig_components; we won't need to check them. + // Then remove any extra components from the beginning of orig_components; + // we won't need to check them. if (orig_components.size() > match_components.size()) { size_t num_to_remove = orig_components.size() - match_components.size(); orig_components.erase(orig_components.begin(), orig_components.begin() + num_to_remove); @@ -1808,12 +1671,9 @@ check_matches_hostname(const string &orig, const string &match) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::separate_components -// Access: Private -// Description: Separates the indicated hostname into its components -// at the dots. -//////////////////////////////////////////////////////////////////// +/** + * Separates the indicated hostname into its components at the dots. + */ void P3DInstance:: separate_components(vector &components, const string &str) { size_t p = 0; @@ -1826,15 +1686,12 @@ separate_components(vector &components, const string &str) { components.push_back(str.substr(p)); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::check_matches_component -// Access: Private -// Description: Matches a single component of check_matches_origin: -// either protocol or port, or a single component of the -// hostname. Case-insensitive, and supports the '*' -// wildcard operator to match the entire component. -// Returns true on match, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Matches a single component of check_matches_origin: either protocol or + * port, or a single component of the hostname. Case-insensitive, and + * supports the '*' wildcard operator to match the entire component. Returns + * true on match, false on failure. + */ bool P3DInstance:: check_matches_component(const string &orig, const string &match) { if (match == "*") { @@ -1862,29 +1719,26 @@ check_matches_component(const string &orig, const string &match) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::check_p3d_signature -// Access: Private -// Description: Checks the signature(s) encoded in the p3d file, and -// looks to see if any of them are recognized. -// -// If the signature is recognized, calls -// mark_p3d_trusted(); otherwise, calls -// mark_p3d_untrusted(). -//////////////////////////////////////////////////////////////////// +/** + * Checks the signature(s) encoded in the p3d file, and looks to see if any of + * them are recognized. + * + * If the signature is recognized, calls mark_p3d_trusted(); otherwise, calls + * mark_p3d_untrusted(). + */ void P3DInstance:: check_p3d_signature() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (inst_mgr->get_trusted_environment()) { - // If we're in a trusted environment (e.g. the panda3d command - // line, where we've already downloaded the p3d file separately), - // then everything is approved. + // If we're in a trusted environment (e.g. the panda3d command line, + // where we've already downloaded the p3d file separately), then + // everything is approved. mark_p3d_trusted(); return; } - // See if we've previously approved the certificate--any - // certificate--that's signing this p3d file. + // See if we've previously approved the certificate--any certificate--that's + // signing this p3d file. int num_signatures = _mf_reader.get_num_signatures(); for (int i = 0; i < num_signatures; ++i) { const P3DMultifileReader::CertChain &chain = _mf_reader.get_signature(i); @@ -1892,8 +1746,7 @@ check_p3d_signature() { // Here's a certificate that has signed this multifile. X509 *cert = chain[0]._cert; - // Look up the certificate to see if we've stored a copy in our - // certs dir. + // Look up the certificate to see if we've stored a copy in our certs dir. if (inst_mgr->find_cert(cert)) { mark_p3d_trusted(); return; @@ -1909,7 +1762,7 @@ check_p3d_signature() { if (_certlist_package != NULL) { _certlist_package->add_instance(this); } - + // When the package finishes downloading, we will come back here. return; } @@ -1924,16 +1777,12 @@ check_p3d_signature() { return; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::mark_p3d_untrusted -// Access: Private -// Description: This is called internally when it has been determined -// that the p3d file can't (yet) be trusted, for -// instance because it lacks a signature, or because it -// is signed by an unrecognized certificate. This puts -// up the red "auth" button and waits for the user to -// approve the app before continuing. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally when it has been determined that the p3d file + * can't (yet) be trusted, for instance because it lacks a signature, or + * because it is signed by an unrecognized certificate. This puts up the red + * "auth" button and waits for the user to approve the app before continuing. + */ void P3DInstance:: mark_p3d_untrusted() { // Failed test. @@ -1950,14 +1799,14 @@ mark_p3d_untrusted() { if (_p3dcert_package != NULL) { _p3dcert_package->add_instance(this); } - + // When the package finishes downloading, we will come back here. return; } if (_p3dcert_package->get_failed()) { - // Oh, too bad for us. We're dependent on this package which we - // weren't able to download for some reason. + // Oh, too bad for us. We're dependent on this package which we weren't + // able to download for some reason. set_failed(); } @@ -1966,8 +1815,8 @@ mark_p3d_untrusted() { return; } - // OK, we've got the authorization program; we can put up the red - // button now. + // OK, we've got the authorization program; we can put up the red button + // now. // Notify JS that we've got no trust of the p3d file. _main_object->set_bool_property("trusted", false); @@ -1977,15 +1826,11 @@ mark_p3d_untrusted() { make_splash_window(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::mark_p3d_trusted -// Access: Private -// Description: This is called internally when it has been determined -// that the p3d file can be trusted and started. When -// this is called, the p3d file will be examined and -// made ready to start; it will not be started until -// this is called. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally when it has been determined that the p3d file can + * be trusted and started. When this is called, the p3d file will be examined + * and made ready to start; it will not be started until this is called. + */ void P3DInstance:: mark_p3d_trusted() { nout << "p3d trusted\n"; @@ -2013,8 +1858,8 @@ mark_p3d_trusted() { // Now we've got no further need to keep the _mf_reader open. _mf_reader.close(); - // For the moment, all sessions will be unique. TODO: support - // multiple instances per session. + // For the moment, all sessions will be unique. TODO: support multiple + // instances per session. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); ostringstream strm; strm << inst_mgr->get_unique_id(); @@ -2024,18 +1869,15 @@ mark_p3d_trusted() { _main_object->set_bool_property("trusted", true); send_notify("onauth"); - // Now that we're all set up, grab the panda3d package. We need to - // examine this before we can start to download the remaining - // packages. + // Now that we're all set up, grab the panda3d package. We need to examine + // this before we can start to download the remaining packages. add_panda3d_package(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::scan_app_desc_file -// Access: Private -// Description: Reads the p3d_info.xml file at instance startup, to -// determine the set of required packages and so forth. -//////////////////////////////////////////////////////////////////// +/** + * Reads the p3d_info.xml file at instance startup, to determine the set of + * required packages and so forth. + */ void P3DInstance:: scan_app_desc_file(TiXmlDocument *doc) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -2106,22 +1948,22 @@ scan_app_desc_file(TiXmlDocument *doc) { nout << "_matches_script_origin = " << _matches_script_origin << "\n"; if (inst_mgr->get_trusted_environment()) { - // If we're in a trusted environment, it is as if the origin - // always matches. + // If we're in a trusted environment, it is as if the origin always + // matches. _matches_run_origin = true; _matches_script_origin = true; } if (_auth_button_clicked) { - // But finally, if the user has already clicked through the red - // "auth" button, no need to present him/her with another green - // "play" button as well. + // But finally, if the user has already clicked through the red "auth" + // button, no need to present himher with another green "play" button as + // well. _auto_install = true; _auto_start = true; } - nout << "_auto_install = " << _auto_install - << ", _auto_start = " << _auto_start + nout << "_auto_install = " << _auto_install + << ", _auto_start = " << _auto_start << ", _stop_on_ready = " << _stop_on_ready << "\n"; @@ -2130,20 +1972,18 @@ scan_app_desc_file(TiXmlDocument *doc) { } if (!_matches_run_origin) { - nout << "Cannot run " << _p3d_basename << " from origin " + nout << "Cannot run " << _p3d_basename << " from origin " << _origin_protocol << "//" << _origin_hostname << ":" << _origin_port << "\n"; set_failed(); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_panda3d_package -// Access: Private -// Description: Adds the "panda3d" package only. This package must -// be downloaded first, and its desc file examined, -// before we can begin downloading the other packages. -//////////////////////////////////////////////////////////////////// +/** + * Adds the "panda3d" package only. This package must be downloaded first, + * and its desc file examined, before we can begin downloading the other + * packages. + */ void P3DInstance:: add_panda3d_package() { assert(!_packages_specified); @@ -2179,13 +2019,10 @@ add_panda3d_package() { set_failed(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_packages -// Access: Private -// Description: Adds the set of packages required by this p3d file to -// the _packages member. If _auto_install is true, this -// will also start downloading them. -//////////////////////////////////////////////////////////////////// +/** + * Adds the set of packages required by this p3d file to the _packages member. + * If _auto_install is true, this will also start downloading them. + */ void P3DInstance:: add_packages() { assert(!_packages_specified); @@ -2219,33 +2056,29 @@ add_packages() { consider_start_download(); - // Now that we've scanned the p3d file, and prepared the list of - // packages, it's safe to set the trusted flag. + // Now that we've scanned the p3d file, and prepared the list of packages, + // it's safe to set the trusted flag. _p3d_trusted = true; - // If the packages are already downloaded, start the instance - // rolling. + // If the packages are already downloaded, start the instance rolling. if (get_packages_ready()) { mark_download_complete(); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::find_alt_host_url -// Access: Private -// Description: Looks in the p3d_info.xml file for the alt_host -// associated with the indicated host_url, if any. -// Returns empty string if there is no match. -//////////////////////////////////////////////////////////////////// +/** + * Looks in the p3d_info.xml file for the alt_host associated with the + * indicated host_url, if any. Returns empty string if there is no match. + */ string P3DInstance:: find_alt_host_url(const string &host_url, const string &alt_host) { TiXmlElement *xhost = _xpackage->FirstChildElement("host"); while (xhost != NULL) { const char *url = xhost->Attribute("url"); if (url != NULL && host_url == url) { - // This matches the host. Now do we have a matching alt_host - // keyword for this host? + // This matches the host. Now do we have a matching alt_host keyword + // for this host? TiXmlElement *xalt_host = xhost->FirstChildElement("alt_host"); while (xalt_host != NULL) { const char *keyword = xalt_host->Attribute("keyword"); @@ -2264,19 +2097,16 @@ find_alt_host_url(const string &host_url, const string &alt_host) { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_host_info -// Access: Private -// Description: Looks in the p3d_info.xml file for the auxiliary host -// information for the selected host. Some of this -// information is helpful to have before the host has -// read its own contents.xml file (particularly the -// host_dir specification). -//////////////////////////////////////////////////////////////////// +/** + * Looks in the p3d_info.xml file for the auxiliary host information for the + * selected host. Some of this information is helpful to have before the host + * has read its own contents.xml file (particularly the host_dir + * specification). + */ void P3DInstance:: get_host_info(P3DHost *host) { - // We should only call this function if we haven't already read the - // host's more-authoritative contents.xml file. + // We should only call this function if we haven't already read the host's + // more-authoritative contents.xml file. assert(!host->has_contents_file()); TiXmlElement *xhost = _xpackage->FirstChildElement("host"); @@ -2293,18 +2123,14 @@ get_host_info(P3DHost *host) { // Didn't find an entry for this host; oh well. } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_start_dir_suffix -// Access: Public -// Description: Determines the local path to the appropriate start -// directory for this instance, within the generic -// "start" directory. Returns empty string if this -// instance doesn't specify a custom start directory. -// -// If this is nonempty, it will begin with a slash--the -// intention is to append this to the end of the generic -// start_dir path. -//////////////////////////////////////////////////////////////////// +/** + * Determines the local path to the appropriate start directory for this + * instance, within the generic "start" directory. Returns empty string if + * this instance doesn't specify a custom start directory. + * + * If this is nonempty, it will begin with a slash--the intention is to append + * this to the end of the generic start_dir path. + */ string P3DInstance:: get_start_dir_suffix() const { string start_dir_suffix; @@ -2314,10 +2140,9 @@ get_start_dir_suffix() const { start_dir = _start_dir; if (!start_dir.empty()) { - // If the start_dir is taken from the p3d file (and not from the - // HTML tokens), then we also append the alt_host name to the - // start_dir, so that each alt_host variant will run in a - // different directory. + // If the start_dir is taken from the p3d file (and not from the HTML + // tokens), then we also append the alt_host name to the start_dir, so + // that each alt_host variant will run in a different directory. string alt_host = get_fparams().lookup_token("alt_host"); if (!alt_host.empty()) { start_dir += "_"; @@ -2333,12 +2158,10 @@ get_start_dir_suffix() const { return start_dir_suffix; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::send_browser_script_object -// Access: Private -// Description: Sends the XML sequence to inform the session of our -// browser's toplevel window object. -//////////////////////////////////////////////////////////////////// +/** + * Sends the XML sequence to inform the session of our browser's toplevel + * window object. + */ void P3DInstance:: send_browser_script_object() { TiXmlDocument *doc = new TiXmlDocument; @@ -2348,18 +2171,16 @@ send_browser_script_object() { if (_dom_object != NULL) { xcommand->LinkEndChild(_session->p3dobj_to_xml(_dom_object)); } - + doc->LinkEndChild(xcommand); - + _session->send_command(doc); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::make_p3d_request -// Access: Private -// Description: Creates a new P3D_request structure from the XML. -// Returns NULL if no request is needed. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new P3D_request structure from the XML. Returns NULL if no + * request is needed. + */ P3D_request *P3DInstance:: make_p3d_request(TiXmlElement *xrequest) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -2379,8 +2200,8 @@ make_p3d_request(TiXmlElement *xrequest) { } } else if (strcmp(rtype, "script") == 0) { - // We don't actually build a P3D_request for a script request; - // we always just handle it immediately. + // We don't actually build a P3D_request for a script request; we always + // just handle it immediately. const char *operation = xrequest->Attribute("operation"); TiXmlElement *xobject = xrequest->FirstChildElement("object"); const char *property_name = xrequest->Attribute("property_name"); @@ -2388,7 +2209,7 @@ make_p3d_request(TiXmlElement *xrequest) { xrequest->Attribute("needs_response", &needs_response); int unique_id = 0; xrequest->Attribute("unique_id", &unique_id); - + P3D_object *value = NULL; TiXmlElement *xvalue = xrequest->FirstChildElement("value"); if (xvalue != NULL) { @@ -2417,7 +2238,7 @@ make_p3d_request(TiXmlElement *xrequest) { // We no longer need to keep this reference. _session->drop_p3dobj(object_id); } - + } else if (strcmp(rtype, "stop") == 0) { // A stop request from Python code. This is kind of weird, but OK. request = new P3D_request; @@ -2458,19 +2279,17 @@ make_p3d_request(TiXmlElement *xrequest) { return request; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::handle_notify_request -// Access: Private -// Description: Called (in the main thread) when a notify request is -// received from the subprocess. -//////////////////////////////////////////////////////////////////// +/** + * Called (in the main thread) when a notify request is received from the + * subprocess. + */ void P3DInstance:: handle_notify_request(const string &message) { - // We look for certain notify events that have particular meaning - // to this instance. + // We look for certain notify events that have particular meaning to this + // instance. if (message == "onpythonload") { - // Once Python is up and running, we can get the actual main - // object from the Python side, and merge it with our own. + // Once Python is up and running, we can get the actual main object from + // the Python side, and merge it with our own. TiXmlDocument *doc = new TiXmlDocument; TiXmlElement *xcommand = new TiXmlElement("command"); @@ -2493,12 +2312,12 @@ handle_notify_request(const string &message) { if (result != NULL) { if (_matches_script_origin) { - // We only actually merge the objects if this web page is - // allowed to call our scripting functions. + // We only actually merge the objects if this web page is allowed to + // call our scripting functions. _main_object->set_pyobj(result); } else { - // Otherwise, we just do a one-time application of the - // toplevel properties down to Python. + // Otherwise, we just do a one-time application of the toplevel + // properties down to Python. _main_object->apply_properties(result); } P3D_OBJECT_DECREF(result); @@ -2507,8 +2326,8 @@ handle_notify_request(const string &message) { _main_object->set_string_property("status", "starting"); } else if (message == "onwindowopen") { - // The process told us that it just successfully opened its - // window, for the first time. Hide the splash window. + // The process told us that it just successfully opened its window, for + // the first time. Hide the splash window. _instance_window_opened = true; if (_splash_window != NULL) { _splash_window->set_visible(false); @@ -2524,14 +2343,13 @@ handle_notify_request(const string &message) { _main_object->set_string_property("status", "open"); } else if (message == "onwindowattach") { - // The graphics window has been attached to the browser frame - // (maybe initially, maybe later). Hide the splash window. + // The graphics window has been attached to the browser frame (maybe + // initially, maybe later). Hide the splash window. - // We don't actually hide the splash window immediately on OSX, - // because on that platform, we can hide it as soon as we render - // the first frame, avoiding an empty frame in that little period - // of time between the window opening and the first frame being - // drawn. + // We don't actually hide the splash window immediately on OSX, because on + // that platform, we can hide it as soon as we render the first frame, + // avoiding an empty frame in that little period of time between the + // window opening and the first frame being drawn. _instance_window_attached = true; #ifndef __APPLE__ if (_splash_window != NULL) { @@ -2554,8 +2372,8 @@ handle_notify_request(const string &message) { #endif // __APPLE__ } else if (message == "onwindowdetach") { - // The graphics window has been removed from the browser frame. - // Restore the splash window. + // The graphics window has been removed from the browser frame. Restore + // the splash window. _instance_window_opened = true; _instance_window_attached = false; set_background_image(IT_active); @@ -2573,11 +2391,11 @@ handle_notify_request(const string &message) { #endif // __APPLE__ } else if (message == "buttonclick") { - // We just got a special "button click" message from the - // sub-thread. This case is a little unusual, as it came from the - // splash window and not from Python (we presumably haven't even - // started Python yet). We use this as a sneaky way to forward - // the event from the sub-thread to the main thread. + // We just got a special "button click" message from the sub-thread. This + // case is a little unusual, as it came from the splash window and not + // from Python (we presumably haven't even started Python yet). We use + // this as a sneaky way to forward the event from the sub-thread to the + // main thread. splash_button_clicked_main_thread(); } else if (message == "authfinished") { @@ -2591,14 +2409,12 @@ handle_notify_request(const string &message) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::handle_script_request -// Access: Private -// Description: Called (in the main thread) when a script request is -// received from the subprocess. -//////////////////////////////////////////////////////////////////// +/** + * Called (in the main thread) when a script request is received from the + * subprocess. + */ void P3DInstance:: -handle_script_request(const string &operation, P3D_object *object, +handle_script_request(const string &operation, P3D_object *object, const string &property_name, P3D_object *value, bool needs_response, int unique_id) { @@ -2606,24 +2422,23 @@ handle_script_request(const string &operation, P3D_object *object, TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "script_response"); xcommand->SetAttribute("unique_id", unique_id); - + doc->LinkEndChild(xcommand); if (operation == "get_property") { P3D_object *result = P3D_OBJECT_GET_PROPERTY(object, property_name.c_str()); - // We've got the property value; feed it back down to the - // subprocess. - + // We've got the property value; feed it back down to the subprocess. + if (result != NULL) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); } } else if (operation == "set_property") { - bool result = + bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, value); - + TiXmlElement *xvalue = new TiXmlElement("value"); xvalue->SetAttribute("type", "bool"); xvalue->SetAttribute("value", (int)result); @@ -2631,7 +2446,7 @@ handle_script_request(const string &operation, P3D_object *object, } else if (operation == "del_property") { bool result = P3D_OBJECT_SET_PROPERTY(object, property_name.c_str(), true, NULL); - + TiXmlElement *xvalue = new TiXmlElement("value"); xvalue->SetAttribute("type", "bool"); xvalue->SetAttribute("value", (int)result); @@ -2639,7 +2454,7 @@ handle_script_request(const string &operation, P3D_object *object, } else if (operation == "has_method") { bool result = P3D_OBJECT_HAS_METHOD(object, property_name.c_str()); - + TiXmlElement *xvalue = new TiXmlElement("value"); xvalue->SetAttribute("type", "bool"); xvalue->SetAttribute("value", (int)result); @@ -2660,7 +2475,7 @@ handle_script_request(const string &operation, P3D_object *object, P3D_object *result = P3D_OBJECT_CALL(object, property_name.c_str(), needs_response, values, num_values); - + if (result != NULL) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); @@ -2673,7 +2488,7 @@ handle_script_request(const string &operation, P3D_object *object, P3D_OBJECT_GET_STRING(value, buffer, size + 1); result = P3D_OBJECT_EVAL(object, buffer); delete[] buffer; - + if (result != NULL) { xcommand->LinkEndChild(_session->p3dobj_to_xml(result)); P3D_OBJECT_DECREF(result); @@ -2687,13 +2502,10 @@ handle_script_request(const string &operation, P3D_object *object, } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_failed -// Access: Private -// Description: Sets the "failed" indication to display sadness to -// the user--we're unable to launch the instance for -// some reason. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "failed" indication to display sadness to the user--we're unable + * to launch the instance for some reason. + */ void P3DInstance:: set_failed() { set_button_image(IT_none); @@ -2707,12 +2519,9 @@ set_failed() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::make_splash_window -// Access: Private -// Description: Creates the splash window to be displayed at startup, -// if it's time. -//////////////////////////////////////////////////////////////////// +/** + * Creates the splash window to be displayed at startup, if it's time. + */ void P3DInstance:: make_splash_window() { // Should we make the splash window visible? @@ -2722,18 +2531,16 @@ make_splash_window() { make_visible = false; } - if (_wparams.get_window_type() != P3D_WT_embedded && + if (_wparams.get_window_type() != P3D_WT_embedded && !_stuff_to_download && _auto_install && (_auto_start || _stop_on_ready) && _p3d_trusted) { - // If it's a toplevel or fullscreen window, then we don't want a - // splash window unless we have stuff to download, or a button to - // display. + // If it's a toplevel or fullscreen window, then we don't want a splash + // window unless we have stuff to download, or a button to display. make_visible = false; } if (is_failed()) { - // But, if we've failed to launch somehow, we need to let the user - // know. + // But, if we've failed to launch somehow, we need to let the user know. make_visible = true; } @@ -2747,9 +2554,8 @@ make_splash_window() { return; } if (_wparams.get_window_type() == P3D_WT_hidden && !is_failed()) { - // We're hidden, and so is the splash window. (But if we've got a - // failure case to report, we don't care and create the splash - // window anyway.) + // We're hidden, and so is the splash window. (But if we've got a failure + // case to report, we don't care and create the splash window anyway.) return; } @@ -2885,27 +2691,27 @@ make_splash_window() { string image_url = _fparams.lookup_token(token_keyword); if (image_url.empty()) { - // No specific image for this type is specified; get the default - // image. We do this via the P3DPackage interface, so we can - // use the cached version on disk if it's good. + // No specific image for this type is specified; get the default image. + // We do this via the P3DPackage interface, so we can use the cached + // version on disk if it's good. _image_files[i]._use_standard_image = true; - + } else { - // We have an explicit image specified for this slot, so just - // download it directly. This one won't be cached locally - // (though the browser might be free to cache it). + // We have an explicit image specified for this slot, so just download + // it directly. This one won't be cached locally (though the browser + // might be free to cache it). _image_files[i]._use_standard_image = false; _image_files[i]._filename.clear(); - + // Make a temporary file to receive the splash image. assert(_image_files[i]._temp_filename == NULL); _image_files[i]._temp_filename = new P3DTemporaryFile(".jpg"); - + // Start downloading the requested image. ImageDownload *download = new ImageDownload(this, i); download->set_url(image_url); download->set_filename(_image_files[i]._temp_filename->get_filename()); - + start_download(download); } } @@ -2917,19 +2723,16 @@ make_splash_window() { if (_current_button_image != IT_none) { _splash_window->set_image_filename(_image_files[_current_button_image]._filename, P3DSplashWindow::IP_button_ready); _splash_window->set_image_filename(_image_files[_current_button_image + 1]._filename, P3DSplashWindow::IP_button_rollover); - _splash_window->set_image_filename(_image_files[_current_button_image + 2]._filename, P3DSplashWindow::IP_button_click); + _splash_window->set_image_filename(_image_files[_current_button_image + 2]._filename, P3DSplashWindow::IP_button_click); _splash_window->set_button_active(true); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_background_image -// Access: Private -// Description: Specifies the particular image that should be -// displayed as the background image in the splash -// window. Specify IT_none to take the background image -// away. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular image that should be displayed as the background + * image in the splash window. Specify IT_none to take the background image + * away. + */ void P3DInstance:: set_background_image(ImageType image_type) { if (is_failed()) { @@ -2956,17 +2759,12 @@ set_background_image(ImageType image_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_button_image -// Access: Private -// Description: Specifies the particular image that should be -// displayed as the button image in the splash -// window. Specify IT_none to take the button image -// away. -// -// This actually defines a trilogy of button images: -// ready, rollover, click. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular image that should be displayed as the button image + * in the splash window. Specify IT_none to take the button image away. + * + * This actually defines a trilogy of button images: ready, rollover, click. + */ void P3DInstance:: set_button_image(ImageType image_type) { if (is_failed()) { @@ -3004,8 +2802,8 @@ set_button_image(ImageType image_type) { } } else { - // We're not changing the button graphic, but we might be - // re-activating it. + // We're not changing the button graphic, but we might be re-activating + // it. if (_splash_window != NULL) { if (_current_button_image != IT_none) { _splash_window->set_button_active(true); @@ -3016,30 +2814,27 @@ set_button_image(ImageType image_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::report_package_info_ready -// Access: Private -// Description: Notified when a package information has been -// successfully downloaded and the package is idle, -// waiting for activate_download() to be called. -//////////////////////////////////////////////////////////////////// +/** + * Notified when a package information has been successfully downloaded and + * the package is idle, waiting for activate_download() to be called. + */ void P3DInstance:: report_package_info_ready(P3DPackage *package) { nout << "report_package_info_ready: " << package->get_package_name() << "\n"; if (package == _image_package || package == _certlist_package || package == _p3dcert_package) { - // A special case: these packages get immediately downloaded, - // without waiting for anything else. + // A special case: these packages get immediately downloaded, without + // waiting for anything else. if (package == _certlist_package || package == _p3dcert_package) { - // If we're downloading one of the two cert packages, though, - // put up a progress bar. + // If we're downloading one of the two cert packages, though, put up a + // progress bar. make_splash_window(); if (_splash_window != NULL) { _splash_window->set_install_progress(0.0, true, 0); } if (package == _certlist_package) { set_install_label("Getting Certificates"); - } else { + } else { set_install_label("Getting Authorization Dialog"); } } @@ -3049,13 +2844,13 @@ report_package_info_ready(P3DPackage *package) { } if (package == _panda3d_package && !_packages_specified) { - // Another special case. Once the special panda3d package is - // ready to download (and we know what platform it belongs to), we - // can begin to download the remaining required packages. + // Another special case. Once the special panda3d package is ready to + // download (and we know what platform it belongs to), we can begin to + // download the remaining required packages. string package_platform = package->get_package_platform(); if (!package_platform.empty() && _session_platform.empty()) { - // From now on, all platform-specific files downloaded by this - // session will be for this platform. + // From now on, all platform-specific files downloaded by this session + // will be for this platform. _session_platform = package_platform; } if (_session_platform != package_platform) { @@ -3073,24 +2868,20 @@ report_package_info_ready(P3DPackage *package) { P3DPackage::Requires::const_iterator ri; for (ri = package->_requires.begin(); ri != package->_requires.end(); ++ri) { const P3DPackage::RequiredPackage &rp = (*ri); - add_package(rp._package_name, rp._package_version, rp._package_seq, + add_package(rp._package_name, rp._package_version, rp._package_seq, rp._host); } consider_start_download(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::consider_start_download -// Access: Private -// Description: When all package info files have been obtained, -// begins downloading stuff. -//////////////////////////////////////////////////////////////////// +/** + * When all package info files have been obtained, begins downloading stuff. + */ void P3DInstance:: consider_start_download() { if (get_packages_info_ready()) { - // All packages are ready to go. Let's start some download - // action. + // All packages are ready to go. Let's start some download action. _downloading_packages.clear(); _prev_downloaded = 0; _total_download_size = 0; @@ -3110,31 +2901,28 @@ consider_start_download() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ready_to_install -// Access: Private -// Description: Called when it's time to start the package download -// process. -//////////////////////////////////////////////////////////////////// +/** + * Called when it's time to start the package download process. + */ void P3DInstance:: ready_to_install() { if (_downloading_packages.empty() && _download_complete) { // We have already been here. Ignore it. - + } else if (!_auto_install && !_download_started) { - // Not authorized to download yet. We're waiting for the user - // to acknowledge the download. + // Not authorized to download yet. We're waiting for the user to + // acknowledge the download. set_background_image(IT_ready); set_button_image(IT_play_ready); - + } else { _download_started = true; _download_complete = false; _download_package_index = 0; _total_downloaded = 0; - // Record the time we started the package download, so we can - // report downloadElapsedTime and predict downloadRemainingTime. + // Record the time we started the package download, so we can report + // downloadElapsedTime and predict downloadRemainingTime. #ifdef _WIN32 _start_dl_tick = GetTickCount(); #else @@ -3145,14 +2933,14 @@ ready_to_install() { << " packages, total " << _total_download_size << " bytes required (" << _prev_downloaded << " previously downloaded).\n"; - + if (_downloading_packages.size() > 0) { _stuff_to_download = true; - + // Maybe it's time to open a splash window now. make_splash_window(); } - + _main_object->set_string_property("status", "downloading"); _main_object->set_int_property("numDownloadingPackages", _downloading_packages.size()); _main_object->set_int_property("totalDownloadSize", _total_download_size); @@ -3161,8 +2949,8 @@ ready_to_install() { double progress = 0.0; if (_prev_downloaded != 0) { - // We might start off with more than 0 progress, if we've - // already downloaded some of it previously. + // We might start off with more than 0 progress, if we've already + // downloaded some of it previously. progress = (_prev_downloaded) / (_total_download_size + _prev_downloaded); progress = min(progress, 1.0); @@ -3173,18 +2961,15 @@ ready_to_install() { } send_notify("ondownloadbegin"); - + start_next_download(); } } - -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::start_next_download -// Access: Private -// Description: Checks whether all packages are ready and waiting to -// be downloaded; if so, starts the next package in -// sequence downloading. -//////////////////////////////////////////////////////////////////// + +/** + * Checks whether all packages are ready and waiting to be downloaded; if so, + * starts the next package in sequence downloading. + */ void P3DInstance:: start_next_download() { while (_download_package_index < (int)_downloading_packages.size()) { @@ -3214,7 +2999,7 @@ start_next_download() { send_notify("ondownloadnext"); return; } - + // This package has been downloaded. Move to the next. _total_downloaded += package->get_download_size(); ++_download_package_index; @@ -3228,12 +3013,9 @@ start_next_download() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::mark_download_complete -// Access: Private -// Description: Called internally when all files needed to launch -// have been downloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when all files needed to launch have been downloaded. + */ void P3DInstance:: mark_download_complete() { if (_failed) { @@ -3246,7 +3028,7 @@ mark_download_complete() { _main_object->set_string_property("status", "downloadcomplete"); send_notify("ondownloadcomplete"); } - + // Take down the download progress bar. if (_splash_window != NULL) { _splash_window->set_install_progress(0.0, true, 0); @@ -3259,12 +3041,10 @@ mark_download_complete() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ready_to_start -// Access: Private -// Description: Called internally when we have got the wparams and -// fparams and we have downloaded all required packages. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when we have got the wparams and fparams and we have + * downloaded all required packages. + */ void P3DInstance:: ready_to_start() { if (_instance_started || is_failed()) { @@ -3277,8 +3057,8 @@ ready_to_start() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (_stop_on_ready) { - // If we've got the "stop_on_ready" token, then exit abruptly - // now, instead of displaying the splash window. + // If we've got the "stop_on_ready" token, then exit abruptly now, instead + // of displaying the splash window. request_stop_main_thread(); return; } @@ -3294,19 +3074,17 @@ ready_to_start() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::report_instance_progress -// Access: Private -// Description: Notified as the instance file is downloaded. -//////////////////////////////////////////////////////////////////// +/** + * Notified as the instance file is downloaded. + */ void P3DInstance:: report_instance_progress(double progress, bool is_progress_known, size_t received_data) { if (!_show_dl_instance_progress) { - // If we haven't yet set the download label, set it after a full - // second has elapsed. We don't want to set it too soon, because - // we're not really sure how long it will take to download (the - // instance file might be already in the browser cache). + // If we haven't yet set the download label, set it after a full second + // has elapsed. We don't want to set it too soon, because we're not + // really sure how long it will take to download (the instance file might + // be already in the browser cache). #ifdef _WIN32 int now = GetTickCount(); double elapsed = (double)(now - _start_dl_tick) * 0.001; @@ -3317,9 +3095,8 @@ report_instance_progress(double progress, bool is_progress_known, (double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0; #endif - // Put up the progress bar after 2 seconds have elapsed, if we've - // still got some distance to go; or after 5 seconds have elapsed - // regardless. + // Put up the progress bar after 2 seconds have elapsed, if we've still + // got some distance to go; or after 5 seconds have elapsed regardless. if ((elapsed > 2.0 && progress < 0.7) || (elapsed > 5.0)) { _show_dl_instance_progress = true; @@ -3337,12 +3114,9 @@ report_instance_progress(double progress, bool is_progress_known, _main_object->set_float_property("instanceDownloadProgress", progress); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::report_package_progress -// Access: Private -// Description: Notified as the packages required by the instance -// file are downloaded. -//////////////////////////////////////////////////////////////////// +/** + * Notified as the packages required by the instance file are downloaded. + */ void P3DInstance:: report_package_progress(P3DPackage *package, double progress) { if (package == _image_package) { @@ -3359,8 +3133,7 @@ report_package_progress(P3DPackage *package, double progress) { if (_download_package_index >= (int)_downloading_packages.size() || package != _downloading_packages[_download_package_index]) { - // Quietly ignore a download progress report from an unexpected - // package. + // Quietly ignore a download progress report from an unexpected package. return; } @@ -3414,7 +3187,7 @@ report_package_progress(P3DPackage *package, double progress) { tr._report_time = elapsed; _time_reports.push_back(tr); _total_time_reports += tr._total; - + // Now get the average report. if (!_time_reports.empty()) { double total = _total_time_reports / (double)_time_reports.size(); @@ -3427,20 +3200,17 @@ report_package_progress(P3DPackage *package, double progress) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::report_package_done -// Access: Private -// Description: Notified when a required package is fully downloaded, -// or failed. -//////////////////////////////////////////////////////////////////// +/** + * Notified when a required package is fully downloaded, or failed. + */ void P3DInstance:: report_package_done(P3DPackage *package, bool success) { nout << "Done installing " << package->get_package_name() << ": success = " << success << "\n"; if (package == _image_package) { - // A special case: we just downloaded the image package, so get - // the image files out of it and point them to the splash window. + // A special case: we just downloaded the image package, so get the image + // files out of it and point them to the splash window. string package_dir = package->get_package_dir(); const TiXmlElement *xconfig = package->get_xconfig(); if (xconfig == NULL) { @@ -3451,8 +3221,8 @@ report_package_done(P3DPackage *package, bool success) { for (int i = 0; i < (int)IT_none; ++i) { if (_image_files[i]._use_standard_image) { - // This image indexes into the package. Go get the standard - // image filename. + // This image indexes into the package. Go get the standard image + // filename. string token = string(_image_type_names[i]) + "_img"; const string *basename = xconfig->Attribute(token); if (basename == NULL) { @@ -3460,9 +3230,9 @@ report_package_done(P3DPackage *package, bool success) { } else { string image_filename = package_dir + "/" + *basename; _image_files[i]._filename = image_filename; - - // If the image should be on the window now, and the window - // still exists, put it up. + + // If the image should be on the window now, and the window still + // exists, put it up. if (_splash_window != NULL && _image_files[i]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _image_files[i]._image_placement; @@ -3475,9 +3245,9 @@ report_package_done(P3DPackage *package, bool success) { } if (package == _certlist_package) { - // Another special case: successfully downloading certlist (or - // failing to download it) means we can finish checking the - // authenticity of the p3d file. + // Another special case: successfully downloading certlist (or failing to + // download it) means we can finish checking the authenticity of the p3d + // file. package->mark_used(); @@ -3494,8 +3264,8 @@ report_package_done(P3DPackage *package, bool success) { } if (package == _p3dcert_package) { - // Another special case: successfully downloading p3dcert means we - // can enable the auth button. + // Another special case: successfully downloading p3dcert means we can + // enable the auth button. package->mark_used(); @@ -3517,12 +3287,10 @@ report_package_done(P3DPackage *package, bool success) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::set_install_label -// Access: Private -// Description: Sets the install label that will be displayed on the -// splash window, if it is present. -//////////////////////////////////////////////////////////////////// +/** + * Sets the install label that will be displayed on the splash window, if it + * is present. + */ void P3DInstance:: set_install_label(const string &install_label) { _install_label = install_label; @@ -3531,13 +3299,10 @@ set_install_label(const string &install_label) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::paint_window -// Access: Private -// Description: Actually paints the rendered image to the browser -// window. This is only needed for OSX, where the child -// process isn't allowed to do it directly. -//////////////////////////////////////////////////////////////////// +/** + * Actually paints the rendered image to the browser window. This is only + * needed for OSX, where the child process isn't allowed to do it directly. + */ void P3DInstance:: paint_window() { #ifdef __APPLE__ @@ -3558,15 +3323,11 @@ paint_window() { } #if defined(__APPLE__) && !__LP64__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_framebuffer_osx_port -// Access: Private -// Description: Fills _reversed_buffer with the pixels from the -// current frame, suitable for rendering via the old -// QuickDraw interface. Returns true on success, or -// false if there is no Panda3D window visible. Only -// needed on OSX. -//////////////////////////////////////////////////////////////////// +/** + * Fills _reversed_buffer with the pixels from the current frame, suitable for + * rendering via the old QuickDraw interface. Returns true on success, or + * false if there is no Panda3D window visible. Only needed on OSX. + */ bool P3DInstance:: get_framebuffer_osx_port() { if (_swbuffer == NULL || !_instance_window_attached) { @@ -3582,13 +3343,13 @@ get_framebuffer_osx_port() { if (_swbuffer->ready_for_read()) { // Copy the new framebuffer image from the child process. const void *framebuffer = _swbuffer->open_read_framebuffer(); - - // We have to reverse the image vertically first (different - // conventions between Panda and Mac). + + // We have to reverse the image vertically first (different conventions + // between Panda and Mac). for (int yi = 0; yi < y_size; ++yi) { #ifndef __BIG_ENDIAN__ - // On a little-endian machine, we only have to reverse the order - // of the rows. + // On a little-endian machine, we only have to reverse the order of the + // rows. memcpy(_reversed_buffer + (y_size - 1 - yi) * rowsize, (char *)framebuffer + yi * rowsize, rowsize); @@ -3596,11 +3357,10 @@ get_framebuffer_osx_port() { #else // __BIG_ENDIAN__ // On a big-endian machine, we need to do more work. - // It appears that kBGRAPixelFormat, below, is ignored on - // big-endian machines, and it is treated as KARGBPixelFormat - // regardless of what we specify. Vexing. To compensate for - // this, we have to reverse the color channels ourselves on - // big-endian machines. + // It appears that kBGRAPixelFormat, below, is ignored on big-endian + // machines, and it is treated as KARGBPixelFormat regardless of what we + // specify. Vexing. To compensate for this, we have to reverse the + // color channels ourselves on big-endian machines. const char *source = (const char *)framebuffer + yi * rowsize; const char *stop = source + x_size * 4; @@ -3619,18 +3379,17 @@ get_framebuffer_osx_port() { } #endif } - + _swbuffer->close_read_framebuffer(); if (_splash_window != NULL && _splash_window->get_visible()) { - // If the splash window is up, time to hide it. We've just - // rendered a real frame. + // If the splash window is up, time to hide it. We've just rendered a + // real frame. _splash_window->set_visible(false); } } else { - // No frame ready. Just re-paint the frame we had saved last - // time. + // No frame ready. Just re-paint the frame we had saved last time. } return true; @@ -3638,15 +3397,11 @@ get_framebuffer_osx_port() { #endif // __APPLE__ #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::get_framebuffer_osx_cgcontext -// Access: Private -// Description: Fills _reversed_buffer with the pixels from the -// current frame, suitable for rendering via the new -// CoreGraphics interface. Returns true on success, or -// false if there is no Panda3D window visible. Only -// needed on OSX. -//////////////////////////////////////////////////////////////////// +/** + * Fills _reversed_buffer with the pixels from the current frame, suitable for + * rendering via the new CoreGraphics interface. Returns true on success, or + * false if there is no Panda3D window visible. Only needed on OSX. + */ bool P3DInstance:: get_framebuffer_osx_cgcontext() { if (_swbuffer == NULL || !_instance_window_attached) { @@ -3666,14 +3421,13 @@ get_framebuffer_osx_cgcontext() { _swbuffer->close_read_framebuffer(); if (_splash_window != NULL && _splash_window->get_visible()) { - // If the splash window is up, time to hide it. We've just - // rendered a real frame. + // If the splash window is up, time to hide it. We've just rendered a + // real frame. _splash_window->set_visible(false); } } else { - // No frame ready. Just re-paint the frame we had saved last - // time. + // No frame ready. Just re-paint the frame we had saved last time. } return true; @@ -3681,13 +3435,10 @@ get_framebuffer_osx_cgcontext() { #endif // __APPLE__ #if defined(__APPLE__) && !__LP64__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::paint_window_osx_port -// Access: Private -// Description: Actually paints the rendered image to the browser -// window, using the OSX deprecated QuickDraw -// interfaces. -//////////////////////////////////////////////////////////////////// +/** + * Actually paints the rendered image to the browser window, using the OSX + * deprecated QuickDraw interfaces. + */ void P3DInstance:: paint_window_osx_port() { if (!get_framebuffer_osx_port()) { @@ -3705,7 +3456,7 @@ paint_window_osx_port() { QDErr err; GWorldPtr pGWorld; - err = NewGWorldFromPtr(&pGWorld, k32BGRAPixelFormat, &src_rect, 0, 0, 0, + err = NewGWorldFromPtr(&pGWorld, k32BGRAPixelFormat, &src_rect, 0, 0, 0, _reversed_buffer, rowsize); if (err != noErr) { nout << " error in NewGWorldFromPtr, called from paint_window()\n"; @@ -3718,31 +3469,28 @@ paint_window_osx_port() { GrafPtr port_save = NULL; Boolean port_changed = QDSwapPort(out_port, &port_save); - // Make sure the clipping rectangle isn't in the way. Is there a - // better way to eliminate the cliprect from consideration? - Rect r = { 0, 0, 0x7fff, 0x7fff }; + // Make sure the clipping rectangle isn't in the way. Is there a better way + // to eliminate the cliprect from consideration? + Rect r = { 0, 0, 0x7fff, 0x7fff }; ClipRect(&r); - CopyBits(GetPortBitMapForCopyBits(pGWorld), - GetPortBitMapForCopyBits(out_port), + CopyBits(GetPortBitMapForCopyBits(pGWorld), + GetPortBitMapForCopyBits(out_port), &src_rect, &ddrc_rect, srcCopy, 0); - + if (port_changed) { QDSwapPort(port_save, NULL); } - + DisposeGWorld(pGWorld); } -#endif // __APPLE__ +#endif // __APPLE__ #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::paint_window_osx_cgcontext -// Access: Private -// Description: Actually paints the rendered image to the browser -// window. This is the newer CoreGraphics -// implementation on OSX. -//////////////////////////////////////////////////////////////////// +/** + * Actually paints the rendered image to the browser window. This is the + * newer CoreGraphics implementation on OSX. + */ void P3DInstance:: paint_window_osx_cgcontext(CGContextRef context) { if (!get_framebuffer_osx_cgcontext()) { @@ -3760,12 +3508,9 @@ paint_window_osx_cgcontext(CGContextRef context) { } #endif // __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::handle_event_osx_event_record -// Access: Private -// Description: Responds to the deprecated Carbon event types in Mac -// OSX. -//////////////////////////////////////////////////////////////////// +/** + * Responds to the deprecated Carbon event types in Mac OSX. + */ bool P3DInstance:: handle_event_osx_event_record(const P3D_event_data &event) { bool retval = false; @@ -3776,28 +3521,27 @@ handle_event_osx_event_record(const P3D_event_data &event) { Point pt = er->where; - // Need to ensure we have the correct port set, in order to - // convert the mouse coordinates successfully via - // GlobalToLocal(). + // Need to ensure we have the correct port set, in order to convert the + // mouse coordinates successfully via GlobalToLocal(). const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; GrafPtr port_save = NULL; Boolean port_changed = QDSwapPort(out_port, &port_save); - + GlobalToLocal(&pt); - + if (port_changed) { QDSwapPort(port_save, NULL); } } else { - // First, convert the coordinates from screen coordinates to - // browser window coordinates. + // First, convert the coordinates from screen coordinates to browser + // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { pt.h, pt.v }; HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, kHICoordSpaceWindow, window); - + // Then convert to plugin coordinates. pt.h = (short)(cgpt.x - _wparams.get_win_x()); pt.v = (short)(cgpt.y - _wparams.get_win_y()); @@ -3852,8 +3596,8 @@ handle_event_osx_event_record(const P3D_event_data &event) { break; case osEvt: - // The mouse data sent with an "os event" seems to be in an - // indeterminate space. + // The mouse data sent with an "os event" seems to be in an indeterminate + // space. trust_mouse_data = false; break; @@ -3878,12 +3622,9 @@ handle_event_osx_event_record(const P3D_event_data &event) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::handle_event_osx_cocoa -// Access: Private -// Description: Responds to the new Cocoa event types in Mac -// OSX. -//////////////////////////////////////////////////////////////////// +/** + * Responds to the new Cocoa event types in Mac OSX. + */ bool P3DInstance:: handle_event_osx_cocoa(const P3D_event_data &event) { bool retval = false; @@ -3976,13 +3717,11 @@ handle_event_osx_cocoa(const P3D_event_data &event) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_carbon_modifier_flags -// Access: Private -// Description: OSX only: adds the appropriate bits to the Event flag -// bitmask to correspond to the modifier buttons held in -// the MacOS-style EventRecord::modifiers mask. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: adds the appropriate bits to the Event flag bitmask to correspond + * to the modifier buttons held in the MacOS-style EventRecord::modifiers + * mask. + */ void P3DInstance:: add_carbon_modifier_flags(unsigned int &swb_flags, int modifiers) { #if defined(__APPLE__) && !__LP64__ @@ -4001,13 +3740,10 @@ add_carbon_modifier_flags(unsigned int &swb_flags, int modifiers) { #endif // __APPLE__ } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::add_cocoa_modifier_flags -// Access: Private -// Description: OSX only: adds the appropriate bits to the Event flag -// bitmask to correspond to the modifier buttons held in -// the P3DCocoaEvent modifierFlags mask. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: adds the appropriate bits to the Event flag bitmask to correspond + * to the modifier buttons held in the P3DCocoaEvent modifierFlags mask. + */ void P3DInstance:: add_cocoa_modifier_flags(unsigned int &swb_flags, int modifiers) { #ifdef __APPLE__ @@ -4026,17 +3762,13 @@ add_cocoa_modifier_flags(unsigned int &swb_flags, int modifiers) { #endif // __APPLE__ } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::send_notify -// Access: Private -// Description: Generates a synthetic notify message here at the C++ -// level. -// -// Most notify messages are generated from within the -// Python code, and don't use this method; but a few -// have to be sent before Python has started, and those -// come through this method. -//////////////////////////////////////////////////////////////////// +/** + * Generates a synthetic notify message here at the C++ level. + * + * Most notify messages are generated from within the Python code, and don't + * use this method; but a few have to be sent before Python has started, and + * those come through this method. + */ void P3DInstance:: send_notify(const string &message) { nout << "send_notify(" << message << ")\n"; @@ -4048,13 +3780,10 @@ send_notify(const string &message) { } #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::alloc_swbuffer -// Access: Private -// Description: OSX only: allocates the _swbuffer and associated -// support objects. If it was already allocated, -// deallocates the previous one first. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: allocates the _swbuffer and associated support objects. If it + * was already allocated, deallocates the previous one first. + */ void P3DInstance:: alloc_swbuffer() { free_swbuffer(); @@ -4068,29 +3797,26 @@ alloc_swbuffer() { _reversed_buffer = new char[_swbuffer->get_framebuffer_size()]; memset(_reversed_buffer, 0, _swbuffer->get_row_size()); size_t rowsize = _swbuffer->get_row_size(); - - _buffer_data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)_reversed_buffer, + + _buffer_data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)_reversed_buffer, y_size * rowsize, kCFAllocatorNull); - + _data_provider = CGDataProviderCreateWithCFData(_buffer_data); _buffer_color_space = CGColorSpaceCreateDeviceRGB(); - + _buffer_image = CGImageCreate(x_size, y_size, 8, 32, rowsize, _buffer_color_space, - kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, + kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, _data_provider, NULL, false, kCGRenderingIntentDefault); - + } } #endif // __APPLE__ #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::free_swbuffer -// Access: Private -// Description: OSX only: releases the _swbuffer and associated -// support objects previously allocated by -// alloc_swbuffer(). -//////////////////////////////////////////////////////////////////// +/** + * OSX only: releases the _swbuffer and associated support objects previously + * allocated by alloc_swbuffer(). + */ void P3DInstance:: free_swbuffer() { if (_swbuffer != NULL) { @@ -4116,16 +3842,13 @@ free_swbuffer() { } } #endif // __APPLE__ - + #ifdef __APPLE__ - //////////////////////////////////////////////////////////////////// -// Function: P3DInstance::timer_callback -// Access: Private, Static -// Description: OSX only: this callback is associated with a -// CFRunLoopTimer, to be called periodically for -// updating the frame. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: this callback is associated with a CFRunLoopTimer, to be called + * periodically for updating the frame. + */ void P3DInstance:: timer_callback(CFRunLoopTimerRef timer, void *info) { P3DInstance *self = (P3DInstance *)info; @@ -4133,11 +3856,9 @@ timer_callback(CFRunLoopTimerRef timer, void *info) { } #endif // __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ImageDownload::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstance::ImageDownload:: ImageDownload(P3DInstance *inst, int index) : _inst(inst), @@ -4145,24 +3866,21 @@ ImageDownload(P3DInstance *inst, int index) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::ImageDownload::download_finished -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate a callback -// when the download finishes, either successfully or -// otherwise. The bool parameter is true if the -// download was successful. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate a callback when the download + * finishes, either successfully or otherwise. The bool parameter is true if + * the download was successful. + */ void P3DInstance::ImageDownload:: download_finished(bool success) { P3DFileDownload::download_finished(success); if (success) { - // We've successfully downloaded the image (directly, not via the - // package interface). + // We've successfully downloaded the image (directly, not via the package + // interface). _inst->_image_files[_index]._filename = get_filename(); - // Put it onscreen if it's supposed to be onscreen now, and our - // splash window still exists. + // Put it onscreen if it's supposed to be onscreen now, and our splash + // window still exists. if (_inst->_splash_window != NULL && _inst->_image_files[_index]._image_placement != P3DSplashWindow::IP_none) { P3DSplashWindow::ImagePlacement image_placement = _inst->_image_files[_index]._image_placement; @@ -4171,37 +3889,30 @@ download_finished(bool success) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::InstanceDownload::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstance::InstanceDownload:: InstanceDownload(P3DInstance *inst) : _inst(inst) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::InstanceDownload::download_progress -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate an occasional -// callback as new data comes in. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate an occasional callback as new data + * comes in. + */ void P3DInstance::InstanceDownload:: download_progress() { P3DFileDownload::download_progress(); _inst->report_instance_progress(get_download_progress(), is_download_progress_known(), get_total_data()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstance::InstanceDownload::download_finished -// Access: Protected, Virtual -// Description: Intended to be overloaded to generate a callback -// when the download finishes, either successfully or -// otherwise. The bool parameter is true if the -// download was successful. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overloaded to generate a callback when the download + * finishes, either successfully or otherwise. The bool parameter is true if + * the download was successful. + */ void P3DInstance::InstanceDownload:: download_finished(bool success) { P3DFileDownload::download_finished(success); diff --git a/direct/src/plugin/p3dInstance.h b/direct/src/plugin/p3dInstance.h index 76d37e6522..325e368003 100644 --- a/direct/src/plugin/p3dInstance.h +++ b/direct/src/plugin/p3dInstance.h @@ -1,16 +1,15 @@ -// Filename: p3dInstance.h -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstance.h + * @author drose + * @date 2009-05-29 + */ #ifndef P3DINSTANCE_H #define P3DINSTANCE_H @@ -45,15 +44,14 @@ class P3DObject; class P3DMainObject; class P3DTemporaryFile; -//////////////////////////////////////////////////////////////////// -// Class : P3DInstance -// Description : This is an instance of a Panda3D window, as seen in -// the parent-level process. -//////////////////////////////////////////////////////////////////// +/** + * This is an instance of a Panda3D window, as seen in the parent-level + * process. + */ class P3DInstance : public P3D_instance, public P3DReferenceCount { public: - P3DInstance(P3D_request_ready_func *func, - const P3D_token tokens[], size_t num_tokens, + P3DInstance(P3D_request_ready_func *func, + const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data); ~P3DInstance(); void cleanup(); @@ -78,9 +76,9 @@ public: bool feed_url_stream(int unique_id, P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const unsigned char *this_data, + const unsigned char *this_data, size_t this_data_size); bool handle_event(const P3D_event_data &event); @@ -94,14 +92,14 @@ public: inline P3D_request_ready_func *get_request_ready_func() const; - void add_package(const string &name, const string &version, + void add_package(const string &name, const string &version, const string &seq, P3DHost *host); void add_package(P3DPackage *package); void remove_package(P3DPackage *package); bool get_packages_info_ready() const; bool get_packages_ready() const; bool get_packages_failed() const; - + inline bool is_trusted() const; inline bool get_matches_script_origin() const; int start_download(P3DDownload *download, bool add_request = true); @@ -144,8 +142,7 @@ private: P3DInstance *_inst; }; - // The different kinds of image files we download for the splash - // window. + // The different kinds of image files we download for the splash window. enum ImageType { // Also update _image_type_names when you update this list. IT_download, @@ -186,7 +183,7 @@ private: void send_browser_script_object(); P3D_request *make_p3d_request(TiXmlElement *xrequest); void handle_notify_request(const string &message); - void handle_script_request(const string &operation, P3D_object *object, + void handle_script_request(const string &operation, P3D_object *object, const string &property_name, P3D_object *value, bool needs_response, int unique_id); @@ -236,8 +233,8 @@ private: string _origin_hostname; string _origin_port; - // We need a list of previous time reports so we can average the - // predicted download time over the past few seconds. + // We need a list of previous time reports so we can average the predicted + // download time over the past few seconds. class TimeReport { public: double _total; @@ -278,10 +275,10 @@ private: bool _p3d_trusted; TiXmlElement *_xpackage; - // Holds the list of certificates that are pre-approved by the - // plugin vendor. + // Holds the list of certificates that are pre-approved by the plugin + // vendor. P3DPackage *_certlist_package; - + // For downloading the p3dcert authorization program. P3DPackage *_p3dcert_package; @@ -307,9 +304,8 @@ private: string _log_pathname; #ifdef __APPLE__ - // On OSX, we have to get a copy of the framebuffer data back from - // the child process, and draw it to the window, here in the parent - // process. Crazy! + // On OSX, we have to get a copy of the framebuffer data back from the child + // process, and draw it to the window, here in the parent process. Crazy! int _shared_fd; size_t _shared_mmap_size; string _shared_filename; @@ -332,17 +328,17 @@ private: bool _instance_window_attached; bool _stuff_to_download; - // Keep track of when the download was started, for reporting - // purposes. These members are used both for the instance download, - // and for the later package download. + // Keep track of when the download was started, for reporting purposes. + // These members are used both for the instance download, and for the later + // package download. #ifdef _WIN32 int _start_dl_tick; #else struct timeval _start_dl_timeval; #endif - // This is set false initially, but true if the instance download - // continues for more than a couple of seconds. + // This is set false initially, but true if the instance download continues + // for more than a couple of seconds. bool _show_dl_instance_progress; typedef vector Packages; @@ -357,22 +353,22 @@ private: bool _download_complete; bool _instance_started; - // We keep the _panda3d pointer separately because it's so - // important, but it's in the above vector also. + // We keep the _panda3d pointer separately because it's so important, but + // it's in the above vector also. P3DPackage *_panda3d_package; typedef map Downloads; Downloads _downloads; - // The _raw_requests queue might be filled up by the read thread, so - // we protect it in a lock. + // The _raw_requests queue might be filled up by the read thread, so we + // protect it in a lock. LOCK _request_lock; typedef deque RawRequests; RawRequests _raw_requests; bool _requested_stop; - // The _baked_requests queue is only touched in the main thread; no - // lock needed. + // The _baked_requests queue is only touched in the main thread; no lock + // needed. typedef deque BakedRequests; BakedRequests _baked_requests; diff --git a/direct/src/plugin/p3dInstanceManager.I b/direct/src/plugin/p3dInstanceManager.I index af5b6de16c..90a13c810a 100644 --- a/direct/src/plugin/p3dInstanceManager.I +++ b/direct/src/plugin/p3dInstanceManager.I @@ -1,36 +1,30 @@ -// Filename: p3dInstanceManager.I -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstanceManager.I + * @author drose + * @date 2009-05-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::is_initialized -// Access: Public -// Description: Returns true if the instance manager is successfully -// initialized, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the instance manager is successfully initialized, false + * otherwise. + */ inline bool P3DInstanceManager:: is_initialized() const { return _is_initialized; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::reconsider_runtime_environment -// Access: Public -// Description: Recreates the runtime environment if a previous call -// to uninstall_all() removed it. Does nothing if the -// runtime environment is already correctly set up. -//////////////////////////////////////////////////////////////////// +/** + * Recreates the runtime environment if a previous call to uninstall_all() + * removed it. Does nothing if the runtime environment is already correctly + * set up. + */ inline void P3DInstanceManager:: reconsider_runtime_environment() { assert(_is_initialized); @@ -39,28 +33,21 @@ reconsider_runtime_environment() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::verify_contents -// Access: Public -// Description: Returns the verify_contents setting. When this is -// set to P3D_VC_none, it indicates that we don't need -// to contact the server to verify that a contents.xml -// file is fresh before using it; we should just use it -// as it is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the verify_contents setting. When this is set to P3D_VC_none, it + * indicates that we don't need to contact the server to verify that a + * contents.xml file is fresh before using it; we should just use it as it is. + */ inline P3D_verify_contents P3DInstanceManager:: get_verify_contents() const { return _verify_contents; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::reset_verify_contents -// Access: Public -// Description: Resets the verify_contents flag to P3D_VC_normal, if -// it is P3D_VC_none. This should be done whenever we -// discover anything needs to be downloaded. At this -// point, we might as well verify everything. -//////////////////////////////////////////////////////////////////// +/** + * Resets the verify_contents flag to P3D_VC_normal, if it is P3D_VC_none. + * This should be done whenever we discover anything needs to be downloaded. + * At this point, we might as well verify everything. + */ inline void P3DInstanceManager:: reset_verify_contents() { if (_verify_contents == P3D_VC_none) { @@ -69,328 +56,253 @@ reset_verify_contents() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_api_version -// Access: Public -// Description: Returns the api_version number which was passed to -// P3D_initialize(). Client code may use this to -// determine how to interpret parameters to various -// functions whose interface may have changed over -// different versions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the api_version number which was passed to P3D_initialize(). + * Client code may use this to determine how to interpret parameters to + * various functions whose interface may have changed over different versions. + */ inline int P3DInstanceManager:: get_api_version() const { return _api_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_host_url -// Access: Public -// Description: Returns the standard host_url which the instances -// should attempt to contact to download auxiliary -// packages associated with the core API, such as the -// p3dcert and images packages. This is normally the -// compiled-in PANDA_PACKAGE_HOST_URL, but it might be -// set to something different by the -u parameter on the -// panda3d executable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard host_url which the instances should attempt to contact + * to download auxiliary packages associated with the core API, such as the + * p3dcert and images packages. This is normally the compiled-in + * PANDA_PACKAGE_HOST_URL, but it might be set to something different by the + * -u parameter on the panda3d executable. + */ inline const string &P3DInstanceManager:: get_host_url() const { return _host_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_root_dir -// Access: Public -// Description: Returns the root directory into which all the P3D -// runtime files are downloaded and installed. This -// must be a writable directory or nothing will work. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root directory into which all the P3D runtime files are + * downloaded and installed. This must be a writable directory or nothing + * will work. + */ inline const string &P3DInstanceManager:: get_root_dir() const { return _root_dir; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_start_dir -// Access: Public -// Description: Returns the directory that the .p3d file should be -// mounted to and run from. This is usually the -// "start" subdirectory of the root_dir. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory that the .p3d file should be mounted to and run from. + * This is usually the "start" subdirectory of the root_dir. + */ inline const string &P3DInstanceManager:: get_start_dir() const { return _start_dir; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_platform -// Access: Public -// Description: Returns the string that corresponds to the platform -// on which we are running. This string will be used to -// determine the appropriate packages to download. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that corresponds to the platform on which we are + * running. This string will be used to determine the appropriate packages to + * download. + */ inline const string &P3DInstanceManager:: get_platform() const { return _platform; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_temp_directory -// Access: Public -// Description: Returns the pathname of the directory into which -// temporary files should be written. This filename -// will end with a slash, so that full pathnames may be -// made by concatenting directly with this string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pathname of the directory into which temporary files should be + * written. This filename will end with a slash, so that full pathnames may + * be made by concatenting directly with this string. + */ inline const string &P3DInstanceManager:: get_temp_directory() const { return _temp_directory; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_log_directory -// Access: Public -// Description: Returns the pathname of the directory into which all -// log files should be written. This filename will end -// with a slash, so that full pathnames may be made by -// concatenting directly with this string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pathname of the directory into which all log files should be + * written. This filename will end with a slash, so that full pathnames may + * be made by concatenting directly with this string. + */ inline const string &P3DInstanceManager:: get_log_directory() const { return _log_directory; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_log_pathname -// Access: Public -// Description: Returns the filename of the system log file; this -// file is responsible for downloading and installing -// updates, and launching applications. This is -// different from the session log file(s), which -// represent the output from a particular Python -// session. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename of the system log file; this file is responsible for + * downloading and installing updates, and launching applications. This is + * different from the session log file(s), which represent the output from a + * particular Python session. + */ inline const string &P3DInstanceManager:: get_log_pathname() const { return _log_pathname; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_trusted_environment -// Access: Public -// Description: Returns the value of the trusted_environment flag -// passed to the constructor. If this is true, it means -// the environment we are running in is trusted and the -// p3d file is already vetted. This means the current -// working directory will remain unchanged, and the p3d -// file will be run without checking its signature. -// -// This should generally be true only when run by -// panda3d.exe or panda3dw.exe, and not when run by the -// web plugin. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the trusted_environment flag passed to the + * constructor. If this is true, it means the environment we are running in + * is trusted and the p3d file is already vetted. This means the current + * working directory will remain unchanged, and the p3d file will be run + * without checking its signature. + * + * This should generally be true only when run by panda3d.exe or panda3dw.exe, + * and not when run by the web plugin. + */ inline bool P3DInstanceManager:: get_trusted_environment() const { return _trusted_environment; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_console_environment -// Access: Public -// Description: Returns the value of the console_environment flag -// passed to the constructor. If this is true, it means -// we are running from a text-based console window, and -// not from a desktop environment. -// -// This should generally be true only when run by -// panda3d.exe, and not when run by the web plugin or by -// panda3dw.exe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the console_environment flag passed to the + * constructor. If this is true, it means we are running from a text-based + * console window, and not from a desktop environment. + * + * This should generally be true only when run by panda3d.exe, and not when + * run by the web plugin or by panda3dw.exe. + */ inline bool P3DInstanceManager:: get_console_environment() const { return _console_environment; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_num_supported_platforms -// Access: Public -// Description: Returns the number of different supported platforms -// available in get_supported_platform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different supported platforms available in + * get_supported_platform(). + */ inline int P3DInstanceManager:: get_num_supported_platforms() const { return (int)_supported_platforms.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_supported_platform -// Access: Public -// Description: Returns the nth supported platform, where 0 <= n < -// get_num_supported_platforms(). -// -// A given runtime environment may support multiple -// different platforms, e.g. win32 or win64, with the -// restriction that all platform-specific packages -// (beginning from panda3d), must be the same platform. -// -// This function enumerates the different platforms that -// the current runtime environment will support, in -// order of preference--preferred platforms appear first -// in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth supported platform, where 0 <= n < + * get_num_supported_platforms(). + * + * A given runtime environment may support multiple different platforms, e.g. + * win32 or win64, with the restriction that all platform-specific packages + * (beginning from panda3d), must be the same platform. + * + * This function enumerates the different platforms that the current runtime + * environment will support, in order of preference--preferred platforms + * appear first in the list. + */ inline const string &P3DInstanceManager:: get_supported_platform(int n) const { return _supported_platforms.at(n); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_plugin_major_version -// Access: Public -// Description: Returns the plugin's reported major version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the plugin's reported major version number. + */ inline int P3DInstanceManager:: get_plugin_major_version() const { return _plugin_major_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_plugin_minor_version -// Access: Public -// Description: Returns the plugin's reported minor version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the plugin's reported minor version number. + */ inline int P3DInstanceManager:: get_plugin_minor_version() const { return _plugin_minor_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_plugin_sequence_version -// Access: Public -// Description: Returns the plugin's reported sequence version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the plugin's reported sequence version number. + */ inline int P3DInstanceManager:: get_plugin_sequence_version() const { return _plugin_sequence_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_plugin_official_version -// Access: Public -// Description: Returns true if the plugin claims to be from an -// "official" build, and the its version number is -// authoritative; or false if it makes no such claim -// (for instance, it was built by someone checking out -// from cvs). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the plugin claims to be from an "official" build, and the + * its version number is authoritative; or false if it makes no such claim + * (for instance, it was built by someone checking out from cvs). + */ inline bool P3DInstanceManager:: get_plugin_official_version() const { return _plugin_official_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_plugin_distributor -// Access: Public -// Description: Returns the "distributor" reported by the plugin. -// This should represent the entity that built and -// hosted the plugin. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "distributor" reported by the plugin. This should represent + * the entity that built and hosted the plugin. + */ inline const string &P3DInstanceManager:: get_plugin_distributor() const { return _plugin_distributor; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_coreapi_host_url -// Access: Public -// Description: Returns the host URL from which this Core API was -// downloaded (according to the plugin). This is for -// reporting purposes only; see get_host_url() for the -// URL to contact to actually download content. -//////////////////////////////////////////////////////////////////// +/** + * Returns the host URL from which this Core API was downloaded (according to + * the plugin). This is for reporting purposes only; see get_host_url() for + * the URL to contact to actually download content. + */ inline const string &P3DInstanceManager:: get_coreapi_host_url() const { return _coreapi_host_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_coreapi_timestamp -// Access: Public -// Description: Returns the timestamp associated with this Core API -// DLL (according to the plugin). This is the timestamp -// shown in the contents.xml for this host, and is -// usually the time at which the plugin was built. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp associated with this Core API DLL (according to the + * plugin). This is the timestamp shown in the contents.xml for this host, + * and is usually the time at which the plugin was built. + */ inline time_t P3DInstanceManager:: get_coreapi_timestamp() const { return _coreapi_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_coreapi_set_ver -// Access: Public -// Description: Returns the version number associated with the Core -// API, if provided. Some early versions of the Core -// API, and some early versions of the plugin, did not -// provide a number here. If provided, this will be a -// string of dot-separated integers. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version number associated with the Core API, if provided. Some + * early versions of the Core API, and some early versions of the plugin, did + * not provide a number here. If provided, this will be a string of dot- + * separated integers. + */ inline const string &P3DInstanceManager:: get_coreapi_set_ver() const { return _coreapi_set_ver; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_super_mirror -// Access: Public -// Description: Returns the "super mirror" URL. See p3d_plugin.h. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "super mirror" URL. See p3d_plugin.h. + */ inline const string &P3DInstanceManager:: get_super_mirror() const { return _super_mirror_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_num_instances -// Access: Public -// Description: Returns the number of instances currently running -// within the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of instances currently running within the world. + */ inline int P3DInstanceManager:: get_num_instances() const { return _instances.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::new_undefined_object -// Access: Public -// Description: Returns the singleton "undefined" object, as a new -// reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the singleton "undefined" object, as a new reference. + */ inline P3D_object *P3DInstanceManager:: new_undefined_object() { P3D_OBJECT_INCREF(_undefined_object); return _undefined_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::new_none_object -// Access: Public -// Description: Returns the singleton "none" object, as a new -// reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the singleton "none" object, as a new reference. + */ inline P3D_object *P3DInstanceManager:: new_none_object() { P3D_OBJECT_INCREF(_none_object); return _none_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::new_bool_object -// Access: Public -// Description: Returns the singleton "true" or "false" object, as a -// new reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the singleton "true" or "false" object, as a new reference. + */ inline P3D_object *P3DInstanceManager:: new_bool_object(bool value) { P3D_object *obj = (value) ? _true_object : _false_object; @@ -398,12 +310,9 @@ new_bool_object(bool value) { return obj; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::encode_hexdigit -// Access: Public -// Description: Returns the hex digit corresponding to the -// indicated integer value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the hex digit corresponding to the indicated integer value. + */ inline char P3DInstanceManager:: encode_hexdigit(int c) { if (c >= 10) { diff --git a/direct/src/plugin/p3dInstanceManager.cxx b/direct/src/plugin/p3dInstanceManager.cxx index fa8c70def2..65ed9104f7 100644 --- a/direct/src/plugin/p3dInstanceManager.cxx +++ b/direct/src/plugin/p3dInstanceManager.cxx @@ -1,16 +1,15 @@ -// Filename: p3dInstanceManager.cxx -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstanceManager.cxx + * @author drose + * @date 2009-05-29 + */ #include "p3dInstanceManager.h" #include "p3dInstance.h" @@ -30,8 +29,8 @@ #include "mkdir_complete.h" #include "wstring_encode.h" -// We can include this header file to get the DTOOL_PLATFORM -// definition, even though we don't link with dtool. +// We can include this header file to get the DTOOL_PLATFORM definition, even +// though we don't link with dtool. #include "dtool_platform.h" #ifdef _WIN32 @@ -56,11 +55,9 @@ ostream *nout_stream = &logfile; P3DInstanceManager *P3DInstanceManager::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstanceManager:: P3DInstanceManager() { init_xml(); @@ -91,13 +88,13 @@ P3DInstanceManager() { _auth_session = NULL; - // Seed the lame random number generator in rand(); we use it to - // select a mirror for downloading. + // Seed the lame random number generator in rand(); we use it to select a + // mirror for downloading. srand((unsigned int)time(NULL)); #ifdef _WIN32 - // Ensure the appropriate Windows common controls are available to - // this application. + // Ensure the appropriate Windows common controls are available to this + // application. INITCOMMONCONTROLSEX icc; icc.dwSize = sizeof(icc); icc.dwICC = ICC_PROGRESS_CLASS; @@ -105,8 +102,8 @@ P3DInstanceManager() { #endif #ifndef _WIN32 - // On Mac or Linux, we'd better ignore SIGPIPE, or this signal will - // shut down the browser if the plugin exits unexpectedly. + // On Mac or Linux, we'd better ignore SIGPIPE, or this signal will shut + // down the browser if the plugin exits unexpectedly. struct sigaction ignore; memset(&ignore, 0, sizeof(ignore)); ignore.sa_handler = SIG_IGN; @@ -114,11 +111,9 @@ P3DInstanceManager() { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::Destructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstanceManager:: ~P3DInstanceManager() { if (_started_notify_thread) { @@ -187,16 +182,13 @@ P3DInstanceManager:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::initialize -// Access: Public -// Description: Called by the plugin host at application startup. It -// returns true if the DLL is successfully initialized, -// false if it should be immediately shut down and -// redownloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called by the plugin host at application startup. It returns true if the + * DLL is successfully initialized, false if it should be immediately shut + * down and redownloaded. + */ bool P3DInstanceManager:: -initialize(int api_version, const string &contents_filename, +initialize(int api_version, const string &contents_filename, const string &host_url, P3D_verify_contents verify_contents, const string &platform, const string &log_directory, const string &log_basename, bool trusted_environment, @@ -217,8 +209,8 @@ initialize(int api_version, const string &contents_filename, } if (_platform.empty()) { - // If the platform is compiled in (as opposed to passed in by the - // caller), we might in fact support multiple platforms. + // If the platform is compiled in (as opposed to passed in by the caller), + // we might in fact support multiple platforms. _platform = DTOOL_PLATFORM; #ifdef _WIN32 if (_platform == "win_amd64") { @@ -227,8 +219,8 @@ initialize(int api_version, const string &contents_filename, _supported_platforms.push_back("win32"); } else if (_platform == "win_i386" || _platform == "win32") { - // This is a WIN32 process, but determine if the underlying OS - // actually supports WIN64. + // This is a WIN32 process, but determine if the underlying OS actually + // supports WIN64. if (supports_win64()) { _supported_platforms.push_back("win_amd64"); } @@ -241,8 +233,8 @@ initialize(int api_version, const string &contents_filename, _supported_platforms.push_back("osx_i386"); } else if (_platform == "osx_i386") { - // This is a 32-bit process, but determine if the underlying OS - // supports 64-bit. + // This is a 32-bit process, but determine if the underlying OS supports + // 64-bit. int mib[2] = { CTL_HW, HW_MACHINE }; char machine[512]; @@ -257,8 +249,8 @@ initialize(int api_version, const string &contents_filename, } #endif // _WIN32 - // TODO: Linux multiplatform support. Just add the - // appropriate platform strings to _supported_platforms. + // TODO: Linux multiplatform support. Just add the appropriate platform + // strings to _supported_platforms. } else { nout << "Platform string was set by plugin to " << _platform << "\n"; } @@ -308,10 +300,9 @@ initialize(int api_version, const string &contents_filename, _start_dir = start_dir; } - // Allow the caller (e.g. panda3d.exe) to specify a log directory. - // Or, allow the developer to compile one in. - // - // Failing that, we write logfiles to Panda3D/log. + // Allow the caller (e.g. panda3d.exe) to specify a log directory. Or, + // allow the developer to compile one in. Failing that, we write logfiles + // to Panda3Dlog. if (_log_directory.empty()) { _log_directory = _root_dir + "/log"; } @@ -350,12 +341,10 @@ initialize(int api_version, const string &contents_filename, return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::set_plugin_version -// Access: Public -// Description: Specifies the version of the calling plugin, for -// reporting to JavaScript and the like. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the version of the calling plugin, for reporting to JavaScript + * and the like. + */ void P3DInstanceManager:: set_plugin_version(int major, int minor, int sequence, bool official, const string &distributor, @@ -369,9 +358,8 @@ set_plugin_version(int major, int minor, int sequence, _plugin_official_version = official; _plugin_distributor = distributor; - // The Core API "host URL" is both compiled in, and comes in - // externally; we trust the external source in the case of a - // conflict. + // The Core API "host URL" is both compiled in, and comes in externally; we + // trust the external source in the case of a conflict. string internal_host_url = PANDA_PACKAGE_HOST_URL; if (coreapi_host_url != internal_host_url) { nout << "Warning! Downloaded Core API from " << coreapi_host_url @@ -385,13 +373,13 @@ set_plugin_version(int major, int minor, int sequence, // The Core API timestamp is only available externally. _coreapi_timestamp = coreapi_timestamp; - // The Core API "set ver", or version, is both compiled in and comes - // in externally; for this one we trust the internal version in the - // case of a conflict. + // The Core API "set ver", or version, is both compiled in and comes in + // externally; for this one we trust the internal version in the case of a + // conflict. string internal_set_ver = P3D_COREAPI_VERSION_STR; if (coreapi_set_ver != internal_set_ver && !coreapi_set_ver.empty() && !internal_set_ver.empty()) { nout << "Warning! contents.xml reports Core API version number " - << coreapi_set_ver << ", but its actual version number is " + << coreapi_set_ver << ", but its actual version number is " << internal_set_ver << "\n"; } _coreapi_set_ver = internal_set_ver; @@ -418,11 +406,9 @@ set_plugin_version(int major, int minor, int sequence, nout << "Core API date: " << timestamp_string << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::set_super_mirror -// Access: Public -// Description: Specifies the "super mirror" URL. See p3d_plugin.h. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the "super mirror" URL. See p3d_plugin.h. + */ void P3DInstanceManager:: set_super_mirror(const string &super_mirror_url) { reconsider_runtime_environment(); @@ -437,15 +423,13 @@ set_super_mirror(const string &super_mirror_url) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::create_instance -// Access: Public -// Description: Returns a newly-allocated P3DInstance with the -// indicated startup information. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated P3DInstance with the indicated startup + * information. + */ P3DInstance *P3DInstanceManager:: -create_instance(P3D_request_ready_func *func, - const P3D_token tokens[], size_t num_tokens, +create_instance(P3D_request_ready_func *func, + const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data) { reconsider_runtime_environment(); P3DInstance *inst = new P3DInstance(func, tokens, num_tokens, argc, argv, @@ -456,12 +440,9 @@ create_instance(P3D_request_ready_func *func, return inst; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::set_p3d_filename -// Access: Public -// Description: Sets the p3d_filename (or p3d_url) on a particular -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the p3d_filename (or p3d_url) on a particular instance. + */ bool P3DInstanceManager:: set_p3d_filename(P3DInstance *inst, bool is_local, const string &p3d_filename, const int &p3d_offset) { @@ -478,13 +459,10 @@ set_p3d_filename(P3DInstance *inst, bool is_local, return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::make_p3d_stream -// Access: Public -// Description: Indicates an intention to transmit the p3d data as a -// stream. Should return a new unique stream ID to -// receive it. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an intention to transmit the p3d data as a stream. Should return + * a new unique stream ID to receive it. + */ int P3DInstanceManager:: make_p3d_stream(P3DInstance *inst, const string &p3d_url) { if (inst->is_started()) { @@ -495,13 +473,10 @@ make_p3d_stream(P3DInstance *inst, const string &p3d_url) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::start_instance -// Access: Public -// Description: Actually starts the instance running on a particular -// session. This is called by the P3DInstance when it -// successfully loads its instance file. -//////////////////////////////////////////////////////////////////// +/** + * Actually starts the instance running on a particular session. This is + * called by the P3DInstance when it successfully loads its instance file. + */ bool P3DInstanceManager:: start_instance(P3DInstance *inst) { if (inst->is_failed()) { @@ -530,12 +505,9 @@ start_instance(P3DInstance *inst) { return inst->is_started(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::finish_instance -// Access: Public -// Description: Terminates and removes a previously-returned -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Terminates and removes a previously-returned instance. + */ void P3DInstanceManager:: finish_instance(P3DInstance *inst) { nout << "finish_instance: " << inst << "\n"; @@ -550,8 +522,7 @@ finish_instance(P3DInstance *inst) { P3DSession *session = (*si).second; session->terminate_instance(inst); - // If that was the last instance in this session, terminate the - // session. + // If that was the last instance in this session, terminate the session. if (session->get_num_instances() == 0) { _sessions.erase(session->get_session_key()); session->shutdown(); @@ -563,19 +534,16 @@ finish_instance(P3DInstance *inst) { p3d_unref_delete(inst); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::authorize_instance -// Access: Public -// Description: Creates a new P3DAuthSession object, to pop up a -// window for the user to authorize the certificate on -// this instance. Automatically terminates any -// previously-created P3DAuthSession. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new P3DAuthSession object, to pop up a window for the user to + * authorize the certificate on this instance. Automatically terminates any + * previously-created P3DAuthSession. + */ P3DAuthSession *P3DInstanceManager:: authorize_instance(P3DInstance *inst) { if (_auth_session != NULL) { - // We only want one auth_session window open at a time, to - // minimize user confusion, so close any previous window. + // We only want one auth_session window open at a time, to minimize user + // confusion, so close any previous window. _auth_session->shutdown(true); p3d_unref_delete(_auth_session); _auth_session = NULL; @@ -586,13 +554,10 @@ authorize_instance(P3DInstance *inst) { return _auth_session; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::validate_instance -// Access: Public -// Description: Returns the P3DInstance pointer corresponding to the -// indicated P3D_instance if it is valid, or NULL if it -// is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the P3DInstance pointer corresponding to the indicated P3D_instance + * if it is valid, or NULL if it is not. + */ P3DInstance *P3DInstanceManager:: validate_instance(P3D_instance *instance) { Instances::iterator ii; @@ -604,12 +569,10 @@ validate_instance(P3D_instance *instance) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::check_request -// Access: Public -// Description: If a request is currently pending on any instance, -// returns its pointer. Otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * If a request is currently pending on any instance, returns its pointer. + * Otherwise, returns NULL. + */ P3DInstance *P3DInstanceManager:: check_request() { Instances::iterator ii; @@ -623,18 +586,14 @@ check_request() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::wait_request -// Access: Public -// Description: Does not return until a request is pending on some -// instance, or until no instances remain, or until the -// indicated time in seconds has elapsed. Use -// check_request to retrieve the pending request. Due -// to the possibility of race conditions, it is possible -// for this function to return when there is in fact no -// request pending (another thread may have extracted -// the request first). -//////////////////////////////////////////////////////////////////// +/** + * Does not return until a request is pending on some instance, or until no + * instances remain, or until the indicated time in seconds has elapsed. Use + * check_request to retrieve the pending request. Due to the possibility of + * race conditions, it is possible for this function to return when there is + * in fact no request pending (another thread may have extracted the request + * first). + */ void P3DInstanceManager:: wait_request(double timeout) { #ifdef _WIN32 @@ -661,7 +620,7 @@ wait_request(double timeout) { _request_ready.release(); return; } - + // No pending requests; go to sleep. _request_ready.wait(timeout); @@ -698,19 +657,16 @@ wait_request(double timeout) { _request_ready.release(); return; } - + // No pending requests; go to sleep. _request_ready.wait(timeout); } _request_ready.release(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_host -// Access: Public -// Description: Returns a (possibly shared) pointer to the indicated -// download host. -//////////////////////////////////////////////////////////////////// +/** + * Returns a (possibly shared) pointer to the indicated download host. + */ P3DHost *P3DInstanceManager:: get_host(const string &host_url) { Hosts::iterator pi = _hosts.find(host_url); @@ -725,49 +681,41 @@ get_host(const string &host_url) { return host; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::forget_host -// Access: Public -// Description: Removes the indicated host from the cache. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated host from the cache. + */ void P3DInstanceManager:: forget_host(P3DHost *host) { const string &host_url = host->get_host_url(); nout << "Forgetting host " << host_url << "\n"; - - // Hmm, this is a memory leak. But we allow it to remain, since - // it's an unusual circumstance (uninstalling), and it's safer to - // leak than to risk a floating pointer. + + // Hmm, this is a memory leak. But we allow it to remain, since it's an + // unusual circumstance (uninstalling), and it's safer to leak than to risk + // a floating pointer. _hosts.erase(host_url); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_unique_id -// Access: Public -// Description: Returns a number used to uniquify different -// instances. This number is guaranteed to be different -// at each call, at least until the int space rolls -// over. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number used to uniquify different instances. This number is + * guaranteed to be different at each call, at least until the int space rolls + * over. + */ int P3DInstanceManager:: get_unique_id() { ++_unique_id; return _unique_id; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::signal_request_ready -// Access: Public -// Description: May be called in any thread to indicate that a new -// P3D_request is available in the indicated instance. -//////////////////////////////////////////////////////////////////// +/** + * May be called in any thread to indicate that a new P3D_request is available + * in the indicated instance. + */ void P3DInstanceManager:: signal_request_ready(P3DInstance *inst) { if (inst->get_request_ready_func() != NULL) { - // This instance requires asynchronous notifications of requests. - // Thus, we should tell the notify thread to wake up and make the - // callback. + // This instance requires asynchronous notifications of requests. Thus, + // we should tell the notify thread to wake up and make the callback. _notify_ready.acquire(); _notify_instances.push_back(inst); _notify_ready.notify(); @@ -781,18 +729,15 @@ signal_request_ready(P3DInstance *inst) { } } - // Then, wake up the main thread, in case it's sleeping on - // wait_request(). + // Then, wake up the main thread, in case it's sleeping on wait_request(). _request_ready.acquire(); _request_ready.notify(); _request_ready.release(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::make_class_definition -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3D_class_definition *P3DInstanceManager:: make_class_definition() const { P3D_class_definition *new_class = new P3D_class_definition(P3DObject::_generic_class); @@ -800,14 +745,11 @@ make_class_definition() const { return new_class; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::make_temp_filename -// Access: Public -// Description: Constructs a new, unique temporary filename with the -// indicated extension. You should use the -// P3DTemporaryFilename interface instead of calling -// this method directly. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new, unique temporary filename with the indicated extension. + * You should use the P3DTemporaryFilename interface instead of calling this + * method directly. + */ string P3DInstanceManager:: make_temp_filename(const string &extension) { string result; @@ -832,7 +774,7 @@ make_temp_filename(const string &extension) { result += "p3d_"; result += hex_code; result += extension; - + exists = false; if (_temp_filenames.find(result) != _temp_filenames.end()) { // We've previously allocated this file. @@ -861,14 +803,11 @@ make_temp_filename(const string &extension) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::release_temp_filename -// Access: Public -// Description: Releases a temporary filename assigned earlier via -// make_temp_filename(). If the file exists, it will be -// removed. You should use the P3DTemporaryFilename -// interface instead of calling this method directly. -//////////////////////////////////////////////////////////////////// +/** + * Releases a temporary filename assigned earlier via make_temp_filename(). + * If the file exists, it will be removed. You should use the + * P3DTemporaryFilename interface instead of calling this method directly. + */ void P3DInstanceManager:: release_temp_filename(const string &filename) { nout << "release_temp_filename: " << filename << "\n"; @@ -876,38 +815,35 @@ release_temp_filename(const string &filename) { unlink(filename.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::find_cert -// Access: Public -// Description: Looks for the particular certificate in the cache of -// recognized certificates. Returns true if it is -// found, false if not. -//////////////////////////////////////////////////////////////////// +/** + * Looks for the particular certificate in the cache of recognized + * certificates. Returns true if it is found, false if not. + */ bool P3DInstanceManager:: find_cert(X509 *cert) { // First, we need the DER representation. string der = cert_to_der(cert); - // If we've previously found this certificate, we don't have to hit - // disk again. + // If we've previously found this certificate, we don't have to hit disk + // again. ApprovedCerts::iterator ci = _approved_certs.find(der); if (ci != _approved_certs.end()) { return true; } - // Well, we haven't found it already. Look for it on disk. For - // this, we hash the cert into a hex string. This is similar to - // OpenSSL's get_by_subject() approach, except we hash the whole - // cert, not just the subject. (Since we also store self-signed - // certs in this list, we can't trust the subject name alone.) + // Well, we haven't found it already. Look for it on disk. For this, we + // hash the cert into a hex string. This is similar to OpenSSL's + // get_by_subject() approach, except we hash the whole cert, not just the + // subject. (Since we also store self-signed certs in this list, we can't + // trust the subject name alone.) string this_cert_dir = get_cert_dir(cert); nout << "looking in " << this_cert_dir << "\n"; vector contents; scan_directory(this_cert_dir, contents); - // Now look at each of the files in this directory and see if any of - // them matches the certificate. + // Now look at each of the files in this directory and see if any of them + // matches the certificate. vector::iterator si; for (si = contents.begin(); si != contents.end(); ++si) { string filename = this_cert_dir + "/" + (*si); @@ -928,10 +864,10 @@ find_cert(X509 *cert) { if (x509 != NULL) { string der2 = cert_to_der(x509); - // We might as well save this cert in the table for next time, - // even if it's not the one we're looking for right now. + // We might as well save this cert in the table for next time, even if + // it's not the one we're looking for right now. _approved_certs.insert(der2); - + if (der == der2) { return true; } @@ -942,12 +878,10 @@ find_cert(X509 *cert) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::read_certlist -// Access: Public -// Description: Reads the pre-approved certificates in the certlist -// package and adds them to the in-memory cache. -//////////////////////////////////////////////////////////////////// +/** + * Reads the pre-approved certificates in the certlist package and adds them + * to the in-memory cache. + */ void P3DInstanceManager:: read_certlist(P3DPackage *package) { nout << "reading certlist in " << package->get_package_dir() << "\n"; @@ -976,7 +910,7 @@ read_certlist(P3DPackage *package) { x509 = PEM_read_X509(fp, NULL, NULL, (void *)""); fclose(fp); } - + if (x509 != NULL) { string der2 = cert_to_der(x509); _approved_certs.insert(der2); @@ -986,12 +920,9 @@ read_certlist(P3DPackage *package) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_cert_dir -// Access: Public -// Description: Returns the directory searched for this particular -// certificate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory searched for this particular certificate. + */ string P3DInstanceManager:: get_cert_dir(X509 *cert) { string der = cert_to_der(cert); @@ -1016,35 +947,29 @@ get_cert_dir(X509 *cert) { return _certs_dir + "/" + basename; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::cert_to_der -// Access: Public, Static -// Description: Converts the indicated certificate to its binary DER -// representation. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated certificate to its binary DER representation. + */ string P3DInstanceManager:: cert_to_der(X509 *cert) { int buffer_size = i2d_X509(cert, NULL); unsigned char *buffer = new unsigned char[buffer_size]; unsigned char *p = buffer; i2d_X509(cert, &p); - + string result((char *)buffer, buffer_size); delete[] buffer; return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::uninstall_all -// Access: Public -// Description: Stops all active instances and removes *all* -// downloaded files from all hosts, and empties the -// current user's Panda3D directory as much as possible. -// -// This cannot remove the coreapi dll or directory on -// Windows. -//////////////////////////////////////////////////////////////////// +/** + * Stops all active instances and removes *all* downloaded files from all + * hosts, and empties the current user's Panda3D directory as much as + * possible. + * + * This cannot remove the coreapi dll or directory on Windows. + */ void P3DInstanceManager:: uninstall_all() { Instances::iterator ii; @@ -1063,20 +988,17 @@ uninstall_all() { logfile.close(); if (!_root_dir.empty()) { - // This won't be able to delete the coreapi directory on Windows, - // because we're running that DLL right now. But it will delete - // everything else. + // This won't be able to delete the coreapi directory on Windows, because + // we're running that DLL right now. But it will delete everything else. delete_directory_recursively(_root_dir); } _created_runtime_environment = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::get_global_ptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DInstanceManager *P3DInstanceManager:: get_global_ptr() { if (_global_ptr == NULL) { @@ -1085,13 +1007,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::delete_global_ptr -// Access: Public, Static -// Description: This is called only at plugin shutdown time; it -// deletes the global instance manager pointer and -// clears it to NULL. -//////////////////////////////////////////////////////////////////// +/** + * This is called only at plugin shutdown time; it deletes the global instance + * manager pointer and clears it to NULL. + */ void P3DInstanceManager:: delete_global_ptr() { if (_global_ptr != NULL) { @@ -1100,27 +1019,22 @@ delete_global_ptr() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::scan_directory -// Access: Public, Static -// Description: Attempts to open the named filename as if it were a -// directory and looks for the non-hidden files within -// the directory. Fills the given vector up with the -// sorted list of filenames that are local to this -// directory. -// -// It is the user's responsibility to ensure that the -// contents vector is empty before making this call; -// otherwise, the new files will be appended to it. -// -// Returns true on success, false if the directory could -// not be read for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the named filename as if it were a directory and looks for + * the non-hidden files within the directory. Fills the given vector up with + * the sorted list of filenames that are local to this directory. + * + * It is the user's responsibility to ensure that the contents vector is empty + * before making this call; otherwise, the new files will be appended to it. + * + * Returns true on success, false if the directory could not be read for some + * reason. + */ bool P3DInstanceManager:: scan_directory(const string &dirname, vector &contents) { #ifdef _WIN32 - // Use Windows' FindFirstFile() / FindNextFile() to walk through the - // list of files in a directory. + // Use Windows' FindFirstFile() FindNextFile() to walk through the list of + // files in a directory. size_t orig_size = contents.size(); string match = dirname + "\\*.*"; @@ -1153,8 +1067,8 @@ scan_directory(const string &dirname, vector &contents) { return scan_ok; #else // _WIN32 - // Use Posix's opendir() / readdir() to walk through the list of - // files in a directory. + // Use Posix's opendir() readdir() to walk through the list of files in a + // directory. size_t orig_size = contents.size(); DIR *root = opendir(dirname.c_str()); @@ -1179,22 +1093,18 @@ scan_directory(const string &dirname, vector &contents) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::scan_directory_recursively -// Access: Public, Static -// Description: Fills up filename_contents with the list of all -// files (but not directories), and dirname_contents -// with the list of all directories, rooted at the -// indicated dirname and below. The filenames generated -// are relative to the root of the dirname, with slashes -// (not backslashes) as the directory separator -// character. -// -// Returns true on success, false if the original -// dirname wasn't a directory or something like that. -//////////////////////////////////////////////////////////////////// +/** + * Fills up filename_contents with the list of all files (but not + * directories), and dirname_contents with the list of all directories, rooted + * at the indicated dirname and below. The filenames generated are relative + * to the root of the dirname, with slashes (not backslashes) as the directory + * separator character. + * + * Returns true on success, false if the original dirname wasn't a directory + * or something like that. + */ bool P3DInstanceManager:: -scan_directory_recursively(const string &dirname, +scan_directory_recursively(const string &dirname, vector &filename_contents, vector &dirname_contents, const string &prefix) { @@ -1207,19 +1117,18 @@ scan_directory_recursively(const string &dirname, // Walk through the contents of dirname. vector::const_iterator si; for (si = dir_contents.begin(); si != dir_contents.end(); ++si) { - // Here's a particular file within dirname. Is it another - // directory, or is it a regular file? + // Here's a particular file within dirname. Is it another directory, or + // is it a regular file? string pathname = dirname + "/" + (*si); string rel_filename = prefix + (*si); - if (scan_directory_recursively(pathname, filename_contents, + if (scan_directory_recursively(pathname, filename_contents, dirname_contents, rel_filename + "/")) { - // It's a directory, and it's just added its results to the - // contents. + // It's a directory, and it's just added its results to the contents. dirname_contents.push_back(rel_filename); } else { - // It's not a directory, so assume it's an ordinary file, and - // add it to the contents. + // It's not a directory, so assume it's an ordinary file, and add it to + // the contents. filename_contents.push_back(rel_filename); } } @@ -1227,13 +1136,10 @@ scan_directory_recursively(const string &dirname, return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::delete_directory_recursively -// Access: Public, Static -// Description: Deletes all of the files and directories in the named -// directory and below, like rm -rf. Use with extreme -// caution. -//////////////////////////////////////////////////////////////////// +/** + * Deletes all of the files and directories in the named directory and below, + * like rm -rf. Use with extreme caution. + */ void P3DInstanceManager:: delete_directory_recursively(const string &root_dir) { vector contents, dirname_contents; @@ -1284,8 +1190,8 @@ delete_directory_recursively(const string &root_dir) { } } - // Now delete all of the directories too. They're already in - // reverse order, so we remove deeper directories first. + // Now delete all of the directories too. They're already in reverse order, + // so we remove deeper directories first. for (ci = dirname_contents.begin(); ci != dirname_contents.end(); ++ci) { string filename = (*ci); string pathname = root_dir + "/" + filename; @@ -1329,26 +1235,21 @@ delete_directory_recursively(const string &root_dir) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::remove_file_from_list -// Access: Public, Static -// Description: Removes the first instance of the indicated file -// from the given list. Returns true if removed, false -// if it was not found. -// -// On Windows, the directory separator characters are -// changed from backslash to forward slash before -// searching in the list; so it is assumed that the list -// contains filenames with a forward slash used as a -// separator. -//////////////////////////////////////////////////////////////////// +/** + * Removes the first instance of the indicated file from the given list. + * Returns true if removed, false if it was not found. + * + * On Windows, the directory separator characters are changed from backslash + * to forward slash before searching in the list; so it is assumed that the + * list contains filenames with a forward slash used as a separator. + */ bool P3DInstanceManager:: remove_file_from_list(vector &contents, const string &filename) { #ifdef _WIN32 // Convert backslashes to slashes. string clean_filename; - for (string::const_iterator pi = filename.begin(); - pi != filename.end(); + for (string::const_iterator pi = filename.begin(); + pi != filename.end(); ++pi) { if ((*pi) == '\\') { clean_filename += '/'; @@ -1371,15 +1272,12 @@ remove_file_from_list(vector &contents, const string &filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::append_safe_dir -// Access: Public, Static -// Description: Appends the indicated basename to the root directory -// name, which is modified in-place. The basename is -// allowed to contain nested slashes, but no directory -// component of the basename may begin with a ".", thus -// precluding ".." and hidden files. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicated basename to the root directory name, which is + * modified in-place. The basename is allowed to contain nested slashes, but + * no directory component of the basename may begin with a ".", thus + * precluding ".." and hidden files. + */ void P3DInstanceManager:: append_safe_dir(string &root, const string &basename) { if (basename.empty()) { @@ -1402,13 +1300,10 @@ append_safe_dir(string &root, const string &basename) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::create_runtime_environment -// Access: Private -// Description: Called during initialize, or after a previous call to -// uninstall_all(), to make sure all needed -// directories exist and the logfile is open. -//////////////////////////////////////////////////////////////////// +/** + * Called during initialize, or after a previous call to uninstall_all(), to + * make sure all needed directories exist and the logfile is open. + */ void P3DInstanceManager:: create_runtime_environment() { mkdir_complete(_log_directory, cerr); @@ -1432,27 +1327,25 @@ create_runtime_environment() { wchar_t buffer_1[MAX_PATH]; wstring temp_directory_w; - // Figuring out the correct path for temporary files is a real mess - // on Windows. We should be able to use GetTempPath(), but that - // relies on $TMP or $TEMP being defined, and it appears that - // Mozilla clears these environment variables for the plugin, which - // forces GetTempPath() into $USERPROFILE instead. This is really - // an inappropriate place for temporary files, so, GetTempPath() - // isn't a great choice. + // Figuring out the correct path for temporary files is a real mess on + // Windows. We should be able to use GetTempPath(), but that relies on $TMP + // or $TEMP being defined, and it appears that Mozilla clears these + // environment variables for the plugin, which forces GetTempPath() into + // $USERPROFILE instead. This is really an inappropriate place for + // temporary files, so, GetTempPath() isn't a great choice. - // We could use SHGetSpecialFolderPath() instead to get us the path - // to "Temporary Internet Files", which is acceptable. The trouble - // is, if we happen to be running in "Protected Mode" on Vista, this - // folder isn't actually writable by us! On Vista, we're supposed - // to use IEGetWriteableFolderPath() instead, but *this* function - // doesn't exist on XP and below. Good Lord. + // We could use SHGetSpecialFolderPath() instead to get us the path to + // "Temporary Internet Files", which is acceptable. The trouble is, if we + // happen to be running in "Protected Mode" on Vista, this folder isn't + // actually writable by us! On Vista, we're supposed to use + // IEGetWriteableFolderPath() instead, but *this* function doesn't exist on + // XP and below. Good Lord. - // We could go through a bunch of LoadLibrary() calls to try to find - // the right path, like we do in find_root_dir(), but I'm just tired - // of doing all that nonsense. We'll use a two-stage trick instead. - // We'll check for $TEMP or $TMP being defined specifically, and if - // they are, we'll use GetTempPath(); otherwise, we'll fall back to - // SHGetSpecialFolderPath(). + // We could go through a bunch of LoadLibrary() calls to try to find the + // right path, like we do in find_root_dir(), but I'm just tired of doing + // all that nonsense. We'll use a two-stage trick instead. We'll check for + // $TEMP or $TMP being defined specifically, and if they are, we'll use + // GetTempPath(); otherwise, we'll fall back to SHGetSpecialFolderPath(). if (getenv("TEMP") != NULL || getenv("TMP") != NULL) { if (GetTempPathW(MAX_PATH, buffer_1) != 0) { @@ -1463,8 +1356,8 @@ create_runtime_environment() { if (SHGetSpecialFolderPathW(NULL, buffer_1, CSIDL_INTERNET_CACHE, true)) { temp_directory_w = buffer_1; - // That just *might* return a non-writable folder, if we're in - // Protected Mode. We'll test this with GetTempFileName(). + // That just *might* return a non-writable folder, if we're in Protected + // Mode. We'll test this with GetTempFileName(). wchar_t temp_buffer[MAX_PATH]; if (!GetTempFileNameW(temp_directory_w.c_str(), L"p3d", 0, temp_buffer)) { nout << "GetTempFileName failed on " << temp_directory_w @@ -1476,9 +1369,9 @@ create_runtime_environment() { } } - // If both of the above failed, we'll fall back to GetTempPath() - // once again as a last resort, which is supposed to return - // *something* that works, even if $TEMP and $TMP are undefined. + // If both of the above failed, we'll fall back to GetTempPath() once again + // as a last resort, which is supposed to return *something* that works, + // even if $TEMP and $TMP are undefined. if (temp_directory_w.empty()) { if (GetTempPathW(MAX_PATH, buffer_1) != 0) { temp_directory_w = buffer_1; @@ -1531,12 +1424,10 @@ create_runtime_environment() { _created_runtime_environment = true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::append_safe_dir_component -// Access: Private, Static -// Description: Appends a single directory component, implementing -// append_safe_dir(), above. -//////////////////////////////////////////////////////////////////// +/** + * Appends a single directory component, implementing append_safe_dir(), + * above. + */ void P3DInstanceManager:: append_safe_dir_component(string &root, const string &component) { if (component.empty()) { @@ -1549,22 +1440,21 @@ append_safe_dir_component(string &root, const string &component) { root += component; } -//////////////////////////////////////////////////////////////////// -// Function: P3DInstanceManager::nt_thread_run -// Access: Private -// Description: The main function for the notify thread. -//////////////////////////////////////////////////////////////////// +/** + * The main function for the notify thread. + */ void P3DInstanceManager:: nt_thread_run() { - // The notify thread exists because we need to be able to send - // asynchronous notifications of request events. These request - // events were detected in the various read threads associated with - // each session, but we can't call back into the plugin host space - // from the read thread, since if the host immediately responds to a - // callback by calling back into the p3d_plugin space, we will have - // our read thread doing stuff in here that's not related to the - // read thread. Even worse, some of the things it might need to do - // might require a separate read thread to be running! +/* + * The notify thread exists because we need to be able to send asynchronous + * notifications of request events. These request events were detected in the + * various read threads associated with each session, but we can't call back + * into the plugin host space from the read thread, since if the host + * immediately responds to a callback by calling back into the p3d_plugin + * space, we will have our read thread doing stuff in here that's not related + * to the read thread. Even worse, some of the things it might need to do + * might require a separate read thread to be running! + */ _notify_ready.acquire(); while (_notify_thread_continue) { @@ -1573,9 +1463,9 @@ nt_thread_run() { instances.clear(); instances.swap(_notify_instances); - // Go ahead and drop the lock while we make the callback, to - // reduce the risk of deadlock. We don't want to be holding any - // locks when we call into client code. + // Go ahead and drop the lock while we make the callback, to reduce the + // risk of deadlock. We don't want to be holding any locks when we call + // into client code. _notify_ready.release(); NotifyInstances::iterator ni; for (ni = instances.begin(); ni != instances.end(); ++ni) { @@ -1603,7 +1493,7 @@ supports_win64() { typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); LPFN_ISWOW64PROCESS _IsWow64Process; _IsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); - + if (_IsWow64Process != NULL) { if (!_IsWow64Process(GetCurrentProcess(), &is_win64)) { is_win64 = false; diff --git a/direct/src/plugin/p3dInstanceManager.h b/direct/src/plugin/p3dInstanceManager.h index b051c01310..a148c760a2 100644 --- a/direct/src/plugin/p3dInstanceManager.h +++ b/direct/src/plugin/p3dInstanceManager.h @@ -1,16 +1,15 @@ -// Filename: p3dInstanceManager.h -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dInstanceManager.h + * @author drose + * @date 2009-05-29 + */ #ifndef P3DINSTANCEMANAGER_H #define P3DINSTANCEMANAGER_H @@ -39,11 +38,9 @@ class P3DPackage; class FileSpec; class TiXmlElement; -//////////////////////////////////////////////////////////////////// -// Class : P3DInstanceManager -// Description : This global class manages the set of instances in the -// universe. -//////////////////////////////////////////////////////////////////// +/** + * This global class manages the set of instances in the universe. + */ class P3DInstanceManager { private: P3DInstanceManager(); @@ -99,8 +96,8 @@ public: inline const string &get_super_mirror() const; P3DInstance * - create_instance(P3D_request_ready_func *func, - const P3D_token tokens[], size_t num_tokens, + create_instance(P3D_request_ready_func *func, + const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data); bool set_p3d_filename(P3DInstance *inst, bool is_local, @@ -138,13 +135,13 @@ public: static string cert_to_der(X509 *cert); void uninstall_all(); - + static P3DInstanceManager *get_global_ptr(); static void delete_global_ptr(); static inline char encode_hexdigit(int c); static bool scan_directory(const string &dirname, vector &contents); - static bool scan_directory_recursively(const string &dirname, + static bool scan_directory_recursively(const string &dirname, vector &filename_contents, vector &dirname_contents, const string &prefix = ""); @@ -158,9 +155,8 @@ private: static void append_safe_dir_component(string &root, const string &component); private: - // The notify thread. This thread runs only for the purpose of - // generating asynchronous notifications of requests, to callers who - // ask for it. + // The notify thread. This thread runs only for the purpose of generating + // asynchronous notifications of requests, to callers who ask for it. THREAD_CALLBACK_DECLARATION(P3DInstanceManager, nt_thread_run); void nt_thread_run(); @@ -204,7 +200,7 @@ private: P3D_object *_false_object; typedef set ApprovedCerts; - ApprovedCerts _approved_certs; + ApprovedCerts _approved_certs; typedef set Instances; Instances _instances; @@ -222,16 +218,16 @@ private: int _unique_id; - // This condition var is waited on the main thread and signaled in a - // sub-thread when new request notices arrive. + // This condition var is waited on the main thread and signaled in a sub- + // thread when new request notices arrive. P3DConditionVar _request_ready; // We may need a thread to send async request notices to callers. bool _notify_thread_continue; bool _started_notify_thread; THREAD _notify_thread; - // This queue of instances that need to send notifications is - // protected by _notify_ready's mutex. + // This queue of instances that need to send notifications is protected by + // _notify_ready's mutex. typedef vector NotifyInstances; NotifyInstances _notify_instances; P3DConditionVar _notify_ready; diff --git a/direct/src/plugin/p3dIntObject.cxx b/direct/src/plugin/p3dIntObject.cxx index 6c38a9cfa8..4fa4b14aaf 100644 --- a/direct/src/plugin/p3dIntObject.cxx +++ b/direct/src/plugin/p3dIntObject.cxx @@ -1,33 +1,28 @@ -// Filename: p3dIntObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dIntObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dIntObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DIntObject:: P3DIntObject(int value) : _value(value) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DIntObject:: P3DIntObject(const P3DIntObject ©) : P3DObject(copy), @@ -35,48 +30,37 @@ P3DIntObject(const P3DIntObject ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DIntObject:: get_type() { return P3D_OT_int; } -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DIntObject:: get_bool() { return (_value != 0); } -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DIntObject:: get_int() { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DIntObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DIntObject:: make_string(string &value) { ostringstream strm; strm << _value; value = strm.str(); } - diff --git a/direct/src/plugin/p3dIntObject.h b/direct/src/plugin/p3dIntObject.h index 829ba0c62e..899e422142 100644 --- a/direct/src/plugin/p3dIntObject.h +++ b/direct/src/plugin/p3dIntObject.h @@ -1,16 +1,15 @@ -// Filename: p3dIntObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dIntObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DINTOBJECT_H #define P3DINTOBJECT_H @@ -18,10 +17,9 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DIntObject -// Description : An object type that contains an integer value. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains an integer value. + */ class P3DIntObject : public P3DObject { public: P3DIntObject(int value); @@ -38,4 +36,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dMainObject.cxx b/direct/src/plugin/p3dMainObject.cxx index 5b49cbcf43..c905c8805b 100644 --- a/direct/src/plugin/p3dMainObject.cxx +++ b/direct/src/plugin/p3dMainObject.cxx @@ -1,16 +1,15 @@ -// Filename: p3dMainObject.cxx -// Created by: drose (10Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dMainObject.cxx + * @author drose + * @date 2009-07-10 + */ #include "p3dMainObject.h" #include "p3dPythonObject.h" @@ -19,11 +18,9 @@ #include "p3dStringObject.h" #include "p3dInstanceManager.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DMainObject:: P3DMainObject() : _pyobj(NULL), @@ -32,11 +29,9 @@ P3DMainObject() : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DMainObject:: ~P3DMainObject() { set_pyobj(NULL); @@ -50,55 +45,42 @@ P3DMainObject:: _properties.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DMainObject:: get_type() { return P3D_OT_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DMainObject:: get_bool() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DMainObject:: get_int() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_float -// Access: Public, Virtual -// Description: Returns the object value coerced to a floating-point -// value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a floating-point value, if possible. + */ double P3DMainObject:: get_float() { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DMainObject:: make_string(string &value) { if (_pyobj == NULL) { @@ -109,16 +91,13 @@ make_string(string &value) { P3D_OBJECT_GET_STRING(_pyobj, buffer, size); value = string(buffer, size); delete[] buffer; - } + } } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_property -// Access: Public, Virtual -// Description: Returns the named property element in the object. The -// return value is a new-reference P3D_object, or NULL -// on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * new-reference P3D_object, or NULL on error. + */ P3D_object *P3DMainObject:: get_property(const string &property) { if (_pyobj == NULL) { @@ -137,13 +116,10 @@ get_property(const string &property) { return P3D_OBJECT_GET_PROPERTY(_pyobj, property.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::set_property -// Access: Public, Virtual -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool P3DMainObject:: set_property(const string &property, bool needs_response, P3D_object *value) { // First, we set the property locally. @@ -177,12 +153,9 @@ set_property(const string &property, bool needs_response, P3D_object *value) { return P3D_OBJECT_SET_PROPERTY(_pyobj, property.c_str(), needs_response, value); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::has_method -// Access: Public, Virtual -// Description: Returns true if the named method exists on this -// object, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named method exists on this object, false otherwise. + */ bool P3DMainObject:: has_method(const string &method_name) { // Some special-case methods implemented in-place. @@ -206,19 +179,14 @@ has_method(const string &method_name) { return P3D_OBJECT_HAS_METHOD(_pyobj, method_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call -// Access: Public, Virtual -// Description: Invokes the named method on the object, passing the -// indicated parameters. If the method name is empty, -// invokes the object itself. -// -// If needs_response is true, the return value is a -// new-reference P3D_object on success, or NULL on -// failure. If needs_response is false, the return -// value is always NULL, and there is no way to -// determine success or failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes the named method on the object, passing the indicated parameters. + * If the method name is empty, invokes the object itself. + * + * If needs_response is true, the return value is a new-reference P3D_object + * on success, or NULL on failure. If needs_response is false, the return + * value is always NULL, and there is no way to determine success or failure. + */ P3D_object *P3DMainObject:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { @@ -258,37 +226,30 @@ call(const string &method_name, bool needs_response, params, num_params); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::output -// Access: Public, Virtual -// Description: Writes a formatted representation of the value to the -// indicated string. This is intended for developer -// assistance. -//////////////////////////////////////////////////////////////////// +/** + * Writes a formatted representation of the value to the indicated string. + * This is intended for developer assistance. + */ void P3DMainObject:: output(ostream &out) { out << "P3DMainObject"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::set_pyobj -// Access: Public -// Description: Changes the internal pyobj pointer. This is the -// P3D_object that references the actual PyObject held -// within the child process, corresponding to the true -// main object there. The new object's reference -// count is incremented, and the previous object's is -// decremented. -//////////////////////////////////////////////////////////////////// +/** + * Changes the internal pyobj pointer. This is the P3D_object that references + * the actual PyObject held within the child process, corresponding to the + * true main object there. The new object's reference count is incremented, + * and the previous object's is decremented. + */ void P3DMainObject:: set_pyobj(P3D_object *pyobj) { if (pyobj == this) { - // We are setting a reference directly to ourselves. This happens - // when the application has accepted the main object we gave it in + // We are setting a reference directly to ourselves. This happens when + // the application has accepted the main object we gave it in // set_instance_info(). This means the application is directly - // manipulating this object as its appRunner.main. In this case, - // we don't actually need to set the reference; instead, we clear - // anything we had set. + // manipulating this object as its appRunner.main. In this case, we don't + // actually need to set the reference; instead, we clear anything we had + // set. nout << "application shares main object\n"; pyobj = NULL; @@ -297,7 +258,7 @@ set_pyobj(P3D_object *pyobj) { // appRunner.main object. Thus, we do need to set the pointer. nout << "application has its own main object\n"; } - + if (_pyobj != pyobj) { P3D_OBJECT_XDECREF(_pyobj); _pyobj = pyobj; @@ -311,26 +272,20 @@ set_pyobj(P3D_object *pyobj) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::get_pyobj -// Access: Public -// Description: Returns the internal pyobj pointer, or NULL if it has -// not yet been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal pyobj pointer, or NULL if it has not yet been set. + */ P3D_object *P3DMainObject:: get_pyobj() const { return _pyobj; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::apply_properties -// Access: Public -// Description: Applies the locally-set properties onto the indicated -// Python object, but does not store the object. This -// is a one-time copy of the locally-set properties -// (like "coreapiHostUrl" and the like) onto the -// indicated Python object. -//////////////////////////////////////////////////////////////////// +/** + * Applies the locally-set properties onto the indicated Python object, but + * does not store the object. This is a one-time copy of the locally-set + * properties (like "coreapiHostUrl" and the like) onto the indicated Python + * object. + */ void P3DMainObject:: apply_properties(P3D_object *pyobj) { P3DPythonObject *p3dpyobj = NULL; @@ -343,12 +298,11 @@ apply_properties(P3D_object *pyobj) { const string &property_name = (*pi).first; P3D_object *value = (*pi).second; if (p3dpyobj != NULL && P3D_OBJECT_GET_TYPE(value) != P3D_OT_object) { - // If we know we have an actual P3DPythonObject (we really - // expect this), then we can call set_property_insecure() - // directly, because we want to allow setting the initial - // properties even if Javascript has no permissions to write - // into Python. But we don't allow setting objects this way in - // any event. + // If we know we have an actual P3DPythonObject (we really expect this), + // then we can call set_property_insecure() directly, because we want to + // allow setting the initial properties even if Javascript has no + // permissions to write into Python. But we don't allow setting objects + // this way in any event. p3dpyobj->set_property_insecure(property_name, false, value); } else { // Otherwise, we go through the generic interface. @@ -357,39 +311,33 @@ apply_properties(P3D_object *pyobj) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::set_instance -// Access: Public -// Description: Sets a callback pointer to the instance that owns -// this object. When this instance destructs, it clears -// this pointer to NULL. -//////////////////////////////////////////////////////////////////// +/** + * Sets a callback pointer to the instance that owns this object. When this + * instance destructs, it clears this pointer to NULL. + */ void P3DMainObject:: set_instance(P3DInstance *inst) { if (_inst != NULL) { - // Save the game log filename of the instance just before it goes - // away, in case JavaScript asks for it later. + // Save the game log filename of the instance just before it goes away, in + // case JavaScript asks for it later. _game_log_pathname = _inst->get_log_pathname(); } _inst = inst; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call_play -// Access: Private -// Description: Starts the process remotely, as if the play button -// had been clicked. If the application has not yet -// been validated, this pops up the validation dialog. -// -// Only applicable if the application was in the ready -// state, or the unauth state. Returns true if the -// application is now started, false otherwise. -// -// This may be invoked from the unauth state only once. -// If the user chooses not to authorize the plugin at -// that time, it may not be invoked automatically again. -//////////////////////////////////////////////////////////////////// +/** + * Starts the process remotely, as if the play button had been clicked. If + * the application has not yet been validated, this pops up the validation + * dialog. + * + * Only applicable if the application was in the ready state, or the unauth + * state. Returns true if the application is now started, false otherwise. + * + * This may be invoked from the unauth state only once. If the user chooses + * not to authorize the plugin at that time, it may not be invoked + * automatically again. + */ P3D_object *P3DMainObject:: call_play(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -397,33 +345,31 @@ call_play(P3D_object *params[], int num_params) { return inst_mgr->new_bool_object(false); } - // I guess there's no harm in allowing JavaScript to call play(), - // with or without explicit scripting authorization. + // I guess there's no harm in allowing JavaScript to call play(), with or + // without explicit scripting authorization. nout << "play() called from JavaScript\n"; if (!_inst->is_trusted()) { - // Requires authorization. We allow this only once; beyond that, - // and you're only annoying the user. + // Requires authorization. We allow this only once; beyond that, and + // you're only annoying the user. if (!_unauth_play) { _unauth_play = true; _inst->splash_button_clicked_main_thread(); } } else if (!_inst->is_started()) { - // We allow calling play() from a ready state without limit, but - // probably only once will be necessary. + // We allow calling play() from a ready state without limit, but probably + // only once will be necessary. _inst->splash_button_clicked_main_thread(); } - + return inst_mgr->new_bool_object(_inst->is_started()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call_read_game_log -// Access: Private -// Description: Reads the entire logfile as a string, and returns it -// to the calling JavaScript process. -//////////////////////////////////////////////////////////////////// +/** + * Reads the entire logfile as a string, and returns it to the calling + * JavaScript process. + */ P3D_object *P3DMainObject:: call_read_game_log(P3D_object *params[], int num_params) { if (_inst != NULL) { @@ -432,8 +378,7 @@ call_read_game_log(P3D_object *params[], int num_params) { } if (!_game_log_pathname.empty()) { - // The instance has already finished, but we saved its log - // filename. + // The instance has already finished, but we saved its log filename. return read_log(_game_log_pathname, params, num_params); } @@ -443,12 +388,10 @@ call_read_game_log(P3D_object *params[], int num_params) { return inst_mgr->new_undefined_object(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call_read_system_log -// Access: Private -// Description: As above, but reads the system log, the logfile for -// the installation process. -//////////////////////////////////////////////////////////////////// +/** + * As above, but reads the system log, the logfile for the installation + * process. + */ P3D_object *P3DMainObject:: call_read_system_log(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -457,13 +400,10 @@ call_read_system_log(P3D_object *params[], int num_params) { return read_log(log_pathname, params, num_params); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call_read_log -// Access: Private -// Description: Reads a named logfile. The filename must end -// in ".log" and must not contain any slashes or colons -// (it must be found within the log directory). -//////////////////////////////////////////////////////////////////// +/** + * Reads a named logfile. The filename must end in ".log" and must not + * contain any slashes or colons (it must be found within the log directory). + */ P3D_object *P3DMainObject:: call_read_log(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -511,38 +451,36 @@ call_read_log(P3D_object *params[], int num_params) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::read_log -// Access: Private -// Description: log-reader meta function that handles reading -// previous log files in addition to the present one -//////////////////////////////////////////////////////////////////// +/** + * log-reader meta function that handles reading previous log files in + * addition to the present one + */ P3D_object *P3DMainObject:: read_log(const string &log_pathname, P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); string log_directory = inst_mgr->get_log_directory(); ostringstream log_data; - // Check the first parameter, if any--if given, it specifies the - // last n bytes to retrieve. + // Check the first parameter, if any--if given, it specifies the last n + // bytes to retrieve. size_t tail_bytes = 0; if (num_params > 0) { tail_bytes = (size_t)max(P3D_OBJECT_GET_INT(params[0]), 0); } - // Check the second parameter, if any--if given, it specifies the - // first n bytes to retrieve. + // Check the second parameter, if any--if given, it specifies the first n + // bytes to retrieve. size_t head_bytes = 0; if (num_params > 1) { head_bytes = (size_t)max(P3D_OBJECT_GET_INT(params[1]), 0); } - // Check the third parameter, if any--if given, it specifies the - // last n bytes to retrieve from previous copies of this file. + // Check the third parameter, if any--if given, it specifies the last n + // bytes to retrieve from previous copies of this file. size_t tail_bytes_prev = 0; if (num_params > 2) { tail_bytes_prev = (size_t)max(P3D_OBJECT_GET_INT(params[2]), 0); } - // Check the fourth parameter, if any--if given, it specifies the - // first n bytes to retrieve from previous copies of this file. + // Check the fourth parameter, if any--if given, it specifies the first n + // bytes to retrieve from previous copies of this file. size_t head_bytes_prev = 0; if (num_params > 3) { head_bytes_prev = (size_t)max(P3D_OBJECT_GET_INT(params[3]), 0); @@ -600,11 +538,9 @@ read_log(const string &log_pathname, P3D_object *params[], int num_params) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::read_log_file -// Access: Private -// Description: The generic log-reader function. -//////////////////////////////////////////////////////////////////// +/** + * The generic log-reader function. + */ void P3DMainObject:: read_log_file(const string &log_pathname, size_t tail_bytes, size_t head_bytes, @@ -717,22 +653,19 @@ read_log_file(const string &log_pathname, log_data << " " << "(" << log_leafname << ")" << "\n"; } - // Render log file footer to log_data - //log_data << "======================================="; - //log_data << "=======================================" << "\n"; + // Render log file footer to log_data log_data << + // "======================================="; log_data << + // "=======================================" << "\n"; // cleanup delete[] buffer; buffer = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMainObject::call_uninstall -// Access: Private -// Description: Implements the uninstall() plugin method, which -// removes all Panda installed files for a particular -// host, or referenced by a particular p3d file. -//////////////////////////////////////////////////////////////////// +/** + * Implements the uninstall() plugin method, which removes all Panda installed + * files for a particular host, or referenced by a particular p3d file. + */ P3D_object *P3DMainObject:: call_uninstall(P3D_object *params[], int num_params) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); diff --git a/direct/src/plugin/p3dMainObject.h b/direct/src/plugin/p3dMainObject.h index bb5008f850..7ed634c44c 100644 --- a/direct/src/plugin/p3dMainObject.h +++ b/direct/src/plugin/p3dMainObject.h @@ -1,16 +1,15 @@ -// Filename: p3dMainObject.h -// Created by: drose (10Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dMainObject.h + * @author drose + * @date 2009-07-10 + */ #ifndef P3DMAINOBJECT_H #define P3DMAINOBJECT_H @@ -23,23 +22,18 @@ class P3DSession; class P3DInstance; -//////////////////////////////////////////////////////////////////// -// Class : P3DMainObject -// Description : This corresponds to the "main" object exposed by a -// particular instance, as returned by -// P3DInstance::get_panda_script_object(). This object -// corresponds to the appRunner.main object in Python, -// and the document.pluginobject.main object in -// JavaScript. -// -// This is mostly a wrapper around a P3DPythonObject -// pointer, and therefore functions like any other -// P3DPythonObject; but it also handles the special case -// of being available before Python has been started; -// and it furthermore reports properties that are -// generated directly by the core API (like -// downloadProgress and such). -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to the "main" object exposed by a particular instance, as + * returned by P3DInstance::get_panda_script_object(). This object + * corresponds to the appRunner.main object in Python, and the + * document.pluginobject.main object in JavaScript. + * + * This is mostly a wrapper around a P3DPythonObject pointer, and therefore + * functions like any other P3DPythonObject; but it also handles the special + * case of being available before Python has been started; and it furthermore + * reports properties that are generated directly by the core API (like + * downloadProgress and such). + */ class P3DMainObject : public P3DObject { public: P3DMainObject(); @@ -74,10 +68,10 @@ private: P3D_object *call_read_game_log(P3D_object *params[], int num_params); P3D_object *call_read_system_log(P3D_object *params[], int num_params); P3D_object *call_read_log(P3D_object *params[], int num_params); - P3D_object *read_log(const string &log_pathname, + P3D_object *read_log(const string &log_pathname, P3D_object *params[], int num_params); - void read_log_file(const string &log_pathname, - size_t tail_bytes, size_t head_bytes, + void read_log_file(const string &log_pathname, + size_t tail_bytes, size_t head_bytes, ostringstream &log_data); P3D_object *call_uninstall(P3D_object *params[], int num_params); @@ -85,16 +79,14 @@ private: P3D_object *_pyobj; P3DInstance *_inst; - bool _unauth_play; + bool _unauth_play; string _game_log_pathname; - // This map is used to store properties and retrieve until - // set_pyobj() is called for the firs ttime. At that point, the - // properties stored here are transferred down to the internal - // PyObject. + // This map is used to store properties and retrieve until set_pyobj() is + // called for the firs ttime. At that point, the properties stored here are + // transferred down to the internal PyObject. typedef map Properties; Properties _properties; }; #endif - diff --git a/direct/src/plugin/p3dMultifileReader.I b/direct/src/plugin/p3dMultifileReader.I index abcb6a0983..eb072e0a3b 100644 --- a/direct/src/plugin/p3dMultifileReader.I +++ b/direct/src/plugin/p3dMultifileReader.I @@ -1,33 +1,27 @@ -// Filename: p3dMultifileReader.I -// Created by: drose (15Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dMultifileReader.I + * @author drose + * @date 2009-06-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::is_open -// Access: Public -// Description: Returns true if the reader is open, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader is open, false otherwise. + */ inline bool P3DMultifileReader:: is_open() const { return _is_open; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::read_uint16 -// Access: Private -// Description: Extracts an unsigned short from the file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned short from the file. + */ inline unsigned int P3DMultifileReader:: read_uint16() { unsigned int a = _in.get(); @@ -35,11 +29,9 @@ read_uint16() { return (b << 8) | a; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::read_uint32 -// Access: Private -// Description: Extracts an unsigned long from the file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned long from the file. + */ inline unsigned int P3DMultifileReader:: read_uint32() { unsigned int a = _in.get(); @@ -49,47 +41,38 @@ read_uint32() { return (d << 24) | (c << 16) | (b << 8) | a; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::get_last_byte_pos -// Access: Public -// Description: Returns the byte position within the Multifile of the -// last byte that contributes to this Subfile, either in -// the index record or in the subfile data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the byte position within the Multifile of the last byte that + * contributes to this Subfile, either in the index record or in the subfile + * data. + */ inline size_t P3DMultifileReader::Subfile:: get_last_byte_pos() const { return max(_index_start + _index_length, _data_start + _data_length) - 1; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::CertRecord::Constructor -// Access: Public -// Description: Ownership of the X509 object is passed into the -// CertRecord; it will be freed when the CertRecord -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * Ownership of the X509 object is passed into the CertRecord; it will be + * freed when the CertRecord destructs. + */ inline P3DMultifileReader::CertRecord:: CertRecord(X509 *cert) : _cert(cert) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::CertRecord::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DMultifileReader::CertRecord:: CertRecord(const P3DMultifileReader::CertRecord ©) : _cert(X509_dup(copy._cert)) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::CertRecord::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DMultifileReader::CertRecord:: ~CertRecord() { X509_free(_cert); diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index 4ec537ab50..2ab529f887 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -1,16 +1,15 @@ -// Filename: p3dMultifileReader.cxx -// Created by: drose (15Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dMultifileReader.cxx + * @author drose + * @date 2009-06-15 + */ #include "p3dMultifileReader.h" #include "p3dPackage.h" @@ -24,37 +23,32 @@ #include #endif -// This sequence of bytes begins each Multifile to identify it as a -// Multifile. +// This sequence of bytes begins each Multifile to identify it as a Multifile. const char P3DMultifileReader::_header[] = "pmf\0\n\r"; const size_t P3DMultifileReader::_header_size = 6; const int P3DMultifileReader::_current_major_ver = 1; const int P3DMultifileReader::_current_minor_ver = 1; -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DMultifileReader:: P3DMultifileReader() { _is_open = false; _read_offset = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::open_read -// Access: Public -// Description: Opens the indicated file for reading. Returns true -// on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated file for reading. Returns true on success, false on + * failure. + */ bool P3DMultifileReader:: open_read(const string &pathname, const int &offset) { if (_is_open) { close(); } - + _read_offset = offset; if (!read_header(pathname)) { return false; @@ -64,38 +58,32 @@ open_read(const string &pathname, const int &offset) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::close -// Access: Public -// Description: Closes the previously-opened file. -//////////////////////////////////////////////////////////////////// +/** + * Closes the previously-opened file. + */ void P3DMultifileReader:: close() { _in.close(); _is_open = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::extract_all -// Access: Public -// Description: Reads the multifile, and extracts all the expected -// extractable components within it to the indicated -// directory. Returns true on success, false on -// failure. -// -// Upates the "step" object with the progress through -// this operation. -//////////////////////////////////////////////////////////////////// +/** + * Reads the multifile, and extracts all the expected extractable components + * within it to the indicated directory. Returns true on success, false on + * failure. + * + * Upates the "step" object with the progress through this operation. + */ bool P3DMultifileReader:: -extract_all(const string &to_dir, P3DPackage *package, +extract_all(const string &to_dir, P3DPackage *package, P3DPackage::InstallStepThreaded *step) { assert(_is_open); if (_in.fail()) { return false; } - // Now walk through all of the files, and extract only the ones we - // expect to encounter. + // Now walk through all of the files, and extract only the ones we expect to + // encounter. Subfiles::iterator si; for (si = _subfiles.begin(); si != _subfiles.end(); ++si) { const Subfile &s = (*si); @@ -128,15 +116,15 @@ extract_all(const string &to_dir, P3DPackage *package, } out.close(); - // Check that the file was extracted correctly (and also set the - // correct timestamp). + // Check that the file was extracted correctly (and also set the correct + // timestamp). if (!file.full_verify(to_dir)) { nout << "After extracting, " << s._filename << " is still incorrect.\n"; return false; } - // Be sure to set execute permissions on the file, in case it's a - // program or something. + // Be sure to set execute permissions on the file, in case it's a program + // or something. chmod(output_pathname.c_str(), 0555); if (step != NULL && package != NULL) { @@ -147,13 +135,10 @@ extract_all(const string &to_dir, P3DPackage *package, return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::extract_one -// Access: Public -// Description: Reads the multifile, and extracts only the named -// component to the indicated stream. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the multifile, and extracts only the named component to the indicated + * stream. Returns true on success, false on failure. + */ bool P3DMultifileReader:: extract_one(ostream &out, const string &filename) { assert(_is_open); @@ -174,22 +159,17 @@ extract_one(ostream &out, const string &filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::get_num_signatures -// Access: Published -// Description: Returns the number of matching signatures found on -// the Multifile. These signatures may be iterated via -// get_signature() and related methods. -// -// A signature on this list is guaranteed to match the -// Multifile contents, proving that the Multifile has -// been unmodified since the signature was applied. -// However, this does not guarantee that the certificate -// itself is actually from who it says it is from; only -// that it matches the Multifile contents. See -// validate_signature_certificate() to authenticate a -// particular certificate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of matching signatures found on the Multifile. These + * signatures may be iterated via get_signature() and related methods. + * + * A signature on this list is guaranteed to match the Multifile contents, + * proving that the Multifile has been unmodified since the signature was + * applied. However, this does not guarantee that the certificate itself is + * actually from who it says it is from; only that it matches the Multifile + * contents. See validate_signature_certificate() to authenticate a + * particular certificate. + */ int P3DMultifileReader:: get_num_signatures() const { if (_is_open) { @@ -199,12 +179,10 @@ get_num_signatures() const { return _signatures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::get_signature -// Access: Published -// Description: Returns the nth signature found on the Multifile. -// See the comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth signature found on the Multifile. See the comments in + * get_num_signatures(). + */ const P3DMultifileReader::CertChain &P3DMultifileReader:: get_signature(int n) const { static CertChain error_chain; @@ -212,13 +190,10 @@ get_signature(int n) const { return _signatures[n]; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::read_header -// Access: Private -// Description: Opens the named multifile and reads the header -// information and index, returning true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named multifile and reads the header information and index, + * returning true on success, false on failure. + */ bool P3DMultifileReader:: read_header(const string &pathname) { assert(!_is_open); @@ -242,12 +217,11 @@ read_header(const string &pathname) { char this_header[_header_size]; _in.seekg(_read_offset); - // Here's a special case: if the multifile begins with a hash - // character, then we continue reading and discarding lines of ASCII - // text, until we come across a nonempty line that does not begin - // with a hash character. This allows a P3D application (which is a - // multifile) to be run directly on the command line on Unix-based - // systems. + // Here's a special case: if the multifile begins with a hash character, + // then we continue reading and discarding lines of ASCII text, until we + // come across a nonempty line that does not begin with a hash character. + // This allows a P3D application (which is a multifile) to be run directly + // on the command line on Unix-based systems. int ch = _in.get(); if (ch == '#') { @@ -300,13 +274,11 @@ read_header(const string &pathname) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::read_index -// Access: Private -// Description: Assuming the file stream is positioned at the first -// record, reads all of the records into the _subfiles -// list. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the file stream is positioned at the first record, reads all of + * the records into the _subfiles list. Returns true on success, false on + * failure. + */ bool P3DMultifileReader:: read_index() { _last_data_byte = 0; @@ -325,7 +297,7 @@ read_index() { // Skip over the uncompressed length. read_uint32(); } - + s._timestamp = read_uint32(); size_t name_length = read_uint16(); char *buffer = new char[name_length]; @@ -364,20 +336,17 @@ read_index() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::extract_subfile -// Access: Private -// Description: Extracts the indicated subfile and writes it to the -// indicated stream. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated subfile and writes it to the indicated stream. + * Returns true on success, false on failure. + */ bool P3DMultifileReader:: extract_subfile(ostream &out, const Subfile &s) { _in.seekg(s._data_start + _read_offset); static const streamsize buffer_size = 4096; char buffer[buffer_size]; - + streamsize remaining_data = s._data_length; _in.read(buffer, min(buffer_size, remaining_data)); streamsize count = _in.gcount(); @@ -387,7 +356,7 @@ extract_subfile(ostream &out, const Subfile &s) { _in.read(buffer, min(buffer_size, remaining_data)); count = _in.gcount(); } - + if (remaining_data != 0) { nout << "Unable to extract " << s._filename << "\n"; return false; @@ -397,18 +366,14 @@ extract_subfile(ostream &out, const Subfile &s) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DMultifileReader::check_signatures -// Access: Private -// Description: Walks through the list of _cert_special entries in -// the Multifile, moving any valid signatures found to -// _signatures. After this call, _cert_special will be -// empty. -// -// This does not check the validity of the certificates -// themselves. It only checks that they correctly sign -// the Multifile contents. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the list of _cert_special entries in the Multifile, moving + * any valid signatures found to _signatures. After this call, _cert_special + * will be empty. + * + * This does not check the validity of the certificates themselves. It only + * checks that they correctly sign the Multifile contents. + */ void P3DMultifileReader:: check_signatures() { Subfiles::iterator pi; @@ -441,8 +406,8 @@ check_signatures() { return; } - // Now convert each of the certificates to an X509 object, and - // store it in our CertChain. + // Now convert each of the certificates to an X509 object, and store it in + // our CertChain. CertChain chain; EVP_PKEY *pkey = NULL; if (buffer_size > 0) { @@ -467,11 +432,11 @@ check_signatures() { } delete[] buffer; - + if (!chain.empty()) { pkey = X509_get_pubkey(chain[0]._cert); } - + if (pkey != NULL) { EVP_MD_CTX *md_ctx; #if OPENSSL_VERSION_NUMBER >= 0x00907000L @@ -497,10 +462,10 @@ check_signatures() { count = _in.gcount(); } assert(bytes_remaining == (streampos)0); - + // Now check that the signature matches the hash. - int verify_result = - EVP_VerifyFinal(md_ctx, (unsigned char *)sig, + int verify_result = + EVP_VerifyFinal(md_ctx, (unsigned char *)sig, sig_size, pkey); if (verify_result == 1) { // The signature matches; save the certificate and its chain. diff --git a/direct/src/plugin/p3dMultifileReader.h b/direct/src/plugin/p3dMultifileReader.h index 80253997d3..64a788c263 100644 --- a/direct/src/plugin/p3dMultifileReader.h +++ b/direct/src/plugin/p3dMultifileReader.h @@ -1,16 +1,15 @@ -// Filename: p3dMultifileReader.h -// Created by: drose (15Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dMultifileReader.h + * @author drose + * @date 2009-06-15 + */ #ifndef P3DMULTIFILEREADER_H #define P3DMULTIFILEREADER_H @@ -19,14 +18,12 @@ #include "p3dInstanceManager.h" // for openssl #include "p3dPackage.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DMultifileReader -// Description : A way-simple implementation of Panda's multifile -// reader. See panda/src/express/multifile.cxx for a -// full description of the binary format. This -// implementation doesn't support per-subfile -// compression or encryption. -//////////////////////////////////////////////////////////////////// +/** + * A way-simple implementation of Panda's multifile reader. See + * panda/src/express/multifile.cxx for a full description of the binary + * format. This implementation doesn't support per-subfile compression or + * encryption. + */ class P3DMultifileReader { public: P3DMultifileReader(); @@ -34,7 +31,7 @@ public: inline bool is_open() const; void close(); - bool extract_all(const string &to_dir, P3DPackage *package, + bool extract_all(const string &to_dir, P3DPackage *package, P3DPackage::InstallStepThreaded *step); bool extract_one(ostream &out, const string &filename); diff --git a/direct/src/plugin/p3dNoneObject.cxx b/direct/src/plugin/p3dNoneObject.cxx index 04d3f618af..0245b61174 100644 --- a/direct/src/plugin/p3dNoneObject.cxx +++ b/direct/src/plugin/p3dNoneObject.cxx @@ -1,55 +1,45 @@ -// Filename: p3dNoneObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dNoneObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dNoneObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DNoneObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DNoneObject:: P3DNoneObject() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DNoneObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DNoneObject:: get_type() { return P3D_OT_none; } -//////////////////////////////////////////////////////////////////// -// Function: P3DNoneObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DNoneObject:: get_bool() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DNoneObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DNoneObject:: make_string(string &value) { value = "None"; diff --git a/direct/src/plugin/p3dNoneObject.h b/direct/src/plugin/p3dNoneObject.h index 657d35400d..e0272f04cb 100644 --- a/direct/src/plugin/p3dNoneObject.h +++ b/direct/src/plugin/p3dNoneObject.h @@ -1,16 +1,15 @@ -// Filename: p3dNoneObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dNoneObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DNONEOBJECT_H #define P3DNONEOBJECT_H @@ -18,11 +17,10 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DNoneObject -// Description : An object type that contains no value, similar to -// Python's None type, or JavaScript's null type. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains no value, similar to Python's None type, or + * JavaScript's null type. + */ class P3DNoneObject : public P3DObject { public: P3DNoneObject(); @@ -34,4 +32,3 @@ public: }; #endif - diff --git a/direct/src/plugin/p3dObject.I b/direct/src/plugin/p3dObject.I index 7941e68468..2911760832 100644 --- a/direct/src/plugin/p3dObject.I +++ b/direct/src/plugin/p3dObject.I @@ -1,23 +1,19 @@ -// Filename: p3dObject.I -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dObject.I + * @author drose + * @date 2009-06-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DObject:: P3DObject() { _class = &_object_class; @@ -26,11 +22,9 @@ P3DObject() { _ref_count = 1; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DObject:: P3DObject(const P3DObject ©) { assert(copy._class == &_object_class); diff --git a/direct/src/plugin/p3dObject.cxx b/direct/src/plugin/p3dObject.cxx index 612fcd0603..5f17ee3e2e 100644 --- a/direct/src/plugin/p3dObject.cxx +++ b/direct/src/plugin/p3dObject.cxx @@ -1,16 +1,15 @@ -// Filename: p3dObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dObject.h" #include "p3dBoolObject.h" @@ -20,21 +19,20 @@ #include "p3dInstanceManager.h" #include // strncpy -// The following functions are C-style wrappers around the below -// P3DObject virtual methods; they are defined to allow us to create -// the C-style P3D_class_definition method table to store in the -// P3D_object structure. +// The following functions are C-style wrappers around the below P3DObject +// virtual methods; they are defined to allow us to create the C-style +// P3D_class_definition method table to store in the P3D_object structure. static void object_finish(P3D_object *object) { delete (P3DObject *)object; } -static P3D_object_type +static P3D_object_type object_get_type(P3D_object *object) { return ((P3DObject *)object)->get_type(); } -static bool +static bool object_get_bool(P3D_object *object) { return ((P3DObject *)object)->get_bool(); } @@ -44,17 +42,17 @@ object_get_int(P3D_object *object) { return ((P3DObject *)object)->get_int(); } -static double +static double object_get_float(P3D_object *object) { return ((P3DObject *)object)->get_float(); } -static int +static int object_get_string(P3D_object *object, char *buffer, int buffer_length) { return ((P3DObject *)object)->get_string(buffer, buffer_length); } -static int +static int object_get_repr(P3D_object *object, char *buffer, int buffer_length) { return ((P3DObject *)object)->get_repr(buffer, buffer_length); } @@ -105,26 +103,24 @@ P3D_class_definition P3DObject::_object_class = { &object_eval, }; -// The next functions are used to construct the generic -// P3D_class_definition class returned by P3D_make_class_definition(). -// These are pointers to no-op functions, which the host may or may -// not choose to override. +// The next functions are used to construct the generic P3D_class_definition +// class returned by P3D_make_class_definition(). These are pointers to no-op +// functions, which the host may or may not choose to override. static void generic_finish(P3D_object *object) { - // You must override finish(), though, otherwise it's a leak. The - // core API has no idea how to delete your object. + // You must override finish(), though, otherwise it's a leak. The core API + // has no idea how to delete your object. nout << "Warning! default object_finish() method does nothing; object will leak.\n"; } -static P3D_object_type +static P3D_object_type generic_get_type(P3D_object *object) { - // We assume anyone going through the trouble of subclassing this - // will want to return an object, not one of the other fundamental - // types. + // We assume anyone going through the trouble of subclassing this will want + // to return an object, not one of the other fundamental types. return P3D_OT_object; } -static bool +static bool generic_get_bool(P3D_object *object) { return false; } @@ -134,17 +130,17 @@ generic_get_int(P3D_object *object) { return 0; } -static double +static double generic_get_float(P3D_object *object) { return 0.0; } -static int +static int generic_get_string(P3D_object *object, char *buffer, int buffer_length) { return 0; } -static int +static int generic_get_repr(P3D_object *object, char *buffer, int buffer_length) { return 0; } @@ -191,48 +187,36 @@ P3D_class_definition P3DObject::_generic_class = { &generic_eval, }; -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DObject:: ~P3DObject() { assert(_ref_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DObject:: get_int() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_float -// Access: Public, Virtual -// Description: Returns the object value coerced to a floating-point -// value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a floating-point value, if possible. + */ double P3DObject:: get_float() { return get_int(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_string -// Access: Public -// Description: Stores a string that represents the object value in -// the indicated buffer; a null character is included if -// there is space. Returns the number of characters -// needed in the output (which might be more than the -// actual number of characters stored if buffer_length -// was too small). -//////////////////////////////////////////////////////////////////// +/** + * Stores a string that represents the object value in the indicated buffer; a + * null character is included if there is space. Returns the number of + * characters needed in the output (which might be more than the actual number + * of characters stored if buffer_length was too small). + */ int P3DObject:: get_string(char *buffer, int buffer_length) { string result; @@ -241,12 +225,10 @@ get_string(char *buffer, int buffer_length) { return (int)result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_repr -// Access: Public -// Description: Returns a user-friendly representation of the object, -// similar to get_string(), above. -//////////////////////////////////////////////////////////////////// +/** + * Returns a user-friendly representation of the object, similar to + * get_string(), above. + */ int P3DObject:: get_repr(char *buffer, int buffer_length) { ostringstream strm; @@ -256,78 +238,59 @@ get_repr(char *buffer, int buffer_length) { return (int)result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_property -// Access: Public, Virtual -// Description: Returns the named property element in the object. The -// return value is a new-reference P3D_object, or NULL -// on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * new-reference P3D_object, or NULL on error. + */ P3D_object *P3DObject:: get_property(const string &property) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_property -// Access: Public, Virtual -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool P3DObject:: set_property(const string &property, bool needs_response, P3D_object *value) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::has_method -// Access: Public, Virtual -// Description: Returns true if the named method exists on this -// object, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named method exists on this object, false otherwise. + */ bool P3DObject:: has_method(const string &method_name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::call -// Access: Public, Virtual -// Description: Invokes the named method on the object, passing the -// indicated parameters. If the method name is empty, -// invokes the object itself. -// -// If needs_response is true, the return value is a -// new-reference P3D_object on success, or NULL on -// failure. If needs_response is false, the return -// value is always NULL, and there is no way to -// determine success or failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes the named method on the object, passing the indicated parameters. + * If the method name is empty, invokes the object itself. + * + * If needs_response is true, the return value is a new-reference P3D_object + * on success, or NULL on failure. If needs_response is false, the return + * value is always NULL, and there is no way to determine success or failure. + */ P3D_object *P3DObject:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::eval -// Access: Public, Virtual -// Description: Evaluates an arbitrary JavaScript expression. None -// of the P3DObject classes implement this. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates an arbitrary JavaScript expression. None of the P3DObject + * classes implement this. + */ P3D_object *P3DObject:: eval(const string &expression) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::output -// Access: Public, Virtual -// Description: Writes a formatted representation of the value to the -// indicated string. This is intended for developer -// assistance. -//////////////////////////////////////////////////////////////////// +/** + * Writes a formatted representation of the value to the indicated string. + * This is intended for developer assistance. + */ void P3DObject:: output(ostream &out) { string value; @@ -335,65 +298,50 @@ output(ostream &out) { out << value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::fill_xml -// Access: Public, Virtual -// Description: If this object has a valid XML representation for the -// indicated session (that hasn't already been -// implemented by the generic code in P3DSession), this -// method will apply it to the indicated "value" element -// and return true. Otherwise, this method will leave -// the element unchanged and return false. -//////////////////////////////////////////////////////////////////// +/** + * If this object has a valid XML representation for the indicated session + * (that hasn't already been implemented by the generic code in P3DSession), + * this method will apply it to the indicated "value" element and return true. + * Otherwise, this method will leave the element unchanged and return false. + */ bool P3DObject:: fill_xml(TiXmlElement *xvalue, P3DSession *session) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_object_array -// Access: Public, Virtual -// Description: Returns a pointer to the array of objects represented -// by this object, if any, or NULL if the object does -// not represent an array of objects. This may also -// return NULL for a zero-length array; use -// get_object_array_size() to differentiate. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the array of objects represented by this object, if + * any, or NULL if the object does not represent an array of objects. This + * may also return NULL for a zero-length array; use get_object_array_size() + * to differentiate. + */ P3D_object **P3DObject:: get_object_array() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_object_array_size -// Access: Public, Virtual -// Description: Returns the number of elements in the array returned -// by get_object_array(), or -1 if this object does not -// representan array of objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the array returned by get_object_array(), + * or -1 if this object does not representan array of objects. + */ int P3DObject:: get_object_array_size() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::as_python_object -// Access: Public, Virtual -// Description: Returns this object, downcast to a P3DPythonObject, -// if it is in fact an object of that type; or NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object, downcast to a P3DPythonObject, if it is in fact an + * object of that type; or NULL if it is not. + */ P3DPythonObject *P3DObject:: as_python_object() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_bool_property -// Access: Public -// Description: Returns the value of the named property, as a -// boolean. Returns 0 if the property does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the named property, as a boolean. Returns 0 if the + * property does not exist. + */ bool P3DObject:: get_bool_property(const string &property) { P3D_object *result = get_property(property); @@ -405,12 +353,9 @@ get_bool_property(const string &property) { return bresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_bool_property -// Access: Public -// Description: Changes the value of the named property to the -// indicated boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value of the named property to the indicated boolean value. + */ void P3DObject:: set_bool_property(const string &property, bool value) { P3D_object *bvalue = new P3DBoolObject(value); @@ -418,12 +363,10 @@ set_bool_property(const string &property, bool value) { P3D_OBJECT_DECREF(bvalue); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_int_property -// Access: Public -// Description: Returns the value of the named property, as an -// integer. Returns 0 if the property does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the named property, as an integer. Returns 0 if the + * property does not exist. + */ int P3DObject:: get_int_property(const string &property) { P3D_object *result = get_property(property); @@ -435,12 +378,9 @@ get_int_property(const string &property) { return iresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_int_property -// Access: Public -// Description: Changes the value of the named property to the -// indicated integer value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value of the named property to the indicated integer value. + */ void P3DObject:: set_int_property(const string &property, int value) { P3D_object *ivalue = new P3DIntObject(value); @@ -448,13 +388,10 @@ set_int_property(const string &property, int value) { P3D_OBJECT_DECREF(ivalue); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_float_property -// Access: Public -// Description: Returns the value of the named property, as a -// floating-point number. Returns 0.0 if the property -// does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the named property, as a floating-point number. + * Returns 0.0 if the property does not exist. + */ double P3DObject:: get_float_property(const string &property) { P3D_object *result = get_property(property); @@ -466,12 +403,10 @@ get_float_property(const string &property) { return fresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_float_property -// Access: Public -// Description: Changes the value of the named property to the -// indicated floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value of the named property to the indicated floating-point + * value. + */ void P3DObject:: set_float_property(const string &property, double value) { P3D_object *fvalue = new P3DFloatObject(value); @@ -479,13 +414,10 @@ set_float_property(const string &property, double value) { P3D_OBJECT_DECREF(fvalue); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::get_string_property -// Access: Public -// Description: Returns the value of the named property, as a -// string. Returns empty string if the property does -// not exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the named property, as a string. Returns empty string + * if the property does not exist. + */ string P3DObject:: get_string_property(const string &property) { P3D_object *result = get_property(property); @@ -503,12 +435,9 @@ get_string_property(const string &property) { return sresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_string_property -// Access: Public -// Description: Changes the value of the named property to the -// indicated string value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value of the named property to the indicated string value. + */ void P3DObject:: set_string_property(const string &property, const string &value) { P3D_object *svalue = new P3DStringObject(value); @@ -516,12 +445,9 @@ set_string_property(const string &property, const string &value) { P3D_OBJECT_DECREF(svalue); } -//////////////////////////////////////////////////////////////////// -// Function: P3DObject::set_undefined_property -// Access: Public -// Description: Changes the value of the named property to the -// undefined value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value of the named property to the undefined value. + */ void P3DObject:: set_undefined_property(const string &property) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); diff --git a/direct/src/plugin/p3dObject.h b/direct/src/plugin/p3dObject.h index 56d5e100a3..0cedd291ad 100644 --- a/direct/src/plugin/p3dObject.h +++ b/direct/src/plugin/p3dObject.h @@ -1,16 +1,15 @@ -// Filename: p3dObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DOBJECT_H #define P3DOBJECT_H @@ -19,14 +18,12 @@ class P3DPythonObject; -//////////////////////////////////////////////////////////////////// -// Class : P3DObject -// Description : The C++ implementation of P3D_value, corresponding -// to a single atomic value that is passed around -// between scripting languages. This is an abstract -// base class; the actual implementations are provided -// by the various specialized classes. -//////////////////////////////////////////////////////////////////// +/** + * The C++ implementation of P3D_value, corresponding to a single atomic value + * that is passed around between scripting languages. This is an abstract + * base class; the actual implementations are provided by the various + * specialized classes. + */ class P3DObject : public P3D_object { protected: inline P3DObject(); @@ -82,14 +79,13 @@ public: #include "p3dObject.I" -// For classes that inherit from P3DObject, above, we can use the -// virtual method to write the output simply. (For classes that -// inherit only from P3D_object, we have to use the generic C method -// defined in p3d_plugin_common.h, a little clumsier.) +// For classes that inherit from P3DObject, above, we can use the virtual +// method to write the output simply. (For classes that inherit only from +// P3D_object, we have to use the generic C method defined in +// p3d_plugin_common.h, a little clumsier.) inline ostream &operator << (ostream &out, P3DObject &value) { value.output(out); return out; } #endif - diff --git a/direct/src/plugin/p3dOsxSplashWindow.I b/direct/src/plugin/p3dOsxSplashWindow.I index f183bb36ed..4778fd40cc 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.I +++ b/direct/src/plugin/p3dOsxSplashWindow.I @@ -1,23 +1,19 @@ -// Filename: p3dOsxSplashWindow.I -// Created by: drose (16Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dOsxSplashWindow.I + * @author drose + * @date 2009-07-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::OsxImageData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DOsxSplashWindow::OsxImageData:: OsxImageData() { _raw_data = NULL; @@ -27,13 +23,10 @@ OsxImageData() { _data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::OsxImageData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DOsxSplashWindow::OsxImageData:: ~OsxImageData() { dump_image(); } - diff --git a/direct/src/plugin/p3dOsxSplashWindow.cxx b/direct/src/plugin/p3dOsxSplashWindow.cxx index 53f9976d4c..2014251149 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.cxx +++ b/direct/src/plugin/p3dOsxSplashWindow.cxx @@ -1,16 +1,15 @@ -// Filename: p3dOsxSplashWindow.cxx -// Created by: drose (16Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dOsxSplashWindow.cxx + * @author drose + * @date 2009-07-16 + */ #include "p3dOsxSplashWindow.h" @@ -27,13 +26,11 @@ #endif #endif -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DOsxSplashWindow:: -P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : +P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { _font_attribs = NULL; @@ -41,17 +38,15 @@ P3DOsxSplashWindow(P3DInstance *inst, bool make_visible) : _progress_known = true; _received_data = 0; _got_wparams = false; - // We have to start with _mouse_active true; firefox doesn't send - // activate events. + // We have to start with _mouse_active true; firefox doesn't send activate + // events. _mouse_active = true; _toplevel_window = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DOsxSplashWindow:: ~P3DOsxSplashWindow() { if (_toplevel_window != NULL) { @@ -65,13 +60,10 @@ P3DOsxSplashWindow:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::set_wparams -// Access: Public, Virtual -// Description: Changes the window parameters, e.g. to resize or -// reposition the window; or sets the parameters for the -// first time, creating the initial window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window parameters, e.g. to resize or reposition the window; or + * sets the parameters for the first time, creating the initial window. + */ void P3DOsxSplashWindow:: set_wparams(const P3DWindowParams &wparams) { P3DSplashWindow::set_wparams(wparams); @@ -84,7 +76,7 @@ set_wparams(const P3DWindowParams &wparams) { Rect r; r.top = _wparams.get_win_y(); r.left = _wparams.get_win_x(); - + // These are the same defaults used by Panda's osxGraphicsWindow. if (r.left == -1) r.left = 10; if (r.top == -1) r.top = 50; @@ -99,12 +91,12 @@ set_wparams(const P3DWindowParams &wparams) { r.right = r.left + _win_width; r.bottom = r.top + _win_height; - WindowAttributes attrib = + WindowAttributes attrib = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute; CreateNewWindow(kDocumentWindowClass, attrib, &r, &_toplevel_window); - + EventHandlerRef application_event_ref_ref1; - EventTypeSpec list1[] = { + EventTypeSpec list1[] = { { kEventClassWindow, kEventWindowDrawContent }, { kEventClassWindow, kEventWindowBoundsChanged }, { kEventClassWindow, kEventWindowClose }, @@ -113,9 +105,9 @@ set_wparams(const P3DWindowParams &wparams) { { kEventClassMouse, kEventMouseMoved }, { kEventClassMouse, kEventMouseDragged }, }; - + EventHandlerUPP gEvtHandler = NewEventHandlerUPP(st_event_callback); - InstallWindowEventHandler(_toplevel_window, gEvtHandler, + InstallWindowEventHandler(_toplevel_window, gEvtHandler, GetEventTypeCount(list1), list1, this, &application_event_ref_ref1); ProcessSerialNumber psn = { 0, kCurrentProcess }; @@ -164,13 +156,10 @@ set_wparams(const P3DWindowParams &wparams) { CFRelease(symbolic_ref); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::set_visible -// Access: Public, Virtual -// Description: Makes the splash window visible or invisible, so as -// not to compete with the embedded Panda window in the -// same space. -//////////////////////////////////////////////////////////////////// +/** + * Makes the splash window visible or invisible, so as not to compete with the + * embedded Panda window in the same space. + */ void P3DOsxSplashWindow:: set_visible(bool visible) { P3DSplashWindow::set_visible(visible); @@ -185,12 +174,10 @@ set_visible(bool visible) { refresh(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::set_image_filename -// Access: Public, Virtual -// Description: Specifies the name of a JPEG image file that is -// displayed in the center of the splash window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a JPEG image file that is displayed in the center of + * the splash window. + */ void P3DOsxSplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { switch (image_placement) { @@ -206,7 +193,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) case IP_button_rollover: load_image(_button_rollover_image, image_filename); break; - + case IP_button_click: load_image(_button_click_image, image_filename); break; @@ -218,23 +205,18 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) refresh(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::set_install_label -// Access: Public, Virtual -// Description: Specifies the text that is displayed above the -// install progress bar. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the text that is displayed above the install progress bar. + */ void P3DOsxSplashWindow:: set_install_label(const string &install_label) { _install_label = install_label; refresh(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::set_install_progress -// Access: Public, Virtual -// Description: Moves the install progress bar from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Moves the install progress bar from 0.0 to 1.0. + */ void P3DOsxSplashWindow:: set_install_progress(double install_progress, bool is_progress_known, size_t received_data) { @@ -246,7 +228,7 @@ set_install_progress(double install_progress, refresh(); } } else { - if ((int)(received_data * _unknown_progress_rate) != + if ((int)(received_data * _unknown_progress_rate) != (int)(_received_data * _unknown_progress_rate)) { refresh(); } @@ -257,13 +239,10 @@ set_install_progress(double install_progress, _received_data = received_data; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::handle_event -// Access: Public, Virtual -// Description: Deals with the event callback from the OS window -// system. Returns true if the event is handled, false -// if ignored. -//////////////////////////////////////////////////////////////////// +/** + * Deals with the event callback from the OS window system. Returns true if + * the event is handled, false if ignored. + */ bool P3DOsxSplashWindow:: handle_event(const P3D_event_data &event) { bool retval = false; @@ -279,76 +258,71 @@ handle_event(const P3D_event_data &event) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::refresh -// Access: Protected, Virtual -// Description: Requests that the window will be repainted. -//////////////////////////////////////////////////////////////////// +/** + * Requests that the window will be repainted. + */ void P3DOsxSplashWindow:: refresh() { if (!_visible) { return; } if (_toplevel_window != NULL) { - Rect r = { 0, 0, _win_height, _win_width }; + Rect r = { 0, 0, _win_height, _win_width }; InvalWindowRect(_toplevel_window, &r); - + } else { _inst->request_refresh(); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::paint_window -// Access: Private -// Description: Redraws the current splash window. -//////////////////////////////////////////////////////////////////// +/** + * Redraws the current splash window. + */ void P3DOsxSplashWindow:: paint_window() { if (!_visible) { return; } - if (_toplevel_window != NULL || + if (_toplevel_window != NULL || _wparams.get_parent_window()._window_handle_type == P3D_WHT_osx_port) { - // The old QuickDraw-style window handle. We use - // CreateCGContextForPort() to map this to the new - // CoreGraphics-style. + // The old QuickDraw-style window handle. We use CreateCGContextForPort() + // to map this to the new CoreGraphics-style. GrafPtr out_port = NULL; if (_toplevel_window != NULL) { GetPort(&out_port); - + } else { const P3D_window_handle &handle = _wparams.get_parent_window(); assert(handle._window_handle_type == P3D_WHT_osx_port); out_port = handle._handle._osx_port._port; } - + CGContextRef context; OSStatus err = CreateCGContextForPort(out_port, &context); if (err != noErr) { nout << "Couldn't create CG context\n"; return; } - - // Adjust for any SetOrigin calls on out_port + + // Adjust for any SetOrigin calls on out_port SyncCGContextOriginWithPort(context, out_port); - - // Move the CG origin to the upper left of the port + + // Move the CG origin to the upper left of the port Rect port_rect; GetPortBounds(out_port, &port_rect); CGContextTranslateCTM(context, 0, (float)(port_rect.bottom - port_rect.top)); - - // Flip the y axis so that positive Y points down + + // Flip the y axis so that positive Y points down CGContextScaleCTM(context, 1.0, -1.0); - + paint_window_osx_cgcontext(context); // We need to synchronize, or we don't see the update every frame. CGContextSynchronize(context); CGContextRelease(context); - + } else { // The new CoreGraphics-style window handle. We can draw to this // directly. @@ -361,12 +335,9 @@ paint_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::paint_window_osx_cgcontext -// Access: Private -// Description: Redraws the current splash window, using the new -// CoreGraphics interface. -//////////////////////////////////////////////////////////////////// +/** + * Redraws the current splash window, using the new CoreGraphics interface. + */ void P3DOsxSplashWindow:: paint_window_osx_cgcontext(CGContextRef context) { // Clear the whole region to the background color before beginning. @@ -401,19 +372,16 @@ paint_window_osx_cgcontext(CGContextRef context) { break; } - // Draw the progress bar. We don't draw this bar at all unless we - // have nonzero progress. + // Draw the progress bar. We don't draw this bar at all unless we have + // nonzero progress. if (!_progress_known || _install_progress != 0.0) { paint_progress_bar(context); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::handle_event_osx_event_record -// Access: Private -// Description: Responds to the deprecated Carbon event types in Mac -// OSX. -//////////////////////////////////////////////////////////////////// +/** + * Responds to the deprecated Carbon event types in Mac OSX. + */ bool P3DOsxSplashWindow:: handle_event_osx_event_record(const P3D_event_data &event) { assert(event._event_type == P3D_ET_osx_event_record); @@ -421,15 +389,14 @@ handle_event_osx_event_record(const P3D_event_data &event) { Point pt = er->where; - // Need to ensure we have the correct port set, in order to - // convert the mouse coordinates successfully via - // GlobalToLocal(). + // Need to ensure we have the correct port set, in order to convert the + // mouse coordinates successfully via GlobalToLocal(). const P3D_window_handle &handle = _wparams.get_parent_window(); if (handle._window_handle_type == P3D_WHT_osx_port) { GrafPtr out_port = handle._handle._osx_port._port; GrafPtr port_save = NULL; Boolean port_changed = QDSwapPort(out_port, &port_save); - + GlobalToLocal(&pt); if (port_changed) { @@ -437,8 +404,8 @@ handle_event_osx_event_record(const P3D_event_data &event) { } } else if (handle._window_handle_type == P3D_WHT_osx_cgcontext) { - // First, convert the coordinates from screen coordinates to - // browser window coordinates. + // First, convert the coordinates from screen coordinates to browser + // window coordinates. WindowRef window = handle._handle._osx_cgcontext._window; CGPoint cgpt = { pt.h, pt.v }; HIPointConvert(&cgpt, kHICoordSpaceScreenPixel, NULL, @@ -448,7 +415,7 @@ handle_event_osx_event_record(const P3D_event_data &event) { pt.h = (short)(cgpt.x - _wparams.get_win_x()); pt.v = (short)(cgpt.y - _wparams.get_win_y()); } - + switch (er->what) { case updateEvt: paint_window(); @@ -477,12 +444,9 @@ handle_event_osx_event_record(const P3D_event_data &event) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::handle_event_osx_cocoa -// Access: Private -// Description: Responds to the new Cocoa event types in Mac -// OSX. -//////////////////////////////////////////////////////////////////// +/** + * Responds to the new Cocoa event types in Mac OSX. + */ bool P3DOsxSplashWindow:: handle_event_osx_cocoa(const P3D_event_data &event) { assert(event._event_type == P3D_ET_osx_cocoa); @@ -520,11 +484,9 @@ handle_event_osx_cocoa(const P3D_event_data &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::load_image -// Access: Private -// Description: Loads the named image file into an OsxImageData object. -//////////////////////////////////////////////////////////////////// +/** + * Loads the named image file into an OsxImageData object. + */ void P3DOsxSplashWindow:: load_image(OsxImageData &image, const string &image_filename) { image.dump_image(); @@ -533,10 +495,9 @@ load_image(OsxImageData &image, const string &image_filename) { return; } - // Now we need to copy from the RGB (or RGBA) source image into the - // BGRA target image. We also flip the image upside-down here to - // compensate for the upside-down vertical scale on - // CGContextScaleCTM. + // Now we need to copy from the RGB (or RGBA) source image into the BGRA + // target image. We also flip the image upside-down here to compensate for + // the upside-down vertical scale on CGContextScaleCTM. int row_stride = image._width * image._num_channels; int new_row_stride = image._width * 4; image._raw_data = new char[new_row_stride * image._height]; @@ -575,40 +536,37 @@ load_image(OsxImageData &image, const string &image_filename) { } image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, image._height * new_row_stride, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); image._image = - CGImageCreate(image._width, image._height, 8, 32, + CGImageCreate(image._width, image._height, 8, 32, new_row_stride, image._color_space, - kCGImageAlphaFirst | kCGBitmapByteOrder32Little, + kCGImageAlphaFirst | kCGBitmapByteOrder32Little, image._provider, NULL, false, kCGRenderingIntentDefault); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::paint_image -// Access: Private -// Description: Draws the indicated image, centered within the -// window. Returns true on success, false if the image -// is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Draws the indicated image, centered within the window. Returns true on + * success, false if the image is not defined. + */ bool P3DOsxSplashWindow:: paint_image(CGContextRef context, const OsxImageData &image) { if (image._image == NULL) { return false; } - + // Determine the relative size of image and window. int win_cx = _win_width / 2; int win_cy = _win_height / 2; CGRect rect = { { 0, 0 }, { 0, 0 } }; - + if (image._width <= _win_width && image._height <= _win_height) { // The bitmap fits within the window; center it. - + // This is the top-left corner of the bitmap in window coordinates. int p_x = win_cx - image._width / 2; int p_y = win_cy - image._height / 2; @@ -617,7 +575,7 @@ paint_image(CGContextRef context, const OsxImageData &image) { rect.origin.y += p_y; rect.size.width = image._width; rect.size.height = image._height; - + } else { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; @@ -625,7 +583,7 @@ paint_image(CGContextRef context, const OsxImageData &image) { double scale = min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); - + int p_x = win_cx - sc_width / 2; int p_y = win_cy - sc_height / 2; @@ -636,16 +594,13 @@ paint_image(CGContextRef context, const OsxImageData &image) { } CGContextDrawImage(context, rect, image._image); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::paint_progress_bar -// Access: Private -// Description: Draws the progress bar and the label within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Draws the progress bar and the label within the window. + */ void P3DOsxSplashWindow:: paint_progress_bar(CGContextRef context) { CGFloat fg_components[] = { _fgcolor_r / 255.0f, _fgcolor_g / 255.0f, _fgcolor_b / 255.0f, 1 }; @@ -677,8 +632,8 @@ paint_progress_bar(CGContextRef context) { CGContextFillRect(context, prog); } } else { - // Progress is unknown. Draw a moving block, not a progress bar - // filling up. + // Progress is unknown. Draw a moving block, not a progress bar filling + // up. int block_width = (int)(bar_width * 0.1 + 0.5); int block_travel = bar_width - block_width; int progress = (int)(_received_data * _unknown_progress_rate); @@ -694,9 +649,9 @@ paint_progress_bar(CGContextRef context) { // Draw the black stroke around the progress bar. if (_bar_border > 0) { - // We offset the border by half a pixel, so we'll be drawing the - // one-pixel line through the middle of a pixel, and it won't try to - // antialias itself into a half-black two-pixel line. + // We offset the border by half a pixel, so we'll be drawing the one-pixel + // line through the middle of a pixel, and it won't try to antialias + // itself into a half-black two-pixel line. CGRect border_rect = { { bar_x - 0.5, bar_y - 0.5 }, { bar_width + 1, bar_height + 1 } }; @@ -745,30 +700,26 @@ paint_progress_bar(CGContextRef context) { CGColorSpaceRelease(rgb_space); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::st_event_callback -// Access: Private, Static -// Description: The event callback on the toplevel window. -//////////////////////////////////////////////////////////////////// +/** + * The event callback on the toplevel window. + */ pascal OSStatus P3DOsxSplashWindow:: -st_event_callback(EventHandlerCallRef my_handler, EventRef event, +st_event_callback(EventHandlerCallRef my_handler, EventRef event, void *user_data) { return ((P3DOsxSplashWindow *)user_data)->event_callback(my_handler, event); } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::event_callback -// Access: Private -// Description: The event callback on the toplevel window. -//////////////////////////////////////////////////////////////////// +/** + * The event callback on the toplevel window. + */ OSStatus P3DOsxSplashWindow:: event_callback(EventHandlerCallRef my_handler, EventRef event) { OSStatus result = eventNotHandledErr; - WindowRef window = NULL; + WindowRef window = NULL; UInt32 the_class = GetEventClass(event); UInt32 kind = GetEventKind(event); - GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, + GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, (void*) &window); switch (the_class) { case kEventClassWindow: @@ -791,8 +742,8 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { } } - // We seem to get the mouse-down, but lose the mouse-up, event - // in this case, so infer it. + // We seem to get the mouse-down, but lose the mouse-up, event in this + // case, so infer it. set_mouse_data(_mouse_x, _mouse_y, false); result = noErr; break; @@ -844,11 +795,9 @@ event_callback(EventHandlerCallRef my_handler, EventRef event) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DOsxSplashWindow::OsxImageData::dump_image -// Access: Public -// Description: Frees the previous image data. -//////////////////////////////////////////////////////////////////// +/** + * Frees the previous image data. + */ void P3DOsxSplashWindow::OsxImageData:: dump_image() { if (_image != NULL) { diff --git a/direct/src/plugin/p3dOsxSplashWindow.h b/direct/src/plugin/p3dOsxSplashWindow.h index 8c4cab382b..2a725412eb 100644 --- a/direct/src/plugin/p3dOsxSplashWindow.h +++ b/direct/src/plugin/p3dOsxSplashWindow.h @@ -1,16 +1,15 @@ -// Filename: p3dOsxSplashWindow.h -// Created by: drose (16Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dOsxSplashWindow.h + * @author drose + * @date 2009-07-16 + */ #ifndef P3DOSXSPLASHWINDOW_H #define P3DOSXSPLASHWINDOW_H @@ -23,11 +22,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : P3DOsxSplashWindow -// Description : This is the OSX implementation of the -// initial-download window. -//////////////////////////////////////////////////////////////////// +/** + * This is the OSX implementation of the initial-download window. + */ class P3DOsxSplashWindow : public P3DSplashWindow { public: P3DOsxSplashWindow(P3DInstance *inst, bool make_visible); @@ -58,7 +55,7 @@ private: void paint_progress_bar(CGContextRef context); static pascal OSStatus - st_event_callback(EventHandlerCallRef my_handler, EventRef event, + st_event_callback(EventHandlerCallRef my_handler, EventRef event, void *user_data); OSStatus event_callback(EventHandlerCallRef my_handler, EventRef event); diff --git a/direct/src/plugin/p3dPackage.I b/direct/src/plugin/p3dPackage.I index 2ba1c24171..2b5f40ff73 100644 --- a/direct/src/plugin/p3dPackage.I +++ b/direct/src/plugin/p3dPackage.I @@ -1,197 +1,154 @@ -// Filename: p3dPackage.I -// Created by: drose (12Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPackage.I + * @author drose + * @date 2009-06-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_info_ready -// Access: Public -// Description: Returns true if the package file information has been -// downloaded and verified and is ready to be consulted, -// false if it is not yet available. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the package file information has been downloaded and + * verified and is ready to be consulted, false if it is not yet available. + */ inline bool P3DPackage:: get_info_ready() const { return _info_ready; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_download_size -// Access: Public -// Description: Returns the number of bytes that will need to be -// downloaded, when this package is downloaded. This is -// intended to be used to estimate the download time for -// this package relative to other packages, for instance -// to update a progress bar sensibly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that will need to be downloaded, when this + * package is downloaded. This is intended to be used to estimate the + * download time for this package relative to other packages, for instance to + * update a progress bar sensibly. + */ inline size_t P3DPackage:: get_download_size() const { return _compressed_archive.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_ready -// Access: Public -// Description: Returns true if the package has been downloaded and -// verified and is ready to be used, false if it has -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the package has been downloaded and verified and is ready + * to be used, false if it has not. + */ inline bool P3DPackage:: get_ready() const { return _ready; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_failed -// Access: Public -// Description: Returns true if the package cannot be made ready, for -// instance because the download server is down. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the package cannot be made ready, for instance because the + * download server is down. + */ inline bool P3DPackage:: get_failed() const { return _failed; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_host -// Access: Public -// Description: Returns the host server which offers this package for -// download. -//////////////////////////////////////////////////////////////////// +/** + * Returns the host server which offers this package for download. + */ inline P3DHost *P3DPackage:: get_host() const { return _host; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_package_dir -// Access: Public -// Description: Returns the directory into which this package is -// installed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory into which this package is installed. + */ inline const string &P3DPackage:: get_package_dir() const { return _package_dir; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_package_name -// Access: Public -// Description: Returns the name of this package. This is an -// internal name, used to generate filenames and the -// like; it will generally be all-lowercase and will not -// contain spaces. See also get_package_display_name() -// for a name suitable for displaying to the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this package. This is an internal name, used to + * generate filenames and the like; it will generally be all-lowercase and + * will not contain spaces. See also get_package_display_name() for a name + * suitable for displaying to the user. + */ inline const string &P3DPackage:: get_package_name() const { return _package_name; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_package_version -// Access: Public -// Description: Returns the version string of this package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version string of this package. + */ inline const string &P3DPackage:: get_package_version() const { return _package_version; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_package_platform -// Access: Public -// Description: Returns the platform string of this package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the platform string of this package. + */ inline const string &P3DPackage:: get_package_platform() const { return _package_platform; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_package_display_name -// Access: Public -// Description: Returns the display_name name of this package, as set -// in the desc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the display_name name of this package, as set in the desc file. + */ inline const string &P3DPackage:: get_package_display_name() const { return _package_display_name; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_xconfig -// Access: Public -// Description: Returns the entry of the package desc file, -// if any, or NULL if it was not present. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entry of the package desc file, if any, or NULL if it + * was not present. + */ inline const TiXmlElement *P3DPackage:: get_xconfig() const { return _xconfig; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_desc_file_pathname -// Access: Public -// Description: Returns the full path to the package's desc file. If -// this is a "solo" type package, the desc file itself -// represents the entire contents of the package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path to the package's desc file. If this is a "solo" type + * package, the desc file itself represents the entire contents of the + * package. + */ inline const string &P3DPackage:: get_desc_file_pathname() const { return _desc_file_pathname; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_desc_file_dirname -// Access: Public -// Description: Returns the relative path, on the host, of the -// directory that contains the desc file (and to which -// all of the paths in the desc file are relative). -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative path, on the host, of the directory that contains the + * desc file (and to which all of the paths in the desc file are relative). + */ inline const string &P3DPackage:: get_desc_file_dirname() const { return _desc_file_dirname; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_archive_file_pathname -// Access: Public -// Description: Returns the full path to the package's uncompressed -// archive file. This is only valid if get_ready() is -// true and the package is not a "solo" package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path to the package's uncompressed archive file. This is + * only valid if get_ready() is true and the package is not a "solo" package. + */ inline string P3DPackage:: get_archive_file_pathname() const { return _uncompressed_archive.get_pathname(_package_dir); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStep::get_effort -// Access: Public -// Description: Returns the relative amount of effort of this step. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative amount of effort of this step. + */ inline double P3DPackage::InstallStep:: get_effort() const { return _bytes_needed * _bytes_factor; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStep::get_progress -// Access: Public -// Description: Returns the progress of this step, in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the progress of this step, in the range 0..1. + */ inline double P3DPackage::InstallStep:: get_progress() const { if (_bytes_needed == 0) { @@ -200,22 +157,17 @@ get_progress() const { return min((double)_bytes_done / (double)_bytes_needed, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStep::report_step_progress -// Access: Public -// Description: Notifies the Package that progress has been made on -// this particular step. -//////////////////////////////////////////////////////////////////// +/** + * Notifies the Package that progress has been made on this particular step. + */ inline void P3DPackage::InstallStep:: report_step_progress() { _package->report_progress(this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::RequiredPackage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DPackage::RequiredPackage:: RequiredPackage(const string &package_name, const string &package_version, const string &package_seq, P3DHost *host) : @@ -225,4 +177,3 @@ RequiredPackage(const string &package_name, const string &package_version, _host(host) { } - diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 85ab9a3b21..7646a8c602 100644 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -1,16 +1,15 @@ -// Filename: p3dPackage.cxx -// Created by: drose (12Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPackage.cxx + * @author drose + * @date 2009-06-12 + */ #include "p3dPackage.h" #include "p3dInstanceManager.h" @@ -30,18 +29,16 @@ #include // chmod() #endif -// Weight factors for computing download progress. This attempts to -// reflect the relative time-per-byte of each of these operations. +// Weight factors for computing download progress. This attempts to reflect +// the relative time-per-byte of each of these operations. const double P3DPackage::_download_factor = 1.0; const double P3DPackage::_uncompress_factor = 0.01; const double P3DPackage::_unpack_factor = 0.01; const double P3DPackage::_patch_factor = 0.01; -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage:: P3DPackage(P3DHost *host, const string &package_name, const string &package_version, const string &package_platform, @@ -56,8 +53,8 @@ P3DPackage(P3DHost *host, const string &package_name, _per_platform = false; _patch_version = 0; - // This is set true if the package is a "solo", i.e. a single - // file, instead of an xml file and a multifile to unpack. + // This is set true if the package is a "solo", i.e. a single file, instead + // of an xml file and a multifile to unpack. _package_solo = false; _host_contents_iseq = 0; @@ -75,11 +72,9 @@ P3DPackage(P3DHost *host, const string &package_name, _updated = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage:: ~P3DPackage() { // Tell any pending callbacks that we're no good any more. @@ -115,14 +110,11 @@ P3DPackage:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::activate_download -// Access: Public -// Description: Authorizes the package to begin downloading and -// unpacking the meat of its data. Until this is -// called, the package will download its file -// information only, and then wait. -//////////////////////////////////////////////////////////////////// +/** + * Authorizes the package to begin downloading and unpacking the meat of its + * data. Until this is called, the package will download its file information + * only, and then wait. + */ void P3DPackage:: activate_download() { _allow_data_download = true; @@ -135,22 +127,18 @@ activate_download() { } } else { - // Otherwise, if we've already got the desc file, then start the - // download. + // Otherwise, if we've already got the desc file, then start the download. if (_info_ready) { follow_install_plans(true, false); } } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::get_formatted_name -// Access: Public -// Description: Returns the name of this package, for output to the -// user. This will be the "public" name of the package, -// as formatted for user consumption; it will include -// capital letters and spaces where appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this package, for output to the user. This will be the + * "public" name of the package, as formatted for user consumption; it will + * include capital letters and spaces where appropriate. + */ string P3DPackage:: get_formatted_name() const { ostringstream strm; @@ -171,44 +159,39 @@ get_formatted_name() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::add_instance -// Access: Public -// Description: Specifies an instance that that will be using this -// package, and may be responsible for downloading it. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an instance that that will be using this package, and may be + * responsible for downloading it. + */ void P3DPackage:: add_instance(P3DInstance *inst) { _instances.push_back(inst); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_host->has_current_contents_file(inst_mgr)) { - // If the host needs to update its contents file, we're no longer - // sure that we're current. + // If the host needs to update its contents file, we're no longer sure + // that we're current. _info_ready = false; _ready = false; _failed = false; _allow_data_download = false; nout << "No longer current: " << get_package_name() << "\n"; } - + begin_info_download(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::remove_instance -// Access: Public -// Description: Indicates that the given instance is no longer -// interested in this package and will not be -// responsible for downloading it. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given instance is no longer interested in this package + * and will not be responsible for downloading it. + */ void P3DPackage:: remove_instance(P3DInstance *inst) { assert(!_instances.empty()); if (inst == _instances[0]) { - // This was the primary instance. Cancel any pending download and - // move to the next instance. + // This was the primary instance. Cancel any pending download and move to + // the next instance. if (_active_download != NULL) { _active_download->cancel(); set_active_download(NULL); @@ -222,12 +205,9 @@ remove_instance(P3DInstance *inst) { begin_info_download(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::mark_used -// Access: Public -// Description: Marks this package as having been "used", for -// accounting purposes. -//////////////////////////////////////////////////////////////////// +/** + * Marks this package as having been "used", for accounting purposes. + */ void P3DPackage:: mark_used() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -236,8 +216,8 @@ mark_used() { return; } - // Unlike the Python variant of this function, we don't mess around - // with updating the disk space or anything. + // Unlike the Python variant of this function, we don't mess around with + // updating the disk space or anything. string filename = get_package_dir() + "/usage.xml"; TiXmlDocument doc(filename); if (!doc.LoadFile()) { @@ -263,15 +243,15 @@ mark_used() { xusage->SetAttribute("last_use", (int)now); if (_updated) { - // If we've updated the package, we're no longer sure what its - // disk space is. Remove that from the XML file, so that the - // Python code can recompute it later. + // If we've updated the package, we're no longer sure what its disk space + // is. Remove that from the XML file, so that the Python code can + // recompute it later. xusage->RemoveAttribute("disk_space"); xusage->SetAttribute("last_update", (int)now); } - // Write the file to a temporary filename, then atomically move it - // to its actual filename, to avoid race conditions. + // Write the file to a temporary filename, then atomically move it to its + // actual filename, to avoid race conditions. ostringstream strm; strm << get_package_dir() << "/usage_"; #ifdef _WIN32 @@ -292,12 +272,10 @@ mark_used() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::uninstall -// Access: Public -// Description: Removes the package directory and all its contents -// from the user's hard disk. -//////////////////////////////////////////////////////////////////// +/** + * Removes the package directory and all its contents from the user's hard + * disk. + */ void P3DPackage:: uninstall() { if (_package_dir.empty()) { @@ -307,10 +285,9 @@ uninstall() { nout << "Uninstalling package " << _package_name << " from " << _package_dir << "\n"; - // First, make sure that all instances that are sharing this package - // are stopped, so there will be no access conflicts preventing us - // from removing the files. This is particularly important on - // Windows. + // First, make sure that all instances that are sharing this package are + // stopped, so there will be no access conflicts preventing us from removing + // the files. This is particularly important on Windows. Instances::iterator ii; for (ii = _instances.begin(); ii != _instances.end(); ++ii) { P3DInstance *inst = (*ii); @@ -334,13 +311,10 @@ uninstall() { _host->forget_package(this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::make_xml -// Access: Public -// Description: Returns a newly-allocated XML structure that -// corresponds to the package data within this -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated XML structure that corresponds to the package + * data within this instance. + */ TiXmlElement *P3DPackage:: make_xml() { TiXmlElement *xpackage = new TiXmlElement("package"); @@ -358,16 +332,13 @@ make_xml() { return xpackage; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::begin_info_download -// Access: Private -// Description: Begins downloading and installing the information -// about the package, including its file size and -// download source and such, if needed. This is -// generally a very small download. -//////////////////////////////////////////////////////////////////// +/** + * Begins downloading and installing the information about the package, + * including its file size and download source and such, if needed. This is + * generally a very small download. + */ void P3DPackage:: -begin_info_download() { +begin_info_download() { if (_instances.empty()) { // Can't download without any instances. return; @@ -387,26 +358,23 @@ begin_info_download() { download_contents_file(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::download_contents_file -// Access: Private -// Description: Starts downloading the root-level contents.xml file. -// This is only done for the first package downloaded -// from a particular host, and only if the host doesn't -// have the file already. -//////////////////////////////////////////////////////////////////// +/** + * Starts downloading the root-level contents.xml file. This is only done for + * the first package downloaded from a particular host, and only if the host + * doesn't have the file already. + */ void P3DPackage:: download_contents_file() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_host->has_contents_file() && inst_mgr->get_verify_contents() != P3D_VC_force) { - // First, read whatever contents file is already on disk. Maybe - // it's current enough. + // First, read whatever contents file is already on disk. Maybe it's + // current enough. _host->read_contents_file(); } if (_host->has_current_contents_file(inst_mgr)) { - // We've already got a contents.xml file; go straight to the - // package desc file. + // We've already got a contents.xml file; go straight to the package desc + // file. host_got_contents_file(); return; } @@ -417,31 +385,28 @@ download_contents_file() { return; } - // Download contents.xml to a temporary filename first, in case - // multiple packages are downloading it simultaneously. + // Download contents.xml to a temporary filename first, in case multiple + // packages are downloading it simultaneously. if (_temp_contents_file != NULL) { delete _temp_contents_file; _temp_contents_file = NULL; } _temp_contents_file = new P3DTemporaryFile(".xml"); - start_download(DT_contents_file, "contents.xml", + start_download(DT_contents_file, "contents.xml", _temp_contents_file->get_filename(), FileSpec()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::contents_file_download_finished -// Access: Private -// Description: Called when the contents.xml file has been fully -// downloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called when the contents.xml file has been fully downloaded. + */ void P3DPackage:: contents_file_download_finished(bool success) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_host->has_current_contents_file(inst_mgr)) { if (!success || _temp_contents_file == NULL || !_host->read_contents_file(_temp_contents_file->get_filename(), true)) { - + if (_temp_contents_file) { nout << "Couldn't read " << *_temp_contents_file << "\n"; } @@ -470,9 +435,8 @@ contents_file_download_finished(bool success) { } } } - - // The file is correctly installed by now; we can remove the - // temporary file. + + // The file is correctly installed by now; we can remove the temporary file. if (_temp_contents_file) { delete _temp_contents_file; _temp_contents_file = NULL; @@ -481,42 +445,37 @@ contents_file_download_finished(bool success) { host_got_contents_file(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::redownload_contents_file -// Access: Private -// Description: Starts a new download attempt of contents.xml, to -// check to see whether our local copy is stale. This -// is called only from download_desc_file(), or from -// Download::download_finished(). If the former, the -// download pointer will be NULL. -// -// If it turns out a new version can be downloaded, the -// indicated Download object (and the current install -// plan) is discarded, and the package download is -// restarted from the beginning. -// -// If there is no new version available, calls -// resume_download_finished() on the indicated Download -// object, to carry on as if nothing had happened. -//////////////////////////////////////////////////////////////////// +/** + * Starts a new download attempt of contents.xml, to check to see whether our + * local copy is stale. This is called only from download_desc_file(), or + * from Download::download_finished(). If the former, the download pointer + * will be NULL. + * + * If it turns out a new version can be downloaded, the indicated Download + * object (and the current install plan) is discarded, and the package + * download is restarted from the beginning. + * + * If there is no new version available, calls resume_download_finished() on + * the indicated Download object, to carry on as if nothing had happened. + */ void P3DPackage:: redownload_contents_file(P3DPackage::Download *download) { assert(_active_download == NULL); assert(_saved_download == NULL); - + if (_host->get_contents_iseq() != _host_contents_iseq) { - // If the contents_iseq number has changed, we don't even need to - // download anything--just go restart the download. + // If the contents_iseq number has changed, we don't even need to download + // anything--just go restart the download. host_got_contents_file(); return; } - + // Don't download it if we're not allowed to. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (inst_mgr->get_verify_contents() == P3D_VC_never) { return; } - + set_saved_download(download); // Download contents.xml to a temporary filename first. @@ -526,29 +485,26 @@ redownload_contents_file(P3DPackage::Download *download) { } _temp_contents_file = new P3DTemporaryFile(".xml"); - start_download(DT_redownload_contents_file, "contents.xml", + start_download(DT_redownload_contents_file, "contents.xml", _temp_contents_file->get_filename(), FileSpec()); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::contents_file_redownload_finished -// Access: Private -// Description: Called when the redownload attempt on contents.xml -// has finished. -//////////////////////////////////////////////////////////////////// +/** + * Called when the redownload attempt on contents.xml has finished. + */ void P3DPackage:: contents_file_redownload_finished(bool success) { bool contents_changed = false; - + if (_host->get_contents_iseq() != _host_contents_iseq) { - // If the contents_iseq number has changed, we don't even need to - // bother reading what we just downloaded. + // If the contents_iseq number has changed, we don't even need to bother + // reading what we just downloaded. contents_changed = true; } if (!contents_changed && success) { - // If we successfully downloaded something, see if it's different - // from what we had before. + // If we successfully downloaded something, see if it's different from + // what we had before. if (!_host->check_contents_hash(_temp_contents_file->get_filename())) { // It changed! Now see if we can read the new contents. if (!_host->read_contents_file(_temp_contents_file->get_filename(), true)) { @@ -561,7 +517,7 @@ contents_file_redownload_finished(bool success) { } } } - + // We no longer need the temporary file. if (_temp_contents_file) { delete _temp_contents_file; @@ -569,25 +525,25 @@ contents_file_redownload_finished(bool success) { } if (contents_changed) { - // OK, the contents.xml has changed; this means we have to restart - // the whole download process from the beginning. + // OK, the contents.xml has changed; this means we have to restart the + // whole download process from the beginning. nout << "Redownloading contents.xml made a difference.\n"; set_saved_download(NULL); host_got_contents_file(); } else { - // Nothing's changed. This was just a useless diversion. We now - // return you to our regularly scheduled download. + // Nothing's changed. This was just a useless diversion. We now return + // you to our regularly scheduled download. nout << "Redownloading contents.xml didn't help.\n"; Download *download = _saved_download; _saved_download = NULL; if (download == NULL) { // But, if _saved_download was NULL (meaning NULL was passed to - // redownload_contents_file(), above), it means that we were - // called from download_desc_file(), and there's nothing more to - // do. We're just hosed. + // redownload_contents_file(), above), it means that we were called from + // download_desc_file(), and there's nothing more to do. We're just + // hosed. report_done(false); - + } else { download->resume_download_finished(false); p3d_unref_delete(download); @@ -595,30 +551,26 @@ contents_file_redownload_finished(bool success) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::host_got_contents_file -// Access: Private -// Description: We come here when we've successfully downloaded and -// read the host's contents.xml file. This begins the -// rest of the download process. -//////////////////////////////////////////////////////////////////// +/** + * We come here when we've successfully downloaded and read the host's + * contents.xml file. This begins the rest of the download process. + */ void P3DPackage:: host_got_contents_file() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (!_alt_host.empty()) { - // If we have an alt host specification, maybe we need to change - // the host now. + // If we have an alt host specification, maybe we need to change the host + // now. P3DHost *new_host = _host->get_alt_host(_alt_host); - nout << "Migrating " << get_package_name() << " to alt_host " + nout << "Migrating " << get_package_name() << " to alt_host " << _alt_host << ": " << new_host->get_host_url() << "\n"; if (new_host != _host) { _host->migrate_package_host(this, _alt_host, new_host); _host = new_host; } - // Clear the alt_host string now that we're migrated to our final - // host. + // Clear the alt_host string now that we're migrated to our final host. _alt_host.clear(); if (!_host->has_current_contents_file(inst_mgr)) { @@ -628,20 +580,19 @@ host_got_contents_file() { } } - // Record this now, so we'll know later whether the host has been - // reloaded (e.g. due to some other package, from some other - // instance, reloading it). + // Record this now, so we'll know later whether the host has been reloaded + // (e.g. due to some other package, from some other instance, reloading + // it). _host_contents_iseq = _host->get_contents_iseq(); - // Now adjust the platform based on the available platforms - // provided. + // Now adjust the platform based on the available platforms provided. assert(_alt_host.empty()); string new_platform; if (_host->choose_suitable_platform(new_platform, _per_platform, _package_name, _package_version, _package_platform)) { if (new_platform != _package_platform) { nout << "Migrating " << get_package_name() << " from platform \"" - << _package_platform << "\" to platform \"" + << _package_platform << "\" to platform \"" << new_platform << "\"\n"; _package_platform = new_platform; set_fullname(); @@ -670,20 +621,17 @@ host_got_contents_file() { download_desc_file(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::download_desc_file -// Access: Private -// Description: Starts downloading the desc file for the package, if -// it's needed; or read the local version if it's fresh -// enough. -//////////////////////////////////////////////////////////////////// +/** + * Starts downloading the desc file for the package, if it's needed; or read + * the local version if it's fresh enough. + */ void P3DPackage:: download_desc_file() { assert(!_package_dir.empty()); - // Attempt to check the desc file for freshness. If it already - // exists, and is consistent with the server contents file, we don't - // need to re-download it. + // Attempt to check the desc file for freshness. If it already exists, and + // is consistent with the server contents file, we don't need to re-download + // it. string package_seq; if (!_host->get_package_desc_file(_desc_file, package_seq, _package_solo, _package_name, _package_version, @@ -705,9 +653,9 @@ download_desc_file() { _desc_file_basename = _desc_file_basename.substr(slash + 1); } - // The desc file might have a different path on the host server than - // it has locally, because we might strip out the platform directory - // locally (according to _per_platform). + // The desc file might have a different path on the host server than it has + // locally, because we might strip out the platform directory locally + // (according to _per_platform). FileSpec local_desc_file = _desc_file; local_desc_file.set_filename(_desc_file_basename); _desc_file_pathname = local_desc_file.get_pathname(_package_dir); @@ -739,15 +687,13 @@ download_desc_file() { } // The desc file is not current. Go download it. - start_download(DT_desc_file, _desc_file.get_filename(), + start_download(DT_desc_file, _desc_file.get_filename(), _desc_file_pathname, local_desc_file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::desc_file_download_finished -// Access: Private -// Description: Called when the desc file has been fully downloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called when the desc file has been fully downloaded. + */ void P3DPackage:: desc_file_download_finished(bool success) { if (!success) { @@ -773,16 +719,14 @@ desc_file_download_finished(bool success) { report_done(false); return; } - + got_desc_file(&doc, true); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::got_desc_file -// Access: Private -// Description: Reads the desc file and begins verifying the files. -//////////////////////////////////////////////////////////////////// +/** + * Reads the desc file and begins verifying the files. + */ void P3DPackage:: got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { TiXmlElement *xpackage = doc->FirstChildElement("package"); @@ -801,27 +745,26 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { nout << "Warning! per_platform disagreement for " << get_package_name() << "!\n"; // We don't do anything with this warning--the original value for - // _per_platform we got from the contents.xml file has to apply, - // because we're already committed to the _package_dir we're - // using. + // _per_platform we got from the contents.xml file has to apply, because + // we're already committed to the _package_dir we're using. } - + xpackage->Attribute("patch_version", &_patch_version); - + TiXmlElement *xconfig = xpackage->FirstChildElement("config"); if (xconfig != NULL) { const char *display_name_cstr = xconfig->Attribute("display_name"); if (display_name_cstr != NULL) { _package_display_name = display_name_cstr; } - + // Save the config entry within this class for others to query. _xconfig = (TiXmlElement *)xconfig->Clone(); } - TiXmlElement *xuncompressed_archive = + TiXmlElement *xuncompressed_archive = xpackage->FirstChildElement("uncompressed_archive"); - TiXmlElement *xcompressed_archive = + TiXmlElement *xcompressed_archive = xpackage->FirstChildElement("compressed_archive"); if (xuncompressed_archive == NULL || xcompressed_archive == NULL) { @@ -874,14 +817,13 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { } if (inst_mgr->get_verify_contents() == P3D_VC_never) { - // This means we'll just leave it at this - // and assume that we're finished. + // This means we'll just leave it at this and assume that we're finished. report_done(true); return; } - // Get a list of all of the files in the directory, so we can remove - // files that don't belong. + // Get a list of all of the files in the directory, so we can remove files + // that don't belong. vector contents, dirname_contents; inst_mgr->scan_directory_recursively(_package_dir, contents, dirname_contents); @@ -893,10 +835,10 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { inst_mgr->remove_file_from_list(contents, (*ei).get_filename()); } - // Now, any files that are still in the contents list don't belong. - // It's important to remove these files before we start verifying - // the files that we expect to find here, in case there is a problem - // with ambiguous filenames or something (e.g. case insensitivity). + // Now, any files that are still in the contents list don't belong. It's + // important to remove these files before we start verifying the files that + // we expect to find here, in case there is a problem with ambiguous + // filenames or something (e.g. case insensitivity). vector::iterator ci; for (ci = contents.begin(); ci != contents.end(); ++ci) { string filename = (*ci); @@ -937,13 +879,13 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { report_done(true); } else { - // We need to get the file data still, but at least we know all - // about it by this point. + // We need to get the file data still, but at least we know all about it + // by this point. build_install_plans(doc); if (!_allow_data_download) { - // Not authorized to start downloading yet; just report that - // we're ready. + // Not authorized to start downloading yet; just report that we're + // ready. report_info_ready(); } else { // We've already been authorized to start downloading, so do it. @@ -952,11 +894,9 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::clear_install_plans -// Access: Private -// Description: Empties _install_plans cleanly. -//////////////////////////////////////////////////////////////////// +/** + * Empties _install_plans cleanly. + */ void P3DPackage:: clear_install_plans() { InstallPlans::iterator pi; @@ -973,12 +913,10 @@ clear_install_plans() { _computed_plan_size = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::build_install_plans -// Access: Private -// Description: Sets up _install_plans, a list of one or more "plans" -// to download and install the package. -//////////////////////////////////////////////////////////////////// +/** + * Sets up _install_plans, a list of one or more "plans" to download and + * install the package. + */ void P3DPackage:: build_install_plans(TiXmlDocument *doc) { clear_install_plans(); @@ -998,21 +936,20 @@ build_install_plans(TiXmlDocument *doc) { _computed_plan_size = false; bool needs_redownload = false; - + InstallStep *step; if (!_uncompressed_archive.quick_verify(_package_dir)) { // The uncompressed archive is no good. if (!_compressed_archive.quick_verify(_package_dir)) { - // The compressed archive is no good either. Download a new - // compressed archive. + // The compressed archive is no good either. Download a new compressed + // archive. needs_redownload = true; step = new InstallStepDownloadFile(this, _compressed_archive); plan.push_back(step); } - // Uncompress the compressed archive to generate the uncompressed - // archive. + // Uncompress the compressed archive to generate the uncompressed archive. step = new InstallStepUncompressFile (this, _compressed_archive, _uncompressed_archive, true); plan.push_back(step); @@ -1023,12 +960,11 @@ build_install_plans(TiXmlDocument *doc) { plan.push_back(step); if (needs_redownload) { - // Since we need to do some downloading, try to build a plan that - // involves downloading patches instead of downloading the whole - // file. This will be our first choice, plan A, if we can do it. + // Since we need to do some downloading, try to build a plan that involves + // downloading patches instead of downloading the whole file. This will + // be our first choice, plan A, if we can do it. - // We'll need the md5 hash of the uncompressed archive currently - // on disk. + // We'll need the md5 hash of the uncompressed archive currently on disk. // Maybe we've already read the md5 hash and we have it stored here. const FileSpec *on_disk_ptr = _uncompressed_archive.get_actual_file(); @@ -1087,19 +1023,15 @@ build_install_plans(TiXmlDocument *doc) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::follow_install_plans -// Access: Private -// Description: Performs the next step in the current install plan. -// -// If download_finished is false, there is a pending -// download that has not fully completed yet; otherwise, -// download_finished should be set true. -// -// If plan_failed is false, it means that the -// top-of-stack plan is still good; if true, the -// top-of-stack plan has failed and should be removed. -//////////////////////////////////////////////////////////////////// +/** + * Performs the next step in the current install plan. + * + * If download_finished is false, there is a pending download that has not + * fully completed yet; otherwise, download_finished should be set true. + * + * If plan_failed is false, it means that the top-of-stack plan is still good; + * if true, the top-of-stack plan has failed and should be removed. + */ void P3DPackage:: follow_install_plans(bool download_finished, bool plan_failed) { if (!_allow_data_download || _failed) { @@ -1121,7 +1053,7 @@ follow_install_plans(bool download_finished, bool plan_failed) { _total_plan_size += step_effort; _total_plan_completed += (*si)->get_progress() * step_effort; } - + _download_progress = 0.0; if (_total_plan_size > 0.0) { _download_progress = _total_plan_completed / _total_plan_size; @@ -1187,24 +1119,18 @@ follow_install_plans(bool download_finished, bool plan_failed) { report_done(false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::st_callback -// Access: Private, Static -// Description: This function is registered as the callback hook when -// a package is in the middle of processing in a -// sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * This function is registered as the callback hook when a package is in the + * middle of processing in a sub-thread. + */ void P3DPackage:: st_callback(void *self) { ((P3DPackage *)self)->follow_install_plans(false, false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::request_callback -// Access: Private -// Description: Requests that follow_install_plans() will be called -// again in the future. -//////////////////////////////////////////////////////////////////// +/** + * Requests that follow_install_plans() will be called again in the future. + */ void P3DPackage:: request_callback() { Instances::iterator ii; @@ -1213,18 +1139,15 @@ request_callback() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::report_progress -// Access: Private -// Description: Reports the current install progress to all -// interested instances. -//////////////////////////////////////////////////////////////////// +/** + * Reports the current install progress to all interested instances. + */ void P3DPackage:: report_progress(P3DPackage::InstallStep *step) { if (_computed_plan_size) { double size = _total_plan_completed + _current_step_effort * step->get_progress(); _download_progress = min(size / _total_plan_size, 1.0); - + Instances::iterator ii; for (ii = _instances.begin(); ii != _instances.end(); ++ii) { (*ii)->report_package_progress(this, _download_progress); @@ -1232,14 +1155,11 @@ report_progress(P3DPackage::InstallStep *step) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::report_info_ready -// Access: Private -// Description: Called when the package information has been -// successfully downloaded but activate_download() has -// not yet been called, and the package is now idle, -// waiting for activate_download() to be called. -//////////////////////////////////////////////////////////////////// +/** + * Called when the package information has been successfully downloaded but + * activate_download() has not yet been called, and the package is now idle, + * waiting for activate_download() to be called. + */ void P3DPackage:: report_info_ready() { _info_ready = true; @@ -1250,13 +1170,10 @@ report_info_ready() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::report_done -// Access: Private -// Description: Transitions the package to "ready" or "failure" -// state, and reports this change to all the interested -// instances. -//////////////////////////////////////////////////////////////////// +/** + * Transitions the package to "ready" or "failure" state, and reports this + * change to all the interested instances. + */ void P3DPackage:: report_done(bool success) { // Don't call report_done() twice. @@ -1276,8 +1193,8 @@ report_done(bool success) { } if (!_allow_data_download && success) { - // If we haven't been authorized to start downloading yet, just - // report that we're ready to start. + // If we haven't been authorized to start downloading yet, just report + // that we're ready to start. Instances::iterator ii; for (ii = _instances.begin(); ii != _instances.end(); ++ii) { (*ii)->report_package_info_ready(this); @@ -1292,26 +1209,23 @@ report_done(bool success) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::start_download -// Access: Private -// Description: Initiates a download of the indicated file. Returns -// the new Download object. -//////////////////////////////////////////////////////////////////// +/** + * Initiates a download of the indicated file. Returns the new Download + * object. + */ P3DPackage::Download *P3DPackage:: -start_download(P3DPackage::DownloadType dtype, const string &urlbase, +start_download(P3DPackage::DownloadType dtype, const string &urlbase, const string &pathname, const FileSpec &file_spec) { // Only one download should be active at a time assert(_active_download == NULL); - // This can't happen! If verify_contents is set to P3D_VC_never, we're - // not allowed to download anything, so we shouldn't get here + // This can't happen! If verify_contents is set to P3D_VC_never, we're not + // allowed to download anything, so we shouldn't get here P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); assert(inst_mgr->get_verify_contents() != P3D_VC_never); - // We can't explicitly support partial downloads here, because - // Mozilla provides no interface to ask for one. We have to trust - // that Mozilla's use of the browser cache handles partial downloads - // for us automatically. + // We can't explicitly support partial downloads here, because Mozilla + // provides no interface to ask for one. We have to trust that Mozilla's + // use of the browser cache handles partial downloads for us automatically. // Delete the target file before we begin. #ifdef _WIN32 @@ -1319,15 +1233,15 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, chmod(pathname.c_str(), 0644); #endif unlink(pathname.c_str()); - + Download *download = new Download(this, dtype, file_spec); - // Fill up the _try_urls vector for URL's to try getting this file - // from, in reverse order. + // Fill up the _try_urls vector for URL's to try getting this file from, in + // reverse order. bool is_contents_file = (dtype == DT_contents_file || dtype == DT_redownload_contents_file); - // The last thing we try is the actual authoritative host, with a - // cache-busting query string. + // The last thing we try is the actual authoritative host, with a cache- + // busting query string. ostringstream strm; if (is_contents_file) { strm << _host->get_host_url_prefix(); @@ -1348,7 +1262,7 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, vector mirrors; _host->choose_random_mirrors(mirrors, 2); for (vector::iterator si = mirrors.begin(); - si != mirrors.end(); + si != mirrors.end(); ++si) { url = (*si) + urlbase; download->_try_urls.push_back(url); @@ -1356,13 +1270,12 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, } if (dtype == DT_redownload_contents_file) { - // When we're redownloading the contents file after a download - // error, we always go straight to the authoritative host, not - // even to the super-mirror. + // When we're redownloading the contents file after a download error, we + // always go straight to the authoritative host, not even to the super- + // mirror. } else { - // In other cases, if the "super mirror" is enabled, we try that - // first. + // In other cases, if the "super mirror" is enabled, we try that first. if (!inst_mgr->get_super_mirror().empty()) { string url = inst_mgr->get_super_mirror() + urlbase; download->_try_urls.push_back(url); @@ -1370,12 +1283,12 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, } if (download->_try_urls.size() == 1) { - // If we only ended up with only one URL on the try list, then try - // it twice, for a bit of redundancy in case there's a random - // network hiccup or something. + // If we only ended up with only one URL on the try list, then try it + // twice, for a bit of redundancy in case there's a random network hiccup + // or something. - // Save a copy into its own string object first to avoid - // self-dereferencing errors in the push_back() method. + // Save a copy into its own string object first to avoid self- + // dereferencing errors in the push_back() method. string url = download->_try_urls[0]; download->_try_urls.push_back(url); } @@ -1394,12 +1307,10 @@ start_download(P3DPackage::DownloadType dtype, const string &urlbase, return download; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::set_active_download -// Access: Private -// Description: Changes _active_download to point to the indicated -// object, respecting reference counts. -//////////////////////////////////////////////////////////////////// +/** + * Changes _active_download to point to the indicated object, respecting + * reference counts. + */ void P3DPackage:: set_active_download(Download *download) { if (_active_download != download) { @@ -1413,12 +1324,10 @@ set_active_download(Download *download) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::set_saved_download -// Access: Private -// Description: Changes _saved_download to point to the indicated -// object, respecting reference counts. -//////////////////////////////////////////////////////////////////// +/** + * Changes _saved_download to point to the indicated object, respecting + * reference counts. + */ void P3DPackage:: set_saved_download(Download *download) { if (_saved_download != download) { @@ -1432,13 +1341,10 @@ set_saved_download(Download *download) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::is_extractable -// Access: Private -// Description: Returns true if the name file is on the extract list, -// false otherwise. If true, fills in the FileSpec with -// the file's information. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the name file is on the extract list, false otherwise. If + * true, fills in the FileSpec with the file's information. + */ bool P3DPackage:: is_extractable(FileSpec &file, const string &filename) const { Extracts::const_iterator ei; @@ -1453,18 +1359,13 @@ is_extractable(FileSpec &file, const string &filename) const { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::instance_terminating -// Access: Private -// Description: Called when P3D_RC_shutdown is received by any -// Download object, which indicates that the instance -// owning this download object is terminating and we -// should either find a new instance or abort the -// download. -// -// The return value is true if a new instance is -// available, or false if not. -//////////////////////////////////////////////////////////////////// +/** + * Called when P3D_RC_shutdown is received by any Download object, which + * indicates that the instance owning this download object is terminating and + * we should either find a new instance or abort the download. + * + * The return value is true if a new instance is available, or false if not. + */ bool P3DPackage:: instance_terminating(P3DInstance *instance) { if (_instances.empty() || @@ -1473,8 +1374,8 @@ instance_terminating(P3DInstance *instance) { return false; } - // There are more instances available to continue this download; - // pick one of them. Move this one to the end of the list. + // There are more instances available to continue this download; pick one of + // them. Move this one to the end of the list. Instances::iterator ii = find(_instances.begin(), _instances.end(), instance); if (ii != _instances.end()) { _instances.erase(ii); @@ -1483,12 +1384,10 @@ instance_terminating(P3DInstance *instance) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::set_fullname -// Access: Private -// Description: Assigns _package_fullname to the appropriate -// combination of name, version, and platform. -//////////////////////////////////////////////////////////////////// +/** + * Assigns _package_fullname to the appropriate combination of name, version, + * and platform. + */ void P3DPackage:: set_fullname() { _package_fullname = _package_name; @@ -1500,11 +1399,9 @@ set_fullname() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Download::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::Download:: Download(P3DPackage *package, DownloadType dtype, const FileSpec &file_spec) : _package(package), @@ -1513,11 +1410,9 @@ Download(P3DPackage *package, DownloadType dtype, const FileSpec &file_spec) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Download::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::Download:: Download(const P3DPackage::Download ©) : P3DFileDownload(copy), @@ -1528,11 +1423,9 @@ Download(const P3DPackage::Download ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Download::download_progress -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::Download:: download_progress() { P3DFileDownload::download_progress(); @@ -1552,11 +1445,9 @@ download_progress() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Download::download_finished -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::Download:: download_finished(bool success) { P3DFileDownload::download_finished(success); @@ -1572,8 +1463,7 @@ download_finished(bool success) { assert(get_ref_count() > 0); if (success && !_file_spec.get_filename().empty()) { - // We think we downloaded it correctly. Check the hash to be - // sure. + // We think we downloaded it correctly. Check the hash to be sure. if (!_file_spec.full_verify(_package->_package_dir)) { nout << "After downloading " << get_url() << ", failed hash check\n"; @@ -1600,8 +1490,8 @@ download_finished(bool success) { return; } - // Maybe it failed because our contents.xml file is out-of-date. - // Go try to freshen it. + // Maybe it failed because our contents.xml file is out-of-date. Go try + // to freshen it. bool is_contents_file = (_dtype == DT_contents_file || _dtype == DT_redownload_contents_file); if (!is_contents_file) { _package->redownload_contents_file(this); @@ -1613,14 +1503,11 @@ download_finished(bool success) { resume_download_finished(success); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::Download::resume_download_finished -// Access: Public -// Description: Continuing the work begun in download_finished(). -// This is a separate entry point so that it can be -// called again after determining that the host's -// contents.xml file is *not* stale. -//////////////////////////////////////////////////////////////////// +/** + * Continuing the work begun in download_finished(). This is a separate entry + * point so that it can be called again after determining that the host's + * contents.xml file is *not* stale. + */ void P3DPackage::Download:: resume_download_finished(bool success) { if (!success && !_try_urls.empty()) { @@ -1657,11 +1544,9 @@ resume_download_finished(bool success) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStep::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStep:: InstallStep(P3DPackage *package, size_t bytes, double factor) : _package(package), @@ -1671,20 +1556,16 @@ InstallStep(P3DPackage *package, size_t bytes, double factor) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStep::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStep:: ~InstallStep() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepDownloadFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepDownloadFile:: InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : InstallStep(package, file.get_size(), _download_factor), @@ -1693,17 +1574,15 @@ InstallStepDownloadFile(P3DPackage *package, const FileSpec &file) : _urlbase = _package->get_desc_file_dirname(); _urlbase += "/"; _urlbase += _file.get_filename(); - + _pathname = _package->get_package_dir() + "/" + _file.get_filename(); - + _download = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepDownloadFile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepDownloadFile:: ~InstallStepDownloadFile() { if (_download != NULL) { @@ -1711,18 +1590,16 @@ P3DPackage::InstallStepDownloadFile:: } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepDownloadFile::do_step -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallToken P3DPackage::InstallStepDownloadFile:: do_step(bool download_finished) { if (_download == NULL) { // First, we have to start the download going. assert(_package->_active_download == NULL); - _download = _package->start_download(DT_install_step, _urlbase, + _download = _package->start_download(DT_install_step, _urlbase, _pathname, _file); assert(_download != NULL); _download->ref(); @@ -1742,13 +1619,12 @@ do_step(bool download_finished) { return IT_step_complete; } else if (_download->get_download_terminated()) { - // The download was interrupted because its instance is shutting - // down. Don't try any other plans, unless we have some more - // instances. + // The download was interrupted because its instance is shutting down. + // Don't try any other plans, unless we have some more instances. P3DInstance *instance = _download->get_instance(); if (!_package->instance_terminating(instance)) { - // That was the only instance referencing this package, so stop - // the download. + // That was the only instance referencing this package, so stop the + // download. nout << "Terminating download of " << _urlbase << "\n"; return IT_terminate; } @@ -1759,17 +1635,15 @@ do_step(bool download_finished) { return IT_continue; } else { - // The Download object has already tried all of the mirrors, and - // they all failed. + // The Download object has already tried all of the mirrors, and they all + // failed. return IT_step_failed; } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepDownloadFile::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::InstallStepDownloadFile:: output(ostream &out) { out << "InstallStepDownloadFile(" << _package->get_package_name() @@ -1777,11 +1651,9 @@ output(ostream &out) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepThreaded:: InstallStepThreaded(P3DPackage *package, size_t bytes, double factor) : InstallStep(package, bytes, factor) @@ -1793,11 +1665,9 @@ InstallStepThreaded(P3DPackage *package, size_t bytes, double factor) : _thread_bytes_done = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepThreaded:: ~InstallStepThreaded() { if (_thread_started) { @@ -1807,15 +1677,13 @@ P3DPackage::InstallStepThreaded:: DESTROY_LOCK(_thread_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::do_step -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallToken P3DPackage::InstallStepThreaded:: do_step(bool download_finished) { - // This method is called within the main thread. It simply checks - // the thread status, and returns. + // This method is called within the main thread. It simply checks the + // thread status, and returns. // Spawn a thread and wait for it to finish. if (!_thread_started) { @@ -1842,15 +1710,13 @@ do_step(bool download_finished) { return token; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::thread_main -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::InstallStepThreaded:: thread_main() { - // This method is called within the sub-thread. It calls - // thread_step() to do its work. + // This method is called within the sub-thread. It calls thread_step() to + // do its work. InstallToken token = IT_needs_callback; do { @@ -1860,19 +1726,17 @@ thread_main() { ACQUIRE_LOCK(_thread_lock); _thread_token = token; RELEASE_LOCK(_thread_lock); - + // Do it again if needed. } while (token == IT_needs_callback); // All done. } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::thread_set_bytes_done -// Access: Public -// Description: Should be called from time to time within the -// sub-thread to update the number of bytes processed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called from time to time within the sub-thread to update the + * number of bytes processed. + */ void P3DPackage::InstallStepThreaded:: thread_set_bytes_done(size_t bytes_done) { ACQUIRE_LOCK(_thread_lock); @@ -1880,12 +1744,10 @@ thread_set_bytes_done(size_t bytes_done) { RELEASE_LOCK(_thread_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepThreaded::thread_add_bytes_done -// Access: Public -// Description: Should be called from time to time within the -// sub-thread to update the number of bytes processed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called from time to time within the sub-thread to update the + * number of bytes processed. + */ void P3DPackage::InstallStepThreaded:: thread_add_bytes_done(size_t bytes_done) { ACQUIRE_LOCK(_thread_lock); @@ -1893,11 +1755,9 @@ thread_add_bytes_done(size_t bytes_done) { RELEASE_LOCK(_thread_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUncompressFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepUncompressFile:: InstallStepUncompressFile(P3DPackage *package, const FileSpec &source, const FileSpec &target, bool verify_target) : @@ -1909,11 +1769,9 @@ InstallStepUncompressFile(P3DPackage *package, const FileSpec &source, } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUncompressFile::thread_step -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallToken P3DPackage::InstallStepUncompressFile:: thread_step() { string source_pathname = _package->get_package_dir() + "/" + _source.get_filename(); @@ -1950,7 +1808,7 @@ thread_step() { nout << "Couldn't write to " << target_pathname << "\n"; return IT_step_failed; } - + static const int decompress_buffer_size = 81920; char decompress_buffer[decompress_buffer_size]; static const int write_buffer_size = 81920; @@ -1972,7 +1830,7 @@ thread_step() { source.read(decompress_buffer, decompress_buffer_size); streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); - + z.next_in = (Bytef *)decompress_buffer; z.avail_in = (size_t)read_count; @@ -1987,7 +1845,7 @@ thread_step() { source.read(decompress_buffer, decompress_buffer_size); streamsize read_count = source.gcount(); eof = (read_count == 0 || source.eof() || source.fail()); - + z.next_in = (Bytef *)decompress_buffer; z.avail_in = (size_t)read_count; } @@ -2010,9 +1868,9 @@ thread_step() { break; } else if (result == Z_BUF_ERROR && flush == 0) { - // We might get this if no progress is possible, for instance if - // the input stream is truncated. In this case, tell zlib to - // dump everything it's got. + // We might get this if no progress is possible, for instance if the + // input stream is truncated. In this case, tell zlib to dump + // everything it's got. flush = Z_FINISH; } else if (result < 0) { @@ -2051,11 +1909,9 @@ thread_step() { return IT_step_complete; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUncompressFile::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::InstallStepUncompressFile:: output(ostream &out) { out << "InstallStepUncompressFile(" << _package->get_package_name() @@ -2063,22 +1919,18 @@ output(ostream &out) { << ", " << _verify_target << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUnpackArchive::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepUnpackArchive:: InstallStepUnpackArchive(P3DPackage *package, size_t unpack_size) : InstallStepThreaded(package, unpack_size, _unpack_factor) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUnpackArchive::thread_step -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallToken P3DPackage::InstallStepUnpackArchive:: thread_step() { string source_pathname = _package->get_archive_file_pathname(); @@ -2098,22 +1950,18 @@ thread_step() { return IT_step_complete; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepUnpackArchive::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::InstallStepUnpackArchive:: output(ostream &out) { out << "InstallStepUnpackArchive(" << _package->get_package_name() << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepApplyPatch::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallStepApplyPatch:: InstallStepApplyPatch(P3DPackage *package, const FileSpec &patchfile, const FileSpec &source, const FileSpec &target) : @@ -2122,11 +1970,9 @@ InstallStepApplyPatch(P3DPackage *package, const FileSpec &patchfile, { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepApplyPatch::thread_step -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPackage::InstallToken P3DPackage::InstallStepApplyPatch:: thread_step() { // Open the patchfile @@ -2153,11 +1999,9 @@ thread_step() { return IT_step_complete; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPackage::InstallStepApplyPatch::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPackage::InstallStepApplyPatch:: output(ostream &out) { out << "InstallStepApplyPatch(" << _package->get_package_name() << ")"; diff --git a/direct/src/plugin/p3dPackage.h b/direct/src/plugin/p3dPackage.h index 775fda83ee..b65290f836 100644 --- a/direct/src/plugin/p3dPackage.h +++ b/direct/src/plugin/p3dPackage.h @@ -1,16 +1,15 @@ -// Filename: p3dPackage.h -// Created by: drose (12Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPackage.h + * @author drose + * @date 2009-06-12 + */ #ifndef P3DPACKAGE_H #define P3DPACKAGE_H @@ -26,23 +25,20 @@ class P3DHost; class P3DInstance; class P3DTemporaryFile; -//////////////////////////////////////////////////////////////////// -// Class : P3DPackage -// Description : This corresponds to a downloadable, patchable -// package, and all its constituent files. For -// instance, a particular version of the Panda3D -// runtime, which consists of a bunch of dll's -// downloaded in a single tar file, is a package. -// -// The core API is responsible for managing these -// packages on disk, downloading new versions when -// needed, and removing stale versions to limit disk -// space waste. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to a downloadable, patchable package, and all its + * constituent files. For instance, a particular version of the Panda3D + * runtime, which consists of a bunch of dll's downloaded in a single tar + * file, is a package. + * + * The core API is responsible for managing these packages on disk, + * downloading new versions when needed, and removing stale versions to limit + * disk space waste. + */ class P3DPackage { private: P3DPackage(P3DHost *host, - const string &package_name, + const string &package_name, const string &package_version, const string &package_platform, const string &alt_host); @@ -171,7 +167,7 @@ private: bool _thread_started; InstallToken _thread_token; size_t _thread_bytes_done; - }; + }; class InstallStepUncompressFile : public InstallStepThreaded { public: @@ -234,7 +230,7 @@ private: void report_progress(InstallStep *step); void report_info_ready(); void report_done(bool success); - Download *start_download(DownloadType dtype, const string &urlbase, + Download *start_download(DownloadType dtype, const string &urlbase, const string &pathname, const FileSpec &file_spec); void set_active_download(Download *download); void set_saved_download(Download *download); diff --git a/direct/src/plugin/p3dPatchFinder.I b/direct/src/plugin/p3dPatchFinder.I index 6e9264d58e..af066807ca 100644 --- a/direct/src/plugin/p3dPatchFinder.I +++ b/direct/src/plugin/p3dPatchFinder.I @@ -1,14 +1,12 @@ -// Filename: p3dPatchFinder.I -// Created by: drose (27Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchFinder.I + * @author drose + * @date 2009-09-27 + */ diff --git a/direct/src/plugin/p3dPatchFinder.cxx b/direct/src/plugin/p3dPatchFinder.cxx index 370a709a4a..c3e5b80c86 100644 --- a/direct/src/plugin/p3dPatchFinder.cxx +++ b/direct/src/plugin/p3dPatchFinder.cxx @@ -1,24 +1,21 @@ -// Filename: p3dPatchFinder.cxx -// Created by: drose (27Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchFinder.cxx + * @author drose + * @date 2009-09-27 + */ #include "p3dPatchFinder.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::PackageVersion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder::PackageVersion:: PackageVersion(const PackageVersionKey &key) : _package_name(key._package_name), @@ -31,34 +28,28 @@ PackageVersion(const PackageVersionKey &key) : _package_base = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::PackageVersion::get_patch_chain -// Access: Public -// Description: Fills chain with the list of patches that, when -// applied in sequence to the indicated PackageVersion -// object, produces this PackageVersion object. Returns -// false if no chain can be found. -//////////////////////////////////////////////////////////////////// +/** + * Fills chain with the list of patches that, when applied in sequence to the + * indicated PackageVersion object, produces this PackageVersion object. + * Returns false if no chain can be found. + */ bool P3DPatchFinder::PackageVersion:: get_patch_chain(Patchfiles &chain, PackageVersion *start_pv, const PackageVersionsList &already_visited_in) { chain.clear(); if (this == start_pv) { - // We're already here. A zero-length patch chain is therefore the - // answer. + // We're already here. A zero-length patch chain is therefore the answer. return true; } if (::find(already_visited_in.begin(), already_visited_in.end(), this) != already_visited_in.end()) { - // We've already been here; this is a loop. Avoid infinite - // recursion. + // We've already been here; this is a loop. Avoid infinite recursion. return false; } - // Yeah, we make a new copy of this vector at each stage of the - // recursion. This could be made much faster with a linked list - // instead, but I'm working on the assumption that there will be no - // more than a few dozen patchfiles, in which case this naive - // approach should be fast enough. + // Yeah, we make a new copy of this vector at each stage of the recursion. + // This could be made much faster with a linked list instead, but I'm + // working on the assumption that there will be no more than a few dozen + // patchfiles, in which case this naive approach should be fast enough. PackageVersionsList already_visited = already_visited_in; already_visited.push_back(this); @@ -79,16 +70,14 @@ get_patch_chain(Patchfiles &chain, PackageVersion *start_pv, } } - // If found_any is true, we've already filled chain with the - // shortest path found. + // If found_any is true, we've already filled chain with the shortest path + // found. return found_any; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::PackageVersionKey::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder::PackageVersionKey:: PackageVersionKey(const string &package_name, const string &platform, @@ -103,11 +92,9 @@ PackageVersionKey(const string &package_name, { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::PackageVersionKey::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool P3DPatchFinder::PackageVersionKey:: operator < (const PackageVersionKey &other) const { if (_package_name != other._package_name) { @@ -125,11 +112,9 @@ operator < (const PackageVersionKey &other) const { return _file.compare_hash(other._file) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::PackageVersionKey::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DPatchFinder::PackageVersionKey:: output(ostream &out) const { out << "(" << _package_name << ", " << _platform << ", " << _version @@ -138,11 +123,9 @@ output(ostream &out) const { out << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Patchfile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder::Patchfile:: Patchfile(Package *package) : _package(package), @@ -155,33 +138,26 @@ Patchfile(Package *package) : _host_url = package->_host_url; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Patchfile::get_source_key -// Access: Public -// Description: Returns the key for locating the package that this -// patchfile can be applied to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key for locating the package that this patchfile can be applied + * to. + */ P3DPatchFinder::PackageVersionKey P3DPatchFinder::Patchfile:: get_source_key() const { return PackageVersionKey(_package_name, _platform, _version, _host_url, _source_file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Patchfile::get_target_key -// Access: Public -// Description: Returns the key for locating the package that this -// patchfile will generate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key for locating the package that this patchfile will generate. + */ P3DPatchFinder::PackageVersionKey P3DPatchFinder::Patchfile:: get_target_key() const { return PackageVersionKey(_package_name, _platform, _version, _host_url, _target_file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Patchfile::load_xml -// Access: Public -// Description: Reads the data structures from an xml file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data structures from an xml file. + */ void P3DPatchFinder::Patchfile:: load_xml(TiXmlElement *xpatch) { const char *package_name_cstr = xpatch->Attribute("name"); @@ -213,11 +189,9 @@ load_xml(TiXmlElement *xpatch) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Package::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder::Package:: Package() { _current_pv = NULL; @@ -225,45 +199,34 @@ Package() { _got_base_file = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Package::get_current_key -// Access: Public -// Description: Returns the key to locate the current version of this -// package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key to locate the current version of this package. + */ P3DPatchFinder::PackageVersionKey P3DPatchFinder::Package:: get_current_key() const { return PackageVersionKey(_package_name, _platform, _version, _host_url, _current_file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Package::get_base_key -// Access: Public -// Description: Returns the key to locate the "base" or oldest -// version of this package. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key to locate the "base" or oldest version of this package. + */ P3DPatchFinder::PackageVersionKey P3DPatchFinder::Package:: get_base_key() const { return PackageVersionKey(_package_name, _platform, _version, _host_url, _base_file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Package::get_generic_key -// Access: Public -// Description: Returns the key that has the indicated hash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key that has the indicated hash. + */ P3DPatchFinder::PackageVersionKey P3DPatchFinder::Package:: get_generic_key(const FileSpec &file) const { return PackageVersionKey(_package_name, _platform, _version, _host_url, file); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Package::read_desc_file -// Access: Public -// Description: Reads the package's desc file for the package -// information. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the package's desc file for the package information. Returns true on + * success, false on failure. + */ bool P3DPatchFinder::Package:: read_desc_file(TiXmlDocument *doc) { TiXmlElement *xpackage = doc->FirstChildElement("package"); @@ -313,34 +276,26 @@ read_desc_file(TiXmlDocument *doc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder:: P3DPatchFinder() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchFinder:: ~P3DPatchFinder() { // TODO. Cleanup nicely. } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::get_patch_chain_to_current -// Access: Public -// Description: Loads the package defined in the indicated desc file, -// and constructs a patch chain from the version -// represented by file to the current version of this -// package, if possible. Returns true if successful, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Loads the package defined in the indicated desc file, and constructs a + * patch chain from the version represented by file to the current version of + * this package, if possible. Returns true if successful, false otherwise. + */ bool P3DPatchFinder:: get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, const FileSpec &file) { @@ -362,14 +317,10 @@ get_patch_chain_to_current(Patchfiles &chain, TiXmlDocument *doc, } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::read_package_desc_file -// Access: Public -// Description: Reads a desc file associated with a particular -// package, and adds the package to -// _packages. Returns the Package object, or -// NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads a desc file associated with a particular package, and adds the + * package to _packages. Returns the Package object, or NULL on failure. + */ P3DPatchFinder::Package *P3DPatchFinder:: read_package_desc_file(TiXmlDocument *doc) { Package *package = new Package; @@ -382,12 +333,10 @@ read_package_desc_file(TiXmlDocument *doc) { return package; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::build_patch_chains -// Access: Public -// Description: Builds up the chains of PackageVersions and the -// patchfiles that connect them. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the chains of PackageVersions and the patchfiles that connect + * them. + */ void P3DPatchFinder:: build_patch_chains() { Packages::iterator pi; @@ -415,12 +364,9 @@ build_patch_chains() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::get_package_version -// Access: Public -// Description: Returns a shared PackageVersion object for the -// indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Returns a shared PackageVersion object for the indicated key. + */ P3DPatchFinder::PackageVersion *P3DPatchFinder:: get_package_version(const PackageVersionKey &key) { assert(!key._package_name.empty()); @@ -435,11 +381,9 @@ get_package_version(const PackageVersionKey &key) { return pv; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchFinder::record_patchfile -// Access: Public -// Description: Adds the indicated patchfile to the patch chains. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated patchfile to the patch chains. + */ void P3DPatchFinder:: record_patchfile(Patchfile *patchfile) { PackageVersion *from_pv = get_package_version(patchfile->get_source_key()); diff --git a/direct/src/plugin/p3dPatchFinder.h b/direct/src/plugin/p3dPatchFinder.h index b022d61456..d3ee7d02b7 100644 --- a/direct/src/plugin/p3dPatchFinder.h +++ b/direct/src/plugin/p3dPatchFinder.h @@ -1,16 +1,15 @@ -// Filename: p3dPatchFinder.h -// Created by: drose (27Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchFinder.h + * @author drose + * @date 2009-09-27 + */ #ifndef P3DPATCHFINDER_H #define P3DPATCHFINDER_H @@ -21,16 +20,14 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : P3DPatchFinder -// Description : This class is used to reconstruct the patch -// chain--the chain of patch files needed to generate a -// file--for downloading a package via patches, rather -// than downloading the entire file. -// -// It is similar to PatchMaker.py, except it only reads -// patches, it does not generate them. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to reconstruct the patch chain--the chain of patch files + * needed to generate a file--for downloading a package via patches, rather + * than downloading the entire file. + * + * It is similar to PatchMaker.py, except it only reads patches, it does not + * generate them. + */ class P3DPatchFinder { public: class Package; @@ -40,8 +37,8 @@ public: typedef vector Patchfiles; typedef vector PackageVersionsList; - // This class is used to index into a map to locate PackageVersion - // objects, below. + // This class is used to index into a map to locate PackageVersion objects, + // below. class PackageVersionKey { public: PackageVersionKey(const string &package_name, @@ -60,9 +57,9 @@ public: FileSpec _file; }; - // A specific version of a package. This is not just a package's - // "version" string; it also corresponds to the particular patch - // version, which increments independently of the "version". + // A specific version of a package. This is not just a package's "version" + // string; it also corresponds to the particular patch version, which + // increments independently of the "version". class PackageVersion { public: PackageVersion(const PackageVersionKey &key); @@ -78,8 +75,8 @@ public: FileSpec _file; string _print_name; - // The Package object that produces this version if this is the - // current form or the base form, respectively. + // The Package object that produces this version if this is the current + // form or the base form, respectively. Package *_package_current; Package *_package_base; @@ -122,8 +119,8 @@ public: PackageVersion *_to_pv; }; - // This is a particular package. This contains all of the - // information extracted from the package's desc file. + // This is a particular package. This contains all of the information + // extracted from the package's desc file. class Package { public: Package(); @@ -180,4 +177,3 @@ inline ostream &operator << (ostream &out, const P3DPatchFinder::PackageVersionK } #endif - diff --git a/direct/src/plugin/p3dPatchfileReader.I b/direct/src/plugin/p3dPatchfileReader.I index 1d884f282c..9e290b43c8 100644 --- a/direct/src/plugin/p3dPatchfileReader.I +++ b/direct/src/plugin/p3dPatchfileReader.I @@ -1,57 +1,45 @@ -// Filename: p3dPatchfileReader.I -// Created by: drose (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchfileReader.I + * @author drose + * @date 2009-09-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::is_open -// Access: Public -// Description: Returns true if the patchfile is currently open, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the patchfile is currently open, false otherwise. + */ inline bool P3DPatchfileReader:: is_open() const { return _is_open; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::get_bytes_written -// Access: Public -// Description: Returns the number of bytes written to the output -// file so far during the patching process. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes written to the output file so far during the + * patching process. + */ inline size_t P3DPatchfileReader:: get_bytes_written() const { return _bytes_written; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::get_success -// Access: Public -// Description: Returns true if the patching process has completed -// successfully, false if it has failed or has not yet -// completed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the patching process has completed successfully, false if + * it has failed or has not yet completed. + */ inline bool P3DPatchfileReader:: get_success() const { return _success; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::read_uint16 -// Access: Private -// Description: Extracts an unsigned short from the patchfile. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned short from the patchfile. + */ inline unsigned int P3DPatchfileReader:: read_uint16() { unsigned int a = _patch_in.get(); @@ -59,11 +47,9 @@ read_uint16() { return (b << 8) | a; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::read_uint32 -// Access: Private -// Description: Extracts an unsigned long from the patchfile. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned long from the patchfile. + */ inline unsigned int P3DPatchfileReader:: read_uint32() { unsigned int a = _patch_in.get(); @@ -73,11 +59,9 @@ read_uint32() { return (d << 24) | (c << 16) | (b << 8) | a; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::read_int32 -// Access: Private -// Description: Extracts a signed long from the patchfile. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed long from the patchfile. + */ inline int P3DPatchfileReader:: read_int32() { unsigned int a = _patch_in.get(); diff --git a/direct/src/plugin/p3dPatchfileReader.cxx b/direct/src/plugin/p3dPatchfileReader.cxx index 417eac86ce..255bed8477 100644 --- a/direct/src/plugin/p3dPatchfileReader.cxx +++ b/direct/src/plugin/p3dPatchfileReader.cxx @@ -1,25 +1,22 @@ -// Filename: p3dPatchfileReader.cxx -// Created by: drose (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchfileReader.cxx + * @author drose + * @date 2009-09-28 + */ #include "p3dPatchfileReader.h" #include "wstring_encode.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchfileReader:: P3DPatchfileReader(const string &package_dir, const FileSpec &patchfile, const FileSpec &source, const FileSpec &target) : @@ -33,31 +30,25 @@ P3DPatchfileReader(const string &package_dir, const FileSpec &patchfile, _success = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPatchfileReader:: ~P3DPatchfileReader() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::open_read -// Access: Public -// Description: Opens the named patchfile for reading, reads the -// header, and validates the inputs. Returns true on -// success, false otherwise. If this returns false, you -// should immediately call close(), or let this object -// destruct. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named patchfile for reading, reads the header, and validates the + * inputs. Returns true on success, false otherwise. If this returns false, + * you should immediately call close(), or let this object destruct. + */ bool P3DPatchfileReader:: open_read() { close(); - // Synthesize an output filename, in case the source and the target - // refer to the same filename. + // Synthesize an output filename, in case the source and the target refer to + // the same filename. _output_pathname = _target.get_pathname(_package_dir); _output_pathname += ".tmp"; @@ -102,8 +93,8 @@ open_read() { return false; } - // Read the patchfile header and validate it against the hashes we - // were given. + // Read the patchfile header and validate it against the hashes we were + // given. unsigned int magic_number = read_uint32(); if (magic_number != 0xfeebfaac) { nout << "Not a valid patchfile: " << patch_pathname << "\n"; @@ -112,9 +103,8 @@ open_read() { unsigned int version = read_uint16(); if (version != 2) { - // This code only knows about patchfile version 2. If the - // patchfile code is updated, we have to update this code - // accordingly. + // This code only knows about patchfile version 2. If the patchfile code + // is updated, we have to update this code accordingly. nout << "Unsupported patchfile version: " << version << "\n"; return false; } @@ -149,15 +139,11 @@ open_read() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::step -// Access: Public -// Description: Performs one incremental step of the patching -// operation. Returns true if the operation should -// continue and step() should be called again, false if -// the patching is done (either successfully, or due to -// failure). -//////////////////////////////////////////////////////////////////// +/** + * Performs one incremental step of the patching operation. Returns true if + * the operation should continue and step() should be called again, false if + * the patching is done (either successfully, or due to failure). + */ bool P3DPatchfileReader:: step() { assert(_is_open); @@ -195,8 +181,8 @@ step() { return false; } - // Set the _success flag true, so close() will move the finished - // file into place. + // Set the _success flag true, so close() will move the finished file into + // place. _success = true; close(); @@ -212,14 +198,11 @@ step() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::close -// Access: Public -// Description: Closes the previously-opened files, and moves the -// output file into place. This also deletes the -// patchfile, assuming it will not be needed after it -// has been used. -//////////////////////////////////////////////////////////////////// +/** + * Closes the previously-opened files, and moves the output file into place. + * This also deletes the patchfile, assuming it will not be needed after it + * has been used. + */ void P3DPatchfileReader:: close() { if (!_is_open) { @@ -231,7 +214,7 @@ close() { _patch_in.close(); _source_in.close(); _target_out.close(); - + // Delete the patchfile. string patch_pathname = _patchfile.get_pathname(_package_dir); #ifdef _WIN32 @@ -258,14 +241,11 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPatchfileReader::copy_bytes -// Access: Private -// Description: Copies the indicated number of bytes from the -// indicated stream onto the output stream. Returns -// true on success, false if the input stream didn't -// have enough bytes. -//////////////////////////////////////////////////////////////////// +/** + * Copies the indicated number of bytes from the indicated stream onto the + * output stream. Returns true on success, false if the input stream didn't + * have enough bytes. + */ bool P3DPatchfileReader:: copy_bytes(istream &in, size_t copy_byte_count) { static const size_t buffer_size = 8192; diff --git a/direct/src/plugin/p3dPatchfileReader.h b/direct/src/plugin/p3dPatchfileReader.h index f8d41b4c26..1ad097a5ba 100644 --- a/direct/src/plugin/p3dPatchfileReader.h +++ b/direct/src/plugin/p3dPatchfileReader.h @@ -1,16 +1,15 @@ -// Filename: p3dPatchfileReader.h -// Created by: drose (27Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPatchfileReader.h + * @author drose + * @date 2009-09-27 + */ #ifndef P3DPATCHFILEREADER_H #define P3DPATCHFILEREADER_H @@ -19,18 +18,15 @@ #include "p3dInstanceManager.h" // for openssl #include "fileSpec.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DPatchfileReader -// Description : A read-only implementation of Panda's patchfile -// format, for applying patches. -// -// This object assumes that the sourcefile has been -// already validated against its md5 hash, and does not -// validate it again. It *does* verify that the md5 -// hash in source and target match those read in the -// patchfile header; and it verifies the md5 hash on the -// target after completion. -//////////////////////////////////////////////////////////////////// +/** + * A read-only implementation of Panda's patchfile format, for applying + * patches. + * + * This object assumes that the sourcefile has been already validated against + * its md5 hash, and does not validate it again. It *does* verify that the + * md5 hash in source and target match those read in the patchfile header; and + * it verifies the md5 hash on the target after completion. + */ class P3DPatchfileReader { public: P3DPatchfileReader(const string &package_dir, @@ -43,7 +39,7 @@ public: inline bool is_open() const; bool step(); - inline size_t get_bytes_written() const; + inline size_t get_bytes_written() const; inline bool get_success() const; void close(); diff --git a/direct/src/plugin/p3dPythonMain.cxx b/direct/src/plugin/p3dPythonMain.cxx index ef5b83e282..76cf92c7e4 100644 --- a/direct/src/plugin/p3dPythonMain.cxx +++ b/direct/src/plugin/p3dPythonMain.cxx @@ -1,16 +1,15 @@ -// Filename: p3dPythonMain.cxx -// Created by: drose (29Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonMain.cxx + * @author drose + * @date 2009-08-29 + */ #include "run_p3dpython.h" @@ -22,16 +21,15 @@ using namespace std; #if defined(_WIN32) && defined(NON_CONSOLE) -// On Windows, we may need to build p3dpythonw.exe, a non-console -// version of this program. +// On Windows, we may need to build p3dpythonw.exe, a non-console version of +// this program. // We'll wrap the main() function with our own startup WinMain(). #define main local_main int main(int argc, char *argv[]); -// Returns a newly-allocated string representing the quoted argument -// beginning at p. Advances p to the first character following the -// close quote. +// Returns a newly-allocated string representing the quoted argument beginning +// at p. Advances p to the first character following the close quote. static char * parse_quoted_arg(char *&p) { char quote = *p; @@ -50,8 +48,7 @@ parse_quoted_arg(char *&p) { } // Returns a newly-allocated string representing the unquoted argument -// beginning at p. Advances p to the first whitespace following the -// argument. +// beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { string result; @@ -62,12 +59,12 @@ parse_unquoted_arg(char *&p) { return strdup(result.c_str()); } -int WINAPI +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); vector argv; - + char *p = command_line; while (*p != '\0') { if (*p == '"') { @@ -89,13 +86,11 @@ WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { } #endif // NON_CONSOLE -//////////////////////////////////////////////////////////////////// -// Function: main -// Description: This is a trivial main() function that invokes -// P3DPythonRun. It's used to build p3dpython.exe, -// which is the preferred way to run Python in a child -// process, as a separate executable. -//////////////////////////////////////////////////////////////////// +/** + * This is a trivial main() function that invokes P3DPythonRun. It's used to + * build p3dpython.exe, which is the preferred way to run Python in a child + * process, as a separate executable. + */ int main(int argc, char *argv[]) { const char *program_name = argv[0]; diff --git a/direct/src/plugin/p3dPythonObject.cxx b/direct/src/plugin/p3dPythonObject.cxx index 2195321b22..3a771dbf72 100644 --- a/direct/src/plugin/p3dPythonObject.cxx +++ b/direct/src/plugin/p3dPythonObject.cxx @@ -1,24 +1,21 @@ -// Filename: p3dPythonObject.cxx -// Created by: drose (03Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonObject.cxx + * @author drose + * @date 2009-07-03 + */ #include "p3dPythonObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPythonObject:: P3DPythonObject(P3DSession *session, int object_id) : _session(session), @@ -27,36 +24,29 @@ P3DPythonObject(P3DSession *session, int object_id) : _session->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPythonObject:: ~P3DPythonObject() { - // When the P3DPythonObject wrapper goes away, we have to inform the - // child process that we no longer need the corresponding PyObject - // to be kept around. + // When the P3DPythonObject wrapper goes away, we have to inform the child + // process that we no longer need the corresponding PyObject to be kept + // around. _session->drop_pyobj(_object_id); p3d_unref_delete(_session); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DPythonObject:: get_type() { return P3D_OT_object; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DPythonObject:: get_bool() { bool bresult = 0; @@ -65,17 +55,14 @@ get_bool() { if (result != NULL) { bresult = P3D_OBJECT_GET_BOOL(result); P3D_OBJECT_DECREF(result); - } + } return bresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_int -// Access: Public, Virtual -// Description: Returns the object value coerced to an integer, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to an integer, if possible. + */ int P3DPythonObject:: get_int() { int iresult = 0; @@ -84,17 +71,14 @@ get_int() { if (result != NULL) { iresult = P3D_OBJECT_GET_INT(result); P3D_OBJECT_DECREF(result); - } + } return iresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_float -// Access: Public, Virtual -// Description: Returns the object value coerced to a floating-point -// value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a floating-point value, if possible. + */ double P3DPythonObject:: get_float() { double fresult = 0.0; @@ -103,17 +87,15 @@ get_float() { if (result != NULL) { fresult = P3D_OBJECT_GET_FLOAT(result); P3D_OBJECT_DECREF(result); - } + } return fresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DPythonObject:: make_string(string &value) { P3D_object *result = call("__str__", true, NULL, 0); @@ -125,16 +107,13 @@ make_string(string &value) { delete[] buffer; P3D_OBJECT_DECREF(result); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_property -// Access: Public, Virtual -// Description: Returns the named property element in the object. The -// return value is a new-reference P3D_object, or NULL -// on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * new-reference P3D_object, or NULL on error. + */ P3D_object *P3DPythonObject:: get_property(const string &property) { P3D_object *params[1]; @@ -145,13 +124,10 @@ get_property(const string &property) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::set_property -// Access: Public, Virtual -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool P3DPythonObject:: set_property(const string &property, bool needs_response, P3D_object *value) { if (!_session->get_matches_script_origin()) { @@ -162,15 +138,12 @@ set_property(const string &property, bool needs_response, P3D_object *value) { return set_property_insecure(property, needs_response, value); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::set_property_insecure -// Access: Public -// Description: Works as set_property(), but does not check the -// matches_script_origin flag. Intended to be called -// internally only, never to be called from Javascript. -//////////////////////////////////////////////////////////////////// +/** + * Works as set_property(), but does not check the matches_script_origin flag. + * Intended to be called internally only, never to be called from Javascript. + */ bool P3DPythonObject:: -set_property_insecure(const string &property, bool needs_response, +set_property_insecure(const string &property, bool needs_response, P3D_object *value) { bool bresult = !needs_response; @@ -199,12 +172,9 @@ set_property_insecure(const string &property, bool needs_response, return bresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::has_method -// Access: Public, Virtual -// Description: Returns true if the named method exists on this -// object, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named method exists on this object, false otherwise. + */ bool P3DPythonObject:: has_method(const string &method_name) { // First, check the cache. @@ -228,27 +198,22 @@ has_method(const string &method_name) { P3D_OBJECT_DECREF(result); } - // Save the cached result, so we don't have to keep asking this - // question. We assume that the set of methods on an object don't - // change substantially, so we can get away with keeping this cache. + // Save the cached result, so we don't have to keep asking this question. + // We assume that the set of methods on an object don't change + // substantially, so we can get away with keeping this cache. (*hi).second = bresult; return bresult; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::call -// Access: Public, Virtual -// Description: Invokes the named method on the object, passing the -// indicated parameters. If the method name is empty, -// invokes the object itself. -// -// If needs_response is true, the return value is a -// new-reference P3D_object on success, or NULL on -// failure. If needs_response is false, the return -// value is always NULL, and there is no way to -// determine success or failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes the named method on the object, passing the indicated parameters. + * If the method name is empty, invokes the object itself. + * + * If needs_response is true, the return value is a new-reference P3D_object + * on success, or NULL on failure. If needs_response is false, the return + * value is always NULL, and there is no way to determine success or failure. + */ P3D_object *P3DPythonObject:: call(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { @@ -260,13 +225,10 @@ call(const string &method_name, bool needs_response, return call_insecure(method_name, needs_response, params, num_params); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::call_insecure -// Access: Public -// Description: Works as call(), but does not check the -// matches_script_origin flag. Intended to be called -// internally only, never to be called from Javascript. -//////////////////////////////////////////////////////////////////// +/** + * Works as call(), but does not check the matches_script_origin flag. + * Intended to be called internally only, never to be called from Javascript. + */ P3D_object *P3DPythonObject:: call_insecure(const string &method_name, bool needs_response, P3D_object *params[], int num_params) { @@ -289,15 +251,14 @@ call_insecure(const string &method_name, bool needs_response, doc->LinkEndChild(xcommand); - // If no response is requested, send the command out in a vacuum, - // and return NULL. + // If no response is requested, send the command out in a vacuum, and return + // NULL. if (!needs_response) { _session->send_command(doc); return NULL; } - // If a response is requested, we have to send the command and wait - // for it. + // If a response is requested, we have to send the command and wait for it. TiXmlDocument *response = _session->command_and_response(doc); P3D_object *result = NULL; @@ -315,13 +276,10 @@ call_insecure(const string &method_name, bool needs_response, return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::output -// Access: Public, Virtual -// Description: Writes a formatted representation of the value to the -// indicated string. This is intended for developer -// assistance. -//////////////////////////////////////////////////////////////////// +/** + * Writes a formatted representation of the value to the indicated string. + * This is intended for developer assistance. + */ void P3DPythonObject:: output(ostream &out) { P3D_object *result = call("__repr__", true, NULL, 0); @@ -329,25 +287,21 @@ output(ostream &out) { if (result != NULL) { out << ": " << *result; P3D_OBJECT_DECREF(result); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::fill_xml -// Access: Public, Virtual -// Description: If this object has a valid XML representation for the -// indicated session (that hasn't already been -// implemented by the generic code in P3DSession), this -// method will apply it to the indicated "value" element -// and return true. Otherwise, this method will leave -// the element unchanged and return false. -//////////////////////////////////////////////////////////////////// +/** + * If this object has a valid XML representation for the indicated session + * (that hasn't already been implemented by the generic code in P3DSession), + * this method will apply it to the indicated "value" element and return true. + * Otherwise, this method will leave the element unchanged and return false. + */ bool P3DPythonObject:: fill_xml(TiXmlElement *xvalue, P3DSession *session) { if (session == _session) { - // If it's a P3DPythonObject from the same session, just send - // the object_id down, since the actual implementation of this - // object exists (as a Python object) in the sub-process space. + // If it's a P3DPythonObject from the same session, just send the + // object_id down, since the actual implementation of this object exists + // (as a Python object) in the sub-process space. xvalue->SetAttribute("type", "python"); xvalue->SetAttribute("object_id", _object_id); return true; @@ -357,38 +311,29 @@ fill_xml(TiXmlElement *xvalue, P3DSession *session) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::as_python_object -// Access: Public, Virtual -// Description: Returns this object, downcast to a P3DPythonObject, -// if it is in fact an object of that type; or NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object, downcast to a P3DPythonObject, if it is in fact an + * object of that type; or NULL if it is not. + */ P3DPythonObject *P3DPythonObject:: as_python_object() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_session -// Access: Public -// Description: Returns the session that this object is identified -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the session that this object is identified with. + */ P3DSession *P3DPythonObject:: get_session() { return _session; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonObject::get_object_id -// Access: Public -// Description: Returns the object_id number that is used to uniquely -// identify this object in the XML stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object_id number that is used to uniquely identify this object + * in the XML stream. + */ int P3DPythonObject:: get_object_id() { return _object_id; } - diff --git a/direct/src/plugin/p3dPythonObject.h b/direct/src/plugin/p3dPythonObject.h index 8a98e23f0f..980617257e 100644 --- a/direct/src/plugin/p3dPythonObject.h +++ b/direct/src/plugin/p3dPythonObject.h @@ -1,16 +1,15 @@ -// Filename: p3dPythonObject.h -// Created by: drose (02Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonObject.h + * @author drose + * @date 2009-07-02 + */ #ifndef P3DPYTHONOBJECT_H #define P3DPYTHONOBJECT_H @@ -20,14 +19,11 @@ class P3DSession; -//////////////////////////////////////////////////////////////////// -// Class : P3DPythonObject -// Description : An object type that references a PyObject in the -// subordinate process. It allows querying and/or -// modifying the state of the referenced PyObject, via -// clever XML communication in -// P3DSession::command_and_response(). -//////////////////////////////////////////////////////////////////// +/** + * An object type that references a PyObject in the subordinate process. It + * allows querying and/or modifying the state of the referenced PyObject, via + * clever XML communication in P3DSession::command_and_response(). + */ class P3DPythonObject : public P3DObject { public: P3DPythonObject(P3DSession *session, int object_id); @@ -69,4 +65,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dPythonRun.I b/direct/src/plugin/p3dPythonRun.I index c16c136d8b..dabbe7ef8f 100644 --- a/direct/src/plugin/p3dPythonRun.I +++ b/direct/src/plugin/p3dPythonRun.I @@ -1,14 +1,12 @@ -// Filename: p3dPythonRun.I -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonRun.I + * @author drose + * @date 2009-06-05 + */ diff --git a/direct/src/plugin/p3dPythonRun.cxx b/direct/src/plugin/p3dPythonRun.cxx index e0d1f71b82..cb7f58fb22 100644 --- a/direct/src/plugin/p3dPythonRun.cxx +++ b/direct/src/plugin/p3dPythonRun.cxx @@ -1,16 +1,15 @@ -// Filename: p3dPythonRun.cxx -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonRun.cxx + * @author drose + * @date 2009-06-05 + */ #include "p3dPythonRun.h" #include "asyncTaskManager.h" @@ -26,18 +25,16 @@ extern "C" { extern struct _frozen _PyImport_FrozenModules[]; }; -// There is only one P3DPythonRun object in any given process space. -// Makes the statics easier to deal with, and we don't need multiple -// instances of this thing. +// There is only one P3DPythonRun object in any given process space. Makes +// the statics easier to deal with, and we don't need multiple instances of +// this thing. P3DPythonRun *P3DPythonRun::_global_ptr = NULL; TypeHandle P3DPythonRun::P3DWindowHandle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPythonRun:: P3DPythonRun(const char *program_name, const char *archive_file, FHandle input_handle, FHandle output_handle, @@ -98,12 +95,12 @@ P3DPythonRun(const char *program_name, const char *archive_file, // Prevent Python from complaining about finding the standard modules. Py_FrozenFlag = 1; - // This contains the modules we need in order to call Py_Initialize, - // as well as the VFSImporter. + // This contains the modules we need in order to call Py_Initialize, as well + // as the VFSImporter. PyImport_FrozenModules = _PyImport_FrozenModules; - // Initialize Python. It appears to be important to do this before - // we open the pipe streams and spawn the thread, below. + // Initialize Python. It appears to be important to do this before we open + // the pipe streams and spawn the thread, below. #if PY_MAJOR_VERSION >= 3 Py_SetProgramName((wchar_t *)_program_name.c_str()); Py_SetPythonHome((wchar_t *)L""); @@ -126,8 +123,7 @@ P3DPythonRun(const char *program_name, const char *archive_file, } } - // Open the pipe streams with the input and output handles from the - // parent. + // Open the pipe streams with the input and output handles from the parent. _pipe_read.open_read(input_handle); _pipe_write.open_write(output_handle); @@ -141,11 +137,9 @@ P3DPythonRun(const char *program_name, const char *archive_file, spawn_read_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPythonRun:: ~P3DPythonRun() { terminate_session(); @@ -159,33 +153,30 @@ P3DPythonRun:: join_read_thread(); DESTROY_LOCK(_commands_lock); - // Restore the notify stream in case it tries to write to anything - // else after our shutdown. + // Restore the notify stream in case it tries to write to anything else + // after our shutdown. Notify::ptr()->set_ostream_ptr(&cerr, false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::run_python -// Access: Public -// Description: Runs the embedded Python process. This method does -// not return until the plugin is ready to exit. -// -// Returns the exit status, which will be 0 on success. -//////////////////////////////////////////////////////////////////// +/** + * Runs the embedded Python process. This method does not return until the + * plugin is ready to exit. + * + * Returns the exit status, which will be 0 on success. + */ int P3DPythonRun:: run_python() { #if defined(_WIN32) && defined(USE_DEBUG_PYTHON) - // On Windows, in a debug build, we have to preload sys.dll_suffix = - // "_d", so that the Panda DLL preloader can import the correct - // filenames. + // On Windows, in a debug build, we have to preload sys.dll_suffix = "_d", + // so that the Panda DLL preloader can import the correct filenames. PyRun_SimpleString("import sys; sys.dll_suffix = '_d'"); #endif Filename dir = _archive_file.get_dirname(); - // We'll need to synthesize a 'panda3d' module before loading - // VFSImporter. We could simply freeze it, but Python has a bug - // setting __path__ of frozen modules properly. + // We'll need to synthesize a 'panda3d' module before loading VFSImporter. + // We could simply freeze it, but Python has a bug setting __path__ of + // frozen modules properly. PyObject *panda3d_module = PyImport_AddModule("panda3d"); if (panda3d_module == NULL) { nout << "Failed to add panda3d module:\n"; @@ -193,7 +184,7 @@ run_python() { return 1; } - // Set the __path__ such that it can find panda3d/core.pyd, etc. + // Set the __path__ such that it can find panda3dcore.pyd, etc. Filename panda3d_dir(dir, "panda3d"); string dir_str = panda3d_dir.to_os_specific(); PyModule_AddObject(panda3d_module, "__path__", Py_BuildValue("[s#]", dir_str.data(), dir_str.length())); @@ -208,8 +199,8 @@ run_python() { } // Now repair the "direct" and "direct.showbase" trees, which were - // presumably frozen along with the VFSImporter, by setting their - // __path__ such that we can still find the other direct modules. + // presumably frozen along with the VFSImporter, by setting their __path__ + // such that we can still find the other direct modules. Filename direct_dir(dir, "direct"); PyObject *direct_module = PyImport_AddModule("direct"); if (direct_module != NULL) { @@ -236,10 +227,9 @@ run_python() { Py_DECREF(result); Py_DECREF(vfsimporter_module); - // Now, the VFSImporter has been registered, which means we can - // start importing the rest of the Python modules, which are all - // defined in the multifile. First, we need to mount the multifile - // into the VFS. + // Now, the VFSImporter has been registered, which means we can start + // importing the rest of the Python modules, which are all defined in the + // multifile. First, we need to mount the multifile into the VFS. PT(Multifile) mf = new Multifile; if (!mf->open_read(_archive_file)) { nout << "Could not read " << _archive_file << "\n"; @@ -322,7 +312,8 @@ run_python() { Py_DECREF(app_runner_module); Py_DECREF(javascript_module); - // Construct a Python wrapper around our methods we need to expose to Python. + // Construct a Python wrapper around our methods we need to expose to + // Python. static PyMethodDef p3dpython_methods[] = { { "check_comm", P3DPythonRun::st_check_comm, METH_VARARGS, "Poll for communications from the parent process" }, @@ -354,8 +345,8 @@ run_python() { return 1; } - // Now pass that func pointer back to our AppRunner instance, so it - // can call up to us. + // Now pass that func pointer back to our AppRunner instance, so it can call + // up to us. result = PyObject_CallMethod(_runner, (char *)"setRequestFunc", (char *)"N", request_func); if (result == NULL) { PyErr_Print(); @@ -363,17 +354,15 @@ run_python() { } Py_DECREF(result); - // Now add check_comm() as a task. It can be a threaded task, but - // this does mean that application programmers will have to be alert - // to asynchronous calls coming in from JavaScript. We'll put it on - // its own task chain so the application programmer can decide how - // it should be. + // Now add check_comm() as a task. It can be a threaded task, but this does + // mean that application programmers will have to be alert to asynchronous + // calls coming in from JavaScript. We'll put it on its own task chain so + // the application programmer can decide how it should be. AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); PT(AsyncTaskChain) chain = task_mgr->make_task_chain("JavaScript"); - // The default is not threaded (num_threads == 0), but if the app - // programmer decides to enable threads, the default is TP_low - // priority. + // The default is not threaded (num_threads == 0), but if the app programmer + // decides to enable threads, the default is TP_low priority. chain->set_thread_priority(TP_low); PyObject *check_comm = PyObject_GetAttrString(p3dpython, "check_comm"); @@ -398,8 +387,8 @@ run_python() { int status = 1; // An uncaught application exception, and not handled by - // appRunner.exceptionHandler. If it is a SystemExit, extract - // the exit status that we should return. + // appRunner.exceptionHandler. If it is a SystemExit, extract the exit + // status that we should return. if (PyErr_ExceptionMatches(PyExc_SystemExit)) { PyObject *ptype, *ptraceback; PyObject *value = NULL; @@ -449,15 +438,12 @@ run_python() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::set_window_open -// Access: Public -// Description: Called from low-level Panda (via the P3DWindowHandle -// object) when a child window has been attached or -// detached from the browser window. This triggers the -// "onwindowattach" and "onwindowdetach" JavaScript -// notifications. -//////////////////////////////////////////////////////////////////// +/** + * Called from low-level Panda (via the P3DWindowHandle object) when a child + * window has been attached or detached from the browser window. This + * triggers the "onwindowattach" and "onwindowdetach" JavaScript + * notifications. + */ void P3DPythonRun:: set_window_open(P3DCInstance *inst, bool is_open) { TiXmlDocument doc; @@ -474,21 +460,16 @@ set_window_open(P3DCInstance *inst, bool is_open) { write_xml(_pipe_write, &doc, nout); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::request_keyboard_focus -// Access: Public -// Description: Called from low-level Panda (via the P3DWindowHandle -// object) when its main window requires keyboard focus, -// but is unable to assign it directly. This is -// particularly necessary under Windows Vista, where a -// child window of the browser is specifically -// disallowed from being given keyboard focus. -// -// This sends a notify request up to the parent process, -// to ask the parent to manage keyboard events by proxy, -// and send them back down to Panda, again via the -// P3DWindowHandle. -//////////////////////////////////////////////////////////////////// +/** + * Called from low-level Panda (via the P3DWindowHandle object) when its main + * window requires keyboard focus, but is unable to assign it directly. This + * is particularly necessary under Windows Vista, where a child window of the + * browser is specifically disallowed from being given keyboard focus. + * + * This sends a notify request up to the parent process, to ask the parent to + * manage keyboard events by proxy, and send them back down to Panda, again + * via the P3DWindowHandle. + */ void P3DPythonRun:: request_keyboard_focus(P3DCInstance *inst) { TiXmlDocument doc; @@ -501,15 +482,12 @@ request_keyboard_focus(P3DCInstance *inst) { write_xml(_pipe_write, &doc, nout); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::run_interactive_console -// Access: Private -// Description: Gives the user a chance to type interactive Python -// commands, for easy development of a p3d application. -// This method is only called if "interactive_console=1" -// is set as a web token, and "allow_python_dev" is set -// within the application itself. -//////////////////////////////////////////////////////////////////// +/** + * Gives the user a chance to type interactive Python commands, for easy + * development of a p3d application. This method is only called if + * "interactive_console=1" is set as a web token, and "allow_python_dev" is + * set within the application itself. + */ void P3DPythonRun:: run_interactive_console() { #ifdef _WIN32 @@ -517,13 +495,12 @@ run_interactive_console() { SetConsoleCtrlHandler(NULL, false); #endif - // The "readline" module makes the Python prompt friendlier, with - // command history and everything. Simply importing it is - // sufficient. + // The "readline" module makes the Python prompt friendlier, with command + // history and everything. Simply importing it is sufficient. PyObject *readline_module = PyImport_ImportModule("readline"); if (readline_module == NULL) { - // But, the module might not exist on certain platforms. If not, - // no sweat. + // But, the module might not exist on certain platforms. If not, no + // sweat. PyErr_Clear(); } else { Py_DECREF(readline_module); @@ -532,16 +509,12 @@ run_interactive_console() { PyRun_InteractiveLoop(stdin, ""); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::handle_command -// Access: Private -// Description: Handles a command received from the plugin host, via -// an XML syntax on the wire. Ownership of the XML -// document object is passed into this method. -// -// It's important *not* to be holding _commands_lock -// when calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Handles a command received from the plugin host, via an XML syntax on the + * wire. Ownership of the XML document object is passed into this method. + * + * It's important *not* to be holding _commands_lock when calling this method. + */ void P3DPythonRun:: handle_command(TiXmlDocument *doc) { TiXmlElement *xcommand = doc->FirstChildElement("command"); @@ -558,14 +531,14 @@ handle_command(TiXmlDocument *doc) { if (strcmp(cmd, "init") == 0) { assert(!needs_response); - // The only purpose of the "init" command is to send us a - // unique session ID, which in fact we don't do much with. + // The only purpose of the "init" command is to send us a unique + // session ID, which in fact we don't do much with. xcommand->Attribute("session_id", &_session_id); - // We do use it to initiate our object id sequence with a - // number at least a little bit distinct from other sessions, - // though. No technical requirement that we do this, but it - // does make debugging the logs a bit easier. + // We do use it to initiate our object id sequence with a number at + // least a little bit distinct from other sessions, though. No + // technical requirement that we do this, but it does make debugging + // the logs a bit easier. _next_sent_id = _session_id * 1000; PyObject *obj = PyObject_CallMethod(_runner, (char*)"setSessionId", (char *)"i", _session_id); @@ -597,9 +570,8 @@ handle_command(TiXmlDocument *doc) { } else if (strcmp(cmd, "windows_message") == 0) { assert(!needs_response); - // This is a special message that we use to proxy keyboard - // events from the parent process down into Panda, a necessary - // hack on Vista. + // This is a special message that we use to proxy keyboard events from + // the parent process down into Panda, a necessary hack on Vista. int instance_id = 0, msg = 0, wparam = 0, lparam = 0; xcommand->Attribute("instance_id", &instance_id); xcommand->Attribute("msg", &msg); @@ -616,14 +588,14 @@ handle_command(TiXmlDocument *doc) { handle_pyobj_command(xcommand, needs_response, want_response_id); } else if (strcmp(cmd, "script_response") == 0) { - // Response from a script request. In this case, we just - // store it away instead of processing it immediately. + // Response from a script request. In this case, we just store it + // away instead of processing it immediately. MutexHolder holder(_responses_lock); _responses.push_back(doc); - // And now we must return out, instead of deleting the - // document at the bottom of this method. + // And now we must return out, instead of deleting the document at the + // bottom of this method. return; } else if (strcmp(cmd, "drop_pyobj") == 0) { @@ -654,12 +626,10 @@ handle_command(TiXmlDocument *doc) { delete doc; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::handle_pyobj_command -// Access: Private -// Description: Handles the pyobj command, which queries or modifies -// a Python object from the browser scripts. -//////////////////////////////////////////////////////////////////// +/** + * Handles the pyobj command, which queries or modifies a Python object from + * the browser scripts. + */ void P3DPythonRun:: handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, int want_response_id) { @@ -693,8 +663,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, (_runner, (char *)"setBrowserScriptObject", (char *)"N", obj)); } else if (strcmp(op, "call") == 0) { - // Call the named method on the indicated object, or the object - // itself if method_name isn't given. + // Call the named method on the indicated object, or the object itself + // if method_name isn't given. TiXmlElement *xobject = xcommand->FirstChildElement("object"); if (xobject != NULL) { PyObject *obj = xml_to_pyobj(xobject); @@ -744,8 +714,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } else if (strcmp(method_name, "__set_property__") == 0) { // We call these methods __set_property__ et al instead of - // __setattr__ et al, because they do not precisely - // duplicate the Python semantics. + // __setattr__ et al, because they do not precisely duplicate the + // Python semantics. char *property_name; PyObject *value; if (PyArg_ParseTuple(params, "sO", &property_name, &value)) { @@ -760,8 +730,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } } - // If the object supports the mapping protocol, store it - // in the object's dictionary. + // If the object supports the mapping protocol, store it in the + // object's dictionary. if (!success && PyMapping_Check(obj)) { if (PyMapping_SetItemString(obj, property_name, value) != -1) { success = true; @@ -878,8 +848,7 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } Py_DECREF(params); - // Feed the return value back through the XML pipe to the - // caller. + // Feed the return value back through the XML pipe to the caller. if (result != NULL) { xresponse->LinkEndChild(pyobj_to_xml(result)); Py_DECREF(result); @@ -898,17 +867,14 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response, } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::check_comm -// Access: Private -// Description: This method is added to the task manager (via -// st_check_comm, below) so that it gets a call every -// frame. Its job is to check for commands received -// from the plugin host in the parent process. -//////////////////////////////////////////////////////////////////// +/** + * This method is added to the task manager (via st_check_comm, below) so that + * it gets a call every frame. Its job is to check for commands received from + * the plugin host in the parent process. + */ void P3DPythonRun:: check_comm() { - // nout << ":"; + // nout << ":"; ACQUIRE_LOCK(_commands_lock); while (!_commands.empty()) { TiXmlDocument *doc = _commands.front(); @@ -923,47 +889,42 @@ check_comm() { RELEASE_LOCK(_commands_lock); if (!_program_continue) { - // The low-level thread detected an error, for instance pipe - // closed. We should exit gracefully. + // The low-level thread detected an error, for instance pipe closed. We + // should exit gracefully. terminate_session(); return; } - // Sleep to yield the timeslice, but only if we're not running in - // the main thread. + // Sleep to yield the timeslice, but only if we're not running in the main + // thread. if (Thread::get_current_thread() != Thread::get_main_thread()) { Thread::sleep(0.001); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::st_check_comm -// Access: Private, Static -// Description: This is a static Python wrapper around py_check_comm, -// needed to add the function to a PythonTask. -//////////////////////////////////////////////////////////////////// +/** + * This is a static Python wrapper around py_check_comm, needed to add the + * function to a PythonTask. + */ PyObject *P3DPythonRun:: st_check_comm(PyObject *, PyObject *args) { P3DPythonRun::_global_ptr->check_comm(); return Py_BuildValue("i", AsyncTask::DS_cont); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::wait_script_response -// Access: Private -// Description: This method is similar to check_comm(), above, but -// instead of handling all events, it waits for a -// specific script_response ID to come back from the -// browser, and leaves all other events in the queue. -//////////////////////////////////////////////////////////////////// +/** + * This method is similar to check_comm(), above, but instead of handling all + * events, it waits for a specific script_response ID to come back from the + * browser, and leaves all other events in the queue. + */ TiXmlDocument *P3DPythonRun:: wait_script_response(int response_id) { - // nout << "waiting script_response " << response_id << "\n"; + // nout << "waiting script_response " << response_id << "\n"; while (true) { Commands::iterator ci; - // First, walk through the _commands queue to see if there's - // anything that needs immediate processing. + // First, walk through the _commands queue to see if there's anything that + // needs immediate processing. ACQUIRE_LOCK(_commands_lock); for (ci = _commands.begin(); ci != _commands.end(); ++ci) { TiXmlDocument *doc = (*ci); @@ -974,10 +935,9 @@ wait_script_response(int response_id) { if ((cmd != NULL && strcmp(cmd, "script_response") == 0) || xcommand->Attribute("want_response_id") != NULL) { - // This is either a response, or it's a command that will - // want a response itself. In either case we should handle - // it right away. ("handling" a response means moving it to - // the _responses queue.) + // This is either a response, or it's a command that will want a + // response itself. In either case we should handle it right away. + // ("handling" a response means moving it to the _responses queue.) _commands.erase(ci); RELEASE_LOCK(_commands_lock); handle_command(doc); @@ -991,8 +951,8 @@ wait_script_response(int response_id) { } RELEASE_LOCK(_commands_lock); - // Now, walk through the _responses queue to look for the - // particular response we're waiting for. + // Now, walk through the _responses queue to look for the particular + // response we're waiting for. _responses_lock.acquire(); for (ci = _responses.begin(); ci != _responses.end(); ++ci) { TiXmlDocument *doc = (*ci); @@ -1008,7 +968,7 @@ wait_script_response(int response_id) { // This is the response we were waiting for. _responses.erase(ci); _responses_lock.release(); - // nout << "got script_response " << unique_id << "\n"; + // nout << "got script_response " << unique_id << "\n"; return doc; } } @@ -1021,32 +981,28 @@ wait_script_response(int response_id) { } #ifdef _WIN32 - // Make sure we process the Windows event loop while we're - // waiting, or everything that depends on Windows messages will - // starve. + // Make sure we process the Windows event loop while we're waiting, or + // everything that depends on Windows messages will starve. - // We appear to be best off with just a single PeekMessage() call - // here; the full message pump seems to cause problems. + // We appear to be best off with just a single PeekMessage() call here; + // the full message pump seems to cause problems. MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); #endif // _WIN32 - // nout << "."; + // nout << "."; - // It hasn't shown up yet. Give the sub-thread a chance to - // process the input and append it to the queue. + // It hasn't shown up yet. Give the sub-thread a chance to process the + // input and append it to the queue. Thread::force_yield(); } assert(false); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::py_request_func -// Access: Private -// Description: This method is a special Python function that is -// added as a callback to the AppRunner class, to allow -// Python to upcall into this object. -//////////////////////////////////////////////////////////////////// +/** + * This method is a special Python function that is added as a callback to the + * AppRunner class, to allow Python to upcall into this object. + */ PyObject *P3DPythonRun:: py_request_func(PyObject *args) { int instance_id; @@ -1057,9 +1013,8 @@ py_request_func(PyObject *args) { } if (strcmp(request_type, "wait_script_response") == 0) { - // This is a special case. Instead of generating a new request, - // this means to wait for a particular script_response to come in - // on the wire. + // This is a special case. Instead of generating a new request, this + // means to wait for a particular script_response to come in on the wire. int response_id; if (!PyArg_ParseTuple(extra_args, "i", &response_id)) { return NULL; @@ -1078,9 +1033,8 @@ py_request_func(PyObject *args) { if (xvalue != NULL) { value = xml_to_pyobj(xvalue); } else { - // An absence of a element is an exception. We will - // return NULL from this function, but first set the error - // condition. + // An absence of a element is an exception. We will return NULL + // from this function, but first set the error condition. PyErr_SetString(PyExc_EnvironmentError, "Error on script call"); } @@ -1131,8 +1085,7 @@ py_request_func(PyObject *args) { write_xml(_pipe_write, &doc, nout); } else if (strcmp(request_type, "drop_p3dobj") == 0) { - // Release a particular P3D_object that we were holding a - // reference to. + // Release a particular P3D_object that we were holding a reference to. int object_id; if (!PyArg_ParseTuple(extra_args, "i", &object_id)) { return NULL; @@ -1142,8 +1095,8 @@ py_request_func(PyObject *args) { write_xml(_pipe_write, &doc, nout); } else if (strcmp(request_type, "forget_package") == 0) { - // A request to the instance to drop a particular package (or - // host) from the cache. + // A request to the instance to drop a particular package (or host) from + // the cache. const char *host_url; const char *package_name; const char *package_version; @@ -1169,54 +1122,44 @@ py_request_func(PyObject *args) { return Py_BuildValue(""); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::st_request_func -// Access: Private, Static -// Description: This is the static wrapper around py_request_func. -//////////////////////////////////////////////////////////////////// +/** + * This is the static wrapper around py_request_func. + */ PyObject *P3DPythonRun:: st_request_func(PyObject *, PyObject *args) { return P3DPythonRun::_global_ptr->py_request_func(args); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::spawn_read_thread -// Access: Private -// Description: Starts the read thread. This thread is responsible -// for reading the standard input socket for XML -// commands and storing them in the _commands queue. -//////////////////////////////////////////////////////////////////// +/** + * Starts the read thread. This thread is responsible for reading the + * standard input socket for XML commands and storing them in the _commands + * queue. + */ void P3DPythonRun:: spawn_read_thread() { assert(!_read_thread_continue); - // We have to use direct OS calls to create the thread instead of - // Panda constructs, because it has to be an actual thread, not - // necessarily a Panda thread (we can't use Panda's simple threads - // implementation, because we can't get overlapped I/O on an - // anonymous pipe in Windows). + // We have to use direct OS calls to create the thread instead of Panda + // constructs, because it has to be an actual thread, not necessarily a + // Panda thread (we can't use Panda's simple threads implementation, because + // we can't get overlapped IO on an anonymous pipe in Windows). _read_thread_continue = true; SPAWN_THREAD(_read_thread, rt_thread_run, this); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::join_read_thread -// Access: Private -// Description: Waits for the read thread to stop. -//////////////////////////////////////////////////////////////////// +/** + * Waits for the read thread to stop. + */ void P3DPythonRun:: join_read_thread() { _read_thread_continue = false; JOIN_THREAD(_read_thread); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::start_instance -// Access: Private -// Description: Starts the indicated instance running within the -// Python process. -//////////////////////////////////////////////////////////////////// +/** + * Starts the indicated instance running within the Python process. + */ void P3DPythonRun:: start_instance(P3DCInstance *inst, TiXmlElement *xinstance) { _instances[inst->get_instance_id()] = inst; @@ -1240,11 +1183,9 @@ start_instance(P3DCInstance *inst, TiXmlElement *xinstance) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::terminate_instance -// Access: Private -// Description: Stops the instance with the indicated id. -//////////////////////////////////////////////////////////////////// +/** + * Stops the instance with the indicated id. + */ void P3DPythonRun:: terminate_instance(int id) { Instances::iterator ii = _instances.find(id); @@ -1257,17 +1198,15 @@ terminate_instance(int id) { _instances.erase(ii); delete inst; - // TODO: we don't currently have any way to stop just one instance - // of a multi-instance session. This will require a different - // Python interface than ShowBase. + // TODO: we don't currently have any way to stop just one instance of a + // multi-instance session. This will require a different Python interface + // than ShowBase. terminate_session(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::set_instance_info -// Access: Private -// Description: Sets some global information about the instance. -//////////////////////////////////////////////////////////////////// +/** + * Sets some global information about the instance. + */ void P3DPythonRun:: set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { const char *root_dir = xinstance->Attribute("root_dir"); @@ -1315,11 +1254,9 @@ set_instance_info(P3DCInstance *inst, TiXmlElement *xinstance) { Py_XDECREF(result); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::add_package_info -// Access: Private -// Description: Adds some information about a pre-loaded package. -//////////////////////////////////////////////////////////////////// +/** + * Adds some information about a pre-loaded package. + */ void P3DPythonRun:: add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { const char *name = xpackage->Attribute("name"); @@ -1355,12 +1292,9 @@ add_package_info(P3DCInstance *inst, TiXmlElement *xpackage) { Py_XDECREF(result); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::set_p3d_filename -// Access: Private -// Description: Sets the startup filename and tokens for the -// indicated instance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the startup filename and tokens for the indicated instance. + */ void P3DPythonRun:: set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { string p3d_filename; @@ -1431,11 +1365,9 @@ set_p3d_filename(P3DCInstance *inst, TiXmlElement *xfparams) { Py_XDECREF(result); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::setup_window -// Access: Private -// Description: Sets the window parameters for the indicated instance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the window parameters for the indicated instance. + */ void P3DPythonRun:: setup_window(int id, TiXmlElement *xwparams) { Instances::iterator ii = _instances.find(id); @@ -1448,11 +1380,9 @@ setup_window(int id, TiXmlElement *xwparams) { setup_window(inst, xwparams); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::setup_window -// Access: Private -// Description: Sets the window parameters for the indicated instance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the window parameters for the indicated instance. + */ void P3DPythonRun:: setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { string window_type; @@ -1477,8 +1407,8 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { } #elif __APPLE__ - // On Mac, we don't parent windows directly to the browser; instead, - // we have to go through this subprocess-window nonsense. + // On Mac, we don't parent windows directly to the browser; instead, we have + // to go through this subprocess-window nonsense. const char *subprocess_window = xwparams->Attribute("subprocess_window"); if (subprocess_window != NULL) { @@ -1506,15 +1436,15 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { inst->_parent_window_handle = parent_window_handle; // Also pass this P3DWindowHandle object down into Panda, via the - // setupWindow() call. For this, we need to create a Python - // wrapper objcet. + // setupWindow() call. For this, we need to create a Python wrapper + // objcet. parent_window_handle->ref(); py_handle = DTool_CreatePyInstanceTyped(parent_window_handle.p(), true); } Py_INCREF(py_handle); - // TODO: direct this into the particular instance. This will - // require a specialized ShowBase replacement. + // TODO: direct this into the particular instance. This will require a + // specialized ShowBase replacement. PyObject *result = PyObject_CallMethod (_runner, (char *)"setupWindow", (char *)"siiiiN", window_type.c_str(), win_x, win_y, win_width, win_height, py_handle); @@ -1529,13 +1459,10 @@ setup_window(P3DCInstance *inst, TiXmlElement *xwparams) { Py_XDECREF(result); } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::send_windows_message -// Access: Public -// Description: This is used to deliver a windows keyboard message to -// the Panda process from the parent process, a -// necessary hack on Vista. -//////////////////////////////////////////////////////////////////// +/** + * This is used to deliver a windows keyboard message to the Panda process + * from the parent process, a necessary hack on Vista. + */ void P3DPythonRun:: send_windows_message(int id, unsigned int msg, int wparam, int lparam) { Instances::iterator ii = _instances.find(id); @@ -1549,11 +1476,9 @@ send_windows_message(int id, unsigned int msg, int wparam, int lparam) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::terminate_session -// Access: Private -// Description: Stops all currently-running instances. -//////////////////////////////////////////////////////////////////// +/** + * Stops all currently-running instances. + */ void P3DPythonRun:: terminate_session() { Instances::iterator ii; @@ -1577,13 +1502,10 @@ terminate_session() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::pyobj_to_xml -// Access: Private -// Description: Converts the indicated PyObject to the appropriate -// XML representation of a P3D_value type, and returns a -// freshly-allocated TiXmlElement. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated PyObject to the appropriate XML representation of a + * P3D_value type, and returns a freshly-allocated TiXmlElement. + */ TiXmlElement *P3DPythonRun:: pyobj_to_xml(PyObject *value) { TiXmlElement *xvalue = new TiXmlElement("value"); @@ -1604,8 +1526,8 @@ pyobj_to_xml(PyObject *value) { #endif } else if (PyLong_Check(value)) { - // A long integer value. This gets converted either as an integer - // or as a floating-point type, whichever fits. + // A long integer value. This gets converted either as an integer or as a + // floating-point type, whichever fits. long lvalue = PyLong_AsLong(value); if (PyErr_Occurred()) { // It won't fit as an integer; make it a double. @@ -1629,8 +1551,8 @@ pyobj_to_xml(PyObject *value) { xvalue->SetAttribute("type", "string"); #if PY_MAJOR_VERSION >= 3 - // In Python 3, there are only unicode strings, and there is a - // handy function for getting the UTF-8 encoded version. + // In Python 3, there are only unicode strings, and there is a handy + // function for getting the UTF-8 encoded version. Py_ssize_t length = 0; char *buffer = PyUnicode_AsUTF8AndSize(value, &length); if (buffer != NULL) { @@ -1650,8 +1572,8 @@ pyobj_to_xml(PyObject *value) { } } else if (PyString_Check(value)) { - // A string value. Insist that it is utf-8 encoded, by decoding - // it first using the standard encoding, then re-encoding it. + // A string value. Insist that it is utf-8 encoded, by decoding it first + // using the standard encoding, then re-encoding it. xvalue->SetAttribute("type", "string"); PyObject *ustr = PyUnicode_FromEncodedObject(value, NULL, NULL); @@ -1716,8 +1638,8 @@ pyobj_to_xml(PyObject *value) { as_str = PyUnicode_AsUTF8String(a); #endif } else { - // The key is a string value or something else. Make it - // a string. + // The key is a string value or something else. Make it a + // string. as_str = PyObject_Str(a); } char *buffer; @@ -1741,8 +1663,7 @@ pyobj_to_xml(PyObject *value) { } } - // We've already avoided errors in the above code; clear the error - // flag. + // We've already avoided errors in the above code; clear the error flag. PyErr_Clear(); Py_DECREF(items); @@ -1752,9 +1673,8 @@ pyobj_to_xml(PyObject *value) { xvalue->SetAttribute("type", "undefined"); } else if (PyObject_IsInstance(value, _browser_object_class)) { - // This is a BrowserObject, a reference to an object that actually - // exists in the host namespace. So, pass up the appropriate - // object ID. + // This is a BrowserObject, a reference to an object that actually exists + // in the host namespace. So, pass up the appropriate object ID. PyObject *objectId = PyObject_GetAttrString(value, (char *)"_BrowserObject__objectId"); if (objectId != NULL) { int object_id = PyInt_AsLong(objectId); @@ -1764,18 +1684,17 @@ pyobj_to_xml(PyObject *value) { } } else { - // Some other kind of object. Make it a generic Python object. - // This is more expensive for the caller to deal with--it requires - // a back-and-forth across the XML pipe--but it's much more - // general. + // Some other kind of object. Make it a generic Python object. This is + // more expensive for the caller to deal with--it requires a back-and- + // forth across the XML pipe--but it's much more general. int object_id = _next_sent_id; ++_next_sent_id; bool inserted = _sent_objects.insert(SentObjects::value_type(object_id, value)).second; while (!inserted) { - // Hmm, we must have cycled around the entire int space? Either - // that, or there's a logic bug somewhere. Assume the former, - // and keep looking for an empty slot. + // Hmm, we must have cycled around the entire int space? Either that, + // or there's a logic bug somewhere. Assume the former, and keep + // looking for an empty slot. object_id = _next_sent_id; ++_next_sent_id; inserted = _sent_objects.insert(SentObjects::value_type(object_id, value)).second; @@ -1791,12 +1710,10 @@ pyobj_to_xml(PyObject *value) { return xvalue; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::xml_to_pyobj -// Access: Private -// Description: Converts the XML representation of a P3D_value type -// into the equivalent Python object and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Converts the XML representation of a P3D_value type into the equivalent + * Python object and returns it. + */ PyObject *P3DPythonRun:: xml_to_pyobj(TiXmlElement *xvalue) { const char *type = xvalue->Attribute("type"); @@ -1826,8 +1743,8 @@ xml_to_pyobj(TiXmlElement *xvalue) { } } else if (strcmp(type, "string") == 0) { - // Using the string form here instead of the char * form, so we - // don't get tripped up on embedded null characters. + // Using the string form here instead of the char * form, so we don't get + // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); if (value != NULL) { return PyUnicode_DecodeUTF8(value->data(), value->length(), NULL); @@ -1905,11 +1822,9 @@ xml_to_pyobj(TiXmlElement *xvalue) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::rt_thread_run -// Access: Private -// Description: The main function for the read thread. -//////////////////////////////////////////////////////////////////// +/** + * The main function for the read thread. + */ void P3DPythonRun:: rt_thread_run() { while (_read_thread_continue) { @@ -1922,8 +1837,8 @@ rt_thread_run() { // Successfully read an XML document. - // Check for one special case: the "exit" command means we shut - // down the read thread along with everything else. + // Check for one special case: the "exit" command means we shut down the + // read thread along with everything else. TiXmlElement *xcommand = doc->FirstChildElement("command"); if (xcommand != NULL) { const char *cmd = xcommand->Attribute("cmd"); @@ -1941,11 +1856,9 @@ rt_thread_run() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::P3DWindowHandle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DPythonRun::P3DWindowHandle:: P3DWindowHandle(P3DPythonRun *p3dpython, P3DCInstance *inst, const WindowHandle ©) : @@ -1956,12 +1869,10 @@ P3DWindowHandle(P3DPythonRun *p3dpython, P3DCInstance *inst, { } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::P3DWindowHandle::attach_child -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's intention to attach itself. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's intention to attach + * itself. + */ void P3DPythonRun::P3DWindowHandle:: attach_child(WindowHandle *child) { WindowHandle::attach_child(child); @@ -1973,12 +1884,10 @@ attach_child(WindowHandle *child) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::P3DWindowHandle::detach_child -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's intention to detach itself. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's intention to detach + * itself. + */ void P3DPythonRun::P3DWindowHandle:: detach_child(WindowHandle *child) { WindowHandle::detach_child(child); @@ -1990,12 +1899,10 @@ detach_child(WindowHandle *child) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DPythonRun::P3DWindowHandle::request_keyboard_focus -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's wish to receive keyboard button events. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's wish to receive + * keyboard button events. + */ void P3DPythonRun::P3DWindowHandle:: request_keyboard_focus(WindowHandle *child) { WindowHandle::request_keyboard_focus(child); diff --git a/direct/src/plugin/p3dPythonRun.h b/direct/src/plugin/p3dPythonRun.h index 84188bdd2c..17a8e35371 100644 --- a/direct/src/plugin/p3dPythonRun.h +++ b/direct/src/plugin/p3dPythonRun.h @@ -1,16 +1,15 @@ -// Filename: p3dPythonRun.h -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dPythonRun.h + * @author drose + * @date 2009-06-05 + */ #ifndef P3DPYTHONRUN_H #define P3DPYTHONRUN_H @@ -44,30 +43,25 @@ typedef int Py_ssize_t; using namespace std; -//////////////////////////////////////////////////////////////////// -// Class : P3DPythonRun -// Description : This class is used to run, and communicate with, -// embedded Python in a sub-process. It is compiled and -// launched as a separate executable from the p3d_plugin -// dll, because that's the only way Windows can launch a -// sub-process, and also because it makes it possible to -// compile-time link with Panda and Python, instead of -// having to go through the clumsy dynamic-loading -// interface. -// -// Communication is via XML files exchanged via -// anonymous pipes from the parent process. This isn't -// terribly eficient, of course, but it's easy; and it's -// a fairly low-bandwidth channel so efficiency is not -// paramount. -// -// This executable is not designed to stand alone; it is -// designed to be invoked only by p3d_plugin. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to run, and communicate with, embedded Python in a sub- + * process. It is compiled and launched as a separate executable from the + * p3d_plugin dll, because that's the only way Windows can launch a sub- + * process, and also because it makes it possible to compile-time link with + * Panda and Python, instead of having to go through the clumsy dynamic- + * loading interface. + * + * Communication is via XML files exchanged via anonymous pipes from the + * parent process. This isn't terribly eficient, of course, but it's easy; + * and it's a fairly low-bandwidth channel so efficiency is not paramount. + * + * This executable is not designed to stand alone; it is designed to be + * invoked only by p3d_plugin. + */ class P3DPythonRun { public: P3DPythonRun(const char *program_name, const char *archive_file, - FHandle input_handle, FHandle output_handle, + FHandle input_handle, FHandle output_handle, const char *log_pathname, bool interactive_console); ~P3DPythonRun(); @@ -102,7 +96,7 @@ private: void setup_window(P3DCInstance *inst, TiXmlElement *xwparams); void send_windows_message(int id, unsigned int msg, int wparam, int lparam); - + void terminate_session(); private: @@ -110,11 +104,10 @@ private: PyObject *xml_to_pyobj(TiXmlElement *xvalue); private: - // This subclass of WindowHandle is associated with the parent - // window we are given by the parent process. We use it to add - // hooks for communicating with the parent window, for instance to - // ask for the parent window to manage keyboard focus when - // necessary. + // This subclass of WindowHandle is associated with the parent window we are + // given by the parent process. We use it to add hooks for communicating + // with the parent window, for instance to ask for the parent window to + // manage keyboard focus when necessary. class P3DWindowHandle : public WindowHandle { public: P3DWindowHandle(P3DPythonRun *p3dpython, P3DCInstance *inst, @@ -143,7 +136,7 @@ private: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -177,27 +170,25 @@ private: PyObject *_browser_object_class; PyObject *_taskMgr; - // This map keeps track of the PyObject pointers we have delivered - // to the parent process. We have to hold the reference count on - // each of these until the parent process tells us it's safe to - // release them. + // This map keeps track of the PyObject pointers we have delivered to the + // parent process. We have to hold the reference count on each of these + // until the parent process tells us it's safe to release them. typedef pmap SentObjects; SentObjects _sent_objects; int _next_sent_id; typedef pdeque Commands; - // This is a special queue of responses extracted from the _commands - // queue, below. It's protected by the Panda mutex. + // This is a special queue of responses extracted from the _commands queue, + // below. It's protected by the Panda mutex. Commands _responses; Mutex _responses_lock; // The remaining members are manipulated by the read thread. Commands _commands; - - // This has to be an actual OS LOCK instead of Panda's Mutex, - // because we have to use a true thread here, not one of Panda's - // simple threads. + + // This has to be an actual OS LOCK instead of Panda's Mutex, because we + // have to use a true thread here, not one of Panda's simple threads. LOCK _commands_lock; HandleStream _pipe_read; @@ -216,4 +207,3 @@ public: #include "p3dPythonRun.I" #endif - diff --git a/direct/src/plugin/p3dReferenceCount.I b/direct/src/plugin/p3dReferenceCount.I index f9ba1140eb..b4cac7c05f 100644 --- a/direct/src/plugin/p3dReferenceCount.I +++ b/direct/src/plugin/p3dReferenceCount.I @@ -1,82 +1,68 @@ -// Filename: p3dReferenceCount.I -// Created by: drose (09Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dReferenceCount.I + * @author drose + * @date 2009-07-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DReferenceCount::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DReferenceCount:: P3DReferenceCount() { _ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DReferenceCount::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DReferenceCount:: ~P3DReferenceCount() { assert(_ref_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: P3DReferenceCount::ref -// Access: Public -// Description: Explicitly increments the reference count. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly increments the reference count. + */ inline void P3DReferenceCount:: ref() const { ++((P3DReferenceCount *)this)->_ref_count; } -//////////////////////////////////////////////////////////////////// -// Function: P3DReferenceCount::unref -// Access: Public -// Description: Explicitly decrements the reference count. Usually, -// you should call p3d_unref_delete() instead. -// -// The return value is true if the new reference count -// is nonzero, false if it is zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the reference count. Usually, you should call + * p3d_unref_delete() instead. + * + * The return value is true if the new reference count is nonzero, false if it + * is zero. + */ inline bool P3DReferenceCount:: unref() const { return --(((P3DReferenceCount *)this)->_ref_count) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DReferenceCount::get_ref_count -// Access: Public -// Description: Returns the current reference count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current reference count. + */ inline int P3DReferenceCount:: get_ref_count() const { return _ref_count; } -//////////////////////////////////////////////////////////////////// -// Function: p3d_unref_delete -// Description: This global helper function will unref the given -// P3DReferenceCount object, and if the reference count -// reaches zero, automatically delete it. -//////////////////////////////////////////////////////////////////// +/** + * This global helper function will unref the given P3DReferenceCount object, + * and if the reference count reaches zero, automatically delete it. + */ template inline void p3d_unref_delete(RefCountType *ptr) { if (!ptr->unref()) { delete ptr; - } + } } diff --git a/direct/src/plugin/p3dReferenceCount.cxx b/direct/src/plugin/p3dReferenceCount.cxx index 5975dcbe29..9747476e73 100644 --- a/direct/src/plugin/p3dReferenceCount.cxx +++ b/direct/src/plugin/p3dReferenceCount.cxx @@ -1,15 +1,14 @@ -// Filename: p3dReferenceCount.cxx -// Created by: drose (09Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dReferenceCount.cxx + * @author drose + * @date 2009-07-09 + */ #include "p3dReferenceCount.h" diff --git a/direct/src/plugin/p3dReferenceCount.h b/direct/src/plugin/p3dReferenceCount.h index 71209db1d6..b11eb82931 100644 --- a/direct/src/plugin/p3dReferenceCount.h +++ b/direct/src/plugin/p3dReferenceCount.h @@ -1,29 +1,26 @@ -// Filename: p3dReferenceCount.h -// Created by: drose (09Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dReferenceCount.h + * @author drose + * @date 2009-07-09 + */ #ifndef P3DREFERENCECOUNT_H #define P3DREFERENCECOUNT_H #include "p3d_plugin_common.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DReferenceCount -// Description : A base class for reference-counted objects in this -// module. We follow the Panda convention, rather than -// the Python convention: the reference count of a new -// object is initially 0. -//////////////////////////////////////////////////////////////////// +/** + * A base class for reference-counted objects in this module. We follow the + * Panda convention, rather than the Python convention: the reference count of + * a new object is initially 0. + */ class P3DReferenceCount { public: inline P3DReferenceCount(); diff --git a/direct/src/plugin/p3dSession.I b/direct/src/plugin/p3dSession.I index d5a97d2bb9..2ab1155788 100644 --- a/direct/src/plugin/p3dSession.I +++ b/direct/src/plugin/p3dSession.I @@ -1,61 +1,48 @@ -// Filename: p3dSession.I -// Created by: drose (03Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSession.I + * @author drose + * @date 2009-06-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::get_session_key -// Access: Public -// Description: Returns a string that uniquely identifies this -// session. See P3dInstance::get_session_key(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that uniquely identifies this session. See + * P3dInstance::get_session_key(). + */ inline const string &P3DSession:: get_session_key() const { return _session_key; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::get_log_pathname -// Access: Public -// Description: Returns the log filename for this particular session, -// if the session was started and if it has a log file. -// Returns empty string if the session never started or -// if it lacks a log file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the log filename for this particular session, if the session was + * started and if it has a log file. Returns empty string if the session + * never started or if it lacks a log file. + */ inline const string &P3DSession:: get_log_pathname() const { return _log_pathname; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::get_matches_script_origin -// Access: Public -// Description: Returns true if the instances of this session are -// allowed to be scripted by its embedding web page, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the instances of this session are allowed to be scripted by + * its embedding web page, false otherwise. + */ inline bool P3DSession:: get_matches_script_origin() const { return _matches_script_origin; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::get_num_instances -// Access: Public -// Description: Returns the number of instances currently running -// within the session. When this is zero, the session -// may be safely deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of instances currently running within the session. When + * this is zero, the session may be safely deleted. + */ inline int P3DSession:: get_num_instances() const { return _instances.size(); diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index 0c2f13e4a8..522936f61a 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -1,16 +1,15 @@ -// Filename: p3dSession.cxx -// Created by: drose (03Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSession.cxx + * @author drose + * @date 2009-06-03 + */ #include "p3dSession.h" #include "p3dInstance.h" @@ -44,15 +43,12 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::Constructor -// Access: Public -// Description: Creates a new session, corresponding to a new -// subprocess with its own copy of Python. The initial -// parameters for the session are taken from the -// indicated instance object (but the instance itself is -// not automatically started within the session). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new session, corresponding to a new subprocess with its own copy + * of Python. The initial parameters for the session are taken from the + * indicated instance object (but the instance itself is not automatically + * started within the session). + */ P3DSession:: P3DSession(P3DInstance *inst) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); @@ -79,23 +75,18 @@ P3DSession(P3DInstance *inst) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DSession:: ~P3DSession() { assert(!_p3dpython_running); - DESTROY_LOCK(_instances_lock); + DESTROY_LOCK(_instances_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::shutdown -// Access: Public -// Description: Terminates the session by shutting down Python and -// stopping the subprocess. -//////////////////////////////////////////////////////////////////// +/** + * Terminates the session by shutting down Python and stopping the subprocess. + */ void P3DSession:: shutdown() { set_failed(); @@ -113,29 +104,26 @@ shutdown() { // Also close the pipe, to help underscore the point. _pipe_write.close(); - // Closing _pipe_read before the thread has stopped can result in - // a hang. Don't need to close it yet. - // _pipe_read.close(); + // Closing _pipe_read before the thread has stopped can result in a hang. + // Don't need to close it yet. _pipe_read.close(); static const int max_wait_ms = 2000; if (_p3dpython_one_process) { - // Since it's running in a thread, we can't reliably force-kill - // it. So, just wait. + // Since it's running in a thread, we can't reliably force-kill it. So, + // just wait. nout << "Waiting for Python thread to exit\n"; JOIN_THREAD(_p3dpython_thread); nout << "Done waiting.\n"; _p3dpython_one_process = false; } else { - // Python's running in a sub-process, the preferred way. In - // this case, we can wait a brief amount of time before it - // closes itself; but if it doesn't, we can safely force-kill - // it. + // Python's running in a sub-process, the preferred way. In this case, + // we can wait a brief amount of time before it closes itself; but if it + // doesn't, we can safely force-kill it. #ifdef _WIN32 - // Wait for a certain amount of time for the process to stop by - // itself. + // Wait for a certain amount of time for the process to stop by itself. while (WaitForSingleObject(_p3dpython_handle, max_wait_ms) == WAIT_TIMEOUT) { // It didn't shut down cleanly, so kill it the hard way. nout << "Force-killing python process.\n"; @@ -153,12 +141,11 @@ shutdown() { _p3dpython_handle = INVALID_HANDLE_VALUE; #else // _WIN32 - // Wait for a certain amount of time for the process to stop by - // itself. + // Wait for a certain amount of time for the process to stop by itself. struct timeval start; gettimeofday(&start, NULL); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; - + int status; pid_t result = waitpid(_p3dpython_pid, &status, WNOHANG); while (result != _p3dpython_pid) { @@ -166,20 +153,20 @@ shutdown() { perror("waitpid"); break; } - + struct timeval now; gettimeofday(&now, NULL); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; - + if (elapsed > max_wait_ms) { // Tired of waiting. Kill the process. - nout << "Force-killing python process, pid " << _p3dpython_pid + nout << "Force-killing python process, pid " << _p3dpython_pid << "\n"; kill(_p3dpython_pid, SIGKILL); start_ms = now_ms; } - + // Yield the timeslice and wait some more. struct timeval tv; tv.tv_sec = 0; @@ -212,9 +199,8 @@ shutdown() { _p3dpython_started = false; } - // If there are any leftover commands in the queue (presumably - // implying we have never started the python process), then delete - // them now, unsent. + // If there are any leftover commands in the queue (presumably implying we + // have never started the python process), then delete them now, unsent. Commands::iterator ci; for (ci = _commands.begin(); ci != _commands.end(); ++ci) { delete (*ci); @@ -232,16 +218,13 @@ shutdown() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::start_instance -// Access: Public -// Description: Adds the indicated instance to the session, and -// starts it running. It is an error if the instance -// has been started anywhere else. -// -// The instance must have the same session_key as the -// one that was passed to the P3DSession constructor. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated instance to the session, and starts it running. It is + * an error if the instance has been started anywhere else. + * + * The instance must have the same session_key as the one that was passed to + * the P3DSession constructor. + */ void P3DSession:: start_instance(P3DInstance *inst) { assert(inst->_session == NULL); @@ -263,34 +246,31 @@ start_instance(P3DInstance *inst) { TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "start_instance"); TiXmlElement *xinstance = inst->make_xml(); - + doc->LinkEndChild(xcommand); xcommand->LinkEndChild(xinstance); send_command(doc); inst->send_browser_script_object(); - // We shouldn't have gotten here unless the instance is fully - // downloaded and ready to start. + // We shouldn't have gotten here unless the instance is fully downloaded and + // ready to start. assert(inst->get_packages_ready()); start_p3dpython(inst); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::terminate_instance -// Access: Public -// Description: Removes the indicated instance from the session, and -// stops it. It is an error if the instance is not -// already running on this session. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated instance from the session, and stops it. It is an + * error if the instance is not already running on this session. + */ void P3DSession:: terminate_instance(P3DInstance *inst) { TiXmlDocument *doc = new TiXmlDocument; TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "terminate_instance"); xcommand->SetAttribute("instance_id", inst->get_instance_id()); - + doc->LinkEndChild(xcommand); send_command(doc); @@ -306,17 +286,13 @@ terminate_instance(P3DInstance *inst) { p3d_unref_delete(inst); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::send_command -// Access: Public -// Description: Sends the indicated command to the running Python -// process. If the process has not yet been started, -// queues it up until it is ready. -// -// The command must be a newly-allocated TiXmlDocument; -// it will be deleted after it has been delivered to the -// process. -//////////////////////////////////////////////////////////////////// +/** + * Sends the indicated command to the running Python process. If the process + * has not yet been started, queues it up until it is ready. + * + * The command must be a newly-allocated TiXmlDocument; it will be deleted + * after it has been delivered to the process. + */ void P3DSession:: send_command(TiXmlDocument *command) { if (_p3dpython_started) { @@ -329,21 +305,17 @@ send_command(TiXmlDocument *command) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::command_and_response -// Access: Public -// Description: Sends the indicated command to the running Python -// process, and waits for a response. Returns the -// newly-allocated response on success, or NULL on -// failure. -// -// The command must be a newly-allocated TiXmlDocument; -// it will be deleted after it has been delivered to the -// process. -// -// This will fail if the python process is not running -// or if it suddenly stops. -//////////////////////////////////////////////////////////////////// +/** + * Sends the indicated command to the running Python process, and waits for a + * response. Returns the newly-allocated response on success, or NULL on + * failure. + * + * The command must be a newly-allocated TiXmlDocument; it will be deleted + * after it has been delivered to the process. + * + * This will fail if the python process is not running or if it suddenly + * stops. + */ TiXmlDocument *P3DSession:: command_and_response(TiXmlDocument *command) { if (!_p3dpython_started) { @@ -353,8 +325,8 @@ command_and_response(TiXmlDocument *command) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); int response_id = inst_mgr->get_unique_id(); - // Add the "want_response_id" attribute to the toplevel command, so - // the sub-process knows we'll be waiting for its response. + // Add the "want_response_id" attribute to the toplevel command, so the sub- + // process knows we'll be waiting for its response. TiXmlElement *xcommand = command->FirstChildElement("command"); assert(xcommand != NULL); xcommand->SetAttribute("want_response_id", response_id); @@ -372,13 +344,13 @@ command_and_response(TiXmlDocument *command) { return NULL; } - // Make sure we bake requests while we are waiting, to process - // recursive script requests. (The child process might have to - // wait for us to process some of these before it can fulfill the - // command we're actually waiting for.) + // Make sure we bake requests while we are waiting, to process recursive + // script requests. (The child process might have to wait for us to + // process some of these before it can fulfill the command we're actually + // waiting for.) - // Release the mutex while we do this, so we can safely call back - // in recursively. + // Release the mutex while we do this, so we can safely call back in + // recursively. _response_ready.release(); Instances::iterator ii; // TODO: should we acquire _instances_lock? Deadlock concerns? @@ -390,39 +362,37 @@ command_and_response(TiXmlDocument *command) { ri = _responses.find(response_id); if (ri != _responses.end()) { - // We got the response we were waiting for while we had the - // mutex unlocked. + // We got the response we were waiting for while we had the mutex + // unlocked. break; } #ifdef _WIN32 - // Make sure we process the Windows event loop while we're - // waiting, or everything that depends on Windows messages within - // the subprocess will starve, and we could end up with deadlock. + // Make sure we process the Windows event loop while we're waiting, or + // everything that depends on Windows messages within the subprocess will + // starve, and we could end up with deadlock. - // A single call to PeekMessage() appears to be sufficient. This - // will scan the message queue and deliver messages to the - // appropriate threads, so that our subprocess can find them. If - // we don't do this, the messages that come into this parent - // window will never get delivered to the subprocess, even though - // somehow the subprocess will know they're coming and will block - // waiting for them. + // A single call to PeekMessage() appears to be sufficient. This will + // scan the message queue and deliver messages to the appropriate threads, + // so that our subprocess can find them. If we don't do this, the + // messages that come into this parent window will never get delivered to + // the subprocess, even though somehow the subprocess will know they're + // coming and will block waiting for them. MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); - // We wait with a timeout, so we can go back and spin the event - // loop some more. On Windows, the timeout needs to be small, so - // we continue to process windows messages in a timely fashion. + // We wait with a timeout, so we can go back and spin the event loop some + // more. On Windows, the timeout needs to be small, so we continue to + // process windows messages in a timely fashion. _response_ready.wait(0.01); #else - // On other platforms, we shouldn't need a timeout at all--we - // could just block indefinitely--but we go ahead and put one in - // anyway, just in case a notification slips past somehow, and - // also so we can see evidence that we're actively waiting. This - // timeout doesn't need to be nearly so small, since it's only a - // "just in case" sort of thing. + // On other platforms, we shouldn't need a timeout at all--we could just + // block indefinitely--but we go ahead and put one in anyway, just in case + // a notification slips past somehow, and also so we can see evidence that + // we're actively waiting. This timeout doesn't need to be nearly so + // small, since it's only a "just in case" sort of thing. _response_ready.wait(0.5); #endif // _WIN32 @@ -437,13 +407,10 @@ command_and_response(TiXmlDocument *command) { return response; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::xml_to_p3dobj -// Access: Public -// Description: Converts the XML representation of the particular -// object value into a corresponding P3D_object. -// Returns the object, a new reference. -//////////////////////////////////////////////////////////////////// +/** + * Converts the XML representation of the particular object value into a + * corresponding P3D_object. Returns the object, a new reference. + */ P3D_object *P3DSession:: xml_to_p3dobj(const TiXmlElement *xvalue) { const char *type = xvalue->Attribute("type"); @@ -474,8 +441,8 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { } } else if (strcmp(type, "string") == 0) { - // Using the string form here instead of the char * form, so we - // don't get tripped up on embedded null characters. + // Using the string form here instead of the char * form, so we don't get + // tripped up on embedded null characters. const string *value = xvalue->Attribute(string("value")); if (value != NULL) { return new P3DStringObject(*value); @@ -536,14 +503,11 @@ xml_to_p3dobj(const TiXmlElement *xvalue) { return inst_mgr->new_undefined_object(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::p3dobj_to_xml -// Access: Public -// Description: Allocates and returns a new XML structure -// corresponding to the indicated value. The supplied -// P3DObject's reference count is not decremented; the -// caller remains responsible for decrementing it later. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new XML structure corresponding to the indicated + * value. The supplied P3DObject's reference count is not decremented; the + * caller remains responsible for decrementing it later. + */ TiXmlElement *P3DSession:: p3dobj_to_xml(P3D_object *obj) { TiXmlElement *xvalue = new TiXmlElement("value"); @@ -590,23 +554,22 @@ p3dobj_to_xml(P3D_object *obj) { } if (p3dobj != NULL && p3dobj->fill_xml(xvalue, this)) { - // This object has a specialized XML representation, valid for - // this particular session. It has already been filled into - // xvalue. + // This object has a specialized XML representation, valid for this + // particular session. It has already been filled into xvalue. } else { - // Otherwise, it must a host-provided object, or a Python object - // from another session; which means we should pass a reference - // down to this particular object, so the Python process knows - // to call back up to here to query it. + // Otherwise, it must a host-provided object, or a Python object from + // another session; which means we should pass a reference down to this + // particular object, so the Python process knows to call back up to + // here to query it. P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); int object_id = inst_mgr->get_unique_id(); bool inserted = _sent_objects.insert(SentObjects::value_type(object_id, obj)).second; while (!inserted) { - // Hmm, we must have cycled around the entire int space? Either - // that, or there's a logic bug somewhere. Assume the former, - // and keep looking for an empty slot. + // Hmm, we must have cycled around the entire int space? Either that, + // or there's a logic bug somewhere. Assume the former, and keep + // looking for an empty slot. object_id = inst_mgr->get_unique_id(); inserted = _sent_objects.insert(SentObjects::value_type(object_id, obj)).second; } @@ -623,14 +586,11 @@ p3dobj_to_xml(P3D_object *obj) { return xvalue; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::send_windows_message -// Access: Public -// Description: This is called by the splash window to deliver a -// windows keyboard message to the Panda process. It -// will be called in a sub-thread, but that's OK, since -// write_xml() supports locking. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the splash window to deliver a windows keyboard message + * to the Panda process. It will be called in a sub-thread, but that's OK, + * since write_xml() supports locking. + */ void P3DSession:: send_windows_message(P3DInstance *inst, unsigned int msg, int wparam, int lparam) { if (_p3dpython_started) { @@ -646,33 +606,28 @@ send_windows_message(P3DInstance *inst, unsigned int msg, int wparam, int lparam } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::signal_request_ready -// Access: Public -// Description: May be called in any thread to indicate that a new -// P3D_request is available in the indicated instance. -//////////////////////////////////////////////////////////////////// +/** + * May be called in any thread to indicate that a new P3D_request is available + * in the indicated instance. + */ void P3DSession:: signal_request_ready(P3DInstance *inst) { - // Since a new request might require baking, we should wake up a - // blocked command_and_request() process, so the main thread can go - // back and bake the new request. + // Since a new request might require baking, we should wake up a blocked + // command_and_request() process, so the main thread can go back and bake + // the new request. - // Technically, a response isn't really ready now, but we still need - // the main thread to wake up and look around for a bit. + // Technically, a response isn't really ready now, but we still need the + // main thread to wake up and look around for a bit. _response_ready.acquire(); _response_ready.notify(); _response_ready.release(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::drop_pyobj -// Access: Public -// Description: If the session is still active, issues the command to -// the child process to release the indicated PyObject -// from its table. This is intended to be called -// strictly by the P3DPythonObject destructor. -//////////////////////////////////////////////////////////////////// +/** + * If the session is still active, issues the command to the child process to + * release the indicated PyObject from its table. This is intended to be + * called strictly by the P3DPythonObject destructor. + */ void P3DSession:: drop_pyobj(int object_id) { if (_p3dpython_started) { @@ -685,15 +640,12 @@ drop_pyobj(int object_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::drop_p3dobj -// Access: Public -// Description: Responds to a drop_p3dobj message from the child -// process indicating that a particular P3D_object is no -// longer being used by the child. This removes the -// corresponding P3D_object from our tables and -// decrements its reference count. -//////////////////////////////////////////////////////////////////// +/** + * Responds to a drop_p3dobj message from the child process indicating that a + * particular P3D_object is no longer being used by the child. This removes + * the corresponding P3D_object from our tables and decrements its reference + * count. + */ void P3DSession:: drop_p3dobj(int object_id) { SentObjects::iterator si = _sent_objects.find(object_id); @@ -704,11 +656,9 @@ drop_p3dobj(int object_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::start_p3dpython -// Access: Private -// Description: Starts Python running in a child process. -//////////////////////////////////////////////////////////////////// +/** + * Starts Python running in a child process. + */ void P3DSession:: start_p3dpython(P3DInstance *inst) { if (_p3dpython_started) { @@ -727,11 +677,11 @@ start_p3dpython(P3DInstance *inst) { _python_root_dir = inst->_panda3d_package->get_package_dir(); replace_slashes(_python_root_dir); - // If we're not to be preserving the user's current directory, then - // we'll need to change to the standard start directory. + // If we're not to be preserving the user's current directory, then we'll + // need to change to the standard start directory. _keep_user_env = false; - if (inst_mgr->get_trusted_environment() && - inst_mgr->get_console_environment() && + if (inst_mgr->get_trusted_environment() && + inst_mgr->get_console_environment() && inst->_keep_user_env) { _keep_user_env = true; } @@ -752,10 +702,10 @@ start_p3dpython(P3DInstance *inst) { char sep = ':'; #endif // _WIN32 - // Build up a search path that includes all of the required packages - // that have already been installed. We build this in reverse - // order, so that the higher-order packages come first in the list; - // that allows them to shadow settings in the lower-order packages. + // Build up a search path that includes all of the required packages that + // have already been installed. We build this in reverse order, so that the + // higher-order packages come first in the list; that allows them to shadow + // settings in the lower-order packages. assert(!inst->_packages.empty()); string search_path; size_t pi = inst->_packages.size() - 1; @@ -771,9 +721,8 @@ start_p3dpython(P3DInstance *inst) { bool keep_pythonpath = false; if (inst->_allow_python_dev) { - // If "allow_python_dev" is set in the instance's p3d_info.xml, - // *and* we have keep_pythonpath in the tokens, then we set - // keep_pythonpath true. + // If "allow_python_dev" is set in the instance's p3d_info.xml, *and* we + // have keep_pythonpath in the tokens, then we set keep_pythonpath true. keep_pythonpath = (inst->get_fparams().lookup_token_int("keep_pythonpath") != 0); } @@ -786,12 +735,11 @@ start_p3dpython(P3DInstance *inst) { string prc_name = inst->get_fparams().lookup_token("prc_name"); if (prc_name.empty()) { prc_name = inst->_prc_name; - + if (!prc_name.empty()) { - // If the prc_name is taken from the p3d file (and not from the - // HTML tokens), then we also append the alt_host name to the - // prc_name, so that each alt_host variant will run in a - // different directory. + // If the prc_name is taken from the p3d file (and not from the HTML + // tokens), then we also append the alt_host name to the prc_name, so + // that each alt_host variant will run in a different directory. string alt_host = inst->get_fparams().lookup_token("alt_host"); if (!alt_host.empty()) { prc_name += "_"; @@ -805,15 +753,14 @@ start_p3dpython(P3DInstance *inst) { string this_prc_dir = inst_mgr->get_root_dir() + "/prc"; inst_mgr->append_safe_dir(this_prc_dir, prc_name); replace_slashes(this_prc_dir); - prc_path = this_prc_dir + sep + prc_path; + prc_path = this_prc_dir + sep + prc_path; } if (keep_pythonpath) { - // With keep_pythonpath true, we preserve the PYTHONPATH setting - // from the caller's environment; in fact, we put it in the front. - // This allows the caller's on-disk Python files to shadow the - // similar-named files in the p3d file, allowing easy iteration on - // the code in the p3d file. + // With keep_pythonpath true, we preserve the PYTHONPATH setting from the + // caller's environment; in fact, we put it in the front. This allows the + // caller's on-disk Python files to shadow the similar-named files in the + // p3d file, allowing easy iteration on the code in the p3d file. if (get_env(python_path, "PYTHONPATH")) { replace_slashes(python_path); python_path += sep; @@ -832,15 +779,15 @@ start_p3dpython(P3DInstance *inst) { << "PRC_PATH set to: " << prc_path << "\n"; } - // Get the name of the executable to run. Ideally, we'll run the - // executable successfully, in a sub-process; this will in turn load - // and run the dynamic library. If that fails for some reason, we - // can fall back to loading and running the library directly. + // Get the name of the executable to run. Ideally, we'll run the executable + // successfully, in a sub-process; this will in turn load and run the + // dynamic library. If that fails for some reason, we can fall back to + // loading and running the library directly. _p3dpython_exe = P3D_PLUGIN_P3DPYTHON; string p3dpythonw_exe = _p3dpython_exe + "w"; if (_p3dpython_exe.empty()) { // Allow package to override the name of the p3dpython executables. - const char *p3dpython_name_xconfig = NULL; + const char *p3dpython_name_xconfig = NULL; const char *p3dpythonw_name_xconfig = NULL; const TiXmlElement *panda3d_xconfig = inst->_panda3d_package->get_xconfig(); if (panda3d_xconfig != NULL) { @@ -884,9 +831,8 @@ start_p3dpython(P3DInstance *inst) { _env = string(); if (!_keep_user_env) { - // Reconstruct an environment just for running the process. - // Completely replace most of the existing environment variables - // with our own. + // Reconstruct an environment just for running the process. Completely + // replace most of the existing environment variables with our own. // These are the enviroment variables we forward from the current // environment, if they are set. @@ -915,9 +861,8 @@ start_p3dpython(P3DInstance *inst) { } } else { - // In a trusted environment, when the application asks us to, we - // forward *all* environment variables, except those defined - // specifically below. + // In a trusted environment, when the application asks us to, we forward + // *all* environment variables, except those defined specifically below. const char *dont_keep[] = { "PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "PYTHONPATH", "PYTHONHOME", "PRC_PATH", "PANDA_PRC_PATH", @@ -926,13 +871,13 @@ start_p3dpython(P3DInstance *inst) { }; #ifdef _WIN32 - // Windows has a leading underscore in the name, and the word - // "environ" is a keyword. (!) + // Windows has a leading underscore in the name, and the word "environ" is + // a keyword. (!) extern char **_environ; char **global_environ = _environ; #elif defined(__APPLE__) - // Apple doesn't guarantee that environ is available for shared - // libraries, but provides _NSGetEnviron(). + // Apple doesn't guarantee that environ is available for shared libraries, + // but provides _NSGetEnviron(). char **global_environ = *_NSGetEnviron(); #else // Posix is straightforward. @@ -965,9 +910,9 @@ start_p3dpython(P3DInstance *inst) { } // We also append the original PATH et al to the *end* of the new - // definitions, even if keep_user_env is not set. This is necessary - // for os.system() and such to work as expected within the embedded - // app. It's also necessary for webbrowser on Linux. + // definitions, even if keep_user_env is not set. This is necessary for + // os.system() and such to work as expected within the embedded app. It's + // also necessary for webbrowser on Linux. string orig_path; if (get_env(orig_path, "PATH")) { sys_path += sep; @@ -1001,8 +946,8 @@ start_p3dpython(P3DInstance *inst) { _env += python_path; _env += '\0'; - // Let's leave PYTHONHOME empty. Setting it adds junk to our - // carefully-constructed PYTHONPATH. + // Let's leave PYTHONHOME empty. Setting it adds junk to our carefully- + // constructed PYTHONPATH. _env += "PYTHONHOME="; _env += '\0'; @@ -1019,10 +964,10 @@ start_p3dpython(P3DInstance *inst) { replace_slashes(temp_dir); _env += temp_dir; _env += '\0'; - - // Define each package's root directory in an environment variable - // named after the package, for the convenience of the packages in - // setting up their config files. + + // Define each package's root directory in an environment variable named + // after the package, for the convenience of the packages in setting up + // their config files. for (size_t pi = 0; pi < inst->_packages.size(); ++pi) { P3DPackage *package = inst->_packages[pi]; const string package_name = package->get_package_name(); @@ -1044,8 +989,8 @@ start_p3dpython(P3DInstance *inst) { _interactive_console = (inst->get_fparams().lookup_token_int("interactive_console") != 0); if (!inst->_allow_python_dev) { - // interactive_console is only allowed to be enabled if - // allow_python_dev is also set within the p3d file. + // interactive_console is only allowed to be enabled if allow_python_dev + // is also set within the p3d file. _interactive_console = false; } @@ -1055,17 +1000,15 @@ start_p3dpython(P3DInstance *inst) { console_output = true; } - // Get the log filename from the HTML tokens, or from the - // p3d_info.xml file. + // Get the log filename from the HTML tokens, or from the p3d_info.xml file. string log_basename = inst->get_fparams().lookup_token("log_basename"); if (log_basename.empty()) { log_basename = inst->_log_basename; if (!log_basename.empty()) { - // If the log_basename is taken from the p3d file (and not from - // the HTML tokens), then we also append the alt_host name to - // the log_basename, so that each alt_host variant will run in a - // different directory. + // If the log_basename is taken from the p3d file (and not from the HTML + // tokens), then we also append the alt_host name to the log_basename, + // so that each alt_host variant will run in a different directory. string alt_host = inst->get_fparams().lookup_token("alt_host"); if (!alt_host.empty()) { log_basename += "_"; @@ -1076,8 +1019,7 @@ start_p3dpython(P3DInstance *inst) { if (log_basename.empty()) { #ifdef P3D_PLUGIN_LOG_BASENAME3 - // No log_basename specified for the app; use the compiled-in - // default. + // No log_basename specified for the app; use the compiled-in default. log_basename = P3D_PLUGIN_LOG_BASENAME3; #endif if (log_basename.empty()) { @@ -1085,8 +1027,8 @@ start_p3dpython(P3DInstance *inst) { } } - // However, it is always written into the log directory only; the - // user may not override the log file to put it anywhere else. + // However, it is always written into the log directory only; the user may + // not override the log file to put it anywhere else. size_t slash = log_basename.rfind('/'); if (slash != string::npos) { log_basename = log_basename.substr(slash + 1); @@ -1098,8 +1040,8 @@ start_p3dpython(P3DInstance *inst) { } #endif // _WIN32 - // Get the log history count from the HTML tokens, or from the - // p3d_info.xml file. + // Get the log history count from the HTML tokens, or from the p3d_info.xml + // file. int log_history = inst->get_fparams().lookup_token_int("log_history"); // Check if we want to keep copies of recent logs on disk. @@ -1152,7 +1094,7 @@ start_p3dpython(P3DInstance *inst) { struct tm log_time_local = *log_time_local_p; static const size_t buffer_size = 16; char buffer[buffer_size]; - sprintf(buffer, "%02d%02d%02d_%02d%02d%02d", + sprintf(buffer, "%02d%02d%02d_%02d%02d%02d", (int)(log_time_local.tm_year+1900-2000), (int)(log_time_local.tm_mon+1), (int)(log_time_local.tm_mday), @@ -1168,8 +1110,8 @@ start_p3dpython(P3DInstance *inst) { _log_pathname = inst_mgr->get_log_directory(); _log_pathname += log_basename; - // We always tack on the extension ".log", to make it even more - // difficult to overwrite a system file. + // We always tack on the extension ".log", to make it even more difficult + // to overwrite a system file. _log_pathname += ".log"; } @@ -1192,7 +1134,7 @@ start_p3dpython(P3DInstance *inst) { if (!CreatePipe(&r_from, &w_from, NULL, 0)) { nout << "failed to create pipe\n"; set_failed(); - } else { + } else { // Make sure the right end of the pipe is inheritable. SetHandleInformation(w_from, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); SetHandleInformation(r_from, HANDLE_FLAG_INHERIT, 0); @@ -1229,8 +1171,8 @@ start_p3dpython(P3DInstance *inst) { nout << "Setting environment:\n"; write_env(); - // Get the filename of the Panda3D multifile. We need to pass this - // to p3dpython. + // Get the filename of the Panda3D multifile. We need to pass this to + // p3dpython. _mf_filename = inst->_panda3d_package->get_archive_file_pathname(); nout << "Attempting to start python from " << _p3dpython_exe << "\n"; @@ -1253,10 +1195,9 @@ start_p3dpython(P3DInstance *inst) { } if (!started_p3dpython) { - // Well, we couldn't run python in a sub-process, for some reason. - // Fall back to running it in a sub-thread within the same - // process. This isn't nearly as good, but I guess it's better - // than nothing. + // Well, we couldn't run python in a sub-process, for some reason. Fall + // back to running it in a sub-thread within the same process. This isn't + // nearly as good, but I guess it's better than nothing. INIT_THREAD(_p3dpython_thread); SPAWN_THREAD(_p3dpython_thread, p3dpython_thread_run, this); @@ -1271,7 +1212,7 @@ start_p3dpython(P3DInstance *inst) { if (!_pipe_write) { nout << "unable to open write pipe\n"; } - + spawn_read_thread(); // The very first command we send to the process is its session_id. @@ -1281,9 +1222,9 @@ start_p3dpython(P3DInstance *inst) { xcommand->SetAttribute("session_id", _session_id); doc.LinkEndChild(xcommand); write_xml(_pipe_write, &doc, nout); - - // Also feed it any commands we may have queued up from before the - // process was started. + + // Also feed it any commands we may have queued up from before the process + // was started. Commands::iterator ci; for (ci = _commands.begin(); ci != _commands.end(); ++ci) { write_xml(_pipe_write, (*ci), nout); @@ -1292,17 +1233,14 @@ start_p3dpython(P3DInstance *inst) { _commands.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::set_failed -// Access: Private -// Description: Sets the "failed" indication to display sadness to -// the user--we're unable to launch the instance for -// some reason. -// -// When this is called on the P3DSession instead of on a -// particular P3DInstance, it means that all instances -// attached to this session are marked failed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "failed" indication to display sadness to the user--we're unable + * to launch the instance for some reason. + * + * When this is called on the P3DSession instead of on a particular + * P3DInstance, it means that all instances attached to this session are + * marked failed. + */ void P3DSession:: set_failed() { _failed = true; @@ -1316,13 +1254,11 @@ set_failed() { RELEASE_LOCK(_instances_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::spawn_read_thread -// Access: Private -// Description: Starts the read thread. This thread is responsible -// for reading the standard input socket for XML -// requests and storing them in the _requests queue. -//////////////////////////////////////////////////////////////////// +/** + * Starts the read thread. This thread is responsible for reading the + * standard input socket for XML requests and storing them in the _requests + * queue. + */ void P3DSession:: spawn_read_thread() { assert(!_started_read_thread && !_read_thread_continue); @@ -1332,11 +1268,9 @@ spawn_read_thread() { _started_read_thread = true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::join_read_thread -// Access: Private -// Description: Waits for the read thread to stop. -//////////////////////////////////////////////////////////////////// +/** + * Waits for the read thread to stop. + */ void P3DSession:: join_read_thread() { if (!_started_read_thread) { @@ -1349,22 +1283,19 @@ join_read_thread() { _started_read_thread = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::replace_slashes -// Access: Private, Static -// Description: Changes the forward slashes to backslashes on -// Windows. Does nothing on the other platforms. -//////////////////////////////////////////////////////////////////// +/** + * Changes the forward slashes to backslashes on Windows. Does nothing on the + * other platforms. + */ void P3DSession:: replace_slashes(string &str) { #ifdef _WIN32 - // It turns out that some very low-level Windows functions fail when - // you give them a forward slash instead of a backslash. In - // particular, Windows fails to load the MSVS runtime DLL's (and - // their associated manifest files) correctly in this case. So we - // have to be sure to replace forward slashes in our PATH variable - // (and other environment variables, for good measure) with - // backslashes. + // It turns out that some very low-level Windows functions fail when you + // give them a forward slash instead of a backslash. In particular, Windows + // fails to load the MSVS runtime DLL's (and their associated manifest + // files) correctly in this case. So we have to be sure to replace forward + // slashes in our PATH variable (and other environment variables, for good + // measure) with backslashes. for (size_t i = 0; i < str.length(); ++i) { if (str[i] == '/') { str[i] = '\\'; @@ -1373,11 +1304,9 @@ replace_slashes(string &str) { #endif // _WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::rt_thread_run -// Access: Private -// Description: The main function for the read thread. -//////////////////////////////////////////////////////////////////// +/** + * The main function for the read thread. + */ void P3DSession:: rt_thread_run() { while (_read_thread_continue) { @@ -1399,21 +1328,18 @@ rt_thread_run() { nout << "Exiting rt_thread_run in " << this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::rt_handle_request -// Access: Private -// Description: Processes a single request or notification received -// from an instance. This method runs in the read -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Processes a single request or notification received from an instance. This + * method runs in the read thread. + */ void P3DSession:: rt_handle_request(TiXmlDocument *doc) { TiXmlElement *xresponse = doc->FirstChildElement("response"); if (xresponse != (TiXmlElement *)NULL) { int response_id; if (xresponse->QueryIntAttribute("response_id", &response_id) == TIXML_SUCCESS) { - // This is a response to a previous command-and-response. Send - // it to the parent thread. + // This is a response to a previous command-and-response. Send it to + // the parent thread. _response_ready.acquire(); bool inserted = _responses.insert(Responses::value_type(response_id, doc)).second; assert(inserted); @@ -1445,12 +1371,10 @@ rt_handle_request(TiXmlDocument *doc) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::rt_terminate -// Access: Private -// Description: Got a closed pipe from the sub-process. Send a -// terminate request for all instances. -//////////////////////////////////////////////////////////////////// +/** + * Got a closed pipe from the sub-process. Send a terminate request for all + * instances. + */ void P3DSession:: rt_terminate() { Instances icopy; @@ -1458,8 +1382,8 @@ rt_terminate() { icopy = _instances; RELEASE_LOCK(_instances_lock); - // TODO: got a race condition here. What happens if someone deletes - // an instance while we're processing this loop? + // TODO: got a race condition here. What happens if someone deletes an + // instance while we're processing this loop? for (Instances::iterator ii = icopy.begin(); ii != icopy.end(); ++ii) { P3DInstance *inst = (*ii).second; @@ -1468,23 +1392,18 @@ rt_terminate() { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::win_create_process -// Access: Private -// Description: Creates a sub-process to run _p3dpython_exe, with -// the appropriate command-line arguments, and the -// environment string defined in _env. Standard error -// is logged to _log_pathname, if that string is -// nonempty. -// -// Opens the two HandleStreams _pipe_read and -// _pipe_write as the read and write pipes to the child -// process's standard output and standard input, -// respectively. -// -// Returns the handle to the created process on success, -// or INVALID_HANDLE_VALUE on falure. -//////////////////////////////////////////////////////////////////// +/** + * Creates a sub-process to run _p3dpython_exe, with the appropriate command- + * line arguments, and the environment string defined in _env. Standard error + * is logged to _log_pathname, if that string is nonempty. + * + * Opens the two HandleStreams _pipe_read and _pipe_write as the read and + * write pipes to the child process's standard output and standard input, + * respectively. + * + * Returns the handle to the created process on success, or + * INVALID_HANDLE_VALUE on falure. + */ HANDLE P3DSession:: win_create_process() { // Make sure we see an error dialog if there is a missing DLL. @@ -1497,7 +1416,7 @@ win_create_process() { wstring log_pathname_w; string_to_wstring(log_pathname_w, _log_pathname); HANDLE handle = CreateFileW - (log_pathname_w.c_str(), GENERIC_WRITE, + (log_pathname_w.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, CREATE_ALWAYS, 0, NULL); if (handle != INVALID_HANDLE_VALUE) { @@ -1511,10 +1430,9 @@ win_create_process() { STARTUPINFOW startup_info; ZeroMemory(&startup_info, sizeof(startup_info)); - startup_info.cb = sizeof(startup_info); + startup_info.cb = sizeof(startup_info); - // Set up the I/O handles. We send stderr and stdout to our - // error_handle. + // Set up the IO handles. We send stderr and stdout to our error_handle. startup_info.hStdError = error_handle; startup_info.hStdOutput = error_handle; startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE); @@ -1524,9 +1442,8 @@ win_create_process() { startup_info.wShowWindow = SW_SHOW; startup_info.dwFlags |= STARTF_USESHOWWINDOW; - // If _keep_user_env is true, meaning not to change the current - // directory, then pass NULL in to CreateProcess(). Otherwise pass - // in _start_dir. + // If _keep_user_env is true, meaning not to change the current directory, + // then pass NULL in to CreateProcess(). Otherwise pass in _start_dir. const wchar_t *start_dir_cstr; wstring start_dir_w; if (_keep_user_env) { @@ -1538,16 +1455,16 @@ win_create_process() { nout << "Setting working directory: " << _start_dir << "\n"; } - // Construct the command-line string, containing the quoted - // command-line arguments. + // Construct the command-line string, containing the quoted command-line + // arguments. ostringstream stream; stream << "\"" << _p3dpython_exe << "\" \"" << _mf_filename << "\" \"" << _input_handle << "\" \"" << _output_handle << "\" \"" << _interactive_console << "\""; - // I'm not sure why CreateProcess wants a non-const char pointer for - // its command-line string, but I'm not taking chances. It gets a - // non-const char array that it can modify. + // I'm not sure why CreateProcess wants a non-const char pointer for its + // command-line string, but I'm not taking chances. It gets a non-const + // char array that it can modify. wstring command_line_str; string_to_wstring(command_line_str, stream.str()); wchar_t *command_line = new wchar_t[command_line_str.size() + 1]; @@ -1560,10 +1477,10 @@ win_create_process() { wstring env_w; string_to_wstring(env_w, _env); - PROCESS_INFORMATION process_info; + PROCESS_INFORMATION process_info; BOOL result = CreateProcessW - (p3dpython_exe_w.c_str(), command_line, NULL, NULL, TRUE, - CREATE_UNICODE_ENVIRONMENT, (void *)env_w.c_str(), + (p3dpython_exe_w.c_str(), command_line, NULL, NULL, TRUE, + CREATE_UNICODE_ENVIRONMENT, (void *)env_w.c_str(), start_dir_cstr, &startup_info, &process_info); bool started_program = (result != 0); @@ -1593,27 +1510,21 @@ win_create_process() { #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::posix_create_process -// Access: Private -// Description: Creates a sub-process to run _p3dpython_exe, with -// the appropriate command-line arguments, and the -// environment string defined in _env. Standard error -// is logged to _log_pathname, if that string is -// nonempty. -// -// Opens the two HandleStreams _pipe_read and -// _pipe_write as the read and write pipes to the child -// process's standard output and standard input, -// respectively. -// -// Returns the pid of the created process on success, or -// -1 on falure. -//////////////////////////////////////////////////////////////////// +/** + * Creates a sub-process to run _p3dpython_exe, with the appropriate command- + * line arguments, and the environment string defined in _env. Standard error + * is logged to _log_pathname, if that string is nonempty. + * + * Opens the two HandleStreams _pipe_read and _pipe_write as the read and + * write pipes to the child process's standard output and standard input, + * respectively. + * + * Returns the pid of the created process on success, or -1 on falure. + */ int P3DSession:: posix_create_process() { - // If the program file doesn't exist or isn't executable, don't even - // bother to try. + // If the program file doesn't exist or isn't executable, don't even bother + // to try. if (access(_p3dpython_exe.c_str(), X_OK) != 0) { return -1; } @@ -1634,7 +1545,7 @@ posix_create_process() { if (!_log_pathname.empty()) { // Open a logfile. - int logfile_fd = open(_log_pathname.c_str(), + int logfile_fd = open(_log_pathname.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666); if (logfile_fd < 0) { nout << "Unable to open " << _log_pathname << "\n"; @@ -1652,8 +1563,8 @@ posix_create_process() { nout << "Setting working directory: " << _start_dir << "\n"; if (chdir(_start_dir.c_str()) < 0) { nout << "Could not chdir to " << _start_dir << "\n"; - // This is a warning, not an error. We don't actually care - // that much about the starting directory. + // This is a warning, not an error. We don't actually care that much + // about the starting directory. } } @@ -1689,15 +1600,14 @@ posix_create_process() { close(_output_handle); // Let's wait a few milliseconds and see if the child is going to - // immediately exit with a failure status. This isn't 100% - // reliable, but it's a lot easier than sending back a "yes I - // successfully started the program" message. Maybe I'll put in the - // more reliable test later. + // immediately exit with a failure status. This isn't 100% reliable, but + // it's a lot easier than sending back a "yes I successfully started the + // program" message. Maybe I'll put in the more reliable test later. struct timeval start; gettimeofday(&start, NULL); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; - + int status; pid_t result = waitpid(child, &status, WNOHANG); while (result != child) { @@ -1705,18 +1615,18 @@ posix_create_process() { perror("waitpid"); break; } - + struct timeval now; gettimeofday(&now, NULL); int now_ms = now.tv_sec * 1000 + now.tv_usec / 1000; int elapsed = now_ms - start_ms; if (elapsed > 100) { - // OK, we've waited, and the child process is still alive. - // Assume it will stay that way. + // OK, we've waited, and the child process is still alive. Assume it + // will stay that way. nout << "child still alive after " << elapsed << " ms\n"; return child; } - + // Yield the timeslice and wait some more. struct timeval tv; tv.tv_sec = 0; @@ -1725,8 +1635,8 @@ posix_create_process() { result = waitpid(child, &status, WNOHANG); } - // The child process died for some reason; maybe it couldn't exec() - // its process. Report an error condition. + // The child process died for some reason; maybe it couldn't exec() its + // process. Report an error condition. nout << "Python process stopped immediately.\n"; if (WIFEXITED(status)) { int code = WEXITSTATUS(status); @@ -1751,24 +1661,21 @@ posix_create_process() { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::p3dpython_thread_run -// Access: Private -// Description: This method is called in a sub-thread to fire up -// p3dpython within this same process, but only if the -// above attempt to create a sub-process failed. -//////////////////////////////////////////////////////////////////// +/** + * This method is called in a sub-thread to fire up p3dpython within this same + * process, but only if the above attempt to create a sub-process failed. + */ void P3DSession:: p3dpython_thread_run() { nout << "running p3dpython_thread_run()\n"; - // Set the environment. Hopefully this won't be too destructive to - // the current process. + // Set the environment. Hopefully this won't be too destructive to the + // current process. - // Note that on OSX at least, changing the DYLD_LIBRARY_PATH after - // the process has started has no effect (and furthermore you can't - // specify a full path to dlopen() calls), so this whole one-process - // approach is fatally flawed on OSX. + // Note that on OSX at least, changing the DYLD_LIBRARY_PATH after the + // process has started has no effect (and furthermore you can't specify a + // full path to dlopen() calls), so this whole one-process approach is + // fatally flawed on OSX. size_t p = 0; size_t zero = _env.find('\0', p); while (zero != string::npos) { @@ -1791,7 +1698,7 @@ p3dpython_thread_run() { #ifdef _WIN32 #ifdef _DEBUG libp3dpython += "_d.dll"; -#else +#else libp3dpython += ".dll"; #endif SetErrorMode(0); @@ -1837,14 +1744,11 @@ p3dpython_thread_run() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::get_env -// Access: Private, Static -// Description: Implements getenv(), respecting Windows' Unicode -// environment. Returns true if the variable is -// defined, false if it is not. If it is defined, fills -// value with its definition. -//////////////////////////////////////////////////////////////////// +/** + * Implements getenv(), respecting Windows' Unicode environment. Returns true + * if the variable is defined, false if it is not. If it is defined, fills + * value with its definition. + */ bool P3DSession:: get_env(string &value, const string &varname) { #ifdef _WIN32 @@ -1866,14 +1770,10 @@ get_env(string &value, const string &varname) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: P3DSession::write_env -// Access: Private -// Description: Writes _env, which is formatted as a string -// containing zero-byte-terminated environment -// defintions, to the nout stream, one definition per -// line. -//////////////////////////////////////////////////////////////////// +/** + * Writes _env, which is formatted as a string containing zero-byte-terminated + * environment defintions, to the nout stream, one definition per line. + */ void P3DSession:: write_env() const { size_t p = 0; @@ -1886,4 +1786,3 @@ write_env() const { zero = _env.find('\0', p); } } - diff --git a/direct/src/plugin/p3dSession.h b/direct/src/plugin/p3dSession.h index 09c779b740..88db279379 100644 --- a/direct/src/plugin/p3dSession.h +++ b/direct/src/plugin/p3dSession.h @@ -1,16 +1,15 @@ -// Filename: p3dSession.h -// Created by: drose (03Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSession.h + * @author drose + * @date 2009-06-03 + */ #ifndef P3DSESSION_H #define P3DSESSION_H @@ -28,13 +27,11 @@ class P3DInstance; class P3DProgressWindow; -//////////////////////////////////////////////////////////////////// -// Class : P3DSession -// Description : Corresponds to a single session: a subprocess with a -// unique instance of Python running within it, which -// might include one or more P3DInstance objects running -// in the same memory space with each other. -//////////////////////////////////////////////////////////////////// +/** + * Corresponds to a single session: a subprocess with a unique instance of + * Python running within it, which might include one or more P3DInstance + * objects running in the same memory space with each other. + */ class P3DSession : public P3DReferenceCount { public: P3DSession(P3DInstance *inst); @@ -55,7 +52,7 @@ public: TiXmlDocument *command_and_response(TiXmlDocument *command); P3D_object *xml_to_p3dobj(const TiXmlElement *xvalue); TiXmlElement *p3dobj_to_xml(P3D_object *obj); - void send_windows_message(P3DInstance *inst, unsigned int msg, + void send_windows_message(P3DInstance *inst, unsigned int msg, int wparam, int lparam); void signal_request_ready(P3DInstance *inst); @@ -85,8 +82,8 @@ private: int posix_create_process(); #endif - // In case we can't get a separate process, we'll run p3dpython in a - // sub-thread. + // In case we can't get a separate process, we'll run p3dpython in a sub- + // thread. THREAD_CALLBACK_DECLARATION(P3DSession, p3dpython_thread_run); void p3dpython_thread_run(); @@ -116,29 +113,29 @@ private: Instances _instances; LOCK _instances_lock; - // Commands that are queued up to send down the pipe. Normally - // these only accumulate before the python process has been started; - // after that, commands are written to the pipe directly. + // Commands that are queued up to send down the pipe. Normally these only + // accumulate before the python process has been started; after that, + // commands are written to the pipe directly. typedef vector Commands; Commands _commands; - // This map keeps track of the P3D_object pointers we have delivered - // to the child process. We have to keep each of these until the - // child process tells us it's safe to delete them. + // This map keeps track of the P3D_object pointers we have delivered to the + // child process. We have to keep each of these until the child process + // tells us it's safe to delete them. typedef map SentObjects; SentObjects _sent_objects; P3DPackage *_panda3d; // If this is true, then CreateProcess() or fork() failed (or we had - // one_process set true in the tokens), and we're forced to run - // p3dpython in a sub-thread within the same process, rather than in - // a separate process. This means we can't have multiple sessions - // running simultaneously, because Python don't play that way. + // one_process set true in the tokens), and we're forced to run p3dpython in + // a sub-thread within the same process, rather than in a separate process. + // This means we can't have multiple sessions running simultaneously, + // because Python don't play that way. bool _p3dpython_one_process; - // Members for communicating with the p3dpython child process (or - // thread, as the case may be). + // Members for communicating with the p3dpython child process (or thread, as + // the case may be). #ifdef _WIN32 HANDLE _p3dpython_handle; #else diff --git a/direct/src/plugin/p3dSplashWindow.I b/direct/src/plugin/p3dSplashWindow.I index a26403cbf3..c9562a083a 100644 --- a/direct/src/plugin/p3dSplashWindow.I +++ b/direct/src/plugin/p3dSplashWindow.I @@ -1,54 +1,44 @@ -// Filename: p3dSplashWindow.I -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSplashWindow.I + * @author drose + * @date 2009-06-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::get_fparams -// Access: Public -// Description: Returns the current file parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file parameters. + */ inline const P3DFileParams &P3DSplashWindow:: get_fparams() const { return _fparams; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::get_wparams -// Access: Public -// Description: Returns the current window parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current window parameters. + */ inline const P3DWindowParams &P3DSplashWindow:: get_wparams() const { return _wparams; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::get_visible -// Access: Public -// Description: Returns the current setting of the "visible" flag. -// If false, the splash window is hidden. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the "visible" flag. If false, the splash + * window is hidden. + */ inline bool P3DSplashWindow:: get_visible() const { return _visible; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::ImageData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DSplashWindow::ImageData:: ImageData() { _width = 0; diff --git a/direct/src/plugin/p3dSplashWindow.cxx b/direct/src/plugin/p3dSplashWindow.cxx index 37960d4499..dc17b5c95a 100644 --- a/direct/src/plugin/p3dSplashWindow.cxx +++ b/direct/src/plugin/p3dSplashWindow.cxx @@ -1,37 +1,33 @@ -// Filename: p3dSplashWindow.cxx -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSplashWindow.cxx + * @author drose + * @date 2009-06-17 + */ #include "p3dSplashWindow.h" #include "wstring_encode.h" -// We use the public domain stb_image library for loading images. -// Define the stb_image implementation. We only use it in this unit. +// We use the public domain stb_image library for loading images. Define the +// stb_image implementation. We only use it in this unit. #define STB_IMAGE_STATIC #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" -// The number of pixels to move the block per byte downloaded, when we -// don't know the actual file size we're downloading. +// The number of pixels to move the block per byte downloaded, when we don't +// know the actual file size we're downloading. const double P3DSplashWindow::_unknown_progress_rate = 1.0 / 4096; -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::Constructor -// Access: Public -// Description: By the time the SplashWindow is created, the instance -// has received both its fparams and its wparams. Copy -// them both into this class for reference. -//////////////////////////////////////////////////////////////////// +/** + * By the time the SplashWindow is created, the instance has received both its + * fparams and its wparams. Copy them both into this class for reference. + */ P3DSplashWindow:: P3DSplashWindow(P3DInstance *inst, bool make_visible) : _inst(inst), @@ -73,22 +69,17 @@ P3DSplashWindow(P3DInstance *inst, bool make_visible) : _bstate = BS_hidden; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DSplashWindow:: ~P3DSplashWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_wparams -// Access: Public, Virtual -// Description: Changes the window parameters, e.g. to resize or -// reposition the window; or sets the parameters for the -// first time, creating the initial window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window parameters, e.g. to resize or reposition the window; or + * sets the parameters for the first time, creating the initial window. + */ void P3DSplashWindow:: set_wparams(const P3DWindowParams &wparams) { _wparams = wparams; @@ -96,42 +87,33 @@ set_wparams(const P3DWindowParams &wparams) { _win_height = _wparams.get_win_height(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_visible -// Access: Public, Virtual -// Description: Makes the splash window visible or invisible, so as -// not to compete with the embedded Panda window in the -// same space. -//////////////////////////////////////////////////////////////////// +/** + * Makes the splash window visible or invisible, so as not to compete with the + * embedded Panda window in the same space. + */ void P3DSplashWindow:: set_visible(bool visible) { nout << "P3DSplashWindow::set_visible(" << visible << ")\n"; _visible = visible; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_image_filename -// Access: Public, Virtual -// Description: Specifies the name of a JPEG or PNG image file that -// is displayed in the center of the splash window. -// -// image_placement defines the specific context in which -// this particular image is displayed. It is similar to -// the P3DInstance's image_type, but it is a more -// specific, lower-level usage. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a JPEG or PNG image file that is displayed in the + * center of the splash window. + * + * image_placement defines the specific context in which this particular image + * is displayed. It is similar to the P3DInstance's image_type, but it is a + * more specific, lower-level usage. + */ void P3DSplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_fgcolor -// Access: Public -// Description: Specifies the color that is used to display the text -// above the loading bar. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the color that is used to display the text above the loading bar. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_fgcolor(int r, int g, int b) { nout << "fgcolor " << r << ", " << g << ", " << b << "\n"; @@ -140,15 +122,12 @@ set_fgcolor(int r, int g, int b) { _fgcolor_b = b; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bgcolor -// Access: Public -// Description: Specifies the solid color that is displayed behind -// the splash image, if any, or before the splash image -// is loaded. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the solid color that is displayed behind the splash image, if + * any, or before the splash image is loaded. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bgcolor(int r, int g, int b) { nout << "bgcolor " << r << ", " << g << ", " << b << "\n"; @@ -157,14 +136,11 @@ set_bgcolor(int r, int g, int b) { _bgcolor_b = b; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_barcolor -// Access: Public -// Description: Specifies the color that is used to fill the -// loading bar. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the color that is used to fill the loading bar. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_barcolor(int r, int g, int b) { nout << "barcolor " << r << ", " << g << ", " << b << "\n"; @@ -173,14 +149,11 @@ set_barcolor(int r, int g, int b) { _barcolor_b = b; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bar_bgcolor -// Access: Public -// Description: Specifies the solid color that is displayed behind -// the loading bar. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the solid color that is displayed behind the loading bar. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bar_bgcolor(int r, int g, int b) { nout << "bar_bgcolor " << r << ", " << g << ", " << b << "\n"; @@ -189,45 +162,37 @@ set_bar_bgcolor(int r, int g, int b) { _bar_bgcolor_b = b; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bar_border -// Access: Public -// Description: Sets the width in pixels of the border around the -// loading bar, or 0 not to draw a bar at all. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width in pixels of the border around the loading bar, or 0 not to + * draw a bar at all. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bar_border(int border) { nout << "bar_border " << border << "\n"; _bar_border = border; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bar_bottom -// Access: Public -// Description: Sets the amount of background pixels between the -// bottom edge of the window and the bottom edge of -// the loading bar border. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of background pixels between the bottom edge of the window + * and the bottom edge of the loading bar border. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bar_bottom(int bottom) { nout << "bar_bottom " << bottom << "\n"; _bar_bottom = bottom; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bar_width -// Access: Public -// Description: Sets the width of the loading bar. If percent is -// true, it is interpreted as a percentage of the -// window width. If false, it is interpreted as an -// absolute width in pixels. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width of the loading bar. If percent is true, it is interpreted + * as a percentage of the window width. If false, it is interpreted as an + * absolute width in pixels. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bar_width(int width, bool percent) { nout << "bar_width " << width; @@ -245,16 +210,13 @@ set_bar_width(int width, bool percent) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bar_height -// Access: Public -// Description: Sets the height of the loading bar. If percent is -// true, it is interpreted as a percentage of the -// window height. If false, it is interpreted as an -// absolute height in pixels. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the height of the loading bar. If percent is true, it is interpreted + * as a percentage of the window height. If false, it is interpreted as an + * absolute height in pixels. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_bar_height(int height, bool percent) { nout << "bar_height " << height; @@ -272,104 +234,82 @@ set_bar_height(int height, bool percent) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_font_family -// Access: Public -// Description: Sets the font family of the text above the loading -// bar. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the font family of the text above the loading bar. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_font_family(const string &family) { nout << "font_family " << family << "\n"; _font_family = family; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_font_size -// Access: Public -// Description: Sets the font size in pixels of the text above the -// loading bar. The default value is 12. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the font size in pixels of the text above the loading bar. The + * default value is 12. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_font_size(int size) { nout << "font_size " << size << "\n"; _font_size = size; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_font_style -// Access: Public -// Description: Sets the font style of the text above the loading -// bar. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the font style of the text above the loading bar. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_font_style(FontStyle style) { nout << "font_style " << style << "\n"; _font_style = style; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_font_weight -// Access: Public -// Description: Sets the font weight of the text above the loading -// bar. The default is FW_normal. It should be -// a multiple of 100 in the range 100-900. -// -// This may only be set before wparams is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the font weight of the text above the loading bar. The default is + * FW_normal. It should be a multiple of 100 in the range 100-900. + * + * This may only be set before wparams is set. + */ void P3DSplashWindow:: set_font_weight(int weight) { nout << "font_weight " << weight << "\n"; _font_weight = weight; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_install_label -// Access: Public, Virtual -// Description: Specifies the text that is displayed above the -// install progress bar. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the text that is displayed above the install progress bar. + */ void P3DSplashWindow:: set_install_label(const string &install_label) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_install_progress -// Access: Public, Virtual -// Description: Moves the install progress bar from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Moves the install progress bar from 0.0 to 1.0. + */ void P3DSplashWindow:: set_install_progress(double install_progress, bool is_progress_known, size_t received_data) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::handle_event -// Access: Public, Virtual -// Description: Deals with the event callback from the OS window -// system. Returns true if the event is handled, false -// if ignored. -//////////////////////////////////////////////////////////////////// +/** + * Deals with the event callback from the OS window system. Returns true if + * the event is handled, false if ignored. + */ bool P3DSplashWindow:: handle_event(const P3D_event_data &event) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_button_active -// Access: Public, Virtual -// Description: Sets whether the button should be visible and active -// (true) or invisible and inactive (false). If active, -// the button image will be displayed in the window, and -// a click event will be generated when the user clicks -// the button. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the button should be visible and active (true) or invisible + * and inactive (false). If active, the button image will be displayed in the + * window, and a click event will be generated when the user clicks the + * button. + */ void P3DSplashWindow:: set_button_active(bool flag) { _button_active = flag; @@ -378,25 +318,19 @@ set_button_active(bool flag) { set_mouse_data(_mouse_x, _mouse_y, _mouse_down); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::request_keyboard_focus -// Access: Private -// Description: The Panda window is asking us to manage keyboard -// focus in proxy for it. This is used on Vista, where -// the Panda window may be disallowed from directly -// assigning itself keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * The Panda window is asking us to manage keyboard focus in proxy for it. + * This is used on Vista, where the Panda window may be disallowed from + * directly assigning itself keyboard focus. + */ void P3DSplashWindow:: request_keyboard_focus() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::read_image_data -// Access: Protected -// Description: Reads the image filename and sets image parameters -// width, height, num_channels, and data. Returns true -// on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the image filename and sets image parameters width, height, + * num_channels, and data. Returns true on success, false on failure. + */ bool P3DSplashWindow:: read_image_data(ImageData &image, string &data, const string &image_filename) { @@ -431,12 +365,10 @@ read_image_data(ImageData &image, string &data, return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::get_bar_placement -// Access: Protected -// Description: Given the window width and height, determine the -// rectangle in which to place the progress bar. -//////////////////////////////////////////////////////////////////// +/** + * Given the window width and height, determine the rectangle in which to + * place the progress bar. + */ void P3DSplashWindow:: get_bar_placement(int &bar_x, int &bar_y, int &bar_width, int &bar_height) { @@ -451,23 +383,20 @@ get_bar_placement(int &bar_x, int &bar_y, bar_height = min(bar_height, _bar_height); } - // Horizontally center the bar, and set it at a fixed distance - // from the bottom edge of the splash window. + // Horizontally center the bar, and set it at a fixed distance from the + // bottom edge of the splash window. bar_x = (_win_width - bar_width) / 2; bar_y = _win_height - _bar_bottom - _bar_border - bar_height; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_button_range -// Access: Protected -// Description: Specifies the image that contains the "ready" button -// image, which in turn determines the clickable -// dimensions of the button within the window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the image that contains the "ready" button image, which in turn + * determines the clickable dimensions of the button within the window. + */ void P3DSplashWindow:: set_button_range(const ImageData &image) { - // The clickable area has a certain minimum size, even if it's a - // very small image. + // The clickable area has a certain minimum size, even if it's a very small + // image. _button_width = max(image._width, 64); _button_height = max(image._height, 64); @@ -475,23 +404,18 @@ set_button_range(const ImageData &image) { _button_width = min(_button_width, _win_width); _button_height = min(_button_height, _win_height); - // Compute the top-left corner of the button image in window - // coordinates. + // Compute the top-left corner of the button image in window coordinates. _button_x = (_win_width - _button_width) / 2; _button_y = (_win_height - _button_height) / 2; } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_mouse_data -// Access: Protected -// Description: Intended to be called by the subclasses as the mouse -// is tracked through the window, whether the button is -// currently active or not. This updates the internal -// state of the mouse pointer, and also (if the button -// is active) updates the button state appropriately, -// and generates the click event when the mouse button -// transitions from down to up over the button area. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by the subclasses as the mouse is tracked through the + * window, whether the button is currently active or not. This updates the + * internal state of the mouse pointer, and also (if the button is active) + * updates the button state appropriately, and generates the click event when + * the mouse button transitions from down to up over the button area. + */ void P3DSplashWindow:: set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { ButtonState orig_bstate = _bstate; @@ -504,36 +428,35 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { bool click_detected = false; if (!_button_active) { - // The button isn't active, so it's hidden, regardless of the - // mouse position. + // The button isn't active, so it's hidden, regardless of the mouse + // position. bstate = BS_hidden; } else { // Is the mouse pointer within the button region? bool is_within = (_mouse_x >= _button_x && _mouse_x < _button_x + _button_width && _mouse_y >= _button_y && _mouse_y < _button_y + _button_height); if (is_within) { - // The mouse is within the button region. This means either - // click or rollover state, according to the mouse button. + // The mouse is within the button region. This means either click or + // rollover state, according to the mouse button. if (_mouse_down) { - // We only count it mouse-down if you've clicked down while - // over the button (or you never released the button since the - // last time you clicked down). Clicking down somewhere else - // and dragging over the button doesn't count. + // We only count it mouse-down if you've clicked down while over the + // button (or you never released the button since the last time you + // clicked down). Clicking down somewhere else and dragging over the + // button doesn't count. if (orig_bstate == BS_rollover || _button_depressed) { _button_depressed = true; bstate = BS_click; } else { - // Otherwise, we're mousing over the button region with the - // button held down. Hmm, don't think the button should - // light up. + // Otherwise, we're mousing over the button region with the button + // held down. Hmm, don't think the button should light up. bstate = BS_ready; } } else { _button_depressed = false; if (orig_bstate == BS_click) { - // If we just transitioned from mouse down to mouse up, this - // means a click. And the button automatically hides itself - // after a successful click. + // If we just transitioned from mouse down to mouse up, this means a + // click. And the button automatically hides itself after a + // successful click. bstate = BS_hidden; _button_active = false; click_detected = true; @@ -542,8 +465,7 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { } } } else { - // The mouse is not within the button region. This means ready - // state. + // The mouse is not within the button region. This means ready state. bstate = BS_ready; if (!_mouse_down) { _button_depressed = false; @@ -553,25 +475,21 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) { set_bstate(bstate); - // If we detected a click operation in the above, make the callback - // here, at the end of the method, after we have finished updating - // the button state. + // If we detected a click operation in the above, make the callback here, at + // the end of the method, after we have finished updating the button state. if (click_detected) { button_click_detected(); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::button_click_detected -// Access: Protected, Virtual -// Description: Called when a button click by the user is detected in -// set_mouse_data(), this method simply turns around and -// notifies the instance. It's a virtual method to give -// subclasses a chance to redirect this message to the -// main thread or process, as necessary. -// -// Note that this method might be called in a sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Called when a button click by the user is detected in set_mouse_data(), + * this method simply turns around and notifies the instance. It's a virtual + * method to give subclasses a chance to redirect this message to the main + * thread or process, as necessary. + * + * Note that this method might be called in a sub-thread. + */ void P3DSplashWindow:: button_click_detected() { assert(_inst != NULL); @@ -579,12 +497,9 @@ button_click_detected() { _inst->splash_button_clicked_sub_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::set_bstate -// Access: Protected, Virtual -// Description: Changes the button state as the mouse interacts with -// it. -//////////////////////////////////////////////////////////////////// +/** + * Changes the button state as the mouse interacts with it. + */ void P3DSplashWindow:: set_bstate(ButtonState bstate) { if (_bstate != bstate) { @@ -594,13 +509,10 @@ set_bstate(ButtonState bstate) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DSplashWindow::refresh -// Access: Protected, Virtual -// Description: Requests that the window will be repainted. This may -// or may not be implemented for a particular -// specialization of P3DSplashWindow. -//////////////////////////////////////////////////////////////////// +/** + * Requests that the window will be repainted. This may or may not be + * implemented for a particular specialization of P3DSplashWindow. + */ void P3DSplashWindow:: refresh() { } diff --git a/direct/src/plugin/p3dSplashWindow.h b/direct/src/plugin/p3dSplashWindow.h index 3b98b2cfa1..65c7301d7c 100644 --- a/direct/src/plugin/p3dSplashWindow.h +++ b/direct/src/plugin/p3dSplashWindow.h @@ -1,16 +1,15 @@ -// Filename: p3dSplashWindow.h -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dSplashWindow.h + * @author drose + * @date 2009-06-17 + */ #ifndef P3DSPLASHWINDOW_H #define P3DSPLASHWINDOW_H @@ -21,16 +20,14 @@ class P3DInstance; -//////////////////////////////////////////////////////////////////// -// Class : P3DSplashWindow -// Description : This window is displayed temporarily, in place of an -// instance's actual window, during the initial launch -// of an applet, and also during the initial download of -// Panda3D code if necessary. -// -// This is the base implementation; it contains no -// specific code to open a window. -//////////////////////////////////////////////////////////////////// +/** + * This window is displayed temporarily, in place of an instance's actual + * window, during the initial launch of an applet, and also during the initial + * download of Panda3D code if necessary. + * + * This is the base implementation; it contains no specific code to open a + * window. + */ class P3DSplashWindow { public: P3DSplashWindow(P3DInstance *inst, bool make_visible); @@ -87,9 +84,9 @@ public: virtual void request_keyboard_focus(); protected: - // This ImageData base class provides minimal functionality for - // storing a loaded image. Most of the real meat of this class is - // provided by the various subclasses. + // This ImageData base class provides minimal functionality for storing a + // loaded image. Most of the real meat of this class is provided by the + // various subclasses. class ImageData { public: inline ImageData(); diff --git a/direct/src/plugin/p3dStringObject.cxx b/direct/src/plugin/p3dStringObject.cxx index 45bbed1f2e..d0188a65af 100644 --- a/direct/src/plugin/p3dStringObject.cxx +++ b/direct/src/plugin/p3dStringObject.cxx @@ -1,42 +1,35 @@ -// Filename: p3dStringObject.cxx -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dStringObject.cxx + * @author drose + * @date 2009-06-30 + */ #include "p3dStringObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DStringObject:: P3DStringObject(const string &value) : _value(value) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DStringObject:: P3DStringObject(const char *data, size_t size) : _value(data, size) { } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DStringObject:: P3DStringObject(const P3DStringObject ©) : P3DObject(copy), @@ -44,54 +37,42 @@ P3DStringObject(const P3DStringObject ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DStringObject:: ~P3DStringObject() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DStringObject:: get_type() { return P3D_OT_string; } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DStringObject:: get_bool() { return !_value.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DStringObject:: make_string(string &value) { value = _value; } -//////////////////////////////////////////////////////////////////// -// Function: P3DStringObject::output -// Access: Public, Virtual -// Description: Writes a formatted representation of the value to the -// indicated string. This is intended for developer -// assistance. -//////////////////////////////////////////////////////////////////// +/** + * Writes a formatted representation of the value to the indicated string. + * This is intended for developer assistance. + */ void P3DStringObject:: output(ostream &out) { out << '"'; diff --git a/direct/src/plugin/p3dStringObject.h b/direct/src/plugin/p3dStringObject.h index bce0b62f92..22366023f7 100644 --- a/direct/src/plugin/p3dStringObject.h +++ b/direct/src/plugin/p3dStringObject.h @@ -1,16 +1,15 @@ -// Filename: p3dStringObject.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dStringObject.h + * @author drose + * @date 2009-06-30 + */ #ifndef P3DSTRINGOBJECT_H #define P3DSTRINGOBJECT_H @@ -18,10 +17,9 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DStringObject -// Description : An object type that contains a string value. -//////////////////////////////////////////////////////////////////// +/** + * An object type that contains a string value. + */ class P3DStringObject : public P3DObject { public: P3DStringObject(const string &value); @@ -42,4 +40,3 @@ private: }; #endif - diff --git a/direct/src/plugin/p3dTemporaryFile.I b/direct/src/plugin/p3dTemporaryFile.I index ae878afa8b..104fefa420 100644 --- a/direct/src/plugin/p3dTemporaryFile.I +++ b/direct/src/plugin/p3dTemporaryFile.I @@ -1,23 +1,19 @@ -// Filename: p3dTemporaryFile.I -// Created by: drose (19Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dTemporaryFile.I + * @author drose + * @date 2009-08-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DTemporaryFile::get_filename -// Access: Public -// Description: Returns the temporary filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the temporary filename. + */ inline const string &P3DTemporaryFile:: get_filename() const { return _filename; diff --git a/direct/src/plugin/p3dTemporaryFile.cxx b/direct/src/plugin/p3dTemporaryFile.cxx index ca83347b64..ca7abe701a 100644 --- a/direct/src/plugin/p3dTemporaryFile.cxx +++ b/direct/src/plugin/p3dTemporaryFile.cxx @@ -1,36 +1,31 @@ -// Filename: p3dTemporaryFile.cxx -// Created by: drose (19Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dTemporaryFile.cxx + * @author drose + * @date 2009-08-19 + */ #include "p3dTemporaryFile.h" #include "p3dInstanceManager.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DTemporaryFile::Constructor -// Access: Public -// Description: Constructs a new, unique temporary filename. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new, unique temporary filename. + */ P3DTemporaryFile:: P3DTemporaryFile(const string &extension) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _filename = inst_mgr->make_temp_filename(extension); } -//////////////////////////////////////////////////////////////////// -// Function: P3DTemporaryFile::Destructor -// Access: Public -// Description: Deletes the temporary file, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the temporary file, if it exists. + */ P3DTemporaryFile:: ~P3DTemporaryFile() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); diff --git a/direct/src/plugin/p3dTemporaryFile.h b/direct/src/plugin/p3dTemporaryFile.h index 7e17b80c1c..f4b87df247 100644 --- a/direct/src/plugin/p3dTemporaryFile.h +++ b/direct/src/plugin/p3dTemporaryFile.h @@ -1,32 +1,29 @@ -// Filename: p3dTemporaryFile.h -// Created by: drose (19Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dTemporaryFile.h + * @author drose + * @date 2009-08-19 + */ #ifndef P3DTEMPORARYFILE_H #define P3DTEMPORARYFILE_H #include "p3d_plugin_common.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DTemporaryFile -// Description : This represents a temporary filename for some -// transitory purpose. This returns a filename which is -// guaranteed to be unique at the time the constructor -// was called. -// -// The file on disk, if it exists, will automatically be -// deleted when the destructor is called. -//////////////////////////////////////////////////////////////////// +/** + * This represents a temporary filename for some transitory purpose. This + * returns a filename which is guaranteed to be unique at the time the + * constructor was called. + * + * The file on disk, if it exists, will automatically be deleted when the + * destructor is called. + */ class P3DTemporaryFile { public: P3DTemporaryFile(const string &extension); diff --git a/direct/src/plugin/p3dUndefinedObject.cxx b/direct/src/plugin/p3dUndefinedObject.cxx index 8c12e88207..80cbb5897d 100644 --- a/direct/src/plugin/p3dUndefinedObject.cxx +++ b/direct/src/plugin/p3dUndefinedObject.cxx @@ -1,55 +1,45 @@ -// Filename: p3dUndefinedObject.cxx -// Created by: drose (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dUndefinedObject.cxx + * @author drose + * @date 2009-07-07 + */ #include "p3dUndefinedObject.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DUndefinedObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DUndefinedObject:: P3DUndefinedObject() { } -//////////////////////////////////////////////////////////////////// -// Function: P3DUndefinedObject::get_type -// Access: Public, Virtual -// Description: Returns the fundamental type of this kind of object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental type of this kind of object. + */ P3D_object_type P3DUndefinedObject:: get_type() { return P3D_OT_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: P3DUndefinedObject::get_bool -// Access: Public, Virtual -// Description: Returns the object value coerced to a boolean, if -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object value coerced to a boolean, if possible. + */ bool P3DUndefinedObject:: get_bool() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DUndefinedObject::make_string -// Access: Public, Virtual -// Description: Fills the indicated C++ string object with the value -// of this object coerced to a string. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated C++ string object with the value of this object coerced + * to a string. + */ void P3DUndefinedObject:: make_string(string &value) { value = "Undefined"; diff --git a/direct/src/plugin/p3dUndefinedObject.h b/direct/src/plugin/p3dUndefinedObject.h index b3ec82ea52..9ab8189de6 100644 --- a/direct/src/plugin/p3dUndefinedObject.h +++ b/direct/src/plugin/p3dUndefinedObject.h @@ -1,16 +1,15 @@ -// Filename: p3dUndefinedObject.h -// Created by: drose (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dUndefinedObject.h + * @author drose + * @date 2009-07-07 + */ #ifndef P3DUNDEFINEDOBJECT_H #define P3DUNDEFINEDOBJECT_H @@ -18,12 +17,11 @@ #include "p3d_plugin_common.h" #include "p3dObject.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DUndefinedObject -// Description : An object type that represents an undefined value. -// Python doesn't have such a concept, but JavaScript -// does, and it is sometimes an important return value. -//////////////////////////////////////////////////////////////////// +/** + * An object type that represents an undefined value. Python doesn't have + * such a concept, but JavaScript does, and it is sometimes an important + * return value. + */ class P3DUndefinedObject : public P3DObject { public: P3DUndefinedObject(); @@ -35,4 +33,3 @@ public: }; #endif - diff --git a/direct/src/plugin/p3dWinSplashWindow.I b/direct/src/plugin/p3dWinSplashWindow.I index b169286746..20cafcc1bf 100644 --- a/direct/src/plugin/p3dWinSplashWindow.I +++ b/direct/src/plugin/p3dWinSplashWindow.I @@ -1,36 +1,29 @@ -// Filename: p3dWinSplashWindow.I -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWinSplashWindow.I + * @author drose + * @date 2009-06-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::WinImageData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DWinSplashWindow::WinImageData:: WinImageData() { _filename_changed = false; _bitmap = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::WinImageData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DWinSplashWindow::WinImageData:: ~WinImageData() { dump_image(); } - diff --git a/direct/src/plugin/p3dWinSplashWindow.cxx b/direct/src/plugin/p3dWinSplashWindow.cxx index 999abdb86f..eb4d242430 100644 --- a/direct/src/plugin/p3dWinSplashWindow.cxx +++ b/direct/src/plugin/p3dWinSplashWindow.cxx @@ -1,16 +1,15 @@ -// Filename: p3dWinSplashWindow.cxx -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWinSplashWindow.cxx + * @author drose + * @date 2009-06-17 + */ #include "p3dWinSplashWindow.h" @@ -22,13 +21,11 @@ bool P3DWinSplashWindow::_registered_window_class = false; -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DWinSplashWindow:: -P3DWinSplashWindow(P3DInstance *inst, bool make_visible) : +P3DWinSplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) { _thread = NULL; @@ -55,11 +52,9 @@ P3DWinSplashWindow(P3DInstance *inst, bool make_visible) : INIT_LOCK(_install_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DWinSplashWindow:: ~P3DWinSplashWindow() { stop_thread(); @@ -67,13 +62,10 @@ P3DWinSplashWindow:: DESTROY_LOCK(_install_lock); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::set_wparams -// Access: Public, Virtual -// Description: Changes the window parameters, e.g. to resize or -// reposition the window; or sets the parameters for the -// first time, creating the initial window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window parameters, e.g. to resize or reposition the window; or + * sets the parameters for the first time, creating the initial window. + */ void P3DWinSplashWindow:: set_wparams(const P3DWindowParams &wparams) { P3DSplashWindow::set_wparams(wparams); @@ -83,13 +75,10 @@ set_wparams(const P3DWindowParams &wparams) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::set_visible -// Access: Public, Virtual -// Description: Makes the splash window visible or invisible, so as -// not to compete with the embedded Panda window in the -// same space. -//////////////////////////////////////////////////////////////////// +/** + * Makes the splash window visible or invisible, so as not to compete with the + * embedded Panda window in the same space. + */ void P3DWinSplashWindow:: set_visible(bool visible) { P3DSplashWindow::set_visible(visible); @@ -101,12 +90,10 @@ set_visible(bool visible) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::set_image_filename -// Access: Public, Virtual -// Description: Specifies the name of a JPEG image file that is -// displayed in the center of the splash window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a JPEG image file that is displayed in the center of + * the splash window. + */ void P3DWinSplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << ", thread_id = " << _thread_id << "\n"; @@ -124,7 +111,7 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) case IP_button_rollover: image = &_button_rollover_image; break; - + case IP_button_click: image = &_button_click_image; break; @@ -143,19 +130,16 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) PostThreadMessage(_thread_id, WM_USER, 0, 0); if (!_thread_running && _thread_continue) { - // The user must have closed the window. Let's shut down the - // instance, too. + // The user must have closed the window. Let's shut down the instance, + // too. _inst->request_stop_main_thread(); } } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::set_install_label -// Access: Public, Virtual -// Description: Specifies the text that is displayed above the -// install progress bar. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the text that is displayed above the install progress bar. + */ void P3DWinSplashWindow:: set_install_label(const string &install_label) { ACQUIRE_LOCK(_install_lock); @@ -169,18 +153,16 @@ set_install_label(const string &install_label) { PostThreadMessage(_thread_id, WM_USER, 0, 0); if (!_thread_running && _thread_continue) { - // The user must have closed the window. Let's shut down the - // instance, too. + // The user must have closed the window. Let's shut down the instance, + // too. _inst->request_stop_main_thread(); } } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::set_install_progress -// Access: Public, Virtual -// Description: Moves the install progress bar from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Moves the install progress bar from 0.0 to 1.0. + */ void P3DWinSplashWindow:: set_install_progress(double install_progress, bool is_progress_known, size_t received_data) { @@ -195,21 +177,18 @@ set_install_progress(double install_progress, PostThreadMessage(_thread_id, WM_USER, 0, 0); if (!_thread_running && _thread_continue) { - // The user must have closed the window. Let's shut down the - // instance, too. + // The user must have closed the window. Let's shut down the instance, + // too. _inst->request_stop_main_thread(); } } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::request_keyboard_focus -// Access: Private -// Description: The Panda window is asking us to manage keyboard -// focus in proxy for it. This is used on Vista, where -// the Panda window may be disallowed from directly -// assigning itself keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * The Panda window is asking us to manage keyboard focus in proxy for it. + * This is used on Vista, where the Panda window may be disallowed from + * directly assigning itself keyboard focus. + */ void P3DWinSplashWindow:: request_keyboard_focus() { // Store the time at which we last requested focus. @@ -219,19 +198,16 @@ request_keyboard_focus() { ACQUIRE_LOCK(_install_lock); ++_focus_seq; RELEASE_LOCK(_install_lock); - + if (_thread_id != 0) { // Post a silly message to spin the message loop. PostThreadMessage(_thread_id, WM_USER, 0, 0); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::register_window_class -// Access: Public, Static -// Description: Registers the window class for this window, if -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for this window, if needed. + */ void P3DWinSplashWindow:: register_window_class() { if (!_registered_window_class) { @@ -243,7 +219,7 @@ register_window_class() { wc.hInstance = application; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = "panda3d_splash"; - + if (!RegisterClass(&wc)) { nout << "Could not register window class panda3d_splash\n"; } @@ -251,12 +227,10 @@ register_window_class() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::unregister_window_class -// Access: Public, Static -// Description: Unregisters the window class for this window. It is -// necessary to do this before unloading the DLL. -//////////////////////////////////////////////////////////////////// +/** + * Unregisters the window class for this window. It is necessary to do this + * before unloading the DLL. + */ void P3DWinSplashWindow:: unregister_window_class() { if (_registered_window_class) { @@ -269,25 +243,20 @@ unregister_window_class() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::button_click_detected -// Access: Protected, Virtual -// Description: Called when a button click by the user is detected in -// set_mouse_data(), this method simply turns around and -// notifies the instance. It's a virtual method to give -// subclasses a chance to redirect this message to the -// main thread or process, as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called when a button click by the user is detected in set_mouse_data(), + * this method simply turns around and notifies the instance. It's a virtual + * method to give subclasses a chance to redirect this message to the main + * thread or process, as necessary. + */ void P3DWinSplashWindow:: button_click_detected() { P3DSplashWindow::button_click_detected(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::start_thread -// Access: Private -// Description: Spawns the sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Spawns the sub-thread. + */ void P3DWinSplashWindow:: start_thread() { _thread_continue = true; @@ -299,11 +268,9 @@ start_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::stop_thread -// Access: Private -// Description: Terminates and joins the sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Terminates and joins the sub-thread. + */ void P3DWinSplashWindow:: stop_thread() { _thread_continue = false; @@ -314,32 +281,28 @@ stop_thread() { } if (_thread != NULL){ - // If the thread doesn't close right away, call PeekMessage() to - // check for Windows messages that the thread might be waiting - // for. + // If the thread doesn't close right away, call PeekMessage() to check for + // Windows messages that the thread might be waiting for. while (WaitForSingleObject(_thread, 200) == WAIT_TIMEOUT) { MSG msg; PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_NOYIELD); nout << "Waiting for thread\n"; } - + CloseHandle(_thread); _thread = NULL; - // Now that the thread has exited, we can safely close its window. - // (We couldn't close the window in the thread, because that would - // cause a deadlock situation--the thread can't acknowledge the - // window closing until we spin the event loop in the parent - // thread.) + // Now that the thread has exited, we can safely close its window. (We + // couldn't close the window in the thread, because that would cause a + // deadlock situation--the thread can't acknowledge the window closing + // until we spin the event loop in the parent thread.) close_window(); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::thread_run -// Access: Private -// Description: The sub-thread's main run method. -//////////////////////////////////////////////////////////////////// +/** + * The sub-thread's main run method. + */ void P3DWinSplashWindow:: thread_run() { make_window(); @@ -414,56 +377,51 @@ thread_run() { _inst->request_stop_sub_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::win_thread_run -// Access: Private, Static -// Description: The OS-specific thread callback function. -//////////////////////////////////////////////////////////////////// +/** + * The OS-specific thread callback function. + */ DWORD P3DWinSplashWindow:: win_thread_run(LPVOID data) { ((P3DWinSplashWindow *)data)->thread_run(); return 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::make_window -// Access: Private -// Description: Creates the window for displaying progress. Runs -// within the sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for displaying progress. Runs within the sub-thread. + */ void P3DWinSplashWindow:: make_window() { register_window_class(); HINSTANCE application = GetModuleHandle(NULL); - + int width = 320; int height = 240; if (_wparams.get_win_width() != 0 && _wparams.get_win_height() != 0) { width = _wparams.get_win_width(); height = _wparams.get_win_height(); } - + int x = _wparams.get_win_x(); int y = _wparams.get_win_y(); if (x == -1) x = CW_USEDEFAULT; if (y == -1) y = CW_USEDEFAULT; if (x == -2) x = (int)(0.5 * (GetSystemMetrics(SM_CXSCREEN) - width)); if (y == -2) y = (int)(0.5 * (GetSystemMetrics(SM_CYSCREEN) - height)); - + if (_wparams.get_window_type() == P3D_WT_embedded) { // Create an embedded window. - DWORD window_style = + DWORD window_style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; const P3D_window_handle &handle = _wparams.get_parent_window(); assert(handle._window_handle_type == P3D_WHT_win_hwnd); HWND parent_hwnd = handle._handle._win_hwnd._hwnd; - _hwnd = + _hwnd = CreateWindow("panda3d_splash", "Panda3D", window_style, x, y, width, height, parent_hwnd, NULL, application, 0); - + if (!_hwnd) { nout << "Could not create embedded window!\n"; return; @@ -471,7 +429,7 @@ make_window() { } else { // Create a toplevel window. - DWORD window_style = + DWORD window_style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; @@ -479,7 +437,7 @@ make_window() { RECT win_rect = { 0, 0, width, height }; // Adjust window size based on desired client area size AdjustWindowRect(&win_rect, window_style, FALSE); - _hwnd = + _hwnd = CreateWindow("panda3d_splash", "Panda3D", window_style, x, y, win_rect.right - win_rect.left, @@ -516,13 +474,10 @@ make_window() { _bar_bg_brush = CreateSolidBrush(RGB(_bar_bgcolor_r, _bar_bgcolor_g, _bar_bgcolor_b)); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::update_image -// Access: Private -// Description: Loads the image from the named file (if it has -// changed), converts to to BITMAP form, and stores it -// in _bitmap. Runs only in the sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Loads the image from the named file (if it has changed), converts to to + * BITMAP form, and stores it in _bitmap. Runs only in the sub-thread. + */ void P3DWinSplashWindow:: update_image(WinImageData &image) { if (!image._filename_changed) { @@ -534,8 +489,7 @@ update_image(WinImageData &image) { // Clear the old image. image.dump_image(); - // Since we'll be displaying a new image, we need to refresh the - // window. + // Since we'll be displaying a new image, we need to refresh the window. InvalidateRect(_hwnd, NULL, TRUE); // Go read the image. @@ -552,8 +506,8 @@ update_image(WinImageData &image) { char *new_data = new char[new_data_length]; if (image._num_channels == 4) { - // We have to reverse the order of the RGB channels: libjpeg and - // Windows follow an opposite convention. + // We have to reverse the order of the RGB channels: libjpeg and Windows + // follow an opposite convention. for (int yi = 0; yi < image._height; ++yi) { const char *sp = data.data() + yi * row_stride; char *dp = new_data + yi * new_row_stride; @@ -567,8 +521,8 @@ update_image(WinImageData &image) { } } } else if (image._num_channels == 3) { - // We have to reverse the order of the RGB channels: libjpeg and - // Windows follow an opposite convention. + // We have to reverse the order of the RGB channels: libjpeg and Windows + // follow an opposite convention. for (int yi = 0; yi < image._height; ++yi) { const char *sp = data.data() + yi * row_stride; char *dp = new_data + yi * new_row_stride; @@ -623,12 +577,10 @@ update_image(WinImageData &image) { nout << "Loaded image: " << image._filename << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::close_window -// Access: Private -// Description: Closes the window created above. This call is -// actually made in the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window created above. This call is actually made in the main + * thread. + */ void P3DWinSplashWindow:: close_window() { if (_hwnd != NULL) { @@ -636,7 +588,7 @@ close_window() { CloseWindow(_hwnd); _hwnd = NULL; } - + if (_fg_brush != NULL) { DeleteObject(_fg_brush); _fg_brush = NULL; @@ -660,12 +612,9 @@ close_window() { _button_click_image.dump_image(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::paint_window -// Access: Private -// Description: Paints the contents of the window into the indicated -// DC. -//////////////////////////////////////////////////////////////////// +/** + * Paints the contents of the window into the indicated DC. + */ void P3DWinSplashWindow:: paint_window(HDC dc) { RECT rect; @@ -709,8 +658,8 @@ paint_window(HDC dc) { break; } - // Draw the progress bar. We don't draw this bar at all unless we - // have nonzero progress. + // Draw the progress bar. We don't draw this bar at all unless we have + // nonzero progress. if (!_drawn_progress_known || _drawn_progress != 0.0) { paint_progress_bar(bdc); } @@ -721,14 +670,11 @@ paint_window(HDC dc) { DeleteObject(bdc); DeleteObject(buffer); } - -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::paint_image -// Access: Private -// Description: Draws the indicated image, centered within the -// window. Returns true on success, false if the image -// is not defined. -//////////////////////////////////////////////////////////////////// + +/** + * Draws the indicated image, centered within the window. Returns true on + * success, false if the image is not defined. + */ bool P3DWinSplashWindow:: paint_image(HDC dc, const WinImageData &image, bool use_alpha) { if (image._bitmap == NULL) { @@ -738,7 +684,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { // Paint the background splash image. HDC mem_dc = CreateCompatibleDC(dc); SelectObject(mem_dc, image._bitmap); - + // Determine the relative size of bitmap and window. int win_cx = _win_width / 2; int win_cy = _win_height / 2; @@ -748,10 +694,10 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { bf.BlendFlags = 0; bf.SourceConstantAlpha = 0xff; bf.AlphaFormat = AC_SRC_ALPHA; - + if (image._width <= _win_width && image._height <= _win_height) { // The bitmap fits within the window; center it. - + // This is the top-left corner of the bitmap in window coordinates. int p_x = win_cx - image._width / 2; int p_y = win_cy - image._height / 2; @@ -764,7 +710,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { mem_dc, 0, 0, image._width, image._height, bf); } - + } else { // The bitmap is larger than the window; scale it down. double x_scale = (double)_win_width / (double)image._width; @@ -772,7 +718,7 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { double scale = min(x_scale, y_scale); int sc_width = (int)(image._width * scale); int sc_height = (int)(image._height * scale); - + int p_x = win_cx - sc_width / 2; int p_y = win_cy - sc_height / 2; @@ -780,30 +726,27 @@ paint_image(HDC dc, const WinImageData &image, bool use_alpha) { StretchBlt(dc, p_x, p_y, sc_width, sc_height, mem_dc, 0, 0, image._width, image._height, SRCCOPY); } else { - // For some reason, AlphaBlend has issues when scaling a - // black-and-white image to draw onto the window: it draws the - // image in the last fill color used on the dc, instead of - // black. This only happens when the image consists only of - // black and white, and only when the image is being scaled. - // Weird. But StretchBlt, above, doesn't have this problem. + // For some reason, AlphaBlend has issues when scaling a black-and-white + // image to draw onto the window: it draws the image in the last fill + // color used on the dc, instead of black. This only happens when the + // image consists only of black and white, and only when the image is + // being scaled. Weird. But StretchBlt, above, doesn't have this + // problem. AlphaBlend(dc, p_x, p_y, sc_width, sc_height, - mem_dc, 0, 0, image._width, image._height, + mem_dc, 0, 0, image._width, image._height, bf); } } - + SelectObject(mem_dc, NULL); DeleteDC(mem_dc); return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::paint_progress_bar -// Access: Private -// Description: Draws the progress bar and the label within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Draws the progress bar and the label within the window. + */ void P3DWinSplashWindow:: paint_progress_bar(HDC dc) { int bar_x, bar_y, bar_width, bar_height; @@ -822,8 +765,8 @@ paint_progress_bar(HDC dc) { FillRect(dc, &prog_rect, _bar_brush); } } else { - // Progress is unknown. Draw a moving block, not a progress bar - // filling up. + // Progress is unknown. Draw a moving block, not a progress bar filling + // up. int block_width = (int)(bar_width * 0.1 + 0.5); int block_travel = bar_width - block_width; int progress = (int)(_received_data * _unknown_progress_rate); @@ -832,7 +775,7 @@ paint_progress_bar(HDC dc) { progress = block_travel * 2 - progress; } - RECT prog_rect = { bar_x + progress, bar_y, + RECT prog_rect = { bar_x + progress, bar_y, bar_x + progress + block_width, bar_y + bar_height }; FillRect(dc, &prog_rect, _bar_brush); } @@ -872,16 +815,14 @@ paint_progress_bar(HDC dc) { // And finally, draw the text. SetTextColor(dc, RGB(_fgcolor_r, _fgcolor_g, _fgcolor_b)); SetBkColor(dc, RGB(_bgcolor_r, _bgcolor_g, _bgcolor_b)); - DrawText(dc, text, -1, &text_rect, + DrawText(dc, text, -1, &text_rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::window_proc -// Access: Private -// Description: The windows event-processing handler. -//////////////////////////////////////////////////////////////////// +/** + * The windows event-processing handler. + */ LRESULT P3DWinSplashWindow:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -895,7 +836,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_ERASEBKGND: return true; - + case WM_PAINT: { PAINTSTRUCT ps; @@ -905,7 +846,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } return true; - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: set_mouse_data(LOWORD(lparam), HIWORD(lparam), _mouse_down); break; @@ -920,12 +861,11 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_KILLFOCUS: - // Someone on the desktop is playing games with us. It keeps - // wanting to grab the keyboard focus back immediately after we - // successfully call SetFocus(). Well, we really mean it, darn it - // all. If we got a WM_KILLFOCUS within a few milliseconds of - // calling SetFocus(), well, call SetFocus() again, until it - // sticks. + // Someone on the desktop is playing games with us. It keeps wanting to + // grab the keyboard focus back immediately after we successfully call + // SetFocus(). Well, we really mean it, darn it all. If we got a + // WM_KILLFOCUS within a few milliseconds of calling SetFocus(), well, + // call SetFocus() again, until it sticks. { int elapsed = GetTickCount() - _request_focus_tick; if (elapsed < 200) { @@ -946,7 +886,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_CHAR: case WM_SYSKEYDOWN: case WM_SYSCOMMAND: - case WM_KEYDOWN: + case WM_KEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: if (_inst->get_session() != NULL) { @@ -958,11 +898,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::st_window_proc -// Access: Private, Static -// Description: The windows event-processing handler, static version. -//////////////////////////////////////////////////////////////////// +/** + * The windows event-processing handler, static version. + */ LRESULT P3DWinSplashWindow:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -974,11 +912,9 @@ st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return ((P3DWinSplashWindow *)self)->window_proc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: P3DWinSplashWindow::WinImageData::dump_image -// Access: Public -// Description: Frees the previous image data. -//////////////////////////////////////////////////////////////////// +/** + * Frees the previous image data. + */ void P3DWinSplashWindow::WinImageData:: dump_image() { if (_bitmap != NULL) { diff --git a/direct/src/plugin/p3dWinSplashWindow.h b/direct/src/plugin/p3dWinSplashWindow.h index 33c9f9d584..852d794cb8 100644 --- a/direct/src/plugin/p3dWinSplashWindow.h +++ b/direct/src/plugin/p3dWinSplashWindow.h @@ -1,16 +1,15 @@ -// Filename: p3dWinSplashWindow.h -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWinSplashWindow.h + * @author drose + * @date 2009-06-17 + */ #ifndef P3DWINSPLASHWINDOW_H #define P3DWINSPLASHWINDOW_H @@ -24,11 +23,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : P3DWinSplashWindow -// Description : This is the Windows implementation of the -// initial-download window. -//////////////////////////////////////////////////////////////////// +/** + * This is the Windows implementation of the initial-download window. + */ class P3DWinSplashWindow : public P3DSplashWindow { public: P3DWinSplashWindow(P3DInstance *inst, bool make_visible); diff --git a/direct/src/plugin/p3dWindowParams.I b/direct/src/plugin/p3dWindowParams.I index 8b7eff0162..667d94210a 100644 --- a/direct/src/plugin/p3dWindowParams.I +++ b/direct/src/plugin/p3dWindowParams.I @@ -1,89 +1,68 @@ -// Filename: p3dWindowParams.I -// Created by: drose (22Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWindowParams.I + * @author drose + * @date 2009-06-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_window_type -// Access: Public -// Description: Returns the window_type that was passed to the -// constructor, or to set_window_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the window_type that was passed to the constructor, or to + * set_window_type(). + */ inline P3D_window_type P3DWindowParams:: get_window_type() const { return _window_type; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::set_window_type -// Access: Public -// Description: Changes the window_type. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window_type. + */ inline void P3DWindowParams:: set_window_type(P3D_window_type window_type) { _window_type = window_type; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_window_x -// Access: Public -// Description: Returns the window origin X coordinate that was -// passed to the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window origin X coordinate that was passed to the constructor. + */ inline int P3DWindowParams:: get_win_x() const { return _win_x; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_win_y -// Access: Public -// Description: Returns the window origin Y coordinate that was -// passed to the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window origin Y coordinate that was passed to the constructor. + */ inline int P3DWindowParams:: get_win_y() const { return _win_y; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_win_width -// Access: Public -// Description: Returns the window width that was passed to the -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window width that was passed to the constructor. + */ inline int P3DWindowParams:: get_win_width() const { return _win_width; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_win_height -// Access: Public -// Description: Returns the window height that was passed to the -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window height that was passed to the constructor. + */ inline int P3DWindowParams:: get_win_height() const { return _win_height; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::get_parent_window -// Access: Public -// Description: Returns the parent window handle that was passed to -// the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent window handle that was passed to the constructor. + */ inline const P3D_window_handle &P3DWindowParams:: get_parent_window() const { return _parent_window; diff --git a/direct/src/plugin/p3dWindowParams.cxx b/direct/src/plugin/p3dWindowParams.cxx index 0d6b3b3ef3..e6e9b750e4 100644 --- a/direct/src/plugin/p3dWindowParams.cxx +++ b/direct/src/plugin/p3dWindowParams.cxx @@ -1,24 +1,21 @@ -// Filename: p3dWindowParams.cxx -// Created by: drose (22Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWindowParams.cxx + * @author drose + * @date 2009-06-22 + */ #include "p3dWindowParams.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DWindowParams:: P3DWindowParams() : _window_type(P3D_WT_hidden), @@ -27,11 +24,9 @@ P3DWindowParams() : { } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DWindowParams:: P3DWindowParams(P3D_window_type window_type, int win_x, int win_y, @@ -44,11 +39,9 @@ P3DWindowParams(P3D_window_type window_type, { } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void P3DWindowParams:: operator = (const P3DWindowParams &other) { _window_type = other._window_type; @@ -59,13 +52,10 @@ operator = (const P3DWindowParams &other) { _parent_window = other._parent_window; } -//////////////////////////////////////////////////////////////////// -// Function: P3DWindowParams::make_xml -// Access: Public -// Description: Returns a newly-allocated XML structure that -// corresponds to the window parameter data within this -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated XML structure that corresponds to the window + * parameter data within this instance. + */ TiXmlElement *P3DWindowParams:: make_xml(P3DInstance *inst) { TiXmlElement *xwparams = new TiXmlElement("wparams"); @@ -85,8 +75,8 @@ make_xml(P3DInstance *inst) { xwparams->SetAttribute("subprocess_window", inst->_shared_filename); #elif defined(HAVE_X11) - // TinyXml doesn't support a "long" attribute. We'll use - // stringstream to do it ourselves. + // TinyXml doesn't support a "long" attribute. We'll use stringstream to + // do it ourselves. { ostringstream strm; assert(_parent_window._window_handle_type == P3D_WHT_x11_window); diff --git a/direct/src/plugin/p3dWindowParams.h b/direct/src/plugin/p3dWindowParams.h index 3036f4e681..91d8639b28 100644 --- a/direct/src/plugin/p3dWindowParams.h +++ b/direct/src/plugin/p3dWindowParams.h @@ -1,16 +1,15 @@ -// Filename: p3dWindowParams.h -// Created by: drose (22Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dWindowParams.h + * @author drose + * @date 2009-06-22 + */ #ifndef P3DWINDOWPARAMS_H #define P3DWINDOWPARAMS_H @@ -20,10 +19,9 @@ class P3DInstance *inst; -//////////////////////////////////////////////////////////////////// -// Class : P3DWindowParams -// Description : Encapsulates the window parameters. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the window parameters. + */ class P3DWindowParams { public: P3DWindowParams(); diff --git a/direct/src/plugin/p3dX11SplashWindow.I b/direct/src/plugin/p3dX11SplashWindow.I index cf1c0f7c5a..22407f96ed 100644 --- a/direct/src/plugin/p3dX11SplashWindow.I +++ b/direct/src/plugin/p3dX11SplashWindow.I @@ -1,34 +1,27 @@ -// Filename: p3dX11SplashWindow.I -// Created by: drose (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dX11SplashWindow.I + * @author drose + * @date 2009-09-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::X11ImageData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DX11SplashWindow::X11ImageData:: X11ImageData() { _filename_changed = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::X11ImageData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline P3DX11SplashWindow::X11ImageData:: ~X11ImageData() { } - diff --git a/direct/src/plugin/p3dX11SplashWindow.cxx b/direct/src/plugin/p3dX11SplashWindow.cxx index 4c41b3ca4c..8be0edb050 100644 --- a/direct/src/plugin/p3dX11SplashWindow.cxx +++ b/direct/src/plugin/p3dX11SplashWindow.cxx @@ -1,16 +1,15 @@ -// Filename: p3dX11SplashWindow.cxx -// Created by: pro-rsoft (08Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dX11SplashWindow.cxx + * @author rdb + * @date 2009-07-08 + */ #include "p3dX11SplashWindow.h" @@ -25,11 +24,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DX11SplashWindow:: P3DX11SplashWindow(P3DInstance *inst, bool make_visible) : P3DSplashWindow(inst, make_visible) @@ -61,23 +58,18 @@ P3DX11SplashWindow(P3DInstance *inst, bool make_visible) : _received_data = 0; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DX11SplashWindow:: ~P3DX11SplashWindow() { stop_subprocess(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_wparams -// Access: Public, Virtual -// Description: Changes the window parameters, e.g. to resize or -// reposition the window; or sets the parameters for the -// first time, creating the initial window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the window parameters, e.g. to resize or reposition the window; or + * sets the parameters for the first time, creating the initial window. + */ void P3DX11SplashWindow:: set_wparams(const P3DWindowParams &wparams) { P3DSplashWindow::set_wparams(wparams); @@ -87,13 +79,10 @@ set_wparams(const P3DWindowParams &wparams) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_visible -// Access: Public, Virtual -// Description: Makes the splash window visible or invisible, so as -// not to compete with the embedded Panda window in the -// same space. -//////////////////////////////////////////////////////////////////// +/** + * Makes the splash window visible or invisible, so as not to compete with the + * embedded Panda window in the same space. + */ void P3DX11SplashWindow:: set_visible(bool visible) { P3DSplashWindow::set_visible(visible); @@ -106,12 +95,10 @@ set_visible(bool visible) { write_xml(_pipe_write, &doc, nout); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_image_filename -// Access: Public, Virtual -// Description: Specifies the name of a JPEG image file that is -// displayed in the center of the splash window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a JPEG image file that is displayed in the center of + * the splash window. + */ void P3DX11SplashWindow:: set_image_filename(const string &image_filename, ImagePlacement image_placement) { nout << "image_filename = " << image_filename << "\n"; @@ -130,12 +117,9 @@ set_image_filename(const string &image_filename, ImagePlacement image_placement) check_stopped(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_install_label -// Access: Public, Virtual -// Description: Specifies the text that is displayed above the -// install progress bar. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the text that is displayed above the install progress bar. + */ void P3DX11SplashWindow:: set_install_label(const string &install_label) { if (_subprocess_pid == -1) { @@ -152,11 +136,9 @@ set_install_label(const string &install_label) { check_stopped(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_install_progress -// Access: Public, Virtual -// Description: Moves the install progress bar from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Moves the install progress bar from 0.0 to 1.0. + */ void P3DX11SplashWindow:: set_install_progress(double install_progress, bool is_progress_known, size_t received_data) { @@ -176,15 +158,12 @@ set_install_progress(double install_progress, check_stopped(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_button_active -// Access: Public, Virtual -// Description: Sets whether the button should be visible and active -// (true) or invisible and inactive (false). If active, -// the button image will be displayed in the window, and -// a click event will be generated when the user clicks -// the button. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the button should be visible and active (true) or invisible + * and inactive (false). If active, the button image will be displayed in the + * window, and a click event will be generated when the user clicks the + * button. + */ void P3DX11SplashWindow:: set_button_active(bool flag) { if (_subprocess_pid == -1) { @@ -201,48 +180,38 @@ set_button_active(bool flag) { check_stopped(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::button_click_detected -// Access: Protected, Virtual -// Description: Called when a button click by the user is detected in -// set_mouse_data(), this method simply turns around and -// notifies the instance. It's a virtual method to give -// subclasses a chance to redirect this message to the -// main thread or process, as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called when a button click by the user is detected in set_mouse_data(), + * this method simply turns around and notifies the instance. It's a virtual + * method to give subclasses a chance to redirect this message to the main + * thread or process, as necessary. + */ void P3DX11SplashWindow:: button_click_detected() { - // This method is called in the child process, and must relay - // the information to the parent process. + // This method is called in the child process, and must relay the + // information to the parent process. TiXmlDocument doc; TiXmlElement *xcommand = new TiXmlElement("click"); doc.LinkEndChild(xcommand); write_xml(_pipe_write, &doc, nout); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::set_bstate -// Access: Protected, Virtual -// Description: Changes the button state as the mouse interacts with -// it. -//////////////////////////////////////////////////////////////////// +/** + * Changes the button state as the mouse interacts with it. + */ void P3DX11SplashWindow:: set_bstate(ButtonState bstate) { if (_bstate != bstate) { - // When the button state changes, we need to remake the composite - // image. + // When the button state changes, we need to remake the composite image. _needs_new_composite = true; P3DSplashWindow::set_bstate(bstate); } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::start_subprocess -// Access: Private -// Description: Spawns the subprocess that runs the window. We have -// to use a subprocess instead of just a sub-thread, to -// protect X11 against mutual access. -//////////////////////////////////////////////////////////////////// +/** + * Spawns the subprocess that runs the window. We have to use a subprocess + * instead of just a sub-thread, to protect X11 against mutual access. + */ void P3DX11SplashWindow:: start_subprocess() { assert(_subprocess_pid == -1); @@ -292,11 +261,9 @@ start_subprocess() { spawn_read_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::stop_subprocess -// Access: Private -// Description: Terminates the subprocess. -//////////////////////////////////////////////////////////////////// +/** + * Terminates the subprocess. + */ void P3DX11SplashWindow:: stop_subprocess() { if (_subprocess_pid == -1) { @@ -316,8 +283,7 @@ stop_subprocess() { static const int max_wait_ms = 2000; - // Wait for a certain amount of time for the process to stop by - // itself. + // Wait for a certain amount of time for the process to stop by itself. struct timeval start; gettimeofday(&start, NULL); int start_ms = start.tv_sec * 1000 + start.tv_usec / 1000; @@ -365,12 +331,10 @@ stop_subprocess() { join_read_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::check_stopped -// Access: Private -// Description: Shuts down the instance if the window is closed -// prematurely (for instance, due to user action). -//////////////////////////////////////////////////////////////////// +/** + * Shuts down the instance if the window is closed prematurely (for instance, + * due to user action). + */ void P3DX11SplashWindow:: check_stopped() { if (_subprocess_pid == -1) { @@ -411,25 +375,20 @@ check_stopped() { _inst->request_stop_main_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::spawn_read_thread -// Access: Private -// Description: Starts the read thread. We need this thread to -// listen for feedback from the subprocess. (At the -// moment, the only kind of feedback we might receive is -// whether the button has been clicked.) -//////////////////////////////////////////////////////////////////// +/** + * Starts the read thread. We need this thread to listen for feedback from + * the subprocess. (At the moment, the only kind of feedback we might receive + * is whether the button has been clicked.) + */ void P3DX11SplashWindow:: spawn_read_thread() { SPAWN_THREAD(_read_thread, rt_thread_run, this); _started_read_thread = true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::join_read_thread -// Access: Private -// Description: Waits for the read thread to stop. -//////////////////////////////////////////////////////////////////// +/** + * Waits for the read thread to stop. + */ void P3DX11SplashWindow:: join_read_thread() { if (!_started_read_thread) { @@ -440,19 +399,16 @@ join_read_thread() { _started_read_thread = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::rt_thread_run -// Access: Private -// Description: The main function for the read thread. -//////////////////////////////////////////////////////////////////// +/** + * The main function for the read thread. + */ void P3DX11SplashWindow:: rt_thread_run() { while (true) { TiXmlDocument *doc = read_xml(_pipe_read, nout); if (doc == NULL) { - // Some error on reading. The splash window must have gone - // away, e.g. because the user explicitly closed it; tell the - // instance to exit. + // Some error on reading. The splash window must have gone away, e.g. + // because the user explicitly closed it; tell the instance to exit. _inst->request_stop_sub_thread(); return; } @@ -462,31 +418,25 @@ rt_thread_run() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::rt_handle_request -// Access: Private -// Description: Processes a single request or notification received -// from an instance. -//////////////////////////////////////////////////////////////////// +/** + * Processes a single request or notification received from an instance. + */ void P3DX11SplashWindow:: rt_handle_request(TiXmlDocument *doc) { - // Eh, don't even bother decoding the XML. We know it can only be a - // click notification. + // Eh, don't even bother decoding the XML. We know it can only be a click + // notification. delete doc; P3DSplashWindow::button_click_detected(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::subprocess_run -// Access: Private -// Description: The subprocess's main run method. -//////////////////////////////////////////////////////////////////// +/** + * The subprocess's main run method. + */ void P3DX11SplashWindow:: subprocess_run() { - // Since we're now isolated in a subprocess, we can safely make all - // the X calls we like, and run independently of the browser - // process. + // Since we're now isolated in a subprocess, we can safely make all the X + // calls we like, and run independently of the browser process. make_window(); setup_gc(); @@ -526,8 +476,8 @@ subprocess_run() { set_button_range(_button_ready_image); - // If the window changes size, we need to recompute the - // composed image. + // If the window changes size, we need to recompute the composed + // image. _needs_new_composite = true; } needs_redraw = true; @@ -590,8 +540,8 @@ subprocess_run() { prev_received_data = _received_data; if (_progress_known && _install_progress == 0.0) { - // If the progress bar drops to zero, repaint the screen to - // take the progress bar away. + // If the progress bar drops to zero, repaint the screen to take the + // progress bar away. needs_redraw = true; } } @@ -605,8 +555,8 @@ subprocess_run() { needs_redraw_progress = true; } - // Don't draw an install label or a progress bar unless we have - // some nonzero progress. + // Don't draw an install label or a progress bar unless we have some + // nonzero progress. if (!_progress_known || _install_progress != 0.0) { int bar_x, bar_y, bar_width, bar_height; get_bar_placement(bar_x, bar_y, bar_width, bar_height); @@ -724,11 +674,9 @@ subprocess_run() { close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::receive_command -// Access: Private -// Description: Receives a command from the parent. -//////////////////////////////////////////////////////////////////// +/** + * Receives a command from the parent. + */ void P3DX11SplashWindow:: receive_command() { TiXmlDocument *doc = read_xml(_pipe_read, nout); @@ -822,11 +770,9 @@ receive_command() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::redraw -// Access: Private -// Description: Redraws the window. -//////////////////////////////////////////////////////////////////// +/** + * Redraws the window. + */ void P3DX11SplashWindow:: redraw() { if (_composite_image == NULL) { @@ -857,12 +803,9 @@ redraw() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::make_window -// Access: Private -// Description: Creates the window for displaying progress. Runs -// within the sub-process. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for displaying progress. Runs within the sub-process. + */ void P3DX11SplashWindow:: make_window() { _win_width = 320; @@ -874,17 +817,15 @@ make_window() { X11_Window parent = 0; - // Hum, if we use the display provided by the browser, - // it causes a crash in some browsers when you make an Xlib - // call with the plugin window minimized. - // So I kept XOpenDisplay until we have a better workaround. + // Hum, if we use the display provided by the browser, it causes a crash in + // some browsers when you make an Xlib call with the plugin window + // minimized. So I kept XOpenDisplay until we have a better workaround. - //_display = (X11_Display*) _wparams.get_parent_window()._xdisplay; - //_own_display = false; - //if (_display == 0) { + // _display = (X11_Display*) _wparams.get_parent_window()._xdisplay; + // _own_display = false; if (_display == 0) { _display = XOpenDisplay(NULL); _own_display = true; - //} + // } assert(_display != NULL); _screen = DefaultScreen(_display); @@ -952,13 +893,13 @@ make_window() { (_display, parent, x, y, _win_width, _win_height, 0, depth, InputOutput, dvisual, attrib_mask, &wa); - // Now hint the window manager about the window origin and size. - // This is necessary because window managers are free to ignore - // the window origin specified in the XCreateWindow call. + // Now hint the window manager about the window origin and size. This is + // necessary because window managers are free to ignore the window origin + // specified in the XCreateWindow call. XSizeHints *size_hints_p = XAllocSizeHints(); if (_wparams.get_win_x() != -1 || _wparams.get_win_y() != -1) { - // If the user requested (-1, -1), the default position, we let - // the window manager choose a position by omitting the pos hint. + // If the user requested (-1, -1), the default position, we let the window + // manager choose a position by omitting the pos hint. size_hints_p->x = x; size_hints_p->y = y; size_hints_p->flags |= USPosition; @@ -974,11 +915,9 @@ make_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::setup_gc -// Access: Private -// Description: Sets up the graphics context for drawing the text. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the graphics context for drawing the text. + */ void P3DX11SplashWindow:: setup_gc() { if (_graphics_context != None) { @@ -993,7 +932,7 @@ setup_gc() { } // Determine the order at which to try the various weights. From: - // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight + // https:developer.mozilla.orgen-USdocsWebCSSfont-weight const char *const *try_weights; const int num_weights = 7; @@ -1074,8 +1013,8 @@ setup_gc() { _graphics_context = XCreateGC(_display, _window, GCFont | GCFunction | GCPlaneMask | GCForeground | GCBackground, &gcval); - // Also create a gc for filling in the interior of the progress bar - // in a pleasant blue color (or whatever color the user requested). + // Also create a gc for filling in the interior of the progress bar in a + // pleasant blue color (or whatever color the user requested). XColor bar; bar.red = _barcolor_r * 0x101; bar.green = _barcolor_g * 0x101; @@ -1110,11 +1049,9 @@ setup_gc() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::close_window -// Access: Private -// Description: Closes the window created above. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window created above. + */ void P3DX11SplashWindow:: close_window() { if (_composite_image != NULL) { @@ -1170,15 +1107,12 @@ close_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::update_image -// Access: Private -// Description: Loads the splash image, converts to to an XImage, -// and stores it in _image. Runs only in the -// child process. -// -// If the image is changed, sets needs_redraw to true. -//////////////////////////////////////////////////////////////////// +/** + * Loads the splash image, converts to to an XImage, and stores it in _image. + * Runs only in the child process. + * + * If the image is changed, sets needs_redraw to true. + */ void P3DX11SplashWindow:: update_image(X11ImageData &image) { if (!image._filename_changed) { @@ -1196,13 +1130,10 @@ update_image(X11ImageData &image) { } } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::compose_image -// Access: Private -// Description: Constructs the XImage to display onscreen. It's a -// composition of the background image and/or one of the -// button images, scaled to fit the window. -//////////////////////////////////////////////////////////////////// +/** + * Constructs the XImage to display onscreen. It's a composition of the + * background image and/or one of the button images, scaled to fit the window. + */ void P3DX11SplashWindow:: compose_image() { if (_composite_image != NULL) { @@ -1245,13 +1176,12 @@ compose_image() { // We have no button image; image1 will serve as the result. } else { - // We do have a button image. Compose the button image on top of - // the background image (or on top of a white image if we have no - // background). + // We do have a button image. Compose the button image on top of the + // background image (or on top of a white image if we have no background). - // We compose them here on the client, because X11 doesn't - // natively provide an alpha-blending mechanism (at least, not - // without the XRender extension). + // We compose them here on the client, because X11 doesn't natively + // provide an alpha-blending mechanism (at least, not without the XRender + // extension). vector image0; int image0_width, image0_height; compose_two_images(image0, image0_width, image0_height, @@ -1289,13 +1219,10 @@ compose_image() { _composite_height = image1_height; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::scale_image -// Access: Private -// Description: Scales the image into the window size, and expands it -// to four channels. Returns true if the image is -// valid, false if it is empty. -//////////////////////////////////////////////////////////////////// +/** + * Scales the image into the window size, and expands it to four channels. + * Returns true if the image is valid, false if it is empty. + */ bool P3DX11SplashWindow:: scale_image(vector &image0, int &image0_width, int &image0_height, X11ImageData &image) { @@ -1400,12 +1327,9 @@ scale_image(vector &image0, int &image0_width, int &image0_height return true; } -//////////////////////////////////////////////////////////////////// -// Function: P3DX11SplashWindow::compose_two_images -// Access: Private -// Description: Constructs into image0 the alpha-composite of image1 -// beneath image2. -//////////////////////////////////////////////////////////////////// +/** + * Constructs into image0 the alpha-composite of image1 beneath image2. + */ void P3DX11SplashWindow:: compose_two_images(vector &image0, int &image0_width, int &image0_height, const vector &image1, int image1_width, int image1_height, @@ -1417,14 +1341,14 @@ compose_two_images(vector &image0, int &image0_width, int &image0 int new_row_stride = image0_width * 4; int new_data_length = image0_height * new_row_stride; - // Now copy in the first image. If the first image exactly fills - // the output image, this is easy. + // Now copy in the first image. If the first image exactly fills the output + // image, this is easy. if (image1_width == image0_width && image1_height == image0_height) { image0 = image1; } else { - // If the first image doesn't fill it, it's only a little bit more - // work. Start by finding the top-left pixel. + // If the first image doesn't fill it, it's only a little bit more work. + // Start by finding the top-left pixel. int xo = (image0_width - image1_width) / 2; int yo = (image0_height - image1_height) / 2; diff --git a/direct/src/plugin/p3dX11SplashWindow.h b/direct/src/plugin/p3dX11SplashWindow.h index 2622a31fa3..892fc6e4cb 100644 --- a/direct/src/plugin/p3dX11SplashWindow.h +++ b/direct/src/plugin/p3dX11SplashWindow.h @@ -1,16 +1,15 @@ -// Filename: p3dX11SplashWindow.h -// Created by: pro-rsoft (08Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dX11SplashWindow.h + * @author rdb + * @date 2009-07-08 + */ #ifndef P3DX11SPLASHWINDOW_H #define P3DX11SPLASHWINDOW_H @@ -25,11 +24,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : P3DX11SplashWindow -// Description : This is the Windows implementation of the -// initial-download window. -//////////////////////////////////////////////////////////////////// +/** + * This is the Windows implementation of the initial-download window. + */ class P3DX11SplashWindow : public P3DSplashWindow { public: P3DX11SplashWindow(P3DInstance *inst, bool make_visible); diff --git a/direct/src/plugin/p3d_lock.h b/direct/src/plugin/p3d_lock.h index 6e65447af3..ed923de304 100644 --- a/direct/src/plugin/p3d_lock.h +++ b/direct/src/plugin/p3d_lock.h @@ -1,22 +1,21 @@ -// Filename: p3d_lock.h -// Created by: drose (05Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3d_lock.h + * @author drose + * @date 2009-06-05 + */ #ifndef P3D_LOCK_H #define P3D_LOCK_H -// Provides some simple macros that implement platform-independet -// mutex locks, as well as platform-independent thread constructs. +// Provides some simple macros that implement platform-independet mutex locks, +// as well as platform-independent thread constructs. #ifdef _WIN32 @@ -56,10 +55,9 @@ public: (thread) = NULL; \ } -// Declare this macro within your class declaration. This implements -// the callback function wrapper necessary to hook into the above -// SPAWN_THREAD call. The wrapper will in turn call the method -// function you provide. +// Declare this macro within your class declaration. This implements the +// callback function wrapper necessary to hook into the above SPAWN_THREAD +// call. The wrapper will in turn call the method function you provide. #define THREAD_CALLBACK_DECLARATION(class, callback_function) \ static DWORD WINAPI \ win_ ## callback_function(LPVOID data) { \ @@ -73,9 +71,9 @@ public: // Posix case #include -// We declare this to be a recursive lock, since we might make a -// request_ready call from within the API, which in turn is allowed to -// call back into the API. +// We declare this to be a recursive lock, since we might make a request_ready +// call from within the API, which in turn is allowed to call back into the +// API. #define LOCK pthread_mutex_t #define INIT_LOCK(lock) { \ pthread_mutexattr_t attr; \ @@ -123,4 +121,3 @@ public: #endif // _WIN32 #endif - diff --git a/direct/src/plugin/p3d_plugin.cxx b/direct/src/plugin/p3d_plugin.cxx index 241a59d253..8fc91c881e 100644 --- a/direct/src/plugin/p3d_plugin.cxx +++ b/direct/src/plugin/p3d_plugin.cxx @@ -1,16 +1,15 @@ -// Filename: p3d_plugin.cxx -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3d_plugin.cxx + * @author drose + * @date 2009-05-29 + */ #include "p3d_plugin_common.h" #include "p3d_plugin_config.h" @@ -27,13 +26,13 @@ #include #include -// Use a simple lock to protect the C-style API functions in this -// module from parallel access by multiple threads in the host. +// Use a simple lock to protect the C-style API functions in this module from +// parallel access by multiple threads in the host. bool initialized_lock = false; LOCK _api_lock; -bool +bool P3D_initialize(int api_version, const char *contents_filename, const char *host_url, P3D_verify_contents verify_contents, const char *platform, const char *log_directory, @@ -47,8 +46,8 @@ P3D_initialize(int api_version, const char *contents_filename, } if (api_version < 13) { - // Prior to version 13, verify_contents was a bool. Convert - // "true" to P3D_VC_normal and "false" to P3D_VC_none. + // Prior to version 13, verify_contents was a bool. Convert "true" to + // P3D_VC_normal and "false" to P3D_VC_none. if ((int)verify_contents != 0) { verify_contents = P3D_VC_normal; } else { @@ -62,11 +61,11 @@ P3D_initialize(int api_version, const char *contents_filename, } ACQUIRE_LOCK(_api_lock); - if (contents_filename == NULL){ + if (contents_filename == NULL){ contents_filename = ""; } - if (host_url == NULL){ + if (host_url == NULL){ host_url = ""; } @@ -104,7 +103,7 @@ P3D_initialize(int api_version, const char *contents_filename, return result; } -void +void P3D_finalize() { nout << "P3D_finalize called\n"; P3DInstanceManager::delete_global_ptr(); @@ -129,11 +128,11 @@ P3D_set_plugin_version(int major, int minor, int sequence, time_t coreapi_timestamp = 0; if (inst_mgr->get_api_version() < 15) { - // Before version 15, this was passed as a time_t. + // Before version 15, this was passed as a time_t. coreapi_timestamp = (time_t)coreapi_timestamp_str; } else { - // Passing a time_t causes problems with disagreements about word - // size, so since version 15 we pass it as a string. + // Passing a time_t causes problems with disagreements about word size, so + // since version 15 we pass it as a string. coreapi_timestamp = strtoul(coreapi_timestamp_str, NULL, 10); } @@ -162,20 +161,20 @@ P3D_set_super_mirror(const char *super_mirror_url) { } P3D_instance * -P3D_new_instance(P3D_request_ready_func *func, +P3D_new_instance(P3D_request_ready_func *func, const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); - P3DInstance *result = inst_mgr->create_instance(func, tokens, num_tokens, + P3DInstance *result = inst_mgr->create_instance(func, tokens, num_tokens, argc, argv, user_data); RELEASE_LOCK(_api_lock); return result; } bool -P3D_instance_start(P3D_instance *instance, bool is_local, +P3D_instance_start(P3D_instance *instance, bool is_local, const char *p3d_filename, int p3d_offset) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); if (p3d_filename == NULL) { @@ -184,17 +183,17 @@ P3D_instance_start(P3D_instance *instance, bool is_local, ACQUIRE_LOCK(_api_lock); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); if (inst_mgr->get_api_version() < 11) { - // Prior to version 11, there was no p3d_offset parameter. So, we - // default it to 0. + // Prior to version 11, there was no p3d_offset parameter. So, we default + // it to 0. p3d_offset = 0; } P3DInstance *inst = inst_mgr->validate_instance(instance); bool result = false; if (inst != NULL) { - // We don't actually start it immediately; the instance will have - // to download the p3d url and read it, reading the python - // version, before it can start. + // We don't actually start it immediately; the instance will have to + // download the p3d url and read it, reading the python version, before it + // can start. result = inst_mgr->set_p3d_filename(inst, is_local, p3d_filename, p3d_offset); } @@ -314,7 +313,7 @@ P3D_object_get_property(P3D_object *object, const char *property) { } bool -P3D_object_set_property(P3D_object *object, const char *property, +P3D_object_set_property(P3D_object *object, const char *property, bool needs_response, P3D_object *value) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); @@ -333,7 +332,7 @@ P3D_object_has_method(P3D_object *object, const char *method_name) { } P3D_object * -P3D_object_call(P3D_object *object, const char *method_name, +P3D_object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); @@ -354,7 +353,7 @@ P3D_object_eval(P3D_object *object, const char *expression) { } -void +void P3D_object_incref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); if (object != NULL) { @@ -364,7 +363,7 @@ P3D_object_incref(P3D_object *object) { } } -void +void P3D_object_decref(P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); if (object != NULL) { @@ -381,7 +380,7 @@ P3D_make_class_definition() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_class_definition *result = inst_mgr->make_class_definition(); - + RELEASE_LOCK(_api_lock); return result; } @@ -393,7 +392,7 @@ P3D_new_undefined_object() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_object *result = inst_mgr->new_undefined_object(); - + RELEASE_LOCK(_api_lock); return result; } @@ -405,7 +404,7 @@ P3D_new_none_object() { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_object *result = inst_mgr->new_none_object(); - + RELEASE_LOCK(_api_lock); return result; } @@ -417,7 +416,7 @@ P3D_new_bool_object(bool value) { P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3D_object *result = inst_mgr->new_bool_object(value); - + RELEASE_LOCK(_api_lock); return result; } @@ -428,7 +427,7 @@ P3D_new_int_object(int value) { ACQUIRE_LOCK(_api_lock); P3D_object *result = new P3DIntObject(value); - + RELEASE_LOCK(_api_lock); return result; } @@ -439,7 +438,7 @@ P3D_new_float_object(double value) { ACQUIRE_LOCK(_api_lock); P3D_object *result = new P3DFloatObject(value); - + RELEASE_LOCK(_api_lock); return result; } @@ -450,7 +449,7 @@ P3D_new_string_object(const char *str, int length) { ACQUIRE_LOCK(_api_lock); P3D_object *result = new P3DStringObject(string(str, length)); - + RELEASE_LOCK(_api_lock); return result; } @@ -466,13 +465,13 @@ P3D_instance_get_panda_script_object(P3D_instance *instance) { if (inst != NULL) { result = inst->get_panda_script_object(); } - + RELEASE_LOCK(_api_lock); return result; } void -P3D_instance_set_browser_script_object(P3D_instance *instance, +P3D_instance_set_browser_script_object(P3D_instance *instance, P3D_object *object) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); @@ -482,7 +481,7 @@ P3D_instance_set_browser_script_object(P3D_instance *instance, if (inst != NULL) { inst->set_browser_script_object(object); } - + RELEASE_LOCK(_api_lock); } @@ -584,9 +583,9 @@ P3D_request_finish(P3D_request *request, bool handled) { bool P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id, P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const void *this_data, + const void *this_data, size_t this_data_size) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); @@ -597,7 +596,7 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id, if (inst != NULL) { result = inst-> feed_url_stream(unique_id, result_code, http_status_code, - total_expected_data, + total_expected_data, (const unsigned char *)this_data, this_data_size); } @@ -606,7 +605,7 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id, } bool -P3D_instance_handle_event(P3D_instance *instance, +P3D_instance_handle_event(P3D_instance *instance, const P3D_event_data *event) { assert(P3DInstanceManager::get_global_ptr()->is_initialized()); ACQUIRE_LOCK(_api_lock); diff --git a/direct/src/plugin/p3d_plugin.h b/direct/src/plugin/p3d_plugin.h index f17e26dda3..6df6e281fc 100644 --- a/direct/src/plugin/p3d_plugin.h +++ b/direct/src/plugin/p3d_plugin.h @@ -1,8 +1,4 @@ -/* Filename: p3d_plugin.h - * Created by: drose (28May09) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file p3d_plugin.h + * @author drose + * @date 2009-05-28 + */ #ifndef P3D_PLUGIN_H #define P3D_PLUGIN_H @@ -137,7 +136,7 @@ typedef enum { core API. Note that the individual instances also have their own log_basename values. If log_history is greater than zero, the most recent log_history (count) logs generated (per log_basename) - will be retained on disk, each named uniquely by appending a + will be retained on disk, each named uniquely by appending a timestamp to the log_basename before file creation. Next, trusted_environment should be set true to indicate that the @@ -159,7 +158,7 @@ typedef enum { compatible API, false otherwise. If it returns false, the host should not call any more functions in this API, and should immediately unload the DLL and (if possible) download a new one. */ -typedef bool +typedef bool P3D_initialize_func(int api_version, const char *contents_filename, const char *host_url, P3D_verify_contents verify_contents, const char *platform, @@ -334,7 +333,7 @@ typedef struct { const char *_value; } P3D_token; -/* This function creates a new Panda3D instance. +/* This function creates a new Panda3D instance. For tokens, pass an array of P3D_token elements (above), which correspond to the user-supplied keyword/value pairs that may appear @@ -360,7 +359,7 @@ typedef struct { */ typedef P3D_instance * -P3D_new_instance_func(P3D_request_ready_func *func, +P3D_new_instance_func(P3D_request_ready_func *func, const P3D_token tokens[], size_t num_tokens, int argc, const char *argv[], void *user_data); @@ -403,7 +402,7 @@ P3D_instance_start_stream_func(P3D_instance *instance, const char *p3d_url); from rendering, for instance when the user navigates away from the page containing it. After calling this function, you should not reference the P3D_instance pointer again. */ -typedef void +typedef void P3D_instance_finish_func(P3D_instance *instance); /* Call this function after creating an instance in order to set its @@ -429,7 +428,7 @@ P3D_instance_setup_window_func(P3D_instance *instance, an int, float, or string; or it might be a class object with methods and properties. Instances of P3D_object are passed around as parameters into and return values from functions. - + To implement a P3D_object, we need to first define a class definition, which is a table of methods. Most classes are defined internally by the core API, but the host must define at least one @@ -509,7 +508,7 @@ P3D_object_get_float_method(P3D_object *object); of the buffer. Note that P3D_object string data is internally encoded using utf-8, by convention. */ typedef int -P3D_object_get_string_method(P3D_object *object, +P3D_object_get_string_method(P3D_object *object, char *buffer, int buffer_size); /* As above, but instead of the literal object data, returns a @@ -519,7 +518,7 @@ P3D_object_get_string_method(P3D_object *object, marks and escape characters from P3D_OBJECT_GET_REPR(). Mechanically, this function works the same way as get_string(). */ typedef int -P3D_object_get_repr_method(P3D_object *object, +P3D_object_get_repr_method(P3D_object *object, char *buffer, int buffer_size); /* Looks up a property on the object by name, i.e. a data member or a @@ -656,12 +655,12 @@ P3D_object_get_repr_func(P3D_object *object, char *buffer, int buffer_size); typedef P3D_object * P3D_object_get_property_func(P3D_object *object, const char *property); typedef bool -P3D_object_set_property_func(P3D_object *object, const char *property, +P3D_object_set_property_func(P3D_object *object, const char *property, bool needs_response, P3D_object *value); typedef bool P3D_object_has_method_func(P3D_object *object, const char *method_name); typedef P3D_object * -P3D_object_call_func(P3D_object *object, const char *method_name, +P3D_object_call_func(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params); typedef P3D_object * @@ -669,9 +668,9 @@ P3D_object_eval_func(P3D_object *object, const char *expression); /* A NULL pointer passed into either incref or decref is safe and will be quietly ignored. */ -typedef void +typedef void P3D_object_incref_func(P3D_object *object); -typedef void +typedef void P3D_object_decref_func(P3D_object *object); @@ -744,14 +743,14 @@ P3D_instance_get_panda_script_object_func(P3D_instance *instance); If this function is never called, the instance will not be able to make outcalls to the DOM or to JavaScript, but scripts may still be able to control the instance via P3D_instance_get_panda_script_object(), - above. + above. Note that the object's constructor should initialize its reference count to 1. The instance will increment the reference count as a result of this call; the caller is responsible for calling DECREF on the object after this call to remove its own reference. */ typedef void -P3D_instance_set_browser_script_object_func(P3D_instance *instance, +P3D_instance_set_browser_script_object_func(P3D_instance *instance, P3D_object *object); @@ -967,9 +966,9 @@ typedef enum { typedef bool P3D_instance_feed_url_stream_func(P3D_instance *instance, int unique_id, P3D_result_code result_code, - int http_status_code, + int http_status_code, size_t total_expected_data, - const void *this_data, + const void *this_data, size_t this_data_size); /* This enum and set of structures abstract out the event pointer data @@ -1006,8 +1005,8 @@ typedef enum { P3DCocoaEventTextInput } P3DCocoaEventType; -// This structure reimplements NPCocoaEvent, to pass the complex -// cocoa event structures as generated by NPAPI. +// This structure reimplements NPCocoaEvent, to pass the complex cocoa event +// structures as generated by NPAPI. typedef struct { P3DCocoaEventType type; unsigned int version; @@ -1015,7 +1014,7 @@ typedef struct { struct { unsigned int modifierFlags; double pluginX; - double pluginY; + double pluginY; int buttonNumber; int clickCount; double deltaX; @@ -1067,7 +1066,7 @@ typedef struct { The return value is true if the handler has processed the event, false if it has been ignored. */ typedef bool -P3D_instance_handle_event_func(P3D_instance *instance, +P3D_instance_handle_event_func(P3D_instance *instance, const P3D_event_data *event); #ifdef P3D_FUNCTION_PROTOTYPES @@ -1116,10 +1115,9 @@ EXPCL_P3D_PLUGIN P3D_instance_handle_event_func P3D_instance_handle_event; #endif /* P3D_FUNCTION_PROTOTYPES */ -// The default max_age, if none is specified in a particular -// contents.xml, is 5 seconds. This gives us enough time to start a -// few packages downloading, without re-querying the host for a new -// contents.xml at each operation. +// The default max_age, if none is specified in a particular contents.xml, is +// 5 seconds. This gives us enough time to start a few packages downloading, +// without re-querying the host for a new contents.xml at each operation. #define P3D_CONTENTS_DEFAULT_MAX_AGE 5 #ifdef __cplusplus @@ -1127,5 +1125,3 @@ EXPCL_P3D_PLUGIN P3D_instance_handle_event_func P3D_instance_handle_event; #endif #endif /* P3D_PLUGIN_H */ - - diff --git a/direct/src/plugin/p3d_plugin_common.h b/direct/src/plugin/p3d_plugin_common.h index f05c346ae4..244ac70925 100644 --- a/direct/src/plugin/p3d_plugin_common.h +++ b/direct/src/plugin/p3d_plugin_common.h @@ -1,31 +1,29 @@ -// Filename: p3d_plugin_common.h -// Created by: drose (29May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3d_plugin_common.h + * @author drose + * @date 2009-05-29 + */ #ifndef P3D_PLUGIN_COMMON #define P3D_PLUGIN_COMMON -// This header file is included by all C++ files in this directory -// that contribute to p3d_plugin; it provides some common symbol -// declarations. +// This header file is included by all C++ files in this directory that +// contribute to p3d_plugin; it provides some common symbol declarations. #define P3D_FUNCTION_PROTOTYPES -//#define BUILDING_P3D_PLUGIN +// #define BUILDING_P3D_PLUGIN #define TIXML_USE_STL -// It's a good idea to pick up this header file, even though we don't -// actually link with dtool. This header file defines useful -// system-wide config settings. +// It's a good idea to pick up this header file, even though we don't actually +// link with dtool. This header file defines useful system-wide config +// settings. #include "dtool_config.h" #include "p3d_plugin.h" @@ -45,8 +43,7 @@ extern ostream *nout_stream; // Appears in p3d_plugin.cxx. extern LOCK _api_lock; -// A convenience function for formatting a generic P3D_object to an -// ostream. +// A convenience function for formatting a generic P3D_object to an ostream. inline ostream & operator << (ostream &out, P3D_object &value) { int size = P3D_OBJECT_GET_REPR(&value, NULL, 0); @@ -59,4 +56,3 @@ operator << (ostream &out, P3D_object &value) { } #endif - diff --git a/direct/src/plugin/parse_color.cxx b/direct/src/plugin/parse_color.cxx index fce44da69b..e3094e9d40 100644 --- a/direct/src/plugin/parse_color.cxx +++ b/direct/src/plugin/parse_color.cxx @@ -1,37 +1,34 @@ -// Filename: parse_color.cxx -// Created by: drose (25Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parse_color.cxx + * @author drose + * @date 2011-08-25 + */ #include "parse_color.h" #include static bool parse_hexdigit(int &result, char digit); -//////////////////////////////////////////////////////////////////// -// Function: parse_color -// Description: Parses a HTML color spec of the form #rgb or #rrggbb. -// Returns true on success, false on failure. On -// success, fills r, g, b with the color values in the -// range 0..255. On failure, r, g, b are undefined. -//////////////////////////////////////////////////////////////////// +/** + * Parses a HTML color spec of the form #rgb or #rrggbb. Returns true on + * success, false on failure. On success, fills r, g, b with the color values + * in the range 0..255. On failure, r, g, b are undefined. + */ bool parse_color(int &r, int &g, int &b, const string &color) { if (color.empty() || color[0] != '#') { return false; } if (color.length() == 4) { - if (!parse_hexdigit(r, color[1]) || - !parse_hexdigit(g, color[2]) || + if (!parse_hexdigit(r, color[1]) || + !parse_hexdigit(g, color[2]) || !parse_hexdigit(b, color[3])) { return false; } @@ -59,12 +56,10 @@ parse_color(int &r, int &g, int &b, const string &color) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: parse_hexdigit -// Description: Parses a single hex digit. Returns true on success, -// false on failure. On success, fills result with the -// parsed value, an integer in the range 0..15. -//////////////////////////////////////////////////////////////////// +/** + * Parses a single hex digit. Returns true on success, false on failure. On + * success, fills result with the parsed value, an integer in the range 0..15. + */ bool parse_hexdigit(int &result, char digit) { if (isdigit(digit)) { diff --git a/direct/src/plugin/parse_color.h b/direct/src/plugin/parse_color.h index 13f7710b2c..cbbed95e03 100644 --- a/direct/src/plugin/parse_color.h +++ b/direct/src/plugin/parse_color.h @@ -1,16 +1,15 @@ -// Filename: parse_color.h -// Created by: drose (25Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parse_color.h + * @author drose + * @date 2011-08-25 + */ #ifndef PARSE_COLOR_H #define PARSE_COLOR_H @@ -21,4 +20,3 @@ using namespace std; bool parse_color(int &r, int &g, int &b, const string &color); #endif - diff --git a/direct/src/plugin/plugin_get_x11.h b/direct/src/plugin/plugin_get_x11.h index dde8f13241..827c96fc27 100644 --- a/direct/src/plugin/plugin_get_x11.h +++ b/direct/src/plugin/plugin_get_x11.h @@ -1,16 +1,15 @@ -// Filename: plugin_get_x11.h -// Created by: drose (28Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plugin_get_x11.h + * @author drose + * @date 2011-08-28 + */ #ifndef PLUGIN_GET_X11_H #define PLUGIN_GET_X11_H @@ -18,15 +17,14 @@ #include "pandabase.h" #include "p3d_plugin_config.h" -#ifdef HAVE_X11 -// This header file is designed to help work around some of the -// namespace spamming that X11 causes, by renaming the symbols that -// X11 declares that are known to conflict with other library names -// (like Apple's Core Graphics, for instance). +#ifdef HAVE_X11 +// This header file is designed to help work around some of the namespace +// spamming that X11 causes, by renaming the symbols that X11 declares that +// are known to conflict with other library names (like Apple's Core Graphics, +// for instance). -// In order for this to work, everyone who uses X11 within Panda -// should include this file instead of including the X11 headers -// directly. +// In order for this to work, everyone who uses X11 within Panda should +// include this file instead of including the X11 headers directly. #include "pre_x11_include.h" diff --git a/direct/src/plugin/run_p3dpython.cxx b/direct/src/plugin/run_p3dpython.cxx index 5a7dc4c742..abbaa92730 100644 --- a/direct/src/plugin/run_p3dpython.cxx +++ b/direct/src/plugin/run_p3dpython.cxx @@ -1,27 +1,24 @@ -// Filename: run_p3dpython.cxx -// Created by: drose (29Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file run_p3dpython.cxx + * @author drose + * @date 2009-08-29 + */ #include "p3dPythonRun.h" #include "run_p3dpython.h" -//////////////////////////////////////////////////////////////////// -// Function: run_p3dpython -// Description: This externally-visible function is the main entry -// point to this DLL, and it starts the whole thing -// running. Returns the exit status, which will be -// 0 on success, 1 or otherwise on failure. -//////////////////////////////////////////////////////////////////// +/** + * This externally-visible function is the main entry point to this DLL, and + * it starts the whole thing running. Returns the exit status, which will be + * 0 on success, 1 or otherwise on failure. + */ int run_p3dpython(const char *program_name, const char *archive_file, FHandle input_handle, FHandle output_handle, diff --git a/direct/src/plugin/run_p3dpython.h b/direct/src/plugin/run_p3dpython.h index 6b358b742b..8c1a6c2b69 100644 --- a/direct/src/plugin/run_p3dpython.h +++ b/direct/src/plugin/run_p3dpython.h @@ -1,22 +1,21 @@ -// Filename: run_p3dpython.h -// Created by: drose (29Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file run_p3dpython.h + * @author drose + * @date 2009-08-29 + */ #ifndef RUN_P3DPYTHON_H #define RUN_P3DPYTHON_H -// This header file defines the prototype for run_p3dpython(), the -// main entry point to this DLL. +// This header file defines the prototype for run_p3dpython(), the main entry +// point to this DLL. #include "fhandle.h" @@ -37,4 +36,3 @@ run_p3dpython(const char *program_name, const char *archive_file, const char *log_pathname, bool interactive_console); #endif - diff --git a/direct/src/plugin/wstring_encode.cxx b/direct/src/plugin/wstring_encode.cxx index 082f2bf1f0..bda90a4270 100644 --- a/direct/src/plugin/wstring_encode.cxx +++ b/direct/src/plugin/wstring_encode.cxx @@ -1,16 +1,15 @@ -// Filename: wstring_encode.cxx -// Created by: drose (29Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wstring_encode.cxx + * @author drose + * @date 2011-08-29 + */ #include "wstring_encode.h" @@ -24,10 +23,9 @@ #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: wstring_to_string -// Description: Encodes std::wstring to std::string using UTF-8. -//////////////////////////////////////////////////////////////////// +/** + * Encodes std::wstring to std::string using UTF-8. + */ bool wstring_to_string(string &result, const wstring &source) { bool success = false; @@ -49,10 +47,9 @@ wstring_to_string(string &result, const wstring &source) { #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: string_to_wstring -// Description: Decodes std::string to std::wstring using UTF-8. -//////////////////////////////////////////////////////////////////// +/** + * Decodes std::string to std::wstring using UTF-8. + */ bool string_to_wstring(wstring &result, const string &source) { bool success = false; diff --git a/direct/src/plugin/wstring_encode.h b/direct/src/plugin/wstring_encode.h index 5d9fca9fc3..8f36f88209 100644 --- a/direct/src/plugin/wstring_encode.h +++ b/direct/src/plugin/wstring_encode.h @@ -1,16 +1,15 @@ -// Filename: wstring_encode.h -// Created by: drose (29Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wstring_encode.h + * @author drose + * @date 2009-06-29 + */ #ifndef WSTRING_ENCODE_H #define WSTRING_ENCODE_H @@ -18,15 +17,15 @@ #include using namespace std; -// Presently, these two functions are implemented only for Windows, -// which is the only place they are needed. (Only Windows requires -// wstrings for filenames.) +// Presently, these two functions are implemented only for Windows, which is +// the only place they are needed. (Only Windows requires wstrings for +// filenames.) #ifdef _WIN32 bool wstring_to_string(string &result, const wstring &source); bool string_to_wstring(wstring &result, const string &source); -// We declare this inline so it won't conflict with the similar -// function defined in Panda's textEncoder.h. +// We declare this inline so it won't conflict with the similar function +// defined in Panda's textEncoder.h. inline ostream &operator << (ostream &out, const wstring &str) { string result; if (wstring_to_string(result, str)) { @@ -38,5 +37,3 @@ inline ostream &operator << (ostream &out, const wstring &str) { #endif // _WIN32 #endif - - diff --git a/direct/src/plugin/xml_helpers.cxx b/direct/src/plugin/xml_helpers.cxx index 8b8b2dc3b3..e08511f07a 100644 --- a/direct/src/plugin/xml_helpers.cxx +++ b/direct/src/plugin/xml_helpers.cxx @@ -1,28 +1,25 @@ -// Filename: xml_helpers.cxx -// Created by: drose (28Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xml_helpers.cxx + * @author drose + * @date 2012-09-28 + */ #include "p3d_plugin_common.h" #include "xml_helpers.h" -//////////////////////////////////////////////////////////////////// -// Function: parse_bool_attrib -// Description: Examines the indicated attrib from the XML attrib and -// returns its true or false value. Returns -// default_value if the attrib is not present or is -// empty. -//////////////////////////////////////////////////////////////////// +/** + * Examines the indicated attrib from the XML attrib and returns its true or + * false value. Returns default_value if the attrib is not present or is + * empty. + */ bool parse_bool_attrib(TiXmlElement *xelem, const string &attrib, bool default_value) { diff --git a/direct/src/plugin/xml_helpers.h b/direct/src/plugin/xml_helpers.h index 022e86e9bd..ea540bcf7a 100644 --- a/direct/src/plugin/xml_helpers.h +++ b/direct/src/plugin/xml_helpers.h @@ -1,16 +1,15 @@ -// Filename: xml_helpers.h -// Created by: drose (28Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xml_helpers.h + * @author drose + * @date 2012-09-28 + */ #ifndef XML_HELPERS_H #define XML_HELPERS_H @@ -21,4 +20,3 @@ bool parse_bool_attrib(TiXmlElement *xelem, const string &attrib, bool default_value); #endif - diff --git a/direct/src/plugin_activex/P3DActiveX.cpp b/direct/src/plugin_activex/P3DActiveX.cpp index fa752bf7d7..c5c718c78e 100644 --- a/direct/src/plugin_activex/P3DActiveX.cpp +++ b/direct/src/plugin_activex/P3DActiveX.cpp @@ -1,16 +1,15 @@ -// Filename: P3DActiveX.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveX.cpp + * @author atrestman + * @date 2009-09-14 + */ // P3DActiveX.cpp : Implementation of CP3DActiveXApp and DLL registration. @@ -72,7 +71,7 @@ HRESULT CreateComponentCategory(CATID catid, WCHAR *catDescription) // number of characters that may be read into catDescription. - // There must be room for a NULL-terminator. The third parameter + // There must be room for a NULL-terminator. The third parameter // contains the number of characters excluding the NULL-terminator. @@ -106,7 +105,7 @@ HRESULT CreateComponentCategory(CATID catid, WCHAR *catDescription) // HRESULT RegisterCLSIDInCategory - -// Register your component categories information +// Register your component categories information HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid) @@ -168,8 +167,8 @@ BOOL CP3DActiveXApp::InitInstance() { // TODO: Add your own module initialization code here. - // Seed the lame random number generator in rand(); we use it to - // select a mirror for downloading. + // Seed the lame random number generator in rand(); we use it to select + // a mirror for downloading. srand((unsigned int)time(NULL)); } diff --git a/direct/src/plugin_activex/P3DActiveX.h b/direct/src/plugin_activex/P3DActiveX.h index f17228dc5d..1024021791 100644 --- a/direct/src/plugin_activex/P3DActiveX.h +++ b/direct/src/plugin_activex/P3DActiveX.h @@ -1,16 +1,15 @@ -// Filename: P3DActiveX.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveX.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -35,4 +34,3 @@ public: extern const GUID CDECL _tlid; extern const WORD _wVerMajor; extern const WORD _wVerMinor; - diff --git a/direct/src/plugin_activex/P3DActiveXCtrl.cpp b/direct/src/plugin_activex/P3DActiveXCtrl.cpp index 6567e31063..78c5125a62 100644 --- a/direct/src/plugin_activex/P3DActiveXCtrl.cpp +++ b/direct/src/plugin_activex/P3DActiveXCtrl.cpp @@ -1,18 +1,18 @@ -// Filename: P3DActiveXCtrl.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveXCtrl.cpp + * @author atrestman + * @date 2009-09-14 + */ -// P3DActiveXCtrl.cpp : Implementation of the CP3DActiveXCtrl ActiveX Control class. +// P3DActiveXCtrl.cpp : Implementation of the CP3DActiveXCtrl ActiveX Control +// class. #include "stdafx.h" #include "P3DActiveX.h" @@ -128,16 +128,15 @@ IMPLEMENT_OLECTLTYPE(CP3DActiveXCtrl, IDS_P3DACTIVEX, _dwP3DActiveXOleMisc) -// CP3DActiveXCtrl::CP3DActiveXCtrlFactory::UpdateRegistry - -// Adds or removes system registry entries for CP3DActiveXCtrl +// CP3DActiveXCtrl::CP3DActiveXCtrlFactory::UpdateRegistry - Adds or removes +// system registry entries for CP3DActiveXCtrl BOOL CP3DActiveXCtrl::CP3DActiveXCtrlFactory::UpdateRegistry(BOOL bRegister) { // TODO: Verify that your control follows apartment-model threading rules. - // Refer to MFC TechNote 64 for more information. - // If your control does not conform to the apartment-model rules, then - // you must modify the code below, changing the 6th parameter from - // afxRegApartmentThreading to 0. + // Refer to MFC TechNote 64 for more information. If your control does + // not conform to the apartment-model rules, then you must modify the code + // below, changing the 6th parameter from afxRegApartmentThreading to 0. if (bRegister) return AfxOleRegisterControlClass( @@ -193,8 +192,8 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv case S_init: { _state = S_loading; - // The first time we get the Draw message, we know we're - // sufficiently set up to start downloading the instance. + // The first time we get the Draw message, we know we're sufficiently + // set up to start downloading the instance. m_instance.read_tokens(); get_twirl_bitmaps(); @@ -202,9 +201,8 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv SetTimer(1, 100, timer_callback); _init_time = GetTickCount(); - // But do most of the setup in a child thread, so we don't lock - // up the browser GUI while the instance gets itself downloaded - // and such. + // But do most of the setup in a child thread, so we don't lock up the + // browser GUI while the instance gets itself downloaded and such. _init_not_running.ResetEvent(); // Now the init thread is running. if (_beginthread(st_init, 0, this) == -1L) { nout << "Couldn't start thread.\n"; @@ -248,17 +246,16 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv DWORD now = GetTickCount(); - // Don't draw the twirling icon until at least half a second has - // passed, so we don't distract people by drawing it - // unnecessarily. + // Don't draw the twirling icon until at least half a second has passed, + // so we don't distract people by drawing it unnecessarily. if (_state == S_failed || (now - _init_time) >= 500) { int step = (now / 100) % twirl_num_steps; if (_state == S_failed) { step = twirl_num_steps; } - // Create an in-memory DC compatible with the display DC we're - // using to paint + // Create an in-memory DC compatible with the display DC we're using to + // paint CDC dcMemory; dcMemory.CreateCompatibleDC(pdc); @@ -271,9 +268,9 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv int nX = rect.left + (rect.Width() - twirl_width) / 2; int nY = rect.top + (rect.Height() - twirl_height) / 2; - // Copy the bits from the in-memory DC into the on-screen DC to - // actually do the painting. Use the centerpoint we computed for - // the target offset. + // Copy the bits from the in-memory DC into the on-screen DC to actually + // do the painting. Use the centerpoint we computed for the target + // offset. pdc->BitBlt(nX, nY, twirl_width, twirl_height, &dcMemory, 0, 0, SRCCOPY); } @@ -281,7 +278,7 @@ void CP3DActiveXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInv void CP3DActiveXCtrl::OnClose( DWORD dwSaveOption ) { - m_instance.Stop(); + m_instance.Stop(); // Make sure the init thread has finished. if (_state == S_loading) { @@ -290,7 +287,7 @@ void CP3DActiveXCtrl::OnClose( DWORD dwSaveOption ) nout << "Done waiting for thread stop\n" << flush; } - COleControl::OnClose( dwSaveOption ); + COleControl::OnClose( dwSaveOption ); } @@ -308,16 +305,15 @@ void CP3DActiveXCtrl::DoPropExchange(CPropExchange* pPX) -// CP3DActiveXCtrl::GetControlFlags - -// Flags to customize MFC's implementation of ActiveX controls. -// +// CP3DActiveXCtrl::GetControlFlags - Flags to customize MFC's implementation +// of ActiveX controls. DWORD CP3DActiveXCtrl::GetControlFlags() { DWORD dwFlags = COleControl::GetControlFlags(); - // The control will not be redrawn when making the transition - // between the active and inactivate state. + // The control will not be redrawn when making the transition between the + // active and inactivate state. dwFlags |= noFlickerActivate; return dwFlags; } @@ -421,9 +417,8 @@ int CP3DActiveXCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) } if ( collectionLength < 1 ) { - // javascript engine was not specified on the page. - // hence we need to initialize it by infusing javascript - // element tags + // javascript engine was not specified on the page. hence we need to + // initialize it by infusing javascript element tags CComPtr spHtmlElement; hr = pHtml2Doc->createElement( CComBSTR( "script" ), &spHtmlElement ); @@ -465,8 +460,7 @@ st_init(void *data) { self->_init_not_running.SetEvent(); } -// The init method. This is called once at startup, in a child -// thread. +// The init method. This is called once at startup, in a child thread. int CP3DActiveXCtrl::init( ) { int error( 0 ); @@ -553,8 +547,7 @@ HRESULT CP3DActiveXCtrl::ExchangeProperties( CPropExchange* pPX ) for (unsigned long ind = 0; ind < aNum; ind++) { std::pair< CString, CString> p( CString( aPropNames[ind].pstrName ), CString( aVal[ind] ) ); m_parameters.push_back( p ); -// do_what_you_want_with (OLE2T (aPropNames[ind].pstrName), -// aVal[ind]); +// do_what_you_want_with (OLE2T (aPropNames[ind].pstrName), aVal[ind]); } // delete the unused arrays delete[] hvs; @@ -622,4 +615,3 @@ timer_callback(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) { // Just invalidate the region and make it draw again. ::InvalidateRect(hwnd, NULL, FALSE); } - diff --git a/direct/src/plugin_activex/P3DActiveXCtrl.h b/direct/src/plugin_activex/P3DActiveXCtrl.h index 3af6ac2ce7..133ce29d27 100644 --- a/direct/src/plugin_activex/P3DActiveXCtrl.h +++ b/direct/src/plugin_activex/P3DActiveXCtrl.h @@ -1,20 +1,20 @@ -// Filename: P3DActiveXCtrl.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveXCtrl.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once -// P3DActiveXCtrl.h : Declaration of the CP3DActiveXCtrl ActiveX Control class. +// P3DActiveXCtrl.h : Declaration of the CP3DActiveXCtrl ActiveX Control +// class. #include "PPInstance.h" #include "PPPandaObject.h" #include "PPInterface.h" @@ -29,7 +29,7 @@ class CP3DActiveXCtrl : public COleControl, public PPInterface { DECLARE_DYNCREATE(CP3DActiveXCtrl) - + // Constructor public: CP3DActiveXCtrl(); @@ -82,7 +82,7 @@ public: virtual IOleClientSite* GetClientSte(); // ActiveX properties - std::vector< std::pair < CString, CString > > m_parameters; + std::vector< std::pair < CString, CString > > m_parameters; CString m_hostingPageUrl; @@ -114,4 +114,3 @@ protected: DWORD _init_time; CEvent _init_not_running; // set when the init thread has finished, or before it has started. }; - diff --git a/direct/src/plugin_activex/P3DActiveXPropPage.cpp b/direct/src/plugin_activex/P3DActiveXPropPage.cpp index 7fba377fbb..181f249838 100644 --- a/direct/src/plugin_activex/P3DActiveXPropPage.cpp +++ b/direct/src/plugin_activex/P3DActiveXPropPage.cpp @@ -1,18 +1,18 @@ -// Filename: P3DActiveXPropPage.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveXPropPage.cpp + * @author atrestman + * @date 2009-09-14 + */ -// P3DActiveXPropPage.cpp : Implementation of the CP3DActiveXPropPage property page class. +// P3DActiveXPropPage.cpp : Implementation of the CP3DActiveXPropPage property +// page class. #include "stdafx.h" #include "P3DActiveX.h" @@ -41,8 +41,8 @@ IMPLEMENT_OLECREATE_EX(CP3DActiveXPropPage, "P3DACTIVEX.P3DActiveXPropPage.1", -// CP3DActiveXPropPage::CP3DActiveXPropPageFactory::UpdateRegistry - -// Adds or removes system registry entries for CP3DActiveXPropPage +// CP3DActiveXPropPage::CP3DActiveXPropPageFactory::UpdateRegistry - Adds or +// removes system registry entries for CP3DActiveXPropPage BOOL CP3DActiveXPropPage::CP3DActiveXPropPageFactory::UpdateRegistry(BOOL bRegister) { @@ -64,7 +64,8 @@ CP3DActiveXPropPage::CP3DActiveXPropPage() : -// CP3DActiveXPropPage::DoDataExchange - Moves data between page and properties +// CP3DActiveXPropPage::DoDataExchange - Moves data between page and +// properties void CP3DActiveXPropPage::DoDataExchange(CDataExchange* pDX) { diff --git a/direct/src/plugin_activex/P3DActiveXPropPage.h b/direct/src/plugin_activex/P3DActiveXPropPage.h index d7d377f921..56b1400a26 100644 --- a/direct/src/plugin_activex/P3DActiveXPropPage.h +++ b/direct/src/plugin_activex/P3DActiveXPropPage.h @@ -1,20 +1,20 @@ -// Filename: P3DActiveXPropPage.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file P3DActiveXPropPage.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once -// P3DActiveXPropPage.h : Declaration of the CP3DActiveXPropPage property page class. +// P3DActiveXPropPage.h : Declaration of the CP3DActiveXPropPage property page +// class. #include "PPPandaObject.h" // CP3DActiveXPropPage : See P3DActiveXPropPage.cpp for implementation. @@ -39,4 +39,3 @@ protected: protected: DECLARE_MESSAGE_MAP() }; - diff --git a/direct/src/plugin_activex/PPBrowserObject.cpp b/direct/src/plugin_activex/PPBrowserObject.cpp index f2ac8f8a4e..02debb6dc9 100644 --- a/direct/src/plugin_activex/PPBrowserObject.cpp +++ b/direct/src/plugin_activex/PPBrowserObject.cpp @@ -1,16 +1,15 @@ -// Filename: PPBrowserObject.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPBrowserObject.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" @@ -21,58 +20,57 @@ #include // The following functions are C-style wrappers around the above -// PPBrowserObject methods; they are defined to allow us to create the -// C-style P3D_class_definition method table to store in the -// P3D_object structure. -static void object_finish(P3D_object *object) +// PPBrowserObject methods; they are defined to allow us to create the C-style +// P3D_class_definition method table to store in the P3D_object structure. +static void object_finish(P3D_object *object) { delete ((PPBrowserObject *)object); } -static int object_get_repr(P3D_object *object, char *buffer, int buffer_length) +static int object_get_repr(P3D_object *object, char *buffer, int buffer_length) { return ((const PPBrowserObject *)object)->get_repr(buffer, buffer_length); } -static P3D_object* object_get_property(P3D_object *object, const char *property) +static P3D_object* object_get_property(P3D_object *object, const char *property) { return ((const PPBrowserObject *)object)->get_property(property); } static bool object_set_property(P3D_object* object, const char* property, - bool needs_response, P3D_object *value) + bool needs_response, P3D_object *value) { return ((PPBrowserObject *)object)->set_property(property, needs_response, value); } -static P3D_object* object_call(P3D_object* object, const char* method_name, +static P3D_object* object_call(P3D_object* object, const char* method_name, bool needs_response, - P3D_object *params[], int num_params) + P3D_object *params[], int num_params) { if (method_name == NULL) { method_name = ""; } P3D_object *response = ((const PPBrowserObject *)object)->call(method_name, params, num_params); - if (!needs_response) + if (!needs_response) { - // No response was expected. Throw away the response we received, - // so we can be consistent with defined semantics. + // No response was expected. Throw away the response we received, so + // we can be consistent with defined semantics. P3D_OBJECT_XDECREF(response); response = NULL; } return response; } -static P3D_object* object_eval( P3D_object *object, const char *expression ) +static P3D_object* object_eval( P3D_object *object, const char *expression ) { return ( ( const PPBrowserObject* )object )->eval( expression ); } P3D_class_definition* PPBrowserObject::_browser_object_class; -PPBrowserObject::PPBrowserObject( PPInterface* interfac, IDispatch* pDispatch ) : - m_interface( interfac ), m_pDispatch( pDispatch ) +PPBrowserObject::PPBrowserObject( PPInterface* interfac, IDispatch* pDispatch ) : + m_interface( interfac ), m_pDispatch( pDispatch ) { _class = get_class_definition( ); _ref_count = 1; @@ -85,7 +83,7 @@ PPBrowserObject::PPBrowserObject( const PPBrowserObject& copy ) : _ref_count = 1; } -PPBrowserObject::~PPBrowserObject( ) +PPBrowserObject::~PPBrowserObject( ) { assert( _ref_count == 0 ); } @@ -101,7 +99,7 @@ P3D_object* PPBrowserObject::get_property( const std::string &property ) const { return NULL; } - + hr = m_interface->GetProperty( pDispatch, CString( property.c_str() ), varResult ); if ( FAILED( hr ) ) { @@ -113,7 +111,7 @@ P3D_object* PPBrowserObject::get_property( const std::string &property ) const bool PPBrowserObject::set_property( const std::string& property, bool needs_response, P3D_object* value ) -{ +{ assert( m_interface ); CComPtr pDispatch( m_pDispatch ); @@ -136,13 +134,13 @@ P3D_object* PPBrowserObject::call( const std::string &method_name, P3D_object* p COleVariant varResult; // First, convert all of the parameters. - for ( int i = 0; i < num_params; ++i ) + for ( int i = 0; i < num_params; ++i ) { m_interface->p3dobj_to_variant( &varParams[i], params[i] ); } CComPtr pDispatch( m_pDispatch ); - HRESULT hr = m_interface->CallMethod( pDispatch, CString( method_name.c_str() ), varResult, num_params, varParams ); + HRESULT hr = m_interface->CallMethod( pDispatch, CString( method_name.c_str() ), varResult, num_params, varParams ); delete [] varParams; if ( FAILED( hr ) ) @@ -160,7 +158,7 @@ P3D_object* PPBrowserObject::eval( const std::string &expression ) const CComPtr pDispatch( m_pDispatch ); CString evalExpression( expression.c_str() ); - HRESULT hr = m_interface->EvalExpression( pDispatch, evalExpression , varResult ); + HRESULT hr = m_interface->EvalExpression( pDispatch, evalExpression , varResult ); if ( FAILED( hr ) ) { return NULL; @@ -184,14 +182,14 @@ int PPBrowserObject::get_repr( char* buffer, int buffer_length ) const return (int)result.GetLength(); } -void PPBrowserObject::clear_class_definition() +void PPBrowserObject::clear_class_definition() { _browser_object_class = NULL; } -P3D_class_definition* PPBrowserObject::get_class_definition() +P3D_class_definition* PPBrowserObject::get_class_definition() { - if ( _browser_object_class == NULL ) + if ( _browser_object_class == NULL ) { // Create a default class_definition object, and fill in the // appropriate pointers. diff --git a/direct/src/plugin_activex/PPBrowserObject.h b/direct/src/plugin_activex/PPBrowserObject.h index a8cfc1411f..ac4d6426c7 100644 --- a/direct/src/plugin_activex/PPBrowserObject.h +++ b/direct/src/plugin_activex/PPBrowserObject.h @@ -1,16 +1,15 @@ -// Filename: PPBrowserObject.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPBrowserObject.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -19,7 +18,7 @@ class PPInterface; -class PPBrowserObject : public P3D_object +class PPBrowserObject : public P3D_object { public: PPBrowserObject( PPInterface* interfac, IDispatch* pDisp ); @@ -31,7 +30,7 @@ public: bool set_property( const std::string& property, bool needs_response, P3D_object* value ); - P3D_object* call( const std::string &method_name, + P3D_object* call( const std::string &method_name, P3D_object* params[], int num_params ) const; P3D_object* eval( const std::string &expression ) const; diff --git a/direct/src/plugin_activex/PPDownloadCallback.cpp b/direct/src/plugin_activex/PPDownloadCallback.cpp index d02bc643d3..d7739e2039 100644 --- a/direct/src/plugin_activex/PPDownloadCallback.cpp +++ b/direct/src/plugin_activex/PPDownloadCallback.cpp @@ -1,31 +1,30 @@ -// Filename: PPDownloadCallback.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPDownloadCallback.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" #include "PPDownloadCallback.h" #include "PPInstance.h" -PPDownloadCallback::PPDownloadCallback( PPDownloadCallbackSync& downloadSync ) - : m_downloadSync( downloadSync ), m_dwTotalRead( 0 ), - m_dwTotalInStream( 0 ), m_ulObjRefCount( 1 ) +PPDownloadCallback::PPDownloadCallback( PPDownloadCallbackSync& downloadSync ) + : m_downloadSync( downloadSync ), m_dwTotalRead( 0 ), + m_dwTotalInStream( 0 ), m_ulObjRefCount( 1 ) { } PPDownloadCallback::~PPDownloadCallback() { - m_spStream.Release(); + m_spStream.Release(); } STDMETHODIMP PPDownloadCallback::QueryInterface(REFIID riid, void **ppvObject) @@ -57,7 +56,7 @@ STDMETHODIMP PPDownloadCallback::QueryInterface(REFIID riid, void **ppvObject) } return E_NOINTERFACE; -} +} STDMETHODIMP_(ULONG) PPDownloadCallback::AddRef() { @@ -102,7 +101,7 @@ STDMETHODIMP PPDownloadCallback::OnProgress(ULONG ulProgress, LPCWSTR szStatusText) { #ifdef _DEBUG - static const LPCTSTR plpszStatus[] = + static const LPCTSTR plpszStatus[] = { _T("BINDSTATUS_FINDINGRESOURCE"), // 1 _T("BINDSTATUS_CONNECTING"), diff --git a/direct/src/plugin_activex/PPDownloadCallback.h b/direct/src/plugin_activex/PPDownloadCallback.h index 08ff5c00bf..0ea6d3de4b 100644 --- a/direct/src/plugin_activex/PPDownloadCallback.h +++ b/direct/src/plugin_activex/PPDownloadCallback.h @@ -1,16 +1,15 @@ -// Filename: PPDownloadCallback.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPDownloadCallback.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once diff --git a/direct/src/plugin_activex/PPDownloadRequest.cpp b/direct/src/plugin_activex/PPDownloadRequest.cpp index 961ae07d89..5a25bfd2cc 100644 --- a/direct/src/plugin_activex/PPDownloadRequest.cpp +++ b/direct/src/plugin_activex/PPDownloadRequest.cpp @@ -1,16 +1,15 @@ -// Filename: PPDownloadRequest.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPDownloadRequest.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" @@ -18,10 +17,10 @@ #include "PPInstance.h" #include "wstring_encode.h" -bool PPDownloadRequest::Begin( ) +bool PPDownloadRequest::Begin( ) { - m_instance.m_eventStop.ResetEvent( ); - m_instance.m_eventDownloadStopped.ResetEvent( ); + m_instance.m_eventStop.ResetEvent( ); + m_instance.m_eventDownloadStopped.ResetEvent( ); return true; } @@ -41,12 +40,12 @@ bool PPDownloadRequest::DataNotify( size_t expectedDataSize, const void* data, s { if ( m_p3dRequest ) { - ret = P3D_instance_feed_url_stream_ptr( m_p3dRequest->_instance, - m_p3dRequest->_request._get_url._unique_id, - P3D_RC_in_progress, - 0, - expectedDataSize, - data, + ret = P3D_instance_feed_url_stream_ptr( m_p3dRequest->_instance, + m_p3dRequest->_request._get_url._unique_id, + P3D_RC_in_progress, + 0, + expectedDataSize, + data, dataSize ); } } @@ -88,17 +87,17 @@ void PPDownloadRequest::ProgressNotify( size_t progress, size_t maxProgress ) { if ( ::IsWindow( m_instance.m_parentWnd ) ) { - SendMessage( m_instance.m_parentWnd, WM_PROGRESS, (WPARAM)(progress * 100.0 / maxProgress), 0 ); + SendMessage( m_instance.m_parentWnd, WM_PROGRESS, (WPARAM)(progress * 100.0 / maxProgress), 0 ); } } -bool PPDownloadRequest::End( ) +bool PPDownloadRequest::End( ) { if ( m_hFile != INVALID_HANDLE_VALUE ) { ::CloseHandle( m_hFile ); m_hFile = INVALID_HANDLE_VALUE; } - m_instance.m_eventDownloadStopped.SetEvent( ); + m_instance.m_eventDownloadStopped.SetEvent( ); return true; } diff --git a/direct/src/plugin_activex/PPDownloadRequest.h b/direct/src/plugin_activex/PPDownloadRequest.h index b35828f052..a9ad8f3b2d 100644 --- a/direct/src/plugin_activex/PPDownloadRequest.h +++ b/direct/src/plugin_activex/PPDownloadRequest.h @@ -1,16 +1,15 @@ -// Filename: PPDownloadRequest.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPDownloadRequest.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -31,19 +30,19 @@ public: }; PPDownloadRequest( PPInstance& instance, P3D_request* p3dRequest ) : - m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( NULL ), + m_instance( instance ), m_p3dRequest( p3dRequest ), m_data( NULL ), m_requestType( RequestType::P3DObject ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, const std::string& fileName ) : - m_instance( instance ), m_p3dRequest( NULL ), m_fileName( fileName ), + m_instance( instance ), m_p3dRequest( NULL ), m_fileName( fileName ), m_data( NULL ), m_requestType( RequestType::File ), m_hFile( INVALID_HANDLE_VALUE ) { } PPDownloadRequest( PPInstance& instance, std::strstream* data ) : - m_instance( instance ), m_p3dRequest ( NULL ), m_data( data ), + m_instance( instance ), m_p3dRequest ( NULL ), m_data( data ), m_requestType( RequestType::Data ), m_hFile( INVALID_HANDLE_VALUE ) { } diff --git a/direct/src/plugin_activex/PPInstance.cpp b/direct/src/plugin_activex/PPInstance.cpp index 2151fc63f1..1c1c6fc071 100644 --- a/direct/src/plugin_activex/PPInstance.cpp +++ b/direct/src/plugin_activex/PPInstance.cpp @@ -1,16 +1,15 @@ -// Filename: PPInstance.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPInstance.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" @@ -42,8 +41,8 @@ #include "parse_color.h" #include "wstring_encode.h" -// We can include this header file to get the DTOOL_PLATFORM -// definition, even though we don't link with dtool. +// We can include this header file to get the DTOOL_PLATFORM definition, even +// though we don't link with dtool. #include "dtool_platform.h" #include "pandaVersion.h" @@ -75,7 +74,7 @@ void P3D_NotificationSync(P3D_instance *instance) } } -PPInstance::PPInstance( CP3DActiveXCtrl& parentCtrl ) : +PPInstance::PPInstance( CP3DActiveXCtrl& parentCtrl ) : m_parentCtrl( parentCtrl ), m_p3dInstance( NULL ), m_p3dObject( NULL ), m_isInit( false ) { // We need the root dir first. @@ -92,8 +91,8 @@ PPInstance::PPInstance( CP3DActiveXCtrl& parentCtrl ) : _tokens = NULL; _num_tokens = 0; - // Ensure this event is initially in the "set" state, in case we - // never get a download request before we get a close request. + // Ensure this event is initially in the "set" state, in case we never get a + // download request before we get a close request. m_eventDownloadStopped.SetEvent( ); m_eventStop.ResetEvent(); @@ -104,8 +103,8 @@ PPInstance::~PPInstance() { assert(_tokens == NULL); } -// This is called at setup time to read the set of web tokens from the -// ActiveX control. +// This is called at setup time to read the set of web tokens from the ActiveX +// control. void PPInstance:: read_tokens() { assert(_tokens == NULL); @@ -113,20 +112,20 @@ read_tokens() { _tokens = new P3D_token[ _num_tokens ]; for (int i = 0; i < _num_tokens; i++ ) { std::pair< CString, CString > keyAndValue = m_parentCtrl.m_parameters[ i ]; - // Make the token lowercase, since HTML is case-insensitive but - // we're not. + // Make the token lowercase, since HTML is case-insensitive but we're + // not. string keyword; for (const char *p = m_parentCtrl.m_parameters[ i ].first; *p; ++p) { keyword += tolower(*p); } - - _tokens[i]._keyword = strdup( keyword.c_str() ); + + _tokens[i]._keyword = strdup( keyword.c_str() ); _tokens[i]._value = strdup( m_parentCtrl.m_parameters[ i ].second ); } - - // fgcolor and bgcolor are useful to know here (in case we have to - // draw a twirling icon). - + + // fgcolor and bgcolor are useful to know here (in case we have to draw a + // twirling icon). + // The default bgcolor is white. _bgcolor_r = _bgcolor_g = _bgcolor_b = 0xff; if (has_token("bgcolor")) { @@ -137,7 +136,7 @@ read_tokens() { _bgcolor_b = b; } } - + // The default fgcolor is either black or white, according to the // brightness of the bgcolor. if (_bgcolor_r + _bgcolor_g + _bgcolor_b > 0x80 + 0x80 + 0x80) { @@ -158,16 +157,16 @@ read_tokens() { int PPInstance::DownloadFile( const std::string& from, const std::string& to ) { int error( 0 ); - HRESULT hr( S_OK ); + HRESULT hr( S_OK ); nout << "Downloading " << from << " into " << to << "\n"; - { - PPDownloadRequest p3dFileDownloadRequest( *this, to ); - PPDownloadCallback dcForFile( p3dFileDownloadRequest ); - hr = ::URLOpenStream( m_parentCtrl.GetControllingUnknown(), from.c_str(), 0, &dcForFile ); - } + { + PPDownloadRequest p3dFileDownloadRequest( *this, to ); + PPDownloadCallback dcForFile( p3dFileDownloadRequest ); + hr = ::URLOpenStream( m_parentCtrl.GetControllingUnknown(), from.c_str(), 0, &dcForFile ); + } if ( FAILED( hr ) ) - { + { error = 1; nout << "Error downloading " << from << " :" << hr << "\n"; } @@ -178,10 +177,10 @@ int PPInstance::CopyFile( const std::string& from, const std::string& to ) { ifstream in(from.c_str(), ios::in | ios::binary); ofstream out(to.c_str(), ios::out | ios::binary); - + static const size_t buffer_size = 4096; char buffer[buffer_size]; - + in.read(buffer, buffer_size); size_t count = in.gcount(); while (count != 0) { @@ -200,14 +199,11 @@ int PPInstance::CopyFile( const std::string& from, const std::string& to ) return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::read_contents_file -// Access: Private -// Description: Attempts to open and read the contents.xml file on -// disk. Copies the file to its standard location -// on success. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open and read the contents.xml file on disk. Copies the file + * to its standard location on success. Returns true on success, false on + * failure. + */ bool PPInstance:: read_contents_file(const string &contents_filename, bool fresh_download) { TiXmlDocument doc(contents_filename.c_str()); @@ -237,7 +233,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { xorig = new TiXmlElement("orig"); xcontents->LinkEndChild(xorig); - + xorig->SetAttribute("expiration", (int)_contents_expiration); } else { @@ -247,7 +243,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { if (xorig != NULL) { xorig->Attribute("expiration", &expiration); } - + _contents_expiration = min(_contents_expiration, (time_t)expiration); } @@ -255,8 +251,8 @@ read_contents_file(const string &contents_filename, bool fresh_download) { << ", expires in " << max(_contents_expiration, now) - now << " s\n"; - // Look for the entry; it might point us at a different - // download URL, and it might mention some mirrors. + // Look for the entry; it might point us at a different download + // URL, and it might mention some mirrors. find_host(xcontents); // Now look for the core API package. @@ -276,7 +272,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { break; } } - + xpackage = xpackage->NextSiblingElement("package"); } } @@ -288,9 +284,9 @@ read_contents_file(const string &contents_filename, bool fresh_download) { return false; } - // Check the coreapi_set_ver token. If it is given, it specifies a - // minimum Core API version number we expect to find. If we didn't - // find that number, perhaps our contents.xml is out of date. + // Check the coreapi_set_ver token. If it is given, it specifies a minimum + // Core API version number we expect to find. If we didn't find that + // number, perhaps our contents.xml is out of date. string coreapi_set_ver = lookup_token("coreapi_set_ver"); if (!coreapi_set_ver.empty()) { nout << "Instance asked for Core API set_ver " << coreapi_set_ver @@ -298,8 +294,8 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // But don't bother if we just freshly downloaded it. if (!fresh_download) { if (compare_seq(coreapi_set_ver, _coreapi_set_ver) > 0) { - // The requested set_ver value is higher than the one we have on - // file; our contents.xml file must be out of date after all. + // The requested set_ver value is higher than the one we have on file; + // our contents.xml file must be out of date after all. nout << "expiring contents.xml\n"; _contents_expiration = 0; } @@ -314,16 +310,13 @@ read_contents_file(const string &contents_filename, bool fresh_download) { nout << "Couldn't rewrite " << standard_filename << "\n"; return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::find_host -// Access: Private -// Description: Scans the element for the matching -// element. -//////////////////////////////////////////////////////////////////// +/** + * Scans the element for the matching element. + */ void PPInstance:: find_host(TiXmlElement *xcontents) { string host_url = PANDA_PACKAGE_HOST_URL; @@ -349,22 +342,20 @@ find_host(TiXmlElement *xcontents) { } } - // Hmm, didn't find the URL we used mentioned. Assume we're the - // primary host. + // Hmm, didn't find the URL we used mentioned. Assume we're the primary + // host. read_xhost(xhost); } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::read_xhost -// Access: Private -// Description: Reads the host data from the (or ) -// entry in the contents.xml file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the host data from the (or ) entry in the + * contents.xml file. + */ void PPInstance:: read_xhost(TiXmlElement *xhost) { - // Get the "download" URL, which is the source from which we - // download everything other than the contents.xml file. + // Get the "download" URL, which is the source from which we download + // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); if (download_url != NULL) { _download_url_prefix = download_url; @@ -376,7 +367,7 @@ read_xhost(TiXmlElement *xhost) { _download_url_prefix += "/"; } } - + TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); while (xmirror != NULL) { const char *url = xmirror->Attribute("url"); @@ -387,35 +378,28 @@ read_xhost(TiXmlElement *xhost) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::add_mirror -// Access: Private -// Description: Adds a new URL to serve as a mirror for this host. -// The mirrors will be consulted first, before -// consulting the host directly. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new URL to serve as a mirror for this host. The mirrors will be + * consulted first, before consulting the host directly. + */ void PPInstance:: add_mirror(std::string mirror_url) { // Ensure the URL ends in a slash. if (!mirror_url.empty() && mirror_url[mirror_url.size() - 1] != '/') { mirror_url += '/'; } - - // Add it to the _mirrors list, but only if it's not already - // there. + + // Add it to the _mirrors list, but only if it's not already there. if (std::find(_mirrors.begin(), _mirrors.end(), mirror_url) == _mirrors.end()) { _mirrors.push_back(mirror_url); } } - -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::choose_random_mirrors -// Access: Public -// Description: Selects num_mirrors elements, chosen at random, from -// the _mirrors list. Adds the selected mirrors to -// result. If there are fewer than num_mirrors elements -// in the list, adds only as many mirrors as we can get. -//////////////////////////////////////////////////////////////////// + +/** + * Selects num_mirrors elements, chosen at random, from the _mirrors list. + * Adds the selected mirrors to result. If there are fewer than num_mirrors + * elements in the list, adds only as many mirrors as we can get. + */ void PPInstance:: choose_random_mirrors(std::vector &result, int num_mirrors) { std::vector selected; @@ -452,14 +436,14 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) } if (!already_got) { - // OK, we need to download a new contents.xml file. Start off - // by downloading it into a local temporary file. + // OK, we need to download a new contents.xml file. Start off by + // downloading it into a local temporary file. WCHAR local_filename_w[ MAX_PATH ]; if (!::GetTempFileNameW( m_rootDir_w.c_str(), L"p3d", 0, local_filename_w )) { nout << "GetTempFileName failed (folder is " << m_rootDir << ")\n"; return 1; } - + std::string local_filename; wstring_to_string(local_filename, local_filename_w); @@ -467,13 +451,13 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) if (!hostUrl.empty() && hostUrl[hostUrl.size() - 1] != '/') { hostUrl += '/'; } - - // Append a query string to the contents.xml URL to uniquify it - // and ensure we don't get a cached version. + + // Append a query string to the contents.xml URL to uniquify it and + // ensure we don't get a cached version. std::ostringstream strm; strm << hostUrl << P3D_CONTENTS_FILENAME << "?" << time(NULL); std::string remoteContentsUrl( strm.str() ); - + error = DownloadFile( remoteContentsUrl, local_filename ); if ( !error ) { if ( !read_contents_file( local_filename, true ) ) @@ -481,8 +465,8 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) } if ( error ) { - // If we couldn't download or read the contents.xml file, check - // to see if there's a good one on disk already, as a fallback. + // If we couldn't download or read the contents.xml file, check to see + // if there's a good one on disk already, as a fallback. if ( !read_contents_file( finalContentsFileName, false ) ) error = 1; } @@ -490,10 +474,10 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) // We don't need the temporary file any more. ::DeleteFileW( local_filename_w ); } - + if (!error) { - // OK, at this point we have successfully read contents.xml, - // and we have a good file spec in _coreapi_dll. + // OK, at this point we have successfully read contents.xml, and we have + // a good file spec in _coreapi_dll. if (_coreapi_dll.quick_verify(m_rootDir)) { // The DLL is already on-disk, and is good. p3dDllFilename = _coreapi_dll.get_pathname(m_rootDir); @@ -508,7 +492,7 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) error = 1; for (std::vector::iterator si = mirrors.begin(); - si != mirrors.end() && error; + si != mirrors.end() && error; ++si) { std::string url = (*si) + _coreapi_dll.get_filename(); error = DownloadFile(url, p3dLocalModuleFileName); @@ -527,8 +511,8 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) } } - // If *that* failed, go get it again from the same URL, this - // time with a query prefix to bust through any caches. + // If *that* failed, go get it again from the same URL, this time with + // a query prefix to bust through any caches. if (error) { std::ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename(); @@ -556,12 +540,12 @@ int PPInstance::DownloadP3DComponents( std::string& p3dDllFilename ) return error; } -int PPInstance::LoadPlugin( const std::string& dllFilename ) +int PPInstance::LoadPlugin( const std::string& dllFilename ) { CSingleLock lock(&_load_mutex); lock.Lock(); if ( !m_pluginLoaded ) - { + { ref_plugin(); m_pluginLoaded = true; } @@ -573,9 +557,9 @@ int PPInstance::LoadPlugin( const std::string& dllFilename ) #ifdef P3D_PLUGIN_P3D_PLUGIN // This is a convenience macro for development. If defined and // nonempty, it indicates the name of the plugin DLL that we will - // actually run, even after downloading a possibly different - // (presumably older) version. Its purpose is to simplify iteration - // on the plugin DLL. + // actually run, even after downloading a possibly different (presumably + // older) version. Its purpose is to simplify iteration on the plugin + // DLL. string override_filename = P3D_PLUGIN_P3D_PLUGIN; if (!override_filename.empty()) { pathname = override_filename; @@ -625,7 +609,7 @@ int PPInstance::UnloadPlugin() int error( 0 ); if ( m_pluginLoaded ) - { + { m_pluginLoaded = false; m_isInit = false; unref_plugin(); @@ -633,27 +617,26 @@ int PPInstance::UnloadPlugin() return error; } -// Increments the reference count on the "plugin" library (i.e. the -// core API). Call unref_plugin() later to decrement this count. +// Increments the reference count on the "plugin" library (i.e. the core +// API). Call unref_plugin() later to decrement this count. void PPInstance:: ref_plugin() { s_instanceCount += 1; } // Decrements the reference count on the "plugin" library. This must -// correspond to an earlier call to ref_plugin(). When the last -// reference is removed, the plugin will be unloaded. +// correspond to an earlier call to ref_plugin(). When the last reference is +// removed, the plugin will be unloaded. void PPInstance:: unref_plugin() { assert( s_instanceCount > 0 ); s_instanceCount -= 1; - + if ( s_instanceCount == 0 && is_plugin_loaded() ) { nout << "Unloading core API\n"; unload_plugin(nout); - - // This pointer is no longer valid and must be reset for next - // time. + + // This pointer is no longer valid and must be reset for next time. PPBrowserObject::clear_class_definition(); } } @@ -663,7 +646,7 @@ int PPInstance::Start( const std::string& p3dFilename ) { CSingleLock lock(&_load_mutex); lock.Lock(); - + assert(!m_isInit); m_isInit = true; } @@ -681,17 +664,17 @@ int PPInstance::Start( const std::string& p3dFilename ) if ( !m_p3dInstance ) { - nout << "Error creating P3D instance: " << GetLastError() << "\n"; + nout << "Error creating P3D instance: " << GetLastError() << "\n"; return 1; } CComPtr pDispatch; PPBrowserObject *pobj = new PPBrowserObject( &m_parentCtrl, pDispatch ); P3D_instance_set_browser_script_object_ptr( m_p3dInstance, pobj ); P3D_OBJECT_DECREF( pobj ); - + m_p3dObject = P3D_instance_get_panda_script_object_ptr( m_p3dInstance ); P3D_OBJECT_INCREF( m_p3dObject ); - + P3D_instance_setup_window_ptr( m_p3dInstance, P3D_WT_embedded, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, &parent_window ); nout << "Starting new P3D instance " << p3dFilename << "\n"; @@ -706,8 +689,8 @@ int PPInstance::Start( const std::string& p3dFilename ) int PPInstance::Stop( ) { - m_eventStop.SetEvent( ); - ::WaitForSingleObject( m_eventDownloadStopped.m_hObject, INFINITE ); + m_eventStop.SetEvent( ); + ::WaitForSingleObject( m_eventDownloadStopped.m_hObject, INFINITE ); if ( m_p3dInstance ) { P3D_instance_finish_ptr( m_p3dInstance ); @@ -733,15 +716,15 @@ int PPInstance::Stop( ) _num_tokens = 0; } - return 0; + return 0; } std::string PPInstance::GetHostUrl( ) { CString hostingPageLocation = m_parentCtrl.m_hostingPageUrl.Left( m_parentCtrl.m_hostingPageUrl.ReverseFind( '/' ) );; std::string p3dRemoteFilename( hostingPageLocation ); - p3dRemoteFilename += "/"; - return p3dRemoteFilename; + p3dRemoteFilename += "/"; + return p3dRemoteFilename; } std::string PPInstance::GetP3DFilename( ) @@ -766,12 +749,11 @@ void PPInstance::HandleRequestLoop() { CP3DActiveXCtrl* parent = ( CP3DActiveXCtrl* )(p3d_inst->_user_data); if ( parent ) { if (!parent->m_instance.HandleRequest( request )) { - // If handling the request is meant to yield control - // temporarily to JavaScript (e.g. P3D_RT_callback), then do - // so now. + // If handling the request is meant to yield control temporarily to + // JavaScript (e.g. P3D_RT_callback), then do so now. return; } - + } else { nout << "Error handling P3D request. Instance's user data is not a Control \n"; } @@ -782,7 +764,7 @@ void PPInstance::HandleRequestLoop() { void PPInstance::HandleRequestGetUrl( void* data ) { - HRESULT hr( S_OK ); + HRESULT hr( S_OK ); ThreadedRequestData *trdata = static_cast( data ); PPInstance *self = trdata->_self; P3D_request *request = trdata->_request; @@ -808,46 +790,44 @@ void PPInstance::HandleRequestGetUrl( void* data ) size_t colon = url.find(':'); size_t slash = url.find('/'); if (colon == std::string::npos || colon > slash) { - // Not a full URL, so it's a relative URL. Prepend the current - // URL. + // Not a full URL, so it's a relative URL. Prepend the current URL. if (url.empty() || url[0] == '/') { - // It starts with a slash, so go back to the root of this - // particular host. + // It starts with a slash, so go back to the root of this particular + // host. colon = host_url.find(':'); - if (colon != std::string::npos && - colon + 2 < host_url.size() && + if (colon != std::string::npos && + colon + 2 < host_url.size() && host_url[colon + 1] == '/' && host_url[colon + 2] == '/') { slash = host_url.find('/', colon + 3); url = host_url.substr(0, slash) + url; } } else { - // It doesn't start with a slash, so it's relative to this - // page. + // It doesn't start with a slash, so it's relative to this page. url = host_url + url; } nout << "Made fullpath: " << url << "\n"; } - { - PPDownloadRequest p3dObjectDownloadRequest( parent->m_instance, request ); - PPDownloadCallback bsc( p3dObjectDownloadRequest ); - hr = ::URLOpenStream( parent->GetControllingUnknown(), url.c_str(), 0, &bsc ); - } + { + PPDownloadRequest p3dObjectDownloadRequest( parent->m_instance, request ); + PPDownloadCallback bsc( p3dObjectDownloadRequest ); + hr = ::URLOpenStream( parent->GetControllingUnknown(), url.c_str(), 0, &bsc ); + } P3D_result_code result_code = P3D_RC_done; if ( FAILED( hr ) ) { - nout << "Error handling P3D_RT_get_url request" << " :" << hr << "\n"; + nout << "Error handling P3D_RT_get_url request" << " :" << hr << "\n"; result_code = P3D_RC_generic_error; } - P3D_instance_feed_url_stream_ptr( - request->_instance, - request->_request._get_url._unique_id, - result_code, - 0, - 0, - (const void*)NULL, - 0 + P3D_instance_feed_url_stream_ptr( + request->_instance, + request->_request._get_url._unique_id, + result_code, + 0, + 0, + (const void*)NULL, + 0 ); P3D_request_finish_ptr( request, true ); } @@ -859,7 +839,7 @@ HandleRequest( P3D_request *request ) { } bool handled = false; bool continue_loop = true; - + switch ( request->_request_type ) { case P3D_RT_stop: { @@ -896,13 +876,10 @@ HandleRequest( P3D_request *request ) { return continue_loop; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::compare_seq -// Access: Private, Static -// Description: Compares the two dotted-integer sequence values -// numerically. Returns -1 if seq_a sorts first, 1 if -// seq_b sorts first, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Compares the two dotted-integer sequence values numerically. Returns -1 if + * seq_a sorts first, 1 if seq_b sorts first, 0 if they are equivalent. + */ int PPInstance:: compare_seq(const string &seq_a, const string &seq_b) { const char *num_a = seq_a.c_str(); @@ -930,13 +907,11 @@ compare_seq(const string &seq_a, const string &seq_b) { return comp; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::compare_seq_int -// Access: Private, Static -// Description: Numerically compares the formatted integer value at -// num_a with num_b. Increments both num_a and num_b to -// the next character following the valid integer. -//////////////////////////////////////////////////////////////////// +/** + * Numerically compares the formatted integer value at num_a with num_b. + * Increments both num_a and num_b to the next character following the valid + * integer. + */ int PPInstance:: compare_seq_int(const char *&num_a, const char *&num_b) { long int a; @@ -959,13 +934,10 @@ compare_seq_int(const char *&num_a, const char *&num_b) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::set_failed -// Access: Private -// Description: Called when something has gone wrong that prevents -// the plugin instance from running. Specifically, this -// means it failed to load the core API. -//////////////////////////////////////////////////////////////////// +/** + * Called when something has gone wrong that prevents the plugin instance from + * running. Specifically, this means it failed to load the core API. + */ void PPInstance:: set_failed() { if (!_failed) { @@ -982,7 +954,7 @@ set_failed() { CComPtr pDispatch; CString evalExpression( expression.c_str() ); - HRESULT hr = m_parentCtrl.EvalExpression( pDispatch, evalExpression , varResult ); + HRESULT hr = m_parentCtrl.EvalExpression( pDispatch, evalExpression , varResult ); if (FAILED(hr)) { nout << "Unable to eval " << expression << "\n"; } else { @@ -993,13 +965,10 @@ set_failed() { } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::lookup_token -// Access: Private -// Description: Returns the value associated with the first -// appearance of the named token, or empty string if the -// token does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the first appearance of the named token, + * or empty string if the token does not appear. + */ std::string PPInstance:: lookup_token(const std::string &keyword) const { for (int i = 0; i < _num_tokens; ++i) { @@ -1011,12 +980,9 @@ lookup_token(const std::string &keyword) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::has_token -// Access: Private -// Description: Returns true if the named token appears in the list, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named token appears in the list, false otherwise. + */ bool PPInstance:: has_token(const std::string &keyword) const { for (int i = 0; i < _num_tokens; ++i) { @@ -1027,4 +993,3 @@ has_token(const std::string &keyword) const { return false; } - diff --git a/direct/src/plugin_activex/PPInstance.h b/direct/src/plugin_activex/PPInstance.h index 9468f1070f..1c80168aea 100644 --- a/direct/src/plugin_activex/PPInstance.h +++ b/direct/src/plugin_activex/PPInstance.h @@ -1,16 +1,15 @@ -// Filename: PPInstance.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPInstance.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once diff --git a/direct/src/plugin_activex/PPInterface.cpp b/direct/src/plugin_activex/PPInterface.cpp index 91ccbb3d06..25a8750c30 100644 --- a/direct/src/plugin_activex/PPInterface.cpp +++ b/direct/src/plugin_activex/PPInterface.cpp @@ -1,16 +1,15 @@ -// Filename: PPInterface.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPInterface.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" @@ -23,7 +22,7 @@ #include #include "Mshtml.h" -PPInterface::PPInterface( ) +PPInterface::PPInterface( ) { } @@ -77,14 +76,15 @@ HRESULT PPInterface::Invoke(int nType, IDispatch* pDisp, CString& ptName, VARIAN // Allocate memory for arguments... VARIANT *pArgs = new VARIANT[ cArgs + 1 ]; - // Reversing the arguments!!! - // NOTE: http://msdn.microsoft.com/en-us/library/cc237569(PROT.10).aspx - // pDispParams: MUST point to a DISPPARAMS structure that defines the arguments passed to the method. - // Arguments MUST be stored in pDispParams->rgvarg in reverse order, so that the first argument is - // the one with the highest index in the array. Byref arguments MUST be marked in this array - // as VT_EMPTY entries, and stored in rgVarRef instead. + // Reversing the arguments!!! NOTE: http:msdn.microsoft.comen- + // uslibrarycc237569(PROT.10).aspx pDispParams: MUST point to a DISPPARAMS + // structure that defines the arguments passed to the method. Arguments + // MUST be stored in pDispParams->rgvarg in reverse order, so that the + // first argument is the one with the highest index in the array. Byref + // arguments MUST be marked in this array as VT_EMPTY entries, and stored + // in rgVarRef instead. - for( int i = 0; i < cArgs; i++ ) + for( int i = 0; i < cArgs; i++ ) { pArgs[i] = params[ cArgs - 1 - i ]; } @@ -94,7 +94,7 @@ HRESULT PPInterface::Invoke(int nType, IDispatch* pDisp, CString& ptName, VARIAN dp.rgvarg = pArgs; // Handle special-case for property-puts! - if( nType & DISPATCH_PROPERTYPUT || nType & DISPATCH_PROPERTYPUTREF ) + if( nType & DISPATCH_PROPERTYPUT || nType & DISPATCH_PROPERTYPUTREF ) { dp.cNamedArgs = 1; dp.rgdispidNamedArgs = &dispidNamed; @@ -103,7 +103,7 @@ HRESULT PPInterface::Invoke(int nType, IDispatch* pDisp, CString& ptName, VARIAN // Make the call! if ( pDispEx ) { - hr = pDispEx->InvokeEx(dispID, LOCALE_USER_DEFAULT, + hr = pDispEx->InvokeEx(dispID, LOCALE_USER_DEFAULT, nType, &dp, pvResult, NULL, NULL); if ( FAILED( hr ) ) { @@ -112,7 +112,7 @@ HRESULT PPInterface::Invoke(int nType, IDispatch* pDisp, CString& ptName, VARIAN } else { - hr = pDisp->Invoke( dispID, IID_NULL, LOCALE_USER_DEFAULT, + hr = pDisp->Invoke( dispID, IID_NULL, LOCALE_USER_DEFAULT, nType, &dp, pvResult, NULL, NULL ); } delete [] pArgs; @@ -122,23 +122,23 @@ HRESULT PPInterface::Invoke(int nType, IDispatch* pDisp, CString& ptName, VARIAN HRESULT PPInterface::GetHtmlDocDispatch( CComPtr& pDispScript ) { - HRESULT hr = S_OK; + HRESULT hr = S_OK; - CComPtr pOleClientSite = GetClientSte( ); + CComPtr pOleClientSite = GetClientSte( ); if (pOleClientSite == NULL) { return E_FAIL; } - CComPtr pOleContainer; - hr = pOleClientSite->GetContainer(& pOleContainer ); - ASSERT( SUCCEEDED( hr ) && pOleContainer ); + CComPtr pOleContainer; + hr = pOleClientSite->GetContainer(& pOleContainer ); + ASSERT( SUCCEEDED( hr ) && pOleContainer ); - CComPtr pHtmlDoc; - hr = pOleContainer->QueryInterface( IID_IHTMLDocument, ( void** )&pHtmlDoc ); - ASSERT( SUCCEEDED( hr ) && pHtmlDoc ); + CComPtr pHtmlDoc; + hr = pOleContainer->QueryInterface( IID_IHTMLDocument, ( void** )&pHtmlDoc ); + ASSERT( SUCCEEDED( hr ) && pHtmlDoc ); - // Get the script object (this returns the script object, NOT the script - // element(s) that the get_scripts method does). + // Get the script object (this returns the script object, NOT the script + // element(s) that the get_scripts method does). hr = pHtmlDoc->get_Script( &pDispScript ); ASSERT( SUCCEEDED( hr ) && pDispScript ); @@ -151,7 +151,7 @@ HRESULT PPInterface::GetHtmlDocDispatch( CComPtr& pDispScript ) CComPtr pTypeInfo; hr = pDispScript->GetTypeInfo( 0, 0, &pTypeInfo ); - return hr; + return hr; } HRESULT PPInterface::HasProperty( CComPtr& pDispatch, CString& name ) @@ -179,7 +179,7 @@ HRESULT PPInterface::CallMethod( CComPtr& pDispatch, CString& name, C } if ( SUCCEEDED( hr ) ) { - hr = Invoke( DISPATCH_METHOD, pDispatch, name, &varResult, numParams, params ); + hr = Invoke( DISPATCH_METHOD, pDispatch, name, &varResult, numParams, params ); } return hr; } @@ -193,7 +193,7 @@ HRESULT PPInterface::GetProperty( CComPtr& pDispatch, CString& name, } if ( SUCCEEDED( hr ) ) { - hr = Invoke( DISPATCH_PROPERTYGET, pDispatch, name, &varResult, 0, NULL ); + hr = Invoke( DISPATCH_PROPERTYGET, pDispatch, name, &varResult, 0, NULL ); } return hr; } @@ -229,7 +229,7 @@ HRESULT PPInterface::EvalExpression( CComPtr& pDispatch, CString& exp if ( SUCCEEDED( hr ) ) { COleVariant param( expression ); - hr = Invoke( DISPATCH_METHOD, pDispatch, CString("eval"), &varResult, 1, ¶m ); + hr = Invoke( DISPATCH_METHOD, pDispatch, CString("eval"), &varResult, 1, ¶m ); } return hr; } @@ -261,12 +261,13 @@ HRESULT PPInterface::P3DCallMethod( P3D_object* p3dObject, CString& name, DISPPA P3D_object** params = new P3D_object*[pdispparams->cArgs]; for ( UINT i = 0; i < pdispparams->cArgs; i++ ) { - // Reversing the arguments!!! - // http://msdn.microsoft.com/en-us/library/cc237569(PROT.10).aspx - // pDispParams: MUST point to a DISPPARAMS structure that defines the arguments passed to the method. - // Arguments MUST be stored in pDispParams->rgvarg in reverse order, so that the first argument is - // the one with the highest index in the array. Byref arguments MUST be marked in this array - // as VT_EMPTY entries, and stored in rgVarRef instead. + // Reversing the arguments!!! http:msdn.microsoft.comen- + // uslibrarycc237569(PROT.10).aspx pDispParams: MUST point to a + // DISPPARAMS structure that defines the arguments passed to the + // method. Arguments MUST be stored in pDispParams->rgvarg in reverse + // order, so that the first argument is the one with the highest index + // in the array. Byref arguments MUST be marked in this array as + // VT_EMPTY entries, and stored in rgVarRef instead. COleVariant vaArg( pdispparams->rgvarg[pdispparams->cArgs - 1 - i] ); params[i] = variant_to_p3dobj( &vaArg ); @@ -332,13 +333,13 @@ HRESULT PPInterface::P3DSetProperty( P3D_object* p3dObject, CString& name, DISPP return S_OK; } -void PPInterface::p3dobj_to_variant(VARIANT* result, P3D_object* object) +void PPInterface::p3dobj_to_variant(VARIANT* result, P3D_object* object) { if ( !result ) { return; } - switch ( P3D_OBJECT_GET_TYPE( object ) ) + switch ( P3D_OBJECT_GET_TYPE( object ) ) { case P3D_OT_undefined: { @@ -402,7 +403,7 @@ void PPInterface::p3dobj_to_variant(VARIANT* result, P3D_object* object) } } -P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) +P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) { if ( !variant ) { @@ -410,24 +411,24 @@ P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) } switch( variant->vt ) { - case VT_VOID: + case VT_VOID: { return P3D_new_undefined_object_ptr(); break; - } + } case VT_EMPTY: { - // return P3D_new_none_object_ptr(); - // A.T. Panda really expect undefined object here + // return P3D_new_none_object_ptr(); A.T. Panda really expect + // undefined object here return P3D_new_undefined_object_ptr(); break; - } - case VT_BOOL: + } + case VT_BOOL: { return P3D_new_bool_object_ptr( variant->bVal ); break; - } - case VT_I2: + } + case VT_I2: { return P3D_new_int_object_ptr( variant->iVal ); break; @@ -494,28 +495,28 @@ P3D_object* PPInterface::variant_to_p3dobj(COleVariant* variant) } } -CString PPInterface::get_repr(COleVariant& variant) +CString PPInterface::get_repr(COleVariant& variant) { std::strstream repr; repr << "IDispatch"; switch( variant.vt ) { - case VT_VOID: + case VT_VOID: { repr << ":VT_VOID"; break; - } + } case VT_EMPTY: { repr << ":VT_EMPTY"; break; - } - case VT_BOOL: + } + case VT_BOOL: { repr << ":VT_BOOL:" << variant.bVal; break; - } - case VT_I2: + } + case VT_I2: { repr << ":VT_I2:" << variant.iVal; break; @@ -530,12 +531,12 @@ CString PPInterface::get_repr(COleVariant& variant) repr << ":VT_I8:" << variant.llVal; break; } - case VT_R4: + case VT_R4: { repr << ":VT_R4:" << variant.fltVal; break; } - case VT_R8: + case VT_R8: { repr << ":VT_R8:" << variant.dblVal; break; @@ -589,7 +590,6 @@ CString PPInterface::get_repr(COleVariant& variant) break; } } - + return CString ( repr.str(), repr.pcount() ); } - diff --git a/direct/src/plugin_activex/PPInterface.h b/direct/src/plugin_activex/PPInterface.h index 3b67afbd83..0e516532a7 100644 --- a/direct/src/plugin_activex/PPInterface.h +++ b/direct/src/plugin_activex/PPInterface.h @@ -1,16 +1,15 @@ -// Filename: PPInterface.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPInterface.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -36,7 +35,7 @@ public: HRESULT P3DGetProperty( P3D_object* p3dObject, CString& name, VARIANT FAR* varResult ); HRESULT P3DSetProperty( P3D_object* p3dObject, CString& name, DISPPARAMS FAR* pdispparams, bool& result ); - void p3dobj_to_variant(VARIANT* result, P3D_object* object); + void p3dobj_to_variant(VARIANT* result, P3D_object* object); P3D_object* variant_to_p3dobj(COleVariant* variant); CString get_repr(COleVariant& variant); diff --git a/direct/src/plugin_activex/PPLogger.cpp b/direct/src/plugin_activex/PPLogger.cpp index 5eb6a85a01..6dbfa01768 100644 --- a/direct/src/plugin_activex/PPLogger.cpp +++ b/direct/src/plugin_activex/PPLogger.cpp @@ -1,16 +1,15 @@ -// Filename: PPLogger.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPLogger.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" @@ -30,11 +29,11 @@ PPLogger::~PPLogger( ) { } -void PPLogger::Open( const std::string &rootDir ) +void PPLogger::Open( const std::string &rootDir ) { if (!m_isOpen) { - // Note that this logfile name may not be specified at runtime. It - // must be compiled in if it is specified at all. + // Note that this logfile name may not be specified at runtime. It must + // be compiled in if it is specified at all. std::string log_directory; // Allow the developer to compile in the log directory. @@ -43,8 +42,8 @@ void PPLogger::Open( const std::string &rootDir ) log_directory = P3D_PLUGIN_LOG_DIRECTORY; } #endif - - // Failing that, we write logfiles to Panda3D/log. + + // Failing that, we write logfiles to Panda3Dlog. if (log_directory.empty()) { log_directory = rootDir + "/log"; } @@ -57,9 +56,9 @@ void PPLogger::Open( const std::string &rootDir ) #endif log_directory += "/"; } - + // Construct the logfile pathname. - + std::string log_basename; #ifdef P3D_PLUGIN_LOG_BASENAME1 if (log_basename.empty()) { @@ -83,9 +82,8 @@ void PPLogger::Open( const std::string &rootDir ) m_logfile.setf(std::ios::unitbuf); } - // If we didn't have a logfile name compiled in, we throw away log - // output by the simple expedient of never actually opening the - // ofstream. + // If we didn't have a logfile name compiled in, we throw away log output + // by the simple expedient of never actually opening the ofstream. m_isOpen = true; } } diff --git a/direct/src/plugin_activex/PPLogger.h b/direct/src/plugin_activex/PPLogger.h index 79514872ac..2cc49de77a 100644 --- a/direct/src/plugin_activex/PPLogger.h +++ b/direct/src/plugin_activex/PPLogger.h @@ -1,16 +1,15 @@ -// Filename: PPLogger.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPLogger.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -35,4 +34,3 @@ protected: }; #define nout PPLogger::Log( ) - diff --git a/direct/src/plugin_activex/PPPandaObject.cpp b/direct/src/plugin_activex/PPPandaObject.cpp index 636870d60a..e65d6d7974 100644 --- a/direct/src/plugin_activex/PPPandaObject.cpp +++ b/direct/src/plugin_activex/PPPandaObject.cpp @@ -1,23 +1,22 @@ -// Filename: PPPandaObject.cpp -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPPandaObject.cpp + * @author atrestman + * @date 2009-09-14 + */ #include "stdafx.h" #include "PPPandaObject.h" #include "PPInstance.h" #include "load_plugin.h" -PPandaObject::PPandaObject( PPInterface* interfac, P3D_object* p3dObject ) : +PPandaObject::PPandaObject( PPInterface* interfac, P3D_object* p3dObject ) : m_interface( interfac ), m_p3dObject( p3dObject ), m_refs( 0 ), m_ptinfo( NULL ) { if ( m_p3dObject ) @@ -35,8 +34,8 @@ PPandaObject::~PPandaObject() m_ptinfo->Release(); } - // Clean up the p3d_object, but only if we haven't already - // unloaded the plugin. + // Clean up the p3d_object, but only if we haven't already unloaded the + // plugin. if ( m_p3dObject ) { P3D_OBJECT_DECREF( m_p3dObject ); @@ -67,9 +66,9 @@ STDMETHODIMP PPandaObject::QueryInterface(REFIID riid, void FAR* FAR* ppv) { if(!IsEqualIID(riid, IID_IUnknown)) { - if(!IsEqualIID(riid, IID_IDispatch)) + if(!IsEqualIID(riid, IID_IDispatch)) { - *ppv = NULL; + *ppv = NULL; return E_NOINTERFACE; } } @@ -141,7 +140,6 @@ STDMETHODIMP PPandaObject::GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo STDMETHODIMP PPandaObject::GetTypeInfoCount(unsigned int FAR* pctinfo) { // This object has a single *introduced* interface - // *pctinfo = 1; return NOERROR; @@ -170,7 +168,7 @@ STDMETHODIMP PPandaObject::Invoke( return E_FAIL; } - if ( dispidMember >= m_idsOfNames.size( ) ) + if ( dispidMember >= m_idsOfNames.size( ) ) { return E_FAIL; } @@ -182,9 +180,10 @@ STDMETHODIMP PPandaObject::Invoke( case ( DISPATCH_METHOD ): case ( DISPATCH_METHOD | DISPATCH_PROPERTYGET ): { - // NOTE: http://msdn.microsoft.com/en-us/library/ms221479.aspx - // The member is invoked as a method. If a property has the same name, - // both the DISPATCH_METHOD and the DISPATCH_PROPERTYGET flag may be set. + // NOTE: http:msdn.microsoft.comen-uslibraryms221479.aspx The + // member is invoked as a method. If a property has the same + // name, both the DISPATCH_METHOD and the DISPATCH_PROPERTYGET + // flag may be set. bool hasMethod( false ); hr = m_interface->P3DHasMethod( m_p3dObject, name, hasMethod ); diff --git a/direct/src/plugin_activex/PPPandaObject.h b/direct/src/plugin_activex/PPPandaObject.h index e2e767e570..ea64b83e16 100644 --- a/direct/src/plugin_activex/PPPandaObject.h +++ b/direct/src/plugin_activex/PPPandaObject.h @@ -1,16 +1,15 @@ -// Filename: PPPandaObject.h -// Created by: atrestman (14Sept09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PPPandaObject.h + * @author atrestman + * @date 2009-09-14 + */ #pragma once @@ -28,12 +27,12 @@ public: PPandaObject( PPInterface* interfac, P3D_object* p3dObject ); virtual ~PPandaObject(); - // IUnknown methods + // IUnknown methods STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj); STDMETHOD_(unsigned long, AddRef)(void); STDMETHOD_(unsigned long, Release)(void); - // IDispatch methods + // IDispatch methods STDMETHOD(GetTypeInfoCount)(unsigned int FAR* pcTypeInfo); STDMETHOD(GetTypeInfo)( @@ -60,7 +59,7 @@ public: private: PPandaObject(); - + // Props - Dispatch related unsigned long m_refs; ITypeInfo FAR* m_ptinfo; diff --git a/direct/src/plugin_npapi/nppanda3d_common.h b/direct/src/plugin_npapi/nppanda3d_common.h index 4affdc3884..512281ea3d 100644 --- a/direct/src/plugin_npapi/nppanda3d_common.h +++ b/direct/src/plugin_npapi/nppanda3d_common.h @@ -1,29 +1,28 @@ -// Filename: nppanda3d_common.h -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nppanda3d_common.h + * @author drose + * @date 2009-06-19 + */ #ifndef NPPANDA3D_COMMON #define NPPANDA3D_COMMON // This header file is included by all C++ files in this directory -// It's a good idea to pick up this header file, even though we don't -// actually link with dtool. This header file defines useful -// system-wide config settings. +// It's a good idea to pick up this header file, even though we don't actually +// link with dtool. This header file defines useful system-wide config +// settings. #include "dtool_config.h" -// We include this header file directly out of its source directory, -// so we don't have to link with the library that builds it. +// We include this header file directly out of its source directory, so we +// don't have to link with the library that builds it. #include "../plugin/p3d_plugin.h" #include @@ -50,8 +49,7 @@ extern bool has_plugin_thread_async_call; #define _USRDLL #define NPBASIC_EXPORTS -// Panda already defines this one. -//#define WIN32 +// Panda already defines this one. #define WIN32 #include @@ -77,44 +75,41 @@ extern bool has_plugin_thread_async_call; #if NP_VERSION_MAJOR == 0 && NP_VERSION_MINOR <= 19 #ifdef _WIN32 - // Also somewhere in there, they started defining and using - // int16_t instead of int16, and so on. They already had int32_t - // from earlier, but the typedef is not quite the same as int32 - // (!), so we have to use #define to keep things compatible. + // Also somewhere in there, they started defining and using int16_t + // instead of int16, and so on. They already had int32_t from earlier, + // but the typedef is not quite the same as int32 (!), so we have to use + // #define to keep things compatible. typedef int16 int16_t; typedef uint16 uint16_t; -// #define int32_t int32 -// #define uint32_t uint32 +// #define int32_t int32 #define uint32_t uint32 #endif // _WIN32 #endif // NP_VERSION #include "load_plugin.h" -// Mozilla's version of NPAPI has these names lowercase. WebKit's -// version has them uppercase. What a mess. We have to define a -// duplicate of the structure to allow us to reference them -// consistently. +// Mozilla's version of NPAPI has these names lowercase. WebKit's version has +// them uppercase. What a mess. We have to define a duplicate of the +// structure to allow us to reference them consistently. struct UC_NPString { const NPUTF8 *UTF8Characters; uint32_t UTF8Length; }; -// If we are building with a version of Gecko that supports the -// asynchronous callback function, we should use it--it's just so -// handy. +// If we are building with a version of Gecko that supports the asynchronous +// callback function, we should use it--it's just so handy. #if defined(NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) && NP_VERSION_MINOR >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL #define HAS_PLUGIN_THREAD_ASYNC_CALL 1 #endif -// We also need to know whether we have Apple's new Cocoa-based -// drawing and event callbacks. +// We also need to know whether we have Apple's new Cocoa-based drawing and +// event callbacks. #if defined(NPVERS_MACOSX_HAS_EVENT_MODELS) && NP_VERSION_MINOR >= NPVERS_MACOSX_HAS_EVENT_MODELS #define MACOSX_HAS_EVENT_MODELS 1 #endif -// No one defined a symbol for the introduction of the Cocoa drawing, -// but it appears to have been version 19. +// No one defined a symbol for the introduction of the Cocoa drawing, but it +// appears to have been version 19. #if NP_VERSION_MINOR >= 19 #define MACOSX_HAS_COREGRAPHICS_DRAWING_MODEL 1 #endif @@ -123,4 +118,3 @@ struct UC_NPString { extern NPNetscapeFuncs *browser; #endif - diff --git a/direct/src/plugin_npapi/ppBrowserObject.I b/direct/src/plugin_npapi/ppBrowserObject.I index 208450532b..431535af85 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.I +++ b/direct/src/plugin_npapi/ppBrowserObject.I @@ -1,14 +1,12 @@ -// Filename: ppBrowserObject.I -// Created by: drose (05Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppBrowserObject.I + * @author drose + * @date 2009-07-05 + */ diff --git a/direct/src/plugin_npapi/ppBrowserObject.cxx b/direct/src/plugin_npapi/ppBrowserObject.cxx index 850d2020c1..822f1f5657 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.cxx +++ b/direct/src/plugin_npapi/ppBrowserObject.cxx @@ -1,16 +1,15 @@ -// Filename: ppBrowserObject.cxx -// Created by: drose (05Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppBrowserObject.cxx + * @author drose + * @date 2009-07-05 + */ #include "ppBrowserObject.h" #include "ppInstance.h" @@ -18,15 +17,14 @@ #include // strncpy // The following functions are C-style wrappers around the above -// PPBrowserObject methods; they are defined to allow us to create the -// C-style P3D_class_definition method table to store in the -// P3D_object structure. +// PPBrowserObject methods; they are defined to allow us to create the C-style +// P3D_class_definition method table to store in the P3D_object structure. static void object_finish(P3D_object *object) { delete ((PPBrowserObject *)object); } -static int +static int object_get_repr(P3D_object *object, char *buffer, int buffer_length) { return ((const PPBrowserObject *)object)->get_repr(buffer, buffer_length); } @@ -43,7 +41,7 @@ object_set_property(P3D_object *object, const char *property, } static P3D_object * -object_call(P3D_object *object, const char *method_name, +object_call(P3D_object *object, const char *method_name, bool needs_response, P3D_object *params[], int num_params) { if (method_name == NULL) { @@ -51,8 +49,8 @@ object_call(P3D_object *object, const char *method_name, } P3D_object *response = ((const PPBrowserObject *)object)->call(method_name, params, num_params); if (!needs_response) { - // No response was expected. Throw away the response we received, - // so we can be consistent with defined semantics. + // No response was expected. Throw away the response we received, so we + // can be consistent with defined semantics. P3D_OBJECT_XDECREF(response); response = NULL; } @@ -66,11 +64,9 @@ object_eval(P3D_object *object, const char *expression) { P3D_class_definition *PPBrowserObject::_browser_object_class; -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPBrowserObject:: PPBrowserObject(PPInstance *inst, NPObject *npobj) : _instance(inst), @@ -81,11 +77,9 @@ PPBrowserObject(PPInstance *inst, NPObject *npobj) : browser->retainobject(_npobj); } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPBrowserObject:: PPBrowserObject(const PPBrowserObject ©) : _instance(copy._instance), @@ -96,23 +90,19 @@ PPBrowserObject(const PPBrowserObject ©) : browser->retainobject(_npobj); } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPBrowserObject:: ~PPBrowserObject() { assert(_ref_count == 0); browser->releaseobject(_npobj); } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::get_repr -// Access: Public -// Description: Returns a user-friendly representation of the object, -// similar to get_string(), above. -//////////////////////////////////////////////////////////////////// +/** + * Returns a user-friendly representation of the object, similar to + * get_string(), above. + */ int PPBrowserObject:: get_repr(char *buffer, int buffer_length) const { ostringstream strm; @@ -122,13 +112,11 @@ get_repr(char *buffer, int buffer_length) const { return (int)result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::get_property -// Access: Public -// Description: Returns the named property element in the object. The -// return value is a freshly-allocated PPBrowserObject object -// that must be deleted by the caller, or NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named property element in the object. The return value is a + * freshly-allocated PPBrowserObject object that must be deleted by the + * caller, or NULL on error. + */ P3D_object *PPBrowserObject:: get_property(const string &property) const { NPIdentifier property_name = browser->getstringidentifier(property.c_str()); @@ -150,13 +138,10 @@ get_property(const string &property) const { return object; } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::set_property -// Access: Public -// Description: Modifies (or deletes, if value is NULL) the named -// property element in the object. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Modifies (or deletes, if value is NULL) the named property element in the + * object. Returns true on success, false on failure. + */ bool PPBrowserObject:: set_property(const string &property, bool needs_response, P3D_object *value) { NPIdentifier property_name = browser->getstringidentifier(property.c_str()); @@ -178,14 +163,11 @@ set_property(const string &property, bool needs_response, P3D_object *value) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::call -// Access: Public -// Description: Invokes the named method on the object, passing the -// indicated parameters. If the method name is empty, -// invokes the object itself. Returns the return value -// on success, NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Invokes the named method on the object, passing the indicated parameters. + * If the method name is empty, invokes the object itself. Returns the return + * value on success, NULL on error. + */ P3D_object *PPBrowserObject:: call(const string &method_name, P3D_object *params[], int num_params) const { // First, convert all of the parameters. @@ -222,12 +204,9 @@ call(const string &method_name, P3D_object *params[], int num_params) const { return object; } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::eval -// Access: Public -// Description: Evaluates the indicated JavaScript expression in the -// context of the object. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the indicated JavaScript expression in the context of the object. + */ P3D_object *PPBrowserObject:: eval(const string &expression) const { NPString npexpr = { expression.c_str(), (uint32_t)expression.length() }; @@ -244,30 +223,24 @@ eval(const string &expression) const { return object; } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::clear_class_definition -// Access: Public, Static -// Description: Should be called when the core API is unloaded, and -// the associated class definition object is therefore -// invalidated. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the core API is unloaded, and the associated class + * definition object is therefore invalidated. + */ void PPBrowserObject:: clear_class_definition() { _browser_object_class = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PPBrowserObject::get_class_definition -// Access: Private, Static -// Description: Returns a pointer to the P3D_class_definition object -// that lists all of the C-style method pointers for -// this class object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the P3D_class_definition object that lists all of the + * C-style method pointers for this class object. + */ P3D_class_definition *PPBrowserObject:: get_class_definition() { if (_browser_object_class == NULL) { - // Create a default class_definition object, and fill in the - // appropriate pointers. + // Create a default class_definition object, and fill in the appropriate + // pointers. _browser_object_class = P3D_make_class_definition_ptr(); _browser_object_class->_finish = &object_finish; diff --git a/direct/src/plugin_npapi/ppBrowserObject.h b/direct/src/plugin_npapi/ppBrowserObject.h index ec87317204..8274ea8f34 100644 --- a/direct/src/plugin_npapi/ppBrowserObject.h +++ b/direct/src/plugin_npapi/ppBrowserObject.h @@ -1,16 +1,15 @@ -// Filename: ppBrowserObject.h -// Created by: drose (05Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppBrowserObject.h + * @author drose + * @date 2009-07-05 + */ #ifndef PPBROWSEROBJECT_H #define PPBROWSEROBJECT_H @@ -19,16 +18,13 @@ class PPInstance; -//////////////////////////////////////////////////////////////////// -// Class : PPBrowserObject -// Description : This is the interface layer between an NPObject and a -// P3D_object. It maps calls from P3D_object into the -// NPObject system, thus allowing Panda to view and -// operate on a browser object. -// -// Also see PPPandaObject, which maps calls the other -// way. -//////////////////////////////////////////////////////////////////// +/** + * This is the interface layer between an NPObject and a P3D_object. It maps + * calls from P3D_object into the NPObject system, thus allowing Panda to view + * and operate on a browser object. + * + * Also see PPPandaObject, which maps calls the other way. + */ class PPBrowserObject : public P3D_object { public: PPBrowserObject(PPInstance *inst, NPObject *npobj); @@ -40,7 +36,7 @@ public: bool set_property(const string &property, bool needs_response, P3D_object *value); - P3D_object *call(const string &method_name, + P3D_object *call(const string &method_name, P3D_object *params[], int num_params) const; P3D_object *eval(const string &expression) const; @@ -58,4 +54,3 @@ private: #include "ppBrowserObject.I" #endif - diff --git a/direct/src/plugin_npapi/ppDownloadRequest.I b/direct/src/plugin_npapi/ppDownloadRequest.I index 2ac0da3b5c..d0610db522 100644 --- a/direct/src/plugin_npapi/ppDownloadRequest.I +++ b/direct/src/plugin_npapi/ppDownloadRequest.I @@ -1,23 +1,19 @@ -// Filename: ppDownloadRequest.I -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppDownloadRequest.I + * @author drose + * @date 2009-06-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PPDownloadRequest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline PPDownloadRequest:: PPDownloadRequest(RequestType rtype, int user_id) : _rtype(rtype), @@ -25,4 +21,3 @@ PPDownloadRequest(RequestType rtype, int user_id) : _notified_done(false) { } - diff --git a/direct/src/plugin_npapi/ppDownloadRequest.cxx b/direct/src/plugin_npapi/ppDownloadRequest.cxx index 8b64e4fd62..81e0605c27 100644 --- a/direct/src/plugin_npapi/ppDownloadRequest.cxx +++ b/direct/src/plugin_npapi/ppDownloadRequest.cxx @@ -1,16 +1,14 @@ -// Filename: ppDownloadRequest.cxx -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppDownloadRequest.cxx + * @author drose + * @date 2009-06-23 + */ #include "ppDownloadRequest.h" - diff --git a/direct/src/plugin_npapi/ppDownloadRequest.h b/direct/src/plugin_npapi/ppDownloadRequest.h index ee2fb1f515..55fe0f60fa 100644 --- a/direct/src/plugin_npapi/ppDownloadRequest.h +++ b/direct/src/plugin_npapi/ppDownloadRequest.h @@ -1,28 +1,25 @@ -// Filename: ppDownloadRequest.h -// Created by: drose (23Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppDownloadRequest.h + * @author drose + * @date 2009-06-23 + */ #ifndef PPDOWNLOADREQUEST_H #define PPDOWNLOADREQUEST_H #include "nppanda3d_common.h" -//////////////////////////////////////////////////////////////////// -// Class : PPDownloadRequest -// Description : An instance of this object is assigned as the -// notifyData for URL requests, to help the plugin -// associate streams with requests. -//////////////////////////////////////////////////////////////////// +/** + * An instance of this object is assigned as the notifyData for URL requests, + * to help the plugin associate streams with requests. + */ class PPDownloadRequest { public: enum RequestType { @@ -38,12 +35,11 @@ public: RequestType _rtype; int _user_id; - // This is sent true when we have notified the plugin that the - // stream is done. + // This is sent true when we have notified the plugin that the stream is + // done. bool _notified_done; }; #include "ppDownloadRequest.I" #endif - diff --git a/direct/src/plugin_npapi/ppInstance.I b/direct/src/plugin_npapi/ppInstance.I index e94a2c48c3..122b396912 100644 --- a/direct/src/plugin_npapi/ppInstance.I +++ b/direct/src/plugin_npapi/ppInstance.I @@ -1,34 +1,27 @@ -// Filename: ppInstance.I -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppInstance.I + * @author drose + * @date 2009-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::get_npp_instance -// Access: Public -// Description: Returns the NPP object corresponding to this -// particular instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NPP object corresponding to this particular instance. + */ inline NPP PPInstance:: get_npp_instance() const { return _npp_instance; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::get_window -// Access: Public -// Description: Returns the current window parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current window parameters. + */ const NPWindow *PPInstance:: get_window() const { if (_got_window) { diff --git a/direct/src/plugin_npapi/ppInstance.cxx b/direct/src/plugin_npapi/ppInstance.cxx index 209204652d..47aa5b3cd0 100644 --- a/direct/src/plugin_npapi/ppInstance.cxx +++ b/direct/src/plugin_npapi/ppInstance.cxx @@ -1,16 +1,15 @@ -// Filename: ppInstance.cxx -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppInstance.cxx + * @author drose + * @date 2009-06-19 + */ #include "ppInstance.h" #include "ppPandaObject.h" @@ -22,8 +21,8 @@ #include "parse_color.h" #include "nppanda3d_common.h" -// We can include this header file to get the DTOOL_PLATFORM -// definition, even though we don't link with dtool. +// We can include this header file to get the DTOOL_PLATFORM definition, even +// though we don't link with dtool. #include "dtool_platform.h" #include "pandaVersion.h" @@ -45,16 +44,13 @@ PPInstance::FileDatas PPInstance::_file_datas; -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::Constructor -// Access: Public -// Description: Creates a new instance of a Panda3D plugin window. -// The create_data structure is supplied from NPAPI, and -// defines the initial parameters specified in the HTML -// document. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new instance of a Panda3D plugin window. The create_data + * structure is supplied from NPAPI, and defines the initial parameters + * specified in the HTML document. + */ PPInstance:: -PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, +PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved, P3D_window_handle_type window_handle_type, P3D_event_type event_type) { @@ -79,8 +75,8 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, v = ""; } - // Make the token lowercase, since HTML is case-insensitive but - // we're not. + // Make the token lowercase, since HTML is case-insensitive but we're + // not. string keyword; for (const char *p = argn[i]; *p; ++p) { keyword += tolower(*p); @@ -98,8 +94,8 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, _got_instance_url = false; _p3d_instance_id = 0; - // fgcolor and bgcolor are useful to know here (in case we have to - // draw a twirling icon). + // fgcolor and bgcolor are useful to know here (in case we have to draw a + // twirling icon). // The default bgcolor is white. _bgcolor_r = _bgcolor_g = _bgcolor_b = 0xff; @@ -112,8 +108,8 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, } } - // The default fgcolor is either black or white, according to the - // brightness of the bgcolor. + // The default fgcolor is either black or white, according to the brightness + // of the bgcolor. if (_bgcolor_r + _bgcolor_g + _bgcolor_b > 0x80 + 0x80 + 0x80) { _fgcolor_r = _fgcolor_g = _fgcolor_b = 0x00; } else { @@ -144,9 +140,9 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, #endif // _WIN32 #ifndef _WIN32 - // Save the startup time to improve precision of gettimeofday(). We - // also use this to measure elapsed time from the window parameters - // having been received. + // Save the startup time to improve precision of gettimeofday(). We also + // use this to measure elapsed time from the window parameters having been + // received. struct timeval tv; gettimeofday(&tv, (struct timezone *)NULL); _init_sec = tv.tv_sec; @@ -154,9 +150,9 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, #endif // !_WIN32 #ifdef __APPLE__ - // Get the run loop in the browser thread. (CFRunLoopGetMain() is - // only 10.5 or higher. Plus, the browser thread is not necessarily - // the "main" thread.) + // Get the run loop in the browser thread. (CFRunLoopGetMain() is only 10.5 + // or higher. Plus, the browser thread is not necessarily the "main" + // thread.) _run_loop_main = CFRunLoopGetCurrent(); CFRetain(_run_loop_main); _request_timer = NULL; @@ -177,11 +173,9 @@ PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, #endif // MACOSX_HAS_EVENT_MODELS } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPInstance:: ~PPInstance() { cleanup_window(); @@ -227,31 +221,26 @@ PPInstance:: _tokens.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::begin -// Access: Public -// Description: Begins the initial download of the core API. This -// should be called after constructing the PPInstance. -// It is a separate method than the constructor, because -// it initiates some callbacks that might rely on the -// object having been fully constructed and its pointer -// stored. -//////////////////////////////////////////////////////////////////// +/** + * Begins the initial download of the core API. This should be called after + * constructing the PPInstance. It is a separate method than the constructor, + * because it initiates some callbacks that might rely on the object having + * been fully constructed and its pointer stored. + */ void PPInstance:: begin() { - // On Windows and Linux, we must insist on having this call. OSX - // doesn't necessarily require it (which is lucky, since it appears - // that Safari doesn't necessarily provide it!) + // On Windows and Linux, we must insist on having this call. OSX doesn't + // necessarily require it (which is lucky, since it appears that Safari + // doesn't necessarily provide it!) #ifndef __APPLE__ if (!has_plugin_thread_async_call) { nout << "Browser version insufficient: we require at least NPAPI version 0.19.\n"; set_failed(); } #else - // While Safari 5 on Mac claims to provide this function, it doesn't - // appear to work. (!) So we pretend we never have it on Mac. - // Fortunately, this hack does us no harm because the _request_timer - // hack works fine on OSX. + // While Safari 5 on Mac claims to provide this function, it doesn't appear + // to work. (!) So we pretend we never have it on Mac. Fortunately, this + // hack does us no harm because the _request_timer hack works fine on OSX. has_plugin_thread_async_call = false; #endif // __APPLE__ @@ -264,8 +253,8 @@ begin() { nout << "Plugin is built with " << PANDA_PACKAGE_HOST_URL << "\n"; if (!is_plugin_loaded() && !_failed) { - // We need to read the contents.xml file. First, check to see if - // the version on disk is already current enough. + // We need to read the contents.xml file. First, check to see if the + // version on disk is already current enough. bool success = false; string contents_filename = _root_dir + "/contents.xml"; @@ -283,13 +272,13 @@ begin() { _mirrors.clear(); ostringstream strm; strm << _download_url_prefix << "contents.xml"; - - // Append a uniquifying query string to the URL to force the - // download to go all the way through any caches. We use the time - // in seconds; that's unique enough. + + // Append a uniquifying query string to the URL to force the download to + // go all the way through any caches. We use the time in seconds; + // that's unique enough. strm << "?" << time(NULL); url = strm.str(); - + PPDownloadRequest *req = new PPDownloadRequest(PPDownloadRequest::RT_contents_file); start_download(url, req); } @@ -298,14 +287,12 @@ begin() { handle_request_loop(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::set_window -// Access: Public -// Description: Stores or updates the window parameters. -//////////////////////////////////////////////////////////////////// +/** + * Stores or updates the window parameters. + */ void PPInstance:: set_window(NPWindow *window) { - if (_got_window && + if (_got_window && window->x == _window.x && window->y == _window.y && window->width == _window.width && @@ -315,8 +302,7 @@ set_window(NPWindow *window) { } if (_got_window) { - // We don't expect the browser to change the window's parent - // on-the-fly. + // We don't expect the browser to change the window's parent on-the-fly. assert(_window.window == window->window); } @@ -327,23 +313,22 @@ set_window(NPWindow *window) { // Save the window handle. _hwnd = (HWND)window->window; - // Now that we've got a window handle, we can go get the - // twirling icon images. + // Now that we've got a window handle, we can go get the twirling icon + // images. win_get_twirl_bitmaps(); _bg_brush = CreateSolidBrush(RGB(_bgcolor_r, _bgcolor_g, _bgcolor_b)); - // Subclass the window to make it call our own window_proc - // instead of whatever window_proc it has already. This is - // mainly just a dopey trick to allow us to poll events in the - // main thread, but we also rely on this to paint the twirling - // icon into the browser window. + // Subclass the window to make it call our own window_proc instead of + // whatever window_proc it has already. This is mainly just a dopey + // trick to allow us to poll events in the main thread, but we also rely + // on this to paint the twirling icon into the browser window. SetWindowLongPtr(_hwnd, GWLP_USERDATA, (LONG_PTR)this); _orig_window_proc = SetWindowLongPtr(_hwnd, GWLP_WNDPROC, (LONG_PTR)st_window_proc); - // Also set a timer to go off every once in a while, to update - // the twirling icon, and also to catch events in case something - // slips through. + // Also set a timer to go off every once in a while, to update the + // twirling icon, and also to catch events in case something slips + // through. _init_time = GetTickCount(); SetTimer(_hwnd, 1, 100, NULL); } @@ -365,7 +350,7 @@ set_window(NPWindow *window) { // Create a new GtkPlug to bind to the XEmbed socket. _plug = gtk_plug_new((GdkNativeWindow) reinterpret_cast(window->window)); gtk_widget_show(_plug); - + nout << "original XID is " << window->window << ", created X11 window " << GDK_DRAWABLE_XID(_plug->window) << "\n"; } @@ -390,12 +375,9 @@ set_window(NPWindow *window) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::new_stream -// Access: Public -// Description: Receives notification of a new stream object, e.g. a -// url request. -//////////////////////////////////////////////////////////////////// +/** + * Receives notification of a new stream object, e.g. a url request. + */ NPError PPInstance:: new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { assert(find(_streams.begin(), _streams.end(), stream) == _streams.end()); @@ -404,9 +386,8 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { } if (stream->notifyData == NULL) { - // This is an unsolicited stream. Assume the first unsolicited - // stream we receive is the instance data; any other unsolicited - // stream is an error. + // This is an unsolicited stream. Assume the first unsolicited stream we + // receive is the instance data; any other unsolicited stream is an error. if (!_got_instance_url && stream->url != NULL) { _got_instance_url = true; @@ -414,13 +395,13 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { stream->notifyData = new PPDownloadRequest(PPDownloadRequest::RT_instance_data); if (_p3d_inst != NULL) { - // If we already have an instance by the time we get this - // stream, start sending the data to the instance (instead of - // having to mess around with a temporary file). + // If we already have an instance by the time we get this stream, + // start sending the data to the instance (instead of having to mess + // around with a temporary file). _p3d_instance_id = P3D_instance_start_stream_ptr(_p3d_inst, _instance_url.c_str()); nout << "p3d instance to stream " << _p3d_instance_id << "\n"; } - + *stype = NP_NORMAL; _streams.push_back(stream); return NPERR_NO_ERROR; @@ -433,23 +414,22 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { PPDownloadRequest *req = (PPDownloadRequest *)(stream->notifyData); switch (req->_rtype) { case PPDownloadRequest::RT_contents_file: - // This is the initial contents.xml file. We used to download - // this via NP_ASFILEONLY, but that option doesn't work on Windows - // within a Unicode user directory. So we use NP_NORMAL instead. + // This is the initial contents.xml file. We used to download this via + // NP_ASFILEONLY, but that option doesn't work on Windows within a Unicode + // user directory. So we use NP_NORMAL instead. *stype = NP_NORMAL; _streams.push_back(stream); return NPERR_NO_ERROR; case PPDownloadRequest::RT_core_dll: - // This is the core API DLL (or dylib or whatever). Again, we - // have to use NP_NORMAL. + // This is the core API DLL (or dylib or whatever). Again, we have to use + // NP_NORMAL. *stype = NP_NORMAL; _streams.push_back(stream); return NPERR_NO_ERROR; case PPDownloadRequest::RT_user: - // This is a request from the plugin. We'll receive this as a - // stream. + // This is a request from the plugin. We'll receive this as a stream. *stype = NP_NORMAL; _streams.push_back(stream); return NPERR_NO_ERROR; @@ -463,14 +443,11 @@ new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype) { } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::stop_outstanding_streams -// Access: Public -// Description: Stops any download streams that are currently active -// on the instance. It is necessary to call this -// explicitly before destroying the instance, at least -// for Safari. -//////////////////////////////////////////////////////////////////// +/** + * Stops any download streams that are currently active on the instance. It + * is necessary to call this explicitly before destroying the instance, at + * least for Safari. + */ void PPInstance:: stop_outstanding_streams() { Streams::iterator si; @@ -485,8 +462,8 @@ stop_outstanding_streams() { assert(_streams.empty()); - // Also stop any currently pending _file_datas; these are - // locally-implemented streams. + // Also stop any currently pending _file_datas; these are locally- + // implemented streams. FileDatas::iterator fi; for (fi = _file_datas.begin(); fi != _file_datas.end(); ++fi) { delete (*fi); @@ -494,26 +471,21 @@ stop_outstanding_streams() { _file_datas.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::write_ready -// Access: Public -// Description: Called by the browser to ask how much data is ready -// to be received for the indicated stream. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to ask how much data is ready to be received for the + * indicated stream. + */ int32_t PPInstance:: write_ready(NPStream *stream) { // We're supposed to return the maximum amount of data the plugin is - // prepared to handle. Gee, I don't know. As much as you can give - // me, I guess. + // prepared to handle. Gee, I don't know. As much as you can give me, I + // guess. return 0x7fffffff; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::write_stream -// Access: Public -// Description: Called by the browser to feed data read from a URL or -// whatever. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to feed data read from a URL or whatever. + */ int PPInstance:: write_stream(NPStream *stream, int offset, int len, void *buffer) { if (stream->notifyData == NULL) { @@ -537,22 +509,20 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { return len; case PPDownloadRequest::RT_instance_data: - // There's a special case for the RT_instance_data stream. This - // is the first, unsolicited stream that indicates the p3d - // instance data. We have to send this stream into the instance, - // but we can only do this once the instance itself has been - // created. + // There's a special case for the RT_instance_data stream. This is the + // first, unsolicited stream that indicates the p3d instance data. We + // have to send this stream into the instance, but we can only do this + // once the instance itself has been created. - // We used to get away with returning 0 in write_ready until the - // instance was ready, but that turns out to fail under Safari - // Snow Leopard, which it seems will hold up every other download - // until the p3d file has been retrieved. Sigh. So we must start - // accepting the data even before the instance has been created, - // or we'll never get our contents.xml or any other important bits - // of data. + // We used to get away with returning 0 in write_ready until the instance + // was ready, but that turns out to fail under Safari Snow Leopard, which + // it seems will hold up every other download until the p3d file has been + // retrieved. Sigh. So we must start accepting the data even before the + // instance has been created, or we'll never get our contents.xml or any + // other important bits of data. - // Nowadays we solve this problem by writing the data to a - // temporary file until the instance is ready for it. + // Nowadays we solve this problem by writing the data to a temporary file + // until the instance is ready for it. if (_p3d_inst == NULL) { // The instance isn't ready, so stuff it in a temporary file. if (!_p3d_temp_file.feed(stream->end, buffer, len)) { @@ -584,7 +554,7 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { set_failed(); } return len; - + default: nout << "Unexpected write_stream on " << stream->url << "\n"; break; @@ -594,13 +564,10 @@ write_stream(NPStream *stream, int offset, int len, void *buffer) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::destroy_stream -// Access: Public -// Description: Called by the browser to mark the end of a stream; -// the file has either been successfully downloaded or -// failed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to mark the end of a stream; the file has either been + * successfully downloaded or failed. + */ NPError PPInstance:: destroy_stream(NPStream *stream, NPReason reason) { Streams::iterator si = find(_streams.begin(), _streams.end(), stream); @@ -636,16 +603,16 @@ destroy_stream(NPStream *stream, NPReason reason) { case PPDownloadRequest::RT_instance_data: if (!req->_notified_done) { if (_p3d_inst == NULL) { - // The instance still isn't ready; just mark the data done. - // We'll send the entire file to the instance when it is ready. + // The instance still isn't ready; just mark the data done. We'll + // send the entire file to the instance when it is ready. _p3d_temp_file.finish(); if (result_code != P3D_RC_done) { set_failed(); } - + } else { - // The instance has (only just) been created. Tell it we've - // sent it all the data it will get. + // The instance has (only just) been created. Tell it we've sent it + // all the data it will get. P3D_instance_feed_url_stream_ptr(_p3d_inst, _p3d_instance_id, result_code, 0, stream->end, NULL, 0); } @@ -681,20 +648,17 @@ destroy_stream(NPStream *stream, NPReason reason) { return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::url_notify -// Access: Public -// Description: Called by the browser to announce the end of a -// stream. This normally follows destroy_stream(), -// unless the stream was never created in the first -// place. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to announce the end of a stream. This normally + * follows destroy_stream(), unless the stream was never created in the first + * place. + */ void PPInstance:: url_notify(const char *url, NPReason reason, void *notifyData) { if (notifyData == NULL) { return; } - + PPDownloadRequest *req = (PPDownloadRequest *)notifyData; if (_failed) { // We're done; ignore this. @@ -705,9 +669,8 @@ url_notify(const char *url, NPReason reason, void *notifyData) { switch (req->_rtype) { case PPDownloadRequest::RT_user: if (!req->_notified_done) { - // We shouldn't have gotten here without notifying the stream - // unless the stream never got started (and hence we never - // called destroy_stream(). + // We shouldn't have gotten here without notifying the stream unless the + // stream never got started (and hence we never called destroy_stream(). nout << "Failure starting stream\n"; assert(reason != NPRES_DONE); @@ -726,9 +689,9 @@ url_notify(const char *url, NPReason reason, void *notifyData) { if (reason == NPRES_USER_BREAK) { nout << "Failure due to user break\n"; } else { - // Couldn't download a fresh contents.xml for some reason. If - // there's an outstanding contents.xml file on disk, try to - // load that one as a fallback. + // Couldn't download a fresh contents.xml for some reason. If there's + // an outstanding contents.xml file on disk, try to load that one as a + // fallback. string contents_filename = _root_dir + "/contents.xml"; if (read_contents_file(contents_filename, false)) { get_core_api(); @@ -739,7 +702,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { } } break; - + case PPDownloadRequest::RT_core_dll: if (reason == NPRES_DONE) { downloaded_plugin(_core_dll_temp_file._filename); @@ -754,7 +717,7 @@ url_notify(const char *url, NPReason reason, void *notifyData) { if (!_core_urls.empty()) { string url = _core_urls.back(); _core_urls.pop_back(); - + PPDownloadRequest *req2 = new PPDownloadRequest(PPDownloadRequest::RT_core_dll); start_download(url, req2); } @@ -766,16 +729,14 @@ url_notify(const char *url, NPReason reason, void *notifyData) { nout << "Unexpected url_notify on stream type " << req->_rtype << "\n"; break; } - + delete req; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::stream_as_file -// Access: Public -// Description: Called by the browser to report the filename that -// contains the fully-downloaded stream contents. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to report the filename that contains the fully- + * downloaded stream contents. + */ void PPInstance:: stream_as_file(NPStream *stream, const char *fname) { if (stream->notifyData == NULL) { @@ -787,7 +748,7 @@ stream_as_file(NPStream *stream, const char *fname) { #ifdef __APPLE__ // Safari seems to want to report the filename in the old-style form // "Macintosh HD:blah:blah:blah" instead of the new-style form - // "/blah/blah/blah". How annoying. + // "blahblahblah". How annoying. size_t colon = filename.find(':'); size_t slash = filename.find('/'); @@ -807,43 +768,38 @@ stream_as_file(NPStream *stream, const char *fname) { // Looks like we've converted it successfully. filename = fname2; - // Here's another crazy hack. In addition to the weird filename - // format, the file that Safari tells us about appears to be a - // temporary file that Safari's about to delete. In order to - // protect ourselves from this, we need to temporarily copy the - // file somewhere else. + // Here's another crazy hack. In addition to the weird filename format, + // the file that Safari tells us about appears to be a temporary file + // that Safari's about to delete. In order to protect ourselves from + // this, we need to temporarily copy the file somewhere else. char *name = tempnam(NULL, "p3d_"); // We prefer just making a hard link; it's quick and easy. if (link(filename.c_str(), name) != 0) { - // But sometimes the hard link might fail, particularly if these - // are two different file systems. In this case we have to open - // the files and copy the data by hand. + // But sometimes the hard link might fail, particularly if these are + // two different file systems. In this case we have to open the files + // and copy the data by hand. copy_file(filename, name); } - + filename = name; free(name); - + // TODO: remove this temporary file when we're done with it. } } - + #endif // __APPLE__ PPDownloadRequest *req = (PPDownloadRequest *)(stream->notifyData); downloaded_file(req, filename); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::handle_request -// Access: Public -// Description: Handles a request from the Core API or the -// application, forwarding it to the browser as -// appropriate. Returns true if we should continue the -// request loop, or false to return (temporarily) to -// JavaScript. -//////////////////////////////////////////////////////////////////// +/** + * Handles a request from the Core API or the application, forwarding it to + * the browser as appropriate. Returns true if we should continue the request + * loop, or false to return (temporarily) to JavaScript. + */ bool PPInstance:: handle_request(P3D_request *request) { if (_p3d_inst == NULL || _failed) { @@ -866,17 +822,17 @@ handle_request(P3D_request *request) { case P3D_RT_get_url: { - PPDownloadRequest *req = - new PPDownloadRequest(PPDownloadRequest::RT_user, + PPDownloadRequest *req = + new PPDownloadRequest(PPDownloadRequest::RT_user, request->_request._get_url._unique_id); start_download(request->_request._get_url._url, req); } break; case P3D_RT_notify: - // We mostly ignore notifies, since these are handled by the core - // API. But we do check for the "onwindowopen" notify, at which - // point we start spamming the refresh requests. + // We mostly ignore notifies, since these are handled by the core API. + // But we do check for the "onwindowopen" notify, at which point we start + // spamming the refresh requests. if (strcmp(request->_request._notify._message, "onwindowopen") == 0) { _python_window_open = true; if (_got_window) { @@ -908,34 +864,27 @@ handle_request(P3D_request *request) { return continue_loop; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::generic_browser_call -// Access: Public, Static -// Description: This method is called from strategically-chosen -// browser callback functions. Its purpose is to -// provide another hook into the main thread callback, -// particularly if the PluginAsyncCall function isn't -// available. -//////////////////////////////////////////////////////////////////// +/** + * This method is called from strategically-chosen browser callback functions. + * Its purpose is to provide another hook into the main thread callback, + * particularly if the PluginAsyncCall function isn't available. + */ void PPInstance:: generic_browser_call() { /* if (!has_plugin_thread_async_call) { // If we can't ask Mozilla to call us back using - // NPN_PluginThreadAsyncCall(), then we'll do it explicitly now, - // since we know we're in the main thread here. + // NPN_PluginThreadAsyncCall(), then we'll do it explicitly now, since we + // know we're in the main thread here. handle_request_loop(); } */ } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::handle_event -// Access: Public -// Description: Called by the browser as new window events are -// generated. Returns true if the event is handled, -// false if ignored. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser as new window events are generated. Returns true if + * the event is handled, false if ignored. + */ bool PPInstance:: handle_event(void *event) { bool retval = false; @@ -951,8 +900,8 @@ handle_event(void *event) { #ifdef MACOSX_HAS_EVENT_MODELS } else if (_event_type == P3D_ET_osx_cocoa) { - // Copy the NPCocoaEvent structure componentwise into a - // P3DCocoaEvent structure. + // Copy the NPCocoaEvent structure componentwise into a P3DCocoaEvent + // structure. NPCocoaEvent *np_event = (NPCocoaEvent *)event; P3DCocoaEvent *p3d_event = &edata._event._osx_cocoa._event; copy_cocoa_event(p3d_event, np_event, aux_data); @@ -971,12 +920,10 @@ handle_event(void *event) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::get_panda_script_object -// Access: Public -// Description: Returns a toplevel object that JavaScript or whatever -// can read and/or modify to control the instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a toplevel object that JavaScript or whatever can read and/or + * modify to control the instance. + */ NPObject *PPInstance:: get_panda_script_object() { if (_script_object != NULL) { @@ -999,26 +946,20 @@ get_panda_script_object() { return _script_object; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::set_xembed -// Access: Public -// Description: Sets the use_xembed flag, telling the instance what -// kind of window object to expect from NPAPI. If this -// is true, the window object is an XID following the -// XEmbed specification; if false, it is a normal window -// handle. -//////////////////////////////////////////////////////////////////// +/** + * Sets the use_xembed flag, telling the instance what kind of window object + * to expect from NPAPI. If this is true, the window object is an XID + * following the XEmbed specification; if false, it is a normal window handle. + */ void PPInstance:: set_xembed(bool use_xembed) { _use_xembed = use_xembed; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::p3dobj_to_variant -// Access: Public -// Description: Converts the indicated P3D_object to the equivalent -// NPVariant, and stores it in result. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated P3D_object to the equivalent NPVariant, and stores + * it in result. + */ void PPInstance:: p3dobj_to_variant(NPVariant *result, P3D_object *object) { switch (P3D_OBJECT_GET_TYPE(object)) { @@ -1060,14 +1001,11 @@ p3dobj_to_variant(NPVariant *result, P3D_object *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::variant_to_p3dobj -// Access: Public -// Description: Converts the indicated NPVariant to the equivalent -// P3D_object, and returns it (newly-allocated). The -// caller is responsible for freeing the returned object -// later. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated NPVariant to the equivalent P3D_object, and returns + * it (newly-allocated). The caller is responsible for freeing the returned + * object later. + */ P3D_object *PPInstance:: variant_to_p3dobj(const NPVariant *variant) { if (NPVARIANT_IS_VOID(*variant)) { @@ -1101,11 +1039,9 @@ variant_to_p3dobj(const NPVariant *variant) { return P3D_new_none_object_ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::output_np_variant -// Access: Public -// Description: Outputs the variant value. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the variant value. + */ void PPInstance:: output_np_variant(ostream &out, const NPVariant &result) { if (NPVARIANT_IS_NULL(result)) { @@ -1128,12 +1064,9 @@ output_np_variant(ostream &out, const NPVariant &result) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::find_host -// Access: Private -// Description: Scans the element for the matching -// element. -//////////////////////////////////////////////////////////////////// +/** + * Scans the element for the matching element. + */ void PPInstance:: find_host(TiXmlElement *xcontents) { string host_url = PANDA_PACKAGE_HOST_URL; @@ -1144,7 +1077,7 @@ find_host(TiXmlElement *xcontents) { // We're the primary host. This is the normal case. read_xhost(xhost); return; - + } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); @@ -1159,22 +1092,20 @@ find_host(TiXmlElement *xcontents) { } } - // Hmm, didn't find the URL we used mentioned. Assume we're the - // primary host. + // Hmm, didn't find the URL we used mentioned. Assume we're the primary + // host. read_xhost(xhost); } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::read_xhost -// Access: Private -// Description: Reads the host data from the (or ) -// entry in the contents.xml file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the host data from the (or ) entry in the + * contents.xml file. + */ void PPInstance:: read_xhost(TiXmlElement *xhost) { - // Get the "download" URL, which is the source from which we - // download everything other than the contents.xml file. + // Get the "download" URL, which is the source from which we download + // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); if (download_url != NULL) { _download_url_prefix = download_url; @@ -1186,7 +1117,7 @@ read_xhost(TiXmlElement *xhost) { _download_url_prefix += "/"; } } - + TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); while (xmirror != NULL) { const char *url = xmirror->Attribute("url"); @@ -1197,35 +1128,28 @@ read_xhost(TiXmlElement *xhost) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::add_mirror -// Access: Private -// Description: Adds a new URL to serve as a mirror for this host. -// The mirrors will be consulted first, before -// consulting the host directly. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new URL to serve as a mirror for this host. The mirrors will be + * consulted first, before consulting the host directly. + */ void PPInstance:: add_mirror(string mirror_url) { // Ensure the URL ends in a slash. if (!mirror_url.empty() && mirror_url[mirror_url.size() - 1] != '/') { mirror_url += '/'; } - - // Add it to the _mirrors list, but only if it's not already - // there. + + // Add it to the _mirrors list, but only if it's not already there. if (find(_mirrors.begin(), _mirrors.end(), mirror_url) == _mirrors.end()) { _mirrors.push_back(mirror_url); } } - -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::choose_random_mirrors -// Access: Public -// Description: Selects num_mirrors elements, chosen at random, from -// the _mirrors list. Adds the selected mirrors to -// result. If there are fewer than num_mirrors elements -// in the list, adds only as many mirrors as we can get. -//////////////////////////////////////////////////////////////////// + +/** + * Selects num_mirrors elements, chosen at random, from the _mirrors list. + * Adds the selected mirrors to result. If there are fewer than num_mirrors + * elements in the list, adds only as many mirrors as we can get. + */ void PPInstance:: choose_random_mirrors(vector &result, int num_mirrors) { vector selected; @@ -1243,14 +1167,11 @@ choose_random_mirrors(vector &result, int num_mirrors) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::request_ready -// Access: Private, Static -// Description: This function is attached as an asynchronous callback -// to each instance; it will be notified when the -// instance has a request ready. This function may be -// called in a sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * This function is attached as an asynchronous callback to each instance; it + * will be notified when the instance has a request ready. This function may + * be called in a sub-thread. + */ void PPInstance:: request_ready(P3D_instance *instance) { PPInstance *inst = (PPInstance *)(instance->_user_data); @@ -1258,22 +1179,21 @@ request_ready(P3D_instance *instance) { if (has_plugin_thread_async_call) { #ifdef HAS_PLUGIN_THREAD_ASYNC_CALL - // Since we are running at least Gecko 1.9, and we have this very - // useful function, let's use it to ask the browser to call us back - // in the main thread. + // Since we are running at least Gecko 1.9, and we have this very useful + // function, let's use it to ask the browser to call us back in the main + // thread. assert((void *)browser->pluginthreadasynccall != (void *)NULL); browser->pluginthreadasynccall(inst->_npp_instance, browser_sync_callback, NULL); #endif // HAS_PLUGIN_THREAD_ASYNC_CALL } else { - // If we're using an older version of Gecko, we have to do this - // some other, OS-dependent way. + // If we're using an older version of Gecko, we have to do this some + // other, OS-dependent way. #ifdef _WIN32 // Use a Windows message to forward this event to the main thread. - - // Get the window handle for the window associated with this - // instance. + + // Get the window handle for the window associated with this instance. const NPWindow *win = inst->get_window(); if (win != NULL && win->type == NPWindowTypeWindow) { PostMessage((HWND)(win->window), WM_USER, 0, 0); @@ -1300,11 +1220,9 @@ request_ready(P3D_instance *instance) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::start_download -// Access: Private -// Description: Initiates a download request. -//////////////////////////////////////////////////////////////////// +/** + * Initiates a download request. + */ void PPInstance:: start_download(const string &url, PPDownloadRequest *req) { nout << "start_download: " << url << "\n"; @@ -1318,28 +1236,25 @@ start_download(const string &url, PPDownloadRequest *req) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::downloaded_contents_file -// Access: Private -// Description: The contents.xml file has been successfully downloaded; -// copy it into place. -//////////////////////////////////////////////////////////////////// +/** + * The contents.xml file has been successfully downloaded; copy it into place. + */ void PPInstance:: downloaded_contents_file(const string &filename) { - // Now we have the contents.xml file. Read this to get the - // filename and md5 hash of our core API DLL. + // Now we have the contents.xml file. Read this to get the filename and md5 + // hash of our core API DLL. if (read_contents_file(filename, true)) { - // Successfully downloaded and read, and it has been written - // into its normal place. + // Successfully downloaded and read, and it has been written into its + // normal place. get_core_api(); - + } else { - // Error reading the contents.xml file, or in loading the core - // API that it references. + // Error reading the contents.xml file, or in loading the core API that it + // references. nout << "Unable to read contents file " << filename << "\n"; - - // If there's an outstanding contents.xml file on disk, try to - // load that one as a fallback. + + // If there's an outstanding contents.xml file on disk, try to load that + // one as a fallback. string contents_filename = _root_dir + "/contents.xml"; if (read_contents_file(contents_filename, false)) { get_core_api(); @@ -1350,14 +1265,11 @@ downloaded_contents_file(const string &filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::read_contents_file -// Access: Private -// Description: Attempts to open and read the contents.xml file on -// disk. Copies the file to its standard location -// on success. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open and read the contents.xml file on disk. Copies the file + * to its standard location on success. Returns true on success, false on + * failure. + */ bool PPInstance:: read_contents_file(const string &contents_filename, bool fresh_download) { _download_url_prefix = _standard_url_prefix; @@ -1390,7 +1302,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { xorig = new TiXmlElement("orig"); xcontents->LinkEndChild(xorig); - + xorig->SetAttribute("expiration", (int)_contents_expiration); } else { @@ -1400,7 +1312,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { if (xorig != NULL) { xorig->Attribute("expiration", &expiration); } - + _contents_expiration = min(_contents_expiration, (time_t)expiration); } @@ -1408,8 +1320,8 @@ read_contents_file(const string &contents_filename, bool fresh_download) { << ", expires in " << max(_contents_expiration, now) - now << " s\n"; - // Look for the entry; it might point us at a different - // download URL, and it might mention some mirrors. + // Look for the entry; it might point us at a different download + // URL, and it might mention some mirrors. find_host(xcontents); // Now look for the core API package. @@ -1429,7 +1341,7 @@ read_contents_file(const string &contents_filename, bool fresh_download) { break; } } - + xpackage = xpackage->NextSiblingElement("package"); } } @@ -1441,9 +1353,9 @@ read_contents_file(const string &contents_filename, bool fresh_download) { return false; } - // Check the coreapi_set_ver token. If it is given, it specifies a - // minimum Core API version number we expect to find. If we didn't - // find that number, perhaps our contents.xml is out of date. + // Check the coreapi_set_ver token. If it is given, it specifies a minimum + // Core API version number we expect to find. If we didn't find that + // number, perhaps our contents.xml is out of date. string coreapi_set_ver = lookup_token("coreapi_set_ver"); if (!coreapi_set_ver.empty()) { nout << "Instance asked for Core API set_ver " << coreapi_set_ver @@ -1451,8 +1363,8 @@ read_contents_file(const string &contents_filename, bool fresh_download) { // But don't bother if we just freshly downloaded it. if (!fresh_download) { if (compare_seq(coreapi_set_ver, _coreapi_set_ver) > 0) { - // The requested set_ver value is higher than the one we have on - // file; our contents.xml file must be out of date after all. + // The requested set_ver value is higher than the one we have on file; + // our contents.xml file must be out of date after all. nout << "expiring contents.xml\n"; _contents_expiration = 0; } @@ -1467,16 +1379,13 @@ read_contents_file(const string &contents_filename, bool fresh_download) { nout << "Couldn't rewrite " << standard_filename << "\n"; return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::get_filename_from_url -// Access: Private, Static -// Description: Returns the actual filename referenced by a file:// -// url. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual filename referenced by a file: url. + */ string PPInstance:: get_filename_from_url(const string &url) { string filename = url.substr(7); @@ -1487,11 +1396,11 @@ get_filename_from_url(const string &url) { filename = filename.substr(0, query); } -#ifdef _WIN32 - // On Windows, we have to munge the filename specially, because it's - // been URL-munged. It might begin with a leading slash as well as - // a drive letter. Clean up that nonsense. - if (filename.length() >= 3 && +#ifdef _WIN32 + // On Windows, we have to munge the filename specially, because it's been + // URL-munged. It might begin with a leading slash as well as a drive + // letter. Clean up that nonsense. + if (filename.length() >= 3 && (filename[0] == '/' || filename[0] == '\\') && isalpha(filename[1]) && filename[2] == ':') { filename = filename.substr(1); @@ -1501,18 +1410,15 @@ get_filename_from_url(const string &url) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::downloaded_file -// Access: Private -// Description: Called to receive the fully-downloaded contents of a -// URL. -//////////////////////////////////////////////////////////////////// +/** + * Called to receive the fully-downloaded contents of a URL. + */ void PPInstance:: downloaded_file(PPDownloadRequest *req, const string &filename) { - // Since we're no longer using NP_ASFILEONLY, none of these URL - // requests will normally come through this codepath (they'll go - // through url_notify() above, instead), unless we short-circuited - // the browser by "downloading" a file:// url. + // Since we're no longer using NP_ASFILEONLY, none of these URL requests + // will normally come through this codepath (they'll go through url_notify() + // above, instead), unless we short-circuited the browser by "downloading" a + // file: url. switch (req->_rtype) { case PPDownloadRequest::RT_contents_file: // The contents.xml file that gets things going. @@ -1520,14 +1426,14 @@ downloaded_file(PPDownloadRequest *req, const string &filename) { break; case PPDownloadRequest::RT_core_dll: - // This is the core API DLL (or dylib or whatever). Now that - // we've downloaded it, we can load it. + // This is the core API DLL (or dylib or whatever). Now that we've + // downloaded it, we can load it. downloaded_plugin(filename); break; case PPDownloadRequest::RT_user: - // Here's the user-requested file. It needs to be streamed to the - // user, so we'll open the file and feed it to the user. + // Here's the user-requested file. It needs to be streamed to the user, + // so we'll open the file and feed it to the user. feed_file(req, filename); break; @@ -1537,25 +1443,20 @@ downloaded_file(PPDownloadRequest *req, const string &filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::feed_file -// Access: Private -// Description: Opens the named file (extracted from a file:// URL) -// and feeds its contents to the core API. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named file (extracted from a file:// URL) and feeds its contents + * to the core API. + */ void PPInstance:: feed_file(PPDownloadRequest *req, const string &filename) { StreamingFileData *file_data = new StreamingFileData(req, filename, _p3d_inst); _file_datas.push_back(file_data); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::send_p3d_temp_file_data -// Access: Private -// Description: Once the instance has been created, sends it all of -// the data we have saved up for it while we were -// waiting. -//////////////////////////////////////////////////////////////////// +/** + * Once the instance has been created, sends it all of the data we have saved + * up for it while we were waiting. + */ void PPInstance:: send_p3d_temp_file_data() { assert(_p3d_temp_file._opened); @@ -1563,7 +1464,7 @@ send_p3d_temp_file_data() { nout << "Sending " << _p3d_temp_file._current_size << " preliminary bytes of " << _p3d_temp_file._total_size << " total p3d data\n"; - + static const size_t buffer_size = 4096; char buffer[buffer_size]; @@ -1595,13 +1496,10 @@ send_p3d_temp_file_data() { _p3d_temp_file.cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::get_core_api -// Access: Private -// Description: Checks the core API DLL file against the -// specification in the contents file, and downloads it -// if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Checks the core API DLL file against the specification in the contents + * file, and downloads it if necessary. + */ void PPInstance:: get_core_api() { if (_coreapi_dll.quick_verify(_root_dir)) { @@ -1609,20 +1507,19 @@ get_core_api() { do_load_plugin(); } else { - // The DLL file needs to be downloaded. Build up our list of - // URL's to attempt to download it from, in reverse order. + // The DLL file needs to be downloaded. Build up our list of URL's to + // attempt to download it from, in reverse order. string url; - // Our last act of desperation: hit the original host, with a - // query uniquifier, to break through any caches. + // Our last act of desperation: hit the original host, with a query + // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() << "?" << time(NULL); url = strm.str(); _core_urls.push_back(url); - // Before we try that, we'll hit the original host, without a - // uniquifier. + // Before we try that, we'll hit the original host, without a uniquifier. url = _download_url_prefix; url += _coreapi_dll.get_filename(); _core_urls.push_back(url); @@ -1631,7 +1528,7 @@ get_core_api() { vector mirrors; choose_random_mirrors(mirrors, 2); for (vector::iterator si = mirrors.begin(); - si != mirrors.end(); + si != mirrors.end(); ++si) { url = (*si) + _coreapi_dll.get_filename(); _core_urls.push_back(url); @@ -1647,19 +1544,15 @@ get_core_api() { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::downloaded_plugin -// Access: Private -// Description: The core API DLL has been successfully downloaded; -// copy it into place. -//////////////////////////////////////////////////////////////////// +/** + * The core API DLL has been successfully downloaded; copy it into place. + */ void PPInstance:: downloaded_plugin(const string &filename) { - // We could have been downloading this file as a stream, but that - // would cause problems with multiple instances downloading the - // plugin at the same time. Instead, we let them all download the - // file asfile, and then only one of them is allowed to copy it into - // place. + // We could have been downloading this file as a stream, but that would + // cause problems with multiple instances downloading the plugin at the same + // time. Instead, we let them all download the file asfile, and then only + // one of them is allowed to copy it into place. if (is_plugin_loaded()) { // Some other instance got there first. Just get started. @@ -1713,22 +1606,19 @@ downloaded_plugin(const string &filename) { } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::do_load_plugin -// Access: Private -// Description: Once the core API DLL has been downloaded, loads it -// into memory and starts the instance. -//////////////////////////////////////////////////////////////////// +/** + * Once the core API DLL has been downloaded, loads it into memory and starts + * the instance. + */ void PPInstance:: do_load_plugin() { string pathname = _coreapi_dll.get_pathname(_root_dir); #ifdef P3D_PLUGIN_P3D_PLUGIN - // This is a convenience macro for development. If defined and - // nonempty, it indicates the name of the plugin DLL that we will - // actually run, even after downloading a possibly different - // (presumably older) version. Its purpose is to simplify iteration - // on the plugin DLL. + // This is a convenience macro for development. If defined and nonempty, it + // indicates the name of the plugin DLL that we will actually run, even + // after downloading a possibly different (presumably older) version. Its + // purpose is to simplify iteration on the plugin DLL. string override_filename = P3D_PLUGIN_P3D_PLUGIN; if (!override_filename.empty()) { pathname = override_filename; @@ -1745,8 +1635,7 @@ do_load_plugin() { return; } - // Format the coreapi_timestamp as a string, for passing as a - // parameter. + // Format the coreapi_timestamp as a string, for passing as a parameter. ostringstream stream; stream << _coreapi_dll.get_timestamp(); string coreapi_timestamp = stream.str(); @@ -1765,12 +1654,9 @@ do_load_plugin() { create_instance(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::create_instance -// Access: Private -// Description: Actually creates the internal P3D_instance object, if -// possible and needed. -//////////////////////////////////////////////////////////////////// +/** + * Actually creates the internal P3D_instance object, if possible and needed. + */ void PPInstance:: create_instance() { if (_started) { @@ -1796,23 +1682,23 @@ create_instance() { x11_stop_twirl_subprocess(); #endif // HAVE_X11 - // In the Windows case, we let the timer keep running, because it - // also checks for wayward messages. + // In the Windows case, we let the timer keep running, because it also + // checks for wayward messages. P3D_token *tokens = NULL; if (!_tokens.empty()) { tokens = &_tokens[0]; } _started = true; - _p3d_inst = P3D_new_instance_ptr(request_ready, tokens, _tokens.size(), + _p3d_inst = P3D_new_instance_ptr(request_ready, tokens, _tokens.size(), 0, NULL, this); if (_p3d_inst == NULL) { set_failed(); return; } - // Now get the browser's toplevel DOM object (called the "window" - // object in JavaScript), to pass to the plugin. + // Now get the browser's toplevel DOM object (called the "window" object in + // JavaScript), to pass to the plugin. NPObject *window_object = NULL; if (browser->getvalue(_npp_instance, NPNVWindowNPObject, &window_object) == NPERR_NO_ERROR) { @@ -1822,10 +1708,10 @@ create_instance() { } else { nout << "Couldn't get window_object\n"; } - + if (_script_object != NULL) { - // Now that we have a true instance, initialize our - // script_object with the proper P3D_object pointer. + // Now that we have a true instance, initialize our script_object with the + // proper P3D_object pointer. P3D_object *main = P3D_instance_get_panda_script_object_ptr(_p3d_inst); nout << "new instance, setting main = " << main << "\n"; _script_object->set_main(main); @@ -1836,25 +1722,22 @@ create_instance() { _p3d_instance_id = P3D_instance_start_stream_ptr(_p3d_inst, _instance_url.c_str()); nout << "p3d instance to stream " << _p3d_instance_id << "\n"; - // If we have already started to receive any instance data, send it - // to the plugin now. + // If we have already started to receive any instance data, send it to the + // plugin now. if (_p3d_temp_file._opened) { send_p3d_temp_file_data(); } } - + if (_got_window) { send_window(); } } - -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::send_window -// Access: Private -// Description: Actually issues the window parameters to the internal -// P3D_instance object. -//////////////////////////////////////////////////////////////////// + +/** + * Actually issues the window parameters to the internal P3D_instance object. + */ void PPInstance:: send_window() { assert(_p3d_inst != NULL); @@ -1867,10 +1750,9 @@ send_window() { parent_window._window_handle_type = P3D_WHT_none; if (_window.type == NPWindowTypeWindow) { - // We have a "windowed" plugin. Parent our window to the one we - // were given. In this case, we should also reset the offset to - // (0, 0), since the window we were given is already placed in the - // right spot. + // We have a "windowed" plugin. Parent our window to the one we were + // given. In this case, we should also reset the offset to (0, 0), since + // the window we were given is already placed in the right spot. #ifdef _WIN32 assert(!_use_xembed); parent_window._window_handle_type = P3D_WHT_win_hwnd; @@ -1896,13 +1778,12 @@ send_window() { #elif defined(HAVE_X11) if (_use_xembed) { - // If we're using the XEmbed model, we've actually received an - // XID for a GtkSocket. + // If we're using the XEmbed model, we've actually received an XID for a + // GtkSocket. #ifdef HAVE_GTK - // If we're using XEmbed, pass the X11 Window pointer of our - // plug down to Panda. (Hmm, it would be nice to pass the XID - // object and use this system in general within Panda, but - // that's for the future, I think.) + // If we're using XEmbed, pass the X11 Window pointer of our plug down + // to Panda. (Hmm, it would be nice to pass the XID object and use this + // system in general within Panda, but that's for the future, I think.) assert(_plug != NULL); parent_window._window_handle_type = P3D_WHT_x11_window; parent_window._handle._x11_window._xwindow = GDK_DRAWABLE_XID(_plug->window); @@ -1918,8 +1799,8 @@ send_window() { #endif } else { - // We have a "windowless" plugin. Parent our window directly to - // the browser window. + // We have a "windowless" plugin. Parent our window directly to the + // browser window. #ifdef _WIN32 HWND hwnd; if (browser->getvalue(_npp_instance, NPNVnetscapeWindow, @@ -1970,7 +1851,7 @@ send_window() { } else if (_window.width == 0 || _window.height == 0) { // No size: hidden. window_type = P3D_WT_hidden; - } + } P3D_instance_setup_window_ptr (_p3d_inst, window_type, @@ -1978,12 +1859,10 @@ send_window() { &parent_window); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::cleanup_window -// Access: Private -// Description: Called at instance shutdown, this restores the parent -// window to its original state. -//////////////////////////////////////////////////////////////////// +/** + * Called at instance shutdown, this restores the parent window to its + * original state. + */ void PPInstance:: cleanup_window() { if (_got_window) { @@ -2020,21 +1899,19 @@ cleanup_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::copy_file -// Access: Private -// Description: Copies the data in the file named by from_filename -// into the file named by to_filename. -//////////////////////////////////////////////////////////////////// +/** + * Copies the data in the file named by from_filename into the file named by + * to_filename. + */ bool PPInstance:: copy_file(const string &from_filename, const string &to_filename) { mkfile_complete(to_filename, nout); ifstream in(from_filename.c_str(), ios::in | ios::binary); ofstream out(to_filename.c_str(), ios::out | ios::binary); - + static const size_t buffer_size = 4096; char buffer[buffer_size]; - + in.read(buffer, buffer_size); size_t count = in.gcount(); while (count != 0) { @@ -2053,13 +1930,10 @@ copy_file(const string &from_filename, const string &to_filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::lookup_token -// Access: Private -// Description: Returns the value associated with the first -// appearance of the named token, or empty string if the -// token does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the first appearance of the named token, + * or empty string if the token does not appear. + */ string PPInstance:: lookup_token(const string &keyword) const { Tokens::const_iterator ti; @@ -2072,12 +1946,9 @@ lookup_token(const string &keyword) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::has_token -// Access: Private -// Description: Returns true if the named token appears in the list, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named token appears in the list, false otherwise. + */ bool PPInstance:: has_token(const string &keyword) const { Tokens::const_iterator ti; @@ -2091,13 +1962,10 @@ has_token(const string &keyword) const { } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::compare_seq -// Access: Private, Static -// Description: Compares the two dotted-integer sequence values -// numerically. Returns -1 if seq_a sorts first, 1 if -// seq_b sorts first, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Compares the two dotted-integer sequence values numerically. Returns -1 if + * seq_a sorts first, 1 if seq_b sorts first, 0 if they are equivalent. + */ int PPInstance:: compare_seq(const string &seq_a, const string &seq_b) { const char *num_a = seq_a.c_str(); @@ -2125,13 +1993,11 @@ compare_seq(const string &seq_a, const string &seq_b) { return comp; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::compare_seq_int -// Access: Private, Static -// Description: Numerically compares the formatted integer value at -// num_a with num_b. Increments both num_a and num_b to -// the next character following the valid integer. -//////////////////////////////////////////////////////////////////// +/** + * Numerically compares the formatted integer value at num_a with num_b. + * Increments both num_a and num_b to the next character following the valid + * integer. + */ int PPInstance:: compare_seq_int(const char *&num_a, const char *&num_b) { long int a; @@ -2154,13 +2020,10 @@ compare_seq_int(const char *&num_a, const char *&num_b) { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::set_failed -// Access: Private -// Description: Called when something has gone wrong that prevents -// the plugin instance from running. Specifically, this -// means it failed to load the core API. -//////////////////////////////////////////////////////////////////// +/** + * Called when something has gone wrong that prevents the plugin instance from + * running. Specifically, this means it failed to load the core API. + */ void PPInstance:: set_failed() { if (!_failed) { @@ -2199,13 +2062,10 @@ set_failed() { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::handle_request_loop -// Access: Private, Static -// Description: Checks for any new requests from the plugin, and -// dispatches them to the appropriate PPInstance. This -// function is called only in the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Checks for any new requests from the plugin, and dispatches them to the + * appropriate PPInstance. This function is called only in the main thread. + */ void PPInstance:: handle_request_loop() { if (!is_plugin_loaded()) { @@ -2219,23 +2079,22 @@ handle_request_loop() { PPInstance *inst = (PPInstance *)(p3d_inst->_user_data); assert(inst != NULL); if (!inst->handle_request(request)) { - // If handling the request is meant to yield control - // temporarily to JavaScript (e.g. P3D_RT_callback), then do - // so now. + // If handling the request is meant to yield control temporarily to + // JavaScript (e.g. P3D_RT_callback), then do so now. return; } if (!is_plugin_loaded()) { - // Oops, we may have unloaded the plugin as an indirect effect - // of handling the request. If so, get out of here. + // Oops, we may have unloaded the plugin as an indirect effect of + // handling the request. If so, get out of here. return; } } p3d_inst = P3D_check_request_ptr(0.0); } - // Also check to see if we have any file_data objects that have - // finished and may be deleted. + // Also check to see if we have any file_data objects that have finished and + // may be deleted. size_t num_file_datas = _file_datas.size(); size_t i = 0; while (i < num_file_datas) { @@ -2251,14 +2110,11 @@ handle_request_loop() { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::browser_sync_callback -// Access: Private, Static -// Description: This callback hook is passed to -// NPN_PluginThreadAsyncCall() (if that function is -// available) to forward a request to the main thread. -// The callback is actually called in the main thread. -//////////////////////////////////////////////////////////////////// +/** + * This callback hook is passed to NPN_PluginThreadAsyncCall() (if that + * function is available) to forward a request to the main thread. The + * callback is actually called in the main thread. + */ void PPInstance:: browser_sync_callback(void *) { handle_request_loop(); @@ -2266,14 +2122,11 @@ browser_sync_callback(void *) { #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::st_window_proc -// Access: Private, Static -// Description: We bind this function to the parent window we were -// given in set_window, so we can spin the request_loop -// when needed. This is only in the Windows case; other -// platforms rely on explicit windows events. -//////////////////////////////////////////////////////////////////// +/** + * We bind this function to the parent window we were given in set_window, so + * we can spin the request_loop when needed. This is only in the Windows + * case; other platforms rely on explicit windows events. + */ LONG PPInstance:: st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -2287,35 +2140,31 @@ st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::window_proc -// Access: Private -// Description: The non-static window_proc() function. -// -// We bind this function to the parent window we were -// given in set_window, so we can spin the request_loop -// when needed. This is only in the Windows case; other -// platforms rely on explicit windows events. -//////////////////////////////////////////////////////////////////// +/** + * The non-static window_proc() function. + * + * We bind this function to the parent window we were given in set_window, so + * we can spin the request_loop when needed. This is only in the Windows + * case; other platforms rely on explicit windows events. + */ LONG PPInstance:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (!has_plugin_thread_async_call) { - // Since we're here in the main thread, call handle_request_loop() - // to see if there are any new requests to be serviced by the main - // thread. + // Since we're here in the main thread, call handle_request_loop() to see + // if there are any new requests to be serviced by the main thread. handle_request_loop(); } switch (msg) { case WM_ERASEBKGND: - // Eat the WM_ERASEBKGND message, so the browser's intervening - // window won't overdraw on top of our own window. + // Eat the WM_ERASEBKGND message, so the browser's intervening window + // won't overdraw on top of our own window. return true; - + case WM_PAINT: if (!_started) { - // If we haven't yet loaded the instance, we can paint a - // twirling icon in the window. + // If we haven't yet loaded the instance, we can paint a twirling icon + // in the window. PAINTSTRUCT ps; HDC dc = BeginPaint(hwnd, &ps); win_paint_twirl(hwnd, dc); @@ -2339,13 +2188,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::win_get_twirl_bitmaps -// Access: Private -// Description: Fills _twirl_bitmaps with an array of bitmaps for -// drawing the twirling icon while we're waiting for the -// instance to load. -//////////////////////////////////////////////////////////////////// +/** + * Fills _twirl_bitmaps with an array of bitmaps for drawing the twirling icon + * while we're waiting for the instance to load. + */ void PPInstance:: win_get_twirl_bitmaps() { BITMAPINFOHEADER bmih; @@ -2372,7 +2218,7 @@ win_get_twirl_bitmaps() { for (int step = 0; step < twirl_num_steps + 1; ++step) { get_twirl_data(twirl_data, twirl_size, step, - _fgcolor_r, _fgcolor_g, _fgcolor_b, + _fgcolor_r, _fgcolor_g, _fgcolor_b, _bgcolor_r, _bgcolor_g, _bgcolor_b); // Expand out the RGB channels into RGBA. @@ -2399,12 +2245,10 @@ win_get_twirl_bitmaps() { #endif // _WIN32 #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::win_paint_twirl -// Access: Private -// Description: Paints the twirling icon into the browser window -// before the instance has started. -//////////////////////////////////////////////////////////////////// +/** + * Paints the twirling icon into the browser window before the instance has + * started. + */ void PPInstance:: win_paint_twirl(HWND hwnd, HDC dc) { RECT rect; @@ -2422,27 +2266,26 @@ win_paint_twirl(HWND hwnd, HDC dc) { if (!_started) { DWORD now = GetTickCount(); - // Don't draw the twirling icon until at least half a second has - // passed, so we don't distract people by drawing it - // unnecessarily. + // Don't draw the twirling icon until at least half a second has passed, + // so we don't distract people by drawing it unnecessarily. if (_failed || (now - _init_time) >= 500) { // Which frame are we drawing? int step = (now / 100) % twirl_num_steps; if (_failed) { step = twirl_num_steps; } - + HBITMAP twirl = _twirl_bitmaps[step]; - + int left = rect.left + (width - twirl_width) / 2; int top = rect.top + (height - twirl_height) / 2; - + HDC mem_dc = CreateCompatibleDC(bdc); SelectObject(mem_dc, twirl); - + BitBlt(bdc, left, top, twirl_width, twirl_height, mem_dc, 0, 0, SRCCOPY); - + SelectObject(mem_dc, NULL); DeleteDC(mem_dc); } @@ -2454,16 +2297,13 @@ win_paint_twirl(HWND hwnd, HDC dc) { #endif // _WIN32 #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::copy_cocoa_event -// Access: Private, Static -// Description: Copies the NPCocoaEvent structure componentwise into -// a P3DCocoaEvent structure, for passing into the core -// API. -// -// The aux_data object is used to manage temporary -// storage on the strings created for the event. -//////////////////////////////////////////////////////////////////// +/** + * Copies the NPCocoaEvent structure componentwise into a P3DCocoaEvent + * structure, for passing into the core API. + * + * The aux_data object is used to manage temporary storage on the strings + * created for the event. + */ void PPInstance:: copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, EventAuxData &aux_data) { @@ -2544,9 +2384,9 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, case NPCocoaEventKeyUp: case NPCocoaEventFlagsChanged: p3d_event->data.key.modifierFlags = np_event->data.key.modifierFlags; - p3d_event->data.key.characters = + p3d_event->data.key.characters = make_ansi_string(aux_data._characters, np_event->data.key.characters); - p3d_event->data.key.charactersIgnoringModifiers = + p3d_event->data.key.charactersIgnoringModifiers = make_ansi_string(aux_data._characters_im, np_event->data.key.charactersIgnoringModifiers); p3d_event->data.key.isARepeat = np_event->data.key.isARepeat; p3d_event->data.key.keyCode = np_event->data.key.keyCode; @@ -2558,7 +2398,7 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, break; case NPCocoaEventTextInput: - p3d_event->data.text.text = + p3d_event->data.text.text = make_ansi_string(aux_data._text, np_event->data.text.text); break; } @@ -2566,22 +2406,20 @@ copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::make_ansi_string -// Access: Private, Static -// Description: OSX only: Fills result with the unicode characters in -// the NPNSString. Also returns result.c_str(). -//////////////////////////////////////////////////////////////////// +/** + * OSX only: Fills result with the unicode characters in the NPNSString. Also + * returns result.c_str(). + */ const wchar_t *PPInstance:: make_ansi_string(wstring &result, NPNSString *ns_string) { result.clear(); - + if (ns_string != NULL) { // An NPNSString is really just an NSString, which is itself just a // CFString. CFStringRef cfstr = (CFStringRef)ns_string; CFIndex length = CFStringGetLength(cfstr); - + for (CFIndex i = 0; i < length; ++i) { result += (wchar_t)CFStringGetCharacterAtIndex(cfstr, i); } @@ -2592,14 +2430,11 @@ make_ansi_string(wstring &result, NPNSString *ns_string) { #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::handle_cocoa_event -// Access: Private -// Description: Locally processes a Cocoa event for the window before -// sending it down to the Core API. This is used for -// drawing a twirling icon in the window while the Core -// API is downloading. -//////////////////////////////////////////////////////////////////// +/** + * Locally processes a Cocoa event for the window before sending it down to + * the Core API. This is used for drawing a twirling icon in the window while + * the Core API is downloading. + */ void PPInstance:: handle_cocoa_event(const P3DCocoaEvent *p3d_event) { switch (p3d_event->type) { @@ -2609,7 +2444,7 @@ handle_cocoa_event(const P3DCocoaEvent *p3d_event) { paint_twirl_osx_cgcontext(context); } break; - + default: break; } @@ -2617,13 +2452,10 @@ handle_cocoa_event(const P3DCocoaEvent *p3d_event) { #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::osx_get_twirl_images -// Access: Private -// Description: Fills _twirl_images with an array of images for -// drawing the twirling icon while we're waiting for the -// instance to load. -//////////////////////////////////////////////////////////////////// +/** + * Fills _twirl_images with an array of images for drawing the twirling icon + * while we're waiting for the instance to load. + */ void PPInstance:: osx_get_twirl_images() { if (_got_twirl_images) { @@ -2636,7 +2468,7 @@ osx_get_twirl_images() { for (int step = 0; step < twirl_num_steps + 1; ++step) { get_twirl_data(twirl_data, twirl_size, step, - _fgcolor_r, _fgcolor_g, _fgcolor_b, + _fgcolor_r, _fgcolor_g, _fgcolor_b, _bgcolor_r, _bgcolor_g, _bgcolor_b); unsigned char *new_data = new unsigned char[twirl_size * 4]; @@ -2660,26 +2492,24 @@ osx_get_twirl_images() { image._raw_data = new_data; image._data = - CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, + CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)image._raw_data, twirl_size * 4, kCFAllocatorNull); image._provider = CGDataProviderCreateWithCFData(image._data); image._color_space = CGColorSpaceCreateDeviceRGB(); - + image._image = - CGImageCreate(twirl_width, twirl_height, 8, 32, + CGImageCreate(twirl_width, twirl_height, 8, 32, twirl_width * 4, image._color_space, - kCGImageAlphaFirst | kCGBitmapByteOrder32Little, + kCGImageAlphaFirst | kCGBitmapByteOrder32Little, image._provider, NULL, false, kCGRenderingIntentDefault); } } #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::osx_release_twirl_images -// Access: Private -// Description: Frees the twirl_images array. -//////////////////////////////////////////////////////////////////// +/** + * Frees the twirl_images array. + */ void PPInstance:: osx_release_twirl_images() { if (!_got_twirl_images) { @@ -2715,13 +2545,10 @@ osx_release_twirl_images() { #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::paint_twirl_osx_cgcontext -// Access: Private -// Description: Actually paints the twirling icon in the OSX window, -// using Core Graphics. (We don't bother painting it in -// the older Cocoa interface.) -//////////////////////////////////////////////////////////////////// +/** + * Actually paints the twirling icon in the OSX window, using Core Graphics. + * (We don't bother painting it in the older Cocoa interface.) + */ void PPInstance:: paint_twirl_osx_cgcontext(CGContextRef context) { // Clear the whole region to the bgcolor before beginning. @@ -2746,10 +2573,9 @@ paint_twirl_osx_cgcontext(CGContextRef context) { struct timeval tv; gettimeofday(&tv, (struct timezone *)NULL); double now = (double)(tv.tv_sec - _init_sec) + (double)(tv.tv_usec - _init_usec) / 1000000.0; - - // Don't draw the twirling icon until at least half a second has - // passed, so we don't distract people by drawing it - // unnecessarily. + + // Don't draw the twirling icon until at least half a second has passed, + // so we don't distract people by drawing it unnecessarily. if (now >= 0.5) { int step = ((int)(now * 10.0)) % twirl_num_steps; osx_paint_image(context, _twirl_images[step]); @@ -2759,50 +2585,44 @@ paint_twirl_osx_cgcontext(CGContextRef context) { #endif // MACOSX_HAS_EVENT_MODELS #ifdef MACOSX_HAS_EVENT_MODELS -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::osx_paint_image -// Access: Private -// Description: Draws the indicated image, centered within the -// window. Returns true on success, false if the image -// is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Draws the indicated image, centered within the window. Returns true on + * success, false if the image is not defined. + */ bool PPInstance:: osx_paint_image(CGContextRef context, const OsxImageData &image) { if (image._image == NULL) { return false; } - + // Determine the relative size of image and window. int win_cx = _window.width / 2; int win_cy = _window.height / 2; CGRect rect = { { 0, 0 }, { 0, 0 } }; - + // The bitmap fits within the window; center it. - + // This is the top-left corner of the bitmap in window coordinates. int p_x = win_cx - twirl_width / 2; int p_y = win_cy - twirl_height / 2; - + rect.origin.x += p_x; rect.origin.y += p_y; rect.size.width = twirl_width; rect.size.height = twirl_height; CGContextDrawImage(context, rect, image._image); - + return true; } #endif // MACOSX_HAS_EVENT_MODELS #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::timer_callback -// Access: Private, Static -// Description: OSX only: this callback is associated with a -// CFRunLoopTimer; it's used to forward request messages -// to the main thread. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: this callback is associated with a CFRunLoopTimer; it's used to + * forward request messages to the main thread. + */ void PPInstance:: timer_callback(CFRunLoopTimerRef timer, void *info) { PPInstance *self = (PPInstance *)info; @@ -2819,12 +2639,10 @@ timer_callback(CFRunLoopTimerRef timer, void *info) { #endif // __APPLE__ #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::st_twirl_timer_callback -// Access: Private, Static -// Description: OSX only: this callback is used to twirl the icon -// before the instance loads. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: this callback is used to twirl the icon before the instance + * loads. + */ void PPInstance:: st_twirl_timer_callback(CFRunLoopTimerRef timer, void *info) { PPInstance *self = (PPInstance *)info; @@ -2833,12 +2651,10 @@ st_twirl_timer_callback(CFRunLoopTimerRef timer, void *info) { #endif // __APPLE__ #ifdef __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::twirl_timer_callback -// Access: Private -// Description: OSX only: this callback is used to twirl the icon -// before the instance loads. -//////////////////////////////////////////////////////////////////// +/** + * OSX only: this callback is used to twirl the icon before the instance + * loads. + */ void PPInstance:: twirl_timer_callback() { if (_got_window) { @@ -2849,12 +2665,10 @@ twirl_timer_callback() { #endif // __APPLE__ #ifdef HAVE_X11 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::x11_start_twirl_subprocess -// Access: Public -// Description: Spawns a separate process to twirl the loading icon -// in the X11 browser window. -//////////////////////////////////////////////////////////////////// +/** + * Spawns a separate process to twirl the loading icon in the X11 browser + * window. + */ void PPInstance:: x11_start_twirl_subprocess() { if (_twirl_subprocess_pid != -1) { @@ -2883,11 +2697,9 @@ x11_start_twirl_subprocess() { #endif // HAVE_X11 #ifdef HAVE_X11 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::x11_stop_twirl_subprocess -// Access: Public -// Description: Kills the twirl process that was started earlier. -//////////////////////////////////////////////////////////////////// +/** + * Kills the twirl process that was started earlier. + */ void PPInstance:: x11_stop_twirl_subprocess() { if (_twirl_subprocess_pid == -1) { @@ -2905,7 +2717,7 @@ x11_stop_twirl_subprocess() { nout << " exited normally, status = " << WEXITSTATUS(status) << "\n"; } else if (WIFSIGNALED(status)) { - nout << " signalled by " << WTERMSIG(status) << ", core = " + nout << " signalled by " << WTERMSIG(status) << ", core = " << WCOREDUMP(status) << "\n"; } else if (WIFSTOPPED(status)) { nout << " stopped by " << WSTOPSIG(status) << "\n"; @@ -2915,30 +2727,27 @@ x11_stop_twirl_subprocess() { #endif // HAVE_X11 #ifdef HAVE_X11 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::x11_twirl_subprocess_run -// Access: Public -// Description: The code that is run within a subprocess. This code -// is responsible for twirling the loading icon -// endlessly. -//////////////////////////////////////////////////////////////////// +/** + * The code that is run within a subprocess. This code is responsible for + * twirling the loading icon endlessly. + */ void PPInstance:: x11_twirl_subprocess_run() { - // Since everything within this function happens within a subprocess - // that will just exit, we can be a little sloppy with our resource - // allocation. It is all done directly within this function, and we - // don't need to worry about freeing stuff. + // Since everything within this function happens within a subprocess that + // will just exit, we can be a little sloppy with our resource allocation. + // It is all done directly within this function, and we don't need to worry + // about freeing stuff. - // First, sleep for 0.5 seconds, so we don't start twirling right - // away (to avoid distracting the user unnecessarily). + // First, sleep for 0.5 seconds, so we don't start twirling right away (to + // avoid distracting the user unnecessarily). struct timespec req; req.tv_sec = 0; req.tv_nsec = 500000000; // 500 ms nanosleep(&req, NULL); - // We haven't been killed yet, so the plugin is still loading. - // Start twirling. + // We haven't been killed yet, so the plugin is still loading. Start + // twirling. // First, embed a window. X11_Display *display = XOpenDisplay(NULL); @@ -3011,8 +2820,8 @@ x11_twirl_subprocess_run() { if (bg_pixel != -1) { gcval.background = bg_pixel; } - GC graphics_context = XCreateGC(display, window, - GCFunction | GCPlaneMask | GCForeground | GCBackground, &gcval); + GC graphics_context = XCreateGC(display, window, + GCFunction | GCPlaneMask | GCForeground | GCBackground, &gcval); // Load up the twirling images. XImage *images[twirl_num_steps]; @@ -3025,7 +2834,7 @@ x11_twirl_subprocess_run() { for (int step = 0; step < twirl_num_steps; ++step) { get_twirl_data(twirl_data, twirl_size, step, - _fgcolor_r, _fgcolor_g, _fgcolor_b, + _fgcolor_r, _fgcolor_g, _fgcolor_b, _bgcolor_r, _bgcolor_g, _bgcolor_b); uint32_t *new_data = new uint32_t[twirl_size]; int j = 0; @@ -3040,7 +2849,7 @@ x11_twirl_subprocess_run() { } // Now load the image. - images[step] = XCreateImage(display, CopyFromParent, DefaultDepth(display, screen), + images[step] = XCreateImage(display, CopyFromParent, DefaultDepth(display, screen), ZPixmap, 0, (char *)new_data, twirl_width, twirl_height, 32, 0); } @@ -3058,9 +2867,9 @@ x11_twirl_subprocess_run() { break; } - // We should probably track the resize event, but this window - // will be short-lived (and probably won't have an opportunity - // to resize anyway) so we don't bother. + // We should probably track the resize event, but this window will be + // short-lived (and probably won't have an opportunity to resize anyway) + // so we don't bother. } // What step are we on now? @@ -3076,7 +2885,7 @@ x11_twirl_subprocess_run() { XClearWindow(display, window); int xo = (_window.width - twirl_width) / 2; int yo = (_window.height - twirl_height) / 2; - XPutImage(display, window, graphics_context, images[step], 0, 0, + XPutImage(display, window, graphics_context, images[step], 0, 0, xo, yo, twirl_width, twirl_height); XFlush(display); @@ -3092,11 +2901,9 @@ x11_twirl_subprocess_run() { } #endif // HAVE_X11 -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamingFileData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPInstance::StreamingFileData:: StreamingFileData(PPDownloadRequest *req, const string &filename, P3D_instance *p3d_inst) : @@ -3121,11 +2928,9 @@ StreamingFileData(PPDownloadRequest *req, const string &filename, SPAWN_THREAD(_thread, thread_run, this); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamingFileData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPInstance::StreamingFileData:: ~StreamingFileData() { // Time to stop. @@ -3134,28 +2939,23 @@ PPInstance::StreamingFileData:: JOIN_THREAD(_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamingFileData::is_done -// Access: Public -// Description: Returns true if the file has been fully read and this -// object is ready to be deleted, or false if there is -// more work to do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has been fully read and this object is ready to be + * deleted, or false if there is more work to do. + */ bool PPInstance::StreamingFileData:: is_done() const { return _thread_done; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamingFileData::thread_run -// Access: Private -// Description: The main function of the file thread. This reads the -// file contents and feeds it to the core API. -//////////////////////////////////////////////////////////////////// +/** + * The main function of the file thread. This reads the file contents and + * feeds it to the core API. + */ void PPInstance::StreamingFileData:: thread_run() { static const size_t buffer_size = 81920; - //static const size_t buffer_size = 512; + // static const size_t buffer_size = 512; char buffer[buffer_size]; _file.read(buffer, buffer_size); @@ -3173,8 +2973,7 @@ thread_run() { } if (!_thread_continue) { - // Interrupted by the main thread. Presumably we're being shut - // down. + // Interrupted by the main thread. Presumably we're being shut down. _thread_done = true; return; } @@ -3183,8 +2982,8 @@ thread_run() { _file.read(buffer, buffer_size); count = _file.gcount(); - // This is useful for development, to slow things down enough to - // see the progress bar move. + // This is useful for development, to slow things down enough to see the + // progress bar move. #ifdef _WIN32 Sleep(10); #else @@ -3210,11 +3009,9 @@ thread_run() { } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPInstance::StreamTempFile:: StreamTempFile() { _opened = false; @@ -3223,24 +3020,19 @@ StreamTempFile() { _total_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PPInstance::StreamTempFile:: ~StreamTempFile() { cleanup(); } - -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::open -// Access: Public -// Description: Creates the temp file and prepares to write to it. -// It is not normally necessary to call this explicitly; -// it will be called automatically on the first call to -// feed(). -//////////////////////////////////////////////////////////////////// + +/** + * Creates the temp file and prepares to write to it. It is not normally + * necessary to call this explicitly; it will be called automatically on the + * first call to feed(). + */ void PPInstance::StreamTempFile:: open() { assert(!_opened); @@ -3262,13 +3054,10 @@ open() { } } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::feed -// Access: Public -// Description: Receives new data from the URL and writes it to the -// temp file. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Receives new data from the URL and writes it to the temp file. Returns + * true on success, false on failure. + */ bool PPInstance::StreamTempFile:: feed(size_t total_expected_data, const void *this_data, size_t this_data_size) { @@ -3293,13 +3082,10 @@ feed(size_t total_expected_data, const void *this_data, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::finish -// Access: Public -// Description: Marks the end of the data received from the URL. The -// file is closed but not yet deleted; it remains on -// disk and may be read at leisure. -//////////////////////////////////////////////////////////////////// +/** + * Marks the end of the data received from the URL. The file is closed but + * not yet deleted; it remains on disk and may be read at leisure. + */ void PPInstance::StreamTempFile:: finish() { if (!_finished) { @@ -3310,24 +3096,18 @@ finish() { _stream.close(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::close -// Access: Public -// Description: Closes the stream for more data. The file is not yet -// deleted; it remains on disk and may be read at -// leisure. -//////////////////////////////////////////////////////////////////// +/** + * Closes the stream for more data. The file is not yet deleted; it remains + * on disk and may be read at leisure. + */ void PPInstance::StreamTempFile:: close() { _stream.close(); } -//////////////////////////////////////////////////////////////////// -// Function: PPInstance::StreamTempFile::cleanup -// Access: Public -// Description: Closes all open processes and removes the temp file -// from disk. -//////////////////////////////////////////////////////////////////// +/** + * Closes all open processes and removes the temp file from disk. + */ void PPInstance::StreamTempFile:: cleanup() { finish(); diff --git a/direct/src/plugin_npapi/ppInstance.h b/direct/src/plugin_npapi/ppInstance.h index 5a6f26571b..86fa9bbf93 100644 --- a/direct/src/plugin_npapi/ppInstance.h +++ b/direct/src/plugin_npapi/ppInstance.h @@ -1,16 +1,15 @@ -// Filename: ppInstance.h -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppInstance.h + * @author drose + * @date 2009-06-19 + */ #ifndef PPINSTANCE_H #define PPINSTANCE_H @@ -35,16 +34,14 @@ class PPToplevelObject; class PPDownloadRequest; -//////////////////////////////////////////////////////////////////// -// Class : PPInstance -// Description : This represents a single instance of the Panda3D -// plugin, via the NPAPI interface. This instance -// brokers the communication with the P3D Core API, as -// defined in the plugin directory. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single instance of the Panda3D plugin, via the NPAPI + * interface. This instance brokers the communication with the P3D Core API, + * as defined in the plugin directory. + */ class PPInstance { public: - PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, + PPInstance(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved, P3D_window_handle_type window_handle_type, P3D_event_type event_type); @@ -56,7 +53,7 @@ public: inline const NPWindow *get_window() const; void set_window(NPWindow *window); - NPError new_stream(NPMIMEType type, NPStream *stream, + NPError new_stream(NPMIMEType type, NPStream *stream, bool seekable, uint16_t *stype); void stop_outstanding_streams(); @@ -117,7 +114,7 @@ private: static void browser_sync_callback(void *); #ifdef _WIN32 - static LONG + static LONG st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); void win_get_twirl_bitmaps(); @@ -131,7 +128,7 @@ private: wstring _text; }; #ifdef MACOSX_HAS_EVENT_MODELS - static void copy_cocoa_event(P3DCocoaEvent *p3d_event, + static void copy_cocoa_event(P3DCocoaEvent *p3d_event, NPCocoaEvent *np_event, EventAuxData &aux_data); static const wchar_t *make_ansi_string(wstring &result, NPNSString *ns_string); @@ -166,15 +163,14 @@ private: // Set from fgcolor & bgcolor. int _fgcolor_r, _fgcolor_b, _fgcolor_g; int _bgcolor_r, _bgcolor_b, _bgcolor_g; - + string _root_dir; string _standard_url_prefix; string _download_url_prefix; typedef vector Mirrors; Mirrors _mirrors; - // A list of URL's that we will attempt to download the core API - // from. + // A list of URL's that we will attempt to download the core API from. typedef vector CoreUrls; CoreUrls _core_urls; @@ -184,15 +180,15 @@ private: bool _failed; bool _started; - // This class is used to stream data from some URL into a temporary - // local file. + // This class is used to stream data from some URL into a temporary local + // file. class StreamTempFile { public: StreamTempFile(); ~StreamTempFile(); - + void open(); - bool feed(size_t total_expected_data, const void *this_data, + bool feed(size_t total_expected_data, const void *this_data, size_t this_data_size); void finish(); void close(); @@ -212,15 +208,15 @@ private: StreamTempFile _p3d_temp_file; StreamTempFile _contents_temp_file; StreamTempFile _core_dll_temp_file; - - // We need to keep a list of the NPStream objects that the instance - // owns, because Safari (at least) won't automatically delete all of - // the outstanding streams when the instance is destroyed. + + // We need to keep a list of the NPStream objects that the instance owns, + // because Safari (at least) won't automatically delete all of the + // outstanding streams when the instance is destroyed. typedef vector Streams; Streams _streams; - // This class is used for feeding local files (accessed via a - // "file://" url) into the core API. + // This class is used for feeding local files (accessed via a "file:" url) + // into the core API. class StreamingFileData { public: StreamingFileData(PPDownloadRequest *req, const string &filename, @@ -249,7 +245,7 @@ private: typedef vector FileDatas; static FileDatas _file_datas; - + bool _use_xembed; bool _got_window; NPWindow _window; diff --git a/direct/src/plugin_npapi/ppPandaObject.I b/direct/src/plugin_npapi/ppPandaObject.I index e4ac51a6d9..1f50908246 100644 --- a/direct/src/plugin_npapi/ppPandaObject.I +++ b/direct/src/plugin_npapi/ppPandaObject.I @@ -1,25 +1,21 @@ -// Filename: ppPandaObject.I -// Created by: drose (03Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppPandaObject.I + * @author drose + * @date 2009-07-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::set_p3d_object -// Access: Public -// Description: Returns the p3d_object this PPPandaObject maps to. This -// may be NULL if the object is not fully initialized. -// If not NULL, this returns a new reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the p3d_object this PPPandaObject maps to. This may be NULL if the + * object is not fully initialized. If not NULL, this returns a new + * reference. + */ inline P3D_object *PPPandaObject:: get_p3d_object() const { if (_p3d_object != NULL) { diff --git a/direct/src/plugin_npapi/ppPandaObject.cxx b/direct/src/plugin_npapi/ppPandaObject.cxx index 6878fd4649..c403868a41 100644 --- a/direct/src/plugin_npapi/ppPandaObject.cxx +++ b/direct/src/plugin_npapi/ppPandaObject.cxx @@ -1,16 +1,15 @@ -// Filename: ppPandaObject.cxx -// Created by: drose (03Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppPandaObject.cxx + * @author drose + * @date 2009-07-03 + */ #include "ppPandaObject.h" @@ -35,27 +34,22 @@ NPClass PPPandaObject::_object_class = { }; -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::make_new -// Access: Public, Static -// Description: Use this call to construct a new PPPandaObject. -//////////////////////////////////////////////////////////////////// +/** + * Use this call to construct a new PPPandaObject. + */ PPPandaObject *PPPandaObject:: make_new(PPInstance *inst, P3D_object *p3d_object) { - NPObject *npobj = + NPObject *npobj = browser->createobject(inst->get_npp_instance(), &_object_class); PPPandaObject *ppobj = (PPPandaObject *)npobj; ppobj->construct(inst, p3d_object); return ppobj; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::set_p3d_object -// Access: Public -// Description: Changes the p3d_object this PPPandaObject maps to. The -// new object's reference count is incremented, and the -// previous object's is decremented. -//////////////////////////////////////////////////////////////////// +/** + * Changes the p3d_object this PPPandaObject maps to. The new object's + * reference count is incremented, and the previous object's is decremented. + */ void PPPandaObject:: set_p3d_object(P3D_object *p3d_object) { if (p3d_object != NULL) { @@ -64,15 +58,12 @@ set_p3d_object(P3D_object *p3d_object) { P3D_OBJECT_XDECREF(_p3d_object); _p3d_object = p3d_object; } - -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::construct -// Access: Private -// Description: Stands in for the C++ constructor. We can't have a -// true constructor because of the C-style interface in -// NPN_CreateObject(). This must be called explicitly -// following NPN_CreateObject(). -//////////////////////////////////////////////////////////////////// + +/** + * Stands in for the C++ constructor. We can't have a true constructor + * because of the C-style interface in NPN_CreateObject(). This must be + * called explicitly following NPN_CreateObject(). + */ void PPPandaObject:: construct(PPInstance *inst, P3D_object *p3d_object) { _instance = inst; @@ -80,59 +71,49 @@ construct(PPInstance *inst, P3D_object *p3d_object) { set_p3d_object(p3d_object); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::invalidate -// Access: Private -// Description: This "destructor" is called by NPInvalidate(). -//////////////////////////////////////////////////////////////////// +/** + * This "destructor" is called by NPInvalidate(). + */ void PPPandaObject:: invalidate() { _instance = NULL; set_p3d_object(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::has_method -// Access: Private -// Description: Returns true if the object has the named method, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the object has the named method, false otherwise. + */ bool PPPandaObject:: has_method(NPIdentifier name) { string method_name = identifier_to_string(name); - //nout << this << ".has_method(" << method_name << ")\n"; + // nout << this << ".has_method(" << method_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; } - // Unlike has_property(), below, it turns out that we really do need - // to honestly answer whether there is a method by this name, - // because if there is, then Firefox won't query the property in a - // meaningful fashion. + // Unlike has_property(), below, it turns out that we really do need to + // honestly answer whether there is a method by this name, because if there + // is, then Firefox won't query the property in a meaningful fashion. - // Of course, in Python the distinction between property and method - // is a little looser than Firefox seems to want to make it, and - // sometimes you have an object which is both. This could become - // problematic in obscure situations. Too bad, say I. Mozilla's - // bug, not mine. + // Of course, in Python the distinction between property and method is a + // little looser than Firefox seems to want to make it, and sometimes you + // have an object which is both. This could become problematic in obscure + // situations. Too bad, say I. Mozilla's bug, not mine. bool result = P3D_OBJECT_HAS_METHOD(_p3d_object, method_name.c_str()); return result; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::invoke -// Access: Private -// Description: Calls the named method on the object, storing the -// return value into result. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Calls the named method on the object, storing the return value into result. + * Returns true on success, false on failure. + */ bool PPPandaObject:: invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { string method_name = identifier_to_string(name); - //nout << this << ".invoke(" << method_name << ")\n"; + // nout << this << ".invoke(" << method_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; @@ -144,7 +125,7 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, p3dargs[i] = _instance->variant_to_p3dobj(&args[i]); } - P3D_object *value = P3D_OBJECT_CALL(_p3d_object, method_name.c_str(), + P3D_object *value = P3D_OBJECT_CALL(_p3d_object, method_name.c_str(), true, p3dargs, argCount); for (i = 0; i < argCount; ++i) { P3D_OBJECT_DECREF(p3dargs[i]); @@ -162,17 +143,14 @@ invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::invoke_default -// Access: Private -// Description: Calls the default method on the object, storing the -// return value into result. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Calls the default method on the object, storing the return value into + * result. Returns true on success, false on failure. + */ bool PPPandaObject:: invoke_default(const NPVariant *args, uint32_t argCount, NPVariant *result) { - //nout << this << ".invoke_default()\n"; + // nout << this << ".invoke_default()\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; @@ -202,49 +180,41 @@ invoke_default(const NPVariant *args, uint32_t argCount, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::has_property -// Access: Private -// Description: Returns true if the object has the named property, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the object has the named property, false otherwise. + */ bool PPPandaObject:: has_property(NPIdentifier name) { string property_name = identifier_to_string(name); - //nout << this << ".has_property(" << property_name << ")\n"; + // nout << this << ".has_property(" << property_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; } - // If we say we don't have a given property, then set_property() - // will never be called. So we always say we *do* have any - // particular property, whether we currently have it right now or - // not (since we *could* have it if you call set_property()). + // If we say we don't have a given property, then set_property() will never + // be called. So we always say we *do* have any particular property, + // whether we currently have it right now or not (since we *could* have it + // if you call set_property()). - // On the other hand, Firefox gets confused about methods that are - // also properties. So you have to say there's *no* property if - // there is in fact a callable method by that name, or Firefox will - // never call the method. + // On the other hand, Firefox gets confused about methods that are also + // properties. So you have to say there's *no* property if there is in fact + // a callable method by that name, or Firefox will never call the method. bool result = P3D_OBJECT_HAS_METHOD(_p3d_object, property_name.c_str()); return !result; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::get_property -// Access: Private -// Description: Retrieves the named property value from the object -// and stores it in result. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the named property value from the object and stores it in result. + * Returns true on success, false on failure. + */ bool PPPandaObject:: get_property(NPIdentifier name, NPVariant *result) { - // Actually, we never return false. If the property doesn't exist, - // we return undefined, to be consistent with JavaScript (and with - // IE). + // Actually, we never return false. If the property doesn't exist, we + // return undefined, to be consistent with JavaScript (and with IE). string property_name = identifier_to_string(name); - //nout << this << ".get_property(" << property_name << ")\n"; + // nout << this << ".get_property(" << property_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. VOID_TO_NPVARIANT(*result); @@ -264,73 +234,62 @@ get_property(NPIdentifier name, NPVariant *result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::set_property -// Access: Private -// Description: Replaces the named property value on the object. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the named property value on the object. Returns true on success, + * false on failure. + */ bool PPPandaObject:: set_property(NPIdentifier name, const NPVariant *value) { string property_name = identifier_to_string(name); - //nout << this << ".set_property(" << property_name << ")\n"; + // nout << this << ".set_property(" << property_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; } P3D_object *object = _instance->variant_to_p3dobj(value); - bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), + bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), true, object); P3D_OBJECT_DECREF(object); return result; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::remove_property -// Access: Private -// Description: Deletes the named property value from the object. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the named property value from the object. Returns true on success, + * false on failure. + */ bool PPPandaObject:: remove_property(NPIdentifier name) { string property_name = identifier_to_string(name); - //nout << this << ".remove_property(" << property_name << ")\n"; + // nout << this << ".remove_property(" << property_name << ")\n"; if (_p3d_object == NULL) { // Not powered up yet. return false; } - bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), + bool result = P3D_OBJECT_SET_PROPERTY(_p3d_object, property_name.c_str(), true, NULL); return result; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::enumerate -// Access: Private -// Description: Constructs a list of available properties on this -// object. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a list of available properties on this object. Returns true on + * success, false on failure. + */ bool PPPandaObject:: enumerate(NPIdentifier **value, uint32_t *count) { - //nout << this << ".enumerate()\n"; - // TODO: Not implemented yet. + // nout << this << ".enumerate()\n"; TODO: Not implemented yet. - // Note that the array of values must be allocated here with - // NPN_MemAlloc(). + // Note that the array of values must be allocated here with NPN_MemAlloc(). *value = NULL; *count = 0; return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::identifier_to_string -// Access: Private, Static -// Description: Gets the string equivalent of the indicated -// identifier, whether it is an integer identifier or a -// string identifier. -//////////////////////////////////////////////////////////////////// +/** + * Gets the string equivalent of the indicated identifier, whether it is an + * integer identifier or a string identifier. + */ string PPPandaObject:: identifier_to_string(NPIdentifier ident) { if (browser->identifierisstring(ident)) { @@ -341,11 +300,10 @@ identifier_to_string(NPIdentifier ident) { return strval; } } else { - // An integer identifier. We could treat this as a special case, - // like Firefox does, but Safari doesn't appear to use integer - // identifiers and just sends everything as a string identifier. - // So to make things consistent internally, we also send - // everything as a string. + // An integer identifier. We could treat this as a special case, like + // Firefox does, but Safari doesn't appear to use integer identifiers and + // just sends everything as a string identifier. So to make things + // consistent internally, we also send everything as a string. ostringstream strm; strm << browser->intfromidentifier(ident); return strm.str(); @@ -355,61 +313,49 @@ identifier_to_string(NPIdentifier ident) { } -// The remaining function bodies are the C-style function wrappers -// that are called directly by NPAPI, and which redirect into the -// above C++-style methods. +// The remaining function bodies are the C-style function wrappers that are +// called directly by NPAPI, and which redirect into the above C++-style +// methods. -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPAllocate -// Access: Private, Static -// Description: Called by NPN_CreateObject() to allocate space for -// this object. -//////////////////////////////////////////////////////////////////// +/** + * Called by NPN_CreateObject() to allocate space for this object. + */ NPObject *PPPandaObject:: NPAllocate(NPP npp, NPClass *aClass) { assert(aClass == &_object_class); return (PPPandaObject *)malloc(sizeof(PPPandaObject)); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::Deallocate -// Access: Private, Static -// Description: Called to delete the space allocated by NPAllocate, -// above. -//////////////////////////////////////////////////////////////////// +/** + * Called to delete the space allocated by NPAllocate, above. + */ void PPPandaObject:: NPDeallocate(NPObject *npobj) { ((PPPandaObject *)npobj)->invalidate(); free(npobj); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::Deallocate -// Access: Private, Static -// Description: Called to destruct the object. -//////////////////////////////////////////////////////////////////// +/** + * Called to destruct the object. + */ void PPPandaObject:: NPInvalidate(NPObject *npobj) { // It turns out that this method isn't actually called by Safari's - // implementation of NPAPI, so we'll move the actual destructor call - // into NPDeallocate, above. + // implementation of NPAPI, so we'll move the actual destructor call into + // NPDeallocate, above. } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPHasMethod -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPHasMethod(NPObject *npobj, NPIdentifier name) { return ((PPPandaObject *)npobj)->has_method(name); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPInvoke -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPInvoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, @@ -417,78 +363,64 @@ NPInvoke(NPObject *npobj, NPIdentifier name, return ((PPPandaObject *)npobj)->invoke(name, args, argCount, result); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPInvokeDefault -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPInvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { return ((PPPandaObject *)npobj)->invoke_default(args, argCount, result); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPHasProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPHasProperty(NPObject *npobj, NPIdentifier name) { return ((PPPandaObject *)npobj)->has_property(name); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPGetProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPGetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { return ((PPPandaObject *)npobj)->get_property(name, result); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPSetProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPSetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { return ((PPPandaObject *)npobj)->set_property(name, value); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPRemoveProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPRemoveProperty(NPObject *npobj, NPIdentifier name) { return ((PPPandaObject *)npobj)->remove_property(name); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPEnumerate -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { return ((PPPandaObject *)npobj)->enumerate(value, count); } -//////////////////////////////////////////////////////////////////// -// Function: PPPandaObject::NPConstruct -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPPandaObject:: NPConstruct(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { - // Not implemented. We don't use this constructor mechanism because - // it wasn't supported on earlier versions of Gecko. Instead, we - // use make_new() to construct PPPandaObjects via an explicit call to + // Not implemented. We don't use this constructor mechanism because it + // wasn't supported on earlier versions of Gecko. Instead, we use + // make_new() to construct PPPandaObjects via an explicit call to // construct(). return true; } diff --git a/direct/src/plugin_npapi/ppPandaObject.h b/direct/src/plugin_npapi/ppPandaObject.h index 2653dd1d93..762f6a9c94 100644 --- a/direct/src/plugin_npapi/ppPandaObject.h +++ b/direct/src/plugin_npapi/ppPandaObject.h @@ -1,32 +1,28 @@ -// Filename: ppPandaObject.h -// Created by: drose (03Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppPandaObject.h + * @author drose + * @date 2009-07-03 + */ #ifndef PPPANDAOBJECT_H #define PPPANDAOBJECT_H #include "nppanda3d_common.h" -//////////////////////////////////////////////////////////////////// -// Class : PPPandaObject -// Description : This is the interface layer between an NPObject and a -// P3D_object. It maps calls from NPAPI into the -// P3D_object system, thus allowing the browser to -// view and operate on a Panda object. -// -// Also see PPBrowserObject, which maps calls the other -// way. -//////////////////////////////////////////////////////////////////// +/** + * This is the interface layer between an NPObject and a P3D_object. It maps + * calls from NPAPI into the P3D_object system, thus allowing the browser to + * view and operate on a Panda object. + * + * Also see PPBrowserObject, which maps calls the other way. + */ class PPPandaObject : public NPObject { public: static PPPandaObject *make_new(PPInstance *inst, P3D_object *p3d_object); @@ -54,7 +50,7 @@ private: private: static string identifier_to_string(NPIdentifier ident); - + private: static NPObject *NPAllocate(NPP npp, NPClass *aClass); @@ -93,4 +89,3 @@ public: #include "ppPandaObject.I" #endif - diff --git a/direct/src/plugin_npapi/ppToplevelObject.I b/direct/src/plugin_npapi/ppToplevelObject.I index 114b4d28d0..f9972f68dd 100644 --- a/direct/src/plugin_npapi/ppToplevelObject.I +++ b/direct/src/plugin_npapi/ppToplevelObject.I @@ -1,14 +1,12 @@ -// Filename: ppToplevelObject.I -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppToplevelObject.I + * @author drose + * @date 2009-08-21 + */ diff --git a/direct/src/plugin_npapi/ppToplevelObject.cxx b/direct/src/plugin_npapi/ppToplevelObject.cxx index 48c386ca5e..a7f9c879e3 100644 --- a/direct/src/plugin_npapi/ppToplevelObject.cxx +++ b/direct/src/plugin_npapi/ppToplevelObject.cxx @@ -1,16 +1,15 @@ -// Filename: ppToplevelObject.cxx -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppToplevelObject.cxx + * @author drose + * @date 2009-08-21 + */ #include "ppToplevelObject.h" @@ -35,27 +34,22 @@ NPClass PPToplevelObject::_object_class = { }; -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::make_new -// Access: Public, Static -// Description: Use this call to construct a new PPToplevelObject. -//////////////////////////////////////////////////////////////////// +/** + * Use this call to construct a new PPToplevelObject. + */ PPToplevelObject *PPToplevelObject:: make_new(PPInstance *inst) { - NPObject *npobj = + NPObject *npobj = browser->createobject(inst->get_npp_instance(), &_object_class); PPToplevelObject *ppobj = (PPToplevelObject *)npobj; ppobj->construct(inst); return ppobj; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::set_main -// Access: Public -// Description: Changes the "main" object this PPToplevelObject maps -// to. The new object's reference count is incremented, -// and the previous object's is decremented. -//////////////////////////////////////////////////////////////////// +/** + * Changes the "main" object this PPToplevelObject maps to. The new object's + * reference count is incremented, and the previous object's is decremented. + */ void PPToplevelObject:: set_main(P3D_object *p3d_object) { if (p3d_object != NULL) { @@ -64,42 +58,33 @@ set_main(P3D_object *p3d_object) { P3D_OBJECT_XDECREF(_main); _main = p3d_object; } - -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::construct -// Access: Private -// Description: Stands in for the C++ constructor. We can't have a -// true constructor because of the C-style interface in -// NPN_CreateObject(). This must be called explicitly -// following NPN_CreateObject(). -//////////////////////////////////////////////////////////////////// + +/** + * Stands in for the C++ constructor. We can't have a true constructor + * because of the C-style interface in NPN_CreateObject(). This must be + * called explicitly following NPN_CreateObject(). + */ void PPToplevelObject:: construct(PPInstance *inst) { _instance = inst; _main = NULL; - // Get our one property name as an identifier, so we can look for - // it. + // Get our one property name as an identifier, so we can look for it. _main_id = browser->getstringidentifier("main"); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::invalidate -// Access: Private -// Description: This "destructor" is called by NPInvalidate(). -//////////////////////////////////////////////////////////////////// +/** + * This "destructor" is called by NPInvalidate(). + */ void PPToplevelObject:: invalidate() { _instance = NULL; set_main(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::has_property -// Access: Private -// Description: Returns true if the object has the named property, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the object has the named property, false otherwise. + */ bool PPToplevelObject:: has_property(NPIdentifier name) { if (_main == NULL) { @@ -114,13 +99,10 @@ has_property(NPIdentifier name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::get_property -// Access: Private -// Description: Retrieves the named property value from the object -// and stores it in result. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the named property value from the object and stores it in result. + * Returns true on success, false on failure. + */ bool PPToplevelObject:: get_property(NPIdentifier name, NPVariant *result) { if (_main == NULL) { @@ -137,61 +119,49 @@ get_property(NPIdentifier name, NPVariant *result) { } -// The remaining function bodies are the C-style function wrappers -// that are called directly by NPAPI, and which redirect into the -// above C++-style methods. +// The remaining function bodies are the C-style function wrappers that are +// called directly by NPAPI, and which redirect into the above C++-style +// methods. -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPAllocate -// Access: Private, Static -// Description: Called by NPN_CreateObject() to allocate space for -// this object. -//////////////////////////////////////////////////////////////////// +/** + * Called by NPN_CreateObject() to allocate space for this object. + */ NPObject *PPToplevelObject:: NPAllocate(NPP npp, NPClass *aClass) { assert(aClass == &_object_class); return (PPToplevelObject *)malloc(sizeof(PPToplevelObject)); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::Deallocate -// Access: Private, Static -// Description: Called to delete the space allocated by NPAllocate, -// above. -//////////////////////////////////////////////////////////////////// +/** + * Called to delete the space allocated by NPAllocate, above. + */ void PPToplevelObject:: NPDeallocate(NPObject *npobj) { ((PPToplevelObject *)npobj)->invalidate(); free(npobj); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::Deallocate -// Access: Private, Static -// Description: Called to destruct the object. -//////////////////////////////////////////////////////////////////// +/** + * Called to destruct the object. + */ void PPToplevelObject:: NPInvalidate(NPObject *npobj) { // It turns out that this method isn't actually called by Safari's - // implementation of NPAPI, so we'll move the actual destructor call - // into NPDeallocate, above. + // implementation of NPAPI, so we'll move the actual destructor call into + // NPDeallocate, above. } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPHasMethod -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPHasMethod(NPObject *npobj, NPIdentifier name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPInvoke -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPInvoke(NPObject *npobj, NPIdentifier name, const NPVariant *args, uint32_t argCount, @@ -199,78 +169,64 @@ NPInvoke(NPObject *npobj, NPIdentifier name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPInvokeDefault -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPInvokeDefault(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPHasProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPHasProperty(NPObject *npobj, NPIdentifier name) { return ((PPToplevelObject *)npobj)->has_property(name); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPGetProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPGetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result) { return ((PPToplevelObject *)npobj)->get_property(name, result); } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPSetProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPSetProperty(NPObject *npobj, NPIdentifier name, const NPVariant *value) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPRemoveProperty -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPRemoveProperty(NPObject *npobj, NPIdentifier name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPEnumerate -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPEnumerate(NPObject *npobj, NPIdentifier **value, uint32_t *count) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PPToplevelObject::NPConstruct -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PPToplevelObject:: NPConstruct(NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result) { - // Not implemented. We don't use this constructor mechanism because - // it wasn't supported on earlier versions of Gecko. Instead, we - // use make_new() to construct PPToplevelObjects via an explicit call to + // Not implemented. We don't use this constructor mechanism because it + // wasn't supported on earlier versions of Gecko. Instead, we use + // make_new() to construct PPToplevelObjects via an explicit call to // construct(). return true; } diff --git a/direct/src/plugin_npapi/ppToplevelObject.h b/direct/src/plugin_npapi/ppToplevelObject.h index a1b291ff95..ad9130c9d1 100644 --- a/direct/src/plugin_npapi/ppToplevelObject.h +++ b/direct/src/plugin_npapi/ppToplevelObject.h @@ -1,29 +1,26 @@ -// Filename: ppToplevelObject.h -// Created by: drose (21Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ppToplevelObject.h + * @author drose + * @date 2009-08-21 + */ #ifndef PPTOPLEVELOBJECT_H #define PPTOPLEVELOBJECT_H #include "nppanda3d_common.h" -//////////////////////////////////////////////////////////////////// -// Class : PPToplevelObject -// Description : This is a special object fed to Mozilla as the -// toplevel scripting object for the instance. It has -// only one property, "main", which corresponds to the -// appRunner.main object from Python. -//////////////////////////////////////////////////////////////////// +/** + * This is a special object fed to Mozilla as the toplevel scripting object + * for the instance. It has only one property, "main", which corresponds to + * the appRunner.main object from Python. + */ class PPToplevelObject : public NPObject { public: static PPToplevelObject *make_new(PPInstance *inst); @@ -77,4 +74,3 @@ public: #include "ppToplevelObject.I" #endif - diff --git a/direct/src/plugin_npapi/startup.cxx b/direct/src/plugin_npapi/startup.cxx index a5bc20341a..8d64c71dc7 100644 --- a/direct/src/plugin_npapi/startup.cxx +++ b/direct/src/plugin_npapi/startup.cxx @@ -1,16 +1,15 @@ -// Filename: startup.cxx -// Created by: drose (17Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file startup.cxx + * @author drose + * @date 2009-06-17 + */ #include "startup.h" #include "p3d_plugin_config.h" @@ -32,13 +31,13 @@ bool has_plugin_thread_async_call; NPNetscapeFuncs *browser; -// These function prototypes changed slightly (but insignificantly) -// between releases of NPAPI. To avoid compilation errors, we use our -// own name, and cast it to the correct type. +// These function prototypes changed slightly (but insignificantly) between +// releases of NPAPI. To avoid compilation errors, we use our own name, and +// cast it to the correct type. static int32_t NPP_WriteReady_x(NPP instance, NPStream *stream); static int32_t -NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, +NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buffer); // open_logfile() also assigns global_root_dir. @@ -48,8 +47,8 @@ open_logfile() { if (!logfile_is_open) { global_root_dir = find_root_dir(); - // Note that this logfile name may not be specified at runtime. It - // must be compiled in if it is specified at all. + // Note that this logfile name may not be specified at runtime. It must + // be compiled in if it is specified at all. string log_directory; // Allow the developer to compile in the log directory. @@ -58,8 +57,8 @@ open_logfile() { log_directory = P3D_PLUGIN_LOG_DIRECTORY; } #endif - - // Failing that, we write logfiles to Panda3D/log. + + // Failing that, we write logfiles to Panda3Dlog. if (log_directory.empty()) { log_directory = global_root_dir + "/log"; } @@ -72,9 +71,9 @@ open_logfile() { #endif log_directory += "/"; } - + // Construct the logfile pathname. - + string log_basename; #ifdef P3D_PLUGIN_LOG_BASENAME1 if (log_basename.empty()) { @@ -102,20 +101,17 @@ open_logfile() { logfile.setf(ios::unitbuf); } - // If we didn't have a logfile name compiled in, we throw away log - // output by the simple expedient of never actually opening the - // ofstream. + // If we didn't have a logfile name compiled in, we throw away log output + // by the simple expedient of never actually opening the ofstream. logfile_is_open = true; } } -//////////////////////////////////////////////////////////////////// -// Function: NP_GetMIMEDescription -// Description: On Unix, this function is called by the browser to -// get the mimetypes and extensions this plugin is -// supposed to handle. -//////////////////////////////////////////////////////////////////// +/** + * On Unix, this function is called by the browser to get the mimetypes and + * extensions this plugin is supposed to handle. + */ #if NP_VERSION_MAJOR == 0 && NP_VERSION_MINOR <= 22 char * #else @@ -125,17 +121,16 @@ NP_GetMIMEDescription(void) { return "application/x-panda3d:p3d:Panda3D applet;"; } -//////////////////////////////////////////////////////////////////// -// Function: NP_GetValue -// Description: On Unix, this function is called by the browser to -// get some information like the name and description. -//////////////////////////////////////////////////////////////////// +/** + * On Unix, this function is called by the browser to get some information + * like the name and description. + */ NPError NP_GetValue(void*, NPPVariable variable, void* value) { if (value == NULL) { return NPERR_INVALID_PARAM; } - + switch (variable) { case NPPVpluginNameString: *(const char **)value = "Panda3D Game Engine Plug-In"; @@ -147,24 +142,22 @@ NP_GetValue(void*, NPPVariable variable, void* value) { nout << "Ignoring GetValue request " << variable << "\n"; return NPERR_INVALID_PARAM; } - + return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NP_Initialize -// Description: This function is called (almost) before any other -// function, to ask the plugin to initialize itself and -// to send the pointers to the browser control -// functions. Also see NP_GetEntryPoints. -//////////////////////////////////////////////////////////////////// +/** + * This function is called (almost) before any other function, to ask the + * plugin to initialize itself and to send the pointers to the browser control + * functions. Also see NP_GetEntryPoints. + */ #ifdef _WIN32 -NPError OSCALL +NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs) #else -// On Mac, the API specifies this second parameter is included, -// but it lies. We actually don't get a second parameter there, -// but we have to put it here to make the compiler happy. +// On Mac, the API specifies this second parameter is included, but it lies. +// We actually don't get a second parameter there, but we have to put it here +// to make the compiler happy. NPError OSCALL NP_Initialize(NPNetscapeFuncs *browserFuncs, NPPluginFuncs *pluginFuncs) @@ -179,8 +172,8 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, nout << "browserFuncs = " << browserFuncs << "\n"; - // On Unix, we have to use the pluginFuncs argument - // to pass our entry points. + // On Unix, we have to use the pluginFuncs argument to pass our entry + // points. #if !defined(_WIN32) && !defined(__APPLE__) if (pluginFuncs != NULL) { NP_GetEntryPoints(pluginFuncs); @@ -210,21 +203,19 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs, } #endif - // Seed the lame random number generator in rand(); we use it to - // select a mirror for downloading. + // Seed the lame random number generator in rand(); we use it to select a + // mirror for downloading. srand((unsigned int)time(NULL)); return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NP_GetEntryPoints -// Description: This method is extracted directly from the DLL and -// called at initialization time by the browser, either -// before or after NP_Initialize, to retrieve the -// pointers to the rest of the plugin functions that are -// not exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This method is extracted directly from the DLL and called at initialization + * time by the browser, either before or after NP_Initialize, to retrieve the + * pointers to the rest of the plugin functions that are not exported from the + * DLL. + */ NPError OSCALL NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { // open_logfile() also assigns global_root_dir. @@ -238,11 +229,11 @@ NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { return NPERR_INVALID_FUNCTABLE_ERROR; } - // Not entirely sure what version number we should send back here. - // Sending the verion number of the NPAPI library we're compiled - // against doesn't seem 100% right, because there's no reason to - // think that *this* code knows about all of the functions provided - // by the particular library version it's compiled against. + // Not entirely sure what version number we should send back here. Sending + // the verion number of the NPAPI library we're compiled against doesn't + // seem 100% right, because there's no reason to think that *this* code + // knows about all of the functions provided by the particular library + // version it's compiled against. pluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; pluginFuncs->newp = NPP_New; @@ -252,9 +243,9 @@ NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { pluginFuncs->destroystream = NPP_DestroyStream; pluginFuncs->asfile = NPP_StreamAsFile; - // WebKit's NPAPI defines the wrong prototype for these functions, - // so we have to cast them. But the casting typename isn't - // consistent between WebKit and Mozilla's NPAPI headers. + // WebKit's NPAPI defines the wrong prototype for these functions, so we + // have to cast them. But the casting typename isn't consistent between + // WebKit and Mozilla's NPAPI headers. #ifdef NewNPP_WriteProc pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady_x); pluginFuncs->write = NewNPP_WriteProc(NPP_Write_x); @@ -272,30 +263,26 @@ NP_GetEntryPoints(NPPluginFuncs *pluginFuncs) { return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NP_Shutdown -// Description: This function is called when the browser is done with -// the plugin; it asks the plugin to unload itself and -// free all used resources. -//////////////////////////////////////////////////////////////////// +/** + * This function is called when the browser is done with the plugin; it asks + * the plugin to unload itself and free all used resources. + */ NPError OSCALL NP_Shutdown(void) { nout << "shutdown\n"; unload_plugin(nout); PPBrowserObject::clear_class_definition(); - // Not clear whether there's a return value or not. Some versions - // of the API have different opinions on this. + // Not clear whether there's a return value or not. Some versions of the + // API have different opinions on this. return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_New -// Description: Called by the browser to create a new instance of the -// plugin. -//////////////////////////////////////////////////////////////////// -NPError -NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, +/** + * Called by the browser to create a new instance of the plugin. + */ +NPError +NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved) { nout << "new instance " << instance << "\n"; @@ -303,14 +290,14 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, P3D_event_type event_type = P3D_ET_none; #ifdef __APPLE__ - // The default drawing model for Apple is via the deprecated - // QuickDraw GrafPtr, and the default event model is via the - // deprecated Carbon EventRecord. + // The default drawing model for Apple is via the deprecated QuickDraw + // GrafPtr, and the default event model is via the deprecated Carbon + // EventRecord. window_handle_type = P3D_WHT_osx_port; event_type = P3D_ET_osx_event_record; - // But we have to request the CoreGraphics drawing model to be - // compatible with Snow Leopard. + // But we have to request the CoreGraphics drawing model to be compatible + // with Snow Leopard. NPBool supports_core_graphics = false; #ifdef MACOSX_HAS_COREGRAPHICS_DRAWING_MODEL NPError err = browser->getvalue(instance, @@ -361,28 +348,27 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, instance->pdata = inst; nout << "new instance->pdata = " << inst << "\n"; - // To experiment with a "windowless" plugin, which really means we - // create our own window without an intervening window, try this. - //browser->setvalue(instance, NPPVpluginWindowBool, (void *)false); + // To experiment with a "windowless" plugin, which really means we create + // our own window without an intervening window, try this. + // browser->setvalue(instance, NPPVpluginWindowBool, (void *)false); - // Now that we have stored the pointer, we can call begin(), which - // starts to initiate downloads. + // Now that we have stored the pointer, we can call begin(), which starts to + // initiate downloads. inst->begin(); return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_Destroy -// Description: Called by the browser to destroy an instance of the -// plugin previously created with NPP_New. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to destroy an instance of the plugin previously + * created with NPP_New. + */ NPError NPP_Destroy(NPP instance, NPSavedData **save) { nout << "destroy instance " << instance << ", " << (PPInstance *)instance->pdata << "\n"; nout << "save = " << (void *)save << "\n"; - // (*save) = NULL; + // (*save) = NULL; PPInstance *inst = (PPInstance *)(instance->pdata); assert(inst != NULL); inst->stop_outstanding_streams(); @@ -393,14 +379,12 @@ NPP_Destroy(NPP instance, NPSavedData **save) { return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_SetWindow -// Description: Called by the browser to inform the instance of its -// window size and placement. This is called initially -// to create the window, and may be called subsequently -// when the window needs to be moved. It may be called -// redundantly. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to inform the instance of its window size and + * placement. This is called initially to create the window, and may be + * called subsequently when the window needs to be moved. It may be called + * redundantly. + */ NPError NPP_SetWindow(NPP instance, NPWindow *window) { nout << "SetWindow " << window->x << ", " << window->y @@ -414,21 +398,19 @@ NPP_SetWindow(NPP instance, NPWindow *window) { return NPERR_NO_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_NewStream -// Description: Called by the browser when a new data stream is -// created, usually in response to a geturl request; but -// it is also called initially to supply the data in the -// data or src element. The plugin must specify how it -// can receive the stream. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser when a new data stream is created, usually in + * response to a geturl request; but it is also called initially to supply the + * data in the data or src element. The plugin must specify how it can + * receive the stream. + */ NPError -NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, +NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16_t *stype) { nout << "NewStream " << type << ": " << (void *)stream - << ", " << stream->url << ", size = " << stream->end + << ", " << stream->url << ", size = " << stream->end << ", notifyData = " << stream->notifyData - << ", for " << instance + << ", for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); @@ -437,17 +419,15 @@ NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, return inst->new_stream(type, stream, seekable != 0, stype); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_DestroyStream -// Description: Called by the browser to mark the end of a stream -// created with NewStream. -//////////////////////////////////////////////////////////////////// -NPError +/** + * Called by the browser to mark the end of a stream created with NewStream. + */ +NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { - nout << "DestroyStream: " << (void *)stream << ", " << stream->url + nout << "DestroyStream: " << (void *)stream << ", " << stream->url << ", notifyData = " << stream->notifyData << ", reason = " << reason - << ", for " << instance + << ", for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); @@ -457,14 +437,13 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) { return inst->destroy_stream(stream, reason); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_WriteReady -// Description: Called by the browser to ask how many bytes it can -// deliver for a stream. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to ask how many bytes it can deliver for a stream. + */ int32_t NPP_WriteReady_x(NPP instance, NPStream *stream) { - // nout << "WriteReady " << stream->url << " for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; + // nout << "WriteReady " << stream->url << " for " << instance << ", " << + // (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); assert(inst != NULL); @@ -472,16 +451,15 @@ NPP_WriteReady_x(NPP instance, NPStream *stream) { return inst->write_ready(stream); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_Write -// Description: Called by the browser to deliver bytes for the -// stream; the plugin should return the number of bytes -// consumed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to deliver bytes for the stream; the plugin should + * return the number of bytes consumed. + */ int32_t -NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, +NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buffer) { - // nout << "Write " << stream->url << ", " << offset << ", " << len << " for " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; + // nout << "Write " << stream->url << ", " << offset << ", " << len << " for + // " << instance << ", " << (PPInstance *)(instance->pdata) << "\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); assert(inst != NULL); @@ -489,17 +467,15 @@ NPP_Write_x(NPP instance, NPStream *stream, int32_t offset, return inst->write_stream(stream, offset, len, buffer); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_StreamAsFile -// Description: Called by the browser to report the filename that -// contains the fully-downloaded stream, if -// NP_ASFILEONLY was specified by the plugin in -// NPP_NewStream. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to report the filename that contains the fully- + * downloaded stream, if NP_ASFILEONLY was specified by the plugin in + * NPP_NewStream. + */ void NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { - nout << "StreamAsFile " << stream->url - << ", " << stream->end + nout << "StreamAsFile " << stream->url + << ", " << stream->end << ", notifyData = " << stream->notifyData << "\n"; @@ -510,24 +486,21 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) { inst->stream_as_file(stream, fname); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_Print -// Description: Called by the browser when the user attempts to print -// the page containing the plugin instance. -//////////////////////////////////////////////////////////////////// -void +/** + * Called by the browser when the user attempts to print the page containing + * the plugin instance. + */ +void NPP_Print(NPP instance, NPPrint *platformPrint) { nout << "Print\n"; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_HandleEvent -// Description: Called by the browser to inform the plugin of OS -// window events. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to inform the plugin of OS window events. + */ int16_t NPP_HandleEvent(NPP instance, void *event) { - // nout << "HandleEvent\n"; + // nout << "HandleEvent\n"; PPInstance::generic_browser_call(); PPInstance *inst = (PPInstance *)(instance->pdata); @@ -536,15 +509,13 @@ NPP_HandleEvent(NPP instance, void *event) { return inst->handle_event(event); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_URLNotify -// Description: Called by the browser to inform the plugin of a -// completed URL request. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to inform the plugin of a completed URL request. + */ void NPP_URLNotify(NPP instance, const char *url, NPReason reason, void *notifyData) { - nout << "URLNotify: " << url + nout << "URLNotify: " << url << ", notifyData = " << notifyData << ", reason = " << reason << "\n"; @@ -556,11 +527,9 @@ NPP_URLNotify(NPP instance, const char *url, inst->url_notify(url, reason, notifyData); } -//////////////////////////////////////////////////////////////////// -// Function: NPP_GetValue -// Description: Called by the browser to query specific information -// from the plugin. -//////////////////////////////////////////////////////////////////// +/** + * Called by the browser to query specific information from the plugin. + */ NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { nout << "GetValue " << variable << "\n"; @@ -579,9 +548,8 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { // If we have Gtk2 available, we can use it to support the XEmbed // protocol, which Chromium (at least) requires. - // In this case, we'll say we can do it, if the browser supports - // it. (Though probably the browser wouldn't be asking if it - // couldn't.) + // In this case, we'll say we can do it, if the browser supports it. + // (Though probably the browser wouldn't be asking if it couldn't.) NPBool supports_xembed = false; NPError err = browser->getvalue(instance, NPNVSupportsXEmbedBool, &supports_xembed); @@ -609,14 +577,12 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) { return NPERR_GENERIC_ERROR; } -//////////////////////////////////////////////////////////////////// -// Function: NPP_SetValue -// Description: Called by the browser to update a scriptable value. -//////////////////////////////////////////////////////////////////// -NPError +/** + * Called by the browser to update a scriptable value. + */ +NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { nout << "SetValue " << variable << "\n"; PPInstance::generic_browser_call(); return NPERR_GENERIC_ERROR; } - diff --git a/direct/src/plugin_npapi/startup.h b/direct/src/plugin_npapi/startup.h index e8b9162a04..e996f58084 100644 --- a/direct/src/plugin_npapi/startup.h +++ b/direct/src/plugin_npapi/startup.h @@ -1,16 +1,15 @@ -// Filename: startup.h -// Created by: drose (19Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file startup.h + * @author drose + * @date 2009-06-19 + */ #ifndef STARTUP_H #define STARTUP_H diff --git a/direct/src/plugin_standalone/p3dEmbed.cxx b/direct/src/plugin_standalone/p3dEmbed.cxx index a09c13423b..87918f66f4 100644 --- a/direct/src/plugin_standalone/p3dEmbed.cxx +++ b/direct/src/plugin_standalone/p3dEmbed.cxx @@ -1,16 +1,15 @@ -// Filename: p3dEmbed.cxx -// Created by: rdb (07Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dEmbed.cxx + * @author rdb + * @date 2009-12-07 + */ #define P3D_FUNCTION_PROTOTYPES @@ -18,39 +17,35 @@ #include "load_plugin.h" #include "find_root_dir.h" -//////////////////////////////////////////////////////////////////// -// Function: P3DEmbed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ P3DEmbed:: P3DEmbed(bool console_environment) : Panda3DBase(console_environment) { - // Since the Panda3DBase constructor no longer assigns _root_dir, we - // have to do it here. + // Since the Panda3DBase constructor no longer assigns _root_dir, we have to + // do it here. _root_dir = find_root_dir(); - - // We should leave the arguments intact, just pass them - // 1:1 as we've received them. + + // We should leave the arguments intact, just pass them 1:1 as we've + // received them. _prepend_filename_to_args = false; } -//////////////////////////////////////////////////////////////////// -// Function: P3DEmbed::run_embedded -// Access: Public -// Description: Runs with the data embedded in the current -// executable, at the specified offset. -//////////////////////////////////////////////////////////////////// +/** + * Runs with the data embedded in the current executable, at the specified + * offset. + */ int P3DEmbed:: run_embedded(streampos read_offset, int argc, char *argv[]) { - // Check to see if we've actually got an application embedded. If - // we do, read_offset will have been modified to contain a different - // value than the one we compiled in, above. We test against - // read_offset + 1, because any appearances of this exact number - // within the binary will be replaced (including this one). + // Check to see if we've actually got an application embedded. If we do, + // read_offset will have been modified to contain a different value than the + // one we compiled in, above. We test against read_offset + 1, because any + // appearances of this exact number within the binary will be replaced + // (including this one). - // We also have to store this computation in a member variable, to - // work around a compiler optimization that might otherwise remove - // the + 1 from the test. + // We also have to store this computation in a member variable, to work + // around a compiler optimization that might otherwise remove the + 1 from + // the test. _read_offset_check = read_offset + (streampos)1; if (_read_offset_check == (streampos)0xFF3D3D01) { cerr << "This program is not intended to be run directly.\nIt is used " @@ -160,8 +155,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { curchr = read.get(); } - // Update the offset to the current read pointer. - // This is where the multifile really starts. + // Update the offset to the current read pointer. This is where the + // multifile really starts. read_offset = read.tellg(); read.close(); @@ -171,7 +166,7 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { root_dir_f.make_absolute(f.get_dirname()); _root_dir = root_dir_f.to_os_specific(); } - + // Make the host directory absolute if (!host_dir.empty()) { Filename host_dir_f(host_dir); @@ -228,8 +223,8 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { P3D_instance_feed_url_stream_ptr = &P3D_instance_feed_url_stream; P3D_instance_handle_event_ptr = &P3D_instance_handle_event; - // Calling the executable with --prep just prepares the directory - // structure, this is usually invoked in the installer. + // Calling the executable with --prep just prepares the directory structure, + // this is usually invoked in the installer. if (argc == 2 && strcmp(argv[1], "--prep") == 0) { cerr << "Invoking the prepare step is deprecated, please rebuild the application using a more recent version of pdeploy\n"; _window_type = P3D_WT_hidden; @@ -243,9 +238,9 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { _tokens.push_back(token); } - // Now call init_plugin() to verify that we got all of the required - // function pointers. This will also call P3D_initialize(). - if (!init_plugin("", _host_url, _verify_contents, _this_platform, + // Now call init_plugin() to verify that we got all of the required function + // pointers. This will also call P3D_initialize(). + if (!init_plugin("", _host_url, _verify_contents, _this_platform, _log_dirname, _log_basename, true, _console_environment, _root_dir, _host_dir, _start_dir, cerr)) { cerr << "Unable to launch core API\n"; @@ -255,7 +250,7 @@ run_embedded(streampos read_offset, int argc, char *argv[]) { // Create a plugin instance and run the program P3D_instance *inst = create_instance(f, true, argv, argc, read_offset); _instances.insert(inst); - + run_main_loop(); unload_plugin(cerr); diff --git a/direct/src/plugin_standalone/p3dEmbed.h b/direct/src/plugin_standalone/p3dEmbed.h index 1dca69f100..98a73ec8fc 100644 --- a/direct/src/plugin_standalone/p3dEmbed.h +++ b/direct/src/plugin_standalone/p3dEmbed.h @@ -1,16 +1,15 @@ -// Filename: p3dEmbed.h -// Created by: drose (04Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dEmbed.h + * @author drose + * @date 2010-01-04 + */ #ifndef P3DEMBED_H #define P3DEMBED_H @@ -28,11 +27,10 @@ #include "pset.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : P3DEmbed -// Description : This program is constructed to self-embed a p3d file -// and execute it directly. -//////////////////////////////////////////////////////////////////// +/** + * This program is constructed to self-embed a p3d file and execute it + * directly. + */ class P3DEmbed : public Panda3DBase { public: P3DEmbed(bool console_environment); diff --git a/direct/src/plugin_standalone/p3dEmbedMain.cxx b/direct/src/plugin_standalone/p3dEmbedMain.cxx index 27db63cd78..0aa3d2eb35 100644 --- a/direct/src/plugin_standalone/p3dEmbedMain.cxx +++ b/direct/src/plugin_standalone/p3dEmbedMain.cxx @@ -1,16 +1,15 @@ -// Filename: p3dEmbedMain.cxx -// Created by: drose (04Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file p3dEmbedMain.cxx + * @author drose + * @date 2010-01-04 + */ #include "p3dEmbed.h" @@ -34,4 +33,3 @@ main(int argc, char *argv[]) { #endif return program.run_embedded(p3d_offset, argc, argv); } - diff --git a/direct/src/plugin_standalone/panda3d.I b/direct/src/plugin_standalone/panda3d.I index 54cac83e3b..ba15732f4d 100644 --- a/direct/src/plugin_standalone/panda3d.I +++ b/direct/src/plugin_standalone/panda3d.I @@ -1,13 +1,12 @@ -// Filename: panda3d.I -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3d.I + * @author drose + * @date 2009-06-30 + */ diff --git a/direct/src/plugin_standalone/panda3d.cxx b/direct/src/plugin_standalone/panda3d.cxx index 065a2afe31..10876d2e64 100644 --- a/direct/src/plugin_standalone/panda3d.cxx +++ b/direct/src/plugin_standalone/panda3d.cxx @@ -1,16 +1,15 @@ -// Filename: panda3d.cxx -// Created by: drose (03Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3d.cxx + * @author drose + * @date 2009-06-03 + */ #include "panda3d.h" #include "load_plugin.h" @@ -30,33 +29,28 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Panda3D:: Panda3D(bool console_environment) : Panda3DBase(console_environment) { - // We use the runtime PandaSystem setting for this value, rather - // than the hard-compiled-in setting, to allow users to override - // this with a Config.prc variable if needed. + // We use the runtime PandaSystem setting for this value, rather than the + // hard-compiled-in setting, to allow users to override this with a + // Config.prc variable if needed. _host_url = PandaSystem::get_package_host_url(); } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::run_command_line -// Access: Public -// Description: Starts the program going, with command-line arguments. -// Returns 0 on success, nonzero on failure. -//////////////////////////////////////////////////////////////////// +/** + * Starts the program going, with command-line arguments. Returns 0 on + * success, nonzero on failure. + */ int Panda3D:: run_command_line(int argc, char *argv[]) { extern char *optarg; extern int optind; - // We prefix a "+" sign to tell getopt not to parse options - // following the first not-option parameter. (These will be passed - // into the sub-process.) + // We prefix a "+" sign to tell getopt not to parse options following the + // first not-option parameter. (These will be passed into the sub-process.) const char *optstr = "+mu:M:Sp:nfw:t:s:o:l:iVUPh"; bool allow_multiple = false; @@ -146,10 +140,9 @@ run_command_line(int argc, char *argv[]) { token._value = "1"; _tokens.push_back(token); - // We should also ignore control-C in this case, so that an - // interrupt will be delivered to the subordinate Python - // process and return to a command shell, and won't just kill - // the panda3d process. + // We should also ignore control-C in this case, so that an interrupt + // will be delivered to the subordinate Python process and return to a + // command shell, and won't just kill the panda3d process. #ifdef _WIN32 SetConsoleCtrlHandler(NULL, true); #else @@ -212,79 +205,79 @@ run_command_line(int argc, char *argv[]) { instance_filenames = argv + 1; num_instance_args = 0; instance_args = argv + argc; - + } else { - // Without -m, there is one instance filename, and everything else - // gets delivered to that instance. + // Without -m, there is one instance filename, and everything else gets + // delivered to that instance. num_instance_filenames = 1; instance_filenames = argv + 1; num_instance_args = argc - 2; instance_args = argv + 2; } - + if (_window_type == P3D_WT_embedded) { - // The user asked for an embedded window. Create a toplevel - // window to be its parent, of the requested size. + // The user asked for an embedded window. Create a toplevel window to + // be its parent, of the requested size. if (_win_width == 0 && _win_height == 0) { _win_width = 800; _win_height = 600; } - + make_parent_window(); - + // Center the child window(s) within the parent window. #ifdef _WIN32 assert(_parent_window._window_handle_type == P3D_WHT_win_hwnd); HWND parent_hwnd = _parent_window._handle._win_hwnd._hwnd; - + RECT rect; GetClientRect(parent_hwnd, &rect); - + _win_x = (int)(rect.right * 0.1); _win_y = (int)(rect.bottom * 0.1); _win_width = (int)(rect.right * 0.8); _win_height = (int)(rect.bottom * 0.8); #endif - + // Subdivide the window into num_x_spans * num_y_spans sub-windows. int num_y_spans = int(sqrt((double)num_instance_filenames)); int num_x_spans = (num_instance_filenames + num_y_spans - 1) / num_y_spans; - + int origin_x = _win_x; int origin_y = _win_y; _win_width = _win_width / num_x_spans; _win_height = _win_height / num_y_spans; _got_win_size = true; - + for (int yi = 0; yi < num_y_spans; ++yi) { for (int xi = 0; xi < num_x_spans; ++xi) { int i = yi * num_x_spans + xi; if (i >= num_instance_filenames) { continue; } - + // Create instance i at window slot (xi, yi). _win_x = origin_x + xi * _win_width; _win_y = origin_y + yi * _win_height; - + P3D_instance *inst = create_instance (instance_filenames[i], true, instance_args, num_instance_args); _instances.insert(inst); } } - + } else { // Not an embedded window. Create each window with the same parameters. for (int i = 0; i < num_instance_filenames; ++i) { P3D_instance *inst = create_instance - (instance_filenames[i], true, + (instance_filenames[i], true, instance_args, num_instance_args); _instances.insert(inst); } } } - + run_main_loop(); // All instances have finished; we can exit. @@ -292,13 +285,10 @@ run_command_line(int argc, char *argv[]) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::post_arg_processing -// Access: Protected -// Description: Sets up some internal state after processing the -// command-line arguments. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Sets up some internal state after processing the command-line arguments. + * Returns true on success, false on failure. + */ bool Panda3D:: post_arg_processing() { // Now is a good time to assign _root_dir. @@ -311,7 +301,7 @@ post_arg_processing() { } _download_url_prefix = _host_url_prefix; - // If the "super mirror" URL is a filename, convert it to a file:// url. + // If the "super mirror" URL is a filename, convert it to a file: url. if (!_super_mirror_url.empty()) { if (!is_url(_super_mirror_url)) { Filename filename = Filename::from_os_specific(_super_mirror_url); @@ -345,13 +335,10 @@ post_arg_processing() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::get_plugin -// Access: Protected -// Description: Downloads the contents.xml file from the named URL -// and attempts to use it to load the core API. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Downloads the contents.xml file from the named URL and attempts to use it + * to load the core API. Returns true on success, false on failure. + */ bool Panda3D:: get_plugin() { // First, look for the existing contents.xml file. @@ -369,8 +356,7 @@ get_plugin() { } if (!success) { - // Couldn't read it (or it wasn't current enough), so go get a new - // one. + // Couldn't read it (or it wasn't current enough), so go get a new one. if (!download_contents_file(contents_filename)) { // We don't have a usable contents.xml file. return false; @@ -378,8 +364,8 @@ get_plugin() { is_fresh = true; } - // Now that we've downloaded the contents file successfully, start - // the Core API. + // Now that we've downloaded the contents file successfully, start the Core + // API. if (!get_core_api()) { // We failed. Make sure contents.xml is up-to-date and try again. if (!is_fresh && download_contents_file(contents_filename) && get_core_api()) { @@ -392,14 +378,11 @@ get_plugin() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::download_contents_file -// Access: Protected -// Description: Redownloads the contents.xml file from the named -// URL without first checking if it is up to date. -// Returns true if we have a contents.xml file that -// might be usable, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Redownloads the contents.xml file from the named URL without first checking + * if it is up to date. Returns true if we have a contents.xml file that + * might be usable, false otherwise. + */ bool Panda3D:: download_contents_file(const Filename &contents_filename) { bool success = false; @@ -408,9 +391,8 @@ download_contents_file(const Filename &contents_filename) { // Try the super_mirror first. if (!_super_mirror_url_prefix.empty()) { // We don't bother putting a uniquifying query string when we're - // downloading this file from the super_mirror. The super_mirror - // is by definition a cache, so it doesn't make sense to bust - // caches here. + // downloading this file from the super_mirror. The super_mirror is by + // definition a cache, so it doesn't make sense to bust caches here. string url = _super_mirror_url_prefix + "contents.xml"; PT(HTTPChannel) channel = http->make_channel(false); channel->get_document(url); @@ -430,22 +412,22 @@ download_contents_file(const Filename &contents_filename) { // Go download contents.xml from the actual host. ostringstream strm; strm << _host_url_prefix << "contents.xml"; - // Append a uniquifying query string to the URL to force the - // download to go all the way through any caches. We use the time - // in seconds; that's unique enough. + // Append a uniquifying query string to the URL to force the download to + // go all the way through any caches. We use the time in seconds; that's + // unique enough. strm << "?" << time(NULL); string url = strm.str(); - // We might as well explicitly request the cache to be disabled too, - // since we have an interface for that via HTTPChannel. + // We might as well explicitly request the cache to be disabled too, since + // we have an interface for that via HTTPChannel. DocumentSpec request(url); request.set_cache_control(DocumentSpec::CC_no_cache); PT(HTTPChannel) channel = http->make_channel(false); channel->get_document(request); - // Since we have to download some of it, might as well ask the core - // API to check all of it. + // Since we have to download some of it, might as well ask the core API to + // check all of it. if (_verify_contents == P3D_VC_none) { _verify_contents = P3D_VC_normal; } @@ -455,8 +437,8 @@ download_contents_file(const Filename &contents_filename) { if (!channel->download_to_file(tempfile)) { cerr << "Unable to download " << url << "\n"; - // Couldn't download, but try to read the existing contents.xml - // file anyway. Maybe it's good enough. + // Couldn't download, but try to read the existing contents.xml file + // anyway. Maybe it's good enough. success = read_contents_file(contents_filename, false); } else { @@ -470,14 +452,11 @@ download_contents_file(const Filename &contents_filename) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::read_contents_file -// Access: Protected -// Description: Attempts to open and read the contents.xml file on -// disk. Copies the file to its standard location -// on success. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open and read the contents.xml file on disk. Copies the file + * to its standard location on success. Returns true on success, false on + * failure. + */ bool Panda3D:: read_contents_file(const Filename &contents_filename, bool fresh_download) { string os_contents_filename = contents_filename.to_os_specific(); @@ -508,7 +487,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { xorig = new TiXmlElement("orig"); xcontents->LinkEndChild(xorig); - + xorig->SetAttribute("expiration", (int)_contents_expiration); } else { @@ -518,12 +497,12 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { if (xorig != NULL) { xorig->Attribute("expiration", &expiration); } - + _contents_expiration = min(_contents_expiration, (time_t)expiration); } - // Look for the entry; it might point us at a different - // download URL, and it might mention some mirrors. + // Look for the entry; it might point us at a different download + // URL, and it might mention some mirrors. find_host(xcontents); // Now look for the core API package. @@ -543,7 +522,7 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { break; } } - + xpackage = xpackage->NextSiblingElement("package"); } } @@ -555,9 +534,9 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { return false; } - // Check the coreapi_set_ver token. If it is given, it specifies a - // minimum Core API version number we expect to find. If we didn't - // find that number, perhaps our contents.xml is out of date. + // Check the coreapi_set_ver token. If it is given, it specifies a minimum + // Core API version number we expect to find. If we didn't find that + // number, perhaps our contents.xml is out of date. string coreapi_set_ver = lookup_token("coreapi_set_ver"); if (!coreapi_set_ver.empty()) { nout << "Instance asked for Core API set_ver " << coreapi_set_ver @@ -565,8 +544,8 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { // But don't bother if we just freshly downloaded it. if (!fresh_download) { if (compare_seq(coreapi_set_ver, _coreapi_set_ver) > 0) { - // The requested set_ver value is higher than the one we have on - // file; our contents.xml file must be out of date after all. + // The requested set_ver value is higher than the one we have on file; + // our contents.xml file must be out of date after all. nout << "expiring contents.xml\n"; _contents_expiration = 0; } @@ -598,12 +577,9 @@ read_contents_file(const Filename &contents_filename, bool fresh_download) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::find_host -// Access: Protected -// Description: Scans the element for the matching -// element. -//////////////////////////////////////////////////////////////////// +/** + * Scans the element for the matching element. + */ void Panda3D:: find_host(TiXmlElement *xcontents) { TiXmlElement *xhost = xcontents->FirstChildElement("host"); @@ -613,7 +589,7 @@ find_host(TiXmlElement *xcontents) { // We're the primary host. This is the normal case. read_xhost(xhost); return; - + } else { // We're not the primary host; perhaps we're an alternate host. TiXmlElement *xalthost = xhost->FirstChildElement("alt_host"); @@ -628,22 +604,20 @@ find_host(TiXmlElement *xcontents) { } } - // Hmm, didn't find the URL we used mentioned. Assume we're the - // primary host. + // Hmm, didn't find the URL we used mentioned. Assume we're the primary + // host. read_xhost(xhost); } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::read_xhost -// Access: Protected -// Description: Reads the host data from the (or ) -// entry in the contents.xml file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the host data from the (or ) entry in the + * contents.xml file. + */ void Panda3D:: read_xhost(TiXmlElement *xhost) { - // Get the "download" URL, which is the source from which we - // download everything other than the contents.xml file. + // Get the "download" URL, which is the source from which we download + // everything other than the contents.xml file. const char *download_url = xhost->Attribute("download_url"); if (download_url == NULL) { download_url = xhost->Attribute("url"); @@ -659,7 +633,7 @@ read_xhost(TiXmlElement *xhost) { _download_url_prefix += "/"; } } - + TiXmlElement *xmirror = xhost->FirstChildElement("mirror"); while (xmirror != NULL) { const char *url = xmirror->Attribute("url"); @@ -670,35 +644,28 @@ read_xhost(TiXmlElement *xhost) { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::add_mirror -// Access: Protected -// Description: Adds a new URL to serve as a mirror for this host. -// The mirrors will be consulted first, before -// consulting the host directly. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new URL to serve as a mirror for this host. The mirrors will be + * consulted first, before consulting the host directly. + */ void Panda3D:: add_mirror(string mirror_url) { // Ensure the URL ends in a slash. if (!mirror_url.empty() && mirror_url[mirror_url.size() - 1] != '/') { mirror_url += '/'; } - - // Add it to the _mirrors list, but only if it's not already - // there. + + // Add it to the _mirrors list, but only if it's not already there. if (find(_mirrors.begin(), _mirrors.end(), mirror_url) == _mirrors.end()) { _mirrors.push_back(mirror_url); } } - -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::choose_random_mirrors -// Access: Public -// Description: Selects num_mirrors elements, chosen at random, from -// the _mirrors list. Adds the selected mirrors to -// result. If there are fewer than num_mirrors elements -// in the list, adds only as many mirrors as we can get. -//////////////////////////////////////////////////////////////////// + +/** + * Selects num_mirrors elements, chosen at random, from the _mirrors list. + * Adds the selected mirrors to result. If there are fewer than num_mirrors + * elements in the list, adds only as many mirrors as we can get. + */ void Panda3D:: choose_random_mirrors(vector_string &result, int num_mirrors) { pvector selected; @@ -716,13 +683,10 @@ choose_random_mirrors(vector_string &result, int num_mirrors) { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::get_core_api -// Access: Protected -// Description: Checks the core API DLL file against the -// specification in the contents file, and downloads it -// if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Checks the core API DLL file against the specification in the contents + * file, and downloads it if necessary. + */ bool Panda3D:: get_core_api() { bool is_fresh = false; @@ -737,11 +701,10 @@ get_core_api() { string pathname = _coreapi_dll.get_pathname(_root_dir); #ifdef P3D_PLUGIN_P3D_PLUGIN - // This is a convenience macro for development. If defined and - // nonempty, it indicates the name of the plugin DLL that we will - // actually run, even after downloading a possibly different - // (presumably older) version. Its purpose is to simplify iteration - // on the plugin DLL. + // This is a convenience macro for development. If defined and nonempty, it + // indicates the name of the plugin DLL that we will actually run, even + // after downloading a possibly different (presumably older) version. Its + // purpose is to simplify iteration on the plugin DLL. string override_filename = P3D_PLUGIN_P3D_PLUGIN; if (!override_filename.empty()) { pathname = override_filename; @@ -756,8 +719,8 @@ get_core_api() { _log_basename, trusted_environment, _console_environment, _root_dir, _host_dir, _start_dir, cerr)) { - // If we're not sure this is the latest version, make sure it is - // up-to-date, and then try again. + // If we're not sure this is the latest version, make sure it is up-to- + // date, and then try again. if (is_fresh || !download_core_api() || !load_plugin(pathname, contents_filename.to_os_specific(), _host_url, _verify_contents, _this_platform, _log_dirname, @@ -776,8 +739,7 @@ get_core_api() { static const bool official = false; #endif - // Format the coreapi_timestamp as a string, for passing as a - // parameter. + // Format the coreapi_timestamp as a string, for passing as a parameter. ostringstream stream; stream << _coreapi_dll.get_timestamp(); string coreapi_timestamp = stream.str(); @@ -791,29 +753,25 @@ get_core_api() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::download_core_api -// Access: Protected -// Description: Downloads the latest version of the core API from -// the plug-in server. -//////////////////////////////////////////////////////////////////// +/** + * Downloads the latest version of the core API from the plug-in server. + */ bool Panda3D:: download_core_api() { - // The DLL file needs to be downloaded. Build up our list of - // URL's to attempt to download it from, in reverse order. + // The DLL file needs to be downloaded. Build up our list of URL's to + // attempt to download it from, in reverse order. string url; vector_string core_urls; - // Our last act of desperation: hit the original host, with a - // query uniquifier, to break through any caches. + // Our last act of desperation: hit the original host, with a query + // uniquifier, to break through any caches. ostringstream strm; strm << _download_url_prefix << _coreapi_dll.get_filename() << "?" << time(NULL); url = strm.str(); core_urls.push_back(url); - // Before we try that, we'll hit the original host, without a - // uniquifier. + // Before we try that, we'll hit the original host, without a uniquifier. url = _download_url_prefix; url += _coreapi_dll.get_filename(); core_urls.push_back(url); @@ -828,15 +786,13 @@ download_core_api() { core_urls.push_back(url); } - // The very first thing we'll try is the super_mirror, if we have - // one. + // The very first thing we'll try is the super_mirror, if we have one. if (!_super_mirror_url_prefix.empty()) { url = _super_mirror_url_prefix + _coreapi_dll.get_filename(); core_urls.push_back(url); } - // Now pick URL's off the list, and try them, until we have - // success. + // Now pick URL's off the list, and try them, until we have success. Filename pathname = Filename::from_os_specific(_coreapi_dll.get_pathname(_root_dir)); pathname.make_dir(); HTTPClient *http = HTTPClient::get_global_ptr(); @@ -864,23 +820,21 @@ download_core_api() { return false; } - // Since we had to download some of it, might as well ask the core - // API to check all of it. + // Since we had to download some of it, might as well ask the core API to + // check all of it. if (_verify_contents == P3D_VC_none) { _verify_contents = P3D_VC_normal; } return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3D::usage -// Access: Protected -// Description: Reports the available command-line options. -//////////////////////////////////////////////////////////////////// +/** + * Reports the available command-line options. + */ void Panda3D:: usage() { cerr - << "\nThis is panda3d version " + << "\nThis is panda3d version " << P3D_PLUGIN_MAJOR_VERSION << "." << P3D_PLUGIN_MINOR_VERSION << "." << P3D_PLUGIN_SEQUENCE_VERSION; @@ -892,7 +846,7 @@ usage() { << "\n\nUsage:\n" << " panda3d [opts] file.p3d [args]\n" << " panda3d -m [opts] file_a.p3d file_b.p3d [file_c.p3d ...]\n\n" - + << "This program is used to execute a Panda3D application bundle stored\n" << "in a .p3d file. In the first form, without the -m option, it\n" << "executes one application; remaining arguments following the\n" diff --git a/direct/src/plugin_standalone/panda3d.h b/direct/src/plugin_standalone/panda3d.h index 2f902bac6e..8333177bb2 100644 --- a/direct/src/plugin_standalone/panda3d.h +++ b/direct/src/plugin_standalone/panda3d.h @@ -1,16 +1,15 @@ -// Filename: panda3d.h -// Created by: drose (30Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3d.h + * @author drose + * @date 2009-06-30 + */ #ifndef PANDA3D_H #define PANDA3D_H @@ -28,11 +27,9 @@ #include "pset.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : Panda3D -// Description : A standalone program that invokes the Panda3D plugin -// to launch .p3d files. -//////////////////////////////////////////////////////////////////// +/** + * A standalone program that invokes the Panda3D plugin to launch .p3d files. + */ class Panda3D : public Panda3DBase { public: Panda3D(bool console_environment); @@ -60,7 +57,7 @@ protected: string _super_mirror_url_prefix; typedef pvector Mirrors; Mirrors _mirrors; - + string _coreapi_set_ver; FileSpec _coreapi_dll; }; @@ -68,4 +65,3 @@ protected: #include "panda3d.I" #endif - diff --git a/direct/src/plugin_standalone/panda3dBase.I b/direct/src/plugin_standalone/panda3dBase.I index d31dea20be..f875229f2d 100644 --- a/direct/src/plugin_standalone/panda3dBase.I +++ b/direct/src/plugin_standalone/panda3dBase.I @@ -1,36 +1,28 @@ -// Filename: panda3dBase.I -// Created by: pro-rsoft (07Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dBase.I + * @author rdb + * @date 2009-12-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::time_to_exit -// Access: Public -// Description: Returns true if it is time to exit because the last -// instance has exited, or false if we should continue -// running. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is time to exit because the last instance has exited, or + * false if we should continue running. + */ bool Panda3DBase:: time_to_exit() { return _instances.empty() && _exit_with_last_instance; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::URLGetter::get_instance -// Access: Public -// Description: Returns the P3D_instance associated with this -// URLGetter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the P3D_instance associated with this URLGetter. + */ P3D_instance *Panda3DBase::URLGetter:: get_instance() { return _instance; diff --git a/direct/src/plugin_standalone/panda3dBase.cxx b/direct/src/plugin_standalone/panda3dBase.cxx index 707eddedd2..0b3884f17c 100644 --- a/direct/src/plugin_standalone/panda3dBase.cxx +++ b/direct/src/plugin_standalone/panda3dBase.cxx @@ -1,16 +1,15 @@ -// Filename: panda3dBase.cxx -// Created by: pro-rsoft (07Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dBase.cxx + * @author rdb + * @date 2009-12-07 + */ #include "dtoolbase.h" #ifdef _WIN32 @@ -27,8 +26,8 @@ #include "multifile.h" #include "tinyxml.h" -// We can include this header file to get the DTOOL_PLATFORM -// definition, even though we don't link with dtool. +// We can include this header file to get the DTOOL_PLATFORM definition, even +// though we don't link with dtool. #include "dtool_platform.h" #include "pandaVersion.h" @@ -39,21 +38,18 @@ // The amount of time in seconds to wait for new messages. static const double wait_cycle = 0.2; -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Panda3DBase:: Panda3DBase(bool console_environment) { _console_environment = console_environment; - // We can't assign _root_dir immediately, because it requires a - // low-level Mac call that will balk if we're not logged in to the - // console, which will prevent scripts from using "panda3d -P" to - // find the platform and whatnot. Instead, we'll assign it after - // we've processed the command line. - //_root_dir = find_root_dir(); + // We can't assign _root_dir immediately, because it requires a low-level + // Mac call that will balk if we're not logged in to the console, which will + // prevent scripts from using "panda3d -P" to find the platform and whatnot. + // Instead, we'll assign it after we've processed the command line. + // _root_dir = find_root_dir(); _reporting_download = false; _enable_security = false; @@ -68,34 +64,30 @@ Panda3DBase(bool console_environment) { _exit_with_last_instance = true; _host_url = PANDA_PACKAGE_HOST_URL; - // Better to leave _this_platform set to the empty string until the - // user specifies otherwise; this allows the plugin to select a - // suitable platform at runtime. + // Better to leave _this_platform set to the empty string until the user + // specifies otherwise; this allows the plugin to select a suitable platform + // at runtime. _this_platform = ""; _coreapi_platform = DTOOL_PLATFORM; _verify_contents = P3D_VC_none; _contents_expiration = 0; - // Seed the lame random number generator in rand(); we use it to - // select a mirror for downloading. + // Seed the lame random number generator in rand(); we use it to select a + // mirror for downloading. srand((unsigned int)time(NULL)); - + _prepend_filename_to_args = true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::run_main_loop -// Access: Public -// Description: Gets lost in the application main loop, waiting for -// system events and notifications from the open -// instance(s). -//////////////////////////////////////////////////////////////////// +/** + * Gets lost in the application main loop, waiting for system events and + * notifications from the open instance(s). + */ void Panda3DBase:: run_main_loop() { #ifdef _WIN32 if (_window_type == P3D_WT_embedded) { - // Wait for new messages from Windows, and new requests from the - // plugin. + // Wait for new messages from Windows, and new requests from the plugin. MSG msg; int retval; retval = GetMessage(&msg, NULL, 0, 0); @@ -117,24 +109,23 @@ run_main_loop() { inst = P3D_check_request_ptr(wait_cycle); } - while (!_url_getters.empty() && + while (!_url_getters.empty() && !PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { // If there are no Windows messages, check the download tasks. run_getters(); } retval = GetMessage(&msg, NULL, 0, 0); } - - // WM_QUIT has been received. Terminate all instances, and fall - // through. + + // WM_QUIT has been received. Terminate all instances, and fall through. while (!_instances.empty()) { P3D_instance *inst = *(_instances.begin()); delete_instance(inst); } } else { - // Not an embedded window, so we don't have our own window to - // generate Windows events. Instead, just wait for requests. + // Not an embedded window, so we don't have our own window to generate + // Windows events. Instead, just wait for requests. while (!time_to_exit()) { P3D_instance *inst = P3D_check_request_ptr(wait_cycle); if (inst != (P3D_instance *)NULL) { @@ -148,9 +139,9 @@ run_main_loop() { } #elif defined(__APPLE__) && !__LP64__ - // OSX really prefers to own the main loop, so we install a timer to - // call out to our instances and getters, rather than polling within - // the event loop as we do in the Windows case, above. + // OSX really prefers to own the main loop, so we install a timer to call + // out to our instances and getters, rather than polling within the event + // loop as we do in the Windows case, above. EventLoopRef main_loop = GetMainEventLoop(); EventLoopTimerUPP timer_upp = NewEventLoopTimerUPP(st_timer_callback); EventLoopTimerRef timer; @@ -159,13 +150,13 @@ run_main_loop() { timer_upp, this, &timer); RunApplicationEventLoop(); RemoveEventLoopTimer(timer); - + // Terminate all instances, and fall through. while (!_instances.empty()) { P3D_instance *inst = *(_instances.begin()); delete_instance(inst); } - + #else // _WIN32, __APPLE__ // Now wait while we process pending requests. @@ -183,11 +174,9 @@ run_main_loop() { #endif // _WIN32, __APPLE__ } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::run_getters -// Access: Protected -// Description: Polls all of the active URL requests. -//////////////////////////////////////////////////////////////////// +/** + * Polls all of the active URL requests. + */ void Panda3DBase:: run_getters() { URLGetters::iterator gi; @@ -207,12 +196,9 @@ run_getters() { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::handle_request -// Access: Protected -// Description: Handles a single request received via the plugin API -// from a p3d instance. -//////////////////////////////////////////////////////////////////// +/** + * Handles a single request received via the plugin API from a p3d instance. + */ void Panda3DBase:: handle_request(P3D_request *request) { bool handled = false; @@ -239,7 +225,7 @@ handle_request(P3D_request *request) { case P3D_RT_notify: { - //cerr << "Notify: " << request->_request._notify._message << "\n"; + // cerr << "Notify: " << request->_request._notify._message << "\n"; if (strcmp(request->_request._notify._message, "ondownloadnext") == 0) { // Tell the user we're downloading a package. report_downloading_package(request->_instance); @@ -273,12 +259,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::make_parent_window -// Access: Protected -// Description: Creates a toplevel window to contain the embedded -// instances. Windows implementation. -//////////////////////////////////////////////////////////////////// +/** + * Creates a toplevel window to contain the embedded instances. Windows + * implementation. + */ void Panda3DBase:: make_parent_window() { WNDCLASS wc; @@ -295,12 +279,12 @@ make_parent_window() { exit(1); } - DWORD window_style = + DWORD window_style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; - HWND toplevel_window = + HWND toplevel_window = CreateWindow("panda3d", "Panda3D", window_style, CW_USEDEFAULT, CW_USEDEFAULT, _win_width, _win_height, NULL, NULL, application, 0); @@ -318,12 +302,9 @@ make_parent_window() { #else -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::make_parent_window -// Access: Protected -// Description: Creates a toplevel window to contain the embedded -// instances. -//////////////////////////////////////////////////////////////////// +/** + * Creates a toplevel window to contain the embedded instances. + */ void Panda3DBase:: make_parent_window() { // TODO. @@ -332,19 +313,15 @@ make_parent_window() { #endif -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::create_instance -// Access: Protected -// Description: Uses the plugin API to create a new P3D instance to -// play a particular .p3d file. This instance is also -// started if start_instance is true (which requires -// that the named p3d file exists). -//////////////////////////////////////////////////////////////////// +/** + * Uses the plugin API to create a new P3D instance to play a particular .p3d + * file. This instance is also started if start_instance is true (which + * requires that the named p3d file exists). + */ P3D_instance *Panda3DBase:: create_instance(const string &p3d, bool start_instance, char **args, int num_args, int p3d_offset) { - // Check to see if the p3d filename we were given is a URL, or a - // local file. + // Check to see if the p3d filename we were given is a URL, or a local file. Filename p3d_filename = Filename::from_os_specific(p3d); string os_p3d_filename = p3d; bool is_local = !is_url(p3d); @@ -407,9 +384,8 @@ create_instance(const string &p3d, bool start_instance, if (inst != NULL) { if (start_instance) { - // We call start() first, to give the core API a chance to - // notice the "hidden" attrib before we set the window - // parameters. + // We call start() first, to give the core API a chance to notice the + // "hidden" attrib before we set the window parameters. P3D_instance_start_ptr(inst, is_local, os_p3d_filename.c_str(), p3d_offset); } @@ -420,19 +396,16 @@ create_instance(const string &p3d, bool start_instance, return inst; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::delete_instance -// Access: Protected -// Description: Deletes the indicated instance and removes it from -// the internal structures. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the indicated instance and removes it from the internal structures. + */ void Panda3DBase:: delete_instance(P3D_instance *inst) { P3D_instance_finish_ptr(inst); _instances.erase(inst); - // Make sure we also terminate any pending URLGetters associated - // with this instance. + // Make sure we also terminate any pending URLGetters associated with this + // instance. URLGetters::iterator gi; gi = _url_getters.begin(); while (gi != _url_getters.end()) { @@ -446,13 +419,10 @@ delete_instance(P3D_instance *inst) { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::read_p3d_info -// Access: Protected -// Description: Opens the p3d file to read the p3d_info.xml file -// within it, looking for any locally-relevant -// parameters (like width and height). -//////////////////////////////////////////////////////////////////// +/** + * Opens the p3d file to read the p3d_info.xml file within it, looking for any + * locally-relevant parameters (like width and height). + */ bool Panda3DBase:: read_p3d_info(const Filename &p3d_filename, int p3d_offset) { PT(Multifile) mf = new Multifile; @@ -483,8 +453,8 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { // Successfully read the p3d_info.xml file. if (!_got_win_size) { - // If the user didn't override the size on the command line, allow - // the p3d file to request a preferred size. + // If the user didn't override the size on the command line, allow the p3d + // file to request a preferred size. if (xconfig->Attribute("width", &_win_width)) { _got_win_size = true; } @@ -496,13 +466,10 @@ read_p3d_info(const Filename &p3d_filename, int p3d_offset) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::parse_token -// Access: Protected -// Description: Parses a web token of the form token=value, and -// stores it in _tokens. Returns true on success, false -// on failure. -//////////////////////////////////////////////////////////////////// +/** + * Parses a web token of the form token=value, and stores it in _tokens. + * Returns true on success, false on failure. + */ bool Panda3DBase:: parse_token(const char *arg) { const char *equals = strchr(arg, '='); @@ -525,12 +492,10 @@ parse_token(const char *arg) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::parse_int_pair -// Access: Protected -// Description: Parses a string into an x,y pair of integers. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Parses a string into an x,y pair of integers. Returns true on success, + * false on failure. + */ bool Panda3DBase:: parse_int_pair(const char *arg, int &x, int &y) { char *endptr; @@ -546,13 +511,10 @@ parse_int_pair(const char *arg, int &x, int &y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::lookup_token -// Access: Protected -// Description: Returns the value associated with the first -// appearance of the named token, or empty string if the -// token does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the first appearance of the named token, + * or empty string if the token does not appear. + */ string Panda3DBase:: lookup_token(const string &keyword) const { Tokens::const_iterator ti; @@ -565,13 +527,10 @@ lookup_token(const string &keyword) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::compare_seq -// Access: Protected, Static -// Description: Compares the two dotted-integer sequence values -// numerically. Returns -1 if seq_a sorts first, 1 if -// seq_b sorts first, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Compares the two dotted-integer sequence values numerically. Returns -1 if + * seq_a sorts first, 1 if seq_b sorts first, 0 if they are equivalent. + */ int Panda3DBase:: compare_seq(const string &seq_a, const string &seq_b) { const char *num_a = seq_a.c_str(); @@ -599,13 +558,11 @@ compare_seq(const string &seq_a, const string &seq_b) { return comp; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::compare_seq_int -// Access: Protected, Static -// Description: Numerically compares the formatted integer value at -// num_a with num_b. Increments both num_a and num_b to -// the next character following the valid integer. -//////////////////////////////////////////////////////////////////// +/** + * Numerically compares the formatted integer value at num_a with num_b. + * Increments both num_a and num_b to the next character following the valid + * integer. + */ int Panda3DBase:: compare_seq_int(const char *&num_a, const char *&num_b) { long int a; @@ -628,17 +585,15 @@ compare_seq_int(const char *&num_a, const char *&num_b) { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::is_url -// Access: Protected, Static -// Description: Returns true if the indicated string appears to be a -// URL, with a leading http:// or file:// or whatever, -// or false if it must be a local filename instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated string appears to be a URL, with a leading + * http:// or file:// or whatever, or false if it must be a local filename + * instead. + */ bool Panda3DBase:: is_url(const string ¶m) { - // We define a URL prefix as a sequence of at least two letters, - // followed by a colon, followed by at least one slash. + // We define a URL prefix as a sequence of at least two letters, followed by + // a colon, followed by at least one slash. size_t p = 0; while (p < param.size() && isalpha(param[p])) { ++p; @@ -661,15 +616,13 @@ is_url(const string ¶m) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::report_downloading_package -// Access: Protected -// Description: Tells the user we have to download a package. -//////////////////////////////////////////////////////////////////// +/** + * Tells the user we have to download a package. + */ void Panda3DBase:: report_downloading_package(P3D_instance *instance) { P3D_object *obj = P3D_instance_get_panda_script_object_ptr(instance); - + P3D_object *display_name = P3D_object_get_property_ptr(obj, "downloadPackageDisplayName"); if (display_name == NULL) { cerr << "Installing package.\n"; @@ -686,12 +639,10 @@ report_downloading_package(P3D_instance *instance) { P3D_object_decref_ptr(display_name); _reporting_download = true; } - -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::report_download_complete -// Access: Protected -// Description: Tells the user we're done downloading packages -//////////////////////////////////////////////////////////////////// + +/** + * Tells the user we're done downloading packages + */ void Panda3DBase:: report_download_complete(P3D_instance *instance) { if (_reporting_download) { @@ -700,12 +651,10 @@ report_download_complete(P3D_instance *instance) { } #if defined(__APPLE__) && !__LP64__ -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::st_timer_callback -// Access: Protected, Static -// Description: Installed as a timer on the event loop, so we can -// process local events, in the Apple implementation. -//////////////////////////////////////////////////////////////////// +/** + * Installed as a timer on the event loop, so we can process local events, in + * the Apple implementation. + */ pascal void Panda3DBase:: st_timer_callback(EventLoopTimerRef timer, void *user_data) { ((Panda3DBase *)user_data)->timer_callback(timer); @@ -713,12 +662,10 @@ st_timer_callback(EventLoopTimerRef timer, void *user_data) { #endif // __APPLE__ #if defined(__APPLE__) && !__LP64__ -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::timer_callback -// Access: Protected -// Description: Installed as a timer on the event loop, so we can -// process local events, in the Apple implementation. -//////////////////////////////////////////////////////////////////// +/** + * Installed as a timer on the event loop, so we can process local events, in + * the Apple implementation. + */ void Panda3DBase:: timer_callback(EventLoopTimerRef timer) { // Check for new requests from the Panda3D plugin. @@ -730,7 +677,7 @@ timer_callback(EventLoopTimerRef timer) { } inst = P3D_check_request_ptr(0.0); } - + // Check the download tasks. run_getters(); @@ -741,11 +688,9 @@ timer_callback(EventLoopTimerRef timer) { } #endif // __APPLE__ -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::URLGetter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Panda3DBase::URLGetter:: URLGetter(P3D_instance *instance, int unique_id, const URLSpec &url, const string &post_data) : @@ -757,7 +702,7 @@ URLGetter(P3D_instance *instance, int unique_id, HTTPClient *http = HTTPClient::get_global_ptr(); _channel = http->make_channel(false); - // _channel->set_download_throttle(true); + // _channel->set_download_throttle(true); if (_post_data.empty()) { _channel->begin_get_document(_url); } else { @@ -768,15 +713,11 @@ URLGetter(P3D_instance *instance, int unique_id, _bytes_sent = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DBase::URLGetter::run -// Access: Public -// Description: Polls the URLGetter for new results. Returns true if -// the URL request is still in progress and run() should -// be called again later, or false if the URL request -// has been completed and run() should not be called -// again. -//////////////////////////////////////////////////////////////////// +/** + * Polls the URLGetter for new results. Returns true if the URL request is + * still in progress and run() should be called again later, or false if the + * URL request has been completed and run() should not be called again. + */ bool Panda3DBase::URLGetter:: run() { if (_channel->run() || _rf.get_data_size() != 0) { @@ -792,7 +733,7 @@ run() { if (!download_ok) { // The plugin doesn't care any more. Interrupt the download. - cerr << "Download interrupted: " << _url + cerr << "Download interrupted: " << _url << ", after " << _bytes_sent << " of " << _channel->get_file_size() << " bytes.\n"; return false; diff --git a/direct/src/plugin_standalone/panda3dBase.h b/direct/src/plugin_standalone/panda3dBase.h index b3ace6256f..fd277ce9ec 100644 --- a/direct/src/plugin_standalone/panda3dBase.h +++ b/direct/src/plugin_standalone/panda3dBase.h @@ -1,27 +1,25 @@ -// Filename: panda3dBase.h -// Created by: pro-rsoft (07Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dBase.h + * @author rdb + * @date 2009-12-07 + */ #ifndef PANDA3DBASE_H #define PANDA3DBASE_H -// This program must link with Panda for HTTPClient support. This -// means it probably should be built with LINK_ALL_STATIC defined, so -// we won't have to deal with confusing .dll or .so files that might -// compete on the disk with the dynamically-loaded versions. There's -// no competition in memory address space, though, because -// p3d_plugin--the only file we dynamically link in--doesn't itself -// link with Panda. +// This program must link with Panda for HTTPClient support. This means it +// probably should be built with LINK_ALL_STATIC defined, so we won't have to +// deal with confusing .dll or .so files that might compete on the disk with +// the dynamically-loaded versions. There's no competition in memory address +// space, though, because p3d_plugin--the only file we dynamically link in-- +// doesn't itself link with Panda. #include "pandabase.h" #include "p3d_plugin.h" @@ -31,11 +29,10 @@ #include "pset.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : Panda3DBase -// Description : Base for creating a standalone application that -// invokes the panda3d plugin to launch .p3d files. -//////////////////////////////////////////////////////////////////// +/** + * Base for creating a standalone application that invokes the panda3d plugin + * to launch .p3d files. + */ class Panda3DBase { public: Panda3DBase(bool console_environment); @@ -105,21 +102,21 @@ protected: public: URLGetter(P3D_instance *instance, int unique_id, const URLSpec &url, const string &post_data); - + bool run(); inline P3D_instance *get_instance(); - + private: P3D_instance *_instance; int _unique_id; URLSpec _url; string _post_data; - + PT(HTTPChannel) _channel; Ramfile _rf; size_t _bytes_sent; }; - + typedef pset URLGetters; URLGetters _url_getters; }; @@ -127,4 +124,3 @@ protected: #include "panda3dBase.I" #endif - diff --git a/direct/src/plugin_standalone/panda3dMac.I b/direct/src/plugin_standalone/panda3dMac.I index 7b25d4fd7d..d70e879a92 100644 --- a/direct/src/plugin_standalone/panda3dMac.I +++ b/direct/src/plugin_standalone/panda3dMac.I @@ -1,14 +1,12 @@ -// Filename: panda3dMac.I -// Created by: drose (23Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dMac.I + * @author drose + * @date 2009-10-23 + */ diff --git a/direct/src/plugin_standalone/panda3dMac.cxx b/direct/src/plugin_standalone/panda3dMac.cxx index 6090dc9850..2b7ab47e8c 100644 --- a/direct/src/plugin_standalone/panda3dMac.cxx +++ b/direct/src/plugin_standalone/panda3dMac.cxx @@ -1,16 +1,15 @@ -// Filename: panda3dMac.cxx -// Created by: drose (23Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dMac.cxx + * @author drose + * @date 2009-10-23 + */ #include "panda3dMac.h" #include "load_plugin.h" @@ -22,15 +21,13 @@ using namespace std; // Having a global Panda3DMac object just makes things easier. static Panda3DMac *this_prog; -//////////////////////////////////////////////////////////////////// -// Function: Panda3DMac::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Panda3DMac:: Panda3DMac() : Panda3D(false) { - // Mac applications traditionally keep running even when all windows - // are closed. + // Mac applications traditionally keep running even when all windows are + // closed. _exit_with_last_instance = false; // No command-line arguments, so just run. @@ -39,12 +36,10 @@ Panda3DMac() : Panda3D(false) { } } -//////////////////////////////////////////////////////////////////// -// Function: Panda3DMac::open_p3d_file -// Access: Public -// Description: Opens a p3d file received via the "open documents" -// event as its own instance. -//////////////////////////////////////////////////////////////////// +/** + * Opens a p3d file received via the "open documents" event as its own + * instance. + */ void Panda3DMac:: open_p3d_file(FSRef *ref) { OSErr err; @@ -62,33 +57,33 @@ open_p3d_file(FSRef *ref) { } static pascal OSErr -open_documents_handler(const AppleEvent *theAppleEvent, AppleEvent *reply, +open_documents_handler(const AppleEvent *theAppleEvent, AppleEvent *reply, SRefCon handlerRefcon) { AEDescList docList; FSRef theFSRef; long index; long count = 0; - + // Get the list of file aliases from the event. OSErr err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList); require_noerr(err, CantGetDocList); - + err = AECountItems(&docList, &count); require_noerr(err, CantGetCount); - + for (index = 1; index <= count; index++) { err = AEGetNthPtr(&docList, index, typeFSRef, NULL, NULL, &theFSRef, sizeof(FSRef), NULL);// 5 require_noerr(err, CantGetDocDescPtr); - + // Here's the file, do something with it. this_prog->open_p3d_file(&theFSRef); } - + // Release list of files AEDisposeDesc(&docList); - + // Error handlers. CantGetDocList: CantGetCount: @@ -106,8 +101,8 @@ main(int argc, char *argv[]) { err = AEInstallEventHandler (kCoreEventClass, kAEOpenDocuments, handler, 0, false); - // The command-line options are weird when we start from the - // Launcher. Just ignore them. + // The command-line options are weird when we start from the Launcher. Just + // ignore them. this_prog->run_main_loop(); return 0; } diff --git a/direct/src/plugin_standalone/panda3dMac.h b/direct/src/plugin_standalone/panda3dMac.h index a5291c7642..8d6899dba0 100644 --- a/direct/src/plugin_standalone/panda3dMac.h +++ b/direct/src/plugin_standalone/panda3dMac.h @@ -1,16 +1,15 @@ -// Filename: panda3dMac.h -// Created by: drose (23Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dMac.h + * @author drose + * @date 2009-10-23 + */ #ifndef PANDA3DMAC_H #define PANDA3DMAC_H @@ -19,13 +18,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : Panda3DMac -// Description : A specialization of Panda3D for running as a Carbon -// application on OS X. Instead of taking input from -// the command line, this program waits quietly for an -// "open documents" Apple event. -//////////////////////////////////////////////////////////////////// +/** + * A specialization of Panda3D for running as a Carbon application on OS X. + * Instead of taking input from the command line, this program waits quietly + * for an "open documents" Apple event. + */ class Panda3DMac : public Panda3D { public: Panda3DMac(); diff --git a/direct/src/plugin_standalone/panda3dMain.cxx b/direct/src/plugin_standalone/panda3dMain.cxx index e0ed95e660..51420eb39a 100644 --- a/direct/src/plugin_standalone/panda3dMain.cxx +++ b/direct/src/plugin_standalone/panda3dMain.cxx @@ -1,16 +1,15 @@ -// Filename: panda3dMain.cxx -// Created by: drose (23Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dMain.cxx + * @author drose + * @date 2009-10-23 + */ #include "panda3d.h" diff --git a/direct/src/plugin_standalone/panda3dWinMain.cxx b/direct/src/plugin_standalone/panda3dWinMain.cxx index 6007ee2dbb..dbf951da4c 100644 --- a/direct/src/plugin_standalone/panda3dWinMain.cxx +++ b/direct/src/plugin_standalone/panda3dWinMain.cxx @@ -1,26 +1,23 @@ -// Filename: panda3dWinMain.cxx -// Created by: drose (23Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda3dWinMain.cxx + * @author drose + * @date 2009-10-23 + */ #include "panda3d.h" -// On Windows, we may need to build panda3dw.exe, a non-console -// version of this program. +// On Windows, we may need to build panda3dw.exe, a non-console version of +// this program. -// Returns a newly-allocated string representing the quoted argument -// beginning at p. Advances p to the first character following the -// close quote. +// Returns a newly-allocated string representing the quoted argument beginning +// at p. Advances p to the first character following the close quote. static char * parse_quoted_arg(char *&p) { char quote = *p; @@ -39,8 +36,7 @@ parse_quoted_arg(char *&p) { } // Returns a newly-allocated string representing the unquoted argument -// beginning at p. Advances p to the first whitespace following the -// argument. +// beginning at p. Advances p to the first whitespace following the argument. static char * parse_unquoted_arg(char *&p) { string result; @@ -51,12 +47,12 @@ parse_unquoted_arg(char *&p) { return strdup(result.c_str()); } -int WINAPI +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { char *command_line = GetCommandLine(); vector argv; - + char *p = command_line; while (*p != '\0') { if (*p == '"') { diff --git a/direct/src/showbase/showBase.cxx b/direct/src/showbase/showBase.cxx index c2051023da..fabc7a9497 100644 --- a/direct/src/showbase/showBase.cxx +++ b/direct/src/showbase/showBase.cxx @@ -1,22 +1,20 @@ -// Filename: showBase.cxx -// Created by: shochet (02Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showBase.cxx + * @author shochet + * @date 2000-02-02 + */ + #ifdef __APPLE__ -// We have to include this before we include any Panda libraries, -// because one of the things we pick up in Panda defines a macro for -// TCP_NODELAY and friends, causing heartaches for the header files -// picked up here. +// We have to include this before we include any Panda libraries, because one +// of the things we pick up in Panda defines a macro for TCP_NODELAY and +// friends, causing heartaches for the header files picked up here. #include extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); } #endif @@ -33,7 +31,7 @@ extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); } #include // For SystemParametersInfo() STICKYKEYS g_StartupStickyKeys = {sizeof(STICKYKEYS), 0}; TOGGLEKEYS g_StartupToggleKeys = {sizeof(TOGGLEKEYS), 0}; -FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; +FILTERKEYS g_StartupFilterKeys = {sizeof(FILTERKEYS), 0}; #endif ConfigureDef(config_showbase); @@ -41,7 +39,7 @@ ConfigureFn(config_showbase) { } ConfigVariableSearchPath particle_path -("particle-path", +("particle-path", PRC_DESC("The directories to search for particle files to be loaded.")); ConfigVariableSearchPath & @@ -49,9 +47,9 @@ get_particle_path() { return particle_path; } -// Throw the "NewFrame" event in the C++ world. Some of the lerp code -// depends on receiving this. -void +// Throw the "NewFrame" event in the C++ world. Some of the lerp code depends +// on receiving this. +void throw_new_frame() { throw_event("NewFrame"); } @@ -64,28 +62,28 @@ get_config_showbase() { return config_showbase; } -// Initialize the application for making a Gui-based app, such as wx. -// At the moment, this is a no-op except on Mac. +// Initialize the application for making a Gui-based app, such as wx. At the +// moment, this is a no-op except on Mac. void init_app_for_gui() { #ifdef IS_OSX - // Rudely bring the application to the foreground. This is - // particularly important when running wx via the plugin, since the - // plugin app is seen as separate from the browser app, even though - // the user sees them as the same thing. We need to bring the - // plugin app to the foreground to make its wx windows visible. + // Rudely bring the application to the foreground. This is particularly + // important when running wx via the plugin, since the plugin app is seen as + // separate from the browser app, even though the user sees them as the same + // thing. We need to bring the plugin app to the foreground to make its wx + // windows visible. activate_osx_application(); #endif - // We don't appear need to do the following, however, if we launch - // the plugin correctly from its own bundle. + // We don't appear need to do the following, however, if we launch the + // plugin correctly from its own bundle. /* static bool initted_for_gui = false; if (!initted_for_gui) { initted_for_gui = true; #ifdef IS_OSX ProcessSerialNumber psn; - + GetCurrentProcess(&psn); CPSEnableForegroundOperation(&psn); SetFrontProcess(&psn); @@ -94,7 +92,8 @@ init_app_for_gui() { */ } -// klunky interface since we cant pass array from python->C++ to use verify_window_sizes directly +// klunky interface since we cant pass array from python->C++ to use +// verify_window_sizes directly static int num_fullscreen_testsizes = 0; #define MAX_FULLSCREEN_TESTS 10 static int fullscreen_testsizes[MAX_FULLSCREEN_TESTS * 2]; @@ -145,83 +144,82 @@ allow_accessibility_shortcut_keys(bool allowKeys) { #ifdef WIN32 if( allowKeys ) { - // Restore StickyKeys/etc to original state and enable Windows key + // Restore StickyKeysetc to original state and enable Windows key SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &g_StartupStickyKeys, 0); SystemParametersInfo(SPI_SETTOGGLEKEYS, sizeof(TOGGLEKEYS), &g_StartupToggleKeys, 0); SystemParametersInfo(SPI_SETFILTERKEYS, sizeof(FILTERKEYS), &g_StartupFilterKeys, 0); } else { - // Disable StickyKeys/etc shortcuts but if the accessibility feature is on, + // Disable StickyKeysetc shortcuts but if the accessibility feature is on, // then leave the settings alone as its probably being usefully used - + STICKYKEYS skOff = g_StartupStickyKeys; if( (skOff.dwFlags & SKF_STICKYKEYSON) == 0 ) { // Disable the hotkey and the confirmation skOff.dwFlags &= ~SKF_HOTKEYACTIVE; skOff.dwFlags &= ~SKF_CONFIRMHOTKEY; - + SystemParametersInfo(SPI_SETSTICKYKEYS, sizeof(STICKYKEYS), &skOff, 0); } - + TOGGLEKEYS tkOff = g_StartupToggleKeys; if( (tkOff.dwFlags & TKF_TOGGLEKEYSON) == 0 ) { // Disable the hotkey and the confirmation tkOff.dwFlags &= ~TKF_HOTKEYACTIVE; tkOff.dwFlags &= ~TKF_CONFIRMHOTKEY; - + SystemParametersInfo(SPI_SETTOGGLEKEYS, sizeof(TOGGLEKEYS), &tkOff, 0); } - + FILTERKEYS fkOff = g_StartupFilterKeys; if( (fkOff.dwFlags & FKF_FILTERKEYSON) == 0 ) { // Disable the hotkey and the confirmation fkOff.dwFlags &= ~FKF_HOTKEYACTIVE; fkOff.dwFlags &= ~FKF_CONFIRMHOTKEY; - + SystemParametersInfo(SPI_SETFILTERKEYS, sizeof(FILTERKEYS), &fkOff, 0); } - } -#endif + } +#endif } #if 0 int TempGridZoneManager:: -add_grid_zone(unsigned int x, - unsigned int y, - unsigned int width, - unsigned int height, - unsigned int zoneBase, +add_grid_zone(unsigned int x, + unsigned int y, + unsigned int width, + unsigned int height, + unsigned int zoneBase, unsigned int xZoneResolution, unsigned int yZoneResolution) { - // zoneBase is the first zone in the grid (e.g. the upper left) - // zoneResolution is the number of cells on each axsis. - // returns the next available zoneBase (i.e. zoneBase+xZoneResolution*yZoneResolution) + // zoneBase is the first zone in the grid (e.g. the upper left) + // zoneResolution is the number of cells on each axsis. returns the next + // available zoneBase (i.e. zoneBase+xZoneResolution*yZoneResolution) cerr<<"adding grid zone with a zoneBase of "< 1.0 || y < 0.0 || y > 1.0) { return 0; } @@ -312,4 +307,3 @@ get_zone_list(int x, int y, int resolution) { return 5; } #endif - diff --git a/direct/src/showbase/showBase.h b/direct/src/showbase/showBase.h index 5ffea8cbee..2347800789 100644 --- a/direct/src/showbase/showBase.h +++ b/direct/src/showbase/showBase.h @@ -1,16 +1,15 @@ -// Filename: showBase.h -// Created by: shochet (02Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showBase.h + * @author shochet + * @date 2000-02-02 + */ #ifndef SHOWBASE_H #define SHOWBASE_H @@ -63,13 +62,13 @@ class TempGridZoneManager { PUBLISHED: TempGridZoneManager() {} ~TempGridZoneManager() {} - + unsigned int add_grid_zone( - unsigned int x, - unsigned int y, - unsigned int width, - unsigned int height, - unsigned int zoneBase, + unsigned int x, + unsigned int y, + unsigned int width, + unsigned int height, + unsigned int zoneBase, unsigned int xZoneResolution, unsigned int yZoneResolution); int get_zone_list(int x, int y); @@ -80,11 +79,11 @@ protected: unsigned int base; unsigned int resolution; GridZone( - unsigned int x, - unsigned int y, - unsigned int width, - unsigned int height, - unsigned int zoneBase, + unsigned int x, + unsigned int y, + unsigned int width, + unsigned int height, + unsigned int zoneBase, unsigned int xZoneResolution, unsigned int yZoneResolution) { base=zoneBase; diff --git a/direct/src/showbase/showBase_assist.mm b/direct/src/showbase/showBase_assist.mm index 33598fca2c..c912bb56f8 100644 --- a/direct/src/showbase/showBase_assist.mm +++ b/direct/src/showbase/showBase_assist.mm @@ -7,10 +7,9 @@ #include #include "showBase.h" -//////////////////////////////////////////////////////////////////// -// Function: activate_osx_application -// Description: Activates the current application for Mac OSX. -//////////////////////////////////////////////////////////////////// +/** + * Activates the current application for Mac OSX. + */ void activate_osx_application() { cerr << "activate_osx_application\n"; diff --git a/dtool/metalibs/dtool/dtool.cxx b/dtool/metalibs/dtool/dtool.cxx index 16d0918ca6..fb15deb0eb 100644 --- a/dtool/metalibs/dtool/dtool.cxx +++ b/dtool/metalibs/dtool/dtool.cxx @@ -1,11 +1,10 @@ -// Filename: dtool.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// - -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libdtool.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libdtool. - +/** + * @file dtool.cxx + * @author drose + * @date 2000-05-15 + */ +// This is a dummy file whose sole purpose is to give the compiler something +// to compile when making libdtool.so in NO_DEFER mode, which generates an +// empty library that itself links with all the other shared libraries that +// make up libdtool. diff --git a/dtool/metalibs/dtoolconfig/dtoolconfig.cxx b/dtool/metalibs/dtoolconfig/dtoolconfig.cxx index cf71893a69..bb3d39b36d 100644 --- a/dtool/metalibs/dtoolconfig/dtoolconfig.cxx +++ b/dtool/metalibs/dtoolconfig/dtoolconfig.cxx @@ -1,11 +1,10 @@ -// Filename: dtoolconfig.cxx -// Created by: frang (09Jan01) -// -//////////////////////////////////////////////////////////////////// - -// This is a dummy file whose sole purpose is to give the compiler -// something to compile when making libdtoolconfig.so in NO_DEFER mode, -// which generates an empty library that itself links with all the -// other shared libraries that make up libdtoolconfig. - +/** + * @file dtoolconfig.cxx + * @author frang + * @date 2001-01-09 + */ +// This is a dummy file whose sole purpose is to give the compiler something +// to compile when making libdtoolconfig.so in NO_DEFER mode, which generates +// an empty library that itself links with all the other shared libraries that +// make up libdtoolconfig. diff --git a/dtool/src/cppparser/cppArrayType.cxx b/dtool/src/cppparser/cppArrayType.cxx index bda2f72d7d..ac891e259f 100644 --- a/dtool/src/cppparser/cppArrayType.cxx +++ b/dtool/src/cppparser/cppArrayType.cxx @@ -1,26 +1,22 @@ -// Filename: cppArrayType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppArrayType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppArrayType.h" #include "cppExpression.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPArrayType:: CPPArrayType(CPPType *element_type, CPPExpression *bounds) : CPPType(CPPFile()), @@ -29,28 +25,22 @@ CPPArrayType(CPPType *element_type, CPPExpression *bounds) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPArrayType:: is_fully_specified() const { return CPPType::is_fully_specified() && _element_type->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPArrayType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *ptype = _element_type->resolve_type(current_scope, global_scope); @@ -63,59 +53,46 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPArrayType:: is_tbd() const { return _element_type->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPArrayType:: is_trivial() const { return _element_type->is_trivial(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPArrayType:: is_default_constructible() const { return _element_type->is_default_constructible(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPArrayType:: is_copy_constructible() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_equivalent -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPArrayType:: is_equivalent(const CPPType &other) const { const CPPArrayType *ot = ((CPPType *)&other)->as_array_type(); @@ -126,11 +103,9 @@ is_equivalent(const CPPType &other) const { return _element_type->is_equivalent(*ot->_element_type); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPArrayType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -160,11 +135,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPArrayType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* @@ -178,14 +151,11 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output_instance(out, indent_level, scope, complete, "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPArrayType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -202,32 +172,26 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, prename, name + bracketsstr); } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPArrayType:: get_subtype() const { return ST_array; } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::as_array_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPArrayType *CPPArrayType:: as_array_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPArrayType:: is_equal(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); @@ -245,13 +209,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPArrayType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPArrayType:: is_less(const CPPDeclaration *other) const { const CPPArrayType *ot = ((CPPDeclaration *)other)->as_array_type(); @@ -270,4 +231,3 @@ is_less(const CPPDeclaration *other) const { } return false; } - diff --git a/dtool/src/cppparser/cppArrayType.h b/dtool/src/cppparser/cppArrayType.h index 25f7786fc9..4633e95aa4 100644 --- a/dtool/src/cppparser/cppArrayType.h +++ b/dtool/src/cppparser/cppArrayType.h @@ -1,16 +1,15 @@ -// Filename: cppArrayType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppArrayType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPARRAYTYPE_H #define CPPARRAYTYPE_H @@ -21,10 +20,9 @@ class CPPExpression; -//////////////////////////////////////////////////////////////////// -// Class : CPPArrayType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPArrayType : public CPPType { public: CPPArrayType(CPPType *element_type, CPPExpression *bounds); diff --git a/dtool/src/cppparser/cppBison.yxx b/dtool/src/cppparser/cppBison.yxx index 09991d8086..b9a64f90fc 100644 --- a/dtool/src/cppparser/cppBison.yxx +++ b/dtool/src/cppparser/cppBison.yxx @@ -1,7 +1,8 @@ -// Filename: cppBison.yxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// +/** + * @file cppBison.yxx + * @author drose + * @date 1999-01-16 + */ %{ diff --git a/dtool/src/cppparser/cppBisonDefs.h b/dtool/src/cppparser/cppBisonDefs.h index ae1fc477d7..b90c47cc20 100644 --- a/dtool/src/cppparser/cppBisonDefs.h +++ b/dtool/src/cppparser/cppBisonDefs.h @@ -1,24 +1,23 @@ -// Filename: cppBisonDefs.h -// Created by: drose (17Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppBisonDefs.h + * @author drose + * @date 1999-01-17 + */ #ifndef CPPBISON_H #define CPPBISON_H -// This header file defines the interface to the yacc (actually, -// bison) parser and grammar. None of these interfaces are intended -// to be used directly; they're defined here strictly to be used by -// the CPPParser and CPPExpressionParser classes. +// This header file defines the interface to the yacc (actually, bison) parser +// and grammar. None of these interfaces are intended to be used directly; +// they're defined here strictly to be used by the CPPParser and +// CPPExpressionParser classes. #include "dtoolbase.h" @@ -57,12 +56,11 @@ extern CPPScope *global_scope; extern CPPPreprocessor *current_lexer; -// This structure holds the return value for each token. -// Traditionally, this is a union, and is declared with the %union -// declaration in the parser.y file, but unions are pretty worthless -// in C++ (you can't include an object that has member functions in a -// union), so we'll use a class instead. That means we need to -// declare it externally, here. +// This structure holds the return value for each token. Traditionally, this +// is a union, and is declared with the %union declaration in the parser.y +// file, but unions are pretty worthless in C++ (you can't include an object +// that has member functions in a union), so we'll use a class instead. That +// means we need to declare it externally, here. class cppyystype { public: @@ -87,10 +85,9 @@ public: }; #define YYSTYPE cppyystype -// This structure takes advantage of a bison feature to track the -// exact location in the file of each token, for more useful error -// reporting. We define it up here so we can reference it in the -// lexer. +// This structure takes advantage of a bison feature to track the exact +// location in the file of each token, for more useful error reporting. We +// define it up here so we can reference it in the lexer. struct cppyyltype { // Bison expects these members to be part of this struct. @@ -99,22 +96,22 @@ struct cppyyltype { int last_line; int last_column; - // Early versions of bison (1.25 and earlier) expected these members - // to be in this struct as well. + // Early versions of bison (1.25 and earlier) expected these members to be + // in this struct as well. int timestamp; char *text; - // The remaining members are added for this application and have no - // meaning to bison. + // The remaining members are added for this application and have no meaning + // to bison. CPPFile file; }; #define YYLTYPE cppyyltype -// Beginning around bison 1.35 or so, we need to define this macro as -// well, to tell bison how to collect multiple locations together. -// (The default implementation copies only first_line through -// last_column, whereas here we use the struct assignment operator to -// copy all the members of the structure). +// Beginning around bison 1.35 or so, we need to define this macro as well, to +// tell bison how to collect multiple locations together. (The default +// implementation copies only first_line through last_column, whereas here we +// use the struct assignment operator to copy all the members of the +// structure). #define YYLLOC_DEFAULT(Current, Rhs, N) \ (Current) = (Rhs)[1]; \ (Current).last_line = (Rhs)[N].last_line; \ diff --git a/dtool/src/cppparser/cppClassTemplateParameter.cxx b/dtool/src/cppparser/cppClassTemplateParameter.cxx index 62bdb65091..1c39532be5 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.cxx +++ b/dtool/src/cppparser/cppClassTemplateParameter.cxx @@ -1,26 +1,22 @@ -// Filename: cppClassTemplateParameter.cxx -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppClassTemplateParameter.cxx + * @author drose + * @date 1999-10-28 + */ #include "cppClassTemplateParameter.h" #include "cppIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPClassTemplateParameter:: CPPClassTemplateParameter(CPPIdentifier *ident, CPPType *default_type) : CPPType(CPPFile()), @@ -29,24 +25,19 @@ CPPClassTemplateParameter(CPPIdentifier *ident, CPPType *default_type) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPClassTemplateParameter:: is_fully_specified() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPClassTemplateParameter:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (complete) { @@ -62,32 +53,26 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPClassTemplateParameter:: get_subtype() const { return ST_class_template_parameter; } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::as_classTemplateParameter -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPClassTemplateParameter *CPPClassTemplateParameter:: as_class_template_parameter() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPClassTemplateParameter:: is_equal(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); @@ -101,13 +86,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPClassTemplateParameter::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPClassTemplateParameter:: is_less(const CPPDeclaration *other) const { const CPPClassTemplateParameter *ot = ((CPPDeclaration *)other)->as_class_template_parameter(); diff --git a/dtool/src/cppparser/cppClassTemplateParameter.h b/dtool/src/cppparser/cppClassTemplateParameter.h index c4bc892222..89923bd067 100644 --- a/dtool/src/cppparser/cppClassTemplateParameter.h +++ b/dtool/src/cppparser/cppClassTemplateParameter.h @@ -1,16 +1,15 @@ -// Filename: cppClassTemplateParameter.h -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppClassTemplateParameter.h + * @author drose + * @date 1999-10-28 + */ #ifndef CPPCLASSTEMPLATEPARAMETER_H #define CPPCLASSTEMPLATEPARAMETER_H @@ -21,10 +20,9 @@ class CPPIdentifier; -//////////////////////////////////////////////////////////////////// -// Class : CPPClassTemplateParameter -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPClassTemplateParameter : public CPPType { public: CPPClassTemplateParameter(CPPIdentifier *ident, @@ -46,4 +44,3 @@ protected: }; #endif - diff --git a/dtool/src/cppparser/cppCommentBlock.cxx b/dtool/src/cppparser/cppCommentBlock.cxx index e4f90d0dc9..46865ba44d 100644 --- a/dtool/src/cppparser/cppCommentBlock.cxx +++ b/dtool/src/cppparser/cppCommentBlock.cxx @@ -1,16 +1,14 @@ -// Filename: cppCommentBlock.cxx -// Created by: drose (15Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppCommentBlock.cxx + * @author drose + * @date 2000-08-15 + */ #include "cppCommentBlock.h" - diff --git a/dtool/src/cppparser/cppCommentBlock.h b/dtool/src/cppparser/cppCommentBlock.h index 839b0639e6..d3e8ef0a02 100644 --- a/dtool/src/cppparser/cppCommentBlock.h +++ b/dtool/src/cppparser/cppCommentBlock.h @@ -1,16 +1,15 @@ -// Filename: cppCommentBlock.h -// Created by: drose (15Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppCommentBlock.h + * @author drose + * @date 2000-08-15 + */ #ifndef CPPCOMMENTBLOCK_H #define CPPCOMMENTBLOCK_H @@ -21,14 +20,12 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : CPPCommentBlock -// Description : This represents a comment appearing in the source -// code. The CPPPreprocessor collects these, and saves -// the complete list of comments encountered; it also -// stores a list of the comment blocks appearing before -// each declaration. -//////////////////////////////////////////////////////////////////// +/** + * This represents a comment appearing in the source code. The + * CPPPreprocessor collects these, and saves the complete list of comments + * encountered; it also stores a list of the comment blocks appearing before + * each declaration. + */ class CPPCommentBlock { public: CPPFile _file; diff --git a/dtool/src/cppparser/cppConstType.cxx b/dtool/src/cppparser/cppConstType.cxx index 40bfd9548b..da5c0d18fe 100644 --- a/dtool/src/cppparser/cppConstType.cxx +++ b/dtool/src/cppparser/cppConstType.cxx @@ -1,25 +1,21 @@ -// Filename: cppConstType.cxx -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppConstType.cxx + * @author drose + * @date 1999-10-28 + */ #include "cppConstType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPConstType:: CPPConstType(CPPType *wrapped_around) : CPPType(CPPFile()), @@ -27,25 +23,20 @@ CPPConstType(CPPType *wrapped_around) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPConstType:: is_fully_specified() const { return CPPType::is_fully_specified() && _wrapped_around->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPConstType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -68,14 +59,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPConstType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *ptype = _wrapped_around->resolve_type(current_scope, global_scope); @@ -88,59 +76,46 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPConstType:: is_tbd() const { return _wrapped_around->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPConstType:: is_trivial() const { return _wrapped_around->is_trivial(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPConstType:: is_default_constructible() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPConstType:: is_copy_constructible() const { return _wrapped_around->is_copy_constructible(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_equivalent -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPConstType:: is_equivalent(const CPPType &other) const { const CPPConstType *ot = ((CPPType *)&other)->as_const_type(); @@ -151,25 +126,20 @@ is_equivalent(const CPPType &other) const { return _wrapped_around->is_equivalent(*ot->_wrapped_around); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPConstType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { _wrapped_around->output(out, indent_level, scope, complete); out << " const"; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPConstType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -178,33 +148,27 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, "const " + prename, name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPConstType:: get_subtype() const { return ST_const; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::as_const_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPConstType *CPPConstType:: as_const_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPConstType:: is_equal(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); @@ -214,13 +178,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPConstType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPConstType:: is_less(const CPPDeclaration *other) const { const CPPConstType *ot = ((CPPDeclaration *)other)->as_const_type(); diff --git a/dtool/src/cppparser/cppConstType.h b/dtool/src/cppparser/cppConstType.h index 339043ea3d..dbc3e166d4 100644 --- a/dtool/src/cppparser/cppConstType.h +++ b/dtool/src/cppparser/cppConstType.h @@ -1,16 +1,15 @@ -// Filename: cppConstType.h -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppConstType.h + * @author drose + * @date 1999-10-28 + */ #ifndef CPPCONSTTYPE_H #define CPPCONSTTYPE_H @@ -19,10 +18,9 @@ #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPConstType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPConstType : public CPPType { public: CPPConstType(CPPType *wrapped_around); diff --git a/dtool/src/cppparser/cppDeclaration.cxx b/dtool/src/cppparser/cppDeclaration.cxx index 13c81e734d..d2399c0fbb 100644 --- a/dtool/src/cppparser/cppDeclaration.cxx +++ b/dtool/src/cppparser/cppDeclaration.cxx @@ -1,26 +1,22 @@ -// Filename: cppDeclaration.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppDeclaration.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppDeclaration.h" #include "cppPreprocessor.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration:: CPPDeclaration(const CPPFile &file) : _file(file) @@ -30,11 +26,9 @@ CPPDeclaration(const CPPFile &file) : _leading_comment = (CPPCommentBlock *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration:: CPPDeclaration(const CPPDeclaration ©) : _vis(copy._vis), @@ -44,20 +38,16 @@ CPPDeclaration(const CPPDeclaration ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration:: ~CPPDeclaration() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPDeclaration:: operator == (const CPPDeclaration &other) const { if (get_subtype() != other.get_subtype()) { @@ -66,21 +56,17 @@ operator == (const CPPDeclaration &other) const { return is_equal(&other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPDeclaration:: operator != (const CPPDeclaration &other) const { return !(*this == other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPDeclaration:: operator < (const CPPDeclaration &other) const { if (get_subtype() != other.get_subtype()) { @@ -89,49 +75,38 @@ operator < (const CPPDeclaration &other) const { return is_less(&other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::is_template -// Access: Public -// Description: Returns true if this is a template declaration of -// some kind: a template function or a template class, -// typically. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is a template declaration of some kind: a template + * function or a template class, typically. + */ bool CPPDeclaration:: is_template() const { return _template_scope != NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::get_template_scope -// Access: Public -// Description: If is_template(), above, returns true, this returns -// the CPPTemplateScope in which this particular -// template declaration is defined. This scope includes -// the information about the template parameters. -//////////////////////////////////////////////////////////////////// +/** + * If is_template(), above, returns true, this returns the CPPTemplateScope in + * which this particular template declaration is defined. This scope includes + * the information about the template parameters. + */ CPPTemplateScope *CPPDeclaration:: get_template_scope() const { return _template_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPDeclaration:: is_fully_specified() const { return !is_template(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::instantiate -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPDeclaration:: instantiate(const CPPTemplateParameterList *, CPPScope *, CPPScope *, @@ -142,11 +117,9 @@ instantiate(const CPPTemplateParameterList *, return (CPPDeclaration *)this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPDeclaration:: substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { SubstDecl::const_iterator si = subst.find(this); @@ -156,244 +129,195 @@ substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_instance -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance *CPPDeclaration:: as_instance() { return (CPPInstance *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_class_template_parameter -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPClassTemplateParameter *CPPDeclaration:: as_class_template_parameter() { return (CPPClassTemplateParameter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_typedef_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypedefType *CPPDeclaration:: as_typedef_type() { return (CPPTypedefType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_type_declaration -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeDeclaration *CPPDeclaration:: as_type_declaration() { return (CPPTypeDeclaration *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_expression -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression *CPPDeclaration:: as_expression() { return (CPPExpression *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType *CPPDeclaration:: as_type() { return (CPPType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_namespace -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPNamespace *CPPDeclaration:: as_namespace() { return (CPPNamespace *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_using -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPUsing *CPPDeclaration:: as_using() { return (CPPUsing *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_simple_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPSimpleType *CPPDeclaration:: as_simple_type() { return (CPPSimpleType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_pointer_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPointerType *CPPDeclaration:: as_pointer_type() { return (CPPPointerType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_reference_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPReferenceType *CPPDeclaration:: as_reference_type() { return (CPPReferenceType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_array_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPArrayType *CPPDeclaration:: as_array_type() { return (CPPArrayType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_const_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPConstType *CPPDeclaration:: as_const_type() { return (CPPConstType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_function_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionType *CPPDeclaration:: as_function_type() { return (CPPFunctionType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_function_group -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionGroup *CPPDeclaration:: as_function_group() { return (CPPFunctionGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_extension_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExtensionType *CPPDeclaration:: as_extension_type() { return (CPPExtensionType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_struct_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPStructType *CPPDeclaration:: as_struct_type() { return (CPPStructType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_enum_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPEnumType *CPPDeclaration:: as_enum_type() { return (CPPEnumType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_tbd_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTBDType *CPPDeclaration:: as_tbd_type() { return (CPPTBDType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_type_proxy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeProxy *CPPDeclaration:: as_type_proxy() { return (CPPTypeProxy *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_make_property -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeProperty *CPPDeclaration:: as_make_property() { return (CPPMakeProperty *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::as_make_seq -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeSeq *CPPDeclaration:: as_make_seq() { return (CPPMakeSeq *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// type is equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPDeclaration:: is_equal(const CPPDeclaration *other) const { return this == other; } -//////////////////////////////////////////////////////////////////// -// Function: CPPDeclaration::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// type should be ordered before another type of the -// same type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPDeclaration:: is_less(const CPPDeclaration *other) const { return this < other; diff --git a/dtool/src/cppparser/cppDeclaration.h b/dtool/src/cppparser/cppDeclaration.h index b0f5afa10a..f1ce96820f 100644 --- a/dtool/src/cppparser/cppDeclaration.h +++ b/dtool/src/cppparser/cppDeclaration.h @@ -1,16 +1,15 @@ -// Filename: cppDeclaration.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppDeclaration.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPDECLARATION_H #define CPPDECLARATION_H @@ -55,10 +54,9 @@ class CPPScope; class CPPTemplateScope; class CPPPreprocessor; -//////////////////////////////////////////////////////////////////// -// Class : CPPDeclaration -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPDeclaration { public: enum SubType { diff --git a/dtool/src/cppparser/cppEnumType.cxx b/dtool/src/cppparser/cppEnumType.cxx index e596cb4359..bee8ec2f5b 100644 --- a/dtool/src/cppparser/cppEnumType.cxx +++ b/dtool/src/cppparser/cppEnumType.cxx @@ -1,16 +1,15 @@ -// Filename: cppEnumType.cxx -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppEnumType.cxx + * @author drose + * @date 1999-10-25 + */ #include "cppEnumType.h" #include "cppTypedefType.h" @@ -22,11 +21,9 @@ #include "cppIdentifier.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::Constructor -// Access: Public -// Description: Creates an untyped, unscoped enum. -//////////////////////////////////////////////////////////////////// +/** + * Creates an untyped, unscoped enum. + */ CPPEnumType:: CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope, const CPPFile &file) : @@ -40,11 +37,9 @@ CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::Constructor -// Access: Public -// Description: Creates a typed but unscoped enum. -//////////////////////////////////////////////////////////////////// +/** + * Creates a typed but unscoped enum. + */ CPPEnumType:: CPPEnumType(CPPIdentifier *ident, CPPType *element_type, CPPScope *current_scope, const CPPFile &file) : @@ -58,16 +53,14 @@ CPPEnumType(CPPIdentifier *ident, CPPType *element_type, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::get_element_type -// Access: Public -// Description: Returns the integral type used to store enum values. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integral type used to store enum values. + */ CPPType *CPPEnumType:: get_element_type() { if (_element_type == NULL) { - // This enum is untyped. Use a suitable default, ie. 'int'. - // In the future, we might want to check whether it fits in an int. + // This enum is untyped. Use a suitable default, ie. 'int'. In the + // future, we might want to check whether it fits in an int. static CPPType *default_element_type = NULL; if (default_element_type == NULL) { default_element_type = @@ -81,11 +74,9 @@ get_element_type() { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::add_element -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance *CPPEnumType:: add_element(const string &name, CPPExpression *value) { CPPIdentifier *ident = new CPPIdentifier(name); @@ -105,8 +96,8 @@ add_element(const string &name, CPPExpression *value) { value = new CPPExpression(_last_value->_u._integer + 1); } else { - // We may not be able to determine the value just yet. No - // problem; we'll just define it as another expression. + // We may not be able to determine the value just yet. No problem; + // we'll just define it as another expression. static CPPExpression *const one = new CPPExpression(1); value = new CPPExpression('+', _last_value, one); } @@ -116,25 +107,19 @@ add_element(const string &name, CPPExpression *value) { return inst; } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPEnumType:: is_incomplete() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPEnumType:: is_fully_specified() const { if (!CPPDeclaration::is_fully_specified()) { @@ -159,11 +144,9 @@ is_fully_specified() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPEnumType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -210,11 +193,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPEnumType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != NULL) { @@ -246,21 +227,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPEnumType:: get_subtype() const { return ST_enum; } -//////////////////////////////////////////////////////////////////// -// Function: CPPEnumType::as_enum_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPEnumType *CPPEnumType:: as_enum_type() { return this; diff --git a/dtool/src/cppparser/cppEnumType.h b/dtool/src/cppparser/cppEnumType.h index 1d592b337b..85143d664b 100644 --- a/dtool/src/cppparser/cppEnumType.h +++ b/dtool/src/cppparser/cppEnumType.h @@ -1,16 +1,15 @@ -// Filename: cppEnumType.h -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppEnumType.h + * @author drose + * @date 1999-10-25 + */ #ifndef CPPENUMTYPE_H #define CPPENUMTYPE_H @@ -26,10 +25,9 @@ class CPPInstance; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPEnumType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPEnumType : public CPPExtensionType { public: CPPEnumType(CPPIdentifier *ident, CPPScope *current_scope, diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index fc33ee03fa..5adfb28232 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -1,17 +1,15 @@ -// Filename: cppExpression.cxx -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExpression.cxx + * @author drose + * @date 1999-10-25 + */ #include "cppExpression.h" #include "cppToken.h" @@ -30,43 +28,35 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression::Result:: Result() { _type = RT_error; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression::Result:: Result(int value) { _type = RT_integer; _u._integer = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression::Result:: Result(double value) { _type = RT_real; _u._real = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression::Result:: Result(void *value) { _type = RT_pointer; @@ -74,11 +64,9 @@ Result(void *value) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::as_integer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPExpression::Result:: as_integer() const { switch (_type) { @@ -99,11 +87,9 @@ as_integer() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::as_real -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double CPPExpression::Result:: as_real() const { switch (_type) { @@ -124,11 +110,9 @@ as_real() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::as_pointer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void *CPPExpression::Result:: as_pointer() const { switch (_type) { @@ -148,11 +132,9 @@ as_pointer() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::as_boolean -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPExpression::Result:: as_boolean() const { switch (_type) { @@ -172,11 +154,9 @@ as_boolean() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Result::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPExpression::Result:: output(ostream &out) const { switch (_type) { @@ -201,11 +181,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(bool value) : CPPDeclaration(CPPFile()) @@ -214,11 +192,9 @@ CPPExpression(bool value) : _u._boolean = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(unsigned long long value) : CPPDeclaration(CPPFile()) @@ -227,11 +203,9 @@ CPPExpression(unsigned long long value) : _u._integer = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(int value) : CPPDeclaration(CPPFile()) @@ -240,11 +214,9 @@ CPPExpression(int value) : _u._integer = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(long double value) : CPPDeclaration(CPPFile()) @@ -253,11 +225,9 @@ CPPExpression(long double value) : _u._real = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(const string &value) : CPPDeclaration(CPPFile()) @@ -266,11 +236,9 @@ CPPExpression(const string &value) : _str = value; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) : @@ -297,14 +265,12 @@ CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, _type = T_unknown_ident; _u._ident = ident; - //_u._ident->_native_scope = current_scope; + // _u._ident->_native_scope = current_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(int unary_operator, CPPExpression *op1) : CPPDeclaration(CPPFile()) @@ -316,11 +282,9 @@ CPPExpression(int unary_operator, CPPExpression *op1) : _u._op._op3 = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2) : CPPDeclaration(CPPFile()) @@ -332,11 +296,9 @@ CPPExpression(int binary_operator, CPPExpression *op1, CPPExpression *op2) : _u._op._op3 = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, CPPExpression *op3) : @@ -349,12 +311,9 @@ CPPExpression(int trinary_operator, CPPExpression *op1, CPPExpression *op2, _u._op._op3 = op3; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named typecast_op constructor -// Access: Public, Static -// Description: Creates an expression that represents a typecast -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Creates an expression that represents a typecast operation. + */ CPPExpression CPPExpression:: typecast_op(CPPType *type, CPPExpression *op1, Type cast_type) { assert(cast_type >= T_typecast && cast_type <= T_reinterpret_cast); @@ -365,12 +324,9 @@ typecast_op(CPPType *type, CPPExpression *op1, Type cast_type) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named construct_op constructor -// Access: Public, Static -// Description: Creates an expression that represents a constructor -// call. -//////////////////////////////////////////////////////////////////// +/** + * Creates an expression that represents a constructor call. + */ CPPExpression CPPExpression:: construct_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); @@ -388,12 +344,9 @@ construct_op(CPPType *type, CPPExpression *op1) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named new_op constructor -// Access: Public, Static -// Description: Creates an expression that represents a use of the -// new operator. -//////////////////////////////////////////////////////////////////// +/** + * Creates an expression that represents a use of the new operator. + */ CPPExpression CPPExpression:: new_op(CPPType *type, CPPExpression *op1) { CPPExpression expr(0); @@ -411,12 +364,9 @@ new_op(CPPType *type, CPPExpression *op1) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named typeid_op constructor -// Access: Public, Static -// Description: Creates an expression that represents a use of the -// typeid operator. -//////////////////////////////////////////////////////////////////// +/** + * Creates an expression that represents a use of the typeid operator. + */ CPPExpression CPPExpression:: typeid_op(CPPType *type, CPPType *std_type_info) { CPPExpression expr(0); @@ -426,12 +376,9 @@ typeid_op(CPPType *type, CPPType *std_type_info) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named typeid_op constructor -// Access: Public, Static -// Description: Creates an expression that represents a use of the -// typeid operator. -//////////////////////////////////////////////////////////////////// +/** + * Creates an expression that represents a use of the typeid operator. + */ CPPExpression CPPExpression:: typeid_op(CPPExpression *op1, CPPType *std_type_info) { CPPExpression expr(0); @@ -441,11 +388,9 @@ typeid_op(CPPExpression *op1, CPPType *std_type_info) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named sizeof_func constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: sizeof_func(CPPType *type) { CPPExpression expr(0); @@ -455,11 +400,9 @@ sizeof_func(CPPType *type) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named alignof_func constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: alignof_func(CPPType *type) { CPPExpression expr(0); @@ -469,11 +412,9 @@ alignof_func(CPPType *type) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named literal constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: literal(unsigned long long value, CPPInstance *lit_op) { CPPExpression expr(0); @@ -483,11 +424,9 @@ literal(unsigned long long value, CPPInstance *lit_op) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named literal constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: literal(long double value, CPPInstance *lit_op) { CPPExpression expr(0); @@ -497,11 +436,9 @@ literal(long double value, CPPInstance *lit_op) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named literal constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: literal(CPPExpression *value, CPPInstance *lit_op) { CPPExpression expr(0); @@ -511,11 +448,9 @@ literal(CPPExpression *value, CPPInstance *lit_op) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::named raw_literal constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression CPPExpression:: raw_literal(const string &raw, CPPInstance *lit_op) { CPPExpression expr(0); @@ -526,11 +461,9 @@ raw_literal(const string &raw, CPPInstance *lit_op) { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::get_nullptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const CPPExpression &CPPExpression:: get_nullptr() { static CPPExpression expr(0); @@ -538,11 +471,9 @@ get_nullptr() { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::get_default -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const CPPExpression &CPPExpression:: get_default() { static CPPExpression expr(0); @@ -550,11 +481,9 @@ get_default() { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::get_delete -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const CPPExpression &CPPExpression:: get_delete() { static CPPExpression expr(0); @@ -562,20 +491,16 @@ get_delete() { return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression:: ~CPPExpression() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::evaluate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression::Result CPPExpression:: evaluate() const { Result r1, r2; @@ -670,13 +595,13 @@ evaluate() const { assert(_u._op._op2 != NULL); r2 = _u._op._op2->evaluate(); - // The operators && and || are special cases: these are - // shirt-circuiting operators. Thus, if we are using either of - // these it might be acceptable for the second operand to be - // invalid, since we might never evaluate it. + // The operators && and || are special cases: these are shirt-circuiting + // operators. Thus, if we are using either of these it might be + // acceptable for the second operand to be invalid, since we might never + // evaluate it. - // In all other cases, both operands must be valid in order for - // the operation to be valid. + // In all other cases, both operands must be valid in order for the + // operation to be valid. if (r2._type == RT_error && (_u._op._operator != OROR && _u._op._operator != ANDAND)) { return r2; @@ -685,9 +610,9 @@ evaluate() const { case T_trinary_operation: - // The trinary operator is also a short-circuiting operator: we - // don't test the second or third operands until we need them. - // The only critical one is the first operand. + // The trinary operator is also a short-circuiting operator: we don't test + // the second or third operands until we need them. The only critical one + // is the first operand. // Fall through @@ -695,18 +620,16 @@ evaluate() const { assert(_u._op._op1 != NULL); r1 = _u._op._op1->evaluate(); if (r1._type == RT_error) { - // Here's one more special case: if the first operand is - // invalid, it really means we don't know how to evaluate it. - // However, if the operator is ||, then it might not matter as - // long as we can evaluate the second one *and* that comes out - // to be true. + // Here's one more special case: if the first operand is invalid, it + // really means we don't know how to evaluate it. However, if the + // operator is ||, then it might not matter as long as we can evaluate + // the second one *and* that comes out to be true. if (_u._op._operator == OROR && r2._type == RT_integer && r2.as_boolean()) { return r2; } - // Ditto for the operator being && and the second one coming out - // false. + // Ditto for the operator being && and the second one coming out false. if (_u._op._operator == ANDAND && r2._type == RT_integer && !r2.as_boolean()) { return r2; @@ -885,12 +808,10 @@ evaluate() const { return Result(); // Compiler kludge; can't get here. } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::determine_type -// Access: Public -// Description: Returns the type of the expression, if it is known, -// or NULL if the type cannot be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the expression, if it is known, or NULL if the type + * cannot be determined. + */ CPPType *CPPExpression:: determine_type() const { CPPType *t1 = (CPPType *)NULL; @@ -970,10 +891,9 @@ determine_type() const { case T_function: if (_u._fgroup->get_return_type() == (CPPType *)NULL) { - // There are multiple functions by this name that have different - // return types. We could attempt to differentiate them based - // on the parameter list, but that's a lot of work. Let's just - // give up. + // There are multiple functions by this name that have different return + // types. We could attempt to differentiate them based on the parameter + // list, but that's a lot of work. Let's just give up. return (CPPType *)NULL; } return _u._fgroup->_instances.front()->_type; @@ -996,9 +916,9 @@ determine_type() const { case T_sizeof: case T_alignof: - // Note: this should actually be size_t, but that is defined as a - // typedef in parser-inc. We could try to resolve it, but that's - // hacky. Eh, it's probably not worth the effort to get this right. + // Note: this should actually be size_t, but that is defined as a typedef + // in parser-inc. We could try to resolve it, but that's hacky. Eh, it's + // probably not worth the effort to get this right. return unsigned_long_type; case T_binary_operation: @@ -1144,14 +1064,11 @@ determine_type() const { return NULL; // Compiler kludge; can't get here. } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPExpression:: is_fully_specified() const { if (!CPPDeclaration::is_fully_specified()) { @@ -1228,11 +1145,9 @@ is_fully_specified() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPExpression:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -1280,7 +1195,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, decl = inst->substitute_decl(subst, current_scope, global_scope); if (decl != inst) { if (decl->as_instance()) { - // Replacing the variable reference with another variable reference. + // Replacing the variable reference with another variable + // reference. rep->_u._variable = decl->as_instance(); } else if (decl->as_expression()) { @@ -1372,13 +1288,10 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::is_tbd -// Access: Public -// Description: Returns true if any type within the expression list is -// a CPPTBDType and thus isn't fully determined right -// now. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any type within the expression list is a CPPTBDType and + * thus isn't fully determined right now. + */ bool CPPExpression:: is_tbd() const { switch (_type) { @@ -1441,11 +1354,9 @@ is_tbd() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPExpression:: output(ostream &out, int indent_level, CPPScope *scope, bool) const { switch (_type) { @@ -1463,8 +1374,8 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { case T_real: { - // We use our own dtoa implementation here because it guarantees - // to never format the number as an integer. + // We use our own dtoa implementation here because it guarantees to + // never format the number as an integer. char buffer[32]; pdtoa(_u._real, buffer); out << buffer; @@ -1532,9 +1443,9 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { break; case T_variable: - // We can just refer to the variable by name, except if it's a - // private constant, in which case we have to compute the value, - // since we may have to use it in generated code. + // We can just refer to the variable by name, except if it's a private + // constant, in which case we have to compute the value, since we may have + // to use it in generated code. if (_u._variable->_type != NULL && _u._variable->_initializer != NULL && _u._variable->_vis > V_public) { @@ -1846,31 +1757,25 @@ output(ostream &out, int indent_level, CPPScope *scope, bool) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPExpression:: get_subtype() const { return ST_expression; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::as_expression -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpression *CPPExpression:: as_expression() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::elevate_type -// Access: Public, Static -// Description: Returns the most general of the two given types. -//////////////////////////////////////////////////////////////////// +/** + * Returns the most general of the two given types. + */ CPPType *CPPExpression:: elevate_type(CPPType *t1, CPPType *t2) { CPPSimpleType *st1 = t1->as_simple_type(); @@ -1882,8 +1787,7 @@ elevate_type(CPPType *t1, CPPType *t2) { } if (st1->_type == st2->_type) { - // They have the same type, so return the one with the largest - // flag bits. + // They have the same type, so return the one with the largest flag bits. if (st1->_flags & CPPSimpleType::F_longlong) { return st1; } else if (st2->_flags & CPPSimpleType::F_longlong) { @@ -1919,12 +1823,10 @@ elevate_type(CPPType *t1, CPPType *t2) { return st1; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// expr is equivalent to another expr. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this expr is equivalent to + * another expr. + */ bool CPPExpression:: is_equal(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); @@ -2011,13 +1913,10 @@ is_equal(const CPPDeclaration *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpression::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// expr should be ordered before another expr of the -// same type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this expr should be ordered + * before another expr of the same type, in an arbitrary but fixed ordering. + */ bool CPPExpression:: is_less(const CPPDeclaration *other) const { const CPPExpression *ot = ((CPPDeclaration *)other)->as_expression(); diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index 644f3c5a96..71df065fd9 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -1,16 +1,15 @@ -// Filename: cppExpression.h -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExpression.h + * @author drose + * @date 1999-10-25 + */ #ifndef CPPEXPRESSION_H #define CPPEXPRESSION_H @@ -24,10 +23,9 @@ class CPPType; class CPPPreprocessor; class CPPFunctionGroup; -//////////////////////////////////////////////////////////////////// -// Class : CPPExpression -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPExpression : public CPPDeclaration { public: enum Type { @@ -162,8 +160,7 @@ public: CPPExpression *_op1; } _typecast; struct { - // One of the yytoken values: a character, or something - // like EQCOMPARE. + // One of the yytoken values: a character, or something like EQCOMPARE. int _operator; CPPExpression *_op1; CPPExpression *_op2; diff --git a/dtool/src/cppparser/cppExpressionParser.cxx b/dtool/src/cppparser/cppExpressionParser.cxx index cedf3c57b4..2ab7b30771 100644 --- a/dtool/src/cppparser/cppExpressionParser.cxx +++ b/dtool/src/cppparser/cppExpressionParser.cxx @@ -1,26 +1,22 @@ -// Filename: cppExpressionParser.cxx -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExpressionParser.cxx + * @author drose + * @date 1999-10-25 + */ #include "cppExpressionParser.h" #include "cppExpression.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPExpressionParser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpressionParser:: CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), @@ -29,20 +25,16 @@ CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope) : _expr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpressionParser::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExpressionParser:: ~CPPExpressionParser() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpressionParser::parse_expr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPExpressionParser:: parse_expr(const string &expr) { if (!init_const_expr(expr)) { @@ -55,11 +47,9 @@ parse_expr(const string &expr) { return get_error_count() == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpressionParser::parse_expr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPExpressionParser:: parse_expr(const string &expr, const CPPPreprocessor &filepos) { if (!init_const_expr(expr)) { @@ -74,11 +64,9 @@ parse_expr(const string &expr, const CPPPreprocessor &filepos) { return get_error_count() == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExpressionParser::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPExpressionParser:: output(ostream &out) const { if (_expr == NULL) { diff --git a/dtool/src/cppparser/cppExpressionParser.h b/dtool/src/cppparser/cppExpressionParser.h index f726850d39..f9ef78dafc 100644 --- a/dtool/src/cppparser/cppExpressionParser.h +++ b/dtool/src/cppparser/cppExpressionParser.h @@ -1,16 +1,15 @@ -// Filename: cppExpressionParser.h -// Created by: drose (25Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExpressionParser.h + * @author drose + * @date 1999-10-25 + */ #ifndef CPPEXPRESSIONPARSER_H #define CPPEXPRESSIONPARSER_H @@ -22,10 +21,9 @@ class CPPExpression; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPExpressionParser -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPExpressionParser : public CPPPreprocessor { public: CPPExpressionParser(CPPScope *current_scope, CPPScope *global_scope); @@ -48,5 +46,3 @@ operator << (ostream &out, const CPPExpressionParser &ep) { } #endif - - diff --git a/dtool/src/cppparser/cppExtensionType.cxx b/dtool/src/cppparser/cppExtensionType.cxx index d4b7d171c2..9e9aeb4c71 100644 --- a/dtool/src/cppparser/cppExtensionType.cxx +++ b/dtool/src/cppparser/cppExtensionType.cxx @@ -1,17 +1,15 @@ -// Filename: cppExtensionType.cxx -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExtensionType.cxx + * @author drose + * @date 1999-10-21 + */ #include "cppExtensionType.h" #include "cppTypedefType.h" @@ -19,11 +17,9 @@ #include "cppParser.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::Conextensionor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExtensionType:: CPPExtensionType(CPPExtensionType::Type type, CPPIdentifier *ident, CPPScope *current_scope, @@ -37,11 +33,9 @@ CPPExtensionType(CPPExtensionType::Type type, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPExtensionType:: get_simple_name() const { if (_ident == NULL) { @@ -50,11 +44,9 @@ get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPExtensionType:: get_local_name(CPPScope *scope) const { if (_ident == NULL) { @@ -63,11 +55,9 @@ get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPExtensionType:: get_fully_scoped_name() const { if (_ident == NULL) { @@ -76,25 +66,19 @@ get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPExtensionType:: is_incomplete() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPExtensionType:: is_tbd() const { if (_ident != (CPPIdentifier *)NULL) { @@ -103,42 +87,33 @@ is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPExtensionType:: is_trivial() const { return (_type == T_enum); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPExtensionType:: is_default_constructible() const { return (_type == T_enum); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPExtensionType:: is_copy_constructible() const { return (_type == T_enum); } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPExtensionType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -162,19 +137,16 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPExtensionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { if (_ident == NULL) { - // We can't resolve anonymous types. But that's OK, since they - // can't be forward declared anyway. + // We can't resolve anonymous types. But that's OK, since they can't be + // forward declared anyway. return this; } @@ -186,15 +158,12 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::is_equivalent_type -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPExtensionType:: is_equivalent(const CPPType &other) const { const CPPExtensionType *ot = ((CPPType *)&other)->as_extension_type(); @@ -202,17 +171,15 @@ is_equivalent(const CPPType &other) const { return CPPType::is_equivalent(other); } - // We consider two different extension types to be equivalent if - // they have the same name. + // We consider two different extension types to be equivalent if they have + // the same name. return *_ident == *ot->_ident; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPExtensionType:: output(ostream &out, int, CPPScope *scope, bool complete) const { if (_ident != NULL) { @@ -231,21 +198,17 @@ output(ostream &out, int, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPExtensionType:: get_subtype() const { return ST_extension; } -//////////////////////////////////////////////////////////////////// -// Function: CPPExtensionType::as_extension_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExtensionType *CPPExtensionType:: as_extension_type() { return this; diff --git a/dtool/src/cppparser/cppExtensionType.h b/dtool/src/cppparser/cppExtensionType.h index 7d1bbe2298..801809f753 100644 --- a/dtool/src/cppparser/cppExtensionType.h +++ b/dtool/src/cppparser/cppExtensionType.h @@ -1,16 +1,15 @@ -// Filename: cppExtensionType.h -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppExtensionType.h + * @author drose + * @date 1999-10-21 + */ #ifndef CPPEXTENSIONTYPE_H #define CPPEXTENSIONTYPE_H @@ -23,12 +22,11 @@ class CPPScope; class CPPIdentifier; -//////////////////////////////////////////////////////////////////// -// Class : CPPExtensionType -// Description : Base class of enum, class, struct, and union types. -// An instance of the base class (instead of one of -// the specializations) is used for forward references. -//////////////////////////////////////////////////////////////////// +/** + * Base class of enum, class, struct, and union types. An instance of the + * base class (instead of one of the specializations) is used for forward + * references. + */ class CPPExtensionType : public CPPType { public: enum Type { diff --git a/dtool/src/cppparser/cppFile.cxx b/dtool/src/cppparser/cppFile.cxx index 4e8e8fba95..a42602013f 100644 --- a/dtool/src/cppparser/cppFile.cxx +++ b/dtool/src/cppparser/cppFile.cxx @@ -1,27 +1,23 @@ -// Filename: cppFile.cxx -// Created by: drose (11Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFile.cxx + * @author drose + * @date 1999-11-11 + */ #include "cppFile.h" #include -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFile:: CPPFile(const Filename &filename, const Filename &filename_as_referenced, Source source) : @@ -34,11 +30,9 @@ CPPFile(const Filename &filename, const Filename &filename_as_referenced, } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFile:: CPPFile(const CPPFile ©) : _filename(copy._filename), @@ -48,11 +42,9 @@ CPPFile(const CPPFile ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPFile:: operator = (const CPPFile ©) { _filename = copy._filename; @@ -61,36 +53,28 @@ operator = (const CPPFile ©) { _pragma_once = copy._pragma_once; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFile:: ~CPPFile() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::is_c_or_i_file -// Access: Public -// Description: Returns true if the file appears to be a C or C++ -// source code file based on its extension. That is, -// returns true if the filename ends in .c, .C, .cc, -// .cpp, or any of a series of likely extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file appears to be a C or C++ source code file based on + * its extension. That is, returns true if the filename ends in .c, .C, .cc, + * .cpp, or any of a series of likely extensions. + */ bool CPPFile:: is_c_or_i_file() const { return is_c_or_i_file(_filename); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::is_c_or_i_file -// Access: Public, Static -// Description: Returns true if the file appears to be a C or C++ -// source code file based on its extension. That is, -// returns true if the filename ends in .c, .C, .cc, -// .cpp, or any of a series of likely extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file appears to be a C or C++ source code file based on + * its extension. That is, returns true if the filename ends in .c, .C, .cc, + * .cpp, or any of a series of likely extensions. + */ bool CPPFile:: is_c_or_i_file(const Filename &filename) { string extension = filename.get_extension(); @@ -106,27 +90,21 @@ is_c_or_i_file(const Filename &filename) { extension == "i" || extension == "t"); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::is_c_file -// Access: Public -// Description: Returns true if the file appears to be a C or C++ -// source code file based on its extension. That is, -// returns true if the filename ends in .c, .C, .cc, -// .cpp, or any of a series of likely extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file appears to be a C or C++ source code file based on + * its extension. That is, returns true if the filename ends in .c, .C, .cc, + * .cpp, or any of a series of likely extensions. + */ bool CPPFile:: is_c_file() const { return is_c_file(_filename); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::is_c_file -// Access: Public, Static -// Description: Returns true if the file appears to be a C or C++ -// source code file based on its extension. That is, -// returns true if the filename ends in .c, .C, .cc, -// .cpp, or any of a series of likely extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file appears to be a C or C++ source code file based on + * its extension. That is, returns true if the filename ends in .c, .C, .cc, + * .cpp, or any of a series of likely extensions. + */ bool CPPFile:: is_c_file(const Filename &filename) { string extension = filename.get_extension(); @@ -141,15 +119,12 @@ is_c_file(const Filename &filename) { extension == "cpp" || extension == "c++" || extension == "cxx"); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::replace_nearer -// Access: Public -// Description: If the other file is "nearer" than this file (in the -// sense that a file in the local directory is nearer -// than a file in the system directory, etc.), replaces -// this file's information with that of the other. -// Otherwise, does nothing. -//////////////////////////////////////////////////////////////////// +/** + * If the other file is "nearer" than this file (in the sense that a file in + * the local directory is nearer than a file in the system directory, etc.), + * replaces this file's information with that of the other. Otherwise, does + * nothing. + */ void CPPFile:: replace_nearer(const CPPFile &other) { if ((int)_source > (int)other._source) { @@ -157,51 +132,41 @@ replace_nearer(const CPPFile &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPFile:: operator < (const CPPFile &other) const { return _filename < other._filename; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Equality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPFile:: operator == (const CPPFile &other) const { return _filename == other._filename; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPFile:: operator != (const CPPFile &other) const { return _filename != other._filename; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::c_str -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *CPPFile:: c_str() const { return _filename.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFile::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPFile:: empty() const { return _filename.empty(); diff --git a/dtool/src/cppparser/cppFile.h b/dtool/src/cppparser/cppFile.h index 20ec4ba6d9..b284758615 100644 --- a/dtool/src/cppparser/cppFile.h +++ b/dtool/src/cppparser/cppFile.h @@ -1,16 +1,15 @@ -// Filename: cppFile.h -// Created by: drose (11Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFile.h + * @author drose + * @date 1999-11-11 + */ #ifndef CPPFILE_H #define CPPFILE_H @@ -18,13 +17,11 @@ #include "dtoolbase.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPFile -// Description : This defines a source file (typically a C++ header -// file) that is parsed by the CPPParser. Each -// declaration indicates the source file where it -// appeared. -//////////////////////////////////////////////////////////////////// +/** + * This defines a source file (typically a C++ header file) that is parsed by + * the CPPParser. Each declaration indicates the source file where it + * appeared. + */ class CPPFile { public: enum Source { @@ -67,4 +64,3 @@ inline ostream &operator << (ostream &out, const CPPFile &file) { } #endif - diff --git a/dtool/src/cppparser/cppFunctionGroup.cxx b/dtool/src/cppparser/cppFunctionGroup.cxx index 9e61e4ee84..2243d14708 100644 --- a/dtool/src/cppparser/cppFunctionGroup.cxx +++ b/dtool/src/cppparser/cppFunctionGroup.cxx @@ -1,28 +1,24 @@ -// Filename: cppFunctionGroup.cxx -// Created by: drose (11Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFunctionGroup.cxx + * @author drose + * @date 1999-11-11 + */ #include "cppFunctionGroup.h" #include "cppFunctionType.h" #include "cppInstance.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionGroup:: CPPFunctionGroup(const string &name) : CPPDeclaration(CPPFile()), @@ -30,23 +26,18 @@ CPPFunctionGroup(const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionGroup:: ~CPPFunctionGroup() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::get_return_type -// Access: Public -// Description: If all the functions that share this name have the -// same return type, returns that type. Otherwise, if -// some functions have different return types, returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * If all the functions that share this name have the same return type, + * returns that type. Otherwise, if some functions have different return + * types, returns NULL. + */ CPPType *CPPFunctionGroup:: get_return_type() const { CPPType *return_type = NULL; @@ -66,11 +57,9 @@ get_return_type() const { return return_type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPFunctionGroup:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!_instances.empty()) { @@ -86,21 +75,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPFunctionGroup:: get_subtype() const { return ST_function_group; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionGroup::as_function_group -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionGroup *CPPFunctionGroup:: as_function_group() { return this; diff --git a/dtool/src/cppparser/cppFunctionGroup.h b/dtool/src/cppparser/cppFunctionGroup.h index 3a9e4ad8df..c33eee3907 100644 --- a/dtool/src/cppparser/cppFunctionGroup.h +++ b/dtool/src/cppparser/cppFunctionGroup.h @@ -1,16 +1,15 @@ -// Filename: cppFunctionGroup.h -// Created by: drose (11Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFunctionGroup.h + * @author drose + * @date 1999-11-11 + */ #ifndef CPPFUNCTIONGROUP_H #define CPPFUNCTIONGROUP_H @@ -21,15 +20,12 @@ class CPPInstance; -//////////////////////////////////////////////////////////////////// -// Class : CPPFunctionGroup -// Description : This class is simply a container for one or more -// CPPInstances for functions of the same name. It's -// handy for storing in the CPPScope, so that -// CPPScope::find_symbol() can return a single pointer -// to indicate all of the functions that may share a -// given name. -//////////////////////////////////////////////////////////////////// +/** + * This class is simply a container for one or more CPPInstances for functions + * of the same name. It's handy for storing in the CPPScope, so that + * CPPScope::find_symbol() can return a single pointer to indicate all of the + * functions that may share a given name. + */ class CPPFunctionGroup : public CPPDeclaration { public: CPPFunctionGroup(const string &name); @@ -49,5 +45,3 @@ public: }; #endif - - diff --git a/dtool/src/cppparser/cppFunctionType.cxx b/dtool/src/cppparser/cppFunctionType.cxx index be716f35c9..3232fc56fa 100644 --- a/dtool/src/cppparser/cppFunctionType.cxx +++ b/dtool/src/cppparser/cppFunctionType.cxx @@ -1,28 +1,24 @@ -// Filename: cppFunctionType.cxx -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFunctionType.cxx + * @author drose + * @date 1999-10-21 + */ #include "cppFunctionType.h" #include "cppParameterList.h" #include "cppSimpleType.h" #include "cppInstance.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionType:: CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, int flags) : @@ -44,11 +40,9 @@ CPPFunctionType(CPPType *return_type, CPPParameterList *parameters, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionType:: CPPFunctionType(const CPPFunctionType ©) : CPPType(copy), @@ -59,11 +53,9 @@ CPPFunctionType(const CPPFunctionType ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPFunctionType:: operator = (const CPPFunctionType ©) { CPPType::operator = (copy); @@ -73,14 +65,11 @@ operator = (const CPPFunctionType ©) { _class_owner = copy._class_owner; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPFunctionType:: is_fully_specified() const { return CPPType::is_fully_specified() && @@ -88,11 +77,9 @@ is_fully_specified() const { _parameters->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPFunctionType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -120,14 +107,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPFunctionType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *rtype = _return_type->resolve_type(current_scope, global_scope); @@ -143,14 +127,11 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPFunctionType:: is_tbd() const { if (_return_type->is_tbd()) { @@ -159,43 +140,35 @@ is_tbd() const { return _parameters->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPFunctionType:: is_trivial() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPFunctionType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output(out, indent_level, scope, complete, -1); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::output -// Access: Public -// Description: The additional parameter allows us to specify the -// number of parameters we wish to show the default -// values for. If num_default_parameters is >= 0, it -// indicates the number of default parameter values to -// show on output. Otherwise, all parameter values are -// shown. -//////////////////////////////////////////////////////////////////// +/** + * The additional parameter allows us to specify the number of parameters we + * wish to show the default values for. If num_default_parameters is >= 0, it + * indicates the number of default parameter values to show on output. + * Otherwise, all parameter values are shown. + */ void CPPFunctionType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { if (_flags & F_trailing_return_type) { - // It was declared using trailing return type, so let's format it that way. + // It was declared using trailing return type, so let's format it that + // way. out << "auto("; _parameters->output(out, scope, true, num_default_parameters); out << ")"; @@ -234,14 +207,11 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPFunctionType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -249,16 +219,12 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, output_instance(out, indent_level, scope, complete, prename, name, -1); } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::output_instance -// Access: Public -// Description: The additional parameter allows us to specify the -// number of parameters we wish to show the default -// values for. If num_default_parameters is >= 0, it -// indicates the number of default parameter values to -// show on output. Otherwise, all parameter values are -// shown. -//////////////////////////////////////////////////////////////////// +/** + * The additional parameter allows us to specify the number of parameters we + * wish to show the default values for. If num_default_parameters is >= 0, it + * indicates the number of default parameter values to show on output. + * Otherwise, all parameter values are shown. + */ void CPPFunctionType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -274,7 +240,8 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, out << prename << name << str; } else if (_flags & F_trailing_return_type) { - // It was declared using trailing return type, so let's format it that way. + // It was declared using trailing return type, so let's format it that + // way. out << "auto "; if (prename.empty()) { @@ -314,17 +281,13 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::get_num_default_parameters -// Access: Public -// Description: Returns the number of parameters in the list that may -// take default values. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parameters in the list that may take default values. + */ int CPPFunctionType:: get_num_default_parameters() const { - // The trick is just to count, beginning from the end and working - // towards the front, the number of parameters that have some - // initializer. + // The trick is just to count, beginning from the end and working towards + // the front, the number of parameters that have some initializer. const CPPParameterList::Parameters ¶ms = _parameters->_parameters; CPPParameterList::Parameters::const_reverse_iterator pi; @@ -338,34 +301,27 @@ get_num_default_parameters() const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPFunctionType:: get_subtype() const { return ST_function; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::as_function_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionType *CPPFunctionType:: as_function_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_equivalent_function -// Access: Public -// Description: This is similar to is_equal(), except it is more -// forgiving: it considers the functions to be -// equivalent only if the return type and the types of -// all parameters match. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to is_equal(), except it is more forgiving: it considers + * the functions to be equivalent only if the return type and the types of all + * parameters match. + */ bool CPPFunctionType:: is_equivalent_function(const CPPFunctionType &other) const { if (!_return_type->is_equivalent(*other._return_type)) { @@ -383,12 +339,10 @@ is_equivalent_function(const CPPFunctionType &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPFunctionType:: is_equal(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); @@ -407,13 +361,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPFunctionType:: is_less(const CPPDeclaration *other) const { const CPPFunctionType *ot = ((CPPDeclaration *)other)->as_function_type(); diff --git a/dtool/src/cppparser/cppFunctionType.h b/dtool/src/cppparser/cppFunctionType.h index d80c815b00..6618c625fe 100644 --- a/dtool/src/cppparser/cppFunctionType.h +++ b/dtool/src/cppparser/cppFunctionType.h @@ -1,16 +1,15 @@ -// Filename: cppFunctionType.h -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppFunctionType.h + * @author drose + * @date 1999-10-21 + */ #ifndef CPPFUNCTIONTYPE_H #define CPPFUNCTIONTYPE_H @@ -22,10 +21,9 @@ class CPPParameterList; class CPPIdentifier; -//////////////////////////////////////////////////////////////////// -// Class : CPPFunctionType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPFunctionType : public CPPType { public: enum Flags { @@ -93,4 +91,3 @@ protected: }; #endif - diff --git a/dtool/src/cppparser/cppGlobals.cxx b/dtool/src/cppparser/cppGlobals.cxx index c0dbecdc77..a435227203 100644 --- a/dtool/src/cppparser/cppGlobals.cxx +++ b/dtool/src/cppparser/cppGlobals.cxx @@ -1,16 +1,15 @@ -// Filename: cppGlobals.cxx -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppGlobals.cxx + * @author drose + * @date 2000-05-16 + */ #include "cppGlobals.h" diff --git a/dtool/src/cppparser/cppGlobals.h b/dtool/src/cppparser/cppGlobals.h index 9f4d5c4c3a..9cf4e8711a 100644 --- a/dtool/src/cppparser/cppGlobals.h +++ b/dtool/src/cppparser/cppGlobals.h @@ -1,29 +1,26 @@ -// Filename: cppGlobals.h -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppGlobals.h + * @author drose + * @date 2000-05-16 + */ #ifndef CPPGLOBALS_H #define CPPGLOBALS_H #include "dtoolbase.h" -// Some compilers (notably VC++) define a special keyword to represent -// a 64-bit integer, but don't recognize "long long int". To parse -// (and generate) code for these compilers, set this string to the -// 64-bit integer typename keyword. +// Some compilers (notably VC++) define a special keyword to represent a +// 64-bit integer, but don't recognize "long long int". To parse (and +// generate) code for these compilers, set this string to the 64-bit integer +// typename keyword. extern string cpp_longlong_keyword; #endif - - diff --git a/dtool/src/cppparser/cppIdentifier.cxx b/dtool/src/cppparser/cppIdentifier.cxx index 678bea56b8..940b2a5daf 100644 --- a/dtool/src/cppparser/cppIdentifier.cxx +++ b/dtool/src/cppparser/cppIdentifier.cxx @@ -1,17 +1,15 @@ -// Filename: cppIdentifier.cxx -// Created by: drose (26Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppIdentifier.cxx + * @author drose + * @date 1999-10-26 + */ #include "cppIdentifier.h" #include "cppScope.h" @@ -22,11 +20,9 @@ #include "cppStructType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPIdentifier:: CPPIdentifier(const string &name, const CPPFile &file) { _names.push_back(CPPNameComponent(name)); @@ -38,11 +34,9 @@ CPPIdentifier(const string &name, const CPPFile &file) { _loc.file = file; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { _names.push_back(name); @@ -54,53 +48,43 @@ CPPIdentifier(const CPPNameComponent &name, const CPPFile &file) { _loc.file = file; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPIdentifier:: CPPIdentifier(const string &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(CPPNameComponent(name)); _native_scope = (CPPScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPIdentifier:: CPPIdentifier(const CPPNameComponent &name, const cppyyltype &loc) : _loc(loc) { _names.push_back(name); _native_scope = (CPPScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::add_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPIdentifier:: add_name(const string &name) { _names.push_back(CPPNameComponent(name)); } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::add_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPIdentifier:: add_name(const CPPNameComponent &name) { _names.push_back(name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPIdentifier:: operator == (const CPPIdentifier &other) const { if (_names.size() != other._names.size()) { @@ -115,21 +99,17 @@ operator == (const CPPIdentifier &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPIdentifier:: operator != (const CPPIdentifier &other) const { return !(*this == other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPIdentifier:: operator < (const CPPIdentifier &other) const { if (_names.size() != other._names.size()) { @@ -144,32 +124,26 @@ operator < (const CPPIdentifier &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::is_scoped -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPIdentifier:: is_scoped() const { return _names.size() > 1; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::get_simple_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPIdentifier:: get_simple_name() const { return _names.back().get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::get_local_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPIdentifier:: get_local_name(CPPScope *scope) const { assert(!_names.empty()); @@ -183,12 +157,12 @@ get_local_name(CPPScope *scope) const { result = get_fully_scoped_name(); } else { - // Determine the scope of everything up until but not including the - // last name. + // Determine the scope of everything up until but not including the last + // name. CPPScope *my_scope = get_scope(scope, NULL); - // Strip off template scopes, since they don't add anything - // particularly meaningful to the local name. + // Strip off template scopes, since they don't add anything particularly + // meaningful to the local name. while (my_scope != NULL && my_scope->as_template_scope() != NULL) { my_scope = my_scope->get_parent_scope(); } @@ -208,11 +182,9 @@ get_local_name(CPPScope *scope) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::get_fully_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPIdentifier:: get_fully_scoped_name() const { assert(!_names.empty()); @@ -226,14 +198,11 @@ get_fully_scoped_name() const { return name; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::is_fully_specified -// Access: Public -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPIdentifier:: is_fully_specified() const { Names::const_iterator ni; @@ -246,13 +215,10 @@ is_fully_specified() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::is_tbd -// Access: Public -// Description: Returns true if the identifier includes a -// template parameter list that includes some -// not-yet-defined type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the identifier includes a template parameter list that + * includes some not-yet-defined type. + */ bool CPPIdentifier:: is_tbd() const { Names::const_iterator ni; @@ -265,11 +231,9 @@ is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPIdentifier:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -282,8 +246,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, int i = 0; if (_names[i].empty()) { - // This identifier starts with a ::, thus it begins at the global - // scope. + // This identifier starts with a ::, thus it begins at the global scope. scope = global_scope; i++; } @@ -310,11 +273,9 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, return scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPIdentifier:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, @@ -328,8 +289,7 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, int i = 0; if (_names[i].empty()) { - // This identifier starts with a ::, thus it begins at the global - // scope. + // This identifier starts with a ::, thus it begins at the global scope. scope = global_scope; i++; } @@ -357,19 +317,14 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, return scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_type -// Access: Public -// Description: Looks up the identifier in the current and/or global -// scopes, and returns a CPPType pointer if it seems to -// refer to a type, or NULL if it does not. If -// force_instantiate is true, the type will be -// instantiated as fully as possible right now, even if -// it means instantiating it into an identical template -// type. Otherwise, the instantiation may be delayed -// for optimization reasons, and a CPPTBDType -// placeholder may be returned instead. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the identifier in the current and/or global scopes, and returns a + * CPPType pointer if it seems to refer to a type, or NULL if it does not. If + * force_instantiate is true, the type will be instantiated as fully as + * possible right now, even if it means instantiating it into an identical + * template type. Otherwise, the instantiation may be delayed for + * optimization reasons, and a CPPTBDType placeholder may be returned instead. + */ CPPType *CPPIdentifier:: find_type(CPPScope *current_scope, CPPScope *global_scope, bool force_instantiate, @@ -402,20 +357,18 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, // Otherwise, we'll have to instantiate the type later. type = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } - // type->_file.replace_nearer(_file); + // type->_file.replace_nearer(_file); } */ } return type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_type -// Access: Public -// Description: This flavor of find_type() will instantiate any scope -// names in the identifier. It's useful for fully -// defining a type while instantiating a class. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of find_type() will instantiate any scope names in the + * identifier. It's useful for fully defining a type while instantiating a + * class. + */ CPPType *CPPIdentifier:: find_type(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, @@ -430,8 +383,7 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, // This is a template type. if (is_fully_specified()) { - // If our identifier fully specifies the instantiation, then - // apply it. + // If our identifier fully specifies the instantiation, then apply it. CPPDeclaration *decl = type->instantiate(_names.back().get_templ(), current_scope, global_scope, @@ -448,17 +400,15 @@ find_type(CPPScope *current_scope, CPPScope *global_scope, // Otherwise, we'll have to instantiate the type later. type = CPPType::new_type(new CPPTBDType((CPPIdentifier *)this)); } - // type->_file.replace_nearer(_file); + // type->_file.replace_nearer(_file); } return type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_symbol -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPIdentifier:: find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -470,7 +420,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration *sym; if (!_names.back().has_templ()) { if (_names.size() > 1 && scope->get_simple_name() == get_simple_name()) { - // An identifier like Class::Class always refers to the class constructor. +/** + + */ sym = scope->get_struct_type()->get_constructor(); } else { sym = scope->find_symbol(get_simple_name()); @@ -494,11 +446,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, return sym; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_symbol -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPIdentifier:: find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration::SubstDecl &subst, @@ -511,7 +461,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, CPPDeclaration *sym; if (!_names.back().has_templ()) { if (_names.size() > 1 && scope->get_simple_name() == get_simple_name()) { - // An identifier like Class::Class always refers to the class constructor. +/** + + */ sym = scope->get_struct_type()->get_constructor(); } else { sym = scope->find_symbol(get_simple_name()); @@ -536,11 +488,9 @@ find_symbol(CPPScope *current_scope, CPPScope *global_scope, return sym; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_template -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPIdentifier:: find_template(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -551,11 +501,9 @@ find_template(CPPScope *current_scope, CPPScope *global_scope, return scope->find_template(get_simple_name()); } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::find_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPIdentifier:: find_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -567,11 +515,9 @@ find_scope(CPPScope *current_scope, CPPScope *global_scope, } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::substitute_decl -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPIdentifier *CPPIdentifier:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -596,11 +542,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPIdentifier:: output(ostream &out, CPPScope *scope) const { if (scope == NULL) { @@ -611,11 +555,9 @@ output(ostream &out, CPPScope *scope) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::output_local_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPIdentifier:: output_local_name(ostream &out, CPPScope *scope) const { assert(!_names.empty()); @@ -625,8 +567,8 @@ output_local_name(ostream &out, CPPScope *scope) const { } else if (_names.front().empty()) { output_fully_scoped_name(out); } else { - // Determine the scope of everything up until but not including the - // last name. + // Determine the scope of everything up until but not including the last + // name. CPPScope *my_scope = get_scope(scope, NULL); if (my_scope == NULL) { @@ -637,11 +579,9 @@ output_local_name(ostream &out, CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPIdentifier::output_fully_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPIdentifier:: output_fully_scoped_name(ostream &out) const { if (_native_scope != NULL) { @@ -656,4 +596,3 @@ output_fully_scoped_name(ostream &out) const { ++ni; } } - diff --git a/dtool/src/cppparser/cppIdentifier.h b/dtool/src/cppparser/cppIdentifier.h index 964db5bb43..abb6405fc6 100644 --- a/dtool/src/cppparser/cppIdentifier.h +++ b/dtool/src/cppparser/cppIdentifier.h @@ -1,16 +1,15 @@ -// Filename: cppIdentifier.h -// Created by: drose (26Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppIdentifier.h + * @author drose + * @date 1999-10-26 + */ #ifndef CPPIDENTIFIER_H #define CPPIDENTIFIER_H @@ -30,10 +29,9 @@ class CPPType; class CPPPreprocessor; class CPPTemplateParameterList; -//////////////////////////////////////////////////////////////////// -// Class : CPPIdentifier -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPIdentifier { public: CPPIdentifier(const string &name, const CPPFile &file = CPPFile()); diff --git a/dtool/src/cppparser/cppInstance.cxx b/dtool/src/cppparser/cppInstance.cxx index 7ac4792043..ce01da78e4 100644 --- a/dtool/src/cppparser/cppInstance.cxx +++ b/dtool/src/cppparser/cppInstance.cxx @@ -1,17 +1,15 @@ -// Filename: cppInstance.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppInstance.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppInstance.h" #include "cppInstanceIdentifier.h" @@ -28,11 +26,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance:: CPPInstance(CPPType *type, const string &name, int storage_class) : CPPDeclaration(CPPFile()), @@ -45,11 +41,9 @@ CPPInstance(CPPType *type, const string &name, int storage_class) : _initializer = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance:: CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class) : CPPDeclaration(CPPFile()), @@ -62,14 +56,11 @@ CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class) : _initializer = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Constructor -// Access: Public -// Description: Constructs a new CPPInstance object that defines a -// variable of the indicated type according to the type -// and the InstanceIdentifier. The InstanceIdentifier -// pointer is deallocated. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CPPInstance object that defines a variable of the + * indicated type according to the type and the InstanceIdentifier. The + * InstanceIdentifier pointer is deallocated. + */ CPPInstance:: CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, const CPPFile &file) : @@ -85,23 +76,18 @@ CPPInstance(CPPType *type, CPPInstanceIdentifier *ii, int storage_class, CPPParameterList *params = ii->get_initializer(); if (params != (CPPParameterList *)NULL) { - // In this case, the instance has a parameter-list initializer, e.g.: - // - // int foo(0); - // - // We really should save this initializer in the instance object. - // But we don't for now, since no one really cares about - // initializers anyway. + // In this case, the instance has a parameter-list initializer, e.g.: int + // foo(0); We really should save this initializer in the instance object. + // But we don't for now, since no one really cares about initializers + // anyway. } delete ii; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance:: CPPInstance(const CPPInstance ©) : CPPDeclaration(copy), @@ -115,25 +101,20 @@ CPPInstance(const CPPInstance ©) : assert(_type != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance:: ~CPPInstance() { // Can't delete the identifier. Don't try. } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::make_typecast_function -// Access: Public, Static -// Description: Constructs and returns a new CPPInstance object that -// corresponds to a function prototype declaration for a -// typecast method, whose return type is implicit in the -// identifier type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs and returns a new CPPInstance object that corresponds to a + * function prototype declaration for a typecast method, whose return type is + * implicit in the identifier type. + */ CPPInstance *CPPInstance:: make_typecast_function(CPPInstance *inst, CPPIdentifier *ident, CPPParameterList *parameters, int function_flags) { @@ -148,11 +129,9 @@ make_typecast_function(CPPInstance *inst, CPPIdentifier *ident, return new CPPInstance(ft, ident); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPInstance:: operator == (const CPPInstance &other) const { if (_type != other._type) { @@ -165,9 +144,8 @@ operator == (const CPPInstance &other) const { return false; } - // We *do* care about the identifier. We need to differentiate - // types of function variables, among possibly other things, based - // on the identifier. + // We *do* care about the identifier. We need to differentiate types of + // function variables, among possibly other things, based on the identifier. if ((_ident == NULL && other._ident != NULL) || (_ident != NULL && other._ident == NULL) || (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) @@ -187,21 +165,17 @@ operator == (const CPPInstance &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPInstance:: operator != (const CPPInstance &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPInstance:: operator < (const CPPInstance &other) const { if (_type != other._type) { @@ -214,9 +188,8 @@ operator < (const CPPInstance &other) const { return _alignment < other._alignment; } - // We *do* care about the identifier. We need to differentiate - // types of function variables, among possibly other things, based - // on the identifier. + // We *do* care about the identifier. We need to differentiate types of + // function variables, among possibly other things, based on the identifier. if ((_ident == NULL && other._ident != NULL) || (_ident != NULL && other._ident == NULL) || (_ident != NULL && other._ident != NULL && *_ident != *other._ident)) @@ -242,15 +215,11 @@ operator < (const CPPInstance &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::set_initializer -// Access: Public -// Description: Sets the value of the expression that is used to -// initialize the variable, or the default value for a -// parameter. If a non-null expression is set on a -// function declaration, it implies that the function is -// pure virtual. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the expression that is used to initialize the variable, + * or the default value for a parameter. If a non-null expression is set on a + * function declaration, it implies that the function is pure virtual. + */ void CPPInstance:: set_initializer(CPPExpression *initializer) { if (_type->as_function_type() != (CPPFunctionType *)NULL) { @@ -274,34 +243,27 @@ set_initializer(CPPExpression *initializer) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::set_alignment -// Access: Public -// Description: Sets the number of bytes to align this instance to. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of bytes to align this instance to. + */ void CPPInstance:: set_alignment(int align) { _alignment = new CPPExpression(align); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::set_alignment -// Access: Public -// Description: Sets the expression that is used to determine the -// required alignment for the variable. This should -// be a constant expression, but we don't presently -// verify that it is. -//////////////////////////////////////////////////////////////////// +/** + * Sets the expression that is used to determine the required alignment for + * the variable. This should be a constant expression, but we don't presently + * verify that it is. + */ void CPPInstance:: set_alignment(CPPExpression *const_expr) { _alignment = const_expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::is_scoped -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPInstance:: is_scoped() const { if (_ident == NULL) { @@ -311,11 +273,9 @@ is_scoped() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPInstance:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -326,11 +286,9 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::get_simple_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPInstance:: get_simple_name() const { if (_ident == NULL) { @@ -340,11 +298,9 @@ get_simple_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::get_local_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPInstance:: get_local_name(CPPScope *scope) const { if (_ident == NULL) { @@ -354,11 +310,9 @@ get_local_name(CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::get_fully_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPInstance:: get_fully_scoped_name() const { if (_ident == NULL) { @@ -368,13 +322,11 @@ get_fully_scoped_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::check_for_constructor -// Access: Public -// Description: If this is a function type instance, checks whether -// the function name matches the class name (or ~name), -// and if so, flags it as a constructor (or destructor). -//////////////////////////////////////////////////////////////////// +/** + * If this is a function type instance, checks whether the function name + * matches the class name (or ~name), and if so, flags it as a constructor (or + * destructor). + */ void CPPInstance:: check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { CPPScope *scope = get_scope(current_scope, global_scope); @@ -432,11 +384,9 @@ check_for_constructor(CPPScope *current_scope, CPPScope *global_scope) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::instantiate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPInstance:: instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, @@ -453,8 +403,8 @@ instantiate(const CPPTemplateParameterList *actual_params, Instantiations::const_iterator ii; ii = _instantiations.find(actual_params); if (ii != _instantiations.end()) { - // We've already instantiated this instance with these parameters. - // Return that. + // We've already instantiated this instance with these parameters. Return + // that. return (*ii).second; } @@ -469,8 +419,8 @@ instantiate(const CPPTemplateParameterList *actual_params, ((CPPInstance *)this)->substitute_decl(subst, current_scope, global_scope) ->as_instance(); if (inst == this) { - // Hmm, nothing to substitute. Make a new instance anyway, so we - // can change the name. + // Hmm, nothing to substitute. Make a new instance anyway, so we can + // change the name. inst = new CPPInstance(*this); } assert(inst != NULL); @@ -487,14 +437,11 @@ instantiate(const CPPTemplateParameterList *actual_params, return inst; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPInstance:: is_fully_specified() const { if (_ident != NULL && !_ident->is_fully_specified()) { @@ -507,11 +454,9 @@ is_fully_specified() const { _type->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPInstance:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -546,33 +491,27 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstance:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output(out, indent_level, scope, complete, -1); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::output -// Access: Public -// Description: The extra parameter comes into play only when we -// happen to be outputting a function prototype. See -// CPPFunctionType::output(). -//////////////////////////////////////////////////////////////////// +/** + * The extra parameter comes into play only when we happen to be outputting a + * function prototype. See CPPFunctionType::output(). + */ void CPPInstance:: output(ostream &out, int indent_level, CPPScope *scope, bool complete, int num_default_parameters) const { assert(_type != NULL); if (_type->is_parameter_expr()) { - // In this case, the whole thing is really an expression, and not - // an instance at all. This can only happen if we parsed an - // instance declaration while we thought we were parsing a - // function prototype. + // In this case, the whole thing is really an expression, and not an + // instance at all. This can only happen if we parsed an instance + // declaration while we thought we were parsing a function prototype. out << *_initializer; return; } @@ -653,21 +592,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete, } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPInstance:: get_subtype() const { return ST_instance; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstance::as_instance -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstance *CPPInstance:: as_instance() { return this; diff --git a/dtool/src/cppparser/cppInstance.h b/dtool/src/cppparser/cppInstance.h index 81578a1e35..5e6459fbda 100644 --- a/dtool/src/cppparser/cppInstance.h +++ b/dtool/src/cppparser/cppInstance.h @@ -1,16 +1,15 @@ -// Filename: cppInstance.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppInstance.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPINSTANCE_H #define CPPINSTANCE_H @@ -27,14 +26,13 @@ class CPPParameterList; class CPPScope; class CPPExpression; -//////////////////////////////////////////////////////////////////// -// Class : CPPInstance -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPInstance : public CPPDeclaration { public: - // Some of these flags clearly only make sense in certain contexts, - // e.g. for a function or method. + // Some of these flags clearly only make sense in certain contexts, e.g. + // for a function or method. enum StorageClass { SC_static = 0x0001, SC_extern = 0x0002, @@ -51,10 +49,10 @@ public: // This bit is only set by CPPStructType::check_virtual(). SC_inherited_virtual = 0x0800, - // This is a special "storage class" for methods tagged with the - // BLOCKING macro (i.e. the special __blocking keyword). These - // are methods that might block and therefore need to release - // Python threads for their duration. + // This is a special "storage class" for methods tagged with the BLOCKING + // macro (i.e. the special __blocking keyword). These are methods that + // might block and therefore need to release Python threads for their + // duration. SC_blocking = 0x1000, // And this is for methods tagged with __extension, which declares @@ -129,4 +127,3 @@ private: }; #endif - diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index 044dc34d75..052b1067ed 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -1,17 +1,15 @@ -// Filename: cppInstanceIdentifier.cxx -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppInstanceIdentifier.cxx + * @author drose + * @date 1999-10-21 + */ #include "cppInstanceIdentifier.h" #include "cppPointerType.h" @@ -22,11 +20,9 @@ #include "cppParameterList.h" #include "cppIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Modifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstanceIdentifier::Modifier:: Modifier(CPPInstanceIdentifierType type) : _type(type) @@ -37,11 +33,9 @@ Modifier(CPPInstanceIdentifierType type) : _expr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Modifier::named func_type constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier:: func_type(CPPParameterList *params, int flags, CPPType *trailing_return_type) { Modifier mod(IIT_func); @@ -51,11 +45,9 @@ func_type(CPPParameterList *params, int flags, CPPType *trailing_return_type) { return mod; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Modifier::named array_type constructor -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier:: array_type(CPPExpression *expr) { Modifier mod(IIT_array); @@ -63,11 +55,9 @@ array_type(CPPExpression *expr) { return mod; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Modifier::named scoped_pointer_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier:: scoped_pointer_type(CPPIdentifier *scoping) { Modifier mod(IIT_scoped_pointer); @@ -75,12 +65,10 @@ scoped_pointer_type(CPPIdentifier *scoping) { return mod; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Modifier::named initializer_type constructor -// Access: Public, Static -// Description: This is used only for instance declarations that turn -// out to be have a parameter list for an initializer. -//////////////////////////////////////////////////////////////////// +/** + * This is used only for instance declarations that turn out to be have a + * parameter list for an initializer. + */ CPPInstanceIdentifier::Modifier CPPInstanceIdentifier::Modifier:: initializer_type(CPPParameterList *params) { Modifier mod(IIT_initializer); @@ -88,26 +76,21 @@ initializer_type(CPPParameterList *params) { return mod; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPInstanceIdentifier:: CPPInstanceIdentifier(CPPIdentifier *ident) : _ident(ident), _bit_width(-1) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::unroll_type -// Access: Public -// Description: Unrolls the list of type punctuation on either side -// of the identifier to determine the actual type -// represented by the identifier, given the indicated -// starting type (that is, the type name written to the -// left of the identifier). -//////////////////////////////////////////////////////////////////// +/** + * Unrolls the list of type punctuation on either side of the identifier to + * determine the actual type represented by the identifier, given the + * indicated starting type (that is, the type name written to the left of the + * identifier). + */ CPPType *CPPInstanceIdentifier:: unroll_type(CPPType *start_type) { CPPType *result = r_unroll_type(start_type, _modifiers.begin()); @@ -115,27 +98,23 @@ unroll_type(CPPType *start_type) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_modifier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_modifier(CPPInstanceIdentifierType type) { _modifiers.push_back(Modifier(type)); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_func_modifier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_type) { - // As a special hack, if we added a parameter list to an operator - // function, check if the parameter list is empty. If it is, this - // is really a unary operator, so set the unary_op flag. Operators - // () and [] are never considered unary operators. + // As a special hack, if we added a parameter list to an operator function, + // check if the parameter list is empty. If it is, this is really a unary + // operator, so set the unary_op flag. Operators () and [] are never + // considered unary operators. if (_ident != NULL && _ident->get_simple_name().substr(0, 9) == "operator ") { @@ -157,26 +136,22 @@ add_func_modifier(CPPParameterList *params, int flags, CPPType *trailing_return_ _modifiers.push_back(Modifier::func_type(params, flags, trailing_return_type)); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_scoped_pointer_modifier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_scoped_pointer_modifier(CPPIdentifier *scoping) { _modifiers.push_back(Modifier::scoped_pointer_type(scoping)); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_array_modifier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_array_modifier(CPPExpression *expr) { - // Special case for operator new[] and delete[]. We're not really - // adding an array modifier to them, but appending [] to the - // identifier. This is to work around a parser ambiguity. + // Special case for operator new[] and delete[]. We're not really adding an + // array modifier to them, but appending [] to the identifier. This is to + // work around a parser ambiguity. if (_ident != NULL && (_ident->get_simple_name() == "operator delete" || _ident->get_simple_name() == "operator new")) { @@ -186,21 +161,17 @@ add_array_modifier(CPPExpression *expr) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_initializer_modifier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_initializer_modifier(CPPParameterList *params) { _modifiers.push_back(Modifier::initializer_type(params)); } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::add_trailing_return_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPInstanceIdentifier:: add_trailing_return_type(CPPType *type) { // This is an awkward hack. Improve in the future. @@ -215,19 +186,15 @@ add_trailing_return_type(CPPType *type) { cerr << "trailing return type can only be added to a function\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::get_initializer -// Access: Public -// Description: Returns the initializer parameter list that was set -// for this particular instance, e.g. if the instance -// were: -// -// int foo(0); -// -// this would return the parameter list (0). Returns -// NULL if the instance did not use a parameter list -// initializer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the initializer parameter list that was set for this particular + * instance, e.g. if the instance were: + * + * int foo(0); + * + * this would return the parameter list (0). Returns NULL if the instance did + * not use a parameter list initializer. + */ CPPParameterList *CPPInstanceIdentifier:: get_initializer() const { Modifiers::const_iterator mi; @@ -241,11 +208,9 @@ get_initializer() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPInstanceIdentifier:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -256,11 +221,9 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPInstanceIdentifier::r_unroll_type -// Access: Private -// Description: The recursive implementation of unroll_type(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of unroll_type(). + */ CPPType *CPPInstanceIdentifier:: r_unroll_type(CPPType *start_type, CPPInstanceIdentifier::Modifiers::const_iterator mi) { @@ -341,9 +304,9 @@ r_unroll_type(CPPType *start_type, break; case IIT_initializer: - // In this case, we have parsed an instance declaration with a set - // of initializers as a parameter list. We lose the initializers - // at this point, but the instance will put it back again. + // In this case, we have parsed an instance declaration with a set of + // initializers as a parameter list. We lose the initializers at this + // point, but the instance will put it back again. result = start_type; break; diff --git a/dtool/src/cppparser/cppInstanceIdentifier.h b/dtool/src/cppparser/cppInstanceIdentifier.h index ee44ab8c0a..a96086a2ee 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.h +++ b/dtool/src/cppparser/cppInstanceIdentifier.h @@ -1,16 +1,15 @@ -// Filename: cppInstanceIdentifier.h -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppInstanceIdentifier.h + * @author drose + * @date 1999-10-21 + */ #ifndef CPPINSTANCEIDENTIFIER_H #define CPPINSTANCEIDENTIFIER_H @@ -42,14 +41,12 @@ enum CPPInstanceIdentifierType { IIT_initializer, }; -//////////////////////////////////////////////////////////////////// -// Class : CPPInstanceIdentifier -// Description : This class is used in parser.y to build up a variable -// instance definition. An instance is something like -// 'int *&a'; the InstanceIdentifier stores everything -// to the right of the typename. Later this can be -// passed to make_instance() to construct a CPPInstance. -//////////////////////////////////////////////////////////////////// +/** + * This class is used in parser.y to build up a variable instance definition. + * An instance is something like 'int *&a'; the InstanceIdentifier stores + * everything to the right of the typename. Later this can be passed to + * make_instance() to construct a CPPInstance. + */ class CPPInstanceIdentifier { public: CPPInstanceIdentifier(CPPIdentifier *ident); diff --git a/dtool/src/cppparser/cppMakeProperty.cxx b/dtool/src/cppparser/cppMakeProperty.cxx index 93b2b440b8..78ea191092 100644 --- a/dtool/src/cppparser/cppMakeProperty.cxx +++ b/dtool/src/cppparser/cppMakeProperty.cxx @@ -1,25 +1,22 @@ -// Filename: cppMakeProperty.cxx -// Created by: rdb (18Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppMakeProperty.cxx + * @author rdb + * @date 2014-09-18 + */ #include "cppMakeProperty.h" #include "cppFunctionGroup.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeProperty:: CPPMakeProperty(CPPIdentifier *ident, CPPFunctionGroup *getter, CPPFunctionGroup *setter, @@ -34,11 +31,9 @@ CPPMakeProperty(CPPIdentifier *ident, _ident->_native_scope = current_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeProperty:: CPPMakeProperty(CPPIdentifier *ident, CPPFunctionGroup *hasser, CPPFunctionGroup *getter, @@ -54,41 +49,33 @@ CPPMakeProperty(CPPIdentifier *ident, _ident->_native_scope = current_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeProperty:: get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeProperty:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeProperty:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPMakeProperty:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << "__make_property"; @@ -116,21 +103,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << ");"; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPMakeProperty:: get_subtype() const { return ST_make_property; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeProperty::as_make_property -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeProperty *CPPMakeProperty:: as_make_property() { return this; diff --git a/dtool/src/cppparser/cppMakeProperty.h b/dtool/src/cppparser/cppMakeProperty.h index 2beac20ec4..40308e4b14 100644 --- a/dtool/src/cppparser/cppMakeProperty.h +++ b/dtool/src/cppparser/cppMakeProperty.h @@ -1,16 +1,15 @@ -// Filename: cppMakeProperty.h -// Created by: rdb (18Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppMakeProperty.h + * @author rdb + * @date 2014-09-18 + */ #ifndef CPPMAKEPROPERTY_H #define CPPMAKEPROPERTY_H @@ -20,14 +19,11 @@ #include "cppDeclaration.h" #include "cppIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPMakeProperty -// Description : This is a MAKE_PROPERTY() declaration appearing -// within a class body. It means to generate a property -// within Python, replacing (for instance) -// get_something()/set_something() with a synthetic -// 'something' attribute. -//////////////////////////////////////////////////////////////////// +/** + * This is a MAKE_PROPERTY() declaration appearing within a class body. It + * means to generate a property within Python, replacing (for instance) + * get_something()/set_something() with a synthetic 'something' attribute. + */ class CPPMakeProperty : public CPPDeclaration { public: CPPMakeProperty(CPPIdentifier *ident, diff --git a/dtool/src/cppparser/cppMakeSeq.cxx b/dtool/src/cppparser/cppMakeSeq.cxx index b3b8a78b5f..d9b5ac7fcd 100644 --- a/dtool/src/cppparser/cppMakeSeq.cxx +++ b/dtool/src/cppparser/cppMakeSeq.cxx @@ -1,24 +1,21 @@ -// Filename: cppMakeSeq.cxx -// Created by: drose (06Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppMakeSeq.cxx + * @author drose + * @date 2008-11-06 + */ #include "cppMakeSeq.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeSeq:: CPPMakeSeq(CPPIdentifier *ident, CPPFunctionGroup *length_getter, @@ -32,41 +29,33 @@ CPPMakeSeq(CPPIdentifier *ident, _ident->_native_scope = current_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeSeq:: get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeSeq:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPMakeSeq:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPMakeSeq:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { out << "__make_seq(" << _ident->get_local_name(scope) @@ -75,21 +64,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { << ");"; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPMakeSeq:: get_subtype() const { return ST_make_seq; } -//////////////////////////////////////////////////////////////////// -// Function: CPPMakeSeq::as_make_seq -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPMakeSeq *CPPMakeSeq:: as_make_seq() { return this; diff --git a/dtool/src/cppparser/cppMakeSeq.h b/dtool/src/cppparser/cppMakeSeq.h index ad4e493e83..0e48dd0ef4 100644 --- a/dtool/src/cppparser/cppMakeSeq.h +++ b/dtool/src/cppparser/cppMakeSeq.h @@ -1,16 +1,15 @@ -// Filename: cppMakeSeq.h -// Created by: drose (06Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppMakeSeq.h + * @author drose + * @date 2008-11-06 + */ #ifndef CPPMAKESEQ_H #define CPPMAKESEQ_H @@ -21,14 +20,11 @@ #include "cppIdentifier.h" #include "cppFunctionGroup.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPMakeSeq -// Description : This is a MAKE_SEQ() declaration appearing within a -// class body. It means to generate a sequence method -// within Python, replacing (for instance) -// get_num_nodes()/get_node(n) with a synthetic -// get_nodes() method. -//////////////////////////////////////////////////////////////////// +/** + * This is a MAKE_SEQ() declaration appearing within a class body. It means + * to generate a sequence method within Python, replacing (for instance) + * get_num_nodes()/get_node(n) with a synthetic get_nodes() method. + */ class CPPMakeSeq : public CPPDeclaration { public: CPPMakeSeq(CPPIdentifier *ident, diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index eeb2859c0d..18a747d241 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -1,50 +1,42 @@ -// Filename: cppManifest.cxx -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppManifest.cxx + * @author drose + * @date 1999-10-22 + */ #include "cppManifest.h" #include "cppExpression.h" #include -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::ExpansionNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPManifest::ExpansionNode:: ExpansionNode(int parm_number, bool stringify, bool paste) : _parm_number(parm_number), _stringify(stringify), _paste(paste) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::ExpansionNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPManifest::ExpansionNode:: ExpansionNode(const string &str, bool paste) : _parm_number(-1), _stringify(false), _paste(paste), _str(str) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::Constructor -// Access: Public -// Description: Creates a manifest from a preprocessor definition. -//////////////////////////////////////////////////////////////////// +/** + * Creates a manifest from a preprocessor definition. + */ CPPManifest:: CPPManifest(const string &args, const cppyyltype &loc) : _variadic_param(-1), @@ -85,12 +77,10 @@ CPPManifest(const string &args, const cppyyltype &loc) : save_expansion(args.substr(p), parameter_names); } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::Constructor -// Access: Public -// Description: Creates a custom manifest definition, for example -// as specified from a command-line -D option. -//////////////////////////////////////////////////////////////////// +/** + * Creates a custom manifest definition, for example as specified from a + * command-line -D option. + */ CPPManifest:: CPPManifest(const string ¯o, const string &definition) : _variadic_param(-1), @@ -130,11 +120,9 @@ CPPManifest(const string ¯o, const string &definition) : save_expansion(definition, parameter_names); } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPManifest:: ~CPPManifest() { if (_expr != (CPPExpression *)NULL) { @@ -142,11 +130,9 @@ CPPManifest:: } } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::stringify -// Access: Public, Static -// Description: This implements the stringification operator, #. -//////////////////////////////////////////////////////////////////// +/** + * This implements the stringification operator, #. + */ string CPPManifest:: stringify(const string &source) { string result("\""); @@ -195,11 +181,9 @@ stringify(const string &source) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::expand -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPManifest:: expand(const vector_string &args) const { string result; @@ -222,10 +206,9 @@ expand(const vector_string &args) const { subst = stringify(subst); } } else if (i == _variadic_param && (*ei)._paste) { - // Special case GCC behavior: if __VA_ARGS__ is pasted - // to a comma and no arguments are passed, the comma - // is removed. MSVC does this automatically. Not sure - // if we should allow MSVC behavior as well. + // Special case GCC behavior: if __VA_ARGS__ is pasted to a comma and + // no arguments are passed, the comma is removed. MSVC does this + // automatically. Not sure if we should allow MSVC behavior as well. if (!result.empty() && *result.rbegin() == ',') { result.resize(result.size() - 1); } @@ -253,12 +236,10 @@ expand(const vector_string &args) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::determine_type -// Access: Public -// Description: Returns the type of the manifest, if it is known, -// or NULL if the type cannot be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the manifest, if it is known, or NULL if the type + * cannot be determined. + */ CPPType *CPPManifest:: determine_type() const { if (_expr != (CPPExpression *)NULL) { @@ -267,11 +248,9 @@ determine_type() const { return (CPPType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPManifest:: output(ostream &out) const { out << _name; @@ -320,11 +299,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::parse_parameters -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPManifest:: parse_parameters(const string &args, size_t &p, vector_string ¶meter_names) { @@ -344,9 +321,9 @@ parse_parameters(const string &args, size_t &p, p++; } - // Check if it's a variadic parameter by checking if it ends - // with "...". This picks up both C99-style variadic macros - // and GCC-style variadic macros. + // Check if it's a variadic parameter by checking if it ends with "...". + // This picks up both C99-style variadic macros and GCC-style variadic + // macros. if (p - q >= 3 && args.compare(p - 3, 3, "...") == 0) { _variadic_param = parameter_names.size(); parameter_names.push_back(args.substr(q, p - q - 3)); @@ -369,11 +346,9 @@ parse_parameters(const string &args, size_t &p, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPManifest::save_expansion -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPManifest:: save_expansion(const string &exp, const vector_string ¶meter_names) { // Walk through the expansion string. For each substring that is an @@ -399,7 +374,7 @@ save_expansion(const string &exp, const vector_string ¶meter_names) { if (ident == "__VA_ARGS__") { va_args = true; - // C99-style variadics, ie. #define macro(...) __VA_ARGS__ + // C99-style variadics, ie. #define macro(...) __VA_ARGS__ pnum = _variadic_param; } else { diff --git a/dtool/src/cppparser/cppManifest.h b/dtool/src/cppparser/cppManifest.h index 662776d2d9..dc5e7701a5 100644 --- a/dtool/src/cppparser/cppManifest.h +++ b/dtool/src/cppparser/cppManifest.h @@ -1,16 +1,15 @@ -// Filename: cppManifest.h -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppManifest.h + * @author drose + * @date 1999-10-22 + */ #ifndef CPPMANIFEST_H #define CPPMANIFEST_H @@ -26,10 +25,9 @@ class CPPExpression; class CPPType; -//////////////////////////////////////////////////////////////////// -// Class : CPPManifest -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPManifest { public: CPPManifest(const string &args, const cppyyltype &loc); @@ -50,10 +48,9 @@ public: cppyyltype _loc; CPPExpression *_expr; - // Manifests don't have a visibility in the normal sense. Normally - // this will be V_public. But a manifest that is defined between - // __begin_publish and __end_publish will have a visibility of - // V_published. + // Manifests don't have a visibility in the normal sense. Normally this + // will be V_public. But a manifest that is defined between __begin_publish + // and __end_publish will have a visibility of V_published. CPPVisibility _vis; private: diff --git a/dtool/src/cppparser/cppNameComponent.cxx b/dtool/src/cppparser/cppNameComponent.cxx index 90e2993ae3..9287aaa89b 100644 --- a/dtool/src/cppparser/cppNameComponent.cxx +++ b/dtool/src/cppparser/cppNameComponent.cxx @@ -1,26 +1,22 @@ -// Filename: cppNameComponent.cxx -// Created by: drose (12Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppNameComponent.cxx + * @author drose + * @date 1999-11-12 + */ #include "cppNameComponent.h" #include "cppTemplateParameterList.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPNameComponent:: CPPNameComponent(const string &name) : _name(name) @@ -28,11 +24,9 @@ CPPNameComponent(const string &name) : _templ = (CPPTemplateParameterList *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPNameComponent:: operator == (const CPPNameComponent &other) const { if (_name != other._name) { @@ -51,21 +45,17 @@ operator == (const CPPNameComponent &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPNameComponent:: operator != (const CPPNameComponent &other) const { return !(*this == other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPNameComponent:: operator < (const CPPNameComponent &other) const { if (_name != other._name) { @@ -80,21 +70,17 @@ operator < (const CPPNameComponent &other) const { return (*_templ) < (*other._templ); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPNameComponent:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::get_name_with_templ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPNameComponent:: get_name_with_templ(CPPScope *scope) const { ostringstream strm; @@ -107,43 +93,34 @@ get_name_with_templ(CPPScope *scope) const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::get_templ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateParameterList *CPPNameComponent:: get_templ() const { return _templ; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPNameComponent:: empty() const { return _name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::has_templ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPNameComponent:: has_templ() const { return _templ != (CPPTemplateParameterList *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::is_tbd -// Access: Public -// Description: Returns true if the name component includes a -// template parameter list that includes some -// not-yet-defined type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the name component includes a template parameter list that + * includes some not-yet-defined type. + */ bool CPPNameComponent:: is_tbd() const { if (_templ != (CPPTemplateParameterList *)NULL) { @@ -152,41 +129,33 @@ is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::set_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPNameComponent:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::append_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPNameComponent:: append_name(const string &name) { _name += name; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::set_templ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPNameComponent:: set_templ(CPPTemplateParameterList *templ) { _templ = templ; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNameComponent::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPNameComponent:: output(ostream &out) const { out << _name; diff --git a/dtool/src/cppparser/cppNameComponent.h b/dtool/src/cppparser/cppNameComponent.h index 6d9b99a042..e8f4a94ce4 100644 --- a/dtool/src/cppparser/cppNameComponent.h +++ b/dtool/src/cppparser/cppNameComponent.h @@ -1,16 +1,15 @@ -// Filename: cppNameComponent.h -// Created by: drose (12Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppNameComponent.h + * @author drose + * @date 1999-11-12 + */ #ifndef CPPNAMECOMPONENT_H #define CPPNAMECOMPONENT_H diff --git a/dtool/src/cppparser/cppNamespace.cxx b/dtool/src/cppparser/cppNamespace.cxx index ca91a86b63..36bad0a932 100644 --- a/dtool/src/cppparser/cppNamespace.cxx +++ b/dtool/src/cppparser/cppNamespace.cxx @@ -1,28 +1,24 @@ -// Filename: cppNamespace.cxx -// Created by: drose (16Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppNamespace.cxx + * @author drose + * @date 1999-11-16 + */ #include "cppNamespace.h" #include "cppIdentifier.h" #include "cppScope.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPNamespace:: CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : CPPDeclaration(file), @@ -32,11 +28,9 @@ CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::get_simple_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPNamespace:: get_simple_name() const { if (_ident == NULL) { @@ -45,11 +39,9 @@ get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::get_local_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPNamespace:: get_local_name(CPPScope *scope) const { if (_ident == NULL) { @@ -58,11 +50,9 @@ get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::get_fully_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPNamespace:: get_fully_scoped_name() const { if (_ident == NULL) { @@ -71,21 +61,17 @@ get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPNamespace:: get_scope() const { return _scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPNamespace:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_is_inline) { @@ -107,21 +93,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPNamespace:: get_subtype() const { return ST_namespace; } -//////////////////////////////////////////////////////////////////// -// Function: CPPNamespace::as_namespace -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPNamespace *CPPNamespace:: as_namespace() { return this; diff --git a/dtool/src/cppparser/cppNamespace.h b/dtool/src/cppparser/cppNamespace.h index fe0848358d..81002b475f 100644 --- a/dtool/src/cppparser/cppNamespace.h +++ b/dtool/src/cppparser/cppNamespace.h @@ -1,16 +1,15 @@ -// Filename: cppNamespace.h -// Created by: drose (16Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppNamespace.h + * @author drose + * @date 1999-11-16 + */ #ifndef CPPNAMESPACE_H #define CPPNAMESPACE_H @@ -22,10 +21,9 @@ class CPPIdentifier; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPNamespace -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPNamespace : public CPPDeclaration { public: CPPNamespace(CPPIdentifier *ident, CPPScope *scope, @@ -42,8 +40,8 @@ public: virtual CPPNamespace *as_namespace(); - // We can't call this _inline since that would clash with an MSVC - // built-in keyword declaration. + // We can't call this _inline since that would clash with an MSVC built-in + // keyword declaration. bool _is_inline; private: diff --git a/dtool/src/cppparser/cppParameterList.cxx b/dtool/src/cppparser/cppParameterList.cxx index d4199c0e81..1d3c2b986d 100644 --- a/dtool/src/cppparser/cppParameterList.cxx +++ b/dtool/src/cppparser/cppParameterList.cxx @@ -1,39 +1,32 @@ -// Filename: cppParameterList.cxx -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppParameterList.cxx + * @author drose + * @date 1999-10-21 + */ #include "cppParameterList.h" #include "cppInstance.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPParameterList:: CPPParameterList() { _includes_ellipsis = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::is_equivalent -// Access: Public -// Description: This is similar to operator == except it is more -// forgiving: it is true if only the length and order of -// types is the same, never minding the instance names -// or initial values. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to operator == except it is more forgiving: it is true if + * only the length and order of types is the same, never minding the instance + * names or initial values. + */ bool CPPParameterList:: is_equivalent(const CPPParameterList &other) const { if (_includes_ellipsis != other._includes_ellipsis) { @@ -50,11 +43,9 @@ is_equivalent(const CPPParameterList &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::Equality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPParameterList:: operator == (const CPPParameterList &other) const { if (_includes_ellipsis != other._includes_ellipsis) { @@ -71,21 +62,17 @@ operator == (const CPPParameterList &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPParameterList:: operator != (const CPPParameterList &other) const { return !(*this == other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPParameterList:: operator < (const CPPParameterList &other) const { if (_includes_ellipsis != other._includes_ellipsis) { @@ -102,12 +89,10 @@ operator < (const CPPParameterList &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::is_tbd -// Access: Public -// Description: Returns true if any of the types in the parameter -// list are base on CPPTBDType. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the types in the parameter list are base on + * CPPTBDType. + */ bool CPPParameterList:: is_tbd() const { for (int i = 0; i < (int)_parameters.size(); ++i) { @@ -118,14 +103,11 @@ is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::is_parameter_expr -// Access: Public -// Description: Returns true if any of the types in the parameter -// list turns out to be a constant expression, which is -// a clue that this parameter list is actually intended -// to be an instance declaration. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the types in the parameter list turns out to be a + * constant expression, which is a clue that this parameter list is actually + * intended to be an instance declaration. + */ bool CPPParameterList:: is_parameter_expr() const { for (int i = 0; i < (int)_parameters.size(); ++i) { @@ -136,14 +118,11 @@ is_parameter_expr() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::is_fully_specified -// Access: Public -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPParameterList:: is_fully_specified() const { for (int i = 0; i < (int)_parameters.size(); ++i) { @@ -155,11 +134,9 @@ is_fully_specified() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::substitute_decl -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPParameterList *CPPParameterList:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -183,12 +160,10 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::resolve_type -// Access: Public -// Description: Returns an equivalent CPPParameterList, in which all -// of the individual types have been resolved. -//////////////////////////////////////////////////////////////////// +/** + * Returns an equivalent CPPParameterList, in which all of the individual + * types have been resolved. + */ CPPParameterList *CPPParameterList:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPParameterList *rep = new CPPParameterList; @@ -217,13 +192,11 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParameterList::output -// Access: Public -// Description: If num_default_parameters is >= 0, it indicates the -// number of default parameter values to show on output. -// Otherwise, all parameter values are shown. -//////////////////////////////////////////////////////////////////// +/** + * If num_default_parameters is >= 0, it indicates the number of default + * parameter values to show on output. Otherwise, all parameter values are + * shown. + */ void CPPParameterList:: output(ostream &out, CPPScope *scope, bool parameter_names, int num_default_parameters) const { @@ -233,8 +206,8 @@ output(ostream &out, CPPScope *scope, bool parameter_names, out << ", "; } - // Save the default value expression; we might be about to - // temporarily clear it. + // Save the default value expression; we might be about to temporarily + // clear it. CPPExpression *expr = _parameters[i]->_initializer; if (num_default_parameters >= 0 && diff --git a/dtool/src/cppparser/cppParameterList.h b/dtool/src/cppparser/cppParameterList.h index bbe6ae53bf..93e00a822e 100644 --- a/dtool/src/cppparser/cppParameterList.h +++ b/dtool/src/cppparser/cppParameterList.h @@ -1,16 +1,15 @@ -// Filename: cppParameterList.h -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppParameterList.h + * @author drose + * @date 1999-10-21 + */ #ifndef CPPPARAMETERLIST_H #define CPPPARAMETERLIST_H @@ -24,11 +23,9 @@ class CPPInstance; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPParameterList -// Description : A list of formal parameters for a function -// declaration. -//////////////////////////////////////////////////////////////////// +/** + * A list of formal parameters for a function declaration. + */ class CPPParameterList { public: CPPParameterList(); @@ -50,8 +47,8 @@ public: CPPParameterList *resolve_type(CPPScope *current_scope, CPPScope *global_scope); - // This vector contains a list of formal parameters, in order. A - // parameter may have an empty identifer name. + // This vector contains a list of formal parameters, in order. A parameter + // may have an empty identifer name. typedef vector Parameters; Parameters _parameters; bool _includes_ellipsis; @@ -67,5 +64,3 @@ operator << (ostream &out, const CPPParameterList &plist) { } #endif - - diff --git a/dtool/src/cppparser/cppParser.cxx b/dtool/src/cppparser/cppParser.cxx index d47a0db5ca..29874cb559 100644 --- a/dtool/src/cppparser/cppParser.cxx +++ b/dtool/src/cppparser/cppParser.cxx @@ -1,17 +1,15 @@ -// Filename: cppParser.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppParser.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppParser.h" #include "cppFile.h" @@ -23,35 +21,28 @@ bool cppparser_output_class_keyword = false; -//////////////////////////////////////////////////////////////////// -// Function: CPPParser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPParser:: CPPParser() : CPPScope((CPPScope *)NULL, CPPNameComponent(""), V_public) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPParser::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPParser:: is_fully_specified() const { - // The global scope is always considered to be "fully specified", - // even if it contains some template declarations. + // The global scope is always considered to be "fully specified", even if it + // contains some template declarations. return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParser::parse_file -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPParser:: parse_file(const Filename &filename) { if (!init_cpp(CPPFile(filename, filename, CPPFile::S_local))) { @@ -63,26 +54,20 @@ parse_file(const Filename &filename) { return get_error_count() == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPParser::parse_expr -// Access: Public -// Description: Given a string, expand all manifests within the -// string and evaluate it as an expression. Returns -// NULL if the string is not a valid expression. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, expand all manifests within the string and evaluate it as + * an expression. Returns NULL if the string is not a valid expression. + */ CPPExpression *CPPParser:: parse_expr(const string &expr) { YYLTYPE loc = {}; return CPPPreprocessor::parse_expr(expr, this, this, loc); } -//////////////////////////////////////////////////////////////////// -// Function: CPPParser::parse_type -// Access: Public -// Description: Given a string, interpret it as a type name and -// return the corresponding CPPType. Returns NULL if -// the string is not a valid type. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, interpret it as a type name and return the corresponding + * CPPType. Returns NULL if the string is not a valid type. + */ CPPType *CPPParser:: parse_type(const string &type) { CPPTypeParser ep(this, this); diff --git a/dtool/src/cppparser/cppParser.h b/dtool/src/cppparser/cppParser.h index dbfd6a4574..f3b4405b7e 100644 --- a/dtool/src/cppparser/cppParser.h +++ b/dtool/src/cppparser/cppParser.h @@ -1,16 +1,15 @@ -// Filename: cppParser.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppParser.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPPARSER_H #define CPPPARSER_H @@ -23,10 +22,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : CPPParser -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPParser : public CPPScope, public CPPPreprocessor { public: CPPParser(); @@ -39,17 +37,16 @@ public: CPPType *parse_type(const string &type); }; -// Normally, this variable should be left true, especially while -// parsing. However, after parsing has finished, and you want to -// output the results of parsing in a way that can be successfully -// compiled by VC++, you may need to set this variable to false. It -// controls the way typenames are written. When true, class names are -// written 'class X', which is the way the parser expects things to -// come, and which compiles successfully under every compiler except -// VC++. When false, class names are written simply 'X', which is the -// only way they'll compile under VC++. +/* + * Normally, this variable should be left true, especially while parsing. + * However, after parsing has finished, and you want to output the results of + * parsing in a way that can be successfully compiled by VC++, you may need to + * set this variable to false. It controls the way typenames are written. + * When true, class names are written 'class X', which is the way the parser + * expects things to come, and which compiles successfully under every + * compiler except VC++. When false, class names are written simply 'X', + * which is the only way they'll compile under VC++. + */ extern bool cppparser_output_class_keyword; #endif - - diff --git a/dtool/src/cppparser/cppPointerType.cxx b/dtool/src/cppparser/cppPointerType.cxx index 044bb68893..59734ed575 100644 --- a/dtool/src/cppparser/cppPointerType.cxx +++ b/dtool/src/cppparser/cppPointerType.cxx @@ -1,27 +1,23 @@ -// Filename: cppPointerType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppPointerType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppPointerType.h" #include "cppFunctionType.h" #include "cppIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPointerType:: CPPPointerType(CPPType *pointing_at) : CPPType(CPPFile()), @@ -29,25 +25,20 @@ CPPPointerType(CPPType *pointing_at) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPPointerType:: is_fully_specified() const { return CPPType::is_fully_specified() && _pointing_at->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPPointerType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -70,14 +61,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPPointerType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *ptype = _pointing_at->resolve_type(current_scope, global_scope); @@ -90,59 +78,46 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPPointerType:: is_tbd() const { return _pointing_at->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPPointerType:: is_trivial() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPPointerType:: is_default_constructible() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPPointerType:: is_copy_constructible() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_equivalent -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPPointerType:: is_equivalent(const CPPType &other) const { const CPPPointerType *ot = ((CPPType *)&other)->as_pointer_type(); @@ -153,23 +128,20 @@ is_equivalent(const CPPType &other) const { return _pointing_at->is_equivalent(*ot->_pointing_at); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPointerType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != (CPPFunctionType *)NULL) { - // Pointers to functions are a bit of a special case; we have to - // be a little more careful about where the '*' goes. + // Pointers to functions are a bit of a special case; we have to be a + // little more careful about where the '*' goes. string star = "*"; if ((ftype->_flags & CPPFunctionType::F_method_pointer) != 0) { - // We have to output pointers-to-method with a scoping before the - // '*'. + // We have to output pointers-to-method with a scoping before the '*'. star = ftype->_class_owner->get_fully_scoped_name() + "::*"; } @@ -184,14 +156,11 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output_instance(out, indent_level, scope, complete, "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPPointerType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -201,8 +170,7 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, CPPFunctionType *ftype = _pointing_at->as_function_type(); if (ftype != NULL && ((ftype->_flags & CPPFunctionType::F_method_pointer) != 0)) { - // We have to output pointers-to-method with a scoping before the - // '*'. + // We have to output pointers-to-method with a scoping before the '*'. star = ftype->_class_owner->get_fully_scoped_name() + "::*"; } @@ -210,33 +178,27 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, star + prename, name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPPointerType:: get_subtype() const { return ST_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::as_pointer_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPointerType *CPPPointerType:: as_pointer_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPPointerType:: is_equal(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); @@ -246,13 +208,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPPointerType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPPointerType:: is_less(const CPPDeclaration *other) const { const CPPPointerType *ot = ((CPPDeclaration *)other)->as_pointer_type(); diff --git a/dtool/src/cppparser/cppPointerType.h b/dtool/src/cppparser/cppPointerType.h index 7882305ff3..2bb0fea0c1 100644 --- a/dtool/src/cppparser/cppPointerType.h +++ b/dtool/src/cppparser/cppPointerType.h @@ -1,16 +1,15 @@ -// Filename: cppPointerType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppPointerType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPPOINTERTYPE_H #define CPPPOINTERTYPE_H @@ -19,10 +18,9 @@ #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPPointerType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPPointerType : public CPPType { public: CPPPointerType(CPPType *pointing_at); diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index cef75dbe74..6b382161db 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1,17 +1,15 @@ -// Filename: cppPreprocessor.cxx -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppPreprocessor.cxx + * @author drose + * @date 1999-10-22 + */ #include "cppPreprocessor.h" #include "cppExpressionParser.h" @@ -36,11 +34,11 @@ #include #include -// We manage our own visibility counter, in addition to that managed -// by cppBison.y. We do this just so we can define manifests with the -// correct visibility when they are declared. (Asking the parser for -// the current visibility is prone to error, since the parser might be -// several tokens behind the preprocessor.) +// We manage our own visibility counter, in addition to that managed by +// cppBison.y. We do this just so we can define manifests with the correct +// visibility when they are declared. (Asking the parser for the current +// visibility is prone to error, since the parser might be several tokens +// behind the preprocessor.) static CPPVisibility preprocessor_vis = V_public; static int @@ -83,11 +81,9 @@ trim_blanks(const string &str) { return str.substr(first, last - first + 1); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPreprocessor::InputFile:: InputFile() { _in = NULL; @@ -99,18 +95,16 @@ InputFile() { _lock_position = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPreprocessor::InputFile:: ~InputFile() { if (_in != NULL) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) _in->~istream(); (*global_operator_delete)(_in); @@ -120,11 +114,9 @@ CPPPreprocessor::InputFile:: } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor::InputFile:: open(const CPPFile &file) { assert(_in == NULL); @@ -136,11 +128,9 @@ open(const CPPFile &file) { return _file._filename.open_read(*in); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::connect_input -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor::InputFile:: connect_input(const string &input) { assert(_in == NULL); @@ -150,11 +140,9 @@ connect_input(const string &input) { return !_in->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::get -// Access: Public -// Description: Fetches a single character from the source file. -//////////////////////////////////////////////////////////////////// +/** + * Fetches a single character from the source file. + */ int CPPPreprocessor::InputFile:: get() { assert(_in != NULL); @@ -166,9 +154,8 @@ get() { int c = _in->get(); - // Quietly skip over embedded carriage-return characters. We - // shouldn't see any of these unless there was some DOS-to-Unix file - // conversion problem. + // Quietly skip over embedded carriage-return characters. We shouldn't see + // any of these unless there was some DOS-to-Unix file conversion problem. while (c == '\r') { c = _in->get(); } @@ -193,20 +180,17 @@ get() { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::InputFile::peek -// Access: Public -// Description: Like get(), but does not advance the file pointer. -//////////////////////////////////////////////////////////////////// +/** + * Like get(), but does not advance the file pointer. + */ int CPPPreprocessor::InputFile:: peek() { assert(_in != NULL); int c = _in->peek(); - // Quietly skip over embedded carriage-return characters. We - // shouldn't see any of these unless there was some DOS-to-Unix file - // conversion problem. + // Quietly skip over embedded carriage-return characters. We shouldn't see + // any of these unless there was some DOS-to-Unix file conversion problem. while (c == '\r') { _in->get(); c = _in->peek(); @@ -215,11 +199,9 @@ peek() { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPreprocessor:: CPPPreprocessor() { _noangles = false; @@ -243,33 +225,26 @@ CPPPreprocessor() { _verbose = 1; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::set_verbose -// Access: Public -// Description: Sets the verbosity level of the parser. At 0, no -// warnings will be reported; at 1 or higher, expect to -// get spammed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the verbosity level of the parser. At 0, no warnings will be + * reported; at 1 or higher, expect to get spammed. + */ void CPPPreprocessor:: set_verbose(int verbose) { _verbose = verbose; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_verbose -// Access: Public -// Description: Returns the verbosity level of the parser. -//////////////////////////////////////////////////////////////////// +/** + * Returns the verbosity level of the parser. + */ int CPPPreprocessor:: get_verbose() const { return _verbose; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::copy_filepos -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: copy_filepos(const CPPPreprocessor &other) { assert(!_files.empty()); @@ -278,11 +253,9 @@ copy_filepos(const CPPPreprocessor &other) { _files.back()._col_number = other.get_col_number(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_file -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFile CPPPreprocessor:: get_file() const { if (_files.empty()) { @@ -291,12 +264,9 @@ get_file() const { return _files.back()._file; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_line_number -// Access: Public -// Description: Returns the line number of the last character -// returned by get(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the line number of the last character returned by get(). + */ int CPPPreprocessor:: get_line_number() const { if (_files.empty()) { @@ -305,12 +275,9 @@ get_line_number() const { return _files.back()._line_number; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_col_number -// Access: Public -// Description: Returns the column number of the last character -// returned by get(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the column number of the last character returned by get(). + */ int CPPPreprocessor:: get_col_number() const { if (_files.empty()) { @@ -319,11 +286,9 @@ get_col_number() const { return _files.back()._col_number; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_next_token -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: get_next_token() { @@ -338,9 +303,9 @@ CPPToken CPPPreprocessor:: get_next_token0() { #endif - // We make a nested call to internal_get_next_token(), so we can - // combine sequences of identifiers and scoping symbols into a - // single identifier, for yacc's convenience. + // We make a nested call to internal_get_next_token(), so we can combine + // sequences of identifiers and scoping symbols into a single identifier, + // for yacc's convenience. CPPToken token(0); if (!_saved_tokens.empty()) { @@ -354,16 +319,14 @@ get_next_token0() { if (_resolve_identifiers && (token._token == SIMPLE_IDENTIFIER || token._token == SCOPE)) { - // We will be returning a scoped identifier, or a scoping. Keep - // pulling off tokens until we reach the end of the - // scope/identifier sequence. + // We will be returning a scoped identifier, or a scoping. Keep pulling + // off tokens until we reach the end of the scopeidentifier sequence. string name; - // If we started the ball with an identifier, use it and get the - // next token. Otherwise, we started with :: (global scope), and - // we indicate this with an empty string at the beginning of the - // scoping sequence. + // If we started the ball with an identifier, use it and get the next + // token. Otherwise, we started with :: (global scope), and we indicate + // this with an empty string at the beginning of the scoping sequence. if (token._token == SIMPLE_IDENTIFIER) { name = token._lval.str; token = internal_get_next_token(); @@ -374,10 +337,10 @@ get_next_token0() { result.u.identifier = ident; if (token._token == '<') { - // If the next token is an angle bracket and the current - // identifier wants template instantiation, assume the angle - // bracket begins the instantiation and call yacc recursively to - // parse the template parameters. + // If the next token is an angle bracket and the current identifier + // wants template instantiation, assume the angle bracket begins the + // instantiation and call yacc recursively to parse the template + // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); if (decl != NULL) { ident->_names.back().set_templ @@ -397,22 +360,20 @@ get_next_token0() { string token_prefix; if (token._token == '~') { - // A scoping operator followed by a tilde can only be the - // start of a scoped destructor name. Make the tilde be part - // of the name. + // A scoping operator followed by a tilde can only be the start of a + // scoped destructor name. Make the tilde be part of the name. name += "~"; token_prefix = "~"; token = internal_get_next_token(); } if (token._token != SIMPLE_IDENTIFIER) { - // The last useful token was a SCOPE, thus this is a scoping - // token. + // The last useful token was a SCOPE, thus this is a scoping token. if (token._token == KW_OPERATOR) { - // Unless the last token we came across was the "operator" - // keyword. We make a special case for this, because it's - // occasionally scoped in normal use. + // Unless the last token we came across was the "operator" keyword. + // We make a special case for this, because it's occasionally scoped + // in normal use. token._lval = result; _last_token_loc = token._lloc; return token; @@ -433,10 +394,10 @@ get_next_token0() { token = internal_get_next_token(); if (token._token == '<') { - // If the next token is an angle bracket and the current - // indentifier wants template instantiation, assume the angle - // bracket begins the instantiation and call yacc recursively to - // parse the template parameters. + // If the next token is an angle bracket and the current indentifier + // wants template instantiation, assume the angle bracket begins the + // instantiation and call yacc recursively to parse the template + // parameters. CPPDeclaration *decl = ident->find_template(current_scope, global_scope); if (decl != NULL) { @@ -448,8 +409,8 @@ get_next_token0() { } } } - // The last useful token was a SIMPLE_IDENTIFIER, thus this is a - // normal scoped identifier. + // The last useful token was a SIMPLE_IDENTIFIER, thus this is a normal + // scoped identifier. _saved_tokens.push_back(token); int token_type = IDENTIFIER; @@ -467,11 +428,9 @@ get_next_token0() { return token; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::peek_next_token -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: peek_next_token() { CPPToken token(0); @@ -484,11 +443,9 @@ peek_next_token() { return token; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::warning -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: warning(const string &message) { if (_verbose < 2) { @@ -505,11 +462,9 @@ warning(const string &message) { warning(message, loc); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::warning -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: warning(const string &message, const YYLTYPE &loc) { if (_verbose >= 2) { @@ -534,11 +489,9 @@ warning(const string &message, const YYLTYPE &loc) { _warning_count++; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::error -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: error(const string &message) { int line = get_line_number(); @@ -552,16 +505,14 @@ error(const string &message) { error(message, loc); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::error -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: error(const string &message, const YYLTYPE &loc) { if (_state == S_nested || _state == S_end_nested) { - // Don't report or log errors in the nested state. These will be - // reported when the nesting level collapses. + // Don't report or log errors in the nested state. These will be reported + // when the nesting level collapses. return; } @@ -592,11 +543,9 @@ error(const string &message, const YYLTYPE &loc) { _error_count++; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::show_line -// Access: Public -// Description: Shows the indicated line, useful for error messages. -//////////////////////////////////////////////////////////////////// +/** + * Shows the indicated line, useful for error messages. + */ void CPPPreprocessor:: show_line(const YYLTYPE &loc) { if (loc.file._filename.empty()) { @@ -649,33 +598,26 @@ show_line(const YYLTYPE &loc) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_warning_count -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: get_warning_count() const { return _warning_count; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_error_count -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: get_error_count() const { return _error_count; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_comment_before -// Access: Public -// Description: Returns the CPPCommentBlock immediately preceding the -// indicated line, if any. If there is no such comment, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CPPCommentBlock immediately preceding the indicated line, if + * any. If there is no such comment, returns NULL. + */ CPPCommentBlock *CPPPreprocessor:: get_comment_before(int line, CPPFile file) { CPPComments::reverse_iterator ci; @@ -706,13 +648,10 @@ get_comment_before(int line, CPPFile file) { return (CPPCommentBlock *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_comment_on -// Access: Public -// Description: Returns the CPPCommentBlock that starts on the -// indicated line, if any. If there is no such -// comment, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CPPCommentBlock that starts on the indicated line, if any. If + * there is no such comment, returns NULL. + */ CPPCommentBlock *CPPPreprocessor:: get_comment_on(int line, CPPFile file) { CPPComments::reverse_iterator ci; @@ -734,11 +673,9 @@ get_comment_on(int line, CPPFile file) { return (CPPCommentBlock *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::init_cpp -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor:: init_cpp(const CPPFile &file) { _state = S_normal; @@ -748,11 +685,9 @@ init_cpp(const CPPFile &file) { return push_file(file); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::init_const_expr -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor:: init_const_expr(const string &expr) { _state = S_normal; @@ -761,11 +696,9 @@ init_const_expr(const string &expr) { return push_string(expr, false); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::init_type -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor:: init_type(const string &type) { _state = S_normal; @@ -774,11 +707,9 @@ init_type(const string &type) { return push_string(type, false); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::push_file -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor:: push_file(const CPPFile &file) { if (_verbose >= 3) { @@ -791,8 +722,7 @@ push_file(const CPPFile &file) { InputFile &infile = _files.back(); if (infile.open(file)) { - // Record the fact that we opened the file for the benefit of user - // code. + // Record the fact that we opened the file for the benefit of user code. _parsed_files.insert(file); infile._prev_last_c = _last_c; @@ -805,11 +735,9 @@ push_file(const CPPFile &file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::push_string -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPPreprocessor:: push_string(const string &input, bool lock_position) { #ifdef CPP_VERBOSE_LEX @@ -846,20 +774,17 @@ push_string(const string &input, bool lock_position) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::expand_manifests -// Access: Protected -// Description: Given a string, expand all manifests within the -// string and return the new string. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, expand all manifests within the string and return the new + * string. + */ string CPPPreprocessor:: expand_manifests(const string &input_expr, bool expand_undefined, const YYLTYPE &loc) { // Get a copy of the expression string we can modify. string expr = input_expr; - // Repeatedly scan the expr for any manifest names or defined() - // function. + // Repeatedly scan the expr for any manifest names or defined() function. bool manifest_found; do { @@ -912,25 +837,21 @@ expand_manifests(const string &input_expr, bool expand_undefined, } } - // If we expanded any manifests at all that time, then go back - // through the string and look again--we might have a manifest - // that expands to another manifest. + // If we expanded any manifests at all that time, then go back through the + // string and look again--we might have a manifest that expands to another + // manifest. } while (manifest_found); return expr; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::parse_expr -// Access: Protected -// Description: Given a string, expand all manifests within the -// string and evaluate it as an expression. Returns -// NULL if the string is not a valid expression. -// -// This is an internal support function for -// CPPPreprocessor; however, there is a public variant -// of this function defined for CPPParser. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, expand all manifests within the string and evaluate it as + * an expression. Returns NULL if the string is not a valid expression. + * + * This is an internal support function for CPPPreprocessor; however, there is + * a public variant of this function defined for CPPParser. + */ CPPExpression *CPPPreprocessor:: parse_expr(const string &input_expr, CPPScope *current_scope, CPPScope *global_scope, const YYLTYPE &loc) { @@ -945,11 +866,9 @@ parse_expr(const string &input_expr, CPPScope *current_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::internal_get_next_token -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: internal_get_next_token() { if (_state == S_eof || _state == S_end_nested) { @@ -962,8 +881,8 @@ internal_get_next_token() { c = get(); } - // Skip any whitespace, comments, and preprocessor directives before - // the token. + // Skip any whitespace, comments, and preprocessor directives before the + // token. c = skip_whitespace(c); while (c == '#' && _start_of_line && !should_ignore_preprocessor()) { c = skip_whitespace(process_directive(c)); @@ -1014,9 +933,9 @@ internal_get_next_token() { } if (_state == S_nested) { - // If we're running a nested lexer, keep track of the paren - // levels. When we encounter a comma or closing angle bracket at - // the bottom level, we stop. + // If we're running a nested lexer, keep track of the paren levels. When + // we encounter a comma or closing angle bracket at the bottom level, we + // stop. switch (c) { case '(': @@ -1045,9 +964,9 @@ internal_get_next_token() { } } - // Look for an end-of-line comment, and parse it before we finish - // this token. This is not strictly necessary, but it allows us to - // pick up docstrings from comments after enum values. + // Look for an end-of-line comment, and parse it before we finish this + // token. This is not strictly necessary, but it allows us to pick up + // docstrings from comments after enum values. while (next_c != EOF && isspace(next_c)) { get(); next_c = peek(); @@ -1059,13 +978,10 @@ internal_get_next_token() { return CPPToken(c, loc); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::check_digraph -// Access: Private -// Description: Checks the next character in the stream to see if -// this might be a two-character token. -// Returns 0 if it is only a single-character token. -//////////////////////////////////////////////////////////////////// +/** + * Checks the next character in the stream to see if this might be a two- + * character token. Returns 0 if it is only a single-character token. + */ int CPPPreprocessor:: check_digraph(int c) { int next_c = peek(); @@ -1090,9 +1006,9 @@ check_digraph(int c) { case '>': if (_parsing_template_params && _paren_nesting <= 0) { - // Don't parse >> as right-shift when parsing a template list, as - // per C++11, to allow a syntax like A>. - // However, nested >> must be preserved, such as in A<(2>>1)> + // Don't parse >> as right-shift when parsing a template list, as per + // C++11, to allow a syntax like A>. However, nested >> must be + // preserved, such as in A<(2>>1)> break; } if (next_c == '>') return RSHIFT; @@ -1155,14 +1071,11 @@ check_digraph(int c) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::check_trigraph -// Access: Private -// Description: Checks the next character in the stream to see if -// this might be a three-character token; usually -// called in conjunction with check_digraph. -// Returns 0 if it is not a three-character token. -//////////////////////////////////////////////////////////////////// +/** + * Checks the next character in the stream to see if this might be a three- + * character token; usually called in conjunction with check_digraph. Returns + * 0 if it is not a three-character token. + */ int CPPPreprocessor:: check_trigraph(int c) { int next_c = peek(); @@ -1183,19 +1096,17 @@ check_trigraph(int c) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_whitespace -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: skip_whitespace(int c) { while (c != EOF) { c = skip_comment(c); if (c == '\\') { - // This does not usually occur in the middle of unquoted C++ - // code, except before a newline character. + // This does not usually occur in the middle of unquoted C++ code, + // except before a newline character. if (peek() != '\n') { return '\\'; } @@ -1210,11 +1121,9 @@ skip_whitespace(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_comment -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: skip_comment(int c) { while (c == '/') { @@ -1238,11 +1147,9 @@ skip_comment(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_c_comment -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: skip_c_comment(int c) { YYLTYPE loc; @@ -1307,11 +1214,9 @@ skip_c_comment(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_cpp_comment -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: skip_cpp_comment(int c) { if (_save_comments) { @@ -1319,17 +1224,17 @@ skip_cpp_comment(int c) { int line_number = get_line_number(); if (c == '\n') { - // We have to subtract one from the line number as we just - // fetched a newline. + // We have to subtract one from the line number as we just fetched a + // newline. --line_number; } if (_last_cpp_comment && !_comments.empty() && _comments.back()->_last_line >= line_number - 1) { - // If the last non-whitespace character read was also part of a - // C++ comment, then this is just a continuation of that comment - // block. However, if there was a line without comment in between, - // it starts a new block anyway. + // If the last non-whitespace character read was also part of a C++ + // comment, then this is just a continuation of that comment block. + // However, if there was a line without comment in between, it starts a + // new block anyway. comment = _comments.back(); assert(!comment->_c_style); comment->_comment += "//"; @@ -1367,12 +1272,9 @@ skip_cpp_comment(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_digit_separator -// Access: Private -// Description: Skips a C++14 digit separator that has just been -// found through peek(). -//////////////////////////////////////////////////////////////////// +/** + * Skips a C++14 digit separator that has just been found through peek(). + */ int CPPPreprocessor:: skip_digit_separator(int c) { if (c != '\'') { @@ -1394,9 +1296,9 @@ skip_digit_separator(int c) { loc.last_column = loc.first_column; if (c != '\'') { - // This assumes that this isn't a character constant directly follows - // a digit sequence, like 123'a' -- I can't think of a situation - // where that's legal anyway, though. + // This assumes that this isn't a character constant directly follows a + // digit sequence, like 123'a' -- I can't think of a situation where + // that's legal anyway, though. error("digit separator cannot occur at end of digit sequence", loc); return c; } @@ -1411,11 +1313,9 @@ skip_digit_separator(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::process_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: process_directive(int c) { assert(c == '#'); @@ -1453,12 +1353,12 @@ process_directive(int c) { } else if (command == "if") { handle_if_directive(args, loc); } else if (command == "else" || command == "elif") { - // Presumably this follows some #if or #ifdef. We don't bother to - // check this, however. + // Presumably this follows some #if or #ifdef. We don't bother to check + // this, however. skip_false_if_block(false); } else if (command == "endif") { - // Presumably this follows some #if or #ifdef. We don't bother to - // check this, however. + // Presumably this follows some #if or #ifdef. We don't bother to check + // this, however. } else if (command == "include") { handle_include_directive(args, loc); } else if (command == "pragma") { @@ -1479,11 +1379,9 @@ process_directive(int c) { return '\n'; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_preprocessor_command -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: get_preprocessor_command(int c, string &command) { // The next sequence of characters is the command. @@ -1499,15 +1397,13 @@ get_preprocessor_command(int c, string &command) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_preprocessor_args -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: get_preprocessor_args(int c, string &args) { - // Following the command, the rest of the line, as well as any text - // on successive lines, is part of the arguments to the command. + // Following the command, the rest of the line, as well as any text on + // successive lines, is part of the arguments to the command. while (c != EOF && c != '\n') { if (c == '\\') { @@ -1534,11 +1430,9 @@ get_preprocessor_args(int c, string &args) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_define_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_define_directive(const string &args, const YYLTYPE &loc) { if (args.empty()) { @@ -1567,11 +1461,9 @@ handle_define_directive(const string &args, const YYLTYPE &loc) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_undef_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_undef_directive(const string &args, const YYLTYPE &loc) { if (args.empty()) { @@ -1584,11 +1476,9 @@ handle_undef_directive(const string &args, const YYLTYPE &loc) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_ifdef_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_ifdef_directive(const string &args, const YYLTYPE &loc) { Manifests::const_iterator mi = _manifests.find(args); @@ -1601,11 +1491,9 @@ handle_ifdef_directive(const string &args, const YYLTYPE &loc) { skip_false_if_block(true); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_ifndef_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_ifndef_directive(const string &args, const YYLTYPE &loc) { Manifests::const_iterator mi = _manifests.find(args); @@ -1619,15 +1507,12 @@ handle_ifndef_directive(const string &args, const YYLTYPE &loc) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_if_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_if_directive(const string &args, const YYLTYPE &loc) { - // When expanding manifests, we should replace unknown macros - // with 0. + // When expanding manifests, we should replace unknown macros with 0. string expr = expand_manifests(args, true, loc); int expression_result = 0; @@ -1655,11 +1540,9 @@ handle_if_directive(const string &args, const YYLTYPE &loc) { skip_false_if_block(true); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_include_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_include_directive(const string &args, const YYLTYPE &loc) { bool okflag = false; @@ -1669,12 +1552,12 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { string expr = args; - // The filename to include might actually be hidden within a - // manifest definition. Wow. FreeType depends on this. + // The filename to include might actually be hidden within a manifest + // definition. Wow. FreeType depends on this. - // Just to play things safe, since our manifest-expansion logic - // might not filter out quotes and angle brackets properly, we'll - // only expand manifests if we don't begin with a quote or bracket. + // Just to play things safe, since our manifest-expansion logic might not + // filter out quotes and angle brackets properly, we'll only expand + // manifests if we don't begin with a quote or bracket. if (!expr.empty() && (expr[0] != '"' && expr[0] != '<')) { expr = expand_manifests(expr, false, loc); } @@ -1685,25 +1568,23 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { okflag = true; if (_files.size() == 1) { - // If we're currently processing a top-level file, record the - // include directive. We don't need to record includes from - // included files. + // If we're currently processing a top-level file, record the include + // directive. We don't need to record includes from included files. _quote_includes.insert(filename); } } else if (expr[0] == '<' && expr[expr.size() - 1] == '>') { filename = expr.substr(1, expr.size() - 2); if (!_noangles) { - // If _noangles is true, we don't make a distinction between - // angle brackets and quote marks--all #include statements are - // treated the same, as if they used quote marks. + // If _noangles is true, we don't make a distinction between angle + // brackets and quote marks--all #include statements are treated the + // same, as if they used quote marks. angle_quotes = true; } okflag = true; if (_files.size() == 1) { - // If we're currently processing a top-level file, record the - // include directive. We don't need to record includes from - // included files. + // If we're currently processing a top-level file, record the include + // directive. We don't need to record includes from included files. _angle_includes.insert(filename); } } @@ -1712,8 +1593,8 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { filename.set_text(); filename_as_referenced = filename; - // Now look for the filename. If we didn't use angle quotes, look - // first in the current directory. + // Now look for the filename. If we didn't use angle quotes, look first in + // the current directory. bool found_file = false; CPPFile::Source source = CPPFile::S_none; @@ -1782,11 +1663,9 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_pragma_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_pragma_directive(const string &args, const YYLTYPE &loc) { if (args == "once") { @@ -1796,24 +1675,19 @@ handle_pragma_directive(const string &args, const YYLTYPE &loc) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::handle_error_directive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: handle_error_directive(const string &args, const YYLTYPE &loc) { error(args, loc); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_false_if_block -// Access: Private -// Description: We come here when we fail an #if or an #ifdef test, -// or when we reach the #else clause to something we -// didn't fail. This function skips all text up until -// the matching #endif. -//////////////////////////////////////////////////////////////////// +/** + * We come here when we fail an #if or an #ifdef test, or when we reach the + * #else clause to something we didn't fail. This function skips all text up + * until the matching #endif. + */ void CPPPreprocessor:: skip_false_if_block(bool consider_elifs) { int level = 0; @@ -1868,11 +1742,9 @@ skip_false_if_block(bool consider_elifs) { _save_comments = true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_quoted_char -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: get_quoted_char(int c) { YYLTYPE loc; @@ -1891,11 +1763,9 @@ get_quoted_char(int c) { return get_literal(CHAR_TOK, loc, str, result); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_quoted_string -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: get_quoted_string(int c) { YYLTYPE loc; @@ -1908,11 +1778,9 @@ get_quoted_string(int c) { return get_literal(SIMPLE_STRING, loc, str); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_identifier -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: get_identifier(int c) { YYLTYPE loc; @@ -1936,8 +1804,8 @@ get_identifier(int c) { if ((c == '\'' || c == '"') && (name == "L" || name == "u8" || name == "u" || name == "U")) { - // This is actually a wide-character or wide-string literal or - // some such. Figure out the correct character type to use. + // This is actually a wide-character or wide-string literal or some such. + // Figure out the correct character type to use. CPPExpression::Type type; if (name == "L") { @@ -2003,13 +1871,10 @@ get_identifier(int c) { return CPPToken(SIMPLE_IDENTIFIER, loc, name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_literal -// Access: Private -// Description: Under the assumption that we've just parsed a -// string or real constant, parse a following custom -// literal, and returns a token for it. -//////////////////////////////////////////////////////////////////// +/** + * Under the assumption that we've just parsed a string or real constant, + * parse a following custom literal, and returns a token for it. + */ CPPToken CPPPreprocessor:: get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { string suffix; @@ -2106,7 +1971,8 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { simple == CPPSimpleType::T_wchar_t || simple == CPPSimpleType::T_char16_t || simple == CPPSimpleType::T_char32_t)) { - // We currently don't have the means to check the exact character type. + // We currently don't have the means to check the exact character + // type. expr = new CPPExpression(value.u.integer); instance = (*it); break; @@ -2125,8 +1991,8 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { CPPSimpleType::Type simple = type->as_simple_type()->_type; if (simple == CPPSimpleType::T_char && params.size() == 1) { - // This is the raw literal operator. Store it, but don't break; - // a non-raw version of the operator might follow, which we'd prefer. + // This is the raw literal operator. Store it, but don't break; a + // non-raw version of the operator might follow, which we'd prefer. raw_instance = (*it); } else if (token == SIMPLE_STRING && simple == CPPSimpleType::T_char) { @@ -2135,8 +2001,8 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { break; } else if (token == STRING_LITERAL) { - // Verify that the character type of the string literal matches - // the character type of the parameter. + // Verify that the character type of the string literal matches the + // character type of the parameter. CPPExpression::Type str_type = value.u.expr->_type; if ((str_type == CPPExpression::T_string && simple == CPPSimpleType::T_char) || (str_type == CPPExpression::T_wstring && simple == CPPSimpleType::T_wchar_t) || @@ -2168,11 +2034,9 @@ get_literal(int token, YYLTYPE loc, const string &str, const YYSTYPE &value) { return CPPToken(CUSTOM_LITERAL, loc, str, result); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::expand_manifest -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken CPPPreprocessor:: expand_manifest(const CPPManifest *manifest) { vector_string args; @@ -2200,11 +2064,9 @@ expand_manifest(const CPPManifest *manifest) { return internal_get_next_token(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::extract_manifest_args -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: extract_manifest_args(const string &name, int num_args, int va_arg, vector_string &args) { @@ -2281,8 +2143,8 @@ extract_manifest_args(const string &name, int num_args, int va_arg, } } else if (c == '\\') { - // It could be a slash before a newline. - // If so, that's whitespace as well. + // It could be a slash before a newline. If so, that's whitespace as + // well. c = get(); if (c != '\n') { arg += '\\'; @@ -2316,12 +2178,10 @@ extract_manifest_args(const string &name, int num_args, int va_arg, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::expand_defined_function -// Access: Private -// Description: Expands the defined(manifest) function to either -// 1 or 0, depending on whether the manifest exists. -//////////////////////////////////////////////////////////////////// +/** + * Expands the defined(manifest) function to either 1 or 0, depending on + * whether the manifest exists. + */ void CPPPreprocessor:: expand_defined_function(string &expr, size_t q, size_t &p) { string result; @@ -2344,11 +2204,9 @@ expand_defined_function(string &expr, size_t q, size_t &p) { p = q + result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::expand_manifest_inline -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: expand_manifest_inline(string &expr, size_t q, size_t &p, const CPPManifest *manifest) { @@ -2363,11 +2221,9 @@ expand_manifest_inline(string &expr, size_t q, size_t &p, p = q + result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::extract_manifest_args_inline -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPPreprocessor:: extract_manifest_args_inline(const string &name, int num_args, int va_arg, vector_string &args, @@ -2436,12 +2292,10 @@ extract_manifest_args_inline(const string &name, int num_args, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get_number -// Access: Private -// Description: Assuming that we've just read a digit or a period -// indicating the start of a number, read the rest. -//////////////////////////////////////////////////////////////////// +/** + * Assuming that we've just read a digit or a period indicating the start of a + * number, read the rest. + */ CPPToken CPPPreprocessor:: get_number(int c) { YYLTYPE loc; @@ -2544,9 +2398,9 @@ get_number(int c) { YYSTYPE result; if (leading_zero) { - // A leading zero implies an octal number. strtol() is supposed - // to be able to make this distinction by itself, but we'll do it - // explicitly just to be sure. + // A leading zero implies an octal number. strtol() is supposed to be + // able to make this distinction by itself, but we'll do it explicitly + // just to be sure. result.u.integer = strtol(num.c_str(), (char **)NULL, 8); } else { @@ -2557,11 +2411,9 @@ get_number(int c) { return get_literal(INTEGER, loc, num, result); } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::check_keyword -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: check_keyword(const string &name) { if (name == "alignas") return KW_ALIGNAS; @@ -2662,11 +2514,9 @@ check_keyword(const string &name) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::scan_escape_sequence -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: scan_escape_sequence(int c) { if (c != '\\') { @@ -2739,11 +2589,9 @@ scan_escape_sequence(int c) { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::scan_quoted -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPPreprocessor:: scan_quoted(int c) { int quote_mark = c; @@ -2766,13 +2614,10 @@ scan_quoted(int c) { return str; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::should_ignore_manifest -// Access: Public -// Description: Returns true if the manifest is one that is being -// ignored right now (presumably because we are -// presently expanding it). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the manifest is one that is being ignored right now + * (presumably because we are presently expanding it). + */ bool CPPPreprocessor:: should_ignore_manifest(const CPPManifest *manifest) const { Files::const_iterator fi; @@ -2785,13 +2630,10 @@ should_ignore_manifest(const CPPManifest *manifest) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::should_ignore_preprocessor -// Access: Public -// Description: Returns true if we should ignore any preprocessor -// directives (e.g. we're presently expanding a -// manifest). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we should ignore any preprocessor directives (e.g. we're + * presently expanding a manifest). + */ bool CPPPreprocessor:: should_ignore_preprocessor() const { Files::const_iterator fi; @@ -2804,11 +2646,9 @@ should_ignore_preprocessor() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::get -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int CPPPreprocessor:: get() { if (_unget != '\0') { @@ -2830,8 +2670,8 @@ get() { #endif _files.pop_back(); - // Synthesize a newline, just in case the file doesn't already - // end with one. + // Synthesize a newline, just in case the file doesn't already end with + // one. c = '\n'; } @@ -2844,11 +2684,9 @@ get() { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::peek -// Access: Private -// Description: Like get(), but does not alter the current state. -//////////////////////////////////////////////////////////////////// +/** + * Like get(), but does not alter the current state. + */ int CPPPreprocessor:: peek() { if (_unget != '\0') { @@ -2876,28 +2714,22 @@ peek() { return c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::unget -// Access: Private -// Description: Undoes the effects of a previous get(). Not -// recommended, use peek() instead where possible, as -// it doesn't cause the column index to be off. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effects of a previous get(). Not recommended, use peek() + * instead where possible, as it doesn't cause the column index to be off. + */ void CPPPreprocessor:: unget(int c) { assert(_unget == '\0'); _unget = c; } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::nested_parse_template_instantiation -// Access: Private -// Description: Recursively invokes yacc to parse the stuff within -// angle brackets that's the template instantiation part -// of an identifier. This involves setting and -// restoring some state flags so we can return EOF when -// we reach the closing bracket. -//////////////////////////////////////////////////////////////////// +/** + * Recursively invokes yacc to parse the stuff within angle brackets that's + * the template instantiation part of an identifier. This involves setting + * and restoring some state flags so we can return EOF when we reach the + * closing bracket. + */ CPPTemplateParameterList *CPPPreprocessor:: nested_parse_template_instantiation(CPPTemplateScope *scope) { #ifdef CPP_VERBOSE_LEX @@ -2980,16 +2812,12 @@ nested_parse_template_instantiation(CPPTemplateScope *scope) { } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_to_end_nested -// Access: Private -// Description: This is an error-recovery function, called after -// returning from a nested parse. If the state is not -// S_end_nested, there was an error in parsing the -// nested tokens, and not all of the nested tokens may -// have been consumed. This function will consume the -// rest of the nested tokens. -//////////////////////////////////////////////////////////////////// +/** + * This is an error-recovery function, called after returning from a nested + * parse. If the state is not S_end_nested, there was an error in parsing the + * nested tokens, and not all of the nested tokens may have been consumed. + * This function will consume the rest of the nested tokens. + */ void CPPPreprocessor:: skip_to_end_nested() { #ifdef CPP_VERBOSE_LEX @@ -3012,14 +2840,11 @@ skip_to_end_nested() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CPPPreprocessor::skip_to_angle_bracket -// Access: Private -// Description: This is an error-recovery function, called after -// returning from a nested parse. If we haven't yet -// consumed the closing angle bracket on the template -// instantiation, keep consuming tokens until we do. -//////////////////////////////////////////////////////////////////// +/** + * This is an error-recovery function, called after returning from a nested + * parse. If we haven't yet consumed the closing angle bracket on the + * template instantiation, keep consuming tokens until we do. + */ void CPPPreprocessor:: skip_to_angle_bracket() { #ifdef CPP_VERBOSE_LEX diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index aa7b8ef89c..74ff8edcf1 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -1,16 +1,15 @@ -// Filename: cppPreprocessor.h -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppPreprocessor.h + * @author drose + * @date 1999-10-22 + */ #ifndef CPPPREPROCESSOR_H #define CPPPREPROCESSOR_H @@ -33,12 +32,11 @@ class CPPScope; class CPPTemplateParameterList; class CPPExpression; -//#define CPP_VERBOSE_LEX +// #define CPP_VERBOSE_LEX -//////////////////////////////////////////////////////////////////// -// Class : CPPPreprocessor -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPPreprocessor { public: CPPPreprocessor(); @@ -90,17 +88,17 @@ public: set _explicit_files; - // This is normally true, to indicate that the preprocessor should - // decode identifiers like foo::bar into a single IDENTIFIER, - // TYPENAME_IDENTIFIER, or SCOPING token for yacc's convenience. - // When false, it leaves them alone and returns a sequence of - // SIMPLE_IDENTIFIER and SCOPE tokens instead. + // This is normally true, to indicate that the preprocessor should decode + // identifiers like foo::bar into a single IDENTIFIER, + // TYPENAME_IDENTIFIER, or SCOPING token for yacc's convenience. When + // false, it leaves them alone and returns a sequence of SIMPLE_IDENTIFIER + // and SCOPE tokens instead. bool _resolve_identifiers; - // The default _verbose level is 1, which will output normal error - // and warning messages but nothing else. Set this to 0 to make the - // warning messages go away (although the counts will still be - // incremented), or set it higher to get more debugging information. + // The default _verbose level is 1, which will output normal error and + // warning messages but nothing else. Set this to 0 to make the warning + // messages go away (although the counts will still be incremented), or set + // it higher to get more debugging information. int _verbose; // The location of the last token. @@ -197,8 +195,8 @@ private: int _prev_last_c; }; - // This must be a list and not a vector because we don't have a good - // copy constructor defined for InputFile. + // This must be a list and not a vector because we don't have a good copy + // constructor defined for InputFile. typedef list Files; Files _files; diff --git a/dtool/src/cppparser/cppReferenceType.cxx b/dtool/src/cppparser/cppReferenceType.cxx index 21e4b352bc..edb29a91e2 100644 --- a/dtool/src/cppparser/cppReferenceType.cxx +++ b/dtool/src/cppparser/cppReferenceType.cxx @@ -1,25 +1,21 @@ -// Filename: cppReferenceType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppReferenceType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppReferenceType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPReferenceType:: CPPReferenceType(CPPType *pointing_at, ValueCategory vcat) : CPPType(CPPFile()), @@ -28,25 +24,20 @@ CPPReferenceType(CPPType *pointing_at, ValueCategory vcat) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPReferenceType:: is_fully_specified() const { return CPPType::is_fully_specified() && _pointing_at->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPReferenceType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -69,14 +60,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPReferenceType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *ptype = _pointing_at->resolve_type(current_scope, global_scope); @@ -89,59 +77,46 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPReferenceType:: is_tbd() const { return _pointing_at->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPReferenceType:: is_trivial() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPReferenceType:: is_default_constructible() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPReferenceType:: is_copy_constructible() const { return (_value_category == VC_lvalue); } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_equivalent -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPReferenceType:: is_equivalent(const CPPType &other) const { const CPPReferenceType *ot = ((CPPType *)&other)->as_reference_type(); @@ -152,11 +127,9 @@ is_equivalent(const CPPType &other) const { return _pointing_at->is_equivalent(*ot->_pointing_at); } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPReferenceType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { /* @@ -166,14 +139,11 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { output_instance(out, indent_level, scope, complete, "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPReferenceType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -188,33 +158,27 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPReferenceType:: get_subtype() const { return ST_reference; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::as_reference_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPReferenceType *CPPReferenceType:: as_reference_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPReferenceType:: is_equal(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); @@ -225,13 +189,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPReferenceType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPReferenceType:: is_less(const CPPDeclaration *other) const { const CPPReferenceType *ot = ((CPPDeclaration *)other)->as_reference_type(); diff --git a/dtool/src/cppparser/cppReferenceType.h b/dtool/src/cppparser/cppReferenceType.h index 501eb9e828..96b898ce2b 100644 --- a/dtool/src/cppparser/cppReferenceType.h +++ b/dtool/src/cppparser/cppReferenceType.h @@ -1,16 +1,15 @@ -// Filename: cppReferenceType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppReferenceType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPREFERENCETYPE_H #define CPPREFERENCETYPE_H @@ -19,10 +18,9 @@ #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPReferenceType -// Description : Either an lvalue- or rvalue-reference. -//////////////////////////////////////////////////////////////////// +/** + * Either an lvalue- or rvalue-reference. + */ class CPPReferenceType : public CPPType { public: enum ValueCategory { diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 9a76fb6657..54bc80fe2a 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -1,17 +1,15 @@ -// Filename: cppScope.cxx -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppScope.cxx + * @author drose + * @date 1999-10-21 + */ #include "cppScope.h" #include "cppParser.h" @@ -33,11 +31,9 @@ #include "cppBisonDefs.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope:: CPPScope(CPPScope *parent_scope, const CPPNameComponent &name, CPPVisibility starting_vis) : @@ -52,83 +48,66 @@ CPPScope(CPPScope *parent_scope, _subst_decl_recursive_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope:: ~CPPScope() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::set_struct_type -// Access: Public -// Description: Sets the struct or class that owns this scope. This -// should only be done once, when the scope and its -// associated struct are created. It's provided so the -// scope can check the struct's ancestry for inherited -// symbols. -//////////////////////////////////////////////////////////////////// +/** + * Sets the struct or class that owns this scope. This should only be done + * once, when the scope and its associated struct are created. It's provided + * so the scope can check the struct's ancestry for inherited symbols. + */ void CPPScope:: set_struct_type(CPPStructType *struct_type) { _struct_type = struct_type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_struct_type -// Access: Public -// Description: Returns the class or struct that defines this scope, -// if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the class or struct that defines this scope, if any. + */ CPPStructType *CPPScope:: get_struct_type() const { return _struct_type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_parent_scope -// Access: Public -// Description: Returns the parent scope of this scope, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent scope of this scope, if any. + */ CPPScope *CPPScope:: get_parent_scope() const { return _parent_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::set_current_vis -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: set_current_vis(CPPVisibility current_vis) { _current_vis = current_vis; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_current_vis -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPVisibility CPPScope:: get_current_vis() const { return _current_vis; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::add_declaration -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: add_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *preprocessor, const cppyyltype &pos) { decl->_vis = _current_vis; - // Get the recent comments from the preprocessor. These are the - // comments that appeared preceding this particular declaration; - // they might be relevant to the declaration. + // Get the recent comments from the preprocessor. These are the comments + // that appeared preceding this particular declaration; they might be + // relevant to the declaration. if (decl->_leading_comment == (CPPCommentBlock *)NULL) { decl->_leading_comment = @@ -140,11 +119,9 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, handle_declaration(decl, global_scope, preprocessor); } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::add_enum_value -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor, const cppyyltype &pos) { @@ -161,8 +138,8 @@ add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor, preprocessor->get_comment_before(pos.first_line, pos.file); if (comment != NULL) { - // This is a bit of a hack, but it prevents us from picking - // up a same-line comment from the previous line. + // This is a bit of a hack, but it prevents us from picking up a same- + // line comment from the previous line. if (comment->_line_number != pos.first_line - 1 || comment->_col_number <= pos.first_column) { @@ -180,11 +157,9 @@ add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::define_extension_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { assert(type != NULL); @@ -211,14 +186,14 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { break; } - // Create an implicit typedef for the extension. - //CPPTypedefType *td = new CPPTypedefType(type, name); + // Create an implicit typedef for the extension. CPPTypedefType *td = new + // CPPTypedefType(type, name); pair result = _types.insert(Types::value_type(name, type)); if (!result.second) { - // There's already a typedef for this extension. This one - // overrides it only if the other is a forward declaration. + // There's already a typedef for this extension. This one overrides it + // only if the other is a forward declaration. CPPType *other_type = (*result.first).second; if (other_type->get_subtype() == CPPDeclaration::ST_extension) { @@ -278,25 +253,23 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { _templates.insert(Templates::value_type(simple_name, type)); if (!result.second) { - // The template was not inserted because we already had a - // template definition with the given name. If the previous - // definition was incomplete, replace it. + // The template was not inserted because we already had a template + // definition with the given name. If the previous definition was + // incomplete, replace it. CPPDeclaration *old_templ = (*result.first).second; CPPType *old_templ_type = old_templ->as_type(); if (old_templ_type == NULL || old_templ_type->is_incomplete()) { - // The previous template definition was incomplete, maybe a - // forward reference; replace it with the good one. + // The previous template definition was incomplete, maybe a forward + // reference; replace it with the good one. (*result.first).second = type; } } } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::define_namespace -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: define_namespace(CPPNamespace *ns) { string name = ns->get_simple_name(); @@ -309,11 +282,9 @@ define_namespace(CPPNamespace *ns) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::add_using -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: add_using(CPPUsing *using_decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { @@ -339,14 +310,11 @@ add_using(CPPUsing *using_decl, CPPScope *global_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPScope:: is_fully_specified() const { if (_fully_specified_known) { @@ -381,11 +349,9 @@ is_fully_specified() const { return specified; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::instantiate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPScope:: instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, @@ -408,8 +374,8 @@ instantiate(const CPPTemplateParameterList *actual_params, Instantiations::const_iterator ii; ii = _instantiations.find(actual_params); if (ii != _instantiations.end()) { - // We've already instantiated this scope with these parameters. - // Return that. + // We've already instantiated this scope with these parameters. Return + // that. return (*ii).second; } @@ -431,12 +397,12 @@ instantiate(const CPPTemplateParameterList *actual_params, } else { CPPNameComponent name = _name; name.set_templ(new CPPTemplateParameterList(*actual_params)); - // scope = new CPPScope(current_scope, name, V_public); + // scope = new CPPScope(current_scope, name, V_public); scope = new CPPScope(_parent_scope, name, V_public); copy_substitute_decl(scope, subst, global_scope); - // Also define any new template parameter types, in case we - // "instantiated" this scope with another template parameter. + // Also define any new template parameter types, in case we "instantiated" + // this scope with another template parameter. CPPTemplateParameterList::Parameters::const_iterator pi; for (pi = actual_params->_parameters.begin(); pi != actual_params->_parameters.end(); @@ -444,10 +410,9 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPDeclaration *decl = (*pi); CPPClassTemplateParameter *ctp = decl->as_class_template_parameter(); if (ctp != NULL) { - //CPPTypedefType *td = new CPPTypedefType(ctp, ctp->_ident); - //scope->_typedefs.insert(Typedefs::value_type - // (ctp->_ident->get_local_name(), - // td)); + // CPPTypedefType *td = new CPPTypedefType(ctp, ctp->_ident); + // scope->_typedefs.insert(Typedefs::value_type + // (ctp->_ident->get_local_name(), td)); scope->_types.insert(Types::value_type (ctp->_ident->get_local_name(), ctp)); @@ -455,18 +420,16 @@ instantiate(const CPPTemplateParameterList *actual_params, } } - // Finally, record this particular instantiation for future - // reference, so we don't have to do this again. + // Finally, record this particular instantiation for future reference, so we + // don't have to do this again. ((CPPScope *)this)->_instantiations.insert(Instantiations::value_type(actual_params, scope)); return scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPScope:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) const { @@ -487,10 +450,10 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, if (_parent_scope != NULL && _parent_scope->as_template_scope() != NULL) { - // If the parent of this scope is a template scope--e.g. this - // scope has template parameters--then we must first remove any of - // the template parameters from the subst list. These will later - // get substituted properly during instantiation. + // If the parent of this scope is a template scope--e.g. this scope has + // template parameters--then we must first remove any of the template + // parameters from the subst list. These will later get substituted + // properly during instantiation. const CPPTemplateParameterList &p = _parent_scope->as_template_scope()->_parameters; @@ -513,11 +476,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType *CPPScope:: find_type(const string &name, bool recurse) const { Types::const_iterator ti; @@ -556,11 +517,9 @@ find_type(const string &name, bool recurse) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType *CPPScope:: find_type(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse) const { @@ -603,11 +562,9 @@ find_type(const string &name, CPPDeclaration::SubstDecl &subst, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPScope:: find_scope(const string &name, bool recurse) const { Namespaces::const_iterator ni = _namespaces.find(name); @@ -665,11 +622,9 @@ find_scope(const string &name, bool recurse) const { return (CPPScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPScope:: find_scope(const string &name, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope, bool recurse) const { @@ -696,11 +651,9 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst, return st->_scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_symbol -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPScope:: find_symbol(const string &name, bool recurse) const { if (_struct_type != NULL && name == get_simple_name()) { @@ -760,11 +713,9 @@ find_symbol(const string &name, bool recurse) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::find_template -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPScope:: find_template(const string &name, bool recurse) const { Templates::const_iterator ti; @@ -803,11 +754,9 @@ find_template(const string &name, bool recurse) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPScope:: get_simple_name() const { /* @@ -818,11 +767,9 @@ get_simple_name() const { return _name.get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPScope:: get_local_name(CPPScope *scope) const { /* @@ -844,11 +791,9 @@ get_local_name(CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPScope:: get_fully_scoped_name() const { /* @@ -865,14 +810,12 @@ get_fully_scoped_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: output(ostream &out, CPPScope *scope) const { - // out << get_local_name(scope); + // out << get_local_name(scope); if (_parent_scope != NULL && _parent_scope != scope) { _parent_scope->output(out, scope); out << "::"; @@ -880,11 +823,9 @@ output(ostream &out, CPPScope *scope) const { out << _name; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPScope:: write(ostream &out, int indent_level, CPPScope *scope) const { CPPVisibility vis = V_unknown; @@ -907,13 +848,10 @@ write(ostream &out, int indent_level, CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::get_template_scope -// Access: Public -// Description: Returns the nearest ancestor of this scope that is a -// template scope, or NULL if the scope is fully -// specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nearest ancestor of this scope that is a template scope, or + * NULL if the scope is fully specified. + */ CPPTemplateScope *CPPScope:: get_template_scope() { if (as_template_scope()) { @@ -925,29 +863,22 @@ get_template_scope() { return (CPPTemplateScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::as_template_scope -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateScope *CPPScope:: as_template_scope() { return (CPPTemplateScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::copy_substitute_decl -// Access: Private -// Description: This is in support of both substitute_decl() and -// instantiate(). It's similar in purpose to -// substitute_decl(), but this function assumes the -// caller has already created a new, empty scope. All -// of the declarations in this scope are copied to the -// new scope, filtering through the subst decl. -// -// The return value is true if the scope is changed, -// false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * This is in support of both substitute_decl() and instantiate(). It's + * similar in purpose to substitute_decl(), but this function assumes the + * caller has already created a new, empty scope. All of the declarations in + * this scope are copied to the new scope, filtering through the subst decl. + * + * The return value is true if the scope is changed, false if it is not. + */ bool CPPScope:: copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, CPPScope *global_scope) const { @@ -1107,13 +1038,10 @@ copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst, } -//////////////////////////////////////////////////////////////////// -// Function: CPPScope::handle_declaration -// Access: Private -// Description: Does the right thing with a newly given declaration: -// adds it to the typedef list, or variables or -// functions, or whatever. -//////////////////////////////////////////////////////////////////// +/** + * Does the right thing with a newly given declaration: adds it to the typedef + * list, or variables or functions, or whatever. + */ void CPPScope:: handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { @@ -1128,8 +1056,8 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPType *other_type = result.first->second; CPPTypedefType *other_td = other_type->as_typedef_type(); - // We don't do redefinitions of typedefs. But we don't complain - // as long as this is actually a typedef to the previous definition. + // We don't do redefinitions of typedefs. But we don't complain as long + // as this is actually a typedef to the previous definition. if (other_type != def->_type && (other_td == NULL || !other_td->_type->is_equivalent(*def->_type))) { @@ -1169,18 +1097,18 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, inst->check_for_constructor(this, global_scope); if (inst->_ident != NULL) { - // Not sure if this is the best place to assign this. However, - // this fixes a bug with variables in expressions not having - // the proper scoping prefix. ~rdb + // Not sure if this is the best place to assign this. However, this + // fixes a bug with variables in expressions not having the proper + // scoping prefix. ~rdb inst->_ident->_native_scope = this; } string name = inst->get_simple_name(); if (!name.empty() && inst->get_scope(this, global_scope) == this) { if (inst->_type->as_function_type()) { - // This is a function declaration; hence it gets added to - // the _functions member. But we must be careful to share - // common-named functions. + // This is a function declaration; hence it gets added to the + // _functions member. But we must be careful to share common-named + // functions. CPPFunctionGroup *fgroup; Functions::const_iterator fi; @@ -1194,14 +1122,14 @@ handle_declaration(CPPDeclaration *decl, CPPScope *global_scope, fgroup->_instances.push_back(inst); } else { - // This is not a function declaration; hence it gets added - // to the _variables member. + // This is not a function declaration; hence it gets added to the + // _variables member. _variables[name] = inst; } if (inst->is_template()) { - // Don't add a new template definition if we already had one - // by the same name in another scope. + // Don't add a new template definition if we already had one by the + // same name in another scope. if (find_template(name) == NULL) { _templates.insert(Templates::value_type(name, inst)); diff --git a/dtool/src/cppparser/cppScope.h b/dtool/src/cppparser/cppScope.h index 6b7cd1feaa..7941a9afb1 100644 --- a/dtool/src/cppparser/cppScope.h +++ b/dtool/src/cppparser/cppScope.h @@ -1,16 +1,15 @@ -// Filename: cppScope.h -// Created by: drose (21Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppScope.h + * @author drose + * @date 1999-10-21 + */ #ifndef CPPSCOPE_H #define CPPSCOPE_H @@ -43,10 +42,9 @@ class CPPPreprocessor; class CPPNameComponent; struct cppyyltype; -//////////////////////////////////////////////////////////////////// -// Class : CPPScope -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPScope { public: CPPScope(CPPScope *parent_scope, diff --git a/dtool/src/cppparser/cppSimpleType.cxx b/dtool/src/cppparser/cppSimpleType.cxx index ee8d2a1627..8c9b323945 100644 --- a/dtool/src/cppparser/cppSimpleType.cxx +++ b/dtool/src/cppparser/cppSimpleType.cxx @@ -1,25 +1,22 @@ -// Filename: cppSimpleType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppSimpleType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppSimpleType.h" #include "cppGlobals.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPSimpleType:: CPPSimpleType(CPPSimpleType::Type type, int flags) : CPPType(CPPFile()), @@ -27,81 +24,63 @@ CPPSimpleType(CPPSimpleType::Type type, int flags) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPSimpleType:: is_tbd() const { return (_type == T_unknown); } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPSimpleType:: is_trivial() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPSimpleType:: is_default_constructible() const { return (_type != T_void); } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPSimpleType:: is_copy_constructible() const { return (_type != T_void); } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_parameter_expr -// Access: Public, Virtual -// Description: Returns true if the type is a special parameter -// expression type. -// -// This sort of type is created to handle instance -// declarations that initially look like function -// prototypes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is a special parameter expression type. + * + * This sort of type is created to handle instance declarations that initially + * look like function prototypes. + */ bool CPPSimpleType:: is_parameter_expr() const { return (_type == T_parameter); } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::get_preferred_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPSimpleType:: get_preferred_name() const { // Simple types always prefer to use their native types. return get_local_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPSimpleType:: output(ostream &out, int, CPPScope *, bool) const { if (_flags & F_unsigned) { @@ -114,9 +93,8 @@ output(ostream &out, int, CPPScope *, bool) const { if ((_type == T_int && (_flags & F_longlong) != 0) && !cpp_longlong_keyword.empty()) { - // It's a long long, and we have a specific long long type name. - // This is to output code for compilers that don't recognize "long - // long int". + // It's a long long, and we have a specific long long type name. This is + // to output code for compilers that don't recognize "long long int". out << cpp_longlong_keyword; return; } @@ -187,33 +165,27 @@ output(ostream &out, int, CPPScope *, bool) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPSimpleType:: get_subtype() const { return ST_simple; } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::as_simple_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPSimpleType *CPPSimpleType:: as_simple_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPSimpleType:: is_equal(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); @@ -223,13 +195,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPSimpleType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPSimpleType:: is_less(const CPPDeclaration *other) const { const CPPSimpleType *ot = ((CPPDeclaration *)other)->as_simple_type(); diff --git a/dtool/src/cppparser/cppSimpleType.h b/dtool/src/cppparser/cppSimpleType.h index 51b2806005..12ee96857f 100644 --- a/dtool/src/cppparser/cppSimpleType.h +++ b/dtool/src/cppparser/cppSimpleType.h @@ -1,16 +1,15 @@ -// Filename: cppSimpleType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppSimpleType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPSIMPLETYPE_H #define CPPSIMPLETYPE_H @@ -19,10 +18,9 @@ #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPSimpleType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPSimpleType : public CPPType { public: enum Type { @@ -37,30 +35,23 @@ public: T_double, T_void, - // We need something to represent the type of nullptr so that we - // can return it from decltype(nullptr). Note that this is not - // the same as nullptr_t, which is a typedef of decltype(nullptr). + // We need something to represent the type of nullptr so that we can + // return it from decltype(nullptr). Note that this is not the same as + // nullptr_t, which is a typedef of decltype(nullptr). T_nullptr, - // T_parameter is a special type which is assigned to expressions - // that are discovered where a formal parameter was expected. - // This is a special case for handling cases like this: - // - // int foo(0); - // - // which really means the same thing as: - // - // int foo = 0; - // - // but it initially looks like a function prototype. - // +/* + * T_parameter is a special type which is assigned to expressions that are + * discovered where a formal parameter was expected. This is a special case + * for handling cases like this: int foo(0); which really means the same thing + * as: int foo = 0; but it initially looks like a function prototype. + */ T_parameter, - // T_auto is also a special type that corresponds to the "auto" - // keyword used in a variable assignment. The type of it is - // automatically determined at a later stage based on the type - // of the expression that is assigned to it. - // + // T_auto is also a special type that corresponds to the "auto" keyword + // used in a variable assignment. The type of it is automatically + // determined at a later stage based on the type of the expression that is + // assigned to it. T_auto, }; diff --git a/dtool/src/cppparser/cppStructType.cxx b/dtool/src/cppparser/cppStructType.cxx index 36e20a1f73..f1f610c191 100644 --- a/dtool/src/cppparser/cppStructType.cxx +++ b/dtool/src/cppparser/cppStructType.cxx @@ -1,17 +1,15 @@ -// Filename: cppStructType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppStructType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppStructType.h" #include "cppTypedefType.h" @@ -25,11 +23,9 @@ #include "indent.h" #include "cppParser.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::Base::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPStructType::Base:: output(ostream &out) const { if (_is_virtual) { @@ -38,11 +34,9 @@ output(ostream &out) const { out << _vis << " " << *_base; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPStructType:: CPPStructType(CPPStructType::Type type, CPPIdentifier *ident, CPPScope *current_scope, CPPScope *scope, @@ -55,11 +49,9 @@ CPPStructType(CPPStructType::Type type, CPPIdentifier *ident, _incomplete = true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPStructType:: CPPStructType(const CPPStructType ©) : CPPExtensionType(copy), @@ -71,11 +63,9 @@ CPPStructType(const CPPStructType ©) : _subst_decl_recursive_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPStructType:: operator = (const CPPStructType ©) { CPPExtensionType::operator = (copy); @@ -85,13 +75,10 @@ operator = (const CPPStructType ©) { _final = copy._final; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::append_derivation -// Access: Public -// Description: A handy function used while parsing to add a new base -// class to the list of classes (or structs) this class -// derives from. -//////////////////////////////////////////////////////////////////// +/** + * A handy function used while parsing to add a new base class to the list of + * classes (or structs) this class derives from. + */ void CPPStructType:: append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual) { if (base != NULL) { @@ -120,23 +107,18 @@ append_derivation(CPPType *base, CPPVisibility vis, bool is_virtual) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPStructType:: get_scope() const { return _scope; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_abstract -// Access: Public -// Description: Returns true if this struct declaration is abstract, -// e.g. it contains or inherits at least one method that -// is pure virtual. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this struct declaration is abstract, e.g. it contains or + * inherits at least one method that is pure virtual. + */ bool CPPStructType:: is_abstract() const { VFunctions funcs; @@ -144,12 +126,9 @@ is_abstract() const { return !funcs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPStructType:: is_trivial() const { // Make sure all base classes are trivial. @@ -187,7 +166,7 @@ is_trivial() const { } } - // Now look for functions that are virtual or con/destructors. + // Now look for functions that are virtual or condestructors. bool is_default_constructible = true; CPPScope::Functions::const_iterator fi; for (fi = _scope->_functions.begin(); fi != _scope->_functions.end(); ++fi) { @@ -214,8 +193,8 @@ is_trivial() const { if (ftype->_flags & (CPPFunctionType::F_destructor | CPPFunctionType::F_move_constructor | CPPFunctionType::F_copy_constructor)) { - // User-provided destructors and copy/move constructors are not - // trivial unless they are defaulted (and not virtual). + // User-provided destructors and copymove constructors are not trivial + // unless they are defaulted (and not virtual). return false; } @@ -241,31 +220,25 @@ is_trivial() const { return is_default_constructible; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPStructType:: is_default_constructible() const { return is_default_constructible(V_public); } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPStructType:: is_copy_constructible() const { return is_copy_constructible(V_public); } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_default_constructible -// Access: Public -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPStructType:: is_default_constructible(CPPVisibility min_vis) const { CPPInstance *constructor = get_default_constructor(); @@ -289,8 +262,8 @@ is_default_constructible(CPPVisibility min_vis) const { return false; } - // Implicit default constructor. Check if the implicit default - // constructor is deleted. + // Implicit default constructor. Check if the implicit default constructor + // is deleted. Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); @@ -343,11 +316,9 @@ is_default_constructible(CPPVisibility min_vis) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_copy_constructible -// Access: Public -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPStructType:: is_copy_constructible(CPPVisibility min_vis) const { CPPInstance *constructor = get_copy_constructor(); @@ -379,8 +350,8 @@ is_copy_constructible(CPPVisibility min_vis) const { } } - // Implicit copy constructor. Check if the implicit copy - // constructor is deleted. + // Implicit copy constructor. Check if the implicit copy constructor is + // deleted. Derivation::const_iterator di; for (di = _derivation.begin(); di != _derivation.end(); ++di) { CPPStructType *base = (*di)._base->as_struct_type(); @@ -428,26 +399,20 @@ is_copy_constructible(CPPVisibility min_vis) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::check_virtual -// Access: Public -// Description: Ensures all functions are correctly marked with the -// "virtual" flag if they are truly virtual by virtue of -// inheritance, rather than simply being labeled -// virtual. -// -// This also sets the CPPInstance::SC_inherited_virtual -// flags on those virtual methods that override a -// virtual method defined in a parent class (as opposed -// to those that appear for this first time in this -// class). It is sometimes useful to know whether a -// given virtual method represents the first time that -// particular method appears. -// -// The return value is true if this class defines or -// inherits any virtual methods (and thus requires a -// virtual function pointer), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Ensures all functions are correctly marked with the "virtual" flag if they + * are truly virtual by virtue of inheritance, rather than simply being + * labeled virtual. + * + * This also sets the CPPInstance::SC_inherited_virtual flags on those virtual + * methods that override a virtual method defined in a parent class (as + * opposed to those that appear for this first time in this class). It is + * sometimes useful to know whether a given virtual method represents the + * first time that particular method appears. + * + * The return value is true if this class defines or inherits any virtual + * methods (and thus requires a virtual function pointer), or false otherwise. + */ bool CPPStructType:: check_virtual() const { VFunctions funcs; @@ -455,14 +420,11 @@ check_virtual() const { return !funcs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPStructType:: is_fully_specified() const { if (_scope != NULL && !_scope->is_fully_specified()) { @@ -471,23 +433,18 @@ is_fully_specified() const { return CPPType::is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPStructType:: is_incomplete() const { return _incomplete; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_constructor -// Access: Public -// Description: Returns the constructor defined for the struct type, -// if any, or NULL if no constructor is found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the constructor defined for the struct type, if any, or NULL if no + * constructor is found. + */ CPPFunctionGroup *CPPStructType:: get_constructor() const { // Just look for the function with the same name as the class. @@ -500,12 +457,10 @@ get_constructor() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_default_constructor -// Access: Public -// Description: Returns the default constructor defined for the -// struct type, or NULL if there is none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default constructor defined for the struct type, or NULL if + * there is none. + */ CPPInstance *CPPStructType:: get_default_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); @@ -533,12 +488,10 @@ get_default_constructor() const { return (CPPInstance *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_copy_constructor -// Access: Public -// Description: Returns the copy constructor defined for the struct -// type, or NULL if no copy constructor exists. -//////////////////////////////////////////////////////////////////// +/** + * Returns the copy constructor defined for the struct type, or NULL if no + * copy constructor exists. + */ CPPInstance *CPPStructType:: get_copy_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); @@ -564,12 +517,10 @@ get_copy_constructor() const { return (CPPInstance *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_move_constructor -// Access: Public -// Description: Returns the move constructor defined for the struct -// type, or NULL if no move constructor exists. -//////////////////////////////////////////////////////////////////// +/** + * Returns the move constructor defined for the struct type, or NULL if no + * move constructor exists. + */ CPPInstance *CPPStructType:: get_move_constructor() const { CPPFunctionGroup *fgroup = get_constructor(); @@ -595,17 +546,15 @@ get_move_constructor() const { return (CPPInstance *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_destructor -// Access: Public -// Description: Returns the destructor defined for the struct type, -// if any, or NULL if no destructor is found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the destructor defined for the struct type, if any, or NULL if no + * destructor is found. + */ CPPInstance *CPPStructType:: get_destructor() const { - // Iterate through all the functions that begin with '~' until we - // find one that claims to be a destructor. In theory, there should - // only be one such function. + // Iterate through all the functions that begin with '~' until we find one + // that claims to be a destructor. In theory, there should only be one such + // function. CPPScope::Functions::const_iterator fi; fi = _scope->_functions.lower_bound("~"); @@ -632,18 +581,16 @@ get_destructor() const { return (CPPInstance *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::instantiate -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPStructType:: instantiate(const CPPTemplateParameterList *actual_params, CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { // I *think* this assertion is no longer valid. Who knows. - // assert(!_incomplete); + // assert(!_incomplete); if (_scope == NULL) { if (error_sink != NULL) { @@ -657,9 +604,9 @@ instantiate(const CPPTemplateParameterList *actual_params, _scope->instantiate(actual_params, current_scope, global_scope, error_sink); if (scope->get_struct_type()->get_scope() != scope) { - // Hmm, this type seems to be not completely defined. We must be - // in the middle of recursively instantiating the scope. Thus, we - // don't yet know what its associated struct type will be. + // Hmm, this type seems to be not completely defined. We must be in the + // middle of recursively instantiating the scope. Thus, we don't yet know + // what its associated struct type will be. // Postpone the evaluation of this type. CPPIdentifier *ident = new CPPIdentifier(get_fully_scoped_name(), _file); @@ -670,19 +617,17 @@ instantiate(const CPPTemplateParameterList *actual_params, CPPType *result = scope->get_struct_type(); result = CPPType::new_type(result); if (result != (CPPType *)this) { - // This really means the method ought to be non-const. But I'm - // too lazy to propagate this change all the way back right now, - // so this hack is here. + // This really means the method ought to be non-const. But I'm too lazy + // to propagate this change all the way back right now, so this hack is + // here. ((CPPStructType *)this)->_instantiations.insert(result); } return result; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPStructType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -698,8 +643,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } if (_subst_decl_recursive_protect) { - // We're already executing this block; we'll have to return a - // proxy to the type which we'll define later. + // We're already executing this block; we'll have to return a proxy to the + // type which we'll define later. CPPTypeProxy *proxy = new CPPTypeProxy; _proxies.push_back(proxy); assert(proxy != NULL); @@ -727,8 +672,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, if (pscope != (CPPScope *)NULL && pscope->_name.has_templ()) { - // If the struct name didn't have an explicit template - // reference before, now it does. + // If the struct name didn't have an explicit template reference + // before, now it does. if (!_ident->_names.empty() && !_ident->_names.back().has_templ()) { if (rep->is_template()) { rep->_template_scope = (CPPTemplateScope *)NULL; @@ -760,8 +705,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, subst.insert(SubstDecl::value_type(this, rep)); _subst_decl_recursive_protect = false; - // Now fill in all the proxies we created for our recursive - // references. + // Now fill in all the proxies we created for our recursive references. Proxies::iterator pi; for (pi = _proxies.begin(); pi != _proxies.end(); ++pi) { (*pi)->_actual_type = rep; @@ -776,11 +720,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPStructType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (!complete && _ident != NULL) { @@ -827,39 +769,30 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPStructType:: get_subtype() const { return ST_struct; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::as_struct_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPStructType *CPPStructType:: as_struct_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::get_virtual_funcs -// Access: Public -// Description: Fills funcs up with a list of all the virtual -// function declarations (pure-virtual or otherwise) -// defined at or above this class. This is used to -// determine which functions in a given class are -// actually virtual, since a function is virtual whose -// parent class holds a virtual function by the same -// name, whether or not it is actually declared virtual -// in the derived class. -//////////////////////////////////////////////////////////////////// +/** + * Fills funcs up with a list of all the virtual function declarations (pure- + * virtual or otherwise) defined at or above this class. This is used to + * determine which functions in a given class are actually virtual, since a + * function is virtual whose parent class holds a virtual function by the same + * name, whether or not it is actually declared virtual in the derived class. + */ void CPPStructType:: get_virtual_funcs(VFunctions &funcs) const { // First, get all the virtual funcs from our parents. @@ -873,8 +806,8 @@ get_virtual_funcs(VFunctions &funcs) const { } } - // Now look for matching functions in this class that we can now - // infer are virtual. + // Now look for matching functions in this class that we can now infer are + // virtual. VFunctions::iterator vfi, vfnext; vfi = funcs.begin(); while (vfi != funcs.end()) { @@ -890,8 +823,8 @@ get_virtual_funcs(VFunctions &funcs) const { // Ignore deleted functions. } else if ((base_ftype->_flags & CPPFunctionType::F_destructor) != 0) { - // Match destructor-for-destructor; don't try to match - // destructors up by name. + // Match destructor-for-destructor; don't try to match destructors up by + // name. CPPInstance *destructor = get_destructor(); if (destructor != (CPPInstance *)NULL) { // It's a match! This destructor is virtual. @@ -922,15 +855,14 @@ get_virtual_funcs(VFunctions &funcs) const { assert(new_ftype != (CPPFunctionType *)NULL); if (new_ftype->is_equivalent_function(*base_ftype)) { - // It's a match! We now know it's virtual. Erase this - // function from the list, so we can add it back in below. + // It's a match! We now know it's virtual. Erase this function + // from the list, so we can add it back in below. funcs.erase(vfi); match_found = true; - // In fact, it's not only definitely virtual, but it's - // *inherited* virtual, which means only that the - // interface is defined in some parent class. Sometimes - // this is useful to know. + // In fact, it's not only definitely virtual, but it's *inherited* + // virtual, which means only that the interface is defined in some + // parent class. Sometimes this is useful to know. new_inst->_storage_class |= (CPPInstance::SC_virtual | CPPInstance::SC_inherited_virtual); } @@ -960,21 +892,17 @@ get_virtual_funcs(VFunctions &funcs) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::count_pure_virtual_funcs -// Access: Public -// Description: Fills funcs up with a list of all the pure virtual -// function declarations defined at or above this class -// that have not been given definitions. -//////////////////////////////////////////////////////////////////// +/** + * Fills funcs up with a list of all the pure virtual function declarations + * defined at or above this class that have not been given definitions. + */ void CPPStructType:: get_pure_virtual_funcs(VFunctions &funcs) const { // First, get all the virtual functions. VFunctions vfuncs; get_virtual_funcs(vfuncs); - // Now traverse the list, getting out those functions that are pure - // virtual. + // Now traverse the list, getting out those functions that are pure virtual. VFunctions::iterator vfi; for (vfi = vfuncs.begin(); vfi != vfuncs.end(); ++vfi) { CPPInstance *inst = (*vfi); @@ -984,12 +912,10 @@ get_pure_virtual_funcs(VFunctions &funcs) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// type is equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPStructType:: is_equal(const CPPDeclaration *other) const { return CPPDeclaration::is_equal(other); @@ -1002,13 +928,10 @@ is_equal(const CPPDeclaration *other) const { */ } -//////////////////////////////////////////////////////////////////// -// Function: CPPStructType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration to determine whether this -// type should be ordered before another type of the -// same type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPStructType:: is_less(const CPPDeclaration *other) const { return CPPDeclaration::is_less(other); @@ -1024,4 +947,3 @@ is_less(const CPPDeclaration *other) const { (get_fully_scoped_name() < ot->get_fully_scoped_name()); */ } - diff --git a/dtool/src/cppparser/cppStructType.h b/dtool/src/cppparser/cppStructType.h index c6b0a976ab..46c7a428b3 100644 --- a/dtool/src/cppparser/cppStructType.h +++ b/dtool/src/cppparser/cppStructType.h @@ -1,16 +1,15 @@ -// Filename: cppStructType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppStructType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPSTRUCTTYPE_H #define CPPSTRUCTTYPE_H @@ -28,10 +27,9 @@ class CPPScope; class CPPTypeProxy; -//////////////////////////////////////////////////////////////////// -// Class : CPPStructType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPStructType : public CPPExtensionType { public: CPPStructType(Type type, CPPIdentifier *ident, diff --git a/dtool/src/cppparser/cppTBDType.cxx b/dtool/src/cppparser/cppTBDType.cxx index d0bdefeb78..0b01c86817 100644 --- a/dtool/src/cppparser/cppTBDType.cxx +++ b/dtool/src/cppparser/cppTBDType.cxx @@ -1,28 +1,24 @@ -// Filename: cppTBDType.cxx -// Created by: drose (05Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTBDType.cxx + * @author drose + * @date 1999-11-05 + */ #include "cppTBDType.h" #include "cppIdentifier.h" #include "cppSimpleType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTBDType:: CPPTBDType(CPPIdentifier *ident) : CPPType(CPPFile()), @@ -31,14 +27,11 @@ CPPTBDType(CPPIdentifier *ident) : _subst_decl_recursive_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPTBDType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *type = _ident->find_type(current_scope, global_scope); @@ -48,60 +41,47 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPTBDType:: is_tbd() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::get_simple_name -// Access: Public, Virtual -// Description: Returns a fundametal one-word name for the type. -// This name will not include any scoping operators or -// template parameters, so it may not be a compilable -// reference to the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a fundametal one-word name for the type. This name will not + * include any scoping operators or template parameters, so it may not be a + * compilable reference to the type. + */ string CPPTBDType:: get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::get_local_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for this type -// within the indicated scope. If the scope is NULL, -// within the scope the type is declared in. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for this type within the indicated + * scope. If the scope is NULL, within the scope the type is declared in. + */ string CPPTBDType:: get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::get_fully_scoped_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for the type, -// with completely explicit scoping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for the type, with completely explicit + * scoping. + */ string CPPTBDType:: get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPTBDType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -111,8 +91,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return top; } - // Protect against recursive entry into this function block. I know - // it's ugly--have you got any better suggestions? + // Protect against recursive entry into this function block. I know it's + // ugly--have you got any better suggestions? if (_subst_decl_recursive_protect) { // We're already executing this block. return this; @@ -144,43 +124,35 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return result; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTBDType:: output(ostream &out, int, CPPScope *, bool) const { out /* << "typename " */ << *_ident; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPTBDType:: get_subtype() const { return ST_tbd; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::as_tbd_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTBDType *CPPTBDType:: as_tbd_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPTBDType:: is_equal(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); @@ -190,13 +162,10 @@ is_equal(const CPPDeclaration *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPTBDType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPTBDType:: is_less(const CPPDeclaration *other) const { const CPPTBDType *ot = ((CPPDeclaration *)other)->as_tbd_type(); diff --git a/dtool/src/cppparser/cppTBDType.h b/dtool/src/cppparser/cppTBDType.h index d854efb92f..6d35f053f4 100644 --- a/dtool/src/cppparser/cppTBDType.h +++ b/dtool/src/cppparser/cppTBDType.h @@ -1,16 +1,15 @@ -// Filename: cppTBDType.h -// Created by: drose (05Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTBDType.h + * @author drose + * @date 1999-11-05 + */ #ifndef CPPTBDTYPE_H #define CPPTBDTYPE_H @@ -21,14 +20,12 @@ class CPPIdentifier; -//////////////////////////////////////////////////////////////////// -// Class : CPPTBDType -// Description : This represents a type whose exact meaning is still -// to-be-determined. It happens when a typename is -// referenced in a template class (especially using the -// 'typename' keyword) but the actual type cannot be -// known until the class is instantiated. -//////////////////////////////////////////////////////////////////// +/** + * This represents a type whose exact meaning is still to-be-determined. It + * happens when a typename is referenced in a template class (especially using + * the 'typename' keyword) but the actual type cannot be known until the class + * is instantiated. + */ class CPPTBDType : public CPPType { public: CPPTBDType(CPPIdentifier *ident); diff --git a/dtool/src/cppparser/cppTemplateParameterList.cxx b/dtool/src/cppparser/cppTemplateParameterList.cxx index ebb40308b2..54d4ae544c 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.cxx +++ b/dtool/src/cppparser/cppTemplateParameterList.cxx @@ -1,37 +1,31 @@ -// Filename: cppTemplateParameterList.cxx -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTemplateParameterList.cxx + * @author drose + * @date 1999-10-28 + */ #include "cppTemplateParameterList.h" #include "cppClassTemplateParameter.h" #include "cppInstance.h" #include "cppExpression.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateParameterList:: CPPTemplateParameterList() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTemplateParameterList:: get_string() const { ostringstream strname; @@ -39,15 +33,11 @@ get_string() const { return strname.str(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::build_subst_decl -// Access: Public -// Description: Matches up the actual parameters one-to-one with the -// formal parameters they are replacing, so the template -// may be instantiated by swapping out each occurrence -// of a template standin type with its appropriate -// replacement. -//////////////////////////////////////////////////////////////////// +/** + * Matches up the actual parameters one-to-one with the formal parameters they + * are replacing, so the template may be instantiated by swapping out each + * occurrence of a template standin type with its appropriate replacement. + */ void CPPTemplateParameterList:: build_subst_decl(const CPPTemplateParameterList &formal_params, CPPDeclaration::SubstDecl &subst, @@ -101,17 +91,13 @@ build_subst_decl(const CPPTemplateParameterList &formal_params, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::is_fully_specified -// Access: Public -// Description: This function returns true if all the parameters in -// the list are real expressions or classes, and not -// types yet to-be-determined or template parameter -// types. That is, this returns true for a normal -// template instantiation, and false for a template -// instantiation based on template parameters that have -// not yet been specified. -//////////////////////////////////////////////////////////////////// +/** + * This function returns true if all the parameters in the list are real + * expressions or classes, and not types yet to-be-determined or template + * parameter types. That is, this returns true for a normal template + * instantiation, and false for a template instantiation based on template + * parameters that have not yet been specified. + */ bool CPPTemplateParameterList:: is_fully_specified() const { for (int i = 0; i < (int)_parameters.size(); ++i) { @@ -122,13 +108,10 @@ is_fully_specified() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::is_tbd -// Access: Public -// Description: Returns true if any type within the parameter list is -// a CPPTBDType and thus isn't fully determined right -// now. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any type within the parameter list is a CPPTBDType and thus + * isn't fully determined right now. + */ bool CPPTemplateParameterList:: is_tbd() const { for (int i = 0; i < (int)_parameters.size(); ++i) { @@ -145,11 +128,9 @@ is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTemplateParameterList:: operator == (const CPPTemplateParameterList &other) const { if (_parameters.size() != other._parameters.size()) { @@ -163,21 +144,17 @@ operator == (const CPPTemplateParameterList &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTemplateParameterList:: operator != (const CPPTemplateParameterList &other) const { return !(*this == other); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTemplateParameterList:: operator < (const CPPTemplateParameterList &other) const { if (_parameters.size() != other._parameters.size()) { @@ -191,11 +168,9 @@ operator < (const CPPTemplateParameterList &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::substitute_decl -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateParameterList *CPPTemplateParameterList:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -218,11 +193,9 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateParameterList:: output(ostream &out, CPPScope *scope) const { if (!_parameters.empty()) { @@ -238,13 +211,11 @@ output(ostream &out, CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateParameterList::write_formal -// Access: Public -// Description: Writes the list as a set of formal parameters for a -// template scope. Includes the keyword "template" and -// the angle brackets, as well as the trailing newline. -//////////////////////////////////////////////////////////////////// +/** + * Writes the list as a set of formal parameters for a template scope. + * Includes the keyword "template" and the angle brackets, as well as the + * trailing newline. + */ void CPPTemplateParameterList:: write_formal(ostream &out, CPPScope *scope) const { out << "template<"; diff --git a/dtool/src/cppparser/cppTemplateParameterList.h b/dtool/src/cppparser/cppTemplateParameterList.h index f06d959b9d..712dd227cd 100644 --- a/dtool/src/cppparser/cppTemplateParameterList.h +++ b/dtool/src/cppparser/cppTemplateParameterList.h @@ -1,16 +1,15 @@ -// Filename: cppTemplateParameterList.h -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTemplateParameterList.h + * @author drose + * @date 1999-10-28 + */ #ifndef CPPTEMPLATEPARAMETERLIST_H #define CPPTEMPLATEPARAMETERLIST_H @@ -24,14 +23,12 @@ class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPTemplateParameterList -// Description : This class serves to store the parameter list for a -// template function or class, both for the formal -// parameter list (given when the template is defined) -// and for the actual parameter list (given when the -// template is instantiated). -//////////////////////////////////////////////////////////////////// +/** + * This class serves to store the parameter list for a template function or + * class, both for the formal parameter list (given when the template is + * defined) and for the actual parameter list (given when the template is + * instantiated). + */ class CPPTemplateParameterList { public: CPPTemplateParameterList(); @@ -77,5 +74,3 @@ public: }; #endif - - diff --git a/dtool/src/cppparser/cppTemplateScope.cxx b/dtool/src/cppparser/cppTemplateScope.cxx index 7f5fdbb089..baa36a5619 100644 --- a/dtool/src/cppparser/cppTemplateScope.cxx +++ b/dtool/src/cppparser/cppTemplateScope.cxx @@ -1,17 +1,15 @@ -// Filename: cppTemplateScope.cxx -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTemplateScope.cxx + * @author drose + * @date 1999-10-28 + */ #include "cppTemplateScope.h" #include "cppExtensionType.h" @@ -19,11 +17,9 @@ #include "cppIdentifier.h" #include "cppTypedefType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateScope:: CPPTemplateScope(CPPScope *parent_scope) : CPPScope(parent_scope, CPPNameComponent("template"), V_public) @@ -31,11 +27,9 @@ CPPTemplateScope(CPPScope *parent_scope) : } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::add_declaration -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: add_declaration(CPPDeclaration *decl, CPPScope *global_scope, CPPPreprocessor *preprocessor, @@ -45,11 +39,9 @@ add_declaration(CPPDeclaration *decl, CPPScope *global_scope, _parent_scope->add_declaration(decl, global_scope, preprocessor, pos); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::add_enum_value -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor, const cppyyltype &pos) { @@ -58,11 +50,9 @@ add_enum_value(CPPInstance *inst, CPPPreprocessor *preprocessor, _parent_scope->add_enum_value(inst, preprocessor, pos); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::define_extension_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { type->_template_scope = this; @@ -70,22 +60,18 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) { _parent_scope->define_extension_type(type, error_sink); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::define_namespace -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: define_namespace(CPPNamespace *scope) { assert(_parent_scope != NULL); _parent_scope->define_namespace(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::add_using -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: add_using(CPPUsing *using_decl, CPPScope *global_scope, CPPPreprocessor *error_sink) { @@ -93,11 +79,9 @@ add_using(CPPUsing *using_decl, CPPScope *global_scope, _parent_scope->add_using(using_decl, global_scope, error_sink); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::add_template_parameter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: add_template_parameter(CPPDeclaration *param) { _parameters._parameters.push_back(param); @@ -118,57 +102,46 @@ add_template_parameter(CPPDeclaration *param) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPTemplateScope:: is_fully_specified() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTemplateScope:: get_simple_name() const { assert(_parent_scope != NULL); return _parent_scope->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTemplateScope:: get_local_name(CPPScope *scope) const { assert(_parent_scope != NULL); return _parent_scope->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTemplateScope:: get_fully_scoped_name() const { assert(_parent_scope != NULL); return _parent_scope->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTemplateScope:: output(ostream &out, CPPScope *scope) const { CPPScope::output(out, scope); @@ -177,11 +150,9 @@ output(ostream &out, CPPScope *scope) const { out << " >"; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTemplateScope::as_template_scope -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTemplateScope *CPPTemplateScope:: as_template_scope() { return this; diff --git a/dtool/src/cppparser/cppTemplateScope.h b/dtool/src/cppparser/cppTemplateScope.h index 4a2ed8917f..7ce48f34f3 100644 --- a/dtool/src/cppparser/cppTemplateScope.h +++ b/dtool/src/cppparser/cppTemplateScope.h @@ -1,16 +1,15 @@ -// Filename: cppTemplateScope.h -// Created by: drose (28Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTemplateScope.h + * @author drose + * @date 1999-10-28 + */ #ifndef CPPTEMPLATESCOPE_H #define CPPTEMPLATESCOPE_H @@ -20,13 +19,11 @@ #include "cppScope.h" #include "cppTemplateParameterList.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPTemplateScope -// Description : This is an implicit scope that is created following -// the appearance of a "template" or -// some such line in a C++ file. It simply defines the -// template parameters. -//////////////////////////////////////////////////////////////////// +/** + * This is an implicit scope that is created following the appearance of a + * "template" or some such line in a C++ file. It simply + * defines the template parameters. + */ class CPPTemplateScope : public CPPScope { public: CPPTemplateScope(CPPScope *parent_scope); diff --git a/dtool/src/cppparser/cppToken.cxx b/dtool/src/cppparser/cppToken.cxx index 30f0307ebe..b6f03d8d49 100644 --- a/dtool/src/cppparser/cppToken.cxx +++ b/dtool/src/cppparser/cppToken.cxx @@ -1,17 +1,15 @@ -// Filename: cppToken.cxx -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppToken.cxx + * @author drose + * @date 1999-10-22 + */ #include "cppToken.h" #include "cppExpression.h" @@ -20,11 +18,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken:: CPPToken(int token, int line_number, int col_number, const CPPFile &file, const string &str, @@ -39,11 +35,9 @@ CPPToken(int token, int line_number, int col_number, _lloc.file = file; } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken:: CPPToken(int token, const YYLTYPE &loc, const string &str, const YYSTYPE &val) : _token(token), _lloc(loc), _lval(val) @@ -51,11 +45,9 @@ CPPToken(int token, const YYLTYPE &loc, const string &str, const YYSTYPE &val) : _lval.str = str; } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPToken:: CPPToken(const CPPToken ©) : _token(copy._token), @@ -65,11 +57,9 @@ CPPToken(const CPPToken ©) : _lval.u = copy._lval.u; } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPToken:: operator = (const CPPToken ©) { _token = copy._token; @@ -78,33 +68,27 @@ operator = (const CPPToken ©) { _lloc = copy._lloc; } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::eof -// Access: Public, Static -// Description: A named constructor for the token returned when the -// end of file has been reached. -//////////////////////////////////////////////////////////////////// +/** + * A named constructor for the token returned when the end of file has been + * reached. + */ CPPToken CPPToken:: eof() { return CPPToken(0); } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::is_eof -// Access: Public -// Description: Returns true if this is the EOF token. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is the EOF token. + */ bool CPPToken:: is_eof() const { return _token == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPToken::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPToken:: output(ostream &out) const { switch (_token) { diff --git a/dtool/src/cppparser/cppToken.h b/dtool/src/cppparser/cppToken.h index bf3001e996..0c14af3171 100644 --- a/dtool/src/cppparser/cppToken.h +++ b/dtool/src/cppparser/cppToken.h @@ -1,16 +1,15 @@ -// Filename: cppToken.h -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppToken.h + * @author drose + * @date 1999-10-22 + */ #ifndef CPPTOKEN_H #define CPPTOKEN_H @@ -19,10 +18,9 @@ #include "cppBisonDefs.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPToken -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPToken { public: CPPToken(int token, int line_number = 0, int col_number = 0, diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index d3818ca8e9..e6430e6b45 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -1,17 +1,15 @@ -// Filename: cppType.cxx -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppType.cxx + * @author drose + * @date 1999-10-19 + */ #include "cppType.h" #include "cppTypedefType.h" @@ -26,114 +24,88 @@ operator () (CPPType *a, CPPType *b) const { return (*a) < (*b); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType:: CPPType(const CPPFile &file) : CPPDeclaration(file) { _declaration = (CPPTypeDeclaration *)NULL; - // This is set true by interrogate when the "forcetype" keyword is - // used. + // This is set true by interrogate when the "forcetype" keyword is used. _forcetype = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPType:: resolve_type(CPPScope *, CPPScope *) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPType:: is_tbd() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPType:: is_trivial() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPType:: is_default_constructible() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPType:: is_copy_constructible() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_parameter_expr -// Access: Public, Virtual -// Description: Returns true if the type is a special parameter -// expression type. -// -// This sort of type is created to handle instance -// declarations that initially look like function -// prototypes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is a special parameter expression type. + * + * This sort of type is created to handle instance declarations that initially + * look like function prototypes. + */ bool CPPType:: is_parameter_expr() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::has_typedef_name -// Access: Public -// Description: Returns true if the type has even been typedef'ed and -// therefore has a simple name available to stand for -// it. Extension types are all implicitly typedef'ed on -// declaration. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has even been typedef'ed and therefore has a + * simple name available to stand for it. Extension types are all implicitly + * typedef'ed on declaration. + */ bool CPPType:: has_typedef_name() const { return !_typedefs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_typedef_name -// Access: Public -// Description: Returns a string that can be used to name the type, -// if has_typedef_name() returned true. This will be -// the first typedef name applied to the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that can be used to name the type, if has_typedef_name() + * returned true. This will be the first typedef name applied to the type. + */ string CPPType:: get_typedef_name(CPPScope *scope) const { if (_typedefs.empty()) { @@ -143,26 +115,20 @@ get_typedef_name(CPPScope *scope) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_simple_name -// Access: Public, Virtual -// Description: Returns a fundametal one-word name for the type. -// This name will not include any scoping operators or -// template parameters, so it may not be a compilable -// reference to the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a fundametal one-word name for the type. This name will not + * include any scoping operators or template parameters, so it may not be a + * compilable reference to the type. + */ string CPPType:: get_simple_name() const { return get_local_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_local_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for this type -// within the indicated scope. If the scope is NULL, -// within the scope the type is declared in. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for this type within the indicated + * scope. If the scope is NULL, within the scope the type is declared in. + */ string CPPType:: get_local_name(CPPScope *scope) const { ostringstream ostrm; @@ -170,27 +136,21 @@ get_local_name(CPPScope *scope) const { return ostrm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_fully_scoped_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for the type, -// with completely explicit scoping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for the type, with completely explicit + * scoping. + */ string CPPType:: get_fully_scoped_name() const { return get_local_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_preferred_name -// Access: Public, Virtual -// Description: Returns the best name to use for the type from a -// programmer's point of view. This will typically be a -// typedef name if one is available, or the full C++ -// name if it is not. The typedef may or may not be -// visible within the current scope, so this type name -// may not be compilable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the best name to use for the type from a programmer's point of + * view. This will typically be a typedef name if one is available, or the + * full C++ name if it is not. The typedef may or may not be visible within + * the current scope, so this type name may not be compilable. + */ string CPPType:: get_preferred_name() const { string preferred_name = get_preferred_name_for(this); @@ -200,19 +160,16 @@ get_preferred_name() const { return get_local_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_num_alt_names -// Access: Public -// Description: Returns the number of "alternate" names for this -// type. The alternate names are alternate typedef -// names. This list might be empty, or it might be -// long. One of these names may or may not be the same -// as the "preferred" name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of "alternate" names for this type. The alternate names + * are alternate typedef names. This list might be empty, or it might be + * long. One of these names may or may not be the same as the "preferred" + * name. + */ int CPPType:: get_num_alt_names() const { - // We do a lookup based on the type's name, instead of its pointer, - // so we can resolve different expansions of the same type. + // We do a lookup based on the type's name, instead of its pointer, so we + // can resolve different expansions of the same type. string tname = this->get_fully_scoped_name(); if (!tname.empty()) { @@ -227,16 +184,13 @@ get_num_alt_names() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_alt_name -// Access: Public -// Description: Returns the nth "alternate" name for this -// type. See get_num_alt_names(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth "alternate" name for this type. See get_num_alt_names(). + */ string CPPType:: get_alt_name(int n) const { - // We do a lookup based on the type's name, instead of its pointer, - // so we can resolve different expansions of the same type. + // We do a lookup based on the type's name, instead of its pointer, so we + // can resolve different expansions of the same type. string tname = this->get_fully_scoped_name(); if (!tname.empty()) { @@ -253,26 +207,20 @@ get_alt_name(int n) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPType:: is_incomplete() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::is_equivalent -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPType:: is_equivalent(const CPPType &other) const { if (get_subtype() != other.get_subtype()) { @@ -282,27 +230,21 @@ is_equivalent(const CPPType &other) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPType:: output_instance(ostream &out, const string &name, CPPScope *scope) const { output_instance(out, 0, scope, false, "", name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPType:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -312,71 +254,60 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::as_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType *CPPType:: as_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::new_type -// Access: Public, Static -// Description: This should be called whenever a new CPPType object -// is created. It will uniquify the type pointers by -// checking to see if some equivalent CPPType object has -// previously been created; if it has, it returns the -// old object and deletes the new one. Otherwise, it -// stores the new one and returns it. -//////////////////////////////////////////////////////////////////// +/** + * This should be called whenever a new CPPType object is created. It will + * uniquify the type pointers by checking to see if some equivalent CPPType + * object has previously been created; if it has, it returns the old object + * and deletes the new one. Otherwise, it stores the new one and returns it. + */ CPPType *CPPType:: new_type(CPPType *type) { pair result = _types.insert(type); if (result.second) { - // The insertion has taken place; thus, this is the first time - // this type has been declared. + // The insertion has taken place; thus, this is the first time this type + // has been declared. assert(*result.first == type); return type; } // If this triggers, we probably messed up by defining is_less() - // incorrectly; they provide a relative ordering even though they - // are equal to each other. Or, we provided an is_equal() that - // gives false negatives. + // incorrectly; they provide a relative ordering even though they are equal + // to each other. Or, we provided an is_equal() that gives false negatives. assert(**result.first == *type); - // The insertion has not taken place; thus, there was previously - // another equivalent type declared. + // The insertion has not taken place; thus, there was previously another + // equivalent type declared. if (*result.first != type) { // *** Something wrong here. Deleting this should always be safe; - // however, it's not. Thus, someone failed to call new_type() on - // a type pointer before saving it somewhere. Fix me soon. **** + // however, it's not. Thus, someone failed to call new_type() on a type + // pointer before saving it somewhere. Fix me soon. **** delete type; } return *result.first; } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::record_alt_name_for -// Access: Public, Static -// Description: Records a global typedef name associated with the -// indicated Type. This will be an "alt" name, and it -// may also become the "preferred" name. -//////////////////////////////////////////////////////////////////// +/** + * Records a global typedef name associated with the indicated Type. This + * will be an "alt" name, and it may also become the "preferred" name. + */ void CPPType:: record_alt_name_for(const CPPType *type, const string &name) { if (!name.empty()) { string tname = type->get_fully_scoped_name(); if (!tname.empty()) { if (tname.find('<') != string::npos) { - // If the name contains a funny character like a template - // name, then we implicitly take the first typedef as the - // preferred name. + // If the name contains a funny character like a template name, then + // we implicitly take the first typedef as the preferred name. _preferred_names.insert(PreferredNames::value_type(tname, name)); } @@ -389,17 +320,14 @@ record_alt_name_for(const CPPType *type, const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPType::get_preferred_name_for -// Access: Public, Static -// Description: Returns the previously-stored "preferred" name -// associated with the type, if any, or empty string if -// no name is associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the previously-stored "preferred" name associated with the type, if + * any, or empty string if no name is associated. + */ string CPPType:: get_preferred_name_for(const CPPType *type) { - // We do a lookup based on the type's name, instead of its pointer, - // so we can resolve different expansions of the same type. + // We do a lookup based on the type's name, instead of its pointer, so we + // can resolve different expansions of the same type. string tname = type->get_fully_scoped_name(); if (!tname.empty()) { diff --git a/dtool/src/cppparser/cppType.h b/dtool/src/cppparser/cppType.h index 19ed29211a..298eaf179c 100644 --- a/dtool/src/cppparser/cppType.h +++ b/dtool/src/cppparser/cppType.h @@ -1,16 +1,15 @@ -// Filename: cppType.h -// Created by: drose (19Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppType.h + * @author drose + * @date 1999-10-19 + */ #ifndef CPPTYPE_H #define CPPTYPE_H @@ -26,17 +25,15 @@ class CPPTypedefType; class CPPTypeDeclaration; -// This is an STL function object used to uniquely order CPPType -// pointers. +// This is an STL function object used to uniquely order CPPType pointers. class CPPTypeCompare { public: bool operator () (CPPType *a, CPPType *b) const; }; -//////////////////////////////////////////////////////////////////// -// Class : CPPType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPType : public CPPDeclaration { public: typedef vector Typedefs; diff --git a/dtool/src/cppparser/cppTypeDeclaration.cxx b/dtool/src/cppparser/cppTypeDeclaration.cxx index b0f2b9e02b..88509911b4 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.cxx +++ b/dtool/src/cppparser/cppTypeDeclaration.cxx @@ -1,26 +1,21 @@ -// Filename: cppTypeDeclaration.cxx -// Created by: drose (14Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeDeclaration.cxx + * @author drose + * @date 2000-08-14 + */ #include "cppTypeDeclaration.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeDeclaration::Constructor -// Access: Public -// Description: Constructs a new CPPTypeDeclaration object for the -// given type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CPPTypeDeclaration object for the given type. + */ CPPTypeDeclaration:: CPPTypeDeclaration(CPPType *type) : CPPInstance(type, (CPPIdentifier *)NULL) @@ -31,11 +26,9 @@ CPPTypeDeclaration(CPPType *type) : } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeDeclaration::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPTypeDeclaration:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { @@ -49,31 +42,25 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return new CPPTypeDeclaration(decl->as_instance()->_type); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeDeclaration::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTypeDeclaration:: output(ostream &out, int indent_level, CPPScope *scope, bool) const { _type->output(out, indent_level, scope, true); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeDeclaration::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPTypeDeclaration:: get_subtype() const { return ST_type_declaration; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeDeclaration::as_type_declaration -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeDeclaration *CPPTypeDeclaration:: as_type_declaration() { return this; diff --git a/dtool/src/cppparser/cppTypeDeclaration.h b/dtool/src/cppparser/cppTypeDeclaration.h index 2a1639b607..9fb06debef 100644 --- a/dtool/src/cppparser/cppTypeDeclaration.h +++ b/dtool/src/cppparser/cppTypeDeclaration.h @@ -1,16 +1,15 @@ -// Filename: cppTypeDeclaration.h -// Created by: drose (14Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeDeclaration.h + * @author drose + * @date 2000-08-14 + */ #ifndef CPPTYPEDECLARATION_H #define CPPTYPEDECLARATION_H @@ -19,13 +18,11 @@ #include "cppInstance.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPTypeDeclaration -// Description : A CPPTypeDeclaration is a special declaration that -// represents the top-level declaration of a type in a -// source file. Typically this is the first appearance -// of the type. -//////////////////////////////////////////////////////////////////// +/** + * A CPPTypeDeclaration is a special declaration that represents the top-level + * declaration of a type in a source file. Typically this is the first + * appearance of the type. + */ class CPPTypeDeclaration : public CPPInstance { public: CPPTypeDeclaration(CPPType *type); @@ -42,4 +39,3 @@ public: }; #endif - diff --git a/dtool/src/cppparser/cppTypeParser.cxx b/dtool/src/cppparser/cppTypeParser.cxx index 939d1b6ba5..815875dcf9 100644 --- a/dtool/src/cppparser/cppTypeParser.cxx +++ b/dtool/src/cppparser/cppTypeParser.cxx @@ -1,26 +1,22 @@ -// Filename: cppTypeParser.cxx -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeParser.cxx + * @author drose + * @date 1999-12-14 + */ #include "cppTypeParser.h" #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeParser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeParser:: CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) : _current_scope(current_scope), @@ -29,20 +25,16 @@ CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope) : _type = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeParser::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeParser:: ~CPPTypeParser() { } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeParser::parse_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTypeParser:: parse_type(const string &type) { if (!init_type(type)) { @@ -55,11 +47,9 @@ parse_type(const string &type) { return get_error_count() == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeParser::parse_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTypeParser:: parse_type(const string &type, const CPPPreprocessor &filepos) { if (!init_type(type)) { @@ -74,11 +64,9 @@ parse_type(const string &type, const CPPPreprocessor &filepos) { return get_error_count() == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeParser::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTypeParser:: output(ostream &out) const { if (_type == NULL) { diff --git a/dtool/src/cppparser/cppTypeParser.h b/dtool/src/cppparser/cppTypeParser.h index fde4ad069c..af18e0e5b8 100644 --- a/dtool/src/cppparser/cppTypeParser.h +++ b/dtool/src/cppparser/cppTypeParser.h @@ -1,16 +1,15 @@ -// Filename: cppTypeParser.h -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeParser.h + * @author drose + * @date 1999-12-14 + */ #ifndef CPPTYPEPARSER_H #define CPPTYPEPARSER_H @@ -22,10 +21,9 @@ class CPPType; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPTypeParser -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPTypeParser : public CPPPreprocessor { public: CPPTypeParser(CPPScope *current_scope, CPPScope *global_scope); @@ -48,5 +46,3 @@ operator << (ostream &out, const CPPTypeParser &ep) { } #endif - - diff --git a/dtool/src/cppparser/cppTypeProxy.cxx b/dtool/src/cppparser/cppTypeProxy.cxx index 89fde2473a..239ef04828 100644 --- a/dtool/src/cppparser/cppTypeProxy.cxx +++ b/dtool/src/cppparser/cppTypeProxy.cxx @@ -1,26 +1,22 @@ -// Filename: cppTypeProxy.cxx -// Created by: drose (07Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeProxy.cxx + * @author drose + * @date 1999-12-07 + */ #include "cppTypeProxy.h" #include "cppFile.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeProxy:: CPPTypeProxy() : CPPType(CPPFile()) @@ -28,14 +24,11 @@ CPPTypeProxy() : _actual_type = (CPPType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPTypeProxy:: resolve_type(CPPScope *, CPPScope *) { if (_actual_type == (CPPType *)NULL) { @@ -44,14 +37,11 @@ resolve_type(CPPScope *, CPPScope *) { return _actual_type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPTypeProxy:: is_tbd() const { if (_actual_type == (CPPType *)NULL) { @@ -60,14 +50,11 @@ is_tbd() const { return _actual_type->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::has_typedef_name -// Access: Public -// Description: Returns true if the type has even been typedef'ed and -// therefore has a simple name available to stand for -// it. Extension types are all implicitly typedef'ed on -// declaration. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has even been typedef'ed and therefore has a + * simple name available to stand for it. Extension types are all implicitly + * typedef'ed on declaration. + */ bool CPPTypeProxy:: has_typedef_name() const { if (_actual_type == (CPPType *)NULL) { @@ -76,13 +63,10 @@ has_typedef_name() const { return _actual_type->has_typedef_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_typedef_name -// Access: Public -// Description: Returns a string that can be used to name the type, -// if has_typedef_name() returned true. This will be -// the first typedef name applied to the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that can be used to name the type, if has_typedef_name() + * returned true. This will be the first typedef name applied to the type. + */ string CPPTypeProxy:: get_typedef_name(CPPScope *) const { if (_actual_type == (CPPType *)NULL) { @@ -92,14 +76,11 @@ get_typedef_name(CPPScope *) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_simple_name -// Access: Public, Virtual -// Description: Returns a fundametal one-word name for the type. -// This name will not include any scoping operators or -// template parameters, so it may not be a compilable -// reference to the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a fundametal one-word name for the type. This name will not + * include any scoping operators or template parameters, so it may not be a + * compilable reference to the type. + */ string CPPTypeProxy:: get_simple_name() const { if (_actual_type == (CPPType *)NULL) { @@ -108,13 +89,10 @@ get_simple_name() const { return _actual_type->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_local_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for this type -// within the indicated scope. If the scope is NULL, -// within the scope the type is declared in. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for this type within the indicated + * scope. If the scope is NULL, within the scope the type is declared in. + */ string CPPTypeProxy:: get_local_name(CPPScope *scope) const { if (_actual_type == (CPPType *)NULL) { @@ -123,12 +101,10 @@ get_local_name(CPPScope *scope) const { return _actual_type->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_fully_scoped_name -// Access: Public, Virtual -// Description: Returns the compilable, correct name for the type, -// with completely explicit scoping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compilable, correct name for the type, with completely explicit + * scoping. + */ string CPPTypeProxy:: get_fully_scoped_name() const { if (_actual_type == (CPPType *)NULL) { @@ -137,16 +113,12 @@ get_fully_scoped_name() const { return _actual_type->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_preferred_name -// Access: Public, Virtual -// Description: Returns the best name to use for the type from a -// programmer's point of view. This will typically be a -// typedef name if one is available, or the full C++ -// name if it is not. The typedef may or may not be -// visible within the current scope, so this type name -// may not be compilable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the best name to use for the type from a programmer's point of + * view. This will typically be a typedef name if one is available, or the + * full C++ name if it is not. The typedef may or may not be visible within + * the current scope, so this type name may not be compilable. + */ string CPPTypeProxy:: get_preferred_name() const { if (_actual_type == (CPPType *)NULL) { @@ -155,12 +127,9 @@ get_preferred_name() const { return _actual_type->get_preferred_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPTypeProxy:: is_incomplete() const { if (_actual_type == (CPPType *)NULL) { @@ -169,14 +138,11 @@ is_incomplete() const { return _actual_type->is_incomplete(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::output_instance -// Access: Public, Virtual -// Description: Formats a C++-looking line that defines an instance -// of the given type, with the indicated name. In most -// cases this will be "type name", but some types have -// special exceptions. -//////////////////////////////////////////////////////////////////// +/** + * Formats a C++-looking line that defines an instance of the given type, with + * the indicated name. In most cases this will be "type name", but some types + * have special exceptions. + */ void CPPTypeProxy:: output_instance(ostream &out, int indent_level, CPPScope *scope, bool complete, const string &prename, @@ -189,11 +155,9 @@ output_instance(ostream &out, int indent_level, CPPScope *scope, prename, name); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTypeProxy:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { if (_actual_type == (CPPType *)NULL) { @@ -204,21 +168,17 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPTypeProxy:: get_subtype() const { return ST_type_proxy; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPType *CPPTypeProxy:: as_type() { if (_actual_type == (CPPType *)NULL) { @@ -227,11 +187,9 @@ as_type() { return _actual_type; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_simple_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPSimpleType *CPPTypeProxy:: as_simple_type() { if (_actual_type == (CPPType *)NULL) { @@ -240,11 +198,9 @@ as_simple_type() { return _actual_type->as_simple_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_pointer_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPPointerType *CPPTypeProxy:: as_pointer_type() { if (_actual_type == (CPPType *)NULL) { @@ -253,11 +209,9 @@ as_pointer_type() { return _actual_type->as_pointer_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_reference_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPReferenceType *CPPTypeProxy:: as_reference_type() { if (_actual_type == (CPPType *)NULL) { @@ -266,11 +220,9 @@ as_reference_type() { return _actual_type->as_reference_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_array_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPArrayType *CPPTypeProxy:: as_array_type() { if (_actual_type == (CPPType *)NULL) { @@ -279,11 +231,9 @@ as_array_type() { return _actual_type->as_array_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_const_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPConstType *CPPTypeProxy:: as_const_type() { if (_actual_type == (CPPType *)NULL) { @@ -292,11 +242,9 @@ as_const_type() { return _actual_type->as_const_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_function_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPFunctionType *CPPTypeProxy:: as_function_type() { if (_actual_type == (CPPType *)NULL) { @@ -305,11 +253,9 @@ as_function_type() { return _actual_type->as_function_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_extension_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPExtensionType *CPPTypeProxy:: as_extension_type() { if (_actual_type == (CPPType *)NULL) { @@ -318,11 +264,9 @@ as_extension_type() { return _actual_type->as_extension_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_struct_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPStructType *CPPTypeProxy:: as_struct_type() { if (_actual_type == (CPPType *)NULL) { @@ -331,11 +275,9 @@ as_struct_type() { return _actual_type->as_struct_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_enum_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPEnumType *CPPTypeProxy:: as_enum_type() { if (_actual_type == (CPPType *)NULL) { @@ -344,11 +286,9 @@ as_enum_type() { return _actual_type->as_enum_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_tbd_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTBDType *CPPTypeProxy:: as_tbd_type() { if (_actual_type == (CPPType *)NULL) { @@ -357,11 +297,9 @@ as_tbd_type() { return _actual_type->as_tbd_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_typedef_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypedefType *CPPTypeProxy:: as_typedef_type() { if (_actual_type == (CPPType *)NULL) { @@ -370,11 +308,9 @@ as_typedef_type() { return _actual_type->as_typedef_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypeProxy::as_type_proxy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypeProxy *CPPTypeProxy:: as_type_proxy() { return this; diff --git a/dtool/src/cppparser/cppTypeProxy.h b/dtool/src/cppparser/cppTypeProxy.h index 4182b48029..da87e99ca6 100644 --- a/dtool/src/cppparser/cppTypeProxy.h +++ b/dtool/src/cppparser/cppTypeProxy.h @@ -1,16 +1,15 @@ -// Filename: cppTypeProxy.h -// Created by: drose (07Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypeProxy.h + * @author drose + * @date 1999-12-07 + */ #ifndef CPPTYPEPROXY_H #define CPPTYPEPROXY_H @@ -19,13 +18,11 @@ #include "cppType.h" -//////////////////////////////////////////////////////////////////// -// Class : CPPTypeProxy -// Description : This is a special kind of type that is a placeholder -// for some type, currently unknown, that will be filled -// in later. It's used when a type that references -// itself must instantiate. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of type that is a placeholder for some type, + * currently unknown, that will be filled in later. It's used when a type + * that references itself must instantiate. + */ class CPPTypeProxy : public CPPType { public: CPPTypeProxy(); diff --git a/dtool/src/cppparser/cppTypedefType.cxx b/dtool/src/cppparser/cppTypedefType.cxx index 9bb0f24e9b..c86e684420 100644 --- a/dtool/src/cppparser/cppTypedefType.cxx +++ b/dtool/src/cppparser/cppTypedefType.cxx @@ -1,26 +1,23 @@ -// Filename: cppTypedefType.cxx -// Created by: rdb (01Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypedefType.cxx + * @author rdb + * @date 2014-08-01 + */ #include "cppTypedefType.h" #include "cppIdentifier.h" #include "cppInstanceIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypedefType:: CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope) : CPPType(CPPFile()), @@ -34,18 +31,13 @@ CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope) : _subst_decl_recursive_protect = false; - //assert(_type != NULL); - //if (global) { - // _type->_typedefs.push_back(this); - // CPPType::record_alt_name_for(_type, inst->get_local_name()); - //} + // assert(_type != NULL); if (global) { _type->_typedefs.push_back(this); + // CPPType::record_alt_name_for(_type, inst->get_local_name()); } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypedefType:: CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : CPPType(CPPFile()), @@ -59,14 +51,11 @@ CPPTypedefType(CPPType *type, CPPIdentifier *ident, CPPScope *current_scope) : _subst_decl_recursive_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::Constructor -// Access: Public -// Description: Constructs a new CPPTypedefType object that defines a -// typedef to the indicated type according to the type -// and the InstanceIdentifier. The InstanceIdentifier -// pointer is deallocated. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CPPTypedefType object that defines a typedef to the + * indicated type according to the type and the InstanceIdentifier. The + * InstanceIdentifier pointer is deallocated. + */ CPPTypedefType:: CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, CPPScope *current_scope, const CPPFile &file) : @@ -86,11 +75,9 @@ CPPTypedefType(CPPType *type, CPPInstanceIdentifier *ii, _subst_decl_recursive_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_scoped -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CPPTypedefType:: is_scoped() const { if (_ident == NULL) { @@ -100,11 +87,9 @@ is_scoped() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::get_scope -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPScope *CPPTypedefType:: get_scope(CPPScope *current_scope, CPPScope *global_scope, CPPPreprocessor *error_sink) const { @@ -115,11 +100,9 @@ get_scope(CPPScope *current_scope, CPPScope *global_scope, } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::get_simple_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTypedefType:: get_simple_name() const { if (_ident == NULL) { @@ -128,11 +111,9 @@ get_simple_name() const { return _ident->get_simple_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::get_local_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTypedefType:: get_local_name(CPPScope *scope) const { if (_ident == NULL) { @@ -141,11 +122,9 @@ get_local_name(CPPScope *scope) const { return _ident->get_local_name(scope); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::get_fully_scoped_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string CPPTypedefType:: get_fully_scoped_name() const { if (_ident == NULL) { @@ -154,26 +133,20 @@ get_fully_scoped_name() const { return _ident->get_fully_scoped_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_incomplete -// Access: Public, Virtual -// Description: Returns true if the type has not yet been fully -// specified, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type has not yet been fully specified, false if it has. + */ bool CPPTypedefType:: is_incomplete() const { return false; - //return _type->is_incomplete(); + // return _type->is_incomplete(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_tbd -// Access: Public, Virtual -// Description: Returns true if the type, or any nested type within -// the type, is a CPPTBDType and thus isn't fully -// determined right now. In this case, calling -// resolve_type() may or may not resolve the type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type, or any nested type within the type, is a + * CPPTBDType and thus isn't fully determined right now. In this case, + * calling resolve_type() may or may not resolve the type. + */ bool CPPTypedefType:: is_tbd() const { if (_ident != NULL && _ident->is_tbd()) { @@ -182,45 +155,35 @@ is_tbd() const { return _type->is_tbd(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_trivial -// Access: Public, Virtual -// Description: Returns true if the type is considered a Plain Old -// Data (POD) type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is considered a Plain Old Data (POD) type. + */ bool CPPTypedefType:: is_trivial() const { return _type->is_trivial(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_default_constructible -// Access: Public, Virtual -// Description: Returns true if the type is default-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is default-constructible. + */ bool CPPTypedefType:: is_default_constructible() const { return _type->is_default_constructible(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_copy_constructible -// Access: Public, Virtual -// Description: Returns true if the type is copy-constructible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is copy-constructible. + */ bool CPPTypedefType:: is_copy_constructible() const { return _type->is_copy_constructible(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_fully_specified -// Access: Public, Virtual -// Description: Returns true if this declaration is an actual, -// factual declaration, or false if some part of the -// declaration depends on a template parameter which has -// not yet been instantiated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this declaration is an actual, factual declaration, or + * false if some part of the declaration depends on a template parameter which + * has not yet been instantiated. + */ bool CPPTypedefType:: is_fully_specified() const { if (_ident != NULL && !_ident->is_fully_specified()) { @@ -230,18 +193,16 @@ is_fully_specified() const { _type->is_fully_specified(); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::substitute_decl -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration *CPPTypedefType:: substitute_decl(CPPDeclaration::SubstDecl &subst, CPPScope *current_scope, CPPScope *global_scope) { if (_ident != NULL && _ident->get_scope(current_scope, global_scope) == global_scope) { - // Hack... I know that size_t etc is supposed to work fine, so - // preserve these top-level typedefs. + // Hack... I know that size_t etc is supposed to work fine, so preserve + // these top-level typedefs. CPPDeclaration *top = CPPType::substitute_decl(subst, current_scope, global_scope); if (top != this) { @@ -254,10 +215,10 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return _type->substitute_decl(subst, current_scope, global_scope); - // Bah, this doesn't seem to work, and I can't figure out why. - // Well, for now, let's just substitute it with the type we're - // pointing to. This is not a huge deal for now, until we find - // that we need to preserve these typedefs. + // Bah, this doesn't seem to work, and I can't figure out why. Well, for + // now, let's just substitute it with the type we're pointing to. This is + // not a huge deal for now, until we find that we need to preserve these + // typedefs. /* CPPDeclaration *top = @@ -267,8 +228,8 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, } if (_subst_decl_recursive_protect) { - // We're already executing this block; we'll have to return a - // proxy to the type which we'll define later. + // We're already executing this block; we'll have to return a proxy to the + // type which we'll define later. CPPTypeProxy *proxy = new CPPTypeProxy; _proxies.push_back(proxy); assert(proxy != NULL); @@ -299,8 +260,7 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, subst.insert(SubstDecl::value_type(this, rep)); _subst_decl_recursive_protect = false; - // Now fill in all the proxies we created for our recursive - // references. + // Now fill in all the proxies we created for our recursive references. Proxies::iterator pi; for (pi = _proxies.begin(); pi != _proxies.end(); ++pi) { (*pi)->_actual_type = rep; @@ -309,14 +269,11 @@ substitute_decl(CPPDeclaration::SubstDecl &subst, return rep; */ } -//////////////////////////////////////////////////////////////////// -// Function: CPPFunctionType::resolve_type -// Access: Public, Virtual -// Description: If this CPPType object is a forward reference or -// other nonspecified reference to a type that might now -// be known a real type, returns the real type. -// Otherwise returns the type itself. -//////////////////////////////////////////////////////////////////// +/** + * If this CPPType object is a forward reference or other nonspecified + * reference to a type that might now be known a real type, returns the real + * type. Otherwise returns the type itself. + */ CPPType *CPPTypedefType:: resolve_type(CPPScope *current_scope, CPPScope *global_scope) { CPPType *ptype = _type->resolve_type(current_scope, global_scope); @@ -330,15 +287,12 @@ resolve_type(CPPScope *current_scope, CPPScope *global_scope) { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_equivalent_type -// Access: Public, Virtual -// Description: This is a little more forgiving than is_equal(): it -// returns true if the types appear to be referring to -// the same thing, even if they may have different -// pointers or somewhat different definitions. It's -// useful for parameter matching, etc. -//////////////////////////////////////////////////////////////////// +/** + * This is a little more forgiving than is_equal(): it returns true if the + * types appear to be referring to the same thing, even if they may have + * different pointers or somewhat different definitions. It's useful for + * parameter matching, etc. + */ bool CPPTypedefType:: is_equivalent(const CPPType &other) const { CPPType *ot = (CPPType *)&other; @@ -348,17 +302,14 @@ is_equivalent(const CPPType &other) const { ot = ot->as_typedef_type()->_type; } - // Compare the unwrapped type to what we are pointing to. - // If we are pointing to a typedef ourselves, then this will - // automatically recurse. + // Compare the unwrapped type to what we are pointing to. If we are + // pointing to a typedef ourselves, then this will automatically recurse. return _type->is_equivalent(*ot); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPTypedefType:: output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { string name; @@ -380,32 +331,26 @@ output(ostream &out, int indent_level, CPPScope *scope, bool complete) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPTypedefType:: get_subtype() const { return ST_typedef; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::as_typedef_type -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPTypedefType *CPPTypedefType:: as_typedef_type() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_equal -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type is -// equivalent to another type of the same type. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type is equivalent to + * another type of the same type. + */ bool CPPTypedefType:: is_equal(const CPPDeclaration *other) const { const CPPTypedefType *ot = ((CPPDeclaration *)other)->as_typedef_type(); @@ -414,13 +359,10 @@ is_equal(const CPPDeclaration *other) const { return (*_type == *ot->_type) && (*_ident == *ot->_ident) && (_using == ot->_using); } -//////////////////////////////////////////////////////////////////// -// Function: CPPTypedefType::is_less -// Access: Protected, Virtual -// Description: Called by CPPDeclaration() to determine whether this type -// should be ordered before another type of the same -// type, in an arbitrary but fixed ordering. -//////////////////////////////////////////////////////////////////// +/** + * Called by CPPDeclaration() to determine whether this type should be ordered + * before another type of the same type, in an arbitrary but fixed ordering. + */ bool CPPTypedefType:: is_less(const CPPDeclaration *other) const { return CPPDeclaration::is_less(other); diff --git a/dtool/src/cppparser/cppTypedefType.h b/dtool/src/cppparser/cppTypedefType.h index 49ef52c250..921c802383 100644 --- a/dtool/src/cppparser/cppTypedefType.h +++ b/dtool/src/cppparser/cppTypedefType.h @@ -1,16 +1,15 @@ -// Filename: cppTypedefType.h -// Created by: rdb (01Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppTypedefType.h + * @author rdb + * @date 2014-08-01 + */ #ifndef CPPTYPEDEFTYPE_H #define CPPTYPEDEFTYPE_H @@ -21,10 +20,9 @@ class CPPIdentifier; class CPPInstanceIdentifier; -//////////////////////////////////////////////////////////////////// -// Class : CPPTypedefType -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPTypedefType : public CPPType { public: CPPTypedefType(CPPType *type, const string &name, CPPScope *current_scope); diff --git a/dtool/src/cppparser/cppUsing.cxx b/dtool/src/cppparser/cppUsing.cxx index 80bbb0c93a..3611450de6 100644 --- a/dtool/src/cppparser/cppUsing.cxx +++ b/dtool/src/cppparser/cppUsing.cxx @@ -1,26 +1,22 @@ -// Filename: cppUsing.cxx -// Created by: drose (16Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppUsing.cxx + * @author drose + * @date 1999-11-16 + */ #include "cppUsing.h" #include "cppIdentifier.h" -//////////////////////////////////////////////////////////////////// -// Function: CPPUsing::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPUsing:: CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file) : CPPDeclaration(file), @@ -28,11 +24,9 @@ CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file) : { } -//////////////////////////////////////////////////////////////////// -// Function: CPPUsing::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CPPUsing:: output(ostream &out, int, CPPScope *, bool) const { out << "using "; @@ -42,21 +36,17 @@ output(ostream &out, int, CPPScope *, bool) const { out << *_ident; } -//////////////////////////////////////////////////////////////////// -// Function: CPPUsing::get_subtype -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPDeclaration::SubType CPPUsing:: get_subtype() const { return ST_using; } -//////////////////////////////////////////////////////////////////// -// Function: CPPUsing::as_using -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPPUsing *CPPUsing:: as_using() { return this; diff --git a/dtool/src/cppparser/cppUsing.h b/dtool/src/cppparser/cppUsing.h index 25227f9fb0..0ec72c8ebf 100644 --- a/dtool/src/cppparser/cppUsing.h +++ b/dtool/src/cppparser/cppUsing.h @@ -1,16 +1,15 @@ -// Filename: cppUsing.h -// Created by: drose (16Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppUsing.h + * @author drose + * @date 1999-11-16 + */ #ifndef CPPUSING_H #define CPPUSING_H @@ -22,10 +21,9 @@ class CPPIdentifier; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : CPPUsing -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class CPPUsing : public CPPDeclaration { public: CPPUsing(CPPIdentifier *ident, bool full_namespace, const CPPFile &file); diff --git a/dtool/src/cppparser/cppVisibility.cxx b/dtool/src/cppparser/cppVisibility.cxx index fc87756e81..6cee2a70f3 100644 --- a/dtool/src/cppparser/cppVisibility.cxx +++ b/dtool/src/cppparser/cppVisibility.cxx @@ -1,17 +1,15 @@ -// Filename: cppVisibility.cxx -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppVisibility.cxx + * @author drose + * @date 1999-10-22 + */ #include "cppVisibility.h" diff --git a/dtool/src/cppparser/cppVisibility.h b/dtool/src/cppparser/cppVisibility.h index 2703e3dbc6..07d3bfdcb5 100644 --- a/dtool/src/cppparser/cppVisibility.h +++ b/dtool/src/cppparser/cppVisibility.h @@ -1,16 +1,15 @@ -// Filename: cppVisibility.h -// Created by: drose (22Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cppVisibility.h + * @author drose + * @date 1999-10-22 + */ #ifndef CPPVISIBILITY_H #define CPPVISIBILITY_H @@ -28,4 +27,3 @@ enum CPPVisibility { ostream &operator << (ostream &out, CPPVisibility vis); #endif - diff --git a/dtool/src/dconfig/config_dconfig.cxx b/dtool/src/dconfig/config_dconfig.cxx index e4329a6487..49708e719a 100644 --- a/dtool/src/dconfig/config_dconfig.cxx +++ b/dtool/src/dconfig/config_dconfig.cxx @@ -1,16 +1,15 @@ -// Filename: config_dconfig.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dconfig.cxx + * @author drose + * @date 2000-05-15 + */ #include "config_dconfig.h" diff --git a/dtool/src/dconfig/config_dconfig.h b/dtool/src/dconfig/config_dconfig.h index a95ddb0833..9988086d45 100644 --- a/dtool/src/dconfig/config_dconfig.h +++ b/dtool/src/dconfig/config_dconfig.h @@ -1,16 +1,15 @@ -// Filename: config_dconfig.h -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dconfig.h + * @author drose + * @date 2000-05-15 + */ #ifndef CONFIG_DCONFIG_H #define CONFIG_DCONFIG_H diff --git a/dtool/src/dconfig/dconfig.I b/dtool/src/dconfig/dconfig.I index ffa809820e..a49d57cd2c 100644 --- a/dtool/src/dconfig/dconfig.I +++ b/dtool/src/dconfig/dconfig.I @@ -1,17 +1,15 @@ -// Filename: dconfig.I -// Created by: cary (20Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dconfig.I + * @author cary + * @date 2000-03-20 + */ bool DConfig:: GetBool(const string &sym, bool def) { diff --git a/dtool/src/dconfig/dconfig.cxx b/dtool/src/dconfig/dconfig.cxx index 951e42cffd..b57f5b70f4 100644 --- a/dtool/src/dconfig/dconfig.cxx +++ b/dtool/src/dconfig/dconfig.cxx @@ -1,15 +1,14 @@ -// Filename: dconfig.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dconfig.cxx + * @author drose + * @date 1999-02-08 + */ #include "dconfig.h" diff --git a/dtool/src/dconfig/dconfig.h b/dtool/src/dconfig/dconfig.h index 56f9af11ee..cf6e7396fd 100644 --- a/dtool/src/dconfig/dconfig.h +++ b/dtool/src/dconfig/dconfig.h @@ -1,16 +1,15 @@ -// Filename: dconfig.h -// Created by: cary (14Jul98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dconfig.h + * @author cary + * @date 1998-07-14 + */ #ifndef DCONFIG_H #define DCONFIG_H @@ -25,15 +24,12 @@ #include "configVariableList.h" #include "configFlags.h" -//////////////////////////////////////////////////////////////////// -// Class : DConfig -// Description : This class emulates the old dconfig-style interface -// to our Panda config system. It exists only to -// provide backward-compatible support, and it is used -// primarily by Python code. For modern code, use the -// new ConfigVariable* interface instead of this -// deprecated interface. -//////////////////////////////////////////////////////////////////// +/** + * This class emulates the old dconfig-style interface to our Panda config + * system. It exists only to provide backward-compatible support, and it is + * used primarily by Python code. For modern code, use the new + * ConfigVariable* interface instead of this deprecated interface. + */ class EXPCL_DTOOLCONFIG DConfig { PUBLISHED: static INLINE bool GetBool(const string &sym, bool def = false); @@ -46,24 +42,22 @@ PUBLISHED: #include "dconfig.I" -// These macros are used in each directory to call an initialization -// function at static-init time. These macros may eventually be -// phased out in favor of a simpler interface that does not require -// static init. +// These macros are used in each directory to call an initialization function +// at static-init time. These macros may eventually be phased out in favor of +// a simpler interface that does not require static init. -// NOTE: -// Having a macro called Configure proved to be problematic with some -// DX9 headers. To avoid that in the future we provide a new family -// of macros prefixed by DTool and deprecate the old ones, to be -// removed from the codebase sometime in the future. +// NOTE: Having a macro called Configure proved to be problematic with some +// DX9 headers. To avoid that in the future we provide a new family of macros +// prefixed by DTool and deprecate the old ones, to be removed from the +// codebase sometime in the future. // This macro should appear in the config_*.h file. #define ConfigureDecl(name, expcl, exptp) #define DToolConfigureDecl(name, expcl, exptp) -// This macro defines the actual declaration of the object defined -// above; it should appear in the config_*.cxx file. +// This macro defines the actual declaration of the object defined above; it +// should appear in the config_*.cxx file. #define ConfigureDef(name) \ class StaticInitializer_ ## name { \ @@ -78,15 +72,15 @@ PUBLISHED: }; \ static StaticInitializer_ ## name name; -// This macro can be used in lieu of the above two when the Configure -// object does not need to be visible outside of the current C file. +// This macro can be used in lieu of the above two when the Configure object +// does not need to be visible outside of the current C file. #define Configure(name) ConfigureDef(name) #define DToolConfigure(name) DToolConfigureDef(name) -// This one defines a block of code that will be executed at static -// init time. It must always be defined (in the C file), even if no -// code is to be executed. +// This one defines a block of code that will be executed at static init time. +// It must always be defined (in the C file), even if no code is to be +// executed. #define ConfigureFn(name) \ StaticInitializer_ ## name::StaticInitializer_ ## name() diff --git a/dtool/src/dconfig/test_config.cxx b/dtool/src/dconfig/test_config.cxx index ff199fc2f0..40f27e7197 100644 --- a/dtool/src/dconfig/test_config.cxx +++ b/dtool/src/dconfig/test_config.cxx @@ -1,16 +1,15 @@ -// Filename: test_config.cxx -// Created by: cary (10Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_config.cxx + * @author cary + * @date 1998-09-10 + */ #include "dconfig.h" diff --git a/dtool/src/dconfig/test_expand.cxx b/dtool/src/dconfig/test_expand.cxx index 50da8b150a..281e8b02ba 100644 --- a/dtool/src/dconfig/test_expand.cxx +++ b/dtool/src/dconfig/test_expand.cxx @@ -1,16 +1,15 @@ -// Filename: test_expand.cxx -// Created by: cary (31Aug98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_expand.cxx + * @author cary + * @date 1998-08-31 + */ #include "expand.h" #include diff --git a/dtool/src/dconfig/test_pfstream.cxx b/dtool/src/dconfig/test_pfstream.cxx index 1167480e6e..29874a97ac 100644 --- a/dtool/src/dconfig/test_pfstream.cxx +++ b/dtool/src/dconfig/test_pfstream.cxx @@ -1,16 +1,15 @@ -// Filename: test_pfstream.cxx -// Created by: cary (31Aug98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_pfstream.cxx + * @author cary + * @date 1998-08-31 + */ #include "pfstream.h" #include diff --git a/dtool/src/dconfig/test_searchpath.cxx b/dtool/src/dconfig/test_searchpath.cxx index f4dfa99070..edcb8a13cd 100644 --- a/dtool/src/dconfig/test_searchpath.cxx +++ b/dtool/src/dconfig/test_searchpath.cxx @@ -1,28 +1,27 @@ -// Filename: test_searchpath.cxx -// Created by: cary (01Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_searchpath.cxx + * @author cary + * @date 1998-09-01 + */ #include "dSearchPath.h" -//#include "expand.h" +// #include "expand.h" #include void TestSearch() { std::string line, path; -// path = ".:~ /etc"; +// path = ".:~ etc"; path = ". /etc"; -// path = Expand::Expand(path); +// path = Expand::Expand(path); line = "searchpath.h"; cout << "looking for file '" << line << "' in path '" << path << "': '"; line = DSearchPath::search_path(line, path); diff --git a/dtool/src/dtoolbase/addHash.I b/dtool/src/dtoolbase/addHash.I index 7a7e28570c..ddc1c737fb 100644 --- a/dtool/src/dtoolbase/addHash.I +++ b/dtool/src/dtoolbase/addHash.I @@ -1,45 +1,36 @@ -// Filename: addHash.I -// Created by: drose (01Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file addHash.I + * @author drose + * @date 2006-09-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AddHash::add_hash -// Access: Public, Static -// Description: Adds a linear sequence of uint32 words to the hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear sequence of uint32 words to the hash. + */ INLINE size_t AddHash:: add_hash(size_t start, const PN_uint32 *words, size_t num_words) { return (size_t)hashword(words, num_words, (PN_uint32)start); } -//////////////////////////////////////////////////////////////////// -// Function: AddHash::add_hash -// Access: Public, Static -// Description: Adds a linear sequence of float32 words to the hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear sequence of float32 words to the hash. + */ INLINE size_t AddHash:: add_hash(size_t start, const PN_float32 *floats, size_t num_floats) { return add_hash(start, (const PN_uint32 *)floats, num_floats); } -//////////////////////////////////////////////////////////////////// -// Function: AddHash::add_hash -// Access: Public, Static -// Description: Adds a linear sequence of float64 words to the hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear sequence of float64 words to the hash. + */ INLINE size_t AddHash:: add_hash(size_t start, const PN_float64 *floats, size_t num_floats) { return add_hash(start, (const PN_uint32 *)floats, num_floats * 2); } - diff --git a/dtool/src/dtoolbase/addHash.cxx b/dtool/src/dtoolbase/addHash.cxx index 770cbdf773..fd3717960d 100644 --- a/dtool/src/dtoolbase/addHash.cxx +++ b/dtool/src/dtoolbase/addHash.cxx @@ -1,24 +1,21 @@ -// Filename: addHash.cxx -// Created by: drose (01Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file addHash.cxx + * @author drose + * @date 2006-09-01 + */ #include "addHash.h" -//////////////////////////////////////////////////////////////////// -// Function: AddHash::add_hash -// Access: Public, Static -// Description: Adds a linear sequence of bytes to the hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear sequence of bytes to the hash. + */ size_t AddHash:: add_hash(size_t start, const PN_uint8 *bytes, size_t num_bytes) { size_t num_words = num_bytes >> 2; diff --git a/dtool/src/dtoolbase/addHash.h b/dtool/src/dtoolbase/addHash.h index 64f5c5b7f3..fba194b688 100644 --- a/dtool/src/dtoolbase/addHash.h +++ b/dtool/src/dtoolbase/addHash.h @@ -1,16 +1,15 @@ -// Filename: addHash.h -// Created by: drose (01Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file addHash.h + * @author drose + * @date 2006-09-01 + */ #ifndef ADDHASH_H #define ADDHASH_H @@ -19,13 +18,11 @@ #include "numeric_types.h" #include "lookup3.h" -//////////////////////////////////////////////////////////////////// -// Class : AddHash -// Description : This class is used just as a namespace scope to -// collect together a handful of static functions, which -// are used to wrap calls to Bob Jenkins' public-domain -// hash generation function (defined in lookup3.c). -//////////////////////////////////////////////////////////////////// +/** + * This class is used just as a namespace scope to collect together a handful + * of static functions, which are used to wrap calls to Bob Jenkins' public- + * domain hash generation function (defined in lookup3.c). + */ class EXPCL_DTOOL AddHash { public: INLINE static size_t add_hash(size_t start, const PN_uint32 *words, size_t num_words); diff --git a/dtool/src/dtoolbase/atomicAdjust.h b/dtool/src/dtoolbase/atomicAdjust.h index cbaa2bcf7f..1180529ded 100644 --- a/dtool/src/dtoolbase/atomicAdjust.h +++ b/dtool/src/dtoolbase/atomicAdjust.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjust.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjust.h + * @author drose + * @date 2002-08-09 + */ #ifndef ATOMICADJUST_H #define ATOMICADJUST_H @@ -32,18 +31,17 @@ struct AtomicAdjust { typedef AtomicAdjustDummyImpl AtomicAdjust; #elif (defined(__i386__) || defined(_M_IX86)) && !defined(__APPLE__) -// For an i386 architecture, we'll always use the i386 implementation. -// It should be safe for any OS, and it might be a bit faster than -// any OS-provided calls. +// For an i386 architecture, we'll always use the i386 implementation. It +// should be safe for any OS, and it might be a bit faster than any OS- +// provided calls. #include "atomicAdjustI386Impl.h" typedef AtomicAdjustI386Impl AtomicAdjust; // These symbols are defined if the compare_and_exchange() methods are -// implemented natively, without recourse to external locks. If these -// are not defined, users may elect to implement an operation with -// some other method than compare_and_exchange(), which might be -// faster. +// implemented natively, without recourse to external locks. If these are not +// defined, users may elect to implement an operation with some other method +// than compare_and_exchange(), which might be faster. #define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1 #define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1 diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I index d7b405ae15..a08d6ce130 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.I @@ -1,57 +1,44 @@ -// Filename: atomicAdjustDummyImpl.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustDummyImpl.I + * @author drose + * @date 2002-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable. -//////////////////////////////////////////////////////////////////// +/** + * Atomically increments the indicated variable. + */ ALWAYS_INLINE void AtomicAdjustDummyImpl:: inc(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { ++var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns true if the new value is nonzero, false if it -// is zero. -//////////////////////////////////////////////////////////////////// +/** + * Atomically decrements the indicated variable and returns true if the new + * value is nonzero, false if it is zero. + */ ALWAYS_INLINE bool AtomicAdjustDummyImpl:: dec(TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return (--var) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::add -// Access: Public, Static -// Description: Atomically computes var += delta. It is legal for -// delta to be negative. -//////////////////////////////////////////////////////////////////// +/** + * Atomically computes var += delta. It is legal for delta to be negative. + */ ALWAYS_INLINE void AtomicAdjustDummyImpl:: add(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer delta) { var += delta; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: set(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Integer new_value) { Integer orig_value = var; @@ -59,26 +46,20 @@ set(TVOLATILE AtomicAdjustDummyImpl::Integer &var, AtomicAdjustDummyImpl::Intege return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: get(const TVOLATILE AtomicAdjustDummyImpl::Integer &var) { return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::set_ptr -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: set_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &var, AtomicAdjustDummyImpl::Pointer new_value) { @@ -87,30 +68,24 @@ set_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &var, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::get_ptr -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: get_ptr(const TVOLATILE AtomicAdjustDummyImpl::Pointer &var) { return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::compare_and_exchange -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// If mem is equal to old_value, store new_value in mem. -// In either case, return the original value of mem. -// The caller can test for success by comparing -// return_value == old_value. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * If mem is equal to old_value, store new_value in mem. In either case, + * return the original value of mem. The caller can test for success by + * comparing return_value == old_value. + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Integer AtomicAdjustDummyImpl:: compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, AtomicAdjustDummyImpl::Integer old_value, @@ -122,13 +97,11 @@ compare_and_exchange(TVOLATILE AtomicAdjustDummyImpl::Integer &mem, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustDummyImpl::compare_and_exchange_ptr -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// As above, but works on pointers instead of integers. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * As above, but works on pointers instead of integers. + */ ALWAYS_INLINE AtomicAdjustDummyImpl::Pointer AtomicAdjustDummyImpl:: compare_and_exchange_ptr(TVOLATILE AtomicAdjustDummyImpl::Pointer &mem, AtomicAdjustDummyImpl::Pointer old_value, diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx b/dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx index 5b3f0a831b..aa8fc7d893 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.cxx @@ -1,16 +1,15 @@ -// Filename: atomicAdjustDummyImpl.cxx -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustDummyImpl.cxx + * @author drose + * @date 2002-08-09 + */ #include "selectThreadImpl.h" #include "atomicAdjustDummyImpl.h" diff --git a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h index c77f527dc1..b6e530f395 100644 --- a/dtool/src/dtoolbase/atomicAdjustDummyImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustDummyImpl.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjustDummyImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustDummyImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef ATOMICADJUSTDUMMYIMPL_H #define ATOMICADJUSTDUMMYIMPL_H @@ -20,12 +19,11 @@ #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : AtomicAdjustDummyImpl -// Description : A trivial implementation for atomic adjustments for -// systems that don't require multiprogramming, and -// therefore don't require special atomic operations. -//////////////////////////////////////////////////////////////////// +/** + * A trivial implementation for atomic adjustments for systems that don't + * require multiprogramming, and therefore don't require special atomic + * operations. + */ class EXPCL_DTOOL AtomicAdjustDummyImpl { public: typedef long Integer; diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.I b/dtool/src/dtoolbase/atomicAdjustGccImpl.I index 6831a16a1e..5becaaa4c0 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.I @@ -1,58 +1,45 @@ -// Filename: atomicAdjustGccImpl.I -// Created by: rdb (04Jul14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustGccImpl.I + * @author rdb + * @date 2014-07-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable. -//////////////////////////////////////////////////////////////////// +/** + * Atomically increments the indicated variable. + */ INLINE void AtomicAdjustGccImpl:: inc(TVOLATILE AtomicAdjustGccImpl::Integer &var) { __atomic_fetch_add(&var, 1, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns true if the new value is nonzero, false if it -// is zero. -//////////////////////////////////////////////////////////////////// +/** + * Atomically decrements the indicated variable and returns true if the new + * value is nonzero, false if it is zero. + */ INLINE bool AtomicAdjustGccImpl:: dec(TVOLATILE AtomicAdjustGccImpl::Integer &var) { return (__atomic_sub_fetch(&var, 1, __ATOMIC_SEQ_CST) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::add -// Access: Public, Static -// Description: Atomically computes var += delta. It is legal for -// delta to be negative. -//////////////////////////////////////////////////////////////////// +/** + * Atomically computes var += delta. It is legal for delta to be negative. + */ INLINE void AtomicAdjustGccImpl:: add(TVOLATILE AtomicAdjustGccImpl::Integer &var, AtomicAdjustGccImpl::Integer delta) { __atomic_fetch_add(&var, delta, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustGccImpl::Integer AtomicAdjustGccImpl:: set(TVOLATILE AtomicAdjustGccImpl::Integer &var, AtomicAdjustGccImpl::Integer new_value) { @@ -60,26 +47,20 @@ set(TVOLATILE AtomicAdjustGccImpl::Integer &var, return __atomic_exchange_n(&var, new_value, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustGccImpl::Integer AtomicAdjustGccImpl:: get(const TVOLATILE AtomicAdjustGccImpl::Integer &var) { return __atomic_load_n(&var, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::set_ptr -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustGccImpl::Pointer AtomicAdjustGccImpl:: set_ptr(TVOLATILE AtomicAdjustGccImpl::Pointer &var, AtomicAdjustGccImpl::Pointer new_value) { @@ -87,39 +68,30 @@ set_ptr(TVOLATILE AtomicAdjustGccImpl::Pointer &var, return __atomic_exchange_n(&var, new_value, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::get_ptr -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustGccImpl::Pointer AtomicAdjustGccImpl:: get_ptr(const TVOLATILE AtomicAdjustGccImpl::Pointer &var) { return __atomic_load_n(&var, __ATOMIC_SEQ_CST); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::compare_and_exchange -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// If mem is equal to old_value, store new_value in mem. -// In either case, return the original value of mem. -// The caller can test for success by comparing -// return_value == old_value. -// -// The atomic function expressed in pseudo-code: -// -// orig_value = mem; -// if (mem == old_value) { -// mem = new_value; -// } -// return orig_value; -// -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * If mem is equal to old_value, store new_value in mem. In either case, + * return the original value of mem. The caller can test for success by + * comparing return_value == old_value. + * + * The atomic function expressed in pseudo-code: + * + * orig_value = mem; if (mem == old_value) { mem = new_value; } return + * orig_value; + * + */ INLINE AtomicAdjustGccImpl::Integer AtomicAdjustGccImpl:: compare_and_exchange(TVOLATILE AtomicAdjustGccImpl::Integer &mem, AtomicAdjustGccImpl::Integer old_value, @@ -130,13 +102,11 @@ compare_and_exchange(TVOLATILE AtomicAdjustGccImpl::Integer &mem, return old_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustGccImpl::compare_and_exchange_ptr -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// As above, but works on pointers instead of integers. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * As above, but works on pointers instead of integers. + */ INLINE AtomicAdjustGccImpl::Pointer AtomicAdjustGccImpl:: compare_and_exchange_ptr(TVOLATILE AtomicAdjustGccImpl::Pointer &mem, AtomicAdjustGccImpl::Pointer old_value, diff --git a/dtool/src/dtoolbase/atomicAdjustGccImpl.h b/dtool/src/dtoolbase/atomicAdjustGccImpl.h index ec3050f14c..1012a52721 100644 --- a/dtool/src/dtoolbase/atomicAdjustGccImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustGccImpl.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjustGccImpl.h -// Created by: rdb (04Jul14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustGccImpl.h + * @author rdb + * @date 2014-07-04 + */ #ifndef ATOMICADJUSTGCCIMPL_H #define ATOMICADJUSTGCCIMPL_H @@ -20,10 +19,9 @@ #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3)) -//////////////////////////////////////////////////////////////////// -// Class : AtomicAdjustGccImpl -// Description : Uses GCC built-ins to implement atomic adjustments. -//////////////////////////////////////////////////////////////////// +/** + * Uses GCC built-ins to implement atomic adjustments. + */ class EXPCL_DTOOL AtomicAdjustGccImpl { public: #if __GCC_ATOMIC_LONG_LOCK_FREE >= __GCC_ATOMIC_INT_LOCK_FREE diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.I b/dtool/src/dtoolbase/atomicAdjustI386Impl.I index 4c95b9bb3a..3841479b28 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.I @@ -1,23 +1,19 @@ -// Filename: atomicAdjustI386Impl.I -// Created by: drose (01Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustI386Impl.I + * @author drose + * @date 2006-04-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable. -//////////////////////////////////////////////////////////////////// +/** + * Atomically increments the indicated variable. + */ INLINE void AtomicAdjustI386Impl:: inc(TVOLATILE AtomicAdjustI386Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -36,13 +32,10 @@ inc(TVOLATILE AtomicAdjustI386Impl::Integer &var) { #endif // __EDG__ } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns true if the new value is nonzero, false if it -// is zero. -//////////////////////////////////////////////////////////////////// +/** + * Atomically decrements the indicated variable and returns true if the new + * value is nonzero, false if it is zero. + */ INLINE bool AtomicAdjustI386Impl:: dec(TVOLATILE AtomicAdjustI386Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -64,12 +57,9 @@ dec(TVOLATILE AtomicAdjustI386Impl::Integer &var) { return (c == 0); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::add -// Access: Public, Static -// Description: Atomically computes var += delta. It is legal for -// delta to be negative. -//////////////////////////////////////////////////////////////////// +/** + * Atomically computes var += delta. It is legal for delta to be negative. + */ INLINE void AtomicAdjustI386Impl:: add(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer delta) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -79,14 +69,11 @@ add(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer } } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: -set(TVOLATILE AtomicAdjustI386Impl::Integer &var, +set(TVOLATILE AtomicAdjustI386Impl::Integer &var, AtomicAdjustI386Impl::Integer new_value) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); Integer orig_value = var; @@ -94,29 +81,23 @@ set(TVOLATILE AtomicAdjustI386Impl::Integer &var, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: get(const TVOLATILE AtomicAdjustI386Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::set_ptr -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustI386Impl::Pointer AtomicAdjustI386Impl:: -set_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &var, +set_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &var, AtomicAdjustI386Impl::Pointer new_value) { assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0); Pointer orig_value = var; @@ -124,42 +105,33 @@ set_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &var, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::get_ptr -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustI386Impl::Pointer AtomicAdjustI386Impl:: get_ptr(const TVOLATILE AtomicAdjustI386Impl::Pointer &var) { assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0); return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::compare_and_exchange -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// If mem is equal to old_value, store new_value in mem. -// In either case, return the original value of mem. -// The caller can test for success by comparing -// return_value == old_value. -// -// The atomic function expressed in pseudo-code: -// -// orig_value = mem; -// if (mem == old_value) { -// mem = new_value; -// } -// return orig_value; -// -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * If mem is equal to old_value, store new_value in mem. In either case, + * return the original value of mem. The caller can test for success by + * comparing return_value == old_value. + * + * The atomic function expressed in pseudo-code: + * + * orig_value = mem; if (mem == old_value) { mem = new_value; } return + * orig_value; + * + */ INLINE AtomicAdjustI386Impl::Integer AtomicAdjustI386Impl:: -compare_and_exchange(TVOLATILE AtomicAdjustI386Impl::Integer &mem, +compare_and_exchange(TVOLATILE AtomicAdjustI386Impl::Integer &mem, AtomicAdjustI386Impl::Integer old_value, AtomicAdjustI386Impl::Integer new_value) { assert((((size_t)&mem) & (sizeof(Integer) - 1)) == 0); @@ -184,15 +156,13 @@ compare_and_exchange(TVOLATILE AtomicAdjustI386Impl::Integer &mem, return prev; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustI386Impl::compare_and_exchange_ptr -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// As above, but works on pointers instead of integers. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * As above, but works on pointers instead of integers. + */ INLINE AtomicAdjustI386Impl::Pointer AtomicAdjustI386Impl:: -compare_and_exchange_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &mem, +compare_and_exchange_ptr(TVOLATILE AtomicAdjustI386Impl::Pointer &mem, AtomicAdjustI386Impl::Pointer old_value, AtomicAdjustI386Impl::Pointer new_value) { assert((((size_t)&mem) & (sizeof(Pointer) - 1)) == 0); diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx b/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx index ee0cccd6fd..01fb308022 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.cxx @@ -1,15 +1,14 @@ -// Filename: atomicAdjustI386Impl.cxx -// Created by: drose (28Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustI386Impl.cxx + * @author drose + * @date 2006-03-28 + */ #include "atomicAdjustI386Impl.h" diff --git a/dtool/src/dtoolbase/atomicAdjustI386Impl.h b/dtool/src/dtoolbase/atomicAdjustI386Impl.h index e234a47e31..c9db9a806d 100644 --- a/dtool/src/dtoolbase/atomicAdjustI386Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustI386Impl.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjustI386Impl.h -// Created by: drose (01Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustI386Impl.h + * @author drose + * @date 2006-04-01 + */ #ifndef ATOMICADJUSTI386IMPL_H #define ATOMICADJUSTI386IMPL_H @@ -22,13 +21,11 @@ #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : AtomicAdjustI386Impl -// Description : Uses assembly-language calls to atomically increment -// and decrement. Although this class is named i386, it -// actually uses instructions that are specific to 486 -// and higher. -//////////////////////////////////////////////////////////////////// +/** + * Uses assembly-language calls to atomically increment and decrement. + * Although this class is named i386, it actually uses instructions that are + * specific to 486 and higher. + */ class EXPCL_DTOOL AtomicAdjustI386Impl { public: typedef ALIGN_4BYTE PN_int32 Integer; @@ -44,11 +41,11 @@ public: INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); - INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, Integer old_value, Integer new_value); - - INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, + + INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, Pointer old_value, Pointer new_value); }; diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I index c104a43666..ef3d43f053 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.I +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.I @@ -1,23 +1,19 @@ -// Filename: atomicAdjustPosixImpl.I -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustPosixImpl.I + * @author drose + * @date 2006-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable. -//////////////////////////////////////////////////////////////////// +/** + * Atomically increments the indicated variable. + */ INLINE void AtomicAdjustPosixImpl:: inc(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); @@ -25,13 +21,10 @@ inc(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_unlock(&_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns true if the new value is nonzero, false if it -// is zero. -//////////////////////////////////////////////////////////////////// +/** + * Atomically decrements the indicated variable and returns true if the new + * value is nonzero, false if it is zero. + */ INLINE bool AtomicAdjustPosixImpl:: dec(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); @@ -40,28 +33,22 @@ dec(TVOLATILE AtomicAdjustPosixImpl::Integer &var) { return (result != 0); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::add -// Access: Public, Static -// Description: Atomically computes var += delta. It is legal for -// delta to be negative. -//////////////////////////////////////////////////////////////////// +/** + * Atomically computes var += delta. It is legal for delta to be negative. + */ INLINE void AtomicAdjustPosixImpl:: -add(TVOLATILE AtomicAdjustPosixImpl::Integer &var, +add(TVOLATILE AtomicAdjustPosixImpl::Integer &var, AtomicAdjustPosixImpl::Integer delta) { pthread_mutex_lock(&_mutex); var += delta; pthread_mutex_unlock(&_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: -set(TVOLATILE AtomicAdjustPosixImpl::Integer &var, +set(TVOLATILE AtomicAdjustPosixImpl::Integer &var, AtomicAdjustPosixImpl::Integer new_value) { pthread_mutex_lock(&_mutex); Integer orig_value = var; @@ -70,15 +57,12 @@ set(TVOLATILE AtomicAdjustPosixImpl::Integer &var, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: get(const TVOLATILE AtomicAdjustPosixImpl::Integer &var) { pthread_mutex_lock(&_mutex); @@ -87,14 +71,11 @@ get(const TVOLATILE AtomicAdjustPosixImpl::Integer &var) { return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::set_ptr -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ INLINE AtomicAdjustPosixImpl::Pointer AtomicAdjustPosixImpl:: -set_ptr(TVOLATILE AtomicAdjustPosixImpl::Pointer &var, +set_ptr(TVOLATILE AtomicAdjustPosixImpl::Pointer &var, AtomicAdjustPosixImpl::Pointer new_value) { pthread_mutex_lock(&_mutex); Pointer orig_value = var; @@ -103,15 +84,12 @@ set_ptr(TVOLATILE AtomicAdjustPosixImpl::Pointer &var, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::get_ptr -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ INLINE AtomicAdjustPosixImpl::Pointer AtomicAdjustPosixImpl:: get_ptr(const TVOLATILE AtomicAdjustPosixImpl::Pointer &var) { pthread_mutex_lock(&_mutex); @@ -120,27 +98,21 @@ get_ptr(const TVOLATILE AtomicAdjustPosixImpl::Pointer &var) { return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::compare_and_exchange -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// If mem is equal to old_value, store new_value in mem. -// In either case, return the original value of mem. -// The caller can test for success by comparing -// return_value == old_value. -// -// The atomic function expressed in pseudo-code: -// -// orig_value = mem; -// if (mem == old_value) { -// mem = new_value; -// } -// return orig_value; -// -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * If mem is equal to old_value, store new_value in mem. In either case, + * return the original value of mem. The caller can test for success by + * comparing return_value == old_value. + * + * The atomic function expressed in pseudo-code: + * + * orig_value = mem; if (mem == old_value) { mem = new_value; } return + * orig_value; + * + */ INLINE AtomicAdjustPosixImpl::Integer AtomicAdjustPosixImpl:: -compare_and_exchange(TVOLATILE AtomicAdjustPosixImpl::Integer &mem, +compare_and_exchange(TVOLATILE AtomicAdjustPosixImpl::Integer &mem, AtomicAdjustPosixImpl::Integer old_value, AtomicAdjustPosixImpl::Integer new_value) { pthread_mutex_lock(&_mutex); @@ -152,15 +124,13 @@ compare_and_exchange(TVOLATILE AtomicAdjustPosixImpl::Integer &mem, return orig_value; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustPosixImpl::compare_and_exchange_ptr -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// As above, but works on pointers instead of integers. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * As above, but works on pointers instead of integers. + */ INLINE AtomicAdjustPosixImpl::Pointer AtomicAdjustPosixImpl:: -compare_and_exchange_ptr(TVOLATILE AtomicAdjustPosixImpl::Pointer &mem, +compare_and_exchange_ptr(TVOLATILE AtomicAdjustPosixImpl::Pointer &mem, AtomicAdjustPosixImpl::Pointer old_value, AtomicAdjustPosixImpl::Pointer new_value) { pthread_mutex_lock(&_mutex); diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx b/dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx index f58719d686..abfe9ab1a3 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.cxx @@ -1,16 +1,15 @@ -// Filename: atomicAdjustPosixImpl.cxx -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustPosixImpl.cxx + * @author drose + * @date 2006-02-10 + */ #include "selectThreadImpl.h" diff --git a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h index 157f6eeb72..ff5a55fb60 100644 --- a/dtool/src/dtoolbase/atomicAdjustPosixImpl.h +++ b/dtool/src/dtoolbase/atomicAdjustPosixImpl.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjustPosixImpl.h -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustPosixImpl.h + * @author drose + * @date 2006-02-10 + */ #ifndef ATOMICADJUSTPOSIXIMPL_H #define ATOMICADJUSTPOSIXIMPL_H @@ -24,14 +23,13 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : AtomicAdjustPosixImpl -// Description : Uses POSIX to implement atomic adjustments. -//////////////////////////////////////////////////////////////////// +/** + * Uses POSIX to implement atomic adjustments. + */ class EXPCL_DTOOL AtomicAdjustPosixImpl { public: - // In Posix, "long" is generally the native word size (32- or - // 64-bit), which is what we'd prefer. + // In Posix, "long" is generally the native word size (32- or 64-bit), which + // is what we'd prefer. typedef long Integer; typedef void *Pointer; @@ -44,11 +42,11 @@ public: INLINE static Pointer set_ptr(TVOLATILE Pointer &var, Pointer new_value); INLINE static Pointer get_ptr(const TVOLATILE Pointer &var); - INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, + INLINE static Integer compare_and_exchange(TVOLATILE Integer &mem, Integer old_value, Integer new_value); - - INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, + + INLINE static Pointer compare_and_exchange_ptr(TVOLATILE Pointer &mem, Pointer old_value, Pointer new_value); diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I index f04dfbe8fa..a0e213c638 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.I +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.I @@ -1,23 +1,19 @@ -// Filename: atomicAdjustWin32Impl.I -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustWin32Impl.I + * @author drose + * @date 2006-02-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::inc -// Access: Public, Static -// Description: Atomically increments the indicated variable. -//////////////////////////////////////////////////////////////////// +/** + * Atomically increments the indicated variable. + */ ALWAYS_INLINE void AtomicAdjustWin32Impl:: inc(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -28,13 +24,10 @@ inc(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { #endif // _WIN64 } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::dec -// Access: Public, Static -// Description: Atomically decrements the indicated variable and -// returns true if the new value is nonzero, false if it -// is zero. -//////////////////////////////////////////////////////////////////// +/** + * Atomically decrements the indicated variable and returns true if the new + * value is nonzero, false if it is zero. + */ ALWAYS_INLINE bool AtomicAdjustWin32Impl:: dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -45,12 +38,9 @@ dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) { #endif // _WIN64 } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::add -// Access: Public, Static -// Description: Atomically computes var += delta. It is legal for -// delta to be negative. -//////////////////////////////////////////////////////////////////// +/** + * Atomically computes var += delta. It is legal for delta to be negative. + */ INLINE void AtomicAdjustWin32Impl:: add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer delta) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); @@ -64,14 +54,11 @@ add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Intege #endif // _WIN64 } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::set -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ ALWAYS_INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: -set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, +set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer new_value) { assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); #ifdef _WIN64 @@ -81,48 +68,38 @@ set(TVOLATILE AtomicAdjustWin32Impl::Integer &var, #endif // _WIN64 } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::get -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ ALWAYS_INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: get(const TVOLATILE AtomicAdjustWin32Impl::Integer &var) { - // On Intel platforms, word-aligned loads are atomic (if performed - // in a single instruction). We can't guarantee the compiler will - // generate a single instruction to load this value, but it - // certainly won't happen if its address isn't word-aligned, so make - // sure that's the case. + // On Intel platforms, word-aligned loads are atomic (if performed in a + // single instruction). We can't guarantee the compiler will generate a + // single instruction to load this value, but it certainly won't happen if + // its address isn't word-aligned, so make sure that's the case. assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0); return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::set_ptr -// Access: Public, Static -// Description: Atomically changes the indicated variable and -// returns the original value. -//////////////////////////////////////////////////////////////////// +/** + * Atomically changes the indicated variable and returns the original value. + */ ALWAYS_INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: -set_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &var, +set_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &var, AtomicAdjustWin32Impl::Pointer new_value) { assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0); return InterlockedExchangePointer(&var, new_value); } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::get_ptr -// Access: Public, Static -// Description: Atomically retrieves the snapshot value of the -// indicated variable. This is the only guaranteed safe -// way to retrieve the value that other threads might be -// asynchronously setting, incrementing, or decrementing -// (via other AtomicAjust methods). -//////////////////////////////////////////////////////////////////// +/** + * Atomically retrieves the snapshot value of the indicated variable. This is + * the only guaranteed safe way to retrieve the value that other threads might + * be asynchronously setting, incrementing, or decrementing (via other + * AtomicAjust methods). + */ ALWAYS_INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: get_ptr(const TVOLATILE AtomicAdjustWin32Impl::Pointer &var) { // As in get(), make sure the address is word-aligned. @@ -130,32 +107,26 @@ get_ptr(const TVOLATILE AtomicAdjustWin32Impl::Pointer &var) { return var; } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::compare_and_exchange -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// If mem is equal to old_value, store new_value in mem. -// In either case, return the original value of mem. -// The caller can test for success by comparing -// return_value == old_value. -// -// The atomic function expressed in pseudo-code: -// -// orig_value = mem; -// if (mem == old_value) { -// mem = new_value; -// } -// return orig_value; -// -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * If mem is equal to old_value, store new_value in mem. In either case, + * return the original value of mem. The caller can test for success by + * comparing return_value == old_value. + * + * The atomic function expressed in pseudo-code: + * + * orig_value = mem; if (mem == old_value) { mem = new_value; } return + * orig_value; + * + */ INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl:: -compare_and_exchange(TVOLATILE AtomicAdjustWin32Impl::Integer &mem, +compare_and_exchange(TVOLATILE AtomicAdjustWin32Impl::Integer &mem, AtomicAdjustWin32Impl::Integer old_value, AtomicAdjustWin32Impl::Integer new_value) { assert((((size_t)&mem) & (sizeof(Integer) - 1)) == 0); - // Note that the AtomicAdjust parameter order is different from - // Windows convention! + // Note that the AtomicAdjust parameter order is different from Windows + // convention! #ifdef _WIN64 return InterlockedCompareExchange64((TVOLATILE LONGLONG *)&mem, new_value, old_value); #else @@ -163,19 +134,17 @@ compare_and_exchange(TVOLATILE AtomicAdjustWin32Impl::Integer &mem, #endif // _WIN64 } -//////////////////////////////////////////////////////////////////// -// Function: AtomicAdjustWin32Impl::compare_and_exchange_ptr -// Access: Public, Static -// Description: Atomic compare and exchange. -// -// As above, but works on pointers instead of integers. -//////////////////////////////////////////////////////////////////// +/** + * Atomic compare and exchange. + * + * As above, but works on pointers instead of integers. + */ INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl:: compare_and_exchange_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &mem, AtomicAdjustWin32Impl::Pointer old_value, AtomicAdjustWin32Impl::Pointer new_value) { assert((((size_t)&mem) & (sizeof(Pointer) - 1)) == 0); - // Note that the AtomicAdjust parameter order is different from - // Windows convention! + // Note that the AtomicAdjust parameter order is different from Windows + // convention! return InterlockedCompareExchangePointer(&mem, new_value, old_value); } diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx b/dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx index 8781593f7b..8128a8d2dd 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.cxx @@ -1,16 +1,15 @@ -// Filename: atomicAdjustWin32Impl.cxx -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustWin32Impl.cxx + * @author drose + * @date 2006-02-07 + */ #include "selectThreadImpl.h" diff --git a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h index 2018560577..e249ce6448 100644 --- a/dtool/src/dtoolbase/atomicAdjustWin32Impl.h +++ b/dtool/src/dtoolbase/atomicAdjustWin32Impl.h @@ -1,16 +1,15 @@ -// Filename: atomicAdjustWin32Impl.h -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file atomicAdjustWin32Impl.h + * @author drose + * @date 2006-02-07 + */ #ifndef ATOMICADJUSTWIN32IMPL_H #define ATOMICADJUSTWIN32IMPL_H @@ -27,11 +26,9 @@ #endif #include -//////////////////////////////////////////////////////////////////// -// Class : AtomicAdjustWin32Impl -// Description : Uses Windows native calls to implement atomic -// adjustments. -//////////////////////////////////////////////////////////////////// +/** + * Uses Windows native calls to implement atomic adjustments. + */ class EXPCL_DTOOL AtomicAdjustWin32Impl { public: #ifdef _WIN64 diff --git a/dtool/src/dtoolbase/cmath.I b/dtool/src/dtoolbase/cmath.I index 6e8ed6e618..d353a99ce4 100644 --- a/dtool/src/dtoolbase/cmath.I +++ b/dtool/src/dtoolbase/cmath.I @@ -1,16 +1,15 @@ -// Filename: cmath.I -// Created by: drose (19May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cmath.I + * @author drose + * @date 2000-05-19 + */ #ifdef __INTEL_COMPILER // see float.h @@ -18,50 +17,45 @@ #define FPU_CONTROLWORD_NEW_SETTING _CW_DEFAULT #endif -//////////////////////////////////////////////////////////////////// -// Function: csqrt -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float csqrt(float v) { return sqrtf(v); } -//////////////////////////////////////////////////////////////////// -// Function: csin -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float csin(float v) { return sinf(v); } -//////////////////////////////////////////////////////////////////// -// Function: ccos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float ccos(float v) { return cosf(v); } -//////////////////////////////////////////////////////////////////// -// Function: ctan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float ctan(float v) { return tanf(v); } -//////////////////////////////////////////////////////////////////// -// Function: csincos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void csincos(float v, float *sin_result, float *cos_result) { // MS VC defines _M_IX86 for x86. gcc should define _X86_ #if defined(_M_IX86) || defined(_X86_) - //#define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb + // #define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb __asm { mov eax, sin_result mov edx, cos_result @@ -76,10 +70,9 @@ csincos(float v, float *sin_result, float *cos_result) { #endif //!_X86_ } -//////////////////////////////////////////////////////////////////// -// Function: csin_over_x -// Description: Computes sin(x) / x, well-behaved as x approaches 0. -//////////////////////////////////////////////////////////////////// +/** + * Computes sin(x) / x, well-behaved as x approaches 0. + */ INLINE float csin_over_x(float v) { if (1.0f + v * v == 1.0f) { @@ -89,80 +82,72 @@ csin_over_x(float v) { } } -//////////////////////////////////////////////////////////////////// -// Function: cabs -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float cabs(float v) { return fabs(v); } -//////////////////////////////////////////////////////////////////// -// Function: catan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float catan(float v) { return atanf(v); } -//////////////////////////////////////////////////////////////////// -// Function: catan2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float catan2(float y, float x) { return atan2f(y, x); } -//////////////////////////////////////////////////////////////////// -// Function: casin -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float casin(float v) { return asinf(v); } -//////////////////////////////////////////////////////////////////// -// Function: cacos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float cacos(float v) { return acosf(v); } -//////////////////////////////////////////////////////////////////// -// Function: cmod -// Description: This is similar to fmod(), but it behaves properly -// when x is negative: that is, it always returns a -// value in the range [0, y), assuming y is positive. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to fmod(), but it behaves properly when x is negative: that + * is, it always returns a value in the range [0, y), assuming y is positive. + */ INLINE float cmod(float x, float y) { return x - floor(x / y) * y; } -//////////////////////////////////////////////////////////////////// -// Function: cpow -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float cpow(float x, float y) { return powf(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: cfloor -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double cfloor(double f) { #ifdef __INTEL_COMPILER - // intel floor doesnt work right if fpu mode is not double, so make double-prec mode is on + // intel floor doesnt work right if fpu mode is not double, so make + // double-prec mode is on unsigned int saved_fpu_control_word=_controlfp(0x0,0x0); _controlfp(FPU_CONTROLWORD_NEW_SETTING,FPU_CONTROLWORD_WRITEMASK); double retval=floor(f); @@ -173,14 +158,14 @@ cfloor(double f) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: cceil -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double cceil(double f) { #ifdef __INTEL_COMPILER - // intel ceil doesnt work right if fpu mode is not double, so make double-prec mode is on + // intel ceil doesnt work right if fpu mode is not double, so make double- + // prec mode is on unsigned int saved_fpu_control_word=_controlfp(0x0,0x0); _controlfp(FPU_CONTROLWORD_NEW_SETTING,FPU_CONTROLWORD_WRITEMASK); double retval=ceil(f); @@ -191,59 +176,53 @@ cceil(double f) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: cfrac -// Description: Returns the fractional component of f: f - cfloor(f). -//////////////////////////////////////////////////////////////////// +/** + * Returns the fractional component of f: f - cfloor(f). + */ INLINE double cfrac(double f) { return f - cfloor(f); } -//////////////////////////////////////////////////////////////////// -// Function: csqrt -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double csqrt(double v) { return sqrt(v); } -//////////////////////////////////////////////////////////////////// -// Function: csin -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double csin(double v) { return sin(v); } -//////////////////////////////////////////////////////////////////// -// Function: ccos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double ccos(double v) { return cos(v); } -//////////////////////////////////////////////////////////////////// -// Function: ctan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double ctan(double v) { return tan(v); } -//////////////////////////////////////////////////////////////////// -// Function: csincos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void csincos(double v, double *sin_result, double *cos_result) { #if defined(_M_IX86) || defined(_X86_) - //#define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb + // #define fsincos_opcode __asm _emit 0xd9 __asm _emit 0xfb __asm { mov eax, sin_result mov edx, cos_result @@ -258,10 +237,9 @@ csincos(double v, double *sin_result, double *cos_result) { #endif //!_X86_ } -//////////////////////////////////////////////////////////////////// -// Function: csin_over_x -// Description: Computes sin(x) / x, well-behaved as x approaches 0. -//////////////////////////////////////////////////////////////////// +/** + * Computes sin(x) / x, well-behaved as x approaches 0. + */ INLINE double csin_over_x(double v) { if (1.0 + v * v == 1.0) { @@ -271,75 +249,66 @@ csin_over_x(double v) { } } -//////////////////////////////////////////////////////////////////// -// Function: cabs -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double cabs(double v) { return fabs(v); } -//////////////////////////////////////////////////////////////////// -// Function: catan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double catan(double v) { return atan(v); } -//////////////////////////////////////////////////////////////////// -// Function: catan2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double catan2(double y, double x) { return atan2(y, x); } -//////////////////////////////////////////////////////////////////// -// Function: casin -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double casin(double v) { return asin(v); } -//////////////////////////////////////////////////////////////////// -// Function: cacos -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double cacos(double v) { return acos(v); } -//////////////////////////////////////////////////////////////////// -// Function: cmod -// Description: This is similar to fmod(), but it behaves properly -// when x is negative: that is, it always returns a -// value in the range [0, y), assuming y is positive. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to fmod(), but it behaves properly when x is negative: that + * is, it always returns a value in the range [0, y), assuming y is positive. + */ INLINE double cmod(double x, double y) { return x - cfloor(x / y) * y; } -//////////////////////////////////////////////////////////////////// -// Function: cpow -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double cpow(double x, double y) { return pow(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: cpow -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int cpow(int x, int y) { int result = 1; @@ -358,10 +327,9 @@ cpow(int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: cnan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool cnan(float v) { #if __FINITE_MATH_ONLY__ @@ -375,10 +343,9 @@ cnan(float v) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: cnan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool cnan(double v) { #if __FINITE_MATH_ONLY__ @@ -392,10 +359,9 @@ cnan(double v) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: cinf -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool cinf(float v) { #if __FINITE_MATH_ONLY__ @@ -409,10 +375,9 @@ cinf(float v) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: cinf -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool cinf(double v) { #if __FINITE_MATH_ONLY__ @@ -426,52 +391,45 @@ cinf(double v) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: make_nan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float make_nan(float) { return std::numeric_limits::quiet_NaN(); } -//////////////////////////////////////////////////////////////////// -// Function: make_nan -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double make_nan(double) { return std::numeric_limits::quiet_NaN(); } -//////////////////////////////////////////////////////////////////// -// Function: make_inf -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE float make_inf(float) { return std::numeric_limits::infinity(); } -//////////////////////////////////////////////////////////////////// -// Function: make_inf -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double make_inf(double) { return std::numeric_limits::infinity(); } -//////////////////////////////////////////////////////////////////// -// Function: cmod -// Description: This is similar to fmod(), but it behaves properly -// when x is negative: that is, it always returns a -// value in the range [0, y), assuming y is positive. -// -// This integer-valued function is provided since the -// built-in modulo operator % does not work properly for -// negative x. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to fmod(), but it behaves properly when x is negative: that + * is, it always returns a value in the range [0, y), assuming y is positive. + * + * This integer-valued function is provided since the built-in modulo operator + * % does not work properly for negative x. + */ INLINE int cmod(int x, int y) { if (x < 0) { diff --git a/dtool/src/dtoolbase/cmath.h b/dtool/src/dtoolbase/cmath.h index 42d83f77d5..a72ad36fcf 100644 --- a/dtool/src/dtoolbase/cmath.h +++ b/dtool/src/dtoolbase/cmath.h @@ -1,25 +1,23 @@ -// Filename: cmath.h -// Created by: drose (19May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cmath.h + * @author drose + * @date 2000-05-19 + */ #ifndef CMATH_H #define CMATH_H -// This file declares a number of C++-style overloading wrappers -// around the standard math library functions, so we can use -// overloading to differentiate on type instead of having to know -// explicitly whether we need to call, for instance, sqrtf() or -// sqrt(). +// This file declares a number of C++-style overloading wrappers around the +// standard math library functions, so we can use overloading to differentiate +// on type instead of having to know explicitly whether we need to call, for +// instance, sqrtf() or sqrt(). #include "dtoolbase.h" @@ -59,8 +57,8 @@ INLINE double cpow(double x, double y); INLINE int cpow(int x, int y); -// Returns true if the number is NaN, false if it's a genuine number -// or infinity. +// Returns true if the number is NaN, false if it's a genuine number or +// infinity. INLINE bool cnan(float v); INLINE bool cnan(double v); diff --git a/dtool/src/dtoolbase/deletedBufferChain.I b/dtool/src/dtoolbase/deletedBufferChain.I index d9514929c5..7f6a003f64 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.I +++ b/dtool/src/dtoolbase/deletedBufferChain.I @@ -1,28 +1,23 @@ -// Filename: deletedBufferChain.I -// Created by: drose (20Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deletedBufferChain.I + * @author drose + * @date 2007-07-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::validate -// Access: Public -// Description: Returns true if the pointer is valid, false if it has -// been deleted or if it was never a valid pointer. -// -// This is only meaningful in debug mode, where -// USE_DELETEDCHAINFLAG is defined. If not, this -// trivially returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pointer is valid, false if it has been deleted or if it + * was never a valid pointer. + * + * This is only meaningful in debug mode, where USE_DELETEDCHAINFLAG is + * defined. If not, this trivially returns true. + */ INLINE bool DeletedBufferChain:: validate(void *ptr) { TAU_PROFILE("bool DeletedBufferChain::validate(void *)", " ", TAU_USER); @@ -38,43 +33,36 @@ validate(void *ptr) { #endif // USE_DELETEDCHAINFLAG } -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::get_buffer_size -// Access: Public -// Description: Returns the size of the buffer that is actually -// returned at each request. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the buffer that is actually returned at each request. + */ INLINE size_t DeletedBufferChain:: get_buffer_size() const { return _buffer_size; } -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::node_to_buffer -// Access: Private, Static -// Description: Casts an ObjectNode* to a void* buffer. -//////////////////////////////////////////////////////////////////// +/** + * Casts an ObjectNode* to a void* buffer. + */ INLINE void *DeletedBufferChain:: node_to_buffer(DeletedBufferChain::ObjectNode *node) { #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN) - // In development mode, we increment the pointer so that the - // returned data does not overlap our _flag member. + // In development mode, we increment the pointer so that the returned data + // does not overlap our _flag member. return (void *)(((char *)node) + flag_reserved_bytes); #else return (void *)node; #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::buffer_to_node -// Access: Private, Static -// Description: Casts a void* buffer to an ObjectNode* . -//////////////////////////////////////////////////////////////////// +/** + * Casts a void* buffer to an ObjectNode* . + */ INLINE DeletedBufferChain::ObjectNode *DeletedBufferChain:: buffer_to_node(void *ptr) { #if defined(USE_DELETEDCHAINFLAG) && defined(USE_DELETED_CHAIN) - // In development mode, we decrement the pointer to undo the - // increment we did above. + // In development mode, we decrement the pointer to undo the increment we + // did above. return (ObjectNode *)(((char *)ptr) - flag_reserved_bytes); #else return (ObjectNode *)ptr; diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index d02f10ead0..89f056219c 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -1,47 +1,41 @@ -// Filename: deletedBufferChain.cxx -// Created by: drose (20Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deletedBufferChain.cxx + * @author drose + * @date 2007-07-20 + */ #include "deletedBufferChain.h" #include "memoryHook.h" -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::Constructor -// Access: Protected -// Description: Use the global MemoryHook to get a new -// DeletedBufferChain of the appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Use the global MemoryHook to get a new DeletedBufferChain of the + * appropriate size. + */ DeletedBufferChain:: DeletedBufferChain(size_t buffer_size) { _deleted_chain = NULL; _buffer_size = buffer_size; - // We must allocate at least this much space for bookkeeping - // reasons. + // We must allocate at least this much space for bookkeeping reasons. _buffer_size = max(_buffer_size, sizeof(ObjectNode)); } -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::allocate -// Access: Public -// Description: Allocates the memory for a new buffer of the -// indicated size (which must be no greater than the -// fixed size associated with the DeletedBufferChain). -//////////////////////////////////////////////////////////////////// +/** + * Allocates the memory for a new buffer of the indicated size (which must be + * no greater than the fixed size associated with the DeletedBufferChain). + */ void *DeletedBufferChain:: allocate(size_t size, TypeHandle type_handle) { #ifdef USE_DELETED_CHAIN - //TAU_PROFILE("void *DeletedBufferChain::allocate(size_t, TypeHandle)", " ", TAU_USER); + // TAU_PROFILE("void *DeletedBufferChain::allocate(size_t, TypeHandle)", " + // ", TAU_USER); assert(size <= _buffer_size); // Determine how much space to allocate. @@ -63,7 +57,8 @@ allocate(size_t size, TypeHandle type_handle) { void *ptr = node_to_buffer(obj); #ifdef DO_MEMORY_USAGE - // type_handle.dec_memory_usage(TypeHandle::MC_deleted_chain_inactive, alloc_size); + // type_handle.dec_memory_usage(TypeHandle::MC_deleted_chain_inactive, + // alloc_size); type_handle.inc_memory_usage(TypeHandle::MC_deleted_chain_active, alloc_size); #endif // DO_MEMORY_USAGE @@ -71,8 +66,8 @@ allocate(size_t size, TypeHandle type_handle) { } _lock.release(); - // If we get here, the deleted_chain is empty; we have to allocate a - // new object from the system pool. + // If we get here, the deleted_chain is empty; we have to allocate a new + // object from the system pool. obj = (ObjectNode *)NeverFreeMemory::alloc(alloc_size); @@ -93,23 +88,21 @@ allocate(size_t size, TypeHandle type_handle) { #endif // USE_DELETED_CHAIN } -//////////////////////////////////////////////////////////////////// -// Function: DeletedBufferChain::deallocate -// Access: Public -// Description: Frees the memory for a buffer previously allocated -// via allocate(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the memory for a buffer previously allocated via allocate(). + */ void DeletedBufferChain:: deallocate(void *ptr, TypeHandle type_handle) { #ifdef USE_DELETED_CHAIN - //TAU_PROFILE("void DeletedBufferChain::deallocate(void *, TypeHandle)", " ", TAU_USER); + // TAU_PROFILE("void DeletedBufferChain::deallocate(void *, TypeHandle)", " + // ", TAU_USER); assert(ptr != (void *)NULL); #ifdef DO_MEMORY_USAGE type_handle.dec_memory_usage(TypeHandle::MC_deleted_chain_active, _buffer_size + flag_reserved_bytes); - // type_handle.inc_memory_usage(TypeHandle::MC_deleted_chain_inactive, - // _buffer_size + flag_reserved_bytes); + // type_handle.inc_memory_usage(TypeHandle::MC_deleted_chain_inactive, + // _buffer_size + flag_reserved_bytes); #endif // DO_MEMORY_USAGE @@ -121,8 +114,8 @@ deallocate(void *ptr, TypeHandle type_handle) { // If this assertion is triggered, you double-deleted an object. assert(orig_flag != (AtomicAdjust::Integer)DCF_deleted); - // If this assertion is triggered, you tried to delete an object - // that was never allocated, or you have heap corruption. + // If this assertion is triggered, you tried to delete an object that was + // never allocated, or you have heap corruption. assert(orig_flag == (AtomicAdjust::Integer)DCF_alive); #endif // USE_DELETEDCHAINFLAG diff --git a/dtool/src/dtoolbase/deletedBufferChain.h b/dtool/src/dtoolbase/deletedBufferChain.h index 301ee5d297..6df4583ee8 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.h +++ b/dtool/src/dtoolbase/deletedBufferChain.h @@ -1,16 +1,15 @@ -// Filename: deletedBufferChain.h -// Created by: drose (20Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deletedBufferChain.h + * @author drose + * @date 2007-07-20 + */ #ifndef DELETEDBUFFERCHAIN_H #define DELETEDBUFFERCHAIN_H @@ -24,17 +23,16 @@ #include // Though it's tempting, it doesn't seem to be possible to implement -// DeletedBufferChain via the atomic exchange operation. -// Specifically, a pointer may be removed from the head of the chain, -// then the same pointer reinserted in the chain, while another thread -// is waiting; and that thread will not detect the change. So -// instead, we always use a mutex. +// DeletedBufferChain via the atomic exchange operation. Specifically, a +// pointer may be removed from the head of the chain, then the same pointer +// reinserted in the chain, while another thread is waiting; and that thread +// will not detect the change. So instead, we always use a mutex. #ifndef NDEBUG -// In development mode, we define USE_DELETEDCHAINFLAG, which -// triggers the piggyback of an additional word of data on every -// allocated block, so we can ensure that an object is not -// double-deleted and that the deleted chain remains intact. +// In development mode, we define USE_DELETEDCHAINFLAG, which triggers the +// piggyback of an additional word of data on every allocated block, so we can +// ensure that an object is not double-deleted and that the deleted chain +// remains intact. #define USE_DELETEDCHAINFLAG 1 #endif // NDEBUG @@ -45,23 +43,18 @@ enum DeletedChainFlag { }; #endif -//////////////////////////////////////////////////////////////////// -// Class : DeletedBufferChain -// Description : This template class can be used to provide faster -// allocation/deallocation for many Panda objects. It -// works by maintaining a linked list of deleted buffers -// that are all of the same size; when a new object is -// allocated that matches that size, the same space is -// just reused. -// -// This class manages untyped buffers of a fixed size. -// It can be used directly; or it also serves as a -// backbone for DeletedChain, which is a template class -// that manages object allocations. -// -// Use MemoryHook to get a new DeletedBufferChain of a -// particular size. -//////////////////////////////////////////////////////////////////// +/** + * This template class can be used to provide faster allocation/deallocation + * for many Panda objects. It works by maintaining a linked list of deleted + * buffers that are all of the same size; when a new object is allocated that + * matches that size, the same space is just reused. + * + * This class manages untyped buffers of a fixed size. It can be used + * directly; or it also serves as a backbone for DeletedChain, which is a + * template class that manages object allocations. + * + * Use MemoryHook to get a new DeletedBufferChain of a particular size. + */ class EXPCL_DTOOL DeletedBufferChain { protected: DeletedBufferChain(size_t buffer_size); @@ -77,17 +70,16 @@ private: class ObjectNode { public: #ifdef USE_DELETEDCHAINFLAG - // In development mode, we piggyback this extra data. This is - // maintained out-of-band from the actual pointer returned, so we - // can safely use this flag to indicate the difference between - // allocated and freed pointers. + // In development mode, we piggyback this extra data. This is maintained + // out-of-band from the actual pointer returned, so we can safely use this + // flag to indicate the difference between allocated and freed pointers. TVOLATILE AtomicAdjust::Integer _flag; #endif - // This pointer sits within the buffer, in the same space - // referenced by the actual pointer returned (unlike _flag, - // above). It's only used when the buffer is deleted, so there's - // no harm in sharing space with the undeleted buffer. + // This pointer sits within the buffer, in the same space referenced by + // the actual pointer returned (unlike _flag, above). It's only used when + // the buffer is deleted, so there's no harm in sharing space with the + // undeleted buffer. ObjectNode *_next; }; @@ -95,7 +87,7 @@ private: static INLINE ObjectNode *buffer_to_node(void *buffer); ObjectNode *_deleted_chain; - + MutexImpl _lock; size_t _buffer_size; @@ -118,4 +110,3 @@ private: #include "deletedBufferChain.I" #endif - diff --git a/dtool/src/dtoolbase/deletedChain.h b/dtool/src/dtoolbase/deletedChain.h index 4fb93609f2..17a723a89b 100644 --- a/dtool/src/dtoolbase/deletedChain.h +++ b/dtool/src/dtoolbase/deletedChain.h @@ -1,16 +1,15 @@ -// Filename: deletedChain.h -// Created by: drose (01Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deletedChain.h + * @author drose + * @date 2006-04-01 + */ #ifndef DELETEDCHAIN_H #define DELETEDCHAIN_H @@ -19,29 +18,21 @@ #include "deletedBufferChain.h" #include -//////////////////////////////////////////////////////////////////// -// Class : DeletedChain -// Description : This template class can be used to provide faster -// allocation/deallocation for many Panda objects. It -// works by maintaining a linked list of deleted objects -// that are all of the same type; when a new object is -// allocated that matches that type, the same space is -// just reused. -// -// This class is actually a layer on top of -// DeletedBufferChain, which handles the actual -// allocation. This class just provides the -// typecasting. -// -// Of course, this trick of maintaining the deleted -// object chain won't work in the presence of -// polymorphism, where you might have many classes that -// derive from a base class, and all of them have a -// different size--unless you instantiate a DeletedChain -// for *every* kind of derived class. The -// ALLOC_DELETED_CHAIN macro, below, is designed to make -// this easy. -//////////////////////////////////////////////////////////////////// +/** + * This template class can be used to provide faster allocation/deallocation + * for many Panda objects. It works by maintaining a linked list of deleted + * objects that are all of the same type; when a new object is allocated that + * matches that type, the same space is just reused. + * + * This class is actually a layer on top of DeletedBufferChain, which handles + * the actual allocation. This class just provides the typecasting. + * + * Of course, this trick of maintaining the deleted object chain won't work in + * the presence of polymorphism, where you might have many classes that derive + * from a base class, and all of them have a different size--unless you + * instantiate a DeletedChain for *every* kind of derived class. The + * ALLOC_DELETED_CHAIN macro, below, is designed to make this easy. + */ template class DeletedChain { public: @@ -59,23 +50,18 @@ private: DeletedBufferChain *_chain; }; -//////////////////////////////////////////////////////////////////// -// Class : StaticDeletedChain -// Description : This template class is used to conveniently -// declare a single instance of the DeletedChain -// template object, above, for a particular type. -// -// It relies on the fact that the compiler and linker -// should unify all references to this static pointer -// for a given type, as per the C++ spec. However, this -// sometimes fails; and if the compiler fails to do -// this, it mostly won't be a big deal; it just means -// there will be multiple unrelated chains of deleted -// objects for a particular type. This is only a -// problem if the code structure causes objects to be -// allocated from one chain and freed to another, which -// can lead to leaks. -//////////////////////////////////////////////////////////////////// +/** + * This template class is used to conveniently declare a single instance of + * the DeletedChain template object, above, for a particular type. + * + * It relies on the fact that the compiler and linker should unify all + * references to this static pointer for a given type, as per the C++ spec. + * However, this sometimes fails; and if the compiler fails to do this, it + * mostly won't be a big deal; it just means there will be multiple unrelated + * chains of deleted objects for a particular type. This is only a problem if + * the code structure causes objects to be allocated from one chain and freed + * to another, which can lead to leaks. + */ template class StaticDeletedChain { public: @@ -88,9 +74,8 @@ public: }; #ifdef USE_DELETED_CHAIN -// Place this macro within a class definition to define appropriate -// operator new and delete methods that take advantage of -// DeletedChain. +// Place this macro within a class definition to define appropriate operator +// new and delete methods that take advantage of DeletedChain. #define ALLOC_DELETED_CHAIN(Type) \ inline void *operator new(size_t size) { \ return (void *)StaticDeletedChain< Type >::allocate(size, get_type_handle(Type)); \ @@ -108,9 +93,8 @@ public: return StaticDeletedChain< Type >::validate((const Type *)ptr); \ } -// Use this variant of the above macro in cases in which the compiler -// fails to unify the static template pointers properly, to prevent -// leaks. +// Use this variant of the above macro in cases in which the compiler fails to +// unify the static template pointers properly, to prevent leaks. #define ALLOC_DELETED_CHAIN_DECL(Type) \ inline void *operator new(size_t size) { \ return (void *)_deleted_chain.allocate(size, get_type_handle(Type)); \ @@ -129,8 +113,8 @@ public: } \ static DeletedChain< Type > _deleted_chain; -// When you use ALLOC_DELETED_CHAIN_DECL in a class body, you must -// also put this line in the .cxx file defining that class body. +// When you use ALLOC_DELETED_CHAIN_DECL in a class body, you must also put +// this line in the .cxx file defining that class body. #define ALLOC_DELETED_CHAIN_DEF(Type) \ DeletedChain< Type > Type::_deleted_chain; @@ -151,4 +135,3 @@ public: #include "deletedChain.T" #endif - diff --git a/dtool/src/dtoolbase/dtool_platform.h b/dtool/src/dtoolbase/dtool_platform.h index ccdb48539e..7955c7a941 100644 --- a/dtool/src/dtoolbase/dtool_platform.h +++ b/dtool/src/dtoolbase/dtool_platform.h @@ -1,8 +1,4 @@ -/* Filename: dtool_platform.h - * Created by: drose (03Aug09) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file dtool_platform.h + * @author drose + * @date 2009-08-03 + */ #ifndef DTOOL_PLATFORM_H #define DTOOL_PLATFORM_H @@ -80,4 +79,3 @@ #endif - diff --git a/dtool/src/dtoolbase/dtoolbase.cxx b/dtool/src/dtoolbase/dtoolbase.cxx index 210d08ef9c..75f25ad253 100644 --- a/dtool/src/dtoolbase/dtoolbase.cxx +++ b/dtool/src/dtoolbase/dtoolbase.cxx @@ -1,16 +1,15 @@ -// Filename: dtoolbase.cxx -// Created by: drose (12Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dtoolbase.cxx + * @author drose + * @date 2000-09-12 + */ #include "dtoolbase.h" #include "memoryHook.h" @@ -22,18 +21,15 @@ bool __tau_shutdown = false; MemoryHook *memory_hook; -//////////////////////////////////////////////////////////////////// -// Function: init_memory_hook -// Description: Any code that might need to use PANDA_MALLOC or -// PANDA_FREE, or any methods of the global memory_hook -// object, at static init time, should ensure that it -// calls init_memory_hook() first to ensure that the -// pointer has been properly initialized. There is no -// harm in calling this function more than once. -// -// There is no need to call this function other than at -// static init time. -//////////////////////////////////////////////////////////////////// +/** + * Any code that might need to use PANDA_MALLOC or PANDA_FREE, or any methods + * of the global memory_hook object, at static init time, should ensure that + * it calls init_memory_hook() first to ensure that the pointer has been + * properly initialized. There is no harm in calling this function more than + * once. + * + * There is no need to call this function other than at static init time. + */ void init_memory_hook() { if (memory_hook == NULL) { @@ -41,8 +37,8 @@ init_memory_hook() { } } -// Here's a quick way to ensure the above function is called at least -// once at static init time. +// Here's a quick way to ensure the above function is called at least once at +// static init time. class InitMemoryHook { public: InitMemoryHook() { diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 5d1b61014a..cfa1d9b0e3 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -1,8 +1,4 @@ -/* Filename: dtoolbase.h - * Created by: drose (12Sep00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file dtoolbase.h + * @author drose + * @date 2000-09-12 + */ /* This file is included at the beginning of every header file and/or C or C++ file. It must be compilable for C as well as C++ files, @@ -63,17 +62,18 @@ #if _MSC_VER >= 1300 #if _MSC_VER >= 1310 #define USING_MSVC7_1 -//#pragma message("VC 7.1") +// #pragma message("VC 7.1") #else -//#pragma message("VC 7.0") +// #pragma message("VC 7.0") #endif #define USING_MSVC7 #else // #pragma message("VC 6.0") #endif -// Use NODEFAULT to optimize a switch() stmt to tell MSVC to automatically go to the final untested case -// after it has failed all the other cases (i.e. 'assume at least one of the cases is always true') +// Use NODEFAULT to optimize a switch() stmt to tell MSVC to automatically go +// to the final untested case after it has failed all the other cases (i.e. +// 'assume at least one of the cases is always true') #ifdef _DEBUG # define NODEFAULT default: assert(0); #else @@ -107,8 +107,8 @@ #endif #endif -// This is a workaround for a glibc bug that is triggered by -// clang when compiling with -ffast-math. +// This is a workaround for a glibc bug that is triggered by clang when +// compiling with -ffast-math. #ifdef __clang__ #include #ifndef __extern_always_inline @@ -117,9 +117,9 @@ #endif #ifdef HAVE_PYTHON -// Instead of including the Python headers, which will implicitly -// add a linker flag to link in Python, we'll just excerpt the -// forward declaration of PyObject. +// Instead of including the Python headers, which will implicitly add a linker +// flag to link in Python, we'll just excerpt the forward declaration of +// PyObject. typedef struct _object PyObject; #endif @@ -134,8 +134,8 @@ typedef struct _object PyObject; #include #ifdef __GNUC__ -// Large file >2GB support -// this needs be be before systypes.h and other C headers +// Large file >2GB support this needs be be before systypes.h and other C +// headers #define _FILE_OFFSET_BITS 64 #define _LARGEFILE_SOURCE 1 #endif @@ -354,38 +354,35 @@ typedef struct _object PyObject; #define ALIGN_16BYTE #endif -// Do we need to implement memory-alignment enforcement within the -// MemoryHook class, or will the underlying malloc implementation -// provide it automatically? +// Do we need to implement memory-alignment enforcement within the MemoryHook +// class, or will the underlying malloc implementation provide it +// automatically? #if !defined(LINMATH_ALIGN) -// We don't actually require any special memory-alignment beyond what -// the underlying implementation is likely to provide anyway. +// We don't actually require any special memory-alignment beyond what the +// underlying implementation is likely to provide anyway. #undef MEMORY_HOOK_DO_ALIGN #elif defined(USE_MEMORY_DLMALLOC) -// This specialized malloc implementation can perform the required -// alignment. +// This specialized malloc implementation can perform the required alignment. #undef MEMORY_HOOK_DO_ALIGN #elif defined(USE_MEMORY_PTMALLOC2) -// But not this one. For some reason it crashes when we try to build -// it with alignment 16. So if we're using ptmalloc2, we need to -// enforce alignment externally. +// But not this one. For some reason it crashes when we try to build it with +// alignment 16. So if we're using ptmalloc2, we need to enforce alignment +// externally. #define MEMORY_HOOK_DO_ALIGN 1 #elif defined(IS_OSX) || defined(_WIN64) -// The OS-provided malloc implementation will do the required -// alignment. +// The OS-provided malloc implementation will do the required alignment. #undef MEMORY_HOOK_DO_ALIGN #elif defined(MEMORY_HOOK_DO_ALIGN) // We need memory alignment, and we're willing to provide it ourselves. #else -// We need memory alignment, and we haven't specified whether it -// should be provided on top of the existing malloc library, or -// otherwise. Let's rely on dlmalloc to provide it, it seems to be -// the most memory-efficient option. +// We need memory alignment, and we haven't specified whether it should be +// provided on top of the existing malloc library, or otherwise. Let's rely +// on dlmalloc to provide it, it seems to be the most memory-efficient option. #define USE_MEMORY_DLMALLOC 1 #endif @@ -393,7 +390,7 @@ typedef struct _object PyObject; /* Determine our memory-allocation requirements. */ #if defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) || defined(MEMORY_HOOK_DO_ALIGN) /* In this case we have some custom memory management requirements. */ -#else +#else /* Otherwise, if we have no custom memory management needs at all, we might as well turn it all off and go straight to the OS-level calls. */ diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index cd5e2c091b..eb99381c01 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -1,22 +1,21 @@ -// Filename: dtoolbase_cc.h -// Created by: drose (13Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dtoolbase_cc.h + * @author drose + * @date 2000-09-13 + */ #ifndef DTOOLBASE_CC_H #define DTOOLBASE_CC_H -// This file should never be included directly; it's intended to be -// included only from dtoolbase.h. Include that file instead. +// This file should never be included directly; it's intended to be included +// only from dtoolbase.h. Include that file instead. #ifdef __cplusplus @@ -43,10 +42,9 @@ using namespace std; #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) -// We define the macro PUBLISHED to mark C++ methods that are to be -// published via interrogate to scripting languages. However, if -// we're not running the interrogate pass (CPPPARSER isn't defined), -// this maps to public. +// We define the macro PUBLISHED to mark C++ methods that are to be published +// via interrogate to scripting languages. However, if we're not running the +// interrogate pass (CPPPARSER isn't defined), this maps to public. #define PUBLISHED __published typedef int ios_openmode; @@ -125,9 +123,9 @@ typedef ios::seekdir ios_seekdir; #endif #ifdef FORCE_INLINING -// If FORCE_INLINING is defined, we use the keyword __forceinline, -// which tells MS VC++ to override its internal benefit heuristic -// and inline the fn if it is technically possible to do so. +// If FORCE_INLINING is defined, we use the keyword __forceinline, which tells +// MS VC++ to override its internal benefit heuristic and inline the fn if it +// is technically possible to do so. #define INLINE ALWAYS_INLINE #else #define INLINE inline @@ -154,8 +152,8 @@ typedef ios::seekdir ios_seekdir; # endif #elif defined(__GNUC__) && (__cplusplus >= 201103L) // GCC -// GCC defines several macros which we can query. -// List of all supported builtin macros: https://gcc.gnu.org/projects/cxx0x.html +// GCC defines several macros which we can query. List of all supported +// builtin macros: https:gcc.gnu.orgprojectscxx0x.html # if __cpp_constexpr >= 200704 # define CONSTEXPR constexpr # endif @@ -216,38 +214,34 @@ typedef ios::seekdir ios_seekdir; #if !defined(LINK_ALL_STATIC) && defined(EXPORT_TEMPLATES) -// This macro must be used to export an instantiated template class -// from a DLL. If the template class name itself contains commas, it -// may be necessary to first define a macro for the class name, to -// allow proper macro parameter passing. +// This macro must be used to export an instantiated template class from a +// DLL. If the template class name itself contains commas, it may be +// necessary to first define a macro for the class name, to allow proper macro +// parameter passing. #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) \ exptp template class expcl classname; #else #define EXPORT_TEMPLATE_CLASS(expcl, exptp, classname) #endif -// We define the macro PUBLISHED to mark C++ methods that are to be -// published via interrogate to scripting languages. However, if -// we're not running the interrogate pass (CPPPARSER isn't defined), -// this maps to public. +// We define the macro PUBLISHED to mark C++ methods that are to be published +// via interrogate to scripting languages. However, if we're not running the +// interrogate pass (CPPPARSER isn't defined), this maps to public. #define PUBLISHED public #endif // CPPPARSER -// The ReferenceCount class is defined later, within Panda, but we -// need to pass around forward references to it here at the very low -// level. +// The ReferenceCount class is defined later, within Panda, but we need to +// pass around forward references to it here at the very low level. class ReferenceCount; -// We need a pointer to a global MemoryHook object, to manage all -// malloc and free requests from Panda. See the comments in -// MemoryHook itself. +// We need a pointer to a global MemoryHook object, to manage all malloc and +// free requests from Panda. See the comments in MemoryHook itself. class MemoryHook; EXPCL_DTOOL extern MemoryHook *memory_hook; EXPCL_DTOOL void init_memory_hook(); -// Now redefine some handy macros to hook into the above MemoryHook -// object. +// Now redefine some handy macros to hook into the above MemoryHook object. #ifndef USE_MEMORY_NOWRAPPERS #define PANDA_MALLOC_SINGLE(size) (memory_hook->heap_alloc_single(size)) #define PANDA_FREE_SINGLE(ptr) memory_hook->heap_free_single(ptr) @@ -263,8 +257,8 @@ EXPCL_DTOOL void init_memory_hook(); #endif // USE_MEMORY_NOWRAPPERS #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) -// We need another forward-reference function to allow low-level code -// to cooperatively yield the timeslice, in SIMPLE_THREADS mode. +// We need another forward-reference function to allow low-level code to +// cooperatively yield the timeslice, in SIMPLE_THREADS mode. extern EXPCL_DTOOL void (*global_thread_yield)(); extern EXPCL_DTOOL void (*global_thread_consider_yield)(); diff --git a/dtool/src/dtoolbase/dtoolsymbols.h b/dtool/src/dtoolbase/dtoolsymbols.h index cb4cd7993e..971a13ce32 100644 --- a/dtool/src/dtoolbase/dtoolsymbols.h +++ b/dtool/src/dtoolbase/dtoolsymbols.h @@ -1,8 +1,4 @@ -/* Filename: dtoolsymbols.h - * Created by: drose (18Feb00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file dtoolsymbols.h + * @author drose + * @date 2000-02-18 + */ #ifndef DTOOLSYMBOLS_H #define DTOOLSYMBOLS_H diff --git a/dtool/src/dtoolbase/epvector.h b/dtool/src/dtoolbase/epvector.h index 2359400fd6..c3c650d015 100644 --- a/dtool/src/dtoolbase/epvector.h +++ b/dtool/src/dtoolbase/epvector.h @@ -1,16 +1,15 @@ -// Filename: epvector.h -// Created by: drose (19Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file epvector.h + * @author drose + * @date 2011-12-19 + */ #ifndef EPVECTOR_H #define EPVECTOR_H @@ -21,25 +20,20 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : epvector -// Description : Unfortunately, on Windows, std::vector can't be used -// for classes with explicitly alignment requirements, -// due to a minor mistake in the template definition -// (one of the vector methods receives a concrete -// object, which the compiler flags as an error, even if -// the method is never called). -// -// As a workaround, Eigen provides their own -// specialization of vector, using their own aligned -// allocator. We define that here as epvector, which is -// meant to be a drop-in replacement for pvector for -// classes that include a linmath object that requires -// alignment. Unfortunately, this means we can't use -// the Panda allocator, so memory allocated for this -// vector class won't be tracked as part of Panda's -// memory tracking system. Them's the breaks, kids. -//////////////////////////////////////////////////////////////////// +/** + * Unfortunately, on Windows, std::vector can't be used for classes with + * explicitly alignment requirements, due to a minor mistake in the template + * definition (one of the vector methods receives a concrete object, which the + * compiler flags as an error, even if the method is never called). + * + * As a workaround, Eigen provides their own specialization of vector, using + * their own aligned allocator. We define that here as epvector, which is + * meant to be a drop-in replacement for pvector for classes that include a + * linmath object that requires alignment. Unfortunately, this means we can't + * use the Panda allocator, so memory allocated for this vector class won't be + * tracked as part of Panda's memory tracking system. Them's the breaks, + * kids. + */ template class epvector : public vector > { public: diff --git a/dtool/src/dtoolbase/fakestringstream.h b/dtool/src/dtoolbase/fakestringstream.h index 036ffd6b70..6711eb8d2a 100644 --- a/dtool/src/dtoolbase/fakestringstream.h +++ b/dtool/src/dtoolbase/fakestringstream.h @@ -1,16 +1,15 @@ -// Filename: fakestringstream.h -// Created by: cary (04Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fakestringstream.h + * @author cary + * @date 1999-02-04 + */ #ifndef FAKESTRINGSTREAM_H #define FAKESTRINGSTREAM_H @@ -79,10 +78,9 @@ public: _owns_str = false; } - // str() doesn't seem to compile cross-platform too reliably--Irix - // doesn't define pcount() for some reason. On the other hand, why - // are you calling str() on a stringstream? Just use an - // ostringstream. + // str() doesn't seem to compile cross-platform too reliably--Irix doesn't + // define pcount() for some reason. On the other hand, why are you calling + // str() on a stringstream? Just use an ostringstream. /* string str() { diff --git a/dtool/src/dtoolbase/indent.I b/dtool/src/dtoolbase/indent.I index aeeaea1262..db990ebe1d 100644 --- a/dtool/src/dtoolbase/indent.I +++ b/dtool/src/dtoolbase/indent.I @@ -1,25 +1,22 @@ -// Filename: indent.I -// Created by: drose (15Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indent.I + * @author drose + * @date 1999-02-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: write_long_list -// Description: Writes a list of things to the indicated output -// stream, with a space separating each item. One or -// more lines will be written, and the lines will -// automatically be broken such that no line exceeds -// max_col columns if possible. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of things to the indicated output stream, with a space + * separating each item. One or more lines will be written, and the lines + * will automatically be broken such that no line exceeds max_col columns if + * possible. + */ template void write_long_list(ostream &out, int indent_level, @@ -31,9 +28,8 @@ write_long_list(ostream &out, int indent_level, } if (first != last) { - // We have to use an intermediate strstream object so we can - // count the number of characters the item will have when it is - // output. + // We have to use an intermediate strstream object so we can count the + // number of characters the item will have when it is output. ostringstream item; item << *first; string str = item.str(); diff --git a/dtool/src/dtoolbase/indent.cxx b/dtool/src/dtoolbase/indent.cxx index 31d62b43e8..bf33828d03 100644 --- a/dtool/src/dtoolbase/indent.cxx +++ b/dtool/src/dtoolbase/indent.cxx @@ -1,24 +1,21 @@ -// Filename: indent.cxx -// Created by: drose (05May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indent.cxx + * @author drose + * @date 2000-05-05 + */ #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: indent -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & indent(ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { diff --git a/dtool/src/dtoolbase/indent.h b/dtool/src/dtoolbase/indent.h index d4c9225f2e..e7b6cf3c48 100644 --- a/dtool/src/dtoolbase/indent.h +++ b/dtool/src/dtoolbase/indent.h @@ -1,41 +1,36 @@ -// Filename: indent.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indent.h + * @author drose + * @date 1999-01-16 + */ #ifndef INDENT_H #define INDENT_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Function: indent -// Description: A handy function for doing text formatting. This -// function simply outputs the indicated number of -// spaces to the given output stream, returning the -// stream itself. Useful for indenting a series of -// lines of text by a given amount. -//////////////////////////////////////////////////////////////////// +/** + * A handy function for doing text formatting. This function simply outputs + * the indicated number of spaces to the given output stream, returning the + * stream itself. Useful for indenting a series of lines of text by a given + * amount. + */ EXPCL_DTOOL ostream & indent(ostream &out, int indent_level); -//////////////////////////////////////////////////////////////////// -// Function: write_long_list -// Description: Writes a list of things to the indicated output -// stream, with a space separating each item. One or -// more lines will be written, and the lines will -// automatically be broken such that no line exceeds -// max_col columns if possible. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of things to the indicated output stream, with a space + * separating each item. One or more lines will be written, and the lines + * will automatically be broken such that no line exceeds max_col columns if + * possible. + */ template void write_long_list(ostream &out, int indent_level, @@ -47,5 +42,3 @@ write_long_list(ostream &out, int indent_level, #include "indent.I" #endif - - diff --git a/dtool/src/dtoolbase/lookup3.h b/dtool/src/dtoolbase/lookup3.h index 3486b14621..185db7ffc1 100644 --- a/dtool/src/dtoolbase/lookup3.h +++ b/dtool/src/dtoolbase/lookup3.h @@ -1,16 +1,15 @@ -// Filename: lookup3.h -// Created by: drose (01Sep06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lookup3.h + * @author drose + * @date 2006-09-01 + */ #ifndef LOOKUP3_H #define LOOKUP3_H @@ -31,6 +30,3 @@ EXPCL_DTOOL PN_uint32 hashword(const PN_uint32 *k, /* the key, #endif #endif - - - diff --git a/dtool/src/dtoolbase/memoryBase.cxx b/dtool/src/dtoolbase/memoryBase.cxx index ea8147f0c4..84ea6bed5c 100644 --- a/dtool/src/dtoolbase/memoryBase.cxx +++ b/dtool/src/dtoolbase/memoryBase.cxx @@ -1,15 +1,14 @@ -// Filename: memoryBase.cxx -// Created by: drose (16Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryBase.cxx + * @author drose + * @date 2006-11-16 + */ #include "memoryBase.h" diff --git a/dtool/src/dtoolbase/memoryBase.h b/dtool/src/dtoolbase/memoryBase.h index 1dc15366b1..2f361f1bb1 100644 --- a/dtool/src/dtoolbase/memoryBase.h +++ b/dtool/src/dtoolbase/memoryBase.h @@ -1,16 +1,15 @@ -// Filename: memoryBase.h -// Created by: drose (16Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryBase.h + * @author drose + * @date 2006-11-16 + */ #ifndef MEMORYBASE_H #define MEMORYBASE_H @@ -18,11 +17,11 @@ #include "dtoolbase.h" #include "memoryHook.h" -// Place this macro within a class definition to define appropriate -// operator new and delete methods that hook into the MemoryInfo class -// to provide memory tracking. Of course, it is better simply to -// inherit from MemoryBase; this macro is provided to resolve problems -// with multiple inheritance or some such. +// Place this macro within a class definition to define appropriate operator +// new and delete methods that hook into the MemoryInfo class to provide +// memory tracking. Of course, it is better simply to inherit from +// MemoryBase; this macro is provided to resolve problems with multiple +// inheritance or some such. #ifndef USE_MEMORY_NOWRAPPERS @@ -58,23 +57,18 @@ #endif // USE_MEMORY_NOWRAPPERS -//////////////////////////////////////////////////////////////////// -// Class : MemoryBase -// Description : This class is intended to be the base class of all -// objects in Panda that might be allocated and deleted -// via the new and delete operators. It redefines these -// operators to provide some memory tracking support. -// -// We used to try to override the global operator new -// and delete methods, but that seems to cause problems -// when including header files for C++-based system -// libraries (such as are found on OSX). -//////////////////////////////////////////////////////////////////// +/** + * This class is intended to be the base class of all objects in Panda that + * might be allocated and deleted via the new and delete operators. It + * redefines these operators to provide some memory tracking support. + * + * We used to try to override the global operator new and delete methods, but + * that seems to cause problems when including header files for C++-based + * system libraries (such as are found on OSX). + */ class EXPCL_DTOOL MemoryBase { public: ALLOC_MEMORY_BASE; }; #endif - - diff --git a/dtool/src/dtoolbase/memoryHook.I b/dtool/src/dtoolbase/memoryHook.I index 9286a18d7a..c54e34c1f3 100644 --- a/dtool/src/dtoolbase/memoryHook.I +++ b/dtool/src/dtoolbase/memoryHook.I @@ -1,25 +1,20 @@ -// Filename: memoryHook.I -// Created by: drose (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryHook.I + * @author drose + * @date 2007-06-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::inc_heap -// Access: Public -// Description: Called by our alternative malloc implementations -// (dlmalloc and ptmalloc2) to indicate they have -// requested size bytes from the system for the heap. -//////////////////////////////////////////////////////////////////// +/** + * Called by our alternative malloc implementations (dlmalloc and ptmalloc2) + * to indicate they have requested size bytes from the system for the heap. + */ INLINE void MemoryHook:: inc_heap(size_t size) { #ifdef DO_MEMORY_USAGE @@ -27,34 +22,27 @@ inc_heap(size_t size) { #endif // DO_MEMORY_USAGE } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::dec_heap -// Access: Public -// Description: Called by our alternative malloc implementations -// (dlmalloc and ptmalloc2) to indicate they have -// returned size bytes to the system from the heap. -//////////////////////////////////////////////////////////////////// +/** + * Called by our alternative malloc implementations (dlmalloc and ptmalloc2) + * to indicate they have returned size bytes to the system from the heap. + */ INLINE void MemoryHook:: dec_heap(size_t size) { #ifdef DO_MEMORY_USAGE - //assert((int)size <= _requested_heap_size); + // assert((int)size <= _requested_heap_size); AtomicAdjust::add(_requested_heap_size, -(AtomicAdjust::Integer)size); #endif // DO_MEMORY_USAGE } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::get_memory_alignment -// Access: Public, Static -// Description: Returns the global memory alignment. This is the -// number of bytes at which each allocated memory -// pointer will be aligned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global memory alignment. This is the number of bytes at which + * each allocated memory pointer will be aligned. + */ INLINE size_t MemoryHook:: get_memory_alignment() { #ifdef LINMATH_ALIGN - // We require 16-byte alignment of certain structures, to support - // SSE2. We don't strictly have to align *everything*, but it's just - // easier to do so. + // We require 16-byte alignment of certain structures, to support SSE2. We + // don't strictly have to align *everything*, but it's just easier to do so. const size_t alignment_size = 16; #else // Otherwise, use word alignment. @@ -63,28 +51,24 @@ get_memory_alignment() { return alignment_size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::get_header_reserved_bytes -// Access: Public, Static -// Description: Returns the number of additional bytes that are -// reserved at the beginning of every allocated block to -// store a size_t. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of additional bytes that are reserved at the beginning + * of every allocated block to store a size_t. + */ INLINE size_t MemoryHook:: get_header_reserved_bytes() { - // We need to figure out the minimum amount of additional space we - // need in order to place a single word at the start of each - // allocated block, to store the size of the block. + // We need to figure out the minimum amount of additional space we need in + // order to place a single word at the start of each allocated block, to + // store the size of the block. #ifdef LINMATH_ALIGN - // If we're doing SSE2 alignment, we must reserve a full 16-byte - // block, since anything less than that will spoil the alignment. + // If we're doing SSE2 alignment, we must reserve a full 16-byte block, + // since anything less than that will spoil the alignment. static const size_t header_reserved_bytes = 16; #elif defined(MEMORY_HOOK_DO_ALIGN) - // If we're just aligning to words, we reserve a block as big as two - // words, to allow us wiggle room to align the word precisely within - // that block. + // If we're just aligning to words, we reserve a block as big as two words, + // to allow us wiggle room to align the word precisely within that block. static const size_t header_reserved_bytes = sizeof(size_t) + sizeof(size_t); #else @@ -95,48 +79,39 @@ get_header_reserved_bytes() { return header_reserved_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::get_page_size -// Access: Public -// Description: Returns the operating system page size. This is the -// minimum granularity required for calls to -// mmap_alloc(). Also see round_up_to_page_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the operating system page size. This is the minimum granularity + * required for calls to mmap_alloc(). Also see round_up_to_page_size(). + */ INLINE size_t MemoryHook:: get_page_size() const { return _page_size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::round_up_to_page_size -// Access: Public -// Description: Rounds the indicated size request up to the next -// larger multiple of page_size, to qualify it for a -// call to mmap_alloc(). -//////////////////////////////////////////////////////////////////// +/** + * Rounds the indicated size request up to the next larger multiple of + * page_size, to qualify it for a call to mmap_alloc(). + */ INLINE size_t MemoryHook:: round_up_to_page_size(size_t size) const { return ((size + _page_size - 1) / _page_size) * _page_size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::inflate_size -// Access: Private, Static -// Description: Increments the amount of requested size as necessary -// to accommodate the extra data we might piggyback on -// each allocated block. -//////////////////////////////////////////////////////////////////// +/** + * Increments the amount of requested size as necessary to accommodate the + * extra data we might piggyback on each allocated block. + */ INLINE size_t MemoryHook:: inflate_size(size_t size) { #if defined(MEMORY_HOOK_DO_ALIGN) - // If we're aligning, we need to request the header size, plus extra - // bytes to give us wiggle room to adjust the pointer. + // If we're aligning, we need to request the header size, plus extra bytes + // to give us wiggle room to adjust the pointer. return size + get_header_reserved_bytes() + get_memory_alignment() - 1; #elif defined(DO_MEMORY_USAGE) - // If we're not aligning, but we're tracking memory allocations, we - // just need the header size extra (this gives us a place to store - // the size of the allocated block). - return size + get_header_reserved_bytes(); + // If we're not aligning, but we're tracking memory allocations, we just + // need the header size extra (this gives us a place to store the size of + // the allocated block). + return size + get_header_reserved_bytes(); #else // If we're not doing any of that, we can just allocate the precise // requested amount. @@ -144,13 +119,10 @@ inflate_size(size_t size) { #endif // DO_MEMORY_USAGE } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::alloc_to_ptr -// Access: Private, Static -// Description: Converts an allocated pointer to a pointer returnable -// to the application. Stuffs size in the first n bytes -// of the allocated space. -//////////////////////////////////////////////////////////////////// +/** + * Converts an allocated pointer to a pointer returnable to the application. + * Stuffs size in the first n bytes of the allocated space. + */ INLINE void *MemoryHook:: alloc_to_ptr(void *alloc, size_t size) { #if defined(MEMORY_HOOK_DO_ALIGN) @@ -161,7 +133,7 @@ alloc_to_ptr(void *alloc, size_t size) { root[0] = size; root[1] = (size_t)alloc; // Save the pointer we originally allocated. return (void *)((char *)root + get_header_reserved_bytes()); -#elif defined(DO_MEMORY_USAGE) +#elif defined(DO_MEMORY_USAGE) size_t *root = (size_t *)alloc; root[0] = size; return (void *)((char *)root + get_header_reserved_bytes()); @@ -170,13 +142,10 @@ alloc_to_ptr(void *alloc, size_t size) { #endif // DO_MEMORY_USAGE } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::ptr_to_alloc -// Access: Private, Static -// Description: Converts an application pointer back to the original -// allocated pointer. Extracts size from the first n -// bytes of the allocated space. -//////////////////////////////////////////////////////////////////// +/** + * Converts an application pointer back to the original allocated pointer. + * Extracts size from the first n bytes of the allocated space. + */ INLINE void *MemoryHook:: ptr_to_alloc(void *ptr, size_t &size) { #if defined(MEMORY_HOOK_DO_ALIGN) @@ -185,7 +154,7 @@ ptr_to_alloc(void *ptr, size_t &size) { void *alloc = (void *)root[1]; // Get the pointer we originally allocated. assert(alloc <= root && (size_t)((char *)root - (char *)alloc) < get_memory_alignment()); return alloc; -#elif defined(DO_MEMORY_USAGE) +#elif defined(DO_MEMORY_USAGE) size_t *root = (size_t *)((char *)ptr - get_header_reserved_bytes()); size = root[0]; return (void *)root; diff --git a/dtool/src/dtoolbase/memoryHook.cxx b/dtool/src/dtoolbase/memoryHook.cxx index 743a0cd013..502839654c 100644 --- a/dtool/src/dtoolbase/memoryHook.cxx +++ b/dtool/src/dtoolbase/memoryHook.cxx @@ -1,16 +1,15 @@ -// Filename: memoryHook.cxx -// Created by: drose (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryHook.cxx + * @author drose + * @date 2007-06-28 + */ #include "memoryHook.h" #include "deletedBufferChain.h" @@ -40,14 +39,9 @@ #if defined(USE_MEMORY_DLMALLOC) -//////////////////////////////////////////////////////////////////// -// -// Memory manager: DLMALLOC -// -// This is Doug Lea's memory manager. It is very fast, but it is not -// thread-safe. However, we provide thread locking within MemoryHook. -// -//////////////////////////////////////////////////////////////////// +// Memory manager: DLMALLOC This is Doug Lea's memory manager. It is very +// fast, but it is not thread-safe. However, we provide thread locking within +// MemoryHook. #define USE_DL_PREFIX 1 #define NO_MALLINFO 1 @@ -67,21 +61,16 @@ #define MEMORY_HOOK_MALLOC_LOCK 1 #elif defined(USE_MEMORY_PTMALLOC2) -// This doesn't appear to work in Linux; perhaps it is clashing with -// the system library. It also doesn't appear to be thread-safe on -// OSX. +// This doesn't appear to work in Linux; perhaps it is clashing with the +// system library. It also doesn't appear to be thread-safe on OSX. -//////////////////////////////////////////////////////////////////// -// -// Memory manager: PTMALLOC2 -// -// Ptmalloc2 is a derivative of Doug Lea's memory manager that was -// made thread-safe by Wolfram Gloger, then was ported to windows by -// Niall Douglas. It is not quite as fast as dlmalloc (because the -// thread-safety constructs take a certain amount of CPU time), but -// it's still much faster than the windows allocator. -// -//////////////////////////////////////////////////////////////////// +/* + * Memory manager: PTMALLOC2 Ptmalloc2 is a derivative of Doug Lea's memory + * manager that was made thread-safe by Wolfram Gloger, then was ported to + * windows by Niall Douglas. It is not quite as fast as dlmalloc (because the + * thread-safety constructs take a certain amount of CPU time), but it's still + * much faster than the windows allocator. + */ #define USE_DL_PREFIX 1 #define NO_MALLINFO 1 @@ -97,14 +86,8 @@ #else -//////////////////////////////////////////////////////////////////// -// -// Memory manager: MALLOC -// -// This option uses the built-in system allocator. This is a good -// choice on linux, but it's a terrible choice on windows. -// -//////////////////////////////////////////////////////////////////// +// Memory manager: MALLOC This option uses the built-in system allocator. +// This is a good choice on linux, but it's a terrible choice on windows. #define call_malloc malloc #define call_realloc realloc @@ -113,11 +96,9 @@ #endif // USE_MEMORY_* -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryHook:: MemoryHook() { #ifdef WIN32 @@ -144,11 +125,9 @@ MemoryHook() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryHook:: MemoryHook(const MemoryHook ©) : _page_size(copy._page_size) @@ -166,28 +145,22 @@ MemoryHook(const MemoryHook ©) : ((MutexImpl &)copy._lock).release(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryHook:: ~MemoryHook() { - // Really, we only have this destructor to shut up gcc about the - // virtual functions warning. + // Really, we only have this destructor to shut up gcc about the virtual + // functions warning. } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_alloc_single -// Access: Public, Virtual -// Description: Allocates a block of memory from the heap, similar to -// malloc(). This will never return NULL; it will abort -// instead if memory is not available. -// -// This particular function should be used to allocate -// memory for a single object, as opposed to an array. -// The only difference is in the bookkeeping. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a block of memory from the heap, similar to malloc(). This will + * never return NULL; it will abort instead if memory is not available. + * + * This particular function should be used to allocate memory for a single + * object, as opposed to an array. The only difference is in the bookkeeping. + */ void *MemoryHook:: heap_alloc_single(size_t size) { size_t inflated_size = inflate_size(size); @@ -212,8 +185,8 @@ heap_alloc_single(size_t size) { } #ifdef DO_MEMORY_USAGE - // In the DO_MEMORY_USAGE case, we want to track the total size of - // allocated bytes on the heap. + // In the DO_MEMORY_USAGE case, we want to track the total size of allocated + // bytes on the heap. AtomicAdjust::add(_total_heap_single_size, (AtomicAdjust::Integer)size); if ((size_t)AtomicAdjust::get(_total_heap_single_size) + (size_t)AtomicAdjust::get(_total_heap_array_size) > @@ -227,12 +200,9 @@ heap_alloc_single(size_t size) { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_free_single -// Access: Public, Virtual -// Description: Releases a block of memory previously allocated via -// heap_alloc_single. -//////////////////////////////////////////////////////////////////// +/** + * Releases a block of memory previously allocated via heap_alloc_single. + */ void MemoryHook:: heap_free_single(void *ptr) { size_t size; @@ -252,18 +222,14 @@ heap_free_single(void *ptr) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_alloc_array -// Access: Public, Virtual -// Description: Allocates a block of memory from the heap, similar to -// malloc(). This will never return NULL; it will abort -// instead if memory is not available. -// -// This particular function should be used to allocate -// memory for an array of objects, as opposed to a -// single object. The only difference is in the -// bookkeeping. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a block of memory from the heap, similar to malloc(). This will + * never return NULL; it will abort instead if memory is not available. + * + * This particular function should be used to allocate memory for an array of + * objects, as opposed to a single object. The only difference is in the + * bookkeeping. + */ void *MemoryHook:: heap_alloc_array(size_t size) { size_t inflated_size = inflate_size(size); @@ -288,8 +254,8 @@ heap_alloc_array(size_t size) { } #ifdef DO_MEMORY_USAGE - // In the DO_MEMORY_USAGE case, we want to track the total size of - // allocated bytes on the heap. + // In the DO_MEMORY_USAGE case, we want to track the total size of allocated + // bytes on the heap. AtomicAdjust::add(_total_heap_array_size, (AtomicAdjust::Integer)size); if ((size_t)AtomicAdjust::get(_total_heap_single_size) + (size_t)AtomicAdjust::get(_total_heap_array_size) > @@ -303,12 +269,9 @@ heap_alloc_array(size_t size) { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_realloc_array -// Access: Public, Virtual -// Description: Resizes a block of memory previously returned from -// heap_alloc_array. -//////////////////////////////////////////////////////////////////// +/** + * Resizes a block of memory previously returned from heap_alloc_array. + */ void *MemoryHook:: heap_realloc_array(void *ptr, size_t size) { size_t orig_size; @@ -348,8 +311,8 @@ heap_realloc_array(void *ptr, size_t size) { void *ptr1 = alloc_to_ptr(alloc1, size); assert(ptr1 >= alloc1 && (char *)ptr1 + size <= (char *)alloc1 + inflated_size); #if defined(MEMORY_HOOK_DO_ALIGN) - // We might have to shift the memory to account for the new offset - // due to the alignment. + // We might have to shift the memory to account for the new offset due to + // the alignment. size_t orig_delta = (char *)ptr - (char *)alloc; size_t new_delta = (char *)ptr1 - (char *)alloc1; if (orig_delta != new_delta) { @@ -359,12 +322,9 @@ heap_realloc_array(void *ptr, size_t size) { return ptr1; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_free_array -// Access: Public, Virtual -// Description: Releases a block of memory previously allocated via -// heap_alloc_array. -//////////////////////////////////////////////////////////////////// +/** + * Releases a block of memory previously allocated via heap_alloc_array. + */ void MemoryHook:: heap_free_array(void *ptr) { size_t size; @@ -384,28 +344,23 @@ heap_free_array(void *ptr) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::heap_trim -// Access: Public -// Description: Attempts to release memory back to the system, if -// possible. The pad argument is the minimum amount of -// unused memory to keep in the heap (against future -// allocations). Any memory above that may be released -// to the system, reducing the memory size of this -// process. There is no guarantee that any memory may -// be released. -// -// Returns true if any memory was actually released, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to release memory back to the system, if possible. The pad + * argument is the minimum amount of unused memory to keep in the heap + * (against future allocations). Any memory above that may be released to the + * system, reducing the memory size of this process. There is no guarantee + * that any memory may be released. + * + * Returns true if any memory was actually released, false otherwise. + */ bool MemoryHook:: heap_trim(size_t pad) { bool trimmed = false; #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) - // Since malloc_trim() isn't standard C, we can't be sure it exists - // on a given platform. But if we're using dlmalloc, we know we - // have dlmalloc_trim. + // Since malloc_trim() isn't standard C, we can't be sure it exists on a + // given platform. But if we're using dlmalloc, we know we have + // dlmalloc_trim. _lock.acquire(); if (dlmalloc_trim(pad)) { trimmed = true; @@ -423,22 +378,17 @@ heap_trim(size_t pad) { return trimmed; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::mmap_alloc -// Access: Public, Virtual -// Description: Allocates a raw page or pages of memory directly from -// the OS. This will be in a different address space -// from the memory allocated by heap_alloc(), and so it -// won't contribute to fragmentation of that memory. -// -// The allocation size must be an integer multiple of -// the page size. Use round_to_page_size() if there is -// any doubt. -// -// If allow_exec is true, the memory will be flagged so -// that it is legal to execute code that has been -// written to this memory. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a raw page or pages of memory directly from the OS. This will be + * in a different address space from the memory allocated by heap_alloc(), and + * so it won't contribute to fragmentation of that memory. + * + * The allocation size must be an integer multiple of the page size. Use + * round_to_page_size() if there is any doubt. + * + * If allow_exec is true, the memory will be flagged so that it is legal to + * execute code that has been written to this memory. + */ void *MemoryHook:: mmap_alloc(size_t size, bool allow_exec) { assert((size % _page_size) == 0); @@ -489,12 +439,10 @@ mmap_alloc(size_t size, bool allow_exec) { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::mmap_free -// Access: Public, Virtual -// Description: Frees a block of memory previously allocated via -// mmap_alloc(). You must know how large the block was. -//////////////////////////////////////////////////////////////////// +/** + * Frees a block of memory previously allocated via mmap_alloc(). You must + * know how large the block was. + */ void MemoryHook:: mmap_free(void *ptr, size_t size) { assert((size % _page_size) == 0); @@ -511,29 +459,22 @@ mmap_free(void *ptr, size_t size) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::mark_pointer -// Access: Public, Virtual -// Description: This special method exists only to provide a callback -// hook into MemoryUsage. It indicates that the -// indicated pointer, allocated from somewhere other -// than a call to heap_alloc(), now contains a pointer -// to the indicated ReferenceCount object. If orig_size -// is 0, it indicates that the ReferenceCount object has -// been destroyed. -//////////////////////////////////////////////////////////////////// +/** + * This special method exists only to provide a callback hook into + * MemoryUsage. It indicates that the indicated pointer, allocated from + * somewhere other than a call to heap_alloc(), now contains a pointer to the + * indicated ReferenceCount object. If orig_size is 0, it indicates that the + * ReferenceCount object has been destroyed. + */ void MemoryHook:: mark_pointer(void *, size_t, ReferenceCount *) { } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::get_deleted_chain -// Access: Public -// Description: Returns a pointer to a global DeletedBufferChain -// object suitable for allocating arrays of the -// indicated size. There is one unique -// DeletedBufferChain object for every different size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a global DeletedBufferChain object suitable for + * allocating arrays of the indicated size. There is one unique + * DeletedBufferChain object for every different size. + */ DeletedBufferChain *MemoryHook:: get_deleted_chain(size_t buffer_size) { DeletedBufferChain *chain; @@ -552,23 +493,18 @@ get_deleted_chain(size_t buffer_size) { return chain; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::alloc_fail -// Access: Protected, Virtual -// Description: This callback method is called whenever a low-level -// call to call_malloc() has returned NULL, indicating -// failure. -// -// Since this method is called very low-level, and may -// be in the middle of any number of critical sections, -// it will be difficult for this callback initiate any -// emergency high-level operation to make more memory -// available. However, this module is set up to assume -// that that's what this method does, and will make -// another alloc attempt after it returns. Probably the -// only sensible thing this method can do, however, is -// just to display a message and abort. -//////////////////////////////////////////////////////////////////// +/** + * This callback method is called whenever a low-level call to call_malloc() + * has returned NULL, indicating failure. + * + * Since this method is called very low-level, and may be in the middle of any + * number of critical sections, it will be difficult for this callback + * initiate any emergency high-level operation to make more memory available. + * However, this module is set up to assume that that's what this method does, + * and will make another alloc attempt after it returns. Probably the only + * sensible thing this method can do, however, is just to display a message + * and abort. + */ void MemoryHook:: alloc_fail(size_t attempted_size) { cerr << "Out of memory allocating " << attempted_size << " bytes\n"; @@ -576,17 +512,14 @@ alloc_fail(size_t attempted_size) { } #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: MemoryHook::overflow_heap_size -// Access: Protected, Virtual -// Description: This callback method is called whenever the total -// allocated heap size exceeds _max_heap_size. It's -// mainly intended for reporting memory leaks, on the -// assumption that once we cross some specified -// threshold, we're just leaking memory. -// -// The implementation for this method is in MemoryUsage. -//////////////////////////////////////////////////////////////////// +/** + * This callback method is called whenever the total allocated heap size + * exceeds _max_heap_size. It's mainly intended for reporting memory leaks, + * on the assumption that once we cross some specified threshold, we're just + * leaking memory. + * + * The implementation for this method is in MemoryUsage. + */ void MemoryHook:: overflow_heap_size() { _max_heap_size = ~(size_t)0; diff --git a/dtool/src/dtoolbase/memoryHook.h b/dtool/src/dtoolbase/memoryHook.h index 74bdad276d..d53e03ba2e 100644 --- a/dtool/src/dtoolbase/memoryHook.h +++ b/dtool/src/dtoolbase/memoryHook.h @@ -1,16 +1,15 @@ -// Filename: memoryHook.h -// Created by: drose (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryHook.h + * @author drose + * @date 2007-06-28 + */ #ifndef MEMORYHOOK_H #define MEMORYHOOK_H @@ -23,23 +22,18 @@ class DeletedBufferChain; -//////////////////////////////////////////////////////////////////// -// Class : MemoryHook -// Description : This class provides a wrapper around the various -// possible malloc schemes Panda might employ. It also -// exists to allow the MemoryUsage class in Panda to -// insert callback hooks to track the size of allocated -// pointers. -// -// The PANDA_MALLOC_* and PANDA_FREE_* macros are -// defined to vector through through this class (except -// in production builds) to facilitate that. Every -// memory allocation call in Panda should therefore use -// these macros instead of direct calls to malloc or -// free. (C++ new and delete operators may be employed -// for classes which inherit from MemoryBase; otherwise, -// use the PANDA_MALLOC macros.) -//////////////////////////////////////////////////////////////////// +/** + * This class provides a wrapper around the various possible malloc schemes + * Panda might employ. It also exists to allow the MemoryUsage class in Panda + * to insert callback hooks to track the size of allocated pointers. + * + * The PANDA_MALLOC_* and PANDA_FREE_* macros are defined to vector through + * through this class (except in production builds) to facilitate that. Every + * memory allocation call in Panda should therefore use these macros instead + * of direct calls to malloc or free. (C++ new and delete operators may be + * employed for classes which inherit from MemoryBase; otherwise, use the + * PANDA_MALLOC macros.) + */ class EXPCL_DTOOL MemoryHook { public: MemoryHook(); diff --git a/dtool/src/dtoolbase/mutexDummyImpl.I b/dtool/src/dtoolbase/mutexDummyImpl.I index d7e55fd35c..9c0bbc01d2 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.I +++ b/dtool/src/dtoolbase/mutexDummyImpl.I @@ -1,60 +1,48 @@ -// Filename: mutexDummyImpl.I -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDummyImpl.I + * @author drose + * @date 2002-08-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexDummyImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexDummyImpl:: MutexDummyImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDummyImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexDummyImpl:: ~MutexDummyImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDummyImpl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexDummyImpl:: acquire() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDummyImpl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MutexDummyImpl:: try_acquire() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDummyImpl::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexDummyImpl:: release() { } diff --git a/dtool/src/dtoolbase/mutexDummyImpl.cxx b/dtool/src/dtoolbase/mutexDummyImpl.cxx index ca9a931852..ba9ada10fc 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.cxx +++ b/dtool/src/dtoolbase/mutexDummyImpl.cxx @@ -1,16 +1,15 @@ -// Filename: mutexDummyImpl.cxx -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDummyImpl.cxx + * @author drose + * @date 2002-08-08 + */ #include "selectThreadImpl.h" #include "mutexDummyImpl.h" diff --git a/dtool/src/dtoolbase/mutexDummyImpl.h b/dtool/src/dtoolbase/mutexDummyImpl.h index b2e4b5c7b4..703fb81803 100644 --- a/dtool/src/dtoolbase/mutexDummyImpl.h +++ b/dtool/src/dtoolbase/mutexDummyImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexDummyImpl.h -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDummyImpl.h + * @author drose + * @date 2002-08-08 + */ #ifndef MUTEXDUMMYIMPL_H #define MUTEXDUMMYIMPL_H @@ -18,12 +17,10 @@ #include "dtoolbase.h" #include "selectThreadImpl.h" -//////////////////////////////////////////////////////////////////// -// Class : MutexDummyImpl -// Description : A fake mutex implementation for single-threaded -// applications that don't need any synchronization -// control. This does nothing at all. -//////////////////////////////////////////////////////////////////// +/** + * A fake mutex implementation for single-threaded applications that don't + * need any synchronization control. This does nothing at all. + */ class EXPCL_DTOOL MutexDummyImpl { public: INLINE MutexDummyImpl(); diff --git a/dtool/src/dtoolbase/mutexImpl.h b/dtool/src/dtoolbase/mutexImpl.h index b86c3709b3..f309634ffa 100644 --- a/dtool/src/dtoolbase/mutexImpl.h +++ b/dtool/src/dtoolbase/mutexImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexImpl.h -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexImpl.h + * @author drose + * @date 2002-08-08 + */ #ifndef MUTEXIMPL_H #define MUTEXIMPL_H @@ -47,10 +46,9 @@ typedef ReMutexPosixImpl ReMutexImpl; #endif -// Also define what a true OS-provided lock will be, even if we don't -// have threading enabled in the build. Sometimes we need to -// interface with an external program or something that wants real -// locks. +// Also define what a true OS-provided lock will be, even if we don't have +// threading enabled in the build. Sometimes we need to interface with an +// external program or something that wants real locks. #if defined(WIN32_VC) #include "mutexWin32Impl.h" typedef MutexWin32Impl TrueMutexImpl; @@ -65,6 +63,3 @@ typedef MutexPosixImpl TrueMutexImpl; #endif #endif - - - diff --git a/dtool/src/dtoolbase/mutexPosixImpl.I b/dtool/src/dtoolbase/mutexPosixImpl.I index 7d419cbffc..9b86139b41 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.I +++ b/dtool/src/dtoolbase/mutexPosixImpl.I @@ -1,23 +1,19 @@ -// Filename: mutexPosixImpl.I -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexPosixImpl.I + * @author drose + * @date 2006-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexPosixImpl:: MutexPosixImpl() { TAU_PROFILE("MutexPosixImpl::MutexPosixImpl", " ", TAU_USER); @@ -30,11 +26,9 @@ MutexPosixImpl() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexPosixImpl:: ~MutexPosixImpl() { TAU_PROFILE("MutexPosixImpl::~MutexPosixImpl", " ", TAU_USER); @@ -42,11 +36,9 @@ INLINE MutexPosixImpl:: assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexPosixImpl:: acquire() { TAU_PROFILE("void MutexPosixImpl::acquire", " ", TAU_USER); @@ -54,11 +46,9 @@ acquire() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MutexPosixImpl:: try_acquire() { TAU_PROFILE("bool MutexPosixImpl::try_acquire", " ", TAU_USER); @@ -67,11 +57,9 @@ try_acquire() { return (result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexPosixImpl:: release() { TAU_PROFILE("void MutexPosixImpl::release", " ", TAU_USER); @@ -79,21 +67,17 @@ release() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexPosixImpl::get_posix_lock -// Access: Public -// Description: Returns the underlying Posix lock handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying Posix lock handle. + */ INLINE pthread_mutex_t *MutexPosixImpl:: get_posix_lock() { return &_lock; } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexPosixImpl:: ReMutexPosixImpl() { TAU_PROFILE("ReMutexPosixImpl::ReMutexPosixImpl", " ", TAU_USER); @@ -105,11 +89,9 @@ ReMutexPosixImpl() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexPosixImpl:: ~ReMutexPosixImpl() { TAU_PROFILE("ReMutexPosixImpl::~ReMutexPosixImpl", " ", TAU_USER); @@ -117,11 +99,9 @@ INLINE ReMutexPosixImpl:: assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ReMutexPosixImpl:: acquire() { TAU_PROFILE("void ReMutexPosixImpl::acquire", " ", TAU_USER); @@ -129,11 +109,9 @@ acquire() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ReMutexPosixImpl:: try_acquire() { TAU_PROFILE("bool ReMutexPosixImpl::try_acquire", " ", TAU_USER); @@ -142,11 +120,9 @@ try_acquire() { return (result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ReMutexPosixImpl:: release() { TAU_PROFILE("void ReMutexPosixImpl::release", " ", TAU_USER); @@ -154,11 +130,9 @@ release() { assert(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexPosixImpl::get_posix_lock -// Access: Public -// Description: Returns the underlying Posix lock handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying Posix lock handle. + */ INLINE pthread_mutex_t *ReMutexPosixImpl:: get_posix_lock() { return &_lock; diff --git a/dtool/src/dtoolbase/mutexPosixImpl.cxx b/dtool/src/dtoolbase/mutexPosixImpl.cxx index 23d86938c3..51556c2de9 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.cxx +++ b/dtool/src/dtoolbase/mutexPosixImpl.cxx @@ -1,16 +1,15 @@ -// Filename: mutexPosixImpl.cxx -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexPosixImpl.cxx + * @author drose + * @date 2006-02-10 + */ #include "selectThreadImpl.h" diff --git a/dtool/src/dtoolbase/mutexPosixImpl.h b/dtool/src/dtoolbase/mutexPosixImpl.h index 7f506e1324..e4f684de52 100644 --- a/dtool/src/dtoolbase/mutexPosixImpl.h +++ b/dtool/src/dtoolbase/mutexPosixImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexPosixImpl.h -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexPosixImpl.h + * @author drose + * @date 2006-02-10 + */ #ifndef MUTEXPOSIXIMPL_H #define MUTEXPOSIXIMPL_H @@ -24,10 +23,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : MutexPosixImpl -// Description : Uses Posix threads to implement a mutex. -//////////////////////////////////////////////////////////////////// +/** + * Uses Posix threads to implement a mutex. + */ class EXPCL_DTOOL MutexPosixImpl { public: INLINE MutexPosixImpl(); @@ -44,10 +42,9 @@ private: friend class ConditionVarPosixImpl; }; -//////////////////////////////////////////////////////////////////// -// Class : ReMutexPosixImpl -// Description : Uses Posix threads to implement a reentrant mutex. -//////////////////////////////////////////////////////////////////// +/** + * Uses Posix threads to implement a reentrant mutex. + */ class EXPCL_DTOOL ReMutexPosixImpl { public: INLINE ReMutexPosixImpl(); diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.I b/dtool/src/dtoolbase/mutexSpinlockImpl.I index daa76bd7d0..5b62bf4f55 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.I +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.I @@ -1,42 +1,34 @@ -// Filename: mutexSpinlockImpl.I -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSpinlockImpl.I + * @author drose + * @date 2006-04-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexSpinlockImpl:: MutexSpinlockImpl() { _lock = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexSpinlockImpl:: ~MutexSpinlockImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexSpinlockImpl:: acquire() { if (!try_acquire()) { @@ -44,21 +36,17 @@ acquire() { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MutexSpinlockImpl:: try_acquire() { return (AtomicAdjust::compare_and_exchange(_lock, 0, 1) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexSpinlockImpl:: release() { AtomicAdjust::set(_lock, 0); diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx index d24d73c887..32a84fa28f 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.cxx +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.cxx @@ -1,16 +1,15 @@ -// Filename: mutexSpinlockImpl.cxx -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSpinlockImpl.cxx + * @author drose + * @date 2006-04-11 + */ #include "selectThreadImpl.h" @@ -18,11 +17,9 @@ #include "mutexSpinlockImpl.h" -//////////////////////////////////////////////////////////////////// -// Function: MutexSpinlockImpl::do_lock -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MutexSpinlockImpl:: do_lock() { while (AtomicAdjust::compare_and_exchange(_lock, 0, 1) != 0) { diff --git a/dtool/src/dtoolbase/mutexSpinlockImpl.h b/dtool/src/dtoolbase/mutexSpinlockImpl.h index 9956522e2b..19a8d1802c 100644 --- a/dtool/src/dtoolbase/mutexSpinlockImpl.h +++ b/dtool/src/dtoolbase/mutexSpinlockImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexSpinlockImpl.h -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSpinlockImpl.h + * @author drose + * @date 2006-04-11 + */ #ifndef MUTEXSPINLOCKIMPL_H #define MUTEXSPINLOCKIMPL_H @@ -22,15 +21,12 @@ #include "atomicAdjust.h" -//////////////////////////////////////////////////////////////////// -// Class : MutexSpinlockImpl -// Description : Uses a simple user-space spinlock to implement a -// mutex. It is usually not a good idea to use this -// implementation, unless you are building Panda for a -// specific application on a specific SMP machine, and -// you are confident that you have at least as many -// CPU's as you have threads. -//////////////////////////////////////////////////////////////////// +/** + * Uses a simple user-space spinlock to implement a mutex. It is usually not + * a good idea to use this implementation, unless you are building Panda for a + * specific application on a specific SMP machine, and you are confident that + * you have at least as many CPU's as you have threads. + */ class EXPCL_DTOOL MutexSpinlockImpl { public: INLINE MutexSpinlockImpl(); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.I b/dtool/src/dtoolbase/mutexWin32Impl.I index 0cc9202b36..cd9b3d1fb1 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.I +++ b/dtool/src/dtoolbase/mutexWin32Impl.I @@ -1,53 +1,43 @@ -// Filename: mutexWin32Impl.I -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexWin32Impl.I + * @author drose + * @date 2006-02-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexWin32Impl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexWin32Impl:: ~MutexWin32Impl() { DeleteCriticalSection(&_lock); } -//////////////////////////////////////////////////////////////////// -// Function: MutexWin32Impl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexWin32Impl:: acquire() { EnterCriticalSection(&_lock); } -//////////////////////////////////////////////////////////////////// -// Function: MutexWin32Impl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MutexWin32Impl:: try_acquire() { return (TryEnterCriticalSection(&_lock) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: MutexWin32Impl::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexWin32Impl:: release() { LeaveCriticalSection(&_lock); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.cxx b/dtool/src/dtoolbase/mutexWin32Impl.cxx index b53ea38b35..594f6c0962 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.cxx +++ b/dtool/src/dtoolbase/mutexWin32Impl.cxx @@ -1,16 +1,15 @@ -// Filename: mutexWin32Impl.cxx -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexWin32Impl.cxx + * @author drose + * @date 2006-02-07 + */ #include "selectThreadImpl.h" @@ -18,11 +17,9 @@ #include "mutexWin32Impl.h" -//////////////////////////////////////////////////////////////////// -// Function: MutexWin32Impl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MutexWin32Impl:: MutexWin32Impl() { InitializeCriticalSectionAndSpinCount(&_lock, 4000); diff --git a/dtool/src/dtoolbase/mutexWin32Impl.h b/dtool/src/dtoolbase/mutexWin32Impl.h index 1c66583a9c..0407d5a883 100644 --- a/dtool/src/dtoolbase/mutexWin32Impl.h +++ b/dtool/src/dtoolbase/mutexWin32Impl.h @@ -1,16 +1,15 @@ -// Filename: mutexWin32Impl.h -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexWin32Impl.h + * @author drose + * @date 2006-02-07 + */ #ifndef MUTEXWIN32IMPL_H #define MUTEXWIN32IMPL_H @@ -24,10 +23,9 @@ #endif #include -//////////////////////////////////////////////////////////////////// -// Class : MutexWin32Impl -// Description : Uses Windows native calls to implement a mutex. -//////////////////////////////////////////////////////////////////// +/** + * Uses Windows native calls to implement a mutex. + */ class EXPCL_DTOOL MutexWin32Impl { public: MutexWin32Impl(); diff --git a/dtool/src/dtoolbase/nearly_zero.h b/dtool/src/dtoolbase/nearly_zero.h index a0ffa0b333..af71ad9419 100644 --- a/dtool/src/dtoolbase/nearly_zero.h +++ b/dtool/src/dtoolbase/nearly_zero.h @@ -1,30 +1,29 @@ -// Filename: nearly_zero.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nearly_zero.h + * @author drose + * @date 2000-03-08 + */ #ifndef NEARLY_ZERO_H #define NEARLY_ZERO_H #include "dtoolbase.h" -// The following two functions are defined just to make the -// NEARLY_ZERO() macro work. They each return a suitable nearly-zero -// value for their corresponding numeric type. +// The following two functions are defined just to make the NEARLY_ZERO() +// macro work. They each return a suitable nearly-zero value for their +// corresponding numeric type. -// Note that declaring these small numeric values first as a static -// const identifier, and then returning the value of that identifier, -// seems to lead to compilation errors (at least in VC7) in which -// sometimes IS_THRESHOLD_COMPEQ(a, a, get_nearly_zero_value(a)) != 0. +// Note that declaring these small numeric values first as a static const +// identifier, and then returning the value of that identifier, seems to lead +// to compilation errors (at least in VC7) in which sometimes +// IS_THRESHOLD_COMPEQ(a, a, get_nearly_zero_value(a)) != 0. CONSTEXPR double get_nearly_zero_value(double) { return 1.0e-12; @@ -37,51 +36,48 @@ get_nearly_zero_value(float) { CONSTEXPR int get_nearly_zero_value(int) { - // This is a bit silly, but we should nevertheless define it in - // case it is called for an integer type. + // This is a bit silly, but we should nevertheless define it in case it is + // called for an integer type. return 0; } -// IS_THRESHOLD_ZERO(value, threshold) returns true if the value is -// within threshold of zero. +// IS_THRESHOLD_ZERO(value, threshold) returns true if the value is within +// threshold of zero. #define IS_THRESHOLD_ZERO(value, threshold) \ ((value) < (threshold) && (value) > -(threshold)) -// IS_THRESHOLD_EQUAL(value1, value2, threshold) returns true if the -// two values are within threshold of each other. +// IS_THRESHOLD_EQUAL(value1, value2, threshold) returns true if the two +// values are within threshold of each other. #define IS_THRESHOLD_EQUAL(value1, value2, threshold) \ (IS_THRESHOLD_ZERO((value1) - (value2), threshold)) -// IS_THRESHOLD_COMPEQ(value1, value2, threshold) returns true if -// the two values are equal within threshold tolerance. Unlike -// IS_THRESHOLD_EQUAL, the transitive principle is guaranteed: -// IS_THRESHOLD_COMPEQ(a, b, t) && IS_THRESHOLD_COMPEQ(b, c, t) -// implies IS_THRESHOLD_COMPEQ(a, c, t). +// IS_THRESHOLD_COMPEQ(value1, value2, threshold) returns true if the two +// values are equal within threshold tolerance. Unlike IS_THRESHOLD_EQUAL, +// the transitive principle is guaranteed: IS_THRESHOLD_COMPEQ(a, b, t) && +// IS_THRESHOLD_COMPEQ(b, c, t) implies IS_THRESHOLD_COMPEQ(a, c, t). #define IS_THRESHOLD_COMPEQ(value1, value2, threshold) \ (cfloor(value1 / threshold + 0.5f) == cfloor(value2 / threshold + 0.5f)) -// NEARLY_ZERO(float) returns a number that is considered to be so -// close to zero as not to matter for a float. NEARLY_ZERO(double) -// returns a similar, smaller number for a double. +// NEARLY_ZERO(float) returns a number that is considered to be so close to +// zero as not to matter for a float. NEARLY_ZERO(double) returns a similar, +// smaller number for a double. #define NEARLY_ZERO(FLOATTYPE) (get_nearly_zero_value((FLOATTYPE)0)) -// IS_NEARLY_ZERO(value) returns true if the value is very close to -// zero. +// IS_NEARLY_ZERO(value) returns true if the value is very close to zero. #define IS_NEARLY_ZERO(value) \ (IS_THRESHOLD_ZERO(value, get_nearly_zero_value(value))) -// IS_NEARLY_EQUAL(value1, value2) returns true if the two values are -// very close to each other. +// IS_NEARLY_EQUAL(value1, value2) returns true if the two values are very +// close to each other. #define IS_NEARLY_EQUAL(value1, value2) \ (IS_THRESHOLD_EQUAL(value1, value2, get_nearly_zero_value(value1))) -// MAYBE_ZERO(value) returns 0 if the value is nearly zero, and the -// value itself otherwise. +// MAYBE_ZERO(value) returns 0 if the value is nearly zero, and the value +// itself otherwise. #define MAYBE_ZERO(value) \ (IS_NEARLY_ZERO(value) ? 0 : (value)) #endif - diff --git a/dtool/src/dtoolbase/neverFreeMemory.I b/dtool/src/dtoolbase/neverFreeMemory.I index 5371fe16d3..33e5b5851c 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.I +++ b/dtool/src/dtoolbase/neverFreeMemory.I @@ -1,59 +1,48 @@ -// Filename: neverFreeMemory.I -// Created by: drose (14Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file neverFreeMemory.I + * @author drose + * @date 2007-06-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::alloc -// Access: Public, Static -// Description: Returns a pointer to a newly-allocated block of -// memory of the indicated size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a newly-allocated block of memory of the indicated + * size. + */ INLINE void *NeverFreeMemory:: alloc(size_t size) { return get_global_ptr()->ns_alloc(size); } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::get_total_alloc -// Access: Published, Static -// Description: Returns the total number of bytes consumed by all the -// pages allocated internally by this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes consumed by all the pages allocated + * internally by this object. + */ INLINE size_t NeverFreeMemory:: get_total_alloc() { return get_global_ptr()->_total_alloc; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::get_total_used -// Access: Published, Static -// Description: Returns the total number of bytes requested by the -// application in calls to NeverFreeMemory::alloc(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes requested by the application in calls to + * NeverFreeMemory::alloc(). + */ INLINE size_t NeverFreeMemory:: get_total_used() { return get_global_ptr()->_total_used; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::get_total_unused -// Access: Published, Static -// Description: Returns the difference between get_total_alloc() and -// get_total_used(). This represents bytes in allocated -// pages that have not (yet) been used by the -// application. -//////////////////////////////////////////////////////////////////// +/** + * Returns the difference between get_total_alloc() and get_total_used(). + * This represents bytes in allocated pages that have not (yet) been used by + * the application. + */ INLINE size_t NeverFreeMemory:: get_total_unused() { NeverFreeMemory *global_ptr = get_global_ptr(); @@ -63,11 +52,9 @@ get_total_unused() { return total_unused; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::get_global_ptr -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NeverFreeMemory *NeverFreeMemory:: get_global_ptr() { if (_global_ptr == (NeverFreeMemory *)NULL) { @@ -76,33 +63,27 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::Page::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NeverFreeMemory::Page:: -Page(void *start, size_t size) : +Page(void *start, size_t size) : _next((unsigned char *)start), _remaining(size) { } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::Page::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool NeverFreeMemory::Page:: operator < (const NeverFreeMemory::Page &other) const { return _remaining < other._remaining; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::Page::alloc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void *NeverFreeMemory::Page:: alloc(size_t size) { assert(size <= _remaining); diff --git a/dtool/src/dtoolbase/neverFreeMemory.cxx b/dtool/src/dtoolbase/neverFreeMemory.cxx index 9779e75976..1ec800a749 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.cxx +++ b/dtool/src/dtoolbase/neverFreeMemory.cxx @@ -1,16 +1,15 @@ -// Filename: neverFreeMemory.cxx -// Created by: drose (14Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file neverFreeMemory.cxx + * @author drose + * @date 2007-06-14 + */ #include "neverFreeMemory.h" #include "atomicAdjust.h" @@ -18,42 +17,37 @@ NeverFreeMemory * TVOLATILE NeverFreeMemory::_global_ptr; -// If a page has fewer than this many bytes remaining, never mind -// about it. +// If a page has fewer than this many bytes remaining, never mind about it. static const size_t min_page_remaining_size = 16; // We always allocate at least this many bytes at a time. static const size_t min_page_size = 128 * 1024; // 128K -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NeverFreeMemory:: NeverFreeMemory() { _total_alloc = 0; _total_used = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::ns_alloc -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void *NeverFreeMemory:: ns_alloc(size_t size) { _lock.acquire(); - // We always allocate integer multiples of this many bytes, to - // guarantee this minimum alignment. + // We always allocate integer multiples of this many bytes, to guarantee + // this minimum alignment. static const size_t alignment_size = MemoryHook::get_memory_alignment(); // Round up to the next alignment_size. size = ((size + alignment_size - 1) / alignment_size) * alignment_size; _total_used += size; - + // Look for a page that has sufficient space remaining. Pages::iterator pi = _pages.lower_bound(Page(NULL, size)); @@ -69,8 +63,8 @@ ns_alloc(size_t size) { return result; } - // We have to allocate a new page. Allocate at least min_page_size - // bytes, and then round that up to the next _page_size bytes. + // We have to allocate a new page. Allocate at least min_page_size bytes, + // and then round that up to the next _page_size bytes. size_t needed_size = max(size, min_page_size); needed_size = memory_hook->round_up_to_page_size(needed_size); void *start = memory_hook->mmap_alloc(needed_size, false); @@ -85,11 +79,9 @@ ns_alloc(size_t size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NeverFreeMemory::make_global_ptr -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NeverFreeMemory:: make_global_ptr() { NeverFreeMemory *ptr = new NeverFreeMemory; @@ -100,4 +92,3 @@ make_global_ptr() { delete ptr; } } - diff --git a/dtool/src/dtoolbase/neverFreeMemory.h b/dtool/src/dtoolbase/neverFreeMemory.h index dbe84997d3..49df06a153 100644 --- a/dtool/src/dtoolbase/neverFreeMemory.h +++ b/dtool/src/dtoolbase/neverFreeMemory.h @@ -1,16 +1,15 @@ -// Filename: neverFreeMemory.h -// Created by: drose (14Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file neverFreeMemory.h + * @author drose + * @date 2007-06-14 + */ #ifndef NEVERFREEMEMORY_H #define NEVERFREEMEMORY_H @@ -20,20 +19,16 @@ #include "mutexImpl.h" #include -//////////////////////////////////////////////////////////////////// -// Class : NeverFreeMemory -// Description : This class is used to allocate bytes of memory from a -// pool that is never intended to be freed. It is -// particularly useful to support DeletedChain, which -// allocates memory in just such a fashion. -// -// When it is known that memory will not be freed, it is -// preferable to use this instead of the standard -// malloc() (or global_operator_new()) call, since this -// will help reduce fragmentation problems in the -// dynamic heap. Also, memory allocated from here will -// exhibit less wasted space. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to allocate bytes of memory from a pool that is never + * intended to be freed. It is particularly useful to support DeletedChain, + * which allocates memory in just such a fashion. + * + * When it is known that memory will not be freed, it is preferable to use + * this instead of the standard malloc() (or global_operator_new()) call, + * since this will help reduce fragmentation problems in the dynamic heap. + * Also, memory allocated from here will exhibit less wasted space. + */ class EXPCL_DTOOL NeverFreeMemory { private: NeverFreeMemory(); diff --git a/dtool/src/dtoolbase/numeric_types.h b/dtool/src/dtoolbase/numeric_types.h index daf2bdbc7b..84003ddeb4 100644 --- a/dtool/src/dtoolbase/numeric_types.h +++ b/dtool/src/dtoolbase/numeric_types.h @@ -1,25 +1,23 @@ -// Filename: numeric_types.h -// Created by: drose (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file numeric_types.h + * @author drose + * @date 2000-06-06 + */ #ifndef NUMERIC_TYPES_H #define NUMERIC_TYPES_H #include "dtoolbase.h" -// This header file defines a number of typedefs that correspond to -// the various numeric types for unsigned and signed numbers of -// various widths. +// This header file defines a number of typedefs that correspond to the +// various numeric types for unsigned and signed numbers of various widths. #if defined(WIN32_VC) && !defined(CPPPARSER) typedef signed __int8 PN_int8; @@ -58,4 +56,3 @@ typedef double PN_stdfloat; #endif // STDFLOAT_DOUBLE #endif - diff --git a/dtool/src/dtoolbase/pallocator.h b/dtool/src/dtoolbase/pallocator.h index 61d2bcb2ac..5c1c8d4d5d 100644 --- a/dtool/src/dtoolbase/pallocator.h +++ b/dtool/src/dtoolbase/pallocator.h @@ -1,16 +1,15 @@ -// Filename: pallocator.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pallocator.h + * @author drose + * @date 2001-06-05 + */ #ifndef PALLOCATOR_H #define PALLOCATOR_H @@ -21,26 +20,22 @@ #include "deletedChain.h" #include "typeHandle.h" -//////////////////////////////////////////////////////////////////// -// Class : pallocator -// Description : This is our own Panda specialization on the default -// STL allocator. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -// -// pvector, pmap, etc. are all defined in this directory -// to use a pallocator. -// -// pallocator actually comes it two flavors now: -// pallocator_single, which can only allocate single -// instances of an object, and pallocator_array, which -// can allocate arrays of objects. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL allocator. Its + * main purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + * + * pvector, pmap, etc. are all defined in this directory to use a pallocator. + * + * pallocator actually comes it two flavors now: pallocator_single, which can + * only allocate single instances of an object, and pallocator_array, which + * can allocate arrays of objects. + */ #ifndef USE_STL_ALLOCATOR -// If we're not trying to make custom allocators (either we don't know -// what kind of syntax this STL library wants, or we're compiling with -// OPTIMIZE 4), then simply use the standard allocator. +// If we're not trying to make custom allocators (either we don't know what +// kind of syntax this STL library wants, or we're compiling with OPTIMIZE 4), +// then simply use the standard allocator. #define pallocator_single allocator #define pallocator_array allocator @@ -49,8 +44,8 @@ template class pallocator_single : public allocator { public: - // Nowadays we cannot implicitly inherit typedefs from base classes - // in a template class; we must explicitly copy them here. + // Nowadays we cannot implicitly inherit typedefs from base classes in a + // template class; we must explicitly copy them here. typedef TYPENAME allocator::pointer pointer; typedef TYPENAME allocator::reference reference; typedef TYPENAME allocator::const_pointer const_pointer; @@ -67,7 +62,7 @@ public: INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); INLINE void deallocate(pointer p, size_type n); - template struct rebind { + template struct rebind { typedef pallocator_single other; }; @@ -77,8 +72,8 @@ public: template class pallocator_array : public allocator { public: - // Nowadays we cannot implicitly inherit typedefs from base classes - // in a template class; we must explicitly copy them here. + // Nowadays we cannot implicitly inherit typedefs from base classes in a + // template class; we must explicitly copy them here. typedef TYPENAME allocator::pointer pointer; typedef TYPENAME allocator::reference reference; typedef TYPENAME allocator::const_pointer const_pointer; @@ -95,7 +90,7 @@ public: INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); INLINE void deallocate(pointer p, size_type n); - template struct rebind { + template struct rebind { typedef pallocator_array other; }; @@ -107,4 +102,3 @@ public: #endif // USE_STL_ALLOCATOR #endif - diff --git a/dtool/src/dtoolbase/pdeque.h b/dtool/src/dtoolbase/pdeque.h index 8fd3837bac..eca91125cf 100644 --- a/dtool/src/dtoolbase/pdeque.h +++ b/dtool/src/dtoolbase/pdeque.h @@ -1,16 +1,15 @@ -// Filename: pdeque.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pdeque.h + * @author drose + * @date 2001-06-05 + */ #ifndef PDEQUE_H #define PDEQUE_H @@ -23,17 +22,15 @@ #ifndef USE_STL_ALLOCATOR // If we're not using custom allocators, just use the standard class // definition. -#define pdeque deque +#define pdeque deque #else -//////////////////////////////////////////////////////////////////// -// Class : pdeque -// Description : This is our own Panda specialization on the default -// STL deque. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL deque. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template class pdeque : public deque > { public: diff --git a/dtool/src/dtoolbase/plist.h b/dtool/src/dtoolbase/plist.h index 91de207835..c0ce518720 100644 --- a/dtool/src/dtoolbase/plist.h +++ b/dtool/src/dtoolbase/plist.h @@ -1,16 +1,15 @@ -// Filename: plist.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plist.h + * @author drose + * @date 2001-06-05 + */ #ifndef PLIST_H #define PLIST_H @@ -27,13 +26,11 @@ #else -//////////////////////////////////////////////////////////////////// -// Class : plist -// Description : This is our own Panda specialization on the default -// STL list. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL list. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template class plist : public list > { public: @@ -50,8 +47,8 @@ public: typedef TYPENAME base_class::reverse_iterator reverse_iterator; typedef TYPENAME base_class::const_reverse_iterator const_reverse_iterator; - // This exists because libc++'s remove implementation has a bug with - // Panda's allocator class. + // This exists because libc++'s remove implementation has a bug with Panda's + // allocator class. INLINE void remove(const Type &val) { iterator it = this->begin(); while (it != this->end()) { diff --git a/dtool/src/dtoolbase/pmap.h b/dtool/src/dtoolbase/pmap.h index 0fe55110ab..08a9b1ec22 100644 --- a/dtool/src/dtoolbase/pmap.h +++ b/dtool/src/dtoolbase/pmap.h @@ -1,16 +1,15 @@ -// Filename: pmap.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pmap.h + * @author drose + * @date 2001-06-05 + */ #ifndef PMAP_H #define PMAP_H @@ -41,13 +40,11 @@ #else // USE_STL_ALLOCATOR -//////////////////////////////////////////////////////////////////// -// Class : pmap -// Description : This is our own Panda specialization on the default -// STL map. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL map. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > class pmap : public map > > { public: @@ -66,13 +63,13 @@ public: } std::pair - insert(const TYPENAME base_class::value_type &x) { + insert(const TYPENAME base_class::value_type &x) { TAU_PROFILE("pmap::insert(const value_type &)", " ", TAU_USER); - return base_class::insert(x); + return base_class::insert(x); } TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, + insert(TYPENAME base_class::iterator position, const TYPENAME base_class::value_type &x) { TAU_PROFILE("pmap::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); @@ -111,13 +108,11 @@ public: #endif // USE_TAU }; -//////////////////////////////////////////////////////////////////// -// Class : pmultimap -// Description : This is our own Panda specialization on the default -// STL multimap. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL multimap. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > class pmultimap : public multimap > > { public: @@ -128,13 +123,11 @@ public: }; #ifdef HAVE_STL_HASH -//////////////////////////////////////////////////////////////////// -// Class : phash_map -// Description : This is our own Panda specialization on the default -// STL hash_map. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL hash_map. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > > class phash_map : public stdext::hash_map > > { public: @@ -143,13 +136,11 @@ public: phash_map(const Compare &comp) : stdext::hash_map > >(comp) { } }; -//////////////////////////////////////////////////////////////////// -// Class : phash_multimap -// Description : This is our own Panda specialization on the default -// STL hash_multimap. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL hash_multimap. Its + * main purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > > class phash_multimap : public stdext::hash_multimap > > { public: diff --git a/dtool/src/dtoolbase/pset.h b/dtool/src/dtoolbase/pset.h index 02a7378225..77bcfa2b67 100644 --- a/dtool/src/dtoolbase/pset.h +++ b/dtool/src/dtoolbase/pset.h @@ -1,16 +1,15 @@ -// Filename: pset.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pset.h + * @author drose + * @date 2001-06-05 + */ #ifndef PSET_H #define PSET_H @@ -41,13 +40,11 @@ #else // USE_STL_ALLOCATOR -//////////////////////////////////////////////////////////////////// -// Class : pset -// Description : This is our own Panda specialization on the default -// STL set. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL set. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > class pset : public set > { public: @@ -65,7 +62,7 @@ public: } TYPENAME base_class::iterator - insert(TYPENAME base_class::iterator position, + insert(TYPENAME base_class::iterator position, const TYPENAME base_class::value_type &x) { TAU_PROFILE("pset::insert(iterator, const value_type &)", " ", TAU_USER); return base_class::insert(position, x); @@ -82,7 +79,7 @@ public: TAU_PROFILE("pset::erase(const key_type &)", " ", TAU_USER); return base_class::erase(x); } - + void clear() { TAU_PROFILE("pset::clear()", " ", TAU_USER); @@ -103,13 +100,11 @@ public: #endif // USE_TAU }; -//////////////////////////////////////////////////////////////////// -// Class : pmultiset -// Description : This is our own Panda specialization on the default -// STL multiset. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL multiset. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > class pmultiset : public multiset > { public: @@ -120,13 +115,11 @@ public: }; #ifdef HAVE_STL_HASH -//////////////////////////////////////////////////////////////////// -// Class : phash_set -// Description : This is our own Panda specialization on the default -// STL hash_set. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL hash_set. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > > class phash_set : public stdext::hash_set > { public: @@ -135,13 +128,11 @@ public: phash_set(const Compare &comp) : stdext::hash_set >(comp) { } }; -//////////////////////////////////////////////////////////////////// -// Class : phash_multiset -// Description : This is our own Panda specialization on the default -// STL hash_multiset. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL hash_multiset. Its + * main purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template > > class phash_multiset : public stdext::hash_multiset > { public: diff --git a/dtool/src/dtoolbase/pstrtod.cxx b/dtool/src/dtoolbase/pstrtod.cxx index 19fa28b2e7..5a27ab6212 100644 --- a/dtool/src/dtoolbase/pstrtod.cxx +++ b/dtool/src/dtoolbase/pstrtod.cxx @@ -1,16 +1,15 @@ -// Filename: pstrtod.cxx -// Created by: drose (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pstrtod.cxx + * @author drose + * @date 2009-06-13 + */ #include "pstrtod.h" @@ -22,15 +21,12 @@ #define strncasecmp _strnicmp #endif -//////////////////////////////////////////////////////////////////// -// Function: pstrtod -// Description: This function re-implements strtod, to avoid the -// problems that occur when the LC_NUMERIC locale gets -// set to anything other than "C". Regardless of the -// user's locale, we need to be able to parse -// floating-point numbers internally understanding a "." -// as the decimal point. -//////////////////////////////////////////////////////////////////// +/** + * This function re-implements strtod, to avoid the problems that occur when + * the LC_NUMERIC locale gets set to anything other than "C". Regardless of + * the user's locale, we need to be able to parse floating-point numbers + * internally understanding a "." as the decimal point. + */ double pstrtod(const char *nptr, char **endptr) { // First, skip whitespace. @@ -49,8 +45,8 @@ pstrtod(const char *nptr, char **endptr) { double value = 0.0; if (isalpha(*p)) { - // Windows' implementation of strtod doesn't support "inf" or - // "nan", so check for those here. + // Windows' implementation of strtod doesn't support "inf" or "nan", so + // check for those here. if (strncasecmp(p, "inf", 3) == 0) { p += 3; if (strncasecmp(p, "inity", 5) == 0) { @@ -71,17 +67,17 @@ pstrtod(const char *nptr, char **endptr) { value = std::numeric_limits::quiet_NaN(); } - // It is optionally possible to include a character sequence - // between parentheses after "nan", to be passed to the new - // nan() function. Since it isn't supported universally, we - // will only accept a pair of empty parentheses. + // It is optionally possible to include a character sequence between + // parentheses after "nan", to be passed to the new nan() function. + // Since it isn't supported universally, we will only accept a pair of + // empty parentheses. if (strncmp(p, "()", 2) == 0) { p += 2; } } else { - // Pass it up to the system implementation of strtod; - // perhaps it knows how to deal with this string. + // Pass it up to the system implementation of strtod; perhaps it knows + // how to deal with this string. return strtod(nptr, endptr); } @@ -150,15 +146,12 @@ pstrtod(const char *nptr, char **endptr) { } -//////////////////////////////////////////////////////////////////// -// Function: patof -// Description: This function re-implements atof, to avoid the -// problems that occur when the LC_NUMERIC locale gets -// set to anything other than "C". Regardless of the -// user's locale, we need to be able to parse -// floating-point numbers internally understanding a "." -// as the decimal point. -//////////////////////////////////////////////////////////////////// +/** + * This function re-implements atof, to avoid the problems that occur when the + * LC_NUMERIC locale gets set to anything other than "C". Regardless of the + * user's locale, we need to be able to parse floating-point numbers + * internally understanding a "." as the decimal point. + */ double patof(const char *str) { return pstrtod(str, (char **)NULL); diff --git a/dtool/src/dtoolbase/pstrtod.h b/dtool/src/dtoolbase/pstrtod.h index fef5c844c3..7cd78f2f65 100644 --- a/dtool/src/dtoolbase/pstrtod.h +++ b/dtool/src/dtoolbase/pstrtod.h @@ -1,16 +1,15 @@ -// Filename: pstrtod.h -// Created by: drose (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pstrtod.h + * @author drose + * @date 2009-06-13 + */ #ifndef PSTRTOD_H #define PSTRTOD_H diff --git a/dtool/src/dtoolbase/pvector.h b/dtool/src/dtoolbase/pvector.h index 2bf930c591..c9d89fe942 100644 --- a/dtool/src/dtoolbase/pvector.h +++ b/dtool/src/dtoolbase/pvector.h @@ -1,16 +1,15 @@ -// Filename: pvector.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pvector.h + * @author drose + * @date 2001-06-05 + */ #ifndef PVECTOR_H #define PVECTOR_H @@ -28,13 +27,11 @@ #else -//////////////////////////////////////////////////////////////////// -// Class : pvector -// Description : This is our own Panda specialization on the default -// STL vector. Its main purpose is to call the hooks -// for MemoryUsage to properly track STL-allocated -// memory. -//////////////////////////////////////////////////////////////////// +/** + * This is our own Panda specialization on the default STL vector. Its main + * purpose is to call the hooks for MemoryUsage to properly track STL- + * allocated memory. + */ template class pvector : public vector > { public: diff --git a/dtool/src/dtoolbase/register_type.I b/dtool/src/dtoolbase/register_type.I index 7aca262e68..9d22794d20 100644 --- a/dtool/src/dtoolbase/register_type.I +++ b/dtool/src/dtoolbase/register_type.I @@ -1,27 +1,23 @@ -// Filename: register_type.I -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file register_type.I + * @author drose + * @date 2001-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: register_type -// Description: This inline function is just a convenient way to call -// TypeRegistry::register_type(), along with zero to four -// record_derivation()s. If for some reason you have a -// class that has more than four base classes (you're -// insane!), then you will need to call Register() and -// record_derivation() yourself. -//////////////////////////////////////////////////////////////////// +/** + * This inline function is just a convenient way to call + * TypeRegistry::register_type(), along with zero to four + * record_derivation()s. If for some reason you have a class that has more + * than four base classes (you're insane!), then you will need to call + * Register() and record_derivation() yourself. + */ INLINE void register_type(TypeHandle &type_handle, const string &name) { TypeRegistry::ptr()->register_type(type_handle, name); @@ -63,14 +59,12 @@ register_type(TypeHandle &type_handle, const string &name, } } -//////////////////////////////////////////////////////////////////// -// Function: register_dynamic_type -// Description: This is essentially similar to register_type(), -// except that it doesn't store a reference to any -// TypeHandle passed in and it therefore doesn't -// complain if the type is registered more than once to -// different TypeHandle reference. -//////////////////////////////////////////////////////////////////// +/** + * This is essentially similar to register_type(), except that it doesn't + * store a reference to any TypeHandle passed in and it therefore doesn't + * complain if the type is registered more than once to different TypeHandle + * reference. + */ INLINE TypeHandle register_dynamic_type(const string &name) { return TypeRegistry::ptr()->register_dynamic_type(name); diff --git a/dtool/src/dtoolbase/register_type.cxx b/dtool/src/dtoolbase/register_type.cxx index 1eff1fa75e..b67475e4f6 100644 --- a/dtool/src/dtoolbase/register_type.cxx +++ b/dtool/src/dtoolbase/register_type.cxx @@ -1,16 +1,15 @@ -// Filename: register_type.cxx -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file register_type.cxx + * @author drose + * @date 2001-08-06 + */ #include "register_type.h" diff --git a/dtool/src/dtoolbase/register_type.h b/dtool/src/dtoolbase/register_type.h index e7b6a252ee..7ea6031391 100644 --- a/dtool/src/dtoolbase/register_type.h +++ b/dtool/src/dtoolbase/register_type.h @@ -1,16 +1,15 @@ -// Filename: register_type.h -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file register_type.h + * @author drose + * @date 2001-08-06 + */ #ifndef REGISTER_TYPE_H #define REGISTER_TYPE_H @@ -20,15 +19,13 @@ #include "typeHandle.h" #include "typeRegistry.h" -//////////////////////////////////////////////////////////////////// -// Function: register_type -// Description: This inline function is just a convenient way to call -// TypeRegistry::register_type(), along with zero to four -// record_derivation()s. If for some reason you have a -// class that has more than four base classes (you're -// insane!), then you will need to call Register() and -// record_derivation() yourself. -//////////////////////////////////////////////////////////////////// +/** + * This inline function is just a convenient way to call + * TypeRegistry::register_type(), along with zero to four + * record_derivation()s. If for some reason you have a class that has more + * than four base classes (you're insane!), then you will need to call + * Register() and record_derivation() yourself. + */ INLINE void register_type(TypeHandle &type_handle, const string &name); @@ -51,14 +48,12 @@ register_type(TypeHandle &type_handle, const string &name, TypeHandle parent3, TypeHandle parent4); -//////////////////////////////////////////////////////////////////// -// Function: register_dynamic_type -// Description: This is essentially similar to register_type(), -// except that it doesn't store a reference to any -// TypeHandle passed in and it therefore doesn't -// complain if the type is registered more than once to -// different TypeHandle reference. -//////////////////////////////////////////////////////////////////// +/** + * This is essentially similar to register_type(), except that it doesn't + * store a reference to any TypeHandle passed in and it therefore doesn't + * complain if the type is registered more than once to different TypeHandle + * reference. + */ INLINE TypeHandle register_dynamic_type(const string &name); @@ -112,9 +107,8 @@ extern TypeHandle EXPCL_DTOOL pset_type_handle; void EXPCL_DTOOL init_system_type_handles(); -// The following template function and its specializations will return -// a TypeHandle for any type in the world, from a pointer to that -// type. +// The following template function and its specializations will return a +// TypeHandle for any type in the world, from a pointer to that type. template INLINE TypeHandle _get_type_handle(const T *) { @@ -222,14 +216,13 @@ INLINE TypeHandle _get_type_handle(const void * const *) { } -// The macro get_type_handle(type) is defined to make getting the type -// handle associated with a particular type a bit cleaner. +// The macro get_type_handle(type) is defined to make getting the type handle +// associated with a particular type a bit cleaner. #define get_type_handle(type) _get_type_handle((const type *)0) -// The following template function and its specializations can be used -// to call init() on any unknown type. Handy for use within a -// template class. +// The following template function and its specializations can be used to call +// init() on any unknown type. Handy for use within a template class. template INLINE void _do_init_type(const T *) { diff --git a/dtool/src/dtoolbase/selectThreadImpl.h b/dtool/src/dtoolbase/selectThreadImpl.h index 9a774ecb82..743ea98af7 100644 --- a/dtool/src/dtoolbase/selectThreadImpl.h +++ b/dtool/src/dtoolbase/selectThreadImpl.h @@ -1,39 +1,35 @@ -// Filename: selectThreadImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file selectThreadImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef SELECTTHREADIMPL_H #define SELECTTHREADIMPL_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// This file decides which of the core implementations of the various -// threading and locking implementations we should use, based on -// platform and/or available libraries. -// -// This file, along with mutexImpl.h and the various Mutex -// implementation classes, are defined in dtool so that some form of -// critical-section protection will be available to view low-level -// classes like TypeRegistry. Most of the rest of the threading and -// synchronization classes are defined in panda/src/express. -//////////////////////////////////////////////////////////////////// +/* + * This file decides which of the core implementations of the various + * threading and locking implementations we should use, based on platform + * andor available libraries. This file, along with mutexImpl.h and the + * various Mutex implementation classes, are defined in dtool so that some + * form of critical-section protection will be available to view low-level + * classes like TypeRegistry. Most of the rest of the threading and + * synchronization classes are defined in pandasrcexpress. + */ -// This keyword should be used to mark any variable which is possibly -// volatile because multiple threads might contend on it, unprotected -// by a mutex. It will be defined out in the non-threaded case. -// Other uses for volatile (dma buffers, for instance) should use the -// regular volatile keyword. +// This keyword should be used to mark any variable which is possibly volatile +// because multiple threads might contend on it, unprotected by a mutex. It +// will be defined out in the non-threaded case. Other uses for volatile (dma +// buffers, for instance) should use the regular volatile keyword. #define TVOLATILE volatile #if !defined(HAVE_THREADS) || defined(CPPPARSER) @@ -63,8 +59,8 @@ #else -// This is a configuration error. For some reason, HAVE_THREADS is -// defined but we don't have any way to implement it. +// This is a configuration error. For some reason, HAVE_THREADS is defined +// but we don't have any way to implement it. #error No thread implementation defined for platform. #endif diff --git a/dtool/src/dtoolbase/stl_compares.I b/dtool/src/dtoolbase/stl_compares.I index e68080451c..5e087faa3e 100644 --- a/dtool/src/dtoolbase/stl_compares.I +++ b/dtool/src/dtoolbase/stl_compares.I @@ -1,22 +1,19 @@ -// Filename: stl_compares.I -// Created by: drose (28Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stl_compares.I + * @author drose + * @date 2004-09-28 + */ -//////////////////////////////////////////////////////////////////// -// Function: floating_point_threshold::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE floating_point_threshold:: floating_point_threshold(Key threshold) : @@ -24,99 +21,81 @@ floating_point_threshold(Key threshold) : { } -//////////////////////////////////////////////////////////////////// -// Function: floating_point_threshold::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool floating_point_threshold:: operator () (const Key &a, const Key &b) const { return cfloor(a / _threshold + 0.5f) < cfloor(b / _threshold + 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: compare_to::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool compare_to:: operator () (const Key &a, const Key &b) const { return (a.compare_to(b) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: compare_to::is_equal -// Access: Public -// Description: Returns true if a is equivalent to b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a is equivalent to b, false otherwise. + */ template INLINE bool compare_to:: is_equal(const Key &a, const Key &b) const { return (a.compare_to(b) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_less::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool indirect_less:: operator () (const Key &a, const Key &b) const { return (a != b && (*a) < (*b)); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_compare_to::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool indirect_compare_to:: operator () (const Key &a, const Key &b) const { return (a != b && (*a).compare_to(*b) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_compare_to::is_equal -// Access: Public -// Description: Returns true if a is equivalent to b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a is equivalent to b, false otherwise. + */ template INLINE bool indirect_compare_to:: is_equal(const Key &a, const Key &b) const { return (a == b || (*a).compare_to(*b) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_compare_names::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool indirect_compare_names:: operator () (const Key &a, const Key &b) const { return (a != b && (*a).get_name() < (*b).get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_compare_names::is_equal -// Access: Public -// Description: Returns true if a is equivalent to b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a is equivalent to b, false otherwise. + */ template INLINE bool indirect_compare_names:: is_equal(const Key &a, const Key &b) const { return (a == b || (*a).get_name() == (*b).get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: integer_hash::add_hash -// Access: Public, Static -// Description: Adds the indicated key into a running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated key into a running hash. + */ template INLINE size_t integer_hash:: add_hash(size_t hash, const Key &key) { @@ -124,11 +103,9 @@ add_hash(size_t hash, const Key &key) { return AddHash::add_hash(hash, &key32, 1); } -//////////////////////////////////////////////////////////////////// -// Function: pointer_hash::add_hash -// Access: Public, Static -// Description: Adds the indicated key into a running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated key into a running hash. + */ INLINE size_t pointer_hash:: add_hash(size_t hash, const void *key) { // We don't mind if this loses precision. @@ -136,11 +113,9 @@ add_hash(size_t hash, const void *key) { return AddHash::add_hash(hash, &key32, 1); } -//////////////////////////////////////////////////////////////////// -// Function: floating_point_hash::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE floating_point_hash:: floating_point_hash(Key threshold) : @@ -148,33 +123,27 @@ floating_point_hash(Key threshold) : { } -//////////////////////////////////////////////////////////////////// -// Function: floating_point_hash::operator () -// Access: Public -// Description: Computes a size_t hash from the float. -//////////////////////////////////////////////////////////////////// +/** + * Computes a size_t hash from the float. + */ template INLINE size_t floating_point_hash:: operator () (const Key &key) const { return add_hash(0, key); } -//////////////////////////////////////////////////////////////////// -// Function: floating_point_hash::operator () (two parameters) -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool floating_point_hash:: operator () (const Key &a, const Key &b) const { return cfloor(a / _threshold + 0.5f) < cfloor(b / _threshold + 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: floating_point_hash::add_hash -// Access: Public -// Description: Adds the indicated key into a running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated key into a running hash. + */ template INLINE size_t floating_point_hash:: add_hash(size_t hash, const Key &key) const { @@ -182,24 +151,18 @@ add_hash(size_t hash, const Key &key) const { return AddHash::add_hash(hash, &key32, 1); } -//////////////////////////////////////////////////////////////////// -// Function: sequence_hash::operator () -// Access: Public -// Description: Trivially computes a size_t hash from the components -// of the string. -//////////////////////////////////////////////////////////////////// +/** + * Trivially computes a size_t hash from the components of the string. + */ template INLINE size_t sequence_hash:: operator () (const Key &key) const { return add_hash(0, key); } -//////////////////////////////////////////////////////////////////// -// Function: sequence_hash::add_hash -// Access: Public, Static -// Description: Adds the elements of the indicated key into a running -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the elements of the indicated key into a running hash. + */ template INLINE size_t sequence_hash:: add_hash(size_t hash, const Key &key) { @@ -213,44 +176,36 @@ add_hash(size_t hash, const Key &key) { return AddHash::add_hash(hash, (const PN_uint8 *)&key[0], num_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: method_hash::operator () -// Access: Public -// Description: Calls the Key's get_hash() method. -//////////////////////////////////////////////////////////////////// +/** + * Calls the Key's get_hash() method. + */ template INLINE size_t method_hash:: operator () (const Key &key) const { return key.get_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_method_hash::operator () -// Access: Public -// Description: Calls the Key's get_hash() method. -//////////////////////////////////////////////////////////////////// +/** + * Calls the Key's get_hash() method. + */ template INLINE size_t indirect_method_hash:: operator () (const Key &key) const { return (*key).get_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_equals_hash::operator () -// Access: Public -// Description: Calls the Key's get_hash() method. -//////////////////////////////////////////////////////////////////// +/** + * Calls the Key's get_hash() method. + */ template INLINE size_t indirect_equals_hash:: operator () (const Key &key) const { return (*key).get_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: indirect_equals_hash::is_equal -// Access: Public -// Description: Returns true if a is equal to b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a is equal to b, false otherwise. + */ template INLINE bool indirect_equals_hash:: is_equal(const Key &a, const Key &b) const { diff --git a/dtool/src/dtoolbase/stl_compares.h b/dtool/src/dtoolbase/stl_compares.h index 806f3722ff..57d989337a 100644 --- a/dtool/src/dtoolbase/stl_compares.h +++ b/dtool/src/dtoolbase/stl_compares.h @@ -1,16 +1,15 @@ -// Filename: stl_compares.h -// Created by: drose (28Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stl_compares.h + * @author drose + * @date 2004-09-28 + */ #ifndef STL_COMPARES_H #define STL_COMPARES_H @@ -37,8 +36,7 @@ public: #include // for less -// This is declared for the cases in which we don't have STL_HASH -// available. +// This is declared for the cases in which we don't have STL_HASH available. template > class stl_hash_compare : public Compare { public: @@ -55,11 +53,9 @@ public: #endif // HAVE_STL_HASH -//////////////////////////////////////////////////////////////////// -// Class : floating_point_threshold -// Description : Compares two floating point numbers, within threshold -// of equivalence. -//////////////////////////////////////////////////////////////////// +/** + * Compares two floating point numbers, within threshold of equivalence. + */ template class floating_point_threshold { public: @@ -68,13 +64,11 @@ public: const Key _threshold; }; -//////////////////////////////////////////////////////////////////// -// Class : compare_to -// Description : An STL function object class, this is intended to be -// used on any ordered collection of class objects that -// contain a compare_to() method. It defines the order -// of the objects via compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of class objects that contain a compare_to() method. It defines + * the order of the objects via compare_to(). + */ template class compare_to { public: @@ -82,26 +76,22 @@ public: INLINE bool is_equal(const Key &a, const Key &b) const; }; -//////////////////////////////////////////////////////////////////// -// Class : indirect_less -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that contain an operator <() method. It defines the -// order of the pointers via operator <(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that contain an operator <() method. It + * defines the order of the pointers via operator <(). + */ template class indirect_less { public: INLINE bool operator () (const Key &a, const Key &b) const; }; -//////////////////////////////////////////////////////////////////// -// Class : indirect_compare_to -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that contain a compare_to() method. It defines the -// order of the pointers via compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that contain a compare_to() method. It + * defines the order of the pointers via compare_to(). + */ template class indirect_compare_to { public: @@ -109,15 +99,12 @@ public: INLINE bool is_equal(const Key &a, const Key &b) const; }; -//////////////////////////////////////////////////////////////////// -// Class : indirect_compare_names -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that define a get_name() method, particularly for -// things that derive from Namable. It defines the -// order of the pointers by case-sensitive name -// comparison. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that define a get_name() method, + * particularly for things that derive from Namable. It defines the order of + * the pointers by case-sensitive name comparison. + */ template class indirect_compare_names { public: @@ -125,35 +112,30 @@ public: INLINE bool is_equal(const Key &a, const Key &b) const; }; -//////////////////////////////////////////////////////////////////// -// Class : integer_hash -// Description : This is the default hash_compare class, which assumes -// the Key is a size_t value or can be implicitly -// converted to a size_t value (for instance, via a -// size_t typecast operator). It is the same as the -// system-provided hash_compare. -//////////////////////////////////////////////////////////////////// +/** + * This is the default hash_compare class, which assumes the Key is a size_t + * value or can be implicitly converted to a size_t value (for instance, via a + * size_t typecast operator). It is the same as the system-provided + * hash_compare. + */ template > class integer_hash : public stl_hash_compare { public: INLINE static size_t add_hash(size_t start, const Key &key); }; -//////////////////////////////////////////////////////////////////// -// Class : pointer_hash -// Description : This is the default hash_compare class, which assumes -// the Key is a pointer value. It is the same as the -// system-provided hash_compare. -//////////////////////////////////////////////////////////////////// +/** + * This is the default hash_compare class, which assumes the Key is a pointer + * value. It is the same as the system-provided hash_compare. + */ class pointer_hash : public stl_hash_compare > { public: INLINE static size_t add_hash(size_t start, const void *key); }; -//////////////////////////////////////////////////////////////////// -// Class : floating_point_hash -// Description : This hash_compare class hashes a float or a double. -//////////////////////////////////////////////////////////////////// +/** + * This hash_compare class hashes a float or a double. + */ template class floating_point_hash : public stl_hash_compare { public: @@ -164,12 +146,10 @@ public: const Key _threshold; }; -//////////////////////////////////////////////////////////////////// -// Class : sequence_hash -// Description : This hash_compare class hashes a string. It assumes -// the Key is a string or provides begin() and end() -// methods that iterate through Key::value_type. -//////////////////////////////////////////////////////////////////// +/** + * This hash_compare class hashes a string. It assumes the Key is a string or + * provides begin() and end() methods that iterate through Key::value_type. + */ template > class sequence_hash : public stl_hash_compare { public: @@ -180,12 +160,10 @@ public: INLINE static size_t add_hash(size_t start, const Key &key); }; -//////////////////////////////////////////////////////////////////// -// Class : method_hash -// Description : This hash_compare class hashes a class object. It -// assumes the Key provides a method called get_hash() -// that returns a size_t. -//////////////////////////////////////////////////////////////////// +/** + * This hash_compare class hashes a class object. It assumes the Key provides + * a method called get_hash() that returns a size_t. + */ template > class method_hash : public stl_hash_compare { public: @@ -195,13 +173,11 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Class : indirect_method_hash -// Description : This hash_compare class hashes a pointer to a class -// object. It assumes the Key is a pointer to a class -// that provides a method called get_hash() that returns -// a size_t. -//////////////////////////////////////////////////////////////////// +/** + * This hash_compare class hashes a pointer to a class object. It assumes the + * Key is a pointer to a class that provides a method called get_hash() that + * returns a size_t. + */ template class indirect_method_hash : public stl_hash_compare { public: @@ -211,16 +187,14 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Class : indirect_equals_hash -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that contain an operator ==() method. It defines -// the equality of the pointers via operator ==(). -// -// Since it doesn't define the ordering of the pointers, -// it can only be used with hash containers. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that contain an operator ==() method. It + * defines the equality of the pointers via operator ==(). + * + * Since it doesn't define the ordering of the pointers, it can only be used + * with hash containers. + */ template class indirect_equals_hash { public: diff --git a/dtool/src/dtoolbase/test_strtod.cxx b/dtool/src/dtoolbase/test_strtod.cxx index dd61f4f03a..e2c10de958 100644 --- a/dtool/src/dtoolbase/test_strtod.cxx +++ b/dtool/src/dtoolbase/test_strtod.cxx @@ -1,16 +1,15 @@ -// Filename: test_strtod.cxx -// Created by: drose (14Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_strtod.cxx + * @author drose + * @date 2009-06-14 + */ #include "pstrtod.h" diff --git a/dtool/src/dtoolbase/typeHandle.I b/dtool/src/dtoolbase/typeHandle.I index ceb46a8e41..e002fbb1d7 100644 --- a/dtool/src/dtoolbase/typeHandle.I +++ b/dtool/src/dtoolbase/typeHandle.I @@ -1,111 +1,89 @@ -// Filename: typeHandle.I -// Created by: drose (22Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeHandle.I + * @author drose + * @date 2000-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Equality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator == (const TypeHandle &other) const { return (_index == other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Inequality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator != (const TypeHandle &other) const { return (_index != other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator < (const TypeHandle &other) const { return (_index < other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator <= (const TypeHandle &other) const { return (_index <= other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator > (const TypeHandle &other) const { return (_index > other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeHandle:: operator >= (const TypeHandle &other) const { return (_index >= other._index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::compare_to -// Access: Published -// Description: Sorts TypeHandles arbitrarily (according to <, >, -// etc.). Returns a number less than 0 if this type -// sorts before the other one, greater than zero if it -// sorts after, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Sorts TypeHandles arbitrarily (according to <, >, etc.). Returns a number + * less than 0 if this type sorts before the other one, greater than zero if + * it sorts after, 0 if they are equivalent. + */ INLINE int TypeHandle:: compare_to(const TypeHandle &other) const { return _index - other._index; } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_hash -// Access: Published -// Description: Returns a hash code suitable for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a hash code suitable for phash_map. + */ INLINE size_t TypeHandle:: get_hash() const { return (size_t)_index; } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_name -// Access: Published -// Description: Returns the name of the type. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the type. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ INLINE string TypeHandle:: get_name(TypedObject *object) const { if ((*this) == TypeHandle::none()) { @@ -115,163 +93,126 @@ get_name(TypedObject *object) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::is_derived_from -// Access: Published -// Description: Returns true if this type is derived from the -// indicated type, false otherwise. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this type is derived from the indicated type, false + * otherwise. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ INLINE bool TypeHandle:: is_derived_from(TypeHandle parent, TypedObject *object) const { return TypeRegistry::ptr()->is_derived_from(*this, parent, object); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_num_parent_classes -// Access: Published -// Description: Returns the number of parent classes that this -// type is known to have. This may then be used to -// index into get_parent_class(). The result will be 0 -// if this class does not inherit from any other -// classes, 1 if normal, single inheritance is in -// effect, or greater than one if multiple inheritance -// is in effect. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parent classes that this type is known to have. This + * may then be used to index into get_parent_class(). The result will be 0 if + * this class does not inherit from any other classes, 1 if normal, single + * inheritance is in effect, or greater than one if multiple inheritance is in + * effect. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ INLINE int TypeHandle:: get_num_parent_classes(TypedObject *object) const { return TypeRegistry::ptr()->get_num_parent_classes(*this, object); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_num_parent_classes -// Access: Published -// Description: Returns the nth parent class of this type. The index -// should be in the range 0 <= index < -// get_num_parent_classes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent class of this type. The index should be in the + * range 0 <= index < get_num_parent_classes(). + */ INLINE TypeHandle TypeHandle:: get_parent_class(int index) const { return TypeRegistry::ptr()->get_parent_class(*this, index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_num_child_classes -// Access: Published -// Description: Returns the number of child classes that this -// type is known to have. This may then be used to -// index into get_child_class(). -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child classes that this type is known to have. This + * may then be used to index into get_child_class(). + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ INLINE int TypeHandle:: get_num_child_classes(TypedObject *object) const { return TypeRegistry::ptr()->get_num_child_classes(*this, object); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_num_child_classes -// Access: Published -// Description: Returns the nth child class of this type. The index -// should be in the range 0 <= index < -// get_num_child_classes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child class of this type. The index should be in the range + * 0 <= index < get_num_child_classes(). + */ INLINE TypeHandle TypeHandle:: get_child_class(int index) const { return TypeRegistry::ptr()->get_child_class(*this, index); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_parent_towards -// Access: Published -// Description: Returns the parent class that is in a direct line of -// inheritance to the indicated ancestor class. This is -// useful in the presence of multiple inheritance to try -// to determine what properties an unknown type may -// have. -// -// The return value is TypeHandle::none() if the type -// does not inherit from the ancestor. If ancestor is -// the same as this type, the return value is this type. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent class that is in a direct line of inheritance to the + * indicated ancestor class. This is useful in the presence of multiple + * inheritance to try to determine what properties an unknown type may have. + * + * The return value is TypeHandle::none() if the type does not inherit from + * the ancestor. If ancestor is the same as this type, the return value is + * this type. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ INLINE TypeHandle TypeHandle:: get_parent_towards(TypeHandle ancestor, TypedObject *object) const { return TypeRegistry::ptr()->get_parent_towards(*this, ancestor, object); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_index -// Access: Published -// Description: Returns the integer index associated with this -// TypeHandle. Each different TypeHandle will have a -// different index. However, you probably shouldn't be -// using this method; you should just treat the -// TypeHandles as opaque classes. This is provided for -// the convenience of non-C++ scripting languages to -// build a hashtable of TypeHandles. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer index associated with this TypeHandle. Each different + * TypeHandle will have a different index. However, you probably shouldn't be + * using this method; you should just treat the TypeHandles as opaque classes. + * This is provided for the convenience of non-C++ scripting languages to + * build a hashtable of TypeHandles. + */ INLINE int TypeHandle:: get_index() const { return _index; } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypeHandle:: output(ostream &out) const { out << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::none -// Access: Published, Static -// Description: Returns a special zero-valued TypeHandle that is used -// to indicate no type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special zero-valued TypeHandle that is used to indicate no type. + */ INLINE TypeHandle TypeHandle:: none() { return _none; } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::operator bool -// Access: Published -// Description: TypeHandle::none() evaluates to false, everything -// else evaluates to true. -//////////////////////////////////////////////////////////////////// +/** + * TypeHandle::none() evaluates to false, everything else evaluates to true. + */ INLINE TypeHandle:: operator bool () const { return (_index != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::from_index -// Access: Public, Static -// Description: Creates a TypeHandle from a type index without -// error checking, for use by internal functions. -// -// See TypeRegistry::find_type_by_id(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a TypeHandle from a type index without error checking, for use by + * internal functions. + * + * See TypeRegistry::find_type_by_id(). + */ INLINE TypeHandle TypeHandle:: from_index(int index) { TypeHandle handle; diff --git a/dtool/src/dtoolbase/typeHandle.cxx b/dtool/src/dtoolbase/typeHandle.cxx index c5bb0a7005..ea3a51d6a1 100644 --- a/dtool/src/dtoolbase/typeHandle.cxx +++ b/dtool/src/dtoolbase/typeHandle.cxx @@ -1,16 +1,15 @@ -// Filename: typeHandle.cxx -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeHandle.cxx + * @author drose + * @date 1998-10-23 + */ #include "typeHandle.h" #include "typeRegistryNode.h" @@ -20,14 +19,11 @@ TypeHandle TypeHandle::_none; #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::get_memory_usage -// Access: Published -// Description: Returns the total allocated memory used by objects of -// this type, for the indicated memory class. This is -// only updated if track-memory-usage is set true in -// your Config.prc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total allocated memory used by objects of this type, for the + * indicated memory class. This is only updated if track-memory-usage is set + * true in your Config.prc file. + */ size_t TypeHandle:: get_memory_usage(MemoryClass memory_class) const { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); @@ -42,12 +38,10 @@ get_memory_usage(MemoryClass memory_class) const { #endif // DO_MEMORY_USAGE #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::inc_memory_usage -// Access: Published -// Description: Adds the indicated amount to the record for the total -// allocated memory for objects of this type. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated amount to the record for the total allocated memory for + * objects of this type. + */ void TypeHandle:: inc_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); @@ -55,7 +49,8 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); assert(rnode != (TypeRegistryNode *)NULL); AtomicAdjust::add(rnode->_memory_usage[memory_class], (AtomicAdjust::Integer)size); - //cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << rnode->_memory_usage[memory_class] << "\n"; + // cerr << *this << ".inc(" << memory_class << ", " << size << ") -> " << + // rnode->_memory_usage[memory_class] << "\n"; if (rnode->_memory_usage[memory_class] < 0) { cerr << "Memory usage overflow for type " << *this << ".\n"; abort(); @@ -65,12 +60,10 @@ inc_memory_usage(MemoryClass memory_class, size_t size) { #endif // DO_MEMORY_USAGE #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::dec_memory_usage -// Access: Published -// Description: Subtracts the indicated amount from the record for -// the total allocated memory for objects of this type. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts the indicated amount from the record for the total allocated + * memory for objects of this type. + */ void TypeHandle:: dec_memory_usage(MemoryClass memory_class, size_t size) { assert((int)memory_class >= 0 && (int)memory_class < (int)MC_limit); @@ -78,17 +71,16 @@ dec_memory_usage(MemoryClass memory_class, size_t size) { TypeRegistryNode *rnode = TypeRegistry::ptr()->look_up(*this, NULL); assert(rnode != (TypeRegistryNode *)NULL); AtomicAdjust::add(rnode->_memory_usage[memory_class], -(AtomicAdjust::Integer)size); - //cerr << *this << ".dec(" << memory_class << ", " << size << ") -> " << rnode->_memory_usage[memory_class] << "\n"; + // cerr << *this << ".dec(" << memory_class << ", " << size << ") -> " << + // rnode->_memory_usage[memory_class] << "\n"; assert(rnode->_memory_usage[memory_class] >= 0); } } #endif // DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: get_best_parent_from_Set -// Access: Published -// Description: Return the Index of the BEst fit Classs from a set -//////////////////////////////////////////////////////////////////// +/** + * Return the Index of the BEst fit Classs from a set + */ int TypeHandle:: get_best_parent_from_Set(const std::set< int > &legal_vals) const { if (legal_vals.find(_index) != legal_vals.end()) { diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index ea3ef66346..ca0d1874f6 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -1,16 +1,15 @@ -// Filename: typeHandle.h -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeHandle.h + * @author drose + * @date 1998-10-23 + */ #ifndef TYPEHANDLE_H #define TYPEHANDLE_H @@ -19,69 +18,42 @@ #include -// The following illustrates the convention for declaring a type that -// uses TypeHandle. In this example, ThisThingie inherits from -// TypedObject, which automatically supplies some type-differentiation -// functions at the cost of one virtual function, get_type(); however, -// this inheritance is optional, and may be omitted to avoid the -// virtual function pointer overhead. (If you do use TypedObject, be -// sure to consider whether your destructor should also be virtual.) +// The following illustrates the convention for declaring a type that uses +// TypeHandle. In this example, ThisThingie inherits from TypedObject, which +// automatically supplies some type-differentiation functions at the cost of +// one virtual function, get_type(); however, this inheritance is optional, +// and may be omitted to avoid the virtual function pointer overhead. (If you +// do use TypedObject, be sure to consider whether your destructor should also +// be virtual.) -// -// class ThatThingie : public SimpleTypedObject { -// public: -// static TypeHandle get_class_type() { -// return _type_handle; -// } -// static void init_type() { -// register_type(_type_handle, "ThatThingie"); -// } -// -// private: -// static TypeHandle _type_handle; -// }; -// -// class ThisThingie : public ThatThingie, publid TypedObject { -// public: -// static TypeHandle get_class_type() { -// return _type_handle; -// } -// static void init_type() { -// ThatThingie::init_type(); -// TypedObject::init_type(); -// register_type(_type_handle, "ThisThingie", -// ThatThingie::get_class_type(), -// TypedObject::get_class_type()); -// } -// virtual TypeHandle get_type() const { -// return get_class_type(); -// } -// -// private: -// static TypeHandle _type_handle; -// }; -// +/* + * class ThatThingie : public SimpleTypedObject { public: static TypeHandle + * get_class_type() { return _type_handle; } static void init_type() { + * register_type(_type_handle, "ThatThingie"); } private: static TypeHandle + * _type_handle; }; class ThisThingie : public ThatThingie, publid TypedObject + * { public: static TypeHandle get_class_type() { return _type_handle; } + * static void init_type() { ThatThingie::init_type(); + * TypedObject::init_type(); register_type(_type_handle, "ThisThingie", + * ThatThingie::get_class_type(), TypedObject::get_class_type()); } virtual + * TypeHandle get_type() const { return get_class_type(); } private: static + * TypeHandle _type_handle; }; + */ class TypedObject; -//////////////////////////////////////////////////////////////////// -// Class : TypeHandle -// Description : TypeHandle is the identifier used to differentiate -// C++ class types. Any C++ classes that inherit from -// some base class, and must be differentiated at run -// time, should store a static TypeHandle object that -// can be queried through a static member function -// named get_class_type(). Most of the time, it is also -// desirable to inherit from TypedObject, which provides -// some virtual functions to return the TypeHandle for a -// particular instance. -// -// At its essence, a TypeHandle is simply a unique -// identifier that is assigned by the TypeRegistry. The -// TypeRegistry stores a tree of TypeHandles, so that -// ancestry of a particular type may be queried, and the -// type name may be retrieved for run-time display. -//////////////////////////////////////////////////////////////////// +/** + * TypeHandle is the identifier used to differentiate C++ class types. Any + * C++ classes that inherit from some base class, and must be differentiated + * at run time, should store a static TypeHandle object that can be queried + * through a static member function named get_class_type(). Most of the time, + * it is also desirable to inherit from TypedObject, which provides some + * virtual functions to return the TypeHandle for a particular instance. + * + * At its essence, a TypeHandle is simply a unique identifier that is assigned + * by the TypeRegistry. The TypeRegistry stores a tree of TypeHandles, so + * that ancestry of a particular type may be queried, and the type name may be + * retrieved for run-time display. + */ class EXPCL_DTOOL TypeHandle FINAL { PUBLISHED: enum MemoryClass { @@ -94,10 +66,10 @@ PUBLISHED: // enum value. }; - // The default constructor must do nothing, because we can't - // guarantee ordering of static initializers. If the constructor - // tried to initialize its value, it might happen after the value - // had already been set previously by another static initializer! + // The default constructor must do nothing, because we can't guarantee + // ordering of static initializers. If the constructor tried to initialize + // its value, it might happen after the value had already been set + // previously by another static initializer! EXTENSION(static TypeHandle make(PyTypeObject *classobj)); @@ -154,8 +126,8 @@ private: }; -// It's handy to be able to output a TypeHandle directly, and see the -// type name. +// It's handy to be able to output a TypeHandle directly, and see the type +// name. INLINE ostream &operator << (ostream &out, TypeHandle type) { type.output(out); return out; @@ -163,9 +135,9 @@ INLINE ostream &operator << (ostream &out, TypeHandle type) { EXPCL_DTOOL ostream &operator << (ostream &out, TypeHandle::MemoryClass mem_class); -// We must include typeRegistry at this point so we can call it from -// our inline functions. This is a circular include that is -// strategically placed to do no harm. +// We must include typeRegistry at this point so we can call it from our +// inline functions. This is a circular include that is strategically placed +// to do no harm. /* okcircular */ #include "typeRegistry.h" diff --git a/dtool/src/dtoolbase/typeRegistry.I b/dtool/src/dtoolbase/typeRegistry.I index 3ba8796c45..f0105c1eda 100644 --- a/dtool/src/dtoolbase/typeRegistry.I +++ b/dtool/src/dtoolbase/typeRegistry.I @@ -1,25 +1,20 @@ -// Filename: typeRegistry.I -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistry.I + * @author drose + * @date 2001-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::freshen_derivations -// Access: Private -// Description: Rebuilds the derivation data structures after some -// derivation relationship has been modified, so that -// class relationships can quickly be determined. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the derivation data structures after some derivation relationship + * has been modified, so that class relationships can quickly be determined. + */ INLINE void TypeRegistry:: freshen_derivations() { if (!_derivations_fresh) { @@ -28,11 +23,9 @@ freshen_derivations() { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::init_lock -// Access: Private, Static -// Description: Ensures the lock pointer has been allocated. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the lock pointer has been allocated. + */ INLINE void TypeRegistry:: init_lock() { if (_lock == (MutexImpl *)NULL) { @@ -40,21 +33,17 @@ init_lock() { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::look_up -// Access: Private -// Description: Returns the TypeRegistryNode associated with the -// indicated TypeHandle. If there is no associated -// TypeRegistryNode, reports an error condition and -// returns NULL. -// -// The associated TypedObject pointer is the pointer to -// the object that owns the handle, if available. It is -// only used in an error condition, if for some reason -// the handle was uninitialized. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeRegistryNode associated with the indicated TypeHandle. If + * there is no associated TypeRegistryNode, reports an error condition and + * returns NULL. + * + * The associated TypedObject pointer is the pointer to the object that owns + * the handle, if available. It is only used in an error condition, if for + * some reason the handle was uninitialized. + * + * Assumes the lock is already held. + */ INLINE TypeRegistryNode *TypeRegistry:: look_up(TypeHandle handle, TypedObject *object) const { #ifndef NDEBUG diff --git a/dtool/src/dtoolbase/typeRegistry.cxx b/dtool/src/dtoolbase/typeRegistry.cxx index 6d9e1757cd..a0393cb81c 100644 --- a/dtool/src/dtoolbase/typeRegistry.cxx +++ b/dtool/src/dtoolbase/typeRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: typeRegistry.cxx -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistry.cxx + * @author drose + * @date 2001-08-06 + */ #include "typeRegistry.h" #include "typeRegistryNode.h" @@ -24,24 +23,20 @@ MutexImpl *TypeRegistry::_lock = NULL; TypeRegistry *TypeRegistry::_global_pointer = NULL; -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::register_type -// Access: Public -// Description: Creates a new Type of the given name and assigns a -// unique value to the type_handle. All type names must -// be unique. If the type name has already been used, -// the supplied type_handle value must match the name's -// assigned type_handle or an error is triggered. -// Returns true if the name wasn't defined before, false -// if it was. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Type of the given name and assigns a unique value to the + * type_handle. All type names must be unique. If the type name has already + * been used, the supplied type_handle value must match the name's assigned + * type_handle or an error is triggered. Returns true if the name wasn't + * defined before, false if it was. + */ bool TypeRegistry:: register_type(TypeHandle &type_handle, const string &name) { _lock->acquire(); if (type_handle != TypeHandle::none()) { - // Here's a type that was already registered. Just make sure - // everything's still kosher. + // Here's a type that was already registered. Just make sure everything's + // still kosher. TypeRegistryNode *rnode = look_up(type_handle, NULL); if (&type_handle == &rnode->_ref) { // No problem. @@ -55,8 +50,8 @@ register_type(TypeHandle &type_handle, const string &name) { ri = _name_registry.find(name); if (ri == _name_registry.end()) { - // The name was not already used; this is the first time this - // class has been defined. + // The name was not already used; this is the first time this class has + // been defined. TypeHandle new_handle; new_handle._index = (int)_handle_registry.size(); @@ -86,11 +81,10 @@ register_type(TypeHandle &type_handle, const string &name) { _lock->release(); return false; } - // But wait--the type_handle has changed! We kept a reference to - // the static _type_handle member in the class that was passed in - // at the first call to register_type(), and we got the same - // reference passed in this time, but now it's different! Bad - // juju. + // But wait--the type_handle has changed! We kept a reference to the + // static _type_handle member in the class that was passed in at the first + // call to register_type(), and we got the same reference passed in this + // time, but now it's different! Bad juju. cerr << "Reregistering " << name << "\n"; type_handle = rnode->_handle; _lock->release(); @@ -102,10 +96,10 @@ register_type(TypeHandle &type_handle, const string &name) { cerr << "Attempt to register type " << name << " more than once!\n"; - // This is invalid, but we'll allow it anyway. It seems to happen - // for some reason under GNU libc5 that we occasionally end up - // with two legitimate copies of the same class object in - // memory--each with its own static _type_handle member. + // This is invalid, but we'll allow it anyway. It seems to happen for + // some reason under GNU libc5 that we occasionally end up with two + // legitimate copies of the same class object in memory--each with its own + // static _type_handle member. type_handle = rnode->_handle; } @@ -113,15 +107,11 @@ register_type(TypeHandle &type_handle, const string &name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::register_dynamic_type -// Access: Public -// Description: Registers a new type on-the-fly, presumably at -// runtime. A new TypeHandle is returned if the -// typename was not seen before; otherwise the same -// TypeHandle that was last used for this typename is -// returned. -//////////////////////////////////////////////////////////////////// +/** + * Registers a new type on-the-fly, presumably at runtime. A new TypeHandle + * is returned if the typename was not seen before; otherwise the same + * TypeHandle that was last used for this typename is returned. + */ TypeHandle TypeRegistry:: register_dynamic_type(const string &name) { _lock->acquire(); @@ -130,12 +120,12 @@ register_dynamic_type(const string &name) { ri = _name_registry.find(name); if (ri == _name_registry.end()) { - // The name was not already used; this is the first time this - // class has been defined. + // The name was not already used; this is the first time this class has + // been defined. - // We must dynamically allocate a new handle so the TypeRegistryNode - // has something unique to point to. This doesn't really mean - // anything, though. + // We must dynamically allocate a new handle so the TypeRegistryNode has + // something unique to point to. This doesn't really mean anything, + // though. TypeHandle *new_handle = new TypeHandle; new_handle->_index = (int)_handle_registry.size(); @@ -155,14 +145,11 @@ register_dynamic_type(const string &name) { return handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::record_derivation -// Access: Public -// Description: Records that the type referenced by child inherits -// directly from the type referenced by parent. In the -// event of multiple inheritance, this should be called -// once for each parent class. -//////////////////////////////////////////////////////////////////// +/** + * Records that the type referenced by child inherits directly from the type + * referenced by parent. In the event of multiple inheritance, this should be + * called once for each parent class. + */ void TypeRegistry:: record_derivation(TypeHandle child, TypeHandle parent) { _lock->acquire(); @@ -172,8 +159,8 @@ record_derivation(TypeHandle child, TypeHandle parent) { TypeRegistryNode *pnode = look_up(parent, NULL); assert(pnode != (TypeRegistryNode *)NULL); - // First, we'll just run through the list to make sure we hadn't - // already made this connection. + // First, we'll just run through the list to make sure we hadn't already + // made this connection. TypeRegistryNode::Classes::iterator ni; ni = find(cnode->_parent_classes.begin(), cnode->_parent_classes.end(), pnode); @@ -187,15 +174,12 @@ record_derivation(TypeHandle child, TypeHandle parent) { _lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::record_alternate_name -// Access: Public -// Description: Indicates an alternate name for the same type. This -// is particularly useful when a type has changed names, -// since the type is stored in a Bam file by name; -// setting the original name as the alternate will allow -// the type to be correctly read from old Bam files. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an alternate name for the same type. This is particularly useful + * when a type has changed names, since the type is stored in a Bam file by + * name; setting the original name as the alternate will allow the type to be + * correctly read from old Bam files. + */ void TypeRegistry:: record_alternate_name(TypeHandle type, const string &name) { _lock->acquire(); @@ -218,13 +202,10 @@ record_alternate_name(TypeHandle type, const string &name) { _lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::find_type -// Access: Published -// Description: Looks for a previously-registered type of the given -// name. Returns its TypeHandle if it exists, or -// TypeHandle::none() if there is no such type. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a previously-registered type of the given name. Returns its + * TypeHandle if it exists, or TypeHandle::none() if there is no such type. + */ TypeHandle TypeRegistry:: find_type(const string &name) const { _lock->acquire(); @@ -240,14 +221,11 @@ find_type(const string &name) const { return handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::find_type_by_id -// Access: Published -// Description: Looks for a previously-registered type with the given -// id number (as returned by TypeHandle::get_index()). -// Returns its TypeHandle if it exists, or -// TypeHandle::none() if there is no such type. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a previously-registered type with the given id number (as + * returned by TypeHandle::get_index()). Returns its TypeHandle if it exists, + * or TypeHandle::none() if there is no such type. + */ TypeHandle TypeRegistry:: find_type_by_id(int id) const { if (id < 0 ||id >= (int)_handle_registry.size()) { @@ -261,16 +239,13 @@ find_type_by_id(int id) const { } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_name -// Access: Published -// Description: Returns the name of the indicated type. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated type. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ string TypeRegistry:: get_name(TypeHandle type, TypedObject *object) const { _lock->acquire(); @@ -282,24 +257,19 @@ get_name(TypeHandle type, TypedObject *object) const { return name; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::is_derived_from -// Access: Published -// Description: Returns true if the first type is derived from the -// second type, false otherwise. -// -// The "child_object" pointer is an optional pointer to -// the TypedObject class that owns the child TypeHandle. -// It is only used in case the TypeHandle is -// inadvertently undefined. -// -// This function definition follows the definitions for -// look_up() and freshen_derivations() just to maximize -// the chance the the compiler will be able to inline -// the above functions. Yeah, a compiler shouldn't -// care, but there's a big different between "shouldn't" -// and "doesn't". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the first type is derived from the second type, false + * otherwise. + * + * The "child_object" pointer is an optional pointer to the TypedObject class + * that owns the child TypeHandle. It is only used in case the TypeHandle is + * inadvertently undefined. + * + * This function definition follows the definitions for look_up() and + * freshen_derivations() just to maximize the chance the the compiler will be + * able to inline the above functions. Yeah, a compiler shouldn't care, but + * there's a big different between "shouldn't" and "doesn't". + */ bool TypeRegistry:: is_derived_from(TypeHandle child, TypeHandle base, TypedObject *child_object) { @@ -318,12 +288,9 @@ is_derived_from(TypeHandle child, TypeHandle base, return result; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_num_type_handles -// Access: Published -// Description: Returns the total number of unique TypeHandles in the -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique TypeHandles in the system. + */ int TypeRegistry:: get_num_typehandles() { _lock->acquire(); @@ -332,12 +299,9 @@ get_num_typehandles() { return num_types; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_typehandle -// Access: Published -// Description: Returns the nth TypeHandle in the system. See -// get_num_typehandles(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth TypeHandle in the system. See get_num_typehandles(). + */ TypeHandle TypeRegistry:: get_typehandle(int n) { _lock->acquire(); @@ -354,13 +318,10 @@ get_typehandle(int n) { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_num_root_classes -// Access: Published -// Description: Returns the number of root classes--that is, classes -// that do not inherit from any other classes--known in -// the system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of root classes--that is, classes that do not inherit + * from any other classes--known in the system. + */ int TypeRegistry:: get_num_root_classes() { _lock->acquire(); @@ -370,12 +331,9 @@ get_num_root_classes() { return num_roots; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_root_class -// Access: Published -// Description: Returns the nth root class in the system. See -// get_num_root_classes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth root class in the system. See get_num_root_classes(). + */ TypeHandle TypeRegistry:: get_root_class(int n) { _lock->acquire(); @@ -389,22 +347,17 @@ get_root_class(int n) { return handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_num_parent_classes -// Access: Published -// Description: Returns the number of parent classes that the -// indicated type is known to have. This may then be -// used to index into get_parent_class(). The result -// will be 0 if this class does not inherit from any -// other classes, 1 if normal, single inheritance is in -// effect, or greater than one if multiple inheritance -// is in effect. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parent classes that the indicated type is known to + * have. This may then be used to index into get_parent_class(). The result + * will be 0 if this class does not inherit from any other classes, 1 if + * normal, single inheritance is in effect, or greater than one if multiple + * inheritance is in effect. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ int TypeRegistry:: get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { _lock->acquire(); @@ -415,13 +368,10 @@ get_num_parent_classes(TypeHandle child, TypedObject *child_object) const { return num_parents; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_parent_class -// Access: Published -// Description: Returns the nth parent class of this type. The index -// should be in the range 0 <= index < -// get_num_parent_classes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent class of this type. The index should be in the + * range 0 <= index < get_num_parent_classes(). + */ TypeHandle TypeRegistry:: get_parent_class(TypeHandle child, int index) const { _lock->acquire(); @@ -435,18 +385,14 @@ get_parent_class(TypeHandle child, int index) const { return handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_num_child_classes -// Access: Published -// Description: Returns the number of child classes that the -// indicated type is known to have. This may then be -// used to index into get_child_class(). -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child classes that the indicated type is known to + * have. This may then be used to index into get_child_class(). + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ int TypeRegistry:: get_num_child_classes(TypeHandle child, TypedObject *child_object) const { _lock->acquire(); @@ -457,13 +403,10 @@ get_num_child_classes(TypeHandle child, TypedObject *child_object) const { return num_children; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_child_class -// Access: Published -// Description: Returns the nth child class of this type. The index -// should be in the range 0 <= index < -// get_num_child_classes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child class of this type. The index should be in the range + * 0 <= index < get_num_child_classes(). + */ TypeHandle TypeRegistry:: get_child_class(TypeHandle child, int index) const { _lock->acquire(); @@ -477,20 +420,16 @@ get_child_class(TypeHandle child, int index) const { return handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::get_parent_towards -// Access: Published -// Description: Returns the parent of the indicated child class that -// is in a direct line of inheritance to the indicated -// ancestor class. This is useful in the presence of -// multiple inheritance to try to determine what -// properties an unknown type may have. -// -// The "object" pointer is an optional pointer to the -// TypedObject class that owns this TypeHandle. It is -// only used in case the TypeHandle is inadvertantly -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent of the indicated child class that is in a direct line of + * inheritance to the indicated ancestor class. This is useful in the + * presence of multiple inheritance to try to determine what properties an + * unknown type may have. + * + * The "object" pointer is an optional pointer to the TypedObject class that + * owns this TypeHandle. It is only used in case the TypeHandle is + * inadvertantly undefined. + */ TypeHandle TypeRegistry:: get_parent_towards(TypeHandle child, TypeHandle base, TypedObject *child_object) { @@ -507,17 +446,13 @@ get_parent_towards(TypeHandle child, TypeHandle base, } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::reregister_types -// Access: Published, Static -// Description: Walks through the TypeRegistry tree and makes sure -// that each type that was previously registered is -// *still* registered. This seems to get broken in -// certain circumstances when compiled against libc5--it -// is as if the static initializer stomps on the -// _type_handle values of each class after they've been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the TypeRegistry tree and makes sure that each type that was + * previously registered is *still* registered. This seems to get broken in + * certain circumstances when compiled against libc5--it is as if the static + * initializer stomps on the _type_handle values of each class after they've + * been registered. + */ void TypeRegistry:: reregister_types() { init_lock(); @@ -536,13 +471,10 @@ reregister_types() { } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::write -// Access: Published -// Description: Makes an attempt to format the entire TypeRegistry in -// a nice way that shows the derivation tree as -// intelligently as possible. -//////////////////////////////////////////////////////////////////// +/** + * Makes an attempt to format the entire TypeRegistry in a nice way that shows + * the derivation tree as intelligently as possible. + */ void TypeRegistry:: write(ostream &out) const { _lock->acquire(); @@ -550,12 +482,9 @@ write(ostream &out) const { _lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::ptr -// Access: Published, Static -// Description: Returns the pointer to the global TypeRegistry -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the global TypeRegistry object. + */ TypeRegistry *TypeRegistry:: ptr() { init_lock(); @@ -567,24 +496,21 @@ ptr() { return _global_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TypeRegistry:: TypeRegistry() { // We'll start out our handle_registry with a default entry for the - // TypeHandles whose index number is zero, and are therefore - // (probably) uninitialized. + // TypeHandles whose index number is zero, and are therefore (probably) + // uninitialized. _handle_registry.push_back(NULL); _derivations_fresh = false; - // Here's a few sanity checks on the sizes of our words. We have to - // put it here, at runtime, since there doesn't appear to be a - // cross-platform compile-time way to verify that we've chosen the - // right word sizes. + // Here's a few sanity checks on the sizes of our words. We have to put it + // here, at runtime, since there doesn't appear to be a cross-platform + // compile-time way to verify that we've chosen the right word sizes. assert(sizeof(PN_uint8) == 1 && sizeof(PN_int8) == 1); assert(sizeof(PN_uint16) == 2 && sizeof(PN_int16) == 2); assert(sizeof(PN_uint32) == 4 && sizeof(PN_int32) == 4); @@ -594,25 +520,19 @@ TypeRegistry() { assert(sizeof(PN_float64) == 8); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::init_global_pointer -// Access: Private, Static -// Description: Constructs the TypeRegistry object for the first -// time. -//////////////////////////////////////////////////////////////////// +/** + * Constructs the TypeRegistry object for the first time. + */ void TypeRegistry:: init_global_pointer() { init_memory_hook(); _global_pointer = new TypeRegistry; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::rebuild_derivations -// Access: Private -// Description: Rebuilds the derivation data structures after some -// derivation relationship has been modified, so that -// class relationships can quickly be determined. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the derivation data structures after some derivation relationship + * has been modified, so that class relationships can quickly be determined. + */ void TypeRegistry:: rebuild_derivations() { // First, remove all of the old data from the last type @@ -629,8 +549,8 @@ rebuild_derivations() { } } - // Start by getting the list of root classes: those classes which do - // not derive from anything. + // Start by getting the list of root classes: those classes which do not + // derive from anything. for (hi = _handle_registry.begin(); hi != _handle_registry.end(); ++hi) { @@ -644,16 +564,14 @@ rebuild_derivations() { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::do_write -// Access: Private -// Description: The private implementation of write(), this assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of write(), this assumes the lock is already + * held. + */ void TypeRegistry:: do_write(ostream &out) const { - // Recursively write out the tree, starting from each node that has - // no parent. + // Recursively write out the tree, starting from each node that has no + // parent. HandleRegistry::const_iterator hi; for (hi = _handle_registry.begin(); hi != _handle_registry.end(); @@ -665,12 +583,10 @@ do_write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::write_node -// Access: Private -// Description: Writes a single TypeRegistryNode out, along with all of -// its descendants. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Writes a single TypeRegistryNode out, along with all of its descendants. + * Assumes the lock is already held. + */ void TypeRegistry:: write_node(ostream &out, int indent_level, const TypeRegistryNode *node) const { indent(out, indent_level) << node->_handle.get_index() << " " << node->_name; @@ -687,16 +603,13 @@ write_node(ostream &out, int indent_level, const TypeRegistryNode *node) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistry::look_up_invalid -// Access: Private -// Description: Called by look_up when it detects an invalid -// TypeHandle pointer. In non-release builds, this -// method will do what it can to recover from this -// and initialize the type anyway. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called by look_up when it detects an invalid TypeHandle pointer. In non- + * release builds, this method will do what it can to recover from this and + * initialize the type anyway. + * + * Assumes the lock is already held. + */ TypeRegistryNode *TypeRegistry:: look_up_invalid(TypeHandle handle, TypedObject *object) const { #ifndef NDEBUG @@ -704,9 +617,9 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { // The TypeHandle is unregistered. This is an error condition. if (object != NULL) { - // But we're lucky enough to have a TypedObject pointer handy! - // Maybe we can use it to resolve the error. We have to drop - // the lock while we do this, so we don't get a recursive lock. + // But we're lucky enough to have a TypedObject pointer handy! Maybe we + // can use it to resolve the error. We have to drop the lock while we + // do this, so we don't get a recursive lock. _lock->release(); handle = object->force_init_type(); _lock->acquire(); @@ -718,8 +631,8 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { return NULL; } - // Now get the name for printing. We can't use TypeHandle:: - // get_name() since that recursively calls look_up(). + // Now get the name for printing. We can't use TypeHandle:: get_name() + // since that recursively calls look_up(). ostringstream name; if (handle._index > 0 && handle._index < (int)_handle_registry.size()) { TypeRegistryNode *rnode = _handle_registry[handle._index]; @@ -738,9 +651,8 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { cerr << "Type " << name.str() << " was unregistered!\n"; } else { - // No good; it looks like the TypeHandle belongs to a class - // that defined get_type(), but didn't define - // force_init_type(). + // No good; it looks like the TypeHandle belongs to a class that + // defined get_type(), but didn't define force_init_type(). cerr << "Attempt to reference unregistered TypeHandle. Type is of some\n" << "class derived from type " << name.str() << " that doesn't define\n" @@ -749,8 +661,8 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { } } else { - // We don't have a TypedObject pointer, so there's nothing we - // can do about it. + // We don't have a TypedObject pointer, so there's nothing we can do + // about it. cerr << "Attempt to reference unregistered TypeHandle!\n" << "Registered TypeHandles are:\n"; @@ -771,10 +683,9 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const { return _handle_registry[handle._index]; } -//////////////////////////////////////////////////////////////////// -// Function: get_best_parent_from_Set -// Access: Private -//////////////////////////////////////////////////////////////////// +/** + + */ extern "C" int get_best_parent_from_Set(int id, const std::set &this_set) { // most common case.. diff --git a/dtool/src/dtoolbase/typeRegistry.h b/dtool/src/dtoolbase/typeRegistry.h index e687a7a9ea..1526b6bc2f 100644 --- a/dtool/src/dtoolbase/typeRegistry.h +++ b/dtool/src/dtoolbase/typeRegistry.h @@ -1,16 +1,15 @@ -// Filename: typeRegistry.h -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistry.h + * @author drose + * @date 2001-08-06 + */ #ifndef TYPEREGISTRY_H #define TYPEREGISTRY_H @@ -27,21 +26,18 @@ class TypeHandle; class TypeRegistryNode; class TypedObject; -//////////////////////////////////////////////////////////////////// -// Class : TypeRegistry -// Description : The TypeRegistry class maintains all the assigned -// TypeHandles in a given system. There should be only -// one TypeRegistry class during the lifetime of the -// application. It will be created on the local heap -// initially, and it should be migrated to shared memory -// as soon as shared memory becomes available. -//////////////////////////////////////////////////////////////////// +/** + * The TypeRegistry class maintains all the assigned TypeHandles in a given + * system. There should be only one TypeRegistry class during the lifetime of + * the application. It will be created on the local heap initially, and it + * should be migrated to shared memory as soon as shared memory becomes + * available. + */ class EXPCL_DTOOL TypeRegistry : public MemoryBase { public: - // User code shouldn't generally need to call - // TypeRegistry::register_type() or record_derivation() directly; - // instead, use the register_type convenience function, defined - // below. + // User code shouldn't generally need to call TypeRegistry::register_type() + // or record_derivation() directly; instead, use the register_type + // convenience function, defined below. bool register_type(TypeHandle &type_handle, const string &name); TypeHandle register_dynamic_type(const string &name); @@ -83,8 +79,8 @@ PUBLISHED: static TypeRegistry *ptr(); private: - // The TypeRegistry class should never be constructed by user code. - // There is only one in the universe, and it constructs itself! + // The TypeRegistry class should never be constructed by user code. There + // is only one in the universe, and it constructs itself! TypeRegistry(); static void init_global_pointer(); diff --git a/dtool/src/dtoolbase/typeRegistryNode.I b/dtool/src/dtoolbase/typeRegistryNode.I index b29ddd31f5..c9298aae27 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.I +++ b/dtool/src/dtoolbase/typeRegistryNode.I @@ -1,23 +1,19 @@ -// Filename: typeRegistryNode.I -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistryNode.I + * @author drose + * @date 2001-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeRegistryNode::Inherit:: Inherit() { _top = (TypeRegistryNode *)NULL; @@ -25,11 +21,9 @@ Inherit() { _bits = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeRegistryNode::Inherit:: Inherit(TypeRegistryNode *top, int bit_count, TypeRegistryNode::SubtreeMaskType bits) { @@ -44,11 +38,9 @@ Inherit(TypeRegistryNode *top, int bit_count, _bits = bits; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeRegistryNode::Inherit:: Inherit(const TypeRegistryNode::Inherit ©) : _top(copy._top), @@ -57,11 +49,9 @@ Inherit(const TypeRegistryNode::Inherit ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypeRegistryNode::Inherit:: operator = (const TypeRegistryNode::Inherit ©) { _top = copy._top; @@ -69,32 +59,27 @@ operator = (const TypeRegistryNode::Inherit ©) { _bits = copy._bits; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::Ordering operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TypeRegistryNode::Inherit:: operator < (const Inherit &other) const { return _top < other._top; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Inherit::is_derived_from -// Access: Public -// Description: Assuming the two Inherit objects share the same -// subtree top, this returns true if the bitmasks -// indicate that child inherits from base, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the two Inherit objects share the same subtree top, this returns + * true if the bitmasks indicate that child inherits from base, or false + * otherwise. + */ INLINE bool TypeRegistryNode::Inherit:: -is_derived_from(const TypeRegistryNode::Inherit &child, +is_derived_from(const TypeRegistryNode::Inherit &child, const TypeRegistryNode::Inherit &base) { assert(child._top == base._top); - // Child derives from base if and only if its subtree mask contains - // more bits (or the same number of bits), and the n low-order - // subtree bits that are in common are identical. + // Child derives from base if and only if its subtree mask contains more + // bits (or the same number of bits), and the n low-order subtree bits that + // are in common are identical. return ((child._mask & base._mask) == base._mask && (child._bits & base._mask) == base._bits); } diff --git a/dtool/src/dtoolbase/typeRegistryNode.cxx b/dtool/src/dtoolbase/typeRegistryNode.cxx index 065cea8051..cdc45d7beb 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.cxx +++ b/dtool/src/dtoolbase/typeRegistryNode.cxx @@ -1,16 +1,15 @@ -// Filename: typeRegistryNode.cxx -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistryNode.cxx + * @author drose + * @date 2001-08-06 + */ #include "typeRegistryNode.h" @@ -19,14 +18,12 @@ bool TypeRegistryNode::_paranoid_inheritance = false; -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TypeRegistryNode:: TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref) : - _handle(handle), _name(name), _ref(ref) + _handle(handle), _name(name), _ref(ref) { clear_subtree(); #ifdef DO_MEMORY_USAGE @@ -34,29 +31,25 @@ TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::is_derived_from -// Access: Public, Static -// Description: Returns true if the child RegistryNode represents a -// class that inherits directly or indirectly from the -// class represented by the base RegistryNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the child RegistryNode represents a class that inherits + * directly or indirectly from the class represented by the base RegistryNode. + */ bool TypeRegistryNode:: is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { - // This function is the basis for TypedObject::is_of_type(), which - // gets used quite frequently within Panda, often in inner-loop - // code. Therefore, we go through some pains to make this function - // as efficient as possible. + // This function is the basis for TypedObject::is_of_type(), which gets used + // quite frequently within Panda, often in inner-loop code. Therefore, we + // go through some pains to make this function as efficient as possible. - // First, compare the subtree tops. If they are the same, then this - // node and the base node are within the same single-inheritance - // subtree, and we can use our bitmask trick to determine the - // relationship with no additional work. (See r_build_subtrees()). + // First, compare the subtree tops. If they are the same, then this node + // and the base node are within the same single-inheritance subtree, and we + // can use our bitmask trick to determine the relationship with no + // additional work. (See r_build_subtrees()). if (child->_inherit._top == base->_inherit._top) { assert(child->_inherit._top != (TypeRegistryNode *)NULL); - bool derives = + bool derives = Inherit::is_derived_from(child->_inherit, base->_inherit); #ifndef NDEBUG @@ -64,7 +57,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { cerr - << "Inheritance test for " << child->_name + << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " << paranoid_derives << "\n" @@ -89,36 +82,35 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { return derives; } - // The two nodes are not within the same single-inheritance subtree. - // This complicates things a bit. + // The two nodes are not within the same single-inheritance subtree. This + // complicates things a bit. - // First, we should check whether the subtree tops of the two nodes - // inherit from each other. + // First, we should check whether the subtree tops of the two nodes inherit + // from each other. TypeRegistryNode *child_top = child->_inherit._top; TypeRegistryNode *base_top = base->_inherit._top; bool derives = false; - // If child_top does not inherit from base_top, it follows that - // child does not inherit from base. - TopInheritance::const_iterator ti = - lower_bound(child_top->_top_inheritance.begin(), + // If child_top does not inherit from base_top, it follows that child does + // not inherit from base. + TopInheritance::const_iterator ti = + lower_bound(child_top->_top_inheritance.begin(), child_top->_top_inheritance.end(), Inherit(base_top, 0, 0)); - while (ti != child_top->_top_inheritance.end() && + while (ti != child_top->_top_inheritance.end() && (*ti)._top == base_top && !derives) { - // If child_top *does* inherit from base_top, then child may or - // may not inherit from base. This depends on the exact path of - // inheritance. Since there might be multiple paths from - // child_top to base_top, we have to examine all of them. + // If child_top *does* inherit from base_top, then child may or may not + // inherit from base. This depends on the exact path of inheritance. + // Since there might be multiple paths from child_top to base_top, we have + // to examine all of them. const Inherit &connection = (*ti); - // Here is one inheritance from child_top to base_top. If the - // connecting node inherits from base, then child also inherits - // from base. If the connecting node does not inherit from base, - // we must keep looking. + // Here is one inheritance from child_top to base_top. If the connecting + // node inherits from base, then child also inherits from base. If the + // connecting node does not inherit from base, we must keep looking. derives = Inherit::is_derived_from(connection, base->_inherit); ++ti; @@ -129,7 +121,7 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { bool paranoid_derives = check_derived_from(child, base); if (derives != paranoid_derives) { cerr - << "Inheritance test for " << child->_name + << "Inheritance test for " << child->_name << " from " << base->_name << " failed!\n" << "Result: " << derives << " should have been: " << paranoid_derives << "\n" @@ -150,12 +142,10 @@ is_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { return derives; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::get_parent_towards -// Access: Public, Static -// Description: Returns the first parent class of child that is a -// descendant of the indicated base class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first parent class of child that is a descendant of the + * indicated base class. + */ TypeHandle TypeRegistryNode:: get_parent_towards(const TypeRegistryNode *child, const TypeRegistryNode *base) { @@ -164,7 +154,7 @@ get_parent_towards(const TypeRegistryNode *child, } Classes::const_iterator ni; - for (ni = child->_parent_classes.begin(); + for (ni = child->_parent_classes.begin(); ni != child->_parent_classes.end(); ++ni) { if (is_derived_from((*ni), base)) { return (*ni)->_handle; @@ -175,13 +165,10 @@ get_parent_towards(const TypeRegistryNode *child, } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::clear_subtree -// Access: Public -// Description: Removes any subtree definition previously set up via -// define_subtree(), in preparation for rebuilding the -// subtree data. -//////////////////////////////////////////////////////////////////// +/** + * Removes any subtree definition previously set up via define_subtree(), in + * preparation for rebuilding the subtree data. + */ void TypeRegistryNode:: clear_subtree() { _inherit = Inherit(); @@ -189,18 +176,14 @@ clear_subtree() { _visit_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::define_subtree -// Access: Public -// Description: Indicates that this TypeRegistryNode is the top of a -// subtree within the inheritance graph (typically, this -// indicates a multiple-inheritance node). Builds all -// the subtree_mask etc. flags for nodes at this level -// and below. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this TypeRegistryNode is the top of a subtree within the + * inheritance graph (typically, this indicates a multiple-inheritance node). + * Builds all the subtree_mask etc. flags for nodes at this level and below. + */ void TypeRegistryNode:: define_subtree() { - // cerr << "Building subtree for " << _name << ", top inheritance is:\n"; + // cerr << "Building subtree for " << _name << ", top inheritance is:\n"; /* TopInheritance::const_iterator ti; @@ -214,63 +197,59 @@ define_subtree() { r_build_subtrees(this, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::r_build_subtrees -// Access: Public -// Description: Recursively builds up all the subtree cache -// information for this node and the ones below. This -// information is used to quickly determine class -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * Recursively builds up all the subtree cache information for this node and + * the ones below. This information is used to quickly determine class + * inheritance. + */ void TypeRegistryNode:: -r_build_subtrees(TypeRegistryNode *top, int bit_count, +r_build_subtrees(TypeRegistryNode *top, int bit_count, TypeRegistryNode::SubtreeMaskType bits) { - // The idea with these bits is to optimize the common case of a - // single-inheritance graph (that is, an inheritance tree), or a - // single-inheritance subgraph of the full multiple-inheritance - // graph (i.e. a subtree of the inheritance graph). + // The idea with these bits is to optimize the common case of a single- + // inheritance graph (that is, an inheritance tree), or a single-inheritance + // subgraph of the full multiple-inheritance graph (i.e. a subtree of the + // inheritance graph). - // When we have just single inheritance, we can define a unique - // number for each node in the inheritance tree that allows us to - // immediately determine the inheritance relationship between any - // two nodes in the tree. We choose a number such that for a given - // node whose number has n bits, each child node has m + n bits - // where the low-order n bits are the same as the parent node's - // bits, and the high-order m bits are unique among each sibling. - // The node at the top of the tree has zero bits. +/* + * When we have just single inheritance, we can define a unique number for + * each node in the inheritance tree that allows us to immediately determine + * the inheritance relationship between any two nodes in the tree. We choose + * a number such that for a given node whose number has n bits, each child + * node has m + n bits where the low-order n bits are the same as the parent + * node's bits, and the high-order m bits are unique among each sibling. The + * node at the top of the tree has zero bits. + */ - // That way, we can simply compare bitmasks to determine if class A - // inherits from class B. If the low-order bits are the same, they - // have some ancestry in common. The highest-order bit that still - // matches corresponds to the lowest node in the tree that they have - // in common; i.e. the node from which they both inherit. + // That way, we can simply compare bitmasks to determine if class A inherits + // from class B. If the low-order bits are the same, they have some + // ancestry in common. The highest-order bit that still matches corresponds + // to the lowest node in the tree that they have in common; i.e. the node + // from which they both inherit. - // To put it more formally, let count(A) be the number of bits in - // A's number, and count(B) be the number of bits in B's number. A - // inherits from B if and only if count(B) <= count(A), and the - // lower count(B) bits of A's number are the same as those in B's - // number. + // To put it more formally, let count(A) be the number of bits in A's + // number, and count(B) be the number of bits in B's number. A inherits + // from B if and only if count(B) <= count(A), and the lower count(B) bits + // of A's number are the same as those in B's number. - // This algorithm breaks down in the presence of multiple - // inheritance, since we can't make up a single number for each node - // any more. We still take advantage of the algorithm by - // considering each single-inheritance subgraph separately. + // This algorithm breaks down in the presence of multiple inheritance, since + // we can't make up a single number for each node any more. We still take + // advantage of the algorithm by considering each single-inheritance + // subgraph separately. - // To handle multiple inheritance, we reset the numbers to zero - // every time we come across a multiple-inheritance node (this - // begins a new subtree). There are relatively few of these - // "subtree top" nodes, and we record the explicit inheritance of - // each one from all of its ancestor "subtree top" nodes within the - // node itself. + // To handle multiple inheritance, we reset the numbers to zero every time + // we come across a multiple-inheritance node (this begins a new subtree). + // There are relatively few of these "subtree top" nodes, and we record the + // explicit inheritance of each one from all of its ancestor "subtree top" + // nodes within the node itself. if (top != this && _parent_classes.size() != 1) { assert(!_parent_classes.empty()); - + // This class multiply inherits; it therefore begins a new subtree. // Copy in the inheritance relations from our parent subtree tops. _top_inheritance.insert(_top_inheritance.end(), - top->_top_inheritance.begin(), + top->_top_inheritance.begin(), top->_top_inheritance.end()); _top_inheritance.push_back(Inherit(top, bit_count, bits)); @@ -284,16 +263,15 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, } } else { - // This class singly inherits, so this had better be the only time - // this function is called on it since clear_subtree(). + // This class singly inherits, so this had better be the only time this + // function is called on it since clear_subtree(). assert(_inherit._top == (TypeRegistryNode *)NULL); assert(bit_count < (int)(sizeof(SubtreeMaskType) * 8)); _inherit = Inherit(top, bit_count, bits); - // Now, how many more bits do we need to encode each of our - // children? + // Now, how many more bits do we need to encode each of our children? int num_children = (int)_child_classes.size(); int more_bits = 0; int i = num_children - 1; @@ -302,16 +280,16 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, i >>= 1; } - // We need at least one bit, even if there is only one child, so - // we can differentiate parent from child. + // We need at least one bit, even if there is only one child, so we can + // differentiate parent from child. more_bits = max(more_bits, 1); assert(more_bits < (int)(sizeof(SubtreeMaskType) * 8)); if (bit_count + more_bits > (int)(sizeof(SubtreeMaskType) * 8)) { - // Too many bits; we need to start a new subtree right here. - // This node becomes a subtree top node, even though it's not a - // multiple-inheritance node. + // Too many bits; we need to start a new subtree right here. This node + // becomes a subtree top node, even though it's not a multiple- + // inheritance node. assert(top != this); _top_inheritance = top->_top_inheritance; _top_inheritance.push_back(_inherit); @@ -328,29 +306,25 @@ r_build_subtrees(TypeRegistryNode *top, int bit_count, child->r_build_subtrees(top, bit_count + more_bits, bits | next_bits); } - } + } } } - -//////////////////////////////////////////////////////////////////// -// Function: TypeRegistryNode::check_derived_from -// Access: Private, Static -// Description: A recursive function to double-check the result of -// is_derived_from(). This is the slow, -// examine-the-whole-graph approach, as opposed to the -// clever and optimal algorithm of is_derived_from(); -// it's intended to be used only for debugging said -// clever algorithm. -//////////////////////////////////////////////////////////////////// + +/** + * A recursive function to double-check the result of is_derived_from(). This + * is the slow, examine-the-whole-graph approach, as opposed to the clever and + * optimal algorithm of is_derived_from(); it's intended to be used only for + * debugging said clever algorithm. + */ bool TypeRegistryNode:: -check_derived_from(const TypeRegistryNode *child, +check_derived_from(const TypeRegistryNode *child, const TypeRegistryNode *base) { if (child == base) { return true; } Classes::const_iterator ni; - for (ni = child->_parent_classes.begin(); + for (ni = child->_parent_classes.begin(); ni != child->_parent_classes.end(); ++ni) { if (check_derived_from(*ni, base)) { diff --git a/dtool/src/dtoolbase/typeRegistryNode.h b/dtool/src/dtoolbase/typeRegistryNode.h index 8ade45b8b1..7eb64f8a65 100644 --- a/dtool/src/dtoolbase/typeRegistryNode.h +++ b/dtool/src/dtoolbase/typeRegistryNode.h @@ -1,16 +1,15 @@ -// Filename: typeRegistryNode.h -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeRegistryNode.h + * @author drose + * @date 2001-08-06 + */ #ifndef TYPEREGISTRYNODE_H #define TYPEREGISTRYNODE_H @@ -23,13 +22,11 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : TypeRegistryNode -// Description : This is a single entry in the TypeRegistry. -// Normally, user code will never directly access this -// class; this class is hidden within the TypeRegistry -// accessors. -//////////////////////////////////////////////////////////////////// +/** + * This is a single entry in the TypeRegistry. Normally, user code will never + * directly access this class; this class is hidden within the TypeRegistry + * accessors. + */ class EXPCL_DTOOL TypeRegistryNode { public: TypeRegistryNode(TypeHandle handle, const string &name, TypeHandle &ref); @@ -59,17 +56,17 @@ public: private: typedef int SubtreeMaskType; - // This class defines the inheritance relationship of this node from - // some ancestor denoted as a "subtree top" node. This is usually - // the nearest ancestor that has multiple inheritance. + // This class defines the inheritance relationship of this node from some + // ancestor denoted as a "subtree top" node. This is usually the nearest + // ancestor that has multiple inheritance. class Inherit { public: INLINE Inherit(); - INLINE Inherit(TypeRegistryNode *top, int bit_count, + INLINE Inherit(TypeRegistryNode *top, int bit_count, SubtreeMaskType bits); INLINE Inherit(const Inherit ©); INLINE void operator = (const Inherit ©); - + INLINE bool operator < (const Inherit &other) const; INLINE static bool is_derived_from(const Inherit &child, const Inherit &base); @@ -79,7 +76,7 @@ private: }; typedef vector TopInheritance; - void r_build_subtrees(TypeRegistryNode *top, + void r_build_subtrees(TypeRegistryNode *top, int bit_count, SubtreeMaskType bits); static bool check_derived_from(const TypeRegistryNode *child, @@ -87,10 +84,9 @@ private: Inherit _inherit; - // The _top_inheritance member is only filled for nodes that are - // denoted as "subtree top" nodes. It represents the complete set - // of subtree_top nodes that this node inherits from, directly or - // indirectly. + // The _top_inheritance member is only filled for nodes that are denoted as + // "subtree top" nodes. It represents the complete set of subtree_top nodes + // that this node inherits from, directly or indirectly. TopInheritance _top_inheritance; // _visit_count is only used during r_build_subtree(). diff --git a/dtool/src/dtoolbase/typedObject.I b/dtool/src/dtoolbase/typedObject.I index 7c2917072f..68776b7c13 100644 --- a/dtool/src/dtoolbase/typedObject.I +++ b/dtool/src/dtoolbase/typedObject.I @@ -1,64 +1,50 @@ -// Filename: typedObject.I -// Created by: drose (11May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedObject.I + * @author drose + * @date 2001-05-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedObject:: TypedObject() { } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedObject:: TypedObject(const TypedObject &) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypedObject:: operator = (const TypedObject &) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::get_type_index -// Access: Published -// Description: Returns the internal index number associated with -// this object's TypeHandle, a unique number for each -// different type. This is equivalent to -// get_type().get_index(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal index number associated with this object's TypeHandle, + * a unique number for each different type. This is equivalent to + * get_type().get_index(). + */ INLINE int TypedObject:: get_type_index() const { return get_type().get_index(); } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::is_of_type -// Access: Published -// Description: Returns true if the current object is or derives from -// the indicated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current object is or derives from the indicated type. + */ INLINE bool TypedObject:: is_of_type(TypeHandle handle) const { // Shortcut for the common case where the type matches exactly. @@ -66,12 +52,9 @@ is_of_type(TypeHandle handle) const { return handle == my_type || my_type.is_derived_from(handle, (TypedObject *)this); } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::is_exact_type -// Access: Published -// Description: Returns true if the current object is the indicated -// type exactly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current object is the indicated type exactly. + */ INLINE bool TypedObject:: is_exact_type(TypeHandle handle) const { #ifndef NDEBUG @@ -81,35 +64,26 @@ is_exact_type(TypeHandle handle) const { return get_type() == handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::get_best_parent_from_Set -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int TypedObject:: get_best_parent_from_Set(const std::set &inset) const { return get_type().get_best_parent_from_Set(inset); } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::as_typed_object -// Access: Public -// Description: Returns the object, upcast (if necessary) to a -// TypedObject pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object, upcast (if necessary) to a TypedObject pointer. + */ INLINE TypedObject *TypedObject:: as_typed_object() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::as_typed_object -// Access: Public -// Description: Returns the object, upcast (if necessary) to a -// TypedObject pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object, upcast (if necessary) to a TypedObject pointer. + */ INLINE const TypedObject *TypedObject:: as_typed_object() const { return this; } - diff --git a/dtool/src/dtoolbase/typedObject.cxx b/dtool/src/dtoolbase/typedObject.cxx index f5cd7485be..a397ef843e 100644 --- a/dtool/src/dtoolbase/typedObject.cxx +++ b/dtool/src/dtoolbase/typedObject.cxx @@ -1,53 +1,45 @@ -// Filename: typedObject.cxx -// Created by: drose (11May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedObject.cxx + * @author drose + * @date 2001-05-11 + */ #include "typedObject.h" TypeHandle TypedObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TypedObject:: ~TypedObject() { } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::get_type -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TypeHandle TypedObject:: get_type() const { - // Normally, this function should never be called, because it is a - // pure virtual function. If it is called, you probably called - // get_type() on a recently-destructed object. + // Normally, this function should never be called, because it is a pure + // virtual function. If it is called, you probably called get_type() on a + // recently-destructed object. cerr << "TypedObject::get_type() called!\n"; return _type_handle; } -//////////////////////////////////////////////////////////////////// -// Function: TypedObject::init_type -// Access: Public, Static -// Description: This function is declared non-inline to work around a -// compiler bug in g++ 2.96. Making it inline seems to -// cause problems in the optimizer. -//////////////////////////////////////////////////////////////////// +/** + * This function is declared non-inline to work around a compiler bug in g++ + * 2.96. Making it inline seems to cause problems in the optimizer. + */ void TypedObject:: init_type() { register_type(_type_handle, "TypedObject"); diff --git a/dtool/src/dtoolbase/typedObject.h b/dtool/src/dtoolbase/typedObject.h index 60695a1062..37b0bd67f4 100644 --- a/dtool/src/dtoolbase/typedObject.h +++ b/dtool/src/dtoolbase/typedObject.h @@ -1,16 +1,15 @@ -// Filename: typedObject.h -// Created by: drose (11May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedObject.h + * @author drose + * @date 2001-05-11 + */ #ifndef TYPEDOBJECT_H #define TYPEDOBJECT_H @@ -23,78 +22,49 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : TypedObject -// Description : This is an abstract class that all classes which -// use TypeHandle, and also provide virtual functions to -// support polymorphism, should inherit from. Each -// derived class should define get_type(), which should -// return the specific type of the derived class. -// Inheriting from this automatically provides support -// for is_of_type() and is_exact_type(). -// -// All classes that inherit directly or indirectly from -// TypedObject should redefine get_type() and -// force_init_type(), as shown below. Some classes that -// do not inherit from TypedObject may still declare -// TypeHandles for themselves by defining methods called -// get_class_type() and init_type(). Classes such as -// these may serve as base classes, but the dynamic type -// identification system will be limited. Classes that -// do not inherit from TypedObject need not define the -// virtual functions get_type() and force_init_type() -// (or any other virtual functions). -// -// There is a specific layout for defining the -// overrides from this class. Keeping the definitions -// formatted just like these examples will allow -// someone in the future to use a sed (or similar) -// script to make global changes, if necessary. Avoid -// rearranging the braces or the order of the functions -// unless you're ready to change them in every file all -// at once. -// -// What follows are some examples that can be used in -// new classes that you create. -// -// @par In the class definition (.h file): -// @code -// public: -// static TypeHandle get_class_type() { -// return _type_handle; -// } -// static void init_type() { -// <<>>::init_type(); -// <<>>::init_type(); -// <<>>::init_type(); -// register_type(_type_handle, "<<>>", -// <<>>::get_class_type(), -// <<>>::get_class_type(), -// <<>>::get_class_type()); -// } -// virtual TypeHandle get_type() const { -// return get_class_type(); -// } -// virtual TypeHandle force_init_type() {init_type(); return get_class_type();} -// -// private: -// static TypeHandle _type_handle; -// @endcode -// -// @par In the class .cxx file: -// @code -// TypeHandle <<>>::_type_handle; -// @endcode -// -// @par In the class config_<<>>.cxx file: -// @code -// ConfigureFn(config_<<>>) { -// <<>>::init_type(); -// <<>>::init_type(); -// <<>>::init_type(); -// } -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class that all classes which use TypeHandle, and also + * provide virtual functions to support polymorphism, should inherit from. + * Each derived class should define get_type(), which should return the + * specific type of the derived class. Inheriting from this automatically + * provides support for is_of_type() and is_exact_type(). + * + * All classes that inherit directly or indirectly from TypedObject should + * redefine get_type() and force_init_type(), as shown below. Some classes + * that do not inherit from TypedObject may still declare TypeHandles for + * themselves by defining methods called get_class_type() and init_type(). + * Classes such as these may serve as base classes, but the dynamic type + * identification system will be limited. Classes that do not inherit from + * TypedObject need not define the virtual functions get_type() and + * force_init_type() (or any other virtual functions). + * + * There is a specific layout for defining the overrides from this class. + * Keeping the definitions formatted just like these examples will allow + * someone in the future to use a sed (or similar) script to make global + * changes, if necessary. Avoid rearranging the braces or the order of the + * functions unless you're ready to change them in every file all at once. + * + * What follows are some examples that can be used in new classes that you + * create. + * + * @par In the class definition (.h file): @code public: static TypeHandle + * get_class_type() { return _type_handle; } static void init_type() { + * <<>>::init_type(); <<>>::init_type(); + * <<>>::init_type(); register_type(_type_handle, + * "<<>>", <<>>::get_class_type(), + * <<>>::get_class_type(), <<>>::get_class_type()); + * } virtual TypeHandle get_type() const { return get_class_type(); } virtual + * TypeHandle force_init_type() {init_type(); return get_class_type();} + * + * private: static TypeHandle _type_handle; @endcode + * + * @par In the class .cxx file: @code TypeHandle + * <<>>::_type_handle; @endcode + * + * @par In the class config_<<>>.cxx file: @code + * ConfigureFn(config_<<>>) { <<>>::init_type(); + * <<>>::init_type(); <<>>::init_type(); } @endcode + */ class EXPCL_DTOOL TypedObject : public MemoryBase { public: INLINE TypedObject(); @@ -105,8 +75,7 @@ PUBLISHED: // A virtual destructor is just a good idea. virtual ~TypedObject(); - // Derived classes should override this function to return - // get_class_type(). + // Derived classes should override this function to return get_class_type(). virtual TypeHandle get_type() const=0; MAKE_PROPERTY(type, get_type); @@ -117,17 +86,17 @@ PUBLISHED: public: INLINE int get_best_parent_from_Set(const std::set &) const; - // Derived classes should override this function to call - // init_type(). It will only be called in error situations when the - // type was for some reason not properly initialized. + // Derived classes should override this function to call init_type(). It + // will only be called in error situations when the type was for some reason + // not properly initialized. virtual TypeHandle force_init_type()=0; - // This pair of methods exists mainly for the convenience of - // unambiguous upcasting. Interrogate generates code to call this - // method instead of making an explicit cast to (TypedObject *); - // this allows classes who multiply inherit from TypedObject to - // override these methods and disambiguate the cast. It doesn't - // have to be a virtual method, since this is just a static upcast. + // This pair of methods exists mainly for the convenience of unambiguous + // upcasting. Interrogate generates code to call this method instead of + // making an explicit cast to (TypedObject *); this allows classes who + // multiply inherit from TypedObject to override these methods and + // disambiguate the cast. It doesn't have to be a virtual method, since + // this is just a static upcast. INLINE TypedObject *as_typed_object(); INLINE const TypedObject *as_typed_object() const; diff --git a/dtool/src/dtoolbase/version.h b/dtool/src/dtoolbase/version.h index 04b7804bfa..b23f6ee42e 100644 --- a/dtool/src/dtoolbase/version.h +++ b/dtool/src/dtoolbase/version.h @@ -1,16 +1,13 @@ -// Filename: version.h -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file version.h + */ /* instead of this stuff probably want to use link.exe /VERSION flag instead, which might make auto-incrementing build number a little easier */ @@ -23,4 +20,3 @@ #define PANDA_VERSION_MINOR_STR "0" #define PANDA_VERSION_BUILDSUBVERSION_STR "0" #define PANDA_VERSION_BUILDSUBSUBVERSION_STR "1" - diff --git a/dtool/src/dtoolutil/config_dtoolutil.cxx b/dtool/src/dtoolutil/config_dtoolutil.cxx index 5c03315616..eb45fa2f3e 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.cxx +++ b/dtool/src/dtoolutil/config_dtoolutil.cxx @@ -1,30 +1,27 @@ -// Filename: config_dtoolutil.cxx -// Created by: drose (17Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dtoolutil.cxx + * @author drose + * @date 2006-11-17 + */ #include "config_dtoolutil.h" #include "filename.h" #include "pandaSystem.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libdtoolutil -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdtoolutil() { static bool initialized = false; diff --git a/dtool/src/dtoolutil/config_dtoolutil.h b/dtool/src/dtoolutil/config_dtoolutil.h index 9f53d107ff..1563b0250f 100644 --- a/dtool/src/dtoolutil/config_dtoolutil.h +++ b/dtool/src/dtoolutil/config_dtoolutil.h @@ -1,16 +1,15 @@ -// Filename: config_dtoolutil.h -// Created by: drose (17Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dtoolutil.h + * @author drose + * @date 2006-11-17 + */ #ifndef CONFIG_DTOOLUTIL_H #define CONFIG_DTOOLUTIL_H diff --git a/dtool/src/dtoolutil/dSearchPath.I b/dtool/src/dtoolutil/dSearchPath.I index 5dc035a848..3a958915d6 100644 --- a/dtool/src/dtoolutil/dSearchPath.I +++ b/dtool/src/dtoolutil/dSearchPath.I @@ -1,50 +1,39 @@ -// Filename: dSearchPath.I -// Created by: drose (01Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dSearchPath.I + * @author drose + * @date 2000-07-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::operator [] -// Access: Published -// Description: Returns the nth filename in the set. This method is -// defined to make the Results object appear to be a -// list in Python. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth filename in the set. This method is defined to make the + * Results object appear to be a list in Python. + */ INLINE Filename DSearchPath::Results:: operator [] (size_t n) const { return get_file(n); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::size -// Access: Published -// Description: Returns the num of filenames in the set. This method -// is defined to make the Results object appear to be a -// list in Python. -//////////////////////////////////////////////////////////////////// +/** + * Returns the num of filenames in the set. This method is defined to make + * the Results object appear to be a list in Python. + */ INLINE size_t DSearchPath::Results:: size() const { return get_num_files(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::find_all_files -// Access: Published -// Description: This variant of find_all_files() returns the new -// Results object, instead of filling on in on the -// parameter list. This is a little more convenient to -// call from Python. -//////////////////////////////////////////////////////////////////// +/** + * This variant of find_all_files() returns the new Results object, instead of + * filling on in on the parameter list. This is a little more convenient to + * call from Python. + */ INLINE DSearchPath::Results DSearchPath:: find_all_files(const Filename &filename) const { Results results; @@ -52,15 +41,12 @@ find_all_files(const Filename &filename) const { return results; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::search_path -// Access: Published, Static -// Description: A quick-and-easy way to search a searchpath for a -// file when you don't feel like building or keeping -// around a DSearchPath object. This simply -// constructs a temporary DSearchPath based on the -// indicated path string, and searches that. -//////////////////////////////////////////////////////////////////// +/** + * A quick-and-easy way to search a searchpath for a file when you don't feel + * like building or keeping around a DSearchPath object. This simply + * constructs a temporary DSearchPath based on the indicated path string, and + * searches that. + */ INLINE Filename DSearchPath:: search_path(const Filename &filename, const string &path, const string &separator) { diff --git a/dtool/src/dtoolutil/dSearchPath.cxx b/dtool/src/dtoolutil/dSearchPath.cxx index 89105253a7..d0aec4c3ad 100644 --- a/dtool/src/dtoolutil/dSearchPath.cxx +++ b/dtool/src/dtoolutil/dSearchPath.cxx @@ -1,16 +1,15 @@ -// Filename: dSearchPath.cxx -// Created by: drose (01Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dSearchPath.cxx + * @author drose + * @date 2000-07-01 + */ #include "dSearchPath.h" #include "filename.h" @@ -18,91 +17,73 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath::Results:: Results() { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath::Results:: Results(const DSearchPath::Results ©) : _files(copy._files) { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath::Results:: operator = (const DSearchPath::Results ©) { _files = copy._files; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath::Results:: ~Results() { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::clear -// Access: Published -// Description: Removes all the files from the list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the files from the list. + */ void DSearchPath::Results:: clear() { _files.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::get_num_files -// Access: Published -// Description: Returns the number of files on the result list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of files on the result list. + */ size_t DSearchPath::Results:: get_num_files() const { return _files.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::get_file -// Access: Published -// Description: Returns the nth file on the result list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth file on the result list. + */ const Filename &DSearchPath::Results:: get_file(size_t n) const { assert(n < _files.size()); return _files[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::add_file -// Access: Published -// Description: Adds a new file to the result list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new file to the result list. + */ void DSearchPath::Results:: add_file(const Filename &file) { _files.push_back(file); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath::Results:: output(ostream &out) const { out << "[ "; @@ -118,11 +99,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Results::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath::Results:: write(ostream &out, int indent_level) const { Files::const_iterator fi; @@ -134,101 +113,81 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Default Constructor -// Access: Published -// Description: Creates an empty search path. -//////////////////////////////////////////////////////////////////// +/** + * Creates an empty search path. + */ DSearchPath:: DSearchPath() { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath:: DSearchPath(const string &path, const string &separator) { append_path(path, separator); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath:: DSearchPath(const Filename &directory) { append_directory(directory); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath:: DSearchPath(const DSearchPath ©) : _directories(copy._directories) { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath:: operator = (const DSearchPath ©) { _directories = copy._directories; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DSearchPath:: ~DSearchPath() { } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::clear -// Access: Published -// Description: Removes all the directories from the search list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the directories from the search list. + */ void DSearchPath:: clear() { _directories.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::append_directory -// Access: Published -// Description: Adds a new directory to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new directory to the end of the search list. + */ void DSearchPath:: append_directory(const Filename &directory) { _directories.push_back(directory); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::prepend_directory -// Access: Published -// Description: Adds a new directory to the front of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new directory to the front of the search list. + */ void DSearchPath:: prepend_directory(const Filename &directory) { _directories.insert(_directories.begin(), directory); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::append_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the end of the + * search list. + */ void DSearchPath:: append_path(const string &path, const string &separator) { string pathsep = separator; @@ -255,24 +214,20 @@ append_path(const string &path, const string &separator) { } } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::append_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the end of the + * search list. + */ void DSearchPath:: append_path(const DSearchPath &path) { copy(path._directories.begin(), path._directories.end(), back_inserter(_directories)); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::prepend_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the beginning of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the beginning of + * the search list. + */ void DSearchPath:: prepend_path(const DSearchPath &path) { if (!path._directories.empty()) { @@ -283,46 +238,36 @@ prepend_path(const DSearchPath &path) { } } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::is_empty -// Access: Published -// Description: Returns true if the search list is empty, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the search list is empty, false otherwise. + */ bool DSearchPath:: is_empty() const { return _directories.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::get_num_directories -// Access: Published -// Description: Returns the number of directories on the search list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of directories on the search list. + */ size_t DSearchPath:: get_num_directories() const { return _directories.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::get_directory -// Access: Published -// Description: Returns the nth directory on the search list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth directory on the search list. + */ const Filename &DSearchPath:: get_directory(size_t n) const { assert(n < _directories.size()); return _directories[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::find_file -// Access: Published -// Description: Searches all the directories in the search list for -// the indicated file, in order. Returns the full -// matching pathname of the first match if found, or the -// empty string if not found. -//////////////////////////////////////////////////////////////////// +/** + * Searches all the directories in the search list for the indicated file, in + * order. Returns the full matching pathname of the first match if found, or + * the empty string if not found. + */ Filename DSearchPath:: find_file(const Filename &filename) const { if (filename.is_local()) { @@ -339,10 +284,9 @@ find_file(const Filename &filename) const { Filename match((*di), filename); if (match.exists()) { if ((*di) == "." && filename.is_fully_qualified()) { - // A special case for the "." directory: to avoid prefixing - // an endless stream of ./ in front of files, if the - // filename already has a ./ prefixed - // (i.e. is_fully_qualified() is true), we don't + // A special case for the "." directory: to avoid prefixing an + // endless stream of . in front of files, if the filename already + // has a . prefixed (i.e. is_fully_qualified() is true), we don't // prefix another one. return filename; } else { @@ -356,18 +300,14 @@ find_file(const Filename &filename) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::find_all_files -// Access: Published -// Description: Searches all the directories in the search list for -// the indicated file, in order. Fills up the results -// list with *all* of the matching filenames found, if -// any. Returns the number of matches found. -// -// It is the responsibility of the the caller to clear -// the results list first; otherwise, the newly-found -// files will be appended to the list. -//////////////////////////////////////////////////////////////////// +/** + * Searches all the directories in the search list for the indicated file, in + * order. Fills up the results list with *all* of the matching filenames + * found, if any. Returns the number of matches found. + * + * It is the responsibility of the the caller to clear the results list first; + * otherwise, the newly-found files will be appended to the list. + */ size_t DSearchPath:: find_all_files(const Filename &filename, DSearchPath::Results &results) const { @@ -387,10 +327,9 @@ find_all_files(const Filename &filename, Filename match((*di), filename); if (match.exists()) { if ((*di) == "." && filename.is_fully_qualified()) { - // A special case for the "." directory: to avoid prefixing - // an endless stream of ./ in front of files, if the - // filename already has a ./ prefixed - // (i.e. is_fully_qualified() is true), we don't + // A special case for the "." directory: to avoid prefixing an + // endless stream of . in front of files, if the filename already + // has a . prefixed (i.e. is_fully_qualified() is true), we don't // prefix another one. results.add_file(filename); } else { @@ -405,11 +344,9 @@ find_all_files(const Filename &filename, return num_added; } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath:: output(ostream &out, const string &separator) const { string pathsep = separator; @@ -431,11 +368,9 @@ output(ostream &out, const string &separator) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DSearchPath::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DSearchPath:: write(ostream &out, int indent_level) const { Directories::const_iterator di; diff --git a/dtool/src/dtoolutil/dSearchPath.h b/dtool/src/dtoolutil/dSearchPath.h index edc9f1c3ef..712e77be4c 100644 --- a/dtool/src/dtoolutil/dSearchPath.h +++ b/dtool/src/dtoolutil/dSearchPath.h @@ -1,16 +1,15 @@ -// Filename: dSearchPath.h -// Created by: drose (01Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dSearchPath.h + * @author drose + * @date 2000-07-01 + */ #ifndef PANDASEARCHPATH_H #define PANDASEARCHPATH_H @@ -20,15 +19,12 @@ #include "filename.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : DSearchPath -// Description : This class stores a list of directories that can be -// searched, in order, to locate a particular file. It -// is normally constructed by passing it a traditional -// searchpath-style string, e.g. a list of directory -// names delimited by spaces or colons, but it can also -// be built up explicitly. -//////////////////////////////////////////////////////////////////// +/** + * This class stores a list of directories that can be searched, in order, to + * locate a particular file. It is normally constructed by passing it a + * traditional searchpath-style string, e.g. a list of directory names + * delimited by spaces or colons, but it can also be built up explicitly. + */ class EXPCL_DTOOL DSearchPath { PUBLISHED: class EXPCL_DTOOL Results { diff --git a/dtool/src/dtoolutil/executionEnvironment.I b/dtool/src/dtoolutil/executionEnvironment.I index 518d0cee41..b1fe554a29 100644 --- a/dtool/src/dtoolutil/executionEnvironment.I +++ b/dtool/src/dtoolutil/executionEnvironment.I @@ -1,140 +1,109 @@ -// Filename: executionEnvironment.I -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file executionEnvironment.I + * @author drose + * @date 2000-05-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::has_environment_variable -// Access: Public, Static -// Description: Returns true if the indicated environment variable -// is defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated environment variable is defined. + */ INLINE bool ExecutionEnvironment:: has_environment_variable(const string &var) { return get_ptr()->ns_has_environment_variable(var); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_environment_variable -// Access: Public, Static -// Description: Returns the definition of the indicated environment -// variable, or the empty string if the variable is -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the definition of the indicated environment variable, or the empty + * string if the variable is undefined. + */ INLINE string ExecutionEnvironment:: get_environment_variable(const string &var) { return get_ptr()->ns_get_environment_variable(var); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::set_environment_variable -// Access: Public, Static -// Description: Changes the definition of the indicated environment -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Changes the definition of the indicated environment variable. + */ INLINE void ExecutionEnvironment:: set_environment_variable(const string &var, const string &value) { get_ptr()->ns_set_environment_variable(var, value); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::shadow_environment_variable -// Access: Public, Static -// Description: Changes the apparent definition of the indicated -// environment variable by masking it within this class -// with a new value. This does not change the actual -// environment variable, but future calls to -// get_environment_variable() will return this new -// value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the apparent definition of the indicated environment variable by + * masking it within this class with a new value. This does not change the + * actual environment variable, but future calls to get_environment_variable() + * will return this new value. + */ INLINE void ExecutionEnvironment:: shadow_environment_variable(const string &var, const string &value) { get_ptr()->ns_shadow_environment_variable(var, value); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::clear_shadow -// Access: Public, Static -// Description: Removes a value set by a previous call to -// shadow_environment_variable(), and lets the actual -// value of the variable show again. -//////////////////////////////////////////////////////////////////// +/** + * Removes a value set by a previous call to shadow_environment_variable(), + * and lets the actual value of the variable show again. + */ INLINE void ExecutionEnvironment:: clear_shadow(const string &var) { get_ptr()->ns_clear_shadow(var); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_num_args -// Access: Public, Static -// Description: Returns the number of command-line arguments -// available, not counting arg 0, the binary name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of command-line arguments available, not counting arg 0, + * the binary name. + */ INLINE size_t ExecutionEnvironment:: get_num_args() { return get_ptr()->ns_get_num_args(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_arg -// Access: Public, Static -// Description: Returns the nth command-line argument. The index n -// must be in the range [0 .. get_num_args()). The -// first parameter, n == 0, is the first actual -// parameter, not the binary name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth command-line argument. The index n must be in the range [0 + * .. get_num_args()). The first parameter, n == 0, is the first actual + * parameter, not the binary name. + */ INLINE string ExecutionEnvironment:: get_arg(size_t n) { return get_ptr()->ns_get_arg(n); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_binary_name -// Access: Public, Static -// Description: Returns the name of the binary executable that -// started this program, if it can be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the binary executable that started this program, if it + * can be determined. + */ INLINE string ExecutionEnvironment:: get_binary_name() { return get_ptr()->ns_get_binary_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_dtool_name -// Access: Public, Static -// Description: Returns the name of the libdtool DLL that -// is used in this program, if it can be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the libdtool DLL that is used in this program, if it + * can be determined. + */ INLINE string ExecutionEnvironment:: get_dtool_name() { return get_ptr()->ns_get_dtool_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::set_binary_name -// Access: Public, Static -// Description: Do not use. -//////////////////////////////////////////////////////////////////// +/** + * Do not use. + */ INLINE void ExecutionEnvironment:: set_binary_name(const string &name) { get_ptr()->_binary_name = name; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::set_dtool_name -// Access: Public, Static -// Description: Do not use. -//////////////////////////////////////////////////////////////////// +/** + * Do not use. + */ INLINE void ExecutionEnvironment:: set_dtool_name(const string &name) { get_ptr()->_dtool_name = name; diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index 4117bbf86f..ac5eb548af 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -1,16 +1,15 @@ -// Filename: executionEnvironment.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file executionEnvironment.cxx + * @author drose + * @date 2000-05-15 + */ #include "executionEnvironment.h" #include "pandaVersion.h" @@ -66,52 +65,46 @@ extern char **environ; #include #endif -// We define the symbol PREREAD_ENVIRONMENT if we cannot rely on -// getenv() to read environment variables at static init time. In -// this case, we must read all of the environment variables directly -// and cache them locally. +// We define the symbol PREREAD_ENVIRONMENT if we cannot rely on getenv() to +// read environment variables at static init time. In this case, we must read +// all of the environment variables directly and cache them locally. #ifndef STATIC_INIT_GETENV #define PREREAD_ENVIRONMENT #endif -// We define the symbol HAVE_GLOBAL_ARGV if we have global variables -// named GLOBAL_ARGC/GLOBAL_ARGV that we can read at static init time -// to determine our command-line arguments. +// We define the symbol HAVE_GLOBAL_ARGV if we have global variables named +// GLOBAL_ARGCGLOBAL_ARGV that we can read at static init time to determine +// our command-line arguments. #if !defined(WIN32_VC) && defined(HAVE_GLOBAL_ARGV) && defined(PROTOTYPE_GLOBAL_ARGV) extern char **GLOBAL_ARGV; extern int GLOBAL_ARGC; #endif -// Linux with GNU libc does have global argv/argc variables, but we -// can't safely access them at stat init time--at least, not in libc5. -// (It does seem to work with glibc2, however.) +// Linux with GNU libc does have global argvargc variables, but we can't +// safely access them at stat init time--at least, not in libc5. (It does seem +// to work with glibc2, however.) ExecutionEnvironment *ExecutionEnvironment::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::Constructor -// Access: Private -// Description: You shouldn't need to construct one of these; there's -// only one and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * You shouldn't need to construct one of these; there's only one and it + * constructs itself. + */ ExecutionEnvironment:: ExecutionEnvironment() { read_environment_variables(); read_args(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnviroment::expand_string -// Access: Public, Static -// Description: Reads the string, looking for environment variable -// names marked by a $. Expands all such variable -// names. A repeated dollar sign ($$) is mapped to a -// single dollar sign. -// -// Returns the expanded string. -//////////////////////////////////////////////////////////////////// +/** + * Reads the string, looking for environment variable names marked by a $. + * Expands all such variable names. A repeated dollar sign ($$) is mapped to + * a single dollar sign. + * + * Returns the expanded string. + */ string ExecutionEnvironment:: expand_string(const string &str) { string result; @@ -161,16 +154,13 @@ expand_string(const string &str) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnviroment::get_cwd -// Access: Public, Static -// Description: Returns the name of the current working directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the current working directory. + */ Filename ExecutionEnvironment:: get_cwd() { #ifdef WIN32_VC - // getcwd() requires us to allocate a dynamic buffer and grow it on - // demand. + // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; static wchar_t *buffer = NULL; @@ -193,8 +183,7 @@ get_cwd() { cwd.make_true_case(); return cwd; #else // WIN32_VC - // getcwd() requires us to allocate a dynamic buffer and grow it on - // demand. + // getcwd() requires us to allocate a dynamic buffer and grow it on demand. static size_t bufsize = 1024; static char *buffer = NULL; @@ -219,12 +208,10 @@ get_cwd() { #endif // WIN32_VC } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_has_environment_variable -// Access: Private -// Description: Returns true if the indicated environment variable -// is defined. The nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated environment variable is defined. The + * nonstatic implementation. + */ bool ExecutionEnvironment:: ns_has_environment_variable(const string &var) const { #ifdef PREREAD_ENVIRONMENT @@ -234,13 +221,10 @@ ns_has_environment_variable(const string &var) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_get_environment_variable -// Access: Private -// Description: Returns the definition of the indicated environment -// variable, or the empty string if the variable is -// undefined. The nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the definition of the indicated environment variable, or the empty + * string if the variable is undefined. The nonstatic implementation. + */ string ExecutionEnvironment:: ns_get_environment_variable(const string &var) const { EnvironmentVariables::const_iterator evi; @@ -249,9 +233,9 @@ ns_get_environment_variable(const string &var) const { return (*evi).second; } - // Some special case variables. We virtually stuff these values - // into the Panda environment, shadowing whatever values they have - // in the true environment, so they can be used in config files. + // Some special case variables. We virtually stuff these values into the + // Panda environment, shadowing whatever values they have in the true + // environment, so they can be used in config files. if (var == "HOME") { return Filename::get_home_directory().to_os_specific(); } else if (var == "TEMP") { @@ -261,9 +245,9 @@ ns_get_environment_variable(const string &var) const { } else if (var == "COMMON_APPDATA") { return Filename::get_common_appdata_directory().to_os_specific(); } else if (var == "MAIN_DIR") { - // Return the binary name's parent directory. If we're running - // inside the Python interpreter, this will be overridden by - // a setting from panda3d/core.py. + // Return the binary name's parent directory. If we're running inside the + // Python interpreter, this will be overridden by a setting from + // panda3dcore.py. if (!_binary_name.empty()) { Filename main_dir (_binary_name); main_dir.make_absolute(); @@ -279,11 +263,11 @@ ns_get_environment_variable(const string &var) const { #endif #ifdef _WIN32 - // On Windows only, we also simulate several standard folder names - // as "environment" variables. I know we're supposed to be using - // KnownFolderID's these days, but those calls aren't compatible - // with XP, so we'll continue to use SHGetSpecialFolderPath() until - // we're forced out of it. + // On Windows only, we also simulate several standard folder names as + // "environment" variables. I know we're supposed to be using + // KnownFolderID's these days, but those calls aren't compatible with XP, so + // we'll continue to use SHGetSpecialFolderPath() until we're forced out of + // it. static struct { int id; const char *name; } csidl_table[] = { { CSIDL_ADMINTOOLS, "ADMINTOOLS" }, @@ -362,12 +346,10 @@ ns_get_environment_variable(const string &var) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_set_environment_variable -// Access: Private -// Description: Changes the definition of the indicated environment -// variable. The nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Changes the definition of the indicated environment variable. The + * nonstatic implementation. + */ void ExecutionEnvironment:: ns_set_environment_variable(const string &var, const string &value) { _variables[var] = value; @@ -379,22 +361,18 @@ ns_set_environment_variable(const string &var, const string &value) { putenv(put); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_shadow_environment_variable -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ExecutionEnvironment:: ns_shadow_environment_variable(const string &var, const string &value) { _variables[var] = value; string putstr = var + "=" + value; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_clear_shadow -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ExecutionEnvironment:: ns_clear_shadow(const string &var) { EnvironmentVariables::iterator vi = _variables.find(var); @@ -413,40 +391,30 @@ ns_clear_shadow(const string &var) { #endif // PREREAD_ENVIRONMENT } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_get_num_args -// Access: Private -// Description: Returns the number of command-line arguments -// available, not counting arg 0, the binary name. The -// nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of command-line arguments available, not counting arg 0, + * the binary name. The nonstatic implementation. + */ size_t ExecutionEnvironment:: ns_get_num_args() const { return _args.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_get_arg -// Access: Private -// Description: Returns the nth command-line argument. The index n -// must be in the range [0 .. get_num_args()). The -// first parameter, n == 0, is the first actual -// parameter, not the binary name. The nonstatic -// implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth command-line argument. The index n must be in the range [0 + * .. get_num_args()). The first parameter, n == 0, is the first actual + * parameter, not the binary name. The nonstatic implementation. + */ string ExecutionEnvironment:: ns_get_arg(size_t n) const { assert(n < ns_get_num_args()); return _args[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_get_binary_name -// Access: Private -// Description: Returns the name of the binary executable that -// started this program, if it can be determined. The -// nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the binary executable that started this program, if it + * can be determined. The nonstatic implementation. + */ string ExecutionEnvironment:: ns_get_binary_name() const { if (_binary_name.empty()) { @@ -455,13 +423,10 @@ ns_get_binary_name() const { return _binary_name; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::ns_get_dtool_name -// Access: Private -// Description: Returns the name of the libp3dtool DLL that -// is used in this program, if it can be determined. The -// nonstatic implementation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the libp3dtool DLL that is used in this program, if it + * can be determined. The nonstatic implementation. + */ string ExecutionEnvironment:: ns_get_dtool_name() const { if (_dtool_name.empty()) { @@ -470,12 +435,10 @@ ns_get_dtool_name() const { return _dtool_name; } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::get_ptr -// Access: Private, Static -// Description: Returns a static pointer that may be used to access -// the global ExecutionEnvironment object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a static pointer that may be used to access the global + * ExecutionEnvironment object. + */ ExecutionEnvironment *ExecutionEnvironment:: get_ptr() { if (_global_ptr == (ExecutionEnvironment *)NULL) { @@ -485,19 +448,16 @@ get_ptr() { } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::read_environment_variables -// Access: Private -// Description: Fills up the internal table of existing environment -// variables, if we are in PREREAD_ENVIRONMENT mode. -// Otherwise, does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the internal table of existing environment variables, if we are in + * PREREAD_ENVIRONMENT mode. Otherwise, does nothing. + */ void ExecutionEnvironment:: read_environment_variables() { #ifdef PREREAD_ENVIRONMENT #if defined(IS_OSX) || defined(IS_FREEBSD) || defined(IS_LINUX) - // In the case of Mac, we'll try reading _NSGetEnviron(). - // In the case of FreeBSD and Linux, use the "environ" variable. + // In the case of Mac, we'll try reading _NSGetEnviron(). In the case of + // FreeBSD and Linux, use the "environ" variable. char **envp; for (envp = environ; envp && *envp; envp++) { @@ -520,8 +480,8 @@ read_environment_variables() { } } #elif defined(HAVE_PROC_SELF_ENVIRON) - // In some cases, we may have a file called /proc/self/environ - // that may be read to determine all of our environment variables. + // In some cases, we may have a file called procselfenviron that may be read + // to determine all of our environment variables. pifstream proc("/proc/self/environ"); if (proc.fail()) { @@ -558,17 +518,15 @@ read_environment_variables() { #endif // PREREAD_ENVIRONMENT } -//////////////////////////////////////////////////////////////////// -// Function: ExecutionEnvironment::read_args -// Access: Private -// Description: Reads all the command-line arguments and the name of -// the binary file, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Reads all the command-line arguments and the name of the binary file, if + * possible. + */ void ExecutionEnvironment:: read_args() { #ifndef ANDROID - // First, we need to fill in _dtool_name. This contains - // the full path to the p3dtool library. + // First, we need to fill in _dtool_name. This contains the full path to + // the p3dtool library. #ifdef WIN32_VC #ifdef _DEBUG @@ -589,7 +547,7 @@ read_args() { #endif #if defined(__APPLE__) - // And on OSX we don't have /proc/self/maps, but some _dyld_* functions. + // And on OSX we don't have procselfmaps, but some _dyld_* functions. if (_dtool_name.empty()) { uint32_t ic = _dyld_image_count(); @@ -645,7 +603,7 @@ read_args() { #endif #if defined(HAVE_PROC_SELF_MAPS) || defined(HAVE_PROC_CURPROC_MAP) - // Some operating systems provide a file in the /proc filesystem. + // Some operating systems provide a file in the proc filesystem. if (_dtool_name.empty()) { #ifdef HAVE_PROC_CURPROC_MAP @@ -668,8 +626,8 @@ read_args() { } #endif - // Now, we need to fill in _binary_name. This contains - // the full path to the currently running executable. + // Now, we need to fill in _binary_name. This contains the full path to the + // currently running executable. #ifdef WIN32_VC if (_binary_name.empty()) { @@ -713,8 +671,8 @@ read_args() { #endif #if defined(HAVE_PROC_SELF_EXE) || defined(HAVE_PROC_CURPROC_FILE) - // Some operating systems provide a symbolic link to the executable - // in the /proc filesystem. Use readlink to resolve that link. + // Some operating systems provide a symbolic link to the executable in the + // proc filesystem. Use readlink to resolve that link. if (_binary_name.empty()) { char readlinkbuf [PATH_MAX]; @@ -730,13 +688,13 @@ read_args() { } #endif - // Next we need to fill in _args, which is a vector containing - // the command-line arguments that the executable was invoked with. + // Next we need to fill in _args, which is a vector containing the command- + // line arguments that the executable was invoked with. #if defined(WIN32_VC) - // We cannot rely on __argv when Python is linked in Unicode mode. - // Instead, let's use GetCommandLine. + // We cannot rely on __argv when Python is linked in Unicode mode. Instead, + // let's use GetCommandLine. LPWSTR cmdline = GetCommandLineW(); int argc = 0; @@ -789,8 +747,8 @@ read_args() { #elif defined(HAVE_GLOBAL_ARGV) int argc = GLOBAL_ARGC; - // On Windows, __argv can be NULL when the main entry point is - // compiled in Unicode mode (as is the case with Python 3) + // On Windows, __argv can be NULL when the main entry point is compiled in + // Unicode mode (as is the case with Python 3) if (GLOBAL_ARGV != NULL) { if (_binary_name.empty() && argc > 0) { _binary_name = GLOBAL_ARGV[0]; @@ -803,11 +761,10 @@ read_args() { } #elif defined(HAVE_PROC_SELF_CMDLINE) || defined(HAVE_PROC_CURPROC_CMDLINE) - // In Linux, and possibly in other systems as well, we might not be - // able to use the global ARGC/ARGV variables at static init time. - // However, we may be lucky and have a file called - // /proc/self/cmdline that may be read to determine all of our - // command-line arguments. + // In Linux, and possibly in other systems as well, we might not be able to + // use the global ARGCARGV variables at static init time. However, we may + // be lucky and have a file called procselfcmdline that may be read to + // determine all of our command-line arguments. #ifdef HAVE_PROC_CURPROC_CMDLINE pifstream proc("/proc/curproc/cmdline"); diff --git a/dtool/src/dtoolutil/executionEnvironment.h b/dtool/src/dtoolutil/executionEnvironment.h index 716b956258..bd1c6e879a 100644 --- a/dtool/src/dtoolutil/executionEnvironment.h +++ b/dtool/src/dtoolutil/executionEnvironment.h @@ -1,16 +1,15 @@ -// Filename: executionEnvironment.h -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file executionEnvironment.h + * @author drose + * @date 2000-05-15 + */ #ifndef EXECUTIONENVIRONMENT_H #define EXECUTIONENVIRONMENT_H @@ -22,14 +21,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : ExecutionEnvironment -// Description : Encapsulates access to the environment variables and -// command-line arguments at the time of execution. -// This is encapsulated to support accessing these -// things during static init time, which seems to be -// risky at best. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates access to the environment variables and command-line arguments + * at the time of execution. This is encapsulated to support accessing these + * things during static init time, which seems to be risky at best. + */ class EXPCL_DTOOL ExecutionEnvironment { private: ExecutionEnvironment(); diff --git a/dtool/src/dtoolutil/filename.I b/dtool/src/dtoolutil/filename.I index 130eaf2973..9ab46bf501 100644 --- a/dtool/src/dtoolutil/filename.I +++ b/dtool/src/dtoolutil/filename.I @@ -1,44 +1,37 @@ -// Filename: filename.I -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename.I + * @author drose + * @date 1999-01-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: Filename::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(const string &filename) { _flags = 0; (*this) = filename; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(const wstring &filename) { _flags = 0; (*this) = filename; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(const char *filename) { _flags = 0; @@ -46,11 +39,9 @@ Filename(const char *filename) { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(const Filename ©) : _filename(copy._filename.c_str()), @@ -65,11 +56,9 @@ Filename(const Filename ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::Move Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(string &&filename) NOEXCEPT { _flags = 0; @@ -78,11 +67,9 @@ Filename(string &&filename) NOEXCEPT { #endif // USE_MOVE_SEMANTICS #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::Move Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: Filename(Filename &&from) NOEXCEPT : _filename(move(from._filename)), @@ -97,11 +84,9 @@ Filename(Filename &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::text_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: text_filename(const Filename &filename) { Filename result(filename); @@ -109,11 +94,9 @@ text_filename(const Filename &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::text_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: text_filename(const string &filename) { Filename result(filename); @@ -121,11 +104,9 @@ text_filename(const string &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::binary_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: binary_filename(const Filename &filename) { Filename result(filename); @@ -133,11 +114,9 @@ binary_filename(const Filename &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::binary_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: binary_filename(const string &filename) { Filename result(filename); @@ -145,11 +124,9 @@ binary_filename(const string &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::dso_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: dso_filename(const string &filename) { Filename result(filename); @@ -157,11 +134,9 @@ dso_filename(const string &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::executable_filename named constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename Filename:: executable_filename(const string &filename) { Filename result(filename); @@ -169,12 +144,10 @@ executable_filename(const string &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::pattern_filename named constructor -// Access: Published -// Description: Constructs a filename that represents a sequence of -// numbered files. See set_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a filename that represents a sequence of numbered files. See + * set_pattern(). + */ INLINE Filename Filename:: pattern_filename(const string &filename) { Filename result(filename); @@ -182,21 +155,17 @@ pattern_filename(const string &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: ~Filename() { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (const string &filename) { _filename = filename; @@ -207,11 +176,9 @@ operator = (const string &filename) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (const wstring &filename) { TextEncoder encoder; @@ -220,22 +187,18 @@ operator = (const wstring &filename) { return operator = (encoder.get_text()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (const char *filename) { assert(filename != NULL); return (*this) = string(filename); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (const Filename ©) { _filename = copy._filename; @@ -250,11 +213,9 @@ operator = (const Filename ©) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::Move assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (string &&filename) NOEXCEPT { _filename = move(filename); @@ -267,11 +228,9 @@ operator = (string &&filename) NOEXCEPT { #endif // USE_MOVE_SEMANTICS #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::Move assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename &Filename:: operator = (Filename &&from) NOEXCEPT { _filename = MOVE(from._filename); @@ -286,84 +245,68 @@ operator = (Filename &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Filename::string typecast operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Filename:: operator const string & () const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::c_str -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const char *Filename:: c_str() const { return _filename.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::empty -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Filename:: empty() const { return _filename.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Filename:: length() const { return _filename.length(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Indexing operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE char Filename:: operator [] (size_t n) const { assert(n < _filename.length()); return _filename[n]; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::substr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string Filename:: substr(size_t begin) const { return _filename.substr(begin); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::substr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string Filename:: substr(size_t begin, size_t end) const { return _filename.substr(begin, end); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::operator += -// Access: Published -// Description: Appends the other filename onto the end of this one. -// This does not introduce an intervening slash, but see -// the Filename constructor that takes two parameters. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other filename onto the end of this one. This does not + * introduce an intervening slash, but see the Filename constructor that takes + * two parameters. + */ INLINE void Filename:: operator += (const string &other) { _filename += other; @@ -372,12 +315,9 @@ operator += (const string &other) { locate_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::operator + -// Access: Published -// Description: Returns a new Filename representing the concatenation -// of the two filenames. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Filename representing the concatenation of the two filenames. + */ INLINE Filename Filename:: operator + (const string &other) const { Filename a(*this); @@ -385,36 +325,27 @@ operator + (const string &other) const { return a; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::operator / -// Access: Published -// Description: Returns a new Filename that is composed of the -// other filename added to the end of this filename, -// with an intervening slash added if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Filename that is composed of the other filename added to the + * end of this filename, with an intervening slash added if necessary. + */ INLINE Filename Filename:: operator / (const Filename &other) const { return Filename(*this, other); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_fullpath -// Access: Published -// Description: Returns the entire filename: directory, basename, -// extension. This is the same thing returned by the -// string typecast operator. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire filename: directory, basename, extension. This is the + * same thing returned by the string typecast operator. + */ INLINE string Filename:: get_fullpath() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_fullpath_w -// Access: Published -// Description: Returns the entire filename as a wide-character -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire filename as a wide-character string. + */ INLINE wstring Filename:: get_fullpath_w() const { TextEncoder encoder; @@ -423,49 +354,38 @@ get_fullpath_w() const { return encoder.get_wtext(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_dirname -// Access: Published -// Description: Returns the directory part of the filename. This is -// everything in the filename up to, but not including -// the rightmost slash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory part of the filename. This is everything in the + * filename up to, but not including the rightmost slash. + */ INLINE string Filename:: get_dirname() const { return _filename.substr(0, _dirname_end); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_basename -// Access: Published -// Description: Returns the basename part of the filename. This is -// everything in the filename after the rightmost slash, -// including any extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename part of the filename. This is everything in the + * filename after the rightmost slash, including any extensions. + */ INLINE string Filename:: get_basename() const { return _filename.substr(_basename_start); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_fullpath_wo_extension -// Access: Published -// Description: Returns the full filename--directory and basename -// parts--except for the extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full filename--directory and basename parts--except for the + * extension. + */ INLINE string Filename:: get_fullpath_wo_extension() const { return _filename.substr(0, _basename_end); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_basename_wo_extension -// Access: Published -// Description: Returns the basename part of the filename, without -// the file extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename part of the filename, without the file extension. + */ INLINE string Filename:: get_basename_wo_extension() const { if (_basename_end == string::npos) { @@ -476,13 +396,10 @@ get_basename_wo_extension() const { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_extension -// Access: Published -// Description: Returns the file extension. This is everything after -// the rightmost dot, if there is one, or the empty -// string if there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the file extension. This is everything after the rightmost dot, if + * there is one, or the empty string if there is not. + */ INLINE string Filename:: get_extension() const { if (_extension_start == string::npos) { @@ -492,84 +409,65 @@ get_extension() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_binary -// Access: Published -// Description: Indicates that the filename represents a binary file. -// This is primarily relevant to the read_file() and -// write_file() methods, so they can set the appropriate -// flags to the OS. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the filename represents a binary file. This is primarily + * relevant to the read_file() and write_file() methods, so they can set the + * appropriate flags to the OS. + */ INLINE void Filename:: set_binary() { _flags = (_flags & ~F_text) | F_binary; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_text -// Access: Published -// Description: Indicates that the filename represents a text file. -// This is primarily relevant to the read_file() and -// write_file() methods, so they can set the appropriate -// flags to the OS. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the filename represents a text file. This is primarily + * relevant to the read_file() and write_file() methods, so they can set the + * appropriate flags to the OS. + */ INLINE void Filename:: set_text() { _flags = (_flags & ~F_binary) | F_text; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_binary -// Access: Published -// Description: Returns true if the Filename has been indicated to -// represent a binary file via a previous call to -// set_binary(). It is possible that neither -// is_binary() nor is_text() will be true, if neither -// set_binary() nor set_text() was ever called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Filename has been indicated to represent a binary file + * via a previous call to set_binary(). It is possible that neither + * is_binary() nor is_text() will be true, if neither set_binary() nor + * set_text() was ever called. + */ INLINE bool Filename:: is_binary() const { return ((_flags & F_binary) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_binary_or_text -// Access: Published -// Description: Returns true either is_binary() or is_text() is true; -// that is, that the filename has been specified as -// either binary or text. If this is false, the -// filename has not been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true either is_binary() or is_text() is true; that is, that the + * filename has been specified as either binary or text. If this is false, + * the filename has not been specified. + */ INLINE bool Filename:: is_binary_or_text() const { return ((_flags & (F_binary | F_text)) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_text -// Access: Published -// Description: Returns true if the Filename has been indicated to -// represent a text file via a previous call to -// set_text(). It is possible that neither is_binary() -// nor is_text() will be true, if neither set_binary() -// nor set_text() was ever called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Filename has been indicated to represent a text file + * via a previous call to set_text(). It is possible that neither is_binary() + * nor is_text() will be true, if neither set_binary() nor set_text() was ever + * called. + */ INLINE bool Filename:: is_text() const { return ((_flags & F_text) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_type -// Access: Published -// Description: Sets the type of the file represented by the -// filename. This is useful for to_os_specific(), -// resolve_filename(), test_existence(), and all such -// real-world access functions. It helps the Filename -// know how to map the internal filename to the -// OS-specific filename (for instance, maybe executables -// should have an .exe extension). -//////////////////////////////////////////////////////////////////// +/** + * Sets the type of the file represented by the filename. This is useful for + * to_os_specific(), resolve_filename(), test_existence(), and all such real- + * world access functions. It helps the Filename know how to map the internal + * filename to the OS-specific filename (for instance, maybe executables + * should have an .exe extension). + */ INLINE void Filename:: set_type(Filename::Type type) { _flags = (_flags & ~F_type) | type; @@ -583,35 +481,28 @@ set_type(Filename::Type type) { } } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_type -// Access: Published -// Description: Returns the type of the file represented by the -// filename, as previously set by set_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the file represented by the filename, as previously set + * by set_type(). + */ INLINE Filename::Type Filename:: get_type() const { return (Type)(_flags & (int)F_type); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_pattern -// Access: Published -// Description: Sets the flag indicating whether this is a filename -// pattern. When this is true, the filename is -// understood to be a placeholder for a numbered -// sequence of filename, such as an image sequence. In -// this case, a sequence of one or more hash characters -// ("#") should appear in the filename string; these -// characters will be filled in with the corresponding -// number (or more) of digits representing the sequence -// number. Sequence numbers always begin counting at 0. -// -// When this is true, methods like has_hash() and -// get_hash_to_end() and get_filename_index() may be -// called. Methods like is_exists() will implicitly -// test for existance of filename sequence 0. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether this is a filename pattern. When this is + * true, the filename is understood to be a placeholder for a numbered + * sequence of filename, such as an image sequence. In this case, a sequence + * of one or more hash characters ("#") should appear in the filename string; + * these characters will be filled in with the corresponding number (or more) + * of digits representing the sequence number. Sequence numbers always begin + * counting at 0. + * + * When this is true, methods like has_hash() and get_hash_to_end() and + * get_filename_index() may be called. Methods like is_exists() will + * implicitly test for existance of filename sequence 0. + */ INLINE void Filename:: set_pattern(bool pattern) { if (pattern != get_pattern()) { @@ -624,70 +515,53 @@ set_pattern(bool pattern) { } } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_pattern -// Access: Published -// Description: Returns the flag indicating whether this is a -// filename pattern. See set_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag indicating whether this is a filename pattern. See + * set_pattern(). + */ INLINE bool Filename:: get_pattern() const { return (_flags & F_pattern) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::has_hash -// Access: Published -// Description: Returns true if the filename is indicated to be a -// filename pattern (that is, set_pattern(true) was -// called), and the filename pattern did include a -// sequence of hash marks, or false if it was not a -// filename pattern or did not include hash marks. If -// this is true, then get_filename_index() will return a -// different filename each time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename is indicated to be a filename pattern (that + * is, set_pattern(true) was called), and the filename pattern did include a + * sequence of hash marks, or false if it was not a filename pattern or did + * not include hash marks. If this is true, then get_filename_index() will + * return a different filename each time. + */ INLINE bool Filename:: has_hash() const { return (_hash_start != _hash_end); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_hash_to_end -// Access: Published -// Description: Returns the part of the filename beginning at the -// hash sequence (if any), and continuing to the end of -// the filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the part of the filename beginning at the hash sequence (if any), + * and continuing to the end of the filename. + */ INLINE string Filename:: get_hash_to_end() const { return _filename.substr(_hash_start); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_local -// Access: Published -// Description: Returns true if the filename is local, e.g. does not -// begin with a slash, or false if the filename is fully -// specified from the root. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename is local, e.g. does not begin with a slash, + * or false if the filename is fully specified from the root. + */ INLINE bool Filename:: is_local() const { return _filename.empty() || _filename[0] != '/'; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_fully_qualified -// Access: Published -// Description: Returns true if the filename is fully qualified, -// e.g. begins with a slash. This is almost, but not -// quite, the same thing as !is_local(). It's not -// exactly the same because a special case is made for -// filenames that begin with a single dot followed by a -// slash--these are considered to be fully qualified -// (they are explicitly relative to the current -// directory, and do not refer to a filename on a search -// path somewhere). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename is fully qualified, e.g. begins with a slash. + * This is almost, but not quite, the same thing as !is_local(). It's not + * exactly the same because a special case is made for filenames that begin + * with a single dot followed by a slash--these are considered to be fully + * qualified (they are explicitly relative to the current directory, and do + * not refer to a filename on a search path somewhere). + */ INLINE bool Filename:: is_fully_qualified() const { return @@ -695,95 +569,76 @@ is_fully_qualified() const { (!_filename.empty() && _filename[0] == '/'); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Equality operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Filename:: operator == (const string &other) const { return (*(string *)this) == other; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Inequality operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Filename:: operator != (const string &other) const { return (*(string *)this) != other; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::Ordering operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Filename:: operator < (const string &other) const { return (*(string *)this) < other; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::compare_to -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int Filename:: compare_to(const Filename &other) const { return strcmp(_filename.c_str(), other._filename.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::__nonzero__ -// Access: Published -// Description: Returns true if the Filename is valid (not empty), -// or false if it is an empty string. -// -// This implements the Python equivalent to operator -// bool. Defining an actual operator bool method for -// C++ use would work too, but it seems to cause too -// many ambiguities for the C++ compiler, so we use this -// Python-only approach instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Filename is valid (not empty), or false if it is an + * empty string. + * + * This implements the Python equivalent to operator bool. Defining an actual + * operator bool method for C++ use would work too, but it seems to cause too + * many ambiguities for the C++ compiler, so we use this Python-only approach + * instead. + */ INLINE bool Filename:: __nonzero__() const { return !_filename.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Filename:: output(ostream &out) const { out << _filename; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_filesystem_encoding -// Access: Published, Static -// Description: Specifies the default encoding to be used for all -// subsequent Filenames. This is used to represent -// wide-character (Unicode) filenames internally. On -// non-Windows-based systems, the encoded filename is -// also passed to the underlying operating system. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default encoding to be used for all subsequent Filenames. + * This is used to represent wide-character (Unicode) filenames internally. + * On non-Windows-based systems, the encoded filename is also passed to the + * underlying operating system. + */ INLINE void Filename:: set_filesystem_encoding(TextEncoder::Encoding encoding) { _filesystem_encoding = encoding; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_filesystem_encoding -// Access: Published, Static -// Description: Specifies the default encoding to be used for all -// subsequent Filenames objects. See -// set_filesystem_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default encoding to be used for all subsequent Filenames + * objects. See set_filesystem_encoding(). + */ INLINE TextEncoder::Encoding Filename:: get_filesystem_encoding() { return _filesystem_encoding; diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index f6cf299c77..8d6fa1e415 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -1,16 +1,15 @@ -// Filename: filename.cxx -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename.cxx + * @author drose + * @date 1999-01-18 + */ #include "filename.h" #include "filename_assist.h" @@ -43,8 +42,8 @@ #include #endif -// It's true that dtoolbase.h includes this already, but we include -// this again in case we are building this file within ppremake. +// It's true that dtoolbase.h includes this already, but we include this again +// in case we are building this file within ppremake. #ifdef PHAVE_UNISTD_H #include #endif @@ -77,39 +76,39 @@ string Filename::_internal_data_dir; #define FILE_ATTRIBUTE_DEVICE 0x00000040 #endif -// We might have been linked with the Cygwin dll. This is ideal if it -// is available, because it allows Panda to access all the Cygwin -// mount definitions if they are in use. If the Cygwin dll is not -// available, we fall back to our own convention for converting -// pathnames. +// We might have been linked with the Cygwin dll. This is ideal if it is +// available, because it allows Panda to access all the Cygwin mount +// definitions if they are in use. If the Cygwin dll is not available, we +// fall back to our own convention for converting pathnames. #ifdef HAVE_CYGWIN extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32); extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix); #endif -// Windows uses the convention \\hostname\path\to\file to represent a -// pathname to a file on another share. This redefines a pathname to -// be something more complicated than a sequence of directory names -// separated by slashes. The Unix convention to represent the same -// thing is, like everything else, to graft the reference to the -// remote hostname into the one global filesystem, with something like -// /hosts/hostname/path/to/file. We observe the Unix convention for -// internal names used in Panda; this makes operations -// like Filename::get_dirname() simpler and more internally consistent. +/* + * Windows uses the convention \\hostname\path\to\file to represent a pathname + * to a file on another share. This redefines a pathname to be something more + * complicated than a sequence of directory names separated by slashes. The + * Unix convention to represent the same thing is, like everything else, to + * graft the reference to the remote hostname into the one global filesystem, + * with something like hostshostnamepathtofile. We observe the Unix + * convention for internal names used in Panda; this makes operations like + * Filename::get_dirname() simpler and more internally consistent. + */ -// This string hard-defines the prefix that we use internally to -// indicate that the next directory component name should be treated -// as a hostname. It might be nice to use a ConfigVariable for this, -// except that we haven't defined ConfigVariable by this point (and -// indeed we can't, since we need to have a Filename class already -// created in order to read the first config file). Windows purists -// might be tempted to define this to a double slash so that internal -// Panda filenames more closely resemble their Windows counterparts. -// That might actually work, but it will cause problems -// with Filename::standardize(). +/* + * This string hard-defines the prefix that we use internally to indicate that + * the next directory component name should be treated as a hostname. It + * might be nice to use a ConfigVariable for this, except that we haven't + * defined ConfigVariable by this point (and indeed we can't, since we need to + * have a Filename class already created in order to read the first config + * file). Windows purists might be tempted to define this to a double slash + * so that internal Panda filenames more closely resemble their Windows + * counterparts. That might actually work, but it will cause problems with + * Filename::standardize(). + */ -// We use const char * instead of string to avoid static-init ordering -// issues. +// We use const char * instead of string to avoid static-init ordering issues. static const char *hosts_prefix = "/hosts/"; static size_t hosts_prefix_length = 7; @@ -150,10 +149,10 @@ get_panda_root() { (*panda_root) = front_to_back_slash(envvar); } - // Ensure the string ends in a backslash. If PANDA_ROOT is empty - // or undefined, this function must return a single backslash--not - // an empty string--since this prefix is used to replace a leading - // slash in Filename::to_os_specific(). + // Ensure the string ends in a backslash. If PANDA_ROOT is empty or + // undefined, this function must return a single backslash--not an empty + // string--since this prefix is used to replace a leading slash in + // Filename::to_os_specific(). if ((*panda_root).empty() || (*panda_root)[(*panda_root).length() - 1] != '\\') { (*panda_root) += '\\'; } @@ -168,54 +167,51 @@ convert_pathname(const string &unix_style_pathname) { return string(); } - // To convert from a Unix-style pathname to a Windows-style - // pathname, we need to change all forward slashes to backslashes. - // We might need to add a prefix as well, since Windows pathnames - // typically begin with a drive letter. + // To convert from a Unix-style pathname to a Windows-style pathname, we + // need to change all forward slashes to backslashes. We might need to add + // a prefix as well, since Windows pathnames typically begin with a drive + // letter. - // By convention, if the top directory name consists of just one - // letter, we treat that as a drive letter and map the rest of the - // filename accordingly. On the other hand, if the top directory - // name consists of more than one letter, we assume this is a file - // within some predefined tree whose root is given by the - // environment variable "PANDA_ROOT", or if that is not defined, - // "CYGWIN_ROOT" (for backward compatibility). + // By convention, if the top directory name consists of just one letter, we + // treat that as a drive letter and map the rest of the filename + // accordingly. On the other hand, if the top directory name consists of + // more than one letter, we assume this is a file within some predefined + // tree whose root is given by the environment variable "PANDA_ROOT", or if + // that is not defined, "CYGWIN_ROOT" (for backward compatibility). string windows_pathname; if (unix_style_pathname[0] != '/') { - // It doesn't even start from the root, so we don't have to do - // anything fancy--relative pathnames are the same in Windows as - // in Unix, except for the direction of the slashes. + // It doesn't even start from the root, so we don't have to do anything + // fancy--relative pathnames are the same in Windows as in Unix, except + // for the direction of the slashes. windows_pathname = front_to_back_slash(unix_style_pathname); } else if (unix_style_pathname.length() >= 2 && isalpha(unix_style_pathname[1]) && (unix_style_pathname.length() == 2 || unix_style_pathname[2] == '/')) { - // This pathname begins with a slash and a single letter. That - // must be the drive letter. + // This pathname begins with a slash and a single letter. That must be + // the drive letter. string remainder = unix_style_pathname.substr(2); if (remainder.empty()) { - // There's a difference between "C:" and "C:/". + // There's a difference between "C:" and "C:". remainder = "/"; } remainder = front_to_back_slash(remainder); // We have to cast the result of toupper() to (char) to help some - // compilers (e.g. Cygwin's gcc 2.95.3) happy; so that they do not - // confuse this string constructor with one that takes two - // iterators. + // compilers (e.g. Cygwin's gcc 2.95.3) happy; so that they do not + // confuse this string constructor with one that takes two iterators. windows_pathname = string(1, (char)toupper(unix_style_pathname[1])) + ":" + remainder; } else if (unix_style_pathname.length() > hosts_prefix_length && unix_style_pathname.substr(0, hosts_prefix_length) == hosts_prefix) { - // A filename like /hosts/fooby gets turned into \\fooby. + // A filename like hostsfooby gets turned into \\fooby. windows_pathname = "\\\\" + front_to_back_slash(unix_style_pathname.substr(hosts_prefix_length)); } else { - // It starts with a slash, but the first part is not a single - // letter. + // It starts with a slash, but the first part is not a single letter. #ifdef HAVE_CYGWIN // Use Cygwin to convert it if possible. @@ -251,16 +247,15 @@ convert_dso_pathname(const string &unix_style_pathname) { string dll_basename = unix_style_pathname.substr(0, dot); #ifdef _DEBUG - // If we're building a debug version, all the dso files we link in - // must be named file_d.dll. This does prohibit us from linking in - // external dso files, generated outside of the Panda build system, - // that don't follow this _d convention. Maybe we need a separate + // If we're building a debug version, all the dso files we link in must be + // named file_d.dll. This does prohibit us from linking in external dso + // files, generated outside of the Panda build system, that don't follow + // this _d convention. Maybe we need a separate // convert_system_dso_pathname() function. - // We can't simply check to see if the file exists, because this - // might not be a full path to the dso filename--it might be - // somewhere on the LD_LIBRARY_PATH, or on PATH, or any of a number - // of nutty places. + // We can't simply check to see if the file exists, because this might not + // be a full path to the dso filename--it might be somewhere on the + // LD_LIBRARY_PATH, or on PATH, or any of a number of nutty places. return convert_pathname(dll_basename + "_d.dll"); #else @@ -286,13 +281,10 @@ convert_executable_pathname(const string &unix_style_pathname) { } #endif //WIN32 -//////////////////////////////////////////////////////////////////// -// Function: Filename::Constructor -// Access: Published -// Description: This constructor composes the filename out of a -// directory part and a basename part. It will insert -// an intervening '/' if necessary. -//////////////////////////////////////////////////////////////////// +/** + * This constructor composes the filename out of a directory part and a + * basename part. It will insert an intervening '/' if necessary. + */ Filename:: Filename(const Filename &dirname, const Filename &basename) { if (dirname.empty()) { @@ -308,26 +300,20 @@ Filename(const Filename &dirname, const Filename &basename) { } } -//////////////////////////////////////////////////////////////////// -// Function: Filename::from_os_specific -// Access: Published, Static -// Description: This named constructor returns a Panda-style filename -// (that is, using forward slashes, and no drive letter) -// based on the supplied filename string that describes -// a filename in the local system conventions (for -// instance, on Windows, it may use backslashes or begin -// with a drive letter and a colon). -// -// Use this function to create a Filename from an -// externally-given filename string. Use -// to_os_specific() again later to reconvert it back to -// the local operating system's conventions. -// -// This function will do the right thing even if the -// filename is partially local conventions and partially -// Panda conventions; e.g. some backslashes and some -// forward slashes. -//////////////////////////////////////////////////////////////////// +/** + * This named constructor returns a Panda-style filename (that is, using + * forward slashes, and no drive letter) based on the supplied filename string + * that describes a filename in the local system conventions (for instance, on + * Windows, it may use backslashes or begin with a drive letter and a colon). + * + * Use this function to create a Filename from an externally-given filename + * string. Use to_os_specific() again later to reconvert it back to the local + * operating system's conventions. + * + * This function will do the right thing even if the filename is partially + * local conventions and partially Panda conventions; e.g. some backslashes + * and some forward slashes. + */ Filename Filename:: from_os_specific(const string &os_specific, Filename::Type type) { #ifdef WIN32 @@ -348,8 +334,8 @@ from_os_specific(const string &os_specific, Filename::Type type) { } if (matches) { - // The initial prefix matches! Replace the initial bit with a - // leading slash. + // The initial prefix matches! Replace the initial bit with a leading + // slash. result = result.substr(panda_root.length()); assert(!result.empty()); if (result[0] != '/') { @@ -361,21 +347,21 @@ from_os_specific(const string &os_specific, Filename::Type type) { } } - // All right, the initial prefix was not under panda_root. But - // maybe it begins with a drive letter. + // All right, the initial prefix was not under panda_root. But maybe it + // begins with a drive letter. if (result.size() >= 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/') { result[1] = tolower(result[0]); result[0] = '/'; - // If there's *just* a slash following the drive letter, go ahead - // and trim it. + // If there's *just* a slash following the drive letter, go ahead and trim + // it. if (result.size() == 3) { result = result.substr(0, 2); } } else if (result.substr(0, 2) == "//") { - // If the initial prefix is a double slash, convert it to /hosts/. + // If the initial prefix is a double slash, convert it to hosts. result = hosts_prefix + result.substr(2); } @@ -390,13 +376,10 @@ from_os_specific(const string &os_specific, Filename::Type type) { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::from_os_specific_w -// Access: Published, Static -// Description: The wide-string variant of from_os_specific(). -// Returns a new Filename, converted from an os-specific -// wide-character string. -//////////////////////////////////////////////////////////////////// +/** + * The wide-string variant of from_os_specific(). Returns a new Filename, + * converted from an os-specific wide-character string. + */ Filename Filename:: from_os_specific_w(const wstring &os_specific, Filename::Type type) { TextEncoder encoder; @@ -405,15 +388,11 @@ from_os_specific_w(const wstring &os_specific, Filename::Type type) { return from_os_specific(encoder.get_text(), type); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::expand_from -// Access: Published, Static -// Description: Returns the same thing as from_os_specific(), but -// embedded environment variable references -// (e.g. "$DMODELS/foo.txt") are expanded out. It also -// automatically elevates the file to its true case if -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same thing as from_os_specific(), but embedded environment + * variable references (e.g. "$DMODELS/foo.txt") are expanded out. It also + * automatically elevates the file to its true case if needed. + */ Filename Filename:: expand_from(const string &os_specific, Filename::Type type) { Filename file = from_os_specific(ExecutionEnvironment::expand_string(os_specific), @@ -422,34 +401,30 @@ expand_from(const string &os_specific, Filename::Type type) { return file; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::temporary -// Access: Published, Static -// Description: Generates a temporary filename within the indicated -// directory, using the indicated prefix. If the -// directory is empty, a system-defined directory is -// chosen instead. -// -// The generated filename did not exist when the -// Filename checked, but since it does not specifically -// create the file, it is possible that another process -// could simultaneously create a file by the same name. -//////////////////////////////////////////////////////////////////// +/** + * Generates a temporary filename within the indicated directory, using the + * indicated prefix. If the directory is empty, a system-defined directory is + * chosen instead. + * + * The generated filename did not exist when the Filename checked, but since + * it does not specifically create the file, it is possible that another + * process could simultaneously create a file by the same name. + */ Filename Filename:: temporary(const string &dirname, const string &prefix, const string &suffix, Type type) { Filename fdirname = dirname; #if defined(_WIN32) || defined(ANDROID) - // The Windows tempnam() function doesn't do a good job of choosing - // a temporary directory. Choose one ourselves. + // The Windows tempnam() function doesn't do a good job of choosing a + // temporary directory. Choose one ourselves. if (fdirname.empty()) { fdirname = Filename::get_temp_directory(); } #endif if (fdirname.empty()) { - // If we are not given a dirname, use the system tempnam() - // function to create a system-defined temporary filename. + // If we are not given a dirname, use the system tempnam() function to + // create a system-defined temporary filename. char *name = tempnam(NULL, prefix.c_str()); Filename result = Filename::from_os_specific(name); free(name); @@ -457,15 +432,15 @@ temporary(const string &dirname, const string &prefix, const string &suffix, return result; } - // If we *are* given a dirname, then use our own algorithm to make - // up a filename within that dirname. We do that because the system - // tempnam() (for instance, under Windows) may ignore the dirname. + // If we *are* given a dirname, then use our own algorithm to make up a + // filename within that dirname. We do that because the system tempnam() + // (for instance, under Windows) may ignore the dirname. Filename result; do { - // We take the time of day and multiply it by the process time. - // This will give us a very large number, of which we take the - // bottom 24 bits and generate a 6-character hex code. + // We take the time of day and multiply it by the process time. This will + // give us a very large number, of which we take the bottom 24 bits and + // generate a 6-character hex code. int hash = (clock() * time(NULL)) & 0xffffff; char hex_code[10]; sprintf(hex_code, "%06x", hash); @@ -476,14 +451,11 @@ temporary(const string &dirname, const string &prefix, const string &suffix, return result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_home_directory -// Access: Published -// Description: Returns a path to the user's home directory, if such -// a thing makes sense in the current OS, or to the -// nearest equivalent. This may or may not be directly -// writable by the application. -//////////////////////////////////////////////////////////////////// +/** + * Returns a path to the user's home directory, if such a thing makes sense in + * the current OS, or to the nearest equivalent. This may or may not be + * directly writable by the application. + */ const Filename &Filename:: get_home_directory() { if (AtomicAdjust::get_ptr(_home_directory) == NULL) { @@ -525,7 +497,7 @@ get_home_directory() { home_directory = _internal_data_dir; #else - // Posix case: check /etc/passwd? + // Posix case: check etcpasswd? #endif // WIN32 } @@ -546,12 +518,9 @@ get_home_directory() { return (*(Filename *)_home_directory); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_temp_directory -// Access: Published -// Description: Returns a path to a system-defined temporary -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns a path to a system-defined temporary directory. + */ const Filename &Filename:: get_temp_directory() { if (AtomicAdjust::get_ptr(_temp_directory) == NULL) { @@ -597,14 +566,11 @@ get_temp_directory() { return (*(Filename *)_temp_directory); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_user_appdata_directory -// Access: Published -// Description: Returns a path to a system-defined directory -// appropriate for creating a subdirectory for storing -// application-specific data, specific to the current -// user. -//////////////////////////////////////////////////////////////////// +/** + * Returns a path to a system-defined directory appropriate for creating a + * subdirectory for storing application-specific data, specific to the current + * user. + */ const Filename &Filename:: get_user_appdata_directory() { if (AtomicAdjust::get_ptr(_user_appdata_directory) == NULL) { @@ -651,13 +617,10 @@ get_user_appdata_directory() { return (*(Filename *)_user_appdata_directory); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_common_appdata_directory -// Access: Published -// Description: Returns a path to a system-defined directory -// appropriate for creating a subdirectory for storing -// application-specific data, common to all users. -//////////////////////////////////////////////////////////////////// +/** + * Returns a path to a system-defined directory appropriate for creating a + * subdirectory for storing application-specific data, common to all users. + */ const Filename &Filename:: get_common_appdata_directory() { if (AtomicAdjust::get_ptr(_common_appdata_directory) == NULL) { @@ -703,25 +666,19 @@ get_common_appdata_directory() { return (*(Filename *)_common_appdata_directory); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_fullpath -// Access: Published -// Description: Replaces the entire filename: directory, basename, -// extension. This can also be achieved with the -// assignment operator. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the entire filename: directory, basename, extension. This can + * also be achieved with the assignment operator. + */ void Filename:: set_fullpath(const string &s) { (*this) = s; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_dirname -// Access: Published -// Description: Replaces the directory part of the filename. This is -// everything in the filename up to, but not including -// the rightmost slash. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the directory part of the filename. This is everything in the + * filename up to, but not including the rightmost slash. + */ void Filename:: set_dirname(const string &s) { if (s.empty()) { @@ -752,8 +709,8 @@ set_dirname(const string &s) { _dirname_end = ss.length() - 1; - // An exception: if the dirname string was the single slash, the - // dirname includes that slash. + // An exception: if the dirname string was the single slash, the dirname + // includes that slash. if (ss.length() == 1) { _dirname_end = 1; } @@ -768,13 +725,10 @@ set_dirname(const string &s) { locate_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_basename -// Access: Published -// Description: Replaces the basename part of the filename. This is -// everything in the filename after the rightmost slash, -// including any extensions. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the basename part of the filename. This is everything in the + * filename after the rightmost slash, including any extensions. + */ void Filename:: set_basename(const string &s) { _filename.replace(_basename_start, string::npos, s); @@ -783,12 +737,10 @@ set_basename(const string &s) { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_fullpath_wo_extension -// Access: Published -// Description: Replaces the full filename--directory and basename -// parts--except for the extension. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the full filename--directory and basename parts--except for the + * extension. + */ void Filename:: set_fullpath_wo_extension(const string &s) { int length_change = (int)s.length() - (int)_basename_end; @@ -803,12 +755,9 @@ set_fullpath_wo_extension(const string &s) { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_basename_wo_extension -// Access: Published -// Description: Replaces the basename part of the filename, without -// the file extension. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the basename part of the filename, without the file extension. + */ void Filename:: set_basename_wo_extension(const string &s) { int length_change = (int)s.length() - (int)(_basename_end - _basename_start); @@ -826,13 +775,10 @@ set_basename_wo_extension(const string &s) { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_extension -// Access: Published -// Description: Replaces the file extension. This is everything after -// the rightmost dot, if there is one, or the empty -// string if there is not. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the file extension. This is everything after the rightmost dot, + * if there is one, or the empty string if there is not. + */ void Filename:: set_extension(const string &s) { if (s.empty()) { @@ -856,19 +802,15 @@ set_extension(const string &s) { locate_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_filename_index -// Access: Published -// Description: If the pattern flag is set for this Filename and the -// filename string actually includes a sequence of hash -// marks, then this returns a new Filename with the -// sequence of hash marks replaced by the indicated -// index number. -// -// If the pattern flag is not set for this Filename or -// it does not contain a sequence of hash marks, this -// quietly returns the original filename. -//////////////////////////////////////////////////////////////////// +/** + * If the pattern flag is set for this Filename and the filename string + * actually includes a sequence of hash marks, then this returns a new + * Filename with the sequence of hash marks replaced by the indicated index + * number. + * + * If the pattern flag is not set for this Filename or it does not contain a + * sequence of hash marks, this quietly returns the original filename. + */ Filename Filename:: get_filename_index(int index) const { Filename file(*this); @@ -885,12 +827,10 @@ get_filename_index(int index) const { return file; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::set_hash_to_end -// Access: Published -// Description: Replaces the part of the filename from the beginning -// of the hash sequence to the end of the filename. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the part of the filename from the beginning of the hash sequence + * to the end of the filename. + */ void Filename:: set_hash_to_end(const string &s) { _filename.replace(_hash_start, string::npos, s); @@ -900,16 +840,13 @@ set_hash_to_end(const string &s) { locate_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::extract_components -// Access: Published -// Description: Extracts out the individual directory components of -// the path into a series of strings. get_basename() -// will be the last component stored in the vector. -// Note that no distinction is made by this method -// between a leading slash and no leading slash, but you -// can call is_local() to differentiate the two cases. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out the individual directory components of the path into a series + * of strings. get_basename() will be the last component stored in the + * vector. Note that no distinction is made by this method between a leading + * slash and no leading slash, but you can call is_local() to differentiate + * the two cases. + */ void Filename:: extract_components(vector_string &components) const { components.clear(); @@ -933,14 +870,11 @@ extract_components(vector_string &components) const { components.push_back(string()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::standardize -// Access: Published -// Description: Converts the filename to standard form by replacing -// consecutive slashes with a single slash, removing a -// trailing slash if present, and backing up over ../ -// sequences within the filename where possible. -//////////////////////////////////////////////////////////////////// +/** + * Converts the filename to standard form by replacing consecutive slashes + * with a single slash, removing a trailing slash if present, and backing up + * over .. sequences within the filename where possible. + */ void Filename:: standardize() { assert(!_filename.empty()); @@ -962,12 +896,11 @@ standardize() { size_t slash = _filename.find('/', p); string component = _filename.substr(p, slash - p); if (component == "." && p != 0) { - // Ignore /./. + // Ignore .. } else if (component == ".." && !components.empty() && !(components.back() == "..")) { if (components.back() == ".") { - // To "back up" over a leading ./ means simply to remove the - // leading ./ + // To "back up" over a leading . means simply to remove the leading . components.pop_back(); components.push_back(component); } else { @@ -999,22 +932,17 @@ standardize() { (*this) = result; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_absolute -// Access: Published -// Description: Converts the filename to a fully-qualified pathname -// from the root (if it is a relative pathname), and -// then standardizes it (see standardize()). -// -// This is sometimes a little problematic, since it may -// convert the file to its 'true' absolute pathname, -// which could be an ugly NFS-named file, irrespective -// of symbolic links -// (e.g. /.automount/dimbo/root/usr2/fit/people/drose -// instead of /fit/people/drose); besides being ugly, -// filenames like this may not be consistent across -// multiple different platforms. -//////////////////////////////////////////////////////////////////// +/** + * Converts the filename to a fully-qualified pathname from the root (if it is + * a relative pathname), and then standardizes it (see standardize()). + * + * This is sometimes a little problematic, since it may convert the file to + * its 'true' absolute pathname, which could be an ugly NFS-named file, + * irrespective of symbolic links (e.g. + * /.automount/dimbo/root/usr2/fit/people/drose instead of /fit/people/drose); + * besides being ugly, filenames like this may not be consistent across + * multiple different platforms. + */ void Filename:: make_absolute() { if (is_local()) { @@ -1024,15 +952,12 @@ make_absolute() { } } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_absolute -// Access: Published -// Description: Converts the filename to a fully-qualified filename -// from the root (if it is a relative filename), and -// then standardizes it (see standardize()). This -// flavor accepts a specific starting directory that the -// filename is known to be relative to. -//////////////////////////////////////////////////////////////////// +/** + * Converts the filename to a fully-qualified filename from the root (if it is + * a relative filename), and then standardizes it (see standardize()). This + * flavor accepts a specific starting directory that the filename is known to + * be relative to. + */ void Filename:: make_absolute(const Filename &start_directory) { if (is_local()) { @@ -1044,35 +969,27 @@ make_absolute(const Filename &start_directory) { standardize(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_canonical -// Access: Published -// Description: Converts this filename to a canonical name by -// replacing the directory part with the fully-qualified -// directory part. This is done by changing to that -// directory and calling getcwd(). -// -// This has the effect of (a) converting relative paths -// to absolute paths (but see make_absolute() if this is -// the only effect you want), and (b) always resolving a -// given directory name to the same string, even if -// different symbolic links are traversed, and (c) -// changing nice symbolic-link paths like -// /fit/people/drose to ugly NFS automounter names like -// /hosts/dimbo/usr2/fit/people/drose. This can be -// troubling, but sometimes this is exactly what you -// want, particularly if you're about to call -// make_relative_to() between two filenames. -// -// The return value is true if successful, or false on -// failure (usually because the directory name does not -// exist or cannot be chdir'ed into). -//////////////////////////////////////////////////////////////////// +/** + * Converts this filename to a canonical name by replacing the directory part + * with the fully-qualified directory part. This is done by changing to that + * directory and calling getcwd(). + * + * This has the effect of (a) converting relative paths to absolute paths (but + * see make_absolute() if this is the only effect you want), and (b) always + * resolving a given directory name to the same string, even if different + * symbolic links are traversed, and (c) changing nice symbolic-link paths + * like fit/people/drose to ugly NFS automounter names like + * hosts/dimbo/usr2/fit/people/drose. This can be troubling, but sometimes + * this is exactly what you want, particularly if you're about to call + * make_relative_to() between two filenames. + * + * The return value is true if successful, or false on failure (usually + * because the directory name does not exist or cannot be chdir'ed into). + */ bool Filename:: make_canonical() { if (empty()) { - // An empty filename is a special case. This doesn't name - // anything. + // An empty filename is a special case. This doesn't name anything. return false; } @@ -1099,23 +1016,18 @@ make_canonical() { return make_true_case(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_true_case -// Access: Published -// Description: On a case-insensitive operating system -// (e.g. Windows), this method looks up the file in the -// file system and resets the Filename to represent the -// actual case of the file as it exists on the disk. -// The return value is true if the file exists and the -// conversion can be made, or false if there is some -// error. -// -// On a case-sensitive operating system, this method -// does nothing and always returns true. -// -// An empty filename is considered to exist in this -// case. -//////////////////////////////////////////////////////////////////// +/** + * On a case-insensitive operating system (e.g. Windows), this method looks + * up the file in the file system and resets the Filename to represent the + * actual case of the file as it exists on the disk. The return value is true + * if the file exists and the conversion can be made, or false if there is + * some error. + * + * On a case-sensitive operating system, this method does nothing and always + * returns true. + * + * An empty filename is considered to exist in this case. + */ bool Filename:: make_true_case() { assert(!get_pattern()); @@ -1127,35 +1039,35 @@ make_true_case() { #ifdef WIN32 wstring os_specific = to_os_specific_w(); - // First, we have to convert it to its short name, then back to its - // long name--that seems to be the trick to force Windows to throw - // away the case we give it and get the actual file case. + // First, we have to convert it to its short name, then back to its long + // name--that seems to be the trick to force Windows to throw away the case + // we give it and get the actual file case. wchar_t short_name[MAX_PATH + 1]; DWORD l = GetShortPathNameW(os_specific.c_str(), short_name, MAX_PATH + 1); if (l == 0) { - // Couldn't query the path name for some reason. Probably the - // file didn't exist. + // Couldn't query the path name for some reason. Probably the file didn't + // exist. return false; } - // According to the Windows docs, l will return a value greater than - // the specified length if the short_name length wasn't enough--but also + // According to the Windows docs, l will return a value greater than the + // specified length if the short_name length wasn't enough--but also // according to the Windows docs, MAX_PATH will always be enough. assert(l < MAX_PATH + 1); wchar_t long_name[MAX_PATH + 1]; l = GetLongPathNameW(short_name, long_name, MAX_PATH + 1); if (l == 0) { - // Couldn't query the path name for some reason. Probably the - // file didn't exist. + // Couldn't query the path name for some reason. Probably the file didn't + // exist. return false; } assert(l < MAX_PATH + 1); Filename true_case = Filename::from_os_specific_w(long_name); - // Now sanity-check the true-case filename. If it's not the same as - // the source file, except for case, reject it. + // Now sanity-check the true-case filename. If it's not the same as the + // source file, except for case, reject it. wstring orig_filename = get_fullpath_w(); wstring new_filename = true_case.get_fullpath_w(); bool match = (orig_filename.length() == new_filename.length()); @@ -1163,9 +1075,8 @@ make_true_case() { match = (TextEncoder::unicode_tolower(orig_filename[i]) == TextEncoder::unicode_tolower(new_filename[i])); } if (!match) { - // Something went wrong. Keep the original filename, assume it - // was the correct case after all. We return true because the - // filename is good. + // Something went wrong. Keep the original filename, assume it was the + // correct case after all. We return true because the filename is good. return true; } @@ -1178,20 +1089,15 @@ make_true_case() { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::to_os_specific -// Access: Published -// Description: Converts the filename from our generic Unix-like -// convention (forward slashes starting with the root at -// '/') to the corresponding filename in the local -// operating system (slashes in the appropriate -// direction, starting with the root at C:\, for -// instance). Returns the string representing the -// converted filename, but does not change the Filename -// itself. -// -// See also from_os_specific(). -//////////////////////////////////////////////////////////////////// +/** + * Converts the filename from our generic Unix-like convention (forward + * slashes starting with the root at '/') to the corresponding filename in the + * local operating system (slashes in the appropriate direction, starting with + * the root at C:\, for instance). Returns the string representing the + * converted filename, but does not change the Filename itself. + * + * See also from_os_specific(). + */ string Filename:: to_os_specific() const { assert(!get_pattern()); @@ -1229,11 +1135,9 @@ to_os_specific() const { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::to_os_specific_w -// Access: Published -// Description: The wide-string variant on to_os_specific(). -//////////////////////////////////////////////////////////////////// +/** + * The wide-string variant on to_os_specific(). + */ wstring Filename:: to_os_specific_w() const { TextEncoder encoder; @@ -1242,21 +1146,17 @@ to_os_specific_w() const { return encoder.get_wtext(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::to_os_generic -// Access: Published -// Description: This is similar to to_os_specific(), but it is -// designed to generate a filename that can be -// understood on as many platforms as possible. Since -// Windows can usually understand a -// forward-slash-delimited filename, this means it does -// the same thing as to_os_specific(), but it uses -// forward slashes instead of backslashes. -// -// This method has a pretty limited use; it should -// generally be used for writing file references to a -// file that might be read on any operating system. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to to_os_specific(), but it is designed to generate a + * filename that can be understood on as many platforms as possible. Since + * Windows can usually understand a forward-slash-delimited filename, this + * means it does the same thing as to_os_specific(), but it uses forward + * slashes instead of backslashes. + * + * This method has a pretty limited use; it should generally be used for + * writing file references to a file that might be read on any operating + * system. + */ string Filename:: to_os_generic() const { assert(!get_pattern()); @@ -1268,19 +1168,15 @@ to_os_generic() const { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::to_os_short_name -// Access: Published -// Description: This works like to_os_generic(), but it returns the -// "short name" version of the filename, if it exists, -// or the original filename otherwise. -// -// On Windows platforms, this returns the 8.3 filename -// version of the given filename, if the file exists, -// and the same thing as to_os_specific() otherwise. On -// non-Windows platforms, this always returns the same -// thing as to_os_specific(). -//////////////////////////////////////////////////////////////////// +/** + * This works like to_os_generic(), but it returns the "short name" version of + * the filename, if it exists, or the original filename otherwise. + * + * On Windows platforms, this returns the 8.3 filename version of the given + * filename, if the file exists, and the same thing as to_os_specific() + * otherwise. On non-Windows platforms, this always returns the same thing as + * to_os_specific(). + */ string Filename:: to_os_short_name() const { assert(!get_pattern()); @@ -1291,12 +1187,12 @@ to_os_short_name() const { wchar_t short_name[MAX_PATH + 1]; DWORD l = GetShortPathNameW(os_specific.c_str(), short_name, MAX_PATH + 1); if (l == 0) { - // Couldn't query the path name for some reason. Probably the - // file didn't exist. + // Couldn't query the path name for some reason. Probably the file didn't + // exist. return to_os_specific(); } - // According to the Windows docs, l will return a value greater than - // the specified length if the short_name length wasn't enough--but also + // According to the Windows docs, l will return a value greater than the + // specified length if the short_name length wasn't enough--but also // according to the Windows docs, MAX_PATH will always be enough. assert(l < MAX_PATH + 1); @@ -1310,14 +1206,11 @@ to_os_short_name() const { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::to_os_long_name -// Access: Published -// Description: This is the opposite of to_os_short_name(): it -// returns the "long name" of the filename, if the -// filename exists. On non-Windows platforms, this -// returns the same thing as to_os_specific(). -//////////////////////////////////////////////////////////////////// +/** + * This is the opposite of to_os_short_name(): it returns the "long name" of + * the filename, if the filename exists. On non-Windows platforms, this + * returns the same thing as to_os_specific(). + */ string Filename:: to_os_long_name() const { assert(!get_pattern()); @@ -1328,8 +1221,8 @@ to_os_long_name() const { wchar_t long_name[MAX_PATH + 1]; DWORD l = GetLongPathNameW(os_specific.c_str(), long_name, MAX_PATH + 1); if (l == 0) { - // Couldn't query the path name for some reason. Probably the - // file didn't exist. + // Couldn't query the path name for some reason. Probably the file didn't + // exist. return to_os_specific(); } assert(l < MAX_PATH + 1); @@ -1344,14 +1237,11 @@ to_os_long_name() const { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: Filename::exists -// Access: Published -// Description: Returns true if the filename exists on the disk, -// false otherwise. If the type is indicated to be -// executable, this also tests that the file has execute -// permission. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename exists on the disk, false otherwise. If the + * type is indicated to be executable, this also tests that the file has + * execute permission. + */ bool Filename:: exists() const { #ifdef WIN32_VC @@ -1378,13 +1268,10 @@ exists() const { return exists; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_regular_file -// Access: Published -// Description: Returns true if the filename exists and is the -// name of a regular file (i.e. not a directory or -// device), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename exists and is the name of a regular file (i.e. + * not a directory or device), false otherwise. + */ bool Filename:: is_regular_file() const { #ifdef WIN32_VC @@ -1411,13 +1298,10 @@ is_regular_file() const { return isreg; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_writable -// Access: Published -// Description: Returns true if the filename exists and is either a -// directory or a regular file that can be written to, -// or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename exists and is either a directory or a regular + * file that can be written to, or false otherwise. + */ bool Filename:: is_writable() const { bool writable = false; @@ -1446,12 +1330,10 @@ is_writable() const { return writable; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_directory -// Access: Published -// Description: Returns true if the filename exists and is a -// directory name, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename exists and is a directory name, false + * otherwise. + */ bool Filename:: is_directory() const { #ifdef WIN32_VC @@ -1477,17 +1359,14 @@ is_directory() const { return isdir; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::is_executable -// Access: Published -// Description: Returns true if the filename exists and is -// executable -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename exists and is executable + */ bool Filename:: is_executable() const { #ifdef WIN32_VC - // no access() in windows, but to our advantage executables can only - // end in .exe or .com + // no access() in windows, but to our advantage executables can only end in + // .exe or .com string extension = get_extension(); if (extension == "exe" || extension == "com") { return exists(); @@ -1503,20 +1382,16 @@ is_executable() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::compare_timestamps -// Access: Published -// Description: Returns a number less than zero if the file named by -// this object is older than the given file, zero if -// they have the same timestamp, or greater than zero if -// this one is newer. -// -// If this_missing_is_old is true, it indicates that a -// missing file will be treated as if it were older than -// any other file; otherwise, a missing file will be -// treated as if it were newer than any other file. -// Similarly for other_missing_is_old. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if the file named by this object is older + * than the given file, zero if they have the same timestamp, or greater than + * zero if this one is newer. + * + * If this_missing_is_old is true, it indicates that a missing file will be + * treated as if it were older than any other file; otherwise, a missing file + * will be treated as if it were newer than any other file. Similarly for + * other_missing_is_old. + */ int Filename:: compare_timestamps(const Filename &other, bool this_missing_is_old, @@ -1587,20 +1462,16 @@ compare_timestamps(const Filename &other, return other_missing_is_old ? 1 : -1; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_timestamp -// Access: Published -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t Filename:: get_timestamp() const { #ifdef WIN32_VC @@ -1624,14 +1495,11 @@ get_timestamp() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_access_timestamp -// Access: Published -// Description: Returns a time_t value that represents the time the -// file was last accessed, if this information is -// available. See also get_timestamp(), which returns -// the last modification time. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last accessed, + * if this information is available. See also get_timestamp(), which returns + * the last modification time. + */ time_t Filename:: get_access_timestamp() const { #ifdef WIN32_VC @@ -1655,12 +1523,9 @@ get_access_timestamp() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_file_size -// Access: Published -// Description: Returns the size of the file in bytes, or 0 if there -// is an error. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the file in bytes, or 0 if there is an error. + */ streamsize Filename:: get_file_size() const { #ifdef WIN32_VC @@ -1668,9 +1533,8 @@ get_file_size() const { struct _stat64 this_buf; - // _wstat() only returns the lower 32 bits of the file size (!). We - // have to call _wstati64() if we actually want the full 64-bit file - // size. + // _wstat() only returns the lower 32 bits of the file size (!). We have to + // call _wstati64() if we actually want the full 64-bit file size. if (_wstati64(os_specific.c_str(), &this_buf) == 0) { return this_buf.st_size; } @@ -1687,14 +1551,11 @@ get_file_size() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::resolve_filename -// Access: Published -// Description: Searches the given search path for the filename. If -// it is found, updates the filename to the full -// pathname found and returns true; otherwise, returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * Searches the given search path for the filename. If it is found, updates + * the filename to the full pathname found and returns true; otherwise, + * returns false. + */ bool Filename:: resolve_filename(const DSearchPath &searchpath, const string &default_extension) { @@ -1704,8 +1565,8 @@ resolve_filename(const DSearchPath &searchpath, found = searchpath.find_file(*this); if (found.empty()) { - // We didn't find it with the given extension; can we try the - // default extension? + // We didn't find it with the given extension; can we try the default + // extension? if (get_extension().empty() && !default_extension.empty()) { Filename try_ext = *this; try_ext.set_extension(default_extension); @@ -1717,8 +1578,8 @@ resolve_filename(const DSearchPath &searchpath, // The full pathname exists. Return true. return true; } else { - // The full pathname doesn't exist with the given extension; - // does it exist with the default extension? + // The full pathname doesn't exist with the given extension; does it + // exist with the default extension? if (get_extension().empty() && !default_extension.empty()) { Filename try_ext = *this; try_ext.set_extension(default_extension); @@ -1737,31 +1598,23 @@ resolve_filename(const DSearchPath &searchpath, return false; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_relative_to -// Access: Published -// Description: Adjusts this filename, which must be a -// fully-specified pathname beginning with a slash, to -// make it a relative filename, relative to the -// fully-specified directory indicated (which must also -// begin with, and may or may not end with, a slash--a -// terminating slash is ignored). -// -// This only performs a string comparsion, so it may be -// wise to call make_canonical() on both filenames -// before calling make_relative_to(). -// -// If allow_backups is false, the filename will only be -// adjusted to be made relative if it is already -// somewhere within or below the indicated directory. -// If allow_backups is true, it will be adjusted in all -// cases, even if this requires putting a series of ../ -// characters before the filename--unless it would have -// to back all the way up to the root. -// -// Returns true if the file was adjusted, false if it -// was not. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts this filename, which must be a fully-specified pathname beginning + * with a slash, to make it a relative filename, relative to the fully- + * specified directory indicated (which must also begin with, and may or may + * not end with, a slash--a terminating slash is ignored). + * + * This only performs a string comparsion, so it may be wise to call + * make_canonical() on both filenames before calling make_relative_to(). + * + * If allow_backups is false, the filename will only be adjusted to be made + * relative if it is already somewhere within or below the indicated + * directory. If allow_backups is true, it will be adjusted in all cases, + * even if this requires putting a series of .. characters before the filename + * --unless it would have to back all the way up to the root. + * + * Returns true if the file was adjusted, false if it was not. + */ bool Filename:: make_relative_to(Filename directory, bool allow_backups) { if (_filename.empty() || directory.empty() || @@ -1801,21 +1654,16 @@ make_relative_to(Filename directory, bool allow_backups) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::find_on_searchpath -// Access: Published -// Description: Performs the reverse of the resolve_filename() -// operation: assuming that the current filename is -// fully-specified pathname (i.e. beginning with '/'), -// look on the indicated search path for a directory -// under which the file can be found. When found, -// adjust the Filename to be relative to the indicated -// directory name. -// -// Returns the index of the directory on the searchpath -// at which the file was found, or -1 if it was not -// found. -//////////////////////////////////////////////////////////////////// +/** + * Performs the reverse of the resolve_filename() operation: assuming that the + * current filename is fully-specified pathname (i.e. beginning with '/'), + * look on the indicated search path for a directory under which the file can + * be found. When found, adjust the Filename to be relative to the indicated + * directory name. + * + * Returns the index of the directory on the searchpath at which the file was + * found, or -1 if it was not found. + */ int Filename:: find_on_searchpath(const DSearchPath &searchpath) { if (_filename.empty() || _filename[0] != '/') { @@ -1834,29 +1682,24 @@ find_on_searchpath(const DSearchPath &searchpath) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::scan_directory -// Access: Published -// Description: Attempts to open the named filename as if it were a -// directory and looks for the non-hidden files within -// the directory. Fills the given vector up with the -// sorted list of filenames that are local to this -// directory. -// -// It is the user's responsibility to ensure that the -// contents vector is empty before making this call; -// otherwise, the new files will be appended to it. -// -// Returns true on success, false if the directory could -// not be read for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the named filename as if it were a directory and looks for + * the non-hidden files within the directory. Fills the given vector up with + * the sorted list of filenames that are local to this directory. + * + * It is the user's responsibility to ensure that the contents vector is empty + * before making this call; otherwise, the new files will be appended to it. + * + * Returns true on success, false if the directory could not be read for some + * reason. + */ bool Filename:: scan_directory(vector_string &contents) const { assert(!get_pattern()); #if defined(WIN32_VC) - // Use Windows' FindFirstFile() / FindNextFile() to walk through the - // list of files in a directory. + // Use Windows' FindFirstFile() FindNextFile() to walk through the list of + // files in a directory. size_t orig_size = contents.size(); wstring match; @@ -1894,8 +1737,8 @@ scan_directory(vector_string &contents) const { return scan_ok; #elif defined(PHAVE_DIRENT_H) - // Use Posix's opendir() / readdir() to walk through the list of - // files in a directory. + // Use Posix's opendir() readdir() to walk through the list of files in a + // directory. size_t orig_size = contents.size(); string dirname; @@ -1922,10 +1765,10 @@ scan_directory(vector_string &contents) const { d = readdir(root); } - // It turns out to be a mistake to check the value of errno after - // calling readdir(), since it might have been set to non-zero - // during some internal operation of readdir(), even though there - // wasn't really a problem with scanning the directory itself. + // It turns out to be a mistake to check the value of errno after calling + // readdir(), since it might have been set to non-zero during some internal + // operation of readdir(), even though there wasn't really a problem with + // scanning the directory itself. /* if (errno != 0 && errno != ENOENT && errno != ENOTDIR) { cerr << "Error occurred while scanning directory " << dirname << "\n"; @@ -1940,10 +1783,10 @@ scan_directory(vector_string &contents) const { return true; #elif defined(PHAVE_GLOB_H) - // It's hard to imagine a system that provides glob.h but does not - // provide openddir() .. readdir(), but this code is leftover from a - // time when there was an undetected bug in the above readdir() - // loop, and it works, so we might as well keep it around for now. + // It's hard to imagine a system that provides glob.h but does not provide + // openddir() .. readdir(), but this code is leftover from a time when there + // was an undetected bug in the above readdir() loop, and it works, so we + // might as well keep it around for now. string dirname; if (empty()) { dirname = "*"; @@ -1958,9 +1801,9 @@ scan_directory(vector_string &contents) const { int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); if (r != 0) { - // Some error processing the match string. If our version of - // glob.h defines GLOB_NOMATCH, then we can differentiate an empty - // return result from some other kind of error. + // Some error processing the match string. If our version of glob.h + // defines GLOB_NOMATCH, then we can differentiate an empty return result + // from some other kind of error. #ifdef GLOB_NOMATCH if (r != GLOB_NOMATCH) { perror(dirname.c_str()); @@ -1968,8 +1811,8 @@ scan_directory(vector_string &contents) const { } #endif - // Otherwise, all errors mean the same thing: no matches, but - // otherwise no problem. + // Otherwise, all errors mean the same thing: no matches, but otherwise no + // problem. return true; } @@ -1988,17 +1831,13 @@ scan_directory(vector_string &contents) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read -// Access: Published -// Description: Opens the indicated ifstream for reading the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated ifstream for reading the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + */ bool Filename:: open_read(ifstream &stream) const { assert(!get_pattern()); @@ -2007,8 +1846,7 @@ open_read(ifstream &stream) const { ios_openmode open_mode = ios::in; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2026,21 +1864,16 @@ open_read(ifstream &stream) const { return (!stream.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_write -// Access: Published -// Description: Opens the indicated ifstream for writing the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -// -// If truncate is true, the file is truncated to zero -// length upon opening it, if it already exists. -// Otherwise, the file is kept at its original length. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated ifstream for writing the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + * + * If truncate is true, the file is truncated to zero length upon opening it, + * if it already exists. Otherwise, the file is kept at its original length. + */ bool Filename:: open_write(ofstream &stream, bool truncate) const { assert(!get_pattern()); @@ -2052,19 +1885,18 @@ open_write(ofstream &stream, bool truncate) const { open_mode |= ios::trunc; } else { - // Some systems insist on having ios::in set to prevent the file - // from being truncated when we open it. Makes ios::trunc kind of - // pointless, doesn't it? On the other hand, setting ios::in also - // seems to imply ios::nocreate (!), so we should only set this if - // the file already exists. + // Some systems insist on having ios::in set to prevent the file from + // being truncated when we open it. Makes ios::trunc kind of pointless, + // doesn't it? On the other hand, setting ios::in also seems to imply + // ios::nocreate (!), so we should only set this if the file already + // exists. if (exists()) { open_mode |= ios::in; } } #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2086,17 +1918,13 @@ open_write(ofstream &stream, bool truncate) const { return (!stream.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_append -// Access: Published -// Description: Opens the indicated ofstream for writing the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated ofstream for writing the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + */ bool Filename:: open_append(ofstream &stream) const { assert(!get_pattern()); @@ -2105,8 +1933,7 @@ open_append(ofstream &stream) const { ios_openmode open_mode = ios::app; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2128,17 +1955,13 @@ open_append(ofstream &stream) const { return (!stream.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read_write -// Access: Published -// Description: Opens the indicated fstream for read/write access to -// the file, if possible. Returns true if successful, -// false otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read_write() without first calling one of -// set_text() or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated fstream for read/write access to the file, if possible. + * Returns true if successful, false otherwise. This requires the setting of + * the set_text()/set_binary() flags to open the file appropriately as + * indicated; it is an error to call open_read_write() without first calling + * one of set_text() or set_binary(). + */ bool Filename:: open_read_write(fstream &stream, bool truncate) const { assert(!get_pattern()); @@ -2150,15 +1973,14 @@ open_read_write(fstream &stream, bool truncate) const { open_mode |= ios::trunc; } - // Since ios::in also seems to imply ios::nocreate (!), we must - // guarantee the file already exists before we try to open it. + // Since ios::in also seems to imply ios::nocreate (!), we must guarantee + // the file already exists before we try to open it. if (!exists()) { touch(); } #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2180,18 +2002,13 @@ open_read_write(fstream &stream, bool truncate) const { return (!stream.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read_append -// Access: Published -// Description: Opens the indicated ifstream for reading and writing -// the file, if possible; writes are appended to the end -// of the file. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated ifstream for reading and writing the file, if possible; + * writes are appended to the end of the file. Returns true if successful, + * false otherwise. This requires the setting of the set_text()/set_binary() + * flags to open the file appropriately as indicated; it is an error to call + * open_read() without first calling one of set_text() or set_binary(). + */ bool Filename:: open_read_append(fstream &stream) const { assert(!get_pattern()); @@ -2200,8 +2017,7 @@ open_read_append(fstream &stream) const { ios_openmode open_mode = ios::app | ios::in; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2224,17 +2040,13 @@ open_read_append(fstream &stream) const { } #ifdef USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read -// Access: Published -// Description: Opens the indicated pifstream for reading the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated pifstream for reading the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + */ bool Filename:: open_read(pifstream &stream) const { assert(!get_pattern()); @@ -2243,8 +2055,7 @@ open_read(pifstream &stream) const { ios_openmode open_mode = ios::in; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2258,21 +2069,16 @@ open_read(pifstream &stream) const { #endif // USE_PANDAFILESTREAM #ifdef USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_write -// Access: Published -// Description: Opens the indicated pifstream for writing the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -// -// If truncate is true, the file is truncated to zero -// length upon opening it, if it already exists. -// Otherwise, the file is kept at its original length. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated pifstream for writing the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + * + * If truncate is true, the file is truncated to zero length upon opening it, + * if it already exists. Otherwise, the file is kept at its original length. + */ bool Filename:: open_write(pofstream &stream, bool truncate) const { assert(!get_pattern()); @@ -2284,19 +2090,18 @@ open_write(pofstream &stream, bool truncate) const { open_mode |= ios::trunc; } else { - // Some systems insist on having ios::in set to prevent the file - // from being truncated when we open it. Makes ios::trunc kind of - // pointless, doesn't it? On the other hand, setting ios::in also - // seems to imply ios::nocreate (!), so we should only set this if - // the file already exists. + // Some systems insist on having ios::in set to prevent the file from + // being truncated when we open it. Makes ios::trunc kind of pointless, + // doesn't it? On the other hand, setting ios::in also seems to imply + // ios::nocreate (!), so we should only set this if the file already + // exists. if (exists()) { open_mode |= ios::in; } } #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2315,17 +2120,13 @@ open_write(pofstream &stream, bool truncate) const { #endif // USE_PANDAFILESTREAM #ifdef USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_append -// Access: Published -// Description: Opens the indicated pifstream for writing the file, if -// possible. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated pifstream for writing the file, if possible. Returns + * true if successful, false otherwise. This requires the setting of the + * set_text()/set_binary() flags to open the file appropriately as indicated; + * it is an error to call open_read() without first calling one of set_text() + * or set_binary(). + */ bool Filename:: open_append(pofstream &stream) const { assert(!get_pattern()); @@ -2334,8 +2135,7 @@ open_append(pofstream &stream) const { ios_openmode open_mode = ios::app; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2354,17 +2154,13 @@ open_append(pofstream &stream) const { #endif // USE_PANDAFILESTREAM #ifdef USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read_write -// Access: Published -// Description: Opens the indicated fstream for read/write access to -// the file, if possible. Returns true if successful, -// false otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read_write() without first calling one of -// set_text() or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated fstream for read/write access to the file, if possible. + * Returns true if successful, false otherwise. This requires the setting of + * the set_text()/set_binary() flags to open the file appropriately as + * indicated; it is an error to call open_read_write() without first calling + * one of set_text() or set_binary(). + */ bool Filename:: open_read_write(pfstream &stream, bool truncate) const { assert(!get_pattern()); @@ -2376,15 +2172,14 @@ open_read_write(pfstream &stream, bool truncate) const { open_mode |= ios::trunc; } - // Since ios::in also seems to imply ios::nocreate (!), we must - // guarantee the file already exists before we try to open it. + // Since ios::in also seems to imply ios::nocreate (!), we must guarantee + // the file already exists before we try to open it. if (!exists()) { touch(); } #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2403,18 +2198,13 @@ open_read_write(pfstream &stream, bool truncate) const { #endif // USE_PANDAFILESTREAM #ifdef USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::open_read_append -// Access: Published -// Description: Opens the indicated pfstream for reading and writing -// the file, if possible; writes are appended to the end -// of the file. Returns true if successful, false -// otherwise. This requires the setting of the -// set_text()/set_binary() flags to open the file -// appropriately as indicated; it is an error to call -// open_read() without first calling one of set_text() -// or set_binary(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated pfstream for reading and writing the file, if possible; + * writes are appended to the end of the file. Returns true if successful, + * false otherwise. This requires the setting of the set_text()/set_binary() + * flags to open the file appropriately as indicated; it is an error to call + * open_read() without first calling one of set_text() or set_binary(). + */ bool Filename:: open_read_append(pfstream &stream) const { assert(!get_pattern()); @@ -2423,8 +2213,7 @@ open_read_append(pfstream &stream) const { ios_openmode open_mode = ios::app | ios::in; #ifdef HAVE_IOS_BINARY - // For some reason, some systems (like Irix) don't define - // ios::binary. + // For some reason, some systems (like Irix) don't define ios::binary. if (!is_text()) { open_mode |= ios::binary; } @@ -2442,14 +2231,11 @@ open_read_append(pfstream &stream) const { } #endif // USE_PANDAFILESTREAM -//////////////////////////////////////////////////////////////////// -// Function: Filename::touch -// Access: Published -// Description: Updates the modification time of the file to the -// current time. If the file does not already exist, it -// will be created. Returns true if successful, false -// if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Updates the modification time of the file to the current time. If the file + * does not already exist, it will be created. Returns true if successful, + * false if there is an error. + */ bool Filename:: touch() const { assert(!get_pattern()); @@ -2487,12 +2273,11 @@ touch() const { string os_specific = to_os_specific(); #ifdef HAVE_CYGWIN - // In the Cygwin case, it seems we need to be sure to use the - // Cygwin-style name; some broken utime() implementation. That's - // almost the same thing as the original Panda-style name, but not - // exactly, so we first convert the Panda name to a Windows name, - // then convert it back to Cygwin, to ensure we get it exactly right - // by Cygwin rules. + // In the Cygwin case, it seems we need to be sure to use the Cygwin-style + // name; some broken utime() implementation. That's almost the same thing + // as the original Panda-style name, but not exactly, so we first convert + // the Panda name to a Windows name, then convert it back to Cygwin, to + // ensure we get it exactly right by Cygwin rules. { char result[4096] = ""; cygwin_conv_to_posix_path(os_specific.c_str(), result); @@ -2516,21 +2301,19 @@ touch() const { } return true; #else // WIN32, PHAVE_UTIME_H - // Other systems may not have an explicit control over the - // modification time. For these systems, we'll just temporarily - // open the file in append mode, then close it again (it gets closed - // when the pfstream goes out of scope). + // Other systems may not have an explicit control over the modification + // time. For these systems, we'll just temporarily open the file in append + // mode, then close it again (it gets closed when the pfstream goes out of + // scope). pfstream file; return open_append(file); #endif // WIN32, PHAVE_UTIME_H } -//////////////////////////////////////////////////////////////////// -// Function: Filename::chdir -// Access: Published -// Description: Changes directory to the specified location. -// Returns true if successful, false if failure. -//////////////////////////////////////////////////////////////////// +/** + * Changes directory to the specified location. Returns true if successful, + * false if failure. + */ bool Filename:: chdir() const { #ifdef WIN32_VC @@ -2542,14 +2325,11 @@ chdir() const { #endif // WIN32_VC } -//////////////////////////////////////////////////////////////////// -// Function: Filename::unlink -// Access: Published -// Description: Permanently deletes the file associated with the -// filename, if possible. Returns true if successful, -// false if failure (for instance, because the file did -// not exist, or because permissions were inadequate). -//////////////////////////////////////////////////////////////////// +/** + * Permanently deletes the file associated with the filename, if possible. + * Returns true if successful, false if failure (for instance, because the + * file did not exist, or because permissions were inadequate). + */ bool Filename:: unlink() const { assert(!get_pattern()); @@ -2565,14 +2345,11 @@ unlink() const { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::rename_to -// Access: Published -// Description: Renames the file to the indicated new filename. If -// the new filename is in a different directory, this -// will perform a move. Returns true if successful, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Renames the file to the indicated new filename. If the new filename is in + * a different directory, this will perform a move. Returns true if + * successful, false on failure. + */ bool Filename:: rename_to(const Filename &other) const { assert(!get_pattern()); @@ -2592,9 +2369,9 @@ rename_to(const Filename &other) const { return true; } - // The above might fail if we have tried to move a file to a - // different filesystem. In this case, copy the file into the same - // directory first, and then rename it. + // The above might fail if we have tried to move a file to a different + // filesystem. In this case, copy the file into the same directory first, + // and then rename it. string dirname = other.get_dirname(); if (dirname.empty()) { dirname = "."; @@ -2631,9 +2408,9 @@ rename_to(const Filename &other) const { return true; } - // The above might fail if we have tried to move a file to a - // different filesystem. In this case, copy the file into the same - // directory first, and then rename it. + // The above might fail if we have tried to move a file to a different + // filesystem. In this case, copy the file into the same directory first, + // and then rename it. string dirname = other.get_dirname(); if (dirname.empty()) { dirname = "."; @@ -2667,15 +2444,11 @@ rename_to(const Filename &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::copy_to -// Access: Published -// Description: Copies the file to the indicated new filename, by -// reading the contents and writing it to the new file. -// Returns true if successful, false on failure. The -// copy is always binary, regardless of the filename -// settings. -//////////////////////////////////////////////////////////////////// +/** + * Copies the file to the indicated new filename, by reading the contents and + * writing it to the new file. Returns true if successful, false on failure. + * The copy is always binary, regardless of the filename settings. + */ bool Filename:: copy_to(const Filename &other) const { Filename this_filename = Filename::binary_filename(*this); @@ -2713,19 +2486,15 @@ copy_to(const Filename &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::make_dir -// Access: Published -// Description: Creates all the directories in the path to the file -// specified in the filename, except for the basename -// itself. This assumes that the Filename contains the -// name of a file, not a directory name; it ensures that -// the directory containing the file exists. -// -// However, if the filename ends in a slash, it assumes -// the Filename represents the name of a directory, and -// creates all the paths. -//////////////////////////////////////////////////////////////////// +/** + * Creates all the directories in the path to the file specified in the + * filename, except for the basename itself. This assumes that the Filename + * contains the name of a file, not a directory name; it ensures that the + * directory containing the file exists. + * + * However, if the filename ends in a slash, it assumes the Filename + * represents the name of a directory, and creates all the paths. + */ bool Filename:: make_dir() const { assert(!get_pattern()); @@ -2747,9 +2516,9 @@ make_dir() const { } string dirname = path.get_fullpath(); - // First, make sure everything up to the last path is known. We - // don't care too much if any of these fail; maybe they failed - // because the directory was already there. + // First, make sure everything up to the last path is known. We don't care + // too much if any of these fail; maybe they failed because the directory + // was already there. size_t slash = dirname.find('/'); while (slash != string::npos) { Filename component(dirname.substr(0, slash)); @@ -2776,15 +2545,12 @@ make_dir() const { return (result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::mkdir -// Access: Published -// Description: Creates the directory named by this filename. Unlike -// make_dir(), this assumes that the Filename contains -// the directory name itself. Also, parent directories -// are not automatically created; this function fails if -// any parent directory is missing. -//////////////////////////////////////////////////////////////////// +/** + * Creates the directory named by this filename. Unlike make_dir(), this + * assumes that the Filename contains the directory name itself. Also, parent + * directories are not automatically created; this function fails if any + * parent directory is missing. + */ bool Filename:: mkdir() const { #ifdef WIN32_VC @@ -2798,12 +2564,10 @@ mkdir() const { return (result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::rmdir -// Access: Published -// Description: The inverse of mkdir(): this removes the directory -// named by this Filename, if it is in fact a directory. -//////////////////////////////////////////////////////////////////// +/** + * The inverse of mkdir(): this removes the directory named by this Filename, + * if it is in fact a directory. + */ bool Filename:: rmdir() const { #ifdef WIN32_VC @@ -2811,8 +2575,8 @@ rmdir() const { int result = _wrmdir(os_specific.c_str()); if (result != 0) { - // Windows may require the directory to be writable before we can - // remove it. + // Windows may require the directory to be writable before we can remove + // it. _wchmod(os_specific.c_str(), 0777); result = _wrmdir(os_specific.c_str()); } @@ -2825,12 +2589,10 @@ rmdir() const { return (result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_hash -// Access: Published -// Description: Returns a hash code that attempts to be mostly unique -// for different Filenames. -//////////////////////////////////////////////////////////////////// +/** + * Returns a hash code that attempts to be mostly unique for different + * Filenames. + */ int Filename:: get_hash() const { static const int primes[] = { @@ -2863,45 +2625,34 @@ get_hash() const { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::atomic_compare_and_exchange_contents -// Access: Public -// Description: Uses native file-locking mechanisms to atomically -// replace the contents of a (small) file with the -// specified contents, assuming it hasn't changed since -// the last time the file was read. -// -// This is designed to be similar to -// AtomicAdjust::compare_and_exchange(). The method -// writes new_contents to the file, completely replacing -// the original contents; but only if the original -// contents exactly matched old_contents. If the file -// was modified, returns true. If, however, the -// original contents of the file did not exactly match -// old_contents, then the file is not modified, and -// false is returned. In either case, orig_contents is -// filled with the original contents of the file. -// -// If the file does not exist, it is implicitly created, -// and its original contents are empty. -// -// If an I/O error occurs on write, some of the file may -// or may not have been written, and false is returned. -// -// Expressed in pseudo-code, the logic is: -// -// orig_contents = file.read(); -// if (orig_contents == old_contents) { -// file.write(new_contents); -// return true; -// } -// return false; -// -// The operation is guaranteed to be atomic only if the -// only operations that read and write to this file are -// atomic_compare_and_exchange_contents() and -// atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * Uses native file-locking mechanisms to atomically replace the contents of a + * (small) file with the specified contents, assuming it hasn't changed since + * the last time the file was read. + * + * This is designed to be similar to AtomicAdjust::compare_and_exchange(). + * The method writes new_contents to the file, completely replacing the + * original contents; but only if the original contents exactly matched + * old_contents. If the file was modified, returns true. If, however, the + * original contents of the file did not exactly match old_contents, then the + * file is not modified, and false is returned. In either case, orig_contents + * is filled with the original contents of the file. + * + * If the file does not exist, it is implicitly created, and its original + * contents are empty. + * + * If an I/O error occurs on write, some of the file may or may not have been + * written, and false is returned. + * + * Expressed in pseudo-code, the logic is: + * + * orig_contents = file.read(); if (orig_contents == old_contents) { + * file.write(new_contents); return true; } return false; + * + * The operation is guaranteed to be atomic only if the only operations that + * read and write to this file are atomic_compare_and_exchange_contents() and + * atomic_read_contents(). + */ bool Filename:: atomic_compare_and_exchange_contents(string &orig_contents, const string &old_contents, @@ -3028,23 +2779,18 @@ atomic_compare_and_exchange_contents(string &orig_contents, #endif // WIN32_VC } -//////////////////////////////////////////////////////////////////// -// Function: Filename::atomic_read_contents -// Access: Public -// Description: Uses native file-locking mechanisms to atomically -// read the contents of a (small) file. This is the -// only way to read a file protected by -// atomic_compare_and_exchange_contents(), and be -// confident that the read operation is actually atomic -// with respect to that method. -// -// If the file does not exist, it is implicitly created, -// and its contents are empty. -// -// If the file is read successfully, fills its contents -// in the indicated string, and returns true. If the -// file cannot be read, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Uses native file-locking mechanisms to atomically read the contents of a + * (small) file. This is the only way to read a file protected by + * atomic_compare_and_exchange_contents(), and be confident that the read + * operation is actually atomic with respect to that method. + * + * If the file does not exist, it is implicitly created, and its contents are + * empty. + * + * If the file is read successfully, fills its contents in the indicated + * string, and returns true. If the file cannot be read, returns false. + */ bool Filename:: atomic_read_contents(string &contents) const { #ifdef WIN32_VC @@ -3133,17 +2879,14 @@ atomic_read_contents(string &contents) const { #endif // WIN32_VC } -//////////////////////////////////////////////////////////////////// -// Function: Filename::locate_basename -// Access: Protected -// Description: After the string has been reassigned, search for the -// slash marking the beginning of the basename, and set -// _dirname_end and _basename_start correctly. -//////////////////////////////////////////////////////////////////// +/** + * After the string has been reassigned, search for the slash marking the + * beginning of the basename, and set _dirname_end and _basename_start + * correctly. + */ void Filename:: locate_basename() { - // Scan for the last slash, which marks the end of the directory - // part. + // Scan for the last slash, which marks the end of the directory part. if (_filename.empty()) { _dirname_end = 0; _basename_start = 0; @@ -3155,16 +2898,16 @@ locate_basename() { _basename_start = slash + 1; _dirname_end = _basename_start; - // One exception: in case there are multiple slashes in a row, - // we want to treat them as a single slash. The directory - // therefore actually ends at the first of these; back up a bit. + // One exception: in case there are multiple slashes in a row, we want + // to treat them as a single slash. The directory therefore actually + // ends at the first of these; back up a bit. while (_dirname_end > 0 && _filename[_dirname_end-1] == '/') { _dirname_end--; } - // Another exception: if the dirname was nothing but slashes, it - // was the root directory, or / itself. In this case the dirname - // does include the terminal slash (of course). + // Another exception: if the dirname was nothing but slashes, it was the + // root directory, or itself. In this case the dirname does include + // the terminal slash (of course). if (_dirname_end == 0) { _dirname_end = 1; } @@ -3177,23 +2920,19 @@ locate_basename() { // Now: - // _dirname_end is the last slash character, or 0 if there are no - // slash characters. + // _dirname_end is the last slash character, or 0 if there are no slash + // characters. - // _basename_start is the character after the last slash character, - // or 0 if there are no slash characters. + // _basename_start is the character after the last slash character, or 0 if + // there are no slash characters. } -//////////////////////////////////////////////////////////////////// -// Function: Filename::locate_extension -// Access: Protected -// Description: Once the end of the directory prefix has been found, -// and _dirname_end and _basename_start are set -// correctly, search for the dot marking the beginning -// of the extension, and set _basename_end and -// _extension_start correctly. -//////////////////////////////////////////////////////////////////// +/** + * Once the end of the directory prefix has been found, and _dirname_end and + * _basename_start are set correctly, search for the dot marking the beginning + * of the extension, and set _basename_end and _extension_start correctly. + */ void Filename:: locate_extension() { // Now scan for the last dot after that slash. @@ -3221,28 +2960,25 @@ locate_extension() { // _basename_end is the last dot, or npos if there is no dot. - // _extension_start is the character after the last dot, or npos if - // there is no dot. + // _extension_start is the character after the last dot, or npos if there is + // no dot. } -//////////////////////////////////////////////////////////////////// -// Function: Filename::locate_hash -// Access: Protected -// Description: Identifies the part of the filename that contains the -// sequence of hash marks, if any. -//////////////////////////////////////////////////////////////////// +/** + * Identifies the part of the filename that contains the sequence of hash + * marks, if any. + */ void Filename:: locate_hash() { if (!get_pattern()) { - // If it's not a pattern-type filename, these are always set to - // the end of the string. + // If it's not a pattern-type filename, these are always set to the end of + // the string. _hash_end = string::npos; _hash_start = string::npos; } else { - // If it is a pattern-type filename, we must search for the hash - // marks, which could be anywhere (but are usually toward the - // end). + // If it is a pattern-type filename, we must search for the hash marks, + // which could be anywhere (but are usually toward the end). _hash_end = _filename.rfind('#'); if (_hash_end == string::npos) { _hash_end = string::npos; @@ -3259,14 +2995,11 @@ locate_hash() { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_common_prefix -// Access: Protected -// Description: Returns the length of the longest common initial -// substring of this string and the other one that ends -// in a slash. This is the lowest directory common to -// both filenames. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the longest common initial substring of this string + * and the other one that ends in a slash. This is the lowest directory + * common to both filenames. + */ size_t Filename:: get_common_prefix(const string &other) const { size_t len = 0; @@ -3285,12 +3018,10 @@ get_common_prefix(const string &other) const { return len; } -//////////////////////////////////////////////////////////////////// -// Function: Filename::count_slashes -// Access: Protected, Static -// Description: Returns the number of non-consecutive slashes in the -// indicated string, not counting a terminal slash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of non-consecutive slashes in the indicated string, not + * counting a terminal slash. + */ int Filename:: count_slashes(const string &str) { int count = 0; @@ -3320,16 +3051,13 @@ count_slashes(const string &str) { } -//////////////////////////////////////////////////////////////////// -// Function: Filename::r_make_canonical -// Access: Protected -// Description: The recursive implementation of make_canonical(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of make_canonical(). + */ bool Filename:: r_make_canonical(const Filename &cwd) { if (get_fullpath() == "/") { - // If we reached the root, the whole path doesn't exist. Report - // failure. + // If we reached the root, the whole path doesn't exist. Report failure. return false; } @@ -3363,8 +3091,8 @@ r_make_canonical(const Filename &cwd) { } #endif // WIN32_VC - // That didn't work; maybe it's not a directory. Recursively go to - // the directory above. + // That didn't work; maybe it's not a directory. Recursively go to the + // directory above. Filename dir(get_dirname()); @@ -3380,4 +3108,3 @@ r_make_canonical(const Filename &cwd) { set_dirname(dir); return true; } - diff --git a/dtool/src/dtoolutil/filename.h b/dtool/src/dtoolutil/filename.h index 2058d3f45c..378bf4fe1c 100644 --- a/dtool/src/dtoolutil/filename.h +++ b/dtool/src/dtoolutil/filename.h @@ -1,16 +1,15 @@ -// Filename: filename.h -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename.h + * @author drose + * @date 1999-01-18 + */ #ifndef FILENAME_H #define FILENAME_H @@ -26,26 +25,21 @@ class DSearchPath; -//////////////////////////////////////////////////////////////////// -// Class : Filename -// Description : The name of a file, such as a texture file or an Egg -// file. Stores the full pathname, and includes -// functions for extracting out the directory prefix -// part and the file extension and stuff. -// -// A Filename is also aware of the mapping between the -// Unix-like filename convention we use internally, and -// the local OS's specific filename convention, and it -// knows how to perform basic OS-specific I/O, like -// testing for file existence and searching a -// searchpath, as well as the best way to open an -// fstream for reading or writing. -//////////////////////////////////////////////////////////////////// +/** + * The name of a file, such as a texture file or an Egg file. Stores the full + * pathname, and includes functions for extracting out the directory prefix + * part and the file extension and stuff. + * + * A Filename is also aware of the mapping between the Unix-like filename + * convention we use internally, and the local OS's specific filename + * convention, and it knows how to perform basic OS-specific I/O, like testing + * for file existence and searching a searchpath, as well as the best way to + * open an fstream for reading or writing. + */ class EXPCL_DTOOL Filename { PUBLISHED: enum Type { - // These type values must fit within the bits allocated for - // F_type, below. + // These type values must fit within the bits allocated for F_type, below. T_general = 0x00, T_dso = 0x01, T_executable = 0x02, @@ -78,9 +72,9 @@ PUBLISHED: EXTENSION(PyObject *__reduce__(PyObject *self) const); #endif - // Static constructors to explicitly create a filename that refers - // to a text or binary file. This is in lieu of calling set_text() - // or set_binary() or set_type(). + // Static constructors to explicitly create a filename that refers to a text + // or binary file. This is in lieu of calling set_text() or set_binary() or + // set_type(). INLINE static Filename text_filename(const Filename &filename); INLINE static Filename text_filename(const string &filename); INLINE static Filename binary_filename(const Filename &filename); @@ -149,10 +143,10 @@ PUBLISHED: void set_basename_wo_extension(const string &s); void set_extension(const string &s); - // Setting these flags appropriately is helpful when opening or - // searching for a file; it helps the Filename resolve OS-specific - // conventions (for instance, that dynamic library names should - // perhaps be changed from .so to .dll). + // Setting these flags appropriately is helpful when opening or searching + // for a file; it helps the Filename resolve OS-specific conventions (for + // instance, that dynamic library names should perhaps be changed from .so + // to .dll). INLINE void set_binary(); INLINE void set_text(); INLINE bool is_binary() const; @@ -304,6 +298,3 @@ INLINE ostream &operator << (ostream &out, const Filename &n) { #include "filename.I" #endif - - - diff --git a/dtool/src/dtoolutil/filename_assist.h b/dtool/src/dtoolutil/filename_assist.h index 49eab4472c..ff1c91402c 100644 --- a/dtool/src/dtoolutil/filename_assist.h +++ b/dtool/src/dtoolutil/filename_assist.h @@ -1,16 +1,15 @@ -// Filename: filename_assist.h -// Created by: drose (13Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename_assist.h + * @author drose + * @date 2009-04-13 + */ #ifndef FILENAME_ASSIST_H #define FILENAME_ASSIST_H diff --git a/dtool/src/dtoolutil/filename_assist.mm b/dtool/src/dtoolutil/filename_assist.mm index a09cfa6704..e27c4d1ece 100644 --- a/dtool/src/dtoolutil/filename_assist.mm +++ b/dtool/src/dtoolutil/filename_assist.mm @@ -1,16 +1,15 @@ -// Filename: filename_assist.mm -// Created by: drose (13Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename_assist.mm + * @author drose + * @date 2009-04-13 + */ #include "filename_assist.h" @@ -23,11 +22,10 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: NSString_to_cpp_string -// Description: Copy the Objective-C string to a C++ string. -//////////////////////////////////////////////////////////////////// -static string +/** + * Copy the Objective-C string to a C++ string. + */ +static string NSString_to_cpp_string(NSString *str) { size_t length = [str length]; string result; @@ -38,61 +36,58 @@ NSString_to_cpp_string(NSString *str) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: call_NSSearchPathForDirectories -// Description: -//////////////////////////////////////////////////////////////////// -static string +/** + * + */ +static string call_NSSearchPathForDirectories(NSSearchPathDirectory dirkey, NSSearchPathDomainMask domain) { - // Ensure that Carbon has been initialized, and that we have an - // auto-release pool. Unfortunately, this very important function - // doesn't exist on the IPhone. + // Ensure that Carbon has been initialized, and that we have an auto-release + // pool. Unfortunately, this very important function doesn't exist on the + // IPhone. #ifndef BUILD_IPHONE NSApplicationLoad(); #endif - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(dirkey, domain, YES); string result; if ([paths count] != 0) { result = NSString_to_cpp_string([paths objectAtIndex:0]); } - [pool release]; + [pool release]; return result; } -//////////////////////////////////////////////////////////////////// -// Function: get_osx_home_directory -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string get_osx_home_directory() { #ifndef BUILD_IPHONE NSApplicationLoad(); #endif - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *dir = NSHomeDirectory(); string result = NSString_to_cpp_string(dir); - [pool release]; + [pool release]; return result; } -//////////////////////////////////////////////////////////////////// -// Function: get_NSCachesDirectory -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string get_osx_temp_directory() { #ifndef BUILD_IPHONE NSApplicationLoad(); #endif - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *dir = NSTemporaryDirectory(); if (dir == nil) { @@ -101,15 +96,14 @@ get_osx_temp_directory() { } string result = NSString_to_cpp_string(dir); - [pool release]; + [pool release]; return result; } -//////////////////////////////////////////////////////////////////// -// Function: get_osx_user_appdata_directory -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string get_osx_user_appdata_directory() { string result = call_NSSearchPathForDirectories(NSDocumentDirectory, NSUserDomainMask); @@ -119,10 +113,9 @@ get_osx_user_appdata_directory() { return get_osx_home_directory(); } -//////////////////////////////////////////////////////////////////// -// Function: get_osx_common_appdata_directory -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string get_osx_common_appdata_directory() { string result = call_NSSearchPathForDirectories(NSDocumentDirectory, NSLocalDomainMask); diff --git a/dtool/src/dtoolutil/globPattern.I b/dtool/src/dtoolutil/globPattern.I index 72d0c7e118..c5d48d4d28 100644 --- a/dtool/src/dtoolutil/globPattern.I +++ b/dtool/src/dtoolutil/globPattern.I @@ -1,76 +1,62 @@ -// Filename: globPattern.I -// Created by: drose (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globPattern.I + * @author drose + * @date 2000-05-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GlobPattern:: GlobPattern(const string &pattern) : _pattern(pattern) { _case_sensitive = true; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GlobPattern:: -GlobPattern(const GlobPattern ©) : +GlobPattern(const GlobPattern ©) : _pattern(copy._pattern), _case_sensitive(copy._case_sensitive) { } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GlobPattern:: operator = (const GlobPattern ©) { _pattern = copy._pattern; _case_sensitive = copy._case_sensitive; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GlobPattern:: operator == (const GlobPattern &other) const { return (_pattern == other._pattern && _case_sensitive == other._case_sensitive); } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GlobPattern:: operator != (const GlobPattern &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GlobPattern:: operator < (const GlobPattern &other) const { if (_case_sensitive != other._case_sensitive) { @@ -79,91 +65,68 @@ operator < (const GlobPattern &other) const { return _pattern < other._pattern; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::set_pattern -// Access: Public -// Description: Changes the pattern string that the GlobPattern -// object matches. -//////////////////////////////////////////////////////////////////// +/** + * Changes the pattern string that the GlobPattern object matches. + */ INLINE void GlobPattern:: set_pattern(const string &pattern) { _pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::get_pattern -// Access: Public -// Description: Returns the pattern string that the GlobPattern -// object matches. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pattern string that the GlobPattern object matches. + */ INLINE const string &GlobPattern:: get_pattern() const { return _pattern; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::set_case_sensitive -// Access: Public -// Description: Sets whether the match is case sensitive (true) or -// case insensitive (false). The default is case -// sensitive. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the match is case sensitive (true) or case insensitive + * (false). The default is case sensitive. + */ INLINE void GlobPattern:: set_case_sensitive(bool case_sensitive) { _case_sensitive = case_sensitive; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::get_case_sensitive -// Access: Public -// Description: Returns whether the match is case sensitive (true) or -// case insensitive (false). The default is case -// sensitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the match is case sensitive (true) or case insensitive + * (false). The default is case sensitive. + */ INLINE bool GlobPattern:: get_case_sensitive() const { return _case_sensitive; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::set_nomatch_chars -// Access: Public -// Description: Specifies a set of characters that are not matched by -// * or ?. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a set of characters that are not matched by * or ?. + */ INLINE void GlobPattern:: set_nomatch_chars(const string &nomatch_chars) { _nomatch_chars = nomatch_chars; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::get_nomatch_chars -// Access: Public -// Description: Returns the set of characters that are not matched by -// * or ?. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of characters that are not matched by * or ?. + */ INLINE const string &GlobPattern:: get_nomatch_chars() const { return _nomatch_chars; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::matches -// Access: Public -// Description: Returns true if the candidate string matches the -// pattern, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the candidate string matches the pattern, false otherwise. + */ INLINE bool GlobPattern:: matches(const string &candidate) const { return matches_substr(_pattern.begin(), _pattern.end(), candidate.begin(), candidate.end()); } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GlobPattern:: output(ostream &out) const { out << _pattern; diff --git a/dtool/src/dtoolutil/globPattern.cxx b/dtool/src/dtoolutil/globPattern.cxx index 7f7d23a53b..2a065e9a86 100644 --- a/dtool/src/dtoolutil/globPattern.cxx +++ b/dtool/src/dtoolutil/globPattern.cxx @@ -1,27 +1,23 @@ -// Filename: globPattern.cxx -// Created by: drose (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globPattern.cxx + * @author drose + * @date 2000-05-30 + */ #include "globPattern.h" #include -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::has_glob_characters -// Access: Published -// Description: Returns true if the pattern includes any special -// globbing characters, or false if it is just a literal -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pattern includes any special globbing characters, or + * false if it is just a literal string. + */ bool GlobPattern:: has_glob_characters() const { string::const_iterator pi; @@ -44,15 +40,12 @@ has_glob_characters() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::get_const_prefix -// Access: Published -// Description: Returns the initial part of the pattern before the -// first glob character. Since many glob patterns begin -// with a sequence of static characters and end with one -// or more glob characters, this can be used to -// optimized searches through sorted indices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the initial part of the pattern before the first glob character. + * Since many glob patterns begin with a sequence of static characters and end + * with one or more glob characters, this can be used to optimized searches + * through sorted indices. + */ string GlobPattern:: get_const_prefix() const { string prefix; @@ -77,24 +70,19 @@ get_const_prefix() const { return prefix += _pattern.substr(q, p - q); } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::match_files -// Access: Published -// Description: Treats the GlobPattern as a filename pattern, and -// returns a list of any actual files that match the -// pattern. This is the behavior of the standard Posix -// glob() function. Any part of the filename may -// contain glob characters, including intermediate -// directory names. -// -// If cwd is specified, it is the directory that -// relative filenames are taken to be relative to; -// otherwise, the actual current working directory is -// assumed. -// -// The return value is the number of files matched, -// which are added to the results vector. -//////////////////////////////////////////////////////////////////// +/** + * Treats the GlobPattern as a filename pattern, and returns a list of any + * actual files that match the pattern. This is the behavior of the standard + * Posix glob() function. Any part of the filename may contain glob + * characters, including intermediate directory names. + * + * If cwd is specified, it is the directory that relative filenames are taken + * to be relative to; otherwise, the actual current working directory is + * assumed. + * + * The return value is the number of files matched, which are added to the + * results vector. + */ int GlobPattern:: match_files(vector_string &results, const Filename &cwd) const { string prefix, pattern, suffix; @@ -119,11 +107,9 @@ match_files(vector_string &results, const Filename &cwd) const { return glob.r_match_files(prefix, suffix, results, cwd); } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::r_match_files -// Access: Private -// Description: The recursive implementation of match_files(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of match_files(). + */ int GlobPattern:: r_match_files(const Filename &prefix, const string &suffix, vector_string &results, const Filename &cwd) { @@ -148,8 +134,8 @@ r_match_files(const Filename &prefix, const string &suffix, next_glob.set_case_sensitive(_case_sensitive); if (!has_glob_characters()) { - // If there are no special characters in the pattern, it's a - // literal match. + // If there are no special characters in the pattern, it's a literal + // match. if (suffix.empty()) { // Time to stop. Filename single_filename(parent_dir, _pattern); @@ -165,8 +151,8 @@ r_match_files(const Filename &prefix, const string &suffix, } - // If there *are* special glob characters, we must attempt to - // match the pattern against the files in this directory. + // If there *are* special glob characters, we must attempt to match the + // pattern against the files in this directory. vector_string dir_files; if (!parent_dir.scan_directory(dir_files)) { @@ -174,8 +160,8 @@ r_match_files(const Filename &prefix, const string &suffix, return 0; } - // Now go through each file in the directory looking for one that - // matches the pattern. + // Now go through each file in the directory looking for one that matches + // the pattern. int num_matched = 0; vector_string::const_iterator fi; @@ -198,23 +184,19 @@ r_match_files(const Filename &prefix, const string &suffix, return num_matched; } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::matches_substr -// Access: Private -// Description: The recursive implementation of matches(). This -// returns true if the pattern substring [pi, pend) -// matches the candidate substring [ci, cend), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of matches(). This returns true if the + * pattern substring [pi, pend) matches the candidate substring [ci, cend), + * false otherwise. + */ bool GlobPattern:: matches_substr(string::const_iterator pi, string::const_iterator pend, string::const_iterator ci, string::const_iterator cend) const { - // If we run out of pattern or candidate string, it's a match only - // if they both ran out at the same time. + // If we run out of pattern or candidate string, it's a match only if they + // both ran out at the same time. if (pi == pend || ci == cend) { - // A special exception: we allow ci to reach the end before pi, - // only if pi is one character before the end and that last - // character is '*'. + // A special exception: we allow ci to reach the end before pi, only if pi + // is one character before the end and that last character is '*'. if ((ci == cend) && (std::distance(pi, pend) == 1) && (*pi) == '*') { return true; } @@ -224,24 +206,23 @@ matches_substr(string::const_iterator pi, string::const_iterator pend, switch (*pi) { case '*': - // A '*' in the pattern string means to match any sequence of zero - // or more characters in the candidate string. This means we have - // to recurse twice: either consume one character of the candidate - // string and continue to try matching the *, or stop trying to - // match the * here. + // A '*' in the pattern string means to match any sequence of zero or more + // characters in the candidate string. This means we have to recurse + // twice: either consume one character of the candidate string and + // continue to try matching the *, or stop trying to match the * here. if (_nomatch_chars.find(*ci) == string::npos) { return matches_substr(pi, pend, ci + 1, cend) || matches_substr(pi + 1, pend, ci, cend); } else { - // On the other hand, if this is one of the nomatch chars, we - // can only stop here. + // On the other hand, if this is one of the nomatch chars, we can only + // stop here. return matches_substr(pi + 1, pend, ci, cend); } case '?': - // A '?' in the pattern string means to match exactly one - // character in the candidate string. That's easy. + // A '?' in the pattern string means to match exactly one character in the + // candidate string. That's easy. return matches_substr(pi + 1, pend, ci + 1, cend); case '[': @@ -287,16 +268,13 @@ matches_substr(string::const_iterator pi, string::const_iterator pend, } -//////////////////////////////////////////////////////////////////// -// Function: GlobPattern::matches_set -// Access: Private -// Description: Called when an unescaped open square bracked is -// scanned, this is called with pi positioned after the -// opening square bracket, scans the set sequence, -// leaving pi positioned on the closing square bracket, -// and returns true if the indicated character matches -// the set of characters indicated, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Called when an unescaped open square bracked is scanned, this is called + * with pi positioned after the opening square bracket, scans the set + * sequence, leaving pi positioned on the closing square bracket, and returns + * true if the indicated character matches the set of characters indicated, + * false otherwise. + */ bool GlobPattern:: matches_set(string::const_iterator &pi, string::const_iterator pend, char ch) const { @@ -334,8 +312,8 @@ matches_set(string::const_iterator &pi, string::const_iterator pend, char end = (*pi); ++pi; - if ((ch >= start && ch <= end) || - (!_case_sensitive && + if ((ch >= start && ch <= end) || + (!_case_sensitive && ((tolower(ch) >= start && tolower(ch) <= end) || (toupper(ch) >= start && toupper(ch) <= end)))) { matched = true; @@ -351,6 +329,3 @@ matches_set(string::const_iterator &pi, string::const_iterator pend, return matched; } - - - diff --git a/dtool/src/dtoolutil/globPattern.h b/dtool/src/dtoolutil/globPattern.h index f1bcd007ae..379c3e7dfc 100644 --- a/dtool/src/dtoolutil/globPattern.h +++ b/dtool/src/dtoolutil/globPattern.h @@ -1,16 +1,15 @@ -// Filename: globPattern.h -// Created by: drose (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globPattern.h + * @author drose + * @date 2000-05-30 + */ #ifndef GLOBPATTERN_H #define GLOBPATTERN_H @@ -19,21 +18,17 @@ #include "filename.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : GlobPattern -// Description : This class can be used to test for string matches -// against standard Unix-shell filename globbing -// conventions. It serves as a portable standin for the -// Posix fnmatch() call. -// -// A GlobPattern is given a pattern string, which can -// contain operators like *, ?, and []. Then it can be -// tested against any number of candidate strings; for -// each candidate, it will indicate whether the string -// matches the pattern or not. It can be used, for -// example, to scan a directory for all files matching a -// particular pattern. -//////////////////////////////////////////////////////////////////// +/** + * This class can be used to test for string matches against standard Unix- + * shell filename globbing conventions. It serves as a portable standin for + * the Posix fnmatch() call. + * + * A GlobPattern is given a pattern string, which can contain operators like + * *, ?, and []. Then it can be tested against any number of candidate + * strings; for each candidate, it will indicate whether the string matches + * the pattern or not. It can be used, for example, to scan a directory for + * all files matching a particular pattern. + */ class EXPCL_DTOOL GlobPattern { PUBLISHED: INLINE GlobPattern(const string &pattern = string()); diff --git a/dtool/src/dtoolutil/lineStream.I b/dtool/src/dtoolutil/lineStream.I index bbdd853850..67cab26cbe 100644 --- a/dtool/src/dtoolutil/lineStream.I +++ b/dtool/src/dtoolutil/lineStream.I @@ -1,61 +1,49 @@ -// Filename: lineStream.I -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStream.I + * @author drose + * @date 2000-02-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: LineStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LineStream:: LineStream() : ostream(&_lsb) { } -//////////////////////////////////////////////////////////////////// -// Function: LineStream::is_text_available -// Access: Public -// Description: Returns true if there is at least one line of text -// (or even a partial line) available in the LineStream -// object. If this returns true, the line may then be -// retrieved via get_line(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is at least one line of text (or even a partial line) + * available in the LineStream object. If this returns true, the line may + * then be retrieved via get_line(). + */ INLINE bool LineStream:: is_text_available() const { return _lsb.is_text_available(); } -//////////////////////////////////////////////////////////////////// -// Function: LineStream::get_line -// Access: Public -// Description: Extracts and returns the next line (or partial line) -// of text available in the LineStream object. Once the -// line has been extracted, you may call has_newline() -// to determine whether or not there was an explicit -// newline character written following this line. -//////////////////////////////////////////////////////////////////// +/** + * Extracts and returns the next line (or partial line) of text available in + * the LineStream object. Once the line has been extracted, you may call + * has_newline() to determine whether or not there was an explicit newline + * character written following this line. + */ INLINE string LineStream:: get_line() { return _lsb.get_line(); } -//////////////////////////////////////////////////////////////////// -// Function: LineStream::has_newline -// Access: Public -// Description: Returns true if the line of text most recently -// returned by get_line() was written out with a -// terminating newline, or false if a newline character -// has not yet been written to the LineStream. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the line of text most recently returned by get_line() was + * written out with a terminating newline, or false if a newline character has + * not yet been written to the LineStream. + */ INLINE bool LineStream:: has_newline() const { return _lsb.has_newline(); diff --git a/dtool/src/dtoolutil/lineStream.cxx b/dtool/src/dtoolutil/lineStream.cxx index b679ac2747..016dc97366 100644 --- a/dtool/src/dtoolutil/lineStream.cxx +++ b/dtool/src/dtoolutil/lineStream.cxx @@ -1,15 +1,14 @@ -// Filename: lineStream.cxx -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStream.cxx + * @author drose + * @date 2000-02-26 + */ #include "lineStream.h" diff --git a/dtool/src/dtoolutil/lineStream.h b/dtool/src/dtoolutil/lineStream.h index fe0e271933..43142f81d1 100644 --- a/dtool/src/dtoolutil/lineStream.h +++ b/dtool/src/dtoolutil/lineStream.h @@ -1,16 +1,15 @@ -// Filename: lineStream.h -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStream.h + * @author drose + * @date 2000-02-26 + */ #ifndef LINESTREAM_H #define LINESTREAM_H @@ -19,20 +18,16 @@ #include "lineStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : LineStream -// Description : This is a special ostream that writes to a memory -// buffer, like ostrstream. However, its contents can -// be continuously extracted as a sequence of lines of -// text. -// -// Unlike ostrstream, which can only be extracted from -// once (and then the buffer freezes and it can no -// longer be written to), the LineStream is not -// otherwise affected when a line of text is extracted. -// More text can still be written to it and continuously -// extracted. -//////////////////////////////////////////////////////////////////// +/** + * This is a special ostream that writes to a memory buffer, like ostrstream. + * However, its contents can be continuously extracted as a sequence of lines + * of text. + * + * Unlike ostrstream, which can only be extracted from once (and then the + * buffer freezes and it can no longer be written to), the LineStream is not + * otherwise affected when a line of text is extracted. More text can still + * be written to it and continuously extracted. + */ class EXPCL_DTOOL LineStream : public ostream { PUBLISHED: INLINE LineStream(); diff --git a/dtool/src/dtoolutil/lineStreamBuf.I b/dtool/src/dtoolutil/lineStreamBuf.I index a1a8daf99e..339248d2dd 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.I +++ b/dtool/src/dtoolutil/lineStreamBuf.I @@ -1,45 +1,36 @@ -// Filename: lineStreamBuf.I -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStreamBuf.I + * @author drose + * @date 2000-02-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::is_text_available -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool LineStreamBuf:: is_text_available() const { return !_data.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::has_newline -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool LineStreamBuf:: has_newline() const { return _has_newline; } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::write_chars -// Access: Private -// Description: An internal function called by sync() and overflow() -// to store one or more characters written to the stream -// into the memory buffer. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by sync() and overflow() to store one or more + * characters written to the stream into the memory buffer. + */ INLINE void LineStreamBuf:: write_chars(const char *start, size_t length) { if (length > 0) { diff --git a/dtool/src/dtoolutil/lineStreamBuf.cxx b/dtool/src/dtoolutil/lineStreamBuf.cxx index c1d35a42cb..f2a795dab5 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.cxx +++ b/dtool/src/dtoolutil/lineStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: lineStreamBuf.cxx -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStreamBuf.cxx + * @author drose + * @date 2000-02-26 + */ #include "lineStreamBuf.h" @@ -19,45 +18,37 @@ typedef int streamsize; #endif -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LineStreamBuf:: LineStreamBuf() { _has_newline = false; - // The LineStreamBuf doesn't actually need a buffer--it's happy - // writing characters one at a time, since they're just getting - // stuffed into a string. (Although the code is written portably - // enough to use a buffer correctly, if we had one.) + // The LineStreamBuf doesn't actually need a buffer--it's happy writing + // characters one at a time, since they're just getting stuffed into a + // string. (Although the code is written portably enough to use a buffer + // correctly, if we had one.) setg(0, 0, 0); setp(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LineStreamBuf:: ~LineStreamBuf() { sync(); } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::get_line -// Access: Public -// Description: Extracts the next line of text from the -// LineStreamBuf, and sets the has_newline() flag -// according to whether this line had a trailing newline -// or not. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the next line of text from the LineStreamBuf, and sets the + * has_newline() flag according to whether this line had a trailing newline or + * not. + */ string LineStreamBuf:: get_line() { - // Extract the data up to, but not including, the next newline - // character. + // Extract the data up to, but not including, the next newline character. size_t nl = _data.find('\n'); if (nl == string::npos) { // No trailing newline; return the remainder of the string. @@ -73,13 +64,10 @@ get_line() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::sync -// Access: Public, Virtual -// Description: Called by the system ostream implementation when the -// buffer should be flushed to output (for instance, on -// destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when the buffer should be + * flushed to output (for instance, on destruction). + */ int LineStreamBuf:: sync() { streamsize n = pptr() - pbase(); @@ -88,12 +76,10 @@ sync() { return 0; // EOF to indicate write full. } -//////////////////////////////////////////////////////////////////// -// Function: LineStreamBuf::overflow -// Access: Public, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int LineStreamBuf:: overflow(int ch) { streamsize n = pptr() - pbase(); diff --git a/dtool/src/dtoolutil/lineStreamBuf.h b/dtool/src/dtoolutil/lineStreamBuf.h index 02c5b7e4b1..5da4325384 100644 --- a/dtool/src/dtoolutil/lineStreamBuf.h +++ b/dtool/src/dtoolutil/lineStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: lineStreamBuf.h -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineStreamBuf.h + * @author drose + * @date 2000-02-26 + */ #ifndef LINESTREAMBUF_H #define LINESTREAMBUF_H @@ -19,13 +18,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : LineStreamBuf -// Description : Used by LineStream to implement an ostream that -// writes to a memory buffer, whose contents can be -// continuously extracted as a sequence of lines of -// text. -//////////////////////////////////////////////////////////////////// +/** + * Used by LineStream to implement an ostream that writes to a memory buffer, + * whose contents can be continuously extracted as a sequence of lines of + * text. + */ class EXPCL_DTOOL LineStreamBuf : public streambuf { public: LineStreamBuf(); diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index b4604cc6cc..ae224d3617 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -1,16 +1,15 @@ -// Filename: load_dso.cxx -// Created by: drose (12May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_dso.cxx + * @author drose + * @date 2000-05-12 + */ #include "load_dso.h" #include "executionEnvironment.h" @@ -18,9 +17,8 @@ static Filename resolve_dso(const DSearchPath &path, const Filename &filename) { if (filename.is_local()) { if ((path.get_num_directories()==1)&&(path.get_directory(0)=="")) { - // This is a special case, meaning to search in the same - // directory in which libp3dtool.dll, or the exe, was started - // from. + // This is a special case, meaning to search in the same directory in + // which libp3dtool.dll, or the exe, was started from. Filename dtoolpath = ExecutionEnvironment::get_dtool_name(); DSearchPath spath(dtoolpath.get_dirname()); return spath.find_file(filename); @@ -39,10 +37,9 @@ static Filename resolve_dso(const DSearchPath &path, const Filename &filename) { #include #undef WINDOWS_LEAN_AND_MEAN -// Loads in a dynamic library like an .so or .dll. Returns NULL if -// failure, otherwise on success. If the filename is not absolute, -// searches the path. If the path is empty, searches the dtool -// directory. +// Loads in a dynamic library like an .so or .dll. Returns NULL if failure, +// otherwise on success. If the filename is not absolute, searches the path. +// If the path is empty, searches the dtool directory. void * load_dso(const DSearchPath &path, const Filename &filename) { @@ -51,7 +48,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { return NULL; } string os_specific = abspath.to_os_specific(); - + // Try using LoadLibraryEx, if possible. typedef HMODULE (WINAPI *tLoadLibraryEx)(LPCTSTR, HANDLE, DWORD); tLoadLibraryEx pLoadLibraryEx; @@ -62,7 +59,7 @@ load_dso(const DSearchPath &path, const Filename &filename) { return pLoadLibraryEx(os_specific.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); } } - + return LoadLibrary(os_specific.c_str()); } diff --git a/dtool/src/dtoolutil/load_dso.h b/dtool/src/dtoolutil/load_dso.h index d2ca067ee3..b4232f4ad2 100644 --- a/dtool/src/dtoolutil/load_dso.h +++ b/dtool/src/dtoolutil/load_dso.h @@ -1,16 +1,15 @@ -// Filename: load_dso.h -// Created by: drose (12May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_dso.h + * @author drose + * @date 2000-05-12 + */ #ifndef LOAD_DSO_H #define LOAD_DSO_H @@ -19,10 +18,9 @@ #include "dSearchPath.h" #include "filename.h" -// Loads in a dynamic library like an .so or .dll. Returns NULL if -// failure, otherwise on success. If the filename is not absolute, -// searches the path. If the path is empty, searches the dtool -// directory. +// Loads in a dynamic library like an .so or .dll. Returns NULL if failure, +// otherwise on success. If the filename is not absolute, searches the path. +// If the path is empty, searches the dtool directory. EXPCL_DTOOL void * load_dso(const DSearchPath &path, const Filename &filename); @@ -41,4 +39,3 @@ EXPCL_DTOOL void * get_dso_symbol(void *handle, const string &name); #endif - diff --git a/dtool/src/dtoolutil/pandaFileStream.I b/dtool/src/dtoolutil/pandaFileStream.I index 2ed5d35d38..a30a5fdcc0 100644 --- a/dtool/src/dtoolutil/pandaFileStream.I +++ b/dtool/src/dtoolutil/pandaFileStream.I @@ -1,52 +1,42 @@ -// Filename: pandaFileStream.I -// Created by: drose (08Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFileStream.I + * @author drose + * @date 2008-09-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IFileStream:: IFileStream() : istream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IFileStream:: IFileStream(const char *filename, ios::openmode mode) : istream(&_buf) { open(filename, mode); } -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IFileStream:: ~IFileStream() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::open -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void IFileStream:: open(const char *filename, ios::openmode mode) { clear((ios_iostate)0); @@ -57,17 +47,13 @@ open(const char *filename, ios::openmode mode) { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Windows-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Windows-specific variant. + */ void IFileStream:: attach(const char *filename, HANDLE handle, ios::openmode mode) { clear((ios_iostate)0); @@ -79,17 +65,13 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { #endif // _WIN32 #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Posix-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Posix-specific variant. + */ void IFileStream:: attach(const char *filename, int fd, ios::openmode mode) { clear((ios_iostate)0); @@ -100,50 +82,40 @@ attach(const char *filename, int fd, ios::openmode mode) { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: IFileStream::close -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void IFileStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OFileStream:: OFileStream() : ostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OFileStream:: OFileStream(const char *filename, ios::openmode mode) : ostream(&_buf) { open(filename, mode); } -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OFileStream:: ~OFileStream() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::open -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void OFileStream:: open(const char *filename, ios::openmode mode) { clear((ios_iostate)0); @@ -154,17 +126,13 @@ open(const char *filename, ios::openmode mode) { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Windows-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Windows-specific variant. + */ void OFileStream:: attach(const char *filename, HANDLE handle, ios::openmode mode) { clear((ios_iostate)0); @@ -176,17 +144,13 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { #endif // _WIN32 #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Posix-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Posix-specific variant. + */ void OFileStream:: attach(const char *filename, int fd, ios::openmode mode) { clear((ios_iostate)0); @@ -197,50 +161,40 @@ attach(const char *filename, int fd, ios::openmode mode) { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: OFileStream::close -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void OFileStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: FileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FileStream:: FileStream() : iostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: FileStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FileStream:: FileStream(const char *filename, ios::openmode mode) : iostream(&_buf) { open(filename, mode); } -//////////////////////////////////////////////////////////////////// -// Function: FileStream::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FileStream:: ~FileStream() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: FileStream::open -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FileStream:: open(const char *filename, ios::openmode mode) { clear((ios_iostate)0); @@ -251,17 +205,13 @@ open(const char *filename, ios::openmode mode) { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: FileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Windows-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Windows-specific variant. + */ void FileStream:: attach(const char *filename, HANDLE handle, ios::openmode mode) { clear((ios_iostate)0); @@ -273,17 +223,13 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { #endif // _WIN32 #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: FileStream::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Posix-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Posix-specific variant. + */ void FileStream:: attach(const char *filename, int fd, ios::openmode mode) { clear((ios_iostate)0); @@ -294,11 +240,9 @@ attach(const char *filename, int fd, ios::openmode mode) { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: FileStream::close -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FileStream:: close() { _buf.close(); diff --git a/dtool/src/dtoolutil/pandaFileStream.cxx b/dtool/src/dtoolutil/pandaFileStream.cxx index 9941e5fbb3..412a858899 100644 --- a/dtool/src/dtoolutil/pandaFileStream.cxx +++ b/dtool/src/dtoolutil/pandaFileStream.cxx @@ -1,16 +1,15 @@ -// Filename: pandaFileStream.cxx -// Created by: drose (08Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFileStream.cxx + * @author drose + * @date 2008-09-08 + */ #include "pandaFileStream.h" @@ -18,4 +17,3 @@ #endif // USE_PANDAFILESTREAM - diff --git a/dtool/src/dtoolutil/pandaFileStream.h b/dtool/src/dtoolutil/pandaFileStream.h index 23aa5b5521..bd943bd11a 100644 --- a/dtool/src/dtoolutil/pandaFileStream.h +++ b/dtool/src/dtoolutil/pandaFileStream.h @@ -1,16 +1,15 @@ -// Filename: pandaFileStream.h -// Created by: drose (08Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFileStream.h + * @author drose + * @date 2008-09-08 + */ #ifndef PANDAFILESTREAM_H #define PANDAFILESTREAM_H @@ -21,15 +20,12 @@ #include "pandaFileStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : IFileStream -// Description : Implements a C++ stream object suitable for reading -// from files on disk. This is similar to ifstream, but -// it provides low-level support for Panda's -// simple-threading implementation (using this interface -// will block only the current thread, rather than the -// entire process, on I/O waits). -//////////////////////////////////////////////////////////////////// +/** + * Implements a C++ stream object suitable for reading from files on disk. + * This is similar to ifstream, but it provides low-level support for Panda's + * simple-threading implementation (using this interface will block only the + * current thread, rather than the entire process, on I/O waits). + */ class EXPCL_DTOOL IFileStream : public istream { PUBLISHED: INLINE IFileStream(); @@ -52,15 +48,12 @@ private: PandaFileStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : OFileStream -// Description : Implements a C++ stream object suitable for writing -// to files on disk. This is similar to ofstream, but -// it provides low-level support for Panda's -// simple-threading implementation (using this interface -// will block only the current thread, rather than the -// entire process, on I/O waits). -//////////////////////////////////////////////////////////////////// +/** + * Implements a C++ stream object suitable for writing to files on disk. This + * is similar to ofstream, but it provides low-level support for Panda's + * simple-threading implementation (using this interface will block only the + * current thread, rather than the entire process, on I/O waits). + */ class EXPCL_DTOOL OFileStream : public ostream { PUBLISHED: INLINE OFileStream(); @@ -83,15 +76,13 @@ private: PandaFileStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : FileStream -// Description : Implements a C++ stream object suitable for reading -// from and/or writing to files on disk. This is -// similar to fstream, but it provides low-level support -// for Panda's simple-threading implementation (using -// this interface will block only the current thread, -// rather than the entire process, on I/O waits). -//////////////////////////////////////////////////////////////////// +/** + * Implements a C++ stream object suitable for reading from and/or writing to + * files on disk. This is similar to fstream, but it provides low-level + * support for Panda's simple-threading implementation (using this interface + * will block only the current thread, rather than the entire process, on I/O + * waits). + */ class EXPCL_DTOOL FileStream : public iostream { PUBLISHED: INLINE FileStream(); diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx index 3b7c14387a..ca78c0a551 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.cxx +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: pandaFileStreamBuf.cxx -// Created by: drose (08Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFileStreamBuf.cxx + * @author drose + * @date 2008-09-08 + */ #include "pandaFileStreamBuf.h" #include "memoryHook.h" @@ -30,18 +29,16 @@ PandaFileStreamBuf::NewlineMode PandaFileStreamBuf::_newline_mode = NM_native; static const size_t file_buffer_size = 4096; -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaFileStreamBuf:: PandaFileStreamBuf() { _is_open = false; _open_mode = (ios::openmode)0; _last_read_nl = 0; - + #ifdef _WIN32 // Windows case. _handle = NULL; @@ -58,8 +55,8 @@ PandaFileStreamBuf() { #else allocate(); - // Chop the buffer in half. The bottom half goes to the get buffer; - // the top half goes to the put buffer. + // Chop the buffer in half. The bottom half goes to the get buffer; the top + // half goes to the put buffer. char *b = base(); char *t = ebuf(); char *m = b + (t - b) / 2; @@ -71,11 +68,9 @@ PandaFileStreamBuf() { _ppos = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaFileStreamBuf:: ~PandaFileStreamBuf() { close(); @@ -84,11 +79,9 @@ PandaFileStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::open -// Access: Public -// Description: Attempts to open the file for input and/or output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the file for input and/or output. + */ void PandaFileStreamBuf:: open(const char *filename, ios::openmode mode) { close(); @@ -130,7 +123,7 @@ open(const char *filename, ios::openmode mode) { } #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In SIMPLE_THREADS mode, we use "overlapped" I/O. + // In SIMPLE_THREADS mode, we use "overlapped" IO. flags |= FILE_FLAG_OVERLAPPED; #endif @@ -144,7 +137,7 @@ open(const char *filename, ios::openmode mode) { // The file was successfully opened and locked. _is_open = true; } - + #else // Posix case. int flags = 0; @@ -166,7 +159,7 @@ open(const char *filename, ios::openmode mode) { } #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In SIMPLE_THREADS mode, we use non-blocking I/O. + // In SIMPLE_THREADS mode, we use non-blocking IO. flags |= O_NONBLOCK; #endif @@ -184,17 +177,13 @@ open(const char *filename, ios::openmode mode) { } #ifdef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Windows-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Windows-specific variant. + */ void PandaFileStreamBuf:: attach(const char *filename, HANDLE handle, ios::openmode mode) { close(); @@ -217,17 +206,13 @@ attach(const char *filename, HANDLE handle, ios::openmode mode) { #endif // _WIN32 #ifndef _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::attach -// Access: Public -// Description: Connects the file stream to the existing OS-defined -// stream, presumably opened via a low-level OS call. -// The filename is for reporting only. When the file -// stream is closed, it will also close the underlying -// OS handle. -// -// This function is the Posix-specific variant. -//////////////////////////////////////////////////////////////////// +/** + * Connects the file stream to the existing OS-defined stream, presumably + * opened via a low-level OS call. The filename is for reporting only. When + * the file stream is closed, it will also close the underlying OS handle. + * + * This function is the Posix-specific variant. + */ void PandaFileStreamBuf:: attach(const char *filename, int fd, ios::openmode mode) { close(); @@ -249,21 +234,17 @@ attach(const char *filename, int fd, ios::openmode mode) { } #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::is_open -// Access: Public -// Description: Returns true if the file is open, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file is open, false otherwise. + */ bool PandaFileStreamBuf:: is_open() const { return _is_open; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::close -// Access: Public -// Description: Empties the buffer and closes the file. -//////////////////////////////////////////////////////////////////// +/** + * Empties the buffer and closes the file. + */ void PandaFileStreamBuf:: close() { // Make sure the write buffer is flushed. @@ -291,18 +272,16 @@ close() { gbump(egptr() - gptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::seekoff -// Access: Public, Virtual -// Description: Implements seeking within the stream. -//////////////////////////////////////////////////////////////////// +/** + * Implements seeking within the stream. + */ streampos PandaFileStreamBuf:: seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { streampos result = -1; if (!(_open_mode & ios::binary)) { - // Seeking on text files is only supported for seeks to the - // beginning of the file. + // Seeking on text files is only supported for seeks to the beginning of + // the file. if (off != 0 || dir != ios::beg) { return -1; } @@ -321,17 +300,17 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { assert(_gpos >= 0); streampos cur_pos = _gpos; streampos new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (streampos)off; break; - + case ios::cur: new_pos = (streampos)(cur_pos + off); break; - + case ios::end: #ifdef _WIN32 // Windows case. @@ -367,17 +346,17 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { size_t n = pptr() - pbase(); streampos cur_pos = _ppos + (streamoff)n; streampos new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (streampos)off; break; - + case ios::cur: new_pos = (streampos)(cur_pos + off); break; - + case ios::end: #ifdef _WIN32 // Windows case. @@ -408,31 +387,24 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::seekpos -// Access: Public, Virtual -// Description: A variant on seekoff() to implement seeking within a -// stream. -// -// The MSDN Library claims that it is only necessary to -// redefine seekoff(), and not seekpos() as well, as the -// default implementation of seekpos() is supposed to -// map to seekoff() exactly as I am doing here; but in -// fact it must do something else, because seeking -// didn't work on Windows until I redefined this -// function as well. -//////////////////////////////////////////////////////////////////// +/** + * A variant on seekoff() to implement seeking within a stream. + * + * The MSDN Library claims that it is only necessary to redefine seekoff(), + * and not seekpos() as well, as the default implementation of seekpos() is + * supposed to map to seekoff() exactly as I am doing here; but in fact it + * must do something else, because seeking didn't work on Windows until I + * redefined this function as well. + */ streampos PandaFileStreamBuf:: seekpos(streampos pos, ios_openmode which) { return seekoff(pos, ios::beg, which); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int PandaFileStreamBuf:: overflow(int ch) { bool okflag = true; @@ -463,12 +435,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int PandaFileStreamBuf:: sync() { size_t n = pptr() - pbase(); @@ -482,12 +452,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int PandaFileStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -519,13 +487,10 @@ underflow() { return (unsigned char)*gptr(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::read_chars -// Access: Private -// Description: Attempts to extract the indicated number of -// characters from the current file position. Returns -// the number of characters extracted. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to extract the indicated number of characters from the current + * file position. Returns the number of characters extracted. + */ size_t PandaFileStreamBuf:: read_chars(char *start, size_t length) { if (length == 0 || !_is_open) { @@ -537,13 +502,12 @@ read_chars(char *start, size_t length) { sync(); if (_open_mode & ios::binary) { - // If the file is opened in binary mode, just read the data in the - // file. + // If the file is opened in binary mode, just read the data in the file. return read_chars_raw(start, length); } - // The file is opened in text mode. We have to decode newline - // characters in the file. + // The file is opened in text mode. We have to decode newline characters in + // the file. if (_newline_mode == NM_binary) { // Unless we're configured to always use binary mode. return read_chars_raw(start, length); @@ -556,11 +520,11 @@ read_chars(char *start, size_t length) { do { read_length = length - 1; if (_last_read_nl != 0) { - // If we have a newline character to grow on, we might need to - // expand the buffer we read from the file by one character. In - // that case, read one character less to make room for it. - // (Otherwise, we are confident that the buffer will not expand - // when we decode the newlines.) + // If we have a newline character to grow on, we might need to expand + // the buffer we read from the file by one character. In that case, + // read one character less to make room for it. (Otherwise, we are + // confident that the buffer will not expand when we decode the + // newlines.) --read_length; } read_length = read_chars_raw(buffer, read_length); @@ -573,12 +537,9 @@ read_chars(char *start, size_t length) { return final_length; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::write_chars -// Access: Private -// Description: Outputs the indicated stream of characters to the -// current file position. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated stream of characters to the current file position. + */ size_t PandaFileStreamBuf:: write_chars(const char *start, size_t length) { if (length == 0) { @@ -594,13 +555,12 @@ write_chars(const char *start, size_t length) { // Windows case. if (_open_mode & ios::binary) { - // If the file is opened in binary mode, just write the data to the - // file. + // If the file is opened in binary mode, just write the data to the file. return write_chars_raw(start, length); } - // The file is opened in text mode. We have to encode newline - // characters to the file. + // The file is opened in text mode. We have to encode newline characters to + // the file. NewlineMode this_newline_mode = _newline_mode; if (this_newline_mode == NM_native) { @@ -609,7 +569,7 @@ write_chars(const char *start, size_t length) { #else // Even the Mac uses Unix-style EOL characters these days. this_newline_mode = NM_unix; -#endif +#endif } if (this_newline_mode == NM_binary) { @@ -618,8 +578,8 @@ write_chars(const char *start, size_t length) { size_t buffer_length = length; if (this_newline_mode == NM_msdos) { - // Windows requires a larger buffer here, since we are writing two - // newline characters for every one. + // Windows requires a larger buffer here, since we are writing two newline + // characters for every one. buffer_length *= 2; } char *buffer = (char *)alloca(buffer_length); @@ -648,19 +608,16 @@ write_chars(const char *start, size_t length) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::read_chars_raw -// Access: Private -// Description: Reads raw data from the file directly into the -// indicated buffer. Returns the number of characters -// read. -//////////////////////////////////////////////////////////////////// +/** + * Reads raw data from the file directly into the indicated buffer. Returns + * the number of characters read. + */ size_t PandaFileStreamBuf:: read_chars_raw(char *start, size_t length) { if (length == 0) { return 0; } - + #ifdef _WIN32 // Windows case. OVERLAPPED overlapped; @@ -669,17 +626,17 @@ read_chars_raw(char *start, size_t length) { gpos.QuadPart = _gpos; overlapped.Offset = gpos.LowPart; overlapped.OffsetHigh = gpos.HighPart; - + DWORD bytes_read = 0; BOOL success = ReadFile(_handle, start, length, &bytes_read, &overlapped); int pass = 0; while (!success) { DWORD error = GetLastError(); if (error == ERROR_IO_INCOMPLETE || error == ERROR_IO_PENDING) { - // Wait for more later, but don't actually yield until we have - // made the first call to GetOverlappedResult(). (Apparently, - // Vista and Windows 7 *always* return ERROR_IO_INCOMPLETE after - // the first call to ReadFile.) + // Wait for more later, but don't actually yield until we have made the + // first call to GetOverlappedResult(). (Apparently, Vista and Windows + // 7 *always* return ERROR_IO_INCOMPLETE after the first call to + // ReadFile.) if (pass > 0) { thread_yield(); } @@ -698,7 +655,7 @@ read_chars_raw(char *start, size_t length) { } length = bytes_read; - + #else // Posix case. if (lseek(_fd, _gpos, SEEK_SET) == -1) { @@ -706,7 +663,7 @@ read_chars_raw(char *start, size_t length) { << "Error seeking to position " << _gpos << " in " << _filename << "\n"; return 0; } - + int result = ::read(_fd, start, length); while (result < 0) { if (errno == EAGAIN) { @@ -727,18 +684,16 @@ read_chars_raw(char *start, size_t length) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::write_chars_raw -// Access: Private -// Description: Writes the indicated buffer directly to the file -// stream. Returns the number of characters written. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated buffer directly to the file stream. Returns the + * number of characters written. + */ size_t PandaFileStreamBuf:: write_chars_raw(const char *start, size_t length) { if (length == 0 || !_is_open) { return 0; } - + #ifdef _WIN32 // Windows case. OVERLAPPED overlapped; @@ -752,17 +707,17 @@ write_chars_raw(const char *start, size_t length) { overlapped.Offset = -1; overlapped.OffsetHigh = -1; } - + DWORD bytes_written = 0; BOOL success = WriteFile(_handle, start, length, &bytes_written, &overlapped); int pass = 0; while (!success) { DWORD error = GetLastError(); if (error == ERROR_IO_INCOMPLETE || error == ERROR_IO_PENDING) { - // Wait for more later, but don't actually yield until we have - // made the first call to GetOverlappedResult(). (Apparently, - // Vista and Windows 7 *always* return ERROR_IO_INCOMPLETE after - // the first call to WriteFile.) + // Wait for more later, but don't actually yield until we have made the + // first call to GetOverlappedResult(). (Apparently, Vista and Windows + // 7 *always* return ERROR_IO_INCOMPLETE after the first call to + // WriteFile.) if (pass > 0) { thread_yield(); } @@ -783,7 +738,7 @@ write_chars_raw(const char *start, size_t length) { assert(bytes_written == length); _ppos += bytes_written; assert(_ppos >= 0); - + #else // Posix case. if (!(_open_mode & ios::app)) { @@ -807,7 +762,7 @@ write_chars_raw(const char *start, size_t length) { } continue; } - + start += result; remaining -= result; _ppos += result; @@ -818,17 +773,13 @@ write_chars_raw(const char *start, size_t length) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::decode_newlines -// Access: Private -// Description: Converts a buffer from universal newlines to \n. -// -// Returns the number of characters placed in dest. -// This may also set (or read) the value of -// _last_read_nl, which is preserved from call-to-call -// to deal with newline combinations that straddle a -// read operation. -//////////////////////////////////////////////////////////////////// +/** + * Converts a buffer from universal newlines to \n. + * + * Returns the number of characters placed in dest. This may also set (or + * read) the value of _last_read_nl, which is preserved from call-to-call to + * deal with newline combinations that straddle a read operation. + */ size_t PandaFileStreamBuf:: decode_newlines(char *dest, size_t dest_length, const char *source, size_t source_length) { @@ -836,8 +787,7 @@ decode_newlines(char *dest, size_t dest_length, char *q = dest; // Write to q if (source_length == 0) { - // A special case: this is at end-of-file. Resolve the hanging - // newline. + // A special case: this is at end-of-file. Resolve the hanging newline. switch (_last_read_nl) { case '\n': case '\r': @@ -912,16 +862,14 @@ decode_newlines(char *dest, size_t dest_length, return q - dest; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::encode_newlines_msdos -// Access: Private -// Description: Windows case: Converts a buffer from \n to \n\r. -// -// To allow for full buffer expansion, dest_length -// should be at least 2*source_length. -// -// Returns the number of characters placed in dest. -//////////////////////////////////////////////////////////////////// +/** + * Windows case: Converts a buffer from \n to \n\r. + * + * To allow for full buffer expansion, dest_length should be at least + * 2*source_length. + * + * Returns the number of characters placed in dest. + */ size_t PandaFileStreamBuf:: encode_newlines_msdos(char *dest, size_t dest_length, const char *source, size_t source_length) { @@ -952,19 +900,16 @@ encode_newlines_msdos(char *dest, size_t dest_length, return q - dest; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::encode_newlines_unix -// Access: Private -// Description: Unix case: Converts a buffer from \n to \n. -// -// This is, of course, no conversion at all; but we do -// strip out \r characters if they appear in the buffer; -// this will help programmers to realize when they have -// incorrectly tagged a binary file with text mode, even -// on a Posix environment. -// -// Returns the number of characters placed in dest. -//////////////////////////////////////////////////////////////////// +/** + * Unix case: Converts a buffer from \n to \n. + * + * This is, of course, no conversion at all; but we do strip out \r characters + * if they appear in the buffer; this will help programmers to realize when + * they have incorrectly tagged a binary file with text mode, even on a Posix + * environment. + * + * Returns the number of characters placed in dest. + */ size_t PandaFileStreamBuf:: encode_newlines_unix(char *dest, size_t dest_length, const char *source, size_t source_length) { @@ -988,13 +933,11 @@ encode_newlines_unix(char *dest, size_t dest_length, return q - dest; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFileStreamBuf::encode_newlines_mac -// Access: Private -// Description: Classic Mac case: Converts a buffer from \n to \r. -// -// Returns the number of characters placed in dest. -//////////////////////////////////////////////////////////////////// +/** + * Classic Mac case: Converts a buffer from \n to \r. + * + * Returns the number of characters placed in dest. + */ size_t PandaFileStreamBuf:: encode_newlines_mac(char *dest, size_t dest_length, const char *source, size_t source_length) { diff --git a/dtool/src/dtoolutil/pandaFileStreamBuf.h b/dtool/src/dtoolutil/pandaFileStreamBuf.h index 0561c3bcba..cab9556919 100644 --- a/dtool/src/dtoolutil/pandaFileStreamBuf.h +++ b/dtool/src/dtoolutil/pandaFileStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: pandaFileStreamBuf.h -// Created by: drose (08Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFileStreamBuf.h + * @author drose + * @date 2008-09-08 + */ #ifndef PANDAFILESTREAMBUF_H #define PANDAFILESTREAMBUF_H @@ -26,11 +25,9 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Class : PandaFileStreamBuf -// Description : The streambuf object that implements -// pifstream and pofstream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements pifstream and pofstream. + */ class EXPCL_DTOOL PandaFileStreamBuf : public streambuf { public: PandaFileStreamBuf(); diff --git a/dtool/src/dtoolutil/pandaSystem.cxx b/dtool/src/dtoolutil/pandaSystem.cxx index c4c94a59e1..cef04eb37b 100644 --- a/dtool/src/dtoolutil/pandaSystem.cxx +++ b/dtool/src/dtoolutil/pandaSystem.cxx @@ -1,16 +1,15 @@ -// Filename: pandaSystem.cxx -// Created by: drose (26Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaSystem.cxx + * @author drose + * @date 2005-01-26 + */ #include "pandaSystem.h" #include "pandaVersion.h" @@ -19,22 +18,19 @@ PandaSystem *PandaSystem::_global_ptr = NULL; TypeHandle PandaSystem::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::Constructor -// Access: Protected -// Description: Don't try to construct a PandaSystem object; there is -// only one of these, and it constructs itself. Use -// get_global_ptr() to get a pointer to the one -// PandaSystem. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to construct a PandaSystem object; there is only one of these, + * and it constructs itself. Use get_global_ptr() to get a pointer to the one + * PandaSystem. + */ PandaSystem:: PandaSystem() : _systems(get_class_type()) { _system_names_dirty = false; - // These are settable via Config.prc, but only in development - // (!NDEBUG) mode, and only if they are not already defined. + // These are settable via Config.prc, but only in development (!NDEBUG) + // mode, and only if they are not already defined. _package_version_string = PANDA_PACKAGE_VERSION_STR; _package_host_url = PANDA_PACKAGE_HOST_URL; @@ -60,51 +56,41 @@ PandaSystem() : #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::Destructor -// Access: Protected -// Description: Don't try to destruct the global PandaSystem object. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to destruct the global PandaSystem object. + */ PandaSystem:: ~PandaSystem() { } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_version_string -// Access: Published, Static -// Description: Returns the current version of Panda, expressed as a -// string, e.g. "1.0.0". The string will end in the -// letter "c" if this build does not represent an -// official version. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current version of Panda, expressed as a string, e.g. "1.0.0". + * The string will end in the letter "c" if this build does not represent an + * official version. + */ string PandaSystem:: get_version_string() { return PANDA_VERSION_STR; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_package_version_string -// Access: Published, Static -// Description: Returns the version of the Panda3D distributable -// package that provides this build of Panda. -// -// When the currently-executing version of Panda was -// loaded from a distributable package, such as via the -// browser plugin, then this string will be nonempty and -// will contain the corresponding version string. You -// can build applications that use this particular -// version of Panda by requesting it in the pdef file, -// using "panda3d", this version string, and the -// download host provided by get_package_host_url(). -// -// If this string is empty, then the currently-executing -// Panda was built independently, and is not part of a -// distributable package. -// -// This string is set explicitly at compilation time. -// Normally, it should be set to a nonempty string only -// when building a Panda3D package for distribution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version of the Panda3D distributable package that provides this + * build of Panda. + * + * When the currently-executing version of Panda was loaded from a + * distributable package, such as via the browser plugin, then this string + * will be nonempty and will contain the corresponding version string. You + * can build applications that use this particular version of Panda by + * requesting it in the pdef file, using "panda3d", this version string, and + * the download host provided by get_package_host_url(). + * + * If this string is empty, then the currently-executing Panda was built + * independently, and is not part of a distributable package. + * + * This string is set explicitly at compilation time. Normally, it should be + * set to a nonempty string only when building a Panda3D package for + * distribution. + */ string PandaSystem:: get_package_version_string() { #ifdef NDEBUG @@ -114,22 +100,18 @@ get_package_version_string() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_package_host_url -// Access: Published, Static -// Description: Returns the URL of the download server that provides -// the Panda3D distributable package currently running. -// This can be used, along with the -// get_package_version_string(), to uniquely identify -// the running version of Panda among distributable -// Panda versions. -// -// See get_package_version_string() for more information. -// -// This string is set explicitly at compilation time. -// Normally, it should be set to a nonempty string only -// when building a Panda3D package for distribution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the URL of the download server that provides the Panda3D + * distributable package currently running. This can be used, along with the + * get_package_version_string(), to uniquely identify the running version of + * Panda among distributable Panda versions. + * + * See get_package_version_string() for more information. + * + * This string is set explicitly at compilation time. Normally, it should be + * set to a nonempty string only when building a Panda3D package for + * distribution. + */ string PandaSystem:: get_package_host_url() { #ifdef NDEBUG @@ -139,22 +121,17 @@ get_package_host_url() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_p3d_coreapi_version_string -// Access: Published, Static -// Description: Returns the current version of Panda's Core API, -// expressed as a string of dot-delimited integers. -// There are usually four integers in this version, but -// this is not guaranteed. -// -// The Core API is used during the runtime (plugin) -// environment only. This may be the empty string if -// the current version of Panda is not built to provide -// a particular Core API, which will be the normal case -// in a development SDK. However, you should not use -// this method to determine whether you are running in a -// runtime environment or not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current version of Panda's Core API, expressed as a string of + * dot-delimited integers. There are usually four integers in this version, + * but this is not guaranteed. + * + * The Core API is used during the runtime (plugin) environment only. This + * may be the empty string if the current version of Panda is not built to + * provide a particular Core API, which will be the normal case in a + * development SDK. However, you should not use this method to determine + * whether you are running in a runtime environment or not. + */ string PandaSystem:: get_p3d_coreapi_version_string() { #ifndef P3D_COREAPI_VERSION_STR @@ -164,60 +141,45 @@ get_p3d_coreapi_version_string() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_major_version -// Access: Published, Static -// Description: Returns the major version number of the current -// version of Panda. This is the first number of the -// dotted triple returned by get_version_string(). It -// changes very rarely. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number of the current version of Panda. This is + * the first number of the dotted triple returned by get_version_string(). It + * changes very rarely. + */ int PandaSystem:: get_major_version() { return PANDA_MAJOR_VERSION; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_minor_version -// Access: Published, Static -// Description: Returns the minor version number of the current -// version of Panda. This is the second number of the -// dotted triple returned by get_version_string(). It -// changes with each release that introduces new -// features. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number of the current version of Panda. This is + * the second number of the dotted triple returned by get_version_string(). + * It changes with each release that introduces new features. + */ int PandaSystem:: get_minor_version() { return PANDA_MINOR_VERSION; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_sequence_version -// Access: Published, Static -// Description: Returns the sequence version number of the current -// version of Panda. This is the third number of the -// dotted triple returned by get_version_string(). It -// changes with bugfix updates and very minor feature -// updates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sequence version number of the current version of Panda. This + * is the third number of the dotted triple returned by get_version_string(). + * It changes with bugfix updates and very minor feature updates. + */ int PandaSystem:: get_sequence_version() { return PANDA_SEQUENCE_VERSION; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::is_official_version -// Access: Published, Static -// Description: Returns true if current version of Panda claims to be -// an "official" version, that is, one that was compiled -// by an official distributor of Panda using a specific -// version of the panda source tree. If this is true, -// there will not be a "c" at the end of the version -// string returned by get_version_string(). -// -// Note that we must take the distributor's word for it -// here. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if current version of Panda claims to be an "official" + * version, that is, one that was compiled by an official distributor of Panda + * using a specific version of the panda source tree. If this is true, there + * will not be a "c" at the end of the version string returned by + * get_version_string(). + * + * Note that we must take the distributor's word for it here. + */ bool PandaSystem:: is_official_version() { #ifdef PANDA_OFFICIAL_VERSION @@ -227,26 +189,20 @@ is_official_version() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_distributor -// Access: Published, Static -// Description: Returns the string defined by the distributor of this -// version of Panda, or "homebuilt" if this version was -// built directly from the sources by the end-user. -// This is a completely arbitrary string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string defined by the distributor of this version of Panda, or + * "homebuilt" if this version was built directly from the sources by the end- + * user. This is a completely arbitrary string. + */ string PandaSystem:: get_distributor() { return PANDA_DISTRIBUTOR; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_compiler -// Access: Published, Static -// Description: Returns a string representing the compiler that was -// used to generate this version of Panda, if it is -// available, or "unknown" if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the compiler that was used to generate this + * version of Panda, if it is available, or "unknown" if it is not. + */ string PandaSystem:: get_compiler() { #if defined(_MSC_VER) @@ -254,8 +210,8 @@ get_compiler() { ostringstream strm; strm << "MSC v." << _MSC_VER; - // We also get this suite of macros that tells us what the build - // platform is. + // We also get this suite of macros that tells us what the build platform + // is. #if defined(_M_IX86) #ifdef MS_WIN64 strm << " 64 bit (Intel)"; @@ -271,8 +227,8 @@ get_compiler() { return strm.str(); #elif defined(__clang__) - // Clang has this macro. This case has to go before __GNUC__ - // because that is also defined by clang. + // Clang has this macro. This case has to go before __GNUC__ because that + // is also defined by clang. return "Clang " __clang_version__; #elif defined(__GNUC__) @@ -285,25 +241,19 @@ get_compiler() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_build_date -// Access: Published, Static -// Description: Returns a string representing the date and time at -// which this version of Panda (or at least dtool) was -// compiled, if available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the date and time at which this version of + * Panda (or at least dtool) was compiled, if available. + */ string PandaSystem:: get_build_date() { return __DATE__ " " __TIME__; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_git_commit -// Access: Published, Static -// Description: Returns a string representing the git commit hash -// that this source tree is based on, or the empty -// string if it has not been specified at build time. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the git commit hash that this source tree is + * based on, or the empty string if it has not been specified at build time. + */ string PandaSystem:: get_git_commit() { #ifdef PANDA_GIT_COMMIT_STR @@ -313,27 +263,21 @@ get_git_commit() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_platform -// Access: Published, Static -// Description: Returns a string representing the runtime platform -// that we are currently running on. This will be -// something like "win32" or "osx_i386" or -// "linux_amd64". -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the runtime platform that we are currently + * running on. This will be something like "win32" or "osx_i386" or + * "linux_amd64". + */ string PandaSystem:: get_platform() { return DTOOL_PLATFORM; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::has_system -// Access: Published -// Description: Returns true if the current version of Panda claims -// to have the indicated subsystem installed, false -// otherwise. The set of available subsystems is -// implementation defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current version of Panda claims to have the indicated + * subsystem installed, false otherwise. The set of available subsystems is + * implementation defined. + */ bool PandaSystem:: has_system(const string &system) const { Systems::const_iterator si; @@ -341,26 +285,20 @@ has_system(const string &system) const { return (si != _systems.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_num_systems -// Access: Published -// Description: Returns the number of Panda subsystems that have -// registered themselves. This can be used with -// get_system() to iterate through the entire list of -// available Panda subsystems. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of Panda subsystems that have registered themselves. + * This can be used with get_system() to iterate through the entire list of + * available Panda subsystems. + */ size_t PandaSystem:: get_num_systems() const { return _systems.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_system -// Access: Published -// Description: Returns the nth Panda subsystem that has registered -// itself. This list will be sorted in alphabetical -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Panda subsystem that has registered itself. This list will + * be sorted in alphabetical order. + */ string PandaSystem:: get_system(size_t n) const { if (n >= _systems.size()) { @@ -374,19 +312,15 @@ get_system(size_t n) const { return _system_names[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_system_tag -// Access: Published -// Description: Returns the value associated with the indicated tag -// for the given system. This provides a standard way -// to query each subsystem's advertised capabilities. -// The set of tags and values are per-system and -// implementation-defined. -// -// The return value is the empty string if the indicated -// system is undefined or if does not define the -// indicated tag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the indicated tag for the given system. + * This provides a standard way to query each subsystem's advertised + * capabilities. The set of tags and values are per-system and + * implementation-defined. + * + * The return value is the empty string if the indicated system is undefined + * or if does not define the indicated tag. + */ string PandaSystem:: get_system_tag(const string &system, const string &tag) const { Systems::const_iterator si; @@ -403,12 +337,9 @@ get_system_tag(const string &system, const string &tag) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::add_system -// Access: Published -// Description: Intended for use by each subsystem to register itself -// at startup. -//////////////////////////////////////////////////////////////////// +/** + * Intended for use by each subsystem to register itself at startup. + */ void PandaSystem:: add_system(const string &system) { bool inserted = _systems.insert(Systems::value_type(system, SystemTags(get_class_type()))).second; @@ -417,12 +348,10 @@ add_system(const string &system) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::set_system_tag -// Access: Published -// Description: Intended for use by each subsystem to register its -// set of capabilities at startup. -//////////////////////////////////////////////////////////////////// +/** + * Intended for use by each subsystem to register its set of capabilities at + * startup. + */ void PandaSystem:: set_system_tag(const string &system, const string &tag, const string &value) { @@ -436,43 +365,34 @@ set_system_tag(const string &system, const string &tag, tags[tag] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::heap_trim -// Access: Published -// Description: Attempts to release memory back to the system, if -// possible. The pad argument is the minimum amount of -// unused memory to keep in the heap (against future -// allocations). Any memory above that may be released -// to the system, reducing the memory size of this -// process. There is no guarantee that any memory may -// be released. -// -// Returns true if any memory was actually released, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to release memory back to the system, if possible. The pad + * argument is the minimum amount of unused memory to keep in the heap + * (against future allocations). Any memory above that may be released to the + * system, reducing the memory size of this process. There is no guarantee + * that any memory may be released. + * + * Returns true if any memory was actually released, false otherwise. + */ bool PandaSystem:: heap_trim(size_t pad) { - // This actually just vectors into _memory_hook, which isn't - // published. This method only exists on PandaSystem for the - // convenience of Python programmers. + // This actually just vectors into _memory_hook, which isn't published. + // This method only exists on PandaSystem for the convenience of Python + // programmers. return memory_hook->heap_trim(pad); } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaSystem:: output(ostream &out) const { out << "Panda version " << get_version_string(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaSystem:: write(ostream &out) const { out << *this << "\n" @@ -494,11 +414,9 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::get_global_ptr -// Access: Published, Static -// Description: Returns the global PandaSystem object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global PandaSystem object. + */ PandaSystem *PandaSystem:: get_global_ptr() { if (_global_ptr == (PandaSystem *)NULL) { @@ -508,13 +426,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::reset_system_names -// Access: Private -// Description: Refills the _system_names vector, which is used for -// get_system_name(), from the current set of available -// system names. -//////////////////////////////////////////////////////////////////// +/** + * Refills the _system_names vector, which is used for get_system_name(), from + * the current set of available system names. + */ void PandaSystem:: reset_system_names() { _system_names.clear(); @@ -528,18 +443,13 @@ reset_system_names() { _system_names_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::set_package_version_string -// Access: Private -// Description: Loads the value returned by -// get_package_version_string(). This is intended to be -// called by ConfigPageManager to preload the value from -// the panda-package-version config variable, for -// developer's convenience. This has no effect if the -// PANDA_PACKAGE_VERSION_STR configure variable is -// defined at compilation time. This also has no effect -// in NDEBUG mode. -//////////////////////////////////////////////////////////////////// +/** + * Loads the value returned by get_package_version_string(). This is intended + * to be called by ConfigPageManager to preload the value from the panda- + * package-version config variable, for developer's convenience. This has no + * effect if the PANDA_PACKAGE_VERSION_STR configure variable is defined at + * compilation time. This also has no effect in NDEBUG mode. + */ void PandaSystem:: set_package_version_string(const string &package_version_string) { _package_version_string = PANDA_PACKAGE_VERSION_STR; @@ -548,18 +458,13 @@ set_package_version_string(const string &package_version_string) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaSystem::set_package_host_url -// Access: Private -// Description: Loads the value returned by -// get_package_host_url(). This is intended to be -// called by ConfigPageManager to preload the value from -// the panda-package-host-url config variable, for -// developer's convenience. This has no effect if the -// PANDA_PACKAGE_HOST_URL configure variable is defined -// at compilation time. This also has no effect in -// NDEBUG mode. -//////////////////////////////////////////////////////////////////// +/** + * Loads the value returned by get_package_host_url(). This is intended to be + * called by ConfigPageManager to preload the value from the panda-package- + * host-url config variable, for developer's convenience. This has no effect + * if the PANDA_PACKAGE_HOST_URL configure variable is defined at compilation + * time. This also has no effect in NDEBUG mode. + */ void PandaSystem:: set_package_host_url(const string &package_host_url) { _package_host_url = PANDA_PACKAGE_HOST_URL; diff --git a/dtool/src/dtoolutil/pandaSystem.h b/dtool/src/dtoolutil/pandaSystem.h index 2f100414fa..a401440b6b 100644 --- a/dtool/src/dtoolutil/pandaSystem.h +++ b/dtool/src/dtoolutil/pandaSystem.h @@ -1,16 +1,15 @@ -// Filename: pandaSystem.h -// Created by: drose (26Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaSystem.h + * @author drose + * @date 2005-01-26 + */ #ifndef PANDASYSTEM_H #define PANDASYSTEM_H @@ -19,13 +18,11 @@ #include "pmap.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : PandaSystem -// Description : This class is used as a namespace to group several -// global properties of Panda. Application developers -// can use this class to query the runtime version or -// capabilities of the current Panda environment. -//////////////////////////////////////////////////////////////////// +/** + * This class is used as a namespace to group several global properties of + * Panda. Application developers can use this class to query the runtime + * version or capabilities of the current Panda environment. + */ class EXPCL_DTOOL PandaSystem { protected: PandaSystem(); @@ -106,5 +103,3 @@ inline ostream &operator << (ostream &out, const PandaSystem &ps) { } #endif - - diff --git a/dtool/src/dtoolutil/panda_getopt.h b/dtool/src/dtoolutil/panda_getopt.h index a2c50cfb47..2d05ae557b 100644 --- a/dtool/src/dtoolutil/panda_getopt.h +++ b/dtool/src/dtoolutil/panda_getopt.h @@ -1,8 +1,4 @@ -/* Filename: panda_getopt.h - * Created by: drose (19Jul11) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file panda_getopt.h + * @author drose + * @date 2011-07-19 + */ #ifndef PANDA_GETOPT_H #define PANDA_GETOPT_H @@ -30,4 +29,3 @@ #endif #endif - diff --git a/dtool/src/dtoolutil/panda_getopt_impl.cxx b/dtool/src/dtoolutil/panda_getopt_impl.cxx index 716983ee71..fe1d630a32 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.cxx +++ b/dtool/src/dtoolutil/panda_getopt_impl.cxx @@ -1,28 +1,26 @@ -// Filename: panda_getopt_impl.cxx -// Created by: drose (19Jul11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file panda_getopt_impl.cxx + * @author drose + * @date 2011-07-19 + */ #include "panda_getopt_impl.h" #include "pvector.h" #if defined(HAVE_GETOPT) && defined(HAVE_GETOPT_LONG_ONLY) -// If the system provides both of these functions, we don't need to -// provide our own implementation, so in that case this file does -// nothing. +// If the system provides both of these functions, we don't need to provide +// our own implementation, so in that case this file does nothing. #else -// If the system does lack one or the other of these functions, then -// we'll go ahead and provide it instead. +// If the system does lack one or the other of these functions, then we'll go +// ahead and provide it instead. char *optarg = NULL; @@ -30,13 +28,11 @@ int optind = 0; int opterr = 1; int optopt = 0; -//////////////////////////////////////////////////////////////////// -// Class : PandaGetopt -// Description : The implementation within this file of the various -// getopt() functions. This class is not visible -// outside of this file; instead, the interface is via -// the getopt() functions themselves. -//////////////////////////////////////////////////////////////////// +/** + * The implementation within this file of the various getopt() functions. + * This class is not visible outside of this file; instead, the interface is + * via the getopt() functions themselves. + */ class PandaGetopt { public: PandaGetopt(int argc, char *const argv[], const char *optstring, @@ -52,11 +48,10 @@ private: void scan_options(const char *optstring, const struct option *longopts); void scan_args(int argc, char *const argv[]); - // We build a list of Options, which correspond to the input defined - // in optstring and/or in the longopts list. These are the short - // and long options that are available, whether or not the user - // tries to use any of them. This list is populated by - // scan_options(). + // We build a list of Options, which correspond to the input defined in + // optstring andor in the longopts list. These are the short and long + // options that are available, whether or not the user tries to use any of + // them. This list is populated by scan_options(). class Option { public: Option(char short_option, int has_arg); @@ -69,15 +64,14 @@ private: int _longopts_index; }; - // We next build a list of Params, which are the parameter options - // that are parsed out of the argv array--those options that the - // user has actually specified. This list does not contain the - // non-option arguments, the words that follow the options on the - // command line (those end up in the _arguments list instead). This - // list is populated by scan_args(). + // We next build a list of Params, which are the parameter options that are + // parsed out of the argv array--those options that the user has actually + // specified. This list does not contain the non-option arguments, the + // words that follow the options on the command line (those end up in the + // _arguments list instead). This list is populated by scan_args(). class Param { public: - Param(size_t opt_index, size_t argv_index, + Param(size_t opt_index, size_t argv_index, char short_option, char *argument = NULL); size_t _opt_index; @@ -96,47 +90,42 @@ private: typedef pvector Arguments; - // The list of option arguments on the command line, with pointers - // back into the original argv array. This is similar to the - // _params list, above, but it is the pointers to the original - // unprocessed strings. We use this list to premute the argv array - // into proper order if needed. + // The list of option arguments on the command line, with pointers back into + // the original argv array. This is similar to the _params list, above, but + // it is the pointers to the original unprocessed strings. We use this list + // to premute the argv array into proper order if needed. Arguments _output_argv; - // The list of non-option arguments on the command line, following - // the options. The vector contains the actual pointers back into - // the original argv array; we use it to permute the argv array into - // proper order if needed. + // The list of non-option arguments on the command line, following the + // options. The vector contains the actual pointers back into the original + // argv array; we use it to permute the argv array into proper order if + // needed. Arguments _arguments; - // See the PandaGetopt constructor for an explanation of these - // two flags. + // See the PandaGetopt constructor for an explanation of these two flags. bool _return_in_order; bool _require_order; - // If we are invoked via getopt_long_only(), then a single hyphen is - // allowed to introduce a long option, as well as a double hyphen. + // If we are invoked via getopt_long_only(), then a single hyphen is allowed + // to introduce a long option, as well as a double hyphen. bool _allow_one_hyphen_long; - // This member is used to hold our place in the parameters list - // across multiple calls to process(). + // This member is used to hold our place in the parameters list across + // multiple calls to process(). size_t _next_param; - // This is the index of the first non-option argument in the argv - // list. It's filled into optind when process() reaches the end of - // its processing. + // This is the index of the first non-option argument in the argv list. + // It's filled into optind when process() reaches the end of its processing. size_t _next_argv_index; }; -// This global pointer is used to differentiate between getopt() being -// called the first time, vs. subsequent times. +// This global pointer is used to differentiate between getopt() being called +// the first time, vs. subsequent times. static PandaGetopt *pgetopt = NULL; -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaGetopt:: PandaGetopt(int argc, char *const argv[], const char *optstring, const struct option *longopts, bool allow_one_hyphen_long) { @@ -151,9 +140,8 @@ PandaGetopt(int argc, char *const argv[], const char *optstring, _options.push_back(Option('?', no_argument)); if (optstring[0] == '-') { - // RETURN_IN_ORDER: Non-option arguments (operands) are handled as - // if they were the argument to an option with the value 1 - // ('\001'). + // RETURN_IN_ORDER: Non-option arguments (operands) are handled as if they + // were the argument to an option with the value 1 ('\001'). ++optstring; _return_in_order = true; @@ -161,9 +149,8 @@ PandaGetopt(int argc, char *const argv[], const char *optstring, _options.push_back(Option('\001', required_argument)); } else if (optstring[0] == '+') { - // REQUIRE_ORDER: option processing stops when the first - // non-option argument is reached, or when the element of argv is - // "--". + // REQUIRE_ORDER: option processing stops when the first non-option + // argument is reached, or when the element of argv is "--". ++optstring; _require_order = true; @@ -172,23 +159,18 @@ PandaGetopt(int argc, char *const argv[], const char *optstring, _require_order = true; } else { - // PERMUTE: the order of arguments in argv is altered so that all - // options (and their arguments) are moved in front of all of the - // operands. + // PERMUTE: the order of arguments in argv is altered so that all options + // (and their arguments) are moved in front of all of the operands. } scan_options(optstring, longopts); scan_args(argc, argv); } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::permute -// Access: Public -// Description: Permutes the argv array so that the non-option -// arguments are at the end of the list (if -// POSIXLY_CORRECT is not set), as the gnu -// implementation does. -//////////////////////////////////////////////////////////////////// +/** + * Permutes the argv array so that the non-option arguments are at the end of + * the list (if POSIXLY_CORRECT is not set), as the gnu implementation does. + */ void PandaGetopt:: permute(int argc, char **mutable_argv) { if (!_require_order && !_return_in_order) { @@ -210,14 +192,11 @@ permute(int argc, char **mutable_argv) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::process -// Access: Public -// Description: Can be called repeatedly to extract out the option -// arguments scanned from the argv list, one at a time. -// Sets *longindex, optarg, optind, optopt. -// Returns EOF when finished. -//////////////////////////////////////////////////////////////////// +/** + * Can be called repeatedly to extract out the option arguments scanned from + * the argv list, one at a time. Sets *longindex, optarg, optind, optopt. + * Returns EOF when finished. + */ int PandaGetopt:: process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { if (_next_param >= _params.size()) { @@ -236,8 +215,7 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { } if (option._option != NULL) { - // This was a long option. Check the special longopt handling - // parameters. + // This was a long option. Check the special longopt handling parameters. if (option._option->flag == NULL) { return option._option->val; } @@ -256,13 +234,10 @@ process(int opterr, int *longindex, char *&optarg, int &optind, int &optopt) { return param._short_option; } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::find_short_option -// Access: Private -// Description: Returns the index within the _options array of the -// option with the indicated short_option letter, or 0 -// if the option is not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index within the _options array of the option with the + * indicated short_option letter, or 0 if the option is not found. + */ size_t PandaGetopt:: find_short_option(char short_option) { size_t opt_index = 1; @@ -276,15 +251,11 @@ find_short_option(char short_option) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::find_long_option -// Access: Private -// Description: Returns the index within the _options array of the -// option with the indicated long_option word, or 0 -// if the option is not found. If the word contains an -// '=' sign, only the text before this sign is -// considered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index within the _options array of the option with the + * indicated long_option word, or 0 if the option is not found. If the word + * contains an '=' sign, only the text before this sign is considered. + */ size_t PandaGetopt:: find_long_option(const string &long_option) { string search = long_option; @@ -304,13 +275,10 @@ find_long_option(const string &long_option) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::scan_options -// Access: Private -// Description: Parses the optstring and longopts list to understand -// the options we should be searching for, and populate -// the internal _options array. -//////////////////////////////////////////////////////////////////// +/** + * Parses the optstring and longopts list to understand the options we should + * be searching for, and populate the internal _options array. + */ void PandaGetopt:: scan_options(const char *optstring, const struct option *longopts) { const char *p = optstring; @@ -326,7 +294,7 @@ scan_options(const char *optstring, const struct option *longopts) { ++p; } } - + _options.push_back(Option(short_option, has_arg)); } @@ -339,13 +307,10 @@ scan_options(const char *optstring, const struct option *longopts) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::scan_args -// Access: Private -// Description: Parses the argv list to understand the arguments -// passed by the user, and populates the _params and -// _arguments arrays. -//////////////////////////////////////////////////////////////////// +/** + * Parses the argv list to understand the arguments passed by the user, and + * populates the _params and _arguments arrays. + */ void PandaGetopt:: scan_args(int argc, char *const argv[]) { size_t ai = 1; @@ -369,8 +334,8 @@ scan_args(int argc, char *const argv[]) { } } else if (strcmp(argv[ai], "--") == 0) { - // Special case: this ends processing. Everything after this - // is a non-option argument. + // Special case: this ends processing. Everything after this is a non- + // option argument. _output_argv.push_back(argv[ai]); end_of_processing = true; @@ -389,8 +354,8 @@ scan_args(int argc, char *const argv[]) { opt_index = find_long_option(option); is_long_option = true; } else { - // This is one or more short options, or a short option and - // its argument. + // This is one or more short options, or a short option and its + // argument. option = argv[ai] + 1; if (_allow_one_hyphen_long) { // Or maybe it's a long option. @@ -401,8 +366,8 @@ scan_args(int argc, char *const argv[]) { } if (!is_long_option) { opt_index = find_short_option(option[0]); - while (opt_index != 0 && - _options[opt_index]._has_arg == no_argument && + while (opt_index != 0 && + _options[opt_index]._has_arg == no_argument && option[1] != '\0') { // There are multiple short options jammed into a single word. _params.push_back(Param(opt_index, ai, option[0])); @@ -430,7 +395,7 @@ scan_args(int argc, char *const argv[]) { size_t argv_index = ai; - if (opt_index != 0 && _options[opt_index]._has_arg == required_argument && + if (opt_index != 0 && _options[opt_index]._has_arg == required_argument && !has_argument) { // Check the next word for an argument. _output_argv.push_back(argv[ai]); @@ -457,13 +422,10 @@ scan_args(int argc, char *const argv[]) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::Option::Constructor -// Access: Public -// Description: The constructor for a short_option. Receives the -// letter that is the short option, and one of -// no_argument, required_argument, or optional_argument. -//////////////////////////////////////////////////////////////////// +/** + * The constructor for a short_option. Receives the letter that is the short + * option, and one of no_argument, required_argument, or optional_argument. + */ PandaGetopt::Option:: Option(char short_option, int has_arg) : _short_option(short_option), @@ -473,13 +435,10 @@ Option(char short_option, int has_arg) : { } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::Option::Constructor -// Access: Public -// Description: The constructor for a long_option. Receives the -// longopts array and the index within the array for -// this particular option. -//////////////////////////////////////////////////////////////////// +/** + * The constructor for a long_option. Receives the longopts array and the + * index within the array for this particular option. + */ PandaGetopt::Option:: Option(const struct option *longopts, int longopts_index) : _short_option(0), @@ -490,11 +449,9 @@ Option(const struct option *longopts, int longopts_index) : { } -//////////////////////////////////////////////////////////////////// -// Function: PandaGetopt::Param::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaGetopt::Param:: Param(size_t opt_index, size_t argv_index, char short_option, char *argument) : _opt_index(opt_index), @@ -514,7 +471,7 @@ getopt(int argc, char *const argv[], const char *optstring) { } int -getopt_long(int argc, char *const argv[], const char *optstring, +getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { if (pgetopt == NULL) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, false); @@ -524,7 +481,7 @@ getopt_long(int argc, char *const argv[], const char *optstring, } int -getopt_long_only(int argc, char *const argv[], const char *optstring, +getopt_long_only(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex) { if (pgetopt == NULL) { pgetopt = new PandaGetopt(argc, argv, optstring, longopts, true); diff --git a/dtool/src/dtoolutil/panda_getopt_impl.h b/dtool/src/dtoolutil/panda_getopt_impl.h index ec662d6b9e..9544f68187 100644 --- a/dtool/src/dtoolutil/panda_getopt_impl.h +++ b/dtool/src/dtoolutil/panda_getopt_impl.h @@ -1,8 +1,4 @@ -/* Filename: panda_getopt_impl.h - * Created by: drose (19Jul11) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file panda_getopt_impl.h + * @author drose + * @date 2011-07-19 + */ #ifndef PANDA_GETOPT_IMPL_H #define PANDA_GETOPT_IMPL_H @@ -22,13 +21,12 @@ It is completely new code, contributed under the Panda3D license. */ #if defined(HAVE_GETOPT) && defined(HAVE_GETOPT_LONG_ONLY) -// If the system provides both of these functions, we don't need to -// provide our own implementation, so in that case this file does -// nothing. +// If the system provides both of these functions, we don't need to provide +// our own implementation, so in that case this file does nothing. #else -// If the system does lack one or the other of these functions, then -// we'll go ahead and provide it instead. +// If the system does lack one or the other of these functions, then we'll go +// ahead and provide it instead. #define getopt panda_getopt #define optind panda_optind @@ -59,10 +57,10 @@ struct option { extern EXPCL_DTOOL int getopt(int argc, char *const argv[], const char *optstring); extern EXPCL_DTOOL int -getopt_long(int argc, char *const argv[], const char *optstring, +getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex); extern EXPCL_DTOOL int -getopt_long_only(int argc, char *const argv[], const char *optstring, +getopt_long_only(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex); #ifdef __cplusplus diff --git a/dtool/src/dtoolutil/panda_getopt_long.h b/dtool/src/dtoolutil/panda_getopt_long.h index 7b37b14aec..9f788fcf33 100644 --- a/dtool/src/dtoolutil/panda_getopt_long.h +++ b/dtool/src/dtoolutil/panda_getopt_long.h @@ -1,8 +1,4 @@ -/* Filename: panda_getopt.h - * Created by: drose (19Jul11) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file panda_getopt_long.h + * @author drose + * @date 2011-07-19 + */ #ifndef PANDA_GETOPT_LONG_H #define PANDA_GETOPT_LONG_H @@ -32,4 +31,3 @@ #endif #endif - diff --git a/dtool/src/dtoolutil/pfstream.I b/dtool/src/dtoolutil/pfstream.I index ca57e8decf..c72a433453 100644 --- a/dtool/src/dtoolutil/pfstream.I +++ b/dtool/src/dtoolutil/pfstream.I @@ -1,16 +1,15 @@ -// Filename: pfstream.I -// Created by: cary (12Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfstream.I + * @author cary + * @date 2000-12-12 + */ INLINE IPipeStream::IPipeStream(const std::string cmd) : istream(&_psb), _psb(PipeStreamBuf::Input) { diff --git a/dtool/src/dtoolutil/pfstream.cxx b/dtool/src/dtoolutil/pfstream.cxx index 047918ad0e..3b230b27f0 100644 --- a/dtool/src/dtoolutil/pfstream.cxx +++ b/dtool/src/dtoolutil/pfstream.cxx @@ -1,16 +1,15 @@ -// Filename: pfstream.cxx -// Created by: cary (09Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfstream.cxx + * @author cary + * @date 2001-01-09 + */ #include "pfstream.h" diff --git a/dtool/src/dtoolutil/pfstream.h b/dtool/src/dtoolutil/pfstream.h index fb6d29f0aa..b7565c1c64 100644 --- a/dtool/src/dtoolutil/pfstream.h +++ b/dtool/src/dtoolutil/pfstream.h @@ -1,16 +1,15 @@ -// Filename: pfstream.h -// Created by: cary (27Aug98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfstream.h + * @author cary + * @date 1998-08-27 + */ #ifndef __PFSTREAM_H__ #define __PFSTREAM_H__ @@ -52,5 +51,3 @@ private: #include "pfstream.I" #endif /* __PFSTREAM_H__ */ - - diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index fc0de36048..b97a4691b0 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -1,28 +1,27 @@ -// Filename: pfstreamBuf.cxx -// Created by: cary (12Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfstreamBuf.cxx + * @author cary + * @date 2000-12-12 + */ #include "pfstreamBuf.h" #include -PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : +PipeStreamBuf::PipeStreamBuf(PipeStreamBuf::Direction dir) : _dir(dir) { init_pipe(); #ifndef PHAVE_IOSTREAM - // These lines, which are essential on older implementations of the - // iostream library, are not understood by more recent versions. + // These lines, which are essential on older implementations of the iostream + // library, are not understood by more recent versions. allocate(); assert((dir == Input) || (dir == Output)); if (dir == Input) { @@ -157,50 +156,39 @@ void PipeStreamBuf::write_chars(const char* start, int length, bool flush) { #ifndef WIN_PIPE_CALLS -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::init_pipe -// Access: Private -// Description: Initializes whatever data structures store the child -// process information. This function is only called -// once at startup, by the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Initializes whatever data structures store the child process information. + * This function is only called once at startup, by the constructor. + */ void PipeStreamBuf:: init_pipe() { _pipe = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::is_open -// Access: Private -// Description: Returns true if the pipe has been opened, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pipe has been opened, false otherwise. + */ bool PipeStreamBuf:: is_open() const { return _pipe != NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::eof_pipe -// Access: Private -// Description: Returns true if there is an end-of-file condition on -// the input, or if the pipe was never opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an end-of-file condition on the input, or if the + * pipe was never opened. + */ bool PipeStreamBuf:: eof_pipe() const { return (_pipe == NULL) && feof(_pipe); } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::open_pipe -// Access: Private -// Description: Forks a child to run the indicated command, and -// according to the setting of _dir, binds either its -// input or output to this process for writing or -// reading. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Forks a child to run the indicated command, and according to the setting of + * _dir, binds either its input or output to this process for writing or + * reading. + * + * Returns true on success, false on failure. + */ bool PipeStreamBuf:: open_pipe(const string &cmd) { const char *typ = (_dir == Output)?"w":"r"; @@ -208,11 +196,9 @@ open_pipe(const string &cmd) { return (_pipe != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::close_pipe -// Access: Private -// Description: Closes the pipe opened previously. -//////////////////////////////////////////////////////////////////// +/** + * Closes the pipe opened previously. + */ void PipeStreamBuf:: close_pipe() { if (_pipe != NULL) { @@ -221,12 +207,10 @@ close_pipe() { } } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::write_pipe -// Access: Private -// Description: Writes the indicated data out to the child process -// opened previously. Returns the number of bytes read. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated data out to the child process opened previously. + * Returns the number of bytes read. + */ size_t PipeStreamBuf:: write_pipe(const char *data, size_t len) { size_t wrote_count = fwrite(data, 1, len, _pipe); @@ -234,13 +218,10 @@ write_pipe(const char *data, size_t len) { return wrote_count; } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::read_pipe -// Access: Private -// Description: Reads the indicated amount of data from the child -// process opened previously. Returns the number of -// bytes read. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated amount of data from the child process opened + * previously. Returns the number of bytes read. + */ size_t PipeStreamBuf:: read_pipe(char *data, size_t len) { return fread(data, 1, len, _pipe); @@ -248,86 +229,74 @@ read_pipe(char *data, size_t len) { #else // WIN_PIPE_CALLS -// The official Windows way of reading from a child process, without -// using a Unix-style convenience function like popen(), is similar in -// principle to the Unix pipe() method. We have to first redirect our -// own stdout to an anonymous pipe, then we spawn a child, who -// inherits this new stdout. Then we can restore our own stdout, and -// read from the other end of the pipe. +// The official Windows way of reading from a child process, without using a +// Unix-style convenience function like popen(), is similar in principle to +// the Unix pipe() method. We have to first redirect our own stdout to an +// anonymous pipe, then we spawn a child, who inherits this new stdout. Then +// we can restore our own stdout, and read from the other end of the pipe. -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::init_pipe -// Access: Private -// Description: Initializes whatever data structures store the child -// process information. This function is only called -// once at startup, by the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Initializes whatever data structures store the child process information. + * This function is only called once at startup, by the constructor. + */ void PipeStreamBuf:: init_pipe() { _child_out = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::is_open -// Access: Private -// Description: Returns true if the pipe has been opened, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pipe has been opened, false otherwise. + */ bool PipeStreamBuf:: is_open() const { return (_child_out != 0); } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::eof_pipe -// Access: Private -// Description: Returns true if there is an end-of-file condition on -// the input, or if the pipe was never opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an end-of-file condition on the input, or if the + * pipe was never opened. + */ bool PipeStreamBuf:: eof_pipe() const { return (_child_out == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::open_pipe -// Access: Private -// Description: Forks a child to run the indicated command, and -// according to the setting of _dir, binds either its -// input or output to this process for writing or -// reading. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Forks a child to run the indicated command, and according to the setting of + * _dir, binds either its input or output to this process for writing or + * reading. + * + * Returns true on success, false on failure. + */ bool PipeStreamBuf:: open_pipe(const string &cmd) { close_pipe(); - // At the present, this only works for input pipes. We can add code - // to support output pipes later if anyone cares. + // At the present, this only works for input pipes. We can add code to + // support output pipes later if anyone cares. if (_dir == Output) { return false; } - // First, save our current stdout, so we can restore it after all of - // this nonsense. - HANDLE hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); - + // First, save our current stdout, so we can restore it after all of this + // nonsense. + HANDLE hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); + // Now create a pipe to accept the child processes' output. HANDLE hChildStdoutRd, hChildStdoutWr; - - // Set the bInheritHandle flag so pipe handles are inherited. - SECURITY_ATTRIBUTES saAttr; - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; + + // Set the bInheritHandle flag so pipe handles are inherited. + SECURITY_ATTRIBUTES saAttr; + saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); + saAttr.bInheritHandle = TRUE; + saAttr.lpSecurityDescriptor = NULL; if (!CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) { #ifndef NDEBUG cerr << "Unable to create output pipe\n"; #endif return false; } - + // Remap stdout to the "write" end of this pipe. if (!SetStdHandle(STD_OUTPUT_HANDLE, hChildStdoutWr)) { #ifndef NDEBUG @@ -337,14 +306,13 @@ open_pipe(const string &cmd) { CloseHandle(hChildStdoutWr); return false; } - - // Create noninheritable read handle and close the inheritable read - // handle. + + // Create noninheritable read handle and close the inheritable read handle. BOOL fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd, GetCurrentProcess(), &_child_out, 0, FALSE, DUPLICATE_SAME_ACCESS); - + if (!fSuccess) { #ifndef NDEBUG cerr << "DuplicateHandle failed\n"; @@ -354,18 +322,17 @@ open_pipe(const string &cmd) { return false; } CloseHandle(hChildStdoutRd); - + // Now spawn the child process. - - // Both WinExec() and CreateProcess() want a non-const char pointer. - // Maybe they change it, and maybe they don't. I'm not taking - // chances. + + // Both WinExec() and CreateProcess() want a non-const char pointer. Maybe + // they change it, and maybe they don't. I'm not taking chances. char *cmdline = new char[cmd.length() + 1]; strcpy(cmdline, cmd.c_str()); - // We should be using CreateProcess() instead of WinExec(), but that - // seems to be likely to crash Win98. WinExec() seems better - // behaved, and it's all we need anyway. + // We should be using CreateProcess() instead of WinExec(), but that seems + // to be likely to crash Win98. WinExec() seems better behaved, and it's + // all we need anyway. if (!WinExec(cmdline, 0)) { #ifndef NDEBUG cerr << "Unable to spawn process.\n"; @@ -375,7 +342,7 @@ open_pipe(const string &cmd) { } delete[] cmdline; - + // Now restore our own stdout, up here in the parent process. if (!SetStdHandle(STD_OUTPUT_HANDLE, hSaveStdout)) { #ifndef NDEBUG @@ -383,8 +350,8 @@ open_pipe(const string &cmd) { #endif } - // Close the write end of the pipe before reading from the - // read end of the pipe. + // Close the write end of the pipe before reading from the read end of the + // pipe. if (!CloseHandle(hChildStdoutWr)) { #ifndef NDEBUG cerr << "Unable to close write end of pipe\n"; @@ -394,11 +361,9 @@ open_pipe(const string &cmd) { return (_child_out != 0); } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::close_pipe -// Access: Private -// Description: Closes the pipe opened previously. -//////////////////////////////////////////////////////////////////// +/** + * Closes the pipe opened previously. + */ void PipeStreamBuf:: close_pipe() { if (_child_out != 0) { @@ -407,30 +372,25 @@ close_pipe() { } } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::write_pipe -// Access: Private -// Description: Writes the indicated data out to the child process -// opened previously. Returns the number of bytes read. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated data out to the child process opened previously. + * Returns the number of bytes read. + */ size_t PipeStreamBuf:: write_pipe(const char *data, size_t len) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipeStreamBuf::read_pipe -// Access: Private -// Description: Reads the indicated amount of data from the child -// process opened previously. Returns the number of -// bytes read. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated amount of data from the child process opened + * previously. Returns the number of bytes read. + */ size_t PipeStreamBuf:: read_pipe(char *data, size_t len) { if (_child_out == 0) { return 0; } - DWORD dwRead; + DWORD dwRead; if (!ReadFile(_child_out, data, len, &dwRead, NULL)) { close_pipe(); return 0; diff --git a/dtool/src/dtoolutil/pfstreamBuf.h b/dtool/src/dtoolutil/pfstreamBuf.h index 5e35723997..3fbf055eae 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.h +++ b/dtool/src/dtoolutil/pfstreamBuf.h @@ -1,16 +1,15 @@ -// Filename: pfstreamBuf.h -// Created by: cary (12Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfstreamBuf.h + * @author cary + * @date 2000-12-12 + */ #ifndef __PFSTREAMBUF_H__ #define __PFSTREAMBUF_H__ @@ -20,9 +19,9 @@ #include // By default, we'll use the Windows flavor of pipe functions if we're -// compiling under Windows. Turn this off to use popen(), even on -// Windows. (popen() doesn't seem to work on Win9x, although it does -// work on NT-based variants.) +// compiling under Windows. Turn this off to use popen(), even on Windows. +// (popen() doesn't seem to work on Win9x, although it does work on NT-based +// variants.) #ifdef WIN32_VC #define WIN_PIPE_CALLS 1 #endif diff --git a/dtool/src/dtoolutil/preprocess_argv.cxx b/dtool/src/dtoolutil/preprocess_argv.cxx index 26f4899e7b..5b5b544ff3 100644 --- a/dtool/src/dtoolutil/preprocess_argv.cxx +++ b/dtool/src/dtoolutil/preprocess_argv.cxx @@ -1,36 +1,31 @@ -// Filename: preprocess_argv.cxx -// Created by: drose (08Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file preprocess_argv.cxx + * @author drose + * @date 2011-11-08 + */ #include "preprocess_argv.h" #include "win32ArgParser.h" -//////////////////////////////////////////////////////////////////// -// Function: preprocess_argv -// Description: Processes the argc, argv pair as needed before -// passing it to getopt(). If this program is running -// on Windows, but not within Cygwin, this ignores the -// incoming argv, argv values, replacing them from the -// GetCommandLine() string, and expanding glob patterns -// like *.egg to a list of all matching egg files. On -// other platforms, this function does nothing and -// returns argc, argv unchanged. -// -// The argc and argv values are modified by this -// function, if necessary, to point to -// statically-allocated memory that will be valid until -// the next call to preprocess_argv(). -//////////////////////////////////////////////////////////////////// +/** + * Processes the argc, argv pair as needed before passing it to getopt(). If + * this program is running on Windows, but not within Cygwin, this ignores the + * incoming argv, argv values, replacing them from the GetCommandLine() + * string, and expanding glob patterns like *.egg to a list of all matching + * egg files. On other platforms, this function does nothing and returns + * argc, argv unchanged. + * + * The argc and argv values are modified by this function, if necessary, to + * point to statically-allocated memory that will be valid until the next call + * to preprocess_argv(). + */ void preprocess_argv(int &argc, char **&argv) { #ifndef _WIN32 diff --git a/dtool/src/dtoolutil/preprocess_argv.h b/dtool/src/dtoolutil/preprocess_argv.h index 9c63161d17..6323c50c05 100644 --- a/dtool/src/dtoolutil/preprocess_argv.h +++ b/dtool/src/dtoolutil/preprocess_argv.h @@ -1,16 +1,15 @@ -// Filename: preprocess_argv.h -// Created by: drose (08Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file preprocess_argv.h + * @author drose + * @date 2011-11-08 + */ #ifndef PREPROCESS_ARGV_H #define PREPROCESS_ARGV_H @@ -21,4 +20,3 @@ extern EXPCL_DTOOL void preprocess_argv(int &argc, char **&argv); #endif - diff --git a/dtool/src/dtoolutil/stringDecoder.I b/dtool/src/dtoolutil/stringDecoder.I index c85d9b6090..8ac51f52c6 100644 --- a/dtool/src/dtoolutil/stringDecoder.I +++ b/dtool/src/dtoolutil/stringDecoder.I @@ -1,47 +1,38 @@ -// Filename: stringDecoder.I -// Created by: drose (11Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringDecoder.I + * @author drose + * @date 2002-02-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StringDecoder:: StringDecoder(const string &input) : _input(input) { _p = 0; _eof = false; } -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::is_eof -// Access: Public -// Description: Returns true if the decoder has returned the last -// character in the string, false if there are more to -// go. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the decoder has returned the last character in the string, + * false if there are more to go. + */ INLINE bool StringDecoder:: is_eof() { return _eof; } -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::test_eof -// Access: Protected -// Description: If the pointer is past the last character of the -// string, set the eof flag and return true. -//////////////////////////////////////////////////////////////////// +/** + * If the pointer is past the last character of the string, set the eof flag + * and return true. + */ INLINE bool StringDecoder:: test_eof() { if (_p >= _input.size()) { @@ -51,20 +42,16 @@ test_eof() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: StringUtf8Decoder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StringUtf8Decoder:: StringUtf8Decoder(const string &input) : StringDecoder(input) { } -//////////////////////////////////////////////////////////////////// -// Function: StringUnicodeDecoder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StringUnicodeDecoder:: StringUnicodeDecoder(const string &input) : StringDecoder(input) { } diff --git a/dtool/src/dtoolutil/stringDecoder.cxx b/dtool/src/dtoolutil/stringDecoder.cxx index 89d7b359fc..ce73120543 100644 --- a/dtool/src/dtoolutil/stringDecoder.cxx +++ b/dtool/src/dtoolutil/stringDecoder.cxx @@ -1,36 +1,31 @@ -// Filename: stringDecoder.cxx -// Created by: drose (11Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringDecoder.cxx + * @author drose + * @date 2002-02-11 + */ #include "stringDecoder.h" #include "config_dtoolutil.h" ostream *StringDecoder::_notify_ptr = &cerr; -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StringDecoder:: ~StringDecoder() { } -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::get_next_character -// Access: Public, Virtual -// Description: Returns the next character in sequence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next character in sequence. + */ int StringDecoder:: get_next_character() { if (test_eof()) { @@ -39,26 +34,21 @@ get_next_character() { return (unsigned char)_input[_p++]; } -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::set_notify_ptr -// Access: Public, Static -// Description: Sets the ostream that is used to write error messages -// to. This is necessary because of the low-level -// placement of this class, before the definition of the -// NotifyCategory class, so it cannot specify its own -// notify. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ostream that is used to write error messages to. This is + * necessary because of the low-level placement of this class, before the + * definition of the NotifyCategory class, so it cannot specify its own + * notify. + */ void StringDecoder:: set_notify_ptr(ostream *notify_ptr) { _notify_ptr = notify_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: StringDecoder::get_notify_ptr -// Access: Public, Static -// Description: Returns the ostream that is used to write error messages -// to. See set_notify_ptr(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the ostream that is used to write error messages to. See + * set_notify_ptr(). + */ ostream *StringDecoder:: get_notify_ptr() { return _notify_ptr; @@ -89,11 +79,9 @@ The value of each individual byte indicates its UTF-8 function, as follows: E0 to EF hex (224 to 239): first byte of a three-byte sequence. */ -//////////////////////////////////////////////////////////////////// -// Function: StringUtf8Decoder::get_next_character -// Access: Public, Virtual -// Description: Returns the next character in sequence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next character in sequence. + */ int StringUtf8Decoder:: get_next_character() { unsigned int result; @@ -116,7 +104,7 @@ get_next_character() { two = (unsigned char)_input[_p++]; result = ((result & 0x1f) << 6) | (two & 0x3f); return result; - + } else if ((result & 0xf0) == 0xe0) { // First byte of three. if (test_eof()) { @@ -139,8 +127,8 @@ get_next_character() { return result; } - // Otherwise--the high bit is set but it is not one of the - // introductory utf-8 bytes--we have an error. + // Otherwise--the high bit is set but it is not one of the introductory + // utf-8 bytes--we have an error. if (_notify_ptr != NULL) { (*_notify_ptr) << "Non utf-8 byte in string: 0x" << hex << result << dec @@ -153,11 +141,9 @@ get_next_character() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: StringUnicodeDecoder::get_next_character -// Access: Public, Virtual -// Description: Returns the next character in sequence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next character in sequence. + */ int StringUnicodeDecoder:: get_next_character() { if (test_eof()) { diff --git a/dtool/src/dtoolutil/stringDecoder.h b/dtool/src/dtoolutil/stringDecoder.h index c2f3404624..d611ed1751 100644 --- a/dtool/src/dtoolutil/stringDecoder.h +++ b/dtool/src/dtoolutil/stringDecoder.h @@ -1,30 +1,26 @@ -// Filename: stringDecoder.h -// Created by: drose (11Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringDecoder.h + * @author drose + * @date 2002-02-11 + */ #ifndef STRINGDECODER_H #define STRINGDECODER_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : StringDecoder -// Description : The base class to a family of classes that decode -// various kinds of encoded byte streams. Give it a -// string, then ask it to pull the characters out one at -// a time. This also serves as the plain old -// byte-at-a-time decoder. -//////////////////////////////////////////////////////////////////// +/** + * The base class to a family of classes that decode various kinds of encoded + * byte streams. Give it a string, then ask it to pull the characters out one + * at a time. This also serves as the plain old byte-at-a-time decoder. + */ class EXPCL_DTOOL StringDecoder { public: INLINE StringDecoder(const string &input); @@ -45,10 +41,9 @@ protected: static ostream *_notify_ptr; }; -//////////////////////////////////////////////////////////////////// -// Class : StringUtf8Decoder -// Description : This decoder extracts utf-8 sequences. -//////////////////////////////////////////////////////////////////// +/** + * This decoder extracts utf-8 sequences. + */ class StringUtf8Decoder : public StringDecoder { public: INLINE StringUtf8Decoder(const string &input); @@ -56,11 +51,10 @@ public: virtual int get_next_character(); }; -//////////////////////////////////////////////////////////////////// -// Class : StringUnicodeDecoder -// Description : This decoder extracts characters two at a time to get -// a plain wide character sequence. -//////////////////////////////////////////////////////////////////// +/** + * This decoder extracts characters two at a time to get a plain wide + * character sequence. + */ class StringUnicodeDecoder : public StringDecoder { public: INLINE StringUnicodeDecoder(const string &input); diff --git a/dtool/src/dtoolutil/string_utils.I b/dtool/src/dtoolutil/string_utils.I index a69497c97f..597a7f603b 100644 --- a/dtool/src/dtoolutil/string_utils.I +++ b/dtool/src/dtoolutil/string_utils.I @@ -1,17 +1,15 @@ -// Filename: string_utils.I -// Created by: drose (14Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file string_utils.I + * @author drose + * @date 2000-07-14 + */ template INLINE string diff --git a/dtool/src/dtoolutil/string_utils.cxx b/dtool/src/dtoolutil/string_utils.cxx index 80a022f1e6..600b07e7ed 100644 --- a/dtool/src/dtoolutil/string_utils.cxx +++ b/dtool/src/dtoolutil/string_utils.cxx @@ -1,16 +1,15 @@ -// Filename: string_utils.cxx -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file string_utils.cxx + * @author drose + * @date 1999-01-18 + */ #include "string_utils.h" #include "textEncoder.h" @@ -62,11 +61,9 @@ cmp_nocase_uh(const string &s, const string &s2) { -//////////////////////////////////////////////////////////////////// -// Function: downcase -// Description: Returns the input string with all uppercase letters -// converted to lowercase. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input string with all uppercase letters converted to lowercase. + */ string downcase(const string &s) { string result; @@ -78,11 +75,9 @@ downcase(const string &s) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: upcase -// Description: Returns the input string with all lowercase letters -// converted to uppercase. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input string with all lowercase letters converted to uppercase. + */ string upcase(const string &s) { string result; @@ -95,16 +90,14 @@ upcase(const string &s) { } -//////////////////////////////////////////////////////////////////// -// Function: extract_words -// Description: Divides the string into a number of words according -// to whitespace. The words vector should be cleared by -// the user before calling; otherwise, the list of words -// in the string will be appended to the end of whatever -// was there before. -// -// The return value is the number of words extracted. -//////////////////////////////////////////////////////////////////// +/** + * Divides the string into a number of words according to whitespace. The + * words vector should be cleared by the user before calling; otherwise, the + * list of words in the string will be appended to the end of whatever was + * there before. + * + * The return value is the number of words extracted. + */ int extract_words(const string &str, vector_string &words) { int num_words = 0; @@ -129,16 +122,14 @@ extract_words(const string &str, vector_string &words) { return num_words; } -//////////////////////////////////////////////////////////////////// -// Function: extract_words -// Description: Divides the string into a number of words according -// to whitespace. The words vector should be cleared by -// the user before calling; otherwise, the list of words -// in the string will be appended to the end of whatever -// was there before. -// -// The return value is the number of words extracted. -//////////////////////////////////////////////////////////////////// +/** + * Divides the string into a number of words according to whitespace. The + * words vector should be cleared by the user before calling; otherwise, the + * list of words in the string will be appended to the end of whatever was + * there before. + * + * The return value is the number of words extracted. + */ int extract_words(const wstring &str, pvector &words) { int num_words = 0; @@ -163,18 +154,15 @@ extract_words(const wstring &str, pvector &words) { return num_words; } -//////////////////////////////////////////////////////////////////// -// Function: tokenize -// Description: Chops the source string up into pieces delimited by -// any of the characters specified in delimiters. -// Repeated delimiter characters represent zero-length -// tokens. -// -// It is the user's responsibility to ensure the output -// vector is cleared before calling this function; the -// results will simply be appended to the end of the -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Chops the source string up into pieces delimited by any of the characters + * specified in delimiters. Repeated delimiter characters represent zero- + * length tokens. + * + * It is the user's responsibility to ensure the output vector is cleared + * before calling this function; the results will simply be appended to the + * end of the vector. + */ void tokenize(const string &str, vector_string &words, const string &delimiters, bool discard_repeated_delimiters) { @@ -195,18 +183,15 @@ tokenize(const string &str, vector_string &words, const string &delimiters, words.push_back(string()); } -//////////////////////////////////////////////////////////////////// -// Function: tokenize -// Description: Chops the source string up into pieces delimited by -// any of the characters specified in delimiters. -// Repeated delimiter characters represent zero-length -// tokens. -// -// It is the user's responsibility to ensure the output -// vector is cleared before calling this function; the -// results will simply be appended to the end of the -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Chops the source string up into pieces delimited by any of the characters + * specified in delimiters. Repeated delimiter characters represent zero- + * length tokens. + * + * It is the user's responsibility to ensure the output vector is cleared + * before calling this function; the results will simply be appended to the + * end of the vector. + */ void tokenize(const wstring &str, pvector &words, const wstring &delimiters, bool discard_repeated_delimiters) { @@ -227,11 +212,10 @@ tokenize(const wstring &str, pvector &words, const wstring &delimiters, words.push_back(wstring()); } -//////////////////////////////////////////////////////////////////// -// Function: trim_left -// Description: Returns a new string representing the contents of the -// given string with the leading whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with the + * leading whitespace removed. + */ string trim_left(const string &str) { size_t begin = 0; @@ -242,11 +226,10 @@ trim_left(const string &str) { return str.substr(begin); } -//////////////////////////////////////////////////////////////////// -// Function: trim_left -// Description: Returns a new string representing the contents of the -// given string with the leading whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with the + * leading whitespace removed. + */ wstring trim_left(const wstring &str) { size_t begin = 0; @@ -257,11 +240,10 @@ trim_left(const wstring &str) { return str.substr(begin); } -//////////////////////////////////////////////////////////////////// -// Function: trim_right -// Description: Returns a new string representing the contents of the -// given string with the trailing whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with the + * trailing whitespace removed. + */ string trim_right(const string &str) { size_t begin = 0; @@ -273,11 +255,10 @@ trim_right(const string &str) { return str.substr(begin, end - begin); } -//////////////////////////////////////////////////////////////////// -// Function: trim_right -// Description: Returns a new string representing the contents of the -// given string with the trailing whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with the + * trailing whitespace removed. + */ wstring trim_right(const wstring &str) { size_t begin = 0; @@ -289,12 +270,10 @@ trim_right(const wstring &str) { return str.substr(begin, end - begin); } -//////////////////////////////////////////////////////////////////// -// Function: trim -// Description: Returns a new string representing the contents of the -// given string with both leading and trailing -// whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with + * both leading and trailing whitespace removed. + */ string trim(const string &str) { size_t begin = 0; @@ -310,12 +289,10 @@ trim(const string &str) { return str.substr(begin, end - begin); } -//////////////////////////////////////////////////////////////////// -// Function: trim -// Description: Returns a new string representing the contents of the -// given string with both leading and trailing -// whitespace removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new string representing the contents of the given string with + * both leading and trailing whitespace removed. + */ wstring trim(const wstring &str) { size_t begin = 0; @@ -331,18 +308,15 @@ trim(const wstring &str) { return str.substr(begin, end - begin); } -//////////////////////////////////////////////////////////////////// -// Function: string_to_int -// Description: A string-interface wrapper around the C library -// strtol(). This parses the ASCII representation of an -// integer, and then sets tail to everything that -// follows the first valid integer read. If, on exit, -// str == tail, there was no valid integer in the -// source string; if !tail.empty(), there was garbage -// after the integer. -// -// It is legal if str and tail refer to the same string. -//////////////////////////////////////////////////////////////////// +/** + * A string-interface wrapper around the C library strtol(). This parses the + * ASCII representation of an integer, and then sets tail to everything that + * follows the first valid integer read. If, on exit, str == tail, there was + * no valid integer in the source string; if !tail.empty(), there was garbage + * after the integer. + * + * It is legal if str and tail refer to the same string. + */ int string_to_int(const string &str, string &tail) { const char *nptr = str.c_str(); @@ -352,12 +326,11 @@ string_to_int(const string &str, string &tail) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: string_to_int -// Description: Another flavor of string_to_int(), this one returns -// true if the string is a perfectly valid integer (and -// sets result to that value), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Another flavor of string_to_int(), this one returns true if the string is a + * perfectly valid integer (and sets result to that value), or false + * otherwise. + */ bool string_to_int(const string &str, int &result) { string tail; @@ -365,18 +338,15 @@ string_to_int(const string &str, int &result) { return tail.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: string_to_double -// Description: A string-interface wrapper around the C library -// strtol(). This parses the ASCII representation of an -// floating-point number, and then sets tail to -// everything that follows the first valid integer read. -// If, on exit, str == tail, there was no valid integer -// in the source string; if !tail.empty(), there was -// garbage after the number. -// -// It is legal if str and tail refer to the same string. -//////////////////////////////////////////////////////////////////// +/** + * A string-interface wrapper around the C library strtol(). This parses the + * ASCII representation of an floating-point number, and then sets tail to + * everything that follows the first valid integer read. If, on exit, str == + * tail, there was no valid integer in the source string; if !tail.empty(), + * there was garbage after the number. + * + * It is legal if str and tail refer to the same string. + */ double string_to_double(const string &str, string &tail) { const char *nptr = str.c_str(); @@ -386,13 +356,11 @@ string_to_double(const string &str, string &tail) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: string_to_double -// Description: Another flavor of string_to_double(), this one -// returns true if the string is a perfectly valid -// number (and sets result to that value), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Another flavor of string_to_double(), this one returns true if the string + * is a perfectly valid number (and sets result to that value), or false + * otherwise. + */ bool string_to_double(const string &str, double &result) { string tail; @@ -400,10 +368,9 @@ string_to_double(const string &str, double &result) { return tail.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: string_to_float -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool string_to_float(const string &str, float &result) { string tail; @@ -411,10 +378,9 @@ string_to_float(const string &str, float &result) { return tail.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: string_to_stdfloat -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool string_to_stdfloat(const string &str, PN_stdfloat &result) { string tail; diff --git a/dtool/src/dtoolutil/string_utils.h b/dtool/src/dtoolutil/string_utils.h index 10ebad4720..2737566cdf 100644 --- a/dtool/src/dtoolutil/string_utils.h +++ b/dtool/src/dtoolutil/string_utils.h @@ -1,16 +1,15 @@ -// Filename: string_utils.h -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file string_utils.h + * @author drose + * @date 1999-01-18 + */ #ifndef STRING_UTILS_H #define STRING_UTILS_H @@ -46,7 +45,7 @@ EXPCL_DTOOL void tokenize(const wstring &str, pvector &words, const wstring &delimiters, bool discard_repeated_delimiters = false); -// Trims leading and/or trailing whitespace from the string. +// Trims leading andor trailing whitespace from the string. EXPCL_DTOOL string trim_left(const string &str); EXPCL_DTOOL wstring trim_left(const wstring &str); EXPCL_DTOOL string trim_right(const string &str); @@ -62,8 +61,8 @@ EXPCL_DTOOL bool string_to_double(const string &str, double &result); EXPCL_DTOOL bool string_to_float(const string &str, float &result); EXPCL_DTOOL bool string_to_stdfloat(const string &str, PN_stdfloat &result); -// Convenience function to make a string from anything that has an -// ostream operator. +// Convenience function to make a string from anything that has an ostream +// operator. template INLINE string format_string(const Thing &thing); diff --git a/dtool/src/dtoolutil/test_pfstream.cxx b/dtool/src/dtoolutil/test_pfstream.cxx index c1a44bf72b..b088079723 100644 --- a/dtool/src/dtoolutil/test_pfstream.cxx +++ b/dtool/src/dtoolutil/test_pfstream.cxx @@ -1,21 +1,20 @@ -// Filename: test_pfstream.cxx -// Created by: drose (31Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_pfstream.cxx + * @author drose + * @date 2002-07-31 + */ #include "dtoolbase.h" #include "pfstream.h" -int +int main(int argc, char *argv[]) { if (argc < 2) { cout << "test_pfstream command-line\n"; @@ -31,7 +30,7 @@ main(int argc, char *argv[]) { } cout << "Executing command:\n" << cmd << "\n"; - + IPipeStream in(cmd); char c; diff --git a/dtool/src/dtoolutil/test_touch.cxx b/dtool/src/dtoolutil/test_touch.cxx index eb78d4694b..722a94a85e 100644 --- a/dtool/src/dtoolutil/test_touch.cxx +++ b/dtool/src/dtoolutil/test_touch.cxx @@ -1,16 +1,15 @@ -// Filename: test_touch.cxx -// Created by: drose (04Nov02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_touch.cxx + * @author drose + * @date 2002-11-04 + */ #include "dtoolbase.h" #include "filename.h" diff --git a/dtool/src/dtoolutil/textEncoder.I b/dtool/src/dtoolutil/textEncoder.I index c8ef58751f..fb84aa316d 100644 --- a/dtool/src/dtoolutil/textEncoder.I +++ b/dtool/src/dtoolutil/textEncoder.I @@ -1,38 +1,31 @@ -// Filename: textEncoder.I -// Created by: drose (26Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textEncoder.I + * @author drose + * @date 2003-03-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextEncoder:: TextEncoder() { _encoding = _default_encoding; - - // Initially, since the text string is empty, we know that both - // _text and _wtext accurately reflect the empty state; so we "got" - // both of them. + + // Initially, since the text string is empty, we know that both _text and + // _wtext accurately reflect the empty state; so we "got" both of them. _flags = (F_got_text | F_got_wtext); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextEncoder:: TextEncoder(const TextEncoder ©) : _flags(copy._flags), @@ -42,19 +35,15 @@ TextEncoder(const TextEncoder ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_encoding -// Access: Published -// Description: Specifies how the string set via set_text() is to be -// interpreted. The default, E_iso8859, means a -// standard string with one-byte characters -// (i.e. ASCII). Other encodings are possible to take -// advantage of character sets with more than 256 -// characters. -// -// This affects only future calls to set_text(); it does -// not change text that was set previously. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how the string set via set_text() is to be interpreted. The + * default, E_iso8859, means a standard string with one-byte characters (i.e. + * ASCII). Other encodings are possible to take advantage of character sets + * with more than 256 characters. + * + * This affects only future calls to set_text(); it does not change text that + * was set previously. + */ INLINE void TextEncoder:: set_encoding(TextEncoder::Encoding encoding) { // Force the previously-set strings to be encoded or decoded now. @@ -63,51 +52,39 @@ set_encoding(TextEncoder::Encoding encoding) { _encoding = encoding; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_encoding -// Access: Published -// Description: Returns the encoding by which the string set via -// set_text() is to be interpreted. See set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the encoding by which the string set via set_text() is to be + * interpreted. See set_encoding(). + */ INLINE TextEncoder::Encoding TextEncoder:: get_encoding() const { return _encoding; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_default_encoding -// Access: Published, Static -// Description: Specifies the default encoding to be used for all -// subsequently created TextEncoder objects. See -// set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default encoding to be used for all subsequently created + * TextEncoder objects. See set_encoding(). + */ INLINE void TextEncoder:: set_default_encoding(TextEncoder::Encoding encoding) { _default_encoding = encoding; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_default_encoding -// Access: Published, Static -// Description: Specifies the default encoding to be used for all -// subsequently created TextEncoder objects. See -// set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default encoding to be used for all subsequently created + * TextEncoder objects. See set_encoding(). + */ INLINE TextEncoder::Encoding TextEncoder:: get_default_encoding() { return _default_encoding; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_text -// Access: Published -// Description: Changes the text that is stored in the encoder. The -// text should be encoded according to the method -// indicated by set_encoding(). Subsequent calls to -// get_text() will return this same string, while -// get_wtext() will return the decoded version of the -// string. -//////////////////////////////////////////////////////////////////// +/** + * Changes the text that is stored in the encoder. The text should be encoded + * according to the method indicated by set_encoding(). Subsequent calls to + * get_text() will return this same string, while get_wtext() will return the + * decoded version of the string. + */ INLINE void TextEncoder:: set_text(const string &text) { if (!has_text() || _text != text) { @@ -116,26 +93,20 @@ set_text(const string &text) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_text -// Access: Published -// Description: The two-parameter version of set_text() accepts an -// explicit encoding; the text is immediately decoded -// and stored as a wide-character string. Subsequent -// calls to get_text() will return the same text -// re-encoded using whichever encoding is specified by -// set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * The two-parameter version of set_text() accepts an explicit encoding; the + * text is immediately decoded and stored as a wide-character string. + * Subsequent calls to get_text() will return the same text re-encoded using + * whichever encoding is specified by set_encoding(). + */ INLINE void TextEncoder:: set_text(const string &text, TextEncoder::Encoding encoding) { set_wtext(decode_text(text, encoding)); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::clear_text -// Access: Published -// Description: Removes the text from the TextEncoder. -//////////////////////////////////////////////////////////////////// +/** + * Removes the text from the TextEncoder. + */ INLINE void TextEncoder:: clear_text() { _text = string(); @@ -143,11 +114,9 @@ clear_text() { _flags |= (F_got_text | F_got_wtext); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::has_text -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextEncoder:: has_text() const { if (_flags & F_got_wtext) { @@ -157,12 +126,9 @@ has_text() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_text -// Access: Published -// Description: Returns the current text, as encoded via the current -// encoding system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current text, as encoded via the current encoding system. + */ INLINE string TextEncoder:: get_text() const { if ((_flags & F_got_text) == 0) { @@ -172,62 +138,48 @@ get_text() const { return _text; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_text -// Access: Published -// Description: Returns the current text, as encoded via the indicated -// encoding system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current text, as encoded via the indicated encoding system. + */ INLINE string TextEncoder:: get_text(TextEncoder::Encoding encoding) const { return encode_wtext(get_wtext(), encoding); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::append_text -// Access: Published -// Description: Appends the indicates string to the end of the stored -// text. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicates string to the end of the stored text. + */ INLINE void TextEncoder:: append_text(const string &text) { _text = get_text() + text; _flags = (_flags | F_got_text) & ~F_got_wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::append_unicode_char -// Access: Published -// Description: Appends a single character to the end of the stored -// text. This may be a wide character, up to 16 bits in -// Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Appends a single character to the end of the stored text. This may be a + * wide character, up to 16 bits in Unicode. + */ INLINE void TextEncoder:: append_unicode_char(int character) { _wtext = get_wtext() + wstring(1, (wchar_t)character); _flags = (_flags | F_got_wtext) & ~F_got_text; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_num_chars -// Access: Published -// Description: Returns the number of characters in the stored text. -// This is a count of wide characters, after the string -// has been decoded according to set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of characters in the stored text. This is a count of + * wide characters, after the string has been decoded according to + * set_encoding(). + */ INLINE size_t TextEncoder:: get_num_chars() const { return get_wtext().length(); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_unicode_char -// Access: Published -// Description: Returns the Unicode value of the nth character in the -// stored text. This may be a wide character (greater -// than 255), after the string has been decoded -// according to set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the Unicode value of the nth character in the stored text. This + * may be a wide character (greater than 255), after the string has been + * decoded according to set_encoding(). + */ INLINE int TextEncoder:: get_unicode_char(size_t index) const { get_wtext(); @@ -237,14 +189,11 @@ get_unicode_char(size_t index) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_unicode_char -// Access: Published -// Description: Sets the Unicode value of the nth character in the -// stored text. This may be a wide character (greater -// than 255), after the string has been decoded -// according to set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the Unicode value of the nth character in the stored text. This may + * be a wide character (greater than 255), after the string has been decoded + * according to set_encoding(). + */ INLINE void TextEncoder:: set_unicode_char(size_t index, int character) { get_wtext(); @@ -254,75 +203,59 @@ set_unicode_char(size_t index, int character) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_encoded_char -// Access: Published -// Description: Returns the nth char of the stored text, as a one-, -// two-, or three-byte encoded string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth char of the stored text, as a one-, two-, or three-byte + * encoded string. + */ INLINE string TextEncoder:: get_encoded_char(size_t index) const { return get_encoded_char(index, get_encoding()); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_encoded_char -// Access: Published -// Description: Returns the nth char of the stored text, as a one-, -// two-, or three-byte encoded string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth char of the stored text, as a one-, two-, or three-byte + * encoded string. + */ INLINE string TextEncoder:: get_encoded_char(size_t index, TextEncoder::Encoding encoding) const { wstring wch(1, (wchar_t)get_unicode_char(index)); return encode_wtext(wch, encoding); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_text_as_ascii -// Access: Published -// Description: Returns the text associated with the node, converted -// as nearly as possible to a fully-ASCII -// representation. This means replacing accented -// letters with their unaccented ASCII equivalents. -// -// It is possible that some characters in the string -// cannot be converted to ASCII. (The string may -// involve symbols like the copyright symbol, for -// instance, or it might involve letters in some other -// alphabet such as Greek or Cyrillic, or even Latin -// letters like thorn or eth that are not part of the -// ASCII character set.) In this case, as much of the -// string as possible will be converted to ASCII, and -// the nonconvertible characters will remain encoded in -// the encoding specified by set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the text associated with the node, converted as nearly as possible + * to a fully-ASCII representation. This means replacing accented letters + * with their unaccented ASCII equivalents. + * + * It is possible that some characters in the string cannot be converted to + * ASCII. (The string may involve symbols like the copyright symbol, for + * instance, or it might involve letters in some other alphabet such as Greek + * or Cyrillic, or even Latin letters like thorn or eth that are not part of + * the ASCII character set.) In this case, as much of the string as possible + * will be converted to ASCII, and the nonconvertible characters will remain + * encoded in the encoding specified by set_encoding(). + */ INLINE string TextEncoder:: get_text_as_ascii() const { return encode_wtext(get_wtext_as_ascii()); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::reencode_text -// Access: Published, Static -// Description: Given the indicated text string, which is assumed to -// be encoded via the encoding "from", decodes it and -// then reencodes it into the encoding "to", and returns -// the newly encoded string. This does not change or -// affect any properties on the TextEncoder itself. -//////////////////////////////////////////////////////////////////// +/** + * Given the indicated text string, which is assumed to be encoded via the + * encoding "from", decodes it and then reencodes it into the encoding "to", + * and returns the newly encoded string. This does not change or affect any + * properties on the TextEncoder itself. + */ INLINE string TextEncoder:: -reencode_text(const string &text, TextEncoder::Encoding from, +reencode_text(const string &text, TextEncoder::Encoding from, TextEncoder::Encoding to) { return encode_wtext(decode_text(text, from), to); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_isalpha -// Access: Published, Static -// Description: Returns true if the indicated character is an -// alphabetic letter, false otherwise. This is akin to -// ctype's isalpha(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is an alphabetic letter, false + * otherwise. This is akin to ctype's isalpha(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_isalpha(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); @@ -333,13 +266,10 @@ unicode_isalpha(int character) { entry->_char_type == UnicodeLatinMap::CT_lower; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_isdigit -// Access: Published, Static -// Description: Returns true if the indicated character is a -// numeric digit, false otherwise. This is akin to -// ctype's isdigit(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is a numeric digit, false + * otherwise. This is akin to ctype's isdigit(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_isdigit(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); @@ -351,13 +281,10 @@ unicode_isdigit(int character) { return (isdigit(entry->_ascii_equiv) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_ispunct -// Access: Published, Static -// Description: Returns true if the indicated character is a -// punctuation mark, false otherwise. This is akin to -// ctype's ispunct(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is a punctuation mark, false + * otherwise. This is akin to ctype's ispunct(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_ispunct(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); @@ -368,13 +295,10 @@ unicode_ispunct(int character) { return entry->_char_type == UnicodeLatinMap::CT_punct; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_isupper -// Access: Published, Static -// Description: Returns true if the indicated character is an -// uppercase letter, false otherwise. This is akin to -// ctype's isupper(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is an uppercase letter, false + * otherwise. This is akin to ctype's isupper(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_isupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); @@ -384,13 +308,10 @@ unicode_isupper(int character) { return entry->_char_type == UnicodeLatinMap::CT_upper; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_isspace -// Access: Published, Static -// Description: Returns true if the indicated character is a -// whitespace letter, false otherwise. This is akin to -// ctype's isspace(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is a whitespace letter, false + * otherwise. This is akin to ctype's isspace(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_isspace(int character) { switch (character) { @@ -404,13 +325,10 @@ unicode_isspace(int character) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_islower -// Access: Published, Static -// Description: Returns true if the indicated character is a -// lowercase letter, false otherwise. This is akin to -// ctype's islower(), extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character is a lowercase letter, false + * otherwise. This is akin to ctype's islower(), extended to Unicode. + */ INLINE bool TextEncoder:: unicode_islower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); @@ -420,55 +338,45 @@ unicode_islower(int character) { return entry->_char_type == UnicodeLatinMap::CT_lower; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_toupper -// Access: Published, Static -// Description: Returns the uppercase equivalent of the given Unicode -// character. This is akin to ctype's toupper(), -// extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the uppercase equivalent of the given Unicode character. This is + * akin to ctype's toupper(), extended to Unicode. + */ INLINE int TextEncoder:: unicode_toupper(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == (const UnicodeLatinMap::Entry *)NULL) { return character; - } + } return entry->_toupper_character; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::unicode_tolower -// Access: Published, Static -// Description: Returns the uppercase equivalent of the given Unicode -// character. This is akin to ctype's tolower(), -// extended to Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the uppercase equivalent of the given Unicode character. This is + * akin to ctype's tolower(), extended to Unicode. + */ INLINE int TextEncoder:: unicode_tolower(int character) { const UnicodeLatinMap::Entry *entry = UnicodeLatinMap::look_up(character); if (entry == (const UnicodeLatinMap::Entry *)NULL) { return character; - } + } return entry->_tolower_character; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::upper -// Access: Published, Static -// Description: Converts the string to uppercase, assuming the string -// is encoded in the default encoding. -//////////////////////////////////////////////////////////////////// +/** + * Converts the string to uppercase, assuming the string is encoded in the + * default encoding. + */ INLINE string TextEncoder:: upper(const string &source) { return upper(source, get_default_encoding()); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::upper -// Access: Published, Static -// Description: Converts the string to uppercase, assuming the string -// is encoded in the indicated encoding. -//////////////////////////////////////////////////////////////////// +/** + * Converts the string to uppercase, assuming the string is encoded in the + * indicated encoding. + */ INLINE string TextEncoder:: upper(const string &source, TextEncoder::Encoding encoding) { TextEncoder encoder; @@ -478,23 +386,19 @@ upper(const string &source, TextEncoder::Encoding encoding) { return encoder.get_text(); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::lower -// Access: Published, Static -// Description: Converts the string to lowercase, assuming the string -// is encoded in the default encoding. -//////////////////////////////////////////////////////////////////// +/** + * Converts the string to lowercase, assuming the string is encoded in the + * default encoding. + */ INLINE string TextEncoder:: lower(const string &source) { return lower(source, get_default_encoding()); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::lower -// Access: Published, Static -// Description: Converts the string to lowercase, assuming the string -// is encoded in the indicated encoding. -//////////////////////////////////////////////////////////////////// +/** + * Converts the string to lowercase, assuming the string is encoded in the + * indicated encoding. + */ INLINE string TextEncoder:: lower(const string &source, TextEncoder::Encoding encoding) { TextEncoder encoder; @@ -504,14 +408,11 @@ lower(const string &source, TextEncoder::Encoding encoding) { return encoder.get_text(); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::set_wtext -// Access: Published -// Description: Changes the text that is stored in the encoder. -// Subsequent calls to get_wtext() will return this same -// string, while get_text() will return the encoded -// version of the string. -//////////////////////////////////////////////////////////////////// +/** + * Changes the text that is stored in the encoder. Subsequent calls to + * get_wtext() will return this same string, while get_text() will return the + * encoded version of the string. + */ INLINE void TextEncoder:: set_wtext(const wstring &wtext) { if (!has_text() || _wtext != wtext) { @@ -520,12 +421,10 @@ set_wtext(const wstring &wtext) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_wtext -// Access: Published -// Description: Returns the text associated with the TextEncoder, as -// a wide-character string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the text associated with the TextEncoder, as a wide-character + * string. + */ INLINE const wstring &TextEncoder:: get_wtext() const { if ((_flags & F_got_wtext) == 0) { @@ -535,45 +434,36 @@ get_wtext() const { return _wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::append_wtext -// Access: Published -// Description: Appends the indicates string to the end of the stored -// wide-character text. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicates string to the end of the stored wide-character text. + */ INLINE void TextEncoder:: append_wtext(const wstring &wtext) { _wtext = get_wtext() + wtext; _flags = (_flags | F_got_wtext) & ~F_got_text; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::encode_wtext -// Access: Published -// Description: Encodes a wide-text string into a single-char string, -// according to the current encoding. -//////////////////////////////////////////////////////////////////// +/** + * Encodes a wide-text string into a single-char string, according to the + * current encoding. + */ INLINE string TextEncoder:: encode_wtext(const wstring &wtext) const { return encode_wtext(wtext, _encoding); } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::decode_text -// Access: Published -// Description: Returns the given wstring decoded to a single-byte -// string, via the current encoding system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the given wstring decoded to a single-byte string, via the current + * encoding system. + */ INLINE wstring TextEncoder:: decode_text(const string &text) const { return decode_text(text, _encoding); } -//////////////////////////////////////////////////////////////////// -// Function: wstring ostream operator -// Description: Uses the current default encoding to output the -// wstring. -//////////////////////////////////////////////////////////////////// +/** + * Uses the current default encoding to output the wstring. + */ INLINE ostream & operator << (ostream &out, const wstring &str) { TextEncoder encoder; diff --git a/dtool/src/dtoolutil/textEncoder.cxx b/dtool/src/dtoolutil/textEncoder.cxx index de5b625a86..f4f788845e 100644 --- a/dtool/src/dtoolutil/textEncoder.cxx +++ b/dtool/src/dtoolutil/textEncoder.cxx @@ -1,16 +1,15 @@ -// Filename: textEncoder.cxx -// Created by: drose (26Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textEncoder.cxx + * @author drose + * @date 2003-03-26 + */ #include "textEncoder.h" #include "stringDecoder.h" @@ -19,13 +18,10 @@ TextEncoder::Encoding TextEncoder::_default_encoding = TextEncoder::E_iso8859; -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::make_upper -// Access: Published -// Description: Adjusts the text stored within the encoder to all -// uppercase letters (preserving accent marks -// correctly). -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the text stored within the encoder to all uppercase letters + * (preserving accent marks correctly). + */ void TextEncoder:: make_upper() { get_wtext(); @@ -36,13 +32,10 @@ make_upper() { _flags &= ~F_got_text; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::make_lower -// Access: Published -// Description: Adjusts the text stored within the encoder to all -// lowercase letters (preserving accent marks -// correctly). -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the text stored within the encoder to all lowercase letters + * (preserving accent marks correctly). + */ void TextEncoder:: make_lower() { get_wtext(); @@ -53,25 +46,19 @@ make_lower() { _flags &= ~F_got_text; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::get_wtext_as_ascii -// Access: Published -// Description: Returns the text associated with the node, converted -// as nearly as possible to a fully-ASCII -// representation. This means replacing accented -// letters with their unaccented ASCII equivalents. -// -// It is possible that some characters in the string -// cannot be converted to ASCII. (The string may -// involve symbols like the copyright symbol, for -// instance, or it might involve letters in some other -// alphabet such as Greek or Cyrillic, or even Latin -// letters like thorn or eth that are not part of the -// ASCII character set.) In this case, as much of the -// string as possible will be converted to ASCII, and -// the nonconvertible characters will remain in their -// original form. -//////////////////////////////////////////////////////////////////// +/** + * Returns the text associated with the node, converted as nearly as possible + * to a fully-ASCII representation. This means replacing accented letters + * with their unaccented ASCII equivalents. + * + * It is possible that some characters in the string cannot be converted to + * ASCII. (The string may involve symbols like the copyright symbol, for + * instance, or it might involve letters in some other alphabet such as Greek + * or Cyrillic, or even Latin letters like thorn or eth that are not part of + * the ASCII character set.) In this case, as much of the string as possible + * will be converted to ASCII, and the nonconvertible characters will remain + * in their original form. + */ wstring TextEncoder:: get_wtext_as_ascii() const { get_wtext(); @@ -80,7 +67,7 @@ get_wtext_as_ascii() const { for (si = _wtext.begin(); si != _wtext.end(); ++si) { wchar_t character = (*si); - const UnicodeLatinMap::Entry *map_entry = + const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); if (map_entry != NULL && map_entry->_ascii_equiv != 0) { result += (wchar_t)map_entry->_ascii_equiv; @@ -96,15 +83,12 @@ get_wtext_as_ascii() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::is_wtext -// Access: Published -// Description: Returns true if any of the characters in the string -// returned by get_wtext() are out of the range of an -// ASCII character (and, therefore, get_wtext() should -// be called in preference to get_text()). -//////////////////////////////////////////////////////////////////// -bool TextEncoder:: +/** + * Returns true if any of the characters in the string returned by get_wtext() + * are out of the range of an ASCII character (and, therefore, get_wtext() + * should be called in preference to get_text()). + */ +bool TextEncoder:: is_wtext() const { get_wtext(); wstring::const_iterator ti; @@ -117,13 +101,10 @@ is_wtext() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::encode_wchar -// Access: Published, Static -// Description: Encodes a single wide char into a one-, two-, or -// three-byte string, according to the given encoding -// system. -//////////////////////////////////////////////////////////////////// +/** + * Encodes a single wide char into a one-, two-, or three-byte string, + * according to the given encoding system. + */ string TextEncoder:: encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { switch (encoding) { @@ -131,10 +112,10 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { if ((ch & ~0xff) == 0) { return string(1, (char)ch); } else { - // The character won't fit in the 8-bit ISO 8859. See if we can - // make it fit by reducing it to its ascii equivalent - // (essentially stripping off an unusual accent mark). - const UnicodeLatinMap::Entry *map_entry = + // The character won't fit in the 8-bit ISO 8859. See if we can make it + // fit by reducing it to its ascii equivalent (essentially stripping off + // an unusual accent mark). + const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(ch); if (map_entry != NULL && map_entry->_ascii_equiv != 0) { // Yes, it has an ascii equivalent. @@ -154,11 +135,11 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { if ((ch & ~0x7f) == 0) { return string(1, (char)ch); } else if ((ch & ~0x7ff) == 0) { - return + return string(1, (char)((ch >> 6) | 0xc0)) + string(1, (char)((ch & 0x3f) | 0x80)); } else { - return + return string(1, (char)((ch >> 12) | 0xe0)) + string(1, (char)(((ch >> 6) & 0x3f) | 0x80)) + string(1, (char)((ch & 0x3f) | 0x80)); @@ -166,19 +147,17 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) { case E_unicode: return - string(1, (char)(ch >> 8)) + + string(1, (char)(ch >> 8)) + string(1, (char)(ch & 0xff)); } return ""; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::encode_wtext -// Access: Published, Static -// Description: Encodes a wide-text string into a single-char string, -// according to the given encoding. -//////////////////////////////////////////////////////////////////// +/** + * Encodes a wide-text string into a single-char string, according to the + * given encoding. + */ string TextEncoder:: encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) { string result; @@ -190,12 +169,10 @@ encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::decode_text -// Access: Published, Static -// Description: Returns the given wstring decoded to a single-byte -// string, via the given encoding system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the given wstring decoded to a single-byte string, via the given + * encoding system. + */ wstring TextEncoder:: decode_text(const string &text, TextEncoder::Encoding encoding) { switch (encoding) { @@ -220,23 +197,20 @@ decode_text(const string &text, TextEncoder::Encoding encoding) { }; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::decode_text_impl -// Access: Private, Static -// Description: Decodes the eight-bit stream from the indicated -// decoder, returning the decoded wide-char string. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the eight-bit stream from the indicated decoder, returning the + * decoded wide-char string. + */ wstring TextEncoder:: decode_text_impl(StringDecoder &decoder) { wstring result; - // bool expand_amp = get_expand_amp(); + // bool expand_amp = get_expand_amp(); wchar_t character = decoder.get_next_character(); while (!decoder.is_eof()) { /* if (character == '&' && expand_amp) { - // An ampersand in expand_amp mode is treated as an escape - // character. + // An ampersand in expand_amp mode is treated as an escape character. character = expand_amp_sequence(decoder); } */ @@ -247,16 +221,13 @@ decode_text_impl(StringDecoder &decoder) { return result; } +/** + * Given that we have just read an ampersand from the StringDecoder, and that + * we have expand_amp in effect and are therefore expected to expand the + * sequence that this ampersand begins into a single unicode character, do the + * expansion and return the character. + */ /* -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::expand_amp_sequence -// Access: Private -// Description: Given that we have just read an ampersand from the -// StringDecoder, and that we have expand_amp in effect -// and are therefore expected to expand the sequence -// that this ampersand begins into a single unicode -// character, do the expansion and return the character. -//////////////////////////////////////////////////////////////////// int TextEncoder:: expand_amp_sequence(StringDecoder &decoder) const { int result = 0; @@ -279,7 +250,7 @@ expand_amp_sequence(StringDecoder &decoder) const { } string sequence; - + // Some non-numeric sequence. while (!decoder.is_eof() && character < 128 && isalpha((unsigned int)character)) { sequence += character; @@ -339,10 +310,9 @@ expand_amp_sequence(StringDecoder &decoder) const { */ -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::Encoding ostream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, TextEncoder::Encoding encoding) { switch (encoding) { @@ -359,10 +329,9 @@ operator << (ostream &out, TextEncoder::Encoding encoding) { return out << "**invalid TextEncoder::Encoding(" << (int)encoding << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: TextEncoder::Encoding istream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, TextEncoder::Encoding &encoding) { string word; diff --git a/dtool/src/dtoolutil/textEncoder.h b/dtool/src/dtoolutil/textEncoder.h index 5a8d7ecf9b..bc42d4a4c1 100644 --- a/dtool/src/dtoolutil/textEncoder.h +++ b/dtool/src/dtoolutil/textEncoder.h @@ -1,16 +1,15 @@ -// Filename: textEncoder.h -// Created by: drose (26Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textEncoder.h + * @author drose + * @date 2003-03-26 + */ #ifndef TEXTENCODER_H #define TEXTENCODER_H @@ -22,18 +21,15 @@ class StringDecoder; -//////////////////////////////////////////////////////////////////// -// Class : TextEncoder -// Description : This class can be used to convert text between -// multiple representations, e.g. utf-8 to Unicode. You -// may use it as a static class object, passing the -// encoding each time, or you may create an instance and -// use that object, which will record the current -// encoding and retain the current string. -// -// This class is also a base class of TextNode, which -// inherits this functionality. -//////////////////////////////////////////////////////////////////// +/** + * This class can be used to convert text between multiple representations, + * e.g. utf-8 to Unicode. You may use it as a static class object, passing + * the encoding each time, or you may create an instance and use that object, + * which will record the current encoding and retain the current string. + * + * This class is also a base class of TextNode, which inherits this + * functionality. + */ class EXPCL_DTOOL TextEncoder { PUBLISHED: enum Encoding { @@ -86,8 +82,8 @@ PUBLISHED: INLINE static string lower(const string &source); INLINE static string lower(const string &source, Encoding encoding); - // Direct support for wide-character strings. Now publishable with - // the new wstring support in interrogate. + // Direct support for wide-character strings. Now publishable with the new + // wstring support in interrogate. INLINE void set_wtext(const wstring &wtext); INLINE const wstring &get_wtext() const; INLINE void append_wtext(const wstring &text); @@ -120,12 +116,11 @@ operator << (ostream &out, TextEncoder::Encoding encoding); EXPCL_DTOOL istream & operator >> (istream &in, TextEncoder::Encoding &encoding); -// We'll define the output operator for wstring here, too. Presumably -// this will not be automatically defined by any system libraries. +// We'll define the output operator for wstring here, too. Presumably this +// will not be automatically defined by any system libraries. -// This function is declared inline to minimize the risk of link -// conflicts should another third-party module also define the same -// output operator. +// This function is declared inline to minimize the risk of link conflicts +// should another third-party module also define the same output operator. INLINE EXPCL_DTOOL ostream & operator << (ostream &out, const wstring &str); diff --git a/dtool/src/dtoolutil/unicodeLatinMap.cxx b/dtool/src/dtoolutil/unicodeLatinMap.cxx index 081f6f9693..3fc1e3cb1c 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.cxx +++ b/dtool/src/dtoolutil/unicodeLatinMap.cxx @@ -1,16 +1,15 @@ -// Filename: unicodeLatinMap.cxx -// Created by: drose (01Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file unicodeLatinMap.cxx + * @author drose + * @date 2003-02-01 + */ #include "unicodeLatinMap.h" @@ -1375,12 +1374,9 @@ static const wchar_t combining_accent_map[] = { 0x0000, // topbar }; -//////////////////////////////////////////////////////////////////// -// Function: UnicodeLatinMap::look_up -// Access: Public, Static -// Description: Returns the Entry associated with the indicated -// character, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Entry associated with the indicated character, if there is one. + */ const UnicodeLatinMap::Entry *UnicodeLatinMap:: look_up(wchar_t character) { if (!_initialized) { @@ -1400,24 +1396,18 @@ look_up(wchar_t character) { } } -//////////////////////////////////////////////////////////////////// -// Function: UnicodeLatinMap::get_combining_accent -// Access: Public, Static -// Description: Returns the unicode code point for the combining -// character corresponding with the given accent type, -// or 0 if none is recorded. -//////////////////////////////////////////////////////////////////// +/** + * Returns the unicode code point for the combining character corresponding + * with the given accent type, or 0 if none is recorded. + */ wchar_t UnicodeLatinMap:: get_combining_accent(AccentType accent) { return combining_accent_map[(size_t)accent]; } -//////////////////////////////////////////////////////////////////// -// Function: UnicodeLatinMap::init -// Access: Private, Static -// Description: Initializes the map, if it has not already been -// initialized. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the map, if it has not already been initialized. + */ void UnicodeLatinMap:: init() { if (!_initialized) { @@ -1425,9 +1415,9 @@ init() { for (size_t i = 0; i < latin_map_length; i++) { const UnicodeLatinMap::Entry *entry = &latin_map[i]; - // The first 256 characters are very common in Latin-alphabet - // languages, so index those in an array for superfast lookup. - // Everything else goes into the map. + // The first 256 characters are very common in Latin-alphabet languages, + // so index those in an array for superfast lookup. Everything else + // goes into the map. if (entry->_character < max_direct_chars) { _direct_chars[entry->_character] = entry; } else { @@ -1437,4 +1427,3 @@ init() { _initialized = true; } } - diff --git a/dtool/src/dtoolutil/unicodeLatinMap.h b/dtool/src/dtoolutil/unicodeLatinMap.h index 90883221d5..dc74fcf8d9 100644 --- a/dtool/src/dtoolutil/unicodeLatinMap.h +++ b/dtool/src/dtoolutil/unicodeLatinMap.h @@ -1,16 +1,15 @@ -// Filename: unicodeLatinMap.h -// Created by: drose (01Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file unicodeLatinMap.h + * @author drose + * @date 2003-02-01 + */ #ifndef UNICODELATINMAP_H #define UNICODELATINMAP_H @@ -18,18 +17,14 @@ #include "dtoolbase.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : UnicodeLatinMap -// Description : This class mainly serves as a container for a largish -// table of the subset of the Unicode character set that -// corresponds to the Latin alphabet, with its various -// accent marks and so on. Specifically, this table -// indicates how to map between the Unicode accented -// character and the corresponding ASCII equivalent -// without the accent mark; as well as how to switch -// case from upper to lower while retaining the Unicode -// accent marks. -//////////////////////////////////////////////////////////////////// +/** + * This class mainly serves as a container for a largish table of the subset + * of the Unicode character set that corresponds to the Latin alphabet, with + * its various accent marks and so on. Specifically, this table indicates how + * to map between the Unicode accented character and the corresponding ASCII + * equivalent without the accent mark; as well as how to switch case from + * upper to lower while retaining the Unicode accent marks. + */ class EXPCL_DTOOL UnicodeLatinMap { public: enum AccentType { @@ -108,7 +103,7 @@ public: AF_smallcap = 0x0008, AF_dotless = 0x0010, }; - + enum CharType { CT_upper, CT_lower, diff --git a/dtool/src/dtoolutil/vector_int.cxx b/dtool/src/dtoolutil/vector_int.cxx index 4ec1769281..1bb9423b7e 100644 --- a/dtool/src/dtoolutil/vector_int.cxx +++ b/dtool/src/dtoolutil/vector_int.cxx @@ -1,16 +1,15 @@ -// Filename: vector_int.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_int.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_int.h" diff --git a/dtool/src/dtoolutil/vector_int.h b/dtool/src/dtoolutil/vector_int.h index af0a7dd981..56436a956f 100644 --- a/dtool/src/dtoolutil/vector_int.h +++ b/dtool/src/dtoolutil/vector_int.h @@ -1,30 +1,27 @@ -// Filename: vector_int.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_int.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_INT_H #define VECTOR_INT_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_int -// Description : A vector of ints. This class is defined once here, -// and exported to DTOOLCONFIG.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of ints. This class is defined once here, and exported to + * DTOOLCONFIG.DLL; other packages that want to use a vector of this type + * (whether they need to export it or not) should include this header file, + * rather than defining the vector again. + */ #define EXPCL EXPCL_DTOOL #define EXPTP EXPTP_DTOOL diff --git a/dtool/src/dtoolutil/vector_src.cxx b/dtool/src/dtoolutil/vector_src.cxx index e363c4b4d7..930fc8400f 100644 --- a/dtool/src/dtoolutil/vector_src.cxx +++ b/dtool/src/dtoolutil/vector_src.cxx @@ -1,45 +1,37 @@ -// Filename: vector_src.cxx -// Created by: drose (15May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_src.cxx + * @author drose + * @date 2001-05-15 + */ -//////////////////////////////////////////////////////////////////// -// -// This file defines the interface to declare and export from the DLL -// an STL vector of some type. -// -// To use this file you must #define a number of symbols and then -// #include it from a .cxx file. You also must do the same thing with -// vector_something_src.h from a .h file. -// -// This is necessary because of the complexity involved in exporting a -// vector class from a DLL. If we are using the Dinkumware STL -// implementation, it is even more complex. However, all this -// complexity is only needed to support Windows builds; Unix shared -// libraries are able to export symbols (including templates) without -// any special syntax. -// -//////////////////////////////////////////////////////////////////// +/* + * This file defines the interface to declare and export from the DLL an STL + * vector of some type. To use this file you must #define a number of symbols + * and then #include it from a .cxx file. You also must do the same thing + * with vector_something_src.h from a .h file. This is necessary because of + * the complexity involved in exporting a vector class from a DLL. If we are + * using the Dinkumware STL implementation, it is even more complex. However, + * all this complexity is only needed to support Windows builds; Unix shared + * libraries are able to export symbols (including templates) without any + * special syntax. + */ -// The following variables should be defined prior to including this -// file: -// -// EXPCL - the appropriate EXPCL_* symbol for this DLL. -// EXPTP - the appropriate EXPTP_* symbol for this DLL. -// TYPE - the type of thing we are building a vector on. -// NAME - The name of the resulting vector typedef, e.g. vector_int. -// -// They will automatically be undefined at the end of the file. +/* + * The following variables should be defined prior to including this file: + * EXPCL - the appropriate EXPCL_* symbol for this DLL. EXPTP - the + * appropriate EXPTP_* symbol for this DLL. TYPE - the type of thing we are + * building a vector on. NAME - The name of the resulting vector typedef, + * e.g. vector_int. They will automatically be undefined at the end of the + * file. + */ /* void diff --git a/dtool/src/dtoolutil/vector_src.h b/dtool/src/dtoolutil/vector_src.h index 182341b16f..fae382b7e6 100644 --- a/dtool/src/dtoolutil/vector_src.h +++ b/dtool/src/dtoolutil/vector_src.h @@ -1,53 +1,43 @@ -// Filename: vector_src.h -// Created by: drose (15May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_src.h + * @author drose + * @date 2001-05-15 + */ +/* + * This file defines the interface to declare and export from the DLL an STL + * vector of some type. To use this file you must #define a number of symbols + * and then #include it from a .h file. You also must do the same thing with + * vector_something_src.cxx from a .cxx file. This is necessary because of + * the complexity involved in exporting a vector class from a DLL. If we are + * using the Dinkumware STL implementation, it is even more complex. However, + * all this complexity is only needed to support Windows builds; Unix shared + * libraries are able to export symbols (including templates) without any + * special syntax. + */ -//////////////////////////////////////////////////////////////////// -// -// This file defines the interface to declare and export from the DLL -// an STL vector of some type. -// -// To use this file you must #define a number of symbols and then -// #include it from a .h file. You also must do the same thing with -// vector_something_src.cxx from a .cxx file. -// -// This is necessary because of the complexity involved in exporting a -// vector class from a DLL. If we are using the Dinkumware STL -// implementation, it is even more complex. However, all this -// complexity is only needed to support Windows builds; Unix shared -// libraries are able to export symbols (including templates) without -// any special syntax. -// -//////////////////////////////////////////////////////////////////// - -// The following variables should be defined prior to including this -// file: -// -// EXPCL - the appropriate EXPCL_* symbol for this DLL. -// EXPTP - the appropriate EXPTP_* symbol for this DLL. -// TYPE - the type of thing we are building a vector on. -// NAME - The name of the resulting vector typedef, e.g. vector_int. -// -// They will automatically be undefined at the end of the file. +/* + * The following variables should be defined prior to including this file: + * EXPCL - the appropriate EXPCL_* symbol for this DLL. EXPTP - the + * appropriate EXPTP_* symbol for this DLL. TYPE - the type of thing we are + * building a vector on. NAME - The name of the resulting vector typedef, + * e.g. vector_int. They will automatically be undefined at the end of the + * file. + */ #include "pvector.h" #if defined(WIN32_VC) && !defined(CPPPARSER) #ifdef HAVE_DINKUM -// With the Dinkum library, we must first export the base class, -// _Vector_val. +// With the Dinkum library, we must first export the base class, _Vector_val. #define VV_BASE std::_Vector_val > #pragma warning (disable : 4231) EXPORT_TEMPLATE_CLASS(EXPCL, EXPTP, VV_BASE) @@ -76,10 +66,10 @@ typedef std::vector NAME; typedef pvector NAME; #endif - // Finally, we must define a non-inline function that performs the - // insert operation given a range of pointers. We do this because - // the Dinkum STL implementation uses member templates to handle - // this, but we cannot export the member templates from the DLL. + // Finally, we must define a non-inline function that performs the insert + // operation given a range of pointers. We do this because the Dinkum STL + // implementation uses member templates to handle this, but we cannot export + // the member templates from the DLL. /* extern EXPCL void @@ -92,4 +82,3 @@ insert_into_vector(NAME &vec, NAME::iterator where, #undef EXPTP #undef TYPE #undef NAME - diff --git a/dtool/src/dtoolutil/vector_string.cxx b/dtool/src/dtoolutil/vector_string.cxx index f4ce7a8f96..2b7ba4202a 100644 --- a/dtool/src/dtoolutil/vector_string.cxx +++ b/dtool/src/dtoolutil/vector_string.cxx @@ -1,16 +1,15 @@ -// Filename: vector_string.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_string.cxx + * @author drose + * @date 2000-05-15 + */ #include "vector_string.h" diff --git a/dtool/src/dtoolutil/vector_string.h b/dtool/src/dtoolutil/vector_string.h index a5e52154e7..d34ab7b301 100644 --- a/dtool/src/dtoolutil/vector_string.h +++ b/dtool/src/dtoolutil/vector_string.h @@ -1,30 +1,27 @@ -// Filename: vector_string.h -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_string.h + * @author drose + * @date 2000-05-15 + */ #ifndef VECTOR_STRING_H #define VECTOR_STRING_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_string -// Description : A vector of strings. This class is defined once here, -// and exported to DTOOL.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of strings. This class is defined once here, and exported to + * DTOOL.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_DTOOL #define EXPTP EXPTP_DTOOL diff --git a/dtool/src/dtoolutil/win32ArgParser.cxx b/dtool/src/dtoolutil/win32ArgParser.cxx index 88cdbc5a43..84ddb785a6 100644 --- a/dtool/src/dtoolutil/win32ArgParser.cxx +++ b/dtool/src/dtoolutil/win32ArgParser.cxx @@ -1,16 +1,15 @@ -// Filename: win32ArgParser.cxx -// Created by: drose (08Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file win32ArgParser.cxx + * @author drose + * @date 2011-11-08 + */ #include "win32ArgParser.h" @@ -25,11 +24,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Win32ArgParser:: Win32ArgParser() : _argv(NULL), @@ -37,22 +34,18 @@ Win32ArgParser() : { } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Win32ArgParser:: ~Win32ArgParser() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::clear -// Access: Public -// Description: Resets the parser to empty command line and -// deallocates the internal argv array. -//////////////////////////////////////////////////////////////////// +/** + * Resets the parser to empty command line and deallocates the internal argv + * array. + */ void Win32ArgParser:: clear() { assert(_argc == (int)_args.size()); @@ -69,16 +62,14 @@ clear() { _args.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::set_command_line -// Access: Public -// Description: Sets the string that indicates the full Win32 command -// line, and starts parsing this into argc, argv. -//////////////////////////////////////////////////////////////////// +/** + * Sets the string that indicates the full Win32 command line, and starts + * parsing this into argc, argv. + */ void Win32ArgParser:: set_command_line(const string &command_line) { clear(); - + const char *p = command_line.c_str(); while (*p != '\0') { parse_unquoted_arg(p); @@ -101,13 +92,10 @@ set_command_line(const string &command_line) { } } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::set_command_line -// Access: Public -// Description: Sets the Unicode string that indicates the full Win32 -// command line, and starts parsing this into argc, -// argv. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Unicode string that indicates the full Win32 command line, and + * starts parsing this into argc, argv. + */ void Win32ArgParser:: set_command_line(const wstring &command_line) { TextEncoder encoder; @@ -116,57 +104,46 @@ set_command_line(const wstring &command_line) { set_command_line(encoder.get_text()); } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::set_system_command_line -// Access: Public -// Description: Tells the parser to call GetCommandLine() to query -// the system command line string, and parse it into -// argc, argv. -//////////////////////////////////////////////////////////////////// +/** + * Tells the parser to call GetCommandLine() to query the system command line + * string, and parse it into argc, argv. + */ void Win32ArgParser:: set_system_command_line() { LPWSTR command_line = GetCommandLineW(); set_command_line(command_line); } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::get_argv -// Access: Public -// Description: Returns the argv array as computed by -// set_command_line() or set_system_command_line(). -// This array indexes directly into data allocated -// within the Win32ArgParser object; it will remain -// valid until set_command_line() or clear() is again -// called, or until the parser object destructs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the argv array as computed by set_command_line() or + * set_system_command_line(). This array indexes directly into data allocated + * within the Win32ArgParser object; it will remain valid until + * set_command_line() or clear() is again called, or until the parser object + * destructs. + */ char **Win32ArgParser:: get_argv() { return _argv; } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::get_argc -// Access: Public -// Description: Returns the number of elements in the argv array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the argv array. + */ int Win32ArgParser:: get_argc() { return _argc; } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::do_glob -// Access: Public, Static -// Description: Returns true if we should attempt to process (and -// apply glob matching) to the command line, or false if -// we should not (for instance, because it has already -// been done by the shell). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we should attempt to process (and apply glob matching) to + * the command line, or false if we should not (for instance, because it has + * already been done by the shell). + */ bool Win32ArgParser:: do_glob() { - // First, we check for the PANDA_GLOB environment variable. If this - // is present, it overrides any other checks: "0" means not to do - // the glob, "1" means to do it. + // First, we check for the PANDA_GLOB environment variable. If this is + // present, it overrides any other checks: "0" means not to do the glob, "1" + // means to do it. string envvar = ExecutionEnvironment::get_environment_variable("PANDA_GLOB"); if (!envvar.empty()) { istringstream strm(envvar); @@ -177,16 +154,15 @@ do_glob() { } } - // Nothing explicit, so the default is to perform globbing only if - // we were launched from the Windows default command shell, cmd.exe. - // Presumably if we were launched from something else, like Python, - // the caller won't expect globbing to be performed; and if we were - // launched from a Cygwin shell, it will already have been - // performed. + // Nothing explicit, so the default is to perform globbing only if we were + // launched from the Windows default command shell, cmd.exe. Presumably if + // we were launched from something else, like Python, the caller won't + // expect globbing to be performed; and if we were launched from a Cygwin + // shell, it will already have been performed. - // Unfortunately, it is surprisingly difficult to determine the - // parent process in Windows. We have to enumerate all of the - // processes to find it. + // Unfortunately, it is surprisingly difficult to determine the parent + // process in Windows. We have to enumerate all of the processes to find + // it. HANDLE toolhelp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); @@ -208,8 +184,8 @@ do_glob() { Filename parent_exe; if (parent_id != -1) { - // Now we've got the parent process ID, go back through the list - // to get its process name. + // Now we've got the parent process ID, go back through the list to get + // its process name. if (Process32First(toolhelp, &entry)) { do { if (entry.th32ProcessID == parent_id) { @@ -229,13 +205,10 @@ do_glob() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::parse_quoted_arg -// Access: Private -// Description: Parses the quoted argument beginning at p and returns -// it. Advances p to the first character following the -// close quote. -//////////////////////////////////////////////////////////////////// +/** + * Parses the quoted argument beginning at p and returns it. Advances p to + * the first character following the close quote. + */ string Win32ArgParser:: parse_quoted_arg(const char *&p) { char quote = *p; @@ -246,8 +219,8 @@ parse_quoted_arg(const char *&p) { // TODO: handle caret? What does it mean? if (*p == '\\') { - // A backslash is an escape character only when it precedes a - // quote mark, or a series of backslashes precede a quote mark. + // A backslash is an escape character only when it precedes a quote + // mark, or a series of backslashes precede a quote mark. int num_slashes = 1; ++p; while (*p == '\\') { @@ -255,36 +228,32 @@ parse_quoted_arg(const char *&p) { ++num_slashes; } if (*p == quote) { - // A series of backslashes precede a quote mark. This means - // something special. First, each pair of backslashes means a - // single backslash. + // A series of backslashes precede a quote mark. This means something + // special. First, each pair of backslashes means a single backslash. for (int i = 0; i < num_slashes; i += 2) { result += '\\'; } - // And if there's no odd backslashes left over, we've reached - // the closing quote and we're done. + // And if there's no odd backslashes left over, we've reached the + // closing quote and we're done. if ((num_slashes & 1) == 0) { ++p; return result; } - - // But if there's an odd backslash, it simply escapes the - // quote mark. + + // But if there's an odd backslash, it simply escapes the quote mark. result += quote; ++p; } else { - // A series of backslashes not followed by a quote mark is - // interpreted literally, not even counting them by twos, per - // Win32's weird rules. + // A series of backslashes not followed by a quote mark is interpreted + // literally, not even counting them by twos, per Win32's weird rules. for (int i = 0; i < num_slashes; ++i) { result += '\\'; } } } else { - // Neither a backslash nor a quote mark, so just interpret it - // literally. + // Neither a backslash nor a quote mark, so just interpret it literally. result += *p; ++p; } @@ -297,13 +266,10 @@ parse_quoted_arg(const char *&p) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::parse_unquoted_arg -// Access: Private -// Description: Parses the unquoted argument beginning at p and saves -// it in _char_args. Advances p to the first whitespace -// following the argument. -//////////////////////////////////////////////////////////////////// +/** + * Parses the unquoted argument beginning at p and saves it in _char_args. + * Advances p to the first whitespace following the argument. + */ void Win32ArgParser:: parse_unquoted_arg(const char *&p) { string result; @@ -323,9 +289,9 @@ parse_unquoted_arg(const char *&p) { Filename filename = Filename::from_os_specific(result); GlobPattern glob(filename); if (!contains_quotes && glob.has_glob_characters()) { - // If the arg contains one or more glob characters (and no - // quotation marks), we attempt to expand the files. This means - // we interpret it as a Windows-specific filename. + // If the arg contains one or more glob characters (and no quotation + // marks), we attempt to expand the files. This means we interpret it as + // a Windows-specific filename. vector_string expand; if (glob.match_files(expand) != 0) { // The files matched. Add the expansions. @@ -335,25 +301,22 @@ parse_unquoted_arg(const char *&p) { save_arg(filename.to_os_specific()); } } else { - // There wasn't a match. Just add the original, unexpanded - // string, like bash does. + // There wasn't a match. Just add the original, unexpanded string, like + // bash does. save_arg(result); } - + } else { - // No glob characters means we just store it directly. Also, an - // embedded quoted string, anywhere within the arg, means we can't - // expand the glob characters. + // No glob characters means we just store it directly. Also, an embedded + // quoted string, anywhere within the arg, means we can't expand the glob + // characters. save_arg(result); } } -//////////////////////////////////////////////////////////////////// -// Function: Win32ArgParser::save_arg -// Access: Private -// Description: Stores the indicated string as the next argument in -// _args. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated string as the next argument in _args. + */ void Win32ArgParser:: save_arg(const string &arg) { _args.push_back(arg); diff --git a/dtool/src/dtoolutil/win32ArgParser.h b/dtool/src/dtoolutil/win32ArgParser.h index 46ea9a9353..505c6934cb 100644 --- a/dtool/src/dtoolutil/win32ArgParser.h +++ b/dtool/src/dtoolutil/win32ArgParser.h @@ -1,16 +1,15 @@ -// Filename: win32ArgParser.h -// Created by: drose (08Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file win32ArgParser.h + * @author drose + * @date 2011-11-08 + */ #ifndef WIN32ARGPARSER_H #define WIN32ARGPARSER_H @@ -24,16 +23,13 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : Win32ArgParser -// Description : This class is used to parse the single command-line -// string provided by Windows into the standard argc, -// argv array of strings. In this way it duplicates the -// functionality of Windows' own CommandLineToArgv() -// function, but it is also supports automatic expansion -// of glob filenames, e.g. *.egg is turned into an -// explicit list of egg files in the directory. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to parse the single command-line string provided by + * Windows into the standard argc, argv array of strings. In this way it + * duplicates the functionality of Windows' own CommandLineToArgv() function, + * but it is also supports automatic expansion of glob filenames, e.g. *.egg + * is turned into an explicit list of egg files in the directory. + */ class EXPCL_DTOOL Win32ArgParser { public: Win32ArgParser(); diff --git a/dtool/src/interrogate/functionRemap.cxx b/dtool/src/interrogate/functionRemap.cxx index c1f5f51c8b..a60da64576 100644 --- a/dtool/src/interrogate/functionRemap.cxx +++ b/dtool/src/interrogate/functionRemap.cxx @@ -1,16 +1,15 @@ -// Filename: functionRemap.cxx -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionRemap.cxx + * @author drose + * @date 2001-09-19 + */ #include "functionRemap.h" #include "typeManager.h" @@ -33,11 +32,9 @@ #include "interrogateType.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionRemap:: FunctionRemap(const InterrogateType &itype, const InterrogateFunction &ifunc, CPPInstance *cppfunc, int num_default_parameters, @@ -68,23 +65,18 @@ FunctionRemap(const InterrogateType &itype, const InterrogateFunction &ifunc, _is_valid = setup_properties(ifunc, interface_maker); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionRemap:: ~FunctionRemap() { } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::get_parameter_name -// Access: Public -// Description: Returns a string that will be a suitable name for the -// nth parameter in the generated code. This may not -// correspond to the name of the parameter in the -// original code. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that will be a suitable name for the nth parameter in the + * generated code. This may not correspond to the name of the parameter in + * the original code. + */ string FunctionRemap:: get_parameter_name(int n) const { ostringstream str; @@ -92,18 +84,14 @@ get_parameter_name(int n) const { return str.str(); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::call_function -// Access: Public -// Description: Writes a sequence of commands to the given output -// stream to call the wrapped function. The parameter -// values are assumed to be simply the names of the -// parameters. -// -// The return value is the expression to return, if we -// are returning a value, or the empty string if we -// return nothing. -//////////////////////////////////////////////////////////////////// +/** + * Writes a sequence of commands to the given output stream to call the + * wrapped function. The parameter values are assumed to be simply the names + * of the parameters. + * + * The return value is the expression to return, if we are returning a value, + * or the empty string if we return nothing. + */ string FunctionRemap:: call_function(ostream &out, int indent_level, bool convert_result, const string &container) const { @@ -114,17 +102,13 @@ call_function(ostream &out, int indent_level, bool convert_result, return call_function(out, indent_level, convert_result, container, pexprs); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::call_function -// Access: Public -// Description: Writes a sequence of commands to the given output -// stream to call the wrapped function. The parameter -// values are taken from pexprs. -// -// The return value is the expression to return, if we -// are returning a value, or the empty string if we -// return nothing. -//////////////////////////////////////////////////////////////////// +/** + * Writes a sequence of commands to the given output stream to call the + * wrapped function. The parameter values are taken from pexprs. + * + * The return value is the expression to return, if we are returning a value, + * or the empty string if we return nothing. + */ string FunctionRemap:: call_function(ostream &out, int indent_level, bool convert_result, const string &container, const vector_string &pexprs) const { @@ -161,10 +145,9 @@ call_function(ostream &out, int indent_level, bool convert_result, } } else if (_type == T_typecast) { - // A regular typecast converts from a pointer type to another - // pointer type. (This is different from the typecast method, - // above, which converts from the concrete type to some other - // type.) + // A regular typecast converts from a pointer type to another pointer + // type. (This is different from the typecast method, above, which + // converts from the concrete type to some other type.) assert(!container.empty()); string cast_expr = "(" + _return_type->get_orig_type()->get_local_name(&parser) + @@ -230,16 +213,16 @@ call_function(ostream &out, int indent_level, bool convert_result, _return_type->prepare_return_expr(out, indent_level, ref_expr); return_expr = _return_type->get_return_expr(new_str); - // Now a simple special-case test. Often, we will have converted - // the reference-returning assignment operator to a pointer. In - // this case, we might inadvertently generate code like "return - // &(*this)", when "return this" would do. We check for this here - // and undo it as a special case. + // Now a simple special-case test. Often, we will have converted the + // reference-returning assignment operator to a pointer. In this case, + // we might inadvertently generate code like "return &(*this)", when + // "return this" would do. We check for this here and undo it as a + // special case. - // There's no real good reason to do this, other than that it - // feels more satisfying to a casual perusal of the generated - // code. It *is* conceivable that some broken compilers wouldn't - // like "&(*this)", though. + // There's no real good reason to do this, other than that it feels more + // satisfying to a casual perusal of the generated code. It *is* + // conceivable that some broken compilers wouldn't like "&(*this)", + // though. if (return_expr == "&(" + ref_expr + ")" || return_expr == "&" + ref_expr) { @@ -258,21 +241,21 @@ call_function(ostream &out, int indent_level, bool convert_result, return_expr = call; } else { - //if (_return_type->return_value_should_be_simple()) { + // if (_return_type->return_value_should_be_simple()) { if (false) { - // We have to assign the result to a temporary first; this makes - // it a bit easier on poor old VC++. + // We have to assign the result to a temporary first; this makes it a + // bit easier on poor old VC++. InterfaceMaker::indent(out, indent_level); _return_type->get_orig_type()->output_instance(out, "result", &parser); out << " = " << call << ";\n"; - // MOVE() expands to std::move() when we are compiling with a - // compiler that supports rvalue references. It basically turns - // an lvalue into an rvalue, allowing a move constructor to be - // called instead of a copy constructor (since we won't be using - // the return value any more), which is usually more efficient if - // it exists. If it doesn't, it shouldn't do any harm. + // MOVE() expands to std::move() when we are compiling with a compiler + // that supports rvalue references. It basically turns an lvalue into + // an rvalue, allowing a move constructor to be called instead of a + // copy constructor (since we won't be using the return value any + // more), which is usually more efficient if it exists. If it + // doesn't, it shouldn't do any harm. string new_str = _return_type->prepare_return_expr(out, indent_level, "MOVE(result)"); return_expr = _return_type->get_return_expr(new_str); @@ -289,13 +272,10 @@ call_function(ostream &out, int indent_level, bool convert_result, return return_expr; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::write_orig_prototype -// Access: Public -// Description: Writes a line describing the original C++ method or -// function. This is generally useful only within a -// comment. -//////////////////////////////////////////////////////////////////// +/** + * Writes a line describing the original C++ method or function. This is + * generally useful only within a comment. + */ void FunctionRemap:: write_orig_prototype(ostream &out, int indent_level, bool local, int num_default_args) const { if (local) { @@ -305,13 +285,10 @@ write_orig_prototype(ostream &out, int indent_level, bool local, int num_default } } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::make_wrapper_entry -// Access: Public -// Description: Creates an InterrogateFunctionWrapper object -// corresponding to this callable instance and stores it -// in the database. -//////////////////////////////////////////////////////////////////// +/** + * Creates an InterrogateFunctionWrapper object corresponding to this callable + * instance and stores it in the database. + */ FunctionWrapperIndex FunctionRemap:: make_wrapper_entry(FunctionIndex function_index) { _wrapper_index = @@ -376,15 +353,13 @@ make_wrapper_entry(FunctionIndex function_index) { iwrapper._return_value_destructor = destructor; } else { - // We don't need to report this warning, since the FFI code - // understands that if the destructor function is zero, it - // should use the regular class destructor. + // We don't need to report this warning, since the FFI code understands + // that if the destructor function is zero, it should use the regular + // class destructor. - // nout << "Warning! Destructor for " - // << *_return_type->get_orig_type() - // << " is unavailable.\n" - // << " Cannot manage return value for:\n " - // << description << "\n"; + // nout << "Warning! Destructor for " << *_return_type->get_orig_type() + // << " is unavailable.\n" << " Cannot manage return value for:\n " << + // description << "\n"; } } @@ -392,14 +367,11 @@ make_wrapper_entry(FunctionIndex function_index) { return _wrapper_index; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::get_call_str -// Access: Public -// Description: Returns a string suitable for calling the wrapped -// function. If pexprs is nonempty, it represents -// the list of expressions that will evaluate to each -// parameter value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string suitable for calling the wrapped function. If pexprs is + * nonempty, it represents the list of expressions that will evaluate to each + * parameter value. + */ string FunctionRemap:: get_call_str(const string &container, const vector_string &pexprs) const { // Build up the call to the actual function. @@ -439,8 +411,8 @@ get_call_str(const string &container, const vector_string &pexprs) const { } else { const char *separator = ""; - // If this function is marked as having an extension function, - // call that instead. + // If this function is marked as having an extension function, call that + // instead. if (_extension) { if (!container.empty()) { call << "invoke_extension(" << container << ")."; @@ -460,8 +432,8 @@ get_call_str(const string &container, const vector_string &pexprs) const { call << _cpptype->get_local_name(&parser); } else if (_has_this && !container.empty()) { - // If we have a "this" parameter, the calling convention is also - // a bit different. + // If we have a "this" parameter, the calling convention is also a bit + // different. call << "("; _parameters[0]._remap->pass_parameter(call, container); call << ")." << _cppfunc->get_local_name(); @@ -504,12 +476,10 @@ get_call_str(const string &container, const vector_string &pexprs) const { return call.str(); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::get_min_num_args -// Access: Private -// Description: Returns the minimum number of arguments that needs -// to be passed to this function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of arguments that needs to be passed to this + * function. + */ int FunctionRemap:: get_min_num_args() const { int min_num_args = 0; @@ -530,12 +500,10 @@ get_min_num_args() const { return min_num_args; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::get_max_num_args -// Access: Private -// Description: Returns the maximum number of arguments that can -// be passed to this function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of arguments that can be passed to this + * function. + */ int FunctionRemap:: get_max_num_args() const { int max_num_args = _parameters.size(); @@ -545,14 +513,11 @@ get_max_num_args() const { return max_num_args; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::get_parameter_expr -// Access: Private -// Description: Returns a string that represents the expression -// associated with the nth parameter. This is just the -// nth element of pexprs if it is nonempty, or the name -// of the nth parameter is it is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that represents the expression associated with the nth + * parameter. This is just the nth element of pexprs if it is nonempty, or + * the name of the nth parameter is it is empty. + */ string FunctionRemap:: get_parameter_expr(size_t n, const vector_string &pexprs) const { if (n < pexprs.size()) { @@ -561,13 +526,10 @@ get_parameter_expr(size_t n, const vector_string &pexprs) const { return get_parameter_name(n); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionRemap::setup_properties -// Access: Private -// Description: Sets up the properties of the function appropriately. -// Returns true if successful, or false if there is -// something unacceptable about the function. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the properties of the function appropriately. Returns true if + * successful, or false if there is something unacceptable about the function. + */ bool FunctionRemap:: setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_maker) { _function_signature = @@ -609,15 +571,15 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak ((_cppfunc->_storage_class & CPPInstance::SC_static) == 0) && _type != T_constructor) { - // If this is a method, but not a static method, and not a - // constructor, then we need a "this" parameter. + // If this is a method, but not a static method, and not a constructor, + // then we need a "this" parameter. _has_this = true; _const_method = (_ftype->_flags & CPPFunctionType::F_const_method) != 0; if (interface_maker->synthesize_this_parameter()) { - // If the interface_maker demands it, the "this" parameter is treated - // as any other parameter, and inserted at the beginning of the - // parameter list. + // If the interface_maker demands it, the "this" parameter is treated as + // any other parameter, and inserted at the beginning of the parameter + // list. Parameter param; param._name = "this"; param._has_name = true; @@ -627,13 +589,13 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } else { param._remap = interface_maker->remap_parameter(_cpptype, _cpptype); } - // param._remap = new ParameterRemapThis(_cpptype, _const_method); + // param._remap = new ParameterRemapThis(_cpptype, _const_method); _parameters.push_back(param); _first_true_parameter = 1; } - // Also check the name of the function. If it's one of the - // assignment-style operators, flag it as such. + // Also check the name of the function. If it's one of the assignment- + // style operators, flag it as such. if (fname == "operator =" || fname == "operator *=" || fname == "operator /=" || @@ -660,15 +622,15 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak const CPPParameterList::Parameters ¶ms = _ftype->_parameters->_parameters; for (int i = 0; i < (int)params.size() - _num_default_parameters; i++) { - //CPPType *type = params[i]->_type->resolve_type(&parser, _cppscope); + // CPPType *type = params[i]->_type->resolve_type(&parser, _cppscope); CPPType *type = params[i]->_type; Parameter param; param._has_name = true; param._name = params[i]->get_simple_name(); if (param._name.empty()) { - // If the parameter has no name, record it as being nameless, - // but also synthesize one in case someone asks anyway. + // If the parameter has no name, record it as being nameless, but also + // synthesize one in case someone asks anyway. param._has_name = false; ostringstream param_name; param_name << "param" << i; @@ -677,13 +639,14 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak param._remap = interface_maker->remap_parameter(_cpptype, type); if (param._remap == (ParameterRemap *)NULL) { - // If we can't handle one of the parameter types, we can't call - // the function. + // If we can't handle one of the parameter types, we can't call the + // function. if (fname == "__traverse__") { // Hack to record this even though we can't wrap visitproc. param._remap = new ParameterRemapUnchanged(type); } else { - //nout << "Can't handle parameter " << i << " of method " << *_cppfunc << "\n"; + // nout << "Can't handle parameter " << i << " of method " << + // *_cppfunc << "\n"; return false; } } else { @@ -699,9 +662,9 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } if (_type == T_constructor) { - // Constructors are a special case. These appear to return void - // as seen by the parser, but we know they actually return a new - // concrete instance. + // Constructors are a special case. These appear to return void as seen + // by the parser, but we know they actually return a new concrete + // instance. if (_cpptype == (CPPType *)NULL) { nout << "Method " << *_cppfunc << " has no struct type\n"; @@ -714,9 +677,9 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (_type == T_assignment_method) { - // Assignment-type methods are also a special case. We munge - // these to return *this, which is a semi-standard C++ convention - // anyway. We just enforce it. + // Assignment-type methods are also a special case. We munge these to + // return *this, which is a semi-standard C++ convention anyway. We just + // enforce it. if (_cpptype == (CPPType *)NULL) { nout << "Method " << *_cppfunc << " has no struct type\n"; @@ -730,8 +693,8 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } } else if (_type == T_item_assignment_operator) { - // An item-assignment method isn't really a thing in C++, but it is - // in scripting languages, so we use this to denote item-access operators + // An item-assignment method isn't really a thing in C++, but it is in + // scripting languages, so we use this to denote item-access operators // that return a non-const reference. if (_cpptype == (CPPType *)NULL) { @@ -770,8 +733,8 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_return_type == (ParameterRemap *)NULL || !_return_type->is_valid()) { - // If our return type isn't something we can deal with, treat the - // function as if it returns NULL. + // If our return type isn't something we can deal with, treat the function + // as if it returns NULL. _void_return = true; _ForcedVoidReturn = true; CPPType *void_type = TypeManager::get_void_type(); @@ -797,9 +760,9 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak _manage_reference_count = true; _return_value_needs_management = true; - // This is problematic, because we might not have the class in - // question fully defined here, particularly if the class is - // defined in some other library. + // This is problematic, because we might not have the class in question + // fully defined here, particularly if the class is defined in some other + // library. _return_value_destructor = builder.get_destructor_for(return_meat_type); } @@ -812,10 +775,10 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak if (_has_this || _type == T_constructor) { if (_parameters.size() > (size_t)first_param && _parameters[first_param]._name == "self" && TypeManager::is_pointer_to_PyObject(_parameters[first_param]._remap->get_orig_type())) { - // Here's a special case. If the first parameter of a nonstatic - // method is a PyObject * called "self", then we will - // automatically fill it in from the this pointer, and remove it - // from the generated parameter list. + // Here's a special case. If the first parameter of a nonstatic method + // is a PyObject * called "self", then we will automatically fill it in + // from the this pointer, and remove it from the generated parameter + // list. _parameters.erase(_parameters.begin() + first_param); _flags |= F_explicit_self; } @@ -920,8 +883,8 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak } else { if (_args_type == InterfaceMaker::AT_varargs) { - // Every other method can take keyword arguments, if they - // take more than one argument. + // Every other method can take keyword arguments, if they take more + // than one argument. _args_type = InterfaceMaker::AT_keyword_args; } } diff --git a/dtool/src/interrogate/functionRemap.h b/dtool/src/interrogate/functionRemap.h index aa63dfb905..72e18cf09e 100644 --- a/dtool/src/interrogate/functionRemap.h +++ b/dtool/src/interrogate/functionRemap.h @@ -1,16 +1,15 @@ -// Filename: functionRemap.h -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionRemap.h + * @author drose + * @date 2001-09-19 + */ #ifndef FUNCTIONREMAP_H #define FUNCTIONREMAP_H @@ -33,16 +32,14 @@ class CPPScope; class CPPFunctionType; class InterfaceMaker; -//////////////////////////////////////////////////////////////////// -// Class : FunctionRemap -// Description : This class describes how to remap a C++ function (and -// its list of parameters and return type) to a wrapped -// function, for a particular scripting language. -// -// The InterfaceMaker class will create one of these for -// each function, including one for each instance of an -// overloaded function. -//////////////////////////////////////////////////////////////////// +/** + * This class describes how to remap a C++ function (and its list of + * parameters and return type) to a wrapped function, for a particular + * scripting language. + * + * The InterfaceMaker class will create one of these for each function, + * including one for each instance of an overloaded function. + */ class FunctionRemap { public: FunctionRemap(const InterrogateType &itype, diff --git a/dtool/src/interrogate/functionWriter.cxx b/dtool/src/interrogate/functionWriter.cxx index 24f7176e95..6a5c3e4e34 100644 --- a/dtool/src/interrogate/functionWriter.cxx +++ b/dtool/src/interrogate/functionWriter.cxx @@ -1,52 +1,43 @@ -// Filename: functionWriter.cxx -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriter.cxx + * @author drose + * @date 2001-09-14 + */ #include "functionWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriter:: FunctionWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriter:: ~FunctionWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const string &FunctionWriter:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::compare_to -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int FunctionWriter:: compare_to(const FunctionWriter &other) const { // Lexicographical string comparison. @@ -70,20 +61,16 @@ compare_to(const FunctionWriter &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::write_prototype -// Access: Public, Virtual -// Description: Outputs the prototype for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the prototype for the function. + */ void FunctionWriter:: write_prototype(ostream &) { } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriter::write_code -// Access: Public, Virtual -// Description: Outputs the code for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the code for the function. + */ void FunctionWriter:: write_code(ostream &) { } diff --git a/dtool/src/interrogate/functionWriter.h b/dtool/src/interrogate/functionWriter.h index 0a413254d3..11d4c90252 100644 --- a/dtool/src/interrogate/functionWriter.h +++ b/dtool/src/interrogate/functionWriter.h @@ -1,29 +1,26 @@ -// Filename: functionWriter.h -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriter.h + * @author drose + * @date 2001-09-14 + */ #ifndef FUNCTIONWRITER_H #define FUNCTIONWRITER_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : FunctionWriter -// Description : This is an abstract class that can be used by the -// various InterfaceMakers to indicate a generic helper -// function or variable that needs to be written to the -// generated source file. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class that can be used by the various InterfaceMakers + * to indicate a generic helper function or variable that needs to be written + * to the generated source file. + */ class FunctionWriter { public: FunctionWriter(); diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.cxx b/dtool/src/interrogate/functionWriterPtrFromPython.cxx index 7bed0fdebe..d39d5f47dd 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrFromPython.cxx @@ -1,16 +1,15 @@ -// Filename: functionWriterPtrFromPython.cxx -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriterPtrFromPython.cxx + * @author drose + * @date 2001-09-14 + */ #include "functionWriterPtrFromPython.h" #include "typeManager.h" @@ -19,36 +18,30 @@ #include "cppPointerType.h" -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriterPtrFromPython:: FunctionWriterPtrFromPython(CPPType *type) { _type = TypeManager::unwrap_const(TypeManager::unwrap_pointer(type)); - _name = - "from_python_" + + _name = + "from_python_" + InterrogateBuilder::clean_identifier(_type->get_local_name(&parser)); _pointer_type = new CPPPointerType(_type); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriterPtrFromPython:: ~FunctionWriterPtrFromPython() { delete _pointer_type; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::write_prototype -// Access: Public, Virtual -// Description: Outputs the prototype for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the prototype for the function. + */ void FunctionWriterPtrFromPython:: write_prototype(ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); @@ -56,15 +49,13 @@ write_prototype(ostream &out) { out << "static int " << _name << "(PyObject *obj, "; ppointer->output_instance(out, "addr", &parser); out << ");\n"; - + delete ppointer; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::write_code -// Access: Public, Virtual -// Description: Outputs the code for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the code for the function. + */ void FunctionWriterPtrFromPython:: write_code(ostream &out) { CPPType *ppointer = new CPPPointerType(_pointer_type); @@ -74,7 +65,8 @@ write_code(ostream &out) { ppointer->output_instance(out, "addr", &parser); out << ") {\n" << " if (obj != (PyObject *)NULL && PyInstance_Check(obj)) {\n" - // << " PyClassObject *in_class = ((PyInstanceObject *)obj)->in_class;\n" + // << " PyClassObject *in_class = ((PyInstanceObject + // *)obj)->in_class;\n" << " PyObject *in_dict = ((PyInstanceObject *)obj)->in_dict;\n" << " if (in_dict != (PyObject *)NULL && PyDict_Check(in_dict)) {\n" << " PyObject *thisobj = PyDict_GetItemString(in_dict, \"this\");\n" @@ -87,26 +79,21 @@ write_code(ostream &out) { << " }\n" << " return 0;\n" << "}\n\n"; - + delete ppointer; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::get_type -// Access: Public -// Description: Returns the type that represents the actual data type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type that represents the actual data type. + */ CPPType *FunctionWriterPtrFromPython:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrFromPython::get_pointer_type -// Access: Public -// Description: Returns the type that represents a pointer to the -// data type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type that represents a pointer to the data type. + */ CPPType *FunctionWriterPtrFromPython:: get_pointer_type() const { return _pointer_type; diff --git a/dtool/src/interrogate/functionWriterPtrFromPython.h b/dtool/src/interrogate/functionWriterPtrFromPython.h index f566d7ca90..36f59fa955 100644 --- a/dtool/src/interrogate/functionWriterPtrFromPython.h +++ b/dtool/src/interrogate/functionWriterPtrFromPython.h @@ -1,16 +1,15 @@ -// Filename: functionWriterPtrFromPython.h -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriterPtrFromPython.h + * @author drose + * @date 2001-09-14 + */ #ifndef FUNCTIONWRITERPTRFROMPYTHON_H #define FUNCTIONWRITERPTRFROMPYTHON_H @@ -19,13 +18,11 @@ class CPPType; -//////////////////////////////////////////////////////////////////// -// Class : FunctionWriterPtrFromPython -// Description : This specialization of FunctionWriter generates a -// function that converts a PyObject pointer -// representing a class wrapper object to the -// corresponding C++ pointer. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of FunctionWriter generates a function that converts a + * PyObject pointer representing a class wrapper object to the corresponding + * C++ pointer. + */ class FunctionWriterPtrFromPython : public FunctionWriter { public: FunctionWriterPtrFromPython(CPPType *type); diff --git a/dtool/src/interrogate/functionWriterPtrToPython.cxx b/dtool/src/interrogate/functionWriterPtrToPython.cxx index 4c26c294cb..23a8304528 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.cxx +++ b/dtool/src/interrogate/functionWriterPtrToPython.cxx @@ -1,16 +1,15 @@ -// Filename: functionWriterPtrToPython.cxx -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriterPtrToPython.cxx + * @author drose + * @date 2001-09-14 + */ #include "functionWriterPtrToPython.h" #include "typeManager.h" @@ -20,36 +19,30 @@ #include "cppPointerType.h" -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrToPython::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriterPtrToPython:: FunctionWriterPtrToPython(CPPType *type) { _type = TypeManager::unwrap_const(TypeManager::unwrap_pointer(type)); - _name = - "to_python_" + + _name = + "to_python_" + InterrogateBuilder::clean_identifier(_type->get_local_name(&parser)); _pointer_type = new CPPPointerType(_type); } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrToPython::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriterPtrToPython:: ~FunctionWriterPtrToPython() { delete _pointer_type; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrToPython::write_prototype -// Access: Public, Virtual -// Description: Outputs the prototype for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the prototype for the function. + */ void FunctionWriterPtrToPython:: write_prototype(ostream &out) { out << "static PyObject *" << _name << "("; @@ -57,11 +50,9 @@ write_prototype(ostream &out) { out << ", int caller_manages);\n"; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrToPython::write_code -// Access: Public, Virtual -// Description: Outputs the code for the function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the code for the function. + */ void FunctionWriterPtrToPython:: write_code(ostream &out) { string classobj_func = InterfaceMakerPythonObj::get_builder_name(_type); @@ -80,12 +71,9 @@ write_code(ostream &out) { << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriterPtrToPython::get_pointer_type -// Access: Public -// Description: Returns the type that represents a pointer to the -// data type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type that represents a pointer to the data type. + */ CPPType *FunctionWriterPtrToPython:: get_pointer_type() const { return _pointer_type; diff --git a/dtool/src/interrogate/functionWriterPtrToPython.h b/dtool/src/interrogate/functionWriterPtrToPython.h index 6a2cb4f386..d36e025da1 100644 --- a/dtool/src/interrogate/functionWriterPtrToPython.h +++ b/dtool/src/interrogate/functionWriterPtrToPython.h @@ -1,16 +1,15 @@ -// Filename: functionWriterPtrToPython.h -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriterPtrToPython.h + * @author drose + * @date 2001-09-14 + */ #ifndef FUNCTIONWRITERPTRTOPYTHON_H #define FUNCTIONWRITERPTRTOPYTHON_H @@ -19,12 +18,10 @@ class CPPType; -//////////////////////////////////////////////////////////////////// -// Class : FunctionWriterPtrToPython -// Description : This specialization of FunctionWriter generates a -// function that generates a PyObject class wrapper -// object around the corresponding C++ pointer. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of FunctionWriter generates a function that generates a + * PyObject class wrapper object around the corresponding C++ pointer. + */ class FunctionWriterPtrToPython : public FunctionWriter { public: FunctionWriterPtrToPython(CPPType *type); diff --git a/dtool/src/interrogate/functionWriters.cxx b/dtool/src/interrogate/functionWriters.cxx index e69dc92f86..93ee5945fc 100644 --- a/dtool/src/interrogate/functionWriters.cxx +++ b/dtool/src/interrogate/functionWriters.cxx @@ -1,33 +1,28 @@ -// Filename: functionWriters.cxx -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriters.cxx + * @author drose + * @date 2001-09-14 + */ #include "functionWriters.h" -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriters::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriters:: FunctionWriters() { } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriters::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FunctionWriters:: ~FunctionWriters() { Writers::iterator wi; @@ -36,17 +31,14 @@ FunctionWriters:: } } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriters::add_writer -// Access: Public -// Description: Adds the indicated FunctionWriter to the set of -// functions to be written, unless there is already a -// matching FunctionWriter. -// -// The return value is the FunctionWriter pointer that -// was added to the set, which may be the same pointer -// or a previously-allocated (but equivalent) pointer. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated FunctionWriter to the set of functions to be written, + * unless there is already a matching FunctionWriter. + * + * The return value is the FunctionWriter pointer that was added to the set, + * which may be the same pointer or a previously-allocated (but equivalent) + * pointer. + */ FunctionWriter *FunctionWriters:: add_writer(FunctionWriter *writer) { pair result = _writers.insert(writer); @@ -59,11 +51,9 @@ add_writer(FunctionWriter *writer) { return *result.first; } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriters::write_prototypes -// Access: Public -// Description: Generates prototypes for all of the functions. -//////////////////////////////////////////////////////////////////// +/** + * Generates prototypes for all of the functions. + */ void FunctionWriters:: write_prototypes(ostream &out) { Writers::iterator wi; @@ -73,11 +63,9 @@ write_prototypes(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: FunctionWriters::write_code -// Access: Public -// Description: Generates all of the functions. -//////////////////////////////////////////////////////////////////// +/** + * Generates all of the functions. + */ void FunctionWriters:: write_code(ostream &out) { Writers::iterator wi; diff --git a/dtool/src/interrogate/functionWriters.h b/dtool/src/interrogate/functionWriters.h index ce4be1513e..0db121de10 100644 --- a/dtool/src/interrogate/functionWriters.h +++ b/dtool/src/interrogate/functionWriters.h @@ -1,16 +1,15 @@ -// Filename: functionWriters.h -// Created by: drose (14Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file functionWriters.h + * @author drose + * @date 2001-09-14 + */ #ifndef FUNCTIONWRITERS_H #define FUNCTIONWRITERS_H @@ -20,13 +19,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : FunctionWriters -// Description : A set of zero or more FunctionWriter pointers -// accumulated by the various InterfaceMaker objects -// that are generating code for one particular output -// source file. -//////////////////////////////////////////////////////////////////// +/** + * A set of zero or more FunctionWriter pointers accumulated by the various + * InterfaceMaker objects that are generating code for one particular output + * source file. + */ class FunctionWriters { public: FunctionWriters(); diff --git a/dtool/src/interrogate/interfaceMaker.cxx b/dtool/src/interrogate/interfaceMaker.cxx index e9975786c9..6a7c63e40f 100644 --- a/dtool/src/interrogate/interfaceMaker.cxx +++ b/dtool/src/interrogate/interfaceMaker.cxx @@ -1,16 +1,15 @@ -// Filename: interfaceMaker.cxx -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMaker.cxx + * @author drose + * @date 2001-09-19 + */ #include "interfaceMaker.h" #include "interrogateBuilder.h" @@ -42,11 +41,9 @@ InterrogateType dummy_type; -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Function::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::Function:: Function(const string &name, const InterrogateType &itype, @@ -60,11 +57,9 @@ Function(const string &name, _args_type = AT_unknown; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Function::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::Function:: ~Function() { Remaps::iterator ri; @@ -73,11 +68,9 @@ InterfaceMaker::Function:: } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::MakeSeq::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::MakeSeq:: MakeSeq(const string &name, const InterrogateMakeSeq &imake_seq) : _name(name), @@ -87,11 +80,9 @@ MakeSeq(const string &name, const InterrogateMakeSeq &imake_seq) : { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Property::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::Property:: Property(const InterrogateElement &ielement) : _ielement(ielement), @@ -102,11 +93,9 @@ Property(const InterrogateElement &ielement) : { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Object::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::Object:: Object(const InterrogateType &itype) : _itype(itype), @@ -114,23 +103,18 @@ Object(const InterrogateType &itype) : { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Object::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker::Object:: ~Object() { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Object::check_protocols -// Access: Public -// Description: To be called after all of the methods have been -// added, this checks which protocols this object -// appears to support (based on the methods it -// provides). -//////////////////////////////////////////////////////////////////// +/** + * To be called after all of the methods have been added, this checks which + * protocols this object appears to support (based on the methods it + * provides). + */ void InterfaceMaker::Object:: check_protocols() { int flags = 0; @@ -145,17 +129,17 @@ check_protocols() { flags |= func->_flags; if (func->_ifunc.get_name() == "__traverse__") { - // If we have a method named __traverse__, we implement Python's - // cyclic garbage collection protocol. + // If we have a method named __traverse__, we implement Python's cyclic + // garbage collection protocol. _protocol_types |= PT_python_gc; } } if ((flags & (FunctionRemap::F_getitem_int | FunctionRemap::F_size)) == (FunctionRemap::F_getitem_int | FunctionRemap::F_size)) { - // If we have both a getitem that receives an int, and a size, - // then we implement the sequence protocol: you can iterate - // through the elements of this object. + // If we have both a getitem that receives an int, and a size, then we + // implement the sequence protocol: you can iterate through the elements + // of this object. _protocol_types |= PT_sequence; } else if (flags & FunctionRemap::F_getitem) { @@ -164,9 +148,9 @@ check_protocols() { } if (flags & FunctionRemap::F_make_copy) { - // It's not exactly a protocol, but if we have a make_copy() - // method, we can use it to synthesize a __copy__ and __deepcopy__ - // Python method to support the copy module. + // It's not exactly a protocol, but if we have a make_copy() method, we + // can use it to synthesize a __copy__ and __deepcopy__ Python method to + // support the copy module. _protocol_types |= PT_make_copy; } else if (flags & FunctionRemap::F_copy_constructor) { // Ditto for the copy constructor. @@ -178,14 +162,11 @@ check_protocols() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Object::is_static_method -// Access: Public -// Description: Returns true if the first method found with the -// indicated name is a static method, false if it is an -// instance method. This does not test all overloads of -// the indicated name, merely the first one found. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the first method found with the indicated name is a static + * method, false if it is an instance method. This does not test all + * overloads of the indicated name, merely the first one found. + */ bool InterfaceMaker::Object:: is_static_method(const string &name) { Functions::const_iterator fi; @@ -204,22 +185,18 @@ is_static_method(const string &name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker:: InterfaceMaker(InterrogateModuleDef *def) : _def(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMaker:: ~InterfaceMaker() { Objects::iterator oi; @@ -233,22 +210,17 @@ InterfaceMaker:: } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::generate_wrappers -// Access: Public, Virtual -// Description: Walks through the set of functions in the database -// and generates wrappers for each function, storing -// these in the database. No actual code should be -// output yet; this just updates the database with the -// wrapper information. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the set of functions in the database and generates wrappers + * for each function, storing these in the database. No actual code should be + * output yet; this just updates the database with the wrapper information. + */ void InterfaceMaker:: generate_wrappers() { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - // We use a while loop rather than a simple for loop, because we - // might increase the number of types recursively during the - // traversal. + // We use a while loop rather than a simple for loop, because we might + // increase the number of types recursively during the traversal. int ti = 0; while (ti < idb->get_num_all_types()) { TypeIndex type_index = idb->get_all_type(ti++); @@ -296,62 +268,47 @@ generate_wrappers() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::write_includes -// Access: Public, Virtual -// Description: Generates the list of #include ... whatever that's -// required by this particular interface to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of #include ... whatever that's required by this + * particular interface to the indicated output stream. + */ void InterfaceMaker:: write_includes(ostream &) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::write_prototypes -// Access: Public, Virtual -// Description: Generates the list of function prototypes -// corresponding to the functions that will be output in -// write_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of function prototypes corresponding to the functions + * that will be output in write_functions(). + */ void InterfaceMaker:: write_prototypes(ostream &out,ostream *out_h) { _function_writers.write_prototypes(out); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::write_functions -// Access: Public, Virtual -// Description: Generates the list of functions that are appropriate -// for this interface. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of functions that are appropriate for this interface. + */ void InterfaceMaker:: write_functions(ostream &out) { _function_writers.write_code(out); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::write_module -// Access: Public, Virtual -// Description: Generates whatever additional code is required to -// support a module file. -//////////////////////////////////////////////////////////////////// +/** + * Generates whatever additional code is required to support a module file. + */ void InterfaceMaker:: write_module(ostream &, ostream *out_h, InterrogateModuleDef *) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::remap_parameter -// Access: Public, Virtual -// Description: Allocates a new ParameterRemap object suitable to the -// indicated parameter type. If struct_type is -// non-NULL, it is the type of the enclosing class for -// the function (method) in question. -// -// The return value is a newly-allocated ParameterRemap -// object, if the parameter type is acceptable, or NULL -// if the parameter type cannot be handled. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new ParameterRemap object suitable to the indicated parameter + * type. If struct_type is non-NULL, it is the type of the enclosing class + * for the function (method) in question. + * + * The return value is a newly-allocated ParameterRemap object, if the + * parameter type is acceptable, or NULL if the parameter type cannot be + * handled. + */ ParameterRemap *InterfaceMaker:: remap_parameter(CPPType *struct_type, CPPType *param_type) { nassertr(param_type != NULL, NULL); @@ -364,8 +321,8 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { return new ParameterRemapWCharStarToWString(param_type); } - // If we're exporting a method of basic_string itself, don't - // convert basic_string's to atomic strings. + // If we're exporting a method of basic_string itself, don't convert + // basic_string's to atomic strings. if (struct_type == (CPPType *)NULL || !(TypeManager::is_basic_string_char(struct_type) || @@ -393,8 +350,8 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { } else if (TypeManager::is_reference(param_type) || TypeManager::is_pointer(param_type)) { - // Python strings are immutable, so we can't wrap a non-const - // pointer or reference to a string. + // Python strings are immutable, so we can't wrap a non-const pointer + // or reference to a string. CPPType *pt_type = TypeManager::unwrap(param_type); if (TypeManager::is_basic_string_char(pt_type) || TypeManager::is_basic_string_wchar(pt_type)) { @@ -410,8 +367,8 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { { CPPType *pt_type = TypeManager::unwrap_reference(param_type); - // Don't convert PointerTo<>'s to pointers for methods of the - // PointerTo itself! + // Don't convert PointerTo<>'s to pointers for methods of the PointerTo + // itself! if (struct_type == (CPPType *)NULL || !(pt_type->get_local_name(&parser) == struct_type->get_local_name(&parser))) { return new ParameterRemapPTToPointer(param_type); @@ -430,8 +387,8 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { return new ParameterRemapEnumToInt(param_type); */ - //} else if (TypeManager::is_const_simple(param_type)) { - // return new ParameterRemapConstToNonConst(param_type); + // } else if (TypeManager::is_const_simple(param_type)) { return new + // ParameterRemapConstToNonConst(param_type); } else if (TypeManager::is_const_ref_to_simple(param_type)) { return new ParameterRemapReferenceToConcrete(param_type); @@ -448,57 +405,44 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::synthesize_this_parameter -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require the implicit -// "this" parameter, if present, to be passed as the -// first parameter to any wrapper functions. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require the implicit "this" parameter, if present, to be + * passed as the first parameter to any wrapper functions. + */ bool InterfaceMaker:: synthesize_this_parameter() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::separate_overloading -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require overloaded -// instances of a function to be defined as separate -// functions (each with its own hashed name), or false -// for interfaces that can support overloading natively, -// and thus only require one wrapper function per each -// overloaded input function. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require overloaded instances of a function to be defined as + * separate functions (each with its own hashed name), or false for interfaces + * that can support overloading natively, and thus only require one wrapper + * function per each overloaded input function. + */ bool InterfaceMaker:: separate_overloading() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::wrap_global_functions -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return false for interfaces that don't support -// global functions and should therefore will only -// accept function remaps that have a class associated. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return false for + * interfaces that don't support global functions and should therefore will + * only accept function remaps that have a class associated. + */ bool InterfaceMaker:: wrap_global_functions() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::get_function_remaps -// Access: Public -// Description: Fills up the indicated vector with all of the -// FunctionRemap pointers created by this -// InterfaceMaker. It is the user's responsibility to -// empty the vector before calling this function; the -// new pointers will simply be added to the end. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated vector with all of the FunctionRemap pointers + * created by this InterfaceMaker. It is the user's responsibility to empty + * the vector before calling this function; the new pointers will simply be + * added to the end. + */ void InterfaceMaker:: get_function_remaps(vector &remaps) { FunctionsByIndex::iterator fi; @@ -512,11 +456,9 @@ get_function_remaps(vector &remaps) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::indent -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &InterfaceMaker:: indent(ostream &out, int indent_level) { for (int i = 0; i < indent_level; i++) { @@ -525,12 +467,10 @@ indent(ostream &out, int indent_level) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::make_function_remap -// Access: Protected, Virtual -// Description: Creates a FunctionRemap object corresponding to the -// particular function wrapper. -//////////////////////////////////////////////////////////////////// +/** + * Creates a FunctionRemap object corresponding to the particular function + * wrapper. + */ FunctionRemap *InterfaceMaker:: make_function_remap(const InterrogateType &itype, const InterrogateFunction &ifunc, @@ -559,18 +499,14 @@ make_function_remap(const InterrogateType &itype, return (FunctionRemap *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::get_wrapper_name -// Access: Protected, Virtual -// Description: Returns the function name that will be used to wrap -// the indicated function. -// -// This is the name for the overall wrapper function, -// including all of the overloaded instances. -// Interfaces that must define a different wrapper for -// each FunctionRemap object (i.e. for each instance of -// an overloaded function) need not define a name here. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function name that will be used to wrap the indicated function. + * + * This is the name for the overall wrapper function, including all of the + * overloaded instances. Interfaces that must define a different wrapper for + * each FunctionRemap object (i.e. for each instance of an overloaded + * function) need not define a name here. + */ string InterfaceMaker:: get_wrapper_name(const InterrogateType &itype, const InterrogateFunction &ifunc, @@ -583,36 +519,28 @@ get_wrapper_name(const InterrogateType &itype, return new_name.str(); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::get_wrapper_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate wrapper -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate wrapper function names. + */ string InterfaceMaker:: get_wrapper_prefix() { return "xx_"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::get_unique_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate unique -// symbolic names, which are not necessarily C-callable -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate unique symbolic names, which are + * not necessarily C-callable function names. + */ string InterfaceMaker:: get_unique_prefix() { return "x"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::record_function -// Access: Protected -// Description: Records the indicated function, along with all of its -// FunctionRemap flavors and FunctionWriter helpers, for -// future output. Returns the new Function pointer. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated function, along with all of its FunctionRemap flavors + * and FunctionWriter helpers, for future output. Returns the new Function + * pointer. + */ InterfaceMaker::Function *InterfaceMaker:: record_function(const InterrogateType &itype, FunctionIndex func_index) { assert(func_index != 0); @@ -629,7 +557,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { Function *func = new Function(wrapper_name, itype, ifunc); _functions[func_index] = func; -// printf(" Function Name = %s\n", ifunc.get_name().c_str()); +// printf(" Function Name = %s\n", ifunc.get_name().c_str()); // Now get all the valid FunctionRemaps for the function. if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { @@ -640,8 +568,7 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { int max_default_parameters = 0; if (separate_overloading()) { - // Count up the number of default parameters this function might - // take. + // Count up the number of default parameters this function might take. CPPParameterList *parameters = ftype->_parameters; CPPParameterList::Parameters::reverse_iterator pi; for (pi = parameters->_parameters.rbegin(); @@ -659,9 +586,9 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { } // Now make a different wrapper for each combination of default - // parameters. This will happen only if separate_overloading(), - // tested above, returned true; otherwise, max_default_parameters - // will be 0 and the loop will only be traversed once. + // parameters. This will happen only if separate_overloading(), tested + // above, returned true; otherwise, max_default_parameters will be 0 and + // the loop will only be traversed once. for (int num_default_parameters = 0; num_default_parameters <= max_default_parameters; num_default_parameters++) { @@ -671,9 +598,8 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { func->_remaps.push_back(remap); - // If *any* of the variants of this function has a "this" - // pointer, the entire set of functions is deemed to have a - // "this" pointer. + // If *any* of the variants of this function has a "this" pointer, + // the entire set of functions is deemed to have a "this" pointer. if (remap->_has_this) { func->_has_this = true; } @@ -696,23 +622,18 @@ record_function(const InterrogateType &itype, FunctionIndex func_index) { return func; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::record_function_wrapper -// Access: Protected, Virtual -// Description: Associates the function wrapper with its function in -// the appropriate structures in the database. -//////////////////////////////////////////////////////////////////// +/** + * Associates the function wrapper with its function in the appropriate + * structures in the database. + */ void InterfaceMaker:: record_function_wrapper(InterrogateFunction &, FunctionWrapperIndex) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::record_object -// Access: Protected -// Description: Records the indicated type, which may be a struct -// type, along with all of its associated methods, if -// any. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated type, which may be a struct type, along with all of + * its associated methods, if any. + */ InterfaceMaker::Object *InterfaceMaker:: record_object(TypeIndex type_index) { if (type_index == 0) { @@ -793,14 +714,11 @@ record_object(TypeIndex type_index) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::manage_return_value -// Access: Protected -// Description: Does any additional processing that we might want to -// do on the return value for the function, just before -// we return it. Returns the string representing the -// new return value after processing. -//////////////////////////////////////////////////////////////////// +/** + * Does any additional processing that we might want to do on the return value + * for the function, just before we return it. Returns the string + * representing the new return value after processing. + */ string InterfaceMaker:: manage_return_value(ostream &out, int indent_level, FunctionRemap *remap, const string &return_expr) const { @@ -814,8 +732,8 @@ manage_return_value(ostream &out, int indent_level, return return_expr; } else { - // Otherwise, we should probably assign it to a temporary first, - // so we don't invoke the function twice or something. + // Otherwise, we should probably assign it to a temporary first, so we + // don't invoke the function twice or something. CPPType *type = remap->_return_type->get_temporary_type(); indent(out, indent_level); type->output_instance(out, "refcount", &parser); @@ -837,13 +755,10 @@ manage_return_value(ostream &out, int indent_level, return return_expr; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::delete_return_value -// Access: Protected -// Description: Cleans up the given return value by deleting it or -// decrementing its reference count or whatever is -// appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up the given return value by deleting it or decrementing its + * reference count or whatever is appropriate. + */ void InterfaceMaker:: delete_return_value(ostream &out, int indent_level, FunctionRemap *remap, const string &return_expr) const { @@ -858,12 +773,10 @@ delete_return_value(ostream &out, int indent_level, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::output_ref -// Access: Protected -// Description: Outputs the code to increment the reference count for -// the indicated variable name. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the code to increment the reference count for the indicated + * variable name. + */ void InterfaceMaker:: output_ref(ostream &out, int indent_level, FunctionRemap *remap, const string &varname) const { @@ -875,14 +788,14 @@ output_ref(ostream &out, int indent_level, FunctionRemap *remap, if (remap->_type == FunctionRemap::T_constructor || remap->_type == FunctionRemap::T_typecast) { - // In either of these cases, we can safely assume the pointer will - // never be NULL. + // In either of these cases, we can safely assume the pointer will never + // be NULL. indent(out, indent_level) << varname << "->ref();\n"; } else { - // However, in the general case, we have to check for that before - // we attempt to ref it. + // However, in the general case, we have to check for that before we + // attempt to ref it. indent(out, indent_level) << "if (" << varname << " != (" @@ -894,12 +807,10 @@ output_ref(ostream &out, int indent_level, FunctionRemap *remap, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::output_unref -// Access: Protected -// Description: Outputs the code to decrement the reference count for -// the indicated variable name. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the code to decrement the reference count for the indicated + * variable name. + */ void InterfaceMaker:: output_unref(ostream &out, int indent_level, FunctionRemap *remap, const string &varname) const { @@ -911,14 +822,14 @@ output_unref(ostream &out, int indent_level, FunctionRemap *remap, if (remap->_type == FunctionRemap::T_constructor || remap->_type == FunctionRemap::T_typecast) { - // In either of these cases, we can safely assume the pointer will - // never be NULL. + // In either of these cases, we can safely assume the pointer will never + // be NULL. indent(out, indent_level) << "unref_delete(" << varname << ");\n"; } else { - // However, in the general case, we have to check for that before - // we attempt to ref it. + // However, in the general case, we have to check for that before we + // attempt to ref it. indent(out, indent_level) << "if (" << varname << " != (" @@ -939,14 +850,11 @@ output_unref(ostream &out, int indent_level, FunctionRemap *remap, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::hash_function_signature -// Access: Protected -// Description: Generates a unique string that corresponds to the -// function signature for the indicated FunctionRemap -// object, and stores the generated string in the _hash -// member of the FunctionRemap. -//////////////////////////////////////////////////////////////////// +/** + * Generates a unique string that corresponds to the function signature for + * the indicated FunctionRemap object, and stores the generated string in the + * _hash member of the FunctionRemap. + */ void InterfaceMaker:: hash_function_signature(FunctionRemap *remap) { string hash = InterrogateBuilder::hash_string(remap->_function_signature, 5); @@ -963,8 +871,8 @@ hash_function_signature(FunctionRemap *remap) { if ((*hi).second != (FunctionRemap *)NULL && (*hi).second->_function_signature == remap->_function_signature) { - // The same function signature has already appeared. This - // shouldn't happen. + // The same function signature has already appeared. This shouldn't + // happen. nout << "Internal error! Function signature " << remap->_function_signature << " repeated!\n"; remap->_hash = hash; @@ -972,8 +880,7 @@ hash_function_signature(FunctionRemap *remap) { return; } - // We have a conflict. Extend both strings to resolve the - // ambiguity. + // We have a conflict. Extend both strings to resolve the ambiguity. if ((*hi).second != (FunctionRemap *)NULL) { FunctionRemap *other_remap = (*hi).second; (*hi).second = (FunctionRemap *)NULL; @@ -992,8 +899,8 @@ hash_function_signature(FunctionRemap *remap) { (WrappersByHash::value_type(hash, remap)).second; if (!inserted) { - // Huh. We still have a conflict. This should be extremely rare. - // Well, just tack on a letter until it's resolved. + // Huh. We still have a conflict. This should be extremely rare. Well, + // just tack on a letter until it's resolved. string old_hash = hash; for (char ch = 'a'; ch <= 'z' && !inserted; ch++) { hash = old_hash + ch; @@ -1009,12 +916,10 @@ hash_function_signature(FunctionRemap *remap) { remap->_hash = hash; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::write_spam_message -// Access: Protected -// Description: Generates a string to output a spammy message to -// notify indicating we have just called this function. -//////////////////////////////////////////////////////////////////// +/** + * Generates a string to output a spammy message to notify indicating we have + * just called this function. + */ void InterfaceMaker:: write_spam_message(ostream &out, FunctionRemap *remap) const { ostringstream strm; @@ -1045,4 +950,3 @@ write_spam_message(ostream &out, FunctionRemap *remap) const { out << "\\n\";\n" " }\n"; } - diff --git a/dtool/src/interrogate/interfaceMaker.h b/dtool/src/interrogate/interfaceMaker.h index 3e36ddde88..f76975d592 100644 --- a/dtool/src/interrogate/interfaceMaker.h +++ b/dtool/src/interrogate/interfaceMaker.h @@ -1,16 +1,15 @@ -// Filename: interfaceMaker.h -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMaker.h + * @author drose + * @date 2001-09-19 + */ #ifndef INTERFACEMAKER_H #define INTERFACEMAKER_H @@ -36,18 +35,15 @@ class InterrogateFunction; class InterrogateMakeSeq; class InterrogateType; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMaker -// Description : This is an abstract base class that defines how to -// generate code that can be called from an external -// language (like Python or Squeak) and that can call -// into Panda. -// -// The specializations of this class like -// InterfaceMakerPython and InterfaceMakerC will -// generate the actual wrappers for the various language -// calling conventions. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class that defines how to generate code that can + * be called from an external language (like Python or Squeak) and that can + * call into Panda. + * + * The specializations of this class like InterfaceMakerPython and + * InterfaceMakerC will generate the actual wrappers for the various language + * calling conventions. + */ class InterfaceMaker { public: InterfaceMaker(InterrogateModuleDef *def); @@ -73,12 +69,11 @@ public: static ostream &indent(ostream &out, int indent_level); public: - // This contains information about the number - // of arguments that the wrapping function should take. + // This contains information about the number of arguments that the wrapping + // function should take. enum ArgsType { - // This is deliberately engineered such that these - // values can be OR'ed together to produce another - // valid enum value. + // This is deliberately engineered such that these values can be OR'ed + // together to produce another valid enum value. AT_unknown = 0x00, // The method or function takes no arguments. @@ -90,8 +85,8 @@ public: // The method takes a variable number of arguments. AT_varargs = 0x03, - // The method may take keyword arguments, if appropriate - // in the scripting language. Implies AT_varargs. + // The method may take keyword arguments, if appropriate in the scripting + // language. Implies AT_varargs. AT_keyword_args = 0x07, }; @@ -174,23 +169,23 @@ public: CPPInstance *cppfunc, int num_default_parameters); virtual string - get_wrapper_name(const InterrogateType &itype, + get_wrapper_name(const InterrogateType &itype, const InterrogateFunction &ifunc, FunctionIndex func_index); virtual string get_wrapper_prefix(); virtual string get_unique_prefix(); - + Function * record_function(const InterrogateType &itype, FunctionIndex func_index); virtual void - record_function_wrapper(InterrogateFunction &ifunc, + record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); virtual Object *record_object(TypeIndex type_index); void hash_function_signature(FunctionRemap *remap); - + string manage_return_value(ostream &out, int indent_level, @@ -200,9 +195,9 @@ public: delete_return_value(ostream &out, int indent_level, FunctionRemap *remap, const string &return_expr) const; - void output_ref(ostream &out, int indent_level, FunctionRemap *remap, + void output_ref(ostream &out, int indent_level, FunctionRemap *remap, const string &varname) const; - void output_unref(ostream &out, int indent_level, FunctionRemap *remap, + void output_unref(ostream &out, int indent_level, FunctionRemap *remap, const string &varname) const; void write_spam_message(ostream &out, FunctionRemap *remap) const; diff --git a/dtool/src/interrogate/interfaceMakerC.cxx b/dtool/src/interrogate/interfaceMakerC.cxx index 9bd21a9922..966e9c058d 100644 --- a/dtool/src/interrogate/interfaceMakerC.cxx +++ b/dtool/src/interrogate/interfaceMakerC.cxx @@ -1,17 +1,16 @@ -// Filename: interfaceMakerC.cxx -// Created by: drose (25Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerC.cxx + * @author drose + * @date 2001-09-25 + */ + #include "interfaceMakerC.h" #include "interrogateBuilder.h" #include "interrogate.h" @@ -25,33 +24,26 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerC:: InterfaceMakerC(InterrogateModuleDef *def) : InterfaceMaker(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerC:: ~InterfaceMakerC() { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_prototypes -// Access: Public, Virtual -// Description: Generates the list of function prototypes -// corresponding to the functions that will be output in -// write_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of function prototypes corresponding to the functions + * that will be output in write_functions(). + */ void InterfaceMakerC:: write_prototypes(ostream &out,ostream *out_h) { // The 'used' attribute prevents emscripten from optimizing it out. @@ -72,13 +64,10 @@ write_prototypes(ostream &out,ostream *out_h) { InterfaceMaker::write_prototypes(out,out_h); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_functions -// Access: Public, Virtual -// Description: Generates the list of functions that are appropriate -// for this interface. This function is called *before* -// write_prototypes(), above. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of functions that are appropriate for this interface. + * This function is called *before* write_prototypes(), above. + */ void InterfaceMakerC:: write_functions(ostream &out) { FunctionsByIndex::iterator fi; @@ -90,24 +79,21 @@ write_functions(ostream &out) { InterfaceMaker::write_functions(out); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::remap_parameter -// Access: Public, Virtual -// Description: Allocates a new ParameterRemap object suitable to the -// indicated parameter type. If struct_type is -// non-NULL, it is the type of the enclosing class for -// the function (method) in question. -// -// The return value is a newly-allocated ParameterRemap -// object, if the parameter type is acceptable, or NULL -// if the parameter type cannot be handled. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new ParameterRemap object suitable to the indicated parameter + * type. If struct_type is non-NULL, it is the type of the enclosing class + * for the function (method) in question. + * + * The return value is a newly-allocated ParameterRemap object, if the + * parameter type is acceptable, or NULL if the parameter type cannot be + * handled. + */ ParameterRemap *InterfaceMakerC:: remap_parameter(CPPType *struct_type, CPPType *param_type) { - // Wrap TypeHandle and ButtonHandle, which are practically just - // ints, as an integer instead of a pointer. It makes things easier - // on the scripting language, especially if there has to be a - // dynamic downcasting system on the scripting language side. + // Wrap TypeHandle and ButtonHandle, which are practically just ints, as an + // integer instead of a pointer. It makes things easier on the scripting + // language, especially if there has to be a dynamic downcasting system on + // the scripting language side. if (TypeManager::is_handle(param_type)) { return new ParameterRemapHandleToInt(param_type); @@ -116,59 +102,46 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::synthesize_this_parameter -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require the implicit -// "this" parameter, if present, to be passed as the -// first parameter to any wrapper functions. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require the implicit "this" parameter, if present, to be + * passed as the first parameter to any wrapper functions. + */ bool InterfaceMakerC:: synthesize_this_parameter() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::get_wrapper_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate wrapper -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate wrapper function names. + */ string InterfaceMakerC:: get_wrapper_prefix() { return "_inC"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::get_unique_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate unique -// symbolic names, which are not necessarily C-callable -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate unique symbolic names, which are + * not necessarily C-callable function names. + */ string InterfaceMakerC:: get_unique_prefix() { return "c"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::record_function_wrapper -// Access: Protected, Virtual -// Description: Associates the function wrapper with its function in -// the appropriate structures in the database. -//////////////////////////////////////////////////////////////////// +/** + * Associates the function wrapper with its function in the appropriate + * structures in the database. + */ void InterfaceMakerC:: -record_function_wrapper(InterrogateFunction &ifunc, +record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index) { ifunc._c_wrappers.push_back(wrapper_index); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_prototype_for -// Access: Private -// Description: Writes the prototype for the indicated function. -//////////////////////////////////////////////////////////////////// +/** + * Writes the prototype for the indicated function. + */ void InterfaceMakerC:: write_prototype_for(ostream &out, InterfaceMaker::Function *func) { Function::Remaps::const_iterator ri; @@ -188,12 +161,10 @@ write_prototype_for(ostream &out, InterfaceMaker::Function *func) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_function_for -// Access: Private -// Description: Writes the definition for a function that will call -// the indicated C++ function or method. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a function that will call the indicated C++ + * function or method. + */ void InterfaceMakerC:: write_function_for(ostream &out, InterfaceMaker::Function *func) { Function::Remaps::const_iterator ri; @@ -204,12 +175,10 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_function_instance -// Access: Private -// Description: Writes out the particular function that handles a -// single instance of an overloaded function. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the particular function that handles a single instance of an + * overloaded function. + */ void InterfaceMakerC:: write_function_instance(ostream &out, InterfaceMaker::Function *func, FunctionRemap *remap) { @@ -225,8 +194,8 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, << " */\n"; if (!output_function_names) { - // If we're not saving the function names, don't export it from - // the library. + // If we're not saving the function names, don't export it from the + // library. out << "static "; } @@ -247,12 +216,10 @@ write_function_instance(ostream &out, InterfaceMaker::Function *func, out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerC::write_function_header -// Access: Private -// Description: Writes the first line of a function definition, -// either for a prototype or a function body. -//////////////////////////////////////////////////////////////////// +/** + * Writes the first line of a function definition, either for a prototype or a + * function body. + */ void InterfaceMakerC:: write_function_header(ostream &out, InterfaceMaker::Function *func, FunctionRemap *remap, bool newline) { diff --git a/dtool/src/interrogate/interfaceMakerC.h b/dtool/src/interrogate/interfaceMakerC.h index ee715424ac..5eaf276815 100644 --- a/dtool/src/interrogate/interfaceMakerC.h +++ b/dtool/src/interrogate/interfaceMakerC.h @@ -1,16 +1,15 @@ -// Filename: interfaceMakerC.h -// Created by: drose (25Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerC.h + * @author drose + * @date 2001-09-25 + */ #ifndef INTERFACEMAKERC_H #define INTERFACEMAKERC_H @@ -22,12 +21,10 @@ class FunctionRemap; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMakerC -// Description : An InteraceMaker suitable for generating -// a series of C-calling-convention functions for -// Panda class objects. -//////////////////////////////////////////////////////////////////// +/** + * An InteraceMaker suitable for generating a series of C-calling-convention + * functions for Panda class objects. + */ class InterfaceMakerC : public InterfaceMaker { public: InterfaceMakerC(InterrogateModuleDef *def); @@ -45,7 +42,7 @@ protected: virtual string get_unique_prefix(); virtual void - record_function_wrapper(InterrogateFunction &ifunc, + record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); private: diff --git a/dtool/src/interrogate/interfaceMakerPython.cxx b/dtool/src/interrogate/interfaceMakerPython.cxx index 59a272a7e6..f799335dfa 100644 --- a/dtool/src/interrogate/interfaceMakerPython.cxx +++ b/dtool/src/interrogate/interfaceMakerPython.cxx @@ -1,38 +1,32 @@ -// Filename: interfaceMakerPython.cxx -// Created by: drose (21Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPython.cxx + * @author drose + * @date 2001-09-21 + */ #include "interfaceMakerPython.h" #include "interrogate.h" -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPython::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPython:: InterfaceMakerPython(InterrogateModuleDef *def) : InterfaceMaker(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPython::write_includes -// Access: Public, Virtual -// Description: Generates the list of #include ... whatever that's -// required by this particular interface to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of #include ... whatever that's required by this + * particular interface to the indicated output stream. + */ void InterfaceMakerPython:: write_includes(ostream &out) { InterfaceMaker::write_includes(out); @@ -46,13 +40,10 @@ write_includes(ostream &out) { << "#endif\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPython::test_assert -// Access: Protected -// Description: Outputs code to check to see if an assertion has -// failed while the C++ code was executing, and report -// this failure back to Python. -//////////////////////////////////////////////////////////////////// +/** + * Outputs code to check to see if an assertion has failed while the C++ code + * was executing, and report this failure back to Python. + */ void InterfaceMakerPython:: test_assert(ostream &out, int indent_level) const { if (watch_asserts) { diff --git a/dtool/src/interrogate/interfaceMakerPython.h b/dtool/src/interrogate/interfaceMakerPython.h index afe37dcc45..2d9bb84376 100644 --- a/dtool/src/interrogate/interfaceMakerPython.h +++ b/dtool/src/interrogate/interfaceMakerPython.h @@ -1,16 +1,15 @@ -// Filename: interfaceMakerPython.h -// Created by: drose (21Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPython.h + * @author drose + * @date 2001-09-21 + */ #ifndef INTERFACEMAKERPYTHON_H #define INTERFACEMAKERPYTHON_H @@ -21,13 +20,11 @@ class FunctionRemap; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMakerPython -// Description : The base class for InteraceMakerPythonSimple and -// InterfaceMakerPythonObj, this includes a few -// functions that both have in common for formatting -// Python objects. -//////////////////////////////////////////////////////////////////// +/** + * The base class for InteraceMakerPythonSimple and InterfaceMakerPythonObj, + * this includes a few functions that both have in common for formatting + * Python objects. + */ class InterfaceMakerPython : public InterfaceMaker { protected: InterfaceMakerPython(InterrogateModuleDef *def); diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index f7085dd1ee..5ab6f54768 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1,14 +1,13 @@ -// Filename: interfaceMakerPythonNative.cxx -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonNative.cxx + */ #include "interfaceMakerPythonNative.h" #include "interrogateBuilder.h" @@ -45,10 +44,7 @@ extern std::string EXPORT_IMPORT_PREFIX; #define CLASS_PREFIX "Dtool_" -//////////////////////////////////////////////////////////////////// -// Name Remapper... -// Snagged from ffi py code.... -//////////////////////////////////////////////////////////////////// +// Name Remapper... Snagged from ffi py code.... struct RenameSet { const char *_from; const char *_to; @@ -164,10 +160,10 @@ classNameFromCppName(const std::string &cppName, bool mangle) { mangle = false; } - //# initialize to empty string + // # initialize to empty string std::string className = ""; - //# These are the characters we want to strip out of the name + // # These are the characters we want to strip out of the name const std::string badChars("!@#$%^&*()<>,.-=+~{}? "); bool nextCap = false; @@ -209,7 +205,8 @@ classNameFromCppName(const std::string &cppName, bool mangle) { } className = checkKeyword(className); - //# FFIConstants.notify.debug('Renaming class: ' + cppName + ' to: ' + className) + // # FFIConstants.notify.debug('Renaming class: ' + cppName + ' to: ' + + // className) return className; } @@ -265,7 +262,7 @@ methodNameFromCppName(const std::string &cppName, const std::string &className, } } - // # Mangle names that happen to be python keywords so they are not anymore + // # Mangle names that happen to be python keywords so they are not anymore methodName = checkKeyword(methodName); return methodName; } @@ -286,20 +283,16 @@ std::string methodNameFromCppName(FunctionRemap *remap, const std::string &class return methodNameFromCppName(cppName, className, mangle); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::get_slotted_function_def -// Access: Private, Static -// Description: Determines whether this method should be mapped to -// one of Python's special slotted functions, those -// hard-coded functions that are assigned to particular -// function pointers within the object structure, for -// special functions like __getitem__ and __len__. -// -// Returns true if it has such a mapping, false if it is -// just a normal method. If it returns true, the -// SlottedFunctionDef structure is filled in with the -// important details. -//////////////////////////////////////////////////////////////////// +/** + * Determines whether this method should be mapped to one of Python's special + * slotted functions, those hard-coded functions that are assigned to + * particular function pointers within the object structure, for special + * functions like __getitem__ and __len__. + * + * Returns true if it has such a mapping, false if it is just a normal method. + * If it returns true, the SlottedFunctionDef structure is filled in with the + * important details. + */ bool InterfaceMakerPythonNative:: get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, SlottedFunctionDef &def) { @@ -508,8 +501,8 @@ get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, } if (method_name == "__getattribute__") { - // Like __getattr__, but is called unconditionally, ie. - // does not try PyObject_GenericGetAttr first. + // Like __getattr__, but is called unconditionally, ie. does not try + // PyObject_GenericGetAttr first. def._answer_location = "tp_getattro"; def._wrapper_type = WT_one_param; return true; @@ -528,16 +521,16 @@ get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, } if (method_name == "__delattr__") { - // __delattr__ shares the slot with __setattr__, except - // that it takes only one argument. + // __delattr__ shares the slot with __setattr__, except that it takes only + // one argument. def._answer_location = "tp_setattro"; def._wrapper_type = WT_setattr; return true; } if (method_name == "__nonzero__" || method_name == "__bool__") { - // Python 2 named it nb_nonzero, Python 3 nb_bool. We refer to it just - // as nb_bool. + // Python 2 named it nb_nonzero, Python 3 nb_bool. We refer to it just as + // nb_bool. def._answer_location = "nb_bool"; def._wrapper_type = WT_inquiry; return true; @@ -596,8 +589,8 @@ get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, if (remap->_type == FunctionRemap::T_typecast_method) { // A typecast operator. Check for a supported low-level typecast type. if (TypeManager::is_bool(remap->_return_type->get_orig_type())) { - // If it's a bool type, then we wrap it with the __nonzero__ - // slot method. + // If it's a bool type, then we wrap it with the __nonzero__ slot + // method. def._answer_location = "nb_bool"; def._wrapper_type = WT_inquiry; return true; @@ -625,13 +618,11 @@ get_slotted_function_def(Object *obj, Function *func, FunctionRemap *remap, return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_function_slot -// Access: Private, Static -// Description: Determines whether the slot occurs in the map of -// slotted functions, and if so, writes out a pointer -// to its wrapper. If not, writes out def (usually 0). -//////////////////////////////////////////////////////////////////// +/** + * Determines whether the slot occurs in the map of slotted functions, and if + * so, writes out a pointer to its wrapper. If not, writes out def (usually + * 0). + */ void InterfaceMakerPythonNative:: write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slots, const string &slot, const string &default_) { @@ -648,7 +639,8 @@ write_function_slot(ostream &out, int indent_level, const SlottedFunctions &slot const SlottedFunctionDef &def = rfi->second; - // Add an #ifdef if there is a specific version requirement on this function. + // Add an #ifdef if there is a specific version requirement on this + // function. if (def._min_version > 0) { out << "#if PY_VERSION_HEX >= 0x" << hex << def._min_version << dec << "\n"; } @@ -674,8 +666,7 @@ get_valid_child_classes(std::map &answer, CPPStructTyp ++bi) { const CPPStructType::Base &base = (*bi); -// if (base._vis <= V_public) -// can_downcast = false; +// if (base._vis <= V_public) can_downcast = false; CPPStructType *base_type = TypeManager::resolve_type(base._base)->as_struct_type(); if (base_type != NULL) { std::string scoped_name = base_type->get_local_name(&parser); @@ -702,9 +693,9 @@ get_valid_child_classes(std::map &answer, CPPStructTyp } } -//////////////////////////////////////////////////////////////////// -// Function: write_python_instance -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_python_instance(ostream &out, int indent_level, const string &return_expr, bool owns_memory, const InterrogateType &itype, bool is_const) { @@ -718,8 +709,8 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, if (IsPandaTypedObject(itype._cpptype->as_struct_type())) { // We can't let DTool_CreatePyInstanceTyped do the NULL check since we - // will be grabbing the type index (which would obviously crash when called - // on a NULL pointer), so we do it here. + // will be grabbing the type index (which would obviously crash when + // called on a NULL pointer), so we do it here. indent(out, indent_level) << "if (" << return_expr << " == NULL) {\n"; indent(out, indent_level) @@ -745,33 +736,26 @@ write_python_instance(ostream &out, int indent_level, const string &return_expr, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonNative:: InterfaceMakerPythonNative(InterrogateModuleDef *def) : InterfaceMakerPython(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonNative:: ~InterfaceMakerPythonNative() { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_prototypes -// Access: Public, Virtual -// Description: Generates the list of function prototypes -// corresponding to the functions that will be output in -// write_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of function prototypes corresponding to the functions + * that will be output in write_functions(). + */ void InterfaceMakerPythonNative:: write_prototypes(ostream &out_code, ostream *out_h) { Functions::iterator fi; @@ -801,8 +785,8 @@ write_prototypes(ostream &out_code, ostream *out_h) { if (isExportThisRun(object->_itype._cpptype)) { write_prototypes_class(out_code, out_h, object); } else { - //write_prototypes_class_external(out_code, object); - //_external_imports.insert(object->_itype._cpptype); + // write_prototypes_class_external(out_code, object); + // _external_imports.insert(object->_itype._cpptype); } } } @@ -820,14 +804,17 @@ write_prototypes(ostream &out_code, ostream *out_h) { out_code << "// " << class_name << "\n"; out_code << "#ifndef LINK_ALL_STATIC\n"; - //out_code << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << safe_name << ";\n"; + // out_code << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << + // safe_name << ";\n"; out_code << "static struct Dtool_PyTypedObject *Dtool_Ptr_" << safe_name << ";\n"; - //out_code << "#define Dtool_Ptr_" << safe_name << " &Dtool_" << safe_name << "\n"; - //out_code << "IMPORT_THIS void Dtool_PyModuleClassInit_" << safe_name << "(PyObject *module);\n"; + // out_code << "#define Dtool_Ptr_" << safe_name << " &Dtool_" << + // safe_name << "\n"; out_code << "IMPORT_THIS void + // Dtool_PyModuleClassInit_" << safe_name << "(PyObject *module);\n"; - // This is some really ugly code, because we have to store a pointer with a - // function of a signature that differs from class to class. If someone can - // think of an elegant way to do this without sacrificing perf, let me know. + // This is some really ugly code, because we have to store a pointer with + // a function of a signature that differs from class to class. If someone + // can think of an elegant way to do this without sacrificing perf, let me + // know. int has_coerce = has_coerce_constructor(type->as_struct_type()); if (has_coerce > 0) { if (TypeManager::is_reference_count(type)) { @@ -899,11 +886,10 @@ write_prototypes(ostream &out_code, ostream *out_h) { } } -//////////////////////////////////////////////////////////////////// -// Function: write_prototypes_class_external -// Description: Output enough enformation to a declartion of a externally -// generated dtool type object -//////////////////////////////////////////////////////////////////// +/** + * Output enough enformation to a declartion of a externally generated dtool + * type object + */ void InterfaceMakerPythonNative:: write_prototypes_class_external(ostream &out, Object *obj) { std::string class_name = make_safe_name(obj->_itype.get_scoped_name()); @@ -915,15 +901,15 @@ write_prototypes_class_external(ostream &out, Object *obj) { out << "//*** prototypes for external.. " << class_name << "\n"; out << "//********************************************************************\n"; - // This typedef is necessary for class templates since we can't pass - // a comma to a macro function. + // This typedef is necessary for class templates since we can't pass a comma + // to a macro function. out << "typedef " << c_class_name << " " << class_name << "_localtype;\n"; out << "Define_Module_Class_Forward(" << _def->module_name << ", " << class_name << ", " << class_name << "_localtype, " << classNameFromCppName(preferred_name, false) << ");\n"; } -//////////////////////////////////////////////////////////////////// -// Function: write_prototypes_class -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); @@ -951,13 +937,10 @@ write_prototypes_class(ostream &out_code, ostream *out_h, Object *obj) { write_class_declarations(out_code, out_h, obj); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_functions -// Access: Public, Virtual -// Description: Generates the list of functions that are appropriate -// for this interface. This function is called *before* -// write_prototypes(), above. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of functions that are appropriate for this interface. + * This function is called *before* write_prototypes(), above. + */ void InterfaceMakerPythonNative:: write_functions(ostream &out) { out << "//********************************************************************\n"; @@ -983,7 +966,7 @@ write_functions(ostream &out) { } } - //Objects::iterator oi; + // Objects::iterator oi; for (oi = _objects.begin(); oi != _objects.end(); ++oi) { Object *object = (*oi).second; if (!object->_itype.get_outer_class()) { @@ -998,19 +981,16 @@ write_functions(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_class_details -// Access: Private -// Description: Writes out all of the wrapper methods necessary to -// export the given object. This is called by -// write_functions. -//////////////////////////////////////////////////////////////////// +/** + * Writes out all of the wrapper methods necessary to export the given object. + * This is called by write_functions. + */ void InterfaceMakerPythonNative:: write_class_details(ostream &out, Object *obj) { Functions::iterator fi; Function::Remaps::const_iterator ri; - //std::string cClassName = obj->_itype.get_scoped_name(); + // std::string cClassName = obj->_itype.get_scoped_name(); std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); std::string cClassName = obj->_itype.get_true_name(); @@ -1022,7 +1002,8 @@ write_class_details(ostream &out, Object *obj) { for (fi = obj->_methods.begin(); fi != obj->_methods.end(); ++fi) { Function *func = (*fi); if (func) { - // Write the definition of the generic wrapper function for this function. + // Write the definition of the generic wrapper function for this + // function. write_function_for_top(out, obj, func); } } @@ -1046,7 +1027,8 @@ write_class_details(ostream &out, Object *obj) { CPPType *cpptype = TypeManager::resolve_type(obj->_itype._cpptype); - // If we have "coercion constructors", write a single wrapper to consolidate those. + // If we have "coercion constructors", write a single wrapper to consolidate + // those. int has_coerce = has_coerce_constructor(cpptype->as_struct_type()); if (has_coerce > 0) { write_coerce_constructor(out, obj, true); @@ -1077,11 +1059,12 @@ write_class_details(ostream &out, Object *obj) { builder.get_type(TypeManager::unwrap(cpptype), false); get_valid_child_classes(details, cpptype->as_struct_type()); for (di = details.begin(); di != details.end(); di++) { - //InterrogateType ptype =idb->get_type(di->first); + // InterrogateType ptype =idb->get_type(di->first); if (di->second._is_legal_py_class && !isExportThisRun(di->second._structType)) { _external_imports.insert(TypeManager::resolve_type(di->second._structType)); } - //out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << make_safe_name(di->second._to_class_name) << ";\n"; + // out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << + // make_safe_name(di->second._to_class_name) << ";\n"; } // Write support methods to cast from and to pointers of this type. @@ -1129,10 +1112,9 @@ write_class_details(ostream &out, Object *obj) { } } -//////////////////////////////////////////////////////////////////// -// Function: write_class_declarations -// -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_class_declarations(ostream &out, ostream *out_h, Object *obj) { const InterrogateType &itype = obj->_itype; @@ -1143,8 +1125,8 @@ write_class_declarations(ostream &out, ostream *out_h, Object *obj) { CPPType *type = obj->_itype._cpptype; - // This typedef is necessary for class templates since we can't pass - // a comma to a macro function. + // This typedef is necessary for class templates since we can't pass a comma + // to a macro function. out << "typedef " << c_class_name << " " << class_name << "_localtype;\n"; if (obj->_itype.has_destructor() || obj->_itype.destructor_is_inherited()) { @@ -1193,15 +1175,12 @@ write_class_declarations(ostream &out, ostream *out_h, Object *obj) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_sub_module -// Access: Public, Virtual -// Description: Generates whatever additional code is required to -// support a module file. -//////////////////////////////////////////////////////////////////// +/** + * Generates whatever additional code is required to support a module file. + */ void InterfaceMakerPythonNative:: write_sub_module(ostream &out, Object *obj) { - //Object * obj = _objects[_embeded_index] ; + // Object * obj = _objects[_embeded_index] ; string class_name = make_safe_name(obj->_itype.get_scoped_name()); string class_ptr; out << " // Module init upcall for " << obj->_itype.get_scoped_name() << "\n"; @@ -1254,9 +1233,9 @@ write_sub_module(ostream &out, Object *obj) { } } -//////////////////////////////////////////////////////////////////// -// Function: write_module_support -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << "//********************************************************************\n"; @@ -1381,8 +1360,9 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { out << "//*** Module Init Upcall .. Externally Defined Class\n"; out << "//********************************************************************\n"; -// for (std::set< std::string >::iterator ii = _external_imports.begin(); ii != _external_imports.end(); ii++) -// out << "Dtool_" <<*ii << "._Dtool_ClassInit(NULL);\n"; +// for (std::set< std::string >::iterator ii = _external_imports.begin(); ii +// != _external_imports.end(); ii++) out << "Dtool_" <<*ii << +// "._Dtool_ClassInit(NULL);\n"; out << "}\n\n"; @@ -1417,8 +1397,8 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { break; } - // Note: we shouldn't add METH_STATIC here, since both METH_STATIC - // and METH_CLASS are illegal for module-level functions. + // Note: we shouldn't add METH_STATIC here, since both METH_STATIC and + // METH_CLASS are illegal for module-level functions. out << " {\"" << name1 << "\", " << fptr << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; @@ -1443,9 +1423,9 @@ write_module_support(ostream &out, ostream *out_h, InterrogateModuleDef *def) { } } -//////////////////////////////////////////////////////////////////// -// Function: write_module -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { InterfaceMakerPython::write_module(out, out_h, def); @@ -1496,9 +1476,9 @@ write_module(ostream &out, ostream *out_h, InterrogateModuleDef *def) { << "#endif\n" << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: write_module_class -//////////////////////////////////////////////////////////////////// +/** + + */ void InterfaceMakerPythonNative:: write_module_class(ostream &out, Object *obj) { bool has_local_repr = false; @@ -1611,10 +1591,10 @@ write_module_class(ostream &out, Object *obj) { } // Python 3 doesn't support nb_divide. It has nb_true_divide and also - // nb_floor_divide, but they have different semantics than in C++. Ugh. - // Make special slots to store the nb_divide members that take a float. - // We'll use this to build up nb_true_divide, so that we can still properly - // divide float vector types. + // nb_floor_divide, but they have different semantics than in C++. + // Ugh. Make special slots to store the nb_divide members that take a + // float. We'll use this to build up nb_true_divide, so that we can + // still properly divide float vector types. if (remap->_flags & FunctionRemap::F_divide_float) { string true_key; if (key == "nb_inplace_divide") { @@ -1638,9 +1618,9 @@ write_module_class(ostream &out, Object *obj) { } if (has_nonslotted) { - // This is a bit of a hack, as these methods should probably be - // going through the slotted function system. But it's kind of - // pointless to write these out, and a waste of space. + // This is a bit of a hack, as these methods should probably be going + // through the slotted function system. But it's kind of pointless to + // write these out, and a waste of space. string fname = func->_ifunc.get_name(); if (fname == "operator <" || fname == "operator <=" || @@ -1651,7 +1631,8 @@ write_module_class(ostream &out, Object *obj) { continue; } - // This method has non-slotted remaps, so write it out into the function table. + // This method has non-slotted remaps, so write it out into the function + // table. out << " {\"" << name1 << "\", " << fptr << ", " << flags << ", (const char *)" << func->_name << "_comment},\n"; if (name1 != name2) { @@ -1716,7 +1697,8 @@ write_module_class(ostream &out, Object *obj) { if (!isExportThisRun(d_itype._cpptype)) { _external_imports.insert(TypeManager::resolve_type(d_itype._cpptype)); - //out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << make_safe_name(d_itype.get_scoped_name().c_str()) << ";\n"; + // out << "IMPORT_THIS struct Dtool_PyTypedObject Dtool_" << + // make_safe_name(d_itype.get_scoped_name().c_str()) << ";\n"; } } } @@ -1798,9 +1780,9 @@ write_module_class(ostream &out, Object *obj) { out << " " << cClassName << " *local_this = NULL;\n"; if (rfi->second._wrapper_type != WT_one_param) { // WT_binary_operator means we must return NotImplemented, instead - // of raising an exception, if the this pointer doesn't - // match. This is for things like __sub__, which Python - // likes to call on the wrong-type objects. + // of raising an exception, if the this pointer doesn't match. + // This is for things like __sub__, which Python likes to call on + // the wrong-type objects. out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; out << " if (local_this == NULL) {\n"; out << " Py_INCREF(Py_NotImplemented);\n"; @@ -1846,8 +1828,8 @@ write_module_class(ostream &out, Object *obj) { set setattr_remaps; set delattr_remaps; - // This function handles both delattr and setattr. Fish out - // the remaps for both types. + // This function handles both delattr and setattr. Fish out the + // remaps for both types. set::const_iterator ri; for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -1907,10 +1889,10 @@ write_module_class(ostream &out, Object *obj) { break; case WT_getattr: - // PyObject *func(PyObject *self, PyObject *one) - // Specifically to implement __getattr__. - // First calls PyObject_GenericGetAttr(), and only calls the wrapper if it returns NULL. - // If one wants to override this completely, one should define __getattribute__ instead. + // PyObject *func(PyObject *self, PyObject *one) Specifically to + // implement __getattr__. First calls PyObject_GenericGetAttr(), and + // only calls the wrapper if it returns NULL. If one wants to override + // this completely, one should define __getattribute__ instead. { out << "//////////////////\n"; out << "// A wrapper function to satisfy Python's internal calling conventions.\n"; @@ -1936,7 +1918,7 @@ write_module_class(ostream &out, Object *obj) { true, true, AT_single_arg, RF_pyobject | RF_err_null, true); - //out << " PyErr_Clear();\n"; + // out << " PyErr_Clear();\n"; out << " return NULL;\n"; out << "}\n\n"; } @@ -1999,8 +1981,8 @@ write_module_class(ostream &out, Object *obj) { set setitem_remaps; set delitem_remaps; - // This function handles both delitem and setitem. Fish out - // the remaps for either one. + // This function handles both delitem and setitem. Fish out the + // remaps for either one. set::const_iterator ri; for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -2045,7 +2027,8 @@ write_module_class(ostream &out, Object *obj) { out << " return -1;\n"; out << " }\n\n"; - // This is a cheap cheat around all of the overhead of calling the wrapper function. + // This is a cheap cheat around all of the overhead of calling the + // wrapper function. out << " return (Py_ssize_t) local_this->" << fname << "();\n"; out << "}\n\n"; } @@ -2067,8 +2050,8 @@ write_module_class(ostream &out, Object *obj) { set setitem_remaps; set delitem_remaps; - // This function handles both delitem and setitem. Fish out - // the remaps for either one. + // This function handles both delitem and setitem. Fish out the + // remaps for either one. set::const_iterator ri; for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -2123,11 +2106,12 @@ write_module_class(ostream &out, Object *obj) { break; case WT_getbuffer: - // int __getbuffer__(PyObject *self, Py_buffer *buffer, int flags) - // We map this directly, and assume that the arguments match. The whole point - // of this is to be fast, and we don't want to negate that by first wrapping - // and then unwrapping the arguments again. We also want to guarantee const - // correctness, since that will determine whether a read-only buffer is given. + // int __getbuffer__(PyObject *self, Py_buffer *buffer, int flags) We + // map this directly, and assume that the arguments match. The whole + // point of this is to be fast, and we don't want to negate that by + // first wrapping and then unwrapping the arguments again. We also + // want to guarantee const correctness, since that will determine + // whether a read-only buffer is given. { has_local_getbuffer = true; @@ -2146,7 +2130,8 @@ write_module_class(ostream &out, Object *obj) { FunctionRemap *remap_const = NULL; FunctionRemap *remap_nonconst = NULL; - // Iterate through the remaps to find the one that matches our parameters. + // Iterate through the remaps to find the one that matches our + // parameters. set::const_iterator ri; for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -2167,8 +2152,9 @@ write_module_class(ostream &out, Object *obj) { params_nonconst.push_back("buffer"); params_nonconst.push_back("flags"); - // We have to distinguish properly between const and nonconst, because the function - // may depend on it to decide whether to provide a writable buffer or a readonly buffer. + // We have to distinguish properly between const and nonconst, + // because the function may depend on it to decide whether to + // provide a writable buffer or a readonly buffer. const string const_this = "(const " + cClassName + " *)local_this"; if (remap_const != NULL && remap_nonconst != NULL) { out << " if (!((Dtool_PyInstDef *)self)->_is_const) {\n"; @@ -2195,8 +2181,8 @@ write_module_class(ostream &out, Object *obj) { break; case WT_releasebuffer: - // void __releasebuffer__(PyObject *self, Py_buffer *buffer) - // Same story as __getbuffer__ above. + // void __releasebuffer__(PyObject *self, Py_buffer *buffer) Same + // story as __getbuffer__ above. { out << "//////////////////\n"; out << "// A wrapper function to satisfy Python's internal calling conventions.\n"; @@ -2213,7 +2199,8 @@ write_module_class(ostream &out, Object *obj) { FunctionRemap *remap_const = NULL; FunctionRemap *remap_nonconst = NULL; - // Iterate through the remaps to find the one that matches our parameters. + // Iterate through the remaps to find the one that matches our + // parameters. set::const_iterator ri; for (ri = def._remaps.begin(); ri != def._remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -2249,7 +2236,8 @@ write_module_class(ostream &out, Object *obj) { out << " }\n"; } else if (remap_nonconst != NULL) { - // Doesn't matter if there's no const version. We *have* to call it or else we could leak memory. + // Doesn't matter if there's no const version. We *have* to call + // it or else we could leak memory. return_expr = remap_nonconst->call_function(out, 2, false, "local_this", params_nonconst); if (!return_expr.empty()) { out << " " << return_expr << ";\n"; @@ -2289,9 +2277,9 @@ write_module_class(ostream &out, Object *obj) { out << " DTOOL_Call_ExtractThisPointerForType(self, &Dtool_" << ClassName << ", (void **)&local_this);\n"; out << " if (local_this == NULL) {\n"; // WT_ternary_operator means we must return NotImplemented, instead - // of raising an exception, if the this pointer doesn't - // match. This is for things like __pow__, which Python - // likes to call on the wrong-type objects. + // of raising an exception, if the this pointer doesn't match. This + // is for things like __pow__, which Python likes to call on the + // wrong-type objects. out << " Py_INCREF(Py_NotImplemented);\n"; out << " return Py_NotImplemented;\n"; out << " }\n"; @@ -2334,8 +2322,8 @@ write_module_class(ostream &out, Object *obj) { break; case WT_traverse: - // int __traverse__(PyObject *self, visitproc visit, void *arg) - // This is a low-level function. Overloads are not supported. + // int __traverse__(PyObject *self, visitproc visit, void *arg) This + // is a low-level function. Overloads are not supported. { out << "//////////////////\n"; out << "// A wrapper function to satisfy Python's internal calling conventions.\n"; @@ -2509,7 +2497,8 @@ write_module_class(ostream &out, Object *obj) { if (!func) { continue; } - // We only accept comparison operators that take one parameter (besides 'this'). + // We only accept comparison operators that take one parameter (besides + // 'this'). Function::Remaps::const_iterator ri; for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { FunctionRemap *remap = (*ri); @@ -2590,8 +2579,8 @@ write_module_class(ostream &out, Object *obj) { int num_getset = 0; if (obj->_properties.size() > 0) { - // Write out the array of properties, telling Python which getter and setter - // to call when they are assigned or queried in Python code. + // Write out the array of properties, telling Python which getter and + // setter to call when they are assigned or queried in Python code. out << "static PyGetSetDef Dtool_Properties_" << ClassName << "[] = {\n"; Properties::const_iterator pit; @@ -2605,7 +2594,7 @@ write_module_class(ostream &out, Object *obj) { ++num_getset; string name1 = methodNameFromCppName(ielem.get_name(), "", false); - //string name2 = methodNameFromCppName(ielem.get_name(), "", true); + // string name2 = methodNameFromCppName(ielem.get_name(), "", true); string getter = "&Dtool_" + ClassName + "_" + ielem.get_name() + "_Getter"; string setter = "NULL"; @@ -2706,9 +2695,9 @@ write_module_class(ostream &out, Object *obj) { out << "};\n\n"; // NB: it's tempting not to write this table when a class doesn't have them. - // But then Python won't inherit them from base classes either! So we always - // write this table for now even if it will be full of 0's, unless this type - // has no base classes at all. + // But then Python won't inherit them from base classes either! So we + // always write this table for now even if it will be full of 0's, unless + // this type has no base classes at all. if (has_parent_class || (obj->_protocol_types & Object::PT_sequence) != 0) { out << "static PySequenceMethods Dtool_SequenceMethods_" << ClassName << " = {\n"; write_function_slot(out, 2, slots, "sq_length"); @@ -3083,7 +3072,8 @@ write_module_class(ostream &out, Object *obj) { string name1 = classNameFromCppName(ClassName2, false); out << " PyDict_SetItemString(dict, \"" << name1 << "\", (PyObject *)&Dtool_" << ClassName1 << ");\n"; - // No need to support mangled names for nested typedefs; we only added support recently. + // No need to support mangled names for nested typedefs; we only added + // support recently. } else if (nested_obj->_itype.is_enum()) { out << " // Enum " << nested_obj->_itype.get_scoped_name() << ";\n"; @@ -3095,8 +3085,9 @@ write_module_class(ostream &out, Object *obj) { if (nested_obj->_itype.has_true_name()) { name2 = classNameFromCppName((*ei)->get_simple_name(), true); } else { - // Don't generate the alternative syntax for anonymous enums, since we added support - // for those after we started deprecating the alternative syntax. + // Don't generate the alternative syntax for anonymous enums, since + // we added support for those after we started deprecating the + // alternative syntax. name2 = name1; } string enum_value = obj->_itype.get_scoped_name() + "::" + (*ei)->get_simple_name(); @@ -3115,130 +3106,108 @@ write_module_class(ostream &out, Object *obj) { " Py_INCREF((PyTypeObject *)&Dtool_" << ClassName << ");\n" " }\n"; - // Also write out the explicit alternate names. - //int num_alt_names = obj->_itype.get_num_alt_names(); - //for (int i = 0; i < num_alt_names; ++i) { - // string alt_name = make_safe_name(obj->_itype.get_alt_name(i)); - // if (export_class_name != alt_name) { - // out << " PyModule_AddObject(module, \"" << alt_name << "\", (PyObject *)&Dtool_" << ClassName << ".As_PyTypeObject());\n"; - // } - //} +/* + * Also write out the explicit alternate names. int num_alt_names = + * obj->_itype.get_num_alt_names(); for (int i = 0; i < num_alt_names; ++i) { + * string alt_name = make_safe_name(obj->_itype.get_alt_name(i)); if + * (export_class_name != alt_name) { out << " PyModule_AddObject(module, + * \"" << alt_name << "\", (PyObject *)&Dtool_" << ClassName << + * ".As_PyTypeObject());\n"; } } + */ - //out << " }\n"; + // out << " }\n"; out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::synthesize_this_parameter -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require the implicit -// "this" parameter, if present, to be passed as the -// first parameter to any wrapper functions. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require the implicit "this" parameter, if present, to be + * passed as the first parameter to any wrapper functions. + */ bool InterfaceMakerPythonNative:: synthesize_this_parameter() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::separate_overloading -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require overloaded -// instances of a function to be defined as separate -// functions (each with its own hashed name), or false -// for interfaces that can support overloading natively, -// and thus only require one wrapper function per each -// overloaded input function. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require overloaded instances of a function to be defined as + * separate functions (each with its own hashed name), or false for interfaces + * that can support overloading natively, and thus only require one wrapper + * function per each overloaded input function. + */ bool InterfaceMakerPythonNative:: separate_overloading() { - // We used to return true here. Nowadays, some of the default - // arguments are handled in the PyArg_ParseTuple code, and some - // are still being considered as separate overloads (this depends - // on a bunch of factors, see collapse_default_remaps). - // This is all handled elsewhere. + // We used to return true here. Nowadays, some of the default arguments are + // handled in the PyArg_ParseTuple code, and some are still being considered + // as separate overloads (this depends on a bunch of factors, see + // collapse_default_remaps). This is all handled elsewhere. return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::get_wrapper_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate wrapper -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate wrapper function names. + */ string InterfaceMakerPythonNative:: get_wrapper_prefix() { return "Dtool_"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::get_unique_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate unique -// symbolic names, which are not necessarily C-callable -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate unique symbolic names, which are + * not necessarily C-callable function names. + */ string InterfaceMakerPythonNative:: get_unique_prefix() { return "Dtool_"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::record_function_wrapper -// Access: Protected, Virtual -// Description: Associates the function wrapper with its function in -// the appropriate structures in the database. -//////////////////////////////////////////////////////////////////// +/** + * Associates the function wrapper with its function in the appropriate + * structures in the database. + */ void InterfaceMakerPythonNative:: record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index) { ifunc._python_wrappers.push_back(wrapper_index); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_prototype_for -// Access: Private -// Description: Writes the prototype for the indicated function. -//////////////////////////////////////////////////////////////////// +/** + * Writes the prototype for the indicated function. + */ void InterfaceMakerPythonNative:: write_prototype_for(ostream &out, InterfaceMaker::Function *func) { std::string fname = "PyObject *" + func->_name + "(PyObject *self, PyObject *args)"; write_prototype_for_name(out, func, fname); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_prototype_for_name -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterfaceMakerPythonNative:: write_prototype_for_name(ostream &out, InterfaceMaker::Function *func, const std::string &function_namename) { Function::Remaps::const_iterator ri; -// for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { -// FunctionRemap *remap = (*ri); +// for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { +// FunctionRemap *remap = (*ri); if (!output_function_names) { - // If we're not saving the function names, don't export it from - // the library. + // If we're not saving the function names, don't export it from the + // library. out << "static "; } else { out << "extern \"C\" "; } out << function_namename << ";\n"; -// } +// } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_function_for_top -// Access: Private -// Description: Writes the definition for a function that will call -// the indicated C++ function or method. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a function that will call the indicated C++ + * function or method. + */ void InterfaceMakerPythonNative:: write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker::Function *func) { - // First check if this function has non-slotted and legal remaps, - // ie. if we should even write it. + // First check if this function has non-slotted and legal remaps, ie. if we + // should even write it. bool has_remaps = false; Function::Remaps::const_iterator ri; @@ -3261,9 +3230,9 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker return; } - // This is a bit of a hack, as these methods should probably be - // going through the slotted function system. But it's kind of - // pointless to write these out, and a waste of space. + // This is a bit of a hack, as these methods should probably be going + // through the slotted function system. But it's kind of pointless to write + // these out, and a waste of space. string fname = func->_ifunc.get_name(); if (fname == "operator <" || fname == "operator <=" || @@ -3330,12 +3299,10 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker out << "#endif\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_function_for_name -// Access: Private -// Description: Writes the definition for a function that will call -// the indicated C++ function or method. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a function that will call the indicated C++ + * function or method. + */ void InterfaceMakerPythonNative:: write_function_for_name(ostream &out, Object *obj, const Function::Remaps &remaps, @@ -3389,7 +3356,7 @@ write_function_for_name(ostream &out, Object *obj, if (has_this) { std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); std::string cClassName = obj->_itype.get_true_name(); - //string class_name = remap->_cpptype->get_simple_name(); + // string class_name = remap->_cpptype->get_simple_name(); // Extract pointer from 'self' parameter. out << " " << cClassName << " *local_this = NULL;\n"; @@ -3440,9 +3407,9 @@ write_function_for_name(ostream &out, Object *obj, break; } - // Keep track of how many args this function actually takes for - // the error message. We add one to the parameter count for "self", - // following the Python convention. + // Keep track of how many args this function actually takes for the error + // message. We add one to the parameter count for "self", following the + // Python convention. int add_self = has_this ? 1 : 0; set num_args; @@ -3526,7 +3493,8 @@ write_function_for_name(ostream &out, Object *obj, mii = map_sets.begin(); // If no parameters are accepted, we do need to check that the argument - // count is indeed 0, since we won't check that in write_function_instance. + // count is indeed 0, since we won't check that in + // write_function_instance. if (mii->first == 0 && args_type != AT_no_args) { switch (args_type) { case AT_keyword_args: @@ -3561,8 +3529,8 @@ write_function_for_name(ostream &out, Object *obj, out << " }\n"; } else if (args_type == AT_keyword_args && max_required_args == 1 && mii->first == 1) { - // Check this to be sure, as we handle the case of only 1 keyword arg - // in write_function_forset (not using ParseTupleAndKeywords). + // Check this to be sure, as we handle the case of only 1 keyword arg in + // write_function_forset (not using ParseTupleAndKeywords). out << " int parameter_count = (int)PyTuple_Size(args);\n" " if (kwds != NULL) {\n" " parameter_count += (int)PyDict_Size(kwds);\n" @@ -3584,8 +3552,8 @@ write_function_for_name(ostream &out, Object *obj, coercion_allowed, true, args_type, return_flags, true, !all_nonconst); // This block is often unreachable for many functions... maybe we can - // figure out a way in the future to better determine when it will be - // and won't be necessary to write this out. + // figure out a way in the future to better determine when it will be and + // won't be necessary to write this out. if (args_type != AT_no_args) { out << " if (!_PyErr_OCCURRED()) {\n" << " "; @@ -3604,35 +3572,27 @@ write_function_for_name(ostream &out, Object *obj, out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_coerce_constructor -// Access: Private -// Description: Writes the definition for a coerce constructor: a -// special constructor that is called to implicitly -// cast a tuple or other type to a desired type. This -// is done by calling the appropriate constructor or -// static make() function. Constructors marked with -// the "explicit" keyword aren't considered, just like -// in C++. -// -// There are usually two coerce constructors: one for -// const pointers, one for non-const pointers. This -// is due to the possibility that a static make() -// function may return a const pointer. -// -// There are two variants of this: if the class in -// question is a ReferenceCount, the coerce constructor -// takes a reference to a PointerTo or ConstPointerTo -// to store the converted pointer in. Otherwise, it -// is a regular pointer, and an additional boolean -// indicates whether the caller is supposed to call -// "delete" on the coerced pointer or not. -// -// In all cases, the coerce constructor returns a bool -// indicating whether the conversion was possible. -// It does not raise exceptions when none of the -// constructors matched, but just returns false. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a coerce constructor: a special constructor that + * is called to implicitly cast a tuple or other type to a desired type. This + * is done by calling the appropriate constructor or static make() function. + * Constructors marked with the "explicit" keyword aren't considered, just + * like in C++. + * + * There are usually two coerce constructors: one for const pointers, one for + * non-const pointers. This is due to the possibility that a static make() + * function may return a const pointer. + * + * There are two variants of this: if the class in question is a + * ReferenceCount, the coerce constructor takes a reference to a PointerTo or + * ConstPointerTo to store the converted pointer in. Otherwise, it is a + * regular pointer, and an additional boolean indicates whether the caller is + * supposed to call "delete" on the coerced pointer or not. + * + * In all cases, the coerce constructor returns a bool indicating whether the + * conversion was possible. It does not raise exceptions when none of the + * constructors matched, but just returns false. + */ void InterfaceMakerPythonNative:: write_coerce_constructor(ostream &out, Object *obj, bool is_const) { std::map > map_sets; @@ -3656,8 +3616,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { CPPType *return_type = remap->_return_type->get_new_type(); if (!is_const && TypeManager::is_const_pointer_or_ref(return_type)) { - // If we're making the non-const coerce constructor, reject - // this remap if it returns a const pointer. + // If we're making the non-const coerce constructor, reject this + // remap if it returns a const pointer. continue; } @@ -3680,8 +3640,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { } } - // Now go through the constructors that are suitable for coercion. - // This excludes copy constructors and ones marked "explicit". + // Now go through the constructors that are suitable for coercion. This + // excludes copy constructors and ones marked "explicit". for (fi = obj->_constructors.begin(); fi != obj->_constructors.end(); ++fi) { Function *func = (*fi); for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { @@ -3714,17 +3674,19 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { int return_flags = RF_coerced; if (TypeManager::is_reference_count(obj->_itype._cpptype)) { - // The coercion works slightly different for reference counted types, since - // we can handle those a bit more nicely by taking advantage of the refcount - // instead of having to use a boolean to indicate that it should be managed. + // The coercion works slightly different for reference counted types, + // since we can handle those a bit more nicely by taking advantage of the + // refcount instead of having to use a boolean to indicate that it should + // be managed. if (is_const) { out << "bool Dtool_ConstCoerce_" << ClassName << "(PyObject *args, CPT(" << cClassName << ") &coerced) {\n"; } else { out << "bool Dtool_Coerce_" << ClassName << "(PyObject *args, PT(" << cClassName << ") &coerced) {\n"; } - // Note: this relies on the PT() being initialized to NULL. This is currently - // the case in all invocations, but this may not be true in the future. + // Note: this relies on the PT() being initialized to NULL. This is + // currently the case in all invocations, but this may not be true in the + // future. out << " DTOOL_Call_ExtractThisPointerForType(args, &Dtool_" << ClassName << ", (void**)&coerced.cheat());\n"; out << " if (coerced != NULL) {\n"; out << " // The argument is already of matching type, no need to coerce.\n"; @@ -3784,9 +3746,9 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { return; } - // Coercion constructors are special cases in that they can take either - // a single value or a tuple. (They never, however, take a tuple - // containing a single value.) + // Coercion constructors are special cases in that they can take either a + // single value or a tuple. (They never, however, take a tuple containing a + // single value.) string expected_params; mii = map_sets.find(1); if (mii != map_sets.end()) { @@ -3798,7 +3760,7 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { if (map_sets.size() == 1) { out << " }\n"; - //out << " PyErr_Clear();\n"; + // out << " PyErr_Clear();\n"; error_return(out, 2, return_flags); out << "}\n\n"; return; @@ -3822,8 +3784,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { int max_args = mii->first; int min_args = min(max_required_args, max_args); - // This is not called for tuples containing just one value or no - // values at all, so we should never have to consider that case. + // This is not called for tuples containing just one value or no values + // at all, so we should never have to consider that case. if (min_args < 2) { min_args = 2; } @@ -3850,8 +3812,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { int max_args = mii->first; int min_args = min(max_required_args, max_args); - // This is not called for tuples containing just one value or no - // values at all, so we should never have to consider that case. + // This is not called for tuples containing just one value or no values at + // all, so we should never have to consider that case. if (min_args < 2) { min_args = 2; } @@ -3861,8 +3823,8 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { indent(out, 4) << "if (PyTuple_GET_SIZE(args) == " << mii->first << ") {\n"; } else { indent(out, 4) << "Py_ssize_t size = PyTuple_GET_SIZE(args);\n"; - // Not sure if this check really does any good. I guess it's a - // useful early-fail test. + // Not sure if this check really does any good. I guess it's a useful + // early-fail test. indent(out, 4) << "if (size >= " << min_args << " && size <= " << max_args << ") {\n"; } @@ -3872,46 +3834,39 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { } out << " }\n\n"; - //out << " PyErr_Clear();\n"; + // out << " PyErr_Clear();\n"; error_return(out, 2, return_flags); out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::collapse_default_remaps -// Access: Private -// Description: Special case optimization: if the last map is a subset -// of the map before it, and the last parameter is only a -// simple parameter type (that we have special default -// argument handling for), we can merge the cases. -// When this happens, we can make use of a special -// feature of PyArg_ParseTuple for handling of these -// last few default arguments. This doesn't work well -// for all types of default expressions, though, hence the -// need for this elaborate checking mechanism down here, -// which goes in parallel with the actual optional arg -// handling logic in write_function_instance. -// -// This isn't just to help reduce the amount of generated -// code; it also enables arbitrary selection of keyword -// arguments for many functions, ie. for this function: -// -// int func(int a=0, int b=0, bool c=false, string d=""); -// -// Thanks to this mechanism, we can call it like so: -// -// func(c=True, d=".") -// -// The return value is the minimum of the number -// of maximum arguments. -// -// Sorry, let me try that again: it returns the -// largest number of arguments for which the overloads -// will be separated out rather than handled via the -// special default handling mechanism. Or something. -// -// Please don't hate me. -//////////////////////////////////////////////////////////////////// +/** + * Special case optimization: if the last map is a subset of the map before + * it, and the last parameter is only a simple parameter type (that we have + * special default argument handling for), we can merge the cases. When this + * happens, we can make use of a special feature of PyArg_ParseTuple for + * handling of these last few default arguments. This doesn't work well for + * all types of default expressions, though, hence the need for this elaborate + * checking mechanism down here, which goes in parallel with the actual + * optional arg handling logic in write_function_instance. + * + * This isn't just to help reduce the amount of generated code; it also + * enables arbitrary selection of keyword arguments for many functions, ie. + * for this function: + * + * int func(int a=0, int b=0, bool c=false, string d=""); + * + * Thanks to this mechanism, we can call it like so: + * + * func(c=True, d=".") + * + * The return value is the minimum of the number of maximum arguments. + * + * Sorry, let me try that again: it returns the largest number of arguments + * for which the overloads will be separated out rather than handled via the + * special default handling mechanism. Or something. + * + * Please don't hate me. + */ int InterfaceMakerPythonNative:: collapse_default_remaps(std::map > &map_sets, int max_required_args) { @@ -3926,7 +3881,8 @@ collapse_default_remaps(std::map > &map_sets, if (std::includes(rmi_next->second.begin(), rmi_next->second.end(), rmi->second.begin(), rmi->second.end())) { - // Check if the nth argument is something we can easily create a default for. + // Check if the nth argument is something we can easily create a default + // for. std::set::iterator sii; for (sii = rmi->second.begin(); sii != rmi->second.end(); ++sii) { FunctionRemap *remap = (*sii); @@ -3949,9 +3905,10 @@ collapse_default_remaps(std::map > &map_sets, } else if (TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) { goto abort_iteration; } else { - // Regular strings are OK if the default argument is a string literal - // or the default string constructor, since those are trivial to handle. - // This actually covers almost all of the cases of default string args. + // Regular strings are OK if the default argument is a string + // literal or the default string constructor, since those are + // trivial to handle. This actually covers almost all of the + // cases of default string args. CPPExpression::Type expr_type = param->get_default_value()->_type; if (expr_type != CPPExpression::T_default_construct && expr_type != CPPExpression::T_string) { @@ -3976,11 +3933,11 @@ collapse_default_remaps(std::map > &map_sets, } else if (TypeManager::is_pointer_to_simple(type)) { goto abort_iteration; } else if (TypeManager::is_pointer(type)) { - // I'm allowing other pointer types, but only if the expression happens - // to evaluate to a numeric constant (which will likely only be NULL). - // There are too many issues to resolve right now with allowing more - // complex default expressions, including issues in the C++ parser - // (but the reader is welcome to give it a try!) + // I'm allowing other pointer types, but only if the expression + // happens to evaluate to a numeric constant (which will likely only + // be NULL). There are too many issues to resolve right now with + // allowing more complex default expressions, including issues in + // the C++ parser (but the reader is welcome to give it a try!) CPPExpression::Result res = param->get_default_value()->evaluate(); if (res._type != CPPExpression::RT_integer && res._type != CPPExpression::RT_pointer) { @@ -3992,8 +3949,8 @@ collapse_default_remaps(std::map > &map_sets, } // rmi_next has a superset of the remaps in rmi, and we are going to - // erase rmi_next, so put all the remaps in rmi. - //rmi->second = rmi_next->second; + // erase rmi_next, so put all the remaps in rmi. rmi->second = + // rmi_next->second; max_required_args = rmi_next->first; rmi = rmi_next; @@ -4004,8 +3961,8 @@ collapse_default_remaps(std::map > &map_sets, } abort_iteration: - // Now erase the other remap sets. Reverse iterators are weird, we - // first need to get forward iterators and decrement them by one. + // Now erase the other remap sets. Reverse iterators are weird, we first + // need to get forward iterators and decrement them by one. std::map >::iterator erase_begin, erase_end; erase_begin = rmi.base(); erase_end = map_sets.rbegin().base(); @@ -4019,11 +3976,11 @@ abort_iteration: // We're never erasing the map set with the highest number of args. nassertr(erase_end != map_sets.end(), max_required_args); - // We know erase_begin is a superset of erase_end, but we want all - // the remaps in erase_end (which we aren't erasing). - //if (rmi == map_sets.rbegin()) { + // We know erase_begin is a superset of erase_end, but we want all the + // remaps in erase_end (which we aren't erasing). if (rmi == + // map_sets.rbegin()) { erase_end->second = erase_begin->second; - //} + // } map_sets.erase(erase_begin, erase_end); @@ -4032,13 +3989,12 @@ abort_iteration: return max_required_args; } -//////////////////////////////////////////////////////////////////// -// Function: GetParnetDepth -// Support Function used to Sort the name based overrides.. For know must be complex to simple -//////////////////////////////////////////////////////////////////// +/** + + */ int get_type_sort(CPPType *type) { int answer = 0; -// printf(" %s\n",type->get_local_name().c_str()); +// printf(" %s\n",type->get_local_name().c_str()); // The highest numbered one will be checked first. if (TypeManager::is_pointer_to_Py_buffer(type)) { @@ -4090,16 +4046,14 @@ int get_type_sort(CPPType *type) { } } answer += deepest; -// printf(" Class Name %s %d\n",itype.get_name().c_str(),answer); +// printf(" Class Name %s %d\n",itype.get_name().c_str(),answer); } -// printf(" Class Name %s %d\n",itype.get_name().c_str(),answer); +// printf(" Class Name %s %d\n",itype.get_name().c_str(),answer); return answer; } -//////////////////////////////////////////////////////////////////// -// The Core sort function for remap calling orders.. -//////////////////////////////////////////////////////////////////// +// The Core sort function for remap calling orders.. bool RemapCompareLess(FunctionRemap *in1, FunctionRemap *in2) { assert(in1 != NULL); assert(in2 != NULL); @@ -4130,62 +4084,48 @@ bool RemapCompareLess(FunctionRemap *in1, FunctionRemap *in2) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_function_forset -// Access: Private -// Description: Writes out a set of function wrappers that handle -// all instances of a particular function with the -// same number of parameters. -// (Actually, in some cases relating to default -// argument handling, this may be called with remaps -// taking a range of parameters.) -// -// min_num_args and max_num_args are the range of -// parameter counts to respect for these functions. -// This is important for default argument handling. -// -// expected_params is a reference to a string that -// will be filled in with a list of overloads that -// this function takes, for displaying in the doc -// string and error messages. -// -// If coercion_allowed is true, it will attempt -// to convert arguments to the appropriate parameter -// type using the appropriate Dtool_Coerce function. -// This means it may write some remaps twice: once -// without coercion, and then it may go back and -// write it a second time to try parameter coercion. -// -// If report_errors is true, it will print an error -// and exit when one has occurred, instead of falling -// back to the next overload. This is automatically -// disabled when more than one function is passed. -// -// args_type indicates whether this function takes -// no args, a single PyObject* arg, an args tuple, -// or an args tuple and kwargs dictionary. -// -// return_flags indicates which value should be -// returned from the wrapper function and what should -// be returned on error. -// -// If check_exceptions is false, it will not check -// if the function raised an exception, except if -// it took PyObject* arguments. This should NEVER -// be false for C++ functions that call Python code, -// since that would block a meaningful exception -// like SystemExit or KeyboardInterrupt. -// -// If verify_const is set, it will write out a check -// to make sure that non-const functions aren't called -// for a const "this". This is usually only false when -// write_function_for_name has already done this check -// (which it does when *all* remaps are non-const). -// -// If first_pexpr is not empty, it represents the -// preconverted value of the first parameter. This -// is a special-case hack for one of the slot functions. -//////////////////////////////////////////////////////////////////// +/** + * Writes out a set of function wrappers that handle all instances of a + * particular function with the same number of parameters. (Actually, in some + * cases relating to default argument handling, this may be called with remaps + * taking a range of parameters.) + * + * min_num_args and max_num_args are the range of parameter counts to respect + * for these functions. This is important for default argument handling. + * + * expected_params is a reference to a string that will be filled in with a + * list of overloads that this function takes, for displaying in the doc + * string and error messages. + * + * If coercion_allowed is true, it will attempt to convert arguments to the + * appropriate parameter type using the appropriate Dtool_Coerce function. + * This means it may write some remaps twice: once without coercion, and then + * it may go back and write it a second time to try parameter coercion. + * + * If report_errors is true, it will print an error and exit when one has + * occurred, instead of falling back to the next overload. This is + * automatically disabled when more than one function is passed. + * + * args_type indicates whether this function takes no args, a single PyObject* + * arg, an args tuple, or an args tuple and kwargs dictionary. + * + * return_flags indicates which value should be returned from the wrapper + * function and what should be returned on error. + * + * If check_exceptions is false, it will not check if the function raised an + * exception, except if it took PyObject* arguments. This should NEVER be + * false for C++ functions that call Python code, since that would block a + * meaningful exception like SystemExit or KeyboardInterrupt. + * + * If verify_const is set, it will write out a check to make sure that non- + * const functions aren't called for a const "this". This is usually only + * false when write_function_for_name has already done this check (which it + * does when *all* remaps are non-const). + * + * If first_pexpr is not empty, it represents the preconverted value of the + * first parameter. This is a special-case hack for one of the slot + * functions. + */ void InterfaceMakerPythonNative:: write_function_forset(ostream &out, const std::set &remapsin, @@ -4206,8 +4146,8 @@ write_function_forset(ostream &out, bool all_nonconst = false; if (verify_const) { - // Check if all of the remaps are non-const. If so, we only have to - // check the constness of the self pointer once, rather than per remap. + // Check if all of the remaps are non-const. If so, we only have to check + // the constness of the self pointer once, rather than per remap. all_nonconst = true; for (sii = remapsin.begin(); sii != remapsin.end(); ++sii) { @@ -4231,7 +4171,8 @@ write_function_forset(ostream &out, bool same_first_param = false; // If there's only one arg and all remaps have the same parameter name, we - // extract it from the dictionary, so we don't have to call ParseTupleAndKeywords. + // extract it from the dictionary, so we don't have to call + // ParseTupleAndKeywords. if (first_pexpr.empty() && min_num_args == 1 && max_num_args == 1 && args_type == AT_keyword_args) { sii = remapsin.begin(); @@ -4250,7 +4191,8 @@ write_function_forset(ostream &out, if (same_first_param) { // Yes, they all have the same argument name (or there is only one remap). - // Extract it from the dict so we don't have to call ParseTupleAndKeywords. + // Extract it from the dict so we don't have to call + // ParseTupleAndKeywords. indent(out, indent_level) << "PyObject *arg = NULL;\n"; indent(out, indent_level) << "if (PyTuple_GET_SIZE(args) == 1) {\n"; indent(out, indent_level) << " arg = PyTuple_GET_ITEM(args, 0);\n"; @@ -4270,18 +4212,18 @@ write_function_forset(ostream &out, } if (remapsin.size() > 1) { - // There are multiple different overloads for this number of - // parameters. Sort them all into order from most-specific to - // least-specific, then try them one at a time. + // There are multiple different overloads for this number of parameters. + // Sort them all into order from most-specific to least-specific, then try + // them one at a time. std::vector remaps (remapsin.begin(), remapsin.end()); std::sort(remaps.begin(), remaps.end(), RemapCompareLess); std::vector::const_iterator sii; - // Check if all of them have an InternalName pointer as first - // parameter. This is a dirty hack, of course, to work around an - // awkward overload resolution problem in NodePath::set_shader_input() - // (while perhaps also improving its performance). If I had more time - // I'd create a better solution. + // Check if all of them have an InternalName pointer as first parameter. + // This is a dirty hack, of course, to work around an awkward overload + // resolution problem in NodePath::set_shader_input() (while perhaps also + // improving its performance). If I had more time I'd create a better + // solution. bool first_internalname = false; string first_pexpr2(first_pexpr); if (first_pexpr.empty() && args_type != AT_no_args) { @@ -4335,17 +4277,16 @@ write_function_forset(ostream &out, if (coercion_allowed && is_remap_coercion_possible(remap)) { if (++num_coercion_possible == 1 && sii == remaps.end()) { - // This is the last remap, and it happens to be the only one - // with coercion possible. So we might as well just break off - // now, and let this case be handled by the coercion loop, below. - // BUG: this remap doesn't get listed in expected_params. + // This is the last remap, and it happens to be the only one with + // coercion possible. So we might as well just break off now, and + // let this case be handled by the coercion loop, below. BUG: this + // remap doesn't get listed in expected_params. break; } } if (verify_const && (remap->_has_this && !remap->_const_method)) { - // If it's a non-const method, we only allow a - // non-const this. + // If it's a non-const method, we only allow a non-const this. indent(out, indent_level) << "if (!((Dtool_PyInstDef *)self)->_is_const) {\n"; } else { @@ -4357,8 +4298,8 @@ write_function_forset(ostream &out, remap->write_orig_prototype(out, 0, false, (max_num_args - min_num_args)); out << "\n"; - // NB. We don't pass on report_errors here because we want - // it to silently drop down to the next overload. + // NB. We don't pass on report_errors here because we want it to + // silently drop down to the next overload. write_function_instance(out, remap, min_num_args, max_num_args, expected_params, indent_level + 2, @@ -4419,8 +4360,8 @@ write_function_forset(ostream &out, indent(out, indent_level) << "}\n"; } } else { - // There is only one possible overload with this number of - // parameters. Just call it. + // There is only one possible overload with this number of parameters. + // Just call it. sii = remapsin.begin(); remap = (*sii); @@ -4468,40 +4409,31 @@ write_function_forset(ostream &out, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::write_function_instance -// Access: Private -// Description: Writes out the code to handle a a single instance -// of an overloaded function. This will convert all -// of the arguments from PyObject* to the appropriate -// C++ type, call the C++ function, possibly check -// for errors, and construct a Python wrapper for the -// return value. -// -// return_flags indicates which value should be -// returned from the wrapper function and what should -// be returned on error. -// -// If coercion_possible is true, it will attempt -// to convert arguments to the appropriate parameter -// type using the appropriate Dtool_Coerce function. -// -// If report_errors is true, it will print an error -// and exit when one has occurred, instead of falling -// back to the next overload. This should be done -// if it is the only overload. -// -// If check_exceptions is false, it will not check -// if the function raised an exception, except if -// it took PyObject* arguments. This should NEVER -// be false for C++ functions that call Python code, -// since that would block a meaningful exception -// like SystemExit or KeyboardInterrupt. -// -// If first_pexpr is not empty, it represents the -// preconverted value of the first parameter. This -// is a special-case hack for one of the slot functions. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the code to handle a a single instance of an overloaded + * function. This will convert all of the arguments from PyObject* to the + * appropriate C++ type, call the C++ function, possibly check for errors, and + * construct a Python wrapper for the return value. + * + * return_flags indicates which value should be returned from the wrapper + * function and what should be returned on error. + * + * If coercion_possible is true, it will attempt to convert arguments to the + * appropriate parameter type using the appropriate Dtool_Coerce function. + * + * If report_errors is true, it will print an error and exit when one has + * occurred, instead of falling back to the next overload. This should be + * done if it is the only overload. + * + * If check_exceptions is false, it will not check if the function raised an + * exception, except if it took PyObject* arguments. This should NEVER be + * false for C++ functions that call Python code, since that would block a + * meaningful exception like SystemExit or KeyboardInterrupt. + * + * If first_pexpr is not empty, it represents the preconverted value of the + * first parameter. This is a special-case hack for one of the slot + * functions. + */ void InterfaceMakerPythonNative:: write_function_instance(ostream &out, FunctionRemap *remap, int min_num_args, int max_num_args, @@ -4521,22 +4453,22 @@ write_function_instance(ostream &out, FunctionRemap *remap, LineStream extra_cleanup; int min_version = 0; - // This will be set if the function itself is suspected of possibly - // raising a TypeError. + // This will be set if the function itself is suspected of possibly raising + // a TypeError. bool may_raise_typeerror = false; - // This will be set to true if one of the things we're about to do - // *might* raise a TypeError that we may have to clear. + // This will be set to true if one of the things we're about to do *might* + // raise a TypeError that we may have to clear. bool clear_error = false; bool is_constructor = (remap->_type == FunctionRemap::T_constructor); InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - // Make one pass through the parameter list. We will output a - // one-line temporary variable definition for each parameter, while - // simultaneously building the ParseTuple() function call and also - // the parameter expression list for call_function(). + // Make one pass through the parameter list. We will output a one-line + // temporary variable definition for each parameter, while simultaneously + // building the ParseTuple() function call and also the parameter expression + // list for call_function(). expected_params += methodNameFromCppName(remap, "", false); expected_params += "("; @@ -4603,10 +4535,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, continue; } - // Has this remap been selected to consider optional arguments for - // this parameter? We can do that by adding a vertical bar to the - // PyArg_ParseTuple format string, coupled with some extra logic - // in the argument handling, below. + // Has this remap been selected to consider optional arguments for this + // parameter? We can do that by adding a vertical bar to the + // PyArg_ParseTuple format string, coupled with some extra logic in the + // argument handling, below. bool is_optional = false; if (remap->_has_this && !is_constructor) { if (pn > min_num_args) { @@ -4628,24 +4560,24 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += ", "; } - // This is the string to convert our local variable to the - // appropriate C++ type. Normally this is just a cast. + // This is the string to convert our local variable to the appropriate C++ + // type. Normally this is just a cast. string pexpr_string = "(" + orig_type->get_local_name(&parser) + ")" + param_name; string default_expr; if (is_optional) { - // If this is an optional argument, PyArg_ParseTuple will leave - // the variable unchanged if it has been omitted, so we have to - // initialize it to the desired default expression. Format it. + // If this is an optional argument, PyArg_ParseTuple will leave the + // variable unchanged if it has been omitted, so we have to initialize + // it to the desired default expression. Format it. ostringstream default_expr_str; default_expr_str << " = "; default_value->output(default_expr_str, 0, &parser, false); default_expr = default_expr_str.str(); - // We should only ever have to consider optional arguments for - // functions taking a variable number of arguments. + // We should only ever have to consider optional arguments for functions + // taking a variable number of arguments. nassertv(args_type == AT_varargs || args_type == AT_keyword_args); } @@ -4788,12 +4720,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, + "_str, &" + param_name + "_len"; } -// if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) { -// pexpr_string = "&std::string(" + -// param_name + "_str, " + param_name + "_len)"; -// } else { +// if (TypeManager::is_const_ptr_to_basic_string_char(orig_type)) { +// pexpr_string = "&std::string(" + param_name + "_str, " + param_name + +// "_len)"; } else { pexpr_string = param_name + "_str, " + param_name + "_len"; -// } +// } expected_params += "str"; } // Remember to clear the TypeError that any of the above methods raise. @@ -4830,7 +4761,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, format_specifiers += "c"; parameter_list += ", &" + param_name; - //extra_param_check << " && isascii(" << param_name << ")"; + // extra_param_check << " && isascii(" << param_name << ")"; pexpr_string = "(char) " + param_name; expected_params += "char"; only_pyobjects = false; @@ -4844,8 +4775,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, format_specifiers += "U"; parameter_list += ", &" + param_name; - // We tell it to copy 2 characters, but make sure it only - // copied one, as a trick to check for the proper length in one go. + // We tell it to copy 2 characters, but make sure it only copied one, as + // a trick to check for the proper length in one go. extra_convert << "wchar_t " << param_name << "_chars[2];\n"; extra_param_check << " && PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_chars, 2) == 1"; @@ -4863,9 +4794,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else if (TypeManager::is_size(type)) { // It certainly isn't the exact same thing as size_t, but Py_ssize_t - // should at least be the same size. The problem with mapping this - // to unsigned int is that that doesn't work well on 64-bit systems, - // on which size_t is a 64-bit integer. + // should at least be the same size. The problem with mapping this to + // unsigned int is that that doesn't work well on 64-bit systems, on + // which size_t is a 64-bit integer. indent(out, indent_level) << "Py_ssize_t " << param_name << default_expr << ";\n"; format_specifiers += "n"; parameter_list += ", &" + param_name; @@ -4912,8 +4843,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, parameter_list += ", &" + param_name; } - // The "H" format code, unlike "h", does not do overflow checking, so - // we have to do it ourselves (except in release builds). + // The "H" format code, unlike "h", does not do overflow checking, so we + // have to do it ourselves (except in release builds). extra_convert << "#ifndef NDEBUG\n"; @@ -4983,12 +4914,12 @@ write_function_instance(ostream &out, FunctionRemap *remap, parameter_list += ", &" + param_name; } - // The "I" format code, unlike "i", does not do overflow checking, so - // we have to do it ourselves (in debug builds). Note that Python 2 - // stores longs internally, for ints, so we don't do it for Python 2 on - // Windows, where longs are the same size as ints. - // BUG: does not catch negative values on Windows when going through - // the PyArg_ParseTuple case. + // The "I" format code, unlike "i", does not do overflow checking, so we + // have to do it ourselves (in debug builds). Note that Python 2 stores + // longs internally, for ints, so we don't do it for Python 2 on + // Windows, where longs are the same size as ints. BUG: does not catch + // negative values on Windows when going through the PyArg_ParseTuple + // case. if (!TypeManager::is_long(type)) { extra_convert << "#if (SIZEOF_LONG > SIZEOF_INT) && !defined(NDEBUG)\n" @@ -5092,14 +5023,14 @@ write_function_instance(ostream &out, FunctionRemap *remap, pexpr_string = "(PyTypeObject *)" + param_name; expected_params += "type"; - // It's reasonable to assume that a function taking a PyTypeObject - // might also throw a TypeError if the type is incorrect. + // It's reasonable to assume that a function taking a PyTypeObject might + // also throw a TypeError if the type is incorrect. may_raise_typeerror = true; } else if (TypeManager::is_pointer_to_PyStringObject(type)) { if (args_type == AT_single_arg) { - // This is a single-arg function, so there's no need - // to convert anything. + // This is a single-arg function, so there's no need to convert + // anything. param_name = "arg"; type_check = "PyString_Check(arg)"; pexpr_string = "(PyStringObject *)" + param_name; @@ -5113,8 +5044,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else if (TypeManager::is_pointer_to_PyUnicodeObject(type)) { if (args_type == AT_single_arg) { - // This is a single-arg function, so there's no need - // to convert anything. + // This is a single-arg function, so there's no need to convert + // anything. param_name = "arg"; type_check = "PyUnicode_Check(arg)"; pexpr_string = "(PyUnicodeObject *)" + param_name; @@ -5128,8 +5059,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else if (TypeManager::is_pointer_to_PyObject(type)) { if (args_type == AT_single_arg) { - // This is a single-arg function, so there's no need - // to convert anything. + // This is a single-arg function, so there's no need to convert + // anything. param_name = "arg"; } else { indent(out, indent_level) << "PyObject *" << param_name << default_expr << ";\n"; @@ -5139,8 +5070,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, pexpr_string = param_name; expected_params += "object"; - // It's reasonable to assume that a function taking a PyObject - // might also throw a TypeError if the type is incorrect. + // It's reasonable to assume that a function taking a PyObject might + // also throw a TypeError if the type is incorrect. may_raise_typeerror = true; } else if (TypeManager::is_pointer_to_Py_buffer(type)) { @@ -5289,8 +5220,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (TypeManager::is_const_pointer_or_ref(orig_type)) { expected_params += "const "; - //} else { - // expected_params += "non-const "; + // } else { expected_params += "non-const "; } string expected_class_name = classNameFromCppName(obj_type->get_simple_name(), false); expected_params += expected_class_name; @@ -5323,8 +5253,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (coercion_possible && has_coerce_constructor(obj_type->as_struct_type())) { - // Call the coercion function directly, which will try to - // extract the pointer directly before trying coercion. + // Call the coercion function directly, which will try to extract the + // pointer directly before trying coercion. string coerce_call; if (TypeManager::is_reference_count(obj_type)) { @@ -5346,8 +5276,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, "(" + param_name + ", " + param_name + "_this)"; } - // Use move constructor when available for functions that take - // an actual PointerTo. This eliminates an unref()/ref() pair. + // Use move constructor when available for functions that take an + // actual PointerTo. This eliminates an unref()ref() pair. pexpr_string = "MOVE(" + param_name + "_this)"; } else if (TypeManager::is_trivial(obj_type)) { @@ -5376,8 +5306,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, pexpr_string = param_name + "_this"; } else { - // This is a bit less elegant: we use a bool to store whether - // we're supposed to clean up the reference afterward. + // This is a bit less elegant: we use a bool to store whether we're + // supposed to clean up the reference afterward. type->output_instance(extra_convert, param_name + "_this", &parser); extra_convert << default_expr << ";\n" @@ -5526,8 +5456,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, case AT_varargs: // Wrapper takes a varargs tuple. if (only_pyobjects) { - // All parameters are PyObject*, so we can use the slightly - // more efficient PyArg_UnpackTuple function instead. + // All parameters are PyObject*, so we can use the slightly more + // efficient PyArg_UnpackTuple function instead. indent(out, indent_level) << "if (PyArg_UnpackTuple(args, \"" << methodNameFromCppName(remap, "", false) @@ -5581,9 +5511,9 @@ write_function_instance(ostream &out, FunctionRemap *remap, } if (!remap->_has_this && (remap->_flags & FunctionRemap::F_explicit_self) != 0) { - // If we'll be passing "self" to the constructor, we need to - // pre-initialize it here. Unfortunately, we can't pre-load the - // "this" pointer, but the constructor itself can do this. + // If we'll be passing "self" to the constructor, we need to pre- + // initialize it here. Unfortunately, we can't pre-load the "this" + // pointer, but the constructor itself can do this. CPPType *orig_type = remap->_return_type->get_orig_type(); TypeIndex type_index = builder.get_type(TypeManager::unwrap(TypeManager::resolve_type(orig_type)), false); @@ -5593,10 +5523,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "// Pre-initialize self for the constructor\n"; if (!is_constructor || (return_flags & RF_int) == 0) { - // This is not a constructor, but somehow we landed up here at a - // static method requiring a 'self' pointer. This happens in - // coercion constructors in particular. We'll have to create - // a temporary PyObject instance to pass to it. + // This is not a constructor, but somehow we landed up here at a static + // method requiring a 'self' pointer. This happens in coercion + // constructors in particular. We'll have to create a temporary + // PyObject instance to pass to it. indent(out, indent_level) << "PyObject *self = Dtool_new_" @@ -5606,8 +5536,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_cleanup << "PyObject_Del(self);\n"; } else { - //XXX rdb: this isn't needed, is it, because tp_new already - // initializes the instance? + // XXX rdb: this isn't needed, is it, because tp_new already initializes + // the instance? indent(out, indent_level) << "DTool_PyInit_Finalize(self, NULL, &" << CLASS_PREFIX << make_safe_name(itype.get_scoped_name()) @@ -5631,13 +5561,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, indent(out, indent_level) << "in_interpreter = 0;\n"; } - // If the function returns a pointer that we may need to manage, we store - // it in a temporary return_value variable and set this to true. + // If the function returns a pointer that we may need to manage, we store it + // in a temporary return_value variable and set this to true. bool manage_return = false; if (remap->_return_type->new_type_is_atomic_string()) { - // Treat strings as a special case. We don't want to format the - // return expression. + // Treat strings as a special case. We don't want to format the return + // expression. return_expr = remap->call_function(out, indent_level, false, container, pexprs); CPPType *type = remap->_return_type->get_orig_type(); indent(out, indent_level); @@ -5647,8 +5577,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, return_expr = "return_value"; } else if ((return_flags & RF_coerced) != 0 && TypeManager::is_trivial(remap->_cpptype)) { - // Another special case is the coerce constructor for a trivial type. - // We don't want to invoke "operator new" unnecessarily. + // Another special case is the coerce constructor for a trivial type. We + // don't want to invoke "operator new" unnecessarily. if (is_constructor && remap->_extension) { // Extension constructors are a special case, as usual. indent(out, indent_level) @@ -5728,8 +5658,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, check_exceptions = true; } - // Generated getters and setters don't raise exceptions or asserts - // since they don't contain any code. + // Generated getters and setters don't raise exceptions or asserts since + // they don't contain any code. if (remap->_type == FunctionRemap::T_getter || remap->_type == FunctionRemap::T_setter) { check_exceptions = false; @@ -5745,10 +5675,10 @@ write_function_instance(ostream &out, FunctionRemap *remap, return_flags &= ~RF_decref_args; } - // An even specialer special case for functions with void return or - // bool return. We have our own functions that do all this in a - // single function call, so it should reduce the amount of code output - // while not being any slower. + // An even specialer special case for functions with void return or bool + // return. We have our own functions that do all this in a single + // function call, so it should reduce the amount of code output while not + // being any slower. bool return_null = (return_flags & RF_pyobject) != 0 && (return_flags & RF_err_null) != 0; if (return_null && return_expr.empty()) { @@ -5784,19 +5714,18 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { if (check_exceptions) { // Check if a Python exception has occurred. We only do this when - // check_exception is set. If report_errors is set, this method - // must terminate on error. + // check_exception is set. If report_errors is set, this method must + // terminate on error. if (!may_raise_typeerror || report_errors) { indent(out, indent_level) << "if (_PyErr_OCCURRED()) {\n"; } else { - // If a method is some extension method that takes a PyObject*, - // and it raised a TypeError, continue. - // The documentation tells us not to compare the result of - // PyErr_Occurred against a specific exception type. However, in our - // case, this seems okay because we know that the TypeError we want - // to catch here is going to be generated by a PyErr_SetString call, - // not by user code. + // If a method is some extension method that takes a PyObject*, and it + // raised a TypeError, continue. The documentation tells us not to + // compare the result of PyErr_Occurred against a specific exception + // type. However, in our case, this seems okay because we know that + // the TypeError we want to catch here is going to be generated by a + // PyErr_SetString call, not by user code. indent(out, indent_level) << "PyObject *exception = _PyErr_OCCURRED();\n"; indent(out, indent_level) @@ -5825,11 +5754,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, return_flags &= ~RF_decref_args; } - // Outputs code to check to see if an assertion has failed while - // the C++ code was executing, and report this failure back to Python. - // Don't do this for coercion constructors since they are called by - // other wrapper functions which already check this on their own. - // Generated getters obviously can't raise asserts. + // Outputs code to check to see if an assertion has failed while the C++ + // code was executing, and report this failure back to Python. Don't do + // this for coercion constructors since they are called by other wrapper + // functions which already check this on their own. Generated getters + // obviously can't raise asserts. if (watch_asserts && (return_flags & RF_coerced) == 0 && remap->_type != FunctionRemap::T_getter && remap->_type != FunctionRemap::T_setter) { @@ -5860,8 +5789,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, } } - // Okay, we're past all the error conditions and special cases. Now - // return the return type in the way that was requested. + // Okay, we're past all the error conditions and special cases. Now return + // the return type in the way that was requested. if (return_flags & RF_int) { CPPType *orig_type = remap->_return_type->get_orig_type(); if (is_constructor) { @@ -5913,8 +5842,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, CPPType *return_type = remap->_cpptype; CPPType *orig_type = remap->_return_type->get_orig_type(); - // Special case for static make function that returns a pointer: - // cast the pointer to the right pointer type. + // Special case for static make function that returns a pointer: cast the + // pointer to the right pointer type. if (!is_constructor && (remap->_flags & FunctionRemap::F_coerce_constructor) != 0 && (TypeManager::is_pointer(orig_type) || TypeManager::is_pointer_to_base(orig_type))) { @@ -5963,8 +5892,8 @@ write_function_instance(ostream &out, FunctionRemap *remap, } if (clear_error && !report_errors) { - // We were asked not to report errors, so clear the active exception - // if this overload might have raised a TypeError. + // We were asked not to report errors, so clear the active exception if + // this overload might have raised a TypeError. indent(out, indent_level) << "PyErr_Clear();\n"; } @@ -5974,17 +5903,14 @@ write_function_instance(ostream &out, FunctionRemap *remap, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::error_return -// Access: Private -// Description: Outputs the correct return statement that should be -// used in case of error based on the ReturnFlags. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the correct return statement that should be used in case of error + * based on the ReturnFlags. + */ void InterfaceMakerPythonNative:: error_return(ostream &out, int indent_level, int return_flags) { - //if (return_flags & RF_coerced) { - // indent(out, indent_level) << "coerced = NULL;\n"; - //} + // if (return_flags & RF_coerced) { indent(out, indent_level) << "coerced = + // NULL;\n"; } if (return_flags & RF_decref_args) { indent(out, indent_level) << "Py_DECREF(args);\n"; @@ -6005,13 +5931,11 @@ error_return(ostream &out, int indent_level, int return_flags) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::error_raise_return -// Access: Private -// Description: Similar to error_return, except raises an exception -// before returning. If format_args are not the empty -// string, uses PyErr_Format instead of PyErr_SetString. -//////////////////////////////////////////////////////////////////// +/** + * Similar to error_return, except raises an exception before returning. If + * format_args are not the empty string, uses PyErr_Format instead of + * PyErr_SetString. + */ void InterfaceMakerPythonNative:: error_raise_return(ostream &out, int indent_level, int return_flags, const string &exc_type, const string &message, @@ -6043,8 +5967,8 @@ error_raise_return(ostream &out, int indent_level, int return_flags, } else if ((return_flags & RF_err_null) != 0 && (return_flags & RF_pyobject) != 0) { - // PyErr_Format always returns NULL. Passing it on directly allows - // the compiler to make a tiny optimization, so why not. + // PyErr_Format always returns NULL. Passing it on directly allows the + // compiler to make a tiny optimization, so why not. indent(out, indent_level) << "return PyErr_Format(PyExc_" << exc_type << ",\n"; output_quoted(out, indent_level + 20, message); out << ",\n"; @@ -6061,12 +5985,10 @@ error_raise_return(ostream &out, int indent_level, int return_flags, error_return(out, indent_level, return_flags); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::pack_return_value -// Access: Private -// Description: Outputs a command to pack the indicated expression, -// of the return_type type, as a Python return value. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a command to pack the indicated expression, of the return_type + * type, as a Python return value. + */ void InterfaceMakerPythonNative:: pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, string return_expr) { @@ -6276,7 +6198,7 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, } else { indent(out, indent_level) << "Should Never Reach This InterfaceMakerPythonNative::pack_python_value"; - //<< "return PyLongOrInt_FromLong((int) " << return_expr << ");\n"; + // << "return PyLongOrInt_FromLong((int) " << return_expr << ");\n"; } } else { @@ -6286,12 +6208,9 @@ pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonName::write_make_seq -// Access: Public -// Description: Generates the synthetic method described by the -// MAKE_SEQ() macro. -//////////////////////////////////////////////////////////////////// +/** + * Generates the synthetic method described by the MAKE_SEQ() macro. + */ void InterfaceMakerPythonNative:: write_make_seq(ostream &out, Object *obj, const std::string &ClassName, const std::string &cClassName, MakeSeq *make_seq) { @@ -6301,9 +6220,9 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, out << "static PyObject *" << make_seq->_name + "(PyObject *self, PyObject *) {\n"; - // This used to return a list. But it should really be a tuple, I - // think, because it probably makes more sense for it to be immutable - // (as changes to it won't be visible on the C++ side anyway). + // This used to return a list. But it should really be a tuple, I think, + // because it probably makes more sense for it to be immutable (as changes + // to it won't be visible on the C++ side anyway). FunctionRemap *remap = make_seq->_length_getter->_remaps.front(); vector_string pexprs; @@ -6323,8 +6242,8 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, if ((elem_getter->_args_type & AT_varargs) == AT_varargs) { // Fast way to create a temporary tuple to hold only a single item, under - // the assumption that the called method doesn't do anything with this tuple - // other than unpack it (which is a fairly safe assumption to make). + // the assumption that the called method doesn't do anything with this + // tuple other than unpack it (which is a fairly safe assumption to make). out << " PyTupleObject args;\n"; out << " PyObject_INIT_VAR(&args, &PyTuple_Type, 1);\n"; } @@ -6379,12 +6298,9 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonName::write_getset -// Access: Public -// Description: Generates the synthetic method described by the -// MAKE_PROPERTY() macro. -//////////////////////////////////////////////////////////////////// +/** + * Generates the synthetic method described by the MAKE_PROPERTY() macro. + */ void InterfaceMakerPythonNative:: write_getset(ostream &out, Object *obj, Property *property) { @@ -6470,13 +6386,10 @@ write_getset(ostream &out, Object *obj, Property *property) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::record_object -// Access: Protected -// Description: Records the indicated type, which may be a struct -// type, along with all of its associated methods, if -// any. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated type, which may be a struct type, along with all of + * its associated methods, if any. + */ InterfaceMaker::Object *InterfaceMakerPythonNative:: record_object(TypeIndex type_index) { if (type_index == 0) { @@ -6626,22 +6539,17 @@ record_object(TypeIndex type_index) { } return object; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMaker::generate_wrappers -// Access: Public, Virtual -// Description: Walks through the set of functions in the database -// and generates wrappers for each function, storing -// these in the database. No actual code should be -// output yet; this just updates the database with the -// wrapper information. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the set of functions in the database and generates wrappers + * for each function, storing these in the database. No actual code should be + * output yet; this just updates the database with the wrapper information. + */ void InterfaceMakerPythonNative:: generate_wrappers() { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); - // We use a while loop rather than a simple for loop, because we - // might increase the number of types recursively during the - // traversal. + // We use a while loop rather than a simple for loop, because we might + // increase the number of types recursively during the traversal. int ti = 0; while (ti < idb->get_num_all_types()) { @@ -6687,10 +6595,9 @@ generate_wrappers() { } } -//////////////////////////////////////////////////////////////////// -// Function: is_cpp_type_legal -// is the cpp object supported by by the dtool_py interface.. -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: is_cpp_type_legal(CPPType *in_ctype) { if (in_ctype == NULL) { @@ -6707,7 +6614,7 @@ is_cpp_type_legal(CPPType *in_ctype) { return true; } - //bool answer = false; + // bool answer = false; CPPType *type = TypeManager::resolve_type(in_ctype); type = TypeManager::unwrap(type); @@ -6729,14 +6636,14 @@ is_cpp_type_legal(CPPType *in_ctype) { return true; } - //if (answer == false) -// printf(" -------------------- Bad Type ?? %s\n",type->get_local_name().c_str()); + // if (answer == false) printf(" -------------------- Bad Type ?? + // %s\n",type->get_local_name().c_str()); return false; } -//////////////////////////////////////////////////////////////////// -// Function: isExportThisRun -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: isExportThisRun(CPPType *ctype) { if (builder.in_forcetype(ctype->get_local_name(&parser))) { @@ -6754,9 +6661,9 @@ isExportThisRun(CPPType *ctype) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: isExportThisRun -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: isExportThisRun(Function *func) { if (func == NULL || !is_function_legal(func)) { @@ -6772,9 +6679,9 @@ isExportThisRun(Function *func) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: is_remap_legal -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: is_remap_legal(FunctionRemap *remap) { if (remap == NULL) { @@ -6783,12 +6690,13 @@ is_remap_legal(FunctionRemap *remap) { // return must be legal and managable.. if (!is_cpp_type_legal(remap->_return_type->get_orig_type())) { -// printf(" is_remap_legal Return Is Bad %s\n",remap->_return_type->get_orig_type()->get_fully_scoped_name().c_str()); +// printf(" is_remap_legal Return Is Bad %s\n",remap->_return_type->get_orig_ +// type()->get_fully_scoped_name().c_str()); return false; } - // We don't currently support returning pointers, but we accept - // them as function parameters. But const char * is an exception. + // We don't currently support returning pointers, but we accept them as + // function parameters. But const char * is an exception. if (!remap->_return_type->new_type_is_atomic_string() && TypeManager::is_pointer_to_simple(remap->_return_type->get_orig_type())) { return false; @@ -6812,11 +6720,9 @@ is_remap_legal(FunctionRemap *remap) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: has_coerce_constructor -// Returns 1 if coerce constructor -// returns const, 2 if non-const. -//////////////////////////////////////////////////////////////////// +/** + + */ int InterfaceMakerPythonNative:: has_coerce_constructor(CPPStructType *type) { if (type == NULL) { @@ -6879,9 +6785,9 @@ has_coerce_constructor(CPPStructType *type) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: is_remap_coercion_possible -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: is_remap_coercion_possible(FunctionRemap *remap) { if (remap == NULL) { @@ -6902,8 +6808,8 @@ is_remap_coercion_possible(FunctionRemap *remap) { } else if (TypeManager::is_pointer_to_Py_buffer(type)) { } else if (TypeManager::is_pointer_to_simple(type)) { } else if (TypeManager::is_pointer(type)) { - // This is a pointer to an object, so we - // might be able to coerce a parameter to it. + // This is a pointer to an object, so we might be able to coerce a + // parameter to it. CPPType *obj_type = TypeManager::unwrap(TypeManager::resolve_type(type)); if (has_coerce_constructor(obj_type->as_struct_type()) > 0) { // It has a coercion constructor, so go for it. @@ -6916,28 +6822,28 @@ is_remap_coercion_possible(FunctionRemap *remap) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: is_function_legal -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: is_function_legal(Function *func) { Function::Remaps::const_iterator ri; for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { FunctionRemap *remap = (*ri); if (is_remap_legal(remap)) { -// printf(" Function Is Marked Legal %s\n",func->_name.c_str()); +// printf(" Function Is Marked Legal %s\n",func->_name.c_str()); return true; } } -// printf(" Function Is Marked Illegal %s\n",func->_name.c_str()); +// printf(" Function Is Marked Illegal %s\n",func->_name.c_str()); return false; } -//////////////////////////////////////////////////////////////////// -// Function: IsRunTimeTyped -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: IsRunTimeTyped(const InterrogateType &itype) { TypeIndex ptype_id = itype.get_outer_class(); @@ -6955,10 +6861,9 @@ IsRunTimeTyped(const InterrogateType &itype) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DoesInheritFromIsClass -// Helper function to check cpp class inharatience.. -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { if (inclass == NULL) { @@ -6987,10 +6892,9 @@ DoesInheritFromIsClass(const CPPStructType *inclass, const std::string &name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HasAGetClassTypeFunction -// does the class have a supportable GetClassType which returns a TypeHandle. -//////////////////////////////////////////////////////////////////// +/** + + */ bool InterfaceMakerPythonNative:: HasAGetClassTypeFunction(CPPType *type) { while (type->get_subtype() == CPPDeclaration::ST_typedef) { @@ -7007,20 +6911,18 @@ HasAGetClassTypeFunction(CPPType *type) { return scope->_functions.find("get_class_type") != scope->_functions.end(); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::NeedsAStrFunction -// Access: Private -// Description: Returns -1 if the class does not define write() (and -// therefore cannot support a __str__ function). -// -// Returns 1 if the class defines write(ostream). -// -// Returns 2 if the class defines write(ostream, int). -// -// Note that if you want specific behavior for Python -// str(), you should just define a __str__ function, -// which maps directly to the appropriate type slot. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if the class does not define write() (and therefore cannot + * support a __str__ function). + * + * Returns 1 if the class defines write(ostream). + * + * Returns 2 if the class defines write(ostream, int). + * + * Note that if you want specific behavior for Python str(), you should just + * define a __str__ function, which maps directly to the appropriate type + * slot. + */ int InterfaceMakerPythonNative:: NeedsAStrFunction(const InterrogateType &itype_class) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); @@ -7076,24 +6978,21 @@ NeedsAStrFunction(const InterrogateType &itype_class) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::NeedsAReprFunction -// Access: Private -// Description: Returns -1 if the class does not define output() or -// python_repr() (and therefore cannot support a -// __repr__ function). -// -// Returns 1 if the class defines python_repr(ostream, string). -// -// Returns 2 if the class defines output(ostream). -// -// Returns 3 if the class defines an extension -// function for python_repr(ostream, string). -// -// Note that defining python_repr is deprecated in -// favor of defining a __repr__ that returns a string, -// which maps directly to the appropriate type slot. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if the class does not define output() or python_repr() (and + * therefore cannot support a __repr__ function). + * + * Returns 1 if the class defines python_repr(ostream, string). + * + * Returns 2 if the class defines output(ostream). + * + * Returns 3 if the class defines an extension function for + * python_repr(ostream, string). + * + * Note that defining python_repr is deprecated in favor of defining a + * __repr__ that returns a string, which maps directly to the appropriate type + * slot. + */ int InterfaceMakerPythonNative:: NeedsAReprFunction(const InterrogateType &itype_class) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); @@ -7182,12 +7081,9 @@ NeedsAReprFunction(const InterrogateType &itype_class) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::NeedsARichCompareFunction -// Access: Private -// Description: Returns true if the class defines a rich comparison -// operator. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the class defines a rich comparison operator. + */ bool InterfaceMakerPythonNative:: NeedsARichCompareFunction(const InterrogateType &itype_class) { InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); @@ -7220,14 +7116,11 @@ NeedsARichCompareFunction(const InterrogateType &itype_class) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonNative::output_quoted -// Access: Private -// Description: Outputs the indicated string as a single quoted, -// multi-line string to the generated C++ source code. -// The output point is left on the last line of the -// string, following the trailing quotation mark. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated string as a single quoted, multi-line string to the + * generated C++ source code. The output point is left on the last line of + * the string, following the trailing quotation mark. + */ void InterfaceMakerPythonNative:: output_quoted(ostream &out, int indent_level, const std::string &str, bool first_line) { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index a66b6d9fcc..1c7b7d98de 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -1,14 +1,13 @@ -// Filename: interfaceMakerPythonNative.h -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonNative.h + */ #ifndef INTERFACEMAKERPYTHONNATIVE_H #define INTERFACEMAKERPYTHONNATIVE_H @@ -22,11 +21,10 @@ class FunctionRemap; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMakerPythonNative -// Description : An InterfaceMaker for generating complex Python -// function wrappers around C++ code. -//////////////////////////////////////////////////////////////////// +/** + * An InterfaceMaker for generating complex Python function wrappers around + * C++ code. + */ class InterfaceMakerPythonNative : public InterfaceMakerPython { public: InterfaceMakerPythonNative(InterrogateModuleDef *def); @@ -59,9 +57,9 @@ protected: virtual void generate_wrappers(); private: - // This enum defines the various prototypes that must be generated - // for the specialty functions that Python requires, especially for - // the slotted functions. + // This enum defines the various prototypes that must be generated for the + // specialty functions that Python requires, especially for the slotted + // functions. enum WrapperType { WT_none, WT_no_params, @@ -85,8 +83,8 @@ private: WT_hash, }; - // This enum is passed to the wrapper generation functions to indicate - // what sort of values the wrapper function is expected to return. + // This enum is passed to the wrapper generation functions to indicate what + // sort of values the wrapper function is expected to return. enum ReturnFlags { // -1 on failure, 0 on success. RF_int = 0x100, diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.cxx b/dtool/src/interrogate/interfaceMakerPythonObj.cxx index d88c62e7c7..af48b2f016 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonObj.cxx @@ -1,17 +1,16 @@ -// Filename: interfaceMakerPythonObj.cxx -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonObj.cxx + * @author drose + * @date 2001-09-19 + */ + #include "interfaceMakerPythonObj.h" #include "interrogateBuilder.h" #include "interrogate.h" @@ -26,33 +25,26 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonObj:: InterfaceMakerPythonObj(InterrogateModuleDef *def) : InterfaceMakerPython(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonObj:: ~InterfaceMakerPythonObj() { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_prototypes -// Access: Public, Virtual -// Description: Generates the list of function prototypes -// corresponding to the functions that will be output in -// write_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of function prototypes corresponding to the functions + * that will be output in write_functions(). + */ void InterfaceMakerPythonObj:: write_prototypes(ostream &out, ostream *out_h) { FunctionsByIndex::iterator fi; @@ -65,13 +57,10 @@ write_prototypes(ostream &out, ostream *out_h) { InterfaceMakerPython::write_prototypes(out,out_h); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_functions -// Access: Public, Virtual -// Description: Generates the list of functions that are appropriate -// for this interface. This function is called *before* -// write_prototypes(), above. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of functions that are appropriate for this interface. + * This function is called *before* write_prototypes(), above. + */ void InterfaceMakerPythonObj:: write_functions(ostream &out) { FunctionsByIndex::iterator fi; @@ -91,12 +80,9 @@ write_functions(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_module -// Access: Public, Virtual -// Description: Generates whatever additional code is required to -// support a module file. -//////////////////////////////////////////////////////////////////// +/** + * Generates whatever additional code is required to support a module file. + */ void InterfaceMakerPythonObj:: write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { InterfaceMakerPython::write_module(out,out_h, def); @@ -108,14 +94,14 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { Object *object = (*oi).second; Functions::iterator fi; - for (fi = object->_constructors.begin(); - fi != object->_constructors.end(); + for (fi = object->_constructors.begin(); + fi != object->_constructors.end(); ++fi) { Function *func = (*fi); - out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name + out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name << ", METH_VARARGS },\n"; } - } + } out << " { NULL, NULL }\n" << "};\n\n" @@ -151,48 +137,37 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::synthesize_this_parameter -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require the implicit -// "this" parameter, if present, to be passed as the -// first parameter to any wrapper functions. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require the implicit "this" parameter, if present, to be + * passed as the first parameter to any wrapper functions. + */ bool InterfaceMakerPythonObj:: synthesize_this_parameter() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::get_builder_name -// Access: Public, Static -// Description: Returns the name of the InterfaceMaker function -// generated to define the Python class for the -// indicated struct type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the InterfaceMaker function generated to define the + * Python class for the indicated struct type. + */ string InterfaceMakerPythonObj:: get_builder_name(CPPType *struct_type) { - return "get_python_class_" + + return "get_python_class_" + InterrogateBuilder::clean_identifier(struct_type->get_local_name(&parser)); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::get_wrapper_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate wrapper -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate wrapper function names. + */ string InterfaceMakerPythonObj:: get_wrapper_prefix() { return "wpo_"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_class_wrapper -// Access: Private -// Description: Writes a function that will define the Python class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a function that will define the Python class. + */ void InterfaceMakerPythonObj:: write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { CPPType *struct_type = object->_itype._cpptype; @@ -220,7 +195,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { for (fi = object->_methods.begin(); fi != object->_methods.end(); ++fi) { Function *func = (*fi); if (func->_has_this) { - out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name + out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name << ", METH_VARARGS },\n"; methods_size++; } @@ -233,7 +208,7 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { for (fi = object->_methods.begin(); fi != object->_methods.end(); ++fi) { Function *func = (*fi); if (!func->_has_this) { - out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name + out << " { \"" << func->_ifunc.get_name() << "\", &" << func->_name << ", METH_VARARGS },\n"; class_methods_size++; } @@ -267,23 +242,19 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) { << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_prototype_for -// Access: Private -// Description: Writes the prototype for the indicated function. -//////////////////////////////////////////////////////////////////// +/** + * Writes the prototype for the indicated function. + */ void InterfaceMakerPythonObj:: write_prototype_for(ostream &out, InterfaceMaker::Function *func) { out << "static PyObject *" << func->_name << "(PyObject *self, PyObject *args);\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_function_for -// Access: Private -// Description: Writes the definition for a function that will call -// the indicated C++ function or method. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a function that will call the indicated C++ + * function or method. + */ void InterfaceMakerPythonObj:: write_function_for(ostream &out, InterfaceMaker::Function *func) { Function::Remaps::const_iterator ri; @@ -309,12 +280,11 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { write_function_instance(out, 2, func, remap, expected_params); } - // If we get here in the generated code, none of the parameters were - // valid. Generate an error exception. (We don't rely on the error - // already generated by ParseTuple(), because it only reports the - // error for one flavor of the function, whereas we might accept - // multiple flavors for the different overloaded C++ function - // signatures. + // If we get here in the generated code, none of the parameters were valid. + // Generate an error exception. (We don't rely on the error already + // generated by ParseTuple(), because it only reports the error for one + // flavor of the function, whereas we might accept multiple flavors for the + // different overloaded C++ function signatures. out << " PyErr_SetString(PyExc_TypeError, \"" << expected_params << "\");\n" << " return (PyObject *)NULL;\n"; @@ -322,12 +292,10 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::write_function_instance -// Access: Private -// Description: Writes out the part of a function that handles a -// single instance of an overloaded function. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the part of a function that handles a single instance of an + * overloaded function. + */ void InterfaceMakerPythonObj:: write_function_instance(ostream &out, int indent_level, InterfaceMaker::Function *func, @@ -336,7 +304,7 @@ write_function_instance(ostream &out, int indent_level, indent(out, indent_level + 2) << "/* "; remap->write_orig_prototype(out, 0); out << " */\n\n"; - + string format_specifiers; string parameter_list; vector_string pexprs; @@ -344,10 +312,10 @@ write_function_instance(ostream &out, int indent_level, string extra_param_check; string extra_cleanup; - // Make one pass through the parameter list. We will output a - // one-line temporary variable definition for each parameter, while - // simultaneously building the ParseTuple() function call and also - // the parameter expression list for call_function(). + // Make one pass through the parameter list. We will output a one-line + // temporary variable definition for each parameter, while simultaneously + // building the ParseTuple() function call and also the parameter expression + // list for call_function(). expected_params += remap->_cppfunc->get_simple_name(); expected_params += "("; @@ -363,8 +331,8 @@ write_function_instance(ostream &out, int indent_level, CPPType *type = remap->_parameters[pn]._remap->get_new_type(); string param_name = remap->get_parameter_name(pn); - // This is the string to convert our local variable to the - // appropriate C++ type. Normally this is just a cast. + // This is the string to convert our local variable to the appropriate C++ + // type. Normally this is just a cast. string pexpr_string = "(" + type->get_local_name(&parser) + ")" + param_name; @@ -494,11 +462,11 @@ write_function_instance(ostream &out, int indent_level, << "in_interpreter = 0;\n"; } - if (!remap->_void_return && + if (!remap->_void_return && remap->_return_type->new_type_is_atomic_string()) { - // Treat strings as a special case. We don't want to format the - // return expression. - string return_expr = + // Treat strings as a special case. We don't want to format the return + // expression. + string return_expr = remap->call_function(out, indent_level + 4, false, "param0", pexprs); CPPType *type = remap->_return_type->get_orig_type(); @@ -520,7 +488,7 @@ write_function_instance(ostream &out, int indent_level, pack_return_value(out, indent_level + 4, remap, return_expr); } else { - string return_expr = + string return_expr = remap->call_function(out, indent_level + 4, true, "param0", pexprs); if (return_expr.empty()) { if (track_interpreter) { @@ -562,12 +530,10 @@ write_function_instance(ostream &out, int indent_level, << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::pack_return_value -// Access: Private -// Description: Outputs a command to pack the indicated expression, -// of the return_type type, as a Python return value. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a command to pack the indicated expression, of the return_type + * type, as a Python return value. + */ void InterfaceMakerPythonObj:: pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, string return_expr) { @@ -639,7 +605,7 @@ pack_return_value(ostream &out, int indent_level, FunctionWriterPtrToPython *writer = get_ptr_to_python(type); indent(out, indent_level) - << "return " << writer->get_name() << "((" + << "return " << writer->get_name() << "((" << writer->get_pointer_type()->get_local_name(&parser) << ")" << return_expr << ", " << caller_manages << ");\n"; @@ -650,13 +616,10 @@ pack_return_value(ostream &out, int indent_level, } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::get_ptr_from_python -// Access: Private -// Description: Returns a FunctionWriter pointer suitable for -// converting from a Python wrapper of the indicated -// type to the corresponding C++ pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FunctionWriter pointer suitable for converting from a Python + * wrapper of the indicated type to the corresponding C++ pointer. + */ FunctionWriterPtrFromPython *InterfaceMakerPythonObj:: get_ptr_from_python(CPPType *type) { PtrConverter::iterator ci; @@ -666,19 +629,16 @@ get_ptr_from_python(CPPType *type) { return (FunctionWriterPtrFromPython *)(*ci).second; } - FunctionWriter *writer = + FunctionWriter *writer = _function_writers.add_writer(new FunctionWriterPtrFromPython(type)); _from_python.insert(PtrConverter::value_type(type, writer)); return (FunctionWriterPtrFromPython *)writer; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonObj::get_ptr_to_python -// Access: Private -// Description: Returns a FunctionWriter pointer suitable for -// converting from a C++ pointer of the indicated -// type to the corresponding Python wrapper. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FunctionWriter pointer suitable for converting from a C++ pointer + * of the indicated type to the corresponding Python wrapper. + */ FunctionWriterPtrToPython *InterfaceMakerPythonObj:: get_ptr_to_python(CPPType *type) { PtrConverter::iterator ci; @@ -688,7 +648,7 @@ get_ptr_to_python(CPPType *type) { return (FunctionWriterPtrToPython *)(*ci).second; } - FunctionWriter *writer = + FunctionWriter *writer = _function_writers.add_writer(new FunctionWriterPtrToPython(type)); _to_python.insert(PtrConverter::value_type(type, writer)); return (FunctionWriterPtrToPython *)writer; diff --git a/dtool/src/interrogate/interfaceMakerPythonObj.h b/dtool/src/interrogate/interfaceMakerPythonObj.h index f49c698c95..df2263f8d7 100644 --- a/dtool/src/interrogate/interfaceMakerPythonObj.h +++ b/dtool/src/interrogate/interfaceMakerPythonObj.h @@ -1,16 +1,15 @@ -// Filename: interfaceMakerPythonObj.h -// Created by: drose (19Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonObj.h + * @author drose + * @date 2001-09-19 + */ #ifndef INTERFACEMAKERPYTHONOBJ_H #define INTERFACEMAKERPYTHONOBJ_H @@ -29,12 +28,10 @@ class CPPInstance; class FunctionWriterPtrFromPython; class FunctionWriterPtrToPython; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMakerPythonObj -// Description : An InterfaceMaker suitable for generating -// object-oriented Python code, that can be imported and -// used directly by Python. -//////////////////////////////////////////////////////////////////// +/** + * An InterfaceMaker suitable for generating object-oriented Python code, that + * can be imported and used directly by Python. + */ class InterfaceMakerPythonObj : public InterfaceMakerPython { public: InterfaceMakerPythonObj(InterrogateModuleDef *def); diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx index 17391e2226..b7b5925a8c 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.cxx @@ -1,16 +1,15 @@ -// Filename: interfaceMakerPythonSimple.cxx -// Created by: drose (01Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonSimple.cxx + * @author drose + * @date 2001-10-01 + */ #include "interfaceMakerPythonSimple.h" #include "interrogateBuilder.h" @@ -24,33 +23,26 @@ #include "interrogateFunction.h" #include "cppFunctionType.h" -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonSimple:: InterfaceMakerPythonSimple(InterrogateModuleDef *def) : InterfaceMakerPython(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterfaceMakerPythonSimple:: ~InterfaceMakerPythonSimple() { } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_prototypes -// Access: Public, Virtual -// Description: Generates the list of function prototypes -// corresponding to the functions that will be output in -// write_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of function prototypes corresponding to the functions + * that will be output in write_functions(). + */ void InterfaceMakerPythonSimple:: write_prototypes(ostream &out,ostream *out_h) { FunctionsByIndex::iterator fi; @@ -63,13 +55,10 @@ write_prototypes(ostream &out,ostream *out_h) { InterfaceMakerPython::write_prototypes(out,out_h); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_functions -// Access: Public, Virtual -// Description: Generates the list of functions that are appropriate -// for this interface. This function is called *before* -// write_prototypes(), above. -//////////////////////////////////////////////////////////////////// +/** + * Generates the list of functions that are appropriate for this interface. + * This function is called *before* write_prototypes(), above. + */ void InterfaceMakerPythonSimple:: write_functions(ostream &out) { FunctionsByIndex::iterator fi; @@ -81,12 +70,9 @@ write_functions(ostream &out) { InterfaceMakerPython::write_functions(out); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_module -// Access: Public, Virtual -// Description: Generates whatever additional code is required to -// support a module file. -//////////////////////////////////////////////////////////////////// +/** + * Generates whatever additional code is required to support a module file. + */ void InterfaceMakerPythonSimple:: write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { InterfaceMakerPython::write_module(out,out_h, def); @@ -138,59 +124,46 @@ write_module(ostream &out,ostream *out_h, InterrogateModuleDef *def) { << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::synthesize_this_parameter -// Access: Public, Virtual -// Description: This method should be overridden and redefined to -// return true for interfaces that require the implicit -// "this" parameter, if present, to be passed as the -// first parameter to any wrapper functions. -//////////////////////////////////////////////////////////////////// +/** + * This method should be overridden and redefined to return true for + * interfaces that require the implicit "this" parameter, if present, to be + * passed as the first parameter to any wrapper functions. + */ bool InterfaceMakerPythonSimple:: synthesize_this_parameter() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::get_wrapper_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate wrapper -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate wrapper function names. + */ string InterfaceMakerPythonSimple:: get_wrapper_prefix() { return "_inP"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::get_unique_prefix -// Access: Protected, Virtual -// Description: Returns the prefix string used to generate unique -// symbolic names, which are not necessarily C-callable -// function names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix string used to generate unique symbolic names, which are + * not necessarily C-callable function names. + */ string InterfaceMakerPythonSimple:: get_unique_prefix() { return "p"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::record_function_wrapper -// Access: Protected, Virtual -// Description: Associates the function wrapper with its function in -// the appropriate structures in the database. -//////////////////////////////////////////////////////////////////// +/** + * Associates the function wrapper with its function in the appropriate + * structures in the database. + */ void InterfaceMakerPythonSimple:: -record_function_wrapper(InterrogateFunction &ifunc, +record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index) { ifunc._python_wrappers.push_back(wrapper_index); } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_prototype_for -// Access: Private -// Description: Writes the prototype for the indicated function. -//////////////////////////////////////////////////////////////////// +/** + * Writes the prototype for the indicated function. + */ void InterfaceMakerPythonSimple:: write_prototype_for(ostream &out, InterfaceMaker::Function *func) { Function::Remaps::const_iterator ri; @@ -198,8 +171,8 @@ write_prototype_for(ostream &out, InterfaceMaker::Function *func) { for (ri = func->_remaps.begin(); ri != func->_remaps.end(); ++ri) { FunctionRemap *remap = (*ri); if (!output_function_names) { - // If we're not saving the function names, don't export it from - // the library. + // If we're not saving the function names, don't export it from the + // library. out << "static "; } else { out << "extern \"C\" "; @@ -209,12 +182,10 @@ write_prototype_for(ostream &out, InterfaceMaker::Function *func) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_function_for -// Access: Private -// Description: Writes the definition for a function that will call -// the indicated C++ function or method. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition for a function that will call the indicated C++ + * function or method. + */ void InterfaceMakerPythonSimple:: write_function_for(ostream &out, InterfaceMaker::Function *func) { Function::Remaps::const_iterator ri; @@ -225,12 +196,10 @@ write_function_for(ostream &out, InterfaceMaker::Function *func) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::write_function_instance -// Access: Private -// Description: Writes out the particular function that handles a -// single instance of an overloaded function. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the particular function that handles a single instance of an + * overloaded function. + */ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, InterfaceMaker::Function *func, FunctionRemap *remap) { out << "/*\n" @@ -241,8 +210,8 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface << " */\n"; if (!output_function_names) { - // If we're not saving the function names, don't export it from - // the library. + // If we're not saving the function names, don't export it from the + // library. out << "static "; } @@ -261,10 +230,10 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface string extra_param_check; string extra_cleanup; - // Make one pass through the parameter list. We will output a - // one-line temporary variable definition for each parameter, while - // simultaneously building the ParseTuple() function call and also - // the parameter expression list for call_function(). + // Make one pass through the parameter list. We will output a one-line + // temporary variable definition for each parameter, while simultaneously + // building the ParseTuple() function call and also the parameter expression + // list for call_function(). int pn; for (pn = 0; pn < (int)remap->_parameters.size(); ++pn) { @@ -273,8 +242,8 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface CPPType *type = remap->_parameters[pn]._remap->get_new_type(); string param_name = remap->get_parameter_name(pn); - // This is the string to convert our local variable to the - // appropriate C++ type. Normally this is just a cast. + // This is the string to convert our local variable to the appropriate C++ + // type. Normally this is just a cast. string pexpr_string = "(" + type->get_local_name(&parser) + ")" + param_name; @@ -395,32 +364,32 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface << " return (PyObject *)NULL;\n" << " }\n"; } - + if (track_interpreter) { out << " in_interpreter = 0;\n"; } - if (!remap->_void_return && + if (!remap->_void_return && remap->_return_type->new_type_is_atomic_string()) { - // Treat strings as a special case. We don't want to format the - // return expression. + // Treat strings as a special case. We don't want to format the return + // expression. string return_expr = remap->call_function(out, 4, false, container, pexprs); CPPType *type = remap->_return_type->get_orig_type(); out << " "; type->output_instance(out, "return_value", &parser); out << " = " << return_expr << ";\n"; - + if (track_interpreter) { out << " in_interpreter = 1;\n"; } if (!extra_cleanup.empty()) { out << " " << extra_cleanup << "\n"; } - + return_expr = manage_return_value(out, 4, remap, "return_value"); test_assert(out, 4); pack_return_value(out, 4, remap, return_expr); - + } else { string return_expr = remap->call_function(out, 4, true, container, pexprs); if (return_expr.empty()) { @@ -432,7 +401,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface } test_assert(out, 4); out << " return Py_BuildValue(\"\");\n"; - + } else { CPPType *type = remap->_return_type->get_temporary_type(); out << " "; @@ -444,32 +413,30 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface if (!extra_cleanup.empty()) { out << " " << extra_cleanup << "\n"; } - + return_expr = manage_return_value(out, 4, remap, "return_value"); test_assert(out, 4); pack_return_value(out, 4, remap, remap->_return_type->temporary_to_return(return_expr)); } } - + out << " }\n"; - + out << " return (PyObject *)NULL;\n"; out << "}\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: InterfaceMakerPythonSimple::pack_return_value -// Access: Private -// Description: Outputs a command to pack the indicated expression, -// of the return_type type, as a Python return value. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a command to pack the indicated expression, of the return_type + * type, as a Python return value. + */ void InterfaceMakerPythonSimple:: pack_return_value(ostream &out, int indent_level, FunctionRemap *remap, string return_expr) { CPPType *orig_type = remap->_return_type->get_orig_type(); CPPType *type = remap->_return_type->get_new_type(); - if (remap->_return_type->new_type_is_atomic_string()) + if (remap->_return_type->new_type_is_atomic_string()) { if (TypeManager::is_char_pointer(orig_type)) { out << "#if PY_MAJOR_VERSION >= 3\n"; @@ -501,12 +468,12 @@ pack_return_value(ostream &out, int indent_level, indent(out, indent_level) << "return PyBool_FromLong(" << return_expr << ");\n"; - } else if (TypeManager::is_unsigned_longlong(type)) + } else if (TypeManager::is_unsigned_longlong(type)) { indent(out, indent_level) << "return PyLong_FromUnsignedLongLong(" << return_expr << ");\n"; - } else if (TypeManager::is_longlong(type)) + } else if (TypeManager::is_longlong(type)) { indent(out, indent_level) << "return PyLong_FromLongLong(" << return_expr << ");\n"; @@ -540,7 +507,7 @@ pack_return_value(ostream &out, int indent_level, } else if (TypeManager::is_pointer_to_PyObject(type)) { indent(out, indent_level) << "return " << return_expr << ";\n"; - + } else if (TypeManager::is_pointer(type)) { indent(out, indent_level) << "return PyLong_FromVoidPtr((void*)" << return_expr << ");\n"; diff --git a/dtool/src/interrogate/interfaceMakerPythonSimple.h b/dtool/src/interrogate/interfaceMakerPythonSimple.h index e97f6b20da..0b17df3688 100644 --- a/dtool/src/interrogate/interfaceMakerPythonSimple.h +++ b/dtool/src/interrogate/interfaceMakerPythonSimple.h @@ -1,16 +1,15 @@ -// Filename: interfaceMakerPythonSimple.h -// Created by: drose (01Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interfaceMakerPythonSimple.h + * @author drose + * @date 2001-10-01 + */ #ifndef INTERFACEMAKERPYTHONSIMPLE_H #define INTERFACEMAKERPYTHONSIMPLE_H @@ -22,18 +21,15 @@ class FunctionRemap; -//////////////////////////////////////////////////////////////////// -// Class : InterfaceMakerPythonSimple -// Description : An InterfaceMaker for generating simple Python -// function wrappers around C++ code. This allows the -// C++ code to be called by Python, but not necessarily -// in a user-friendly or object-oriented way. -// -// You probably want to use InterfaceMakerPythonObj for -// a full object-oriented solution. This InterfaceMaker -// is primarily useful as a stopgap for our old -// Python-based FFI system. -//////////////////////////////////////////////////////////////////// +/** + * An InterfaceMaker for generating simple Python function wrappers around C++ + * code. This allows the C++ code to be called by Python, but not necessarily + * in a user-friendly or object-oriented way. + * + * You probably want to use InterfaceMakerPythonObj for a full object-oriented + * solution. This InterfaceMaker is primarily useful as a stopgap for our old + * Python-based FFI system. + */ class InterfaceMakerPythonSimple : public InterfaceMakerPython { public: InterfaceMakerPythonSimple(InterrogateModuleDef *def); @@ -51,7 +47,7 @@ protected: virtual string get_unique_prefix(); virtual void - record_function_wrapper(InterrogateFunction &ifunc, + record_function_wrapper(InterrogateFunction &ifunc, FunctionWrapperIndex wrapper_index); private: diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index aead6ba481..86d2ae9a6e 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -1,16 +1,15 @@ -// Filename: interrogate.cxx -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate.cxx + * @author drose + * @date 2000-07-31 + */ #include "interrogate.h" #include "interrogateBuilder.h" @@ -479,15 +478,13 @@ main(int argc, char **argv) { } } -// if(!output_code_filename.empty()) -// { -// output_include_filename = output_code_filename.get_fullpath_wo_extension() +".h"; -// printf(" Include File Will be Set to %s \n",output_include_filename.c_str()); -// } +// if(!output_code_filename.empty()) { output_include_filename = +// output_code_filename.get_fullpath_wo_extension() +".h"; printf(" Include +// File Will be Set to %s \n",output_include_filename.c_str()); } output_code_filename.set_text(); output_data_filename.set_text(); -// output_include_filename.set_text(); +// output_include_filename.set_text(); output_data_basename = output_data_filename.get_basename(); if (output_function_names && true_wrapper_names) { @@ -498,7 +495,7 @@ main(int argc, char **argv) { exit(1); } - if (!build_c_wrappers && !build_python_wrappers && + if (!build_c_wrappers && !build_python_wrappers && !build_python_obj_wrappers &&!build_python_native) { build_c_wrappers = true; } @@ -520,14 +517,13 @@ main(int argc, char **argv) { builder.add_source_file(filename); } - // Now that we've parsed all the source code, change the way things - // are output from now on so we can compile our generated code using - // VC++. Sheesh. + // Now that we've parsed all the source code, change the way things are + // output from now on so we can compile our generated code using VC++. + // Sheesh. - // Actually, don't do this any more, since it bitches some of the - // logic (particularly with locating alt names), and it shouldn't be - // necessary with modern VC++. - // cppparser_output_class_keyword = false; + // Actually, don't do this any more, since it bitches some of the logic + // (particularly with locating alt names), and it shouldn't be necessary + // with modern VC++. cppparser_output_class_keyword = false; // Now look for the .N files. for (i = 1; i < argc; ++i) { @@ -543,17 +539,17 @@ main(int argc, char **argv) { builder.build(); - // Make up a file identifier. This is just some bogus number that - // should be the same in both the compiled-in code and in the - // database, so we can check synchronicity at load time. + // Make up a file identifier. This is just some bogus number that should be + // the same in both the compiled-in code and in the database, so we can + // check synchronicity at load time. int file_identifier = time((time_t *)NULL); InterrogateModuleDef *def = builder.make_module_def(file_identifier); - + pofstream * the_output_include = NULL; pofstream output_include; - - if (1==2 && !output_include_filename.empty()) + + if (1==2 && !output_include_filename.empty()) { output_include_filename.open_write(output_include); @@ -568,11 +564,11 @@ main(int argc, char **argv) { << " */\n\n"; - if (output_include.fail()) + if (output_include.fail()) { nout << "Unable to write to " << output_include_filename << "\n"; exit(-1); - } + } the_output_include = &output_include; } @@ -611,7 +607,7 @@ main(int argc, char **argv) { pofstream output_data; output_data_filename.open_write(output_data); - if (output_data.fail()) + if (output_data.fail()) { nout << "Unable to write to " << output_data_filename << "\n"; } else { diff --git a/dtool/src/interrogate/interrogate.h b/dtool/src/interrogate/interrogate.h index a7d6ed275d..80b55c4e8f 100644 --- a/dtool/src/interrogate/interrogate.h +++ b/dtool/src/interrogate/interrogate.h @@ -1,16 +1,15 @@ -// Filename: interrogate.h -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate.h + * @author drose + * @date 2000-07-31 + */ #ifndef INTERROGATE_H #define INTERROGATE_H diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index f70f4ff90a..0521852fdc 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -1,16 +1,15 @@ -// Filename: interrogateBuilder.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateBuilder.cxx + * @author drose + * @date 2000-08-01 + */ #include "interrogateBuilder.h" #include "interrogate.h" @@ -54,14 +53,11 @@ InterrogateBuilder builder; std::string EXPORT_IMPORT_PREFIX; -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::add_source_file -// Access: Public -// Description: Adds the given source filename to the list of files -// that we are scanning. Those source files that appear -// to be header files will be #included in the generated -// code file. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given source filename to the list of files that we are scanning. + * Those source files that appear to be header files will be #included in the + * generated code file. + */ void InterrogateBuilder:: add_source_file(const string &filename) { if (filename.empty()) { @@ -71,12 +67,10 @@ add_source_file(const string &filename) { _include_files[filename] = '"'; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::read_command_file -// Access: Public -// Description: Reads a .N file that might contain control -// information for the interrogate process. -//////////////////////////////////////////////////////////////////// +/** + * Reads a .N file that might contain control information for the interrogate + * process. + */ void InterrogateBuilder:: read_command_file(istream &in) { string line; @@ -120,11 +114,9 @@ read_command_file(istream &in) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::do_command -// Access: Public -// Description: Executes a single command as read from the .N file. -//////////////////////////////////////////////////////////////////// +/** + * Executes a single command as read from the .N file. + */ void InterrogateBuilder:: do_command(const string &command, const string ¶ms) { @@ -149,9 +141,9 @@ do_command(const string &command, const string ¶ms) { } } else if (command == "renametype") { - // rename exports the type as the indicated name. We strip off - // the last word as the new name; the new name may not contain - // spaces (although the original type name may). + // rename exports the type as the indicated name. We strip off the last + // word as the new name; the new name may not contain spaces (although the + // original type name may). size_t space = params.rfind(' '); if (space == string::npos) { @@ -180,10 +172,10 @@ do_command(const string &command, const string ¶ms) { } } else if (command == "defconstruct") { - // defining the parameters that are implicitly supplied to the - // generated default constructor. Especially useful for linmath - // objects, whose default constructor in C++ is uninitialized, but - // whose Python-level constructor should initialize to 0. + // defining the parameters that are implicitly supplied to the generated + // default constructor. Especially useful for linmath objects, whose + // default constructor in C++ is uninitialized, but whose Python-level + // constructor should initialize to 0. size_t space = params.find(' '); if (space == string::npos) { @@ -234,11 +226,9 @@ do_command(const string &command, const string ¶ms) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::build -// Access: Public -// Description: Builds all of the interrogate data. -//////////////////////////////////////////////////////////////////// +/** + * Builds all of the interrogate data. + */ void InterrogateBuilder:: build() { _library_hash_name = hash_string(library_name, 5); @@ -291,8 +281,8 @@ build() { CPPTypedefType *tdef = (*di)->as_typedef_type(); if (tdef->_type->get_subtype() == CPPDeclaration::ST_struct) { - // A typedef counts as a declaration. This lets us pick up - // most template instantiations. + // A typedef counts as a declaration. This lets us pick up most + // template instantiations. CPPStructType *struct_type = tdef->_type->resolve_type(&parser, &parser)->as_struct_type(); scan_struct_type(struct_type); @@ -324,17 +314,13 @@ build() { scan_manifest(manifest); } - // Now that we've gone through all the code and generated all the - // functions and types, build the function wrappers. - // make_wrappers(); + // Now that we've gone through all the code and generated all the functions + // and types, build the function wrappers. make_wrappers(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::write_code -// Access: Public -// Description: Generates all the code necessary to the indicated -// output stream. -//////////////////////////////////////////////////////////////////// +/** + * Generates all the code necessary to the indicated output stream. + */ void InterrogateBuilder:: write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { typedef vector InterfaceMakers; @@ -372,9 +358,8 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } // Now generate all the function bodies to a temporary buffer. By - // generating these first, we ensure that we know all of the - // pointers we'll be using ahead of time (and can therefore generate - // correct prototypes). + // generating these first, we ensure that we know all of the pointers we'll + // be using ahead of time (and can therefore generate correct prototypes). ostringstream function_bodies; for (mi = makers.begin(); mi != makers.end(); ++mi) { (*mi)->write_functions(function_bodies); @@ -440,9 +425,7 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } declaration_bodies << "\n"; -// if(out_include != NULL) -// (*out_include) << declaration_bodies.str(); -// else +// if(out_include != NULL) (*out_include) << declaration_bodies.str(); else out_code << declaration_bodies.str(); // Followed by the function bodies. @@ -466,8 +449,8 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } // Make sure all of the function wrappers appear first in the set of - // indices, and that they occupy consecutive index numbers, so we - // can build a simple array of function pointers by index. + // indices, and that they occupy consecutive index numbers, so we can build + // a simple array of function pointers by index. remap_indices(remaps); // Get the function wrappers in index-number order. @@ -521,8 +504,8 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } if (!no_database) { - // Now build the module definition structure to add ourselves to - // the global interrogate database. + // Now build the module definition structure to add ourselves to the + // global interrogate database. out_code << "static InterrogateModuleDef _in_module_def = {\n" << " " << def->file_identifier << ", /* file_identifier */\n" << " \"" << def->library_name << "\", /* library_name */\n" @@ -556,8 +539,8 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { << " /* next_index */\n" << "};\n\n"; - // And now write the static-init code that tells the interrogate - // database to load up this module. + // And now write the static-init code that tells the interrogate database + // to load up this module. out_code << "Configure(_in_configure_" << library_name << ");\n" << "ConfigureFn(_in_configure_" << library_name << ") {\n" << " interrogate_request_module(&_in_module_def);\n" @@ -565,19 +548,15 @@ write_code(ostream &out_code,ostream * out_include, InterrogateModuleDef *def) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::make_module_def -// Access: Public -// Description: Allocates and returns a new InterrogateModuleDef -// structure that reflects the data we have just build, -// or at least that subset of the InterrogateModuleDef -// data that we have available at this time. -// -// The data in this structure may include pointers that -// reference directly into the InterrogateBuilder -// object; thus, this structure is only valid for as -// long as the builder itself remains in scope. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new InterrogateModuleDef structure that reflects + * the data we have just build, or at least that subset of the + * InterrogateModuleDef data that we have available at this time. + * + * The data in this structure may include pointers that reference directly + * into the InterrogateBuilder object; thus, this structure is only valid for + * as long as the builder itself remains in scope. + */ InterrogateModuleDef *InterrogateBuilder:: make_module_def(int file_identifier) { InterrogateModuleDef *def = new InterrogateModuleDef; @@ -594,16 +573,12 @@ make_module_def(int file_identifier) { return def; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::clean_identifier -// Access: Public, Static -// Description: Adjusts the given string to remove any characters we -// don't want to export as part of an identifier name. -// Returns the cleaned string. -// -// This replaces any consecutive invalid characters with -// an underscore. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the given string to remove any characters we don't want to export + * as part of an identifier name. Returns the cleaned string. + * + * This replaces any consecutive invalid characters with an underscore. + */ string InterrogateBuilder:: clean_identifier(const string &name) { string result; @@ -626,13 +601,10 @@ clean_identifier(const string &name) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::descope -// Access: Public, Static -// Description: Removes the leading "::", if present, from a -// fully-scoped name. Sometimes CPPParser throws this -// on, and sometimes it doesn't. -//////////////////////////////////////////////////////////////////// +/** + * Removes the leading "::", if present, from a fully-scoped name. Sometimes + * CPPParser throws this on, and sometimes it doesn't. + */ string InterrogateBuilder:: descope(const string &name) { if (name.length() >= 2 && name.substr(0, 2) == "::") { @@ -641,13 +613,10 @@ descope(const string &name) { return name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_destructor_for -// Access: Public -// Description: Returns the FunctionIndex for the destructor -// appropriate to destruct an instance of the indicated -// type, or 0 if no suitable destructor exists. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FunctionIndex for the destructor appropriate to destruct an + * instance of the indicated type, or 0 if no suitable destructor exists. + */ FunctionIndex InterrogateBuilder:: get_destructor_for(CPPType *type) { TypeIndex type_index = get_type(type, false); @@ -658,16 +627,12 @@ get_destructor_for(CPPType *type) { return itype.get_destructor(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_preferred_name -// Access: Public -// Description: Returns the name of the type as it should be reported -// to the database. This is either the name indicated -// by the user via a renametype command, or the -// "preferred name" of the type itself (i.e. the typedef -// name within the C++ code), or failing that, the -// type's true name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the type as it should be reported to the database. + * This is either the name indicated by the user via a renametype command, or + * the "preferred name" of the type itself (i.e. the typedef name within the + * C++ code), or failing that, the type's true name. + */ string InterrogateBuilder:: get_preferred_name(CPPType *type) { string true_name = type->get_local_name(&parser); @@ -678,13 +643,10 @@ get_preferred_name(CPPType *type) { return type->get_preferred_name(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::hash_string -// Access: Public, Static -// Description: Hashes an arbitrary string into a four-character -// string using only the characters legal in a C -// identifier. -//////////////////////////////////////////////////////////////////// +/** + * Hashes an arbitrary string into a four-character string using only the + * characters legal in a C identifier. + */ string InterrogateBuilder:: hash_string(const string &name, int shift_offset) { int hash = 0; @@ -702,24 +664,23 @@ hash_string(const string &name, int shift_offset) { shift = (shift + shift_offset) % 24; } - // Now multiply the hash by a biggish prime number and apply the - // high-order bits back at the bottom, to scramble up the bits a - // bit. This helps reduce hash conflicts from names that are - // similar to each other, by separating adjacent hash codes. + // Now multiply the hash by a biggish prime number and apply the high-order + // bits back at the bottom, to scramble up the bits a bit. This helps + // reduce hash conflicts from names that are similar to each other, by + // separating adjacent hash codes. int prime = 4999; int low_order = (hash * prime) & 0xffffff; int high_order = (int)((double)hash * (double)prime / (double)(1 << 24)); hash = low_order ^ high_order; - // Also add in the additional_number, times some prime factor. - // hash = (hash + additional_number * 1657) & 0xffffff; + // Also add in the additional_number, times some prime factor. hash = (hash + // + additional_number * 1657) & 0xffffff; - // Now turn the hash code into a four-character string. For each - // six bits, we choose a character in the set [A-Za-z0-9_]. Note - // that there are only 63 characters to choose from; we have to - // duplicate '_' for values 62 and 63. This introduces a small - // additional chance of hash conflicts. No big deal, since we have - // to resolve hash conflicts anyway. + // Now turn the hash code into a four-character string. For each six bits, + // we choose a character in the set [A-Za-z0-9_]. Note that there are only + // 63 characters to choose from; we have to duplicate '_' for values 62 and + // 63. This introduces a small additional chance of hash conflicts. No big + // deal, since we have to resolve hash conflicts anyway. string result; int extract_h = hash; @@ -743,12 +704,10 @@ hash_string(const string &name, int shift_offset) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::insert_param_list -// Access: Public -// Description: Inserts a list of space-separated parameters into the -// given command parameter list. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a list of space-separated parameters into the given command + * parameter list. + */ void InterrogateBuilder:: insert_param_list(InterrogateBuilder::Commands &commands, const string ¶ms) { @@ -768,24 +727,19 @@ insert_param_list(InterrogateBuilder::Commands &commands, } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_forcetype -// Access: Private -// Description: Returns true if the indicated name is one that the -// user identified with a forcetype command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is one that the user identified with a + * forcetype command. + */ bool InterrogateBuilder:: in_forcetype(const string &name) const { return (_forcetype.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_renametype -// Access: Private -// Description: If the user requested an explicit name for this type -// via the renametype command, returns that name; -// otherwise, returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * If the user requested an explicit name for this type via the renametype + * command, returns that name; otherwise, returns the empty string. + */ string InterrogateBuilder:: in_renametype(const string &name) const { CommandParams::const_iterator pi; @@ -796,24 +750,20 @@ in_renametype(const string &name) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_ignoretype -// Access: Private -// Description: Returns true if the indicated name is one that the -// user identified with an ignoretype command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is one that the user identified with an + * ignoretype command. + */ bool InterrogateBuilder:: in_ignoretype(const string &name) const { return (_ignoretype.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_defconstruct -// Access: Private -// Description: If the user requested an explicit default constructor -// for this type via the defconstruct command, returns -// that string; otherwise, returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * If the user requested an explicit default constructor for this type via the + * defconstruct command, returns that string; otherwise, returns the empty + * string. + */ string InterrogateBuilder:: in_defconstruct(const string &name) const { CommandParams::const_iterator pi; @@ -824,23 +774,18 @@ in_defconstruct(const string &name) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_ignoreinvolved -// Access: Private -// Description: Returns true if the indicated name is one that the -// user identified with an ignoreinvolved command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is one that the user identified with an + * ignoreinvolved command. + */ bool InterrogateBuilder:: in_ignoreinvolved(const string &name) const { return (_ignoreinvolved.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_ignoreinvolved -// Access: Private -// Description: Returns true if the indicated type involves some type -// name that the user identified with an ignoreinvolved -// command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type involves some type name that the user + * identified with an ignoreinvolved command. + */ bool InterrogateBuilder:: in_ignoreinvolved(CPPType *type) const { switch (type->get_subtype()) { @@ -899,46 +844,37 @@ in_ignoreinvolved(CPPType *type) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_ignorefile -// Access: Private -// Description: Returns true if the indicated name is one that the -// user identified with an ignorefile command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is one that the user identified with an + * ignorefile command. + */ bool InterrogateBuilder:: in_ignorefile(const string &name) const { return (_ignorefile.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_ignoremember -// Access: Private -// Description: Returns true if the indicated name is one that the -// user identified with an ignoremember command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is one that the user identified with an + * ignoremember command. + */ bool InterrogateBuilder:: in_ignoremember(const string &name) const { return (_ignoremember.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::in_noinclude -// Access: Private -// Description: Returns true if the indicated filename is one that -// the user identified with a noinclude command. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated filename is one that the user identified with + * a noinclude command. + */ bool InterrogateBuilder:: in_noinclude(const string &name) const { return (_noinclude.count(name) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::should_include -// Access: Private -// Description: Returns true if the indicated filename is a valid -// file to explicitly #include in the generated .cxx -// file, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated filename is a valid file to explicitly + * #include in the generated .cxx file, false otherwise. + */ bool InterrogateBuilder:: should_include(const string &filename) const { // Don't directly include any .cxx or .I files, except for extensions. @@ -946,15 +882,14 @@ should_include(const string &filename) const { return false; } - // Also, don't include any files specifically forbidden in a .N - // file. + // Also, don't include any files specifically forbidden in a .N file. if (in_noinclude(filename)) { return false; } - // Much as I hate to do it, I'm going to code in a special-case - // for two particularly nasty header files that we probably don't - // want to actually ever include. + // Much as I hate to do it, I'm going to code in a special-case for two + // particularly nasty header files that we probably don't want to actually + // ever include. if (filename == "winbase.h" || filename == "windows.h") { return false; } @@ -977,15 +912,11 @@ should_include(const string &filename) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::is_inherited_published -// Access: Private -// Description: Recursively looks for the first inherited version of -// this function in the derivation chain of this class. -// Returns true if this function is declared published, -// or false if it is not published, or if it can't be -// found. -//////////////////////////////////////////////////////////////////// +/** + * Recursively looks for the first inherited version of this function in the + * derivation chain of this class. Returns true if this function is declared + * published, or false if it is not published, or if it can't be found. + */ bool InterrogateBuilder:: is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { nassertr(struct_type->_derivation.size() == 1, false); @@ -1017,23 +948,17 @@ is_inherited_published(CPPInstance *function, CPPStructType *struct_type) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::remap_indices -// Access: Private -// Description: Resequences all of the index numbers so that -// function wrappers start at 1 and occupy consecutive -// positions, and everything else follows. This allows -// us to build a table of function wrappers by index -// number. -// -// The "remaps" member is a list of FunctionRemap -// pointers. The collision in naming is unfortunate; -// the FunctionRemap objects are so named because they -// remap synthesized function wrappers to actual C++ -// methods and functions. It has nothing to do with the -// remapping of index numbers, which is the purpose of -// this function. -//////////////////////////////////////////////////////////////////// +/** + * Resequences all of the index numbers so that function wrappers start at 1 + * and occupy consecutive positions, and everything else follows. This allows + * us to build a table of function wrappers by index number. + * + * The "remaps" member is a list of FunctionRemap pointers. The collision in + * naming is unfortunate; the FunctionRemap objects are so named because they + * remap synthesized function wrappers to actual C++ methods and functions. + * It has nothing to do with the remapping of index numbers, which is the + * purpose of this function. + */ void InterrogateBuilder:: remap_indices(vector &remaps) { IndexRemapper index_remap; @@ -1058,12 +983,9 @@ remap_indices(vector &remaps) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_function -// Access: Private -// Description: Adds the indicated global function to the database, -// if warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated global function to the database, if warranted. + */ void InterrogateBuilder:: scan_function(CPPFunctionGroup *fgroup) { CPPFunctionGroup::Instances::const_iterator fi; @@ -1073,12 +995,9 @@ scan_function(CPPFunctionGroup *fgroup) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_function -// Access: Private -// Description: Adds the indicated global function to the database, -// if warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated global function to the database, if warranted. + */ void InterrogateBuilder:: scan_function(CPPInstance *function) { assert(function != (CPPInstance *)NULL); @@ -1097,10 +1016,10 @@ scan_function(CPPInstance *function) { } if (scope->get_struct_type() != (CPPStructType *)NULL) { - // Wait, this is a method, not a function. This must be the - // declaration for the method (since it's appearing - // out-of-scope). We don't need to define a new method for it, - // but we'd like to update the comment, if we have a comment. + // Wait, this is a method, not a function. This must be the declaration + // for the method (since it's appearing out-of-scope). We don't need to + // define a new method for it, but we'd like to update the comment, if + // we have a comment. update_function_comment(function, scope); return; } @@ -1112,8 +1031,8 @@ scan_function(CPPInstance *function) { } if (function->_file.is_c_file()) { - // This function declaration appears in a .C file. We can only - // export functions whose prototypes appear in an .h file. + // This function declaration appears in a .C file. We can only export + // functions whose prototypes appear in an .h file. string function_name = TypeManager::get_function_name(function); @@ -1124,8 +1043,7 @@ scan_function(CPPInstance *function) { if (function->_file._source != CPPFile::S_local || in_ignorefile(function->_file._filename_as_referenced)) { - // The function is defined in some other package or in an - // ignorable file. + // The function is defined in some other package or in an ignorable file. return; } @@ -1140,14 +1058,14 @@ scan_function(CPPInstance *function) { } if (TypeManager::involves_protected(ftype)) { - // We can't export the function because it involves parameter - // types that are protected or private. + // We can't export the function because it involves parameter types that + // are protected or private. return; } if (in_ignoreinvolved(ftype)) { - // The function or its parameters involves something that the - // user requested we ignore. + // The function or its parameters involves something that the user + // requested we ignore. return; } @@ -1156,12 +1074,9 @@ scan_function(CPPInstance *function) { InterrogateFunction::F_global); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_struct_type -// Access: Private -// Description: Adds the indicated struct type to the database, if -// warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated struct type to the database, if warranted. + */ void InterrogateBuilder:: scan_struct_type(CPPStructType *type) { if (type == (CPPStructType *)NULL) { @@ -1174,20 +1089,19 @@ scan_struct_type(CPPStructType *type) { } if (type->_file.is_c_file()) { - // This type declaration appears in a .C file. We can only export - // types defined in a .h file. + // This type declaration appears in a .C file. We can only export types + // defined in a .h file. return; } if (type->_file._source != CPPFile::S_local || in_ignorefile(type->_file._filename_as_referenced)) { - // The type is defined in some other package or in an - // ignorable file. + // The type is defined in some other package or in an ignorable file. return; } - // Check if any of the members are exported. If none of them are, - // and the type itself is not marked for export, then never mind. + // Check if any of the members are exported. If none of them are, and the + // type itself is not marked for export, then never mind. if (type->_vis > min_vis) { CPPScope *scope = type->_scope; @@ -1210,12 +1124,9 @@ scan_struct_type(CPPStructType *type) { get_type(type, true); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_enum_type -// Access: Private -// Description: Adds the indicated enum type to the database, if -// warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated enum type to the database, if warranted. + */ void InterrogateBuilder:: scan_enum_type(CPPEnumType *type) { if (type == (CPPEnumType *)NULL) { @@ -1228,15 +1139,14 @@ scan_enum_type(CPPEnumType *type) { } if (type->_file.is_c_file()) { - // This type declaration appears in a .C file. We can only export - // types defined in a .h file. + // This type declaration appears in a .C file. We can only export types + // defined in a .h file. return; } if (type->_file._source != CPPFile::S_local || in_ignorefile(type->_file._filename_as_referenced)) { - // The type is defined in some other package or in an - // ignorable file. + // The type is defined in some other package or in an ignorable file. return; } @@ -1248,12 +1158,9 @@ scan_enum_type(CPPEnumType *type) { get_type(type, true); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_typedef_type -// Access: Private -// Description: Adds the indicated typedef type to the database, if -// warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated typedef type to the database, if warranted. + */ void InterrogateBuilder:: scan_typedef_type(CPPTypedefType *type) { if (type == (CPPTypedefType *)NULL) { @@ -1264,26 +1171,24 @@ scan_typedef_type(CPPTypedefType *type) { assert(!type->is_template()); if (type->_file.is_c_file()) { - // This type declaration appears in a .C file. We can only export - // types defined in a .h file. + // This type declaration appears in a .C file. We can only export types + // defined in a .h file. return; } if (type->_file._source != CPPFile::S_local || in_ignorefile(type->_file._filename_as_referenced)) { - // The type is defined in some other package or in an - // ignorable file. + // The type is defined in some other package or in an ignorable file. return; } - // Do we require explicitly placing BEGIN_PUBLISH/END_PUBLISH - // blocks around typedefs for them to be exported? My thinking is - // that we shoudn't, for now, since we don't require it for structs - // either (we only require it to have published methods). - //if (type->_vis > min_vis) { - // // The wrapped type is not marked to be exported. - // return; - //} +/* + * Do we require explicitly placing BEGIN_PUBLISHEND_PUBLISH blocks around + * typedefs for them to be exported? My thinking is that we shoudn't, for + * now, since we don't require it for structs either (we only require it to + * have published methods). if (type->_vis > min_vis) { The wrapped type is + * not marked to be exported. return; } + */ // Find out what this typedef points to. CPPType *wrapped_type = type->_type; @@ -1304,14 +1209,14 @@ scan_typedef_type(CPPTypedefType *type) { if (!forced) { if (wrapped_type->_file._source != CPPFile::S_local || in_ignorefile(wrapped_type->_file._filename_as_referenced)) { - // The wrapped type is defined in some other package or - // in an ignorable file. + // The wrapped type is defined in some other package or in an ignorable + // file. return; } - // Check if any of the wrapped type's members are published. - // If none of them are, and the wrapped type itself is not - // marked for export, then never mind. + // Check if any of the wrapped type's members are published. If none of + // them are, and the wrapped type itself is not marked for export, then + // never mind. if (struct_type->_vis > min_vis) { CPPScope *scope = struct_type->_scope; @@ -1335,12 +1240,9 @@ scan_typedef_type(CPPTypedefType *type) { get_type(type, true); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_manifest -// Access: Private -// Description: Adds the indicated manifest constant to the database, -// if warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated manifest constant to the database, if warranted. + */ void InterrogateBuilder:: scan_manifest(CPPManifest *manifest) { if (manifest == (CPPManifest *)NULL) { @@ -1348,15 +1250,14 @@ scan_manifest(CPPManifest *manifest) { } if (manifest->_loc.file.is_c_file()) { - // This #define appears in a .C file. We can only export - // manifests defined in a .h file. + // This #define appears in a .C file. We can only export manifests + // defined in a .h file. return; } if (manifest->_loc.file._source != CPPFile::S_local || in_ignorefile(manifest->_loc.file._filename_as_referenced)) { - // The manifest is defined in some other package or in an - // ignorable file. + // The manifest is defined in some other package or in an ignorable file. return; } @@ -1387,8 +1288,7 @@ scan_manifest(CPPManifest *manifest) { imanifest._int_value = result.as_integer(); } else { - // We have a more complex expression. Generate a getter - // function. + // We have a more complex expression. Generate a getter function. FunctionIndex getter = get_getter(type, manifest->_name, (CPPStructType *)NULL, &parser, (CPPInstance *)NULL); @@ -1405,12 +1305,9 @@ scan_manifest(CPPManifest *manifest) { InterrogateDatabase::get_ptr()->add_manifest(index, imanifest); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::scan_element -// Access: Private -// Description: Adds the indicated data element to the database, -// if warranted. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated data element to the database, if warranted. + */ ElementIndex InterrogateBuilder:: scan_element(CPPInstance *element, CPPStructType *struct_type, CPPScope *scope) { @@ -1432,16 +1329,15 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, } if (element->_file.is_c_file()) { - // This element declaration appears in a .C file. We can only - // export elements declared in a .h file. + // This element declaration appears in a .C file. We can only export + // elements declared in a .h file. return 0; } if (struct_type == NULL && (element->_file._source != CPPFile::S_local || in_ignorefile(element->_file._filename_as_referenced))) { - // The element is defined in some other package or in an - // ignorable file. + // The element is defined in some other package or in an ignorable file. return 0; } @@ -1481,8 +1377,8 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, } if (!TypeManager::involves_protected(element_type)) { - // We can only generate a getter and a setter if we can talk about - // the type it is. + // We can only generate a getter and a setter if we can talk about the + // type it is. if (parameter_type->as_struct_type() != (CPPStructType *)NULL) { // Wrap the type in a const reference. @@ -1521,12 +1417,10 @@ scan_element(CPPInstance *element, CPPStructType *struct_type, return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_getter -// Access: Private -// Description: Adds a function to return the value for the indicated -// expression. Returns the new function index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a function to return the value for the indicated expression. Returns + * the new function index. + */ FunctionIndex InterrogateBuilder:: get_getter(CPPType *expr_type, string expression, CPPStructType *struct_type, CPPScope *scope, @@ -1534,15 +1428,15 @@ get_getter(CPPType *expr_type, string expression, // Make up a name for the function. string fname = clean_identifier("get_" + expression); - // Unroll the "const" from the expr_type, since that doesn't matter - // for a return type. + // Unroll the "const" from the expr_type, since that doesn't matter for a + // return type. while (expr_type->as_const_type() != (CPPConstType *)NULL) { expr_type = expr_type->as_const_type()->_wrapped_around; assert(expr_type != (CPPType *)NULL); } - // We can't return an array from a function, but we can decay it - // into a pointer. + // We can't return an array from a function, but we can decay it into a + // pointer. while (expr_type->get_subtype() == CPPDeclaration::ST_array) { expr_type = CPPType::new_type(new CPPPointerType(expr_type->as_array_type()->_element_type)); } @@ -1563,16 +1457,16 @@ get_getter(CPPType *expr_type, string expression, assert(scope != (CPPScope *)NULL); if ((element->_storage_class & CPPInstance::SC_static) != 0) { - // This is a static data member; therefore, the synthesized - // getter is also static. + // This is a static data member; therefore, the synthesized getter is + // also static. function->_storage_class |= CPPInstance::SC_static; // And the expression is fully scoped. expression = element->get_local_name(&parser); } else { - // This is a non-static data member, so it has a const - // synthesized getter method. + // This is a non-static data member, so it has a const synthesized + // getter method. ftype->_flags |= CPPFunctionType::F_const_method; // And the expression is locally scoped. @@ -1581,9 +1475,9 @@ get_getter(CPPType *expr_type, string expression, } } - // Now check to see if there's already a function matching this - // name. If there is, we can't define a getter, and we - // shouldn't mistake this other function for a synthesized getter. + // Now check to see if there's already a function matching this name. If + // there is, we can't define a getter, and we shouldn't mistake this other + // function for a synthesized getter. string function_name = TypeManager::get_function_name(function); if (_functions_by_name.count(function_name) != 0) { return 0; @@ -1610,12 +1504,10 @@ get_getter(CPPType *expr_type, string expression, return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_setter -// Access: Private -// Description: Adds a function to return the value for the indicated -// expression. Returns the new function index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a function to return the value for the indicated expression. Returns + * the new function index. + */ FunctionIndex InterrogateBuilder:: get_setter(CPPType *expr_type, string expression, CPPStructType *struct_type, CPPScope *scope, @@ -1642,24 +1534,23 @@ get_setter(CPPType *expr_type, string expression, assert(scope != (CPPScope *)NULL); if ((element->_storage_class & CPPInstance::SC_static) != 0) { - // This is a static data member; therefore, the synthesized - // setter is also static. + // This is a static data member; therefore, the synthesized setter is + // also static. function->_storage_class |= CPPInstance::SC_static; // And the expression is fully scoped. expression = element->get_local_name(&parser); } else { - // This is a non-static data member. The expression is locally - // scoped. + // This is a non-static data member. The expression is locally scoped. expression = element->get_local_name(scope); setter_flags |= InterrogateFunction::F_method; } } - // Now check to see if there's already a function matching this - // name. If there is, we can't define a setter, and we - // shouldn't mistake this other function for a synthesized setter. + // Now check to see if there's already a function matching this name. If + // there is, we can't define a setter, and we shouldn't mistake this other + // function for a synthesized setter. string function_name = TypeManager::get_function_name(function); if (_functions_by_name.count(function_name) != 0) { return 0; @@ -1686,13 +1577,10 @@ get_setter(CPPType *expr_type, string expression, return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_cast_function -// Access: Private -// Description: Adds a function to cast from a pointer of the -// indicated type to a pointer of the indicated type to -// the database. Returns the new function index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a function to cast from a pointer of the indicated type to a pointer + * of the indicated type to the database. Returns the new function index. + */ FunctionIndex InterrogateBuilder:: get_cast_function(CPPType *to_type, CPPType *from_type, const string &prefix) { @@ -1718,8 +1606,8 @@ get_cast_function(CPPType *to_type, CPPType *from_type, function = new CPPInstance(ftype, fname); } else { - // The from type isn't a struct or a class, so this has to be an - // external function. + // The from type isn't a struct or a class, so this has to be an external + // function. // Make up a name for the function. string fname = @@ -1752,21 +1640,19 @@ get_cast_function(CPPType *to_type, CPPType *from_type, return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_function -// Access: Private -// Description: Adds the indicated function to the database, if it is -// not already present. In either case, returns the -// FunctionIndex of the function within the database. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated function to the database, if it is not already present. + * In either case, returns the FunctionIndex of the function within the + * database. + */ FunctionIndex InterrogateBuilder:: get_function(CPPInstance *function, string description, CPPStructType *struct_type, CPPScope *scope, int flags, const string &expression) { - // Get a unique function signature. Make sure we tell the function - // where its native scope is, so we get a fully-scoped signature. + // Get a unique function signature. Make sure we tell the function where + // its native scope is, so we get a fully-scoped signature. if (function->_ident->_native_scope != scope) { function = new CPPInstance(*function); @@ -1793,9 +1679,8 @@ get_function(CPPInstance *function, string description, string function_signature = TypeManager::get_function_signature(function); if (ftype->_flags & CPPFunctionType::F_unary_op) { - // This is a unary operator function. Name it differently so we - // don't consider it an overloaded version of a similarly-named - // binary operator. + // This is a unary operator function. Name it differently so we don't + // consider it an overloaded version of a similarly-named binary operator. function_name += "unary"; } @@ -1896,14 +1781,11 @@ get_function(CPPInstance *function, string description, return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_make_property -// Access: Private -// Description: Adds the indicated make_property to the database, -// if it is not already present. In either case, -// returns the MakeSeqIndex of the make_seq within the -// database. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated make_property to the database, if it is not already + * present. In either case, returns the MakeSeqIndex of the make_seq within + * the database. + */ ElementIndex InterrogateBuilder:: get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CPPScope *scope) { // This is needed so we can get a proper unique name for the property. @@ -1989,9 +1871,8 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP if (return_type != NULL) { iproperty._type = get_type(return_type, false); - //if (iproperty._type == 0) { - // parser.warning("cannot determine property type", make_property->_ident->_loc); - //} + // if (iproperty._type == 0) { parser.warning("cannot determine property + // type", make_property->_ident->_loc); } } else { iproperty._type = 0; } @@ -2055,13 +1936,10 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_make_seq -// Access: Private -// Description: Adds the indicated make_seq to the database, if it is -// not already present. In either case, returns the -// MakeSeq of the make_seq within the database. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated make_seq to the database, if it is not already present. + * In either case, returns the MakeSeq of the make_seq within the database. + */ MakeSeqIndex InterrogateBuilder:: get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { string make_seq_name = make_seq->get_local_name(&parser); @@ -2151,20 +2029,17 @@ get_make_seq(CPPMakeSeq *make_seq, CPPStructType *struct_type) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_atomic_string_type -// Access: Private -// Description: Returns a TypeIndex for the "atomic string" type, -// which is a bogus type that might be used if -string -// is passed to interrogate. It means to translate -// basic_string and char * to whatever atomic -// string type is native to the particular the scripting -// language we happen to be generating wrappers for. -//////////////////////////////////////////////////////////////////// +/** + * Returns a TypeIndex for the "atomic string" type, which is a bogus type + * that might be used if -string is passed to interrogate. It means to + * translate basic_string and char * to whatever atomic string type is + * native to the particular the scripting language we happen to be generating + * wrappers for. + */ TypeIndex InterrogateBuilder:: get_atomic_string_type() { - // Make up a true name that can't possibly clash with an actual C++ - // type name. + // Make up a true name that can't possibly clash with an actual C++ type + // name. string true_name = "atomic string"; TypesByName::const_iterator tni = _types_by_name.find(true_name); @@ -2172,8 +2047,8 @@ get_atomic_string_type() { return (*tni).second; } - // This is the first time the atomic string has been requested; - // define it now. + // This is the first time the atomic string has been requested; define it + // now. TypeIndex index = InterrogateDatabase::get_ptr()->get_next_index(); _types_by_name[true_name] = index; @@ -2190,13 +2065,10 @@ get_atomic_string_type() { return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::get_type -// Access: Private -// Description: Adds the indicated type to the database, if it is not -// already present. In either case, returns the -// TypeIndex of the type within the database. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated type to the database, if it is not already present. In + * either case, returns the TypeIndex of the type within the database. + */ TypeIndex InterrogateBuilder:: get_type(CPPType *type, bool global) { if (type->is_template()) { @@ -2210,9 +2082,9 @@ get_type(CPPType *type, bool global) { string true_name = type->get_local_name(&parser); if (true_name.empty()) { - // Whoops, it's an anonymous type. That's okay, because we'll - // usually only encounter them once anyway, so let's go ahead and - // define it without checking _types_by_name first. + // Whoops, it's an anonymous type. That's okay, because we'll usually + // only encounter them once anyway, so let's go ahead and define it + // without checking _types_by_name first. } else { TypesByName::const_iterator tni = _types_by_name.find(true_name); @@ -2233,8 +2105,8 @@ get_type(CPPType *type, bool global) { return index; } - // But wait--it's not fully defined yet! We'll go ahead and - // define it now. + // But wait--it's not fully defined yet! We'll go ahead and define it + // now. } } @@ -2274,8 +2146,7 @@ get_type(CPPType *type, bool global) { itype._cpptype = type; if (type->_declaration != (CPPTypeDeclaration *)NULL) { - // This type has a declaration; does the declaration have a - // comment? + // This type has a declaration; does the declaration have a comment? CPPTypeDeclaration *decl = type->_declaration; if (decl->_leading_comment != (CPPCommentBlock *)NULL) { itype._comment = trim_blanks(decl->_leading_comment->_comment); @@ -2362,11 +2233,9 @@ get_type(CPPType *type, bool global) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_atomic_type -// Access: Private -// Description: Builds up a definition for the indicated atomic type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated atomic type. + */ void InterrogateBuilder:: define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype) { itype._flags |= InterrogateType::F_atomic; @@ -2438,39 +2307,32 @@ define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_wrapped_type -// Access: Private -// Description: Builds up a definition for the indicated wrapped type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated wrapped type. + */ void InterrogateBuilder:: define_wrapped_type(InterrogateType &itype, CPPPointerType *cpptype) { itype._flags |= (InterrogateType::F_wrapped | InterrogateType::F_pointer); itype._wrapped_type = get_type(cpptype->_pointing_at, false); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_wrapped_type -// Access: Private -// Description: Builds up a definition for the indicated wrapped type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated wrapped type. + */ void InterrogateBuilder:: define_wrapped_type(InterrogateType &itype, CPPConstType *cpptype) { itype._flags |= (InterrogateType::F_wrapped | InterrogateType::F_const); itype._wrapped_type = get_type(cpptype->_wrapped_around, false); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_struct_type -// Access: Private -// Description: Builds up a definition for the indicated struct type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated struct type. + */ void InterrogateBuilder:: define_struct_type(InterrogateType &itype, CPPStructType *cpptype, TypeIndex type_index, bool forced) { if (cpptype->get_simple_name().empty()) { - // If the type has no name, forget it. We don't export anonymous - // structs. + // If the type has no name, forget it. We don't export anonymous structs. return; } @@ -2496,29 +2358,27 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } if (cpptype->_file.is_c_file()) { - // This type declaration appears in a .C file. We can only export - // types defined in a .h file. + // This type declaration appears in a .C file. We can only export types + // defined in a .h file. return; } if (!forced && (cpptype->_file._source != CPPFile::S_local || in_ignorefile(cpptype->_file._filename_as_referenced))) { - // The struct type is defined in some other package or in an - // ignorable file, so don't try to output it. + // The struct type is defined in some other package or in an ignorable + // file, so don't try to output it. - // This means we also don't gather any information about its - // derivations or determine if an implicit destructor is - // necessary. However, this is not important, and it causes - // problems if we do (how many implicit destructors do we need, - // anyway?). + // This means we also don't gather any information about its derivations + // or determine if an implicit destructor is necessary. However, this is + // not important, and it causes problems if we do (how many implicit + // destructors do we need, anyway?). itype._flags &= ~InterrogateType::F_fully_defined; return; } - // Make sure the class declaration within its parent scope isn't - // private or protected. If it is, we can't export any of its - // members. + // Make sure the class declaration within its parent scope isn't private or + // protected. If it is, we can't export any of its members. if (TypeManager::involves_unpublished(cpptype)) { itype._flags &= ~InterrogateType::F_fully_defined; itype._flags |= InterrogateType::F_unpublished; @@ -2573,17 +2433,16 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } else if (cpptype->_derivation.size() != 1 && left_inheritance_requires_upcast) { - // Or even if we are the leftmost fork of multiple - // inheritance, if the flag is set indicating that this - // requires a pointer change. (For many compilers, this does - // not require a pointer change.) + // Or even if we are the leftmost fork of multiple inheritance, if + // the flag is set indicating that this requires a pointer change. + // (For many compilers, this does not require a pointer change.) generate_casts = true; } else if (has_virt_methods && (base_type->as_struct_type() == (CPPStructType *)NULL || !base_type->as_struct_type()->check_virtual())) { - // Finally, if this class has virtual methods, but its - // parent doesn't, then we have to upcast (because this - // class will require space for a virtual function table - // pointer, while the parent class won't). + // Finally, if this class has virtual methods, but its parent + // doesn't, then we have to upcast (because this class will require + // space for a virtual function table pointer, while the parent + // class won't). generate_casts = true; } @@ -2592,8 +2451,7 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, d._flags |= InterrogateType::DF_upcast; if (base._is_virtual) { - // If this is a virtual inheritance, we can't write a - // downcast. + // If this is a virtual inheritance, we can't write a downcast. d._flags |= InterrogateType::DF_downcast_impossible; } else { d._downcast = get_cast_function(cpptype, base_type, "downcast"); @@ -2731,8 +2589,8 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } if ((itype._flags & InterrogateType::F_inherited_destructor) != 0) { - // If we have inherited our virtual destructor from our base - // class, go ahead and assign the same function index. + // If we have inherited our virtual destructor from our base class, go + // ahead and assign the same function index. assert(!itype._derivations.empty()); TypeIndex base_type_index = itype._derivations.front()._base; InterrogateType &base_type = InterrogateDatabase::get_ptr()-> @@ -2745,8 +2603,8 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, InterrogateType::F_private_destructor | InterrogateType::F_inherited_destructor | InterrogateType::F_implicit_destructor)) == 0) { - // If we didn't get a destructor at all, we should make a wrapper - // for one anyway. + // If we didn't get a destructor at all, we should make a wrapper for one + // anyway. string function_name = "~" + cpptype->get_simple_name(); // Make up a CPPFunctionType. @@ -2765,16 +2623,12 @@ define_struct_type(InterrogateType &itype, CPPStructType *cpptype, } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::update_function_comment -// Access: Private -// Description: Updates the function definition in the database to -// include whatever comment is associated with this -// declaration. This is called when we encounted a -// method definition outside of the class or function -// definition in a C++ file; the only new information -// this might include for us is the comment. -//////////////////////////////////////////////////////////////////// +/** + * Updates the function definition in the database to include whatever comment + * is associated with this declaration. This is called when we encounted a + * method definition outside of the class or function definition in a C++ + * file; the only new information this might include for us is the comment. + */ void InterrogateBuilder:: update_function_comment(CPPInstance *function, CPPScope *scope) { if (function->_leading_comment == (CPPCommentBlock *)NULL) { @@ -2796,9 +2650,8 @@ update_function_comment(CPPInstance *function, CPPScope *scope) { string function_signature = TypeManager::get_function_signature(function); if (ftype->_flags & CPPFunctionType::F_unary_op) { - // This is a unary operator function. Name it differently so we - // don't consider it an overloaded version of a similarly-named - // binary operator. + // This is a unary operator function. Name it differently so we don't + // consider it an overloaded version of a similarly-named binary operator. function_name += "unary"; } @@ -2833,11 +2686,9 @@ update_function_comment(CPPInstance *function, CPPScope *scope) { } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_method -// Access: Private -// Description: Adds the indicated member function to the struct type, -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated member function to the struct type, + */ void InterrogateBuilder:: define_method(CPPFunctionGroup *fgroup, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope) { @@ -2848,11 +2699,9 @@ define_method(CPPFunctionGroup *fgroup, InterrogateType &itype, } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_method -// Access: Private -// Description: Adds the indicated member function to the struct type, -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated member function to the struct type, + */ void InterrogateBuilder:: define_method(CPPInstance *function, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope) { @@ -2872,11 +2721,10 @@ define_method(CPPInstance *function, InterrogateType &itype, return; } - // As a special kludgey extension, we consider a public static - // method called "get_class_type()" to be marked published, even if - // it is not. This allows us to export all of the TypeHandle system - // stuff without having to specifically flag get_class_type() as - // published. + // As a special kludgey extension, we consider a public static method called + // "get_class_type()" to be marked published, even if it is not. This + // allows us to export all of the TypeHandle system stuff without having to + // specifically flag get_class_type() as published. bool force_publish = false; if (function->get_simple_name() == "get_class_type" && (function->_storage_class && CPPInstance::SC_static) != 0 && @@ -2885,10 +2733,9 @@ define_method(CPPInstance *function, InterrogateType &itype, } if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { - // A destructor is a special case. If it's public, we export it - // (even if it's not published), but if it's protected or private, - // we don't export it, and we flag it so we don't try to - // synthesize one later. + // A destructor is a special case. If it's public, we export it (even if + // it's not published), but if it's protected or private, we don't export + // it, and we flag it so we don't try to synthesize one later. if (function->_vis > V_public) { itype._flags |= InterrogateType::F_private_destructor; return; @@ -2902,14 +2749,14 @@ define_method(CPPInstance *function, InterrogateType &itype, } if (TypeManager::involves_protected(ftype)) { - // We can't export the function because it involves parameter - // types that are protected or private. + // We can't export the function because it involves parameter types that + // are protected or private. return; } if (in_ignoreinvolved(ftype)) { - // The function or its parameters involves something that the - // user requested we ignore. + // The function or its parameters involves something that the user + // requested we ignore. if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { itype._flags |= InterrogateType::F_private_destructor; } @@ -2928,18 +2775,17 @@ define_method(CPPInstance *function, InterrogateType &itype, struct_type->_derivation.size() == 1 && struct_type->_derivation[0]._vis <= V_public && !struct_type->_derivation[0]._is_virtual) { - // If this function is a virtual function whose first appearance - // is in some base class, we don't need to repeat its definition - // here, since we're already inheriting it properly. However, we - // may need to make an exception in the presence of multiple - // inheritance. + // If this function is a virtual function whose first appearance is in + // some base class, we don't need to repeat its definition here, since + // we're already inheriting it properly. However, we may need to make an + // exception in the presence of multiple inheritance. if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { itype._flags |= InterrogateType::F_inherited_destructor; return; } - // Let's make sure the that first appearance of the function is - // actually declared published. + // Let's make sure the that first appearance of the function is actually + // declared published. if (is_inherited_published(function, struct_type)) { return; } @@ -2974,11 +2820,9 @@ define_method(CPPInstance *function, InterrogateType &itype, } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_enum_type -// Access: Private -// Description: Builds up a definition for the indicated enum type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated enum type. + */ void InterrogateBuilder:: define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { itype._flags |= InterrogateType::F_enum; @@ -2988,9 +2832,8 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { scope = cpptype->_ident->get_scope(&parser, &parser); } - // Make sure the enum declaration within its parent scope isn't - // private or protected. If it is, we can't export any of its - // members. + // Make sure the enum declaration within its parent scope isn't private or + // protected. If it is, we can't export any of its members. if (TypeManager::involves_unpublished(cpptype)) { itype._flags &= ~InterrogateType::F_fully_defined; itype._flags |= InterrogateType::F_unpublished; @@ -3005,8 +2848,8 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { ++ei) { CPPInstance *element = (*ei); - // Tell the enum element where its native scope is, so we can get - // a properly scoped name. + // Tell the enum element where its native scope is, so we can get a + // properly scoped name. if (element->_ident->_native_scope != scope) { element = new CPPInstance(*element); @@ -3041,22 +2884,18 @@ define_enum_type(InterrogateType &itype, CPPEnumType *cpptype) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_typedef_type -// Access: Private -// Description: Builds up a definition for the indicated typedef. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated typedef. + */ void InterrogateBuilder:: define_typedef_type(InterrogateType &itype, CPPTypedefType *cpptype) { itype._flags |= InterrogateType::F_typedef; itype._wrapped_type = get_type(cpptype->_type, false); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_array_type -// Access: Private -// Description: Builds up a definition for the indicated wrapped type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated wrapped type. + */ void InterrogateBuilder:: define_array_type(InterrogateType &itype, CPPArrayType *cpptype) { itype._flags |= InterrogateType::F_array; @@ -3070,19 +2909,16 @@ define_array_type(InterrogateType &itype, CPPArrayType *cpptype) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::define_extension_type -// Access: Private -// Description: Builds up a definition for the indicated extension type. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a definition for the indicated extension type. + */ void InterrogateBuilder:: define_extension_type(InterrogateType &itype, CPPExtensionType *cpptype) { // An "extension type" as returned by CPPParser is really a forward // reference to an undefined struct or class type. itype._flags &= ~InterrogateType::F_fully_defined; - // But we can at least indicate which of the various extension types - // it is. + // But we can at least indicate which of the various extension types it is. switch (cpptype->_type) { case CPPExtensionType::T_enum: itype._flags |= InterrogateType::F_enum; @@ -3102,11 +2938,9 @@ define_extension_type(InterrogateType &itype, CPPExtensionType *cpptype) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateBuilder::trim_blanks -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string InterrogateBuilder:: trim_blanks(const string &str) { size_t start = 0; diff --git a/dtool/src/interrogate/interrogateBuilder.h b/dtool/src/interrogate/interrogateBuilder.h index 78962630e7..41096a6f6a 100644 --- a/dtool/src/interrogate/interrogateBuilder.h +++ b/dtool/src/interrogate/interrogateBuilder.h @@ -1,16 +1,15 @@ -// Filename: interrogateBuilder.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateBuilder.h + * @author drose + * @date 2000-08-01 + */ #ifndef INTERROGATEBUILDER_H #define INTERROGATEBUILDER_H @@ -47,12 +46,10 @@ class InterrogateFunction; class FunctionRemap; class InterfaceMaker; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateBuilder -// Description : This class builds up the InterrogateDatabase based on -// the data indicated by CPPParser after reading the -// source code. -//////////////////////////////////////////////////////////////////// +/** + * This class builds up the InterrogateDatabase based on the data indicated by + * CPPParser after reading the source code. + */ class InterrogateBuilder { public: void add_source_file(const string &filename); @@ -168,5 +165,3 @@ public: extern InterrogateBuilder builder; #endif - - diff --git a/dtool/src/interrogate/interrogate_module.cxx b/dtool/src/interrogate/interrogate_module.cxx index 2b9dfa5ce3..9a8cff85bf 100644 --- a/dtool/src/interrogate/interrogate_module.cxx +++ b/dtool/src/interrogate/interrogate_module.cxx @@ -1,21 +1,20 @@ -// Filename: interrogate_module.cxx -// Created by: drose (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_module.cxx + * @author drose + * @date 2000-08-08 + */ -// This program generates a module-level file for interrogate. This -// is a higher level than library, and groups several libraries -// together. Presently, the only thing that goes into the module file -// is a python table, but who knows what the future holds. +// This program generates a module-level file for interrogate. This is a +// higher level than library, and groups several libraries together. +// Presently, the only thing that goes into the module file is a python table, +// but who knows what the future holds. #include "interrogate_interface.h" #include "interrogate_request.h" @@ -86,7 +85,7 @@ int write_python_table_native(ostream &out) { vector_string libraries; -// out << "extern \"C\" {\n"; +// out << "extern \"C\" {\n"; // Walk through all of the Python functions. int num_functions = interrogate_number_of_functions(); @@ -94,17 +93,17 @@ int write_python_table_native(ostream &out) { for (fi = 0; fi < num_functions; fi++) { FunctionIndex function_index = interrogate_get_function(fi); - // Consider only those that belong in the module we asked for. - //if (interrogate_function_has_module_name(function_index) && - // module_name == interrogate_function_module_name(function_index)) { - // if it has a library name add it to set of libraries + // Consider only those that belong in the module we asked for. if + // (interrogate_function_has_module_name(function_index) && module_name == + // interrogate_function_module_name(function_index)) { if it has a library + // name add it to set of libraries if (interrogate_function_has_library_name(function_index)) { string library_name = interrogate_function_library_name(function_index); if (std::find(libraries.begin(), libraries.end(), library_name) == libraries.end()) { libraries.push_back(library_name); } } - //} + // } } for (int ti = 0; ti < interrogate_number_of_types(); ti++) { @@ -267,8 +266,8 @@ int write_python_table(ostream &out) { int count = 0; - // First, we have to declare extern C prototypes for each of the - // function names. + // First, we have to declare extern C prototypes for each of the function + // names. out << "extern \"C\" {\n"; @@ -447,8 +446,8 @@ int main(int argc, char *argv[]) { if (param.length() > 3 && param.substr(param.length() - 3) == ".in") { - // If the filename ends in ".in", it's an interrogate database - // file, not a shared library--read it directly. + // If the filename ends in ".in", it's an interrogate database file, not + // a shared library--read it directly. interrogate_request_database(param.c_str()); } else { diff --git a/dtool/src/interrogate/parameterRemap.I b/dtool/src/interrogate/parameterRemap.I index bf76395959..4b3040e514 100644 --- a/dtool/src/interrogate/parameterRemap.I +++ b/dtool/src/interrogate/parameterRemap.I @@ -1,23 +1,19 @@ -// Filename: parameterRemap.I -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemap.I + * @author drose + * @date 2000-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ParameterRemap:: ParameterRemap(CPPType *orig_type) : _orig_type(orig_type), @@ -28,48 +24,37 @@ ParameterRemap(CPPType *orig_type) : _default_value = (CPPExpression *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::is_valid -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ParameterRemap:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_orig_type -// Access: Public -// Description: Returns the type of the original, C++ parameter or -// return value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the original, C++ parameter or return value. + */ INLINE CPPType *ParameterRemap:: get_orig_type() const { return _orig_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_new_type -// Access: Public -// Description: Returns the type of the wrapper's parameter or return -// value. This is the type that will be reported in the -// interrogate database, and the type that the scripting -// language is expected to deal with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the wrapper's parameter or return value. This is the + * type that will be reported in the interrogate database, and the type that + * the scripting language is expected to deal with. + */ INLINE CPPType *ParameterRemap:: get_new_type() const { return _new_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_temporary_type -// Access: Public -// Description: Returns the type of any temporary variables used to -// hold the return value before returning it. This is -// normally the same as get_new_type(), but in some -// circumstances it may need to be different. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of any temporary variables used to hold the return value + * before returning it. This is normally the same as get_new_type(), but in + * some circumstances it may need to be different. + */ INLINE CPPType *ParameterRemap:: get_temporary_type() const { if (_temporary_type == (CPPType *)NULL) { @@ -79,34 +64,25 @@ get_temporary_type() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::has_default_value -// Access: Public -// Description: Returns true if this particular parameter has a -// default value defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular parameter has a default value defined. + */ INLINE bool ParameterRemap:: has_default_value() const { return (_default_value != (CPPExpression *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_default_value -// Access: Public -// Description: Returns the expression corresponding to this parameter's -// default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the expression corresponding to this parameter's default value. + */ INLINE CPPExpression *ParameterRemap:: get_default_value() const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::set_default_value -// Access: Public -// Description: Records a default value to be associated with this -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Records a default value to be associated with this parameter. + */ INLINE void ParameterRemap:: set_default_value(CPPExpression *expr) { _default_value = expr; diff --git a/dtool/src/interrogate/parameterRemap.cxx b/dtool/src/interrogate/parameterRemap.cxx index 6862010ea2..19c6bb4251 100644 --- a/dtool/src/interrogate/parameterRemap.cxx +++ b/dtool/src/interrogate/parameterRemap.cxx @@ -1,149 +1,116 @@ -// Filename: parameterRemap.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemap.cxx + * @author drose + * @date 2000-08-01 + */ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemap:: ~ParameterRemap() { } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemap:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::prepare_return_expr -// Access: Public, Virtual -// Description: This will be called immediately before -// get_return_expr(). It outputs whatever lines the -// remapper needs to the function to set up its return -// value, e.g. to declare a temporary variable or -// something. It should return the modified expression. -//////////////////////////////////////////////////////////////////// +/** + * This will be called immediately before get_return_expr(). It outputs + * whatever lines the remapper needs to the function to set up its return + * value, e.g. to declare a temporary variable or something. It should + * return the modified expression. + */ string ParameterRemap:: prepare_return_expr(ostream &, int, const string &expression) { return expression; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemap:: get_return_expr(const string &expression) { return expression; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::temporary_to_return -// Access: Public, Virtual -// Description: Returns the string that converts the expression -// stored in the indicated temporary variable to the -// appropriate return value type. This is normally a -// pass-through, but in cases when the temporary -// variable type must be different than the return type -// (i.e. get_temporary_type() != get_new_type()), this -// might perform some operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that converts the expression stored in the indicated + * temporary variable to the appropriate return value type. This is normally + * a pass-through, but in cases when the temporary variable type must be + * different than the return type (i.e. get_temporary_type() != + * get_new_type()), this might perform some operation. + */ string ParameterRemap:: temporary_to_return(const string &temporary) { return temporary; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::return_value_needs_management -// Access: Public, Virtual -// Description: Returns true if the return value represents a value -// that was newly allocated, and hence must be -// explicitly deallocated later by the caller. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the return value represents a value that was newly + * allocated, and hence must be explicitly deallocated later by the caller. + */ bool ParameterRemap:: return_value_needs_management() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::get_return_value_destructor -// Access: Public, Virtual -// Description: If return_value_needs_management() returns true, this -// should return the index of the function that should -// be called when it is time to destruct the return -// value. It will generally be the same as the -// destructor for the class we just returned a pointer -// to. -//////////////////////////////////////////////////////////////////// +/** + * If return_value_needs_management() returns true, this should return the + * index of the function that should be called when it is time to destruct the + * return value. It will generally be the same as the destructor for the + * class we just returned a pointer to. + */ FunctionIndex ParameterRemap:: get_return_value_destructor() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::return_value_should_be_simple -// Access: Public, Virtual -// Description: This is a hack around a problem VC++ has with -// overly-complex expressions, particularly in -// conjunction with the 'new' operator. If this -// parameter type is one that will probably give VC++ a -// headache, this should be set true to indicate that -// the code generator should save the return value -// expression into a temporary variable first, and pass -// the temporary variable name in instead. -//////////////////////////////////////////////////////////////////// +/** + * This is a hack around a problem VC++ has with overly-complex expressions, + * particularly in conjunction with the 'new' operator. If this parameter + * type is one that will probably give VC++ a headache, this should be set + * true to indicate that the code generator should save the return value + * expression into a temporary variable first, and pass the temporary variable + * name in instead. + */ bool ParameterRemap:: return_value_should_be_simple() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::new_type_is_atomic_string -// Access: Public, Virtual -// Description: Returns true if the type represented by the -// conversion is now the atomic string type. We have to -// have this crazy method for representing atomic -// string, because there's no such type in C (and hence -// no corresponding CPPType *). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type represented by the conversion is now the atomic + * string type. We have to have this crazy method for representing atomic + * string, because there's no such type in C (and hence no corresponding + * CPPType *). + */ bool ParameterRemap:: new_type_is_atomic_string() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemap::is_this -// Access: Public, Virtual -// Description: Returns true if this is the "this" parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is the "this" parameter. + */ bool ParameterRemap:: is_this() { return false; } - diff --git a/dtool/src/interrogate/parameterRemap.h b/dtool/src/interrogate/parameterRemap.h index 4afc0900b5..1e34fd0a8f 100644 --- a/dtool/src/interrogate/parameterRemap.h +++ b/dtool/src/interrogate/parameterRemap.h @@ -1,16 +1,15 @@ -// Filename: parameterRemap.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemap.h + * @author drose + * @date 2000-08-01 + */ #ifndef PARAMETERREMAP_H #define PARAMETERREMAP_H @@ -22,23 +21,18 @@ class CPPType; class CPPExpression; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemap -// Description : An abstract base class for a number of different -// kinds of ways to remap parameters for passing to -// wrapper functions. -// -// Certain kinds of function parameters that are legal -// in C++ (for instance, passing by reference, or -// passing structures as concrete values) are not legal -// for a typical scripting language. We map these types -// of parameters to something equivalent (for instance, -// a reference becomes a pointer). -// -// For each kind of possible remapping, we define a -// class derived from ParameterRemap that defines the -// exact nature of the remap. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for a number of different kinds of ways to remap + * parameters for passing to wrapper functions. + * + * Certain kinds of function parameters that are legal in C++ (for instance, + * passing by reference, or passing structures as concrete values) are not + * legal for a typical scripting language. We map these types of parameters + * to something equivalent (for instance, a reference becomes a pointer). + * + * For each kind of possible remapping, we define a class derived from + * ParameterRemap that defines the exact nature of the remap. + */ class ParameterRemap { public: INLINE ParameterRemap(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx index 03bb183a0e..8c9c247ac7 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.cxx @@ -1,25 +1,22 @@ -// Filename: parameterRemapBasicStringPtrToString.cxx -// Created by: drose (11Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringPtrToString.cxx + * @author drose + * @date 2009-08-11 + */ #include "parameterRemapBasicStringPtrToString.h" #include "interrogate.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringPtrToString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicStringPtrToString:: ParameterRemapBasicStringPtrToString(CPPType *orig_type) : ParameterRemapToString(orig_type) @@ -32,35 +29,27 @@ ParameterRemapBasicStringPtrToString(CPPType *orig_type) : _new_type = const_char_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringPtrToString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicStringPtrToString:: pass_parameter(ostream &out, const string &variable_name) { out << "&std::string(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringPtrToString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicStringPtrToString:: get_return_expr(const string &expression) { return "(" + expression + ")->c_str()"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringPtrToWString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicWStringPtrToWString:: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) @@ -73,25 +62,19 @@ ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) : _new_type = const_wchar_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringPtrToWString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicWStringPtrToWString:: pass_parameter(ostream &out, const string &variable_name) { out << "&std::wstring(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringPtrToWString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicWStringPtrToWString:: get_return_expr(const string &expression) { return "(" + expression + ")->c_str()"; diff --git a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h index ef4f686195..e034d8ebad 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringPtrToString.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapBasicStringPtrToString.h -// Created by: drose (11Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringPtrToString.h + * @author drose + * @date 2009-08-11 + */ #ifndef PARAMETERREMAPBASICSTRINGPTRTOSTRING_H #define PARAMETERREMAPBASICSTRINGPTRTOSTRING_H @@ -19,11 +18,9 @@ #include "parameterRemapToString.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicStringPtrToString -// Description : Maps a const pointer to a basic_string to an -// atomic string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a const pointer to a basic_string to an atomic string. + */ class ParameterRemapBasicStringPtrToString : public ParameterRemapToString { public: ParameterRemapBasicStringPtrToString(CPPType *orig_type); @@ -32,11 +29,9 @@ public: virtual string get_return_expr(const string &expression); }; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicWStringPtrToWString -// Description : Maps a const pointer to a basic_string to an -// atomic string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a const pointer to a basic_string to an atomic string. + */ class ParameterRemapBasicWStringPtrToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringPtrToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx index 84962d4bf6..a94055f899 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.cxx @@ -1,25 +1,22 @@ -// Filename: parameterRemapBasicStringRefToString.cxx -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringRefToString.cxx + * @author drose + * @date 2000-08-09 + */ #include "parameterRemapBasicStringRefToString.h" #include "interrogate.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringRefToString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicStringRefToString:: ParameterRemapBasicStringRefToString(CPPType *orig_type) : ParameterRemapToString(orig_type) @@ -32,35 +29,27 @@ ParameterRemapBasicStringRefToString(CPPType *orig_type) : _new_type = const_char_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringRefToString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicStringRefToString:: pass_parameter(ostream &out, const string &variable_name) { out << "std::string(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringRefToString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicStringRefToString:: get_return_expr(const string &expression) { return "(" + expression + ").c_str()"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringRefToWString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicWStringRefToWString:: ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) @@ -73,25 +62,19 @@ ParameterRemapBasicWStringRefToWString(CPPType *orig_type) : _new_type = const_wchar_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringRefToWString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicWStringRefToWString:: pass_parameter(ostream &out, const string &variable_name) { out << "std::wstring(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringRefToWString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicWStringRefToWString:: get_return_expr(const string &expression) { return "(" + expression + ").c_str()"; diff --git a/dtool/src/interrogate/parameterRemapBasicStringRefToString.h b/dtool/src/interrogate/parameterRemapBasicStringRefToString.h index 57f1192bc8..65c6bc23fc 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringRefToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringRefToString.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapBasicStringRefToString.h -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringRefToString.h + * @author drose + * @date 2000-08-09 + */ #ifndef PARAMETERREMAPBASICSTRINGREFTOSTRING_H #define PARAMETERREMAPBASICSTRINGREFTOSTRING_H @@ -19,11 +18,9 @@ #include "parameterRemapToString.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicStringRefToString -// Description : Maps a const reference to a basic_string to an -// atomic string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a const reference to a basic_string to an atomic string. + */ class ParameterRemapBasicStringRefToString : public ParameterRemapToString { public: ParameterRemapBasicStringRefToString(CPPType *orig_type); @@ -32,11 +29,9 @@ public: virtual string get_return_expr(const string &expression); }; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicWStringRefToWString -// Description : Maps a const reference to a basic_string to an -// atomic string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a const reference to a basic_string to an atomic string. + */ class ParameterRemapBasicWStringRefToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringRefToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx index 8a23083953..db031004c6 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.cxx +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.cxx @@ -1,26 +1,23 @@ -// Filename: parameterRemapBasicStringToString.cxx -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringToString.cxx + * @author drose + * @date 2000-08-09 + */ #include "parameterRemapBasicStringToString.h" #include "interfaceMaker.h" #include "interrogate.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringToString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicStringToString:: ParameterRemapBasicStringToString(CPPType *orig_type) : ParameterRemapToString(orig_type) @@ -33,27 +30,21 @@ ParameterRemapBasicStringToString(CPPType *orig_type) : _new_type = const_char_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringToString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicStringToString:: pass_parameter(ostream &out, const string &variable_name) { out << "std::string(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringToString::prepare_return_expr -// Access: Public, Virtual -// Description: This will be called immediately before -// get_return_expr(). It outputs whatever lines the -// remapper needs to the function to set up its return -// value, e.g. to declare a temporary variable or -// something. It should return the modified expression. -//////////////////////////////////////////////////////////////////// +/** + * This will be called immediately before get_return_expr(). It outputs + * whatever lines the remapper needs to the function to set up its return + * value, e.g. to declare a temporary variable or something. It should + * return the modified expression. + */ string ParameterRemapBasicStringToString:: prepare_return_expr(ostream &out, int indent_level, const string &expression) { InterfaceMaker::indent(out, indent_level) @@ -61,23 +52,18 @@ prepare_return_expr(ostream &out, int indent_level, const string &expression) { return "string_holder"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicStringToString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicStringToString:: get_return_expr(const string &expression) { return "string_holder.c_str()"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringToWString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapBasicWStringToWString:: ParameterRemapBasicWStringToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) @@ -90,27 +76,21 @@ ParameterRemapBasicWStringToWString(CPPType *orig_type) : _new_type = const_wchar_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringToWString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapBasicWStringToWString:: pass_parameter(ostream &out, const string &variable_name) { out << "std::wstring(" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringToWString::prepare_return_expr -// Access: Public, Virtual -// Description: This will be called immediately before -// get_return_expr(). It outputs whatever lines the -// remapper needs to the function to set up its return -// value, e.g. to declare a temporary variable or -// something. It should return the modified expression. -//////////////////////////////////////////////////////////////////// +/** + * This will be called immediately before get_return_expr(). It outputs + * whatever lines the remapper needs to the function to set up its return + * value, e.g. to declare a temporary variable or something. It should + * return the modified expression. + */ string ParameterRemapBasicWStringToWString:: prepare_return_expr(ostream &out, int indent_level, const string &expression) { InterfaceMaker::indent(out, indent_level) @@ -118,13 +98,10 @@ prepare_return_expr(ostream &out, int indent_level, const string &expression) { return "string_holder"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapBasicWStringToWString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapBasicWStringToWString:: get_return_expr(const string &expression) { return "string_holder.c_str()"; diff --git a/dtool/src/interrogate/parameterRemapBasicStringToString.h b/dtool/src/interrogate/parameterRemapBasicStringToString.h index 63678a8354..57d1a5624e 100644 --- a/dtool/src/interrogate/parameterRemapBasicStringToString.h +++ b/dtool/src/interrogate/parameterRemapBasicStringToString.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapBasicStringToString.h -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapBasicStringToString.h + * @author drose + * @date 2000-08-09 + */ #ifndef PARAMETERREMAPBASICSTRINGTOSTRING_H #define PARAMETERREMAPBASICSTRINGTOSTRING_H @@ -19,11 +18,9 @@ #include "parameterRemapToString.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicStringToString -// Description : Maps a concrete basic_string to an atomic -// string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a concrete basic_string to an atomic string. + */ class ParameterRemapBasicStringToString : public ParameterRemapToString { public: ParameterRemapBasicStringToString(CPPType *orig_type); @@ -34,11 +31,9 @@ public: virtual string get_return_expr(const string &expression); }; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapBasicWStringToWString -// Description : Maps a concrete basic_string to an atomic -// string. -//////////////////////////////////////////////////////////////////// +/** + * Maps a concrete basic_string to an atomic string. + */ class ParameterRemapBasicWStringToWString : public ParameterRemapToWString { public: ParameterRemapBasicWStringToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapCharStarToString.cxx b/dtool/src/interrogate/parameterRemapCharStarToString.cxx index d54e4f90cb..e791fe9c61 100644 --- a/dtool/src/interrogate/parameterRemapCharStarToString.cxx +++ b/dtool/src/interrogate/parameterRemapCharStarToString.cxx @@ -1,35 +1,30 @@ -// Filename: parameterRemapCharStarToString.cxx -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapCharStarToString.cxx + * @author drose + * @date 2000-08-09 + */ #include "parameterRemapCharStarToString.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapCharStarToString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapCharStarToString:: ParameterRemapCharStarToString(CPPType *orig_type) : ParameterRemapToString(orig_type) { } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapWCharStarToWString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapWCharStarToWString:: ParameterRemapWCharStarToWString(CPPType *orig_type) : ParameterRemapToWString(orig_type) diff --git a/dtool/src/interrogate/parameterRemapCharStarToString.h b/dtool/src/interrogate/parameterRemapCharStarToString.h index 2bb9442f0f..8d1d891681 100644 --- a/dtool/src/interrogate/parameterRemapCharStarToString.h +++ b/dtool/src/interrogate/parameterRemapCharStarToString.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapCharStarToString.h -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapCharStarToString.h + * @author drose + * @date 2000-08-09 + */ #ifndef PARAMETERREMAPCHARSTARTOSTRING_H #define PARAMETERREMAPCHARSTARTOSTRING_H @@ -19,21 +18,17 @@ #include "parameterRemapToString.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapCharStarToString -// Description : Maps from (char *) or (const char *) to the atomic -// string type. -//////////////////////////////////////////////////////////////////// +/** + * Maps from (char *) or (const char *) to the atomic string type. + */ class ParameterRemapCharStarToString : public ParameterRemapToString { public: ParameterRemapCharStarToString(CPPType *orig_type); }; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapWCharStarToWString -// Description : Maps from (wchar_t *) or (const wchar_ *) to the atomic -// wide-string type. -//////////////////////////////////////////////////////////////////// +/** + * Maps from (wchar_t *) or (const wchar_ *) to the atomic wide-string type. + */ class ParameterRemapWCharStarToWString : public ParameterRemapToWString { public: ParameterRemapWCharStarToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx index 92739e96eb..05f0eda533 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapConcreteToPointer.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapConcreteToPointer.cxx + * @author drose + * @date 2000-08-01 + */ #include "parameterRemapConcreteToPointer.h" #include "interrogate.h" @@ -22,11 +21,9 @@ #include "cppConstType.h" #include "cppPointerType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapConcreteToPointer:: ParameterRemapConcreteToPointer(CPPType *orig_type) : ParameterRemap(orig_type) @@ -34,32 +31,25 @@ ParameterRemapConcreteToPointer(CPPType *orig_type) : _new_type = TypeManager::wrap_pointer(orig_type); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapConcreteToPointer:: pass_parameter(ostream &out, const string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { - // Prevent generating something like *¶m - // Also, if this is really some local type, we can presumably - // just move it? + // Prevent generating something like *¶m Also, if this is really some + // local type, we can presumably just move it? out << "MOVE(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapConcreteToPointer:: get_return_expr(const string &expression) { return @@ -67,45 +57,34 @@ get_return_expr(const string &expression) { "(" + expression + ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::return_value_needs_management -// Access: Public, Virtual -// Description: Returns true if the return value represents a value -// that was newly allocated, and hence must be -// explicitly deallocated later by the caller. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the return value represents a value that was newly + * allocated, and hence must be explicitly deallocated later by the caller. + */ bool ParameterRemapConcreteToPointer:: return_value_needs_management() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::get_return_value_destructor -// Access: Public, Virtual -// Description: If return_value_needs_management() returns true, this -// should return the index of the function that should -// be called when it is time to destruct the return -// value. It will generally be the same as the -// destructor for the class we just returned a pointer -// to. -//////////////////////////////////////////////////////////////////// +/** + * If return_value_needs_management() returns true, this should return the + * index of the function that should be called when it is time to destruct the + * return value. It will generally be the same as the destructor for the + * class we just returned a pointer to. + */ FunctionIndex ParameterRemapConcreteToPointer:: get_return_value_destructor() { return builder.get_destructor_for(_orig_type); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConcreteToPointer::return_value_should_be_simple -// Access: Public, Virtual -// Description: This is a hack around a problem VC++ has with -// overly-complex expressions, particularly in -// conjunction with the 'new' operator. If this -// parameter type is one that will probably give VC++ a -// headache, this should be set true to indicate that -// the code generator should save the return value -// expression into a temporary variable first, and pass -// the temporary variable name in instead. -//////////////////////////////////////////////////////////////////// +/** + * This is a hack around a problem VC++ has with overly-complex expressions, + * particularly in conjunction with the 'new' operator. If this parameter + * type is one that will probably give VC++ a headache, this should be set + * true to indicate that the code generator should save the return value + * expression into a temporary variable first, and pass the temporary variable + * name in instead. + */ bool ParameterRemapConcreteToPointer:: return_value_should_be_simple() { return true; diff --git a/dtool/src/interrogate/parameterRemapConcreteToPointer.h b/dtool/src/interrogate/parameterRemapConcreteToPointer.h index acc8909248..50c9bbab2e 100644 --- a/dtool/src/interrogate/parameterRemapConcreteToPointer.h +++ b/dtool/src/interrogate/parameterRemapConcreteToPointer.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapConcreteToPointer.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapConcreteToPointer.h + * @author drose + * @date 2000-08-01 + */ #ifndef PARAMETERREMAPCONCRETETOPOINTER_H #define PARAMETERREMAPCONCRETETOPOINTER_H @@ -19,12 +18,10 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapConcreteToPointer -// Description : A ParameterRemap class that handles remapping a -// concrete structure or class parameter to a pointer -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a concrete structure or class + * parameter to a pointer parameter. + */ class ParameterRemapConcreteToPointer : public ParameterRemap { public: ParameterRemapConcreteToPointer(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx index 1d46bf3c5c..c031350e70 100644 --- a/dtool/src/interrogate/parameterRemapConstToNonConst.cxx +++ b/dtool/src/interrogate/parameterRemapConstToNonConst.cxx @@ -1,27 +1,24 @@ -// Filename: parameterRemapConstToNonConst.cxx -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapConstToNonConst.cxx + * @author drose + * @date 2000-08-04 + */ #include "parameterRemapConstToNonConst.h" #include "typeManager.h" #include "cppConstType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConstToNonConst::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapConstToNonConst:: ParameterRemapConstToNonConst(CPPType *orig_type) : ParameterRemap(orig_type) @@ -29,25 +26,19 @@ ParameterRemapConstToNonConst(CPPType *orig_type) : _new_type = TypeManager::unwrap_const(orig_type); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConstToNonConst::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapConstToNonConst:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapConstToNonConst::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapConstToNonConst:: get_return_expr(const string &expression) { return expression; diff --git a/dtool/src/interrogate/parameterRemapConstToNonConst.h b/dtool/src/interrogate/parameterRemapConstToNonConst.h index d6f6e4315f..d952e26167 100644 --- a/dtool/src/interrogate/parameterRemapConstToNonConst.h +++ b/dtool/src/interrogate/parameterRemapConstToNonConst.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapConstToNonConst.h -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapConstToNonConst.h + * @author drose + * @date 2000-08-04 + */ #ifndef PARAMETERREMAPCONSTTONONCONST_H #define PARAMETERREMAPCONSTTONONCONST_H @@ -19,13 +18,11 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapConstToNonConst -// Description : A ParameterRemap class that handles remapping a -// simple const parameter (like const int) to an -// ordinary parameter (like int). It doesn't apply to -// const references or const pointers, however. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a simple const parameter + * (like const int) to an ordinary parameter (like int). It doesn't apply to + * const references or const pointers, however. + */ class ParameterRemapConstToNonConst : public ParameterRemap { public: ParameterRemapConstToNonConst(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapEnumToInt.cxx b/dtool/src/interrogate/parameterRemapEnumToInt.cxx index bc75480c22..40283dd364 100644 --- a/dtool/src/interrogate/parameterRemapEnumToInt.cxx +++ b/dtool/src/interrogate/parameterRemapEnumToInt.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapEnumToInt.cxx -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapEnumToInt.cxx + * @author drose + * @date 2000-08-04 + */ #include "parameterRemapEnumToInt.h" #include "interrogate.h" @@ -20,11 +19,9 @@ #include "cppPointerType.h" #include "cppReferenceType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapEnumToInt::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapEnumToInt:: ParameterRemapEnumToInt(CPPType *orig_type) : ParameterRemap(orig_type) @@ -33,36 +30,28 @@ ParameterRemapEnumToInt(CPPType *orig_type) : _enum_type = unwrap_type(_orig_type); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapEnumToInt::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapEnumToInt:: pass_parameter(ostream &out, const string &variable_name) { out << "(" << _enum_type->get_local_name(&parser) << ")" << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapEnumToInt::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapEnumToInt:: get_return_expr(const string &expression) { return "(int)(" + expression + ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapEnumToInt::unwrap_type -// Access: Private -// Description: Recursively walks through the type definition, -// and finds the enum definition under all the wrappers. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the type definition, and finds the enum + * definition under all the wrappers. + */ CPPType *ParameterRemapEnumToInt:: unwrap_type(CPPType *source_type) const { switch (source_type->get_subtype()) { diff --git a/dtool/src/interrogate/parameterRemapEnumToInt.h b/dtool/src/interrogate/parameterRemapEnumToInt.h index a2097a2770..f3a33bc631 100644 --- a/dtool/src/interrogate/parameterRemapEnumToInt.h +++ b/dtool/src/interrogate/parameterRemapEnumToInt.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapEnumToInt.h -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapEnumToInt.h + * @author drose + * @date 2000-08-04 + */ #ifndef PARAMETERREMAPENUMTOINT_H #define PARAMETERREMAPENUMTOINT_H @@ -19,11 +18,10 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapEnumToInt -// Description : A ParameterRemap class that handles remapping an -// enumerated type to an integer parameter. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping an enumerated type to an + * integer parameter. + */ class ParameterRemapEnumToInt : public ParameterRemap { public: ParameterRemapEnumToInt(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapHandleToInt.cxx b/dtool/src/interrogate/parameterRemapHandleToInt.cxx index 82220c1b75..b22052c7c3 100644 --- a/dtool/src/interrogate/parameterRemapHandleToInt.cxx +++ b/dtool/src/interrogate/parameterRemapHandleToInt.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapHandleToInt.cxx -// Created by: rdb (08Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapHandleToInt.cxx + * @author rdb + * @date 2015-09-08 + */ #include "parameterRemapHandleToInt.h" #include "interrogate.h" @@ -22,11 +21,9 @@ #include "cppConstType.h" #include "cppPointerType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapHandleToInt::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapHandleToInt:: ParameterRemapHandleToInt(CPPType *orig_type) : ParameterRemap(orig_type) @@ -34,13 +31,10 @@ ParameterRemapHandleToInt(CPPType *orig_type) : _new_type = TypeManager::get_int_type(); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapHandleToInt::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapHandleToInt:: pass_parameter(ostream &out, const string &variable_name) { CPPType *unwrapped = TypeManager::unwrap_const(_orig_type); @@ -52,13 +46,10 @@ pass_parameter(ostream &out, const string &variable_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapHandleToInt::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapHandleToInt:: get_return_expr(const string &expression) { return "(" + expression + ").get_index()"; diff --git a/dtool/src/interrogate/parameterRemapHandleToInt.h b/dtool/src/interrogate/parameterRemapHandleToInt.h index 4a2915d279..840a768180 100644 --- a/dtool/src/interrogate/parameterRemapHandleToInt.h +++ b/dtool/src/interrogate/parameterRemapHandleToInt.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapHandleToInt.h -// Created by: rdb (08Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapHandleToInt.h + * @author rdb + * @date 2015-09-08 + */ #ifndef PARAMETERREMAPHANDLETOINT_H #define PARAMETERREMAPHANDLETOINT_H @@ -19,16 +18,14 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapHandleToInt -// Description : A ParameterRemap class that handles remapping a -// Handle parameter to an integer. This makes it -// easier to set up a dynamic typing system on the -// scripting language side. -// -// It also applies to ButtonHandle or any other class -// with the same semantics, because why not. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a Handle parameter to an + * integer. This makes it easier to set up a dynamic typing system on the + * scripting language side. + * + * It also applies to ButtonHandle or any other class with the same semantics, + * because why not. + */ class ParameterRemapHandleToInt : public ParameterRemap { public: ParameterRemapHandleToInt(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.cxx b/dtool/src/interrogate/parameterRemapPTToPointer.cxx index bec363a33c..44f6a0d036 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapPTToPointer.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapPTToPointer.cxx -// Created by: drose (10Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapPTToPointer.cxx + * @author drose + * @date 2000-08-10 + */ #include "parameterRemapPTToPointer.h" #include "interrogate.h" @@ -22,11 +21,9 @@ #include "cppDeclaration.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapPTToPointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapPTToPointer:: ParameterRemapPTToPointer(CPPType *orig_type) : ParameterRemap(orig_type) @@ -34,10 +31,9 @@ ParameterRemapPTToPointer(CPPType *orig_type) : CPPStructType *pt_type = TypeManager::unwrap(_orig_type)->as_struct_type(); assert(pt_type != (CPPStructType *)NULL); - // A horrible hack around a CPPParser bug. We don't trust the - // CPPStructType pointer we were given; instead, we ask CPPParser to - // parse a new type of the same name. This has a better chance of - // fully resolving templates. + // A horrible hack around a CPPParser bug. We don't trust the CPPStructType + // pointer we were given; instead, we ask CPPParser to parse a new type of + // the same name. This has a better chance of fully resolving templates. string name = pt_type->get_local_name(&parser); CPPType *new_type = parser.parse_type(name); if (new_type == (CPPType *)NULL) { @@ -58,48 +54,37 @@ ParameterRemapPTToPointer(CPPType *orig_type) : _new_type = _pointer_type; - // We must use an actual PointerTo to hold any temporary values, - // until we can safely ref it. + // We must use an actual PointerTo to hold any temporary values, until we + // can safely ref it. _temporary_type = pt_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapPTToPointer::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapPTToPointer:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapPTToPointer::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapPTToPointer:: get_return_expr(const string &expression) { return expression; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapPTToPointer::temporary_to_return -// Access: Public, Virtual -// Description: Returns the string that converts the expression -// stored in the indicated temporary variable to the -// appropriate return value type. This is normally a -// pass-through, but in cases when the temporary -// variable type must be different than the return type -// (i.e. get_temporary_type() != get_new_type()), this -// might perform some operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that converts the expression stored in the indicated + * temporary variable to the appropriate return value type. This is normally + * a pass-through, but in cases when the temporary variable type must be + * different than the return type (i.e. get_temporary_type() != + * get_new_type()), this might perform some operation. + */ string ParameterRemapPTToPointer:: temporary_to_return(const string &temporary) { return temporary + ".p()"; } - diff --git a/dtool/src/interrogate/parameterRemapPTToPointer.h b/dtool/src/interrogate/parameterRemapPTToPointer.h index 40f76b6cd3..e92bd5b5e8 100644 --- a/dtool/src/interrogate/parameterRemapPTToPointer.h +++ b/dtool/src/interrogate/parameterRemapPTToPointer.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapPTToPointer.h -// Created by: drose (10Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapPTToPointer.h + * @author drose + * @date 2000-08-10 + */ #ifndef PARAMETERREMAPPTTOPOINTER_H #define PARAMETERREMAPPTTOPOINTER_H @@ -22,11 +21,10 @@ class CPPType; class CPPStructType; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapPTToPointer -// Description : A ParameterRemap class that handles remapping a -// PT(Type) or PointerTo to a Type *. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a PT(Type) or PointerTo + * to a Type *. + */ class ParameterRemapPTToPointer : public ParameterRemap { public: ParameterRemapPTToPointer(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx index 52fb3647e2..c4a4e77451 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToConcrete.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapReferenceToConcrete.cxx -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapReferenceToConcrete.cxx + * @author drose + * @date 2000-08-04 + */ #include "parameterRemapReferenceToConcrete.h" #include "typeManager.h" @@ -21,11 +20,9 @@ #include "cppPointerType.h" #include "cppReferenceType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToConcrete::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapReferenceToConcrete:: ParameterRemapReferenceToConcrete(CPPType *orig_type) : ParameterRemap(orig_type) @@ -33,27 +30,20 @@ ParameterRemapReferenceToConcrete(CPPType *orig_type) : _new_type = TypeManager::unwrap_const_reference(orig_type); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToConcrete::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapReferenceToConcrete:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToConcrete::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapReferenceToConcrete:: get_return_expr(const string &expression) { return expression; } - diff --git a/dtool/src/interrogate/parameterRemapReferenceToConcrete.h b/dtool/src/interrogate/parameterRemapReferenceToConcrete.h index d1426cd256..47ac919a39 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToConcrete.h +++ b/dtool/src/interrogate/parameterRemapReferenceToConcrete.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapReferenceToConcrete.h -// Created by: drose (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapReferenceToConcrete.h + * @author drose + * @date 2000-08-04 + */ #ifndef PARAMETERREMAPREFERENCETOCONCRETE_H #define PARAMETERREMAPREFERENCETOCONCRETE_H @@ -19,13 +18,11 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapReferenceToConcrete -// Description : A ParameterRemap class that handles remapping a -// const reference parameter to a concrete. This only -// makes sense when we're talking about a const -// reference to a simple type. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a const reference parameter + * to a concrete. This only makes sense when we're talking about a const + * reference to a simple type. + */ class ParameterRemapReferenceToConcrete : public ParameterRemap { public: ParameterRemapReferenceToConcrete(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx index ab7137e6bb..3199017eea 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapReferenceToPointer.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapReferenceToPointer.cxx + * @author drose + * @date 2000-08-01 + */ #include "parameterRemapReferenceToPointer.h" #include "typeManager.h" @@ -21,11 +20,9 @@ #include "cppPointerType.h" #include "cppReferenceType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToPointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapReferenceToPointer:: ParameterRemapReferenceToPointer(CPPType *orig_type) : ParameterRemap(orig_type) @@ -33,34 +30,28 @@ ParameterRemapReferenceToPointer(CPPType *orig_type) : _new_type = TypeManager::wrap_pointer(TypeManager::unwrap_reference(orig_type)); } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToPointer::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapReferenceToPointer:: pass_parameter(ostream &out, const string &variable_name) { if (variable_name.size() > 1 && variable_name[0] == '&') { - // Prevent generating something like *¶m - // Also, if this is really some local type, we can presumably just - // move it? This is only relevant if this parameter is an rvalue - // reference, but CPPParser can't know that, and it might have an overload - // that takes an rvalue reference. It shouldn't hurt either way. + // Prevent generating something like *¶m Also, if this is really some + // local type, we can presumably just move it? This is only relevant if + // this parameter is an rvalue reference, but CPPParser can't know that, + // and it might have an overload that takes an rvalue reference. It + // shouldn't hurt either way. out << "MOVE(" << variable_name.substr(1) << ")"; } else { out << "*" << variable_name; } } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapReferenceToPointer::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapReferenceToPointer:: get_return_expr(const string &expression) { return "&(" + expression + ")"; diff --git a/dtool/src/interrogate/parameterRemapReferenceToPointer.h b/dtool/src/interrogate/parameterRemapReferenceToPointer.h index dade07bc36..3e6d4bd87d 100644 --- a/dtool/src/interrogate/parameterRemapReferenceToPointer.h +++ b/dtool/src/interrogate/parameterRemapReferenceToPointer.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapReferenceToPointer.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapReferenceToPointer.h + * @author drose + * @date 2000-08-01 + */ #ifndef PARAMETERREMAPREFERENCETOPOINTER_H #define PARAMETERREMAPREFERENCETOPOINTER_H @@ -19,12 +18,10 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapReferenceToPointer -// Description : A ParameterRemap class that handles remapping a -// reference (or a const reference) parameter to a -// pointer (or const pointer) parameter. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that handles remapping a reference (or a const + * reference) parameter to a pointer (or const pointer) parameter. + */ class ParameterRemapReferenceToPointer : public ParameterRemap { public: ParameterRemapReferenceToPointer(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapThis.cxx b/dtool/src/interrogate/parameterRemapThis.cxx index 220f01ab44..e0ef867931 100644 --- a/dtool/src/interrogate/parameterRemapThis.cxx +++ b/dtool/src/interrogate/parameterRemapThis.cxx @@ -1,16 +1,15 @@ -// Filename: parameterRemapThis.cxx -// Created by: drose (02Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapThis.cxx + * @author drose + * @date 2000-08-02 + */ #include "parameterRemapThis.h" #include "typeManager.h" @@ -20,11 +19,9 @@ #include "cppPointerType.h" #include "cppConstType.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapThis::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapThis:: ParameterRemapThis(CPPType *type, bool is_const) : ParameterRemap(TypeManager::get_void_type()) @@ -37,35 +34,27 @@ ParameterRemapThis(CPPType *type, bool is_const) : _orig_type = _new_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapThis::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the new type to the original type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the new + * type to the original type, for passing into the actual C++ function. + */ void ParameterRemapThis:: pass_parameter(ostream &out, const string &variable_name) { out << "(*" << variable_name << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapThis::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapThis:: get_return_expr(const string &) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapThis::is_this -// Access: Public, Virtual -// Description: Returns true if this is the "this" parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is the "this" parameter. + */ bool ParameterRemapThis:: is_this() { return true; diff --git a/dtool/src/interrogate/parameterRemapThis.h b/dtool/src/interrogate/parameterRemapThis.h index 3421f44cf2..31204684b1 100644 --- a/dtool/src/interrogate/parameterRemapThis.h +++ b/dtool/src/interrogate/parameterRemapThis.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapThis.h -// Created by: drose (02Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapThis.h + * @author drose + * @date 2000-08-02 + */ #ifndef PARAMETERREMAPTHIS_H #define PARAMETERREMAPTHIS_H @@ -21,11 +20,9 @@ class CPPType; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapThis -// Description : A ParameterRemap class that represents a generated -// "this" parameter. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that represents a generated "this" parameter. + */ class ParameterRemapThis : public ParameterRemap { public: ParameterRemapThis(CPPType *type, bool is_const); diff --git a/dtool/src/interrogate/parameterRemapToString.cxx b/dtool/src/interrogate/parameterRemapToString.cxx index fd41c9bbe3..fe7c7a8253 100644 --- a/dtool/src/interrogate/parameterRemapToString.cxx +++ b/dtool/src/interrogate/parameterRemapToString.cxx @@ -1,26 +1,23 @@ -// Filename: parameterRemapToString.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapToString.cxx + * @author drose + * @date 2000-08-01 + */ #include "parameterRemapToString.h" #include "interrogate.h" #include "typeManager.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapToString:: ParameterRemapToString(CPPType *orig_type) : ParameterRemap(orig_type) @@ -42,49 +39,38 @@ ParameterRemapToString(CPPType *orig_type) : } } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapToString:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapToString:: get_return_expr(const string &expression) { return expression; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToString::new_type_is_atomic_string -// Access: Public, Virtual -// Description: Returns true if the type represented by the -// conversion is now the atomic string type. We have to -// have this crazy method for representing atomic -// string, because there's no such type in C (and hence -// no corresponding CPPType *). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type represented by the conversion is now the atomic + * string type. We have to have this crazy method for representing atomic + * string, because there's no such type in C (and hence no corresponding + * CPPType *). + */ bool ParameterRemapToString:: new_type_is_atomic_string() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToWString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapToWString:: ParameterRemapToWString(CPPType *orig_type) : ParameterRemap(orig_type) @@ -97,39 +83,30 @@ ParameterRemapToWString(CPPType *orig_type) : _new_type = char_star_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToWString::pass_parameter -// Access: Public, Virtual -// Description: Outputs an expression that converts the indicated -// variable from the original type to the new type, for -// passing into the actual C++ function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs an expression that converts the indicated variable from the + * original type to the new type, for passing into the actual C++ function. + */ void ParameterRemapToWString:: pass_parameter(ostream &out, const string &variable_name) { out << variable_name; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToWString::get_return_expr -// Access: Public, Virtual -// Description: Returns an expression that evalutes to the -// appropriate value type for returning from the -// function, given an expression of the original type. -//////////////////////////////////////////////////////////////////// +/** + * Returns an expression that evalutes to the appropriate value type for + * returning from the function, given an expression of the original type. + */ string ParameterRemapToWString:: get_return_expr(const string &expression) { return expression; } -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapToWString::new_type_is_atomic_string -// Access: Public, Virtual -// Description: Returns true if the type represented by the -// conversion is now the atomic string type. We have to -// have this crazy method for representing atomic -// string, because there's no such type in C (and hence -// no corresponding CPPType *). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type represented by the conversion is now the atomic + * string type. We have to have this crazy method for representing atomic + * string, because there's no such type in C (and hence no corresponding + * CPPType *). + */ bool ParameterRemapToWString:: new_type_is_atomic_string() { return true; diff --git a/dtool/src/interrogate/parameterRemapToString.h b/dtool/src/interrogate/parameterRemapToString.h index a375f3e2eb..b41369f9c0 100644 --- a/dtool/src/interrogate/parameterRemapToString.h +++ b/dtool/src/interrogate/parameterRemapToString.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapToString.h -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapToString.h + * @author drose + * @date 2000-08-09 + */ #ifndef PARAMETERREMAPTOSTRING_H #define PARAMETERREMAPTOSTRING_H @@ -19,16 +18,14 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapToString -// Description : A base class for several different remapping types -// that convert to an atomic string class. -// -// The atomic string class is represented in the C -// interface as a (const char *). Other interfaces may -// be able to represent it differently, subverting the -// code defined here. -//////////////////////////////////////////////////////////////////// +/** + * A base class for several different remapping types that convert to an + * atomic string class. + * + * The atomic string class is represented in the C interface as a (const char + * *). Other interfaces may be able to represent it differently, subverting + * the code defined here. + */ class ParameterRemapToString : public ParameterRemap { public: ParameterRemapToString(CPPType *orig_type); @@ -39,16 +36,14 @@ public: virtual bool new_type_is_atomic_string(); }; -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapToWString -// Description : A base class for several different remapping types -// that convert to an atomic string class. -// -// The atomic string class is represented in the C -// interface as a (const wchar_t *). Other interfaces -// may be able to represent it differently, subverting -// the code defined here. -//////////////////////////////////////////////////////////////////// +/** + * A base class for several different remapping types that convert to an + * atomic string class. + * + * The atomic string class is represented in the C interface as a (const + * wchar_t *). Other interfaces may be able to represent it differently, + * subverting the code defined here. + */ class ParameterRemapToWString : public ParameterRemap { public: ParameterRemapToWString(CPPType *orig_type); diff --git a/dtool/src/interrogate/parameterRemapUnchanged.cxx b/dtool/src/interrogate/parameterRemapUnchanged.cxx index 77f1a19b1d..a39314166f 100644 --- a/dtool/src/interrogate/parameterRemapUnchanged.cxx +++ b/dtool/src/interrogate/parameterRemapUnchanged.cxx @@ -1,24 +1,21 @@ -// Filename: parameterRemapUnchanged.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapUnchanged.cxx + * @author drose + * @date 2000-08-01 + */ #include "parameterRemapUnchanged.h" -//////////////////////////////////////////////////////////////////// -// Function: ParameterRemapUnchanged::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParameterRemapUnchanged:: ParameterRemapUnchanged(CPPType *orig_type) : ParameterRemap(orig_type) diff --git a/dtool/src/interrogate/parameterRemapUnchanged.h b/dtool/src/interrogate/parameterRemapUnchanged.h index a3b594bef5..127fd908d8 100644 --- a/dtool/src/interrogate/parameterRemapUnchanged.h +++ b/dtool/src/interrogate/parameterRemapUnchanged.h @@ -1,16 +1,15 @@ -// Filename: parameterRemapUnchanged.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parameterRemapUnchanged.h + * @author drose + * @date 2000-08-01 + */ #ifndef PARAMETERREMAPUNCHANGED_H #define PARAMETERREMAPUNCHANGED_H @@ -19,11 +18,10 @@ #include "parameterRemap.h" -//////////////////////////////////////////////////////////////////// -// Class : ParameterRemapUnchanged -// Description : A ParameterRemap class that represents no change to -// the parameter: the parameter type is legal as is. -//////////////////////////////////////////////////////////////////// +/** + * A ParameterRemap class that represents no change to the parameter: the + * parameter type is legal as is. + */ class ParameterRemapUnchanged : public ParameterRemap { public: ParameterRemapUnchanged(CPPType *orig_type); diff --git a/dtool/src/interrogate/parse_file.cxx b/dtool/src/interrogate/parse_file.cxx index 938ca95731..2b32f39561 100644 --- a/dtool/src/interrogate/parse_file.cxx +++ b/dtool/src/interrogate/parse_file.cxx @@ -1,16 +1,15 @@ -// Filename: parse_file.cxx -// Created by: drose (20Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parse_file.cxx + * @author drose + * @date 1999-10-20 + */ #include "cppParser.h" #include "cppManifest.h" @@ -352,6 +351,3 @@ main(int argc, char **argv) { return (0); } - - - diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index f96cae5e6f..1fe51f8111 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -1,16 +1,15 @@ -// Filename: typeManager.cxx -// Created by: drose (14Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeManager.cxx + * @author drose + * @date 2000-08-14 + */ #include "typeManager.h" #include "interrogate.h" @@ -31,15 +30,11 @@ #include "cppTypedefType.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::resolve_type -// Access: Public, Static -// Description: A horrible hack around a CPPParser bug. We don't -// trust the CPPType pointer we were given; instead, we -// ask CPPParser to parse a new type of the same name. -// This has a better chance of fully resolving -// templates. -//////////////////////////////////////////////////////////////////// +/** + * A horrible hack around a CPPParser bug. We don't trust the CPPType pointer + * we were given; instead, we ask CPPParser to parse a new type of the same + * name. This has a better chance of fully resolving templates. + */ CPPType *TypeManager:: resolve_type(CPPType *type, CPPScope *scope) { if (scope == (CPPScope *)NULL) { @@ -69,13 +64,10 @@ resolve_type(CPPType *type, CPPScope *scope) { */ } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_assignable -// Access: Public, Static -// Description: Returns true if the indicated type is something we -// can legitimately assign a value to, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is something we can legitimately assign + * a value to, or false otherwise. + */ bool TypeManager:: is_assignable(CPPType *type) { switch (type->get_subtype()) { @@ -85,18 +77,16 @@ is_assignable(CPPType *type) { return false; case CPPDeclaration::ST_struct: - // In many cases, this is assignable, but there are some bizarre - // cases where it is not. Particularly in the event that the - // programmer has defined a private copy assignment operator for - // the class or struct. + // In many cases, this is assignable, but there are some bizarre cases + // where it is not. Particularly in the event that the programmer has + // defined a private copy assignment operator for the class or struct. - // We could try to figure out whether this has happened, but screw - // it. Concrete structure objects are not assignable, and so they - // don't get setters synthesized for them. If you want a setter, - // write it yourself. + // We could try to figure out whether this has happened, but screw it. + // Concrete structure objects are not assignable, and so they don't get + // setters synthesized for them. If you want a setter, write it yourself. - // We'll make an exception for the string types, however, since - // these are nearly an atomic type. + // We'll make an exception for the string types, however, since these are + // nearly an atomic type. if (is_basic_string_char(type) || is_basic_string_wchar(type)) { return true; } @@ -111,13 +101,10 @@ is_assignable(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_reference -// Access: Public, Static -// Description: Returns true if the indicated type is some kind of a -// reference or const reference type to something -// useful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some kind of a reference or const + * reference type to something useful, false otherwise. + */ bool TypeManager:: is_reference(CPPType *type) { switch (type->get_subtype()) { @@ -135,13 +122,10 @@ is_reference(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_ref_to_anything -// Access: Public, Static -// Description: Returns true if the indicated type is some kind of a -// reference or const reference type at all, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some kind of a reference or const + * reference type at all, false otherwise. + */ bool TypeManager:: is_ref_to_anything(CPPType *type) { switch (type->get_subtype()) { @@ -159,12 +143,10 @@ is_ref_to_anything(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_anything -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to something, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to something, false + * otherwise. + */ bool TypeManager:: is_const_ref_to_anything(CPPType *type) { switch (type->get_subtype()) { @@ -182,12 +164,10 @@ is_const_ref_to_anything(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_pointer_to_anything -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// pointer to something, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const pointer to something, false + * otherwise. + */ bool TypeManager:: is_const_pointer_to_anything(CPPType *type) { switch (type->get_subtype()) { @@ -205,12 +185,10 @@ is_const_pointer_to_anything(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_pointer_or_ref -// Access: Public, Static -// Description: Returns true if the indicated type is a non-const -// pointer or reference to something, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a non-const pointer or reference to + * something, false otherwise. + */ bool TypeManager:: is_const_pointer_or_ref(CPPType *type) { switch (type->get_subtype()) { @@ -238,12 +216,10 @@ is_const_pointer_or_ref(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_non_const_pointer_or_ref -// Access: Public, Static -// Description: Returns true if the indicated type is a non-const -// pointer or reference to something, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a non-const pointer or reference to + * something, false otherwise. + */ bool TypeManager:: is_non_const_pointer_or_ref(CPPType *type) { switch (type->get_subtype()) { @@ -271,12 +247,10 @@ is_non_const_pointer_or_ref(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is some kind of a -// pointer or const pointer type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some kind of a pointer or const + * pointer type, false otherwise. + */ bool TypeManager:: is_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -294,12 +268,10 @@ is_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const -// Access: Public, Static -// Description: Returns true if the indicated type is some kind of a -// const type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some kind of a const type, false + * otherwise. + */ bool TypeManager:: is_const(CPPType *type) { switch (type->get_subtype()) { @@ -314,12 +286,10 @@ is_const(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_struct -// Access: Public, Static -// Description: Returns true if the indicated type is a concrete -// struct, class, or union type, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a concrete struct, class, or union + * type, or false otherwise. + */ bool TypeManager:: is_struct(CPPType *type) { switch (type->get_subtype()) { @@ -338,12 +308,10 @@ is_struct(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_enum -// Access: Public, Static -// Description: Returns true if the indicated type is some kind of -// enumerated type, const or otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some kind of enumerated type, const + * or otherwise. + */ bool TypeManager:: is_enum(CPPType *type) { switch (type->get_subtype()) { @@ -361,12 +329,9 @@ is_enum(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_enum -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// enumerated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const enumerated type. + */ bool TypeManager:: is_const_enum(CPPType *type) { switch (type->get_subtype()) { @@ -381,12 +346,10 @@ is_const_enum(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_enum -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to an enumerated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to an enumerated + * type. + */ bool TypeManager:: is_const_ref_to_enum(CPPType *type) { switch (type->get_subtype()) { @@ -401,14 +364,11 @@ is_const_ref_to_enum(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_simple -// Access: Public, Static -// Description: Returns true if the indicated type is something that -// a scripting language can handle directly as a -// concrete, like an int or float, either const or -// non-const. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is something that a scripting language + * can handle directly as a concrete, like an int or float, either const or + * non-const. + */ bool TypeManager:: is_simple(CPPType *type) { switch (type->get_subtype()) { @@ -427,12 +387,10 @@ is_simple(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_simple -// Access: Public, Static -// Description: Returns true if the indicated type is a const wrapper -// around some simple type like int. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const wrapper around some simple + * type like int. + */ bool TypeManager:: is_const_simple(CPPType *type) { switch (type->get_subtype()) { @@ -447,13 +405,10 @@ is_const_simple(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_simple -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to something that a scripting language can -// handle directly as a concrete. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to something that a + * scripting language can handle directly as a concrete. + */ bool TypeManager:: is_const_ref_to_simple(CPPType *type) { switch (type->get_subtype()) { @@ -468,13 +423,10 @@ is_const_ref_to_simple(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_ref_to_simple -// Access: Public, Static -// Description: Returns true if the indicated type is a non-const -// reference to something that a scripting language can -// handle directly as a concrete. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a non-const reference to something + * that a scripting language can handle directly as a concrete. + */ bool TypeManager:: is_ref_to_simple(CPPType *type) { switch (type->get_subtype()) { @@ -489,12 +441,9 @@ is_ref_to_simple(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_simple_array -// Access: Public, Static -// Description: Returns true if the indicated type is an array of -// a simple type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is an array of a simple type. + */ bool TypeManager:: is_simple_array(CPPType *type) { switch (type->get_subtype()) { @@ -512,13 +461,11 @@ is_simple_array(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_simple -// Access: Public, Static -// Description: Returns true if the indicated type is a const or -// a non-constant pointer to a simple type. This could -// also be a reference to an array of the simple type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const or a non-constant pointer to + * a simple type. This could also be a reference to an array of the simple + * type. + */ bool TypeManager:: is_pointer_to_simple(CPPType *type) { switch (type->get_subtype()) { @@ -542,14 +489,11 @@ is_pointer_to_simple(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointable -// Access: Public, Static -// Description: Returns true if the indicated type is something -// ordinary that a scripting language can handle a -// pointer to, e.g. a class or a structure, but not an -// int or a function. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is something ordinary that a scripting + * language can handle a pointer to, e.g. a class or a structure, but not an + * int or a function. + */ bool TypeManager:: is_pointable(CPPType *type) { switch (type->get_subtype()) { @@ -562,8 +506,7 @@ is_pointable(CPPType *type) { case CPPDeclaration::ST_struct: return true; - //case CPPDeclaration::ST_simple: - // return is_char(type); + // case CPPDeclaration::ST_simple: return is_char(type); case CPPDeclaration::ST_typedef: return is_pointable(type->as_typedef_type()->_type); @@ -573,12 +516,10 @@ is_pointable(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_char -// Access: Public, Static -// Description: Returns true if the indicated type is char or const -// char, but not signed or unsigned char. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is char or const char, but not signed or + * unsigned char. + */ bool TypeManager:: is_char(CPPType *type) { switch (type->get_subtype()) { @@ -605,12 +546,10 @@ is_char(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_unsigned_char -// Access: Public, Static -// Description: Returns true if the indicated type is unsigned char, -// but not signed or 'plain' char. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is unsigned char, but not signed or + * 'plain' char. + */ bool TypeManager:: is_unsigned_char(CPPType *type) { switch (type->get_subtype()) { @@ -639,12 +578,10 @@ is_unsigned_char(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_signed_char -// Access: Public, Static -// Description: Returns true if the indicated type is signed char, -// but not unsigned or 'plain' char. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is signed char, but not unsigned or + * 'plain' char. + */ bool TypeManager:: is_signed_char(CPPType *type) { switch (type->get_subtype()) { @@ -673,12 +610,9 @@ is_signed_char(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_char_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is char * or const -// char * or some such. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is char * or const char * or some such. + */ bool TypeManager:: is_char_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -696,11 +630,9 @@ is_char_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_char_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is const char*. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is const char*. + */ bool TypeManager:: is_const_char_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -719,12 +651,10 @@ is_const_char_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_unsigned_char_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is unsigned char* -// or const unsigned char*. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is unsigned char* or const unsigned + * char*. + */ bool TypeManager:: is_unsigned_char_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -742,12 +672,9 @@ is_unsigned_char_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_unsigned_char_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is -// const unsigned char*. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is const unsigned char*. + */ bool TypeManager:: is_const_unsigned_char_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -762,12 +689,10 @@ is_const_unsigned_char_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_basic_string_char -// Access: Public, Static -// Description: Returns true if the type is basic_string. This -// is the standard C++ string class. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is basic_string. This is the standard C++ + * string class. + */ bool TypeManager:: is_basic_string_char(CPPType *type) { CPPType *string_type = get_basic_string_char_type(); @@ -790,12 +715,10 @@ is_basic_string_char(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_basic_string_char -// Access: Public, Static -// Description: Returns true if the indicated type is a const wrapper -// around basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const wrapper around + * basic_string. + */ bool TypeManager:: is_const_basic_string_char(CPPType *type) { switch (type->get_subtype()) { @@ -810,12 +733,10 @@ is_const_basic_string_char(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_basic_string_char -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to + * basic_string. + */ bool TypeManager:: is_const_ref_to_basic_string_char(CPPType *type) { switch (type->get_subtype()) { @@ -830,12 +751,10 @@ is_const_ref_to_basic_string_char(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ptr_to_basic_string_char -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// pointer to basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const pointer to + * basic_string. + */ bool TypeManager:: is_const_ptr_to_basic_string_char(CPPType *type) { switch (type->get_subtype()) { @@ -850,12 +769,9 @@ is_const_ptr_to_basic_string_char(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_string -// Access: Public, Static -// Description: Returns true if the type is basic_string, or -// a const reference to it. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is basic_string, or a const reference to it. + */ bool TypeManager:: is_string(CPPType *type) { switch (type->get_subtype()) { @@ -872,12 +788,10 @@ is_string(CPPType *type) { return is_basic_string_char(type); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_wchar -// Access: Public, Static -// Description: Returns true if the indicated type is wchar_t or const -// wchar_t. We don't mind signed or unsigned wchar_t. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is wchar_t or const wchar_t. We don't + * mind signed or unsigned wchar_t. + */ bool TypeManager:: is_wchar(CPPType *type) { switch (type->get_subtype()) { @@ -902,12 +816,10 @@ is_wchar(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_wchar_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is wchar_t * or const -// wchar_t * or some such. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is wchar_t * or const wchar_t * or some + * such. + */ bool TypeManager:: is_wchar_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -925,12 +837,10 @@ is_wchar_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_basic_string_wchar -// Access: Public, Static -// Description: Returns true if the type is basic_string. This -// is the standard C++ wide string class. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is basic_string. This is the standard + * C++ wide string class. + */ bool TypeManager:: is_basic_string_wchar(CPPType *type) { CPPType *string_type = get_basic_string_wchar_type(); @@ -953,12 +863,10 @@ is_basic_string_wchar(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_basic_string_wchar -// Access: Public, Static -// Description: Returns true if the indicated type is a const wrapper -// around basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const wrapper around + * basic_string. + */ bool TypeManager:: is_const_basic_string_wchar(CPPType *type) { switch (type->get_subtype()) { @@ -973,12 +881,10 @@ is_const_basic_string_wchar(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_basic_string_wchar -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to + * basic_string. + */ bool TypeManager:: is_const_ref_to_basic_string_wchar(CPPType *type) { switch (type->get_subtype()) { @@ -993,12 +899,10 @@ is_const_ref_to_basic_string_wchar(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ptr_to_basic_string_wchar -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// pointer to basic_string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const pointer to + * basic_string. + */ bool TypeManager:: is_const_ptr_to_basic_string_wchar(CPPType *type) { switch (type->get_subtype()) { @@ -1013,12 +917,10 @@ is_const_ptr_to_basic_string_wchar(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_wstring -// Access: Public, Static -// Description: Returns true if the type is basic_string, or -// a const reference to it. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is basic_string, or a const reference to + * it. + */ bool TypeManager:: is_wstring(CPPType *type) { switch (type->get_subtype()) { @@ -1035,12 +937,9 @@ is_wstring(CPPType *type) { return is_basic_string_wchar(type); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_bool -// Access: Public, Static -// Description: Returns true if the indicated type is bool, or some -// trivial variant. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is bool, or some trivial variant. + */ bool TypeManager:: is_bool(CPPType *type) { switch (type->get_subtype()) { @@ -1067,13 +966,10 @@ is_bool(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_integer -// Access: Public, Static -// Description: Returns true if the indicated type is one of the -// basic integer types: bool, char, short, int, or long, -// signed or unsigned, as well as enumerated types. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is one of the basic integer types: bool, + * char, short, int, or long, signed or unsigned, as well as enumerated types. + */ bool TypeManager:: is_integer(CPPType *type) { switch (type->get_subtype()) { @@ -1108,12 +1004,10 @@ is_integer(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_unsigned_integer -// Access: Public, Static -// Description: Returns true if the indicated type is one of the -// basic integer types, but only the unsigned varieties. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is one of the basic integer types, but + * only the unsigned varieties. + */ bool TypeManager:: is_unsigned_integer(CPPType *type) { switch (type->get_subtype()) { @@ -1146,12 +1040,10 @@ is_unsigned_integer(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_size -// Access: Public, Static -// Description: Returns true if the indicated type is the "size_t" -// type, or a const size_t, or a typedef to either. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "size_t" type, or a const size_t, + * or a typedef to either. + */ bool TypeManager:: is_size(CPPType *type) { switch (type->get_subtype()) { @@ -1172,15 +1064,12 @@ is_size(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_ssize -// Access: Public, Static -// Description: Returns true if the indicated type is the "ssize_t" -// type, or a const ssize_t, or a typedef to either. -// ptrdiff_t and streamsize are also accepted, since -// they are usually also defined as the signed -// counterpart to size_t. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "ssize_t" type, or a const + * ssize_t, or a typedef to either. ptrdiff_t and streamsize are also + * accepted, since they are usually also defined as the signed counterpart to + * size_t. + */ bool TypeManager:: is_ssize(CPPType *type) { switch (type->get_subtype()) { @@ -1204,12 +1093,10 @@ is_ssize(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_long -// Access: Public, Static -// Description: Returns true if the indicated type is the "long" -// type, whether signed or unsigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "long" type, whether signed or + * unsigned. + */ bool TypeManager:: is_long(CPPType *type) { switch (type->get_subtype()) { @@ -1236,12 +1123,10 @@ is_long(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_short -// Access: Public, Static -// Description: Returns true if the indicated type is the "short" -// type, whether signed or unsigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "short" type, whether signed or + * unsigned. + */ bool TypeManager:: is_short(CPPType *type) { switch (type->get_subtype()) { @@ -1268,12 +1153,9 @@ is_short(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_unsigned_short -// Access: Public, Static -// Description: Returns true if the indicated type is an unsigned -// "short" type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is an unsigned "short" type. + */ bool TypeManager:: is_unsigned_short(CPPType *type) { switch (type->get_subtype()) { @@ -1300,13 +1182,10 @@ is_unsigned_short(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_longlong -// Access: Public, Static -// Description: Returns true if the indicated type is the "long long" -// type or larger, or at least a 64-bit integer, whether -// signed or unsigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "long long" type or larger, or at + * least a 64-bit integer, whether signed or unsigned. + */ bool TypeManager:: is_longlong(CPPType *type) { switch (type->get_subtype()) { @@ -1333,13 +1212,10 @@ is_longlong(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_unsigned_longlong -// Access: Public, Static -// Description: Returns true if the indicated type is an unsigned -// "long long" type or larger, or at least a 64-bit -// unsigned integer. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is an unsigned "long long" type or + * larger, or at least a 64-bit unsigned integer. + */ bool TypeManager:: is_unsigned_longlong(CPPType *type) { switch (type->get_subtype()) { @@ -1366,12 +1242,9 @@ is_unsigned_longlong(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_double -// Access: Public, Static -// Description: Returns true if the indicated type is the "double" -// type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is the "double" type. + */ bool TypeManager:: is_double(CPPType *type) { switch (type->get_subtype()) { @@ -1397,13 +1270,10 @@ is_double(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_float -// Access: Public, Static -// Description: Returns true if the indicated type is one of the -// basic floating-point types: float, double, or some -// similar variant. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is one of the basic floating-point + * types: float, double, or some similar variant. + */ bool TypeManager:: is_float(CPPType *type) { switch (type->get_subtype()) { @@ -1431,12 +1301,9 @@ is_float(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_void -// Access: Public, Static -// Description: Returns true if the indicated type is void. (Not -// void *, just void.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is void. (Not void *, just void.) + */ bool TypeManager:: is_void(CPPType *type) { CPPSimpleType *simple_type = type->as_simple_type(); @@ -1449,12 +1316,10 @@ is_void(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_reference_count -// Access: Public, Static -// Description: Returns true if the indicated type is some class that -// derives from ReferenceCount, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some class that derives from + * ReferenceCount, or false otherwise. + */ bool TypeManager:: is_reference_count(CPPType *type) { CPPType *refcount_type = get_reference_count_type(); @@ -1491,12 +1356,10 @@ is_reference_count(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_reference_count_pointer -// Access: Public, Static -// Description: Returns true if the indicated type is a pointer to a -// class that derives from ReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a pointer to a class that derives + * from ReferenceCount. + */ bool TypeManager:: is_reference_count_pointer(CPPType *type) { switch (type->get_subtype()) { @@ -1514,21 +1377,18 @@ is_reference_count_pointer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_base -// Access: Public, Static -// Description: Returns true if the indicated type is some class that -// derives from PointerToBase, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is some class that derives from + * PointerToBase, or false otherwise. + */ bool TypeManager:: is_pointer_to_base(CPPType *type) { - // We only check the simple name of the type against PointerToBase, - // since we need to allow for the various template instantiations of - // this thing. + // We only check the simple name of the type against PointerToBase, since we + // need to allow for the various template instantiations of this thing. - // We also check explicitly for "PointerTo" and "ConstPointerTo", - // instead of actually checking for PointerToBase, because we don't - // want to consider PointerToArray in this category. + // We also check explicitly for "PointerTo" and "ConstPointerTo", instead of + // actually checking for PointerToBase, because we don't want to consider + // PointerToArray in this category. if (type->get_simple_name() == "PointerTo" || type->get_simple_name() == "ConstPointerTo") { return true; @@ -1560,12 +1420,10 @@ is_pointer_to_base(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_pointer_to_base -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// PointerToBase or some derivative. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const PointerToBase or some + * derivative. + */ bool TypeManager:: is_const_pointer_to_base(CPPType *type) { switch (type->get_subtype()) { @@ -1580,12 +1438,10 @@ is_const_pointer_to_base(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_const_ref_to_pointer_to_base -// Access: Public, Static -// Description: Returns true if the indicated type is a const -// reference to a class that derives from PointerToBase. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is a const reference to a class that + * derives from PointerToBase. + */ bool TypeManager:: is_const_ref_to_pointer_to_base(CPPType *type) { switch (type->get_subtype()) { @@ -1603,17 +1459,13 @@ is_const_ref_to_pointer_to_base(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pair -// Access: Public, Static -// Description: Returns true if the type is pair<>, or -// a reference to it. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is pair<>, or a reference to it. + */ bool TypeManager:: is_pair(CPPType *type) { - // We only check the simple name of the type against pair, - // since we need to allow for the various template instantiations of - // this thing. + // We only check the simple name of the type against pair, since we need to + // allow for the various template instantiations of this thing. if (type->get_simple_name() == "pair") { return true; } @@ -1635,11 +1487,9 @@ is_pair(CPPType *type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_PyObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyObject *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyObject *. + */ bool TypeManager:: is_pointer_to_PyObject(CPPType *type) { switch (type->get_subtype()) { @@ -1657,11 +1507,9 @@ is_pointer_to_PyObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_PyObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyObject. + */ bool TypeManager:: is_PyObject(CPPType *type) { switch (type->get_subtype()) { @@ -1686,11 +1534,9 @@ is_PyObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_PyTypeObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyTypeObject *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyTypeObject *. + */ bool TypeManager:: is_pointer_to_PyTypeObject(CPPType *type) { switch (type->get_subtype()) { @@ -1708,11 +1554,9 @@ is_pointer_to_PyTypeObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_PyTypeObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyTypeObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyTypeObject. + */ bool TypeManager:: is_PyTypeObject(CPPType *type) { switch (type->get_subtype()) { @@ -1733,11 +1577,9 @@ is_PyTypeObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_PyStringObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyStringObject *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyStringObject *. + */ bool TypeManager:: is_pointer_to_PyStringObject(CPPType *type) { switch (type->get_subtype()) { @@ -1752,11 +1594,9 @@ is_pointer_to_PyStringObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_PyStringObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyStringObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyStringObject. + */ bool TypeManager:: is_PyStringObject(CPPType *type) { switch (type->get_subtype()) { @@ -1773,11 +1613,9 @@ is_PyStringObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_PyUnicodeObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyStringObject *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyStringObject *. + */ bool TypeManager:: is_pointer_to_PyUnicodeObject(CPPType *type) { switch (type->get_subtype()) { @@ -1792,11 +1630,9 @@ is_pointer_to_PyUnicodeObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_PyUnicodeObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyUnicodeObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyUnicodeObject. + */ bool TypeManager:: is_PyUnicodeObject(CPPType *type) { switch (type->get_subtype()) { @@ -1813,11 +1649,9 @@ is_PyUnicodeObject(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_Py_buffer -// Access: Public, Static -// Description: Returns true if the indicated type is Py_buffer *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is Py_buffer *. + */ bool TypeManager:: is_pointer_to_Py_buffer(CPPType *type) { switch (type->get_subtype()) { @@ -1835,11 +1669,9 @@ is_pointer_to_Py_buffer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_Py_buffer -// Access: Public, Static -// Description: Returns true if the indicated type is Py_buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is Py_buffer. + */ bool TypeManager:: is_Py_buffer(CPPType *type) { switch (type->get_subtype()) { @@ -1858,12 +1690,10 @@ is_Py_buffer(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_handle -// Access: Public, Static -// Description: Returns true if the indicated type is TypeHandle -// or a class with identical semantics like ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is TypeHandle or a class with identical + * semantics like ButtonHandle. + */ bool TypeManager:: is_handle(CPPType *type) { switch (type->get_subtype()) { @@ -1883,11 +1713,9 @@ is_handle(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_ostream -// Access: Public, Static -// Description: Returns true if the indicated type is PyObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyObject. + */ bool TypeManager::is_ostream(CPPType *type) { switch (type->get_subtype()) { case CPPDeclaration::ST_const: @@ -1904,11 +1732,9 @@ bool TypeManager::is_ostream(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_pointer_to_PyObject -// Access: Public, Static -// Description: Returns true if the indicated type is PyObject *. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated type is PyObject *. + */ bool TypeManager:: is_pointer_to_ostream(CPPType *type) { switch (type->get_subtype()) { @@ -1929,16 +1755,13 @@ is_pointer_to_ostream(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::involves_unpublished -// Access: Public, Static -// Description: Returns true if the type is an unpublished type, -// e.g. a protected or private nested class, or simply a -// type not marked as 'published', or if the type is a -// pointer or reference to such an unpublished type, or -// even if the type is a function type that includes a -// parameter of such an unpublished type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is an unpublished type, e.g. a protected or + * private nested class, or simply a type not marked as 'published', or if the + * type is a pointer or reference to such an unpublished type, or even if the + * type is a function type that includes a parameter of such an unpublished + * type. + */ bool TypeManager:: involves_unpublished(CPPType *type) { switch (type->get_subtype()) { @@ -2011,15 +1834,12 @@ involves_unpublished(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::involves_protected -// Access: Public, Static -// Description: Returns true if the type is an protected type, -// e.g. a protected or private nested class, or if the -// type is a pointer or reference to such a protected -// type, or even if the type is a function type that -// includes a parameter of such a protected type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is an protected type, e.g. a protected or private + * nested class, or if the type is a pointer or reference to such a protected + * type, or even if the type is a function type that includes a parameter of + * such a protected type. + */ bool TypeManager:: involves_protected(CPPType *type) { switch (type->get_subtype()) { @@ -2060,11 +1880,9 @@ involves_protected(CPPType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::unwrap_pointer -// Access: Public, Static -// Description: Returns the type this pointer type points to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type this pointer type points to. + */ CPPType *TypeManager:: unwrap_pointer(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2079,11 +1897,9 @@ unwrap_pointer(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::unwrap_reference -// Access: Public, Static -// Description: Returns the type this reference type points to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type this reference type points to. + */ CPPType *TypeManager:: unwrap_reference(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2098,12 +1914,9 @@ unwrap_reference(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::unwrap_const -// Access: Public, Static -// Description: Removes the const declaration from the outside of the -// type. -//////////////////////////////////////////////////////////////////// +/** + * Removes the const declaration from the outside of the type. + */ CPPType *TypeManager:: unwrap_const(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2115,12 +1928,9 @@ unwrap_const(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::unwrap_const_reference -// Access: Public, Static -// Description: Removes a reference or a const reference from the -// type. -//////////////////////////////////////////////////////////////////// +/** + * Removes a reference or a const reference from the type. + */ CPPType *TypeManager:: unwrap_const_reference(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2135,12 +1945,10 @@ unwrap_const_reference(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::unwrap -// Access: Public, Static -// Description: Removes all const, pointer, reference wrappers, and -// typedefs, to get to the thing we're talking about. -//////////////////////////////////////////////////////////////////// +/** + * Removes all const, pointer, reference wrappers, and typedefs, to get to the + * thing we're talking about. + */ CPPType *TypeManager:: unwrap(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2161,14 +1969,11 @@ unwrap(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_pointer_type -// Access: Public, Static -// Description: Returns the type of pointer the given PointerTo class -// emulates. Essentially this just checks the return -// type of the method called 'p()'. Returns NULL if the -// PointerTo class has no method p(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of pointer the given PointerTo class emulates. + * Essentially this just checks the return type of the method called 'p()'. + * Returns NULL if the PointerTo class has no method p(). + */ CPPType *TypeManager:: get_pointer_type(CPPStructType *pt_type) { CPPScope *scope = pt_type->_scope; @@ -2178,8 +1983,8 @@ get_pointer_type(CPPStructType *pt_type) { if (fi != scope->_functions.end()) { CPPFunctionGroup *fgroup = (*fi).second; - // These are all the functions named "p". Now look for one that - // takes no parameters. + // These are all the functions named "p". Now look for one that takes no + // parameters. CPPFunctionGroup::Instances::iterator ii; for (ii = fgroup->_instances.begin(); ii != fgroup->_instances.end(); @@ -2197,14 +2002,11 @@ get_pointer_type(CPPStructType *pt_type) { return (CPPType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_template_parameter_type -// Access: Public, Static -// Description: Returns the ith template parameter type. For -// instance, if the type is pair, then this -// function will return type A when passing 0 and -// type B when passing 1, and NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith template parameter type. For instance, if the type is + * pair, then this function will return type A when passing 0 and type B + * when passing 1, and NULL otherwise. + */ CPPType *TypeManager:: get_template_parameter_type(CPPType *source_type, int i) { switch (source_type->get_subtype()) { @@ -2226,8 +2028,8 @@ get_template_parameter_type(CPPType *source_type, int i) { return NULL; } - // I'm not sure how reliable this is, but I don't know if there - // is a more proper way to access this. + // I'm not sure how reliable this is, but I don't know if there is a more + // proper way to access this. CPPTemplateParameterList *templ = type->_ident->_names.back().get_templ(); if (templ == NULL || i >= (int)templ->_parameters.size()) { return NULL; @@ -2237,23 +2039,17 @@ get_template_parameter_type(CPPType *source_type, int i) { return decl->as_type(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::wrap_pointer -// Access: Public, Static -// Description: Returns the type corresponding to a pointer to the -// given type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type corresponding to a pointer to the given type. + */ CPPType *TypeManager:: wrap_pointer(CPPType *source_type) { return CPPType::new_type(new CPPPointerType(source_type)); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::wrap_const_pointer -// Access: Public, Static -// Description: Returns the type corresponding to a const pointer -// to the given type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type corresponding to a const pointer to the given type. + */ CPPType *TypeManager:: wrap_const_pointer(CPPType *source_type) { if (source_type->as_const_type() != (CPPConstType *)NULL) { @@ -2266,12 +2062,9 @@ wrap_const_pointer(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::wrap_const_reference -// Access: Public, Static -// Description: Returns the type corresponding to a const reference -// to the given type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type corresponding to a const reference to the given type. + */ CPPType *TypeManager:: wrap_const_reference(CPPType *source_type) { if (source_type->as_const_type() != (CPPConstType *)NULL) { @@ -2284,12 +2077,10 @@ wrap_const_reference(CPPType *source_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_basic_string_char_type -// Access: Public, Static -// Description: Returns a CPPType that represents basic_string, -// or NULL if the type is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns a CPPType that represents basic_string, or NULL if the type + * is unknown. + */ CPPType *TypeManager:: get_basic_string_char_type() { static bool got_type = false; @@ -2301,12 +2092,10 @@ get_basic_string_char_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_basic_string_wchar_type -// Access: Public, Static -// Description: Returns a CPPType that represents basic_string, -// or NULL if the type is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns a CPPType that represents basic_string, or NULL if the + * type is unknown. + */ CPPType *TypeManager:: get_basic_string_wchar_type() { static bool got_type = false; @@ -2318,12 +2107,10 @@ get_basic_string_wchar_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_reference_count_type -// Access: Public, Static -// Description: Returns a CPPType that represents ReferenceCount, -// or NULL if the type is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns a CPPType that represents ReferenceCount, or NULL if the type is + * unknown. + */ CPPType *TypeManager:: get_reference_count_type() { static bool got_type = false; @@ -2335,11 +2122,9 @@ get_reference_count_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_void_type -// Access: Public, Static -// Description: Returns a CPPType that represents void. -//////////////////////////////////////////////////////////////////// +/** + * Returns a CPPType that represents void. + */ CPPType *TypeManager:: get_void_type() { static bool got_type = false; @@ -2351,11 +2136,9 @@ get_void_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_int_type -// Access: Public, Static -// Description: Returns a CPPType that represents int. -//////////////////////////////////////////////////////////////////// +/** + * Returns a CPPType that represents int. + */ CPPType *TypeManager:: get_int_type() { static bool got_type = false; @@ -2367,20 +2150,16 @@ get_int_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_function_signature -// Access: Public, Static -// Description: Returns a string corresponding to the given function -// signature. This is a unique string per each -// uniquely-callable C++ function or method. Basically -// it's the function prototype, sans the return type. -// -// If num_default_parameters is nonzero, it is the -// number of parameters to omit from the end of the -// parameter list. This in effect gets the function -// signature for an equivalent function with n -// parameters assuming default values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string corresponding to the given function signature. This is a + * unique string per each uniquely-callable C++ function or method. Basically + * it's the function prototype, sans the return type. + * + * If num_default_parameters is nonzero, it is the number of parameters to + * omit from the end of the parameter list. This in effect gets the function + * signature for an equivalent function with n parameters assuming default + * values. + */ string TypeManager:: get_function_signature(CPPInstance *function, int num_default_parameters) { @@ -2389,12 +2168,12 @@ get_function_signature(CPPInstance *function, ostringstream out; - // It's tempting to mark static methods with a different function - // signature than non-static, because a static method doesn't have - // an implicit 'this' parameter. However, this breaks the lookup - // when we come across a method definition outside of the class - // body; since there's no clue at this point whether the method is - // static or not, we can't successfully look it up. Bummer. + // It's tempting to mark static methods with a different function signature + // than non-static, because a static method doesn't have an implicit 'this' + // parameter. However, this breaks the lookup when we come across a method + // definition outside of the class body; since there's no clue at this point + // whether the method is static or not, we can't successfully look it up. + // Bummer. /* if ((function->_storage_class & CPPInstance::SC_static) != 0) { out << "static "; @@ -2413,9 +2192,9 @@ get_function_signature(CPPInstance *function, assert(pi != params.end()); CPPType *ptype = (*pi)->_type; - // One exception: if the type is a const reference to something, - // we build the signature with its corresponding concrete. C++ - // can't differentiate these two anyway. + // One exception: if the type is a const reference to something, we build + // the signature with its corresponding concrete. C++ can't differentiate + // these two anyway. if (is_const_ref_to_anything(ptype)) { ptype = unwrap_const_reference(ptype); } @@ -2437,27 +2216,20 @@ get_function_signature(CPPInstance *function, return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::get_function_name -// Access: Public, Static -// Description: Returns a string corresponding to the given function -// name. This is not necessarily unique to the -// particular overloaded function instance, but is -// common among all overloaded functions of the same -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string corresponding to the given function name. This is not + * necessarily unique to the particular overloaded function instance, but is + * common among all overloaded functions of the same name. + */ string TypeManager:: get_function_name(CPPInstance *function) { return function->get_local_name(&parser); } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::has_protected_destructor -// Access: Public, Static -// Description: Returns true if the destructor for the given class or -// struct is protected or private, or false if the -// destructor is public or absent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the destructor for the given class or struct is protected + * or private, or false if the destructor is public or absent. + */ bool TypeManager:: has_protected_destructor(CPPType *type) { CPPStructType *struct_type = type->as_struct_type(); @@ -2490,11 +2262,9 @@ has_protected_destructor(CPPType *type) { // No explicit destructor. return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_exported -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TypeManager:: is_exported(CPPType *in_type) { string name = in_type->get_local_name(&parser); @@ -2504,10 +2274,8 @@ is_exported(CPPType *in_type) { // this question is about the base type CPPType *base_type = resolve_type(unwrap(in_type)); - //CPPType *base_type = in_type; - // Ok export Rules.. - // Classes and Structs and Unions are exported only if they have a - // function that is exported.. + // CPPType *base_type = in_type; Ok export Rules.. Classes and Structs and + // Unions are exported only if they have a function that is exported.. // function is the easiest case. if (base_type->_vis <= min_vis) { @@ -2555,11 +2323,12 @@ is_exported(CPPType *in_type) { CPPType *type = base_type->as_type_declaration()->_type; if (type->get_subtype() == CPPDeclaration::ST_struct) { CPPStructType *struct_type =type->as_type()->resolve_type(&parser, &parser)->as_struct_type(); - //CPPScope *scope = struct_type->_scope; + // CPPScope *scope = struct_type->_scope; return is_exported(struct_type); } else if (type->get_subtype() == CPPDeclaration::ST_enum) { - //CPPEnumType *enum_type = type->as_type()->resolve_type(&parser, &parser)->as_enum_type(); + // CPPEnumType *enum_type = type->as_type()->resolve_type(&parser, + // &parser)->as_enum_type(); if (type->_vis <= min_vis) { return true; } @@ -2576,12 +2345,10 @@ is_exported(CPPType *in_type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_local -// Access: Public, Static -// Description: Returns true if the type is defined in a local -// file rather than one that is included. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is defined in a local file rather than one that is + * included. + */ bool TypeManager:: is_local(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2669,12 +2436,9 @@ is_local(CPPType *source_type) { */ } -//////////////////////////////////////////////////////////////////// -// Function: TypeManager::is_trivial -// Access: Public, Static -// Description: Returns true if the type is trivial (or trivial -// enough for our purposes). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is trivial (or trivial enough for our purposes). + */ bool TypeManager:: is_trivial(CPPType *source_type) { switch (source_type->get_subtype()) { @@ -2698,9 +2462,9 @@ is_trivial(CPPType *source_type) { return true; } else { // This is a bit of a hack. is_trivial() returns false for types that - // have an empty constructor (since we can't use =default yet). - // For the other classes, it's just convenient to consider them trivial - // even if they aren't, since they are simple enough. + // have an empty constructor (since we can't use =default yet). For the + // other classes, it's just convenient to consider them trivial even if + // they aren't, since they are simple enough. string name = source_type->get_simple_name(); return (name == "ButtonHandle" || name == "DatagramIterator" || name == "BitMask" || name == "Filename" || name == "pixel" || diff --git a/dtool/src/interrogate/typeManager.h b/dtool/src/interrogate/typeManager.h index 99315383a6..5c5ed18190 100644 --- a/dtool/src/interrogate/typeManager.h +++ b/dtool/src/interrogate/typeManager.h @@ -1,16 +1,15 @@ -// Filename: typeManager.h -// Created by: drose (14Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeManager.h + * @author drose + * @date 2000-08-14 + */ #ifndef TYPEMANAGER_H #define TYPEMANAGER_H @@ -32,13 +31,11 @@ class CPPIdentifier; class CPPNameComponent; class CPPManifest; -//////////////////////////////////////////////////////////////////// -// Class : TypeManager -// Description : This is just a collection of static methods that -// perform useful operations on CPPTypes for -// interrogate. The class is really just a namespace -// that groups these functions together. -//////////////////////////////////////////////////////////////////// +/** + * This is just a collection of static methods that perform useful operations + * on CPPTypes for interrogate. The class is really just a namespace that + * groups these functions together. + */ class TypeManager { public: @@ -153,4 +150,3 @@ public: }; #endif - diff --git a/dtool/src/interrogatedb/config_interrogatedb.cxx b/dtool/src/interrogatedb/config_interrogatedb.cxx index ff6f4a6493..4971443cc1 100644 --- a/dtool/src/interrogatedb/config_interrogatedb.cxx +++ b/dtool/src/interrogatedb/config_interrogatedb.cxx @@ -1,16 +1,15 @@ -// Filename: config_interrogatedb.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_interrogatedb.cxx + * @author drose + * @date 2000-08-01 + */ #include "config_interrogatedb.h" #include "interrogate_request.h" @@ -28,7 +27,7 @@ Configure(config_interrogatedb); NotifyCategoryDef(interrogatedb, ""); ConfigureFn(config_interrogatedb) { - // interrogate_request_library("types"); + // interrogate_request_library("types"); #ifdef USE_WIN32_DBGHEAP ConfigVariableBool use_win32_dbgheap("use-win32-dbgheap", false); @@ -37,26 +36,25 @@ ConfigureFn(config_interrogatedb) { int dbg_flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); if (use_win32_dbgheap.get_string_value() == "full") { - // "full" means check the heap after *every* alloc/dealloc. - // Expensive. + // "full" means check the heap after *every* allocdealloc. Expensive. dbg_flags |= (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF); } else { - // Otherwise, it's a bool flag. true means check the heap - // normally, false means don't do any debug checking. + // Otherwise, it's a bool flag. true means check the heap normally, false + // means don't do any debug checking. if (!use_win32_dbgheap) { - // deflt disable complete heap verify every 1024 allocations (VC7 deflt). - // With vc7 stl small-string-optimization causing more allocs, + // deflt disable complete heap verify every 1024 allocations (VC7 + // deflt). With vc7 stl small-string-optimization causing more allocs, // this can cause order-of-magnitude slowdowns in dbg builds dbg_flags = 0; } } if (win32_report_leaks) { - // Report memory still allocated at program termination. Not sure - // how useful this is, as many things get allocated once and never - // freed, but they aren't really leaks. + // Report memory still allocated at program termination. Not sure how + // useful this is, as many things get allocated once and never freed, but + // they aren't really leaks. dbg_flags |= _CRTDBG_LEAK_CHECK_DF; } @@ -66,4 +64,3 @@ ConfigureFn(config_interrogatedb) { ConfigVariableSearchPath interrogatedb_path ("interrogatedb-path", "The search path for interrogate's *.in files."); - diff --git a/dtool/src/interrogatedb/config_interrogatedb.h b/dtool/src/interrogatedb/config_interrogatedb.h index 6dd0995532..1a99702d0e 100644 --- a/dtool/src/interrogatedb/config_interrogatedb.h +++ b/dtool/src/interrogatedb/config_interrogatedb.h @@ -1,16 +1,15 @@ -// Filename: config_interrogatedb.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_interrogatedb.h + * @author drose + * @date 2000-08-01 + */ #ifndef CONFIG_INTERROGATEDB_H #define CONFIG_INTERROGATEDB_H diff --git a/dtool/src/interrogatedb/dtool_super_base.cxx b/dtool/src/interrogatedb/dtool_super_base.cxx index 5b7dc0f105..26b57a157d 100644 --- a/dtool/src/interrogatedb/dtool_super_base.cxx +++ b/dtool/src/interrogatedb/dtool_super_base.cxx @@ -1,16 +1,15 @@ -// Filename: dtool_super_base.cxx -// Created by: drose (04Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dtool_super_base.cxx + * @author drose + * @date 2005-07-04 + */ #include "py_panda.h" diff --git a/dtool/src/interrogatedb/extension.h b/dtool/src/interrogatedb/extension.h index b8aa8b8183..878c997f86 100644 --- a/dtool/src/interrogatedb/extension.h +++ b/dtool/src/interrogatedb/extension.h @@ -1,51 +1,44 @@ -// Filename: extension.h -// Created by: rdb (11Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file extension.h + * @author rdb + * @date 2013-09-11 + */ #ifndef EXTENSION_H #define EXTENSION_H #include "dtoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : ExtensionBase -// Description : This is where all extensions should derive from. -// It defines the _self and _this members that can -// be used from the extension method. -//////////////////////////////////////////////////////////////////// +/** + * This is where all extensions should derive from. It defines the _self and + * _this members that can be used from the extension method. + */ template class EXPCL_INTERROGATEDB ExtensionBase { public: T * _this; }; -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : The default class template does not define any -// methods. Classes that are extended should create -// a specialization of this class template. -//////////////////////////////////////////////////////////////////// +/** + * The default class template does not define any methods. Classes that are + * extended should create a specialization of this class template. + */ template class EXPCL_INTERROGATEDB Extension : public ExtensionBase { }; -//////////////////////////////////////////////////////////////////// -// Function: invoke_extension -// Description: Creates a new extension object for the given -// pointer that can then be used to call extension -// methods, as follows: -// invoke_extension((MyClass) *ptr).method() -//////////////////////////////////////////////////////////////////// +/** + * Creates a new extension object for the given pointer that can then be used + * to call extension methods, as follows: invoke_extension((MyClass) + * *ptr).method() + */ template inline Extension invoke_extension(T *ptr) { @@ -54,10 +47,9 @@ invoke_extension(T *ptr) { return ext; } -//////////////////////////////////////////////////////////////////// -// Function: invoke_extension -// Description: The const version of the above function. -//////////////////////////////////////////////////////////////////// +/** + * The const version of the above function. + */ template inline const Extension invoke_extension(const T *ptr) { diff --git a/dtool/src/interrogatedb/indexRemapper.cxx b/dtool/src/interrogatedb/indexRemapper.cxx index 188e7a5b1d..eee236cf08 100644 --- a/dtool/src/interrogatedb/indexRemapper.cxx +++ b/dtool/src/interrogatedb/indexRemapper.cxx @@ -1,76 +1,62 @@ -// Filename: indexRemapper.cxx -// Created by: drose (05Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexRemapper.cxx + * @author drose + * @date 2000-08-05 + */ #include "indexRemapper.h" -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IndexRemapper:: IndexRemapper() { } -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IndexRemapper:: ~IndexRemapper() { } -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::clear -// Access: Public -// Description: Removes all mappings from the object. -//////////////////////////////////////////////////////////////////// +/** + * Removes all mappings from the object. + */ void IndexRemapper:: clear() { _map_int.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::add_mapping -// Access: Public -// Description: Adds a mapping from the integer 'from' to 'to'. -//////////////////////////////////////////////////////////////////// +/** + * Adds a mapping from the integer 'from' to 'to'. + */ void IndexRemapper:: add_mapping(int from, int to) { _map_int[from] = to; } -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::in_map -// Access: Public -// Description: Returns true if the given 'from' integer has been -// assigned a mapping, false if it has not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given 'from' integer has been assigned a mapping, false + * if it has not. + */ bool IndexRemapper:: in_map(int from) const { return _map_int.count(from) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: IndexRemapper::map_from -// Access: Public -// Description: Returns the integer that the given 'from' integer had -// been set to map to, or the same integer if nothing -// had been set for it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer that the given 'from' integer had been set to map to, + * or the same integer if nothing had been set for it. + */ int IndexRemapper:: map_from(int from) const { map::const_iterator mi; diff --git a/dtool/src/interrogatedb/indexRemapper.h b/dtool/src/interrogatedb/indexRemapper.h index 61aa67ccc5..9318777c94 100644 --- a/dtool/src/interrogatedb/indexRemapper.h +++ b/dtool/src/interrogatedb/indexRemapper.h @@ -1,16 +1,15 @@ -// Filename: indexRemapper.h -// Created by: drose (05Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexRemapper.h + * @author drose + * @date 2000-08-05 + */ #ifndef INDEXREMAPPER_H #define INDEXREMAPPER_H @@ -19,17 +18,14 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : IndexRemapper -// Description : This class manages a mapping of integers to integers. -// It's used in this package to resequence some or all -// of the index numbers in the database to a different -// sequence. -// -// This class is just a wrapper around STL map. The -// only reason it exists is because Microsoft can't -// export STL map outside of the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This class manages a mapping of integers to integers. It's used in this + * package to resequence some or all of the index numbers in the database to a + * different sequence. + * + * This class is just a wrapper around STL map. The only reason it exists is + * because Microsoft can't export STL map outside of the DLL. + */ class EXPCL_INTERROGATEDB IndexRemapper { public: IndexRemapper(); diff --git a/dtool/src/interrogatedb/interrogateComponent.I b/dtool/src/interrogatedb/interrogateComponent.I index 7f85969055..4617eee858 100644 --- a/dtool/src/interrogatedb/interrogateComponent.I +++ b/dtool/src/interrogatedb/interrogateComponent.I @@ -1,34 +1,28 @@ -// Filename: interrogateComponent.I -// Created by: drose (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateComponent.I + * @author drose + * @date 2000-08-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateComponent:: InterrogateComponent(InterrogateModuleDef *def) : _def(def) { } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateComponent:: InterrogateComponent(const InterrogateComponent ©) : _def(copy._def), @@ -36,39 +30,31 @@ InterrogateComponent(const InterrogateComponent ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void InterrogateComponent:: operator = (const InterrogateComponent ©) { _def = copy._def; _name = copy._name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::has_library_name -// Access: Public -// Description: Returns true if we have a known library name, false if -// we do not. See get_library_name(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have a known library name, false if we do not. See + * get_library_name(). + */ INLINE bool InterrogateComponent:: has_library_name() const { const char *name = get_library_name(); return (name != (const char *)NULL && name[0] != '\0'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::get_library_name -// Access: Public -// Description: Returns the library name, if it is known, or NULL if -// it is not. This is the name of the library that this -// particular component was built into. Typically this -// will be a one-to-one correspondance with an -// invocation of the interrogate command. Typical -// examples are "libutil" and "liblinmath". -//////////////////////////////////////////////////////////////////// +/** + * Returns the library name, if it is known, or NULL if it is not. This is + * the name of the library that this particular component was built into. + * Typically this will be a one-to-one correspondance with an invocation of + * the interrogate command. Typical examples are "libutil" and "liblinmath". + */ INLINE const char *InterrogateComponent:: get_library_name() const { if (_def != (InterrogateModuleDef *)NULL) { @@ -77,27 +63,22 @@ get_library_name() const { return (const char *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::has_module_name -// Access: Public -// Description: Returns true if we have a known module name, false if -// we do not. See get_module_name(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have a known module name, false if we do not. See + * get_module_name(). + */ INLINE bool InterrogateComponent:: has_module_name() const { const char *name = get_module_name(); return (name != (const char *)NULL && name[0] != '\0'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::get_module_name -// Access: Public -// Description: Returns the module name, if it is known, or NULL if -// it is not. This is the name of the module that this -// particular component is associated with. This is a -// higher grouping than library. Typical examples are -// "panda" and "pandaegg". -//////////////////////////////////////////////////////////////////// +/** + * Returns the module name, if it is known, or NULL if it is not. This is the + * name of the module that this particular component is associated with. This + * is a higher grouping than library. Typical examples are "panda" and + * "pandaegg". + */ INLINE const char *InterrogateComponent:: get_module_name() const { if (_def != (InterrogateModuleDef *)NULL) { @@ -106,41 +87,33 @@ get_module_name() const { return (const char *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::has_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateComponent:: has_name() const { return !_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateComponent:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::get_num_alt_names -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateComponent:: get_num_alt_names() const { return _alt_names.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::get_num_alt_names -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateComponent:: get_alt_name(int n) const { if (n >= 0 && n < (int)_alt_names.size()) { diff --git a/dtool/src/interrogatedb/interrogateComponent.cxx b/dtool/src/interrogatedb/interrogateComponent.cxx index dcd6af9a20..c5a8e15df0 100644 --- a/dtool/src/interrogatedb/interrogateComponent.cxx +++ b/dtool/src/interrogatedb/interrogateComponent.cxx @@ -1,29 +1,26 @@ -// Filename: interrogateComponent.cxx -// Created by: drose (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateComponent.cxx + * @author drose + * @date 2000-08-08 + */ #include "interrogateComponent.h" #include "interrogate_datafile.h" -// This static string is just kept around as a handy bogus return -// value for functions that must return a const string reference. +// This static string is just kept around as a handy bogus return value for +// functions that must return a const string reference. string InterrogateComponent::_empty_string; -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::output -// Access: Public -// Description: Formats the component for output to a data file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the component for output to a data file. + */ void InterrogateComponent:: output(ostream &out) const { idf_output_string(out, _name); @@ -35,12 +32,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateComponent::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateComponent:: input(istream &in) { idf_input_string(in, _name); diff --git a/dtool/src/interrogatedb/interrogateComponent.h b/dtool/src/interrogatedb/interrogateComponent.h index e1820806d3..c69dc26886 100644 --- a/dtool/src/interrogatedb/interrogateComponent.h +++ b/dtool/src/interrogatedb/interrogateComponent.h @@ -1,16 +1,15 @@ -// Filename: interrogateComponent.h -// Created by: drose (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateComponent.h + * @author drose + * @date 2000-08-08 + */ #ifndef INTERROGATECOMPONENT_H #define INTERROGATECOMPONENT_H @@ -24,12 +23,10 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateComponent -// Description : The base class for things that are part of the -// interrogate database. This includes types, -// functions, and function wrappers. -//////////////////////////////////////////////////////////////////// +/** + * The base class for things that are part of the interrogate database. This + * includes types, functions, and function wrappers. + */ class EXPCL_INTERROGATEDB InterrogateComponent { public: INLINE InterrogateComponent(InterrogateModuleDef *def = NULL); @@ -68,5 +65,3 @@ private: #include "interrogateComponent.I" #endif - - diff --git a/dtool/src/interrogatedb/interrogateDatabase.I b/dtool/src/interrogatedb/interrogateDatabase.I index 61879a859d..91493a1772 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.I +++ b/dtool/src/interrogatedb/interrogateDatabase.I @@ -1,24 +1,20 @@ -// Filename: interrogateDatabase.I -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateDatabase.I + * @author drose + * @date 2000-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::check_latest -// Access: Public -// Description: Checks that all the latest data for all the libraries -// have been loaded. Loads them if not. -//////////////////////////////////////////////////////////////////// +/** + * Checks that all the latest data for all the libraries have been loaded. + * Loads them if not. + */ INLINE void InterrogateDatabase:: check_latest() { if (!_requests.empty()) { @@ -26,13 +22,10 @@ check_latest() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_type_by_name -// Access: Public -// Description: Returns the TypeIndex associated with the first type -// found with the given name, or 0 if no type has this -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeIndex associated with the first type found with the given + * name, or 0 if no type has this name. + */ INLINE TypeIndex InterrogateDatabase:: lookup_type_by_name(const string &name) { check_latest(); @@ -40,13 +33,10 @@ lookup_type_by_name(const string &name) { &InterrogateDatabase::freshen_types_by_name); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_type_by_scoped_name -// Access: Public -// Description: Returns the TypeIndex associated with the first type -// found with the given scoped name, or 0 if no type has -// this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeIndex associated with the first type found with the given + * scoped name, or 0 if no type has this name. + */ INLINE TypeIndex InterrogateDatabase:: lookup_type_by_scoped_name(const string &name) { check_latest(); @@ -54,13 +44,10 @@ lookup_type_by_scoped_name(const string &name) { &InterrogateDatabase::freshen_types_by_scoped_name); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_type_by_true_name -// Access: Public -// Description: Returns the TypeIndex associated with the first type -// found with the given true name, or 0 if no type has -// this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeIndex associated with the first type found with the given + * true name, or 0 if no type has this name. + */ INLINE TypeIndex InterrogateDatabase:: lookup_type_by_true_name(const string &name) { check_latest(); @@ -68,13 +55,10 @@ lookup_type_by_true_name(const string &name) { &InterrogateDatabase::freshen_types_by_true_name); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_manifest_by_name -// Access: Public -// Description: Returns the ManifestIndex associated with the first -// manifest found with the given name, or 0 if no -// manifest has this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ManifestIndex associated with the first manifest found with the + * given name, or 0 if no manifest has this name. + */ INLINE ManifestIndex InterrogateDatabase:: lookup_manifest_by_name(const string &name) { check_latest(); @@ -82,13 +66,10 @@ lookup_manifest_by_name(const string &name) { &InterrogateDatabase::freshen_manifests_by_name); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_element_by_name -// Access: Public -// Description: Returns the ElementIndex associated with the first -// element found with the given name, or 0 if no element -// has this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ElementIndex associated with the first element found with the + * given name, or 0 if no element has this name. + */ INLINE ElementIndex InterrogateDatabase:: lookup_element_by_name(const string &name) { check_latest(); @@ -96,13 +77,10 @@ lookup_element_by_name(const string &name) { &InterrogateDatabase::freshen_elements_by_name); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup_element_by_scoped_name -// Access: Public -// Description: Returns the ElementIndex associated with the first -// element found with the given scoped name, or 0 if no -// element has this name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ElementIndex associated with the first element found with the + * given scoped name, or 0 if no element has this name. + */ INLINE ElementIndex InterrogateDatabase:: lookup_element_by_scoped_name(const string &name) { check_latest(); diff --git a/dtool/src/interrogatedb/interrogateDatabase.cxx b/dtool/src/interrogatedb/interrogateDatabase.cxx index 8d2133212f..22d424b6e9 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.cxx +++ b/dtool/src/interrogatedb/interrogateDatabase.cxx @@ -1,16 +1,15 @@ -// Filename: interrogateDatabase.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateDatabase.cxx + * @author drose + * @date 2000-08-01 + */ #include "interrogateDatabase.h" #include "config_interrogatedb.h" @@ -23,11 +22,9 @@ int InterrogateDatabase::_file_minor_version = 0; int InterrogateDatabase::_current_major_version = 3; int InterrogateDatabase::_current_minor_version = 1; -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterrogateDatabase:: InterrogateDatabase() { _error_flag = false; @@ -35,12 +32,9 @@ InterrogateDatabase() { _lookups_fresh = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_ptr -// Access: Private -// Description: Returns the global pointer to the one -// InterrogateDatabase. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global pointer to the one InterrogateDatabase. + */ InterrogateDatabase *InterrogateDatabase:: get_ptr() { if (_global_ptr == (InterrogateDatabase *)NULL) { @@ -53,15 +47,12 @@ get_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::request_module -// Access: Public -// Description: Requests that the interrogate data for the given -// module be made available. The function pointers will -// be made available immediately, while the database -// file will be read later, the next time someone asks -// for interrogate data that requires it. -//////////////////////////////////////////////////////////////////// +/** + * Requests that the interrogate data for the given module be made available. + * The function pointers will be made available immediately, while the + * database file will be read later, the next time someone asks for + * interrogate data that requires it. + */ void InterrogateDatabase:: request_module(InterrogateModuleDef *def) { if (interrogatedb_cat->is_debug()) { @@ -76,21 +67,20 @@ request_module(InterrogateModuleDef *def) { int num_indices = def->next_index - def->first_index; if (num_indices > 0) { - // If the module def has any definitions--any index numbers - // used--assign it to its own unique range of index numbers. + // If the module def has any definitions--any index numbers used--assign + // it to its own unique range of index numbers. def->first_index = _next_index; _next_index += num_indices; def->next_index = _next_index; - // Assign a reference to the module def by index number. When we - // need to look up a function by its index number, we'll be able - // to use this. + // Assign a reference to the module def by index number. When we need to + // look up a function by its index number, we'll be able to use this. _modules.push_back(def); } if (def->num_unique_names > 0 && def->library_name != (const char *)NULL) { - // Define a lookup by hash for this module, mainly so we can look - // up functions by their unique names. + // Define a lookup by hash for this module, mainly so we can look up + // functions by their unique names. _modules_by_hash[def->library_hash_name] = def; } @@ -99,41 +89,31 @@ request_module(InterrogateModuleDef *def) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_error_flag -// Access: Public -// Description: Returns the global error flag. This will be set true -// if there was some problem importing the database -// (e.g. cannot find an .in file), or false if -// everything is ok. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global error flag. This will be set true if there was some + * problem importing the database (e.g. cannot find an .in file), or false if + * everything is ok. + */ bool InterrogateDatabase:: get_error_flag() { return _error_flag; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_global_types -// Access: Public -// Description: Returns the total number of "global" types known to -// the interrogate database. These are types defined at -// the global level that should be considered for -// exporting, but not the incidental types (like -// pointers, etc.) that must be defined to support -// these. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of "global" types known to the interrogate + * database. These are types defined at the global level that should be + * considered for exporting, but not the incidental types (like pointers, + * etc.) that must be defined to support these. + */ int InterrogateDatabase:: get_num_global_types() { check_latest(); return _global_types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_global_type -// Access: Public -// Description: Returns the index of the nth global type known to the -// interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth global type known to the interrogate database. + */ TypeIndex InterrogateDatabase:: get_global_type(int n) { check_latest(); @@ -143,26 +123,20 @@ get_global_type(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_all_types -// Access: Public -// Description: Returns the total number of types known to the -// interrogate database. This includes all known types, -// global as well as incidental. See also -// get_num_global_types(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of types known to the interrogate database. This + * includes all known types, global as well as incidental. See also + * get_num_global_types(). + */ int InterrogateDatabase:: get_num_all_types() { check_latest(); return _all_types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_all_type -// Access: Public -// Description: Returns the index of the nth type known to the -// interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth type known to the interrogate database. + */ TypeIndex InterrogateDatabase:: get_all_type(int n) { check_latest(); @@ -172,26 +146,21 @@ get_all_type(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_global_functions -// Access: Public -// Description: Returns the total number of global functions known to -// the interrogate database. These are functions -// defined at the global level, e.g. non-member -// functions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of global functions known to the interrogate + * database. These are functions defined at the global level, e.g. non- + * member functions. + */ int InterrogateDatabase:: get_num_global_functions() { check_latest(); return _global_functions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_global_function -// Access: Public -// Description: Returns the index of the nth global function known to -// the interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth global function known to the interrogate + * database. + */ FunctionIndex InterrogateDatabase:: get_global_function(int n) { check_latest(); @@ -201,26 +170,20 @@ get_global_function(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_all_functions -// Access: Public -// Description: Returns the total number of functions known to the -// interrogate database. This includes all known -// functions, global, method, or synthesized. See also -// get_num_global_functions(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of functions known to the interrogate database. + * This includes all known functions, global, method, or synthesized. See + * also get_num_global_functions(). + */ int InterrogateDatabase:: get_num_all_functions() { check_latest(); return _all_functions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_all_function -// Access: Public -// Description: Returns the index of the nth function known to the -// interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth function known to the interrogate database. + */ FunctionIndex InterrogateDatabase:: get_all_function(int n) { check_latest(); @@ -230,24 +193,20 @@ get_all_function(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_global_manifests -// Access: Public -// Description: Returns the total number of global manifest constants -// known to the interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of global manifest constants known to the + * interrogate database. + */ int InterrogateDatabase:: get_num_global_manifests() { check_latest(); return _global_manifests.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_global_manifest -// Access: Public -// Description: Returns the index of the nth global manifest constant -// known to the interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth global manifest constant known to the + * interrogate database. + */ ManifestIndex InterrogateDatabase:: get_global_manifest(int n) { check_latest(); @@ -257,24 +216,20 @@ get_global_manifest(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_num_global_elements -// Access: Public -// Description: Returns the total number of global data elements -// known to the interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of global data elements known to the interrogate + * database. + */ int InterrogateDatabase:: get_num_global_elements() { check_latest(); return _global_elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_global_element -// Access: Public -// Description: Returns the index of the nth global data element -// known to the interrogate database. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the nth global data element known to the interrogate + * database. + */ ElementIndex InterrogateDatabase:: get_global_element(int n) { check_latest(); @@ -284,12 +239,9 @@ get_global_element(int n) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_type -// Access: Public -// Description: Returns the type associated with the given TypeIndex, -// if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type associated with the given TypeIndex, if there is one. + */ const InterrogateType &InterrogateDatabase:: get_type(TypeIndex type) { static InterrogateType bogus_type; @@ -303,12 +255,10 @@ get_type(TypeIndex type) { return (*ti).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_function -// Access: Public -// Description: Returns the function associated with the given -// FunctionIndex, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function associated with the given FunctionIndex, if there is + * one. + */ const InterrogateFunction &InterrogateDatabase:: get_function(FunctionIndex function) { static InterrogateFunction bogus_function; @@ -322,12 +272,10 @@ get_function(FunctionIndex function) { return *(*fi).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_wrapper -// Access: Public -// Description: Returns the function wrapper associated with the -// given FunctionWrapperIndex, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function wrapper associated with the given + * FunctionWrapperIndex, if there is one. + */ const InterrogateFunctionWrapper &InterrogateDatabase:: get_wrapper(FunctionWrapperIndex wrapper) { static InterrogateFunctionWrapper bogus_wrapper; @@ -341,12 +289,10 @@ get_wrapper(FunctionWrapperIndex wrapper) { return (*wi).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_manifest -// Access: Public -// Description: Returns the manifest constant associated with the -// given ManifestIndex, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the manifest constant associated with the given ManifestIndex, if + * there is one. + */ const InterrogateManifest &InterrogateDatabase:: get_manifest(ManifestIndex manifest) { static InterrogateManifest bogus_manifest; @@ -360,12 +306,10 @@ get_manifest(ManifestIndex manifest) { return (*mi).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_element -// Access: Public -// Description: Returns the data element associated with the -// given ElementIndex, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data element associated with the given ElementIndex, if there + * is one. + */ const InterrogateElement &InterrogateDatabase:: get_element(ElementIndex element) { static InterrogateElement bogus_element; @@ -379,12 +323,10 @@ get_element(ElementIndex element) { return (*ei).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_make_seq -// Access: Public -// Description: Returns the make_seq associated with the given -// MakeSeqIndex, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the make_seq associated with the given MakeSeqIndex, if there is + * one. + */ const InterrogateMakeSeq &InterrogateDatabase:: get_make_seq(MakeSeqIndex make_seq) { static InterrogateMakeSeq bogus_make_seq; @@ -398,24 +340,18 @@ get_make_seq(MakeSeqIndex make_seq) { return (*si).second; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::remove_type -// Access: Public -// Description: Erases the type from the database. -//////////////////////////////////////////////////////////////////// +/** + * Erases the type from the database. + */ void InterrogateDatabase:: remove_type(TypeIndex type) { _type_map.erase(type); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_fptr -// Access: Public -// Description: Returns the function pointer associated with the -// given function wrapper, if it has a pointer -// available. Returns NULL if the pointer is not -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function pointer associated with the given function wrapper, if + * it has a pointer available. Returns NULL if the pointer is not available. + */ void *InterrogateDatabase:: get_fptr(FunctionWrapperIndex wrapper) { InterrogateModuleDef *def; @@ -428,14 +364,11 @@ get_fptr(FunctionWrapperIndex wrapper) { return (void *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_wrapper_by_unique_name -// Access: Public -// Description: Looks up the function wrapper corresponding to the -// given unique name, if available. Returns the -// corresponding wrapper index, or 0 if no such -// wrapper is found. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the function wrapper corresponding to the given unique name, if + * available. Returns the corresponding wrapper index, or 0 if no such + * wrapper is found. + */ FunctionWrapperIndex InterrogateDatabase:: get_wrapper_by_unique_name(const string &unique_name) { // First, split the unique_name into a library_hash_name and a @@ -464,82 +397,63 @@ get_wrapper_by_unique_name(const string &unique_name) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_file_major_version -// Access: Public -// Description: Returns the major version number of the interrogate -// database file currently being read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number of the interrogate database file currently + * being read. + */ int InterrogateDatabase:: get_file_major_version() { return _file_major_version; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_file_minor_version -// Access: Public -// Description: Returns the minor version number of the interrogate -// database file currently being read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number of the interrogate database file currently + * being read. + */ int InterrogateDatabase:: get_file_minor_version() { return _file_minor_version; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_current_major_version -// Access: Public -// Description: Returns the major version number currently expected -// in interrogate database files generated by this code -// base. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number currently expected in interrogate database + * files generated by this code base. + */ int InterrogateDatabase:: get_current_major_version() { return _current_major_version; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_current_minor_version -// Access: Public -// Description: Returns the minor version number currently expected -// in interrogate database files generated by this code -// base. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number currently expected in interrogate database + * files generated by this code base. + */ int InterrogateDatabase:: get_current_minor_version() { return _current_minor_version; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::set_error_flag -// Access: Public -// Description: Sets the global error flag. This should be set true -// if there was some problem importing the database -// (e.g. cannot find an .in file). -//////////////////////////////////////////////////////////////////// +/** + * Sets the global error flag. This should be set true if there was some + * problem importing the database (e.g. cannot find an .in file). + */ void InterrogateDatabase:: set_error_flag(bool error_flag) { _error_flag = error_flag; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::get_next_index -// Access: Public -// Description: Returns a new index number suitable for the next -// thing, that will not be shared with any other index -// numbers. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new index number suitable for the next thing, that will not be + * shared with any other index numbers. + */ int InterrogateDatabase:: get_next_index() { return _next_index++; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_type -// Access: Public -// Description: Adds the indicated type to the database at the given -// index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated type to the database at the given index number. + */ void InterrogateDatabase:: add_type(TypeIndex index, const InterrogateType &type) { assert(index != 0); @@ -547,9 +461,8 @@ add_type(TypeIndex index, const InterrogateType &type) { _type_map.insert(TypeMap::value_type(index, type)).second; if (!inserted) { - // If there was already a type at that index, maybe it was a - // forward reference. If its _fully_defined bit isn't set, then - // it's ok. + // If there was already a type at that index, maybe it was a forward + // reference. If its _fully_defined bit isn't set, then it's ok. InterrogateType &old_type = _type_map[index]; assert(!old_type.is_fully_defined()); @@ -563,12 +476,9 @@ add_type(TypeIndex index, const InterrogateType &type) { _all_types.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_function -// Access: Public -// Description: Adds the indicated function to the database at -// the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated function to the database at the given index number. + */ void InterrogateDatabase:: add_function(FunctionIndex index, InterrogateFunction *function) { bool inserted = @@ -581,12 +491,10 @@ add_function(FunctionIndex index, InterrogateFunction *function) { _all_functions.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_wrapper -// Access: Public -// Description: Adds the indicated function wrapper to the database at -// the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated function wrapper to the database at the given index + * number. + */ void InterrogateDatabase:: add_wrapper(FunctionWrapperIndex index, const InterrogateFunctionWrapper &wrapper) { @@ -595,12 +503,10 @@ add_wrapper(FunctionWrapperIndex index, assert(inserted); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_manifest -// Access: Public -// Description: Adds the indicated manifest constant to the database -// at the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated manifest constant to the database at the given index + * number. + */ void InterrogateDatabase:: add_manifest(ManifestIndex index, const InterrogateManifest &manifest) { bool inserted = @@ -610,12 +516,9 @@ add_manifest(ManifestIndex index, const InterrogateManifest &manifest) { _global_manifests.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_element -// Access: Public -// Description: Adds the indicated data element to the database -// at the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated data element to the database at the given index number. + */ void InterrogateDatabase:: add_element(ElementIndex index, const InterrogateElement &element) { bool inserted = @@ -627,12 +530,9 @@ add_element(ElementIndex index, const InterrogateElement &element) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::add_make_seq -// Access: Public -// Description: Adds the indicated make_seq to the database at -// the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated make_seq to the database at the given index number. + */ void InterrogateDatabase:: add_make_seq(MakeSeqIndex index, const InterrogateMakeSeq &make_seq) { bool inserted = @@ -640,12 +540,10 @@ add_make_seq(MakeSeqIndex index, const InterrogateMakeSeq &make_seq) { assert(inserted); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_type -// Access: Public -// Description: Returns a non-const reference to the indicated type, -// allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated type, allowing the user to + * update it. + */ InterrogateType &InterrogateDatabase:: update_type(TypeIndex type) { assert(type != 0); @@ -653,90 +551,73 @@ update_type(TypeIndex type) { return _type_map[type]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_function -// Access: Public -// Description: Returns a non-const reference to the indicated -// function, allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated function, allowing the user + * to update it. + */ InterrogateFunction &InterrogateDatabase:: update_function(FunctionIndex function) { check_latest(); return *_function_map[function]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_wrapper -// Access: Public -// Description: Returns a non-const reference to the indicated -// function wrapper, allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated function wrapper, allowing + * the user to update it. + */ InterrogateFunctionWrapper &InterrogateDatabase:: update_wrapper(FunctionWrapperIndex wrapper) { check_latest(); return _wrapper_map[wrapper]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_manifest -// Access: Public -// Description: Returns a non-const reference to the indicated -// manifest constant, allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated manifest constant, allowing + * the user to update it. + */ InterrogateManifest &InterrogateDatabase:: update_manifest(ManifestIndex manifest) { check_latest(); return _manifest_map[manifest]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_element -// Access: Public -// Description: Returns a non-const reference to the indicated -// data element, allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated data element, allowing the + * user to update it. + */ InterrogateElement &InterrogateDatabase:: update_element(ElementIndex element) { check_latest(); return _element_map[element]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::update_make_seq -// Access: Public -// Description: Returns a non-const reference to the indicated -// make_seq, allowing the user to update it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const reference to the indicated make_seq, allowing the user + * to update it. + */ InterrogateMakeSeq &InterrogateDatabase:: update_make_seq(MakeSeqIndex make_seq) { check_latest(); return _make_seq_map[make_seq]; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::remap_indices -// Access: Public -// Description: Resequences all of the various index numbers so that -// all of the functions start at first_index and -// increment consecutively from there, and then all of -// the types follow. Returns the next available index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Resequences all of the various index numbers so that all of the functions + * start at first_index and increment consecutively from there, and then all + * of the types follow. Returns the next available index number. + */ int InterrogateDatabase:: remap_indices(int first_index) { IndexRemapper remap; return remap_indices(first_index, remap); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::remap_indices -// Access: Public -// Description: This flavor of remap_indices() accepts a map that -// should be empty on initial call, and will be filled -// with the mapping of old index number to new index -// number. This allows the caller to update its own -// data structures to match the new index numbers. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of remap_indices() accepts a map that should be empty on + * initial call, and will be filled with the mapping of old index number to + * new index number. This allows the caller to update its own data structures + * to match the new index numbers. + */ int InterrogateDatabase:: remap_indices(int first_index, IndexRemapper &remap) { remap.clear(); @@ -849,12 +730,9 @@ remap_indices(int first_index, IndexRemapper &remap) { return _next_index; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::write -// Access: Public -// Description: Writes the database to the indicated stream for later -// reading. -//////////////////////////////////////////////////////////////////// +/** + * Writes the database to the indicated stream for later reading. + */ void InterrogateDatabase:: write(ostream &out, InterrogateModuleDef *def) const { // Write out the file header. @@ -906,19 +784,14 @@ write(ostream &out, InterrogateModuleDef *def) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::read -// Access: Public -// Description: Reads a database from the indicated stream, -// associated with the indicated module definition and -// merges it with any existing data in the database, -// according to the expected index numbers specified in -// the module def. The header information has already -// been read. -// -// Returns true if the file is read successfully, false -// if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Reads a database from the indicated stream, associated with the indicated + * module definition and merges it with any existing data in the database, + * according to the expected index numbers specified in the module def. The + * header information has already been read. + * + * Returns true if the file is read successfully, false if there is an error. + */ bool InterrogateDatabase:: read(istream &in, InterrogateModuleDef *def) { InterrogateDatabase temp; @@ -943,11 +816,9 @@ read(istream &in, InterrogateModuleDef *def) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::load_latest -// Access: Private -// Description: Reads in the latest interrogate data. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the latest interrogate data. + */ void InterrogateDatabase:: load_latest() { const DSearchPath &searchpath = interrogatedb_path; @@ -1022,14 +893,11 @@ load_latest() { _requests.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::read_new -// Access: Private -// Description: Reads from the indicated stream (the header -// information has already been read) into the -// newly-created database. It is an error if the -// database already has some data in it. -//////////////////////////////////////////////////////////////////// +/** + * Reads from the indicated stream (the header information has already been + * read) into the newly-created database. It is an error if the database + * already has some data in it. + */ bool InterrogateDatabase:: read_new(istream &in, InterrogateModuleDef *def) { // We've already read the header. Read the module definition. @@ -1163,20 +1031,17 @@ read_new(istream &in, InterrogateModuleDef *def) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::merge_from -// Access: Private -// Description: Copies all the data from the indicated database into -// this one. It is an error if any index numbers are -// shared between the two databases. -//////////////////////////////////////////////////////////////////// +/** + * Copies all the data from the indicated database into this one. It is an + * error if any index numbers are shared between the two databases. + */ void InterrogateDatabase:: merge_from(const InterrogateDatabase &other) { // We want to collapse shared types together. IndexRemapper remap; - // First, we need to build a set of types by name, so we know what - // types we already have. + // First, we need to build a set of types by name, so we know what types we + // already have. map types_by_name; TypeMap::const_iterator ti; @@ -1187,8 +1052,8 @@ merge_from(const InterrogateDatabase &other) { } } - // Now go through the other set of types and determine the mapping - // into this set. + // Now go through the other set of types and determine the mapping into this + // set. for (ti = other._type_map.begin(); ti != other._type_map.end(); ++ti) { TypeIndex other_type_index = (*ti).first; const InterrogateType &other_type = (*ti).second; @@ -1197,16 +1062,16 @@ merge_from(const InterrogateDatabase &other) { map::iterator ni; ni = types_by_name.find(other_type.get_true_name()); if (ni != types_by_name.end()) { - // Here's a type that we seem to have in common! We'll have - // to merge them. + // Here's a type that we seem to have in common! We'll have to merge + // them. TypeIndex this_type_index = (*ni).second; remap.add_mapping(other_type_index, this_type_index); } } } - // Now that we know the full type-to-type mapping, we can copy the - // new types, one at a time. + // Now that we know the full type-to-type mapping, we can copy the new + // types, one at a time. for (ti = other._type_map.begin(); ti != other._type_map.end(); ++ti) { TypeIndex other_type_index = (*ti).first; const InterrogateType &other_type = (*ti).second; @@ -1222,8 +1087,8 @@ merge_from(const InterrogateDatabase &other) { InterrogateType &this_type = update_type(this_type_index); if (!this_type.is_global() && other_type.is_global()) { - // If the type is about to become global, we need to add it - // to our global_types list. + // If the type is about to become global, we need to add it to our + // global_types list. _global_types.push_back(this_type_index); } @@ -1287,18 +1152,15 @@ merge_from(const InterrogateDatabase &other) { _lookups_fresh = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::find_module -// Access: Private -// Description: Looks up the wrapper definition in the set of module -// defs that are loaded in at runtime and represent the -// part of the interrogate database that's compiled in. -// -// If the wrapper definition is not found, returns -// false. If it is found, returns true and sets def and -// module_index to the particular module and the index -// within the module where the wrapper is defined. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the wrapper definition in the set of module defs that are loaded + * in at runtime and represent the part of the interrogate database that's + * compiled in. + * + * If the wrapper definition is not found, returns false. If it is found, + * returns true and sets def and module_index to the particular module and the + * index within the module where the wrapper is defined. + */ bool InterrogateDatabase:: find_module(FunctionWrapperIndex wrapper, InterrogateModuleDef *&def, int &module_index) { @@ -1314,12 +1176,10 @@ find_module(FunctionWrapperIndex wrapper, InterrogateModuleDef *&def, return (wrapper < def->next_index); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::binary_search_module -// Access: Private -// Description: Searches for the function module that includes the -// given function index by binary search. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the function module that includes the given function index by + * binary search. + */ int InterrogateDatabase:: binary_search_module(int begin, int end, FunctionIndex function) { int mid = begin + (end - begin) / 2; @@ -1336,13 +1196,11 @@ binary_search_module(int begin, int end, FunctionIndex function) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::binary_search_wrapper_hash -// Access: Private -// Description: Searches for the particular function wrapper's hash -// name within a given module. Returns the index number -// local to the module, or -1 if it is not found. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the particular function wrapper's hash name within a given + * module. Returns the index number local to the module, or -1 if it is not + * found. + */ int InterrogateDatabase:: binary_search_wrapper_hash(InterrogateUniqueNameDef *begin, InterrogateUniqueNameDef *end, @@ -1364,11 +1222,9 @@ binary_search_wrapper_hash(InterrogateUniqueNameDef *begin, } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_types_by_name -// Access: Private -// Description: Builds up the lookup of types by name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of types by name. + */ void InterrogateDatabase:: freshen_types_by_name() { _types_by_name.clear(); @@ -1378,11 +1234,9 @@ freshen_types_by_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_types_by_scoped_name -// Access: Private -// Description: Builds up the lookup of types by scoped name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of types by scoped name. + */ void InterrogateDatabase:: freshen_types_by_scoped_name() { _types_by_scoped_name.clear(); @@ -1392,11 +1246,9 @@ freshen_types_by_scoped_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_types_by_true_name -// Access: Private -// Description: Builds up the lookup of types by true name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of types by true name. + */ void InterrogateDatabase:: freshen_types_by_true_name() { _types_by_true_name.clear(); @@ -1406,11 +1258,9 @@ freshen_types_by_true_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_manifests_by_name -// Access: Private -// Description: Builds up the lookup of manifests by name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of manifests by name. + */ void InterrogateDatabase:: freshen_manifests_by_name() { _manifests_by_name.clear(); @@ -1420,11 +1270,9 @@ freshen_manifests_by_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_elements_by_name -// Access: Private -// Description: Builds up the lookup of elements by name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of elements by name. + */ void InterrogateDatabase:: freshen_elements_by_name() { _elements_by_name.clear(); @@ -1434,11 +1282,9 @@ freshen_elements_by_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::freshen_elements_by_scoped_name -// Access: Private -// Description: Builds up the lookup of elements by scoped name. -//////////////////////////////////////////////////////////////////// +/** + * Builds up the lookup of elements by scoped name. + */ void InterrogateDatabase:: freshen_elements_by_scoped_name() { _elements_by_scoped_name.clear(); @@ -1448,13 +1294,10 @@ freshen_elements_by_scoped_name() { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateDatabase::lookup -// Access: Private -// Description: Looks up a type, manifest, or element in the -// indicated lookup table by name. This is an internal -// support function. -//////////////////////////////////////////////////////////////////// +/** + * Looks up a type, manifest, or element in the indicated lookup table by + * name. This is an internal support function. + */ int InterrogateDatabase:: lookup(const string &name, Lookup &lookup, LookupType type, void (InterrogateDatabase::*freshen)()) { diff --git a/dtool/src/interrogatedb/interrogateDatabase.h b/dtool/src/interrogatedb/interrogateDatabase.h index 893fa23ba4..84fc55fbab 100644 --- a/dtool/src/interrogatedb/interrogateDatabase.h +++ b/dtool/src/interrogatedb/interrogateDatabase.h @@ -1,16 +1,15 @@ -// Filename: interrogateDatabase.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateDatabase.h + * @author drose + * @date 2000-08-01 + */ #ifndef INTERROGATEDATABASE_H #define INTERROGATEDATABASE_H @@ -30,11 +29,10 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateDatabase -// Description : This stores all of the interrogate data and handles -// reading the data from a disk file when necessary. -//////////////////////////////////////////////////////////////////// +/** + * This stores all of the interrogate data and handles reading the data from a + * disk file when necessary. + */ class EXPCL_INTERROGATEDB InterrogateDatabase { private: InterrogateDatabase(); @@ -152,15 +150,14 @@ private: typedef vector GlobalElements; GlobalElements _global_elements; - // This data is compiled in directly to the shared libraries that we - // link with. + // This data is compiled in directly to the shared libraries that we link + // with. typedef vector Modules; Modules _modules; typedef map ModulesByHash; ModulesByHash _modules_by_hash; - // This records the set of database files that are still to be - // loaded. + // This records the set of database files that are still to be loaded. typedef vector Requests; Requests _requests; diff --git a/dtool/src/interrogatedb/interrogateElement.I b/dtool/src/interrogatedb/interrogateElement.I index 02cbe95c3e..4fea0bf105 100644 --- a/dtool/src/interrogatedb/interrogateElement.I +++ b/dtool/src/interrogatedb/interrogateElement.I @@ -1,23 +1,19 @@ -// Filename: interrogateElement.I -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateElement.I + * @author drose + * @date 2000-08-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateElement:: InterrogateElement(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -30,21 +26,17 @@ InterrogateElement(InterrogateModuleDef *def) : _clear_function = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateElement:: InterrogateElement(const InterrogateElement ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void InterrogateElement:: operator = (const InterrogateElement ©) { InterrogateComponent::operator = (copy); @@ -58,143 +50,114 @@ operator = (const InterrogateElement ©) { _clear_function = copy._clear_function; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::is_global -// Access: Public -// Description: Returns true if the element is marked as 'global'. -// This means only that it should appear in the global -// element list. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the element is marked as 'global'. This means only that it + * should appear in the global element list. + */ INLINE bool InterrogateElement:: is_global() const { return (_flags & F_global) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_scoped_name() const { return !_scoped_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateElement:: get_scoped_name() const { return _scoped_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateElement:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateElement:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_getter() const { return (_flags & F_has_getter) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateElement:: get_getter() const { return _getter; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_setter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_setter() const { return (_flags & F_has_setter) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_setter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateElement:: get_setter() const { return _setter; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_has_function -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_has_function() const { return (_flags & F_has_has_function) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_has_function -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateElement:: get_has_function() const { return _has_function; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::has_clear_function -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateElement:: has_clear_function() const { return (_flags & F_has_clear_function) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::get_clear_function -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateElement:: get_clear_function() const { return _clear_function; diff --git a/dtool/src/interrogatedb/interrogateElement.cxx b/dtool/src/interrogatedb/interrogateElement.cxx index 7895d0a70e..754f88ba33 100644 --- a/dtool/src/interrogatedb/interrogateElement.cxx +++ b/dtool/src/interrogatedb/interrogateElement.cxx @@ -1,28 +1,24 @@ -// Filename: interrogateElement.cxx -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateElement.cxx + * @author drose + * @date 2000-08-11 + */ #include "interrogateElement.h" #include "interrogateDatabase.h" #include "indexRemapper.h" #include "interrogate_datafile.h" -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::output -// Access: Public -// Description: Formats the InterrogateElement data for output to a data -// file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateElement data for output to a data file. + */ void InterrogateElement:: output(ostream &out) const { InterrogateComponent::output(out); @@ -36,12 +32,9 @@ output(ostream &out) const { idf_output_string(out, _comment, '\n'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateElement:: input(istream &in) { InterrogateComponent::input(in); @@ -53,13 +46,10 @@ input(istream &in) { idf_input_string(in, _comment); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateElement::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateElement:: remap_indices(const IndexRemapper &remap) { _type = remap.map_from(_type); diff --git a/dtool/src/interrogatedb/interrogateElement.h b/dtool/src/interrogatedb/interrogateElement.h index 75b6fc58ba..a69be7f5d1 100644 --- a/dtool/src/interrogatedb/interrogateElement.h +++ b/dtool/src/interrogatedb/interrogateElement.h @@ -1,16 +1,15 @@ -// Filename: interrogateElement.h -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateElement.h + * @author drose + * @date 2000-08-11 + */ #ifndef INTERROGATEELEMENT_H #define INTERROGATEELEMENT_H @@ -21,11 +20,10 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateElement -// Description : An internal representation of a data element, like a -// data member or a global variable. -//////////////////////////////////////////////////////////////////// +/** + * An internal representation of a data element, like a data member or a + * global variable. + */ class EXPCL_INTERROGATEDB InterrogateElement : public InterrogateComponent { public: INLINE InterrogateElement(InterrogateModuleDef *def = NULL); diff --git a/dtool/src/interrogatedb/interrogateFunction.I b/dtool/src/interrogatedb/interrogateFunction.I index 0dc6f30ab1..c394c8ac6f 100644 --- a/dtool/src/interrogatedb/interrogateFunction.I +++ b/dtool/src/interrogatedb/interrogateFunction.I @@ -1,159 +1,126 @@ -// Filename: interrogateFunction.I -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunction.I + * @author drose + * @date 2000-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::is_global -// Access: Public -// Description: Returns true if the function is marked as 'global'. -// This means only that it should appear in the global -// function list. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the function is marked as 'global'. This means only that it + * should appear in the global function list. + */ INLINE bool InterrogateFunction:: is_global() const { return (_flags & F_global) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::is_virtual -// Access: Public -// Description: Returns true if the function is virtual, for whatever -// that's worth. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the function is virtual, for whatever that's worth. + */ INLINE bool InterrogateFunction:: is_virtual() const { return (_flags & F_virtual) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::is_method -// Access: Public -// Description: Returns true if the function is a class method. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the function is a class method. + */ INLINE bool InterrogateFunction:: is_method() const { return (_flags & F_method) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::is_unary_op -// Access: Public -// Description: Returns true if the function is flagged as a special -// unary operator, like operator -() with no parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the function is flagged as a special unary operator, like + * operator -() with no parameters. + */ INLINE bool InterrogateFunction:: is_unary_op() const { return (_flags & F_unary_op) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::is_operator_typecast -// Access: Public -// Description: Returns true if the function is a special typecast -// operator, like operator bool(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the function is a special typecast operator, like operator + * bool(). + */ INLINE bool InterrogateFunction:: is_operator_typecast() const { return (_flags & F_operator_typecast) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_class -// Access: Public -// Description: Return the class that owns the method, if is_method() -// returns true. -//////////////////////////////////////////////////////////////////// +/** + * Return the class that owns the method, if is_method() returns true. + */ INLINE TypeIndex InterrogateFunction:: get_class() const { return _class; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::has_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunction:: has_scoped_name() const { return !_scoped_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunction:: get_scoped_name() const { return _scoped_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::has_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunction:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunction:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::has_prototype -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunction:: has_prototype() const { return !_prototype.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_prototype -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunction:: get_prototype() const { return _prototype; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::number_of_c_wrappers -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateFunction:: number_of_c_wrappers() const { return _c_wrappers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_c_wrapper -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionWrapperIndex InterrogateFunction:: get_c_wrapper(int n) const { if (n >= 0 && n < (int)_c_wrappers.size()) { @@ -162,21 +129,17 @@ get_c_wrapper(int n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::number_of_python_wrappers -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateFunction:: number_of_python_wrappers() const { return _python_wrappers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::get_python_wrapper -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionWrapperIndex InterrogateFunction:: get_python_wrapper(int n) const { if (n >= 0 && n < (int)_python_wrappers.size()) { diff --git a/dtool/src/interrogatedb/interrogateFunction.cxx b/dtool/src/interrogatedb/interrogateFunction.cxx index 62af522401..6510f86fc9 100644 --- a/dtool/src/interrogatedb/interrogateFunction.cxx +++ b/dtool/src/interrogatedb/interrogateFunction.cxx @@ -1,27 +1,24 @@ -// Filename: interrogateFunction.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunction.cxx + * @author drose + * @date 2000-08-01 + */ #include "interrogateFunction.h" #include "indexRemapper.h" #include "interrogate_datafile.h" #include "interrogateDatabase.h" -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterrogateFunction:: InterrogateFunction(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -31,21 +28,17 @@ InterrogateFunction(InterrogateModuleDef *def) : _instances = (Instances *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterrogateFunction:: InterrogateFunction(const InterrogateFunction ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateFunction:: operator = (const InterrogateFunction ©) { InterrogateComponent::operator = (copy); @@ -61,12 +54,9 @@ operator = (const InterrogateFunction ©) { _expression = copy._expression; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::output -// Access: Public -// Description: Formats the InterrogateFunction data for output to a data -// file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateFunction data for output to a data file. + */ void InterrogateFunction:: output(ostream &out) const { InterrogateComponent::output(out); @@ -79,12 +69,9 @@ output(ostream &out) const { idf_output_string(out, _prototype, '\n'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateFunction:: input(istream &in) { InterrogateComponent::input(in); @@ -96,13 +83,10 @@ input(istream &in) { idf_input_string(in, _prototype); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunction::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateFunction:: remap_indices(const IndexRemapper &remap) { _class = remap.map_from(_class); diff --git a/dtool/src/interrogatedb/interrogateFunction.h b/dtool/src/interrogatedb/interrogateFunction.h index 04132814f8..312f69a97e 100644 --- a/dtool/src/interrogatedb/interrogateFunction.h +++ b/dtool/src/interrogatedb/interrogateFunction.h @@ -1,16 +1,15 @@ -// Filename: interrogateFunction.h -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunction.h + * @author drose + * @date 2000-08-01 + */ #ifndef INTERROGATEFUNCTION_H #define INTERROGATEFUNCTION_H @@ -25,10 +24,9 @@ class IndexRemapper; class CPPInstance; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateFunction -// Description : An internal representation of a function. -//////////////////////////////////////////////////////////////////// +/** + * An internal representation of a function. + */ class EXPCL_INTERROGATEDB InterrogateFunction : public InterrogateComponent { public: InterrogateFunction(InterrogateModuleDef *def = NULL); @@ -85,15 +83,15 @@ private: Wrappers _python_wrappers; public: - // The rest of the members in this class aren't part of the public - // interface to interrogate, but are used internally as the - // interrogate database is built. They are valid only during the - // session of interrogate that generates the database, and will not - // be filled in when the database is reloaded from disk. + // The rest of the members in this class aren't part of the public interface + // to interrogate, but are used internally as the interrogate database is + // built. They are valid only during the session of interrogate that + // generates the database, and will not be filled in when the database is + // reloaded from disk. - // This must be a pointer, rather than a concrete map, so we don't - // risk trying to create a map in one DLL and access it in another. - // Silly Windows. + // This must be a pointer, rather than a concrete map, so we don't risk + // trying to create a map in one DLL and access it in another. Silly + // Windows. typedef map Instances; Instances *_instances; string _expression; diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.I b/dtool/src/interrogatedb/interrogateFunctionWrapper.I index b504a1a088..955800e5c1 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.I +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.I @@ -1,23 +1,19 @@ -// Filename: interrogateFunctionWrapper.I -// Created by: drose (06Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunctionWrapper.I + * @author drose + * @date 2000-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateFunctionWrapper:: InterrogateFunctionWrapper(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -28,21 +24,17 @@ InterrogateFunctionWrapper(InterrogateModuleDef *def) : _return_value_destructor = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateFunctionWrapper:: InterrogateFunctionWrapper(const InterrogateFunctionWrapper ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void InterrogateFunctionWrapper:: operator = (const InterrogateFunctionWrapper ©) { InterrogateComponent::operator = (copy); @@ -55,82 +47,65 @@ operator = (const InterrogateFunctionWrapper ©) { _parameters = copy._parameters; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::get_function -// Access: Public -// Description: Returns the FunctionIndex of the function that this -// wrapper corresponds to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FunctionIndex of the function that this wrapper corresponds to. + */ INLINE FunctionIndex InterrogateFunctionWrapper:: get_function() const { return _function; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::is_callable_by_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: is_callable_by_name() const { return (_flags & F_callable_by_name) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::has_return_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: has_return_value() const { return (_flags & F_has_return) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::get_return_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateFunctionWrapper:: get_return_type() const { return _return_type; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::caller_manages_return_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: caller_manages_return_value() const { return (_flags & F_caller_manages) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::get_return_value_destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateFunctionWrapper:: get_return_value_destructor() const { return _return_value_destructor; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::number_of_parameters -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateFunctionWrapper:: number_of_parameters() const { return _parameters.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::parameter_get_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateFunctionWrapper:: parameter_get_type(int n) const { if (n >= 0 && n < (int)_parameters.size()) { @@ -139,11 +114,9 @@ parameter_get_type(int n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::parameter_has_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: parameter_has_name(int n) const { if (n >= 0 && n < (int)_parameters.size()) { @@ -152,11 +125,9 @@ parameter_has_name(int n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::parameter_get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunctionWrapper:: parameter_get_name(int n) const { static string bogus_string; @@ -166,11 +137,9 @@ parameter_get_name(int n) const { return bogus_string; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::parameter_is_this -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: parameter_is_this(int n) const { if (n >= 0 && n < (int)_parameters.size()) { @@ -179,31 +148,25 @@ parameter_is_this(int n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::get_unique_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunctionWrapper:: get_unique_name() const { return _unique_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::has_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateFunctionWrapper:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::get_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateFunctionWrapper:: get_comment() const { return _comment; @@ -232,4 +195,3 @@ operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p) { p.input(in); return in; } - diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx index 185f93e29a..3cb143a2f3 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.cxx @@ -1,16 +1,15 @@ -// Filename: interrogateFunctionWrapper.cxx -// Created by: drose (06Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunctionWrapper.cxx + * @author drose + * @date 2000-08-06 + */ #include "interrogateFunctionWrapper.h" #include "indexRemapper.h" @@ -18,34 +17,27 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::Parameter::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateFunctionWrapper::Parameter:: output(ostream &out) const { idf_output_string(out, _name); out << _parameter_flags << " " << _type << " "; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::Parameter::input -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateFunctionWrapper::Parameter:: input(istream &in) { idf_input_string(in, _name); in >> _parameter_flags >> _type; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::output -// Access: Public -// Description: Formats the InterrogateFunctionWrapper data for -// output to a data file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateFunctionWrapper data for output to a data file. + */ void InterrogateFunctionWrapper:: output(ostream &out) const { InterrogateComponent::output(out); @@ -58,12 +50,9 @@ output(ostream &out) const { idf_output_vector(out, _parameters); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateFunctionWrapper:: input(istream &in) { InterrogateComponent::input(in); @@ -76,13 +65,10 @@ input(istream &in) { idf_input_vector(in, _parameters); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateFunctionWrapper::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateFunctionWrapper:: remap_indices(const IndexRemapper &remap) { _return_value_destructor = remap.map_from(_return_value_destructor); diff --git a/dtool/src/interrogatedb/interrogateFunctionWrapper.h b/dtool/src/interrogatedb/interrogateFunctionWrapper.h index 282b989961..511e8c6263 100644 --- a/dtool/src/interrogatedb/interrogateFunctionWrapper.h +++ b/dtool/src/interrogatedb/interrogateFunctionWrapper.h @@ -1,16 +1,15 @@ -// Filename: interrogateFunctionWrapper.h -// Created by: drose (06Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateFunctionWrapper.h + * @author drose + * @date 2000-08-06 + */ #ifndef INTERROGATEFUNCTIONWRAPPER_H #define INTERROGATEFUNCTIONWRAPPER_H @@ -23,10 +22,9 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateFunctionWrapper -// Description : An internal representation of a callable function. -//////////////////////////////////////////////////////////////////// +/** + * An internal representation of a callable function. + */ class EXPCL_INTERROGATEDB InterrogateFunctionWrapper : public InterrogateComponent { public: INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL); @@ -78,9 +76,9 @@ private: string _comment; public: - // This nested class must be declared public just so we can declare - // the external ostream and istream I/O operator functions, on the - // SGI compiler. Arguably a compiler bug, but what can you do. + // This nested class must be declared public just so we can declare the + // external ostream and istream IO operator functions, on the SGI compiler. + // Arguably a compiler bug, but what can you do. class Parameter { public: void output(ostream &out) const; diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.I b/dtool/src/interrogatedb/interrogateMakeSeq.I index 3a44cc8688..dde5247912 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.I +++ b/dtool/src/interrogatedb/interrogateMakeSeq.I @@ -1,23 +1,19 @@ -// Filename: interrogateMakeSeq.I -// Created by: drose (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateMakeSeq.I + * @author drose + * @date 2009-09-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateMakeSeq:: InterrogateMakeSeq(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -26,21 +22,17 @@ InterrogateMakeSeq(InterrogateModuleDef *def) : _element_getter = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateMakeSeq:: InterrogateMakeSeq(const InterrogateMakeSeq ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void InterrogateMakeSeq:: operator = (const InterrogateMakeSeq ©) { InterrogateComponent::operator = (copy); @@ -50,61 +42,49 @@ operator = (const InterrogateMakeSeq ©) { _element_getter = copy._element_getter; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::has_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateMakeSeq:: has_scoped_name() const { return !_scoped_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::get_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateMakeSeq:: get_scoped_name() const { return _scoped_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::has_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateMakeSeq:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::get_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateMakeSeq:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::get_length_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateMakeSeq:: get_length_getter() const { return _length_getter; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::get_element_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateMakeSeq:: get_element_getter() const { return _element_getter; diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.cxx b/dtool/src/interrogatedb/interrogateMakeSeq.cxx index 99dec723ca..68f3f5999e 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.cxx +++ b/dtool/src/interrogatedb/interrogateMakeSeq.cxx @@ -1,27 +1,23 @@ -// Filename: interrogateMakeSeq.cxx -// Created by: drose (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateMakeSeq.cxx + * @author drose + * @date 2009-09-15 + */ #include "interrogateMakeSeq.h" #include "indexRemapper.h" #include "interrogate_datafile.h" -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::output -// Access: Public -// Description: Formats the InterrogateMakeSeq data for output to a data -// file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateMakeSeq data for output to a data file. + */ void InterrogateMakeSeq:: output(ostream &out) const { InterrogateComponent::output(out); @@ -31,12 +27,9 @@ output(ostream &out) const { idf_output_string(out, _comment, '\n'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateMakeSeq:: input(istream &in) { InterrogateComponent::input(in); @@ -46,13 +39,10 @@ input(istream &in) { idf_input_string(in, _comment); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateMakeSeq::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateMakeSeq:: remap_indices(const IndexRemapper &remap) { _length_getter = remap.map_from(_length_getter); diff --git a/dtool/src/interrogatedb/interrogateMakeSeq.h b/dtool/src/interrogatedb/interrogateMakeSeq.h index f6c3f4985b..6883e81126 100644 --- a/dtool/src/interrogatedb/interrogateMakeSeq.h +++ b/dtool/src/interrogatedb/interrogateMakeSeq.h @@ -1,16 +1,15 @@ -// Filename: interrogateMakeSeq.h -// Created by: drose (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateMakeSeq.h + * @author drose + * @date 2009-09-15 + */ #ifndef INTERROGATEMAKESEQ_H #define INTERROGATEMAKESEQ_H @@ -21,11 +20,9 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateMakeSeq -// Description : Represents a synthetic method created via the -// MAKE_SEQ() macro. -//////////////////////////////////////////////////////////////////// +/** + * Represents a synthetic method created via the MAKE_SEQ() macro. + */ class EXPCL_INTERROGATEDB InterrogateMakeSeq : public InterrogateComponent { public: INLINE InterrogateMakeSeq(InterrogateModuleDef *def = NULL); diff --git a/dtool/src/interrogatedb/interrogateManifest.I b/dtool/src/interrogatedb/interrogateManifest.I index dfe89e3dd7..877b28a98e 100644 --- a/dtool/src/interrogatedb/interrogateManifest.I +++ b/dtool/src/interrogatedb/interrogateManifest.I @@ -1,23 +1,19 @@ -// Filename: interrogateManifest.I -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateManifest.I + * @author drose + * @date 2000-08-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateManifest:: InterrogateManifest(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -28,21 +24,17 @@ InterrogateManifest(InterrogateModuleDef *def) : _getter = 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InterrogateManifest:: InterrogateManifest(const InterrogateManifest ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void InterrogateManifest:: operator = (const InterrogateManifest ©) { InterrogateComponent::operator = (copy); @@ -54,71 +46,57 @@ operator = (const InterrogateManifest ©) { } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::get_definition -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateManifest:: get_definition() const { return _definition; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::has_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateManifest:: has_type() const { return (_flags & F_has_type) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::get_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateManifest:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::has_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateManifest:: has_getter() const { return (_flags & F_has_getter) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::get_getter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateManifest:: get_getter() const { return _getter; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::has_int_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateManifest:: has_int_value() const { return (_flags & F_has_int_value) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::get_int_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateManifest:: get_int_value() const { return _int_value; diff --git a/dtool/src/interrogatedb/interrogateManifest.cxx b/dtool/src/interrogatedb/interrogateManifest.cxx index 50f2e4b41e..5257b85aaf 100644 --- a/dtool/src/interrogatedb/interrogateManifest.cxx +++ b/dtool/src/interrogatedb/interrogateManifest.cxx @@ -1,27 +1,23 @@ -// Filename: interrogateManifest.cxx -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateManifest.cxx + * @author drose + * @date 2000-08-11 + */ #include "interrogateManifest.h" #include "indexRemapper.h" #include "interrogate_datafile.h" -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::output -// Access: Public -// Description: Formats the InterrogateManifest data for output to a data -// file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateManifest data for output to a data file. + */ void InterrogateManifest:: output(ostream &out) const { InterrogateComponent::output(out); @@ -32,12 +28,9 @@ output(ostream &out) const { idf_output_string(out, _definition); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateManifest:: input(istream &in) { InterrogateComponent::input(in); @@ -45,13 +38,10 @@ input(istream &in) { idf_input_string(in, _definition); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateManifest::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateManifest:: remap_indices(const IndexRemapper &remap) { _type = remap.map_from(_type); diff --git a/dtool/src/interrogatedb/interrogateManifest.h b/dtool/src/interrogatedb/interrogateManifest.h index 4011868953..49323a75c0 100644 --- a/dtool/src/interrogatedb/interrogateManifest.h +++ b/dtool/src/interrogatedb/interrogateManifest.h @@ -1,16 +1,15 @@ -// Filename: interrogateManifest.h -// Created by: drose (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateManifest.h + * @author drose + * @date 2000-08-11 + */ #ifndef INTERROGATEMANIFEST_H #define INTERROGATEMANIFEST_H @@ -21,10 +20,9 @@ class IndexRemapper; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateManifest -// Description : An internal representation of a manifest constant. -//////////////////////////////////////////////////////////////////// +/** + * An internal representation of a manifest constant. + */ class EXPCL_INTERROGATEDB InterrogateManifest : public InterrogateComponent { public: INLINE InterrogateManifest(InterrogateModuleDef *def = NULL); diff --git a/dtool/src/interrogatedb/interrogateType.I b/dtool/src/interrogatedb/interrogateType.I index 7dc101d6db..be8e40960f 100644 --- a/dtool/src/interrogatedb/interrogateType.I +++ b/dtool/src/interrogatedb/interrogateType.I @@ -1,277 +1,221 @@ -// Filename: interrogateType.I -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateType.I + * @author drose + * @date 2000-07-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_global -// Access: Public -// Description: Returns true if the type is marked as 'global'. This -// means only that it should appear in the global type -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is marked as 'global'. This means only that it + * should appear in the global type list. + */ INLINE bool InterrogateType:: is_global() const { return (_flags & F_global) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::has_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: has_scoped_name() const { return !_scoped_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_scoped_name() const { return _scoped_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::has_true_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: has_true_name() const { return !_true_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_true_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_true_name() const { return _true_name; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::has_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_nested -// Access: Public -// Description: Returns true if this type is nested within some class -// definition. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this type is nested within some class definition. + */ INLINE bool InterrogateType:: is_nested() const { return (_flags & F_nested) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_outer_class -// Access: Public -// Description: If is_nested() returns true, this is the class within -// which this type is defined. -//////////////////////////////////////////////////////////////////// +/** + * If is_nested() returns true, this is the class within which this type is + * defined. + */ INLINE TypeIndex InterrogateType:: get_outer_class() const { return _outer_class; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_atomic -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_atomic() const { return (_flags & F_atomic) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_atomic_token -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AtomicToken InterrogateType:: get_atomic_token() const { return _atomic_token; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_unsigned -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_unsigned() const { return (_flags & F_unsigned) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_signed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_signed() const { return (_flags & F_signed) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_long -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_long() const { return (_flags & F_long) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_longlong -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_longlong() const { return (_flags & F_longlong) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_short -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_short() const { return (_flags & F_short) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_wrapped -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_wrapped() const { return (_flags & F_wrapped) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_pointer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_pointer() const { return (_flags & F_pointer) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_const -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_const() const { return (_flags & F_const) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_typedef -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_typedef() const { return (_flags & F_typedef) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_wrapped_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateType:: get_wrapped_type() const { return _wrapped_type; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_array -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_array() const { return (_flags & F_array) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_array_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: get_array_size() const { return _array_size; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_enum -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_enum() const { return (_flags & F_enum) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_enum_values -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_enum_values() const { return _enum_values.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_enum_value_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_enum_value_name(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { @@ -280,11 +224,9 @@ get_enum_value_name(int n) const { return _empty_string; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_enum_value_scoped_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_enum_value_scoped_name(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { @@ -293,11 +235,9 @@ get_enum_value_scoped_name(int n) const { return _empty_string; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_enum_value_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &InterrogateType:: get_enum_value_comment(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { @@ -306,11 +246,9 @@ get_enum_value_comment(int n) const { return _empty_string; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_enum_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: get_enum_value(int n) const { if (n >= 0 && n < (int)_enum_values.size()) { @@ -319,74 +257,59 @@ get_enum_value(int n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_struct -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_struct() const { return (_flags & F_struct) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_class -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_class() const { return (_flags & F_class) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_union -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_union() const { return (_flags & F_union) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_fully_defined -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: is_fully_defined() const { return (_flags & F_fully_defined) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::is_unpublished -// Access: Public -// Description: Returns true if the type is an unpublished type. -// This either means the type is a nested type, and it -// is protected or private within its scope, or that its -// definition is simply not marked as 'published'. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the type is an unpublished type. This either means the + * type is a nested type, and it is protected or private within its scope, or + * that its definition is simply not marked as 'published'. + */ INLINE bool InterrogateType:: is_unpublished() const { return (_flags & F_unpublished) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_constructors -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_constructors() const { return _constructors.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateType:: get_constructor(int n) const { if (n >= 0 && n < (int)_constructors.size()) { @@ -396,51 +319,41 @@ get_constructor(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::has_destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: has_destructor() const { return (_destructor != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::destructor_is_inherited -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: destructor_is_inherited() const { return (_flags & F_inherited_destructor) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateType:: get_destructor() const { return _destructor; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_elements -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_elements() const { return _elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_element -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ElementIndex InterrogateType:: get_element(int n) const { if (n >= 0 && n < (int)_elements.size()) { @@ -450,21 +363,17 @@ get_element(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_methods -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_methods() const { return _methods.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_method -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateType:: get_method(int n) const { if (n >= 0 && n < (int)_methods.size()) { @@ -474,21 +383,17 @@ get_method(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_make_seqs -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_make_seqs() const { return _make_seqs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_make_seq -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MakeSeqIndex InterrogateType:: get_make_seq(int n) const { if (n >= 0 && n < (int)_make_seqs.size()) { @@ -498,21 +403,17 @@ get_make_seq(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_casts -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_casts() const { return _casts.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_cast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FunctionIndex InterrogateType:: get_cast(int n) const { if (n >= 0 && n < (int)_casts.size()) { @@ -522,21 +423,17 @@ get_cast(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_derivations -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_derivations() const { return _derivations.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_derivation -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateType:: get_derivation(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -546,11 +443,9 @@ get_derivation(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::derivation_has_upcast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: derivation_has_upcast(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -560,11 +455,9 @@ derivation_has_upcast(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::derivation_get_upcast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateType:: derivation_get_upcast(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -574,11 +467,9 @@ derivation_get_upcast(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::derivation_downcast_is_impossible -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: derivation_downcast_is_impossible(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -588,11 +479,9 @@ derivation_downcast_is_impossible(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::derivation_has_downcast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool InterrogateType:: derivation_has_downcast(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -602,11 +491,9 @@ derivation_has_downcast(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::derivation_get_downcast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateType:: derivation_get_downcast(int n) const { if (n >= 0 && n < (int)_derivations.size()) { @@ -616,21 +503,17 @@ derivation_get_downcast(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::number_of_nested_types -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int InterrogateType:: number_of_nested_types() const { return _nested_types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::get_nested_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypeIndex InterrogateType:: get_nested_type(int n) const { if (n >= 0 && n < (int)_nested_types.size()) { @@ -675,4 +558,3 @@ operator >> (istream &in, InterrogateType::EnumValue &ev) { ev.input(in); return in; } - diff --git a/dtool/src/interrogatedb/interrogateType.cxx b/dtool/src/interrogatedb/interrogateType.cxx index 57618c6734..a977ff987a 100644 --- a/dtool/src/interrogatedb/interrogateType.cxx +++ b/dtool/src/interrogatedb/interrogateType.cxx @@ -1,16 +1,15 @@ -// Filename: interrogateType.cxx -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateType.cxx + * @author drose + * @date 2000-07-31 + */ #include "interrogateType.h" #include "indexRemapper.h" @@ -19,11 +18,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterrogateType:: InterrogateType(InterrogateModuleDef *def) : InterrogateComponent(def) @@ -39,41 +36,33 @@ InterrogateType(InterrogateModuleDef *def) : _cppscope = (CPPScope *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InterrogateType:: InterrogateType(const InterrogateType ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::Derivation::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateType::Derivation:: output(ostream &out) const { out << _flags << " " << _base << " " << _upcast << " " << _downcast; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::Derivation::input -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateType::Derivation:: input(istream &in) { in >> _flags >> _base >> _upcast >> _downcast; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::EnumValue::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateType::EnumValue:: output(ostream &out) const { idf_output_string(out, _name); @@ -82,11 +71,9 @@ output(ostream &out) const { out << _value; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::EnumValue::input -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateType::EnumValue:: input(istream &in) { idf_input_string(in, _name); @@ -95,11 +82,9 @@ input(istream &in) { in >> _value; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InterrogateType:: operator = (const InterrogateType ©) { InterrogateComponent::operator = (copy); @@ -125,17 +110,14 @@ operator = (const InterrogateType ©) { _cppscope = copy._cppscope; } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::merge_with -// Access: Public -// Description: Combines type with the other similar definition. If -// one type is "fully defined" and the other one isn't, -// the fully-defined type wins. -//////////////////////////////////////////////////////////////////// +/** + * Combines type with the other similar definition. If one type is "fully + * defined" and the other one isn't, the fully-defined type wins. + */ void InterrogateType:: merge_with(const InterrogateType &other) { - // The only thing we care about copying from the non-fully-defined - // type right now is the global flag. + // The only thing we care about copying from the non-fully-defined type + // right now is the global flag. if (is_fully_defined()) { // We win. @@ -149,12 +131,9 @@ merge_with(const InterrogateType &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::output -// Access: Public -// Description: Formats the InterrogateType data for output to a data -// file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the InterrogateType data for output to a data file. + */ void InterrogateType:: output(ostream &out) const { InterrogateComponent::output(out); @@ -182,12 +161,9 @@ output(ostream &out) const { idf_output_string(out, _comment, '\n'); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::input -// Access: Public -// Description: Reads the data file as previously formatted by -// output(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the data file as previously formatted by output(). + */ void InterrogateType:: input(istream &in) { InterrogateComponent::input(in); @@ -219,13 +195,10 @@ input(istream &in) { idf_input_string(in, _comment); } -//////////////////////////////////////////////////////////////////// -// Function: InterrogateType::remap_indices -// Access: Public -// Description: Remaps all internal index numbers according to the -// indicated map. This called from -// InterrogateDatabase::remap_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Remaps all internal index numbers according to the indicated map. This + * called from InterrogateDatabase::remap_indices(). + */ void InterrogateType:: remap_indices(const IndexRemapper &remap) { _outer_class = remap.map_from(_outer_class); diff --git a/dtool/src/interrogatedb/interrogateType.h b/dtool/src/interrogatedb/interrogateType.h index 5a6a88b311..3887569694 100644 --- a/dtool/src/interrogatedb/interrogateType.h +++ b/dtool/src/interrogatedb/interrogateType.h @@ -1,16 +1,15 @@ -// Filename: interrogateType.h -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogateType.h + * @author drose + * @date 2000-07-31 + */ #ifndef INTERROGATETYPE_H #define INTERROGATETYPE_H @@ -25,10 +24,9 @@ class IndexRemapper; class CPPType; class CPPScope; -//////////////////////////////////////////////////////////////////// -// Class : InterrogateType -// Description : An internal representation of a type. -//////////////////////////////////////////////////////////////////// +/** + * An internal representation of a type. + */ class EXPCL_INTERROGATEDB InterrogateType : public InterrogateComponent { public: InterrogateType(InterrogateModuleDef *def = NULL); @@ -170,9 +168,9 @@ public: }; public: - // This nested class must be declared public just so we can declare - // the external ostream and istream I/O operator functions, on the - // SGI compiler. Arguably a compiler bug, but what can you do. + // This nested class must be declared public just so we can declare the + // external ostream and istream IO operator functions, on the SGI compiler. + // Arguably a compiler bug, but what can you do. class Derivation { public: void output(ostream &out) const; @@ -209,11 +207,11 @@ private: Types _nested_types; public: - // The rest of the members in this class aren't part of the public - // interface to interrogate, but are used internally as the - // interrogate database is built. They are valid only during the - // session of interrogate that generates the database, and will not - // be filled in when the database is reloaded from disk. + // The rest of the members in this class aren't part of the public interface + // to interrogate, but are used internally as the interrogate database is + // built. They are valid only during the session of interrogate that + // generates the database, and will not be filled in when the database is + // reloaded from disk. CPPType *_cpptype; CPPScope *_cppscope; diff --git a/dtool/src/interrogatedb/interrogate_datafile.I b/dtool/src/interrogatedb/interrogate_datafile.I index b5a708a823..9111260237 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.I +++ b/dtool/src/interrogatedb/interrogate_datafile.I @@ -1,24 +1,20 @@ -// Filename: interrogate_datafile.I -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_datafile.I + * @author drose + * @date 2000-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: idf_output_vector -// Description: Writes the indicated vector to the output file. Each -// component is written using its normal ostream output -// operator. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated vector to the output file. Each component is written + * using its normal ostream output operator. + */ template void idf_output_vector(ostream &out, const vector &vec) { @@ -30,13 +26,11 @@ idf_output_vector(ostream &out, const vector &vec) { } -//////////////////////////////////////////////////////////////////// -// Function: idf_input_vector -// Description: Reads the given vector from the input file, as -// previously written by output_string(). Each -// component is read using its normal istream input -// operator. -//////////////////////////////////////////////////////////////////// +/** + * Reads the given vector from the input file, as previously written by + * output_string(). Each component is read using its normal istream input + * operator. + */ template void idf_input_vector(istream &in, vector &vec) { diff --git a/dtool/src/interrogatedb/interrogate_datafile.cxx b/dtool/src/interrogatedb/interrogate_datafile.cxx index 5d3870acee..eb5c0ca57f 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.cxx +++ b/dtool/src/interrogatedb/interrogate_datafile.cxx @@ -1,26 +1,23 @@ -// Filename: interrogate_datafile.cxx -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_datafile.cxx + * @author drose + * @date 2000-08-09 + */ #include "interrogate_datafile.h" -//////////////////////////////////////////////////////////////////// -// Function: idf_output_string -// Description: Writes the indicated string to the output file. Uses -// the given whitespace character to separate the -// string's length and its contents. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated string to the output file. Uses the given whitespace + * character to separate the string's length and its contents. + */ void idf_output_string(ostream &out, const string &str, char whitespace) { out << str.length() << whitespace; @@ -29,11 +26,10 @@ idf_output_string(ostream &out, const string &str, char whitespace) { } } -//////////////////////////////////////////////////////////////////// -// Function: idf_input_string -// Description: Reads the given string from the input file, as -// previously written by output_string(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the given string from the input file, as previously written by + * output_string(). + */ void idf_input_string(istream &in, string &str) { int length; @@ -51,12 +47,10 @@ idf_input_string(istream &in, string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: idf_output_string -// Description: Writes the indicated string to the output file. Uses -// the given whitespace character to separate the -// string's length and its contents. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated string to the output file. Uses the given whitespace + * character to separate the string's length and its contents. + */ void idf_output_string(ostream &out, const char *str, char whitespace) { if (str == (const char *)NULL) { @@ -69,11 +63,10 @@ idf_output_string(ostream &out, const char *str, char whitespace) { } } -//////////////////////////////////////////////////////////////////// -// Function: idf_input_string -// Description: Reads the given string from the input file, as -// previously written by output_string(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the given string from the input file, as previously written by + * output_string(). + */ void idf_input_string(istream &in, const char *&str) { int length; diff --git a/dtool/src/interrogatedb/interrogate_datafile.h b/dtool/src/interrogatedb/interrogate_datafile.h index 637c226e70..ecd2acbce0 100644 --- a/dtool/src/interrogatedb/interrogate_datafile.h +++ b/dtool/src/interrogatedb/interrogate_datafile.h @@ -1,22 +1,21 @@ -// Filename: interrogate_datafile.h -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_datafile.h + * @author drose + * @date 2000-08-09 + */ #ifndef INTERROGATE_DATAFILE_H #define INTERROGATE_DATAFILE_H -// This file defines some convenience functions for reading and -// writing the interrogate database files. +// This file defines some convenience functions for reading and writing the +// interrogate database files. #include "dtoolbase.h" #include diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 2c4634c9b3..bd5493fc39 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -1,16 +1,15 @@ -// Filename: interrogate_interface.cxx -// Created by: drose (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_interface.cxx + * @author drose + * @date 2000-07-31 + */ #include "interrogate_interface.h" #include "interrogateDatabase.h" @@ -18,261 +17,262 @@ #include "interrogateFunction.h" #include "config_interrogatedb.h" -// This function adds one more directory to the list of directories -// search for interrogate (*.in) files. In the past, this list has -// been defined the environment variable ETC_PATH, but now it is -// passed in by the code generator. -void +// This function adds one more directory to the list of directories search for +// interrogate (*.in) files. In the past, this list has been defined the +// environment variable ETC_PATH, but now it is passed in by the code +// generator. +void interrogate_add_search_directory(const char *dirname) { - //cerr << "interrogate_add_search_directory(" << dirname << ")\n"; + // cerr << "interrogate_add_search_directory(" << dirname << ")\n"; interrogatedb_path.append_directory(Filename::from_os_specific(dirname)); } -// This function works similar to the above, but adds a complete path -// string--a list of multiple directories, separated by the standard -// delimiter--to the search path. -void +// This function works similar to the above, but adds a complete path string-- +// a list of multiple directories, separated by the standard delimiter--to the +// search path. +void interrogate_add_search_path(const char *pathstring) { - //cerr << "interrogate_add_search_path(" << pathstring << ")\n"; + // cerr << "interrogate_add_search_path(" << pathstring << ")\n"; interrogatedb_path.append_path(pathstring); } bool interrogate_error_flag() { - //cerr << "interrogate_error_flag\n"; + // cerr << "interrogate_error_flag\n"; return InterrogateDatabase::get_ptr()->get_error_flag(); } int interrogate_number_of_manifests() { - //cerr << "interrogate_number_of_manifests\n"; + // cerr << "interrogate_number_of_manifests\n"; return InterrogateDatabase::get_ptr()->get_num_global_manifests(); } ManifestIndex interrogate_get_manifest(int n) { - //cerr << "interrogate_get_manifest(" << n << ")\n"; + // cerr << "interrogate_get_manifest(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_global_manifest(n); } ManifestIndex interrogate_get_manifest_by_name(const char *manifest_name) { - //cerr << "interrogate_get_manifest_by_name(" << manifest_name << ")\n"; + // cerr << "interrogate_get_manifest_by_name(" << manifest_name << ")\n"; return InterrogateDatabase::get_ptr()->lookup_manifest_by_name(manifest_name); } const char * interrogate_manifest_name(ManifestIndex manifest) { - //cerr << "interrogate_manifest_name(" << manifest << ")\n"; + // cerr << "interrogate_manifest_name(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).get_name().c_str(); } const char * interrogate_manifest_definition(ManifestIndex manifest) { - //cerr << "interrogate_manifest_definition(" << manifest << ")\n"; + // cerr << "interrogate_manifest_definition(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).get_definition().c_str(); } bool interrogate_manifest_has_type(ManifestIndex manifest) { - //cerr << "interrogate_manifest_has_type(" << manifest << ")\n"; + // cerr << "interrogate_manifest_has_type(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).has_type(); } TypeIndex interrogate_manifest_get_type(ManifestIndex manifest) { - //cerr << "interrogate_manifest_get_type(" << manifest << ")\n"; + // cerr << "interrogate_manifest_get_type(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).get_type(); } bool interrogate_manifest_has_getter(ManifestIndex manifest) { - //cerr << "interrogate_manifest_has_getter(" << manifest << ")\n"; + // cerr << "interrogate_manifest_has_getter(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).has_getter(); } FunctionIndex interrogate_manifest_getter(ManifestIndex manifest) { - //cerr << "interrogate_manifest_getter(" << manifest << ")\n"; + // cerr << "interrogate_manifest_getter(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).get_getter(); } bool interrogate_manifest_has_int_value(ManifestIndex manifest) { - //cerr << "interrogate_manifest_has_int_value(" << manifest << ")\n"; + // cerr << "interrogate_manifest_has_int_value(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).has_int_value(); } int interrogate_manifest_get_int_value(ManifestIndex manifest) { - //cerr << "interrogate_manifest_get_int_value(" << manifest << ")\n"; + // cerr << "interrogate_manifest_get_int_value(" << manifest << ")\n"; return InterrogateDatabase::get_ptr()->get_manifest(manifest).get_int_value(); } const char * interrogate_element_name(ElementIndex element) { - //cerr << "interrogate_element_name(" << element << ")\n"; + // cerr << "interrogate_element_name(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_name().c_str(); } const char * interrogate_element_scoped_name(ElementIndex element) { - //cerr << "interrogate_element_scoped_name(" << element << ")\n"; + // cerr << "interrogate_element_scoped_name(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_scoped_name().c_str(); } bool interrogate_element_has_comment(ElementIndex element) { - //cerr << "interrogate_element_has_comment(" << element << ")\n"; + // cerr << "interrogate_element_has_comment(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).has_comment(); } const char * interrogate_element_comment(ElementIndex element) { - //cerr << "interrogate_element_comment(" << element << ")\n"; + // cerr << "interrogate_element_comment(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_comment().c_str(); } ElementIndex interrogate_get_element_by_name(const char *element_name) { - //cerr << "interrogate_get_element_by_name(" << element_name << ")\n"; + // cerr << "interrogate_get_element_by_name(" << element_name << ")\n"; return InterrogateDatabase::get_ptr()->lookup_element_by_name(element_name); } ElementIndex interrogate_get_element_by_scoped_name(const char *element_name) { - //cerr << "interrogate_get_element_by_scoped_name(" << element_name << ")\n"; + // cerr << "interrogate_get_element_by_scoped_name(" << element_name << + // ")\n"; return InterrogateDatabase::get_ptr()->lookup_element_by_scoped_name(element_name); } TypeIndex interrogate_element_type(ElementIndex element) { - //cerr << "interrogate_element_type(" << element << ")\n"; + // cerr << "interrogate_element_type(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_type(); } bool interrogate_element_has_getter(ElementIndex element) { - //cerr << "interrogate_element_has_getter(" << element << ")\n"; + // cerr << "interrogate_element_has_getter(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).has_getter(); } FunctionIndex interrogate_element_getter(ElementIndex element) { - //cerr << "interrogate_element_getter(" << element << ")\n"; + // cerr << "interrogate_element_getter(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_getter(); } bool interrogate_element_has_setter(ElementIndex element) { - //cerr << "interrogate_element_has_setter(" << element << ")\n"; + // cerr << "interrogate_element_has_setter(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).has_setter(); } FunctionIndex interrogate_element_setter(ElementIndex element) { - //cerr << "interrogate_element_setter(" << element << ")\n"; + // cerr << "interrogate_element_setter(" << element << ")\n"; return InterrogateDatabase::get_ptr()->get_element(element).get_setter(); } int interrogate_number_of_globals() { - //cerr << "interrogate_number_of_globals()\n"; + // cerr << "interrogate_number_of_globals()\n"; return InterrogateDatabase::get_ptr()->get_num_global_elements(); } ElementIndex interrogate_get_global(int n) { - //cerr << "interrogate_get_global(" << n << ")\n"; + // cerr << "interrogate_get_global(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_global_element(n); } int interrogate_number_of_global_functions() { - //cerr << "interrogate_number_of_global_functions()\n"; + // cerr << "interrogate_number_of_global_functions()\n"; return InterrogateDatabase::get_ptr()->get_num_global_functions(); } FunctionIndex interrogate_get_global_function(int n) { - //cerr << "interrogate_get_global_function(" << n << ")\n"; + // cerr << "interrogate_get_global_function(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_global_function(n); } int interrogate_number_of_functions() { - //cerr << "interrogate_number_of_functions()\n"; + // cerr << "interrogate_number_of_functions()\n"; return InterrogateDatabase::get_ptr()->get_num_all_functions(); } FunctionIndex interrogate_get_function(int n) { - //cerr << "interrogate_get_function(" << n << ")\n"; + // cerr << "interrogate_get_function(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_all_function(n); } const char * interrogate_function_name(FunctionIndex function) { - //cerr << "interrogate_function_name(" << function << ")\n"; + // cerr << "interrogate_function_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_name().c_str(); } const char * interrogate_function_scoped_name(FunctionIndex function) { - //cerr << "interrogate_function_scoped_name(" << function << ")\n"; + // cerr << "interrogate_function_scoped_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_scoped_name().c_str(); } bool interrogate_function_has_comment(FunctionIndex function) { - //cerr << "interrogate_function_has_comment(" << function << ")\n"; + // cerr << "interrogate_function_has_comment(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).has_comment(); } const char * interrogate_function_comment(FunctionIndex function) { - //cerr << "interrogate_function_comment(" << function << ")\n"; + // cerr << "interrogate_function_comment(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_comment().c_str(); } const char * interrogate_function_prototype(FunctionIndex function) { - //cerr << "interrogate_function_prototype(" << function << ")\n"; + // cerr << "interrogate_function_prototype(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_prototype().c_str(); } bool interrogate_function_is_method(FunctionIndex function) { - //cerr << "interrogate_function_is_method(" << function << ")\n"; + // cerr << "interrogate_function_is_method(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).is_method(); } TypeIndex interrogate_function_class(FunctionIndex function) { - //cerr << "interrogate_function_class(" << function << ")\n"; + // cerr << "interrogate_function_class(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_class(); } bool interrogate_function_has_module_name(FunctionIndex function) { - //cerr << "interrogate_function_has_module_name(" << function << ")\n"; + // cerr << "interrogate_function_has_module_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).has_module_name(); } const char * interrogate_function_module_name(FunctionIndex function) { - //cerr << "interrogate_function_module_name(" << function << ")\n"; + // cerr << "interrogate_function_module_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_module_name(); } bool interrogate_function_has_library_name(FunctionIndex function) { - //cerr << "interrogate_function_has_library_name(" << function << ")\n"; + // cerr << "interrogate_function_has_library_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).has_library_name(); } const char * interrogate_function_library_name(FunctionIndex function) { - //cerr << "interrogate_function_library_name(" << function << ")\n"; + // cerr << "interrogate_function_library_name(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_library_name(); } @@ -280,37 +280,41 @@ interrogate_function_library_name(FunctionIndex function) { bool interrogate_function_is_virtual(FunctionIndex function) { - //cerr << "interrogate_function_is_virtual(" << function << ")\n"; + // cerr << "interrogate_function_is_virtual(" << function << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).is_virtual(); } int interrogate_function_number_of_c_wrappers(FunctionIndex function) { - //cerr << "interrogate_function_number_of_c_wrappers(" << function << ")\n"; + // cerr << "interrogate_function_number_of_c_wrappers(" << function << + // ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).number_of_c_wrappers(); } FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n) { - //cerr << "interrogate_function_c_wrapper(" << function << ", " << n << ")\n"; + // cerr << "interrogate_function_c_wrapper(" << function << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_c_wrapper(n); } int interrogate_function_number_of_python_wrappers(FunctionIndex function) { - //cerr << "interrogate_function_number_of_python_wrappers(" << function << ")\n"; + // cerr << "interrogate_function_number_of_python_wrappers(" << function << + // ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).number_of_python_wrappers(); } FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n) { - //cerr << "interrogate_function_python_wrapper(" << function << ", " << n << ")\n"; + // cerr << "interrogate_function_python_wrapper(" << function << ", " << n + // << ")\n"; return InterrogateDatabase::get_ptr()->get_function(function).get_python_wrapper(n); } const char * interrogate_wrapper_name(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_name(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_name(" << wrapper << ")\n"; static string result; result = InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_name(); return result.c_str(); @@ -318,91 +322,96 @@ interrogate_wrapper_name(FunctionWrapperIndex wrapper) { bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_is_callable_by_name(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_is_callable_by_name(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).is_callable_by_name(); } bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_has_comment(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_has_comment(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).has_comment(); } const char * interrogate_wrapper_comment(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_comment(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_comment(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_comment().c_str(); } bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_has_return_value(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_has_return_value(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).has_return_value(); } TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_return_type(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_return_type(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_return_type(); } bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_caller_manages_return_value(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_caller_manages_return_value(" << wrapper << + // ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).caller_manages_return_value(); } FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_return_value_destructor(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_return_value_destructor(" << wrapper << + // ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_return_value_destructor(); } int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_number_of_parameters(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_number_of_parameters(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).number_of_parameters(); } TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n) { - //cerr << "interrogate_wrapper_parameter_type(" << wrapper << ", " << n << ")\n"; + // cerr << "interrogate_wrapper_parameter_type(" << wrapper << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).parameter_get_type(n); } bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n) { - //cerr << "interrogate_wrapper_parameter_has_name(" << wrapper << ", " << n << ")\n"; + // cerr << "interrogate_wrapper_parameter_has_name(" << wrapper << ", " << n + // << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).parameter_has_name(n); } const char * interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n) { - //cerr << "interrogate_wrapper_parameter_name(" << wrapper << ", " << n << ")\n"; + // cerr << "interrogate_wrapper_parameter_name(" << wrapper << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).parameter_get_name(n).c_str(); } bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n) { - //cerr << "interrogate_wrapper_is_this(" << wrapper << ", " << n << ")\n"; + // cerr << "interrogate_wrapper_is_this(" << wrapper << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper(wrapper).parameter_is_this(n); } bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_has_pointer(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_has_pointer(" << wrapper << ")\n"; return (InterrogateDatabase::get_ptr()->get_fptr(wrapper) != (void *)NULL); } void * interrogate_wrapper_pointer(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_pointer(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_pointer(" << wrapper << ")\n"; return InterrogateDatabase::get_ptr()->get_fptr(wrapper); } const char * interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper) { - //cerr << "interrogate_wrapper_unique_name(" << wrapper << ")\n"; + // cerr << "interrogate_wrapper_unique_name(" << wrapper << ")\n"; static string result; result = InterrogateDatabase::get_ptr()->get_wrapper(wrapper).get_unique_name(); return result.c_str(); @@ -410,13 +419,14 @@ interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper) { FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name) { - //cerr << "interrogate_get_wrapper_by_unique_name(" << unique_name << ")\n"; + // cerr << "interrogate_get_wrapper_by_unique_name(" << unique_name << + // ")\n"; return InterrogateDatabase::get_ptr()->get_wrapper_by_unique_name(unique_name); } const char * interrogate_make_seq_seq_name(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_seq_name(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_seq_name(" << make_seq << ")\n"; static string result; result = InterrogateDatabase::get_ptr()->get_make_seq(make_seq).get_name(); return result.c_str(); @@ -424,7 +434,7 @@ interrogate_make_seq_seq_name(MakeSeqIndex make_seq) { const char * interrogate_make_seq_scoped_name(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_seq_name(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_seq_name(" << make_seq << ")\n"; static string result; result = InterrogateDatabase::get_ptr()->get_make_seq(make_seq).get_scoped_name(); return result.c_str(); @@ -432,26 +442,26 @@ interrogate_make_seq_scoped_name(MakeSeqIndex make_seq) { bool interrogate_make_seq_has_comment(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_has_comment(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_has_comment(" << make_seq << ")\n"; return InterrogateDatabase::get_ptr()->get_make_seq(make_seq).has_comment(); } const char * interrogate_make_seq_comment(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_comment(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_comment(" << make_seq << ")\n"; return InterrogateDatabase::get_ptr()->get_make_seq(make_seq).get_comment().c_str(); } const char * interrogate_make_seq_num_name(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_num_name(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_num_name(" << make_seq << ")\n"; FunctionIndex function = InterrogateDatabase::get_ptr()->get_make_seq(make_seq).get_length_getter(); return interrogate_function_name(function); } const char * interrogate_make_seq_element_name(MakeSeqIndex make_seq) { - //cerr << "interrogate_make_seq_element_name(" << make_seq << ")\n"; + // cerr << "interrogate_make_seq_element_name(" << make_seq << ")\n"; static string result; FunctionIndex function = InterrogateDatabase::get_ptr()->get_make_seq(make_seq).get_element_getter(); return interrogate_function_name(function); @@ -459,379 +469,387 @@ interrogate_make_seq_element_name(MakeSeqIndex make_seq) { int interrogate_number_of_global_types() { - //cerr << "interrogate_number_of_global_types()\n"; + // cerr << "interrogate_number_of_global_types()\n"; return InterrogateDatabase::get_ptr()->get_num_global_types(); } TypeIndex interrogate_get_global_type(int n) { - //cerr << "interrogate_get_global_type(" << n << ")\n"; + // cerr << "interrogate_get_global_type(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_global_type(n); } int interrogate_number_of_types() { - //cerr << "interrogate_number_of_types()\n"; + // cerr << "interrogate_number_of_types()\n"; return InterrogateDatabase::get_ptr()->get_num_all_types(); } TypeIndex interrogate_get_type(int n) { - //cerr << "interrogate_get_type(" << n << ")\n"; + // cerr << "interrogate_get_type(" << n << ")\n"; return InterrogateDatabase::get_ptr()->get_all_type(n); } TypeIndex interrogate_get_type_by_name(const char *type_name) { - //cerr << "interrogate_get_type_by_name(" << type_name << ")\n"; + // cerr << "interrogate_get_type_by_name(" << type_name << ")\n"; return InterrogateDatabase::get_ptr()->lookup_type_by_name(type_name); } TypeIndex interrogate_get_type_by_scoped_name(const char *type_name) { - //cerr << "interrogate_get_type_by_scoped_name(" << type_name << ")\n"; + // cerr << "interrogate_get_type_by_scoped_name(" << type_name << ")\n"; return InterrogateDatabase::get_ptr()->lookup_type_by_scoped_name(type_name); } TypeIndex interrogate_get_type_by_true_name(const char *type_name) { - //cerr << "interrogate_get_type_by_true_name(" << type_name << ")\n"; + // cerr << "interrogate_get_type_by_true_name(" << type_name << ")\n"; return InterrogateDatabase::get_ptr()->lookup_type_by_true_name(type_name); } const char * interrogate_type_name(TypeIndex type) { - //cerr << "interrogate_type_name(" << type << ")\n"; + // cerr << "interrogate_type_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_name().c_str(); } const char * interrogate_type_scoped_name(TypeIndex type) { - //cerr << "interrogate_type_scoped_name(" << type << ")\n"; + // cerr << "interrogate_type_scoped_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_scoped_name().c_str(); } const char * interrogate_type_true_name(TypeIndex type) { - //cerr << "interrogate_type_true_name(" << type << ")\n"; + // cerr << "interrogate_type_true_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_true_name().c_str(); } bool interrogate_type_is_nested(TypeIndex type) { - //cerr << "interrogate_type_is_nested(" << type << ")\n"; + // cerr << "interrogate_type_is_nested(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_nested(); } TypeIndex interrogate_type_outer_class(TypeIndex type) { - //cerr << "interrogate_type_outer_class(" << type << ")\n"; + // cerr << "interrogate_type_outer_class(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_outer_class(); } bool interrogate_type_has_comment(TypeIndex type) { - //cerr << "interrogate_type_has_comment(" << type << ")\n"; + // cerr << "interrogate_type_has_comment(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).has_comment(); } const char * interrogate_type_comment(TypeIndex type) { - //cerr << "interrogate_type_comment(" << type << ")\n"; + // cerr << "interrogate_type_comment(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_comment().c_str(); } bool interrogate_type_has_module_name(TypeIndex type) { - //cerr << "interrogate_type_has_module_name(" << type << ")\n"; + // cerr << "interrogate_type_has_module_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).has_module_name(); } const char * interrogate_type_module_name(TypeIndex type) { - //cerr << "interrogate_type_module_name(" << type << ")\n"; + // cerr << "interrogate_type_module_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_module_name(); } bool interrogate_type_has_library_name(TypeIndex type) { - //cerr << "interrogate_type_has_library_name(" << type << ")\n"; + // cerr << "interrogate_type_has_library_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).has_library_name(); } const char * interrogate_type_library_name(TypeIndex type) { - //cerr << "interrogate_type_library_name(" << type << ")\n"; + // cerr << "interrogate_type_library_name(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_library_name(); } bool interrogate_type_is_atomic(TypeIndex type) { - //cerr << "interrogate_type_is_atomic(" << type << ")\n"; + // cerr << "interrogate_type_is_atomic(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_atomic(); } AtomicToken interrogate_type_atomic_token(TypeIndex type) { - //cerr << "interrogate_type_atomic_token(" << type << ")\n"; + // cerr << "interrogate_type_atomic_token(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_atomic_token(); } bool interrogate_type_is_unsigned(TypeIndex type) { - //cerr << "interrogate_type_is_unsigned(" << type << ")\n"; + // cerr << "interrogate_type_is_unsigned(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_unsigned(); } bool interrogate_type_is_signed(TypeIndex type) { - //cerr << "interrogate_type_is_signed(" << type << ")\n"; + // cerr << "interrogate_type_is_signed(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_signed(); } bool interrogate_type_is_long(TypeIndex type) { - //cerr << "interrogate_type_is_long(" << type << ")\n"; + // cerr << "interrogate_type_is_long(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_long(); } bool interrogate_type_is_longlong(TypeIndex type) { - //cerr << "interrogate_type_is_longlong(" << type << ")\n"; + // cerr << "interrogate_type_is_longlong(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_longlong(); } bool interrogate_type_is_short(TypeIndex type) { - //cerr << "interrogate_type_is_short(" << type << ")\n"; + // cerr << "interrogate_type_is_short(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_short(); } bool interrogate_type_is_wrapped(TypeIndex type) { - //cerr << "interrogate_type_is_wrapped(" << type << ")\n"; + // cerr << "interrogate_type_is_wrapped(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_wrapped(); } bool interrogate_type_is_pointer(TypeIndex type) { - //cerr << "interrogate_type_is_pointer(" << type << ")\n"; + // cerr << "interrogate_type_is_pointer(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_pointer(); } bool interrogate_type_is_const(TypeIndex type) { - //cerr << "interrogate_type_is_const(" << type << ")\n"; + // cerr << "interrogate_type_is_const(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_const(); } bool interrogate_type_is_typedef(TypeIndex type) { - //cerr << "interrogate_type_is_typedef(" << type << ")\n"; + // cerr << "interrogate_type_is_typedef(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_typedef(); } TypeIndex interrogate_type_wrapped_type(TypeIndex type) { - //cerr << "interrogate_type_wrapped_type(" << type << ")\n"; + // cerr << "interrogate_type_wrapped_type(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_wrapped_type(); } bool interrogate_type_is_enum(TypeIndex type) { - //cerr << "interrogate_type_is_enum(" << type << ")\n"; + // cerr << "interrogate_type_is_enum(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_enum(); } int interrogate_type_number_of_enum_values(TypeIndex type) { - //cerr << "interrogate_type_number_of_enum_values(" << type << ")\n"; + // cerr << "interrogate_type_number_of_enum_values(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_enum_values(); } const char * interrogate_type_enum_value_name(TypeIndex type, int n) { - //cerr << "interrogate_type_enum_value_name(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_enum_value_name(" << type << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_enum_value_name(n).c_str(); } const char * interrogate_type_enum_value_scoped_name(TypeIndex type, int n) { - //cerr << "interrogate_type_enum_value_scoped_name(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_enum_value_scoped_name(" << type << ", " << n + // << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_enum_value_scoped_name(n).c_str(); } const char * interrogate_type_enum_value_comment(TypeIndex type, int n) { - //cerr << "interrogate_type_enum_value_comment(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_enum_value_comment(" << type << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_enum_value_comment(n).c_str(); } int interrogate_type_enum_value(TypeIndex type, int n) { - //cerr << "interrogate_type_enum_value(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_enum_value(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_enum_value(n); } bool interrogate_type_is_struct(TypeIndex type) { - //cerr << "interrogate_type_is_struct(" << type << ")\n"; + // cerr << "interrogate_type_is_struct(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_struct(); } bool interrogate_type_is_class(TypeIndex type) { - //cerr << "interrogate_type_is_class(" << type << ")\n"; + // cerr << "interrogate_type_is_class(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_class(); } bool interrogate_type_is_union(TypeIndex type) { - //cerr << "interrogate_type_is_union(" << type << ")\n"; + // cerr << "interrogate_type_is_union(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_union(); } bool interrogate_type_is_fully_defined(TypeIndex type) { - //cerr << "interrogate_type_is_fully_defined(" << type << ")\n"; + // cerr << "interrogate_type_is_fully_defined(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_fully_defined(); } bool interrogate_type_is_unpublished(TypeIndex type) { - //cerr << "interrogate_type_is_unpublished(" << type << ")\n"; + // cerr << "interrogate_type_is_unpublished(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).is_unpublished(); } int interrogate_type_number_of_constructors(TypeIndex type) { - //cerr << "interrogate_type_number_of_constructors(" << type << ")\n"; + // cerr << "interrogate_type_number_of_constructors(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_constructors(); } FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n) { - //cerr << "interrogate_type_get_constructor(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_constructor(" << type << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_constructor(n); } bool interrogate_type_has_destructor(TypeIndex type) { - //cerr << "interrogate_type_has_destructor(" << type << ")\n"; + // cerr << "interrogate_type_has_destructor(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).has_destructor(); } bool interrogate_type_destructor_is_inherited(TypeIndex type) { - //cerr << "interrogate_type_destructor_is_inherited(" << type << ")\n"; + // cerr << "interrogate_type_destructor_is_inherited(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).destructor_is_inherited(); } FunctionIndex interrogate_type_get_destructor(TypeIndex type) { - //cerr << "interrogate_type_get_destructor(" << type << ")\n"; + // cerr << "interrogate_type_get_destructor(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_destructor(); } int interrogate_type_number_of_elements(TypeIndex type) { - //cerr << "interrogate_type_number_of_elements(" << type << ")\n"; + // cerr << "interrogate_type_number_of_elements(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_elements(); } ElementIndex interrogate_type_get_element(TypeIndex type, int n) { - //cerr << "interrogate_type_get_element(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_element(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_element(n); } int interrogate_type_number_of_methods(TypeIndex type) { - //cerr << "interrogate_type_number_of_methods(" << type << ")\n"; + // cerr << "interrogate_type_number_of_methods(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_methods(); } FunctionIndex interrogate_type_get_method(TypeIndex type, int n) { - //cerr << "interrogate_type_get_method(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_method(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_method(n); } int interrogate_type_number_of_make_seqs(TypeIndex type) { - //cerr << "interrogate_type_number_of_make_seqs(" << type << ")\n"; + // cerr << "interrogate_type_number_of_make_seqs(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_make_seqs(); } MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n) { - //cerr << "interrogate_type_get_make_seq(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_make_seq(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_make_seq(n); } int interrogate_type_number_of_casts(TypeIndex type) { - //cerr << "interrogate_type_number_of_casts(" << type << ")\n"; + // cerr << "interrogate_type_number_of_casts(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_casts(); } FunctionIndex interrogate_type_get_cast(TypeIndex type, int n) { - //cerr << "interrogate_type_get_cast(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_cast(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_cast(n); } int interrogate_type_number_of_derivations(TypeIndex type) { - //cerr << "interrogate_type_number_of_derivations(" << type << ")\n"; + // cerr << "interrogate_type_number_of_derivations(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_derivations(); } TypeIndex interrogate_type_get_derivation(TypeIndex type, int n) { - //cerr << "interrogate_type_get_derivation(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_derivation(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_derivation(n); } bool interrogate_type_derivation_has_upcast(TypeIndex type, int n) { - //cerr << "interrogate_type_derivation_has_upcast(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_derivation_has_upcast(" << type << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).derivation_has_upcast(n); } FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n) { - //cerr << "interrogate_type_get_upcast(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_upcast(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).derivation_get_upcast(n); } bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n) { - //cerr << "interrogate_type_derivation_downcast_is_impossible(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_derivation_downcast_is_impossible(" << type << + // ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).derivation_downcast_is_impossible(n); } bool interrogate_type_derivation_has_downcast(TypeIndex type, int n) { - //cerr << "interrogate_type_derivation_has_downcast(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_derivation_has_downcast(" << type << ", " << n + // << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).derivation_has_downcast(n); } FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n) { - //cerr << "interrogate_type_get_downcast(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_downcast(" << type << ", " << n << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).derivation_get_downcast(n); } int interrogate_type_number_of_nested_types(TypeIndex type) { - //cerr << "interrogate_type_number_of_nested_types(" << type << ")\n"; + // cerr << "interrogate_type_number_of_nested_types(" << type << ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).number_of_nested_types(); } TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n) { - //cerr << "interrogate_type_get_nested_type(" << type << ", " << n << ")\n"; + // cerr << "interrogate_type_get_nested_type(" << type << ", " << n << + // ")\n"; return InterrogateDatabase::get_ptr()->get_type(type).get_nested_type(n); } diff --git a/dtool/src/interrogatedb/interrogate_interface.h b/dtool/src/interrogatedb/interrogate_interface.h index 47fe98cd98..b3003be2fe 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -1,16 +1,15 @@ -// Filename: interrogate_interface.h -// Created by: frang (09Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_interface.h + * @author frang + * @date 1999-11-09 + */ #ifndef INTERROGATE_INTERFACE_H #define INTERROGATE_INTERFACE_H @@ -21,41 +20,41 @@ extern "C" { #endif -// This file defines the interface to the interrogate database. This -// database is generated by running interrogate on a package's source -// code; interrogate parses the C++ syntax, determines the public -// interface, generates C-style wrapper functions where necessary, and -// builds up a table of functions and classes and their relationships. +// This file defines the interface to the interrogate database. This database +// is generated by running interrogate on a package's source code; interrogate +// parses the C++ syntax, determines the public interface, generates C-style +// wrapper functions where necessary, and builds up a table of functions and +// classes and their relationships. -// Some of this data (in particular, the wrapper functions, and the -// table of unique names for these functions) is linked in along with -// the codebase, permanently a part of the library file, and is always -// available; the rest of it is stored in external files (named *.in) -// and read in when needed. For this reason, most of the interface -// functions defined here will force a load of the complete -// interrogate database the first time any of them are called. The -// three exceptions are noted below; they are -// interrogate_wrapper_has_pointer(), interrogate_wrapper_pointer(), -// and interrogate_get_wrapper_by_unique_name(). +/* + * Some of this data (in particular, the wrapper functions, and the table of + * unique names for these functions) is linked in along with the codebase, + * permanently a part of the library file, and is always available; the rest + * of it is stored in external files (named *.in) and read in when needed. + * For this reason, most of the interface functions defined here will force a + * load of the complete interrogate database the first time any of them are + * called. The three exceptions are noted below; they are + * interrogate_wrapper_has_pointer(), interrogate_wrapper_pointer(), and + * interrogate_get_wrapper_by_unique_name(). + */ -// The interface here is intentionally made to be as simple as -// possible, to maximize portability. All that is required of a -// scripting language is a foreign function interface capable of -// calling C functions. +// The interface here is intentionally made to be as simple as possible, to +// maximize portability. All that is required of a scripting language is a +// foreign function interface capable of calling C functions. // In general, the interrogate database consists of a number of query -// functions that allow the caller to walk through the list of -// available types, functions, manifests, etc. For each of these, a -// unique index number is returned; this index number may then be used -// to query details about the type, function, etc. The index numbers -// are only guaranteed to remain unchanged during a particular -// session; from one session to another they may differ. +// functions that allow the caller to walk through the list of available +// types, functions, manifests, etc. For each of these, a unique index number +// is returned; this index number may then be used to query details about the +// type, function, etc. The index numbers are only guaranteed to remain +// unchanged during a particular session; from one session to another they may +// differ. -// All index numbers are ordinary integers. Each has a unique typedef -// here for clarity of meaning, but they may be treated as ordinary -// integers by the caller. +// All index numbers are ordinary integers. Each has a unique typedef here +// for clarity of meaning, but they may be treated as ordinary integers by the +// caller. typedef int ManifestIndex; typedef int ElementIndex; typedef int TypeIndex; @@ -63,9 +62,9 @@ typedef int FunctionIndex; typedef int FunctionWrapperIndex; typedef int MakeSeqIndex; -// Atomic types are those that are built in to C. This enumerated -// value is returned by interrogate_type_atomic_token() when a type is -// known to be one of the atomic types. +// Atomic types are those that are built in to C. This enumerated value is +// returned by interrogate_type_atomic_token() when a type is known to be one +// of the atomic types. enum AtomicToken { AT_not_atomic = 0, AT_int = 1, @@ -75,13 +74,12 @@ enum AtomicToken { AT_char = 5, AT_void = 6, - // There isn't an atomic string type in C, but there is one in - // almost all other languages. If -string is supplied to the - // interrogate command line, functions may be reported as returning - // and accepting objects of type atomic string. For the C calling - // convention wrappers, atomic string means (const char *); for - // other calling convention wrappers, atomic string means whatever - // the native string representation is. + // There isn't an atomic string type in C, but there is one in almost all + // other languages. If -string is supplied to the interrogate command line, + // functions may be reported as returning and accepting objects of type + // atomic string. For the C calling convention wrappers, atomic string + // means (const char *); for other calling convention wrappers, atomic + // string means whatever the native string representation is. AT_string = 7, AT_longlong = 8 @@ -91,21 +89,18 @@ EXPCL_INTERROGATEDB void interrogate_add_search_directory(const char *dirname); EXPCL_INTERROGATEDB void interrogate_add_search_path(const char *pathstring); EXPCL_INTERROGATEDB bool interrogate_error_flag(); -//////////////////////////////////////////////////////////////////// -// // Manifest Symbols -// -//////////////////////////////////////////////////////////////////// -// These correspond to #define constants that appear in the C code. -// (These are only the manifest constants--those #define's that take -// no parameters. Manifest functions, #define's that take one or more -// parameters, are not exported.) They cannot be set, of course, but -// they often have a meaningful value that may be get. The scripting -// language may choose to get the value as a literal string via -// interrogate_manifest_definition(), or as a value of a particular type -// (whatever type interrogate thinks it is), as returned by the getter -// function given by interrogate_manifest_getter(). +/* + * These correspond to #define constants that appear in the C code. (These + * are only the manifest constants--those #define's that take no parameters. + * Manifest functions, #define's that take one or more parameters, are not + * exported.) They cannot be set, of course, but they often have a meaningful + * value that may be get. The scripting language may choose to get the value + * as a literal string via interrogate_manifest_definition(), or as a value of + * a particular type (whatever type interrogate thinks it is), as returned by + * the getter function given by interrogate_manifest_getter(). + */ EXPCL_INTERROGATEDB int interrogate_number_of_manifests(); EXPCL_INTERROGATEDB ManifestIndex interrogate_get_manifest(int n); @@ -117,24 +112,20 @@ EXPCL_INTERROGATEDB TypeIndex interrogate_manifest_get_type(ManifestIndex manife EXPCL_INTERROGATEDB bool interrogate_manifest_has_getter(ManifestIndex manifest); EXPCL_INTERROGATEDB FunctionIndex interrogate_manifest_getter(ManifestIndex manifest); -// An exception is made for manifest constants that have an integer -// type value, since these are so common. The scripting language can -// query these values directly, which saves having to generate a -// wrapper function for each stupid little manifest. In this case, -// there will be no getter function available. +// An exception is made for manifest constants that have an integer type +// value, since these are so common. The scripting language can query these +// values directly, which saves having to generate a wrapper function for each +// stupid little manifest. In this case, there will be no getter function +// available. EXPCL_INTERROGATEDB bool interrogate_manifest_has_int_value(ManifestIndex manifest); EXPCL_INTERROGATEDB int interrogate_manifest_get_int_value(ManifestIndex manifest); -//////////////////////////////////////////////////////////////////// -// // Data Elements -// -//////////////////////////////////////////////////////////////////// -// These correspond to data members of a class, or global data -// elements. Interrogate automatically generates a getter function -// and, if possible, a setter function. +// These correspond to data members of a class, or global data elements. +// Interrogate automatically generates a getter function and, if possible, a +// setter function. EXPCL_INTERROGATEDB const char *interrogate_element_name(ElementIndex element); EXPCL_INTERROGATEDB const char *interrogate_element_scoped_name(ElementIndex element); @@ -143,14 +134,14 @@ EXPCL_INTERROGATEDB const char *interrogate_element_comment(ElementIndex element EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_name(const char *element_name); EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_scoped_name(const char *element_name); -// Be careful with this function. The element's bare type is not -// likely to be directly useful to the scripting language. This is a -// different answer than the return value of the getter. +// Be careful with this function. The element's bare type is not likely to be +// directly useful to the scripting language. This is a different answer than +// the return value of the getter. -// The element type might well be something concrete that the -// scripting language can't handle directly, e.g. a Node, while the -// getter will return (and the setter accept) a pointer to a Node, -// which is what the scripting language actually works with. +// The element type might well be something concrete that the scripting +// language can't handle directly, e.g. a Node, while the getter will return +// (and the setter accept) a pointer to a Node, which is what the scripting +// language actually works with. EXPCL_INTERROGATEDB TypeIndex interrogate_element_type(ElementIndex element); EXPCL_INTERROGATEDB bool interrogate_element_has_getter(ElementIndex element); @@ -158,157 +149,140 @@ EXPCL_INTERROGATEDB FunctionIndex interrogate_element_getter(ElementIndex elemen EXPCL_INTERROGATEDB bool interrogate_element_has_setter(ElementIndex element); EXPCL_INTERROGATEDB FunctionIndex interrogate_element_setter(ElementIndex element); -//////////////////////////////////////////////////////////////////// -// // Global Data -// -//////////////////////////////////////////////////////////////////// // This is the list of global data elements. EXPCL_INTERROGATEDB int interrogate_number_of_globals(); EXPCL_INTERROGATEDB ElementIndex interrogate_get_global(int n); -//////////////////////////////////////////////////////////////////// -// // Functions -// -//////////////////////////////////////////////////////////////////// -// There is a unique FunctionIndex associated with each of the -// functions that interrogate knows about. This includes member -// functions, nonmember functions, synthesized getters and setters, -// and upcast/downcast functions. +// There is a unique FunctionIndex associated with each of the functions that +// interrogate knows about. This includes member functions, nonmember +// functions, synthesized getters and setters, and upcastdowncast functions. -// These are the global (nonmember) functions that appear outside of -// any class definition. +// These are the global (nonmember) functions that appear outside of any class +// definition. EXPCL_INTERROGATEDB int interrogate_number_of_global_functions(); EXPCL_INTERROGATEDB FunctionIndex interrogate_get_global_function(int n); // This can be used to traverse through *all* the functions known to -// interrogate. It's usually not what you want, since this includes -// global functions, class methods, and synthesized functions like -// upcasts and downcasts. You probably want to use instead +// interrogate. It's usually not what you want, since this includes global +// functions, class methods, and synthesized functions like upcasts and +// downcasts. You probably want to use instead // interrogate_number_of_global_functions(), above. EXPCL_INTERROGATEDB int interrogate_number_of_functions(); EXPCL_INTERROGATEDB FunctionIndex interrogate_get_function(int n); -// This is the function's name. It is not unique; it may be shared -// between multiple different functions that have the same name but -// different parameter types (this is C++'s function overloading). -// Two different classes might also have member functions that have -// the same name, or the same name as a global function (but also see -// the scoped_name, below). +// This is the function's name. It is not unique; it may be shared between +// multiple different functions that have the same name but different +// parameter types (this is C++'s function overloading). Two different classes +// might also have member functions that have the same name, or the same name +// as a global function (but also see the scoped_name, below). EXPCL_INTERROGATEDB const char *interrogate_function_name(FunctionIndex function); -// The scoped name is the function name prefixed with the name of the -// class that includes the function, if the function is a class -// method. If it is a global function, the scoped name is the same as -// the name returned above. In the absence of C++ function -// overloading, this name will be unique to each function. +// The scoped name is the function name prefixed with the name of the class +// that includes the function, if the function is a class method. If it is a +// global function, the scoped name is the same as the name returned above. +// In the absence of C++ function overloading, this name will be unique to +// each function. EXPCL_INTERROGATEDB const char *interrogate_function_scoped_name(FunctionIndex function); -// This returns the C++ comment written for the function, either in -// the header file or in the .C file, or both. +// This returns the C++ comment written for the function, either in the header +// file or in the .C file, or both. EXPCL_INTERROGATEDB bool interrogate_function_has_comment(FunctionIndex function); EXPCL_INTERROGATEDB const char *interrogate_function_comment(FunctionIndex function); -// This defines the function prototype as it appears in the C++ -// source, useful primarily for documentation purposes. +// This defines the function prototype as it appears in the C++ source, useful +// primarily for documentation purposes. EXPCL_INTERROGATEDB const char *interrogate_function_prototype(FunctionIndex function); -// This can be used to determine the class that the function is a -// method for, if the function is a class method. +// This can be used to determine the class that the function is a method for, +// if the function is a class method. EXPCL_INTERROGATEDB bool interrogate_function_is_method(FunctionIndex function); EXPCL_INTERROGATEDB TypeIndex interrogate_function_class(FunctionIndex function); -// This returns the module name reported for the function, if -// available. +// This returns the module name reported for the function, if available. EXPCL_INTERROGATEDB bool interrogate_function_has_module_name(FunctionIndex function); EXPCL_INTERROGATEDB const char *interrogate_function_module_name(FunctionIndex function); -// This returns the library name reported for the function, if -// available. +// This returns the library name reported for the function, if available. EXPCL_INTERROGATEDB bool interrogate_function_has_library_name(FunctionIndex function); EXPCL_INTERROGATEDB const char *interrogate_function_library_name(FunctionIndex function); -// This is true for virtual member functions. It's not likely that -// this will be important to the scripting language. +// This is true for virtual member functions. It's not likely that this will +// be important to the scripting language. EXPCL_INTERROGATEDB bool interrogate_function_is_virtual(FunctionIndex function); -// The actual callable function interface is defined via one or more -// wrappers for each function. (There might be multiple wrappers for -// the same function to allow for default parameter values.) +// The actual callable function interface is defined via one or more wrappers +// for each function. (There might be multiple wrappers for the same function +// to allow for default parameter values.) -// At present, interrogate can generate wrappers that use the C -// calling convention or the Python calling convention. The set of -// wrappers that will actually be available depends on the parameters -// passed to the interrogate command line. +// At present, interrogate can generate wrappers that use the C calling +// convention or the Python calling convention. The set of wrappers that will +// actually be available depends on the parameters passed to the interrogate +// command line. EXPCL_INTERROGATEDB int interrogate_function_number_of_c_wrappers(FunctionIndex function); EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n); EXPCL_INTERROGATEDB int interrogate_function_number_of_python_wrappers(FunctionIndex function); EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n); -//////////////////////////////////////////////////////////////////// -// // Function wrappers -// -//////////////////////////////////////////////////////////////////// -// These define the way to call a given function. Depending on the -// parameters supplied to interrogate, a function wrapper may be able -// to supply either a void * pointer to the function, or the name of -// the function in the library, or both. +// These define the way to call a given function. Depending on the parameters +// supplied to interrogate, a function wrapper may be able to supply either a +// void * pointer to the function, or the name of the function in the library, +// or both. -// This returns the actual name of the wrapper function, as opposed to -// the name of the function it wraps. It's probably not terribly -// useful to the scripting language, unless the -fnames option was -// given to interrogate, in which case this name may be used to call -// the wrapper function (see is_callable_by_name, below). It will -// usually be an ugly hashed name, not intended for human consumption. +// This returns the actual name of the wrapper function, as opposed to the +// name of the function it wraps. It's probably not terribly useful to the +// scripting language, unless the -fnames option was given to interrogate, in +// which case this name may be used to call the wrapper function (see +// is_callable_by_name, below). It will usually be an ugly hashed name, not +// intended for human consumption. -// Don't confuse this with the unique_name, below. The two are -// related, but not identical. +// Don't confuse this with the unique_name, below. The two are related, but +// not identical. EXPCL_INTERROGATEDB const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper); -// This returns true if -fnames was given to interrogate, making the -// wrapper function callable directly by its name. +// This returns true if -fnames was given to interrogate, making the wrapper +// function callable directly by its name. EXPCL_INTERROGATEDB bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper); -// This returns the C++ comment written for the function wrapper, -// usually from the .cpp file. There may be a different comment for -// each overload of a given function. +// This returns the C++ comment written for the function wrapper, usually from +// the .cpp file. There may be a different comment for each overload of a +// given function. EXPCL_INTERROGATEDB bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper); EXPCL_INTERROGATEDB const char *interrogate_wrapper_comment(FunctionWrapperIndex wrapper); -// Every function wrapper has zero or more parameters and may or may -// not have a return value. Each parameter has a type and may or may -// not have a name. For member functions, the first parameter may be -// a 'this' parameter, which should receive a pointer to the class -// object. (If a member function does not have a 'this' parameter as -// its first parameter, it is a static member function, also called a -// class method.) +// Every function wrapper has zero or more parameters and may or may not have +// a return value. Each parameter has a type and may or may not have a name. +// For member functions, the first parameter may be a 'this' parameter, which +// should receive a pointer to the class object. (If a member function does +// not have a 'this' parameter as its first parameter, it is a static member +// function, also called a class method.) EXPCL_INTERROGATEDB bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper); EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper); -// Sometimes interrogate must synthesize a wrapper that allocates its -// return value from the free store. Other times (especially if -// -refcount is supplied to interrogate), interrogate will -// automatically increment the count of a reference-counted object -// that it returns. In cases like these, -// interrogate_wrapper_caller_manages_return_value() will return true, -// and it is the responsibility of the scripting language to -// eventually call the destructor supplied by -// interrogate_wrapper_return_value_destructor() on this value when it -// is no longer needed (which will generally be the same destructor as -// that for the class). Otherwise, this function will return false, -// and the scripting language should *not* call any destructor on this -// value. +/* + * Sometimes interrogate must synthesize a wrapper that allocates its return + * value from the free store. Other times (especially if -refcount is + * supplied to interrogate), interrogate will automatically increment the + * count of a reference-counted object that it returns. In cases like these, + * interrogate_wrapper_caller_manages_return_value() will return true, and it + * is the responsibility of the scripting language to eventually call the + * destructor supplied by interrogate_wrapper_return_value_destructor() on + * this value when it is no longer needed (which will generally be the same + * destructor as that for the class). Otherwise, this function will return + * false, and the scripting language should *not* call any destructor on this + * value. + */ EXPCL_INTERROGATEDB bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper); EXPCL_INTERROGATEDB FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper); @@ -319,78 +293,68 @@ EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_has_name(FunctionWrapperI EXPCL_INTERROGATEDB const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n); EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n); -// This returns a pointer to a function that may be called to invoke -// the function, if the -fptrs option to return function pointers was -// specified to interrogate. Be sure to push the required parameters -// on the stack, according to the calling convention, before calling -// the function. +// This returns a pointer to a function that may be called to invoke the +// function, if the -fptrs option to return function pointers was specified to +// interrogate. Be sure to push the required parameters on the stack, +// according to the calling convention, before calling the function. -// These two functions may be called without forcing a load of the -// complete interrogate database. +// These two functions may be called without forcing a load of the complete +// interrogate database. EXPCL_INTERROGATEDB bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper); EXPCL_INTERROGATEDB void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper); -// This function will return a name that is guaranteed to be unique to -// this particular function wrapper, and that will (usually) be -// consistent across multiple runtime sessions. (It will only change -// between sessions if the database was regenerated in the interim -// with some new function that happened to introduce a hash conflict.) +// This function will return a name that is guaranteed to be unique to this +// particular function wrapper, and that will (usually) be consistent across +// multiple runtime sessions. (It will only change between sessions if the +// database was regenerated in the interim with some new function that +// happened to introduce a hash conflict.) -// The unique name is an ugly hashed name, not safe for human -// consumption. Its sole purpose is to provide some consistent way to -// identify function wrappers between sessions. +// The unique name is an ugly hashed name, not safe for human consumption. +// Its sole purpose is to provide some consistent way to identify function +// wrappers between sessions. EXPCL_INTERROGATEDB const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper); -// This function provides a reverse-lookup on the above unique name, -// returning the wrapper index corresponding to the given name. It -// depends on data having been compiled directly into the library, and -// thus is only available if the option -unique-names was given to -// interrogate. +// This function provides a reverse-lookup on the above unique name, returning +// the wrapper index corresponding to the given name. It depends on data +// having been compiled directly into the library, and thus is only available +// if the option -unique-names was given to interrogate. // This function may be called without forcing a load of the complete // interrogate database. EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name); -//////////////////////////////////////////////////////////////////// -// // MakeSeqs -// -//////////////////////////////////////////////////////////////////// -// These are special synthesized methods that iterate through a list. -// They are generated in C++ code via the MAKE_SEQ macro. The normal -// pattern is that a pair of actual C++ methods like get_num_things() -// and get_thing(n) are used to synthesize a new method called -// get_things(). +// These are special synthesized methods that iterate through a list. They +// are generated in C++ code via the MAKE_SEQ macro. The normal pattern is +// that a pair of actual C++ methods like get_num_things() and get_thing(n) +// are used to synthesize a new method called get_things(). EXPCL_INTERROGATEDB const char *interrogate_make_seq_seq_name(MakeSeqIndex make_seq); EXPCL_INTERROGATEDB const char *interrogate_make_seq_scoped_name(MakeSeqIndex make_seq); EXPCL_INTERROGATEDB bool interrogate_make_seq_has_comment(ElementIndex element); EXPCL_INTERROGATEDB const char *interrogate_make_seq_comment(ElementIndex element); -// The name of the real method that returns the length, e.g. "get_num_things" +// The name of the real method that returns the length, e.g. "get_num_things" EXPCL_INTERROGATEDB const char *interrogate_make_seq_num_name(MakeSeqIndex make_seq); -// The name of the real method that returns the nth element, e.g. "get_thing" +// The name of the real method that returns the nth element, e.g. "get_thing" EXPCL_INTERROGATEDB const char *interrogate_make_seq_element_name(MakeSeqIndex make_seq); -//////////////////////////////////////////////////////////////////// -// // Types -// -//////////////////////////////////////////////////////////////////// -// These are all the types that interrogate knows about. This -// includes atomic types like ints and floats, type wrappers like -// pointers and const pointers, enumerated types, and classes. +// These are all the types that interrogate knows about. This includes atomic +// types like ints and floats, type wrappers like pointers and const pointers, +// enumerated types, and classes. -// Two lists of types are maintained: the list of global types, which -// includes only those types intended to be wrapped in the API (for -// instance, all of the classes). The second list is the complete -// list of all types, which probably does not need to be -// traversed--this includes *all* types known to the interrogate -// database, including simple types and pointers and const pointers to -// classes. These types are necessary to fully define all of the -// function parameters, but need not themselves be wrapped. +/* + * Two lists of types are maintained: the list of global types, which includes + * only those types intended to be wrapped in the API (for instance, all of + * the classes). The second list is the complete list of all types, which + * probably does not need to be traversed--this includes *all* types known to + * the interrogate database, including simple types and pointers and const + * pointers to classes. These types are necessary to fully define all of the + * function parameters, but need not themselves be wrapped. + */ EXPCL_INTERROGATEDB int interrogate_number_of_global_types(); EXPCL_INTERROGATEDB TypeIndex interrogate_get_global_type(int n); @@ -403,12 +367,12 @@ EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type); -// A given type might be a nested type, meaning it is entirely defined -// within (and scoped within) some different C++ class. In this case, -// the type_name() will return the local name of the type as seen -// within the class, while the scoped_name() will return the -// fully-qualified name of the type, and is_nested() and outer_class() -// can be used to determine the class it is nested within. +// A given type might be a nested type, meaning it is entirely defined within +// (and scoped within) some different C++ class. In this case, the +// type_name() will return the local name of the type as seen within the +// class, while the scoped_name() will return the fully-qualified name of the +// type, and is_nested() and outer_class() can be used to determine the class +// it is nested within. EXPCL_INTERROGATEDB bool interrogate_type_is_nested(TypeIndex type); EXPCL_INTERROGATEDB TypeIndex interrogate_type_outer_class(TypeIndex type); @@ -424,10 +388,10 @@ EXPCL_INTERROGATEDB bool interrogate_type_has_library_name(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_library_name(TypeIndex type); -// If interrogate_type_is_atomic() returns true, the type is one of -// the basic C types enumerated in AtomicToken, above. The type may -// then be further modified by one or more of unsigned, signed, long, -// longlong, or short. However, it will not be a pointer. +// If interrogate_type_is_atomic() returns true, the type is one of the basic +// C types enumerated in AtomicToken, above. The type may then be further +// modified by one or more of unsigned, signed, long, longlong, or short. +// However, it will not be a pointer. EXPCL_INTERROGATEDB bool interrogate_type_is_atomic(TypeIndex type); EXPCL_INTERROGATEDB AtomicToken interrogate_type_atomic_token(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_unsigned(TypeIndex type); @@ -436,22 +400,20 @@ EXPCL_INTERROGATEDB bool interrogate_type_is_long(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_longlong(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_short(TypeIndex type); -// If interrogate_type_is_wrapped() returns true, this is a composite -// type "wrapped" around some simpler type, for instance a pointer to -// a class. The type will be either a pointer or a const wrapper--it -// cannot be a combination of these. (When combinations are required, -// they use multiple wrappers. A const char pointer, for example, is -// represented as a pointer wrapper around a const wrapper around an -// atomic char.) +// If interrogate_type_is_wrapped() returns true, this is a composite type +// "wrapped" around some simpler type, for instance a pointer to a class. The +// type will be either a pointer or a const wrapper--it cannot be a +// combination of these. (When combinations are required, they use multiple +// wrappers. A const char pointer, for example, is represented as a pointer +// wrapper around a const wrapper around an atomic char.) EXPCL_INTERROGATEDB bool interrogate_type_is_wrapped(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_pointer(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_const(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_typedef(TypeIndex type); EXPCL_INTERROGATEDB TypeIndex interrogate_type_wrapped_type(TypeIndex type); -// If interrogate_type_is_enum() returns true, this is an enumerated -// type, which means it may take any one of a number of named integer -// values. +// If interrogate_type_is_enum() returns true, this is an enumerated type, +// which means it may take any one of a number of named integer values. EXPCL_INTERROGATEDB bool interrogate_type_is_enum(TypeIndex type); EXPCL_INTERROGATEDB int interrogate_type_number_of_enum_values(TypeIndex type); EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_name(TypeIndex type, int n); @@ -459,45 +421,47 @@ EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_scoped_name(TypeInde EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_comment(TypeIndex type, int n); EXPCL_INTERROGATEDB int interrogate_type_enum_value(TypeIndex type, int n); -// If none of the above is true, the type is some extension type. It -// may be a struct, class, or union (and the distinction between these -// three is not likely to be important to the scripting language). In -// any case, it may contain zero or more constructors, zero or one -// destructor, zero or more member functions, and zero or more data -// members; all of the remaining type functions may apply. +// If none of the above is true, the type is some extension type. It may be a +// struct, class, or union (and the distinction between these three is not +// likely to be important to the scripting language). In any case, it may +// contain zero or more constructors, zero or one destructor, zero or more +// member functions, and zero or more data members; all of the remaining type +// functions may apply. EXPCL_INTERROGATEDB bool interrogate_type_is_struct(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_class(TypeIndex type); EXPCL_INTERROGATEDB bool interrogate_type_is_union(TypeIndex type); -// If is_fully_defined() returns false, this class/struct was a -// forward reference, and we really don't know anything about it. (In -// this case, it will appear to have no methods or members.) +// If is_fully_defined() returns false, this classstruct was a forward +// reference, and we really don't know anything about it. (In this case, it +// will appear to have no methods or members.) EXPCL_INTERROGATEDB bool interrogate_type_is_fully_defined(TypeIndex type); -// If is_unpublished() returns false, the class/struct is unknown -// because it was not marked to be published (or, in promiscuous mode, -// it is a protected or private nested class). +// If is_unpublished() returns false, the classstruct is unknown because it +// was not marked to be published (or, in promiscuous mode, it is a protected +// or private nested class). EXPCL_INTERROGATEDB bool interrogate_type_is_unpublished(TypeIndex type); -// Otherwise, especially if the type is a struct or class, we may have -// a number of member functions, including zero or more constructors -// and zero or one destructor. A constructor function may be called -// to allocate a new instance of the type; its return value will be a -// pointer to the new instance. The destructor may be called to -// destroy the instance; however, it usually should not be explicitly -// called by the user, since the proper support of the -// interrogate_caller_manages_return_value() interface, above, will -// ensure that the appropriate destructors are called when they should -// be. +/* + * Otherwise, especially if the type is a struct or class, we may have a + * number of member functions, including zero or more constructors and zero or + * one destructor. A constructor function may be called to allocate a new + * instance of the type; its return value will be a pointer to the new + * instance. The destructor may be called to destroy the instance; however, + * it usually should not be explicitly called by the user, since the proper + * support of the interrogate_caller_manages_return_value() interface, above, + * will ensure that the appropriate destructors are called when they should + * be. + */ -// In certain circumstances, the destructor might be inherited from a -// parent or ancestor class. This happens when the destructor wrapper -// from the ancestor class is an acceptable substitute for this -// destructor; this is only possible in the case of a virtual C++ -// destructor. In this case, the destructor returned here will be the -// same function index as the one returned by the ancestor class, and -// interrogate_type_destructor_is_inherited() will return true for -// this class. +/* + * In certain circumstances, the destructor might be inherited from a parent + * or ancestor class. This happens when the destructor wrapper from the + * ancestor class is an acceptable substitute for this destructor; this is + * only possible in the case of a virtual C++ destructor. In this case, the + * destructor returned here will be the same function index as the one + * returned by the ancestor class, and + * interrogate_type_destructor_is_inherited() will return true for this class. + */ EXPCL_INTERROGATEDB int interrogate_type_number_of_constructors(TypeIndex type); EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n); EXPCL_INTERROGATEDB bool interrogate_type_has_destructor(TypeIndex type); @@ -516,50 +480,49 @@ EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_method(TypeIndex type, in EXPCL_INTERROGATEDB int interrogate_type_number_of_make_seqs(TypeIndex type); EXPCL_INTERROGATEDB MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n); -// A C++ class may also define a number of explicit cast operators, -// which define how to convert an object of this type to an object of -// some other type (the type can be inferred by the return type of the -// cast function). This is not related to upcast and downcast, -// defined below. +// A C++ class may also define a number of explicit cast operators, which +// define how to convert an object of this type to an object of some other +// type (the type can be inferred by the return type of the cast function). +// This is not related to upcast and downcast, defined below. EXPCL_INTERROGATEDB int interrogate_type_number_of_casts(TypeIndex type); EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_cast(TypeIndex type, int n); -// A C++ class may inherit from zero or more base classes. This -// defines the list of base classes for this particular type. +// A C++ class may inherit from zero or more base classes. This defines the +// list of base classes for this particular type. EXPCL_INTERROGATEDB int interrogate_type_number_of_derivations(TypeIndex type); EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_derivation(TypeIndex type, int n); -// For each base class, we might need to define an explicit upcast or -// downcast operation to convert the pointer to the derived class to -// an appropriate pointer to its base class (upcast) or vice-versa -// (downcast). This is particularly true in the presence of multiple -// inheritance or virtual inheritance, in which case you cannot simply -// use the same pointer as either type. +// For each base class, we might need to define an explicit upcast or downcast +// operation to convert the pointer to the derived class to an appropriate +// pointer to its base class (upcast) or vice-versa (downcast). This is +// particularly true in the presence of multiple inheritance or virtual +// inheritance, in which case you cannot simply use the same pointer as either +// type. -// If interrogate_type_derivation_has_upcast() returns true for a -// particular type/derivation combination, you must use the indicated -// upcast function to convert pointers of this type to pointers of the -// base type before calling any of the inherited methods from the base -// class. If this returns false, you may simply use the same pointer -// as either a derived class pointer or a base class pointer without -// any extra step. +// If interrogate_type_derivation_has_upcast() returns true for a particular +// typederivation combination, you must use the indicated upcast function to +// convert pointers of this type to pointers of the base type before calling +// any of the inherited methods from the base class. If this returns false, +// you may simply use the same pointer as either a derived class pointer or a +// base class pointer without any extra step. EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_upcast(TypeIndex type, int n); EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n); -// Although it is always possible to upcast a pointer to a base class, -// it is not always possible to downcast from a base class to the -// derived class (particularly in the presence of virtual -// inheritance). If interrogate_type_derivation_downcast_is_impossible() -// returns true, forget it. Otherwise, downcasting works the same -// way as upcasting. (Of course, it is the caller's responsibility to -// guarantee that the pointer actually represents an object of the -// type being downcast to.) +/* + * Although it is always possible to upcast a pointer to a base class, it is + * not always possible to downcast from a base class to the derived class + * (particularly in the presence of virtual inheritance). If + * interrogate_type_derivation_downcast_is_impossible() returns true, forget + * it. Otherwise, downcasting works the same way as upcasting. (Of course, + * it is the caller's responsibility to guarantee that the pointer actually + * represents an object of the type being downcast to.) + */ EXPCL_INTERROGATEDB bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n); EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_downcast(TypeIndex type, int n); EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n); -// A C++ class may also define any number of nested types--classes or -// enums defined within the scope of this class. +// A C++ class may also define any number of nested types--classes or enums +// defined within the scope of this class. EXPCL_INTERROGATEDB int interrogate_type_number_of_nested_types(TypeIndex type); EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n); diff --git a/dtool/src/interrogatedb/interrogate_request.cxx b/dtool/src/interrogatedb/interrogate_request.cxx index 28d2dd76f6..49ccff4333 100644 --- a/dtool/src/interrogatedb/interrogate_request.cxx +++ b/dtool/src/interrogatedb/interrogate_request.cxx @@ -1,16 +1,15 @@ -// Filename: interrogate_request.cxx -// Created by: drose (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file interrogate_request.cxx + * @author drose + * @date 2000-08-01 + */ #include "interrogate_request.h" #include "interrogateDatabase.h" diff --git a/dtool/src/interrogatedb/interrogate_request.h b/dtool/src/interrogatedb/interrogate_request.h index 06d8bfb1a4..46a80b27b6 100644 --- a/dtool/src/interrogatedb/interrogate_request.h +++ b/dtool/src/interrogatedb/interrogate_request.h @@ -1,8 +1,4 @@ -/* Filename: interrogate_request.h - * Created by: drose (01Aug00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file interrogate_request.h + * @author drose + * @date 2000-08-01 + */ #ifndef INTERROGATE_REQUEST #define INTERROGATE_REQUEST @@ -81,4 +80,3 @@ EXPCL_INTERROGATEDB void interrogate_request_module(InterrogateModuleDef *def); #endif #endif - diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index c51cdd8024..5b92e5ef3f 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -1,16 +1,15 @@ -// Filename: py_panda.cxx -// Created by: drose (04Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file py_panda.cxx + * @author drose + * @date 2005-07-04 + */ #include "py_panda.h" #include "config_interrogatedb.h" @@ -22,7 +21,8 @@ PyMemberDef standard_type_members[] = { {(char *)"this", (sizeof(void*) == sizeof(int)) ? T_UINT : T_ULONGLONG, offsetof(Dtool_PyInstDef, _ptr_to_object), READONLY, (char *)"C++ 'this' pointer, if any"}, {(char *)"this_ownership", T_BOOL, offsetof(Dtool_PyInstDef, _memory_rules), READONLY, (char *)"C++ 'this' ownership rules"}, {(char *)"this_const", T_BOOL, offsetof(Dtool_PyInstDef, _is_const), READONLY, (char *)"C++ 'this' const flag"}, -// {(char *)"this_signature", T_INT, offsetof(Dtool_PyInstDef, _signature), READONLY, (char *)"A type check signature"}, +// {(char *)"this_signature", T_INT, offsetof(Dtool_PyInstDef, _signature), +// READONLY, (char *)"A type check signature"}, {(char *)"this_metatype", T_OBJECT, offsetof(Dtool_PyInstDef, _My_Type), READONLY, (char *)"The dtool meta object"}, {NULL} /* Sentinel */ }; @@ -31,18 +31,16 @@ static RuntimeTypeMap runtime_type_map; static RuntimeTypeSet runtime_type_set; static NamedTypeMap named_type_map; -//////////////////////////////////////////////////////////////////// -// Function: DtoolCanThisBeAPandaInstance -// Description: Given a valid (non-NULL) PyObject, does a simple -// check to see if it might be an instance of a Panda -// type. It does this using a signature that is -// encoded on each instance. -//////////////////////////////////////////////////////////////////// +/** + * Given a valid (non-NULL) PyObject, does a simple check to see if it might + * be an instance of a Panda type. It does this using a signature that is + * encoded on each instance. + */ bool DtoolCanThisBeAPandaInstance(PyObject *self) { // simple sanity check for the class type..size.. will stop basic foobars.. // It is arguably better to use something like this: - // PyType_IsSubtype(Py_TYPE(self), &Dtool_DTOOL_SUPER_BASE._PyType) - // ...but probably not as fast. + // PyType_IsSubtype(Py_TYPE(self), &Dtool_DTOOL_SUPER_BASE._PyType) ...but + // probably not as fast. if (Py_TYPE(self)->tp_basicsize >= (int)sizeof(Dtool_PyInstDef)) { Dtool_PyInstDef *pyself = (Dtool_PyInstDef *) self; if (pyself->_signature == PY_PANDA_SIGNATURE) { @@ -52,12 +50,9 @@ bool DtoolCanThisBeAPandaInstance(PyObject *self) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DTOOL_Call_ExtractThisPointerForType -// These are the wrappers that allow for down and upcast from type .. -// needed by the Dtool py interface.. Be very careful if you muck with these -// as the generated code depends on how this is set up.. -//////////////////////////////////////////////////////////////////// +/** + + */ void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer) { if (DtoolCanThisBeAPandaInstance(self)) { *answer = ((Dtool_PyInstDef *)self)->_My_Type->_Dtool_UpcastInterface(self, classdef); @@ -66,13 +61,11 @@ void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *c } } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Call_ExtractThisPointer -// Description: This is a support function for the Python bindings: -// it extracts the underlying C++ pointer of the given -// type for a given Python object. If it was of the -// wrong type, raises an AttributeError. -//////////////////////////////////////////////////////////////////// +/** + * This is a support function for the Python bindings: it extracts the + * underlying C++ pointer of the given type for a given Python object. If it + * was of the wrong type, raises an AttributeError. + */ bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef, void **answer) { if (self == NULL || !DtoolCanThisBeAPandaInstance(self)) { Dtool_Raise_TypeError("C++ object is not yet constructed, or already destructed."); @@ -83,17 +76,14 @@ bool Dtool_Call_ExtractThisPointer(PyObject *self, Dtool_PyTypedObject &classdef return true; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Call_ExtractThisPointer_NonConst -// Description: The same thing as Dtool_Call_ExtractThisPointer, -// except that it performs the additional check that -// the pointer is a non-const pointer. This is called -// by function wrappers for functions of which all -// overloads are non-const, and saves a bit of code. -// -// The extra method_name argument is used in formatting -// the error message. -//////////////////////////////////////////////////////////////////// +/** + * The same thing as Dtool_Call_ExtractThisPointer, except that it performs + * the additional check that the pointer is a non-const pointer. This is + * called by function wrappers for functions of which all overloads are non- + * const, and saves a bit of code. + * + * The extra method_name argument is used in formatting the error message. + */ bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject &classdef, void **answer, const char *method_name) { @@ -114,40 +104,33 @@ bool Dtool_Call_ExtractThisPointer_NonConst(PyObject *self, Dtool_PyTypedObject return true; } -//////////////////////////////////////////////////////////////////// -// Function: DTOOL_Call_GetPointerThisClass -// Description: Extracts the C++ pointer for an object, given its -// Python wrapper object, for passing as the parameter -// to a C++ function. -// -// self is the Python wrapper object in question. -// -// classdef is the Python class wrapper for the C++ -// class in which the this pointer should be returned. -// (This may require an upcast operation, if self is not -// already an instance of classdef.) -// -// param and function_name are used for error reporting -// only, and describe the particular function and -// parameter index for this parameter. -// -// const_ok is true if the function is declared const -// and can therefore be called with either a const or -// non-const "this" pointer, or false if the function is -// declared non-const, and can therefore be called with -// only a non-const "this" pointer. -// -// The return value is the C++ pointer that was -// extracted, or NULL if there was a problem (in which -// case the Python exception state will have been set). -//////////////////////////////////////////////////////////////////// +/** + * Extracts the C++ pointer for an object, given its Python wrapper object, + * for passing as the parameter to a C++ function. + * + * self is the Python wrapper object in question. + * + * classdef is the Python class wrapper for the C++ class in which the this + * pointer should be returned. (This may require an upcast operation, if self + * is not already an instance of classdef.) + * + * param and function_name are used for error reporting only, and describe the + * particular function and parameter index for this parameter. + * + * const_ok is true if the function is declared const and can therefore be + * called with either a const or non-const "this" pointer, or false if the + * function is declared non-const, and can therefore be called with only a + * non-const "this" pointer. + * + * The return value is the C++ pointer that was extracted, or NULL if there + * was a problem (in which case the Python exception state will have been + * set). + */ void * DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name, bool const_ok, bool report_errors) { - //if (PyErr_Occurred()) { - // return NULL; - //} + // if (PyErr_Occurred()) { return NULL; } if (self == NULL) { if (report_errors) { return Dtool_Raise_TypeError("self is NULL"); @@ -190,20 +173,16 @@ void *DTOOL_Call_GetPointerThis(PyObject *self) { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: Dtool_CheckErrorOccurred -// Description: This is similar to a PyErr_Occurred() check, except -// that it also checks Notify to see if an assertion -// has occurred. If that is the case, then it raises -// an AssertionError. -// -// Returns true if there is an active exception, false -// otherwise. -// -// In the NDEBUG case, this is simply a #define to -// _PyErr_OCCURRED() (which is an undocumented inline -// version of PyErr_Occurred()). -//////////////////////////////////////////////////////////////////// +/** + * This is similar to a PyErr_Occurred() check, except that it also checks + * Notify to see if an assertion has occurred. If that is the case, then it + * raises an AssertionError. + * + * Returns true if there is an active exception, false otherwise. + * + * In the NDEBUG case, this is simply a #define to _PyErr_OCCURRED() (which is + * an undocumented inline version of PyErr_Occurred()). + */ bool Dtool_CheckErrorOccurred() { if (_PyErr_OCCURRED()) { return true; @@ -216,12 +195,10 @@ bool Dtool_CheckErrorOccurred() { } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Raise_AssertionError -// Description: Raises an AssertionError containing the last thrown -// assert message, and clears the assertion flag. -// Returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Raises an AssertionError containing the last thrown assert message, and + * clears the assertion flag. Returns NULL. + */ PyObject *Dtool_Raise_AssertionError() { Notify *notify = Notify::ptr(); #if PY_MAJOR_VERSION >= 3 @@ -235,11 +212,9 @@ PyObject *Dtool_Raise_AssertionError() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Raise_TypeError -// Description: Raises a TypeError with the given message, and -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Raises a TypeError with the given message, and returns NULL. + */ PyObject *Dtool_Raise_TypeError(const char *message) { // PyErr_Restore is what PyErr_SetString would have ended up calling // eventually anyway, so we might as well just get to the point. @@ -252,16 +227,13 @@ PyObject *Dtool_Raise_TypeError(const char *message) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Raise_ArgTypeError -// Description: Raises a TypeError of the form: -// function_name() argument n must be type, not type -// for a given object passed to a function. -// -// Always returns NULL so that it can be conveniently -// used as a return expression for wrapper functions -// that return a PyObject pointer. -//////////////////////////////////////////////////////////////////// +/** + * Raises a TypeError of the form: function_name() argument n must be type, + * not type for a given object passed to a function. + * + * Always returns NULL so that it can be conveniently used as a return + * expression for wrapper functions that return a PyObject pointer. + */ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *function_name, const char *type_name) { #if PY_MAJOR_VERSION >= 3 PyObject *message = PyUnicode_FromFormat( @@ -277,15 +249,12 @@ PyObject *Dtool_Raise_ArgTypeError(PyObject *obj, int param, const char *functio return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Raise_AttributeError -// Description: Raises an AttributeError of the form: -// 'type' has no attribute 'attr' -// -// Always returns NULL so that it can be conveniently -// used as a return expression for wrapper functions -// that return a PyObject pointer. -//////////////////////////////////////////////////////////////////// +/** + * Raises an AttributeError of the form: 'type' has no attribute 'attr' + * + * Always returns NULL so that it can be conveniently used as a return + * expression for wrapper functions that return a PyObject pointer. + */ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { #if PY_MAJOR_VERSION >= 3 PyObject *message = PyUnicode_FromFormat( @@ -300,30 +269,24 @@ PyObject *Dtool_Raise_AttributeError(PyObject *obj, const char *attribute) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Raise_BadArgumentsError -// Description: Raises a TypeError of the form: -// Arguments must match: -// -// -// However, in release builds, this instead is defined -// to a function that just prints out a generic -// message, to help reduce the amount of strings in -// the compiled library. -// -// Always returns NULL so that it can be conveniently -// used as a return expression for wrapper functions -// that return a PyObject pointer. -//////////////////////////////////////////////////////////////////// +/** + * Raises a TypeError of the form: Arguments must match: + * + * However, in release builds, this instead is defined to a function that just + * prints out a generic message, to help reduce the amount of strings in the + * compiled library. + * + * Always returns NULL so that it can be conveniently used as a return + * expression for wrapper functions that return a PyObject pointer. + */ PyObject *_Dtool_Raise_BadArgumentsError() { return Dtool_Raise_TypeError("arguments do not match any function overload"); } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Return_None -// Description: Convenience method that checks for exceptions, and -// if one occurred, returns NULL, otherwise Py_None. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method that checks for exceptions, and if one occurred, returns + * NULL, otherwise Py_None. + */ PyObject *_Dtool_Return_None() { if (_PyErr_OCCURRED()) { return NULL; @@ -337,12 +300,10 @@ PyObject *_Dtool_Return_None() { return Py_None; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Return_Bool -// Description: Convenience method that checks for exceptions, and -// if one occurred, returns NULL, otherwise the given -// boolean value as a PyObject *. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method that checks for exceptions, and if one occurred, returns + * NULL, otherwise the given boolean value as a PyObject *. + */ PyObject *Dtool_Return_Bool(bool value) { if (_PyErr_OCCURRED()) { return NULL; @@ -357,12 +318,11 @@ PyObject *Dtool_Return_Bool(bool value) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Dtool_Return -// Description: Convenience method that checks for exceptions, and -// if one occurred, returns NULL, otherwise the given -// return value. Its reference count is not increased. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method that checks for exceptions, and if one occurred, returns + * NULL, otherwise the given return value. Its reference count is not + * increased. + */ PyObject *_Dtool_Return(PyObject *value) { if (_PyErr_OCCURRED()) { return NULL; @@ -375,16 +335,14 @@ PyObject *_Dtool_Return(PyObject *value) { return value; } -//////////////////////////////////////////////////////////////////// -// Function: DTool_CreatePyInstanceTyped -// this function relies on the behavior of typed objects in the panda system. -// -//////////////////////////////////////////////////////////////////// +/** + + */ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int type_index) { - // We can't do the NULL check here like in DTool_CreatePyInstance, since - // the caller will have to get the type index to pass to this function - // to begin with. That code probably would have crashed by now if it was - // really NULL for whatever reason. + // We can't do the NULL check here like in DTool_CreatePyInstance, since the + // caller will have to get the type index to pass to this function to begin + // with. That code probably would have crashed by now if it was really NULL + // for whatever reason. nassertr(local_this_in != NULL, NULL); // IF the class is possibly a run time typed object @@ -401,7 +359,7 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & self->_ptr_to_object = new_local_this; self->_memory_rules = memory_rules; self->_is_const = is_const; - //self->_signature = PY_PANDA_SIGNATURE; + // self->_signature = PY_PANDA_SIGNATURE; self->_My_Type = target_class; return (PyObject *)self; } @@ -409,23 +367,21 @@ PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject & } } - // if we get this far .. just wrap the thing in the known type ?? - // better than aborting...I guess.... + // if we get this far .. just wrap the thing in the known type ?? better + // than aborting...I guess.... Dtool_PyInstDef *self = (Dtool_PyInstDef *) known_class_type._PyType.tp_new(&known_class_type._PyType, NULL, NULL); if (self != NULL) { self->_ptr_to_object = local_this_in; self->_memory_rules = memory_rules; self->_is_const = is_const; - //self->_signature = PY_PANDA_SIGNATURE; + // self->_signature = PY_PANDA_SIGNATURE; self->_My_Type = &known_class_type; } return (PyObject *)self; } -//////////////////////////////////////////////////////////////////// -// DTool_CreatePyInstance .. wrapper function to finalize the existance of a general -// dtool py instance.. -//////////////////////////////////////////////////////////////////// +// DTool_CreatePyInstance .. wrapper function to finalize the existance of a +// general dtool py instance.. PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const) { if (local_this == NULL) { // This is actually a very common case, so let's allow this, but return @@ -445,12 +401,10 @@ PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_class return (PyObject *)self; } -//////////////////////////////////////////////////////////////////// -/// Th Finalizer for simple instances.. -//////////////////////////////////////////////////////////////////// +// Th Finalizer for simple instances.. int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject *type, bool memory_rules, bool is_const) { - // lets put some code in here that checks to see the memory is properly configured.. - // prior to my call .. + // lets put some code in here that checks to see the memory is properly + // configured.. prior to my call .. ((Dtool_PyInstDef *)self)->_My_Type = type; ((Dtool_PyInstDef *)self)->_ptr_to_object = local_this; @@ -459,11 +413,9 @@ int DTool_PyInit_Finalize(PyObject *self, void *local_this, Dtool_PyTypedObject return 0; } -//////////////////////////////////////////////////////////////////// -// A helper function to glue method definition together .. that can not be done -// at code generation time because of multiple generation passes in interrogate.. -// -//////////////////////////////////////////////////////////////////// +// A helper function to glue method definition together .. that can not be +// done at code generation time because of multiple generation passes in +// interrogate.. void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { for (; in->ml_name != NULL; in++) { if (themap.find(in->ml_name) == themap.end()) { @@ -472,13 +424,9 @@ void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap) { } } -//////////////////////////////////////////////////////////////////// -// ** HACK ** alert.. -// -// Need to keep a runtime type dictionary ... that is forward declared of typed object. -// We rely on the fact that typed objects are uniquly defined by an integer. -// -//////////////////////////////////////////////////////////////////// +// ** HACK ** alert.. Need to keep a runtime type dictionary ... that is +// forward declared of typed object. We rely on the fact that typed objects +// are uniquly defined by an integer. void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype) { pair result = @@ -685,14 +633,9 @@ PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename) { return module; } -//////////////////////////////////////////////////////////////////// -/// HACK.... Be careful -// -// Dtool_BorrowThisReference -// This function can be used to grab the "THIS" pointer from an object and use it -// Required to support historical inheritance in the form of "is this instance of".. -// -//////////////////////////////////////////////////////////////////// +// HACK.... Be careful Dtool_BorrowThisReference This function can be used to +// grab the "THIS" pointer from an object and use it Required to support +// historical inheritance in the form of "is this instance of".. PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { PyObject *from_in = NULL; PyObject *to_in = NULL; @@ -702,7 +645,7 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { Dtool_PyInstDef *from = (Dtool_PyInstDef *) from_in; Dtool_PyInstDef *to = (Dtool_PyInstDef *) to_in; - //if (PyObject_TypeCheck(to_in, Py_TYPE(from_in))) { + // if (PyObject_TypeCheck(to_in, Py_TYPE(from_in))) { if (from->_My_Type == to->_My_Type) { to->_memory_rules = false; to->_is_const = from->_is_const; @@ -721,9 +664,8 @@ PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args) { return (PyObject *) NULL; } -//////////////////////////////////////////////////////////////////// -// We do expose a dictionay for dtool classes .. this should be removed at some point.. -//////////////////////////////////////////////////////////////////// +// We do expose a dictionay for dtool classes .. this should be removed at +// some point.. PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { PyObject *self; PyObject *subject; @@ -743,7 +685,6 @@ PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args) { return Py_None; } -//////////////////////////////////////////////////////////////////// Py_hash_t DTOOL_PyObject_HashPointer(PyObject *self) { if (self != NULL && DtoolCanThisBeAPandaInstance(self)) { Dtool_PyInstDef * pyself = (Dtool_PyInstDef *) self; @@ -860,20 +801,18 @@ PyObject *DTOOL_PyObject_RichCompare(PyObject *v1, PyObject *v2, int op) { return PyBool_FromLong(result); } -//////////////////////////////////////////////////////////////////// -// Function: copy_from_make_copy -// Description: This is a support function for a synthesized -// __copy__() method from a C++ make_copy() method. -//////////////////////////////////////////////////////////////////// +/** + * This is a support function for a synthesized __copy__() method from a C++ + * make_copy() method. + */ PyObject *copy_from_make_copy(PyObject *self, PyObject *noargs) { return PyObject_CallMethod(self, (char *)"make_copy", (char *)"()"); } -//////////////////////////////////////////////////////////////////// -// Function: copy_from_copy_constructor -// Description: This is a support function for a synthesized -// __copy__() method from a C++ copy constructor. -//////////////////////////////////////////////////////////////////// +/** + * This is a support function for a synthesized __copy__() method from a C++ + * copy constructor. + */ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { @@ -885,23 +824,19 @@ PyObject *copy_from_copy_constructor(PyObject *self, PyObject *noargs) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: map_deepcopy_to_copy -// Description: This is a support function for a synthesized -// __deepcopy__() method for any class that has a -// __copy__() method. The sythethic method simply -// invokes __copy__(). -//////////////////////////////////////////////////////////////////// +/** + * This is a support function for a synthesized __deepcopy__() method for any + * class that has a __copy__() method. The sythethic method simply invokes + * __copy__(). + */ PyObject *map_deepcopy_to_copy(PyObject *self, PyObject *args) { return PyObject_CallMethod(self, (char *)"__copy__", (char *)"()"); } -//////////////////////////////////////////////////////////////////// -// Function: PyLongOrInt_FromUnsignedLong -// Description: Similar to PyLong_FromUnsignedLong(), but returns -// either a regular integer or a long integer, according -// to whether the indicated value will fit. -//////////////////////////////////////////////////////////////////// +/** + * Similar to PyLong_FromUnsignedLong(), but returns either a regular integer + * or a long integer, according to whether the indicated value will fit. + */ #if PY_MAJOR_VERSION < 3 EXPCL_INTERROGATEDB PyObject * PyLongOrInt_FromUnsignedLong(unsigned long value) { diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 5e34a73287..14310c8052 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -1,14 +1,13 @@ -// Filename: py_panda.h -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file py_panda.h + */ #ifndef PY_PANDA_H_ #define PY_PANDA_H_ @@ -138,9 +137,7 @@ typedef long Py_hash_t; using namespace std; -//////////////////////////////////////////////////////////////////// // this is tempory .. untill this is glued better into the panda build system -//////////////////////////////////////////////////////////////////// #if defined(_WIN32) && !defined(LINK_ALL_STATIC) #define EXPORT_THIS __declspec(dllexport) @@ -162,26 +159,23 @@ typedef void *(*DowncastFunction)(void *, Dtool_PyTypedObject *); typedef void *(*CoerceFunction)(PyObject *, void *); typedef void (*ModuleClassInitFunction)(PyObject *module); -//inline Dtool_PyTypedObject * Dtool_RuntimeTypeDtoolType(int type); -//inline void Dtool_Deallocate_General(PyObject * self); -//inline int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); -// -//////////////////////////////////////////////////////////////////// -// THIS IS THE INSTANCE CONTAINER FOR ALL panda py objects.... -//////////////////////////////////////////////////////////////////// +// inline Dtool_PyTypedObject * Dtool_RuntimeTypeDtoolType(int +// type); inline void Dtool_Deallocate_General(PyObject * self); inline +// int DTOOL_PyObject_Compare(PyObject *v1, PyObject *v2); THIS IS THE +// INSTANCE CONTAINER FOR ALL panda py objects.... struct Dtool_PyInstDef { PyObject_HEAD - // This is a pointer to the Dtool_PyTypedObject type. It's tempting - // not to store this and to instead use PY_TYPE(self) and upcast that, - // but that breaks when someone inherits from our class in Python. + // This is a pointer to the Dtool_PyTypedObject type. It's tempting not to + // store this and to instead use PY_TYPE(self) and upcast that, but that + // breaks when someone inherits from our class in Python. struct Dtool_PyTypedObject *_My_Type; // Pointer to the underlying C++ object. void *_ptr_to_object; - // This is always set to PY_PANDA_SIGNATURE, so that we can quickly - // detect whether an object is a Panda object. + // This is always set to PY_PANDA_SIGNATURE, so that we can quickly detect + // whether an object is a Panda object. unsigned short _signature; // True if we own the pointer and should delete it or unref it. @@ -191,14 +185,10 @@ struct Dtool_PyInstDef { bool _is_const; }; -//////////////////////////////////////////////////////////////////// // A Offset Dictionary Defining How to read the Above Object.. -//////////////////////////////////////////////////////////////////// extern EXPCL_INTERROGATEDB PyMemberDef standard_type_members[]; -//////////////////////////////////////////////////////////////////// // The Class Definition Structor For a Dtool python type. -//////////////////////////////////////////////////////////////////// struct Dtool_PyTypedObject { // Standard Python Features.. PyTypeObject _PyType; @@ -220,9 +210,8 @@ struct Dtool_PyTypedObject { #define Define_Dtool_Class(MODULE_NAME, CLASS_NAME, PUBLIC_NAME) \ extern Dtool_PyTypedObject Dtool_##CLASS_NAME; -//////////////////////////////////////////////////////////////////// -// More Macro(s) to Implement class functions.. Usually used if C++ needs type information -//////////////////////////////////////////////////////////////////// +// More Macro(s) to Implement class functions.. Usually used if C++ needs type +// information #define Define_Dtool_new(CLASS_NAME,CNAME)\ static PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyObject *kwds) {\ (void) args; (void) kwds;\ @@ -232,15 +221,12 @@ static PyObject *Dtool_new_##CLASS_NAME(PyTypeObject *type, PyObject *args, PyOb return self;\ } -// The following used to be in the above macro, but it doesn't seem to -// be necessary as tp_alloc memsets the object to 0. - //((Dtool_PyInstDef *)self)->_ptr_to_object = NULL;\ - //((Dtool_PyInstDef *)self)->_memory_rules = false;\ - //((Dtool_PyInstDef *)self)->_is_const = false;\ +// The following used to be in the above macro, but it doesn't seem to be +// necessary as tp_alloc memsets the object to 0. ((Dtool_PyInstDef +// *)self)->_ptr_to_object = NULL;\ ((Dtool_PyInstDef *)self)->_memory_rules = +// false;\ ((Dtool_PyInstDef *)self)->_is_const = false;\ -//////////////////////////////////////////////////////////////////// -/// Delete functions.. -//////////////////////////////////////////////////////////////////// +// Delete functions.. #ifdef NDEBUG #define Define_Dtool_FreeInstance_Private(CLASS_NAME,CNAME)\ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ @@ -285,18 +271,12 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\ Py_TYPE(self)->tp_free(self);\ } -//////////////////////////////////////////////////////////////////// -/// Simple Recognition Functions.. -//////////////////////////////////////////////////////////////////// +// Simple Recognition Functions.. EXPCL_INTERROGATEDB bool DtoolCanThisBeAPandaInstance(PyObject *self); -//////////////////////////////////////////////////////////////////// -// ** HACK ** allert.. -// -// Need to keep a runtime type dictionary ... that is forward declared of typed object. -// We rely on the fact that typed objects are uniquly defined by an integer. -// -//////////////////////////////////////////////////////////////////// +// ** HACK ** allert.. Need to keep a runtime type dictionary ... that is +// forward declared of typed object. We rely on the fact that typed objects +// are uniquly defined by an integer. EXPCL_INTERROGATEDB void RegisterNamedClass(const string &name, Dtool_PyTypedObject &otype); EXPCL_INTERROGATEDB void RegisterRuntimeTypedClass(Dtool_PyTypedObject &otype); @@ -306,13 +286,9 @@ EXPCL_INTERROGATEDB Dtool_PyTypedObject *LookupRuntimeTypedClass(TypeHandle hand EXPCL_INTERROGATEDB Dtool_PyTypedObject *Dtool_RuntimeTypeDtoolType(int type); -//////////////////////////////////////////////////////////////////// -// Function: DTOOL_Call_ExtractThisPointerForType -// These are the wrappers that allow for down and upcast from type .. -// needed by the Dtool py interface.. Be very careful if you muck -// with these as the generated code depends on how this is set -// up.. -//////////////////////////////////////////////////////////////////// +/** + + */ EXPCL_INTERROGATEDB void DTOOL_Call_ExtractThisPointerForType(PyObject *self, Dtool_PyTypedObject *classdef, void **answer); EXPCL_INTERROGATEDB void *DTOOL_Call_GetPointerThisClass(PyObject *self, Dtool_PyTypedObject *classdef, int param, const string &function_name, bool const_ok, bool report_errors); @@ -371,17 +347,13 @@ EXPCL_INTERROGATEDB PyObject *_Dtool_Return(PyObject *value); #define Dtool_Return(value) _Dtool_Return(value) #endif -//////////////////////////////////////////////////////////////////// -// Function: DTool_CreatePyInstanceTyped -// this function relies on the behavior of typed objects in the panda system. -// -//////////////////////////////////////////////////////////////////// +/** + + */ EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstanceTyped(void *local_this_in, Dtool_PyTypedObject &known_class_type, bool memory_rules, bool is_const, int RunTimeType); -//////////////////////////////////////////////////////////////////// -// DTool_CreatePyInstance .. wrapper function to finalize the existance of a general -// dtool py instance.. -//////////////////////////////////////////////////////////////////// +// DTool_CreatePyInstance .. wrapper function to finalize the existance of a +// general dtool py instance.. EXPCL_INTERROGATEDB PyObject *DTool_CreatePyInstance(void *local_this, Dtool_PyTypedObject &in_classdef, bool memory_rules, bool is_const); // These template methods allow use when the Dtool_PyTypedObject is not known. @@ -410,12 +382,10 @@ template INLINE PyObject *DTool_CreatePyInstanceTyped(T *obj, bool memo return DTool_CreatePyInstanceTyped((void*) obj, *known_class, memory_rules, false, obj->get_type().get_index()); } -//////////////////////////////////////////////////////////////////// -// Macro(s) class definition .. Used to allocate storage and -// init some values for a Dtool Py Type object. -//////////////////////////////////////////////////////////////////// +// Macro(s) class definition .. Used to allocate storage and init some values +// for a Dtool Py Type object. -//struct Dtool_PyTypedObject Dtool_##CLASS_NAME; +// struct Dtool_PyTypedObject Dtool_##CLASS_NAME; #define Define_Module_Class_Internal(MODULE_NAME,CLASS_NAME,CNAME)\ extern struct Dtool_PyTypedObject Dtool_##CLASS_NAME;\ @@ -446,24 +416,19 @@ Define_Dtool_new(CLASS_NAME,CNAME)\ Define_Dtool_FreeInstanceRef(CLASS_NAME,CNAME)\ Define_Dtool_Class(MODULE_NAME,CLASS_NAME,PUBLIC_NAME) -//////////////////////////////////////////////////////////////////// -/// The finalizer for simple instances. -//////////////////////////////////////////////////////////////////// +// The finalizer for simple instances. EXPCL_INTERROGATEDB int DTool_PyInit_Finalize(PyObject *self, void *This, Dtool_PyTypedObject *type, bool memory_rules, bool is_const); -//////////////////////////////////////////////////////////////////// -/// A heler function to glu methed definition together .. that can not be done at -// code generation time becouse of multiple generation passes in interigate.. -// -//////////////////////////////////////////////////////////////////// +// A heler function to glu methed definition together .. that can not be done +// at code generation time becouse of multiple generation passes in +// interigate.. typedef std::map MethodDefmap; EXPCL_INTERROGATEDB void Dtool_Accum_MethDefs(PyMethodDef in[], MethodDefmap &themap); -//////////////////////////////////////////////////////////////////// -// We need a way to runtime merge compile units into a python "Module" .. this is done with the -// fallowing structors and code.. along with the support of interigate_module -//////////////////////////////////////////////////////////////////// +// We need a way to runtime merge compile units into a python "Module" .. this +// is done with the fallowing structors and code.. along with the support of +// interigate_module struct LibraryDef { PyMethodDef *_methods; }; @@ -474,22 +439,15 @@ EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], PyMod EXPCL_INTERROGATEDB PyObject *Dtool_PyModuleInitHelper(LibraryDef *defs[], const char *modulename); #endif -//////////////////////////////////////////////////////////////////// -/// HACK.... Be carefull -// -// Dtool_BorrowThisReference -// This function can be used to grab the "THIS" pointer from an object and use it -// Required to support fom historical inharatence in the for of "is this instance of".. -// -//////////////////////////////////////////////////////////////////// +// HACK.... Be carefull Dtool_BorrowThisReference This function can be used to +// grab the "THIS" pointer from an object and use it Required to support fom +// historical inharatence in the for of "is this instance of".. EXPCL_INTERROGATEDB PyObject *Dtool_BorrowThisReference(PyObject *self, PyObject *args); -//////////////////////////////////////////////////////////////////// -// We do expose a dictionay for dtool classes .. this should be removed at some point.. -//////////////////////////////////////////////////////////////////// +// We do expose a dictionay for dtool classes .. this should be removed at +// some point.. EXPCL_INTERROGATEDB PyObject *Dtool_AddToDictionary(PyObject *self1, PyObject *args); -//////////////////////////////////////////////////////////////////// EXPCL_INTERROGATEDB Py_hash_t DTOOL_PyObject_HashPointer(PyObject *obj); @@ -516,7 +474,8 @@ EXPCL_INTERROGATEDB PyObject * map_deepcopy_to_copy(PyObject *self, PyObject *args); #if PY_MAJOR_VERSION < 3 -// In the Python 3 case, it is defined as a macro, at the beginning of this file. +// In the Python 3 case, it is defined as a macro, at the beginning of this +// file. EXPCL_INTERROGATEDB PyObject * PyLongOrInt_FromUnsignedLong(unsigned long value); #endif diff --git a/dtool/src/newheader/newheader.cxx b/dtool/src/newheader/newheader.cxx index 49563a8210..2e97dbb031 100644 --- a/dtool/src/newheader/newheader.cxx +++ b/dtool/src/newheader/newheader.cxx @@ -1,16 +1,15 @@ -// Filename: newheader.cxx -// Created by: drose (05Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file newheader.cxx + * @author drose + * @date 2004-07-05 + */ #include "dtoolbase.h" @@ -18,7 +17,7 @@ #include #include -const char *cxx_style = +const char *cxx_style = "// Filename: %s\n" "// Created by: %s (%s)\n" "//\n" @@ -34,7 +33,7 @@ const char *cxx_style = "////////////////////////////////////////////////////////////////////\n" "\n"; -const char *c_style = +const char *c_style = "/* Filename: %s\n" " * Created by: %s (%s)\n" " *\n" diff --git a/dtool/src/parser-inc/Cg/cg.h b/dtool/src/parser-inc/Cg/cg.h index a0adab732b..d1047c9eae 100644 --- a/dtool/src/parser-inc/Cg/cg.h +++ b/dtool/src/parser-inc/Cg/cg.h @@ -1,16 +1,15 @@ -// Filename: cg.h -// Created by: drose (22Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cg.h + * @author drose + * @date 2004-07-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/Cg/cgGL.h b/dtool/src/parser-inc/Cg/cgGL.h index 187b79ce59..5de890d9c6 100644 --- a/dtool/src/parser-inc/Cg/cgGL.h +++ b/dtool/src/parser-inc/Cg/cgGL.h @@ -1,16 +1,15 @@ -// Filename: cgGL.h -// Created by: sshodhan(22Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cgGL.h + * @author sshodhan + * @date 2004-07-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/Max.h b/dtool/src/parser-inc/Max.h index 4bd9ecc225..1ca2272709 100644 --- a/dtool/src/parser-inc/Max.h +++ b/dtool/src/parser-inc/Max.h @@ -1,16 +1,15 @@ -// Filename: Max.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file Max.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxBoxController.h b/dtool/src/parser-inc/NxBoxController.h index bf826a945a..3377e5a53e 100644 --- a/dtool/src/parser-inc/NxBoxController.h +++ b/dtool/src/parser-inc/NxBoxController.h @@ -1,16 +1,15 @@ -// Filename: NxBoxController.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxBoxController.h + * @author enn0x + * @date 2009-09-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxCapsuleController.h b/dtool/src/parser-inc/NxCapsuleController.h index a3e3bfc66c..3a2df9e25f 100644 --- a/dtool/src/parser-inc/NxCapsuleController.h +++ b/dtool/src/parser-inc/NxCapsuleController.h @@ -1,16 +1,15 @@ -// Filename: NxCapsuleController.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxCapsuleController.h + * @author enn0x + * @date 2009-09-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxController.h b/dtool/src/parser-inc/NxController.h index 6fd5d7fff3..ddd9213452 100644 --- a/dtool/src/parser-inc/NxController.h +++ b/dtool/src/parser-inc/NxController.h @@ -1,16 +1,15 @@ -// Filename: NxController.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxController.h + * @author enn0x + * @date 2009-09-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxControllerManager.h b/dtool/src/parser-inc/NxControllerManager.h index 2b6e92e8fd..c170c413b2 100644 --- a/dtool/src/parser-inc/NxControllerManager.h +++ b/dtool/src/parser-inc/NxControllerManager.h @@ -1,16 +1,15 @@ -// Filename: NxControllerManager.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxControllerManager.h + * @author enn0x + * @date 2009-09-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxCooking.h b/dtool/src/parser-inc/NxCooking.h index a7cacab1eb..be886af382 100644 --- a/dtool/src/parser-inc/NxCooking.h +++ b/dtool/src/parser-inc/NxCooking.h @@ -1,16 +1,15 @@ -// Filename: NxCooking.h -// Created by: enn0x (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxCooking.h + * @author enn0x + * @date 2009-10-12 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxExtended.h b/dtool/src/parser-inc/NxExtended.h index e23ff0dc51..d5a5daf4fc 100644 --- a/dtool/src/parser-inc/NxExtended.h +++ b/dtool/src/parser-inc/NxExtended.h @@ -1,16 +1,15 @@ -// Filename: NxExtended.h -// Created by: enn0x (02Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxExtended.h + * @author enn0x + * @date 2009-09-02 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxPhysics.h b/dtool/src/parser-inc/NxPhysics.h index ab7c06c5a6..8d3f5bd500 100644 --- a/dtool/src/parser-inc/NxPhysics.h +++ b/dtool/src/parser-inc/NxPhysics.h @@ -1,16 +1,15 @@ -// Filename: NxPhysics.h -// Created by: enn0x (02Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxPhysics.h + * @author enn0x + * @date 2009-09-02 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/NxStream.h b/dtool/src/parser-inc/NxStream.h index cd80eab090..85d000cabf 100644 --- a/dtool/src/parser-inc/NxStream.h +++ b/dtool/src/parser-inc/NxStream.h @@ -1,16 +1,15 @@ -// Filename: NxStream.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NxStream.h + * @author enn0x + * @date 2009-10-11 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/Python.h b/dtool/src/parser-inc/Python.h index de17409f53..b687f1b5cb 100644 --- a/dtool/src/parser-inc/Python.h +++ b/dtool/src/parser-inc/Python.h @@ -1,16 +1,15 @@ -// Filename: Python.h -// Created by: drose (12May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file Python.h + * @author drose + * @date 2000-05-12 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/Rocket/Core/RenderInterface.h b/dtool/src/parser-inc/Rocket/Core/RenderInterface.h index 981700c54d..7111067040 100644 --- a/dtool/src/parser-inc/Rocket/Core/RenderInterface.h +++ b/dtool/src/parser-inc/Rocket/Core/RenderInterface.h @@ -1,16 +1,15 @@ -// Filename: RenderInterface.h -// Created by: rdb (25Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file RenderInterface.h + * @author rdb + * @date 2011-11-25 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/files.h b/dtool/src/parser-inc/files.h index dedab644f2..095f16273a 100644 --- a/dtool/src/parser-inc/files.h +++ b/dtool/src/parser-inc/files.h @@ -1,16 +1,15 @@ -// Filename: files.h -// Created by: drose (07Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file files.h + * @author drose + * @date 2000-11-07 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/ft2build.h b/dtool/src/parser-inc/ft2build.h index 88dc8d645a..6b4184a467 100644 --- a/dtool/src/parser-inc/ft2build.h +++ b/dtool/src/parser-inc/ft2build.h @@ -1,16 +1,15 @@ -// Filename: ft2build.h -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ft2build.h + * @author drose + * @date 2002-02-08 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/hex.h b/dtool/src/parser-inc/hex.h index 67f7a69ab6..775bad82b3 100644 --- a/dtool/src/parser-inc/hex.h +++ b/dtool/src/parser-inc/hex.h @@ -1,16 +1,15 @@ -// Filename: hex.h -// Created by: drose (17Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hex.h + * @author drose + * @date 2000-11-17 + */ // This file, and all the other hex in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/iparamb2.h b/dtool/src/parser-inc/iparamb2.h index 9aff73387a..086bf36c4e 100644 --- a/dtool/src/parser-inc/iparamb2.h +++ b/dtool/src/parser-inc/iparamb2.h @@ -1,16 +1,15 @@ -// Filename: iparamb2.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iparamb2.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/iparamm2.h b/dtool/src/parser-inc/iparamm2.h index 02549f67cd..e1ce37b5c4 100644 --- a/dtool/src/parser-inc/iparamm2.h +++ b/dtool/src/parser-inc/iparamm2.h @@ -1,16 +1,15 @@ -// Filename: iparamm2.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iparamm2.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/iskin.h b/dtool/src/parser-inc/iskin.h index f2de948bdf..e9bc100a2e 100644 --- a/dtool/src/parser-inc/iskin.h +++ b/dtool/src/parser-inc/iskin.h @@ -1,16 +1,15 @@ -// Filename: iskin.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iskin.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/istdplug.h b/dtool/src/parser-inc/istdplug.h index 626cd405fb..908d7f60c8 100644 --- a/dtool/src/parser-inc/istdplug.h +++ b/dtool/src/parser-inc/istdplug.h @@ -1,16 +1,15 @@ -// Filename: istdplug.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file istdplug.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/krb5.h b/dtool/src/parser-inc/krb5.h index bd2b964303..80f130fd76 100644 --- a/dtool/src/parser-inc/krb5.h +++ b/dtool/src/parser-inc/krb5.h @@ -1,16 +1,15 @@ -// Filename: krb5.h -// Created by: drose (10Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file krb5.h + * @author drose + * @date 2003-07-10 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/libtar.h b/dtool/src/parser-inc/libtar.h index 83a56c5b2d..af0be1f33a 100644 --- a/dtool/src/parser-inc/libtar.h +++ b/dtool/src/parser-inc/libtar.h @@ -1,14 +1,13 @@ -// Filename: libtar.h -// Created by: drose (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file libtar.h + * @author drose + * @date 2007-06-28 + */ diff --git a/dtool/src/parser-inc/malloc.h b/dtool/src/parser-inc/malloc.h index 4e6506719e..4effbc1d73 100644 --- a/dtool/src/parser-inc/malloc.h +++ b/dtool/src/parser-inc/malloc.h @@ -1,14 +1,13 @@ -// Filename: malloc.h -// Created by: drose (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file malloc.h + * @author drose + * @date 2007-06-28 + */ diff --git a/dtool/src/parser-inc/math.h b/dtool/src/parser-inc/math.h index 6e61aa4e0b..c29252acec 100644 --- a/dtool/src/parser-inc/math.h +++ b/dtool/src/parser-inc/math.h @@ -1,14 +1,13 @@ -// Filename: math.h -// Created by: drose (26Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file math.h + * @author drose + * @date 2007-06-26 + */ diff --git a/dtool/src/parser-inc/mmsystem.h b/dtool/src/parser-inc/mmsystem.h index 2ae809fdc9..888a95e1b0 100644 --- a/dtool/src/parser-inc/mmsystem.h +++ b/dtool/src/parser-inc/mmsystem.h @@ -1,16 +1,15 @@ -// Filename: mmsystem.h -// Created by: darren (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mmsystem.h + * @author darren + * @date 2002-02-22 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/netinet/ip.h b/dtool/src/parser-inc/netinet/ip.h index 99a1bd8423..df1abcf00b 100644 --- a/dtool/src/parser-inc/netinet/ip.h +++ b/dtool/src/parser-inc/netinet/ip.h @@ -1,16 +1,15 @@ -// Filename: ip.h -// Created by: drose (08Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ip.h + * @author drose + * @date 2007-02-08 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/netinet/tcp.h b/dtool/src/parser-inc/netinet/tcp.h index b0aa1f91c8..50ecba5d56 100644 --- a/dtool/src/parser-inc/netinet/tcp.h +++ b/dtool/src/parser-inc/netinet/tcp.h @@ -1,16 +1,15 @@ -// Filename: tcp.h -// Created by: drose (08Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tcp.h + * @author drose + * @date 2007-02-08 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/nurbs.hh b/dtool/src/parser-inc/nurbs.hh index 80d9010956..6d7d143f71 100644 --- a/dtool/src/parser-inc/nurbs.hh +++ b/dtool/src/parser-inc/nurbs.hh @@ -1,16 +1,15 @@ -// Filename: nurbs.hh -// Created by: drose (02Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbs.hh + * @author drose + * @date 2001-03-02 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/ode.h b/dtool/src/parser-inc/ode.h index c34e687a92..b5b2e674ab 100644 --- a/dtool/src/parser-inc/ode.h +++ b/dtool/src/parser-inc/ode.h @@ -1,17 +1,16 @@ -// Filename: ode.h -// Created by: drose (27Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// /** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ode.h + * @author drose + * @date 2007-06-27 + */ + * @file config.h * common internal api header. */ diff --git a/dtool/src/parser-inc/ode/ode.h b/dtool/src/parser-inc/ode/ode.h index 6f9d0a0f6a..5c9a5a7835 100755 --- a/dtool/src/parser-inc/ode/ode.h +++ b/dtool/src/parser-inc/ode/ode.h @@ -1,16 +1,16 @@ -// Filename: ode.h -// Created by: drose (27Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ode.h + * @author drose + * @date 2007-06-27 + */ + /** * @file config.h * common internal api header. @@ -20,7 +20,7 @@ #define _ODE_CONFIG_H_ #define dSINGLE 1 -#define ODE_PLATFORM_WINDOWS +#define ODE_PLATFORM_WINDOWS #if !defined(ODE_API) #define ODE_API diff --git a/dtool/src/parser-inc/openssl/md5.h b/dtool/src/parser-inc/openssl/md5.h index e16d4f1e02..b2fbc750f8 100644 --- a/dtool/src/parser-inc/openssl/md5.h +++ b/dtool/src/parser-inc/openssl/md5.h @@ -1,16 +1,15 @@ -// Filename: md5.h -// Created by: drose (07Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file md5.h + * @author drose + * @date 2000-11-07 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/phyexp.h b/dtool/src/parser-inc/phyexp.h index 3162791316..88e233478b 100644 --- a/dtool/src/parser-inc/phyexp.h +++ b/dtool/src/parser-inc/phyexp.h @@ -1,16 +1,15 @@ -// Filename: phyexp.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file phyexp.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/pthread.h b/dtool/src/parser-inc/pthread.h index 9159cd69a6..e8e10837bc 100644 --- a/dtool/src/parser-inc/pthread.h +++ b/dtool/src/parser-inc/pthread.h @@ -1,16 +1,15 @@ -// Filename: pthread.h -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pthread.h + * @author drose + * @date 2006-02-10 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/py_panda.h b/dtool/src/parser-inc/py_panda.h index b8347f3c27..13059958c5 100644 --- a/dtool/src/parser-inc/py_panda.h +++ b/dtool/src/parser-inc/py_panda.h @@ -1,14 +1,13 @@ -// Filename: py_panda.h -// Created by: drose (22Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file py_panda.h + * @author drose + * @date 2007-06-22 + */ diff --git a/dtool/src/parser-inc/rfftw.h b/dtool/src/parser-inc/rfftw.h index ceb0aa25b1..47bb2102d1 100644 --- a/dtool/src/parser-inc/rfftw.h +++ b/dtool/src/parser-inc/rfftw.h @@ -1,16 +1,15 @@ -// Filename: rfftw.h -// Created by: drose (27Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rfftw.h + * @author drose + * @date 2007-06-27 + */ typedef struct _rfftw_plan rfftw_plan; diff --git a/dtool/src/parser-inc/setjmp.h b/dtool/src/parser-inc/setjmp.h index 984bf7e269..5b99b79eb9 100644 --- a/dtool/src/parser-inc/setjmp.h +++ b/dtool/src/parser-inc/setjmp.h @@ -1,16 +1,15 @@ -// Filename: setjmp.h -// Created by: drose (21Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file setjmp.h + * @author drose + * @date 2007-06-21 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/stdcompare.h b/dtool/src/parser-inc/stdcompare.h index 7eed6335a1..09c0b7d388 100644 --- a/dtool/src/parser-inc/stdcompare.h +++ b/dtool/src/parser-inc/stdcompare.h @@ -1,16 +1,15 @@ -// Filename: stdcompare.h -// Created by: drose (05Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stdcompare.h + * @author drose + * @date 2001-06-05 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/stddef.h b/dtool/src/parser-inc/stddef.h index a1b0f59c31..6867ac2156 100644 --- a/dtool/src/parser-inc/stddef.h +++ b/dtool/src/parser-inc/stddef.h @@ -1,16 +1,15 @@ -// Filename: stddef.h -// Created by: drose (26Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stddef.h + * @author drose + * @date 2002-09-26 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/stdint.h b/dtool/src/parser-inc/stdint.h index 11fba7a776..44729cbe17 100644 --- a/dtool/src/parser-inc/stdint.h +++ b/dtool/src/parser-inc/stdint.h @@ -1,16 +1,15 @@ -// Filename: stdint.h -// Created by: rdb (29Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stdint.h + * @author rdb + * @date 2010-03-29 + */ #ifndef _STDINT_H #define _STDINT_H diff --git a/dtool/src/parser-inc/stdmat.h b/dtool/src/parser-inc/stdmat.h index 4ec892dd35..44f91bdb17 100644 --- a/dtool/src/parser-inc/stdmat.h +++ b/dtool/src/parser-inc/stdmat.h @@ -1,16 +1,15 @@ -// Filename: stdmat.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stdmat.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/stdtypedefs.h b/dtool/src/parser-inc/stdtypedefs.h index ec71a37e12..5a92caaff7 100644 --- a/dtool/src/parser-inc/stdtypedefs.h +++ b/dtool/src/parser-inc/stdtypedefs.h @@ -1,16 +1,15 @@ -// Filename: stdtypedefs.h -// Created by: drose (12May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stdtypedefs.h + * @author drose + * @date 2000-05-12 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/ucontext.h b/dtool/src/parser-inc/ucontext.h index d20be01e1e..921ba6eece 100644 --- a/dtool/src/parser-inc/ucontext.h +++ b/dtool/src/parser-inc/ucontext.h @@ -1,15 +1,14 @@ -// Filename: ucontext.h -// Created by: drose (17Jan08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ucontext.h + * @author drose + * @date 2008-01-17 + */ typedef int ucontext_t; diff --git a/dtool/src/parser-inc/windows.h b/dtool/src/parser-inc/windows.h index 6ad9e3082a..81343a9744 100644 --- a/dtool/src/parser-inc/windows.h +++ b/dtool/src/parser-inc/windows.h @@ -1,16 +1,15 @@ -// Filename: windows.h -// Created by: drose (17Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windows.h + * @author drose + * @date 2000-08-17 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/parser-inc/zlib.h b/dtool/src/parser-inc/zlib.h index b7d777850a..74b373394a 100644 --- a/dtool/src/parser-inc/zlib.h +++ b/dtool/src/parser-inc/zlib.h @@ -1,16 +1,15 @@ -// Filename: zlib.h -// Created by: drose (14Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zlib.h + * @author drose + * @date 2000-09-14 + */ // This file, and all the other files in this directory, aren't // intended to be compiled--they're just parsed by CPPParser (and diff --git a/dtool/src/prc/androidLogStream.cxx b/dtool/src/prc/androidLogStream.cxx index 7f4cb943fb..b5512f9f52 100644 --- a/dtool/src/prc/androidLogStream.cxx +++ b/dtool/src/prc/androidLogStream.cxx @@ -1,16 +1,15 @@ -// Filename: androidLogStream.cxx -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidLogStream.cxx + * @author rdb + * @date 2013-01-12 + */ #include "androidLogStream.h" #include "configVariableString.h" @@ -19,11 +18,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidLogStream::AndroidLogStreamBuf:: AndroidLogStreamBuf(int priority) : _priority(priority) { @@ -38,30 +35,25 @@ AndroidLogStreamBuf(int priority) : } // The AndroidLogStreamBuf doesn't actually need a buffer--it's happy - // writing characters one at a time, since they're just getting - // stuffed into a string. (Although the code is written portably - // enough to use a buffer correctly, if we had one.) + // writing characters one at a time, since they're just getting stuffed into + // a string. (Although the code is written portably enough to use a buffer + // correctly, if we had one.) setg(0, 0, 0); setp(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidLogStream::AndroidLogStreamBuf:: ~AndroidLogStreamBuf() { sync(); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStreamBuf::sync -// Access: Public, Virtual -// Description: Called by the system ostream implementation when the -// buffer should be flushed to output (for instance, on -// destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when the buffer should be + * flushed to output (for instance, on destruction). + */ int AndroidLogStream::AndroidLogStreamBuf:: sync() { streamsize n = pptr() - pbase(); @@ -75,12 +67,10 @@ sync() { return 0; // EOF to indicate write full. } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStreamBuf::overflow -// Access: Public, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int AndroidLogStream::AndroidLogStreamBuf:: overflow(int ch) { streamsize n = pptr() - pbase(); @@ -97,11 +87,9 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStreamBuf::write_char -// Access: Private -// Description: Stores a single character. -//////////////////////////////////////////////////////////////////// +/** + * Stores a single character. + */ void AndroidLogStream::AndroidLogStreamBuf:: write_char(char c) { if (c == '\n') { @@ -113,32 +101,26 @@ write_char(char c) { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStream::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidLogStream:: AndroidLogStream(int priority) : ostream(new AndroidLogStreamBuf(priority)) { } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStream::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidLogStream:: ~AndroidLogStream() { delete rdbuf(); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidLogStream::out -// Access: Public, Static -// Description: Returns an AndroidLogStream suitable for writing -// log messages with the indicated severity. -//////////////////////////////////////////////////////////////////// +/** + * Returns an AndroidLogStream suitable for writing log messages with the + * indicated severity. + */ ostream &AndroidLogStream:: out(NotifySeverity severity) { static AndroidLogStream* streams[NS_fatal + 1] = {NULL}; diff --git a/dtool/src/prc/androidLogStream.h b/dtool/src/prc/androidLogStream.h index 1ca3438978..a565a348a3 100644 --- a/dtool/src/prc/androidLogStream.h +++ b/dtool/src/prc/androidLogStream.h @@ -1,16 +1,15 @@ -// Filename: androidLogStream.h -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidLogStream.h + * @author rdb + * @date 2013-01-12 + */ #ifndef ANDROIDLOGSTREAM_H #define ANDROIDLOGSTREAM_H @@ -23,11 +22,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : AndroidLogStream -// Description : This is a type of ostream that writes each line -// to the Android log. -//////////////////////////////////////////////////////////////////// +/** + * This is a type of ostream that writes each line to the Android log. + */ class AndroidLogStream : public ostream { private: class AndroidLogStreamBuf : public streambuf { diff --git a/dtool/src/prc/bigEndian.h b/dtool/src/prc/bigEndian.h index dc0cdad2cc..59f96066aa 100644 --- a/dtool/src/prc/bigEndian.h +++ b/dtool/src/prc/bigEndian.h @@ -1,16 +1,15 @@ -// Filename: bigEndian.h -// Created by: drose (23Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bigEndian.h + * @author drose + * @date 2000-08-23 + */ #ifndef BIGENDIAN_H #define BIGENDIAN_H @@ -21,13 +20,11 @@ #include "nativeNumericData.h" #include "reversedNumericData.h" -//////////////////////////////////////////////////////////////////// -// Class : BigEndian -// Description : BigEndian is a special class that automatically -// reverses the byte-order of numeric values for -// little-endian machines, and passes them through -// unchanged for big-endian machines. -//////////////////////////////////////////////////////////////////// +/** + * BigEndian is a special class that automatically reverses the byte-order of + * numeric values for little-endian machines, and passes them through + * unchanged for big-endian machines. + */ #ifdef WORDS_BIGENDIAN typedef NativeNumericData BigEndian; diff --git a/dtool/src/prc/configDeclaration.I b/dtool/src/prc/configDeclaration.I index ac080d58ac..889a01a4c4 100644 --- a/dtool/src/prc/configDeclaration.I +++ b/dtool/src/prc/configDeclaration.I @@ -1,25 +1,21 @@ -// Filename: configDeclaration.I -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configDeclaration.I + * @author drose + * @date 2004-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::operator < -// Access: Public -// Description: Sorts two declarations in order based on the order in -// which their respective pages were loaded, and the -// order in which they appear within the same page. -//////////////////////////////////////////////////////////////////// +/** + * Sorts two declarations in order based on the order in which their + * respective pages were loaded, and the order in which they appear within the + * same page. + */ INLINE bool ConfigDeclaration:: operator < (const ConfigDeclaration &other) const { if (get_page() == other.get_page()) { @@ -31,47 +27,36 @@ operator < (const ConfigDeclaration &other) const { return *get_page() < *other.get_page(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_page -// Access: Public -// Description: Returns the page on which this declaration can be -// found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the page on which this declaration can be found. + */ INLINE ConfigPage *ConfigDeclaration:: get_page() const { return _page; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_variable -// Access: Public -// Description: Returns the variable that this declaration names. -// This variable may or may not have been defined by the -// time the declaration is read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable that this declaration names. This variable may or may + * not have been defined by the time the declaration is read. + */ INLINE ConfigVariableCore *ConfigDeclaration:: get_variable() const { return _variable; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_string_value -// Access: Public -// Description: Returns the value assigned to this variable. This is -// the original one-line text defined for the variable -// in the .prc file (or passed to -// ConfigPage::make_declaration()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value assigned to this variable. This is the original one-line + * text defined for the variable in the .prc file (or passed to + * ConfigPage::make_declaration()). + */ INLINE const string &ConfigDeclaration:: get_string_value() const { return _string_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_string_value -// Access: Public -// Description: Changes the value assigned to this variable. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value assigned to this variable. + */ INLINE void ConfigDeclaration:: set_string_value(const string &string_value) { _string_value = string_value; @@ -79,13 +64,10 @@ set_string_value(const string &string_value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_num_words -// Access: Public -// Description: Returns the number of words in the declaration's -// value. A word is defined as a sequence of -// non-whitespace characters delimited by whitespace. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of words in the declaration's value. A word is defined + * as a sequence of non-whitespace characters delimited by whitespace. + */ INLINE size_t ConfigDeclaration:: get_num_words() const { if (!_got_words) { @@ -94,14 +76,11 @@ get_num_words() const { return _words.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::has_string_word -// Access: Public -// Description: Returns true if the declaration's value has a valid -// string value for the nth word. This is really the -// same thing as asking if there are at least n words in -// the value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the declaration's value has a valid string value for the + * nth word. This is really the same thing as asking if there are at least n + * words in the value. + */ INLINE bool ConfigDeclaration:: has_string_word(size_t n) const { if (!_got_words) { @@ -110,12 +89,10 @@ has_string_word(size_t n) const { return (n < _words.size()); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::has_bool_word -// Access: Public -// Description: Returns true if the declaration's value has a valid -// boolean value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the declaration's value has a valid boolean value for the + * nth word. + */ INLINE bool ConfigDeclaration:: has_bool_word(size_t n) const { if (has_string_word(n)) { @@ -125,12 +102,10 @@ has_bool_word(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::has_int_word -// Access: Public -// Description: Returns true if the declaration's value has a valid -// integer value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the declaration's value has a valid integer value for the + * nth word. + */ INLINE bool ConfigDeclaration:: has_int_word(size_t n) const { if (has_string_word(n)) { @@ -140,12 +115,10 @@ has_int_word(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::has_int64_word -// Access: Public -// Description: Returns true if the declaration's value has a valid -// int64 value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the declaration's value has a valid int64 value for the nth + * word. + */ INLINE bool ConfigDeclaration:: has_int64_word(size_t n) const { if (has_string_word(n)) { @@ -155,12 +128,10 @@ has_int64_word(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::has_double_word -// Access: Public -// Description: Returns true if the declaration's value has a valid -// integer value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the declaration's value has a valid integer value for the + * nth word. + */ INLINE bool ConfigDeclaration:: has_double_word(size_t n) const { if (has_string_word(n)) { @@ -170,13 +141,10 @@ has_double_word(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_string_word -// Access: Public -// Description: Returns the string value of the nth word of the -// declaration's value, or empty string if there is no -// nth value. See also has_string_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string value of the nth word of the declaration's value, or + * empty string if there is no nth value. See also has_string_word(). + */ INLINE string ConfigDeclaration:: get_string_word(size_t n) const { if (has_string_word(n)) { @@ -185,17 +153,14 @@ get_string_word(size_t n) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_bool_word -// Access: Public -// Description: Returns the boolean value of the nth word of the -// declaration's value, or false if there is no nth -// value. See also has_bool_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the boolean value of the nth word of the declaration's value, or + * false if there is no nth value. See also has_bool_word(). + */ INLINE bool ConfigDeclaration:: get_bool_word(size_t n) const { - // We use has_string_word() instead of has_bool_word(), so we can - // return a partial answer if there was one. + // We use has_string_word() instead of has_bool_word(), so we can return a + // partial answer if there was one. if (has_string_word(n)) { ((ConfigDeclaration *)this)->check_bool_word(n); return _words[n]._bool; @@ -203,17 +168,14 @@ get_bool_word(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_int_word -// Access: Public -// Description: Returns the integer value of the nth word of the -// declaration's value, or 0 if there is no nth value. -// See also has_int_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value of the nth word of the declaration's value, or 0 + * if there is no nth value. See also has_int_word(). + */ INLINE int ConfigDeclaration:: get_int_word(size_t n) const { - // We use has_string_word() instead of has_int_word(), so we can - // return a partial answer if there was one. + // We use has_string_word() instead of has_int_word(), so we can return a + // partial answer if there was one. if (has_string_word(n)) { ((ConfigDeclaration *)this)->check_int_word(n); return _words[n]._int; @@ -221,17 +183,14 @@ get_int_word(size_t n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_int64_word -// Access: Public -// Description: Returns the int64 value of the nth word of the -// declaration's value, or 0 if there is no nth value. -// See also has_int64_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the int64 value of the nth word of the declaration's value, or 0 if + * there is no nth value. See also has_int64_word(). + */ INLINE PN_int64 ConfigDeclaration:: get_int64_word(size_t n) const { - // We use has_string_word() instead of has_int64_word(), so we can - // return a partial answer if there was one. + // We use has_string_word() instead of has_int64_word(), so we can return a + // partial answer if there was one. if (has_string_word(n)) { ((ConfigDeclaration *)this)->check_int64_word(n); return _words[n]._int_64; @@ -239,17 +198,14 @@ get_int64_word(size_t n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_double_word -// Access: Public -// Description: Returns the integer value of the nth word of the -// declaration's value, or 0 if there is no nth value. -// See also has_double_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value of the nth word of the declaration's value, or 0 + * if there is no nth value. See also has_double_word(). + */ INLINE double ConfigDeclaration:: get_double_word(size_t n) const { - // We use has_string_word() instead of has_double_word(), so we can - // return a partial answer if there was one. + // We use has_string_word() instead of has_double_word(), so we can return a + // partial answer if there was one. if (has_string_word(n)) { ((ConfigDeclaration *)this)->check_double_word(n); return _words[n]._double; @@ -258,15 +214,12 @@ get_double_word(size_t n) const { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_decl_seq -// Access: Public -// Description: Returns the sequence number of the declaration within -// the page. Sequence numbers are assigned as each -// declaration is created; each declaration is given a -// higher sequence number than all the declarations -// created in the page before it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sequence number of the declaration within the page. Sequence + * numbers are assigned as each declaration is created; each declaration is + * given a higher sequence number than all the declarations created in the + * page before it. + */ INLINE int ConfigDeclaration:: get_decl_seq() const { return _decl_seq; diff --git a/dtool/src/prc/configDeclaration.cxx b/dtool/src/prc/configDeclaration.cxx index f299e63d54..2c7550e90d 100644 --- a/dtool/src/prc/configDeclaration.cxx +++ b/dtool/src/prc/configDeclaration.cxx @@ -1,16 +1,15 @@ -// Filename: configDeclaration.cxx -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configDeclaration.cxx + * @author drose + * @date 2004-10-15 + */ #include "configDeclaration.h" #include "configVariableCore.h" @@ -18,12 +17,10 @@ #include "pstrtod.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::Constructor -// Access: Private -// Description: Use the ConfigPage::make_declaration() interface to -// create a new declaration. -//////////////////////////////////////////////////////////////////// +/** + * Use the ConfigPage::make_declaration() interface to create a new + * declaration. + */ ConfigDeclaration:: ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, const string &string_value, int decl_seq) : @@ -38,12 +35,9 @@ ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::Destructor -// Access: Private -// Description: Use the ConfigPage::delete_declaration() interface to -// delete a declaration. -//////////////////////////////////////////////////////////////////// +/** + * Use the ConfigPage::delete_declaration() interface to delete a declaration. + */ ConfigDeclaration:: ~ConfigDeclaration() { if (!_page->is_special()) { @@ -51,12 +45,10 @@ ConfigDeclaration:: } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_string_word -// Access: Public -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ void ConfigDeclaration:: set_string_word(size_t n, const string &value) { if (!_got_words) { @@ -85,12 +77,10 @@ set_string_word(size_t n, const string &value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_bool_word -// Access: Public -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ void ConfigDeclaration:: set_bool_word(size_t n, bool value) { set_string_word(n, value ? "1" : "0"); @@ -100,12 +90,10 @@ set_bool_word(size_t n, bool value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_int_word -// Access: Public -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ void ConfigDeclaration:: set_int_word(size_t n, int value) { set_string_word(n, format_string(value)); @@ -115,12 +103,10 @@ set_int_word(size_t n, int value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_int64_word -// Access: Public -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ void ConfigDeclaration:: set_int64_word(size_t n, PN_int64 value) { set_string_word(n, format_string(value)); @@ -130,12 +116,10 @@ set_int64_word(size_t n, PN_int64 value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::set_double_word -// Access: Public -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ void ConfigDeclaration:: set_double_word(size_t n, double value) { set_string_word(n, format_string(value)); @@ -145,35 +129,27 @@ set_double_word(size_t n, double value) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigDeclaration:: output(ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigDeclaration:: write(ostream &out) const { out << get_variable()->get_name() << " " << get_string_value(); - //if (!get_variable()->is_used()) { - // out << " (not used)"; - //} + // if (!get_variable()->is_used()) { out << " (not used)"; } out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::get_words -// Access: Private -// Description: Separates the string value into words. -//////////////////////////////////////////////////////////////////// +/** + * Separates the string value into words. + */ void ConfigDeclaration:: get_words() { if (!_got_words) { @@ -195,12 +171,9 @@ get_words() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::check_bool_word -// Access: Private -// Description: Checks whether the nth word can be interpreted as a -// boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the nth word can be interpreted as a boolean value. + */ void ConfigDeclaration:: check_bool_word(size_t n) { if (!_got_words) { @@ -242,12 +215,9 @@ check_bool_word(size_t n) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::check_int_word -// Access: Private -// Description: Checks whether the nth word can be interpreted as an -// integer value. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the nth word can be interpreted as an integer value. + */ void ConfigDeclaration:: check_int_word(size_t n) { if (!_got_words) { @@ -259,8 +229,8 @@ check_int_word(size_t n) { if ((word._flags & F_checked_int) == 0) { word._flags |= F_checked_int; - // We scan the word by hand, rather than relying on strtol(), so - // we can check for overflow of the 32-bit value. + // We scan the word by hand, rather than relying on strtol(), so we can + // check for overflow of the 32-bit value. word._int = 0; bool overflow = false; @@ -302,12 +272,9 @@ check_int_word(size_t n) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::check_int64_word -// Access: Private -// Description: Checks whether the nth word can be interpreted as an -// integer value. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the nth word can be interpreted as an integer value. + */ void ConfigDeclaration:: check_int64_word(size_t n) { if (!_got_words) { @@ -360,12 +327,9 @@ check_int64_word(size_t n) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::check_double_word -// Access: Private -// Description: Checks whether the nth word can be interpreted as a -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the nth word can be interpreted as a floating-point value. + */ void ConfigDeclaration:: check_double_word(size_t n) { if (!_got_words) { @@ -392,17 +356,14 @@ check_double_word(size_t n) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::extract_words -// Access: Public, Static -// Description: Divides the string into a number of words according -// to whitespace. The words vector should be cleared by -// the user before calling; otherwise, the list of words -// in the string will be appended to the end of whatever -// was there before. -// -// The return value is the number of words extracted. -//////////////////////////////////////////////////////////////////// +/** + * Divides the string into a number of words according to whitespace. The + * words vector should be cleared by the user before calling; otherwise, the + * list of words in the string will be appended to the end of whatever was + * there before. + * + * The return value is the number of words extracted. + */ size_t ConfigDeclaration:: extract_words(const string &str, vector_string &words) { size_t num_words = 0; @@ -427,12 +388,9 @@ extract_words(const string &str, vector_string &words) { return num_words; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigDeclaration::downcase -// Access: Public, Static -// Description: Returns the input string with all uppercase letters -// converted to lowercase. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input string with all uppercase letters converted to lowercase. + */ string ConfigDeclaration:: downcase(const string &s) { string result; diff --git a/dtool/src/prc/configDeclaration.h b/dtool/src/prc/configDeclaration.h index e578380280..7e9c96b6a5 100644 --- a/dtool/src/prc/configDeclaration.h +++ b/dtool/src/prc/configDeclaration.h @@ -1,16 +1,15 @@ -// Filename: configDeclaration.h -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configDeclaration.h + * @author drose + * @date 2004-10-15 + */ #ifndef CONFIGDECLARATION_H #define CONFIGDECLARATION_H @@ -25,14 +24,12 @@ class ConfigVariableCore; -//////////////////////////////////////////////////////////////////// -// Class : ConfigDeclaration -// Description : A single declaration of a config variable, typically -// defined as one line in a .prc file, -// e.g. "show-frame-rate-meter 1". This is really just -// a pairing of a string name (actually, a -// ConfigVariableCore pointer) to a string value. -//////////////////////////////////////////////////////////////////// +/** + * A single declaration of a config variable, typically defined as one line in + * a .prc file, e.g. "show-frame-rate-meter 1". This is really just a + * pairing of a string name (actually, a ConfigVariableCore pointer) to a + * string value. + */ class EXPCL_DTOOLCONFIG ConfigDeclaration : public ConfigFlags { private: ConfigDeclaration(ConfigPage *page, ConfigVariableCore *variable, diff --git a/dtool/src/prc/configFlags.I b/dtool/src/prc/configFlags.I index d13cdd2699..6f35c4d814 100644 --- a/dtool/src/prc/configFlags.I +++ b/dtool/src/prc/configFlags.I @@ -1,62 +1,49 @@ -// Filename: configFlags.I -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configFlags.I + * @author drose + * @date 2004-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigFlags::is_cache_valid -// Access: Protected, Static -// Description: Returns true if the local object's cache is still -// valid (based on a comparison of the supplied -// local_modified value with the global_modified value). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the local object's cache is still valid (based on a + * comparison of the supplied local_modified value with the global_modified + * value). + */ ALWAYS_INLINE bool ConfigFlags:: is_cache_valid(AtomicAdjust::Integer local_modified) { return local_modified == _global_modified; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigFlags::mark_cache_valid -// Access: Protected, Static -// Description: Updates the indicated local_modified value so that -// the cache will appear to be valid, until someone next -// calls invalidate_cache(). -//////////////////////////////////////////////////////////////////// +/** + * Updates the indicated local_modified value so that the cache will appear to + * be valid, until someone next calls invalidate_cache(). + */ ALWAYS_INLINE void ConfigFlags:: mark_cache_valid(AtomicAdjust::Integer &local_modified) { local_modified = _global_modified; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigFlags::initial_invalid_cache -// Access: Protected, Static -// Description: Returns a value that will be appropriate for -// initializing a local_modified value. This value will -// indicate an invalid cache in the next call to -// is_cache_valid(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a value that will be appropriate for initializing a local_modified + * value. This value will indicate an invalid cache in the next call to + * is_cache_valid(). + */ INLINE AtomicAdjust::Integer ConfigFlags:: initial_invalid_cache() { return _global_modified - 1; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigFlags::invalidate_cache -// Access: Protected, Static -// Description: Invalidates all of the global ConfigVariable caches -// in the world at once, by incrementing the -// global_modified counter. -//////////////////////////////////////////////////////////////////// +/** + * Invalidates all of the global ConfigVariable caches in the world at once, + * by incrementing the global_modified counter. + */ INLINE void ConfigFlags:: invalidate_cache() { AtomicAdjust::inc(_global_modified); diff --git a/dtool/src/prc/configFlags.cxx b/dtool/src/prc/configFlags.cxx index 233fa5d307..7d9fb90eec 100644 --- a/dtool/src/prc/configFlags.cxx +++ b/dtool/src/prc/configFlags.cxx @@ -1,25 +1,23 @@ -// Filename: configFlags.cxx -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configFlags.cxx + * @author drose + * @date 2004-10-21 + */ #include "configFlags.h" TVOLATILE AtomicAdjust::Integer ConfigFlags::_global_modified; -//////////////////////////////////////////////////////////////////// -// Function: ConfigFlags::Type output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, ConfigFlags::ValueType type) { switch (type) { diff --git a/dtool/src/prc/configFlags.h b/dtool/src/prc/configFlags.h index b7a3205468..7333c80393 100644 --- a/dtool/src/prc/configFlags.h +++ b/dtool/src/prc/configFlags.h @@ -1,16 +1,15 @@ -// Filename: configFlags.h -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configFlags.h + * @author drose + * @date 2004-10-21 + */ #ifndef CONFIGFLAGS_H #define CONFIGFLAGS_H @@ -19,13 +18,11 @@ #include "numeric_types.h" #include "atomicAdjust.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigFlags -// Description : This class is the base class of both ConfigVariable -// and ConfigVariableCore. It exists only to provide a -// convenient name scoping for some enumerated values -// common to both classes. -//////////////////////////////////////////////////////////////////// +/** + * This class is the base class of both ConfigVariable and ConfigVariableCore. + * It exists only to provide a convenient name scoping for some enumerated + * values common to both classes. + */ class EXPCL_DTOOLCONFIG ConfigFlags { PUBLISHED: enum ValueType { @@ -43,21 +40,20 @@ PUBLISHED: }; enum VariableFlags { - // Trust level. We have the bottom twelve bits reserved for a - // trust level indicator; then the open and closed bits are a - // special case. + // Trust level. We have the bottom twelve bits reserved for a trust level + // indicator; then the open and closed bits are a special case. F_trust_level_mask = 0x00000fff, F_open = 0x00001000, F_closed = 0x00002000, // F_dynamic means that the variable name is generated dynamically - // (possibly from a very large pool) and should not be included in - // the normal list of variable names. + // (possibly from a very large pool) and should not be included in the + // normal list of variable names. F_dynamic = 0x00004000, - // F_dconfig means that the variable was constructed from the - // legacy DConfig system, rather than directly by the user. You - // shouldn't pass this in directly. + // F_dconfig means that the variable was constructed from the legacy + // DConfig system, rather than directly by the user. You shouldn't pass + // this in directly. F_dconfig = 0x00008000, }; diff --git a/dtool/src/prc/configPage.I b/dtool/src/prc/configPage.I index 9f3f62cda4..e4ed5ccf60 100644 --- a/dtool/src/prc/configPage.I +++ b/dtool/src/prc/configPage.I @@ -1,155 +1,124 @@ -// Filename: configPage.I -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPage.I + * @author drose + * @date 2004-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::operator < -// Access: Public -// Description: Sorts two pages in order based on the order in -// which their respective pages were loaded, and the -// order in which they appear within the same page. -//////////////////////////////////////////////////////////////////// +/** + * Sorts two pages in order based on the order in which their respective pages + * were loaded, and the order in which they appear within the same page. + */ INLINE bool ConfigPage:: operator < (const ConfigPage &other) const { - // The explicit sort value is the most important setting. It's - // usually zero unless explicitly changed. + // The explicit sort value is the most important setting. It's usually zero + // unless explicitly changed. if (get_sort() != other.get_sort()) { return get_sort() < other.get_sort(); } - // Within the implicit/explicit categorization, sort by the page - // sequence. The higher page sequence is more important (since it - // was loaded later), so it gets sorted to the front of the list. + // Within the implicitexplicit categorization, sort by the page sequence. + // The higher page sequence is more important (since it was loaded later), + // so it gets sorted to the front of the list. return get_page_seq() > other.get_page_seq(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_name -// Access: Published -// Description: Returns the name of the page. If the page was loaded -// from a .prc file, this is usually the filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the page. If the page was loaded from a .prc file, + * this is usually the filename. + */ INLINE const string &ConfigPage:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::is_special -// Access: Published -// Description: Returns true if this is the special "default" or -// "local" page, or false if it is an ordinary page, -// e.g. an implicit page loaded from a prc file at -// startup, or an explicit page created by -// ConfigPageManager::make_explicit_page(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is the special "default" or "local" page, or false if + * it is an ordinary page, e.g. an implicit page loaded from a prc file at + * startup, or an explicit page created by + * ConfigPageManager::make_explicit_page(). + */ INLINE bool ConfigPage:: is_special() const { return this == get_default_page() || this == get_local_page(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::is_implicit -// Access: Published -// Description: Returns true if the page was loaded by implicitly -// searching the config path on startup, or false if it -// was explicitly loaded by dynamic code after initial -// startup. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the page was loaded by implicitly searching the config path + * on startup, or false if it was explicitly loaded by dynamic code after + * initial startup. + */ INLINE bool ConfigPage:: is_implicit() const { return _implicit_load; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_sort -// Access: Published -// Description: Returns the explicit sort order of this particular -// ConfigPage. See set_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the explicit sort order of this particular ConfigPage. See + * set_sort(). + */ INLINE int ConfigPage:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_page_seq -// Access: Published -// Description: Returns the sequence number of the page. -// -// Sequence numbers for a particular class (implicit -// vs. explicit) of pages are assigned as each page is -// loaded; each page is given a higher sequence number -// than all the pages loaded before it. -// -// The implicit_load pages, which are discovered in the -// file system automatically, have a different set of -// sequence numbers than the explicit pages. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sequence number of the page. + * + * Sequence numbers for a particular class (implicit vs. explicit) of pages + * are assigned as each page is loaded; each page is given a higher sequence + * number than all the pages loaded before it. + * + * The implicit_load pages, which are discovered in the file system + * automatically, have a different set of sequence numbers than the explicit + * pages. + */ INLINE int ConfigPage:: get_page_seq() const { return _page_seq; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_trust_level -// Access: Published -// Description: Returns the trust level associated with this page. -// An untrusted page is trust level 0; if the page was -// loaded from a signed .prc file, its trust level is -// the index number of the certificate that signed it. -// Generally, a higher trust level value represents -// a greater level of trust. -//////////////////////////////////////////////////////////////////// +/** + * Returns the trust level associated with this page. An untrusted page is + * trust level 0; if the page was loaded from a signed .prc file, its trust + * level is the index number of the certificate that signed it. Generally, a + * higher trust level value represents a greater level of trust. + */ INLINE int ConfigPage:: get_trust_level() const { return _trust_level; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::set_trust_level -// Access: Published -// Description: Explicitly sets the trust level on this particular -// page. Note that any subsequent changes to the page, -// or to any variable declarations on it, will reset the -// trust level to zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the trust level on this particular page. Note that any + * subsequent changes to the page, or to any variable declarations on it, will + * reset the trust level to zero. + */ INLINE void ConfigPage:: set_trust_level(int trust_level) { _trust_level = trust_level; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_signature -// Access: Published -// Description: Returns the raw binary signature that was found in -// the prc file, if any. This method is probably not -// terribly useful for most applications. -//////////////////////////////////////////////////////////////////// +/** + * Returns the raw binary signature that was found in the prc file, if any. + * This method is probably not terribly useful for most applications. + */ INLINE const string &ConfigPage:: get_signature() const { return _signature; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::make_dirty -// Access: Private -// Description: Called internally when the page is changed through -// some API operation, this is intended as a hook to -// mark the page untrusted. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the page is changed through some API operation, this + * is intended as a hook to mark the page untrusted. + */ INLINE void ConfigPage:: make_dirty() { _trust_level = 0; diff --git a/dtool/src/prc/configPage.cxx b/dtool/src/prc/configPage.cxx index 4148c64ca7..ab65fdcd73 100644 --- a/dtool/src/prc/configPage.cxx +++ b/dtool/src/prc/configPage.cxx @@ -1,16 +1,15 @@ -// Filename: configPage.cxx -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPage.cxx + * @author drose + * @date 2004-10-15 + */ #include "configPage.h" #include "configDeclaration.h" @@ -29,13 +28,10 @@ ConfigPage *ConfigPage::_default_page = NULL; ConfigPage *ConfigPage::_local_page = NULL; -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::Constructor -// Access: Private -// Description: The constructor is private because a ConfigPage -// should be constructed via the ConfigPageManager -// make_page() interface. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is private because a ConfigPage should be constructed via + * the ConfigPageManager make_page() interface. + */ ConfigPage:: ConfigPage(const string &name, bool implicit_load, int page_seq) : _name(name), @@ -47,25 +43,19 @@ ConfigPage(const string &name, bool implicit_load, int page_seq) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::Destructor -// Access: Private -// Description: The destructor is private because a ConfigPage -// should be deleted via the ConfigPageManager -// delete_page() interface. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is private because a ConfigPage should be deleted via the + * ConfigPageManager delete_page() interface. + */ ConfigPage:: ~ConfigPage() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_default_page -// Access: Published, Static -// Description: Returns a pointer to the global "default page". This -// is the ConfigPage that lists all variables' original -// default values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global "default page". This is the ConfigPage + * that lists all variables' original default values. + */ ConfigPage *ConfigPage:: get_default_page() { if (_default_page == (ConfigPage *)NULL) { @@ -74,14 +64,11 @@ get_default_page() { return _default_page; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_local_page -// Access: Published, Static -// Description: Returns a pointer to the global "local page". This -// is the ConfigPage that lists the locally-assigned -// values for any variables in the world that have such -// a local assignment. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global "local page". This is the ConfigPage that + * lists the locally-assigned values for any variables in the world that have + * such a local assignment. + */ ConfigPage *ConfigPage:: get_local_page() { if (_local_page == (ConfigPage *)NULL) { @@ -90,18 +77,13 @@ get_local_page() { return _local_page; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::set_sort -// Access: Published -// Description: Changes the explicit sort order of this particular -// ConfigPage. Lower-numbered pages supercede -// higher-numbered pages. Initially, all -// explicitly-loaded pages have sort value 0, and -// implicitly-loaded pages (found on disk) have sort -// value 10; you may set an individual page higher or -// lower to influence its priority relative to other -// pages. -//////////////////////////////////////////////////////////////////// +/** + * Changes the explicit sort order of this particular ConfigPage. Lower- + * numbered pages supercede higher-numbered pages. Initially, all explicitly- + * loaded pages have sort value 0, and implicitly-loaded pages (found on disk) + * have sort value 10; you may set an individual page higher or lower to + * influence its priority relative to other pages. + */ void ConfigPage:: set_sort(int sort) { if (_sort != sort) { @@ -110,11 +92,9 @@ set_sort(int sort) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::clear -// Access: Published -// Description: Removes all of the declarations from the page. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the declarations from the page. + */ void ConfigPage:: clear() { Declarations::iterator di; @@ -127,33 +107,28 @@ clear() { _signature = string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::read_prc -// Access: Published -// Description: Reads the contents of a complete prc file, as -// returned by the indicated istream, into the current -// page file. Returns true on success, or false on some -// I/O error. -// -// This is a low-level interface. Normally you do not -// need to call it directly. See the global functions -// load_prc_file() and unload_prc_file(), defined in -// panda/src/putil, for a higher-level interface. -//////////////////////////////////////////////////////////////////// +/** + * Reads the contents of a complete prc file, as returned by the indicated + * istream, into the current page file. Returns true on success, or false on + * some I/O error. + * + * This is a low-level interface. Normally you do not need to call it + * directly. See the global functions load_prc_file() and unload_prc_file(), + * defined in panda/src/putil, for a higher-level interface. + */ bool ConfigPage:: read_prc(istream &in) { - // We must empty the page before we start to read it; otherwise - // trust level is meaningless. + // We must empty the page before we start to read it; otherwise trust level + // is meaningless. clear(); - // We avoid getline() here because of its notorious problem with - // last lines that lack a trailing newline character. + // We avoid getline() here because of its notorious problem with last lines + // that lack a trailing newline character. static const size_t buffer_size = 1024; char buffer[buffer_size]; #ifdef HAVE_OPENSSL - // Set up the evp context for verifying the signature, if we find - // one. + // Set up the evp context for verifying the signature, if we find one. #ifdef SSL_097 _md_ctx = EVP_MD_CTX_create(); #else @@ -190,16 +165,15 @@ read_prc(istream &in) { newline = (char *)memchr((void *)start, '\n', buffer_end - start); } - // The remaining text in the buffer is the start of the next - // line. + // The remaining text in the buffer is the start of the next line. length = buffer_end - start; prev_line = string(start, length); } if (in.fail() || in.eof()) { - // If we got a failure reading the buffer last time, don't keep - // reading again. Irix seems to require this test; otherwise, - // it repeatedly returns the same text at the end of the file. + // If we got a failure reading the buffer last time, don't keep reading + // again. Irix seems to require this test; otherwise, it repeatedly + // returns the same text at the end of the file. count = 0; } else { @@ -220,9 +194,9 @@ read_prc(istream &in) { for (int i = 1; i < num_keys && _trust_level == 0; i++) { EVP_PKEY *pkey = pkr->get_key(i); if (pkey != (EVP_PKEY *)NULL) { - int verify_result = - EVP_VerifyFinal((EVP_MD_CTX *)_md_ctx, - (unsigned char *)_signature.data(), + int verify_result = + EVP_VerifyFinal((EVP_MD_CTX *)_md_ctx, + (unsigned char *)_signature.data(), _signature.size(), pkey); if (verify_result == 1) { _trust_level = i; @@ -230,7 +204,7 @@ read_prc(istream &in) { } } if (_trust_level == 0) { - prc_cat->info() + prc_cat->info() << "invalid signature found in " << get_name() << "\n"; } } @@ -246,13 +220,10 @@ read_prc(istream &in) { return !failed; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::read_encrypted_prc -// Access: Published -// Description: Automatically decrypts and reads the stream, given -// the indicated password. Note that if the password is -// incorrect, the result may be garbage. -//////////////////////////////////////////////////////////////////// +/** + * Automatically decrypts and reads the stream, given the indicated password. + * Note that if the password is incorrect, the result may be garbage. + */ bool ConfigPage:: read_encrypted_prc(istream &in, const string &password) { #ifdef HAVE_OPENSSL @@ -263,24 +234,18 @@ read_encrypted_prc(istream &in, const string &password) { #endif // HAVE_OPENSSL } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::make_declaration -// Access: Published -// Description: Adds the indicated variable/value pair as a new -// declaration on the page. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated variable/value pair as a new declaration on the page. + */ ConfigDeclaration *ConfigPage:: make_declaration(const string &variable, const string &value) { ConfigVariableManager *variable_mgr = ConfigVariableManager::get_global_ptr(); return make_declaration(variable_mgr->make_variable(variable), value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::make_declaration -// Access: Published -// Description: Adds the indicated variable/value pair as a new -// declaration on the page. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated variable/value pair as a new declaration on the page. + */ ConfigDeclaration *ConfigPage:: make_declaration(ConfigVariableCore *variable, const string &value) { ConfigDeclaration *decl = new ConfigDeclaration @@ -293,14 +258,11 @@ make_declaration(ConfigVariableCore *variable, const string &value) { return decl; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::delete_declaration -// Access: Published -// Description: Removes the indicated declaration from the page and -// deletes it. Returns true if the declaration is -// successfully removed, false if it was not on the -// page. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated declaration from the page and deletes it. Returns + * true if the declaration is successfully removed, false if it was not on the + * page. + */ bool ConfigPage:: delete_declaration(ConfigDeclaration *decl) { Declarations::iterator di; @@ -316,93 +278,74 @@ delete_declaration(ConfigDeclaration *decl) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_num_declarations -// Access: Published -// Description: Returns the number of declarations on the page. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of declarations on the page. + */ size_t ConfigPage:: get_num_declarations() const { return _declarations.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_declaration -// Access: Published -// Description: Returns the nth declaration on the page. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth declaration on the page. + */ const ConfigDeclaration *ConfigPage:: get_declaration(size_t n) const { nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); return _declarations[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::modify_declaration -// Access: Published -// Description: Returns a modifiable pointer to the nth declaration -// on the page. Any modifications will appear in the -// output, if the page is written out with -// ConfigPage::write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the nth declaration on the page. Any + * modifications will appear in the output, if the page is written out with + * ConfigPage::write(). + */ ConfigDeclaration *ConfigPage:: modify_declaration(size_t n) { nassertr(n < _declarations.size(), (ConfigDeclaration *)NULL); return _declarations[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_variable_name -// Access: Published -// Description: Returns the variable named by the nth declaration on -// the page. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable named by the nth declaration on the page. + */ string ConfigPage:: get_variable_name(size_t n) const { nassertr(n < _declarations.size(), string()); return _declarations[n]->get_variable()->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::get_string_value -// Access: Published -// Description: Returns the value assigned by the nth declaration on -// the page. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value assigned by the nth declaration on the page. + */ string ConfigPage:: get_string_value(size_t n) const { nassertr(n < _declarations.size(), string()); return _declarations[n]->get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::is_variable_used -// Access: Published -// Description: Returns true if the nth active variable on -// the page has been used by code, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth active variable on the page has been used by code, + * false otherwise. + */ bool ConfigPage:: is_variable_used(size_t n) const { nassertr(n < _declarations.size(), false); return _declarations[n]->get_variable()->is_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigPage:: output(ostream &out) const { out << "ConfigPage " << get_name() << ", " << get_num_declarations() << " declarations."; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::output_brief_signature -// Access: Published -// Description: Outputs the first few hex digits of the signature. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the first few hex digits of the signature. + */ void ConfigPage:: output_brief_signature(ostream &out) const { size_t num_bytes = min(_signature.size(), (size_t)8); @@ -425,11 +368,9 @@ output_brief_signature(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigPage:: write(ostream &out) const { Declarations::const_iterator di; @@ -438,18 +379,15 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::read_prc_line -// Access: Private -// Description: Handles reading in a single line from a .prc file. -// This is called internally by read_prc() for each -// line. -//////////////////////////////////////////////////////////////////// +/** + * Handles reading in a single line from a .prc file. This is called + * internally by read_prc() for each line. + */ void ConfigPage:: read_prc_line(const string &line) { if (line.substr(0, 7) == "##!sig ") { - // This is a signature. Accumulate it into the signature and - // return, and don't count it as contributing to the hash. + // This is a signature. Accumulate it into the signature and return, and + // don't count it as contributing to the hash. for (size_t p = 7; p < line.length() - 1; p += 2) { unsigned char digit = (hex_digit(line[p]) << 4) | hex_digit(line[p + 1]); _signature += digit; @@ -458,8 +396,8 @@ read_prc_line(const string &line) { } #ifdef HAVE_OPENSSL - // Accumulate any line that's not itself a signature into the hash, - // so we can validate the signature at the end. + // Accumulate any line that's not itself a signature into the hash, so we + // can validate the signature at the end. EVP_VerifyUpdate((EVP_MD_CTX *)_md_ctx, line.data(), line.size()); #endif // HAVE_OPENSSL @@ -492,9 +430,8 @@ read_prc_line(const string &line) { p = line.length(); } - // The value extends from here to the end of the line (or to the - // start of the embedded comment), so trim whitespace backwards off - // from there. + // The value extends from here to the end of the line (or to the start of + // the embedded comment), so trim whitespace backwards off from there. while (p > value_begin && isspace((unsigned char)line[p - 1])) { p--; } @@ -506,11 +443,9 @@ read_prc_line(const string &line) { make_declaration(variable, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPage::hex_digit -// Access: Private, Static -// Description: Decodes a hex digit into its numeric value. -//////////////////////////////////////////////////////////////////// +/** + * Decodes a hex digit into its numeric value. + */ unsigned int ConfigPage:: hex_digit(unsigned char digit) { if (isalpha(digit)) { diff --git a/dtool/src/prc/configPage.h b/dtool/src/prc/configPage.h index ebddb55e21..63ec9106df 100644 --- a/dtool/src/prc/configPage.h +++ b/dtool/src/prc/configPage.h @@ -1,16 +1,15 @@ -// Filename: configPage.h -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPage.h + * @author drose + * @date 2004-10-15 + */ #ifndef CONFIGPAGE_H #define CONFIGPAGE_H @@ -22,14 +21,12 @@ class ConfigDeclaration; class ConfigVariableCore; -//////////////////////////////////////////////////////////////////// -// Class : ConfigPage -// Description : A page of ConfigDeclarations that may be loaded or -// unloaded. Typically this represents a single .prc -// file that is read from disk at runtime, but it may -// also represent a list of declarations built up -// by application code and explicitly loaded. -//////////////////////////////////////////////////////////////////// +/** + * A page of ConfigDeclarations that may be loaded or unloaded. Typically + * this represents a single .prc file that is read from disk at runtime, but + * it may also represent a list of declarations built up by application code + * and explicitly loaded. + */ class EXPCL_DTOOLCONFIG ConfigPage { private: ConfigPage(const string &name, bool implicit_load, int page_seq); @@ -97,8 +94,8 @@ private: string _signature; #ifdef HAVE_OPENSSL - // This maintains the hash of the prc file as we are scanning it, so - // we can compare its signature which we discover at the end. + // This maintains the hash of the prc file as we are scanning it, so we can + // compare its signature which we discover at the end. void *_md_ctx; #endif // HAVE_OPENSSL diff --git a/dtool/src/prc/configPageManager.I b/dtool/src/prc/configPageManager.I index 9ca0abb8ca..16dbeb3e6c 100644 --- a/dtool/src/prc/configPageManager.I +++ b/dtool/src/prc/configPageManager.I @@ -1,39 +1,31 @@ -// Filename: configPageManager.I -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPageManager.I + * @author drose + * @date 2004-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::loaded_implicit_pages -// Access: Published -// Description: Returns true if the implicit *.prc files have already -// been loaded, false otherwise. Normally this will -// only be false briefly before startup. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the implicit *.prc files have already been loaded, false + * otherwise. Normally this will only be false briefly before startup. + */ INLINE bool ConfigPageManager:: loaded_implicit_pages() const { return _loaded_implicit; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::load_implicit_pages -// Access: Published -// Description: Searches the PRC_DIR and/or PRC_PATH directories for -// *.prc files and loads them in as pages. This is -// normally called automatically at startup time, when -// the first variable's value is referenced. See also -// reload_implicit_pages(). -//////////////////////////////////////////////////////////////////// +/** + * Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads + * them in as pages. This is normally called automatically at startup time, + * when the first variable's value is referenced. See also + * reload_implicit_pages(). + */ INLINE void ConfigPageManager:: load_implicit_pages() { if (!_loaded_implicit) { @@ -41,120 +33,93 @@ load_implicit_pages() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_search_path -// Access: Published -// Description: Returns the search path used to locate implicit .prc -// files. This is determined by the PRC_DIR and -// PRC_PATH environment variables. The object returned -// by this method may be modified to change the path at -// runtime, and then reload_implicit_pages() called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the search path used to locate implicit .prc files. This is + * determined by the PRC_DIR and PRC_PATH environment variables. The object + * returned by this method may be modified to change the path at runtime, and + * then reload_implicit_pages() called. + */ INLINE DSearchPath &ConfigPageManager:: get_search_path() { load_implicit_pages(); return _search_path; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_num_prc_patterns -// Access: Published -// Description: Returns the number of patterns, like "*.prc", that -// are compiled in that will be searched for as default -// config filenames. Normally there is only one -// pattern, and it is "*.prc", but others may be -// specified with the PRC_FILENAME variable in -// Config.pp. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of patterns, like "*.prc", that are compiled in that + * will be searched for as default config filenames. Normally there is only + * one pattern, and it is "*.prc", but others may be specified with the + * PRC_FILENAME variable in Config.pp. + */ INLINE size_t ConfigPageManager:: get_num_prc_patterns() const { return _prc_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_prc_pattern -// Access: Published -// Description: Returns the nth filename pattern that will be -// considered a match as a valid config file. See -// get_num_prc_patterns(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth filename pattern that will be considered a match as a valid + * config file. See get_num_prc_patterns(). + */ INLINE string ConfigPageManager:: get_prc_pattern(size_t n) const { nassertr(n < _prc_patterns.size(), string()); return _prc_patterns[n].get_pattern(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_num_prc_encrypted_patterns -// Access: Published -// Description: Returns the number of patterns, like "*.pre", that -// are compiled in that will be searched for as special -// config files that are understood to be encrypted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of patterns, like "*.pre", that are compiled in that + * will be searched for as special config files that are understood to be + * encrypted. + */ INLINE size_t ConfigPageManager:: get_num_prc_encrypted_patterns() const { return _prc_encrypted_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_prc_encrypted_pattern -// Access: Published -// Description: Returns the nth filename pattern that will be -// considered a match as a valid encrypted config -// file. See get_num_prc_encrypted_patterns(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth filename pattern that will be considered a match as a valid + * encrypted config file. See get_num_prc_encrypted_patterns(). + */ INLINE string ConfigPageManager:: get_prc_encrypted_pattern(size_t n) const { nassertr(n < _prc_patterns.size(), string()); return _prc_encrypted_patterns[n].get_pattern(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_num_prc_executable_patterns -// Access: Published -// Description: Returns the number of patterns, like "*.exe", that -// are compiled in that will be searched for as special -// config files that are to be executed as a program, -// and their output taken to be input. This is normally -// empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of patterns, like "*.exe", that are compiled in that + * will be searched for as special config files that are to be executed as a + * program, and their output taken to be input. This is normally empty. + */ INLINE size_t ConfigPageManager:: get_num_prc_executable_patterns() const { return _prc_executable_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_prc_executable_pattern -// Access: Published -// Description: Returns the nth filename pattern that will be -// considered a match as a valid executable-style config -// file. See get_num_prc_executable_patterns(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth filename pattern that will be considered a match as a valid + * executable-style config file. See get_num_prc_executable_patterns(). + */ INLINE string ConfigPageManager:: get_prc_executable_pattern(size_t n) const { nassertr(n < _prc_patterns.size(), string()); return _prc_executable_patterns[n].get_pattern(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_num_implicit_pages -// Access: Published -// Description: Returns the current number of implicitly-loaded -// ConfigPages in the world. These represent files that -// were automatically discovered on the disk as .prc -// files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of implicitly-loaded ConfigPages in the world. + * These represent files that were automatically discovered on the disk as + * .prc files. + */ INLINE size_t ConfigPageManager:: get_num_implicit_pages() const { return _implicit_pages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_implicit_page -// Access: Published -// Description: Returns the nth implicit ConfigPage in the world. -// See get_num_implicit_pages(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth implicit ConfigPage in the world. See + * get_num_implicit_pages(). + */ INLINE ConfigPage *ConfigPageManager:: get_implicit_page(size_t n) const { check_sort_pages(); @@ -162,25 +127,20 @@ get_implicit_page(size_t n) const { return _implicit_pages[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_num_explicit_pages -// Access: Published -// Description: Returns the current number of explicitly-loaded -// ConfigPages in the world. These represent pages that -// were loaded dynamically at runtime by explicit calls -// to ConfigPageManager::make_explicit_page(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of explicitly-loaded ConfigPages in the world. + * These represent pages that were loaded dynamically at runtime by explicit + * calls to ConfigPageManager::make_explicit_page(). + */ INLINE size_t ConfigPageManager:: get_num_explicit_pages() const { return _explicit_pages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_explicit_page -// Access: Published -// Description: Returns the nth explicit ConfigPage in the world. -// See get_num_explicit_pages(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth explicit ConfigPage in the world. See + * get_num_explicit_pages(). + */ INLINE ConfigPage *ConfigPageManager:: get_explicit_page(size_t n) const { check_sort_pages(); @@ -189,25 +149,19 @@ get_explicit_page(size_t n) const { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::mark_unsorted() -// Access: Public -// Description: This method is meant to be used internally to this -// module; there is no need to call it directly. It -// indicates that the sort values of some pages may have -// changed and pages need to be re-sorted. -//////////////////////////////////////////////////////////////////// +/** + * This method is meant to be used internally to this module; there is no need + * to call it directly. It indicates that the sort values of some pages may + * have changed and pages need to be re-sorted. + */ INLINE void ConfigPageManager:: mark_unsorted() { _pages_sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::check_sort_pages() -// Access: Private -// Description: Called internally to ensure that the list of -// pages is properly sorted. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to ensure that the list of pages is properly sorted. + */ INLINE void ConfigPageManager:: check_sort_pages() const { if (!_pages_sorted) { diff --git a/dtool/src/prc/configPageManager.cxx b/dtool/src/prc/configPageManager.cxx index eae07c92c8..f7868aa394 100644 --- a/dtool/src/prc/configPageManager.cxx +++ b/dtool/src/prc/configPageManager.cxx @@ -1,16 +1,15 @@ -// Filename: configPageManager.cxx -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPageManager.cxx + * @author drose + * @date 2004-10-15 + */ #include "configPageManager.h" #include "configDeclaration.h" @@ -40,14 +39,11 @@ ConfigPageManager *ConfigPageManager::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::Constructor -// Access: Protected -// Description: The constructor is private (actually, just protected, -// but only to avoid a gcc compiler warning) because it -// should not be explicitly constructed. There is only -// one ConfigPageManager, and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is private (actually, just protected, but only to avoid a + * gcc compiler warning) because it should not be explicitly constructed. + * There is only one ConfigPageManager, and it constructs itself. + */ ConfigPageManager:: ConfigPageManager() { _next_page_seq = 1; @@ -61,34 +57,28 @@ ConfigPageManager() { #endif // PRC_PUBLIC_KEYS_INCLUDE } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::Destructor -// Access: Protected -// Description: The ConfigPageManager destructor should never be -// called, because this is a global object that is never -// freed. -//////////////////////////////////////////////////////////////////// +/** + * The ConfigPageManager destructor should never be called, because this is a + * global object that is never freed. + */ ConfigPageManager:: ~ConfigPageManager() { prc_cat->error() << "Internal error--ConfigPageManager destructor called!\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::reload_implicit_pages -// Access: Published -// Description: Searches the PRC_DIR and/or PRC_PATH directories for -// *.prc files and loads them in as pages. -// -// This may be called after startup, to force the system -// to re-read all of the implicit prc files. -//////////////////////////////////////////////////////////////////// +/** + * Searches the PRC_DIR and/or PRC_PATH directories for *.prc files and loads + * them in as pages. + * + * This may be called after startup, to force the system to re-read all of the + * implicit prc files. + */ void ConfigPageManager:: reload_implicit_pages() { if (_currently_loading) { - // This is a recursion protector. We can get recursion feedback - // between config and notify, as each tries to use the other at - // construction. + // This is a recursion protector. We can get recursion feedback between + // config and notify, as each tries to use the other at construction. return; } _currently_loading = true; @@ -100,8 +90,8 @@ reload_implicit_pages() { } _implicit_pages.clear(); - // PRC_PATTERNS lists one or more filename templates separated by - // spaces. Pull them out and store them in _prc_patterns. + // PRC_PATTERNS lists one or more filename templates separated by spaces. + // Pull them out and store them in _prc_patterns. _prc_patterns.clear(); string prc_patterns = PRC_PATTERNS; @@ -112,8 +102,8 @@ reload_implicit_pages() { for (size_t i = 0; i < pat_list.size(); ++i) { GlobPattern glob(pat_list[i]); #ifdef WIN32 - // On windows, the file system is case-insensitive, so the - // pattern should be too. + // On windows, the file system is case-insensitive, so the pattern + // should be too. glob.set_case_sensitive(false); #endif // WIN32 _prc_patterns.push_back(glob); @@ -157,9 +147,9 @@ reload_implicit_pages() { // Now build up the search path for .prc files. _search_path.clear(); - // PRC_DIR_ENVVARS lists one or more environment variables separated - // by spaces. Pull them out, and each of those contains the name of - // a single directory to search. Add it to the search path. + // PRC_DIR_ENVVARS lists one or more environment variables separated by + // spaces. Pull them out, and each of those contains the name of a single + // directory to search. Add it to the search path. string prc_dir_envvars = PRC_DIR_ENVVARS; if (!prc_dir_envvars.empty()) { vector_string prc_dir_envvar_list; @@ -175,11 +165,10 @@ reload_implicit_pages() { } } } - - // PRC_PATH_ENVVARS lists one or more environment variables separated - // by spaces. Pull them out, and then each one of those contains a - // list of directories to search. Add each of those to the search - // path. + + // PRC_PATH_ENVVARS lists one or more environment variables separated by + // spaces. Pull them out, and then each one of those contains a list of + // directories to search. Add each of those to the search path. string prc_path_envvars = PRC_PATH_ENVVARS; if (!prc_path_envvars.empty()) { vector_string prc_path_envvar_list; @@ -201,15 +190,16 @@ reload_implicit_pages() { } } } - - // PRC_PATH2_ENVVARS is a special variable that is rarely used; it - // exists primarily to support the Cygwin-based "ctattach" tools - // used by the Walt Disney VR Studio. This defines a set of - // environment variable(s) that define a search path, as above; - // except that the directory names on these search paths are - // Panda-style filenames, not Windows-style filenames; and the path - // separator is always a space character, regardless of - // DEFAULT_PATHSEP. + +/* + * PRC_PATH2_ENVVARS is a special variable that is rarely used; it exists + * primarily to support the Cygwin-based "ctattach" tools used by the Walt + * Disney VR Studio. This defines a set of environment variable(s) that + * define a search path, as above; except that the directory names on these + * search paths are Panda-style filenames, not Windows-style filenames; and + * the path separator is always a space character, regardless of + * DEFAULT_PATHSEP. + */ string prc_path2_envvars = PRC_PATH2_ENVVARS; if (!prc_path2_envvars.empty()) { vector_string prc_path_envvar_list; @@ -230,7 +220,7 @@ reload_implicit_pages() { } } } - + if (_search_path.is_empty()) { // If nothing's on the search path (PRC_DIR and PRC_PATH were not // defined), then use the DEFAULT_PRC_DIR. @@ -244,17 +234,16 @@ reload_implicit_pages() { } } - // Now find all of the *.prc files (or whatever matches - // PRC_PATTERNS) on the path. + // Now find all of the *.prc files (or whatever matches PRC_PATTERNS) on the + // path. ConfigFiles config_files; - // Use a set to ensure that we only visit each directory once, even - // if it appears multiple times (under different aliases!) in the - // path. + // Use a set to ensure that we only visit each directory once, even if it + // appears multiple times (under different aliases!) in the path. set unique_dirnames; - // We walk through the list of directories in forward order, so that - // the most important directories are visited first. + // We walk through the list of directories in forward order, so that the + // most important directories are visited first. for (size_t di = 0; di < _search_path.get_num_directories(); ++di) { const Filename &directory = _search_path.get_directory(di); if (directory.is_directory()) { @@ -265,10 +254,10 @@ reload_implicit_pages() { directory.scan_directory(files); // We walk through the directory's list of files in reverse - // alphabetical order, because for historical reasons, the - // most important file within a directory is the - // alphabetically last file of that directory, and we still - // want to visit the most important files first. + // alphabetical order, because for historical reasons, the most + // important file within a directory is the alphabetically last file + // of that directory, and we still want to visit the most important + // files first. vector_string::reverse_iterator fi; for (fi = files.rbegin(); fi != files.rend(); ++fi) { int file_flags = 0; @@ -308,10 +297,10 @@ reload_implicit_pages() { } } - // Now we have a list of filenames in order from most important to - // least important. Walk through the list in reverse order to load - // their contents, because we want the first file in the list (the - // most important) to be on the top of the stack. + // Now we have a list of filenames in order from most important to least + // important. Walk through the list in reverse order to load their + // contents, because we want the first file in the list (the most important) + // to be on the top of the stack. ConfigFiles::reverse_iterator ci; int i = 1; for (ci = config_files.rbegin(); ci != config_files.rend(); ++ci) { @@ -337,13 +326,13 @@ reload_implicit_pages() { ++i; _implicit_pages.push_back(page); _pages_sorted = false; - + page->read_prc(ifs); } else if ((file._file_flags & FF_decrypt) != 0) { // Read and decrypt the file. filename.set_binary(); - + pifstream in; if (!filename.open_read(in)) { prc_cat.error() @@ -353,14 +342,14 @@ reload_implicit_pages() { ++i; _implicit_pages.push_back(page); _pages_sorted = false; - + page->read_encrypted_prc(in, PRC_ENCRYPTION_KEY); } } else if ((file._file_flags & FF_read) != 0) { // Just read the file. filename.set_text(); - + pifstream in; if (!filename.open_read(in)) { prc_cat.error() @@ -370,7 +359,7 @@ reload_implicit_pages() { ++i; _implicit_pages.push_back(page); _pages_sorted = false; - + page->read_prc(in); } } @@ -385,8 +374,8 @@ reload_implicit_pages() { invalidate_cache(); #ifdef USE_PANDAFILESTREAM - // Update this very low-level config variable here, for lack of any - // better place. + // Update this very low-level config variable here, for lack of any better + // place. ConfigVariableEnum newline_mode ("newline-mode", PandaFileStreamBuf::NM_native, PRC_DESC("Controls how newlines are written by Panda applications writing " @@ -398,8 +387,8 @@ reload_implicit_pages() { #endif // USE_PANDAFILESTREAM #ifdef WIN32 - // We don't necessarily want an error dialog when we fail to load a - // .dll file. But sometimes it is useful for debugging. + // We don't necessarily want an error dialog when we fail to load a .dll + // file. But sometimes it is useful for debugging. ConfigVariableBool show_dll_error_dialog ("show-dll-error-dialog", false, PRC_DESC("Set this true to enable the Windows system dialog that pops " @@ -412,19 +401,16 @@ reload_implicit_pages() { SetErrorMode(0); } else { SetErrorMode(SEM_FAILCRITICALERRORS); - } + } #endif } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::make_explicit_page -// Access: Published -// Description: Creates and returns a new, empty ConfigPage. This -// page will be stacked on top of any pages that were -// created before; it may shadow variable declarations -// that are defined in previous pages. -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new, empty ConfigPage. This page will be stacked on + * top of any pages that were created before; it may shadow variable + * declarations that are defined in previous pages. + */ ConfigPage *ConfigPageManager:: make_explicit_page(const string &name) { ConfigPage *page = new ConfigPage(name, false, _next_page_seq); @@ -435,16 +421,13 @@ make_explicit_page(const string &name) { return page; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::delete_explicit_page -// Access: Published -// Description: Removes a previously-constructed ConfigPage from the -// set of active pages, and deletes it. The ConfigPage -// object is no longer valid after this call. Returns -// true if the page is successfully deleted, or false if -// it was unknown (which should never happen if the page -// was legitimately constructed). -//////////////////////////////////////////////////////////////////// +/** + * Removes a previously-constructed ConfigPage from the set of active pages, + * and deletes it. The ConfigPage object is no longer valid after this call. + * Returns true if the page is successfully deleted, or false if it was + * unknown (which should never happen if the page was legitimately + * constructed). + */ bool ConfigPageManager:: delete_explicit_page(ConfigPage *page) { Pages::iterator pi; @@ -459,23 +442,19 @@ delete_explicit_page(ConfigPage *page) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigPageManager:: output(ostream &out) const { - out << "ConfigPageManager, " - << _explicit_pages.size() + _implicit_pages.size() + out << "ConfigPageManager, " + << _explicit_pages.size() + _implicit_pages.size() << " pages."; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigPageManager:: write(ostream &out) const { check_sort_pages(); @@ -516,11 +495,9 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::get_global_ptr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConfigPageManager *ConfigPageManager:: get_global_ptr() { if (_global_ptr == (ConfigPageManager *)NULL) { @@ -537,13 +514,10 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::sort_pages -// Access: Private -// Description: Sorts the list of pages into priority order, -// so that the page at the front of the list is -// the one that shadows all following pages. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the list of pages into priority order, so that the page at the front + * of the list is the one that shadows all following pages. + */ void ConfigPageManager:: sort_pages() { sort(_implicit_pages.begin(), _implicit_pages.end(), CompareConfigPages()); @@ -552,27 +526,22 @@ sort_pages() { _pages_sorted = true; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::scan_auto_prc_dir -// Access: Private -// Description: Checks for the prefix "" in the value of the -// $PRC_DIR environment variable (or in the compiled-in -// DEFAULT_PRC_DIR value). If it is found, then the -// actual directory is determined by searching upward -// from the executable's starting directory, or from the -// current working directory, until at least one .prc -// file is found. -// -// Returns true if the prc_dir has been filled with a -// valid directory name, false if no good directory name -// was found. -//////////////////////////////////////////////////////////////////// +/** + * Checks for the prefix "" in the value of the $PRC_DIR environment + * variable (or in the compiled-in DEFAULT_PRC_DIR value). If it is found, + * then the actual directory is determined by searching upward from the + * executable's starting directory, or from the current working directory, + * until at least one .prc file is found. + * + * Returns true if the prc_dir has been filled with a valid directory name, + * false if no good directory name was found. + */ bool ConfigPageManager:: scan_auto_prc_dir(Filename &prc_dir) const { string prc_dir_string = prc_dir; if (prc_dir_string.substr(0, 6) == "") { Filename suffix = prc_dir_string.substr(6); - + // Start at the dtool directory. Filename dtool = ExecutionEnvironment::get_dtool_name(); Filename dir = dtool.get_dirname(); @@ -580,7 +549,7 @@ scan_auto_prc_dir(Filename &prc_dir) const { if (scan_up_from(prc_dir, dir, suffix)) { return true; } - + // Try the program's directory. dir = ExecutionEnvironment::get_environment_variable("MAIN_DIR"); if (scan_up_from(prc_dir, dir, suffix)) { @@ -597,22 +566,19 @@ scan_auto_prc_dir(Filename &prc_dir) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::scan_up_from -// Access: Private -// Description: Used to implement scan_auto_prc_dir(), above, this -// scans upward from the indicated directory name until -// a directory is found that includes at least one .prc -// file, or the root directory is reached. -// -// If a match is found, puts it result and returns true; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Used to implement scan_auto_prc_dir(), above, this scans upward from the + * indicated directory name until a directory is found that includes at least + * one .prc file, or the root directory is reached. + * + * If a match is found, puts it result and returns true; otherwise, returns + * false. + */ bool ConfigPageManager:: -scan_up_from(Filename &result, const Filename &dir, +scan_up_from(Filename &result, const Filename &dir, const Filename &suffix) const { Filename consider(dir, suffix); - + vector_string files; if (consider.is_directory()) { if (consider.scan_directory(files)) { @@ -651,15 +617,12 @@ scan_up_from(Filename &result, const Filename &dir, return scan_up_from(result, parent, suffix); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigPageManager::config_initialized -// Access: Private -// Description: This is called once, at startup, the first time that -// the config system has been initialized and is ready -// to read config variables. It's intended to be a -// place to initialize values that are defined at a -// lower level than the config system itself. -//////////////////////////////////////////////////////////////////// +/** + * This is called once, at startup, the first time that the config system has + * been initialized and is ready to read config variables. It's intended to + * be a place to initialize values that are defined at a lower level than the + * config system itself. + */ void ConfigPageManager:: config_initialized() { Notify::ptr()->config_initialized(); diff --git a/dtool/src/prc/configPageManager.h b/dtool/src/prc/configPageManager.h index acc5acd0e1..ff81b3dc57 100644 --- a/dtool/src/prc/configPageManager.h +++ b/dtool/src/prc/configPageManager.h @@ -1,16 +1,15 @@ -// Filename: configPageManager.h -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configPageManager.h + * @author drose + * @date 2004-10-15 + */ #ifndef CONFIGPAGEMANAGER_H #define CONFIGPAGEMANAGER_H @@ -25,12 +24,10 @@ class ConfigPage; -//////////////////////////////////////////////////////////////////// -// Class : ConfigPageManager -// Description : A global object that maintains the set of ConfigPages -// everywhere in the world, and keeps them in sorted -// order. -//////////////////////////////////////////////////////////////////// +/** + * A global object that maintains the set of ConfigPages everywhere in the + * world, and keeps them in sorted order. + */ class EXPCL_DTOOLCONFIG ConfigPageManager : public ConfigFlags { protected: ConfigPageManager(); @@ -74,7 +71,7 @@ private: void sort_pages(); bool scan_auto_prc_dir(Filename &prc_dir) const; - bool scan_up_from(Filename &result, const Filename &dir, + bool scan_up_from(Filename &result, const Filename &dir, const Filename &suffix) const; void config_initialized(); @@ -95,9 +92,9 @@ private: Globs _prc_encrypted_patterns; Globs _prc_executable_patterns; - // In load_implicit_pages(), we temporarily build up a list of - // potential config files to read and/or execute. We'll need some - // data structures to store that information. + // In load_implicit_pages(), we temporarily build up a list of potential + // config files to read andor execute. We'll need some data structures to + // store that information. enum FileFlags { FF_read = 0x001, FF_execute = 0x002, diff --git a/dtool/src/prc/configVariable.I b/dtool/src/prc/configVariable.I index 435233e459..65ef0380aa 100644 --- a/dtool/src/prc/configVariable.I +++ b/dtool/src/prc/configVariable.I @@ -1,36 +1,30 @@ -// Filename: configVariable.I -// Created by: drose (18Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariable.I + * @author drose + * @date 2004-10-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::Constructor -// Access: Protected -// Description: This constructor is only intended to be called from a -// specialized ConfigVariableFoo derived class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended to be called from a specialized + * ConfigVariableFoo derived class. + */ INLINE ConfigVariable:: ConfigVariable(const string &name, ConfigVariable::ValueType value_type) : ConfigVariableBase(name, value_type) { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::Constructor -// Access: Protected -// Description: This constructor is only intended to be called from a -// specialized ConfigVariableFoo derived class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended to be called from a specialized + * ConfigVariableFoo derived class. + */ INLINE ConfigVariable:: ConfigVariable(const string &name, ConfigVariable::ValueType value_type, const string &description, int flags) : @@ -38,14 +32,11 @@ ConfigVariable(const string &name, ConfigVariable::ValueType value_type, { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::Constructor -// Access: Published -// Description: Use this constructor to make a ConfigVariable of an -// unspecified type. Usually you'd want to do this just -// to reference a previously-defined ConfigVariable of a -// specific type, without having to know what type it is. -//////////////////////////////////////////////////////////////////// +/** + * Use this constructor to make a ConfigVariable of an unspecified type. + * Usually you'd want to do this just to reference a previously-defined + * ConfigVariable of a specific type, without having to know what type it is. + */ INLINE ConfigVariable:: ConfigVariable(const string &name) : ConfigVariableBase(name, VT_undefined) @@ -53,34 +44,26 @@ ConfigVariable(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariable:: ~ConfigVariable() { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_default_value -// Access: Published -// Description: Returns the default variable specified for this -// variable. If the variable has not yet been defined, -// this will return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default variable specified for this variable. If the variable + * has not yet been defined, this will return NULL. + */ INLINE const ConfigDeclaration *ConfigVariable:: get_default_value() const { nassertr(is_constructed(), (ConfigDeclaration *)NULL); return _core->get_default_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_string_value -// Access: Published -// Description: Returns the toplevel value of the variable, formatted -// as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the toplevel value of the variable, formatted as a string. + */ INLINE const string &ConfigVariable:: get_string_value() const { nassertr(is_constructed(), *new string()); @@ -88,40 +71,31 @@ get_string_value() const { return decl->get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_string_value -// Access: Published -// Description: Changes the value assigned to this variable. This -// creates a local value that shadows any values defined -// in the .prc files, until clear_local_value() is -// called. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value assigned to this variable. This creates a local value + * that shadows any values defined in the .prc files, until + * clear_local_value() is called. + */ INLINE void ConfigVariable:: set_string_value(const string &string_value) { nassertv(is_constructed()); _core->make_local_value()->set_string_value(string_value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::clear_value -// Access: Published -// Description: Removes the value assigned to this variable, and lets -// its original value (as read from the prc files) show -// through. -//////////////////////////////////////////////////////////////////// +/** + * Removes the value assigned to this variable, and lets its original value + * (as read from the prc files) show through. + */ INLINE void ConfigVariable:: clear_value() { nassertv(is_constructed()); _core->clear_local_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_num_words -// Access: Published -// Description: Returns the number of words in the variable's -// value. A word is defined as a sequence of -// non-whitespace characters delimited by whitespace. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of words in the variable's value. A word is defined as + * a sequence of non-whitespace characters delimited by whitespace. + */ INLINE size_t ConfigVariable:: get_num_words() const { nassertr(is_constructed(), 0); @@ -129,14 +103,11 @@ get_num_words() const { return decl->get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::has_string_word -// Access: Published -// Description: Returns true if the variable's value has a valid -// string value for the nth word. This is really the -// same thing as asking if there are at least n words in -// the value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable's value has a valid string value for the nth + * word. This is really the same thing as asking if there are at least n + * words in the value. + */ INLINE bool ConfigVariable:: has_string_word(size_t n) const { nassertr(is_constructed(), false); @@ -144,12 +115,10 @@ has_string_word(size_t n) const { return decl->has_string_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::has_bool_word -// Access: Published -// Description: Returns true if the variable's value has a valid -// boolean value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable's value has a valid boolean value for the nth + * word. + */ INLINE bool ConfigVariable:: has_bool_word(size_t n) const { nassertr(is_constructed(), false); @@ -157,12 +126,10 @@ has_bool_word(size_t n) const { return decl->has_bool_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::has_int_word -// Access: Published -// Description: Returns true if the variable's value has a valid -// integer value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable's value has a valid integer value for the nth + * word. + */ INLINE bool ConfigVariable:: has_int_word(size_t n) const { nassertr(is_constructed(), false); @@ -170,12 +137,10 @@ has_int_word(size_t n) const { return decl->has_int_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::has_int64_word -// Access: Published -// Description: Returns true if the variable's value has a valid -// 64-bit integer value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable's value has a valid 64-bit integer value for + * the nth word. + */ INLINE bool ConfigVariable:: has_int64_word(size_t n) const { nassertr(is_constructed(), false); @@ -183,12 +148,10 @@ has_int64_word(size_t n) const { return decl->has_int64_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::has_double_word -// Access: Published -// Description: Returns true if the variable's value has a valid -// integer value for the nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable's value has a valid integer value for the nth + * word. + */ INLINE bool ConfigVariable:: has_double_word(size_t n) const { nassertr(is_constructed(), false); @@ -196,13 +159,10 @@ has_double_word(size_t n) const { return decl->has_double_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_string_word -// Access: Published -// Description: Returns the string value of the nth word of the -// variable's value, or empty string if there is no -// nth value. See also has_string_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string value of the nth word of the variable's value, or empty + * string if there is no nth value. See also has_string_word(). + */ INLINE string ConfigVariable:: get_string_word(size_t n) const { nassertr(is_constructed(), string()); @@ -210,13 +170,10 @@ get_string_word(size_t n) const { return decl->get_string_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_bool_word -// Access: Published -// Description: Returns the boolean value of the nth word of the -// variable's value, or false if there is no nth -// value. See also has_bool_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the boolean value of the nth word of the variable's value, or false + * if there is no nth value. See also has_bool_word(). + */ INLINE bool ConfigVariable:: get_bool_word(size_t n) const { nassertr(is_constructed(), false); @@ -224,13 +181,10 @@ get_bool_word(size_t n) const { return decl->get_bool_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_int_word -// Access: Published -// Description: Returns the integer value of the nth word of the -// variable's value, or 0 if there is no nth value. -// See also has_int_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value of the nth word of the variable's value, or 0 if + * there is no nth value. See also has_int_word(). + */ INLINE int ConfigVariable:: get_int_word(size_t n) const { nassertr(is_constructed(), 0); @@ -238,13 +192,10 @@ get_int_word(size_t n) const { return decl->get_int_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_int64_word -// Access: Published -// Description: Returns the int64 value of the nth word of the -// variable's value, or 0 if there is no nth value. -// See also has_int_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the int64 value of the nth word of the variable's value, or 0 if + * there is no nth value. See also has_int_word(). + */ INLINE PN_int64 ConfigVariable:: get_int64_word(size_t n) const { nassertr(is_constructed(), 0); @@ -252,13 +203,10 @@ get_int64_word(size_t n) const { return decl->get_int64_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::get_double_word -// Access: Published -// Description: Returns the integer value of the nth word of the -// variable's value, or 0 if there is no nth value. -// See also has_double_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer value of the nth word of the variable's value, or 0 if + * there is no nth value. See also has_double_word(). + */ INLINE double ConfigVariable:: get_double_word(size_t n) const { nassertr(is_constructed(), 0.0); @@ -266,75 +214,62 @@ get_double_word(size_t n) const { return decl->get_double_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_string_word -// Access: Published -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ INLINE void ConfigVariable:: set_string_word(size_t n, const string &value) { nassertv(is_constructed()); _core->make_local_value()->set_string_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_bool_word -// Access: Published -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ INLINE void ConfigVariable:: set_bool_word(size_t n, bool value) { nassertv(is_constructed()); _core->make_local_value()->set_bool_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_int_word -// Access: Published -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ INLINE void ConfigVariable:: set_int_word(size_t n, int value) { nassertv(is_constructed()); _core->make_local_value()->set_int_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_int64_word -// Access: Published -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ INLINE void ConfigVariable:: set_int64_word(size_t n, PN_int64 value) { nassertv(is_constructed()); _core->make_local_value()->set_int64_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::set_double_word -// Access: Published -// Description: Changes the nth word to the indicated value without -// affecting the other words. -//////////////////////////////////////////////////////////////////// +/** + * Changes the nth word to the indicated value without affecting the other + * words. + */ INLINE void ConfigVariable:: set_double_word(size_t n, double value) { nassertv(is_constructed()); _core->make_local_value()->set_double_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::is_constructed -// Access: Protected -// Description: Returns true if the constructor has been called and -// _core initialized, false if the constructor has not -// yet been called and _core is NULL. This is intended -// to be placed in an assertion check, to guard against -// static-init ordering issues. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the constructor has been called and _core initialized, + * false if the constructor has not yet been called and _core is NULL. This + * is intended to be placed in an assertion check, to guard against static- + * init ordering issues. + */ INLINE bool ConfigVariable:: is_constructed() const { #ifndef NDEBUG diff --git a/dtool/src/prc/configVariable.cxx b/dtool/src/prc/configVariable.cxx index 72ca1b2da2..3ef722eb52 100644 --- a/dtool/src/prc/configVariable.cxx +++ b/dtool/src/prc/configVariable.cxx @@ -1,27 +1,24 @@ -// Filename: configVariable.cxx -// Created by: drose (18Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariable.cxx + * @author drose + * @date 2004-10-18 + */ #include "configVariable.h" #include "config_prc.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariable::report_unconstructed -// Access: Protected -// Description: Displays a suitable error message when an -// unconstructed ConfigVariable is attempted to be used. -// This normally indicates a static-init ordering issue. -//////////////////////////////////////////////////////////////////// +/** + * Displays a suitable error message when an unconstructed ConfigVariable is + * attempted to be used. This normally indicates a static-init ordering + * issue. + */ void ConfigVariable:: report_unconstructed() const { prc_cat->error() @@ -29,4 +26,3 @@ report_unconstructed() const { << " accessed before its constructor has run!\n"; record_unconstructed(); } - diff --git a/dtool/src/prc/configVariable.h b/dtool/src/prc/configVariable.h index d3a79e3b7a..a937b1cdea 100644 --- a/dtool/src/prc/configVariable.h +++ b/dtool/src/prc/configVariable.h @@ -1,16 +1,15 @@ -// Filename: configVariable.h -// Created by: drose (18Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariable.h + * @author drose + * @date 2004-10-18 + */ #ifndef CONFIGVARIABLE_H #define CONFIGVARIABLE_H @@ -19,19 +18,16 @@ #include "configVariableBase.h" #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariable -// Description : This is a generic, untyped ConfigVariable. It is -// also the base class for the typed ConfigVariables, -// and contains all of the code common to -// ConfigVariables of all types (except -// ConfigVariableList, which is a bit of a special -// case). -// -// Mostly, this class serves as a thin wrapper around -// ConfigVariableCore and/or ConfigDeclaration, more or -// less duplicating the interface presented there. -//////////////////////////////////////////////////////////////////// +/** + * This is a generic, untyped ConfigVariable. It is also the base class for + * the typed ConfigVariables, and contains all of the code common to + * ConfigVariables of all types (except ConfigVariableList, which is a bit of + * a special case). + * + * Mostly, this class serves as a thin wrapper around ConfigVariableCore + * and/or ConfigDeclaration, more or less duplicating the interface presented + * there. + */ class EXPCL_DTOOLCONFIG ConfigVariable : public ConfigVariableBase { protected: INLINE ConfigVariable(const string &name, ValueType type); diff --git a/dtool/src/prc/configVariableBase.I b/dtool/src/prc/configVariableBase.I index d9abd86037..09db1c4088 100644 --- a/dtool/src/prc/configVariableBase.I +++ b/dtool/src/prc/configVariableBase.I @@ -1,26 +1,22 @@ -// Filename: configVariableBase.I -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBase.I + * @author drose + * @date 2004-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::Constructor -// Access: Protected -// Description: This constructor is only intended to be called from a -// specialized ConfigVariableFoo derived class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended to be called from a specialized + * ConfigVariableFoo derived class. + */ INLINE ConfigVariableBase:: -ConfigVariableBase(const string &name, +ConfigVariableBase(const string &name, ConfigVariableBase::ValueType value_type) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) { @@ -29,180 +25,140 @@ ConfigVariableBase(const string &name, } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableBase:: ~ConfigVariableBase() { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::get_name -// Access: Published -// Description: Returns the name of the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the variable. + */ INLINE const string &ConfigVariableBase:: get_name() const { nassertr(_core != (ConfigVariableCore *)NULL, *new string()); return _core->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::get_value_type -// Access: Published -// Description: Returns the stated type of this variable. This -// should be VT_list, unless a later variable -// declaration has changed it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated type of this variable. This should be VT_list, unless a + * later variable declaration has changed it. + */ INLINE ConfigVariableBase::ValueType ConfigVariableBase:: get_value_type() const { nassertr(_core != (ConfigVariableCore *)NULL, VT_undefined); return _core->get_value_type(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::get_description -// Access: Published -// Description: Returns the brief description of this variable, if -// it has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the brief description of this variable, if it has been defined. + */ INLINE const string &ConfigVariableBase:: get_description() const { nassertr(_core != (ConfigVariableCore *)NULL, *new string()); return _core->get_description(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::get_flags -// Access: Public -// Description: Returns the flags value as set by set_flags(). This -// includes the trust level and some other settings. -// See the individual methods is_closed(), -// get_trust_level(), etc. to pull out the semantic -// meaning of these flags individually. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flags value as set by set_flags(). This includes the trust + * level and some other settings. See the individual methods is_closed(), + * get_trust_level(), etc. to pull out the semantic meaning of these flags + * individually. + */ INLINE int ConfigVariableBase:: get_flags() const { nassertr(_core != (ConfigVariableCore *)NULL, 0); return _core->get_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::is_closed -// Access: Public -// Description: Returns true if the variable is not trusted by any -// prc file (and hence cannot be modified from its -// compiled-in default value), or false for the normal -// case, in which the variable can be modified by any -// prc file at or above its trust level (see -// get_trust_level()). -// -// This value only has effect in a release build -// (specifically, when PRC_RESPECT_TRUST_LEVEL is -// defined true in Config.pp). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable is not trusted by any prc file (and hence + * cannot be modified from its compiled-in default value), or false for the + * normal case, in which the variable can be modified by any prc file at or + * above its trust level (see get_trust_level()). + * + * This value only has effect in a release build (specifically, when + * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp). + */ INLINE bool ConfigVariableBase:: is_closed() const { nassertr(_core != (ConfigVariableCore *)NULL, false); return _core->is_closed(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::get_trust_level -// Access: Public -// Description: Returns the minimum trust_level a prc file must -// demonstrate in order to redefine the value for this -// variable. Arguably, this should be called the -// "mistrust level", since the larger the value, the -// more suspicious we are of prc files. This value is -// not used if is_closed() returns true, which indicates -// no file may be trusted. -// -// This value only has effect in a release build -// (specifically, when PRC_RESPECT_TRUST_LEVEL is -// defined true in Config.pp). -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum trust_level a prc file must demonstrate in order to + * redefine the value for this variable. Arguably, this should be called the + * "mistrust level", since the larger the value, the more suspicious we are of + * prc files. This value is not used if is_closed() returns true, which + * indicates no file may be trusted. + * + * This value only has effect in a release build (specifically, when + * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp). + */ INLINE int ConfigVariableBase:: get_trust_level() const { nassertr(_core != (ConfigVariableCore *)NULL, 0); return _core->get_trust_level(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::is_dynamic -// Access: Public -// Description: Returns true if the variable was indicated as -// "dynamic" by its constructor, indicating that its -// name was dynamically generated, possibly from a large -// pool, and it should not be listed along with the -// other variables. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable was indicated as "dynamic" by its constructor, + * indicating that its name was dynamically generated, possibly from a large + * pool, and it should not be listed along with the other variables. + */ INLINE bool ConfigVariableBase:: is_dynamic() const { nassertr(_core != (ConfigVariableCore *)NULL, false); return _core->is_dynamic(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::clear_local_value -// Access: Published -// Description: Removes the local value defined for this variable, -// and allows its value to be once again retrieved from -// the .prc files. -// -// Returns true if the value was successfully removed, -// false if it did not exist in the first place. -//////////////////////////////////////////////////////////////////// +/** + * Removes the local value defined for this variable, and allows its value to + * be once again retrieved from the .prc files. + * + * Returns true if the value was successfully removed, false if it did not + * exist in the first place. + */ INLINE bool ConfigVariableBase:: clear_local_value() { nassertr(_core != (ConfigVariableCore *)NULL, false); return _core->clear_local_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::has_local_value -// Access: Published -// Description: Returns true if this variable's value has been -// shadowed by a local assignment (as created via -// make_local_value()), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this variable's value has been shadowed by a local + * assignment (as created via make_local_value()), or false otherwise. + */ INLINE bool ConfigVariableBase:: has_local_value() const { nassertr(_core != (ConfigVariableCore *)NULL, false); return _core->has_local_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::has_value -// Access: Public -// Description: Returns true if this variable has an explicit value, -// either from a prc file or locally set, or false if -// variable has its default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this variable has an explicit value, either from a prc file + * or locally set, or false if variable has its default value. + */ INLINE bool ConfigVariableBase:: has_value() const { nassertr(_core != (ConfigVariableCore *)NULL, false); return _core->has_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConfigVariableBase:: output(ostream &out) const { nassertv(_core != (ConfigVariableCore *)NULL); _core->output(out); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConfigVariableBase:: write(ostream &out) const { nassertv(_core != (ConfigVariableCore *)NULL); diff --git a/dtool/src/prc/configVariableBase.cxx b/dtool/src/prc/configVariableBase.cxx index 7cdc6b6a98..52b113b79a 100644 --- a/dtool/src/prc/configVariableBase.cxx +++ b/dtool/src/prc/configVariableBase.cxx @@ -1,30 +1,27 @@ -// Filename: configVariableBase.cxx -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBase.cxx + * @author drose + * @date 2004-10-21 + */ #include "configVariableBase.h" #include "config_prc.h" ConfigVariableBase::Unconstructed *ConfigVariableBase::_unconstructed; -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::Constructor -// Access: Protected -// Description: This constructor is only intended to be called from a -// specialized ConfigVariableFoo derived class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended to be called from a specialized + * ConfigVariableFoo derived class. + */ ConfigVariableBase:: -ConfigVariableBase(const string &name, +ConfigVariableBase(const string &name, ConfigVariableBase::ValueType value_type, const string &description, int flags) : _core(ConfigVariableManager::get_global_ptr()->make_variable(name)) @@ -49,16 +46,12 @@ ConfigVariableBase(const string &name, } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::record_unconstructed -// Access: Protected -// Description: Records that this config variable was referenced -// before it was constructed (presumably a static-init -// ordering issue). This is used to print a useful -// error message later, when the constructor is actually -// called (and we then know what the name of the -// variable is). -//////////////////////////////////////////////////////////////////// +/** + * Records that this config variable was referenced before it was constructed + * (presumably a static-init ordering issue). This is used to print a useful + * error message later, when the constructor is actually called (and we then + * know what the name of the variable is). + */ void ConfigVariableBase:: record_unconstructed() const { #ifndef NDEBUG @@ -69,12 +62,10 @@ record_unconstructed() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBase::was_unconstructed -// Access: Protected -// Description: Returns true if record_unconstructed() was ever -// called on this pointer, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if record_unconstructed() was ever called on this pointer, + * false otherwise. + */ bool ConfigVariableBase:: was_unconstructed() const { #ifndef NDEBUG @@ -87,4 +78,3 @@ was_unconstructed() const { #endif return false; } - diff --git a/dtool/src/prc/configVariableBase.h b/dtool/src/prc/configVariableBase.h index 805398a2d7..cbb7aab183 100644 --- a/dtool/src/prc/configVariableBase.h +++ b/dtool/src/prc/configVariableBase.h @@ -1,16 +1,15 @@ -// Filename: configVariableBase.h -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBase.h + * @author drose + * @date 2004-10-21 + */ #ifndef CONFIGVARIABLEBASE_H #define CONFIGVARIABLEBASE_H @@ -23,28 +22,26 @@ #include "vector_string.h" #include "pset.h" -// Use this macro to wrap around a description passed to a -// ConfigVariable constructor. This allows the description to be -// completely compiled out, so that it won't even be a part of the -// string table, in the absence of PRC_SAVE_DESCRIPTIONS. +// Use this macro to wrap around a description passed to a ConfigVariable +// constructor. This allows the description to be completely compiled out, so +// that it won't even be a part of the string table, in the absence of +// PRC_SAVE_DESCRIPTIONS. #ifdef PRC_SAVE_DESCRIPTIONS #define PRC_DESC(description) description #else #define PRC_DESC(description) "" #endif -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableBase -// Description : This class is the base class for both -// ConfigVariableList and ConfigVariable (and hence for -// all of the ConfigVariableBool, ConfigVaribleString, -// etc. classes). It collects together the common -// interface for all generic ConfigVariables. -// -// Mostly, this class serves as a thin wrapper around -// ConfigVariableCore and/or ConfigDeclaration, more or -// less duplicating the interface presented there. -//////////////////////////////////////////////////////////////////// +/** + * This class is the base class for both ConfigVariableList and ConfigVariable + * (and hence for all of the ConfigVariableBool, ConfigVaribleString, etc. + * classes). It collects together the common interface for all generic + * ConfigVariables. + * + * Mostly, this class serves as a thin wrapper around ConfigVariableCore + * and/or ConfigDeclaration, more or less duplicating the interface presented + * there. + */ class EXPCL_DTOOLCONFIG ConfigVariableBase : public ConfigFlags { protected: INLINE ConfigVariableBase(const string &name, ValueType type); diff --git a/dtool/src/prc/configVariableBool.I b/dtool/src/prc/configVariableBool.I index 7336bb44ba..4e6b0ab35f 100644 --- a/dtool/src/prc/configVariableBool.I +++ b/dtool/src/prc/configVariableBool.I @@ -1,23 +1,19 @@ -// Filename: configVariableBool.I -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBool.I + * @author drose + * @date 2004-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableBool:: ConfigVariableBool(const string &name) : ConfigVariable(name, VT_bool), @@ -26,13 +22,11 @@ ConfigVariableBool(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableBool:: -ConfigVariableBool(const string &name, bool default_value, +ConfigVariableBool(const string &name, bool default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_bool, description, flags), @@ -45,13 +39,11 @@ ConfigVariableBool(const string &name, bool default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableBool:: -ConfigVariableBool(const string &name, const string &default_value, +ConfigVariableBool(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_bool, description, flags), @@ -64,62 +56,50 @@ ConfigVariableBool(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableBool:: operator = (bool value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableBool:: operator bool () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::size() -// Access: Published -// Description: Returns the number of unique words in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique words in the variable. + */ INLINE size_t ConfigVariableBool:: size() const { return get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::operator [] -// Access: Published -// Description: Returns the value of the variable's nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the variable's nth word. + */ INLINE bool ConfigVariableBool:: operator [] (size_t n) const { return get_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableBool:: set_value(bool value) { set_string_value(""); set_bool_word(0, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE bool ConfigVariableBool:: get_value() const { TAU_PROFILE("bool ConfigVariableBool::get_value() const", " ", TAU_USER); @@ -130,11 +110,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE bool ConfigVariableBool:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -144,22 +122,18 @@ get_default_value() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE bool ConfigVariableBool:: get_word(size_t n) const { return get_bool_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableBool::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableBool:: set_word(size_t n, bool value) { set_bool_word(n, value); diff --git a/dtool/src/prc/configVariableBool.cxx b/dtool/src/prc/configVariableBool.cxx index ac86c172ff..d063b06fd5 100644 --- a/dtool/src/prc/configVariableBool.cxx +++ b/dtool/src/prc/configVariableBool.cxx @@ -1,15 +1,14 @@ -// Filename: configVariableBool.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBool.cxx + * @author drose + * @date 2004-10-20 + */ #include "configVariableBool.h" diff --git a/dtool/src/prc/configVariableBool.h b/dtool/src/prc/configVariableBool.h index a43a867de6..a0d8b0b1dd 100644 --- a/dtool/src/prc/configVariableBool.h +++ b/dtool/src/prc/configVariableBool.h @@ -1,16 +1,15 @@ -// Filename: configVariableBool.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableBool.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIGVARIABLEBOOL_H #define CONFIGVARIABLEBOOL_H @@ -18,11 +17,9 @@ #include "dtoolbase.h" #include "configVariable.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableBool -// Description : This is a convenience class to specialize -// ConfigVariable as a boolean type. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a boolean type. + */ class EXPCL_DTOOLCONFIG ConfigVariableBool : public ConfigVariable { PUBLISHED: INLINE ConfigVariableBool(const string &name); diff --git a/dtool/src/prc/configVariableCore.I b/dtool/src/prc/configVariableCore.I index 2512a4e7bb..057beb0449 100644 --- a/dtool/src/prc/configVariableCore.I +++ b/dtool/src/prc/configVariableCore.I @@ -1,188 +1,143 @@ -// Filename: configVariableCore.I -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableCore.I + * @author drose + * @date 2004-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_name -// Access: Public -// Description: Returns the name of the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the variable. + */ INLINE const string &ConfigVariableCore:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::is_used -// Access: Public -// Description: Returns true if the variable has been referenced by a -// ConfigVariable somewhere in code, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable has been referenced by a ConfigVariable + * somewhere in code, false otherwise. + */ INLINE bool ConfigVariableCore:: is_used() const { return _is_used; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_value_type -// Access: Public -// Description: Returns the stated type of this variable. If the -// variable has not yet been defined, this will be -// VT_undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated type of this variable. If the variable has not yet been + * defined, this will be VT_undefined. + */ INLINE ConfigVariableCore::ValueType ConfigVariableCore:: get_value_type() const { return _value_type; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_description -// Access: Public -// Description: Returns the brief description of this variable, if -// it has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the brief description of this variable, if it has been defined. + */ INLINE const string &ConfigVariableCore:: get_description() const { return _description; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_flags -// Access: Public -// Description: Returns the flags value as set by set_flags(). This -// includes the trust level and some other settings. -// See the individual methods is_closed(), -// get_trust_level(), etc. to pull out the semantic -// meaning of these flags individually. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flags value as set by set_flags(). This includes the trust + * level and some other settings. See the individual methods is_closed(), + * get_trust_level(), etc. to pull out the semantic meaning of these flags + * individually. + */ INLINE int ConfigVariableCore:: get_flags() const { return _flags; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::is_closed -// Access: Public -// Description: Returns true if the variable is not trusted by any -// prc file (and hence cannot be modified from its -// compiled-in default value), or false for the normal -// case, in which the variable can be modified by any -// prc file at or above its trust level (see -// get_trust_level()). -// -// This value only has effect in a release build -// (specifically, when PRC_RESPECT_TRUST_LEVEL is -// defined true in Config.pp). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable is not trusted by any prc file (and hence + * cannot be modified from its compiled-in default value), or false for the + * normal case, in which the variable can be modified by any prc file at or + * above its trust level (see get_trust_level()). + * + * This value only has effect in a release build (specifically, when + * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp). + */ INLINE bool ConfigVariableCore:: is_closed() const { return (_flags & F_closed) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_trust_level -// Access: Public -// Description: Returns the minimum trust_level a prc file must -// demonstrate in order to redefine the value for this -// variable. Arguably, this should be called the -// "mistrust level", since the larger the value, the -// more suspicious we are of prc files. This value is -// not used if is_closed() returns true, which indicates -// no file may be trusted. -// -// This value only has effect in a release build -// (specifically, when PRC_RESPECT_TRUST_LEVEL is -// defined true in Config.pp). -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum trust_level a prc file must demonstrate in order to + * redefine the value for this variable. Arguably, this should be called the + * "mistrust level", since the larger the value, the more suspicious we are of + * prc files. This value is not used if is_closed() returns true, which + * indicates no file may be trusted. + * + * This value only has effect in a release build (specifically, when + * PRC_RESPECT_TRUST_LEVEL is defined true in Config.pp). + */ INLINE int ConfigVariableCore:: get_trust_level() const { return (_flags & F_trust_level_mask); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::is_dynamic -// Access: Public -// Description: Returns true if the variable was indicated as -// "dynamic" by its constructor, indicating that its -// name was dynamically generated, possibly from a large -// pool, and it should not be listed along with the -// other variables. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the variable was indicated as "dynamic" by its constructor, + * indicating that its name was dynamically generated, possibly from a large + * pool, and it should not be listed along with the other variables. + */ INLINE bool ConfigVariableCore:: is_dynamic() const { return (_flags & F_dynamic) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_default_value -// Access: Public -// Description: Returns the default variable specified for this -// variable. If the variable has not yet been defined, -// this will return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default variable specified for this variable. If the variable + * has not yet been defined, this will return NULL. + */ INLINE const ConfigDeclaration *ConfigVariableCore:: get_default_value() const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::set_used -// Access: Public -// Description: Marks that the variable has been "declared" by a -// ConfigVariable. -//////////////////////////////////////////////////////////////////// +/** + * Marks that the variable has been "declared" by a ConfigVariable. + */ INLINE void ConfigVariableCore:: set_used() { _is_used = true; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::has_local_value -// Access: Public -// Description: Returns true if this variable's value has been -// shadowed by a local assignment (as created via -// make_local_value()), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this variable's value has been shadowed by a local + * assignment (as created via make_local_value()), or false otherwise. + */ INLINE bool ConfigVariableCore:: has_local_value() const { return _local_value != (ConfigDeclaration *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_num_references -// Access: Public -// Description: Returns the number of prc files that reference this -// variable. This is not exactly the same as the number -// of declarations; see get_reference(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of prc files that reference this variable. This is not + * exactly the same as the number of declarations; see get_reference(). + */ INLINE size_t ConfigVariableCore:: get_num_references() const { check_sort_declarations(); return _declarations.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_reference -// Access: Public -// Description: Returns the nth declaration in a prc file that -// references this variable. This is similar, but not -// identical to, get_declaration(). The difference is -// that this will list *only* true references in a prc -// file, and will not list default values or -// locally-assigned values; it also will list even the -// untrusted files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth declaration in a prc file that references this variable. + * This is similar, but not identical to, get_declaration(). The difference + * is that this will list *only* true references in a prc file, and will not + * list default values or locally-assigned values; it also will list even the + * untrusted files. + */ INLINE const ConfigDeclaration *ConfigVariableCore:: get_reference(size_t n) const { check_sort_declarations(); @@ -190,33 +145,25 @@ get_reference(size_t n) const { return _declarations[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_num_trusted_references -// Access: Public -// Description: Returns the number of trusted prc files that -// reference this variable. See also -// get_num_references(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of trusted prc files that reference this variable. See + * also get_num_references(). + */ INLINE size_t ConfigVariableCore:: get_num_trusted_references() const { check_sort_declarations(); return _trusted_declarations.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_trusted_reference -// Access: Public -// Description: Returns the nth declaration in a trusted prc file -// that references this variable. This is similar, but -// not identical to, get_declaration(). The difference -// is that this will list *only* true references in a -// prc file, and will not list default values or -// locally-assigned values. -// -// This is also similar to get_reference(), except that -// it only lists the trusted declarations, omitting the -// untrusted ones. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth declaration in a trusted prc file that references this + * variable. This is similar, but not identical to, get_declaration(). The + * difference is that this will list *only* true references in a prc file, and + * will not list default values or locally-assigned values. + * + * This is also similar to get_reference(), except that it only lists the + * trusted declarations, omitting the untrusted ones. + */ INLINE const ConfigDeclaration *ConfigVariableCore:: get_trusted_reference(size_t n) const { check_sort_declarations(); @@ -224,26 +171,20 @@ get_trusted_reference(size_t n) const { return _trusted_declarations[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_num_unique_references -// Access: Public -// Description: Returns the number of trusted, unique (by string -// value) values there exist for this variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of trusted, unique (by string value) values there exist + * for this variable. + */ INLINE size_t ConfigVariableCore:: get_num_unique_references() const { check_sort_declarations(); return _unique_declarations.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_unique_reference -// Access: Public -// Description: Returns the nth trusted, unique value for this -// variable. This is similar to -// get_trusted_reference(), except that duplicate values -// are removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth trusted, unique value for this variable. This is similar + * to get_trusted_reference(), except that duplicate values are removed. + */ INLINE const ConfigDeclaration *ConfigVariableCore:: get_unique_reference(size_t n) const { check_sort_declarations(); @@ -251,17 +192,14 @@ get_unique_reference(size_t n) const { return _unique_declarations[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::check_sort_declarations() -// Access: Private -// Description: Called internally to ensure that the list of -// declarations is properly sorted. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to ensure that the list of declarations is properly + * sorted. + */ INLINE void ConfigVariableCore:: check_sort_declarations() const { - // First, make sure that all of the implicit .prc files have been - // loaded. This may unsort the list by adding a bunch more - // declarations. + // First, make sure that all of the implicit .prc files have been loaded. + // This may unsort the list by adding a bunch more declarations. ConfigPageManager::get_global_ptr()->load_implicit_pages(); // Then sort the list if it needs it. diff --git a/dtool/src/prc/configVariableCore.cxx b/dtool/src/prc/configVariableCore.cxx index ce8c32a669..7bf355ba3c 100644 --- a/dtool/src/prc/configVariableCore.cxx +++ b/dtool/src/prc/configVariableCore.cxx @@ -1,16 +1,15 @@ -// Filename: configVariableCore.cxx -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableCore.cxx + * @author drose + * @date 2004-10-15 + */ #include "configVariableCore.h" #include "configDeclaration.h" @@ -25,12 +24,10 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::Constructor -// Access: Private -// Description: Use the ConfigVariableManager::make_variable() -// interface to create a new ConfigVariableCore. -//////////////////////////////////////////////////////////////////// +/** + * Use the ConfigVariableManager::make_variable() interface to create a new + * ConfigVariableCore. + */ ConfigVariableCore:: ConfigVariableCore(const string &name) : _name(name), @@ -47,13 +44,11 @@ ConfigVariableCore(const string &name) : #endif // PRC_INC_TRUST_LEVEL } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::Copy Constructor -// Access: Private -// Description: This is used by ConfigVariableManager to create the -// variable from a template--basically, another variable -// with all of the initial properties pre-defined. -//////////////////////////////////////////////////////////////////// +/** + * This is used by ConfigVariableManager to create the variable from a + * template--basically, another variable with all of the initial properties + * pre-defined. + */ ConfigVariableCore:: ConfigVariableCore(const ConfigVariableCore &templ, const string &name) : _name(name), @@ -71,40 +66,33 @@ ConfigVariableCore(const ConfigVariableCore &templ, const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::Destructor -// Access: Private -// Description: The destructor should never be called; -// ConfigVariableCore objects live forever and never get -// destructed. -//////////////////////////////////////////////////////////////////// +/** + * The destructor should never be called; ConfigVariableCore objects live + * forever and never get destructed. + */ ConfigVariableCore:: ~ConfigVariableCore() { prc_cat->error() << "Internal error--ConfigVariableCore destructor called!\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::set_value_type -// Access: Public -// Description: Specifies the type of this variable. See -// get_value_type(). It is not an error to call this -// multiple times, but if the value changes once -// get_declaration() has been called, a warning is printed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the type of this variable. See get_value_type(). It is not an + * error to call this multiple times, but if the value changes once + * get_declaration() has been called, a warning is printed. + */ void ConfigVariableCore:: set_value_type(ConfigVariableCore::ValueType value_type) { if (_value_queried && _value_type != value_type) { if ((_flags & F_dconfig) != 0) { - // As a special exception, if the flags include F_dconfig, we - // don't report a warning for changing the type, assuming the - // variable is being defined through the older DConfig - // interface. - + // As a special exception, if the flags include F_dconfig, we don't + // report a warning for changing the type, assuming the variable is + // being defined through the older DConfig interface. + } else { prc_cat->warning() - << "changing type for ConfigVariable " - << get_name() << " from " << _value_type << " to " + << "changing type for ConfigVariable " + << get_name() << " from " << _value_type << " to " << value_type << ".\n"; } } @@ -112,15 +100,11 @@ set_value_type(ConfigVariableCore::ValueType value_type) { _value_type = value_type; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::set_flags -// Access: Public -// Description: Specifies the trust level of this variable. See -// get_flags(). It is not an error to call this -// multiple times, but if the value changes once -// get_declaration() has been called, a warning is -// printed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the trust level of this variable. See get_flags(). It is not an + * error to call this multiple times, but if the value changes once + * get_declaration() has been called, a warning is printed. + */ void ConfigVariableCore:: set_flags(int flags) { if ((flags & F_dconfig) != 0) { @@ -135,14 +119,14 @@ set_flags(int flags) { int bits_changed = (_flags ^ flags); if ((bits_changed & F_trust_level_mask) != 0) { prc_cat->warning() - << "changing trust level for ConfigVariable " - << get_name() << " from " << (_flags & F_trust_level_mask) << " to " + << "changing trust level for ConfigVariable " + << get_name() << " from " << (_flags & F_trust_level_mask) << " to " << (flags & F_trust_level_mask) << ".\n"; } if ((bits_changed & ~(F_trust_level_mask | F_dconfig)) != 0) { prc_cat->warning() - << "changing flags for ConfigVariable " - << get_name() << " from " << hex + << "changing flags for ConfigVariable " + << get_name() << " from " << hex << (_flags & ~F_trust_level_mask) << " to " << (flags & ~F_trust_level_mask) << dec << ".\n"; } @@ -150,32 +134,28 @@ set_flags(int flags) { _flags = flags; - // Changing the trust level will require re-sorting the - // declarations. + // Changing the trust level will require re-sorting the declarations. _declarations_sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::set_description -// Access: Public -// Description: Specifies the one-line description of this variable. -// See get_description(). It is not an error to call -// this multiple times, but if the value changes once -// get_declaration() has been called, a warning is printed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the one-line description of this variable. See + * get_description(). It is not an error to call this multiple times, but if + * the value changes once get_declaration() has been called, a warning is + * printed. + */ void ConfigVariableCore:: set_description(const string &description) { if (_value_queried && _description != description) { if ((_flags & F_dconfig) != 0) { - // As a special exception, if the flags include F_dconfig, we - // don't change it, since this is presumably coming from the - // older DConfig interface. + // As a special exception, if the flags include F_dconfig, we don't + // change it, since this is presumably coming from the older DConfig + // interface. return; } if (description == "DConfig") { - // As a similar exception, we don't replace an existing - // description with one that reads simply "DConfig", unless it - // was empty previously. + // As a similar exception, we don't replace an existing description with + // one that reads simply "DConfig", unless it was empty previously. if (_description.empty()) { _description = description; } @@ -194,19 +174,17 @@ set_description(const string &description) { } prc_cat->warning() - << "changing description for ConfigVariable " + << "changing description for ConfigVariable " << get_name() << ".\n"; } _description = description; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::set_default_value -// Access: Public -// Description: Specifies the default value for this variable if it -// is not defined in any prc file. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default value for this variable if it is not defined in any + * prc file. + */ void ConfigVariableCore:: set_default_value(const string &default_value) { if (_default_value == (ConfigDeclaration *)NULL) { @@ -217,23 +195,21 @@ set_default_value(const string &default_value) { } else { // Modifying an existing default value. - // We set the original default value first, to avoid infinite - // recursion when the config variable in question happens to be - // consulted in NotifyCategory::out() (for instance, - // notify-timestamp). + // We set the original default value first, to avoid infinite recursion + // when the config variable in question happens to be consulted in + // NotifyCategory::out() (for instance, notify-timestamp). string orig_default_value = _default_value->get_string_value(); _default_value->set_string_value(default_value); if (orig_default_value != default_value) { if ((_flags & F_dconfig) != 0) { - // As a special exception, if the flags include F_dconfig, we - // don't report a warning for changing the default value, - // assuming the variable is being defined through the older - // DConfig interface. + // As a special exception, if the flags include F_dconfig, we don't + // report a warning for changing the default value, assuming the + // variable is being defined through the older DConfig interface. } else { prc_cat->warning() - << "changing default value for ConfigVariable " + << "changing default value for ConfigVariable " << get_name() << " from '" << orig_default_value << "' to '" << default_value << "'.\n"; } @@ -241,19 +217,15 @@ set_default_value(const string &default_value) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::make_local_value -// Access: Public -// Description: Creates a new local value for this variable, if there -// is not already one specified. This will shadow any -// values defined in the various .prc files. -// -// If there is already a local value defined for this -// variable, simply returns that one. -// -// Use clear_local_value() to remove the local value -// definition. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new local value for this variable, if there is not already one + * specified. This will shadow any values defined in the various .prc files. + * + * If there is already a local value defined for this variable, simply returns + * that one. + * + * Use clear_local_value() to remove the local value definition. + */ ConfigDeclaration *ConfigVariableCore:: make_local_value() { if (_local_value == (ConfigDeclaration *)NULL) { @@ -272,16 +244,13 @@ make_local_value() { return _local_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::clear_local_value -// Access: Public -// Description: Removes the local value defined for this variable, -// and allows its value to be once again retrieved from -// the .prc files. -// -// Returns true if the value was successfully removed, -// false if it did not exist in the first place. -//////////////////////////////////////////////////////////////////// +/** + * Removes the local value defined for this variable, and allows its value to + * be once again retrieved from the .prc files. + * + * Returns true if the value was successfully removed, false if it did not + * exist in the first place. + */ bool ConfigVariableCore:: clear_local_value() { if (_local_value != (ConfigDeclaration *)NULL) { @@ -294,13 +263,10 @@ clear_local_value() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::has_value -// Access: Public -// Description: Returns true if this variable has an explicit value, -// either from a prc file or locally set, or false if -// variable has its default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this variable has an explicit value, either from a prc file + * or locally set, or false if variable has its default value. + */ bool ConfigVariableCore:: has_value() const { if (has_local_value()) { @@ -310,14 +276,11 @@ has_value() const { return (!_trusted_declarations.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_num_declarations -// Access: Public -// Description: Returns the number of declarations that contribute to -// this variable's value. If the variable has been -// defined, this will always be at least 1 (for the -// default value, at least). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of declarations that contribute to this variable's + * value. If the variable has been defined, this will always be at least 1 + * (for the default value, at least). + */ size_t ConfigVariableCore:: get_num_declarations() const { if (has_local_value()) { @@ -332,16 +295,12 @@ get_num_declarations() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::get_declaration -// Access: Public -// Description: Returns the nth declarations that contributes to -// this variable's value. The declarations are arranged -// in order such that earlier declarations shadow later -// declarations; thus, get_declaration(0) is always -// defined and always returns the current value of the -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth declarations that contributes to this variable's value. + * The declarations are arranged in order such that earlier declarations + * shadow later declarations; thus, get_declaration(0) is always defined and + * always returns the current value of the variable. + */ const ConfigDeclaration *ConfigVariableCore:: get_declaration(size_t n) const { ((ConfigVariableCore *)this)->_value_queried = true; @@ -362,21 +321,17 @@ get_declaration(size_t n) const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableCore:: output(ostream &out) const { out << get_declaration(0)->get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableCore:: write(ostream &out) const { out << "ConfigVariable " << get_name() << ":\n"; @@ -388,10 +343,10 @@ write(ostream &out) const { } Declarations::const_iterator di; - for (di = _trusted_declarations.begin(); - di != _trusted_declarations.end(); + for (di = _trusted_declarations.begin(); + di != _trusted_declarations.end(); ++di) { - out << " " << *(*di) + out << " " << *(*di) << " (from " << (*di)->get_page()->get_name() << ")\n"; } @@ -399,10 +354,10 @@ write(ostream &out) const { out << " " << *_default_value << " (default value)\n"; } - for (di = _untrusted_declarations.begin(); - di != _untrusted_declarations.end(); + for (di = _untrusted_declarations.begin(); + di != _untrusted_declarations.end(); ++di) { - out << " " << *(*di) + out << " " << *(*di) << " (from " << (*di)->get_page()->get_name() << ", untrusted)\n"; } @@ -411,13 +366,10 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::add_declaration -// Access: Private -// Description: Called only by the ConfigDeclaration constructor, -// this adds the indicated declaration to the list of -// declarations that reference this variable. -//////////////////////////////////////////////////////////////////// +/** + * Called only by the ConfigDeclaration constructor, this adds the indicated + * declaration to the list of declarations that reference this variable. + */ void ConfigVariableCore:: add_declaration(ConfigDeclaration *decl) { _declarations.push_back(decl); @@ -425,21 +377,18 @@ add_declaration(ConfigDeclaration *decl) { _declarations_sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::remove_declaration -// Access: Private -// Description: Called only by the ConfigDeclaration destructor, -// this removes the indicated declaration from the list -// of declarations that reference this variable. -//////////////////////////////////////////////////////////////////// +/** + * Called only by the ConfigDeclaration destructor, this removes the indicated + * declaration from the list of declarations that reference this variable. + */ void ConfigVariableCore:: remove_declaration(ConfigDeclaration *decl) { Declarations::iterator di; for (di = _declarations.begin(); di != _declarations.end(); ++di) { if ((*di) == decl) { - // Rather than deleting the declaration from the middle of the - // list, we maybe save a bit of time by swapping in the one at - // the end of the list (although this will unsort the list). + // Rather than deleting the declaration from the middle of the list, we + // maybe save a bit of time by swapping in the one at the end of the + // list (although this will unsort the list). Declarations::iterator di2 = _declarations.end(); di2--; (*di) = (*di2); @@ -460,24 +409,22 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableCore::sort_declarations -// Access: Private -// Description: Sorts the list of declarations into priority order, -// so that the declaration at the front of the list is -// the one that shadows all following declarations. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the list of declarations into priority order, so that the declaration + * at the front of the list is the one that shadows all following + * declarations. + */ void ConfigVariableCore:: sort_declarations() { sort(_declarations.begin(), _declarations.end(), CompareConfigDeclarations()); Declarations::iterator di; - // Now that they're sorted, divide them into either trusted or - // untrusted declarations. + // Now that they're sorted, divide them into either trusted or untrusted + // declarations. #ifdef PRC_RESPECT_TRUST_LEVEL - // In this mode, normally for a release build, we sort the - // declarations honestly according to whether the prc file that - // defines them meets the required trust level. + // In this mode, normally for a release build, we sort the declarations + // honestly according to whether the prc file that defines them meets the + // required trust level. _trusted_declarations.clear(); _untrusted_declarations.clear(); for (di = _declarations.begin(); di != _declarations.end(); ++di) { @@ -491,23 +438,22 @@ sort_declarations() { } #else // PRC_RESPECT_TRUST_LEVEL - // In this mode, normally for the development environment, all - // declarations are trusted, regardless of the trust level. + // In this mode, normally for the development environment, all declarations + // are trusted, regardless of the trust level. _trusted_declarations = _declarations; _untrusted_declarations.clear(); #endif // PRC_RESPECT_TRUST_LEVEL - // Finally, determine the set of unique, trusted - // declarations--trusted declarations that have a unique string - // value. This is usually unneeded, but what the heck, it doesn't - // need to be recomputed all that often. + // Finally, determine the set of unique, trusted declarations--trusted + // declarations that have a unique string value. This is usually unneeded, + // but what the heck, it doesn't need to be recomputed all that often. _unique_declarations.clear(); init_system_type_handles(); // Make sure pset_type_handle is initted. pset already_added; - for (di = _trusted_declarations.begin(); - di != _trusted_declarations.end(); + for (di = _trusted_declarations.begin(); + di != _trusted_declarations.end(); ++di) { const ConfigDeclaration *decl = (*di); if (already_added.insert(decl->get_string_value()).second) { diff --git a/dtool/src/prc/configVariableCore.h b/dtool/src/prc/configVariableCore.h index e8b74bc59a..11af6061ce 100644 --- a/dtool/src/prc/configVariableCore.h +++ b/dtool/src/prc/configVariableCore.h @@ -1,16 +1,15 @@ -// Filename: configVariableCore.h -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableCore.h + * @author drose + * @date 2004-10-15 + */ #ifndef CONFIGVARIABLECORE_H #define CONFIGVARIABLECORE_H @@ -24,17 +23,14 @@ class ConfigDeclaration; -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableCore -// Description : The internal definition of a ConfigVariable. This -// object is shared between all instances of a -// ConfigVariable that use the same variable name. -// -// You cannot create a ConfigVariableCore instance -// directly; instead, use the make() method, which may -// return a shared instance. Once created, these -// objects are never destructed. -//////////////////////////////////////////////////////////////////// +/** + * The internal definition of a ConfigVariable. This object is shared between + * all instances of a ConfigVariable that use the same variable name. + * + * You cannot create a ConfigVariableCore instance directly; instead, use the + * make() method, which may return a shared instance. Once created, these + * objects are never destructed. + */ class EXPCL_DTOOLCONFIG ConfigVariableCore : public ConfigFlags { private: ConfigVariableCore(const string &name); diff --git a/dtool/src/prc/configVariableDouble.I b/dtool/src/prc/configVariableDouble.I index 2daafb82a3..8cd2cd1e91 100644 --- a/dtool/src/prc/configVariableDouble.I +++ b/dtool/src/prc/configVariableDouble.I @@ -1,23 +1,19 @@ -// Filename: configVariableDouble.I -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableDouble.I + * @author drose + * @date 2004-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableDouble:: ConfigVariableDouble(const string &name) : ConfigVariable(name, VT_double), @@ -26,13 +22,11 @@ ConfigVariableDouble(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableDouble:: -ConfigVariableDouble(const string &name, double default_value, +ConfigVariableDouble(const string &name, double default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), @@ -45,13 +39,11 @@ ConfigVariableDouble(const string &name, double default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableDouble:: -ConfigVariableDouble(const string &name, const string &default_value, +ConfigVariableDouble(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_double, description, flags), @@ -64,62 +56,50 @@ ConfigVariableDouble(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableDouble:: operator = (double value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableDouble:: operator double () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::size() -// Access: Published -// Description: Returns the number of unique words in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique words in the variable. + */ INLINE size_t ConfigVariableDouble:: size() const { return get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::operator [] -// Access: Published -// Description: Returns the value of the variable's nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the variable's nth word. + */ INLINE double ConfigVariableDouble:: operator [] (size_t n) const { return get_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableDouble:: set_value(double value) { set_string_value(""); set_double_word(0, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE double ConfigVariableDouble:: get_value() const { TAU_PROFILE("double ConfigVariableDouble::get_value() const", " ", TAU_USER); @@ -130,11 +110,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE double ConfigVariableDouble:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -144,22 +122,18 @@ get_default_value() const { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE double ConfigVariableDouble:: get_word(size_t n) const { return get_double_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableDouble:: set_word(size_t n, double value) { set_double_word(n, value); diff --git a/dtool/src/prc/configVariableDouble.cxx b/dtool/src/prc/configVariableDouble.cxx index 74722b6444..a077778882 100644 --- a/dtool/src/prc/configVariableDouble.cxx +++ b/dtool/src/prc/configVariableDouble.cxx @@ -1,25 +1,22 @@ -// Filename: configVariableDouble.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableDouble.cxx + * @author drose + * @date 2004-10-20 + */ #include "configVariableDouble.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableDouble::set_default_value -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableDouble:: set_default_value(double default_value) { _core->set_default_value(format_string(default_value)); diff --git a/dtool/src/prc/configVariableDouble.h b/dtool/src/prc/configVariableDouble.h index 6180a5056c..817449ae2f 100644 --- a/dtool/src/prc/configVariableDouble.h +++ b/dtool/src/prc/configVariableDouble.h @@ -1,16 +1,15 @@ -// Filename: configVariableDouble.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableDouble.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIGVARIABLEDOUBLE_H #define CONFIGVARIABLEDOUBLE_H @@ -18,19 +17,18 @@ #include "dtoolbase.h" #include "configVariable.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableDouble -// Description : This is a convenience class to specialize -// ConfigVariable as a floating-point type. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a floating- + * point type. + */ class EXPCL_DTOOLCONFIG ConfigVariableDouble : public ConfigVariable { PUBLISHED: INLINE ConfigVariableDouble(const string &name); INLINE ConfigVariableDouble(const string &name, double default_value, - const string &description = string(), + const string &description = string(), int flags = 0); INLINE ConfigVariableDouble(const string &name, const string &default_value, - const string &description = string(), + const string &description = string(), int flags = 0); INLINE void operator = (double value); diff --git a/dtool/src/prc/configVariableEnum.I b/dtool/src/prc/configVariableEnum.I index a65d6e18d6..04464fcc41 100644 --- a/dtool/src/prc/configVariableEnum.I +++ b/dtool/src/prc/configVariableEnum.I @@ -1,26 +1,22 @@ -// Filename: configVariableEnum.I -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableEnum.I + * @author drose + * @date 2004-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConfigVariableEnum:: -ConfigVariableEnum(const string &name, EnumType default_value, +ConfigVariableEnum(const string &name, EnumType default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags), @@ -35,14 +31,12 @@ ConfigVariableEnum(const string &name, EnumType default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConfigVariableEnum:: -ConfigVariableEnum(const string &name, const string &default_value, +ConfigVariableEnum(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_enum, description, flags), @@ -57,76 +51,62 @@ ConfigVariableEnum(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConfigVariableEnum:: ~ConfigVariableEnum() { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::operator = -// Access: Public -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ template INLINE void ConfigVariableEnum:: operator = (EnumType value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::typecast operator -// Access: Public -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ template INLINE ConfigVariableEnum:: operator EnumType () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::size() -// Access: Public -// Description: Returns the number of unique words in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique words in the variable. + */ template INLINE size_t ConfigVariableEnum:: size() const { return get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::operator [] -// Access: Public -// Description: Returns the value of the variable's nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the variable's nth word. + */ template INLINE EnumType ConfigVariableEnum:: operator [] (size_t n) const { return get_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::set_value -// Access: Public -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ template INLINE void ConfigVariableEnum:: set_value(EnumType value) { set_string_value(format_enum(value)); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::get_value -// Access: Public -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ template INLINE EnumType ConfigVariableEnum:: get_value() const { @@ -138,11 +118,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::get_default_value -// Access: Public -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ template INLINE EnumType ConfigVariableEnum:: get_default_value() const { @@ -156,36 +134,29 @@ get_default_value() const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::get_word -// Access: Public -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ template INLINE EnumType ConfigVariableEnum:: get_word(size_t n) const { return (EnumType)parse_string(get_string_word(n)); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::set_word -// Access: Public -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ template INLINE void ConfigVariableEnum:: set_word(size_t n, EnumType value) { set_string_word(n, format_enum(value)); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::parse_string -// Access: Public, Virtual -// Description: Turns the string value into a value of the enumerated -// type by invoking its predefined operator >> (istream) -// operator. -//////////////////////////////////////////////////////////////////// +/** + * Turns the string value into a value of the enumerated type by invoking its + * predefined operator >> (istream) operator. + */ template INLINE EnumType ConfigVariableEnum:: parse_string(const string &value) const { @@ -195,13 +166,11 @@ parse_string(const string &value) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableEnum::format_enum -// Access: Public, Virtual -// Description: The format_enum() method assumes the enumerated type -// has a valid operator << (ostream) defined, which -// balances against the operator >> (istream) operator. -//////////////////////////////////////////////////////////////////// +/** + * The format_enum() method assumes the enumerated type has a valid operator + * << (ostream) defined, which balances against the operator >> (istream) + * operator. + */ template INLINE string ConfigVariableEnum:: format_enum(EnumType value) const { diff --git a/dtool/src/prc/configVariableEnum.cxx b/dtool/src/prc/configVariableEnum.cxx index 336a9aa1f8..0a3a3f8df3 100644 --- a/dtool/src/prc/configVariableEnum.cxx +++ b/dtool/src/prc/configVariableEnum.cxx @@ -1,15 +1,14 @@ -// Filename: configVariableEnum.cxx -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableEnum.cxx + * @author drose + * @date 2004-10-21 + */ #include "configVariableEnum.h" diff --git a/dtool/src/prc/configVariableEnum.h b/dtool/src/prc/configVariableEnum.h index c49fe960b9..81f5c91a09 100644 --- a/dtool/src/prc/configVariableEnum.h +++ b/dtool/src/prc/configVariableEnum.h @@ -1,16 +1,15 @@ -// Filename: configVariableEnum.h -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableEnum.h + * @author drose + * @date 2004-10-21 + */ #ifndef CONFIGVARIABLEENUM_H #define CONFIGVARIABLEENUM_H @@ -18,27 +17,24 @@ #include "dtoolbase.h" #include "configVariable.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableEnum -// Description : This class specializes ConfigVariable as an -// enumerated type. It is a template class, so it -// cannot be easily published; it's not really necessary -// outside of C++ anyway. -// -// This variable assumes that the enumerated type in -// question has input and output stream operators -// defined that do the right thing (outputting a -// sensible string for the type, and converting a string -// to the correct value). -//////////////////////////////////////////////////////////////////// +/** + * This class specializes ConfigVariable as an enumerated type. It is a + * template class, so it cannot be easily published; it's not really necessary + * outside of C++ anyway. + * + * This variable assumes that the enumerated type in question has input and + * output stream operators defined that do the right thing (outputting a + * sensible string for the type, and converting a string to the correct + * value). + */ template class ConfigVariableEnum : public ConfigVariable { public: - INLINE ConfigVariableEnum(const string &name, EnumType default_value, - const string &description = string(), + INLINE ConfigVariableEnum(const string &name, EnumType default_value, + const string &description = string(), int flags = 0); - INLINE ConfigVariableEnum(const string &name, const string &default_value, - const string &description = string(), + INLINE ConfigVariableEnum(const string &name, const string &default_value, + const string &description = string(), int flags = 0); INLINE ~ConfigVariableEnum(); @@ -72,4 +68,3 @@ private: #include "configVariableEnum.I" #endif - diff --git a/dtool/src/prc/configVariableFilename.I b/dtool/src/prc/configVariableFilename.I index e1cec7974c..d84d92dcb0 100644 --- a/dtool/src/prc/configVariableFilename.I +++ b/dtool/src/prc/configVariableFilename.I @@ -1,23 +1,19 @@ -// Filename: configVariableFilename.I -// Created by: drose (22Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableFilename.I + * @author drose + * @date 2004-11-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableFilename:: ConfigVariableFilename(const string &name) : ConfigVariable(name, VT_filename), @@ -26,13 +22,11 @@ ConfigVariableFilename(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableFilename:: -ConfigVariableFilename(const string &name, const Filename &default_value, +ConfigVariableFilename(const string &name, const Filename &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_filename, description, flags), @@ -45,200 +39,159 @@ ConfigVariableFilename(const string &name, const Filename &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableFilename:: operator = (const Filename &value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Filename typecast operator -// Access: Published -// Description: Returns the variable's value as a Filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value as a Filename. + */ INLINE ConfigVariableFilename:: operator const Filename &() const { return get_ref_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::c_str -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const char *ConfigVariableFilename:: c_str() const { return get_ref_value().c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableFilename:: empty() const { return get_ref_value().empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t ConfigVariableFilename:: length() const { return get_ref_value().length(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE char ConfigVariableFilename:: operator [] (size_t n) const { return get_ref_value()[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_fullpath -// Access: Public -// Description: Returns the entire filename: directory, basename, -// extension. This is the same thing returned by the -// string typecast operator, so this function is a -// little redundant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire filename: directory, basename, extension. This is the + * same thing returned by the string typecast operator, so this function is a + * little redundant. + */ INLINE string ConfigVariableFilename:: get_fullpath() const { return get_ref_value().get_fullpath(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_dirname -// Access: Public -// Description: Returns the directory part of the filename. This is -// everything in the filename up to, but not including -// the rightmost slash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory part of the filename. This is everything in the + * filename up to, but not including the rightmost slash. + */ INLINE string ConfigVariableFilename:: get_dirname() const { return get_ref_value().get_dirname(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_basename -// Access: Public -// Description: Returns the basename part of the filename. This is -// everything in the filename after the rightmost slash, -// including any extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename part of the filename. This is everything in the + * filename after the rightmost slash, including any extensions. + */ INLINE string ConfigVariableFilename:: get_basename() const { return get_ref_value().get_basename(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_fullpath_wo_extension -// Access: Public -// Description: Returns the full filename--directory and basename -// parts--except for the extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full filename--directory and basename parts--except for the + * extension. + */ INLINE string ConfigVariableFilename:: get_fullpath_wo_extension() const { return get_ref_value().get_fullpath_wo_extension(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_basename_wo_extension -// Access: Public -// Description: Returns the basename part of the filename, without -// the file extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename part of the filename, without the file extension. + */ INLINE string ConfigVariableFilename:: get_basename_wo_extension() const { return get_ref_value().get_basename_wo_extension(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_extension -// Access: Public -// Description: Returns the file extension. This is everything after -// the rightmost dot, if there is one, or the empty -// string if there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the file extension. This is everything after the rightmost dot, if + * there is one, or the empty string if there is not. + */ INLINE string ConfigVariableFilename:: get_extension() const { return get_ref_value().get_extension(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Equality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableFilename:: operator == (const Filename &other) const { return get_ref_value() == other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Inequality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableFilename:: operator != (const Filename &other) const { return get_ref_value() != other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::Ordering operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableFilename:: operator < (const Filename &other) const { return get_ref_value() < other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableFilename:: set_value(const Filename &value) { set_string_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE Filename ConfigVariableFilename:: get_value() const { - // This returns a concrete rather than a reference by design, to - // avoid problems with scope. When we call this method from Python, - // we'd like to be able to keep the Filename value around longer - // than the lifetime of the config variable itself. + // This returns a concrete rather than a reference by design, to avoid + // problems with scope. When we call this method from Python, we'd like to + // be able to keep the Filename value around longer than the lifetime of the + // config variable itself. return get_ref_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE Filename ConfigVariableFilename:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -248,35 +201,28 @@ get_default_value() const { return Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE Filename ConfigVariableFilename:: get_word(size_t n) const { return Filename::expand_from(get_string_word(n)); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableFilename:: set_word(size_t n, const Filename &value) { set_string_word(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::get_ref_value -// Access: Private -// Description: Returns the variable's value, as a reference into the -// config variable itself. This is the internal method -// that implements get_value(), which returns a -// concrete. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value, as a reference into the config variable + * itself. This is the internal method that implements get_value(), which + * returns a concrete. + */ INLINE const Filename &ConfigVariableFilename:: get_ref_value() const { TAU_PROFILE("const Filename &ConfigVariableFilename::get_ref_value() const", " ", TAU_USER); diff --git a/dtool/src/prc/configVariableFilename.cxx b/dtool/src/prc/configVariableFilename.cxx index dd9a4ab3ef..dc82a88f45 100644 --- a/dtool/src/prc/configVariableFilename.cxx +++ b/dtool/src/prc/configVariableFilename.cxx @@ -1,26 +1,22 @@ -// Filename: configVariableFilename.cxx -// Created by: drose (22Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableFilename.cxx + * @author drose + * @date 2004-11-22 + */ #include "configVariableFilename.h" #include "executionEnvironment.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableFilename::reload_cache -// Access: Private -// Description: Recopies the config variable into the Filename for -// returning its value. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the config variable into the Filename for returning its value. + */ void ConfigVariableFilename:: reload_cache() { nassertv(_core != (ConfigVariableCore *)NULL); diff --git a/dtool/src/prc/configVariableFilename.h b/dtool/src/prc/configVariableFilename.h index d546c25b55..e68c730128 100644 --- a/dtool/src/prc/configVariableFilename.h +++ b/dtool/src/prc/configVariableFilename.h @@ -1,16 +1,15 @@ -// Filename: configVariableFilename.h -// Created by: drose (22Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableFilename.h + * @author drose + * @date 2004-11-22 + */ #ifndef CONFIGVARIABLEFILENAME_H #define CONFIGVARIABLEFILENAME_H @@ -18,15 +17,13 @@ #include "dtoolbase.h" #include "configVariable.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableFilename -// Description : This is a convenience class to specialize -// ConfigVariable as a Filename type. It is almost the -// same thing as ConfigVariableString, except it handles -// an implicit Filename::expand_from() operation so that -// the user may put OS-specific filenames, or filenames -// based on environment variables, in the prc file. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a Filename + * type. It is almost the same thing as ConfigVariableString, except it + * handles an implicit Filename::expand_from() operation so that the user may + * put OS-specific filenames, or filenames based on environment variables, in + * the prc file. + */ class EXPCL_DTOOLCONFIG ConfigVariableFilename : public ConfigVariable { PUBLISHED: INLINE ConfigVariableFilename(const string &name); @@ -36,8 +33,7 @@ PUBLISHED: INLINE void operator = (const Filename &value); INLINE operator const Filename &() const; - // These methods help the ConfigVariableFilename act like a Filename - // object. + // These methods help the ConfigVariableFilename act like a Filename object. INLINE const char *c_str() const; INLINE bool empty() const; INLINE size_t length() const; diff --git a/dtool/src/prc/configVariableInt.I b/dtool/src/prc/configVariableInt.I index 8d56e00c52..7c91ce1d6a 100644 --- a/dtool/src/prc/configVariableInt.I +++ b/dtool/src/prc/configVariableInt.I @@ -1,23 +1,19 @@ -// Filename: configVariableInt.I -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt.I + * @author drose + * @date 2004-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt:: ConfigVariableInt(const string &name) : ConfigVariable(name, VT_int), @@ -26,13 +22,11 @@ ConfigVariableInt(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt:: -ConfigVariableInt(const string &name, int default_value, +ConfigVariableInt(const string &name, int default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), @@ -45,13 +39,11 @@ ConfigVariableInt(const string &name, int default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt:: -ConfigVariableInt(const string &name, const string &default_value, +ConfigVariableInt(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, ConfigVariableCore::VT_int, description, flags), @@ -64,62 +56,50 @@ ConfigVariableInt(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableInt:: operator = (int value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableInt:: operator int () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::size() -// Access: Published -// Description: Returns the number of unique words in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique words in the variable. + */ INLINE size_t ConfigVariableInt:: size() const { return get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::operator [] -// Access: Published -// Description: Returns the value of the variable's nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the variable's nth word. + */ INLINE int ConfigVariableInt:: operator [] (size_t n) const { return get_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableInt:: set_value(int value) { set_string_value(""); set_int_word(0, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE int ConfigVariableInt:: get_value() const { TAU_PROFILE("int ConfigVariableInt::get_value() const", " ", TAU_USER); @@ -130,11 +110,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE int ConfigVariableInt:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -144,24 +122,19 @@ get_default_value() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE int ConfigVariableInt:: get_word(size_t n) const { return get_int_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableInt:: set_word(size_t n, int value) { set_int_word(n, value); } - diff --git a/dtool/src/prc/configVariableInt.cxx b/dtool/src/prc/configVariableInt.cxx index 909368e3c2..e4cb18ac0f 100644 --- a/dtool/src/prc/configVariableInt.cxx +++ b/dtool/src/prc/configVariableInt.cxx @@ -1,25 +1,22 @@ -// Filename: configVariableInt.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt.cxx + * @author drose + * @date 2004-10-20 + */ #include "configVariableInt.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt::set_default_value -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableInt:: set_default_value(int default_value) { _core->set_default_value(format_string(default_value)); diff --git a/dtool/src/prc/configVariableInt.h b/dtool/src/prc/configVariableInt.h index b39889d31c..7605b27480 100644 --- a/dtool/src/prc/configVariableInt.h +++ b/dtool/src/prc/configVariableInt.h @@ -1,16 +1,15 @@ -// Filename: configVariableInt.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIGVARIABLEINT_H #define CONFIGVARIABLEINT_H @@ -18,19 +17,18 @@ #include "dtoolbase.h" #include "configVariable.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableInt -// Description : This is a convenience class to specialize -// ConfigVariable as an integer type. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as an integer + * type. + */ class EXPCL_DTOOLCONFIG ConfigVariableInt : public ConfigVariable { PUBLISHED: INLINE ConfigVariableInt(const string &name); INLINE ConfigVariableInt(const string &name, int default_value, - const string &description = string(), + const string &description = string(), int flags = 0); INLINE ConfigVariableInt(const string &name, const string &default_value, - const string &description = string(), + const string &description = string(), int flags = 0); INLINE void operator = (int value); diff --git a/dtool/src/prc/configVariableInt64.I b/dtool/src/prc/configVariableInt64.I index d45511df4d..94d405cd76 100644 --- a/dtool/src/prc/configVariableInt64.I +++ b/dtool/src/prc/configVariableInt64.I @@ -1,23 +1,19 @@ -// Filename: configVariableInt64.I -// Created by: drose (19Dec07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt64.I + * @author drose + * @date 2007-12-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt64:: ConfigVariableInt64(const string &name) : ConfigVariable(name, VT_int64), @@ -26,11 +22,9 @@ ConfigVariableInt64(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt64:: ConfigVariableInt64(const string &name, PN_int64 default_value, const string &description, int flags) : @@ -45,11 +39,9 @@ ConfigVariableInt64(const string &name, PN_int64 default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableInt64:: ConfigVariableInt64(const string &name, const string &default_value, const string &description, int flags) : @@ -64,62 +56,50 @@ ConfigVariableInt64(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableInt64:: operator = (PN_int64 value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableInt64:: operator PN_int64 () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::size() -// Access: Published -// Description: Returns the number of unique words in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique words in the variable. + */ INLINE size_t ConfigVariableInt64:: size() const { return get_num_words(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::operator [] -// Access: Published -// Description: Returns the value of the variable's nth word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the variable's nth word. + */ INLINE PN_int64 ConfigVariableInt64:: operator [] (size_t n) const { return get_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableInt64:: set_value(PN_int64 value) { set_string_value(""); set_int64_word(0, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE PN_int64 ConfigVariableInt64:: get_value() const { TAU_PROFILE("PN_int64 ConfigVariableInt64::get_value() const", " ", TAU_USER); @@ -130,11 +110,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE PN_int64 ConfigVariableInt64:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -144,24 +122,19 @@ get_default_value() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE PN_int64 ConfigVariableInt64:: get_word(size_t n) const { return get_int64_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableInt64:: set_word(size_t n, PN_int64 value) { set_int64_word(n, value); } - diff --git a/dtool/src/prc/configVariableInt64.cxx b/dtool/src/prc/configVariableInt64.cxx index 637172c65e..5545678685 100644 --- a/dtool/src/prc/configVariableInt64.cxx +++ b/dtool/src/prc/configVariableInt64.cxx @@ -1,25 +1,22 @@ -// Filename: configVariableInt64.cxx -// Created by: drose (19Dec07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt64.cxx + * @author drose + * @date 2007-12-19 + */ #include "configVariableInt64.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableInt64::set_default_value -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableInt64:: set_default_value(PN_int64 default_value) { _core->set_default_value(format_string(default_value)); diff --git a/dtool/src/prc/configVariableInt64.h b/dtool/src/prc/configVariableInt64.h index bcbfdff044..835c165f8a 100644 --- a/dtool/src/prc/configVariableInt64.h +++ b/dtool/src/prc/configVariableInt64.h @@ -1,16 +1,15 @@ -// Filename: configVariableInt64.h -// Created by: drose (19Dec07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableInt64.h + * @author drose + * @date 2007-12-19 + */ #ifndef CONFIGVARIABLEINT64_H #define CONFIGVARIABLEINT64_H @@ -19,11 +18,10 @@ #include "configVariable.h" #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableInt64 -// Description : This is a convenience class to specialize -// ConfigVariable as a 64-bit integer type. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a 64-bit + * integer type. + */ class EXPCL_DTOOLCONFIG ConfigVariableInt64 : public ConfigVariable { PUBLISHED: INLINE ConfigVariableInt64(const string &name); diff --git a/dtool/src/prc/configVariableList.I b/dtool/src/prc/configVariableList.I index 0b89f3855d..4429e31fb9 100644 --- a/dtool/src/prc/configVariableList.I +++ b/dtool/src/prc/configVariableList.I @@ -1,34 +1,28 @@ -// Filename: configVariableList.I -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableList.I + * @author drose + * @date 2004-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableList:: ~ConfigVariableList() { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableList:: -ConfigVariableList(const string &name, +ConfigVariableList(const string &name, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_list, description, flags) @@ -36,31 +30,27 @@ ConfigVariableList(const string &name, ConfigVariableBase(name, VT_list, string(), flags) #endif { - // A list variable implicitly defines a default value of the empty - // string. This is just to prevent the core variable from - // complaining should anyone ask for its solitary value. + // A list variable implicitly defines a default value of the empty string. + // This is just to prevent the core variable from complaining should anyone + // ask for its solitary value. if (_core->get_default_value() == (ConfigDeclaration *)NULL) { _core->set_default_value(""); } _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::get_num_values -// Access: Published -// Description: Returns the number of values in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of values in the variable. + */ INLINE size_t ConfigVariableList:: get_num_values() const { nassertr(_core != (ConfigVariableCore *)NULL, 0); return _core->get_num_trusted_references(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::get_string_value -// Access: Published -// Description: Returns the nth value of the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth value of the variable. + */ INLINE string ConfigVariableList:: get_string_value(size_t n) const { nassertr(_core != (ConfigVariableCore *)NULL, string()); @@ -71,22 +61,18 @@ get_string_value(size_t n) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::get_num_unique_values -// Access: Published -// Description: Returns the number of unique values in the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique values in the variable. + */ INLINE size_t ConfigVariableList:: get_num_unique_values() const { nassertr(_core != (ConfigVariableCore *)NULL, 0); return _core->get_num_unique_references(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::get_unique_value -// Access: Published -// Description: Returns the nth unique value of the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth unique value of the variable. + */ INLINE string ConfigVariableList:: get_unique_value(size_t n) const { nassertr(_core != (ConfigVariableCore *)NULL, string()); @@ -97,24 +83,19 @@ get_unique_value(size_t n) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::size() -// Access: Published -// Description: Returns the number of unique values of the variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique values of the variable. + */ INLINE size_t ConfigVariableList:: size() const { return get_num_unique_values(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::operator [] -// Access: Published -// Description: Returns the nth unique value of the variable. Note -// that the indexing operator returns the list of unique -// values, and so the maximum range is -// get_num_unique_values(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth unique value of the variable. Note that the indexing + * operator returns the list of unique values, and so the maximum range is + * get_num_unique_values(). + */ INLINE string ConfigVariableList:: operator [] (size_t n) const { return get_unique_value(n); diff --git a/dtool/src/prc/configVariableList.cxx b/dtool/src/prc/configVariableList.cxx index bc0f10c1e5..7ecd861837 100644 --- a/dtool/src/prc/configVariableList.cxx +++ b/dtool/src/prc/configVariableList.cxx @@ -1,34 +1,29 @@ -// Filename: configVariableList.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableList.cxx + * @author drose + * @date 2004-10-20 + */ #include "configVariableList.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableList:: output(ostream &out) const { out << get_num_values() << " values."; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableList::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableList:: write(ostream &out) const { size_t num_values = get_num_values(); diff --git a/dtool/src/prc/configVariableList.h b/dtool/src/prc/configVariableList.h index 69a289b119..448f8b5886 100644 --- a/dtool/src/prc/configVariableList.h +++ b/dtool/src/prc/configVariableList.h @@ -1,16 +1,15 @@ -// Filename: configVariableList.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableList.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIGVARIABLELIST_H #define CONFIGVARIABLELIST_H @@ -18,24 +17,21 @@ #include "dtoolbase.h" #include "configVariableBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableList -// Description : This class is similar to ConfigVariable, but it -// reports its value as a list of strings. In this -// special case, all of the declarations of the variable -// are returned as the elements of this list, in order. -// -// Note that this is different from a normal -// ConfigVariableString, which just returns its topmost -// value, which can optionally be treated as a number of -// discrete words by dividing it at the spaces. -// -// A ConfigVariableList cannot be modified locally. -//////////////////////////////////////////////////////////////////// +/** + * This class is similar to ConfigVariable, but it reports its value as a list + * of strings. In this special case, all of the declarations of the variable + * are returned as the elements of this list, in order. + * + * Note that this is different from a normal ConfigVariableString, which just + * returns its topmost value, which can optionally be treated as a number of + * discrete words by dividing it at the spaces. + * + * A ConfigVariableList cannot be modified locally. + */ class EXPCL_DTOOLCONFIG ConfigVariableList : public ConfigVariableBase { PUBLISHED: INLINE ConfigVariableList(const string &name, - const string &description = string(), + const string &description = string(), int flags = 0); INLINE ~ConfigVariableList(); diff --git a/dtool/src/prc/configVariableManager.I b/dtool/src/prc/configVariableManager.I index 11a6184c20..4ca5363bde 100644 --- a/dtool/src/prc/configVariableManager.I +++ b/dtool/src/prc/configVariableManager.I @@ -1,34 +1,27 @@ -// Filename: configVariableManager.I -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableManager.I + * @author drose + * @date 2004-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::get_num_variables -// Access: Published -// Description: Returns the current number of active ConfigVariableCores in -// the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of active ConfigVariableCores in the world. + */ INLINE size_t ConfigVariableManager:: get_num_variables() const { return _variables.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::get_variable -// Access: Published -// Description: Returns the nth active ConfigVariableCore in the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth active ConfigVariableCore in the world. + */ INLINE ConfigVariableCore *ConfigVariableManager:: get_variable(size_t n) const { nassertr(n < _variables.size(), (ConfigVariableCore *)NULL); diff --git a/dtool/src/prc/configVariableManager.cxx b/dtool/src/prc/configVariableManager.cxx index e884f12b5c..4231abbbaa 100644 --- a/dtool/src/prc/configVariableManager.cxx +++ b/dtool/src/prc/configVariableManager.cxx @@ -1,16 +1,15 @@ -// Filename: configVariableManager.cxx -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableManager.cxx + * @author drose + * @date 2004-10-15 + */ #include "configVariableManager.h" #include "configVariableCore.h" @@ -20,41 +19,31 @@ ConfigVariableManager *ConfigVariableManager::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::Constructor -// Access: Protected -// Description: The constructor is private (actually, just protected, -// but only to avoid a gcc compiler warning) because it -// should not be explicitly constructed. There is only -// one ConfigVariableManager, and it constructs -// itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is private (actually, just protected, but only to avoid a + * gcc compiler warning) because it should not be explicitly constructed. + * There is only one ConfigVariableManager, and it constructs itself. + */ ConfigVariableManager:: ConfigVariableManager() { init_memory_hook(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::Destructor -// Access: Protected -// Description: The ConfigVariableManager destructor should never be -// called, because this is a global object that is never -// freed. -//////////////////////////////////////////////////////////////////// +/** + * The ConfigVariableManager destructor should never be called, because this + * is a global object that is never freed. + */ ConfigVariableManager:: ~ConfigVariableManager() { prc_cat->error() << "Internal error--ConfigVariableManager destructor called!\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::make_variable -// Access: Published -// Description: Creates and returns a new, undefined -// ConfigVariableCore with the indicated name; or if a -// variable with this name has already been created, -// returns that one instead. -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new, undefined ConfigVariableCore with the indicated + * name; or if a variable with this name has already been created, returns + * that one instead. + */ ConfigVariableCore *ConfigVariableManager:: make_variable(const string &name) { VariablesByName::iterator ni; @@ -87,34 +76,27 @@ make_variable(const string &name) { return variable; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::make_variable_template -// Access: Published -// Description: Defines a variable "template" to match against -// dynamically-defined variables that may or may not be -// created in the future. -// -// The template consists of a glob pattern, -// e.g. "notify-level-*", which will be tested against -// any config variable passed to a future call to -// make_variable(). If the pattern matches, the -// returned ConfigVariableCore is copied to define the -// new variable, instead of creating a default, empty -// one. -// -// This is useful to pre-specify default values for a -// family of variables that all have similar properties, -// and all may not be created at the same time. It is -// especially useful to avoid cluttering up the list of -// available variables with user-declared variables that -// have not been defined yet by the application -// (e.g. "egg-object-type-*"). -// -// This method basically pre-defines all variables that -// match the specified glob pattern. -//////////////////////////////////////////////////////////////////// +/** + * Defines a variable "template" to match against dynamically-defined + * variables that may or may not be created in the future. + * + * The template consists of a glob pattern, e.g. "notify-level-*", which will + * be tested against any config variable passed to a future call to + * make_variable(). If the pattern matches, the returned ConfigVariableCore + * is copied to define the new variable, instead of creating a default, empty + * one. + * + * This is useful to pre-specify default values for a family of variables that + * all have similar properties, and all may not be created at the same time. + * It is especially useful to avoid cluttering up the list of available + * variables with user-declared variables that have not been defined yet by + * the application (e.g. "egg-object-type-*"). + * + * This method basically pre-defines all variables that match the specified + * glob pattern. + */ ConfigVariableCore *ConfigVariableManager:: -make_variable_template(const string &pattern, +make_variable_template(const string &pattern, ConfigFlags::ValueType value_type, const string &default_value, const string &description, int flags) { @@ -133,7 +115,7 @@ make_variable_template(const string &pattern, if (value_type != ConfigFlags::VT_undefined) { core->set_value_type(value_type); } - if (!default_value.empty() || + if (!default_value.empty() || core->get_default_value() == (ConfigDeclaration *)NULL) { core->set_default_value(default_value); } @@ -145,8 +127,8 @@ make_variable_template(const string &pattern, } core->set_used(); - // Also apply the same changes to any previously-defined variables - // that match the pattern. + // Also apply the same changes to any previously-defined variables that + // match the pattern. Variables::iterator vi; for (vi = _variables.begin(); vi != _variables.end(); ++vi) { ConfigVariableCore *variable = (*vi); @@ -154,7 +136,7 @@ make_variable_template(const string &pattern, if (value_type != ConfigFlags::VT_undefined) { variable->set_value_type(value_type); } - if (!default_value.empty() || + if (!default_value.empty() || variable->get_default_value() == (ConfigDeclaration *)NULL) { variable->set_default_value(default_value); } @@ -171,12 +153,9 @@ make_variable_template(const string &pattern, return core; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::get_variable_name -// Access: Published -// Description: Returns the name of the nth active ConfigVariable in -// the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth active ConfigVariable in the list. + */ string ConfigVariableManager:: get_variable_name(size_t n) const { if (n < _variables.size()) { @@ -185,12 +164,10 @@ get_variable_name(size_t n) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::is_variable_used -// Access: Published -// Description: Returns true if the nth active ConfigVariable in -// the list has been used by code, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth active ConfigVariable in the list has been used by + * code, false otherwise. + */ bool ConfigVariableManager:: is_variable_used(size_t n) const { if (n < _variables.size()) { @@ -199,21 +176,17 @@ is_variable_used(size_t n) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableManager:: output(ostream &out) const { out << "ConfigVariableManager, " << _variables.size() << " variables."; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableManager:: write(ostream &out) const { VariablesByName::const_iterator ni; @@ -228,18 +201,15 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::write_prc_variables -// Access: Published -// Description: Writes all of the prc-set config variables, as they -// appear in a prc file somewhere, one per line, very -// concisely. This lists the dominant value in the prc -// file; it does not list shadowed values, and it does -// not list locally-set values. -// -// This is mainly intended for generating a hash of the -// input config file state. -//////////////////////////////////////////////////////////////////// +/** + * Writes all of the prc-set config variables, as they appear in a prc file + * somewhere, one per line, very concisely. This lists the dominant value in + * the prc file; it does not list shadowed values, and it does not list + * locally-set values. + * + * This is mainly intended for generating a hash of the input config file + * state. + */ void ConfigVariableManager:: write_prc_variables(ostream &out) const { VariablesByName::const_iterator ni; @@ -267,13 +237,10 @@ write_prc_variables(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::list_unused_variables -// Access: Published -// Description: Writes a list of all the variables that have been -// defined in a prc file without having been declared -// somewhere in code. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of all the variables that have been defined in a prc file + * without having been declared somewhere in code. + */ void ConfigVariableManager:: list_unused_variables() const { VariablesByName::const_iterator ni; @@ -292,13 +259,10 @@ list_unused_variables() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::list_variables -// Access: Published -// Description: Writes a list of all the variables that have been -// declared somewhere in code, along with a brief -// description. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of all the variables that have been declared somewhere in + * code, along with a brief description. + */ void ConfigVariableManager:: list_variables() const { VariablesByName::const_iterator ni; @@ -312,15 +276,12 @@ list_variables() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::list_dynamic_variables -// Access: Published -// Description: Writes a list of all the "dynamic" variables that -// have been declared somewhere in code, along with a -// brief description. This is a (usually large) list of -// config variables that are declared with a generated -// variable name. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of all the "dynamic" variables that have been declared + * somewhere in code, along with a brief description. This is a (usually + * large) list of config variables that are declared with a generated variable + * name. + */ void ConfigVariableManager:: list_dynamic_variables() const { VariablesByName::const_iterator ni; @@ -334,11 +295,9 @@ list_dynamic_variables() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::get_global_ptr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConfigVariableManager *ConfigVariableManager:: get_global_ptr() { if (_global_ptr == (ConfigVariableManager *)NULL) { @@ -347,38 +306,35 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableManager::list_variable -// Access: Private -// Description: Lists a single variable and its value. -//////////////////////////////////////////////////////////////////// +/** + * Lists a single variable and its value. + */ void ConfigVariableManager:: -list_variable(const ConfigVariableCore *variable, +list_variable(const ConfigVariableCore *variable, bool include_descriptions) const { if (!variable->is_used()) { // If the variable is unused, just show its name. nout << variable->get_name() << " not used"; if (variable->get_num_references() > 0) { - nout << " (referenced in " + nout << " (referenced in " << variable->get_reference(0)->get_page()->get_name() << ")"; } nout << "\n"; - - } else { - // If the variable is used--it's been defined somewhere--show its - // name, its type, its current and default values, and if - // available, its description. - nout << variable->get_name() << " " + } else { + // If the variable is used--it's been defined somewhere--show its name, + // its type, its current and default values, and if available, its + // description. + + nout << variable->get_name() << " " << variable->get_value_type() << "\n"; - + const ConfigDeclaration *decl; - + if (variable->get_value_type() == ConfigVariableCore::VT_list || variable->get_value_type() == ConfigVariableCore::VT_search_path) { - // We treat a "list" variable as a special case: list all of - // its values. + // We treat a "list" variable as a special case: list all of its values. nout << " current value:\n"; size_t num_references = variable->get_num_trusted_references(); for (size_t i = 0; i < num_references; ++i) { @@ -388,9 +344,8 @@ list_variable(const ConfigVariableCore *variable, } } else { - // An ordinary, non-list variable gets one line for its - // current value (if it has one) and another line for its - // default value. + // An ordinary, non-list variable gets one line for its current value + // (if it has one) and another line for its default value. decl = variable->get_declaration(0); if (decl != variable->get_default_value()) { nout << " current value = " << decl->get_string_value(); @@ -400,13 +355,13 @@ list_variable(const ConfigVariableCore *variable, nout << " (defined locally)\n"; } } - + decl = variable->get_default_value(); if (decl != (ConfigDeclaration *)NULL) { nout << " default value = " << decl->get_string_value() << "\n"; } } - + if (!variable->get_description().empty() && include_descriptions) { nout << " " << variable->get_description() << "\n"; } diff --git a/dtool/src/prc/configVariableManager.h b/dtool/src/prc/configVariableManager.h index 69e039d42e..eccdf2945c 100644 --- a/dtool/src/prc/configVariableManager.h +++ b/dtool/src/prc/configVariableManager.h @@ -1,16 +1,15 @@ -// Filename: configVariableManager.h -// Created by: drose (15Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableManager.h + * @author drose + * @date 2004-10-15 + */ #ifndef CONFIGVARIABLEMANAGER_H #define CONFIGVARIABLEMANAGER_H @@ -24,13 +23,11 @@ class ConfigVariableCore; -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableManager -// Description : A global object that maintains the set of -// ConfigVariables (actually, ConfigVariableCores) -// everywhere in the world, and keeps them in sorted -// order. -//////////////////////////////////////////////////////////////////// +/** + * A global object that maintains the set of ConfigVariables (actually, + * ConfigVariableCores) everywhere in the world, and keeps them in sorted + * order. + */ class EXPCL_DTOOLCONFIG ConfigVariableManager { protected: ConfigVariableManager(); @@ -38,10 +35,10 @@ protected: PUBLISHED: ConfigVariableCore *make_variable(const string &name); - ConfigVariableCore *make_variable_template(const string &pattern, + ConfigVariableCore *make_variable_template(const string &pattern, ConfigFlags::ValueType type, const string &default_value, - const string &description = string(), + const string &description = string(), int flags = 0); @@ -66,8 +63,8 @@ private: void list_variable(const ConfigVariableCore *variable, bool include_descriptions) const; - // We have to avoid pmap and pvector, due to the very low-level - // nature of this stuff. + // We have to avoid pmap and pvector, due to the very low-level nature of + // this stuff. typedef vector Variables; Variables _variables; @@ -85,4 +82,3 @@ INLINE ostream &operator << (ostream &out, const ConfigVariableManager &variable #include "configVariableManager.I" #endif - diff --git a/dtool/src/prc/configVariableSearchPath.I b/dtool/src/prc/configVariableSearchPath.I index 75c9f5edf1..9017d1cf0a 100644 --- a/dtool/src/prc/configVariableSearchPath.I +++ b/dtool/src/prc/configVariableSearchPath.I @@ -1,25 +1,21 @@ -// Filename: configVariableSearchPath.I -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableSearchPath.I + * @author drose + * @date 2004-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, +ConfigVariableSearchPath(const string &name, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariableBase(name, VT_search_path, description, flags), @@ -30,21 +26,19 @@ ConfigVariableSearchPath(const string &name, _local_modified(initial_invalid_cache()) { // A SearchPath variable implicitly defines a default value of the empty - // string. This is just to prevent the core variable from - // complaining should anyone ask for its solitary value. + // string. This is just to prevent the core variable from complaining + // should anyone ask for its solitary value. if (_core->get_default_value() == (ConfigDeclaration *)NULL) { _core->set_default_value(""); } _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, +ConfigVariableSearchPath(const string &name, const DSearchPath &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS @@ -56,21 +50,19 @@ ConfigVariableSearchPath(const string &name, _local_modified(initial_invalid_cache()) { // A SearchPath variable implicitly defines a default value of the empty - // string. This is just to prevent the core variable from - // complaining should anyone ask for its solitary value. + // string. This is just to prevent the core variable from complaining + // should anyone ask for its solitary value. if (_core->get_default_value() == (ConfigDeclaration *)NULL) { _core->set_default_value(""); } _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableSearchPath:: -ConfigVariableSearchPath(const string &name, +ConfigVariableSearchPath(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS @@ -82,38 +74,32 @@ ConfigVariableSearchPath(const string &name, _local_modified(initial_invalid_cache()) { // A SearchPath variable implicitly defines a default value of the empty - // string. This is just to prevent the core variable from - // complaining should anyone ask for its solitary value. + // string. This is just to prevent the core variable from complaining + // should anyone ask for its solitary value. if (_core->get_default_value() == (ConfigDeclaration *)NULL) { _core->set_default_value(""); } _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableSearchPath:: ~ConfigVariableSearchPath() { } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::DSearchPath typecast -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableSearchPath:: operator const DSearchPath & () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::get_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const DSearchPath &ConfigVariableSearchPath:: get_value() const { TAU_PROFILE("const DSearchPath &ConfigVariableSearchPath::get_value() const", " ", TAU_USER); @@ -123,22 +109,18 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::get_default_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const DSearchPath &ConfigVariableSearchPath:: get_default_value() const { return _default_value; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::clear_local_value -// Access: Published -// Description: Removes all the directories locally added to the -// search list, and restores it to its original form. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the directories locally added to the search list, and restores + * it to its original form. + */ INLINE bool ConfigVariableSearchPath:: clear_local_value() { nassertr(_core != (ConfigVariableCore *)NULL, false); @@ -146,7 +128,7 @@ clear_local_value() { bool any_to_clear = !_prefix.is_empty() || _postfix.is_empty(); _prefix.clear(); _postfix.clear(); - + if (_core->clear_local_value()) { any_to_clear = true; } @@ -155,165 +137,132 @@ clear_local_value() { return any_to_clear; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::clear -// Access: Published -// Description: Removes all the directories locally added to the -// search list, and restores it to its original form. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the directories locally added to the search list, and restores + * it to its original form. + */ INLINE void ConfigVariableSearchPath:: clear() { clear_local_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::append_directory -// Access: Published -// Description: Adds a new directory to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new directory to the end of the search list. + */ INLINE void ConfigVariableSearchPath:: append_directory(const Filename &directory) { _postfix.append_directory(directory); _local_modified = initial_invalid_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::prepend_directory -// Access: Published -// Description: Adds a new directory to the front of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new directory to the front of the search list. + */ INLINE void ConfigVariableSearchPath:: prepend_directory(const Filename &directory) { _prefix.prepend_directory(directory); _local_modified = initial_invalid_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::append_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the end of the + * search list. + */ INLINE void ConfigVariableSearchPath:: append_path(const string &path, const string &separator) { _postfix.append_path(path, separator); _local_modified = initial_invalid_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::append_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the end of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the end of the + * search list. + */ INLINE void ConfigVariableSearchPath:: append_path(const DSearchPath &path) { _postfix.append_path(path); _local_modified = initial_invalid_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::prepend_path -// Access: Published -// Description: Adds all of the directories listed in the search path -// to the beginning of the search list. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the directories listed in the search path to the beginning of + * the search list. + */ INLINE void ConfigVariableSearchPath:: prepend_path(const DSearchPath &path) { _prefix.prepend_path(path); _local_modified = initial_invalid_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::is_empty -// Access: Published -// Description: Returns true if the search list is empty, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the search list is empty, false otherwise. + */ INLINE bool ConfigVariableSearchPath:: is_empty() const { return get_value().is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::get_num_directories -// Access: Published -// Description: Returns the number of directories on the search list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of directories on the search list. + */ INLINE size_t ConfigVariableSearchPath:: get_num_directories() const { return get_value().get_num_directories(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::get_directory -// Access: Published -// Description: Returns the nth directory on the search list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth directory on the search list. + */ INLINE const Filename &ConfigVariableSearchPath:: get_directory(size_t n) const { return get_value().get_directory(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::find_file -// Access: Published -// Description: Searches all the directories in the search list for -// the indicated file, in order. Returns the full -// matching pathname of the first match if found, or the -// empty string if not found. -//////////////////////////////////////////////////////////////////// +/** + * Searches all the directories in the search list for the indicated file, in + * order. Returns the full matching pathname of the first match if found, or + * the empty string if not found. + */ INLINE Filename ConfigVariableSearchPath:: find_file(const Filename &filename) const { return get_value().find_file(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::find_all_files -// Access: Published -// Description: Searches all the directories in the search list for -// the indicated file, in order. Fills up the results -// list with *all* of the matching filenames found, if -// any. Returns the number of matches found. -// -// It is the responsibility of the the caller to clear -// the results list first; otherwise, the newly-found -// files will be appended to the list. -//////////////////////////////////////////////////////////////////// +/** + * Searches all the directories in the search list for the indicated file, in + * order. Fills up the results list with *all* of the matching filenames + * found, if any. Returns the number of matches found. + * + * It is the responsibility of the the caller to clear the results list first; + * otherwise, the newly-found files will be appended to the list. + */ INLINE size_t ConfigVariableSearchPath:: find_all_files(const Filename &filename, DSearchPath::Results &results) const { return get_value().find_all_files(filename, results); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::find_all_files -// Access: Published -// Description: This variant of find_all_files() returns the new -// Results object, instead of filling on in on the -// parameter list. This is a little more convenient to -// call from Python. -//////////////////////////////////////////////////////////////////// +/** + * This variant of find_all_files() returns the new Results object, instead of + * filling on in on the parameter list. This is a little more convenient to + * call from Python. + */ INLINE DSearchPath::Results ConfigVariableSearchPath:: find_all_files(const Filename &filename) const { return get_value().find_all_files(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConfigVariableSearchPath:: output(ostream &out) const { get_value().output(out); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConfigVariableSearchPath:: write(ostream &out) const { get_value().write(out); diff --git a/dtool/src/prc/configVariableSearchPath.cxx b/dtool/src/prc/configVariableSearchPath.cxx index 0b379ec1ea..2ae4d87d16 100644 --- a/dtool/src/prc/configVariableSearchPath.cxx +++ b/dtool/src/prc/configVariableSearchPath.cxx @@ -1,26 +1,22 @@ -// Filename: configVariableSearchPath.cxx -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableSearchPath.cxx + * @author drose + * @date 2004-10-21 + */ #include "configVariableSearchPath.h" #include "executionEnvironment.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableSearchPath::reload_search_path -// Access: Private -// Description: Recopies the config variable into the search path for -// returning its value. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the config variable into the search path for returning its value. + */ void ConfigVariableSearchPath:: reload_search_path() { nassertv(_core != (ConfigVariableCore *)NULL); @@ -45,7 +41,7 @@ reload_search_path() { } } - if (_prefix.is_empty() && _postfix.is_empty() && + if (_prefix.is_empty() && _postfix.is_empty() && num_unique_references == 0) { // An empty search path implicitly has the default value. _cache = _default_value; diff --git a/dtool/src/prc/configVariableSearchPath.h b/dtool/src/prc/configVariableSearchPath.h index c2b6e1f0b6..25524b86d4 100644 --- a/dtool/src/prc/configVariableSearchPath.h +++ b/dtool/src/prc/configVariableSearchPath.h @@ -1,16 +1,15 @@ -// Filename: configVariableSearchPath.h -// Created by: drose (21Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableSearchPath.h + * @author drose + * @date 2004-10-21 + */ #ifndef CONFIGVARIABLESEARCHPATH_H #define CONFIGVARIABLESEARCHPATH_H @@ -19,38 +18,33 @@ #include "configVariableBase.h" #include "dSearchPath.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableSearchPath -// Description : This is similar to a ConfigVariableList, but it -// returns its list as a DSearchPath, as a list of -// directories. -// -// You may locally append directories to the end of the -// search path with the methods here, or prepend them to -// the beginning. Use these methods to make adjustments -// to the path; do not attempt to directly modify the -// const DSearchPath object returned by get_value(). -// -// Unlike other ConfigVariable types, local changes -// (made by calling append_directory() and -// prepend_directory()) are specific to this particular -// instance of the ConfigVariableSearchPath. A separate -// instance of the same variable, created by using the -// same name to the constructor, will not reflect the -// local changes. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to a ConfigVariableList, but it returns its list as a + * DSearchPath, as a list of directories. + * + * You may locally append directories to the end of the search path with the + * methods here, or prepend them to the beginning. Use these methods to make + * adjustments to the path; do not attempt to directly modify the const + * DSearchPath object returned by get_value(). + * + * Unlike other ConfigVariable types, local changes (made by calling + * append_directory() and prepend_directory()) are specific to this particular + * instance of the ConfigVariableSearchPath. A separate instance of the same + * variable, created by using the same name to the constructor, will not + * reflect the local changes. + */ class EXPCL_DTOOLCONFIG ConfigVariableSearchPath : public ConfigVariableBase { PUBLISHED: - INLINE ConfigVariableSearchPath(const string &name, - const string &description = string(), + INLINE ConfigVariableSearchPath(const string &name, + const string &description = string(), int flags = 0); - INLINE ConfigVariableSearchPath(const string &name, + INLINE ConfigVariableSearchPath(const string &name, const DSearchPath &default_value, - const string &description, + const string &description, int flags = 0); - INLINE ConfigVariableSearchPath(const string &name, + INLINE ConfigVariableSearchPath(const string &name, const string &default_value, - const string &description, + const string &description, int flags = 0); INLINE ~ConfigVariableSearchPath(); diff --git a/dtool/src/prc/configVariableString.I b/dtool/src/prc/configVariableString.I index 65152bcc78..b3b88b90fe 100644 --- a/dtool/src/prc/configVariableString.I +++ b/dtool/src/prc/configVariableString.I @@ -1,23 +1,19 @@ -// Filename: configVariableString.I -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableString.I + * @author drose + * @date 2004-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableString:: ConfigVariableString(const string &name) : ConfigVariable(name, VT_string), @@ -26,13 +22,11 @@ ConfigVariableString(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableString:: -ConfigVariableString(const string &name, const string &default_value, +ConfigVariableString(const string &name, const string &default_value, const string &description, int flags) : #ifdef PRC_SAVE_DESCRIPTIONS ConfigVariable(name, VT_string, description, flags), @@ -45,112 +39,90 @@ ConfigVariableString(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableString:: operator = (const string &value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::string typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableString:: operator const string & () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::c_str -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const char *ConfigVariableString:: c_str() const { return get_value().c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableString:: empty() const { return get_value().empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t ConfigVariableString:: length() const { return get_value().length(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE char ConfigVariableString:: operator [] (size_t n) const { assert(n < length()); return get_value()[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Equality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableString:: operator == (const string &other) const { return get_value() == other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Inequality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableString:: operator != (const string &other) const { return get_value() != other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::Ordering operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConfigVariableString:: operator < (const string &other) const { return get_value() < other; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableString:: set_value(const string &value) { set_string_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE const string &ConfigVariableString:: get_value() const { TAU_PROFILE("const string &ConfigVariableString::get_value() const", " ", TAU_USER); @@ -161,11 +133,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE string ConfigVariableString:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); @@ -175,22 +145,18 @@ get_default_value() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::get_word -// Access: Published -// Description: Returns the variable's nth value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's nth value. + */ INLINE string ConfigVariableString:: get_word(size_t n) const { return get_string_word(n); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableString::set_word -// Access: Published -// Description: Reassigns the variable's nth value. This makes a -// local copy of the variable's overall value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's nth value. This makes a local copy of the + * variable's overall value. + */ INLINE void ConfigVariableString:: set_word(size_t n, const string &value) { set_string_word(n, value); diff --git a/dtool/src/prc/configVariableString.cxx b/dtool/src/prc/configVariableString.cxx index e1b7796f3f..125c8841a9 100644 --- a/dtool/src/prc/configVariableString.cxx +++ b/dtool/src/prc/configVariableString.cxx @@ -1,15 +1,14 @@ -// Filename: configVariableString.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableString.cxx + * @author drose + * @date 2004-10-20 + */ #include "configVariableString.h" diff --git a/dtool/src/prc/configVariableString.h b/dtool/src/prc/configVariableString.h index 7375a9e6ad..08709e1ac1 100644 --- a/dtool/src/prc/configVariableString.h +++ b/dtool/src/prc/configVariableString.h @@ -1,16 +1,15 @@ -// Filename: configVariableString.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableString.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIGVARIABLESTRING_H #define CONFIGVARIABLESTRING_H @@ -18,11 +17,9 @@ #include "dtoolbase.h" #include "configVariable.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableString -// Description : This is a convenience class to specialize -// ConfigVariable as a string type. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a string type. + */ class EXPCL_DTOOLCONFIG ConfigVariableString : public ConfigVariable { PUBLISHED: INLINE ConfigVariableString(const string &name); @@ -32,8 +29,7 @@ PUBLISHED: INLINE void operator = (const string &value); INLINE operator const string & () const; - // These methods help the ConfigVariableString act like a C++ string - // object. + // These methods help the ConfigVariableString act like a C++ string object. INLINE const char *c_str() const; INLINE bool empty() const; INLINE size_t length() const; diff --git a/dtool/src/prc/config_prc.cxx b/dtool/src/prc/config_prc.cxx index 6db118e093..f2a57d1993 100644 --- a/dtool/src/prc/config_prc.cxx +++ b/dtool/src/prc/config_prc.cxx @@ -1,16 +1,15 @@ -// Filename: config_prc.cxx -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_prc.cxx + * @author drose + * @date 2004-10-20 + */ #include "config_prc.h" #include "configVariableBool.h" diff --git a/dtool/src/prc/config_prc.h b/dtool/src/prc/config_prc.h index 6084b035b0..5fbe9ec7d3 100644 --- a/dtool/src/prc/config_prc.h +++ b/dtool/src/prc/config_prc.h @@ -1,16 +1,15 @@ -// Filename: config_prc.h -// Created by: drose (20Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_prc.h + * @author drose + * @date 2004-10-20 + */ #ifndef CONFIG_PRC_H #define CONFIG_PRC_H @@ -26,4 +25,3 @@ NotifyCategoryDecl(prc, EXPCL_DTOOLCONFIG, EXPTP_DTOOLCONFIG); extern ALIGN_16BYTE ConfigVariableBool assert_abort; #endif - diff --git a/dtool/src/prc/encryptStream.I b/dtool/src/prc/encryptStream.I index 643980fbba..bdb911ebf8 100644 --- a/dtool/src/prc/encryptStream.I +++ b/dtool/src/prc/encryptStream.I @@ -1,43 +1,35 @@ -// Filename: encryptStream.I -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStream.I + * @author drose + * @date 2004-09-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecryptStream:: IDecryptStream() : istream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecryptStream:: IDecryptStream(istream *source, bool owns_source, const string &password) : istream(&_buf) { open(source, owns_source, password); } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::open -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecryptStream &IDecryptStream:: open(istream *source, bool owns_source, const string &password) { clear((ios_iostate)0); @@ -45,77 +37,61 @@ open(istream *source, bool owns_source, const string &password) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::close -// Access: Published -// Description: Resets the EncryptStream to empty, but does not actually -// close the source istream unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the EncryptStream to empty, but does not actually close the source + * istream unless owns_source was true. + */ INLINE IDecryptStream &IDecryptStream:: close() { _buf.close_read(); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::get_algorithm -// Access: Published -// Description: Returns the encryption algorithm that was read from -// the stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption algorithm that was read from the stream. + */ INLINE const string &IDecryptStream:: get_algorithm() const { return _buf.get_algorithm(); } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::get_key_length -// Access: Published -// Description: Returns the encryption key length, in bits, that was -// read from the stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption key length, in bits, that was read from the stream. + */ INLINE int IDecryptStream:: get_key_length() const { return _buf.get_key_length(); } -//////////////////////////////////////////////////////////////////// -// Function: IDecryptStream::get_iteration_count -// Access: Published -// Description: Returns the value that was was read from the stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value that was was read from the stream. + */ INLINE int IDecryptStream:: get_iteration_count() const { return _buf.get_iteration_count(); } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OEncryptStream:: OEncryptStream() : ostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OEncryptStream:: OEncryptStream(ostream *dest, bool owns_dest, const string &password) : - ostream(&_buf) + ostream(&_buf) { open(dest, owns_dest, password); } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::open -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OEncryptStream &OEncryptStream:: open(ostream *dest, bool owns_dest, const string &password) { clear((ios_iostate)0); @@ -123,12 +99,10 @@ open(ostream *dest, bool owns_dest, const string &password) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::close -// Access: Published -// Description: Resets the EncryptStream to empty, but does not actually -// close the dest ostream unless owns_dest was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the EncryptStream to empty, but does not actually close the dest + * ostream unless owns_dest was true. + */ INLINE OEncryptStream &OEncryptStream:: close() { _buf.close_write(); @@ -136,57 +110,44 @@ close() { } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::set_algorithm -// Access: Published -// Description: Specifies the encryption algorithm that should be -// used for future calls to open(). The default -// is whatever is specified by the encryption-algorithm -// config variable. The complete set of available -// algorithms is defined by the current version of -// OpenSSL. -// -// If an invalid algorithm is specified, there is no -// immediate error return code, but open() will -// fail. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the encryption algorithm that should be used for future calls to + * open(). The default is whatever is specified by the encryption-algorithm + * config variable. The complete set of available algorithms is defined by + * the current version of OpenSSL. + * + * If an invalid algorithm is specified, there is no immediate error return + * code, but open() will fail. + */ INLINE void OEncryptStream:: set_algorithm(const string &algorithm) { _buf.set_algorithm(algorithm); } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::set_key_length -// Access: Published -// Description: Specifies the length of the key, in bits, that should -// be used to encrypt the stream in future calls to -// open(). The default is whatever is specified -// by the encryption-key-length config variable. -// -// If an invalid key_length for the chosen algorithm is -// specified, there is no immediate error return code, -// but open() will fail. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the length of the key, in bits, that should be used to encrypt + * the stream in future calls to open(). The default is whatever is specified + * by the encryption-key-length config variable. + * + * If an invalid key_length for the chosen algorithm is specified, there is no + * immediate error return code, but open() will fail. + */ INLINE void OEncryptStream:: set_key_length(int key_length) { _buf.set_key_length(key_length); } -//////////////////////////////////////////////////////////////////// -// Function: OEncryptStream::set_iteration_count -// Access: Published -// Description: Specifies the number of times to repeatedly hash the -// key before writing it to the stream in future calls -// to open(). Its purpose is to make it -// computationally more expensive for an attacker to -// search the key space exhaustively. This should be a -// multiple of 1,000 and should not exceed about 65 -// million; the value 0 indicates just one application -// of the hashing algorithm. -// -// The default is whatever is specified by the -// encryption-iteration-count config variable. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of times to repeatedly hash the key before writing it + * to the stream in future calls to open(). Its purpose is to make it + * computationally more expensive for an attacker to search the key space + * exhaustively. This should be a multiple of 1,000 and should not exceed + * about 65 million; the value 0 indicates just one application of the hashing + * algorithm. + * + * The default is whatever is specified by the encryption-iteration-count + * config variable. + */ INLINE void OEncryptStream:: set_iteration_count(int iteration_count) { _buf.set_iteration_count(iteration_count); diff --git a/dtool/src/prc/encryptStream.cxx b/dtool/src/prc/encryptStream.cxx index f0e93589fd..24656b7416 100644 --- a/dtool/src/prc/encryptStream.cxx +++ b/dtool/src/prc/encryptStream.cxx @@ -1,15 +1,14 @@ -// Filename: encryptStream.cxx -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStream.cxx + * @author drose + * @date 2004-09-01 + */ #include "encryptStream.h" diff --git a/dtool/src/prc/encryptStream.h b/dtool/src/prc/encryptStream.h index 75787d26e8..e69ab0f9a9 100644 --- a/dtool/src/prc/encryptStream.h +++ b/dtool/src/prc/encryptStream.h @@ -1,16 +1,15 @@ -// Filename: encryptStream.h -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStream.h + * @author drose + * @date 2004-09-01 + */ #ifndef ENCRYPTSTREAM_H #define ENCRYPTSTREAM_H @@ -22,18 +21,16 @@ #include "encryptStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : IDecryptStream -// Description : An input stream object that uses OpenSSL to decrypt -// the input from another source stream on-the-fly. -// -// Attach an IDecryptStream to an existing istream that -// provides encrypted data, as generated by an -// OEncryptStream, and read the corresponding -// unencrypted data from the IDecryptStream. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An input stream object that uses OpenSSL to decrypt the input from another + * source stream on-the-fly. + * + * Attach an IDecryptStream to an existing istream that provides encrypted + * data, as generated by an OEncryptStream, and read the corresponding + * unencrypted data from the IDecryptStream. + * + * Seeking is not supported. + */ class EXPCL_DTOOLCONFIG IDecryptStream : public istream { PUBLISHED: INLINE IDecryptStream(); @@ -56,28 +53,26 @@ private: EncryptStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : OEncryptStream -// Description : An input stream object that uses OpenSSL to encrypt -// data to another destination stream on-the-fly. -// -// Attach an OEncryptStream to an existing ostream that -// will accept encrypted data, and write your -// unencrypted source data to the OEncryptStream. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An input stream object that uses OpenSSL to encrypt data to another + * destination stream on-the-fly. + * + * Attach an OEncryptStream to an existing ostream that will accept encrypted + * data, and write your unencrypted source data to the OEncryptStream. + * + * Seeking is not supported. + */ class EXPCL_DTOOLCONFIG OEncryptStream : public ostream { PUBLISHED: INLINE OEncryptStream(); - INLINE OEncryptStream(ostream *dest, bool owns_dest, + INLINE OEncryptStream(ostream *dest, bool owns_dest, const string &password); #if _MSC_VER >= 1800 INLINE OEncryptStream(const OEncryptStream ©) = delete; #endif - INLINE OEncryptStream &open(ostream *dest, bool owns_dest, + INLINE OEncryptStream &open(ostream *dest, bool owns_dest, const string &password); INLINE OEncryptStream &close(); @@ -95,5 +90,3 @@ private: #endif - - diff --git a/dtool/src/prc/encryptStreamBuf.I b/dtool/src/prc/encryptStreamBuf.I index 8170b40c15..88537ca09e 100644 --- a/dtool/src/prc/encryptStreamBuf.I +++ b/dtool/src/prc/encryptStreamBuf.I @@ -1,105 +1,82 @@ -// Filename: encryptStreamBuf.I -// Created by: drose (09Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStreamBuf.I + * @author drose + * @date 2004-12-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::set_algorithm -// Access: Public -// Description: Specifies the encryption algorithm that should be -// used for future calls to open_write(). The default -// is whatever is specified by the encryption-algorithm -// config variable. The complete set of available -// algorithms is defined by the current version of -// OpenSSL. -// -// If an invalid algorithm is specified, there is no -// immediate error return code, but open_write() will -// fail. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the encryption algorithm that should be used for future calls to + * open_write(). The default is whatever is specified by the encryption- + * algorithm config variable. The complete set of available algorithms is + * defined by the current version of OpenSSL. + * + * If an invalid algorithm is specified, there is no immediate error return + * code, but open_write() will fail. + */ INLINE void EncryptStreamBuf:: set_algorithm(const string &algorithm) { _algorithm = algorithm; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::get_algorithm -// Access: Public -// Description: Returns the encryption algorithm that was specified -// by set_algorithm(), or was read from the stream by -// the last successful open_read(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption algorithm that was specified by set_algorithm(), or + * was read from the stream by the last successful open_read(). + */ INLINE const string &EncryptStreamBuf:: get_algorithm() const { return _algorithm; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::set_key_length -// Access: Public -// Description: Specifies the length of the key, in bits, that should -// be used to encrypt the stream in future calls to -// open_write(). The default is whatever is specified -// by the encryption-key-length config variable. -// -// If an invalid key_length for the chosen algorithm is -// specified, there is no immediate error return code, -// but open_write() will fail. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the length of the key, in bits, that should be used to encrypt + * the stream in future calls to open_write(). The default is whatever is + * specified by the encryption-key-length config variable. + * + * If an invalid key_length for the chosen algorithm is specified, there is no + * immediate error return code, but open_write() will fail. + */ INLINE void EncryptStreamBuf:: set_key_length(int key_length) { _key_length = key_length; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::get_key_length -// Access: Public -// Description: Returns the encryption key length, in bits, that was -// specified by set_key_length(), or was read from the -// stream by the last successful open_read(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption key length, in bits, that was specified by + * set_key_length(), or was read from the stream by the last successful + * open_read(). + */ INLINE int EncryptStreamBuf:: get_key_length() const { return _key_length; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::set_iteration_count -// Access: Public -// Description: Specifies the number of times to repeatedly hash the -// key before writing it to the stream in future calls -// to open_write(). Its purpose is to make it -// computationally more expensive for an attacker to -// search the key space exhaustively. This should be a -// multiple of 1,000 and should not exceed about 65 -// million; the value 0 indicates just one application -// of the hashing algorithm. -// -// The default is whatever is specified by the -// encryption-iteration-count config variable. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of times to repeatedly hash the key before writing it + * to the stream in future calls to open_write(). Its purpose is to make it + * computationally more expensive for an attacker to search the key space + * exhaustively. This should be a multiple of 1,000 and should not exceed + * about 65 million; the value 0 indicates just one application of the hashing + * algorithm. + * + * The default is whatever is specified by the encryption-iteration-count + * config variable. + */ INLINE void EncryptStreamBuf:: set_iteration_count(int iteration_count) { _iteration_count = iteration_count; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::get_iteration_count -// Access: Public -// Description: Returns the value that was specified by -// set_iteration_count(), or was read from the stream by -// the last successful open_read(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value that was specified by set_iteration_count(), or was read + * from the stream by the last successful open_read(). + */ INLINE int EncryptStreamBuf:: get_iteration_count() const { return _iteration_count; diff --git a/dtool/src/prc/encryptStreamBuf.cxx b/dtool/src/prc/encryptStreamBuf.cxx index 1dcac25349..a308412797 100644 --- a/dtool/src/prc/encryptStreamBuf.cxx +++ b/dtool/src/prc/encryptStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: encryptStreamBuf.cxx -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStreamBuf.cxx + * @author drose + * @date 2004-09-01 + */ #include "encryptStreamBuf.h" #include "config_prc.h" @@ -28,15 +27,12 @@ typedef int streamsize; #endif /* HAVE_STREAMSIZE */ -// The iteration count is scaled by this factor for writing to the -// stream. +// The iteration count is scaled by this factor for writing to the stream. static const int iteration_count_factor = 1000; -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EncryptStreamBuf:: EncryptStreamBuf() { _source = (istream *)NULL; @@ -96,22 +92,18 @@ EncryptStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EncryptStreamBuf:: ~EncryptStreamBuf() { close_read(); close_write(); } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::open_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EncryptStreamBuf:: open_read(istream *source, bool owns_source, const string &password) { OpenSSL_add_all_algorithms(); @@ -169,8 +161,8 @@ open_read(istream *source, bool owns_source, const string &password) { unsigned char *key = (unsigned char *)alloca(key_length); result = PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(), - (unsigned char *)iv.data(), iv.length(), - count * iteration_count_factor + 1, + (unsigned char *)iv.data(), iv.length(), + count * iteration_count_factor + 1, key_length, key); nassertv(result > 0); @@ -185,11 +177,9 @@ open_read(istream *source, bool owns_source, const string &password) { thread_consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::close_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EncryptStreamBuf:: close_read() { if (_read_valid) { @@ -211,11 +201,9 @@ close_read() { } } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::open_write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EncryptStreamBuf:: open_write(ostream *dest, bool owns_dest, const string &password) { OpenSSL_add_all_algorithms(); @@ -225,7 +213,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) { _owns_dest = owns_dest; _write_valid = false; - const EVP_CIPHER *cipher = + const EVP_CIPHER *cipher = EVP_get_cipherbyname(_algorithm.c_str()); if (cipher == NULL) { @@ -235,14 +223,14 @@ open_write(ostream *dest, bool owns_dest, const string &password) { }; int nid = EVP_CIPHER_nid(cipher); - + int iv_length = EVP_CIPHER_iv_length(cipher); _write_block_size = EVP_CIPHER_block_size(cipher); unsigned char *iv = (unsigned char *)alloca(iv_length); - // Generate a random IV. It doesn't need to be cryptographically - // secure, just unique. + // Generate a random IV. It doesn't need to be cryptographically secure, + // just unique. RAND_pseudo_bytes(iv, iv_length); int result; @@ -300,26 +288,24 @@ open_write(ostream *dest, bool owns_dest, const string &password) { thread_consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::close_write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EncryptStreamBuf:: close_write() { if (_dest != (ostream *)NULL) { size_t n = pptr() - pbase(); write_chars(pbase(), n); pbump(-(int)n); - + if (_write_valid) { unsigned char *write_buffer = (unsigned char *)alloca(_write_block_size); int bytes_written = 0; EVP_EncryptFinal(&_write_ctx, write_buffer, &bytes_written); thread_consider_yield(); - + _dest->write((const char *)write_buffer, bytes_written); - + _write_valid = false; } @@ -331,12 +317,10 @@ close_write() { } } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int EncryptStreamBuf:: overflow(int ch) { size_t n = pptr() - pbase(); @@ -354,12 +338,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int EncryptStreamBuf:: sync() { if (_source != (istream *)NULL) { @@ -372,17 +354,15 @@ sync() { write_chars(pbase(), n); pbump(-(int)n); } - + _dest->flush(); return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int EncryptStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -412,11 +392,9 @@ underflow() { } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::read_chars -// Access: Private -// Description: Gets some characters from the source stream. -//////////////////////////////////////////////////////////////////// +/** + * Gets some characters from the source stream. + */ size_t EncryptStreamBuf:: read_chars(char *start, size_t length) { if (length == 0) { @@ -437,13 +415,13 @@ read_chars(char *start, size_t length) { unsigned char *read_buffer = (unsigned char *)alloca(max_read_buffer); int bytes_read = 0; - + do { - // Get more bytes from the stream. + // Get more bytes from the stream. if (!_read_valid) { return 0; } - + _source->read((char *)source_buffer, length); size_t source_length = _source->gcount(); @@ -478,35 +456,32 @@ read_chars(char *start, size_t length) { return bytes_read; } else { - // We have to save some of the returned bytes in the overflow - // buffer. + // We have to save some of the returned bytes in the overflow buffer. _in_read_overflow_buffer = bytes_read - length; nassertr(_in_read_overflow_buffer <= _read_block_size, 0); - memcpy(_read_overflow_buffer, read_buffer + length, + memcpy(_read_overflow_buffer, read_buffer + length, _in_read_overflow_buffer); memcpy(start, read_buffer, length); return length; } } -//////////////////////////////////////////////////////////////////// -// Function: EncryptStreamBuf::write_chars -// Access: Private -// Description: Sends some characters to the dest stream. -//////////////////////////////////////////////////////////////////// +/** + * Sends some characters to the dest stream. + */ void EncryptStreamBuf:: write_chars(const char *start, size_t length) { if (_write_valid && length != 0) { size_t max_write_buffer = length + _write_block_size; unsigned char *write_buffer = (unsigned char *)alloca(max_write_buffer); - + int bytes_written = 0; - int result = + int result = EVP_EncryptUpdate(&_write_ctx, write_buffer, &bytes_written, (unsigned char *)start, length); if (result <= 0) { - prc_cat.error() + prc_cat.error() << "Error encrypting stream.\n"; } thread_consider_yield(); diff --git a/dtool/src/prc/encryptStreamBuf.h b/dtool/src/prc/encryptStreamBuf.h index fe15da53f7..0542457267 100644 --- a/dtool/src/prc/encryptStreamBuf.h +++ b/dtool/src/prc/encryptStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: encryptStreamBuf.h -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encryptStreamBuf.h + * @author drose + * @date 2004-09-01 + */ #ifndef ENCRYPTSTREAMBUF_H #define ENCRYPTSTREAMBUF_H @@ -22,11 +21,9 @@ #include "openssl/evp.h" -//////////////////////////////////////////////////////////////////// -// Class : EncryptStreamBuf -// Description : The streambuf object that implements -// IDecompressStream and OCompressStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements IDecompressStream and OCompressStream. + */ class EXPCL_DTOOLCONFIG EncryptStreamBuf : public streambuf { public: EncryptStreamBuf(); @@ -66,7 +63,7 @@ private: string _algorithm; int _key_length; int _iteration_count; - + bool _read_valid; EVP_CIPHER_CTX _read_ctx; size_t _read_block_size; diff --git a/dtool/src/prc/littleEndian.h b/dtool/src/prc/littleEndian.h index ce2fda7139..40c6a4a5db 100644 --- a/dtool/src/prc/littleEndian.h +++ b/dtool/src/prc/littleEndian.h @@ -1,16 +1,15 @@ -// Filename: littleEndian.h -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file littleEndian.h + * @author drose + * @date 2000-02-09 + */ #ifndef LITTLEENDIAN_H #define LITTLEENDIAN_H @@ -21,13 +20,11 @@ #include "nativeNumericData.h" #include "reversedNumericData.h" -//////////////////////////////////////////////////////////////////// -// Class : LittleEndian -// Description : LittleEndian is a special class that automatically -// reverses the byte-order of numeric values for -// big-endian machines, and passes them through -// unchanged for little-endian machines. -//////////////////////////////////////////////////////////////////// +/** + * LittleEndian is a special class that automatically reverses the byte-order + * of numeric values for big-endian machines, and passes them through + * unchanged for little-endian machines. + */ #ifdef WORDS_BIGENDIAN typedef ReversedNumericData LittleEndian; diff --git a/dtool/src/prc/nativeNumericData.I b/dtool/src/prc/nativeNumericData.I index a59380344f..9a43707c9f 100644 --- a/dtool/src/prc/nativeNumericData.I +++ b/dtool/src/prc/nativeNumericData.I @@ -1,75 +1,59 @@ -// Filename: nativeNumericData.I -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeNumericData.I + * @author drose + * @date 2001-05-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NativeNumericData::Constructor -// Access: Public -// Description: This constructor accepts the address of a numeric -// variable, and its sizeof. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts the address of a numeric variable, and its sizeof. + */ INLINE NativeNumericData:: NativeNumericData(const void *data, size_t) : _source(data) { } -//////////////////////////////////////////////////////////////////// -// Function: NativeNumericData::Constructor -// Access: Public -// Description: This constructor accepts a pointer to a data array -// containing a packed numeric value, the offset within -// the array at which the numeric value starts, and the -// size of the numeric value. -// -// It is essential that the array not be destructed or -// modified as long as the NumericData object remains; -// it may just store a pointer into that string's -// internal buffer. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts a pointer to a data array containing a packed + * numeric value, the offset within the array at which the numeric value + * starts, and the size of the numeric value. + * + * It is essential that the array not be destructed or modified as long as the + * NumericData object remains; it may just store a pointer into that string's + * internal buffer. + */ INLINE NativeNumericData:: NativeNumericData(const void *data, size_t start, size_t) { _source = (void *)((const char *)data + start); } -//////////////////////////////////////////////////////////////////// -// Function: NativeNumericData::store_value -// Access: Public -// Description: Copies the data, with byte reversal if appropriate, -// into the indicated numeric variable, whose address -// and sizeof are given. -//////////////////////////////////////////////////////////////////// +/** + * Copies the data, with byte reversal if appropriate, into the indicated + * numeric variable, whose address and sizeof are given. + */ INLINE void NativeNumericData:: store_value(void *dest, size_t length) const { memcpy(dest, _source, length); } -//////////////////////////////////////////////////////////////////// -// Function: NativeNumericData::get_data -// Access: Public -// Description: Returns the pointer to the first byte of the data, -// either reversed or nonreversed, as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the first byte of the data, either reversed or + * nonreversed, as appropriate. + */ INLINE const void *NativeNumericData:: get_data() const { return _source; } -//////////////////////////////////////////////////////////////////// -// this is for a intel compile .. it is native format and it is -// readable off word boundries -//////////////////////////////////////////////////////////////////// +// this is for a intel compile .. it is native format and it is readable off +// word boundries inline void TS_SetVal1(const PN_int8 * src, PN_int8 *dst) { *dst = *src; @@ -116,4 +100,3 @@ template inline void TS_AddInteger(type val, char * _dst) #define TS_GetDirect(TT,SS) *((TT *)(SS)) #define TS_GetDirectIncPtr(TT,SS) { _ptr += sizeof(TT); return *((TT *)(SS -sizeof(TT))); } - diff --git a/dtool/src/prc/nativeNumericData.cxx b/dtool/src/prc/nativeNumericData.cxx index 7b1494c75f..f496e81c65 100644 --- a/dtool/src/prc/nativeNumericData.cxx +++ b/dtool/src/prc/nativeNumericData.cxx @@ -1,16 +1,14 @@ -// Filename: nativeNumericData.cxx -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeNumericData.cxx + * @author drose + * @date 2001-05-09 + */ #include "nativeNumericData.h" - diff --git a/dtool/src/prc/nativeNumericData.h b/dtool/src/prc/nativeNumericData.h index 95ba1c7a1a..db1e9e5b06 100644 --- a/dtool/src/prc/nativeNumericData.h +++ b/dtool/src/prc/nativeNumericData.h @@ -1,16 +1,15 @@ -// Filename: nativeNumericData.h -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeNumericData.h + * @author drose + * @date 2001-05-09 + */ #ifndef NATIVENUMERICDATA_H #define NATIVENUMERICDATA_H @@ -20,28 +19,23 @@ #include // for memcpy() -//////////////////////////////////////////////////////////////////// -// Class : NativeNumericData -// Description : NativeNumericData and ReversedNumericData work -// together to provide a sneaky interface for -// automatically byte-swapping numbers, when necessary, -// to transparency support big-endian and little-endian -// architectures. -// -// Both of these classes provide interfaces that accept -// a pointer to a numeric variable and the size of the -// number, and they can append that data to the end of a -// string, or memcpy it into another location. -// -// The difference is that NativeNumericData simply -// passes everything through unchanged, while -// ReversedNumericData always byte-swaps everything. -// Otherwise, they have the same interface. -// -// The transparent part comes from LittleEndian and -// BigEndian, which are typedeffed to be one of these or -// the other, according to the machine's architecture. -//////////////////////////////////////////////////////////////////// +/** + * NativeNumericData and ReversedNumericData work together to provide a sneaky + * interface for automatically byte-swapping numbers, when necessary, to + * transparency support big-endian and little-endian architectures. + * + * Both of these classes provide interfaces that accept a pointer to a numeric + * variable and the size of the number, and they can append that data to the + * end of a string, or memcpy it into another location. + * + * The difference is that NativeNumericData simply passes everything through + * unchanged, while ReversedNumericData always byte-swaps everything. + * Otherwise, they have the same interface. + * + * The transparent part comes from LittleEndian and BigEndian, which are + * typedeffed to be one of these or the other, according to the machine's + * architecture. + */ class EXPCL_DTOOLCONFIG NativeNumericData { public: INLINE NativeNumericData(const void *data, size_t length); diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index 9d100e5f54..741f3a0dd6 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -1,16 +1,15 @@ -// Filename: notify.cxx -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notify.cxx + * @author drose + * @date 2000-02-28 + */ #include "pnotify.h" #include "notifyCategory.h" @@ -32,11 +31,9 @@ Notify *Notify::_global_ptr = (Notify *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: Notify::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Notify:: Notify() { _ostream_ptr = &cerr; @@ -47,11 +44,9 @@ Notify() { _assert_failed = false; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Notify:: ~Notify() { if (_owns_ostream_ptr) { @@ -60,15 +55,12 @@ Notify:: delete _null_ostream_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::set_ostream_ptr -// Access: Public -// Description: Changes the ostream that all subsequent Notify -// messages will be written to. If the previous ostream -// was set with delete_later = true, this will delete -// the previous ostream. If ostream_ptr is NULL, this -// resets the default to cerr. -//////////////////////////////////////////////////////////////////// +/** + * Changes the ostream that all subsequent Notify messages will be written to. + * If the previous ostream was set with delete_later = true, this will delete + * the previous ostream. If ostream_ptr is NULL, this resets the default to + * cerr. + */ void Notify:: set_ostream_ptr(ostream *ostream_ptr, bool delete_later) { if (_owns_ostream_ptr && ostream_ptr != _ostream_ptr) { @@ -84,31 +76,24 @@ set_ostream_ptr(ostream *ostream_ptr, bool delete_later) { } } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_ostream_ptr -// Access: Public -// Description: Returns the system-wide ostream for all Notify -// messages. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system-wide ostream for all Notify messages. + */ ostream *Notify:: get_ostream_ptr() const { return _ostream_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_literal_flag -// Access: Public -// Description: Returns a flag that may be set on the Notify stream -// via setf() that, when set, enables "literal" mode, -// which means the Notify stream will not attempt to do -// any fancy formatting (like word-wrapping). -// -// Notify does not itself respect this flag; this is -// left up to the ostream that Notify writes to. Note -// that Notify just maps to cerr by default, in which -// case this does nothing. But the flag is available in -// case any extended types want to make use of it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a flag that may be set on the Notify stream via setf() that, when + * set, enables "literal" mode, which means the Notify stream will not attempt + * to do any fancy formatting (like word-wrapping). + * + * Notify does not itself respect this flag; this is left up to the ostream + * that Notify writes to. Note that Notify just maps to cerr by default, in + * which case this does nothing. But the flag is available in case any + * extended types want to make use of it. + */ ios_fmtflags Notify:: get_literal_flag() { static bool got_flag = false; @@ -118,8 +103,8 @@ get_literal_flag() { #ifndef PHAVE_IOSTREAM flag = ios::bitalloc(); #else - // We lost bitalloc in the new iostream? Ok, this feature will - // just be disabled for now. No big deal. + // We lost bitalloc in the new iostream? Ok, this feature will just be + // disabled for now. No big deal. flag = (ios_fmtflags)0; #endif got_flag = true; @@ -128,80 +113,62 @@ get_literal_flag() { return flag; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::set_assert_handler -// Access: Public -// Description: Sets a pointer to a C function that will be called -// when an assertion test fails. This function may -// decide what to do when that happens: it may choose to -// abort or return. If it returns, it should return -// true to indicate that the assertion should be -// respected (and the calling function should return out -// of its block of code), or false to indicate that the -// assertion should be completely ignored. -// -// If an assert handler is installed, it completely -// replaces the default behavior of nassertr() and -// nassertv(). -//////////////////////////////////////////////////////////////////// +/** + * Sets a pointer to a C function that will be called when an assertion test + * fails. This function may decide what to do when that happens: it may + * choose to abort or return. If it returns, it should return true to + * indicate that the assertion should be respected (and the calling function + * should return out of its block of code), or false to indicate that the + * assertion should be completely ignored. + * + * If an assert handler is installed, it completely replaces the default + * behavior of nassertr() and nassertv(). + */ void Notify:: set_assert_handler(Notify::AssertHandler *assert_handler) { _assert_handler = assert_handler; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::clear_assert_handler -// Access: Public -// Description: Removes the installed assert handler and restores -// default behavior of nassertr() and nassertv(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the installed assert handler and restores default behavior of + * nassertr() and nassertv(). + */ void Notify:: clear_assert_handler() { _assert_handler = (AssertHandler *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::has_assert_handler -// Access: Public -// Description: Returns true if a user assert handler has been -// installed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a user assert handler has been installed, false otherwise. + */ bool Notify:: has_assert_handler() const { return (_assert_handler != (AssertHandler *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_assert_handler -// Access: Public -// Description: Returns a pointer to the user-installed assert -// handler, if one was installed, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the user-installed assert handler, if one was + * installed, or NULL otherwise. + */ Notify::AssertHandler *Notify:: get_assert_handler() const { return _assert_handler; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_top_category -// Access: Public -// Description: Returns the topmost Category in the hierarchy. This -// may be used to traverse the hierarchy of available -// Categories. -//////////////////////////////////////////////////////////////////// +/** + * Returns the topmost Category in the hierarchy. This may be used to + * traverse the hierarchy of available Categories. + */ NotifyCategory *Notify:: get_top_category() { return get_category(string()); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_category -// Access: Public -// Description: Finds or creates a new Category given the basename of -// the category and its parent in the category -// hierarchy. The parent pointer may be NULL to -// indicate this is a top-level Category. -//////////////////////////////////////////////////////////////////// +/** + * Finds or creates a new Category given the basename of the category and its + * parent in the category hierarchy. The parent pointer may be NULL to + * indicate this is a top-level Category. + */ NotifyCategory *Notify:: get_category(const string &basename, NotifyCategory *parent_category) { // The string should not contain colons. @@ -211,10 +178,9 @@ get_category(const string &basename, NotifyCategory *parent_category) { if (parent_category != (NotifyCategory *)NULL) { fullname = parent_category->get_fullname() + ":" + basename; } else { - // The parent_category is NULL. If basename is empty, that means - // we refer to the very top-level category (with an empty - // fullname); otherwise, it's a new category just below that top - // level. + // The parent_category is NULL. If basename is empty, that means we refer + // to the very top-level category (with an empty fullname); otherwise, + // it's a new category just below that top level. if (!basename.empty()) { parent_category = get_top_category(); fullname = ":" + basename; @@ -228,41 +194,32 @@ get_category(const string &basename, NotifyCategory *parent_category) { NotifyCategory *&category = (*result.first).second; if (inserted) { - // If we just inserted a new record, then we have to create a new - // Category pointer. Otherwise, there was already one created - // from before. + // If we just inserted a new record, then we have to create a new Category + // pointer. Otherwise, there was already one created from before. category = new NotifyCategory(fullname, basename, parent_category); } return category; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_category -// Access: Public -// Description: Finds or creates a new Category given the basename of -// the category and the fullname of its parent. This is -// another way to create a category when you don't have -// a pointer to its parent handy, but you know the name -// of its parent. If the parent Category does not -// already exist, it will be created. -//////////////////////////////////////////////////////////////////// +/** + * Finds or creates a new Category given the basename of the category and the + * fullname of its parent. This is another way to create a category when you + * don't have a pointer to its parent handy, but you know the name of its + * parent. If the parent Category does not already exist, it will be created. + */ NotifyCategory *Notify:: get_category(const string &basename, const string &parent_fullname) { return get_category(basename, get_category(parent_fullname)); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_category -// Access: Public -// Description: Finds or creates a new Category given the fullname of -// the Category. This name should be a sequence of -// colon-separated names of parent Categories, ending in -// the basename of this Category, -// e.g. display:glxdisplay. This is a shorthand way to -// define a Category when a pointer to its parent is not -// handy. -//////////////////////////////////////////////////////////////////// +/** + * Finds or creates a new Category given the fullname of the Category. This + * name should be a sequence of colon-separated names of parent Categories, + * ending in the basename of this Category, e.g. display:glxdisplay. This is + * a shorthand way to define a Category when a pointer to its parent is not + * handy. + */ NotifyCategory *Notify:: get_category(const string &fullname) { Categories::const_iterator ci; @@ -271,8 +228,8 @@ get_category(const string &fullname) { return (*ci).second; } - // No such Category; create one. First identify the parent name, - // based on the rightmost colon. + // No such Category; create one. First identify the parent name, based on + // the rightmost colon. NotifyCategory *parent_category = (NotifyCategory *)NULL; string basename = fullname; @@ -289,50 +246,39 @@ get_category(const string &fullname) { return get_category(basename, parent_category); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::out -// Access: Public, Static -// Description: A convenient way to get the ostream that should be -// written to for a Notify-type message. Also see -// Category::out() for a message that is specific to a -// particular Category. -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to get the ostream that should be written to for a Notify- + * type message. Also see Category::out() for a message that is specific to a + * particular Category. + */ ostream &Notify:: out() { return *(ptr()->_ostream_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::null -// Access: Public, Static -// Description: A convenient way to get an ostream that doesn't do -// anything. Returned by Category::out() when a -// particular Category and/or Severity is disabled. -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to get an ostream that doesn't do anything. Returned by + * Category::out() when a particular Category and/or Severity is disabled. + */ ostream &Notify:: null() { return *(ptr()->_null_ostream_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::write_string -// Access: Public, Static -// Description: A convenient way for scripting languages, which may -// know nothing about ostreams, to write to Notify. -// This writes a single string, followed by an implicit -// newline, to the Notify output stream. -//////////////////////////////////////////////////////////////////// +/** + * A convenient way for scripting languages, which may know nothing about + * ostreams, to write to Notify. This writes a single string, followed by an + * implicit newline, to the Notify output stream. + */ void Notify:: write_string(const string &str) { out() << str << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::ptr -// Access: Public, Static -// Description: Returns the pointer to the global Notify object. -// There is only one of these in the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the global Notify object. There is only one of + * these in the world. + */ Notify *Notify:: ptr() { if (_global_ptr == (Notify *)NULL) { @@ -342,40 +288,32 @@ ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::assert_failure -// Access: Public -// Description: This function is not intended to be called directly -// by user code. It's called from the nassertr() and -// assertv() macros when an assertion test fails; it -// handles the job of printing the warning message and -// deciding what to do about it. -// -// If this function returns true, the calling function -// should return out of its function; if it returns -// false, the calling function should ignore the -// assertion. -//////////////////////////////////////////////////////////////////// +/** + * This function is not intended to be called directly by user code. It's + * called from the nassertr() and assertv() macros when an assertion test + * fails; it handles the job of printing the warning message and deciding what + * to do about it. + * + * If this function returns true, the calling function should return out of + * its function; if it returns false, the calling function should ignore the + * assertion. + */ bool Notify:: assert_failure(const string &expression, int line, const char *source_file) { return assert_failure(expression.c_str(), line, source_file); } -//////////////////////////////////////////////////////////////////// -// Function: Notify::assert_failure -// Access: Public -// Description: This function is not intended to be called directly -// by user code. It's called from the nassertr() and -// assertv() macros when an assertion test fails; it -// handles the job of printing the warning message and -// deciding what to do about it. -// -// If this function returns true, the calling function -// should return out of its function; if it returns -// false, the calling function should ignore the -// assertion. -//////////////////////////////////////////////////////////////////// +/** + * This function is not intended to be called directly by user code. It's + * called from the nassertr() and assertv() macros when an assertion test + * fails; it handles the job of printing the warning message and deciding what + * to do about it. + * + * If this function returns true, the calling function should return out of + * its function; if it returns false, the calling function should ignore the + * assertion. + */ bool Notify:: assert_failure(const char *expression, int line, const char *source_file) { @@ -385,8 +323,8 @@ assert_failure(const char *expression, int line, string message = message_str.str(); if (!_assert_failed) { - // We only save the first assertion failure message, as this is - // usually the most meaningful when several occur in a row. + // We only save the first assertion failure message, as this is usually + // the most meaningful when several occur in a row. _assert_failed = true; _assert_error_message = message; } @@ -401,24 +339,23 @@ assert_failure(const char *expression, int line, nout << "Assertion failed: " << message << "\n"; #endif - // This is redefined here, shadowing the defining in config_prc.h, - // so we can guarantee it has already been constructed. + // This is redefined here, shadowing the defining in config_prc.h, so we can + // guarantee it has already been constructed. ALIGN_16BYTE ConfigVariableBool assert_abort("assert-abort", false); if (assert_abort) { #ifdef WIN32 - // How to trigger an exception in VC++ that offers to take us into - // the debugger? abort() doesn't do it. We used to be able to - // assert(false), but in VC++ 7 that just throws an exception, and - // an uncaught exception just exits, without offering to open the - // debugger. + // How to trigger an exception in VC++ that offers to take us into the + // debugger? abort() doesn't do it. We used to be able to assert(false), + // but in VC++ 7 that just throws an exception, and an uncaught exception + // just exits, without offering to open the debugger. - // DebugBreak() seems to be provided for this purpose, but it - // doesn't seem to work properly either, since we don't seem to - // get a reliable stack trace. + // DebugBreak() seems to be provided for this purpose, but it doesn't seem + // to work properly either, since we don't seem to get a reliable stack + // trace. - // The old reliable int 3 works (at least on an Intel platform) if - // you are already running within a debugger. But it doesn't - // offer to bring up a debugger otherwise. + // The old reliable int 3 works (at least on an Intel platform) if you are + // already running within a debugger. But it doesn't offer to bring up a + // debugger otherwise. // So we'll force a segfault, which works every time. int *ptr = (int *)NULL; @@ -432,17 +369,14 @@ assert_failure(const char *expression, int line, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::string_severity -// Access: Public -// Description: Given a string, one of "debug", "info", "warning", -// etc., return the corresponding Severity level, or -// NS_unspecified if none of the strings matches. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, one of "debug", "info", "warning", etc., return the + * corresponding Severity level, or NS_unspecified if none of the strings + * matches. + */ NotifySeverity Notify:: string_severity(const string &str) { - // Convert the string to lowercase for a case-insensitive - // comparison. + // Convert the string to lowercase for a case-insensitive comparison. string lstring; for (string::const_iterator si = str.begin(); si != str.end(); @@ -473,15 +407,11 @@ string_severity(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: Notify::config_initialized -// Access: Public -// Description: Intended to be called only by Config, this is a -// callback that indicates to Notify when Config has -// done initializing and Notify can safely set up some -// internal state variables that depend on Config -// variables. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called only by Config, this is a callback that indicates to + * Notify when Config has done initializing and Notify can safely set up some + * internal state variables that depend on Config variables. + */ void Notify:: config_initialized() { static bool already_initialized = false; @@ -508,9 +438,8 @@ config_initialized() { Filename filename = notify_output; filename.set_text(); #ifdef BUILD_IPHONE - // On the iPhone, route everything through cerr, and then send - // cerr to the log file, since we can't get the cerr output - // otherwise. + // On the iPhone, route everything through cerr, and then send cerr to + // the log file, since we can't get the cerr output otherwise. string os_specific = filename.to_os_specific(); int logfile_fd = open(os_specific.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0666); if (logfile_fd < 0) { diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 579c492e93..a485447dcc 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -1,43 +1,35 @@ -// Filename: notifyCategory.I -// Created by: drose (29Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifyCategory.I + * @author drose + * @date 2000-02-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_fullname -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string NotifyCategory:: get_fullname() const { return _fullname; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_basename -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string NotifyCategory:: get_basename() const { return _basename; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_severity -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NotifySeverity NotifyCategory:: get_severity() const { TAU_PROFILE("NotifyCategory NotifyCategory::get_severity() const", " ", TAU_USER); @@ -47,13 +39,10 @@ get_severity() const { return _severity_cache; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::set_severity -// Access: Public -// Description: Sets the severity level of messages that will be -// reported from this Category. This allows any message -// of this severity level or higher. -//////////////////////////////////////////////////////////////////// +/** + * Sets the severity level of messages that will be reported from this + * Category. This allows any message of this severity level or higher. + */ INLINE void NotifyCategory:: set_severity(NotifySeverity severity) { #if defined(NOTIFY_DEBUG) @@ -65,12 +54,10 @@ set_severity(NotifySeverity severity) { invalidate_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_on -// Access: Public -// Description: Returns true if messages of the indicated severity -// level ought to be reported for this Category. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if messages of the indicated severity level ought to be + * reported for this Category. + */ INLINE bool NotifyCategory:: is_on(NotifySeverity severity) const { TAU_PROFILE("bool NotifyCategory::is_on(NotifySeverity) const", " ", TAU_USER); @@ -78,98 +65,78 @@ is_on(NotifySeverity severity) const { } #if defined(NOTIFY_DEBUG) || defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_spam -// Access: Public -// Description: A shorthand way to write is_on(NS_spam). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_spam). + */ INLINE bool NotifyCategory:: is_spam() const { return is_on(NS_spam); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_debug -// Access: Public -// Description: A shorthand way to write is_on(NS_debug). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_debug). + */ INLINE bool NotifyCategory:: is_debug() const { return is_on(NS_debug); } #else -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_spam -// Access: Public, Static -// Description: When NOTIFY_DEBUG is not defined, the categories are -// never set to "spam" or "debug" severities, and these -// methods are redefined to be static to make it more -// obvious to the compiler. -//////////////////////////////////////////////////////////////////// +/** + * When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or + * "debug" severities, and these methods are redefined to be static to make it + * more obvious to the compiler. + */ CONSTEXPR bool NotifyCategory:: is_spam() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_debug -// Access: Public -// Description: When NOTIFY_DEBUG is not defined, the categories are -// never set to "spam" or "debug" severities, and these -// methods are redefined to be static to make it more -// obvious to the compiler. -//////////////////////////////////////////////////////////////////// +/** + * When NOTIFY_DEBUG is not defined, the categories are never set to "spam" or + * "debug" severities, and these methods are redefined to be static to make it + * more obvious to the compiler. + */ CONSTEXPR bool NotifyCategory:: is_debug() { return false; } #endif -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_info -// Access: Public -// Description: A shorthand way to write is_on(NS_info). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_info). + */ INLINE bool NotifyCategory:: is_info() const { return is_on(NS_info); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_warning -// Access: Public -// Description: A shorthand way to write is_on(NS_warning). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_warning). + */ INLINE bool NotifyCategory:: is_warning() const { return is_on(NS_warning); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_error -// Access: Public -// Description: A shorthand way to write is_on(NS_error). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_error). + */ INLINE bool NotifyCategory:: is_error() const { return is_on(NS_error); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::is_fatal -// Access: Public -// Description: A shorthand way to write is_on(NS_fatal). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write is_on(NS_fatal). + */ INLINE bool NotifyCategory:: is_fatal() const { return is_on(NS_fatal); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::spam -// Access: Public -// Description: A shorthand way to write out(NS_spam). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_spam). + */ INLINE ostream &NotifyCategory:: spam(bool prefix) const { #if defined(NOTIFY_DEBUG) @@ -179,11 +146,9 @@ spam(bool prefix) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::debug -// Access: Public -// Description: A shorthand way to write out(NS_debug). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_debug). + */ INLINE ostream &NotifyCategory:: debug(bool prefix) const { #if defined(NOTIFY_DEBUG) @@ -193,41 +158,33 @@ debug(bool prefix) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::info -// Access: Public -// Description: A shorthand way to write out(NS_info). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_info). + */ INLINE ostream &NotifyCategory:: info(bool prefix) const { return out(NS_info, prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::warning -// Access: Public -// Description: A shorthand way to write out(NS_warning). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_warning). + */ INLINE ostream &NotifyCategory:: warning(bool prefix) const { return out(NS_warning, prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::error -// Access: Public -// Description: A shorthand way to write out(NS_error). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_error). + */ INLINE ostream &NotifyCategory:: error(bool prefix) const { return out(NS_error, prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::fatal -// Access: Public -// Description: A shorthand way to write out(NS_fatal). -//////////////////////////////////////////////////////////////////// +/** + * A shorthand way to write out(NS_fatal). + */ INLINE ostream &NotifyCategory:: fatal(bool prefix) const { return out(NS_fatal, prefix); diff --git a/dtool/src/prc/notifyCategory.cxx b/dtool/src/prc/notifyCategory.cxx index 5d26421ec0..e44b33dffa 100644 --- a/dtool/src/prc/notifyCategory.cxx +++ b/dtool/src/prc/notifyCategory.cxx @@ -1,16 +1,15 @@ -// Filename: notifyCategory.cxx -// Created by: drose (29Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifyCategory.cxx + * @author drose + * @date 2000-02-29 + */ #include "notifyCategory.h" #include "pnotify.h" @@ -28,19 +27,17 @@ long NotifyCategory::_server_delta = 0; -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NotifyCategory:: NotifyCategory(const string &fullname, const string &basename, NotifyCategory *parent) : _fullname(fullname), _basename(basename), _parent(parent), - _severity(get_config_name(), NS_unspecified, - "Default severity of this notify category", + _severity(get_config_name(), NS_unspecified, + "Default severity of this notify category", ConfigVariable::F_dynamic), _local_modified(initial_invalid_cache()) { @@ -52,24 +49,20 @@ NotifyCategory(const string &fullname, const string &basename, nassertv(_parent != (NotifyCategory *)NULL || _fullname.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::out -// Access: Published -// Description: Begins a new message to this Category at the -// indicated severity level. If the indicated severity -// level is enabled, this writes a prefixing string to -// the Notify::out() stream and returns that. If the -// severity level is disabled, this returns -// Notify::null(). -//////////////////////////////////////////////////////////////////// +/** + * Begins a new message to this Category at the indicated severity level. If + * the indicated severity level is enabled, this writes a prefixing string to + * the Notify::out() stream and returns that. If the severity level is + * disabled, this returns Notify::null(). + */ ostream &NotifyCategory:: out(NotifySeverity severity, bool prefix) const { if (is_on(severity)) { #ifdef ANDROID - // Android redirects stdio and stderr to /dev/null, - // but does provide its own logging system. We use a special - // type of stream that redirects it to Android's log system. + // Android redirects stdio and stderr to devnull, but does provide its own + // logging system. We use a special type of stream that redirects it to + // Android's log system. if (prefix) { return AndroidLogStream::out(severity) << *this << ": "; } else { @@ -99,11 +92,10 @@ out(NotifySeverity severity, bool prefix) const { #endif } else if (severity <= NS_debug && get_check_debug_notify_protect()) { - // Someone issued a debug Notify output statement without - // protecting it within an if statement. This can cause a - // significant runtime performance hit, since it forces the - // iostream library to fully format its output, and then discards - // the output. + // Someone issued a debug Notify output statement without protecting it + // within an if statement. This can cause a significant runtime + // performance hit, since it forces the iostream library to fully format + // its output, and then discards the output. nout << " **Not protected!** "; if (prefix) { nout << *this << "(" << severity << "): "; @@ -119,48 +111,37 @@ out(NotifySeverity severity, bool prefix) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_num_children -// Access: Published -// Description: Returns the number of child Categories of this -// particular Category. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child Categories of this particular Category. + */ size_t NotifyCategory:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_child -// Access: Published -// Description: Returns the nth child Category of this particular -// Category. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child Category of this particular Category. + */ NotifyCategory *NotifyCategory:: get_child(size_t i) const { assert(i < _children.size()); return _children[i]; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::set_server_delta -// Access: Published, Static -// Description: Sets a global delta (in seconds) between the local -// time and the server's time, for the purpose of -// synchronizing the time stamps in the log messages of -// the client with that of a known server. -//////////////////////////////////////////////////////////////////// +/** + * Sets a global delta (in seconds) between the local time and the server's + * time, for the purpose of synchronizing the time stamps in the log messages + * of the client with that of a known server. + */ void NotifyCategory:: set_server_delta(long delta) { _server_delta = delta; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_config_name -// Access: Private -// Description: Returns the name of the config variable that controls -// this category. This is called at construction time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the config variable that controls this category. This + * is called at construction time. + */ string NotifyCategory:: get_config_name() const { string config_name; @@ -174,16 +155,13 @@ get_config_name() const { return config_name; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::update_severity_cache -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NotifyCategory:: update_severity_cache() { if (_severity == NS_unspecified) { - // If we don't have an explicit severity level, inherit our - // parent's. + // If we don't have an explicit severity level, inherit our parent's. if (_severity.has_value()) { nout << "Invalid severity name for " << _severity.get_name() << ": " << _severity.get_string_value() << "\n"; @@ -198,18 +176,14 @@ update_severity_cache() { } else { _severity_cache = _severity; } - mark_cache_valid(_local_modified); + mark_cache_valid(_local_modified); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_notify_timestamp -// Access: Private, Static -// Description: Returns the value of the notify-timestamp -// ConfigVariable. This is defined using a method -// accessor rather than a static ConfigVariableBool, to -// protect against the variable needing to be accessed -// at static init time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the notify-timestamp ConfigVariable. This is defined + * using a method accessor rather than a static ConfigVariableBool, to protect + * against the variable needing to be accessed at static init time. + */ bool NotifyCategory:: get_notify_timestamp() { static ConfigVariableBool *notify_timestamp = NULL; @@ -221,15 +195,11 @@ get_notify_timestamp() { return *notify_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategory::get_check_debug_notify_protect -// Access: Private, Static -// Description: Returns the value of the check-debug-notify-protect -// ConfigVariable. This is defined using a method -// accessor rather than a static ConfigVariableBool, to -// protect against the variable needing to be accessed -// at static init time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the check-debug-notify-protect ConfigVariable. This + * is defined using a method accessor rather than a static ConfigVariableBool, + * to protect against the variable needing to be accessed at static init time. + */ bool NotifyCategory:: get_check_debug_notify_protect() { static ConfigVariableBool *check_debug_notify_protect = NULL; diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 2896a8caa2..fe9a7255e6 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -1,16 +1,15 @@ -// Filename: notifyCategory.h -// Created by: drose (29Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifyCategory.h + * @author drose + * @date 2000-02-29 + */ #ifndef NOTIFYCATEGORY_H #define NOTIFYCATEGORY_H @@ -24,15 +23,12 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : NotifyCategory -// Description : A particular category of error messages. Typically -// there will be one of these per package, so that we -// can turn on or off error messages at least at a -// package level; further nested categories can be -// created within a package if a finer grain of control -// is required. -//////////////////////////////////////////////////////////////////// +/** + * A particular category of error messages. Typically there will be one of + * these per package, so that we can turn on or off error messages at least at + * a package level; further nested categories can be created within a package + * if a finer grain of control is required. + */ class EXPCL_DTOOLCONFIG NotifyCategory : public MemoryBase, public ConfigFlags { private: NotifyCategory(const string &fullname, const string &basename, @@ -49,12 +45,12 @@ PUBLISHED: INLINE bool is_on(NotifySeverity severity) const; - // When NOTIFY_DEBUG is not defined, the categories will never be - // set to "spam" or "debug" severities, and these methods are - // redefined to be static to make it more obvious to the compiler. - // However, we still want to present a consistent interface to our - // scripting language, so during the interrogate pass (that is, when - // CPPPARSER is defined), we still pretend they're nonstatic. + // When NOTIFY_DEBUG is not defined, the categories will never be set to + // "spam" or "debug" severities, and these methods are redefined to be + // static to make it more obvious to the compiler. However, we still want + // to present a consistent interface to our scripting language, so during + // the interrogate pass (that is, when CPPPARSER is defined), we still + // pretend they're nonstatic. #if defined(NOTIFY_DEBUG) || defined(CPPPARSER) INLINE bool is_spam() const; INLINE bool is_debug() const; diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index 10b956f763..08c253f081 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -1,23 +1,20 @@ -// Filename: notifyCategoryProxy.I -// Created by: drose (04Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifyCategoryProxy.I + * @author drose + * @date 2000-03-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::init() -// Access: Public -// Description: Initializes the proxy object by calling -// get_category() on the template class. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the proxy object by calling get_category() on the template + * class. + */ template NotifyCategory *NotifyCategoryProxy:: init() { @@ -27,16 +24,12 @@ init() { return _ptr; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::get_unsafe_ptr() -// Access: Public -// Description: Returns a pointer which is assumed to have been -// already initialized. This function should only be -// used in functions that will certainly not execute at -// static init time. All of the category methods that -// are accessed via the dot operator, e.g. proxy.info(), -// use this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer which is assumed to have been already initialized. This + * function should only be used in functions that will certainly not execute + * at static init time. All of the category methods that are accessed via the + * dot operator, e.g. proxy.info(), use this method. + */ template INLINE NotifyCategory *NotifyCategoryProxy:: get_unsafe_ptr() { @@ -47,39 +40,31 @@ get_unsafe_ptr() { return _ptr; } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::get_safe_ptr() -// Access: Public -// Description: Returns a pointer which is *not* assumed to have been -// already initialized; if necessary, it will be -// initialized before it returns. This function may be -// used in functions that might execute at static init -// time. All of the category methods that are accessed -// via the arrow operator, e.g. proxy->info(), use this -// method. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer which is *not* assumed to have been already initialized; + * if necessary, it will be initialized before it returns. This function may + * be used in functions that might execute at static init time. All of the + * category methods that are accessed via the arrow operator, e.g. + * proxy->info(), use this method. + */ template INLINE NotifyCategory *NotifyCategoryProxy:: get_safe_ptr() { return init(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_on -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool NotifyCategoryProxy:: is_on(NotifySeverity severity) { return get_unsafe_ptr()->is_on(severity); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_spam -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ #ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: @@ -94,11 +79,9 @@ is_spam() { } #endif -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_debug -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ #ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: @@ -113,164 +96,133 @@ is_debug() { } #endif -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool NotifyCategoryProxy:: is_info() { return get_unsafe_ptr()->is_info(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_warning -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool NotifyCategoryProxy:: is_warning() { return get_unsafe_ptr()->is_warning(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_error -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool NotifyCategoryProxy:: is_error() { return get_unsafe_ptr()->is_error(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::is_fatal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool NotifyCategoryProxy:: is_fatal() { return get_unsafe_ptr()->is_fatal(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::out -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: out(NotifySeverity severity, bool prefix) { return get_unsafe_ptr()->out(severity, prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::spam -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: spam(bool prefix) { return get_unsafe_ptr()->spam(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::debug -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: debug(bool prefix) { return get_unsafe_ptr()->debug(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: info(bool prefix) { return get_unsafe_ptr()->info(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::warning -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: warning(bool prefix) { return get_unsafe_ptr()->warning(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::error -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: error(bool prefix) { return get_unsafe_ptr()->error(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::fatal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ostream &NotifyCategoryProxy:: fatal(bool prefix) { return get_unsafe_ptr()->fatal(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::Member Access Operator -// Access: Public -// Description: This magic operator function defines the syntax -// proxy->info(), etc., for all of the methods that are -// defined for NotifyCategory. It's designed to vector -// through get_safe_ptr(), so this syntax is safe for -// functions that may execute at static init time. -//////////////////////////////////////////////////////////////////// +/** + * This magic operator function defines the syntax proxy->info(), etc., for + * all of the methods that are defined for NotifyCategory. It's designed to + * vector through get_safe_ptr(), so this syntax is safe for functions that + * may execute at static init time. + */ template INLINE NotifyCategory *NotifyCategoryProxy:: operator -> () { return get_safe_ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::Dereference Operator -// Access: Public -// Description: This operator handles the case of dereferencing the -// proxy object as if it were a pointer, -// e.g. (*proxy).info(). It works the same way as the -// -> operator, above. -//////////////////////////////////////////////////////////////////// +/** + * This operator handles the case of dereferencing the proxy object as if it + * were a pointer, e.g. (*proxy).info(). It works the same way as the -> + * operator, above. + */ template INLINE NotifyCategory &NotifyCategoryProxy:: operator * () { return *get_safe_ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: NotifyCategoryProxy::Typecast Operator -// Access: Public -// Description: This operator handles the case of passing the -// proxy object to a function that accepts a -// NotifyCategory pointer. It works the same way as the -// -> and * operators, above. -//////////////////////////////////////////////////////////////////// +/** + * This operator handles the case of passing the proxy object to a function + * that accepts a NotifyCategory pointer. It works the same way as the -> and + * * operators, above. + */ template INLINE NotifyCategoryProxy:: operator NotifyCategory * () { diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index de9ada490a..653da558de 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -1,16 +1,15 @@ -// Filename: notifyCategoryProxy.h -// Created by: drose (04Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifyCategoryProxy.h + * @author drose + * @date 2000-03-04 + */ #ifndef NOTIFYCATEGORYPROXY_H #define NOTIFYCATEGORYPROXY_H @@ -21,63 +20,54 @@ #include "notifySeverity.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : NotifyCategoryProxy -// Description : A handy wrapper around a NotifyCategory pointer. -// This wrapper pretends to be a NotifyCategory object -// itself, except that it is capable of initializing its -// pointer if it is NULL. -// -// The advantage to this over a normal pointer is that -// it can be used in functions that run at static init -// time, without worrying about ordering issues among -// static init routines. If the pointer hasn't been -// initialized yet, no sweat; it can initialize itself. -// -// This must be a template class so it can do this -// magic; it templates on a class with a static method -// called get_category() that returns a new pointer to -// the NotifyCategory. This way the compiler can -// generate correct static-init-independent code to -// initialize the proxy. -// -// In general, if the proxy object is treated as if it -// were itself a NotifyCategory object, then it doesn't -// check whether its category is initialized, and so may -// not be run at static init time. That is, you may -// call proxy.info(), but only when you are not running -// at static init time. This is an optimization so you -// can avoid this unnecessary check when you know (as in -// most cases) the code does not run at static init. -// -// On the other hand, if the proxy object is treated as -// if it were a *pointer* to a NotifyCategory object, -// then it *does* check whether its category is -// initialized; you may safely use it in this way at -// static init time. Thus, you may call proxy->info() -// safely whenever you like. -//////////////////////////////////////////////////////////////////// +/** + * A handy wrapper around a NotifyCategory pointer. This wrapper pretends to + * be a NotifyCategory object itself, except that it is capable of + * initializing its pointer if it is NULL. + * + * The advantage to this over a normal pointer is that it can be used in + * functions that run at static init time, without worrying about ordering + * issues among static init routines. If the pointer hasn't been initialized + * yet, no sweat; it can initialize itself. + * + * This must be a template class so it can do this magic; it templates on a + * class with a static method called get_category() that returns a new pointer + * to the NotifyCategory. This way the compiler can generate correct static- + * init-independent code to initialize the proxy. + * + * In general, if the proxy object is treated as if it were itself a + * NotifyCategory object, then it doesn't check whether its category is + * initialized, and so may not be run at static init time. That is, you may + * call proxy.info(), but only when you are not running at static init time. + * This is an optimization so you can avoid this unnecessary check when you + * know (as in most cases) the code does not run at static init. + * + * On the other hand, if the proxy object is treated as if it were a *pointer* + * to a NotifyCategory object, then it *does* check whether its category is + * initialized; you may safely use it in this way at static init time. Thus, + * you may call proxy->info() safely whenever you like. + */ template class NotifyCategoryProxy { public: - // This should be set to be called at static init time; it - // initializes the pointer if it is not already. + // This should be set to be called at static init time; it initializes the + // pointer if it is not already. NotifyCategory *init(); - // You don't normally need to call these directly, but they're here - // anyway. get_unsafe_ptr() assumes the pointer has been - // initialized; it should be called only when you know static init - // has completed (i.e. in any function that is not executing at - // static init time). get_safe_ptr() should be called when it is - // possible that static init has not yet completed (i.e. in a - // function that might execute at static init time); it calls init() - // first. +/* + * You don't normally need to call these directly, but they're here anyway. + * get_unsafe_ptr() assumes the pointer has been initialized; it should be + * called only when you know static init has completed (i.e. in any function + * that is not executing at static init time). get_safe_ptr() should be + * called when it is possible that static init has not yet completed (i.e. in + * a function that might execute at static init time); it calls init() first. + */ INLINE NotifyCategory *get_unsafe_ptr(); INLINE NotifyCategory *get_safe_ptr(); - // The following functions, which may be accessed using the - // proxy.function() syntax, call get_unsafe_ptr(). They should be - // used only in non-static-init functions. + // The following functions, which may be accessed using the proxy.function() + // syntax, call get_unsafe_ptr(). They should be used only in non-static- + // init functions. INLINE bool is_on(NotifySeverity severity); @@ -101,9 +91,9 @@ public: INLINE ostream &error(bool prefix = true); INLINE ostream &fatal(bool prefix = true); - // The same functions as above, when accessed using - // proxy->function() syntax, call get_safe_ptr(). These can be used - // safely either in static-init or non-static-init functions. + // The same functions as above, when accessed using proxy->function() + // syntax, call get_safe_ptr(). These can be used safely either in static- + // init or non-static-init functions. INLINE NotifyCategory *operator -> (); INLINE NotifyCategory &operator * (); INLINE operator NotifyCategory * (); @@ -120,10 +110,9 @@ INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &pro // Finally, here is a set of handy macros to define and reference a // NotifyCategoryProxy object in each package. -// Following the config convention, this macro defines an external -// reference to a suitable NotifyCategoryProxy object; it should -// appear in the config_*.h file. The proxy object will be named -// basename_cat. +// Following the config convention, this macro defines an external reference +// to a suitable NotifyCategoryProxy object; it should appear in the +// config_*.h file. The proxy object will be named basename_cat. #ifdef CPPPARSER #define NotifyCategoryDecl(basename, expcl, exptp) @@ -149,11 +138,11 @@ INLINE ostream &operator << (ostream &out, NotifyCategoryProxy &pro }; \ extern NotifyCategoryProxy basename ## _cat; -// This macro defines the actual declaration of the -// NotifyCategoryProxy object defined above; it should appear in the -// config_*.C file. In this macro, parent_category may either be the -// NotifyCategoryProxy object of the parent category -// (e.g. parent_cat), or it may be the quoted fullname of the parent. +// This macro defines the actual declaration of the NotifyCategoryProxy object +// defined above; it should appear in the config_*.C file. In this macro, +// parent_category may either be the NotifyCategoryProxy object of the parent +// category (e.g. parent_cat), or it may be the quoted fullname of the +// parent. #ifdef CPPPARSER #define NotifyCategoryDefName(basename, actual_name, parent_category) diff --git a/dtool/src/prc/notifySeverity.cxx b/dtool/src/prc/notifySeverity.cxx index d8b3d02eef..0ee750e879 100644 --- a/dtool/src/prc/notifySeverity.cxx +++ b/dtool/src/prc/notifySeverity.cxx @@ -1,16 +1,15 @@ -// Filename: notifySeverity.cxx -// Created by: drose (29Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifySeverity.cxx + * @author drose + * @date 2000-02-29 + */ #include "notifySeverity.h" #include "pnotify.h" diff --git a/dtool/src/prc/notifySeverity.h b/dtool/src/prc/notifySeverity.h index 7a626c8c78..8750602d73 100644 --- a/dtool/src/prc/notifySeverity.h +++ b/dtool/src/prc/notifySeverity.h @@ -1,16 +1,15 @@ -// Filename: notifySeverity.h -// Created by: drose (29Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file notifySeverity.h + * @author drose + * @date 2000-02-29 + */ #ifndef NOTIFYSEVERITY_H #define NOTIFYSEVERITY_H diff --git a/dtool/src/prc/pnotify.I b/dtool/src/prc/pnotify.I index 287a5495f4..1cdea86f2d 100644 --- a/dtool/src/prc/pnotify.I +++ b/dtool/src/prc/pnotify.I @@ -1,60 +1,48 @@ -// Filename: pnotify.I -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnotify.I + * @author drose + * @date 2000-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Notify::has_assert_failed -// Access: Public -// Description: Returns true if an assertion test has failed (and not -// been ignored) since the last call to -// clear_assert_failed(). -// -// When an assertion test fails, the assert handler -// may decide either to abort, return, or ignore the -// assertion. Naturally, if it decides to abort, this -// flag is irrelevant. If it chooses to ignore the -// assertion, the flag is not set. However, if the -// assert handler chooses to return out of the -// function (the normal case), it will also set this -// flag to indicate that an assertion failure has -// occurred. -// -// This will also be the behavior in the absence of a -// user-defined assert handler. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an assertion test has failed (and not been ignored) since + * the last call to clear_assert_failed(). + * + * When an assertion test fails, the assert handler may decide either to + * abort, return, or ignore the assertion. Naturally, if it decides to abort, + * this flag is irrelevant. If it chooses to ignore the assertion, the flag + * is not set. However, if the assert handler chooses to return out of the + * function (the normal case), it will also set this flag to indicate that an + * assertion failure has occurred. + * + * This will also be the behavior in the absence of a user-defined assert + * handler. + */ INLINE bool Notify:: has_assert_failed() const { return _assert_failed; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::get_assert_error_message -// Access: Public -// Description: Returns the error message that corresponds to the -// assertion that most recently failed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the error message that corresponds to the assertion that most + * recently failed. + */ INLINE const string &Notify:: get_assert_error_message() const { return _assert_error_message; } -//////////////////////////////////////////////////////////////////// -// Function: Notify::clear_assert_failed -// Access: Public -// Description: Resets the assert_failed flag that is set whenever an -// assertion test fails. See has_assert_failed(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the assert_failed flag that is set whenever an assertion test fails. + * See has_assert_failed(). + */ INLINE void Notify:: clear_assert_failed() { _assert_failed = false; diff --git a/dtool/src/prc/pnotify.h b/dtool/src/prc/pnotify.h index 53dd7d11f7..a8254cc910 100644 --- a/dtool/src/prc/pnotify.h +++ b/dtool/src/prc/pnotify.h @@ -1,16 +1,15 @@ -// Filename: pnotify.h -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnotify.h + * @author drose + * @date 2000-02-28 + */ #ifndef NOTIFY_H #define NOTIFY_H @@ -21,20 +20,16 @@ class NotifyCategory; -//////////////////////////////////////////////////////////////////// -// Class : Notify -// Description : An object that handles general error reporting to the -// user. It contains a pointer to an ostream, initially -// cerr, which can be reset at will to point to -// different output devices, according to the needs of -// the application. All output generated within Panda -// should vector through the Notify ostream. -// -// This also includes a collection of Categories and -// Severities, which may be independently enabled or -// disabled, so that error messages may be squelched or -// respected according to the wishes of the user. -//////////////////////////////////////////////////////////////////// +/** + * An object that handles general error reporting to the user. It contains a + * pointer to an ostream, initially cerr, which can be reset at will to point + * to different output devices, according to the needs of the application. + * All output generated within Panda should vector through the Notify ostream. + * + * This also includes a collection of Categories and Severities, which may be + * independently enabled or disabled, so that error messages may be squelched + * or respected according to the wishes of the user. + */ class EXPCL_DTOOLCONFIG Notify { PUBLISHED: Notify(); @@ -88,8 +83,8 @@ private: bool _assert_failed; string _assert_error_message; - // This shouldn't be a pmap, since it might be invoked before we - // initialize the global malloc pointers. + // This shouldn't be a pmap, since it might be invoked before we initialize + // the global malloc pointers. typedef map Categories; Categories _categories; @@ -98,38 +93,34 @@ private: // This defines the symbol nout in the same way that cerr and cout are -// defined, for compactness of C++ code that uses Notify in its -// simplest form. Maybe it's a good idea to define this symbol and -// maybe it's not, but it does seem that "nout" isn't likely to -// collide with any other name. +// defined, for compactness of C++ code that uses Notify in its simplest form. +// Maybe it's a good idea to define this symbol and maybe it's not, but it +// does seem that "nout" isn't likely to collide with any other name. #define nout (Notify::out()) -// Here are a couple of assert-type functions. These are designed to -// avoid simply dumping core, since that's quite troublesome when the -// programmer is working in a higher-level environment that is calling -// into the C++ layer. +// Here are a couple of assert-type functions. These are designed to avoid +// simply dumping core, since that's quite troublesome when the programmer is +// working in a higher-level environment that is calling into the C++ layer. -// nassertr() is intended to be used in functions that have return -// values; it returns the indicated value if the assertion fails. +// nassertr() is intended to be used in functions that have return values; it +// returns the indicated value if the assertion fails. -// nassertv() is intended to be used in functions that do not have -// return values; it simply returns if the assertion fails. +// nassertv() is intended to be used in functions that do not have return +// values; it simply returns if the assertion fails. -// nassertd() does not return from the function, but instead executes -// the following block of code (like an if statement) if the assertion -// fails. +// nassertd() does not return from the function, but instead executes the +// following block of code (like an if statement) if the assertion fails. -// nassertr_always() and nassertv_always() are like nassertr() and -// nassertv(), except that they will not get completely compiled out -// if NDEBUG is set. Instead, they will quietly return from the -// function. These macros are appropriate, for instance, for sanity -// checking user input parameters, where optimal performance is not -// paramount. +// nassertr_always() and nassertv_always() are like nassertr() and nassertv(), +// except that they will not get completely compiled out if NDEBUG is set. +// Instead, they will quietly return from the function. These macros are +// appropriate, for instance, for sanity checking user input parameters, where +// optimal performance is not paramount. -// nassert_static() is a compile-time assertion. It should only be -// used with constant expressions and compilation will fail if the -// assertion is not true. +// nassert_static() is a compile-time assertion. It should only be used with +// constant expressions and compilation will fail if the assertion is not +// true. #ifdef NDEBUG diff --git a/dtool/src/prc/prcKeyRegistry.I b/dtool/src/prc/prcKeyRegistry.I index 93a338e312..0e443003bf 100644 --- a/dtool/src/prc/prcKeyRegistry.I +++ b/dtool/src/prc/prcKeyRegistry.I @@ -1,14 +1,12 @@ -// Filename: prcKeyRegistry.I -// Created by: drose (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file prcKeyRegistry.I + * @author drose + * @date 2004-10-19 + */ diff --git a/dtool/src/prc/prcKeyRegistry.cxx b/dtool/src/prc/prcKeyRegistry.cxx index 70e18a5735..9b760ac53d 100644 --- a/dtool/src/prc/prcKeyRegistry.cxx +++ b/dtool/src/prc/prcKeyRegistry.cxx @@ -1,23 +1,21 @@ -// Filename: prcKeyRegistry.cxx -// Created by: drose (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file prcKeyRegistry.cxx + * @author drose + * @date 2004-10-19 + */ #include "prcKeyRegistry.h" #include "config_prc.h" -// This file requires OpenSSL to compile, because we use routines in -// the OpenSSL library to manage keys and to sign and validate -// signatures. +// This file requires OpenSSL to compile, because we use routines in the +// OpenSSL library to manage keys and to sign and validate signatures. #ifdef HAVE_OPENSSL @@ -25,39 +23,31 @@ PrcKeyRegistry *PrcKeyRegistry::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::Constructor -// Access: Protected -// Description: There is only one PrcKeyRegistry in the world; use -// get_global_ptr() to get it. -//////////////////////////////////////////////////////////////////// +/** + * There is only one PrcKeyRegistry in the world; use get_global_ptr() to get + * it. + */ PrcKeyRegistry:: PrcKeyRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PrcKeyRegistry:: ~PrcKeyRegistry() { prc_cat.error() << "Internal error--PrcKeyRegistry destructor called!\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::record_keys -// Access: Public -// Description: Records the list of public keys that are compiled -// into this executable. The pointer is assumed to be -// to an area of static memory that will not be -// destructed, so the data is not copied, but only the -// pointer is assigned. -// -// This method is normally called after including the -// code generated by the make-prc-key utility. -//////////////////////////////////////////////////////////////////// +/** + * Records the list of public keys that are compiled into this executable. + * The pointer is assumed to be to an area of static memory that will not be + * destructed, so the data is not copied, but only the pointer is assigned. + * + * This method is normally called after including the code generated by the + * make-prc-key utility. + */ void PrcKeyRegistry:: record_keys(const KeyDef *key_def, size_t num_keys) { for (size_t i = 0; i < num_keys; i++) { @@ -83,15 +73,12 @@ record_keys(const KeyDef *key_def, size_t num_keys) { } } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::set_key -// Access: Public -// Description: Sets the nth public key in the registry to the given -// value. The EVP_PKEY structure must have been -// properly allocated view EVP_PKEY_new(); its ownership -// is transferred to the registry and it will eventually -// be freed via EVP_PKEY_free(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth public key in the registry to the given value. The EVP_PKEY + * structure must have been properly allocated view EVP_PKEY_new(); its + * ownership is transferred to the registry and it will eventually be freed + * via EVP_PKEY_free(). + */ void PrcKeyRegistry:: set_key(size_t n, EVP_PKEY *pkey, time_t generated_time) { // Clear the nth key. @@ -111,25 +98,19 @@ set_key(size_t n, EVP_PKEY *pkey, time_t generated_time) { _keys[n]._generated_time = generated_time; } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::get_num_keys -// Access: Public -// Description: Returns the number of public keys in the registry. -// This is actually the highest index number + 1, which -// might not strictly be the number of keys, since there -// may be holes in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of public keys in the registry. This is actually the + * highest index number + 1, which might not strictly be the number of keys, + * since there may be holes in the list. + */ size_t PrcKeyRegistry:: get_num_keys() const { return _keys.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::get_key -// Access: Public -// Description: Returns the nth public key, or NULL if the nth key is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth public key, or NULL if the nth key is not defined. + */ EVP_PKEY *PrcKeyRegistry:: get_key(size_t n) const { nassertr(n < _keys.size(), (EVP_PKEY *)NULL); @@ -153,12 +134,10 @@ get_key(size_t n) const { return _keys[n]._pkey; } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::get_generated_time -// Access: Public -// Description: Returns the timestamp at which the indicated key was -// generated, or 0 if the key is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp at which the indicated key was generated, or 0 if the + * key is not defined. + */ time_t PrcKeyRegistry:: get_generated_time(size_t n) const { nassertr(n < _keys.size(), 0); @@ -166,11 +145,9 @@ get_generated_time(size_t n) const { return _keys[n]._generated_time; } -//////////////////////////////////////////////////////////////////// -// Function: PrcKeyRegistry::get_global_ptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PrcKeyRegistry *PrcKeyRegistry:: get_global_ptr() { if (_global_ptr == (PrcKeyRegistry *)NULL) { diff --git a/dtool/src/prc/prcKeyRegistry.h b/dtool/src/prc/prcKeyRegistry.h index ebffc10171..1b53287215 100644 --- a/dtool/src/prc/prcKeyRegistry.h +++ b/dtool/src/prc/prcKeyRegistry.h @@ -1,25 +1,23 @@ -// Filename: prcKeyRegistry.h -// Created by: drose (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file prcKeyRegistry.h + * @author drose + * @date 2004-10-19 + */ #ifndef PRCKEYREGISTRY_H #define PRCKEYREGISTRY_H #include "dtoolbase.h" -// This file requires OpenSSL to compile, because we use routines in -// the OpenSSL library to manage keys and to sign and validate -// signatures. +// This file requires OpenSSL to compile, because we use routines in the +// OpenSSL library to manage keys and to sign and validate signatures. #ifdef HAVE_OPENSSL @@ -29,17 +27,14 @@ // Some versions of OpenSSL appear to define this as a macro. Yucky. #undef set_key -//////////////////////////////////////////////////////////////////// -// Class : PrcKeyRegistry -// Description : This class records the set of public keys used to -// verify the signature on a prc file. The actual -// public keys themselves are generated by the -// make-prc-key utility; the output of this utility is a -// .cxx file which should be named by the -// PRC_PUBLIC_KEYS_FILENAME variable in Config.pp. -// -// This class requires the OpenSSL library. -//////////////////////////////////////////////////////////////////// +/** + * This class records the set of public keys used to verify the signature on a + * prc file. The actual public keys themselves are generated by the make-prc- + * key utility; the output of this utility is a .cxx file which should be + * named by the PRC_PUBLIC_KEYS_FILENAME variable in Config.pp. + * + * This class requires the OpenSSL library. + */ class EXPCL_DTOOLCONFIG PrcKeyRegistry { protected: PrcKeyRegistry(); diff --git a/dtool/src/prc/reversedNumericData.I b/dtool/src/prc/reversedNumericData.I index a72e3f10df..df34a98a78 100644 --- a/dtool/src/prc/reversedNumericData.I +++ b/dtool/src/prc/reversedNumericData.I @@ -1,65 +1,51 @@ -// Filename: reversedNumericData.I -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reversedNumericData.I + * @author drose + * @date 2001-05-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ReversedNumericData::Constructor -// Access: Public -// Description: This constructor accepts the address of a numeric -// variable, and its sizeof. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts the address of a numeric variable, and its sizeof. + */ INLINE ReversedNumericData:: ReversedNumericData(const void *data, size_t length) { reverse_assign((const char *)data, length); } -//////////////////////////////////////////////////////////////////// -// Function: ReversedNumericData::Constructor -// Access: Public -// Description: This constructor accepts a pointer to a data array -// containing a packed numeric value, the offset within -// the array at which the numeric value starts, and the -// size of the numeric value. -// -// It is essential that the array not be destructed or -// modified as long as the NumericData object remains; -// it may just store a pointer into that string's -// internal buffer. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts a pointer to a data array containing a packed + * numeric value, the offset within the array at which the numeric value + * starts, and the size of the numeric value. + * + * It is essential that the array not be destructed or modified as long as the + * NumericData object remains; it may just store a pointer into that string's + * internal buffer. + */ INLINE ReversedNumericData:: ReversedNumericData(const void *data, size_t start, size_t length) { reverse_assign((const char *)data + start, length); } -//////////////////////////////////////////////////////////////////// -// Function: ReversedNumericData::store_value -// Access: Public -// Description: Copies the data, with byte reversal if appropriate, -// into the indicated numeric variable, whose address -// and sizeof are given. -//////////////////////////////////////////////////////////////////// +/** + * Copies the data, with byte reversal if appropriate, into the indicated + * numeric variable, whose address and sizeof are given. + */ INLINE void ReversedNumericData:: store_value(void *dest, size_t length) const { memcpy(dest, _data, length); } -//////////////////////////////////////////////////////////////////// -// Function: ReversedNumericData::get_data -// Access: Public -// Description: Returns the pointer to the first byte of the data, -// either reversed or nonreversed, as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the first byte of the data, either reversed or + * nonreversed, as appropriate. + */ INLINE const void *ReversedNumericData:: get_data() const { return _data; diff --git a/dtool/src/prc/reversedNumericData.cxx b/dtool/src/prc/reversedNumericData.cxx index 49375b5613..62b967d022 100644 --- a/dtool/src/prc/reversedNumericData.cxx +++ b/dtool/src/prc/reversedNumericData.cxx @@ -1,27 +1,23 @@ -// Filename: reversedNumericData.cxx -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reversedNumericData.cxx + * @author drose + * @date 2001-05-09 + */ #include "pnotify.h" #include "reversedNumericData.h" -//////////////////////////////////////////////////////////////////// -// Function: ReversedNumericData::reverse_assign -// Access: Private -// Description: Actually does the data reversal. -//////////////////////////////////////////////////////////////////// +/** + * Actually does the data reversal. + */ void ReversedNumericData:: reverse_assign(const char *source, size_t length) { nassertv((int)length <= max_numeric_size); diff --git a/dtool/src/prc/reversedNumericData.h b/dtool/src/prc/reversedNumericData.h index 4f3b6f2880..d92ab82964 100644 --- a/dtool/src/prc/reversedNumericData.h +++ b/dtool/src/prc/reversedNumericData.h @@ -1,16 +1,15 @@ -// Filename: reversedNumericData.h -// Created by: drose (09May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reversedNumericData.h + * @author drose + * @date 2001-05-09 + */ #ifndef REVERSEDNUMERICDATA_H #define REVERSEDNUMERICDATA_H @@ -19,32 +18,27 @@ #include // for memcpy() -// The maximum size of any numeric data type. At present, this is -// int64 and float64. +// The maximum size of any numeric data type. At present, this is int64 and +// float64. static const int max_numeric_size = 8; -//////////////////////////////////////////////////////////////////// -// Class : ReversedNumericData -// Description : NativeNumericData and ReversedNumericData work -// together to provide a sneaky interface for -// automatically byte-swapping numbers, when necessary, -// to transparency support big-endian and little-endian -// architectures. -// -// Both of these classes provide interfaces that accept -// a pointer to a numeric variable and the size of the -// number, and they can append that data to the end of a -// string, or memcpy it into another location. -// -// The difference is that NativeNumericData simply -// passes everything through unchanged, while -// ReversedNumericData always byte-swaps everything. -// Otherwise, they have the same interface. -// -// The transparent part comes from LittleEndian and -// BigEndian, which are typedeffed to be one of these or -// the other, according to the machine's architecture. -//////////////////////////////////////////////////////////////////// +/** + * NativeNumericData and ReversedNumericData work together to provide a sneaky + * interface for automatically byte-swapping numbers, when necessary, to + * transparency support big-endian and little-endian architectures. + * + * Both of these classes provide interfaces that accept a pointer to a numeric + * variable and the size of the number, and they can append that data to the + * end of a string, or memcpy it into another location. + * + * The difference is that NativeNumericData simply passes everything through + * unchanged, while ReversedNumericData always byte-swaps everything. + * Otherwise, they have the same interface. + * + * The transparent part comes from LittleEndian and BigEndian, which are + * typedeffed to be one of these or the other, according to the machine's + * architecture. + */ class EXPCL_DTOOLCONFIG ReversedNumericData { public: INLINE ReversedNumericData(const void *data, size_t length); diff --git a/dtool/src/prc/streamReader.I b/dtool/src/prc/streamReader.I index 65a2c90c06..e02e3e9aec 100644 --- a/dtool/src/prc/streamReader.I +++ b/dtool/src/prc/streamReader.I @@ -1,23 +1,19 @@ -// Filename: streamReader.I -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamReader.I + * @author drose + * @date 2002-08-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamReader:: StreamReader(istream &in) : _in(&in), @@ -25,12 +21,10 @@ StreamReader(istream &in) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::Constructor -// Access: Published -// Description: If owns_stream is true, the stream pointer will be -// deleted when the StreamReader destructs. -//////////////////////////////////////////////////////////////////// +/** + * If owns_stream is true, the stream pointer will be deleted when the + * StreamReader destructs. + */ INLINE StreamReader:: StreamReader(istream *in, bool owns_stream) : _in(in), @@ -38,12 +32,9 @@ StreamReader(istream *in, bool owns_stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::Copy Constructor -// Access: Published -// Description: The copy constructor does not copy ownership of the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * The copy constructor does not copy ownership of the stream. + */ INLINE StreamReader:: StreamReader(const StreamReader ©) : _in(copy._in), @@ -51,12 +42,9 @@ StreamReader(const StreamReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::Copy Assignment Operator -// Access: Published -// Description: The copy constructor does not copy ownership of the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * The copy constructor does not copy ownership of the stream. + */ INLINE void StreamReader:: operator = (const StreamReader ©) { if (_owns_stream) { @@ -66,11 +54,9 @@ operator = (const StreamReader ©) { _owns_stream = false; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamReader:: ~StreamReader() { if (_owns_stream) { @@ -78,51 +64,41 @@ INLINE StreamReader:: } } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_istream -// Access: Published -// Description: Returns the stream in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stream in use. + */ INLINE istream *StreamReader:: get_istream() const { return _in; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_bool -// Access: Published -// Description: Extracts a boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a boolean value. + */ INLINE bool StreamReader:: get_bool() { return (get_uint8() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_int8 -// Access: Published -// Description: Extracts a signed 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 8-bit integer. + */ INLINE PN_int8 StreamReader:: get_int8() { return (PN_int8)_in->get(); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_uint8 -// Access: Published -// Description: Extracts an unsigned 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 8-bit integer. + */ INLINE PN_uint8 StreamReader:: get_uint8() { return (PN_uint8)_in->get(); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_int16 -// Access: Published -// Description: Extracts a signed 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 16-bit integer. + */ INLINE PN_int16 StreamReader:: get_int16() { PN_int16 readval, retval; @@ -132,11 +108,9 @@ get_int16() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_int32 -// Access: Published -// Description: Extracts a signed 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 32-bit integer. + */ INLINE PN_int32 StreamReader:: get_int32() { PN_int32 readval, retval; @@ -146,11 +120,9 @@ get_int32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_int64 -// Access: Published -// Description: Extracts a signed 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 64-bit integer. + */ INLINE PN_int64 StreamReader:: get_int64() { PN_int64 readval, retval; @@ -160,11 +132,9 @@ get_int64() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_uint16 -// Access: Published -// Description: Extracts an unsigned 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 16-bit integer. + */ INLINE PN_uint16 StreamReader:: get_uint16() { PN_uint16 readval, retval; @@ -174,11 +144,9 @@ get_uint16() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_uint32 -// Access: Published -// Description: Extracts an unsigned 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 32-bit integer. + */ INLINE PN_uint32 StreamReader:: get_uint32() { PN_uint32 readval, retval; @@ -188,11 +156,9 @@ get_uint32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_uint64 -// Access: Published -// Description: Extracts an unsigned 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 64-bit integer. + */ INLINE PN_uint64 StreamReader:: get_uint64() { PN_uint64 readval, retval; @@ -202,19 +168,16 @@ get_uint64() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_float32 -// Access: Published -// Description: Extracts a 32-bit single-precision floating-point -// number. Since this kind of float is not necessarily -// portable across different architectures, special care -// is required. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 32-bit single-precision floating-point number. Since this kind + * of float is not necessarily portable across different architectures, + * special care is required. + */ INLINE float StreamReader:: get_float32() { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. + // For now, we assume the float format is portable across all architectures + // we are concerned with. If we come across one that is different, we will + // have to convert. nassertr(sizeof(float) == 4, 0.0f); float readval, retval; @@ -224,11 +187,9 @@ get_float32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_float64 -// Access: Published -// Description: Extracts a 64-bit floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 64-bit floating-point number. + */ INLINE PN_float64 StreamReader:: get_float64() { PN_float64 readval, retval; @@ -238,11 +199,9 @@ get_float64() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_int16 -// Access: Published -// Description: Extracts a signed big-endian 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed big-endian 16-bit integer. + */ INLINE PN_int16 StreamReader:: get_be_int16() { PN_int16 readval, retval; @@ -252,11 +211,9 @@ get_be_int16() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_int32 -// Access: Published -// Description: Extracts a signed big-endian 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed big-endian 32-bit integer. + */ INLINE PN_int32 StreamReader:: get_be_int32() { PN_int32 readval, retval; @@ -266,11 +223,9 @@ get_be_int32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_int64 -// Access: Published -// Description: Extracts a signed big-endian 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed big-endian 64-bit integer. + */ INLINE PN_int64 StreamReader:: get_be_int64() { PN_int64 readval, retval; @@ -280,11 +235,9 @@ get_be_int64() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_uint16 -// Access: Published -// Description: Extracts an unsigned big-endian 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned big-endian 16-bit integer. + */ INLINE PN_uint16 StreamReader:: get_be_uint16() { PN_uint16 readval, retval; @@ -294,11 +247,9 @@ get_be_uint16() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_uint32 -// Access: Published -// Description: Extracts an unsigned big-endian 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned big-endian 32-bit integer. + */ INLINE PN_uint32 StreamReader:: get_be_uint32() { PN_uint32 readval, retval; @@ -308,11 +259,9 @@ get_be_uint32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_uint64 -// Access: Published -// Description: Extracts an unsigned big-endian 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned big-endian 64-bit integer. + */ INLINE PN_uint64 StreamReader:: get_be_uint64() { PN_uint64 readval, retval; @@ -322,19 +271,16 @@ get_be_uint64() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_float32 -// Access: Published -// Description: Extracts a 32-bit single-precision big-endian -// floating-point number. Since this kind of float is -// not necessarily portable across different -// architectures, special care is required. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 32-bit single-precision big-endian floating-point number. Since + * this kind of float is not necessarily portable across different + * architectures, special care is required. + */ INLINE float StreamReader:: get_be_float32() { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. + // For now, we assume the float format is portable across all architectures + // we are concerned with. If we come across one that is different, we will + // have to convert. nassertr(sizeof(float) == 4, 0.0f); float readval, retval; @@ -344,11 +290,9 @@ get_be_float32() { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_be_float64 -// Access: Published -// Description: Extracts a 64-bit big-endian floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 64-bit big-endian floating-point number. + */ INLINE PN_float64 StreamReader:: get_be_float64() { PN_float64 readval, retval; diff --git a/dtool/src/prc/streamReader.cxx b/dtool/src/prc/streamReader.cxx index 77ac276dc1..17252f5dd2 100644 --- a/dtool/src/prc/streamReader.cxx +++ b/dtool/src/prc/streamReader.cxx @@ -1,26 +1,23 @@ -// Filename: streamReader.cxx -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamReader.cxx + * @author drose + * @date 2002-08-04 + */ #include "streamReader.h" #include "memoryHook.h" -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_string -// Access: Published -// Description: Extracts a variable-length string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string. + */ string StreamReader:: get_string() { nassertr(!_in->eof() && !_in->fail(), string()); @@ -34,12 +31,9 @@ get_string() { return string(buffer, read_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_string32 -// Access: Published -// Description: Extracts a variable-length string with a 32-bit -// length field. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string with a 32-bit length field. + */ string StreamReader:: get_string32() { nassertr(!_in->eof() && !_in->fail(), string()); @@ -55,12 +49,9 @@ get_string32() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_z_string -// Access: Published -// Description: Extracts a variable-length string, as a -// NULL-terminated string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string, as a NULL-terminated string. + */ string StreamReader:: get_z_string() { nassertr(!_in->eof() && !_in->fail(), string()); @@ -75,13 +66,10 @@ get_z_string() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::get_fixed_string -// Access: Published -// Description: Extracts a fixed-length string. However, if a zero -// byte occurs within the string, it marks the end of -// the string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a fixed-length string. However, if a zero byte occurs within the + * string, it marks the end of the string. + */ string StreamReader:: get_fixed_string(size_t size) { nassertr(!_in->eof() && !_in->fail(), string()); @@ -95,12 +83,9 @@ get_fixed_string(size_t size) { return result.substr(0, zero_byte); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::skip_bytes -// Access: Published -// Description: Skips over the indicated number of bytes in the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Skips over the indicated number of bytes in the stream. + */ void StreamReader:: skip_bytes(size_t size) { nassertv(!_in->eof() && !_in->fail()); @@ -112,15 +97,12 @@ skip_bytes(size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::extract_bytes -// Access: Published -// Description: Extracts the indicated number of bytes in the -// stream into the given character buffer. Assumes -// that the buffer is big enough to hold the requested -// number of bytes. Returns the number of bytes -// that were successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the stream into the given + * character buffer. Assumes that the buffer is big enough to hold the + * requested number of bytes. Returns the number of bytes that were + * successfully written. + */ size_t StreamReader:: extract_bytes(unsigned char *into, size_t size) { if (_in->eof() || _in->fail()) { @@ -131,13 +113,10 @@ extract_bytes(unsigned char *into, size_t size) { return _in->gcount(); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::extract_bytes -// Access: Public -// Description: Extracts the indicated number of bytes in the -// stream and returns them as a string. Returns empty -// string at end-of-file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the stream and returns them as a + * string. Returns empty string at end-of-file. + */ string StreamReader:: extract_bytes(size_t size) { if (_in->eof() || _in->fail()) { @@ -150,18 +129,14 @@ extract_bytes(size_t size) { return string(buffer, read_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::readline -// Access: Public -// Description: Assumes the stream represents a text file, and -// extracts one line up to and including the trailing -// newline character. Returns empty string when the end -// of file is reached. -// -// The interface here is intentionally designed to be -// similar to that for Python's File.readline() -// function. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the stream represents a text file, and extracts one line up to and + * including the trailing newline character. Returns empty string when the + * end of file is reached. + * + * The interface here is intentionally designed to be similar to that for + * Python's File.readline() function. + */ string StreamReader:: readline() { string line; diff --git a/dtool/src/prc/streamReader.h b/dtool/src/prc/streamReader.h index 9560cfef5e..f8f4678537 100644 --- a/dtool/src/prc/streamReader.h +++ b/dtool/src/prc/streamReader.h @@ -1,16 +1,15 @@ -// Filename: streamReader.h -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamReader.h + * @author drose + * @date 2002-08-04 + */ #ifndef STREAMREADER_H #define STREAMREADER_H @@ -21,12 +20,10 @@ #include "littleEndian.h" #include "bigEndian.h" -//////////////////////////////////////////////////////////////////// -// Class : StreamReader -// Description : A class to read sequential binary data directly from -// an istream. Its interface is similar to -// DatagramIterator by design; see also StreamWriter. -//////////////////////////////////////////////////////////////////// +/** + * A class to read sequential binary data directly from an istream. Its + * interface is similar to DatagramIterator by design; see also StreamWriter. + */ class EXPCL_DTOOLCONFIG StreamReader { public: INLINE StreamReader(istream &in); diff --git a/dtool/src/prc/streamWrapper.I b/dtool/src/prc/streamWrapper.I index 44518f9a84..788498aceb 100644 --- a/dtool/src/prc/streamWrapper.I +++ b/dtool/src/prc/streamWrapper.I @@ -1,23 +1,19 @@ -// Filename: streamWrapper.I -// Created by: drose (11Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWrapper.I + * @author drose + * @date 2008-11-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapperBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWrapperBase:: StreamWrapperBase() { #ifdef SIMPLE_THREADS @@ -25,24 +21,19 @@ StreamWrapperBase() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapperBase::acquire -// Access: Published -// Description: Acquires the internal lock. -// -// User code should call this to take temporary -// possession of the stream and perform direct I/O -// operations on it, for instance to make several -// sequential atomic reads. You may not call any of the -// StreamWrapper methods while the lock is held, other -// than release(). -// -// Use with extreme caution! This is a very low-level, -// non-recursive lock. You must call acquire() only -// once, and you must later call release() exactly once. -// Failing to do so may result in a hard deadlock with -// no available debugging features. -//////////////////////////////////////////////////////////////////// +/** + * Acquires the internal lock. + * + * User code should call this to take temporary possession of the stream and + * perform direct I/O operations on it, for instance to make several + * sequential atomic reads. You may not call any of the StreamWrapper methods + * while the lock is held, other than release(). + * + * Use with extreme caution! This is a very low-level, non-recursive lock. + * You must call acquire() only once, and you must later call release() + * exactly once. Failing to do so may result in a hard deadlock with no + * available debugging features. + */ INLINE void StreamWrapperBase:: acquire() { _lock.acquire(); @@ -54,13 +45,10 @@ acquire() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapperBase::release -// Access: Published -// Description: Releases the internal lock. Must be called exactly -// once following a call to acquire(). See the cautions -// with acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the internal lock. Must be called exactly once following a call + * to acquire(). See the cautions with acquire(). + */ INLINE void StreamWrapperBase:: release() { #ifdef SIMPLE_THREADS @@ -70,11 +58,9 @@ release() { _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IStreamWrapper:: IStreamWrapper(istream *stream, bool owns_pointer) : _istream(stream), @@ -82,11 +68,9 @@ IStreamWrapper(istream *stream, bool owns_pointer) : { } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IStreamWrapper:: IStreamWrapper(istream &stream) : _istream(&stream), @@ -94,21 +78,17 @@ IStreamWrapper(istream &stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::get_istream -// Access: Published -// Description: Returns the istream this object is wrapping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the istream this object is wrapping. + */ INLINE istream *IStreamWrapper:: get_istream() const { return _istream; } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::get -// Access: Public -// Description: Atomically reads a single character from the stream. -//////////////////////////////////////////////////////////////////// +/** + * Atomically reads a single character from the stream. + */ INLINE int IStreamWrapper:: get() { int result; @@ -119,11 +99,9 @@ get() { } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OStreamWrapper:: OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) : _ostream(stream), @@ -134,11 +112,9 @@ OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack) : { } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OStreamWrapper:: OStreamWrapper(ostream &stream) : _ostream(&stream), @@ -149,22 +125,18 @@ OStreamWrapper(ostream &stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::get_ostream -// Access: Published -// Description: Returns the ostream this object is wrapping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ostream this object is wrapping. + */ INLINE ostream *OStreamWrapper:: get_ostream() const { return _ostream; } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::put -// Access: Public -// Description: Atomically writes a single character to the stream. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Atomically writes a single character to the stream. Returns true on + * success, false on failure. + */ INLINE bool OStreamWrapper:: put(char c) { bool success; @@ -175,11 +147,9 @@ put(char c) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWrapper:: StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack) : IStreamWrapper(stream, false), @@ -189,11 +159,9 @@ StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapper::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWrapper:: StreamWrapper(iostream &stream) : IStreamWrapper(&stream, false), @@ -203,11 +171,9 @@ StreamWrapper(iostream &stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapper::get_iostream -// Access: Published -// Description: Returns the iostream this object is wrapping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iostream this object is wrapping. + */ INLINE iostream *StreamWrapper:: get_iostream() const { return _iostream; diff --git a/dtool/src/prc/streamWrapper.cxx b/dtool/src/prc/streamWrapper.cxx index 16e568c459..68f8e47abb 100644 --- a/dtool/src/prc/streamWrapper.cxx +++ b/dtool/src/prc/streamWrapper.cxx @@ -1,31 +1,28 @@ -// Filename: streamWrapper.cxx -// Created by: drose (11Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWrapper.cxx + * @author drose + * @date 2008-11-11 + */ #include "streamWrapper.h" -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IStreamWrapper:: ~IStreamWrapper() { if (_owns_pointer) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) _istream->~istream(); (*global_operator_delete)(_istream); @@ -35,14 +32,11 @@ IStreamWrapper:: } } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::read -// Access: Public -// Description: Atomically reads a number of bytes from the stream, -// without error detection. If fewer bytes than -// requested are read, quietly fills the remaining bytes -// with 0. -//////////////////////////////////////////////////////////////////// +/** + * Atomically reads a number of bytes from the stream, without error + * detection. If fewer bytes than requested are read, quietly fills the + * remaining bytes with 0. + */ void IStreamWrapper:: read(char *buffer, streamsize num_bytes) { acquire(); @@ -50,8 +44,7 @@ read(char *buffer, streamsize num_bytes) { _istream->read(buffer, num_bytes); streamsize read_bytes = _istream->gcount(); while (read_bytes < num_bytes) { - // Fewer bytes than expected were read. Maybe more will be - // coming later. + // Fewer bytes than expected were read. Maybe more will be coming later. release(); thread_yield(); acquire(); @@ -71,12 +64,10 @@ read(char *buffer, streamsize num_bytes) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::read -// Access: Public -// Description: Atomically reads a number of bytes from the stream. -// Returns the number of bytes actually read. -//////////////////////////////////////////////////////////////////// +/** + * Atomically reads a number of bytes from the stream. Returns the number of + * bytes actually read. + */ void IStreamWrapper:: read(char *buffer, streamsize num_bytes, streamsize &read_bytes) { acquire(); @@ -87,14 +78,11 @@ read(char *buffer, streamsize num_bytes, streamsize &read_bytes) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::read -// Access: Public -// Description: Atomically reads a number of bytes from the stream. -// Returns the number of bytes actually read, and -// whether an eof condition was detected by the -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Atomically reads a number of bytes from the stream. Returns the number of + * bytes actually read, and whether an eof condition was detected by the + * operation. + */ void IStreamWrapper:: read(char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof) { acquire(); @@ -106,17 +94,13 @@ read(char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::seek_read -// Access: Public -// Description: Atomically seeks to a particular offset from the -// beginning of the file, and reads a number of bytes -// from the stream. Returns the number of bytes -// actually read, and whether an eof condition was -// detected by the operation. -//////////////////////////////////////////////////////////////////// +/** + * Atomically seeks to a particular offset from the beginning of the file, and + * reads a number of bytes from the stream. Returns the number of bytes + * actually read, and whether an eof condition was detected by the operation. + */ void IStreamWrapper:: -seek_read(streamsize pos, char *buffer, streamsize num_bytes, +seek_read(streamsize pos, char *buffer, streamsize num_bytes, streamsize &read_bytes, bool &eof) { acquire(); _istream->clear(); @@ -128,14 +112,11 @@ seek_read(streamsize pos, char *buffer, streamsize num_bytes, release(); } -//////////////////////////////////////////////////////////////////// -// Function: IStreamWrapper::seek_gpos_eof -// Access: Public -// Description: Atomically seeks to EOF and returns the gpos there; -// that is, returns the file size. Note that the EOF -// might have been moved in another thread by the time -// this method returns. -//////////////////////////////////////////////////////////////////// +/** + * Atomically seeks to EOF and returns the gpos there; that is, returns the + * file size. Note that the EOF might have been moved in another thread by + * the time this method returns. + */ streamsize IStreamWrapper:: seek_gpos_eof() { streamsize pos; @@ -147,18 +128,16 @@ seek_gpos_eof() { return pos; } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OStreamWrapper:: ~OStreamWrapper() { if (_owns_pointer) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) _ostream->~ostream(); (*global_operator_delete)(_ostream); @@ -168,12 +147,9 @@ OStreamWrapper:: } } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::write -// Access: Public -// Description: Atomically writes a number of bytes to the stream, -// without error detection. -//////////////////////////////////////////////////////////////////// +/** + * Atomically writes a number of bytes to the stream, without error detection. + */ void OStreamWrapper:: write(const char *buffer, streamsize num_bytes) { acquire(); @@ -181,13 +157,10 @@ write(const char *buffer, streamsize num_bytes) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::read -// Access: Public -// Description: Atomically writes a number of bytes to the stream. -// Returns whether a failure condition was detected by -// the operation. -//////////////////////////////////////////////////////////////////// +/** + * Atomically writes a number of bytes to the stream. Returns whether a + * failure condition was detected by the operation. + */ void OStreamWrapper:: write(const char *buffer, streamsize num_bytes, bool &fail) { acquire(); @@ -197,16 +170,13 @@ write(const char *buffer, streamsize num_bytes, bool &fail) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::seek_write -// Access: Public -// Description: Atomically seeks to a particular offset from the -// beginning of the file, and writes a number of bytes -// to the stream. Returns whether a failure condition -// was detected by the operation. -//////////////////////////////////////////////////////////////////// +/** + * Atomically seeks to a particular offset from the beginning of the file, and + * writes a number of bytes to the stream. Returns whether a failure + * condition was detected by the operation. + */ void OStreamWrapper:: -seek_write(streamsize pos, const char *buffer, streamsize num_bytes, +seek_write(streamsize pos, const char *buffer, streamsize num_bytes, bool &fail) { acquire(); _ostream->clear(); @@ -214,8 +184,8 @@ seek_write(streamsize pos, const char *buffer, streamsize num_bytes, #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack && pos == 0) { - // Ignore an unsuccessful attempt to seekp(0) if - // _stringstream_hack is true. + // Ignore an unsuccessful attempt to seekp(0) if _stringstream_hack is + // true. _ostream->clear(); } #endif // WIN32_VC @@ -225,13 +195,11 @@ seek_write(streamsize pos, const char *buffer, streamsize num_bytes, release(); } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::seek_eof_write -// Access: Public -// Description: Atomically seeks to the end of the file, and writes a -// number of bytes to the stream. Returns whether a -// failure condition was detected by the operation. -//////////////////////////////////////////////////////////////////// +/** + * Atomically seeks to the end of the file, and writes a number of bytes to + * the stream. Returns whether a failure condition was detected by the + * operation. + */ void OStreamWrapper:: seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail) { acquire(); @@ -240,8 +208,8 @@ seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail) { #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { - // Ignore an unsuccessful attempt to seekp(0) if - // _stringstream_hack is true. + // Ignore an unsuccessful attempt to seekp(0) if _stringstream_hack is + // true. _ostream->clear(); } #endif // WIN32_VC @@ -251,14 +219,11 @@ seek_eof_write(const char *buffer, streamsize num_bytes, bool &fail) { release(); } -//////////////////////////////////////////////////////////////////// -// Function: OStreamWrapper::seek_ppos_eof -// Access: Public -// Description: Atomically seeks to EOF and returns the ppos there; -// that is, returns the file size. Note that the EOF -// might have been moved in another thread by the time -// this method returns. -//////////////////////////////////////////////////////////////////// +/** + * Atomically seeks to EOF and returns the ppos there; that is, returns the + * file size. Note that the EOF might have been moved in another thread by + * the time this method returns. + */ streamsize OStreamWrapper:: seek_ppos_eof() { streamsize pos; @@ -267,8 +232,8 @@ seek_ppos_eof() { #ifdef WIN32_VC if (_ostream->fail() && _stringstream_hack) { - // Ignore an unsuccessful attempt to seekp(0) if - // _stringstream_hack is true. + // Ignore an unsuccessful attempt to seekp(0) if _stringstream_hack is + // true. _ostream->clear(); release(); return 0; @@ -281,18 +246,16 @@ seek_ppos_eof() { return pos; } -//////////////////////////////////////////////////////////////////// -// Function: StreamWrapper::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StreamWrapper:: ~StreamWrapper() { if (_owns_pointer) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) _iostream->~iostream(); (*global_operator_delete)(_iostream); diff --git a/dtool/src/prc/streamWrapper.h b/dtool/src/prc/streamWrapper.h index 6a16deecf3..de25a4267d 100644 --- a/dtool/src/prc/streamWrapper.h +++ b/dtool/src/prc/streamWrapper.h @@ -1,16 +1,15 @@ -// Filename: streamWrapper.h -// Created by: drose (11Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWrapper.h + * @author drose + * @date 2008-11-11 + */ #ifndef STREAMWRAPPER_H #define STREAMWRAPPER_H @@ -18,12 +17,10 @@ #include "dtoolbase.h" #include "mutexImpl.h" -//////////////////////////////////////////////////////////////////// -// Class : StreamWrapperBase -// Description : The base class for both IStreamWrapper and -// OStreamWrapper, this provides the common locking -// interface. -//////////////////////////////////////////////////////////////////// +/** + * The base class for both IStreamWrapper and OStreamWrapper, this provides + * the common locking interface. + */ class EXPCL_DTOOLCONFIG StreamWrapperBase { protected: INLINE StreamWrapperBase(); @@ -35,21 +32,19 @@ PUBLISHED: private: MutexImpl _lock; #ifdef SIMPLE_THREADS - // In the SIMPLE_THREADS case, we need to use a bool flag, because - // MutexImpl defines to nothing in this case--but we still need to - // achieve a form of locking, since I/O operations can cause the - // thread to swap without warning. + // In the SIMPLE_THREADS case, we need to use a bool flag, because MutexImpl + // defines to nothing in this case--but we still need to achieve a form of + // locking, since IO operations can cause the thread to swap without + // warning. bool _lock_flag; #endif }; -//////////////////////////////////////////////////////////////////// -// Class : IStreamWrapper -// Description : This class provides a locking wrapper around an -// arbitrary istream pointer. A thread may use this -// class to perform an atomic seek/read/gcount -// operation. -//////////////////////////////////////////////////////////////////// +/** + * This class provides a locking wrapper around an arbitrary istream pointer. + * A thread may use this class to perform an atomic seek/read/gcount + * operation. + */ class EXPCL_DTOOLCONFIG IStreamWrapper : virtual public StreamWrapperBase { public: INLINE IStreamWrapper(istream *stream, bool owns_pointer); @@ -72,12 +67,10 @@ private: bool _owns_pointer; }; -//////////////////////////////////////////////////////////////////// -// Class : OStreamWrapper -// Description : This class provides a locking wrapper around an -// arbitrary ostream pointer. A thread may use this -// class to perform an atomic seek/write operation. -//////////////////////////////////////////////////////////////////// +/** + * This class provides a locking wrapper around an arbitrary ostream pointer. + * A thread may use this class to perform an atomic seek/write operation. + */ class EXPCL_DTOOLCONFIG OStreamWrapper : virtual public StreamWrapperBase { public: INLINE OStreamWrapper(ostream *stream, bool owns_pointer, bool stringstream_hack = false); @@ -99,22 +92,20 @@ private: ostream *_ostream; bool _owns_pointer; - // This flag is necessary to work around a weird quirk in the MSVS - // C++ runtime library: an empty stringstream cannot successfully - // seekp(0), until some data has been written to the stream. When - // this flag is set true, we know we have a possibly-empty - // stringstream, so we allow seekp(0) to fail silently, knowing that - // there's no harm in this case. + // This flag is necessary to work around a weird quirk in the MSVS C++ + // runtime library: an empty stringstream cannot successfully seekp(0), + // until some data has been written to the stream. When this flag is set + // true, we know we have a possibly-empty stringstream, so we allow seekp(0) + // to fail silently, knowing that there's no harm in this case. #ifdef WIN32_VC bool _stringstream_hack; #endif }; -//////////////////////////////////////////////////////////////////// -// Class : StreamWrapper -// Description : This class provides a locking wrapper around a -// combination ostream/istream pointer. -//////////////////////////////////////////////////////////////////// +/** + * This class provides a locking wrapper around a combination ostream/istream + * pointer. + */ class EXPCL_DTOOLCONFIG StreamWrapper : public IStreamWrapper, public OStreamWrapper { public: INLINE StreamWrapper(iostream *stream, bool owns_pointer, bool stringstream_hack = false); diff --git a/dtool/src/prc/streamWriter.I b/dtool/src/prc/streamWriter.I index b297245c30..9db035094f 100644 --- a/dtool/src/prc/streamWriter.I +++ b/dtool/src/prc/streamWriter.I @@ -1,23 +1,19 @@ -// Filename: streamWriter.I -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWriter.I + * @author drose + * @date 2002-08-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWriter:: StreamWriter(ostream &out) : #ifdef HAVE_PYTHON @@ -28,11 +24,9 @@ StreamWriter(ostream &out) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWriter:: StreamWriter(ostream *out, bool owns_stream) : #ifdef HAVE_PYTHON @@ -43,12 +37,9 @@ StreamWriter(ostream *out, bool owns_stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::Copy Constructor -// Access: Published -// Description: The copy constructor does not copy ownership of the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * The copy constructor does not copy ownership of the stream. + */ INLINE StreamWriter:: StreamWriter(const StreamWriter ©) : #ifdef HAVE_PYTHON @@ -59,12 +50,9 @@ StreamWriter(const StreamWriter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::Copy Assignment Operator -// Access: Published -// Description: The copy constructor does not copy ownership of the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * The copy constructor does not copy ownership of the stream. + */ INLINE void StreamWriter:: operator = (const StreamWriter ©) { if (_owns_stream) { @@ -74,11 +62,9 @@ operator = (const StreamWriter ©) { _owns_stream = false; } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StreamWriter:: ~StreamWriter() { if (_owns_stream) { @@ -86,249 +72,198 @@ INLINE StreamWriter:: } } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::get_ostream -// Access: Published -// Description: Returns the stream in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stream in use. + */ INLINE ostream *StreamWriter:: get_ostream() const { return _out; } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_bool -// Access: Published -// Description: Adds a boolean value to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a boolean value to the stream. + */ INLINE void StreamWriter:: add_bool(bool b) { add_uint8(b); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_int8 -// Access: Published -// Description: Adds a signed 8-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 8-bit integer to the stream. + */ INLINE void StreamWriter:: add_int8(PN_int8 value) { append_data(&value, 1); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_uint8 -// Access: Published -// Description: Adds an unsigned 8-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 8-bit integer to the stream. + */ INLINE void StreamWriter:: add_uint8(PN_uint8 value) { append_data(&value, 1); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_int16 -// Access: Published -// Description: Adds a signed 16-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 16-bit integer to the stream. + */ INLINE void StreamWriter:: add_int16(PN_int16 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_int32 -// Access: Published -// Description: Adds a signed 32-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 32-bit integer to the stream. + */ INLINE void StreamWriter:: add_int32(PN_int32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_int64 -// Access: Published -// Description: Adds a signed 64-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 64-bit integer to the stream. + */ INLINE void StreamWriter:: add_int64(PN_int64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_uint16 -// Access: Published -// Description: Adds an unsigned 16-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 16-bit integer to the stream. + */ INLINE void StreamWriter:: add_uint16(PN_uint16 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_uint32 -// Access: Published -// Description: Adds an unsigned 32-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 32-bit integer to the stream. + */ INLINE void StreamWriter:: add_uint32(PN_uint32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_uint64 -// Access: Published -// Description: Adds an unsigned 64-bit integer to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 64-bit integer to the stream. + */ INLINE void StreamWriter:: add_uint64(PN_uint64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_float32 -// Access: Published -// Description: Adds a 32-bit single-precision floating-point number -// to the stream. Since this kind of float is not -// necessarily portable across different architectures, -// special care is required. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 32-bit single-precision floating-point number to the stream. Since + * this kind of float is not necessarily portable across different + * architectures, special care is required. + */ INLINE void StreamWriter:: add_float32(float value) { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. + // For now, we assume the float format is portable across all architectures + // we are concerned with. If we come across one that is different, we will + // have to convert. nassertv(sizeof(value) == 4); LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_float64 -// Access: Published -// Description: Adds a 64-bit floating-point number to the stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 64-bit floating-point number to the stream. + */ INLINE void StreamWriter:: add_float64(PN_float64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_int16 -// Access: Published -// Description: Adds a signed 16-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 16-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_int16(PN_int16 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_int32 -// Access: Published -// Description: Adds a signed 32-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 32-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_int32(PN_int32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_int64 -// Access: Published -// Description: Adds a signed 64-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 64-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_int64(PN_int64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_uint16 -// Access: Published -// Description: Adds an unsigned 16-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 16-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_uint16(PN_uint16 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_uint32 -// Access: Published -// Description: Adds an unsigned 32-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 32-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_uint32(PN_uint32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_uint64 -// Access: Published -// Description: Adds an unsigned 64-bit big-endian integer to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 64-bit big-endian integer to the streamWriter. + */ INLINE void StreamWriter:: add_be_uint64(PN_uint64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_float32 -// Access: Published -// Description: Adds a 32-bit single-precision big-endian -// floating-point number to the stream. Since this -// kind of float is not necessarily portable across -// different architectures, special care is required. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 32-bit single-precision big-endian floating-point number to the + * stream. Since this kind of float is not necessarily portable across + * different architectures, special care is required. + */ INLINE void StreamWriter:: add_be_float32(float value) { - // For now, we assume the float format is portable across all - // architectures we are concerned with. If we come across one that - // is different, we will have to convert. + // For now, we assume the float format is portable across all architectures + // we are concerned with. If we come across one that is different, we will + // have to convert. nassertv(sizeof(value) == 4); BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_be_float64 -// Access: Published -// Description: Adds a 64-bit big-endian floating-point number to the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 64-bit big-endian floating-point number to the streamWriter. + */ INLINE void StreamWriter:: add_be_float64(PN_float64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_string -// Access: Published -// Description: Adds a variable-length string to the stream. This -// actually adds a count followed by n bytes. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the stream. This actually adds a count + * followed by n bytes. + */ INLINE void StreamWriter:: add_string(const string &str) { // The max sendable length for a string is 2^16. @@ -341,12 +276,9 @@ add_string(const string &str) { append_data(str); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_string32 -// Access: Published -// Description: Adds a variable-length string to the stream, using a -// 32-bit length field. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the stream, using a 32-bit length field. + */ INLINE void StreamWriter:: add_string32(const string &str) { // Strings always are preceded by their length @@ -356,12 +288,9 @@ add_string32(const string &str) { append_data(str); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_z_string -// Access: Published -// Description: Adds a variable-length string to the stream, as a -// NULL-terminated string. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the stream, as a NULL-terminated string. + */ INLINE void StreamWriter:: add_z_string(string str) { // We must not have any nested null characters in the string. @@ -373,15 +302,11 @@ add_z_string(string str) { add_uint8('\0'); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::add_fixed_string -// Access: Published -// Description: Adds a fixed-length string to the stream. If the -// string given is less than the requested size, this -// will pad the string out with zeroes; if it is greater -// than the requested size, this will silently truncate -// the string. -//////////////////////////////////////////////////////////////////// +/** + * Adds a fixed-length string to the stream. If the string given is less than + * the requested size, this will pad the string out with zeroes; if it is + * greater than the requested size, this will silently truncate the string. + */ INLINE void StreamWriter:: add_fixed_string(const string &str, size_t size) { if (str.length() < size) { @@ -393,45 +318,34 @@ add_fixed_string(const string &str, size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::append_data -// Access: Public -// Description: Appends some more raw data to the end of the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Appends some more raw data to the end of the streamWriter. + */ INLINE void StreamWriter:: append_data(const void *data, size_t size) { _out->write((const char *)data, size); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::append_data -// Access: Public -// Description: Appends some more raw data to the end of the -// streamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Appends some more raw data to the end of the streamWriter. + */ INLINE void StreamWriter:: append_data(const string &data) { append_data(data.data(), data.length()); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::flush -// Access: Published -// Description: Calls flush() on the underlying stream. -//////////////////////////////////////////////////////////////////// +/** + * Calls flush() on the underlying stream. + */ INLINE void StreamWriter:: flush() { _out->flush(); } -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::write -// Access: Published -// Description: A synonym of append_data(). This is useful when -// assigning the StreamWriter to sys.stderr and/or -// sys.stdout in Python. -//////////////////////////////////////////////////////////////////// +/** + * A synonym of append_data(). This is useful when assigning the StreamWriter + * to sys.stderr and/or sys.stdout in Python. + */ INLINE void StreamWriter:: write(const string &data) { append_data(data.data(), data.length()); diff --git a/dtool/src/prc/streamWriter.cxx b/dtool/src/prc/streamWriter.cxx index 838363638d..b636496488 100644 --- a/dtool/src/prc/streamWriter.cxx +++ b/dtool/src/prc/streamWriter.cxx @@ -1,25 +1,21 @@ -// Filename: streamWriter.cxx -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWriter.cxx + * @author drose + * @date 2002-08-04 + */ #include "streamWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::pad_bytes -// Access: Public -// Description: Adds the indicated number of zero bytes to the -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated number of zero bytes to the stream. + */ void StreamWriter:: pad_bytes(size_t size) { nassertv((int)size >= 0); diff --git a/dtool/src/prc/streamWriter.h b/dtool/src/prc/streamWriter.h index eb1f3bcf67..e21dc3cbed 100644 --- a/dtool/src/prc/streamWriter.h +++ b/dtool/src/prc/streamWriter.h @@ -1,16 +1,15 @@ -// Filename: streamWriter.h -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWriter.h + * @author drose + * @date 2002-08-04 + */ #ifndef STREAMWRITER_H #define STREAMWRITER_H @@ -21,15 +20,12 @@ #include "littleEndian.h" #include "bigEndian.h" -//////////////////////////////////////////////////////////////////// -// Class : StreamWriter -// Description : A StreamWriter object is used to write sequential -// binary data directly to an ostream. Its interface is -// very similar to Datagram by design; it's primarily -// intended as a convenience to eliminate the overhead -// of writing bytes to a Datagram and then writing the -// Datagram to a stream. -//////////////////////////////////////////////////////////////////// +/** + * A StreamWriter object is used to write sequential binary data directly to + * an ostream. Its interface is very similar to Datagram by design; it's + * primarily intended as a convenience to eliminate the overhead of writing + * bytes to a Datagram and then writing the Datagram to a stream. + */ class EXPCL_DTOOLCONFIG StreamWriter { public: INLINE StreamWriter(ostream &out); diff --git a/dtool/src/prckeys/makePrcKey.cxx b/dtool/src/prckeys/makePrcKey.cxx index f61fa7a830..57672e5c8a 100644 --- a/dtool/src/prckeys/makePrcKey.cxx +++ b/dtool/src/prckeys/makePrcKey.cxx @@ -1,16 +1,15 @@ -// Filename: makePrcKey.cxx -// Created by: drose (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file makePrcKey.cxx + * @author drose + * @date 2004-10-19 + */ #include "dtoolbase.h" #include "prcKeyRegistry.h" @@ -39,13 +38,11 @@ public: }; typedef pvector KeyNumbers; -//////////////////////////////////////////////////////////////////// -// Function: output_ssl_errors -// Description: A convenience function that is itself a wrapper -// around the OpenSSL convenience function to output the -// recent OpenSSL errors. This function sends the error -// string to cerr. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function that is itself a wrapper around the OpenSSL + * convenience function to output the recent OpenSSL errors. This function + * sends the error string to cerr. + */ void output_ssl_errors() { cerr << "Error occurred in SSL routines.\n"; @@ -66,14 +63,13 @@ output_ssl_errors() { } } -//////////////////////////////////////////////////////////////////// -// Function: output_c_string -// Description: Extracts the data written to the indicated memory bio -// and writes it to the indicated stream, formatting it -// to be compiled into a C or C++ program as a string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the data written to the indicated memory bio and writes it to the + * indicated stream, formatting it to be compiled into a C or C++ program as a + * string. + */ void -output_c_string(ostream &out, const string &string_name, +output_c_string(ostream &out, const string &string_name, size_t index, BIO *mbio) { char *data_ptr; size_t data_size = BIO_get_mem_data(mbio, &data_ptr); @@ -98,7 +94,7 @@ output_c_string(ostream &out, const string &string_name, out << data_ptr[i]; } else { - out << "\\x" << hex << setw(2) << setfill('0') + out << "\\x" << hex << setw(2) << setfill('0') << (unsigned int)(unsigned char)data_ptr[i] << dec; } } @@ -107,14 +103,13 @@ output_c_string(ostream &out, const string &string_name, << "_length = " << data_size << ";\n"; } -//////////////////////////////////////////////////////////////////// -// Function: generate_key -// Description: Generates a new public and private key pair. -//////////////////////////////////////////////////////////////////// +/** + * Generates a new public and private key pair. + */ EVP_PKEY * generate_key() { RSA *rsa = RSA_generate_key(1024, 7, NULL, NULL); - + if (rsa == (RSA *)NULL) { output_ssl_errors(); exit(1); @@ -126,13 +121,11 @@ generate_key() { return pkey; } -//////////////////////////////////////////////////////////////////// -// Function: write_public_keys -// Description: Writes the list of public keys stored in the -// PrcKeyRegistry to the indicated output filename as a -// compilable list of KeyDef entries, suitable for -// passing to PrcKeyRegistry::record_keys(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the list of public keys stored in the PrcKeyRegistry to the + * indicated output filename as a compilable list of KeyDef entries, suitable + * for passing to PrcKeyRegistry::record_keys(). + */ void write_public_keys(Filename outfile) { outfile.set_text(); @@ -183,7 +176,7 @@ write_public_keys(Filename outfile) { time_t generated_time = pkr->get_generated_time(i); if (pkey != (EVP_PKEY *)NULL) { - out << " { prc_pubkey" << i << "_data, prc_pubkey" << i + out << " { prc_pubkey" << i << "_data, prc_pubkey" << i << "_length, " << generated_time << " },\n"; } else { out << " { NULL, 0, 0 },\n"; @@ -194,12 +187,10 @@ write_public_keys(Filename outfile) { << "static const int num_prc_pubkeys = " << num_keys << ";\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: write_private_key -// Description: Generates a C++ program that can be used to sign a -// prc file with the indicated private key into the -// given output filename. -//////////////////////////////////////////////////////////////////// +/** + * Generates a C++ program that can be used to sign a prc file with the + * indicated private key into the given output filename. + */ void write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, const char *pp) { @@ -221,8 +212,8 @@ write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, int write_result; if (pp != NULL && *pp == '\0') { - // The supplied password was the empty string. This means not to - // encrypt the private key. + // The supplied password was the empty string. This means not to encrypt + // the private key. write_result = PEM_write_bio_PKCS8PrivateKey(mbio, pkey, NULL, NULL, 0, NULL, NULL); @@ -242,7 +233,7 @@ write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, BIO_free(mbio); - out << + out << "\n\n" "#define KEY_NUMBER " << n << "\n" "#define KEY_DATA prc_privkey" << n << "_data\n" @@ -253,10 +244,9 @@ write_private_key(EVP_PKEY *pkey, Filename outfile, int n, time_t now, "#include \"signPrcFile_src.cxx\"\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: usage -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void usage() { cerr << @@ -268,18 +258,18 @@ usage() { "key is not secret and will be compiled into libdtool, while the private\n" "key should be safeguarded and will be written into a .cxx file that\n" "can be compiled as a standalone application.\n\n" - + "The output is a public and private key pair for each trust level. The\n" "form of the output for both public and private keys will be compilable\n" "C++ code; see -a and -b, below, for a complete description.\n\n" - + "After the options, the remaining arguments list the individual trust\n" "level keys to generate. For each integer specified, a different key\n" "will be created. There should be one key for each trust level\n" "required; a typical application will only need one or two keys.\n\n" - + "Options:\n\n" - + " -a pub_outfile.cxx\n" " Specifies the name and location of the public key output file\n" " to generate. This file must then be named by the Config.pp\n" @@ -313,10 +303,9 @@ usage() { " programs without having to supply a pass phrase.\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: main -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int main(int argc, char **argv) { extern char *optarg; @@ -416,7 +405,7 @@ main(int argc, char **argv) { exit(1); } if (key._number <= 0) { - cerr << "Key numbers must be greater than 0; you specified " + cerr << "Key numbers must be greater than 0; you specified " << key._number << ".\n"; exit(1); } @@ -460,15 +449,15 @@ main(int argc, char **argv) { ostringstream strm; if (got_hash || n != 1) { - // If we got an explicit hash mark, we always output the number. - // If we did not get an explicit hash mark, we output the number - // only if it is other than 1. + // If we got an explicit hash mark, we always output the number. If we + // did not get an explicit hash mark, we output the number only if it is + // other than 1. strm << prefix << n << suffix; } else { - // If we did not get an explicit hash mark in the filename, we - // omit the number for key 1 (this might be the only key, and - // so maybe the user doesn't require a number designator). + // If we did not get an explicit hash mark in the filename, we omit the + // number for key 1 (this might be the only key, and so maybe the user + // doesn't require a number designator). strm << prefix << suffix; } diff --git a/dtool/src/prckeys/signPrcFile_src.cxx b/dtool/src/prckeys/signPrcFile_src.cxx index 62a9b4c5a3..6ff6b1d4c6 100644 --- a/dtool/src/prckeys/signPrcFile_src.cxx +++ b/dtool/src/prckeys/signPrcFile_src.cxx @@ -1,20 +1,19 @@ -// Filename: signPrcFile_src.cxx -// Created by: drose (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file signPrcFile_src.cxx + * @author drose + * @date 2004-10-19 + */ -// This file is intended to be #included by a generated *_sign?.cxx -// file, one of the output files of make-prc-key. This contains the -// common code to sign a prc file with the given signature. +// This file is intended to be #included by a generated *_sign?.cxx file, one +// of the output files of make-prc-key. This contains the common code to sign +// a prc file with the given signature. #include "dtoolbase.h" @@ -33,13 +32,11 @@ string progname = PROGNAME; -//////////////////////////////////////////////////////////////////// -// Function: output_ssl_errors -// Description: A convenience function that is itself a wrapper -// around the OpenSSL convenience function to output the -// recent OpenSSL errors. This function sends the error -// string to cerr. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function that is itself a wrapper around the OpenSSL + * convenience function to output the recent OpenSSL errors. This function + * sends the error string to cerr. + */ void output_ssl_errors() { cerr << "Error occurred in SSL routines.\n"; @@ -60,14 +57,12 @@ output_ssl_errors() { } } -//////////////////////////////////////////////////////////////////// -// Function: read_prc_line -// Description: Reads a single line of the prc file. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single line of the prc file. + */ void read_prc_line(const string &line, string &data) { - // Strip out lines with this prefix. These are from a previous - // signature. + // Strip out lines with this prefix. These are from a previous signature. if (line.substr(0, 3) == "##!") { return; } @@ -77,15 +72,14 @@ read_prc_line(const string &line, string &data) { return; } -//////////////////////////////////////////////////////////////////// -// Function: read_file -// Description: Reads the entire contents of the file, less any -// previous signatures, to the indicated string. -//////////////////////////////////////////////////////////////////// +/** + * Reads the entire contents of the file, less any previous signatures, to the + * indicated string. + */ void read_file(istream &in, string &data) { - // We avoid getline() here because of its notorious problem with - // last lines that lack a trailing newline character. + // We avoid getline() here because of its notorious problem with last lines + // that lack a trailing newline character. static const size_t buffer_size = 1024; char buffer[buffer_size]; @@ -117,8 +111,7 @@ read_file(istream &in, string &data) { newline = (char *)memchr((void *)start, '\n', buffer_end - start); } - // The remaining text in the buffer is the start of the next - // line. + // The remaining text in the buffer is the start of the next line. length = buffer_end - start; prev_line = string(start, length); } @@ -132,19 +125,16 @@ read_file(istream &in, string &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: output_hex -// Description: Outputs the indicated data stream as a series of hex -// digits. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the indicated data stream as a series of hex digits. + */ void output_hex(ostream &out, const unsigned char *data, size_t size) { } -//////////////////////////////////////////////////////////////////// -// Function: sign_prc -// Description: Applies the signature to the named file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the signature to the named file. + */ void sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { filename.set_text(); @@ -181,7 +171,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { time_t generated_time = GENERATED_TIME; t = localtime(&generated_time); strftime(formatted, 128, "%I:%M %p %B %d, %Y", t); - + strm << "\n" << "##! Signed with level " << KEY_NUMBER << " key generated on " << formatted << "\n" @@ -215,8 +205,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { delete md_ctx; #endif - // Now open the file in write mode and rewrite it with the new - // signature. + // Now open the file in write mode and rewrite it with the new signature. pofstream out; if (!filename.open_write(out)) { cerr << "Unable to rewrite file " << filename << "\n"; @@ -229,7 +218,7 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { for (size_t p = 0; p < sig_size; p += row_width) { out << "##!sig "; -// size_t end = min(sig_size, p + row_width); +// size_t end = min(sig_size, p + row_width); size_t end = sig_size; if(end > p+row_width) end = p+row_width; @@ -245,10 +234,9 @@ sign_prc(Filename filename, bool no_comments, EVP_PKEY *pkey) { } -//////////////////////////////////////////////////////////////////// -// Function: usage -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void usage() { time_t generated_time = GENERATED_TIME; @@ -281,10 +269,9 @@ usage() { " prompted interactively.\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: main -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int main(int argc, char **argv) { preprocess_argv(argc, argv); @@ -351,8 +338,8 @@ main(int argc, char **argv) { BIO_free(mbio); if (pkey == (EVP_PKEY *)NULL) { - // Actually, we're not 100% sure this was the problem, but we - // can't really tell why it failed, and we're 99% sure anyway. + // Actually, we're not 100% sure this was the problem, but we can't really + // tell why it failed, and we're 99% sure anyway. cerr << "Invalid pass phrase.\n"; exit(1); } diff --git a/dtool/src/pystub/pystub.cxx b/dtool/src/pystub/pystub.cxx index 4fa1a4ed6a..4f2e74144a 100644 --- a/dtool/src/pystub/pystub.cxx +++ b/dtool/src/pystub/pystub.cxx @@ -1,16 +1,15 @@ -// Filename: pystub.cxx -// Created by: drose (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pystub.cxx + * @author drose + * @date 2000-08-09 + */ #include "pystub.h" diff --git a/dtool/src/pystub/pystub.h b/dtool/src/pystub/pystub.h index c28da8c21b..d812a98148 100644 --- a/dtool/src/pystub/pystub.h +++ b/dtool/src/pystub/pystub.h @@ -1,42 +1,38 @@ -// Filename: pystub.h -// Created by: drose (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pystub.h + * @author drose + * @date 2000-08-08 + */ #ifndef PYSTUB_H #define PYSTUB_H #include "dtoolbase.h" -// The sole purpose of this header file is to allow a program other -// than Python to load in a module that includes Python wrappers. +// The sole purpose of this header file is to allow a program other than +// Python to load in a module that includes Python wrappers. -// We need this if we build the Panda libraries with Python wrappers, -// but want to run a standalone program with those libraries. +// We need this if we build the Panda libraries with Python wrappers, but want +// to run a standalone program with those libraries. -// This header file just stubs out the Python functions that these -// wrappers will call. You should include this header file in exactly -// one .C file in your project, preferably in the .C file that defines -// main(), and then link with -lpystub. Do not include this header -// file in a .C or .h file that will become part of an .so that might -// eventually link with Python. +// This header file just stubs out the Python functions that these wrappers +// will call. You should include this header file in exactly one .C file in +// your project, preferably in the .C file that defines main(), and then link +// with -lpystub. Do not include this header file in a .C or .h file that +// will become part of an .so that might eventually link with Python. -// You might need to call this function in main() or somewhere to -// force the .so to be linked in--some OS'es try to be smart about not -// pulling in shared libraries whose symbols aren't referenced -// anywhere. +// You might need to call this function in main() or somewhere to force the +// .so to be linked in--some OS'es try to be smart about not pulling in shared +// libraries whose symbols aren't referenced anywhere. EXPCL_PYSTUB void pystub(); #endif - diff --git a/dtool/src/test_interrogate/test_interrogate.cxx b/dtool/src/test_interrogate/test_interrogate.cxx index e328693905..f715a6f366 100644 --- a/dtool/src/test_interrogate/test_interrogate.cxx +++ b/dtool/src/test_interrogate/test_interrogate.cxx @@ -1,16 +1,15 @@ -// Filename: test_interrogate.cxx -// Created by: drose (09Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_interrogate.cxx + * @author drose + * @date 1999-12-09 + */ #include "dtoolbase.h" @@ -35,7 +34,7 @@ indent(ostream &out, int indent_level) { // Indents one or more lines of text, breaking the text up at newline // characters. static ostream & -hanging_indent(ostream &out, const string &text, int first_indent_level, +hanging_indent(ostream &out, const string &text, int first_indent_level, int next_indent_level = -1) { if (next_indent_level < 0) { next_indent_level = first_indent_level; @@ -117,7 +116,7 @@ describe_wrapper(int wrapper, int indent_level) { string comment = interrogate_wrapper_comment(wrapper); hanging_indent(cout, comment, indent_level + 2); } - + if (interrogate_wrapper_caller_manages_return_value(wrapper)) { indent(cout, indent_level + 2) @@ -206,7 +205,7 @@ void describe_make_seq(int make_seq, int indent_level) { indent(cout, indent_level) << "MakeSeq " << interrogate_make_seq_seq_name(make_seq) - << " (" << make_seq << "): " + << " (" << make_seq << "): " << interrogate_make_seq_num_name(make_seq) << ", " << interrogate_make_seq_element_name(make_seq) << "\n"; @@ -286,7 +285,7 @@ describe_type(int type, int indent_level) { string comment = interrogate_type_comment(type); hanging_indent(cout, comment, indent_level + 2); } - + if (interrogate_type_is_nested(type)) { indent(cout, indent_level + 2) << "Nested within "; @@ -570,8 +569,8 @@ main(int argc, char **argv) { string param = argv[i]; if (param.length() > 3 && param.substr(param.length() - 3) == ".in") { - // If the filename ends in ".in", it's an interrogate database - // file, not a shared library--read it directly. + // If the filename ends in ".in", it's an interrogate database file, not + // a shared library--read it directly. interrogate_request_database(param.c_str()); } else { diff --git a/dtool/src/test_interrogate/test_lib.cxx b/dtool/src/test_interrogate/test_lib.cxx index f1c913a218..cab224118c 100644 --- a/dtool/src/test_interrogate/test_lib.cxx +++ b/dtool/src/test_interrogate/test_lib.cxx @@ -1,16 +1,15 @@ -// Filename: test_lib.cxx -// Created by: frang (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_lib.cxx + * @author frang + * @date 2000-06-15 + */ #include "test_lib.h" diff --git a/dtool/src/test_interrogate/test_lib.h b/dtool/src/test_interrogate/test_lib.h index b956411858..9b316c941e 100644 --- a/dtool/src/test_interrogate/test_lib.h +++ b/dtool/src/test_interrogate/test_lib.h @@ -1,16 +1,15 @@ -// Filename: test_lib.h -// Created by: frang (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_lib.h + * @author frang + * @date 2000-06-15 + */ #ifndef __TEST_LIB_H__ #define __TEST_LIB_H__ diff --git a/panda/metalibs/panda/panda.cxx b/panda/metalibs/panda/panda.cxx index 05af696ff1..67620867e3 100644 --- a/panda/metalibs/panda/panda.cxx +++ b/panda/metalibs/panda/panda.cxx @@ -1,7 +1,8 @@ -// Filename: panda.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file panda.cxx + * @author drose + * @date 2000-05-15 + */ #include "panda.h" @@ -13,20 +14,18 @@ #include "config_pstats.h" #endif -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpanda.so/.dll will fail if they inadvertently -// link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpanda.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpanda -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpanda() { init_libpnmimagetypes(); diff --git a/panda/metalibs/panda/panda.h b/panda/metalibs/panda/panda.h index 811fd6b967..93811cf60b 100644 --- a/panda/metalibs/panda/panda.h +++ b/panda/metalibs/panda/panda.h @@ -1,7 +1,8 @@ -// Filename: panda.h -// Created by: drose (2Jan01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file panda.h + * @author drose + * @date 2001-01-02 + */ #ifndef PANDA_H #define PANDA_H @@ -11,4 +12,3 @@ EXPCL_PANDA void init_libpanda(); #endif - diff --git a/panda/metalibs/pandabullet/pandabullet.cxx b/panda/metalibs/pandabullet/pandabullet.cxx index 388df4cb36..4eaa6fcd04 100644 --- a/panda/metalibs/pandabullet/pandabullet.cxx +++ b/panda/metalibs/pandabullet/pandabullet.cxx @@ -1,27 +1,25 @@ -// Filename: pandabullet.cxx -// Created by: enn0x (10May2011) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandabullet.cxx + * @author enn0x + * @date 2011-05-10 + */ #include "pandabullet.h" #include "config_bullet.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandabullet.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandabullet.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandabullet -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandabullet() { init_libbullet(); } - diff --git a/panda/metalibs/pandabullet/pandabullet.h b/panda/metalibs/pandabullet/pandabullet.h index 842db1f646..083904ea0e 100644 --- a/panda/metalibs/pandabullet/pandabullet.h +++ b/panda/metalibs/pandabullet/pandabullet.h @@ -1,7 +1,8 @@ -// Filename: pandabullet.h -// Created by: enn0x (10May2011) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandabullet.h + * @author enn0x + * @date 2011-05-10 + */ #ifndef PANDABULLET_H #define PANDABULLET_H diff --git a/panda/metalibs/pandadx9/pandadx9.cxx b/panda/metalibs/pandadx9/pandadx9.cxx index ae4b747769..8953365225 100644 --- a/panda/metalibs/pandadx9/pandadx9.cxx +++ b/panda/metalibs/pandadx9/pandadx9.cxx @@ -1,37 +1,35 @@ -// Filename: pandadx9.cxx -// Created by: masad (15Jan04) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandadx9.cxx + * @author masad + * @date 2004-01-15 + */ #include "pandadx9.h" #include "config_dxgsg9.h" #include "wdxGraphicsPipe9.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandadx9.dll will fail if they -// inadvertently link with the wrong version of libdtool.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandadx9.dll will fail if they inadvertently link with the wrong +// version of libdtool.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandadx -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandadx9() { init_libdxgsg9(); } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_pandadx9 -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_pandadx9() { return wdxGraphicsPipe9::get_class_type().get_index(); diff --git a/panda/metalibs/pandadx9/pandadx9.h b/panda/metalibs/pandadx9/pandadx9.h index be3e7db827..806ffbda99 100644 --- a/panda/metalibs/pandadx9/pandadx9.h +++ b/panda/metalibs/pandadx9/pandadx9.h @@ -1,7 +1,8 @@ -// Filename: pandadx9.h -// Created by: masad (15Jan04) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandadx9.h + * @author masad + * @date 2004-01-15 + */ #ifndef PANDADX9_H #define PANDADX9_H diff --git a/panda/metalibs/pandaegg/pandaegg.cxx b/panda/metalibs/pandaegg/pandaegg.cxx index 10afe6d392..7bb592e488 100644 --- a/panda/metalibs/pandaegg/pandaegg.cxx +++ b/panda/metalibs/pandaegg/pandaegg.cxx @@ -1,27 +1,26 @@ -// Filename: pandaegg.cxx -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaegg.cxx + * @author drose + * @date 2000-05-16 + */ #include "pandaegg.h" #include "config_egg.h" #include "config_egg2pg.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaegg.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaegg.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandaegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandaegg() { init_libegg(); diff --git a/panda/metalibs/pandaegg/pandaegg.h b/panda/metalibs/pandaegg/pandaegg.h index 64889f46c6..0a11258a17 100644 --- a/panda/metalibs/pandaegg/pandaegg.h +++ b/panda/metalibs/pandaegg/pandaegg.h @@ -1,7 +1,8 @@ -// Filename: pandaegg.h -// Created by: drose (2Jan01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaegg.h + * @author drose + * @date 2001-01-02 + */ #ifndef PANDAEGG_H #define PANDAEGG_H @@ -11,4 +12,3 @@ EXPCL_PANDAEGG void init_libpandaegg(); #endif - diff --git a/panda/metalibs/pandaegg/pandaeggnopg.cxx b/panda/metalibs/pandaegg/pandaeggnopg.cxx index 3461574f91..1b72143237 100644 --- a/panda/metalibs/pandaegg/pandaeggnopg.cxx +++ b/panda/metalibs/pandaegg/pandaeggnopg.cxx @@ -1,26 +1,25 @@ -// Filename: pandaeggnopg.cxx -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaeggnopg.cxx + * @author drose + * @date 2000-05-16 + */ #include "pandaegg.h" #include "config_egg.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaegg.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaegg.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandaegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandaegg() { init_libegg(); diff --git a/panda/metalibs/pandaexpress/pandaexpress.cxx b/panda/metalibs/pandaexpress/pandaexpress.cxx index 1ec56ad688..6c6adc0e77 100644 --- a/panda/metalibs/pandaexpress/pandaexpress.cxx +++ b/panda/metalibs/pandaexpress/pandaexpress.cxx @@ -1,10 +1,11 @@ -// Filename: pandaexpress.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaexpress.cxx + * @author drose + * @date 2000-05-15 + */ -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaexpress.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaexpress.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" diff --git a/panda/metalibs/pandafx/pandafx.cxx b/panda/metalibs/pandafx/pandafx.cxx index b13b9f7036..968ab2f285 100644 --- a/panda/metalibs/pandafx/pandafx.cxx +++ b/panda/metalibs/pandafx/pandafx.cxx @@ -1,26 +1,25 @@ -// Filename: pandafx.cxx -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandafx.cxx + * @author drose + * @date 2001-12-11 + */ #include "pandafx.h" #include "config_distort.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandafx.so/.dll will fail if they inadvertently -// link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandafx.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandafx -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandafx() { init_libdistort(); diff --git a/panda/metalibs/pandafx/pandafx.h b/panda/metalibs/pandafx/pandafx.h index edb9053b2c..bd4f675651 100644 --- a/panda/metalibs/pandafx/pandafx.h +++ b/panda/metalibs/pandafx/pandafx.h @@ -1,7 +1,8 @@ -// Filename: pandafx.h -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandafx.h + * @author drose + * @date 2001-12-11 + */ #ifndef PANDAFX_H #define PANDAFX_H diff --git a/panda/metalibs/pandagl/pandagl.cxx b/panda/metalibs/pandagl/pandagl.cxx index 5a17201827..71b6e83025 100644 --- a/panda/metalibs/pandagl/pandagl.cxx +++ b/panda/metalibs/pandagl/pandagl.cxx @@ -1,7 +1,8 @@ -// Filename: pandagl.cxx -// Created by: drose (15May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagl.cxx + * @author drose + * @date 2000-05-15 + */ #include "pandagl.h" @@ -29,20 +30,18 @@ #error One of HAVE_WGL, HAVE_COCOA, HAVE_CARBON or HAVE_GLX must be defined when compiling pandagl! #endif -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandagl.so/.dll will fail if they inadvertently -// link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandagl.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandagl -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandagl() { init_libglgsg(); @@ -62,11 +61,10 @@ init_libpandagl() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_pandagl -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_pandagl() { #ifdef HAVE_WGL diff --git a/panda/metalibs/pandagl/pandagl.h b/panda/metalibs/pandagl/pandagl.h index 4dcd99a30c..2a25a86587 100644 --- a/panda/metalibs/pandagl/pandagl.h +++ b/panda/metalibs/pandagl/pandagl.h @@ -1,7 +1,8 @@ -// Filename: pandagl.h -// Created by: drose (2Jan01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagl.h + * @author drose + * @date 2001-01-02 + */ #ifndef PANDAGL_H #define PANDAGL_H @@ -12,4 +13,3 @@ EXPCL_PANDAGL void init_libpandagl(); extern "C" EXPCL_PANDAGL int get_pipe_type_pandagl(); #endif - diff --git a/panda/metalibs/pandagles/pandagles.cxx b/panda/metalibs/pandagles/pandagles.cxx index 5b3b2926f0..27053534c6 100644 --- a/panda/metalibs/pandagles/pandagles.cxx +++ b/panda/metalibs/pandagles/pandagles.cxx @@ -1,7 +1,8 @@ -// Filename: pandagles.cxx -// Created by: rdb (8Jun09) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagles.cxx + * @author rdb + * @date 2009-06-08 + */ #include "pandagles.h" @@ -16,20 +17,18 @@ #include "eglGraphicsPipe.h" #endif -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandagles.so/.dll will fail if they inadvertently -// link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandagles.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandagles -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandagles() { init_libglesgsg(); @@ -41,11 +40,10 @@ init_libpandagles() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_pandagles -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_pandagles() { #if defined(ANDROID) diff --git a/panda/metalibs/pandagles/pandagles.h b/panda/metalibs/pandagles/pandagles.h index c4d5df921b..df49d1438e 100644 --- a/panda/metalibs/pandagles/pandagles.h +++ b/panda/metalibs/pandagles/pandagles.h @@ -1,7 +1,8 @@ -// Filename: pandagles.h -// Created by: pro-rsoft (8Jun09) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagles.h + * @author rdb + * @date 2009-06-08 + */ #ifndef PANDAGLES_H #define PANDAGLES_H @@ -12,4 +13,3 @@ EXPCL_PANDAGLES void init_libpandagles(); extern "C" EXPCL_PANDAGLES int get_pipe_type_pandagles(); #endif - diff --git a/panda/metalibs/pandagles2/pandagles2.cxx b/panda/metalibs/pandagles2/pandagles2.cxx index 5404617da0..4810bd60af 100644 --- a/panda/metalibs/pandagles2/pandagles2.cxx +++ b/panda/metalibs/pandagles2/pandagles2.cxx @@ -1,7 +1,8 @@ -// Filename: pandagles2.cxx -// Created by: pro-rsoft (8Jun09) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagles2.cxx + * @author rdb + * @date 2009-06-08 + */ #include "pandagles2.h" @@ -11,31 +12,28 @@ #include "config_egldisplay.h" #include "eglGraphicsPipe.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandagles2.so/.dll will fail if they inadvertently -// link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandagles2.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandagles2 -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandagles2() { init_libgles2gsg(); init_libegldisplay(); } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_pandagles2 -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_pandagles2() { return eglGraphicsPipe::get_class_type().get_index(); diff --git a/panda/metalibs/pandagles2/pandagles2.h b/panda/metalibs/pandagles2/pandagles2.h index d661c9d870..1aa00efe33 100644 --- a/panda/metalibs/pandagles2/pandagles2.h +++ b/panda/metalibs/pandagles2/pandagles2.h @@ -1,7 +1,8 @@ -// Filename: pandagles2.h -// Created by: pro-rsoft (16Jun09) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandagles2.h + * @author rdb + * @date 2009-06-16 + */ #ifndef PANDAGLES2_H #define PANDAGLES2_H @@ -12,4 +13,3 @@ EXPCL_PANDAGLES2 void init_libpandagles2(); extern "C" EXPCL_PANDAGLES2 int get_pipe_type_pandagles2(); #endif - diff --git a/panda/metalibs/pandaode/pandaode.cxx b/panda/metalibs/pandaode/pandaode.cxx index 10b8f5eb77..583b9c3a9d 100644 --- a/panda/metalibs/pandaode/pandaode.cxx +++ b/panda/metalibs/pandaode/pandaode.cxx @@ -1,25 +1,24 @@ -// Filename: pandaode.cxx -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaode.cxx + * @author drose + * @date 2000-05-16 + */ #include "pandaode.h" #include "config_ode.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaode.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaode.so.dll will fail if they inadvertently link with the wrong +// version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandaode -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandaode() { init_libode(); diff --git a/panda/metalibs/pandaode/pandaode.h b/panda/metalibs/pandaode/pandaode.h index ceb0eb2d6d..39eb71e244 100644 --- a/panda/metalibs/pandaode/pandaode.h +++ b/panda/metalibs/pandaode/pandaode.h @@ -1,7 +1,8 @@ -// Filename: pandaode.h -// Created by: drose (2Jan01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaode.h + * @author drose + * @date 2001-01-02 + */ #ifndef PANDAODE_H #define PANDAODE_H diff --git a/panda/metalibs/pandaphysics/pandaphysics.cxx b/panda/metalibs/pandaphysics/pandaphysics.cxx index 4f46a4297a..890d450d47 100644 --- a/panda/metalibs/pandaphysics/pandaphysics.cxx +++ b/panda/metalibs/pandaphysics/pandaphysics.cxx @@ -1,26 +1,25 @@ -// Filename: pandaphysics.cxx -// Created by: drose (16May00) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaphysics.cxx + * @author drose + * @date 2000-05-16 + */ #include "pandaphysics.h" #include "config_physics.h" #include "config_particlesystem.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaphysics.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaphysics.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandaphysics -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandaphysics() { init_libphysics(); diff --git a/panda/metalibs/pandaphysics/pandaphysics.h b/panda/metalibs/pandaphysics/pandaphysics.h index c01ec8b0be..d916c5da21 100644 --- a/panda/metalibs/pandaphysics/pandaphysics.h +++ b/panda/metalibs/pandaphysics/pandaphysics.h @@ -1,7 +1,8 @@ -// Filename: pandaphysics.h -// Created by: drose (2Jan01) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaphysics.h + * @author drose + * @date 2001-01-02 + */ #ifndef PANDAPHYSICS_H #define PANDAPHYSICS_H diff --git a/panda/metalibs/pandaphysx/pandaphysx.cxx b/panda/metalibs/pandaphysx/pandaphysx.cxx index a480b65fdb..fd75ee86b5 100644 --- a/panda/metalibs/pandaphysx/pandaphysx.cxx +++ b/panda/metalibs/pandaphysx/pandaphysx.cxx @@ -1,25 +1,24 @@ -// Filename: pandaphysx.cxx -// Created by: pratt (20Apr2006) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaphysx.cxx + * @author pratt + * @date 2006-04-20 + */ #include "pandaphysx.h" #include "config_physx.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libpandaphysx.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libpandaphysx.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" -//////////////////////////////////////////////////////////////////// -// Function: init_libpandaphysx -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandaphysx() { init_libphysx(); diff --git a/panda/metalibs/pandaphysx/pandaphysx.h b/panda/metalibs/pandaphysx/pandaphysx.h index 1cdaa1a4be..13de6c3c79 100644 --- a/panda/metalibs/pandaphysx/pandaphysx.h +++ b/panda/metalibs/pandaphysx/pandaphysx.h @@ -1,7 +1,8 @@ -// Filename: pandaphysx.h -// Created by: pratt (20Apr2006) -// -//////////////////////////////////////////////////////////////////// +/** + * @file pandaphysx.h + * @author pratt + * @date 2006-04-20 + */ #ifndef PANDAPHYSX_H #define PANDAPHYSX_H diff --git a/panda/src/android/NativeIStream.java b/panda/src/android/NativeIStream.java index 8487dadafb..ffef7b1812 100644 --- a/panda/src/android/NativeIStream.java +++ b/panda/src/android/NativeIStream.java @@ -1,26 +1,24 @@ -// Filename: NativeIStream.java -// Created by: rdb (22Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file NativeIStream.java + * @author rdb + * @date 2013-01-22 + */ package org.panda3d.android; import java.io.InputStream; -//////////////////////////////////////////////////////////////////// -// Class : NativeIStream -// Description : An implementation of InputStream that gets its -// data from a C++ istream pointer, passed as long. -//////////////////////////////////////////////////////////////////// +/** + * An implementation of InputStream that gets its data from a C++ istream + * pointer, passed as long. + */ public class NativeIStream extends InputStream { private long streamPtr = 0; diff --git a/panda/src/android/PandaActivity.java b/panda/src/android/PandaActivity.java index 8bf8ff4612..feba4baa4e 100644 --- a/panda/src/android/PandaActivity.java +++ b/panda/src/android/PandaActivity.java @@ -1,16 +1,15 @@ -// Filename: PandaActivity.java -// Created by: rdb (22Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file PandaActivity.java + * @author rdb + * @date 2013-01-22 + */ package org.panda3d.android; @@ -19,12 +18,10 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import org.panda3d.android.NativeIStream; -//////////////////////////////////////////////////////////////////// -// Class : PandaActivity -// Description : The entry point for a Panda-based activity. Loads -// the Panda libraries and also provides some utility -// functions. -//////////////////////////////////////////////////////////////////// +/** + * The entry point for a Panda-based activity. Loads the Panda libraries and + * also provides some utility functions. + */ public class PandaActivity extends NativeActivity { protected static BitmapFactory.Options readBitmapSize(long istreamPtr) { BitmapFactory.Options options = new BitmapFactory.Options(); @@ -37,7 +34,7 @@ public class PandaActivity extends NativeActivity { protected static Bitmap readBitmap(long istreamPtr, int sampleSize) { BitmapFactory.Options options = new BitmapFactory.Options(); - //options.inPreferredConfig = Bitmap.Config.RGBA_8888; + // options.inPreferredConfig = Bitmap.Config.RGBA_8888; options.inScaled = false; options.inSampleSize = sampleSize; NativeIStream stream = new NativeIStream(istreamPtr); diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index a75f6ceb0e..ebc777ffa3 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -1,16 +1,15 @@ -// Filename: android_main.cxx -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file android_main.cxx + * @author rdb + * @date 2013-01-12 + */ #include "config_android.h" #include "config_util.h" @@ -19,21 +18,18 @@ #include "filename.h" #include "config_display.h" -//#define OPENGLES_1 -//#include "config_androiddisplay.h" +// #define OPENGLES_1 #include "config_androiddisplay.h" #include -//struct android_app* panda_android_app = NULL; +// struct android_app* panda_android_app = NULL; extern int main(int argc, char **argv); -//////////////////////////////////////////////////////////////////// -// Function: android_main -// Description: This function is called by native_app_glue to -// initialize the program. It simply stores the -// android_app object and calls main() normally. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by native_app_glue to initialize the program. It + * simply stores the android_app object and calls main() normally. + */ void android_main(struct android_app* app) { panda_android_app = app; diff --git a/panda/src/android/config_android.cxx b/panda/src/android/config_android.cxx index c8c22d1f03..bf9056c562 100644 --- a/panda/src/android/config_android.cxx +++ b/panda/src/android/config_android.cxx @@ -1,16 +1,15 @@ -// Filename: config_android.cxx -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_android.cxx + * @author rdb + * @date 2013-01-12 + */ #include "config_android.h" #include "pnmFileTypeAndroid.h" @@ -30,13 +29,11 @@ jclass jni_BitmapFactory_Options; jfieldID jni_BitmapFactory_Options_outWidth; jfieldID jni_BitmapFactory_Options_outHeight; -//////////////////////////////////////////////////////////////////// -// Function: init_libandroid -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes -// in this library can be used. Normally, this is -// called by JNI_OnLoad. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally, this is + * called by JNI_OnLoad. + */ void init_libandroid() { PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_global_ptr(); @@ -45,12 +42,10 @@ init_libandroid() { tr->register_type(new PNMFileTypeAndroid); } -//////////////////////////////////////////////////////////////////// -// Function: JNI_OnLoad -// Description: Called by Java when loading this library. -// Initializes the global class references and the -// method IDs. -//////////////////////////////////////////////////////////////////// +/** + * Called by Java when loading this library. Initializes the global class + * references and the method IDs. + */ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { init_libandroid(); @@ -75,11 +70,10 @@ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { return JNI_VERSION_1_4; } -//////////////////////////////////////////////////////////////////// -// Function: JNI_OnUnload -// Description: Called by Java when unloading this library. -// Destroys the global class references. -//////////////////////////////////////////////////////////////////// +/** + * Called by Java when unloading this library. Destroys the global class + * references. + */ void JNI_OnUnload(JavaVM *jvm, void *reserved) { JNIEnv *env = get_jni_env(); diff --git a/panda/src/android/config_android.h b/panda/src/android/config_android.h index 298a6863f7..a67ac2423f 100644 --- a/panda/src/android/config_android.h +++ b/panda/src/android/config_android.h @@ -1,16 +1,15 @@ -// Filename: config_android.h -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_android.h + * @author rdb + * @date 2013-01-12 + */ #ifndef CONFIG_ANDROID_H #define CONFIG_ANDROID_H diff --git a/panda/src/android/jni_NativeIStream.cxx b/panda/src/android/jni_NativeIStream.cxx index 949790bbe3..56e0c8c8bc 100644 --- a/panda/src/android/jni_NativeIStream.cxx +++ b/panda/src/android/jni_NativeIStream.cxx @@ -1,16 +1,15 @@ -// Filename: jni_NativeIStream.cxx -// Created by: rdb (22Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file jni_NativeIStream.cxx + * @author rdb + * @date 2013-01-22 + */ #include @@ -22,12 +21,9 @@ #define EXPORT_JNI extern "C" #endif -//////////////////////////////////////////////////////////////////// -// Function: NativeIStream::nativeGet -// Access: Private, Static -// Description: Reads a single character from the istream. -// Should return -1 on EOF. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single character from the istream. Should return -1 on EOF. + */ EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlong ptr) { std::istream *stream = (std::istream *) ptr; @@ -36,13 +32,10 @@ Java_org_panda3d_android_NativeIStream_nativeGet(JNIEnv *env, jclass clazz, jlon return stream->good() ? ch : -1; } -//////////////////////////////////////////////////////////////////// -// Function: NativeIStream::nativeRead -// Access: Private, Static -// Description: Reads an array of bytes from the istream. Returns -// the actual number of bytes that were read. -// Should return -1 on EOF. -//////////////////////////////////////////////////////////////////// +/** + * Reads an array of bytes from the istream. Returns the actual number of + * bytes that were read. Should return -1 on EOF. + */ EXPORT_JNI jint Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlong ptr, jbyteArray byte_array, jint offset, jint length) { std::istream *stream = (std::istream *) ptr; @@ -63,12 +56,10 @@ Java_org_panda3d_android_NativeIStream_nativeRead(JNIEnv *env, jclass clazz, jlo } } -//////////////////////////////////////////////////////////////////// -// Function: NativeIStream::nativeIgnore -// Access: Private, Static -// Description: Skips ahead N bytes in the stream. Returns the -// actual number of skipped bytes. -//////////////////////////////////////////////////////////////////// +/** + * Skips ahead N bytes in the stream. Returns the actual number of skipped + * bytes. + */ EXPORT_JNI jlong Java_org_panda3d_android_NativeIStream_nativeIgnore(JNIEnv *env, jclass clazz, jlong ptr, jlong offset) { std::istream *stream = (std::istream *) ptr; diff --git a/panda/src/android/pnmFileTypeAndroid.cxx b/panda/src/android/pnmFileTypeAndroid.cxx index 68840a1b83..fae5d147c4 100644 --- a/panda/src/android/pnmFileTypeAndroid.cxx +++ b/panda/src/android/pnmFileTypeAndroid.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeAndroid.cxx -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeAndroid.cxx + * @author rdb + * @date 2013-01-11 + */ #include "pnmFileTypeAndroid.h" @@ -28,97 +27,77 @@ static const int num_extensions_android = sizeof(extensions_android) / sizeof(co TypeHandle PNMFileTypeAndroid::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeAndroid:: PNMFileTypeAndroid() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeAndroid:: get_name() const { return "Android Bitmap"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeAndroid:: get_num_extensions() const { return num_extensions_android; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeAndroid:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_android, string()); return extensions_android[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeAndroid:: has_magic_number() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeAndroid:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeAndroid:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeAndroid); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::make_PNMFileTypeAndroid -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeAndroid:: make_PNMFileTypeAndroid(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/android/pnmFileTypeAndroid.h b/panda/src/android/pnmFileTypeAndroid.h index a98aefec29..cc49fd8f4f 100644 --- a/panda/src/android/pnmFileTypeAndroid.h +++ b/panda/src/android/pnmFileTypeAndroid.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeAndroid.h -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeAndroid.h + * @author rdb + * @date 2013-01-11 + */ #ifndef PNMFILETYPEANDROID_H #define PNMFILETYPEANDROID_H @@ -25,12 +24,10 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeAndroid -// Description : Wrapper class around the Android Bitmap mechanism -// to allow loading images on Android without needing -// libpng or libjpeg. -//////////////////////////////////////////////////////////////////// +/** + * Wrapper class around the Android Bitmap mechanism to allow loading images + * on Android without needing libpng or libjpeg. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeAndroid : public PNMFileType { public: PNMFileTypeAndroid(); diff --git a/panda/src/android/pnmFileTypeAndroidReader.cxx b/panda/src/android/pnmFileTypeAndroidReader.cxx index 8ff2d78a6e..50c69cb59c 100644 --- a/panda/src/android/pnmFileTypeAndroidReader.cxx +++ b/panda/src/android/pnmFileTypeAndroidReader.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeAndroidReader.cxx -// Created by: rdb (22Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeAndroidReader.cxx + * @author rdb + * @date 2013-01-22 + */ #include "pnmFileTypeAndroid.h" @@ -57,11 +56,9 @@ static void conv_rgba4444(uint16_t in, xel &rgb, xelval &alpha) { alpha = scale_table_4[in & 0xF]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeAndroid::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file), _bitmap(NULL) @@ -110,11 +107,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::Reader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeAndroid::Reader:: ~Reader() { if (_bitmap != NULL) { @@ -122,18 +117,14 @@ PNMFileTypeAndroid::Reader:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::Reader::prepare_read -// Access: Public, Virtual -// Description: This method will be called before read_data() or -// read_row() is called. It instructs the reader to -// initialize its data structures as necessary to -// actually perform the read operation. -// -// After this call, _x_size and _y_size should reflect -// the actual size that will be filled by read_data() -// (as possibly modified by set_read_size()). -//////////////////////////////////////////////////////////////////// +/** + * This method will be called before read_data() or read_row() is called. It + * instructs the reader to initialize its data structures as necessary to + * actually perform the read operation. + * + * After this call, _x_size and _y_size should reflect the actual size that + * will be filled by read_data() (as possibly modified by set_read_size()). + */ void PNMFileTypeAndroid::Reader:: prepare_read() { _sample_size = 2; @@ -173,9 +164,9 @@ prepare_read() { _format = info.format; _stride = info.stride; - // Note: we could be setting maxval more appropriately, - // but this only causes texture.cxx to end up rescaling it later. - // Best to do the scaling ourselves, using efficient tables. + // Note: we could be setting maxval more appropriately, but this only causes + // texture.cxx to end up rescaling it later. Best to do the scaling + // ourselves, using efficient tables. _maxval = 255; switch (info.format) { @@ -208,19 +199,15 @@ prepare_read() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeAndroid::Reader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMFileTypeAndroid::Reader:: read_data(xel *rgb, xelval *alpha) { if (!_is_valid) { diff --git a/panda/src/android/pview.cxx b/panda/src/android/pview.cxx index 3f4077830a..60ee5eada6 100644 --- a/panda/src/android/pview.cxx +++ b/panda/src/android/pview.cxx @@ -1,16 +1,15 @@ -// Filename: pview.cxx -// Created by: rdb (12Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pview.cxx + * @author rdb + * @date 2013-01-12 + */ #include "pandaFramework.h" #include "pandaSystem.h" @@ -23,9 +22,9 @@ #include "bamCache.h" #include "virtualFileSystem.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to run pview will fail if it inadvertently links with the -// wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to run +// pview will fail if it inadvertently links with the wrong version of +// libdtool.so.dll. #include "checkPandaVersion.h" @@ -58,8 +57,8 @@ int main(int argc, char **argv) { loading->set_align(TextNode::A_center); loading->set_text("Loading..."); - // Allow a couple of frames to go by so the window will be fully - // created and the text will be visible. + // Allow a couple of frames to go by so the window will be fully created + // and the text will be visible. Thread *current_thread = Thread::get_current_thread(); framework.do_frame(current_thread); framework.do_frame(current_thread); @@ -68,12 +67,9 @@ int main(int argc, char **argv) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); - //if (argc < 2) { - // If we have no arguments, get that trusty old triangle out. - //window->load_default_model(framework.get_models()); - //} else { - // window->load_models(framework.get_models(), argc, argv); - //} + // if (argc < 2) { If we have no arguments, get that trusty old triangle + // out. window->load_default_model(framework.get_models()); } else { + // window->load_models(framework.get_models(), argc, argv); } window->load_model(framework.get_models(), "panda-model.egg"); window->load_model(framework.get_models(), "panda-walk4.egg"); diff --git a/panda/src/androiddisplay/androidGraphicsPipe.I b/panda/src/androiddisplay/androidGraphicsPipe.I index 7af4f55bd2..529e58f47c 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.I +++ b/panda/src/androiddisplay/androidGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: androidGraphicsPipe.I -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsPipe.I + * @author rdb + * @date 2013-01-11 + */ diff --git a/panda/src/androiddisplay/androidGraphicsPipe.cxx b/panda/src/androiddisplay/androidGraphicsPipe.cxx index 53e6240700..00ff6f924f 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.cxx +++ b/panda/src/androiddisplay/androidGraphicsPipe.cxx @@ -1,20 +1,19 @@ -// Filename: androidGraphicsPipe.cxx -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsPipe.cxx + * @author rdb + * @date 2013-01-11 + */ -//#include "androidGraphicsBuffer.h" +// #include "androidGraphicsBuffer.h" #include "androidGraphicsPipe.h" -//#include "androidGraphicsPixmap.h" +// #include "androidGraphicsPixmap.h" #include "androidGraphicsWindow.h" #include "androidGraphicsStateGuardian.h" #include "config_androiddisplay.h" @@ -22,11 +21,9 @@ TypeHandle AndroidGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsPipe:: AndroidGraphicsPipe() { _is_valid = false; @@ -52,11 +49,9 @@ AndroidGraphicsPipe() { _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsPipe:: ~AndroidGraphicsPipe() { if (_egl_display) { @@ -67,54 +62,42 @@ AndroidGraphicsPipe:: } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string AndroidGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// AndroidGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default AndroidGraphicsPipe. + */ PT(GraphicsPipe) AndroidGraphicsPipe:: pipe_constructor() { return new AndroidGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ GraphicsPipe::PreferredWindowThread AndroidGraphicsPipe::get_preferred_window_thread() const { - // Most of the Android NDK window functions can be - // called from any thread. Since we're creating the - // context at open_window time, let's choose "draw". + // Most of the Android NDK window functions can be called from any thread. + // Since we're creating the context at open_window time, let's choose + // "draw". return PWT_app; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) AndroidGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -154,13 +137,13 @@ make_output(const string &name, // Second thing to try: a GLES(2)GraphicsBuffer /*if (retry == 1) { if ((host==0)|| - // (!gl_support_fbo)|| + // (!gl_support_fbo)|| ((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_indexed_color() > 0)|| (fb_prop.get_back_buffers() > 0)|| @@ -169,8 +152,8 @@ make_output(const string &name, return NULL; } } - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we can + // precertify it. if ((eglgsg != 0) && (eglgsg->is_valid()) && (!eglgsg->needs_reset()) && @@ -200,8 +183,8 @@ make_output(const string &name, if (!support_rtt) { if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - // If we require Render-to-Texture, but can't be sure we - // support it, bail. + // If we require Render-to-Texture, but can't be sure we support it, + // bail. return NULL; } } diff --git a/panda/src/androiddisplay/androidGraphicsPipe.h b/panda/src/androiddisplay/androidGraphicsPipe.h index ad53d9af6a..cead149963 100644 --- a/panda/src/androiddisplay/androidGraphicsPipe.h +++ b/panda/src/androiddisplay/androidGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: androidGraphicsPipe.h -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsPipe.h + * @author rdb + * @date 2013-01-11 + */ #ifndef ANDROIDGRAPHICSPIPE_H #define ANDROIDGRAPHICSPIPE_H @@ -21,9 +20,8 @@ #ifdef OPENGLES_2 #include "gles2gsg.h" -// #define NativeDisplayType EGLNativeDisplayType -// #define NativePixmapType EGLNativePixmapType -// #define NativeWindowType EGLNativeWindowType +// #define NativeDisplayType EGLNativeDisplayType #define NativePixmapType +// EGLNativePixmapType #define NativeWindowType EGLNativeWindowType #else #include "glesgsg.h" #endif @@ -35,12 +33,10 @@ class AndroidGraphicsBuffer; class AndroidGraphicsPixmap; class AndroidGraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : AndroidGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL ES graphics windows on an X-based -// (e.g. Unix) client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL ES graphics + * windows on an X-based (e.g. Unix) client. + */ class AndroidGraphicsPipe : public GraphicsPipe { public: AndroidGraphicsPipe(); diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.I b/panda/src/androiddisplay/androidGraphicsStateGuardian.I index 49f95b326f..4851aaccc7 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.I +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.I @@ -1,24 +1,20 @@ -// Filename: androidGraphicsStateGuardian.I -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsStateGuardian.I + * @author rdb + * @date 2013-01-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::get_fb_properties -// Access: Private -// Description: Gets the FrameBufferProperties for all windows and -// buffers that use this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties for all windows and buffers that use this + * GSG. + */ INLINE const FrameBufferProperties &AndroidGraphicsStateGuardian:: get_fb_properties() const { return _fbprops; diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx index 937fa0815b..409baa0a96 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: androidGraphicsStateGuardian.cxx -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsStateGuardian.cxx + * @author rdb + * @date 2013-01-11 + */ #include "androidGraphicsStateGuardian.h" #include "config_androiddisplay.h" @@ -20,11 +19,9 @@ TypeHandle AndroidGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsStateGuardian:: AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, AndroidGraphicsStateGuardian *share_with) : @@ -46,11 +43,9 @@ AndroidGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsStateGuardian:: ~AndroidGraphicsStateGuardian() { if (_context != (EGLContext)NULL) { @@ -62,12 +57,9 @@ AndroidGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::get_properties -// Access: Private -// Description: Gets the FrameBufferProperties to match the -// indicated config. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated config. + */ void AndroidGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, bool &pbuffer_supported, bool &pixmap_supported, @@ -127,12 +119,10 @@ get_properties(FrameBufferProperties &properties, properties.set_force_hardware(1); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::choose_pixel_format -// Access: Private -// Description: Selects a visual or fbconfig for all the windows -// and buffers that use this gsg. -//////////////////////////////////////////////////////////////////// +/** + * Selects a visual or fbconfig for all the windows and buffers that use this + * gsg. + */ void AndroidGraphicsStateGuardian:: choose_pixel_format(const FrameBufferProperties &properties, bool need_pbuffer, bool need_pixmap) { @@ -152,7 +142,8 @@ choose_pixel_format(const FrameBufferProperties &properties, EGL_NONE }; - // First get the number of matching configurations, so we know how much memory to allocate. + // First get the number of matching configurations, so we know how much + // memory to allocate. int num_configs = 0, returned_configs; if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { androiddisplay_cat.error() << "eglChooseConfig failed: " @@ -179,8 +170,9 @@ choose_pixel_format(const FrameBufferProperties &properties, bool pbuffer_supported, pixmap_supported, slow; get_properties(fbprops, pbuffer_supported, pixmap_supported, slow, configs[i]); - // We're not protecting this code by an is_debug() check, because if we do, - // some weird compiler bug appears and somehow makes the quality always 0. + // We're not protecting this code by an is_debug() check, because if we + // do, some weird compiler bug appears and somehow makes the quality + // always 0. const char *pbuffertext = pbuffer_supported ? " (pbuffer)" : ""; const char *pixmaptext = pixmap_supported ? " (pixmap)" : ""; const char *slowtext = slow ? " (slow)" : ""; @@ -222,12 +214,10 @@ choose_pixel_format(const FrameBufferProperties &properties, delete[] configs; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::create_context -// Access: Private -// Description: Creates the context based on the config previously -// obtained in choose_pixel_format. -//////////////////////////////////////////////////////////////////// +/** + * Creates the context based on the config previously obtained in + * choose_pixel_format. + */ bool AndroidGraphicsStateGuardian:: create_context() { if (_context != EGL_NO_CONTEXT) { @@ -253,12 +243,9 @@ create_context() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::destroy_context -// Access: Private -// Description: Destroys the context previously created by -// create_context. -//////////////////////////////////////////////////////////////////// +/** + * Destroys the context previously created by create_context. + */ void AndroidGraphicsStateGuardian:: destroy_context() { if (_context == EGL_NO_CONTEXT) { @@ -276,12 +263,9 @@ destroy_context() { _context = EGL_NO_CONTEXT; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void AndroidGraphicsStateGuardian:: reset() { #ifdef OPENGLES_2 @@ -300,12 +284,10 @@ reset() { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::egl_is_at_least_version -// Access: Public -// Description: Returns true if the runtime GLX version number is at -// least the indicated value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the runtime GLX version number is at least the indicated + * value, false otherwise. + */ bool AndroidGraphicsStateGuardian:: egl_is_at_least_version(int major_version, int minor_version) const { if (_egl_version_major < major_version) { @@ -317,11 +299,9 @@ egl_is_at_least_version(int major_version, int minor_version) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::gl_flush -// Access: Protected, Virtual -// Description: Calls glFlush(). -//////////////////////////////////////////////////////////////////// +/** + * Calls glFlush(). + */ void AndroidGraphicsStateGuardian:: gl_flush() const { #ifdef OPENGLES_2 @@ -331,11 +311,9 @@ gl_flush() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::gl_get_error -// Access: Protected, Virtual -// Description: Returns the result of glGetError(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the result of glGetError(). + */ GLenum AndroidGraphicsStateGuardian:: gl_get_error() const { #ifdef OPENGLES_2 @@ -345,11 +323,9 @@ gl_get_error() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::query_gl_version -// Access: Protected, Virtual -// Description: Queries the runtime version of OpenGL in use. -//////////////////////////////////////////////////////////////////// +/** + * Queries the runtime version of OpenGL in use. + */ void AndroidGraphicsStateGuardian:: query_gl_version() { #ifdef OPENGLES_2 @@ -358,16 +334,16 @@ query_gl_version() { GLESGraphicsStateGuardian::query_gl_version(); #endif - // Calling eglInitialize on an already-initialized display will - // just provide us the version numbers. + // Calling eglInitialize on an already-initialized display will just provide + // us the version numbers. if (!eglInitialize(_egl_display, &_egl_version_major, &_egl_version_minor)) { androiddisplay_cat.error() << "Failed to get EGL version number: " << get_egl_error_string(eglGetError()) << "\n"; } // We output to glesgsg_cat instead of androiddisplay_cat, since this is - // where the GL version has been output, and it's nice to see the - // two of these together. + // where the GL version has been output, and it's nice to see the two of + // these together. #ifdef OPENGLES_2 if (gles2gsg_cat.is_debug()) { gles2gsg_cat.debug() @@ -380,29 +356,22 @@ query_gl_version() { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::get_extra_extensions -// Access: Protected, Virtual -// Description: This may be redefined by a derived class (e.g. glx or -// wgl) to get whatever further extensions strings may -// be appropriate to that interface, in addition to the -// GL extension strings return by glGetString(). -//////////////////////////////////////////////////////////////////// +/** + * This may be redefined by a derived class (e.g. glx or wgl) to get whatever + * further extensions strings may be appropriate to that interface, in + * addition to the GL extension strings return by glGetString(). + */ void AndroidGraphicsStateGuardian:: get_extra_extensions() { save_extensions(eglQueryString(_egl_display, EGL_EXTENSIONS)); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *AndroidGraphicsStateGuardian:: do_get_extension_func(const char *name) { return (void *)eglGetProcAddress(name); diff --git a/panda/src/androiddisplay/androidGraphicsStateGuardian.h b/panda/src/androiddisplay/androidGraphicsStateGuardian.h index d9824ff6fd..15a9f94cc0 100644 --- a/panda/src/androiddisplay/androidGraphicsStateGuardian.h +++ b/panda/src/androiddisplay/androidGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: androidGraphicsStateGuardian.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsStateGuardian.h + * @author rdb + * @date 2009-05-21 + */ #ifndef ANDROIDGRAPHICSSTATEGUARDIAN_H #define ANDROIDGRAPHICSSTATEGUARDIAN_H @@ -18,11 +17,10 @@ #include "pandabase.h" #include "androidGraphicsPipe.h" -//////////////////////////////////////////////////////////////////// -// Class : AndroidGraphicsStateGuardian -// Description : A tiny specialization on GLESGraphicsStateGuardian -// to add some egl-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific + * information. + */ #ifdef OPENGLES_2 class AndroidGraphicsStateGuardian : public GLES2GraphicsStateGuardian { #else diff --git a/panda/src/androiddisplay/androidGraphicsWindow.I b/panda/src/androiddisplay/androidGraphicsWindow.I index f2c85ab105..81b9eba0d9 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.I +++ b/panda/src/androiddisplay/androidGraphicsWindow.I @@ -1,14 +1,12 @@ -// Filename: androidGraphicsWindow.I -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsWindow.I + * @author rdb + * @date 2013-01-11 + */ diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index 80499e0e12..946e602aeb 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: androidGraphicsWindow.cxx -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsWindow.cxx + * @author rdb + * @date 2013-01-11 + */ #include "androidGraphicsWindow.h" #include "androidGraphicsStateGuardian.h" @@ -34,11 +33,9 @@ extern IMPORT_CLASS struct android_app* panda_android_app; TypeHandle AndroidGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsWindow:: AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -62,25 +59,20 @@ AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, add_input_device(device); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AndroidGraphicsWindow:: ~AndroidGraphicsWindow() { destroy_surface(); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool AndroidGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -90,7 +82,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } - //XXX not open yet. + // XXX not open yet. if (_egl_surface == EGL_NO_SURFACE) { return false; } @@ -102,8 +94,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { eglGetCurrentSurface(EGL_READ) == _egl_surface && eglGetCurrentSurface(EGL_DRAW) == _egl_surface && eglGetCurrentContext() == androidgsg->_context) { - // No need to make the context current again. Short-circuit - // this possibly-expensive call. + // No need to make the context current again. Short-circuit this + // possibly-expensive call. } else { // Need to set the context. if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, androidgsg->_context)) { @@ -113,10 +105,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { } } - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) androidgsg->reset_if_new(); if (mode == FM_render) { @@ -128,13 +120,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void AndroidGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -153,25 +143,22 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void AndroidGraphicsWindow:: end_flip() { if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { - // It doesn't appear to be necessary to ensure the graphics - // context is current before flipping the windows, and insisting - // on doing so can be a significant performance hit. + // It doesn't appear to be necessary to ensure the graphics context is + // current before flipping the windows, and insisting on doing so can be a + // significant performance hit. - //make_current(); + // make_current(); if (_egl_surface != EGL_NO_SURFACE) { eglSwapBuffers(_egl_display, _egl_surface); @@ -180,16 +167,13 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void AndroidGraphicsWindow:: process_events() { GraphicsWindow::process_events(); @@ -208,23 +192,18 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The return value is true if the properties are set, -// false if they are ignored. This is mainly useful for -// derived classes to implement extensions to this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The return value is true if the properties are set, false if they are + * ignored. This is mainly useful for derived classes to implement extensions + * to this function. + */ void AndroidGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (_pipe == (GraphicsPipe *)NULL) { @@ -255,12 +234,9 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void AndroidGraphicsWindow:: close_window() { destroy_surface(); @@ -272,16 +248,13 @@ close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool AndroidGraphicsWindow:: open_window() { - // GSG Creation/Initialization + // GSG CreationInitialization AndroidGraphicsStateGuardian *androidgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -289,8 +262,8 @@ open_window() { androidgsg->choose_pixel_format(_fb_properties, false, false); _gsg = androidgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(androidgsg, _gsg, false); if (!androidgsg->get_fb_properties().subsumes(_fb_properties)) { androidgsg = new AndroidGraphicsStateGuardian(_engine, _pipe, androidgsg); @@ -333,11 +306,9 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::destroy_surface -// Access: Protected, Virtual -// Description: Terminates the EGL surface. -//////////////////////////////////////////////////////////////////// +/** + * Terminates the EGL surface. + */ void AndroidGraphicsWindow:: destroy_surface() { if (_egl_surface != EGL_NO_SURFACE) { @@ -356,11 +327,9 @@ destroy_surface() { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::create_surface -// Access: Protected, Virtual -// Description: Creates the EGL surface. -//////////////////////////////////////////////////////////////////// +/** + * Creates the EGL surface. + */ bool AndroidGraphicsWindow:: create_surface() { AndroidGraphicsStateGuardian *androidgsg; @@ -401,10 +370,9 @@ create_surface() { << get_egl_error_string(eglGetError()) << "\n"; } - // Query the size of the surface. - //EGLint width, height; - //eglQuerySurface(_egl_display, _egl_surface, EGL_WIDTH, &width); - //eglQuerySurface(_egl_display, _egl_surface, EGL_HEIGHT, &height); + // Query the size of the surface. EGLint width, height; + // eglQuerySurface(_egl_display, _egl_surface, EGL_WIDTH, &width); + // eglQuerySurface(_egl_display, _egl_surface, EGL_HEIGHT, &height); androidgsg->reset_if_new(); if (!androidgsg->is_valid()) { @@ -415,22 +383,18 @@ create_surface() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::handle_command -// Access: Private, Static -// Description: Android app sends a command from the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Android app sends a command from the main thread. + */ void AndroidGraphicsWindow:: handle_command(struct android_app *app, int32_t command) { AndroidGraphicsWindow* window = (AndroidGraphicsWindow*) app->userData; window->ns_handle_command(command); } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::ns_handle_command -// Access: Private -// Description: Android app sends a command from the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Android app sends a command from the main thread. + */ void AndroidGraphicsWindow:: ns_handle_command(int32_t command) { WindowProperties properties; @@ -438,9 +402,9 @@ ns_handle_command(int32_t command) { switch (command) { case APP_CMD_SAVE_STATE: // The system has asked us to save our current state. Do so. - //engine->app->savedState = malloc(sizeof(struct saved_state)); - //*((struct saved_state*)engine->app->savedState) = engine->state; - //engine->app->savedStateSize = sizeof(struct saved_state); + // engine->app->savedState = malloc(sizeof(struct saved_state)); + // *((struct saved_state*)engine->app->savedState) = engine->state; + // engine->app->savedStateSize = sizeof(struct saved_state); break; case APP_CMD_INIT_WINDOW: // The window is being shown, get it ready. @@ -490,12 +454,9 @@ ns_handle_command(int32_t command) { } } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::handle_input_event -// Access: Private, Static -// Description: Processes an input event. Returns 1 if the event -// was handled, 0 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Processes an input event. Returns 1 if the event was handled, 0 otherwise. + */ int32_t AndroidGraphicsWindow:: handle_input_event(struct android_app* app, AInputEvent *event) { AndroidGraphicsWindow* window = (AndroidGraphicsWindow*) app->userData; @@ -510,11 +471,9 @@ handle_input_event(struct android_app* app, AInputEvent *event) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::handle_keystroke -// Access: Private -// Description: Processes a key event. -//////////////////////////////////////////////////////////////////// +/** + * Processes a key event. + */ int32_t AndroidGraphicsWindow:: handle_key_event(const AInputEvent *event) { /* @@ -554,16 +513,14 @@ handle_key_event(const AInputEvent *event) { } else if (action == AKEY_EVENT_ACTION_UP) { _input_devices[0].button_up(button); } - //TODO getRepeatCount, ACTION_MULTIPLE + // TODO getRepeatCount, ACTION_MULTIPLE return 1; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::handle_motion_event -// Access: Private -// Description: Processes a motion event. -//////////////////////////////////////////////////////////////////// +/** + * Processes a motion event. + */ int32_t AndroidGraphicsWindow:: handle_motion_event(const AInputEvent *event) { int32_t action = AMotionEvent_getAction(event); @@ -583,13 +540,10 @@ handle_motion_event(const AInputEvent *event) { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: AndroidGraphicsWindow::map_button -// Access: Private -// Description: Given an Android keycode, returns an appropriate -// ButtonHandle object, or ButtonHandle::none() if -// a matching ButtonHandle does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Given an Android keycode, returns an appropriate ButtonHandle object, or + * ButtonHandle::none() if a matching ButtonHandle does not exist. + */ ButtonHandle AndroidGraphicsWindow:: map_button(int32_t keycode) { switch (keycode) { diff --git a/panda/src/androiddisplay/androidGraphicsWindow.h b/panda/src/androiddisplay/androidGraphicsWindow.h index d4314e3b21..10ce6de983 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.h +++ b/panda/src/androiddisplay/androidGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: androidGraphicsWindow.h -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file androidGraphicsWindow.h + * @author rdb + * @date 2013-01-11 + */ #ifndef ANDROIDGRAPHICSWINDOW_H #define ANDROIDGRAPHICSWINDOW_H @@ -28,11 +27,9 @@ struct android_app; -//////////////////////////////////////////////////////////////////// -// Class : AndroidGraphicsWindow -// Description : An interface to manage Android windows and their -// appropriate EGL surfaces. -//////////////////////////////////////////////////////////////////// +/** + * An interface to manage Android windows and their appropriate EGL surfaces. + */ class AndroidGraphicsWindow : public GraphicsWindow { public: AndroidGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/androiddisplay/config_androiddisplay.cxx b/panda/src/androiddisplay/config_androiddisplay.cxx index 51990a8484..6b344b6c9d 100644 --- a/panda/src/androiddisplay/config_androiddisplay.cxx +++ b/panda/src/androiddisplay/config_androiddisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_androiddisplay.cxx -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_androiddisplay.cxx + * @author rdb + * @date 2013-01-11 + */ #include "config_androiddisplay.h" #include "androidGraphicsPipe.h" @@ -29,14 +28,12 @@ ConfigureFn(config_androiddisplay) { init_libandroiddisplay(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libandroiddisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libandroiddisplay() { static bool initialized = false; @@ -64,10 +61,9 @@ init_libandroiddisplay() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_egl_error_string -// Description: Returns the given EGL error as string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the given EGL error as string. + */ const string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; diff --git a/panda/src/androiddisplay/config_androiddisplay.h b/panda/src/androiddisplay/config_androiddisplay.h index 949c529e53..29c5c3417c 100644 --- a/panda/src/androiddisplay/config_androiddisplay.h +++ b/panda/src/androiddisplay/config_androiddisplay.h @@ -1,16 +1,15 @@ -// Filename: config_androiddisplay.h -// Created by: rdb (11Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_androiddisplay.h + * @author rdb + * @date 2013-01-11 + */ #ifndef CONFIG_ANDROIDDISPLAY_H #define CONFIG_ANDROIDDISPLAY_H @@ -30,12 +29,12 @@ #ifdef OPENGLES_2 NotifyCategoryDecl(androiddisplay, EXPCL_PANDAGLES2, EXPTP_PANDAGLES2); - + extern EXPCL_PANDAGLES2 void init_libandroiddisplay(); extern EXPCL_PANDAGLES2 const string get_egl_error_string(int error); #else NotifyCategoryDecl(androiddisplay, EXPCL_PANDAGLES, EXPTP_PANDAGLES); - + extern EXPCL_PANDAGLES void init_libandroiddisplay(); extern EXPCL_PANDAGLES const string get_egl_error_string(int error); #endif diff --git a/panda/src/audio/audio.h b/panda/src/audio/audio.h index 0e2ba95d6c..c498834502 100644 --- a/panda/src/audio/audio.h +++ b/panda/src/audio/audio.h @@ -1,16 +1,15 @@ -// Filename: audio.h -// Created by: frang (06Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audio.h + * @author frang + * @date 2000-07-06 + */ #ifndef __AUDIO_H__ #define __AUDIO_H__ diff --git a/panda/src/audio/audioLoadRequest.I b/panda/src/audio/audioLoadRequest.I index 14b33d8d97..21eea901c5 100644 --- a/panda/src/audio/audioLoadRequest.I +++ b/panda/src/audio/audioLoadRequest.I @@ -1,26 +1,22 @@ -// Filename: audioLoadRequest.I -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioLoadRequest.I + * @author drose + * @date 2006-08-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::Constructor -// Access: Published -// Description: Create a new AudioLoadRequest, and add it to the loader -// via load_async(), to begin an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * Create a new AudioLoadRequest, and add it to the loader via load_async(), + * to begin an asynchronous load. + */ INLINE AudioLoadRequest:: -AudioLoadRequest(AudioManager *audio_manager, const string &filename, +AudioLoadRequest(AudioManager *audio_manager, const string &filename, bool positional) : _audio_manager(audio_manager), _filename(filename), @@ -29,58 +25,46 @@ AudioLoadRequest(AudioManager *audio_manager, const string &filename, { } -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::get_audio_manager -// Access: Published -// Description: Returns the AudioManager that will serve this -// asynchronous AudioLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AudioManager that will serve this asynchronous + * AudioLoadRequest. + */ INLINE AudioManager *AudioLoadRequest:: get_audio_manager() const { return _audio_manager; } -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::get_filename -// Access: Published -// Description: Returns the filename associated with this -// asynchronous AudioLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename associated with this asynchronous AudioLoadRequest. + */ INLINE const string &AudioLoadRequest:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::get_positional -// Access: Published -// Description: Returns the positional flag associated with this -// asynchronous AudioLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the positional flag associated with this asynchronous + * AudioLoadRequest. + */ INLINE bool AudioLoadRequest:: get_positional() const { return _positional; } -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. When this returns true, you may -// retrieve the sound loaded by calling get_sound(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + * When this returns true, you may retrieve the sound loaded by calling + * get_sound(). + */ INLINE bool AudioLoadRequest:: is_ready() const { return _is_ready; } -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::get_sound -// Access: Published -// Description: Returns the sound that was loaded asynchronously, if -// any, or NULL if there was an error. It is an error -// to call this unless is_ready() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sound that was loaded asynchronously, if any, or NULL if there + * was an error. It is an error to call this unless is_ready() returns true. + */ INLINE AudioSound *AudioLoadRequest:: get_sound() const { nassertr(_is_ready, NULL); diff --git a/panda/src/audio/audioLoadRequest.cxx b/panda/src/audio/audioLoadRequest.cxx index ee40cfd7a2..c44780b354 100644 --- a/panda/src/audio/audioLoadRequest.cxx +++ b/panda/src/audio/audioLoadRequest.cxx @@ -1,27 +1,24 @@ -// Filename: audioLoadRequest.cxx -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioLoadRequest.cxx + * @author drose + * @date 2006-08-29 + */ #include "audioLoadRequest.h" #include "audioManager.h" TypeHandle AudioLoadRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AudioLoadRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, loads the one sound file. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, loads the one sound file. + */ AsyncTask::DoneStatus AudioLoadRequest:: do_task() { _sound = _audio_manager->get_sound(_filename, _positional); diff --git a/panda/src/audio/audioLoadRequest.h b/panda/src/audio/audioLoadRequest.h index ccb36d7501..7e5fb3d23b 100644 --- a/panda/src/audio/audioLoadRequest.h +++ b/panda/src/audio/audioLoadRequest.h @@ -1,16 +1,15 @@ -// Filename: audioLoadRequest.h -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioLoadRequest.h + * @author drose + * @date 2006-08-29 + */ #ifndef AUDIOLOADREQUEST_H #define AUDIOLOADREQUEST_H @@ -22,21 +21,18 @@ #include "audioSound.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : AudioLoadRequest -// Description : A class object that manages a single asynchronous -// audio load request. This works in conjunction with -// the Loader class defined in pgraph, or really with -// any AsyncTaskManager. Create a new AudioLoadRequest, -// and add it to the loader via load_async(), to begin -// an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * A class object that manages a single asynchronous audio load request. This + * works in conjunction with the Loader class defined in pgraph, or really + * with any AsyncTaskManager. Create a new AudioLoadRequest, and add it to + * the loader via load_async(), to begin an asynchronous load. + */ class EXPCL_PANDA_AUDIO AudioLoadRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(AudioLoadRequest); PUBLISHED: - INLINE AudioLoadRequest(AudioManager *audio_manager, const string &filename, + INLINE AudioLoadRequest(AudioManager *audio_manager, const string &filename, bool positional); INLINE AudioManager *get_audio_manager() const; @@ -56,7 +52,7 @@ private: bool _is_ready; PT(AudioSound) _sound; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -70,7 +66,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -78,4 +74,3 @@ private: #include "audioLoadRequest.I" #endif - diff --git a/panda/src/audio/audioManager.I b/panda/src/audio/audioManager.I index 8e11cb67da..f392c65c63 100644 --- a/panda/src/audio/audioManager.I +++ b/panda/src/audio/audioManager.I @@ -1,14 +1,12 @@ -// Filename: audioManager.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioManager.I + * @author jyelon + * @date 2007-08-01 + */ diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index baff6c3cf4..bbcf6167a3 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -1,17 +1,16 @@ -// Filename: audioManager.cxx -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioManager.cxx + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #include "config_audio.h" #include "audioManager.h" @@ -64,8 +63,8 @@ PT(AudioManager) AudioManager::create_AudioManager() { audio_error(" "<get_config(); @@ -200,108 +181,86 @@ configure_filters(FilterProperties *config) { } } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::update() -// Access: Published, Virtual -// Description: Must be called every frame. Failure to call this -// every frame could cause problems for some audio -// managers. -//////////////////////////////////////////////////////////////////// +/** + * Must be called every frame. Failure to call this every frame could cause + * problems for some audio managers. + */ void AudioManager:: update() { // Intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_set_listener_attributes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager::audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_get_listener_attributes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager::audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_set_distance_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_get_distance_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat AudioManager::audio_3d_get_distance_factor() const { // intentionally blank. return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_set_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_get_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat AudioManager::audio_3d_get_doppler_factor() const { // intentionally blank. return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_set_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager::audio_3d_set_drop_off_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::audio_3d_get_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat AudioManager::audio_3d_get_drop_off_factor() const { // intentionally blank. return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::get_dls_pathname -// Access: Published, Static -// Description: Returns the full pathname to the DLS file, as -// specified by the Config.prc file, or the default for -// the current OS if appropriate. Returns empty string -// if the DLS file is unavailable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to the DLS file, as specified by the Config.prc + * file, or the default for the current OS if appropriate. Returns empty + * string if the DLS file is unavailable. + */ Filename AudioManager:: get_dls_pathname() { Filename dls_filename = audio_dls_file; if (!dls_filename.empty()) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(dls_filename, get_model_path()); - + return dls_filename; } @@ -330,31 +289,25 @@ get_dls_pathname() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioManager:: write(ostream &out) const { out << (*this) << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AudioManager::set_speaker_configuration -// Access: Published -// Description: For use only with Miles. -//////////////////////////////////////////////////////////////////// +/** + * For use only with Miles. + */ void AudioManager:: set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *speaker3, LVecBase3 *speaker4, LVecBase3 *speaker5, LVecBase3 *speaker6, LVecBase3 *speaker7, LVecBase3 *speaker8, LVecBase3 *speaker9) { // intentionally blank diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index 4c0915a67f..262593a1d5 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -1,17 +1,16 @@ -// Filename: audioManager.h -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioManager.h + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #ifndef __AUDIO_MANAGER_H__ #define __AUDIO_MANAGER_H__ @@ -30,19 +29,19 @@ class EXPCL_PANDA_AUDIO AudioManager : public TypedReferenceCount { PUBLISHED: enum SpeakerModeCategory { - // These enumerants line up one-to-one - // with the FMOD SPEAKERMODE enumerants. - SPEAKERMODE_raw, - SPEAKERMODE_mono, - SPEAKERMODE_stereo, - SPEAKERMODE_quad, - SPEAKERMODE_surround, - SPEAKERMODE_5point1, - SPEAKERMODE_7point1, + // These enumerants line up one-to-one with the FMOD SPEAKERMODE + // enumerants. + SPEAKERMODE_raw, + SPEAKERMODE_mono, + SPEAKERMODE_stereo, + SPEAKERMODE_quad, + SPEAKERMODE_surround, + SPEAKERMODE_5point1, + SPEAKERMODE_7point1, SPEAKERMODE_max, SPEAKERMODE_COUNT }; - + enum SpeakerId { SPK_none, @@ -62,101 +61,89 @@ PUBLISHED: SM_sample, SM_stream, }; - + virtual int getSpeakerSetup(); virtual void setSpeakerSetup(SpeakerModeCategory cat); virtual bool configure_filters(FilterProperties *config); - - // Create an AudioManager for each category of sounds you have. - // E.g. - // MySoundEffects = create_AudioManager::AudioManager(); - // MyMusicManager = create_AudioManager::AudioManager(); - // ... - // my_sound = MySoundEffects.get_sound("neatSfx.mp3"); - // my_music = MyMusicManager.get_sound("introTheme.mid"); + + // Create an AudioManager for each category of sounds you have. E.g. + // MySoundEffects = create_AudioManager::AudioManager(); MyMusicManager = + // create_AudioManager::AudioManager(); ... my_sound = + // MySoundEffects.get_sound("neatSfx.mp3"); my_music = + // MyMusicManager.get_sound("introTheme.mid"); static PT(AudioManager) create_AudioManager(); virtual ~AudioManager(); virtual void shutdown(); - - // If you're interested in knowing whether this audio manager - // is valid, here's the call to do it. It is not necessary - // to check whether the audio manager is valid before making other - // calls. You are free to use an invalid sound manager, you - // may get silent sounds from it though. The sound manager and - // the sounds it creates should not crash the application even - // when the objects are not valid. + + // If you're interested in knowing whether this audio manager is valid, + // here's the call to do it. It is not necessary to check whether the audio + // manager is valid before making other calls. You are free to use an + // invalid sound manager, you may get silent sounds from it though. The + // sound manager and the sounds it creates should not crash the application + // even when the objects are not valid. virtual bool is_valid() = 0; - + // Get a sound: virtual PT(AudioSound) get_sound(const string& file_name, bool positional = false, int mode=SM_heuristic) = 0; virtual PT(AudioSound) get_sound(MovieAudio *source, bool positional = false, int mode=SM_heuristic) = 0; PT(AudioSound) get_null_sound(); - // Tell the AudioManager there is no need to keep this one cached. - // This doesn't break any connection between AudioSounds that have - // already given by get_sound() from this manager. It's - // only affecting whether the AudioManager keeps a copy of the sound - // in its pool/cache. + // Tell the AudioManager there is no need to keep this one cached. This + // doesn't break any connection between AudioSounds that have already given + // by get_sound() from this manager. It's only affecting whether the + // AudioManager keeps a copy of the sound in its poolcache. virtual void uncache_sound(const string& file_name) = 0; virtual void clear_cache() = 0; virtual void set_cache_limit(unsigned int count) = 0; virtual unsigned int get_cache_limit() const = 0; - // Control volume: - // FYI: - // If you start a sound with the volume off and turn the volume - // up later, you'll hear the sound playing at that late point. - // 0 = minimum; 1.0 = maximum. - // inits to 1.0. + // Control volume: FYI: If you start a sound with the volume off and turn + // the volume up later, you'll hear the sound playing at that late point. 0 + // = minimum; 1.0 = maximum. inits to 1.0. virtual void set_volume(PN_stdfloat volume) = 0; virtual PN_stdfloat get_volume() const = 0; - - // Turn the manager on or off. - // If you play a sound while the manager is inactive, it won't start. - // If you deactivate the manager while sounds are playing, they'll - // stop. - // If you activate the manager while looping sounds are playing - // (those that have a loop_count of zero), - // they will start playing from the beginning of their loop. - // inits to true. + +/* + * Turn the manager on or off. If you play a sound while the manager is + * inactive, it won't start. If you deactivate the manager while sounds are + * playing, they'll stop. If you activate the manager while looping sounds + * are playing (those that have a loop_count of zero), they will start playing + * from the beginning of their loop. inits to true. + */ virtual void set_active(bool flag) = 0; virtual bool get_active() const = 0; - - // This controls the number of sounds that you allow at once. This - // is more of a user choice -- it avoids talk over and the creation - // of a cacophony. - // It can also be used to help performance. - // 0 == unlimited. - // 1 == mutually exclusive (one sound at a time). Which is an example of: - // n == allow n sounds to be playing at the same time. + + // This controls the number of sounds that you allow at once. This is more + // of a user choice -- it avoids talk over and the creation of a cacophony. + // It can also be used to help performance. 0 == unlimited. 1 == mutually + // exclusive (one sound at a time). Which is an example of: n == allow n + // sounds to be playing at the same time. virtual void set_concurrent_sound_limit(unsigned int limit = 0) = 0; virtual unsigned int get_concurrent_sound_limit() const = 0; - + // This is likely to be a utility function for the concurrent_sound_limit - // options. It is exposed as an API, because it's reasonable that it - // may be useful to be here. It reduces the number of concurrently - // playing sounds to count by some implementation specific means. - // If the number of sounds currently playing is at or below count then - // there is no effect. + // options. It is exposed as an API, because it's reasonable that it may be + // useful to be here. It reduces the number of concurrently playing sounds + // to count by some implementation specific means. If the number of sounds + // currently playing is at or below count then there is no effect. virtual void reduce_sounds_playing_to(unsigned int count) = 0; - // Stop playback on all sounds managed by this manager. - // This is effectively the same as reduce_sounds_playing_to(0), but - // this call may be for efficient on some implementations. + // Stop playback on all sounds managed by this manager. This is effectively + // the same as reduce_sounds_playing_to(0), but this call may be for + // efficient on some implementations. virtual void stop_all_sounds() = 0; - // This should be called every frame. Failure to call could - // cause problems. + // This should be called every frame. Failure to call could cause problems. virtual void update(); - // This controls the "set of ears" that listens to 3D spacialized sound - // px, py, pz are position coordinates. - // vx, vy, vz are a velocity vector in UNITS PER SECOND (default: meters). - // fx, fy and fz are the respective components of a unit forward-vector - // ux, uy and uz are the respective components of a unit up-vector + // This controls the "set of ears" that listens to 3D spacialized sound px, + // py, pz are position coordinates. vx, vy, vz are a velocity vector in + // UNITS PER SECOND (default: meters). fx, fy and fz are the respective + // components of a unit forward-vector ux, uy and uz are the respective + // components of a unit up-vector virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, @@ -165,24 +152,22 @@ PUBLISHED: PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); - - // Control the "relative scale that sets the distance factor" units for 3D spacialized audio. Default is 1.0 - // Fmod uses meters internally, so give a float in Units-per meter - // Don't know what Miles uses. - // Default is 1.0 which is adjust in panda to be feet. + + // Control the "relative scale that sets the distance factor" units for 3D + // spacialized audio. Default is 1.0 Fmod uses meters internally, so give a + // float in Units-per meter Don't know what Miles uses. Default is 1.0 + // which is adjust in panda to be feet. virtual void audio_3d_set_distance_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_distance_factor() const; - // Control the presence of the Doppler effect. Default is 1.0 - // Exaggerated Doppler, use >1.0 - // Diminshed Doppler, use <1.0 + // Control the presence of the Doppler effect. Default is 1.0 Exaggerated + // Doppler, use >1.0 Diminshed Doppler, use <1.0 virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_doppler_factor() const; - // Exaggerate or diminish the effect of distance on sound. Default is 1.0 - // Valid range is 0 to 10 - // Faster drop off, use >1.0 - // Slower drop off, use <1.0 + // Exaggerate or diminish the effect of distance on sound. Default is 1.0 + // Valid range is 0 to 10 Faster drop off, use >1.0 Slower drop off, use + // <1.0 virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_drop_off_factor() const; @@ -199,11 +184,11 @@ public: protected: friend class AudioSound; - + // Avoid adding data members (instance variables) to this mostly abstract - // base class. This allows implementors of various sound systems the - // best flexibility. - + // base class. This allows implementors of various sound systems the best + // flexibility. + static Create_AudioManager_proc* _create_AudioManager; AtomicAdjust::Pointer _null_sound; diff --git a/panda/src/audio/audioSound.I b/panda/src/audio/audioSound.I index 0dd70cb99f..4c95eafe2b 100644 --- a/panda/src/audio/audioSound.I +++ b/panda/src/audio/audioSound.I @@ -1,14 +1,12 @@ -// Filename: audioSound.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioSound.I + * @author jyelon + * @date 2007-08-01 + */ diff --git a/panda/src/audio/audioSound.cxx b/panda/src/audio/audioSound.cxx index 30f8ee8961..9d121e06b0 100644 --- a/panda/src/audio/audioSound.cxx +++ b/panda/src/audio/audioSound.cxx @@ -1,36 +1,31 @@ -// Filename: audioSound.cxx -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioSound.cxx + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #include "audioSound.h" TypeHandle AudioSound::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AudioSound:: ~AudioSound() { } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AudioSound:: AudioSound() { // Intentionally blank. @@ -69,59 +64,47 @@ get_3d_max_distance() const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::get_speaker_mix -// Access: Published -// Description: For use only with FMOD. -//////////////////////////////////////////////////////////////////// +/** + * For use only with FMOD. + */ PN_stdfloat AudioSound:: get_speaker_mix(int speaker) { // intentionally blank return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::set_speaker_mix -// Access: Published -// Description: For use only with FMOD. -//////////////////////////////////////////////////////////////////// +/** + * For use only with FMOD. + */ void AudioSound:: set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright) { // intentionally blank } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::get_speaker_level -// Access: Published -// Description: For use only with Miles. -//////////////////////////////////////////////////////////////////// +/** + * For use only with Miles. + */ PN_stdfloat AudioSound:: get_speaker_level(int index) { // intentionally blank return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::set_speaker_levels -// Access: Published -// Description: For use only with Miles. -//////////////////////////////////////////////////////////////////// +/** + * For use only with Miles. + */ void AudioSound:: set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2, PN_stdfloat level3, PN_stdfloat level4, PN_stdfloat level5, PN_stdfloat level6, PN_stdfloat level7, PN_stdfloat level8, PN_stdfloat level9) { // intentionally blank } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::configure_filters -// Access: Published -// Description: Configure the local DSP filter chain. -// -// There is no guarantee that any given configuration -// will be supported by the implementation. The only -// way to find out what's supported is to call -// configure_filters. If it returns true, the -// configuration is supported. -//////////////////////////////////////////////////////////////////// +/** + * Configure the local DSP filter chain. + * + * There is no guarantee that any given configuration will be supported by the + * implementation. The only way to find out what's supported is to call + * configure_filters. If it returns true, the configuration is supported. + */ bool AudioSound:: configure_filters(FilterProperties *config) { const FilterProperties::ConfigVector &conf = config->get_config(); @@ -132,52 +115,43 @@ configure_filters(FilterProperties *config) { } } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::get_priority -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int AudioSound:: get_priority() { // intentionally blank return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::set_priority -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioSound:: set_priority(int priority) { // intentionally blank ; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioSound:: output(ostream &out) const { out << get_type() << " " << get_name() << " " << status(); } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioSound:: write(ostream &out) const { out << (*this) << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AudioSound::SoundStatus::output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, AudioSound::SoundStatus status) { switch (status) { diff --git a/panda/src/audio/audioSound.h b/panda/src/audio/audioSound.h index 163111e7e8..357df8ad11 100644 --- a/panda/src/audio/audioSound.h +++ b/panda/src/audio/audioSound.h @@ -1,17 +1,16 @@ -// Filename: audioSound.h -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioSound.h + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #ifndef __AUDIOSOUND_H__ #define __AUDIOSOUND_H__ @@ -27,57 +26,45 @@ class EXPCL_PANDA_AUDIO AudioSound : public TypedReferenceCount { PUBLISHED: virtual ~AudioSound(); - // For best compatibility, set the loop_count, - // volume, and balance, prior to calling play(). You may - // set them while they're playing, but it's implementation - // specific whether you get the results. - // - Calling play() a second time on the same sound before it is - // finished will start the sound again (creating a skipping or - // stuttering effect). + // For best compatibility, set the loop_count, volume, and balance, prior to + // calling play(). You may set them while they're playing, but it's + // implementation specific whether you get the results. - Calling play() a + // second time on the same sound before it is finished will start the sound + // again (creating a skipping or stuttering effect). virtual void play() = 0; virtual void stop() = 0; - - // loop: false = play once; true = play forever. - // inits to false. + + // loop: false = play once; true = play forever. inits to false. virtual void set_loop(bool loop=true) = 0; virtual bool get_loop() const = 0; - - // loop_count: 0 = forever; 1 = play once; n = play n times. - // inits to 1. + + // loop_count: 0 = forever; 1 = play once; n = play n times. inits to 1. virtual void set_loop_count(unsigned long loop_count=1) = 0; virtual unsigned long get_loop_count() const = 0; - - // Control time position within the sound. - // This is similar (in concept) to the seek position within - // a file. - // time in seconds: 0 = beginning; length() = end. - // inits to 0.0. - // - The current time position will not change while the sound is - // playing; you must call play() again to effect the change. To - // play the same sound from a time offset a second time, - // explicitly set the time position again. When looping, the - // second and later loops will start from the beginning of the - // sound. - // - If a sound is playing, calling get_time() repeatedly will - // return different results over time. e.g.: - // PN_stdfloat percent_complete = s.get_time() / s.length(); + +/* + * Control time position within the sound. This is similar (in concept) to + * the seek position within a file. time in seconds: 0 = beginning; length() + * = end. inits to 0.0. - The current time position will not change while the + * sound is playing; you must call play() again to effect the change. To play + * the same sound from a time offset a second time, explicitly set the time + * position again. When looping, the second and later loops will start from + * the beginning of the sound. - If a sound is playing, calling get_time() + * repeatedly will return different results over time. e.g.: PN_stdfloat + * percent_complete = s.get_time() s.length(); + */ virtual void set_time(PN_stdfloat start_time=0.0) = 0; virtual PN_stdfloat get_time() const = 0; - - // 0 = minimum; 1.0 = maximum. - // inits to 1.0. + + // 0 = minimum; 1.0 = maximum. inits to 1.0. virtual void set_volume(PN_stdfloat volume=1.0) = 0; virtual PN_stdfloat get_volume() const = 0; - - // -1.0 is hard left - // 0.0 is centered - // 1.0 is hard right - // inits to 0.0. + + // -1.0 is hard left 0.0 is centered 1.0 is hard right inits to 0.0. virtual void set_balance(PN_stdfloat balance_right=0.0) = 0; virtual PN_stdfloat get_balance() const = 0; - - // play_rate is any positive PN_stdfloat value. - // inits to 1.0. + + // play_rate is any positive PN_stdfloat value. inits to 1.0. virtual void set_play_rate(PN_stdfloat play_rate=1.0f) = 0; virtual PN_stdfloat get_play_rate() const = 0; @@ -85,20 +72,20 @@ PUBLISHED: virtual void set_active(bool flag=true) = 0; virtual bool get_active() const = 0; - // Set (or clear) the event that will be thrown when the sound - // finishes playing. To clear the event, pass an empty string. + // Set (or clear) the event that will be thrown when the sound finishes + // playing. To clear the event, pass an empty string. virtual void set_finished_event(const string& event) = 0; virtual const string& get_finished_event() const = 0; - + // There is no set_name(), this is intentional. virtual const string& get_name() const = 0; - + // return: playing time in seconds. virtual PN_stdfloat length() const = 0; - // Controls the position of this sound's emitter. - // px, py and pz are the emitter's position. - // vx, vy and vz are the emitter's velocity in UNITS PER SECOND (default: meters). + // Controls the position of this sound's emitter. px, py and pz are the + // emitter's position. vx, vy and vz are the emitter's velocity in UNITS + // PER SECOND (default: meters). virtual void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); virtual void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, @@ -106,24 +93,20 @@ PUBLISHED: // Controls the distance (in units) that this sound begins to fall off. - // Also affects the rate it falls off. - // Default is 1.0 - // Closer/Faster, <1.0 - // Farther/Slower, >1.0 + // Also affects the rate it falls off. Default is 1.0 CloserFaster, <1.0 + // FartherSlower, >1.0 virtual void set_3d_min_distance(PN_stdfloat dist); virtual PN_stdfloat get_3d_min_distance() const; - // Controls the maximum distance (in units) that this sound stops falling off. - // The sound does not stop at that point, it just doesn't get any quieter. - // You should rarely need to adjust this. - // Default is 1000000000.0 + // Controls the maximum distance (in units) that this sound stops falling + // off. The sound does not stop at that point, it just doesn't get any + // quieter. You should rarely need to adjust this. Default is 1000000000.0 virtual void set_3d_max_distance(PN_stdfloat dist); virtual PN_stdfloat get_3d_max_distance() const; // *_speaker_mix and *_speaker_level(s) serve the same purpose. - // *_speaker_mix is for use with FMOD. - // *_speaker_level(s) is for use with Miles. - // Both interfaces exist because of a significant difference in the + // *_speaker_mix is for use with FMOD. *_speaker_level(s) is for use with + // Miles. Both interfaces exist because of a significant difference in the // two APIs. Hopefully the difference can be reconciled into a single // interface at some point. virtual PN_stdfloat get_speaker_mix(int speaker); diff --git a/panda/src/audio/config_audio.cxx b/panda/src/audio/config_audio.cxx index b967913f70..e59b3c73ef 100644 --- a/panda/src/audio/config_audio.cxx +++ b/panda/src/audio/config_audio.cxx @@ -1,16 +1,15 @@ -// Filename: config_audio.cxx -// Created by: cary (22Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_audio.cxx + * @author cary + * @date 2000-09-22 + */ #include "config_audio.h" #include "dconfig.h" @@ -25,29 +24,29 @@ Configure(config_audio); NotifyCategoryDef(audio, ""); -ConfigVariableBool audio_active +ConfigVariableBool audio_active ("audio-active", true); -ConfigVariableInt audio_cache_limit +ConfigVariableInt audio_cache_limit ("audio-cache-limit", 15, PRC_DESC("The number of sounds in the cache.")); ConfigVariableString audio_library_name ("audio-library-name", "null"); -ConfigVariableDouble audio_volume +ConfigVariableDouble audio_volume ("audio-volume", 1.0f); // Config variables for OpenAL: -ConfigVariableDouble audio_doppler_factor -("audio-doppler-factor", 1.0f); +ConfigVariableDouble audio_doppler_factor +("audio-doppler-factor", 1.0f); -ConfigVariableDouble audio_distance_factor -("audio-distance-factor", 1.0f); +ConfigVariableDouble audio_distance_factor +("audio-distance-factor", 1.0f); -ConfigVariableDouble audio_drop_off_factor -("audio-drop-off-factor", 1.0f); +ConfigVariableDouble audio_drop_off_factor +("audio-drop-off-factor", 1.0f); ConfigVariableDouble audio_buffering_seconds ("audio-buffering-seconds", 3.0f, @@ -70,9 +69,9 @@ ConfigVariableInt audio_preload_threshold // Unknown -ConfigVariableInt audio_min_hw_channels -("audio-min-hw-channels", 15, -PRC_DESC("Guarantee this many channels on the local sound card, or just " +ConfigVariableInt audio_min_hw_channels +("audio-min-hw-channels", 15, +PRC_DESC("Guarantee this many channels on the local sound card, or just " "play EVERYTHING in software.")); // Config variables for Fmod: @@ -82,7 +81,7 @@ ConfigVariableInt fmod_number_of_sound_channels PRC_DESC("Guarantee this many channels you will have with FMOD. AKA the max number of sounds you can play at one time.") ); ConfigVariableBool fmod_use_surround_sound -("fmod-use-surround-sound", false, +("fmod-use-surround-sound", false, PRC_DESC("Determines if an FMOD Flavor of PANDA use 5.1 Surround Sound or not. " "This variable is deprecated and should not be used. Use the enum " "variable fmod-speaker-mode instead.")); @@ -95,10 +94,10 @@ ConfigVariableEnum fmod_speaker_mode // Config variables for Miles: -ConfigVariableBool audio_software_midi +ConfigVariableBool audio_software_midi ("audio-software-midi", true); -ConfigVariableFilename audio_dls_file +ConfigVariableFilename audio_dls_file ("audio-dls-file", Filename(), PRC_DESC("Specifies a DLS file that defines an instrument set to load " "for MIDI file playback. If this is not specified, the sound " @@ -106,18 +105,18 @@ ConfigVariableFilename audio_dls_file "one is available; the likely success of this depends on the " "operating system.")); -ConfigVariableBool audio_play_midi +ConfigVariableBool audio_play_midi ("audio-play-midi", true); -ConfigVariableBool audio_play_wave +ConfigVariableBool audio_play_wave ("audio-play-wave", true); -ConfigVariableBool audio_play_mp3 +ConfigVariableBool audio_play_mp3 ("audio-play-mp3", true); -ConfigVariableInt audio_output_rate +ConfigVariableInt audio_output_rate ("audio-output-rate", 22050); - + ConfigVariableInt audio_output_bits ("audio-output-bits", 16); diff --git a/panda/src/audio/config_audio.h b/panda/src/audio/config_audio.h index 521bd7b656..bb84a9bf2d 100644 --- a/panda/src/audio/config_audio.h +++ b/panda/src/audio/config_audio.h @@ -1,16 +1,15 @@ -// Filename: config_audio.h -// Created by: cary (22Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_audio.h + * @author cary + * @date 2000-09-22 + */ #ifndef __CONFIG_AUDIO_H__ #define __CONFIG_AUDIO_H__ @@ -34,7 +33,7 @@ extern EXPCL_PANDA_AUDIO ConfigVariableInt audio_cache_limit; extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_volume; extern EXPCL_PANDA_AUDIO ConfigVariableFilename audio_dls_file; -//We Need This one. +// We Need This one. extern EXPCL_PANDA_AUDIO ConfigVariableString audio_library_name; // Config vars for Fmod: @@ -62,9 +61,9 @@ extern EXPCL_PANDA_AUDIO ConfigVariableEnum fmod_speaker_mode; // Config vars for OpenAL: -extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_doppler_factor; -extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_distance_factor; -extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_drop_off_factor; +extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_doppler_factor; +extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_distance_factor; +extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_drop_off_factor; extern EXPCL_PANDA_AUDIO ConfigVariableDouble audio_buffering_seconds; extern EXPCL_PANDA_AUDIO ConfigVariableInt audio_preload_threshold; diff --git a/panda/src/audio/filterProperties.I b/panda/src/audio/filterProperties.I index 51f1171540..510f90d426 100644 --- a/panda/src/audio/filterProperties.I +++ b/panda/src/audio/filterProperties.I @@ -1,151 +1,121 @@ -// Filename: filterProperties.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filterProperties.I + * @author jyelon + * @date 2007-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::clear -// Access: Published -// Description: Removes all DSP postprocessing. -//////////////////////////////////////////////////////////////////// +/** + * Removes all DSP postprocessing. + */ INLINE void FilterProperties:: clear() { _config.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::apply_lowpass -// Access: Published -// Description: Add a lowpass filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a lowpass filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_lowpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q) { add_filter(FT_lowpass, cutoff_freq, resonance_q); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_highpass -// Access: Published -// Description: Add a highpass filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a highpass filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_highpass(PN_stdfloat cutoff_freq, PN_stdfloat resonance_q) { add_filter(FT_highpass, cutoff_freq, resonance_q); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_echo -// Access: Published -// Description: Add a echo filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a echo filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_echo(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat delay, PN_stdfloat decayratio) { add_filter(FT_echo, drymix, wetmix, delay, decayratio); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_flange -// Access: Published -// Description: Add a flange filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a flange filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_flange(PN_stdfloat drymix, PN_stdfloat wetmix, PN_stdfloat depth, PN_stdfloat rate) { add_filter(FT_flange, drymix, wetmix, depth, rate); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_distort -// Access: Published -// Description: Add a distort filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a distort filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_distort(PN_stdfloat level) { add_filter(FT_distort, level); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_normalize -// Access: Published -// Description: Add a normalize filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a normalize filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_normalize(PN_stdfloat fadetime, PN_stdfloat threshold, PN_stdfloat maxamp) { add_filter(FT_normalize, fadetime, threshold, maxamp); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_parameq -// Access: Published -// Description: Add a parameq filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a parameq filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_parameq(PN_stdfloat center_freq, PN_stdfloat bandwidth, PN_stdfloat gain) { add_filter(FT_parameq, center_freq, bandwidth, gain); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_pitchshift -// Access: Published -// Description: Add a pitchshift filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a pitchshift filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_pitchshift(PN_stdfloat pitch, PN_stdfloat fftsize, PN_stdfloat overlap) { add_filter(FT_pitchshift, pitch, fftsize, overlap); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_chorus -// Access: Published -// Description: Add a chorus filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a chorus filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_chorus(PN_stdfloat drymix, PN_stdfloat wet1, PN_stdfloat wet2, PN_stdfloat wet3, PN_stdfloat delay, PN_stdfloat rate, PN_stdfloat depth) { add_filter(FT_chorus, drymix, wet1, wet2, wet3, delay, rate, depth); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_sfxreverb -// Access: Published -// Description: Add a reverb filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a reverb filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_sfxreverb(PN_stdfloat drylevel, PN_stdfloat room, PN_stdfloat roomhf, PN_stdfloat decaytime, - PN_stdfloat decayhfratio, PN_stdfloat reflectionslevel, PN_stdfloat reflectionsdelay, - PN_stdfloat reverblevel, PN_stdfloat reverbdelay, PN_stdfloat diffusion, - PN_stdfloat density, PN_stdfloat hfreference, PN_stdfloat roomlf, PN_stdfloat lfreference) { + PN_stdfloat decayhfratio, PN_stdfloat reflectionslevel, PN_stdfloat reflectionsdelay, + PN_stdfloat reverblevel, PN_stdfloat reverbdelay, PN_stdfloat diffusion, + PN_stdfloat density, PN_stdfloat hfreference, PN_stdfloat roomlf, PN_stdfloat lfreference) { add_filter(FT_sfxreverb, drylevel, room, roomhf, decaytime, decayhfratio, reflectionslevel, reflectionsdelay, - reverblevel, reverbdelay, diffusion, density, hfreference, roomlf, lfreference); + reverblevel, reverbdelay, diffusion, density, hfreference, roomlf, lfreference); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_compress -// Access: Published -// Description: Add a compress filter to the end of the DSP chain. -//////////////////////////////////////////////////////////////////// +/** + * Add a compress filter to the end of the DSP chain. + */ INLINE void FilterProperties:: add_compress(PN_stdfloat threshold, PN_stdfloat attack, PN_stdfloat release, PN_stdfloat gainmakeup) { add_filter(FT_compress, threshold, attack, release, gainmakeup); } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::get_config -// Access: Published -// Description: Intended for use by AudioManager and AudioSound -// implementations: allows access to the config vector. -//////////////////////////////////////////////////////////////////// +/** + * Intended for use by AudioManager and AudioSound implementations: allows + * access to the config vector. + */ INLINE const FilterProperties::ConfigVector &FilterProperties:: get_config() { return _config; } - - diff --git a/panda/src/audio/filterProperties.cxx b/panda/src/audio/filterProperties.cxx index 48c51e3f91..319db5414c 100644 --- a/panda/src/audio/filterProperties.cxx +++ b/panda/src/audio/filterProperties.cxx @@ -1,50 +1,43 @@ -// Filename: filterProperties.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filterProperties.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "filterProperties.h" TypeHandle FilterProperties::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FilterProperties:: FilterProperties() { } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FilterProperties:: ~FilterProperties() { } -//////////////////////////////////////////////////////////////////// -// Function: FilterProperties::add_filter -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FilterProperties:: add_filter(FilterType t, PN_stdfloat a, PN_stdfloat b, PN_stdfloat c, PN_stdfloat d, - PN_stdfloat e, PN_stdfloat f, PN_stdfloat g, PN_stdfloat h, - PN_stdfloat i, PN_stdfloat j, PN_stdfloat k, PN_stdfloat l, - PN_stdfloat m, PN_stdfloat n) { + PN_stdfloat e, PN_stdfloat f, PN_stdfloat g, PN_stdfloat h, + PN_stdfloat i, PN_stdfloat j, PN_stdfloat k, PN_stdfloat l, + PN_stdfloat m, PN_stdfloat n) { FilterConfig conf; conf._type = t; conf._a = a; @@ -63,4 +56,3 @@ add_filter(FilterType t, PN_stdfloat a, PN_stdfloat b, PN_stdfloat c, PN_stdfloa conf._n = n; _config.push_back(conf); } - diff --git a/panda/src/audio/filterProperties.h b/panda/src/audio/filterProperties.h index 19d7f0feb6..3eacc24b50 100644 --- a/panda/src/audio/filterProperties.h +++ b/panda/src/audio/filterProperties.h @@ -1,16 +1,15 @@ -// Filename: filterProperties.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filterProperties.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FILTERPROPERTIES_H #define FILTERPROPERTIES_H @@ -18,10 +17,9 @@ #include "config_audio.h" #include "typedReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : FilterProperties -// Description : Stores a configuration for a set of audio DSP filters. -//////////////////////////////////////////////////////////////////// +/** + * Stores a configuration for a set of audio DSP filters. + */ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { PUBLISHED: @@ -38,9 +36,9 @@ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { INLINE void add_pitchshift(PN_stdfloat pitch, PN_stdfloat fftsize, PN_stdfloat overlap); INLINE void add_chorus(PN_stdfloat drymix, PN_stdfloat wet1, PN_stdfloat wet2, PN_stdfloat wet3, PN_stdfloat delay, PN_stdfloat rate, PN_stdfloat depth); INLINE void add_sfxreverb(PN_stdfloat drylevel=0, PN_stdfloat room=-10000, PN_stdfloat roomhf=0, PN_stdfloat decaytime=1, - PN_stdfloat decayhfratio=0.5, PN_stdfloat reflectionslevel=-10000, PN_stdfloat reflectionsdelay=0.02, - PN_stdfloat reverblevel=0, PN_stdfloat reverbdelay=0.04, PN_stdfloat diffusion=100, - PN_stdfloat density=100, PN_stdfloat hfreference=5000, PN_stdfloat roomlf=0, PN_stdfloat lfreference=250); + PN_stdfloat decayhfratio=0.5, PN_stdfloat reflectionslevel=-10000, PN_stdfloat reflectionsdelay=0.02, + PN_stdfloat reverblevel=0, PN_stdfloat reverbdelay=0.04, PN_stdfloat diffusion=100, + PN_stdfloat density=100, PN_stdfloat hfreference=5000, PN_stdfloat roomlf=0, PN_stdfloat lfreference=250); INLINE void add_compress(PN_stdfloat threshold, PN_stdfloat attack, PN_stdfloat release, PN_stdfloat gainmakeup); public: @@ -66,16 +64,16 @@ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { PN_stdfloat _i,_j,_k,_l; PN_stdfloat _m,_n; }; - + typedef pvector ConfigVector; - - private: + + private: void add_filter(FilterType t, PN_stdfloat a=0, PN_stdfloat b=0, PN_stdfloat c=0, PN_stdfloat d=0, - PN_stdfloat e=0, PN_stdfloat f=0, PN_stdfloat g=0, PN_stdfloat h=0, - PN_stdfloat i=0, PN_stdfloat j=0, PN_stdfloat k=0, PN_stdfloat l=0, - PN_stdfloat m=0, PN_stdfloat n=0); + PN_stdfloat e=0, PN_stdfloat f=0, PN_stdfloat g=0, PN_stdfloat h=0, + PN_stdfloat i=0, PN_stdfloat j=0, PN_stdfloat k=0, PN_stdfloat l=0, + PN_stdfloat m=0, PN_stdfloat n=0); ConfigVector _config; - + public: INLINE const ConfigVector &get_config(); @@ -95,7 +93,7 @@ class EXPCL_PANDA_AUDIO FilterProperties : public TypedReferenceCount { private: static TypeHandle _type_handle; -}; +}; #include "filterProperties.I" diff --git a/panda/src/audio/nullAudioManager.cxx b/panda/src/audio/nullAudioManager.cxx index 8c3f53d51e..f7126e9b7b 100644 --- a/panda/src/audio/nullAudioManager.cxx +++ b/panda/src/audio/nullAudioManager.cxx @@ -1,299 +1,242 @@ -// Filename: nullAudioManager.cxx -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nullAudioManager.cxx + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #include "nullAudioManager.h" TypeHandle NullAudioManager::_type_handle; -//namespace { - //static const string blank=""; - //static PN_stdfloat no_listener_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; -//} +// namespace { static const string blank=""; static PN_stdfloat +// no_listener_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f, +// 0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::NullAudioManager -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NullAudioManager:: NullAudioManager() { audio_info("NullAudioManager"); } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::~NullAudioManager -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NullAudioManager:: ~NullAudioManager() { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::is_valid -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool NullAudioManager:: is_valid() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_sound -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(AudioSound) NullAudioManager:: get_sound(const string&, bool positional, int mode) { return get_null_sound(); } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_sound -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(AudioSound) NullAudioManager:: get_sound(MovieAudio *sound, bool positional, int mode) { return get_null_sound(); } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::uncache_sound -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: uncache_sound(const string&) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::uncache_all_sounds -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: clear_cache() { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::set_cache_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: set_cache_limit(unsigned int) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_cache_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int NullAudioManager:: get_cache_limit() const { // intentionally blank. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::set_volume -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: set_volume(PN_stdfloat) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_volume -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat NullAudioManager:: get_volume() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::set_play_rate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: set_play_rate(PN_stdfloat) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_play_rate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat NullAudioManager:: get_play_rate() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::set_active -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: set_active(bool) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_active -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool NullAudioManager:: get_active() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::set_concurrent_sound_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: set_concurrent_sound_limit(unsigned int) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::get_concurrent_sound_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int NullAudioManager:: get_concurrent_sound_limit() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::reduce_sounds_playing_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: reduce_sounds_playing_to(unsigned int) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::stop_all_sounds -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: stop_all_sounds() { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_set_listener_attributes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_get_listener_attributes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_set_distance_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: audio_3d_set_distance_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_get_distance_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat NullAudioManager:: audio_3d_get_distance_factor() const { // intentionally blank. return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_set_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: audio_3d_set_doppler_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_get_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat NullAudioManager:: audio_3d_get_doppler_factor() const { // intentionally blank. return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_set_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NullAudioManager:: audio_3d_set_drop_off_factor(PN_stdfloat factor) { // intentionally blank. } -//////////////////////////////////////////////////////////////////// -// Function: NullAudioManager::audio_3d_get_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat NullAudioManager:: audio_3d_get_drop_off_factor() const { // intentionally blank. return 0.0f; } - diff --git a/panda/src/audio/nullAudioManager.h b/panda/src/audio/nullAudioManager.h index d86d913858..cebf6ab08a 100644 --- a/panda/src/audio/nullAudioManager.h +++ b/panda/src/audio/nullAudioManager.h @@ -1,17 +1,16 @@ -// Filename: nullAudioManager.h -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nullAudioManager.h + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #ifndef __NULL_AUDIO_MANAGER_H__ #define __NULL_AUDIO_MANAGER_H__ @@ -20,16 +19,16 @@ #include "nullAudioSound.h" class EXPCL_PANDA_AUDIO NullAudioManager : public AudioManager { - // All of these methods are stubbed out to some degree. - // If you're looking for a starting place for a new AudioManager, - // please consider looking at the milesAudioManager. - + // All of these methods are stubbed out to some degree. If you're looking + // for a starting place for a new AudioManager, please consider looking at + // the milesAudioManager. + public: NullAudioManager(); virtual ~NullAudioManager(); - + virtual bool is_valid(); - + virtual PT(AudioSound) get_sound(const string&, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); virtual void uncache_sound(const string&); @@ -42,7 +41,7 @@ public: virtual void set_play_rate(PN_stdfloat); virtual PN_stdfloat get_play_rate() const; - + virtual void set_active(bool); virtual bool get_active() const; @@ -61,7 +60,7 @@ public: PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); - + virtual void audio_3d_set_distance_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_distance_factor() const; diff --git a/panda/src/audio/nullAudioSound.cxx b/panda/src/audio/nullAudioSound.cxx index 64e0fdf222..980083b468 100644 --- a/panda/src/audio/nullAudioSound.cxx +++ b/panda/src/audio/nullAudioSound.cxx @@ -1,17 +1,16 @@ -// Filename: nullAudioSound.cxx -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nullAudioSound.cxx + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #include "nullAudioSound.h" @@ -19,14 +18,12 @@ TypeHandle NullAudioSound::_type_handle; namespace { static const string blank=""; - // static PN_stdfloat no_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; + // static PN_stdfloat no_attributes [] = {0.0f,0.0f,0.0f, 0.0f,0.0f,0.0f}; } -//////////////////////////////////////////////////////////////////// -// Function: -// Access: -// Description: All of these functions are just stubs. -//////////////////////////////////////////////////////////////////// +/** + * All of these functions are just stubs. + */ NullAudioSound::NullAudioSound() { // Intentionally blank. } @@ -34,7 +31,7 @@ NullAudioSound::NullAudioSound() { NullAudioSound::~NullAudioSound() { // Intentionally blank. } - + void NullAudioSound::play() { // Intentionally blank. } @@ -42,29 +39,29 @@ void NullAudioSound::play() { void NullAudioSound::stop() { // Intentionally blank. } - + void NullAudioSound::set_loop(bool) { // Intentionally blank. } bool NullAudioSound::get_loop() const { - return false; + return false; } - + void NullAudioSound::set_loop_count(unsigned long) { // Intentionally blank. } unsigned long NullAudioSound::get_loop_count() const { - return 0; + return 0; } - + void NullAudioSound::set_time(PN_stdfloat) { // Intentionally blank. } PN_stdfloat NullAudioSound::get_time() const { - return 0; + return 0; } void NullAudioSound::set_volume(PN_stdfloat) { @@ -72,7 +69,7 @@ void NullAudioSound::set_volume(PN_stdfloat) { } PN_stdfloat NullAudioSound::get_volume() const { - return 0; + return 0; } void NullAudioSound::set_balance(PN_stdfloat) { @@ -80,7 +77,7 @@ void NullAudioSound::set_balance(PN_stdfloat) { } PN_stdfloat NullAudioSound::get_balance() const { - return 0; + return 0; } void NullAudioSound::set_play_rate(PN_stdfloat) { @@ -88,7 +85,7 @@ void NullAudioSound::set_play_rate(PN_stdfloat) { } PN_stdfloat NullAudioSound::get_play_rate() const { - return 0; + return 0; } void NullAudioSound::set_active(bool) { @@ -96,7 +93,7 @@ void NullAudioSound::set_active(bool) { } bool NullAudioSound::get_active() const { - return false; + return false; } void NullAudioSound::set_finished_event(const string& event) { @@ -142,5 +139,5 @@ PN_stdfloat NullAudioSound::get_3d_max_distance() const { } AudioSound::SoundStatus NullAudioSound::status() const { - return AudioSound::READY; + return AudioSound::READY; } diff --git a/panda/src/audio/nullAudioSound.h b/panda/src/audio/nullAudioSound.h index d3bbd5801b..87ef0c9b95 100644 --- a/panda/src/audio/nullAudioSound.h +++ b/panda/src/audio/nullAudioSound.h @@ -1,17 +1,16 @@ -// Filename: nullAudioSound.h -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nullAudioSound.h + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #ifndef __NULL_AUDIO_SOUND_H__ #define __NULL_AUDIO_SOUND_H__ @@ -19,35 +18,34 @@ #include "audioSound.h" -// This class intentionally does next to nothing. -// It's used as a placeholder when you don't want a sound -// system. +// This class intentionally does next to nothing. It's used as a placeholder +// when you don't want a sound system. class EXPCL_PANDA_AUDIO NullAudioSound : public AudioSound { - // All of these methods are stubbed out to some degree. - // If you're looking for a starting place for a new AudioManager, - // please consider looking at the milesAudioManager. + // All of these methods are stubbed out to some degree. If you're looking + // for a starting place for a new AudioManager, please consider looking at + // the milesAudioManager. public: ~NullAudioSound(); - + void play(); void stop(); - + void set_loop(bool); bool get_loop() const; - + void set_loop_count(unsigned long); unsigned long get_loop_count() const; - + void set_time(PN_stdfloat); PN_stdfloat get_time() const; - + void set_volume(PN_stdfloat); PN_stdfloat get_volume() const; - + void set_balance(PN_stdfloat); PN_stdfloat get_balance() const; - + void set_play_rate(PN_stdfloat); PN_stdfloat get_play_rate() const; @@ -56,9 +54,9 @@ public: void set_finished_event(const string& event); const string& get_finished_event() const; - + const string& get_name() const; - + PN_stdfloat length() const; void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); @@ -67,11 +65,10 @@ public: PN_stdfloat get_3d_min_distance() const; void set_3d_max_distance(PN_stdfloat dist); PN_stdfloat get_3d_max_distance() const; - + AudioSound::SoundStatus status() const; -// why protect the constructor?!? -//protected: +// why protect the constructor?!? protected: NullAudioSound(); public: diff --git a/panda/src/audio/test_audio.cxx b/panda/src/audio/test_audio.cxx index 5f4565e854..a2a7ac06fb 100644 --- a/panda/src/audio/test_audio.cxx +++ b/panda/src/audio/test_audio.cxx @@ -1,16 +1,15 @@ -// Filename: test_audio.cxx -// Created by: cary (24Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_audio.cxx + * @author cary + * @date 2000-09-24 + */ #include "pandabase.h" #include "audio.h" @@ -47,7 +46,7 @@ main(int argc, char* argv[]) { ipc_traits::sleep(0, 1000000); } - // AudioMidi foo("test.midi"); + // AudioMidi foo("test.midi"); if (! AudioPool::verify_sound("test.midi")) { audio_cat->fatal() << "could not locate 'test.midi'" << endl; exit(-1); diff --git a/panda/src/audiotraits/config_fmodAudio.cxx b/panda/src/audiotraits/config_fmodAudio.cxx index b5c111a59a..0726118121 100644 --- a/panda/src/audiotraits/config_fmodAudio.cxx +++ b/panda/src/audiotraits/config_fmodAudio.cxx @@ -1,16 +1,14 @@ -// Filename: config_fmodAudio.cxx -// Created by: cort -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_fmodAudio.cxx + * @author cort + */ #include "pandabase.h" @@ -36,14 +34,12 @@ ConfigVariableInt fmod_audio_preload_threshold "will be streamed from disk. Set this to -1 to preload " "every file.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libFmodAudio -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libFmodAudio() { static bool initialized = false; @@ -61,12 +57,11 @@ init_libFmodAudio() { ps->set_system_tag("audio", "implementation", "FMOD"); } -//////////////////////////////////////////////////////////////////// -// Function: get_audio_manager_func_fmod_audio -// Description: This function is called when the dynamic library is -// loaded; it should return the Create_AudioManager -// function appropriate to create a FmodAudioManager. -//////////////////////////////////////////////////////////////////// +/** + * This function is called when the dynamic library is loaded; it should + * return the Create_AudioManager function appropriate to create a + * FmodAudioManager. + */ Create_AudioManager_proc * get_audio_manager_func_fmod_audio() { init_libFmodAudio(); diff --git a/panda/src/audiotraits/config_fmodAudio.h b/panda/src/audiotraits/config_fmodAudio.h index cea24744c9..79e221ff31 100644 --- a/panda/src/audiotraits/config_fmodAudio.h +++ b/panda/src/audiotraits/config_fmodAudio.h @@ -1,16 +1,14 @@ -// Filename: config_fmodAudio.h -// Created by: cort -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_fmodAudio.h + * @author cort + */ #ifndef CONFIG_FMODAUDIO_H #define CONFIG_FMODAUDIO_H diff --git a/panda/src/audiotraits/config_milesAudio.cxx b/panda/src/audiotraits/config_milesAudio.cxx index 3da1bcc119..6f3f29dddb 100644 --- a/panda/src/audiotraits/config_milesAudio.cxx +++ b/panda/src/audiotraits/config_milesAudio.cxx @@ -1,16 +1,14 @@ -// Filename: config_milesAudio.cxx -// Created by: skyler -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_milesAudio.cxx + * @author skyler + */ #include "pandabase.h" #ifdef HAVE_RAD_MSS //[ @@ -61,14 +59,12 @@ ConfigVariableBool miles_audio_panda_threads "and ensures better lock protection within Panda. This has " "no meaning unless Panda is compiled with thread support.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libMilesAudio -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libMilesAudio() { static bool initialized = false; @@ -88,12 +84,11 @@ init_libMilesAudio() { ps->set_system_tag("audio", "implementation", "Miles"); } -//////////////////////////////////////////////////////////////////// -// Function: get_audio_manager_func_miles_audio -// Description: This function is called when the dynamic library is -// loaded; it should return the Create_AudioManager -// function appropriate to create a MilesAudioManager. -//////////////////////////////////////////////////////////////////// +/** + * This function is called when the dynamic library is loaded; it should + * return the Create_AudioManager function appropriate to create a + * MilesAudioManager. + */ Create_AudioManager_proc * get_audio_manager_func_miles_audio() { init_libMilesAudio(); diff --git a/panda/src/audiotraits/config_milesAudio.h b/panda/src/audiotraits/config_milesAudio.h index 5a2ec1cd36..abcb5b1261 100644 --- a/panda/src/audiotraits/config_milesAudio.h +++ b/panda/src/audiotraits/config_milesAudio.h @@ -1,16 +1,14 @@ -// Filename: config_milesAudio.h -// Created by: skyler -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_milesAudio.h + * @author skyler + */ #ifndef CONFIG_MILESAUDIO_H #define CONFIG_MILESAUDIO_H diff --git a/panda/src/audiotraits/config_openalAudio.cxx b/panda/src/audiotraits/config_openalAudio.cxx index 94508743a7..43ba4d890c 100644 --- a/panda/src/audiotraits/config_openalAudio.cxx +++ b/panda/src/audiotraits/config_openalAudio.cxx @@ -1,16 +1,14 @@ -// Filename: config_openalAudio.cxx -// Created by: cort -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_openalAudio.cxx + * @author cort + */ #include "pandabase.h" @@ -33,14 +31,12 @@ ConfigVariableString openal_device "is not specified, the OpenAL default device is used.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libOpenALAudio -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libOpenALAudio() { static bool initialized = false; @@ -58,12 +54,11 @@ init_libOpenALAudio() { ps->set_system_tag("audio", "implementation", "OpenAL"); } -//////////////////////////////////////////////////////////////////// -// Function: get_audio_manager_func_openal_audio -// Description: This function is called when the dynamic library is -// loaded; it should return the Create_AudioManager -// function appropriate to create an OpenALAudioManager. -//////////////////////////////////////////////////////////////////// +/** + * This function is called when the dynamic library is loaded; it should + * return the Create_AudioManager function appropriate to create an + * OpenALAudioManager. + */ Create_AudioManager_proc * get_audio_manager_func_openal_audio() { init_libOpenALAudio(); diff --git a/panda/src/audiotraits/config_openalAudio.h b/panda/src/audiotraits/config_openalAudio.h index 646e13bdc8..dd24d208eb 100644 --- a/panda/src/audiotraits/config_openalAudio.h +++ b/panda/src/audiotraits/config_openalAudio.h @@ -1,16 +1,14 @@ -// Filename: config_openalAudio.h -// Created by: Ben Buchwald -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_openalAudio.h + * @author Ben Buchwald + */ #ifndef CONFIG_OPENALAUDIO_H #define CONFIG_OPENALAUDIO_H diff --git a/panda/src/audiotraits/fmodAudioManager.cxx b/panda/src/audiotraits/fmodAudioManager.cxx index 7864917970..7d7ae246e3 100644 --- a/panda/src/audiotraits/fmodAudioManager.cxx +++ b/panda/src/audiotraits/fmodAudioManager.cxx @@ -1,26 +1,24 @@ -// Filename: fmodAudioManager.cxx -// Created by: cort (January 22, 2003) -// Prior system by: cary -// Rewrite [for new Version of FMOD-EX] by: Stan Rosenbaum "Staque" - Spring 2006 -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fmodAudioManager.cxx + * @author cort + * @date 2003-01-22 + * Prior system by: cary + * @author Stan Rosenbaum "Staque" - Spring 2006 + */ #include "pandabase.h" #include "config_audio.h" #include "config_fmodAudio.h" #include "dcast.h" -//Panda headers. +// Panda headers. #include "config_audio.h" #include "config_util.h" #include "fmodAudioManager.h" @@ -29,7 +27,7 @@ #include "virtualFileSystem.h" #include "reMutexHolder.h" -//FMOD Headers. +// FMOD Headers. #include #include @@ -45,21 +43,17 @@ pset FmodAudioManager::_all_managers; bool FmodAudioManager::_system_is_valid = false; -// This sets the distance factor for 3D audio to use feet. -// FMOD uses meters by default. -// Since Panda use feet we need to compensate for that with a factor of 3.28 -// -// This can be overwritten. You just need to call -// audio_3d_set_distance_factor(PN_stdfloat factor) and set your new factor. +// This sets the distance factor for 3D audio to use feet. FMOD uses meters +// by default. Since Panda use feet we need to compensate for that with a +// factor of 3.28 This can be overwritten. You just need to call +// audio_3d_set_distance_factor(PN_stdfloat factor) and set your new factor. PN_stdfloat FmodAudioManager::_doppler_factor = 1; PN_stdfloat FmodAudioManager::_distance_factor = 3.28; PN_stdfloat FmodAudioManager::_drop_off_factor = 1; -//////////////////////////////////////////////////////////////////// // Central dispatcher for audio errors. -//////////////////////////////////////////////////////////////////// void fmod_audio_errcheck(const char *context, FMOD_RESULT result) { if (result != 0) { @@ -67,33 +61,29 @@ void fmod_audio_errcheck(const char *context, FMOD_RESULT result) { } } -//////////////////////////////////////////////////////////////////// -// Function: Create_FmodAudioManager -// Access: Private -// Description: Factory Function -//////////////////////////////////////////////////////////////////// +/** + * Factory Function + */ AudioManager *Create_FmodAudioManager() { audio_debug("Create_FmodAudioManager()"); return new FmodAudioManager; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FmodAudioManager:: FmodAudioManager() { ReMutexHolder holder(_lock); FMOD_RESULT result; - //We need a varible temporary to check the FMOD Version. + // We need a varible temporary to check the FMOD Version. unsigned int version; _all_managers.insert(this); - //Init 3D attributes + // Init 3D attributes _position.x = 0; _position.y = 0; _position.z = 0; @@ -113,15 +103,16 @@ FmodAudioManager() { _saved_outputtype = FMOD_OUTPUTTYPE_AUTODETECT; if (_system == (FMOD::System *)NULL) { - // Create the global FMOD System object. This one object must be - // shared by all FmodAudioManagers (this is particularly true on - // OSX, but the FMOD documentation is unclear as to whether this - // is the intended design on all systems). + // Create the global FMOD System object. This one object must be shared + // by all FmodAudioManagers (this is particularly true on OSX, but the + // FMOD documentation is unclear as to whether this is the intended design + // on all systems). result = FMOD::System_Create(&_system); fmod_audio_errcheck("FMOD::System_Create()", result); - // Let check the Version of FMOD to make sure the Headers and Libraries are correct. + // Let check the Version of FMOD to make sure the Headers and Libraries + // are correct. result = _system->getVersion(&version); fmod_audio_errcheck("_system->getVersion()", result); @@ -132,8 +123,8 @@ FmodAudioManager() { // Set speaker mode. if (fmod_speaker_mode.get_value() == FSM_unspecified) { if (fmod_use_surround_sound) { - // fmod-use-surround-sound is the old variable, now replaced - // by fmod-speaker-mode. This is for backward compatibility. + // fmod-use-surround-sound is the old variable, now replaced by fmod- + // speaker-mode. This is for backward compatibility. result = _system->setSpeakerMode(FMOD_SPEAKERMODE_5POINT1); fmod_audio_errcheck("_system->setSpeakerMode()", result); } @@ -144,7 +135,7 @@ FmodAudioManager() { fmod_audio_errcheck("_system->setSpeakerMode()", result); } - //Now we Initialize the System. + // Now we Initialize the System. int nchan = fmod_number_of_sound_channels; int flags = FMOD_INIT_NORMAL; @@ -173,8 +164,8 @@ FmodAudioManager() { Filename dls_pathname = get_dls_pathname(); #ifdef IS_OSX - // Here's a big kludge. Don't ever let FMOD try to load this - // OSX-provided file; it crashes messily if you do. + // Here's a big kludge. Don't ever let FMOD try to load this OSX-provided + // file; it crashes messily if you do. if (dls_pathname == "/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls") { dls_pathname = ""; } @@ -191,18 +182,16 @@ FmodAudioManager() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FmodAudioManager:: ~FmodAudioManager() { ReMutexHolder holder(_lock); // Be sure to delete associated sounds before deleting the manager! FMOD_RESULT result; - //Release Sounds Next + // Release Sounds Next _all_sounds.clear(); // Remove me from the managers list. @@ -216,22 +205,17 @@ FmodAudioManager:: } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::is_valid -// Access: Public -// Description: This just check to make sure the FMOD System is -// up and running correctly. -//////////////////////////////////////////////////////////////////// +/** + * This just check to make sure the FMOD System is up and running correctly. + */ bool FmodAudioManager:: is_valid() { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::make_dsp -// Access: Private -// Description: Converts a FilterConfig to an FMOD_DSP -//////////////////////////////////////////////////////////////////// +/** + * Converts a FilterConfig to an FMOD_DSP + */ FMOD::DSP *FmodAudioManager:: make_dsp(const FilterProperties::FilterConfig &conf) { ReMutexHolder holder(_lock); @@ -362,19 +346,14 @@ make_dsp(const FilterProperties::FilterConfig &conf) { return dsp; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::update_dsp_chain -// Access: Public -// Description: Alters a DSP chain to make it match the specified -// configuration. -// -// This is an inadequate implementation - it just -// clears the whole DSP chain and rebuilds it from -// scratch. A better implementation would compare -// the existing DSP chain to the desired one, and -// make incremental changes. This would prevent -// a "pop" sound when the changes are made. -//////////////////////////////////////////////////////////////////// +/** + * Alters a DSP chain to make it match the specified configuration. + * + * This is an inadequate implementation - it just clears the whole DSP chain + * and rebuilds it from scratch. A better implementation would compare the + * existing DSP chain to the desired one, and make incremental changes. This + * would prevent a "pop" sound when the changes are made. + */ void FmodAudioManager:: update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { ReMutexHolder holder(_lock); @@ -410,15 +389,12 @@ update_dsp_chain(FMOD::DSP *head, FilterProperties *config) { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::configure_filters -// Access: Public -// Description: Configure the global DSP filter chain. -// -// FMOD has a relatively powerful DSP -// implementation. It is likely that most -// configurations will be supported. -//////////////////////////////////////////////////////////////////// +/** + * Configure the global DSP filter chain. + * + * FMOD has a relatively powerful DSP implementation. It is likely that most + * configurations will be supported. + */ bool FmodAudioManager:: configure_filters(FilterProperties *config) { ReMutexHolder holder(_lock); @@ -433,16 +409,14 @@ configure_filters(FilterProperties *config) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::get_sound -// Access: Public -// Description: This is what creates a sound instance. -//////////////////////////////////////////////////////////////////// +/** + * This is what creates a sound instance. + */ PT(AudioSound) FmodAudioManager:: get_sound(const string &file_name, bool positional, int) { ReMutexHolder holder(_lock); - //Needed so People use Panda's Generic UNIX Style Paths for Filename. - //path.to_os_specific() converts it back to the proper OS version later on. + // Needed so People use Panda's Generic UNIX Style Paths for Filename. + // path.to_os_specific() converts it back to the proper OS version later on. Filename path = file_name; @@ -460,22 +434,18 @@ get_sound(const string &file_name, bool positional, int) { return audioSound; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::get_sound -// Access: Public -// Description: This is what creates a sound instance. -//////////////////////////////////////////////////////////////////// +/** + * This is what creates a sound instance. + */ PT(AudioSound) FmodAudioManager:: get_sound(MovieAudio *source, bool positional, int) { nassert_raise("FMOD audio manager does not support MovieAudio sources"); return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::getSpeakerSetup() -// Access: Published -// Description: This is to query if you are using a MultiChannel Setup. -//////////////////////////////////////////////////////////////////// +/** + * This is to query if you are using a MultiChannel Setup. + */ int FmodAudioManager:: getSpeakerSetup() { ReMutexHolder holder(_lock); @@ -518,26 +488,19 @@ getSpeakerSetup() { return returnMode; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::setSpeakerSetup() -// Access: Published -// Description: This is to set up FMOD to use a MultiChannel Setup. -// This method is pretty much useless. -// To set a speaker setup in FMOD for Surround Sound, -// stereo, or whatever you have to set the SpeakerMode -// BEFORE you Initialize FMOD. -// Since Panda Inits the FmodAudioManager right when you -// Start it up, you are never given an oppertunity to call -// this function. -// That is why I stuck a BOOL in the CONFIG.PRC file, whichs -// lets you flag if you want to use a Multichannel or not. -// That will set the speaker setup when an instance of this -// class is constructed. -// Still I put this here as a measure of good faith, since you -// can query the speaker setup after everything in Init. -// Also, maybe someone will completely hack Panda someday, in which -// one can init or re-init the AudioManagers after Panda is running. -//////////////////////////////////////////////////////////////////// +/** + * This is to set up FMOD to use a MultiChannel Setup. This method is pretty + * much useless. To set a speaker setup in FMOD for Surround Sound, stereo, + * or whatever you have to set the SpeakerMode BEFORE you Initialize FMOD. + * Since Panda Inits the FmodAudioManager right when you Start it up, you are + * never given an oppertunity to call this function. That is why I stuck a + * BOOL in the CONFIG.PRC file, whichs lets you flag if you want to use a + * Multichannel or not. That will set the speaker setup when an instance of + * this class is constructed. Still I put this here as a measure of good + * faith, since you can query the speaker setup after everything in Init. + * Also, maybe someone will completely hack Panda someday, in which one can + * init or re-init the AudioManagers after Panda is running. + */ void FmodAudioManager:: setSpeakerSetup(AudioManager::SpeakerModeCategory cat) { ReMutexHolder holder(_lock); @@ -547,12 +510,10 @@ setSpeakerSetup(AudioManager::SpeakerModeCategory cat) { fmod_audio_errcheck("_system->setSpeakerMode()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::set_volume(PN_stdfloat volume) -// Access: Public -// Description: Sets the volume of the AudioManager. -// It is not an override, but a multiplier. -//////////////////////////////////////////////////////////////////// +/** + * Sets the volume of the AudioManager. It is not an override, but a + * multiplier. + */ void FmodAudioManager:: set_volume(PN_stdfloat volume) { ReMutexHolder holder(_lock); @@ -561,11 +522,9 @@ set_volume(PN_stdfloat volume) { fmod_audio_errcheck("_channelgroup->setVolume()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::get_volume() -// Access: Public -// Description: Returns the AudioManager's volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AudioManager's volume. + */ PN_stdfloat FmodAudioManager:: get_volume() const { ReMutexHolder holder(_lock); @@ -576,30 +535,25 @@ get_volume() const { return (PN_stdfloat)volume; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::set_wavwriter() -// Access: Public -// Description: Changes output mode to write all audio to a wav file. -//////////////////////////////////////////////////////////////////// +/** + * Changes output mode to write all audio to a wav file. + */ void FmodAudioManager:: set_wavwriter(bool outputwav) { - ReMutexHolder holder(_lock); - if (outputwav) { - _system->getOutput(&_saved_outputtype); - _system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER); - } - else { - _system->setOutput(_saved_outputtype); - } + ReMutexHolder holder(_lock); + if (outputwav) { + _system->getOutput(&_saved_outputtype); + _system->setOutput(FMOD_OUTPUTTYPE_WAVWRITER); + } + else { + _system->setOutput(_saved_outputtype); + } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::set_active(bool active) -// Access: Public -// Description: Turn on/off -// Warning: not implemented. -//////////////////////////////////////////////////////////////////// +/** + * Turn on/off Warning: not implemented. + */ void FmodAudioManager:: set_active(bool active) { ReMutexHolder holder(_lock); @@ -615,27 +569,23 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::get_active() -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FmodAudioManager:: get_active() const { return _active; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::stop_all_sounds() -// Access: Public -// Description: Stop playback on all sounds managed by this manager. -//////////////////////////////////////////////////////////////////// +/** + * Stop playback on all sounds managed by this manager. + */ void FmodAudioManager:: stop_all_sounds() { ReMutexHolder holder(_lock); - // We have to walk through this list with some care, since stopping - // a sound may also remove it from the set (if there are no other - // references to the sound). + // We have to walk through this list with some care, since stopping a sound + // may also remove it from the set (if there are no other references to the + // sound). SoundSet::iterator i; i = _all_sounds.begin(); while (i != _all_sounds.end()) { @@ -647,32 +597,26 @@ stop_all_sounds() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::update -// Access: Public -// Description: Perform all per-frame update functions. -//////////////////////////////////////////////////////////////////// +/** + * Perform all per-frame update functions. + */ void FmodAudioManager:: update() { ReMutexHolder holder(_lock); _system->update(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_set_listener_attributes -// Access: Public -// Description: Set position of the "ear" that picks up 3d sounds -// NOW LISTEN UP!!! THIS IS IMPORTANT! -// Both Panda3D and FMOD use a left handed coordinate system. -// But there is a major difference! -// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. -// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. -// The solution is simple, we just flip the Y and Z axis, as we move coordinates -// from Panda to FMOD and back. -// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. -// But if you decide to do any 3D audio work in here you have to keep it in mind. -// I told you, so you can't say I didn't. -//////////////////////////////////////////////////////////////////// +/** + * Set position of the "ear" that picks up 3d sounds NOW LISTEN UP!!! THIS IS + * IMPORTANT! Both Panda3D and FMOD use a left handed coordinate system. But + * there is a major difference! In Panda3D the Y-Axis is going into the + * Screen and the Z-Axis is going up. In FMOD the Y-Axis is going up and the + * Z-Axis is going into the screen. The solution is simple, we just flip the + * Y and Z axis, as we move coordinates from Panda to FMOD and back. What + * does did mean to average Panda user? Nothing, they shouldn't notice + * anyway. But if you decide to do any 3D audio work in here you have to keep + * it in mind. I told you, so you can't say I didn't. + */ void FmodAudioManager:: audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { ReMutexHolder holder(_lock); @@ -701,11 +645,9 @@ audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_get_listener_attributes -// Access: Public -// Description: Get position of the "ear" that picks up 3d sounds -//////////////////////////////////////////////////////////////////// +/** + * Get position of the "ear" that picks up 3d sounds + */ void FmodAudioManager:: audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { audio_error("audio3dGetListenerAttributes: currently unimplemented. Get the attributes of the attached object"); @@ -713,12 +655,10 @@ audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat * } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_set_distance_factor -// Access: Public -// Description: Set units per meter (Fmod uses meters internally for -// its sound-spacialization calculations) -//////////////////////////////////////////////////////////////////// +/** + * Set units per meter (Fmod uses meters internally for its sound- + * spacialization calculations) + */ void FmodAudioManager:: audio_3d_set_distance_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -734,12 +674,10 @@ audio_3d_set_distance_factor(PN_stdfloat factor) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_get_distance_factor -// Access: Public -// Description: Gets units per meter (Fmod uses meters internally for -// its sound-spacialization calculations) -//////////////////////////////////////////////////////////////////// +/** + * Gets units per meter (Fmod uses meters internally for its sound- + * spacialization calculations) + */ PN_stdfloat FmodAudioManager:: audio_3d_get_distance_factor() const { audio_debug("FmodAudioManager::audio_3d_get_distance_factor()"); @@ -747,12 +685,9 @@ audio_3d_get_distance_factor() const { return _distance_factor; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_set_doppler_factor -// Access: Public -// Description: Exaggerates or diminishes the Doppler effect. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Exaggerates or diminishes the Doppler effect. Defaults to 1.0 + */ void FmodAudioManager:: audio_3d_set_doppler_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -767,11 +702,9 @@ audio_3d_set_doppler_factor(PN_stdfloat factor) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_get_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat FmodAudioManager:: audio_3d_get_doppler_factor() const { audio_debug("FmodAudioManager::audio_3d_get_doppler_factor()"); @@ -779,12 +712,9 @@ audio_3d_get_doppler_factor() const { return _doppler_factor; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_set_drop_off_factor -// Access: Public -// Description: Control the effect distance has on audability. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Control the effect distance has on audability. Defaults to 1.0 + */ void FmodAudioManager:: audio_3d_set_drop_off_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -799,11 +729,9 @@ audio_3d_set_drop_off_factor(PN_stdfloat factor) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::audio_3d_get_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat FmodAudioManager:: audio_3d_get_drop_off_factor() const { ReMutexHolder holder(_lock); @@ -815,43 +743,34 @@ audio_3d_get_drop_off_factor() const { -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::set_concurrent_sound_limit -// Access: Public -// Description: NOT USED FOR FMOD-EX!!! -//////////////////////////////////////////////////////////////////// +/** + * NOT USED FOR FMOD-EX!!! + */ void FmodAudioManager:: set_concurrent_sound_limit(unsigned int limit) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::get_concurrent_sound_limit -// Access: Public -// Description: NOT USED FOR FMOD-EX!!! -//////////////////////////////////////////////////////////////////// +/** + * NOT USED FOR FMOD-EX!!! + */ unsigned int FmodAudioManager:: get_concurrent_sound_limit() const { return 1000000; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::reduce_sounds_playing_to -// Access: Private -// Description: NOT USED FOR FMOD-EX!!! -//////////////////////////////////////////////////////////////////// +/** + * NOT USED FOR FMOD-EX!!! + */ void FmodAudioManager:: reduce_sounds_playing_to(unsigned int count) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioManager::uncache_sound -// Access: Public -// Description: NOT USED FOR FMOD-EX!!! -// Clears a sound out of the sound cache. -//////////////////////////////////////////////////////////////////// +/** + * NOT USED FOR FMOD-EX!!! Clears a sound out of the sound cache. + */ void FmodAudioManager:: uncache_sound(const string& file_name) { audio_debug("FmodAudioManager::uncache_sound(\""< #include @@ -89,9 +82,7 @@ extern void fmod_audio_errcheck(const char *context, FMOD_RESULT n); class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager { friend class FmodAudioSound; - public: - - //Constructor and Destructor +public: FmodAudioManager(); virtual ~FmodAudioManager(); @@ -115,12 +106,12 @@ class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager { virtual void update(); - // This controls the "set of ears" that listens to 3D spacialized sound - // px, py, pz are position coordinates. Can be 0.0f to ignore. - // vx, vy, vz are a velocity vector in UNITS PER SECOND (default: meters). - // fx, fy and fz are the respective components of a unit forward-vector - // ux, uy and uz are the respective components of a unit up-vector - // These changes will NOT be invoked until audio_3d_update() is called. + // This controls the "set of ears" that listens to 3D spacialized sound px, + // py, pz are position coordinates. Can be 0.0f to ignore. vx, vy, vz are + // a velocity vector in UNITS PER SECOND (default: meters). fx, fy and fz + // are the respective components of a unit forward-vector ux, uy and uz are + // the respective components of a unit up-vector These changes will NOT be + // invoked until audio_3d_update() is called. virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, @@ -132,28 +123,24 @@ class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager { PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); - // Control the "relative distance factor" for 3D spacialized audio. Default is 1.0 - // Fmod uses meters internally, so give a float in Units-per meter + // Control the "relative distance factor" for 3D spacialized audio. Default + // is 1.0 Fmod uses meters internally, so give a float in Units-per meter // Don't know what Miles uses. virtual void audio_3d_set_distance_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_distance_factor() const; - // Control the presence of the Doppler effect. Default is 1.0 - // Exaggerated Doppler, use >1.0 - // Diminshed Doppler, use <1.0 + // Control the presence of the Doppler effect. Default is 1.0 Exaggerated + // Doppler, use >1.0 Diminshed Doppler, use <1.0 virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_doppler_factor() const; - // Exaggerate or diminish the effect of distance on sound. Default is 1.0 - // Faster drop off, use >1.0 - // Slower drop off, use <1.0 + // Exaggerate or diminish the effect of distance on sound. Default is 1.0 + // Faster drop off, use >1.0 Slower drop off, use <1.0 virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_drop_off_factor() const; - //THESE ARE NOT USED ANYMORE. - //THEY ARE ONLY HERE BECAUSE THEY are still needed by Miles. - //THESE are stubs in FMOD-EX version - //////////////////////////////////////////////////////////////////// + // THESE ARE NOT USED ANYMORE. THEY ARE ONLY HERE BECAUSE THEY are still + // needed by Miles. THESE are stubs in FMOD-EX version virtual void set_concurrent_sound_limit(unsigned int limit = 0); virtual unsigned int get_concurrent_sound_limit() const; virtual void reduce_sounds_playing_to(unsigned int count); @@ -161,7 +148,6 @@ class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager { virtual void clear_cache(); virtual void set_cache_limit(unsigned int count); virtual unsigned int get_cache_limit() const; - //////////////////////////////////////////////////////////////////// private: FMOD::DSP *make_dsp(const FilterProperties::FilterConfig &conf); @@ -201,11 +187,7 @@ private: FMOD_OUTPUTTYPE _saved_outputtype; -//////////////////////////////////////////////////////////////////// - //These are needed for Panda's Pointer System. DO NOT ERASE! -//////////////////////////////////////////////////////////////////// - - public: +public: static TypeHandle get_class_type() { return _type_handle; } @@ -221,13 +203,8 @@ private: return get_class_type(); } - private: +private: static TypeHandle _type_handle; - -//////////////////////////////////////////////////////////////////// - //DONE -//////////////////////////////////////////////////////////////////// - }; EXPCL_FMOD_AUDIO AudioManager *Create_FmodAudioManager(); diff --git a/panda/src/audiotraits/fmodAudioSound.I b/panda/src/audiotraits/fmodAudioSound.I index 4d848d10de..2fe4498245 100644 --- a/panda/src/audiotraits/fmodAudioSound.I +++ b/panda/src/audiotraits/fmodAudioSound.I @@ -1,20 +1,13 @@ -// Filename: fmodAudioSound.I -// Created by: cort (January 22, 2003) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - - - - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fmodAudioSound.I + * @author cort + * @date 2003-01-22 + * Prior system by: cary + */ diff --git a/panda/src/audiotraits/fmodAudioSound.cxx b/panda/src/audiotraits/fmodAudioSound.cxx index 6747cdebd6..a793b9bfa5 100644 --- a/panda/src/audiotraits/fmodAudioSound.cxx +++ b/panda/src/audiotraits/fmodAudioSound.cxx @@ -1,25 +1,24 @@ -// Filename: fmodAudioSound.cxx -// Created by: cort (January 22, 2003) -// Extended by: ben (October 22, 2003) -// Prior system by: cary -// Rewrite [for new Version of FMOD-EX] by: Stan Rosenbaum "Staque" - Spring 2006 -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fmodAudioSound.cxx + * @author cort + * @date 2003-01-22 + * @author ben + * @date 2003-10-22 + * Prior system by: cary + * @author Stan Rosenbaum "Staque" - Spring 2006 + */ #include "pandabase.h" #include "dcast.h" -//Panda Headers +// Panda Headers #include "config_audio.h" #include "config_fmodAudio.h" #include "fmodAudioSound.h" @@ -30,13 +29,10 @@ TypeHandle FmodAudioSound::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::FmodAudioSound -// Access: Public -// Description: Constructor -// All sound will DEFAULT load as a 2D sound unless -// otherwise specified. -//////////////////////////////////////////////////////////////////// +/** + * Constructor All sound will DEFAULT load as a 2D sound unless otherwise + * specified. + */ FmodAudioSound:: FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { @@ -47,10 +43,10 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { _paused = false; _start_time = 0.0; - //Local Variables that are needed. + // Local Variables that are needed. FMOD_RESULT result; - //Inits 3D Attributes + // Inits 3D Attributes _location.x = 0; _location.y = 0; _location.z = 0; @@ -59,15 +55,16 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { _velocity.y = 0; _velocity.z = 0; - //Play Rate Variable + // Play Rate Variable _playrate = 1; - // These set the Speaker Levels to a default if you are using a MultiChannel Setup. + // These set the Speaker Levels to a default if you are using a MultiChannel + // Setup. for (int i=0; i_system->getSpeakerMode( &_speakermode ); fmod_audio_errcheck("_system->getSpeakerMode()", result); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); PT(VirtualFile) file = vfs->get_file(_file_name); if (file == (VirtualFile *)NULL) { - // File not found. We will display the appropriate error message - // below. + // File not found. We will display the appropriate error message below. result = FMOD_ERR_FILE_NOTFOUND; } else { @@ -111,9 +107,9 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { pvector mem_buffer; SubfileInfo info; if (preload) { - // Pre-read the file right now, and pass it in as a memory - // buffer. This avoids threading issues completely, because all - // of the reading happens right here. + // Pre-read the file right now, and pass it in as a memory buffer. This + // avoids threading issues completely, because all of the reading + // happens right here. file->read_file(mem_buffer, true); sound_info.length = mem_buffer.size(); if (mem_buffer.size() != 0) { @@ -127,11 +123,10 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { } } else if (file->get_system_info(info)) { - // The file exists on disk (or it's part of a multifile that - // exists on disk), so we can have FMod read the file directly. - // This is also safe, because FMod uses its own I/O operations - // that don't involve Panda, so this can safely happen in an - // FMod thread. + // The file exists on disk (or it's part of a multifile that exists on + // disk), so we can have FMod read the file directly. This is also + // safe, because FMod uses its own IO operations that don't involve + // Panda, so this can safely happen in an FMod thread. os_filename = info.get_filename().to_os_specific(); name_or_data = os_filename.c_str(); sound_info.fileoffset = (unsigned int)info.get_start(); @@ -145,8 +140,8 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { } else { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) - // Otherwise, if the Panda threading system is compiled in, we - // can assign callbacks to read the file through the VFS. + // Otherwise, if the Panda threading system is compiled in, we can + // assign callbacks to read the file through the VFS. name_or_data = (const char *)file.p(); sound_info.length = (unsigned int)info.get_size(); sound_info.useropen = open_callback; @@ -175,8 +170,7 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { if (result != FMOD_OK) { audio_error("createSound(" << _file_name << "): " << FMOD_ErrorString(result)); - // We couldn't load the sound file. Create a blank sound record - // instead. + // We couldn't load the sound file. Create a blank sound record instead. FMOD_CREATESOUNDEXINFO sound_info; memset(&sound_info, 0, sizeof(sound_info)); char blank_data[100]; @@ -192,55 +186,49 @@ FmodAudioSound(AudioManager *manager, Filename file_name, bool positional) { fmod_audio_errcheck("createSound (blank)", result); } - // Some WAV files contain a loop bit. This is not handled - // consistently. Override it. + // Some WAV files contain a loop bit. This is not handled consistently. + // Override it. _sound->setLoopCount(1); _sound->setMode(FMOD_LOOP_OFF); - //This is just to collect the defaults of the sound, so we don't - //Have to query FMOD everytime for the info. - //It is also important we get the '_sampleFrequency' variable here, for the - //'set_play_rate()' and 'get_play_rate()' methods later; + // This is just to collect the defaults of the sound, so we don't Have to + // query FMOD everytime for the info. It is also important we get the + // '_sampleFrequency' variable here, for the 'set_play_rate()' and + // 'get_play_rate()' methods later; result = _sound->getDefaults( &_sampleFrequency, &_volume , &_balance, &_priority); fmod_audio_errcheck("_sound->getDefaults()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::~FmodAudioSound -// Access: Public -// Description: DESTRUCTOR!!! -//////////////////////////////////////////////////////////////////// +/** + * DESTRUCTOR!!! + */ FmodAudioSound:: ~FmodAudioSound() { ReMutexHolder holder(FmodAudioManager::_lock); FMOD_RESULT result; - //Remove me from table of all sounds. + // Remove me from table of all sounds. _manager->_all_sounds.erase(this); - //The Release Sound + // The Release Sound result = _sound->release(); fmod_audio_errcheck("_sound->release()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound:: play -// Access: Public -// Description: Plays a sound. -//////////////////////////////////////////////////////////////////// +/** + * Plays a sound. + */ void FmodAudioSound:: play() { start_playing(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::stop -// Access: Public -// Description: Stop a sound -//////////////////////////////////////////////////////////////////// +/** + * Stop a sound + */ void FmodAudioSound:: stop() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -260,11 +248,9 @@ stop() { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_loop -// Access: Public -// Description: Turns looping on and off -//////////////////////////////////////////////////////////////////// +/** + * Turns looping on and off + */ void FmodAudioSound:: set_loop(bool loop) { if (loop) { @@ -274,11 +260,9 @@ set_loop(bool loop) { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_loop -// Access: Public -// Description: Returns whether looping is on or off -//////////////////////////////////////////////////////////////////// +/** + * Returns whether looping is on or off + */ bool FmodAudioSound:: get_loop() const { if (get_loop_count() == 1) { @@ -288,21 +272,17 @@ get_loop() const { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_loop_count -// Access: Public -// Description: -// Panda uses 0 to mean loop forever. -// Fmod uses negative numbers to mean loop forever. -// (0 means don't loop, 1 means play twice, etc. -// We must convert! -//////////////////////////////////////////////////////////////////// +/** + * + * Panda uses 0 to mean loop forever. Fmod uses negative numbers to mean loop + * forever. (0 means don't loop, 1 means play twice, etc. We must convert! + */ void FmodAudioSound:: set_loop_count(unsigned long loop_count) { ReMutexHolder holder(FmodAudioManager::_lock); audio_debug("FmodAudioSound::set_loop_count() Setting the sound's loop count to: " << loop_count); - //LOCALS + // LOCALS FMOD_RESULT result; if (loop_count == 0) { @@ -325,11 +305,9 @@ set_loop_count(unsigned long loop_count) { audio_debug("FmodAudioSound::set_loop_count() Sound's loop count should be set to: " << loop_count); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_loop_count -// Access: Public -// Description: Return how many times a sound will loop. -//////////////////////////////////////////////////////////////////// +/** + * Return how many times a sound will loop. + */ unsigned long FmodAudioSound:: get_loop_count() const { ReMutexHolder holder(FmodAudioManager::_lock); @@ -346,13 +324,10 @@ get_loop_count() const { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_time -// Access: Public -// Description: Sets the time at which the next play() operation will -// begin. If we are already playing, skips to that time -// immediatey. -//////////////////////////////////////////////////////////////////// +/** + * Sets the time at which the next play() operation will begin. If we are + * already playing, skips to that time immediatey. + */ void FmodAudioSound:: set_time(PN_stdfloat start_time) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -364,11 +339,9 @@ set_time(PN_stdfloat start_time) { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_time -// Access: Public -// Description: Gets the play position within the sound -//////////////////////////////////////////////////////////////////// +/** + * Gets the play position within the sound + */ PN_stdfloat FmodAudioSound:: get_time() const { ReMutexHolder holder(FmodAudioManager::_lock); @@ -388,12 +361,9 @@ get_time() const { return ((double)current_time) / 1000.0; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_volume(PN_stdfloat vol) -// Access: Public -// Description: 0.0 to 1.0 scale of volume converted to Fmod's -// internal 0.0 to 255.0 scale. -//////////////////////////////////////////////////////////////////// +/** + * 0.0 to 1.0 scale of volume converted to Fmod's internal 0.0 to 255.0 scale. + */ void FmodAudioSound:: set_volume(PN_stdfloat vol) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -401,21 +371,17 @@ set_volume(PN_stdfloat vol) { set_volume_on_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_volume -// Access: Public -// Description: Gets the current volume of a sound. 1 is Max. O is Min. -//////////////////////////////////////////////////////////////////// +/** + * Gets the current volume of a sound. 1 is Max. O is Min. + */ PN_stdfloat FmodAudioSound:: get_volume() const { return _volume; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::start_playing -// Access: Private -// Description: Starts the sound playing at _start_time. -//////////////////////////////////////////////////////////////////// +/** + * Starts the sound playing at _start_time. + */ void FmodAudioSound:: start_playing() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -471,11 +437,9 @@ start_playing() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_volume_on_channel() -// Access: Private -// Description: Set the volume on a prepared Sound channel. -//////////////////////////////////////////////////////////////////// +/** + * Set the volume on a prepared Sound channel. + */ void FmodAudioSound:: set_volume_on_channel() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -491,11 +455,9 @@ set_volume_on_channel() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_balance(PN_stdfloat bal) -// Access: Public -// Description: -1.0 to 1.0 scale -//////////////////////////////////////////////////////////////////// +/** + * -1.0 to 1.0 scale + */ void FmodAudioSound:: set_balance(PN_stdfloat bal) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -503,28 +465,22 @@ set_balance(PN_stdfloat bal) { set_speaker_mix_or_balance_on_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_balance -// Access: Public -// Description: -1.0 to 1.0 scale -// -1 should be all the way left. -// 1 is all the way to the right. -//////////////////////////////////////////////////////////////////// +/** + * -1.0 to 1.0 scale -1 should be all the way left. 1 is all the way to the + * right. + */ PN_stdfloat FmodAudioSound:: get_balance() const { return _balance; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_play_rate(PN_stdfloat rate) -// Access: Public -// Description: Sets the speed at which a sound plays back. -// The rate is a multiple of the sound, normal playback speed. -// IE 2 would play back 2 times fast, 3 would play 3 times, and so on. -// This can also be set to a negative number so a sound plays backwards. -// But rememeber if the sound is not playing, you must set the -// sound's time to its end to hear a song play backwards. -//////////////////////////////////////////////////////////////////// +/** + * Sets the speed at which a sound plays back. The rate is a multiple of the + * sound, normal playback speed. IE 2 would play back 2 times fast, 3 would + * play 3 times, and so on. This can also be set to a negative number so a + * sound plays backwards. But rememeber if the sound is not playing, you must + * set the sound's time to its end to hear a song play backwards. + */ void FmodAudioSound:: set_play_rate(PN_stdfloat rate) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -532,21 +488,17 @@ set_play_rate(PN_stdfloat rate) { set_play_rate_on_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_play_rate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat FmodAudioSound:: get_play_rate() const { return _playrate; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_play_rate_on_channel() -// Access: Public -// Description: Set the play rate on a prepared Sound channel. -//////////////////////////////////////////////////////////////////// +/** + * Set the play rate on a prepared Sound channel. + */ void FmodAudioSound:: set_play_rate_on_channel() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -563,22 +515,17 @@ set_play_rate_on_channel() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_name -// Access: Public -// Description: Get name of sound file -//////////////////////////////////////////////////////////////////// +/** + * Get name of sound file + */ const string& FmodAudioSound:: get_name() const { return _file_name; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::length -// Access: Public -// Description: Get length -// FMOD returns the time in MS so we have to convert to seconds. -//////////////////////////////////////////////////////////////////// +/** + * Get length FMOD returns the time in MS so we have to convert to seconds. + */ PN_stdfloat FmodAudioSound:: length() const { ReMutexHolder holder(FmodAudioManager::_lock); @@ -591,21 +538,17 @@ length() const { return ((double)length) / 1000.0; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_3d_attributes -// Access: Public -// Description: Set position and velocity of this sound -// NOW LISTEN UP!!! THIS IS IMPORTANT! -// Both Panda3D and FMOD use a left handed coordinate system. -// But there is a major difference! -// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. -// In FMOD the Y-Axis is going up and the Z-Axis is going into the screen. -// The solution is simple, we just flip the Y and Z axis, as we move coordinates -// from Panda to FMOD and back. -// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. -// But if you decide to do any 3D audio work in here you have to keep it in mind. -// I told you, so you can't say I didn't. -//////////////////////////////////////////////////////////////////// +/** + * Set position and velocity of this sound NOW LISTEN UP!!! THIS IS IMPORTANT! + * Both Panda3D and FMOD use a left handed coordinate system. But there is a + * major difference! In Panda3D the Y-Axis is going into the Screen and the + * Z-Axis is going up. In FMOD the Y-Axis is going up and the Z-Axis is going + * into the screen. The solution is simple, we just flip the Y and Z axis, as + * we move coordinates from Panda to FMOD and back. What does did mean to + * average Panda user? Nothing, they shouldn't notice anyway. But if you + * decide to do any 3D audio work in here you have to keep it in mind. I told + * you, so you can't say I didn't. + */ void FmodAudioSound:: set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -620,11 +563,9 @@ set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx set_3d_attributes_on_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_3d_attributes_on_channel -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FmodAudioSound:: set_3d_attributes_on_channel() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -644,23 +585,19 @@ set_3d_attributes_on_channel() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_3d_attributes -// Access: Public -// Description: Get position and velocity of this sound -// Currently unimplemented. Get the attributes of the attached object. -//////////////////////////////////////////////////////////////////// +/** + * Get position and velocity of this sound Currently unimplemented. Get the + * attributes of the attached object. + */ void FmodAudioSound:: get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { audio_error("get3dAttributes: Currently unimplemented. Get the attributes of the attached object."); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_3d_min_distance -// Access: Public -// Description: Set the distance that this sound begins to fall off. Also -// affects the rate it falls off. -//////////////////////////////////////////////////////////////////// +/** + * Set the distance that this sound begins to fall off. Also affects the rate + * it falls off. + */ void FmodAudioSound:: set_3d_min_distance(PN_stdfloat dist) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -672,21 +609,17 @@ set_3d_min_distance(PN_stdfloat dist) { fmod_audio_errcheck("_sound->set3DMinMaxDistance()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_3d_min_distance -// Access: Public -// Description: Get the distance that this sound begins to fall off -//////////////////////////////////////////////////////////////////// +/** + * Get the distance that this sound begins to fall off + */ PN_stdfloat FmodAudioSound:: get_3d_min_distance() const { return _min_dist; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_3d_max_distance -// Access: Public -// Description: Set the distance that this sound stops falling off -//////////////////////////////////////////////////////////////////// +/** + * Set the distance that this sound stops falling off + */ void FmodAudioSound:: set_3d_max_distance(PN_stdfloat dist) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -698,27 +631,23 @@ set_3d_max_distance(PN_stdfloat dist) { fmod_audio_errcheck("_sound->set3DMinMaxDistance()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_3d_max_distance -// Access: Public -// Description: Get the distance that this sound stops falling off -//////////////////////////////////////////////////////////////////// +/** + * Get the distance that this sound stops falling off + */ PN_stdfloat FmodAudioSound:: get_3d_max_distance() const { return _max_dist; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_speaker_mix -// Access: Published -// Description: In Multichannel Speaker systems [like Surround]. -// -// Speakers which don't exist in some systems will simply be ignored. -// But I haven't been able to test this yet, so I am jsut letting you know. -// -// BTW This will also work in Stereo speaker systems, but since -// PANDA/FMOD has a balance [pan] function what is the point? -//////////////////////////////////////////////////////////////////// +/** + * In Multichannel Speaker systems [like Surround]. + * + * Speakers which don't exist in some systems will simply be ignored. But I + * haven't been able to test this yet, so I am jsut letting you know. + * + * BTW This will also work in Stereo speaker systems, but since PANDA/FMOD has + * a balance [pan] function what is the point? + */ PN_stdfloat FmodAudioSound:: get_speaker_mix(AudioManager::SpeakerId speaker) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -752,22 +681,14 @@ get_speaker_mix(AudioManager::SpeakerId speaker) { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_speaker_mix -// Access: Published -// Description: This sets the speaker mix for Surround Sound sytems. -// It required 8 parameters which match up to the following: -// -// * 1 = Front Left -// * 2 = Front Right -// * 3 = Center -// * 4 = Subwoofer -// * 5 = Back Left -// * 6 = Back Right -// * 7 = Side Left -// * 8 = Side Right -// -//////////////////////////////////////////////////////////////////// +/** + * This sets the speaker mix for Surround Sound sytems. It required 8 + * parameters which match up to the following: + * + * * 1 = Front Left * 2 = Front Right * 3 = Center * 4 = Subwoofer * 5 = Back + * Left * 6 = Back Right * 7 = Side Left * 8 = Side Right + * + */ void FmodAudioSound:: set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat center, PN_stdfloat sub, PN_stdfloat backleft, PN_stdfloat backright, PN_stdfloat sideleft, PN_stdfloat sideright) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -783,17 +704,14 @@ set_speaker_mix(PN_stdfloat frontleft, PN_stdfloat frontright, PN_stdfloat cente set_speaker_mix_or_balance_on_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_speaker_mix_or_balance_on_channel -// Access: Private -// Description: This is simply a safety catch. -// If you are using a Stero speaker setup Panda will only pay attention -// to 'set_balance()' command when setting speaker balances. -// Other wise it will use 'set_speaker_mix'. -// I put this in, because other wise you end up with a sitation, -// where 'set_speaker_mix()' or 'set_balace()' will override any -// previous speaker balance setups. It all depends on which was called last. -//////////////////////////////////////////////////////////////////// +/** + * This is simply a safety catch. If you are using a Stero speaker setup + * Panda will only pay attention to 'set_balance()' command when setting + * speaker balances. Other wise it will use 'set_speaker_mix'. I put this in, + * because other wise you end up with a sitation, where 'set_speaker_mix()' or + * 'set_balace()' will override any previous speaker balance setups. It all + * depends on which was called last. + */ void FmodAudioSound:: set_speaker_mix_or_balance_on_channel() { ReMutexHolder holder(FmodAudioManager::_lock); @@ -825,25 +743,20 @@ set_speaker_mix_or_balance_on_channel() { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_priority -// Access: Published -// Description: Sets the priority of a sound. -// This is what FMOD uses to determine is a sound will -// play if all the other real channels have been used up. -//////////////////////////////////////////////////////////////////// +/** + * Sets the priority of a sound. This is what FMOD uses to determine is a + * sound will play if all the other real channels have been used up. + */ int FmodAudioSound:: get_priority() { audio_debug("FmodAudioSound::get_priority()"); return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_priority(int priority) -// Access: Published -// Description: Sets the Sound Priority [Whether is will be played -// over other sound when real audio channels become short. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Sound Priority [Whether is will be played over other sound when + * real audio channels become short. + */ void FmodAudioSound:: set_priority(int priority) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -858,11 +771,9 @@ set_priority(int priority) { fmod_audio_errcheck("_sound->setDefaults()", result); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::status -// Access: Public -// Description: Get status of the sound. -//////////////////////////////////////////////////////////////////// +/** + * Get status of the sound. + */ AudioSound::SoundStatus FmodAudioSound:: status() const { ReMutexHolder holder(FmodAudioManager::_lock); @@ -881,14 +792,11 @@ status() const { } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_active -// Access: Public -// Description: Sets whether the sound is marked "active". By -// default, the active flag true for all sounds. If the -// active flag is set to false for any particular sound, -// the sound will not be heard. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the sound is marked "active". By default, the active flag + * true for all sounds. If the active flag is set to false for any particular + * sound, the sound will not be heard. + */ void FmodAudioSound:: set_active(bool active) { ReMutexHolder holder(FmodAudioManager::_lock); @@ -917,67 +825,56 @@ set_active(bool active) { } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_active -// Access: Public -// Description: Returns whether the sound has been marked "active". -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the sound has been marked "active". + */ bool FmodAudioSound:: get_active() const { return _active; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::finished -// Access: Public -// Description: Not implemented. -//////////////////////////////////////////////////////////////////// +/** + * Not implemented. + */ void FmodAudioSound:: finished() { audio_error("finished: not implemented under FMOD-EX"); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::set_finished_event -// Access: Public -// Description: NOT USED ANYMORE!!! -// Assign a string for the finished event to be referenced -// by in python by an accept method -// -//////////////////////////////////////////////////////////////////// +/** + * NOT USED ANYMORE!!! Assign a string for the finished event to be referenced + * by in python by an accept method + * + */ void FmodAudioSound:: set_finished_event(const string& event) { audio_error("set_finished_event: not implemented under FMOD-EX"); } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::get_finished_event -// Access: Public -// Description:NOT USED ANYMORE!!! -// Return the string the finished event is referenced by -// -// -//////////////////////////////////////////////////////////////////// +/** + * NOT USED ANYMORE!!! Return the string the finished event is referenced by + * + + * + */ const string& FmodAudioSound:: get_finished_event() const { audio_error("get_finished_event: not implemented under FMOD-EX"); return _finished_event; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::sound_end_callback -// Access: Private, Static -// Description: When fmod finishes playing a sound, decrements the -// reference count of the associated FmodAudioSound. -//////////////////////////////////////////////////////////////////// +/** + * When fmod finishes playing a sound, decrements the reference count of the + * associated FmodAudioSound. + */ FMOD_RESULT F_CALLBACK FmodAudioSound:: sound_end_callback(FMOD_CHANNEL * channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2) { // Fortunately, this callback is made synchronously rather than - // asynchronously (it is triggered during System::update()), so we - // don't have to worry about thread-related issues here. + // asynchronously (it is triggered during System::update()), so we don't + // have to worry about thread-related issues here. if (type == FMOD_CHANNEL_CALLBACKTYPE_END) { FMOD::Channel *fc = (FMOD::Channel *)channel; void *userdata = NULL; @@ -989,11 +886,9 @@ sound_end_callback(FMOD_CHANNEL * channel, return FMOD_OK; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::open_callback -// Access: Private, Static -// Description: A hook into Panda's virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * A hook into Panda's virtual file system. + */ FMOD_RESULT F_CALLBACK FmodAudioSound:: open_callback(const char *name, int, unsigned int *file_size, void **handle, void **user_data) { @@ -1013,18 +908,16 @@ open_callback(const char *name, int, unsigned int *file_size, (*handle) = (void *)str; (*user_data) = (void *)file; - // Explicitly ref the VirtualFile since we're storing it in a void - // pointer instead of a PT(VirtualFile). + // Explicitly ref the VirtualFile since we're storing it in a void pointer + // instead of a PT(VirtualFile). file->ref(); return FMOD_OK; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::close_callback -// Access: Private, Static -// Description: A hook into Panda's virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * A hook into Panda's virtual file system. + */ FMOD_RESULT F_CALLBACK FmodAudioSound:: close_callback(void *handle, void *user_data) { VirtualFile *file = (VirtualFile *)user_data; @@ -1044,11 +937,9 @@ close_callback(void *handle, void *user_data) { return FMOD_OK; } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::read_callback -// Access: Private, Static -// Description: A hook into Panda's virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * A hook into Panda's virtual file system. + */ FMOD_RESULT F_CALLBACK FmodAudioSound:: read_callback(void *handle, void *buffer, unsigned int size_bytes, unsigned int *bytes_read, void *user_data) { @@ -1062,11 +953,10 @@ read_callback(void *handle, void *buffer, unsigned int size_bytes, str->read((char *)buffer, size_bytes); (*bytes_read) = str->gcount(); - // We can't yield here, since this callback is made within a - // sub-thread--an OS-level sub-thread spawned by FMod, not a Panda - // thread. But we will only execute this code in the true-threads - // case anyway. - //thread_consider_yield(); + // We can't yield here, since this callback is made within a sub-thread--an + // OS-level sub-thread spawned by FMod, not a Panda thread. But we will + // only execute this code in the true-threads case anyway. + // thread_consider_yield(); if (str->eof()) { if ((*bytes_read) == 0) { @@ -1082,11 +972,9 @@ read_callback(void *handle, void *buffer, unsigned int size_bytes, } } -//////////////////////////////////////////////////////////////////// -// Function: FmodAudioSound::seek_callback -// Access: Private, Static -// Description: A hook into Panda's virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * A hook into Panda's virtual file system. + */ FMOD_RESULT F_CALLBACK FmodAudioSound:: seek_callback(void *handle, unsigned int pos, void *user_data) { VirtualFile *file = (VirtualFile *)user_data; diff --git a/panda/src/audiotraits/fmodAudioSound.h b/panda/src/audiotraits/fmodAudioSound.h index 774fcaecce..c77664ab61 100644 --- a/panda/src/audiotraits/fmodAudioSound.h +++ b/panda/src/audiotraits/fmodAudioSound.h @@ -1,70 +1,62 @@ -// Filename: fmodAudioSound.h -// Created by: cort (January 22, 2003) -// Prior system by: cary -// Rewrite [for new Version of FMOD-EX] by: Stan Rosenbaum "Staque" - Spring 2006 -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// -// -//////////////////////////////////////////////////////////////////// -// -// [FIRST READ FmodAudioManager for an Introduction if you haven't -// already]. -// -// Hello, all future Panda audio code people! This is my errata -// documentation to Help any future programmer maintain FMOD and PANDA. -// -// Well, if you reading this you probably want to know how PANDA deals -// with sounds directly using FMOD-EX. Well I am going to tell you. -// -// The first thing, you as the programmer have to understand, -// especially if you never have done sound programming before, is how -// the FMOD-EX API works. -// -// With FMOD-EX the guys at Firelight, adopted a model of managing -// sounds with FMOD similar to how a Sound Designer creates sound in a -// sound studio using SOUNDS and CHANNELS. Although this may seem -// strange at first, if you are not familiar with sound programming, -// there is a very good metaphor you are probably already familiar with -// to explain how FMOD-EX works. -// -// Think of you standard GUI API. Usually a GUI API is made up of two -// things: Windows and Widgets. These correspond to CHANNELS and -// SOUNDS, where a Channel is a Window and a Sound is Widget. Sounds -// are played within channels, and channels don't exist unless they -// have something to display. -// -// Now why am I explaining all of this? When PANDA was created they set -// up the basic audio classes to handle only the idea of a SOUND. The -// idea of a Channel really wasn't prevalent as in more modern Audio -// APIs. With this rewrite of PANDA to use the FMOD-EX API, the PANDA -// FmodAudioSound Class, now has to handle two different parts of the -// FMOD-EX API in order to play a sound. -// -// SOUND: The object the handles the audio data in form of WAV, AIF, -// OGG, MID, IT, MP3, etc... And CHANNEL: The object that actually -// plays the sound and manipulates it in real time. -// -// Ultimately this isn't a problem expect for a couple situations when -// you go to play a sound, which I will explain in more detail in that -// part of the code. All that you have to know right now is that -// Channels in FMOD do not exist unless they are playing a sound. And -// in the PANDA FmodAudioSound API class there is only ONE dedicated -// channel per sound. Otherwise there is really nothing to worry -// about. -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fmodAudioSound.h + * @author cort + * @date 2003-01-22 + * Prior system by: cary + * @author Stan Rosenbaum "Staque" - Spring 2006 + * + * [FIRST READ FmodAudioManager for an Introduction if you haven't + * already]. + * + * Hello, all future Panda audio code people! This is my errata + * documentation to Help any future programmer maintain FMOD and PANDA. + * + * Well, if you reading this you probably want to know how PANDA deals + * with sounds directly using FMOD-EX. Well I am going to tell you. + * + * The first thing, you as the programmer have to understand, + * especially if you never have done sound programming before, is how + * the FMOD-EX API works. + * + * With FMOD-EX the guys at Firelight, adopted a model of managing + * sounds with FMOD similar to how a Sound Designer creates sound in a + * sound studio using SOUNDS and CHANNELS. Although this may seem + * strange at first, if you are not familiar with sound programming, + * there is a very good metaphor you are probably already familiar with + * to explain how FMOD-EX works. + * + * Think of you standard GUI API. Usually a GUI API is made up of two + * things: Windows and Widgets. These correspond to CHANNELS and + * SOUNDS, where a Channel is a Window and a Sound is Widget. Sounds + * are played within channels, and channels don't exist unless they + * have something to display. + * + * Now why am I explaining all of this? When PANDA was created they set + * up the basic audio classes to handle only the idea of a SOUND. The + * idea of a Channel really wasn't prevalent as in more modern Audio + * APIs. With this rewrite of PANDA to use the FMOD-EX API, the PANDA + * FmodAudioSound Class, now has to handle two different parts of the + * FMOD-EX API in order to play a sound. + * + * SOUND: The object the handles the audio data in form of WAV, AIF, + * OGG, MID, IT, MP3, etc... And CHANNEL: The object that actually + * plays the sound and manipulates it in real time. + * + * Ultimately this isn't a problem expect for a couple situations when + * you go to play a sound, which I will explain in more detail in that + * part of the code. All that you have to know right now is that + * Channels in FMOD do not exist unless they are playing a sound. And + * in the PANDA FmodAudioSound API class there is only ONE dedicated + * channel per sound. Otherwise there is really nothing to worry + * about. + */ #ifndef __FMOD_AUDIO_SOUND_H__ #define __FMOD_AUDIO_SOUND_H__ @@ -84,42 +76,33 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { FmodAudioSound(AudioManager *manager, Filename fn, bool positional ); ~FmodAudioSound(); - // For best compatibility, set the loop_count, start_time, - // volume, and balance, prior to calling play(). You may - // set them while they're playing, but it's implementation - // specific whether you get the results. + // For best compatibility, set the loop_count, start_time, volume, and + // balance, prior to calling play(). You may set them while they're + // playing, but it's implementation specific whether you get the results. void play(); void stop(); - // loop: false = play once; true = play forever. - // inits to false. + // loop: false = play once; true = play forever. inits to false. void set_loop(bool loop=true); bool get_loop() const; - // loop_count: 0 = forever; 1 = play once; n = play n times. - // inits to 1. + // loop_count: 0 = forever; 1 = play once; n = play n times. inits to 1. void set_loop_count(unsigned long loop_count=1); unsigned long get_loop_count() const; - // 0 = beginning; length() = end. - // inits to 0.0. + // 0 = beginning; length() = end. inits to 0.0. void set_time(PN_stdfloat start_time=0.0); PN_stdfloat get_time() const; - // 0 = minimum; 1.0 = maximum. - // inits to 1.0. + // 0 = minimum; 1.0 = maximum. inits to 1.0. void set_volume(PN_stdfloat volume=1.0); PN_stdfloat get_volume() const; - // -1.0 is hard left - // 0.0 is centered - // 1.0 is hard right - // inits to 0.0. + // -1.0 is hard left 0.0 is centered 1.0 is hard right inits to 0.0. void set_balance(PN_stdfloat balance_right=0.0); PN_stdfloat get_balance() const; - // play_rate is any positive float value. - // inits to 1.0. + // play_rate is any positive float value. inits to 1.0. void set_play_rate(PN_stdfloat play_rate=1.0f); PN_stdfloat get_play_rate() const; @@ -128,9 +111,9 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { // return: playing time in seconds. PN_stdfloat length() const; - // Controls the position of this sound's emitter. - // pos is a pointer to an xyz triplet of the emitter's position. - // vel is a pointer to an xyz triplet of the emitter's velocity. + // Controls the position of this sound's emitter. pos is a pointer to an + // xyz triplet of the emitter's position. vel is a pointer to an xyz + // triplet of the emitter's velocity. void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); @@ -196,10 +179,9 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { // This reference-counting pointer is set to this while the sound is // playing, and cleared when we get an indication that the sound has - // stopped. This prevents a sound from destructing while it is - // playing. We use a PT instead of managing the reference counts by - // hand to help guard against accidental reference count leaks or - // other mismanagement. + // stopped. This prevents a sound from destructing while it is playing. We + // use a PT instead of managing the reference counts by hand to help guard + // against accidental reference count leaks or other mismanagement. PT(FmodAudioSound) _self_ref; static FMOD_RESULT F_CALLBACK @@ -223,9 +205,7 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { seek_callback(void *handle, unsigned int pos, void *user_data); -//////////////////////////////////////////////////////////////////// - //These are needed for Panda's Pointer System. DO NOT ERASE! -//////////////////////////////////////////////////////////////////// + // These are needed for Panda's Pointer System. DO NOT ERASE! public: static TypeHandle get_class_type() { @@ -246,9 +226,7 @@ class EXPCL_FMOD_AUDIO FmodAudioSound : public AudioSound { private: static TypeHandle _type_handle; -//////////////////////////////////////////////////////////////////// - //DONE -//////////////////////////////////////////////////////////////////// + // DONE }; #include "fmodAudioSound.I" diff --git a/panda/src/audiotraits/globalMilesManager.I b/panda/src/audiotraits/globalMilesManager.I index 4d96642f84..2a1ae3028e 100644 --- a/panda/src/audiotraits/globalMilesManager.I +++ b/panda/src/audiotraits/globalMilesManager.I @@ -1,47 +1,37 @@ -// Filename: globalMilesManager.I -// Created by: drose (30Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalMilesManager.I + * @author drose + * @date 2007-07-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::is_open -// Access: Public -// Description: Returns true if the Miles Sound System is open (and -// active), false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Miles Sound System is open (and active), false if it is + * not. + */ INLINE bool GlobalMilesManager:: is_open() const { return _is_open; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::get_num_samples -// Access: Public -// Description: Returns the number of sample handles that have been -// allocated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sample handles that have been allocated. + */ INLINE int GlobalMilesManager:: get_num_samples() const { LightMutexHolder holder(_samples_lock); return _samples.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::get_num_sequences -// Access: Public -// Description: Returns the number of sequence handles that have been -// allocated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sequence handles that have been allocated. + */ INLINE int GlobalMilesManager:: get_num_sequences() const { LightMutexHolder holder(_sequences_lock); diff --git a/panda/src/audiotraits/globalMilesManager.cxx b/panda/src/audiotraits/globalMilesManager.cxx index 81b0a2be33..163147c75e 100644 --- a/panda/src/audiotraits/globalMilesManager.cxx +++ b/panda/src/audiotraits/globalMilesManager.cxx @@ -1,16 +1,15 @@ -// Filename: globalMilesManager.cxx -// Created by: drose (26Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalMilesManager.cxx + * @author drose + * @date 2007-07-26 + */ #include "globalMilesManager.h" @@ -23,19 +22,17 @@ #ifdef WIN32 // For midiOutReset() -#include +#include #include #endif GlobalMilesManager *GlobalMilesManager::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GlobalMilesManager:: -GlobalMilesManager() : +GlobalMilesManager() : _managers_lock("GlobalMilesManager::_managers_lock"), _samples_lock("GlobalMilesManager::_samples_lock"), _sequences_lock("GlobalMilesManager::_sequences_lock") @@ -47,13 +44,10 @@ GlobalMilesManager() : _is_open = false; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::add_manager -// Access: Public -// Description: Records a new MilesAudioManager in the world. This -// will open the Miles API when the first audio manager -// is added. -//////////////////////////////////////////////////////////////////// +/** + * Records a new MilesAudioManager in the world. This will open the Miles API + * when the first audio manager is added. + */ void GlobalMilesManager:: add_manager(MilesAudioManager *manager) { LightMutexHolder holder(_managers_lock); @@ -63,13 +57,10 @@ add_manager(MilesAudioManager *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::remove_manager -// Access: Public -// Description: Records that a MilesAudioManager is destructing. -// This will clsoe the Miles API when the last audio -// manager is removed. -//////////////////////////////////////////////////////////////////// +/** + * Records that a MilesAudioManager is destructing. This will clsoe the Miles + * API when the last audio manager is removed. + */ void GlobalMilesManager:: remove_manager(MilesAudioManager *manager) { LightMutexHolder holder(_managers_lock); @@ -79,12 +70,9 @@ remove_manager(MilesAudioManager *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::cleanup -// Access: Public -// Description: Calls cleanup() on all MilesAudioManagers, to cause a -// clean shutdown. -//////////////////////////////////////////////////////////////////// +/** + * Calls cleanup() on all MilesAudioManagers, to cause a clean shutdown. + */ void GlobalMilesManager:: cleanup() { LightMutexHolder holder(_managers_lock); @@ -94,21 +82,17 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::get_sample -// Access: Public -// Description: Gets a sample handle from the global pool for the -// digital output device, to be used with the indicated -// AudioSound. -// -// If successful, sets the sample handle and the index -// (which should later be used to release the sample) -// and returns true. If unsuccessful (because there are -// no more available handles), returns false. -// -// This is a very limited resource; you should only get -// a sample just before playing a sound. -//////////////////////////////////////////////////////////////////// +/** + * Gets a sample handle from the global pool for the digital output device, to + * be used with the indicated AudioSound. + * + * If successful, sets the sample handle and the index (which should later be + * used to release the sample) and returns true. If unsuccessful (because + * there are no more available handles), returns false. + * + * This is a very limited resource; you should only get a sample just before + * playing a sound. + */ bool GlobalMilesManager:: get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { LightMutexHolder holder(_samples_lock); @@ -117,8 +101,7 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { SampleData &smp = _samples[i]; if (AIL_sample_status(smp._sample) == SMP_DONE) { if (smp._sound != NULL) { - // Tell the last sound that was using this sample that it's - // done now. + // Tell the last sound that was using this sample that it's done now. smp._sound->internal_stop(); } smp._sound = sound; @@ -133,7 +116,7 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { if (sample == 0) { return false; } - + AIL_init_sample(sample, DIG_F_STEREO_16, 0); index = _samples.size(); @@ -144,12 +127,9 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::release_sample -// Access: Public -// Description: Indicates that the indicated AudioSound no longer -// needs this sample. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the indicated AudioSound no longer needs this sample. + */ void GlobalMilesManager:: release_sample(size_t index, MilesAudioSample *sound) { LightMutexHolder holder(_samples_lock); @@ -161,21 +141,17 @@ release_sample(size_t index, MilesAudioSample *sound) { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::get_sequence -// Access: Public -// Description: Gets a sequence handle from the global pool for the -// digital output device, to be used with the indicated -// AudioSound. -// -// If successful, sets the sequence handle and the index -// (which should later be used to release the sequence) -// and returns true. If unsuccessful (because there are -// no more available handles), returns false. -// -// This is a very limited resource; you should only get -// a sequence just before playing a sound. -//////////////////////////////////////////////////////////////////// +/** + * Gets a sequence handle from the global pool for the digital output device, + * to be used with the indicated AudioSound. + * + * If successful, sets the sequence handle and the index (which should later + * be used to release the sequence) and returns true. If unsuccessful + * (because there are no more available handles), returns false. + * + * This is a very limited resource; you should only get a sequence just before + * playing a sound. + */ bool GlobalMilesManager:: get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { LightMutexHolder holder(_sequences_lock); @@ -184,8 +160,8 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { SequenceData &seq = _sequences[i]; if (AIL_sequence_status(seq._sequence) == SEQ_DONE) { if (seq._sound != NULL) { - // Tell the last sound that was using this sequence that it's - // done now. + // Tell the last sound that was using this sequence that it's done + // now. seq._sound->internal_stop(); } seq._sound = sound; @@ -200,7 +176,7 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { if (sequence == 0) { return false; } - + index = _sequences.size(); SequenceData seq; @@ -210,12 +186,9 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::release_sequence -// Access: Public -// Description: Indicates that the indicated AudioSound no longer -// needs this sequence. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the indicated AudioSound no longer needs this sequence. + */ void GlobalMilesManager:: release_sequence(size_t index, MilesAudioSequence *sound) { LightMutexHolder holder(_sequences_lock); @@ -227,18 +200,15 @@ release_sequence(size_t index, MilesAudioSequence *sound) { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::force_midi_reset -// Access: Public -// Description: Sometimes Miles seems to leave midi notes hanging, -// even after stop is called, so call this method to -// perform an explicit reset using winMM.dll calls, just -// to ensure silence. -//////////////////////////////////////////////////////////////////// +/** + * Sometimes Miles seems to leave midi notes hanging, even after stop is + * called, so call this method to perform an explicit reset using winMM.dll + * calls, just to ensure silence. + */ void GlobalMilesManager:: force_midi_reset() { if (!miles_audio_force_midi_reset) { - audio_debug("MilesAudioManager::skipping force_midi_reset"); + audio_debug("MilesAudioManager::skipping force_midi_reset"); return; } audio_debug("MilesAudioManager::force_midi_reset"); @@ -251,12 +221,9 @@ force_midi_reset() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::get_global_ptr -// Access: Public, Static -// Description: Returns the pointer to the one GlobalMilesManager -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the one GlobalMilesManager object. + */ GlobalMilesManager *GlobalMilesManager:: get_global_ptr() { if (_global_ptr == NULL) { @@ -265,11 +232,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::open_api -// Access: Private -// Description: Called internally to initialize the Miles API. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to initialize the Miles API. + */ void GlobalMilesManager:: open_api() { audio_debug("GlobalMilesManager::open_api()") @@ -283,7 +248,7 @@ open_api() { #ifdef IS_OSX audio_software_midi = true; #endif - + audio_debug(" use_digital="<close_read_file(strm); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::seek_callback -// Access: Private, Static -// Description: This callback function is given to Miles to handle -// file I/O via the Panda VFS. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is given to Miles to handle file I/O via the Panda + * VFS. + */ S32 AILCALLBACK GlobalMilesManager:: seek_callback(UINTa file_handle, S32 offset, U32 type) { istream *strm = (istream *)file_handle; @@ -473,12 +429,10 @@ seek_callback(UINTa file_handle, S32 offset, U32 type) { return strm->tellg(); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalMilesManager::read_callback -// Access: Private, Static -// Description: This callback function is given to Miles to handle -// file I/O via the Panda VFS. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is given to Miles to handle file I/O via the Panda + * VFS. + */ U32 AILCALLBACK GlobalMilesManager:: read_callback(UINTa file_handle, void *buffer, U32 bytes) { istream *strm = (istream *)file_handle; @@ -487,4 +441,3 @@ read_callback(UINTa file_handle, void *buffer, U32 bytes) { } #endif //] - diff --git a/panda/src/audiotraits/globalMilesManager.h b/panda/src/audiotraits/globalMilesManager.h index 7dfa2cad6d..e7e0a11646 100644 --- a/panda/src/audiotraits/globalMilesManager.h +++ b/panda/src/audiotraits/globalMilesManager.h @@ -1,16 +1,15 @@ -// Filename: globalMilesManager.h -// Created by: drose (26Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalMilesManager.h + * @author drose + * @date 2007-07-26 + */ #ifndef GLOBALMILESMANAGER_H #define GLOBALMILESMANAGER_H @@ -34,12 +33,11 @@ class MilesAudioSample; class MilesAudioSequence; -//////////////////////////////////////////////////////////////////// -// Class : GlobalMilesManager -// Description : This is a wrapper around the parts of the Miles API -// that should only be created once. This represents -// the global data common to all MilesAudioManagers. -//////////////////////////////////////////////////////////////////// +/** + * This is a wrapper around the parts of the Miles API that should only be + * created once. This represents the global data common to all + * MilesAudioManagers. + */ class EXPCL_MILES_AUDIO GlobalMilesManager { private: GlobalMilesManager(); @@ -107,7 +105,7 @@ private: typedef pvector Sequences; Sequences _sequences; LightMutex _sequences_lock; - + static GlobalMilesManager *_global_ptr; }; @@ -116,6 +114,3 @@ private: #endif //] #endif - - - diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index 3f56ad509a..5414d49574 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -1,17 +1,16 @@ -// Filename: milesAudioManager.cxx -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioManager.cxx + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #include "milesAudioManager.h" @@ -40,21 +39,18 @@ AudioManager *Create_MilesAudioManager() { return new MilesAudioManager(); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::Constructor -// Access: Public -// Description: Create an audio manager. This may open the Miles -// sound system if there were no other MilesAudioManager -// instances. Subsequent managers may use the same -// Miles resources. -//////////////////////////////////////////////////////////////////// +/** + * Create an audio manager. This may open the Miles sound system if there + * were no other MilesAudioManager instances. Subsequent managers may use the + * same Miles resources. + */ MilesAudioManager:: -MilesAudioManager() : +MilesAudioManager() : _lock("MilesAudioManager::_lock"), _streams_lock("MilesAudioManager::_streams_lock"), _streams_cvar(_streams_lock) { - audio_debug("MilesAudioManager::MilesAudioManager(), this = " + audio_debug("MilesAudioManager::MilesAudioManager(), this = " << (void *)this); GlobalMilesManager::get_global_ptr()->add_manager(this); audio_debug(" audio_active="<= (unsigned int)_cache_limit) { uncache_a_sound(); } - // Put it in the pool: - // The following is roughly like: _sounds[path] = sd; - // But, it gives us an iterator into the map. + // Put it in the pool: The following is roughly like: _sounds[path] = + // sd; But, it gives us an iterator into the map. pair ib = _sounds.insert(SoundMap::value_type(path, sd)); if (!ib.second) { @@ -177,8 +161,8 @@ get_sound(const string &file_name, bool, int) { nassertr(do_is_valid(), NULL); return get_null_sound(); } - // Set si, so that we can get a reference to the path - // for the MilesAudioSound. + // Set si, so that we can get a reference to the path for the + // MilesAudioSound. si=ib.first; } } @@ -219,22 +203,18 @@ get_sound(const string &file_name, bool, int) { return audioSound; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::get_sound -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(AudioSound) MilesAudioManager:: get_sound(MovieAudio *sound, bool, int) { nassert_raise("Miles audio manager does not support MovieAudio sources."); return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::uncache_sound -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioManager:: uncache_sound(const string &file_name) { audio_debug("MilesAudioManager::uncache_sound(file_name=\"" @@ -258,11 +238,9 @@ uncache_sound(const string &file_name) { nassertv(do_is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::clear_cache -// Access: Public, Virtual -// Description: Clear out the sound cache. -//////////////////////////////////////////////////////////////////// +/** + * Clear out the sound cache. + */ void MilesAudioManager:: clear_cache() { audio_debug("MilesAudioManager::clear_cache()"); @@ -270,11 +248,9 @@ clear_cache() { do_clear_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::set_cache_limit -// Access: Public, Virtual -// Description: Set the number of sounds that the cache can hold. -//////////////////////////////////////////////////////////////////// +/** + * Set the number of sounds that the cache can hold. + */ void MilesAudioManager:: set_cache_limit(unsigned int count) { LightReMutexHolder holder(_lock); @@ -288,21 +264,17 @@ set_cache_limit(unsigned int count) { nassertv(do_is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::get_cache_limit -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int MilesAudioManager:: get_cache_limit() const { return _cache_limit; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::set_volume -// Access: Public, Virtual -// Description: set the overall volume -//////////////////////////////////////////////////////////////////// +/** + * set the overall volume + */ void MilesAudioManager:: set_volume(PN_stdfloat volume) { audio_debug("MilesAudioManager::set_volume(volume="<_digital_driver, fx, fz, fy, ux, uz, uy); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_get_listener_attributes -// Access: Public -// Description: Get spatial attributes of the listener for 3D -// sounds. Note that Y and Z are switched to -// translate from Miles's coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Get spatial attributes of the listener for 3D sounds. Note that Y and Z + * are switched to translate from Miles's coordinate system. + */ void MilesAudioManager::audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { audio_debug("MilesAudioManager::audio_3d_get_listener_attributes()"); @@ -479,12 +427,10 @@ void MilesAudioManager::audio_3d_get_listener_attributes(PN_stdfloat *px, PN_std *uz = luz; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_set_distance_factor -// Access: Public -// Description: Set factor to allow user to easily work in a -// different scale. 1.0 represents meters. -//////////////////////////////////////////////////////////////////// +/** + * Set factor to allow user to easily work in a different scale. 1.0 + * represents meters. + */ void MilesAudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) { audio_debug("MilesAudioManager::audio_3d_set_distance_factor( factor= " << factor << ")"); @@ -492,11 +438,9 @@ void MilesAudioManager::audio_3d_set_distance_factor(PN_stdfloat factor) { AIL_set_3D_distance_factor(mgr->_digital_driver, factor); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_get_distance_factor -// Access: Public -// Description: Get factor controlling working units. -//////////////////////////////////////////////////////////////////// +/** + * Get factor controlling working units. + */ PN_stdfloat MilesAudioManager::audio_3d_get_distance_factor() const { audio_debug("MilesAudioManager::audio_3d_get_distance_factor()"); @@ -504,12 +448,9 @@ PN_stdfloat MilesAudioManager::audio_3d_get_distance_factor() const { return AIL_3D_distance_factor(mgr->_digital_driver); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_set_doppler_factor -// Access: Public -// Description: Exaggerates or diminishes the Doppler effect. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Exaggerates or diminishes the Doppler effect. Defaults to 1.0 + */ void MilesAudioManager::audio_3d_set_doppler_factor(PN_stdfloat factor) { audio_debug("MilesAudioManager::audio_3d_set_doppler_factor(factor="<_digital_driver, factor); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_get_doppler_factor -// Access: Public -// Description: Get the factor controlling the Doppler effect. -//////////////////////////////////////////////////////////////////// +/** + * Get the factor controlling the Doppler effect. + */ PN_stdfloat MilesAudioManager::audio_3d_get_doppler_factor() const { audio_debug("MilesAudioManager::audio_3d_get_doppler_factor()"); @@ -529,12 +468,9 @@ PN_stdfloat MilesAudioManager::audio_3d_get_doppler_factor() const { return AIL_3D_doppler_factor(mgr->_digital_driver); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_set_drop_off_factor -// Access: Public -// Description: Control the effect distance has on audability. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Control the effect distance has on audability. Defaults to 1.0 + */ void MilesAudioManager::audio_3d_set_drop_off_factor(PN_stdfloat factor) { audio_debug("MilesAudioManager::audio_3d_set_drop_off_factor("<_digital_driver, factor); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::audio_3d_get_drop_off_factor -// Access: Public -// Description: Get the factor controlling how quickly sound falls -// off with distance. -//////////////////////////////////////////////////////////////////// +/** + * Get the factor controlling how quickly sound falls off with distance. + */ PN_stdfloat MilesAudioManager::audio_3d_get_drop_off_factor() const { audio_debug("MilesAudioManager::audio_3d_get_drop_off_factor()"); @@ -555,18 +488,15 @@ PN_stdfloat MilesAudioManager::audio_3d_get_drop_off_factor() const { return AIL_3D_rolloff_factor(mgr->_digital_driver); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::set_speaker_configuration -// Access: Published -// Description: Works similarly to MilesAudioSound::set_speaker_levels, -// but specifies the 3D positions of the speakers in space. -// -// Once a NULL value is found for a speaker position, -// no more speaker positions will be used. -// -// Note that Y and Z are switched to translate from Miles's -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Works similarly to MilesAudioSound::set_speaker_levels, but specifies the + * 3D positions of the speakers in space. + * + * Once a NULL value is found for a speaker position, no more speaker + * positions will be used. + * + * Note that Y and Z are switched to translate from Miles's coordinate system. + */ void MilesAudioManager:: set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *speaker3, LVecBase3 *speaker4, LVecBase3 *speaker5, LVecBase3 *speaker6, LVecBase3 *speaker7, LVecBase3 *speaker8, LVecBase3 *speaker9) { audio_debug("MilesAudioManager::set_speaker_configuration()"); @@ -644,32 +574,29 @@ set_speaker_configuration(LVecBase3 *speaker1, LVecBase3 *speaker2, LVecBase3 *s } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::update() -// Access: Public, Virtual -// Description: Must be called every frame. Failure to call this -// every frame could cause problems for some audio -// managers. -//////////////////////////////////////////////////////////////////// +/** + * Must be called every frame. Failure to call this every frame could cause + * problems for some audio managers. + */ void MilesAudioManager:: update() { { MutexHolder holder(_streams_lock); if (_stream_thread.is_null() && !_streams.empty()) { - // If we don't have a sub-thread, we have to service the streams - // in the main thread. + // If we don't have a sub-thread, we have to service the streams in the + // main thread. do_service_streams(); } } if (_sounds_finished) { _sounds_finished = false; - - // If the _sounds_finished flag was set, we should scan our list - // of playing sounds and see if any of them have finished - // recently. We don't do this in the finished callback, because - // that might have been called in a sub-thread (and we may not - // have threading supported--and mutex protection--compiled in). + + // If the _sounds_finished flag was set, we should scan our list of + // playing sounds and see if any of them have finished recently. We don't + // do this in the finished callback, because that might have been called + // in a sub-thread (and we may not have threading supported--and mutex + // protection--compiled in). SoundsPlaying::iterator si = _sounds_playing.begin(); while (si != _sounds_playing.end()) { @@ -683,11 +610,9 @@ update() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::release_sound -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioManager:: release_sound(MilesAudioSound *audioSound) { audio_debug("MilesAudioManager::release_sound(audioSound=\"" @@ -701,13 +626,10 @@ release_sound(MilesAudioSound *audioSound) { audio_debug("MilesAudioManager::release_sound() finished"); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::cleanup -// Access: Public -// Description: Shuts down the audio manager and releases any -// resources associated with it. Also cleans up all -// AudioSounds created via the manager. -//////////////////////////////////////////////////////////////////// +/** + * Shuts down the audio manager and releases any resources associated with it. + * Also cleans up all AudioSounds created via the manager. + */ void MilesAudioManager:: cleanup() { audio_debug("MilesAudioManager::cleanup(), this = " << (void *)this @@ -747,23 +669,19 @@ cleanup() { audio_debug("MilesAudioManager::cleanup() finished"); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioManager:: output(ostream &out) const { LightReMutexHolder holder(_lock); out << get_type() << ": " << _sounds_playing.size() - << " / " << _sounds_on_loan.size() << " sounds playing / total"; + << " / " << _sounds_on_loan.size() << " sounds playing / total"; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioManager:: write(ostream &out) const { LightReMutexHolder holder(_lock); @@ -795,7 +713,7 @@ write(ostream &out) const { } GlobalMilesManager *mgr = GlobalMilesManager::get_global_ptr(); - + int num_samples = mgr->get_num_samples(); out << num_samples << " sample handles allocated globally.\n"; @@ -804,12 +722,9 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::do_is_valid -// Access: Private -// Description: Implementation of is_valid(). Assumes the lock is -// already held. -//////////////////////////////////////////////////////////////////// +/** + * Implementation of is_valid(). Assumes the lock is already held. + */ bool MilesAudioManager:: do_is_valid() { bool check = true; @@ -831,11 +746,9 @@ do_is_valid() { return _is_valid && check; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::do_reduce_sounds_playing_to -// Access: Private -// Description: Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the lock is already held. + */ void MilesAudioManager:: do_reduce_sounds_playing_to(unsigned int count) { int limit = _sounds_playing.size() - count; @@ -846,11 +759,9 @@ do_reduce_sounds_playing_to(unsigned int count) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::do_clear_cache -// Access: Private -// Description: Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the lock is already held. + */ void MilesAudioManager:: do_clear_cache() { if (_is_valid) { nassertv(do_is_valid()); } @@ -859,13 +770,10 @@ do_clear_cache() { if (_is_valid) { nassertv(do_is_valid()); } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::start_service_stream -// Access: Private -// Description: Adds the indicated stream to the list of streams to -// be serviced by a Panda sub-thread. This is in lieu -// of Miles' auto-service-stream mechanism. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated stream to the list of streams to be serviced by a Panda + * sub-thread. This is in lieu of Miles' auto-service-stream mechanism. + */ void MilesAudioManager:: start_service_stream(HSTREAM stream) { MutexHolder holder(_streams_lock); @@ -881,12 +789,10 @@ start_service_stream(HSTREAM stream) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::stop_service_stream -// Access: Private -// Description: Removes the indicated stream from the list of streams -// to be serviced by a Panda sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated stream from the list of streams to be serviced by a + * Panda sub-thread. + */ void MilesAudioManager:: stop_service_stream(HSTREAM stream) { MutexHolder holder(_streams_lock); @@ -895,13 +801,11 @@ stop_service_stream(HSTREAM stream) { _streams.erase(si); } } - -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::most_recently_used -// Access: Private -// Description: Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// + +/** + * Assumes the lock is already held. + */ void MilesAudioManager:: most_recently_used(const string &path) { audio_debug("MilesAudioManager::most_recently_used(path=\"" @@ -916,11 +820,9 @@ most_recently_used(const string &path) { nassertv(do_is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::uncache_a_sound -// Access: Private -// Description: Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the lock is already held. + */ void MilesAudioManager:: uncache_a_sound() { audio_debug("MilesAudioManager::uncache_a_sound()"); @@ -939,11 +841,9 @@ uncache_a_sound() { nassertv(do_is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::starting_sound -// Access: Private -// Description: Inform the manager that a sound is about to play. -//////////////////////////////////////////////////////////////////// +/** + * Inform the manager that a sound is about to play. + */ void MilesAudioManager:: starting_sound(MilesAudioSound *audio) { LightReMutexHolder holder(_lock); @@ -953,13 +853,10 @@ starting_sound(MilesAudioSound *audio) { _sounds_playing.insert(audio); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::stopping_sound -// Access: Private -// Description: Inform the manager that a sound is finished or -// someone called stop on the sound (this should not -// be called if a sound is only paused). -//////////////////////////////////////////////////////////////////// +/** + * Inform the manager that a sound is finished or someone called stop on the + * sound (this should not be called if a sound is only paused). + */ void MilesAudioManager:: stopping_sound(MilesAudioSound *audio) { LightReMutexHolder holder(_lock); @@ -969,15 +866,12 @@ stopping_sound(MilesAudioSound *audio) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::load -// Access: Private -// Description: Reads a sound file and allocates a SoundData pointer -// for it. Returns NULL if the sound file cannot be -// loaded. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Reads a sound file and allocates a SoundData pointer for it. Returns NULL + * if the sound file cannot be loaded. + * + * Assumes the lock is already held. + */ PT(MilesAudioManager::SoundData) MilesAudioManager:: load(const Filename &file_name) { PT(SoundData) sd = new SoundData; @@ -1007,9 +901,9 @@ load(const Filename &file_name) { if ((miles_audio_preload_threshold == -1 || file->get_file_size() < (streamsize)miles_audio_preload_threshold) || is_midi_file) { - // If the file is sufficiently small, we'll preload it into - // memory. MIDI files cannot be streamed, so we always preload - // them, regardless of size. + // If the file is sufficiently small, we'll preload it into memory. MIDI + // files cannot be streamed, so we always preload them, regardless of + // size. if (!file->read_file(sd->_raw_data, true)) { milesAudio_cat.warning() @@ -1017,12 +911,11 @@ load(const Filename &file_name) { return NULL; } - sd->_file_type = + sd->_file_type = AIL_file_type(&sd->_raw_data[0], sd->_raw_data.size()); if (sd->_file_type == AILFILETYPE_MIDI) { - // A standard MIDI file. We have to convert this to XMIDI for - // Miles. + // A standard MIDI file. We have to convert this to XMIDI for Miles. void *xmi; U32 xmi_size; if (AIL_MIDI_to_XMI(&sd->_raw_data[0], sd->_raw_data.size(), @@ -1031,10 +924,9 @@ load(const Filename &file_name) { << sd->_raw_data.size() << " bytes) to XMIDI (" << xmi_size << " bytes)"); - // Copy the data to our own buffer and free the - // Miles-allocated data. + // Copy the data to our own buffer and free the Miles-allocated data. sd->_raw_data.clear(); - sd->_raw_data.insert(sd->_raw_data.end(), + sd->_raw_data.insert(sd->_raw_data.end(), (unsigned char *)xmi, (unsigned char *)xmi + xmi_size); AIL_mem_free_lock(xmi); sd->_file_type = AILFILETYPE_XMIDI; @@ -1043,7 +935,7 @@ load(const Filename &file_name) { << "Could not convert " << sd->_basename << " to XMIDI.\n"; } } - + bool expand_to_wav = false; if (sd->_file_type != AILFILETYPE_MPEG_L3_AUDIO) { @@ -1054,11 +946,11 @@ load(const Filename &file_name) { audio_debug(sd->_basename << " will be expanded in-memory."); expand_to_wav = true; } - + if (expand_to_wav) { - // Now convert the file to WAV format in-memory. This is useful - // to work around seek and length problems associated with - // variable bit-rate MP3 encoding. + // Now convert the file to WAV format in-memory. This is useful to work + // around seek and length problems associated with variable bit-rate MP3 + // encoding. void *wav_data; U32 wav_data_size; if (AIL_decompress_ASI(&sd->_raw_data[0], sd->_raw_data.size(), @@ -1066,10 +958,10 @@ load(const Filename &file_name) { NULL)) { audio_debug("expanded " << sd->_basename << " from " << sd->_raw_data.size() << " bytes to " << wav_data_size << " bytes."); - + if (wav_data_size != 0) { - // Now copy the memory into our own buffers, and free the - // Miles-allocated memory. + // Now copy the memory into our own buffers, and free the Miles- + // allocated memory. sd->_raw_data.clear(); sd->_raw_data.insert(sd->_raw_data.end(), (unsigned char *)wav_data, (unsigned char *)wav_data + wav_data_size); @@ -1077,35 +969,31 @@ load(const Filename &file_name) { sd->_basename.set_extension("wav"); } AIL_mem_free_lock(wav_data); - + } else { audio_debug("unable to expand " << sd->_basename); } } } else { - // If the file is large, we'll stream it from disk instead of - // preloading it. This means we don't need to load any data at - // this point. + // If the file is large, we'll stream it from disk instead of preloading + // it. This means we don't need to load any data at this point. } return sd; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::thread_main -// Access: Private -// Description: Called to service the streaming audio channels -// currently playing on the audio manager. -//////////////////////////////////////////////////////////////////// +/** + * Called to service the streaming audio channels currently playing on the + * audio manager. + */ void MilesAudioManager:: thread_main(volatile bool &keep_running) { MutexHolder holder(_streams_lock); while (keep_running) { if (_streams.empty()) { - // If there are no streams to service, block on the condition - // variable. + // If there are no streams to service, block on the condition variable. _streams_cvar.wait(); } else { do_service_streams(); @@ -1118,56 +1006,48 @@ thread_main(volatile bool &keep_running) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::do_service_streams -// Access: Private -// Description: Internal function to service all the streams. -// Assumes _streams_lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to service all the streams. Assumes _streams_lock is + * already held. + */ void MilesAudioManager:: do_service_streams() { size_t i = 0; while (i < _streams.size()) { HSTREAM stream = _streams[i]; - + // We must release the lock while we are servicing stream i. _streams_lock.release(); AIL_service_stream(stream, 0); Thread::consider_yield(); _streams_lock.acquire(); - + ++i; } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::StreamThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MilesAudioManager::StreamThread:: -StreamThread(MilesAudioManager *mgr) : +StreamThread(MilesAudioManager *mgr) : Thread("StreamThread", "StreamThread"), - _mgr(mgr) + _mgr(mgr) { _keep_running = true; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::StreamThread::thread_main -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioManager::StreamThread:: thread_main() { _mgr->thread_main(_keep_running); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::SoundData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MilesAudioManager::SoundData:: SoundData() : _raw_data(MilesAudioManager::get_class_type()), @@ -1176,34 +1056,30 @@ SoundData() : { } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::SoundData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MilesAudioManager::SoundData:: ~SoundData() { } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::SoundData::get_length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioManager::SoundData:: get_length() { if (!_has_length) { // Time to determine the length of the file. - + if (_raw_data.empty()) { _length = 0.0f; _has_length = true; } else if (_file_type == AILFILETYPE_MPEG_L3_AUDIO) { - // If it's an mp3 file, we have to calculate its length by - // walking through all of its frames. + // If it's an mp3 file, we have to calculate its length by walking + // through all of its frames. audio_debug("Computing length of mp3 file " << _basename); - + MP3_INFO info; AIL_inspect_MP3(&info, &_raw_data[0], _raw_data.size()); _length = 0.0f; @@ -1231,11 +1107,9 @@ get_length() { return _length; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioManager::SoundData::set_length -// Access: Public -// Description: Records the sample length, as determined externally. -//////////////////////////////////////////////////////////////////// +/** + * Records the sample length, as determined externally. + */ void MilesAudioManager::SoundData:: set_length(PN_stdfloat length) { _length = length; diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index f39662927d..ead813b679 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -1,17 +1,16 @@ -// Filename: milesAudioManager.h -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioManager.h + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ #ifndef __MILES_AUDIO_MANAGER_H__ //[ #define __MILES_AUDIO_MANAGER_H__ @@ -35,14 +34,14 @@ class MilesAudioSound; class EXPCL_MILES_AUDIO MilesAudioManager: public AudioManager { public: // See AudioManager.h for documentation. - + MilesAudioManager(); virtual ~MilesAudioManager(); - + virtual void shutdown(); virtual bool is_valid(); - + virtual PT(AudioSound) get_sound(const string &file_name, bool positional = false, int mode=SM_heuristic); virtual PT(AudioSound) get_sound(MovieAudio *sound, bool positional = false, int mode=SM_heuristic); virtual void uncache_sound(const string &file_name); @@ -55,7 +54,7 @@ public: void set_play_rate(PN_stdfloat play_rate); PN_stdfloat get_play_rate() const; - + virtual void set_active(bool active); virtual bool get_active() const; @@ -71,10 +70,9 @@ public: void release_sound(MilesAudioSound *audioSound); void cleanup(); - // 3D spatialized sound support. - // Spatialized sound was originally added for FMOD, so there are parts of the - // interface in the Miles implementation that are a little more awkward than - // they would be otherwise. + // 3D spatialized sound support. Spatialized sound was originally added for + // FMOD, so there are parts of the interface in the Miles implementation + // that are a little more awkward than they would be otherwise. virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz); virtual void audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); virtual void audio_3d_set_distance_factor(PN_stdfloat factor); @@ -95,7 +93,7 @@ private: void start_service_stream(HSTREAM stream); void stop_service_stream(HSTREAM stream); - + void most_recently_used(const string &path); void uncache_a_sound(); @@ -153,7 +151,7 @@ private: int _cache_limit; bool _cleanup_required; unsigned int _concurrent_sound_limit; - + bool _is_valid; bool _hasMidiSounds; @@ -196,5 +194,3 @@ EXPCL_MILES_AUDIO AudioManager *Create_MilesAudioManager(); #endif //] #endif //] - - diff --git a/panda/src/audiotraits/milesAudioSample.I b/panda/src/audiotraits/milesAudioSample.I index d092840135..4c7cb37996 100644 --- a/panda/src/audiotraits/milesAudioSample.I +++ b/panda/src/audiotraits/milesAudioSample.I @@ -1,20 +1,13 @@ -// Filename: milesAudioSample.I -// Created by: skyler (June 6, 2001) -// Prior system by: cary -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - - - - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioSample.I + * @author skyler + * @date 2001-06-06 + * Prior system by: cary + */ diff --git a/panda/src/audiotraits/milesAudioSample.cxx b/panda/src/audiotraits/milesAudioSample.cxx index 42245b70b6..c89addb1a5 100644 --- a/panda/src/audiotraits/milesAudioSample.cxx +++ b/panda/src/audiotraits/milesAudioSample.cxx @@ -1,16 +1,15 @@ -// Filename: milesAudioSample.cxx -// Created by: skyler (June 6, 2001) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioSample.cxx + * @author skyler + * @date 2001-06-06 + */ #include "milesAudioSample.h" @@ -30,12 +29,9 @@ TypeHandle MilesAudioSample::_type_handle; #define miles_audio_debug(x) ((void)0) #endif //] -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::Constructor -// Access: Private -// Description: This constructor is called only by the -// MilesAudioManager. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is called only by the MilesAudioManager. + */ MilesAudioSample:: MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, const string &file_name) : @@ -51,11 +47,9 @@ MilesAudioSample(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, _original_playback_rate = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MilesAudioSample:: ~MilesAudioSample() { miles_audio_debug("~MilesAudioSample()"); @@ -63,11 +57,9 @@ MilesAudioSample:: miles_audio_debug("~MilesAudioSample() done"); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::play -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSample:: play() { miles_audio_debug("play()"); @@ -115,11 +107,9 @@ play() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::stop -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSample:: stop() { if (_manager == (MilesAudioManager *)NULL) { @@ -128,12 +118,12 @@ stop() { miles_audio_debug("stop()"); _manager->stopping_sound(this); - // The _paused flag should not be cleared here. _paused is not like - // the Pause button on a cd/dvd player. It is used as a flag to say - // that it was looping when it was set inactive. There is no need to - // make this symmetrical with play(). set_active() is the 'owner' of - // _paused. play() accesses _paused to help in the situation where - // someone calls play on an inactive sound(). + // The _paused flag should not be cleared here. _paused is not like the + // Pause button on a cddvd player. It is used as a flag to say that it was + // looping when it was set inactive. There is no need to make this + // symmetrical with play(). set_active() is the 'owner' of _paused. play() + // accesses _paused to help in the situation where someone calls play on an + // inactive sound(). // it fixes audio bug, I don't understand the reasoning of the above comment _paused = false; @@ -149,11 +139,9 @@ stop() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::get_time -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSample:: get_time() const { if (_sample == 0) { @@ -170,18 +158,15 @@ get_time() const { return time; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::set_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSample:: set_volume(PN_stdfloat volume) { miles_audio_debug("set_volume(volume="<get_play_rate(); - // wave and mp3 use sample rate (e.g. 44100) + // wave and mp3 use sample rate (e.g. 44100) S32 speed = (S32)(play_rate * (PN_stdfloat)_original_playback_rate); AIL_set_sample_playback_rate(_sample, speed); audio_debug(" play_rate for this wav or mp3 is now " << speed); } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::length -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSample:: length() const { return _sd->get_length(); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::status -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AudioSound::SoundStatus MilesAudioSample:: status() const { if (_sample == 0) { @@ -272,13 +249,10 @@ status() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::cleanup -// Access: Public, Virtual -// Description: Stops the sound from playing and releases any -// associated resources, in preparation for releasing -// the sound or shutting down the sound system. -//////////////////////////////////////////////////////////////////// +/** + * Stops the sound from playing and releases any associated resources, in + * preparation for releasing the sound or shutting down the sound system. + */ void MilesAudioSample:: cleanup() { stop(); @@ -291,11 +265,9 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSample:: output(ostream &out) const { out << get_type() << " " << get_name() << " " << status(); @@ -304,13 +276,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::set_3d_attributes -// Access: Public -// Description: Set position and velocity of this sound. Note that -// Y and Z are switched to translate from Miles's -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Set position and velocity of this sound. Note that Y and Z are switched to + * translate from Miles's coordinate system. + */ void MilesAudioSample::set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { audio_debug("MilesAudioSample::set_3d_attributes() Setting a sound's 3D Coordinates."); @@ -322,11 +291,9 @@ void MilesAudioSample::set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdf } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::get_3d_attributes -// Access: Public -// Description: Get position and velocity of this sound. -//////////////////////////////////////////////////////////////////// +/** + * Get position and velocity of this sound. + */ void MilesAudioSample::get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { audio_debug("MilesAudioSample::get_3d_attributes()."); @@ -345,20 +312,17 @@ void MilesAudioSample::get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_st } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::set_3d_min_distance -// Access: Public -// Description: Set the distance that this sound begins to fall -// off. With Miles's default falloff behavior, when -// the distance between the sound and the listener is -// doubled, the volume is halved, and vice versa. -//////////////////////////////////////////////////////////////////// +/** + * Set the distance that this sound begins to fall off. With Miles's default + * falloff behavior, when the distance between the sound and the listener is + * doubled, the volume is halved, and vice versa. + */ void MilesAudioSample::set_3d_min_distance(PN_stdfloat dist) { audio_debug("MilesAudioSample::set_3d_min_distance() Setting the sound's 3D min distance ( min= " << dist << " ) "); if(_sample != 0) { - // Implementation is awkward, since Miles gets and sets min and max distances - // in a single operation. + // Implementation is awkward, since Miles gets and sets min and max + // distances in a single operation. float max_dist; int auto_3D_wet_atten; AIL_sample_3D_distances(_sample, &max_dist, NULL, &auto_3D_wet_atten); @@ -369,11 +333,9 @@ void MilesAudioSample::set_3d_min_distance(PN_stdfloat dist) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::get_3d_min_distance -// Access: Public -// Description: Get the distance that this sound begins to fall off. -//////////////////////////////////////////////////////////////////// +/** + * Get the distance that this sound begins to fall off. + */ PN_stdfloat MilesAudioSample::get_3d_min_distance() const { audio_debug("MilesAudioSample::get_3d_min_distance() "); @@ -387,20 +349,17 @@ PN_stdfloat MilesAudioSample::get_3d_min_distance() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::set_3d_max_distance -// Access: Public -// Description: Set the distance at which this sound is clipped to -// silence. Note that this value does not affect -// the rate at which the sound falls off, but only -// the distance at which it gets clipped. -//////////////////////////////////////////////////////////////////// +/** + * Set the distance at which this sound is clipped to silence. Note that this + * value does not affect the rate at which the sound falls off, but only the + * distance at which it gets clipped. + */ void MilesAudioSample::set_3d_max_distance(PN_stdfloat dist) { audio_debug("MilesAudioSample::set_3d_max_distance() Setting the sound's 3D max distance ( max= " << dist << " ) "); if(_sample != 0) { - // Implementation is awkward, since Miles gets and sets min and max distances - // in a single operation. + // Implementation is awkward, since Miles gets and sets min and max + // distances in a single operation. float min_dist; int auto_3D_wet_atten; AIL_sample_3D_distances(_sample, NULL, &min_dist, &auto_3D_wet_atten); @@ -411,12 +370,9 @@ void MilesAudioSample::set_3d_max_distance(PN_stdfloat dist) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::get_3d_max_distance -// Access: Public -// Description: Get the distance at which this sound is clipped to -// silence. -//////////////////////////////////////////////////////////////////// +/** + * Get the distance at which this sound is clipped to silence. + */ PN_stdfloat MilesAudioSample::get_3d_max_distance() const { audio_debug("MilesAudioSample::get_3d_max_distance() "); @@ -430,42 +386,24 @@ PN_stdfloat MilesAudioSample::get_3d_max_distance() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::get_speaker_level -// Access: Published -// Description: Get the level of a particular logical channel (speaker). -// "index" specifies which speaker in an array of all the -// logical channels currently in use to retrieve the level -// of. -// -// For instance, in a standard 4.0 channel setup, speakers -// are setup as [frontLeft, frontRight, backLeft, backRight]. -// Thus, get_speaker_level(2) will retrieve the level of the -// backLeft speaker. -// -// The order in which speakers appear in the array for -// standard speaker setups is defined to be: -// -// FRONT_LEFT -// FRONT_RIGHT -// FRONT_CENTER -// LOW_FREQUENCY (sub woofer) -// BACK_LEFT -// BACK_RIGHT -// FRONT_LEFT_OF_CENTER -// FRONT_RIGHT_OF_CENTER -// BACK_CENTER -// SIDE_LEFT -// SIDE_RIGHT -// TOP_CENTER -// TOP_FRONT_LEFT -// TOP_FRONT_CENTER -// TOP_FRONT_RIGHT -// TOP_BACK_LEFT -// TOP_BACK_CENTER -// TOP_BACK_RIGHT -// -//////////////////////////////////////////////////////////////////// +/** + * Get the level of a particular logical channel (speaker). "index" specifies + * which speaker in an array of all the logical channels currently in use to + * retrieve the level of. + * + * For instance, in a standard 4.0 channel setup, speakers are setup as + * [frontLeft, frontRight, backLeft, backRight]. Thus, get_speaker_level(2) + * will retrieve the level of the backLeft speaker. + * + * The order in which speakers appear in the array for standard speaker setups + * is defined to be: + * + * FRONT_LEFT FRONT_RIGHT FRONT_CENTER LOW_FREQUENCY (sub woofer) BACK_LEFT + * BACK_RIGHT FRONT_LEFT_OF_CENTER FRONT_RIGHT_OF_CENTER BACK_CENTER SIDE_LEFT + * SIDE_RIGHT TOP_CENTER TOP_FRONT_LEFT TOP_FRONT_CENTER TOP_FRONT_RIGHT + * TOP_BACK_LEFT TOP_BACK_CENTER TOP_BACK_RIGHT + * + */ PN_stdfloat MilesAudioSample:: get_speaker_level(int index) { audio_debug("MilesAudioSample::get_speaker_level(" << index << ")"); @@ -486,45 +424,28 @@ get_speaker_level(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::set_speaker_levels -// Access: Published -// Description: Set the output levels on the logical channels (speakers) -// for this sound. Values should be in the range 0.0 to 1.0. -// Levels for up to nine channels may be specified. As soon -// as a level is reached that falls outside the range 0.0 to -// 1.0, the levels specified up to that point will be sent -// and all other levels will be ignored. -// -// The user must know what the current speaker setup is in order -// to know which level corresponds to which speaker. -// -// This method will have no effect if 3D attributes have been -// set for this sound. -// -// The order in which speakers appear in the array for -// standard speaker setups is defined to be: -// -// FRONT_LEFT -// FRONT_RIGHT -// FRONT_CENTER -// LOW_FREQUENCY (sub woofer) -// BACK_LEFT -// BACK_RIGHT -// FRONT_LEFT_OF_CENTER -// FRONT_RIGHT_OF_CENTER -// BACK_CENTER -// SIDE_LEFT -// SIDE_RIGHT -// TOP_CENTER -// TOP_FRONT_LEFT -// TOP_FRONT_CENTER -// TOP_FRONT_RIGHT -// TOP_BACK_LEFT -// TOP_BACK_CENTER -// TOP_BACK_RIGHT -// -//////////////////////////////////////////////////////////////////// +/** + * Set the output levels on the logical channels (speakers) for this sound. + * Values should be in the range 0.0 to 1.0. Levels for up to nine channels + * may be specified. As soon as a level is reached that falls outside the + * range 0.0 to 1.0, the levels specified up to that point will be sent and + * all other levels will be ignored. + * + * The user must know what the current speaker setup is in order to know which + * level corresponds to which speaker. + * + * This method will have no effect if 3D attributes have been set for this + * sound. + * + * The order in which speakers appear in the array for standard speaker setups + * is defined to be: + * + * FRONT_LEFT FRONT_RIGHT FRONT_CENTER LOW_FREQUENCY (sub woofer) BACK_LEFT + * BACK_RIGHT FRONT_LEFT_OF_CENTER FRONT_RIGHT_OF_CENTER BACK_CENTER SIDE_LEFT + * SIDE_RIGHT TOP_CENTER TOP_FRONT_LEFT TOP_FRONT_CENTER TOP_FRONT_RIGHT + * TOP_BACK_LEFT TOP_BACK_CENTER TOP_BACK_RIGHT + * + */ void MilesAudioSample:: set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2, PN_stdfloat level3, PN_stdfloat level4, PN_stdfloat level5, PN_stdfloat level6, PN_stdfloat level7, PN_stdfloat level8, PN_stdfloat level9) { audio_debug("MilesAudioSample::set_speaker_levels()"); @@ -558,25 +479,20 @@ set_speaker_levels(PN_stdfloat level1, PN_stdfloat level2, PN_stdfloat level3, P } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::internal_stop -// Access: Private -// Description: Called by the GlobalMilesManager when it is detected -// that this particular sound has already stopped, and -// its sample handle will be recycled. -//////////////////////////////////////////////////////////////////// +/** + * Called by the GlobalMilesManager when it is detected that this particular + * sound has already stopped, and its sample handle will be recycled. + */ void MilesAudioSample:: internal_stop() { _sample = 0; _sample_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::finish_callback -// Access: Private, Static -// Description: This callback is made by Miles (possibly in a -// sub-thread) when the sample finishes. -//////////////////////////////////////////////////////////////////// +/** + * This callback is made by Miles (possibly in a sub-thread) when the sample + * finishes. + */ void AILCALLBACK MilesAudioSample:: finish_callback(HSAMPLE sample) { MilesAudioSample *self = (MilesAudioSample *)AIL_sample_user_data(sample, 0); @@ -590,11 +506,9 @@ finish_callback(HSAMPLE sample) { self->_manager->_sounds_finished = true; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSample::do_set_time -// Access: Private -// Description: Sets the start time of an already allocated sample. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start time of an already allocated sample. + */ void MilesAudioSample:: do_set_time(PN_stdfloat time) { miles_audio_debug("do_set_time(time="<_raw_data.empty()) { milesAudio_cat.warning() << "Could not play " << _file_name << ": no data\n"; @@ -82,7 +74,7 @@ play() { nassertv(_sequence == 0); GlobalMilesManager *mgr = GlobalMilesManager::get_global_ptr(); - if (!mgr->get_sequence(_sequence, _sequence_index, this)){ + if (!mgr->get_sequence(_sequence, _sequence_index, this)){ milesAudio_cat.warning() << "Could not play " << _file_name << ": too many open sequences\n"; _sequence = 0; @@ -112,21 +104,19 @@ play() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::stop -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSequence:: stop() { miles_audio_debug("stop()"); _manager->stopping_sound(this); - // The _paused flag should not be cleared here. _paused is not like - // the Pause button on a cd/dvd player. It is used as a flag to say - // that it was looping when it was set inactive. There is no need to - // make this symmetrical with play(). set_active() is the 'owner' of - // _paused. play() accesses _paused to help in the situation where - // someone calls play on an inactive sound(). + // The _paused flag should not be cleared here. _paused is not like the + // Pause button on a cddvd player. It is used as a flag to say that it was + // looping when it was set inactive. There is no need to make this + // symmetrical with play(). set_active() is the 'owner' of _paused. play() + // accesses _paused to help in the situation where someone calls play on an + // inactive sound(). if (_sequence != 0) { AIL_end_sequence(_sequence); @@ -139,11 +129,9 @@ stop() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::get_time -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSequence:: get_time() const { if (_sequence == 0) { @@ -160,39 +148,34 @@ get_time() const { return time; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::set_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSequence:: set_volume(PN_stdfloat volume) { miles_audio_debug("set_volume(volume="<get_volume(); - + // Change to Miles volume, range 0 to 127: S32 milesVolume = (S32)(volume * 127.0f); milesVolume = min(milesVolume, 127); milesVolume = max(milesVolume, 0); - + AIL_set_sequence_volume(_sequence, milesVolume, 0); } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::set_balance -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSequence:: set_balance(PN_stdfloat balance_right) { miles_audio_debug("set_balance(balance_right="<_has_length) { - // It isn't cached, so load the sequence temporarily to - // determine its length. + // It isn't cached, so load the sequence temporarily to determine its + // length. ((MilesAudioSequence *)this)->determine_length(); } - + return _sd->get_length(); } - // The MIDI file has already been started, so we can ask it - // directly. + // The MIDI file has already been started, so we can ask it directly. S32 length_ms; AIL_sequence_ms_position(_sequence, &length_ms, NULL); PN_stdfloat time = (PN_stdfloat)length_ms * 0.001f; return time; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::status -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AudioSound::SoundStatus MilesAudioSequence:: status() const { if (_sequence == 0) { @@ -273,37 +249,29 @@ status() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::cleanup -// Access: Public, Virtual -// Description: Stops the sound from playing and releases any -// associated resources, in preparation for releasing -// the sound or shutting down the sound system. -//////////////////////////////////////////////////////////////////// +/** + * Stops the sound from playing and releases any associated resources, in + * preparation for releasing the sound or shutting down the sound system. + */ void MilesAudioSequence:: cleanup() { stop(); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::internal_stop -// Access: Private -// Description: Called by the GlobalMilesManager when it is detected -// that this particular sound has already stopped, and -// its sequence handle will be recycled. -//////////////////////////////////////////////////////////////////// +/** + * Called by the GlobalMilesManager when it is detected that this particular + * sound has already stopped, and its sequence handle will be recycled. + */ void MilesAudioSequence:: internal_stop() { _sequence = 0; _sequence_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::finish_callback -// Access: Private, Static -// Description: This callback is made by Miles (possibly in a -// sub-thread) when the sequence finishes. -//////////////////////////////////////////////////////////////////// +/** + * This callback is made by Miles (possibly in a sub-thread) when the sequence + * finishes. + */ void AILCALLBACK MilesAudioSequence:: finish_callback(HSEQUENCE sequence) { MilesAudioSequence *self = (MilesAudioSequence *)AIL_sequence_user_data(sequence, 0); @@ -314,11 +282,9 @@ finish_callback(HSEQUENCE sequence) { self->_manager->_sounds_finished = true; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSequence::do_set_time -// Access: Private -// Description: Sets the start time of an already allocated stream. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start time of an already allocated stream. + */ void MilesAudioSequence:: do_set_time(PN_stdfloat time) { miles_audio_debug("do_set_time(time="<get_sequence(_sequence, _sequence_index, this)){ + if (!mgr->get_sequence(_sequence, _sequence_index, this)){ milesAudio_cat.warning() << "Could not determine length of " << _file_name << ": too many open sequences\n"; _sequence = 0; @@ -359,7 +323,7 @@ determine_length() { mgr->release_sequence(_sequence_index, this); _sequence = 0; _sequence_index = 0; - + _sd->set_length(time); } } diff --git a/panda/src/audiotraits/milesAudioSequence.h b/panda/src/audiotraits/milesAudioSequence.h index 272eb433fa..8f01a037fd 100644 --- a/panda/src/audiotraits/milesAudioSequence.h +++ b/panda/src/audiotraits/milesAudioSequence.h @@ -1,16 +1,15 @@ -// Filename: milesAudioSequence.h -// Created by: drose (31Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioSequence.h + * @author drose + * @date 2007-07-31 + */ #ifndef MILESAUDIOSEQUENCE_H #define MILESAUDIOSEQUENCE_H @@ -22,29 +21,28 @@ #include "milesAudioManager.h" #include "mss.h" -//////////////////////////////////////////////////////////////////// -// Class : MilesAudioSequence -// Description : A MIDI file, preloaded and played from a memory -// buffer. MIDI files cannot be streamed. -//////////////////////////////////////////////////////////////////// +/** + * A MIDI file, preloaded and played from a memory buffer. MIDI files cannot + * be streamed. + */ class EXPCL_MILES_AUDIO MilesAudioSequence : public MilesAudioSound { private: - MilesAudioSequence(MilesAudioManager *manager, + MilesAudioSequence(MilesAudioManager *manager, MilesAudioManager::SoundData *sd, const string &file_name); public: virtual ~MilesAudioSequence(); - + virtual void play(); virtual void stop(); - + virtual PN_stdfloat get_time() const; - + virtual void set_volume(PN_stdfloat volume=1.0f); virtual void set_balance(PN_stdfloat balance_right=0.0f); virtual void set_play_rate(PN_stdfloat play_rate=1.0f); - + virtual PN_stdfloat length() const; virtual AudioSound::SoundStatus status() const; diff --git a/panda/src/audiotraits/milesAudioSound.I b/panda/src/audiotraits/milesAudioSound.I index 9a9385005f..c1354a737f 100644 --- a/panda/src/audiotraits/milesAudioSound.I +++ b/panda/src/audiotraits/milesAudioSound.I @@ -1,14 +1,12 @@ -// Filename: milesAudioSound.I -// Created by: drose (30Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioSound.I + * @author drose + * @date 2007-07-30 + */ diff --git a/panda/src/audiotraits/milesAudioSound.cxx b/panda/src/audiotraits/milesAudioSound.cxx index ec1d440e4e..0988eaf48e 100644 --- a/panda/src/audiotraits/milesAudioSound.cxx +++ b/panda/src/audiotraits/milesAudioSound.cxx @@ -1,16 +1,15 @@ -// Filename: milesAudioSound.cxx -// Created by: drose (30Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioSound.cxx + * @author drose + * @date 2007-07-30 + */ #include "milesAudioSound.h" #ifdef HAVE_RAD_MSS //[ @@ -28,19 +27,17 @@ TypeHandle MilesAudioSound::_type_handle; #define miles_audio_debug(x) ((void)0) #endif //] -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MilesAudioSound:: MilesAudioSound(MilesAudioManager *manager, const string &file_name) : _manager(manager), _file_name(file_name), _volume(1.0f), _balance(0), _play_rate(1.0f), - _loop_count(1), - _active(true), + _loop_count(1), + _active(true), _paused(false), _start_time(0.0f), _got_start_time(false) @@ -48,94 +45,77 @@ MilesAudioSound(MilesAudioManager *manager, nassertv(!file_name.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::set_loop -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSound:: set_loop(bool loop) { // loop count of 0 means always loop set_loop_count((loop)?0:1); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::get_loop -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool MilesAudioSound:: get_loop() const { return (_loop_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound:: -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSound:: set_loop_count(unsigned long loop_count) { if (_loop_count != loop_count) { _loop_count = loop_count; if (status() == PLAYING) { - // hack: - // For now, the loop count is picked up when the sound starts playing. - // There may be a way to change the loop count of a playing sound, but - // I'm going to focus on other things. If you would like to change the - // need to stop and start the sound, feel free. Or, maybe I'll spend - // time on it in the future. Please set the loop option before starting - // the sound. + // hack: For now, the loop count is picked up when the sound starts + // playing. There may be a way to change the loop count of a playing + // sound, but I'm going to focus on other things. If you would like to + // change the need to stop and start the sound, feel free. Or, maybe + // I'll spend time on it in the future. Please set the loop option + // before starting the sound. play(); } } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound:: -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned long MilesAudioSound:: get_loop_count() const { return _loop_count; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::get_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSound:: get_volume() const { return _volume; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::get_balance -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSound:: get_balance() const { return _balance; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::get_play_rate -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioSound:: get_play_rate() const { return _play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioSound::set_time -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioSound:: set_time(PN_stdfloat time) { miles_audio_debug("set_time(time="<stop_service_stream(_stream); } @@ -91,20 +83,20 @@ play() { nassertv(_stream != 0); HSAMPLE sample = AIL_stream_sample_handle(_stream); nassertv(sample != 0); - + _original_playback_rate = AIL_sample_playback_rate(sample); set_volume(_volume); set_play_rate(_play_rate); - + AIL_set_stream_loop_count(_stream, _loop_count); AIL_start_stream(_stream); if (_got_start_time) { - // There's no AIL_resume_stream(), so we start in the middle by - // starting normally, then immediately skipping to the middle. + // There's no AIL_resume_stream(), so we start in the middle by starting + // normally, then immediately skipping to the middle. do_set_time(_start_time); } - + if (miles_audio_panda_threads) { AIL_auto_service_stream(_stream, 0); _manager->start_service_stream(_stream); @@ -121,11 +113,9 @@ play() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::stop -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioStream:: stop() { if (_manager == (MilesAudioManager *)NULL) { @@ -134,12 +124,12 @@ stop() { miles_audio_debug("stop()"); _manager->stopping_sound(this); - // The _paused flag should not be cleared here. _paused is not like - // the Pause button on a cd/dvd player. It is used as a flag to say - // that it was looping when it was set inactive. There is no need to - // make this symmetrical with play(). set_active() is the 'owner' of - // _paused. play() accesses _paused to help in the situation where - // someone calls play on an inactive sound(). + // The _paused flag should not be cleared here. _paused is not like the + // Pause button on a cddvd player. It is used as a flag to say that it was + // looping when it was set inactive. There is no need to make this + // symmetrical with play(). set_active() is the 'owner' of _paused. play() + // accesses _paused to help in the situation where someone calls play on an + // inactive sound(). if (_stream != 0) { _manager->stop_service_stream(_stream); @@ -149,11 +139,9 @@ stop() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream:: -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioStream:: get_time() const { if (_stream == 0) { @@ -170,11 +158,9 @@ get_time() const { return time; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream:: -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioStream:: set_volume(PN_stdfloat volume) { _volume = volume; @@ -184,24 +170,22 @@ set_volume(PN_stdfloat volume) { nassertv(sample != 0); volume *= _manager->get_volume(); - + // Change to Miles volume, range 0 to 1.0: F32 milesVolume = volume; milesVolume = min(milesVolume, 1.0f); milesVolume = max(milesVolume, 0.0f); - + // Convert balance of -1.0..1.0 to 0-1.0: F32 milesBalance = (F32)((_balance + 1.0f) * 0.5f); - + AIL_set_sample_volume_pan(sample, milesVolume, milesBalance); } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::set_balance -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioStream:: set_balance(PN_stdfloat balance_right) { _balance = balance_right; @@ -210,11 +194,9 @@ set_balance(PN_stdfloat balance_right) { set_volume(_volume); } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::set_play_rate -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MilesAudioStream:: set_play_rate(PN_stdfloat play_rate) { _play_rate = play_rate; @@ -225,18 +207,16 @@ set_play_rate(PN_stdfloat play_rate) { play_rate *= _manager->get_play_rate(); - // wave and mp3 use sample rate (e.g. 44100) + // wave and mp3 use sample rate (e.g. 44100) S32 speed = (S32)(play_rate * (PN_stdfloat)_original_playback_rate); AIL_set_sample_playback_rate(sample, speed); audio_debug(" play_rate for this wav or mp3 is now " << speed); } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::length -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat MilesAudioStream:: length() const { if (!_got_length) { @@ -244,21 +224,19 @@ length() const { GlobalMilesManager *mgr = GlobalMilesManager::get_global_ptr(); ((MilesAudioStream *)this)->_stream = AIL_open_stream(mgr->_digital_driver, _path.c_str(), 0); } - + S32 length_ms; AIL_stream_ms_position(_stream, &length_ms, NULL); _length = (PN_stdfloat)length_ms * 0.001f; _got_length = true; } - + return _length; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::status -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AudioSound::SoundStatus MilesAudioStream:: status() const { if (!_stream) { @@ -277,12 +255,9 @@ status() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::cleanup -// Access: Public, Virtual -// Description: Called to release any resources associated with the -// sound. -//////////////////////////////////////////////////////////////////// +/** + * Called to release any resources associated with the sound. + */ void MilesAudioStream:: cleanup() { if (_stream) { @@ -297,12 +272,10 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::finish_callback -// Access: Private, Static -// Description: This callback is made by Miles (possibly in a -// sub-thread) when the stream finishes. -//////////////////////////////////////////////////////////////////// +/** + * This callback is made by Miles (possibly in a sub-thread) when the stream + * finishes. + */ void AILCALLBACK MilesAudioStream:: finish_callback(HSTREAM stream) { MilesAudioStream *self = (MilesAudioStream *)AIL_stream_user_data(stream, 0); @@ -316,11 +289,9 @@ finish_callback(HSTREAM stream) { self->_manager->_sounds_finished = true; } -//////////////////////////////////////////////////////////////////// -// Function: MilesAudioStream::do_set_time -// Access: Private -// Description: Sets the start time of an already allocated stream. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start time of an already allocated stream. + */ void MilesAudioStream:: do_set_time(PN_stdfloat time) { nassertv(_stream != 0); @@ -331,7 +302,7 @@ do_set_time(PN_stdfloat time) { S32 length_ms; AIL_stream_ms_position(_stream, &length_ms, NULL); time_ms = min(time_ms, length_ms); - + AIL_set_stream_ms_position(_stream, time_ms); } diff --git a/panda/src/audiotraits/milesAudioStream.h b/panda/src/audiotraits/milesAudioStream.h index 1b19d5181b..8050f513cf 100644 --- a/panda/src/audiotraits/milesAudioStream.h +++ b/panda/src/audiotraits/milesAudioStream.h @@ -1,16 +1,15 @@ -// Filename: milesAudioStream.h -// Created by: drose (26Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file milesAudioStream.h + * @author drose + * @date 2007-07-26 + */ #ifndef MILESAUDIOSTREAM_H #define MILESAUDIOSTREAM_H @@ -22,13 +21,11 @@ #include "milesAudioManager.h" #include "mss.h" -//////////////////////////////////////////////////////////////////// -// Class : MilesAudioStream -// Description : This represents a sound file played by the Miles -// Sound System, similar to MilesAudioSample, except -// that it is streamed from disk instead of preloaded -// into memory. -//////////////////////////////////////////////////////////////////// +/** + * This represents a sound file played by the Miles Sound System, similar to + * MilesAudioSample, except that it is streamed from disk instead of preloaded + * into memory. + */ class EXPCL_MILES_AUDIO MilesAudioStream : public MilesAudioSound { private: MilesAudioStream(MilesAudioManager *manager, const string &file_name, @@ -36,16 +33,16 @@ private: public: virtual ~MilesAudioStream(); - + virtual void play(); virtual void stop(); - + virtual PN_stdfloat get_time() const; - + virtual void set_volume(PN_stdfloat volume=1.0f); virtual void set_balance(PN_stdfloat balance_right=0.0f); virtual void set_play_rate(PN_stdfloat play_rate=1.0f); - + virtual PN_stdfloat length() const; virtual AudioSound::SoundStatus status() const; diff --git a/panda/src/audiotraits/openalAudioManager.cxx b/panda/src/audiotraits/openalAudioManager.cxx index 0ef5eface0..c32407970c 100644 --- a/panda/src/audiotraits/openalAudioManager.cxx +++ b/panda/src/audiotraits/openalAudioManager.cxx @@ -1,21 +1,18 @@ -// Filename: openalAudioManager.cxx -// Created by: Ben Buchwald -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openalAudioManager.cxx + * @author Ben Buchwald + */ #include "pandabase.h" -//Panda headers. +// Panda headers. #include "config_audio.h" #include "config_util.h" #include "config_express.h" @@ -44,17 +41,15 @@ bool OpenALAudioManager::_openal_active = false; ALCdevice* OpenALAudioManager::_device = NULL; ALCcontext* OpenALAudioManager::_context = NULL; -// This is the list of all OpenALAudioManager objects in the world. It -// must be a pointer rather than a concrete object, so it won't be -// destructed at exit time before we're done removing things from it. +// This is the list of all OpenALAudioManager objects in the world. It must +// be a pointer rather than a concrete object, so it won't be destructed at +// exit time before we're done removing things from it. OpenALAudioManager::Managers *OpenALAudioManager::_managers = NULL; OpenALAudioManager::SourceCache *OpenALAudioManager::_al_sources = NULL; -//////////////////////////////////////////////////////////////////// // Central dispatcher for audio errors. -//////////////////////////////////////////////////////////////////// void al_audio_errcheck(const char *context) { ALenum result = alGetError(); if (result != AL_NO_ERROR) { @@ -69,22 +64,18 @@ void alc_audio_errcheck(const char *context,ALCdevice* device) { } } -//////////////////////////////////////////////////////////////////// -// Function: Create_OpenALAudioManager -// Access: Private -// Description: Factory Function -//////////////////////////////////////////////////////////////////// +/** + * Factory Function + */ AudioManager *Create_OpenALAudioManager() { audio_debug("Create_OpenALAudioManager()"); return new OpenALAudioManager; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioManager:: OpenALAudioManager() { ReMutexHolder holder(_lock); @@ -105,7 +96,7 @@ OpenALAudioManager() { _concurrent_sound_limit = 0; _is_valid = true; - //Init 3D attributes + // Init 3D attributes _distance_factor = 3.28; _drop_off_factor = 1; @@ -169,9 +160,8 @@ OpenALAudioManager() { } } - // We increment _active_managers regardless of possible errors above. - // The shutdown call will do the right thing when it's called, - // either way. + // We increment _active_managers regardless of possible errors above. The + // shutdown call will do the right thing when it's called, either way. ++_active_managers; nassertv(_active_managers>0); @@ -201,11 +191,9 @@ OpenALAudioManager() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioManager:: ~OpenALAudioManager() { ReMutexHolder holder(_lock); @@ -216,15 +204,12 @@ OpenALAudioManager:: cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::shutdown -// Access: Published, Virtual -// Description: Call this at exit time to shut down the audio system. -// This will invalidate all currently-active -// AudioManagers and AudioSounds in the system. If you -// change your mind and want to play sounds again, you -// will have to recreate all of these objects. -//////////////////////////////////////////////////////////////////// +/** + * Call this at exit time to shut down the audio system. This will invalidate + * all currently-active AudioManagers and AudioSounds in the system. If you + * change your mind and want to play sounds again, you will have to recreate + * all of these objects. + */ void OpenALAudioManager:: shutdown() { ReMutexHolder holder(_lock); @@ -239,24 +224,19 @@ shutdown() { } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::is_valid -// Access: -// Description: This is mostly for debugging, but it it could be -// used to detect errors in a release build if you -// don't mind the cpu cost. -//////////////////////////////////////////////////////////////////// +/** + * This is mostly for debugging, but it it could be used to detect errors in a + * release build if you don't mind the cpu cost. + */ bool OpenALAudioManager:: is_valid() { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::select_audio_device -// Access: Private -// Description: Enumerate the audio devices, selecting the one that -// is most appropriate or has been selected by the user. -//////////////////////////////////////////////////////////////////// +/** + * Enumerate the audio devices, selecting the one that is most appropriate or + * has been selected by the user. + */ string OpenALAudioManager:: select_audio_device() { string selected_device = openal_device; @@ -290,8 +270,8 @@ select_audio_device() { audio_cat.debug() << "ALC_ENUMERATE_ALL_EXT not supported\n"; } - // This extension just gives us generic driver names, like "OpenAL Soft" - // and "Generic Software", rather than individual outputs. + // This extension just gives us generic driver names, like "OpenAL Soft" and + // "Generic Software", rather than individual outputs. if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE) { string default_device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER); devices = (const char *)alcGetString(NULL, ALC_DEVICE_SPECIFIER); @@ -327,25 +307,20 @@ select_audio_device() { return selected_device; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::make_current -// Access: Private -// Description: This makes this manager's OpenAL context the -// current context. Needed before any parameter sets. -//////////////////////////////////////////////////////////////////// +/** + * This makes this manager's OpenAL context the current context. Needed + * before any parameter sets. + */ void OpenALAudioManager:: make_current() const { // Since we only use one context, this is now a no-op. } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::can_use_audio -// Access: Private -// Description: Returns true if the specified MovieAudioCursor -// can be used by this AudioManager. Mostly, this -// involves checking whether or not the format is -// implemented/supported. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the specified MovieAudioCursor can be used by this + * AudioManager. Mostly, this involves checking whether or not the format is + * implemented/supported. + */ bool OpenALAudioManager:: can_use_audio(MovieAudioCursor *source) { ReMutexHolder holder(_lock); @@ -357,14 +332,11 @@ can_use_audio(MovieAudioCursor *source) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::should_load_audio -// Access: Private -// Description: Returns true if the specified MovieAudio should be -// cached into RAM. A lot of conditions have to be met -// in order to allow caching - if any are not met, -// the file will be streamed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the specified MovieAudio should be cached into RAM. A lot + * of conditions have to be met in order to allow caching - if any are not + * met, the file will be streamed. + */ bool OpenALAudioManager:: should_load_audio(MovieAudioCursor *source, int mode) { ReMutexHolder holder(_lock); @@ -394,14 +366,12 @@ should_load_audio(MovieAudioCursor *source, int mode) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_sound_data -// Access: Private -// Description: Obtains a SoundData for the specified sound. -// -// When you are done with the SoundData, you need -// to decrement the client count. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a SoundData for the specified sound. + * + * When you are done with the SoundData, you need to decrement the client + * count. + */ OpenALAudioManager::SoundData *OpenALAudioManager:: get_sound_data(MovieAudio *movie, int mode) { ReMutexHolder holder(_lock); @@ -488,11 +458,9 @@ get_sound_data(MovieAudio *movie, int mode) { return sd; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_sound -// Access: Public -// Description: This is what creates a sound instance. -//////////////////////////////////////////////////////////////////// +/** + * This is what creates a sound instance. + */ PT(AudioSound) OpenALAudioManager:: get_sound(MovieAudio *sound, bool positional, int mode) { ReMutexHolder holder(_lock); @@ -507,11 +475,9 @@ get_sound(MovieAudio *sound, bool positional, int mode) { return res; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_sound -// Access: Public -// Description: This is what creates a sound instance. -//////////////////////////////////////////////////////////////////// +/** + * This is what creates a sound instance. + */ PT(AudioSound) OpenALAudioManager:: get_sound(const string &file_name, bool positional, int mode) { ReMutexHolder holder(_lock); @@ -538,13 +504,10 @@ get_sound(const string &file_name, bool positional, int mode) { return res; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::uncache_sound -// Access: Public -// Description: Deletes a sample from the expiration queues. -// If the sound is actively in use, then the sound -// cannot be deleted, and this function has no effect. -//////////////////////////////////////////////////////////////////// +/** + * Deletes a sample from the expiration queues. If the sound is actively in + * use, then the sound cannot be deleted, and this function has no effect. + */ void OpenALAudioManager:: uncache_sound(const string& file_name) { ReMutexHolder holder(_lock); @@ -565,22 +528,18 @@ uncache_sound(const string& file_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::clear_cache -// Access: Public -// Description: Clear out the sound cache. -//////////////////////////////////////////////////////////////////// +/** + * Clear out the sound cache. + */ void OpenALAudioManager:: clear_cache() { ReMutexHolder holder(_lock); discard_excess_cache(0); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_cache_limit -// Access: Public -// Description: Set the number of sounds that the cache can hold. -//////////////////////////////////////////////////////////////////// +/** + * Set the number of sounds that the cache can hold. + */ void OpenALAudioManager:: set_cache_limit(unsigned int count) { ReMutexHolder holder(_lock); @@ -588,21 +547,17 @@ set_cache_limit(unsigned int count) { discard_excess_cache(count); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_cache_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int OpenALAudioManager:: get_cache_limit() const { return _cache_limit; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::release_sound -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioManager:: release_sound(OpenALAudioSound* audioSound) { ReMutexHolder holder(_lock); @@ -612,12 +567,10 @@ release_sound(OpenALAudioSound* audioSound) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_volume(PN_stdfloat volume) -// Access: Public -// Description: -// Sets listener gain -//////////////////////////////////////////////////////////////////// +/** + * + * Sets listener gain + */ void OpenALAudioManager::set_volume(PN_stdfloat volume) { ReMutexHolder holder(_lock); if (_volume!=volume) { @@ -630,8 +583,8 @@ void OpenALAudioManager::set_volume(PN_stdfloat volume) { } /* - // this was neat alternative to the above look - // when we had a seperate context for each manager + // this was neat alternative to the above look when we had a seperate + // context for each manager make_current(); alGetError(); // clear errors @@ -640,22 +593,18 @@ void OpenALAudioManager::set_volume(PN_stdfloat volume) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_volume() -// Access: Public -// Description: -// Gets listener gain -//////////////////////////////////////////////////////////////////// +/** + * + * Gets listener gain + */ PN_stdfloat OpenALAudioManager:: get_volume() const { return _volume; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_play_rate -// Access: Public -// Description: set the overall play rate -//////////////////////////////////////////////////////////////////// +/** + * set the overall play rate + */ void OpenALAudioManager:: set_play_rate(PN_stdfloat play_rate) { ReMutexHolder holder(_lock); @@ -669,22 +618,17 @@ set_play_rate(PN_stdfloat play_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_play_rate -// Access: Public -// Description: get the overall speed/pitch/play rate -//////////////////////////////////////////////////////////////////// +/** + * get the overall speed/pitch/play rate + */ PN_stdfloat OpenALAudioManager:: get_play_rate() const { return _play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_active(bool active) -// Access: Public -// Description: Turn on/off -// Warning: not implemented. -//////////////////////////////////////////////////////////////////// +/** + * Turn on/off Warning: not implemented. + */ void OpenALAudioManager:: set_active(bool active) { ReMutexHolder holder(_lock); @@ -698,31 +642,25 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_active() -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OpenALAudioManager:: get_active() const { return _active; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_set_listener_attributes -// Access: Public -// Description: Set position of the "ear" that picks up 3d sounds -// NOW LISTEN UP!!! THIS IS IMPORTANT! -// Both Panda3D and OpenAL use a right handed coordinate system. -// But there is a major difference! -// In Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. -// In OpenAL the Y-Axis is going up and the Z-Axis is coming out of the screen. -// The solution is simple, we just flip the Y and Z axis and negate the Z, as we move coordinates -// from Panda to OpenAL and back. -// What does did mean to average Panda user? Nothing, they shouldn't notice anyway. -// But if you decide to do any 3D audio work in here you have to keep it in mind. -// I told you, so you can't say I didn't. -//////////////////////////////////////////////////////////////////// +/** + * Set position of the "ear" that picks up 3d sounds NOW LISTEN UP!!! THIS IS + * IMPORTANT! Both Panda3D and OpenAL use a right handed coordinate system. + * But there is a major difference! In Panda3D the Y-Axis is going into the + * Screen and the Z-Axis is going up. In OpenAL the Y-Axis is going up and + * the Z-Axis is coming out of the screen. The solution is simple, we just + * flip the Y and Z axis and negate the Z, as we move coordinates from Panda + * to OpenAL and back. What does did mean to average Panda user? Nothing, + * they shouldn't notice anyway. But if you decide to do any 3D audio work in + * here you have to keep it in mind. I told you, so you can't say I didn't. + */ void OpenALAudioManager:: audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, PN_stdfloat ux, PN_stdfloat uy, PN_stdfloat uz) { ReMutexHolder holder(_lock); @@ -754,11 +692,9 @@ audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, al_audio_errcheck("alListerfv(AL_ORIENTATION)"); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_get_listener_attributes -// Access: Public -// Description: Get position of the "ear" that picks up 3d sounds -//////////////////////////////////////////////////////////////////// +/** + * Get position of the "ear" that picks up 3d sounds + */ void OpenALAudioManager:: audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz, PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz) { ReMutexHolder holder(_lock); @@ -780,15 +716,12 @@ audio_3d_get_listener_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat * } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_set_distance_factor -// Access: Public -// Description: Set units per foot -// WARNING: OpenAL has no distance factor but we use this as a scale -// on the min/max distances of sounds to preserve FMOD compatibility. -// Also, adjusts the speed of sound to compensate for unit difference. -// OpenAL's default speed of sound is 343.3 m/s == 1126.3 ft/s -//////////////////////////////////////////////////////////////////// +/** + * Set units per foot WARNING: OpenAL has no distance factor but we use this + * as a scale on the min/max distances of sounds to preserve FMOD + * compatibility. Also, adjusts the speed of sound to compensate for unit + * difference. OpenAL's default speed of sound is 343.3 m/s == 1126.3 ft/s + */ void OpenALAudioManager:: audio_3d_set_distance_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -801,7 +734,8 @@ audio_3d_set_distance_factor(PN_stdfloat factor) { if (_distance_factor>0) { alSpeedOfSound(1126.3*_distance_factor); al_audio_errcheck("alSpeedOfSound()"); - // resets the doppler factor to the correct setting in case it was set to 0.0 by a distance_factor<=0.0 + // resets the doppler factor to the correct setting in case it was set to + // 0.0 by a distance_factor<=0.0 alDopplerFactor(_doppler_factor); al_audio_errcheck("alDopplerFactor()"); } else { @@ -817,22 +751,17 @@ audio_3d_set_distance_factor(PN_stdfloat factor) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_get_distance_factor -// Access: Public -// Description: Sets units per foot -//////////////////////////////////////////////////////////////////// +/** + * Sets units per foot + */ PN_stdfloat OpenALAudioManager:: audio_3d_get_distance_factor() const { return _distance_factor; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_set_doppler_factor -// Access: Public -// Description: Exaggerates or diminishes the Doppler effect. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Exaggerates or diminishes the Doppler effect. Defaults to 1.0 + */ void OpenALAudioManager:: audio_3d_set_doppler_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -845,22 +774,17 @@ audio_3d_set_doppler_factor(PN_stdfloat factor) { al_audio_errcheck("alDopplerFactor()"); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_get_doppler_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat OpenALAudioManager:: audio_3d_get_doppler_factor() const { return _doppler_factor; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_set_drop_off_factor -// Access: Public -// Description: Control the effect distance has on audability. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Control the effect distance has on audability. Defaults to 1.0 + */ void OpenALAudioManager:: audio_3d_set_drop_off_factor(PN_stdfloat factor) { ReMutexHolder holder(_lock); @@ -872,24 +796,19 @@ audio_3d_set_drop_off_factor(PN_stdfloat factor) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::audio_3d_get_drop_off_factor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat OpenALAudioManager:: audio_3d_get_drop_off_factor() const { return _drop_off_factor; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::starting_sound -// Access: -// Description: Inform the manager that a sound is about to play. -// The manager will add this sound to the table of -// sounds that are playing, and will allocate a source -// to this sound. -//////////////////////////////////////////////////////////////////// +/** + * Inform the manager that a sound is about to play. The manager will add + * this sound to the table of sounds that are playing, and will allocate a + * source to this sound. + */ void OpenALAudioManager:: starting_sound(OpenALAudioSound* audio) { ReMutexHolder holder(_lock); @@ -900,7 +819,8 @@ starting_sound(OpenALAudioSound* audio) { return; } - // first give all sounds that have finished a chance to stop, so that these get stopped first + // first give all sounds that have finished a chance to stop, so that these + // get stopped first update(); if (_concurrent_sound_limit) { @@ -915,7 +835,8 @@ starting_sound(OpenALAudioSound* audio) { ALenum result = alGetError(); if (result!=AL_NO_ERROR) { audio_error("alGenSources(): " << alGetString(result) ); - // if we can't create any more sources, set stop a sound to free a source + // if we can't create any more sources, set stop a sound to free a + // source reduce_sounds_playing_to(_sounds_playing.size()-1); source = 0; } @@ -932,13 +853,10 @@ starting_sound(OpenALAudioSound* audio) { _sounds_playing.insert(audio); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::stopping_sound -// Access: -// Description: Inform the manager that a sound is finished or -// someone called stop on the sound (this should not -// be called if a sound is only paused). -//////////////////////////////////////////////////////////////////// +/** + * Inform the manager that a sound is finished or someone called stop on the + * sound (this should not be called if a sound is only paused). + */ void OpenALAudioManager:: stopping_sound(OpenALAudioSound* audio) { ReMutexHolder holder(_lock); @@ -949,11 +867,9 @@ stopping_sound(OpenALAudioSound* audio) { _sounds_playing.erase(audio); // This could cause the sound to destruct. } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::set_concurrent_sound_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioManager:: set_concurrent_sound_limit(unsigned int limit) { ReMutexHolder holder(_lock); @@ -961,67 +877,58 @@ set_concurrent_sound_limit(unsigned int limit) { reduce_sounds_playing_to(_concurrent_sound_limit); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::get_concurrent_sound_limit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int OpenALAudioManager:: get_concurrent_sound_limit() const { return _concurrent_sound_limit; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::reduce_sounds_playing_to -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioManager:: reduce_sounds_playing_to(unsigned int count) { ReMutexHolder holder(_lock); - // first give all sounds that have finished a chance to stop, so that these get stopped first + // first give all sounds that have finished a chance to stop, so that these + // get stopped first update(); int limit = _sounds_playing.size() - count; while (limit-- > 0) { SoundsPlaying::iterator sound = _sounds_playing.begin(); assert(sound != _sounds_playing.end()); - // When the user stops a sound, there is still a PT in the - // user's hand. When we stop a sound here, however, - // this can remove the last PT. This can cause an ugly - // recursion where stop calls the destructor, and the - // destructor calls stop. To avoid this, we create - // a temporary PT, stop the sound, and then release the PT. + // When the user stops a sound, there is still a PT in the user's hand. + // When we stop a sound here, however, this can remove the last PT. This + // can cause an ugly recursion where stop calls the destructor, and the + // destructor calls stop. To avoid this, we create a temporary PT, stop + // the sound, and then release the PT. PT(OpenALAudioSound) s = (*sound); s->stop(); } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::stop_all_sounds() -// Access: Public -// Description: Stop playback on all sounds managed by this manager. -//////////////////////////////////////////////////////////////////// +/** + * Stop playback on all sounds managed by this manager. + */ void OpenALAudioManager:: stop_all_sounds() { ReMutexHolder holder(_lock); reduce_sounds_playing_to(0); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::update -// Access: Public -// Description: Perform all per-frame update functions. -//////////////////////////////////////////////////////////////////// +/** + * Perform all per-frame update functions. + */ void OpenALAudioManager:: update() { ReMutexHolder holder(_lock); - // See if any of our playing sounds have ended - // we must first collect a seperate list of finished sounds and then - // iterated over those again calling their finished method. We - // can't call finished() within a loop iterating over _sounds_playing - // since finished() modifies _sounds_playing + // See if any of our playing sounds have ended we must first collect a + // seperate list of finished sounds and then iterated over those again + // calling their finished method. We can't call finished() within a loop + // iterating over _sounds_playing since finished() modifies _sounds_playing SoundsPlaying sounds_finished; double rtc = TrueClock::get_global_ptr()->get_short_time(); @@ -1046,13 +953,10 @@ update() { } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::cleanup -// Access: Private -// Description: Shuts down the audio manager and releases any -// resources associated with it. Also cleans up all -// AudioSounds created via the manager. -//////////////////////////////////////////////////////////////////// +/** + * Shuts down the audio manager and releases any resources associated with it. + * Also cleans up all AudioSounds created via the manager. + */ void OpenALAudioManager:: cleanup() { ReMutexHolder holder(_lock); @@ -1101,7 +1005,7 @@ cleanup() { if (_device) { audio_debug("Going to try to close openAL"); alcCloseDevice(_device); - //alc_audio_errcheck("alcCloseDevice(_device)",_device); + // alc_audio_errcheck("alcCloseDevice(_device)",_device); _device = NULL; audio_debug("openAL Closed"); } @@ -1112,11 +1016,9 @@ cleanup() { _cleanup_required = false; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::SoundData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioManager::SoundData:: SoundData() : _manager(0), @@ -1130,11 +1032,9 @@ SoundData() : { } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::SoundData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioManager::SoundData:: ~SoundData() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -1147,13 +1047,10 @@ OpenALAudioManager::SoundData:: } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::increment_client_count -// Access: Public -// Description: Increments the SoundData's client count. Any -// SoundData that is actively in use (ie, has a client) -// is removed entirely from the expiration queue. -//////////////////////////////////////////////////////////////////// +/** + * Increments the SoundData's client count. Any SoundData that is actively in + * use (ie, has a client) is removed entirely from the expiration queue. + */ void OpenALAudioManager:: increment_client_count(SoundData *sd) { ReMutexHolder holder(_lock); @@ -1168,15 +1065,11 @@ increment_client_count(SoundData *sd) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::decrement_client_count -// Access: Public -// Description: Decrements the SoundData's client count. Sounds -// that are no longer in use (ie, have no clients) -// go into the expiration queue. When the expiration -// queue reaches the cache limit, the first item on -// the queue is freed. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the SoundData's client count. Sounds that are no longer in use + * (ie, have no clients) go into the expiration queue. When the expiration + * queue reaches the cache limit, the first item on the queue is freed. + */ void OpenALAudioManager:: decrement_client_count(SoundData *sd) { ReMutexHolder holder(_lock); @@ -1196,12 +1089,10 @@ decrement_client_count(SoundData *sd) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioManager::discard_excess_cache -// Access: Public -// Description: Discards sounds from the sound cache until the -// number of sounds remaining is under the limit. -//////////////////////////////////////////////////////////////////// +/** + * Discards sounds from the sound cache until the number of sounds remaining + * is under the limit. + */ void OpenALAudioManager:: discard_excess_cache(int sample_limit) { ReMutexHolder holder(_lock); diff --git a/panda/src/audiotraits/openalAudioManager.h b/panda/src/audiotraits/openalAudioManager.h index 25d49605c7..f78e8a53ea 100644 --- a/panda/src/audiotraits/openalAudioManager.h +++ b/panda/src/audiotraits/openalAudioManager.h @@ -1,18 +1,14 @@ -// Filename: openalAudioManager.h -// Created by: Ben Buchwald -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openalAudioManager.h + * @author Ben Buchwald + */ #ifndef __OPENAL_AUDIO_MANAGER_H__ #define __OPENAL_AUDIO_MANAGER_H__ @@ -47,7 +43,7 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { friend class OpenALSoundData; public: - //Constructor and Destructor + // Constructor and Destructor OpenALAudioManager(); virtual ~OpenALAudioManager(); @@ -72,12 +68,12 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { virtual void set_active(bool); virtual bool get_active() const; - // This controls the "set of ears" that listens to 3D spacialized sound - // px, py, pz are position coordinates. Can be 0.0f to ignore. - // vx, vy, vz are a velocity vector in UNITS PER SECOND. - // fx, fy and fz are the respective components of a unit forward-vector - // ux, uy and uz are the respective components of a unit up-vector - // These changes will NOT be invoked until audio_3d_update() is called. + // This controls the "set of ears" that listens to 3D spacialized sound px, + // py, pz are position coordinates. Can be 0.0f to ignore. vx, vy, vz are + // a velocity vector in UNITS PER SECOND. fx, fy and fz are the respective + // components of a unit forward-vector ux, uy and uz are the respective + // components of a unit up-vector These changes will NOT be invoked until + // audio_3d_update() is called. virtual void audio_3d_set_listener_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat xy, PN_stdfloat xz, PN_stdfloat fx, PN_stdfloat fy, PN_stdfloat fz, @@ -88,22 +84,21 @@ class EXPCL_OPENAL_AUDIO OpenALAudioManager : public AudioManager { PN_stdfloat *fx, PN_stdfloat *fy, PN_stdfloat *fz, PN_stdfloat *ux, PN_stdfloat *uy, PN_stdfloat *uz); - // Control the "relative distance factor" for 3D spacialized audio in units-per-foot. Default is 1.0 - // OpenAL has no distance factor but we use this as a scale - // on the min/max distances of sounds to preserve FMOD compatibility. - // Also, adjusts the speed of sound to compensate for unit difference. + // Control the "relative distance factor" for 3D spacialized audio in units- + // per-foot. Default is 1.0 OpenAL has no distance factor but we use this + // as a scale on the minmax distances of sounds to preserve FMOD + // compatibility. Also, adjusts the speed of sound to compensate for unit + // difference. virtual void audio_3d_set_distance_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_distance_factor() const; - // Control the presence of the Doppler effect. Default is 1.0 - // Exaggerated Doppler, use >1.0 - // Diminshed Doppler, use <1.0 + // Control the presence of the Doppler effect. Default is 1.0 Exaggerated + // Doppler, use >1.0 Diminshed Doppler, use <1.0 virtual void audio_3d_set_doppler_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_doppler_factor() const; - // Exaggerate or diminish the effect of distance on sound. Default is 1.0 - // Faster drop off, use >1.0 - // Slower drop off, use <1.0 + // Exaggerate or diminish the effect of distance on sound. Default is 1.0 + // Faster drop off, use >1.0 Slower drop off, use <1.0 virtual void audio_3d_set_drop_off_factor(PN_stdfloat factor); virtual PN_stdfloat audio_3d_get_drop_off_factor() const; @@ -140,26 +135,24 @@ private: // This global lock protects all access to OpenAL library interfaces. static ReMutex _lock; - // An expiration queue is a list of SoundData - // that are no longer being used. They are kept - // around for a little while, since it is common to - // stop using a sound for a brief moment and then - // quickly resume. + // An expiration queue is a list of SoundData that are no longer being used. + // They are kept around for a little while, since it is common to stop using + // a sound for a brief moment and then quickly resume. typedef plist ExpirationQueue; ExpirationQueue _expiring_samples; ExpirationQueue _expiring_streams; - // An AudioSound that uses a SoundData is called a "client" - // of the SoundData. The SoundData keeps track of how - // many clients are using it. When the number of clients - // drops to zero, the SoundData is no longer in use. The - // expiration queue is a list of all SoundData that aren't - // in use, in least-recently-used order. If a SoundData - // in the expiration queue gains a new client, it is removed - // from the expiration queue. When the number of sounds - // in the expiration queue exceeds the cache limit, the - // first sound in the expiration queue is purged. +/* + * An AudioSound that uses a SoundData is called a "client" of the SoundData. + * The SoundData keeps track of how many clients are using it. When the + * number of clients drops to zero, the SoundData is no longer in use. The + * expiration queue is a list of all SoundData that aren't in use, in least- + * recently-used order. If a SoundData in the expiration queue gains a new + * client, it is removed from the expiration queue. When the number of sounds + * in the expiration queue exceeds the cache limit, the first sound in the + * expiration queue is purged. + */ class SoundData { public: @@ -217,9 +210,7 @@ private: ALfloat _velocity[3]; ALfloat _forward_up[6]; -//////////////////////////////////////////////////////////////////// - //These are needed for Panda's Pointer System. DO NOT ERASE! -//////////////////////////////////////////////////////////////////// + // These are needed for Panda's Pointer System. DO NOT ERASE! public: static TypeHandle get_class_type() { @@ -240,9 +231,7 @@ private: private: static TypeHandle _type_handle; -//////////////////////////////////////////////////////////////////// - //DONE -//////////////////////////////////////////////////////////////////// + // DONE }; diff --git a/panda/src/audiotraits/openalAudioSound.I b/panda/src/audiotraits/openalAudioSound.I index f2d9649917..a68d36ee12 100644 --- a/panda/src/audiotraits/openalAudioSound.I +++ b/panda/src/audiotraits/openalAudioSound.I @@ -1,55 +1,43 @@ -// Filename: openalAudioSound.I -// Created by: Ben Buchwald -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openalAudioSound.I + * @author Ben Buchwald + */ -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_calibrated_clock -// Access: Public -// Description: Sets the sound's calibrated clock. -// -// OpenAL is not very accurate at reporting how much -// time has elapsed within a buffer. However, it does -// accurately report when it has finished playing a -// buffer. So we use a hybrid clock algorithm. -// When OpenAL is in the middle of a buffer, -// we use a real-time-clock to estimate how far the -// sound has gotten. Each time OpenAL reaches the end -// of a buffer (which it does every 1/4 second or so), -// we calibrate our real-time-clock by speeding it up -// or slowing it down. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sound's calibrated clock. + * + * OpenAL is not very accurate at reporting how much time has elapsed within a + * buffer. However, it does accurately report when it has finished playing a + * buffer. So we use a hybrid clock algorithm. When OpenAL is in the middle + * of a buffer, we use a real-time-clock to estimate how far the sound has + * gotten. Each time OpenAL reaches the end of a buffer (which it does every + * 1/4 second or so), we calibrate our real-time-clock by speeding it up or + * slowing it down. + */ INLINE void OpenALAudioSound:: set_calibrated_clock(double rtc, double t, double accel) { _calibrated_clock_scale = _playing_rate * accel; _calibrated_clock_base = rtc - (t / _calibrated_clock_scale); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_calibrated_clock -// Access: Public -// Description: Returns the value of the calibrated clock. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the calibrated clock. + */ INLINE double OpenALAudioSound:: get_calibrated_clock(double rtc) const { return (rtc - _calibrated_clock_base) * _calibrated_clock_scale; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::require_sound_data -// Access: Private -// Description: Makes sure the sound data record is present, -// and if not, obtains it. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure the sound data record is present, and if not, obtains it. + */ void OpenALAudioSound:: require_sound_data() { if (_sd==0) { @@ -61,12 +49,10 @@ require_sound_data() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::release_sound_data -// Access: Private -// Description: Checks if the sound data record is present and -// releasable, and if so, releases it. -//////////////////////////////////////////////////////////////////// +/** + * Checks if the sound data record is present and releasable, and if so, + * releases it. + */ void OpenALAudioSound:: release_sound_data() { if ((_sd!=0) && (!_movie->get_filename().empty())) { diff --git a/panda/src/audiotraits/openalAudioSound.cxx b/panda/src/audiotraits/openalAudioSound.cxx index e620a65718..7237b2fefe 100644 --- a/panda/src/audiotraits/openalAudioSound.cxx +++ b/panda/src/audiotraits/openalAudioSound.cxx @@ -1,21 +1,18 @@ -// Filename: openalAudioSound.cxx -// Created by: Ben Buchwald -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openalAudioSound.cxx + * @author Ben Buchwald + */ #include "pandabase.h" -//Panda Headers +// Panda Headers #include "throw_event.h" #include "openalAudioSound.h" #include "openalAudioManager.h" @@ -31,11 +28,9 @@ TypeHandle OpenALAudioSound::_type_handle; #define openal_audio_debug(x) ((void)0) #endif //] -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioSound:: OpenALAudioSound(OpenALAudioManager* manager, @@ -89,22 +84,18 @@ OpenALAudioSound(OpenALAudioManager* manager, } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenALAudioSound:: ~OpenALAudioSound() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::cleanup -// Access: Private -// Description: Disables the sound forever. Releases resources and -// detaches the sound from its audio manager. -//////////////////////////////////////////////////////////////////// +/** + * Disables the sound forever. Releases resources and detaches the sound from + * its audio manager. + */ void OpenALAudioSound:: cleanup() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -122,11 +113,9 @@ cleanup() { _manager = 0; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::play -// Access: Public -// Description: Plays a sound. -//////////////////////////////////////////////////////////////////// +/** + * Plays a sound. + */ void OpenALAudioSound:: play() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -153,13 +142,14 @@ play() { alGetError(); // clear errors - // nonpositional sources are made relative to the listener so they don't move + // nonpositional sources are made relative to the listener so they don't + // move alSourcei(_source,AL_SOURCE_RELATIVE,_positional?AL_FALSE:AL_TRUE); al_audio_errcheck("alSourcei(_source,AL_SOURCE_RELATIVE)"); // set source properties that we have stored set_volume(_volume); - //set_balance(_balance); + // set_balance(_balance); set_3d_min_distance(_min_dist); set_3d_max_distance(_max_dist); @@ -197,11 +187,9 @@ play() { _start_time = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::stop -// Access: Public -// Description: Stop a sound -//////////////////////////////////////////////////////////////////// +/** + * Stop a sound + */ void OpenALAudioSound:: stop() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -229,11 +217,9 @@ stop() { release_sound_data(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::finished -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioSound:: finished() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -244,32 +230,26 @@ finished() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_loop -// Access: Public -// Description: Turns looping on and off -//////////////////////////////////////////////////////////////////// +/** + * Turns looping on and off + */ void OpenALAudioSound:: set_loop(bool loop) { ReMutexHolder holder(OpenALAudioManager::_lock); set_loop_count((loop)?0:1); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_loop -// Access: Public -// Description: Returns whether looping is on or off -//////////////////////////////////////////////////////////////////// +/** + * Returns whether looping is on or off + */ bool OpenALAudioSound:: get_loop() const { return (_loop_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_loop_count -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioSound:: set_loop_count(unsigned long loop_count) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -281,27 +261,21 @@ set_loop_count(unsigned long loop_count) { _loop_count=loop_count; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_loop_count -// Access: Public -// Description: Return how many times a sound will loop. -//////////////////////////////////////////////////////////////////// +/** + * Return how many times a sound will loop. + */ unsigned long OpenALAudioSound:: get_loop_count() const { return _loop_count; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::restart_stalled_audio -// Access: Public -// Description: When streaming audio, the computer is supposed to -// keep OpenAL's queue full. However, there are times -// when the computer is running slow and the queue -// empties prematurely. In that case, OpenAL will stop. -// When the computer finally gets around to refilling -// the queue, it is necessary to tell OpenAL to resume -// playing. -//////////////////////////////////////////////////////////////////// +/** + * When streaming audio, the computer is supposed to keep OpenAL's queue full. + * However, there are times when the computer is running slow and the queue + * empties prematurely. In that case, OpenAL will stop. When the computer + * finally gets around to refilling the queue, it is necessary to tell OpenAL + * to resume playing. + */ void OpenALAudioSound:: restart_stalled_audio() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -316,11 +290,9 @@ restart_stalled_audio() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::queue_buffer -// Access: Public -// Description: Pushes a buffer into the source queue. -//////////////////////////////////////////////////////////////////// +/** + * Pushes a buffer into the source queue. + */ void OpenALAudioSound:: queue_buffer(ALuint buffer, int samples, int loop_index, double time_offset) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -341,11 +313,9 @@ queue_buffer(ALuint buffer, int samples, int loop_index, double time_offset) { _stream_queued.push_back(buf); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::make_buffer -// Access: Public -// Description: Creates an OpenAL buffer object. -//////////////////////////////////////////////////////////////////// +/** + * Creates an OpenAL buffer object. + */ ALuint OpenALAudioSound:: make_buffer(int samples, int channels, int rate, unsigned char *data) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -374,12 +344,10 @@ make_buffer(int samples, int channels, int rate, unsigned char *data) { return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::read_stream_data -// Access: Public -// Description: Fills a buffer with data from the stream. -// Returns the number of samples stored in the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Fills a buffer with data from the stream. Returns the number of samples + * stored in the buffer. + */ int OpenALAudioSound:: read_stream_data(int bytelen, unsigned char *buffer) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -425,16 +393,12 @@ read_stream_data(int bytelen, unsigned char *buffer) { return fill; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::correct_calibrated_clock -// Access: Public -// Description: Compares the specified time to the value of the -// calibrated clock, and adjusts the calibrated -// clock speed to make it closer to the target value. -// This routine is quite careful to make sure that -// the calibrated clock moves in a smooth, monotonic -// way. -//////////////////////////////////////////////////////////////////// +/** + * Compares the specified time to the value of the calibrated clock, and + * adjusts the calibrated clock speed to make it closer to the target value. + * This routine is quite careful to make sure that the calibrated clock moves + * in a smooth, monotonic way. + */ void OpenALAudioSound:: correct_calibrated_clock(double rtc, double t) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -463,11 +427,9 @@ correct_calibrated_clock(double rtc, double t) { cc = (rtc - _calibrated_clock_base) * _calibrated_clock_scale; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::pull_used_buffers -// Access: Public -// Description: Pulls any used buffers out of OpenAL's queue. -//////////////////////////////////////////////////////////////////// +/** + * Pulls any used buffers out of OpenAL's queue. + */ void OpenALAudioSound:: pull_used_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -497,12 +459,10 @@ pull_used_buffers() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::push_fresh_buffers -// Access: Public -// Description: Pushes fresh buffers into OpenAL's queue until -// the queue is "full" (ie, has plenty of data). -//////////////////////////////////////////////////////////////////// +/** + * Pushes fresh buffers into OpenAL's queue until the queue is "full" (ie, has + * plenty of data). + */ void OpenALAudioSound:: push_fresh_buffers() { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -541,23 +501,19 @@ push_fresh_buffers() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_time -// Access: Public -// Description: The next time you call play, the sound will -// start from the specified offset. -//////////////////////////////////////////////////////////////////// +/** + * The next time you call play, the sound will start from the specified + * offset. + */ void OpenALAudioSound:: set_time(PN_stdfloat time) { ReMutexHolder holder(OpenALAudioManager::_lock); _start_time = time; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_time -// Access: Public -// Description: Gets the play position within the sound -//////////////////////////////////////////////////////////////////// +/** + * Gets the play position within the sound + */ PN_stdfloat OpenALAudioSound:: get_time() const { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -567,11 +523,9 @@ get_time() const { return _current_time; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::cache_time -// Access: Private -// Description: Updates the current_time field of a playing sound. -//////////////////////////////////////////////////////////////////// +/** + * Updates the current_time field of a playing sound. + */ void OpenALAudioSound:: cache_time(double rtc) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -585,12 +539,9 @@ cache_time(double rtc) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_volume(PN_stdfloat vol) -// Access: Public -// Description: 0.0 to 1.0 scale of volume converted to Fmod's -// internal 0.0 to 255.0 scale. -//////////////////////////////////////////////////////////////////// +/** + * 0.0 to 1.0 scale of volume converted to Fmod's internal 0.0 to 255.0 scale. + */ void OpenALAudioSound:: set_volume(PN_stdfloat volume) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -605,46 +556,37 @@ set_volume(PN_stdfloat volume) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_volume -// Access: Public -// Description: Gets the current volume of a sound. 1 is Max. O is Min. -//////////////////////////////////////////////////////////////////// +/** + * Gets the current volume of a sound. 1 is Max. O is Min. + */ PN_stdfloat OpenALAudioSound:: get_volume() const { return _volume; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_balance(PN_stdfloat bal) -// Access: Public -// Description: -1.0 to 1.0 scale -//////////////////////////////////////////////////////////////////// +/** + * -1.0 to 1.0 scale + */ void OpenALAudioSound:: set_balance(PN_stdfloat balance_right) { audio_debug("OpenALAudioSound::set_balance() not implemented"); } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_balance -// Access: Public -// Description: -1.0 to 1.0 scale -// -1 should be all the way left. -// 1 is all the way to the right. -//////////////////////////////////////////////////////////////////// +/** + * -1.0 to 1.0 scale -1 should be all the way left. 1 is all the way to the + * right. + */ PN_stdfloat OpenALAudioSound:: get_balance() const { audio_debug("OpenALAudioSound::get_balance() not implemented"); return 0; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_play_rate(PN_stdfloat rate) -// Access: Public -// Description: Sets the speed at which a sound plays back. -// The rate is a multiple of the sound, normal playback speed. -// IE 2 would play back 2 times fast, 3 would play 3 times, and so on. -//////////////////////////////////////////////////////////////////// +/** + * Sets the speed at which a sound plays back. The rate is a multiple of the + * sound, normal playback speed. IE 2 would play back 2 times fast, 3 would + * play 3 times, and so on. + */ void OpenALAudioSound:: set_play_rate(PN_stdfloat play_rate) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -654,42 +596,32 @@ set_play_rate(PN_stdfloat play_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_play_rate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat OpenALAudioSound:: get_play_rate() const { return _play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::length -// Access: Public -// Description: Get length -//////////////////////////////////////////////////////////////////// +/** + * Get length + */ PN_stdfloat OpenALAudioSound:: length() const { return _length; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_3d_attributes -// Access: Public -// Description: Set position and velocity of this sound -// -// Both Panda3D and OpenAL use a right handed -// coordinate system. However, in Panda3D the -// Y-Axis is going into the Screen and the -// Z-Axis is going up. In OpenAL the Y-Axis is -// going up and the Z-Axis is coming out of -// the screen. -// -// The solution is simple, we just flip the Y -// and Z axis and negate the Z, as we move -// coordinates from Panda to OpenAL and back. -//////////////////////////////////////////////////////////////////// +/** + * Set position and velocity of this sound + * + * Both Panda3D and OpenAL use a right handed coordinate system. However, in + * Panda3D the Y-Axis is going into the Screen and the Z-Axis is going up. In + * OpenAL the Y-Axis is going up and the Z-Axis is coming out of the screen. + * + * The solution is simple, we just flip the Y and Z axis and negate the Z, as + * we move coordinates from Panda to OpenAL and back. + */ void OpenALAudioSound:: set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -712,12 +644,10 @@ set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_3d_attributes -// Access: Public -// Description: Get position and velocity of this sound -// Currently unimplemented. Get the attributes of the attached object. -//////////////////////////////////////////////////////////////////// +/** + * Get position and velocity of this sound Currently unimplemented. Get the + * attributes of the attached object. + */ void OpenALAudioSound:: get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -730,12 +660,10 @@ get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vz = _velocity[1]; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_3d_min_distance -// Access: Public -// Description: Set the distance that this sound begins to fall off. Also -// affects the rate it falls off. -//////////////////////////////////////////////////////////////////// +/** + * Set the distance that this sound begins to fall off. Also affects the rate + * it falls off. + */ void OpenALAudioSound:: set_3d_min_distance(PN_stdfloat dist) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -750,21 +678,17 @@ set_3d_min_distance(PN_stdfloat dist) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_3d_min_distance -// Access: Public -// Description: Get the distance that this sound begins to fall off -//////////////////////////////////////////////////////////////////// +/** + * Get the distance that this sound begins to fall off + */ PN_stdfloat OpenALAudioSound:: get_3d_min_distance() const { return _min_dist; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_3d_max_distance -// Access: Public -// Description: Set the distance that this sound stops falling off -//////////////////////////////////////////////////////////////////// +/** + * Set the distance that this sound stops falling off + */ void OpenALAudioSound:: set_3d_max_distance(PN_stdfloat dist) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -779,22 +703,17 @@ set_3d_max_distance(PN_stdfloat dist) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_3d_max_distance -// Access: Public -// Description: Get the distance that this sound stops falling off -//////////////////////////////////////////////////////////////////// +/** + * Get the distance that this sound stops falling off + */ PN_stdfloat OpenALAudioSound:: get_3d_max_distance() const { return _max_dist; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_3d_drop_off_factor -// Access: Public -// Description: Control the effect distance has on audability. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Control the effect distance has on audability. Defaults to 1.0 + */ void OpenALAudioSound:: set_3d_drop_off_factor(PN_stdfloat factor) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -809,25 +728,19 @@ set_3d_drop_off_factor(PN_stdfloat factor) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_3d_drop_off_factor -// Access: Public -// Description: Control the effect distance has on audability. -// Defaults to 1.0 -//////////////////////////////////////////////////////////////////// +/** + * Control the effect distance has on audability. Defaults to 1.0 + */ PN_stdfloat OpenALAudioSound:: get_3d_drop_off_factor() const { return _drop_off_factor; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_active -// Access: Public -// Description: Sets whether the sound is marked "active". By -// default, the active flag true for all sounds. If the -// active flag is set to false for any particular sound, -// the sound will not be heard. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the sound is marked "active". By default, the active flag + * true for all sounds. If the active flag is set to false for any particular + * sound, the sound will not be heard. + */ void OpenALAudioSound:: set_active(bool active) { ReMutexHolder holder(OpenALAudioManager::_lock); @@ -854,54 +767,43 @@ set_active(bool active) { } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_active -// Access: Public -// Description: Returns whether the sound has been marked "active". -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the sound has been marked "active". + */ bool OpenALAudioSound:: get_active() const { return _active; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::set_finished_event -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OpenALAudioSound:: set_finished_event(const string& event) { _finished_event = event; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_finished_event -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const string& OpenALAudioSound:: get_finished_event() const { return _finished_event; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::get_name -// Access: Public -// Description: Get name of sound file -//////////////////////////////////////////////////////////////////// +/** + * Get name of sound file + */ const string& OpenALAudioSound:: get_name() const { return _basename; } -//////////////////////////////////////////////////////////////////// -// Function: OpenALAudioSound::status -// Access: Public -// Description: Get status of the sound. -// -// This returns the status as of the -// last push_fresh_buffers -//////////////////////////////////////////////////////////////////// +/** + * Get status of the sound. + * + * This returns the status as of the last push_fresh_buffers + */ AudioSound::SoundStatus OpenALAudioSound:: status() const { ReMutexHolder holder(OpenALAudioManager::_lock); diff --git a/panda/src/audiotraits/openalAudioSound.h b/panda/src/audiotraits/openalAudioSound.h index e3cdcdc304..95fd736190 100644 --- a/panda/src/audiotraits/openalAudioSound.h +++ b/panda/src/audiotraits/openalAudioSound.h @@ -1,17 +1,14 @@ -// Filename: openalAudioSound.h -// Created by: Ben Buchwald -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openalAudioSound.h + * @author Ben Buchwald + */ #ifndef __OPENAL_AUDIO_SOUND_H__ #define __OPENAL_AUDIO_SOUND_H__ @@ -39,42 +36,33 @@ public: ~OpenALAudioSound(); - // For best compatibility, set the loop_count, start_time, - // volume, and balance, prior to calling play(). You may - // set them while they're playing, but it's implementation - // specific whether you get the results. + // For best compatibility, set the loop_count, start_time, volume, and + // balance, prior to calling play(). You may set them while they're + // playing, but it's implementation specific whether you get the results. void play(); void stop(); - // loop: false = play once; true = play forever. - // inits to false. + // loop: false = play once; true = play forever. inits to false. void set_loop(bool loop=true); bool get_loop() const; - // loop_count: 0 = forever; 1 = play once; n = play n times. - // inits to 1. + // loop_count: 0 = forever; 1 = play once; n = play n times. inits to 1. void set_loop_count(unsigned long loop_count=1); unsigned long get_loop_count() const; - // 0 = beginning; length() = end. - // inits to 0.0. + // 0 = beginning; length() = end. inits to 0.0. void set_time(PN_stdfloat time=0.0); PN_stdfloat get_time() const; - // 0 = minimum; 1.0 = maximum. - // inits to 1.0. + // 0 = minimum; 1.0 = maximum. inits to 1.0. void set_volume(PN_stdfloat volume=1.0); PN_stdfloat get_volume() const; - // -1.0 is hard left - // 0.0 is centered - // 1.0 is hard right - // inits to 0.0. + // -1.0 is hard left 0.0 is centered 1.0 is hard right inits to 0.0. void set_balance(PN_stdfloat balance_right=0.0); PN_stdfloat get_balance() const; - // play_rate is any positive float value. - // inits to 1.0. + // play_rate is any positive float value. inits to 1.0. void set_play_rate(PN_stdfloat play_rate=1.0f); PN_stdfloat get_play_rate() const; @@ -82,9 +70,8 @@ public: void set_active(bool active=true); bool get_active() const; - // This is the string that throw_event() will throw - // when the sound finishes playing. It is not triggered - // when the sound is stopped with stop(). + // This is the string that throw_event() will throw when the sound finishes + // playing. It is not triggered when the sound is stopped with stop(). void set_finished_event(const string& event); const string& get_finished_event() const; @@ -93,9 +80,9 @@ public: // return: playing time in seconds. PN_stdfloat length() const; - // Controls the position of this sound's emitter. - // pos is a pointer to an xyz triplet of the emitter's position. - // vel is a pointer to an xyz triplet of the emitter's velocity. + // Controls the position of this sound's emitter. pos is a pointer to an + // xyz triplet of the emitter's position. vel is a pointer to an xyz + // triplet of the emitter's velocity. void set_3d_attributes(PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, PN_stdfloat vx, PN_stdfloat vy, PN_stdfloat vz); void get_3d_attributes(PN_stdfloat *px, PN_stdfloat *py, PN_stdfloat *pz, PN_stdfloat *vx, PN_stdfloat *vy, PN_stdfloat *vz); @@ -172,9 +159,8 @@ private: int _desired_mode; - // The calibrated clock is initialized when the - // sound starts playing, and is periodically corrected - // thereafter. + // The calibrated clock is initialized when the sound starts playing, and is + // periodically corrected thereafter. double _calibrated_clock_base; double _calibrated_clock_scale; double _calibrated_clock_decavg; @@ -182,23 +168,20 @@ private: // The start_time field affects the next call to play. double _start_time; - // The current_time field is updated every frame - // during the AudioManager update. Updates need - // to be atomic, because get_time can be called - // in the cull thread. + // The current_time field is updated every frame during the AudioManager + // update. Updates need to be atomic, because get_time can be called in the + // cull thread. PN_stdfloat _current_time; - // This is the string that throw_event() will throw - // when the sound finishes playing. It is not triggered - // when the sound is stopped with stop(). + // This is the string that throw_event() will throw when the sound finishes + // playing. It is not triggered when the sound is stopped with stop(). string _finished_event; Filename _basename; - // _active is for things like a 'turn off sound effects' in - // a preferences pannel. - // _active is not about whether a sound is currently playing. - // Use status() for info on whether the sound is playing. + // _active is for things like a 'turn off sound effects' in a preferences + // pannel. _active is not about whether a sound is currently playing. Use + // status() for info on whether the sound is playing. bool _active; bool _paused; diff --git a/panda/src/awesomium/AwMouseAndKeyboard.cxx b/panda/src/awesomium/AwMouseAndKeyboard.cxx index 258e29b8f0..2ee5728584 100644 --- a/panda/src/awesomium/AwMouseAndKeyboard.cxx +++ b/panda/src/awesomium/AwMouseAndKeyboard.cxx @@ -1,16 +1,15 @@ -// Filename: AwMouseAndKeyboard.cxx -// Created by: Bei Yang (Mar2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file AwMouseAndKeyboard.cxx + * @author Bei Yang + * @date 2010-03 + */ #include "config_awesomium.h" #include "AwMouseAndKeyboard.h" @@ -31,7 +30,7 @@ void AwMouseAndKeyboard::do_transmit_data(DataGraphTraverser *trav, const DataNo if (input.has_data(_button_events_input)) { const ButtonEventList *button_events; DCAST_INTO_V(button_events, input.get_data(_button_events_input).get_ptr()); - + int num_events = button_events->get_num_events(); for (int i = 0; i < num_events; i++) { const ButtonEvent &be = button_events->get_event(i); diff --git a/panda/src/awesomium/AwMouseAndKeyboard.h b/panda/src/awesomium/AwMouseAndKeyboard.h index 9a02fd18c2..2a70904523 100644 --- a/panda/src/awesomium/AwMouseAndKeyboard.h +++ b/panda/src/awesomium/AwMouseAndKeyboard.h @@ -1,16 +1,16 @@ -// Filename: AwMouseAndKeyboard.h -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file AwMouseAndKeyboard.h + * @author rurbino + * @date 2009-10-12 + */ + #ifndef AWWEBKEYBOARDMOUSE_H #define AWWEBKEYBOARDMOUSE_H @@ -21,12 +21,11 @@ #include "mouseAndKeyboard.h" -//////////////////////////////////////////////////////////////////// -// Class : AwMouseAndKeyboard -// Description : Thin wrappings arround WebCore.h -//////////////////////////////////////////////////////////////////// +/** + * Thin wrappings arround WebCore.h + */ class EXPCL_PANDAAWESOMIUM AwMouseAndKeyboard : public DataNode { -//member data data +// member data data protected: // inputs adn output indices... initialized in constructor int _button_events_input; diff --git a/panda/src/awesomium/WebBrowserTexture.cxx b/panda/src/awesomium/WebBrowserTexture.cxx index 5997064af4..7872574b9d 100644 --- a/panda/src/awesomium/WebBrowserTexture.cxx +++ b/panda/src/awesomium/WebBrowserTexture.cxx @@ -1,47 +1,38 @@ -// Filename: WebBrowserTexture.cxx -// Created by: bei yang (Mar 2010) -// -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file WebBrowserTexture.cxx + * @author bei yang + * @date 2010-03 + */ #include "config_awesomium.h" #include "WebBrowserTexture.h" TypeHandle WebBrowserTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::WebBrowserTexture -// Access: Published -// Description: Copy constructor for web browser texture. The behavior -// of copying a webtexture is that will be the same -// as a standard texture copy. However, the content -// will remain the system until set_web_view is called. -//////////////////////////////////////////////////////////////////// +/** + * Copy constructor for web browser texture. The behavior of copying a + * webtexture is that will be the same as a standard texture copy. However, + * the content will remain the system until set_web_view is called. + */ WebBrowserTexture::WebBrowserTexture(const WebBrowserTexture ©): Texture(copy) { - //this kind of assumes that the previous texture - //was initialized properly + // this kind of assumes that the previous texture was initialized properly _aw_web_view = copy._aw_web_view; _update_active = copy._update_active; _flip_texture_active = copy._flip_texture_active; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::WebBrowserTexture -// Access: Published -// Description: This initializes a web browser texture with the given -// AwWebView class. -//////////////////////////////////////////////////////////////////// +/** + * This initializes a web browser texture with the given AwWebView class. + */ WebBrowserTexture::WebBrowserTexture(const string &name, AwWebView* aw_web_view): Texture(name), _update_active(true), @@ -53,168 +44,138 @@ _flip_texture_active(false) } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::~WebBrowserTexture -// Access: Published -// Description: Standard destructor... doesn't do anything. All -// destructing happens in parent texture class. -//////////////////////////////////////////////////////////////////// +/** + * Standard destructor... doesn't do anything. All destructing happens in + * parent texture class. + */ WebBrowserTexture::~WebBrowserTexture() { - //do nothing + // do nothing } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::~WebBrowserTexture -// Access: Published -// Description: Standard destructor... doesn't do anything. All -// destructing happens in parent texture class. -//////////////////////////////////////////////////////////////////// +/** + * Standard destructor... doesn't do anything. All destructing happens in + * parent texture class. + */ bool WebBrowserTexture::get_keep_ram_image() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::reload_ram_image -// Access: Protected, Virtual -// Description: A WebBrowserTexture must always keep its ram image. -// This is essentially a sub. -//////////////////////////////////////////////////////////////////// +/** + * A WebBrowserTexture must always keep its ram image. This is essentially a + * sub. + */ void WebBrowserTexture::do_reload_ram_image() { - // A MovieTexture should never dump its RAM image. - // Therefore, this is not needed. + // A MovieTexture should never dump its RAM image. Therefore, this is not + // needed. } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -// -// This one returns true because it uses -// the cull traverser method to do the texture udpate. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + * + * This one returns true because it uses the cull traverser method to do the + * texture udpate. + */ bool WebBrowserTexture::has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::set_web_view -// Access: Published -// Description: Sets the internal AwWebView of this texture. -// After calling this, the texture will automatically -// set it's width and height to match the AwWebView -// at the next time it is culled and rendered. -//////////////////////////////////////////////////////////////////// +/** + * Sets the internal AwWebView of this texture. After calling this, the + * texture will automatically set it's width and height to match the AwWebView + * at the next time it is culled and rendered. + */ void WebBrowserTexture::set_web_view(AwWebView* aw_web_view){ _aw_web_view = aw_web_view; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::get_web_view -// Access: Published -// Description: Gets the current internal AwWebView of this texture. -//////////////////////////////////////////////////////////////////// +/** + * Gets the current internal AwWebView of this texture. + */ AwWebView* WebBrowserTexture::get_web_view() const{ return _aw_web_view; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::set_update_active -// Access: Published -// Description: Gives the ability to toggle updating this texture -// or not. This can be disabled to improve performance -// so that only the one that needs to be active is -// active. -//////////////////////////////////////////////////////////////////// +/** + * Gives the ability to toggle updating this texture or not. This can be + * disabled to improve performance so that only the one that needs to be + * active is active. + */ void WebBrowserTexture::set_update_active(bool active_flag){ _update_active = active_flag; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::get_update_active -// Access: Published -// Description: Gets whether or not this texture is updating -// itself every time it is rendered. -//////////////////////////////////////////////////////////////////// +/** + * Gets whether or not this texture is updating itself every time it is + * rendered. + */ bool WebBrowserTexture::get_update_active() const{ return _update_active; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::set_flip_texture_active -// Access: Published -// Description: This toggles on/off automatic flipping of the -// of the texture at a source level. Awesomium renders -// things that are flipped vertically. This enables -// automatic flipping of that. -// -// Since it is doing byte manipulation, this can get -// rather slow. Turning this on should be avoided. -// Instead, flipping should be taken care of via UV -// coordinates or shaders. -//////////////////////////////////////////////////////////////////// +/** + * This toggles on/off automatic flipping of the of the texture at a source + * level. Awesomium renders things that are flipped vertically. This enables + * automatic flipping of that. + * + * Since it is doing byte manipulation, this can get rather slow. Turning + * this on should be avoided. Instead, flipping should be taken care of via + * UV coordinates or shaders. + */ void WebBrowserTexture::set_flip_texture_active(bool active_flag){ _flip_texture_active = active_flag; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::get_flip_texture_active -// Access: Published -// Description: Returns whether automatic texture flipping is -// enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether automatic texture flipping is enabled. + */ bool WebBrowserTexture::get_flip_texture_active() const { return _flip_texture_active; } -//////////////////////////////////////////////////////////////////// -// Function: WebBrowserTexture::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to update the WebBrowserTexture. This -// method calls the render method of AwWebView but -// does not call the update method of AwWebCore. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to update the + * WebBrowserTexture. This method calls the render method of AwWebView but + * does not call the update method of AwWebCore. + */ bool WebBrowserTexture::cull_callback(CullTraverser *trav, const CullTraverserData &data) const{ - //see if we are in a state where udpates can happen. else just return + // see if we are in a state where udpates can happen. else just return if( !_update_active ) return true; if( _aw_web_view == NULL ) return true; - //do we even need to update? + // do we even need to update? if( !_aw_web_view->is_dirty() ) return true; - //see if we're the same size, if not we need to make sure this texture - //matches the webview + // see if we're the same size, if not we need to make sure this texture + // matches the webview if( _aw_web_view->get_width() != get_x_size() || _aw_web_view->get_height() != get_y_size() || get_texture_type() != TT_2d_texture){ - //these casts are so dirty especially when the method itself is - //labled as const. Really Texture::cull_callback should be not const - //first clean up + // these casts are so dirty especially when the method itself is + // labled as const. Really Texture::cull_callback should be not const + // first clean up ((WebBrowserTexture*)this)->clear_ram_mipmap_images(); ((WebBrowserTexture*)this)->clear_ram_image(); - //now set up the texture again + // now set up the texture again ((WebBrowserTexture*)this)->setup_2d_texture( _aw_web_view->get_width(), _aw_web_view->get_height(), T_unsigned_byte, F_rgba ); - //should be good to go at this point + // should be good to go at this point } - //get the pointer + // get the pointer PTA_uchar ram_image = ((WebBrowserTexture*)this)->modify_ram_image(); unsigned char* cp_data = ram_image.p(); - //render it + // render it _aw_web_view->render((void*)cp_data, get_x_size()*4, 4); if(_flip_texture_active){ - //flips the texture around... this is super slow. Really this should - //never be enabled. However beginners might find this useful + // flips the texture around... this is super slow. Really this should + // never be enabled. However beginners might find this useful size_t width = get_x_size(); size_t height = get_y_size(); for(size_t i=0; i < height/2; i++){ @@ -228,6 +189,6 @@ bool WebBrowserTexture::cull_callback(CullTraverser *trav, const CullTraverserDa } } } - //success + // success return true; -} \ No newline at end of file +} diff --git a/panda/src/awesomium/WebBrowserTexture.h b/panda/src/awesomium/WebBrowserTexture.h index 804da0b579..e9ae392d10 100644 --- a/panda/src/awesomium/WebBrowserTexture.h +++ b/panda/src/awesomium/WebBrowserTexture.h @@ -1,16 +1,15 @@ -// Filename: WebBrowserTexture.h -// Created by: Bei Yang (03Aug2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file WebBrowserTexture.h + * @author Bei Yang + * @date 2010-08-03 + */ #ifndef WebBrowserTexture_H #define WebBrowserTexture_H @@ -20,24 +19,21 @@ #include "awWebView.h" -//////////////////////////////////////////////////////////////////// -// Class : WebBrowserTexture -// Description : A Wrapper class for Awesomium webview. This -// implements most of Awesomium's features and -// updates on the cull_traverser callback much -// much like a movie texture. -// -// The use of class means that you will have to -// follow Awesomium license agreement give below -// http://www.khrona.com/products/awesomium/licensing/ -//////////////////////////////////////////////////////////////////// +/** + * A Wrapper class for Awesomium webview. This implements most of Awesomium's + * features and updates on the cull_traverser callback much much like a movie + * texture. + * + * The use of class means that you will have to follow Awesomium license + * agreement give below http://www.khrona.com/products/awesomium/licensing + */ class EXPCL_PANDAAWESOMIUM WebBrowserTexture : public Texture { protected: AwWebView* _aw_web_view; bool _update_active; bool _flip_texture_active; -//Constructors & Destructors ------------ +// Constructors & Destructors ------------ private: WebBrowserTexture(const WebBrowserTexture ©); PUBLISHED: @@ -45,7 +41,7 @@ PUBLISHED: virtual ~WebBrowserTexture(); -//methods -------------- +// methods -------------- protected: bool get_keep_ram_image() const; void do_reload_ram_image(); @@ -60,7 +56,7 @@ PUBLISHED: void set_flip_texture_active(bool active_flag); bool get_flip_texture_active() const; -//Type handles ---------------- +// Type handles ---------------- public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/awesomium/awWebCore.I b/panda/src/awesomium/awWebCore.I index 0fffe79b89..7829f6a370 100644 --- a/panda/src/awesomium/awWebCore.I +++ b/panda/src/awesomium/awWebCore.I @@ -1,17 +1,15 @@ -// Filename: awWebCore.I -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebCore.I + * @author rurbino + * @date 2009-10-12 + */ INLINE void AwWebCore:: setBaseDirectory(const std::string& baseDirectory) { @@ -48,5 +46,3 @@ INLINE void AwWebCore:: resume() { WebCore::resume(); } - - diff --git a/panda/src/awesomium/awWebCore.cxx b/panda/src/awesomium/awWebCore.cxx index 4a81a0b5e6..7b1e28f778 100644 --- a/panda/src/awesomium/awWebCore.cxx +++ b/panda/src/awesomium/awWebCore.cxx @@ -1,16 +1,15 @@ -// Filename: awWebCore.cxx -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebCore.cxx + * @author rurbino + * @date 2009-10-12 + */ #include "config_awesomium.h" #include "awWebCore.h" @@ -19,12 +18,12 @@ TypeHandle AwWebCore::_type_handle; AwWebCore:: -AwWebCore(AwWebCore::LogLevel level, bool enablePlugins , AwWebCore::PixelFormat pixelFormat) +AwWebCore(AwWebCore::LogLevel level, bool enablePlugins , AwWebCore::PixelFormat pixelFormat) #ifndef CPPPARSER : - WebCore(static_cast(level), enablePlugins, static_cast(pixelFormat)) + WebCore(static_cast(level), enablePlugins, static_cast(pixelFormat)) #endif - { + { awesomium_cat.info() << "constructing webcore\n"; } @@ -54,4 +53,3 @@ AwWebCore::PixelFormat AwWebCore:: getPixelFormat() const { return ( static_cast( WebCore::getPixelFormat()) ); } - diff --git a/panda/src/awesomium/awWebCore.h b/panda/src/awesomium/awWebCore.h index 354e9823a2..db3160bf21 100644 --- a/panda/src/awesomium/awWebCore.h +++ b/panda/src/awesomium/awWebCore.h @@ -1,16 +1,16 @@ -// Filename: awWebCore.h -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebCore.h + * @author rurbino + * @date 2009-10-12 + */ + #ifndef AWWEBCORE_H #define AWWEBCORE_H @@ -21,10 +21,9 @@ #include "awesomium_includes.h" class AwWebView; -//////////////////////////////////////////////////////////////////// -// Class : AwWebCore -// Description : Thin wrappings arround WebCore.h -//////////////////////////////////////////////////////////////////// +/** + * Thin wrappings arround WebCore.h + */ class EXPCL_PANDAAWESOMIUM AwWebCore : public TypedReferenceCount, public Awesomium::WebCore { PUBLISHED: /** diff --git a/panda/src/awesomium/awWebView.I b/panda/src/awesomium/awWebView.I index 8bee4af5db..c7ecf913e7 100644 --- a/panda/src/awesomium/awWebView.I +++ b/panda/src/awesomium/awWebView.I @@ -1,16 +1,15 @@ -// Filename: awWebView.I -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebView.I + * @author rurbino + * @date 2009-10-12 + */ INLINE void AwWebView:: destroy(void) @@ -81,4 +80,3 @@ INLINE void AwWebView:: injectKeyEvent(bool press, int modifiers, int windowsCode, int nativeCode) { _myWebView->injectKeyEvent(press, modifiers, windowsCode, nativeCode); } - diff --git a/panda/src/awesomium/awWebView.cxx b/panda/src/awesomium/awWebView.cxx index 1b095cecd5..5ef0b95181 100644 --- a/panda/src/awesomium/awWebView.cxx +++ b/panda/src/awesomium/awWebView.cxx @@ -1,16 +1,15 @@ -// Filename: awWebView.cxx -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebView.cxx + * @author rurbino + * @date 2009-10-12 + */ #include "config_awesomium.h" #include "awWebView.h" @@ -18,7 +17,7 @@ TypeHandle AwWebView::_type_handle; AwWebView:: -AwWebView(Awesomium::WebView * webViewPtr) { +AwWebView(Awesomium::WebView * webViewPtr) { _myWebView = webViewPtr; } @@ -53,7 +52,7 @@ void AwWebView:: render(size_t destination, int destRowSpan, int destDepth, AwWebView::Rect * renderedRect) { if (renderedRect) { Awesomium::Rect rect(renderedRect->x, renderedRect->y, renderedRect->width, renderedRect->height); - _myWebView->Awesomium::WebView::render( reinterpret_cast(destination), destRowSpan, destDepth, &rect); + _myWebView->Awesomium::WebView::render( reinterpret_cast(destination), destRowSpan, destDepth, &rect); } else { @@ -70,7 +69,6 @@ injectMouseDown(AwWebView::MouseButton button) { void AwWebView:: injectMouseMove(int x, int y) { - //awesomium_cat.debug() <<"got mouse move " << x << " " << y << "\n"; + // awesomium_cat.debug() <<"got mouse move " << x << " " << y << "\n"; _myWebView->injectMouseMove(x,y); } - diff --git a/panda/src/awesomium/awWebView.h b/panda/src/awesomium/awWebView.h index dd48d1bbb9..5a5550c4ee 100644 --- a/panda/src/awesomium/awWebView.h +++ b/panda/src/awesomium/awWebView.h @@ -1,16 +1,16 @@ -// Filename: awWebView.h -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebView.h + * @author rurbino + * @date 2009-10-12 + */ + #ifndef AWWEBVIEW_H #define AWWEBVIEW_H @@ -22,10 +22,9 @@ class WebViewListener; -//////////////////////////////////////////////////////////////////// -// Class : AwWebView -// Description : Thin bindings, wraps a WebView * returned from WebCore.createWebView -//////////////////////////////////////////////////////////////////// +/** + * Thin bindings, wraps a WebView * returned from WebCore.createWebView + */ class EXPCL_PANDAAWESOMIUM AwWebView : public TypedReferenceCount{ PUBLISHED: @@ -62,18 +61,22 @@ PUBLISHED: INLINE Awesomium::WebViewListener* getListener(); - // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version + // VC7 linker doesn't like wstring from VS2008, hence using the all regular + // string version void loadURL2(const string& url, const string& frameName ="", const string& username="" , const string& password=""); - // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version + // VC7 linker doesn't like wstring from VS2008, hence using the all regular + // string version void loadHTML2(const std::string& html, const std::string& frameName = ""); - // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version + // VC7 linker doesn't like wstring from VS2008, hence using the all regular + // string version void loadFile2(const std::string& file, const std::string& frameName = "" ); INLINE void goToHistoryOffset(int offset); - // VC7 linker doesn't like wstring from VS2008, hence using the all regular string version + // VC7 linker doesn't like wstring from VS2008, hence using the all regular + // string version INLINE void executeJavascript2(const std::string& javascript, const std::string& frameName = "" ); INLINE Awesomium::FutureJSValue executeJavascriptWithResult2(const std::string& javascript, const std::string& frameName = ""); diff --git a/panda/src/awesomium/awWebViewListener.I b/panda/src/awesomium/awWebViewListener.I index f342727802..10b7745aef 100644 --- a/panda/src/awesomium/awWebViewListener.I +++ b/panda/src/awesomium/awWebViewListener.I @@ -1,13 +1,12 @@ -// Filename: awWebViewListener.I -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebViewListener.I + * @author rurbino + * @date 2009-10-12 + */ diff --git a/panda/src/awesomium/awWebViewListener.cxx b/panda/src/awesomium/awWebViewListener.cxx index 9f0456af99..0af38b5da8 100644 --- a/panda/src/awesomium/awWebViewListener.cxx +++ b/panda/src/awesomium/awWebViewListener.cxx @@ -1,16 +1,15 @@ -// Filename: awWebViewListener.cxx -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebViewListener.cxx + * @author rurbino + * @date 2009-10-12 + */ #include "config_awesomium.h" #include "awWebViewListener.h" diff --git a/panda/src/awesomium/awWebViewListener.h b/panda/src/awesomium/awWebViewListener.h index 81c137d36f..924754762d 100644 --- a/panda/src/awesomium/awWebViewListener.h +++ b/panda/src/awesomium/awWebViewListener.h @@ -1,16 +1,16 @@ -// Filename: awWebViewListener.h -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awWebViewListener.h + * @author rurbino + * @date 2009-10-12 + */ + #ifndef AWWEBVIEWLISTENER_H #define AWWEBVIEWLISTENER_H @@ -20,19 +20,18 @@ #include "awesomium_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : AwWebViewListener -// Description : Thin bindings, wraps a WebViewListener -//////////////////////////////////////////////////////////////////// +/** + * Thin bindings, wraps a WebViewListener + */ class EXPCL_PANDAAWESOMIUM AwWebViewListener : public TypedReferenceCount, public Awesomium::WebCore { PUBLISHED: PUBLISHED: AwWebViewListener(); - + virtual ~AwWebViewListener() {} - + /** * This event is fired when a WebView begins navigating to a new URL. * @@ -68,7 +67,7 @@ PUBLISHED: * @param args The arguments passed to the callback. */ void onCallback(const std::string& name, const Awesomium::JSArguments& args); - + /** * This event is fired when a page title is received. * @@ -93,7 +92,7 @@ PUBLISHED: void onChangeKeyboardFocus(bool isFocused) ; /** - * This event is fired when the target URL has changed. This is usually the result of + * This event is fired when the target URL has changed. This is usually the result of * hovering over a link on the page. * * @param url The updated target URL (or empty if the target URL is cleared). diff --git a/panda/src/awesomium/awesomium_includes.h b/panda/src/awesomium/awesomium_includes.h index f103d39566..f892ac06d5 100644 --- a/panda/src/awesomium/awesomium_includes.h +++ b/panda/src/awesomium/awesomium_includes.h @@ -1,16 +1,15 @@ -// Filename: awesomium_includes.h -// Created by: rurbino (08Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file awesomium_includes.h + * @author rurbino + * @date 2010-10-08 + */ #ifndef _AWESOMIUM_INCLUDES_H_ #define _AWESOMIUM_INCLUDES_H_ diff --git a/panda/src/awesomium/config_awesomium.cxx b/panda/src/awesomium/config_awesomium.cxx index 892a351327..4462dce983 100644 --- a/panda/src/awesomium/config_awesomium.cxx +++ b/panda/src/awesomium/config_awesomium.cxx @@ -1,16 +1,15 @@ -// Filename: config_awesomium.cxx -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source cawesomium in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_awesomium.cxx + * @author rurbino + * @date 2009-10-12 + */ #include "config_awesomium.h" #include "awWebCore.h" @@ -27,14 +26,12 @@ ConfigureFn(config_awesomium) { init_libawesomium(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libawesomium -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libawesomium() { static bool initialized = false; @@ -42,7 +39,7 @@ init_libawesomium() { return; } initialized = true; - + AwWebCore::init_type(); AwWebView::init_type(); AwWebViewListener::init_type(); diff --git a/panda/src/awesomium/config_awesomium.h b/panda/src/awesomium/config_awesomium.h index ea0a02a9df..e02f047e16 100644 --- a/panda/src/awesomium/config_awesomium.h +++ b/panda/src/awesomium/config_awesomium.h @@ -1,16 +1,15 @@ -// Filename: config_awesomium.h -// Created by: rurbino (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_awesomium.h + * @author rurbino + * @date 2009-10-12 + */ #ifndef CONFIG_AWESOMIUM_H #define CONFIG_AWESOMIUM_H diff --git a/panda/src/bullet/bulletAllHitsRayResult.I b/panda/src/bullet/bulletAllHitsRayResult.I index 96907e9284..d2da8644b5 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.I +++ b/panda/src/bullet/bulletAllHitsRayResult.I @@ -1,24 +1,20 @@ -// Filename: bulletAllHitsRayResult.I -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletAllHitsRayResult.I + * @author enn0x + * @date 2010-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::empty -// Access: Published -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletAllHitsRayResult BulletAllHitsRayResult:: empty() { @@ -28,15 +24,12 @@ empty() { return BulletAllHitsRayResult(from, to, CollideMask::all_on()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::empty -// Access: Published -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletRayHit BulletRayHit:: empty() { return BulletRayHit(); } - diff --git a/panda/src/bullet/bulletAllHitsRayResult.cxx b/panda/src/bullet/bulletAllHitsRayResult.cxx index 953390820e..12c6abacc4 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.cxx +++ b/panda/src/bullet/bulletAllHitsRayResult.cxx @@ -1,35 +1,30 @@ -// Filename: bulletAllHitsRayResult.cxx -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletAllHitsRayResult.cxx + * @author enn0x + * @date 2010-02-21 + */ #include "bulletAllHitsRayResult.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletAllHitsRayResult:: -BulletAllHitsRayResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) +BulletAllHitsRayResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) : btCollisionWorld::AllHitsRayResultCallback(from_pos, to_pos), _mask(mask) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::needsCollision -// Access: Protected -// Description: Override default implementation. -//////////////////////////////////////////////////////////////////// +/** + * Override default implementation. + */ bool BulletAllHitsRayResult:: needsCollision(btBroadphaseProxy* proxy0) const { @@ -40,15 +35,13 @@ needsCollision(btBroadphaseProxy* proxy0) const { return (_mask & mask0) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::addSingleResult -// Access: Protected -// Description: Override default implementation. -//////////////////////////////////////////////////////////////////// +/** + * Override default implementation. + */ btScalar BulletAllHitsRayResult:: addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace) { - // Store part/index information + // Store partindex information if (rayResult.m_localShapeInfo) { _shapePart.push_back(rayResult.m_localShapeInfo->m_shapePart); _triangleIndex.push_back(rayResult.m_localShapeInfo->m_triangleIndex); @@ -62,66 +55,54 @@ addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldS return btCollisionWorld::AllHitsRayResultCallback::addSingleResult(rayResult, normalInWorldSpace); }; -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::get_from_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletAllHitsRayResult:: get_from_pos() const { return btVector3_to_LPoint3(m_rayFromWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::get_to_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletAllHitsRayResult:: get_to_pos() const { return btVector3_to_LPoint3(m_rayToWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::has_hits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletAllHitsRayResult:: has_hits() const { return hasHit(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::get_closest_hit_fraction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletAllHitsRayResult:: get_closest_hit_fraction() const { return (PN_stdfloat)m_closestHitFraction; } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::get_num_hits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletAllHitsRayResult:: get_num_hits() const { return m_collisionObjects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::get_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const BulletRayHit BulletAllHitsRayResult:: get_hit(int idx) const { @@ -140,69 +121,56 @@ get_hit(int idx) const { return hit; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_hit_fraction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletRayHit:: get_hit_fraction() const { return (PN_stdfloat)_fraction; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *BulletRayHit:: get_node() const { return (_object) ? (PandaNode *)_object->getUserPointer() : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_hit_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletRayHit:: get_hit_pos() const { return btVector3_to_LPoint3(_pos); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_hit_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRayHit:: get_hit_normal() const { return btVector3_to_LVector3(_normal); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_shape_part -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletRayHit:: get_shape_part() const { return _shapePart; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRayHit::get_triangle_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletRayHit:: get_triangle_index() const { return _triangleIndex; } - diff --git a/panda/src/bullet/bulletAllHitsRayResult.h b/panda/src/bullet/bulletAllHitsRayResult.h index 6825e0ff68..c5ff637ac9 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.h +++ b/panda/src/bullet/bulletAllHitsRayResult.h @@ -1,16 +1,15 @@ -// Filename: bulletAllHitsRayResult.h -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletAllHitsRayResult.h + * @author enn0x + * @date 2010-02-21 + */ #ifndef __BULLET_ALL_HITS_RAY_RESULT_H__ #define __BULLET_ALL_HITS_RAY_RESULT_H__ @@ -24,10 +23,9 @@ #include "pandaNode.h" #include "collideMask.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletRayHit -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletRayHit { PUBLISHED: @@ -42,7 +40,7 @@ PUBLISHED: int get_triangle_index() const; private: - const btCollisionObject *_object; + const btCollisionObject *_object; btVector3 _normal; btVector3 _pos; btScalar _fraction; @@ -53,10 +51,9 @@ private: friend struct BulletAllHitsRayResult; }; -//////////////////////////////////////////////////////////////////// -// Class : BulletAllHitsRayResult -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletAllHitsRayResult : public btCollisionWorld::AllHitsRayResultCallback { PUBLISHED: diff --git a/panda/src/bullet/bulletBaseCharacterControllerNode.I b/panda/src/bullet/bulletBaseCharacterControllerNode.I index 6bb8200b0c..597ca16330 100644 --- a/panda/src/bullet/bulletBaseCharacterControllerNode.I +++ b/panda/src/bullet/bulletBaseCharacterControllerNode.I @@ -1,15 +1,12 @@ -// Filename: bulletBaseCharacterControllerNode.I -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBaseCharacterControllerNode.I + * @author enn0x + * @date 2010-11-21 + */ diff --git a/panda/src/bullet/bulletBaseCharacterControllerNode.cxx b/panda/src/bullet/bulletBaseCharacterControllerNode.cxx index b2dfbf8a1c..1ce7b28d97 100644 --- a/panda/src/bullet/bulletBaseCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletBaseCharacterControllerNode.cxx @@ -1,26 +1,23 @@ -// Filename: bulletBaseCharacterControllerNode.cxx -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBaseCharacterControllerNode.cxx + * @author enn0x + * @date 2010-11-21 + */ #include "bulletBaseCharacterControllerNode.h" TypeHandle BulletBaseCharacterControllerNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletBaseCharacterControllerNode:: BulletBaseCharacterControllerNode(const char *name) : PandaNode(name) { @@ -28,107 +25,82 @@ BulletBaseCharacterControllerNode(const char *name) : PandaNode(name) { set_into_collide_mask(CollideMask::all_on()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::get_legal_collide_mask -// Access: Public, Virtual -// Description: Returns the subset of CollideMask bits that may be -// set for this particular type of PandaNode. For -// CharacterControllerNodes this returns all bits on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of CollideMask bits that may be set for this particular + * type of PandaNode. For CharacterControllerNodes this returns all bits on. + */ CollideMask BulletBaseCharacterControllerNode:: get_legal_collide_mask() const { return CollideMask::all_on(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool BulletBaseCharacterControllerNode:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_modify_transform -// Access: Public, Virtual -// Description: Returns true if it is safe to automatically adjust -// the transform on this kind of node. Usually, this is -// only a bad idea if the user expects to find a -// particular transform on the node. -// -// ModelNodes with the preserve_transform flag set are -// presently the only kinds of nodes that should not -// have their transform even adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is safe to automatically adjust the transform on this + * kind of node. Usually, this is only a bad idea if the user expects to find + * a particular transform on the node. + * + * ModelNodes with the preserve_transform flag set are presently the only + * kinds of nodes that should not have their transform even adjusted. + */ bool BulletBaseCharacterControllerNode:: safe_to_modify_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool BulletBaseCharacterControllerNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool BulletBaseCharacterControllerNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_flatten_below -// Access: Public, Virtual -// Description: Returns true if a flatten operation may safely -// continue past this node, or false if nodes below this -// node may not be molested. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a flatten operation may safely continue past this node, or + * false if nodes below this node may not be molested. + */ bool BulletBaseCharacterControllerNode:: safe_to_flatten_below() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBaseCharacterControllerNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a Character. + */ bool BulletBaseCharacterControllerNode:: safe_to_transform() const { return false; } - diff --git a/panda/src/bullet/bulletBaseCharacterControllerNode.h b/panda/src/bullet/bulletBaseCharacterControllerNode.h index 44b452dce9..b09b26db74 100644 --- a/panda/src/bullet/bulletBaseCharacterControllerNode.h +++ b/panda/src/bullet/bulletBaseCharacterControllerNode.h @@ -1,16 +1,15 @@ -// Filename: bulletBaseCharacterControllerNode.h -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBaseCharacterControllerNode.h + * @author enn0x + * @date 2010-11-21 + */ #ifndef __BULLET_BASE_CHARACTER_CONTROLLER_NODE_H__ #define __BULLET_BASE_CHARACTER_CONTROLLER_NODE_H__ @@ -24,10 +23,9 @@ #include "pandaNode.h" #include "collideMask.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletBaseCharacterControllerNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletBaseCharacterControllerNode : public PandaNode { PUBLISHED: @@ -49,14 +47,13 @@ public: virtual void sync_p2b(PN_stdfloat dt, int num_substeps) = 0; virtual void sync_b2p() = 0; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PandaNode::init_type(); - register_type(_type_handle, "BulletBaseCharacterControllerNode", + register_type(_type_handle, "BulletBaseCharacterControllerNode", PandaNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -74,4 +71,3 @@ private: #include "bulletBaseCharacterControllerNode.I" #endif // __BULLET_BASE_CHARACTER_CONTROLLER_NODE_H__ - diff --git a/panda/src/bullet/bulletBodyNode.I b/panda/src/bullet/bulletBodyNode.I index 89e3988bd2..01e62e8bd6 100644 --- a/panda/src/bullet/bulletBodyNode.I +++ b/panda/src/bullet/bulletBodyNode.I @@ -1,38 +1,32 @@ -// Filename: bulletBodyNode.I -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBodyNode.I + * @author enn0x + * @date 2010-11-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletBodyNode:: ~BulletBodyNode() { if (_shape && ( - _shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE || + _shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE || _shape->getShapeType() == EMPTY_SHAPE_PROXYTYPE)) { delete _shape; } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_into_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_into_collide_mask(CollideMask mask) { @@ -54,55 +48,45 @@ set_into_collide_mask(CollideMask mask) { */ } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::notify_collisions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: notify_collisions(bool value) { set_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK, value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::notifies_collisions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: notifies_collisions() const { return get_collision_flag(btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_collision_response -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_collision_response(bool value) { set_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE, !value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_collision_response -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: get_collision_response() const { return !get_collision_flag(btCollisionObject::CF_NO_CONTACT_RESPONSE); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_collision_flag -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_collision_flag(int flag, bool value) { @@ -118,99 +102,81 @@ set_collision_flag(int flag, bool value) { get_object()->setCollisionFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_collision_flag -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: get_collision_flag(int flag) const { return (get_object()->getCollisionFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_static -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: is_static() const { return get_object()->isStaticObject(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_kinematic -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: is_kinematic() const { return get_object()->isKinematicObject(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_static -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_static(bool value) { set_collision_flag(btCollisionObject::CF_STATIC_OBJECT, value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_kinematic -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_kinematic(bool value) { set_collision_flag(btCollisionObject::CF_KINEMATIC_OBJECT, value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletBodyNode:: get_restitution() const { return get_object()->getRestitution(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_restitution(PN_stdfloat restitution) { return get_object()->setRestitution(restitution); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletBodyNode:: get_friction() const { return get_object()->getFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_friction(PN_stdfloat friction) { @@ -218,22 +184,18 @@ set_friction(PN_stdfloat friction) { } #if BT_BULLET_VERSION >= 281 -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_rolling_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletBodyNode:: get_rolling_friction() const { return get_object()->getRollingFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_rolling_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBodyNode:: set_rolling_friction(PN_stdfloat friction) { @@ -241,33 +203,27 @@ set_rolling_friction(PN_stdfloat friction) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::has_anisotropic_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletBodyNode:: has_anisotropic_friction() const { return get_object()->hasAnisotropicFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_num_shapes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletBodyNode:: get_num_shapes() const { return _shapes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletShape *BulletBodyNode:: get_shape(int idx) const { @@ -275,29 +231,22 @@ get_shape(int idx) const { return _shapes[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_debug_enabled -// Access: Published -// Description: Enables or disables the debug visualisation for -// this collision object. By default the debug -// visualisation is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables the debug visualisation for this collision object. By + * default the debug visualisation is enabled. + */ INLINE void BulletBodyNode:: set_debug_enabled(const bool enabled) { set_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT, !enabled); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_debug_enabled -// Access: Published -// Description: Returns TRUE if the debug visualisation is enabled -// for this collision object, and FALSE if the debug -// visualisation is disabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the debug visualisation is enabled for this collision + * object, and FALSE if the debug visualisation is disabled. + */ INLINE bool BulletBodyNode:: is_debug_enabled() const { return !get_collision_flag(btCollisionObject::CF_DISABLE_VISUALIZE_OBJECT); } - diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 12e6bb96cd..e8dbe968f2 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -1,16 +1,15 @@ -// Filename: bulletBodyNode.cxx -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBodyNode.cxx + * @author enn0x + * @date 2010-11-19 + */ #include "bulletBodyNode.h" #include "bulletShape.h" @@ -24,11 +23,9 @@ TypeHandle BulletBodyNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletBodyNode:: BulletBodyNode(const char *name) : PandaNode(name) { @@ -39,115 +36,89 @@ BulletBodyNode(const char *name) : PandaNode(name) { set_into_collide_mask(CollideMask::all_on()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_legal_collide_mask -// Access: Public, Virtual -// Description: Returns the subset of CollideMask bits that may be -// set for this particular type of PandaNode. For -// BodyNodes this returns all bits on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of CollideMask bits that may be set for this particular + * type of PandaNode. For BodyNodes this returns all bits on. + */ CollideMask BulletBodyNode:: get_legal_collide_mask() const { return CollideMask::all_on(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool BulletBodyNode:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a Character. + */ bool BulletBodyNode:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_modify_transform -// Access: Public, Virtual -// Description: Returns true if it is safe to automatically adjust -// the transform on this kind of node. Usually, this is -// only a bad idea if the user expects to find a -// particular transform on the node. -// -// ModelNodes with the preserve_transform flag set are -// presently the only kinds of nodes that should not -// have their transform even adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is safe to automatically adjust the transform on this + * kind of node. Usually, this is only a bad idea if the user expects to find + * a particular transform on the node. + * + * ModelNodes with the preserve_transform flag set are presently the only + * kinds of nodes that should not have their transform even adjusted. + */ bool BulletBodyNode:: safe_to_modify_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool BulletBodyNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool BulletBodyNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::safe_to_flatten_below -// Access: Public, Virtual -// Description: Returns true if a flatten operation may safely -// continue past this node, or false if nodes below this -// node may not be molested. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a flatten operation may safely continue past this node, or + * false if nodes below this node may not be molested. + */ bool BulletBodyNode:: safe_to_flatten_below() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: output(ostream &out) const { @@ -161,11 +132,9 @@ output(ostream &out) const { if (is_kinematic()) out << " kinematic"; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::add_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: add_shape(BulletShape *bullet_shape, const TransformState *ts) { @@ -196,13 +165,13 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { if (ts->is_identity()) { // After adding the shape we will have one shape, but with transform. - // We need to wrap the shape within a compound shape, in oder to - // be able to set the local transform. + // We need to wrap the shape within a compound shape, in oder to be able + // to set the local transform. next = shape; } else { // After adding the shape we will have a total of one shape, without - // local transform. We can set the shape directly. + // local transform. We can set the shape directly. next = new btCompoundShape(); ((btCompoundShape *)next)->addChildShape(trans, shape); } @@ -214,16 +183,16 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { } else if (_shapes.size() == 1) { if (previous->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) { - // We have one shape, and add another shape. The previous shape is - // already a compound shape. So we just need to add the second shape - // to the compound shape. + // We have one shape, and add another shape. The previous shape is + // already a compound shape. So we just need to add the second shape to + // the compound shape. next = previous; ((btCompoundShape *)next)->addChildShape(trans, shape); } else { - // We have one shape which is NOT a compound shape, and want to add - // a second shape. We need to wrap both shapes within a compound shape. + // We have one shape which is NOT a compound shape, and want to add a + // second shape. We need to wrap both shapes within a compound shape. next = new btCompoundShape(); btTransform previous_trans = btTransform::getIdentity(); @@ -235,9 +204,9 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { } } else { - // We already have two or more shapes, and want to add another. So we - // already have a compound shape as wrapper, and just need to add the - // new shape to the compound. + // We already have two or more shapes, and want to add another. So we + // already have a compound shape as wrapper, and just need to add the new + // shape to the compound. nassertv(previous->getShapeType() == COMPOUND_SHAPE_PROXYTYPE); next = previous; @@ -252,11 +221,9 @@ add_shape(BulletShape *bullet_shape, const TransformState *ts) { shape_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::remove_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: remove_shape(BulletShape *shape) { @@ -283,7 +250,7 @@ remove_shape(BulletShape *shape) { get_object()->setCollisionShape(next); _shape = next; - // The previous shape might be a compound. Then delete it. + // The previous shape might be a compound. Then delete it. if (previous->getShapeType() == COMPOUND_SHAPE_PROXYTYPE) { delete previous; } @@ -297,8 +264,8 @@ remove_shape(BulletShape *shape) { nassertv(compound->getNumChildShapes() == 1); - // The compound is no longer required if the remaining shape - // has no transform + // The compound is no longer required if the remaining shape has no + // transform btTransform trans = compound->getChildTransform(0); if (is_identity(trans)) { next = compound->getChildShape(0); @@ -321,12 +288,9 @@ remove_shape(BulletShape *shape) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_identity -// Access: Private -// Description: Returns TRUE if the transform is an identity -// transform, otherwise FALSE. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the transform is an identity transform, otherwise FALSE. + */ bool BulletBodyNode:: is_identity(btTransform &trans) { @@ -336,11 +300,9 @@ is_identity(btTransform &trans) { && trans.getRotation().getAxis() == null); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_shape_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletBodyNode:: get_shape_pos(int idx) const { @@ -357,21 +319,17 @@ get_shape_pos(int idx) const { return LPoint3::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_shape_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4 BulletBodyNode:: get_shape_mat(int idx) const { return get_shape_transform(idx)->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_shape_transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(TransformState) BulletBodyNode:: get_shape_transform(int idx) const { nassertr(idx >= 0 && idx < (int)_shapes.size(), TransformState::make_identity()); @@ -383,10 +341,9 @@ get_shape_transform(int idx) const { btTransform trans = compound->getChildTransform(idx); return btTrans_to_TransformState(trans); - // The above code assumes that shape's index in _shapes member - // is the same as the shapes index within the compound. If it - // turns out that this is not always true we could use the - // following code: + // The above code assumes that shape's index in _shapes member is the same + // as the shapes index within the compound. If it turns out that this is + // not always true we could use the following code: /* btCollisionShape *shape = get_shape(idx)->ptr(); for (int i=0; igetNumChildShapes(); i++) { @@ -401,57 +358,46 @@ get_shape_transform(int idx) const { return TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::shape_changed -// Access: Published -// Description: Hook which will be called whenever the total shape -// of a body changed. Used for example to update -// the mass properties (inertia) of a rigid body. -// The default implementation does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Hook which will be called whenever the total shape of a body changed. Used + * for example to update the mass properties (inertia) of a rigid body. The + * default implementation does nothing. + */ void BulletBodyNode:: shape_changed() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_deactivation_time -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: set_deactivation_time(PN_stdfloat dt) { get_object()->setDeactivationTime(dt); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_deactivation_time -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletBodyNode:: get_deactivation_time() const { return get_object()->getDeactivationTime(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_active -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletBodyNode:: is_active() const { return get_object()->isActive(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_active -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: set_active(bool active, bool force) { @@ -468,13 +414,10 @@ set_active(bool active, bool force) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_deactivation_enabled -// Access: Published -// Description: If true, this object will be deactivated after a -// certain amount of time has passed without movement. -// If false, the object will always remain active. -//////////////////////////////////////////////////////////////////// +/** + * If true, this object will be deactivated after a certain amount of time has + * passed without movement. If false, the object will always remain active. + */ void BulletBodyNode:: set_deactivation_enabled(bool enabled) { @@ -489,22 +432,18 @@ set_deactivation_enabled(bool enabled) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::is_deactivation_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletBodyNode:: is_deactivation_enabled() const { return (get_object()->getActivationState() != DISABLE_DEACTIVATION); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::check_collision_with -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletBodyNode:: check_collision_with(PandaNode *node) { @@ -518,22 +457,18 @@ check_collision_with(PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_anisotropic_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 BulletBodyNode:: get_anisotropic_friction() const { return btVector3_to_LVecBase3(get_object()->getAnisotropicFriction()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_anisotropic_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: set_anisotropic_friction(const LVecBase3 &friction) { @@ -541,89 +476,73 @@ set_anisotropic_friction(const LVecBase3 &friction) { get_object()->setAnisotropicFriction(LVecBase3_to_btVector3(friction)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::has_contact_response -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletBodyNode:: has_contact_response() const { return get_object()->hasContactResponse(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_contact_processing_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletBodyNode:: get_contact_processing_threshold() const { return get_object()->getContactProcessingThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_contact_processing_threshold -// Access: Published -// Description: The constraint solver can discard solving -// contacts, if the distance is above this threshold. -//////////////////////////////////////////////////////////////////// +/** + * The constraint solver can discard solving contacts, if the distance is + * above this threshold. + */ void BulletBodyNode:: set_contact_processing_threshold(PN_stdfloat threshold) { get_object()->setContactProcessingThreshold(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_ccd_swept_sphere_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletBodyNode:: get_ccd_swept_sphere_radius() const { return get_object()->getCcdSweptSphereRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_ccd_swept_sphere_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: set_ccd_swept_sphere_radius(PN_stdfloat radius) { return get_object()->setCcdSweptSphereRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_ccd_motion_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletBodyNode:: get_ccd_motion_threshold() const { return get_object()->getCcdMotionThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_ccd_motion_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: set_ccd_motion_threshold(PN_stdfloat threshold) { return get_object()->setCcdMotionThreshold(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::add_shapes_from_collision_solids -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletBodyNode:: add_shapes_from_collision_solids(CollisionNode *cnode) { @@ -679,27 +598,20 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::set_transform_dirty -// Access: Published -// Description: This method enforces an update of the Bullet -// transform, that is copies the scene graph transform -// to the Bullet transform. -// This is achieved by alling the protected PandaNode -// hook 'transform_changed'. -//////////////////////////////////////////////////////////////////// +/** + * This method enforces an update of the Bullet transform, that is copies the + * scene graph transform to the Bullet transform. This is achieved by alling + * the protected PandaNode hook 'transform_changed'. + */ void BulletBodyNode:: set_transform_dirty() { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::get_shape_bounds -// Access: Published -// Description: Returns the current bounds of all collision shapes -// owned by this body. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current bounds of all collision shapes owned by this body. + */ BoundingSphere BulletBodyNode:: get_shape_bounds() const { @@ -726,12 +638,10 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << return bounds; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletBodyNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -741,10 +651,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(notifies_collisions()); dg.add_bool(get_collision_response()); dg.add_stdfloat(get_contact_processing_threshold()); - //dg.add_bool(is_active()); + // dg.add_bool(is_active()); dg.add_stdfloat(get_deactivation_time()); dg.add_bool(is_deactivation_enabled()); - //dg.add_bool(is_debug_enabled()); + // dg.add_bool(is_debug_enabled()); dg.add_stdfloat(get_restitution()); dg.add_stdfloat(get_friction()); #if BT_BULLET_VERSION >= 281 @@ -770,13 +680,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int BulletBodyNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -793,29 +700,22 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool BulletBodyNode:: require_fully_complete() const { // We require the shape pointers to be complete before we add them. return true; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBodyNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletBodyNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletBodyNode. + */ void BulletBodyNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); @@ -825,7 +725,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { notify_collisions(scan.get_bool()); set_collision_response(scan.get_bool()); set_contact_processing_threshold(scan.get_stdfloat()); - //set_active(scan.get_bool(), true); + // set_active(scan.get_bool(), true); set_deactivation_time(scan.get_stdfloat()); set_deactivation_enabled(scan.get_bool()); set_restitution(scan.get_stdfloat()); diff --git a/panda/src/bullet/bulletBodyNode.h b/panda/src/bullet/bulletBodyNode.h index a2c7fc2e67..42f43cfd6a 100644 --- a/panda/src/bullet/bulletBodyNode.h +++ b/panda/src/bullet/bulletBodyNode.h @@ -1,16 +1,15 @@ -// Filename: bulletBodyNode.h -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBodyNode.h + * @author enn0x + * @date 2010-11-19 + */ #ifndef __BULLET_BODY_NODE_H__ #define __BULLET_BODY_NODE_H__ @@ -28,10 +27,9 @@ class BulletShape; -//////////////////////////////////////////////////////////////////// -// Class : BulletBodyNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletBodyNode : public PandaNode { protected: BulletBodyNode(const char *name); @@ -159,7 +157,7 @@ public: } static void init_type() { PandaNode::init_type(); - register_type(_type_handle, "BulletBodyNode", + register_type(_type_handle, "BulletBodyNode", PandaNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -177,4 +175,3 @@ private: #include "bulletBodyNode.I" #endif // __BULLET_BODY_NODE_H__ - diff --git a/panda/src/bullet/bulletBoxShape.I b/panda/src/bullet/bulletBoxShape.I index d4dd93669e..1051a4018f 100644 --- a/panda/src/bullet/bulletBoxShape.I +++ b/panda/src/bullet/bulletBoxShape.I @@ -1,46 +1,37 @@ -// Filename: bulletBoxShape.I -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBoxShape.I + * @author enn0x + * @date 2010-01-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletBoxShape:: ~BulletBoxShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletBoxShape:: BulletBoxShape(const BulletBoxShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletBoxShape:: operator = (const BulletBoxShape ©) { _shape = copy._shape; } - diff --git a/panda/src/bullet/bulletBoxShape.cxx b/panda/src/bullet/bulletBoxShape.cxx index 1d1996521a..7d52cf2513 100644 --- a/panda/src/bullet/bulletBoxShape.cxx +++ b/panda/src/bullet/bulletBoxShape.cxx @@ -1,27 +1,24 @@ -// Filename: bulletBoxShape.cxx -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBoxShape.cxx + * @author enn0x + * @date 2010-01-24 + */ #include "bulletBoxShape.h" #include "bullet_utils.h" TypeHandle BulletBoxShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletBoxShape:: BulletBoxShape(const LVecBase3 &halfExtents) { @@ -31,44 +28,36 @@ BulletBoxShape(const LVecBase3 &halfExtents) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletBoxShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::get_half_extents_without_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 BulletBoxShape:: get_half_extents_without_margin() const { return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::get_half_extents_with_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 BulletBoxShape:: get_half_extents_with_margin() const { return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::make_from_solid -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletBoxShape *BulletBoxShape:: make_from_solid(const CollisionBox *solid) { @@ -82,37 +71,29 @@ make_from_solid(const CollisionBox *solid) { return new BulletBoxShape(extents); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletShape. + */ void BulletBoxShape:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletBoxShape:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_margin()); get_half_extents_with_margin().write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletBoxShape:: make_from_bam(const FactoryParams ¶ms) { BulletBoxShape *param = new BulletBoxShape; @@ -125,13 +106,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletBoxShape::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletShape. + */ void BulletBoxShape:: fillin(DatagramIterator &scan, BamReader *manager) { nassertv(_shape == NULL); diff --git a/panda/src/bullet/bulletBoxShape.h b/panda/src/bullet/bulletBoxShape.h index 4485689eeb..82b1f10412 100644 --- a/panda/src/bullet/bulletBoxShape.h +++ b/panda/src/bullet/bulletBoxShape.h @@ -1,16 +1,15 @@ -// Filename: bulletBoxShape.h -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletBoxShape.h + * @author enn0x + * @date 2010-01-24 + */ #ifndef __BULLET_BOX_SHAPE_H__ #define __BULLET_BOX_SHAPE_H__ @@ -24,10 +23,9 @@ #include "collisionBox.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletBoxShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletBoxShape : public BulletShape { private: // Only used by make_from_bam @@ -64,7 +62,7 @@ public: } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletBoxShape", + register_type(_type_handle, "BulletBoxShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletCapsuleShape.I b/panda/src/bullet/bulletCapsuleShape.I index a2f6974b9e..24a82dbdbf 100644 --- a/panda/src/bullet/bulletCapsuleShape.I +++ b/panda/src/bullet/bulletCapsuleShape.I @@ -1,67 +1,55 @@ -// Filename: bulletCapsuleShape.I -// Created by: enn0x (27Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCapsuleShape.I + * @author enn0x + * @date 2010-01-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletCapsuleShape:: ~BulletCapsuleShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletCapsuleShape:: BulletCapsuleShape(const BulletCapsuleShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletCapsuleShape:: operator = (const BulletCapsuleShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletCapsuleShape:: get_radius() const { return (PN_stdfloat)_shape->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::get_half_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletCapsuleShape:: get_half_height() const { return (PN_stdfloat)_shape->getHalfHeight(); } - diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 583ce9b693..c1986f1a3a 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletCapsuleShape.cxx -// Created by: enn0x (27Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCapsuleShape.cxx + * @author enn0x + * @date 2010-01-27 + */ #include "bulletCapsuleShape.h" TypeHandle BulletCapsuleShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletCapsuleShape:: BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { @@ -42,14 +39,11 @@ BulletCapsuleShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCapsuleShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletCapsuleShape:: ptr() const { return _shape; } - diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index f3b8cb3d51..5e2150c27c 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -1,16 +1,15 @@ -// Filename: bulletCapsuleShape.h -// Created by: enn0x (27Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCapsuleShape.h + * @author enn0x + * @date 2010-01-27 + */ #ifndef __BULLET_CAPSULE_SHAPE_H__ #define __BULLET_CAPSULE_SHAPE_H__ @@ -21,10 +20,9 @@ #include "bullet_utils.h" #include "bulletShape.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletCapsuleShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletCapsuleShape : public BulletShape { PUBLISHED: @@ -42,14 +40,13 @@ public: private: btCapsuleShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletCapsuleShape", + register_type(_type_handle, "BulletCapsuleShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletCharacterControllerNode.I b/panda/src/bullet/bulletCharacterControllerNode.I index e2aae1dc66..391e387e67 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.I +++ b/panda/src/bullet/bulletCharacterControllerNode.I @@ -1,47 +1,38 @@ -// Filename: bulletCharacterControllerNode.I -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCharacterControllerNode.I + * @author enn0x + * @date 2010-11-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletCharacterControllerNode:: ~BulletCharacterControllerNode() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::get_ghost -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btPairCachingGhostObject *BulletCharacterControllerNode:: get_ghost() const { return _ghost; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::get_character -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btCharacterControllerInterface *BulletCharacterControllerNode:: get_character() const { return _character; } - diff --git a/panda/src/bullet/bulletCharacterControllerNode.cxx b/panda/src/bullet/bulletCharacterControllerNode.cxx index f0cb471e40..929aaa8001 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.cxx +++ b/panda/src/bullet/bulletCharacterControllerNode.cxx @@ -1,26 +1,23 @@ -// Filename: bulletCharacterControllerNode.cxx -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCharacterControllerNode.cxx + * @author enn0x + * @date 2010-11-21 + */ #include "bulletCharacterControllerNode.h" TypeHandle BulletCharacterControllerNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletCharacterControllerNode:: BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const char *name) : BulletBaseCharacterControllerNode(name) { @@ -63,15 +60,12 @@ BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const // Retain a pointer to the shape _shape = shape; - // Default collide mask - // TODO set_into_collide_mask(CollideMask::all_on()); + // Default collide mask TODO set_into_collide_mask(CollideMask::all_on()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_linear_movement -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_linear_movement(const LVector3 &movement, bool is_local) { @@ -81,22 +75,18 @@ set_linear_movement(const LVector3 &movement, bool is_local) { _linear_movement_is_local = is_local; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_angular_movement -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_angular_movement(PN_stdfloat omega) { _angular_movement = omega; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::sync_p2b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: sync_p2b(PN_stdfloat dt, int num_substeps) { @@ -126,16 +116,14 @@ sync_p2b(PN_stdfloat dt, int num_substeps) { v = LVecBase3_to_btVector3(vp); } - //_character->setVelocityForTimeInterval(v, dt); + // _character->setVelocityForTimeInterval(v, dt); _character->setWalkDirection(v * dt); _angular_movement = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: sync_b2p() { @@ -156,11 +144,9 @@ sync_b2p() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::transform_changed -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: transform_changed() { @@ -196,119 +182,99 @@ transform_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::get_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletShape *BulletCharacterControllerNode:: get_shape() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::is_on_ground -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletCharacterControllerNode:: is_on_ground() const { return _character->onGround(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::can_jump -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletCharacterControllerNode:: can_jump() const { return _character->canJump(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::do_jump -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: do_jump() { _character->jump(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_fall_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_fall_speed(PN_stdfloat fall_speed) { _character->setFallSpeed((btScalar)fall_speed); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_jump_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_jump_speed(PN_stdfloat jump_speed) { _character->setJumpSpeed((btScalar)jump_speed); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_max_jump_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_max_jump_height(PN_stdfloat max_jump_height) { _character->setMaxJumpHeight((btScalar)max_jump_height); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_max_slope -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_max_slope(PN_stdfloat max_slope) { _character->setMaxSlope((btScalar)max_slope); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::get_max_slope -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletCharacterControllerNode:: get_max_slope() const { return (PN_stdfloat)_character->getMaxSlope(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::get_gravity -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletCharacterControllerNode:: get_gravity() const { return (PN_stdfloat)_character->getGravity(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_gravity -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_gravity(PN_stdfloat gravity) { @@ -316,13 +282,11 @@ set_gravity(PN_stdfloat gravity) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletCharacterControllerNode::set_use_ghost_sweep_test -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletCharacterControllerNode:: set_use_ghost_sweep_test(bool value) { return _character->setUseGhostSweepTest(value); } - diff --git a/panda/src/bullet/bulletCharacterControllerNode.h b/panda/src/bullet/bulletCharacterControllerNode.h index 667bb0a7a3..80f6aab834 100644 --- a/panda/src/bullet/bulletCharacterControllerNode.h +++ b/panda/src/bullet/bulletCharacterControllerNode.h @@ -1,16 +1,15 @@ -// Filename: bulletCharacterControllerNode.h -// Created by: enn0x (21Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCharacterControllerNode.h + * @author enn0x + * @date 2010-11-21 + */ #ifndef __BULLET_CHARACTER_CONTROLLER_NODE_H__ #define __BULLET_CHARACTER_CONTROLLER_NODE_H__ @@ -26,10 +25,9 @@ #include "transformState.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletCharacterControllerNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletCharacterControllerNode : public BulletBaseCharacterControllerNode { PUBLISHED: @@ -80,14 +78,13 @@ private: bool _linear_movement_is_local; PN_stdfloat _angular_movement; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletBaseCharacterControllerNode::init_type(); - register_type(_type_handle, "BulletCharacterControllerNode", + register_type(_type_handle, "BulletCharacterControllerNode", BulletBaseCharacterControllerNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -105,4 +102,3 @@ private: #include "bulletCharacterControllerNode.I" #endif // __BULLET_CHARACTER_CONTROLLER_NODE_H__ - diff --git a/panda/src/bullet/bulletClosestHitRayResult.I b/panda/src/bullet/bulletClosestHitRayResult.I index 52f84f6fe2..00c969c391 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.I +++ b/panda/src/bullet/bulletClosestHitRayResult.I @@ -1,24 +1,20 @@ -// Filename: bulletClosestHitRayResult.I -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitRayResult.I + * @author enn0x + * @date 2010-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::empty -// Access: Public -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletClosestHitRayResult BulletClosestHitRayResult:: empty() { @@ -27,4 +23,3 @@ empty() { return BulletClosestHitRayResult(from, to, CollideMask::all_on()); } - diff --git a/panda/src/bullet/bulletClosestHitRayResult.cxx b/panda/src/bullet/bulletClosestHitRayResult.cxx index acde58087b..2e831c9308 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.cxx +++ b/panda/src/bullet/bulletClosestHitRayResult.cxx @@ -1,37 +1,32 @@ -// Filename: bulletClosestHitRayResult.cxx -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitRayResult.cxx + * @author enn0x + * @date 2010-02-21 + */ #include "bulletClosestHitRayResult.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletClosestHitRayResult:: -BulletClosestHitRayResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) +BulletClosestHitRayResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) : btCollisionWorld::ClosestRayResultCallback(from_pos, to_pos), _mask(mask) { _shapePart = -1; _triangleIndex = -1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::needsCollision -// Access: Protected -// Description: Override default implementation. -//////////////////////////////////////////////////////////////////// +/** + * Override default implementation. + */ bool BulletClosestHitRayResult:: needsCollision(btBroadphaseProxy* proxy0) const { @@ -42,15 +37,13 @@ needsCollision(btBroadphaseProxy* proxy0) const { return (_mask & mask0) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletAllHitsRayResult::addSingleResult -// Access: Protected -// Description: Override default implementation. -//////////////////////////////////////////////////////////////////// +/** + * Override default implementation. + */ btScalar BulletClosestHitRayResult:: addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace) { - // Store part/index information + // Store partindex information if (rayResult.m_localShapeInfo) { _shapePart = rayResult.m_localShapeInfo->m_shapePart; _triangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; @@ -60,33 +53,27 @@ addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldS return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace); }; -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::has_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletClosestHitRayResult:: has_hit() const { return hasHit(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_hit_fraction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletClosestHitRayResult:: get_hit_fraction() const { return (PN_stdfloat)m_closestHitFraction; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *BulletClosestHitRayResult:: get_node() const { @@ -94,69 +81,56 @@ get_node() const { return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_hit_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitRayResult:: get_hit_pos() const { return btVector3_to_LPoint3(m_hitPointWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_hit_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletClosestHitRayResult:: get_hit_normal() const { return btVector3_to_LVector3(m_hitNormalWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_from_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitRayResult:: get_from_pos() const { return btVector3_to_LPoint3(m_rayFromWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_to_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitRayResult:: get_to_pos() const { return btVector3_to_LPoint3(m_rayToWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_shape_part -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletClosestHitRayResult:: get_shape_part() const { return _shapePart; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitRayResult::get_triangle_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletClosestHitRayResult:: get_triangle_index() const { return _triangleIndex; } - diff --git a/panda/src/bullet/bulletClosestHitRayResult.h b/panda/src/bullet/bulletClosestHitRayResult.h index dcb9e325b9..0f2bd67128 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.h +++ b/panda/src/bullet/bulletClosestHitRayResult.h @@ -1,16 +1,15 @@ -// Filename: bulletClosestHitRayResult.h -// Created by: enn0x (21Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitRayResult.h + * @author enn0x + * @date 2010-02-21 + */ #ifndef __BULLET_CLOSEST_HIT_RAY_RESULT_H__ #define __BULLET_CLOSEST_HIT_RAY_RESULT_H__ @@ -24,10 +23,9 @@ #include "pandaNode.h" #include "collideMask.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletClosestHitRayResult -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletClosestHitRayResult : public btCollisionWorld::ClosestRayResultCallback { PUBLISHED: diff --git a/panda/src/bullet/bulletClosestHitSweepResult.I b/panda/src/bullet/bulletClosestHitSweepResult.I index 5c0655c0d1..099cc7bc32 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.I +++ b/panda/src/bullet/bulletClosestHitSweepResult.I @@ -1,24 +1,20 @@ -// Filename: bulletClosestHitSweepResult.I -// Created by: enn0x (01Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitSweepResult.I + * @author enn0x + * @date 2010-12-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestSweepRayResult::empty -// Access: Public -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletClosestHitSweepResult BulletClosestHitSweepResult:: empty() { @@ -27,4 +23,3 @@ empty() { return BulletClosestHitSweepResult(from, to, CollideMask::all_on()); } - diff --git a/panda/src/bullet/bulletClosestHitSweepResult.cxx b/panda/src/bullet/bulletClosestHitSweepResult.cxx index 6245495490..f86bc0456a 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.cxx +++ b/panda/src/bullet/bulletClosestHitSweepResult.cxx @@ -1,35 +1,30 @@ -// Filename: bulletClosestHitSweepResult.cxx -// Created by: enn0x (01Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitSweepResult.cxx + * @author enn0x + * @date 2010-12-01 + */ #include "bulletClosestHitSweepResult.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletClosestHitSweepResult:: -BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) +BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask) : btCollisionWorld::ClosestConvexResultCallback(from_pos, to_pos), _mask(mask) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::needsCollision -// Access: Protected -// Description: Override default implementation. -//////////////////////////////////////////////////////////////////// +/** + * Override default implementation. + */ bool BulletClosestHitSweepResult:: needsCollision(btBroadphaseProxy* proxy0) const { @@ -40,33 +35,27 @@ needsCollision(btBroadphaseProxy* proxy0) const { return (_mask & mask0) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::has_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletClosestHitSweepResult:: has_hit() const { return hasHit(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_hit_fraction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletClosestHitSweepResult:: get_hit_fraction() const { return (PN_stdfloat)m_closestHitFraction; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *BulletClosestHitSweepResult:: get_node() const { @@ -74,47 +63,38 @@ get_node() const { return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_hit_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitSweepResult:: get_hit_pos() const { return btVector3_to_LPoint3(m_hitPointWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_hit_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletClosestHitSweepResult:: get_hit_normal() const { return btVector3_to_LVector3(m_hitNormalWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_from_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitSweepResult:: get_from_pos() const { return btVector3_to_LPoint3(m_convexFromWorld); } -//////////////////////////////////////////////////////////////////// -// Function: BulletClosestHitSweepResult::get_to_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletClosestHitSweepResult:: get_to_pos() const { return btVector3_to_LPoint3(m_convexToWorld); } - diff --git a/panda/src/bullet/bulletClosestHitSweepResult.h b/panda/src/bullet/bulletClosestHitSweepResult.h index 7ff7e524b4..44a82e5fb8 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.h +++ b/panda/src/bullet/bulletClosestHitSweepResult.h @@ -1,16 +1,15 @@ -// Filename: bulletClosestHitSweepResult.h -// Created by: enn0x (01Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletClosestHitSweepResult.h + * @author enn0x + * @date 2010-12-01 + */ #ifndef __BULLET_CLOSEST_HIT_SWEEP_RESULT_H__ #define __BULLET_CLOSEST_HIT_SWEEP_RESULT_H__ @@ -24,10 +23,9 @@ #include "pandaNode.h" #include "collideMask.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletClosestHitSweepResult -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletClosestHitSweepResult : public btCollisionWorld::ClosestConvexResultCallback { PUBLISHED: @@ -44,7 +42,7 @@ PUBLISHED: PN_stdfloat get_hit_fraction() const; public: - virtual bool needsCollision(btBroadphaseProxy* proxy0) const; + virtual bool needsCollision(btBroadphaseProxy* proxy0) const; private: BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, const CollideMask &mask); diff --git a/panda/src/bullet/bulletConeShape.I b/panda/src/bullet/bulletConeShape.I index ae4bf960dc..89198b8cf3 100644 --- a/panda/src/bullet/bulletConeShape.I +++ b/panda/src/bullet/bulletConeShape.I @@ -1,67 +1,55 @@ -// Filename: bulletConeShape.I -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeShape.I + * @author enn0x + * @date 2010-01-24 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConeShape:: ~BulletConeShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConeShape:: BulletConeShape(const BulletConeShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletConeShape:: operator = (const BulletConeShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletConeShape:: get_radius() const { return (PN_stdfloat)_shape->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::get_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletConeShape:: get_height() const { return (PN_stdfloat)_shape->getHeight(); } - diff --git a/panda/src/bullet/bulletConeShape.cxx b/panda/src/bullet/bulletConeShape.cxx index b11dadddda..e06bf6d842 100644 --- a/panda/src/bullet/bulletConeShape.cxx +++ b/panda/src/bullet/bulletConeShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletConeShape.cxx -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeShape.cxx + * @author enn0x + * @date 2010-01-24 + */ #include "bulletConeShape.h" TypeHandle BulletConeShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConeShape:: BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { @@ -42,14 +39,11 @@ BulletConeShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletConeShape:: ptr() const { return _shape; } - diff --git a/panda/src/bullet/bulletConeShape.h b/panda/src/bullet/bulletConeShape.h index 67c9ba6b97..21349bac14 100644 --- a/panda/src/bullet/bulletConeShape.h +++ b/panda/src/bullet/bulletConeShape.h @@ -1,16 +1,15 @@ -// Filename: bulletConeShape.h -// Created by: enn0x (24Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeShape.h + * @author enn0x + * @date 2010-01-24 + */ #ifndef __BULLET_CONE_SHAPE_H__ #define __BULLET_CONE_SHAPE_H__ @@ -21,10 +20,9 @@ #include "bullet_utils.h" #include "bulletShape.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletConeShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletConeShape : public BulletShape { PUBLISHED: @@ -42,14 +40,13 @@ public: private: btConeShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletConeShape", + register_type(_type_handle, "BulletConeShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletConeTwistConstraint.I b/panda/src/bullet/bulletConeTwistConstraint.I index b8a5a66dae..a29277462d 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.I +++ b/panda/src/bullet/bulletConeTwistConstraint.I @@ -1,47 +1,39 @@ -// Filename: bulletConeTwistConstraint.I -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeTwistConstraint.I + * @author enn0x + * @date 2010-03-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConeTwistConstraint:: ~BulletConeTwistConstraint() { delete _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::get_frame_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletConeTwistConstraint:: get_frame_a() const { return btTrans_to_TransformState(_constraint->getAFrame()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::get_frame_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletConeTwistConstraint:: get_frame_b() const { return btTrans_to_TransformState(_constraint->getBFrame()); } - diff --git a/panda/src/bullet/bulletConeTwistConstraint.cxx b/panda/src/bullet/bulletConeTwistConstraint.cxx index 2908dcbb87..93505b33fc 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.cxx +++ b/panda/src/bullet/bulletConeTwistConstraint.cxx @@ -1,16 +1,15 @@ -// Filename: bulletConeTwistConstraint.cxx -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeTwistConstraint.cxx + * @author enn0x + * @date 2010-03-01 + */ #include "bulletConeTwistConstraint.h" #include "bulletRigidBodyNode.h" @@ -19,13 +18,11 @@ TypeHandle BulletConeTwistConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConeTwistConstraint:: -BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, +BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a) { btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); @@ -34,11 +31,9 @@ BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, _constraint = new btConeTwistConstraint(*ptr_a, trans_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConeTwistConstraint:: BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -54,35 +49,29 @@ BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, _constraint = new btConeTwistConstraint(*ptr_a, *ptr_b, trans_a, trans_b); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTypedConstraint *BulletConeTwistConstraint:: ptr() const { return _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_limit(int index, PN_stdfloat value) { - + value = deg_2_rad(value); _constraint->setLimit(index, value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) { @@ -93,99 +82,81 @@ set_limit(PN_stdfloat swing1, PN_stdfloat swing2, PN_stdfloat twist, PN_stdfloat _constraint->setLimit(swing1, swing2, twist, softness, bias, relaxation); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_damping(PN_stdfloat damping) { - + _constraint->setDamping(damping); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::get_fix_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletConeTwistConstraint:: get_fix_threshold() const { - + return _constraint->getFixThresh(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_fix_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_fix_threshold(PN_stdfloat threshold) { - + _constraint->setFixThresh(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::enable_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: enable_motor(bool enable) { - + _constraint->enableMotor(enable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_max_motor_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_max_motor_impulse(PN_stdfloat max_impulse) { - + _constraint->setMaxMotorImpulse(max_impulse); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_max_motor_impulse_normalized -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_max_motor_impulse_normalized(PN_stdfloat max_impulse) { - + _constraint->setMaxMotorImpulseNormalized(max_impulse); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_motor_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_motor_target(const LQuaternion &quat) { - + _constraint->setMotorTarget(LQuaternion_to_btQuat(quat)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_motor_target_in_constraint_space -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_motor_target_in_constraint_space(const LQuaternion &quat) { - + _constraint->setMotorTargetInConstraintSpace(LQuaternion_to_btQuat(quat)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConeTwistConstraint::set_frames -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConeTwistConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { @@ -194,4 +165,3 @@ set_frames(const TransformState *ts_a, const TransformState *ts_b) { _constraint->setFrames(frame_a, frame_b); } - diff --git a/panda/src/bullet/bulletConeTwistConstraint.h b/panda/src/bullet/bulletConeTwistConstraint.h index 5894e63241..1cc4cc61e6 100644 --- a/panda/src/bullet/bulletConeTwistConstraint.h +++ b/panda/src/bullet/bulletConeTwistConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletConeTwistConstraint.h -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConeTwistConstraint.h + * @author enn0x + * @date 2010-03-01 + */ #ifndef __BULLET_CONE_TWIST_CONSTRAINT_H__ #define __BULLET_CONE_TWIST_CONSTRAINT_H__ @@ -25,14 +24,13 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletConeTwistConstraint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletConeTwistConstraint : public BulletConstraint { PUBLISHED: - BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, + BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a); BulletConeTwistConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -64,14 +62,13 @@ public: private: btConeTwistConstraint *_constraint; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletConstraint::init_type(); - register_type(_type_handle, "BulletConeTwistConstraint", + register_type(_type_handle, "BulletConeTwistConstraint", BulletConstraint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletConstraint.I b/panda/src/bullet/bulletConstraint.I index 5ae86fb398..b2f4666608 100644 --- a/panda/src/bullet/bulletConstraint.I +++ b/panda/src/bullet/bulletConstraint.I @@ -1,72 +1,58 @@ -// Filename: bulletConstraint.I -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConstraint.I + * @author enn0x + * @date 2010-03-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConstraint:: ~BulletConstraint() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::set_breaking_threshold -// Access: Published -// Description: Sets the applied impulse limit for breaking the -// constraint. If the limit is exceeded the constraint -// will be disabled. Disabled constraints are not -// removed from the world, and can be re-enabled. -//////////////////////////////////////////////////////////////////// +/** + * Sets the applied impulse limit for breaking the constraint. If the limit + * is exceeded the constraint will be disabled. Disabled constraints are not + * removed from the world, and can be re-enabled. + */ INLINE void BulletConstraint:: set_breaking_threshold(PN_stdfloat threshold) { ptr()->setBreakingImpulseThreshold(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::set_breaking_threshold -// Access: Published -// Description: Returns the applied impluse limit for breaking the -// constraint. -//////////////////////////////////////////////////////////////////// +/** + * Returns the applied impluse limit for breaking the constraint. + */ INLINE PN_stdfloat BulletConstraint:: set_breaking_threshold() const { return (PN_stdfloat)ptr()->getBreakingImpulseThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::set_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletConstraint:: set_enabled(bool enable) { ptr()->setEnabled(enable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::is_enabled -// Access: Published -// Description: Returns TRUE if the constraint is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the constraint is enabled. + */ INLINE bool BulletConstraint:: is_enabled() const { return ptr()->isEnabled(); } - diff --git a/panda/src/bullet/bulletConstraint.cxx b/panda/src/bullet/bulletConstraint.cxx index f0fd43042e..28efe703ff 100644 --- a/panda/src/bullet/bulletConstraint.cxx +++ b/panda/src/bullet/bulletConstraint.cxx @@ -1,107 +1,89 @@ -// Filename: bulletConstraint.cxx -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConstraint.cxx + * @author enn0x + * @date 2010-03-01 + */ #include "bulletConstraint.h" #include "bulletRigidBodyNode.h" TypeHandle BulletConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::enable_feedback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConstraint:: enable_feedback(bool value) { ptr()->enableFeedback(value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::get_applied_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletConstraint:: get_applied_impulse() const { return (PN_stdfloat)ptr()->getAppliedImpulse(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::set_dbg_draw_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConstraint:: set_debug_draw_size(PN_stdfloat size) { ptr()->setDbgDrawSize((btScalar)size); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::get_dbg_draw_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletConstraint:: get_debug_draw_size() { return (PN_stdfloat)ptr()->getDbgDrawSize(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::get_rigid_body_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRigidBodyNode *BulletConstraint:: get_rigid_body_a() { return (BulletRigidBodyNode *)ptr()->getRigidBodyA().getUserPointer(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::get_rigid_body_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRigidBodyNode *BulletConstraint:: get_rigid_body_b() { return (BulletRigidBodyNode *)ptr()->getRigidBodyB().getUserPointer(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::set_param -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConstraint:: set_param(ConstraintParam num, PN_stdfloat value, int axis) { ptr()->setParam((btConstraintParams)num, (btScalar)value, axis); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConstraint::get_param -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletConstraint:: get_param(ConstraintParam num, int axis) { return (PN_stdfloat)ptr()->getParam((btConstraintParams)num, axis); } - diff --git a/panda/src/bullet/bulletConstraint.h b/panda/src/bullet/bulletConstraint.h index a844a67846..9f97be7af8 100644 --- a/panda/src/bullet/bulletConstraint.h +++ b/panda/src/bullet/bulletConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletConstraint.h -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConstraint.h + * @author enn0x + * @date 2010-03-01 + */ #ifndef __BULLET_CONSTRAINT_H__ #define __BULLET_CONSTRAINT_H__ @@ -23,10 +22,9 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletConstraint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletConstraint : public TypedReferenceCount { PUBLISHED: @@ -59,14 +57,13 @@ PUBLISHED: public: virtual btTypedConstraint *ptr() const = 0; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "BulletConstraint", + register_type(_type_handle, "BulletConstraint", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletContactCallbackData.I b/panda/src/bullet/bulletContactCallbackData.I index bc641fb56d..2cf266e436 100644 --- a/panda/src/bullet/bulletContactCallbackData.I +++ b/panda/src/bullet/bulletContactCallbackData.I @@ -1,22 +1,19 @@ -// Filename: bulletContactCallbackData.I -// Created by: enn0x (22Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactCallbackData.I + * @author enn0x + * @date 2012-11-22 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletContactCallbackData:: BulletContactCallbackData(BulletManifoldPoint &mp, PandaNode *node0, PandaNode *node1, int id0, int id1, int index0, int index1) : _mp(mp), @@ -29,80 +26,65 @@ BulletContactCallbackData(BulletManifoldPoint &mp, PandaNode *node0, PandaNode * } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_manifold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletManifoldPoint &BulletContactCallbackData:: get_manifold() const { return _mp; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_node0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletContactCallbackData:: get_node0() const { return _node0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_node1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletContactCallbackData:: get_node1() const { return _node1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_part_id0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContactCallbackData:: get_part_id0() const { return _id0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_part_id1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContactCallbackData:: get_part_id1() const { return _id1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_index0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContactCallbackData:: get_index0() const { return _index0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::get_index1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContactCallbackData:: get_index1() const { return _index1; } - diff --git a/panda/src/bullet/bulletContactCallbackData.cxx b/panda/src/bullet/bulletContactCallbackData.cxx index cb09a3d7d6..8893b6625c 100644 --- a/panda/src/bullet/bulletContactCallbackData.cxx +++ b/panda/src/bullet/bulletContactCallbackData.cxx @@ -1,31 +1,27 @@ -// Filename: bulletContactCallbackData.cxx -// Created by: enn0x (22Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactCallbackData.cxx + * @author enn0x + * @date 2012-11-22 + */ #include "bulletContactCallbackData.h" TypeHandle BulletContactCallbackData::_type_handle; +/** + * + */ /* -//////////////////////////////////////////////////////////////////// -// Function: BulletContactCallbackData::enable_feedback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// void BulletContactCallbackData:: enable_feedback(bool value) { ptr()->enableFeedback(value); } */ - diff --git a/panda/src/bullet/bulletContactCallbackData.h b/panda/src/bullet/bulletContactCallbackData.h index 5cc760a03b..a83f66ff9c 100644 --- a/panda/src/bullet/bulletContactCallbackData.h +++ b/panda/src/bullet/bulletContactCallbackData.h @@ -1,16 +1,15 @@ -// Filename: bulletContactCallbackData.h -// Created by: enn0x (22Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactCallbackData.h + * @author enn0x + * @date 2012-11-22 + */ #ifndef __BULLET_CONTACT_CALLBACK_DATA_H__ #define __BULLET_CONTACT_CALLBACK_DATA_H__ @@ -23,14 +22,13 @@ #include "bullet_utils.h" #include "bulletManifoldPoint.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletContactCallbackData -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletContactCallbackData : public CallbackData { PUBLISHED: - INLINE BulletContactCallbackData(BulletManifoldPoint &mp, + INLINE BulletContactCallbackData(BulletManifoldPoint &mp, PandaNode *node0, PandaNode *node1, int id0, int id1, int index0, int index1); @@ -52,14 +50,13 @@ private: int _index0; int _index1; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { CallbackData::init_type(); - register_type(_type_handle, "BulletContactCallbackData", + register_type(_type_handle, "BulletContactCallbackData", CallbackData::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletContactCallbacks.h b/panda/src/bullet/bulletContactCallbacks.h index 6d31543916..fa338154f8 100644 --- a/panda/src/bullet/bulletContactCallbacks.h +++ b/panda/src/bullet/bulletContactCallbacks.h @@ -1,16 +1,15 @@ -// Filename: bulletContactCallbacks.h -// Created by: enn0x (10Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactCallbacks.h + * @author enn0x + * @date 2010-04-10 + */ #ifndef __BULLET_CONTACT_CALLBACKS_H__ #define __BULLET_CONTACT_CALLBACKS_H__ @@ -32,10 +31,9 @@ struct UserPersitentData { PT(PandaNode) node1; }; -//////////////////////////////////////////////////////////////////// -// Function: contact_added_callback -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static bool contact_added_callback(btManifoldPoint &cp, #if BT_BULLET_VERSION >= 281 @@ -95,10 +93,9 @@ contact_added_callback(btManifoldPoint &cp, return true; } -//////////////////////////////////////////////////////////////////// -// Function: contact_processed_callback -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static bool contact_processed_callback(btManifoldPoint &cp, void *body0, @@ -121,10 +118,9 @@ contact_processed_callback(btManifoldPoint &cp, return false; } -//////////////////////////////////////////////////////////////////// -// Function: contact_destroyed_callback -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static bool contact_destroyed_callback(void *userPersistentData) { diff --git a/panda/src/bullet/bulletContactResult.I b/panda/src/bullet/bulletContactResult.I index cf1612aa73..5509f35092 100644 --- a/panda/src/bullet/bulletContactResult.I +++ b/panda/src/bullet/bulletContactResult.I @@ -1,111 +1,91 @@ -// Filename: bulletContactResult.I -// Created by: enn0x (08Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactResult.I + * @author enn0x + * @date 2010-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_node0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletContact:: get_node0() const { return _node0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_node1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletContact:: get_node1() const { return _node1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_manifold_point -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletManifoldPoint &BulletContact:: get_manifold_point() { return _mp; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_idx0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContact:: get_idx0() const { return _idx0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_idx1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContact:: get_idx1() const { return _idx1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_part_id0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContact:: get_part_id0() const { return _part_id0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::get_part_id1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContact:: get_part_id1() const { return _part_id1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::get_num_contacts -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletContactResult:: get_num_contacts() const { return _contacts.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::get_contact -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletContact &BulletContactResult:: get_contact(int idx) { diff --git a/panda/src/bullet/bulletContactResult.cxx b/panda/src/bullet/bulletContactResult.cxx index f65d66928f..4d9e2588bd 100644 --- a/panda/src/bullet/bulletContactResult.cxx +++ b/panda/src/bullet/bulletContactResult.cxx @@ -1,27 +1,24 @@ -// Filename: bulletContactResult.cxx -// Created by: enn0x (08Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactResult.cxx + * @author enn0x + * @date 2010-03-08 + */ #include "bulletContactResult.h" btManifoldPoint BulletContact::_empty; BulletContact BulletContactResult::_empty; -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletContact:: BulletContact() : _mp(_empty) { @@ -29,11 +26,9 @@ BulletContact() : _mp(_empty) { _node1 = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContact::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletContact:: BulletContact(const BulletContact &other) : _mp(other._mp) { @@ -45,11 +40,9 @@ BulletContact(const BulletContact &other) : _mp(other._mp) { _idx1 = other._idx1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletContactResult:: BulletContactResult() : btCollisionWorld::ContactResultCallback() { @@ -61,11 +54,9 @@ BulletContactResult() : btCollisionWorld::ContactResultCallback() { } #if BT_BULLET_VERSION >= 281 -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::use_filter -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletContactResult:: use_filter(btOverlapFilterCallback *cb, btBroadphaseProxy *proxy) { @@ -77,11 +68,9 @@ use_filter(btOverlapFilterCallback *cb, btBroadphaseProxy *proxy) { _filter_set = true; } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::needsCollision -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletContactResult:: needsCollision(btBroadphaseProxy *proxy0) const { @@ -93,11 +82,9 @@ needsCollision(btBroadphaseProxy *proxy0) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::addSingleResult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btScalar BulletContactResult:: addSingleResult(btManifoldPoint &mp, const btCollisionObjectWrapper *wrap0, int part_id0, int idx0, @@ -121,11 +108,9 @@ addSingleResult(btManifoldPoint &mp, return 1.0f; } #else -//////////////////////////////////////////////////////////////////// -// Function: BulletContactResult::addSingleResult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btScalar BulletContactResult:: addSingleResult(btManifoldPoint &mp, const btCollisionObject *obj0, int part_id0, int idx0, @@ -146,4 +131,3 @@ addSingleResult(btManifoldPoint &mp, return 1.0f; } #endif - diff --git a/panda/src/bullet/bulletContactResult.h b/panda/src/bullet/bulletContactResult.h index f44e52688c..77ada41468 100644 --- a/panda/src/bullet/bulletContactResult.h +++ b/panda/src/bullet/bulletContactResult.h @@ -1,16 +1,15 @@ -// Filename: bulletContactResult.h -// Created by: enn0x (08Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletContactResult.h + * @author enn0x + * @date 2010-03-08 + */ #ifndef __BULLET_CONTACT_RESULT_H__ #define __BULLET_CONTACT_RESULT_H__ @@ -22,10 +21,9 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletContact -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletContact { public: @@ -57,10 +55,9 @@ private: friend struct BulletContactResult; }; -//////////////////////////////////////////////////////////////////// -// Class : BulletContactResult -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ struct EXPCL_PANDABULLET BulletContactResult : public btCollisionWorld::ContactResultCallback { PUBLISHED: @@ -73,8 +70,8 @@ public: virtual bool needsCollision(btBroadphaseProxy *proxy0) const; virtual btScalar addSingleResult(btManifoldPoint &mp, - const btCollisionObjectWrapper *wrap0, int part_id0, int idx0, - const btCollisionObjectWrapper *wrap1, int part_id1, int idx1); + const btCollisionObjectWrapper *wrap0, int part_id0, int idx0, + const btCollisionObjectWrapper *wrap1, int part_id1, int idx1); #else virtual btScalar addSingleResult(btManifoldPoint &mp, const btCollisionObject *obj0, int part_id0, int idx0, diff --git a/panda/src/bullet/bulletConvexHullShape.I b/panda/src/bullet/bulletConvexHullShape.I index 42d1b266d1..71fa3cd190 100644 --- a/panda/src/bullet/bulletConvexHullShape.I +++ b/panda/src/bullet/bulletConvexHullShape.I @@ -1,45 +1,37 @@ -// Filename: bulletConvexHullShape.I -// Created by: enn0x (26Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexHullShape.I + * @author enn0x + * @date 2010-01-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConvexHullShape:: ~BulletConvexHullShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConvexHullShape:: BulletConvexHullShape(const BulletConvexHullShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletConvexHullShape:: operator = (const BulletConvexHullShape ©) { _shape = copy._shape; } - diff --git a/panda/src/bullet/bulletConvexHullShape.cxx b/panda/src/bullet/bulletConvexHullShape.cxx index 45ccc87b4e..5b4494d330 100644 --- a/panda/src/bullet/bulletConvexHullShape.cxx +++ b/panda/src/bullet/bulletConvexHullShape.cxx @@ -1,16 +1,15 @@ -// Filename: bulletConvexHullShape.cxx -// Created by: enn0x (26Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexHullShape.cxx + * @author enn0x + * @date 2010-01-26 + */ #include "bulletConvexHullShape.h" @@ -20,11 +19,9 @@ TypeHandle BulletConvexHullShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConvexHullShape:: BulletConvexHullShape() { @@ -32,33 +29,27 @@ BulletConvexHullShape() { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletConvexHullShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::add_point -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConvexHullShape:: add_point(const LPoint3 &p) { _shape->addPoint(LVecBase3_to_btVector3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConvexHullShape:: add_array(const PTA_LVecBase3 &points) { @@ -79,11 +70,9 @@ add_array(const PTA_LVecBase3 &points) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletConvexHullShape:: add_geom(const Geom *geom, const TransformState *ts) { @@ -122,23 +111,18 @@ add_geom(const Geom *geom, const TransformState *ts) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletShape. + */ void BulletConvexHullShape:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletConvexHullShape:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_margin()); @@ -154,14 +138,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletConvexHullShape:: make_from_bam(const FactoryParams ¶ms) { BulletConvexHullShape *param = new BulletConvexHullShape; @@ -174,13 +155,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexHullShape::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletShape. + */ void BulletConvexHullShape:: fillin(DatagramIterator &scan, BamReader *manager) { PN_stdfloat margin = scan.get_stdfloat(); diff --git a/panda/src/bullet/bulletConvexHullShape.h b/panda/src/bullet/bulletConvexHullShape.h index f51b33560f..f74489bd0e 100644 --- a/panda/src/bullet/bulletConvexHullShape.h +++ b/panda/src/bullet/bulletConvexHullShape.h @@ -1,16 +1,15 @@ -// Filename: bulletConvexHullShape.h -// Created by: enn0x (26Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexHullShape.h + * @author enn0x + * @date 2010-01-26 + */ #ifndef __BULLET_CONVEX_HULL_SHAPE_H__ #define __BULLET_CONVEX_HULL_SHAPE_H__ @@ -24,10 +23,9 @@ #include "geom.h" #include "pta_LVecBase3.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletConvexHullShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletConvexHullShape : public BulletShape { PUBLISHED: BulletConvexHullShape(); @@ -60,7 +58,7 @@ public: } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletConvexHullShape", + register_type(_type_handle, "BulletConvexHullShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletConvexPointCloudShape.I b/panda/src/bullet/bulletConvexPointCloudShape.I index 595b3874ea..aff49d4698 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.I +++ b/panda/src/bullet/bulletConvexPointCloudShape.I @@ -1,56 +1,46 @@ -// Filename: bulletConvexPointCloudShape.I -// Created by: enn0x (30Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexPointCloudShape.I + * @author enn0x + * @date 2010-01-30 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConvexPointCloudShape:: ~BulletConvexPointCloudShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConvexPointCloudShape:: BulletConvexPointCloudShape(const BulletConvexPointCloudShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletConvexPointCloudShape:: operator = (const BulletConvexPointCloudShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::get_num_points -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletConvexPointCloudShape:: get_num_points() const { return _shape->getNumPoints(); } - diff --git a/panda/src/bullet/bulletConvexPointCloudShape.cxx b/panda/src/bullet/bulletConvexPointCloudShape.cxx index 4e5a4b9444..256357df8c 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.cxx +++ b/panda/src/bullet/bulletConvexPointCloudShape.cxx @@ -1,16 +1,15 @@ -// Filename: bulletConvexPointCloudShape.cxx -// Created by: enn0x (30Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexPointCloudShape.cxx + * @author enn0x + * @date 2010-01-30 + */ #include "bulletConvexPointCloudShape.h" @@ -18,11 +17,9 @@ TypeHandle BulletConvexPointCloudShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConvexPointCloudShape:: BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale) { @@ -43,22 +40,18 @@ BulletConvexPointCloudShape(const PTA_LVecBase3 &points, LVecBase3 scale) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletConvexPointCloudShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletConvexPointCloudShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletConvexPointCloudShape:: BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale) { @@ -88,4 +81,3 @@ BulletConvexPointCloudShape(const Geom *geom, LVecBase3 scale) { _shape = new btConvexPointCloudShape(btPoints, points.size(), btScale); _shape->setUserPointer(this); } - diff --git a/panda/src/bullet/bulletConvexPointCloudShape.h b/panda/src/bullet/bulletConvexPointCloudShape.h index 778f823cec..e1199d7a5b 100644 --- a/panda/src/bullet/bulletConvexPointCloudShape.h +++ b/panda/src/bullet/bulletConvexPointCloudShape.h @@ -1,16 +1,15 @@ -// Filename: bulletConvexPointCloudShape.h -// Created by: enn0x (30Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletConvexPointCloudShape.h + * @author enn0x + * @date 2010-01-30 + */ #ifndef __BULLET_CONVEX_POINT_CLOUD_SHAPE_H__ #define __BULLET_CONVEX_POINT_CLOUD_SHAPE_H__ @@ -23,10 +22,9 @@ #include "geom.h" #include "pta_LVecBase3.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletConvexPointCloudShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletConvexPointCloudShape : public BulletShape { PUBLISHED: @@ -44,14 +42,13 @@ public: private: btConvexPointCloudShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletConvexPointCloudShape", + register_type(_type_handle, "BulletConvexPointCloudShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletCylinderShape.I b/panda/src/bullet/bulletCylinderShape.I index 0acb937300..990d0f0f68 100644 --- a/panda/src/bullet/bulletCylinderShape.I +++ b/panda/src/bullet/bulletCylinderShape.I @@ -1,78 +1,64 @@ -// Filename: bulletCylinderShape.I -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCylinderShape.I + * @author enn0x + * @date 2010-02-17 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletCylinderShape:: ~BulletCylinderShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletCylinderShape:: BulletCylinderShape(const BulletCylinderShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletCylinderShape:: operator = (const BulletCylinderShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletCylinderShape:: get_radius() const { return (PN_stdfloat)_shape->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::get_half_extents_without_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVecBase3 BulletCylinderShape:: get_half_extents_without_margin() const { return btVector3_to_LVecBase3(_shape->getHalfExtentsWithoutMargin()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::get_half_extents_with_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVecBase3 BulletCylinderShape:: get_half_extents_with_margin() const { return btVector3_to_LVecBase3(_shape->getHalfExtentsWithMargin()); } - diff --git a/panda/src/bullet/bulletCylinderShape.cxx b/panda/src/bullet/bulletCylinderShape.cxx index 55c9bbd513..1de1e5d5f0 100644 --- a/panda/src/bullet/bulletCylinderShape.cxx +++ b/panda/src/bullet/bulletCylinderShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletCylinderShape.cxx -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCylinderShape.cxx + * @author enn0x + * @date 2010-02-17 + */ #include "bulletCylinderShape.h" TypeHandle BulletCylinderShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletCylinderShape:: BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) { @@ -44,11 +41,9 @@ BulletCylinderShape(const LVector3 &half_extents, BulletUpAxis up) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletCylinderShape:: BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { @@ -70,14 +65,11 @@ BulletCylinderShape(PN_stdfloat radius, PN_stdfloat height, BulletUpAxis up) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletCylinderShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletCylinderShape:: ptr() const { return _shape; } - diff --git a/panda/src/bullet/bulletCylinderShape.h b/panda/src/bullet/bulletCylinderShape.h index 1511466047..d4e9beb31f 100644 --- a/panda/src/bullet/bulletCylinderShape.h +++ b/panda/src/bullet/bulletCylinderShape.h @@ -1,16 +1,15 @@ -// Filename: bulletCylinderShape.h -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletCylinderShape.h + * @author enn0x + * @date 2010-02-17 + */ #ifndef __BULLET_CYLINDER_SHAPE_H__ #define __BULLET_CYLINDER_SHAPE_H__ @@ -21,10 +20,9 @@ #include "bullet_utils.h" #include "bulletShape.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletCylinderShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletCylinderShape : public BulletShape { PUBLISHED: @@ -44,14 +42,13 @@ public: private: btCylinderShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletCylinderShape", + register_type(_type_handle, "BulletCylinderShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletDebugNode.I b/panda/src/bullet/bulletDebugNode.I index 66f994bd4b..4d4d8aa069 100644 --- a/panda/src/bullet/bulletDebugNode.I +++ b/panda/src/bullet/bulletDebugNode.I @@ -1,32 +1,27 @@ -// Filename: bulletDebugNode.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletDebugNode.I + * @author enn0x + * @date 2010-01-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletDebugNode:: ~BulletDebugNode() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::show_wireframe -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletDebugNode:: show_wireframe(bool show) { @@ -34,11 +29,9 @@ show_wireframe(bool show) { draw_mask_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::show_constraints -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletDebugNode:: show_constraints(bool show) { @@ -46,11 +39,9 @@ show_constraints(bool show) { draw_mask_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::show_bounding_boxes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletDebugNode:: show_bounding_boxes(bool show) { @@ -58,14 +49,11 @@ show_bounding_boxes(bool show) { draw_mask_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::show_normals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletDebugNode:: show_normals(bool show) { _drawer._normals = show; } - diff --git a/panda/src/bullet/bulletDebugNode.cxx b/panda/src/bullet/bulletDebugNode.cxx index ce283267e9..196a9af09f 100644 --- a/panda/src/bullet/bulletDebugNode.cxx +++ b/panda/src/bullet/bulletDebugNode.cxx @@ -1,16 +1,15 @@ -// Filename: bulletDebugNode.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletDebugNode.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bulletDebugNode.h" @@ -23,11 +22,9 @@ TypeHandle BulletDebugNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletDebugNode:: BulletDebugNode(const char *name) : GeomNode(name) { @@ -76,102 +73,79 @@ BulletDebugNode(const char *name) : GeomNode(name) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool BulletDebugNode:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a Character. + */ bool BulletDebugNode:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_modify_transform -// Access: Public, Virtual -// Description: Returns true if it is safe to automatically adjust -// the transform on this kind of node. Usually, this is -// only a bad idea if the user expects to find a -// particular transform on the node. -// -// ModelNodes with the preserve_transform flag set are -// presently the only kinds of nodes that should not -// have their transform even adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is safe to automatically adjust the transform on this + * kind of node. Usually, this is only a bad idea if the user expects to find + * a particular transform on the node. + * + * ModelNodes with the preserve_transform flag set are presently the only + * kinds of nodes that should not have their transform even adjusted. + */ bool BulletDebugNode:: safe_to_modify_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool BulletDebugNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool BulletDebugNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::safe_to_flatten_below -// Access: Public, Virtual -// Description: Returns true if a flatten operation may safely -// continue past this node, or false if nodes below this -// node may not be molested. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a flatten operation may safely continue past this node, or + * false if nodes below this node may not be molested. + */ bool BulletDebugNode:: safe_to_flatten_below() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::draw_mask_changed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode:: draw_mask_changed() { @@ -197,14 +171,12 @@ draw_mask_changed() { } _drawer.setDebugMode(mode); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::sync_b2p -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode:: sync_b2p(btDynamicsWorld *world) { @@ -299,44 +271,36 @@ sync_b2p(btDynamicsWorld *world) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::setDebugMode -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: setDebugMode(int mode) { _mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::getDebugMode -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletDebugNode::DebugDraw:: getDebugMode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::reportErrorWarning -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: reportErrorWarning(const char *warning) { bullet_cat.error() << warning << endl; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::drawLine -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) { @@ -344,8 +308,8 @@ drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) { PN_stdfloat g = color.getY(); PN_stdfloat b = color.getZ(); - // Hack to get rid of triangle normals. The hack is based on the - // assumption that only normals are drawn in yellow. + // Hack to get rid of triangle normals. The hack is based on the assumption + // that only normals are drawn in yellow. if (_normals==false && r==1.0f && g==1.0f && b==0.0f) return; Line line; @@ -357,17 +321,15 @@ drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color) { (PN_stdfloat)to.getY(), (PN_stdfloat)to.getZ()); line._color = UnalignedLVecBase4((PN_stdfloat)r, - (PN_stdfloat)g, + (PN_stdfloat)g, (PN_stdfloat)b, 1.0f); _lines.push_back(line); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::drawTriangle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &color, btScalar) { @@ -389,8 +351,8 @@ drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, cons (PN_stdfloat)v2.getY(), (PN_stdfloat)v2.getZ()); - tri._color = UnalignedLVecBase4((PN_stdfloat)r, - (PN_stdfloat)g, + tri._color = UnalignedLVecBase4((PN_stdfloat)r, + (PN_stdfloat)g, (PN_stdfloat)b, 1.0f); _triangles.push_back(tri); @@ -408,22 +370,18 @@ drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, cons */ } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::drawTriangle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, const btVector3 &n2, const btVector3 &color, btScalar alpha) { bullet_cat.debug() << "drawTriangle(2) - not yet implemented!" << endl; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::drawContactPoint -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: drawContactPoint(const btVector3 &point, const btVector3 &normal, btScalar distance, int lifetime, const btVector3 &color) { @@ -433,22 +391,18 @@ drawContactPoint(const btVector3 &point, const btVector3 &normal, btScalar dista drawLine(from, to, color); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::draw3dText -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: draw3dText(const btVector3 &location, const char *text) { bullet_cat.debug() << "draw3dText - not yet implemented!" << endl; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::DebugDraw::drawSphere -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletDebugNode::DebugDraw:: drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color) { @@ -463,27 +417,22 @@ drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color drawArc(center, zoffs, xoffs, radius, radius, 0, SIMD_2_PI, color, false, 10.0); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletDebugNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletDebugNode. + */ void BulletDebugNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletDebugNode:: write_datagram(BamWriter *manager, Datagram &dg) { - // Don't upcall to GeomNode since we're not interested in storing - // the actual debug Geoms in the .bam file. + // Don't upcall to GeomNode since we're not interested in storing the actual + // debug Geoms in the .bam file. PandaNode::write_datagram(manager, dg); dg.add_bool(_wireframe); @@ -492,14 +441,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_drawer._normals); } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of this type is encountered -// in the Bam file. It should create the rigid body -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * this type is encountered in the Bam file. It should create the rigid body + * and extract its information from the file. + */ TypedWritable *BulletDebugNode:: make_from_bam(const FactoryParams ¶ms) { BulletDebugNode *param = new BulletDebugNode; @@ -512,17 +458,14 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletDebugNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletDebugNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletDebugNode. + */ void BulletDebugNode:: fillin(DatagramIterator &scan, BamReader *manager) { - // Don't upcall to GeomNode since we're not interested in storing - // the actual debug Geoms in the .bam file. + // Don't upcall to GeomNode since we're not interested in storing the actual + // debug Geoms in the .bam file. PandaNode::fillin(scan, manager); _wireframe = scan.get_bool(); diff --git a/panda/src/bullet/bulletDebugNode.h b/panda/src/bullet/bulletDebugNode.h index cae9628dbb..5104438381 100644 --- a/panda/src/bullet/bulletDebugNode.h +++ b/panda/src/bullet/bulletDebugNode.h @@ -1,16 +1,15 @@ -// Filename: bulletDebugNode.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletDebugNode.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_DEBUG_NODE_H__ #define __BULLET_DEBUG_NODE_H__ @@ -21,10 +20,9 @@ #include "geomNode.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletDebugNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletDebugNode : public GeomNode { PUBLISHED: @@ -73,16 +71,16 @@ private: virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color); - virtual void drawContactPoint(const btVector3 &point, - const btVector3 &normal, btScalar distance, int lifetime, + virtual void drawContactPoint(const btVector3 &point, + const btVector3 &normal, btScalar distance, int lifetime, const btVector3 &color); virtual void draw3dText(const btVector3 &location, const char *text); - virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, + virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2, const btVector3 &color, btScalar); - virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, - const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, + virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, + const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, const btVector3 &n2, const btVector3 &color, btScalar alpha); - virtual void drawSphere(btScalar radius, const btTransform &transform, + virtual void drawSphere(btScalar radius, const btTransform &transform, const btVector3 &color); public: @@ -115,7 +113,7 @@ public: } static void init_type() { GeomNode::init_type(); - register_type(_type_handle, "BulletDebugNode", + register_type(_type_handle, "BulletDebugNode", GeomNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -133,4 +131,3 @@ private: #include "bulletDebugNode.I" #endif // __BULLET_DEBUG_NODE_H__ - diff --git a/panda/src/bullet/bulletFilterCallbackData.I b/panda/src/bullet/bulletFilterCallbackData.I index 7512c40cb5..622125c44f 100644 --- a/panda/src/bullet/bulletFilterCallbackData.I +++ b/panda/src/bullet/bulletFilterCallbackData.I @@ -1,22 +1,19 @@ -// Filename: bulletFilterCallbackData.I -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletFilterCallbackData.I + * @author enn0x + * @date 2012-11-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletFilterCallbackData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletFilterCallbackData:: BulletFilterCallbackData(PandaNode *node0, PandaNode *node1) : _node0(node0), @@ -25,47 +22,38 @@ BulletFilterCallbackData(PandaNode *node0, PandaNode *node1) : } -//////////////////////////////////////////////////////////////////// -// Function: BulletFilterCallbackData::get_node_0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletFilterCallbackData:: get_node_0() const { return _node0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletFilterCallbackData::get_node_1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletFilterCallbackData:: get_node_1() const { return _node1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletFilterCallbackData::get_collide -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletFilterCallbackData:: get_collide() const { return _collide; } -//////////////////////////////////////////////////////////////////// -// Function: BulletFilterCallbackData::set_collide -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletFilterCallbackData:: set_collide(bool collide) { _collide = collide; } - diff --git a/panda/src/bullet/bulletFilterCallbackData.cxx b/panda/src/bullet/bulletFilterCallbackData.cxx index 98192407f2..220a22512a 100644 --- a/panda/src/bullet/bulletFilterCallbackData.cxx +++ b/panda/src/bullet/bulletFilterCallbackData.cxx @@ -1,18 +1,16 @@ -// Filename: bulletFilterCallbackData.cxx -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletFilterCallbackData.cxx + * @author enn0x + * @date 2012-11-26 + */ #include "bulletFilterCallbackData.h" TypeHandle BulletFilterCallbackData::_type_handle; - diff --git a/panda/src/bullet/bulletFilterCallbackData.h b/panda/src/bullet/bulletFilterCallbackData.h index ab5dea46fd..00a244cff8 100644 --- a/panda/src/bullet/bulletFilterCallbackData.h +++ b/panda/src/bullet/bulletFilterCallbackData.h @@ -1,16 +1,15 @@ -// Filename: bulletFilterCallbackData.h -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletFilterCallbackData.h + * @author enn0x + * @date 2012-11-26 + */ #ifndef __BULLET_FILTER_CALLBACK_DATA_H__ #define __BULLET_FILTER_CALLBACK_DATA_H__ @@ -22,14 +21,13 @@ #include "bullet_includes.h" #include "bullet_utils.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletFilterCallbackData -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletFilterCallbackData : public CallbackData { PUBLISHED: - INLINE BulletFilterCallbackData(PandaNode *node0, + INLINE BulletFilterCallbackData(PandaNode *node0, PandaNode *node1); INLINE PandaNode *get_node_0() const; @@ -43,14 +41,13 @@ private: PandaNode *_node1; bool _collide; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { CallbackData::init_type(); - register_type(_type_handle, "BulletFilterCallbackData", + register_type(_type_handle, "BulletFilterCallbackData", CallbackData::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletGenericConstraint.I b/panda/src/bullet/bulletGenericConstraint.I index 80c20e4b7b..08ee24ccba 100644 --- a/panda/src/bullet/bulletGenericConstraint.I +++ b/panda/src/bullet/bulletGenericConstraint.I @@ -1,47 +1,39 @@ -// Filename: bulletGenericConstraint.I -// Created by: enn0x (02Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGenericConstraint.I + * @author enn0x + * @date 2010-03-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletGenericConstraint:: ~BulletGenericConstraint() { delete _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_frame_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletGenericConstraint:: get_frame_a() const { return btTrans_to_TransformState(_constraint->getFrameOffsetA()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_frame_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletGenericConstraint:: get_frame_b() const { return btTrans_to_TransformState(_constraint->getFrameOffsetB()); } - diff --git a/panda/src/bullet/bulletGenericConstraint.cxx b/panda/src/bullet/bulletGenericConstraint.cxx index 04b7757202..a68a345ce6 100644 --- a/panda/src/bullet/bulletGenericConstraint.cxx +++ b/panda/src/bullet/bulletGenericConstraint.cxx @@ -1,29 +1,26 @@ -// Filename: bulletGenericConstraint.cxx -// Created by: enn0x (02Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGenericConstraint.cxx + * @author enn0x + * @date 2010-03-02 + */ #include "bulletGenericConstraint.h" #include "bulletRigidBodyNode.h" TypeHandle BulletGenericConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletGenericConstraint:: -BulletGenericConstraint(const BulletRigidBodyNode *node_a, +BulletGenericConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a, bool use_frame_a) { @@ -33,11 +30,9 @@ BulletGenericConstraint(const BulletRigidBodyNode *node_a, _constraint = new btGeneric6DofConstraint(*ptr_a, trans_a, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletGenericConstraint:: BulletGenericConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -54,22 +49,18 @@ BulletGenericConstraint(const BulletRigidBodyNode *node_a, _constraint = new btGeneric6DofConstraint(*ptr_a, *ptr_b, trans_a, trans_b, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTypedConstraint *BulletGenericConstraint:: ptr() const { return _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_axis -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletGenericConstraint:: get_axis(int axis) const { @@ -80,11 +71,9 @@ get_axis(int axis) const { return btVector3_to_LVector3(_constraint->getAxis(axis)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_pivot -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletGenericConstraint:: get_pivot(int axis) const { @@ -95,11 +84,9 @@ get_pivot(int axis) const { return _constraint->getRelativePivotPosition(axis); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_angle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletGenericConstraint:: get_angle(int axis) const { @@ -110,11 +97,9 @@ get_angle(int axis) const { return _constraint->getAngle(axis); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::set_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGenericConstraint:: set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) { @@ -125,11 +110,9 @@ set_linear_limit(int axis, PN_stdfloat low, PN_stdfloat high) { _constraint->setLimit(axis, low, high); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::set_angular_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGenericConstraint:: set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) { @@ -143,33 +126,27 @@ set_angular_limit(int axis, PN_stdfloat low, PN_stdfloat high) { _constraint->setLimit(axis + 3, low, high); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_rotational_limit_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRotationalLimitMotor BulletGenericConstraint:: get_rotational_limit_motor(int axis) { return BulletRotationalLimitMotor(*_constraint->getRotationalLimitMotor(axis)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::get_translational_limit_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletTranslationalLimitMotor BulletGenericConstraint:: get_translational_limit_motor() { return BulletTranslationalLimitMotor(*_constraint->getTranslationalLimitMotor()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGenericConstraint::set_frames -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGenericConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { @@ -178,4 +155,3 @@ set_frames(const TransformState *ts_a, const TransformState *ts_b) { _constraint->setFrames(frame_a, frame_b); } - diff --git a/panda/src/bullet/bulletGenericConstraint.h b/panda/src/bullet/bulletGenericConstraint.h index 98bf3bce36..c43c2217be 100644 --- a/panda/src/bullet/bulletGenericConstraint.h +++ b/panda/src/bullet/bulletGenericConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletGenericConstraint.h -// Created by: enn0x (02Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGenericConstraint.h + * @author enn0x + * @date 2010-03-02 + */ #ifndef __BULLET_GENERIC_CONSTRAINT_H__ #define __BULLET_GENERIC_CONSTRAINT_H__ @@ -28,14 +27,13 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletGenericConstraint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletGenericConstraint : public BulletConstraint { PUBLISHED: - BulletGenericConstraint(const BulletRigidBodyNode *node_a, + BulletGenericConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a, bool use_frame_a); BulletGenericConstraint(const BulletRigidBodyNode *node_a, @@ -69,16 +67,15 @@ public: private: btGeneric6DofConstraint *_constraint; -//TODO btRotationalLimitMotor * getRotationalLimitMotor (int index) +// TODO btRotationalLimitMotor * getRotationalLimitMotor (int index) -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletConstraint::init_type(); - register_type(_type_handle, "BulletGenericConstraint", + register_type(_type_handle, "BulletGenericConstraint", BulletConstraint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletGhostNode.I b/panda/src/bullet/bulletGhostNode.I index 01dbf73e73..c4620097a8 100644 --- a/panda/src/bullet/bulletGhostNode.I +++ b/panda/src/bullet/bulletGhostNode.I @@ -1,45 +1,37 @@ -// Filename: bulletGhostNode.I -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGhostNode.I + * @author enn0x + * @date 2010-11-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletGhostNode:: ~BulletGhostNode() { delete _ghost; } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::get_num_overlapping_nodes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletGhostNode:: get_num_overlapping_nodes() const { return _ghost->getNumOverlappingObjects(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::get_overlapping_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletGhostNode:: get_overlapping_node(int idx) const { @@ -48,4 +40,3 @@ get_overlapping_node(int idx) const { btCollisionObject *object = _ghost->getOverlappingObject(idx); return (object) ? (PandaNode *)object->getUserPointer() : NULL; } - diff --git a/panda/src/bullet/bulletGhostNode.cxx b/panda/src/bullet/bulletGhostNode.cxx index d60278ff98..8f8c783943 100644 --- a/panda/src/bullet/bulletGhostNode.cxx +++ b/panda/src/bullet/bulletGhostNode.cxx @@ -1,27 +1,24 @@ -// Filename: bulletGhostNode.cxx -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGhostNode.cxx + * @author enn0x + * @date 2010-11-19 + */ #include "bulletGhostNode.h" #include "bulletShape.h" TypeHandle BulletGhostNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletGhostNode:: BulletGhostNode(const char *name) : BulletBodyNode(name) { @@ -42,22 +39,18 @@ BulletGhostNode(const char *name) : BulletBodyNode(name) { _ghost->setCollisionShape(_shape); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::get_object -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionObject *BulletGhostNode:: get_object() const { return _ghost; } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::parents_changed -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGhostNode:: parents_changed() { @@ -79,11 +72,9 @@ parents_changed() { _sync_local = false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::transform_changed -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGhostNode:: transform_changed() { @@ -114,22 +105,18 @@ transform_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::sync_p2b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGhostNode:: sync_p2b() { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletGhostNode::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletGhostNode:: sync_b2p() { @@ -149,4 +136,3 @@ sync_b2p() { _sync_disable = false; } } - diff --git a/panda/src/bullet/bulletGhostNode.h b/panda/src/bullet/bulletGhostNode.h index 2c0f5731af..3e8f2b6465 100644 --- a/panda/src/bullet/bulletGhostNode.h +++ b/panda/src/bullet/bulletGhostNode.h @@ -1,16 +1,15 @@ -// Filename: bulletGhostNode.h -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletGhostNode.h + * @author enn0x + * @date 2010-11-19 + */ #ifndef __BULLET_GHOST_NODE_H__ #define __BULLET_GHOST_NODE_H__ @@ -26,10 +25,9 @@ class BulletShape; -//////////////////////////////////////////////////////////////////// -// Class : BulletGhostNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletGhostNode : public BulletBodyNode { PUBLISHED: @@ -58,14 +56,13 @@ private: btPairCachingGhostObject *_ghost; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletBodyNode::init_type(); - register_type(_type_handle, "BulletGhostNode", + register_type(_type_handle, "BulletGhostNode", BulletBodyNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -83,4 +80,3 @@ private: #include "bulletGhostNode.I" #endif // __BULLET_GHOST_NODE_H__ - diff --git a/panda/src/bullet/bulletHeightfieldShape.I b/panda/src/bullet/bulletHeightfieldShape.I index 6803855a51..4794eab227 100644 --- a/panda/src/bullet/bulletHeightfieldShape.I +++ b/panda/src/bullet/bulletHeightfieldShape.I @@ -1,22 +1,19 @@ -// Filename: bulletHeightfieldShape.I -// Created by: enn0x (05Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHeightfieldShape.I + * @author enn0x + * @date 2010-02-05 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletHeightfieldShape:: ~BulletHeightfieldShape() { @@ -24,11 +21,9 @@ INLINE BulletHeightfieldShape:: delete _data; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletHeightfieldShape:: BulletHeightfieldShape(const BulletHeightfieldShape ©) : _shape(copy._shape), @@ -39,11 +34,9 @@ BulletHeightfieldShape(const BulletHeightfieldShape ©) : memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletHeightfieldShape:: operator = (const BulletHeightfieldShape ©) { @@ -54,4 +47,3 @@ operator = (const BulletHeightfieldShape ©) { _data = new float[_num_rows * _num_cols]; memcpy(_data, copy._data, _num_rows * _num_cols * sizeof(float)); } - diff --git a/panda/src/bullet/bulletHeightfieldShape.cxx b/panda/src/bullet/bulletHeightfieldShape.cxx index 3fe13c27fb..8952a1d1bc 100644 --- a/panda/src/bullet/bulletHeightfieldShape.cxx +++ b/panda/src/bullet/bulletHeightfieldShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletHeightfieldShape.cxx -// Created by: enn0x (05Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHeightfieldShape.cxx + * @author enn0x + * @date 2010-02-05 + */ #include "bulletHeightfieldShape.h" TypeHandle BulletHeightfieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletHeightfieldShape:: BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAxis up) { @@ -31,7 +28,7 @@ BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAx for (int row=0; row < _num_rows; row++) { for (int column=0; column < _num_cols; column++) { - _data[_num_cols * row + column] = + _data[_num_cols * row + column] = max_height * image.get_bright(column, _num_cols - row - 1); } } @@ -45,25 +42,20 @@ BulletHeightfieldShape(const PNMImage &image, PN_stdfloat max_height, BulletUpAx _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletHeightfieldShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHeightfieldShape::set_use_diamond_subdivision -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHeightfieldShape:: set_use_diamond_subdivision(bool flag) { return _shape->setUseDiamondSubdivision(flag); } - diff --git a/panda/src/bullet/bulletHeightfieldShape.h b/panda/src/bullet/bulletHeightfieldShape.h index 25031ab25a..495b6752f9 100644 --- a/panda/src/bullet/bulletHeightfieldShape.h +++ b/panda/src/bullet/bulletHeightfieldShape.h @@ -1,16 +1,15 @@ -// Filename: bulletHeightfieldShape.h -// Created by: enn0x (05Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHeightfieldShape.h + * @author enn0x + * @date 2010-02-05 + */ #ifndef __BULLET_HEIGHTFIELD_SHAPE_H__ #define __BULLET_HEIGHTFIELD_SHAPE_H__ @@ -23,10 +22,9 @@ #include "pnmImage.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletHeightfieldShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletHeightfieldShape : public BulletShape { PUBLISHED: @@ -46,14 +44,13 @@ private: float *_data; btHeightfieldTerrainShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletHeightfieldShape", + register_type(_type_handle, "BulletHeightfieldShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletHelper.I b/panda/src/bullet/bulletHelper.I index f4ca9456d0..51c4f4b830 100644 --- a/panda/src/bullet/bulletHelper.I +++ b/panda/src/bullet/bulletHelper.I @@ -1,23 +1,19 @@ -// Filename: bulletHelper.I -// Created by: enn0x (19Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHelper.I + * @author enn0x + * @date 2011-01-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::get_sb_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PT(InternalName) BulletHelper:: get_sb_index() { @@ -27,11 +23,9 @@ get_sb_index() { return _sb_index; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::get_sb_flip -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PT(InternalName) BulletHelper:: get_sb_flip() { diff --git a/panda/src/bullet/bulletHelper.cxx b/panda/src/bullet/bulletHelper.cxx index 61927dc24b..a12a773740 100644 --- a/panda/src/bullet/bulletHelper.cxx +++ b/panda/src/bullet/bulletHelper.cxx @@ -1,16 +1,15 @@ -// Filename: bulletHelper.cxx -// Created by: enn0x (19Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHelper.cxx + * @author enn0x + * @date 2011-01-19 + */ #include "bulletHelper.h" #include "bulletRigidBodyNode.h" @@ -23,11 +22,9 @@ PT(InternalName) BulletHelper::_sb_index; PT(InternalName) BulletHelper::_sb_flip; -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::from_collision_solids -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NodePathCollection BulletHelper:: from_collision_solids(NodePath &np, bool clear) { @@ -79,13 +76,10 @@ from_collision_solids(NodePath &np, bool clear) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::is_tangible -// Access: Private -// Description: Returns TRUE if at least one CollisionSolid of -// the given CollisionNode is tangible. Returns FALSE -// if all CollisionSolids are intangible. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if at least one CollisionSolid of the given CollisionNode is + * tangible. Returns FALSE if all CollisionSolids are intangible. + */ bool BulletHelper:: is_tangible(CollisionNode *cnode) { @@ -99,11 +93,9 @@ is_tangible(CollisionNode *cnode) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::add_sb_index_column -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(GeomVertexFormat) BulletHelper:: add_sb_index_column(const GeomVertexFormat *format) { @@ -126,11 +118,9 @@ add_sb_index_column(const GeomVertexFormat *format) { return registered_format; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::add_sb_flip_column -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(GeomVertexFormat) BulletHelper:: add_sb_flip_column(const GeomVertexFormat *format) { @@ -153,33 +143,27 @@ add_sb_flip_column(const GeomVertexFormat *format) { return registered_format; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::make_geom_from_faces -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(Geom) BulletHelper:: make_geom_from_faces(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool two_sided) { return make_geom(node, format, two_sided, true); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::make_geom_from_links -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(Geom) BulletHelper:: make_geom_from_links(BulletSoftBodyNode *node, const GeomVertexFormat *format) { return make_geom(node, format, false, false); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::make_geom -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(Geom) BulletHelper:: make_geom(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool two_sided, bool use_faces) { @@ -282,11 +266,9 @@ make_geom(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool two_sid return geom; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHelper::make_texcoords_for_patch -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHelper:: make_texcoords_for_patch(Geom *geom, int resx, int resy) { @@ -316,4 +298,3 @@ make_texcoords_for_patch(Geom *geom, int resx, int resy) { i++; } } - diff --git a/panda/src/bullet/bulletHelper.h b/panda/src/bullet/bulletHelper.h index 328ac22f15..5b3aaf6152 100644 --- a/panda/src/bullet/bulletHelper.h +++ b/panda/src/bullet/bulletHelper.h @@ -1,16 +1,15 @@ -// Filename: bulletHelper.h -// Created by: enn0x (19Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHelper.h + * @author enn0x + * @date 2011-01-19 + */ #ifndef __BULLET_HELPER_H__ #define __BULLET_HELPER_H__ @@ -24,10 +23,9 @@ #include "nodePath.h" #include "nodePathCollection.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletHelper -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletHelper { PUBLISHED: @@ -44,7 +42,7 @@ PUBLISHED: static CPT(GeomVertexFormat) add_sb_flip_column(const GeomVertexFormat *format); // Geom utils - static PT(Geom) make_geom_from_faces(BulletSoftBodyNode *node, + static PT(Geom) make_geom_from_faces(BulletSoftBodyNode *node, const GeomVertexFormat *format=NULL, bool two_sided=false); @@ -59,7 +57,7 @@ private: static bool is_tangible(CollisionNode *cnode); - static PT(Geom) make_geom(BulletSoftBodyNode *node, + static PT(Geom) make_geom(BulletSoftBodyNode *node, const GeomVertexFormat *format, bool use_faces, bool two_sided); diff --git a/panda/src/bullet/bulletHingeConstraint.I b/panda/src/bullet/bulletHingeConstraint.I index 9609f421a0..01614f603a 100644 --- a/panda/src/bullet/bulletHingeConstraint.I +++ b/panda/src/bullet/bulletHingeConstraint.I @@ -1,47 +1,39 @@ -// Filename: bulletHingeConstraint.I -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHingeConstraint.I + * @author enn0x + * @date 2010-03-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletHingeConstraint:: ~BulletHingeConstraint() { delete _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_frame_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletHingeConstraint:: get_frame_a() const { return btTrans_to_TransformState(_constraint->getAFrame()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_frame_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletHingeConstraint:: get_frame_b() const { return btTrans_to_TransformState(_constraint->getBFrame()); } - diff --git a/panda/src/bullet/bulletHingeConstraint.cxx b/panda/src/bullet/bulletHingeConstraint.cxx index 8976c23126..a262be88e8 100644 --- a/panda/src/bullet/bulletHingeConstraint.cxx +++ b/panda/src/bullet/bulletHingeConstraint.cxx @@ -1,16 +1,15 @@ -// Filename: bulletHingeConstraint.cxx -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHingeConstraint.cxx + * @author enn0x + * @date 2010-03-01 + */ #include "bulletHingeConstraint.h" #include "bulletRigidBodyNode.h" @@ -19,14 +18,12 @@ TypeHandle BulletHingeConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::Constructor -// Access: Published -// Description: Creates a hinge constraint which connects one -// rigid body with some fixe dpoint in the world. -//////////////////////////////////////////////////////////////////// +/** + * Creates a hinge constraint which connects one rigid body with some fixe + * dpoint in the world. + */ BulletHingeConstraint:: -BulletHingeConstraint(const BulletRigidBodyNode *node_a, +BulletHingeConstraint(const BulletRigidBodyNode *node_a, const TransformState *ts_a, bool use_frame_a) { @@ -36,12 +33,9 @@ BulletHingeConstraint(const BulletRigidBodyNode *node_a, _constraint = new btHingeConstraint(*ptr_a, frame_a, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::Constructor -// Access: Published -// Description: Constructs a hinge constraint which connects two -// rigid bodies. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a hinge constraint which connects two rigid bodies. + */ BulletHingeConstraint:: BulletHingeConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -58,16 +52,13 @@ BulletHingeConstraint(const BulletRigidBodyNode *node_a, _constraint = new btHingeConstraint(*ptr_a, *ptr_b, frame_a, frame_b, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::Constructor -// Access: Published -// Description: Creates a hinge constraint in the same way as the -// other constructor, but uses the world as second -// body so that node_a is fixed to some point in -// mid-air for example. -//////////////////////////////////////////////////////////////////// +/** + * Creates a hinge constraint in the same way as the other constructor, but + * uses the world as second body so that node_a is fixed to some point in mid- + * air for example. + */ BulletHingeConstraint:: -BulletHingeConstraint(const BulletRigidBodyNode *node_a, +BulletHingeConstraint(const BulletRigidBodyNode *node_a, const LPoint3 &pivot_a, const LVector3 &axis_a, bool use_frame_a) { @@ -79,17 +70,13 @@ BulletHingeConstraint(const BulletRigidBodyNode *node_a, _constraint = new btHingeConstraint(*ptr_a, pos_a, vec_a, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::Constructor -// Access: Published -// Description: Creates a hinge connecting node_a to node_b. The -// pivot point is the point at which the body is fixed -// to the constraint. In other words: It specifies -// where on each body the rotation axis should be. This -// axis is specified using axis_a and axis_b. -// Remember, everything is specified in the bodies own -// coordinate system! -//////////////////////////////////////////////////////////////////// +/** + * Creates a hinge connecting node_a to node_b. The pivot point is the point + * at which the body is fixed to the constraint. In other words: It specifies + * where on each body the rotation axis should be. This axis is specified + * using axis_a and axis_b. Remember, everything is specified in the bodies + * own coordinate system! + */ BulletHingeConstraint:: BulletHingeConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -110,45 +97,36 @@ BulletHingeConstraint(const BulletRigidBodyNode *node_a, _constraint = new btHingeConstraint(*ptr_a, *ptr_b, pos_a, pos_b, vec_a, vec_b, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTypedConstraint *BulletHingeConstraint:: ptr() const { return _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_angular_only -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHingeConstraint:: set_angular_only(bool value) { return _constraint->setAngularOnly(value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_angular_only -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletHingeConstraint:: get_angular_only() const { return _constraint->getAngularOnly(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_limit -// Access: Published -// Description: Sets the lower and upper rotational limits in -// degrees. -//////////////////////////////////////////////////////////////////// +/** + * Sets the lower and upper rotational limits in degrees. + */ void BulletHingeConstraint:: set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat bias, PN_stdfloat relaxation) { @@ -158,12 +136,9 @@ set_limit(PN_stdfloat low, PN_stdfloat high, PN_stdfloat softness, PN_stdfloat b _constraint->setLimit(low, high, softness, bias, relaxation); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_axis -// Access: Published -// Description: Sets the hinge's rotation axis in world -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the hinge's rotation axis in world coordinates. + */ void BulletHingeConstraint:: set_axis(const LVector3 &axis) { @@ -173,107 +148,86 @@ set_axis(const LVector3 &axis) { _constraint->setAxis(v); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_lower_limit -// Access: Published -// Description: Returns the lower angular limit in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the lower angular limit in degrees. + */ PN_stdfloat BulletHingeConstraint:: get_lower_limit() const { return rad_2_deg(_constraint->getLowerLimit()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_upper_limit -// Access: Published -// Description: Returns the upper angular limit in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the upper angular limit in degrees. + */ PN_stdfloat BulletHingeConstraint:: get_upper_limit() const { return rad_2_deg(_constraint->getUpperLimit()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::get_hinge_angle -// Access: Published -// Description: Returns the angle between node_a and node_b in -// degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle between node_a and node_b in degrees. + */ PN_stdfloat BulletHingeConstraint:: get_hinge_angle() { return rad_2_deg(_constraint->getHingeAngle()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::enable_angular_motor -// Access: Published -// Description: Applies an impulse to the constraint so that the -// angle changes at target_velocity where max_impulse -// is the maximum impulse that is used for achieving -// the specified velocity. -// -// Note that the target_velocity is in radians/second, -// not degrees. -//////////////////////////////////////////////////////////////////// +/** + * Applies an impulse to the constraint so that the angle changes at + * target_velocity where max_impulse is the maximum impulse that is used for + * achieving the specified velocity. + * + * Note that the target_velocity is in radians/second, not degrees. + */ void BulletHingeConstraint:: enable_angular_motor(bool enable, PN_stdfloat target_velocity, PN_stdfloat max_impulse) { _constraint->enableAngularMotor(enable, target_velocity, max_impulse); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::enable_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHingeConstraint:: enable_motor(bool enable) { _constraint->enableMotor(enable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_max_motor_impulse -// Access: Published -// Description: Sets the maximum impulse used to achieve the -// velocity set in enable_angular_motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum impulse used to achieve the velocity set in + * enable_angular_motor. + */ void BulletHingeConstraint:: set_max_motor_impulse(PN_stdfloat max_impulse) { _constraint->setMaxMotorImpulse(max_impulse); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_motor_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHingeConstraint:: set_motor_target(const LQuaternion &quat, PN_stdfloat dt) { _constraint->setMotorTarget(LQuaternion_to_btQuat(quat), dt); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_motor_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHingeConstraint:: set_motor_target(PN_stdfloat target_angle, PN_stdfloat dt) { _constraint->setMotorTarget(target_angle, dt); } -//////////////////////////////////////////////////////////////////// -// Function: BulletHingeConstraint::set_frames -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletHingeConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { @@ -282,4 +236,3 @@ set_frames(const TransformState *ts_a, const TransformState *ts_b) { _constraint->setFrames(frame_a, frame_b); } - diff --git a/panda/src/bullet/bulletHingeConstraint.h b/panda/src/bullet/bulletHingeConstraint.h index 8036e3cb14..e5d5228454 100644 --- a/panda/src/bullet/bulletHingeConstraint.h +++ b/panda/src/bullet/bulletHingeConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletHingeConstraint.h -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletHingeConstraint.h + * @author enn0x + * @date 2010-03-01 + */ #ifndef __BULLET_HINGE_CONSTRAINT_H__ #define __BULLET_HINGE_CONSTRAINT_H__ @@ -25,16 +24,14 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletHingeConstraint -// Description : The hinge constraint lets two bodies rotate around -// a given axis while adhering to specified limits. -// It's motor can apply angular force to them. -//////////////////////////////////////////////////////////////////// +/** + * The hinge constraint lets two bodies rotate around a given axis while + * adhering to specified limits. It's motor can apply angular force to them. + */ class EXPCL_PANDABULLET BulletHingeConstraint : public BulletConstraint { PUBLISHED: - BulletHingeConstraint(const BulletRigidBodyNode *node_a, + BulletHingeConstraint(const BulletRigidBodyNode *node_a, const LPoint3 &pivot_a, const LVector3 &axis_a, bool use_frame_a=false); @@ -46,7 +43,7 @@ PUBLISHED: const LVector3 &axis_b, bool use_frame_a=false); - BulletHingeConstraint(const BulletRigidBodyNode *node_a, + BulletHingeConstraint(const BulletRigidBodyNode *node_a, const TransformState *ts_a, bool use_frame_a=false); BulletHingeConstraint(const BulletRigidBodyNode *node_a, @@ -82,14 +79,13 @@ public: private: btHingeConstraint *_constraint; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletConstraint::init_type(); - register_type(_type_handle, "BulletHingeConstraint", + register_type(_type_handle, "BulletHingeConstraint", BulletConstraint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletManifoldPoint.I b/panda/src/bullet/bulletManifoldPoint.I index e99c2060ca..0086f3020b 100644 --- a/panda/src/bullet/bulletManifoldPoint.I +++ b/panda/src/bullet/bulletManifoldPoint.I @@ -1,277 +1,227 @@ -// Filename: bulletManifoldPoint.I -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletManifoldPoint.I + * @author enn0x + * @date 2010-03-07 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletManifoldPoint:: ~BulletManifoldPoint() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_lateral_friction_initialized -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_lateral_friction_initialized(bool value) { _pt.m_lateralFrictionInitialized = value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_lateral_friction_initialized -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletManifoldPoint:: get_lateral_friction_initialized() const { return _pt.m_lateralFrictionInitialized; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_lateral_friction_dir1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_lateral_friction_dir1(const LVecBase3 &dir) { _pt.m_lateralFrictionDir1 = LVecBase3_to_btVector3(dir); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_lateral_friction_dir1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletManifoldPoint:: get_lateral_friction_dir1() const { return btVector3_to_LVector3(_pt.m_lateralFrictionDir1); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_lateral_friction_dir2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_lateral_friction_dir2(const LVecBase3 &dir) { _pt.m_lateralFrictionDir2 = LVecBase3_to_btVector3(dir); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_lateral_friction_dir2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletManifoldPoint:: get_lateral_friction_dir2() const { return btVector3_to_LVector3(_pt.m_lateralFrictionDir2); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_contact_motion1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_contact_motion1(PN_stdfloat value) { _pt.m_contactMotion1 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_contact_motion1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_contact_motion1() const { return (PN_stdfloat)_pt.m_contactMotion1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_contact_motion2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_contact_motion2(PN_stdfloat value) { _pt.m_contactMotion2 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_contact_motion2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_contact_motion2() const { return (PN_stdfloat)_pt.m_contactMotion2; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_combined_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_combined_friction(PN_stdfloat value) { _pt.m_combinedFriction = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_combined_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_combined_friction() const { return (PN_stdfloat)_pt.m_combinedFriction; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_combined_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_combined_restitution(PN_stdfloat value) { _pt.m_combinedRestitution = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_combined_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_combined_restitution() const { return (PN_stdfloat)_pt.m_combinedRestitution; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_applied_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_applied_impulse(PN_stdfloat value) { _pt.m_appliedImpulse = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_applied_impulse_lateral1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_applied_impulse_lateral1(PN_stdfloat value) { _pt.m_appliedImpulseLateral1 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_applied_impulse_lateral1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_applied_impulse_lateral1() const { return (PN_stdfloat)_pt.m_appliedImpulseLateral1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_applied_impulse_lateral2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_applied_impulse_lateral2(PN_stdfloat value) { _pt.m_appliedImpulseLateral2 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_applied_impulse_lateral2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_applied_impulse_lateral2() const { return (PN_stdfloat)_pt.m_appliedImpulseLateral2; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_contact_cfm1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_contact_cfm1(PN_stdfloat value) { _pt.m_contactCFM1 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_contact_cfm1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_contact_cfm1() const { return (PN_stdfloat)_pt.m_contactCFM1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::set_contact_cfm2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletManifoldPoint:: set_contact_cfm2(PN_stdfloat value) { _pt.m_contactCFM2 = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_contact_cfm2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletManifoldPoint:: get_contact_cfm2() const { return (PN_stdfloat)_pt.m_contactCFM2; } - diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx index 918240e43e..05ec4e8b87 100644 --- a/panda/src/bullet/bulletManifoldPoint.cxx +++ b/panda/src/bullet/bulletManifoldPoint.cxx @@ -1,182 +1,150 @@ -// Filename: bulletManifoldPoint.cxx -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletManifoldPoint.cxx + * @author enn0x + * @date 2010-03-07 + */ #include "bulletManifoldPoint.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletManifoldPoint:: -BulletManifoldPoint(btManifoldPoint &pt) +BulletManifoldPoint(btManifoldPoint &pt) : _pt(pt) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletManifoldPoint:: -BulletManifoldPoint(const BulletManifoldPoint &other) +BulletManifoldPoint(const BulletManifoldPoint &other) : _pt(other._pt) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletManifoldPoint& BulletManifoldPoint:: operator=(const BulletManifoldPoint& other) { - + this->_pt = other._pt; return *this; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_lift_time -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletManifoldPoint:: get_life_time() const { return _pt.getLifeTime(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletManifoldPoint:: get_distance() const { return (PN_stdfloat)_pt.getDistance(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_applied_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletManifoldPoint:: get_applied_impulse() const { return (PN_stdfloat)_pt.getAppliedImpulse(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_position_world_on_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletManifoldPoint:: get_position_world_on_a() const { return btVector3_to_LPoint3(_pt.getPositionWorldOnA()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_position_world_on_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletManifoldPoint:: get_position_world_on_b() const { return btVector3_to_LPoint3(_pt.getPositionWorldOnB()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_normal_world_on_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletManifoldPoint:: get_normal_world_on_b() const { return btVector3_to_LPoint3(_pt.m_normalWorldOnB); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_local_point_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletManifoldPoint:: get_local_point_a() const { return btVector3_to_LPoint3(_pt.m_localPointA); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_local_point_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletManifoldPoint:: get_local_point_b() const { return btVector3_to_LPoint3(_pt.m_localPointB); } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_part_id0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletManifoldPoint:: get_part_id0() const { return _pt.m_partId0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_part_id1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletManifoldPoint:: get_part_id1() const { return _pt.m_partId1; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_index0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletManifoldPoint:: get_index0() const { return _pt.m_index0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletManifoldPoint::get_index1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletManifoldPoint:: get_index1() const { return _pt.m_index1; } - diff --git a/panda/src/bullet/bulletManifoldPoint.h b/panda/src/bullet/bulletManifoldPoint.h index 672a8db282..0488272885 100644 --- a/panda/src/bullet/bulletManifoldPoint.h +++ b/panda/src/bullet/bulletManifoldPoint.h @@ -1,16 +1,15 @@ -// Filename: bulletManifoldPoint.h -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletManifoldPoint.h + * @author enn0x + * @date 2010-03-07 + */ #ifndef __BULLET_MANIFOLD_POINT_H__ #define __BULLET_MANIFOLD_POINT_H__ @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletManifoldPoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletManifoldPoint { PUBLISHED: diff --git a/panda/src/bullet/bulletMinkowskiSumShape.I b/panda/src/bullet/bulletMinkowskiSumShape.I index c0f718fbf9..07f96a74fb 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.I +++ b/panda/src/bullet/bulletMinkowskiSumShape.I @@ -1,33 +1,28 @@ -// Filename: bulletMinkowskiSumShape.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMinkowskiSumShape.I + * @author enn0x + * @date 2010-01-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletMinkowskiSumShape:: ~BulletMinkowskiSumShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletMinkowskiSumShape:: BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) : _shape(copy._shape), @@ -35,11 +30,9 @@ BulletMinkowskiSumShape(const BulletMinkowskiSumShape ©) : _shape_b(copy._shape_b) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletMinkowskiSumShape:: operator = (const BulletMinkowskiSumShape ©) { _shape = copy._shape; @@ -47,11 +40,9 @@ operator = (const BulletMinkowskiSumShape ©) { _shape_b = copy._shape_b; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::set_transform_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletMinkowskiSumShape:: set_transform_a(const TransformState *ts) { @@ -59,11 +50,9 @@ set_transform_a(const TransformState *ts) { _shape->setTransformA(TransformState_to_btTrans(ts)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::set_transform_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletMinkowskiSumShape:: set_transform_b(const TransformState *ts) { @@ -71,58 +60,47 @@ set_transform_b(const TransformState *ts) { _shape->setTransformB(TransformState_to_btTrans(ts)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::get_transform_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletMinkowskiSumShape:: get_transform_a() const { return btTrans_to_TransformState(_shape->getTransformA()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::get_transform_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletMinkowskiSumShape:: get_transform_b() const { return btTrans_to_TransformState(_shape->GetTransformB()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::get_shape_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const BulletShape *BulletMinkowskiSumShape:: get_shape_a() const { return _shape_a; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::get_shape_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const BulletShape *BulletMinkowskiSumShape:: get_shape_b() const { return _shape_b; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::get_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletMinkowskiSumShape:: get_margin() const { return (PN_stdfloat)_shape->getMargin(); } - diff --git a/panda/src/bullet/bulletMinkowskiSumShape.cxx b/panda/src/bullet/bulletMinkowskiSumShape.cxx index 0b95ea9736..a4382eee52 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.cxx +++ b/panda/src/bullet/bulletMinkowskiSumShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletMinkowskiSumShape.cxx -// Created by: enn0x (15Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMinkowskiSumShape.cxx + * @author enn0x + * @date 2013-08-15 + */ #include "bulletMinkowskiSumShape.h" TypeHandle BulletMinkowskiSumShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletMinkowskiSumShape:: BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b) { @@ -37,14 +34,11 @@ BulletMinkowskiSumShape(const BulletShape *shape_a, const BulletShape *shape_b) _shape_b = shape_b; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMinkowskiSumShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletMinkowskiSumShape:: ptr() const { return _shape; } - diff --git a/panda/src/bullet/bulletMinkowskiSumShape.h b/panda/src/bullet/bulletMinkowskiSumShape.h index 8b0eb0ecbe..3b6aa6bc1f 100644 --- a/panda/src/bullet/bulletMinkowskiSumShape.h +++ b/panda/src/bullet/bulletMinkowskiSumShape.h @@ -1,16 +1,15 @@ -// Filename: bulletMinkowskiSumShape.h -// Created by: enn0x (15Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMinkowskiSumShape.h + * @author enn0x + * @date 2013-08-15 + */ #ifndef __BULLET_MINKOWSKI_SUM_SHAPE_H__ #define __BULLET_MINKOWSKI_SUM_SHAPE_H__ @@ -23,10 +22,9 @@ #include "transformState.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletMinkowskiSumShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletMinkowskiSumShape : public BulletShape { PUBLISHED: @@ -54,14 +52,13 @@ private: CPT(BulletShape) _shape_a; CPT(BulletShape) _shape_b; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletMinkowskiSumShape", + register_type(_type_handle, "BulletMinkowskiSumShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletMultiSphereShape.I b/panda/src/bullet/bulletMultiSphereShape.I index 2a62c875cd..1024dce7dc 100644 --- a/panda/src/bullet/bulletMultiSphereShape.I +++ b/panda/src/bullet/bulletMultiSphereShape.I @@ -1,64 +1,53 @@ -// Filename: bulletMultiSphereShape.I -// Created by: enn0x (04Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMultiSphereShape.I + * @author enn0x + * @date 2012-01-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletMultiSphereShape:: ~BulletMultiSphereShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletMultiSphereShape:: BulletMultiSphereShape(const BulletMultiSphereShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletMultiSphereShape:: operator = (const BulletMultiSphereShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::get_sphere_count -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletMultiSphereShape:: get_sphere_count() const { return _shape->getSphereCount(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::get_sphere_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 BulletMultiSphereShape:: get_sphere_pos(int index) const { @@ -66,15 +55,12 @@ get_sphere_pos(int index) const { return btVector3_to_LPoint3(_shape->getSpherePosition(index)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::get_sphere_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletMultiSphereShape:: get_sphere_radius(int index) const { nassertr(index >=0 && index <_shape->getSphereCount(), 0.0); return (PN_stdfloat)_shape->getSphereRadius(index); } - diff --git a/panda/src/bullet/bulletMultiSphereShape.cxx b/panda/src/bullet/bulletMultiSphereShape.cxx index 3c6951340e..52e2f16c7d 100644 --- a/panda/src/bullet/bulletMultiSphereShape.cxx +++ b/panda/src/bullet/bulletMultiSphereShape.cxx @@ -1,16 +1,15 @@ -// Filename: bulletMultiSphereShape.cxx -// Created by: enn0x (05Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMultiSphereShape.cxx + * @author enn0x + * @date 2012-01-05 + */ #include "bulletMultiSphereShape.h" @@ -18,11 +17,9 @@ TypeHandle BulletMultiSphereShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletMultiSphereShape:: BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) { @@ -45,14 +42,11 @@ BulletMultiSphereShape(const PTA_LVecBase3 &points, const PTA_stdfloat &radii) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletMultiSphereShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletMultiSphereShape:: ptr() const { return _shape; } - diff --git a/panda/src/bullet/bulletMultiSphereShape.h b/panda/src/bullet/bulletMultiSphereShape.h index b826d51232..b3a55bd5e3 100644 --- a/panda/src/bullet/bulletMultiSphereShape.h +++ b/panda/src/bullet/bulletMultiSphereShape.h @@ -1,16 +1,15 @@ -// Filename: bulletMultiSphereShape.h -// Created by: enn0x (04Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletMultiSphereShape.h + * @author enn0x + * @date 2012-01-04 + */ #ifndef __BULLET_MULTI_SPHERE_SHAPE_H__ #define __BULLET_MULTI_SPHERE_SHAPE_H__ @@ -23,10 +22,9 @@ #include "pta_LVecBase3.h" #include "pta_stdfloat.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletMultiSphereShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletMultiSphereShape : public BulletShape { PUBLISHED: @@ -45,14 +43,13 @@ public: private: btMultiSphereShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletMultiSphereShape", + register_type(_type_handle, "BulletMultiSphereShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletPersistentManifold.I b/panda/src/bullet/bulletPersistentManifold.I index 70fc7bd7ef..2e7cef2019 100644 --- a/panda/src/bullet/bulletPersistentManifold.I +++ b/panda/src/bullet/bulletPersistentManifold.I @@ -1,24 +1,20 @@ -// Filename: bulletPersistentManifold.I -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPersistentManifold.I + * @author enn0x + * @date 2010-03-07 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletPersistentManifold:: ~BulletPersistentManifold() { } - diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index f356f6efe0..3a4024f8d2 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -1,68 +1,57 @@ -// Filename: bulletPersistentManifold.cxx -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPersistentManifold.cxx + * @author enn0x + * @date 2010-03-07 + */ #include "bulletPersistentManifold.h" #include "bulletManifoldPoint.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletPersistentManifold:: BulletPersistentManifold(btPersistentManifold *manifold) : _manifold(manifold) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_contact_breaking_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletPersistentManifold:: get_contact_breaking_threshold() const { return (PN_stdfloat)_manifold->getContactBreakingThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_contact_processing_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletPersistentManifold:: get_contact_processing_threshold() const { return (PN_stdfloat)_manifold->getContactProcessingThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::set_suspension_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletPersistentManifold:: clear_manifold() { _manifold->clearManifold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_node0 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *BulletPersistentManifold:: get_node0() { @@ -75,11 +64,9 @@ get_node0() { return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_node1 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *BulletPersistentManifold:: get_node1() { @@ -92,22 +79,18 @@ get_node1() { return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_num_manifold_points -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletPersistentManifold:: get_num_manifold_points() const { return _manifold->getNumContacts(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPersistentManifold::get_manifold_point -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletManifoldPoint *BulletPersistentManifold:: get_manifold_point(int idx) const { @@ -115,4 +98,3 @@ get_manifold_point(int idx) const { return new BulletManifoldPoint(_manifold->getContactPoint(idx)); } - diff --git a/panda/src/bullet/bulletPersistentManifold.h b/panda/src/bullet/bulletPersistentManifold.h index ee976739c9..2878d0b7ed 100644 --- a/panda/src/bullet/bulletPersistentManifold.h +++ b/panda/src/bullet/bulletPersistentManifold.h @@ -1,16 +1,15 @@ -// Filename: bulletPersistentManifold.h -// Created by: enn0x (07Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPersistentManifold.h + * @author enn0x + * @date 2010-03-07 + */ #ifndef __BULLET_PERSISTENT_MANIFOLD_H__ #define __BULLET_PERSISTENT_MANIFOLD_H__ @@ -23,10 +22,9 @@ class BulletManifoldPoint; -//////////////////////////////////////////////////////////////////// -// Class : BulletPersistentManifold -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletPersistentManifold { PUBLISHED: diff --git a/panda/src/bullet/bulletPlaneShape.I b/panda/src/bullet/bulletPlaneShape.I index 9675702977..f6a4c1e752 100644 --- a/panda/src/bullet/bulletPlaneShape.I +++ b/panda/src/bullet/bulletPlaneShape.I @@ -1,67 +1,55 @@ -// Filename: bulletPlaneShape.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPlaneShape.I + * @author enn0x + * @date 2010-01-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletPlaneShape:: ~BulletPlaneShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletPlaneShape:: BulletPlaneShape(const BulletPlaneShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletPlaneShape:: operator = (const BulletPlaneShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::get_plane_constant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletPlaneShape:: get_plane_constant() const { return (PN_stdfloat)_shape->getPlaneConstant(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::get_plane_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletPlaneShape:: get_plane_normal() const { return btVector3_to_LVector3(_shape->getPlaneNormal()); } - diff --git a/panda/src/bullet/bulletPlaneShape.cxx b/panda/src/bullet/bulletPlaneShape.cxx index 0cfa590ee1..5b74f0caae 100644 --- a/panda/src/bullet/bulletPlaneShape.cxx +++ b/panda/src/bullet/bulletPlaneShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletPlaneShape.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPlaneShape.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bulletPlaneShape.h" TypeHandle BulletPlaneShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletPlaneShape:: BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant) { @@ -30,22 +27,18 @@ BulletPlaneShape(const LVector3 &normal, PN_stdfloat constant) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletPlaneShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::make_from_solid -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletPlaneShape *BulletPlaneShape:: make_from_solid(const CollisionPlane *solid) { @@ -55,23 +48,18 @@ make_from_solid(const CollisionPlane *solid) { return new BulletPlaneShape(normal, constant); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletShape. + */ void BulletPlaneShape:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletPlaneShape:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_margin()); @@ -79,14 +67,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_plane_constant()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletPlaneShape:: make_from_bam(const FactoryParams ¶ms) { BulletPlaneShape *param = new BulletPlaneShape; @@ -99,13 +84,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletPlaneShape::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletShape. + */ void BulletPlaneShape:: fillin(DatagramIterator &scan, BamReader *manager) { nassertv(_shape == NULL); @@ -121,4 +103,3 @@ fillin(DatagramIterator &scan, BamReader *manager) { _shape->setUserPointer(this); _shape->setMargin(margin); } - diff --git a/panda/src/bullet/bulletPlaneShape.h b/panda/src/bullet/bulletPlaneShape.h index 545289fcc6..44a8e9ede6 100644 --- a/panda/src/bullet/bulletPlaneShape.h +++ b/panda/src/bullet/bulletPlaneShape.h @@ -1,16 +1,15 @@ -// Filename: bulletPlaneShape.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletPlaneShape.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_PLANE_SHAPE_H__ #define __BULLET_PLANE_SHAPE_H__ @@ -24,10 +23,9 @@ #include "collisionPlane.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletPlaneShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletPlaneShape : public BulletShape { private: // Only used by make_from_bam @@ -64,7 +62,7 @@ public: } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletPlaneShape", + register_type(_type_handle, "BulletPlaneShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletRigidBodyNode.I b/panda/src/bullet/bulletRigidBodyNode.I index 0c67ae06c7..6be1af948f 100644 --- a/panda/src/bullet/bulletRigidBodyNode.I +++ b/panda/src/bullet/bulletRigidBodyNode.I @@ -1,23 +1,19 @@ -// Filename: bulletRigidBodyNode.I -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRigidBodyNode.I + * @author enn0x + * @date 2010-11-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletRigidBodyNode:: ~BulletRigidBodyNode() { @@ -25,47 +21,38 @@ INLINE BulletRigidBodyNode:: delete _motion; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_linear_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRigidBodyNode:: set_linear_damping(PN_stdfloat value) { _rigid->setDamping(value, _rigid->getAngularDamping()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_angular_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRigidBodyNode:: set_angular_damping(PN_stdfloat value) { _rigid->setDamping(_rigid->getLinearDamping(), value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_linear_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletRigidBodyNode:: get_linear_damping() const { return (PN_stdfloat)_rigid->getLinearDamping(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_angular_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletRigidBodyNode:: get_angular_damping() const { return (PN_stdfloat)_rigid->getAngularDamping(); } - diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index 718f83237d..cc5f5945f5 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -1,27 +1,24 @@ -// Filename: bulletRigidBodyNode.cxx -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRigidBodyNode.cxx + * @author enn0x + * @date 2010-11-19 + */ #include "bulletRigidBodyNode.h" #include "bulletShape.h" TypeHandle BulletRigidBodyNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRigidBodyNode:: BulletRigidBodyNode(const char *name) : BulletBodyNode(name) { @@ -49,11 +46,9 @@ BulletRigidBodyNode(const char *name) : BulletBodyNode(name) { _rigid->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: output(ostream &out) const { @@ -62,25 +57,20 @@ output(ostream &out) const { out << " mass=" << get_mass(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionObject *BulletRigidBodyNode:: get_object() const { return _rigid; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::shape_changed -// Access: Published -// Description: Hook which should be called whenever the total -// shape of a body changed. Used for example to update -// the mass properties (inertia) of a rigid body. -// The default implementation does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Hook which should be called whenever the total shape of a body changed. + * Used for example to update the mass properties (inertia) of a rigid body. + * The default implementation does nothing. + */ void BulletRigidBodyNode:: shape_changed() { @@ -88,15 +78,12 @@ shape_changed() { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_mass -// Access: Published -// Description: Sets the mass of a rigid body. This also modifies -// the inertia, which is automatically computed from -// the shape of the body. Setting a value of zero -// for mass will make the body static. A value of -// zero can be considered an infinite mass. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mass of a rigid body. This also modifies the inertia, which is + * automatically computed from the shape of the body. Setting a value of zero + * for mass will make the body static. A value of zero can be considered an + * infinite mass. + */ void BulletRigidBodyNode:: set_mass(PN_stdfloat mass) { @@ -111,13 +98,10 @@ set_mass(PN_stdfloat mass) { _rigid->updateInertiaTensor(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_mass -// Access: Published -// Description: Returns the total mass of a rigid body. -// A value of zero means that the body is staic, i.e. -// has an infinite mass. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total mass of a rigid body. A value of zero means that the + * body is staic, i.e. has an infinite mass. + */ PN_stdfloat BulletRigidBodyNode:: get_mass() const { @@ -127,33 +111,25 @@ get_mass() const { return mass; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_inv_mass -// Access: Published -// Description: Returns the inverse mass of a rigid body. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse mass of a rigid body. + */ PN_stdfloat BulletRigidBodyNode:: get_inv_mass() const { return (PN_stdfloat)_rigid->getInvMass(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_inertia -// Access: Published -// Description: Sets the inertia of a rigid body. Inertia is given -// as a three-component vector. A component value of -// zero means infinite inertia along this direction. -// Setting the intertia will override the value which -// is automatically calculated from the rigid bodies -// shape. However, it is possible that automatic -// calculation of intertia is trigger after calling -// this method, and thus overwriting the explicitly -// set value again. This happens when: -// (a) the mass is set after the inertia. -// (b) a shape is added or removed from the body. -// (c) the scale of the body changed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the inertia of a rigid body. Inertia is given as a three-component + * vector. A component value of zero means infinite inertia along this + * direction. Setting the intertia will override the value which is + * automatically calculated from the rigid bodies shape. However, it is + * possible that automatic calculation of intertia is trigger after calling + * this method, and thus overwriting the explicitly set value again. This + * happens when: (a) the mass is set after the inertia. (b) a shape is added + * or removed from the body. (c) the scale of the body changed. + */ void BulletRigidBodyNode:: set_inertia(const LVecBase3 &inertia) { @@ -167,14 +143,11 @@ set_inertia(const LVecBase3 &inertia) { _rigid->updateInertiaTensor(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_inertia -// Access: Published -// Description: Returns the inertia of the rigid body. Inertia is -// given as a three component vector. A component -// value of zero means infinite inertia along this -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inertia of the rigid body. Inertia is given as a three + * component vector. A component value of zero means infinite inertia along + * this direction. + */ LVector3 BulletRigidBodyNode:: get_inertia() const { @@ -188,33 +161,27 @@ get_inertia() const { return inertia; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_inv_inertia_diag_local -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_inv_inertia_diag_local() const { return btVector3_to_LVector3(_rigid->getInvInertiaDiagLocal()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_inv_inertia_tensor_world -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix3 BulletRigidBodyNode:: get_inv_inertia_tensor_world() const { return btMatrix3x3_to_LMatrix3(_rigid->getInvInertiaTensorWorld()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_force(const LVector3 &force, const LPoint3 &pos) { @@ -225,11 +192,9 @@ apply_force(const LVector3 &force, const LPoint3 &pos) { LVecBase3_to_btVector3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_central_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_central_force(const LVector3 &force) { @@ -238,11 +203,9 @@ apply_central_force(const LVector3 &force) { _rigid->applyCentralForce(LVecBase3_to_btVector3(force)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_torque(const LVector3 &torque) { @@ -251,11 +214,9 @@ apply_torque(const LVector3 &torque) { _rigid->applyTorque(LVecBase3_to_btVector3(torque)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_torque_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_torque_impulse(const LVector3 &torque) { @@ -264,11 +225,9 @@ apply_torque_impulse(const LVector3 &torque) { _rigid->applyTorqueImpulse(LVecBase3_to_btVector3(torque)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_impulse(const LVector3 &impulse, const LPoint3 &pos) { @@ -279,11 +238,9 @@ apply_impulse(const LVector3 &impulse, const LPoint3 &pos) { LVecBase3_to_btVector3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::apply_central_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: apply_central_impulse(const LVector3 &impulse) { @@ -292,11 +249,9 @@ apply_central_impulse(const LVector3 &impulse) { _rigid->applyCentralImpulse(LVecBase3_to_btVector3(impulse)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::transform_changed -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: transform_changed() { @@ -305,23 +260,21 @@ transform_changed() { NodePath np = NodePath::any_path((PandaNode *)this); CPT(TransformState) ts = np.get_net_transform(); - // For kinematic bodies Bullet will query the transform - // via Motionstate::getWorldTransform. Therefor we need to - // store the new transform within the motion state. - // For dynamic bodies we need to store the net scale within - // the motion state, since Bullet might update the transform - // via MotionState::setWorldTransform. + // For kinematic bodies Bullet will query the transform via + // Motionstate::getWorldTransform. Therefor we need to store the new + // transform within the motion state. For dynamic bodies we need to store + // the net scale within the motion state, since Bullet might update the + // transform via MotionState::setWorldTransform. _motion->set_net_transform(ts); - // For dynamic or static bodies we directly apply the - // new transform. + // For dynamic or static bodies we directly apply the new transform. if (!is_kinematic()) { btTransform trans = TransformState_to_btTrans(ts); _rigid->setCenterOfMassTransform(trans); } - // Rescale all shapes, but only if the new transform state - // has a scale, and this scale differes from the current scale. + // Rescale all shapes, but only if the new transform state has a scale, and + // this scale differes from the current scale. if (ts->has_scale()) { btVector3 new_scale = LVecBase3_to_btVector3(ts->get_scale()); btVector3 current_scale = _shape->getLocalScaling(); @@ -339,11 +292,9 @@ transform_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::sync_p2b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: sync_p2b() { @@ -352,44 +303,36 @@ sync_p2b() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: sync_b2p() { _motion->sync_b2p((PandaNode *)this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_linear_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_linear_velocity() const { return btVector3_to_LVector3(_rigid->getLinearVelocity()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_angular_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_angular_velocity() const { return btVector3_to_LVector3(_rigid->getAngularVelocity()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_linear_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_linear_velocity(const LVector3 &velocity) { @@ -398,11 +341,9 @@ set_linear_velocity(const LVector3 &velocity) { _rigid->setLinearVelocity(LVecBase3_to_btVector3(velocity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_angular_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_angular_velocity(const LVector3 &velocity) { @@ -411,66 +352,54 @@ set_angular_velocity(const LVector3 &velocity) { _rigid->setAngularVelocity(LVecBase3_to_btVector3(velocity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::clear_forces -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: clear_forces() { _rigid->clearForces(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_linear_sleep_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletRigidBodyNode:: get_linear_sleep_threshold() const { return _rigid->getLinearSleepingThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_angular_sleep_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletRigidBodyNode:: get_angular_sleep_threshold() const { return _rigid->getAngularSleepingThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_linear_sleep_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_linear_sleep_threshold(PN_stdfloat threshold) { _rigid->setSleepingThresholds(threshold, _rigid->getAngularSleepingThreshold()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_angular_sleep_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_angular_sleep_threshold(PN_stdfloat threshold) { _rigid->setSleepingThresholds(_rigid->getLinearSleepingThreshold(), threshold); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_gravity(const LVector3 &gravity) { @@ -479,88 +408,72 @@ set_gravity(const LVector3 &gravity) { _rigid->setGravity(LVecBase3_to_btVector3(gravity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_gravity() const { return btVector3_to_LVector3(_rigid->getGravity()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_linear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_linear_factor() const { return btVector3_to_LVector3(_rigid->getLinearFactor()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_angular_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_angular_factor() const { return btVector3_to_LVector3(_rigid->getAngularFactor()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_linear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_linear_factor(const LVector3 &factor) { _rigid->setLinearFactor(LVecBase3_to_btVector3(factor)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::set_angular_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode:: set_angular_factor(const LVector3 &factor) { _rigid->setAngularFactor(LVecBase3_to_btVector3(factor)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_total_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_total_force() const { return btVector3_to_LVector3(_rigid->getTotalForce()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::get_total_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletRigidBodyNode:: get_total_torque() const { return btVector3_to_LVector3(_rigid->getTotalTorque()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRigidBodyNode::MotionState:: MotionState() { @@ -570,22 +483,18 @@ MotionState() { _was_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::getWorldTransform -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode::MotionState:: getWorldTransform(btTransform &trans) const { trans = _trans; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::setWorldTransform -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode::MotionState:: setWorldTransform(const btTransform &trans) { @@ -594,11 +503,9 @@ setWorldTransform(const btTransform &trans) { _was_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletRigidBodyNode::MotionState:: sync_b2p(PandaNode *node) { @@ -614,19 +521,14 @@ sync_b2p(PandaNode *node) { _dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::set_net_transform -// Access: Public -// Description: This method stores the global transform within the -// Motionstate. It is called from -// BulletRigidBodyNode::transform_changed(). -// For kinematic bodies the global transform is -// required since Bullet queries the body transform -// via MotionState::getGlobalStranform(). -// For dynamic bodies the global scale is required, -// since Bullet will overwrite the member _trans -// by calling MotionState::setGlobalTransform. -//////////////////////////////////////////////////////////////////// +/** + * This method stores the global transform within the Motionstate. It is + * called from BulletRigidBodyNode::transform_changed(). For kinematic bodies + * the global transform is required since Bullet queries the body transform + * via MotionState::getGlobalStranform(). For dynamic bodies the global scale + * is required, since Bullet will overwrite the member _trans by calling + * MotionState::setGlobalTransform. + */ void BulletRigidBodyNode::MotionState:: set_net_transform(const TransformState *ts) { @@ -635,22 +537,18 @@ set_net_transform(const TransformState *ts) { _trans = TransformState_to_btTrans(ts); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::sync_disabled -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletRigidBodyNode::MotionState:: sync_disabled() const { return _disabled; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::MotionState::pick_dirty_flag -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletRigidBodyNode::MotionState:: pick_dirty_flag() { @@ -659,36 +557,28 @@ pick_dirty_flag() { return rc; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::pick_dirty_flag -// Access: Published -// Description: Returns TRUE if the transform of the rigid body -// has changed at least once since the last call to -// this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the transform of the rigid body has changed at least once + * since the last call to this method. + */ bool BulletRigidBodyNode:: pick_dirty_flag() { return _motion->pick_dirty_flag(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletRigidBodyNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletRigidBodyNode. + */ void BulletRigidBodyNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletRigidBodyNode:: write_datagram(BamWriter *manager, Datagram &dg) { BulletBodyNode::write_datagram(manager, dg); @@ -703,14 +593,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { get_angular_factor().write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of this type is encountered -// in the Bam file. It should create the rigid body -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * this type is encountered in the Bam file. It should create the rigid body + * and extract its information from the file. + */ TypedWritable *BulletRigidBodyNode:: make_from_bam(const FactoryParams ¶ms) { BulletRigidBodyNode *param = new BulletRigidBodyNode; @@ -723,13 +610,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRigidBodyNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletRigidBodyNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletRigidBodyNode. + */ void BulletRigidBodyNode:: fillin(DatagramIterator &scan, BamReader *manager) { BulletBodyNode::fillin(scan, manager); diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index 309e2386a1..2d6b54f2f3 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -1,16 +1,15 @@ -// Filename: bulletRigidBodyNode.h -// Created by: enn0x (19Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRigidBodyNode.h + * @author enn0x + * @date 2010-11-19 + */ #ifndef __BULLET_RIGID_BODY_NODE_H__ #define __BULLET_RIGID_BODY_NODE_H__ @@ -26,10 +25,9 @@ class BulletShape; -//////////////////////////////////////////////////////////////////// -// Class : BulletRigidBodyNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletRigidBodyNode : public BulletBodyNode { PUBLISHED: @@ -102,8 +100,8 @@ protected: private: virtual void shape_changed(); - // The motion state is used for synchronisation between Bullet - // and the Panda3D scene graph. + // The motion state is used for synchronisation between Bullet and the + // Panda3D scene graph. class MotionState : public btMotionState { public: @@ -143,7 +141,7 @@ public: } static void init_type() { BulletBodyNode::init_type(); - register_type(_type_handle, "BulletRigidBodyNode", + register_type(_type_handle, "BulletRigidBodyNode", BulletBodyNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -161,4 +159,3 @@ private: #include "bulletRigidBodyNode.I" #endif // __BULLET_RIGID_BODY_NODE_H__ - diff --git a/panda/src/bullet/bulletRotationalLimitMotor.I b/panda/src/bullet/bulletRotationalLimitMotor.I index f3a0730f2e..10ed68435c 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.I +++ b/panda/src/bullet/bulletRotationalLimitMotor.I @@ -1,216 +1,175 @@ -// Filename: bulletRotationalLimitMotor.I -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRotationalLimitMotor.I + * @author enn0x + * @date 2013-03-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::is_limited -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletRotationalLimitMotor:: is_limited() const { return _motor.isLimited(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_motor_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_motor_enabled(bool enabled) { _motor.m_enableMotor = enabled; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::get_motor_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletRotationalLimitMotor:: get_motor_enabled() const { return _motor.m_enableMotor; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_low_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_low_limit(PN_stdfloat limit) { _motor.m_loLimit = (btScalar)limit; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_high_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_high_limit(PN_stdfloat limit) { _motor.m_hiLimit = (btScalar)limit; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_target_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_target_velocity(PN_stdfloat velocity) { _motor.m_targetVelocity = (btScalar)velocity; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_max_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_max_motor_force(PN_stdfloat force) { _motor.m_maxMotorForce = (btScalar)force; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_max_limit_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_max_limit_force(PN_stdfloat force) { _motor.m_maxLimitForce = (btScalar)force; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_damping(PN_stdfloat damping) { _motor.m_damping = (btScalar)damping; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_softness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_softness(PN_stdfloat softness) { _motor.m_limitSoftness = (btScalar)softness; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_bounce -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_bounce(PN_stdfloat bounce) { _motor.m_bounce = (btScalar)bounce; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_normal_cfm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_normal_cfm(PN_stdfloat cfm) { _motor.m_normalCFM = (btScalar)cfm; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_stop_cfm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_stop_cfm(PN_stdfloat cfm) { _motor.m_stopCFM = (btScalar)cfm; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::set_stop_erp -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletRotationalLimitMotor:: set_stop_erp(PN_stdfloat erp) { _motor.m_stopERP = (btScalar)erp; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::get_current_limit -// Access: Published -// Description: Retrieves the current value of angle: -// 0 = free, -// 1 = at low limit, -// 2 = at high limit. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at + * high limit. + */ INLINE int BulletRotationalLimitMotor:: get_current_limit() const { return _motor.m_currentLimit; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::get_current_error -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletRotationalLimitMotor:: get_current_error() const { return (PN_stdfloat)_motor.m_currentLimitError; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::get_current_position -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletRotationalLimitMotor:: get_current_position() const { return (PN_stdfloat)_motor.m_currentPosition; } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::get_accumulated_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletRotationalLimitMotor:: get_accumulated_impulse() const { return (PN_stdfloat)_motor.m_accumulatedImpulse; } - diff --git a/panda/src/bullet/bulletRotationalLimitMotor.cxx b/panda/src/bullet/bulletRotationalLimitMotor.cxx index 4420c4abf3..ce95a1f8d7 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.cxx +++ b/panda/src/bullet/bulletRotationalLimitMotor.cxx @@ -1,48 +1,40 @@ -// Filename: bulletRotationalLimitMotor.cxx -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRotationalLimitMotor.cxx + * @author enn0x + * @date 2013-03-03 + */ #include "bulletRotationalLimitMotor.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRotationalLimitMotor:: -BulletRotationalLimitMotor(btRotationalLimitMotor &motor) +BulletRotationalLimitMotor(btRotationalLimitMotor &motor) : _motor(motor) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRotationalLimitMotor:: BulletRotationalLimitMotor(const BulletRotationalLimitMotor ©) : _motor(copy._motor) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletRotationalLimitMotor::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletRotationalLimitMotor:: ~BulletRotationalLimitMotor() { } - diff --git a/panda/src/bullet/bulletRotationalLimitMotor.h b/panda/src/bullet/bulletRotationalLimitMotor.h index 674aff9baf..b82db7ad57 100644 --- a/panda/src/bullet/bulletRotationalLimitMotor.h +++ b/panda/src/bullet/bulletRotationalLimitMotor.h @@ -1,16 +1,15 @@ -// Filename: bulletRotationalLimitMotor.h -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletRotationalLimitMotor.h + * @author enn0x + * @date 2013-03-03 + */ #ifndef __BULLET_ROTATIONAL_LIMIT_MOTOR_H__ #define __BULLET_ROTATIONAL_LIMIT_MOTOR_H__ @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletRotationalLimitMotor -// Description : Rotation Limit structure for generic joints. -//////////////////////////////////////////////////////////////////// +/** + * Rotation Limit structure for generic joints. + */ class EXPCL_PANDABULLET BulletRotationalLimitMotor { PUBLISHED: diff --git a/panda/src/bullet/bulletShape.I b/panda/src/bullet/bulletShape.I index 8d8d463d82..35123a868f 100644 --- a/panda/src/bullet/bulletShape.I +++ b/panda/src/bullet/bulletShape.I @@ -1,101 +1,83 @@ -// Filename: bulletShape.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletShape.I + * @author enn0x + * @date 2010-01-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletShape:: ~BulletShape() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_polyhedral -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_polyhedral() const { return ptr()->isPolyhedral(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_convex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_convex() const { return ptr()->isConvex(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_convex_2d -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_convex_2d() const { return ptr()->isConvex2d(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_concave -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_concave() const { return ptr()->isConcave(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_infinite -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_infinite() const { return ptr()->isInfinite(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_non_moving -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_non_moving() const { return ptr()->isNonMoving(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::is_soft_body -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletShape:: is_soft_body() const { return ptr()->isSoftBody(); } - diff --git a/panda/src/bullet/bulletShape.cxx b/panda/src/bullet/bulletShape.cxx index c0398e3922..daf8c1e623 100644 --- a/panda/src/bullet/bulletShape.cxx +++ b/panda/src/bullet/bulletShape.cxx @@ -1,71 +1,60 @@ -// Filename: bulletShape.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletShape.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bulletShape.h" #include "bullet_utils.h" TypeHandle BulletShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *BulletShape:: get_name() const { return ptr()->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::get_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletShape:: get_margin() const { return ptr()->getMargin(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::set_margin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletShape:: set_margin(PN_stdfloat margin) { ptr()->setMargin(margin); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::get_local_scale -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 BulletShape:: get_local_scale() const { return btVector3_to_LVecBase3(ptr()->getLocalScaling()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::set_local_scale -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletShape:: set_local_scale(const LVecBase3 &scale) { @@ -73,11 +62,9 @@ set_local_scale(const LVecBase3 &scale) { ptr()->setLocalScaling(LVecBase3_to_btVector3(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletShape::get_shape_bounds -// Access: Published -// Description: Returns the current bounds of this collision shape. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current bounds of this collision shape. + */ BoundingSphere BulletShape:: get_shape_bounds() const { @@ -100,4 +87,3 @@ cout << "origin " << aabbMin.x() << " " << aabbMin.y() << " " << aabbMin.z() << return bounds; } - diff --git a/panda/src/bullet/bulletShape.h b/panda/src/bullet/bulletShape.h index 3666f2030a..8094cd1efb 100644 --- a/panda/src/bullet/bulletShape.h +++ b/panda/src/bullet/bulletShape.h @@ -1,16 +1,15 @@ -// Filename: bulletShape.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletShape.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_SHAPE_H__ #define __BULLET_SHAPE_H__ @@ -22,10 +21,9 @@ #include "typedReferenceCount.h" #include "boundingSphere.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletShape : public TypedWritableReferenceCount { protected: INLINE BulletShape() {}; @@ -54,14 +52,13 @@ public: LVecBase3 get_local_scale() const; void set_local_scale(const LVecBase3 &scale); -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedWritableReferenceCount::init_type(); - register_type(_type_handle, "BulletShape", + register_type(_type_handle, "BulletShape", TypedWritableReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletSliderConstraint.I b/panda/src/bullet/bulletSliderConstraint.I index 9dcbfcee69..4035f1399f 100644 --- a/panda/src/bullet/bulletSliderConstraint.I +++ b/panda/src/bullet/bulletSliderConstraint.I @@ -1,47 +1,39 @@ -// Filename: bulletSliderConstraint.I -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSliderConstraint.I + * @author enn0x + * @date 2010-03-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSliderConstraint:: ~BulletSliderConstraint() { delete _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_frame_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletSliderConstraint:: get_frame_a() const { return btTrans_to_TransformState(_constraint->getFrameOffsetA()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_frame_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformState) BulletSliderConstraint:: get_frame_b() const { return btTrans_to_TransformState(_constraint->getFrameOffsetB()); } - diff --git a/panda/src/bullet/bulletSliderConstraint.cxx b/panda/src/bullet/bulletSliderConstraint.cxx index 19cf3ab911..cda213b8c2 100644 --- a/panda/src/bullet/bulletSliderConstraint.cxx +++ b/panda/src/bullet/bulletSliderConstraint.cxx @@ -1,16 +1,15 @@ -// Filename: bulletSliderConstraint.cxx -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSliderConstraint.cxx + * @author enn0x + * @date 2010-03-01 + */ #include "bulletSliderConstraint.h" #include "bulletRigidBodyNode.h" @@ -19,13 +18,11 @@ TypeHandle BulletSliderConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSliderConstraint:: -BulletSliderConstraint(const BulletRigidBodyNode *node_a, +BulletSliderConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a, bool use_frame_a) { @@ -35,11 +32,9 @@ BulletSliderConstraint(const BulletRigidBodyNode *node_a, _constraint = new btSliderConstraint(*ptr_a, trans_a, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSliderConstraint:: BulletSliderConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -56,264 +51,216 @@ BulletSliderConstraint(const BulletRigidBodyNode *node_a, _constraint = new btSliderConstraint(*ptr_a, *ptr_b, trans_a, trans_b, use_frame_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTypedConstraint *BulletSliderConstraint:: ptr() const { return _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_lower_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_lower_linear_limit() const { return (PN_stdfloat)_constraint->getLowerLinLimit(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_upper_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_upper_linear_limit() const { return (PN_stdfloat)_constraint->getUpperLinLimit(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_lower_angular_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_lower_angular_limit() const { return rad_2_deg(_constraint->getLowerAngLimit()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_upper_angular_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_upper_angular_limit() const { return rad_2_deg(_constraint->getUpperAngLimit()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_lower_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_lower_linear_limit(PN_stdfloat value) { _constraint->setLowerLinLimit((btScalar)value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_upper_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_upper_linear_limit(PN_stdfloat value) { _constraint->setUpperLinLimit((btScalar)value); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_lower_angular_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_lower_angular_limit(PN_stdfloat value) { _constraint->setLowerAngLimit((btScalar)deg_2_rad(value)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_upper_angular_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_upper_angular_limit(PN_stdfloat value) { _constraint->setUpperAngLimit((btScalar)deg_2_rad(value)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_linear_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_linear_pos() const { return (PN_stdfloat)_constraint->getLinearPos(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_angular_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_angular_pos() const { return (PN_stdfloat)_constraint->getAngularPos(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_powered_linear_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_powered_linear_motor(bool on) { _constraint->setPoweredLinMotor(on); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_target_linear_motor_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_target_linear_motor_velocity(PN_stdfloat target_velocity) { _constraint->setTargetLinMotorVelocity((btScalar)target_velocity); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_max_linear_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_max_linear_motor_force(PN_stdfloat max_force) { _constraint->setMaxLinMotorForce((btScalar)max_force); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_powered_linear_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletSliderConstraint:: get_powered_linear_motor() const { return _constraint->getPoweredLinMotor(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_target_linear_motor_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_target_linear_motor_velocity() const { return (PN_stdfloat)_constraint->getTargetLinMotorVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_max_linear_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_max_linear_motor_force() const { return (PN_stdfloat)_constraint->getMaxLinMotorForce(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_powered_angular_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_powered_angular_motor(bool on) { _constraint->setPoweredAngMotor(on); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_target_angular_motor_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_target_angular_motor_velocity(PN_stdfloat target_velocity) { _constraint->setTargetAngMotorVelocity((btScalar)target_velocity); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_max_angular_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_max_angular_motor_force(PN_stdfloat max_force) { _constraint->setMaxAngMotorForce((btScalar)max_force); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_powered_angular_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletSliderConstraint:: get_powered_angular_motor() const { return _constraint->getPoweredAngMotor(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_target_angular_motor_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_target_angular_motor_velocity() const { return (PN_stdfloat)_constraint->getTargetAngMotorVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::get_max_angular_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSliderConstraint:: get_max_angular_motor_force() const { return (PN_stdfloat)_constraint->getMaxAngMotorForce(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSliderConstraint::set_frames -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSliderConstraint:: set_frames(const TransformState *ts_a, const TransformState *ts_b) { @@ -322,4 +269,3 @@ set_frames(const TransformState *ts_a, const TransformState *ts_b) { _constraint->setFrames(frame_a, frame_b); } - diff --git a/panda/src/bullet/bulletSliderConstraint.h b/panda/src/bullet/bulletSliderConstraint.h index 395c2535e2..b2ea28046e 100644 --- a/panda/src/bullet/bulletSliderConstraint.h +++ b/panda/src/bullet/bulletSliderConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletSliderConstraint.h -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSliderConstraint.h + * @author enn0x + * @date 2010-03-01 + */ #ifndef __BULLET_SLIDER_CONSTRAINT_H__ #define __BULLET_SLIDER_CONSTRAINT_H__ @@ -25,14 +24,13 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletSliderConstraint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSliderConstraint : public BulletConstraint { PUBLISHED: - BulletSliderConstraint(const BulletRigidBodyNode *node_a, + BulletSliderConstraint(const BulletRigidBodyNode *node_a, const TransformState *frame_a, bool useFrame_a); BulletSliderConstraint(const BulletRigidBodyNode *node_a, @@ -82,14 +80,13 @@ public: private: btSliderConstraint *_constraint; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletConstraint::init_type(); - register_type(_type_handle, "BulletSliderConstraint", + register_type(_type_handle, "BulletSliderConstraint", BulletConstraint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletSoftBodyConfig.I b/panda/src/bullet/bulletSoftBodyConfig.I index 43cd016eca..811463d492 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.I +++ b/panda/src/bullet/bulletSoftBodyConfig.I @@ -1,483 +1,396 @@ -// Filename: bulletSoftBodyConfig.I -// Created by: enn0x (12Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyConfig.I + * @author enn0x + * @date 2010-04-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyConfig:: ~BulletSoftBodyConfig() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_velocities_correction_factor -// Access: Published -// Description: Getter for property kVCF. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kVCF. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_velocities_correction_factor() const { return (PN_stdfloat)_cfg.kVCF; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_velocities_correction_factor -// Access: Published -// Description: Setter for property kVCF. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kVCF. + */ INLINE void BulletSoftBodyConfig:: set_velocities_correction_factor(PN_stdfloat value) { _cfg.kVCF = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_damping_coefficient -// Access: Published -// Description: Getter for property kDP. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kDP. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_damping_coefficient() const { return (PN_stdfloat)_cfg.kDP; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_damping_coefficient -// Access: Published -// Description: Setter for property kDP. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kDP. + */ INLINE void BulletSoftBodyConfig:: set_damping_coefficient(PN_stdfloat value) { _cfg.kDP = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_drag_coefficient -// Access: Published -// Description: Getter for property kDG. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kDG. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_drag_coefficient() const { return (PN_stdfloat)_cfg.kDG; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_drag_coefficient -// Access: Published -// Description: Setter for property kDG. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kDG. + */ INLINE void BulletSoftBodyConfig:: set_drag_coefficient(PN_stdfloat value) { _cfg.kDG = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_lift_coefficient -// Access: Published -// Description: Getter for property kLF. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kLF. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_lift_coefficient() const { return (PN_stdfloat)_cfg.kLF; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_lift_coefficient -// Access: Published -// Description: Setter for property kLF. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kLF. + */ INLINE void BulletSoftBodyConfig:: set_lift_coefficient(PN_stdfloat value) { _cfg.kLF = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_pressure_coefficient -// Access: Published -// Description: Getter for property kPR. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kPR. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_pressure_coefficient() const { return (PN_stdfloat)_cfg.kPR; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_pressure_coefficient -// Access: Published -// Description: Setter for property kPR. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kPR. + */ INLINE void BulletSoftBodyConfig:: set_pressure_coefficient(PN_stdfloat value) { _cfg.kPR = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_volume_conversation_coefficient -// Access: Published -// Description: Getter for property kVC. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kVC. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_volume_conversation_coefficient() const { return (PN_stdfloat)_cfg.kVC; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_volume_conversation_coefficient -// Access: Published -// Description: Setter for property kVC. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kVC. + */ INLINE void BulletSoftBodyConfig:: set_volume_conversation_coefficient(PN_stdfloat value) { _cfg.kVC = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_dynamic_friction_coefficient -// Access: Published -// Description: Getter for property kDF. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kDF. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_dynamic_friction_coefficient() const { return (PN_stdfloat)_cfg.kDF; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_dynamic_friction_coefficient -// Access: Published -// Description: Setter for property kDF. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kDF. + */ INLINE void BulletSoftBodyConfig:: set_dynamic_friction_coefficient(PN_stdfloat value) { _cfg.kDF = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_pose_matching_coefficient -// Access: Published -// Description: Getter for property kMT. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kMT. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_pose_matching_coefficient() const { return (PN_stdfloat)_cfg.kMT; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_pose_matching_coefficient -// Access: Published -// Description: Setter for property kMT. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kMT. + */ INLINE void BulletSoftBodyConfig:: set_pose_matching_coefficient(PN_stdfloat value) { _cfg.kMT = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_rigid_contacts_hardness -// Access: Published -// Description: Getter for property kCHR. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kCHR. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_rigid_contacts_hardness() const { return (PN_stdfloat)_cfg.kCHR; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_rigid_contacts_hardness -// Access: Published -// Description: Setter for property kCHR. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kCHR. + */ INLINE void BulletSoftBodyConfig:: set_rigid_contacts_hardness(PN_stdfloat value) { _cfg.kCHR = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_kinetic_contacts_hardness -// Access: Published -// Description: Getter for property kKHR. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kKHR. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_kinetic_contacts_hardness() const { return (PN_stdfloat)_cfg.kKHR; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_kinetic_contacts_hardness -// Access: Published -// Description: Setter for property kKHR. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kKHR. + */ INLINE void BulletSoftBodyConfig:: set_kinetic_contacts_hardness(PN_stdfloat value) { _cfg.kKHR = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_contacts_hardness -// Access: Published -// Description: Getter for property kSHR. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSHR. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_contacts_hardness() const { return (PN_stdfloat)_cfg.kSHR; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_contacts_hardness -// Access: Published -// Description: Setter for property kSHR. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSHR. + */ INLINE void BulletSoftBodyConfig:: set_soft_contacts_hardness(PN_stdfloat value) { _cfg.kSHR = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_anchors_hardness -// Access: Published -// Description: Getter for property kAHR. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kAHR. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_anchors_hardness() const { return (PN_stdfloat)_cfg.kAHR; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_anchors_hardness -// Access: Published -// Description: Setter for property kAHR. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kAHR. + */ INLINE void BulletSoftBodyConfig:: set_anchors_hardness(PN_stdfloat value) { _cfg.kAHR = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_rigid_hardness -// Access: Published -// Description: Getter for property kSRHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSRHR_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_rigid_hardness() const { return (PN_stdfloat)_cfg.kSRHR_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_rigid_hardness -// Access: Published -// Description: Setter for property kSRHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSRHR_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_rigid_hardness(PN_stdfloat value) { _cfg.kSRHR_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_kinetic_hardness -// Access: Published -// Description: Getter for property kSKHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSKHR_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_kinetic_hardness() const { return (PN_stdfloat)_cfg.kSKHR_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_kinetic_hardness -// Access: Published -// Description: Setter for property kSKHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSKHR_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_kinetic_hardness(PN_stdfloat value) { _cfg.kSKHR_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_soft_hardness -// Access: Published -// Description: Getter for property kSSHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSSHR_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_soft_hardness() const { return (PN_stdfloat)_cfg.kSSHR_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_soft_hardness -// Access: Published -// Description: Setter for property kSSHR_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSSHR_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_soft_hardness(PN_stdfloat value) { _cfg.kSSHR_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_rigid_impulse_split -// Access: Published -// Description: Getter for property kSR_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSR_SPLT_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_rigid_impulse_split() const { return (PN_stdfloat)_cfg.kSR_SPLT_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_rigid_impulse_split -// Access: Published -// Description: Setter for property kSR_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSR_SPLT_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_rigid_impulse_split(PN_stdfloat value) { _cfg.kSR_SPLT_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_kinetic_impulse_split -// Access: Published -// Description: Getter for property kSK_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSK_SPLT_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_kinetic_impulse_split() const { return (PN_stdfloat)_cfg.kSK_SPLT_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_kinetic_impulse_split -// Access: Published -// Description: Setter for property kSK_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSK_SPLT_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_kinetic_impulse_split(PN_stdfloat value) { _cfg.kSK_SPLT_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_soft_vs_soft_impulse_split -// Access: Published -// Description: Getter for property kSS_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property kSS_SPLT_CL. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_soft_vs_soft_impulse_split() const { return (PN_stdfloat)_cfg.kSS_SPLT_CL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_soft_vs_soft_impulse_split -// Access: Published -// Description: Setter for property kSS_SPLT_CL. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property kSS_SPLT_CL. + */ INLINE void BulletSoftBodyConfig:: set_soft_vs_soft_impulse_split(PN_stdfloat value) { _cfg.kSS_SPLT_CL = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_maxvolume -// Access: Published -// Description: Getter for property maxvolume. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property maxvolume. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_maxvolume() const { return (PN_stdfloat)_cfg.maxvolume; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_maxvolume -// Access: Published -// Description: Setter for property maxvolume. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property maxvolume. + */ INLINE void BulletSoftBodyConfig:: set_maxvolume(PN_stdfloat value) { _cfg.maxvolume = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_timescale -// Access: Published -// Description: Getter for property timescale. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property timescale. + */ INLINE PN_stdfloat BulletSoftBodyConfig:: get_timescale() const { return (PN_stdfloat)_cfg.timescale; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_timescale -// Access: Published -// Description: Setter for property timescale. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property timescale. + */ INLINE void BulletSoftBodyConfig:: set_timescale(PN_stdfloat value) { _cfg.timescale = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_positions_solver_iterations -// Access: Published -// Description: Getter for property piterations. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property piterations. + */ INLINE int BulletSoftBodyConfig:: get_positions_solver_iterations() const { return _cfg.piterations; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_positions_solver_iterations -// Access: Published -// Description: Setter for property piterations. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property piterations. + */ INLINE void BulletSoftBodyConfig:: set_positions_solver_iterations(int value) { @@ -485,22 +398,18 @@ set_positions_solver_iterations(int value) { _cfg.piterations = value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_velocities_solver_iterations -// Access: Published -// Description: Getter for property viterations. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property viterations. + */ INLINE int BulletSoftBodyConfig:: get_velocities_solver_iterations() const { return _cfg.viterations; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_velocities_solver_iterations -// Access: Published -// Description: Setter for property viterations. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property viterations. + */ INLINE void BulletSoftBodyConfig:: set_velocities_solver_iterations(int value) { @@ -508,22 +417,18 @@ set_velocities_solver_iterations(int value) { _cfg.viterations = value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_drift_solver_iterations -// Access: Published -// Description: Getter for property diterations. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property diterations. + */ INLINE int BulletSoftBodyConfig:: get_drift_solver_iterations() const { return _cfg.diterations; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_drift_solver_iterations -// Access: Published -// Description: Setter for property diterations. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property diterations. + */ INLINE void BulletSoftBodyConfig:: set_drift_solver_iterations(int value) { @@ -531,26 +436,21 @@ set_drift_solver_iterations(int value) { _cfg.diterations = value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_cluster_solver_iterations -// Access: Published -// Description: Getter for property citerations. -//////////////////////////////////////////////////////////////////// +/** + * Getter for property citerations. + */ INLINE int BulletSoftBodyConfig:: get_cluster_solver_iterations() const { return _cfg.citerations; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_cluster_solver_iterations -// Access: Published -// Description: Setter for property citerations. -//////////////////////////////////////////////////////////////////// +/** + * Setter for property citerations. + */ INLINE void BulletSoftBodyConfig:: set_cluster_solver_iterations(int value) { nassertv(value > 0); _cfg.citerations = value; } - diff --git a/panda/src/bullet/bulletSoftBodyConfig.cxx b/panda/src/bullet/bulletSoftBodyConfig.cxx index a2480ab359..dc12fde309 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.cxx +++ b/panda/src/bullet/bulletSoftBodyConfig.cxx @@ -1,45 +1,38 @@ -// Filename: bulletSoftBodyConfig.cxx -// Created by: enn0x (12Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyConfig.cxx + * @author enn0x + * @date 2010-04-12 + */ #include "bulletSoftBodyConfig.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyConfig:: BulletSoftBodyConfig(btSoftBody::Config &cfg) : _cfg(cfg) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::clear_collisions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyConfig:: clear_all_collision_flags() { _cfg.collisions = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_collisions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyConfig:: set_collision_flag(CollisionFlag flag, bool value) { @@ -51,36 +44,29 @@ set_collision_flag(CollisionFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_collisions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletSoftBodyConfig:: get_collision_flag(CollisionFlag flag) const { return (_cfg.collisions & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::set_aero_model -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyConfig:: set_aero_model(AeroModel value) { _cfg.aeromodel = (btSoftBody::eAeroModel::_)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyConfig::get_aero_model -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyConfig::AeroModel BulletSoftBodyConfig:: get_aero_model() const { return (AeroModel)_cfg.aeromodel; } - diff --git a/panda/src/bullet/bulletSoftBodyConfig.h b/panda/src/bullet/bulletSoftBodyConfig.h index 22505c8358..e3bf316881 100644 --- a/panda/src/bullet/bulletSoftBodyConfig.h +++ b/panda/src/bullet/bulletSoftBodyConfig.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyConfig.h -// Created by: enn0x (12Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyConfig.h + * @author enn0x + * @date 2010-04-12 + */ #ifndef __BULLET_SOFT_BODY_CONFIG_H__ #define __BULLET_SOFT_BODY_CONFIG_H__ @@ -19,10 +18,9 @@ #include "bullet_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyConfig -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyConfig { PUBLISHED: diff --git a/panda/src/bullet/bulletSoftBodyControl.I b/panda/src/bullet/bulletSoftBodyControl.I index e646f74a6e..21bfc97ba6 100644 --- a/panda/src/bullet/bulletSoftBodyControl.I +++ b/panda/src/bullet/bulletSoftBodyControl.I @@ -1,59 +1,48 @@ -// Filename: bulletSoftBodyControl.I -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyControl.I + * @author enn0x + * @date 2010-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::set_goal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletSoftBodyControl:: set_goal(PN_stdfloat goal) { _goal = (btScalar)goal; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::set_max_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletSoftBodyControl:: set_max_torque(PN_stdfloat maxtorque) { _maxtorque = (btScalar)maxtorque; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::set_angle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletSoftBodyControl:: set_angle(PN_stdfloat angle) { _angle = (btScalar)angle; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::set_sign -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletSoftBodyControl:: set_sign(PN_stdfloat sign) { _sign = (btScalar)sign; } - diff --git a/panda/src/bullet/bulletSoftBodyControl.cxx b/panda/src/bullet/bulletSoftBodyControl.cxx index 5329464815..58d7c21524 100644 --- a/panda/src/bullet/bulletSoftBodyControl.cxx +++ b/panda/src/bullet/bulletSoftBodyControl.cxx @@ -1,24 +1,21 @@ -// Filename: bulletSoftBodyControl.cxx -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyControl.cxx + * @author enn0x + * @date 2010-03-04 + */ #include "bulletSoftBodyControl.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyControl:: BulletSoftBodyControl() { @@ -29,21 +26,17 @@ BulletSoftBodyControl() { _sign = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyControl:: ~BulletSoftBodyControl() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::Prepare -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyControl:: Prepare(btSoftBody::AJoint* joint) { @@ -53,14 +46,11 @@ Prepare(btSoftBody::AJoint* joint) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyControl::Speed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btScalar BulletSoftBodyControl:: Speed(btSoftBody::AJoint *, btScalar current) { return (current + btMin(_maxtorque, btMax(-_maxtorque, _goal - current))); } - diff --git a/panda/src/bullet/bulletSoftBodyControl.h b/panda/src/bullet/bulletSoftBodyControl.h index c68f7438a6..6d1dfdaab9 100644 --- a/panda/src/bullet/bulletSoftBodyControl.h +++ b/panda/src/bullet/bulletSoftBodyControl.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyControl.h -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyControl.h + * @author enn0x + * @date 2010-03-04 + */ #ifndef __BULLET_SOFT_BODY_CONTROL_H__ #define __BULLET_SOFT_BODY_CONTROL_H__ @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyControl -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyControl : public btSoftBody::AJoint::IControl { PUBLISHED: @@ -36,15 +34,15 @@ PUBLISHED: INLINE void set_goal(PN_stdfloat goal); INLINE void set_max_torque(PN_stdfloat maxtorque); - //INLINE PN_stdfloat get_goal() const; - //INLINE PN_stdfloat get_max_torque() const; + // INLINE PN_stdfloat get_goal() const; INLINE PN_stdfloat get_max_torque() + // const; // Steer INLINE void set_angle(PN_stdfloat angle); INLINE void set_sign(PN_stdfloat sign); - //INLINE PN_stdfloat get_angle() const; - //INLINE PN_stdfloat get_sign() const; + // INLINE PN_stdfloat get_angle() const; INLINE PN_stdfloat get_sign() + // const; public: void Prepare(btSoftBody::AJoint* joint); diff --git a/panda/src/bullet/bulletSoftBodyMaterial.I b/panda/src/bullet/bulletSoftBodyMaterial.I index 79dfcd780a..f0da7e10ce 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.I +++ b/panda/src/bullet/bulletSoftBodyMaterial.I @@ -1,33 +1,28 @@ -// Filename: bulletSoftBodyMaterial.I -// Created by: enn0x (19Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyMaterial.I + * @author enn0x + * @date 2011-03-19 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyMaterial:: ~BulletSoftBodyMaterial() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::empty -// Access: Published -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletSoftBodyMaterial BulletSoftBodyMaterial:: empty() { @@ -36,80 +31,65 @@ empty() { return BulletSoftBodyMaterial(material); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_material -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btSoftBody::Material &BulletSoftBodyMaterial:: get_material() const { return _material; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::getLinearStiffness -// Access: Published -// Description: Getter for the property m_kLST. -//////////////////////////////////////////////////////////////////// +/** + * Getter for the property m_kLST. + */ INLINE PN_stdfloat BulletSoftBodyMaterial:: getLinearStiffness() const { return (PN_stdfloat)_material.m_kLST; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::setLinearStiffness -// Access: Published -// Description: Setter for the property m_kLST. -//////////////////////////////////////////////////////////////////// +/** + * Setter for the property m_kLST. + */ INLINE void BulletSoftBodyMaterial:: setLinearStiffness(PN_stdfloat value) { _material.m_kLST = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::getAngularStiffness -// Access: Published -// Description: Getter for the property m_kAST. -//////////////////////////////////////////////////////////////////// +/** + * Getter for the property m_kAST. + */ INLINE PN_stdfloat BulletSoftBodyMaterial:: getAngularStiffness() const { return (PN_stdfloat)_material.m_kAST; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::setAngularStiffness -// Access: Published -// Description: Setter for the property m_kAST. -//////////////////////////////////////////////////////////////////// +/** + * Setter for the property m_kAST. + */ INLINE void BulletSoftBodyMaterial:: setAngularStiffness(PN_stdfloat value) { _material.m_kAST = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::getVolumePreservation -// Access: Published -// Description: Getter for the property m_kVST. -//////////////////////////////////////////////////////////////////// +/** + * Getter for the property m_kVST. + */ INLINE PN_stdfloat BulletSoftBodyMaterial:: getVolumePreservation() const { return (PN_stdfloat)_material.m_kVST; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::setVolumePreservation -// Access: Published -// Description: Setter for the property m_kVST. -//////////////////////////////////////////////////////////////////// +/** + * Setter for the property m_kVST. + */ INLINE void BulletSoftBodyMaterial:: setVolumePreservation(PN_stdfloat value) { _material.m_kVST = (btScalar)value; } - diff --git a/panda/src/bullet/bulletSoftBodyMaterial.cxx b/panda/src/bullet/bulletSoftBodyMaterial.cxx index d05212ffc8..1767513a27 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.cxx +++ b/panda/src/bullet/bulletSoftBodyMaterial.cxx @@ -1,26 +1,22 @@ -// Filename: bulletSoftBodyMaterial.cxx -// Created by: enn0x (19Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyMaterial.cxx + * @author enn0x + * @date 2011-03-19 + */ #include "bulletSoftBodyMaterial.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyMaterial::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyMaterial:: BulletSoftBodyMaterial(btSoftBody::Material &material) : _material(material) { } - diff --git a/panda/src/bullet/bulletSoftBodyMaterial.h b/panda/src/bullet/bulletSoftBodyMaterial.h index 628e7f37db..fdcd453f4d 100644 --- a/panda/src/bullet/bulletSoftBodyMaterial.h +++ b/panda/src/bullet/bulletSoftBodyMaterial.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyMaterial.h -// Created by: enn0x (19Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyMaterial.h + * @author enn0x + * @date 2011-03-19 + */ #ifndef __BULLET_SOFT_BODY_MATERIAL_H__ #define __BULLET_SOFT_BODY_MATERIAL_H__ @@ -19,10 +18,9 @@ #include "bullet_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyMaterial -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyMaterial { PUBLISHED: diff --git a/panda/src/bullet/bulletSoftBodyNode.I b/panda/src/bullet/bulletSoftBodyNode.I index 91afd45678..086c3396e7 100644 --- a/panda/src/bullet/bulletSoftBodyNode.I +++ b/panda/src/bullet/bulletSoftBodyNode.I @@ -1,45 +1,37 @@ -// Filename: bulletSoftBodyNode.I -// Created by: enn0x (27Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyNode.I + * @author enn0x + * @date 2010-12-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyNode:: ~BulletSoftBodyNode() { delete _soft; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyNodeElement:: ~BulletSoftBodyNodeElement() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::empty -// Access: Published -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletSoftBodyNodeElement BulletSoftBodyNodeElement:: empty() { @@ -48,69 +40,56 @@ empty() { return BulletSoftBodyNodeElement(node); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::get_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 BulletSoftBodyNodeElement:: get_pos() const { return btVector3_to_LPoint3(_node.m_x); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::get_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletSoftBodyNodeElement:: get_normal() const { return btVector3_to_LVector3(_node.m_n); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::get_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletSoftBodyNodeElement:: get_velocity() const { return btVector3_to_LVector3(_node.m_v); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::get_inv_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletSoftBodyNodeElement:: get_inv_mass() const { return (PN_stdfloat)_node.m_im; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::get_area -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletSoftBodyNodeElement:: get_area() const { return (PN_stdfloat)_node.m_area; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::is_attached -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletSoftBodyNodeElement:: is_attached() const { return (PN_stdfloat)_node.m_battach; } - diff --git a/panda/src/bullet/bulletSoftBodyNode.cxx b/panda/src/bullet/bulletSoftBodyNode.cxx index 9dc1ca470b..349dbe4389 100644 --- a/panda/src/bullet/bulletSoftBodyNode.cxx +++ b/panda/src/bullet/bulletSoftBodyNode.cxx @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyNode.cxx -// Created by: enn0x (27Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyNode.cxx + * @author enn0x + * @date 2010-12-27 + */ #include "bulletSoftBodyNode.h" #include "bulletSoftBodyConfig.h" @@ -25,11 +24,9 @@ TypeHandle BulletSoftBodyNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyNode:: BulletSoftBodyNode(btSoftBody *body, const char *name) : BulletBodyNode(name) { @@ -55,55 +52,45 @@ BulletSoftBodyNode(btSoftBody *body, const char *name) : BulletBodyNode(name) { _surface = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionObject *BulletSoftBodyNode:: get_object() const { return _soft; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_cfg -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyConfig BulletSoftBodyNode:: get_cfg() { return BulletSoftBodyConfig(_soft->m_cfg); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_world_info -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyWorldInfo BulletSoftBodyNode:: get_world_info() { return BulletSoftBodyWorldInfo(*(_soft->m_worldInfo)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_num_materials -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletSoftBodyNode:: get_num_materials() const { return _soft->m_materials.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_material -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyMaterial BulletSoftBodyNode:: get_material(int idx) const { @@ -113,11 +100,9 @@ get_material(int idx) const { return BulletSoftBodyMaterial(*material); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_material -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyMaterial BulletSoftBodyNode:: append_material() { @@ -127,22 +112,18 @@ append_material() { return BulletSoftBodyMaterial(*material); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_num_nodes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletSoftBodyNode:: get_num_nodes() const { return _soft->m_nodes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyNodeElement BulletSoftBodyNode:: get_node(int idx) const { @@ -150,11 +131,9 @@ get_node(int idx) const { return BulletSoftBodyNodeElement(_soft->m_nodes[idx]); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::generate_bending_constraints -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: generate_bending_constraints(int distance, BulletSoftBodyMaterial *material) { @@ -166,22 +145,18 @@ generate_bending_constraints(int distance, BulletSoftBodyMaterial *material) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::randomize_constraints -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: randomize_constraints() { _soft->randomizeConstraints(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::transform_changed -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: transform_changed() { @@ -226,22 +201,18 @@ transform_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::sync_p2b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: sync_p2b() { - //transform_changed(); Disabled for now... + // transform_changed(); Disabled for now... } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: sync_b2p() { @@ -293,8 +264,8 @@ sync_b2p() { } } - // Update the synchronized transform with the current - // approximate center of the soft body + // Update the synchronized transform with the current approximate center of + // the soft body LVecBase3 pos = this->get_aabb().get_approx_center(); CPT(TransformState) ts = TransformState::make_pos(pos); @@ -313,14 +284,11 @@ sync_b2p() { this->r_mark_geom_bounds_stale(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_closest_node_index -// Access: Published -// Description: Returns the index of the node which is closest -// to the given point. The distance between each node -// and the given point is computed in world space -// if local=false, and in local space if local=true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the node which is closest to the given point. The + * distance between each node and the given point is computed in world space + * if local=false, and in local space if local=true. + */ int BulletSoftBodyNode:: get_closest_node_index(LVecBase3 point, bool local) { @@ -349,11 +317,9 @@ get_closest_node_index(LVecBase3 point, bool local) { return node_idx; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::link_geom -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: link_geom(Geom *geom) { @@ -388,22 +354,18 @@ link_geom(Geom *geom) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::unlink_geom -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: unlink_geom() { _geom = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::link_curve -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: link_curve(NurbsCurveEvaluator *curve) { @@ -412,22 +374,18 @@ link_curve(NurbsCurveEvaluator *curve) { _curve = curve; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::unlink_curve -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: unlink_curve() { _curve = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::link_surface -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: link_surface(NurbsSurfaceEvaluator *surface) { @@ -436,22 +394,18 @@ link_surface(NurbsSurfaceEvaluator *surface) { _surface = surface; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::unlink_surface -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: unlink_surface() { _surface = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_aabb -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingBox BulletSoftBodyNode:: get_aabb() const { @@ -466,99 +420,81 @@ get_aabb() const { ); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_volume_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_volume_mass(PN_stdfloat mass) { _soft->setVolumeMass(mass); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_total_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_total_mass(PN_stdfloat mass, bool fromfaces) { _soft->setTotalMass(mass, fromfaces); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_volume_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_volume_density(PN_stdfloat density) { _soft->setVolumeDensity(density); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_total_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_total_density(PN_stdfloat density) { _soft->setTotalDensity(density); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_mass(int node, PN_stdfloat mass) { _soft->setMass(node, mass); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyNode:: get_mass(int node) const { return _soft->getMass(node); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_total_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyNode:: get_total_mass() const { return _soft->getTotalMass(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_volume -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyNode:: get_volume() const { return _soft->getVolume(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::add_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: add_force(const LVector3 &force) { @@ -566,11 +502,9 @@ add_force(const LVector3 &force) { _soft->addForce(LVecBase3_to_btVector3(force)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::add_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: add_force(const LVector3 &force, int node) { @@ -578,11 +512,9 @@ add_force(const LVector3 &force, int node) { _soft->addForce(LVecBase3_to_btVector3(force), node); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_velocity(const LVector3 &velocity) { @@ -590,11 +522,9 @@ set_velocity(const LVector3 &velocity) { _soft->setVelocity(LVecBase3_to_btVector3(velocity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::add_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: add_velocity(const LVector3 &velocity) { @@ -602,11 +532,9 @@ add_velocity(const LVector3 &velocity) { _soft->addVelocity(LVecBase3_to_btVector3(velocity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::add_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: add_velocity(const LVector3 &velocity, int node) { @@ -614,77 +542,63 @@ add_velocity(const LVector3 &velocity, int node) { _soft->addVelocity(LVecBase3_to_btVector3(velocity), node); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::generate_clusters -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: generate_clusters(int k, int maxiterations) { _soft->generateClusters(k, maxiterations); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::release_clusters -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: release_clusters() { _soft->releaseClusters(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::release_cluster -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: release_cluster(int index) { _soft->releaseCluster(index); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_num_clusters -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletSoftBodyNode:: get_num_clusters() const { return _soft->clusterCount(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::cluster_com -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 BulletSoftBodyNode:: cluster_com(int cluster) const { return btVector3_to_LVecBase3(_soft->clusterCom(cluster)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_pose -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_pose(bool bvolume, bool bframe) { _soft->setPose(bvolume, bframe); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_anchor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: append_anchor(int node, BulletRigidBodyNode *body, bool disable) { @@ -697,11 +611,9 @@ append_anchor(int node, BulletRigidBodyNode *body, bool disable) { _soft->appendAnchor(node, ptr, disable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_anchor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: append_anchor(int node, BulletRigidBodyNode *body, const LVector3 &pivot, bool disable) { @@ -715,24 +627,19 @@ append_anchor(int node, BulletRigidBodyNode *body, const LVector3 &pivot, bool d _soft->appendAnchor(node, ptr, LVecBase3_to_btVector3(pivot), disable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNodeElement::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyNodeElement:: BulletSoftBodyNodeElement(btSoftBody::Node &node) : _node(node) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_point_index -// Access: Private -// Description: Returns the index of the first point within an -// array of points which has about the same -// coordinates as the given point. If no points -// is found -1 is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the first point within an array of points which has + * about the same coordinates as the given point. If no points is found -1 is + * returned. + */ int BulletSoftBodyNode:: get_point_index(LVecBase3 p, PTA_LVecBase3 points) { @@ -747,12 +654,10 @@ get_point_index(LVecBase3 p, PTA_LVecBase3 points) { return -1; // Not found } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::next_line -// Access: Published -// Description: Read on until the next linebreak is detected, or -// the end of file has been reached. -//////////////////////////////////////////////////////////////////// +/** + * Read on until the next linebreak is detected, or the end of file has been + * reached. + */ int BulletSoftBodyNode:: next_line(const char* buffer) { @@ -762,7 +667,7 @@ next_line(const char* buffer) { buffer++; num_bytes_read++; } - + if (buffer[0] == 0x0a) { buffer++; num_bytes_read++; @@ -771,11 +676,9 @@ next_line(const char* buffer) { return num_bytes_read; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_rope -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_rope(BulletSoftBodyWorldInfo &info, const LPoint3 &from, const LPoint3 &to, int res, int fixeds) { @@ -791,11 +694,9 @@ make_rope(BulletSoftBodyWorldInfo &info, const LPoint3 &from, const LPoint3 &to, return node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_patch -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_patch(BulletSoftBodyWorldInfo &info, const LPoint3 &corner00, const LPoint3 &corner10, const LPoint3 &corner01, const LPoint3 &corner11, int resx, int resy, int fixeds, bool gendiags) { @@ -815,11 +716,9 @@ make_patch(BulletSoftBodyWorldInfo &info, const LPoint3 &corner00, const LPoint3 return node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_ellipsoid -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_ellipsoid(BulletSoftBodyWorldInfo &info, const LPoint3 ¢er, const LVecBase3 &radius, int res) { @@ -834,11 +733,9 @@ make_ellipsoid(BulletSoftBodyWorldInfo &info, const LPoint3 ¢er, const LVecB return node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_tri_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tri_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indices, bool randomizeConstraints) { @@ -903,11 +800,9 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic return node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_tri_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeConstraints) { @@ -947,11 +842,9 @@ make_tri_mesh(BulletSoftBodyWorldInfo &info, const Geom *geom, bool randomizeCon return make_tri_mesh(info, points, indices, randomizeConstraints); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_tet_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tet_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indices, bool tetralinks) { @@ -993,11 +886,9 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, PTA_LVecBase3 points, PTA_int indic return node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::make_tet_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BulletSoftBodyNode) BulletSoftBodyNode:: make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face, const char *node) { @@ -1083,11 +974,9 @@ make_tet_mesh(BulletSoftBodyWorldInfo &info, const char *ele, const char *face, return sbnode; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_linear_joint -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: append_linear_joint(BulletBodyNode *body, int cluster, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) { @@ -1104,11 +993,9 @@ append_linear_joint(BulletBodyNode *body, int cluster, PN_stdfloat erp, PN_stdfl _soft->appendLinearJoint(ls, ptr); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_linear_joint -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: append_linear_joint(BulletBodyNode *body, const LPoint3 &pos, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split) { @@ -1125,11 +1012,9 @@ append_linear_joint(BulletBodyNode *body, const LPoint3 &pos, PN_stdfloat erp, P _soft->appendLinearJoint(ls, ptr); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::append_angular_joint -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: append_angular_joint(BulletBodyNode *body, const LVector3 &axis, PN_stdfloat erp, PN_stdfloat cfm, PN_stdfloat split, BulletSoftBodyControl *control) { @@ -1147,11 +1032,9 @@ append_angular_joint(BulletBodyNode *body, const LVector3 &axis, PN_stdfloat erp _soft->appendAngularJoint(as, ptr); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::set_wind_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyNode:: set_wind_velocity(const LVector3 &velocity) { @@ -1159,14 +1042,11 @@ set_wind_velocity(const LVector3 &velocity) { _soft->setWindVelocity(LVecBase3_to_btVector3(velocity)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyNode::get_wind_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletSoftBodyNode:: get_wind_velocity() const { return btVector3_to_LVector3(_soft->getWindVelocity()); } - diff --git a/panda/src/bullet/bulletSoftBodyNode.h b/panda/src/bullet/bulletSoftBodyNode.h index a8e62d1714..38d95c1fd9 100644 --- a/panda/src/bullet/bulletSoftBodyNode.h +++ b/panda/src/bullet/bulletSoftBodyNode.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyNode.h -// Created by: enn0x (27Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyNode.h + * @author enn0x + * @date 2010-12-27 + */ #ifndef __BULLET_SOFT_BODY_NODE_H__ #define __BULLET_SOFT_BODY_NODE_H__ @@ -35,10 +34,9 @@ class BulletSoftBodyControl; class BulletSoftBodyMaterial; class BulletSoftBodyWorldInfo; -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyNodeElement -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyNodeElement { PUBLISHED: @@ -59,10 +57,9 @@ private: btSoftBody::Node &_node; }; -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyNode -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyNode : public BulletBodyNode { public: @@ -75,7 +72,7 @@ PUBLISHED: BulletSoftBodyWorldInfo get_world_info(); void generate_bending_constraints(int distance, BulletSoftBodyMaterial *material=NULL); - void randomize_constraints(); + void randomize_constraints(); // Mass, volume, density void set_volume_mass(PN_stdfloat mass); @@ -121,9 +118,9 @@ PUBLISHED: void unlink_surface(); // Anchors - void append_anchor(int node, BulletRigidBodyNode *body, + void append_anchor(int node, BulletRigidBodyNode *body, bool disable=false); - void append_anchor(int node, BulletRigidBodyNode *body, + void append_anchor(int node, BulletRigidBodyNode *body, const LVector3 &pivot, bool disable=false); @@ -190,7 +187,7 @@ PUBLISHED: static PT(BulletSoftBodyNode) make_tri_mesh( BulletSoftBodyWorldInfo &info, - PTA_LVecBase3 points, + PTA_LVecBase3 points, PTA_int indices, bool randomizeConstraints=true); @@ -228,14 +225,13 @@ private: static int get_point_index(LVecBase3 p, PTA_LVecBase3 points); static int next_line(const char *buffer); -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletBodyNode::init_type(); - register_type(_type_handle, "BulletSoftBodyNode", + register_type(_type_handle, "BulletSoftBodyNode", BulletBodyNode::get_class_type()); } virtual TypeHandle get_type() const { @@ -253,4 +249,3 @@ private: #include "bulletSoftBodyNode.I" #endif // __BULLET_SOFT_BODY_NODE_H__ - diff --git a/panda/src/bullet/bulletSoftBodyShape.I b/panda/src/bullet/bulletSoftBodyShape.I index 4b84077830..6cd769183d 100644 --- a/panda/src/bullet/bulletSoftBodyShape.I +++ b/panda/src/bullet/bulletSoftBodyShape.I @@ -1,28 +1,22 @@ -// Filename: bulletSoftBodyShape.I -// Created by: enn0x (06May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyShape.I + * @author enn0x + * @date 2010-05-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyShape:: ~BulletSoftBodyShape() { - // The btSoftBodyShape _shape is created and deleted internally - // by the owning btSoftBody object. It must not be deleted - // here! + // The btSoftBodyShape _shape is created and deleted internally by the + // owning btSoftBody object. It must not be deleted here! } - diff --git a/panda/src/bullet/bulletSoftBodyShape.cxx b/panda/src/bullet/bulletSoftBodyShape.cxx index f3ee4c06a0..f28050ae3b 100644 --- a/panda/src/bullet/bulletSoftBodyShape.cxx +++ b/panda/src/bullet/bulletSoftBodyShape.cxx @@ -1,27 +1,24 @@ -// Filename: bulletSoftBodyShape.cxx -// Created by: enn0x (06May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyShape.cxx + * @author enn0x + * @date 2010-05-06 + */ #include "bulletSoftBodyShape.h" #include "bulletSoftBodyNode.h" TypeHandle BulletSoftBodyShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyShape::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyShape:: BulletSoftBodyShape(btSoftBodyCollisionShape *shapePtr) { @@ -29,22 +26,18 @@ BulletSoftBodyShape(btSoftBodyCollisionShape *shapePtr) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletSoftBodyShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyShape::get_body -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyNode *BulletSoftBodyShape:: get_body() const { @@ -56,4 +49,3 @@ get_body() const { return NULL; } } - diff --git a/panda/src/bullet/bulletSoftBodyShape.h b/panda/src/bullet/bulletSoftBodyShape.h index ef8637eca2..28a5aab9a6 100644 --- a/panda/src/bullet/bulletSoftBodyShape.h +++ b/panda/src/bullet/bulletSoftBodyShape.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyShape.h -// Created by: enn0x (06May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyShape.h + * @author enn0x + * @date 2010-05-06 + */ #ifndef __BULLET_SOFT_BODY_SHAPE_H__ #define __BULLET_SOFT_BODY_SHAPE_H__ @@ -22,10 +21,9 @@ class BulletSoftBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyShape : public BulletShape { PUBLISHED: @@ -41,14 +39,13 @@ public: private: btSoftBodyCollisionShape *_shape; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletSoftBodyShape", + register_type(_type_handle, "BulletSoftBodyShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.I b/panda/src/bullet/bulletSoftBodyWorldInfo.I index 1960b31403..264bc6d77d 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.I +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.I @@ -1,35 +1,29 @@ -// Filename: bulletSoftBodyWorldInfo.I -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyWorldInfo.I + * @author enn0x + * @date 2010-03-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyWorldInfo:: ~BulletSoftBodyWorldInfo() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btSoftBodyWorldInfo &BulletSoftBodyWorldInfo:: get_info() const { return _info; } - diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx index 44a98e559d..ee1fddbc96 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.cxx +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.cxx @@ -1,78 +1,65 @@ -// Filename: bulletSoftBodyWorldInfo.cxx -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyWorldInfo.cxx + * @author enn0x + * @date 2010-03-04 + */ #include "bulletSoftBodyWorldInfo.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyWorldInfo:: BulletSoftBodyWorldInfo(btSoftBodyWorldInfo &info) : _info(info) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::garbage_collect -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: garbage_collect(int lifetime) { _info.m_sparsesdf.GarbageCollect(lifetime); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::set_air_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: set_air_density(PN_stdfloat density) { _info.air_density = (btScalar)density; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::set_water_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: set_water_density(PN_stdfloat density) { _info.water_density = (btScalar)density; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::set_water_offset -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: set_water_offset(PN_stdfloat offset) { _info.water_offset = (btScalar)offset; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::set_water_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: set_water_normal(const LVector3 &normal) { @@ -80,11 +67,9 @@ set_water_normal(const LVector3 &normal) { _info.water_normal.setValue(normal.get_x(), normal.get_y(), normal.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::set_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSoftBodyWorldInfo:: set_gravity(const LVector3 &gravity) { @@ -92,58 +77,47 @@ set_gravity(const LVector3 &gravity) { _info.m_gravity.setValue(gravity.get_x(), gravity.get_y(), gravity.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_air_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyWorldInfo:: get_air_density() const { return (PN_stdfloat)_info.air_density; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_water_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyWorldInfo:: get_water_density() const { return (PN_stdfloat)_info.water_density; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_water_offset -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletSoftBodyWorldInfo:: get_water_offset() const { return (PN_stdfloat)_info.water_offset; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_water_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletSoftBodyWorldInfo:: get_water_normal() const { return btVector3_to_LVector3(_info.water_normal); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSoftBodyWorldInfo::get_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 BulletSoftBodyWorldInfo:: get_gravity() const { return btVector3_to_LVector3(_info.m_gravity); } - diff --git a/panda/src/bullet/bulletSoftBodyWorldInfo.h b/panda/src/bullet/bulletSoftBodyWorldInfo.h index c6427f9dc0..c0aa23454b 100644 --- a/panda/src/bullet/bulletSoftBodyWorldInfo.h +++ b/panda/src/bullet/bulletSoftBodyWorldInfo.h @@ -1,16 +1,15 @@ -// Filename: bulletSoftBodyWorldInfo.h -// Created by: enn0x (04Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSoftBodyWorldInfo.h + * @author enn0x + * @date 2010-03-04 + */ #ifndef __BULLET_SOFT_BODY_WORLD_INFO_H__ #define __BULLET_SOFT_BODY_WORLD_INFO_H__ @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletSoftBodyWorldInfo -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSoftBodyWorldInfo { PUBLISHED: diff --git a/panda/src/bullet/bulletSphereShape.I b/panda/src/bullet/bulletSphereShape.I index 117136c62e..340d9b7f2e 100644 --- a/panda/src/bullet/bulletSphereShape.I +++ b/panda/src/bullet/bulletSphereShape.I @@ -1,56 +1,46 @@ -// Filename: bulletSphereShape.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphereShape.I + * @author enn0x + * @date 2010-01-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSphereShape:: ~BulletSphereShape() { delete _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSphereShape:: BulletSphereShape(const BulletSphereShape ©) : _shape(copy._shape) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletSphereShape:: operator = (const BulletSphereShape ©) { _shape = copy._shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletSphereShape:: get_radius() const { return _shape->getRadius(); } - diff --git a/panda/src/bullet/bulletSphereShape.cxx b/panda/src/bullet/bulletSphereShape.cxx index cfc7375983..1e3842bbb8 100644 --- a/panda/src/bullet/bulletSphereShape.cxx +++ b/panda/src/bullet/bulletSphereShape.cxx @@ -1,26 +1,23 @@ -// Filename: bulletSphereShape.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphereShape.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bulletSphereShape.h" TypeHandle BulletSphereShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSphereShape:: BulletSphereShape(PN_stdfloat radius) { @@ -28,59 +25,47 @@ BulletSphereShape(PN_stdfloat radius) { _shape->setUserPointer(this); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletSphereShape:: ptr() const { return _shape; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::make_from_solid -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSphereShape *BulletSphereShape:: make_from_solid(const CollisionSphere *solid) { return new BulletSphereShape(solid->get_radius()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletShape. + */ void BulletSphereShape:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletSphereShape:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_margin()); dg.add_stdfloat(get_radius()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletSphereShape:: make_from_bam(const FactoryParams ¶ms) { BulletSphereShape *param = new BulletSphereShape; @@ -93,13 +78,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphereShape::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletShape. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletShape. + */ void BulletSphereShape:: fillin(DatagramIterator &scan, BamReader *manager) { nassertv(_shape == NULL); diff --git a/panda/src/bullet/bulletSphereShape.h b/panda/src/bullet/bulletSphereShape.h index c2c3331a4d..877f24f5df 100644 --- a/panda/src/bullet/bulletSphereShape.h +++ b/panda/src/bullet/bulletSphereShape.h @@ -1,16 +1,15 @@ -// Filename: bulletSphereShape.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphereShape.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_SPHERE_SHAPE_H__ #define __BULLET_SPHERE_SHAPE_H__ @@ -23,10 +22,9 @@ #include "collisionSphere.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletSphereShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletSphereShape : public BulletShape { private: // Only used by make_from_bam @@ -62,7 +60,7 @@ public: } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletSphereShape", + register_type(_type_handle, "BulletSphereShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletSphericalConstraint.I b/panda/src/bullet/bulletSphericalConstraint.I index 39143e05fe..19a357454c 100644 --- a/panda/src/bullet/bulletSphericalConstraint.I +++ b/panda/src/bullet/bulletSphericalConstraint.I @@ -1,25 +1,21 @@ -// Filename: bulletSphericalConstraint.I -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphericalConstraint.I + * @author enn0x + * @date 2010-03-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSphericalConstraint:: ~BulletSphericalConstraint() { delete _constraint; } - diff --git a/panda/src/bullet/bulletSphericalConstraint.cxx b/panda/src/bullet/bulletSphericalConstraint.cxx index 5162ce2a5a..021dd69777 100644 --- a/panda/src/bullet/bulletSphericalConstraint.cxx +++ b/panda/src/bullet/bulletSphericalConstraint.cxx @@ -1,29 +1,26 @@ -// Filename: bulletSphericalConstraint.cxx -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphericalConstraint.cxx + * @author enn0x + * @date 2010-03-01 + */ #include "bulletSphericalConstraint.h" #include "bulletRigidBodyNode.h" TypeHandle BulletSphericalConstraint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSphericalConstraint:: -BulletSphericalConstraint(const BulletRigidBodyNode *node_a, +BulletSphericalConstraint(const BulletRigidBodyNode *node_a, const LPoint3 &pivot_a) { btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object()); @@ -32,11 +29,9 @@ BulletSphericalConstraint(const BulletRigidBodyNode *node_a, _constraint = new btPoint2PointConstraint(*ptr_a, pos_a); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSphericalConstraint:: BulletSphericalConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -52,22 +47,18 @@ BulletSphericalConstraint(const BulletRigidBodyNode *node_a, _constraint = new btPoint2PointConstraint(*ptr_a, *ptr_b, pos_a, pos_b); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTypedConstraint *BulletSphericalConstraint:: ptr() const { return _constraint; } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::set_pivot_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSphericalConstraint:: set_pivot_a(const LPoint3 &pivot_a) { @@ -75,11 +66,9 @@ set_pivot_a(const LPoint3 &pivot_a) { _constraint->setPivotA(LVecBase3_to_btVector3(pivot_a)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::set_pivot_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletSphericalConstraint:: set_pivot_b(const LPoint3 &pivot_b) { @@ -87,25 +76,20 @@ set_pivot_b(const LPoint3 &pivot_b) { _constraint->setPivotB(LVecBase3_to_btVector3(pivot_b)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::set_pivot_in_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletSphericalConstraint:: get_pivot_in_a() const { return btVector3_to_LPoint3(_constraint->getPivotInA()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletSphericalConstraint::set_pivot_in_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BulletSphericalConstraint:: get_pivot_in_b() const { return btVector3_to_LPoint3(_constraint->getPivotInB()); } - diff --git a/panda/src/bullet/bulletSphericalConstraint.h b/panda/src/bullet/bulletSphericalConstraint.h index d56735d8de..26f04825ea 100644 --- a/panda/src/bullet/bulletSphericalConstraint.h +++ b/panda/src/bullet/bulletSphericalConstraint.h @@ -1,16 +1,15 @@ -// Filename: bulletSphericalConstraint.h -// Created by: enn0x (01Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletSphericalConstraint.h + * @author enn0x + * @date 2010-03-01 + */ #ifndef __BULLET_SPHERICAL_CONSTRAINT_H__ #define __BULLET_SPHERICAL_CONSTRAINT_H__ @@ -25,20 +24,17 @@ class BulletRigidBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : BulletSphericalConstraint -// Description : A constraint between two rigid bodies, each with a -// pivot point. The pivot points are described in the -// body's local space. The constraint limits movement -// of the two rigid bodies in such a way that the -// pivot points match in global space. The spherical -// constraint can be seen as a "ball and socket" -// joint. -//////////////////////////////////////////////////////////////////// +/** + * A constraint between two rigid bodies, each with a pivot point. The pivot + * points are described in the body's local space. The constraint limits + * movement of the two rigid bodies in such a way that the pivot points match + * in global space. The spherical constraint can be seen as a "ball and + * socket" joint. + */ class EXPCL_PANDABULLET BulletSphericalConstraint : public BulletConstraint { PUBLISHED: - BulletSphericalConstraint(const BulletRigidBodyNode *node_a, + BulletSphericalConstraint(const BulletRigidBodyNode *node_a, const LPoint3 &pivot_a); BulletSphericalConstraint(const BulletRigidBodyNode *node_a, const BulletRigidBodyNode *node_b, @@ -58,14 +54,13 @@ public: private: btPoint2PointConstraint *_constraint; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { BulletConstraint::init_type(); - register_type(_type_handle, "BulletSphericalConstraint", + register_type(_type_handle, "BulletSphericalConstraint", BulletConstraint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletTickCallbackData.I b/panda/src/bullet/bulletTickCallbackData.I index e012a90756..0f11871c57 100644 --- a/panda/src/bullet/bulletTickCallbackData.I +++ b/panda/src/bullet/bulletTickCallbackData.I @@ -1,36 +1,30 @@ -// Filename: bulletTickCallbackData.I -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTickCallbackData.I + * @author enn0x + * @date 2012-11-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletTickCallbackData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletTickCallbackData:: BulletTickCallbackData(btScalar timestep) : _timestep(timestep) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletTickCallbackData::get_timestep -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletTickCallbackData:: get_timestep() const { return (PN_stdfloat)_timestep; } - diff --git a/panda/src/bullet/bulletTickCallbackData.cxx b/panda/src/bullet/bulletTickCallbackData.cxx index d05c7303ba..f5035811cd 100644 --- a/panda/src/bullet/bulletTickCallbackData.cxx +++ b/panda/src/bullet/bulletTickCallbackData.cxx @@ -1,18 +1,16 @@ -// Filename: bulletTickCallbackData.cxx -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTickCallbackData.cxx + * @author enn0x + * @date 2012-11-26 + */ #include "bulletTickCallbackData.h" TypeHandle BulletTickCallbackData::_type_handle; - diff --git a/panda/src/bullet/bulletTickCallbackData.h b/panda/src/bullet/bulletTickCallbackData.h index 0e7012d384..80c8570fe1 100644 --- a/panda/src/bullet/bulletTickCallbackData.h +++ b/panda/src/bullet/bulletTickCallbackData.h @@ -1,16 +1,15 @@ -// Filename: bulletTickCallbackData.h -// Created by: enn0x (26Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTickCallbackData.h + * @author enn0x + * @date 2012-11-26 + */ #ifndef __BULLET_TICK_CALLBACK_DATA_H__ #define __BULLET_TICK_CALLBACK_DATA_H__ @@ -21,10 +20,9 @@ #include "bullet_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletTickCallbackData -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletTickCallbackData : public CallbackData { PUBLISHED: @@ -35,14 +33,13 @@ PUBLISHED: private: btScalar _timestep; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { CallbackData::init_type(); - register_type(_type_handle, "BulletTickCallbackData", + register_type(_type_handle, "BulletTickCallbackData", CallbackData::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.I b/panda/src/bullet/bulletTranslationalLimitMotor.I index 6f492dac63..2972994e39 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.I +++ b/panda/src/bullet/bulletTranslationalLimitMotor.I @@ -1,23 +1,19 @@ -// Filename: bulletTranslationalLimitMotor.I -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTranslationalLimitMotor.I + * @author enn0x + * @date 2013-03-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::is_limited -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletTranslationalLimitMotor:: is_limited(int axis) const { @@ -25,11 +21,9 @@ is_limited(int axis) const { return _motor.isLimited(axis); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_motor_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_motor_enabled(int axis, bool enabled) { @@ -37,11 +31,9 @@ set_motor_enabled(int axis, bool enabled) { _motor.m_enableMotor[axis] = enabled; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::get_motor_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletTranslationalLimitMotor:: get_motor_enabled(int axis) const { @@ -49,11 +41,9 @@ get_motor_enabled(int axis) const { return _motor.m_enableMotor[axis]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_low_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_low_limit(const LVecBase3 &limit) { @@ -61,11 +51,9 @@ set_low_limit(const LVecBase3 &limit) { _motor.m_lowerLimit = LVecBase3_to_btVector3(limit); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_high_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_high_limit(const LVecBase3 &limit) { @@ -73,11 +61,9 @@ set_high_limit(const LVecBase3 &limit) { _motor.m_upperLimit = LVecBase3_to_btVector3(limit); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_target_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_target_velocity(const LVecBase3 &velocity) { @@ -85,11 +71,9 @@ set_target_velocity(const LVecBase3 &velocity) { _motor.m_targetVelocity = LVecBase3_to_btVector3(velocity); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_max_motor_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_max_motor_force(const LVecBase3 &force) { @@ -97,44 +81,36 @@ set_max_motor_force(const LVecBase3 &force) { _motor.m_maxMotorForce = LVecBase3_to_btVector3(force); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_damping(PN_stdfloat damping) { _motor.m_damping = (btScalar)damping; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_softness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_softness(PN_stdfloat softness) { _motor.m_limitSoftness = (btScalar)softness; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_restitution(PN_stdfloat restitution) { _motor.m_restitution = (btScalar)restitution; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_normal_cfm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_normal_cfm(const LVecBase3 &cfm) { @@ -142,11 +118,9 @@ set_normal_cfm(const LVecBase3 &cfm) { _motor.m_normalCFM = LVecBase3_to_btVector3(cfm); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_stop_cfm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_stop_cfm(const LVecBase3 &cfm) { @@ -154,11 +128,9 @@ set_stop_cfm(const LVecBase3 &cfm) { _motor.m_stopCFM = LVecBase3_to_btVector3(cfm); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::set_stop_erp -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTranslationalLimitMotor:: set_stop_erp(const LVecBase3 &erp) { @@ -166,14 +138,10 @@ set_stop_erp(const LVecBase3 &erp) { _motor.m_stopERP = LVecBase3_to_btVector3(erp); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::get_current_limit -// Access: Published -// Description: Retrieves the current value of angle: -// 0 = free, -// 1 = at low limit, -// 2 = at high limit. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at + * high limit. + */ INLINE int BulletTranslationalLimitMotor:: get_current_limit(int axis) const { @@ -181,36 +149,29 @@ get_current_limit(int axis) const { return _motor.m_currentLimit[axis]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::get_current_error -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletTranslationalLimitMotor:: get_current_error() const { return btVector3_to_LVector3(_motor.m_currentLimitError); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::get_current_diff -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 BulletTranslationalLimitMotor:: get_current_diff() const { return btVector3_to_LPoint3(_motor.m_currentLinearDiff); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::get_accumulated_impulse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletTranslationalLimitMotor:: get_accumulated_impulse() const { return btVector3_to_LVector3(_motor.m_accumulatedImpulse); } - diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.cxx b/panda/src/bullet/bulletTranslationalLimitMotor.cxx index 5164935ed3..fdf0b55501 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.cxx +++ b/panda/src/bullet/bulletTranslationalLimitMotor.cxx @@ -1,48 +1,40 @@ -// Filename: bulletTranslationalLimitMotor.cxx -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTranslationalLimitMotor.cxx + * @author enn0x + * @date 2013-03-03 + */ #include "bulletTranslationalLimitMotor.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletTranslationalLimitMotor:: -BulletTranslationalLimitMotor(btTranslationalLimitMotor &motor) +BulletTranslationalLimitMotor(btTranslationalLimitMotor &motor) : _motor(motor) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletTranslationalLimitMotor:: BulletTranslationalLimitMotor(const BulletTranslationalLimitMotor ©) : _motor(copy._motor) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletTranslationalLimitMotor::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletTranslationalLimitMotor:: ~BulletTranslationalLimitMotor() { } - diff --git a/panda/src/bullet/bulletTranslationalLimitMotor.h b/panda/src/bullet/bulletTranslationalLimitMotor.h index 9330d1fd1f..bfbdd5e870 100644 --- a/panda/src/bullet/bulletTranslationalLimitMotor.h +++ b/panda/src/bullet/bulletTranslationalLimitMotor.h @@ -1,16 +1,15 @@ -// Filename: bulletTranslationalLimitMotor.h -// Created by: enn0x (03Mar13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTranslationalLimitMotor.h + * @author enn0x + * @date 2013-03-03 + */ #ifndef __BULLET_TRANSLATIONAL_LIMIT_MOTOR_H__ #define __BULLET_TRANSLATIONAL_LIMIT_MOTOR_H__ @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletTranslationalLimitMotor -// Description : Rotation Limit structure for generic joints. -//////////////////////////////////////////////////////////////////// +/** + * Rotation Limit structure for generic joints. + */ class EXPCL_PANDABULLET BulletTranslationalLimitMotor { PUBLISHED: diff --git a/panda/src/bullet/bulletTriangleMesh.I b/panda/src/bullet/bulletTriangleMesh.I index 533bea1e93..4c3b8f83b8 100644 --- a/panda/src/bullet/bulletTriangleMesh.I +++ b/panda/src/bullet/bulletTriangleMesh.I @@ -1,48 +1,40 @@ -// Filename: bulletTriangleMesh.I -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMesh.I + * @author enn0x + * @date 2010-02-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletTriangleMesh:: ~BulletTriangleMesh() { delete _mesh; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTriangleMesh *BulletTriangleMesh:: ptr() const { return _mesh; } -//////////////////////////////////////////////////////////////////// -// Function: ostream::Put To Operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream & operator << (ostream &out, const BulletTriangleMesh &obj) { obj.output(out); return out; } - diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 343f0138af..651f7979bc 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/panda/src/bullet/bulletTriangleMesh.cxx @@ -1,16 +1,15 @@ -// Filename: bulletTriangleMesh.cxx -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMesh.cxx + * @author enn0x + * @date 2010-02-09 + */ #include "bulletTriangleMesh.h" @@ -20,33 +19,27 @@ TypeHandle BulletTriangleMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletTriangleMesh:: BulletTriangleMesh() { _mesh = new btTriangleMesh(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::get_num_triangles -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletTriangleMesh:: get_num_triangles() const { return _mesh->getNumTriangles(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::preallocate -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: preallocate(int num_verts, int num_indices) { @@ -54,11 +47,9 @@ preallocate(int num_verts, int num_indices) { _mesh->preallocateIndices(num_indices); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::add_triangle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remove_duplicate_vertices) { @@ -73,33 +64,27 @@ add_triangle(const LPoint3 &p0, const LPoint3 &p1, const LPoint3 &p2, bool remov remove_duplicate_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::set_welding_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: set_welding_distance(PN_stdfloat distance) { _mesh->m_weldingThreshold = distance; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::get_welding_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletTriangleMesh:: get_welding_distance() const { return _mesh->m_weldingThreshold; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::add_geom -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState *ts) { @@ -151,11 +136,9 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::add_array -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_duplicate_vertices) { @@ -182,22 +165,18 @@ add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_dupli } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: output(ostream &out) const { out << get_type() << ", " << _mesh->getNumTriangles(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMesh:: write(ostream &out, int indent_level) const { @@ -213,23 +192,18 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletTriangleMesh. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletTriangleMesh. + */ void BulletTriangleMesh:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletTriangleMesh:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_welding_distance()); @@ -279,14 +253,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletTriangleMesh:: make_from_bam(const FactoryParams ¶ms) { BulletTriangleMesh *param = new BulletTriangleMesh; @@ -299,13 +270,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMesh::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletTriangleMesh. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletTriangleMesh. + */ void BulletTriangleMesh:: fillin(DatagramIterator &scan, BamReader *manager) { set_welding_distance(scan.get_stdfloat()); @@ -331,7 +299,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _mesh->addIndex(scan.get_int32()); } - // Since we manually added the vertices individually, we have to - // update the triangle count appropriately. + // Since we manually added the vertices individually, we have to update the + // triangle count appropriately. _mesh->getIndexedMeshArray()[0].m_numTriangles = num_triangles; } diff --git a/panda/src/bullet/bulletTriangleMesh.h b/panda/src/bullet/bulletTriangleMesh.h index 8b363a1c48..ade3ccfd7f 100644 --- a/panda/src/bullet/bulletTriangleMesh.h +++ b/panda/src/bullet/bulletTriangleMesh.h @@ -1,16 +1,15 @@ -// Filename: bulletTriangleMesh.h -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMesh.h + * @author enn0x + * @date 2010-02-09 + */ #ifndef __BULLET_TRIANGLE_MESH_H__ #define __BULLET_TRIANGLE_MESH_H__ @@ -27,10 +26,9 @@ #include "pta_LVecBase3.h" #include "pta_int.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletTriangleMesh -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletTriangleMesh : public TypedWritableReferenceCount { PUBLISHED: @@ -44,7 +42,7 @@ PUBLISHED: void add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_duplicate_vertices=false); - void add_geom(const Geom *geom, + void add_geom(const Geom *geom, bool remove_duplicate_vertices=false, const TransformState *ts=TransformState::make_identity()); @@ -77,7 +75,7 @@ public: } static void init_type() { TypedWritableReferenceCount::init_type(); - register_type(_type_handle, "BulletTriangleMesh", + register_type(_type_handle, "BulletTriangleMesh", TypedWritableReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletTriangleMeshShape.I b/panda/src/bullet/bulletTriangleMeshShape.I index 136812d100..abb51607b4 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.I +++ b/panda/src/bullet/bulletTriangleMeshShape.I @@ -1,22 +1,19 @@ -// Filename: bulletTriangleMeshShape.I -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMeshShape.I + * @author enn0x + * @date 2010-02-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletTriangleMeshShape:: BulletTriangleMeshShape(const BulletTriangleMeshShape ©) : _bvh_shape(copy._bvh_shape), @@ -24,11 +21,9 @@ BulletTriangleMeshShape(const BulletTriangleMeshShape ©) : _mesh(copy._mesh) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletTriangleMeshShape:: operator = (const BulletTriangleMeshShape ©) { @@ -37,11 +32,9 @@ operator = (const BulletTriangleMeshShape ©) { _mesh = copy._mesh; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletTriangleMeshShape:: ~BulletTriangleMeshShape() { @@ -54,25 +47,20 @@ INLINE BulletTriangleMeshShape:: } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::is_static -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletTriangleMeshShape:: is_static() const { return (_bvh_shape != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::is_dynamic -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletTriangleMeshShape:: is_dynamic() const { return (_gimpact_shape != NULL); } - diff --git a/panda/src/bullet/bulletTriangleMeshShape.cxx b/panda/src/bullet/bulletTriangleMeshShape.cxx index 1df03d7e32..62252db221 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.cxx +++ b/panda/src/bullet/bulletTriangleMeshShape.cxx @@ -1,16 +1,15 @@ -// Filename: bulletTriangleMeshShape.cxx -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMeshShape.cxx + * @author enn0x + * @date 2010-02-09 + */ #include "bulletTriangleMeshShape.h" #include "bulletTriangleMesh.h" @@ -21,11 +20,9 @@ TypeHandle BulletTriangleMeshShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::Constructor -// Access: Private -// Description: Only used by make_from_bam. -//////////////////////////////////////////////////////////////////// +/** + * Only used by make_from_bam. + */ BulletTriangleMeshShape:: BulletTriangleMeshShape() : _mesh(NULL), @@ -36,12 +33,10 @@ BulletTriangleMeshShape() : _bvh(false) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::Constructor -// Access: Published -// Description: The parameters 'compress' and 'bvh' are only used -// if 'dynamic' is set to FALSE. -//////////////////////////////////////////////////////////////////// +/** + * The parameters 'compress' and 'bvh' are only used if 'dynamic' is set to + * FALSE. + */ BulletTriangleMeshShape:: BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, bool bvh) : _dynamic(dynamic), @@ -83,11 +78,9 @@ BulletTriangleMeshShape(BulletTriangleMesh *mesh, bool dynamic, bool compress, b } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::ptr -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionShape *BulletTriangleMeshShape:: ptr() const { @@ -102,11 +95,9 @@ ptr() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::refit_tree -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletTriangleMeshShape:: refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max) { @@ -119,23 +110,18 @@ refit_tree(const LPoint3 &aabb_min, const LPoint3 &aabb_max) { LVecBase3_to_btVector3(aabb_max)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BulletTriangleMeshShape. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BulletTriangleMeshShape. + */ void BulletTriangleMeshShape:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BulletTriangleMeshShape:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(get_margin()); @@ -149,13 +135,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int BulletTriangleMeshShape:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = BulletShape::complete_pointers(p_list, manager); @@ -177,14 +160,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BulletShape is encountered -// in the Bam file. It should create the BulletShape -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BulletShape is encountered in the Bam file. It should create the + * BulletShape and extract its information from the file. + */ TypedWritable *BulletTriangleMeshShape:: make_from_bam(const FactoryParams ¶ms) { BulletTriangleMeshShape *param = new BulletTriangleMeshShape; @@ -197,13 +177,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: BulletTriangleMeshShape::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BulletTriangleMeshShape. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BulletTriangleMeshShape. + */ void BulletTriangleMeshShape:: fillin(DatagramIterator &scan, BamReader *manager) { PN_stdfloat margin = scan.get_stdfloat(); diff --git a/panda/src/bullet/bulletTriangleMeshShape.h b/panda/src/bullet/bulletTriangleMeshShape.h index 5c8faa0cab..7a40dd5782 100644 --- a/panda/src/bullet/bulletTriangleMeshShape.h +++ b/panda/src/bullet/bulletTriangleMeshShape.h @@ -1,16 +1,15 @@ -// Filename: bulletTriangleMeshShape.h -// Created by: enn0x (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletTriangleMeshShape.h + * @author enn0x + * @date 2010-02-09 + */ #ifndef __BULLET_TRIANGLE_MESH_SHAPE_H__ #define __BULLET_TRIANGLE_MESH_SHAPE_H__ @@ -24,10 +23,9 @@ class BulletTriangleMesh; -//////////////////////////////////////////////////////////////////// -// Class : BulletTriangleMeshShape -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletTriangleMeshShape : public BulletShape { private: INLINE BulletTriangleMeshShape(); @@ -72,7 +70,7 @@ public: } static void init_type() { BulletShape::init_type(); - register_type(_type_handle, "BulletTriangleMeshShape", + register_type(_type_handle, "BulletTriangleMeshShape", BulletShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletVehicle.I b/panda/src/bullet/bulletVehicle.I index ed4ab05779..b167ab5303 100644 --- a/panda/src/bullet/bulletVehicle.I +++ b/panda/src/bullet/bulletVehicle.I @@ -1,194 +1,158 @@ -// Filename: bulletVehicle.I -// Created by: enn0x (16Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletVehicle.I + * @author enn0x + * @date 2010-02-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletVehicle:: ~BulletVehicle() { delete _vehicle; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_vehicle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btRaycastVehicle *BulletVehicle:: get_vehicle() const { return _vehicle; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_tuning -// Access: Published -// Description: Returns a reference to the BulletVehicleTuning -// object of this vehicle which offers various -// vehicle-global tuning options. Make sure to -// configure this before adding wheels! -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the BulletVehicleTuning object of this vehicle which + * offers various vehicle-global tuning options. Make sure to configure this + * before adding wheels! + */ BulletVehicleTuning &BulletVehicle:: get_tuning() { return _tuning; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_num_wheels -// Access: Published -// Description: Returns the number of wheels this vehicle has. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of wheels this vehicle has. + */ INLINE int BulletVehicle:: get_num_wheels() const { return _vehicle->getNumWheels(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_suspension_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_suspension_stiffness(PN_stdfloat value) { _.m_suspensionStiffness = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_suspension_compression -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_suspension_compression(PN_stdfloat value) { _.m_suspensionCompression = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_suspension_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_suspension_damping(PN_stdfloat value) { _.m_suspensionDamping = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_max_suspension_travel_cm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_max_suspension_travel_cm(PN_stdfloat value) { _.m_maxSuspensionTravelCm = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_friction_slip -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_friction_slip(PN_stdfloat value) { _.m_frictionSlip = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::set_max_suspension_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicleTuning:: set_max_suspension_force(PN_stdfloat value) { _.m_maxSuspensionForce = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_suspension_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_suspension_stiffness() const { return (PN_stdfloat)_.m_suspensionStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_suspension_compression -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_suspension_compression() const { return (PN_stdfloat)_.m_suspensionCompression; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_suspension_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_suspension_damping() const { return (PN_stdfloat)_.m_suspensionDamping; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_max_suspension_travel_cm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_max_suspension_travel_cm() const { return (PN_stdfloat)_.m_maxSuspensionTravelCm; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_friction_slip -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_friction_slip() const { return (PN_stdfloat)_.m_frictionSlip; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicleTuning::get_max_suspension_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletVehicleTuning:: get_max_suspension_force() const { return (PN_stdfloat)_.m_maxSuspensionForce; } - diff --git a/panda/src/bullet/bulletVehicle.cxx b/panda/src/bullet/bulletVehicle.cxx index 9e377a0dd2..381f8ab6c8 100644 --- a/panda/src/bullet/bulletVehicle.cxx +++ b/panda/src/bullet/bulletVehicle.cxx @@ -1,16 +1,15 @@ -// Filename: bulletVehicle.cxx -// Created by: enn0x (16Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletVehicle.cxx + * @author enn0x + * @date 2010-02-16 + */ #include "bulletVehicle.h" #include "bulletWorld.h" @@ -19,12 +18,10 @@ TypeHandle BulletVehicle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::Constructor -// Access: Published -// Description: Creates a new BulletVehicle instance in the given -// world and with a chassis node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new BulletVehicle instance in the given world and with a chassis + * node. + */ BulletVehicle:: BulletVehicle(BulletWorld *world, BulletRigidBodyNode *chassis) { @@ -36,12 +33,10 @@ BulletVehicle(BulletWorld *world, BulletRigidBodyNode *chassis) { set_coordinate_system(get_default_up_axis()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::set_coordinate_system -// Access: Published -// Description: Specifies which axis is "up". Nessecary for the -// vehicle's suspension to work properly! -//////////////////////////////////////////////////////////////////// +/** + * Specifies which axis is "up". Nessecary for the vehicle's suspension to + * work properly! + */ void BulletVehicle:: set_coordinate_system(BulletUpAxis up) { @@ -61,25 +56,19 @@ set_coordinate_system(BulletUpAxis up) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_forward_vector -// Access: Published -// Description: Returns the forward vector representing the car's -// actual direction of movement. The forward vetcor -// is given in global coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the forward vector representing the car's actual direction of + * movement. The forward vetcor is given in global coordinates. + */ LVector3 BulletVehicle:: get_forward_vector() const { return btVector3_to_LVector3(_vehicle->getForwardVector()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_chassis -// Access: Published -// Description: Returns the chassis of this vehicle. The chassis -// is a rigid body node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the chassis of this vehicle. The chassis is a rigid body node. + */ BulletRigidBodyNode *BulletVehicle:: get_chassis() { @@ -87,35 +76,28 @@ get_chassis() { return (bodyPtr) ? (BulletRigidBodyNode *)bodyPtr->getUserPointer() : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_current_speed_km_hour -// Access: Published -// Description: Returns the current speed in kilometers per hour. -// Convert to miles using: km/h * 0.62 = mph -//////////////////////////////////////////////////////////////////// +/** + * Returns the current speed in kilometers per hour. Convert to miles using: + * km/h * 0.62 = mph + */ PN_stdfloat BulletVehicle:: get_current_speed_km_hour() const { return (PN_stdfloat)_vehicle->getCurrentSpeedKmHour(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::reset_suspension -// Access: Published -// Description: Resets the vehicle's suspension. -//////////////////////////////////////////////////////////////////// +/** + * Resets the vehicle's suspension. + */ void BulletVehicle:: reset_suspension() { _vehicle->resetSuspension(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_steering_value -// Access: Published -// Description: Returns the steering angle of the wheel with index -// idx in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the steering angle of the wheel with index idx in degrees. + */ PN_stdfloat BulletVehicle:: get_steering_value(int idx) const { @@ -123,12 +105,9 @@ get_steering_value(int idx) const { return rad_2_deg(_vehicle->getSteeringValue(idx)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::set_steering_value -// Access: Published -// Description: Sets the steering value (in degrees) of the wheel -// with index idx. -//////////////////////////////////////////////////////////////////// +/** + * Sets the steering value (in degrees) of the wheel with index idx. + */ void BulletVehicle:: set_steering_value(PN_stdfloat steering, int idx) { @@ -136,12 +115,9 @@ set_steering_value(PN_stdfloat steering, int idx) { _vehicle->setSteeringValue(deg_2_rad(steering), idx); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::apply_engine_force -// Access: Published -// Description: Applies force at the wheel with index idx for -// acceleration. -//////////////////////////////////////////////////////////////////// +/** + * Applies force at the wheel with index idx for acceleration. + */ void BulletVehicle:: apply_engine_force(PN_stdfloat force, int idx) { @@ -149,11 +125,9 @@ apply_engine_force(PN_stdfloat force, int idx) { _vehicle->applyEngineForce(force, idx); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::set_brake -// Access: Published -// Description: Applies braking force to the wheel with index idx. -//////////////////////////////////////////////////////////////////// +/** + * Applies braking force to the wheel with index idx. + */ void BulletVehicle:: set_brake(PN_stdfloat brake, int idx) { @@ -161,23 +135,18 @@ set_brake(PN_stdfloat brake, int idx) { _vehicle->setBrake(brake, idx); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::set_pitch_control -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicle:: set_pitch_control(PN_stdfloat pitch) { _vehicle->setPitchControl(pitch); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::create_wheel -// Access: Published -// Description: Factory method for creating wheels for this -// vehicle instance. -//////////////////////////////////////////////////////////////////// +/** + * Factory method for creating wheels for this vehicle instance. + */ BulletWheel BulletVehicle:: create_wheel() { @@ -195,11 +164,9 @@ create_wheel() { return BulletWheel(info); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_axis -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btVector3 BulletVehicle:: get_axis(int idx) { @@ -215,13 +182,10 @@ get_axis(int idx) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::get_wheel -// Access: Published -// Description: Returns the BulletWheel with index idx. Causes an -// AssertionError if idx is equal or larger than the -// number of wheels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BulletWheel with index idx. Causes an AssertionError if idx is + * equal or larger than the number of wheels. + */ BulletWheel BulletVehicle:: get_wheel(int idx) const { @@ -229,11 +193,9 @@ get_wheel(int idx) const { return BulletWheel(_vehicle->getWheelInfo(idx)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletVehicle::sync_b2p -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletVehicle:: sync_b2p() { @@ -246,7 +208,7 @@ sync_b2p() { CPT(TransformState) ts = btTrans_to_TransformState(info.m_worldTransform); // Transform relative to wheel node's parent - //node->set_transform(ts); + // node->set_transform(ts); // Transform absolute NodePath np = NodePath::any_path(node); @@ -254,4 +216,3 @@ sync_b2p() { } } } - diff --git a/panda/src/bullet/bulletVehicle.h b/panda/src/bullet/bulletVehicle.h index 1cae448b30..7ced2acb46 100644 --- a/panda/src/bullet/bulletVehicle.h +++ b/panda/src/bullet/bulletVehicle.h @@ -1,16 +1,15 @@ -// Filename: bulletVehicle.h -// Created by: enn0x (16Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletVehicle.h + * @author enn0x + * @date 2010-02-16 + */ #ifndef __BULLET_VEHICLE_H__ #define __BULLET_VEHICLE_H__ @@ -27,10 +26,9 @@ class BulletWorld; class BulletRigidBodyNode; class BulletWheel; -//////////////////////////////////////////////////////////////////// -// Class : BulletVehicleTuning -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletVehicleTuning { PUBLISHED: @@ -54,14 +52,12 @@ private: friend class BulletVehicle; }; -//////////////////////////////////////////////////////////////////// -// Class : BulletVehicle -// Description : Simulates a raycast vehicle which casts a ray per -// wheel at the ground as a cheap replacement for -// complex suspension simulation. The suspension can -// be tuned in various ways. It is possible to add a -// (probably) arbitrary number of wheels. -//////////////////////////////////////////////////////////////////// +/** + * Simulates a raycast vehicle which casts a ray per wheel at the ground as a + * cheap replacement for complex suspension simulation. The suspension can be + * tuned in various ways. It is possible to add a (probably) arbitrary number + * of wheels. + */ class EXPCL_PANDABULLET BulletVehicle : public TypedReferenceCount { PUBLISHED: @@ -104,14 +100,13 @@ private: static btVector3 get_axis(int idx); -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "BulletVehicle", + register_type(_type_handle, "BulletVehicle", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bulletWheel.I b/panda/src/bullet/bulletWheel.I index 550fe33021..ed724e184b 100644 --- a/panda/src/bullet/bulletWheel.I +++ b/panda/src/bullet/bulletWheel.I @@ -1,43 +1,36 @@ -// Filename: bulletWheel.I -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWheel.I + * @author enn0x + * @date 2010-02-17 + */ -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletWheel:: ~BulletWheel() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletWheelRaycastInfo:: ~BulletWheelRaycastInfo() { } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::empty -// Access: Public -// Description: Named constructor intended to be used for asserts -// with have to return a concrete value. -//////////////////////////////////////////////////////////////////// +/** + * Named constructor intended to be used for asserts with have to return a + * concrete value. + */ INLINE BulletWheel BulletWheel:: empty() { @@ -47,91 +40,74 @@ empty() { return BulletWheel(info); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::is_in_contact -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BulletWheelRaycastInfo:: is_in_contact() const { return _info.m_isInContact; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_suspension_length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat BulletWheelRaycastInfo:: get_suspension_length() const { return _info.m_suspensionLength; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_contact_point_ws -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 BulletWheelRaycastInfo:: get_contact_point_ws() const { return btVector3_to_LPoint3(_info.m_contactPointWS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_hard_point_ws -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 BulletWheelRaycastInfo:: get_hard_point_ws() const { return btVector3_to_LPoint3(_info.m_hardPointWS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_contact_normal_ws -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletWheelRaycastInfo:: get_contact_normal_ws() const { return btVector3_to_LVector3(_info.m_contactNormalWS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_wheel_direction_ws -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletWheelRaycastInfo:: get_wheel_direction_ws() const { return btVector3_to_LVector3(_info.m_wheelDirectionWS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_wheel_axle_ws -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 BulletWheelRaycastInfo:: get_wheel_axle_ws() const { return btVector3_to_LVector3(_info.m_wheelAxleWS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::get_ground_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *BulletWheelRaycastInfo:: get_ground_object() const { return _info.m_groundObject ? (PandaNode *)_info.m_groundObject : NULL; } - diff --git a/panda/src/bullet/bulletWheel.cxx b/panda/src/bullet/bulletWheel.cxx index 7be7f96df5..687e5ea892 100644 --- a/panda/src/bullet/bulletWheel.cxx +++ b/panda/src/bullet/bulletWheel.cxx @@ -1,457 +1,366 @@ -// Filename: bulletWheel.cxx -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWheel.cxx + * @author enn0x + * @date 2010-02-17 + */ #include "bulletWheel.h" -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletWheel:: BulletWheel(btWheelInfo &info) : _info(info) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheelRaycastInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletWheelRaycastInfo:: BulletWheelRaycastInfo(btWheelInfo::RaycastInfo &info) : _info(info) { } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_raycast_info -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletWheelRaycastInfo BulletWheel:: get_raycast_info() const { return BulletWheelRaycastInfo(_info.m_raycastInfo); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_suspension_rest_length -// Access: Published -// Description: Returns the length of the suspension when the -// vehicle is standing still. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the suspension when the vehicle is standing still. + */ PN_stdfloat BulletWheel:: get_suspension_rest_length() const { return (PN_stdfloat)_info.getSuspensionRestLength(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_suspension_stiffness -// Access: Published -// Description: Sets how stiff the suspension shall be. -//////////////////////////////////////////////////////////////////// +/** + * Sets how stiff the suspension shall be. + */ void BulletWheel:: set_suspension_stiffness(PN_stdfloat value) { _info.m_suspensionStiffness = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_suspension_stiffness -// Access: Published -// Description: Returns the stiffness of the suspension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stiffness of the suspension. + */ PN_stdfloat BulletWheel:: get_suspension_stiffness() const { return (PN_stdfloat)_info.m_suspensionStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_max_suspension_travel_cm -// Access: Published -// Description: Sets the maximum distance the suspension can travel -// out of the resting position in centimeters. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum distance the suspension can travel out of the resting + * position in centimeters. + */ void BulletWheel:: set_max_suspension_travel_cm(PN_stdfloat value) { _info.m_maxSuspensionTravelCm = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_max_suspension_travel_cm -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_max_suspension_travel_cm() const { return (PN_stdfloat)_info.m_maxSuspensionTravelCm; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_friction_slip -// Access: Published -// Description: Sets the slipperyness of the tyre. -//////////////////////////////////////////////////////////////////// +/** + * Sets the slipperyness of the tyre. + */ void BulletWheel:: set_friction_slip(PN_stdfloat value) { _info.m_frictionSlip = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_friction_slip -// Access: Published -// Description: Returns how slippery the tyres are. -//////////////////////////////////////////////////////////////////// +/** + * Returns how slippery the tyres are. + */ PN_stdfloat BulletWheel:: get_friction_slip() const { return (PN_stdfloat)_info.m_frictionSlip; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_max_suspension_force -// Access: Published -// Description: Sets the maximum suspension force the wheel can -// handle. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum suspension force the wheel can handle. + */ void BulletWheel:: set_max_suspension_force(PN_stdfloat value) { _info.m_maxSuspensionForce = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_max_suspension_force -// Access: Published -// Description: Returns the maximum force (weight) the suspension -// can handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum force (weight) the suspension can handle. + */ PN_stdfloat BulletWheel:: get_max_suspension_force() const { return (PN_stdfloat)_info.m_maxSuspensionForce; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheels_damping_compression -// Access: Published -// Description: Sets the damping forces applied when the suspension -// gets compressed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the damping forces applied when the suspension gets compressed. + */ void BulletWheel:: set_wheels_damping_compression(PN_stdfloat value) { _info.m_wheelsDampingCompression = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheels_damping_compression -// Access: Published -// Description: Returns the damping applied to the compressing -// suspension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the damping applied to the compressing suspension. + */ PN_stdfloat BulletWheel:: get_wheels_damping_compression() const { return (PN_stdfloat)_info.m_wheelsDampingCompression; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheels_damping_relaxation -// Access: Published -// Description: Sets the damping forces applied when the suspension -// relaxes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the damping forces applied when the suspension relaxes. + */ void BulletWheel:: set_wheels_damping_relaxation(PN_stdfloat value) { _info.m_wheelsDampingRelaxation = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheels_damping_relaxation -// Access: Published -// Description: Returns the damping applied to the relaxing -// suspension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the damping applied to the relaxing suspension. + */ PN_stdfloat BulletWheel:: get_wheels_damping_relaxation() const { return (PN_stdfloat)_info.m_wheelsDampingRelaxation; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_roll_influence -// Access: Published -// Description: Defines a scaling factor for roll forces that affect -// the chassis. 0.0 means no roll - the chassis won't -// ever flip over - while 1.0 means original physical -// behaviour. Basically, this allows moving the center -// of mass up and down. -//////////////////////////////////////////////////////////////////// +/** + * Defines a scaling factor for roll forces that affect the chassis. 0.0 + * means no roll - the chassis won't ever flip over - while 1.0 means original + * physical behaviour. Basically, this allows moving the center of mass up + * and down. + */ void BulletWheel:: set_roll_influence(PN_stdfloat value) { _info.m_rollInfluence = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_roll_influence -// Access: Published -// Description: Returns the factor by which roll forces are scaled. -// See set_roll_influence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the factor by which roll forces are scaled. See + * set_roll_influence. + */ PN_stdfloat BulletWheel:: get_roll_influence() const { return (PN_stdfloat)_info.m_rollInfluence; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheel_radius -// Access: Published -// Description: Sets the wheel radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the wheel radius. + */ void BulletWheel:: set_wheel_radius(PN_stdfloat value) { _info.m_wheelsRadius = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheel_radius -// Access: Published -// Description: Returns the wheel radius. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wheel radius. + */ PN_stdfloat BulletWheel:: get_wheel_radius() const { return (PN_stdfloat)_info.m_wheelsRadius; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_steering -// Access: Published -// Description: Sets the steering angle. -//////////////////////////////////////////////////////////////////// +/** + * Sets the steering angle. + */ void BulletWheel:: set_steering(PN_stdfloat value) { _info.m_steering = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_steering -// Access: Published -// Description: Returns the steering angle in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the steering angle in degrees. + */ PN_stdfloat BulletWheel:: get_steering() const { return (PN_stdfloat)_info.m_steering; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_rotation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_rotation(PN_stdfloat value) { _info.m_rotation = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_rotation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_rotation() const { return (PN_stdfloat)_info.m_rotation; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_delta_rotation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_delta_rotation(PN_stdfloat value) { _info.m_deltaRotation = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_delta_rotation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_delta_rotation() const { return (PN_stdfloat)_info.m_deltaRotation; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_engine_force -// Access: Published -// Description: Defines how much force should be used to rotate the -// wheel. -//////////////////////////////////////////////////////////////////// +/** + * Defines how much force should be used to rotate the wheel. + */ void BulletWheel:: set_engine_force(PN_stdfloat value) { _info.m_engineForce = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_engine_force -// Access: Published -// Description: Returns the amount of accelleration force currently -// applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of accelleration force currently applied. + */ PN_stdfloat BulletWheel:: get_engine_force() const { return (PN_stdfloat)_info.m_engineForce; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_brake -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_brake(PN_stdfloat value) { _info.m_brake = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_brake -// Access: Published -// Description: Returns the amount of braking force currently -// applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of braking force currently applied. + */ PN_stdfloat BulletWheel:: get_brake() const { return (PN_stdfloat)_info.m_brake; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_skid_info -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_skid_info(PN_stdfloat value) { _info.m_skidInfo = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_skid_info -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_skid_info() const { return (PN_stdfloat)_info.m_skidInfo; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheels_suspension_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_wheels_suspension_force(PN_stdfloat value) { _info.m_wheelsSuspensionForce = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheels_suspension_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_wheels_suspension_force() const { return (PN_stdfloat)_info.m_wheelsSuspensionForce; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_suspension_relative_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_suspension_relative_velocity(PN_stdfloat value) { _info.m_suspensionRelativeVelocity = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_suspension_relative_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_suspension_relative_velocity() const { return (PN_stdfloat)_info.m_suspensionRelativeVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_clipped_inv_connection_point_cs -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_clipped_inv_connection_point_cs(PN_stdfloat value) { _info.m_clippedInvContactDotSuspension = (btScalar)value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_clipped_inv_connection_point_cs -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BulletWheel:: get_clipped_inv_connection_point_cs() const { return (PN_stdfloat)_info.m_clippedInvContactDotSuspension; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_chassis_connection_point_cs -// Access: Published -// Description: Sets the point where the wheel is connected to the -// chassis. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point where the wheel is connected to the chassis. + */ void BulletWheel:: set_chassis_connection_point_cs(const LPoint3 &pos) { @@ -459,24 +368,19 @@ set_chassis_connection_point_cs(const LPoint3 &pos) { _info.m_chassisConnectionPointCS = LVecBase3_to_btVector3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_chassis_connection_point_cs -// Access: Published -// Description: Returns the point where the wheel is connected to -// the chassis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point where the wheel is connected to the chassis. + */ LPoint3 BulletWheel:: get_chassis_connection_point_cs() const { return btVector3_to_LPoint3(_info.m_chassisConnectionPointCS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheel_direction_cs -// Access: Published -// Description: Sets the wheel's forward vector. (Most likely -// orthogonal to the axle vector.) -//////////////////////////////////////////////////////////////////// +/** + * Sets the wheel's forward vector. (Most likely orthogonal to the axle + * vector.) + */ void BulletWheel:: set_wheel_direction_cs(const LVector3 &dir) { @@ -484,23 +388,18 @@ set_wheel_direction_cs(const LVector3 &dir) { _info.m_wheelDirectionCS = LVecBase3_to_btVector3(dir); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheel_direction_cs -// Access: Published -// Description: Returns the wheel's forward vector relative to the -// chassis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wheel's forward vector relative to the chassis. + */ LVector3 BulletWheel:: get_wheel_direction_cs() const { return btVector3_to_LVector3(_info.m_wheelDirectionCS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_wheel_axle_cs -// Access: Published -// Description: Determines the wheel axle normal vector. -//////////////////////////////////////////////////////////////////// +/** + * Determines the wheel axle normal vector. + */ void BulletWheel:: set_wheel_axle_cs(const LVector3 &axle) { @@ -508,22 +407,18 @@ set_wheel_axle_cs(const LVector3 &axle) { _info.m_wheelAxleCS = LVecBase3_to_btVector3(axle); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_wheel_axle_cs -// Access: Published -// Description: Returns the normal vector of the wheel axle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the normal vector of the wheel axle. + */ LVector3 BulletWheel:: get_wheel_axle_cs() const { return btVector3_to_LVector3(_info.m_wheelAxleCS); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_world_transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWheel:: set_world_transform(const LMatrix4 &mat) { @@ -531,61 +426,48 @@ set_world_transform(const LMatrix4 &mat) { _info.m_worldTransform = LMatrix4_to_btTrans(mat); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_world_transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4 BulletWheel:: get_world_transform() const { return btTrans_to_LMatrix4(_info.m_worldTransform); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_front_wheel -// Access: Published -// Description: Sets if the wheel is steerable. -//////////////////////////////////////////////////////////////////// +/** + * Sets if the wheel is steerable. + */ void BulletWheel:: set_front_wheel(bool value) { _info.m_bIsFrontWheel = value; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::is_front_wheel -// Access: Published -// Description: Determines if a wheel is steerable. -//////////////////////////////////////////////////////////////////// +/** + * Determines if a wheel is steerable. + */ bool BulletWheel:: is_front_wheel() const { return _info.m_bIsFrontWheel; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::set_node -// Access: Published -// Description: Sets the PandaNode which representates the visual -// appearance of this wheel. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PandaNode which representates the visual appearance of this wheel. + */ void BulletWheel:: set_node(PandaNode *node) { _info.m_clientInfo = (void *)node; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWheel::get_node -// Access: Published -// Description: Returns the PandaNode which representates the -// visual appearance of this wheel, if such a -// representation has been set previously. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PandaNode which representates the visual appearance of this + * wheel, if such a representation has been set previously. + */ PandaNode *BulletWheel:: get_node() const { return (_info.m_clientInfo == NULL) ? NULL : (PandaNode *)_info.m_clientInfo; } - diff --git a/panda/src/bullet/bulletWheel.h b/panda/src/bullet/bulletWheel.h index 539a7420f2..2f3fcc2e71 100644 --- a/panda/src/bullet/bulletWheel.h +++ b/panda/src/bullet/bulletWheel.h @@ -1,16 +1,15 @@ -// Filename: bulletWheel.h -// Created by: enn0x (17Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWheel.h + * @author enn0x + * @date 2010-02-17 + */ #ifndef __BULLET_WHEEL_H__ #define __BULLET_WHEEL_H__ @@ -23,10 +22,9 @@ #include "luse.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : BulletWheelRaycastInfo -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletWheelRaycastInfo { PUBLISHED: @@ -48,12 +46,10 @@ private: btWheelInfo::RaycastInfo &_info; }; -//////////////////////////////////////////////////////////////////// -// Class : BulletWheel -// Description : One wheel of a BulletVehicle. Instances should not -// be created directly but using the factory method -// BulletVehicle::create_wheel(). -//////////////////////////////////////////////////////////////////// +/** + * One wheel of a BulletVehicle. Instances should not be created directly but + * using the factory method BulletVehicle::create_wheel(). + */ class EXPCL_PANDABULLET BulletWheel { PUBLISHED: diff --git a/panda/src/bullet/bulletWorld.I b/panda/src/bullet/bulletWorld.I index 168aad2f13..e93dc0d176 100644 --- a/panda/src/bullet/bulletWorld.I +++ b/panda/src/bullet/bulletWorld.I @@ -1,23 +1,19 @@ -// Filename: bulletWorld.I -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWorld.I + * @author enn0x + * @date 2010-01-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletWorld:: ~BulletWorld() { @@ -54,11 +50,9 @@ INLINE BulletWorld:: delete _broadphase; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_debug_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletWorld:: set_debug_node(BulletDebugNode *node) { @@ -68,11 +62,9 @@ set_debug_node(BulletDebugNode *node) { _world->setDebugDrawer(&(_debug->_drawer)); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::clear_debug_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BulletWorld:: clear_debug_node() { @@ -80,66 +72,54 @@ clear_debug_node() { _world->setDebugDrawer(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_debug_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletDebugNode *BulletWorld:: get_debug_node() const { return _debug; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_world -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btDynamicsWorld *BulletWorld:: get_world() const { return _world; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_broadphase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btBroadphaseInterface *BulletWorld:: get_broadphase() const { return _broadphase; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_dispatcher -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE btDispatcher *BulletWorld:: get_dispatcher() const { return _dispatcher; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_rigid_bodies -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_rigid_bodies() const { return _bodies.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_rigid_body -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletRigidBodyNode *BulletWorld:: get_rigid_body(int idx) const { @@ -147,22 +127,18 @@ get_rigid_body(int idx) const { return _bodies[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_soft_bodies -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_soft_bodies() const { return _softbodies.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_soft_body -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletSoftBodyNode *BulletWorld:: get_soft_body(int idx) const { @@ -170,22 +146,18 @@ get_soft_body(int idx) const { return _softbodies[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_ghosts -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_ghosts() const { return _ghosts.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_ghost -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletGhostNode *BulletWorld:: get_ghost(int idx) const { @@ -193,22 +165,18 @@ get_ghost(int idx) const { return _ghosts[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_characters -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_characters() const { return _characters.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_character -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletBaseCharacterControllerNode *BulletWorld:: get_character(int idx) const { @@ -216,22 +184,18 @@ get_character(int idx) const { return _characters[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_vehicles -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_vehicles() const { return _vehicles.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_vehicle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletVehicle *BulletWorld:: get_vehicle(int idx) const { @@ -239,22 +203,18 @@ get_vehicle(int idx) const { return _vehicles[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_constraints -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_constraints() const { return _constraints.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_constraint -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BulletConstraint *BulletWorld:: get_constraint(int idx) const { @@ -262,15 +222,11 @@ get_constraint(int idx) const { return _constraints[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_num_manifolds -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int BulletWorld:: get_num_manifolds() const { return _world->getDispatcher()->getNumManifolds(); } - - diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index 0951ef6115..e7f6f3e267 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -1,16 +1,15 @@ -// Filename: bulletWorld.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWorld.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bulletWorld.h" #include "bulletPersistentManifold.h" @@ -31,11 +30,9 @@ PStatCollector BulletWorld::_pstat_b2p("App:Bullet:DoPhysics:SyncB2P"); PT(CallbackObject) bullet_contact_added_callback; -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletWorld:: BulletWorld() { @@ -121,22 +118,18 @@ BulletWorld() { _world->getSolverInfo().m_numIterations = bullet_solver_iterations; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_world_info -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletSoftBodyWorldInfo BulletWorld:: get_world_info() { return BulletSoftBodyWorldInfo(_info); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_gravity(const LVector3 &gravity) { @@ -144,11 +137,9 @@ set_gravity(const LVector3 &gravity) { _info.m_gravity.setValue(gravity.get_x(), gravity.get_y(), gravity.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_gravity(PN_stdfloat gx, PN_stdfloat gy, PN_stdfloat gz) { @@ -156,22 +147,18 @@ set_gravity(PN_stdfloat gx, PN_stdfloat gy, PN_stdfloat gz) { _info.m_gravity.setValue((btScalar)gx, (btScalar)gy, (btScalar)gz); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_gravity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVector3 BulletWorld:: get_gravity() const { return btVector3_to_LVector3(_world->getGravity()); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::do_physics -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BulletWorld:: do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { @@ -207,11 +194,9 @@ do_physics(PN_stdfloat dt, int max_substeps, PN_stdfloat stepsize) { return n; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::sync_p2b -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: sync_p2b(PN_stdfloat dt, int num_substeps) { @@ -232,11 +217,9 @@ sync_p2b(PN_stdfloat dt, int num_substeps) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::sync_b2p -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: sync_b2p() { @@ -261,11 +244,9 @@ sync_b2p() { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: attach(TypedObject *object) { @@ -292,11 +273,9 @@ attach(TypedObject *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: remove(TypedObject *object) { @@ -323,12 +302,9 @@ remove(TypedObject *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_rigid_body -// Access: Published -// Description: Deprecated! -// Please use BulletWorld::attach -//////////////////////////////////////////////////////////////////// +/** + * Deprecated! Please use BulletWorld::attach + */ void BulletWorld:: attach_rigid_body(BulletRigidBodyNode *node) { @@ -349,12 +325,9 @@ attach_rigid_body(BulletRigidBodyNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_rigid_body -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_rigid_body(BulletRigidBodyNode *node) { @@ -375,12 +348,9 @@ remove_rigid_body(BulletRigidBodyNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_soft_body -// Access: Published -// Description: Deprecated! -// Please use BulletWorld::attach -//////////////////////////////////////////////////////////////////// +/** + * Deprecated! Please use BulletWorld::attach + */ void BulletWorld:: attach_soft_body(BulletSoftBodyNode *node) { @@ -388,7 +358,7 @@ attach_soft_body(BulletSoftBodyNode *node) { btSoftBody *ptr = btSoftBody::upcast(node->get_object()); - // TODO: group/filter settings (see ghost objects too) + // TODO: groupfilter settings (see ghost objects too) short group = btBroadphaseProxy::DefaultFilter; short mask = btBroadphaseProxy::AllFilter; @@ -405,12 +375,9 @@ attach_soft_body(BulletSoftBodyNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_soft_body -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_soft_body(BulletSoftBodyNode *node) { @@ -431,18 +398,15 @@ remove_soft_body(BulletSoftBodyNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_ghost -// Access: Published -// Description: Deprecated! -// Please use BulletWorld::attach -//////////////////////////////////////////////////////////////////// +/** + * Deprecated! Please use BulletWorld::attach + */ void BulletWorld:: attach_ghost(BulletGhostNode *node) { nassertv(node); - // TODO group/filter settings... + // TODO groupfilter settings... /* enum CollisionFilterGroups { DefaultFilter = 1, @@ -475,12 +439,9 @@ enum CollisionFilterGroups { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_ghost -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_ghost(BulletGhostNode *node) { @@ -501,12 +462,9 @@ remove_ghost(BulletGhostNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_character -// Access: Published -// Description: Deprecated! -// Please use BulletWorld::attach -//////////////////////////////////////////////////////////////////// +/** + * Deprecated! Please use BulletWorld::attach + */ void BulletWorld:: attach_character(BulletBaseCharacterControllerNode *node) { @@ -530,12 +488,9 @@ attach_character(BulletBaseCharacterControllerNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_character -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_character(BulletBaseCharacterControllerNode *node) { @@ -555,12 +510,9 @@ remove_character(BulletBaseCharacterControllerNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_vehicle -// Access: Published -// Description: Deprecated! -// Please use BulletWorld::attach -//////////////////////////////////////////////////////////////////// +/** + * Deprecated! Please use BulletWorld::attach + */ void BulletWorld:: attach_vehicle(BulletVehicle *vehicle) { @@ -579,12 +531,9 @@ attach_vehicle(BulletVehicle *vehicle) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_vehicle -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_vehicle(BulletVehicle *vehicle) { @@ -605,13 +554,10 @@ remove_vehicle(BulletVehicle *vehicle) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::attach_constraint -// Access: Published -// Description: Attaches a single constraint to a world. Collision -// checks between the linked objects will be disabled -// if the second parameter is set to TRUE. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a single constraint to a world. Collision checks between the + * linked objects will be disabled if the second parameter is set to TRUE. + */ void BulletWorld:: attach_constraint(BulletConstraint *constraint, bool linked_collision) { @@ -630,12 +576,9 @@ attach_constraint(BulletConstraint *constraint, bool linked_collision) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::remove_constraint -// Access: Published -// Description: Deprecated.! -// Please use BulletWorld::remove -//////////////////////////////////////////////////////////////////// +/** + * Deprecated.! Please use BulletWorld::remove + */ void BulletWorld:: remove_constraint(BulletConstraint *constraint) { @@ -654,11 +597,9 @@ remove_constraint(BulletConstraint *constraint) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::ray_test_closest -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletClosestHitRayResult BulletWorld:: ray_test_closest(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask &mask) const { @@ -673,11 +614,9 @@ ray_test_closest(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMa return cb; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::ray_test_all -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletAllHitsRayResult BulletWorld:: ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask &mask) const { @@ -692,11 +631,9 @@ ray_test_all(const LPoint3 &from_pos, const LPoint3 &to_pos, const CollideMask & return cb; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::sweep_test_closest -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletClosestHitSweepResult BulletWorld:: sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const TransformState &to_ts, const CollideMask &mask, PN_stdfloat penetration) const { @@ -716,12 +653,10 @@ sweep_test_closest(BulletShape *shape, const TransformState &from_ts, const Tran return cb; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::filter_test -// Access: Published -// Description: Performs a test if two bodies should collide or -// not, based on the collision filter setting. -//////////////////////////////////////////////////////////////////// +/** + * Performs a test if two bodies should collide or not, based on the collision + * filter setting. + */ bool BulletWorld:: filter_test(PandaNode *node0, PandaNode *node1) const { @@ -744,19 +679,15 @@ filter_test(PandaNode *node0, PandaNode *node1) const { return _filter_cb->needBroadphaseCollision(proxy0, proxy1); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::contact_test -// Access: Published -// Description: Performas a test for all bodies which are -// currently in contact with the given body. -// The test returns a BulletContactResult object -// which may contain zero, one or more contacts. -// -// If the optional parameter use_filter is set to -// TRUE this test will consider filter settings. -// Otherwise all objects in contact are reported, -// no matter if they would collide or not. -//////////////////////////////////////////////////////////////////// +/** + * Performas a test for all bodies which are currently in contact with the + * given body. The test returns a BulletContactResult object which may + * contain zero, one or more contacts. + * + * If the optional parameter use_filter is set to TRUE this test will consider + * filter settings. Otherwise all objects in contact are reported, no matter + * if they would collide or not. + */ BulletContactResult BulletWorld:: contact_test(PandaNode *node, bool use_filter) const { @@ -777,14 +708,11 @@ contact_test(PandaNode *node, bool use_filter) const { return cb; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::contact_pair_test -// Access: Published -// Description: Performas a test if the two bodies given as -// parameters are in contact or not. -// The test returns a BulletContactResult object -// which may contain zero or one contacts. -//////////////////////////////////////////////////////////////////// +/** + * Performas a test if the two bodies given as parameters are in contact or + * not. The test returns a BulletContactResult object which may contain zero + * or one contacts. + */ BulletContactResult BulletWorld:: contact_test_pair(PandaNode *node0, PandaNode *node1) const { @@ -801,11 +729,9 @@ contact_test_pair(PandaNode *node0, PandaNode *node1) const { return cb; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_manifold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletPersistentManifold *BulletWorld:: get_manifold(int idx) const { @@ -815,11 +741,9 @@ get_manifold(int idx) const { return (ptr) ? new BulletPersistentManifold(ptr) : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_collision_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btCollisionObject *BulletWorld:: get_collision_object(PandaNode *node) { @@ -839,11 +763,9 @@ get_collision_object(PandaNode *node) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_group_collision_flag -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable) { @@ -855,22 +777,18 @@ set_group_collision_flag(unsigned int group1, unsigned int group2, bool enable) _filter_cb2._collide[group2].set_bit_to(group1, enable); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::get_group_collision_flag -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletWorld:: get_group_collision_flag(unsigned int group1, unsigned int group2) const { return _filter_cb2._collide[group1].get_bit(group2); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_contact_added_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_contact_added_callback(CallbackObject *obj) { @@ -881,11 +799,9 @@ set_contact_added_callback(CallbackObject *obj) { bullet_contact_added_callback = obj; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::clear_contact_added_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: clear_contact_added_callback() { @@ -896,11 +812,9 @@ clear_contact_added_callback() { bullet_contact_added_callback = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_tick_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_tick_callback(CallbackObject *obj, bool is_pretick) { @@ -909,11 +823,9 @@ set_tick_callback(CallbackObject *obj, bool is_pretick) { _world->setInternalTickCallback(&BulletWorld::tick_callback, this, is_pretick); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::clear_tick_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: clear_tick_callback() { @@ -921,11 +833,9 @@ clear_tick_callback() { _world->setInternalTickCallback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::tick_callback -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: tick_callback(btDynamicsWorld *world, btScalar timestep) { @@ -939,11 +849,9 @@ tick_callback(btDynamicsWorld *world, btScalar timestep) { } } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::set_filter_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: set_filter_callback(CallbackObject *obj) { @@ -956,22 +864,18 @@ set_filter_callback(CallbackObject *obj) { _filter_cb3._filter_callback_obj = obj; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::clear_filter_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BulletWorld:: clear_filter_callback() { _filter_cb3._filter_callback_obj = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::FilterCallback1::needBroadphaseCollision -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletWorld::btFilterCallback1:: needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const { @@ -993,11 +897,9 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co return (mask0 & mask1) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::FilterCallback2::needBroadphaseCollision -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletWorld::btFilterCallback2:: needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const { @@ -1016,12 +918,12 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co CollideMask mask0 = node0->get_into_collide_mask(); CollideMask mask1 = node1->get_into_collide_mask(); -//cout << mask0 << " " << mask1 << endl; +// cout << mask0 << " " << mask1 << endl; for (int i=0; i<32; i++) { if (mask0.get_bit(i)) { if ((_collide[i] & mask1) != 0) -//cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl; +// cout << "collide: i=" << i << " _collide[i]" << _collide[i] << endl; return true; } } @@ -1029,11 +931,9 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co return false; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::FilterCallback3::needBroadphaseCollision -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BulletWorld::btFilterCallback3:: needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) const { @@ -1056,10 +956,9 @@ needBroadphaseCollision(btBroadphaseProxy* proxy0, btBroadphaseProxy* proxy1) co return cbdata.get_collide(); } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::BroadphaseAlgorithm ostream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, BulletWorld::BroadphaseAlgorithm algorithm) { @@ -1074,10 +973,9 @@ operator << (ostream &out, BulletWorld::BroadphaseAlgorithm algorithm) { return out << "**invalid BulletWorld::BroadphaseAlgorithm(" << (int)algorithm << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::BroadphaseAlgorithm istream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, BulletWorld::BroadphaseAlgorithm &algorithm) { string word; @@ -1098,10 +996,9 @@ operator >> (istream &in, BulletWorld::BroadphaseAlgorithm &algorithm) { return in; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::FilterAlgorithm ostream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, BulletWorld::FilterAlgorithm algorithm) { @@ -1116,10 +1013,9 @@ operator << (ostream &out, BulletWorld::FilterAlgorithm algorithm) { return out << "**invalid BulletWorld::FilterAlgorithm(" << (int)algorithm << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: BulletWorld::FilterAlgorithm istream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, BulletWorld::FilterAlgorithm &algorithm) { string word; @@ -1141,4 +1037,3 @@ operator >> (istream &in, BulletWorld::FilterAlgorithm &algorithm) { } return in; } - diff --git a/panda/src/bullet/bulletWorld.h b/panda/src/bullet/bulletWorld.h index 88fca5abd1..8d39186bb0 100644 --- a/panda/src/bullet/bulletWorld.h +++ b/panda/src/bullet/bulletWorld.h @@ -1,16 +1,15 @@ -// Filename: bulletWorld.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bulletWorld.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_WORLD_H__ #define __BULLET_WORLD_H__ @@ -45,10 +44,9 @@ class BulletSoftBodyWorldInfo; extern PT(CallbackObject) bullet_contact_added_callback; -//////////////////////////////////////////////////////////////////// -// Class : BulletWorld -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDABULLET BulletWorld : public TypedReferenceCount { PUBLISHED: @@ -68,7 +66,7 @@ PUBLISHED: INLINE void clear_debug_node(); INLINE BulletDebugNode *get_debug_node() const; - // Attach/Remove + // AttachRemove void attach(TypedObject *object); void attach_constraint(BulletConstraint *constraint, bool linked_collision=false); @@ -250,14 +248,13 @@ private: BulletVehicles _vehicles; BulletConstraints _constraints; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "BulletWorld", + register_type(_type_handle, "BulletWorld", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/bullet/bullet_includes.h b/panda/src/bullet/bullet_includes.h index 14c13c8f21..4c11b5f0b7 100644 --- a/panda/src/bullet/bullet_includes.h +++ b/panda/src/bullet/bullet_includes.h @@ -1,16 +1,15 @@ -// Filename: bullet_includes.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bullet_includes.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_INCLUDES_H__ #define __BULLET_INCLUDES_H__ diff --git a/panda/src/bullet/bullet_utils.I b/panda/src/bullet/bullet_utils.I index 9ae3206782..c6570394f5 100644 --- a/panda/src/bullet/bullet_utils.I +++ b/panda/src/bullet/bullet_utils.I @@ -1,15 +1,12 @@ -// Filename: bullet_utils.I -// Created by: enn0x (25Nov10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bullet_utils.I + * @author enn0x + * @date 2010-11-25 + */ diff --git a/panda/src/bullet/bullet_utils.cxx b/panda/src/bullet/bullet_utils.cxx index a4ae140993..74ee184594 100644 --- a/panda/src/bullet/bullet_utils.cxx +++ b/panda/src/bullet/bullet_utils.cxx @@ -1,25 +1,23 @@ -// Filename: bullet_utils.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bullet_utils.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "bullet_utils.h" #include "transformState.h" -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3_to_btVector3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btVector3 LVecBase3_to_btVector3(const LVecBase3 &v) { return btVector3((btScalar)v.get_x(), @@ -27,10 +25,9 @@ btVector3 LVecBase3_to_btVector3(const LVecBase3 &v) { (btScalar)v.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: btVector3_to_LVecBase3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVecBase3 btVector3_to_LVecBase3(const btVector3 &v) { return LVecBase3((PN_stdfloat)v.getX(), @@ -38,10 +35,9 @@ LVecBase3 btVector3_to_LVecBase3(const btVector3 &v) { (PN_stdfloat)v.getZ()); } -//////////////////////////////////////////////////////////////////// -// Function: btVector3_to_LVector3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3 btVector3_to_LVector3(const btVector3 &v) { return LVector3((PN_stdfloat)v.getX(), @@ -49,10 +45,9 @@ LVector3 btVector3_to_LVector3(const btVector3 &v) { (PN_stdfloat)v.getZ()); } -//////////////////////////////////////////////////////////////////// -// Function: btVector3_to_LPoint3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 btVector3_to_LPoint3(const btVector3 &p) { return LPoint3((PN_stdfloat)p.getX(), @@ -60,10 +55,9 @@ LPoint3 btVector3_to_LPoint3(const btVector3 &p) { (PN_stdfloat)p.getZ()); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3_to_btMatrix3x3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btMatrix3x3 LMatrix3_to_btMatrix3x3(const LMatrix3 &m) { btMatrix3x3 result; @@ -71,10 +65,9 @@ btMatrix3x3 LMatrix3_to_btMatrix3x3(const LMatrix3 &m) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: btMatrix3x3_to_LMatrix3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix3 btMatrix3x3_to_LMatrix3(const btMatrix3x3 &m) { btScalar cells[9]; @@ -84,10 +77,9 @@ LMatrix3 btMatrix3x3_to_LMatrix3(const btMatrix3x3 &m) { (PN_stdfloat)cells[6], (PN_stdfloat)cells[7], (PN_stdfloat)cells[8]); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion_to_btQuat -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btQuaternion LQuaternion_to_btQuat(const LQuaternion &q) { return btQuaternion((btScalar)q.get_i(), @@ -96,10 +88,9 @@ btQuaternion LQuaternion_to_btQuat(const LQuaternion &q) { (btScalar)q.get_r()); } -//////////////////////////////////////////////////////////////////// -// Function: btQuat_to_LQuaternion -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LQuaternion btQuat_to_LQuaternion(const btQuaternion &q) { return LQuaternion((PN_stdfloat)q.getW(), @@ -108,10 +99,9 @@ LQuaternion btQuat_to_LQuaternion(const btQuaternion &q) { (PN_stdfloat)q.getZ()); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4_to_btTrans -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTransform LMatrix4_to_btTrans(const LMatrix4 &m) { LQuaternion quat; @@ -123,10 +113,9 @@ btTransform LMatrix4_to_btTrans(const LMatrix4 &m) { return btTransform(btq, btv); } -//////////////////////////////////////////////////////////////////// -// Function: btTrans_to_LMatrix4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4 btTrans_to_LMatrix4(const btTransform &trans) { return TransformState::make_pos_quat_scale( @@ -135,10 +124,9 @@ LMatrix4 btTrans_to_LMatrix4(const btTransform &trans) { LVector3(1.0f, 1.0f, 1.0f))->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: btTrans_to_TransformState -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(TransformState) btTrans_to_TransformState(const btTransform &trans, const LVecBase3 &scale) { LVecBase3 pos = btVector3_to_LVector3(trans.getOrigin()); @@ -147,10 +135,9 @@ CPT(TransformState) btTrans_to_TransformState(const btTransform &trans, const LV return TransformState::make_pos_quat_scale(pos, quat, scale); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState_to_btTrans -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ btTransform TransformState_to_btTrans(CPT(TransformState) ts) { ts = ts->set_scale(1.0); @@ -166,10 +153,9 @@ btTransform TransformState_to_btTrans(CPT(TransformState) ts) { return btTransform(btq, btv); } -//////////////////////////////////////////////////////////////////// -// Function: get_default_up_axis -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BulletUpAxis get_default_up_axis() { switch (get_default_coordinate_system()) { @@ -187,10 +173,9 @@ BulletUpAxis get_default_up_axis() { } } -//////////////////////////////////////////////////////////////////// -// Function: get_node_transform -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void get_node_transform(btTransform &trans, PandaNode *node) { // Get TS @@ -219,12 +204,10 @@ void get_node_transform(btTransform &trans, PandaNode *node) { trans.setOrigin(btv); } -//////////////////////////////////////////////////////////////////// -// Function: get_bullet_version -// Description: Returns the version of the linked Bullet library. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version of the linked Bullet library. + */ int get_bullet_version() { return BT_BULLET_VERSION; } - diff --git a/panda/src/bullet/bullet_utils.h b/panda/src/bullet/bullet_utils.h index fc9fa3542f..b1577ede5e 100644 --- a/panda/src/bullet/bullet_utils.h +++ b/panda/src/bullet/bullet_utils.h @@ -1,16 +1,15 @@ -// Filename: bullet_utils.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bullet_utils.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __BULLET_UTILS_H__ #define __BULLET_UTILS_H__ @@ -39,7 +38,7 @@ EXPCL_PANDABULLET LMatrix4 btTrans_to_LMatrix4(const btTransform &tf); EXPCL_PANDABULLET LQuaternion btQuat_to_LQuaternion(const btQuaternion &q); EXPCL_PANDABULLET CPT(TransformState) btTrans_to_TransformState( - const btTransform &tf, + const btTransform &tf, const LVecBase3 &scale=LVecBase3(1.0f, 1.0f, 1.0f)); EXPCL_PANDABULLET btTransform TransformState_to_btTrans( diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 2b33b8dffe..06cebf3928 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -1,16 +1,15 @@ -// Filename: config_bullet.cxx -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_bullet.cxx + * @author enn0x + * @date 2010-01-23 + */ #include "config_bullet.h" @@ -130,14 +129,12 @@ ConfigVariableDouble bullet_additional_damping_angular_threshold PRC_DESC("Only used when bullet-additional-damping is set to TRUE. " "Default value is 0.01.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libbullet -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libbullet() { @@ -205,4 +202,3 @@ init_libbullet() { PandaSystem *ps = PandaSystem::get_global_ptr(); ps->add_system("Bullet"); } - diff --git a/panda/src/bullet/config_bullet.h b/panda/src/bullet/config_bullet.h index b9c9ea4ac1..7b8a52e122 100644 --- a/panda/src/bullet/config_bullet.h +++ b/panda/src/bullet/config_bullet.h @@ -1,16 +1,15 @@ -// Filename: config_bullet.h -// Created by: enn0x (23Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_bullet.h + * @author enn0x + * @date 2010-01-23 + */ #ifndef __CONFIG_BULLET_H__ #define __CONFIG_BULLET_H__ diff --git a/panda/src/cftalk/cfChannel.I b/panda/src/cftalk/cfChannel.I index 52736e141d..4bb6a1c3fa 100644 --- a/panda/src/cftalk/cfChannel.I +++ b/panda/src/cftalk/cfChannel.I @@ -1,14 +1,12 @@ -// Filename: cfChannel.I -// Created by: drose (26Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfChannel.I + * @author drose + * @date 2009-03-26 + */ diff --git a/panda/src/cftalk/cfChannel.cxx b/panda/src/cftalk/cfChannel.cxx index ab896f18b4..e63ba79077 100644 --- a/panda/src/cftalk/cfChannel.cxx +++ b/panda/src/cftalk/cfChannel.cxx @@ -1,28 +1,23 @@ -// Filename: cfChannel.cxx -// Created by: drose (26Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfChannel.cxx + * @author drose + * @date 2009-03-26 + */ #include "cfChannel.h" -//////////////////////////////////////////////////////////////////// -// Function: CFChannel::Constructor -// Access: Public -// Description: The DatagramGenerator and DatagramSink should be -// newly created on the free store (via the new -// operator). The CFChannel will take ownership of -// these pointers, and will delete them when it -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * The DatagramGenerator and DatagramSink should be newly created on the free + * store (via the new operator). The CFChannel will take ownership of these + * pointers, and will delete them when it destructs. + */ CFChannel:: CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink) : _dggen(dggen), @@ -35,37 +30,29 @@ CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink) : nassertv(ok1 && ok2); } -//////////////////////////////////////////////////////////////////// -// Function: CFChannel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CFChannel:: ~CFChannel() { delete _dggen; delete _dgsink; } -//////////////////////////////////////////////////////////////////// -// Function: CFChannel::send_command -// Access: Public -// Description: Delivers a single command to the process at the other -// end of the channel. -//////////////////////////////////////////////////////////////////// +/** + * Delivers a single command to the process at the other end of the channel. + */ void CFChannel:: send_command(CFCommand *command) { bool ok = _writer.write_object(command); nassertv(ok); } -//////////////////////////////////////////////////////////////////// -// Function: CFChannel::receive_command -// Access: Public -// Description: Receives a single command from the process at the other -// end of the channel. If no command is ready, the -// thread will block until one is. Returns NULL when -// the connection has been closed. -//////////////////////////////////////////////////////////////////// +/** + * Receives a single command from the process at the other end of the channel. + * If no command is ready, the thread will block until one is. Returns NULL + * when the connection has been closed. + */ PT(CFCommand) CFChannel:: receive_command() { TypedWritable *obj = _reader.read_object(); diff --git a/panda/src/cftalk/cfChannel.h b/panda/src/cftalk/cfChannel.h index 81bb35fc56..e549327efa 100644 --- a/panda/src/cftalk/cfChannel.h +++ b/panda/src/cftalk/cfChannel.h @@ -1,16 +1,15 @@ -// Filename: cfChannel.h -// Created by: drose (26Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfChannel.h + * @author drose + * @date 2009-03-26 + */ #ifndef CFCHANNEL_H #define CFCHANNEL_H @@ -21,12 +20,10 @@ #include "bamWriter.h" #include "cfCommand.h" -//////////////////////////////////////////////////////////////////// -// Class : CFChannel -// Description : Represents an open communication channel in the -// connected-frame protocol. Commands may be sent and -// received on this channel. -//////////////////////////////////////////////////////////////////// +/** + * Represents an open communication channel in the connected-frame protocol. + * Commands may be sent and received on this channel. + */ class EXPCL_CFTALK CFChannel : public ReferenceCount { public: CFChannel(DatagramGenerator *dggen, DatagramSink *dgsink); diff --git a/panda/src/cftalk/cfCommand.I b/panda/src/cftalk/cfCommand.I index 2c97feaac9..fea651c96f 100644 --- a/panda/src/cftalk/cfCommand.I +++ b/panda/src/cftalk/cfCommand.I @@ -1,50 +1,40 @@ -// Filename: cfCommand.I -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfCommand.I + * @author drose + * @date 2009-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CFCommand::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CFCommand:: CFCommand() { } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CFDoCullCommand:: CFDoCullCommand() { } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CFDoCullCommand:: CFDoCullCommand(PandaNode *scene) : _scene(scene) { } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::get_scene -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *CFDoCullCommand:: get_scene() const { return _scene; diff --git a/panda/src/cftalk/cfCommand.cxx b/panda/src/cftalk/cfCommand.cxx index 38de408601..ca58163242 100644 --- a/panda/src/cftalk/cfCommand.cxx +++ b/panda/src/cftalk/cfCommand.cxx @@ -1,77 +1,63 @@ -// Filename: cfCommand.cxx -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfCommand.cxx + * @author drose + * @date 2009-02-19 + */ #include "cfCommand.h" TypeHandle CFCommand::_type_handle; TypeHandle CFDoCullCommand::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CFCommand::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CFCommand:: ~CFCommand() { } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CFDoCullCommand. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CFDoCullCommand. + */ void CFDoCullCommand:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CFDoCullCommand:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); manager->write_pointer(dg, _scene); } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::update_bam_nested -// Access: Public, Virtual -// Description: Called by the BamWriter when this object has not -// itself been modified recently, but it should check -// its nested objects for updates. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamWriter when this object has not itself been modified + * recently, but it should check its nested objects for updates. + */ void CFDoCullCommand:: update_bam_nested(BamWriter *manager) { manager->consider_update(_scene); } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int CFDoCullCommand:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); - + PandaNode *scene; DCAST_INTO_R(scene, p_list[pi++], pi); _scene = scene; @@ -79,14 +65,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CFDoCullCommand is encountered -// in the Bam file. It should create the CFDoCullCommand -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CFDoCullCommand is encountered in the Bam file. It should create the + * CFDoCullCommand and extract its information from the file. + */ TypedWritable *CFDoCullCommand:: make_from_bam(const FactoryParams ¶ms) { CFDoCullCommand *node = new CFDoCullCommand; @@ -99,13 +82,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CFDoCullCommand::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CFDoCullCommand. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CFDoCullCommand. + */ void CFDoCullCommand:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/cftalk/cfCommand.h b/panda/src/cftalk/cfCommand.h index ea74aa5805..84e7e1421c 100644 --- a/panda/src/cftalk/cfCommand.h +++ b/panda/src/cftalk/cfCommand.h @@ -1,16 +1,15 @@ -// Filename: cfCommand.h -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cfCommand.h + * @author drose + * @date 2009-02-19 + */ #ifndef CFCOMMAND_H #define CFCOMMAND_H @@ -20,15 +19,13 @@ #include "typedWritableReferenceCount.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : CFCommand -// Description : A single command in the Connected-Frame protocol. -// This can be sent client-to-server or -// server-to-client. -// -// This is an abstract base class. Individual commands -// will specialize from this. -//////////////////////////////////////////////////////////////////// +/** + * A single command in the Connected-Frame protocol. This can be sent client- + * to-server or server-to-client. + * + * This is an abstract base class. Individual commands will specialize from + * this. + */ class EXPCL_CFTALK CFCommand : public TypedWritableReferenceCount { protected: CFCommand(); @@ -54,11 +51,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : CFDoCullCommand -// Description : Starts the cull process for a particular -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Starts the cull process for a particular DisplayRegion. + */ class EXPCL_CFTALK CFDoCullCommand : public CFCommand { protected: INLINE CFDoCullCommand(); diff --git a/panda/src/cftalk/config_cftalk.cxx b/panda/src/cftalk/config_cftalk.cxx index ee373be6a3..42c5054526 100644 --- a/panda/src/cftalk/config_cftalk.cxx +++ b/panda/src/cftalk/config_cftalk.cxx @@ -1,16 +1,15 @@ -// Filename: config_cftalk.cxx -// Created by: drose (26Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cftalk.cxx + * @author drose + * @date 2009-03-26 + */ #include "config_cftalk.h" #include "cfCommand.h" @@ -23,14 +22,12 @@ ConfigureFn(config_cftalk) { init_libcftalk(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libcftalk -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libcftalk() { static bool initialized = false; diff --git a/panda/src/cftalk/config_cftalk.h b/panda/src/cftalk/config_cftalk.h index 0f7709e7fa..707c5f182d 100644 --- a/panda/src/cftalk/config_cftalk.h +++ b/panda/src/cftalk/config_cftalk.h @@ -1,16 +1,15 @@ -// Filename: config_cftalk.h -// Created by: drose (26Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cftalk.h + * @author drose + * @date 2009-03-26 + */ #ifndef CONFIG_CFTALK_H #define CONFIG_CFTALK_H diff --git a/panda/src/chan/animBundle.I b/panda/src/chan/animBundle.I index df38d209cb..2859273786 100644 --- a/panda/src/chan/animBundle.I +++ b/panda/src/chan/animBundle.I @@ -1,22 +1,19 @@ -// Filename: animBundle.I -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundle.I + * @author drose + * @date 1999-02-21 + */ -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AnimBundle:: AnimBundle(const string &name, PN_stdfloat fps, int num_frames) : AnimGroup(name) { _fps = fps; @@ -24,39 +21,29 @@ AnimBundle(const string &name, PN_stdfloat fps, int num_frames) : AnimGroup(name _root = this; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AnimBundle:: AnimBundle() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::get_base_frame_rate -// Access: Public -// Description: Returns the ideal number of frames per second of the -// animation, when it is running at normal speed. This -// may not be the same as the actual playing frame rate, -// as it might have been adjusted through -// set_play_rate() on the AnimControl object. See -// AnimControl::get_effective_frame_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the ideal number of frames per second of the animation, when it is + * running at normal speed. This may not be the same as the actual playing + * frame rate, as it might have been adjusted through set_play_rate() on the + * AnimControl object. See AnimControl::get_effective_frame_rate(). + */ INLINE double AnimBundle:: get_base_frame_rate() const { return _fps; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::get_num_frames -// Access: Public -// Description: Returns the number of frames of animation, or 0 if -// the animation has no fixed number of frames. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation, or 0 if the animation has no + * fixed number of frames. + */ INLINE int AnimBundle:: get_num_frames() const { return _num_frames; } - - diff --git a/panda/src/chan/animBundle.cxx b/panda/src/chan/animBundle.cxx index 49c71fef97..ad67124966 100644 --- a/panda/src/chan/animBundle.cxx +++ b/panda/src/chan/animBundle.cxx @@ -1,17 +1,15 @@ -// Filename: animBundle.cxx -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundle.cxx + * @author drose + * @date 1999-02-21 + */ #include "animBundle.h" @@ -23,16 +21,13 @@ TypeHandle AnimBundle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::Copy Constructor -// Access: Protected -// Description: Creates a new AnimBundle, just like this one, without -// copying any children. The new copy is added to the -// indicated parent. Intended to be called by -// make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimBundle, just like this one, without copying any children. + * The new copy is added to the indicated parent. Intended to be called by + * make_copy() only. + */ AnimBundle:: -AnimBundle(AnimGroup *parent, const AnimBundle ©) : +AnimBundle(AnimGroup *parent, const AnimBundle ©) : AnimGroup(parent, copy), _fps(copy._fps), _num_frames(copy._num_frames) @@ -41,51 +36,40 @@ AnimBundle(AnimGroup *parent, const AnimBundle ©) : _root = this; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::copy_bundle -// Access: Published -// Description: Returns a full copy of the bundle and its entire tree -// of nested AnimGroups. However, the actual data -// stored in the leaves--that is, animation tables, such -// as those stored in an AnimChannelMatrixXfmTable--will -// be shared. -//////////////////////////////////////////////////////////////////// +/** + * Returns a full copy of the bundle and its entire tree of nested AnimGroups. + * However, the actual data stored in the leaves--that is, animation tables, + * such as those stored in an AnimChannelMatrixXfmTable--will be shared. + */ PT(AnimBundle) AnimBundle:: copy_bundle() const { PT(AnimGroup) group = copy_subtree((AnimGroup *)NULL); return DCAST(AnimBundle, group.p()); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::output -// Access: Public, Virtual -// Description: Writes a one-line description of the bundle. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line description of the bundle. + */ void AnimBundle:: output(ostream &out) const { out << get_type() << " " << get_name() << ", " << get_num_frames() << " frames at " << get_base_frame_rate() << " fps"; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimBundle:: make_copy(AnimGroup *parent) const { return new AnimBundle(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimBundle:: write_datagram(BamWriter *manager, Datagram &me) { AnimGroup::write_datagram(manager, me); @@ -93,14 +77,11 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_uint16(_num_frames); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimBundle:: fillin(DatagramIterator &scan, BamReader *manager) { AnimGroup::fillin(scan, manager); @@ -108,11 +89,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _num_frames = scan.get_uint16(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::make_AnimBundle -// Access: Protected -// Description: Factory method to generate a AnimBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimBundle object + */ TypedWritable *AnimBundle:: make_AnimBundle(const FactoryParams ¶ms) { AnimBundle *me = new AnimBundle; @@ -124,13 +103,10 @@ make_AnimBundle(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundle::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a AnimBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimBundle object + */ void AnimBundle:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimBundle); } - diff --git a/panda/src/chan/animBundle.h b/panda/src/chan/animBundle.h index 5beff2b9b8..2bcaec1896 100644 --- a/panda/src/chan/animBundle.h +++ b/panda/src/chan/animBundle.h @@ -1,16 +1,15 @@ -// Filename: animBundle.h -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundle.h + * @author drose + * @date 1999-02-21 + */ #ifndef ANIMBUNDLE_H #define ANIMBUNDLE_H @@ -22,12 +21,11 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AnimBundle -// Description : This is the root of an AnimChannel hierarchy. It -// knows the frame rate and number of frames of all the -// channels in the hierarchy (which must all match). -//////////////////////////////////////////////////////////////////// +/** + * This is the root of an AnimChannel hierarchy. It knows the frame rate and + * number of frames of all the channels in the hierarchy (which must all + * match). + */ class EXPCL_PANDA_CHAN AnimBundle : public AnimGroup { protected: AnimBundle(AnimGroup *parent, const AnimBundle ©); diff --git a/panda/src/chan/animBundleNode.I b/panda/src/chan/animBundleNode.I index c3e7865d65..b7ac18c818 100644 --- a/panda/src/chan/animBundleNode.I +++ b/panda/src/chan/animBundleNode.I @@ -1,27 +1,21 @@ -// Filename: animBundleNode.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundleNode.I + * @author drose + * @date 2002-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::Constructor -// Access: Public -// Description: The AnimBundle and its node should be constructed -// together. Generally, the derived classes of -// AnimBundleNode will automatically create a AnimBundle -// of the appropriate type, and pass it up to this -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * The AnimBundle and its node should be constructed together. Generally, the + * derived classes of AnimBundleNode will automatically create a AnimBundle of + * the appropriate type, and pass it up to this constructor. + */ INLINE AnimBundleNode:: AnimBundleNode(const string &name, AnimBundle *bundle) : PandaNode(name), @@ -29,21 +23,16 @@ AnimBundleNode(const string &name, AnimBundle *bundle) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::Default Constructor -// Access: Protected -// Description: For internal use only. -//////////////////////////////////////////////////////////////////// +/** + * For internal use only. + */ INLINE AnimBundleNode:: AnimBundleNode() : PandaNode("") { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::Copy Constructor -// Access: Protected -// Description: Use make_copy() or copy_subgraph() to copy one of -// these. -//////////////////////////////////////////////////////////////////// +/** + * Use make_copy() or copy_subgraph() to copy one of these. + */ INLINE AnimBundleNode:: AnimBundleNode(const AnimBundleNode ©) : PandaNode(copy), @@ -51,11 +40,9 @@ AnimBundleNode(const AnimBundleNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::get_bundle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AnimBundle *AnimBundleNode:: get_bundle() const { return _bundle; diff --git a/panda/src/chan/animBundleNode.cxx b/panda/src/chan/animBundleNode.cxx index a74dd8d343..b3e49ca6a7 100644 --- a/panda/src/chan/animBundleNode.cxx +++ b/panda/src/chan/animBundleNode.cxx @@ -1,16 +1,15 @@ -// Filename: animBundleNode.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundleNode.cxx + * @author drose + * @date 2002-03-06 + */ #include "animBundleNode.h" #include "datagram.h" @@ -21,38 +20,30 @@ TypeHandle AnimBundleNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *AnimBundleNode:: make_copy() const { return new AnimBundleNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool AnimBundleNode:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::find_anim_bundle -// Access: Published, Static -// Description: Recursively walks the scene graph beginning at the -// indicated node (which need not be an AnimBundleNode), -// and returns the first AnimBundle found. Returns NULL -// if no AnimBundle can be found. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the scene graph beginning at the indicated node (which + * need not be an AnimBundleNode), and returns the first AnimBundle found. + * Returns NULL if no AnimBundle can be found. + */ AnimBundle *AnimBundleNode:: find_anim_bundle(PandaNode *root) { nassertr(root != (PandaNode *)NULL, NULL); @@ -77,36 +68,28 @@ find_anim_bundle(PandaNode *root) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AnimBundleNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AnimBundleNode. + */ void AnimBundleNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AnimBundleNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_pointer(dg, _bundle); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int AnimBundleNode:: complete_pointers(TypedWritable **p_list, BamReader* manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -114,14 +97,11 @@ complete_pointers(TypedWritable **p_list, BamReader* manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of this type is encountered -// in the Bam file. It should create the object -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * this type is encountered in the Bam file. It should create the object and + * extract its information from the file. + */ TypedWritable *AnimBundleNode:: make_from_bam(const FactoryParams ¶ms) { AnimBundleNode *node = new AnimBundleNode; @@ -134,13 +114,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PandaNode. + */ void AnimBundleNode:: fillin(DatagramIterator &scan, BamReader* manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/chan/animBundleNode.h b/panda/src/chan/animBundleNode.h index 2042416b46..cb6f577a4c 100644 --- a/panda/src/chan/animBundleNode.h +++ b/panda/src/chan/animBundleNode.h @@ -1,16 +1,15 @@ -// Filename: animBundleNode.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundleNode.h + * @author drose + * @date 2002-03-06 + */ #ifndef ANIMBUNDLENODE_H #define ANIMBUNDLENODE_H @@ -22,12 +21,11 @@ #include "pandaNode.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimBundleNode -// Description : This is a node that contains a pointer to an -// AnimBundle. Like PartBundleNode, it exists solely to -// make it easy to store AnimBundles in the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * This is a node that contains a pointer to an AnimBundle. Like + * PartBundleNode, it exists solely to make it easy to store AnimBundles in + * the scene graph. + */ class EXPCL_PANDA_CHAN AnimBundleNode : public PandaNode { PUBLISHED: INLINE AnimBundleNode(const string &name, AnimBundle *bundle); @@ -42,7 +40,7 @@ public: PUBLISHED: INLINE AnimBundle *get_bundle() const; - + static AnimBundle *find_anim_bundle(PandaNode *root); private: diff --git a/panda/src/chan/animChannel.I b/panda/src/chan/animChannel.I index 9f3d983de9..6dd73d5240 100644 --- a/panda/src/chan/animChannel.I +++ b/panda/src/chan/animChannel.I @@ -1,171 +1,136 @@ -// Filename: animChannel.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannel.I + * @author drose + * @date 1999-02-22 + */ template TypeHandle AnimChannel::_type_handle; -// We don't need to explicitly call AnimChannel::init_type(), because -// it is an abstract class and therefore must have derived objects. -// Its derived objects will call init_type() for us. +// We don't need to explicitly call AnimChannel::init_type(), because it is an +// abstract class and therefore must have derived objects. Its derived +// objects will call init_type() for us. -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::Protected constructor -// Access: Protected -// Description: Don't use this constructor. It exists only so that -// AnimChannelFixed may define itself outside of the -// hierarchy. Normally, an AnimChannel must be created -// as part of a hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Don't use this constructor. It exists only so that AnimChannelFixed may + * define itself outside of the hierarchy. Normally, an AnimChannel must be + * created as part of a hierarchy. + */ template INLINE AnimChannel:: AnimChannel(const string &name) : AnimChannelBase(name) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannel, just like this one, -// without copying any children. The new copy is added -// to the indicated parent. Intended to be called by -// make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannel, just like this one, without copying any + * children. The new copy is added to the indicated parent. Intended to be + * called by make_copy() only. + */ template INLINE AnimChannel:: -AnimChannel(AnimGroup *parent, const AnimChannel ©) : +AnimChannel(AnimGroup *parent, const AnimChannel ©) : AnimChannelBase(parent, copy) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::Constructor -// Access: Public -// Description: This is the normal constructor, which automatically -// places the AnimChannel in the previously-created -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This is the normal constructor, which automatically places the AnimChannel + * in the previously-created hierarchy. + */ template INLINE AnimChannel:: AnimChannel(AnimGroup *parent, const string &name) : AnimChannelBase(parent, name) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE AnimChannel:: ~AnimChannel() { } #if defined(WIN32_VC) || defined(WIN64_VC) -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_value -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame. -// This is a pure virtual function and normally would -// not need a function body, except that VC++ seems to -// be unhappy about instantiating the template without -// it. -// -// However, GCC seems to get confused when it *is* -// defined. So this whole thing is protected within an -// ifdef. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame. This is a pure + * virtual function and normally would not need a function body, except that + * VC++ seems to be unhappy about instantiating the template without it. + * + * However, GCC seems to get confused when it *is* defined. So this whole + * thing is protected within an ifdef. + */ template void AnimChannel:: get_value(int, TYPENAME AnimChannel::ValueType &) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_value_no_scale_share -// Access: Public, Virtual -// Description: Returns the value associated with the current frame, -// with no scale or share components. This only makes -// sense for a matrix-type channel, although for fiddly -// technical reasons the function exists for all -// channels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the current frame, with no scale or share + * components. This only makes sense for a matrix-type channel, although for + * fiddly technical reasons the function exists for all channels. + */ template void AnimChannel:: get_value_no_scale_shear(int frame, ValueType &value) { get_value(frame, value); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_scale -// Access: Public, Virtual -// Description: Returns the x, y, and z scale components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y, and z scale components associated with the current frame. + * As above, this only makes sense for a matrix-type channel. + */ template void AnimChannel:: get_scale(int, LVecBase3 &scale) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_hpr -// Access: Public, Virtual -// Description: Returns the h, p, and r components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the h, p, and r components associated with the current frame. As + * above, this only makes sense for a matrix-type channel. + */ template void AnimChannel:: get_hpr(int, LVecBase3 &hpr) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_quat -// Access: Public, Virtual -// Description: Returns the rotation component associated with the -// current frame, expressed as a quaternion. As above, -// this only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component associated with the current frame, expressed + * as a quaternion. As above, this only makes sense for a matrix-type + * channel. + */ template void AnimChannel:: get_quat(int, LQuaternion &quat) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_pos -// Access: Public, Virtual -// Description: Returns the x, y, and z translation components -// associated with the current frame. As above, this -// only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y, and z translation components associated with the current + * frame. As above, this only makes sense for a matrix-type channel. + */ template void AnimChannel:: get_pos(int, LVecBase3 &pos) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_shear -// Access: Public, Virtual -// Description: Returns the a, b, and c shear components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the a, b, and c shear components associated with the current frame. + * As above, this only makes sense for a matrix-type channel. + */ template void AnimChannel:: get_shear(int, LVecBase3 &shear) { @@ -173,18 +138,13 @@ get_shear(int, LVecBase3 &shear) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannel::get_value_type -// Access: Public, Virtual -// Description: Returns the TypeHandle associated with the ValueType -// we return. This is provided to allow a bit of -// run-time checking that joints and channels are -// matching properly in type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the ValueType we return. This is + * provided to allow a bit of run-time checking that joints and channels are + * matching properly in type. + */ template TypeHandle AnimChannel:: get_value_type() const { return get_type_handle(ValueType); } - - diff --git a/panda/src/chan/animChannel.cxx b/panda/src/chan/animChannel.cxx index fb710994ee..66fc1329f4 100644 --- a/panda/src/chan/animChannel.cxx +++ b/panda/src/chan/animChannel.cxx @@ -1,17 +1,15 @@ -// Filename: animChannel.cxx -// Created by: drose (11May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannel.cxx + * @author drose + * @date 2000-05-11 + */ #include "animChannel.h" @@ -25,11 +23,9 @@ template class AnimChannel; template class AnimChannel; -//////////////////////////////////////////////////////////////////// -// Function: ACMatrixSwitchType::output_value -// Access: Public, Static -// Description: Outputs a very brief description of a matrix. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a very brief description of a matrix. + */ void ACMatrixSwitchType:: output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { LVecBase3 scale, shear, hpr, translate; @@ -58,4 +54,3 @@ output_value(ostream &out, const ACMatrixSwitchType::ValueType &value) { out << " mat " << value; } } - diff --git a/panda/src/chan/animChannel.h b/panda/src/chan/animChannel.h index 408f356ecd..1c7fd639fc 100644 --- a/panda/src/chan/animChannel.h +++ b/panda/src/chan/animChannel.h @@ -1,16 +1,15 @@ -// Filename: animChannel.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannel.h + * @author drose + * @date 1999-02-22 + */ #ifndef ANIMCHANNEL_H #define ANIMCHANNEL_H @@ -21,18 +20,16 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannel -// Description : This template class is the parent class for all kinds -// of AnimChannels that return different values. -//////////////////////////////////////////////////////////////////// +/** + * This template class is the parent class for all kinds of AnimChannels that + * return different values. + */ template class AnimChannel : public AnimChannelBase { protected: - // The default constructor is protected: don't try to create an - // AnimChannel without a parent. To create an AnimChannel hierarchy, - // you must first create an AnimBundle, and use that to create any - // subsequent children. + // The default constructor is protected: don't try to create an AnimChannel + // without a parent. To create an AnimChannel hierarchy, you must first + // create an AnimBundle, and use that to create any subsequent children. INLINE AnimChannel(const string &name = ""); INLINE AnimChannel(AnimGroup *parent, const AnimChannel ©); public: @@ -54,8 +51,8 @@ PUBLISHED: virtual TypeHandle get_value_type() const; - //This class has no Read/Write functions as it is abstract - //and defines no new data + // This class has no ReadWrite functions as it is abstract and defines no + // new data public: virtual TypeHandle get_type() const { @@ -132,4 +129,3 @@ typedef AnimChannel AnimChannelScalar; #endif #endif - diff --git a/panda/src/chan/animChannelBase.I b/panda/src/chan/animChannelBase.I index f057009574..dbe24dcc9d 100644 --- a/panda/src/chan/animChannelBase.I +++ b/panda/src/chan/animChannelBase.I @@ -1,25 +1,21 @@ -// Filename: animChannelBase.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelBase.I + * @author drose + * @date 1999-02-19 + */ -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::Protected constructor -// Access: Protected -// Description: Don't use this constructor. It exists only so that -// AnimChannelFixed may define itself outside of the -// hierarchy. Normally, an AnimChannel must be created -// as part of a hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Don't use this constructor. It exists only so that AnimChannelFixed may + * define itself outside of the hierarchy. Normally, an AnimChannel must be + * created as part of a hierarchy. + */ INLINE AnimChannelBase:: AnimChannelBase(const string &name) : AnimGroup(name) @@ -27,33 +23,25 @@ AnimChannelBase(const string &name) _last_frame = -1; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelBase, just like this one, -// without copying any children. The new copy is added -// to the indicated parent. Intended to be called by -// make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelBase, just like this one, without copying any + * children. The new copy is added to the indicated parent. Intended to be + * called by make_copy() only. + */ INLINE AnimChannelBase:: -AnimChannelBase(AnimGroup *parent, const AnimChannelBase ©) : +AnimChannelBase(AnimGroup *parent, const AnimChannelBase ©) : AnimGroup(parent, copy), _last_frame(copy._last_frame) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::Constructor -// Access: Public -// Description: This is the normal constructor, which automatically -// places the AnimChannel in the previously-created -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This is the normal constructor, which automatically places the AnimChannel + * in the previously-created hierarchy. + */ INLINE AnimChannelBase:: AnimChannelBase(AnimGroup *parent, const string &name) : AnimGroup(parent, name) { _last_frame = -1; } - - diff --git a/panda/src/chan/animChannelBase.cxx b/panda/src/chan/animChannelBase.cxx index 935ed2e0e0..ba6be7c631 100644 --- a/panda/src/chan/animChannelBase.cxx +++ b/panda/src/chan/animChannelBase.cxx @@ -1,17 +1,15 @@ -// Filename: animChannelBase.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelBase.cxx + * @author drose + * @date 1999-02-19 + */ #include "animChannelBase.h" #include "datagram.h" @@ -22,45 +20,34 @@ TypeHandle AnimChannelBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::has_changed -// Access: Public, Virtual -// Description: Returns true if the value has changed since the last -// call to has_changed(). last_frame is the frame -// number of the last call; this_frame is the current -// frame number. last_frac and this_frac are the -// fractional steps into those frames, which will be 0.0 -// unless we are running in frame_blend mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the value has changed since the last call to has_changed(). + * last_frame is the frame number of the last call; this_frame is the current + * frame number. last_frac and this_frac are the fractional steps into those + * frames, which will be 0.0 unless we are running in frame_blend mode. + */ bool AnimChannelBase:: has_changed(int, double, int, double) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimChannelBase:: write_datagram(BamWriter *manager, Datagram &me) { AnimGroup::write_datagram(manager, me); me.add_uint16(_last_frame); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelBase::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimChannelBase:: fillin(DatagramIterator &scan, BamReader *manager) { AnimGroup::fillin(scan, manager); _last_frame = scan.get_uint16(); } - - diff --git a/panda/src/chan/animChannelBase.h b/panda/src/chan/animChannelBase.h index be08a6fe75..c3512db282 100644 --- a/panda/src/chan/animChannelBase.h +++ b/panda/src/chan/animChannelBase.h @@ -1,16 +1,15 @@ -// Filename: animChannelBase.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelBase.h + * @author drose + * @date 1999-02-19 + */ #ifndef ANIMCHANNELBASE_H #define ANIMCHANNELBASE_H @@ -22,27 +21,24 @@ #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelBase -// Description : Parent class for all animation channels. An -// AnimChannel is an arbitrary function that changes -// over time (actually, over frames), usually defined by -// a table read from an egg file (but possibly computed -// or generated in any other way). -//////////////////////////////////////////////////////////////////// +/** + * Parent class for all animation channels. An AnimChannel is an arbitrary + * function that changes over time (actually, over frames), usually defined by + * a table read from an egg file (but possibly computed or generated in any + * other way). + */ class EXPCL_PANDA_CHAN AnimChannelBase : public AnimGroup { protected: - // The default constructor is protected: don't try to create an - // AnimChannel without a parent. To create an AnimChannel hierarchy, - // you must first create an AnimBundle, and use that to create any - // subsequent children. + // The default constructor is protected: don't try to create an AnimChannel + // without a parent. To create an AnimChannel hierarchy, you must first + // create an AnimBundle, and use that to create any subsequent children. INLINE AnimChannelBase(const string &name = ""); INLINE AnimChannelBase(AnimGroup *parent, const AnimChannelBase ©); public: INLINE AnimChannelBase(AnimGroup *parent, const string &name); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual TypeHandle get_value_type() const=0; diff --git a/panda/src/chan/animChannelFixed.I b/panda/src/chan/animChannelFixed.I index 8401a1350c..9c71438b86 100644 --- a/panda/src/chan/animChannelFixed.I +++ b/panda/src/chan/animChannelFixed.I @@ -1,41 +1,35 @@ -// Filename: animChannelFixed.I -// Created by: drose (24Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelFixed.I + * @author drose + * @date 1999-02-24 + */ template TypeHandle AnimChannelFixed::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelFixed, just like this one, -// without copying any children. The new copy is added -// to the indicated parent. Intended to be called by -// make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelFixed, just like this one, without copying any + * children. The new copy is added to the indicated parent. Intended to be + * called by make_copy() only. + */ template INLINE AnimChannelFixed:: -AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©) : +AnimChannelFixed(AnimGroup *parent, const AnimChannelFixed ©) : AnimChannel(parent, copy), _value(copy._value) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE AnimChannelFixed:: AnimChannelFixed(const string &name, const ValueType &value) @@ -44,11 +38,9 @@ AnimChannelFixed(const string &name, const ValueType &value) } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::has_changed -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template bool AnimChannelFixed:: has_changed(int, double, int, double) { @@ -56,11 +48,9 @@ has_changed(int, double, int, double) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::get_value -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void AnimChannelFixed:: get_value(int, ValueType &value) { @@ -68,11 +58,9 @@ get_value(int, ValueType &value) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void AnimChannelFixed:: output(ostream &out) const { diff --git a/panda/src/chan/animChannelFixed.h b/panda/src/chan/animChannelFixed.h index 1f6d56ed44..8835cc6db2 100644 --- a/panda/src/chan/animChannelFixed.h +++ b/panda/src/chan/animChannelFixed.h @@ -1,16 +1,15 @@ -// Filename: animChannelFixed.h -// Created by: drose (24Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelFixed.h + * @author drose + * @date 1999-02-24 + */ #ifndef ANIMCHANNELFIXED_H #define ANIMCHANNELFIXED_H @@ -20,15 +19,12 @@ #include "animChannel.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelFixed -// Description : This template class is a special kind of AnimChannel -// that always returns just one fixed value. It is a -// special channel, in that it need not be assigned -// within a hierarchy. It may stand alone, so that it -// may be created on-the-fly for parts that need default -// anims to bind against. -//////////////////////////////////////////////////////////////////// +/** + * This template class is a special kind of AnimChannel that always returns + * just one fixed value. It is a special channel, in that it need not be + * assigned within a hierarchy. It may stand alone, so that it may be created + * on-the-fly for parts that need default anims to bind against. + */ template class AnimChannelFixed : public AnimChannel { public: @@ -40,7 +36,7 @@ protected: public: INLINE AnimChannelFixed(const string &name, const ValueType &value); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, ValueType &value); diff --git a/panda/src/chan/animChannelMatrixDynamic.I b/panda/src/chan/animChannelMatrixDynamic.I index 9cdfc28efc..17c0c1b433 100644 --- a/panda/src/chan/animChannelMatrixDynamic.I +++ b/panda/src/chan/animChannelMatrixDynamic.I @@ -1,36 +1,28 @@ -// Filename: animChannelMatrixDynamic.I -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixDynamic.I + * @author drose + * @date 2003-10-20 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_value_transform -// Access: Published -// Description: Returns the explicit TransformState value that was -// set via set_value(), if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the explicit TransformState value that was set via set_value(), if + * any. + */ INLINE const TransformState *AnimChannelMatrixDynamic:: get_value_transform() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_value_node -// Access: Published -// Description: Returns the node that was set via set_value_node(), -// if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that was set via set_value_node(), if any. + */ INLINE PandaNode *AnimChannelMatrixDynamic:: get_value_node() const { return _value_node; diff --git a/panda/src/chan/animChannelMatrixDynamic.cxx b/panda/src/chan/animChannelMatrixDynamic.cxx index 8046fa2dcc..fb60451bc3 100644 --- a/panda/src/chan/animChannelMatrixDynamic.cxx +++ b/panda/src/chan/animChannelMatrixDynamic.cxx @@ -1,16 +1,15 @@ -// Filename: animChannelMatrixDynamic.cxx -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixDynamic.cxx + * @author drose + * @date 2003-10-20 + */ #include "animChannelMatrixDynamic.h" #include "animBundle.h" @@ -25,23 +24,18 @@ TypeHandle AnimChannelMatrixDynamic::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::Constructor -// Access: Protected -// Description: For use only with the bam reader. -//////////////////////////////////////////////////////////////////// +/** + * For use only with the bam reader. + */ AnimChannelMatrixDynamic:: AnimChannelMatrixDynamic() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelMatrixDynamic, just like -// this one, without copying any children. The new copy -// is added to the indicated parent. Intended to be -// called by make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelMatrixDynamic, just like this one, without copying + * any children. The new copy is added to the indicated parent. Intended to + * be called by make_copy() only. + */ AnimChannelMatrixDynamic:: AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic ©) : AnimChannelMatrix(parent, copy), @@ -51,11 +45,9 @@ AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic © { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelMatrixDynamic:: AnimChannelMatrixDynamic(const string &name) : AnimChannelMatrix(name) @@ -65,14 +57,11 @@ AnimChannelMatrixDynamic(const string &name) // always return true the first time. } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::has_changed -// Access: Public, Virtual -// Description: Returns true if the value has changed since the last -// call to has_changed(). last_frame is the frame -// number of the last call; this_frame is the current -// frame number. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the value has changed since the last call to has_changed(). + * last_frame is the frame number of the last call; this_frame is the current + * frame number. + */ bool AnimChannelMatrixDynamic:: has_changed(int, double, int, double) { if (_value_node != (PandaNode *)NULL) { @@ -83,11 +72,9 @@ has_changed(int, double, int, double) { return has_changed; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_value -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame. + */ void AnimChannelMatrixDynamic:: get_value(int, LMatrix4 &mat) { if (_value_node != (PandaNode *)NULL) { @@ -96,12 +83,10 @@ get_value(int, LMatrix4 &mat) { mat = _value->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_value_no_scale_shear -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame, -// without any scale or shear information. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame, without any scale or + * shear information. + */ void AnimChannelMatrixDynamic:: get_value_no_scale_shear(int, LMatrix4 &mat) { if (_value_node != (PandaNode *)NULL) { @@ -115,11 +100,9 @@ get_value_no_scale_shear(int, LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_scale -// Access: Public, Virtual -// Description: Gets the scale value at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the scale value at the indicated frame. + */ void AnimChannelMatrixDynamic:: get_scale(int, LVecBase3 &scale) { if (_value_node != (PandaNode *)NULL) { @@ -128,13 +111,10 @@ get_scale(int, LVecBase3 &scale) { scale = _value->get_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_hpr -// Access: Public, Virtual -// Description: Returns the h, p, and r components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the h, p, and r components associated with the current frame. As + * above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixDynamic:: get_hpr(int, LVecBase3 &hpr) { if (_value_node != (PandaNode *)NULL) { @@ -143,13 +123,11 @@ get_hpr(int, LVecBase3 &hpr) { hpr = _value->get_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_quat -// Access: Public, Virtual -// Description: Returns the rotation component associated with the -// current frame, expressed as a quaternion. As above, -// this only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component associated with the current frame, expressed + * as a quaternion. As above, this only makes sense for a matrix-type + * channel. + */ void AnimChannelMatrixDynamic:: get_quat(int, LQuaternion &quat) { if (_value_node != (PandaNode *)NULL) { @@ -158,13 +136,10 @@ get_quat(int, LQuaternion &quat) { quat = _value->get_quat(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_pos -// Access: Public, Virtual -// Description: Returns the x, y, and z translation components -// associated with the current frame. As above, this -// only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y, and z translation components associated with the current + * frame. As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixDynamic:: get_pos(int, LVecBase3 &pos) { if (_value_node != (PandaNode *)NULL) { @@ -173,13 +148,10 @@ get_pos(int, LVecBase3 &pos) { pos = _value->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::get_shear -// Access: Public, Virtual -// Description: Returns the a, b, and c shear components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the a, b, and c shear components associated with the current frame. + * As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixDynamic:: get_shear(int, LVecBase3 &shear) { if (_value_node != (PandaNode *)NULL) { @@ -188,36 +160,29 @@ get_shear(int, LVecBase3 &shear) { shear = _value->get_shear(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::set_value -// Access: Published -// Description: Explicitly sets the matrix value. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the matrix value. + */ void AnimChannelMatrixDynamic:: set_value(const LMatrix4 &value) { _value = TransformState::make_mat(value); _value_node.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::set_value -// Access: Published -// Description: Explicitly sets the matrix value, using the indicated -// TransformState object as a convenience. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the matrix value, using the indicated TransformState object + * as a convenience. + */ void AnimChannelMatrixDynamic:: set_value(const TransformState *value) { _value = value; _value_node.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::set_value_node -// Access: Published -// Description: Specifies a node whose transform will be queried each -// frame to implicitly specify the transform of this -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a node whose transform will be queried each frame to implicitly + * specify the transform of this joint. + */ void AnimChannelMatrixDynamic:: set_value_node(PandaNode *value_node) { _value_node = value_node; @@ -226,26 +191,21 @@ set_value_node(PandaNode *value_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimChannelMatrixDynamic:: make_copy(AnimGroup *parent) const { return new AnimChannelMatrixDynamic(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimChannelMatrixDynamic:: write_datagram(BamWriter *manager, Datagram &dg) { AnimChannelMatrix::write_datagram(manager, dg); @@ -253,13 +213,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _value); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int AnimChannelMatrixDynamic:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = AnimChannelMatrix::complete_pointers(p_list, manager); @@ -271,14 +228,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::fillin -// Access: Public -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimChannelMatrixDynamic:: fillin(DatagramIterator &scan, BamReader *manager) { AnimChannelMatrix::fillin(scan, manager); @@ -288,12 +242,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::make_AnimChannelMatrixDynamic -// Access: Public -// Description: Factory method to generate an -// AnimChannelMatrixDynamic object. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimChannelMatrixDynamic object. + */ TypedWritable *AnimChannelMatrixDynamic:: make_AnimChannelMatrixDynamic(const FactoryParams ¶ms) { AnimChannelMatrixDynamic *me = new AnimChannelMatrixDynamic; @@ -305,15 +256,10 @@ make_AnimChannelMatrixDynamic(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixDynamic::register_with_factory -// Access: Public, Static -// Description: Factory method to generate an -// AnimChannelMatrixDynamic object. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimChannelMatrixDynamic object. + */ void AnimChannelMatrixDynamic:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimChannelMatrixDynamic); } - - diff --git a/panda/src/chan/animChannelMatrixDynamic.h b/panda/src/chan/animChannelMatrixDynamic.h index e71fcbd861..8cd9d38904 100644 --- a/panda/src/chan/animChannelMatrixDynamic.h +++ b/panda/src/chan/animChannelMatrixDynamic.h @@ -1,16 +1,15 @@ -// Filename: animChannelMatrixDynamic.h -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixDynamic.h + * @author drose + * @date 2003-10-20 + */ #ifndef ANIMCHANNELMATRIXDYNAMIC_H #define ANIMCHANNELMATRIXDYNAMIC_H @@ -22,18 +21,15 @@ #include "pandaNode.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelMatrixDynamic -// Description : An animation channel that accepts a matrix each frame -// from some dynamic input provided by code. -// -// This object operates in two modes: in explicit mode, -// the programmer should call set_value() each frame to -// indicate the new value; in implicit mode, the -// programmer should call set_value_node() to indicate -// the node whose transform will be copied to the joint -// each frame. -//////////////////////////////////////////////////////////////////// +/** + * An animation channel that accepts a matrix each frame from some dynamic + * input provided by code. + * + * This object operates in two modes: in explicit mode, the programmer should + * call set_value() each frame to indicate the new value; in implicit mode, + * the programmer should call set_value_node() to indicate the node whose + * transform will be copied to the joint each frame. + */ class EXPCL_PANDA_CHAN AnimChannelMatrixDynamic : public AnimChannelMatrix { protected: AnimChannelMatrixDynamic(); @@ -42,7 +38,7 @@ protected: public: AnimChannelMatrixDynamic(const string &name); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, LMatrix4 &mat); @@ -66,9 +62,9 @@ protected: private: - // This is filled in only if we are using the set_value_node() - // interface to get an implicit value from the transform on the - // indicated node each frame. + // This is filled in only if we are using the set_value_node() interface to + // get an implicit value from the transform on the indicated node each + // frame. PT(PandaNode) _value_node; CPT(TransformState) _value; diff --git a/panda/src/chan/animChannelMatrixFixed.I b/panda/src/chan/animChannelMatrixFixed.I index 2bb59250b4..c96feb5b95 100644 --- a/panda/src/chan/animChannelMatrixFixed.I +++ b/panda/src/chan/animChannelMatrixFixed.I @@ -1,14 +1,12 @@ -// Filename: animChannelMatrixFixed.I -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixFixed.I + * @author drose + * @date 2006-01-19 + */ diff --git a/panda/src/chan/animChannelMatrixFixed.cxx b/panda/src/chan/animChannelMatrixFixed.cxx index 289d879bbc..cf79e7ea5a 100644 --- a/panda/src/chan/animChannelMatrixFixed.cxx +++ b/panda/src/chan/animChannelMatrixFixed.cxx @@ -1,32 +1,28 @@ -// Filename: animChannelMatrixFixed.cxx -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixFixed.cxx + * @author drose + * @date 2006-01-19 + */ #include "animChannelMatrixFixed.h" #include "compose_matrix.h" TypeHandle AnimChannelMatrixFixed::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelMatrixFixed, just like this -// one, without copying any children. The new copy is -// added to the indicated parent. Intended to be called -// by make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelMatrixFixed, just like this one, without copying + * any children. The new copy is added to the indicated parent. Intended to + * be called by make_copy() only. + */ AnimChannelMatrixFixed:: -AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : +AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : AnimChannel(parent, copy), _pos(copy._pos), _hpr(copy._hpr), @@ -34,11 +30,9 @@ AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelMatrixFixed:: AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : AnimChannel(name), @@ -46,125 +40,99 @@ AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::has_changed -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool AnimChannelMatrixFixed:: has_changed(int, double, int, double) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelFixed::get_value -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimChannelMatrixFixed:: get_value(int, LMatrix4 &value) { compose_matrix(value, _scale, LVecBase3::zero(), _hpr, _pos); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_value_no_scale_shear -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame, -// without any scale or shear information. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame, without any scale or + * shear information. + */ void AnimChannelMatrixFixed:: get_value_no_scale_shear(int, LMatrix4 &mat) { compose_matrix(mat, LVecBase3(1.0f, 1.0f, 1.0f), LVecBase3::zero(), _hpr, _pos); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_scale -// Access: Public, Virtual -// Description: Gets the scale value at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the scale value at the indicated frame. + */ void AnimChannelMatrixFixed:: get_scale(int, LVecBase3 &scale) { scale = _scale; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_hpr -// Access: Public, Virtual -// Description: Returns the h, p, and r components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the h, p, and r components associated with the current frame. As + * above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixFixed:: get_hpr(int, LVecBase3 &hpr) { hpr = _hpr; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_quat -// Access: Public, Virtual -// Description: Returns the rotation component associated with the -// current frame, expressed as a quaternion. As above, -// this only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component associated with the current frame, expressed + * as a quaternion. As above, this only makes sense for a matrix-type + * channel. + */ void AnimChannelMatrixFixed:: get_quat(int, LQuaternion &quat) { quat.set_hpr(_hpr); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_pos -// Access: Public, Virtual -// Description: Returns the x, y, and z translation components -// associated with the current frame. As above, this -// only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y, and z translation components associated with the current + * frame. As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixFixed:: get_pos(int, LVecBase3 &pos) { pos = _pos; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::get_shear -// Access: Public, Virtual -// Description: Returns the a, b, and c shear components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the a, b, and c shear components associated with the current frame. + * As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixFixed:: get_shear(int, LVecBase3 &shear) { shear = LVecBase3::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimChannelMatrixFixed:: output(ostream &out) const { AnimChannel::output(out); out << ": pos " << _pos << " hpr " << _hpr << " scale " << _scale; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AnimChannelMatrixFixed. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AnimChannelMatrixFixed. + */ void AnimChannelMatrixFixed:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AnimChannelMatrixFixed:: write_datagram(BamWriter *manager, Datagram &dg) { AnimChannel::write_datagram(manager, dg); @@ -174,14 +142,12 @@ write_datagram(BamWriter *manager, Datagram &dg) { _scale.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AnimChannelMatrixFixed is encountered -// in the Bam file. It should create the AnimChannelMatrixFixed -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AnimChannelMatrixFixed is encountered in the Bam file. It should + * create the AnimChannelMatrixFixed and extract its information from the + * file. + */ TypedWritable *AnimChannelMatrixFixed:: make_from_bam(const FactoryParams ¶ms) { AnimChannelMatrixFixed *chan = new AnimChannelMatrixFixed("", LVecBase3::zero(), LVecBase3::zero(), LVecBase3::zero()); @@ -194,13 +160,10 @@ make_from_bam(const FactoryParams ¶ms) { return chan; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixFixed::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AnimChannelMatrixFixed. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AnimChannelMatrixFixed. + */ void AnimChannelMatrixFixed:: fillin(DatagramIterator &scan, BamReader *manager) { AnimChannel::fillin(scan, manager); diff --git a/panda/src/chan/animChannelMatrixFixed.h b/panda/src/chan/animChannelMatrixFixed.h index a2a72889b5..eb34c78321 100644 --- a/panda/src/chan/animChannelMatrixFixed.h +++ b/panda/src/chan/animChannelMatrixFixed.h @@ -1,16 +1,15 @@ -// Filename: animChannelMatrixFixed.h -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixFixed.h + * @author drose + * @date 2006-01-19 + */ #ifndef ANIMCHANNELMATRIXFIXED_H #define ANIMCHANNELMATRIXFIXED_H @@ -20,11 +19,10 @@ #include "animChannel.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelMatrixFixed -// Description : A specialization on AnimChannel to add all the -// special matrix component operations. -//////////////////////////////////////////////////////////////////// +/** + * A specialization on AnimChannel to add all the special matrix component + * operations. + */ class EXPCL_PANDA_CHAN AnimChannelMatrixFixed : public AnimChannel { protected: AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©); @@ -32,7 +30,7 @@ protected: public: AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, LMatrix4 &value); virtual void get_value_no_scale_shear(int frame, LMatrix4 &value); @@ -76,6 +74,3 @@ private: #include "animChannelMatrixFixed.I" #endif - - - diff --git a/panda/src/chan/animChannelMatrixXfmTable.I b/panda/src/chan/animChannelMatrixXfmTable.I index 0c0830fc54..93fceb143c 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.I +++ b/panda/src/chan/animChannelMatrixXfmTable.I @@ -1,35 +1,28 @@ -// Filename: animChannelMatrixXfmTable.I -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixXfmTable.I + * @author drose + * @date 1999-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::is_valid_id -// Access: Public, Static -// Description: Returns true if the given letter is one of the nine -// valid table id's. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given letter is one of the nine valid table id's. + */ INLINE bool AnimChannelMatrixXfmTable:: is_valid_id(char table_id) { return get_table_index(table_id) >= 0; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_table -// Access: Public -// Description: Returns a pointer to the indicated subtable's data, -// if it exists, or NULL if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the indicated subtable's data, if it exists, or NULL + * if it does not. + */ INLINE CPTA_stdfloat AnimChannelMatrixXfmTable:: get_table(char table_id) const { int table_index = get_table_index(table_id); @@ -39,12 +32,9 @@ get_table(char table_id) const { return _tables[table_index]; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::has_table -// Access: Published -// Description: Returns true if the indicated subtable has been -// assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated subtable has been assigned. + */ INLINE bool AnimChannelMatrixXfmTable:: has_table(char table_id) const { int table_index = get_table_index(table_id); @@ -54,11 +44,9 @@ has_table(char table_id) const { return !(_tables[table_index] == (const PN_stdfloat *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::clear_table -// Access: Published -// Description: Removes the indicated table from the definition. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated table from the definition. + */ INLINE void AnimChannelMatrixXfmTable:: clear_table(char table_id) { int table_index = get_table_index(table_id); @@ -68,13 +56,11 @@ clear_table(char table_id) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_table_id -// Access: Protected, Static -// Description: Returns the table ID associated with the indicated -// table index number. This is the letter 'i', 'j', -// 'k', 'a', 'b', 'c', 'h', 'p', 'r', 'x', 'y', or 'z'. -//////////////////////////////////////////////////////////////////// +/** + * Returns the table ID associated with the indicated table index number. + * This is the letter 'i', 'j', 'k', 'a', 'b', 'c', 'h', 'p', 'r', 'x', 'y', + * or 'z'. + */ INLINE char AnimChannelMatrixXfmTable:: get_table_id(int table_index) { nassertr(table_index >= 0 && table_index < num_matrix_components, '\0'); @@ -82,15 +68,12 @@ get_table_id(int table_index) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_default_value -// Access: Protected, Static -// Description: Returns the default value the indicated table is -// expected to have in the absence of any data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default value the indicated table is expected to have in the + * absence of any data. + */ INLINE PN_stdfloat AnimChannelMatrixXfmTable:: get_default_value(int table_index) { nassertr(table_index >= 0 && table_index < num_matrix_components, 0.0); return matrix_component_defaults[table_index]; } - diff --git a/panda/src/chan/animChannelMatrixXfmTable.cxx b/panda/src/chan/animChannelMatrixXfmTable.cxx index 3e0fd730c5..0ae15b7ba1 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.cxx +++ b/panda/src/chan/animChannelMatrixXfmTable.cxx @@ -1,17 +1,15 @@ -// Filename: animChannelMatrixXfmTable.cxx -// Created by: drose (20Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixXfmTable.cxx + * @author drose + * @date 1999-02-20 + */ #include "animChannelMatrixXfmTable.h" #include "animBundle.h" @@ -28,11 +26,9 @@ TypeHandle AnimChannelMatrixXfmTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::Constructor -// Access: Protected -// Description: Used only for bam loader. -//////////////////////////////////////////////////////////////////// +/** + * Used only for bam loader. + */ AnimChannelMatrixXfmTable:: AnimChannelMatrixXfmTable() { for (int i = 0; i < num_matrix_components; i++) { @@ -40,14 +36,11 @@ AnimChannelMatrixXfmTable() { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelMatrixXfmTable, just like -// this one, without copying any children. The new copy -// is added to the indicated parent. Intended to be -// called by make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelMatrixXfmTable, just like this one, without + * copying any children. The new copy is added to the indicated parent. + * Intended to be called by make_copy() only. + */ AnimChannelMatrixXfmTable:: AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable ©) : AnimChannelMatrix(parent, copy) @@ -57,11 +50,9 @@ AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable &co } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelMatrixXfmTable:: AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name) : AnimChannelMatrix(parent, name) @@ -71,24 +62,19 @@ AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name) } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelMatrixXfmTable:: ~AnimChannelMatrixXfmTable() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::has_changed -// Access: Public, Virtual -// Description: Returns true if the value has changed since the last -// call to has_changed(). last_frame is the frame -// number of the last call; this_frame is the current -// frame number. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the value has changed since the last call to has_changed(). + * last_frame is the frame number of the last call; this_frame is the current + * frame number. + */ bool AnimChannelMatrixXfmTable:: has_changed(int last_frame, double last_frac, int this_frame, double this_frac) { @@ -104,8 +90,8 @@ has_changed(int last_frame, double last_frac, } if (last_frac != this_frac) { - // If we have some fractional changes, also check the next - // subsequent frame (since we'll be blending with that). + // If we have some fractional changes, also check the next subsequent + // frame (since we'll be blending with that). for (int i = 0; i < num_matrix_components; i++) { if (_tables[i].size() > 1) { if (_tables[i][last_frame % _tables[i].size()] != @@ -119,11 +105,9 @@ has_changed(int last_frame, double last_frac, return false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_value -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame. + */ void AnimChannelMatrixXfmTable:: get_value(int frame, LMatrix4 &mat) { PN_stdfloat components[num_matrix_components]; @@ -139,12 +123,10 @@ get_value(int frame, LMatrix4 &mat) { compose_matrix(mat, components); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_value_no_scale_shear -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame, -// without any scale or shear information. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame, without any scale or + * shear information. + */ void AnimChannelMatrixXfmTable:: get_value_no_scale_shear(int frame, LMatrix4 &mat) { PN_stdfloat components[num_matrix_components]; @@ -166,11 +148,9 @@ get_value_no_scale_shear(int frame, LMatrix4 &mat) { compose_matrix(mat, components); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_scale -// Access: Public, Virtual -// Description: Gets the scale value at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the scale value at the indicated frame. + */ void AnimChannelMatrixXfmTable:: get_scale(int frame, LVecBase3 &scale) { for (int i = 0; i < 3; i++) { @@ -182,13 +162,10 @@ get_scale(int frame, LVecBase3 &scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_hpr -// Access: Public, Virtual -// Description: Returns the h, p, and r components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the h, p, and r components associated with the current frame. As + * above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixXfmTable:: get_hpr(int frame, LVecBase3 &hpr) { for (int i = 0; i < 3; i++) { @@ -200,13 +177,11 @@ get_hpr(int frame, LVecBase3 &hpr) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_quat -// Access: Public, Virtual -// Description: Returns the rotation component associated with the -// current frame, expressed as a quaternion. As above, -// this only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component associated with the current frame, expressed + * as a quaternion. As above, this only makes sense for a matrix-type + * channel. + */ void AnimChannelMatrixXfmTable:: get_quat(int frame, LQuaternion &quat) { LVecBase3 hpr; @@ -221,13 +196,10 @@ get_quat(int frame, LQuaternion &quat) { quat.set_hpr(hpr); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_pos -// Access: Public, Virtual -// Description: Returns the x, y, and z translation components -// associated with the current frame. As above, this -// only makes sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y, and z translation components associated with the current + * frame. As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixXfmTable:: get_pos(int frame, LVecBase3 &pos) { for (int i = 0; i < 3; i++) { @@ -239,13 +211,10 @@ get_pos(int frame, LVecBase3 &pos) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_shear -// Access: Public, Virtual -// Description: Returns the a, b, and c shear components associated -// with the current frame. As above, this only makes -// sense for a matrix-type channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the a, b, and c shear components associated with the current frame. + * As above, this only makes sense for a matrix-type channel. + */ void AnimChannelMatrixXfmTable:: get_shear(int frame, LVecBase3 &shear) { for (int i = 0; i < 3; i++) { @@ -257,22 +226,19 @@ get_shear(int frame, LVecBase3 &shear) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::set_table -// Access: Public -// Description: Assigns the indicated table. table_id is one of 'i', -// 'j', 'k', for scale, 'a', 'b', 'c' for shear, 'h', -// 'p', 'r', for rotation, and 'x', 'y', 'z', for -// translation. The new table must have either zero, -// one, or get_num_frames() frames. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the indicated table. table_id is one of 'i', 'j', 'k', for scale, + * 'a', 'b', 'c' for shear, 'h', 'p', 'r', for rotation, and 'x', 'y', 'z', + * for translation. The new table must have either zero, one, or + * get_num_frames() frames. + */ void AnimChannelMatrixXfmTable:: set_table(char table_id, const CPTA_stdfloat &table) { int num_frames = _root->get_num_frames(); if (table.size() > 1 && (int)table.size() < num_frames) { - // The new table has an invalid number of frames--it doesn't match - // the bundle's requirement. + // The new table has an invalid number of frames--it doesn't match the + // bundle's requirement. nassertv(false); return; } @@ -286,12 +252,10 @@ set_table(char table_id, const CPTA_stdfloat &table) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::clear_all_tables -// Access: Published -// Description: Removes all the tables from the channel, and resets -// it to its initial state. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the tables from the channel, and resets it to its initial + * state. + */ void AnimChannelMatrixXfmTable:: clear_all_tables() { for (int i = 0; i < num_matrix_components; i++) { @@ -299,12 +263,9 @@ clear_all_tables() { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::write -// Access: Public, Virtual -// Description: Writes a brief description of the table and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the table and all of its descendants. + */ void AnimChannelMatrixXfmTable:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -332,27 +293,21 @@ write(ostream &out, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimChannelMatrixXfmTable:: make_copy(AnimGroup *parent) const { return new AnimChannelMatrixXfmTable(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::get_table_index -// Access: Protected, Static -// Description: Returns the table index number, a value between 0 and -// num_matrix_components, that corresponds to the -// indicated table id. Returns -1 if the table id is -// invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the table index number, a value between 0 and + * num_matrix_components, that corresponds to the indicated table id. Returns + * -1 if the table id is invalid. + */ int AnimChannelMatrixXfmTable:: get_table_index(char table_id) { for (int i = 0; i < num_matrix_components; i++) { @@ -364,12 +319,10 @@ get_table_index(char table_id) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimChannelMatrixXfmTable:: write_datagram(BamWriter *manager, Datagram &me) { AnimChannelMatrix::write_datagram(manager, me); @@ -407,8 +360,8 @@ write_datagram(BamWriter *manager, Datagram &me) { compressor.write_reals(me, _tables[i], _tables[i].size()); } - // Now, write out the joint angles. For these we need to build up - // a HPR array. + // Now, write out the joint angles. For these we need to build up a HPR + // array. pvector hprs; int hprs_length = max(max(_tables[6].size(), _tables[7].size()), _tables[8].size()); hprs.reserve(hprs_length); @@ -431,22 +384,19 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimChannelMatrixXfmTable:: fillin(DatagramIterator &scan, BamReader *manager) { AnimChannelMatrix::fillin(scan, manager); bool wrote_compressed = scan.get_bool(); - // If this is false, the file still uses the old HPR conventions, - // and we'll have to convert the HPR values to the new convention. + // If this is false, the file still uses the old HPR conventions, and we'll + // have to convert the HPR values to the new convention. bool new_hpr = scan.get_bool(); if (!wrote_compressed) { @@ -551,12 +501,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::make_AnimChannelMatrixXfmTable -// Access: Protected -// Description: Factory method to generate an -// AnimChannelMatrixXfmTable object. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimChannelMatrixXfmTable object. + */ TypedWritable *AnimChannelMatrixXfmTable:: make_AnimChannelMatrixXfmTable(const FactoryParams ¶ms) { AnimChannelMatrixXfmTable *me = new AnimChannelMatrixXfmTable; @@ -568,15 +515,10 @@ make_AnimChannelMatrixXfmTable(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelMatrixXfmTable::register_with_factory -// Access: Public, Static -// Description: Factory method to generate an -// AnimChannelMatrixXfmTable object. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimChannelMatrixXfmTable object. + */ void AnimChannelMatrixXfmTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimChannelMatrixXfmTable); } - - diff --git a/panda/src/chan/animChannelMatrixXfmTable.h b/panda/src/chan/animChannelMatrixXfmTable.h index 0198e68726..431d3ef18f 100644 --- a/panda/src/chan/animChannelMatrixXfmTable.h +++ b/panda/src/chan/animChannelMatrixXfmTable.h @@ -1,16 +1,15 @@ -// Filename: animChannelMatrixXfmTable.h -// Created by: drose (20Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelMatrixXfmTable.h + * @author drose + * @date 1999-02-20 + */ #ifndef ANIMCHANNELMATRIXXFMTABLE_H #define ANIMCHANNELMATRIXXFMTABLE_H @@ -23,14 +22,12 @@ #include "pta_stdfloat.h" #include "compose_matrix.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelMatrixXfmTable -// Description : An animation channel that issues a matrix each frame, -// read from a table such as might have been read from -// an egg file. The table actually consists of nine -// sub-tables, each representing one component of the -// transform: scale, rotate, translate. -//////////////////////////////////////////////////////////////////// +/** + * An animation channel that issues a matrix each frame, read from a table + * such as might have been read from an egg file. The table actually consists + * of nine sub-tables, each representing one component of the transform: + * scale, rotate, translate. + */ class EXPCL_PANDA_CHAN AnimChannelMatrixXfmTable : public AnimChannelMatrix { protected: AnimChannelMatrixXfmTable(); @@ -39,9 +36,9 @@ protected: PUBLISHED: AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name); virtual ~AnimChannelMatrixXfmTable(); - + public: - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, LMatrix4 &mat); diff --git a/panda/src/chan/animChannelScalarDynamic.I b/panda/src/chan/animChannelScalarDynamic.I index f447778ec3..e165b58b44 100644 --- a/panda/src/chan/animChannelScalarDynamic.I +++ b/panda/src/chan/animChannelScalarDynamic.I @@ -1,14 +1,12 @@ -// Filename: animChannelScalarDynamic.I -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarDynamic.I + * @author drose + * @date 2003-10-20 + */ diff --git a/panda/src/chan/animChannelScalarDynamic.cxx b/panda/src/chan/animChannelScalarDynamic.cxx index bcfc8011d3..ead0d539a6 100644 --- a/panda/src/chan/animChannelScalarDynamic.cxx +++ b/panda/src/chan/animChannelScalarDynamic.cxx @@ -1,16 +1,15 @@ -// Filename: animChannelScalarDynamic.cxx -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarDynamic.cxx + * @author drose + * @date 2003-10-20 + */ #include "animChannelScalarDynamic.h" #include "animBundle.h" @@ -25,25 +24,20 @@ TypeHandle AnimChannelScalarDynamic::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::Constructor -// Access: Protected -// Description: For use only with the bam reader. -//////////////////////////////////////////////////////////////////// +/** + * For use only with the bam reader. + */ AnimChannelScalarDynamic:: AnimChannelScalarDynamic() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelScalarDynamic, just like -// this one, without copying any children. The new copy -// is added to the indicated parent. Intended to be -// called by make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelScalarDynamic, just like this one, without copying + * any children. The new copy is added to the indicated parent. Intended to + * be called by make_copy() only. + */ AnimChannelScalarDynamic:: -AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic ©) : +AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic ©) : AnimChannelScalar(parent, copy), _value_node(copy._value_node), _value(copy._value), @@ -53,28 +47,23 @@ AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic © { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelScalarDynamic:: AnimChannelScalarDynamic(const string &name) - : AnimChannelScalar(name) + : AnimChannelScalar(name) { _last_value = _value = TransformState::make_identity(); _value_changed = true; _float_value = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::has_changed -// Access: Public, Virtual -// Description: Returns true if the value has changed since the last -// call to has_changed(). last_frame is the frame -// number of the last call; this_frame is the current -// frame number. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the value has changed since the last call to has_changed(). + * last_frame is the frame number of the last call; this_frame is the current + * frame number. + */ bool AnimChannelScalarDynamic:: has_changed(int, double, int, double) { if (_value_node != (PandaNode *)NULL) { @@ -90,11 +79,9 @@ has_changed(int, double, int, double) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::get_value -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame. + */ void AnimChannelScalarDynamic:: get_value(int, PN_stdfloat &value) { if (_value_node != (PandaNode *)NULL) { @@ -105,11 +92,9 @@ get_value(int, PN_stdfloat &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::set_value -// Access: Published -// Description: Explicitly sets the value. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the value. + */ void AnimChannelScalarDynamic:: set_value(PN_stdfloat value) { _float_value = value; @@ -117,13 +102,10 @@ set_value(PN_stdfloat value) { _value_changed = true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::set_value_node -// Access: Published -// Description: Specifies a node whose transform will be queried each -// frame to implicitly specify the transform of this -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a node whose transform will be queried each frame to implicitly + * specify the transform of this joint. + */ void AnimChannelScalarDynamic:: set_value_node(PandaNode *value_node) { if (_value_node == (PandaNode *)NULL) { @@ -137,26 +119,21 @@ set_value_node(PandaNode *value_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimChannelScalarDynamic:: make_copy(AnimGroup *parent) const { return new AnimChannelScalarDynamic(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimChannelScalarDynamic:: write_datagram(BamWriter *manager, Datagram &dg) { AnimChannelScalar::write_datagram(manager, dg); @@ -165,13 +142,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_float_value); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int AnimChannelScalarDynamic:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = AnimChannelScalar::complete_pointers(p_list, manager); @@ -183,14 +157,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::fillin -// Access: Public -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimChannelScalarDynamic:: fillin(DatagramIterator &scan, BamReader *manager) { AnimChannelScalar::fillin(scan, manager); @@ -202,11 +173,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _float_value = scan.get_stdfloat(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::make_AnimChannelScalarDynamic -// Access: Public -// Description: Factory method to generate a AnimChannelScalarDynamic object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimChannelScalarDynamic object + */ TypedWritable *AnimChannelScalarDynamic:: make_AnimChannelScalarDynamic(const FactoryParams ¶ms) { AnimChannelScalarDynamic *me = new AnimChannelScalarDynamic; @@ -218,16 +187,10 @@ make_AnimChannelScalarDynamic(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarDynamic::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a AnimChannelScalarDynamic object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimChannelScalarDynamic object + */ void AnimChannelScalarDynamic:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimChannelScalarDynamic); } - - - - diff --git a/panda/src/chan/animChannelScalarDynamic.h b/panda/src/chan/animChannelScalarDynamic.h index fc4a914d84..72828d968d 100644 --- a/panda/src/chan/animChannelScalarDynamic.h +++ b/panda/src/chan/animChannelScalarDynamic.h @@ -1,16 +1,15 @@ -// Filename: animChannelScalarDynamic.h -// Created by: drose (20Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarDynamic.h + * @author drose + * @date 2003-10-20 + */ #ifndef ANIMCHANNELSCALARDYNAMIC_H #define ANIMCHANNELSCALARDYNAMIC_H @@ -22,18 +21,15 @@ class PandaNode; class TransformState; -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelScalarDynamic -// Description : An animation channel that accepts a scalar each frame -// from some dynamic input provided by code. -// -// This object operates in two modes: in explicit mode, -// the programmer should call set_value() each frame to -// indicate the new value; in implicit mode, the -// programmer should call set_value_node() to indicate -// the node whose X component will be copied to the -// scalar each frame. -//////////////////////////////////////////////////////////////////// +/** + * An animation channel that accepts a scalar each frame from some dynamic + * input provided by code. + * + * This object operates in two modes: in explicit mode, the programmer should + * call set_value() each frame to indicate the new value; in implicit mode, + * the programmer should call set_value_node() to indicate the node whose X + * component will be copied to the scalar each frame. + */ class EXPCL_PANDA_CHAN AnimChannelScalarDynamic : public AnimChannelScalar { protected: AnimChannelScalarDynamic(); @@ -42,7 +38,7 @@ protected: public: AnimChannelScalarDynamic(const string &name); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, PN_stdfloat &value); @@ -54,15 +50,14 @@ protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; private: - // This is filled in only if we are using the set_value_node() - // interface to get an implicit value from the transform on the - // indicated node each frame. + // This is filled in only if we are using the set_value_node() interface to + // get an implicit value from the transform on the indicated node each + // frame. PT(PandaNode) _value_node; CPT(TransformState) _value; CPT(TransformState) _last_value; - // This is used only if we are using the explicit set_value() - // interface. + // This is used only if we are using the explicit set_value() interface. bool _value_changed; PN_stdfloat _float_value; diff --git a/panda/src/chan/animChannelScalarTable.I b/panda/src/chan/animChannelScalarTable.I index 586e2c2e59..1a41648490 100644 --- a/panda/src/chan/animChannelScalarTable.I +++ b/panda/src/chan/animChannelScalarTable.I @@ -1,47 +1,38 @@ -// Filename: animChannelScalarTable.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarTable.I + * @author drose + * @date 1999-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::get_table -// Access: Public -// Description: Returns a pointer to the table's data, -// if it exists, or NULL if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the table's data, if it exists, or NULL if it does + * not. + */ INLINE CPTA_stdfloat AnimChannelScalarTable:: get_table() const { return _table; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::has_table -// Access: Published -// Description: Returns true if the data table has been assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data table has been assigned. + */ INLINE bool AnimChannelScalarTable:: has_table() const { return _table != (const PN_stdfloat *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::clear_table -// Access: Published -// Description: Empties the data table. -//////////////////////////////////////////////////////////////////// +/** + * Empties the data table. + */ INLINE void AnimChannelScalarTable:: clear_table() { _table = NULL; } - diff --git a/panda/src/chan/animChannelScalarTable.cxx b/panda/src/chan/animChannelScalarTable.cxx index 0290a649ca..5bcbd0cb40 100644 --- a/panda/src/chan/animChannelScalarTable.cxx +++ b/panda/src/chan/animChannelScalarTable.cxx @@ -1,17 +1,15 @@ -// Filename: animChannelScalarTable.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarTable.cxx + * @author drose + * @date 1999-02-22 + */ #include "animChannelScalarTable.h" #include "animBundle.h" @@ -26,35 +24,28 @@ TypeHandle AnimChannelScalarTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelScalarTable:: AnimChannelScalarTable() : _table(get_class_type()) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::Copy Constructor -// Access: Protected -// Description: Creates a new AnimChannelScalarTable, just like -// this one, without copying any children. The new copy -// is added to the indicated parent. Intended to be -// called by make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimChannelScalarTable, just like this one, without copying + * any children. The new copy is added to the indicated parent. Intended to + * be called by make_copy() only. + */ AnimChannelScalarTable:: -AnimChannelScalarTable(AnimGroup *parent, const AnimChannelScalarTable ©) : +AnimChannelScalarTable(AnimGroup *parent, const AnimChannelScalarTable ©) : AnimChannelScalar(parent, copy), _table(copy._table) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimChannelScalarTable:: AnimChannelScalarTable(AnimGroup *parent, const string &name) : AnimChannelScalar(parent, name), @@ -62,28 +53,25 @@ AnimChannelScalarTable(AnimGroup *parent, const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::has_changed -// Access: Public, Virtual -// Description: Returns true if the value has changed since the last -// call to has_changed(). last_frame is the frame -// number of the last call; this_frame is the current -// frame number. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the value has changed since the last call to has_changed(). + * last_frame is the frame number of the last call; this_frame is the current + * frame number. + */ bool AnimChannelScalarTable:: -has_changed(int last_frame, double last_frac, +has_changed(int last_frame, double last_frac, int this_frame, double this_frac) { if (_table.size() > 1) { if (last_frame != this_frame) { - if (_table[last_frame % _table.size()] != + if (_table[last_frame % _table.size()] != _table[this_frame % _table.size()]) { return true; } } if (last_frac != this_frac) { - // If we have some fractional changes, also check the next - // subsequent frame (since we'll be blending with that). - if (_table[last_frame % _table.size()] != + // If we have some fractional changes, also check the next subsequent + // frame (since we'll be blending with that). + if (_table[last_frame % _table.size()] != _table[(this_frame + 1) % _table.size()]) { return true; } @@ -93,11 +81,9 @@ has_changed(int last_frame, double last_frac, return false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::get_value -// Access: Public, Virtual -// Description: Gets the value of the channel at the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Gets the value of the channel at the indicated frame. + */ void AnimChannelScalarTable:: get_value(int frame, PN_stdfloat &value) { if (_table.empty()) { @@ -108,18 +94,16 @@ get_value(int frame, PN_stdfloat &value) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::set_table -// Access: Public -// Description: Assigns the data table. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the data table. + */ void AnimChannelScalarTable:: set_table(const CPTA_stdfloat &table) { int num_frames = _root->get_num_frames(); if (table.size() > 1 && (int)table.size() < num_frames) { - // The new table has an invalid number of frames--it doesn't match - // the bundle's requirement. + // The new table has an invalid number of frames--it doesn't match the + // bundle's requirement. nassertv(false); return; } @@ -127,12 +111,9 @@ set_table(const CPTA_stdfloat &table) { _table = table; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::write -// Access: Public, Virtual -// Description: Writes a brief description of the table and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the table and all of its descendants. + */ void AnimChannelScalarTable:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -147,25 +128,20 @@ write(ostream &out, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimChannelScalarTable:: make_copy(AnimGroup *parent) const { return new AnimChannelScalarTable(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimChannelScalarTable:: write_datagram(BamWriter *manager, Datagram &me) { AnimChannelScalar::write_datagram(manager, me); @@ -185,13 +161,13 @@ write_datagram(BamWriter *manager, Datagram &me) { } } else { - // Some channels, particularly blink channels, may involve only a - // small number of discrete values. If we come across one of - // those, write it out losslessly, since the lossy compression - // could damage it significantly (and we can achieve better - // compression directly anyway). We consider the channel value - // only to the nearest 1000th for this purpose, because floats - // aren't very good at being precisely equal to each other. + // Some channels, particularly blink channels, may involve only a small + // number of discrete values. If we come across one of those, write it + // out losslessly, since the lossy compression could damage it + // significantly (and we can achieve better compression directly anyway). + // We consider the channel value only to the nearest 1000th for this + // purpose, because floats aren't very good at being precisely equal to + // each other. static const int max_values = 16; static const PN_stdfloat scale = 1000.0f; @@ -205,14 +181,13 @@ write_datagram(BamWriter *manager, Datagram &me) { } int index_length = index.size(); if (index_length <= max_values) { - // All right, here's a blink channel. Now we write out the - // index table, and then a table of all the index values, two - // per byte. + // All right, here's a blink channel. Now we write out the index table, + // and then a table of all the index values, two per byte. me.add_uint8(index_length); if (index_length > 0) { - // We need to write the index in order by its index number; for - // this, we need to invert the index. + // We need to write the index in order by its index number; for this, + // we need to invert the index. vector_stdfloat reverse_index(index_length); pmap::iterator mi; for (mi = index.begin(); mi != index.end(); ++mi) { @@ -226,14 +201,14 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_stdfloat(reverse_index[i]); } - // Now write out the actual channels. We write these two at a - // time, in the high and low nibbles of each byte. + // Now write out the actual channels. We write these two at a time, + // in the high and low nibbles of each byte. int table_length = _table.size(); me.add_uint16(table_length); if (index_length == 1) { - // In fact, we don't even need to write the channels at all, - // if there weren't at least two different values. + // In fact, we don't even need to write the channels at all, if + // there weren't at least two different values. } else { for (i = 0; i < table_length - 1; i+= 2) { @@ -270,14 +245,11 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimChannelScalarTable:: fillin(DatagramIterator& scan, BamReader* manager) { AnimChannelScalar::fillin(scan, manager); @@ -294,8 +266,8 @@ fillin(DatagramIterator& scan, BamReader* manager) { } } else { - // Compressed channels. - // Did we write them as discrete or continuous channel values? + // Compressed channels. Did we write them as discrete or continuous + // channel values? int index_length = scan.get_uint8(); if (index_length < 0xff) { @@ -343,11 +315,9 @@ fillin(DatagramIterator& scan, BamReader* manager) { _table = temp_table; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::make_AnimChannelScalarTable -// Access: Protected -// Description: Factory method to generate a AnimChannelScalarTable object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimChannelScalarTable object + */ TypedWritable* AnimChannelScalarTable:: make_AnimChannelScalarTable(const FactoryParams ¶ms) { AnimChannelScalarTable *me = new AnimChannelScalarTable; @@ -359,16 +329,10 @@ make_AnimChannelScalarTable(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimChannelScalarTable::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a AnimChannelScalarTable object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimChannelScalarTable object + */ void AnimChannelScalarTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimChannelScalarTable); } - - - - diff --git a/panda/src/chan/animChannelScalarTable.h b/panda/src/chan/animChannelScalarTable.h index 5b18307466..2d706b9e7c 100644 --- a/panda/src/chan/animChannelScalarTable.h +++ b/panda/src/chan/animChannelScalarTable.h @@ -1,16 +1,15 @@ -// Filename: animChannelScalarTable.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animChannelScalarTable.h + * @author drose + * @date 1999-02-22 + */ #ifndef ANIMCHANNELSCALARTABLE_H #define ANIMCHANNELSCALARTABLE_H @@ -22,12 +21,10 @@ #include "pointerToArray.h" #include "pta_stdfloat.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimChannelScalarTable -// Description : An animation channel that issues a scalar each frame, -// read from a table such as might have been read from -// an egg file. -//////////////////////////////////////////////////////////////////// +/** + * An animation channel that issues a scalar each frame, read from a table + * such as might have been read from an egg file. + */ class EXPCL_PANDA_CHAN AnimChannelScalarTable : public AnimChannelScalar { protected: AnimChannelScalarTable(); @@ -36,7 +33,7 @@ protected: public: AnimChannelScalarTable(AnimGroup *parent, const string &name); - virtual bool has_changed(int last_frame, double last_frac, + virtual bool has_changed(int last_frame, double last_frac, int this_frame, double this_frac); virtual void get_value(int frame, PN_stdfloat &value); diff --git a/panda/src/chan/animControl.I b/panda/src/chan/animControl.I index 963b733674..3b79891fc4 100644 --- a/panda/src/chan/animControl.I +++ b/panda/src/chan/animControl.I @@ -1,116 +1,88 @@ -// Filename: animControl.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControl.I + * @author drose + * @date 1999-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::is_pending -// Access: Published -// Description: Returns true if the AnimControl is being bound -// asynchronously, and has not yet finished. If this is -// true, the AnimControl's interface is still available -// and will be perfectly useful (though get_anim() might -// return NULL), but nothing visible will happen -// immediately. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the AnimControl is being bound asynchronously, and has not + * yet finished. If this is true, the AnimControl's interface is still + * available and will be perfectly useful (though get_anim() might return + * NULL), but nothing visible will happen immediately. + */ INLINE bool AnimControl:: is_pending() const { return _pending; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::has_anim -// Access: Published -// Description: Returns true if the AnimControl was successfully -// loaded, or false if there was a problem. This may -// return false while is_pending() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the AnimControl was successfully loaded, or false if there + * was a problem. This may return false while is_pending() is true. + */ INLINE bool AnimControl:: has_anim() const { return (_anim != (AnimBundle *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_anim -// Access: Published -// Description: Returns the AnimBundle bound in with this -// AnimControl. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimBundle bound in with this AnimControl. + */ INLINE AnimBundle *AnimControl:: get_anim() const { return _anim; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_channel_index -// Access: Published -// Description: Returns the particular channel index associated with -// this AnimControl. This channel index is the slot on -// which each AnimGroup is bound to its associated -// PartGroup, for each joint in the animation. -// -// It will be true that -// get_part()->find_child("n")->get_bound(get_channel_index()) -// == get_anim()->find_child("n"), for each joint "n". -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular channel index associated with this AnimControl. + * This channel index is the slot on which each AnimGroup is bound to its + * associated PartGroup, for each joint in the animation. + * + * It will be true that + * get_part()->find_child("n")->get_bound(get_channel_index()) == + * get_anim()->find_child("n"), for each joint "n". + */ INLINE int AnimControl:: get_channel_index() const { return _channel_index; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_bound_joints -// Access: Published -// Description: Returns the subset of joints controlled by this -// AnimControl. Most of the time, this will be -// BitArray::all_on(), for a normal full-body animation. -// For a subset animation, however, this will be just a -// subset of those bits, corresponding to the set of -// joints and sliders actually bound (as enumerated by -// bind_hierarchy() in depth-first LIFO order). -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of joints controlled by this AnimControl. Most of the + * time, this will be BitArray::all_on(), for a normal full-body animation. + * For a subset animation, however, this will be just a subset of those bits, + * corresponding to the set of joints and sliders actually bound (as + * enumerated by bind_hierarchy() in depth-first LIFO order). + */ INLINE const BitArray &AnimControl:: get_bound_joints() const { return _bound_joints; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::set_anim_model -// Access: Published -// Description: Associates the indicated PandaNode with the -// AnimControl. By convention, this node represents the -// root node of the model file that corresponds to this -// AnimControl's animation file, though nothing in this -// code makes this assumption or indeed does anything -// with this node. -// -// The purpose of this is simply to allow the -// AnimControl to keep a reference count on the -// ModelRoot node that generated it, so that the model -// will not disappear from the model pool until it is no -// longer referenced. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated PandaNode with the AnimControl. By convention, + * this node represents the root node of the model file that corresponds to + * this AnimControl's animation file, though nothing in this code makes this + * assumption or indeed does anything with this node. + * + * The purpose of this is simply to allow the AnimControl to keep a reference + * count on the ModelRoot node that generated it, so that the model will not + * disappear from the model pool until it is no longer referenced. + */ INLINE void AnimControl:: set_anim_model(PandaNode *model) { _anim_model = model; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_anim_model -// Access: Published -// Description: Retrieves the pointer set via set_anim_model(). See -// set_anim_model(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the pointer set via set_anim_model(). See set_anim_model(). + */ INLINE PandaNode *AnimControl:: get_anim_model() const { return _anim_model; diff --git a/panda/src/chan/animControl.cxx b/panda/src/chan/animControl.cxx index 110a52a434..09660d22c0 100644 --- a/panda/src/chan/animControl.cxx +++ b/panda/src/chan/animControl.cxx @@ -1,16 +1,15 @@ -// Filename: animControl.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControl.cxx + * @author drose + * @date 1999-02-19 + */ #include "animControl.h" #include "animChannelBase.h" @@ -22,17 +21,13 @@ TypeHandle AnimControl::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::Constructor -// Access: Public -// Description: This constructor is used to create a temporarily -// uninitialized AnimControl that will serve as a -// placeholder for an animation while the animation is -// being loaded during an asynchronous load-and-bind -// operation. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is used to create a temporarily uninitialized AnimControl + * that will serve as a placeholder for an animation while the animation is + * being loaded during an asynchronous load-and-bind operation. + */ AnimControl:: -AnimControl(const string &name, PartBundle *part, +AnimControl(const string &name, PartBundle *part, double frame_rate, int num_frames) : Namable(name), _pending_lock(name), @@ -53,15 +48,12 @@ AnimControl(const string &name, PartBundle *part, _marked_frame = -1; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::setup_anim -// Access: Public -// Description: This can only be called once for a given AnimControl. -// It is used to supply the AnimBundle and related -// information. -//////////////////////////////////////////////////////////////////// +/** + * This can only be called once for a given AnimControl. It is used to supply + * the AnimBundle and related information. + */ void AnimControl:: -setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, +setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints) { MutexHolder holder(_pending_lock); nassertv(_pending && part == _part); @@ -81,25 +73,20 @@ setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::set_bound_joints -// Access: Public -// Description: Called to initialize the AnimControl with its array -// of bound_joints, before setup_anim() has completed. -//////////////////////////////////////////////////////////////////// +/** + * Called to initialize the AnimControl with its array of bound_joints, before + * setup_anim() has completed. + */ void AnimControl:: set_bound_joints(const BitArray &bound_joints) { MutexHolder holder(_pending_lock); _bound_joints = bound_joints; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::fail_anim -// Access: Public -// Description: This can only be called once for a given AnimControl. -// It indicates the attempt to bind it asynchronously -// has failed. -//////////////////////////////////////////////////////////////////// +/** + * This can only be called once for a given AnimControl. It indicates the + * attempt to bind it asynchronously has failed. + */ void AnimControl:: fail_anim(PartBundle *part) { MutexHolder holder(_pending_lock); @@ -111,31 +98,26 @@ fail_anim(PartBundle *part) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimControl:: ~AnimControl() { get_part()->set_control_effect(this, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::wait_pending -// Access: Published -// Description: Blocks the current thread until the AnimControl has -// finished loading and is fully bound. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the current thread until the AnimControl has finished loading and is + * fully bound. + */ void AnimControl:: wait_pending() { MutexHolder holder(_pending_lock); if (_pending) { - // TODO: we should elevate the priority of the associated - // BindAnimRequest while we're waiting for it, so it will jump to - // the front of the queue. + // TODO: we should elevate the priority of the associated BindAnimRequest + // while we're waiting for it, so it will jump to the front of the queue. chan_cat.info() - << "Blocking " << *Thread::get_current_thread() + << "Blocking " << *Thread::get_current_thread() << " until " << get_name() << " is bound\n"; while (_pending) { _pending_cvar.wait(); @@ -143,14 +125,11 @@ wait_pending() { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::set_pending_done_event -// Access: Published -// Description: Specifies an event name that will be thrown when the -// AnimControl is finished binding asynchronously. If -// the AnimControl has already finished binding, the -// event will be thrown immediately. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an event name that will be thrown when the AnimControl is + * finished binding asynchronously. If the AnimControl has already finished + * binding, the event will be thrown immediately. + */ void AnimControl:: set_pending_done_event(const string &done_event) { MutexHolder holder(_pending_lock); @@ -160,34 +139,27 @@ set_pending_done_event(const string &done_event) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_pending_done_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// AnimControl is finished binding asynchronously. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the AnimControl is finished + * binding asynchronously. + */ string AnimControl:: get_pending_done_event() const { MutexHolder holder(_pending_lock); return _pending_done_event; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::get_part -// Access: Published -// Description: Returns the PartBundle bound in with this -// AnimControl. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PartBundle bound in with this AnimControl. + */ PartBundle *AnimControl:: get_part() const { return DCAST(PartBundle, _part); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimControl:: output(ostream &out) const { out << "AnimControl(" << get_name() << ", " << get_part()->get_name() @@ -202,12 +174,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::channel_has_changed -// Access: Public -// Description: Returns true if the indicated channel value has -// changed since the last call to mark_channels(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated channel value has changed since the last call + * to mark_channels(). + */ bool AnimControl:: channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const { if (_marked_frame < 0) { @@ -219,16 +189,14 @@ channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const { if (frame_blend_flag) { this_frac = get_frac(); } - return channel->has_changed(_marked_frame, _marked_frac, + return channel->has_changed(_marked_frame, _marked_frac, this_frame, this_frac); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::mark_channels -// Access: Public -// Description: Marks this point as the point of reference for the -// next call to channel_has_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Marks this point as the point of reference for the next call to + * channel_has_changed(). + */ void AnimControl:: mark_channels(bool frame_blend_flag) { _marked_frame = get_frame(); @@ -238,13 +206,10 @@ mark_channels(bool frame_blend_flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControl::animation_activated -// Access: Protected, Virtual -// Description: This is provided as a callback method for when the -// user calls one of the play/loop/pose type methods to -// start the animation playing. -//////////////////////////////////////////////////////////////////// +/** + * This is provided as a callback method for when the user calls one of the + * play/loop/pose type methods to start the animation playing. + */ void AnimControl:: animation_activated() { get_part()->control_activated(this); diff --git a/panda/src/chan/animControl.h b/panda/src/chan/animControl.h index b00c765c37..09b5e203a1 100644 --- a/panda/src/chan/animControl.h +++ b/panda/src/chan/animControl.h @@ -1,16 +1,15 @@ -// Filename: animControl.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControl.h + * @author drose + * @date 1999-02-19 + */ #ifndef ANIMCONTROL_H #define ANIMCONTROL_H @@ -30,17 +29,15 @@ class PartBundle; class AnimChannelBase; -//////////////////////////////////////////////////////////////////// -// Class : AnimControl -// Description : Controls the timing of a character animation. An -// AnimControl object is created for each -// character/bundle binding and manages the state of the -// animation: whether started, stopped, or looping, and -// the current frame number and play rate. -//////////////////////////////////////////////////////////////////// +/** + * Controls the timing of a character animation. An AnimControl object is + * created for each character/bundle binding and manages the state of the + * animation: whether started, stopped, or looping, and the current frame + * number and play rate. + */ class EXPCL_PANDA_CHAN AnimControl : public TypedReferenceCount, public AnimInterface, public Namable { public: - AnimControl(const string &name, PartBundle *part, + AnimControl(const string &name, PartBundle *part, double frame_rate, int num_frames); void setup_anim(PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints); @@ -67,9 +64,8 @@ PUBLISHED: virtual void output(ostream &out) const; public: - // The following functions aren't really part of the public - // interface; they're just public so we don't have to declare a - // bunch of friends. + // The following functions aren't really part of the public interface; + // they're just public so we don't have to declare a bunch of friends. bool channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const; void mark_channels(bool frame_blend_flag); @@ -83,22 +79,20 @@ private: Mutex _pending_lock; // protects the above two. ConditionVarFull _pending_cvar; // signals when _pending goes true. - // This is a PT(PartGroup) instead of a PT(PartBundle), just because - // we can't include partBundle.h for circular reasons. But it - // actually keeps a pointer to a PartBundle. + // This is a PT(PartGroup) instead of a PT(PartBundle), just because we + // can't include partBundle.h for circular reasons. But it actually keeps a + // pointer to a PartBundle. PT(PartGroup) _part; PT(AnimBundle) _anim; int _channel_index; - // This is the frame number as of the last call to mark_channels(). - // In frame_blend mode, we also record the fractional part of the - // frame number. + // This is the frame number as of the last call to mark_channels(). In + // frame_blend mode, we also record the fractional part of the frame number. int _marked_frame; double _marked_frac; - // This is the bitmask of joints and/or sliders from the animation - // that we have actually bound into this AnimControl. See - // get_bound_joints(). + // This is the bitmask of joints andor sliders from the animation that we + // have actually bound into this AnimControl. See get_bound_joints(). BitArray _bound_joints; PT(PandaNode) _anim_model; diff --git a/panda/src/chan/animControlCollection.I b/panda/src/chan/animControlCollection.I index 4081d04f64..fd4b7251b1 100644 --- a/panda/src/chan/animControlCollection.I +++ b/panda/src/chan/animControlCollection.I @@ -1,23 +1,19 @@ -// Filename: animControlCollection.I -// Created by: drose (22Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControlCollection.I + * @author drose + * @date 2000-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::play -// Access: Public -// Description: Starts the named animation playing. -//////////////////////////////////////////////////////////////////// +/** + * Starts the named animation playing. + */ INLINE bool AnimControlCollection:: play(const string &anim_name) { AnimControl *control = find_anim(anim_name); @@ -29,11 +25,9 @@ play(const string &anim_name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::play -// Access: Public -// Description: Starts the named animation playing. -//////////////////////////////////////////////////////////////////// +/** + * Starts the named animation playing. + */ INLINE bool AnimControlCollection:: play(const string &anim_name, double from, double to) { AnimControl *control = find_anim(anim_name); @@ -45,11 +39,9 @@ play(const string &anim_name, double from, double to) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::loop -// Access: Public -// Description: Starts the named animation looping. -//////////////////////////////////////////////////////////////////// +/** + * Starts the named animation looping. + */ INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart) { AnimControl *control = find_anim(anim_name); @@ -61,11 +53,9 @@ loop(const string &anim_name, bool restart) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::loop -// Access: Public -// Description: Starts the named animation looping. -//////////////////////////////////////////////////////////////////// +/** + * Starts the named animation looping. + */ INLINE bool AnimControlCollection:: loop(const string &anim_name, bool restart, double from, double to) { AnimControl *control = find_anim(anim_name); @@ -77,11 +67,9 @@ loop(const string &anim_name, bool restart, double from, double to) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::stop -// Access: Public -// Description: Stops the named animation. -//////////////////////////////////////////////////////////////////// +/** + * Stops the named animation. + */ INLINE bool AnimControlCollection:: stop(const string &anim_name) { AnimControl *control = find_anim(anim_name); @@ -93,11 +81,9 @@ stop(const string &anim_name) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::pose -// Access: Public -// Description: Sets to a particular frame in the named animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets to a particular frame in the named animation. + */ INLINE bool AnimControlCollection:: pose(const string &anim_name, double frame) { AnimControl *control = find_anim(anim_name); @@ -109,12 +95,10 @@ pose(const string &anim_name, double frame) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_frame -// Access: Public -// Description: Returns the current frame in the named animation, or -// 0 if the animation is not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current frame in the named animation, or 0 if the animation is + * not found. + */ INLINE int AnimControlCollection:: get_frame(const string &anim_name) const { AnimControl *control = find_anim(anim_name); @@ -124,12 +108,9 @@ get_frame(const string &anim_name) const { return control->get_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_frame -// Access: Public -// Description: Returns the current frame in the last-started -// animation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current frame in the last-started animation. + */ INLINE int AnimControlCollection:: get_frame() const { if (_last_started_control == (AnimControl *)NULL) { @@ -138,12 +119,9 @@ get_frame() const { return _last_started_control->get_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::is_playing -// Access: Public -// Description: Returns true if the named animation is currently -// playing, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named animation is currently playing, false otherwise. + */ INLINE bool AnimControlCollection:: is_playing(const string &anim_name) const { AnimControl *control = find_anim(anim_name); @@ -153,12 +131,10 @@ is_playing(const string &anim_name) const { return control->is_playing(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::is_playing -// Access: Public -// Description: Returns true if the last-started animation is -// currently playing, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last-started animation is currently playing, false + * otherwise. + */ INLINE bool AnimControlCollection:: is_playing() const { if (_last_started_control == (AnimControl *)NULL) { @@ -167,12 +143,10 @@ is_playing() const { return _last_started_control->is_playing(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_num_frames -// Access: Public -// Description: Returns the total number of frames in the named -// animation, or 0 if the animation is not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of frames in the named animation, or 0 if the + * animation is not found. + */ INLINE int AnimControlCollection:: get_num_frames(const string &anim_name) const { AnimControl *control = find_anim(anim_name); @@ -182,12 +156,9 @@ get_num_frames(const string &anim_name) const { return control->get_num_frames(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_num_frames -// Access: Public -// Description: Returns the total number of frames in the -// last-started animation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of frames in the last-started animation. + */ INLINE int AnimControlCollection:: get_num_frames() const { if (_last_started_control == (AnimControl *)NULL) { @@ -201,4 +172,3 @@ operator << (ostream &out, const AnimControlCollection &collection) { collection.output(out); return out; } - diff --git a/panda/src/chan/animControlCollection.cxx b/panda/src/chan/animControlCollection.cxx index 87cb4b026b..2a46ebb88f 100644 --- a/panda/src/chan/animControlCollection.cxx +++ b/panda/src/chan/animControlCollection.cxx @@ -1,50 +1,41 @@ -// Filename: animControlCollection.cxx -// Created by: drose (22Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControlCollection.cxx + * @author drose + * @date 2000-02-22 + */ #include "animControlCollection.h" -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::Constructor -// Access: Published -// Description: Returns the AnimControl associated with the given -// name, or NULL if no such control has been associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimControl associated with the given name, or NULL if no such + * control has been associated. + */ AnimControlCollection:: AnimControlCollection() { _last_started_control = (AnimControl *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimControlCollection:: ~AnimControlCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::store_anim -// Access: Published -// Description: Associates the given AnimControl with this collection -// under the given name. The AnimControl will remain -// associated until a new AnimControl is associated with -// the same name later, or until unbind_anim() is called -// with this name. -//////////////////////////////////////////////////////////////////// +/** + * Associates the given AnimControl with this collection under the given name. + * The AnimControl will remain associated until a new AnimControl is + * associated with the same name later, or until unbind_anim() is called with + * this name. + */ void AnimControlCollection:: store_anim(AnimControl *control, const string &name) { ControlsByName::iterator ci = _controls_by_name.find(name); @@ -70,12 +61,10 @@ store_anim(AnimControl *control, const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::find_anim -// Access: Published -// Description: Returns the AnimControl associated with the given -// name, or NULL if no such control has been associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimControl associated with the given name, or NULL if no such + * control has been associated. + */ AnimControl *AnimControlCollection:: find_anim(const string &name) const { ControlsByName::const_iterator ci = _controls_by_name.find(name); @@ -88,14 +77,11 @@ find_anim(const string &name) const { return _controls[index]._control; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::unbind_anim -// Access: Published -// Description: Removes the AnimControl associated with the given -// name, if any. Returns true if an AnimControl was -// removed, false if there was no AnimControl with the -// indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Removes the AnimControl associated with the given name, if any. Returns + * true if an AnimControl was removed, false if there was no AnimControl with + * the indicated name. + */ bool AnimControlCollection:: unbind_anim(const string &name) { ControlsByName::iterator ci = _controls_by_name.find(name); @@ -125,57 +111,44 @@ unbind_anim(const string &name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_num_anims -// Access: Published -// Description: Returns the number of AnimControls associated with -// this collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of AnimControls associated with this collection. + */ int AnimControlCollection:: get_num_anims() const { return _controls.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_anim -// Access: Published -// Description: Returns the nth AnimControl associated with -// this collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth AnimControl associated with this collection. + */ AnimControl *AnimControlCollection:: get_anim(int n) const { nassertr(n >= 0 && n < (int)_controls.size(), NULL); return _controls[n]._control; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::get_anim_name -// Access: Published -// Description: Returns the name of the nth AnimControl associated -// with this collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth AnimControl associated with this collection. + */ string AnimControlCollection:: get_anim_name(int n) const { nassertr(n >= 0 && n < (int)_controls.size(), string()); return _controls[n]._name; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::clear_anims -// Access: Published -// Description: Disassociates all anims from this collection. -//////////////////////////////////////////////////////////////////// +/** + * Disassociates all anims from this collection. + */ void AnimControlCollection:: clear_anims() { _controls.clear(); _controls_by_name.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::play_all -// Access: Published -// Description: Starts all animations playing. -//////////////////////////////////////////////////////////////////// +/** + * Starts all animations playing. + */ void AnimControlCollection:: play_all() { Controls::const_iterator ci; @@ -185,11 +158,9 @@ play_all() { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::play_all -// Access: Published -// Description: Starts all animations playing. -//////////////////////////////////////////////////////////////////// +/** + * Starts all animations playing. + */ void AnimControlCollection:: play_all(double from, double to) { Controls::const_iterator ci; @@ -199,11 +170,9 @@ play_all(double from, double to) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::loop_all -// Access: Published -// Description: Starts all animations looping. -//////////////////////////////////////////////////////////////////// +/** + * Starts all animations looping. + */ void AnimControlCollection:: loop_all(bool restart) { Controls::const_iterator ci; @@ -213,11 +182,9 @@ loop_all(bool restart) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::loop_all -// Access: Published -// Description: Starts all animations looping. -//////////////////////////////////////////////////////////////////// +/** + * Starts all animations looping. + */ void AnimControlCollection:: loop_all(bool restart, double from, double to) { Controls::const_iterator ci; @@ -227,13 +194,10 @@ loop_all(bool restart, double from, double to) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::stop_all -// Access: Published -// Description: Stops all currently playing animations. Returns true -// if any animations were stopped, false if none were -// playing. -//////////////////////////////////////////////////////////////////// +/** + * Stops all currently playing animations. Returns true if any animations + * were stopped, false if none were playing. + */ bool AnimControlCollection:: stop_all() { bool any = false; @@ -248,11 +212,9 @@ stop_all() { return any; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::pose_all -// Access: Published -// Description: Sets all animations to the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets all animations to the indicated frame. + */ void AnimControlCollection:: pose_all(double frame) { Controls::const_iterator ci; @@ -262,21 +224,18 @@ pose_all(double frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::which_anim_playing -// Access: Published -// Description: Returns the name of the bound AnimControl currently -// playing, if any. If more than one AnimControl is -// currently playing, returns all of the names separated -// by spaces. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the bound AnimControl currently playing, if any. If + * more than one AnimControl is currently playing, returns all of the names + * separated by spaces. + */ string AnimControlCollection:: which_anim_playing() const { string result; Controls::const_iterator ci; - for (ci = _controls.begin(); - ci != _controls.end(); + for (ci = _controls.begin(); + ci != _controls.end(); ++ci) { if ((*ci)._control->is_playing()) { if (!result.empty()) { @@ -289,26 +248,22 @@ which_anim_playing() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimControlCollection:: output(ostream &out) const { out << _controls.size() << " anims."; } -//////////////////////////////////////////////////////////////////// -// Function: AnimControlCollection::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimControlCollection:: write(ostream &out) const { ControlsByName::const_iterator ci; - for (ci = _controls_by_name.begin(); - ci != _controls_by_name.end(); + for (ci = _controls_by_name.begin(); + ci != _controls_by_name.end(); ++ci) { out << (*ci).first << ": " << *_controls[(*ci).second]._control << "\n"; } diff --git a/panda/src/chan/animControlCollection.h b/panda/src/chan/animControlCollection.h index 7435339660..74db2fea86 100644 --- a/panda/src/chan/animControlCollection.h +++ b/panda/src/chan/animControlCollection.h @@ -1,16 +1,15 @@ -// Filename: animControlCollection.h -// Created by: drose (22Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animControlCollection.h + * @author drose + * @date 2000-02-22 + */ #ifndef ANIMCONTROLCOLLECTION_H #define ANIMCONTROLCOLLECTION_H @@ -24,16 +23,13 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimControlCollection -// Description : This is a named collection of AnimControl pointers. -// An AnimControl may be added to the collection by -// name. While an AnimControl is associated, its -// reference count is maintained; associating a new -// AnimControl with the same name will decrement the -// previous control's reference count (and possibly -// delete it, unbinding its animation). -//////////////////////////////////////////////////////////////////// +/** + * This is a named collection of AnimControl pointers. An AnimControl may be + * added to the collection by name. While an AnimControl is associated, its + * reference count is maintained; associating a new AnimControl with the same + * name will decrement the previous control's reference count (and possibly + * delete it, unbinding its animation). + */ class EXPCL_PANDA_CHAN AnimControlCollection { PUBLISHED: AnimControlCollection(); @@ -51,8 +47,8 @@ PUBLISHED: void clear_anims(); - // The following functions are convenience functions that vector - // directly into the AnimControl's functionality by anim name. + // The following functions are convenience functions that vector directly + // into the AnimControl's functionality by anim name. INLINE bool play(const string &anim_name); INLINE bool play(const string &anim_name, double from, double to); diff --git a/panda/src/chan/animGroup.I b/panda/src/chan/animGroup.I index 3d2989e3b5..5d8875a89a 100644 --- a/panda/src/chan/animGroup.I +++ b/panda/src/chan/animGroup.I @@ -1,13 +1,12 @@ -// Filename: animGroup.I -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animGroup.I + * @author drose + * @date 1999-02-21 + */ diff --git a/panda/src/chan/animGroup.cxx b/panda/src/chan/animGroup.cxx index 1e23ff4763..364da1bd58 100644 --- a/panda/src/chan/animGroup.cxx +++ b/panda/src/chan/animGroup.cxx @@ -1,17 +1,15 @@ -// Filename: animGroup.cxx -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animGroup.cxx + * @author drose + * @date 1999-02-21 + */ #include "animGroup.h" #include "animBundle.h" @@ -29,33 +27,26 @@ TypeHandle AnimGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::Default Constructor -// Access: Protected -// Description: The default constructor is protected: don't try to -// create an AnimGroup without a parent. To create an -// AnimChannel hierarchy, you must first create an -// AnimBundle, and use that to create any subsequent -// children. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is protected: don't try to create an AnimGroup + * without a parent. To create an AnimChannel hierarchy, you must first + * create an AnimBundle, and use that to create any subsequent children. + */ AnimGroup:: -AnimGroup(const string &name) : +AnimGroup(const string &name) : Namable(name), _children(get_class_type()), _root(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::Copy Constructor -// Access: Protected -// Description: Creates a new AnimGroup, just like this one, without -// copying any children. The new copy is added to the -// indicated parent. Intended to be called by -// make_copy() only. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AnimGroup, just like this one, without copying any children. + * The new copy is added to the indicated parent. Intended to be called by + * make_copy() only. + */ AnimGroup:: -AnimGroup(AnimGroup *parent, const AnimGroup ©) : +AnimGroup(AnimGroup *parent, const AnimGroup ©) : Namable(copy), _children(get_class_type()) { @@ -67,15 +58,12 @@ AnimGroup(AnimGroup *parent, const AnimGroup ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::Constructor -// Access: Published -// Description: Creates the AnimGroup, and adds it to the indicated -// parent. The only way to delete it subsequently is to -// delete the entire hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Creates the AnimGroup, and adds it to the indicated parent. The only way + * to delete it subsequently is to delete the entire hierarchy. + */ AnimGroup:: -AnimGroup(AnimGroup *parent, const string &name) : +AnimGroup(AnimGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { @@ -85,47 +73,38 @@ AnimGroup(AnimGroup *parent, const string &name) : _root = parent->_root; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimGroup:: ~AnimGroup() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::get_num_children -// Access: Published -// Description: Returns the number of child nodes of the group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child nodes of the group. + */ int AnimGroup:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::get_child -// Access: Published -// Description: Returns the nth child of the group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of the group. + */ AnimGroup *AnimGroup:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::get_child_named -// Access: Published -// Description: Returns the first child found with the indicated -// name, or NULL if no such child exists. This method -// searches only the children of this particular -// AnimGroup; it does not recursively search the entire -// graph. See also find_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first child found with the indicated name, or NULL if no such + * child exists. This method searches only the children of this particular + * AnimGroup; it does not recursively search the entire graph. See also + * find_child(). + */ AnimGroup *AnimGroup:: get_child_named(const string &name) const { Children::const_iterator ci; @@ -139,14 +118,11 @@ get_child_named(const string &name) const { return (AnimGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::find_child -// Access: Published -// Description: Returns the first descendant found with the indicated -// name, or NULL if no such descendant exists. This -// method searches the entire graph beginning at this -// AnimGroup; see also get_child_named(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first descendant found with the indicated name, or NULL if no + * such descendant exists. This method searches the entire graph beginning at + * this AnimGroup; see also get_child_named(). + */ AnimGroup *AnimGroup:: find_child(const string &name) const { Children::const_iterator ci; @@ -172,15 +148,12 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::sort_descendants -// Access: Published -// Description: Sorts the children nodes at each level of the -// hierarchy into alphabetical order. This should be -// done after creating the hierarchy, to guarantee that -// the correct names will match up together when the -// AnimBundle is later bound to a PlayerRoot. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the children nodes at each level of the hierarchy into alphabetical + * order. This should be done after creating the hierarchy, to guarantee that + * the correct names will match up together when the AnimBundle is later bound + * to a PlayerRoot. + */ void AnimGroup:: sort_descendants() { sort(_children.begin(), _children.end(), AnimGroupAlphabeticalOrder()); @@ -192,35 +165,27 @@ sort_descendants() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::get_value_type -// Access: Public, Virtual -// Description: Returns the TypeHandle associated with the ValueType -// we are concerned with. This is provided to allow a -// bit of run-time checking that joints and channels are -// matching properly in type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the ValueType we are concerned with. + * This is provided to allow a bit of run-time checking that joints and + * channels are matching properly in type. + */ TypeHandle AnimGroup:: get_value_type() const { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::output -// Access: Published, Virtual -// Description: Writes a one-line description of the group. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line description of the group. + */ void AnimGroup:: output(ostream &out) const { out << get_type() << " " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::write -// Access: Published, Virtual -// Description: Writes a brief description of the group and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the group and all of its descendants. + */ void AnimGroup:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this; @@ -232,12 +197,9 @@ write(ostream &out, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::write_descendants -// Access: Protected -// Description: Writes a brief description of all of the group's -// descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of all of the group's descendants. + */ void AnimGroup:: write_descendants(ostream &out, int indent_level) const { Children::const_iterator ci; @@ -247,26 +209,20 @@ write_descendants(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::make_copy -// Access: Protected, Virtual -// Description: Returns a copy of this object, and attaches it to the -// indicated parent (which may be NULL only if this is -// an AnimBundle). Intended to be called by -// copy_subtree() only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a copy of this object, and attaches it to the indicated parent + * (which may be NULL only if this is an AnimBundle). Intended to be called + * by copy_subtree() only. + */ AnimGroup *AnimGroup:: make_copy(AnimGroup *parent) const { return new AnimGroup(parent, *this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::copy_subtree -// Access: Protected -// Description: Returns a full copy of the subtree at this node and -// below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a full copy of the subtree at this node and below. + */ PT(AnimGroup) AnimGroup:: copy_subtree(AnimGroup *parent) const { PT(AnimGroup) new_group = make_copy(parent); @@ -280,16 +236,14 @@ copy_subtree(AnimGroup *parent) const { return new_group; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimGroup:: write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); - //Write out the root + // Write out the root manager->write_pointer(me, this->_root); me.add_uint16(_children.size()); for(int i = 0; i < (int)_children.size(); i++) { @@ -297,14 +251,11 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimGroup:: fillin(DatagramIterator &scan, BamReader *manager) { set_name(scan.get_string()); @@ -316,13 +267,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::complete_pointers -// Access: Public -// Description: Takes in a vector of pointes to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Takes in a vector of pointes to TypedWritable objects that correspond to + * all the requests for pointers that this object made to BamReader. + */ int AnimGroup:: complete_pointers(TypedWritable **p_list, BamReader *) { _root = DCAST(AnimBundle, p_list[0]); @@ -337,11 +285,9 @@ complete_pointers(TypedWritable **p_list, BamReader *) { return _num_children+1; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::make_AnimGroup -// Access: Protected -// Description: Factory method to generate a AnimGroup object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimGroup object + */ TypedWritable* AnimGroup:: make_AnimGroup(const FactoryParams ¶ms) { AnimGroup *me = new AnimGroup; @@ -353,19 +299,10 @@ make_AnimGroup(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimGroup::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a AnimGroup object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a AnimGroup object + */ void AnimGroup:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_AnimGroup); } - - - - - - - diff --git a/panda/src/chan/animGroup.h b/panda/src/chan/animGroup.h index 5b5fc35b4c..8bcb9c41eb 100644 --- a/panda/src/chan/animGroup.h +++ b/panda/src/chan/animGroup.h @@ -1,16 +1,15 @@ -// Filename: animGroup.h -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animGroup.h + * @author drose + * @date 1999-02-21 + */ #ifndef ANIMGROUP_H #define ANIMGROUP_H @@ -26,13 +25,11 @@ class AnimBundle; class BamReader; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AnimGroup -// Description : This is the base class for AnimChannel and -// AnimBundle. It implements a hierarchy of -// AnimChannels. The root of the hierarchy must be an -// AnimBundle. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for AnimChannel and AnimBundle. It implements a + * hierarchy of AnimChannels. The root of the hierarchy must be an + * AnimBundle. + */ class EXPCL_PANDA_CHAN AnimGroup : public TypedWritableReferenceCount, public Namable { protected: AnimGroup(const string &name = ""); @@ -63,7 +60,7 @@ protected: virtual AnimGroup *make_copy(AnimGroup *parent) const; PT(AnimGroup) copy_subtree(AnimGroup *parent) const; - + protected: typedef pvector< PT(AnimGroup) > Children; Children _children; @@ -111,5 +108,3 @@ inline ostream &operator << (ostream &out, const AnimGroup &anim) { #include "animGroup.I" #endif - - diff --git a/panda/src/chan/animPreloadTable.I b/panda/src/chan/animPreloadTable.I index 1907da6637..a2555c5a9d 100644 --- a/panda/src/chan/animPreloadTable.I +++ b/panda/src/chan/animPreloadTable.I @@ -1,43 +1,34 @@ -// Filename: animPreloadTable.I -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animPreloadTable.I + * @author drose + * @date 2008-08-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::AnimRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AnimPreloadTable::AnimRecord:: AnimRecord() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::AnimRecord::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool AnimPreloadTable::AnimRecord:: operator < (const AnimRecord &other) const { return _basename < other._basename; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::get_basename -// Access: Published -// Description: Returns the basename stored for the nth animation -// record. See find_anim(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename stored for the nth animation record. See find_anim(). + */ INLINE string AnimPreloadTable:: get_basename(int n) const { nassertr(n >= 0 && n < (int)_anims.size(), string()); @@ -45,12 +36,9 @@ get_basename(int n) const { return _anims[n]._basename; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::get_base_frame_rate -// Access: Published -// Description: Returns the frame rate stored for the nth animation -// record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame rate stored for the nth animation record. + */ INLINE PN_stdfloat AnimPreloadTable:: get_base_frame_rate(int n) const { nassertr(n >= 0 && n < (int)_anims.size(), 0.0f); @@ -58,12 +46,9 @@ get_base_frame_rate(int n) const { return _anims[n]._base_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::get_num_frames -// Access: Published -// Description: Returns the number of frames stored for the nth -// animation record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames stored for the nth animation record. + */ INLINE int AnimPreloadTable:: get_num_frames(int n) const { nassertr(n >= 0 && n < (int)_anims.size(), 0); @@ -71,12 +56,9 @@ get_num_frames(int n) const { return _anims[n]._num_frames; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::consider_sort -// Access: Private -// Description: Ensures the table is kept in alphabetical order by -// basename. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the table is kept in alphabetical order by basename. + */ INLINE void AnimPreloadTable:: consider_sort() const { if (_needs_sort) { diff --git a/panda/src/chan/animPreloadTable.cxx b/panda/src/chan/animPreloadTable.cxx index ee8a57732e..9303c11490 100644 --- a/panda/src/chan/animPreloadTable.cxx +++ b/panda/src/chan/animPreloadTable.cxx @@ -1,16 +1,15 @@ -// Filename: animPreloadTable.cxx -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animPreloadTable.cxx + * @author drose + * @date 2008-08-05 + */ #include "animPreloadTable.h" @@ -22,55 +21,44 @@ TypeHandle AnimPreloadTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) AnimPreloadTable:: make_cow_copy() { return new AnimPreloadTable(*this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimPreloadTable:: AnimPreloadTable() { _needs_sort = false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimPreloadTable:: ~AnimPreloadTable() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::get_num_anims -// Access: Published -// Description: Returns the number of animation records in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of animation records in the table. + */ int AnimPreloadTable:: get_num_anims() const { return (int)_anims.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::find_anim -// Access: Published -// Description: Returns the index number in the table of the -// animation record with the indicated name, or -1 if -// the name is not present. By convention, the basename -// is the filename of the egg or bam file, without the -// directory part and without the extension. That is, -// it is Filename::get_basename_wo_extension(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number in the table of the animation record with the + * indicated name, or -1 if the name is not present. By convention, the + * basename is the filename of the egg or bam file, without the directory part + * and without the extension. That is, it is + * Filename::get_basename_wo_extension(). + */ int AnimPreloadTable:: find_anim(const string &basename) const { consider_sort(); @@ -83,38 +71,30 @@ find_anim(const string &basename) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::clear_anims -// Access: Published -// Description: Removes all animation records from the table. -//////////////////////////////////////////////////////////////////// +/** + * Removes all animation records from the table. + */ void AnimPreloadTable:: clear_anims() { _anims.clear(); _needs_sort = false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::remove_anim -// Access: Published -// Description: Removes the nth animation records from the table. -// This renumbers indexes for following animations. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth animation records from the table. This renumbers indexes + * for following animations. + */ void AnimPreloadTable:: remove_anim(int n) { nassertv(n >= 0 && n < (int)_anims.size()); _anims.erase(_anims.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::add_anim -// Access: Published -// Description: Adds a new animation record to the table. If there -// is already a record of this name, no operation is -// performed (the original record is unchanged). See -// find_anim(). This will invalidate existing index -// numbers. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new animation record to the table. If there is already a record of + * this name, no operation is performed (the original record is unchanged). + * See find_anim(). This will invalidate existing index numbers. + */ void AnimPreloadTable:: add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames) { AnimRecord record; @@ -126,13 +106,10 @@ add_anim(const string &basename, PN_stdfloat base_frame_rate, int num_frames) { _needs_sort = true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::add_anims_from -// Access: Published -// Description: Copies the animation records from the other table -// into this one. If a given record name exists in both -// tables, the record in this one supercedes. -//////////////////////////////////////////////////////////////////// +/** + * Copies the animation records from the other table into this one. If a + * given record name exists in both tables, the record in this one supercedes. + */ void AnimPreloadTable:: add_anims_from(const AnimPreloadTable *other) { _anims.reserve(_anims.size() + other->_anims.size()); @@ -143,22 +120,18 @@ add_anims_from(const AnimPreloadTable *other) { _needs_sort = true; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimPreloadTable:: output(ostream &out) const { consider_sort(); out << "AnimPreloadTable, " << _anims.size() << " animation records."; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimPreloadTable:: write(ostream &out, int indent_level) const { consider_sort(); @@ -173,22 +146,18 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate an AnimPreloadTable object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimPreloadTable object + */ void AnimPreloadTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void AnimPreloadTable:: write_datagram(BamWriter *manager, Datagram &dg) { consider_sort(); @@ -203,11 +172,9 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::make_from_bam -// Access: Protected -// Description: Factory method to generate an AnimPreloadTable object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an AnimPreloadTable object + */ TypedWritable *AnimPreloadTable:: make_from_bam(const FactoryParams ¶ms) { AnimPreloadTable *me = new AnimPreloadTable; @@ -219,14 +186,11 @@ make_from_bam(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: AnimPreloadTable::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void AnimPreloadTable:: fillin(DatagramIterator &scan, BamReader *manager) { int num_anims = scan.get_uint16(); diff --git a/panda/src/chan/animPreloadTable.h b/panda/src/chan/animPreloadTable.h index 44dda276e1..123cd00eb4 100644 --- a/panda/src/chan/animPreloadTable.h +++ b/panda/src/chan/animPreloadTable.h @@ -1,16 +1,15 @@ -// Filename: animPreloadTable.h -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animPreloadTable.h + * @author drose + * @date 2008-08-05 + */ #ifndef ANIMPRELOADTABLE_H #define ANIMPRELOADTABLE_H @@ -26,16 +25,13 @@ class Datagram; class DatagramIterator; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AnimPreloadTable -// Description : This table records data about a list of animations -// for a particular model, such as number of frames and -// frame rate. It's used for implementating -// asynchronous binding. -// -// This table is normally built by an offline tool, such -// as egg-optchar. -//////////////////////////////////////////////////////////////////// +/** + * This table records data about a list of animations for a particular model, + * such as number of frames and frame rate. It's used for implementating + * asynchronous binding. + * + * This table is normally built by an offline tool, such as egg-optchar. + */ class EXPCL_PANDA_CHAN AnimPreloadTable : public CopyOnWriteObject { public: class AnimRecord { @@ -113,5 +109,3 @@ inline ostream &operator << (ostream &out, const AnimPreloadTable &anim) { #include "animPreloadTable.I" #endif - - diff --git a/panda/src/chan/auto_bind.cxx b/panda/src/chan/auto_bind.cxx index 9dc66c9df7..912b199ac8 100644 --- a/panda/src/chan/auto_bind.cxx +++ b/panda/src/chan/auto_bind.cxx @@ -1,17 +1,15 @@ -// Filename: auto_bind.cxx -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auto_bind.cxx + * @author drose + * @date 1999-02-23 + */ #include "auto_bind.h" #include "animBundleNode.h" @@ -27,13 +25,11 @@ typedef pset PartBundles; typedef pmap Parts; -//////////////////////////////////////////////////////////////////// -// Function: bind_anims -// Description: A support function for auto_bind(), below. Given a -// set of AnimBundles and a set of PartBundles that all -// share the same name, perform whatever bindings make -// sense. -//////////////////////////////////////////////////////////////////// +/** + * A support function for auto_bind(), below. Given a set of AnimBundles and + * a set of PartBundles that all share the same name, perform whatever + * bindings make sense. + */ static void bind_anims(const PartBundles &parts, const AnimBundles &anims, AnimControlCollection &controls, @@ -86,13 +82,11 @@ bind_anims(const PartBundles &parts, const AnimBundles &anims, } } -//////////////////////////////////////////////////////////////////// -// Function: r_find_bundles -// Description: A support function for auto_bind(), below. Walks -// through the hierarchy and finds all of the -// PartBundles and AnimBundles. -//////////////////////////////////////////////////////////////////// -static void +/** + * A support function for auto_bind(), below. Walks through the hierarchy and + * finds all of the PartBundles and AnimBundles. + */ +static void r_find_bundles(PandaNode *node, Anims &anims, Parts &parts) { if (node->is_of_type(AnimBundleNode::get_class_type())) { AnimBundleNode *bn = DCAST(AnimBundleNode, node); @@ -116,25 +110,23 @@ r_find_bundles(PandaNode *node, Anims &anims, Parts &parts) { } -//////////////////////////////////////////////////////////////////// -// Function: auto_bind -// Description: Walks the scene graph or subgraph beginning at the -// indicated node, and attempts to bind any AnimBundles -// found to their matching PartBundles, when possible. -// -// The list of all resulting AnimControls created is -// filled into controls. -//////////////////////////////////////////////////////////////////// +/** + * Walks the scene graph or subgraph beginning at the indicated node, and + * attempts to bind any AnimBundles found to their matching PartBundles, when + * possible. + * + * The list of all resulting AnimControls created is filled into controls. + */ void auto_bind(PandaNode *root_node, AnimControlCollection &controls, int hierarchy_match_flags) { // First, locate all the bundles in the subgraph. - Anims anims; + Anims anims; AnimBundles extra_anims; - Parts parts; + Parts parts; PartBundles extra_parts; r_find_bundles(root_node, anims, parts); - + if (chan_cat.is_debug()) { int anim_count = 0; Anims::const_iterator ai; @@ -205,9 +197,8 @@ auto_bind(PandaNode *root_node, AnimControlCollection &controls, hierarchy_match_flags); ++pi; - // We don't increment the anim counter yet. That way, the same - // anim may bind to multiple parts, if they all share the same - // name. + // We don't increment the anim counter yet. That way, the same anim may + // bind to multiple parts, if they all share the same name. } } @@ -224,7 +215,7 @@ auto_bind(PandaNode *root_node, AnimControlCollection &controls, } ++ai; } - + while (pi != parts.end()) { // And here's a part with no matching anims. if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) { @@ -235,10 +226,8 @@ auto_bind(PandaNode *root_node, AnimControlCollection &controls, } ++pi; } - + bind_anims(extra_parts, extra_anims, controls, hierarchy_match_flags); } } - - diff --git a/panda/src/chan/auto_bind.h b/panda/src/chan/auto_bind.h index b433572338..c5136e23df 100644 --- a/panda/src/chan/auto_bind.h +++ b/panda/src/chan/auto_bind.h @@ -1,16 +1,15 @@ -// Filename: auto_bind.h -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auto_bind.h + * @author drose + * @date 1999-02-23 + */ #ifndef AUTO_BIND_H #define AUTO_BIND_H @@ -23,19 +22,16 @@ class PandaNode; BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: auto_bind -// Description: Walks the scene graph or subgraph beginning at the -// indicated node, and attempts to bind any AnimBundles -// found to their matching PartBundles, when possible. -// -// The list of all resulting AnimControls created is -// filled into controls. -//////////////////////////////////////////////////////////////////// +/** + * Walks the scene graph or subgraph beginning at the indicated node, and + * attempts to bind any AnimBundles found to their matching PartBundles, when + * possible. + * + * The list of all resulting AnimControls created is filled into controls. + */ EXPCL_PANDA_CHAN void auto_bind(PandaNode *root_node, AnimControlCollection &controls, int hierarchy_match_flags = 0); END_PUBLISH #endif - diff --git a/panda/src/chan/bindAnimRequest.I b/panda/src/chan/bindAnimRequest.I index d90807ee43..ac9bc72bce 100644 --- a/panda/src/chan/bindAnimRequest.I +++ b/panda/src/chan/bindAnimRequest.I @@ -1,14 +1,12 @@ -// Filename: bindAnimRequest.I -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bindAnimRequest.I + * @author drose + * @date 2008-08-05 + */ diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index 7070ea29d0..b1315044b9 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -1,16 +1,15 @@ -// Filename: bindAnimRequest.cxx -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bindAnimRequest.cxx + * @author drose + * @date 2008-08-05 + */ #include "bindAnimRequest.h" #include "animBundleNode.h" @@ -19,11 +18,9 @@ TypeHandle BindAnimRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BindAnimRequest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BindAnimRequest:: BindAnimRequest(const string &name, const Filename &filename, const LoaderOptions &options, @@ -37,12 +34,9 @@ BindAnimRequest(const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: BindAnimRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, loads and binds the -// animation. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, loads and binds the animation. + */ AsyncTask::DoneStatus BindAnimRequest:: do_task() { ModelLoadRequest::do_task(); diff --git a/panda/src/chan/bindAnimRequest.h b/panda/src/chan/bindAnimRequest.h index 9398b6bb86..afb57d46cd 100644 --- a/panda/src/chan/bindAnimRequest.h +++ b/panda/src/chan/bindAnimRequest.h @@ -1,16 +1,15 @@ -// Filename: bindAnimRequest.h -// Created by: drose (05Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bindAnimRequest.h + * @author drose + * @date 2008-08-05 + */ #ifndef BINDANIMREQUEST #define BINDANIMREQUEST @@ -22,33 +21,31 @@ class AnimControl; -//////////////////////////////////////////////////////////////////// -// Class : BindAnimRequest -// Description : This class object manages an asynchronous -// load-and-bind animation request, as issued through -// PartBundle::load_bind_anim(). -//////////////////////////////////////////////////////////////////// +/** + * This class object manages an asynchronous load-and-bind animation request, + * as issued through PartBundle::load_bind_anim(). + */ class EXPCL_PANDA_PGRAPH BindAnimRequest : public ModelLoadRequest { public: ALLOC_DELETED_CHAIN(BindAnimRequest); PUBLISHED: BindAnimRequest(const string &name, - const Filename &filename, + const Filename &filename, const LoaderOptions &options, Loader *loader, AnimControl *control, int hierarchy_match_flags, const PartSubset &subset); - + protected: virtual DoneStatus do_task(); - + private: PT(AnimControl) _control; int _hierarchy_match_flags; PartSubset _subset; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -62,7 +59,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 8d35a75f49..ab9b343d23 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -1,17 +1,15 @@ -// Filename: config_chan.cxx -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_chan.cxx + * @author drose + * @date 2000-02-28 + */ #include "config_chan.h" #include "animBundle.h" @@ -46,24 +44,19 @@ ConfigVariableBool compress_channels "the bam file only; it does not reduce the memory footprint of the " "channels when the bam file is loaded.")); -// There are some special values above 100 which are generally only -// useful for debugging (specifically, to research at what point a -// particular animation artifact is being introduced): -// -// 101 Output numerically lossless data. The output is not run -// through the FFTCompressor. This can be used to check -// whether a particular artifact is due to the FFT conversion -// or not. However, joint angles (HPR) are still converted to -// quaternions and normalized, discarding the fourth -// (redundant) component. -// -// 102 As above, but the fourth quaternion component is preserved. -// -// 103 Quaternions are not used; instead, the HPR values are written -// directly. All output is now completely lossless; if some -// artifacts are being introduced at this point, check your -// sanity. -// +/* + * There are some special values above 100 which are generally only useful for + * debugging (specifically, to research at what point a particular animation + * artifact is being introduced): 101 Output numerically lossless data. The + * output is not run through the FFTCompressor. This can be used to check + * whether a particular artifact is due to the FFT conversion or not. + * However, joint angles (HPR) are still converted to quaternions and + * normalized, discarding the fourth (redundant) component. 102 As above, + * but the fourth quaternion component is preserved. 103 Quaternions are not + * used; instead, the HPR values are written directly. All output is now + * completely lossless; if some artifacts are being introduced at this point, + * check your sanity. + */ ConfigVariableInt compress_chan_quality ("compress-chan-quality", 95, PRC_DESC("The quality level is an integer number that generally ranges " @@ -124,14 +117,13 @@ ConfigureFn(config_chan) { PartBundleNode::init_type(); PartGroup::init_type(); - // This isn't defined in this package, but it *is* essential that it - // be initialized. We have to do it explicitly here since template - // statics don't necessarily resolve very well across dynamic - // libraries. + // This isn't defined in this package, but it *is* essential that it be + // initialized. We have to do it explicitly here since template statics + // don't necessarily resolve very well across dynamic libraries. LMatrix4::init_type(); - //Registration of writeable object's creation - //functions with BamReader's factory + // Registration of writeable object's creation functions with BamReader's + // factory PartGroup::register_with_read_factory(); PartBundle::register_with_read_factory(); MovingPartMatrix::register_with_read_factory(); @@ -147,7 +139,3 @@ ConfigureFn(config_chan) { AnimChannelScalarDynamic::register_with_read_factory(); AnimPreloadTable::register_with_read_factory(); } - - - - diff --git a/panda/src/chan/config_chan.h b/panda/src/chan/config_chan.h index cf1d2176bb..7aedea93d3 100644 --- a/panda/src/chan/config_chan.h +++ b/panda/src/chan/config_chan.h @@ -1,16 +1,15 @@ -// Filename: config_chan.h -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_chan.h + * @author drose + * @date 2000-02-28 + */ #ifndef CONFIG_CHAN_H #define CONFIG_CHAN_H diff --git a/panda/src/chan/movingPart.I b/panda/src/chan/movingPart.I index 631b5ce27e..8b988d9422 100644 --- a/panda/src/chan/movingPart.I +++ b/panda/src/chan/movingPart.I @@ -1,16 +1,15 @@ -// Filename: movingPart.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPart.I + * @author drose + * @date 1999-02-22 + */ #include "animChannelFixed.h" #include "datagram.h" @@ -21,18 +20,15 @@ template TypeHandle MovingPart::_type_handle; -// We don't need to explicitly call MovingPart::init_type(), because -// it is an abstract class and therefore must have derived objects. -// Its derived objects will call init_type() for us. +// We don't need to explicitly call MovingPart::init_type(), because it is an +// abstract class and therefore must have derived objects. Its derived +// objects will call init_type() for us. -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::Copy Constructor -// Access: Protected -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ template INLINE MovingPart:: MovingPart(const MovingPart ©) : @@ -42,11 +38,9 @@ MovingPart(const MovingPart ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE MovingPart:: MovingPart(PartGroup *parent, const string &name, @@ -57,24 +51,19 @@ MovingPart(PartGroup *parent, const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE MovingPart:: MovingPart() { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::get_value_type -// Access: Public, Virtual -// Description: Returns the TypeHandle associated with the ValueType -// we are concerned with. This is provided to allow a -// bit of run-time checking that joints and channels are -// matching properly in type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the ValueType we are concerned with. + * This is provided to allow a bit of run-time checking that joints and + * channels are matching properly in type. + */ template TypeHandle MovingPart:: get_value_type() const { @@ -83,37 +72,29 @@ get_value_type() const { -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::make_default_channel -// Access: Public, Virtual -// Description: Creates and returns a new AnimChannel that is not -// part of any hierarchy, but that returns the default -// value associated with this part. -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new AnimChannel that is not part of any hierarchy, + * but that returns the default value associated with this part. + */ template AnimChannelBase *MovingPart:: make_default_channel() const { return new AnimChannelFixed(get_name(), _default_value); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::output_value -// Access: Public, Virtual -// Description: Outputs a very brief description of the channel's -// current value. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a very brief description of the channel's current value. + */ template void MovingPart:: output_value(ostream &out) const { SwitchType::output_value(out, _value); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ template void MovingPart:: write_datagram(BamWriter *manager, Datagram &me) { @@ -122,14 +103,11 @@ write_datagram(BamWriter *manager, Datagram &me) { SwitchType::write_datagram(me, _default_value); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPart::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ template void MovingPart:: fillin(DatagramIterator &scan, BamReader *manager) { @@ -137,6 +115,3 @@ fillin(DatagramIterator &scan, BamReader *manager) { SwitchType::read_datagram(scan, _value); SwitchType::read_datagram(scan, _default_value); } - - - diff --git a/panda/src/chan/movingPart.h b/panda/src/chan/movingPart.h index 4900c3496c..7b3640b981 100644 --- a/panda/src/chan/movingPart.h +++ b/panda/src/chan/movingPart.h @@ -1,16 +1,15 @@ -// Filename: movingPart.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPart.h + * @author drose + * @date 1999-02-22 + */ #ifndef MOVINGPART_H #define MOVINGPART_H @@ -20,12 +19,10 @@ #include "movingPartBase.h" #include "animChannel.h" -//////////////////////////////////////////////////////////////////// -// Class : MovingPart -// Description : This is the template instantiation of MovingPartBase, -// on the particular type of value provided by the -// channel. -//////////////////////////////////////////////////////////////////// +/** + * This is the template instantiation of MovingPartBase, on the particular + * type of value provided by the channel. + */ template class MovingPart : public MovingPartBase { public: @@ -82,6 +79,3 @@ private: #include "movingPart.I" #endif - - - diff --git a/panda/src/chan/movingPartBase.I b/panda/src/chan/movingPartBase.I index 4ef99ae1dc..2c18cb7584 100644 --- a/panda/src/chan/movingPartBase.I +++ b/panda/src/chan/movingPartBase.I @@ -1,24 +1,19 @@ -// Filename: movingPartBase.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartBase.I + * @author drose + * @date 1999-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::Copy Constructor -// Access: Protected -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ INLINE MovingPartBase:: MovingPartBase(const MovingPartBase ©) : PartGroup(copy), @@ -26,38 +21,30 @@ MovingPartBase(const MovingPartBase ©) : _effective_control(NULL), _forced_channel(copy._forced_channel) { - // We don't copy the bound channels. We do copy the forced_channel, - // though this is just a pointerwise copy. + // We don't copy the bound channels. We do copy the forced_channel, though + // this is just a pointerwise copy. } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::get_max_bound -// Access: Published -// Description: Returns the number of channels that might be bound to -// this PartGroup. This might not be the actual number -// of channels, since there might be holes in the list; -// it is one more than the index number of the highest -// bound channel. Thus, it is called get_max_bound() -// instead of get_num_bound(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of channels that might be bound to this PartGroup. This + * might not be the actual number of channels, since there might be holes in + * the list; it is one more than the index number of the highest bound + * channel. Thus, it is called get_max_bound() instead of get_num_bound(). + */ INLINE int MovingPartBase:: get_max_bound() const { return _channels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::get_bound -// Access: Published -// Description: Returns the nth bound channel on this PartGroup. n -// can be determined by iterating from 0 to one less -// than get_max_bound(); or n might be -// AnimControl::get_channel_index(). -// -// This will return NULL if there is no channel bound on -// the indicated index. It is an error to call this if -// n is less than zero or greater than or equal to -// get_max_bound(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth bound channel on this PartGroup. n can be determined by + * iterating from 0 to one less than get_max_bound(); or n might be + * AnimControl::get_channel_index(). + * + * This will return NULL if there is no channel bound on the indicated index. + * It is an error to call this if n is less than zero or greater than or equal + * to get_max_bound(). + */ INLINE AnimChannelBase *MovingPartBase:: get_bound(int n) const { nassertr(n >= 0 && n < (int)_channels.size(), NULL); diff --git a/panda/src/chan/movingPartBase.cxx b/panda/src/chan/movingPartBase.cxx index 3912deff76..b623e7f689 100644 --- a/panda/src/chan/movingPartBase.cxx +++ b/panda/src/chan/movingPartBase.cxx @@ -1,16 +1,15 @@ -// Filename: movingPartBase.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartBase.cxx + * @author drose + * @date 1999-02-22 + */ #include "movingPartBase.h" #include "animControl.h" @@ -23,11 +22,9 @@ TypeHandle MovingPartBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovingPartBase:: MovingPartBase(PartGroup *parent, const string &name) : PartGroup(parent, name), @@ -36,11 +33,9 @@ MovingPartBase(PartGroup *parent, const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovingPartBase:: MovingPartBase() : _num_effective_channels(0), @@ -48,13 +43,10 @@ MovingPartBase() : { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::clear_forced_channel -// Access: Published, Virtual -// Description: Undoes the effect of a previous call to -// apply_freeze() or apply_control(). Returns true if -// the joint was modified, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to apply_freeze() or apply_control(). + * Returns true if the joint was modified, false otherwise. + */ bool MovingPartBase:: clear_forced_channel() { if (_forced_channel != (AnimChannelBase *)NULL) { @@ -64,25 +56,19 @@ clear_forced_channel() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::get_forced_channel -// Access: Published, Virtual -// Description: Returns the AnimChannelBase that has been forced to -// this joint by a previous call to apply_freeze() or -// apply_control(), or NULL if no such channel has been -// applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimChannelBase that has been forced to this joint by a + * previous call to apply_freeze() or apply_control(), or NULL if no such + * channel has been applied. + */ AnimChannelBase *MovingPartBase:: get_forced_channel() const { return _forced_channel; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::write -// Access: Published, Virtual -// Description: Writes a brief description of the channel and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the channel and all of its descendants. + */ void MovingPartBase:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name(); @@ -95,12 +81,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::write_with_value -// Access: Published, Virtual -// Description: Writes a brief description of the channel and all of -// its descendants, along with their values. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the channel and all of its descendants, along + * with their values. + */ void MovingPartBase:: write_with_value(ostream &out, int indent_level) const { indent(out, indent_level) << get_value_type() << " " << get_name() << "\n"; @@ -116,18 +100,13 @@ write_with_value(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::do_update -// Access: Public, Virtual -// Description: Recursively update this particular part and all of -// its descendents for the current frame. This is not -// really public and is not intended to be called -// directly; it is called from the top of the tree by -// PartBundle::update(). -// -// The return value is true if any part has changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Recursively update this particular part and all of its descendents for the + * current frame. This is not really public and is not intended to be called + * directly; it is called from the top of the tree by PartBundle::update(). + * + * The return value is true if any part has changed, false otherwise. + */ bool MovingPartBase:: do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, bool parent_changed, bool anim_changed, @@ -140,11 +119,11 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, if (!needs_update) { if (_forced_channel != (AnimChannelBase *)NULL) { needs_update = _forced_channel->has_changed(0, 0.0, 0, 0.0); - + } else if (_effective_control != (AnimControl *)NULL) { const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; needs_update = _effective_control->channel_has_changed(_effective_channel, cdata->_frame_blend_flag); - + } else { const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; PartBundle::ChannelBlend::const_iterator bci; @@ -152,7 +131,7 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, !needs_update && bci != cdata->_blend.end(); ++bci) { AnimControl *control = (*bci).first; - + AnimChannelBase *channel = NULL; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { @@ -178,7 +157,7 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, // Now recurse. Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { - if ((*ci)->do_update(root, root_cdata, this, + if ((*ci)->do_update(root, root_cdata, this, parent_changed || needs_update, anim_changed, current_thread)) { any_changed = true; @@ -189,30 +168,24 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *parent, } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::update_internals -// Access: Public, Virtual -// Description: This is called by do_update() whenever the part or -// some ancestor has changed values. It is a hook for -// derived classes to update whatever cache they may -// have that depends on these. -// -// The return value is true if the part has changed as a -// result of the update, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This is called by do_update() whenever the part or some ancestor has + * changed values. It is a hook for derived classes to update whatever cache + * they may have that depends on these. + * + * The return value is true if the part has changed as a result of the update, + * or false otherwise. + */ bool MovingPartBase:: update_internals(PartBundle *, PartGroup *, bool, bool, Thread *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::pick_channel_index -// Access: Protected -// Description: Walks the part hierarchy, looking for a suitable -// channel index number to use. Available index numbers -// are the elements of the holes set, as well as next to -// infinity. -//////////////////////////////////////////////////////////////////// +/** + * Walks the part hierarchy, looking for a suitable channel index number to + * use. Available index numbers are the elements of the holes set, as well as + * next to infinity. + */ void MovingPartBase:: pick_channel_index(plist &holes, int &next) const { // Verify each of the holes. @@ -250,14 +223,12 @@ pick_channel_index(plist &holes, int &next) const { -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::bind_hierarchy -// Access: Protected, Virtual -// Description: Binds the indicated anim hierarchy to the part -// hierarchy, at the given channel index number. -//////////////////////////////////////////////////////////////////// +/** + * Binds the indicated anim hierarchy to the part hierarchy, at the given + * channel index number. + */ void MovingPartBase:: -bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, +bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) { if (subset.matches_include(get_name())) { @@ -285,16 +256,14 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, if (is_included) { if (anim == (AnimGroup*)NULL) { - // If we're binding to the NULL anim, it means actually to create - // a default AnimChannel that just returns the part's initial - // value. + // If we're binding to the NULL anim, it means actually to create a + // default AnimChannel that just returns the part's initial value. _channels[channel_index] = make_default_channel(); } else { _channels[channel_index] = DCAST(AnimChannelBase, anim); } - // Record that we have bound this joint in the bound_joints - // BitArray. + // Record that we have bound this joint in the bound_joints BitArray. bound_joints.set_bit(joint_index); } else { // Record that we have *not* bound this particular joint. @@ -302,21 +271,17 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } ++joint_index; - PartGroup::bind_hierarchy(anim, channel_index, joint_index, + PartGroup::bind_hierarchy(anim, channel_index, joint_index, is_included, bound_joints, subset); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::find_bound_joints -// Access: Protected, Virtual -// Description: Similar to bind_hierarchy, but does not actually -// perform any binding. All it does is compute the -// BitArray bount_joints according to the specified -// subset. This is useful in preparation for -// asynchronous binding--in this case, we may need to -// know bound_joints immediately, without having to wait -// for the animation itself to load and bind. -//////////////////////////////////////////////////////////////////// +/** + * Similar to bind_hierarchy, but does not actually perform any binding. All + * it does is compute the BitArray bount_joints according to the specified + * subset. This is useful in preparation for asynchronous binding--in this + * case, we may need to know bound_joints immediately, without having to wait + * for the animation itself to load and bind. + */ void MovingPartBase:: find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) { @@ -332,13 +297,10 @@ find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, PartGroup::find_bound_joints(joint_index, is_included, bound_joints, subset); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::determine_effective_channels -// Access: Protected, Virtual -// Description: Should be called whenever the ChannelBlend values -// have changed, this recursively updates the -// _effective_channel member in each part. -//////////////////////////////////////////////////////////////////// +/** + * Should be called whenever the ChannelBlend values have changed, this + * recursively updates the _effective_channel member in each part. + */ void MovingPartBase:: determine_effective_channels(const CycleData *root_cdata) { _effective_control = NULL; @@ -351,8 +313,8 @@ determine_effective_channels(const CycleData *root_cdata) { const PartBundle::CData *cdata = (const PartBundle::CData *)root_cdata; PartBundle::ChannelBlend::const_iterator cbi; - for (cbi = cdata->_blend.begin(); - cbi != cdata->_blend.end(); + for (cbi = cdata->_blend.begin(); + cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; int channel_index = control->get_channel_index(); @@ -374,12 +336,10 @@ determine_effective_channels(const CycleData *root_cdata) { PartGroup::determine_effective_channels(root_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void MovingPartBase:: write_datagram(BamWriter *manager, Datagram &dg) { PartGroup::write_datagram(manager, dg); @@ -387,28 +347,21 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _forced_channel); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -// -// This is the callback function that is made by the -// BamReader at some later point, after all of the -// required pointers have been filled in. It is -// necessary because there might be forward references -// in a bam file; when we call read_pointer() in -// fillin(), the object may not have been read from the -// file yet, so we do not have a pointer available at -// that time. Thus, instead of returning a pointer, -// read_pointer() simply reserves a later callback. -// This function provides that callback. The calling -// object is responsible for keeping track of the number -// of times it called read_pointer() and extracting the -// same number of pointers out of the supplied vector, -// and storing them appropriately within the object. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + * + * This is the callback function that is made by the BamReader at some later + * point, after all of the required pointers have been filled in. It is + * necessary because there might be forward references in a bam file; when we + * call read_pointer() in fillin(), the object may not have been read from the + * file yet, so we do not have a pointer available at that time. Thus, + * instead of returning a pointer, read_pointer() simply reserves a later + * callback. This function provides that callback. The calling object is + * responsible for keeping track of the number of times it called + * read_pointer() and extracting the same number of pointers out of the + * supplied vector, and storing them appropriately within the object. + */ int MovingPartBase:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PartGroup::complete_pointers(p_list, manager); @@ -420,13 +373,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartBase::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MovingPartBase. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MovingPartBase. + */ void MovingPartBase:: fillin(DatagramIterator &scan, BamReader *manager) { PartGroup::fillin(scan, manager); diff --git a/panda/src/chan/movingPartBase.h b/panda/src/chan/movingPartBase.h index 12b5624d23..3618cbfd19 100644 --- a/panda/src/chan/movingPartBase.h +++ b/panda/src/chan/movingPartBase.h @@ -1,16 +1,15 @@ -// Filename: movingPartBase.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartBase.h + * @author drose + * @date 1999-02-22 + */ #ifndef MOVINGPARTBASE_H #define MOVINGPARTBASE_H @@ -21,16 +20,14 @@ #include "partBundle.h" #include "animChannelBase.h" -//////////////////////////////////////////////////////////////////// -// Class : MovingPartBase -// Description : This is the base class for a single animatable piece -// that may be bound to one channel (or more, if -// blending is in effect). It corresponds to, for -// instance, a single joint or slider of a character. -// -// MovingPartBase does not have a particular value type. -// See the derived template class, MovingPart, for this. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a single animatable piece that may be bound to + * one channel (or more, if blending is in effect). It corresponds to, for + * instance, a single joint or slider of a character. + * + * MovingPartBase does not have a particular value type. See the derived + * template class, MovingPart, for this. + */ class EXPCL_PANDA_CHAN MovingPartBase : public PartGroup { protected: INLINE MovingPartBase(const MovingPartBase ©); @@ -56,12 +53,12 @@ PUBLISHED: public: virtual bool do_update(PartBundle *root, const CycleData *root_cdata, - PartGroup *parent, bool parent_changed, + PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread); virtual void get_blend_value(const PartBundle *root)=0; - virtual bool update_internals(PartBundle *root, PartGroup *parent, - bool self_changed, bool parent_changed, + virtual bool update_internals(PartBundle *root, PartGroup *parent, + bool self_changed, bool parent_changed, Thread *current_thread); protected: @@ -69,10 +66,10 @@ protected: virtual void pick_channel_index(plist &holes, int &next) const; virtual void bind_hierarchy(AnimGroup *anim, int channel_index, - int &joint_index, bool is_included, + int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset); - virtual void find_bound_joints(int &joint_index, bool is_included, + virtual void find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset); virtual void determine_effective_channels(const CycleData *root_cdata); @@ -85,16 +82,15 @@ protected: // actually have an effect on this part. int _num_effective_channels; - // This is the single channel that has an effect on this part, as - // determined by determine_effective_channels(). It is only set if - // there is exactly one channel that affects this part - // (i.e. _num_effective_channels is 1). If there are multiple - // channels, or no channels at all, it is NULL. + // This is the single channel that has an effect on this part, as determined + // by determine_effective_channels(). It is only set if there is exactly + // one channel that affects this part (i.e. _num_effective_channels is 1). + // If there are multiple channels, or no channels at all, it is NULL. AnimControl *_effective_control; PT(AnimChannelBase) _effective_channel; - // This is the particular channel that's been forced to this part, - // via set_forced_channel(). It overrides all of the above if set. + // This is the particular channel that's been forced to this part, via + // set_forced_channel(). It overrides all of the above if set. PT(AnimChannelBase) _forced_channel; public: @@ -127,7 +123,3 @@ private: #include "movingPartBase.I" #endif - - - - diff --git a/panda/src/chan/movingPartMatrix.I b/panda/src/chan/movingPartMatrix.I index af12e643dc..a545f9f9fa 100644 --- a/panda/src/chan/movingPartMatrix.I +++ b/panda/src/chan/movingPartMatrix.I @@ -1,46 +1,37 @@ -// Filename: movingPartMatrix.I -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartMatrix.I + * @author drose + * @date 1999-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::Copy Constructor -// Access: Protected -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ INLINE MovingPartMatrix:: MovingPartMatrix(const MovingPartMatrix ©) : MovingPart(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MovingPartMatrix:: MovingPartMatrix(PartGroup *parent, const string &name, const LMatrix4 &default_value) : MovingPart(parent, name, default_value) { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MovingPartMatrix:: MovingPartMatrix() { } diff --git a/panda/src/chan/movingPartMatrix.cxx b/panda/src/chan/movingPartMatrix.cxx index fc20b896c9..29ed1f79be 100644 --- a/panda/src/chan/movingPartMatrix.cxx +++ b/panda/src/chan/movingPartMatrix.cxx @@ -1,17 +1,15 @@ -// Filename: movingPartMatrix.cxx -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartMatrix.cxx + * @author drose + * @date 1999-02-23 + */ #include "movingPartMatrix.h" #include "animChannelMatrixDynamic.h" @@ -32,23 +30,18 @@ template class MovingPart; TypeHandle MovingPartMatrix::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovingPartMatrix:: ~MovingPartMatrix() { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::make_default_channel -// Access: Public, Virtual -// Description: Creates and returns a new AnimChannel that is not -// part of any hierarchy, but that returns the default -// value associated with this part. -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new AnimChannel that is not part of any hierarchy, + * but that returns the default value associated with this part. + */ AnimChannelBase *MovingPartMatrix:: make_default_channel() const { LVecBase3 pos, hpr, scale, shear; @@ -56,18 +49,15 @@ make_default_channel() const { return new AnimChannelMatrixFixed(get_name(), pos, hpr, scale); } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::get_blend_value -// Access: Public -// Description: Attempts to blend the various matrix values -// indicated, and sets the _value member to the -// resulting matrix. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to blend the various matrix values indicated, and sets the _value + * member to the resulting matrix. + */ void MovingPartMatrix:: get_blend_value(const PartBundle *root) { - // If a forced channel is set on this particular joint, we always - // return that value instead of performing the blend. Furthermore, - // the frame number is always 0 for the forced channel. + // If a forced channel is set on this particular joint, we always return + // that value instead of performing the blend. Furthermore, the frame + // number is always 0 for the forced channel. if (_forced_channel != (AnimChannelBase *)NULL) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); @@ -82,29 +72,29 @@ get_blend_value(const PartBundle *root) { _value = _default_value; } - } else if (_effective_control != (AnimControl *)NULL && + } else if (_effective_control != (AnimControl *)NULL && !cdata->_frame_blend_flag) { // A single value, the normal case. ChannelType *channel = DCAST(ChannelType, _effective_channel); channel->get_value(_effective_control->get_frame(), _value); } else { - // A blend of two or more values, either between multiple - // different animations, or between consecutive frames of the same - // animation (or both). + // A blend of two or more values, either between multiple different + // animations, or between consecutive frames of the same animation (or + // both). switch (cdata->_blend_type) { case PartBundle::BT_linear: { // An ordinary, linear blend. LMatrix4 net_value = LMatrix4::zeros_mat(); PN_stdfloat net_effect = 0.0f; - + PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - + int channel_index = control->get_channel_index(); nassertv(channel_index >= 0 && channel_index < (int)_channels.size()); ChannelType *channel = DCAST(ChannelType, _channels[channel_index]); @@ -126,7 +116,7 @@ get_blend_value(const PartBundle *root) { net_effect += effect; } } - + if (net_effect == 0.0f) { if (restore_initial_pose) { _value = _default_value; @@ -139,23 +129,22 @@ get_blend_value(const PartBundle *root) { case PartBundle::BT_normalized_linear: { - // A normalized linear blend. This means we do a linear blend - // without scales or shears, normalize the scale and shear - // components of the resulting matrix to eliminate - // artificially-introduced scales, and then reapply the - // scales and shears. - + // A normalized linear blend. This means we do a linear blend without + // scales or shears, normalize the scale and shear components of the + // resulting matrix to eliminate artificially-introduced scales, and + // then reapply the scales and shears. + LMatrix4 net_value = LMatrix4::zeros_mat(); LVecBase3 scale(0.0f, 0.0f, 0.0f); LVecBase3 shear(0.0f, 0.0f, 0.0f); PN_stdfloat net_effect = 0.0f; - + PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - + ChannelType *channel = NULL; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { @@ -168,7 +157,7 @@ get_blend_value(const PartBundle *root) { channel->get_value_no_scale_shear(frame, v); channel->get_scale(frame, iscale); channel->get_shear(frame, ishear); - + if (!cdata->_frame_blend_flag) { // Hold the current frame until the next one is ready. net_value += v * effect; @@ -194,7 +183,7 @@ get_blend_value(const PartBundle *root) { net_effect += effect; } } - + if (net_effect == 0.0f) { if (restore_initial_pose) { _value = _default_value; @@ -204,9 +193,9 @@ get_blend_value(const PartBundle *root) { net_value /= net_effect; scale /= net_effect; shear /= net_effect; - + // Now rebuild the matrix with the correct scale values. - + LVector3 false_scale, false_shear, hpr, translate; decompose_matrix(net_value, false_scale, false_shear, hpr, translate); compose_matrix(_value, scale, shear, hpr, translate); @@ -222,13 +211,13 @@ get_blend_value(const PartBundle *root) { LVecBase3 pos(0.0f, 0.0f, 0.0f); LVecBase3 shear(0.0f, 0.0f, 0.0f); PN_stdfloat net_effect = 0.0f; - + PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - + ChannelType *channel = NULL; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { @@ -241,7 +230,7 @@ get_blend_value(const PartBundle *root) { channel->get_hpr(frame, ihpr); channel->get_pos(frame, ipos); channel->get_shear(frame, ishear); - + if (!cdata->_frame_blend_flag) { // Hold the current frame until the next one is ready. scale += iscale * effect; @@ -273,7 +262,7 @@ get_blend_value(const PartBundle *root) { net_effect += effect; } } - + if (net_effect == 0.0f) { if (restore_initial_pose) { _value = _default_value; @@ -284,7 +273,7 @@ get_blend_value(const PartBundle *root) { hpr /= net_effect; pos /= net_effect; shear /= net_effect; - + compose_matrix(_value, scale, shear, hpr, pos); } } @@ -292,20 +281,19 @@ get_blend_value(const PartBundle *root) { case PartBundle::BT_componentwise_quat: { - // Componentwise linear, except for rotation, which is a - // quaternion. + // Componentwise linear, except for rotation, which is a quaternion. LVecBase3 scale(0.0f, 0.0f, 0.0f); LQuaternion quat(0.0f, 0.0f, 0.0f, 0.0f); LVecBase3 pos(0.0f, 0.0f, 0.0f); LVecBase3 shear(0.0f, 0.0f, 0.0f); PN_stdfloat net_effect = 0.0f; - + PartBundle::ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; PN_stdfloat effect = (*cbi).second; nassertv(effect != 0.0f); - + ChannelType *channel = NULL; int channel_index = control->get_channel_index(); if (channel_index >= 0 && channel_index < (int)_channels.size()) { @@ -319,7 +307,7 @@ get_blend_value(const PartBundle *root) { channel->get_quat(frame, iquat); channel->get_pos(frame, ipos); channel->get_shear(frame, ishear); - + if (!cdata->_frame_blend_flag) { // Hold the current frame until the next one is ready. scale += iscale * effect; @@ -352,7 +340,7 @@ get_blend_value(const PartBundle *root) { net_effect += effect; } } - + if (net_effect == 0.0f) { if (restore_initial_pose) { _value = _default_value; @@ -363,11 +351,10 @@ get_blend_value(const PartBundle *root) { quat /= net_effect; pos /= net_effect; shear /= net_effect; - - // There should be no need to normalize the quaternion, - // assuming all of the input quaternions were already - // normalized. - + + // There should be no need to normalize the quaternion, assuming all + // of the input quaternions were already normalized. + _value = LMatrix4::scale_shear_mat(scale, shear) * quat; _value.set_row(3, pos); } @@ -377,30 +364,23 @@ get_blend_value(const PartBundle *root) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::apply_freeze_matrix -// Access: Public, Virtual -// Description: Freezes this particular joint so that it will always -// hold the specified transform. Returns true if this -// is a joint that can be so frozen, false otherwise. -// This is called internally by -// PartBundle::freeze_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Freezes this particular joint so that it will always hold the specified + * transform. Returns true if this is a joint that can be so frozen, false + * otherwise. This is called internally by PartBundle::freeze_joint(). + */ bool MovingPartMatrix:: apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { _forced_channel = new AnimChannelMatrixFixed(get_name(), pos, hpr, scale); return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::apply_control -// Access: Public, Virtual -// Description: Specifies a node to influence this particular joint -// so that it will always hold the node's transform. -// Returns true if this is a joint that can be so -// controlled, false otherwise. This is called -// internally by PartBundle::control_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies a node to influence this particular joint so that it will always + * hold the node's transform. Returns true if this is a joint that can be so + * controlled, false otherwise. This is called internally by + * PartBundle::control_joint(). + */ bool MovingPartMatrix:: apply_control(PandaNode *node) { AnimChannelMatrixDynamic *chan = new AnimChannelMatrixDynamic(get_name()); @@ -409,11 +389,9 @@ apply_control(PandaNode *node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::make_MovingPartMatrix -// Access: Protected -// Description: Factory method to generate a MovingPartMatrix object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a MovingPartMatrix object + */ TypedWritable* MovingPartMatrix:: make_MovingPartMatrix(const FactoryParams ¶ms) { MovingPartMatrix *me = new MovingPartMatrix; @@ -425,11 +403,9 @@ make_MovingPartMatrix(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartMatrix::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a MovingPartMatrix object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a MovingPartMatrix object + */ void MovingPartMatrix:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_MovingPartMatrix); diff --git a/panda/src/chan/movingPartMatrix.h b/panda/src/chan/movingPartMatrix.h index 3c32aadd33..78352423fc 100644 --- a/panda/src/chan/movingPartMatrix.h +++ b/panda/src/chan/movingPartMatrix.h @@ -1,16 +1,15 @@ -// Filename: movingPartMatrix.h -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartMatrix.h + * @author drose + * @date 1999-02-23 + */ #ifndef MOVINGPARTMATRIX_H #define MOVINGPARTMATRIX_H @@ -24,11 +23,9 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_CHAN, EXPTP_PANDA_CHAN, MovingPart); -//////////////////////////////////////////////////////////////////// -// Class : MovingPartMatrix -// Description : This is a particular kind of MovingPart that accepts -// a matrix each frame. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of MovingPart that accepts a matrix each frame. + */ class EXPCL_PANDA_CHAN MovingPartMatrix : public MovingPart { protected: INLINE MovingPartMatrix(const MovingPartMatrix ©); @@ -81,6 +78,3 @@ private: #endif #endif - - - diff --git a/panda/src/chan/movingPartScalar.I b/panda/src/chan/movingPartScalar.I index 51d28abb35..e49a542575 100644 --- a/panda/src/chan/movingPartScalar.I +++ b/panda/src/chan/movingPartScalar.I @@ -1,46 +1,37 @@ -// Filename: movingPartScalar.I -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartScalar.I + * @author drose + * @date 1999-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::Copy Constructor -// Access: Protected -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ INLINE MovingPartScalar:: MovingPartScalar(const MovingPartScalar ©) : MovingPart(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MovingPartScalar:: MovingPartScalar(PartGroup *parent, const string &name, const PN_stdfloat &default_value) : MovingPart(parent, name, default_value) { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MovingPartScalar:: MovingPartScalar(){ } diff --git a/panda/src/chan/movingPartScalar.cxx b/panda/src/chan/movingPartScalar.cxx index 727b011b5b..ed49cddf63 100644 --- a/panda/src/chan/movingPartScalar.cxx +++ b/panda/src/chan/movingPartScalar.cxx @@ -1,17 +1,15 @@ -// Filename: movingPartScalar.cxx -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartScalar.cxx + * @author drose + * @date 1999-02-23 + */ #include "movingPartScalar.h" #include "animChannelScalarDynamic.h" @@ -30,27 +28,22 @@ template class MovingPart; TypeHandle MovingPartScalar::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovingPartScalar:: ~MovingPartScalar() { } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::get_blend_value -// Access: Public -// Description: Attempts to blend the various scalar values -// indicated, and sets the _value member to the -// resulting scalar. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to blend the various scalar values indicated, and sets the _value + * member to the resulting scalar. + */ void MovingPartScalar:: get_blend_value(const PartBundle *root) { - // If a forced channel is set on this particular scalar, we always - // return that value instead of performing the blend. Furthermore, - // the frame number is always 0 for the forced channel. + // If a forced channel is set on this particular scalar, we always return + // that value instead of performing the blend. Furthermore, the frame + // number is always 0 for the forced channel. if (_forced_channel != (AnimChannelBase *)NULL) { ChannelType *channel = DCAST(ChannelType, _forced_channel); channel->get_value(0, _value); @@ -90,7 +83,7 @@ get_blend_value(const PartBundle *root) { if (channel != NULL) { ValueType v; channel->get_value(control->get_frame(), v); - + if (!cdata->_frame_blend_flag) { // Hold the current frame until the next one is ready. _value += v * effect; @@ -117,30 +110,23 @@ get_blend_value(const PartBundle *root) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::apply_freeze_scalar -// Access: Public, Virtual -// Description: Freezes this particular joint so that it will always -// hold the specified transform. Returns true if this -// is a joint that can be so frozen, false otherwise. -// This is called internally by -// PartBundle::freeze_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Freezes this particular joint so that it will always hold the specified + * transform. Returns true if this is a joint that can be so frozen, false + * otherwise. This is called internally by PartBundle::freeze_joint(). + */ bool MovingPartScalar:: apply_freeze_scalar(PN_stdfloat value) { _forced_channel = new AnimChannelFixed(get_name(), value); return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::apply_control -// Access: Public, Virtual -// Description: Specifies a node to influence this particular joint -// so that it will always hold the node's transform. -// Returns true if this is a joint that can be so -// controlled, false otherwise. This is called -// internally by PartBundle::control_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies a node to influence this particular joint so that it will always + * hold the node's transform. Returns true if this is a joint that can be so + * controlled, false otherwise. This is called internally by + * PartBundle::control_joint(). + */ bool MovingPartScalar:: apply_control(PandaNode *node) { AnimChannelScalarDynamic *chan = new AnimChannelScalarDynamic(get_name()); @@ -149,11 +135,9 @@ apply_control(PandaNode *node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::make_MovingPartScalar -// Access: Protected -// Description: Factory method to generate a MovingPartScalar object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a MovingPartScalar object + */ TypedWritable* MovingPartScalar:: make_MovingPartScalar(const FactoryParams ¶ms) { MovingPartScalar *me = new MovingPartScalar; @@ -165,13 +149,10 @@ make_MovingPartScalar(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: MovingPartScalar::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a MovingPartScalar object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a MovingPartScalar object + */ void MovingPartScalar:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_MovingPartScalar); } - diff --git a/panda/src/chan/movingPartScalar.h b/panda/src/chan/movingPartScalar.h index 9dd41d4ccc..5e45e95e4a 100644 --- a/panda/src/chan/movingPartScalar.h +++ b/panda/src/chan/movingPartScalar.h @@ -1,16 +1,15 @@ -// Filename: movingPartScalar.h -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movingPartScalar.h + * @author drose + * @date 1999-02-23 + */ #ifndef MOVINGPARTSCALAR_H #define MOVINGPARTSCALAR_H @@ -23,11 +22,9 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_CHAN, EXPTP_PANDA_CHAN, MovingPart); -//////////////////////////////////////////////////////////////////// -// Class : MovingPartScalar -// Description : This is a particular kind of MovingPart that accepts -// a scalar each frame. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of MovingPart that accepts a scalar each frame. + */ class EXPCL_PANDA_CHAN MovingPartScalar : public MovingPart { protected: INLINE MovingPartScalar(const MovingPartScalar ©); @@ -79,6 +76,3 @@ private: #endif #endif - - - diff --git a/panda/src/chan/partBundle.I b/panda/src/chan/partBundle.I index ab3af47d6e..ca6ec4c7cf 100644 --- a/panda/src/chan/partBundle.I +++ b/panda/src/chan/partBundle.I @@ -1,75 +1,59 @@ -// Filename: partBundle.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundle.I + * @author drose + * @date 1999-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_anim_preload -// Access: Published -// Description: Returns the AnimPreloadTable associated with -// the PartBundle. This table, if present, can be used -// for the benefit of load_bind_anim() to allow -// asynchronous binding. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimPreloadTable associated with the PartBundle. This table, + * if present, can be used for the benefit of load_bind_anim() to allow + * asynchronous binding. + */ INLINE CPT(AnimPreloadTable) PartBundle:: get_anim_preload() const { return _anim_preload.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::modify_anim_preload -// Access: Published -// Description: Returns a modifiable pointer to the AnimPreloadTable -// associated with the PartBundle, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the AnimPreloadTable associated with the + * PartBundle, if any. + */ INLINE PT(AnimPreloadTable) PartBundle:: modify_anim_preload() { return _anim_preload.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_anim_preload -// Access: Published -// Description: Replaces the AnimPreloadTable associated with -// the PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the AnimPreloadTable associated with the PartBundle. + */ INLINE void PartBundle:: set_anim_preload(AnimPreloadTable *anim_preload) { _anim_preload = anim_preload; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::clear_anim_preload -// Access: Published -// Description: Removes any AnimPreloadTable associated with -// the PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * Removes any AnimPreloadTable associated with the PartBundle. + */ INLINE void PartBundle:: clear_anim_preload() { _anim_preload = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_blend_type -// Access: Published -// Description: Defines the algorithm that is used when blending -// multiple frames or multiple animations together, when -// either anim_blend_flag or frame_blend_flag is set -// to true. -// -// See partBundle.h for a description of the meaning of -// each of the BlendType values. -//////////////////////////////////////////////////////////////////// +/** + * Defines the algorithm that is used when blending multiple frames or + * multiple animations together, when either anim_blend_flag or + * frame_blend_flag is set to true. + * + * See partBundle.h for a description of the meaning of each of the BlendType + * values. + */ INLINE void PartBundle:: set_blend_type(PartBundle::BlendType bt) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -77,55 +61,44 @@ set_blend_type(PartBundle::BlendType bt) { cdata->_blend_type = bt; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_blend_type -// Access: Published -// Description: Returns the algorithm that is used when blending -// multiple frames or multiple animations together, when -// either anim_blend_flag or frame_blend_flag is set -// to true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the algorithm that is used when blending multiple frames or + * multiple animations together, when either anim_blend_flag or + * frame_blend_flag is set to true. + */ INLINE PartBundle::BlendType PartBundle:: get_blend_type() const { CDReader cdata(_cycler); return cdata->_blend_type; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_anim_blend_flag -// Access: Published -// Description: Returns whether the character allows multiple -// different animations to be bound simultaneously. See -// set_anim_blend_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the character allows multiple different animations to be + * bound simultaneously. See set_anim_blend_flag(). + */ INLINE bool PartBundle:: get_anim_blend_flag() const { CDReader cdata(_cycler); return cdata->_anim_blend_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_frame_blend_flag -// Access: Published -// Description: Specifies whether the character interpolates (blends) -// between two sequential frames of an active animation, -// showing a smooth intra-frame motion, or whether it -// holds each frame until the next frame is ready, -// showing precisely the specified animation. -// -// When this value is false, the character holds each -// frame until the next is ready. When this is true, -// the character will interpolate between two -// consecutive frames of animation for each frame the -// animation is onscreen, according to the amount of -// time elapsed between the frames. -// -// The default value of this flag is determined by the -// interpolate-frames Config.prc variable. -// -// Use set_blend_type() to change the algorithm that the -// character uses to interpolate matrix positions. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the character interpolates (blends) between two + * sequential frames of an active animation, showing a smooth intra-frame + * motion, or whether it holds each frame until the next frame is ready, + * showing precisely the specified animation. + * + * When this value is false, the character holds each frame until the next is + * ready. When this is true, the character will interpolate between two + * consecutive frames of animation for each frame the animation is onscreen, + * according to the amount of time elapsed between the frames. + * + * The default value of this flag is determined by the interpolate-frames + * Config.prc variable. + * + * Use set_blend_type() to change the algorithm that the character uses to + * interpolate matrix positions. + */ INLINE void PartBundle:: set_frame_blend_flag(bool frame_blend_flag) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -133,26 +106,21 @@ set_frame_blend_flag(bool frame_blend_flag) { cdata->_frame_blend_flag = frame_blend_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_frame_blend_flag -// Access: Published -// Description: Returns whether the character interpolates (blends) -// between two sequential animation frames, or whether -// it holds the current frame until the next one is -// ready. See set_frame_blend_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the character interpolates (blends) between two sequential + * animation frames, or whether it holds the current frame until the next one + * is ready. See set_frame_blend_flag(). + */ INLINE bool PartBundle:: get_frame_blend_flag() const { CDReader cdata(_cycler); return cdata->_frame_blend_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_root_xform -// Access: Published -// Description: Specifies the transform matrix which is implicitly -// applied at the root of the animated hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the transform matrix which is implicitly applied at the root of + * the animated hierarchy. + */ INLINE void PartBundle:: set_root_xform(const LMatrix4 &root_xform) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -161,12 +129,9 @@ set_root_xform(const LMatrix4 &root_xform) { cdata->_anim_changed = true; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::xform -// Access: Published -// Description: Applies the indicated transform to the root of the -// animated hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform to the root of the animated hierarchy. + */ INLINE void PartBundle:: xform(const LMatrix4 &mat) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -176,35 +141,28 @@ xform(const LMatrix4 &mat) { cdata->_anim_changed = true; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_root_xform -// Access: Published -// Description: Returns the transform matrix which is implicitly -// applied at the root of the animated hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix which is implicitly applied at the root of the + * animated hierarchy. + */ INLINE const LMatrix4 &PartBundle:: get_root_xform() const { CDReader cdata(_cycler); return cdata->_root_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_num_nodes -// Access: Published -// Description: Returns the number of PartBundleNodes that contain a -// pointer to this PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of PartBundleNodes that contain a pointer to this + * PartBundle. + */ INLINE int PartBundle:: get_num_nodes() const { return _nodes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_node -// Access: Published -// Description: Returns the nth PartBundleNode associated with -// this PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth PartBundleNode associated with this PartBundle. + */ INLINE PartBundleNode *PartBundle:: get_node(int n) const { nassertr(n >= 0 && n < (int)_nodes.size(), NULL); @@ -212,22 +170,17 @@ get_node(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_control_effect -// Access: Published -// Description: Sets the amount by which the character is affected by -// the indicated AnimControl (and its associated -// animation). Normally, this will only be zero or one. -// Zero indicates the animation does not affect the -// character, and one means it does. -// -// If the _anim_blend_flag is not false (see -// set_anim_blend_flag()), it is possible to have -// multiple AnimControls in effect simultaneously. In -// this case, the effect is a weight that indicates the -// relative importance of each AnimControl to the final -// animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount by which the character is affected by the indicated + * AnimControl (and its associated animation). Normally, this will only be + * zero or one. Zero indicates the animation does not affect the character, + * and one means it does. + * + * If the _anim_blend_flag is not false (see set_anim_blend_flag()), it is + * possible to have multiple AnimControls in effect simultaneously. In this + * case, the effect is a weight that indicates the relative importance of each + * AnimControl to the final animation. + */ void PartBundle:: set_control_effect(AnimControl *control, PN_stdfloat effect) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -236,28 +189,21 @@ set_control_effect(AnimControl *control, PN_stdfloat effect) { do_set_control_effect(control, effect, cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::get_control_effect -// Access: Published -// Description: Returns the amount by which the character is affected -// by the indicated AnimControl and its associated -// animation. See set_control_effect(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount by which the character is affected by the indicated + * AnimControl and its associated animation. See set_control_effect(). + */ INLINE PN_stdfloat PartBundle:: get_control_effect(AnimControl *control) const { CDReader cdata(_cycler); return do_get_control_effect(control, cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_update_delay -// Access: Public -// Description: Specifies the minimum amount of time, in seconds, -// that should elapse between any two consecutive -// updates. This is normally used by -// Character::set_lod_animation(), and should not be -// called directly. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the minimum amount of time, in seconds, that should elapse + * between any two consecutive updates. This is normally used by + * Character::set_lod_animation(), and should not be called directly. + */ INLINE void PartBundle:: set_update_delay(double delay) { _update_delay = delay; diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index 1648a87a0d..3fb797e3c3 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -1,17 +1,15 @@ -// Filename: partBundle.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundle.cxx + * @author drose + * @date 1999-02-22 + */ #include "partBundle.h" #include "animBundle.h" @@ -44,12 +42,9 @@ static ConfigVariableEnum anim_blend_type "PartBundle::set_frame_blend_flag().")); -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::Copy Constructor -// Access: Protected -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ PartBundle:: PartBundle(const PartBundle ©) : PartGroup(copy) @@ -65,37 +60,29 @@ PartBundle(const PartBundle ©) : cdata->_root_xform = cdata_from->_root_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::Constructor -// Access: Public -// Description: Normally, a PartBundle constructor should not be -// called directly--it will get created when a -// PartBundleNode is created. -//////////////////////////////////////////////////////////////////// +/** + * Normally, a PartBundle constructor should not be called directly--it will + * get created when a PartBundleNode is created. + */ PartBundle:: -PartBundle(const string &name) : +PartBundle(const string &name) : PartGroup(name) { _update_delay = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the node. -// Children are not copied, but see copy_subgraph(). -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the node. Children are not copied, but + * see copy_subgraph(). + */ PartGroup *PartBundle:: make_copy() const { return new PartBundle(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::merge_anim_preloads -// Access: Published -// Description: Copies the contents of the other PartBundle's preload -// table into this one. -//////////////////////////////////////////////////////////////////// +/** + * Copies the contents of the other PartBundle's preload table into this one. + */ void PartBundle:: merge_anim_preloads(const PartBundle *other) { if (other->_anim_preload == (AnimPreloadTable *)NULL || @@ -115,22 +102,18 @@ merge_anim_preloads(const PartBundle *other) { anim_preload->add_anims_from(other->_anim_preload.get_read_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::set_anim_blend_flag -// Access: Published -// Description: Defines the way the character responds to multiple -// calls to set_control_effect()). By default, this -// flag is set false, which disallows multiple -// animations. When this flag is false, it is not -// necessary to explicitly set the control_effect when -// starting an animation; starting the animation will -// implicitly remove the control_effect from the -// previous animation and set it on the current one. -// -// However, if this flag is set true, the control_effect -// must be explicitly set via set_control_effect() -// whenever an animation is to affect the character. -//////////////////////////////////////////////////////////////////// +/** + * Defines the way the character responds to multiple calls to + * set_control_effect()). By default, this flag is set false, which disallows + * multiple animations. When this flag is false, it is not necessary to + * explicitly set the control_effect when starting an animation; starting the + * animation will implicitly remove the control_effect from the previous + * animation and set it on the current one. + * + * However, if this flag is set true, the control_effect must be explicitly + * set via set_control_effect() whenever an animation is to affect the + * character. + */ void PartBundle:: set_anim_blend_flag(bool anim_blend_flag) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -142,8 +125,8 @@ set_anim_blend_flag(bool anim_blend_flag) { if (!anim_blend_flag && cdataw->_blend.size() > 1) { // If we just changed to disallow animation blending, we should - // eliminate all the AnimControls other than the - // most-recently-added one. + // eliminate all the AnimControls other than the most-recently-added + // one. nassertv(cdataw->_last_control_set != NULL); clear_and_stop_intersecting(cdataw->_last_control_set, cdataw); @@ -153,14 +136,11 @@ set_anim_blend_flag(bool anim_blend_flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::apply_transform -// Access: Published -// Description: Returns a PartBundle that is a duplicate of this one, -// but with the indicated transform applied. If this is -// called multiple times with the same TransformState -// pointer, it returns the same PartBundle each time. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PartBundle that is a duplicate of this one, but with the + * indicated transform applied. If this is called multiple times with the + * same TransformState pointer, it returns the same PartBundle each time. + */ PT(PartBundle) PartBundle:: apply_transform(const TransformState *transform) { if (transform->is_identity()) { @@ -189,29 +169,25 @@ apply_transform(const TransformState *transform) { bool inserted = _applied_transforms.insert(AppliedTransforms::value_type(transform, new_bundle)).second; nassertr(inserted, new_bundle); } - - // Make sure the new transform gets immediately applied to all of - // the joints. + + // Make sure the new transform gets immediately applied to all of the + // joints. new_bundle->force_update(); return new_bundle; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::clear_control_effects -// Access: Published -// Description: Sets the control effect of all AnimControls to zero -// (but does not "stop" the AnimControls). The -// character will no longer be affected by any -// animation, and will return to its default -// pose (unless restore-initial-pose is false). -// -// The AnimControls which are no longer associated will -// not be using any CPU cycles, but they may still be in -// the "playing" state; if they are later reassociated -// with the PartBundle they will resume at their current -// frame as if they'd been running all along. -//////////////////////////////////////////////////////////////////// +/** + * Sets the control effect of all AnimControls to zero (but does not "stop" + * the AnimControls). The character will no longer be affected by any + * animation, and will return to its default pose (unless restore-initial-pose + * is false). + * + * The AnimControls which are no longer associated will not be using any CPU + * cycles, but they may still be in the "playing" state; if they are later + * reassociated with the PartBundle they will resume at their current frame as + * if they'd been running all along. + */ void PartBundle:: clear_control_effects() { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -226,22 +202,17 @@ clear_control_effects() { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::output -// Access: Published, Virtual -// Description: Writes a one-line description of the bundle. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line description of the bundle. + */ void PartBundle:: output(ostream &out) const { out << get_type() << " " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::write -// Access: Published, Virtual -// Description: Writes a brief description of the bundle and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the bundle and all of its descendants. + */ void PartBundle:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -251,29 +222,23 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::bind_anim -// Access: Published -// Description: Binds the animation to the bundle, if possible, and -// returns a new AnimControl that can be used to start -// and stop the animation. If the anim hierarchy does -// not match the part hierarchy, returns NULL. -// -// If hierarchy_match_flags is 0, only an exact match is -// accepted; otherwise, it may contain a union of -// PartGroup::HierarchyMatchFlags values indicating -// conditions that will be tolerated (but warnings will -// still be issued). -// -// If subset is specified, it restricts the binding only -// to the named subtree of joints. -// -// The AnimControl is not stored within the PartBundle; -// it is the user's responsibility to maintain the -// pointer. The animation will automatically unbind -// itself when the AnimControl destructs (i.e. its -// reference count goes to zero). -//////////////////////////////////////////////////////////////////// +/** + * Binds the animation to the bundle, if possible, and returns a new + * AnimControl that can be used to start and stop the animation. If the anim + * hierarchy does not match the part hierarchy, returns NULL. + * + * If hierarchy_match_flags is 0, only an exact match is accepted; otherwise, + * it may contain a union of PartGroup::HierarchyMatchFlags values indicating + * conditions that will be tolerated (but warnings will still be issued). + * + * If subset is specified, it restricts the binding only to the named subtree + * of joints. + * + * The AnimControl is not stored within the PartBundle; it is the user's + * responsibility to maintain the pointer. The animation will automatically + * unbind itself when the AnimControl destructs (i.e. its reference count + * goes to zero). + */ PT(AnimControl) PartBundle:: bind_anim(AnimBundle *anim, int hierarchy_match_flags, const PartSubset &subset) { @@ -285,38 +250,30 @@ bind_anim(AnimBundle *anim, int hierarchy_match_flags, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::load_bind_anim -// Access: Published -// Description: Binds an animation to the bundle. The animation is -// loaded from the disk via the indicated Loader object. -// In other respects, this behaves similarly to -// bind_anim(), with the addition of asynchronous -// support. -// -// If allow_aysnc is true, the load will be asynchronous -// if possible. This requires that the animation -// basename can be found in the PartBundle's preload -// table (see get_anim_preload()). -// -// In an asynchronous load, the animation file will be -// loaded and bound in a sub-thread. This means that -// the animation will not necessarily be available at -// the time this method returns. You may still use the -// returned AnimControl immediately, though, but no -// visible effect will occur until the animation -// eventually becomes available. -// -// You can test AnimControl::is_pending() to see if the -// animation has been loaded yet, or wait for it to -// finish with AnimControl::wait_pending() or even -// PartBundle::wait_pending(). You can also set an -// event to be triggered when the animation finishes -// loading with AnimControl::set_pending_done_event(). -//////////////////////////////////////////////////////////////////// +/** + * Binds an animation to the bundle. The animation is loaded from the disk + * via the indicated Loader object. In other respects, this behaves similarly + * to bind_anim(), with the addition of asynchronous support. + * + * If allow_aysnc is true, the load will be asynchronous if possible. This + * requires that the animation basename can be found in the PartBundle's + * preload table (see get_anim_preload()). + * + * In an asynchronous load, the animation file will be loaded and bound in a + * sub-thread. This means that the animation will not necessarily be + * available at the time this method returns. You may still use the returned + * AnimControl immediately, though, but no visible effect will occur until the + * animation eventually becomes available. + * + * You can test AnimControl::is_pending() to see if the animation has been + * loaded yet, or wait for it to finish with AnimControl::wait_pending() or + * even PartBundle::wait_pending(). You can also set an event to be triggered + * when the animation finishes loading with + * AnimControl::set_pending_done_event(). + */ PT(AnimControl) PartBundle:: -load_bind_anim(Loader *loader, const Filename &filename, - int hierarchy_match_flags, const PartSubset &subset, +load_bind_anim(Loader *loader, const Filename &filename, + int hierarchy_match_flags, const PartSubset &subset, bool allow_async) { nassertr(loader != (Loader *)NULL, NULL); @@ -332,9 +289,8 @@ load_bind_anim(Loader *loader, const Filename &filename, } if (anim_index < 0 || !allow_async || !Thread::is_threading_supported()) { - // The animation is not present in the table, or allow_async is - // false. Therefore, perform an ordinary synchronous - // load-and-bind. + // The animation is not present in the table, or allow_async is false. + // Therefore, perform an ordinary synchronous load-and-bind. PT(PandaNode) model = loader->load_sync(filename, anim_options); if (model == (PandaNode *)NULL) { @@ -355,24 +311,24 @@ load_bind_anim(Loader *loader, const Filename &filename, return control; } - // The animation is present in the table, so we can perform an - // asynchronous load-and-bind. + // The animation is present in the table, so we can perform an asynchronous + // load-and-bind. PN_stdfloat frame_rate = anim_preload->get_base_frame_rate(anim_index); int num_frames = anim_preload->get_num_frames(anim_index); - PT(AnimControl) control = + PT(AnimControl) control = new AnimControl(basename, this, frame_rate, num_frames); if (!subset.is_include_empty()) { - // Figure out the actual subset of joints to be bound. + // Figure out the actual subset of joints to be bound. int joint_index = 0; BitArray bound_joints; find_bound_joints(joint_index, false, bound_joints, subset); control->set_bound_joints(bound_joints); } - PT(BindAnimRequest) request = + PT(BindAnimRequest) request = new BindAnimRequest(string("bind:") + filename.get_basename(), - filename, anim_options, loader, control, + filename, anim_options, loader, control, hierarchy_match_flags, subset); request->set_priority(async_bind_priority); loader->load_async(request); @@ -380,19 +336,16 @@ load_bind_anim(Loader *loader, const Filename &filename, return control; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::wait_pending -// Access: Published -// Description: Blocks the current thread until all currently-pending -// AnimControls, with a nonzero control effect, have -// been loaded and are properly bound. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the current thread until all currently-pending AnimControls, with a + * nonzero control effect, have been loaded and are properly bound. + */ void PartBundle:: wait_pending() { CDReader cdata(_cycler); ChannelBlend::const_iterator cbi; - for (cbi = cdata->_blend.begin(); - cbi != cdata->_blend.end(); + for (cbi = cdata->_blend.begin(); + cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; PN_stdfloat effect = (*cbi).second; @@ -402,19 +355,14 @@ wait_pending() { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::freeze_joint -// Access: Published -// Description: Specifies that the joint with the indicated name -// should be frozen with the specified transform. It -// will henceforth always hold this fixed transform, -// regardless of any animations that may subsequently be -// bound to the joint. -// -// Returns true if the joint is successfully frozen, or -// false if the named child is not a joint (or slider) -// or does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the joint with the indicated name should be frozen with the + * specified transform. It will henceforth always hold this fixed transform, + * regardless of any animations that may subsequently be bound to the joint. + * + * Returns true if the joint is successfully frozen, or false if the named + * child is not a joint (or slider) or does not exist. + */ bool PartBundle:: freeze_joint(const string &joint_name, const TransformState *transform) { PartGroup *child = find_child(joint_name); @@ -428,19 +376,14 @@ freeze_joint(const string &joint_name, const TransformState *transform) { return child->apply_freeze(transform); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::freeze_joint -// Access: Published -// Description: Specifies that the joint with the indicated name -// should be frozen with the specified transform. It -// will henceforth always hold this fixed transform, -// regardless of any animations that may subsequently be -// bound to the joint. -// -// Returns true if the joint is successfully frozen, or -// false if the named child is not a joint (or slider) -// or does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the joint with the indicated name should be frozen with the + * specified transform. It will henceforth always hold this fixed transform, + * regardless of any animations that may subsequently be bound to the joint. + * + * Returns true if the joint is successfully frozen, or false if the named + * child is not a joint (or slider) or does not exist. + */ bool PartBundle:: freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { PartGroup *child = find_child(joint_name); @@ -454,19 +397,14 @@ freeze_joint(const string &joint_name, const LVecBase3 &pos, const LVecBase3 &hp return child->apply_freeze_matrix(pos, hpr, scale); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::freeze_joint -// Access: Published -// Description: Specifies that the joint with the indicated name -// should be frozen with the specified transform. It -// will henceforth always hold this fixed transform, -// regardless of any animations that may subsequently be -// bound to the joint. -// -// Returns true if the joint is successfully frozen, or -// false if the named child is not a joint (or slider) -// or does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the joint with the indicated name should be frozen with the + * specified transform. It will henceforth always hold this fixed transform, + * regardless of any animations that may subsequently be bound to the joint. + * + * Returns true if the joint is successfully frozen, or false if the named + * child is not a joint (or slider) or does not exist. + */ bool PartBundle:: freeze_joint(const string &joint_name, PN_stdfloat value) { PartGroup *child = find_child(joint_name); @@ -480,19 +418,15 @@ freeze_joint(const string &joint_name, PN_stdfloat value) { return child->apply_freeze_scalar(value); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::control_joint -// Access: Published -// Description: Specifies that the joint with the indicated name -// should be animated with the transform on the -// indicated node. It will henceforth always follow the -// node's transform, regardless of any animations that -// may subsequently be bound to the joint. -// -// Returns true if the joint is successfully controlled, -// or false if the named child is not a joint (or -// slider) or does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the joint with the indicated name should be animated with + * the transform on the indicated node. It will henceforth always follow the + * node's transform, regardless of any animations that may subsequently be + * bound to the joint. + * + * Returns true if the joint is successfully controlled, or false if the named + * child is not a joint (or slider) or does not exist. + */ bool PartBundle:: control_joint(const string &joint_name, PandaNode *node) { PartGroup *child = find_child(joint_name); @@ -506,18 +440,14 @@ control_joint(const string &joint_name, PandaNode *node) { return child->apply_control(node); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::release_joint -// Access: Published -// Description: Releases the named joint from the effects of a -// previous call to freeze_joint() or control_joint(). -// It will henceforth once again follow whatever -// transforms are dictated by the animation. -// -// Returns true if the joint is released, or false if -// the named child was not previously controlled or -// frozen, or it does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Releases the named joint from the effects of a previous call to + * freeze_joint() or control_joint(). It will henceforth once again follow + * whatever transforms are dictated by the animation. + * + * Returns true if the joint is released, or false if the named child was not + * previously controlled or frozen, or it does not exist. + */ bool PartBundle:: release_joint(const string &joint_name) { PartGroup *child = find_child(joint_name); @@ -531,16 +461,13 @@ release_joint(const string &joint_name) { return child->clear_forced_channel(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::update -// Access: Published -// Description: Updates all the parts in the bundle to reflect the -// data for the current frame (as set in each of the -// AnimControls). -// -// Returns true if any part has changed as a result of -// this, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Updates all the parts in the bundle to reflect the data for the current + * frame (as set in each of the AnimControls). + * + * Returns true if any part has changed as a result of this, or false + * otherwise. + */ bool PartBundle:: update() { Thread *current_thread = Thread::get_current_thread(); @@ -552,16 +479,16 @@ update() { bool anim_changed = cdata->_anim_changed; bool frame_blend_flag = cdata->_frame_blend_flag; - any_changed = do_update(this, cdata, NULL, false, anim_changed, + any_changed = do_update(this, cdata, NULL, false, anim_changed, current_thread); - + // Now update all the controls for next time. ChannelBlend::const_iterator cbi; for (cbi = cdata->_blend.begin(); cbi != cdata->_blend.end(); ++cbi) { AnimControl *control = (*cbi).first; control->mark_channels(frame_blend_flag); } - + cdata->_anim_changed = false; cdata->_last_update = now; } @@ -569,13 +496,10 @@ update() { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::force_update -// Access: Published -// Description: Updates all the parts in the bundle to reflect the -// data for the current frame, whether we believe it -// needs it or not. -//////////////////////////////////////////////////////////////////// +/** + * Updates all the parts in the bundle to reflect the data for the current + * frame, whether we believe it needs it or not. + */ bool PartBundle:: force_update() { Thread *current_thread = Thread::get_current_thread(); @@ -588,20 +512,18 @@ force_update() { AnimControl *control = (*cbi).first; control->mark_channels(cdata->_frame_blend_flag); } - + cdata->_anim_changed = false; return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::control_activated -// Access: Public, Virtual -// Description: Called by the AnimControl whenever it starts an -// animation. This is just a hook so the bundle can do -// something, if necessary, before the animation starts. -//////////////////////////////////////////////////////////////////// +/** + * Called by the AnimControl whenever it starts an animation. This is just a + * hook so the bundle can do something, if necessary, before the animation + * starts. + */ void PartBundle:: control_activated(AnimControl *control) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -609,24 +531,21 @@ control_activated(AnimControl *control) { CDLockedReader cdata(_cycler); - // If (and only if) our anim_blend_flag is false, then starting an - // animation implicitly enables it. + // If (and only if) our anim_blend_flag is false, then starting an animation + // implicitly enables it. if (!cdata->_anim_blend_flag) { CDWriter cdataw(_cycler, cdata); do_set_control_effect(control, 1.0f, cdataw); } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::do_bind_anim -// Access: Public -// Description: The internal implementation of bind_anim(), this -// receives a pointer to an uninitialized AnimControl -// and fills it in if the bind is successful. Returns -// true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of bind_anim(), this receives a pointer to an + * uninitialized AnimControl and fills it in if the bind is successful. + * Returns true if successful, false otherwise. + */ bool PartBundle:: -do_bind_anim(AnimControl *control, AnimBundle *anim, +do_bind_anim(AnimControl *control, AnimBundle *anim, int hierarchy_match_flags, const PartSubset &subset) { nassertr(Thread::get_current_pipeline_stage() == 0, false); @@ -664,7 +583,7 @@ do_bind_anim(AnimControl *control, AnimBundle *anim, if (subset.is_include_empty()) { bound_joints = BitArray::all_on(); } - bind_hierarchy(ptanim, channel_index, joint_index, + bind_hierarchy(ptanim, channel_index, joint_index, subset.is_include_empty(), bound_joints, subset); control->setup_anim(this, anim, channel_index, bound_joints); @@ -674,29 +593,22 @@ do_bind_anim(AnimControl *control, AnimBundle *anim, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::add_node -// Access: Protected, Virtual -// Description: Adds the PartBundleNode pointer to the set of nodes -// associated with the PartBundle. Normally called only -// by the PartBundleNode itself, for instance when the -// bundle is flattened with another node. -//////////////////////////////////////////////////////////////////// +/** + * Adds the PartBundleNode pointer to the set of nodes associated with the + * PartBundle. Normally called only by the PartBundleNode itself, for + * instance when the bundle is flattened with another node. + */ void PartBundle:: add_node(PartBundleNode *node) { nassertv(find(_nodes.begin(), _nodes.end(), node) == _nodes.end()); _nodes.push_back(node); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::remove_node -// Access: Protected, Virtual -// Description: Removes the PartBundleNode pointer from the set of -// nodes associated with the PartBundle. Normally -// called only by the PartBundleNode itself, for -// instance when the bundle is flattened with another -// node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the PartBundleNode pointer from the set of nodes associated with + * the PartBundle. Normally called only by the PartBundleNode itself, for + * instance when the bundle is flattened with another node. + */ void PartBundle:: remove_node(PartBundleNode *node) { Nodes::iterator ni = find(_nodes.begin(), _nodes.end(), node); @@ -704,11 +616,9 @@ remove_node(PartBundleNode *node) { _nodes.erase(ni); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::do_set_control_effect -// Access: Private -// Description: The private implementation of set_control_effect(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of set_control_effect(). + */ void PartBundle:: do_set_control_effect(AnimControl *control, PN_stdfloat effect, CData *cdata) { nassertv(control->get_part() == this); @@ -724,8 +634,8 @@ do_set_control_effect(AnimControl *control, PN_stdfloat effect, CData *cdata) { } else { // Otherwise we define it. - // If anim_blend_flag is false, we only allow one AnimControl at a - // time. Stop all of the other AnimControls. + // If anim_blend_flag is false, we only allow one AnimControl at a time. + // Stop all of the other AnimControls. if (!cdata->_anim_blend_flag) { clear_and_stop_intersecting(control, cdata); } @@ -740,11 +650,9 @@ do_set_control_effect(AnimControl *control, PN_stdfloat effect, CData *cdata) { recompute_net_blend(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::do_get_control_effect -// Access: Private -// Description: The private implementation of get_control_effect(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of get_control_effect(). + */ PN_stdfloat PartBundle:: do_get_control_effect(AnimControl *control, const CData *cdata) const { nassertr(control->get_part() == this, 0.0f); @@ -759,13 +667,11 @@ do_get_control_effect(AnimControl *control, const CData *cdata) const { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::recompute_net_blend -// Access: Private -// Description: Recomputes the total blending amount after a control -// effect has been adjusted. This value must be kept -// up-to-date so we can normalize the blending amounts. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the total blending amount after a control effect has been + * adjusted. This value must be kept up-to-date so we can normalize the + * blending amounts. + */ void PartBundle:: recompute_net_blend(CData *cdata) { cdata->_net_blend = 0.0f; @@ -777,16 +683,12 @@ recompute_net_blend(CData *cdata) { determine_effective_channels(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::clear_and_stop_intersecting -// Access: Private -// Description: Removes and stops all the currently activated -// AnimControls that animate some joints also animated -// by the indicated AnimControl. This is a special -// internal function that's only called when -// _anim_blend_flag is false, to automatically stop all -// the other currently-executing animations. -//////////////////////////////////////////////////////////////////// +/** + * Removes and stops all the currently activated AnimControls that animate + * some joints also animated by the indicated AnimControl. This is a special + * internal function that's only called when _anim_blend_flag is false, to + * automatically stop all the other currently-executing animations. + */ void PartBundle:: clear_and_stop_intersecting(AnimControl *control, CData *cdata) { double new_net_blend = 0.0f; @@ -798,8 +700,8 @@ clear_and_stop_intersecting(AnimControl *control, CData *cdata) { AnimControl *ac = (*cbi).first; if (ac == control || !ac->get_bound_joints().has_bits_in_common(control->get_bound_joints())) { - // Save this control--it's either the target control, or it has - // no joints in common with the target control. + // Save this control--it's either the target control, or it has no + // joints in common with the target control. new_blend.insert(new_blend.end(), (*cbi)); new_net_blend += (*cbi).second; } else { @@ -817,13 +719,11 @@ clear_and_stop_intersecting(AnimControl *control, CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void PartBundle:: finalize(BamReader *) { Thread *current_thread = Thread::get_current_thread(); @@ -831,12 +731,10 @@ finalize(BamReader *) { do_update(this, cdata, NULL, true, true, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PartBundle:: write_datagram(BamWriter *manager, Datagram &dg) { PartGroup::write_datagram(manager, dg); @@ -844,17 +742,14 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::complete_pointers -// Access: Public -// Description: Takes in a vector of pointers to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Takes in a vector of pointers to TypedWritable objects that correspond to + * all the requests for pointers that this object made to BamReader. + */ int PartBundle:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PartGroup::complete_pointers(p_list, manager); - + if (manager->get_file_minor_ver() >= 17) { _anim_preload = DCAST(AnimPreloadTable, p_list[pi++]); } @@ -862,11 +757,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::make_from_bam -// Access: Protected -// Description: Factory method to generate a PartBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a PartBundle object + */ TypedWritable* PartBundle:: make_from_bam(const FactoryParams ¶ms) { PartBundle *me = new PartBundle; @@ -879,13 +772,10 @@ make_from_bam(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PartBundle. + */ void PartBundle:: fillin(DatagramIterator &scan, BamReader *manager) { PartGroup::fillin(scan, manager); @@ -895,27 +785,23 @@ fillin(DatagramIterator &scan, BamReader *manager) { if (manager->get_file_minor_ver() >= 10) { manager->read_cdata(scan, _cycler); } - if (manager->get_file_minor_ver() == 11) { + if (manager->get_file_minor_ver() == 11) { // No longer need the _modifies_anim_bundles flag scan.get_bool(); } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a PartBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a PartBundle object + */ void PartBundle:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartBundle::CData:: CData() { _blend_type = anim_blend_type; @@ -928,11 +814,9 @@ CData() { _last_update = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartBundle::CData:: CData(const PartBundle::CData ©) : _blend_type(copy._blend_type), @@ -945,44 +829,37 @@ CData(const PartBundle::CData ©) : _anim_changed(copy._anim_changed), _last_update(copy._last_update) { - // Note that this copy constructor is not used by the PartBundle - // copy constructor! Any elements that must be copied between - // PartBundles should also be explicitly copied there. + // Note that this copy constructor is not used by the PartBundle copy + // constructor! Any elements that must be copied between PartBundles should + // also be explicitly copied there. } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *PartBundle::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PartBundle::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint8(_blend_type); dg.add_bool(_anim_blend_flag); dg.add_bool(_frame_blend_flag); _root_xform.write_datagram(dg); - + // The remaining members are strictly dynamic. } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PartBundle. + */ void PartBundle::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _blend_type = (BlendType)scan.get_uint8(); @@ -991,10 +868,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _root_xform.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::BlendType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, PartBundle::BlendType blend_type) { switch (blend_type) { @@ -1010,17 +886,16 @@ operator << (ostream &out, PartBundle::BlendType blend_type) { case PartBundle::BT_componentwise_quat: return out << "componentwise_quat"; } - + chan_cat->error() << "Invalid BlendType value: " << (int)blend_type << "\n"; nassertr(false, out); return out; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundle::BlendType input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, PartBundle::BlendType &blend_type) { string word; diff --git a/panda/src/chan/partBundle.h b/panda/src/chan/partBundle.h index d4d46f5816..82272df52c 100644 --- a/panda/src/chan/partBundle.h +++ b/panda/src/chan/partBundle.h @@ -1,16 +1,15 @@ -// Filename: partBundle.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundle.h + * @author drose + * @date 1999-02-22 + */ #ifndef PARTBUNDLE_H #define PARTBUNDLE_H @@ -40,17 +39,15 @@ class PartBundleNode; class TransformState; class AnimPreloadTable; -//////////////////////////////////////////////////////////////////// -// Class : PartBundle -// Description : This is the root of a MovingPart hierarchy. It -// defines the hierarchy of moving parts that make up an -// animatable object. -//////////////////////////////////////////////////////////////////// +/** + * This is the root of a MovingPart hierarchy. It defines the hierarchy of + * moving parts that make up an animatable object. + */ class EXPCL_PANDA_CHAN PartBundle : public PartGroup { public: - // This is passed down through the MovingParts during the - // do_update() call to specify the channels that are in effect. + // This is passed down through the MovingParts during the do_update() call + // to specify the channels that are in effect. typedef pmap ChannelBlend; protected: @@ -67,36 +64,34 @@ PUBLISHED: INLINE void clear_anim_preload(); void merge_anim_preloads(const PartBundle *other); - // This is the parameter to set_blend_type() and specifies the kind - // of blending operation to be performed when multiple controls are - // in effect simultaneously (see set_control_effect()) or between - // sequential frames of the animation. + // This is the parameter to set_blend_type() and specifies the kind of + // blending operation to be performed when multiple controls are in effect + // simultaneously (see set_control_effect()) or between sequential frames of + // the animation. enum BlendType { - // BT_linear does a componentwise average of all blended matrices, - // which is a linear blend. The result of this is that if a - // particular vertex would have been at point P in one animation - // and point Q in another one, it will end up on the line in - // between them in the resulting blend animation. However, this - // tends to stretch and squash limbs in strange and disturbing - // ways. + // BT_linear does a componentwise average of all blended matrices, which + // is a linear blend. The result of this is that if a particular vertex + // would have been at point P in one animation and point Q in another one, + // it will end up on the line in between them in the resulting blend + // animation. However, this tends to stretch and squash limbs in strange + // and disturbing ways. BT_linear, - // BT_normalized_linear is a compromise on BT_linear. The matrix - // is blended linearly without the scale and shear components, and - // the blended scale and shear components are applied separately. - // This keeps all of the character's body parts in the correct - // size and shape. However, if the hierarchy is disconnected, - // body parts can fly off. It's essential the skeleton hierarchy - // be completely connected to use this blend mode successully. + // BT_normalized_linear is a compromise on BT_linear. The matrix is + // blended linearly without the scale and shear components, and the + // blended scale and shear components are applied separately. This keeps + // all of the character's body parts in the correct size and shape. + // However, if the hierarchy is disconnected, body parts can fly off. + // It's essential the skeleton hierarchy be completely connected to use + // this blend mode successully. BT_normalized_linear, - // BT_componentwise linearly blends all components separately, - // including H, P, and R, and recomposes the matrix. + // BT_componentwise linearly blends all components separately, including + // H, P, and R, and recomposes the matrix. BT_componentwise, - // BT_componentwise_quat linearly blends all components - // separately, except for rotation which is blended as a - // quaternion. + // BT_componentwise_quat linearly blends all components separately, except + // for rotation which is blended as a quaternion. BT_componentwise_quat, }; @@ -126,7 +121,7 @@ PUBLISHED: virtual void write(ostream &out, int indent_level) const; PT(AnimControl) bind_anim(AnimBundle *anim, - int hierarchy_match_flags = 0, + int hierarchy_match_flags = 0, const PartSubset &subset = PartSubset()); PT(AnimControl) load_bind_anim(Loader *loader, const Filename &filename, @@ -143,11 +138,10 @@ PUBLISHED: bool update(); bool force_update(); - + public: - // The following functions aren't really part of the public - // interface; they're just public so we don't have to declare a - // bunch of friends. + // The following functions aren't really part of the public interface; + // they're just public so we don't have to declare a bunch of friends. virtual void control_activated(AnimControl *control); INLINE void set_update_delay(double delay); diff --git a/panda/src/chan/partBundleHandle.I b/panda/src/chan/partBundleHandle.I index 5c16c1e7cc..5c5df1b702 100644 --- a/panda/src/chan/partBundleHandle.I +++ b/panda/src/chan/partBundleHandle.I @@ -1,55 +1,43 @@ -// Filename: partBundleHandle.I -// Created by: drose (01Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleHandle.I + * @author drose + * @date 2007-10-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PartBundleHandle::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PartBundleHandle:: PartBundleHandle(PartBundle *bundle) : _bundle(bundle) { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleHandle::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PartBundleHandle:: ~PartBundleHandle() { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleHandle::get_bundle -// Access: Published -// Description: Returns the actual PartBundle embedded within the -// handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual PartBundle embedded within the handle. + */ INLINE PartBundle *PartBundleHandle:: get_bundle() { return _bundle; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleHandle::set_bundle -// Access: Published -// Description: Changes the actual PartBundle embedded within the -// handle. -//////////////////////////////////////////////////////////////////// +/** + * Changes the actual PartBundle embedded within the handle. + */ INLINE void PartBundleHandle:: set_bundle(PartBundle *bundle) { _bundle = bundle; diff --git a/panda/src/chan/partBundleHandle.cxx b/panda/src/chan/partBundleHandle.cxx index bd35e3866a..32ab207c95 100644 --- a/panda/src/chan/partBundleHandle.cxx +++ b/panda/src/chan/partBundleHandle.cxx @@ -1,15 +1,14 @@ -// Filename: partBundleHandle.cxx -// Created by: drose (01Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleHandle.cxx + * @author drose + * @date 2007-10-01 + */ #include "partBundleHandle.h" diff --git a/panda/src/chan/partBundleHandle.h b/panda/src/chan/partBundleHandle.h index 7acac81030..7a5e26e8ce 100644 --- a/panda/src/chan/partBundleHandle.h +++ b/panda/src/chan/partBundleHandle.h @@ -1,16 +1,15 @@ -// Filename: partBundleHandle.h -// Created by: drose (01Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleHandle.h + * @author drose + * @date 2007-10-01 + */ #ifndef PARTBUNDLEHANDLE_H #define PARTBUNDLEHANDLE_H @@ -20,22 +19,17 @@ #include "partBundle.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PartBundleHandle -// Description : This is a trivial class returned by -// PartBundleNode::get_bundle(). Its purpose is to hold -// the actual PartBundle pointer contained within the -// PartBundleNode, so that scene graph flatten -// operations can safely combine or duplicate -// PartBundles as necessary without affecting high-level -// bundle operations. -// -// The high-level Actor class defined in -// direct/src/actor, for instance, will store a list of -// PartBundleHandles instead of on actual PartBundles, -// so that it will be immune to changes from these -// flatten operations. -//////////////////////////////////////////////////////////////////// +/** + * This is a trivial class returned by PartBundleNode::get_bundle(). Its + * purpose is to hold the actual PartBundle pointer contained within the + * PartBundleNode, so that scene graph flatten operations can safely combine + * or duplicate PartBundles as necessary without affecting high-level bundle + * operations. + * + * The high-level Actor class defined in direct/src/actor, for instance, will + * store a list of PartBundleHandles instead of on actual PartBundles, so that + * it will be immune to changes from these flatten operations. + */ class EXPCL_PANDA_CHAN PartBundleHandle : public ReferenceCount { PUBLISHED: INLINE PartBundleHandle(PartBundle *bundle); diff --git a/panda/src/chan/partBundleNode.I b/panda/src/chan/partBundleNode.I index 93e110f0a4..c1251b7eac 100644 --- a/panda/src/chan/partBundleNode.I +++ b/panda/src/chan/partBundleNode.I @@ -1,27 +1,21 @@ -// Filename: partBundleNode.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleNode.I + * @author drose + * @date 2002-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::Constructor -// Access: Public -// Description: The PartBundle and its node should be constructed -// together. Generally, the derived classes of -// PartBundleNode will automatically create a PartBundle -// of the appropriate type, and pass it up to this -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * The PartBundle and its node should be constructed together. Generally, the + * derived classes of PartBundleNode will automatically create a PartBundle of + * the appropriate type, and pass it up to this constructor. + */ INLINE PartBundleNode:: PartBundleNode(const string &name, PartBundle *bundle) : PandaNode(name) @@ -29,58 +23,46 @@ PartBundleNode(const string &name, PartBundle *bundle) : add_bundle(bundle); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::Default Constructor -// Access: Protected -// Description: For internal use only. -//////////////////////////////////////////////////////////////////// +/** + * For internal use only. + */ INLINE PartBundleNode:: PartBundleNode() : PandaNode("") { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::Copy Constructor -// Access: Protected -// Description: Use make_copy() or copy_subgraph() to copy one of -// these. -// -// This constructor does not copy the bundle pointers. -//////////////////////////////////////////////////////////////////// +/** + * Use make_copy() or copy_subgraph() to copy one of these. + * + * This constructor does not copy the bundle pointers. + */ INLINE PartBundleNode:: PartBundleNode(const PartBundleNode ©) : PandaNode(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::get_num_bundles -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PartBundleNode:: get_num_bundles() const { return _bundles.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::get_bundle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PartBundle *PartBundleNode:: get_bundle(int n) const { nassertr(n >= 0 && n < (int)_bundles.size(), NULL); return _bundles[n]->get_bundle(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::get_bundle_handle -// Access: Public -// Description: Returns the PartBundleHandle that wraps around the -// actual nth PartBundle. While the PartBundle pointer -// might later change due to a future flatten operation, -// the PartBundleHandle will not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PartBundleHandle that wraps around the actual nth PartBundle. + * While the PartBundle pointer might later change due to a future flatten + * operation, the PartBundleHandle will not. + */ INLINE PartBundleHandle *PartBundleNode:: get_bundle_handle(int n) const { nassertr(n >= 0 && n < (int)_bundles.size(), NULL); diff --git a/panda/src/chan/partBundleNode.cxx b/panda/src/chan/partBundleNode.cxx index 60508d7d01..e0a726fd39 100644 --- a/panda/src/chan/partBundleNode.cxx +++ b/panda/src/chan/partBundleNode.cxx @@ -1,16 +1,15 @@ -// Filename: partBundleNode.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleNode.cxx + * @author drose + * @date 2002-03-06 + */ #include "partBundleNode.h" #include "datagram.h" @@ -21,11 +20,9 @@ TypeHandle PartBundleNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartBundleNode:: ~PartBundleNode() { Bundles::iterator bi; @@ -34,18 +31,15 @@ PartBundleNode:: } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::apply_attribs_to_vertices -// Access: Public, Virtual -// Description: Applies whatever attributes are specified in the -// AccumulatedAttribs object (and by the attrib_types -// bitmask) to the vertices on this node, if -// appropriate. If this node uses geom arrays like a -// GeomNode, the supplied GeomTransformer may be used to -// unify shared arrays across multiple different nodes. -// -// This is a generalization of xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ void PartBundleNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -58,24 +52,19 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, update_bundle(handle, new_bundle); } - // Make sure the Geom bounding volumes get recomputed due to this - // update. + // Make sure the Geom bounding volumes get recomputed due to this update. r_mark_geom_bounds_stale(Thread::get_current_thread()); } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void PartBundleNode:: xform(const LMatrix4 &mat) { - // With plain xform(), we can't attempt to share bundles across - // different nodes. Better to use apply_attribs_to_vertices(), - // instead. + // With plain xform(), we can't attempt to share bundles across different + // nodes. Better to use apply_attribs_to_vertices(), instead. if (mat.almost_equal(LMatrix4::ident_mat())) { // Don't bother. @@ -95,22 +84,18 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::add_bundle -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PartBundleNode:: add_bundle(PartBundle *bundle) { PT(PartBundleHandle) handle = new PartBundleHandle(bundle); add_bundle_handle(handle); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::add_bundle_handle -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PartBundleNode:: add_bundle_handle(PartBundleHandle *handle) { Bundles::iterator bi = find(_bundles.begin(), _bundles.end(), handle); @@ -123,12 +108,9 @@ add_bundle_handle(PartBundleHandle *handle) { handle->get_bundle()->add_node(this); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::steal_bundles -// Access: Protected -// Description: Moves the PartBundles from the other node onto this -// one. -//////////////////////////////////////////////////////////////////// +/** + * Moves the PartBundles from the other node onto this one. + */ void PartBundleNode:: steal_bundles(PartBundleNode *other) { if (other == this) { @@ -144,13 +126,10 @@ steal_bundles(PartBundleNode *other) { other->_bundles.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::update_bundle -// Access: Protected, Virtual -// Description: Replaces the contents of the indicated -// PartBundleHandle (presumably stored within this node) -// with new_bundle. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the contents of the indicated PartBundleHandle (presumably stored + * within this node) with new_bundle. + */ void PartBundleNode:: update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle) { PartBundle *old_bundle = old_bundle_handle->get_bundle(); @@ -159,12 +138,10 @@ update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle) { new_bundle->add_node(this); } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PartBundleNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -176,13 +153,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int PartBundleNode:: complete_pointers(TypedWritable **p_list, BamReader* manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -197,13 +171,10 @@ complete_pointers(TypedWritable **p_list, BamReader* manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PartBundleNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PandaNode. + */ void PartBundleNode:: fillin(DatagramIterator &scan, BamReader* manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/chan/partBundleNode.h b/panda/src/chan/partBundleNode.h index 0cda9eb1de..5a6de285e1 100644 --- a/panda/src/chan/partBundleNode.h +++ b/panda/src/chan/partBundleNode.h @@ -1,16 +1,15 @@ -// Filename: partBundleNode.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partBundleNode.h + * @author drose + * @date 2002-03-06 + */ #ifndef PARTBUNDLENODE_H #define PARTBUNDLENODE_H @@ -24,17 +23,15 @@ #include "dcast.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : PartBundleNode -// Description : This is a node that contains a pointer to an -// PartBundle. Like AnimBundleNode, it exists to make -// it easy to store PartBundles in the scene graph. -// -// (Unlike AnimBundleNode, however, PartBundleNode has -// an additional function: it is also the base class of -// the Character node type, which adds additional -// functionality.) -//////////////////////////////////////////////////////////////////// +/** + * This is a node that contains a pointer to an PartBundle. Like + * AnimBundleNode, it exists to make it easy to store PartBundles in the scene + * graph. + * + * (Unlike AnimBundleNode, however, PartBundleNode has an additional function: + * it is also the base class of the Character node type, which adds additional + * functionality.) + */ class EXPCL_PANDA_CHAN PartBundleNode : public PandaNode { PUBLISHED: INLINE PartBundleNode(const string &name, PartBundle *bundle); @@ -61,7 +58,7 @@ protected: void add_bundle(PartBundle *bundle); void add_bundle_handle(PartBundleHandle *handle); void steal_bundles(PartBundleNode *other); - virtual void update_bundle(PartBundleHandle *old_bundle_handle, + virtual void update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle); protected: diff --git a/panda/src/chan/partGroup.I b/panda/src/chan/partGroup.I index daef7ea456..4b1c166bad 100644 --- a/panda/src/chan/partGroup.I +++ b/panda/src/chan/partGroup.I @@ -1,25 +1,20 @@ -// Filename: partGroup.I -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partGroup.I + * @author drose + * @date 1999-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::Default Constructor -// Access: Protected -// Description: This constructor is only intended for interal use and -// for derived classes. You should normally use the -// non-default constructor, below. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended for interal use and for derived classes. + * You should normally use the non-default constructor, below. + */ INLINE PartGroup:: PartGroup(const string &name) : Namable(name), @@ -27,18 +22,15 @@ PartGroup(const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::Copy Constructor -// Access: Protected -// Description: This constructor is only intended for interal use and -// for derived classes. You should normally use the -// make_copy() interface to make copies.. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only intended for interal use and for derived classes. + * You should normally use the make_copy() interface to make copies.. + */ INLINE PartGroup:: PartGroup(const PartGroup ©) : Namable(copy), _children(get_class_type()) { - // We don't copy children in the copy constructor. However, - // copy_subgraph() will do this. + // We don't copy children in the copy constructor. However, copy_subgraph() + // will do this. } diff --git a/panda/src/chan/partGroup.cxx b/panda/src/chan/partGroup.cxx index 3b4a65d057..20fe582ae9 100644 --- a/panda/src/chan/partGroup.cxx +++ b/panda/src/chan/partGroup.cxx @@ -1,16 +1,15 @@ -// Filename: partGroup.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partGroup.cxx + * @author drose + * @date 1999-02-22 + */ #include "partGroup.h" #include "animGroup.h" @@ -28,61 +27,48 @@ TypeHandle PartGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::Constructor -// Access: Published -// Description: Creates the PartGroup, and adds it to the indicated -// parent. The only way to delete it subsequently is to -// delete the entire hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Creates the PartGroup, and adds it to the indicated parent. The only way + * to delete it subsequently is to delete the entire hierarchy. + */ PartGroup:: -PartGroup(PartGroup *parent, const string &name) : +PartGroup(PartGroup *parent, const string &name) : Namable(name), _children(get_class_type()) { nassertv(parent != NULL); - + parent->_children.push_back(this); } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartGroup:: ~PartGroup() { } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::is_character_joint -// Access: Published, Virtual -// Description: Returns true if this part is a CharacterJoint, false -// otherwise. This is a tiny optimization over -// is_of_type(CharacterType::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this part is a CharacterJoint, false otherwise. This is a + * tiny optimization over is_of_type(CharacterType::get_class_type()). + */ bool PartGroup:: is_character_joint() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::make_copy -// Access: Published, Virtual -// Description: Allocates and returns a new copy of the node. -// Children are not copied, but see copy_subgraph(). -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the node. Children are not copied, but + * see copy_subgraph(). + */ PartGroup *PartGroup:: make_copy() const { return new PartGroup(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::copy_subgraph -// Access: Published -// Description: Allocates and returns a new copy of this node and of -// all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of this node and of all of its children. + */ PartGroup *PartGroup:: copy_subgraph() const { PartGroup *root = make_copy(); @@ -102,37 +88,30 @@ copy_subgraph() const { } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::get_num_children -// Access: Published -// Description: Returns the number of child nodes of the group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child nodes of the group. + */ int PartGroup:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::get_child -// Access: Published -// Description: Returns the nth child of the group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of the group. + */ PartGroup *PartGroup:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::get_child_named -// Access: Published -// Description: Returns the first child found with the indicated -// name, or NULL if no such child exists. This method -// searches only the children of this particular -// PartGroup; it does not recursively search the entire -// graph. See also find_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first child found with the indicated name, or NULL if no such + * child exists. This method searches only the children of this particular + * PartGroup; it does not recursively search the entire graph. See also + * find_child(). + */ PartGroup *PartGroup:: get_child_named(const string &name) const { Children::const_iterator ci; @@ -146,14 +125,11 @@ get_child_named(const string &name) const { return (PartGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::find_child -// Access: Published -// Description: Returns the first descendant found with the indicated -// name, or NULL if no such descendant exists. This -// method searches the entire graph beginning at this -// PartGroup; see also get_child_named(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first descendant found with the indicated name, or NULL if no + * such descendant exists. This method searches the entire graph beginning at + * this PartGroup; see also get_child_named(). + */ PartGroup *PartGroup:: find_child(const string &name) const { Children::const_iterator ci; @@ -179,15 +155,12 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::sort_descendants -// Access: Published -// Description: Sorts the children nodes at each level of the -// hierarchy into alphabetical order. This should be -// done after creating the hierarchy, to guarantee that -// the correct names will match up together when the -// AnimBundle is later bound to a PlayerRoot. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the children nodes at each level of the hierarchy into alphabetical + * order. This should be done after creating the hierarchy, to guarantee that + * the correct names will match up together when the AnimBundle is later bound + * to a PlayerRoot. + */ void PartGroup:: sort_descendants() { stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder()); @@ -198,108 +171,85 @@ sort_descendants() { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::apply_freeze -// Access: Published -// Description: Freezes this particular joint so that it will always -// hold the specified transform. Returns true if this -// is a joint that can be so frozen, false otherwise. -// -// This is normally only called internally by -// PartBundle::freeze_joint(), but you may also call it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Freezes this particular joint so that it will always hold the specified + * transform. Returns true if this is a joint that can be so frozen, false + * otherwise. + * + * This is normally only called internally by PartBundle::freeze_joint(), but + * you may also call it directly. + */ bool PartGroup:: apply_freeze(const TransformState *transform) { return apply_freeze_matrix(transform->get_pos(), transform->get_hpr(), transform->get_scale()) || apply_freeze_scalar(transform->get_pos()[0]); } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::apply_freeze_matrix -// Access: Published, Virtual -// Description: Freezes this particular joint so that it will always -// hold the specified transform. Returns true if this -// is a joint that can be so frozen, false otherwise. -// -// This is normally only called internally by -// PartBundle::freeze_joint(), but you may also call it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Freezes this particular joint so that it will always hold the specified + * transform. Returns true if this is a joint that can be so frozen, false + * otherwise. + * + * This is normally only called internally by PartBundle::freeze_joint(), but + * you may also call it directly. + */ bool PartGroup:: apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::apply_freeze_scalar -// Access: Published, Virtual -// Description: Freezes this particular joint so that it will always -// hold the specified transform. Returns true if this -// is a joint that can be so frozen, false otherwise. -// -// This is normally only called internally by -// PartBundle::freeze_joint(), but you may also call it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Freezes this particular joint so that it will always hold the specified + * transform. Returns true if this is a joint that can be so frozen, false + * otherwise. + * + * This is normally only called internally by PartBundle::freeze_joint(), but + * you may also call it directly. + */ bool PartGroup:: apply_freeze_scalar(PN_stdfloat value) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::apply_control -// Access: Published, Virtual -// Description: Specifies a node to influence this particular joint -// so that it will always hold the node's transform. -// Returns true if this is a joint that can be so -// controlled, false otherwise. -// -// This is normally only called internally by -// PartBundle::control_joint(), but you may also call it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a node to influence this particular joint so that it will always + * hold the node's transform. Returns true if this is a joint that can be so + * controlled, false otherwise. + * + * This is normally only called internally by PartBundle::control_joint(), but + * you may also call it directly. + */ bool PartGroup:: apply_control(PandaNode *node) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::clear_forced_channel -// Access: Published, Virtual -// Description: Undoes the effect of a previous call to -// apply_freeze() or apply_control(). Returns true if -// the joint was modified, false otherwise. -// -// This is normally only called internally by -// PartBundle::release_joint(), but you may also call it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to apply_freeze() or apply_control(). + * Returns true if the joint was modified, false otherwise. + * + * This is normally only called internally by PartBundle::release_joint(), but + * you may also call it directly. + */ bool PartGroup:: clear_forced_channel() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::get_forced_channel -// Access: Published, Virtual -// Description: Returns the AnimChannelBase that has been forced to -// this joint by a previous call to apply_freeze() or -// apply_control(), or NULL if no such channel has been -// applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AnimChannelBase that has been forced to this joint by a + * previous call to apply_freeze() or apply_control(), or NULL if no such + * channel has been applied. + */ AnimChannelBase *PartGroup:: get_forced_channel() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::write -// Access: Published, Virtual -// Description: Writes a brief description of the group and all of -// its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the group and all of its descendants. + */ void PartGroup:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -308,12 +258,10 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::write_with_value -// Access: Published, Virtual -// Description: Writes a brief description of the group, showing its -// current value, and that of all of its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the group, showing its current value, and + * that of all of its descendants. + */ void PartGroup:: write_with_value(ostream &out, int indent_level) const { indent(out, indent_level) @@ -322,32 +270,24 @@ write_with_value(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::get_value_type -// Access: Public, Virtual -// Description: Returns the TypeHandle associated with the ValueType -// we are concerned with. This is provided to allow a -// bit of run-time checking that joints and channels are -// matching properly in type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with the ValueType we are concerned with. + * This is provided to allow a bit of run-time checking that joints and + * channels are matching properly in type. + */ TypeHandle PartGroup:: get_value_type() const { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::check_hierarchy -// Access: Public -// Description: Walks the part hierarchy in tandem with the indicated -// anim hierarchy, and returns true if the hierarchies -// match, false otherwise. -// -// If hierarchy_match_flags is 0, only an exact match is -// accepted; otherwise, it may contain a union of -// PartGroup::HierarchyMatchFlags values indicating -// conditions that will be tolerated (but warnings will -// still be issued). -//////////////////////////////////////////////////////////////////// +/** + * Walks the part hierarchy in tandem with the indicated anim hierarchy, and + * returns true if the hierarchies match, false otherwise. + * + * If hierarchy_match_flags is 0, only an exact match is accepted; otherwise, + * it may contain a union of PartGroup::HierarchyMatchFlags values indicating + * conditions that will be tolerated (but warnings will still be issued). + */ bool PartGroup:: check_hierarchy(const AnimGroup *anim, const PartGroup *, int hierarchy_match_flags) const { @@ -363,16 +303,16 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, } if (chan_cat.is_info()) { - // If we're issuing error messages, check ahead of time if the set - // of children agrees. If it does not, we'll write a one-line - // warning, and then list the set of children that differ. + // If we're issuing error messages, check ahead of time if the set of + // children agrees. If it does not, we'll write a one-line warning, and + // then list the set of children that differ. bool match = true; if (anim->get_num_children() != get_num_children()) { - // If the only difference is "morph", ignore it. We treat - // "morph" as a special case, because it's common for the model - // and animation files to differ meaninglessly here. Any - // differences here remain unreported. + // If the only difference is "morph", ignore it. We treat "morph" as a + // special case, because it's common for the model and animation files + // to differ meaninglessly here. Any differences here remain + // unreported. if (anim->get_num_children() == get_num_children() + 1 && anim->get_child_named("morph") != NULL && get_child_named("morph") == NULL) { @@ -424,7 +364,8 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, << ", not in part.\n"; j++; } else { - // chan_cat.info() << " part and anim both have " << ac->get_name() << "\n"; + // chan_cat.info() << " part and anim both have " << ac->get_name() + // << "\n"; i++; j++; } @@ -448,8 +389,8 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, } } - // Now walk the list of children and check the matching - // sub-hierarchies only. + // Now walk the list of children and check the matching sub-hierarchies + // only. int i = 0, j = 0; while (i < get_num_children() && @@ -487,7 +428,7 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, while (i < get_num_children()) { // There's at least one extra part. PartGroup *pc = get_child(i); - + if (pc->get_name() == "morph") { // Model has "morph", not in anim. Ignore. } else { @@ -516,18 +457,13 @@ check_hierarchy(const AnimGroup *anim, const PartGroup *, } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::do_update -// Access: Public, Virtual -// Description: Recursively update this particular part and all of -// its descendents for the current frame. This is not -// really public and is not intended to be called -// directly; it is called from the top of the tree by -// PartBundle::update(). -// -// The return value is true if any part has changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Recursively update this particular part and all of its descendents for the + * current frame. This is not really public and is not intended to be called + * directly; it is called from the top of the tree by PartBundle::update(). + * + * The return value is true if any part has changed, false otherwise. + */ bool PartGroup:: do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *, bool parent_changed, bool anim_changed, Thread *current_thread) { @@ -535,7 +471,7 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *, Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { - if ((*ci)->do_update(root, root_cdata, this, parent_changed, + if ((*ci)->do_update(root, root_cdata, this, parent_changed, anim_changed, current_thread)) { any_changed = true; } @@ -544,13 +480,10 @@ do_update(PartBundle *root, const CycleData *root_cdata, PartGroup *, return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::do_xform -// Access: Public, Virtual -// Description: Called by PartBundle::xform(), this indicates the -// indicated transform is being applied to the root -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Called by PartBundle::xform(), this indicates the indicated transform is + * being applied to the root joint. + */ void PartGroup:: do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { Children::const_iterator ci; @@ -560,13 +493,10 @@ do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::determine_effective_channels -// Access: Public, Virtual -// Description: Should be called whenever the ChannelBlend values -// have changed, this recursively updates the -// _effective_channel member in each part. -//////////////////////////////////////////////////////////////////// +/** + * Should be called whenever the ChannelBlend values have changed, this + * recursively updates the _effective_channel member in each part. + */ void PartGroup:: determine_effective_channels(const CycleData *root_cdata) { Children::iterator ci; @@ -576,12 +506,9 @@ determine_effective_channels(const CycleData *root_cdata) { } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::write_descendants -// Access: Protected -// Description: Writes a brief description of all of the group's -// descendants. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of all of the group's descendants. + */ void PartGroup:: write_descendants(ostream &out, int indent_level) const { Children::const_iterator ci; @@ -591,12 +518,10 @@ write_descendants(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::write_descendants_with_value -// Access: Protected -// Description: Writes a brief description of all of the group's -// descendants and their values. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of all of the group's descendants and their + * values. + */ void PartGroup:: write_descendants_with_value(ostream &out, int indent_level) const { Children::const_iterator ci; @@ -606,14 +531,11 @@ write_descendants_with_value(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::pick_channel_index -// Access: Protected, Virtual -// Description: Walks the part hierarchy, looking for a suitable -// channel index number to use. Available index numbers -// are the elements of the holes set, as well as next to -// infinity. -//////////////////////////////////////////////////////////////////// +/** + * Walks the part hierarchy, looking for a suitable channel index number to + * use. Available index numbers are the elements of the holes set, as well as + * next to infinity. + */ void PartGroup:: pick_channel_index(plist &holes, int &next) const { Children::const_iterator ci; @@ -623,14 +545,12 @@ pick_channel_index(plist &holes, int &next) const { } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::bind_hierarchy -// Access: Protected, Virtual -// Description: Binds the indicated anim hierarchy to the part -// hierarchy, at the given channel index number. -//////////////////////////////////////////////////////////////////// +/** + * Binds the indicated anim hierarchy to the part hierarchy, at the given + * channel index number. + */ void PartGroup:: -bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, +bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) { Thread::consider_yield(); @@ -649,9 +569,8 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, AnimGroup *ac = anim->get_child(j); if (pc->get_name() < ac->get_name()) { - // Here's a part, not in the anim. Bind it to the special NULL - // anim. - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + // Here's a part, not in the anim. Bind it to the special NULL anim. + pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, bound_joints, subset); i++; @@ -661,7 +580,7 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, } else { // Here's a matched part and anim pair. - pc->bind_hierarchy(ac, channel_index, joint_index, is_included, + pc->bind_hierarchy(ac, channel_index, joint_index, is_included, bound_joints, subset); i++; j++; @@ -671,23 +590,19 @@ bind_hierarchy(AnimGroup *anim, int channel_index, int &joint_index, // Now pick up any more parts, not in the anim. while (i < part_num_children) { PartGroup *pc = get_child(i); - pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, + pc->bind_hierarchy(NULL, channel_index, joint_index, is_included, bound_joints, subset); i++; } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::find_bound_joints -// Access: Protected, Virtual -// Description: Similar to bind_hierarchy, but does not actually -// perform any binding. All it does is compute the -// BitArray bount_joints according to the specified -// subset. This is useful in preparation for -// asynchronous binding--in this case, we may need to -// know bound_joints immediately, without having to wait -// for the animation itself to load and bind. -//////////////////////////////////////////////////////////////////// +/** + * Similar to bind_hierarchy, but does not actually perform any binding. All + * it does is compute the BitArray bount_joints according to the specified + * subset. This is useful in preparation for asynchronous binding--in this + * case, we may need to know bound_joints immediately, without having to wait + * for the animation itself to load and bind. + */ void PartGroup:: find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) { @@ -703,13 +618,11 @@ find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, pc->find_bound_joints(joint_index, is_included, bound_joints, subset); } } - -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// + +/** + * Function to write the important information in the particular object to a + * Datagram + */ void PartGroup:: write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); @@ -719,14 +632,11 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void PartGroup:: fillin(DatagramIterator &scan, BamReader *manager) { set_name(scan.get_string()); @@ -746,17 +656,14 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::complete_pointers -// Access: Public -// Description: Takes in a vector of pointers to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Takes in a vector of pointers to TypedWritable objects that correspond to + * all the requests for pointers that this object made to BamReader. + */ int PartGroup:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); - + Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { (*ci) = DCAST(PartGroup, p_list[pi++]); @@ -765,11 +672,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::make_PartGroup -// Access: Protected -// Description: Factory method to generate a PartGroup object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a PartGroup object + */ TypedWritable* PartGroup:: make_PartGroup(const FactoryParams ¶ms) { PartGroup *me = new PartGroup; @@ -781,13 +686,10 @@ make_PartGroup(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PartGroup::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a PartGroup object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a PartGroup object + */ void PartGroup:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_PartGroup); } - diff --git a/panda/src/chan/partGroup.h b/panda/src/chan/partGroup.h index 1ba23978d9..16b497f842 100644 --- a/panda/src/chan/partGroup.h +++ b/panda/src/chan/partGroup.h @@ -1,16 +1,15 @@ -// Filename: partGroup.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partGroup.h + * @author drose + * @date 1999-02-22 + */ #ifndef PARTGROUP_H #define PARTGROUP_H @@ -37,17 +36,15 @@ class TransformState; class PandaNode; class AnimChannelBase; -//////////////////////////////////////////////////////////////////// -// Class : PartGroup -// Description : This is the base class for PartRoot and -// MovingPart. It defines a hierarchy of MovingParts. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for PartRoot and MovingPart. It defines a hierarchy + * of MovingParts. + */ class EXPCL_PANDA_CHAN PartGroup : public TypedWritableReferenceCount, public Namable { PUBLISHED: - // This enum defines bits which may be passed into check_hierarchy() - // and PartBundle::bind_anim() to allow an inexact match of channel - // hierarchies. This specifies conditions that we don't care about - // enforcing. + // This enum defines bits which may be passed into check_hierarchy() and + // PartBundle::bind_anim() to allow an inexact match of channel hierarchies. + // This specifies conditions that we don't care about enforcing. enum HierarchyMatchFlags { HMF_ok_part_extra = 0x01, HMF_ok_anim_extra = 0x02, @@ -55,10 +52,9 @@ PUBLISHED: }; protected: - // The default constructor is protected: don't try to create a - // PartGroup without a parent. To create a PartGroup hierarchy, you - // must first create a PartBundle, and use that as the parent of any - // subsequent children. + // The default constructor is protected: don't try to create a PartGroup + // without a parent. To create a PartGroup hierarchy, you must first create + // a PartBundle, and use that as the parent of any subsequent children. INLINE PartGroup(const string &name = ""); INLINE PartGroup(const PartGroup ©); @@ -97,7 +93,7 @@ public: int hierarchy_match_flags = 0) const; virtual bool do_update(PartBundle *root, const CycleData *root_cdata, - PartGroup *parent, bool parent_changed, + PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread); virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat); virtual void determine_effective_channels(const CycleData *root_cdata); @@ -108,10 +104,10 @@ protected: virtual void pick_channel_index(plist &holes, int &next) const; virtual void bind_hierarchy(AnimGroup *anim, int channel_index, - int &joint_index, bool is_included, + int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset); - virtual void find_bound_joints(int &joint_index, bool is_included, + virtual void find_bound_joints(int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset); @@ -156,5 +152,3 @@ private: #include "partGroup.I" #endif - - diff --git a/panda/src/chan/partSubset.I b/panda/src/chan/partSubset.I index 619d2d382b..dfaf2c34d3 100644 --- a/panda/src/chan/partSubset.I +++ b/panda/src/chan/partSubset.I @@ -1,14 +1,12 @@ -// Filename: partSubset.I -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partSubset.I + * @author drose + * @date 2006-01-19 + */ diff --git a/panda/src/chan/partSubset.cxx b/panda/src/chan/partSubset.cxx index 2f04ef9323..6e88cce020 100644 --- a/panda/src/chan/partSubset.cxx +++ b/panda/src/chan/partSubset.cxx @@ -1,111 +1,93 @@ -// Filename: partSubset.cxx -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partSubset.cxx + * @author drose + * @date 2006-01-19 + */ #include "partSubset.h" -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartSubset:: PartSubset() { } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PartSubset:: -PartSubset(const PartSubset ©) : +PartSubset(const PartSubset ©) : _include_joints(copy._include_joints), _exclude_joints(copy._exclude_joints) { } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PartSubset:: operator = (const PartSubset ©) { _include_joints = copy._include_joints; _exclude_joints = copy._exclude_joints; } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::add_include_joint -// Access: Published -// Description: Adds the named joint to the list of joints that will -// be explicitly included in the subset. Any joint at -// or below a named node will be included in the subset -// (unless a lower node is also listed in the exclude -// list). -// -// Since the name is a GlobPattern, it may of course -// include filename globbing characters like * and ?. -//////////////////////////////////////////////////////////////////// +/** + * Adds the named joint to the list of joints that will be explicitly included + * in the subset. Any joint at or below a named node will be included in the + * subset (unless a lower node is also listed in the exclude list). + * + * Since the name is a GlobPattern, it may of course include filename globbing + * characters like * and ?. + */ void PartSubset:: add_include_joint(const GlobPattern &name) { _include_joints.push_back(name); } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::add_exclude_joint -// Access: Published -// Description: Adds the named joint to the list of joints that will -// be explicitly exlcluded from the subset. Any joint at -// or below a named node will not be included in the -// subset (unless a lower node is also listed in the -// include list). -// -// Since the name is a GlobPattern, it may of course -// include filename globbing characters like * and ?. -//////////////////////////////////////////////////////////////////// +/** + * Adds the named joint to the list of joints that will be explicitly + * exlcluded from the subset. Any joint at or below a named node will not be + * included in the subset (unless a lower node is also listed in the include + * list). + * + * Since the name is a GlobPattern, it may of course include filename globbing + * characters like * and ?. + */ void PartSubset:: add_exclude_joint(const GlobPattern &name) { _exclude_joints.push_back(name); } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::append -// Access: Published -// Description: Appends the include and exclude list from the other -// object onto this object's lists. -//////////////////////////////////////////////////////////////////// +/** + * Appends the include and exclude list from the other object onto this + * object's lists. + */ void PartSubset:: append(const PartSubset &other) { Joints::const_iterator ji; - for (ji = other._include_joints.begin(); - ji != other._include_joints.end(); + for (ji = other._include_joints.begin(); + ji != other._include_joints.end(); ++ji) { _include_joints.push_back(*ji); } - for (ji = other._exclude_joints.begin(); - ji != other._exclude_joints.end(); + for (ji = other._exclude_joints.begin(); + ji != other._exclude_joints.end(); ++ji) { _exclude_joints.push_back(*ji); } } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PartSubset:: output(ostream &out) const { if (_include_joints.empty() && _exclude_joints.empty()) { @@ -124,24 +106,19 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::is_include_empty -// Access: Published -// Description: Returns true if the include list is completely empty, -// false otherwise. If it is empty, it is the same -// thing as including all joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the include list is completely empty, false otherwise. If + * it is empty, it is the same thing as including all joints. + */ bool PartSubset:: is_include_empty() const { return _include_joints.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::matches_include -// Access: Published -// Description: Returns true if the indicated name matches a name on -// the include list, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name matches a name on the include list, + * false otherwise. + */ bool PartSubset:: matches_include(const string &joint_name) const { Joints::const_iterator ji; @@ -155,12 +132,10 @@ matches_include(const string &joint_name) const { } -//////////////////////////////////////////////////////////////////// -// Function: PartSubset::matches_exclude -// Access: Published -// Description: Returns true if the indicated name matches a name on -// the exclude list, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name matches a name on the exclude list, + * false otherwise. + */ bool PartSubset:: matches_exclude(const string &joint_name) const { Joints::const_iterator ji; diff --git a/panda/src/chan/partSubset.h b/panda/src/chan/partSubset.h index 9ac86e9ba5..93e7bda47f 100644 --- a/panda/src/chan/partSubset.h +++ b/panda/src/chan/partSubset.h @@ -1,16 +1,15 @@ -// Filename: partSubset.h -// Created by: drose (19Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file partSubset.h + * @author drose + * @date 2006-01-19 + */ #ifndef PARTSUBSET_H #define PARTSUBSET_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "globPattern.h" -//////////////////////////////////////////////////////////////////// -// Class : PartSubset -// Description : This class is used to define a subset of part names -// to apply to the PartBundle::bind_anim() operation. -// Only those part names within the subset will be -// included in the bind. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to define a subset of part names to apply to the + * PartBundle::bind_anim() operation. Only those part names within the subset + * will be included in the bind. + */ class EXPCL_PANDA_CHAN PartSubset { PUBLISHED: PartSubset(); @@ -56,4 +53,3 @@ INLINE ostream &operator << (ostream &out, const PartSubset &subset) { #include "partSubset.I" #endif - diff --git a/panda/src/chan/vector_PartGroupStar.cxx b/panda/src/chan/vector_PartGroupStar.cxx index d459b2db50..e0f6554731 100644 --- a/panda/src/chan/vector_PartGroupStar.cxx +++ b/panda/src/chan/vector_PartGroupStar.cxx @@ -1,16 +1,15 @@ -// Filename: vector_PartGroupStar.cxx -// Created by: drose (06Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PartGroupStar.cxx + * @author drose + * @date 2000-07-06 + */ #include "vector_PartGroupStar.h" diff --git a/panda/src/chan/vector_PartGroupStar.h b/panda/src/chan/vector_PartGroupStar.h index dc144f98b0..988635dc33 100644 --- a/panda/src/chan/vector_PartGroupStar.h +++ b/panda/src/chan/vector_PartGroupStar.h @@ -1,16 +1,15 @@ -// Filename: vector_PartGroupStar.h -// Created by: drose (06Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PartGroupStar.h + * @author drose + * @date 2000-07-06 + */ #ifndef VECTOR_PARTGROUPSTAR_H #define VECTOR_PARTGROUPSTAR_H @@ -19,15 +18,12 @@ #include "partGroup.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_PartGroupStar -// Description : A vector of PartGroup pointers. This class is -// defined once here, and exported to PANDA.DLL; other -// packages that want to use a vector of this type -// (whether they need to export it or not) should -// include this header file, rather than defining the -// vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of PartGroup pointers. This class is defined once here, and + * exported to PANDA.DLL; other packages that want to use a vector of this + * type (whether they need to export it or not) should include this header + * file, rather than defining the vector again. + */ #define EXPCL EXPCL_PANDA_CHAN #define EXPTP EXPTP_PANDA_CHAN diff --git a/panda/src/char/character.I b/panda/src/char/character.I index 2b87d4c78d..74f6061f12 100644 --- a/panda/src/char/character.I +++ b/panda/src/char/character.I @@ -1,27 +1,22 @@ -// Filename: character.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file character.I + * @author drose + * @date 2002-03-06 + */ #include "characterJointBundle.h" -//////////////////////////////////////////////////////////////////// -// Function: Character::get_bundle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CharacterJointBundle *Character:: get_bundle(int i) const { return DCAST(CharacterJointBundle, PartBundleNode::get_bundle(i)); } - - diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 6d3ce17d94..a57ec2eda6 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -1,16 +1,15 @@ -// Filename: character.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file character.cxx + * @author drose + * @date 2002-03-06 + */ #include "character.h" #include "characterJoint.h" @@ -33,11 +32,9 @@ TypeHandle Character::_type_handle; PStatCollector Character::_animation_pcollector("*:Animation"); -//////////////////////////////////////////////////////////////////// -// Function: Character::Copy Constructor -// Access: Protected -// Description: Use make_copy() or copy_subgraph() to copy a Character. -//////////////////////////////////////////////////////////////////// +/** + * Use make_copy() or copy_subgraph() to copy a Character. + */ Character:: Character(const Character ©, bool copy_bundles) : PartBundleNode(copy), @@ -66,17 +63,15 @@ Character(const Character ©, bool copy_bundles) : PartBundle *orig_bundle = copy.get_bundle(i); add_bundle(orig_bundle); } - } + } _last_auto_update = -1.0; _view_frame = -1; _view_distance2 = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: Character::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Character:: Character(const string &name) : PartBundleNode(name, new CharacterJointBundle(name)), @@ -90,11 +85,9 @@ Character(const string &name) : _view_distance2 = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: Character::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Character:: ~Character() { int num_bundles = get_num_bundles(); @@ -103,52 +96,40 @@ Character:: } } -//////////////////////////////////////////////////////////////////// -// Function: Character::make_copy -// Access: Public, Virtual -// Description: The Character make_copy() function will make a new -// copy of the Character, with all of its joints copied, -// and with a new set of dynamic vertex arrays all ready -// to go, but it will not copy any of the original -// Character's geometry, so the new Character won't look -// like much. Use copy_subgraph() to make a full copy -// of the Character. -//////////////////////////////////////////////////////////////////// +/** + * The Character make_copy() function will make a new copy of the Character, + * with all of its joints copied, and with a new set of dynamic vertex arrays + * all ready to go, but it will not copy any of the original Character's + * geometry, so the new Character won't look like much. Use copy_subgraph() + * to make a full copy of the Character. + */ PandaNode *Character:: make_copy() const { return new Character(*this, true); } -//////////////////////////////////////////////////////////////////// -// Function: Character::dupe_for_flatten -// Access: Public, Virtual -// Description: This is similar to make_copy(), but it makes a copy -// for the specific purpose of flatten. Typically, this -// will be a new PandaNode with a new pointer, but all -// of the internal data will always be shared with the -// original; whereas the new node returned by -// make_copy() might not share the internal data. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to make_copy(), but it makes a copy for the specific + * purpose of flatten. Typically, this will be a new PandaNode with a new + * pointer, but all of the internal data will always be shared with the + * original; whereas the new node returned by make_copy() might not share the + * internal data. + */ PandaNode *Character:: dupe_for_flatten() const { return new Character(*this, false); } -//////////////////////////////////////////////////////////////////// -// Function: Character::combine_with -// Access: Published, Virtual -// Description: Collapses this node with the other node, if possible, -// and returns a pointer to the combined node, or NULL -// if the two nodes cannot safely be combined. -// -// The return value may be this, other, or a new node -// altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two nodes and what the -// collapsed node should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this node with the other node, if possible, and returns a pointer + * to the combined node, or NULL if the two nodes cannot safely be combined. + * + * The return value may be this, other, or a new node altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two nodes + * and what the collapsed node should look like. + */ PandaNode *Character:: combine_with(PandaNode *other) { if (is_exact_type(get_class_type()) && @@ -162,38 +143,30 @@ combine_with(PandaNode *other) { return PandaNode::combine_with(other); } -//////////////////////////////////////////////////////////////////// -// Function: Character::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool Character:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // For now, we update the character during the cull traversal; this - // prevents us from needlessly updating characters that aren't in - // the view frustum. We may need a better way to do this - // optimization later, to handle characters that might animate - // themselves in front of the view frustum. + // For now, we update the character during the cull traversal; this prevents + // us from needlessly updating characters that aren't in the view frustum. + // We may need a better way to do this optimization later, to handle + // characters that might animate themselves in front of the view frustum. if (_do_lod_animation) { int this_frame = ClockObject::get_global_clock()->get_frame_count(); @@ -216,7 +189,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { set_lod_current_delay(delay); if (char_cat.is_spam()) { - char_cat.spam() + char_cat.spam() << "Distance to " << NodePath::any_path(this) << " in frame " << this_frame << " is " << dist << ", computed delay is " << delay << "\n"; @@ -228,62 +201,50 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Character::calc_tight_bounds -// Access: Public, Virtual -// Description: This is used to support -// NodePath::calc_tight_bounds(). It is not intended to -// be called directly, and it has nothing to do with the -// normal Panda bounding-volume computation. -// -// If the node contains any geometry, this updates -// min_point and max_point to enclose its bounding box. -// found_any is to be set true if the node has any -// geometry at all, or left alone if it has none. This -// method may be called over several nodes, so it may -// enter with min_point, max_point, and found_any -// already set. -// -// This function is recursive, and the return value is -// the transform after it has been modified by this -// node's transform. -//////////////////////////////////////////////////////////////////// +/** + * This is used to support NodePath::calc_tight_bounds(). It is not intended + * to be called directly, and it has nothing to do with the normal Panda + * bounding-volume computation. + * + * If the node contains any geometry, this updates min_point and max_point to + * enclose its bounding box. found_any is to be set true if the node has any + * geometry at all, or left alone if it has none. This method may be called + * over several nodes, so it may enter with min_point, max_point, and + * found_any already set. + * + * This function is recursive, and the return value is the transform after it + * has been modified by this node's transform. + */ CPT(TransformState) Character:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { - // This method is overridden by Character solely to provide a hook - // to force the joints to update before computing the bounding - // volume. + // This method is overridden by Character solely to provide a hook to force + // the joints to update before computing the bounding volume. ((Character *)this)->update_to_now(); - // Unfortunately, calling update_to_now() will invalidate the node's - // cached bounding volume, which causes a problem when this is - // called during the traversal, e.g. due to a ShowBoundsEffect. As - // a hacky fix to work around this, we will force-recompute all of - // the bounding volumes of our parent nodes immediately. + // Unfortunately, calling update_to_now() will invalidate the node's cached + // bounding volume, which causes a problem when this is called during the + // traversal, e.g. due to a ShowBoundsEffect. As a hacky fix to work + // around this, we will force-recompute all of the bounding volumes of our + // parent nodes immediately. Parents parents = get_parents(); for (int i = 0; i < parents.get_num_parents(); ++i) { PandaNode *parent = parents.get_parent(i); parent->get_bounds(); } - return PandaNode::calc_tight_bounds(min_point, max_point, + return PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: Character::merge_bundles -// Access: Published -// Description: Merges old_bundle with new_bundle. old_bundle -// must be one of the PartBundles within this node. At -// the end of this call, the old_bundle pointer within -// this node will be replaced with the new_bundle -// pointer, and all geometry within this node will be -// updated to reference new_bundle. -// -// This method is deprecated. Use the newer version of -// this method, below. -//////////////////////////////////////////////////////////////////// +/** + * Merges old_bundle with new_bundle. old_bundle must be one of the + * PartBundles within this node. At the end of this call, the old_bundle + * pointer within this node will be replaced with the new_bundle pointer, and + * all geometry within this node will be updated to reference new_bundle. + * + * This method is deprecated. Use the newer version of this method, below. + */ void Character:: merge_bundles(PartBundle *old_bundle, PartBundle *new_bundle) { if (old_bundle == new_bundle) { @@ -306,35 +267,27 @@ merge_bundles(PartBundle *old_bundle, PartBundle *new_bundle) { merge_bundles(old_bundle_handle, new_bundle_handle); } -//////////////////////////////////////////////////////////////////// -// Function: Character::merge_bundles -// Access: Published -// Description: Merges old_bundle_handle->get_bundle() with -// new_bundle. old_bundle_handle must be one of the -// PartBundleHandle within this node. At the end of -// this call, the bundle pointer within the -// old_bundle_handle will be replaced with that within -// the new_bundle_handle pointer, and all geometry -// within this node will be updated to reference -// new_bundle. -// -// Normally, this is called when the two bundles have -// the same, or nearly the same, hierarchies. In this -// case, new_bundle will simply be assigned over the -// old_bundle position. However, if any joints are -// present in one bundle or the other, new_bundle will -// be modified to contain the union of all joints. -// -// The geometry below this node is also updated to -// reference new_bundle, instead of the original -// old_bundle. -// -// This method is intended to unify two different models -// that share a common skeleton, for instance, different -// LOD's of the same model. -//////////////////////////////////////////////////////////////////// +/** + * Merges old_bundle_handle->get_bundle() with new_bundle. old_bundle_handle + * must be one of the PartBundleHandle within this node. At the end of this + * call, the bundle pointer within the old_bundle_handle will be replaced with + * that within the new_bundle_handle pointer, and all geometry within this + * node will be updated to reference new_bundle. + * + * Normally, this is called when the two bundles have the same, or nearly the + * same, hierarchies. In this case, new_bundle will simply be assigned over + * the old_bundle position. However, if any joints are present in one bundle + * or the other, new_bundle will be modified to contain the union of all + * joints. + * + * The geometry below this node is also updated to reference new_bundle, + * instead of the original old_bundle. + * + * This method is intended to unify two different models that share a common + * skeleton, for instance, different LOD's of the same model. + */ void Character:: -merge_bundles(PartBundleHandle *old_bundle_handle, +merge_bundles(PartBundleHandle *old_bundle_handle, PartBundleHandle *new_bundle_handle) { PartBundle *old_bundle = old_bundle_handle->get_bundle(); PartBundle *new_bundle = new_bundle_handle->get_bundle(); @@ -343,37 +296,28 @@ merge_bundles(PartBundleHandle *old_bundle_handle, update_bundle(old_bundle_handle, new_bundle); } -//////////////////////////////////////////////////////////////////// -// Function: Character::set_lod_animation -// Access: Published -// Description: Activates a special mode in which the character -// animates less frequently as it gets further from the -// camera. This is intended as a simple optimization to -// minimize the effort of computing animation for lots -// of characters that may not necessarily be very -// important to animate every frame. -// -// If the character is closer to the camera than -// near_distance, then it is animated its normal rate, -// every frame. If the character is exactly -// far_distance away, it is animated only every -// delay_factor seconds (which should be a number -// greater than 0). If the character is between -// near_distance and far_distance, its animation rate is -// linearly interpolated according to its distance -// between the two. The interpolation function -// continues beyond far_distance, so that the character -// is animated increasingly less frequently as it gets -// farther away. -// -// The distance calculations are made from center, which -// is a fixed point relative to the character node, to -// the camera's lod center or cull center node (or to -// the camera node itself). -// -// If multiple cameras are viewing the character in any -// given frame, the closest one counts. -//////////////////////////////////////////////////////////////////// +/** + * Activates a special mode in which the character animates less frequently as + * it gets further from the camera. This is intended as a simple optimization + * to minimize the effort of computing animation for lots of characters that + * may not necessarily be very important to animate every frame. + * + * If the character is closer to the camera than near_distance, then it is + * animated its normal rate, every frame. If the character is exactly + * far_distance away, it is animated only every delay_factor seconds (which + * should be a number greater than 0). If the character is between + * near_distance and far_distance, its animation rate is linearly interpolated + * according to its distance between the two. The interpolation function + * continues beyond far_distance, so that the character is animated + * increasingly less frequently as it gets farther away. + * + * The distance calculations are made from center, which is a fixed point + * relative to the character node, to the camera's lod center or cull center + * node (or to the camera node itself). + * + * If multiple cameras are viewing the character in any given frame, the + * closest one counts. + */ void Character:: set_lod_animation(const LPoint3 ¢er, PN_stdfloat far_distance, PN_stdfloat near_distance, @@ -390,14 +334,11 @@ set_lod_animation(const LPoint3 ¢er, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::clear_lod_animation -// Access: Published -// Description: Undoes the effect of a recent call to -// set_lod_animation(). Henceforth, the character will -// animate every frame, regardless of its distance from -// the camera. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a recent call to set_lod_animation(). Henceforth, the + * character will animate every frame, regardless of its distance from the + * camera. + */ void Character:: clear_lod_animation() { _lod_center = LPoint3::zero(); @@ -408,13 +349,11 @@ clear_lod_animation() { set_lod_current_delay(0.0); } -//////////////////////////////////////////////////////////////////// -// Function: Character::find_joint -// Access: Published -// Description: Returns a pointer to the joint with the given name, -// if there is such a joint, or NULL if there is no such -// joint. This will not return a pointer to a slider. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the joint with the given name, if there is such a + * joint, or NULL if there is no such joint. This will not return a pointer + * to a slider. + */ CharacterJoint *Character:: find_joint(const string &name) const { int num_bundles = get_num_bundles(); @@ -428,13 +367,11 @@ find_joint(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Character::find_slider -// Access: Published -// Description: Returns a pointer to the slider with the given name, -// if there is such a slider, or NULL if there is no such -// slider. This will not return a pointer to a joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the slider with the given name, if there is such a + * slider, or NULL if there is no such slider. This will not return a pointer + * to a joint. + */ CharacterSlider *Character:: find_slider(const string &name) const { int num_bundles = get_num_bundles(); @@ -449,13 +386,10 @@ find_slider(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Character::write_parts -// Access: Published -// Description: Writes a list of the Character's joints and sliders, -// in their hierchical structure, to the indicated -// output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the Character's joints and sliders, in their hierchical + * structure, to the indicated output stream. + */ void Character:: write_parts(ostream &out) const { int num_bundles = get_num_bundles(); @@ -464,13 +398,11 @@ write_parts(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::write_part_values -// Access: Published -// Description: Writes a list of the Character's joints and sliders, -// along with each current position, in their hierchical -// structure, to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the Character's joints and sliders, along with each + * current position, in their hierchical structure, to the indicated output + * stream. + */ void Character:: write_part_values(ostream &out) const { int num_bundles = get_num_bundles(); @@ -479,30 +411,24 @@ write_part_values(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::update_to_now -// Access: Published -// Description: Advances the character's frame to the current time, -// and then calls update(). This can be used by show -// code to force an update of the character's position -// to the current frame, regardless of whether the -// character is currently onscreen and animating. -// -// This method is deprecated. Call update() instead. -//////////////////////////////////////////////////////////////////// +/** + * Advances the character's frame to the current time, and then calls + * update(). This can be used by show code to force an update of the + * character's position to the current frame, regardless of whether the + * character is currently onscreen and animating. + * + * This method is deprecated. Call update() instead. + */ void Character:: update_to_now() { update(); } -//////////////////////////////////////////////////////////////////// -// Function: Character::update -// Access: Published -// Description: Recalculates the Character's joints and vertices for -// the current frame. Normally this is performed -// automatically during the render and need not be -// called explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the Character's joints and vertices for the current frame. + * Normally this is performed automatically during the render and need not be + * called explicitly. + */ void Character:: update() { double now = ClockObject::get_global_clock()->get_frame_time(); @@ -510,22 +436,19 @@ update() { _last_auto_update = now; if (char_cat.is_spam()) { - char_cat.spam() + char_cat.spam() << "Animating " << NodePath::any_path(this) << " at time " << now << "\n"; } - + PStatTimer timer(_joints_pcollector); do_update(); } } -//////////////////////////////////////////////////////////////////// -// Function: Character::force_update -// Access: Published -// Description: Recalculates the character even if we think it -// doesn't need it. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the character even if we think it doesn't need it. + */ void Character:: force_update() { // Statistics @@ -538,30 +461,25 @@ force_update() { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::r_copy_children -// Access: Protected, Virtual -// Description: This is called by r_copy_subgraph(); the copy has -// already been made of this particular node (and this -// is the copy); this function's job is to copy all of -// the children from the original. -// -// Note that it includes the parameter inst_map, which -// is a map type, and is not (and cannot be) exported -// from PANDA.DLL. Thus, any derivative of PandaNode -// that is not also a member of PANDA.DLL *cannot* -// access this map, and probably should not even -// override this function. -//////////////////////////////////////////////////////////////////// +/** + * This is called by r_copy_subgraph(); the copy has already been made of this + * particular node (and this is the copy); this function's job is to copy all + * of the children from the original. + * + * Note that it includes the parameter inst_map, which is a map type, and is + * not (and cannot be) exported from PANDA.DLL. Thus, any derivative of + * PandaNode that is not also a member of PANDA.DLL *cannot* access this map, + * and probably should not even override this function. + */ void Character:: r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, Thread *current_thread) { - // We assume there will be no instancing going on below the - // Character node. If there is, too bad; it will get flattened out. + // We assume there will be no instancing going on below the Character node. + // If there is, too bad; it will get flattened out. - // We preempt the node's r_copy_children() operation with our own - // function that keeps track of the old vs. new nodes and also - // updates any Geoms we find with our new dynamic vertices. + // We preempt the node's r_copy_children() operation with our own function + // that keeps track of the old vs. new nodes and also updates any Geoms we + // find with our new dynamic vertices. const Character *from_char; DCAST_INTO_V(from_char, from); @@ -578,7 +496,7 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, GeomVertexMap gvmap; GeomJointMap gjmap; GeomSliderMap gsmap; - r_copy_char(this, from_char, from_char, node_map, joint_map, + r_copy_char(this, from_char, from_char, node_map, joint_map, gvmap, gjmap, gsmap); for (i = 0; i < num_bundles; ++i) { @@ -586,13 +504,10 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::update_bundle -// Access: Protected, Virtual -// Description: Replaces the contents of the indicated -// PartBundleHandle (presumably stored within this node) -// with new_bundle. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the contents of the indicated PartBundleHandle (presumably stored + * within this node) with new_bundle. + */ void Character:: update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle) { if (old_bundle_handle->get_bundle() == new_bundle) { @@ -600,8 +515,8 @@ update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle) { return; } - // First, merge the bundles, to ensure we have the same set of - // joints in the new bundle. + // First, merge the bundles, to ensure we have the same set of joints in the + // new bundle. JointMap joint_map; r_merge_bundles(joint_map, old_bundle_handle->get_bundle(), new_bundle); @@ -614,28 +529,26 @@ update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle) { r_update_geom(this, joint_map, gvmap, gjmap, gsmap); } -//////////////////////////////////////////////////////////////////// -// Function: Character::get_rel_transform -// Access: Protected -// Description: Returns the relative transform to convert from the -// LODNode space to the camera space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform to convert from the LODNode space to the + * camera space. + */ CPT(TransformState) Character:: get_rel_transform(CullTraverser *trav, CullTraverserData &data) { // Get a pointer to the camera node. Camera *camera = trav->get_scene()->get_camera_node(); - + // Get the camera space transform. CPT(TransformState) rel_transform; NodePath lod_center = camera->get_lod_center(); if (!lod_center.is_empty()) { - rel_transform = + rel_transform = lod_center.get_net_transform()->invert_compose(data.get_net_transform(trav)); } else { NodePath cull_center = camera->get_cull_center(); if (!cull_center.is_empty()) { - rel_transform = + rel_transform = cull_center.get_net_transform()->invert_compose(data.get_net_transform(trav)); } else { rel_transform = data.get_modelview_transform(trav); @@ -645,12 +558,10 @@ get_rel_transform(CullTraverser *trav, CullTraverserData &data) { return rel_transform; } -//////////////////////////////////////////////////////////////////// -// Function: Character::do_update -// Access: Private -// Description: The actual implementation of update(). Assumes the -// appropriate PStatCollector has already been started. -//////////////////////////////////////////////////////////////////// +/** + * The actual implementation of update(). Assumes the appropriate + * PStatCollector has already been started. + */ void Character:: do_update() { // Update all the joints and sliders. @@ -667,12 +578,10 @@ do_update() { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::set_lod_current_delay -// Access: Private -// Description: Changes the amount of delay we should impose due to -// the LOD animation setting. -//////////////////////////////////////////////////////////////////// +/** + * Changes the amount of delay we should impose due to the LOD animation + * setting. + */ void Character:: set_lod_current_delay(double delay) { int num_bundles = get_num_bundles(); @@ -681,16 +590,13 @@ set_lod_current_delay(double delay) { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::fill_joint_map -// Access: Private -// Description: After the joint hierarchy has already been copied -// from the indicated hierarchy, this recursively walks -// through the joints and builds up a mapping from old -// to new. -//////////////////////////////////////////////////////////////////// +/** + * After the joint hierarchy has already been copied from the indicated + * hierarchy, this recursively walks through the joints and builds up a + * mapping from old to new. + */ void Character:: -fill_joint_map(Character::JointMap &joint_map, +fill_joint_map(Character::JointMap &joint_map, PartGroup *copy, PartGroup *orig) { joint_map[orig] = copy; @@ -714,16 +620,13 @@ fill_joint_map(Character::JointMap &joint_map, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::r_merge_bundles -// Access: Private -// Description: Recursively checks the two bundles for a matching -// hierarchy, and adds nodes as necessary to "new_group" -// where they are not already present. Also fills -// joint_map in the same manner as fill_joint_map(). -//////////////////////////////////////////////////////////////////// +/** + * Recursively checks the two bundles for a matching hierarchy, and adds nodes + * as necessary to "new_group" where they are not already present. Also fills + * joint_map in the same manner as fill_joint_map(). + */ void Character:: -r_merge_bundles(Character::JointMap &joint_map, +r_merge_bundles(Character::JointMap &joint_map, PartGroup *old_group, PartGroup *new_group) { joint_map[old_group] = new_group; @@ -739,12 +642,12 @@ r_merge_bundles(Character::JointMap &joint_map, CharacterJoint *old_joint; DCAST_INTO_V(old_joint, old_group); - // Since the old_joint will be getting dropped, reset its - // character reference. + // Since the old_joint will be getting dropped, reset its character + // reference. old_joint->_character = NULL; - // Copy any _net_transform and _local_transform operations to the - // new joint. + // Copy any _net_transform and _local_transform operations to the new + // joint. CharacterJoint::NodeList::iterator ni; for (ni = old_joint->_net_transform_nodes.begin(); ni != old_joint->_net_transform_nodes.end(); @@ -775,8 +678,8 @@ r_merge_bundles(Character::JointMap &joint_map, PartGroup *ac = new_group->get_child(j); if (pc->get_name() < ac->get_name()) { - // Here is a group that exists in old_group, but not in - // new_group. Duplicate it. + // Here is a group that exists in old_group, but not in new_group. + // Duplicate it. PartGroup *new_pc = pc->make_copy(); new_children.push_back(new_pc); @@ -784,8 +687,8 @@ r_merge_bundles(Character::JointMap &joint_map, i++; } else if (ac->get_name() < pc->get_name()) { - // Here is a group that exists in new_group, but not in - // old_group. Preserve it. + // Here is a group that exists in new_group, but not in old_group. + // Preserve it. new_children.push_back(ac); r_merge_bundles(joint_map, ac, ac); @@ -804,8 +707,8 @@ r_merge_bundles(Character::JointMap &joint_map, while (i < old_num_children) { PartGroup *pc = old_group->get_child(i); - // Here is a group that exists in old_group, but not in - // new_group. Duplicate it. + // Here is a group that exists in old_group, but not in new_group. + // Duplicate it. PartGroup *new_pc = pc->make_copy(); new_children.push_back(new_pc); @@ -816,8 +719,8 @@ r_merge_bundles(Character::JointMap &joint_map, while (j < new_num_children) { PartGroup *ac = new_group->get_child(j); - // Here is a group that exists in new_group, but not in - // old_group. Preserve it. + // Here is a group that exists in new_group, but not in old_group. + // Preserve it. new_children.push_back(ac); r_merge_bundles(joint_map, ac, ac); @@ -828,14 +731,11 @@ r_merge_bundles(Character::JointMap &joint_map, } -//////////////////////////////////////////////////////////////////// -// Function: Character::r_copy_char -// Access: Private -// Description: Recursively walks the scene graph hierarchy below the -// Character node, duplicating it while noting the -// orig:copy node mappings, and also updates any -// GeomNodes found. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the scene graph hierarchy below the Character node, + * duplicating it while noting the orig:copy node mappings, and also updates + * any GeomNodes found. + */ void Character:: r_copy_char(PandaNode *dest, const PandaNode *source, const Character *from, Character::NodeMap &node_map, @@ -865,17 +765,16 @@ r_copy_char(PandaNode *dest, const PandaNode *source, PT(PandaNode) dest_child; if (source_child->is_of_type(Character::get_class_type())) { - // We make a special case for nodes of type Character. If we - // encounter one of these, we have a Character under a - // Character, and the nested Character's copy should be called - // instead of ours. + // We make a special case for nodes of type Character. If we encounter + // one of these, we have a Character under a Character, and the nested + // Character's copy should be called instead of ours. dest_child = source_child->copy_subgraph(); } else { - // Otherwise, we assume that make_copy() will make a suitable - // copy of the node. This does limit the sorts of things we can - // have parented to a Character and expect copy_subgraph() to - // work correctly. Too bad. + // Otherwise, we assume that make_copy() will make a suitable copy of + // the node. This does limit the sorts of things we can have parented + // to a Character and expect copy_subgraph() to work correctly. Too + // bad. dest_child = source_child->make_copy(); r_copy_char(dest_child, source_child, from, node_map, joint_map, gvmap, gjmap, gsmap); @@ -885,17 +784,14 @@ r_copy_char(PandaNode *dest, const PandaNode *source, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::r_update_geom -// Access: Private -// Description: Walks the hierarchy, updating any GeomNodes in-place -// to reference the new animation tables within this -// Character. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, updating any GeomNodes in-place to reference the new + * animation tables within this Character. + */ void Character:: r_update_geom(PandaNode *node, const Character::JointMap &joint_map, Character::GeomVertexMap &gvmap, - Character::GeomJointMap &gjmap, + Character::GeomJointMap &gjmap, Character::GeomSliderMap &gsmap) { if (node->is_geom_node()) { GeomNode *gnode; @@ -917,26 +813,23 @@ r_update_geom(PandaNode *node, const Character::JointMap &joint_map, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::copy_geom -// Access: Private -// Description: Makes a new copy of the Geom with the dynamic vertex -// arrays replaced to reference this Character instead -// of the other one. If no arrays have changed, simply -// returns the same Geom. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new copy of the Geom with the dynamic vertex arrays replaced to + * reference this Character instead of the other one. If no arrays have + * changed, simply returns the same Geom. + */ PT(Geom) Character:: copy_geom(const Geom *source, const Character::JointMap &joint_map, - Character::GeomVertexMap &gvmap, Character::GeomJointMap &gjmap, + Character::GeomVertexMap &gvmap, Character::GeomJointMap &gjmap, Character::GeomSliderMap &gsmap) { CPT(GeomVertexFormat) format = source->get_vertex_data()->get_format(); if (format->get_animation().get_animation_type() == Geom::AT_none) { // Not animated, so never mind. return (Geom *)source; } - + PT(Geom) dest = source->make_copy(); - + CPT(GeomVertexData) orig_vdata = source->get_vertex_data(); PT(GeomVertexData) new_vdata; GeomVertexMap::iterator gvmi = gvmap.find(orig_vdata); @@ -950,20 +843,17 @@ copy_geom(const Geom *source, const Character::JointMap &joint_map, new_vdata->set_slider_table(redirect_slider_table(orig_vdata->get_slider_table(), gsmap)); gvmap.insert(GeomVertexMap::value_type(orig_vdata, new_vdata)); - } + } dest->set_vertex_data(new_vdata); - + return dest; } -//////////////////////////////////////////////////////////////////// -// Function: Character::copy_node_pointers -// Access: Public -// Description: Creates _net_transform_nodes and _local_transform_nodes -// as appropriate in each of the Character's joints, as -// copied from the other Character. -//////////////////////////////////////////////////////////////////// +/** + * Creates _net_transform_nodes and _local_transform_nodes as appropriate in + * each of the Character's joints, as copied from the other Character. + */ void Character:: copy_node_pointers(const Character::NodeMap &node_map, PartGroup *dest, const PartGroup *source) { @@ -973,39 +863,37 @@ copy_node_pointers(const Character::NodeMap &node_map, CharacterJoint *dest_joint; DCAST_INTO_V(source_joint, source); DCAST_INTO_V(dest_joint, dest); - + CharacterJoint::NodeList::const_iterator ai; for (ai = source_joint->_net_transform_nodes.begin(); ai != source_joint->_net_transform_nodes.end(); ++ai) { PandaNode *source_node = (*ai); - + NodeMap::const_iterator mi; mi = node_map.find(source_node); if (mi != node_map.end()) { PandaNode *dest_node = (*mi).second; - - // Here's an internal joint that the source Character was - // animating directly. We'll animate our corresponding - // joint the same way. + + // Here's an internal joint that the source Character was animating + // directly. We'll animate our corresponding joint the same way. dest_joint->set_character(this); dest_joint->add_net_transform(dest_node); } } - + for (ai = source_joint->_local_transform_nodes.begin(); ai != source_joint->_local_transform_nodes.end(); ++ai) { PandaNode *source_node = (*ai); - + NodeMap::const_iterator mi; mi = node_map.find(source_node); if (mi != node_map.end()) { PandaNode *dest_node = (*mi).second; - - // Here's an internal joint that the source Character was - // animating directly. We'll animate our corresponding - // joint the same way. + + // Here's an internal joint that the source Character was animating + // directly. We'll animate our corresponding joint the same way. dest_joint->set_character(this); dest_joint->add_local_transform(dest_node); } @@ -1033,13 +921,10 @@ copy_node_pointers(const Character::NodeMap &node_map, } } -//////////////////////////////////////////////////////////////////// -// Function: Character::redirect_transform_table -// Access: Private -// Description: Creates a new TransformTable, similar to the -// indicated one, with the joint and slider pointers -// redirected into this object. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new TransformTable, similar to the indicated one, with the joint + * and slider pointers redirected into this object. + */ CPT(TransformTable) Character:: redirect_transform_table(const TransformTable *source, const Character::JointMap &joint_map, @@ -1062,13 +947,10 @@ redirect_transform_table(const TransformTable *source, return TransformTable::register_table(dest); } -//////////////////////////////////////////////////////////////////// -// Function: Character::redirect_transform_blend_table -// Access: Private -// Description: Creates a new TransformBlendTable, similar to the -// indicated one, with the joint and slider pointers -// redirected into this object. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new TransformBlendTable, similar to the indicated one, with the + * joint and slider pointers redirected into this object. + */ CPT(TransformBlendTable) Character:: redirect_transform_blend_table(const TransformBlendTable *source, const Character::JointMap &joint_map, @@ -1096,13 +978,10 @@ redirect_transform_blend_table(const TransformBlendTable *source, return dest; } -//////////////////////////////////////////////////////////////////// -// Function: Character::redirect_slider_table -// Access: Private -// Description: Creates a new SliderTable, similar to the -// indicated one, with the joint and slider pointers -// redirected into this object. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new SliderTable, similar to the indicated one, with the joint and + * slider pointers redirected into this object. + */ CPT(SliderTable) Character:: redirect_slider_table(const SliderTable *source, Character::GeomSliderMap &gsmap) { @@ -1124,16 +1003,13 @@ redirect_slider_table(const SliderTable *source, return SliderTable::register_table(dest); } -//////////////////////////////////////////////////////////////////// -// Function: Character::redirect_joint -// Access: Private -// Description: Creates a new JointVertexTransform that is similar to -// the indicated one, but points into this character. -// If one was already created (in the GeomJointMap), returns -// it instead. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new JointVertexTransform that is similar to the indicated one, + * but points into this character. If one was already created (in the + * GeomJointMap), returns it instead. + */ PT(JointVertexTransform) Character:: -redirect_joint(const VertexTransform *vt, +redirect_joint(const VertexTransform *vt, const Character::JointMap &joint_map, Character::GeomJointMap &gjmap) { GeomJointMap::iterator ji; @@ -1143,7 +1019,7 @@ redirect_joint(const VertexTransform *vt, } PT(JointVertexTransform) new_jvt; - + if (vt->is_of_type(JointVertexTransform::get_class_type())) { const JointVertexTransform *jvt = DCAST(JointVertexTransform, vt); const CharacterJoint *orig_joint = jvt->get_joint(); @@ -1163,14 +1039,11 @@ redirect_joint(const VertexTransform *vt, return new_jvt; } -//////////////////////////////////////////////////////////////////// -// Function: Character::redirect_slider -// Access: Private -// Description: Creates a new CharacterVertexSlider that is similar to -// the indicated one, but points into this character. -// If one was already created (in the GeomSliderMap), returns -// it instead. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new CharacterVertexSlider that is similar to the indicated one, + * but points into this character. If one was already created (in the + * GeomSliderMap), returns it instead. + */ PT(CharacterVertexSlider) Character:: redirect_slider(const VertexSlider *vs, Character::GeomSliderMap &gsmap) { GeomSliderMap::iterator ji; @@ -1193,23 +1066,20 @@ redirect_slider(const VertexSlider *vs, Character::GeomSliderMap &gsmap) { return new_cvs; } -//////////////////////////////////////////////////////////////////// -// Function: Character::r_clear_joint_characters -// Access: Private -// Description: Recursively walks through the joint hierarchy and -// clears any _character pointers on all the joints. -// Intended to be called just before Character -// destruction. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the joint hierarchy and clears any _character + * pointers on all the joints. Intended to be called just before Character + * destruction. + */ void Character:: r_clear_joint_characters(PartGroup *part) { if (part->is_character_joint()) { CharacterJoint *joint = DCAST(CharacterJoint, part); - // It is possible for the joint to reference a different Character - // here--after merge_bundles() has been called, a particular joint - // will be listed within more than one Character node, but it can - // only point back to one of them. + // It is possible for the joint to reference a different Character here-- + // after merge_bundles() has been called, a particular joint will be + // listed within more than one Character node, but it can only point back + // to one of them. if (joint->get_character() == this) { joint->set_character(NULL); } @@ -1222,23 +1092,18 @@ r_clear_joint_characters(PartGroup *part) { } } -//////////////////////////////////////////////////////////////////// -// Function: Character::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Character. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Character. + */ void Character:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Character::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Character:: write_datagram(BamWriter *manager, Datagram &dg) { PartBundleNode::write_datagram(manager, dg); @@ -1247,28 +1112,22 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint16(0); } -//////////////////////////////////////////////////////////////////// -// Function: Character::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int Character:: complete_pointers(TypedWritable **p_list, BamReader *manager) { - // Pretend to read the _temp_num_parts parts that were found in the - // bam file. + // Pretend to read the _temp_num_parts parts that were found in the bam + // file. return PartBundleNode::complete_pointers(p_list, manager) + _temp_num_parts; } -//////////////////////////////////////////////////////////////////// -// Function: Character::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Character is encountered -// in the Bam file. It should create the Character -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Character is encountered in the Bam file. It should create the + * Character and extract its information from the file. + */ TypedWritable *Character:: make_from_bam(const FactoryParams ¶ms) { Character *node = new Character(""); @@ -1281,20 +1140,17 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: Character::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Character. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Character. + */ void Character:: fillin(DatagramIterator &scan, BamReader *manager) { PartBundleNode::fillin(scan, manager); - // We no longer read an array of parts here, but for backward - // compatibility, we must read in the number of parts that used to - // be there, and read past each of the pointers. + // We no longer read an array of parts here, but for backward compatibility, + // we must read in the number of parts that used to be there, and read past + // each of the pointers. _temp_num_parts = scan.get_uint16(); for (unsigned int i = 0; i < _temp_num_parts; i++) { manager->read_pointer(scan); @@ -1303,9 +1159,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { #ifdef DO_PSTATS // Reinitialize our collectors with our name, now that we know it. if (has_name()) { - _joints_pcollector = + _joints_pcollector = PStatCollector(PStatCollector(_animation_pcollector, get_name()), "Joints"); - _skinning_pcollector = + _skinning_pcollector = PStatCollector(PStatCollector(_animation_pcollector, get_name()), "Vertices"); } #endif diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 91c2f2bce2..ca040d586b 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -1,16 +1,15 @@ -// Filename: character.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file character.h + * @author drose + * @date 2002-03-06 + */ #ifndef CHARACTER_H #define CHARACTER_H @@ -33,11 +32,10 @@ class CharacterJointBundle; class ComputedVertices; -//////////////////////////////////////////////////////////////////// -// Class : Character -// Description : An animated character, with skeleton-morph animation -// and either soft-skinned or hard-skinned vertices. -//////////////////////////////////////////////////////////////////// +/** + * An animated character, with skeleton-morph animation and either soft- + * skinned or hard-skinned vertices. + */ class EXPCL_PANDA_CHAR Character : public PartBundleNode { protected: Character(const Character ©, bool copy_bundles); @@ -59,14 +57,14 @@ public: Thread *current_thread) const; PUBLISHED: - virtual PandaNode *combine_with(PandaNode *other); + virtual PandaNode *combine_with(PandaNode *other); INLINE CharacterJointBundle *get_bundle(int i) const; void merge_bundles(PartBundle *old_bundle, PartBundle *other_bundle); - void merge_bundles(PartBundleHandle *old_bundle_handle, + void merge_bundles(PartBundleHandle *old_bundle_handle, PartBundleHandle *other_bundle_handle); - void set_lod_animation(const LPoint3 ¢er, + void set_lod_animation(const LPoint3 ¢er, PN_stdfloat far_distance, PN_stdfloat near_distance, PN_stdfloat delay_factor); void clear_lod_animation(); @@ -84,7 +82,7 @@ PUBLISHED: protected: virtual void r_copy_children(const PandaNode *from, InstanceMap &inst_map, Thread *current_thread); - virtual void update_bundle(PartBundleHandle *old_bundle_handle, + virtual void update_bundle(PartBundleHandle *old_bundle_handle, PartBundle *new_bundle); CPT(TransformState) get_rel_transform(CullTraverser *trav, CullTraverserData &data); @@ -99,7 +97,7 @@ private: typedef pmap GeomSliderMap; void fill_joint_map(JointMap &joint_map, PartGroup *copy, PartGroup *orig); - void r_merge_bundles(Character::JointMap &joint_map, + void r_merge_bundles(Character::JointMap &joint_map, PartGroup *old_group, PartGroup *new_group); void r_copy_char(PandaNode *dest, const PandaNode *source, const Character *from, NodeMap &node_map, @@ -108,7 +106,7 @@ private: void r_update_geom(PandaNode *node, const JointMap &joint_map, GeomVertexMap &gvmap, GeomJointMap &gjmap, GeomSliderMap &gsmap); - PT(Geom) copy_geom(const Geom *source, + PT(Geom) copy_geom(const Geom *source, const JointMap &joint_map, GeomVertexMap &gvmap, GeomJointMap &gjmap, GeomSliderMap &gsmap); void copy_node_pointers(const Character::NodeMap &node_map, @@ -123,16 +121,15 @@ private: CPT(SliderTable) redirect_slider_table(const SliderTable *source, GeomSliderMap &gsmap); - PT(JointVertexTransform) redirect_joint(const VertexTransform *vt, + PT(JointVertexTransform) redirect_joint(const VertexTransform *vt, const JointMap &joint_map, GeomJointMap &gjmap); PT(CharacterVertexSlider) redirect_slider(const VertexSlider *vs, GeomSliderMap &gsmap); void r_clear_joint_characters(PartGroup *part); - // into our joints and sliders. - //typedef vector_PartGroupStar Parts; - //Parts _parts; + // into our joints and sliders. typedef vector_PartGroupStar Parts; Parts + // _parts; double _last_auto_update; @@ -150,8 +147,7 @@ private: PStatCollector _skinning_pcollector; static PStatCollector _animation_pcollector; - // This variable is only used temporarily, while reading from the - // bam file. + // This variable is only used temporarily, while reading from the bam file. unsigned int _temp_num_parts; public: @@ -163,7 +159,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: virtual TypeHandle get_type() const { return get_class_type(); @@ -185,4 +181,3 @@ private: #include "character.I" #endif - diff --git a/panda/src/char/characterJoint.I b/panda/src/char/characterJoint.I index b087eeaf58..c8aac8944e 100644 --- a/panda/src/char/characterJoint.I +++ b/panda/src/char/characterJoint.I @@ -1,23 +1,20 @@ -// Filename: characterJoint.I -// Created by: drose (20Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJoint.I + * @author drose + * @date 2008-11-20 + */ -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_transform -// Access: Published -// Description: Returns the transform matrix of the joint -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix of the joint + */ INLINE const LMatrix4 &CharacterJoint:: get_transform() const { return _value; -} \ No newline at end of file +} diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 32b042d479..77b3a99e32 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -1,16 +1,15 @@ -// Filename: characterJoint.cxx -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJoint.cxx + * @author drose + * @date 1999-02-23 + */ #include "characterJoint.h" #include "config_char.h" @@ -23,22 +22,18 @@ TypeHandle CharacterJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::Default Constructor -// Access: Protected -// Description: For internal use only. -//////////////////////////////////////////////////////////////////// +/** + * For internal use only. + */ CharacterJoint:: CharacterJoint() : _character(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterJoint:: CharacterJoint(const CharacterJoint ©) : MovingPartMatrix(copy), @@ -49,11 +44,9 @@ CharacterJoint(const CharacterJoint ©) : // We don't copy the sets of transform nodes. } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterJoint:: CharacterJoint(Character *character, PartBundle *root, PartGroup *parent, const string &name, @@ -67,79 +60,68 @@ CharacterJoint(Character *character, // update_internals() to get our _net_transform set properly. update_internals(root, parent, true, false, current_thread); - // And then compute its inverse. This is needed for - // ComputedVertices, during animation. + // And then compute its inverse. This is needed for ComputedVertices, + // during animation. _initial_net_transform_inverse = invert(_net_transform); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterJoint:: ~CharacterJoint() { nassertv(_vertex_transforms.empty()); nassertv(_character == (Character *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::is_character_joint -// Access: Public, Virtual -// Description: Returns true if this part is a CharacterJoint, false -// otherwise. This is a tiny optimization over -// is_of_type(CharacterType::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this part is a CharacterJoint, false otherwise. This is a + * tiny optimization over is_of_type(CharacterType::get_class_type()). + */ bool CharacterJoint:: is_character_joint() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the node. -// Children are not copied, but see copy_subgraph(). -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the node. Children are not copied, but + * see copy_subgraph(). + */ PartGroup *CharacterJoint:: make_copy() const { return new CharacterJoint(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::update_internals -// Access: Public, Virtual -// Description: This is called by do_update() whenever the part or -// some ancestor has changed values. It is a hook for -// derived classes to update whatever cache they may -// have that depends on these. -// -// The return value is true if the part has changed as a -// result of the update, or false otherwise. -// -// In the case of a CharacterJoint, of course, it means -// to recompute the joint angles and associated -// transforms for this particular joint. -//////////////////////////////////////////////////////////////////// +/** + * This is called by do_update() whenever the part or some ancestor has + * changed values. It is a hook for derived classes to update whatever cache + * they may have that depends on these. + * + * The return value is true if the part has changed as a result of the update, + * or false otherwise. + * + * In the case of a CharacterJoint, of course, it means to recompute the joint + * angles and associated transforms for this particular joint. + */ bool CharacterJoint:: -update_internals(PartBundle *root, PartGroup *parent, bool self_changed, +update_internals(PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread) { nassertr(parent != (PartGroup *)NULL, false); bool net_changed = false; if (parent->is_character_joint()) { - // The joint is not a toplevel joint; its parent therefore affects - // its net transform. + // The joint is not a toplevel joint; its parent therefore affects its net + // transform. if (parent_changed || self_changed) { CharacterJoint *parent_joint = DCAST(CharacterJoint, parent); - + _net_transform = _value * parent_joint->_net_transform; net_changed = true; } } else { - // The joint is a toplevel joint, so therefore it gets its root - // transform from the bundle. + // The joint is a toplevel joint, so therefore it gets its root transform + // from the bundle. if (self_changed) { _net_transform = _value * root->get_root_xform(); net_changed = true; @@ -149,7 +131,7 @@ update_internals(PartBundle *root, PartGroup *parent, bool self_changed, if (net_changed) { if (!_net_transform_nodes.empty()) { CPT(TransformState) t = TransformState::make_mat(_net_transform); - + NodeList::iterator ai; for (ai = _net_transform_nodes.begin(); ai != _net_transform_nodes.end(); @@ -159,8 +141,8 @@ update_internals(PartBundle *root, PartGroup *parent, bool self_changed, } } - // Also tell our related JointVertexTransforms that they now need - // to recompute themselves. + // Also tell our related JointVertexTransforms that they now need to + // recompute themselves. VertexTransforms::iterator vti; for (vti = _vertex_transforms.begin(); vti != _vertex_transforms.end(); ++vti) { (*vti)->_matrix_stale = true; @@ -183,13 +165,10 @@ update_internals(PartBundle *root, PartGroup *parent, bool self_changed, return self_changed || net_changed; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::do_xform -// Access: Public, Virtual -// Description: Called by PartBundle::xform(), this indicates the -// indicated transform is being applied to the root -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Called by PartBundle::xform(), this indicates the indicated transform is + * being applied to the root joint. + */ void CharacterJoint:: do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { _initial_net_transform_inverse = inv_mat * _initial_net_transform_inverse; @@ -199,18 +178,14 @@ do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat) { -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::add_net_transform -// Access: Published -// Description: Adds the indicated node to the list of nodes that will -// be updated each frame with the joint's net transform -// from the root. Returns true if the node is -// successfully added, false if it had already been -// added. -// -// A CharacterJointEffect for this joint's Character -// will automatically be added to the specified node. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated node to the list of nodes that will be updated each + * frame with the joint's net transform from the root. Returns true if the + * node is successfully added, false if it had already been added. + * + * A CharacterJointEffect for this joint's Character will automatically be + * added to the specified node. + */ bool CharacterJoint:: add_net_transform(PandaNode *node) { if (_character != (Character *)NULL) { @@ -221,18 +196,14 @@ add_net_transform(PandaNode *node) { return _net_transform_nodes.insert(node).second; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::remove_net_transform -// Access: Published -// Description: Removes the indicated node from the list of nodes that -// will be updated each frame with the joint's net -// transform from the root. Returns true if the node is -// successfully removed, false if it was not on the -// list. -// -// If the node has a CharacterJointEffect that matches -// this joint's Character, it will be cleared. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated node from the list of nodes that will be updated each + * frame with the joint's net transform from the root. Returns true if the + * node is successfully removed, false if it was not on the list. + * + * If the node has a CharacterJointEffect that matches this joint's Character, + * it will be cleared. + */ bool CharacterJoint:: remove_net_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); @@ -244,25 +215,19 @@ remove_net_transform(PandaNode *node) { return (_net_transform_nodes.erase(node) > 0); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::has_net_transform -// Access: Published -// Description: Returns true if the node is on the list of nodes that -// will be updated each frame with the joint's net -// transform from the root, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is on the list of nodes that will be updated each + * frame with the joint's net transform from the root, false otherwise. + */ bool CharacterJoint:: has_net_transform(PandaNode *node) const { return (_net_transform_nodes.count(node) > 0); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::clear_net_transforms -// Access: Published -// Description: Removes all nodes from the list of nodes that will be -// updated each frame with the joint's net transform -// from the root. -//////////////////////////////////////////////////////////////////// +/** + * Removes all nodes from the list of nodes that will be updated each frame + * with the joint's net transform from the root. + */ void CharacterJoint:: clear_net_transforms() { NodeList::iterator ai; @@ -281,14 +246,11 @@ clear_net_transforms() { _net_transform_nodes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_net_transforms -// Access: Published -// Description: Returns a list of the net transforms set for this -// node. Note that this returns a list of NodePaths, -// even though the net transforms are actually a list of -// PandaNodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of the net transforms set for this node. Note that this + * returns a list of NodePaths, even though the net transforms are actually a + * list of PandaNodes. + */ NodePathCollection CharacterJoint:: get_net_transforms() { NodePathCollection npc; @@ -304,23 +266,18 @@ get_net_transforms() { return npc; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::add_local_transform -// Access: Published -// Description: Adds the indicated node to the list of nodes that will -// be updated each frame with the joint's local -// transform from its parent. Returns true if the node -// is successfully added, false if it had already been -// added. -// -// The Character pointer should be the Character object -// that owns this joint; this will be used to create a -// CharacterJointEffect for this node. If it is NULL, -// no such effect will be created. -// -// A CharacterJointEffect for this joint's Character -// will automatically be added to the specified node. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated node to the list of nodes that will be updated each + * frame with the joint's local transform from its parent. Returns true if + * the node is successfully added, false if it had already been added. + * + * The Character pointer should be the Character object that owns this joint; + * this will be used to create a CharacterJointEffect for this node. If it is + * NULL, no such effect will be created. + * + * A CharacterJointEffect for this joint's Character will automatically be + * added to the specified node. + */ bool CharacterJoint:: add_local_transform(PandaNode *node) { if (_character != (Character *)NULL) { @@ -331,18 +288,14 @@ add_local_transform(PandaNode *node) { return _local_transform_nodes.insert(node).second; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::remove_local_transform -// Access: Published -// Description: Removes the indicated node from the list of nodes that -// will be updated each frame with the joint's local -// transform from its parent. Returns true if the node -// is successfully removed, false if it was not on the -// list. -// -// If the node has a CharacterJointEffect that matches -// this joint's Character, it will be cleared. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated node from the list of nodes that will be updated each + * frame with the joint's local transform from its parent. Returns true if + * the node is successfully removed, false if it was not on the list. + * + * If the node has a CharacterJointEffect that matches this joint's Character, + * it will be cleared. + */ bool CharacterJoint:: remove_local_transform(PandaNode *node) { CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); @@ -354,25 +307,19 @@ remove_local_transform(PandaNode *node) { return (_local_transform_nodes.erase(node) > 0); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::has_local_transform -// Access: Published -// Description: Returns true if the node is on the list of nodes that -// will be updated each frame with the joint's local -// transform from its parent, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is on the list of nodes that will be updated each + * frame with the joint's local transform from its parent, false otherwise. + */ bool CharacterJoint:: has_local_transform(PandaNode *node) const { return (_local_transform_nodes.count(node) > 0); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::clear_local_transforms -// Access: Published -// Description: Removes all nodes from the list of nodes that will be -// updated each frame with the joint's local transform -// from its parent. -//////////////////////////////////////////////////////////////////// +/** + * Removes all nodes from the list of nodes that will be updated each frame + * with the joint's local transform from its parent. + */ void CharacterJoint:: clear_local_transforms() { NodeList::iterator ai; @@ -391,14 +338,11 @@ clear_local_transforms() { _local_transform_nodes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_local_transforms -// Access: Published -// Description: Returns a list of the local transforms set for this -// node. Note that this returns a list of NodePaths, -// even though the local transforms are actually a list of -// PandaNodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of the local transforms set for this node. Note that this + * returns a list of NodePaths, even though the local transforms are actually + * a list of PandaNodes. + */ NodePathCollection CharacterJoint:: get_local_transforms() { NodePathCollection npc; @@ -414,12 +358,9 @@ get_local_transforms() { return npc; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_transform -// Access: Published -// Description: Copies the joint's current transform into the -// indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Copies the joint's current transform into the indicated matrix. + */ void CharacterJoint:: get_transform(LMatrix4 &transform) const { transform = _value; @@ -430,40 +371,32 @@ get_transform_state() const { return TransformState::make_mat( _value ); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_net_transform -// Access: Published -// Description: Copies the joint's current net transform (composed -// from the root of the character joint hierarchy) into -// the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Copies the joint's current net transform (composed from the root of the + * character joint hierarchy) into the indicated matrix. + */ void CharacterJoint:: get_net_transform(LMatrix4 &transform) const { transform = _net_transform; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::get_character -// Access: Published -// Description: Returns the Character that owns this joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Character that owns this joint. + */ Character *CharacterJoint:: get_character() const { return _character; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::set_character -// Access: Private -// Description: Changes the Character that owns this joint. -//////////////////////////////////////////////////////////////////// +/** + * Changes the Character that owns this joint. + */ void CharacterJoint:: set_character(Character *character) { if (character != _character) { if (character != (Character *)NULL) { - // Change or set a _character pointer on each joint's exposed - // node. + // Change or set a _character pointer on each joint's exposed node. NodeList::iterator ai; for (ai = _net_transform_nodes.begin(); ai != _net_transform_nodes.end(); @@ -485,7 +418,7 @@ set_character(Character *character) { ai != _net_transform_nodes.end(); ++ai) { PandaNode *node = *ai; - + CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && DCAST(CharacterJointEffect, effect)->get_character() == _character) { @@ -496,7 +429,7 @@ set_character(Character *character) { ai != _local_transform_nodes.end(); ++ai) { PandaNode *node = *ai; - + CPT(RenderEffect) effect = node->get_effect(CharacterJointEffect::get_class_type()); if (effect != (RenderEffect *)NULL && DCAST(CharacterJointEffect, effect)->get_character() == _character) { @@ -505,16 +438,14 @@ set_character(Character *character) { } } } - + _character = character; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CharacterJoint:: write_datagram(BamWriter *manager, Datagram &me) { NodeList::iterator ni; @@ -523,15 +454,15 @@ write_datagram(BamWriter *manager, Datagram &me) { manager->write_pointer(me, _character); me.add_uint16(_net_transform_nodes.size()); - for (ni = _net_transform_nodes.begin(); - ni != _net_transform_nodes.end(); + for (ni = _net_transform_nodes.begin(); + ni != _net_transform_nodes.end(); ni++) { manager->write_pointer(me, (*ni)); } me.add_uint16(_local_transform_nodes.size()); - for (ni = _local_transform_nodes.begin(); - ni != _local_transform_nodes.end(); + for (ni = _local_transform_nodes.begin(); + ni != _local_transform_nodes.end(); ni++) { manager->write_pointer(me, (*ni)); } @@ -539,14 +470,11 @@ write_datagram(BamWriter *manager, Datagram &me) { _initial_net_transform_inverse.write_datagram(me); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CharacterJoint:: fillin(DatagramIterator &scan, BamReader *manager) { int i; @@ -560,7 +488,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { for(i = 0; i < _num_net_nodes; i++) { manager->read_pointer(scan); } - + _num_local_nodes = scan.get_uint16(); for(i = 0; i < _num_local_nodes; i++) { manager->read_pointer(scan); @@ -569,13 +497,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { _initial_net_transform_inverse.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::complete_pointers -// Access: Public -// Description: Takes in a vector of pointers to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Takes in a vector of pointers to TypedWritable objects that correspond to + * all the requests for pointers that this object made to BamReader. + */ int CharacterJoint:: complete_pointers(TypedWritable **p_list, BamReader* manager) { int pi = MovingPartMatrix::complete_pointers(p_list, manager); @@ -600,11 +525,9 @@ complete_pointers(TypedWritable **p_list, BamReader* manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::make_CharacterJoint -// Access: Protected -// Description: Factory method to generate a CharacterJoint object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterJoint object + */ TypedWritable* CharacterJoint:: make_CharacterJoint(const FactoryParams ¶ms) { CharacterJoint *me = new CharacterJoint; @@ -616,14 +539,10 @@ make_CharacterJoint(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJoint::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CharacterJoint object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterJoint object + */ void CharacterJoint:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CharacterJoint); } - - diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index 00aa74437b..10f73a22a3 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -1,16 +1,15 @@ -// Filename: characterJoint.h -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJoint.h + * @author drose + * @date 1999-02-23 + */ #ifndef CHARACTERJOINT_H #define CHARACTERJOINT_H @@ -26,11 +25,10 @@ class JointVertexTransform; class Character; -//////////////////////////////////////////////////////////////////// -// Class : CharacterJoint -// Description : This represents one joint of the character's -// animation, containing an animating transform matrix. -//////////////////////////////////////////////////////////////////// +/** + * This represents one joint of the character's animation, containing an + * animating transform matrix. + */ class EXPCL_PANDA_CHAR CharacterJoint : public MovingPartMatrix { protected: CharacterJoint(); @@ -46,8 +44,8 @@ public: virtual bool is_character_joint() const; virtual PartGroup *make_copy() const; - virtual bool update_internals(PartBundle *root, PartGroup *parent, - bool self_changed, bool parent_changed, + virtual bool update_internals(PartBundle *root, PartGroup *parent, + bool self_changed, bool parent_changed, Thread *current_thread); virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat); @@ -65,9 +63,9 @@ PUBLISHED: NodePathCollection get_local_transforms(); void get_transform(LMatrix4 &transform) const; - INLINE const LMatrix4 &get_transform() const; - CPT(TransformState) get_transform_state() const; - + INLINE const LMatrix4 &get_transform() const; + CPT(TransformState) get_transform_state() const; + void get_net_transform(LMatrix4 &transform) const; Character *get_character() const; @@ -101,10 +99,9 @@ private: int _num_net_nodes, _num_local_nodes; public: - // The _geom_node member just holds a temporary pointer to a node - // for the CharacterMaker's convenenience while creating the - // character. It does not store any meaningful value after - // creation is complete. + // The _geom_node member just holds a temporary pointer to a node for the + // CharacterMaker's convenenience while creating the character. It does not + // store any meaningful value after creation is complete. PT(PandaNode) _geom_node; // These are filled in as the joint animates. @@ -136,5 +133,3 @@ private: #include "characterJoint.I" #endif - - diff --git a/panda/src/char/characterJointBundle.I b/panda/src/char/characterJointBundle.I index 10108d9fae..0752766ab1 100644 --- a/panda/src/char/characterJointBundle.I +++ b/panda/src/char/characterJointBundle.I @@ -1,41 +1,34 @@ -// Filename: characterJointBundle.I -// Created by: drose (02Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointBundle.I + * @author drose + * @date 1999-03-02 + */ -// This comment tells ppremake that we know this is a circular -// #include reference, and please don't bother us about it. The line -// must be exactly as shown. +// This comment tells ppremake that we know this is a circular #include +// reference, and please don't bother us about it. The line must be exactly +// as shown. /* okcircular */ #include "character.h" -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::Copy Constructor -// Access: Public -// Description: Normally, you'd use make_copy() or copy_subgraph() to -// make a copy of this. -//////////////////////////////////////////////////////////////////// +/** + * Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. + */ INLINE CharacterJointBundle:: CharacterJointBundle(const CharacterJointBundle ©) : PartBundle(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::get_node -// Access: Public -// Description: Returns the nth Character associated with -// this PartBundle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Character associated with this PartBundle. + */ INLINE Character *CharacterJointBundle:: get_node(int n) const { return DCAST(Character, PartBundle::get_node(n)); diff --git a/panda/src/char/characterJointBundle.cxx b/panda/src/char/characterJointBundle.cxx index ba045369c4..e6bf4061a7 100644 --- a/panda/src/char/characterJointBundle.cxx +++ b/panda/src/char/characterJointBundle.cxx @@ -1,16 +1,15 @@ -// Filename: characterJointBundle.cxx -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointBundle.cxx + * @author drose + * @date 1999-02-23 + */ #include "characterJointBundle.h" #include "datagram.h" @@ -20,45 +19,35 @@ TypeHandle CharacterJointBundle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::Constructor -// Access: Public -// Description: Normally, there is no need to create a -// CharacterJointBundle directly. The Character node -// will automatically create one for itself. -//////////////////////////////////////////////////////////////////// +/** + * Normally, there is no need to create a CharacterJointBundle directly. The + * Character node will automatically create one for itself. + */ CharacterJointBundle:: CharacterJointBundle(const string &name) : PartBundle(name) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterJointBundle:: ~CharacterJointBundle() { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::make_copy -// Access: Protected, Virtual -// Description: Allocates and returns a new copy of the node. -// Children are not copied, but see copy_subgraph(). -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the node. Children are not copied, but + * see copy_subgraph(). + */ PartGroup *CharacterJointBundle:: make_copy() const { return new CharacterJointBundle(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::add_node -// Access: Protected, Virtual -// Description: Adds the PartBundleNode pointer to the set of nodes -// associated with the PartBundle. Normally called only -// by the PartBundleNode itself, for instance when the -// bundle is flattened with another node. -//////////////////////////////////////////////////////////////////// +/** + * Adds the PartBundleNode pointer to the set of nodes associated with the + * PartBundle. Normally called only by the PartBundleNode itself, for + * instance when the bundle is flattened with another node. + */ void CharacterJointBundle:: add_node(PartBundleNode *node) { PartBundle::add_node(node); @@ -68,37 +57,30 @@ add_node(PartBundleNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::remove_node -// Access: Protected, Virtual -// Description: Removes the PartBundleNode pointer from the set of -// nodes associated with the PartBundle. Normally -// called only by the PartBundleNode itself, for -// instance when the bundle is flattened with another -// node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the PartBundleNode pointer from the set of nodes associated with + * the PartBundle. Normally called only by the PartBundleNode itself, for + * instance when the bundle is flattened with another node. + */ void CharacterJointBundle:: remove_node(PartBundleNode *node) { PartBundle::remove_node(node); - // If there is still a Character on the list, assign that one to all - // of the joints. + // If there is still a Character on the list, assign that one to all of the + // joints. if (get_num_nodes() > 0) { r_set_character(this, get_node(get_num_nodes() - 1)); } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::r_set_character -// Access: Private -// Description: Recursively sets the Character on each joint in the -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Recursively sets the Character on each joint in the hierarchy. + */ void CharacterJointBundle:: r_set_character(PartGroup *group, Character *character) { if (group == (PartGroup *)NULL) { - // This might happen if we are in the middle of reading the - // Character's hierarchy from the bam file. + // This might happen if we are in the middle of reading the Character's + // hierarchy from the bam file. return; } @@ -112,11 +94,9 @@ r_set_character(PartGroup *group, Character *character) { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::make_CharacterJointBundle -// Access: Protected -// Description: Factory method to generate a CharacterJointBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterJointBundle object + */ TypedWritable* CharacterJointBundle:: make_CharacterJointBundle(const FactoryParams ¶ms) { @@ -130,14 +110,11 @@ make_CharacterJointBundle(const FactoryParams ¶ms) return me; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointBundle::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CharacterJointBundle object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterJointBundle object + */ void CharacterJointBundle:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CharacterJointBundle); } - diff --git a/panda/src/char/characterJointBundle.h b/panda/src/char/characterJointBundle.h index 245db13124..fead649eb0 100644 --- a/panda/src/char/characterJointBundle.h +++ b/panda/src/char/characterJointBundle.h @@ -1,16 +1,15 @@ -// Filename: characterJointBundle.h -// Created by: drose (23Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointBundle.h + * @author drose + * @date 1999-02-23 + */ #ifndef CHARACTERJOINTBUNDLE_H #define CHARACTERJOINTBUNDLE_H @@ -23,11 +22,9 @@ class Character; -//////////////////////////////////////////////////////////////////// -// Class : CharacterJointBundle -// Description : The collection of all the joints and sliders in the -// character. -//////////////////////////////////////////////////////////////////// +/** + * The collection of all the joints and sliders in the character. + */ class EXPCL_PANDA_CHAR CharacterJointBundle : public PartBundle { protected: INLINE CharacterJointBundle(const CharacterJointBundle ©); @@ -73,5 +70,3 @@ private: #include "characterJointBundle.I" #endif - - diff --git a/panda/src/char/characterJointEffect.I b/panda/src/char/characterJointEffect.I index a02ddc5904..fb911569b3 100644 --- a/panda/src/char/characterJointEffect.I +++ b/panda/src/char/characterJointEffect.I @@ -1,35 +1,28 @@ -// Filename: characterJointEffect.I -// Created by: drose (26Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointEffect.I + * @author drose + * @date 2006-07-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::Constructor -// Access: Private -// Description: Use CharacterJointEffect::make() to construct a new -// CharacterJointEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use CharacterJointEffect::make() to construct a new CharacterJointEffect + * object. + */ INLINE CharacterJointEffect:: CharacterJointEffect() { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::get_character -// Access: Published -// Description: Returns the Character that will get update() called -// on it when this node's relative transform is queried, -// or NULL if there is no such character. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Character that will get update() called on it when this node's + * relative transform is queried, or NULL if there is no such character. + */ INLINE Character *CharacterJointEffect:: get_character() const { if (_character.is_valid_pointer()) { diff --git a/panda/src/char/characterJointEffect.cxx b/panda/src/char/characterJointEffect.cxx index e038f4172e..ec0dec9de3 100644 --- a/panda/src/char/characterJointEffect.cxx +++ b/panda/src/char/characterJointEffect.cxx @@ -1,16 +1,15 @@ -// Filename: characterJointEffect.cxx -// Created by: drose (26Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointEffect.cxx + * @author drose + * @date 2006-07-26 + */ #include "characterJointEffect.h" #include "cullTraverser.h" @@ -24,15 +23,12 @@ TypeHandle CharacterJointEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::make -// Access: Published, Static -// Description: Constructs a new CharacterJointEffect object that -// references the indicated character. When a relative -// get_transform() is called on the node that contains -// the CharacterJointEffect, it will implicitly call -// character->update() first. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CharacterJointEffect object that references the indicated + * character. When a relative get_transform() is called on the node that + * contains the CharacterJointEffect, it will implicitly call + * character->update() first. + */ CPT(RenderEffect) CharacterJointEffect:: make(Character *character) { CharacterJointEffect *effect = new CharacterJointEffect; @@ -42,21 +38,20 @@ make(Character *character) { const CharacterJointEffect *new_effect; DCAST_INTO_R(new_effect, new_effect_raw, new_effect_raw); - // It is possible that the CharacterJointEffect we have now is a - // different CharacterJointEffect to a different Character which has - // since been deleted, but which had the same memory address of our - // current character. If this happened, we have to force-update the - // CharacterJointEffect to tell its weak pointer that it is no - // longer invalid (and that it now points to this once-again-live - // Character object). + // It is possible that the CharacterJointEffect we have now is a different + // CharacterJointEffect to a different Character which has since been + // deleted, but which had the same memory address of our current character. + // If this happened, we have to force-update the CharacterJointEffect to + // tell its weak pointer that it is no longer invalid (and that it now + // points to this once-again-live Character object). - // This is a little weird, because it means any nodes that used to - // be pointing to a deleted Character object (and knew they were - // pointing to a deleted Character object) will suddenly be pointing - // to a new, non-deleted Character object--and the wrong Character - // object, no less. But there's no other way to handle this, since - // we can't make the CharacterJointEffect's compare function base - // itself on whether its pointer is valid or not. + // This is a little weird, because it means any nodes that used to be + // pointing to a deleted Character object (and knew they were pointing to a + // deleted Character object) will suddenly be pointing to a new, non-deleted + // Character object--and the wrong Character object, no less. But there's + // no other way to handle this, since we can't make the + // CharacterJointEffect's compare function base itself on whether its + // pointer is valid or not. if (!new_effect->_character.is_valid_pointer()) { nassertr(new_effect->_character.get_orig() == character, new_effect_raw); @@ -66,38 +61,31 @@ make(Character *character) { return new_effect_raw; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of RenderEffect by calling the -// xform() method, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * RenderEffect by calling the xform() method, false otherwise. + */ bool CharacterJointEffect:: safe_to_transform() const { - // We now accept that it will be OK to transform the joint--we allow - // this on the assumption that anything that transforms the joint - // will also transform the Character node, above the joint. + // We now accept that it will be OK to transform the joint--we allow this on + // the assumption that anything that transforms the joint will also + // transform the Character node, above the joint. return true; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if this kind of effect can safely be -// combined with sibling nodes that share the exact same -// effect, or false if this is not a good idea. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of effect can safely be combined with sibling + * nodes that share the exact same effect, or false if this is not a good + * idea. + */ bool CharacterJointEffect:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CharacterJointEffect:: output(ostream &out) const { out << get_type(); @@ -108,37 +96,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool CharacterJointEffect:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void CharacterJointEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -147,30 +126,24 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, adjust_transform(dummy_transform, node_transform, data.node()); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::has_adjust_transform -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if adjust_transform() has been defined, and -// therefore the RenderEffect has some effect on the -// node's apparent local and net transforms. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if + * adjust_transform() has been defined, and therefore the RenderEffect has + * some effect on the node's apparent local and net transforms. + */ bool CharacterJointEffect:: has_adjust_transform() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::adjust_transform -// Access: Public, Virtual -// Description: Performs some operation on the node's apparent net -// and/or local transforms. This will only be called if -// has_adjust_transform() is redefined to return true. -// -// Both parameters are in/out. The original transforms -// will be passed in, and they may (or may not) be -// modified in-place by the RenderEffect. -//////////////////////////////////////////////////////////////////// +/** + * Performs some operation on the node's apparent net and/or local transforms. + * This will only be called if has_adjust_transform() is redefined to return + * true. + * + * Both parameters are in/out. The original transforms will be passed in, and + * they may (or may not) be modified in-place by the RenderEffect. + */ void CharacterJointEffect:: adjust_transform(CPT(TransformState) &net_transform, CPT(TransformState) &node_transform, @@ -182,21 +155,18 @@ adjust_transform(CPT(TransformState) &net_transform, } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived CharacterJointEffect -// types to return a unique number indicating whether -// this CharacterJointEffect is equivalent to the other one. -// -// This should return 0 if the two CharacterJointEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two CharacterJointEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived CharacterJointEffect types to return a + * unique number indicating whether this CharacterJointEffect is equivalent to + * the other one. + * + * This should return 0 if the two CharacterJointEffect objects are + * equivalent, a number less than zero if this one should be sorted before the + * other one, and a number greater than zero otherwise. + * + * This will only be called with two CharacterJointEffect objects whose + * get_type() functions return the same. + */ int CharacterJointEffect:: compare_to_impl(const RenderEffect *other) const { const CharacterJointEffect *ta; @@ -206,32 +176,26 @@ compare_to_impl(const RenderEffect *other) const { return _character.get_orig() < ta->_character.get_orig() ? -1 : 1; } - // As tempting as it is to include the sense of whether the - // character pointer is valid in this sorting, we can't, because - // that property might change without warning--which would - // invalidate the CharacterJointEffect's position in any maps if we - // used it to determine its sort. + // As tempting as it is to include the sense of whether the character + // pointer is valid in this sorting, we can't, because that property might + // change without warning--which would invalidate the CharacterJointEffect's + // position in any maps if we used it to determine its sort. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CharacterJointEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CharacterJointEffect. + */ void CharacterJointEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CharacterJointEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); @@ -243,13 +207,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int CharacterJointEffect:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderEffect::complete_pointers(p_list, manager); @@ -259,14 +220,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CharacterJointEffect is encountered -// in the Bam file. It should create the CharacterJointEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CharacterJointEffect is encountered in the Bam file. It should create + * the CharacterJointEffect and extract its information from the file. + */ TypedWritable *CharacterJointEffect:: make_from_bam(const FactoryParams ¶ms) { CharacterJointEffect *effect = new CharacterJointEffect; @@ -279,13 +237,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterJointEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CharacterJointEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CharacterJointEffect. + */ void CharacterJointEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); diff --git a/panda/src/char/characterJointEffect.h b/panda/src/char/characterJointEffect.h index 69148e977c..031b75237c 100644 --- a/panda/src/char/characterJointEffect.h +++ b/panda/src/char/characterJointEffect.h @@ -1,16 +1,15 @@ -// Filename: characterJointEffect.h -// Created by: drose (26Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterJointEffect.h + * @author drose + * @date 2006-07-26 + */ #ifndef CHARACTERJOINTEFFECT_H #define CHARACTERJOINTEFFECT_H @@ -23,17 +22,15 @@ #include "character.h" #include "weakPointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CharacterJointEffect -// Description : This effect will be added automatically to a node by -// CharacterJoint::add_net_transform() and -// CharacterJoint::add_local_transform(). -// -// The effect binds the node back to the character, so -// that querying the relative transform of the affected -// node will automatically force the indicated character -// to be updated first. -//////////////////////////////////////////////////////////////////// +/** + * This effect will be added automatically to a node by + * CharacterJoint::add_net_transform() and + * CharacterJoint::add_local_transform(). + * + * The effect binds the node back to the character, so that querying the + * relative transform of the affected node will automatically force the + * indicated character to be updated first. + */ class EXPCL_PANDA_CHAR CharacterJointEffect : public RenderEffect { private: INLINE CharacterJointEffect(); @@ -73,7 +70,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -95,4 +92,3 @@ private: #include "characterJointEffect.I" #endif - diff --git a/panda/src/char/characterSlider.cxx b/panda/src/char/characterSlider.cxx index 26e46a4a20..824b7e2737 100644 --- a/panda/src/char/characterSlider.cxx +++ b/panda/src/char/characterSlider.cxx @@ -1,16 +1,15 @@ -// Filename: characterSlider.cxx -// Created by: drose (03Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterSlider.cxx + * @author drose + * @date 1999-03-03 + */ #include "characterSlider.h" #include "characterVertexSlider.h" @@ -21,85 +20,70 @@ TypeHandle CharacterSlider::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::Default Constructor -// Access: Protected -// Description: For internal use only. -//////////////////////////////////////////////////////////////////// +/** + * For internal use only. + */ CharacterSlider:: CharacterSlider() { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterSlider:: CharacterSlider(const CharacterSlider ©) : MovingPartScalar(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterSlider:: CharacterSlider(PartGroup *parent, const string &name) : MovingPartScalar(parent, name) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterSlider:: ~CharacterSlider() { nassertv(_vertex_sliders.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the node. -// Children are not copied, but see copy_subgraph(). -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the node. Children are not copied, but + * see copy_subgraph(). + */ PartGroup *CharacterSlider:: make_copy() const { return new CharacterSlider(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::update_internals -// Access: Public, Virtual -// Description: This is called by do_update() whenever the part or -// some ancestor has changed values. It is a hook for -// derived classes to update whatever cache they may -// have that depends on these. -// -// The return value is true if the part has changed as a -// result of the update, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This is called by do_update() whenever the part or some ancestor has + * changed values. It is a hook for derived classes to update whatever cache + * they may have that depends on these. + * + * The return value is true if the part has changed as a result of the update, + * or false otherwise. + */ bool CharacterSlider:: update_internals(PartBundle *, PartGroup *, bool, bool, Thread *current_thread) { - // Tell our related CharacterVertexSliders that they now need to - // recompute themselves. + // Tell our related CharacterVertexSliders that they now need to recompute + // themselves. VertexSliders::iterator vsi; for (vsi = _vertex_sliders.begin(); vsi != _vertex_sliders.end(); ++vsi) { (*vsi)->mark_modified(current_thread); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::make_CharacterSlider -// Access: Protected -// Description: Factory method to generate a CharacterSlider object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterSlider object + */ TypedWritable* CharacterSlider:: make_CharacterSlider(const FactoryParams ¶ms) { @@ -112,17 +96,11 @@ make_CharacterSlider(const FactoryParams ¶ms) return me; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterSlider::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CharacterSlider object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CharacterSlider object + */ void CharacterSlider:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CharacterSlider); } - - - - diff --git a/panda/src/char/characterSlider.h b/panda/src/char/characterSlider.h index c7e784789f..fe5129bca4 100644 --- a/panda/src/char/characterSlider.h +++ b/panda/src/char/characterSlider.h @@ -1,16 +1,15 @@ -// Filename: characterSlider.h -// Created by: drose (03Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterSlider.h + * @author drose + * @date 1999-03-03 + */ #ifndef CHARACTERSLIDER_H #define CHARACTERSLIDER_H @@ -21,13 +20,11 @@ class CharacterVertexSlider; -//////////////////////////////////////////////////////////////////// -// Class : CharacterSlider -// Description : This is a morph slider within the character. It's -// simply a single floating-point value that animates -// generally between 0 and 1, that controls the effects -// of one or more morphs within the character. -//////////////////////////////////////////////////////////////////// +/** + * This is a morph slider within the character. It's simply a single + * floating-point value that animates generally between 0 and 1, that controls + * the effects of one or more morphs within the character. + */ class EXPCL_PANDA_CHAR CharacterSlider : public MovingPartScalar { protected: CharacterSlider(); @@ -39,8 +36,8 @@ PUBLISHED: virtual PartGroup *make_copy() const; - virtual bool update_internals(PartBundle *root, PartGroup *parent, - bool self_changed, bool parent_changed, + virtual bool update_internals(PartBundle *root, PartGroup *parent, + bool self_changed, bool parent_changed, Thread *current_thread); private: @@ -75,5 +72,3 @@ private: }; #endif - - diff --git a/panda/src/char/characterVertexSlider.I b/panda/src/char/characterVertexSlider.I index a98f874c82..b8180f495c 100644 --- a/panda/src/char/characterVertexSlider.I +++ b/panda/src/char/characterVertexSlider.I @@ -1,24 +1,20 @@ -// Filename: characterVertexSlider.I -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterVertexSlider.I + * @author drose + * @date 2005-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::get_char_slider -// Access: Published -// Description: Returns the CharacterSlider object for which this -// object returns the slider value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CharacterSlider object for which this object returns the slider + * value. + */ INLINE const CharacterSlider *CharacterVertexSlider:: get_char_slider() const { return _char_slider; diff --git a/panda/src/char/characterVertexSlider.cxx b/panda/src/char/characterVertexSlider.cxx index f3a0580db6..c3e8e514b9 100644 --- a/panda/src/char/characterVertexSlider.cxx +++ b/panda/src/char/characterVertexSlider.cxx @@ -1,16 +1,15 @@ -// Filename: characterVertexSlider.cxx -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterVertexSlider.cxx + * @author drose + * @date 2005-03-28 + */ #include "characterVertexSlider.h" #include "datagram.h" @@ -20,25 +19,19 @@ TypeHandle CharacterVertexSlider::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::Default Constructor -// Access: Private -// Description: Constructs an invalid object; used only by the bam -// loader. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid object; used only by the bam loader. + */ CharacterVertexSlider:: CharacterVertexSlider() : VertexSlider(InternalName::get_root()) { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::Constructor -// Access: Published -// Description: Constructs a new object that converts vertices from -// the indicated joint's coordinate space, into the -// other indicated joint's space. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new object that converts vertices from the indicated joint's + * coordinate space, into the other indicated joint's space. + */ CharacterVertexSlider:: CharacterVertexSlider(CharacterSlider *char_slider) : VertexSlider(InternalName::make(char_slider->get_name())), @@ -48,44 +41,35 @@ CharacterVertexSlider(CharacterSlider *char_slider) : _char_slider->_vertex_sliders.insert(this); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterVertexSlider:: ~CharacterVertexSlider() { // Tell the char_slider to stop informing us about its motion. _char_slider->_vertex_sliders.erase(this); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::get_slider -// Access: Published, Virtual -// Description: Returns the current slider value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current slider value. + */ PN_stdfloat CharacterVertexSlider:: get_slider() const { return _char_slider->_value; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CharacterVertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CharacterVertexSlider. + */ void CharacterVertexSlider:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CharacterVertexSlider:: write_datagram(BamWriter *manager, Datagram &dg) { VertexSlider::write_datagram(manager, dg); @@ -93,32 +77,26 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _char_slider); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int CharacterVertexSlider:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = VertexSlider::complete_pointers(p_list, manager); - _char_slider = DCAST(CharacterSlider, p_list[pi++]); + _char_slider = DCAST(CharacterSlider, p_list[pi++]); _char_slider->_vertex_sliders.insert(this); _name = InternalName::make(_char_slider->get_name()); return pi; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CharacterVertexSlider is encountered -// in the Bam file. It should create the CharacterVertexSlider -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CharacterVertexSlider is encountered in the Bam file. It should + * create the CharacterVertexSlider and extract its information from the file. + */ TypedWritable *CharacterVertexSlider:: make_from_bam(const FactoryParams ¶ms) { CharacterVertexSlider *object = new CharacterVertexSlider; @@ -131,13 +109,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterVertexSlider::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CharacterVertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CharacterVertexSlider. + */ void CharacterVertexSlider:: fillin(DatagramIterator &scan, BamReader *manager) { VertexSlider::fillin(scan, manager); diff --git a/panda/src/char/characterVertexSlider.h b/panda/src/char/characterVertexSlider.h index 6bc0de14ae..d072dcbd35 100644 --- a/panda/src/char/characterVertexSlider.h +++ b/panda/src/char/characterVertexSlider.h @@ -1,16 +1,15 @@ -// Filename: characterVertexSlider.h -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterVertexSlider.h + * @author drose + * @date 2005-03-28 + */ #ifndef CHARACTERVERTEXSLIDER_H #define CHARACTERVERTEXSLIDER_H @@ -20,12 +19,10 @@ #include "vertexSlider.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CharacterVertexSlider -// Description : This is a specialization on VertexSlider that -// returns the slider value associated with a particular -// CharacterSlider object. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on VertexSlider that returns the slider value + * associated with a particular CharacterSlider object. + */ class EXPCL_PANDA_CHAR CharacterVertexSlider : public VertexSlider { private: CharacterVertexSlider(); diff --git a/panda/src/char/config_char.cxx b/panda/src/char/config_char.cxx index 40784e310a..f3a8cc6836 100644 --- a/panda/src/char/config_char.cxx +++ b/panda/src/char/config_char.cxx @@ -1,17 +1,15 @@ -// Filename: config_char.cxx -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_char.cxx + * @author drose + * @date 2000-02-28 + */ #include "config_char.h" #include "character.h" @@ -39,14 +37,12 @@ ConfigVariableBool even_animation "computed, which can lead to an uneven frame rate.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libchar -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libchar() { static bool initialized = false; @@ -63,8 +59,8 @@ init_libchar() { CharacterVertexSlider::init_type(); JointVertexTransform::init_type(); - //Registration of writeable object's creation - //functions with BamReader's factory + // Registration of writeable object's creation functions with BamReader's + // factory Character::register_with_read_factory(); CharacterJoint::register_with_read_factory(); CharacterJointBundle::register_with_read_factory(); @@ -73,4 +69,3 @@ init_libchar() { CharacterVertexSlider::register_with_read_factory(); JointVertexTransform::register_with_read_factory(); } - diff --git a/panda/src/char/config_char.h b/panda/src/char/config_char.h index ee2d6b8673..790001ba04 100644 --- a/panda/src/char/config_char.h +++ b/panda/src/char/config_char.h @@ -1,16 +1,15 @@ -// Filename: config_char.h -// Created by: drose (28Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_char.h + * @author drose + * @date 2000-02-28 + */ #ifndef CONFIG_CHAR_H #define CONFIG_CHAR_H diff --git a/panda/src/char/jointVertexTransform.I b/panda/src/char/jointVertexTransform.I index f5df4f6a77..a5a2a2e8cf 100644 --- a/panda/src/char/jointVertexTransform.I +++ b/panda/src/char/jointVertexTransform.I @@ -1,34 +1,27 @@ -// Filename: jointVertexTransform.I -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file jointVertexTransform.I + * @author drose + * @date 2005-03-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::get_joint -// Access: Published -// Description: Returns the joint for which this object returns the -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the joint for which this object returns the transform. + */ INLINE const CharacterJoint *JointVertexTransform:: get_joint() const { return _joint; } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::check_matrix -// Access: Private -// Description: Recomputes _matrix if it needs it. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes _matrix if it needs it. + */ INLINE void JointVertexTransform:: check_matrix() const { if (_matrix_stale) { diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index db3eb9f86f..cf943669a7 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -1,16 +1,15 @@ -// Filename: jointVertexTransform.cxx -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file jointVertexTransform.cxx + * @author drose + * @date 2005-03-24 + */ #include "jointVertexTransform.h" #include "datagram.h" @@ -21,25 +20,19 @@ TypeHandle JointVertexTransform::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::Default Constructor -// Access: Private -// Description: Constructs an invalid object; used only by the bam -// loader. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid object; used only by the bam loader. + */ JointVertexTransform:: JointVertexTransform() : _matrix_stale(true) { } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::Constructor -// Access: Published -// Description: Constructs a new object that converts vertices from -// the indicated joint's coordinate space, into the -// other indicated joint's space. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new object that converts vertices from the indicated joint's + * coordinate space, into the other indicated joint's space. + */ JointVertexTransform:: JointVertexTransform(CharacterJoint *joint) : _joint(joint), @@ -50,52 +43,41 @@ JointVertexTransform(CharacterJoint *joint) : mark_modified(Thread::get_current_thread()); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ JointVertexTransform:: ~JointVertexTransform() { // Tell the joint to stop informing us about its motion. _joint->_vertex_transforms.erase(this); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::get_matrix -// Access: Published, Virtual -// Description: Stores the transform's matrix in the indicated object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the transform's matrix in the indicated object. + */ void JointVertexTransform:: get_matrix(LMatrix4 &matrix) const { check_matrix(); matrix = _matrix; } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::mult_matrix -// Access: Published, Virtual -// Description: Premultiplies this transform's matrix with the -// indicated previous matrix, so that the result is the -// net composition of the given transform with this -// transform. The result is stored in the parameter -// "result", which should not be the same matrix as -// previous. -//////////////////////////////////////////////////////////////////// +/** + * Premultiplies this transform's matrix with the indicated previous matrix, + * so that the result is the net composition of the given transform with this + * transform. The result is stored in the parameter "result", which should + * not be the same matrix as previous. + */ void JointVertexTransform:: mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { check_matrix(); result.multiply(_matrix, previous); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::accumulate_matrix -// Access: Published, Virtual -// Description: Adds the value of this transform's matrix, modified -// by the indicated weight, into the indicated -// accumulation matrix. This is used to compute the -// result of several blended transforms. -//////////////////////////////////////////////////////////////////// +/** + * Adds the value of this transform's matrix, modified by the indicated + * weight, into the indicated accumulation matrix. This is used to compute + * the result of several blended transforms. + */ void JointVertexTransform:: accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { check_matrix(); @@ -103,21 +85,17 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { accum.accumulate(_matrix, weight); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void JointVertexTransform:: output(ostream &out) const { out << _joint->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::compute_matrix -// Access: Private -// Description: Recomputes _matrix if it needs it. Uses locking. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes _matrix if it needs it. Uses locking. + */ void JointVertexTransform:: compute_matrix() { LightMutexHolder holder(_lock); @@ -128,23 +106,18 @@ compute_matrix() { } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// JointVertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type JointVertexTransform. + */ void JointVertexTransform:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void JointVertexTransform:: write_datagram(BamWriter *manager, Datagram &dg) { VertexTransform::write_datagram(manager, dg); @@ -152,31 +125,25 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _joint); } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int JointVertexTransform:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = VertexTransform::complete_pointers(p_list, manager); - _joint = DCAST(CharacterJoint, p_list[pi++]); + _joint = DCAST(CharacterJoint, p_list[pi++]); _joint->_vertex_transforms.insert(this); return pi; } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type JointVertexTransform is encountered -// in the Bam file. It should create the JointVertexTransform -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type JointVertexTransform is encountered in the Bam file. It should create + * the JointVertexTransform and extract its information from the file. + */ TypedWritable *JointVertexTransform:: make_from_bam(const FactoryParams ¶ms) { JointVertexTransform *object = new JointVertexTransform; @@ -189,13 +156,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: JointVertexTransform::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new JointVertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new JointVertexTransform. + */ void JointVertexTransform:: fillin(DatagramIterator &scan, BamReader *manager) { VertexTransform::fillin(scan, manager); diff --git a/panda/src/char/jointVertexTransform.h b/panda/src/char/jointVertexTransform.h index 7e41221e46..39b531de8d 100644 --- a/panda/src/char/jointVertexTransform.h +++ b/panda/src/char/jointVertexTransform.h @@ -1,16 +1,15 @@ -// Filename: jointVertexTransform.h -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file jointVertexTransform.h + * @author drose + * @date 2005-03-24 + */ #ifndef JOINTVERTEXTRANSFORM_H #define JOINTVERTEXTRANSFORM_H @@ -21,20 +20,16 @@ #include "pointerTo.h" #include "lightMutex.h" -//////////////////////////////////////////////////////////////////// -// Class : JointVertexTransform -// Description : This is a specialization on VertexTransform that -// returns the transform necessary to move vertices as -// if they were assigned to the indicated joint. The -// geometry itself should be parented to the scene graph -// at the level of the character's root joint; that is, -// it should not be parented under a node directly -// animated by any joints. -// -// Multiple combinations of these with different weights -// are used to implement soft-skinned vertices for an -// animated character. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on VertexTransform that returns the transform + * necessary to move vertices as if they were assigned to the indicated joint. + * The geometry itself should be parented to the scene graph at the level of + * the character's root joint; that is, it should not be parented under a node + * directly animated by any joints. + * + * Multiple combinations of these with different weights are used to implement + * soft-skinned vertices for an animated character. + */ class EXPCL_PANDA_CHAR JointVertexTransform : public VertexTransform { private: JointVertexTransform(); diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.I b/panda/src/cocoadisplay/cocoaGraphicsPipe.I index 4b73bd6039..874bf12fea 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.I +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.I @@ -1,35 +1,27 @@ -// Filename: cocoaGraphicsPipe.I -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsPipe.I + * @author rdb + * @date 2012-05-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::get_display_id -// Access: Public -// Description: Returns the Quartz display ID associated with -// this graphics pipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Quartz display ID associated with this graphics pipe. + */ INLINE CGDirectDisplayID CocoaGraphicsPipe:: get_display_id() const { return _display; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::get_nsscreen -// Access: Public -// Description: Returns the Cocoa NSScreen pointer associated with -// this graphics pipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Cocoa NSScreen pointer associated with this graphics pipe. + */ INLINE NSScreen *CocoaGraphicsPipe:: get_nsscreen() const { return _screen; diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.h b/panda/src/cocoadisplay/cocoaGraphicsPipe.h index f13f09fd23..d53456e332 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.h +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: cocoaGraphicsPipe.h -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsPipe.h + * @author rdb + * @date 2012-05-14 + */ #ifndef COCOAGRAPHICSPIPE_H #define COCOAGRAPHICSPIPE_H @@ -30,12 +29,10 @@ struct NSScreen; class FrameBufferProperties; -//////////////////////////////////////////////////////////////////// -// Class : CocoaGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on a Cocoa-based -// (e.g. Mac OS X) client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL graphics + * windows on a Cocoa-based (e.g. Mac OS X) client. + */ class CocoaGraphicsPipe : public GraphicsPipe { public: CocoaGraphicsPipe(); @@ -67,10 +64,9 @@ protected: private: void load_display_information(); - // _display and _screen refer to the same thing, - // NSScreen being the tiny Cocoa wrapper around the Quartz - // display ID. NSScreen isn't generally useful, but we need - // it when creating the window. + // _display and _screen refer to the same thing, NSScreen being the tiny + // Cocoa wrapper around the Quartz display ID. NSScreen isn't generally + // useful, but we need it when creating the window. CGDirectDisplayID _display; NSScreen *_screen; diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 7883bad834..7106e440d7 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -1,19 +1,18 @@ -// Filename: cocoaGraphicsPipe.mm -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsPipe.mm + * @author rdb + * @date 2012-05-14 + */ #include "cocoaGraphicsPipe.h" -//#include "cocoaGraphicsBuffer.h" +// #include "cocoaGraphicsBuffer.h" #include "cocoaGraphicsWindow.h" #include "cocoaGraphicsStateGuardian.h" #include "cocoaPandaApp.h" @@ -41,21 +40,19 @@ static void init_app() { #endif [NSApp finishLaunching]; [NSApp activateIgnoringOtherApps:YES]; - - // Put Cocoa into thread-safe mode - // by spawning a thread which immediately exits. + + // Put Cocoa into thread-safe mode by spawning a thread which immediately + // exits. NSThread* thread = [[NSThread alloc] init]; [thread start]; - [thread autorelease]; + [thread autorelease]; } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::Constructor -// Access: Public -// Description: Uses the main screen (the one the user is most -// likely to be working in at the moment). -//////////////////////////////////////////////////////////////////// +/** + * Uses the main screen (the one the user is most likely to be working in at + * the moment). + */ CocoaGraphicsPipe:: CocoaGraphicsPipe() { _supported_types = OT_window | OT_buffer | OT_texture_buffer; @@ -76,11 +73,9 @@ CocoaGraphicsPipe() { << _screen << " with display ID " << _display << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::Constructor -// Access: Public -// Description: Takes a CoreGraphics display ID. -//////////////////////////////////////////////////////////////////// +/** + * Takes a CoreGraphics display ID. + */ CocoaGraphicsPipe:: CocoaGraphicsPipe(CGDirectDisplayID display) { _supported_types = OT_window | OT_buffer | OT_texture_buffer; @@ -108,11 +103,9 @@ CocoaGraphicsPipe(CGDirectDisplayID display) { << _screen << " with display ID " << _display << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::Constructor -// Access: Public -// Description: Takes an NSScreen pointer. -//////////////////////////////////////////////////////////////////// +/** + * Takes an NSScreen pointer. + */ CocoaGraphicsPipe:: CocoaGraphicsPipe(NSScreen *screen) { _supported_types = OT_window | OT_buffer | OT_texture_buffer; @@ -137,16 +130,14 @@ CocoaGraphicsPipe(NSScreen *screen) { << _screen << " with display ID " << _display << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::load_display_information -// Access: Private -// Description: Fills in _display_information. -//////////////////////////////////////////////////////////////////// +/** + * Fills in _display_information. + */ void CocoaGraphicsPipe:: load_display_information() { _display_information->_vendor_id = CGDisplayVendorNumber(_display); - //_display_information->_device_id = CGDisplayUnitNumber(_display); - //_display_information->_device_id = CGDisplaySerialNumber(_display); + // _display_information->_device_id = CGDisplayUnitNumber(_display); + // _display_information->_device_id = CGDisplaySerialNumber(_display); // Display modes #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 @@ -183,9 +174,9 @@ load_display_information() { kCFCompareCaseInsensitive) == kCFCompareEqualTo) { _display_information->_display_mode_array[i].bits_per_pixel = 8; } else { - // The other possible pixel formats in IOKit/IOGraphicsTypes.h - // have strings like "PPPP" or "-RRRRRGGGGGBBBBB", so the number - // of bits per pixel can be deduced from the string length. Nifty! + // The other possible pixel formats in IOKitIOGraphicsTypes.h have + // strings like "PPPP" or "-RRRRRGGGGGBBBBB", so the number of bits per + // pixel can be deduced from the string length. Nifty! _display_information->_display_mode_array[i].bits_per_pixel = CFStringGetLength(encoding); } CFRelease(encoding); @@ -231,62 +222,48 @@ load_display_information() { _display_information->_os_version_build = bugfix; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CocoaGraphicsPipe:: ~CocoaGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string CocoaGraphicsPipe:: get_interface_name() const { return "OpenGL"; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// CocoaGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default CocoaGraphicsPipe. + */ PT(GraphicsPipe) CocoaGraphicsPipe:: pipe_constructor() { return new CocoaGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ GraphicsPipe::PreferredWindowThread CocoaGraphicsPipe::get_preferred_window_thread() const { - // The NSView and NSWindow classes are not completely thread-safe, - // they can only be called from the main thread! + // The NSView and NSWindow classes are not completely thread-safe, they can + // only be called from the main thread! return PWT_app; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) CocoaGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -331,8 +308,8 @@ make_output(const string &name, (flags & (BF_require_parasite | BF_require_window)) != 0) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || @@ -345,8 +322,8 @@ make_output(const string &name, cocoagsg->_glDrawBuffers == NULL) { return NULL; } else if (fb_prop.is_basic()) { - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we + // can precertify it. precertify = true; } } @@ -367,8 +344,8 @@ make_output(const string &name, if (!support_rtt) { if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - // If we require Render-to-Texture, but can't be sure we - // support it, bail. + // If we require Render-to-Texture, but can't be sure we support it, + // bail. return NULL; } } @@ -382,15 +359,12 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsPipe::make_callback_gsg -// Access: Protected, Virtual -// Description: This is called when make_output() is used to create a -// CallbackGraphicsWindow. If the GraphicsPipe can -// construct a GSG that's not associated with any -// particular window object, do so now, assuming the -// correct graphics context has been set up externally. -//////////////////////////////////////////////////////////////////// +/** + * This is called when make_output() is used to create a + * CallbackGraphicsWindow. If the GraphicsPipe can construct a GSG that's not + * associated with any particular window object, do so now, assuming the + * correct graphics context has been set up externally. + */ PT(GraphicsStateGuardian) CocoaGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { return new CocoaGraphicsStateGuardian(engine, this, NULL); diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.I b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.I index 69311ef37c..d593a3fe86 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.I +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.I @@ -1,26 +1,21 @@ -// Filename: cocoaGraphicsStateGuardian.I -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsStateGuardian.I + * @author rdb + * @date 2012-05-14 + */ -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::get_fb_properties -// Access: Private -// Description: Gets the FrameBufferProperties for all windows and -// buffers that use this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties for all windows and buffers that use this + * GSG. + */ INLINE const FrameBufferProperties &CocoaGraphicsStateGuardian:: get_fb_properties() const { return _fbprops; } - - diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h index 2d88c9753d..a2420e55c2 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: cocoaGraphicsStateGuardian.h -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsStateGuardian.h + * @author rdb + * @date 2012-05-14 + */ #ifndef COCOAGRAPHICSSTATEGUARDIAN_H #define COCOAGRAPHICSSTATEGUARDIAN_H @@ -21,11 +20,10 @@ #import -//////////////////////////////////////////////////////////////////// -// Class : CocoaGraphicsStateGuardian -// Description : A tiny specialization on GLGraphicsStateGuardian -// to add some Cocoa-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLGraphicsStateGuardian to add some Cocoa-specific + * information. + */ class CocoaGraphicsStateGuardian : public GLGraphicsStateGuardian { public: INLINE const FrameBufferProperties &get_fb_properties() const; diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index 01e4624015..19ee0e8517 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -1,16 +1,15 @@ -// Filename: cocoaGraphicsStateGuardian.mm -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsStateGuardian.mm + * @author rdb + * @date 2012-05-14 + */ #include "cocoaGraphicsStateGuardian.h" #include "config_cocoadisplay.h" @@ -27,11 +26,9 @@ TypeHandle CocoaGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CocoaGraphicsStateGuardian:: CocoaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, CocoaGraphicsStateGuardian *share_with) : @@ -46,11 +43,9 @@ CocoaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CocoaGraphicsStateGuardian:: ~CocoaGraphicsStateGuardian() { if (_context != nil) { @@ -59,12 +54,9 @@ CocoaGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::get_properties -// Access: Private -// Description: Gets the FrameBufferProperties to match the -// indicated config. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated config. + */ void CocoaGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_format, int screen) { @@ -103,10 +95,10 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for if (sample_buffers > 0) { properties.set_multisamples(samples); } - //TODO: add aux buffers + // TODO: add aux buffers - // Extract the renderer ID bits and check if our - // renderer matches the known software renderers. + // Extract the renderer ID bits and check if our renderer matches the known + // software renderers. renderer_id &= kCGLRendererIDMatchingMask; if (renderer_id == kCGLRendererGenericID || renderer_id == kCGLRendererGenericFloatID || @@ -120,13 +112,10 @@ get_properties(FrameBufferProperties &properties, NSOpenGLPixelFormat* pixel_for } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::choose_pixel_format -// Access: Private -// Description: Selects a visual or fbconfig for all the windows -// and buffers that use this gsg. Also creates the GL -// context and obtains the visual. -//////////////////////////////////////////////////////////////////// +/** + * Selects a visual or fbconfig for all the windows and buffers that use this + * gsg. Also creates the GL context and obtains the visual. + */ void CocoaGraphicsStateGuardian:: choose_pixel_format(const FrameBufferProperties &properties, CGDirectDisplayID display, @@ -136,20 +125,20 @@ choose_pixel_format(const FrameBufferProperties &properties, _fbprops.clear(); // Neither Cocoa nor CGL seem to have a mechanism to query the available - // pixel formats, unfortunately, so the only thing we can do is ask for - // one with the properties we have requested. + // pixel formats, unfortunately, so the only thing we can do is ask for one + // with the properties we have requested. pvector attribs; attribs.reserve(15); - // Picked this up from the pyglet source - seems - // to be necessary to support RAGE-II, which is not compliant. + // Picked this up from the pyglet source - seems to be necessary to support + // RAGE-II, which is not compliant. attribs.push_back(NSOpenGLPFAAllRenderers); // Don't let it fall back to a different renderer. attribs.push_back(NSOpenGLPFANoRecovery); - // Consider pixel formats with properties equal - // to or better than we requested. + // Consider pixel formats with properties equal to or better than we + // requested. attribs.push_back(NSOpenGLPFAMinimumPolicy); if (!properties.is_single_buffered()) { @@ -170,12 +159,11 @@ choose_pixel_format(const FrameBufferProperties &properties, attribs.push_back(NSOpenGLPFAStencilSize); attribs.push_back(properties.get_stencil_bits()); - // Curious case - if we request anything less than 8 alpha bits, - // then on some ATI cards, it will grab a pixel format with just - // 2 alpha bits, which just shows a white window and nothing else. - // Might have something to do with the compositing window manager. - // Omitting it altogether seems to make it grab one with 8 bits, though. - // Dirty hack. Needs more research. + // Curious case - if we request anything less than 8 alpha bits, then on + // some ATI cards, it will grab a pixel format with just 2 alpha bits, which + // just shows a white window and nothing else. Might have something to do + // with the compositing window manager. Omitting it altogether seems to + // make it grab one with 8 bits, though. Dirty hack. Needs more research. if (properties.get_alpha_bits() > 0) { attribs.push_back(NSOpenGLPFAAlphaSize); attribs.push_back(max(8, properties.get_alpha_bits())); @@ -225,7 +213,7 @@ choose_pixel_format(const FrameBufferProperties &properties, "Pixel format has " << [format numberOfVirtualScreens] << " virtual screens.\n"; get_properties(_fbprops, format, 0); - //TODO: print out renderer + // TODO: print out renderer _context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:_share_context]; [format release]; @@ -243,48 +231,41 @@ choose_pixel_format(const FrameBufferProperties &properties, << "Created context " << _context << ": " << _fbprops << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::query_gl_version -// Access: Protected, Virtual -// Description: Queries the runtime version of OpenGL in use. -//////////////////////////////////////////////////////////////////// +/** + * Queries the runtime version of OpenGL in use. + */ void CocoaGraphicsStateGuardian:: query_gl_version() { GLGraphicsStateGuardian::query_gl_version(); - // We output to glgsg_cat instead of glxdisplay_cat, since this is - // where the GL version has been output, and it's nice to see the - // two of these together. + // We output to glgsg_cat instead of glxdisplay_cat, since this is where the + // GL version has been output, and it's nice to see the two of these + // together. if (glgsg_cat.is_debug()) { - //XXX this is supposed to work, but the NSOpenGLGetVersion - // symbol cannot be found when I do this + // XXX this is supposed to work, but the NSOpenGLGetVersion symbol cannot + // be found when I do this - //GLint major, minor; - //NSOpenGLGetVersion(&major, &minor); + // GLint major, minor; NSOpenGLGetVersion(&major, &minor); - //glgsg_cat.debug() - // << "NSOpenGLVersion = " << major << "." << minor << "\n"; + // glgsg_cat.debug() << "NSOpenGLVersion = " << major << "." << minor << + // "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *CocoaGraphicsStateGuardian:: do_get_extension_func(const char *name) { char* fullname = (char*) malloc(strlen(name) + 2); strcpy(fullname + 1, name); fullname[0] = '_'; - // Believe it or not, but this is actually the - // Apple-recommended way to do it. I know, right? + // Believe it or not, but this is actually the Apple-recommended way to do + // it. I know, right? if (NSIsSymbolNameDefined(fullname)) { NSSymbol symbol = NSLookupAndBindSymbol(fullname); diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.I b/panda/src/cocoadisplay/cocoaGraphicsWindow.I index 012c65013d..200d65e7d4 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.I +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.I @@ -1,33 +1,27 @@ -// Filename: cocoaGraphicsWindow.I -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsWindow.I + * @author rdb + * @date 2012-05-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::get_nswindow -// Access: Public -// Description: Returns a pointer to the underlying NSWindow. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the underlying NSWindow. + */ INLINE NSWindow *CocoaGraphicsWindow:: get_nswindow() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::get_nsview -// Access: Public -// Description: Returns a pointer to the underlying NSView. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the underlying NSView. + */ INLINE NSView *CocoaGraphicsWindow:: get_nsview() const { return _view; diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.h b/panda/src/cocoadisplay/cocoaGraphicsWindow.h index a7c44036e6..6432ecc3e8 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.h +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: cocoaGraphicsWindow.h -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsWindow.h + * @author rdb + * @date 2012-05-14 + */ #ifndef COCOAGRAPHICSWINDOW_H #define COCOAGRAPHICSWINDOW_H @@ -24,11 +23,10 @@ #import #import -//////////////////////////////////////////////////////////////////// -// Class : CocoaGraphicsWindow -// Description : An interface to the Cocoa system for managing -// OpenGL windows under Mac OS X. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the Cocoa system for managing OpenGL windows under Mac OS + * X. + */ class CocoaGraphicsWindow : public GraphicsWindow { public: CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 7ac27c723d..6de003d2aa 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -1,16 +1,15 @@ -// Filename: cocoaGraphicsWindow.mm -// Created by: rdb (14May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaGraphicsWindow.mm + * @author rdb + * @date 2012-05-14 + */ #include "cocoaGraphicsWindow.h" #include "cocoaGraphicsStateGuardian.h" @@ -44,11 +43,9 @@ TypeHandle CocoaGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CocoaGraphicsWindow:: CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -77,28 +74,24 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _display = cocoa_pipe->_display; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CocoaGraphicsWindow:: ~CocoaGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool CocoaGraphicsWindow:: move_pointer(int device, int x, int y) { - //Hack! Will go away when we have floating-point mouse pos. + // Hack! Will go away when we have floating-point mouse pos. MouseData md = get_pointer(device); if (md.get_x() == x && md.get_y() == y) { return true; @@ -113,8 +106,8 @@ move_pointer(int device, int x, int y) { y + _properties.get_y_origin() + 1); } - // I don't know what the difference between these two methods is. - //if (CGWarpMouseCursorPosition(point) == kCGErrorSuccess) { + // I don't know what the difference between these two methods is. if + // (CGWarpMouseCursorPosition(point) == kCGErrorSuccess) { if (CGDisplayMoveCursorToPoint(_display, point) == kCGErrorSuccess) { // Generate a mouse event. NSPoint pos = [_window mouseLocationOutsideOfEventStream]; @@ -130,15 +123,12 @@ move_pointer(int device, int x, int y) { } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool CocoaGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -161,11 +151,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { // Fullscreen. CGLSetFullScreenOnDisplay((CGLContextObj) [cocoagsg->_context CGLContextObj], CGDisplayIDToOpenGLDisplayMask(_display)); } else { - // Although not recommended, it is technically possible to - // use the same context with multiple different-sized windows. - // If that happens, the context needs to be updated accordingly. + // Although not recommended, it is technically possible to use the same + // context with multiple different-sized windows. If that happens, the + // context needs to be updated accordingly. if ([cocoagsg->_context view] != _view) { - //XXX I'm not 100% sure that changing the view requires it to update. + // XXX I'm not 100% sure that changing the view requires it to update. _context_needs_update = true; [cocoagsg->_context setView:_view]; @@ -188,10 +178,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { // Make the context current. [cocoagsg->_context makeCurrentContext]; - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) cocoagsg->reset_if_new(); if (mode == FM_render) { @@ -203,13 +193,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void CocoaGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -221,7 +209,7 @@ end_frame(FrameMode mode, Thread *current_thread) { // Release the context. CocoaGraphicsStateGuardian *cocoagsg; DCAST_INTO_V(cocoagsg, _gsg); - + CGLUnlockContext((CGLContextObj) [cocoagsg->_context CGLContextObj]); if (mode == FM_render) { @@ -237,16 +225,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void CocoaGraphicsWindow:: end_flip() { if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { @@ -267,16 +252,13 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void CocoaGraphicsWindow:: process_events() { GraphicsWindow::process_events(); @@ -305,19 +287,16 @@ process_events() { [pool release]; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool CocoaGraphicsWindow:: open_window() { CocoaGraphicsPipe *cocoa_pipe; DCAST_INTO_R(cocoa_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization CocoaGraphicsStateGuardian *cocoagsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -325,8 +304,8 @@ open_window() { cocoagsg->choose_pixel_format(_fb_properties, cocoa_pipe->_display, false); _gsg = cocoagsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(cocoagsg, _gsg, false); if (!cocoagsg->get_fb_properties().subsumes(_fb_properties)) { cocoagsg = new CocoaGraphicsStateGuardian(_engine, _pipe, cocoagsg); @@ -406,9 +385,9 @@ open_window() { } } - // Center the window if coordinates were set to -1 or -2 - //TODO: perhaps in future, in the case of -1, it should use the origin - // used in a previous run of Panda + // Center the window if coordinates were set to -1 or -2 TODO: perhaps in + // future, in the case of -1, it should use the origin used in a previous + // run of Panda NSRect container; if (parent_nsview != NULL) { container = [parent_nsview bounds]; @@ -486,9 +465,8 @@ open_window() { [parent_nsview addSubview:_view]; } - // Create a WindowHandle for ourselves. - // wxWidgets seems to use the NSView pointer approach, - // so let's do the same here. + // Create a WindowHandle for ourselves. wxWidgets seems to use the NSView + // pointer approach, so let's do the same here. _window_handle = NativeWindowHandle::make_int((size_t) _view); // And tell our parent window that we're now its child. @@ -499,9 +477,9 @@ open_window() { if (_properties.has_icon_filename()) { NSImage *image = load_image(_properties.get_icon_filename()); if (image != nil) { - // We're technically changing the application icon, - // but this is most likely what the developer means. - // There isn't really a "window icon" in Mac OS X. + // We're technically changing the application icon, but this is most + // likely what the developer means. There isn't really a "window icon" + // in Mac OS X. [NSApp setApplicationIconImage:image]; } else { _properties.clear_icon_filename(); @@ -511,7 +489,7 @@ open_window() { if (_properties.has_cursor_filename()) { NSImage *image = load_image(_properties.get_cursor_filename()); NSCursor *cursor = nil; - //TODO: allow setting the hotspot, read it from file when loading .cur. + // TODO: allow setting the hotspot, read it from file when loading .cur. if (image != nil) { cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)]; } @@ -520,8 +498,8 @@ open_window() { } else { _properties.clear_cursor_filename(); } - // This will ensure that NSView's resetCursorRects gets - // called, which sets the appropriate cursor rects. + // This will ensure that NSView's resetCursorRects gets called, which sets + // the appropriate cursor rects. [[_view window] invalidateCursorRectsForView:_view]; } @@ -625,12 +603,9 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void CocoaGraphicsWindow:: close_window() { if (_mouse_hidden) { @@ -669,43 +644,34 @@ close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::mouse_mode_relative -// Access: Protected, Virtual -// Description: Overridden from GraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Overridden from GraphicsWindow. + */ void CocoaGraphicsWindow:: mouse_mode_absolute() { CGAssociateMouseAndMouseCursorPosition(YES); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::mouse_mode_relative -// Access: Protected, Virtual -// Description: Overridden from GraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Overridden from GraphicsWindow. + */ void CocoaGraphicsWindow:: mouse_mode_relative() { CGAssociateMouseAndMouseCursorPosition(NO); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The return value is true if the properties are set, -// false if they are ignored. This is mainly useful for -// derived classes to implement extensions to this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The return value is true if the properties are set, false if they are + * ignored. This is mainly useful for derived classes to implement extensions + * to this function. + */ void CocoaGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (_pipe == (GraphicsPipe *)NULL) { @@ -747,8 +713,8 @@ set_properties_now(WindowProperties &properties) { } else if (do_switch_fullscreen(mode)) { if (_window != nil) { - // For some reason, setting the style mask - // makes it give up its first-responder status. + // For some reason, setting the style mask makes it give up its + // first-responder status. if ([_window respondsToSelector:@selector(setStyleMask:)]) { [_window setStyleMask:NSBorderlessWindowMask]; } @@ -808,9 +774,8 @@ set_properties_now(WindowProperties &properties) { << "Setting size to " << width << ", " << height << "\n"; } - // Cocoa doesn't send an event, and the other - // resize-window handlers will do nothing once the properties - // have been changed, so do this now + // Cocoa doesn't send an event, and the other resize-window handlers + // will do nothing once the properties have been changed, so do this now handle_resize_event(); properties.clear_size(); @@ -889,13 +854,13 @@ set_properties_now(WindowProperties &properties) { if (properties.has_fixed_size() && _window != nil) { _properties.set_fixed_size(properties.get_fixed_size()); [_window setShowsResizeIndicator:!properties.get_fixed_size()]; - + if (!_properties.get_fullscreen()) { - // If our window is decorated, change the style mask - // to show or hide the resize button appropriately. - // However, if we're specifying the 'undecorated' property also, - // then we'll be setting the style mask about 25 LOC further down, - // so we won't need to bother setting it here. + // If our window is decorated, change the style mask to show or hide the + // resize button appropriately. However, if we're specifying the + // 'undecorated' property also, then we'll be setting the style mask + // about 25 LOC further down, so we won't need to bother setting it + // here. if (!properties.has_undecorated() && !_properties.get_undecorated() && [_window respondsToSelector:@selector(setStyleMask:)]) { if (properties.get_fixed_size()) { @@ -944,7 +909,7 @@ set_properties_now(WindowProperties &properties) { properties.clear_foreground(); } - //TODO: support raw mice. + // TODO: support raw mice. if (properties.has_cursor_hidden()) { if (properties.get_cursor_hidden() != _properties.get_cursor_hidden()) { @@ -965,9 +930,9 @@ set_properties_now(WindowProperties &properties) { NSImage *image = load_image(icon_filename); if (image != nil || icon_filename.empty()) { - // We're technically changing the application icon, - // but this is most likely what the developer means. - // There isn't really a "window icon" in Mac OS X. + // We're technically changing the application icon, but this is most + // likely what the developer means. There isn't really a "window icon" + // in Mac OS X. [NSApp setApplicationIconImage:image]; _properties.set_icon_filename(icon_filename); properties.clear_icon_filename(); @@ -1001,14 +966,14 @@ set_properties_now(WindowProperties &properties) { } } } - // This will ensure that NSView's resetCursorRects gets - // called, which sets the appropriate cursor rects. + // This will ensure that NSView's resetCursorRects gets called, which sets + // the appropriate cursor rects. [[_view window] invalidateCursorRectsForView:_view]; } if (properties.has_z_order() && _window != nil) { _properties.set_z_order(properties.get_z_order()); - + if (!_properties.get_fullscreen()) { switch (properties.get_z_order()) { case WindowProperties::Z_bottom: @@ -1045,12 +1010,10 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::find_display_mode -// Access: Protected -// Description: Returns an appropriate CGDisplayModeRef for the -// given width and height, or NULL if none was found. -//////////////////////////////////////////////////////////////////// +/** + * Returns an appropriate CGDisplayModeRef for the given width and height, or + * NULL if none was found. + */ #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 CGDisplayModeRef CocoaGraphicsWindow:: find_display_mode(int width, int height) { @@ -1062,13 +1025,13 @@ find_display_mode(int width, int height) { CFStringRef current_pixel_encoding; int refresh_rate; mode = CGDisplayCopyDisplayMode(_display); - + // First check if the current mode is adequate. if (CGDisplayModeGetWidth(mode) == width && CGDisplayModeGetHeight(mode) == height) { return mode; } - + current_pixel_encoding = CGDisplayModeCopyPixelEncoding(mode); refresh_rate = CGDisplayModeGetRefreshRate(mode); CGDisplayModeRelease(mode); @@ -1150,13 +1113,10 @@ find_display_mode(int width, int height) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::do_switch_fullscreen -// Access: Protected -// Description: Switches to the indicated fullscreen mode, or -// back to windowed if NULL was given. Returns true -// on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Switches to the indicated fullscreen mode, or back to windowed if NULL was + * given. Returns true on success, false on failure. + */ #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 bool CocoaGraphicsWindow:: do_switch_fullscreen(CGDisplayModeRef mode) { @@ -1226,22 +1186,19 @@ do_switch_fullscreen(CFDictionaryRef mode) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::load_image -// Access: Private -// Description: Loads the indicated filename and returns an NSImage -// pointer, or NULL on failure. -// Must be called from the window thread. -//////////////////////////////////////////////////////////////////// +/** + * Loads the indicated filename and returns an NSImage pointer, or NULL on + * failure. Must be called from the window thread. + */ NSImage *CocoaGraphicsWindow:: load_image(const Filename &filename) { if (filename.empty()) { return nil; } - // Note: perhaps eventually we will need to create - // an NSImageRep implementation, but for now, Apple - // seems to support the major image formats. + // Note: perhaps eventually we will need to create an NSImageRep + // implementation, but for now, Apple seems to support the major image + // formats. // Resolve the filename on the model path. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -1297,12 +1254,10 @@ load_image(const Filename &filename) { return image; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_move_event -// Access: Public -// Description: Called by CocoaPandaView or the window delegate -// when the frame rect changes. -//////////////////////////////////////////////////////////////////// +/** + * Called by CocoaPandaView or the window delegate when the frame rect + * changes. + */ void CocoaGraphicsWindow:: handle_move_event() { // Remember, Mac OS X uses flipped coordinates @@ -1332,12 +1287,10 @@ handle_move_event() { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_resize_event -// Access: Public -// Description: Called by CocoaPandaView or the window delegate -// when the frame rect changes. -//////////////////////////////////////////////////////////////////// +/** + * Called by CocoaPandaView or the window delegate when the frame rect + * changes. + */ void CocoaGraphicsWindow:: handle_resize_event() { if (_window != nil) { @@ -1364,12 +1317,10 @@ handle_resize_event() { _context_needs_update = true; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_minimize_event -// Access: Public -// Description: Called by the window delegate when the window is -// miniaturized or deminiaturized. -//////////////////////////////////////////////////////////////////// +/** + * Called by the window delegate when the window is miniaturized or + * deminiaturized. + */ void CocoaGraphicsWindow:: handle_minimize_event(bool minimized) { if (minimized == _properties.get_minimized()) { @@ -1389,12 +1340,10 @@ handle_minimize_event(bool minimized) { system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_foreground_event -// Access: Public -// Description: Called by the window delegate when the window has -// become the key window or resigned that status. -//////////////////////////////////////////////////////////////////// +/** + * Called by the window delegate when the window has become the key window or + * resigned that status. + */ void CocoaGraphicsWindow:: handle_foreground_event(bool foreground) { if (cocoadisplay_cat.is_debug()) { @@ -1410,8 +1359,8 @@ handle_foreground_event(bool foreground) { system_changed_properties(properties); if (foreground && _properties.get_mouse_mode() != WindowProperties::M_relative) { - // The mouse position may have changed during - // the time that we were not the key window. + // The mouse position may have changed during the time that we were not + // the key window. NSPoint pos = [_window mouseLocationOutsideOfEventStream]; NSPoint loc = [_view convertPoint:pos fromView:nil]; @@ -1421,23 +1370,19 @@ handle_foreground_event(bool foreground) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_close_request -// Access: Public -// Description: Called by the window delegate when the user -// requests to close the window. This may not always -// be called, which is why there is also a -// handle_close_event. -// Returns false if the user indicated that he wants -// to handle the close request himself, true if the -// operating system should continue closing the window. -//////////////////////////////////////////////////////////////////// +/** + * Called by the window delegate when the user requests to close the window. + * This may not always be called, which is why there is also a + * handle_close_event. Returns false if the user indicated that he wants to + * handle the close request himself, true if the operating system should + * continue closing the window. + */ bool CocoaGraphicsWindow:: handle_close_request() { string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept - // the request and process it directly. + // In this case, the app has indicated a desire to intercept the request + // and process it directly. throw_event(close_request_event); cocoadisplay_cat.debug() @@ -1455,11 +1400,9 @@ handle_close_request() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_close_event -// Access: Public -// Description: Called by the window delegate when the window closes. -//////////////////////////////////////////////////////////////////// +/** + * Called by the window delegate when the window closes. + */ void CocoaGraphicsWindow:: handle_close_event() { cocoadisplay_cat.debug() << "Window is about to close\n"; @@ -1505,20 +1448,17 @@ handle_close_event() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_key_event -// Access: Public -// Description: This method processes the NSEvent of type NSKeyUp, -// NSKeyDown or NSFlagsChanged and passes the -// information on to Panda. -// Should only be called by CocoaPandaView. -//////////////////////////////////////////////////////////////////// +/** + * This method processes the NSEvent of type NSKeyUp, NSKeyDown or + * NSFlagsChanged and passes the information on to Panda. Should only be + * called by CocoaPandaView. + */ void CocoaGraphicsWindow:: handle_key_event(NSEvent *event) { NSUInteger modifierFlags = [event modifierFlags]; - //NB. This is actually a on-off toggle, not up-down. - // Should we instead rapidly fire two successive up-down events? + // NB. This is actually a on-off toggle, not up-down. Should we instead + // rapidly fire two successive up-down events? handle_modifier(modifierFlags, NSAlphaShiftKeyMask, KeyboardButton::caps_lock()); // Check if any of the modifier keys have changed. @@ -1527,8 +1467,8 @@ handle_key_event(NSEvent *event) { handle_modifier(modifierFlags, NSAlternateKeyMask, KeyboardButton::alt()); handle_modifier(modifierFlags, NSCommandKeyMask, KeyboardButton::meta()); - // These are not documented, but they seem to be a reliable indicator - // of the status of the left/right modifier keys. + // These are not documented, but they seem to be a reliable indicator of the + // status of the leftright modifier keys. handle_modifier(modifierFlags, 0x0002, KeyboardButton::lshift()); handle_modifier(modifierFlags, 0x0004, KeyboardButton::rshift()); handle_modifier(modifierFlags, 0x0001, KeyboardButton::lcontrol()); @@ -1543,12 +1483,10 @@ handle_key_event(NSEvent *event) { // Get the raw button and send it. ButtonHandle raw_button = map_raw_key([event keyCode]); if (raw_button != ButtonHandle::none()) { - // This is not perfect. Eventually, this whole thing should - // probably be replaced with something that uses IOKit or so. - // In particular, the flaws are: - // - OS eats unmodified F11, F12, scroll lock, pause - // - no up events for caps lock - // - no robust way to distinguish up/down for modkeys + // This is not perfect. Eventually, this whole thing should probably be + // replaced with something that uses IOKit or so. In particular, the + // flaws are: - OS eats unmodified F11, F12, scroll lock, pause - no up + // events for caps lock - no robust way to distinguish updown for modkeys if ([event type] == NSKeyUp) { _input_devices[0].raw_button_up(raw_button); @@ -1599,8 +1537,8 @@ handle_key_event(NSEvent *event) { ButtonHandle button = map_key(c); if (c < 0xF700 || c >= 0xF900) { - // If a down event and not a special function key, - // process it as keystroke as well. + // If a down event and not a special function key, process it as keystroke + // as well. if ([event type] == NSKeyDown) { NSString *origstr = [event characters]; c = [str characterAtIndex: 0]; @@ -1639,12 +1577,9 @@ handle_key_event(NSEvent *event) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_modifier -// Access: Private -// Description: Called by handle_key_event to read the state of -// a modifier key. -//////////////////////////////////////////////////////////////////// +/** + * Called by handle_key_event to read the state of a modifier key. + */ void CocoaGraphicsWindow:: handle_modifier(NSUInteger modifierFlags, NSUInteger mask, ButtonHandle button) { if ((modifierFlags ^ _modifier_keys) & mask) { @@ -1656,13 +1591,10 @@ handle_modifier(NSUInteger modifierFlags, NSUInteger mask, ButtonHandle button) } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_mouse_button_event -// Access: Public -// Description: This method processes the NSEvents related to -// mouse button presses. -// Should only be called by CocoaPandaView. -//////////////////////////////////////////////////////////////////// +/** + * This method processes the NSEvents related to mouse button presses. Should + * only be called by CocoaPandaView. + */ void CocoaGraphicsWindow:: handle_mouse_button_event(int button, bool down) { if (down) { @@ -1682,13 +1614,10 @@ handle_mouse_button_event(int button, bool down) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_mouse_moved_event -// Access: Public -// Description: This method processes the NSEvents of the -// mouseMoved and mouseDragged types. -// Should only be called by CocoaPandaView. -//////////////////////////////////////////////////////////////////// +/** + * This method processes the NSEvents of the mouseMoved and mouseDragged + * types. Should only be called by CocoaPandaView. + */ void CocoaGraphicsWindow:: handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) { double nx, ny; @@ -1740,8 +1669,8 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) { ClockObject::get_global_clock()->get_frame_time()); if (in_window != _mouse_hidden && _properties.get_cursor_hidden()) { - // Hide the cursor if the mouse enters the window, - // and unhide it when the mouse leaves the window. + // Hide the cursor if the mouse enters the window, and unhide it when the + // mouse leaves the window. if (in_window) { [NSCursor hide]; } else { @@ -1751,12 +1680,9 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::handle_wheel_event -// Access: Public -// Description: Called by CocoaPandaView to inform that the scroll -// wheel has been used. -//////////////////////////////////////////////////////////////////// +/** + * Called by CocoaPandaView to inform that the scroll wheel has been used. + */ void CocoaGraphicsWindow:: handle_wheel_event(double x, double y) { cocoadisplay_cat.spam() @@ -1770,7 +1696,7 @@ handle_wheel_event(double x, double y) { _input_devices[0].button_up(MouseButton::wheel_down()); } - //TODO: check if this is correct, I don't own a MacBook + // TODO: check if this is correct, I don't own a MacBook if (x > 0.0) { _input_devices[0].button_down(MouseButton::wheel_right()); _input_devices[0].button_up(MouseButton::wheel_right()); @@ -1780,12 +1706,10 @@ handle_wheel_event(double x, double y) { } } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::get_keyboard_map -// Access: Published, Virtual -// Description: Returns a ButtonMap containing the association -// between raw buttons and virtual buttons. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ButtonMap containing the association between raw buttons and + * virtual buttons. + */ ButtonMap *CocoaGraphicsWindow:: get_keyboard_map() const { TISInputSourceRef input_source; @@ -1802,8 +1726,8 @@ get_keyboard_map() const { UniChar chars[4]; UniCharCount num_chars; - // Iterate through the known scancode range and see what - // every scan code is mapped to. + // Iterate through the known scancode range and see what every scan code is + // mapped to. for (int k = 0; k <= 0x7E; ++k) { ButtonHandle raw_button = map_raw_key(k); if (raw_button == ButtonHandle::none()) { @@ -1827,7 +1751,8 @@ get_keyboard_map() const { map->map_button(raw_button, button); } } else { - // A special function key or modifier key, which isn't remapped by the OS. + // A special function key or modifier key, which isn't remapped by the + // OS. map->map_button(raw_button, raw_button); } } @@ -1837,11 +1762,9 @@ get_keyboard_map() const { return map; } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::map_key -// Access: Private -// Description: Maps a unicode key character to a ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Maps a unicode key character to a ButtonHandle. + */ ButtonHandle CocoaGraphicsWindow:: map_key(unsigned short c) const { switch (c) { @@ -1857,8 +1780,8 @@ map_key(unsigned short c) const { return KeyboardButton::tab(); case 0x10: - // No idea where this constant comes from, but it - // is sent whenever the menu key is pressed. + // No idea where this constant comes from, but it is sent whenever the + // menu key is pressed. return KeyboardButton::menu(); case 0x1e: @@ -1982,11 +1905,9 @@ map_key(unsigned short c) const { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: CocoaGraphicsWindow::map_raw_key -// Access: Private -// Description: Maps a keycode to a ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Maps a keycode to a ButtonHandle. + */ ButtonHandle CocoaGraphicsWindow:: map_raw_key(unsigned short keycode) const { if (keycode > 0x7f) { diff --git a/panda/src/cocoadisplay/cocoaPandaApp.h b/panda/src/cocoadisplay/cocoaPandaApp.h index ab3aca2d37..94da57fbd0 100644 --- a/panda/src/cocoadisplay/cocoaPandaApp.h +++ b/panda/src/cocoadisplay/cocoaPandaApp.h @@ -1,22 +1,21 @@ -// Filename: cocoaPandaApp.h -// Created by: rdb (08Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaApp.h + * @author rdb + * @date 2014-03-08 + */ #import #import -// This class solely exists so that we can override sendEvent in order -// to prevent NSApplication from eating certain keyboard events. +// This class solely exists so that we can override sendEvent in order to +// prevent NSApplication from eating certain keyboard events. @interface CocoaPandaApp : NSApplication - (void) sendEvent: (NSEvent *) event; @end diff --git a/panda/src/cocoadisplay/cocoaPandaApp.mm b/panda/src/cocoadisplay/cocoaPandaApp.mm index 95efc8fe2d..7c28adda40 100644 --- a/panda/src/cocoadisplay/cocoaPandaApp.mm +++ b/panda/src/cocoadisplay/cocoaPandaApp.mm @@ -1,23 +1,22 @@ -// Filename: cocoaPandaApp.mm -// Created by: rdb (08Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaApp.mm + * @author rdb + * @date 2014-03-08 + */ #import "cocoaPandaApp.h" @implementation CocoaPandaApp - (void) sendEvent: (NSEvent *) event { // This is a hack that allows us to receive cmd-key-up events correctly. - // Also prevent it from eating the insert/help key. + // Also prevent it from eating the inserthelp key. if (([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) ||([event type] == NSKeyDown && [event keyCode] == 0x72)) { diff --git a/panda/src/cocoadisplay/cocoaPandaView.h b/panda/src/cocoadisplay/cocoaPandaView.h index 05ac92bc81..819b088ff7 100644 --- a/panda/src/cocoadisplay/cocoaPandaView.h +++ b/panda/src/cocoadisplay/cocoaPandaView.h @@ -1,16 +1,15 @@ -// Filename: cocoaPandaView.h -// Created by: rdb (17May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaView.h + * @author rdb + * @date 2012-05-17 + */ #include "graphicsWindow.h" diff --git a/panda/src/cocoadisplay/cocoaPandaView.mm b/panda/src/cocoadisplay/cocoaPandaView.mm index 3f0fa550fd..c3471ec36b 100644 --- a/panda/src/cocoadisplay/cocoaPandaView.mm +++ b/panda/src/cocoadisplay/cocoaPandaView.mm @@ -1,16 +1,15 @@ -// Filename: cocoaPandaView.mm -// Created by: rdb (17May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaView.mm + * @author rdb + * @date 2012-05-17 + */ #include "config_cocoadisplay.h" #import "cocoaPandaView.h" @@ -57,8 +56,8 @@ } - (BOOL) isFlipped { - // Apple uses a coordinate system where the lower-left corner - // represents (0, 0). In Panda, this is the upper-left corner. + // Apple uses a coordinate system where the lower-left corner represents (0, + // 0). In Panda, this is the upper-left corner. return YES; } @@ -70,11 +69,11 @@ - (BOOL) acceptsFirstResponder { return YES; } - + - (BOOL) becomeFirstResponder { return YES; } - + - (BOOL) resignFirstResponder { return YES; } @@ -87,7 +86,7 @@ - (void) setFrame: (NSRect) frame { [super setFrame: frame]; - //_graphicsWindow->handle_resize_event(); + // _graphicsWindow->handle_resize_event(); } - (void) keyDown: (NSEvent *) event { @@ -118,9 +117,8 @@ NSPoint loc = [self convertPoint:[event locationInWindow] fromView:nil]; BOOL inside = [self mouse:loc inRect:[self bounds]]; - // the correlation between mouse deltas and location - // are "debounced" apparently, so send deltas for both - // relative and confined modes + // the correlation between mouse deltas and location are "debounced" + // apparently, so send deltas for both relative and confined modes if (_graphicsWindow->get_properties().get_mouse_mode() != WindowProperties::M_absolute) { _graphicsWindow->handle_mouse_moved_event(inside, [event deltaX], [event deltaY], false); } else { diff --git a/panda/src/cocoadisplay/cocoaPandaWindow.h b/panda/src/cocoadisplay/cocoaPandaWindow.h index faeb6a7960..b131896f70 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindow.h +++ b/panda/src/cocoadisplay/cocoaPandaWindow.h @@ -1,16 +1,15 @@ -// Filename: cocoaPandaWindow.h -// Created by: rdb (25May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaWindow.h + * @author rdb + * @date 2012-05-25 + */ #import diff --git a/panda/src/cocoadisplay/cocoaPandaWindow.mm b/panda/src/cocoadisplay/cocoaPandaWindow.mm index 411f08a25c..5b28d4f292 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindow.mm +++ b/panda/src/cocoadisplay/cocoaPandaWindow.mm @@ -1,16 +1,15 @@ -// Filename: cocoaPandaWindow.mm -// Created by: rdb (25May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaWindow.mm + * @author rdb + * @date 2012-05-25 + */ #import "cocoaPandaWindow.h" #import "cocoaPandaWindowDelegate.h" diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h index fd7333bed0..1a80ef056e 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.h @@ -1,16 +1,15 @@ -// Filename: cocoaPandaWindowDelegate.h -// Created by: rdb (24May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaWindowDelegate.h + * @author rdb + * @date 2012-05-24 + */ #import @@ -37,6 +36,6 @@ class CocoaGraphicsWindow; - (BOOL)windowShouldClose:(id)sender; - (void)windowWillClose:(NSNotification *)notification; -//TODO: handle fullscreen on Lion. +// TODO: handle fullscreen on Lion. @end diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm index 505c2f2a5a..6b93410538 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm @@ -1,16 +1,15 @@ -// Filename: cocoaPandaWindowDelegate.mm -// Created by: rdb (24May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cocoaPandaWindowDelegate.mm + * @author rdb + * @date 2012-05-24 + */ #import "cocoaPandaWindowDelegate.h" @@ -29,8 +28,8 @@ } - (void) windowDidResize:(NSNotification *)notification { - // Forcing a move event is unfortunately necessary because - // Cocoa does not call windowDidMove in case of window zooms. + // Forcing a move event is unfortunately necessary because Cocoa does not + // call windowDidMove in case of window zooms. _graphicsWindow->handle_resize_event(); } diff --git a/panda/src/cocoadisplay/config_cocoadisplay.h b/panda/src/cocoadisplay/config_cocoadisplay.h index 16059434ca..a5ed970b8f 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.h +++ b/panda/src/cocoadisplay/config_cocoadisplay.h @@ -1,16 +1,15 @@ -// Filename: config_cocoadisplay.h -// Created by: rdb (17May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cocoadisplay.h + * @author rdb + * @date 2012-05-17 + */ #ifndef CONFIG_COCOADISPLAY_H #define CONFIG_COCOADISPLAY_H diff --git a/panda/src/cocoadisplay/config_cocoadisplay.mm b/panda/src/cocoadisplay/config_cocoadisplay.mm index f61a3237a5..4f67bc1438 100644 --- a/panda/src/cocoadisplay/config_cocoadisplay.mm +++ b/panda/src/cocoadisplay/config_cocoadisplay.mm @@ -1,16 +1,15 @@ -// Filename: config_cocoadisplay.mm -// Created by: rdb (17May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cocoadisplay.mm + * @author rdb + * @date 2012-05-17 + */ #include "config_cocoadisplay.h" #include "cocoaGraphicsPipe.h" @@ -27,14 +26,12 @@ ConfigureFn(config_cocoadisplay) { init_libcocoadisplay(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libcocoadisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libcocoadisplay() { static bool initialized = false; diff --git a/panda/src/collada/colladaBindMaterial.cxx b/panda/src/collada/colladaBindMaterial.cxx index c106cf63b0..768e31a46d 100644 --- a/panda/src/collada/colladaBindMaterial.cxx +++ b/panda/src/collada/colladaBindMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: colladaBindMaterial.cxx -// Created by: rdb (26May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaBindMaterial.cxx + * @author rdb + * @date 2011-05-26 + */ #include "colladaBindMaterial.h" #include "colladaPrimitive.h" @@ -32,11 +31,10 @@ #define getFx_profile_array getFx_profile_abstract_array #endif -//////////////////////////////////////////////////////////////////// -// Function: ColladaBindMaterial::get_material -// Description: Returns the material to be applied to the given -// primitive, or NULL if there was none bound. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material to be applied to the given primitive, or NULL if there + * was none bound. + */ CPT(RenderState) ColladaBindMaterial:: get_material(const ColladaPrimitive *prim) const { if (prim == NULL || _states.count(prim->get_material()) == 0) { @@ -45,11 +43,10 @@ get_material(const ColladaPrimitive *prim) const { return _states.find(prim->get_material())->second; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaBindMaterial::get_material -// Description: Returns the bound material with the indicated -// symbol, or NULL if it was not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bound material with the indicated symbol, or NULL if it was not + * found. + */ CPT(RenderState) ColladaBindMaterial:: get_material(const string &symbol) const { if (_states.count(symbol) == 0) { @@ -58,10 +55,9 @@ get_material(const string &symbol) const { return _states.find(symbol)->second; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaBindMaterial::load_bind_material -// Description: Loads a bind_material object. -//////////////////////////////////////////////////////////////////// +/** + * Loads a bind_material object. + */ void ColladaBindMaterial:: load_bind_material(domBind_material &bind_mat) { domInstance_material_Array &mat_instances @@ -72,10 +68,9 @@ load_bind_material(domBind_material &bind_mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaBindMaterial::load_instance_material -// Description: Loads an instance_material object. -//////////////////////////////////////////////////////////////////// +/** + * Loads an instance_material object. + */ void ColladaBindMaterial:: load_instance_material(domInstance_material &inst) { domMaterialRef mat = daeSafeCast (inst.getTarget().getElement()); @@ -89,10 +84,10 @@ load_instance_material(domInstance_material &inst) { domEffectRef effect = daeSafeCast (mat->getInstance_effect()->getUrl().getElement()); - //TODO: read params - + // TODO: read params + const domFx_profile_Array &profiles = effect->getFx_profile_array(); for (size_t i = 0; i < profiles.getCount(); ++i) { - //profiles[i]-> + // profiles[i]-> } } diff --git a/panda/src/collada/colladaBindMaterial.h b/panda/src/collada/colladaBindMaterial.h index d5ec2e39fa..18cf5b80a8 100644 --- a/panda/src/collada/colladaBindMaterial.h +++ b/panda/src/collada/colladaBindMaterial.h @@ -1,16 +1,15 @@ -// Filename: colladaBindMaterial.h -// Created by: rdb (25May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaBindMaterial.h + * @author rdb + * @date 2011-05-25 + */ #ifndef COLLADABINDMATERIAL_H #define COLLADABINDMATERIAL_H @@ -24,11 +23,9 @@ class ColladaPrimitive; class domBind_material; class domInstance_material; -//////////////////////////////////////////////////////////////////// -// Class : ColladaBindMaterial -// Description : Class that deals with binding materials to -// COLLADA geometry. -//////////////////////////////////////////////////////////////////// +/** + * Class that deals with binding materials to COLLADA geometry. + */ class ColladaBindMaterial { public: CPT(RenderState) get_material(const ColladaPrimitive *prim) const; diff --git a/panda/src/collada/colladaInput.I b/panda/src/collada/colladaInput.I index 1b0873844f..15177ed8fe 100644 --- a/panda/src/collada/colladaInput.I +++ b/panda/src/collada/colladaInput.I @@ -1,32 +1,27 @@ -// Filename: colladaInput.I -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaInput.I + * @author rdb + * @date 2011-05-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::is_vertex_source -// Description: Returns true if this has a element as -// source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this has a element as source. + */ bool ColladaInput:: is_vertex_source() const { return (_semantic == "VERTEX"); } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::get_offset -// Description: Returns the offset associated with this input. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset associated with this input. + */ unsigned int ColladaInput:: get_offset() const { return _offset; diff --git a/panda/src/collada/colladaInput.cxx b/panda/src/collada/colladaInput.cxx index e9ba157257..b0f77ccd4e 100644 --- a/panda/src/collada/colladaInput.cxx +++ b/panda/src/collada/colladaInput.cxx @@ -1,16 +1,15 @@ -// Filename: colladaInput.cxx -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaInput.cxx + * @author rdb + * @date 2011-05-23 + */ #include "colladaInput.h" #include "string_utils.h" @@ -34,10 +33,9 @@ #define domList_of_uints domListOfUInts #endif -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::Constructor -// Description: Pretty obvious what this does. -//////////////////////////////////////////////////////////////////// +/** + * Pretty obvious what this does. + */ ColladaInput:: ColladaInput(const string &semantic) : _column_name (NULL), @@ -67,10 +65,9 @@ ColladaInput(const string &semantic) : } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::Constructor -// Description: Pretty obvious what this does. -//////////////////////////////////////////////////////////////////// +/** + * Pretty obvious what this does. + */ ColladaInput:: ColladaInput(const string &semantic, unsigned int set) : _column_name (NULL), @@ -103,11 +100,10 @@ ColladaInput(const string &semantic, unsigned int set) : } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::from_dom -// Description: Returns the ColladaInput object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaInput object that represents the provided DOM input + * element. + */ ColladaInput *ColladaInput:: from_dom(domInput_local_offset &input) { // If we already loaded it before, use that. @@ -138,11 +134,10 @@ from_dom(domInput_local_offset &input) { return new_input; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::from_dom -// Description: Returns the ColladaInput object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaInput object that represents the provided DOM input + * element. + */ ColladaInput *ColladaInput:: from_dom(domInput_local &input) { // If we already loaded it before, use that. @@ -162,14 +157,11 @@ from_dom(domInput_local &input) { return new_input; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::make_vertex_columns -// Description: Takes a semantic and source URI, and adds a new -// column to the format. If this is a vertex source, -// adds all of the inputs from the corresponding -// element. Returns the number of -// columns added to the format. -//////////////////////////////////////////////////////////////////// +/** + * Takes a semantic and source URI, and adds a new column to the format. If + * this is a vertex source, adds all of the inputs from the corresponding + * element. Returns the number of columns added to the format. + */ int ColladaInput:: make_vertex_columns(GeomVertexArrayFormat *format) const { @@ -188,10 +180,9 @@ make_vertex_columns(GeomVertexArrayFormat *format) const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::read_data -// Description: Reads the data from the source and fills in _data. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data from the source and fills in _data. + */ bool ColladaInput:: read_data(domSource &source) { _data.clear(); @@ -219,8 +210,8 @@ read_data(domSource &source) { domUint pos = accessor.getOffset(); for (domUint a = 0; a < accessor.getCount(); ++a) { domUint c = 0; - // Yes, the last component defaults to 1 to work around a - // perspective divide that Panda3D does internally for points. + // Yes, the last component defaults to 1 to work around a perspective + // divide that Panda3D does internally for points. LVecBase4f v (0, 0, 0, 1); for (domUint p = 0; p < params.getCount(); ++p) { if (params[c]->getName()) { @@ -234,11 +225,9 @@ read_data(domSource &source) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::write_data -// Description: Writes data to the indicated GeomVertexData using -// the given indices. -//////////////////////////////////////////////////////////////////// +/** + * Writes data to the indicated GeomVertexData using the given indices. + */ void ColladaInput:: write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) const { if (is_vertex_source()) { @@ -252,10 +241,9 @@ write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride) c } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaInput::write_data -// Description: Called internally by the other write_data. -//////////////////////////////////////////////////////////////////// +/** + * Called internally by the other write_data. + */ void ColladaInput:: write_data(GeomVertexData *vdata, int start_row, domP &p, unsigned int stride, unsigned int offset) const { nassertv(_column_name != NULL); diff --git a/panda/src/collada/colladaInput.h b/panda/src/collada/colladaInput.h index 110d20911e..53629ecf8d 100644 --- a/panda/src/collada/colladaInput.h +++ b/panda/src/collada/colladaInput.h @@ -1,16 +1,15 @@ -// Filename: colladaInput.h -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaInput.h + * @author rdb + * @date 2011-05-23 + */ #ifndef COLLADAINPUT_H #define COLLADAINPUT_H @@ -38,10 +37,9 @@ class domInput_local_offset; class domP; class domSource; -//////////////////////////////////////////////////////////////////// -// Class : ColladaInput -// Description : Class that deals with COLLADA data sources. -//////////////////////////////////////////////////////////////////// +/** + * Class that deals with COLLADA data sources. + */ class ColladaInput : public ReferenceCount { public: static ColladaInput *from_dom(domInput_local_offset &input); diff --git a/panda/src/collada/colladaLoader.I b/panda/src/collada/colladaLoader.I index b9ff7524fc..2c03d60d16 100644 --- a/panda/src/collada/colladaLoader.I +++ b/panda/src/collada/colladaLoader.I @@ -1,14 +1,12 @@ -// Filename: colladaLoader.I -// Created by: rdb (16Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaLoader.I + * @author rdb + * @date 2011-03-16 + */ diff --git a/panda/src/collada/colladaLoader.cxx b/panda/src/collada/colladaLoader.cxx index f2dcc32ff2..93749b30b6 100644 --- a/panda/src/collada/colladaLoader.cxx +++ b/panda/src/collada/colladaLoader.cxx @@ -1,16 +1,15 @@ -// Filename: colladaLoader.cxx -// Created by: Xidram (21Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaLoader.cxx + * @author Xidram + * @date 2010-12-21 + */ #include "colladaLoader.h" #include "virtualFileSystem.h" @@ -48,10 +47,9 @@ #define TOSTRING(x) (x == NULL ? "" : x) -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::Constructor -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ColladaLoader:: ColladaLoader() : _record (NULL), @@ -63,19 +61,17 @@ ColladaLoader() : _dae = new DAE; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::Destructor -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ColladaLoader:: ~ColladaLoader() { delete _dae; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::read -// Description: Reads from the indicated file. -//////////////////////////////////////////////////////////////////// +/** + * Reads from the indicated file. + */ bool ColladaLoader:: read(const Filename &filename) { _filename = filename; @@ -95,11 +91,10 @@ read(const Filename &filename) { return !_error; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::build_graph -// Description: Converts scene graph structures into a Panda3D -// scene graph, with _root being the root node. -//////////////////////////////////////////////////////////////////// +/** + * Converts scene graph structures into a Panda3D scene graph, with _root + * being the root node. + */ void ColladaLoader:: build_graph() { nassertv(_collada); // read() must be called first @@ -115,10 +110,9 @@ build_graph() { } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_visual_scene -// Description: Loads a visual scene structure. -//////////////////////////////////////////////////////////////////// +/** + * Loads a visual scene structure. + */ void ColladaLoader:: load_visual_scene(domVisual_scene& scene, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. @@ -156,10 +150,9 @@ load_visual_scene(domVisual_scene& scene, PandaNode *parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_node -// Description: Loads a COLLADA . -//////////////////////////////////////////////////////////////////// +/** + * Loads a COLLADA . + */ void ColladaLoader:: load_node(domNode& node, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. @@ -220,7 +213,7 @@ load_node(domNode& node, PandaNode *parent) { break; } case COLLADA_TYPE::SKEW: - //FIXME: implement skew + // FIXME: implement skew collada_cat.error() << " not supported yet\n"; break; case COLLADA_TYPE::TRANSLATE: { @@ -230,8 +223,8 @@ load_node(domNode& node, PandaNode *parent) { } } } - //TODO: convert coordinate systems - //transform *= LMatrix4f::convert_mat(XXX, _cs); + // TODO: convert coordinate systems transform *= LMatrix4f::convert_mat(XXX, + // _cs); // If there's a transform, set it. if (transform != LMatrix4f::ident_mat()) { @@ -249,11 +242,10 @@ load_node(domNode& node, PandaNode *parent) { domInstance_controller_Array &ctrlinst = node.getInstance_controller_array(); for (size_t i = 0; i < ctrlinst.getCount(); ++i) { domController* target = daeSafeCast (ctrlinst[i]->getUrl().getElement()); - //TODO: implement controllers. For now, let's just read the geometry + // TODO: implement controllers. For now, let's just read the geometry if (target->getSkin() != NULL) { domGeometry* geom = daeSafeCast (target->getSkin()->getSource().getElement()); - //TODO - //load_geometry(*geom, ctrlinst[i]->getBind_material(), pnode); + // TODO load_geometry(*geom, ctrlinst[i]->getBind_material(), pnode); } } @@ -287,15 +279,14 @@ load_node(domNode& node, PandaNode *parent) { domExtra_Array &extras = node.getExtra_array(); for (size_t i = 0; i < extras.getCount(); ++i) { load_tags(*extras[i], pnode); - //TODO: load SI_Visibility under XSI profile - //TODO: support OpenSceneGraph's switch nodes + // TODO: load SI_Visibility under XSI profile TODO: support + // OpenSceneGraph's switch nodes } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_tags -// Description: Loads tags specified in an element. -//////////////////////////////////////////////////////////////////// +/** + * Loads tags specified in an element. + */ void ColladaLoader:: load_tags(domExtra &extra, PandaNode *node) { domTechnique_Array &techniques = extra.getTechnique_array(); @@ -324,10 +315,9 @@ load_tags(domExtra &extra, PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_camera -// Description: Loads a COLLADA as a Camera object. -//////////////////////////////////////////////////////////////////// +/** + * Loads a COLLADA as a Camera object. + */ void ColladaLoader:: load_camera(domCamera &cam, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. @@ -336,14 +326,12 @@ load_camera(domCamera &cam, PandaNode *parent) { return; } - //TODO + // TODO } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_instance_geometry -// Description: Loads a COLLADA as a GeomNode -// object. -//////////////////////////////////////////////////////////////////// +/** + * Loads a COLLADA as a GeomNode object. + */ void ColladaLoader:: load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. @@ -375,20 +363,19 @@ load_instance_geometry(domInstance_geometry &inst, PandaNode *parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_geometry -// Description: Loads a COLLADA and adds the primitives -// to the given GeomNode object. -//////////////////////////////////////////////////////////////////// +/** + * Loads a COLLADA and adds the primitives to the given GeomNode + * object. + */ void ColladaLoader:: load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) { domMesh* mesh = geom.getMesh(); if (mesh == NULL) { - //TODO: support non-mesh geometry. + // TODO: support non-mesh geometry. return; } - //TODO: support other than just triangles. + // TODO: support other than just triangles. domLines_Array &lines_array = mesh->getLines_array(); for (size_t i = 0; i < lines_array.getCount(); ++i) { PT(ColladaPrimitive) prim = ColladaPrimitive::from_dom(*lines_array[i]); @@ -446,10 +433,9 @@ load_geometry(domGeometry &geom, GeomNode *gnode, ColladaBindMaterial &bind_mat) } } -//////////////////////////////////////////////////////////////////// -// Function: ColladaLoader::load_light -// Description: Loads a COLLADA as a LightNode object. -//////////////////////////////////////////////////////////////////// +/** + * Loads a COLLADA as a LightNode object. + */ void ColladaLoader:: load_light(domLight &light, PandaNode *parent) { // If we already loaded it before, instantiate the stored node. diff --git a/panda/src/collada/colladaLoader.h b/panda/src/collada/colladaLoader.h index d3d75b25a4..e5f894ccba 100644 --- a/panda/src/collada/colladaLoader.h +++ b/panda/src/collada/colladaLoader.h @@ -1,16 +1,15 @@ -// Filename: colladaLoader.h -// Created by: Xidram (21Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaLoader.h + * @author Xidram + * @date 2010-12-21 + */ #ifndef COLLADALOADER_H #define COLLADALOADER_H @@ -40,11 +39,10 @@ class domCamera; class domSource; class DAE; -//////////////////////////////////////////////////////////////////// -// Class : ColladaLoader -// Description : Object that interfaces with the COLLADA DOM library -// and loads the COLLADA structures into Panda nodes. -//////////////////////////////////////////////////////////////////// +/** + * Object that interfaces with the COLLADA DOM library and loads the COLLADA + * structures into Panda nodes. + */ class ColladaLoader { public: ColladaLoader(); diff --git a/panda/src/collada/colladaPrimitive.I b/panda/src/collada/colladaPrimitive.I index 7462524ed2..697e028f39 100644 --- a/panda/src/collada/colladaPrimitive.I +++ b/panda/src/collada/colladaPrimitive.I @@ -1,22 +1,19 @@ -// Filename: colladaPrimitive.I -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaPrimitive.I + * @author rdb + * @date 2011-05-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::add_input -// Description: Adds a new ColladaInput to this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new ColladaInput to this primitive. + */ INLINE void ColladaPrimitive:: add_input(ColladaInput *input) { if (input->get_offset() >= _stride) { @@ -25,20 +22,18 @@ add_input(ColladaInput *input) { _inputs.push_back(input); } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::get_geom -// Description: Returns the Geom associated with this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Geom associated with this primitive. + */ INLINE PT(Geom) ColladaPrimitive:: get_geom() const { return _geom; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::get_material -// Description: Returns the name of this primitive's material, or -// the empty string if none was assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this primitive's material, or the empty string if none + * was assigned. + */ INLINE const string &ColladaPrimitive:: get_material() const { return _material; diff --git a/panda/src/collada/colladaPrimitive.cxx b/panda/src/collada/colladaPrimitive.cxx index ffa1266459..f1c627cb00 100644 --- a/panda/src/collada/colladaPrimitive.cxx +++ b/panda/src/collada/colladaPrimitive.cxx @@ -1,16 +1,15 @@ -// Filename: colladaPrimitive.cxx -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaPrimitive.cxx + * @author rdb + * @date 2011-05-23 + */ #include "colladaPrimitive.h" #include "geomLines.h" @@ -33,11 +32,10 @@ #define domInput_local_offsetRef domInputLocalOffsetRef #endif -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::Constructor -// Description: Why do I even bother documenting the simplest of -// constructors? A private one at that. -//////////////////////////////////////////////////////////////////// +/** + * Why do I even bother documenting the simplest of constructors? A private + * one at that. + */ ColladaPrimitive:: ColladaPrimitive(GeomPrimitive *prim, daeTArray &inputs) : _stride (1), _gprim (prim) { @@ -60,11 +58,10 @@ ColladaPrimitive(GeomPrimitive *prim, daeTArray &input _geom->add_primitive(_gprim); } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domLines &prim) { // If we already loaded it before, use that. @@ -87,11 +84,10 @@ from_dom(domLines &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domLinestrips &prim) { // If we already loaded it before, use that. @@ -111,11 +107,10 @@ from_dom(domLinestrips &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domPolygons &prim) { // If we already loaded it before, use that. @@ -123,9 +118,9 @@ from_dom(domPolygons &prim) { return (ColladaPrimitive *) prim.getUserData(); } - // We use trifans to represent polygons, seems to be easiest. - // I tried using tristrips instead, but for some reason, - // this resulted in a few flipped polygons. Weird. + // We use trifans to represent polygons, seems to be easiest. I tried using + // tristrips instead, but for some reason, this resulted in a few flipped + // polygons. Weird. ColladaPrimitive *new_prim = new ColladaPrimitive(new GeomTrifans(GeomEnums::UH_static), prim.getInput_array()); @@ -143,11 +138,10 @@ from_dom(domPolygons &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domPolylist &prim) { // If we already loaded it before, use that. @@ -155,9 +149,9 @@ from_dom(domPolylist &prim) { return (ColladaPrimitive *) prim.getUserData(); } - // We use trifans to represent polygons, seems to be easiest. - // I tried using tristrips instead, but for some reason, - // this resulted in a few flipped polygons. Weird. + // We use trifans to represent polygons, seems to be easiest. I tried using + // tristrips instead, but for some reason, this resulted in a few flipped + // polygons. Weird. PT(GeomPrimitive) gprim = new GeomTrifans(GeomEnums::UH_static); ColladaPrimitive *new_prim = @@ -184,11 +178,10 @@ from_dom(domPolylist &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domTriangles &prim) { // If we already loaded it before, use that. @@ -211,11 +204,10 @@ from_dom(domTriangles &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domTrifans &prim) { // If we already loaded it before, use that. @@ -235,11 +227,10 @@ from_dom(domTrifans &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::from_dom -// Description: Returns the ColladaPrimitive object that represents -// the provided DOM input element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ColladaPrimitive object that represents the provided DOM input + * element. + */ ColladaPrimitive *ColladaPrimitive:: from_dom(domTristrips &prim) { // If we already loaded it before, use that. @@ -259,11 +250,10 @@ from_dom(domTristrips &prim) { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::write_data -// Description: Writes the vertex data to the GeomVertexData. -// Returns the number of rows written. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vertex data to the GeomVertexData. Returns the number of rows + * written. + */ unsigned int ColladaPrimitive:: write_data(GeomVertexData *vdata, int start_row, domP &p) { unsigned int num_vertices = p.getValue().getCount() / _stride; @@ -276,22 +266,20 @@ write_data(GeomVertexData *vdata, int start_row, domP &p) { return num_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::load_primitive -// Description: Adds the given indices to the primitive, and -// writes the relevant data to the geom. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given indices to the primitive, and writes the relevant data to + * the geom. + */ void ColladaPrimitive:: load_primitive(domP &p) { _gprim->add_next_vertices(write_data(_vdata, 0, p)); _gprim->close_primitive(); } -//////////////////////////////////////////////////////////////////// -// Function: ColladaPrimitive::load_primitives -// Description: Adds the given indices to the primitive, and -// writes the relevant data to the geom. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given indices to the primitive, and writes the relevant data to + * the geom. + */ void ColladaPrimitive:: load_primitives(domP_Array &p_array) { int start_row = 0; @@ -303,4 +291,3 @@ load_primitives(domP_Array &p_array) { start_row += num_vertices; } } - diff --git a/panda/src/collada/colladaPrimitive.h b/panda/src/collada/colladaPrimitive.h index 659499fff9..740329e020 100644 --- a/panda/src/collada/colladaPrimitive.h +++ b/panda/src/collada/colladaPrimitive.h @@ -1,16 +1,15 @@ -// Filename: colladaPrimitive.h -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colladaPrimitive.h + * @author rdb + * @date 2011-05-23 + */ #ifndef COLLADAPRIMITIVE_H #define COLLADAPRIMITIVE_H @@ -32,11 +31,10 @@ class domTriangles; class domTrifans; class domTristrips; -//////////////////////////////////////////////////////////////////// -// Class : ColladaPrimitive -// Description : Class that deals with COLLADA primitive structures, -// such as and . -//////////////////////////////////////////////////////////////////// +/** + * Class that deals with COLLADA primitive structures, such as and + * . + */ class ColladaPrimitive : public ReferenceCount { public: static ColladaPrimitive *from_dom(domLines &lines); diff --git a/panda/src/collada/config_collada.cxx b/panda/src/collada/config_collada.cxx index 5ddfd7fd97..81404110f2 100644 --- a/panda/src/collada/config_collada.cxx +++ b/panda/src/collada/config_collada.cxx @@ -1,16 +1,15 @@ -// Filename: config_collada.cxx -// Created by: Xidram (21Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_collada.cxx + * @author Xidram + * @date 2010-12-21 + */ #include "config_collada.h" @@ -64,14 +63,12 @@ ConfigureFn(config_collada) { init_libcollada(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libcollada -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libcollada() { static bool initialized = false; @@ -84,4 +81,3 @@ init_libcollada() { reg->register_type(new LoaderFileTypeDae); } - diff --git a/panda/src/collada/config_collada.h b/panda/src/collada/config_collada.h index 5f019eca61..966f497038 100644 --- a/panda/src/collada/config_collada.h +++ b/panda/src/collada/config_collada.h @@ -1,16 +1,15 @@ -// Filename: config_collada.h -// Created by: Xidram (21Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_collada.h + * @author Xidram + * @date 2010-12-21 + */ #ifndef CONFIG_COLLADA_H #define CONFIG_COLLADA_H diff --git a/panda/src/collada/load_collada_file.cxx b/panda/src/collada/load_collada_file.cxx index 969be7040c..bda9641c6f 100644 --- a/panda/src/collada/load_collada_file.cxx +++ b/panda/src/collada/load_collada_file.cxx @@ -1,16 +1,15 @@ -// Filename: load_collada_file.cxx -// Created by: rdb (16Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_collada_file.cxx + * @author rdb + * @date 2011-03-16 + */ #include "load_collada_file.h" #include "colladaLoader.h" @@ -62,14 +61,11 @@ load_from_loader(ColladaLoader &loader) { return DCAST(ModelRoot, loader._root); } -//////////////////////////////////////////////////////////////////// -// Function: load_collada_file -// Description: A convenience function. Loads up the indicated -// dae file, and returns the root of a scene graph. -// Returns NULL if the file cannot be read for some -// reason. Does not search along the model path for -// the filename first. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function. Loads up the indicated dae file, and returns the + * root of a scene graph. Returns NULL if the file cannot be read for some + * reason. Does not search along the model path for the filename first. + */ PT(PandaNode) load_collada_file(const Filename &filename, CoordinateSystem cs, BamCacheRecord *record) { diff --git a/panda/src/collada/load_collada_file.h b/panda/src/collada/load_collada_file.h index 3f1dbae823..9dea0e72f9 100644 --- a/panda/src/collada/load_collada_file.h +++ b/panda/src/collada/load_collada_file.h @@ -1,16 +1,15 @@ -// Filename: load_collada_file.h -// Created by: rdb (16Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_collada_file.h + * @author rdb + * @date 2011-03-16 + */ #ifndef LOAD_COLLADA_FILE_H #define LOAD_COLLADA_FILE_H @@ -24,13 +23,11 @@ class BamCacheRecord; BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: load_collada_file -// Description: A convenience function; the primary interface to this -// package. Loads up the indicated DAE file, and -// returns the root of a scene graph. Returns NULL if -// the file cannot be read for some reason. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function; the primary interface to this package. Loads up + * the indicated DAE file, and returns the root of a scene graph. Returns + * NULL if the file cannot be read for some reason. + */ EXPCL_COLLADA PT(PandaNode) load_collada_file(const Filename &filename, CoordinateSystem cs = CS_default, BamCacheRecord *record = NULL); diff --git a/panda/src/collada/loaderFileTypeDae.cxx b/panda/src/collada/loaderFileTypeDae.cxx index 89cf3e4c6b..d6474fb3ed 100644 --- a/panda/src/collada/loaderFileTypeDae.cxx +++ b/panda/src/collada/loaderFileTypeDae.cxx @@ -1,36 +1,31 @@ -// Filename: loaderFileTypeDae.cxx -// Created by: rdb (23Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeDae.cxx + * @author rdb + * @date 2009-08-23 + */ #include "loaderFileTypeDae.h" #include "load_collada_file.h" TypeHandle LoaderFileTypeDae::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeDae::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeDae:: LoaderFileTypeDae() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeDae::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeDae:: get_name() const { #if PANDA_COLLADA_VERSION == 14 @@ -42,49 +37,38 @@ get_name() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeDae::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeDae:: get_extension() const { return "dae"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::get_additional_extensions -// Access: Published, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this loader. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this loader. + */ string LoaderFileTypeDae:: get_additional_extensions() const { return "zae"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeDae::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeDae:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeDae::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeDae:: load_file(const Filename &path, const LoaderOptions &, BamCacheRecord *record) const { PT(PandaNode) result = load_collada_file(path, CS_default, record); return result; } - diff --git a/panda/src/collada/loaderFileTypeDae.h b/panda/src/collada/loaderFileTypeDae.h index e64a88a25d..4cb79a81f9 100644 --- a/panda/src/collada/loaderFileTypeDae.h +++ b/panda/src/collada/loaderFileTypeDae.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeDae.h -// Created by: rdb (23Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeDae.h + * @author rdb + * @date 2009-08-23 + */ #ifndef LOADERFILETYPEDAE_H #define LOADERFILETYPEDAE_H @@ -19,10 +18,9 @@ #include "loaderFileType.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeDae -// Description : This defines the Loader interface to read Dae files. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to read Dae files. + */ class EXPCL_COLLADA LoaderFileTypeDae : public LoaderFileType { public: LoaderFileTypeDae(); @@ -54,4 +52,3 @@ private: }; #endif - diff --git a/panda/src/collada/pre_collada_include.h b/panda/src/collada/pre_collada_include.h index 6d07cecff0..53b576a773 100644 --- a/panda/src/collada/pre_collada_include.h +++ b/panda/src/collada/pre_collada_include.h @@ -1,21 +1,20 @@ -// Filename: pre_collada_include.h -// Created by: rdb (23May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pre_collada_include.h + * @author rdb + * @date 2011-05-23 + */ -// This header file should be included before including any of the -// COLLADA DOM headers. It should only be included in a .cxx file -// (not in a header file) and no Panda3D headers should be included -// after the pre_collada_include.h include. +// This header file should be included before including any of the COLLADA DOM +// headers. It should only be included in a .cxx file (not in a header file) +// and no Panda3D headers should be included after the pre_collada_include.h +// include. #ifdef PRE_COLLADA_INCLUDE_H #error Don't include any Panda headers after including pre_collada_include.h! diff --git a/panda/src/collide/collisionBox.I b/panda/src/collide/collisionBox.I index 20776bf880..d35bfc906d 100644 --- a/panda/src/collide/collisionBox.I +++ b/panda/src/collide/collisionBox.I @@ -1,30 +1,26 @@ -// Filename: collisionBox.I -// Created by: amith tudur (31Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionBox.I + * @author amith tudur + * @date 2009-07-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::Constructor -// Access: Public -// Description: Create the Box by giving a Center and distances of -// of each of the sides of box from the Center. -//////////////////////////////////////////////////////////////////// +/** + * Create the Box by giving a Center and distances of of each of the sides of + * box from the Center. + */ INLINE CollisionBox:: CollisionBox(const LPoint3 ¢er, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) : _center(center), _x(x), _y(y), _z(z) { _min = LPoint3(_center.get_x() - _x, _center.get_y() - _y, _center.get_z() - _z); - _max = LPoint3(_center.get_x() + _x, _center.get_y() + _y, _center.get_z() + _z); + _max = LPoint3(_center.get_x() + _x, _center.get_y() + _y, _center.get_z() + _z); _radius = sqrt(_x*_x + _y*_y + _z*_z); for(int v = 0; v < 8; v++) _vertex[v] = get_point_aabb(v); @@ -33,11 +29,9 @@ CollisionBox(const LPoint3 ¢er, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) setup_box(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::Constructor -// Access: Public -// Description: Create the Box by Specifying the Diagonal Points -//////////////////////////////////////////////////////////////////// +/** + * Create the Box by Specifying the Diagonal Points + */ INLINE CollisionBox:: CollisionBox(const LPoint3 &min, const LPoint3 &max) : _min(min), _max(max) @@ -54,21 +48,16 @@ CollisionBox(const LPoint3 &min, const LPoint3 &max) : setup_box(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::Default constructor -// Access: Protected -// Description: Creates an invalid Box. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid Box. Only used when reading from a bam file. + */ INLINE CollisionBox:: CollisionBox() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionBox:: CollisionBox(const CollisionBox ©) : CollisionSolid(copy), @@ -87,22 +76,18 @@ CollisionBox(const CollisionBox ©) : setup_box(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionBox:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::set_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionBox:: set_center(const LPoint3 ¢er) { _center = center; @@ -110,71 +95,57 @@ set_center(const LPoint3 ¢er) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::set_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionBox:: set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_center(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionBox:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_min -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionBox:: get_min() const { return _min; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_max -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionBox:: get_max() const { return _max; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_dimensions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 CollisionBox:: get_dimensions() const { return _max - _min; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_num_points -// Access: Published -// Description: Returns 8: the number of vertices of a rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns 8: the number of vertices of a rectangular solid. + */ INLINE int CollisionBox:: get_num_points() const { return 8; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_point -// Access: Published -// Description: Returns the nth vertex of the OBB. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the OBB. + */ INLINE LPoint3 CollisionBox:: get_point(int n) const { nassertr(n >= 0 && n < 8, LPoint3::zero()); @@ -182,47 +153,39 @@ get_point(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_point_aabb -// Access: Published -// Description: Returns the nth vertex of the Axis Aligned Bounding Box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the Axis Aligned Bounding Box. + */ INLINE LPoint3 CollisionBox:: get_point_aabb(int n) const { nassertr(n >= 0 && n < 8, LPoint3::zero()); - - // We do some trickery assuming that _min and _max are consecutive - // in memory. + + // We do some trickery assuming that _min and _max are consecutive in + // memory. const LPoint3 *a = &_min; return LPoint3(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_num_planes -// Access: Published -// Description: Returns 6: the number of faces of a rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns 6: the number of faces of a rectangular solid. + */ INLINE int CollisionBox:: get_num_planes() const { return 6; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_plane -// Access: Published -// Description: Returns the nth face of the rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth face of the rectangular solid. + */ INLINE LPlane CollisionBox:: get_plane(int n) const { nassertr(n >= 0 && n < 6, LPlane()); return _planes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::set_plane -// Access: Published -// Description: Creates the nth face of the rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Creates the nth face of the rectangular solid. + */ INLINE LPlane CollisionBox:: set_plane(int n) const { nassertr(n >= 0 && n < 6, LPlane()); @@ -232,24 +195,19 @@ set_plane(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::is_right -// Access: Private, Static -// Description: Returns true if the 2-d v1 is to the right of v2. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the 2-d v1 is to the right of v2. + */ INLINE bool CollisionBox:: is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 1.0e-6f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::dist_to_line -// Access: Private, Static -// Description: Returns the linear distance of p to the line defined -// by f and f+v, where v is a normalized vector. The -// result is negative if p is left of the line, positive -// if it is right of the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance of p to the line defined by f and f+v, where v + * is a normalized vector. The result is negative if p is left of the line, + * positive if it is right of the line. + */ INLINE PN_stdfloat CollisionBox:: dist_to_line(const LPoint2 &p, const LPoint2 &f, const LVector2 &v) { @@ -257,114 +215,90 @@ dist_to_line(const LPoint2 &p, return (v1[0] * v[1] - v1[1] * v[0]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::to_2d -// Access: Private -// Description: Assuming the indicated point in 3-d space lies within -// the polygon's plane, returns the corresponding point -// in the polygon's 2-d definition space. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the indicated point in 3-d space lies within the polygon's plane, + * returns the corresponding point in the polygon's 2-d definition space. + */ INLINE LPoint2 CollisionBox:: to_2d(const LVecBase3 &point3d, int plane) const { LPoint3 point = LPoint3(point3d) * _to_2d_mat[plane]; return LPoint2(point[0], point[2]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::calc_to_3d_mat -// Access: Private -// Description: Fills the indicated matrix with the appropriate -// rotation transform to move points from the 2-d plane -// into the 3-d (X, 0, Z) plane. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated matrix with the appropriate rotation transform to move + * points from the 2-d plane into the 3-d (X, 0, Z) plane. + */ INLINE void CollisionBox:: calc_to_3d_mat(LMatrix4 &to_3d_mat,int plane) const { - // We have to be explicit about the coordinate system--we - // specifically mean CS_zup_right, because that points the forward - // vector down the Y axis and moves the coords in (X, 0, Z). We - // want this effect regardless of the user's coordinate system of - // choice. + // We have to be explicit about the coordinate system--we specifically mean + // CS_zup_right, because that points the forward vector down the Y axis and + // moves the coords in (X, 0, Z). We want this effect regardless of the + // user's coordinate system of choice. // The up vector, on the other hand, is completely arbitrary. - look_at(to_3d_mat, -get_plane(plane).get_normal(), + look_at(to_3d_mat, -get_plane(plane).get_normal(), LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); to_3d_mat.set_row(3, get_plane(plane).get_point()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::rederive_to_3d_mat -// Access: Private -// Description: Fills the indicated matrix with the appropriate -// rotation transform to move points from the 2-d plane -// into the 3-d (X, 0, Z) plane. -// -// This is essentially similar to calc_to_3d_mat, except -// that the matrix is rederived from whatever is stored -// in _to_2d_mat, guaranteeing that it will match -// whatever algorithm produced that one, even if it was -// produced on a different machine with different -// numerical precision. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated matrix with the appropriate rotation transform to move + * points from the 2-d plane into the 3-d (X, 0, Z) plane. + * + * This is essentially similar to calc_to_3d_mat, except that the matrix is + * rederived from whatever is stored in _to_2d_mat, guaranteeing that it will + * match whatever algorithm produced that one, even if it was produced on a + * different machine with different numerical precision. + */ INLINE void CollisionBox:: rederive_to_3d_mat(LMatrix4 &to_3d_mat, int plane) const { to_3d_mat.invert_from(_to_2d_mat[plane]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::to_3d -// Access: Private, Static -// Description: Extrude the indicated point in the polygon's 2-d -// definition space back into 3-d coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Extrude the indicated point in the polygon's 2-d definition space back into + * 3-d coordinates. + */ INLINE LPoint3 CollisionBox:: to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat) { return LPoint3(point2d[0], 0.0f, point2d[1]) * to_3d_mat; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::PointDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionBox::PointDef:: PointDef(const LPoint2 &p, const LVector2 &v) : _p(p), _v(v) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::PointDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionBox::PointDef:: PointDef(PN_stdfloat x, PN_stdfloat y) : _p(x, y), _v(0.0f, 0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::PointDef::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionBox::PointDef:: PointDef(const CollisionBox::PointDef ©) : _p(copy._p), _v(copy._v) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::PointDef::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionBox::PointDef:: operator = (const CollisionBox::PointDef ©) { _p = copy._p; _v = copy._v; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_plane_points -// Access: Public -// Description: returns the points that form the nth plane -//////////////////////////////////////////////////////////////////// +/** + * returns the points that form the nth plane + */ INLINE CollisionBox::Points CollisionBox:: get_plane_points(int n) { return _points[n]; diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index c508061f30..b358d8b359 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -1,16 +1,15 @@ -// Filename: collisionBox.cxx -// Created by: amith tudur (31Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionBox.cxx + * @author amith tudur + * @date 2009-07-31 + */ #include "collisionBox.h" #include "collisionLine.h" @@ -49,21 +48,17 @@ const int CollisionBox::plane_def[6][4] = { {2, 6, 4, 0}, }; -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionBox:: make_copy() { return new CollisionBox(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::setup_box -// Access: Public, Virtual -// Description: Compute parameters for each of the box's sides -//////////////////////////////////////////////////////////////////// +/** + * Compute parameters for each of the box's sides + */ void CollisionBox:: setup_box(){ for(int plane = 0; plane < 6; plane++) { @@ -76,12 +71,9 @@ setup_box(){ } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::setup_points -// Access: Private -// Description: Computes the plane and 2d projection of points that -// make up this side. -//////////////////////////////////////////////////////////////////// +/** + * Computes the plane and 2d projection of points that make up this side. + */ void CollisionBox:: setup_points(const LPoint3 *begin, const LPoint3 *end, int plane) { int num_points = end - begin; @@ -89,13 +81,12 @@ setup_points(const LPoint3 *begin, const LPoint3 *end, int plane) { _points[plane].clear(); - // Construct a matrix that rotates the points from the (X,0,Z) plane - // into the 3-d plane. + // Construct a matrix that rotates the points from the (X,0,Z) plane into + // the 3-d plane. LMatrix4 to_3d_mat; calc_to_3d_mat(to_3d_mat, plane); - // And the inverse matrix rotates points from 3-d space into the 2-d - // plane. + // And the inverse matrix rotates points from 3-d space into the 2-d plane. _to_2d_mat[plane].invert_from(to_3d_mat); // Now project all of the points onto the 2-d plane. @@ -127,21 +118,17 @@ setup_points(const LPoint3 *begin, const LPoint3 *end, int plane) { compute_vectors(_points[plane]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::test_intersection -// Access: Public, Virtual -// Description: First Dispatch point for box as a FROM object -//////////////////////////////////////////////////////////////////// +/** + * First Dispatch point for box as a FROM object + */ PT(CollisionEntry) CollisionBox:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_box(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionBox:: xform(const LMatrix4 &mat) { _min = _min * mat; @@ -162,68 +149,52 @@ xform(const LMatrix4 &mat) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionBox:: get_collision_origin() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionBox:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionBox:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionBox:: output(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::compute_internal_bounds -// Access: Protected, Virtual -// Description: Sphere is chosen as the Bounding Volume type for -// speed and efficiency -//////////////////////////////////////////////////////////////////// +/** + * Sphere is chosen as the Bounding Volume type for speed and efficiency + */ PT(BoundingVolume) CollisionBox:: compute_internal_bounds() const { return new BoundingSphere(_center, _radius); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::test_intersection_from_sphere -// Access: Public, Virtual -// Description: Double dispatch point for sphere as FROM object -//////////////////////////////////////////////////////////////////// +/** + * Double dispatch point for sphere as FROM object + */ PT(CollisionEntry) CollisionBox:: test_intersection_from_sphere(const CollisionEntry &entry) const { @@ -253,16 +224,16 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { bool intersect; LPlane plane; LVector3 normal; - + for(ip = 0, intersect = false; ip < 6 && !intersect; ip++) { plane = get_plane( ip ); if (_points[ip].size() < 3) { continue; } if (wrt_prev_space != wrt_space) { - // If we have a delta between the previous position and the - // current position, we use that to determine some more properties - // of the collision. + // If we have a delta between the previous position and the current + // position, we use that to determine some more properties of the + // collision. LPoint3 b = from_center; LPoint3 a = sphere->get_center() * wrt_prev_space->get_mat(); LVector3 delta = b - a; @@ -275,23 +246,23 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } if (IS_NEARLY_ZERO(dot)) { - // If we're moving parallel to the plane, the sphere is tested - // at its final point. Leave it as it is. + // If we're moving parallel to the plane, the sphere is tested at its + // final point. Leave it as it is. } else { - // Otherwise, we're moving into the plane; the sphere is tested - // at the point along its path that is closest to intersecting - // the plane. This may be the actual intersection point, or it - // may be the starting point or the final point. - // dot is equal to the (negative) magnitude of 'delta' along the - // direction of the plane normal - // t = ratio of (distance from start pos to plane) to (distance - // from start pos to end pos), along axis of plane normal +/* + * Otherwise, we're moving into the plane; the sphere is tested at the point + * along its path that is closest to intersecting the plane. This may be the + * actual intersection point, or it may be the starting point or the final + * point. dot is equal to the (negative) magnitude of 'delta' along the + * direction of the plane normal t = ratio of (distance from start pos to + * plane) to (distance from start pos to end pos), along axis of plane normal + */ PN_stdfloat dist_to_p = plane.dist_to_plane(a); t = (dist_to_p / -dot); - - // also compute the actual contact point and time of contact - // for handlers that need it + + // also compute the actual contact point and time of contact for + // handlers that need it actual_t = ((dist_to_p - from_radius) / -dot); actual_t = min((PN_stdfloat)1.0, max((PN_stdfloat)0.0, actual_t)); contact_point = a + (actual_t * delta); @@ -310,7 +281,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : plane.get_normal(); - + #ifndef NDEBUG /*if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001), NULL) { std::cout @@ -321,12 +292,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { }*/ #endif - // The nearest point within the plane to our center is the - // intersection of the line (center, center - normal) with the plane. - + // The nearest point within the plane to our center is the intersection of + // the line (center, center - normal) with the plane. + if (!plane.intersects_line(dist, from_center, -(plane.get_normal()))) { - // No intersection with plane? This means the plane's effective - // normal was within the plane itself. A useless polygon. + // No intersection with plane? This means the plane's effective normal + // was within the plane itself. A useless polygon. continue; } @@ -343,8 +314,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform(),ip)) { - // All points are behind the clip plane; just do the default - // test. + // All points are behind the clip plane; just do the default test. edge_dist = dist_to_polygon(p, _points[ip]); } else if (new_points.empty()) { // The polygon is completely clipped. @@ -354,31 +324,30 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { edge_dist = dist_to_polygon(p, new_points); } } else { - // No clip plane is in effect. Do the default test. + // No clip plane is in effect. Do the default test. edge_dist = dist_to_polygon(p, _points[ip]); } max_dist = from_radius; - // Now we have edge_dist, which is the distance from the sphere - // center to the nearest edge of the polygon, within the polygon's - // plane. edge_dist<0 means the point is within the polygon. + // Now we have edge_dist, which is the distance from the sphere center to + // the nearest edge of the polygon, within the polygon's plane. + // edge_dist<0 means the point is within the polygon. if(edge_dist < 0) { intersect = true; continue; } - if((edge_dist > 0) && + if((edge_dist > 0) && ((edge_dist * edge_dist + dist * dist) > from_radius_2)) { // No intersection; the circle is outside the polygon. continue; } - // The sphere appears to intersect the polygon. If the edge is less - // than from_radius away, the sphere may be resting on an edge of - // the polygon. Determine how far the center of the sphere must - // remain from the plane, based on its distance from the nearest - // edge. + // The sphere appears to intersect the polygon. If the edge is less than + // from_radius away, the sphere may be resting on an edge of the polygon. + // Determine how far the center of the sphere must remain from the plane, + // based on its distance from the nearest edge. if (edge_dist >= 0.0f) { PN_stdfloat max_dist_2 = max(from_radius_2 - edge_dist * edge_dist, (PN_stdfloat)0.0); @@ -399,14 +368,13 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { << "intersection detected from " << entry.get_from_node_path() << " into " << entry.get_into_node_path() << "\n"; } - + PT(CollisionEntry) new_entry = new CollisionEntry(entry); PN_stdfloat into_depth = max_dist - dist; if (moved_from_center) { - // We have to base the depth of intersection on the sphere's final - // resting point, not the point from which we tested the - // intersection. + // We have to base the depth of intersection on the sphere's final resting + // point, not the point from which we tested the intersection. PN_stdfloat orig_dist; plane.intersects_line(orig_dist, orig_center, -normal); into_depth = max_dist - orig_dist; @@ -428,11 +396,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::test_intersection_from_ray -// Access: Public, Virtual -// Description: Double dispatch point for ray as a FROM object -//////////////////////////////////////////////////////////////////// +/** + * Double dispatch point for ray as a FROM object + */ PT(CollisionEntry) CollisionBox:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -447,10 +413,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PN_stdfloat near_t = 0.0; bool intersect; LPlane plane; - LPlane near_plane; + LPlane near_plane; - //Returns the details about the first plane of the box that the ray - //intersects. + // Returns the details about the first plane of the box that the ray + // intersects. for (i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { plane = get_plane(i); @@ -460,8 +426,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } if (t < 0.0f) { - // The intersection point is before the start of the ray, and so - // the ray is entirely in front of the plane. + // The intersection point is before the start of the ray, and so the ray + // is entirely in front of the plane. continue; } LPoint3 plane_point = from_origin + t * from_direction; @@ -483,10 +449,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } ++j; } - + if(!intersect) { - //No intersection with ANY of the box's planes has been detected + // No intersection with ANY of the box's planes has been detected return NULL; } @@ -501,7 +467,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 into_intersection_point = from_origin + near_t * from_direction; LVector3 normal = - (has_effective_normal() && ray->get_respect_effective_normal()) + (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : near_plane.get_normal(); new_entry->set_surface_normal(normal); @@ -511,11 +477,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::test_intersection_from_segment -// Access: Public, Virtual -// Description: Double dispatch point for segment as a FROM object -//////////////////////////////////////////////////////////////////// +/** + * Double dispatch point for segment as a FROM object + */ PT(CollisionEntry) CollisionBox:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *seg; @@ -533,8 +497,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPlane plane; LPlane near_plane; - //Returns the details about the first plane of the box that the - //segment intersects. + // Returns the details about the first plane of the box that the segment + // intersects. for(i = 0, intersect = false, t = 0, j = 0; i < 6 && j < 2; i++) { plane = get_plane(i); @@ -544,9 +508,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } if (t < 0.0f || t > 1.0f) { - // The intersection point is before the start of the segment, - // or after the end of the segment, so the segment is either - // entirely in front of or behind the plane. + // The intersection point is before the start of the segment, or after + // the end of the segment, so the segment is either entirely in front of + // or behind the plane. continue; } LPoint3 plane_point = from_origin + t * from_direction; @@ -570,7 +534,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } if(!intersect) { - //No intersection with ANY of the box's planes has been detected + // No intersection with ANY of the box's planes has been detected return NULL; } @@ -585,7 +549,7 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPoint3 into_intersection_point = from_origin + near_t * from_direction; LVector3 normal = - (has_effective_normal() && seg->get_respect_effective_normal()) + (has_effective_normal() && seg->get_respect_effective_normal()) ? get_effective_normal() : near_plane.get_normal(); new_entry->set_surface_normal(normal); @@ -594,11 +558,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::test_intersection_from_box -// Access: Public, Virtual -// Description: Double dispatch point for box as a FROM object -//////////////////////////////////////////////////////////////////// +/** + * Double dispatch point for box as a FROM object + */ PT(CollisionEntry) CollisionBox:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; @@ -615,9 +577,9 @@ test_intersection_from_box(const CollisionEntry &entry) const { LVecBase3 box_z = wrt_mat.get_row3(2); // To make the math simpler, normalize the box basis vectors, instead - // applying the scale to the box dimensions. Note that this doesn't - // work for a non-uniform scales applied after a rotation, since that - // has the possibility of making the box no longer a box. + // applying the scale to the box dimensions. Note that this doesn't work + // for a non-uniform scales applied after a rotation, since that has the + // possibility of making the box no longer a box. PN_stdfloat l; l = box_x.length(); from_extents[0] *= l; @@ -770,8 +732,8 @@ test_intersection_from_box(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - // This isn't always the correct surface point. However, it seems to - // be enough to let the pusher do the right thing. + // This isn't always the correct surface point. However, it seems to be + // enough to let the pusher do the right thing. LPoint3 surface( min(max(diff[0], -into_extents[0]), into_extents[0]), min(max(diff[1], -into_extents[1]), into_extents[1]), @@ -798,12 +760,10 @@ test_intersection_from_box(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionBox:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -860,17 +820,13 @@ fill_viz_geom() { _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::apply_clip_plane -// Access: Private -// Description: Clips the polygon by all of the clip planes named in -// the clip plane attribute and fills new_points up with -// the resulting points. -// -// The return value is true if the set of points is -// unmodified (all points are behind all the clip -// planes), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Clips the polygon by all of the clip planes named in the clip plane + * attribute and fills new_points up with the resulting points. + * + * The return value is true if the set of points is unmodified (all points are + * behind all the clip planes), or false otherwise. + */ bool CollisionBox:: apply_clip_plane(CollisionBox::Points &new_points, const ClipPlaneAttrib *cpa, @@ -909,20 +865,16 @@ apply_clip_plane(CollisionBox::Points &new_points, return all_in; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::clip_polygon -// Access: Private -// Description: Clips the source_points of the polygon by the -// indicated clipping plane, and modifies new_points to -// reflect the new set of clipped points (but does not -// compute the vectors in new_points). -// -// The return value is true if the set of points is -// unmodified (all points are behind the clip plane), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Clips the source_points of the polygon by the indicated clipping plane, and + * modifies new_points to reflect the new set of clipped points (but does not + * compute the vectors in new_points). + * + * The return value is true if the set of points is unmodified (all points are + * behind the clip plane), or false otherwise. + */ bool CollisionBox:: -clip_polygon(CollisionBox::Points &new_points, +clip_polygon(CollisionBox::Points &new_points, const CollisionBox::Points &source_points, const LPlane &plane, int plane_no) const { new_points.clear(); @@ -933,19 +885,19 @@ clip_polygon(CollisionBox::Points &new_points, LPoint3 from3d; LVector3 delta3d; if (!plane.intersects_plane(from3d, delta3d, get_plane(plane_no))) { - // The clipping plane is parallel to the polygon. The polygon is - // either all in or all out. + // The clipping plane is parallel to the polygon. The polygon is either + // all in or all out. if (plane.dist_to_plane(get_plane(plane_no).get_point()) < 0.0) { - // A point within the polygon is behind the clipping plane: the - // polygon is all in. + // A point within the polygon is behind the clipping plane: the polygon + // is all in. new_points = source_points; return true; } return false; } - // Project the line of intersection into the 2-d plane. Now we have - // a 2-d clipping line. + // Project the line of intersection into the 2-d plane. Now we have a 2-d + // clipping line. LPoint2 from2d = to_2d(from3d,plane_no); LVector2 delta2d = to_2d(delta3d,plane_no); @@ -953,13 +905,12 @@ clip_polygon(CollisionBox::Points &new_points, PN_stdfloat b = delta2d[0]; PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; - // Now walk through the points. Any point on the left of our line - // gets removed, and the line segment clipped at the point of - // intersection. + // Now walk through the points. Any point on the left of our line gets + // removed, and the line segment clipped at the point of intersection. - // We might increase the number of vertices by as many as 1, if the - // plane clips off exactly one corner. (We might also decrease the - // number of vertices, or keep them the same number.) + // We might increase the number of vertices by as many as 1, if the plane + // clips off exactly one corner. (We might also decrease the number of + // vertices, or keep them the same number.) new_points.reserve(source_points.size() + 1); LPoint2 last_point = source_points.back()._p; @@ -970,12 +921,12 @@ clip_polygon(CollisionBox::Points &new_points, const LPoint2 &this_point = (*pi)._p; bool this_is_in = !is_right(this_point - from2d, delta2d); - // There appears to be a compiler bug in gcc 4.0: we need to - // extract this comparison outside of the if statement. + // There appears to be a compiler bug in gcc 4.0: we need to extract this + // comparison outside of the if statement. bool crossed_over = (this_is_in != last_is_in); if (crossed_over) { - // We have just crossed over the clipping line. Find the point - // of intersection. + // We have just crossed over the clipping line. Find the point of + // intersection. LVector2 d = this_point - last_point; PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { @@ -985,7 +936,7 @@ clip_polygon(CollisionBox::Points &new_points, new_points.push_back(PointDef(p[0], p[1])); last_is_in = this_is_in; } - } + } if (this_is_in) { // We are behind the clipping line. Keep the point. @@ -1001,25 +952,22 @@ clip_polygon(CollisionBox::Points &new_points, } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox:: -// Access: Private -// Description: Returns the linear distance from the 2-d point to the -// nearest part of the polygon defined by the points -// vector. The result is negative if the point is -// within the polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance from the 2-d point to the nearest part of the + * polygon defined by the points vector. The result is negative if the point + * is within the polygon. + */ PN_stdfloat CollisionBox:: dist_to_polygon(const LPoint2 &p, const CollisionBox::Points &points) const { - // We know that that the polygon is convex and is defined with the - // points in counterclockwise order. Therefore, we simply compare - // the signed distance to each line segment; we ignore any negative - // values, and take the minimum of all the positive values. + // We know that that the polygon is convex and is defined with the points in + // counterclockwise order. Therefore, we simply compare the signed distance + // to each line segment; we ignore any negative values, and take the minimum + // of all the positive values. + + // If all values are negative, the point is within the polygon; we therefore + // return an arbitrary negative result. - // If all values are negative, the point is within the polygon; we - // therefore return an arbitrary negative result. - bool got_dist = false; PN_stdfloat best_dist = -1.0f; @@ -1047,18 +995,14 @@ dist_to_polygon(const LPoint2 &p, const CollisionBox::Points &points) const { return best_dist; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::dist_to_line_segment -// Access: Private, Static -// Description: Returns the linear distance of p to the line segment -// defined by f and t, where v = (t - f).normalize(). -// The result is negative if p is left of the line, -// positive if it is right of the line. If the result -// is positive, it is constrained by endpoints of the -// line segment (i.e. the result might be larger than it -// would be for a straight distance-to-line test). If -// the result is negative, we don't bother. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance of p to the line segment defined by f and t, + * where v = (t - f).normalize(). The result is negative if p is left of the + * line, positive if it is right of the line. If the result is positive, it + * is constrained by endpoints of the line segment (i.e. the result might be + * larger than it would be for a straight distance-to-line test). If the + * result is negative, we don't bother. + */ PN_stdfloat CollisionBox:: dist_to_line_segment(const LPoint2 &p, const LPoint2 &f, const LPoint2 &t, @@ -1166,12 +1110,10 @@ dist_to_line_segment(const LPoint2 &p, } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::point_is_inside -// Access: Private -// Description: Returns true if the indicated point is within the -// polygon's 2-d space, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated point is within the polygon's 2-d space, + * false otherwise. + */ bool CollisionBox:: point_is_inside(const LPoint2 &p, const CollisionBox::Points &points) const { // We insist that the polygon be convex. This makes things a bit simpler. @@ -1183,7 +1125,7 @@ point_is_inside(const LPoint2 &p, const CollisionBox::Points &points) const { return false; } } - if (is_right(p - points[points.size() - 1]._p, + if (is_right(p - points[points.size() - 1]._p, points[0]._p - points[points.size() - 1]._p)) { return false; } @@ -1191,13 +1133,10 @@ point_is_inside(const LPoint2 &p, const CollisionBox::Points &points) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::compute_vectors -// Access: Private, Static -// Description: Now that the _p members of the given points array -// have been computed, go back and compute all of the _v -// members. -//////////////////////////////////////////////////////////////////// +/** + * Now that the _p members of the given points array have been computed, go + * back and compute all of the _v members. + */ void CollisionBox:: compute_vectors(Points &points) { size_t num_points = points.size(); @@ -1207,22 +1146,18 @@ compute_vectors(Points &points) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionBox object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionBox object + */ void CollisionBox:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CollisionBox); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionBox:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSolid::write_datagram(manager, me); @@ -1241,8 +1176,8 @@ write_datagram(BamWriter *manager, Datagram &me) { } for(int i=0; i < 6; i++) { _to_2d_mat[i].write_datagram(me); - } - for(int i=0; i < 6; i++) { + } + for(int i=0; i < 6; i++) { me.add_uint16(_points[i].size()); for (size_t j = 0; j < _points[i].size(); j++) { _points[i][j]._p.write_datagram(me); @@ -1251,11 +1186,9 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::make_CollisionBox -// Access: Protected -// Description: Factory method to generate a CollisionBox object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionBox object + */ TypedWritable *CollisionBox:: make_CollisionBox(const FactoryParams ¶ms) { CollisionBox *me = new CollisionBox; @@ -1267,14 +1200,11 @@ make_CollisionBox(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionBox::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionBox:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index 6ea9f0468d..8a8cd3d0be 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -1,16 +1,15 @@ -// Filename: collisionBox.h -// Created by: amith tudur (31Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionBox.h + * @author amith tudur + * @date 2009-07-31 + */ #ifndef COLLISIONBOX_H #define COLLISIONBOX_H @@ -22,10 +21,9 @@ #include "look_at.h" #include "clipPlaneAttrib.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionBox -// Description : A cuboid collision volume or object. -//////////////////////////////////////////////////////////////////// +/** + * A cuboid collision volume or object. + */ class EXPCL_PANDA_COLLIDE CollisionBox : public CollisionSolid { PUBLISHED: INLINE CollisionBox(const LPoint3 ¢er, diff --git a/panda/src/collide/collisionEntry.I b/panda/src/collide/collisionEntry.I index e2dc757119..9b535d17ce 100644 --- a/panda/src/collide/collisionEntry.I +++ b/panda/src/collide/collisionEntry.I @@ -1,23 +1,19 @@ -// Filename: collisionEntry.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionEntry.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionEntry:: CollisionEntry() { _flags = 0; @@ -25,173 +21,133 @@ CollisionEntry() { _t = 2.f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_from -// Access: Published -// Description: Returns the CollisionSolid pointer for the particular -// solid that triggered this collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CollisionSolid pointer for the particular solid that triggered + * this collision. + */ INLINE const CollisionSolid *CollisionEntry:: get_from() const { return _from; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_into -// Access: Published -// Description: Returns true if the "into" solid is, in fact, a -// CollisionSolid, and its pointer is known (in which -// case get_into() may be called to retrieve it). If -// this returns false, the collision was detected into a -// GeomNode, and there is no CollisionSolid pointer to -// be retrieved. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "into" solid is, in fact, a CollisionSolid, and its + * pointer is known (in which case get_into() may be called to retrieve it). + * If this returns false, the collision was detected into a GeomNode, and + * there is no CollisionSolid pointer to be retrieved. + */ INLINE bool CollisionEntry:: has_into() const { return (_into != (CollisionSolid *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_into -// Access: Published -// Description: Returns the CollisionSolid pointer for the particular -// solid was collided into. This pointer might be NULL -// if the collision was into a piece of visible -// geometry, instead of a normal CollisionSolid -// collision; see has_into(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CollisionSolid pointer for the particular solid was collided + * into. This pointer might be NULL if the collision was into a piece of + * visible geometry, instead of a normal CollisionSolid collision; see + * has_into(). + */ INLINE const CollisionSolid *CollisionEntry:: get_into() const { return _into; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_from_node -// Access: Published -// Description: Returns the node that contains the CollisionSolid -// that triggered this collision. This will be a node -// that has been added to a CollisionTraverser via -// add_collider(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that contains the CollisionSolid that triggered this + * collision. This will be a node that has been added to a CollisionTraverser + * via add_collider(). + */ INLINE CollisionNode *CollisionEntry:: get_from_node() const { return _from_node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_into_node -// Access: Published -// Description: Returns the node that contains the CollisionSolid -// that was collided into. This returns a PandaNode -// pointer instead of something more specific, because -// it might be either a CollisionNode or a GeomNode. -// -// Also see get_into_node_path(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that contains the CollisionSolid that was collided into. + * This returns a PandaNode pointer instead of something more specific, + * because it might be either a CollisionNode or a GeomNode. + * + * Also see get_into_node_path(). + */ INLINE PandaNode *CollisionEntry:: get_into_node() const { return _into_node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_from_node_path -// Access: Published -// Description: Returns the NodePath that represents the -// CollisionNode that contains the CollisionSolid that -// triggered this collision. This will be a NodePath -// that has been added to a CollisionTraverser via -// add_collider(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath that represents the CollisionNode that contains the + * CollisionSolid that triggered this collision. This will be a NodePath that + * has been added to a CollisionTraverser via add_collider(). + */ INLINE NodePath CollisionEntry:: get_from_node_path() const { return _from_node_path; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_into_node_path -// Access: Published -// Description: Returns the NodePath that represents the specific -// CollisionNode or GeomNode instance that was collided -// into. This is the same node returned by -// get_into_node(), represented as a NodePath; however, -// it may be more useful because the NodePath can -// resolve the particular instance of the node, if there -// is more than one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath that represents the specific CollisionNode or GeomNode + * instance that was collided into. This is the same node returned by + * get_into_node(), represented as a NodePath; however, it may be more useful + * because the NodePath can resolve the particular instance of the node, if + * there is more than one. + */ INLINE NodePath CollisionEntry:: get_into_node_path() const { return _into_node_path; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_t -// Access: Published -// Description: Sets a time value for this collision relative to -// other CollisionEntries -//////////////////////////////////////////////////////////////////// +/** + * Sets a time value for this collision relative to other CollisionEntries + */ INLINE void CollisionEntry:: set_t(PN_stdfloat t) { nassertv(!cnan(t)); _t = t; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_t -// Access: Published -// Description: returns time value for this collision relative to -// other CollisionEntries -//////////////////////////////////////////////////////////////////// +/** + * returns time value for this collision relative to other CollisionEntries + */ INLINE PN_stdfloat CollisionEntry:: get_t() const { return _t; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::collided -// Access: Published -// Description: returns true if this represents an actual collision -// as opposed to a potential collision, needed for -// iterative collision resolution where path of -// collider changes mid-frame -//////////////////////////////////////////////////////////////////// +/** + * returns true if this represents an actual collision as opposed to a + * potential collision, needed for iterative collision resolution where path + * of collider changes mid-frame + */ INLINE bool CollisionEntry:: collided() const { return ((0.f <= _t) && (_t <= 1.f)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::reset_collided -// Access: Published -// Description: prepare for another collision test -//////////////////////////////////////////////////////////////////// +/** + * prepare for another collision test + */ INLINE void CollisionEntry:: reset_collided() { _t = 2.f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_respect_prev_transform -// Access: Published -// Description: Returns true if the collision was detected by a -// CollisionTraverser whose respect_prev_transform -// flag was set true, meaning we should consider motion -// significant in evaluating collisions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the collision was detected by a CollisionTraverser whose + * respect_prev_transform flag was set true, meaning we should consider motion + * significant in evaluating collisions. + */ INLINE bool CollisionEntry:: get_respect_prev_transform() const { return (_flags & F_respect_prev_transform) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_surface_point -// Access: Published -// Description: Stores the point, on the surface of the "into" -// object, at which a collision is detected. -// -// This point is specified in the coordinate space of -// the "into" object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the point, on the surface of the "into" object, at which a collision + * is detected. + * + * This point is specified in the coordinate space of the "into" object. + */ INLINE void CollisionEntry:: set_surface_point(const LPoint3 &point) { nassertv(!point.is_nan()); @@ -199,15 +155,12 @@ set_surface_point(const LPoint3 &point) { _flags |= F_has_surface_point; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_surface_normal -// Access: Published -// Description: Stores the surface normal of the "into" object at the -// point of the intersection. -// -// This normal is specified in the coordinate space of -// the "into" object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the surface normal of the "into" object at the point of the + * intersection. + * + * This normal is specified in the coordinate space of the "into" object. + */ INLINE void CollisionEntry:: set_surface_normal(const LVector3 &normal) { nassertv(!normal.is_nan()); @@ -215,19 +168,14 @@ set_surface_normal(const LVector3 &normal) { _flags |= F_has_surface_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_interior_point -// Access: Published -// Description: Stores the point, within the interior of the "into" -// object, which represents the depth to which the -// "from" object has penetrated. This can also be -// described as the intersection point on the surface of -// the "from" object (which is inside the "into" -// object). -// -// This point is specified in the coordinate space of -// the "into" object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the point, within the interior of the "into" object, which + * represents the depth to which the "from" object has penetrated. This can + * also be described as the intersection point on the surface of the "from" + * object (which is inside the "into" object). + * + * This point is specified in the coordinate space of the "into" object. + */ INLINE void CollisionEntry:: set_interior_point(const LPoint3 &point) { nassertv(!point.is_nan()); @@ -235,54 +183,42 @@ set_interior_point(const LPoint3 &point) { _flags |= F_has_interior_point; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_surface_point -// Access: Published -// Description: Returns true if the surface point has been specified, -// false otherwise. See get_surface_point(). Some -// types of collisions may not compute the surface -// point. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the surface point has been specified, false otherwise. See + * get_surface_point(). Some types of collisions may not compute the surface + * point. + */ INLINE bool CollisionEntry:: has_surface_point() const { return (_flags & F_has_surface_point) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_surface_normal -// Access: Published -// Description: Returns true if the surface normal has been specified, -// false otherwise. See get_surface_normal(). Some -// types of collisions may not compute the surface -// normal. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the surface normal has been specified, false otherwise. + * See get_surface_normal(). Some types of collisions may not compute the + * surface normal. + */ INLINE bool CollisionEntry:: has_surface_normal() const { return (_flags & F_has_surface_normal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_interior_point -// Access: Published -// Description: Returns true if the interior point has been specified, -// false otherwise. See get_interior_point(). Some -// types of collisions may not compute the interior -// point. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the interior point has been specified, false otherwise. + * See get_interior_point(). Some types of collisions may not compute the + * interior point. + */ INLINE bool CollisionEntry:: has_interior_point() const { return (_flags & F_has_interior_point) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_contact_pos -// Access: Published -// Description: Stores the position of the "from" object at the -// instant at which the collision is first detected. -// -// This position is specified in the coordinate space of -// the "into" object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the position of the "from" object at the instant at which the + * collision is first detected. + * + * This position is specified in the coordinate space of the "into" object. + */ INLINE void CollisionEntry:: set_contact_pos(const LPoint3 &pos) { nassertv(!pos.is_nan()); @@ -290,15 +226,11 @@ set_contact_pos(const LPoint3 &pos) { _flags |= F_has_contact_pos; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::set_contact_normal -// Access: Published -// Description: Stores the surface normal of the "into" object at the -// contact pos. -// -// This normal is specified in the coordinate space of -// the "into" object. -//////////////////////////////////////////////////////////////////// +/** + * Stores the surface normal of the "into" object at the contact pos. + * + * This normal is specified in the coordinate space of the "into" object. + */ INLINE void CollisionEntry:: set_contact_normal(const LVector3 &normal) { nassertv(!normal.is_nan()); @@ -306,62 +238,47 @@ set_contact_normal(const LVector3 &normal) { _flags |= F_has_contact_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_contact_pos -// Access: Published -// Description: Returns true if the contact position has been specified, -// false otherwise. See get_contact_pos(). Some -// types of collisions may not compute the contact -// pos. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the contact position has been specified, false otherwise. + * See get_contact_pos(). Some types of collisions may not compute the + * contact pos. + */ INLINE bool CollisionEntry:: has_contact_pos() const { return (_flags & F_has_contact_pos) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::has_contact_normal -// Access: Published -// Description: Returns true if the contact normal has been specified, -// false otherwise. See get_contact_normal(). Some -// types of collisions may not compute the contact -// normal. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the contact normal has been specified, false otherwise. + * See get_contact_normal(). Some types of collisions may not compute the + * contact normal. + */ INLINE bool CollisionEntry:: has_contact_normal() const { return (_flags & F_has_contact_normal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_wrt_space -// Access: Public -// Description: Returns the relative transform of the from node as -// seen from the into node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the from node as seen from the into node. + */ INLINE CPT(TransformState) CollisionEntry:: get_wrt_space() const { return _from_node_path.get_transform(_into_node_path); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_inv_wrt_space -// Access: Public -// Description: Returns the relative transform of the into node as -// seen from the from node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the into node as seen from the from node. + */ INLINE CPT(TransformState) CollisionEntry:: get_inv_wrt_space() const { return _into_node_path.get_transform(_from_node_path); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_wrt_prev_space -// Access: Public -// Description: Returns the relative transform of the from node as -// seen from the into node, as of the previous frame -// (according to set_prev_transform(), set_fluid_pos(), -// etc.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the from node as seen from the into node, + * as of the previous frame (according to set_prev_transform(), + * set_fluid_pos(), etc.) + */ INLINE CPT(TransformState) CollisionEntry:: get_wrt_prev_space() const { if (get_respect_prev_transform()) { @@ -371,48 +288,36 @@ get_wrt_prev_space() const { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_wrt_mat -// Access: Public -// Description: Returns the relative transform of the from node as -// seen from the into node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the from node as seen from the into node. + */ INLINE const LMatrix4 &CollisionEntry:: get_wrt_mat() const { return get_wrt_space()->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_inv_wrt_mat -// Access: Public -// Description: Returns the relative transform of the into node as -// seen from the from node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the into node as seen from the from node. + */ INLINE const LMatrix4 &CollisionEntry:: get_inv_wrt_mat() const { return get_inv_wrt_space()->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_wrt_prev_mat -// Access: Public -// Description: Returns the relative transform of the from node as -// seen from the into node, as of the previous frame -// (according to set_prev_transform(), set_fluid_pos(), -// etc.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform of the from node as seen from the into node, + * as of the previous frame (according to set_prev_transform(), + * set_fluid_pos(), etc.) + */ INLINE const LMatrix4 &CollisionEntry:: get_wrt_prev_mat() const { return get_wrt_prev_space()->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_into_clip_planes -// Access: Public -// Description: Returns the ClipPlaneAttrib, if any, that is applied -// to the into_node_path, or NULL if there is no clip -// plane in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ClipPlaneAttrib, if any, that is applied to the into_node_path, + * or NULL if there is no clip plane in effect. + */ INLINE const ClipPlaneAttrib *CollisionEntry:: get_into_clip_planes() const { if ((_flags & F_checked_clip_planes) == 0) { @@ -421,17 +326,14 @@ get_into_clip_planes() const { return _into_clip_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::test_intersection -// Access: Private -// Description: This is intended to be called only by the -// CollisionTraverser. It requests the CollisionEntry -// to start the intersection test between the from and -// into solids stored within it, passing the result (if -// positive) to the indicated CollisionHandler. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only by the CollisionTraverser. It requests + * the CollisionEntry to start the intersection test between the from and into + * solids stored within it, passing the result (if positive) to the indicated + * CollisionHandler. + */ INLINE void CollisionEntry:: -test_intersection(CollisionHandler *record, +test_intersection(CollisionHandler *record, const CollisionTraverser *trav) const { PT(CollisionEntry) result = get_from()->test_intersection(*this); #ifdef DO_COLLISION_RECORDING @@ -446,8 +348,9 @@ test_intersection(CollisionHandler *record, #ifdef DO_PSTATS ((CollisionSolid *)get_into())->get_test_pcollector().add_level(1); #endif // DO_PSTATS - // if there was no collision detected but the handler wants to know about all - // potential collisions, create a "didn't collide" collision entry for it + // if there was no collision detected but the handler wants to know about + // all potential collisions, create a "didn't collide" collision entry for + // it if (record->wants_all_potential_collidees() && result == (CollisionEntry *)NULL) { result = new CollisionEntry(*this); result->reset_collided(); diff --git a/panda/src/collide/collisionEntry.cxx b/panda/src/collide/collisionEntry.cxx index 229cb3eb8b..81814eea48 100644 --- a/panda/src/collide/collisionEntry.cxx +++ b/panda/src/collide/collisionEntry.cxx @@ -1,16 +1,15 @@ -// Filename: collisionEntry.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionEntry.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionEntry.h" #include "dcast.h" @@ -18,11 +17,9 @@ TypeHandle CollisionEntry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionEntry:: CollisionEntry(const CollisionEntry ©) : _from(copy._from), @@ -42,11 +39,9 @@ CollisionEntry(const CollisionEntry ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionEntry:: operator = (const CollisionEntry ©) { _from = copy._from; @@ -65,18 +60,15 @@ operator = (const CollisionEntry ©) { _contact_normal = copy._contact_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_surface_point -// Access: Published -// Description: Returns the point, on the surface of the "into" -// object, at which a collision is detected. This can -// be thought of as the first point of intersection. -// However the contact point is the actual first point of -// intersection. -// -// The point will be converted into whichever coordinate -// space the caller specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point, on the surface of the "into" object, at which a + * collision is detected. This can be thought of as the first point of + * intersection. However the contact point is the actual first point of + * intersection. + * + * The point will be converted into whichever coordinate space the caller + * specifies. + */ LPoint3 CollisionEntry:: get_surface_point(const NodePath &space) const { nassertr(has_surface_point(), LPoint3::zero()); @@ -84,15 +76,13 @@ get_surface_point(const NodePath &space) const { return _surface_point * transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_surface_normal -// Access: Published -// Description: Returns the surface normal of the "into" object at -// the point at which a collision is detected. -// -// The normal will be converted into whichever coordinate -// space the caller specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the surface normal of the "into" object at the point at which a + * collision is detected. + * + * The normal will be converted into whichever coordinate space the caller + * specifies. + */ LVector3 CollisionEntry:: get_surface_normal(const NodePath &space) const { nassertr(has_surface_normal(), LVector3::zero()); @@ -100,20 +90,16 @@ get_surface_normal(const NodePath &space) const { return _surface_normal * transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_interior_point -// Access: Published -// Description: Returns the point, within the interior of the "into" -// object, which represents the depth to which the -// "from" object has penetrated. This can also be -// described as the intersection point on the surface of -// the "from" object (which is inside the "into" -// object). It can be thought of as the deepest point -// of intersection. -// -// The point will be converted into whichever coordinate -// space the caller specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point, within the interior of the "into" object, which + * represents the depth to which the "from" object has penetrated. This can + * also be described as the intersection point on the surface of the "from" + * object (which is inside the "into" object). It can be thought of as the + * deepest point of intersection. + * + * The point will be converted into whichever coordinate space the caller + * specifies. + */ LPoint3 CollisionEntry:: get_interior_point(const NodePath &space) const { if (!has_interior_point()) { @@ -123,16 +109,13 @@ get_interior_point(const NodePath &space) const { return _interior_point * transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_all -// Access: Published -// Description: Simultaneously transforms the surface point, surface -// normal, and interior point of the collision into the -// indicated coordinate space. -// -// Returns true if all three properties are available, -// or false if any one of them is not. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously transforms the surface point, surface normal, and interior + * point of the collision into the indicated coordinate space. + * + * Returns true if all three properties are available, or false if any one of + * them is not. + */ bool CollisionEntry:: get_all(const NodePath &space, LPoint3 &surface_point, LVector3 &surface_normal, LPoint3 &interior_point) const { @@ -164,15 +147,13 @@ get_all(const NodePath &space, LPoint3 &surface_point, return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_contact_pos -// Access: Published -// Description: Returns the position of the "from" object at the instant -// that a collision is first detected. -// -// The position will be converted into whichever coordinate -// space the caller specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the "from" object at the instant that a collision + * is first detected. + * + * The position will be converted into whichever coordinate space the caller + * specifies. + */ LPoint3 CollisionEntry:: get_contact_pos(const NodePath &space) const { nassertr(has_contact_pos(), LPoint3::zero()); @@ -180,15 +161,12 @@ get_contact_pos(const NodePath &space) const { return _contact_pos * transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_contact_normal -// Access: Published -// Description: Returns the surface normal of the "into" object at -// the contact position. -// -// The normal will be converted into whichever coordinate -// space the caller specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the surface normal of the "into" object at the contact position. + * + * The normal will be converted into whichever coordinate space the caller + * specifies. + */ LVector3 CollisionEntry:: get_contact_normal(const NodePath &space) const { nassertr(has_contact_normal(), LVector3::zero()); @@ -196,16 +174,13 @@ get_contact_normal(const NodePath &space) const { return _contact_normal * transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::get_all_contact_info -// Access: Published -// Description: Simultaneously transforms the contact position and -// contact normal of the collision into the -// indicated coordinate space. -// -// Returns true if all three properties are available, -// or false if any one of them is not. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously transforms the contact position and contact normal of the + * collision into the indicated coordinate space. + * + * Returns true if all three properties are available, or false if any one of + * them is not. + */ bool CollisionEntry:: get_all_contact_info(const NodePath &space, LPoint3 &contact_pos, LVector3 &contact_normal) const { @@ -230,11 +205,9 @@ get_all_contact_info(const NodePath &space, LPoint3 &contact_pos, return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionEntry:: output(ostream &out) const { out << _from_node_path; @@ -246,11 +219,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionEntry:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -283,21 +254,18 @@ write(ostream &out, int indent_level) const { } if (has_interior_point()) { indent(out, indent_level + 2) - << "interior " << get_interior_point(NodePath()) - << " (depth " - << (get_interior_point(NodePath()) - get_surface_point(NodePath())).length() + << "interior " << get_interior_point(NodePath()) + << " (depth " + << (get_interior_point(NodePath()) - get_surface_point(NodePath())).length() << ")\n"; } indent(out, indent_level + 2) << "respect_prev_transform = " << get_respect_prev_transform() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionEntry::check_clip_planes -// Access: Private -// Description: Checks whether the into_node_path has a -// ClipPlaneAttrib defined. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the into_node_path has a ClipPlaneAttrib defined. + */ void CollisionEntry:: check_clip_planes() { _into_clip_planes = DCAST(ClipPlaneAttrib, _into_node_path.get_net_state()->get_attrib(ClipPlaneAttrib::get_class_slot())); diff --git a/panda/src/collide/collisionEntry.h b/panda/src/collide/collisionEntry.h index f757804c44..558a6afa70 100644 --- a/panda/src/collide/collisionEntry.h +++ b/panda/src/collide/collisionEntry.h @@ -1,16 +1,15 @@ -// Filename: collisionEntry.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionEntry.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONENTRY_H #define COLLISIONENTRY_H @@ -30,19 +29,16 @@ #include "nodePath.h" #include "clipPlaneAttrib.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionEntry -// Description : Defines a single collision event. One of these is -// created for each collision detected by a -// CollisionTraverser, to be dealt with by the -// CollisionHandler. -// -// A CollisionEntry provides slots for a number of data -// values (such as intersection point and normal) that -// might or might not be known for each collision. It -// is up to the handler to determine what information is -// known and to do the right thing with it. -//////////////////////////////////////////////////////////////////// +/** + * Defines a single collision event. One of these is created for each + * collision detected by a CollisionTraverser, to be dealt with by the + * CollisionHandler. + * + * A CollisionEntry provides slots for a number of data values (such as + * intersection point and normal) that might or might not be known for each + * collision. It is up to the handler to determine what information is known + * and to do the right thing with it. + */ class EXPCL_PANDA_COLLIDE CollisionEntry : public TypedWritableReferenceCount { public: INLINE CollisionEntry(); @@ -120,7 +116,7 @@ public: INLINE const ClipPlaneAttrib *get_into_clip_planes() const; private: - INLINE void test_intersection(CollisionHandler *record, + INLINE void test_intersection(CollisionHandler *record, const CollisionTraverser *trav) const; void check_clip_planes(); @@ -152,7 +148,7 @@ private: LPoint3 _contact_pos; LVector3 _contact_normal; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -179,6 +175,3 @@ INLINE ostream &operator << (ostream &out, const CollisionEntry &entry); #include "collisionEntry.I" #endif - - - diff --git a/panda/src/collide/collisionFloorMesh.I b/panda/src/collide/collisionFloorMesh.I index 8b2c5465e1..613b05019b 100644 --- a/panda/src/collide/collisionFloorMesh.I +++ b/panda/src/collide/collisionFloorMesh.I @@ -1,56 +1,45 @@ -//: collisionPlane.I -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionFloorMesh.I + * @author zpavlov + * @date 2007-06-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::Default Constructor -// Access: Protected -// Description: This is only for the convenience of CollisionPolygon. -// Normally, you should not attempt to create an -// uninitialized CollisionPlane. -//////////////////////////////////////////////////////////////////// +/** + * This is only for the convenience of CollisionPolygon. Normally, you should + * not attempt to create an uninitialized CollisionPlane. + */ INLINE CollisionFloorMesh:: CollisionFloorMesh() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionFloorMesh:: CollisionFloorMesh(const CollisionFloorMesh ©) : CollisionSolid(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionFloorMesh:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::add_vertex -// Access: Published -// Description: store away a vertex to index against -//////////////////////////////////////////////////////////////////// +/** + * store away a vertex to index against + */ INLINE void CollisionFloorMesh:: add_vertex(const LPoint3 &vert) { _vertices.push_back(vert); diff --git a/panda/src/collide/collisionFloorMesh.cxx b/panda/src/collide/collisionFloorMesh.cxx index 84953f42d5..fcec727778 100644 --- a/panda/src/collide/collisionFloorMesh.cxx +++ b/panda/src/collide/collisionFloorMesh.cxx @@ -1,17 +1,15 @@ -// Filename: collisionFloorMesh.cxx -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionFloorMesh.cxx + * @author drose + * @date 2000-04-25 + */ #include "collisionFloorMesh.h" #include "collisionHandler.h" @@ -39,21 +37,17 @@ PStatCollector CollisionFloorMesh::_volume_pcollector("Collision Volumes:Collisi PStatCollector CollisionFloorMesh::_test_pcollector("Collision Tests:CollisionFloorMesh"); TypeHandle CollisionFloorMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionFloorMesh:: make_copy() { return new CollisionFloorMesh(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionFloorMesh:: xform(const LMatrix4 &mat) { Vertices::iterator vi; @@ -76,37 +70,29 @@ xform(const LMatrix4 &mat) { CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionFloorMesh:: get_collision_origin() const { - // No real sensible origin exists for a plane. We return 0, 0, 0, - // without even bothering to ensure that that point exists on the - // plane. + // No real sensible origin exists for a plane. We return 0, 0, 0, without + // even bothering to ensure that that point exists on the plane. return LPoint3::origin(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionFloorMesh:: output(ostream &out) const { out << "cfloor"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionFloorMesh:: compute_internal_bounds() const { if (_vertices.empty()) { @@ -133,11 +119,9 @@ compute_internal_bounds() const { return new BoundingBox(n, x); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::test_intersection_from_ray -// Access: Public, Virtual -// Description: must be a vertical Ray!!! -//////////////////////////////////////////////////////////////////// +/** + * must be a vertical Ray!!! + */ PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -150,12 +134,12 @@ test_intersection_from_ray(const CollisionEntry &entry) const { CollisionFloorMesh::Triangles::const_iterator ti; for (ti = _triangles.begin(); ti < _triangles.end(); ++ti) { TriangleIndices tri = *ti; - //First do a naive bounding box check on the triangle + // First do a naive bounding box check on the triangle if (fx < tri.min_x || fx >= tri.max_x || fy < tri.min_y || fy >= tri.max_y) { continue; } - //okay, there's a good chance we'll be colliding + // okay, there's a good chance we'll be colliding LPoint3 p0 = _vertices[tri.p1]; LPoint3 p1 = _vertices[tri.p2]; LPoint3 p2 = _vertices[tri.p3]; @@ -183,7 +167,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { if (v < 0.0) continue; } if (u + v <= 0.0 || u + v > 1.0) continue; - //we collided!! + // we collided!! PN_stdfloat mag = u + v; PN_stdfloat p0z = p0[2]; @@ -200,11 +184,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionFloorMesh:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; @@ -219,12 +201,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { CollisionFloorMesh::Triangles::const_iterator ti; for (ti = _triangles.begin(); ti < _triangles.end(); ++ti) { TriangleIndices tri = *ti; - //First do a naive bounding box check on the triangle + // First do a naive bounding box check on the triangle if (fx < tri.min_x || fx >= tri.max_x || fy < tri.min_y || fy >= tri.max_y) { continue; } - //okay, there's a good chance we'll be colliding + // okay, there's a good chance we'll be colliding LPoint3 p0 = _vertices[tri.p1]; LPoint3 p1 = _vertices[tri.p2]; LPoint3 p2 = _vertices[tri.p3]; @@ -252,7 +234,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { if (v < 0.0) continue; } if (u + v <= 0.0 || u + v > 1.0) continue; - //we collided!! + // we collided!! PN_stdfloat mag = u + v; PN_stdfloat p0z = p0[2]; @@ -273,12 +255,10 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionFloorMesh:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -324,36 +304,28 @@ fill_viz_geom() { _bounds_viz_geom->add_geom(geom2, get_wireframe_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionFloorMesh:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionFloorMesh:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionFloorMesh:: write_datagram(BamWriter *manager, Datagram &me) { @@ -375,14 +347,11 @@ write_datagram(BamWriter *manager, Datagram &me) } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionFloorMesh:: fillin(DatagramIterator& scan, BamReader* manager) { @@ -410,11 +379,9 @@ fillin(DatagramIterator& scan, BamReader* manager) } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::make_CollisionPolygon -// Access: Protected -// Description: Factory method to generate a CollisionPolygon object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPolygon object + */ TypedWritable* CollisionFloorMesh:: make_CollisionFloorMesh(const FactoryParams ¶ms) { CollisionFloorMesh *me = new CollisionFloorMesh; @@ -426,32 +393,26 @@ make_CollisionFloorMesh(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionPolygon object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPolygon object + */ void CollisionFloorMesh:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CollisionFloorMesh); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionFloorMesh:: write(ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionFloorMesh::add_triangle -// Access: Published -// Description: store a triangle for processing -//////////////////////////////////////////////////////////////////// +/** + * store a triangle for processing + */ void CollisionFloorMesh:: add_triangle(unsigned int pointA, unsigned int pointB, unsigned int pointC) { CollisionFloorMesh::TriangleIndices tri; diff --git a/panda/src/collide/collisionFloorMesh.h b/panda/src/collide/collisionFloorMesh.h index 31a6b1d62d..02861262c7 100644 --- a/panda/src/collide/collisionFloorMesh.h +++ b/panda/src/collide/collisionFloorMesh.h @@ -1,16 +1,15 @@ -// Filename: collisionFloorMesh.h -// Created by: zpavlov (28Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionFloorMesh.h + * @author zpavlov + * @date 2007-06-28 + */ #ifndef COLLISIONFLOORMESH_H #define COLLISIONFLOORMESH_H @@ -24,11 +23,10 @@ class GeomNode; -//////////////////////////////////////////////////////////////////// -// Class : CollisionFloorMesh -// Description : This object represents a solid made entirely of triangles, which -// will only be tested again z axis aligned rays -//////////////////////////////////////////////////////////////////// +/** + * This object represents a solid made entirely of triangles, which will only + * be tested again z axis aligned rays + */ class EXPCL_PANDA_COLLIDE CollisionFloorMesh : public CollisionSolid { public: typedef struct { diff --git a/panda/src/collide/collisionGeom.I b/panda/src/collide/collisionGeom.I index e1f2b4b6e6..5774a8d466 100644 --- a/panda/src/collide/collisionGeom.I +++ b/panda/src/collide/collisionGeom.I @@ -1,23 +1,19 @@ -// Filename: collisionGeom.I -// Created by: drose (01Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionGeom.I + * @author drose + * @date 2006-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionGeom:: CollisionGeom(const LVecBase3 &a, const LVecBase3 &b, const LVecBase3 &c) : @@ -25,11 +21,9 @@ CollisionGeom(const LVecBase3 &a, const LVecBase3 &b, { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionGeom:: CollisionGeom(const CollisionGeom ©) : CollisionPolygon(copy) diff --git a/panda/src/collide/collisionGeom.cxx b/panda/src/collide/collisionGeom.cxx index beee8e98e2..15211b9598 100644 --- a/panda/src/collide/collisionGeom.cxx +++ b/panda/src/collide/collisionGeom.cxx @@ -1,16 +1,15 @@ -// Filename: collisionGeom.cxx -// Created by: drose (01Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionGeom.cxx + * @author drose + * @date 2006-03-01 + */ #include "collisionGeom.h" @@ -18,45 +17,35 @@ PStatCollector CollisionGeom::_volume_pcollector("Collision Volumes:CollisionGeo PStatCollector CollisionGeom::_test_pcollector("Collision Tests:CollisionGeom"); TypeHandle CollisionGeom::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionGeom:: make_copy() { return new CollisionGeom(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionGeom:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionGeom:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionGeom::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionGeom:: output(ostream &out) const { out << "cgeom"; diff --git a/panda/src/collide/collisionGeom.h b/panda/src/collide/collisionGeom.h index 84730b98c1..20e736dba4 100644 --- a/panda/src/collide/collisionGeom.h +++ b/panda/src/collide/collisionGeom.h @@ -1,16 +1,15 @@ -// Filename: collisionGeom.h -// Created by: drose (01Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionGeom.h + * @author drose + * @date 2006-03-01 + */ #ifndef COLLISIONGEOM_H #define COLLISIONGEOM_H @@ -19,17 +18,14 @@ #include "collisionPolygon.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionGeom -// Description : A special CollisionPolygon created just for the -// purpose of detecting collision against geometry. -// This kind of object does not have any persistance in -// the scene graph; it is created on-the-fly. -// -// You should not attempt to create one of these -// directly; it is created only by the -// CollisionTraverser, as needed. -//////////////////////////////////////////////////////////////////// +/** + * A special CollisionPolygon created just for the purpose of detecting + * collision against geometry. This kind of object does not have any + * persistance in the scene graph; it is created on-the-fly. + * + * You should not attempt to create one of these directly; it is created only + * by the CollisionTraverser, as needed. + */ class EXPCL_PANDA_COLLIDE CollisionGeom : public CollisionPolygon { private: INLINE CollisionGeom(const LVecBase3 &a, const LVecBase3 &b, @@ -71,5 +67,3 @@ private: #include "collisionGeom.I" #endif - - diff --git a/panda/src/collide/collisionHandler.I b/panda/src/collide/collisionHandler.I index e833138ca5..5f86b36d58 100644 --- a/panda/src/collide/collisionHandler.I +++ b/panda/src/collide/collisionHandler.I @@ -1,35 +1,29 @@ -// Filename: collisionHandler.I -// Created by: WDIG (15Aug07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandler.I + * @author WDIG + * @date 2007-08-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::wants_all_potential_collidees -// Access: Private -// Description: Returns true if handler wants to know about all -// solids that are within the collider's bounding -// volume -//////////////////////////////////////////////////////////////////// +/** + * Returns true if handler wants to know about all solids that are within the + * collider's bounding volume + */ INLINE bool CollisionHandler:: wants_all_potential_collidees() const { return _wants_all_potential_collidees; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::set_root -// Access: Private -// Description: Sets the root of the collision traversal. Only set -// if wants_all_potential_collidees is true -//////////////////////////////////////////////////////////////////// +/** + * Sets the root of the collision traversal. Only set if + * wants_all_potential_collidees is true + */ INLINE void CollisionHandler:: set_root(const NodePath &root) { _root = &root; diff --git a/panda/src/collide/collisionHandler.cxx b/panda/src/collide/collisionHandler.cxx index 66eb1662ef..39d1bf4269 100644 --- a/panda/src/collide/collisionHandler.cxx +++ b/panda/src/collide/collisionHandler.cxx @@ -1,66 +1,54 @@ -// Filename: collisionHandler.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandler.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandler.h" TypeHandle CollisionHandler::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandler:: CollisionHandler() { _wants_all_potential_collidees = false; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::begin_group -// Access: Public, Virtual -// Description: Will be called by the CollisionTraverser before a new -// traversal is begun. It instructs the handler to -// reset itself in preparation for a number of -// CollisionEntries to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Will be called by the CollisionTraverser before a new traversal is begun. + * It instructs the handler to reset itself in preparation for a number of + * CollisionEntries to be sent. + */ void CollisionHandler:: begin_group() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::add_entry -// Access: Public, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandler:: add_entry(CollisionEntry *) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandler::end_group -// Access: Public, Virtual -// Description: Called by the CollisionTraverser at the completion of -// all collision detections for this traversal. It -// should do whatever finalization is required for the -// handler. -// -// The return value is normally true, but if this -// returns value, the CollisionTraverser will remove the -// handler from its list, allowing the CollisionHandler -// itself to determine when it is no longer needed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the CollisionTraverser at the completion of all collision + * detections for this traversal. It should do whatever finalization is + * required for the handler. + * + * The return value is normally true, but if this returns value, the + * CollisionTraverser will remove the handler from its list, allowing the + * CollisionHandler itself to determine when it is no longer needed. + */ bool CollisionHandler:: end_group() { return true; diff --git a/panda/src/collide/collisionHandler.h b/panda/src/collide/collisionHandler.h index e5bb10b356..8d41fe0df7 100644 --- a/panda/src/collide/collisionHandler.h +++ b/panda/src/collide/collisionHandler.h @@ -1,16 +1,15 @@ -// Filename: collisionHandler.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandler.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLER_H #define COLLISIONHANDLER_H @@ -22,14 +21,12 @@ class CollisionEntry; -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandler -// Description : The abstract interface to a number of classes that -// decide what to do when a collision is detected. One -// of these must be assigned to the CollisionTraverser -// that is processing collisions in order to specify how -// to dispatch detected collisions. -//////////////////////////////////////////////////////////////////// +/** + * The abstract interface to a number of classes that decide what to do when a + * collision is detected. One of these must be assigned to the + * CollisionTraverser that is processing collisions in order to specify how to + * dispatch detected collisions. + */ class EXPCL_PANDA_COLLIDE CollisionHandler : public TypedReferenceCount { public: CollisionHandler(); @@ -70,6 +67,3 @@ private: #include "collisionHandler.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerEvent.I b/panda/src/collide/collisionHandlerEvent.I index 77ebf1f215..28efe50dcc 100644 --- a/panda/src/collide/collisionHandlerEvent.I +++ b/panda/src/collide/collisionHandlerEvent.I @@ -1,25 +1,20 @@ -// Filename: collisionHandlerEvent.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerEvent.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::SortEntries::operator () -// Access: Public -// Description: Orders the CollisionEntries in the set so that there -// is one entry for each node/node intersection -// detected. -//////////////////////////////////////////////////////////////////// +/** + * Orders the CollisionEntries in the set so that there is one entry for each + * node/node intersection detected. + */ INLINE bool CollisionHandlerEvent::SortEntries:: operator () (const PT(CollisionEntry) &a, const PT(CollisionEntry) &b) const { @@ -30,245 +25,184 @@ operator () (const PT(CollisionEntry) &a, return a->get_into_node_path() < b->get_into_node_path(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::SortEntries::operator = -// Access: Public -// Description: The assignment operator does absolutely nothing, -// since this is just a function object class that -// stores no data. We define it just to quiet up g++ in -// -Wall mode. -//////////////////////////////////////////////////////////////////// +/** + * The assignment operator does absolutely nothing, since this is just a + * function object class that stores no data. We define it just to quiet up + * g++ in -Wall mode. + */ INLINE void CollisionHandlerEvent::SortEntries:: operator = (const CollisionHandlerEvent::SortEntries &) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::clear_in_patterns -// Access: Public -// Description: Removes all of the previously-added in patterns. See -// add_in_pattern. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-added in patterns. See add_in_pattern. + */ INLINE void CollisionHandlerEvent:: clear_in_patterns() { _in_patterns.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::add_in_pattern -// Access: Public -// Description: Adds a pattern string to the list of events that will -// be generated in response to a collision. The pattern -// string describes how the event name will be composed. -// It is a string that may contain any of the following: -// -// %fn - the name of the "from" object's node -// %in - the name of the "into" object's node -// %fs - 't' if "from" is tangible, 'i' if intangible -// %is - 't' if "into" is tangible, 'i' if intangible -// %ig - 'c' if the collision is into a -// CollisionNode, 'g' if it is a geom. -// -// %(tag)fh - generate event only if "from" node has -// the indicated net tag. -// %(tag)fx - generate event only if "from" node does -// not have the indicated net tag. -// %(tag)ih - generate event only if "into" node has -// the indicated net tag. -// %(tag)ix - generate event only if "into" node does -// not have the indicated net tag. -// %(tag)ft - the indicated net tag value of the "from" node. -// %(tag)it - the indicated net tag value of the "into" node. -// -// Parentheses in the above are literal and should be -// included in the actual pattern. -// -// The event name will be based on the in_pattern -// string specified here, with all occurrences of the -// above strings replaced with the corresponding values. -// -// In general, the in_pattern event is thrown on the -// first detection of a collision between two particular -// nodes. In subsequent passes, as long as a collision -// between those two nodes continues to be detected each -// frame, the again_pattern is thrown. The first frame -// in which the collision is no longer detected, the -// out_pattern event is thrown. -//////////////////////////////////////////////////////////////////// +/** + * Adds a pattern string to the list of events that will be generated in + * response to a collision. The pattern string describes how the event name + * will be composed. It is a string that may contain any of the following: + * + * %fn - the name of the "from" object's node %in - the name of the "into" + * object's node %fs - 't' if "from" is tangible, 'i' if intangible %is - + * 't' if "into" is tangible, 'i' if intangible %ig - 'c' if the collision is + * into a CollisionNode, 'g' if it is a geom. + * + * %(tag)fh - generate event only if "from" node has the indicated net tag. + * %(tag)fx - generate event only if "from" node does not have the indicated + * net tag. %(tag)ih - generate event only if "into" node has the indicated + * net tag. %(tag)ix - generate event only if "into" node does not have the + * indicated net tag. %(tag)ft - the indicated net tag value of the "from" + * node. %(tag)it - the indicated net tag value of the "into" node. + * + * Parentheses in the above are literal and should be included in the actual + * pattern. + * + * The event name will be based on the in_pattern string specified here, with + * all occurrences of the above strings replaced with the corresponding + * values. + * + * In general, the in_pattern event is thrown on the first detection of a + * collision between two particular nodes. In subsequent passes, as long as a + * collision between those two nodes continues to be detected each frame, the + * again_pattern is thrown. The first frame in which the collision is no + * longer detected, the out_pattern event is thrown. + */ INLINE void CollisionHandlerEvent:: add_in_pattern(const string &in_pattern) { _in_patterns.push_back(in_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::set_in_pattern -// Access: Public -// Description: This method is deprecated; it completely replaces all -// the in patterns that have previously been set with -// the indicated pattern. -//////////////////////////////////////////////////////////////////// +/** + * This method is deprecated; it completely replaces all the in patterns that + * have previously been set with the indicated pattern. + */ INLINE void CollisionHandlerEvent:: set_in_pattern(const string &in_pattern) { clear_in_patterns(); add_in_pattern(in_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_num_in_patterns -// Access: Public -// Description: Returns the number of in pattern strings that have -// been added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of in pattern strings that have been added. + */ INLINE int CollisionHandlerEvent:: get_num_in_patterns() const { return _in_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_in_pattern -// Access: Public -// Description: Returns the nth pattern string that indicates how the -// event names are generated for each collision -// detected. See add_in_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth pattern string that indicates how the event names are + * generated for each collision detected. See add_in_pattern(). + */ INLINE string CollisionHandlerEvent:: get_in_pattern(int n) const { nassertr(n >= 0 && n < (int)_in_patterns.size(), string()); return _in_patterns[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::clear_again_patterns -// Access: Public -// Description: Removes all of the previously-added in patterns. See -// add_again_pattern. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-added in patterns. See add_again_pattern. + */ INLINE void CollisionHandlerEvent:: clear_again_patterns() { _again_patterns.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::add_again_pattern -// Access: Public -// Description: Adds the pattern string that indicates how the event -// names are generated when a collision between two -// particular nodes is *still* detected. This event is -// thrown each consecutive time a collision between two -// particular nodes is detected, starting with the -// second time. -// -// In general, the in_pattern event is thrown on the -// first detection of a collision between two particular -// nodes. In subsequent passes, as long as a collision -// between those two nodes continues to be detected each -// frame, the again_pattern is thrown. The first frame -// in which the collision is no longer detected, the -// out_pattern event is thrown. -//////////////////////////////////////////////////////////////////// +/** + * Adds the pattern string that indicates how the event names are generated + * when a collision between two particular nodes is *still* detected. This + * event is thrown each consecutive time a collision between two particular + * nodes is detected, starting with the second time. + * + * In general, the in_pattern event is thrown on the first detection of a + * collision between two particular nodes. In subsequent passes, as long as a + * collision between those two nodes continues to be detected each frame, the + * again_pattern is thrown. The first frame in which the collision is no + * longer detected, the out_pattern event is thrown. + */ INLINE void CollisionHandlerEvent:: add_again_pattern(const string &again_pattern) { _again_patterns.push_back(again_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::set_again_pattern -// Access: Public -// Description: This method is deprecated; it completely replaces all -// the in patterns that have previously been set with -// the indicated pattern. -//////////////////////////////////////////////////////////////////// +/** + * This method is deprecated; it completely replaces all the in patterns that + * have previously been set with the indicated pattern. + */ INLINE void CollisionHandlerEvent:: set_again_pattern(const string &again_pattern) { clear_again_patterns(); add_again_pattern(again_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_num_again_patterns -// Access: Public -// Description: Returns the number of in pattern strings that have -// been added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of in pattern strings that have been added. + */ INLINE int CollisionHandlerEvent:: get_num_again_patterns() const { return _again_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_again_pattern -// Access: Public -// Description: Returns the nth pattern string that indicates how the -// event names are generated for each collision -// detected. See add_again_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth pattern string that indicates how the event names are + * generated for each collision detected. See add_again_pattern(). + */ INLINE string CollisionHandlerEvent:: get_again_pattern(int n) const { nassertr(n >= 0 && n < (int)_again_patterns.size(), string()); return _again_patterns[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::clear_out_patterns -// Access: Public -// Description: Removes all of the previously-added in patterns. See -// add_out_pattern. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-added in patterns. See add_out_pattern. + */ INLINE void CollisionHandlerEvent:: clear_out_patterns() { _out_patterns.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::add_out_pattern -// Access: Public -// Description: Adds the pattern string that indicates how the event -// names are generated when a collision between two -// particular nodes is *no longer* detected. -// -// In general, the in_pattern event is thrown on the -// first detection of a collision between two particular -// nodes. In subsequent passes, as long as a collision -// between those two nodes continues to be detected each -// frame, the again_pattern is thrown. The first frame -// in which the collision is no longer detected, the -// out_pattern event is thrown. -//////////////////////////////////////////////////////////////////// +/** + * Adds the pattern string that indicates how the event names are generated + * when a collision between two particular nodes is *no longer* detected. + * + * In general, the in_pattern event is thrown on the first detection of a + * collision between two particular nodes. In subsequent passes, as long as a + * collision between those two nodes continues to be detected each frame, the + * again_pattern is thrown. The first frame in which the collision is no + * longer detected, the out_pattern event is thrown. + */ INLINE void CollisionHandlerEvent:: add_out_pattern(const string &out_pattern) { _out_patterns.push_back(out_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::set_out_pattern -// Access: Public -// Description: This method is deprecated; it completely replaces all -// the in patterns that have previously been set with -// the indicated pattern. -//////////////////////////////////////////////////////////////////// +/** + * This method is deprecated; it completely replaces all the in patterns that + * have previously been set with the indicated pattern. + */ INLINE void CollisionHandlerEvent:: set_out_pattern(const string &out_pattern) { clear_out_patterns(); add_out_pattern(out_pattern); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_num_out_patterns -// Access: Public -// Description: Returns the number of in pattern strings that have -// been added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of in pattern strings that have been added. + */ INLINE int CollisionHandlerEvent:: get_num_out_patterns() const { return _out_patterns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::get_out_pattern -// Access: Public -// Description: Returns the nth pattern string that indicates how the -// event names are generated for each collision -// detected. See add_out_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth pattern string that indicates how the event names are + * generated for each collision detected. See add_out_pattern(). + */ INLINE string CollisionHandlerEvent:: get_out_pattern(int n) const { nassertr(n >= 0 && n < (int)_out_patterns.size(), string()); diff --git a/panda/src/collide/collisionHandlerEvent.cxx b/panda/src/collide/collisionHandlerEvent.cxx index 35f7e64f48..c43a3c2ee4 100644 --- a/panda/src/collide/collisionHandlerEvent.cxx +++ b/panda/src/collide/collisionHandlerEvent.cxx @@ -1,17 +1,15 @@ -// Filename: collisionHandlerEvent.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerEvent.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerEvent.h" #include "config_collide.h" @@ -22,25 +20,20 @@ TypeHandle CollisionHandlerEvent::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::Constructor -// Access: Public -// Description: The default CollisionHandlerEvent will throw no -// events. Its pattern strings must first be set via a -// call to add_in_pattern() and/or add_out_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * The default CollisionHandlerEvent will throw no events. Its pattern + * strings must first be set via a call to add_in_pattern() and/or + * add_out_pattern(). + */ CollisionHandlerEvent:: CollisionHandlerEvent() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::begin_group -// Access: Public, Virtual -// Description: Will be called by the CollisionTraverser before a new -// traversal is begun. It instructs the handler to -// reset itself in preparation for a number of -// CollisionEntries to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Will be called by the CollisionTraverser before a new traversal is begun. + * It instructs the handler to reset itself in preparation for a number of + * CollisionEntries to be sent. + */ void CollisionHandlerEvent:: begin_group() { if (collide_cat.is_spam()) { @@ -51,18 +44,16 @@ begin_group() { _current_colliding.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::add_entry -// Access: Public, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandlerEvent:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); - // Record this particular entry for later. This will keep track of - // all the unique pairs of node/node intersections. + // Record this particular entry for later. This will keep track of all the + // unique pairs of nodenode intersections. bool inserted = _current_colliding.insert(entry).second; if (collide_cat.is_spam()) { @@ -73,19 +64,16 @@ add_entry(CollisionEntry *entry) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::end_group -// Access: Public, Virtual -// Description: Called by the CollisionTraverser at the completion of -// all collision detections for this traversal. It -// should do whatever finalization is required for the -// handler. -//////////////////////////////////////////////////////////////////// +/** + * Called by the CollisionTraverser at the completion of all collision + * detections for this traversal. It should do whatever finalization is + * required for the handler. + */ bool CollisionHandlerEvent:: end_group() { - // Now compare the list of entries we collected this frame with - // those we kept from the last time. Each new entry represents a - // new 'in' event; each missing entry represents a new 'out' event. + // Now compare the list of entries we collected this frame with those we + // kept from the last time. Each new entry represents a new 'in' event; + // each missing entry represents a new 'out' event. if (collide_cat.is_spam()) { collide_cat.spam() @@ -137,44 +125,35 @@ end_group() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::clear -// Access: Public -// Description: Empties the list of elements that all colliders are -// known to be colliding with. No "out" events will be -// thrown; if the same collision is detected next frame, -// a new "in" event will be thrown for each collision. -// -// This can be called each frame to defeat the -// persistent "in" event mechanism, which prevents the -// same "in" event from being thrown repeatedly. -// However, also see add_again_pattern(), which can be -// used to set the event that is thrown when a collision -// is detected for two or more consecutive frames. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of elements that all colliders are known to be colliding + * with. No "out" events will be thrown; if the same collision is detected + * next frame, a new "in" event will be thrown for each collision. + * + * This can be called each frame to defeat the persistent "in" event + * mechanism, which prevents the same "in" event from being thrown repeatedly. + * However, also see add_again_pattern(), which can be used to set the event + * that is thrown when a collision is detected for two or more consecutive + * frames. + */ void CollisionHandlerEvent:: clear() { _last_colliding.clear(); _current_colliding.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::flush -// Access: Public -// Description: Same as clear() except "out" events are thrown. -//////////////////////////////////////////////////////////////////// +/** + * Same as clear() except "out" events are thrown. + */ void CollisionHandlerEvent:: flush() { begin_group(); end_group(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::throw_event_for -// Access: Private -// Description: Throws whatever events are suggested by the list of -// patterns. -//////////////////////////////////////////////////////////////////// +/** + * Throws whatever events are suggested by the list of patterns. + */ void CollisionHandlerEvent:: throw_event_for(const vector_string &patterns, CollisionEntry *entry) { vector_string::const_iterator pi; @@ -183,11 +162,9 @@ throw_event_for(const vector_string &patterns, CollisionEntry *entry) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::throw_event_pattern -// Access: Private -// Description: Throws an event matching the indicated pattern. -//////////////////////////////////////////////////////////////////// +/** + * Throws an event matching the indicated pattern. + */ void CollisionHandlerEvent:: throw_event_pattern(const string &pattern, CollisionEntry *entry) { if (pattern.empty()) { @@ -207,8 +184,8 @@ throw_event_pattern(const string &pattern, CollisionEntry *entry) { } } - // Get out the command--the two characters following the percent - // sign (or the key). + // Get out the command--the two characters following the percent sign + // (or the key). string cmd = pattern.substr(p + 1, 2); p += 2; if (cmd == "fn") { @@ -258,7 +235,7 @@ throw_event_pattern(const string &pattern, CollisionEntry *entry) { if (entry->has_into()) { event += entry->get_into_node_path().get_net_tag(key); } - + } else { collide_cat.error() << "Invalid symbol in event_pattern: %" << cmd << "\n"; @@ -267,7 +244,7 @@ throw_event_pattern(const string &pattern, CollisionEntry *entry) { event += pattern[p]; } } - + if (!event.empty()) { throw_event(event, EventParameter(entry)); } diff --git a/panda/src/collide/collisionHandlerEvent.h b/panda/src/collide/collisionHandlerEvent.h index bc6db4169a..c5ebfe78c9 100644 --- a/panda/src/collide/collisionHandlerEvent.h +++ b/panda/src/collide/collisionHandlerEvent.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerEvent.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerEvent.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLEREVENT_H #define COLLISIONHANDLEREVENT_H @@ -24,15 +23,12 @@ #include "vector_string.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerEvent -// Description : A specialized kind of CollisionHandler that throws an -// event for each collision detected. The event thrown -// may be based on the name of the moving object or the -// struck object, or both. The first parameter of the -// event will be a pointer to the CollisionEntry that -// triggered it. -//////////////////////////////////////////////////////////////////// +/** + * A specialized kind of CollisionHandler that throws an event for each + * collision detected. The event thrown may be based on the name of the + * moving object or the struck object, or both. The first parameter of the + * event will be a pointer to the CollisionEntry that triggered it. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerEvent : public CollisionHandler { PUBLISHED: CollisionHandlerEvent(); @@ -110,6 +106,3 @@ private: #include "collisionHandlerEvent.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerFloor.I b/panda/src/collide/collisionHandlerFloor.I index a094532b65..0c970e3f6b 100644 --- a/panda/src/collide/collisionHandlerFloor.I +++ b/panda/src/collide/collisionHandlerFloor.I @@ -1,84 +1,66 @@ -// Filename: collisionHandlerFloor.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFloor.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::set_offset -// Access: Public -// Description: Sets the linear offset to add to (or subtract from) -// the highest detected collision point to determine the -// actual height at which to set the collider. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear offset to add to (or subtract from) the highest detected + * collision point to determine the actual height at which to set the + * collider. + */ INLINE void CollisionHandlerFloor:: set_offset(PN_stdfloat offset) { _offset = offset; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::get_offset -// Access: Public -// Description: Returns the linear offset to add to (or subtract from) -// the highest detected collision point to determine the -// actual height at which to set the collider. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear offset to add to (or subtract from) the highest detected + * collision point to determine the actual height at which to set the + * collider. + */ INLINE PN_stdfloat CollisionHandlerFloor:: get_offset() const { return _offset; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::set_reach -// Access: Public -// Description: Sets the reach to add to (or subtract from) -// the highest collision point -//////////////////////////////////////////////////////////////////// +/** + * Sets the reach to add to (or subtract from) the highest collision point + */ INLINE void CollisionHandlerFloor:: set_reach(PN_stdfloat reach) { _reach = reach; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::get_reach -// Access: Public -// Description: Returns the reach to add to (or subtract from) -// the highest collision point -//////////////////////////////////////////////////////////////////// +/** + * Returns the reach to add to (or subtract from) the highest collision point + */ INLINE PN_stdfloat CollisionHandlerFloor:: get_reach() const { return _reach; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::set_max_velocity -// Access: Public -// Description: Sets the maximum speed at which the object will be -// allowed to descend towards a floor below it, in units -// per second. Set this to zero to allow it to -// instantly teleport any distance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum speed at which the object will be allowed to descend + * towards a floor below it, in units per second. Set this to zero to allow + * it to instantly teleport any distance. + */ INLINE void CollisionHandlerFloor:: set_max_velocity(PN_stdfloat max_velocity) { _max_velocity = max_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::get_max_velocity -// Access: Public -// Description: Retrieves the maximum speed at which the object will -// be allowed to descend towards a floor below it, in -// units per second. See set_max_velocity(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the maximum speed at which the object will be allowed to descend + * towards a floor below it, in units per second. See set_max_velocity(). + */ INLINE PN_stdfloat CollisionHandlerFloor:: get_max_velocity() const { return _max_velocity; diff --git a/panda/src/collide/collisionHandlerFloor.cxx b/panda/src/collide/collisionHandlerFloor.cxx index c86933d696..e8f697fb5f 100644 --- a/panda/src/collide/collisionHandlerFloor.cxx +++ b/panda/src/collide/collisionHandlerFloor.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerFloor.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFloor.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerFloor.h" #include "collisionNode.h" @@ -21,11 +20,9 @@ TypeHandle CollisionHandlerFloor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerFloor:: CollisionHandlerFloor() { _offset = 0.0f; @@ -33,33 +30,34 @@ CollisionHandlerFloor() { _max_velocity = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerFloor:: ~CollisionHandlerFloor() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_highest_collision -// Access: Protected -// Description: -// -// -// -// -// -// -//////////////////////////////////////////////////////////////////// +/** + * + + * + + * + + * + + * + + * + + * + */ PN_stdfloat CollisionHandlerFloor:: set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries) { - // Get the maximum height for all collisions with this node. - // This is really the distance to-the-ground, so it will - // be negative when the avatar is above the ground. - // Larger values (less negative) are higher elevation (assuming - // the avatar is right-side-up (or the ray is plumb)). + // Get the maximum height for all collisions with this node. This is really + // the distance to-the-ground, so it will be negative when the avatar is + // above the ground. Larger values (less negative) are higher elevation + // (assuming the avatar is right-side-up (or the ray is plumb)). bool got_max = false; bool got_min = false; PN_stdfloat max_height = 0.0f; @@ -96,13 +94,12 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod } if (!got_max && got_min) { // We've fallen through the world, but we're also under some walkable - // geometry. - // Move us up to the lowest surface: + // geometry. Move us up to the lowest surface: got_max = true; max_height = min_height; highest = lowest; } - //#*#_has_contact = got_max; + // #*#_has_contact = got_max; #if 0 cout<<"\ncolliding with:\n"; @@ -114,34 +111,31 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod cout<get_from_node_path(), false); - + if (entry->has_surface_point()) { LPoint3 point = entry->get_surface_point(def._target); if (collide_cat.is_debug()) { collide_cat.debug() << "Intersection point detected at " << point << "\n"; } - + PN_stdfloat height = point[2]; if (!got_max || height > max_height) { got_max = true; @@ -200,14 +193,14 @@ handle_entries() { PN_stdfloat max_height = set_highest_collision(def._target, from_node_path, entries); // Now set our height accordingly. - PN_stdfloat adjust = max_height + _offset; + PN_stdfloat adjust = max_height + _offset; #endif if (!IS_THRESHOLD_ZERO(adjust, 0.001)) { if (collide_cat.is_debug()) { collide_cat.debug() << "Adjusting height by " << adjust << "\n"; } - + if (adjust < 0.0f && _max_velocity != 0.0f) { PN_stdfloat max_adjust = _max_velocity * ClockObject::get_global_clock()->get_dt(); @@ -234,11 +227,9 @@ handle_entries() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFloor::apply_linear_force -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionHandlerFloor:: apply_linear_force(ColliderDef &def, const LVector3 &force) { } diff --git a/panda/src/collide/collisionHandlerFloor.h b/panda/src/collide/collisionHandlerFloor.h index 3f4eece73a..d73ca008df 100644 --- a/panda/src/collide/collisionHandlerFloor.h +++ b/panda/src/collide/collisionHandlerFloor.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerFloor.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFloor.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERFLOOR_H #define COLLISIONHANDLERFLOOR_H @@ -19,15 +18,12 @@ #include "collisionHandlerPhysical.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerFloor -// Description : A specialized kind of CollisionHandler that sets the -// Z height of the collider to a fixed linear offset -// from the highest detected collision point each frame. -// It's intended to implement walking around on a floor -// of varying height by casting a ray down from the -// avatar's head. -//////////////////////////////////////////////////////////////////// +/** + * A specialized kind of CollisionHandler that sets the Z height of the + * collider to a fixed linear offset from the highest detected collision point + * each frame. It's intended to implement walking around on a floor of + * varying height by casting a ray down from the avatar's head. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerFloor : public CollisionHandlerPhysical { PUBLISHED: CollisionHandlerFloor(); @@ -79,6 +75,3 @@ private: #include "collisionHandlerFloor.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerFluidPusher.I b/panda/src/collide/collisionHandlerFluidPusher.I index 4fada94a02..4c1a927f2c 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.I +++ b/panda/src/collide/collisionHandlerFluidPusher.I @@ -1,14 +1,12 @@ -// Filename: collisionHandlerFluidPusher.I -// Created by: WDIG (15Aug07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFluidPusher.I + * @author WDIG + * @date 2007-08-15 + */ diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index 8deab17d6c..eea0cc1f22 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerFluidPusher.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFluidPusher.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerFluidPusher.h" #include "collisionNode.h" @@ -22,29 +21,24 @@ TypeHandle CollisionHandlerFluidPusher::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFluidPusher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerFluidPusher:: CollisionHandlerFluidPusher() { _wants_all_potential_collidees = true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFluidPusher::add_entry -// Access: Public, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandlerFluidPusher:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); - // skip over CollisionHandlerPhysical::add_entry, since it filters - // out collidees by orientation; our collider can change direction - // mid-frame, so it may collide with something that would have been - // filtered out + // skip over CollisionHandlerPhysical::add_entry, since it filters out + // collidees by orientation; our collider can change direction mid-frame, so + // it may collide with something that would have been filtered out CollisionHandlerEvent::add_entry(entry); // filter out non-tangibles @@ -58,12 +52,10 @@ add_entry(CollisionEntry *entry) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerFluidPusher::handle_entries -// Access: Protected, Virtual -// Description: Calculates a reasonable final position for a -// collider given a set of collidees -//////////////////////////////////////////////////////////////////// +/** + * Calculates a reasonable final position for a collider given a set of + * collidees + */ bool CollisionHandlerFluidPusher:: handle_entries() { /* @@ -72,25 +64,25 @@ handle_entries() { exhausted or the collider becomes "stuck". This solves the "acute collisions" problem where colliders could bounce their way through to the other side of a wall. - + Pseudocode: - + INPUTS PosA = collider's previous position PosB = collider's current position M = movement vector (PosB - PosA) BV = bounding sphere that includes collider at PosA and PosB CS = 'collision set', all 'collidables' within BV (collision polys, tubes, etc) - + VARIABLES N = movement vector since most recent collision (or start of frame) SCS = 'sub collision set', all collidables that could still be collided with C = single collider currently being collided with PosX = new position given movement along N interrupted by collision with C - + OUTPUTS final position is PosX - + 1. N = M, SCS = CS, PosX = PosB 2. compute, using SCS and N, which collidable C is the first collision 3. if no collision found, DONE @@ -112,57 +104,58 @@ handle_entries() { for (fei = _from_entries.begin(); fei != _from_entries.end(); ++fei) { NodePath from_node_path = fei->first; Entries *orig_entries = &fei->second; - + Colliders::iterator ci; ci = _colliders.find(from_node_path); if (ci == _colliders.end()) { - // Hmm, someone added a CollisionNode to a traverser and gave - // it this CollisionHandler pointer--but they didn't tell us - // about the node. + // Hmm, someone added a CollisionNode to a traverser and gave it this + // CollisionHandler pointer--but they didn't tell us about the node. collide_cat.error() << "CollisionHandlerFluidPusher doesn't know about " << from_node_path << ", disabling.\n"; okflag = false; } else { ColliderDef &def = (*ci).second; - + // we do our math in this node's space NodePath wrt_node(*_root); - + // extract the collision entries into a vector that we can safely modify Entries entries(*orig_entries); - - // this is the original position delta for the entire frame, before collision response + + // this is the original position delta for the entire frame, before + // collision response LVector3 M(from_node_path.get_pos_delta(wrt_node)); - // this is used to track position deltas every time we collide against a solid + // this is used to track position deltas every time we collide against a + // solid LVector3 N(M); - + const LPoint3 orig_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) prev_trans(from_node_path.get_prev_transform(wrt_node)); const LPoint3 orig_prev_pos(prev_trans->get_pos()); - + // currently we only support spheres as the collider const CollisionSphere *sphere; DCAST_INTO_R(sphere, entries.front()->get_from(), 0); - + from_node_path.set_pos(wrt_node, 0,0,0); LPoint3 sphere_offset = (sphere->get_center() * from_node_path.get_transform(wrt_node)->get_mat()); from_node_path.set_pos(wrt_node, orig_pos); - + // this will hold the final calculated position at each iteration LPoint3 candidate_final_pos(orig_pos); // this holds the position before reacting to collisions LPoint3 uncollided_pos(candidate_final_pos); - + // unit vector facing back into original direction of motion LVector3 reverse_vec(-M); reverse_vec.normalize(); - - // unit vector pointing out to the right relative to the direction of motion, - // looking into the direction of motion + + // unit vector pointing out to the right relative to the direction of + // motion, looking into the direction of motion const LVector3 right_unit(LVector3::up().cross(reverse_vec)); - + // iterate until the mover runs out of movement or gets stuck while (true) { const CollisionEntry *C = 0; @@ -176,12 +169,12 @@ handle_entries() { C = entry; } } - + // if no collisions, we're done if (C == 0) { break; } - + // move back to initial contact position LPoint3 contact_pos; LVector3 contact_normal; @@ -194,17 +187,17 @@ handle_entries() { } // calculate the position of the target node at the point of contact contact_pos -= sphere_offset; - + uncollided_pos = candidate_final_pos; candidate_final_pos = contact_pos; - + LVector3 proj_surface_normal(contact_normal); LVector3 norm_proj_surface_normal(proj_surface_normal); norm_proj_surface_normal.normalize(); - + LVector3 blocked_movement(uncollided_pos - contact_pos); - + PN_stdfloat push_magnitude(-blocked_movement.dot(proj_surface_normal)); if (push_magnitude < 0.0f) { // don't ever push into plane @@ -214,12 +207,12 @@ handle_entries() { // project the final position onto the plane of the obstruction candidate_final_pos = uncollided_pos + (norm_proj_surface_normal * push_magnitude); } - + from_node_path.set_pos(wrt_node, candidate_final_pos); CPT(TransformState) prev_trans(from_node_path.get_prev_transform(wrt_node)); prev_trans = prev_trans->set_pos(contact_pos); from_node_path.set_prev_transform(wrt_node, prev_trans); - + { const LPoint3 new_pos(from_node_path.get_pos(wrt_node)); CPT(TransformState) new_prev_trans(from_node_path.get_prev_transform(wrt_node)); @@ -228,7 +221,7 @@ handle_entries() { // recalculate the position delta N = from_node_path.get_pos_delta(wrt_node); - + // calculate new collisions given new movement vector Entries::iterator ei; Entries new_entries; @@ -247,27 +240,27 @@ handle_entries() { } entries.swap(new_entries); } - + // put things back where they were from_node_path.set_pos(wrt_node, orig_pos); // restore the appropriate previous position prev_trans = from_node_path.get_prev_transform(wrt_node); prev_trans = prev_trans->set_pos(orig_prev_pos); from_node_path.set_prev_transform(wrt_node, prev_trans); - + LVector3 net_shove(candidate_final_pos - orig_pos); LVector3 force_normal(net_shove); force_normal.normalize(); - + // This is the part where the node actually gets moved: def._target.set_pos(wrt_node, candidate_final_pos); - - // We call this to allow derived classes to do other - // fix-ups as they see fit: + + // We call this to allow derived classes to do other fix-ups as they see + // fit: apply_net_shove(def, net_shove, force_normal); apply_linear_force(def, force_normal); } } - + return okflag; } diff --git a/panda/src/collide/collisionHandlerFluidPusher.h b/panda/src/collide/collisionHandlerFluidPusher.h index 7f1f02b9c6..f4c0694f65 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.h +++ b/panda/src/collide/collisionHandlerFluidPusher.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerFluidPusher.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerFluidPusher.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERFLUIDPUSHER_H #define COLLISIONHANDLERFLUIDPUSHER_H @@ -20,12 +19,10 @@ #include "collisionSolid.h" #include "collisionHandlerPusher.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerFluidPusher -// Description : A CollisionHandlerPusher that makes use of timing -// and spatial information from fluid collisions to improve -// collision response -//////////////////////////////////////////////////////////////////// +/** + * A CollisionHandlerPusher that makes use of timing and spatial information + * from fluid collisions to improve collision response + */ class EXPCL_PANDA_COLLIDE CollisionHandlerFluidPusher : public CollisionHandlerPusher { PUBLISHED: CollisionHandlerFluidPusher(); @@ -57,6 +54,3 @@ private: #include "collisionHandlerFluidPusher.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerGravity.I b/panda/src/collide/collisionHandlerGravity.I index 7c61954c5e..48c172959f 100644 --- a/panda/src/collide/collisionHandlerGravity.I +++ b/panda/src/collide/collisionHandlerGravity.I @@ -1,225 +1,177 @@ -// Filename: collisionHandlerGravity.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerGravity.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_offset -// Access: Public -// Description: Sets the linear offset to add to (or subtract from) -// the highest detected collision point to determine the -// actual height at which to set the collider. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear offset to add to (or subtract from) the highest detected + * collision point to determine the actual height at which to set the + * collider. + */ INLINE void CollisionHandlerGravity:: set_offset(PN_stdfloat offset) { _offset = offset; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_offset -// Access: Public -// Description: Returns the linear offset to add to (or subtract from) -// the highest detected collision point to determine the -// actual height at which to set the collider. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear offset to add to (or subtract from) the highest detected + * collision point to determine the actual height at which to set the + * collider. + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_offset() const { return _offset; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_reach -// Access: Public -// Description: Sets the reach to add to (or subtract from) -// the highest collision point -//////////////////////////////////////////////////////////////////// +/** + * Sets the reach to add to (or subtract from) the highest collision point + */ INLINE void CollisionHandlerGravity:: set_reach(PN_stdfloat reach) { _reach = reach; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_reach -// Access: Public -// Description: Returns the reach to add to (or subtract from) -// the highest collision point -//////////////////////////////////////////////////////////////////// +/** + * Returns the reach to add to (or subtract from) the highest collision point + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_reach() const { return _reach; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_airborne_height -// Access: Public -// Description: Return the height of the object from the ground. -// -// The object might not necessarily be at rest. Use -// is_on_ground() if you want to know whether the -// object is on the ground and at rest. -// -// See Also: is_in_outer_space() -//////////////////////////////////////////////////////////////////// +/** + * Return the height of the object from the ground. + * + * The object might not necessarily be at rest. Use is_on_ground() if you + * want to know whether the object is on the ground and at rest. + * + * See Also: is_in_outer_space() + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_airborne_height() const { return _airborne_height; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::is_on_ground -// Access: Public -// Description: Is the object at rest? -//////////////////////////////////////////////////////////////////// +/** + * Is the object at rest? + */ INLINE bool CollisionHandlerGravity:: is_on_ground() const { // Testing for 0.0f here is not as foolhardy as it may appear. The - // handle_entries() function will set these values to 0.0f if they - // are within a threshold. + // handle_entries() function will set these values to 0.0f if they are + // within a threshold. return get_airborne_height() == 0.0f && _current_velocity == 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_impact_velocity -// Access: Public -// Description: How hard did the object hit the ground. -// This value is set on impact with the ground. -// You may want to watch (poll) on is_on_groun() and -// when that is true, call get_impact_velocity(). -// Normally I avoid polling, but we are calling -// is_on_ground() frequently anyway. -//////////////////////////////////////////////////////////////////// +/** + * How hard did the object hit the ground. This value is set on impact with + * the ground. You may want to watch (poll) on is_on_groun() and when that is + * true, call get_impact_velocity(). Normally I avoid polling, but we are + * calling is_on_ground() frequently anyway. + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_impact_velocity() const { return _impact_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_contact_normal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVector3 &CollisionHandlerGravity:: get_contact_normal() const { return _contact_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::add_velocity -// Access: Public -// Description: Adds the sepcified amount to the current velocity. -// This is mostly here allow this common operation to -// be faster for scripting, but it's also more concise -// even in cpp. -//////////////////////////////////////////////////////////////////// +/** + * Adds the sepcified amount to the current velocity. This is mostly here + * allow this common operation to be faster for scripting, but it's also more + * concise even in cpp. + */ INLINE void CollisionHandlerGravity:: add_velocity(PN_stdfloat velocity) { _current_velocity += velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_velocity -// Access: Public -// Description: Sets the current vertical velocity. -//////////////////////////////////////////////////////////////////// +/** + * Sets the current vertical velocity. + */ INLINE void CollisionHandlerGravity:: set_velocity(PN_stdfloat velocity) { _current_velocity = velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_velocity -// Access: Public -// Description: Gets the current vertical velocity. -// -// Generally, negative values mean the object is in -// free fall; while postive values mean the object has -// vertical thrust. -// -// A zero value does not necessarily mean the object -// on the ground, it may also be weightless and/or at -// the apex of its jump. -// -// See Also: is_on_ground() and get_gravity() -//////////////////////////////////////////////////////////////////// +/** + * Gets the current vertical velocity. + * + * Generally, negative values mean the object is in free fall; while postive + * values mean the object has vertical thrust. + * + * A zero value does not necessarily mean the object on the ground, it may + * also be weightless and/or at the apex of its jump. + * + * See Also: is_on_ground() and get_gravity() + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_velocity() const { return _current_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_gravity -// Access: Public -// Description: Sets the linear gravity force (always plumb). -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear gravity force (always plumb). + */ INLINE void CollisionHandlerGravity:: set_gravity(PN_stdfloat gravity) { _gravity = gravity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_gravity -// Access: Public -// Description: Gets the linear gravity force (always plumb). -//////////////////////////////////////////////////////////////////// +/** + * Gets the linear gravity force (always plumb). + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_gravity() const { return _gravity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_max_velocity -// Access: Public -// Description: Sets the maximum speed at which the object will be -// allowed to descend towards a floor below it, in units -// per second. Set this to zero to allow it to -// instantly teleport any distance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum speed at which the object will be allowed to descend + * towards a floor below it, in units per second. Set this to zero to allow + * it to instantly teleport any distance. + */ INLINE void CollisionHandlerGravity:: set_max_velocity(PN_stdfloat max_velocity) { _max_velocity = max_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_max_velocity -// Access: Public -// Description: Retrieves the maximum speed at which the object will -// be allowed to descend towards a floor below it, in -// units per second. See set_max_velocity(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the maximum speed at which the object will be allowed to descend + * towards a floor below it, in units per second. See set_max_velocity(). + */ INLINE PN_stdfloat CollisionHandlerGravity:: get_max_velocity() const { return _max_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_legacy_mode -// Access: Public -// Description: Enables old behavior required by Toontown -// (Sellbot Factory lava room is good test case, -// lava and conveyor belt specifically). Behavior -// is to throw enter/exit events only for floor -// that the toon is in contact with -//////////////////////////////////////////////////////////////////// +/** + * Enables old behavior required by Toontown (Sellbot Factory lava room is + * good test case, lava and conveyor belt specifically). Behavior is to throw + * enter/exit events only for floor that the toon is in contact with + */ INLINE void CollisionHandlerGravity:: set_legacy_mode(bool legacy_mode) { _legacy_mode = legacy_mode; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::get_legacy_mode -// Access: Public -// Description: returns true if legacy mode is enabled -//////////////////////////////////////////////////////////////////// +/** + * returns true if legacy mode is enabled + */ INLINE bool CollisionHandlerGravity:: get_legacy_mode() const { return _legacy_mode; diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index 6d7cf943c1..a09b70a0a6 100644 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerGravity.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerGravity.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerGravity.h" #include "collisionNode.h" @@ -21,11 +20,9 @@ TypeHandle CollisionHandlerGravity::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerGravity:: CollisionHandlerGravity() { _offset = 0.0f; @@ -39,20 +36,16 @@ CollisionHandlerGravity() { _legacy_mode = false; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerGravity:: ~CollisionHandlerGravity() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::set_highest_collision -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ #define OLD_COLLISION_HANDLER_GRAVITY 0 #if OLD_COLLISION_HANDLER_GRAVITY PN_stdfloat CollisionHandlerGravity:: @@ -83,7 +76,7 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod } } } - //#*#_has_contact = got_max; + // #*#_has_contact = got_max; #if 0 cout<<"\ncolliding with:\n"; @@ -96,8 +89,8 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod #endif if (_legacy_mode) { - // We only collide with things we are impacting with. - // Remove the collisions: + // We only collide with things we are impacting with. Remove the + // collisions: _current_colliding.clear(); // Add only the one that we're impacting with: add_entry(highest); @@ -108,11 +101,10 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod #else PN_stdfloat CollisionHandlerGravity:: set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries) { - // Get the maximum height for all collisions with this node. - // This is really the distance to-the-ground, so it will - // be negative when the avatar is above the ground. - // Larger values (less negative) are higher elevation (assuming - // the avatar is right-side-up (or the ray is plumb)). + // Get the maximum height for all collisions with this node. This is really + // the distance to-the-ground, so it will be negative when the avatar is + // above the ground. Larger values (less negative) are higher elevation + // (assuming the avatar is right-side-up (or the ray is plumb)). bool got_max = false; bool got_min = false; PN_stdfloat max_height = 0.0f; @@ -152,14 +144,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod } if (!got_max && got_min) { // We've fallen through the world, but we're also under some walkable - // geometry. - // Move us up to the lowest surface: + // geometry. Move us up to the lowest surface: got_max = true; max_height = min_height; highest = lowest; valid_entries.push_back(lowest); } - //#*#_has_contact = got_max; + // #*#_has_contact = got_max; #if 0 cout<<"\ncolliding with:\n"; @@ -171,8 +162,8 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod cout<get_into()->is_of_type(CollisionPlane::get_class_type())) { - // This is asking: what is the normal of the plane that the avatar - // is colliding with relative to the avatar. A positive y valye means - // the avatar is facing downhill and a negative y value means the - // avatar is facing uphill. - //_contact_normal = DCAST(CollisionPlane, highest->get_into())->get_normal() * from_node_path.get_mat(highest->get_into_node_path()); - //_contact_normal = DCAST(CollisionPlane, highest->get_into())->get_normal(); - // This is asking: what is the normal of the avatar that the avatar - // is colliding with relative to the plane. +/* + * This is asking: what is the normal of the plane that the avatar is + * colliding with relative to the avatar. A positive y valye means the avatar + * is facing downhill and a negative y value means the avatar is facing + * uphill. _contact_normal = DCAST(CollisionPlane, + * highest->get_into())->get_normal() * + * from_node_path.get_mat(highest->get_into_node_path()); _contact_normal = + * DCAST(CollisionPlane, highest->get_into())->get_normal(); This is asking: + * what is the normal of the avatar that the avatar is colliding with relative + * to the plane. + */ CPT(TransformState) transform = highest->get_into_node_path().get_transform(from_node_path); _contact_normal = DCAST(CollisionPlane, highest->get_into())->get_normal() * transform->get_mat(); } else { @@ -207,17 +201,14 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod } #endif -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::handle_entries -// Access: Protected, Virtual -// Description: Called by the parent class after all collisions have -// been detected, this manages the various collisions -// and moves around the nodes as necessary. -// -// The return value is normally true, but it may be -// false to indicate the CollisionTraverser should -// disable this handler from being called in the future. -//////////////////////////////////////////////////////////////////// +/** + * Called by the parent class after all collisions have been detected, this + * manages the various collisions and moves around the nodes as necessary. + * + * The return value is normally true, but it may be false to indicate the + * CollisionTraverser should disable this handler from being called in the + * future. + */ bool CollisionHandlerGravity:: handle_entries() { bool okflag = true; @@ -230,9 +221,8 @@ handle_entries() { Colliders::iterator ci; ci = _colliders.find(from_node_path); if (ci == _colliders.end()) { - // Hmm, someone added a CollisionNode to a traverser and gave - // it this CollisionHandler pointer--but they didn't tell us - // about the node. + // Hmm, someone added a CollisionNode to a traverser and gave it this + // CollisionHandler pointer--but they didn't tell us about the node. collide_cat.error() << get_type() << " doesn't know about " << from_node_path << ", disabling.\n"; @@ -254,16 +244,16 @@ handle_entries() { } if (_current_velocity > 0.0f || adjust) { - // ...we have a vertical thrust, - // ...or the node is above the floor, so it is airborne. + // ...we have a vertical thrust, ...or the node is above the floor, + // so it is airborne. PN_stdfloat dt = ClockObject::get_global_clock()->get_dt(); - // Fyi, the sign of _gravity is reversed. I think it makes the get_*() set_*() - // more intuitive to do it this way. + // Fyi, the sign of _gravity is reversed. I think it makes the + // get_*() set_*() more intuitive to do it this way. PN_stdfloat gravity_adjust = _current_velocity * dt + 0.5 * -_gravity * dt * dt; if (adjust > 0.0f) { - // ...the node is under the floor, so it has landed. - // Keep the adjust to bring us up to the ground and - // then add the gravity_adjust to get us airborne: + // ...the node is under the floor, so it has landed. Keep the + // adjust to bring us up to the ground and then add the + // gravity_adjust to get us airborne: adjust += max((PN_stdfloat)0.0, gravity_adjust); } else { // ...the node is above the floor, so it is airborne. @@ -306,11 +296,9 @@ handle_entries() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::apply_linear_force -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionHandlerGravity:: apply_linear_force(ColliderDef &def, const LVector3 &force) { } diff --git a/panda/src/collide/collisionHandlerGravity.h b/panda/src/collide/collisionHandlerGravity.h index f3c0b69839..de89091564 100644 --- a/panda/src/collide/collisionHandlerGravity.h +++ b/panda/src/collide/collisionHandlerGravity.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerGravity.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerGravity.h + * @author drose + * @date 2002-03-16 + */ #ifndef CollisionHandlerGravity_H #define CollisionHandlerGravity_H @@ -19,15 +18,12 @@ #include "collisionHandlerPhysical.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerGravity -// Description : A specialized kind of CollisionHandler that sets the -// Z height of the collider to a fixed linear offset -// from the highest detected collision point each frame. -// It's intended to implement walking around on a floor -// of varying height by casting a ray down from the -// avatar's head. -//////////////////////////////////////////////////////////////////// +/** + * A specialized kind of CollisionHandler that sets the Z height of the + * collider to a fixed linear offset from the highest detected collision point + * each frame. It's intended to implement walking around on a floor of + * varying height by casting a ray down from the avatar's head. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerGravity : public CollisionHandlerPhysical { PUBLISHED: CollisionHandlerGravity(); @@ -106,6 +102,3 @@ private: #include "collisionHandlerGravity.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerHighestEvent.cxx b/panda/src/collide/collisionHandlerHighestEvent.cxx index 145f6687ae..f72023153d 100644 --- a/panda/src/collide/collisionHandlerHighestEvent.cxx +++ b/panda/src/collide/collisionHandlerHighestEvent.cxx @@ -1,17 +1,15 @@ -// Filename: collisionHandlerHighestEvent.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerHighestEvent.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerHighestEvent.h" #include "config_collide.h" @@ -22,25 +20,20 @@ TypeHandle CollisionHandlerHighestEvent::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::Constructor -// Access: Public -// Description: The default CollisionHandlerEvent will throw no -// events. Its pattern strings must first be set via a -// call to add_in_pattern() and/or add_out_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * The default CollisionHandlerEvent will throw no events. Its pattern + * strings must first be set via a call to add_in_pattern() and/or + * add_out_pattern(). + */ CollisionHandlerHighestEvent:: CollisionHandlerHighestEvent() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::begin_group -// Access: Public, Virtual -// Description: Will be called by the CollisionTraverser before a new -// traversal is begun. It instructs the handler to -// reset itself in preparation for a number of -// CollisionEntries to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Will be called by the CollisionTraverser before a new traversal is begun. + * It instructs the handler to reset itself in preparation for a number of + * CollisionEntries to be sent. + */ void CollisionHandlerHighestEvent:: begin_group() { if (collide_cat.is_spam()) { @@ -56,12 +49,10 @@ begin_group() { _closest_collider = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerEvent::add_entry -// Access: Public, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandlerHighestEvent:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); @@ -75,14 +66,11 @@ add_entry(CollisionEntry *entry) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::end_group -// Access: Public, Virtual -// Description: Called by the CollisionTraverser at the completion of -// all collision detections for this traversal. It -// should do whatever finalization is required for the -// handler. -//////////////////////////////////////////////////////////////////// +/** + * Called by the CollisionTraverser at the completion of all collision + * detections for this traversal. It should do whatever finalization is + * required for the handler. + */ bool CollisionHandlerHighestEvent:: end_group() { if (_closest_collider) { diff --git a/panda/src/collide/collisionHandlerHighestEvent.h b/panda/src/collide/collisionHandlerHighestEvent.h index e3a5d43d25..a688ac4a57 100644 --- a/panda/src/collide/collisionHandlerHighestEvent.h +++ b/panda/src/collide/collisionHandlerHighestEvent.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerHighestEvent.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerHighestEvent.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERHIGHESTEVENT_H #define COLLISIONHANDLERHIGHESTEVENT_H @@ -24,15 +23,12 @@ #include "vector_string.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerEvent -// Description : A specialized kind of CollisionHandler that throws an -// event for each collision detected. The event thrown -// may be based on the name of the moving object or the -// struck object, or both. The first parameter of the -// event will be a pointer to the CollisionEntry that -// triggered it. -//////////////////////////////////////////////////////////////////// +/** + * A specialized kind of CollisionHandler that throws an event for each + * collision detected. The event thrown may be based on the name of the + * moving object or the struck object, or both. The first parameter of the + * event will be a pointer to the CollisionEntry that triggered it. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerHighestEvent : public CollisionHandlerEvent { PUBLISHED: CollisionHandlerHighestEvent(); @@ -65,6 +61,3 @@ private: }; #endif - - - diff --git a/panda/src/collide/collisionHandlerPhysical.I b/panda/src/collide/collisionHandlerPhysical.I index 4ebbd9e7d6..d0f45fd495 100644 --- a/panda/src/collide/collisionHandlerPhysical.I +++ b/panda/src/collide/collisionHandlerPhysical.I @@ -1,96 +1,77 @@ -// Filename: collisionHandlerPhysical.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPhysical.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::set_center -// Access: Published -// Description: Specifies an arbitrary NodePath that the handler is -// always considered to be facing. It does not detect -// collisions with surfaces that appear to be facing -// away from this NodePath. This works best when the -// collision surfaces in question are polygons. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an arbitrary NodePath that the handler is always considered to be + * facing. It does not detect collisions with surfaces that appear to be + * facing away from this NodePath. This works best when the collision + * surfaces in question are polygons. + */ INLINE void CollisionHandlerPhysical:: set_center(const NodePath ¢er) { _center = center; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::clear_center -// Access: Published -// Description: Clears the center NodePath specified with set_center. -//////////////////////////////////////////////////////////////////// +/** + * Clears the center NodePath specified with set_center. + */ INLINE void CollisionHandlerPhysical:: clear_center() { _center = NodePath(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::get_center -// Access: Published -// Description: Returns the NodePath specified with set_center, or -// the empty NodePath if nothing has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath specified with set_center, or the empty NodePath if + * nothing has been specified. + */ INLINE const NodePath &CollisionHandlerPhysical:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::has_center -// Access: Published -// Description: Returns true if a NodePath has been specified with -// set_center(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a NodePath has been specified with set_center(), false + * otherwise. + */ INLINE bool CollisionHandlerPhysical:: has_center() const { return !_center.is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::has_contact -// Access: Public -// Description: Did the handler make any contacts with anything -// on the last collision pass? Depending on how your -// world is setup, this can be used to tell if the -// handler is out of the world (i.e. out of bounds). -// That is the original use of this call. -//////////////////////////////////////////////////////////////////// +/** + * Did the handler make any contacts with anything on the last collision pass? + * Depending on how your world is setup, this can be used to tell if the + * handler is out of the world (i.e. out of bounds). That is the original use + * of this call. + */ INLINE bool CollisionHandlerPhysical:: has_contact() const { return _has_contact; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::ColliderDef::set_target -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionHandlerPhysical::ColliderDef:: set_target(const NodePath &target, DriveInterface *drive_interface) { _target = target; _drive_interface = drive_interface; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::ColliderDef::updated_transform -// Access: Public -// Description: Called by the handler when it has changed the -// transform on the target node, this applies the change -// to the drive interface if one is specified. -//////////////////////////////////////////////////////////////////// +/** + * Called by the handler when it has changed the transform on the target node, + * this applies the change to the drive interface if one is specified. + */ INLINE void CollisionHandlerPhysical::ColliderDef:: updated_transform() { if (_drive_interface != (DriveInterface *)NULL) { diff --git a/panda/src/collide/collisionHandlerPhysical.cxx b/panda/src/collide/collisionHandlerPhysical.cxx index a99625e011..4b356235a3 100644 --- a/panda/src/collide/collisionHandlerPhysical.cxx +++ b/panda/src/collide/collisionHandlerPhysical.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerPhysical.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPhysical.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerPhysical.h" #include "config_collide.h" @@ -20,33 +19,26 @@ TypeHandle CollisionHandlerPhysical::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerPhysical:: CollisionHandlerPhysical() { _has_contact = false; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerPhysical:: ~CollisionHandlerPhysical() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::begin_group -// Access: Public, Virtual -// Description: Will be called by the CollisionTraverser before a new -// traversal is begun. It instructs the handler to -// reset itself in preparation for a number of -// CollisionEntries to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Will be called by the CollisionTraverser before a new traversal is begun. + * It instructs the handler to reset itself in preparation for a number of + * CollisionEntries to be sent. + */ void CollisionHandlerPhysical:: begin_group() { CollisionHandlerEvent::begin_group(); @@ -54,12 +46,10 @@ begin_group() { _has_contact = false; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::add_entry -// Access: Public, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandlerPhysical:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); @@ -69,8 +59,8 @@ add_entry(CollisionEntry *entry) { (!entry->has_into() || entry->get_into()->is_tangible())) { if (has_center()) { - // If a center is specified, we have to make sure the surface is - // more-or-less facing it. + // If a center is specified, we have to make sure the surface is more- + // or-less facing it. if (!entry->has_surface_point() || !entry->has_surface_normal()) { return; } @@ -87,14 +77,11 @@ add_entry(CollisionEntry *entry) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::end_group -// Access: Public, Virtual -// Description: Called by the CollisionTraverser at the completion of -// all collision detections for this traversal. It -// should do whatever finalization is required for the -// handler. -//////////////////////////////////////////////////////////////////// +/** + * Called by the CollisionTraverser at the completion of all collision + * detections for this traversal. It should do whatever finalization is + * required for the handler. + */ bool CollisionHandlerPhysical:: end_group() { bool result = handle_entries(); @@ -103,14 +90,11 @@ end_group() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::add_collider -// Access: Published -// Description: Adds a new collider to the list with a NodePath -// that will be updated with the collider's new -// position, or updates the existing collider with a new -// NodePath object. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new collider to the list with a NodePath that will be updated with + * the collider's new position, or updates the existing collider with a new + * NodePath object. + */ void CollisionHandlerPhysical:: add_collider(const NodePath &collider, const NodePath &target) { nassertv(!collider.is_empty() && collider.node()->is_collision_node()); @@ -118,19 +102,15 @@ add_collider(const NodePath &collider, const NodePath &target) { _colliders[collider].set_target(target); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::add_collider -// Access: Published -// Description: Adds a new collider to the list with a NodePath -// that will be updated with the collider's new -// position, or updates the existing collider with a new -// NodePath object. -// -// The indicated DriveInterface will also be updated -// with the target's new transform each frame. This -// method should be used when the target is directly -// controlled by a DriveInterface. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new collider to the list with a NodePath that will be updated with + * the collider's new position, or updates the existing collider with a new + * NodePath object. + * + * The indicated DriveInterface will also be updated with the target's new + * transform each frame. This method should be used when the target is + * directly controlled by a DriveInterface. + */ void CollisionHandlerPhysical:: add_collider(const NodePath &collider, const NodePath &target, DriveInterface *drive_interface) { @@ -139,12 +119,10 @@ add_collider(const NodePath &collider, const NodePath &target, _colliders[collider].set_target(target, drive_interface); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::remove_collider -// Access: Published -// Description: Removes the collider from the list of colliders that -// this handler knows about. -//////////////////////////////////////////////////////////////////// +/** + * Removes the collider from the list of colliders that this handler knows + * about. + */ bool CollisionHandlerPhysical:: remove_collider(const NodePath &collider) { Colliders::iterator ci = _colliders.find(collider); @@ -155,36 +133,28 @@ remove_collider(const NodePath &collider) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::has_collider -// Access: Published -// Description: Returns true if the handler knows about the indicated -// collider, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the handler knows about the indicated collider, false + * otherwise. + */ bool CollisionHandlerPhysical:: has_collider(const NodePath &target) const { Colliders::const_iterator ci = _colliders.find(target); return (ci != _colliders.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::clear_colliders -// Access: Published -// Description: Completely empties the list of colliders this handler -// knows about. -//////////////////////////////////////////////////////////////////// +/** + * Completely empties the list of colliders this handler knows about. + */ void CollisionHandlerPhysical:: clear_colliders() { _colliders.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPhysical::validate_target -// Access: Protected, Virtual -// Description: Called internally to validate the target passed to -// add_collider(). Returns true if acceptable, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to validate the target passed to add_collider(). Returns + * true if acceptable, false otherwise. + */ bool CollisionHandlerPhysical:: validate_target(const NodePath &target) { nassertr_always(!target.is_empty(), false); diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index 3feddfbcb1..cb3a340cdc 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerPhysical.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPhysical.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERPHYSICAL_H #define COLLISIONHANDLERPHYSICAL_H @@ -24,13 +23,11 @@ #include "pointerTo.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerPhysical -// Description : The abstract base class for a number of -// CollisionHandlers that have some physical effect on -// their moving bodies: they need to update the nodes' -// positions based on the effects of the collision. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for a number of CollisionHandlers that have some + * physical effect on their moving bodies: they need to update the nodes' + * positions based on the effects of the collision. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerPhysical : public CollisionHandlerEvent { public: CollisionHandlerPhysical(); @@ -67,7 +64,7 @@ protected: INLINE void set_target(const NodePath &target, DriveInterface *drive_interface = NULL); INLINE void updated_transform(); - + NodePath _target; PT(DriveInterface) _drive_interface; }; @@ -107,6 +104,3 @@ private: #include "collisionHandlerPhysical.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerPusher.I b/panda/src/collide/collisionHandlerPusher.I index fb0ab1cfc2..d103394c7e 100644 --- a/panda/src/collide/collisionHandlerPusher.I +++ b/panda/src/collide/collisionHandlerPusher.I @@ -1,33 +1,27 @@ -// Filename: collisionHandlerPusher.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPusher.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::set_horizontal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionHandlerPusher:: set_horizontal(bool flag) { _horizontal = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::get_horizontal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CollisionHandlerPusher:: get_horizontal() const { return _horizontal; diff --git a/panda/src/collide/collisionHandlerPusher.cxx b/panda/src/collide/collisionHandlerPusher.cxx index 3b4ac34068..4b1b60482a 100644 --- a/panda/src/collide/collisionHandlerPusher.cxx +++ b/panda/src/collide/collisionHandlerPusher.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerPusher.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPusher.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerPusher.h" #include "collisionNode.h" @@ -22,13 +21,11 @@ TypeHandle CollisionHandlerPusher::_type_handle; -//////////////////////////////////////////////////////////////////// -// Class : ShoveData -// Description : The ShoveData class is used within -// CollisionHandlerPusher::handle_entries(), to track -// multiple shoves onto a given collider. It's not -// exported outside this file. -//////////////////////////////////////////////////////////////////// +/** + * The ShoveData class is used within + * CollisionHandlerPusher::handle_entries(), to track multiple shoves onto a + * given collider. It's not exported outside this file. + */ class ShoveData { public: LVector3 _vector; @@ -37,36 +34,29 @@ public: CollisionEntry *_entry; }; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerPusher:: CollisionHandlerPusher() { _horizontal = pushers_horizontal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerPusher:: ~CollisionHandlerPusher() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::handle_entries -// Access: Protected, Virtual -// Description: Called by the parent class after all collisions have -// been detected, this manages the various collisions -// and moves around the nodes as necessary. -// -// The return value is normally true, but it may be -// false to indicate the CollisionTraverser should -// disable this handler from being called in the future. -//////////////////////////////////////////////////////////////////// +/** + * Called by the parent class after all collisions have been detected, this + * manages the various collisions and moves around the nodes as necessary. + * + * The return value is normally true, but it may be false to indicate the + * CollisionTraverser should disable this handler from being called in the + * future. + */ bool CollisionHandlerPusher:: handle_entries() { bool okflag = true; @@ -79,9 +69,8 @@ handle_entries() { Colliders::iterator ci; ci = _colliders.find(from_node_path); if (ci == _colliders.end()) { - // Hmm, someone added a CollisionNode to a traverser and gave - // it this CollisionHandler pointer--but they didn't tell us - // about the node. + // Hmm, someone added a CollisionNode to a traverser and gave it this + // CollisionHandler pointer--but they didn't tell us about the node. collide_cat.error() << "CollisionHandlerPusher doesn't know about " << from_node_path << ", disabling.\n"; @@ -89,13 +78,12 @@ handle_entries() { } else { ColliderDef &def = (*ci).second; { - // How to apply multiple shoves from different solids onto the - // same collider? One's first intuition is to vector sum all - // the shoves. However, this causes problems when two parallel - // walls shove on the collider, because we end up with a double - // shove. We hack around this by testing if two shove vectors - // share nearly the same direction, and if so, we keep only the - // longer of the two. + // How to apply multiple shoves from different solids onto the same + // collider? One's first intuition is to vector sum all the shoves. + // However, this causes problems when two parallel walls shove on the + // collider, because we end up with a double shove. We hack around + // this by testing if two shove vectors share nearly the same + // direction, and if so, we keep only the longer of the two. typedef epvector Shoves; Shoves shoves; @@ -124,9 +112,9 @@ handle_entries() { if (_horizontal) { normal[2] = 0.0f; } - // Just to be on the safe size, we normalize the normal - // vector, even though it really ought to be unit-length - // already (unless we just forced it horizontal, above). + // Just to be on the safe size, we normalize the normal vector, + // even though it really ought to be unit-length already (unless + // we just forced it horizontal, above). normal.normalize(); ShoveData sd; @@ -151,10 +139,9 @@ handle_entries() { if (!shoves.empty()) { // Now we look for two shoves that are largely in the same - // direction, so we can combine them into a single shove of - // the same magnitude; we also check for two shoves at 90 - // degrees, so we can detect whether we are hitting an inner - // or an outer corner. + // direction, so we can combine them into a single shove of the same + // magnitude; we also check for two shoves at 90 degrees, so we can + // detect whether we are hitting an inner or an outer corner. Shoves::iterator si; for (si = shoves.begin(); si != shoves.end(); ++si) { @@ -170,18 +157,18 @@ handle_entries() { } if (d > 0.9) { - // These two shoves are largely in the same direction; - // save the larger of the two. + // These two shoves are largely in the same direction; save + // the larger of the two. if (sd2._length < sd._length) { sd2._valid = false; } else { sd._valid = false; } } else { - // These two shoves are not in the same direction. - // If they are both from polygons that are a child - // of the same node, try to determine the shape of - // the corner (convex or concave). + // These two shoves are not in the same direction. If they + // are both from polygons that are a child of the same node, + // try to determine the shape of the corner (convex or + // concave). const CollisionSolid *s1 = sd._entry->get_into(); const CollisionSolid *s2 = sd2._entry->get_into(); if (s1 != (CollisionSolid *)NULL && @@ -194,23 +181,21 @@ handle_entries() { const CollisionPolygon *p2 = DCAST(CollisionPolygon, s2); if (p1->dist_to_plane(p2->get_collision_origin()) < 0 && p2->dist_to_plane(p1->get_collision_origin()) < 0) { - // Each polygon is behind the other one. That - // means we have a convex corner, and therefore - // we should discard one of the shoves (or the - // user will get stuck coming at a convex - // corner). + // Each polygon is behind the other one. That means we + // have a convex corner, and therefore we should discard + // one of the shoves (or the user will get stuck coming + // at a convex corner). if (collide_cat.is_debug()) { collide_cat.debug() << "Discarding shove from convex corner.\n"; } - // This time, unlike the case of two parallel - // walls above, we discard the larger of the two - // shoves, not the smaller. This is because as - // we slide off the convex corner, the wall we - // are sliding away from will get a bigger and - // bigger shove--and we need to keep ignoring - // the same wall as we slide. + // This time, unlike the case of two parallel walls + // above, we discard the larger of the two shoves, not + // the smaller. This is because as we slide off the + // convex corner, the wall we are sliding away from will + // get a bigger and bigger shove--and we need to keep + // ignoring the same wall as we slide. if (sd2._length < sd._length) { sd._valid = false; } else { @@ -249,8 +234,8 @@ handle_entries() { def._target.set_transform(trans->set_pos(pos)); def.updated_transform(); - // We call this to allow derived classes to do other - // fix-ups as they see fit: + // We call this to allow derived classes to do other fix-ups as they + // see fit: apply_net_shove(def, net_shove, force_normal); apply_linear_force(def, force_normal); } @@ -261,23 +246,19 @@ handle_entries() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::apply_net_shove -// Access: Protected, Virtual -// Description: This is an optional hook for derived classes to do -// some work with the ColliderDef and the force vector. -//////////////////////////////////////////////////////////////////// +/** + * This is an optional hook for derived classes to do some work with the + * ColliderDef and the force vector. + */ void CollisionHandlerPusher:: apply_net_shove(ColliderDef &def, const LVector3 &net_shove, const LVector3 &force_normal) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerPusher::apply_linear_force -// Access: Protected, Virtual -// Description: This is an optional hook for derived classes to do -// some work with the ColliderDef and the force vector. -//////////////////////////////////////////////////////////////////// +/** + * This is an optional hook for derived classes to do some work with the + * ColliderDef and the force vector. + */ void CollisionHandlerPusher:: apply_linear_force(ColliderDef &def, const LVector3 &force_normal) { } diff --git a/panda/src/collide/collisionHandlerPusher.h b/panda/src/collide/collisionHandlerPusher.h index 17630a5954..8f427ca4b2 100644 --- a/panda/src/collide/collisionHandlerPusher.h +++ b/panda/src/collide/collisionHandlerPusher.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerPusher.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerPusher.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERPUSHER_H #define COLLISIONHANDLERPUSHER_H @@ -19,13 +18,11 @@ #include "collisionHandlerPhysical.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerPusher -// Description : A specialized kind of CollisionHandler that simply -// pushes back on things that attempt to move into solid -// walls. This is the simplest kind of "real-world" -// collisions you can have. -//////////////////////////////////////////////////////////////////// +/** + * A specialized kind of CollisionHandler that simply pushes back on things + * that attempt to move into solid walls. This is the simplest kind of "real- + * world" collisions you can have. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerPusher : public CollisionHandlerPhysical { PUBLISHED: CollisionHandlerPusher(); @@ -68,6 +65,3 @@ private: #include "collisionHandlerPusher.I" #endif - - - diff --git a/panda/src/collide/collisionHandlerQueue.cxx b/panda/src/collide/collisionHandlerQueue.cxx index 1a1bba4b6c..9c8909f3bc 100644 --- a/panda/src/collide/collisionHandlerQueue.cxx +++ b/panda/src/collide/collisionHandlerQueue.cxx @@ -1,16 +1,15 @@ -// Filename: collisionHandlerQueue.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerQueue.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionHandlerQueue.h" #include "config_collide.h" @@ -36,53 +35,43 @@ public: PN_stdfloat _dist2; }; -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionHandlerQueue:: CollisionHandlerQueue() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::begin_group -// Access: Published, Virtual -// Description: Will be called by the CollisionTraverser before a new -// traversal is begun. It instructs the handler to -// reset itself in preparation for a number of -// CollisionEntries to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Will be called by the CollisionTraverser before a new traversal is begun. + * It instructs the handler to reset itself in preparation for a number of + * CollisionEntries to be sent. + */ void CollisionHandlerQueue:: begin_group() { _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::add_entry -// Access: Published, Virtual -// Description: Called between a begin_group() .. end_group() -// sequence for each collision that is detected. -//////////////////////////////////////////////////////////////////// +/** + * Called between a begin_group() .. end_group() sequence for each collision + * that is detected. + */ void CollisionHandlerQueue:: add_entry(CollisionEntry *entry) { nassertv(entry != (CollisionEntry *)NULL); _entries.push_back(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::sort_entries -// Access: Published -// Description: Sorts all the detected collisions front-to-back by -// from_intersection_point() so that those intersection -// points closest to the collider's origin (e.g., the -// center of the CollisionSphere, or the point_a of a -// CollisionSegment) appear first. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the detected collisions front-to-back by + * from_intersection_point() so that those intersection points closest to the + * collider's origin (e.g., the center of the CollisionSphere, or the point_a + * of a CollisionSegment) appear first. + */ void CollisionHandlerQueue:: sort_entries() { - // Build up a temporary vector of entries so we can sort the - // pointers. This uses the class defined above. + // Build up a temporary vector of entries so we can sort the pointers. This + // uses the class defined above. typedef pvector Sorter; Sorter sorter; sorter.reserve(_entries.size()); @@ -96,8 +85,8 @@ sort_entries() { nassertv(sorter.size() == _entries.size()); // Now that they're sorted, get them back. We do this in two steps, - // building up a temporary vector first, so we don't accidentally - // delete all the entries when the pointers go away. + // building up a temporary vector first, so we don't accidentally delete all + // the entries when the pointers go away. Entries sorted_entries; sorted_entries.reserve(sorter.size()); Sorter::const_iterator si; @@ -108,53 +97,42 @@ sort_entries() { _entries.swap(sorted_entries); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::clear_entries -// Access: Published -// Description: Removes all the entries from the queue. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the entries from the queue. + */ void CollisionHandlerQueue:: clear_entries() { _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::get_num_entries -// Access: Published -// Description: Returns the number of CollisionEntries detected last -// pass. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of CollisionEntries detected last pass. + */ int CollisionHandlerQueue:: get_num_entries() const { return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::get_entry -// Access: Published -// Description: Returns the nth CollisionEntry detected last pass. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth CollisionEntry detected last pass. + */ CollisionEntry *CollisionHandlerQueue:: get_entry(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), NULL); return _entries[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionHandlerQueue:: output(ostream &out) const { out << "CollisionHandlerQueue, " << _entries.size() << " entries"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerQueue::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionHandlerQueue:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/panda/src/collide/collisionHandlerQueue.h b/panda/src/collide/collisionHandlerQueue.h index cd7160cbba..397aa11809 100644 --- a/panda/src/collide/collisionHandlerQueue.h +++ b/panda/src/collide/collisionHandlerQueue.h @@ -1,16 +1,15 @@ -// Filename: collisionHandlerQueue.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionHandlerQueue.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONHANDLERQUEUE_H #define COLLISIONHANDLERQUEUE_H @@ -20,15 +19,12 @@ #include "collisionHandler.h" #include "collisionEntry.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionHandlerQueue -// Description : A special kind of CollisionHandler that does nothing -// except remember the CollisionEntries detected the -// last pass. This set of CollisionEntries may then be -// queried by the calling function. It's primarily -// useful when a simple intersection test is being made, -// e.g. for picking from the window. -//////////////////////////////////////////////////////////////////// +/** + * A special kind of CollisionHandler that does nothing except remember the + * CollisionEntries detected the last pass. This set of CollisionEntries may + * then be queried by the calling function. It's primarily useful when a + * simple intersection test is being made, e.g. for picking from the window. + */ class EXPCL_PANDA_COLLIDE CollisionHandlerQueue : public CollisionHandler { PUBLISHED: CollisionHandlerQueue(); @@ -76,6 +72,3 @@ INLINE ostream &operator << (ostream &out, const CollisionHandlerQueue &chq) { } #endif - - - diff --git a/panda/src/collide/collisionInvSphere.I b/panda/src/collide/collisionInvSphere.I index 12823f352a..90ae87038a 100644 --- a/panda/src/collide/collisionInvSphere.I +++ b/panda/src/collide/collisionInvSphere.I @@ -1,55 +1,44 @@ -// Filename: collisionInvSphere.I -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionInvSphere.I + * @author drose + * @date 2005-01-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionInvSphere:: CollisionInvSphere(const LPoint3 ¢er, PN_stdfloat radius) : CollisionSphere(center, radius) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionInvSphere:: CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) : CollisionSphere(cx, cy, cz, radius) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::Default constructor -// Access: Protected -// Description: Creates an invalid sphere. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid sphere. Only used when reading from a bam file. + */ INLINE CollisionInvSphere:: CollisionInvSphere() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionInvSphere:: CollisionInvSphere(const CollisionInvSphere ©) : CollisionSphere(copy) diff --git a/panda/src/collide/collisionInvSphere.cxx b/panda/src/collide/collisionInvSphere.cxx index 893d950d48..913ef32589 100644 --- a/panda/src/collide/collisionInvSphere.cxx +++ b/panda/src/collide/collisionInvSphere.cxx @@ -1,16 +1,15 @@ -// Filename: collisionInvSphere.cxx -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionInvSphere.cxx + * @author drose + * @date 2005-01-05 + */ #include "collisionInvSphere.h" #include "collisionSphere.h" @@ -34,66 +33,52 @@ PStatCollector CollisionInvSphere::_volume_pcollector("Collision Volumes:Collisi PStatCollector CollisionInvSphere::_test_pcollector("Collision Tests:CollisionInvSphere"); TypeHandle CollisionInvSphere::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionInvSphere:: make_copy() { return new CollisionInvSphere(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionInvSphere:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionInvSphere:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionInvSphere:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionInvSphere:: output(ostream &out) const { out << "invsphere, c (" << get_center() << "), r " << get_radius(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionInvSphere:: compute_internal_bounds() const { // An inverse sphere always has an infinite bounding volume, since @@ -101,11 +86,9 @@ compute_internal_bounds() const { return new OmniBoundingVolume(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; @@ -138,9 +121,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 surface_normal; PN_stdfloat vec_length = vec.length(); if (IS_NEARLY_ZERO(vec_length)) { - // If we don't have a collision normal (e.g. the centers are - // exactly coincident), then make up an arbitrary normal--any one - // is as good as any other. + // If we don't have a collision normal (e.g. the centers are exactly + // coincident), then make up an arbitrary normal--any one is as good as + // any other. surface_normal.set(1.0, 0.0, 0.0); } else { surface_normal = vec / -vec_length; @@ -155,11 +138,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::test_intersection_from_line -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; @@ -172,8 +153,8 @@ test_intersection_from_line(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { - // The line is in the middle of space, and therefore intersects - // the sphere. + // The line is in the middle of space, and therefore intersects the + // sphere. t1 = t2 = 0.0; } @@ -198,11 +179,9 @@ test_intersection_from_line(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::test_intersection_from_ray -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -215,8 +194,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_origin, from_direction, 0.0f)) { - // The ray is in the middle of space, and therefore intersects - // the sphere. + // The ray is in the middle of space, and therefore intersects the sphere. t1 = t2 = 0.0; } @@ -244,11 +222,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::test_intersection_from_segment -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionInvSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; @@ -262,11 +238,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { double t1, t2; if (!intersects_line(t1, t2, from_a, from_direction, 0.0f)) { - // The segment is in the middle of space, and therefore intersects - // the sphere. + // The segment is in the middle of space, and therefore intersects the + // sphere. t1 = t2 = 0.0; } - + double t; if (t2 <= 0.0) { // The segment is completely below the shell. @@ -285,9 +261,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { t = max(t1, 0.0); } else { - // Neither edge of the segment intersects the shell. It follows - // that both intersection points are within the hollow center of - // the sphere; therefore, there is no intersection. + // Neither edge of the segment intersects the shell. It follows that both + // intersection points are within the hollow center of the sphere; + // therefore, there is no intersection. return NULL; } @@ -312,12 +288,10 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionInvSphere:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -332,7 +306,7 @@ fill_viz_geom() { ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); for (int sl = 0; sl < num_slices; ++sl) { PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; @@ -344,43 +318,37 @@ fill_viz_geom() { vertex.add_data3(compute_point(latitude, longitude0)); } vertex.add_data3(compute_point(1.0, longitude0)); - + strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); } - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + _viz_geom->add_geom(geom, get_solid_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionInvSphere object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionInvSphere object + */ void CollisionInvSphere:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CollisionInvSphere); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionInvSphere:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSphere::write_datagram(manager, me); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::make_CollisionInvSphere -// Access: Protected -// Description: Factory method to generate a CollisionInvSphere object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionInvSphere object + */ TypedWritable *CollisionInvSphere:: make_CollisionInvSphere(const FactoryParams ¶ms) { CollisionInvSphere *me = new CollisionInvSphere; @@ -392,16 +360,12 @@ make_CollisionInvSphere(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionInvSphere::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionInvSphere:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSphere::fillin(scan, manager); } - diff --git a/panda/src/collide/collisionInvSphere.h b/panda/src/collide/collisionInvSphere.h index d358dccc40..bdf08f9009 100644 --- a/panda/src/collide/collisionInvSphere.h +++ b/panda/src/collide/collisionInvSphere.h @@ -1,16 +1,15 @@ -// Filename: collisionInvSphere.h -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionInvSphere.h + * @author drose + * @date 2005-01-05 + */ #ifndef COLLISIONINVSPHERE_H #define COLLISIONINVSPHERE_H @@ -19,15 +18,12 @@ #include "collisionSphere.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionInvSphere -// Description : An inverted sphere: this is a sphere whose collision -// surface is the inside surface of the sphere. -// Everything outside the sphere is solid matter; -// everything inside is empty space. Useful for -// constraining objects to remain within a spherical -// perimeter. -//////////////////////////////////////////////////////////////////// +/** + * An inverted sphere: this is a sphere whose collision surface is the inside + * surface of the sphere. Everything outside the sphere is solid matter; + * everything inside is empty space. Useful for constraining objects to + * remain within a spherical perimeter. + */ class EXPCL_PANDA_COLLIDE CollisionInvSphere : public CollisionSphere { PUBLISHED: INLINE CollisionInvSphere(const LPoint3 ¢er, PN_stdfloat radius); @@ -95,5 +91,3 @@ private: #include "collisionInvSphere.I" #endif - - diff --git a/panda/src/collide/collisionLevelState.I b/panda/src/collide/collisionLevelState.I index 6ce77c24ed..5ac7cb9063 100644 --- a/panda/src/collide/collisionLevelState.I +++ b/panda/src/collide/collisionLevelState.I @@ -1,23 +1,20 @@ -// Filename: collisionLevelState.I -// Created by: drose (05Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelState.I + * @author drose + * @date 2007-04-05 + */ #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CollisionLevelState:: CollisionLevelState(const NodePath &node_path) : @@ -28,12 +25,9 @@ CollisionLevelState(const NodePath &node_path) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::Constructor -// Access: Public -// Description: This constructor goes to the next child node in the -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * This constructor goes to the next child node in the traversal. + */ template INLINE CollisionLevelState:: CollisionLevelState(const CollisionLevelState &parent, PandaNode *child) : @@ -44,11 +38,9 @@ CollisionLevelState(const CollisionLevelState &parent, PandaNode *chil #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CollisionLevelState:: CollisionLevelState(const CollisionLevelState ©) : @@ -59,11 +51,9 @@ CollisionLevelState(const CollisionLevelState ©) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CollisionLevelState:: operator = (const CollisionLevelState ©) { @@ -73,11 +63,9 @@ operator = (const CollisionLevelState ©) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CollisionLevelState:: clear() { @@ -87,12 +75,10 @@ clear() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::prepare_collider -// Access: Public -// Description: Adds the indicated Collider to the set of Colliders -// in the current level state. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated Collider to the set of Colliders in the current level + * state. + */ template INLINE void CollisionLevelState:: prepare_collider(const ColliderDef &def, const NodePath &root) { @@ -106,16 +92,12 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::any_in_bounds -// Access: Public -// Description: Checks the bounding volume of the current node -// against each of our colliders. Eliminates from the -// current collider list any that are outside of the -// bounding volume. Returns true if any colliders -// remain, false if all of them fall outside this node's -// bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Checks the bounding volume of the current node against each of our + * colliders. Eliminates from the current collider list any that are outside + * of the bounding volume. Returns true if any colliders remain, false if all + * of them fall outside this node's bounding volume. + */ template bool CollisionLevelState:: any_in_bounds() { @@ -140,9 +122,8 @@ any_in_bounds() { CollisionNode *cnode = get_collider_node(c); bool is_in = false; - // Don't even bother testing the bounding volume if there are - // no collide bits in common between our collider and this - // node. + // Don't even bother testing the bounding volume if there are no + // collide bits in common between our collider and this node. CollideMask from_mask = cnode->get_from_collide_mask() & _include_mask; if (!(from_mask & node()->get_net_collide_mask()).is_zero()) { // Also don't test a node with itself, or with any of its @@ -157,17 +138,17 @@ any_in_bounds() { #endif // NDEBUG } else { - // There are bits in common, and it's not the same - // instance, so go ahead and try the bounding volume. + // There are bits in common, and it's not the same instance, so go + // ahead and try the bounding volume. const GeometricBoundingVolume *col_gbv = get_local_bound(c); is_in = true; // If there's no bounding volume, we're implicitly in. - + if (col_gbv != (GeometricBoundingVolume *)NULL) { is_in = (node_gbv->contains(col_gbv) != 0); _node_volume_pcollector.add_level(1); - + #ifndef NDEBUG if (collide_cat.is_spam()) { indent(collide_cat.spam(false), indent_level) @@ -180,8 +161,8 @@ any_in_bounds() { } if (!is_in) { - // This collider cannot intersect with any geometry at - // this node or below. + // This collider cannot intersect with any geometry at this node or + // below. omit_collider(c); } } @@ -224,29 +205,25 @@ any_in_bounds() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::apply_transform -// Access: Public -// Description: Applies the inverse transform from the current node, -// if any, onto all the colliders in the level state. -// -// Returns true if the inverse transform is valid, or -// false if it is not valid (e.g. the transform has a -// scale to zero). If the inverse transform is not -// valid, the caller should not visit this node. -//////////////////////////////////////////////////////////////////// +/** + * Applies the inverse transform from the current node, if any, onto all the + * colliders in the level state. + * + * Returns true if the inverse transform is valid, or false if it is not valid + * (e.g. the transform has a scale to zero). If the inverse transform is not + * valid, the caller should not visit this node. + */ template bool CollisionLevelState:: apply_transform() { - // The "parent" bounds list remembers the bounds list of the - // previous node. + // The "parent" bounds list remembers the bounds list of the previous node. _parent_bounds = _local_bounds; if (node()->is_final()) { // If this node has a "final" bounds, we blank out all of the from - // bounding volumes, since we've already tested against this - // node's into bounds, and there's no need to test any further - // bounding volumes at this node level or below. + // bounding volumes, since we've already tested against this node's into + // bounds, and there's no need to test any further bounding volumes at + // this node level or below. BoundingVolumes new_bounds; int num_colliders = get_num_colliders(); @@ -254,16 +231,15 @@ apply_transform() { for (int c = 0; c < num_colliders; c++) { new_bounds.push_back((GeometricBoundingVolume *)NULL); } - + _local_bounds = new_bounds; } else { // Otherwise, in the usual case, the bounds tests will continue. - // Recompute the bounds list of this node (if we have a - // transform). + // Recompute the bounds list of this node (if we have a transform). const TransformState *node_transform = node()->get_transform(); if (!node_transform->is_identity()) { - CPT(TransformState) inv_transform = + CPT(TransformState) inv_transform = node_transform->invert_compose(TransformState::make_identity()); if (!inv_transform->has_mat()) { // No inverse. @@ -271,10 +247,10 @@ apply_transform() { } const LMatrix4 &mat = inv_transform->get_mat(); - + // Now build the new bounding volumes list. BoundingVolumes new_bounds; - + int num_colliders = get_num_colliders(); new_bounds.reserve(num_colliders); for (int c = 0; c < num_colliders; c++) { @@ -283,15 +259,15 @@ apply_transform() { new_bounds.push_back((GeometricBoundingVolume *)NULL); } else { const GeometricBoundingVolume *old_bound = get_local_bound(c); - GeometricBoundingVolume *new_bound = + GeometricBoundingVolume *new_bound = DCAST(GeometricBoundingVolume, old_bound->make_copy()); new_bound->xform(mat); new_bounds.push_back(new_bound); } } - + _local_bounds = new_bounds; - } + } } return true; @@ -299,13 +275,10 @@ apply_transform() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::has_max_colliders -// Access: Public, Static -// Description: Returns true if there is any the maximum number of -// colliders that may be added to the -// CollisionLevelStateBase at any one time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is any the maximum number of colliders that may be + * added to the CollisionLevelStateBase at any one time. + */ template INLINE bool CollisionLevelState:: has_max_colliders() { @@ -314,12 +287,10 @@ has_max_colliders() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::get_max_colliders -// Access: Public, Static -// Description: Returns the maximum number of colliders that may be -// added to the CollisionLevelStateBase at any one time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of colliders that may be added to the + * CollisionLevelStateBase at any one time. + */ template INLINE int CollisionLevelState:: get_max_colliders() { @@ -328,12 +299,10 @@ get_max_colliders() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::has_collider -// Access: Public -// Description: Returns true if the nth collider in the LevelState is -// still part of the level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth collider in the LevelState is still part of the + * level. + */ template INLINE bool CollisionLevelState:: has_collider(int n) const { @@ -343,11 +312,9 @@ has_collider(int n) const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::has_any_collider -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool CollisionLevelState:: has_any_collider() const { @@ -356,11 +323,9 @@ has_any_collider() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelState::omit_collider -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CollisionLevelState:: omit_collider(int n) { diff --git a/panda/src/collide/collisionLevelState.cxx b/panda/src/collide/collisionLevelState.cxx index d435c12919..6518b4ef15 100644 --- a/panda/src/collide/collisionLevelState.cxx +++ b/panda/src/collide/collisionLevelState.cxx @@ -1,15 +1,14 @@ -// Filename: collisionLevelState.cxx -// Created by: drose (05Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelState.cxx + * @author drose + * @date 2007-04-05 + */ #include "collisionLevelState.h" diff --git a/panda/src/collide/collisionLevelState.h b/panda/src/collide/collisionLevelState.h index 89cf9128de..f06a025f1e 100644 --- a/panda/src/collide/collisionLevelState.h +++ b/panda/src/collide/collisionLevelState.h @@ -1,16 +1,15 @@ -// Filename: collisionLevelState.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelState.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONLEVELSTATE_H #define COLLISIONLEVELSTATE_H @@ -22,25 +21,22 @@ #include "bitMask.h" #include "doubleBitMask.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionLevelState -// Description : This is the state information the -// CollisionTraverser retains for each level during -// traversal. -// -// This is the template class that specifies the -// CurrentMask type: the type of bitmask that is used to -// keep track of the set of active colliders for each -// node. -//////////////////////////////////////////////////////////////////// +/** + * This is the state information the CollisionTraverser retains for each level + * during traversal. + * + * This is the template class that specifies the CurrentMask type: the type of + * bitmask that is used to keep track of the set of active colliders for each + * node. + */ template class CollisionLevelState : public CollisionLevelStateBase { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER INLINE CollisionLevelState(const NodePath &node_path); - INLINE CollisionLevelState(const CollisionLevelState &parent, + INLINE CollisionLevelState(const CollisionLevelState &parent, PandaNode *child); INLINE CollisionLevelState(const CollisionLevelState ©); INLINE void operator = (const CollisionLevelState ©); @@ -60,11 +56,11 @@ public: INLINE void omit_collider(int n); private: - // CurrentMask here is a locally-defined value that simply serves - // to keep track of the colliders that are still interested in the - // current node. Don't confuse it with CollideMask, which is a set - // of user-defined bits that specify which CollisionSolids may - // possibly intersect with each other. + // CurrentMask here is a locally-defined value that simply serves to keep + // track of the colliders that are still interested in the current node. + // Don't confuse it with CollideMask, which is a set of user-defined bits + // that specify which CollisionSolids may possibly intersect with each + // other. typedef MaskType CurrentMask; CurrentMask _current; @@ -74,14 +70,12 @@ private: #include "collisionLevelState.I" -// Now instantiate a handful of implementations of CollisionLevelState: -// one that uses a word-at-a-time bitmask to track the active -// colliders, and a couple that use more words at a time. +// Now instantiate a handful of implementations of CollisionLevelState: one +// that uses a word-at-a-time bitmask to track the active colliders, and a +// couple that use more words at a time. typedef CollisionLevelState CollisionLevelStateSingle; typedef CollisionLevelState CollisionLevelStateDouble; typedef CollisionLevelState CollisionLevelStateQuad; #endif - - diff --git a/panda/src/collide/collisionLevelStateBase.I b/panda/src/collide/collisionLevelStateBase.I index 21d3b3ed74..2f2b366fb9 100644 --- a/panda/src/collide/collisionLevelStateBase.I +++ b/panda/src/collide/collisionLevelStateBase.I @@ -1,23 +1,19 @@ -// Filename: collisionLevelStateBase.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelStateBase.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionLevelStateBase:: CollisionLevelStateBase(const NodePath &node_path) : _node_path(node_path), @@ -26,12 +22,9 @@ CollisionLevelStateBase(const NodePath &node_path) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::Constructor -// Access: Public -// Description: This constructor goes to the next child node in the -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * This constructor goes to the next child node in the traversal. + */ INLINE CollisionLevelStateBase:: CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child) : _node_path(parent._node_path, child), @@ -41,11 +34,9 @@ CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionLevelStateBase:: CollisionLevelStateBase(const CollisionLevelStateBase ©) : _node_path(copy._node_path), @@ -56,11 +47,9 @@ CollisionLevelStateBase(const CollisionLevelStateBase ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionLevelStateBase:: operator = (const CollisionLevelStateBase ©) { _node_path = copy._node_path; @@ -70,43 +59,33 @@ operator = (const CollisionLevelStateBase ©) { _parent_bounds = copy._parent_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_node_path -// Access: Public -// Description: Returns the NodePath representing the node instance -// we have traversed to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath representing the node instance we have traversed to. + */ INLINE NodePath CollisionLevelStateBase:: get_node_path() const { return _node_path.get_node_path(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::node -// Access: Public -// Description: Returns the PandaNode pointer of the node we have -// traversed to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PandaNode pointer of the node we have traversed to. + */ INLINE PandaNode *CollisionLevelStateBase:: node() const { return _node_path.node(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_num_colliders -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int CollisionLevelStateBase:: get_num_colliders() const { return _colliders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_collider -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const CollisionSolid *CollisionLevelStateBase:: get_collider(int n) const { nassertr(n >= 0 && n < (int)_colliders.size(), NULL); @@ -114,11 +93,9 @@ get_collider(int n) const { return _colliders[n]._collider; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_collider_node -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionNode *CollisionLevelStateBase:: get_collider_node(int n) const { nassertr(n >= 0 && n < (int)_colliders.size(), NULL); @@ -126,11 +103,9 @@ get_collider_node(int n) const { return _colliders[n]._node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_collider_node_path -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePath CollisionLevelStateBase:: get_collider_node_path(int n) const { nassertr(n >= 0 && n < (int)_colliders.size(), NodePath::fail()); @@ -138,37 +113,28 @@ get_collider_node_path(int n) const { return _colliders[n]._node_path; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_local_bound -// Access: Public -// Description: Returns the bounding volume of the indicated -// collider, transformed into the current node's -// transform space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume of the indicated collider, transformed into the + * current node's transform space. + */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_local_bound(int n) const { nassertr(n >= 0 && n < (int)_colliders.size(), NULL); nassertr(n >= 0 && n < (int)_local_bounds.size(), NULL); - // For whatever reason, the Intel compiler can't figure this line - // out. - //return _local_bounds[n]; + // For whatever reason, the Intel compiler can't figure this line out. + // return _local_bounds[n]; // But it can figure out this equivalent line. return *(_local_bounds + n); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_parent_bound -// Access: Public -// Description: Returns the bounding volume of the indicated -// collider, transformed into the previous node's -// transform space, but not transformed by the current -// node's transform. This is appropriate for testing -// against the bounding volume of the current node -// (which does not have its own transform applied to -// it). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume of the indicated collider, transformed into the + * previous node's transform space, but not transformed by the current node's + * transform. This is appropriate for testing against the bounding volume of + * the current node (which does not have its own transform applied to it). + */ INLINE const GeometricBoundingVolume *CollisionLevelStateBase:: get_parent_bound(int n) const { nassertr(n >= 0 && n < (int)_colliders.size(), NULL); @@ -178,34 +144,26 @@ get_parent_bound(int n) const { return *(_parent_bounds + n); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::set_include_mask -// Access: Public -// Description: Specifies the mask that is applied to the into -// CollideMask of nodes in the scene graph before -// testing for bits in common with the from CollideMask -// of colliders. This is normally all bits on, but you -// may set it to some other mask to restrict certain -// bits from consideration. -// -// This is used by the CollisionTraverser to restrict -// collision with geometry except under the lowest level -// of LOD. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the mask that is applied to the into CollideMask of nodes in the + * scene graph before testing for bits in common with the from CollideMask of + * colliders. This is normally all bits on, but you may set it to some other + * mask to restrict certain bits from consideration. + * + * This is used by the CollisionTraverser to restrict collision with geometry + * except under the lowest level of LOD. + */ INLINE void CollisionLevelStateBase:: set_include_mask(CollideMask include_mask) { _include_mask = include_mask; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::get_include_mask -// Access: Public -// Description: Returns the mask that is applied to the into -// CollideMask of nodes in the scene graph before -// testing for bits in common with the from CollideMask -// of colliders. See set_include_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the mask that is applied to the into CollideMask of nodes in the + * scene graph before testing for bits in common with the from CollideMask of + * colliders. See set_include_mask(). + */ INLINE CollideMask CollisionLevelStateBase:: get_include_mask() const { return _include_mask; diff --git a/panda/src/collide/collisionLevelStateBase.cxx b/panda/src/collide/collisionLevelStateBase.cxx index 7561c80e43..c66f58e8fc 100644 --- a/panda/src/collide/collisionLevelStateBase.cxx +++ b/panda/src/collide/collisionLevelStateBase.cxx @@ -1,16 +1,15 @@ -// Filename: collisionLevelStateBase.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelStateBase.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionLevelStateBase.h" #include "collisionSolid.h" @@ -22,11 +21,9 @@ PStatCollector CollisionLevelStateBase::_node_volume_pcollector("Collision Volum TypeHandle CollisionLevelStateBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionLevelStateBase:: clear() { _colliders.clear(); @@ -34,24 +31,20 @@ clear() { _parent_bounds.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::reserve -// Access: Public -// Description: Indicates an intention to add the indicated number of -// colliders to the level state. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an intention to add the indicated number of colliders to the + * level state. + */ void CollisionLevelStateBase:: reserve(int num_colliders) { _colliders.reserve(num_colliders); _local_bounds.reserve(num_colliders); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLevelStateBase::prepare_collider -// Access: Public -// Description: Adds the indicated Collider to the set of Colliders -// in the current level state. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated Collider to the set of Colliders in the current level + * state. + */ void CollisionLevelStateBase:: prepare_collider(const ColliderDef &def, const NodePath &root) { _colliders.push_back(def); @@ -61,32 +54,30 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { if (!bv->is_of_type(GeometricBoundingVolume::get_class_type())) { _local_bounds.push_back((GeometricBoundingVolume *)NULL); } else { - // We can use a plain pointer, rather than a PT() here, because we - // know we are going to save the volume in the vector, below. + // We can use a plain pointer, rather than a PT() here, because we know we + // are going to save the volume in the vector, below. GeometricBoundingVolume *gbv; DCAST_INTO_V(gbv, bv->make_copy()); - // TODO: we need to make this logic work in the new relative - // world. The bounding volume should be extended by the object's - // motion relative to each object it is considering a collision - // with. That makes things complicated! + // TODO: we need to make this logic work in the new relative world. The + // bounding volume should be extended by the object's motion relative to + // each object it is considering a collision with. That makes things + // complicated! if (bv->as_bounding_sphere()) { LPoint3 pos_delta = def._node_path.get_pos_delta(root); - - //LVector3 cap(pos_delta); - //if(cap.length()>fluid_cap_amount) { - // pos_delta=LPoint3(cap/cap.length())*fluid_cap_amount; - //} + + // LVector3 cap(pos_delta); if(cap.length()>fluid_cap_amount) { + // pos_delta=LPoint3(capcap.length())*fluid_cap_amount; } if (pos_delta != LVector3::zero()) { - // If the node has a delta, we have to include the starting - // position in the volume as well. We only do this for bounding - // spheres, since (a) other kinds of volumes may not extend so - // well, and (b) we've only implemented fluid-motion detection - // for CollisionSpheres anyway. + // If the node has a delta, we have to include the starting position + // in the volume as well. We only do this for bounding spheres, since + // (a) other kinds of volumes may not extend so well, and (b) we've + // only implemented fluid-motion detection for CollisionSpheres + // anyway. LMatrix4 inv_trans = LMatrix4::translate_mat(-pos_delta); PT(GeometricBoundingVolume) gbv_prev; gbv_prev = DCAST(GeometricBoundingVolume, bv->make_copy()); - + gbv_prev->xform(inv_trans); gbv->extend_by(gbv_prev); } @@ -96,6 +87,6 @@ prepare_collider(const ColliderDef &def, const NodePath &root) { gbv->xform(rel_transform->get_mat()); _local_bounds.push_back(gbv); } - + _parent_bounds = _local_bounds; } diff --git a/panda/src/collide/collisionLevelStateBase.h b/panda/src/collide/collisionLevelStateBase.h index 9dc773bcc9..bde70562c2 100644 --- a/panda/src/collide/collisionLevelStateBase.h +++ b/panda/src/collide/collisionLevelStateBase.h @@ -1,16 +1,15 @@ -// Filename: collisionLevelStateBase.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLevelStateBase.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONLEVELSTATEBASE_H #define COLLISIONLEVELSTATEBASE_H @@ -34,16 +33,13 @@ class CollisionSolid; class CollisionNode; -//////////////////////////////////////////////////////////////////// -// Class : CollisionLevelStateBase -// Description : This is the state information the -// CollisionTraverser retains for each level during -// traversal. -// -// The CollisionLevelStateBase is the non-template base -// class. The template version further specifies this -// on CurrentMask type. -//////////////////////////////////////////////////////////////////// +/** + * This is the state information the CollisionTraverser retains for each level + * during traversal. + * + * The CollisionLevelStateBase is the non-template base class. The template + * version further specifies this on CurrentMask type. + */ class CollisionLevelStateBase { public: class ColliderDef { @@ -54,7 +50,7 @@ public: }; INLINE CollisionLevelStateBase(const NodePath &node_path); - INLINE CollisionLevelStateBase(const CollisionLevelStateBase &parent, + INLINE CollisionLevelStateBase(const CollisionLevelStateBase &parent, PandaNode *child); INLINE CollisionLevelStateBase(const CollisionLevelStateBase ©); INLINE void operator = (const CollisionLevelStateBase ©); @@ -62,7 +58,7 @@ public: void clear(); void reserve(int num_colliders); void prepare_collider(const ColliderDef &def, const NodePath &root); - + INLINE NodePath get_node_path() const; INLINE PandaNode *node() const; @@ -107,5 +103,3 @@ private: #include "collisionLevelStateBase.I" #endif - - diff --git a/panda/src/collide/collisionLine.I b/panda/src/collide/collisionLine.I index d07309629c..af9e5974c5 100644 --- a/panda/src/collide/collisionLine.I +++ b/panda/src/collide/collisionLine.I @@ -1,46 +1,37 @@ -// Filename: collisionLine.I -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLine.I + * @author drose + * @date 2005-01-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::Default Constructor -// Access: Public -// Description: Creates an invalid line. This isn't terribly useful; -// it's expected that the user will subsequently adjust -// the line via set_origin()/set_direction() or -// set_from_lens(). -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid line. This isn't terribly useful; it's expected that + * the user will subsequently adjust the line via set_origin()/set_direction() + * or set_from_lens(). + */ INLINE CollisionLine:: CollisionLine() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionLine:: CollisionLine(const LPoint3 &origin, const LVector3 &direction) : CollisionRay(origin, direction) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionLine:: CollisionLine(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz) : @@ -48,11 +39,9 @@ CollisionLine(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionLine:: CollisionLine(const CollisionLine ©) : CollisionRay(copy) diff --git a/panda/src/collide/collisionLine.cxx b/panda/src/collide/collisionLine.cxx index 15ef5717fa..5e98087145 100644 --- a/panda/src/collide/collisionLine.cxx +++ b/panda/src/collide/collisionLine.cxx @@ -1,16 +1,15 @@ -// Filename: collisionLine.cxx -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLine.cxx + * @author drose + * @date 2005-01-05 + */ #include "collisionLine.h" #include "collisionHandler.h" @@ -32,42 +31,34 @@ TypeHandle CollisionLine::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionLine:: make_copy() { return new CollisionLine(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionLine:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_line(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionLine:: output(ostream &out) const { out << "line, o (" << get_origin() << "), d (" << get_direction() << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionLine:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -83,56 +74,48 @@ fill_viz_geom() { Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points - 0.5) * 2.0; vertex.add_data3(get_origin() + t * scale * get_direction()); - + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 1.0f) + fabs(t) * LColor(0.0f, 0.0f, 0.0f, -1.0f)); } - + PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); line->add_next_vertices(num_points); line->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(line); - + _viz_geom->add_geom(geom, get_other_viz_state()); _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionLine. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CollisionLine. + */ void CollisionLine:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CollisionLine:: write_datagram(BamWriter *manager, Datagram &dg) { CollisionRay::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionLine is encountered -// in the Bam file. It should create the CollisionLine -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CollisionLine is encountered in the Bam file. It should create the + * CollisionLine and extract its information from the file. + */ TypedWritable *CollisionLine:: make_from_bam(const FactoryParams ¶ms) { CollisionLine *node = new CollisionLine(); @@ -145,13 +128,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionLine::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionLine. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CollisionLine. + */ void CollisionLine:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionRay::fillin(scan, manager); diff --git a/panda/src/collide/collisionLine.h b/panda/src/collide/collisionLine.h index 06fc60473f..7d08521ef4 100644 --- a/panda/src/collide/collisionLine.h +++ b/panda/src/collide/collisionLine.h @@ -1,16 +1,15 @@ -// Filename: collisionLine.h -// Created by: drose (05Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionLine.h + * @author drose + * @date 2005-01-05 + */ #ifndef COLLISIONLINE_H #define COLLISIONLINE_H @@ -19,12 +18,10 @@ #include "collisionRay.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionLine -// Description : An infinite line, similar to a CollisionRay, except -// that it extends in both directions. It is, however, -// directional. -//////////////////////////////////////////////////////////////////// +/** + * An infinite line, similar to a CollisionRay, except that it extends in both + * directions. It is, however, directional. + */ class EXPCL_PANDA_COLLIDE CollisionLine : public CollisionRay { PUBLISHED: INLINE CollisionLine(); @@ -73,5 +70,3 @@ private: #include "collisionLine.I" #endif - - diff --git a/panda/src/collide/collisionNode.I b/panda/src/collide/collisionNode.I index 2bf2886535..01f6e95311 100644 --- a/panda/src/collide/collisionNode.I +++ b/panda/src/collide/collisionNode.I @@ -1,111 +1,87 @@ -// Filename: collisionNode.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionNode.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::set_collide_mask -// Access: Published -// Description: Simultaneously sets both the "from" and "into" -// CollideMask values to the same thing. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously sets both the "from" and "into" CollideMask values to the + * same thing. + */ INLINE void CollisionNode:: set_collide_mask(CollideMask mask) { set_from_collide_mask(mask); set_into_collide_mask(mask); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::set_into_collide_mask -// Access: Published -// Description: Sets the "into" CollideMask. In order for a -// collision to be detected from another object into -// this object, the intersection of the other object's -// "from" mask and this object's "into" mask must be -// nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "into" CollideMask. In order for a collision to be detected from + * another object into this object, the intersection of the other object's + * "from" mask and this object's "into" mask must be nonzero. + */ INLINE void CollisionNode:: set_into_collide_mask(CollideMask mask) { // This is now inherited from the PandaNode base class. PandaNode::set_into_collide_mask(mask); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_from_collide_mask -// Access: Published -// Description: Returns the current "from" CollideMask. In order for -// a collision to be detected from this object into -// another object, the intersection of this object's -// "from" mask and the other object's "into" mask must -// be nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current "from" CollideMask. In order for a collision to be + * detected from this object into another object, the intersection of this + * object's "from" mask and the other object's "into" mask must be nonzero. + */ INLINE CollideMask CollisionNode:: get_from_collide_mask() const { return _from_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_into_collide_mask -// Access: Published -// Description: Returns the current "into" CollideMask. In order for -// a collision to be detected from another object into -// this object, the intersection of the other object's -// "from" mask and this object's "into" mask must be -// nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current "into" CollideMask. In order for a collision to be + * detected from another object into this object, the intersection of the + * other object's "from" mask and this object's "into" mask must be nonzero. + */ INLINE CollideMask CollisionNode:: get_into_collide_mask() const { // This is now inherited from the PandaNode base class. return PandaNode::get_into_collide_mask(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::clear_solids -// Access: Published -// Description: Removes all solids from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes all solids from the node. + */ INLINE void CollisionNode:: clear_solids() { _solids.clear(); mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_num_solids -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int CollisionNode:: get_num_solids() const { return _solids.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_solid -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(CollisionSolid) CollisionNode:: get_solid(int n) const { nassertr(n >= 0 && n < get_num_solids(), NULL); return _solids[n].get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::modify_solid -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PT(CollisionSolid) CollisionNode:: modify_solid(int n) { nassertr(n >= 0 && n < get_num_solids(), NULL); @@ -113,11 +89,9 @@ modify_solid(int n) { return _solids[n].get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::set_solid -// Access: Published -// Description: Replaces the solid with the indicated index. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the solid with the indicated index. + */ INLINE void CollisionNode:: set_solid(int n, CollisionSolid *solid) { nassertv(n >= 0 && n < get_num_solids()); @@ -125,12 +99,10 @@ set_solid(int n, CollisionSolid *solid) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::remove_solid -// Access: Published -// Description: Removes the solid with the indicated index. This -// will shift all subsequent indices down by one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the solid with the indicated index. This will shift all subsequent + * indices down by one. + */ INLINE void CollisionNode:: remove_solid(int n) { nassertv(n >= 0 && n < get_num_solids()); @@ -138,13 +110,10 @@ remove_solid(int n) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::add_solid -// Access: Published -// Description: Adds the indicated solid to the node. Returns the -// index of the new solid within the node's list of -// solids. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated solid to the node. Returns the index of the new solid + * within the node's list of solids. + */ INLINE int CollisionNode:: add_solid(const CollisionSolid *solid) { _solids.push_back((CollisionSolid *)solid); @@ -152,45 +121,35 @@ add_solid(const CollisionSolid *solid) { return _solids.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_collider_sort -// Access: Published -// Description: Returns the collider_sort value that has been set for -// this particular node. See set_collider_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the collider_sort value that has been set for this particular node. + * See set_collider_sort(). + */ INLINE int CollisionNode:: get_collider_sort() const { return _collider_sort; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::set_collider_sort -// Access: Published -// Description: Sets a particular collider_sort value on this node. -// This controls the order in which colliders (that is, -// "from nodes") are grouped together for the collision -// traversal. -// -// If there are 32 or fewer colliders added to any -// particular CollisionTraverser, then this value has no -// meaning. It is only useful if there are many -// colliders, which may force the CollisionTraverser to -// make multiple passes through the data; in that case, -// it may be a useful optimization to group colliders -// that have similar bounding volumes together (by -// giving them similar sort values). -//////////////////////////////////////////////////////////////////// +/** + * Sets a particular collider_sort value on this node. This controls the + * order in which colliders (that is, "from nodes") are grouped together for + * the collision traversal. + * + * If there are 32 or fewer colliders added to any particular + * CollisionTraverser, then this value has no meaning. It is only useful if + * there are many colliders, which may force the CollisionTraverser to make + * multiple passes through the data; in that case, it may be a useful + * optimization to group colliders that have similar bounding volumes together + * (by giving them similar sort values). + */ INLINE void CollisionNode:: set_collider_sort(int sort) { _collider_sort = sort; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_default_collide_mask -// Access: Published, Static -// Description: Returns the default into_collide_mask assigned to new -// CollisionNodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default into_collide_mask assigned to new CollisionNodes. + */ INLINE CollideMask CollisionNode:: get_default_collide_mask() { return default_collision_node_collide_mask; diff --git a/panda/src/collide/collisionNode.cxx b/panda/src/collide/collisionNode.cxx index 1c42144646..da5aa38cc6 100644 --- a/panda/src/collide/collisionNode.cxx +++ b/panda/src/collide/collisionNode.cxx @@ -1,16 +1,15 @@ -// Filename: collisionNode.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionNode.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionNode.h" #include "config_collide.h" @@ -34,11 +33,9 @@ TypeHandle CollisionNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionNode:: CollisionNode(const string &name) : PandaNode(name), @@ -54,11 +51,9 @@ CollisionNode(const string &name) : set_into_collide_mask(get_default_collide_mask()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionNode:: CollisionNode(const CollisionNode ©) : PandaNode(copy), @@ -67,47 +62,36 @@ CollisionNode(const CollisionNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionNode:: ~CollisionNode() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *CollisionNode:: make_copy() const { return new CollisionNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::preserve_name -// Access: Public, Virtual -// Description: Returns true if the node's name has extrinsic meaning -// and must be preserved across a flatten operation, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node's name has extrinsic meaning and must be preserved + * across a flatten operation, false otherwise. + */ bool CollisionNode:: preserve_name() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void CollisionNode:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -124,29 +108,24 @@ xform(const LMatrix4 &mat) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::combine_with -// Access: Public, Virtual -// Description: Collapses this node with the other node, if possible, -// and returns a pointer to the combined node, or NULL -// if the two nodes cannot safely be combined. -// -// The return value may be this, other, or a new node -// altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two nodes and what the -// collapsed node should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this node with the other node, if possible, and returns a pointer + * to the combined node, or NULL if the two nodes cannot safely be combined. + * + * The return value may be this, other, or a new node altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two nodes + * and what the collapsed node should look like. + */ PandaNode *CollisionNode:: combine_with(PandaNode *other) { if (flatten_collision_nodes) { if (is_exact_type(get_class_type()) && other->is_exact_type(get_class_type())) { - // Two CollisionNodes can combine, but only if they have the same - // name, because the name is often meaningful, and only if they - // have the same collide masks. + // Two CollisionNodes can combine, but only if they have the same name, + // because the name is often meaningful, and only if they have the same + // collide masks. CollisionNode *cother = DCAST(CollisionNode, other); if (get_name() == cother->get_name() && get_from_collide_mask() == cother->get_from_collide_mask() && @@ -157,60 +136,50 @@ combine_with(PandaNode *other) { mark_internal_bounds_stale(); return this; } - - // Two CollisionNodes with different names or different collide - // masks can't combine. + + // Two CollisionNodes with different names or different collide masks + // can't combine. } } return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_legal_collide_mask -// Access: Published, Virtual -// Description: Returns the subset of CollideMask bits that may be -// set for this particular type of PandaNode. For most -// nodes, this is 0; it doesn't make sense to set a -// CollideMask for most kinds of nodes. -// -// For nodes that can be collided with, such as GeomNode -// and CollisionNode, this returns all bits on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of CollideMask bits that may be set for this particular + * type of PandaNode. For most nodes, this is 0; it doesn't make sense to set + * a CollideMask for most kinds of nodes. + * + * For nodes that can be collided with, such as GeomNode and CollisionNode, + * this returns all bits on. + */ CollideMask CollisionNode:: get_legal_collide_mask() const { return CollideMask::all_on(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool CollisionNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // Append our collision vizzes to the drawing, even though they're - // not actually part of the scene graph. + // Append our collision vizzes to the drawing, even though they're not + // actually part of the scene graph. Solids::const_iterator si; for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); @@ -218,30 +187,29 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (node != (PandaNode *)NULL) { CullTraverserData next_data(data, node); - // We don't want to inherit the render state from above for these - // guys. + // We don't want to inherit the render state from above for these guys. next_data._state = RenderState::make_empty(); trav->traverse(next_data); } } if (respect_prev_transform) { - // Determine the previous frame's position, relative to the - // current position. + // Determine the previous frame's position, relative to the current + // position. NodePath node_path = data._node_path.get_node_path(); CPT(TransformState) transform = node_path.get_net_transform()->invert_compose(node_path.get_net_prev_transform()); - + if (!transform->is_identity()) { // If we have a velocity, also draw the previous frame's position, // ghosted. - + for (si = _solids.begin(); si != _solids.end(); ++si) { CPT(CollisionSolid) solid = (*si).get_read_pointer(); PT(PandaNode) node = solid->get_viz(trav, data, false); if (node != (PandaNode *)NULL) { CullTraverserData next_data(data, node); - - next_data._net_transform = + + next_data._net_transform = next_data._net_transform->compose(transform); next_data._state = get_last_pos_state(); trav->traverse(next_data); @@ -254,73 +222,56 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool CollisionNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::is_collision_node -// Access: Published, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from CollisionNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(CollisionNode::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from CollisionNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(CollisionNode::get_class_type()). + */ bool CollisionNode:: is_collision_node() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void CollisionNode:: output(ostream &out) const { PandaNode::output(out); out << " (" << _solids.size() << " solids)"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::set_from_collide_mask -// Access: Published -// Description: Sets the "from" CollideMask. In order for a -// collision to be detected from this object into -// another object, the intersection of this object's -// "from" mask and the other object's "into" mask must -// be nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "from" CollideMask. In order for a collision to be detected from + * this object into another object, the intersection of this object's "from" + * mask and the other object's "into" mask must be nonzero. + */ void CollisionNode:: set_from_collide_mask(CollideMask mask) { _from_collide_mask = mask; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void CollisionNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -353,8 +304,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, if (btype == BoundingVolume::BT_box || (btype != BoundingVolume::BT_sphere && all_box)) { - // If all of the child volumes are a BoundingBox, then our volume - // is also a BoundingBox. + // If all of the child volumes are a BoundingBox, then our volume is also + // a BoundingBox. gbv = new BoundingBox; } else { // Otherwise, it's a sphere. @@ -366,23 +317,20 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, const BoundingVolume **child_end = child_begin + child_volumes.size(); ((BoundingVolume *)gbv)->around(child_begin, child_end); } - + internal_bounds = gbv; internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::get_last_pos_state -// Access: Protected -// Description: Returns a RenderState for rendering the ghosted -// collision solid that represents the previous frame's -// position, for those collision nodes that indicate a -// velocity. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the ghosted collision solid that + * represents the previous frame's position, for those collision nodes that + * indicate a velocity. + */ CPT(RenderState) CollisionNode:: get_last_pos_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make @@ -394,23 +342,18 @@ get_last_pos_state() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CollisionNode. + */ void CollisionNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CollisionNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -429,13 +372,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint32(_from_collide_mask.get_word()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int CollisionNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -448,14 +388,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionNode is encountered -// in the Bam file. It should create the CollisionNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CollisionNode is encountered in the Bam file. It should create the + * CollisionNode and extract its information from the file. + */ TypedWritable *CollisionNode:: make_from_bam(const FactoryParams ¶ms) { CollisionNode *node = new CollisionNode(""); @@ -468,13 +405,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CollisionNode. + */ void CollisionNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); @@ -487,8 +421,7 @@ fillin(DatagramIterator &scan, BamReader *manager) { _solids.reserve(num_solids); for(int i = 0; i < num_solids; i++) { manager->read_pointer(scan); - // Push back a NULL for each solid, for now. We'll fill them in - // later. + // Push back a NULL for each solid, for now. We'll fill them in later. _solids.push_back((CollisionSolid *)NULL); } diff --git a/panda/src/collide/collisionNode.h b/panda/src/collide/collisionNode.h index 4ac6895acf..5a939a284d 100644 --- a/panda/src/collide/collisionNode.h +++ b/panda/src/collide/collisionNode.h @@ -1,16 +1,15 @@ -// Filename: collisionNode.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionNode.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONNODE_H #define COLLISIONNODE_H @@ -22,14 +21,12 @@ #include "collideMask.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionNode -// Description : A node in the scene graph that can hold any number of -// CollisionSolids. This may either represent a bit of -// static geometry in the scene that things will collide -// with, or an animated object twirling around in the -// world and running into things. -//////////////////////////////////////////////////////////////////// +/** + * A node in the scene graph that can hold any number of CollisionSolids. + * This may either represent a bit of static geometry in the scene that things + * will collide with, or an animated object twirling around in the world and + * running into things. + */ class EXPCL_PANDA_COLLIDE CollisionNode : public PandaNode { PUBLISHED: CollisionNode(const string &name); @@ -42,7 +39,7 @@ public: virtual PandaNode *make_copy() const; virtual bool preserve_name() const; virtual void xform(const LMatrix4 &mat); - virtual PandaNode *combine_with(PandaNode *other); + virtual PandaNode *combine_with(PandaNode *other); virtual CollideMask get_legal_collide_mask() const; virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); @@ -87,15 +84,14 @@ protected: private: CPT(RenderState) get_last_pos_state(); - // This data is not cycled, for now. We assume the collision - // traversal will take place in App only. Perhaps we will revisit - // this later. + // This data is not cycled, for now. We assume the collision traversal will + // take place in App only. Perhaps we will revisit this later. CollideMask _from_collide_mask; int _collider_sort; typedef pvector< COWPT(CollisionSolid) > Solids; Solids _solids; - + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); diff --git a/panda/src/collide/collisionParabola.I b/panda/src/collide/collisionParabola.I index 295e5d43f0..0a93d26cb8 100644 --- a/panda/src/collide/collisionParabola.I +++ b/panda/src/collide/collisionParabola.I @@ -1,35 +1,29 @@ -// Filename: collisionParabola.I -// Created by: drose (11Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionParabola.I + * @author drose + * @date 2007-10-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::Default Constructor -// Access: Published -// Description: Creates an invalid parabola. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid parabola. + */ INLINE CollisionParabola:: CollisionParabola() : _t1(0.0f), _t2(0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::Constructor -// Access: Published -// Description: Creates a parabola with the endpoints between t1 and -// t2 in the parametric space of the parabola. -//////////////////////////////////////////////////////////////////// +/** + * Creates a parabola with the endpoints between t1 and t2 in the parametric + * space of the parabola. + */ INLINE CollisionParabola:: CollisionParabola(const LParabola ¶bola, PN_stdfloat t1, PN_stdfloat t2) : _parabola(parabola), @@ -37,11 +31,9 @@ CollisionParabola(const LParabola ¶bola, PN_stdfloat t1, PN_stdfloat t2) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionParabola:: CollisionParabola(const CollisionParabola ©) : _parabola(copy._parabola), @@ -49,11 +41,9 @@ CollisionParabola(const CollisionParabola ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::set_parabola -// Access: Public -// Description: Replaces the parabola specified by this solid. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the parabola specified by this solid. + */ INLINE void CollisionParabola:: set_parabola(const LParabola ¶bola) { _parabola = parabola; @@ -61,21 +51,17 @@ set_parabola(const LParabola ¶bola) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_parabola -// Access: Public -// Description: Returns the parabola specified by this solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parabola specified by this solid. + */ INLINE const LParabola &CollisionParabola:: get_parabola() const { return _parabola; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::set_t1 -// Access: Public -// Description: Changes the starting point on the parabola. -//////////////////////////////////////////////////////////////////// +/** + * Changes the starting point on the parabola. + */ INLINE void CollisionParabola:: set_t1(PN_stdfloat t1) { _t1 = t1; @@ -83,21 +69,17 @@ set_t1(PN_stdfloat t1) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_t1 -// Access: Public -// Description: Returns the starting point on the parabola. -//////////////////////////////////////////////////////////////////// +/** + * Returns the starting point on the parabola. + */ INLINE PN_stdfloat CollisionParabola:: get_t1() const { return _t1; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::set_t2 -// Access: Public -// Description: Changes the ending point on the parabola. -//////////////////////////////////////////////////////////////////// +/** + * Changes the ending point on the parabola. + */ INLINE void CollisionParabola:: set_t2(PN_stdfloat t2) { _t2 = t2; @@ -105,11 +87,9 @@ set_t2(PN_stdfloat t2) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_t2 -// Access: Public -// Description: Returns the ending point on the parabola. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ending point on the parabola. + */ INLINE PN_stdfloat CollisionParabola:: get_t2() const { return _t2; diff --git a/panda/src/collide/collisionParabola.cxx b/panda/src/collide/collisionParabola.cxx index 4ad5023e3b..734647b16c 100644 --- a/panda/src/collide/collisionParabola.cxx +++ b/panda/src/collide/collisionParabola.cxx @@ -1,16 +1,15 @@ -// Filename: collisionParabola.cxx -// Created by: drose (11Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionParabola.cxx + * @author drose + * @date 2007-10-11 + */ #include "collisionParabola.h" #include "collisionEntry.h" @@ -31,45 +30,36 @@ PStatCollector CollisionParabola::_test_pcollector( "Collision Tests:CollisionParabola"); TypeHandle CollisionParabola::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionParabola:: get_collision_origin() const { return _parabola.calc_point(_t1); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionParabola:: make_copy() { return new CollisionParabola(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionParabola:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_parabola(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionParabola:: xform(const LMatrix4 &mat) { _parabola.xform(mat); @@ -78,78 +68,66 @@ xform(const LMatrix4 &mat) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionParabola:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionParabola:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionParabola:: output(ostream &out) const { out << _parabola << ", t1 = " << _t1 << ", t2 = " << _t2; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionParabola:: compute_internal_bounds() const { LPoint3 p1 = _parabola.calc_point(get_t1()); LPoint3 p2 = _parabola.calc_point(get_t2()); LVector3 pdelta = p2 - p1; - // If p1 and p2 are sufficiently close, just put a sphere around - // them. + // If p1 and p2 are sufficiently close, just put a sphere around them. PN_stdfloat d2 = pdelta.length_squared(); if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) { LPoint3 pmid = (p1 + p2) * 0.5f; return new BoundingSphere(pmid, csqrt(d2) * 0.5f); } - // OK, the more general bounding volume. We use BoundingHexahedron - // to define a very thin box that roughly bounds the parabola's arc. - // We must use BoundingHexahedron instead of BoundingBox, because - // the box will not be axis-aligned, and might be inflated too large - // if we insist on using the axis-aligned BoundingBox. + // OK, the more general bounding volume. We use BoundingHexahedron to + // define a very thin box that roughly bounds the parabola's arc. We must + // use BoundingHexahedron instead of BoundingBox, because the box will not + // be axis-aligned, and might be inflated too large if we insist on using + // the axis-aligned BoundingBox. - // We first define "parabola space" as a coordinate space such that - // the YZ plane of parabola space corresponds to the plane of the - // parabola. + // We first define "parabola space" as a coordinate space such that the YZ + // plane of parabola space corresponds to the plane of the parabola. - // We have to be explicit about the coordinate system--we - // specifically mean CS_zup_right here, to make the YZ plane. + // We have to be explicit about the coordinate system--we specifically mean + // CS_zup_right here, to make the YZ plane. LMatrix4 from_parabola; look_at(from_parabola, pdelta, -_parabola.get_a(), CS_zup_right); from_parabola.set_row(3, p1); - // The matrix that computes from world space to parabola space is - // the inverse of that which we just computed. + // The matrix that computes from world space to parabola space is the + // inverse of that which we just computed. LMatrix4 to_parabola; to_parabola.invert_from(from_parabola); @@ -160,8 +138,7 @@ compute_internal_bounds() const { LPoint3 pp2 = psp.calc_point(get_t2()); PN_stdfloat max_y = pp2[1]; - // We compute a few points along the parabola to attempt to get the - // minmax. + // We compute a few points along the parabola to attempt to get the minmax. PN_stdfloat min_z = 0.0f; PN_stdfloat max_z = 0.0f; int num_points = collision_parabola_bounds_sample; @@ -173,22 +150,20 @@ compute_internal_bounds() const { } // That gives us a simple bounding volume in parabola space. - PT(BoundingHexahedron) volume = + PT(BoundingHexahedron) volume = new BoundingHexahedron(LPoint3(-0.01, max_y, min_z), LPoint3(0.01, max_y, min_z), - LPoint3(0.01, max_y, max_z), LPoint3(-0.01, max_y, max_z), - LPoint3(-0.01, 0, min_z), LPoint3(0.01, 0, min_z), + LPoint3(0.01, max_y, max_z), LPoint3(-0.01, max_y, max_z), + LPoint3(-0.01, 0, min_z), LPoint3(0.01, 0, min_z), LPoint3(0.01, 0, max_z), LPoint3(-0.01, 0, max_z)); // And convert that back into real space. volume->xform(from_parabola); return volume.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionParabola:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -203,11 +178,11 @@ fill_viz_geom() { Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points); vertex.add_data3(_parabola.calc_point(_t1 + t * (_t2 - _t1))); - + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 0.0f) + t * LColor(0.0f, 0.0f, 0.0f, 1.0f)); } @@ -215,30 +190,26 @@ fill_viz_geom() { PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); line->add_next_vertices(num_points); line->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(line); - + _viz_geom->add_geom(geom, get_other_viz_state()); _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionParabola object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionParabola object + */ void CollisionParabola:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionParabola:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSolid::write_datagram(manager, me); @@ -247,11 +218,9 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_stdfloat(_t2); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::make_from_bam -// Access: Protected -// Description: Factory method to generate a CollisionParabola object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionParabola object + */ TypedWritable *CollisionParabola:: make_from_bam(const FactoryParams ¶ms) { CollisionParabola *me = new CollisionParabola; @@ -263,14 +232,11 @@ make_from_bam(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionParabola::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionParabola:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionParabola.h b/panda/src/collide/collisionParabola.h index f2958ad67d..5d6cdedb89 100644 --- a/panda/src/collide/collisionParabola.h +++ b/panda/src/collide/collisionParabola.h @@ -1,16 +1,15 @@ -// Filename: collisionParabola.h -// Created by: drose (11Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionParabola.h + * @author drose + * @date 2007-10-11 + */ #ifndef COLLISIONPARABOLA_H #define COLLISIONPARABOLA_H @@ -22,16 +21,14 @@ class LensNode; -//////////////////////////////////////////////////////////////////// -// Class : CollisionParabola -// Description : This defines a parabolic arc, or subset of an arc, -// similar to the path of a projectile or falling -// object. It is finite, having a specific beginning -// and end, but it is infinitely thin. -// -// Think of it as a wire bending from point t1 to point -// t2 along the path of a pre-defined parabola. -//////////////////////////////////////////////////////////////////// +/** + * This defines a parabolic arc, or subset of an arc, similar to the path of a + * projectile or falling object. It is finite, having a specific beginning + * and end, but it is infinitely thin. + * + * Think of it as a wire bending from point t1 to point t2 along the path of a + * pre-defined parabola. + */ class EXPCL_PANDA_COLLIDE CollisionParabola : public CollisionSolid { PUBLISHED: INLINE CollisionParabola(); @@ -110,5 +107,3 @@ private: #include "collisionParabola.I" #endif - - diff --git a/panda/src/collide/collisionPlane.I b/panda/src/collide/collisionPlane.I index 60a408ff5f..29c11d1443 100644 --- a/panda/src/collide/collisionPlane.I +++ b/panda/src/collide/collisionPlane.I @@ -1,45 +1,36 @@ -// Filename: collisionPlane.I -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPlane.I + * @author drose + * @date 2000-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::Default Constructor -// Access: Protected -// Description: This is only for the convenience of CollisionPolygon. -// Normally, you should not attempt to create an -// uninitialized CollisionPlane. -//////////////////////////////////////////////////////////////////// +/** + * This is only for the convenience of CollisionPolygon. Normally, you should + * not attempt to create an uninitialized CollisionPlane. + */ INLINE CollisionPlane:: CollisionPlane() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPlane:: CollisionPlane(const LPlane &plane) : _plane(plane) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPlane:: CollisionPlane(const CollisionPlane ©) : CollisionSolid(copy), @@ -47,42 +38,34 @@ CollisionPlane(const CollisionPlane ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionPlane:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 CollisionPlane:: get_normal() const { return _plane.get_normal(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::dist_to_plane -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat CollisionPlane:: dist_to_plane(const LPoint3 &point) const { return _plane.dist_to_plane(point); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::set_plane -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionPlane:: set_plane(const LPlane &plane) { _plane = plane; @@ -90,21 +73,17 @@ set_plane(const LPlane &plane) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_plane -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPlane &CollisionPlane:: get_plane() const { return _plane; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::flip -// Access: Published -// Description: Convenience method to flip the plane in-place. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method to flip the plane in-place. + */ INLINE void CollisionPlane:: flip() { _plane.flip(); diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index c7707e1cb8..1d7b4ed758 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -1,17 +1,15 @@ -// Filename: collisionPlane.cxx -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPlane.cxx + * @author drose + * @date 2000-04-25 + */ #include "collisionPlane.h" #include "collisionHandler.h" @@ -39,92 +37,72 @@ PStatCollector CollisionPlane::_volume_pcollector("Collision Volumes:CollisionPl PStatCollector CollisionPlane::_test_pcollector("Collision Tests:CollisionPlane"); TypeHandle CollisionPlane::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionPlane:: make_copy() { return new CollisionPlane(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionPlane:: xform(const LMatrix4 &mat) { _plane = _plane * mat; CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionPlane:: get_collision_origin() const { - // No real sensible origin exists for a plane. We return 0, 0, 0, - // without even bothering to ensure that that point exists on the - // plane. + // No real sensible origin exists for a plane. We return 0, 0, 0, without + // even bothering to ensure that that point exists on the plane. return LPoint3::origin(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionPlane:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionPlane:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionPlane:: output(ostream &out) const { out << "cplane, (" << _plane << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionPlane:: compute_internal_bounds() const { return new BoundingPlane(_plane); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; @@ -161,11 +139,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_line -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; @@ -198,7 +174,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { LPoint3 into_intersection_point = from_origin + t * from_direction; - LVector3 normal = + LVector3 normal = (has_effective_normal() && line->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); @@ -208,11 +184,9 @@ test_intersection_from_line(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_ray -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -226,8 +200,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const { PN_stdfloat t; if (_plane.dist_to_plane(from_origin) < 0.0f) { - // The origin of the ray is behind the plane, so we don't need to - // test further. + // The origin of the ray is behind the plane, so we don't need to test + // further. t = 0.0f; } else { @@ -237,8 +211,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const { } if (t < 0.0f) { - // The intersection point is before the start of the ray, and so - // the ray is entirely in front of the plane. + // The intersection point is before the start of the ray, and so the ray + // is entirely in front of the plane. return NULL; } } @@ -253,7 +227,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 into_intersection_point = from_origin + t * from_direction; LVector3 normal = - (has_effective_normal() && ray->get_respect_effective_normal()) + (has_effective_normal() && ray->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); @@ -262,11 +236,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_segment -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; @@ -321,13 +293,10 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_parabola -// Access: Public, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a parabola. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a parabola. + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; @@ -341,32 +310,32 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PN_stdfloat t; if (_plane.dist_to_plane(local_p.calc_point(parabola->get_t1())) < 0.0f) { - // The first point in the parabola is behind the plane, so we - // don't need to test further. + // The first point in the parabola is behind the plane, so we don't need + // to test further. t = parabola->get_t1(); } else { PN_stdfloat t1, t2; if (!get_plane().intersects_parabola(t1, t2, local_p)) { - // No intersection. The infinite parabola is entirely in front - // of the plane. + // No intersection. The infinite parabola is entirely in front of the + // plane. return NULL; } if (t1 >= parabola->get_t1() && t1 <= parabola->get_t2()) { if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { - // Both intersection points are within our segment of the - // parabola. Choose the first of the two. + // Both intersection points are within our segment of the parabola. + // Choose the first of the two. t = min(t1, t2); } else { // Only t1 is within our segment. t = t1; } - + } else if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { // Only t2 is within our segment. t = t2; - + } else { // Neither intersection point is within our segment. return NULL; @@ -390,13 +359,10 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::test_intersection_from_box -// Access: Public, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a box. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a box. + */ PT(CollisionEntry) CollisionPlane:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; @@ -413,8 +379,8 @@ test_intersection_from_box(const CollisionEntry &entry) const { LVecBase3 box_y = wrt_mat.get_row3(1) * from_extents[1]; LVecBase3 box_z = wrt_mat.get_row3(2) * from_extents[2]; - // Project the box onto the normal vector of the plane to determine - // whether there is a separating axis. + // Project the box onto the normal vector of the plane to determine whether + // there is a separating axis. PN_stdfloat dx = box_x.dot(_plane.get_normal()); PN_stdfloat dy = box_y.dot(_plane.get_normal()); PN_stdfloat dz = box_z.dot(_plane.get_normal()); @@ -435,8 +401,8 @@ test_intersection_from_box(const CollisionEntry &entry) const { LVector3 normal = (has_effective_normal() && box->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); - // Determine which point on the cube will be the interior point. If - // the points are equally close, this chooses their center instead. + // Determine which point on the cube will be the interior point. If the + // points are equally close, this chooses their center instead. LPoint3 interior_point = from_center + box_x * ((dx < 0) - (dx > 0)) + box_y * ((dy < 0) - (dy > 0)) + @@ -449,12 +415,10 @@ test_intersection_from_box(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionPlane:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -462,18 +426,16 @@ fill_viz_geom() { << "Recomputing viz for " << *this << "\n"; } - // Since we can't represent an infinite plane, we'll have to be - // satisfied with drawing a big polygon. Choose four points on the - // plane to be the corners of the polygon. + // Since we can't represent an infinite plane, we'll have to be satisfied + // with drawing a big polygon. Choose four points on the plane to be the + // corners of the polygon. - // We must choose four points fairly reasonably spread apart on - // the plane. We'll start with a center point and one corner - // point, and then use cross products to find the remaining three - // corners of a square. + // We must choose four points fairly reasonably spread apart on the plane. + // We'll start with a center point and one corner point, and then use cross + // products to find the remaining three corners of a square. - // The center point will be on the axis with the largest - // coefficent. The first corner will be diagonal in the other two - // dimensions. + // The center point will be on the axis with the largest coefficent. The + // first corner will be diagonal in the other two dimensions. LPoint3 cp; LVector3 p1, p2, p3, p4; @@ -509,40 +471,38 @@ fill_viz_geom() { ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + vertex.add_data3(cp + p1 * plane_scale); vertex.add_data3(cp + p2 * plane_scale); vertex.add_data3(cp + p3 * plane_scale); vertex.add_data3(cp + p4 * plane_scale); - + PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); body->add_consecutive_vertices(0, 4); body->close_primitive(); - + PT(GeomLinestrips) border = new GeomLinestrips(Geom::UH_static); border->add_consecutive_vertices(0, 4); border->add_vertex(0); border->close_primitive(); - + PT(Geom) geom1 = new Geom(vdata); geom1->add_primitive(body); - + PT(Geom) geom2 = new Geom(vdata); geom2->add_primitive(border); - + _viz_geom->add_geom(geom1, get_solid_viz_state()); _viz_geom->add_geom(geom2, get_wireframe_viz_state()); - + _bounds_viz_geom->add_geom(geom1, get_solid_bounds_viz_state()); _bounds_viz_geom->add_geom(geom2, get_wireframe_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionPlane:: write_datagram(BamWriter *manager, Datagram &me) { @@ -550,14 +510,11 @@ write_datagram(BamWriter *manager, Datagram &me) _plane.write_datagram(me); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionPlane:: fillin(DatagramIterator& scan, BamReader* manager) { @@ -565,11 +522,9 @@ fillin(DatagramIterator& scan, BamReader* manager) _plane.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::make_CollisionPlane -// Access: Protected -// Description: Factory method to generate a CollisionPlane object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPlane object + */ TypedWritable* CollisionPlane:: make_CollisionPlane(const FactoryParams ¶ms) { @@ -582,11 +537,9 @@ make_CollisionPlane(const FactoryParams ¶ms) return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPlane::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionPlane object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPlane object + */ void CollisionPlane:: register_with_read_factory() { diff --git a/panda/src/collide/collisionPlane.h b/panda/src/collide/collisionPlane.h index db54441b1b..232b52c650 100644 --- a/panda/src/collide/collisionPlane.h +++ b/panda/src/collide/collisionPlane.h @@ -1,16 +1,15 @@ -// Filename: collisionPlane.h -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPlane.h + * @author drose + * @date 2000-04-25 + */ #ifndef COLLISIONPLANE_H #define COLLISIONPLANE_H @@ -22,10 +21,9 @@ #include "luse.h" #include "plane.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionPlane -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_COLLIDE CollisionPlane : public CollisionSolid { protected: INLINE CollisionPlane(); @@ -116,5 +114,3 @@ private: #include "collisionPlane.I" #endif - - diff --git a/panda/src/collide/collisionPolygon.I b/panda/src/collide/collisionPolygon.I index 12410bafb0..4a048a3995 100644 --- a/panda/src/collide/collisionPolygon.I +++ b/panda/src/collide/collisionPolygon.I @@ -1,23 +1,19 @@ -// Filename: collisionPolygon.I -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPolygon.I + * @author drose + * @date 2000-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon:: CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, const LVecBase3 &c) { @@ -28,11 +24,9 @@ CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, setup_points(array, array + 3); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon:: CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, const LVecBase3 &c, const LVecBase3 &d) { @@ -45,43 +39,32 @@ CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon:: CollisionPolygon(const LPoint3 *begin, const LPoint3 *end) { setup_points(begin, end); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::Constructor -// Access: Private -// Description: Creates an invalid polygon. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid polygon. Only used when reading from a bam file. + */ INLINE CollisionPolygon:: CollisionPolygon() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_num_points -// Access: Published -// Description: Returns the number of vertices of the -// CollisionPolygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices of the CollisionPolygon. + */ INLINE int CollisionPolygon:: get_num_points() const { return _points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_point -// Access: Published -// Description: Returns the nth vertex of the CollisionPolygon, -// expressed in 3-D space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the CollisionPolygon, expressed in 3-D space. + */ INLINE LPoint3 CollisionPolygon:: get_point(int n) const { nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); @@ -90,13 +73,11 @@ get_point(int n) const { return to_3d(_points[n]._p, to_3d_mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::verify_points -// Access: Published, Static -// Description: Verifies that the indicated set of points will define -// a valid CollisionPolygon: that is, at least three -// non-collinear points, with no points repeated. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the indicated set of points will define a valid + * CollisionPolygon: that is, at least three non-collinear points, with no + * points repeated. + */ INLINE bool CollisionPolygon:: verify_points(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c) { @@ -107,13 +88,11 @@ verify_points(const LPoint3 &a, const LPoint3 &b, return verify_points(array, array + 3); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::verify_points -// Access: Published, Static -// Description: Verifies that the indicated set of points will define -// a valid CollisionPolygon: that is, at least three -// non-collinear points, with no points repeated. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the indicated set of points will define a valid + * CollisionPolygon: that is, at least three non-collinear points, with no + * points repeated. + */ INLINE bool CollisionPolygon:: verify_points(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d) { @@ -125,35 +104,28 @@ verify_points(const LPoint3 &a, const LPoint3 &b, return verify_points(array, array + 4); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionPolygon:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::is_right -// Access: Private, Static -// Description: Returns true if the 2-d v1 is to the right of v2. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the 2-d v1 is to the right of v2. + */ INLINE bool CollisionPolygon:: is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 1.0e-6f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::dist_to_line -// Access: Private, Static -// Description: Returns the linear distance of p to the line defined -// by f and f+v, where v is a normalized vector. The -// result is negative if p is left of the line, positive -// if it is right of the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance of p to the line defined by f and f+v, where v + * is a normalized vector. The result is negative if p is left of the line, + * positive if it is right of the line. + */ INLINE PN_stdfloat CollisionPolygon:: dist_to_line(const LPoint2 &p, const LPoint2 &f, const LVector2 &v) { @@ -161,103 +133,81 @@ dist_to_line(const LPoint2 &p, return (v1[0] * v[1] - v1[1] * v[0]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::to_2d -// Access: Private -// Description: Assuming the indicated point in 3-d space lies within -// the polygon's plane, returns the corresponding point -// in the polygon's 2-d definition space. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the indicated point in 3-d space lies within the polygon's plane, + * returns the corresponding point in the polygon's 2-d definition space. + */ INLINE LPoint2 CollisionPolygon:: to_2d(const LVecBase3 &point3d) const { LPoint3 point = LPoint3(point3d) * _to_2d_mat; return LPoint2(point[0], point[2]); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::calc_to_3d_mat -// Access: Private -// Description: Fills the indicated matrix with the appropriate -// rotation transform to move points from the 2-d plane -// into the 3-d (X, 0, Z) plane. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated matrix with the appropriate rotation transform to move + * points from the 2-d plane into the 3-d (X, 0, Z) plane. + */ INLINE void CollisionPolygon:: calc_to_3d_mat(LMatrix4 &to_3d_mat) const { - // We have to be explicit about the coordinate system--we - // specifically mean CS_zup_right, because that points the forward - // vector down the Y axis and moves the coords in (X, 0, Z). We - // want this effect regardless of the user's coordinate system of - // choice. + // We have to be explicit about the coordinate system--we specifically mean + // CS_zup_right, because that points the forward vector down the Y axis and + // moves the coords in (X, 0, Z). We want this effect regardless of the + // user's coordinate system of choice. // The up vector, on the other hand, is completely arbitrary. - look_at(to_3d_mat, -get_plane().get_normal(), + look_at(to_3d_mat, -get_plane().get_normal(), LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); to_3d_mat.set_row(3, get_plane().get_point()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::rederive_to_3d_mat -// Access: Private -// Description: Fills the indicated matrix with the appropriate -// rotation transform to move points from the 2-d plane -// into the 3-d (X, 0, Z) plane. -// -// This is essentially similar to calc_to_3d_mat, except -// that the matrix is rederived from whatever is stored -// in _to_2d_mat, guaranteeing that it will match -// whatever algorithm produced that one, even if it was -// produced on a different machine with different -// numerical precision. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated matrix with the appropriate rotation transform to move + * points from the 2-d plane into the 3-d (X, 0, Z) plane. + * + * This is essentially similar to calc_to_3d_mat, except that the matrix is + * rederived from whatever is stored in _to_2d_mat, guaranteeing that it will + * match whatever algorithm produced that one, even if it was produced on a + * different machine with different numerical precision. + */ INLINE void CollisionPolygon:: rederive_to_3d_mat(LMatrix4 &to_3d_mat) const { to_3d_mat.invert_from(_to_2d_mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::to_3d -// Access: Private, Static -// Description: Extrude the indicated point in the polygon's 2-d -// definition space back into 3-d coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Extrude the indicated point in the polygon's 2-d definition space back into + * 3-d coordinates. + */ INLINE LPoint3 CollisionPolygon:: to_3d(const LVecBase2 &point2d, const LMatrix4 &to_3d_mat) { return LPoint3(point2d[0], 0.0f, point2d[1]) * to_3d_mat; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::PointDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon::PointDef:: PointDef(const LPoint2 &p, const LVector2 &v) : _p(p), _v(v) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::PointDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon::PointDef:: PointDef(PN_stdfloat x, PN_stdfloat y) : _p(x, y), _v(0.0f, 0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::PointDef::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionPolygon::PointDef:: PointDef(const CollisionPolygon::PointDef ©) : _p(copy._p), _v(copy._v) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::PointDef::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionPolygon::PointDef:: operator = (const CollisionPolygon::PointDef ©) { _p = copy._p; diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index a373382ba8..ff64dcc298 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -1,16 +1,15 @@ -// Filename: collisionPolygon.cxx -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPolygon.cxx + * @author drose + * @date 2000-04-25 + */ #include "collisionPolygon.h" #include "collisionHandler.h" @@ -46,11 +45,9 @@ PStatCollector CollisionPolygon::_volume_pcollector("Collision Volumes:Collision PStatCollector CollisionPolygon::_test_pcollector("Collision Tests:CollisionPolygon"); TypeHandle CollisionPolygon::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionPolygon:: CollisionPolygon(const CollisionPolygon ©) : CollisionPlane(copy), @@ -59,28 +56,23 @@ CollisionPolygon(const CollisionPolygon ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionPolygon:: make_copy() { return new CollisionPolygon(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::verify_points -// Access: Public, Static -// Description: Verifies that the indicated set of points will define -// a valid CollisionPolygon: that is, at least three -// non-collinear points, with no points repeated. -// -// This does not check that the polygon defined is -// convex; that check is made later, once we have -// projected the points to 2-d space where the decision -// is easier. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the indicated set of points will define a valid + * CollisionPolygon: that is, at least three non-collinear points, with no + * points repeated. + * + * This does not check that the polygon defined is convex; that check is made + * later, once we have projected the points to 2-d space where the decision is + * easier. + */ bool CollisionPolygon:: verify_points(const LPoint3 *begin, const LPoint3 *end) { int num_points = end - begin; @@ -107,9 +99,9 @@ verify_points(const LPoint3 *begin, const LPoint3 *end) { } if (all_ok) { - // Create a plane to determine the planarity of the first three - // points (or the first two points and the nth point thereafter, in - // case the first three points happen to be collinear). + // Create a plane to determine the planarity of the first three points (or + // the first two points and the nth point thereafter, in case the first + // three points happen to be collinear). bool got_normal = false; for (int i = 2; i < num_points && !got_normal; i++) { LPlane plane(begin[0], begin[1], begin[i]); @@ -126,24 +118,19 @@ verify_points(const LPoint3 *begin, const LPoint3 *end) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::is_valid -// Access: Public -// Description: Returns true if the CollisionPolygon is valid -// (that is, it has at least three vertices), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the CollisionPolygon is valid (that is, it has at least + * three vertices), or false otherwise. + */ bool CollisionPolygon:: is_valid() const { return (_points.size() >= 3); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::is_concave -// Access: Public -// Description: Returns true if the CollisionPolygon appears to be -// concave, or false if it is safely convex. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the CollisionPolygon appears to be concave, or false if it + * is safely convex. + */ bool CollisionPolygon:: is_concave() const { if (_points.size() < 3) { @@ -182,16 +169,14 @@ is_concave() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionPolygon:: xform(const LMatrix4 &mat) { - // We need to convert all the vertices to 3-d for this operation, - // and then convert them back. Hopefully we won't lose too much - // precision during all of this. + // We need to convert all the vertices to 3-d for this operation, and then + // convert them back. Hopefully we won't lose too much precision during all + // of this. if (collide_cat.is_spam()) { collide_cat.spam() @@ -222,14 +207,11 @@ xform(const LMatrix4 &mat) { CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionPolygon:: get_collision_origin() const { LMatrix4 to_3d_mat; @@ -244,21 +226,18 @@ get_collision_origin() const { return to_3d(median, to_3d_mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_viz -// Access: Public, Virtual -// Description: Returns a GeomNode that may be rendered to visualize -// the CollisionSolid. This is used during the cull -// traversal to render the CollisionNodes that have been -// made visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomNode that may be rendered to visualize the CollisionSolid. + * This is used during the cull traversal to render the CollisionNodes that + * have been made visible. + */ PT(PandaNode) CollisionPolygon:: -get_viz(const CullTraverser *trav, const CullTraverserData &data, +get_viz(const CullTraverser *trav, const CullTraverserData &data, bool bounds_only) const { const ClipPlaneAttrib *cpa = DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())); if (cpa == (const ClipPlaneAttrib *)NULL) { - // Fortunately, the polygon is not clipped. This is the normal, - // easy case. + // Fortunately, the polygon is not clipped. This is the normal, easy + // case. return CollisionSolid::get_viz(trav, data, bounds_only); } @@ -267,16 +246,14 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, << "drawing polygon with clip plane " << *cpa << "\n"; } - // The polygon is clipped. We need to render it clipped. We could - // just turn on the ClipPlaneAttrib state and render the full - // polygon, letting the hardware do the clipping, but we get fancy - // and clip it by hand instead, just to prove that our clipping - // algorithm works properly. This does require some more dynamic - // work. + // The polygon is clipped. We need to render it clipped. We could just + // turn on the ClipPlaneAttrib state and render the full polygon, letting + // the hardware do the clipping, but we get fancy and clip it by hand + // instead, just to prove that our clipping algorithm works properly. This + // does require some more dynamic work. Points new_points; if (apply_clip_plane(new_points, cpa, data.get_net_transform(trav))) { - // All points are behind the clip plane; just draw the original - // polygon. + // All points are behind the clip plane; just draw the original polygon. return CollisionSolid::get_viz(trav, data, bounds_only); } @@ -297,46 +274,36 @@ get_viz(const CullTraverser *trav, const CullTraverserData &data, } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionPolygon:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionPolygon:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionPolygon:: output(ostream &out) const { out << "cpolygon, (" << get_plane() << "), " << _points.size() << " vertices"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionPolygon:: write(ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; @@ -354,11 +321,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionPolygon:: compute_internal_bounds() const { if (_points.empty()) { @@ -388,13 +353,10 @@ compute_internal_bounds() const { return new BoundingBox(n, x); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_sphere -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a sphere. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a sphere. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_sphere(const CollisionEntry &entry) const { if (_points.size() < 3) { @@ -422,38 +384,38 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat from_radius = csqrt(from_radius_2); if (wrt_prev_space != wrt_space) { - // If we have a delta between the previous position and the - // current position, we use that to determine some more properties - // of the collision. + // If we have a delta between the previous position and the current + // position, we use that to determine some more properties of the + // collision. LPoint3 b = from_center; LPoint3 a = sphere->get_center() * wrt_prev_space->get_mat(); LVector3 delta = b - a; - // First, there is no collision if the "from" object is definitely - // moving in the same direction as the plane's normal. + // First, there is no collision if the "from" object is definitely moving + // in the same direction as the plane's normal. PN_stdfloat dot = delta.dot(get_normal()); if (dot > 0.1f) { return NULL; } if (IS_NEARLY_ZERO(dot)) { - // If we're moving parallel to the plane, the sphere is tested - // at its final point. Leave it as it is. + // If we're moving parallel to the plane, the sphere is tested at its + // final point. Leave it as it is. } else { - // Otherwise, we're moving into the plane; the sphere is tested - // at the point along its path that is closest to intersecting - // the plane. This may be the actual intersection point, or it - // may be the starting point or the final point. - // dot is equal to the (negative) magnitude of 'delta' along the - // direction of the plane normal - // t = ratio of (distance from start pos to plane) to (distance - // from start pos to end pos), along axis of plane normal +/* + * Otherwise, we're moving into the plane; the sphere is tested at the point + * along its path that is closest to intersecting the plane. This may be the + * actual intersection point, or it may be the starting point or the final + * point. dot is equal to the (negative) magnitude of 'delta' along the + * direction of the plane normal t = ratio of (distance from start pos to + * plane) to (distance from start pos to end pos), along axis of plane normal + */ PN_stdfloat dist_to_p = dist_to_plane(a); t = (dist_to_p / -dot); - - // also compute the actual contact point and time of contact - // for handlers that need it + + // also compute the actual contact point and time of contact for + // handlers that need it actual_t = ((dist_to_p - from_radius) / -dot); actual_t = min((PN_stdfloat)1.0, max((PN_stdfloat)0.0, actual_t)); contact_point = a + (actual_t * delta); @@ -483,12 +445,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } #endif - // The nearest point within the plane to our center is the - // intersection of the line (center, center - normal) with the plane. + // The nearest point within the plane to our center is the intersection of + // the line (center, center - normal) with the plane. PN_stdfloat dist; if (!get_plane().intersects_line(dist, from_center, -get_normal())) { - // No intersection with plane? This means the plane's effective - // normal was within the plane itself. A useless polygon. + // No intersection with plane? This means the plane's effective normal + // was within the plane itself. A useless polygon. return NULL; } @@ -505,8 +467,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // We have a clip plane; apply it. Points new_points; if (apply_clip_plane(new_points, cpa, entry.get_into_node_path().get_net_transform())) { - // All points are behind the clip plane; just do the default - // test. + // All points are behind the clip plane; just do the default test. edge_dist = dist_to_polygon(p, _points); } else if (new_points.empty()) { @@ -519,24 +480,22 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } } else { - // No clip plane is in effect. Do the default test. + // No clip plane is in effect. Do the default test. edge_dist = dist_to_polygon(p, _points); } - // Now we have edge_dist, which is the distance from the sphere - // center to the nearest edge of the polygon, within the polygon's - // plane. + // Now we have edge_dist, which is the distance from the sphere center to + // the nearest edge of the polygon, within the polygon's plane. if (edge_dist > from_radius) { // No intersection; the circle is outside the polygon. return NULL; } - // The sphere appears to intersect the polygon. If the edge is less - // than from_radius away, the sphere may be resting on an edge of - // the polygon. Determine how far the center of the sphere must - // remain from the plane, based on its distance from the nearest - // edge. + // The sphere appears to intersect the polygon. If the edge is less than + // from_radius away, the sphere may be resting on an edge of the polygon. + // Determine how far the center of the sphere must remain from the plane, + // based on its distance from the nearest edge. PN_stdfloat max_dist = from_radius; if (edge_dist >= 0.0f) { @@ -558,9 +517,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat into_depth = max_dist - dist; if (moved_from_center) { - // We have to base the depth of intersection on the sphere's final - // resting point, not the point from which we tested the - // intersection. + // We have to base the depth of intersection on the sphere's final resting + // point, not the point from which we tested the intersection. PN_stdfloat orig_dist; get_plane().intersects_line(orig_dist, orig_center, -normal); into_depth = max_dist - orig_dist; @@ -576,13 +534,10 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_line -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a line. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a line. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_line(const CollisionEntry &entry) const { if (_points.size() < 3) { @@ -647,13 +602,10 @@ test_intersection_from_line(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_ray -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a ray. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a ray. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_ray(const CollisionEntry &entry) const { if (_points.size() < 3) { @@ -723,13 +675,10 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_segment -// Access: Public, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a segment. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a segment. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_segment(const CollisionEntry &entry) const { if (_points.size() < 3) { @@ -752,8 +701,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } if (t < 0.0f || t > 1.0f) { - // The intersection point is before the start of the segment or - // after the end of the segment. + // The intersection point is before the start of the segment or after the + // end of the segment. return NULL; } @@ -801,13 +750,10 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_parabola -// Access: Public, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a parabola. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a parabola. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_parabola(const CollisionEntry &entry) const { if (_points.size() < 3) { @@ -832,8 +778,8 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { PN_stdfloat t; if (t1 >= parabola->get_t1() && t1 <= parabola->get_t2()) { if (t2 >= parabola->get_t1() && t2 <= parabola->get_t2()) { - // Both intersection points are within our segment of the - // parabola. Choose the first of the two. + // Both intersection points are within our segment of the parabola. + // Choose the first of the two. t = min(t1, t2); } else { // Only t1 is within our segment. @@ -893,20 +839,17 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::test_intersection_from_box -// Access: Public, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a box. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a box. + */ PT(CollisionEntry) CollisionPolygon:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; DCAST_INTO_R(box, entry.get_from(), 0); - // To make things easier, transform the box into the coordinate - // space of the plane. + // To make things easier, transform the box into the coordinate space of the + // plane. const LMatrix4 &wrt_mat = entry.get_wrt_mat(); LMatrix4 plane_mat = wrt_mat * _to_2d_mat; @@ -945,8 +888,8 @@ test_intersection_from_box(const CollisionEntry &entry) const { return NULL; } - // Now do the same check for the cross products between the box axes - // and the polygon edges. + // Now do the same check for the cross products between the box axes and the + // polygon edges. Points::const_iterator pi; for (pi = _points.begin(); pi != _points.end(); ++pi) { const PointDef &pd = *pi; @@ -990,9 +933,9 @@ test_intersection_from_box(const CollisionEntry &entry) const { LVector3 normal = (has_effective_normal() && box->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); - // Determine which point on the cube will be the interior point. This - // is the calculation that is also used for the plane, which is not - // perfectly applicable, but I suppose it's better than nothing. + // Determine which point on the cube will be the interior point. This is + // the calculation that is also used for the plane, which is not perfectly + // applicable, but I suppose it's better than nothing. LPoint3 interior_point = box->get_center() * wrt_mat + wrt_mat.get_row3(0) * from_extents[0] * ((box_x[1] > 0) - (box_x[1] < 0)) + wrt_mat.get_row3(1) * from_extents[1] * ((box_y[1] > 0) - (box_y[1] < 0)) + @@ -1005,12 +948,10 @@ test_intersection_from_box(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionPolygon:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -1021,18 +962,14 @@ fill_viz_geom() { draw_polygon(_viz_geom, _bounds_viz_geom, _points); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::dist_to_line_segment -// Access: Private, Static -// Description: Returns the linear distance of p to the line segment -// defined by f and t, where v = (t - f).normalize(). -// The result is negative if p is left of the line, -// positive if it is right of the line. If the result -// is positive, it is constrained by endpoints of the -// line segment (i.e. the result might be larger than it -// would be for a straight distance-to-line test). If -// the result is negative, we don't bother. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance of p to the line segment defined by f and t, + * where v = (t - f).normalize(). The result is negative if p is left of the + * line, positive if it is right of the line. If the result is positive, it + * is constrained by endpoints of the line segment (i.e. the result might be + * larger than it would be for a straight distance-to-line test). If the + * result is negative, we don't bother. + */ PN_stdfloat CollisionPolygon:: dist_to_line_segment(const LPoint2 &p, const LPoint2 &f, const LPoint2 &t, @@ -1141,13 +1078,10 @@ dist_to_line_segment(const LPoint2 &p, } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::compute_vectors -// Access: Private, Static -// Description: Now that the _p members of the given points array -// have been computed, go back and compute all of the _v -// members. -//////////////////////////////////////////////////////////////////// +/** + * Now that the _p members of the given points array have been computed, go + * back and compute all of the _v members. + */ void CollisionPolygon:: compute_vectors(Points &points) { size_t num_points = points.size(); @@ -1157,13 +1091,10 @@ compute_vectors(Points &points) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::draw_polygon -// Access: Private -// Description: Fills up the indicated GeomNode with the Geoms to -// draw the polygon indicated with the given set of 2-d -// points. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated GeomNode with the Geoms to draw the polygon + * indicated with the given set of 2-d points. + */ void CollisionPolygon:: draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, const CollisionPolygon::Points &points) const { @@ -1182,41 +1113,39 @@ draw_polygon(GeomNode *viz_geom_node, GeomNode *bounds_viz_geom_node, ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + Points::const_iterator pi; for (pi = points.begin(); pi != points.end(); ++pi) { vertex.add_data3(to_3d((*pi)._p, to_3d_mat)); } - + PT(GeomTrifans) body = new GeomTrifans(Geom::UH_static); body->add_consecutive_vertices(0, points.size()); body->close_primitive(); - + PT(GeomLinestrips) border = new GeomLinestrips(Geom::UH_static); border->add_consecutive_vertices(0, points.size()); border->add_vertex(0); border->close_primitive(); - + PT(Geom) geom1 = new Geom(vdata); geom1->add_primitive(body); - + PT(Geom) geom2 = new Geom(vdata); geom2->add_primitive(border); viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_viz_state()); viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_viz_state()); - + bounds_viz_geom_node->add_geom(geom1, ((CollisionPolygon *)this)->get_solid_bounds_viz_state()); bounds_viz_geom_node->add_geom(geom2, ((CollisionPolygon *)this)->get_wireframe_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::point_is_inside -// Access: Private -// Description: Returns true if the indicated point is within the -// polygon's 2-d space, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated point is within the polygon's 2-d space, + * false otherwise. + */ bool CollisionPolygon:: point_is_inside(const LPoint2 &p, const CollisionPolygon::Points &points) const { // We insist that the polygon be convex. This makes things a bit simpler. @@ -1237,25 +1166,22 @@ point_is_inside(const LPoint2 &p, const CollisionPolygon::Points &points) const return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::dist_to_polygon -// Access: Private -// Description: Returns the linear distance from the 2-d point to the -// nearest part of the polygon defined by the points -// vector. The result is negative if the point is -// within the polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear distance from the 2-d point to the nearest part of the + * polygon defined by the points vector. The result is negative if the point + * is within the polygon. + */ PN_stdfloat CollisionPolygon:: dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const { - // We know that that the polygon is convex and is defined with the - // points in counterclockwise order. Therefore, we simply compare - // the signed distance to each line segment; we ignore any negative - // values, and take the minimum of all the positive values. + // We know that that the polygon is convex and is defined with the points in + // counterclockwise order. Therefore, we simply compare the signed distance + // to each line segment; we ignore any negative values, and take the minimum + // of all the positive values. + + // If all values are negative, the point is within the polygon; we therefore + // return an arbitrary negative result. - // If all values are negative, the point is within the polygon; we - // therefore return an arbitrary negative result. - bool got_dist = false; PN_stdfloat best_dist = -1.0f; @@ -1283,12 +1209,10 @@ dist_to_polygon(const LPoint2 &p, const CollisionPolygon::Points &points) const return best_dist; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::project -// Access: Private -// Description: Projects the polygon onto the given axis, returning -// the center on the line and the half extent. -//////////////////////////////////////////////////////////////////// +/** + * Projects the polygon onto the given axis, returning the center on the line + * and the half extent. + */ void CollisionPolygon:: project(const LVector3 &axis, PN_stdfloat ¢er, PN_stdfloat &extent) const { PN_stdfloat begin, end; @@ -1312,11 +1236,9 @@ project(const LVector3 &axis, PN_stdfloat ¢er, PN_stdfloat &extent) const { extent = cabs((end - begin) * 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::setup_points -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionPolygon:: setup_points(const LPoint3 *begin, const LPoint3 *end) { int num_points = end - begin; @@ -1324,15 +1246,14 @@ setup_points(const LPoint3 *begin, const LPoint3 *end) { _points.clear(); - // Tell the base CollisionPlane class what its plane will be. To do - // this, we must first compute the polygon normal. + // Tell the base CollisionPlane class what its plane will be. To do this, + // we must first compute the polygon normal. LVector3 normal = LVector3::zero(); - // Project the polygon into each of the three major planes and - // calculate the area of each 2-d projection. This becomes the - // polygon normal. This works because the ratio between these - // different areas corresponds to the angle at which the polygon is - // tilted toward each plane. + // Project the polygon into each of the three major planes and calculate the + // area of each 2-d projection. This becomes the polygon normal. This + // works because the ratio between these different areas corresponds to the + // angle at which the polygon is tilted toward each plane. for (int i = 0; i < num_points; i++) { const LPoint3 &p0 = begin[i]; const LPoint3 &p1 = begin[(i + 1) % num_points]; @@ -1374,13 +1295,12 @@ setup_points(const LPoint3 *begin, const LPoint3 *end) { set_plane(LPlane(normal, begin[0])); - // Construct a matrix that rotates the points from the (X,0,Z) plane - // into the 3-d plane. + // Construct a matrix that rotates the points from the (X,0,Z) plane into + // the 3-d plane. LMatrix4 to_3d_mat; calc_to_3d_mat(to_3d_mat); - // And the inverse matrix rotates points from 3-d space into the 2-d - // plane. + // And the inverse matrix rotates points from 3-d space into the 2-d plane. _to_2d_mat.invert_from(to_3d_mat); // Now project all of the points onto the 2-d plane. @@ -1412,13 +1332,10 @@ setup_points(const LPoint3 *begin, const LPoint3 *end) { compute_vectors(_points); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::legacy_to_3d -// Access: Private -// Description: Converts the indicated point to 3-d space according -// to the way CollisionPolygons used to be stored in bam -// files prior to 4.9. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated point to 3-d space according to the way + * CollisionPolygons used to be stored in bam files prior to 4.9. + */ LPoint3 CollisionPolygon:: legacy_to_3d(const LVecBase2 &point2d, int axis) const { nassertr(!point2d.is_nan(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -1446,20 +1363,16 @@ legacy_to_3d(const LVecBase2 &point2d, int axis) const { return LPoint3(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::clip_polygon -// Access: Private -// Description: Clips the source_points of the polygon by the -// indicated clipping plane, and modifies new_points to -// reflect the new set of clipped points (but does not -// compute the vectors in new_points). -// -// The return value is true if the set of points is -// unmodified (all points are behind the clip plane), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Clips the source_points of the polygon by the indicated clipping plane, and + * modifies new_points to reflect the new set of clipped points (but does not + * compute the vectors in new_points). + * + * The return value is true if the set of points is unmodified (all points are + * behind the clip plane), or false otherwise. + */ bool CollisionPolygon:: -clip_polygon(CollisionPolygon::Points &new_points, +clip_polygon(CollisionPolygon::Points &new_points, const CollisionPolygon::Points &source_points, const LPlane &plane) const { new_points.clear(); @@ -1470,19 +1383,19 @@ clip_polygon(CollisionPolygon::Points &new_points, LPoint3 from3d; LVector3 delta3d; if (!plane.intersects_plane(from3d, delta3d, get_plane())) { - // The clipping plane is parallel to the polygon. The polygon is - // either all in or all out. + // The clipping plane is parallel to the polygon. The polygon is either + // all in or all out. if (plane.dist_to_plane(get_plane().get_point()) < 0.0) { - // A point within the polygon is behind the clipping plane: the - // polygon is all in. + // A point within the polygon is behind the clipping plane: the polygon + // is all in. new_points = source_points; return true; } return false; } - // Project the line of intersection into the 2-d plane. Now we have - // a 2-d clipping line. + // Project the line of intersection into the 2-d plane. Now we have a 2-d + // clipping line. LPoint2 from2d = to_2d(from3d); LVector2 delta2d = to_2d(delta3d); @@ -1490,13 +1403,12 @@ clip_polygon(CollisionPolygon::Points &new_points, PN_stdfloat b = delta2d[0]; PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; - // Now walk through the points. Any point on the left of our line - // gets removed, and the line segment clipped at the point of - // intersection. + // Now walk through the points. Any point on the left of our line gets + // removed, and the line segment clipped at the point of intersection. - // We might increase the number of vertices by as many as 1, if the - // plane clips off exactly one corner. (We might also decrease the - // number of vertices, or keep them the same number.) + // We might increase the number of vertices by as many as 1, if the plane + // clips off exactly one corner. (We might also decrease the number of + // vertices, or keep them the same number.) new_points.reserve(source_points.size() + 1); LPoint2 last_point = source_points.back()._p; @@ -1507,12 +1419,12 @@ clip_polygon(CollisionPolygon::Points &new_points, const LPoint2 &this_point = (*pi)._p; bool this_is_in = !is_right(this_point - from2d, delta2d); - // There appears to be a compiler bug in gcc 4.0: we need to - // extract this comparison outside of the if statement. + // There appears to be a compiler bug in gcc 4.0: we need to extract this + // comparison outside of the if statement. bool crossed_over = (this_is_in != last_is_in); if (crossed_over) { - // We have just crossed over the clipping line. Find the point - // of intersection. + // We have just crossed over the clipping line. Find the point of + // intersection. LVector2 d = this_point - last_point; PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { @@ -1522,7 +1434,7 @@ clip_polygon(CollisionPolygon::Points &new_points, new_points.push_back(PointDef(p[0], p[1])); last_is_in = this_is_in; } - } + } if (this_is_in) { // We are behind the clipping line. Keep the point. @@ -1537,19 +1449,15 @@ clip_polygon(CollisionPolygon::Points &new_points, return all_in; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::apply_clip_plane -// Access: Private -// Description: Clips the polygon by all of the clip planes named in -// the clip plane attribute and fills new_points up with -// the resulting points. -// -// The return value is true if the set of points is -// unmodified (all points are behind all the clip -// planes), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Clips the polygon by all of the clip planes named in the clip plane + * attribute and fills new_points up with the resulting points. + * + * The return value is true if the set of points is unmodified (all points are + * behind all the clip planes), or false otherwise. + */ bool CollisionPolygon:: -apply_clip_plane(CollisionPolygon::Points &new_points, +apply_clip_plane(CollisionPolygon::Points &new_points, const ClipPlaneAttrib *cpa, const TransformState *net_transform) const { bool all_in = true; @@ -1561,9 +1469,9 @@ apply_clip_plane(CollisionPolygon::Points &new_points, NodePath plane_path = cpa->get_on_plane(i); PlaneNode *plane_node = DCAST(PlaneNode, plane_path.node()); if ((plane_node->get_clip_effect() & PlaneNode::CE_collision) != 0) { - CPT(TransformState) new_transform = + CPT(TransformState) new_transform = net_transform->invert_compose(plane_path.get_net_transform()); - + LPlane plane = plane_node->get_plane() * new_transform->get_mat(); if (first_plane) { first_plane = false; @@ -1587,12 +1495,10 @@ apply_clip_plane(CollisionPolygon::Points &new_points, return all_in; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionPolygon:: write_datagram(BamWriter *manager, Datagram &me) { CollisionPlane::write_datagram(manager, me); @@ -1604,14 +1510,11 @@ write_datagram(BamWriter *manager, Datagram &me) { _to_2d_mat.write_datagram(me); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionPolygon:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionPlane::fillin(scan, manager); @@ -1627,9 +1530,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _to_2d_mat.read_datagram(scan); if (manager->get_file_minor_ver() < 13) { - // Before bam version 6.13, we were inadvertently storing - // CollisionPolygon vertices clockwise, instead of - // counter-clockwise. Correct that by re-projecting. + // Before bam version 6.13, we were inadvertently storing CollisionPolygon + // vertices clockwise, instead of counter-clockwise. Correct that by re- + // projecting. if (_points.size() >= 3) { LMatrix4 to_3d_mat; rederive_to_3d_mat(to_3d_mat); @@ -1649,11 +1552,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::make_CollisionPolygon -// Access: Protected -// Description: Factory method to generate a CollisionPolygon object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPolygon object + */ TypedWritable* CollisionPolygon:: make_CollisionPolygon(const FactoryParams ¶ms) { CollisionPolygon *me = new CollisionPolygon; @@ -1665,14 +1566,10 @@ make_CollisionPolygon(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionPolygon::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionPolygon object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionPolygon object + */ void CollisionPolygon:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CollisionPolygon); } - - diff --git a/panda/src/collide/collisionPolygon.h b/panda/src/collide/collisionPolygon.h index e200be8407..147920f580 100644 --- a/panda/src/collide/collisionPolygon.h +++ b/panda/src/collide/collisionPolygon.h @@ -1,16 +1,15 @@ -// Filename: collisionPolygon.h -// Created by: drose (25Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionPolygon.h + * @author drose + * @date 2000-04-25 + */ #ifndef COLLISIONPOLYGON_H #define COLLISIONPOLYGON_H @@ -24,10 +23,9 @@ class GeomNode; -//////////////////////////////////////////////////////////////////// -// Class : CollisionPolygon -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_COLLIDE CollisionPolygon : public CollisionPlane { PUBLISHED: INLINE CollisionPolygon(const LVecBase3 &a, const LVecBase3 &b, @@ -105,7 +103,7 @@ private: static PN_stdfloat dist_to_line_segment(const LPoint2 &p, const LPoint2 &f, const LPoint2 &t, const LVector2 &v); - + private: class PointDef { public: @@ -176,5 +174,3 @@ private: #include "collisionPolygon.I" #endif - - diff --git a/panda/src/collide/collisionRay.I b/panda/src/collide/collisionRay.I index 2cefe9855c..b224835c2f 100644 --- a/panda/src/collide/collisionRay.I +++ b/panda/src/collide/collisionRay.I @@ -1,26 +1,21 @@ -// Filename: collisionRay.I -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRay.I + * @author drose + * @date 2000-06-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::Default Constructor -// Access: Public -// Description: Creates an invalid ray. This isn't terribly useful; -// it's expected that the user will subsequently adjust -// the ray via set_origin()/set_direction() or -// set_from_lens(). -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid ray. This isn't terribly useful; it's expected that the + * user will subsequently adjust the ray via set_origin()/set_direction() or + * set_from_lens(). + */ INLINE CollisionRay:: CollisionRay() : _origin(LPoint3(0.0, 0.0, 0.0)), @@ -28,11 +23,9 @@ CollisionRay() : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionRay:: CollisionRay(const LPoint3 &origin, const LVector3 &direction) : _origin(origin), _direction(direction) @@ -40,11 +33,9 @@ CollisionRay(const LPoint3 &origin, const LVector3 &direction) : nassertv(_direction != LPoint3::zero()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionRay:: CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz) : @@ -53,11 +44,9 @@ CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz, nassertv(_direction != LPoint3::zero()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionRay:: CollisionRay(const CollisionRay ©) : CollisionSolid(copy), @@ -66,11 +55,9 @@ CollisionRay(const CollisionRay ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_origin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionRay:: set_origin(const LPoint3 &origin) { _origin = origin; @@ -78,31 +65,25 @@ set_origin(const LPoint3 &origin) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_origin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionRay:: set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_origin(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::get_origin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionRay:: get_origin() const { return _origin; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_direction -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionRay:: set_direction(const LVector3 &direction) { _direction = direction; @@ -111,35 +92,28 @@ set_direction(const LVector3 &direction) { nassertv(_direction != LPoint3::zero()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_direction -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionRay:: set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_direction(LVector3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::get_direction -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVector3 &CollisionRay:: get_direction() const { return _direction; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_from_lens -// Access: Public -// Description: Accepts a LensNode and a 2-d point in the range -// [-1,1]. Sets the CollisionRay so that it begins at -// the LensNode's near plane and extends to -// infinity, making it suitable for picking objects from -// the screen given a camera and a mouse location. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a LensNode and a 2-d point in the range [-1,1]. Sets the + * CollisionRay so that it begins at the LensNode's near plane and extends to + * infinity, making it suitable for picking objects from the screen given a + * camera and a mouse location. + */ INLINE bool CollisionRay:: set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) { return set_from_lens(camera, LPoint2(px, py)); diff --git a/panda/src/collide/collisionRay.cxx b/panda/src/collide/collisionRay.cxx index 9d5c229331..05aa445aa1 100644 --- a/panda/src/collide/collisionRay.cxx +++ b/panda/src/collide/collisionRay.cxx @@ -1,16 +1,15 @@ -// Filename: collisionRay.cxx -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRay.cxx + * @author drose + * @date 2000-06-22 + */ #include "collisionRay.h" #include "collisionHandler.h" @@ -32,31 +31,25 @@ TypeHandle CollisionRay::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionRay:: make_copy() { return new CollisionRay(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionRay:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_ray(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionRay:: xform(const LMatrix4 &mat) { _origin = _origin * mat; @@ -65,41 +58,32 @@ xform(const LMatrix4 &mat) { CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionRay:: get_collision_origin() const { return get_origin(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionRay:: output(ostream &out) const { out << "ray, o (" << get_origin() << "), d (" << get_direction() << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::set_from_lens -// Access: Public -// Description: Accepts a LensNode and a 2-d point in the range -// [-1,1]. Sets the CollisionRay so that it begins at -// the LensNode's near plane and extends to -// infinity, making it suitable for picking objects from -// the screen given a camera and a mouse location. -// -// Returns true if the point was acceptable, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a LensNode and a 2-d point in the range [-1,1]. Sets the + * CollisionRay so that it begins at the LensNode's near plane and extends to + * infinity, making it suitable for picking objects from the screen given a + * camera and a mouse location. + * + * Returns true if the point was acceptable, false otherwise. + */ bool CollisionRay:: set_from_lens(LensNode *camera, const LPoint2 &point) { Lens *lens = camera->get_lens(); @@ -121,22 +105,18 @@ set_from_lens(LensNode *camera, const LPoint2 &point) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionRay:: compute_internal_bounds() const { return new BoundingLine(_origin, _origin + _direction); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionRay:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -152,11 +132,11 @@ fill_viz_geom() { Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + for (int i = 0; i < num_points; i++) { double t = ((double)i / (double)num_points); vertex.add_data3(get_origin() + t * scale * get_direction()); - + color.add_data4(LColor(1.0f, 1.0f, 1.0f, 1.0f) + t * LColor(0.0f, 0.0f, 0.0f, -1.0f)); } @@ -164,31 +144,26 @@ fill_viz_geom() { PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); line->add_next_vertices(num_points); line->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(line); - + _viz_geom->add_geom(geom, get_other_viz_state()); _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionRay. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CollisionRay. + */ void CollisionRay:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CollisionRay:: write_datagram(BamWriter *manager, Datagram &dg) { CollisionSolid::write_datagram(manager, dg); @@ -196,14 +171,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { _direction.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionRay is encountered -// in the Bam file. It should create the CollisionRay -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CollisionRay is encountered in the Bam file. It should create the + * CollisionRay and extract its information from the file. + */ TypedWritable *CollisionRay:: make_from_bam(const FactoryParams ¶ms) { CollisionRay *node = new CollisionRay(); @@ -216,13 +188,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRay::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionRay. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CollisionRay. + */ void CollisionRay:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionRay.h b/panda/src/collide/collisionRay.h index 09650c7e78..515ed7347d 100644 --- a/panda/src/collide/collisionRay.h +++ b/panda/src/collide/collisionRay.h @@ -1,16 +1,15 @@ -// Filename: collisionRay.h -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRay.h + * @author drose + * @date 2000-06-22 + */ #ifndef COLLISIONRAY_H #define COLLISIONRAY_H @@ -20,14 +19,11 @@ #include "collisionSolid.h" #include "lensNode.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionRay -// Description : An infinite ray, with a specific origin and -// direction. It begins at its origin and continues in -// one direction to infinity, and it has no radius. -// Useful for picking from a window, or for gravity -// effects. -//////////////////////////////////////////////////////////////////// +/** + * An infinite ray, with a specific origin and direction. It begins at its + * origin and continues in one direction to infinity, and it has no radius. + * Useful for picking from a window, or for gravity effects. + */ class EXPCL_PANDA_COLLIDE CollisionRay : public CollisionSolid { PUBLISHED: INLINE CollisionRay(); @@ -101,5 +97,3 @@ private: #include "collisionRay.I" #endif - - diff --git a/panda/src/collide/collisionRecorder.I b/panda/src/collide/collisionRecorder.I index 7752cc00d7..09f1fd26e3 100644 --- a/panda/src/collide/collisionRecorder.I +++ b/panda/src/collide/collisionRecorder.I @@ -1,14 +1,12 @@ -// Filename: collisionRecorder.I -// Created by: drose (17Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRecorder.I + * @author drose + * @date 2003-04-17 + */ diff --git a/panda/src/collide/collisionRecorder.cxx b/panda/src/collide/collisionRecorder.cxx index 54996481d1..09d87a9971 100644 --- a/panda/src/collide/collisionRecorder.cxx +++ b/panda/src/collide/collisionRecorder.cxx @@ -1,16 +1,15 @@ -// Filename: collisionRecorder.cxx -// Created by: drose (16Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRecorder.cxx + * @author drose + * @date 2003-04-16 + */ #include "collisionRecorder.h" #include "collisionTraverser.h" @@ -19,11 +18,9 @@ TypeHandle CollisionRecorder::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionRecorder:: CollisionRecorder() { _num_missed = 0; @@ -31,11 +28,9 @@ CollisionRecorder() { _trav = (CollisionTraverser *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionRecorder:: ~CollisionRecorder() { if (_trav != (CollisionTraverser *)NULL) { @@ -43,39 +38,31 @@ CollisionRecorder:: } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionRecorder:: output(ostream &out) const { out << "tested " << _num_missed + _num_detected << ", detected " << _num_detected << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::begin_traversal -// Access: Public, Virtual -// Description: This method is called at the beginning of a -// CollisionTraverser::traverse() call. It is provided -// as a hook for the derived class to reset its state as -// appropriate. -//////////////////////////////////////////////////////////////////// +/** + * This method is called at the beginning of a CollisionTraverser::traverse() + * call. It is provided as a hook for the derived class to reset its state as + * appropriate. + */ void CollisionRecorder:: begin_traversal() { _num_missed = 0; _num_detected = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::collision_tested -// Access: Public, Virtual -// Description: This method is called when a pair of collision solids -// have passed all bounding-volume tests and have been -// tested for a collision. The detected value is set -// true if a collision was detected, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method is called when a pair of collision solids have passed all + * bounding-volume tests and have been tested for a collision. The detected + * value is set true if a collision was detected, false otherwise. + */ void CollisionRecorder:: collision_tested(const CollisionEntry &entry, bool detected) { if (detected) { @@ -85,14 +72,11 @@ collision_tested(const CollisionEntry &entry, bool detected) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionRecorder::end_traversal -// Access: Public, Virtual -// Description: This method is called at the end of a -// CollisionTraverser::traverse() call. It is provided -// as a hook for the derived class to finalize its state -// as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * This method is called at the end of a CollisionTraverser::traverse() call. + * It is provided as a hook for the derived class to finalize its state as + * appropriate. + */ void CollisionRecorder:: end_traversal() { } diff --git a/panda/src/collide/collisionRecorder.h b/panda/src/collide/collisionRecorder.h index c7716b6df1..a9ceefa250 100644 --- a/panda/src/collide/collisionRecorder.h +++ b/panda/src/collide/collisionRecorder.h @@ -1,16 +1,15 @@ -// Filename: collisionRecorder.h -// Created by: drose (16Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionRecorder.h + * @author drose + * @date 2003-04-16 + */ #ifndef COLLISIONRECORDER_H #define COLLISIONRECORDER_H @@ -24,13 +23,11 @@ class CollisionEntry; #ifdef DO_COLLISION_RECORDING -//////////////////////////////////////////////////////////////////// -// Class : CollisionRecorder -// Description : This class is used to help debug the work the -// collisions system is doing. It is a virtual base -// class that just provides an interface for recording -// collisions tested and detected each frame. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to help debug the work the collisions system is doing. + * It is a virtual base class that just provides an interface for recording + * collisions tested and detected each frame. + */ class EXPCL_PANDA_COLLIDE CollisionRecorder : public TypedObject { protected: CollisionRecorder(); @@ -76,4 +73,3 @@ private: #endif - diff --git a/panda/src/collide/collisionSegment.I b/panda/src/collide/collisionSegment.I index cdb1e0d983..c02d7631cb 100644 --- a/panda/src/collide/collisionSegment.I +++ b/panda/src/collide/collisionSegment.I @@ -1,26 +1,21 @@ -// Filename: collisionSegment.I -// Created by: drose (30Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSegment.I + * @author drose + * @date 2001-01-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::Default Constructor -// Access: Public -// Description: Creates an invalid segment. This isn't terribly useful; -// it's expected that the user will subsequently adjust -// the segment via set_origin()/set_direction() or -// set_from_lens(). -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid segment. This isn't terribly useful; it's expected that + * the user will subsequently adjust the segment via + * set_origin()/set_direction() or set_from_lens(). + */ INLINE CollisionSegment:: CollisionSegment() : _a(LPoint3(0.0, 0.0, 0.0)), @@ -28,11 +23,9 @@ CollisionSegment() : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSegment:: CollisionSegment(const LPoint3 &a, const LPoint3 &b) : _a(a), _b(b) @@ -40,11 +33,9 @@ CollisionSegment(const LPoint3 &a, const LPoint3 &b) : nassertv(_a != _b); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSegment:: CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz) : @@ -53,11 +44,9 @@ CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, nassertv(_a != _b); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSegment:: CollisionSegment(const CollisionSegment ©) : CollisionSolid(copy), @@ -66,46 +55,38 @@ CollisionSegment(const CollisionSegment ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_point_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSegment:: set_point_a(const LPoint3 &a) { _a = a; mark_internal_bounds_stale(); mark_viz_stale(); - // We don't assert here that a != b, on the assumption that you - // might be about to change both at once, and you'll probably start - // by changing a first. + // We don't assert here that a != b, on the assumption that you might be + // about to change both at once, and you'll probably start by changing a + // first. } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_point_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSegment:: set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_a(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::get_point_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionSegment:: get_point_a() const { return _a; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_point_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSegment:: set_point_b(const LPoint3 &b) { _b = b; @@ -114,35 +95,28 @@ set_point_b(const LPoint3 &b) { nassertv(_a != _b); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_point_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSegment:: set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_b(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::get_point_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionSegment:: get_point_b() const { return _b; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_from_lens -// Access: Public -// Description: Accepts a LensNode and a 2-d point in the range -// [-1,1]. Sets the CollisionSegment so that it begins at -// the LensNode's near plane and extends to the -// far plane, making it suitable for picking objects -// from the screen given a camera and a mouse location. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a LensNode and a 2-d point in the range [-1,1]. Sets the + * CollisionSegment so that it begins at the LensNode's near plane and extends + * to the far plane, making it suitable for picking objects from the screen + * given a camera and a mouse location. + */ INLINE bool CollisionSegment:: set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) { return set_from_lens(camera, LPoint2(px, py)); diff --git a/panda/src/collide/collisionSegment.cxx b/panda/src/collide/collisionSegment.cxx index af4444a0b3..3fa0fe0524 100644 --- a/panda/src/collide/collisionSegment.cxx +++ b/panda/src/collide/collisionSegment.cxx @@ -1,17 +1,15 @@ -// Filename: collisionSegment.cxx -// Created by: drose (30Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSegment.cxx + * @author drose + * @date 2001-01-30 + */ #include "collisionSegment.h" #include "collisionHandler.h" @@ -36,31 +34,25 @@ TypeHandle CollisionSegment::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionSegment:: make_copy() { return new CollisionSegment(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSegment:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_segment(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionSegment:: xform(const LMatrix4 &mat) { _a = _a * mat; @@ -69,41 +61,32 @@ xform(const LMatrix4 &mat) { CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionSegment:: get_collision_origin() const { return get_point_a(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionSegment:: output(ostream &out) const { out << "segment, a (" << _a << "), b (" << _b << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::set_from_lens -// Access: Public -// Description: Accepts a LensNode and a 2-d point in the range -// [-1,1]. Sets the CollisionSegment so that it begins at -// the LensNode's near plane and extends to the -// far plane, making it suitable for picking objects -// from the screen given a camera and a mouse location. -// -// Returns true if the point was acceptable, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a LensNode and a 2-d point in the range [-1,1]. Sets the + * CollisionSegment so that it begins at the LensNode's near plane and extends + * to the far plane, making it suitable for picking objects from the screen + * given a camera and a mouse location. + * + * Returns true if the point was acceptable, false otherwise. + */ bool CollisionSegment:: set_from_lens(LensNode *camera, const LPoint2 &point) { Lens *proj = camera->get_lens(); @@ -121,18 +104,15 @@ set_from_lens(LensNode *camera, const LPoint2 &point) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionSegment:: compute_internal_bounds() const { LVector3 pdelta = _b - _a; - // If p1 and p2 are sufficiently close, just put a sphere around - // them. + // If p1 and p2 are sufficiently close, just put a sphere around them. PN_stdfloat d2 = pdelta.length_squared(); if (d2 < collision_parabola_bounds_threshold * collision_parabola_bounds_threshold) { LPoint3 pmid = (_a + _b) * 0.5f; @@ -142,9 +122,9 @@ compute_internal_bounds() const { LMatrix4 from_segment; look_at(from_segment, pdelta, LPoint3(0,0,1), CS_zup_right); from_segment.set_row(3, _a); - + PN_stdfloat max_y = sqrt(d2) + 0.01; - PT(BoundingHexahedron) volume = + PT(BoundingHexahedron) volume = new BoundingHexahedron(LPoint3(-0.01, max_y, -0.01), LPoint3(0.01, max_y, -0.01), LPoint3(0.01, max_y, 0.01), LPoint3(-0.01, max_y, 0.01), LPoint3(-0.01, -0.01, -0.01), LPoint3(0.01, 0.01, -0.01), @@ -154,12 +134,10 @@ compute_internal_bounds() const { return volume.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionSegment:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -171,38 +149,33 @@ fill_viz_geom() { ("collision", GeomVertexFormat::get_v3cp(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + vertex.add_data3(_a); vertex.add_data3(_b); - + PT(GeomLines) line = new GeomLines(Geom::UH_static); line->add_next_vertices(2); line->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(line); - + _viz_geom->add_geom(geom, get_other_viz_state()); _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionSegment. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CollisionSegment. + */ void CollisionSegment:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CollisionSegment:: write_datagram(BamWriter *manager, Datagram &dg) { CollisionSolid::write_datagram(manager, dg); @@ -210,14 +183,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { _b.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionSegment is encountered -// in the Bam file. It should create the CollisionSegment -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CollisionSegment is encountered in the Bam file. It should create the + * CollisionSegment and extract its information from the file. + */ TypedWritable *CollisionSegment:: make_from_bam(const FactoryParams ¶ms) { CollisionSegment *node = new CollisionSegment(); @@ -230,13 +200,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSegment::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionSegment. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CollisionSegment. + */ void CollisionSegment:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionSegment.h b/panda/src/collide/collisionSegment.h index 031446cfb6..e2e00b14e5 100644 --- a/panda/src/collide/collisionSegment.h +++ b/panda/src/collide/collisionSegment.h @@ -1,16 +1,15 @@ -// Filename: collisionSegment.h -// Created by: drose (30Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSegment.h + * @author drose + * @date 2001-01-30 + */ #ifndef COLLISIONSEGMENT_H #define COLLISIONSEGMENT_H @@ -21,17 +20,14 @@ class LensNode; -//////////////////////////////////////////////////////////////////// -// Class : CollisionSegment -// Description : A finite line segment, with two specific endpoints -// but no thickness. It's similar to a CollisionRay, -// except it does not continue to infinity. -// -// It does have an ordering, from point A to point B. -// If more than a single point of the segment is -// intersecting a solid, the reported intersection point -// is generally the closest on the segment to point A. -//////////////////////////////////////////////////////////////////// +/** + * A finite line segment, with two specific endpoints but no thickness. It's + * similar to a CollisionRay, except it does not continue to infinity. + * + * It does have an ordering, from point A to point B. If more than a single + * point of the segment is intersecting a solid, the reported intersection + * point is generally the closest on the segment to point A. + */ class EXPCL_PANDA_COLLIDE CollisionSegment : public CollisionSolid { PUBLISHED: INLINE CollisionSegment(); @@ -106,5 +102,3 @@ private: #include "collisionSegment.I" #endif - - diff --git a/panda/src/collide/collisionSolid.I b/panda/src/collide/collisionSolid.I index 3242b86d77..9308ca77e2 100644 --- a/panda/src/collide/collisionSolid.I +++ b/panda/src/collide/collisionSolid.I @@ -1,28 +1,22 @@ -// Filename: collisionSolid.I -// Created by: drose (27Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSolid.I + * @author drose + * @date 2000-06-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::set_tangible -// Access: Published -// Description: Sets the current state of the 'tangible' flag. Set -// this true to make the solid tangible, so that a -// CollisionHandlerPusher will not allow another object -// to intersect it, or false to make it intangible, so -// that a CollisionHandlerPusher will ignore it except -// to throw an event. -//////////////////////////////////////////////////////////////////// +/** + * Sets the current state of the 'tangible' flag. Set this true to make the + * solid tangible, so that a CollisionHandlerPusher will not allow another + * object to intersect it, or false to make it intangible, so that a + * CollisionHandlerPusher will ignore it except to throw an event. + */ INLINE void CollisionSolid:: set_tangible(bool tangible) { LightMutexHolder holder(_lock); @@ -34,33 +28,25 @@ set_tangible(bool tangible) { _flags |= F_viz_geom_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::is_tangible -// Access: Published -// Description: Returns whether the solid is considered 'tangible' or -// not. An intangible solid has no effect in a -// CollisionHandlerPusher (except to throw an event); -// it's useful for defining 'trigger' planes and -// spheres, that cause an effect when passed through. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the solid is considered 'tangible' or not. An intangible + * solid has no effect in a CollisionHandlerPusher (except to throw an event); + * it's useful for defining 'trigger' planes and spheres, that cause an effect + * when passed through. + */ INLINE bool CollisionSolid:: is_tangible() const { LightMutexHolder holder(_lock); return do_is_tangible(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::set_effective_normal -// Access: Published -// Description: Records a false normal for this CollisionSolid that -// will be reported by the collision system with all -// collisions into it, instead of its actual normal. -// This is useful as a workaround for the problem of an -// avatar wanting to stand on a sloping ground; by -// storing a false normal, the ground appears to be -// perfectly level, and the avatar does not tend to -// slide down it. -//////////////////////////////////////////////////////////////////// +/** + * Records a false normal for this CollisionSolid that will be reported by the + * collision system with all collisions into it, instead of its actual normal. + * This is useful as a workaround for the problem of an avatar wanting to + * stand on a sloping ground; by storing a false normal, the ground appears to + * be perfectly level, and the avatar does not tend to slide down it. + */ INLINE void CollisionSolid:: set_effective_normal(const LVector3 &effective_normal) { LightMutexHolder holder(_lock); @@ -68,37 +54,29 @@ set_effective_normal(const LVector3 &effective_normal) { _flags |= F_effective_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::clear_effective_normal -// Access: Published -// Description: Removes the normal previously set by -// set_effective_normal(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the normal previously set by set_effective_normal(). + */ INLINE void CollisionSolid:: clear_effective_normal() { LightMutexHolder holder(_lock); _flags &= ~F_effective_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::has_effective_normal -// Access: Published -// Description: Returns true if a special normal was set by -// set_effective_normal(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a special normal was set by set_effective_normal(), false + * otherwise. + */ INLINE bool CollisionSolid:: has_effective_normal() const { LightMutexHolder holder(_lock); return do_has_effective_normal(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_effective_normal -// Access: Published -// Description: Returns the normal that was set by -// set_effective_normal(). It is an error to call this -// unless has_effective_normal() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the normal that was set by set_effective_normal(). It is an error + * to call this unless has_effective_normal() returns true. + */ INLINE const LVector3 &CollisionSolid:: get_effective_normal() const { LightMutexHolder holder(_lock); @@ -106,21 +84,17 @@ get_effective_normal() const { return _effective_normal; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::set_respect_effective_normal -// Access: Published -// Description: This is only meaningful for CollisionSolids that will -// be added to a traverser as colliders. It is normally -// true, but if set false, it means that this particular -// solid does not care about the "effective" normal of -// other solids it meets, but rather always uses the -// true normal. -//////////////////////////////////////////////////////////////////// +/** + * This is only meaningful for CollisionSolids that will be added to a + * traverser as colliders. It is normally true, but if set false, it means + * that this particular solid does not care about the "effective" normal of + * other solids it meets, but rather always uses the true normal. + */ INLINE void CollisionSolid:: set_respect_effective_normal(bool respect_effective_normal) { LightMutexHolder holder(_lock); - // For historical reasons, the bit we store is the opposite of the - // bool flag we present. + // For historical reasons, the bit we store is the opposite of the bool flag + // we present. if (respect_effective_normal) { _flags &= ~F_ignore_effective_normal; } else { @@ -128,62 +102,49 @@ set_respect_effective_normal(bool respect_effective_normal) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_respect_effective_normal -// Access: Published -// Description: See set_respect_effective_normal(). -//////////////////////////////////////////////////////////////////// +/** + * See set_respect_effective_normal(). + */ INLINE bool CollisionSolid:: get_respect_effective_normal() const { LightMutexHolder holder(_lock); return (_flags & F_ignore_effective_normal) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::do_is_tangible -// Access: Protected -// Description: Returns whether the solid is considered 'tangible' or -// not. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the solid is considered 'tangible' or not. Assumes the + * lock is already held. + */ INLINE bool CollisionSolid:: do_is_tangible() const { return (_flags & F_tangible) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::do_has_effective_normal -// Access: Protected -// Description: Returns true if a special normal was set by -// set_effective_normal(), false otherwise. Assumes the -// lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a special normal was set by set_effective_normal(), false + * otherwise. Assumes the lock is already held. + */ INLINE bool CollisionSolid:: do_has_effective_normal() const { return respect_effective_normal && (_flags & F_effective_normal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::mark_internal_bounds_stale -// Access: Protected -// Description: Should be called by a derived class to mark the -// internal bounding volume stale, so that -// recompute_internal_bounds() will be called when the -// bounding volume is next requested. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to mark the internal bounding volume + * stale, so that recompute_internal_bounds() will be called when the bounding + * volume is next requested. + */ INLINE void CollisionSolid:: mark_internal_bounds_stale() { LightMutexHolder holder(_lock); _flags |= F_internal_bounds_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::mark_viz_stale -// Access: Protected -// Description: Called internally when the visualization may have -// been compromised by some change to internal state and -// will need to be recomputed the next time it is -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the visualization may have been compromised by some + * change to internal state and will need to be recomputed the next time it is + * rendered. + */ INLINE void CollisionSolid:: mark_viz_stale() { LightMutexHolder holder(_lock); diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index 6c3d38d858..54a4d36a3f 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -1,16 +1,15 @@ -// Filename: collisionSolid.cxx -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSolid.cxx + * @author drose + * @date 2000-04-24 + */ #include "collisionSolid.h" #include "config_collide.h" @@ -39,21 +38,17 @@ PStatCollector CollisionSolid::_test_pcollector( "Collision Tests:CollisionSolid"); TypeHandle CollisionSolid::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid:: CollisionSolid() : _lock("CollisionSolid") { _flags = F_viz_geom_stale | F_tangible | F_internal_bounds_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid:: CollisionSolid(const CollisionSolid ©) : CopyOnWriteObject(copy), @@ -65,30 +60,24 @@ CollisionSolid(const CollisionSolid ©) : _flags |= F_viz_geom_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid:: ~CollisionSolid() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) CollisionSolid:: make_cow_copy() { return make_copy(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_bounds -// Access: Protected -// Description: Returns the solid's bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the solid's bounding volume. + */ CPT(BoundingVolume) CollisionSolid:: get_bounds() const { LightMutexHolder holder(_lock); @@ -99,11 +88,9 @@ get_bounds() const { return _internal_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::set_bounds -// Access: Protected -// Description: Returns the solid's bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the solid's bounding volume. + */ void CollisionSolid:: set_bounds(const BoundingVolume &bounding_volume) { LightMutexHolder holder(_lock); @@ -111,26 +98,21 @@ set_bounds(const BoundingVolume &bounding_volume) { ((CollisionSolid *)this)->_flags &= ~F_internal_bounds_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection -// Access: Public, Virtual -// Description: Tests for a collision between this object (which is -// also the "from" object in the entry) and the "into" -// object. If a collision is detected, returns a new -// CollisionEntry object that records the collision; -// otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Tests for a collision between this object (which is also the "from" object + * in the entry) and the "into" object. If a collision is detected, returns a + * new CollisionEntry object that records the collision; otherwise, returns + * NULL. + */ PT(CollisionEntry) CollisionSolid:: test_intersection(const CollisionEntry &) const { report_undefined_from_intersection(get_type()); return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionSolid:: xform(const LMatrix4 &mat) { LightMutexHolder holder(_lock); @@ -142,14 +124,11 @@ xform(const LMatrix4 &mat) { _flags |= F_viz_geom_stale | F_internal_bounds_stale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_viz -// Access: Public, Virtual -// Description: Returns a GeomNode that may be rendered to visualize -// the CollisionSolid. This is used during the cull -// traversal to render the CollisionNodes that have been -// made visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomNode that may be rendered to visualize the CollisionSolid. + * This is used during the cull traversal to render the CollisionNodes that + * have been made visible. + */ PT(PandaNode) CollisionSolid:: get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) const { LightMutexHolder holder(_lock); @@ -172,67 +151,52 @@ get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) cons } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionSolid:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionSolid:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionSolid:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionSolid:: write(ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionSolid:: compute_internal_bounds() const { return new BoundingSphere; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_sphere -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a sphere. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a sphere. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_sphere(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSphere::get_class_type(), @@ -240,13 +204,10 @@ test_intersection_from_sphere(const CollisionEntry &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_line -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a line. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a line. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_line(const CollisionEntry &) const { report_undefined_intersection_test(CollisionLine::get_class_type(), @@ -254,13 +215,10 @@ test_intersection_from_line(const CollisionEntry &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_ray -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a ray. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a ray. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_ray(const CollisionEntry &) const { report_undefined_intersection_test(CollisionRay::get_class_type(), @@ -268,13 +226,10 @@ test_intersection_from_ray(const CollisionEntry &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_segment -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a segment. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a segment. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_segment(const CollisionEntry &) const { report_undefined_intersection_test(CollisionSegment::get_class_type(), @@ -282,13 +237,10 @@ test_intersection_from_segment(const CollisionEntry &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_parabola -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a parabola. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a parabola. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_parabola(const CollisionEntry &) const { report_undefined_intersection_test(CollisionParabola::get_class_type(), @@ -296,13 +248,10 @@ test_intersection_from_parabola(const CollisionEntry &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::test_intersection_from_box -// Access: Protected, Virtual -// Description: This is part of the double-dispatch implementation of -// test_intersection(). It is called when the "from" -// object is a box. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the double-dispatch implementation of test_intersection(). + * It is called when the "from" object is a box. + */ PT(CollisionEntry) CollisionSolid:: test_intersection_from_box(const CollisionEntry &) const { report_undefined_intersection_test(CollisionBox::get_class_type(), @@ -329,13 +278,10 @@ public: }; #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::report_undefined_intersection_test -// Access: Protected, Static -// Description: Outputs a message the first time an intersection test -// is attempted that isn't defined, and explains a bit -// about what it means. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a message the first time an intersection test is attempted that + * isn't defined, and explains a bit about what it means. + */ void CollisionSolid:: report_undefined_intersection_test(TypeHandle from_type, TypeHandle into_type) { #ifndef NDEBUG @@ -357,13 +303,10 @@ report_undefined_intersection_test(TypeHandle from_type, TypeHandle into_type) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::report_undefined_from_intersection -// Access: Protected, Static -// Description: Outputs a message the first time an intersection test -// is attempted that isn't defined, and explains a bit -// about what it means. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a message the first time an intersection test is attempted that + * isn't defined, and explains a bit about what it means. + */ void CollisionSolid:: report_undefined_from_intersection(TypeHandle from_type) { #ifndef NDEBUG @@ -373,7 +316,7 @@ report_undefined_from_intersection(TypeHandle from_type) { if (reported.insert(from_type).second) { collide_cat.error() << "Invalid attempt to detect collision from " << from_type << "!\n\n" - + "This means that a " << from_type << " object was added to a\n" "CollisionTraverser as if it were a colliding object. However,\n" "no implementation for this kind of object has yet been defined\n" @@ -382,16 +325,14 @@ report_undefined_from_intersection(TypeHandle from_type) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionSolid:: write_datagram(BamWriter *, Datagram &me) { - // For now, we need only 8 bits of flags. If we need to expand this - // later, we will have to increase the bam version. + // For now, we need only 8 bits of flags. If we need to expand this later, + // we will have to increase the bam version. LightMutexHolder holder(_lock); me.add_uint8(_flags); if ((_flags & F_effective_normal) != 0) { @@ -399,14 +340,11 @@ write_datagram(BamWriter *, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionSolid:: fillin(DatagramIterator &scan, BamReader *manager) { _flags = scan.get_uint8(); @@ -420,30 +358,25 @@ fillin(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionSolid:: fill_viz_geom() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_solid_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations in solid. This automatically returns -// the appropriate state according to the setting of -// _tangible. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations in solid. + * This automatically returns the appropriate state according to the setting + * of _tangible. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_solid_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -479,20 +412,17 @@ get_solid_viz_state() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_wireframe_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations in wireframe. This automatically returns -// the appropriate state according to the setting of -// _tangible. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations in wireframe. + * This automatically returns the appropriate state according to the setting + * of _tangible. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_wireframe_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -528,19 +458,16 @@ get_wireframe_viz_state() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_other_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations for things that are neither solid nor -// exactly wireframe, like rays and segments. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations for things + * that are neither solid nor exactly wireframe, like rays and segments. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_other_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -554,20 +481,17 @@ get_other_viz_state() { return base_state; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_solid_bounds_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations in solid. This automatically returns -// the appropriate state according to the setting of -// _tangible. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations in solid. + * This automatically returns the appropriate state according to the setting + * of _tangible. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_solid_bounds_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -603,20 +527,17 @@ get_solid_bounds_viz_state() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_wireframe_bounds_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations in wireframe. This automatically returns -// the appropriate state according to the setting of -// _tangible. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations in wireframe. + * This automatically returns the appropriate state according to the setting + * of _tangible. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_wireframe_bounds_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -630,19 +551,16 @@ get_wireframe_bounds_viz_state() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolid::get_other_bounds_viz_state -// Access: Protected -// Description: Returns a RenderState for rendering collision -// visualizations for things that are neither solid nor -// exactly wireframe, like rays and segments. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering collision visualizations for things + * that are neither solid nor exactly wireframe, like rays and segments. + * + * Assumes the lock is already held. + */ CPT(RenderState) CollisionSolid:: get_other_bounds_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) base_state = (const RenderState *)NULL; if (base_state == (const RenderState *)NULL) { base_state = RenderState::make @@ -655,4 +573,3 @@ get_other_bounds_viz_state() { // intangible. return base_state; } - diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index d9ea395cc2..2aa2c082d3 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -1,16 +1,15 @@ -// Filename: collisionSolid.h -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSolid.h + * @author drose + * @date 2000-04-24 + */ #ifndef COLLISIONSOLID_H #define COLLISIONSOLID_H @@ -34,19 +33,15 @@ class GeomNode; class CollisionNode; class CullTraverserData; -//////////////////////////////////////////////////////////////////// -// Class : CollisionSolid -// Description : The abstract base class for all things that can -// collide with other things in the world, and all the -// things they can collide with (except geometry). -// -// This class and its derivatives really work very -// similarly to the way BoundingVolume and all of its -// derivatives work. There's a different subclass for -// each basic shape of solid, and double-dispatch -// function calls handle the subset of the N*N -// intersection tests that we care about. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for all things that can collide with other things + * in the world, and all the things they can collide with (except geometry). + * + * This class and its derivatives really work very similarly to the way + * BoundingVolume and all of its derivatives work. There's a different + * subclass for each basic shape of solid, and double-dispatch function calls + * handle the subset of the N*N intersection tests that we care about. + */ class EXPCL_PANDA_COLLIDE CollisionSolid : public CopyOnWriteObject { public: CollisionSolid(); @@ -138,8 +133,7 @@ private: LVector3 _effective_normal; PT(BoundingVolume) _internal_bounds; - // Be careful reordering these bits, since they are written to a bam - // file. + // Be careful reordering these bits, since they are written to a bam file. enum Flags { F_tangible = 0x01, F_effective_normal = 0x02, @@ -194,4 +188,3 @@ INLINE ostream &operator << (ostream &out, const CollisionSolid &cs) { #include "collisionSolid.I" #endif - diff --git a/panda/src/collide/collisionSphere.I b/panda/src/collide/collisionSphere.I index a53e319bc9..fa3b103206 100644 --- a/panda/src/collide/collisionSphere.I +++ b/panda/src/collide/collisionSphere.I @@ -1,23 +1,19 @@ -// Filename: collisionSphere.I -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSphere.I + * @author drose + * @date 2000-04-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSphere:: CollisionSphere(const LPoint3 ¢er, PN_stdfloat radius) : _center(center), _radius(radius) @@ -25,11 +21,9 @@ CollisionSphere(const LPoint3 ¢er, PN_stdfloat radius) : nassertv(_radius >= 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSphere:: CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) : _center(cx, cy, cz), _radius(radius) @@ -37,21 +31,16 @@ CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radi nassertv(_radius >= 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::Default constructor -// Access: Protected -// Description: Creates an invalid sphere. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid sphere. Only used when reading from a bam file. + */ INLINE CollisionSphere:: CollisionSphere() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionSphere:: CollisionSphere(const CollisionSphere ©) : CollisionSolid(copy), @@ -60,22 +49,18 @@ CollisionSphere(const CollisionSphere ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionSphere:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::set_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSphere:: set_center(const LPoint3 ¢er) { _center = center; @@ -83,31 +68,25 @@ set_center(const LPoint3 ¢er) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::set_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSphere:: set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_center(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::get_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionSphere:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::set_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionSphere:: set_radius(PN_stdfloat radius) { nassertv(radius >= 0.0f); @@ -116,13 +95,10 @@ set_radius(PN_stdfloat radius) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat CollisionSphere:: get_radius() const { return _radius; } - diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index e69cfbdef0..7c2a5f2c15 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -1,17 +1,15 @@ -// Filename: collisionSphere.cxx -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSphere.cxx + * @author drose + * @date 2000-04-24 + */ #include "collisionSphere.h" #include "collisionLine.h" @@ -39,105 +37,84 @@ PStatCollector CollisionSphere::_test_pcollector( "Collision Tests:CollisionSphere"); TypeHandle CollisionSphere::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionSphere:: make_copy() { return new CollisionSphere(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection(const CollisionEntry &entry) const { return entry.get_into()->test_intersection_from_sphere(entry); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionSphere:: xform(const LMatrix4 &mat) { _center = _center * mat; - // This is a little cheesy and fails miserably in the presence of a - // non-uniform scale. + // This is a little cheesy and fails miserably in the presence of a non- + // uniform scale. LVector3 radius_v = LVector3(_radius, 0.0f, 0.0f) * mat; _radius = length(radius_v); mark_viz_stale(); mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionSphere:: get_collision_origin() const { return get_center(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionSphere:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionSphere:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionSphere:: output(ostream &out) const { out << "sphere, c (" << get_center() << "), r " << get_radius(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionSphere:: compute_internal_bounds() const { return new BoundingSphere(_center, _radius); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; @@ -164,8 +141,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 vec = from_b - into_center; PN_stdfloat dist2 = dot(vec, vec); if (dist2 > (into_radius + from_radius) * (into_radius + from_radius)) { - // No intersection with the current position. Check the delta - // from the previous frame. + // No intersection with the current position. Check the delta from the + // previous frame. CPT(TransformState) wrt_prev_space = entry.get_wrt_prev_space(); LPoint3 from_a = sphere->get_center() * wrt_prev_space->get_mat(); @@ -175,17 +152,17 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { // No intersection. return NULL; } - + if (t2 < 0.0 || t1 > 1.0) { // Both intersection points are before the start of the segment or // after the end of the segment. return NULL; } - + // doubles, not floats, to satisfy min and max templates. actual_t = min(1.0, max(0.0, t1)); contact_point = from_a + actual_t * (from_b - from_a); - + if (t1 < 0.0) { // Point a is within the sphere. The first intersection point is // point a itself. @@ -200,7 +177,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return NULL; } } - + if (collide_cat.is_debug()) { collide_cat.debug() << "intersection detected from " << entry.get_from_node_path() @@ -214,9 +191,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 v(into_intersection_point - into_center); PN_stdfloat vec_length = v.length(); if (IS_NEARLY_ZERO(vec_length)) { - // If we don't have a collision normal (e.g. the centers are - // exactly coincident), then make up an arbitrary normal--any one - // is as good as any other. + // If we don't have a collision normal (e.g. the centers are exactly + // coincident), then make up an arbitrary normal--any one is as good as + // any other. surface_normal.set(1.0, 0.0, 0.0); } else { surface_normal = v / vec_length; @@ -228,9 +205,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LVector3 v2 = contact_point - into_center; PN_stdfloat v2_len = v2.length(); if (IS_NEARLY_ZERO(v2_len)) { - // If we don't have a collision normal (e.g. the centers are - // exactly coincident), then make up an arbitrary normal--any one - // is as good as any other. + // If we don't have a collision normal (e.g. the centers are exactly + // coincident), then make up an arbitrary normal--any one is as good as + // any other. contact_normal.set(1.0, 0.0, 0.0); } else { contact_normal = v2 / v2_len; @@ -246,11 +223,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_line -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; @@ -288,18 +263,16 @@ test_intersection_from_line(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_box -// Access: Public, Virtual -// Description: Double dispatch point for box as a FROM object -//////////////////////////////////////////////////////////////////// +/** + * Double dispatch point for box as a FROM object + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_box(const CollisionEntry &entry) const { const CollisionBox *box; DCAST_INTO_R(box, entry.get_from(), 0); - // Instead of transforming the box into the sphere's coordinate space, - // we do it the other way around. It's easier that way. + // Instead of transforming the box into the sphere's coordinate space, we do + // it the other way around. It's easier that way. const LMatrix4 &wrt_mat = entry.get_inv_wrt_mat(); LPoint3 center = wrt_mat.xform_point(_center); @@ -366,11 +339,9 @@ test_intersection_from_box(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_ray -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -415,11 +386,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_segment -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; @@ -438,8 +407,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } if (t2 < 0.0 || t1 > 1.0) { - // Both intersection points are before the start of the segment or - // after the end of the segment. + // Both intersection points are before the start of the segment or after + // the end of the segment. return NULL; } @@ -466,11 +435,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::test_intersection_from_parabola -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionSphere:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; @@ -511,12 +478,10 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionSphere:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -531,7 +496,7 @@ fill_viz_geom() { ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); for (int sl = 0; sl < num_slices; ++sl) { PN_stdfloat longitude0 = (PN_stdfloat)sl / (PN_stdfloat)num_slices; @@ -543,64 +508,54 @@ fill_viz_geom() { vertex.add_data3(compute_point(latitude, longitude1)); } vertex.add_data3(compute_point(1.0, longitude0)); - + strip->add_next_vertices(num_stacks * 2); strip->close_primitive(); } - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + _viz_geom->add_geom(geom, get_solid_viz_state()); _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::intersects_line -// Access: Protected -// Description: Determine the point(s) of intersection of a parametric -// line with the sphere. The line is infinite in both -// directions, and passes through "from" and from+delta. -// If the line does not intersect the sphere, the -// function returns false, and t1 and t2 are undefined. -// If it does intersect the sphere, it returns true, and -// t1 and t2 are set to the points along the equation -// from+t*delta that correspond to the two points of -// intersection. -//////////////////////////////////////////////////////////////////// +/** + * Determine the point(s) of intersection of a parametric line with the + * sphere. The line is infinite in both directions, and passes through "from" + * and from+delta. If the line does not intersect the sphere, the function + * returns false, and t1 and t2 are undefined. If it does intersect the + * sphere, it returns true, and t1 and t2 are set to the points along the + * equation from+t*delta that correspond to the two points of intersection. + */ bool CollisionSphere:: intersects_line(double &t1, double &t2, const LPoint3 &from, const LVector3 &delta, PN_stdfloat inflate_radius) const { - // Solve the equation for the intersection of a line with a sphere - // using the quadratic equation. + // Solve the equation for the intersection of a line with a sphere using the + // quadratic equation. - // A line segment from f to f+d is defined as all P such that - // P = f + td for 0 <= t <= 1. + // A line segment from f to f+d is defined as all P such that P = f + td for + // 0 <= t <= 1. - // A sphere with radius r about point c is defined as all P such - // that r^2 = (P - c)^2. + // A sphere with radius r about point c is defined as all P such that r^2 = + // (P - c)^2. // Substituting P in the above we have: - // r^2 = (f + td - c)^2 = - // (f^2 + ftd - fc + ftd + t^2d^2 - tdc - fc - tdc + c^2) = - // t^2(d^2) + t(fd + fd - dc - dc) + (f^2 - fc - fc + c^2) = - // t^2(d^2) + t(2d(f - c)) + (f - c)^2 + // r^2 = (f + td - c)^2 = (f^2 + ftd - fc + ftd + t^2d^2 - tdc - fc - tdc + + // c^2) = t^2(d^2) + t(fd + fd - dc - dc) + (f^2 - fc - fc + c^2) = t^2(d^2) + // + t(2d(f - c)) + (f - c)^2 - // Thus, the equation is quadratic in t, and we have - // at^2 + bt + c = 0 + // Thus, the equation is quadratic in t, and we have at^2 + bt + c = 0 - // Where a = d^2 - // b = 2d(f - c) - // c = (f - c)^2 - r^2 + // Where a = d^2 b = 2d(f - c) c = (f - c)^2 - r^2 // Solving for t using the quadratic equation gives us the point of - // intersection along the line segment. Actually, there are two - // solutions (since it is quadratic): one for the front of the - // sphere, and one for the back. In the case where the line is - // tangent to the sphere, there is only one solution (and the - // radical is zero). + // intersection along the line segment. Actually, there are two solutions + // (since it is quadratic): one for the front of the sphere, and one for the + // back. In the case where the line is tangent to the sphere, there is only + // one solution (and the radical is zero). double A = dot(delta, delta); @@ -632,19 +587,14 @@ intersects_line(double &t1, double &t2, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::intersects_parabola -// Access: Protected -// Description: Determine a point of intersection of a parametric -// parabola with the sphere. -// -// We only consider the segment of the parabola between -// t1 and t2, which has already been computed as -// corresponding to points p1 and p2. If there is an -// intersection, t is set to the parametric point of -// intersection, and true is returned; otherwise, false -// is returned. -//////////////////////////////////////////////////////////////////// +/** + * Determine a point of intersection of a parametric parabola with the sphere. + * + * We only consider the segment of the parabola between t1 and t2, which has + * already been computed as corresponding to points p1 and p2. If there is an + * intersection, t is set to the parametric point of intersection, and true is + * returned; otherwise, false is returned. + */ bool CollisionSphere:: intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, @@ -659,23 +609,21 @@ intersects_parabola(double &t, const LParabola ¶bola, return true; } - // To directly test for intersection between a parabola (quadratic) - // and a sphere (also quadratic) requires solving a quartic - // equation. Doable, but hard, and I'm a programmer, not a - // mathematician. So I'll solve it the programmer's way instead, by - // approximating the parabola with a series of line segments. - // Hence, this function works by recursively subdividing the + // To directly test for intersection between a parabola (quadratic) and a + // sphere (also quadratic) requires solving a quartic equation. Doable, but + // hard, and I'm a programmer, not a mathematician. So I'll solve it the + // programmer's way instead, by approximating the parabola with a series of + // line segments. Hence, this function works by recursively subdividing the // parabola as necessary. - // First, see if the line segment (p1 - p2) comes sufficiently close - // to the parabola. Do this by computing the parametric intervening - // point and comparing its distance from the linear intervening - // point. + // First, see if the line segment (p1 - p2) comes sufficiently close to the + // parabola. Do this by computing the parametric intervening point and + // comparing its distance from the linear intervening point. double tmid = (t1 + t2) * 0.5; if (tmid != t1 && tmid != t2) { LPoint3 pmid = parabola.calc_point(tmid); LPoint3 pmid2 = (p1 + p2) * 0.5f; - + if ((pmid - pmid2).length_squared() > 0.001f) { // Subdivide. if (intersects_parabola(t, parabola, t1, tmid, p1, pmid)) { @@ -699,14 +647,11 @@ intersects_parabola(double &t, const LParabola ¶bola, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::compute_point -// Access: Protected -// Description: Returns a point on the surface of the sphere. -// latitude and longitude range from 0.0 to 1.0. This -// is used by fill_viz_geom() to create a visible -// representation of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Returns a point on the surface of the sphere. latitude and longitude range + * from 0.0 to 1.0. This is used by fill_viz_geom() to create a visible + * representation of the sphere. + */ LVertex CollisionSphere:: compute_point(PN_stdfloat latitude, PN_stdfloat longitude) const { PN_stdfloat s1, c1; @@ -719,22 +664,18 @@ compute_point(PN_stdfloat latitude, PN_stdfloat longitude) const { return p * get_radius() + get_center(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a CollisionSphere object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionSphere object + */ void CollisionSphere:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_CollisionSphere); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CollisionSphere:: write_datagram(BamWriter *manager, Datagram &me) { CollisionSolid::write_datagram(manager, me); @@ -742,11 +683,9 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_stdfloat(_radius); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::make_CollisionSphere -// Access: Protected -// Description: Factory method to generate a CollisionSphere object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a CollisionSphere object + */ TypedWritable *CollisionSphere:: make_CollisionSphere(const FactoryParams ¶ms) { CollisionSphere *me = new CollisionSphere; @@ -758,14 +697,11 @@ make_CollisionSphere(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSphere::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CollisionSphere:: fillin(DatagramIterator& scan, BamReader* manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionSphere.h b/panda/src/collide/collisionSphere.h index 8bf9b10381..fe5d1d2d7b 100644 --- a/panda/src/collide/collisionSphere.h +++ b/panda/src/collide/collisionSphere.h @@ -1,16 +1,15 @@ -// Filename: collisionSphere.h -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionSphere.h + * @author drose + * @date 2000-04-24 + */ #ifndef COLLISIONSPHERE_H #define COLLISIONSPHERE_H @@ -20,10 +19,9 @@ #include "parabola.h" #include "collisionBox.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionSphere -// Description : A spherical collision volume or object. -//////////////////////////////////////////////////////////////////// +/** + * A spherical collision volume or object. + */ class EXPCL_PANDA_COLLIDE CollisionSphere : public CollisionSolid { PUBLISHED: INLINE CollisionSphere(const LPoint3 ¢er, PN_stdfloat radius); @@ -125,5 +123,3 @@ private: #include "collisionSphere.I" #endif - - diff --git a/panda/src/collide/collisionTraverser.I b/panda/src/collide/collisionTraverser.I index 5d9d63cdb9..4f35be0a9e 100644 --- a/panda/src/collide/collisionTraverser.I +++ b/panda/src/collide/collisionTraverser.I @@ -1,43 +1,32 @@ -// Filename: collisionTraverser.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTraverser.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::set_respect_prev_transform -// Access: Published -// Description: Sets the flag that indicates whether the -// prev_transform stored on a node (as updated via -// set_fluid_pos(), etc.) is respected to calculate -// collisions. If this is true, certain types of -// collision tests will be enhanced by the information -// about objects in motion. If this is false, objects -// are always considered to be static. The default is -// false. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the prev_transform stored on a node + * (as updated via set_fluid_pos(), etc.) is respected to calculate + * collisions. If this is true, certain types of collision tests will be + * enhanced by the information about objects in motion. If this is false, + * objects are always considered to be static. The default is false. + */ INLINE void CollisionTraverser:: set_respect_prev_transform(bool flag) { _respect_prev_transform = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_respect_prev_transform -// Access: Published -// Description: Returns the flag that indicates whether the -// prev_transform stored on a node is respected to -// calculate collisions. See -// set_respect_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether the prev_transform stored on a node + * is respected to calculate collisions. See set_respect_prev_transform(). + */ INLINE bool CollisionTraverser:: get_respect_prev_transform() const { return _respect_prev_transform; @@ -45,35 +34,28 @@ get_respect_prev_transform() const { #ifdef DO_COLLISION_RECORDING -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::has_recorder -// Access: Published -// Description: Returns true if the CollisionTraverser has a -// CollisionRecorder object currently assigned, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the CollisionTraverser has a CollisionRecorder object + * currently assigned, false otherwise. + */ INLINE bool CollisionTraverser:: has_recorder() const { return _recorder != (CollisionRecorder *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_recorder -// Access: Published -// Description: Returns the CollisionRecorder currently assigned, or -// NULL if no recorder is assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CollisionRecorder currently assigned, or NULL if no recorder is + * assigned. + */ INLINE CollisionRecorder *CollisionTraverser:: get_recorder() const { return _recorder; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::clear_recorder -// Access: Published -// Description: Removes the CollisionRecorder from the traverser and -// restores normal low-overhead operation. -//////////////////////////////////////////////////////////////////// +/** + * Removes the CollisionRecorder from the traverser and restores normal low- + * overhead operation. + */ INLINE void CollisionTraverser:: clear_recorder() { set_recorder((CollisionRecorder *)NULL); diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 884bbb822b..5934a5e541 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -1,16 +1,15 @@ -// Filename: collisionTraverser.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTraverser.cxx + * @author drose + * @date 2002-03-16 + */ #include "collisionTraverser.h" #include "collisionNode.h" @@ -51,7 +50,7 @@ TypeHandle CollisionTraverser::_type_handle; class SortByColliderSort { public: SortByColliderSort(const CollisionTraverser &trav) : - _trav(trav) + _trav(trav) { } @@ -64,13 +63,11 @@ public: const CollisionTraverser &_trav; }; -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionTraverser:: -CollisionTraverser(const string &name) : +CollisionTraverser(const string &name) : Namable(name), _this_pcollector(_collisions_pcollector, name) { @@ -80,11 +77,9 @@ CollisionTraverser(const string &name) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionTraverser:: ~CollisionTraverser() { #ifdef DO_COLLISION_RECORDING @@ -92,20 +87,15 @@ CollisionTraverser:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::add_collider -// Access: Published -// Description: Adds a new CollisionNode, representing an object that -// will be tested for collisions into other objects, -// along with the handler that will serve each detected -// collision. Each CollisionNode may be served by only -// one handler at a time, but a given handler may serve -// many CollisionNodes. -// -// The handler that serves a particular node may be -// changed from time to time by calling add_collider() -// again on the same node. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new CollisionNode, representing an object that will be tested for + * collisions into other objects, along with the handler that will serve each + * detected collision. Each CollisionNode may be served by only one handler + * at a time, but a given handler may serve many CollisionNodes. + * + * The handler that serves a particular node may be changed from time to time + * by calling add_collider() again on the same node. + */ void CollisionTraverser:: add_collider(const NodePath &collider, CollisionHandler *handler) { nassertv(_ordered_colliders.size() == _colliders.size()); @@ -156,15 +146,12 @@ add_collider(const NodePath &collider, CollisionHandler *handler) { nassertv(_ordered_colliders.size() == _colliders.size()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::remove_collider -// Access: Published -// Description: Removes the collider (and its associated handler) -// from the set of CollisionNodes that will be tested -// each frame for collisions into other objects. -// Returns true if the definition was found and removed, -// false if it wasn't present to begin with. -//////////////////////////////////////////////////////////////////// +/** + * Removes the collider (and its associated handler) from the set of + * CollisionNodes that will be tested each frame for collisions into other + * objects. Returns true if the definition was found and removed, false if it + * wasn't present to begin with. + */ bool CollisionTraverser:: remove_collider(const NodePath &collider) { nassertr(_ordered_colliders.size() == _colliders.size(), false); @@ -202,37 +189,30 @@ remove_collider(const NodePath &collider) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::has_collider -// Access: Published -// Description: Returns true if the indicated node is current in the -// set of nodes that will be tested each frame for -// collisions into other objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated node is current in the set of nodes that will + * be tested each frame for collisions into other objects. + */ bool CollisionTraverser:: has_collider(const NodePath &collider) const { Colliders::const_iterator ci = _colliders.find(collider); return (ci != _colliders.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_num_colliders -// Access: Published -// Description: Returns the number of CollisionNodes that have been -// added to the traverser via add_collider(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of CollisionNodes that have been added to the traverser + * via add_collider(). + */ int CollisionTraverser:: get_num_colliders() const { nassertr(_ordered_colliders.size() == _colliders.size(), 0); return _ordered_colliders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_collider -// Access: Published -// Description: Returns the nth CollisionNode that has been -// added to the traverser via add_collider(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth CollisionNode that has been added to the traverser via + * add_collider(). + */ NodePath CollisionTraverser:: get_collider(int n) const { nassertr(_ordered_colliders.size() == _colliders.size(), NodePath()); @@ -240,13 +220,11 @@ get_collider(int n) const { return _ordered_colliders[n]._node_path; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_handler -// Access: Published -// Description: Returns the handler that is currently assigned to -// serve the indicated collision node, or NULL if the -// node is not on the traverser's set of active nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the handler that is currently assigned to serve the indicated + * collision node, or NULL if the node is not on the traverser's set of active + * nodes. + */ CollisionHandler *CollisionTraverser:: get_handler(const NodePath &collider) const { Colliders::const_iterator ci = _colliders.find(collider); @@ -256,12 +234,10 @@ get_handler(const NodePath &collider) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::clear_colliders -// Access: Published -// Description: Completely empties the set of collision nodes and -// their associated handlers. -//////////////////////////////////////////////////////////////////// +/** + * Completely empties the set of collision nodes and their associated + * handlers. + */ void CollisionTraverser:: clear_colliders() { _colliders.clear(); @@ -269,11 +245,9 @@ clear_colliders() { _handlers.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::traverse -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: traverse(const NodePath &root) { PStatTimer timer(_this_pcollector); @@ -283,7 +257,7 @@ traverse(const NodePath &root) { get_recorder()->begin_traversal(); } #endif // DO_COLLISION_RECORDING - + Handlers::iterator hi; for (hi = _handlers.begin(); hi != _handlers.end(); ++hi) { if ((*hi).first->wants_all_potential_collidees()) { @@ -295,8 +269,8 @@ traverse(const NodePath &root) { bool traversal_done = false; if ((int)_colliders.size() <= CollisionLevelStateSingle::get_max_colliders() || !allow_collider_multiple) { - // Use the single-word-at-a-time traverser, which might need to make - // lots of passes. + // Use the single-word-at-a-time traverser, which might need to make lots + // of passes. LevelStatesSingle level_states; prepare_colliders_single(level_states, root); @@ -376,28 +350,22 @@ traverse(const NodePath &root) { } #ifdef DO_COLLISION_RECORDING -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::set_recorder -// Access: Published -// Description: Uses the indicated CollisionRecorder object to start -// recording the intersection tests made by each -// subsequent call to traverse() on this object. A -// particular CollisionRecorder object can only record -// one traverser at a time; if this object has already -// been assigned to another traverser, that assignment -// is broken. -// -// This is intended to be used in a debugging mode to -// try to determine what work is being performed by the -// collision traversal. Usually, attaching a recorder -// will impose significant runtime overhead. -// -// This does not transfer ownership of the -// CollisionRecorder pointer; maintenance of that -// remains the caller's responsibility. If the -// CollisionRecorder is destructed, it will cleanly -// remove itself from the traverser. -//////////////////////////////////////////////////////////////////// +/** + * Uses the indicated CollisionRecorder object to start recording the + * intersection tests made by each subsequent call to traverse() on this + * object. A particular CollisionRecorder object can only record one + * traverser at a time; if this object has already been assigned to another + * traverser, that assignment is broken. + * + * This is intended to be used in a debugging mode to try to determine what + * work is being performed by the collision traversal. Usually, attaching a + * recorder will impose significant runtime overhead. + * + * This does not transfer ownership of the CollisionRecorder pointer; + * maintenance of that remains the caller's responsibility. If the + * CollisionRecorder is destructed, it will cleanly remove itself from the + * traverser. + */ void CollisionTraverser:: set_recorder(CollisionRecorder *recorder) { if (recorder != _recorder) { @@ -406,9 +374,9 @@ set_recorder(CollisionRecorder *recorder) { nassertv(_recorder->_trav == this); _recorder->_trav = (CollisionTraverser *)NULL; } - + _recorder = recorder; - + // Tell the new recorder about his new owner. if (_recorder != (CollisionRecorder *)NULL) { nassertv(_recorder->_trav != this); @@ -421,16 +389,12 @@ set_recorder(CollisionRecorder *recorder) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::show_collisions -// Access: Published -// Description: This is a high-level function to create a -// CollisionVisualizer object to render the collision -// tests performed by this traverser. The supplied root -// should be any node in the scene graph; typically, the -// top node (e.g. render). The CollisionVisualizer will -// be attached to this node. -//////////////////////////////////////////////////////////////////// +/** + * This is a high-level function to create a CollisionVisualizer object to + * render the collision tests performed by this traverser. The supplied root + * should be any node in the scene graph; typically, the top node (e.g. + * render). The CollisionVisualizer will be attached to this node. + */ CollisionVisualizer *CollisionTraverser:: show_collisions(const NodePath &root) { hide_collisions(); @@ -440,12 +404,9 @@ show_collisions(const NodePath &root) { return viz; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::hide_collisions -// Access: Published -// Description: Undoes the effect of a previous call to -// show_collisions(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to show_collisions(). + */ void CollisionTraverser:: hide_collisions() { if (!_collision_visualizer_np.is_empty()) { @@ -456,22 +417,18 @@ hide_collisions() { #endif // DO_COLLISION_RECORDING -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: output(ostream &out) const { out << "CollisionTraverser, " << _colliders.size() << " colliders and " << _handlers.size() << " handlers.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -479,19 +436,19 @@ write(ostream &out, int indent_level) const { << " colliders and " << _handlers.size() << " handlers:\n"; OrderedColliders::const_iterator oci; - for (oci = _ordered_colliders.begin(); - oci != _ordered_colliders.end(); + for (oci = _ordered_colliders.begin(); + oci != _ordered_colliders.end(); ++oci) { NodePath cnode_path = (*oci)._node_path; bool in_graph = (*oci)._in_graph; - + Colliders::const_iterator ci; ci = _colliders.find(cnode_path); nassertv(ci != _colliders.end()); CollisionHandler *handler = (*ci).second; nassertv(handler != (CollisionHandler *)NULL); - + indent(out, indent_level + 2) << cnode_path; if (in_graph) { @@ -502,7 +459,7 @@ write(ostream &out, int indent_level) const { if (!cnode_path.is_empty() && cnode_path.node()->is_collision_node()) { CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node()); - + int num_solids = cnode->get_num_solids(); for (int i = 0; i < num_solids; ++i) { cnode->get_solid(i)->write(out, indent_level + 4); @@ -511,32 +468,28 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::prepare_colliders_single -// Access: Private -// Description: Fills up the set of LevelStates corresponding to the -// active colliders in use. -// -// This flavor uses a CollisionLevelStateSingle, which is -// limited to a certain number of colliders per pass -// (typically 32). -//////////////////////////////////////////////////////////////////// +/** + * Fills up the set of LevelStates corresponding to the active colliders in + * use. + * + * This flavor uses a CollisionLevelStateSingle, which is limited to a certain + * number of colliders per pass (typically 32). + */ void CollisionTraverser:: -prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, +prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, const NodePath &root) { int num_colliders = _colliders.size(); int max_colliders = CollisionLevelStateSingle::get_max_colliders(); CollisionLevelStateSingle level_state(root); - // This reserve() call is only correct if there is exactly one solid - // per collider added to the traverser, which is the normal case. - // If there is more than one solid in any of the colliders, this - // reserve() call won't reserve enough, but the code is otherwise - // correct. + // This reserve() call is only correct if there is exactly one solid per + // collider added to the traverser, which is the normal case. If there is + // more than one solid in any of the colliders, this reserve() call won't + // reserve enough, but the code is otherwise correct. level_state.reserve(min(num_colliders, max_colliders)); - // Create an indirect index array to walk through the colliders in - // sorted order, without affect the actual collider order. + // Create an indirect index array to walk through the colliders in sorted + // order, without affect the actual collider order. int *indirect = (int *)alloca(sizeof(int) * num_colliders); int i; for (i = 0; i < num_colliders; ++i) { @@ -561,11 +514,11 @@ prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, } else { ocd._in_graph = true; CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node()); - + CollisionLevelStateSingle::ColliderDef def; def._node = cnode; def._node_path = cnode_path; - + int num_solids = cnode->get_num_solids(); for (int s = 0; s < num_solids; ++s) { CPT(CollisionSolid) collider = cnode->get_solid(s); @@ -573,8 +526,7 @@ prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, level_state.prepare_collider(def, root); if (level_state.get_num_colliders() == max_colliders) { - // That's the limit. Save off this level state and make a - // new one. + // That's the limit. Save off this level state and make a new one. level_states.push_back(level_state); level_state.clear(); level_state.reserve(min(num_remaining_colliders, max_colliders)); @@ -592,11 +544,9 @@ prepare_colliders_single(CollisionTraverser::LevelStatesSingle &level_states, nassertv(num_remaining_colliders == 0); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::r_traverse_single -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { if (!level_state.any_in_bounds()) { @@ -631,13 +581,13 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & cnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -652,7 +602,7 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { << "Reached " << *node << "\n"; } #endif - + GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); @@ -676,13 +626,13 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & gnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_geom_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -692,8 +642,8 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { } if (node->has_single_child_visibility()) { - // If it's a switch node or sequence node, visit just the one - // visible child. + // If it's a switch node or sequence node, visit just the one visible + // child. int index = node->get_visible_child(); if (index >= 0 && index < node->get_num_children()) { CollisionLevelStateSingle next_state(level_state, node->get_child(index)); @@ -701,12 +651,11 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { } } else if (node->is_lod_node()) { - // If it's an LODNode, visit the lowest level of detail with all - // bits, allowing collision with geometry under the lowest level - // of default; and visit all other levels without - // GeomNode::get_default_collide_mask(), allowing only collision - // with CollisionNodes and special geometry under higher levels of - // detail. + // If it's an LODNode, visit the lowest level of detail with all bits, + // allowing collision with geometry under the lowest level of default; and + // visit all other levels without GeomNode::get_default_collide_mask(), + // allowing only collision with CollisionNodes and special geometry under + // higher levels of detail. int index = DCAST(LODNode, node)->get_lowest_switch(); PandaNode::Children children = node->get_children(); int num_children = children.get_num_children(); @@ -730,32 +679,28 @@ r_traverse_single(CollisionLevelStateSingle &level_state, size_t pass) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::prepare_colliders_double -// Access: Private -// Description: Fills up the set of LevelStates corresponding to the -// active colliders in use. -// -// This flavor uses a CollisionLevelStateDouble, which is -// limited to a certain number of colliders per pass -// (typically 32). -//////////////////////////////////////////////////////////////////// +/** + * Fills up the set of LevelStates corresponding to the active colliders in + * use. + * + * This flavor uses a CollisionLevelStateDouble, which is limited to a certain + * number of colliders per pass (typically 32). + */ void CollisionTraverser:: -prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, +prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, const NodePath &root) { int num_colliders = _colliders.size(); int max_colliders = CollisionLevelStateDouble::get_max_colliders(); CollisionLevelStateDouble level_state(root); - // This reserve() call is only correct if there is exactly one solid - // per collider added to the traverser, which is the normal case. - // If there is more than one solid in any of the colliders, this - // reserve() call won't reserve enough, but the code is otherwise - // correct. + // This reserve() call is only correct if there is exactly one solid per + // collider added to the traverser, which is the normal case. If there is + // more than one solid in any of the colliders, this reserve() call won't + // reserve enough, but the code is otherwise correct. level_state.reserve(min(num_colliders, max_colliders)); - // Create an indirect index array to walk through the colliders in - // sorted order, without affect the actual collider order. + // Create an indirect index array to walk through the colliders in sorted + // order, without affect the actual collider order. int *indirect = (int *)alloca(sizeof(int) * num_colliders); int i; for (i = 0; i < num_colliders; ++i) { @@ -780,11 +725,11 @@ prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, } else { ocd._in_graph = true; CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node()); - + CollisionLevelStateDouble::ColliderDef def; def._node = cnode; def._node_path = cnode_path; - + int num_solids = cnode->get_num_solids(); for (int s = 0; s < num_solids; ++s) { CPT(CollisionSolid) collider = cnode->get_solid(s); @@ -792,8 +737,7 @@ prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, level_state.prepare_collider(def, root); if (level_state.get_num_colliders() == max_colliders) { - // That's the limit. Save off this level state and make a - // new one. + // That's the limit. Save off this level state and make a new one. level_states.push_back(level_state); level_state.clear(); level_state.reserve(min(num_remaining_colliders, max_colliders)); @@ -811,11 +755,9 @@ prepare_colliders_double(CollisionTraverser::LevelStatesDouble &level_states, nassertv(num_remaining_colliders == 0); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::r_traverse_double -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { if (!level_state.any_in_bounds()) { @@ -850,13 +792,13 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & cnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -871,7 +813,7 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { << "Reached " << *node << "\n"; } #endif - + GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); @@ -895,13 +837,13 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & gnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_geom_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -911,8 +853,8 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { } if (node->has_single_child_visibility()) { - // If it's a switch node or sequence node, visit just the one - // visible child. + // If it's a switch node or sequence node, visit just the one visible + // child. int index = node->get_visible_child(); if (index >= 0 && index < node->get_num_children()) { CollisionLevelStateDouble next_state(level_state, node->get_child(index)); @@ -920,12 +862,11 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { } } else if (node->is_lod_node()) { - // If it's an LODNode, visit the lowest level of detail with all - // bits, allowing collision with geometry under the lowest level - // of default; and visit all other levels without - // GeomNode::get_default_collide_mask(), allowing only collision - // with CollisionNodes and special geometry under higher levels of - // detail. + // If it's an LODNode, visit the lowest level of detail with all bits, + // allowing collision with geometry under the lowest level of default; and + // visit all other levels without GeomNode::get_default_collide_mask(), + // allowing only collision with CollisionNodes and special geometry under + // higher levels of detail. int index = DCAST(LODNode, node)->get_lowest_switch(); PandaNode::Children children = node->get_children(); int num_children = children.get_num_children(); @@ -949,32 +890,28 @@ r_traverse_double(CollisionLevelStateDouble &level_state, size_t pass) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::prepare_colliders_quad -// Access: Private -// Description: Fills up the set of LevelStates corresponding to the -// active colliders in use. -// -// This flavor uses a CollisionLevelStateQuad, which is -// limited to a certain number of colliders per pass -// (typically 32). -//////////////////////////////////////////////////////////////////// +/** + * Fills up the set of LevelStates corresponding to the active colliders in + * use. + * + * This flavor uses a CollisionLevelStateQuad, which is limited to a certain + * number of colliders per pass (typically 32). + */ void CollisionTraverser:: -prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, +prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, const NodePath &root) { int num_colliders = _colliders.size(); int max_colliders = CollisionLevelStateQuad::get_max_colliders(); CollisionLevelStateQuad level_state(root); - // This reserve() call is only correct if there is exactly one solid - // per collider added to the traverser, which is the normal case. - // If there is more than one solid in any of the colliders, this - // reserve() call won't reserve enough, but the code is otherwise - // correct. + // This reserve() call is only correct if there is exactly one solid per + // collider added to the traverser, which is the normal case. If there is + // more than one solid in any of the colliders, this reserve() call won't + // reserve enough, but the code is otherwise correct. level_state.reserve(min(num_colliders, max_colliders)); - // Create an indirect index array to walk through the colliders in - // sorted order, without affect the actual collider order. + // Create an indirect index array to walk through the colliders in sorted + // order, without affect the actual collider order. int *indirect = (int *)alloca(sizeof(int) * num_colliders); int i; for (i = 0; i < num_colliders; ++i) { @@ -999,11 +936,11 @@ prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, } else { ocd._in_graph = true; CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node()); - + CollisionLevelStateQuad::ColliderDef def; def._node = cnode; def._node_path = cnode_path; - + int num_solids = cnode->get_num_solids(); for (int s = 0; s < num_solids; ++s) { CPT(CollisionSolid) collider = cnode->get_solid(s); @@ -1011,8 +948,7 @@ prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, level_state.prepare_collider(def, root); if (level_state.get_num_colliders() == max_colliders) { - // That's the limit. Save off this level state and make a - // new one. + // That's the limit. Save off this level state and make a new one. level_states.push_back(level_state); level_state.clear(); level_state.reserve(min(num_remaining_colliders, max_colliders)); @@ -1030,11 +966,9 @@ prepare_colliders_quad(CollisionTraverser::LevelStatesQuad &level_states, nassertv(num_remaining_colliders == 0); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::r_traverse_quad -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { if (!level_state.any_in_bounds()) { @@ -1069,13 +1003,13 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & cnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -1090,7 +1024,7 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { << "Reached " << *node << "\n"; } #endif - + GeomNode *gnode; DCAST_INTO_V(gnode, node); CPT(BoundingVolume) node_bv = gnode->get_bounds(); @@ -1114,13 +1048,13 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { if ((entry._from_node->get_from_collide_mask() & gnode->get_into_collide_mask()) != 0) { #ifdef DO_PSTATS - //PStatTimer collide_timer(_solid_collide_collectors[pass]); + // PStatTimer collide_timer(_solid_collide_collectors[pass]); #endif entry._from_node_path = level_state.get_collider_node_path(c); entry._from = level_state.get_collider(c); compare_collider_to_geom_node( - entry, + entry, level_state.get_parent_bound(c), level_state.get_local_bound(c), node_gbv); @@ -1130,8 +1064,8 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { } if (node->has_single_child_visibility()) { - // If it's a switch node or sequence node, visit just the one - // visible child. + // If it's a switch node or sequence node, visit just the one visible + // child. int index = node->get_visible_child(); if (index >= 0 && index < node->get_num_children()) { CollisionLevelStateQuad next_state(level_state, node->get_child(index)); @@ -1139,12 +1073,11 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { } } else if (node->is_lod_node()) { - // If it's an LODNode, visit the lowest level of detail with all - // bits, allowing collision with geometry under the lowest level - // of default; and visit all other levels without - // GeomNode::get_default_collide_mask(), allowing only collision - // with CollisionNodes and special geometry under higher levels of - // detail. + // If it's an LODNode, visit the lowest level of detail with all bits, + // allowing collision with geometry under the lowest level of default; and + // visit all other levels without GeomNode::get_default_collide_mask(), + // allowing only collision with CollisionNodes and special geometry under + // higher levels of detail. int index = DCAST(LODNode, node)->get_lowest_switch(); PandaNode::Children children = node->get_children(); int num_children = children.get_num_children(); @@ -1168,11 +1101,9 @@ r_traverse_quad(CollisionLevelStateQuad &level_state, size_t pass) { } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::compare_collider_to_node -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: compare_collider_to_node(CollisionEntry &entry, const GeometricBoundingVolume *from_parent_gbv, @@ -1195,32 +1126,29 @@ compare_collider_to_node(CollisionEntry &entry, for (int s = 0; s < num_solids; ++s) { entry._into = cnode->get_solid(s); - // We should allow a collision test for solid into itself, - // because the solid might be simply instanced into multiple - // different CollisionNodes. We are already filtering out tests - // for a CollisionNode into itself. + // We should allow a collision test for solid into itself, because the + // solid might be simply instanced into multiple different + // CollisionNodes. We are already filtering out tests for a + // CollisionNode into itself. CPT(BoundingVolume) solid_bv = entry._into->get_bounds(); const GeometricBoundingVolume *solid_gbv = NULL; if (num_solids > 1 && solid_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { - // Only bother to test against each solid's bounding - // volume if we have more than one solid in the node, as a - // slight optimization. (If the node contains just one - // solid, then the node's bounding volume, which we just - // tested, is the same as the solid's bounding volume.) + // Only bother to test against each solid's bounding volume if we have + // more than one solid in the node, as a slight optimization. (If the + // node contains just one solid, then the node's bounding volume, + // which we just tested, is the same as the solid's bounding volume.) DCAST_INTO_V(solid_gbv, solid_bv); } - + compare_collider_to_solid(entry, from_node_gbv, solid_gbv); } } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::compare_collider_to_geom_node -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: compare_collider_to_geom_node(CollisionEntry &entry, const GeometricBoundingVolume *from_parent_gbv, @@ -1245,11 +1173,11 @@ compare_collider_to_geom_node(CollisionEntry &entry, const GeometricBoundingVolume *geom_gbv = NULL; if (num_geoms > 1 && geom_bv->is_of_type(GeometricBoundingVolume::get_class_type())) { - // Only bother to test against each geom's bounding - // volume if we have more than one geom in the node, as a - // slight optimization. (If the node contains just one - // geom, then the node's bounding volume, which we just - // tested, is the same as the geom's bounding volume.) + // Only bother to test against each geom's bounding volume if we + // have more than one geom in the node, as a slight optimization. + // (If the node contains just one geom, then the node's bounding + // volume, which we just tested, is the same as the geom's bounding + // volume.) DCAST_INTO_V(geom_gbv, geom_bv); } @@ -1259,11 +1187,9 @@ compare_collider_to_geom_node(CollisionEntry &entry, } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::compare_collider_to_solid -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: compare_collider_to_solid(CollisionEntry &entry, const GeometricBoundingVolume *from_node_gbv, @@ -1279,7 +1205,7 @@ compare_collider_to_solid(CollisionEntry &entry, if (collide_cat.is_spam()) { collide_cat.spam(false) << "Comparing to solid: " << *from_node_gbv - << " to " << *solid_gbv << ", within_solid_bounds = " + << " to " << *solid_gbv << ", within_solid_bounds = " << within_solid_bounds << "\n"; } #endif // NDEBUG @@ -1292,11 +1218,9 @@ compare_collider_to_solid(CollisionEntry &entry, } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::compare_collider_to_geom -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTraverser:: compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, const GeometricBoundingVolume *from_node_gbv, @@ -1316,7 +1240,7 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, Thread *current_thread = Thread::get_current_thread(); CPT(GeomVertexData) data = geom->get_vertex_data()->animate_vertices(true, current_thread); GeomVertexReader vertex(data, InternalName::get_vertex()); - + int num_primitives = geom->get_num_primitives(); for (int i = 0; i < num_primitives; ++i) { const GeomPrimitive *primitive = geom->get_primitive(i); @@ -1328,16 +1252,16 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, GeomVertexReader index(tris->get_vertices(), 0); while (!index.is_at_end()) { LPoint3 v[3]; - + vertex.set_row_unsafe(index.get_data1i()); v[0] = vertex.get_data3(); vertex.set_row_unsafe(index.get_data1i()); v[1] = vertex.get_data3(); vertex.set_row_unsafe(index.get_data1i()); v[2] = vertex.get_data3(); - - // Generate a temporary CollisionGeom on the fly for each - // triangle in the Geom. + + // Generate a temporary CollisionGeom on the fly for each triangle + // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; if (from_node_gbv != (GeometricBoundingVolume *)NULL) { @@ -1361,13 +1285,13 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, int num_vertices = primitive->get_num_vertices(); for (int i = 0; i < num_vertices; i += 3) { LPoint3 v[3]; - + v[0] = vertex.get_data3(); v[1] = vertex.get_data3(); v[2] = vertex.get_data3(); - - // Generate a temporary CollisionGeom on the fly for each - // triangle in the Geom. + + // Generate a temporary CollisionGeom on the fly for each triangle + // in the Geom. if (CollisionPolygon::verify_points(v[0], v[1], v[2])) { bool within_solid_bounds = true; if (from_node_gbv != (GeometricBoundingVolume *)NULL) { @@ -1391,18 +1315,15 @@ compare_collider_to_geom(CollisionEntry &entry, const Geom *geom, } } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::remove_handler -// Access: Private -// Description: Removes the indicated CollisionHandler from the list -// of handlers to be processed, and returns the iterator -// to the next handler in the list. This is designed to -// be called safely from within a traversal of the handler -// list. -// -// This also removes any colliders that depend on this -// handler, to keep internal structures intact. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated CollisionHandler from the list of handlers to be + * processed, and returns the iterator to the next handler in the list. This + * is designed to be called safely from within a traversal of the handler + * list. + * + * This also removes any colliders that depend on this handler, to keep + * internal structures intact. + */ CollisionTraverser::Handlers::iterator CollisionTraverser:: remove_handler(CollisionTraverser::Handlers::iterator hi) { nassertr(hi != _handlers.end(), hi); @@ -1435,7 +1356,7 @@ remove_handler(CollisionTraverser::Handlers::iterator hi) { } nassertr(oci != _ordered_colliders.end(), hi); _ordered_colliders.erase(oci); - + nassertr(_ordered_colliders.size() == _colliders.size(), hi); } else { @@ -1447,12 +1368,9 @@ remove_handler(CollisionTraverser::Handlers::iterator hi) { return hi; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTraverser::get_pass_collector -// Access: Private -// Description: Returns the PStatCollector suitable for timing the -// nth pass. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStatCollector suitable for timing the nth pass. + */ PStatCollector &CollisionTraverser:: get_pass_collector(int pass) { nassertr(pass >= 0, _this_pcollector); diff --git a/panda/src/collide/collisionTraverser.h b/panda/src/collide/collisionTraverser.h index bd87a0879a..cd7916fc09 100644 --- a/panda/src/collide/collisionTraverser.h +++ b/panda/src/collide/collisionTraverser.h @@ -1,16 +1,15 @@ -// Filename: collisionTraverser.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTraverser.h + * @author drose + * @date 2002-03-16 + */ #ifndef COLLISIONTRAVERSER_H #define COLLISIONTRAVERSER_H @@ -33,19 +32,16 @@ class Geom; class NodePath; class CollisionEntry; -//////////////////////////////////////////////////////////////////// -// Class : CollisionTraverser -// Description : This class manages the traversal through the scene -// graph to detect collisions. It holds ownership of a -// number of collider objects, each of which is a -// CollisionNode and an associated CollisionHandler. -// -// When traverse() is called, it begins at the indicated -// root and detects all collisions with any of its -// collider objects against nodes at or below the -// indicated root, calling the appropriate -// CollisionHandler for each detected collision. -//////////////////////////////////////////////////////////////////// +/** + * This class manages the traversal through the scene graph to detect + * collisions. It holds ownership of a number of collider objects, each of + * which is a CollisionNode and an associated CollisionHandler. + * + * When traverse() is called, it begins at the indicated root and detects all + * collisions with any of its collider objects against nodes at or below the + * indicated root, calling the appropriate CollisionHandler for each detected + * collision. + */ class EXPCL_PANDA_COLLIDE CollisionTraverser : public Namable { PUBLISHED: CollisionTraverser(const string &name = "ctrav"); @@ -148,7 +144,8 @@ private: PStatCollector _this_pcollector; typedef pvector PassCollectors; PassCollectors _pass_collectors; - // pstats category for actual collision detection (vs. bounding heirarchy collision detection) + // pstats category for actual collision detection (vs. bounding heirarchy + // collision detection) typedef pvector SolidCollideCollectors; SolidCollideCollectors _solid_collide_collectors; @@ -174,4 +171,3 @@ INLINE ostream &operator << (ostream &out, const CollisionTraverser &trav) { #include "collisionTraverser.I" #endif - diff --git a/panda/src/collide/collisionTube.I b/panda/src/collide/collisionTube.I index 0af8961111..53e0f4cff6 100644 --- a/panda/src/collide/collisionTube.I +++ b/panda/src/collide/collisionTube.I @@ -1,23 +1,19 @@ -// Filename: collisionTube.I -// Created by: drose (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTube.I + * @author drose + * @date 2003-09-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionTube:: CollisionTube(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : _a(a), _b(b), _radius(radius) @@ -26,11 +22,9 @@ CollisionTube(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : nassertv(_radius >= 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionTube:: CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, @@ -41,21 +35,16 @@ CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, nassertv(_radius >= 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::Default constructor -// Access: Private -// Description: Creates an invalid tube. Only used when reading -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid tube. Only used when reading from a bam file. + */ INLINE CollisionTube:: CollisionTube() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionTube:: CollisionTube(const CollisionTube ©) : CollisionSolid(copy), @@ -66,102 +55,83 @@ CollisionTube(const CollisionTube ©) : recalc_internals(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CollisionTube:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_point_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionTube:: set_point_a(const LPoint3 &a) { _a = a; recalc_internals(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_point_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionTube:: set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_a(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_point_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionTube:: get_point_a() const { return _a; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_point_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionTube:: set_point_b(const LPoint3 &b) { _b = b; recalc_internals(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_point_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionTube:: set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_b(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_point_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3 &CollisionTube:: get_point_b() const { return _b; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CollisionTube:: set_radius(PN_stdfloat radius) { nassertv(radius >= 0.0f); _radius = radius; - // We don't need to call recalc_internals(), since the radius - // doesn't change either of those properties. + // We don't need to call recalc_internals(), since the radius doesn't change + // either of those properties. mark_internal_bounds_stale(); mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat CollisionTube:: get_radius() const { return _radius; } - diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionTube.cxx index f99c513e93..17e9cd5c3f 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionTube.cxx @@ -1,16 +1,15 @@ -// Filename: collisionTube.cxx -// Created by: drose (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTube.cxx + * @author drose + * @date 2003-09-25 + */ #include "collisionTube.h" #include "collisionSphere.h" @@ -40,28 +39,24 @@ PStatCollector CollisionTube::_volume_pcollector("Collision Volumes:CollisionTub PStatCollector CollisionTube::_test_pcollector("Collision Tests:CollisionTube"); TypeHandle CollisionTube::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionSolid *CollisionTube:: make_copy() { return new CollisionTube(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::xform -// Access: Public, Virtual -// Description: Transforms the solid by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the solid by the indicated matrix. + */ void CollisionTube:: xform(const LMatrix4 &mat) { _a = _a * mat; _b = _b * mat; - // This is a little cheesy and fails miserably in the presence of a - // non-uniform scale. + // This is a little cheesy and fails miserably in the presence of a non- + // uniform scale. LVector3 radius_v = LVector3(_radius, 0.0f, 0.0f) * mat; _radius = length(radius_v); @@ -69,58 +64,45 @@ xform(const LMatrix4 &mat) { CollisionSolid::xform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_collision_origin -// Access: Public, Virtual -// Description: Returns the point in space deemed to be the "origin" -// of the solid for collision purposes. The closest -// intersection point to this origin point is considered -// to be the most significant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space deemed to be the "origin" of the solid for + * collision purposes. The closest intersection point to this origin point is + * considered to be the most significant. + */ LPoint3 CollisionTube:: get_collision_origin() const { return get_point_a(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_volume_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of bounding volume tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of bounding + * volume tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionTube:: get_volume_pcollector() { return _volume_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::get_test_pcollector -// Access: Public, Virtual -// Description: Returns a PStatCollector that is used to count the -// number of intersection tests made against a solid -// of this type in a given frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector that is used to count the number of intersection + * tests made against a solid of this type in a given frame. + */ PStatCollector &CollisionTube:: get_test_pcollector() { return _test_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CollisionTube:: output(ostream &out) const { out << "tube, a (" << _a << "), b (" << _b << "), r " << _radius; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::compute_internal_bounds -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(BoundingVolume) CollisionTube:: compute_internal_bounds() const { PT(BoundingVolume) bound = CollisionSolid::compute_internal_bounds(); @@ -131,8 +113,8 @@ compute_internal_bounds() const { LVector3 vec = (_b - _a); if (vec.normalize()) { - // The bounding volume includes both endpoints, plus a little - // bit more to include the radius in both directions. + // The bounding volume includes both endpoints, plus a little bit more + // to include the radius in both directions. LPoint3 points[2]; points[0] = _a - vec * _radius; points[1] = _b + vec * _radius; @@ -140,8 +122,8 @@ compute_internal_bounds() const { gbound->around(points, points + 2); } else { - // Both endpoints are coincident; therefore, the bounding volume - // is a sphere. + // Both endpoints are coincident; therefore, the bounding volume is a + // sphere. BoundingSphere sphere(_a, _radius); gbound->extend_by(&sphere); } @@ -150,11 +132,9 @@ compute_internal_bounds() const { return bound; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::test_intersection_from_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionTube:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; @@ -172,8 +152,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat actual_t = 0.0f; if (wrt_prev_space != wrt_space) { - // If the sphere is moving relative to the tube, it becomes a tube - // itself. + // If the sphere is moving relative to the tube, it becomes a tube itself. from_a = sphere->get_center() * wrt_prev_space->get_mat(); } @@ -190,8 +169,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { } if (t2 < 0.0 || t1 > 1.0) { - // Both intersection points are before the start of the segment or - // after the end of the segment. + // Both intersection points are before the start of the segment or after + // the end of the segment. return NULL; } @@ -208,12 +187,12 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t2 > 1.0) { - // Point b is within the tube. The first intersection point is - // point b itself. + // Point b is within the tube. The first intersection point is point b + // itself. into_intersection_point = from_b; } else { - // Point b is outside the tube, and point a is either inside the - // tube or beyond it. The first intersection point is at t2. + // Point b is outside the tube, and point a is either inside the tube or + // beyond it. The first intersection point is at t2. into_intersection_point = from_a + t2 * from_direction; } set_intersection_point(new_entry, into_intersection_point, from_radius); @@ -231,11 +210,9 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::test_intersection_from_line -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionTube:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; @@ -281,11 +258,9 @@ test_intersection_from_line(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::test_intersection_from_ray -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionTube:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; @@ -316,12 +291,11 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t1 < 0.0) { - // Point a is within the tube. The first intersection point is - // point a itself. + // Point a is within the tube. The first intersection point is point a + // itself. into_intersection_point = from_origin; } else { - // Point a is outside the tube. The first intersection point is - // at t1. + // Point a is outside the tube. The first intersection point is at t1. into_intersection_point = from_origin + t1 * from_direction; } set_intersection_point(new_entry, into_intersection_point, 0.0); @@ -345,11 +319,9 @@ test_intersection_from_ray(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::test_intersection_from_segment -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionTube:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; @@ -368,8 +340,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } if (t2 < 0.0 || t1 > 1.0) { - // Both intersection points are before the start of the segment or - // after the end of the segment. + // Both intersection points are before the start of the segment or after + // the end of the segment. return NULL; } @@ -382,12 +354,12 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t1 < 0.0) { - // Point a is within the tube. The first intersection point is - // point a itself. + // Point a is within the tube. The first intersection point is point a + // itself. into_intersection_point = from_a; } else { - // Point a is outside the tube, and point b is either inside the - // tube or beyond it. The first intersection point is at t1. + // Point a is outside the tube, and point b is either inside the tube or + // beyond it. The first intersection point is at t1. into_intersection_point = from_a + t1 * from_direction; } set_intersection_point(new_entry, into_intersection_point, 0.0); @@ -411,11 +383,9 @@ test_intersection_from_segment(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::test_intersection_from_parabola -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(CollisionEntry) CollisionTube:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; @@ -464,12 +434,10 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { return new_entry; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the _viz_geom GeomNode up with Geoms suitable -// for rendering this solid. -//////////////////////////////////////////////////////////////////// +/** + * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this + * solid. + */ void CollisionTube:: fill_viz_geom() { if (collide_cat.is_debug()) { @@ -477,9 +445,9 @@ fill_viz_geom() { << "Recomputing viz for " << *this << "\n"; } - // Generate the vertices such that we draw a tube with one endpoint - // at (0, 0, 0), and another at (0, length, 0). Then we'll rotate - // and translate it into place with the appropriate look_at matrix. + // Generate the vertices such that we draw a tube with one endpoint at (0, + // 0, 0), and another at (0, length, 0). Then we'll rotate and translate it + // into place with the appropriate look_at matrix. LVector3 direction = (_b - _a); PN_stdfloat length = direction.length(); @@ -487,7 +455,7 @@ fill_viz_geom() { ("collision", GeomVertexFormat::get_v3(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); // Generate the first endcap. static const int num_slices = 8; @@ -501,7 +469,7 @@ fill_viz_geom() { strip->add_next_vertices((num_slices + 1) * 2); strip->close_primitive(); } - + // Now the cylinder sides. for (si = 0; si <= num_slices; si++) { vertex.add_data3(calc_sphere1_vertex(num_rings, si, num_rings, num_slices)); @@ -510,7 +478,7 @@ fill_viz_geom() { } strip->add_next_vertices((num_slices + 1) * 2); strip->close_primitive(); - + // And the second endcap. for (ri = num_rings - 1; ri >= 0; ri--) { for (si = 0; si <= num_slices; si++) { @@ -520,27 +488,24 @@ fill_viz_geom() { strip->add_next_vertices((num_slices + 1) * 2); strip->close_primitive(); } - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + // Now transform the vertices to their actual location. LMatrix4 mat; look_at(mat, direction, LVector3(0.0f, 0.0f, 1.0f), CS_zup_right); mat.set_row(3, _a); geom->transform_vertices(mat); - + _viz_geom->add_geom(geom, get_solid_viz_state()); _bounds_viz_geom->add_geom(geom, get_solid_bounds_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::recalc_internals -// Access: Private -// Description: Should be called internally to recompute the matrix -// and length when the properties of the tube have -// changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called internally to recompute the matrix and length when the + * properties of the tube have changed. + */ void CollisionTube:: recalc_internals() { LVector3 direction = (_b - _a); @@ -554,13 +519,10 @@ recalc_internals() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::calc_sphere1_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// first endcap hemisphere, for use in generating the -// viz geometry. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a particular vertex on the surface of the first endcap + * hemisphere, for use in generating the viz geometry. + */ LVertex CollisionTube:: calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; @@ -582,13 +544,10 @@ calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { return LVertex(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::calc_sphere2_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// second endcap hemisphere, for use in generating the -// viz geometry. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a particular vertex on the surface of the second endcap + * hemisphere, for use in generating the viz geometry. + */ LVertex CollisionTube:: calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, PN_stdfloat length) { @@ -611,56 +570,49 @@ calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, return LVertex(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::intersects_line -// Access: Private -// Description: Determine the point(s) of intersection of a parametric -// line with the tube. The line is infinite in both -// directions, and passes through "from" and from+delta. -// If the line does not intersect the tube, the -// function returns false, and t1 and t2 are undefined. -// If it does intersect the tube, it returns true, and -// t1 and t2 are set to the points along the equation -// from+t*delta that correspond to the two points of -// intersection. -//////////////////////////////////////////////////////////////////// +/** + * Determine the point(s) of intersection of a parametric line with the tube. + * The line is infinite in both directions, and passes through "from" and + * from+delta. If the line does not intersect the tube, the function returns + * false, and t1 and t2 are undefined. If it does intersect the tube, it + * returns true, and t1 and t2 are set to the points along the equation + * from+t*delta that correspond to the two points of intersection. + */ bool CollisionTube:: intersects_line(double &t1, double &t2, - const LPoint3 &from0, const LVector3 &delta0, + const LPoint3 &from0, const LVector3 &delta0, PN_stdfloat inflate_radius) const { - // Convert the line into our canonical coordinate space: the tube is - // aligned with the y axis. + // Convert the line into our canonical coordinate space: the tube is aligned + // with the y axis. LPoint3 from = from0 * _inv_mat; LVector3 delta = delta0 * _inv_mat; PN_stdfloat radius = _radius + inflate_radius; - // Now project the line into the X-Z plane to test for intersection - // with a 2-d circle around the origin. The equation for this is - // very similar to the formula for the intersection of a line with a - // sphere; see CollisionSphere::intersects_line() for the complete - // derivation. It's a little bit simpler because the circle is - // centered on the origin. + // Now project the line into the X-Z plane to test for intersection with a + // 2-d circle around the origin. The equation for this is very similar to + // the formula for the intersection of a line with a sphere; see + // CollisionSphere::intersects_line() for the complete derivation. It's a + // little bit simpler because the circle is centered on the origin. LVector2 from2(from[0], from[2]); LVector2 delta2(delta[0], delta[2]); double A = dot(delta2, delta2); if (IS_NEARLY_ZERO(A)) { - // If the delta2 is 0, the line is perpendicular to the X-Z plane. - // The whole line intersects with the infinite cylinder if the - // point is within the circle. + // If the delta2 is 0, the line is perpendicular to the X-Z plane. The + // whole line intersects with the infinite cylinder if the point is within + // the circle. if (from2.dot(from2) > radius * radius) { - // Nope, the 2-d point is outside the circle, so no - // intersection. + // Nope, the 2-d point is outside the circle, so no intersection. return false; } if (IS_NEARLY_ZERO(delta[1])) { - // Actually, the whole delta vector is 0, so the line is just a - // point. In this case, (since we have already shown the point - // is within the infinite cylinder), we intersect if and only if - // the three-dimensional point is between the endcaps. + // Actually, the whole delta vector is 0, so the line is just a point. + // In this case, (since we have already shown the point is within the + // infinite cylinder), we intersect if and only if the three-dimensional + // point is between the endcaps. if (from[1] < -radius || from[1] > _length + radius) { // Way out. return false; @@ -683,30 +635,30 @@ intersects_line(double &t1, double &t2, return true; } - // The 2-d point is within the circle, so compute our intersection - // points to include the entire vertical slice of the cylinder. + // The 2-d point is within the circle, so compute our intersection points + // to include the entire vertical slice of the cylinder. t1 = (-radius - from[1]) / delta[1]; t2 = (_length + radius - from[1]) / delta[1]; } else { - // The line is not perpendicular to the X-Z plane, so its - // projection into the plane is 2-d line. Test that 2-d line for - // intersection with the circular projection of the cylinder. + // The line is not perpendicular to the X-Z plane, so its projection into + // the plane is 2-d line. Test that 2-d line for intersection with the + // circular projection of the cylinder. double B = 2.0f * dot(delta2, from2); double fc_d2 = dot(from2, from2); double C = fc_d2 - radius * radius; - + double radical = B*B - 4.0*A*C; - + if (IS_NEARLY_ZERO(radical)) { // Tangent. t1 = t2 = -B / (2.0*A); - + } else if (radical < 0.0) { // No real roots: no intersection with the line. return false; - + } else { double reciprocal_2A = 1.0 / (2.0 * A); double sqrt_radical = sqrtf(radical); @@ -715,14 +667,13 @@ intersects_line(double &t1, double &t2, } } - // Now we need to verify that the intersection points fall within - // the length of the cylinder. + // Now we need to verify that the intersection points fall within the length + // of the cylinder. PN_stdfloat t1_y = from[1] + t1 * delta[1]; PN_stdfloat t2_y = from[1] + t2 * delta[1]; if (t1_y < -radius && t2_y < -radius) { - // Both points are way off the bottom of the tube; no - // intersection. + // Both points are way off the bottom of the tube; no intersection. return false; } else if (t1_y > _length + radius && t2_y > _length + radius) { // Both points are way off the top of the tube; no intersection. @@ -730,8 +681,8 @@ intersects_line(double &t1, double &t2, } if (t1_y < 0.0f) { - // The starting point is off the bottom of the tube. Test the - // line against the first endcap. + // The starting point is off the bottom of the tube. Test the line + // against the first endcap. double t1a, t2a; if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { // If there's no intersection with the endcap, there can't be an @@ -741,8 +692,8 @@ intersects_line(double &t1, double &t2, t1 = t1a; } else if (t1_y > _length) { - // The starting point is off the top of the tube. Test the - // line against the second endcap. + // The starting point is off the top of the tube. Test the line against + // the second endcap. double t1b, t2b; if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { // If there's no intersection with the endcap, there can't be an @@ -753,8 +704,8 @@ intersects_line(double &t1, double &t2, } if (t2_y < 0.0f) { - // The ending point is off the bottom of the tube. Test the - // line against the first endcap. + // The ending point is off the bottom of the tube. Test the line against + // the first endcap. double t1a, t2a; if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, inflate_radius)) { // If there's no intersection with the endcap, there can't be an @@ -764,8 +715,8 @@ intersects_line(double &t1, double &t2, t2 = t2a; } else if (t2_y > _length) { - // The ending point is off the top of the tube. Test the - // line against the second endcap. + // The ending point is off the top of the tube. Test the line against the + // second endcap. double t1b, t2b; if (!sphere_intersects_line(t1b, t2b, _length, from, delta, inflate_radius)) { // If there's no intersection with the endcap, there can't be an @@ -778,20 +729,17 @@ intersects_line(double &t1, double &t2, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::sphere_intersects_line -// Access: Private -// Description: After confirming that the line intersects an infinite -// cylinder, test whether it intersects one or the other -// endcaps. The y parameter specifies the center of the -// sphere (and hence the particular endcap. -//////////////////////////////////////////////////////////////////// +/** + * After confirming that the line intersects an infinite cylinder, test + * whether it intersects one or the other endcaps. The y parameter specifies + * the center of the sphere (and hence the particular endcap. + */ bool CollisionTube:: sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, const LPoint3 &from, const LVector3 &delta, PN_stdfloat inflate_radius) const { - // See CollisionSphere::intersects_line() for a derivation of the - // formula here. + // See CollisionSphere::intersects_line() for a derivation of the formula + // here. PN_stdfloat radius = _radius + inflate_radius; double A = dot(delta, delta); @@ -824,32 +772,25 @@ sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::intersects_parabola -// Access: Protected -// Description: Determine a point of intersection of a parametric -// parabola with the tube. -// -// We only consider the segment of the parabola between -// t1 and t2, which has already been computed as -// corresponding to points p1 and p2. If there is an -// intersection, t is set to the parametric point of -// intersection, and true is returned; otherwise, false -// is returned. -//////////////////////////////////////////////////////////////////// +/** + * Determine a point of intersection of a parametric parabola with the tube. + * + * We only consider the segment of the parabola between t1 and t2, which has + * already been computed as corresponding to points p1 and p2. If there is an + * intersection, t is set to the parametric point of intersection, and true is + * returned; otherwise, false is returned. + */ bool CollisionTube:: intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, const LPoint3 &p1, const LPoint3 &p2) const { - // I don't even want to think about the math to do this calculation - // directly--it's even worse than sphere-parabola. So I'll use the - // recursive subdivision solution again, just like I did for - // sphere-parabola. + // I don't even want to think about the math to do this calculation directly + // --it's even worse than sphere-parabola. So I'll use the recursive + // subdivision solution again, just like I did for sphere-parabola. - // First, see if the line segment (p1 - p2) comes sufficiently close - // to the parabola. Do this by computing the parametric intervening - // point and comparing its distance from the linear intervening - // point. + // First, see if the line segment (p1 - p2) comes sufficiently close to the + // parabola. Do this by computing the parametric intervening point and + // comparing its distance from the linear intervening point. double tmid = (t1 + t2) * 0.5; if (tmid != t1 && tmid != t2) { @@ -879,14 +820,11 @@ intersects_parabola(double &t, const LParabola ¶bola, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::calculate_surface_point_and_normal -// Access: Private -// Description: Calculates a point that is exactly on the surface -// of the tube and its corresponding normal, given -// a point that is supposedly on the surface of the -// tube. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a point that is exactly on the surface of the tube and its + * corresponding normal, given a point that is supposedly on the surface of + * the tube. + */ void CollisionTube:: calculate_surface_point_and_normal(const LPoint3 &surface_point, double extra_radius, @@ -928,17 +866,14 @@ calculate_surface_point_and_normal(const LPoint3 &surface_point, result_normal = normal * _mat; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::set_intersection_point -// Access: Private -// Description: After an intersection has been detected, record the -// computed intersection point in the CollisionEntry, -// and also compute the relevant normal based on that -// point. -//////////////////////////////////////////////////////////////////// +/** + * After an intersection has been detected, record the computed intersection + * point in the CollisionEntry, and also compute the relevant normal based on + * that point. + */ void CollisionTube:: -set_intersection_point(CollisionEntry *new_entry, - const LPoint3 &into_intersection_point, +set_intersection_point(CollisionEntry *new_entry, + const LPoint3 &into_intersection_point, double extra_radius) const { LPoint3 point; LVector3 normal; @@ -955,28 +890,23 @@ set_intersection_point(CollisionEntry *new_entry, new_entry->set_surface_normal(normal); new_entry->set_surface_point(point); // Also adjust the original point into the tube by the amount of - // extra_radius, which should put it on the surface of the tube if - // our collision was tangential. + // extra_radius, which should put it on the surface of the tube if our + // collision was tangential. new_entry->set_interior_point(into_intersection_point - normal * extra_radius); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CollisionTube. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CollisionTube. + */ void CollisionTube:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CollisionTube:: write_datagram(BamWriter *manager, Datagram &dg) { CollisionSolid::write_datagram(manager, dg); @@ -985,14 +915,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_radius); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CollisionTube is encountered -// in the Bam file. It should create the CollisionTube -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CollisionTube is encountered in the Bam file. It should create the + * CollisionTube and extract its information from the file. + */ TypedWritable *CollisionTube:: make_from_bam(const FactoryParams ¶ms) { CollisionTube *node = new CollisionTube(); @@ -1005,13 +932,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionTube::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CollisionTube. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CollisionTube. + */ void CollisionTube:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionSolid::fillin(scan, manager); diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h index 09a00d025e..afc14d71dc 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionTube.h @@ -1,16 +1,15 @@ -// Filename: collisionTube.h -// Created by: drose (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTube.h + * @author drose + * @date 2003-09-25 + */ #ifndef COLLISIONTUBE_H #define COLLISIONTUBE_H @@ -19,14 +18,11 @@ #include "collisionSolid.h" #include "parabola.h" -//////////////////////////////////////////////////////////////////// -// Class : CollisionTube -// Description : This implements a solid roughly in cylindrical shape. -// It's not called a CollisionCylinder because it's not -// a true cylinder; specifically, it has rounded ends -// instead of flat ends. It looks more like a Contac -// pill. -//////////////////////////////////////////////////////////////////// +/** + * This implements a solid roughly in cylindrical shape. It's not called a + * CollisionCylinder because it's not a true cylinder; specifically, it has + * rounded ends instead of flat ends. It looks more like a Contac pill. + */ class EXPCL_PANDA_COLLIDE CollisionTube : public CollisionSolid { PUBLISHED: INLINE CollisionTube(const LPoint3 &a, const LPoint3 &db, @@ -107,8 +103,8 @@ private: double extra_radius, LPoint3 &result_point, LVector3 &result_normal) const; - void set_intersection_point(CollisionEntry *new_entry, - const LPoint3 &into_intersection_point, + void set_intersection_point(CollisionEntry *new_entry, + const LPoint3 &into_intersection_point, double extra_radius) const; private: @@ -152,5 +148,3 @@ private: #include "collisionTube.I" #endif - - diff --git a/panda/src/collide/collisionVisualizer.I b/panda/src/collide/collisionVisualizer.I index 915c4843f9..3c14f309cf 100644 --- a/panda/src/collide/collisionVisualizer.I +++ b/panda/src/collide/collisionVisualizer.I @@ -1,23 +1,19 @@ -// Filename: collisionVisualizer.I -// Created by: drose (17Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionVisualizer.I + * @author drose + * @date 2003-04-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::SolidInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollisionVisualizer::SolidInfo:: SolidInfo() { _detected_count = 0; @@ -25,84 +21,65 @@ SolidInfo() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::set_point_scale -// Access: Published -// Description: Scales the points that are drawn to represent the -// surface and interior intersection points of the -// collisions. By default, these objects are drawn at -// an arbitrary scale which is appropriate if the window -// units are the default range -1 .. 1. Change this -// scale accordinatly if the window units are measured -// on some other scale or if you need to observe these -// objects in a smaller window. -//////////////////////////////////////////////////////////////////// +/** + * Scales the points that are drawn to represent the surface and interior + * intersection points of the collisions. By default, these objects are drawn + * at an arbitrary scale which is appropriate if the window units are the + * default range -1 .. 1. Change this scale accordinatly if the window units + * are measured on some other scale or if you need to observe these objects in + * a smaller window. + */ INLINE void CollisionVisualizer:: set_point_scale(PN_stdfloat point_scale) { _point_scale = point_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::get_point_scale -// Access: Published -// Description: Returns the value last set by set_point_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value last set by set_point_scale(). + */ INLINE PN_stdfloat CollisionVisualizer:: get_point_scale() const { return _point_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::set_normal_scale -// Access: Published -// Description: Scales the line segments that are drawn to represent -// the normals of the collisions. By default, these -// objects are drawn at an arbitrary scale which is -// appropriate if the scene units are measured in feet. -// Change this scale accordinatly if the scene units are -// measured on some other scale or if you need to -// observe these normals from farther away. -//////////////////////////////////////////////////////////////////// +/** + * Scales the line segments that are drawn to represent the normals of the + * collisions. By default, these objects are drawn at an arbitrary scale + * which is appropriate if the scene units are measured in feet. Change this + * scale accordinatly if the scene units are measured on some other scale or + * if you need to observe these normals from farther away. + */ INLINE void CollisionVisualizer:: set_normal_scale(PN_stdfloat normal_scale) { _normal_scale = normal_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::get_normal_scale -// Access: Published -// Description: Returns the value last set by set_normal_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value last set by set_normal_scale(). + */ INLINE PN_stdfloat CollisionVisualizer:: get_normal_scale() const { return _normal_scale; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::as_typed_object -// Access: Public -// Description: This is provided to disambiguate the typecast to -// TypedObject, since we have two TypedObjects in our -// inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * This is provided to disambiguate the typecast to TypedObject, since we have + * two TypedObjects in our inheritance chain. + */ INLINE TypedObject *CollisionVisualizer:: as_typed_object() { - // In fact, it really doesn't matter which one we pick. Arbitrarily - // pick the one that goes through PandaNode. + // In fact, it really doesn't matter which one we pick. Arbitrarily pick + // the one that goes through PandaNode. return PandaNode::as_typed_object(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::as_typed_object -// Access: Public -// Description: This is provided to disambiguate the typecast to -// TypedObject, since we have two TypedObjects in our -// inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * This is provided to disambiguate the typecast to TypedObject, since we have + * two TypedObjects in our inheritance chain. + */ INLINE const TypedObject * CollisionVisualizer:: as_typed_object() const { - // In fact, it really doesn't matter which one we pick. Arbitrarily - // pick the one that goes through PandaNode. + // In fact, it really doesn't matter which one we pick. Arbitrarily pick + // the one that goes through PandaNode. return PandaNode::as_typed_object(); } - diff --git a/panda/src/collide/collisionVisualizer.cxx b/panda/src/collide/collisionVisualizer.cxx index 3a09d25803..19699b9d6f 100644 --- a/panda/src/collide/collisionVisualizer.cxx +++ b/panda/src/collide/collisionVisualizer.cxx @@ -1,16 +1,15 @@ -// Filename: collisionVisualizer.cxx -// Created by: drose (16Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionVisualizer.cxx + * @author drose + * @date 2003-04-16 + */ #include "collisionVisualizer.h" #include "collisionEntry.h" @@ -38,80 +37,64 @@ TypeHandle CollisionVisualizer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionVisualizer:: CollisionVisualizer(const string &name) : PandaNode(name) { set_cull_callback(); - // We always want to render the CollisionVisualizer node itself - // (even if it doesn't appear to have any geometry within it). + // We always want to render the CollisionVisualizer node itself (even if it + // doesn't appear to have any geometry within it). set_internal_bounds(new OmniBoundingVolume()); _point_scale = 1.0f; _normal_scale = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CollisionVisualizer:: ~CollisionVisualizer() { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::clear -// Access: Published -// Description: Removes all the visualization data from a previous -// traversal and resets the visualizer to empty. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the visualization data from a previous traversal and resets the + * visualizer to empty. + */ void CollisionVisualizer:: clear() { _data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *CollisionVisualizer:: make_copy() const { return new CollisionVisualizer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool CollisionVisualizer:: cull_callback(CullTraverser *trav, CullTraverserData &data) { // Now we go through and actually draw our visualized collision solids. @@ -123,10 +106,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { CullTraverserData xform_data(data); - // We don't want to inherit the transform from above! We ignore - // whatever transforms were above the CollisionVisualizer node; it - // always renders its objects according to their appropriate net - // transform. + // We don't want to inherit the transform from above! We ignore whatever + // transforms were above the CollisionVisualizer node; it always renders + // its objects according to their appropriate net transform. xform_data._net_transform = TransformState::make_identity(); xform_data._view_frustum = trav->get_view_frustum(); xform_data.apply_transform_and_state(trav, net_transform, @@ -138,10 +120,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { Solids::const_iterator si; for (si = viz_info._solids.begin(); si != viz_info._solids.end(); ++si) { // Note that we don't preserve the clip plane attribute from the - // collision solid. We always draw the whole polygon (or - // whatever) in the CollisionVisualizer. This is a deliberate - // decision; clipping the polygons may obscure many collision - // tests that are being made. + // collision solid. We always draw the whole polygon (or whatever) in + // the CollisionVisualizer. This is a deliberate decision; clipping the + // polygons may obscure many collision tests that are being made. const CollisionSolid *solid = (*si).first; const SolidInfo &solid_info = (*si).second; bool was_detected = (solid_info._detected_count > 0); @@ -149,8 +130,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { if (node != (PandaNode *)NULL) { CullTraverserData next_data(xform_data, node); - // We don't want to inherit the render state from above for - // these guys. + // We don't want to inherit the render state from above for these + // guys. next_data._state = get_viz_state(); trav->traverse(next_data); } @@ -175,8 +156,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { for (pi = viz_info._points.begin(); pi != viz_info._points.end(); ++pi) { const CollisionPoint &point = (*pi); - // Draw a small red point at the surface point, and a smaller - // white point at the interior point. + // Draw a small red point at the surface point, and a smaller white + // point at the interior point. { PT(GeomVertexData) point_vdata = new GeomVertexData("viz", point_format, Geom::UH_stream); @@ -247,30 +228,23 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool CollisionVisualizer:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void CollisionVisualizer:: output(ostream &out) const { PandaNode::output(out); @@ -278,28 +252,22 @@ output(ostream &out) const { CollisionRecorder::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::begin_traversal -// Access: Public, Virtual -// Description: This method is called at the beginning of a -// CollisionTraverser::traverse() call. It is provided -// as a hook for the derived class to reset its state as -// appropriate. -//////////////////////////////////////////////////////////////////// +/** + * This method is called at the beginning of a CollisionTraverser::traverse() + * call. It is provided as a hook for the derived class to reset its state as + * appropriate. + */ void CollisionVisualizer:: begin_traversal() { CollisionRecorder::begin_traversal(); _data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::collision_tested -// Access: Public, Virtual -// Description: This method is called when a pair of collision solids -// have passed all bounding-volume tests and have been -// tested for a collision. The detected value is set -// true if a collision was detected, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method is called when a pair of collision solids have passed all + * bounding-volume tests and have been tested for a collision. The detected + * value is set true if a collision was detected, false otherwise. + */ void CollisionVisualizer:: collision_tested(const CollisionEntry &entry, bool detected) { CollisionRecorder::collision_tested(entry, detected); @@ -326,16 +294,14 @@ collision_tested(const CollisionEntry &entry, bool detected) { } -//////////////////////////////////////////////////////////////////// -// Function: CollisionVisualizer::get_viz_state -// Access: Private -// Description: Returns a RenderState suitable for rendering the -// collision solids with which a collision was detected. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState suitable for rendering the collision solids with + * which a collision was detected. + */ CPT(RenderState) CollisionVisualizer:: get_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make diff --git a/panda/src/collide/collisionVisualizer.h b/panda/src/collide/collisionVisualizer.h index e5ddf76833..27c2d257a4 100644 --- a/panda/src/collide/collisionVisualizer.h +++ b/panda/src/collide/collisionVisualizer.h @@ -1,16 +1,15 @@ -// Filename: collisionVisualizer.h -// Created by: drose (16Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionVisualizer.h + * @author drose + * @date 2003-04-16 + */ #ifndef COLLISIONVISUALIZER_H #define COLLISIONVISUALIZER_H @@ -24,16 +23,14 @@ #ifdef DO_COLLISION_RECORDING -//////////////////////////////////////////////////////////////////// -// Class : CollisionVisualizer -// Description : This class is used to help debug the work the -// collisions system is doing. It shows the polygons -// that are detected as collisions, as well as those -// that are simply considered for collisions. -// -// It may be parented anywhere in the scene graph where -// it will be rendered to achieve this. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to help debug the work the collisions system is doing. + * It shows the polygons that are detected as collisions, as well as those + * that are simply considered for collisions. + * + * It may be parented anywhere in the scene graph where it will be rendered to + * achieve this. + */ class EXPCL_PANDA_COLLIDE CollisionVisualizer : public PandaNode, public CollisionRecorder { PUBLISHED: CollisionVisualizer(const string &name); @@ -121,6 +118,6 @@ private: #include "collisionVisualizer.I" -#endif // DO_COLLISION_RECORDING +#endif // DO_COLLISION_RECORDING #endif diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index 9787432888..e1999cd147 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -1,16 +1,15 @@ -// Filename: config_collide.cxx -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_collide.cxx + * @author drose + * @date 2000-04-24 + */ #include "config_collide.h" #include "collisionBox.h" @@ -108,14 +107,12 @@ ConfigVariableBool pushers_horizontal "set_horizontal() flag by default, false to let the move " "in three dimensions by default.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libcollide -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libcollide() { static bool initialized = false; diff --git a/panda/src/collide/config_collide.h b/panda/src/collide/config_collide.h index 158ec755fb..ba9fb1a9bb 100644 --- a/panda/src/collide/config_collide.h +++ b/panda/src/collide/config_collide.h @@ -1,16 +1,15 @@ -// Filename: config_collide.h -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_collide.h + * @author drose + * @date 2000-04-24 + */ #ifndef CONFIG_COLLIDE_H #define CONFIG_COLLIDE_H diff --git a/panda/src/collide/test_collide.cxx b/panda/src/collide/test_collide.cxx index 433abc9d43..38736d5d38 100644 --- a/panda/src/collide/test_collide.cxx +++ b/panda/src/collide/test_collide.cxx @@ -1,16 +1,15 @@ -// Filename: test_collide.cxx -// Created by: drose (24Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_collide.cxx + * @author drose + * @date 2000-04-24 + */ #include "collisionTraverser.h" #include "collisionNode.h" @@ -69,4 +68,3 @@ main(int argc, char *argv[]) { return (0); } - diff --git a/panda/src/cull/binCullHandler.I b/panda/src/cull/binCullHandler.I index 5e1abc5a49..e88cbed4d5 100644 --- a/panda/src/cull/binCullHandler.I +++ b/panda/src/cull/binCullHandler.I @@ -1,23 +1,19 @@ -// Filename: binCullHandler.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binCullHandler.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BinCullHandler::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BinCullHandler:: BinCullHandler(CullResult *cull_result) : _cull_result(cull_result) diff --git a/panda/src/cull/binCullHandler.cxx b/panda/src/cull/binCullHandler.cxx index 309be0a548..53feb15bd4 100644 --- a/panda/src/cull/binCullHandler.cxx +++ b/panda/src/cull/binCullHandler.cxx @@ -1,27 +1,23 @@ -// Filename: binCullHandler.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binCullHandler.cxx + * @author drose + * @date 2002-02-28 + */ #include "binCullHandler.h" #include "pStatTimer.h" -//////////////////////////////////////////////////////////////////// -// Function: BinCullHandler::record_object -// Access: Public, Virtual -// Description: This callback function is intended to be overridden -// by a derived class. This is called as each Geom is -// discovered by the CullTraverser. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is intended to be overridden by a derived class. + * This is called as each Geom is discovered by the CullTraverser. + */ void BinCullHandler:: record_object(CullableObject *object, const CullTraverser *traverser) { _cull_result->add_object(object, traverser); diff --git a/panda/src/cull/binCullHandler.h b/panda/src/cull/binCullHandler.h index 4322aba49e..afe73103ed 100644 --- a/panda/src/cull/binCullHandler.h +++ b/panda/src/cull/binCullHandler.h @@ -1,16 +1,15 @@ -// Filename: binCullHandler.h -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binCullHandler.h + * @author drose + * @date 2002-02-28 + */ #ifndef BINCULLHANDLER_H #define BINCULLHANDLER_H @@ -20,18 +19,16 @@ #include "cullResult.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : BinCullHandler -// Description : This CullHandler sends all of the geoms it receives -// into a CullResult object, for binning (and later -// drawing). This is the kind of CullHandler to use for -// most normal rendering needs. -//////////////////////////////////////////////////////////////////// +/** + * This CullHandler sends all of the geoms it receives into a CullResult + * object, for binning (and later drawing). This is the kind of CullHandler + * to use for most normal rendering needs. + */ class EXPCL_PANDA_CULL BinCullHandler : public CullHandler { public: INLINE BinCullHandler(CullResult *cull_result); - virtual void record_object(CullableObject *object, + virtual void record_object(CullableObject *object, const CullTraverser *traverser); private: @@ -41,6 +38,3 @@ private: #include "binCullHandler.I" #endif - - - diff --git a/panda/src/cull/config_cull.cxx b/panda/src/cull/config_cull.cxx index cb5639ebf8..a3b4b4881a 100644 --- a/panda/src/cull/config_cull.cxx +++ b/panda/src/cull/config_cull.cxx @@ -1,16 +1,15 @@ -// Filename: config_cull.cxx -// Created by: drose (23Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cull.cxx + * @author drose + * @date 2006-03-23 + */ #include "config_cull.h" @@ -30,14 +29,12 @@ ConfigureFn(config_cull) { init_libcull(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libcull -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libcull() { static bool initialized = false; diff --git a/panda/src/cull/config_cull.h b/panda/src/cull/config_cull.h index 8450b107f3..3fb68765b1 100644 --- a/panda/src/cull/config_cull.h +++ b/panda/src/cull/config_cull.h @@ -1,16 +1,15 @@ -// Filename: config_cull.h -// Created by: drose (23Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_cull.h + * @author drose + * @date 2006-03-23 + */ #ifndef CONFIG_CULL_H #define CONFIG_CULL_H diff --git a/panda/src/cull/cullBinBackToFront.I b/panda/src/cull/cullBinBackToFront.I index 45641e8b4c..4e77012ac5 100644 --- a/panda/src/cull/cullBinBackToFront.I +++ b/panda/src/cull/cullBinBackToFront.I @@ -1,23 +1,19 @@ -// Filename: cullBinBackToFront.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinBackToFront.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinBackToFront:: CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : @@ -25,11 +21,9 @@ CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg, { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::ObjectData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinBackToFront::ObjectData:: ObjectData(CullableObject *object, PN_stdfloat dist) : _object(object), @@ -37,14 +31,10 @@ ObjectData(CullableObject *object, PN_stdfloat dist) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::ObjectData::operator < -// Access: Public -// Description: Specifies the correct sort ordering for these -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the correct sort ordering for these objects. + */ INLINE bool CullBinBackToFront::ObjectData:: operator < (const ObjectData &other) const { return _dist > other._dist; } - diff --git a/panda/src/cull/cullBinBackToFront.cxx b/panda/src/cull/cullBinBackToFront.cxx index 9e67adc36b..e472d0811d 100644 --- a/panda/src/cull/cullBinBackToFront.cxx +++ b/panda/src/cull/cullBinBackToFront.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinBackToFront.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinBackToFront.cxx + * @author drose + * @date 2002-02-28 + */ #include "cullBinBackToFront.h" #include "graphicsStateGuardianBase.h" @@ -24,11 +23,9 @@ TypeHandle CullBinBackToFront::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBinBackToFront:: ~CullBinBackToFront() { Objects::iterator oi; @@ -38,23 +35,18 @@ CullBinBackToFront:: } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::make_bin -// Access: Public, Static -// Description: Factory constructor for passing to the CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Factory constructor for passing to the CullBinManager. + */ CullBin *CullBinBackToFront:: make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinBackToFront(name, gsg, draw_region_pcollector); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::add_object -// Access: Public, Virtual -// Description: Adds a geom, along with its associated state, to -// the bin for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Adds a geom, along with its associated state, to the bin for rendering. + */ void CullBinBackToFront:: add_object(CullableObject *object, Thread *current_thread) { // Determine the center of the bounding volume. @@ -75,27 +67,20 @@ add_object(CullableObject *object, Thread *current_thread) { _objects.push_back(ObjectData(object, distance)); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::finish_cull -// Access: Public -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullBinBackToFront:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); sort(_objects.begin(), _objects.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::draw -// Access: Public, Virtual -// Description: Draws all the geoms in the bin, in the appropriate -// order. -//////////////////////////////////////////////////////////////////// +/** + * Draws all the geoms in the bin, in the appropriate order. + */ void CullBinBackToFront:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); @@ -106,12 +91,10 @@ draw(bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinBackToFront::fill_result_graph -// Access: Protected, Virtual -// Description: Called by CullBin::make_result_graph() to add all the -// geoms to the special cull result scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Called by CullBin::make_result_graph() to add all the geoms to the special + * cull result scene graph. + */ void CullBinBackToFront:: fill_result_graph(CullBin::ResultGraphBuilder &builder) { Objects::const_iterator oi; diff --git a/panda/src/cull/cullBinBackToFront.h b/panda/src/cull/cullBinBackToFront.h index 93544cc69d..515fafc1a5 100644 --- a/panda/src/cull/cullBinBackToFront.h +++ b/panda/src/cull/cullBinBackToFront.h @@ -1,16 +1,15 @@ -// Filename: cullBinBackToFront.h -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinBackToFront.h + * @author drose + * @date 2002-02-28 + */ #ifndef CULLBINBACKTOFRONT_H #define CULLBINBACKTOFRONT_H @@ -23,25 +22,23 @@ #include "renderState.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinBackToFront -// Description : A specific kind of CullBin that sorts geometry in -// order from furthest to nearest based on the center of -// its bounding volume. This is primarily intended for -// rendering transparent and semi-transparent geometry -// that must be sorted from back to front. -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of CullBin that sorts geometry in order from furthest to + * nearest based on the center of its bounding volume. This is primarily + * intended for rendering transparent and semi-transparent geometry that must + * be sorted from back to front. + */ class EXPCL_PANDA_CULL CullBinBackToFront : public CullBin { public: - INLINE CullBinBackToFront(const string &name, + INLINE CullBinBackToFront(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinBackToFront(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); - + virtual void add_object(CullableObject *object, Thread *current_thread); virtual void finish_cull(SceneSetup *scene_setup, Thread *current_thread); @@ -55,7 +52,7 @@ private: public: INLINE ObjectData(CullableObject *object, PN_stdfloat dist); INLINE bool operator < (const ObjectData &other) const; - + CullableObject *_object; PN_stdfloat _dist; }; @@ -84,6 +81,3 @@ private: #include "cullBinBackToFront.I" #endif - - - diff --git a/panda/src/cull/cullBinFixed.I b/panda/src/cull/cullBinFixed.I index e7e4a8a552..117512283d 100644 --- a/panda/src/cull/cullBinFixed.I +++ b/panda/src/cull/cullBinFixed.I @@ -1,23 +1,19 @@ -// Filename: cullBinFixed.I -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFixed.I + * @author drose + * @date 2002-05-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinFixed:: CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : @@ -25,11 +21,9 @@ CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg, { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::ObjectData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinFixed::ObjectData:: ObjectData(CullableObject *object, int draw_order) : _object(object), @@ -37,14 +31,10 @@ ObjectData(CullableObject *object, int draw_order) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::ObjectData::operator < -// Access: Public -// Description: Specifies the correct sort ordering for these -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the correct sort ordering for these objects. + */ INLINE bool CullBinFixed::ObjectData:: operator < (const ObjectData &other) const { return _draw_order < other._draw_order; } - diff --git a/panda/src/cull/cullBinFixed.cxx b/panda/src/cull/cullBinFixed.cxx index 919880496d..3db9b9f7fb 100644 --- a/panda/src/cull/cullBinFixed.cxx +++ b/panda/src/cull/cullBinFixed.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinFixed.cxx -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFixed.cxx + * @author drose + * @date 2002-05-29 + */ #include "cullBinFixed.h" #include "graphicsStateGuardianBase.h" @@ -24,11 +23,9 @@ TypeHandle CullBinFixed::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBinFixed:: ~CullBinFixed() { Objects::iterator oi; @@ -38,50 +35,38 @@ CullBinFixed:: } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::make_bin -// Access: Public, Static -// Description: Factory constructor for passing to the CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Factory constructor for passing to the CullBinManager. + */ CullBin *CullBinFixed:: make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFixed(name, gsg, draw_region_pcollector); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::add_object -// Access: Public, Virtual -// Description: Adds a geom, along with its associated state, to -// the bin for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Adds a geom, along with its associated state, to the bin for rendering. + */ void CullBinFixed:: add_object(CullableObject *object, Thread *current_thread) { int draw_order = object->_state->get_draw_order(); _objects.push_back(ObjectData(object, draw_order)); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::finish_cull -// Access: Public -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullBinFixed:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); stable_sort(_objects.begin(), _objects.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::draw -// Access: Public, Virtual -// Description: Draws all the geoms in the bin, in the appropriate -// order. -//////////////////////////////////////////////////////////////////// +/** + * Draws all the geoms in the bin, in the appropriate order. + */ void CullBinFixed:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); @@ -92,12 +77,10 @@ draw(bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFixed::fill_result_graph -// Access: Protected, Virtual -// Description: Called by CullBin::make_result_graph() to add all the -// geoms to the special cull result scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Called by CullBin::make_result_graph() to add all the geoms to the special + * cull result scene graph. + */ void CullBinFixed:: fill_result_graph(CullBin::ResultGraphBuilder &builder) { Objects::const_iterator oi; diff --git a/panda/src/cull/cullBinFixed.h b/panda/src/cull/cullBinFixed.h index 31acccf71b..f2d1c8fd07 100644 --- a/panda/src/cull/cullBinFixed.h +++ b/panda/src/cull/cullBinFixed.h @@ -1,16 +1,15 @@ -// Filename: cullBinFixed.h -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFixed.h + * @author drose + * @date 2002-05-29 + */ #ifndef CULLBINFIXED_H #define CULLBINFIXED_H @@ -23,25 +22,22 @@ #include "renderState.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinFixed -// Description : A specific kind of CullBin that sorts geometry in -// the order specified by the user-specified draw_order -// parameter. This allows precise relative ordering of -// two objects. -// -// When two or more objects are assigned the same -// draw_order, they are drawn in scene-graph order (as -// with CullBinUnsorted). -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of CullBin that sorts geometry in the order specified by + * the user-specified draw_order parameter. This allows precise relative + * ordering of two objects. + * + * When two or more objects are assigned the same draw_order, they are drawn + * in scene-graph order (as with CullBinUnsorted). + */ class EXPCL_PANDA_CULL CullBinFixed : public CullBin { public: - INLINE CullBinFixed(const string &name, + INLINE CullBinFixed(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinFixed(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); @@ -57,7 +53,7 @@ private: public: INLINE ObjectData(CullableObject *object, int draw_order); INLINE bool operator < (const ObjectData &other) const; - + CullableObject *_object; int _draw_order; }; @@ -86,6 +82,3 @@ private: #include "cullBinFixed.I" #endif - - - diff --git a/panda/src/cull/cullBinFrontToBack.I b/panda/src/cull/cullBinFrontToBack.I index d1d4bae261..4605e5e6ef 100644 --- a/panda/src/cull/cullBinFrontToBack.I +++ b/panda/src/cull/cullBinFrontToBack.I @@ -1,23 +1,19 @@ -// Filename: cullBinFrontToBack.I -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFrontToBack.I + * @author drose + * @date 2002-05-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinFrontToBack:: CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : @@ -25,11 +21,9 @@ CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg, { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::ObjectData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinFrontToBack::ObjectData:: ObjectData(CullableObject *object, PN_stdfloat dist) : _object(object), @@ -37,14 +31,10 @@ ObjectData(CullableObject *object, PN_stdfloat dist) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::ObjectData::operator < -// Access: Public -// Description: Specifies the correct sort ordering for these -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the correct sort ordering for these objects. + */ INLINE bool CullBinFrontToBack::ObjectData:: operator < (const ObjectData &other) const { return _dist < other._dist; } - diff --git a/panda/src/cull/cullBinFrontToBack.cxx b/panda/src/cull/cullBinFrontToBack.cxx index ba2103a0f7..1800b5636a 100644 --- a/panda/src/cull/cullBinFrontToBack.cxx +++ b/panda/src/cull/cullBinFrontToBack.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinFrontToBack.cxx -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFrontToBack.cxx + * @author drose + * @date 2002-05-29 + */ #include "cullBinFrontToBack.h" #include "graphicsStateGuardianBase.h" @@ -24,11 +23,9 @@ TypeHandle CullBinFrontToBack::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBinFrontToBack:: ~CullBinFrontToBack() { Objects::iterator oi; @@ -38,23 +35,18 @@ CullBinFrontToBack:: } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::make_bin -// Access: Public, Static -// Description: Factory constructor for passing to the CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Factory constructor for passing to the CullBinManager. + */ CullBin *CullBinFrontToBack:: make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinFrontToBack(name, gsg, draw_region_pcollector); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::add_object -// Access: Public, Virtual -// Description: Adds a geom, along with its associated state, to -// the bin for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Adds a geom, along with its associated state, to the bin for rendering. + */ void CullBinFrontToBack:: add_object(CullableObject *object, Thread *current_thread) { // Determine the center of the bounding volume. @@ -75,27 +67,20 @@ add_object(CullableObject *object, Thread *current_thread) { _objects.push_back(ObjectData(object, distance)); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::finish_cull -// Access: Public -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullBinFrontToBack:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); sort(_objects.begin(), _objects.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::draw -// Access: Public -// Description: Draws all the geoms in the bin, in the appropriate -// order. -//////////////////////////////////////////////////////////////////// +/** + * Draws all the geoms in the bin, in the appropriate order. + */ void CullBinFrontToBack:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); @@ -106,12 +91,10 @@ draw(bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinFrontToBack::fill_result_graph -// Access: Protected, Virtual -// Description: Called by CullBin::make_result_graph() to add all the -// geoms to the special cull result scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Called by CullBin::make_result_graph() to add all the geoms to the special + * cull result scene graph. + */ void CullBinFrontToBack:: fill_result_graph(CullBin::ResultGraphBuilder &builder) { Objects::const_iterator oi; diff --git a/panda/src/cull/cullBinFrontToBack.h b/panda/src/cull/cullBinFrontToBack.h index a23cb8e551..6ee0d4424a 100644 --- a/panda/src/cull/cullBinFrontToBack.h +++ b/panda/src/cull/cullBinFrontToBack.h @@ -1,16 +1,15 @@ -// Filename: cullBinFrontToBack.h -// Created by: drose (29May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinFrontToBack.h + * @author drose + * @date 2002-05-29 + */ #ifndef CULLBINFRONTTOBACK_H #define CULLBINFRONTTOBACK_H @@ -23,23 +22,21 @@ #include "renderState.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinFrontToBack -// Description : A specific kind of CullBin that sorts geometry in -// order from nearest to furthest based on the center of -// its bounding volume. -// -// This is useful for rendering opaque geometry, taking -// optimal advantage of a hierarchical Z-buffer. -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of CullBin that sorts geometry in order from nearest to + * furthest based on the center of its bounding volume. + * + * This is useful for rendering opaque geometry, taking optimal advantage of a + * hierarchical Z-buffer. + */ class EXPCL_PANDA_CULL CullBinFrontToBack : public CullBin { public: - INLINE CullBinFrontToBack(const string &name, + INLINE CullBinFrontToBack(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinFrontToBack(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); @@ -55,7 +52,7 @@ private: public: INLINE ObjectData(CullableObject *object, PN_stdfloat dist); INLINE bool operator < (const ObjectData &other) const; - + CullableObject *_object; PN_stdfloat _dist; }; @@ -84,6 +81,3 @@ private: #include "cullBinFrontToBack.I" #endif - - - diff --git a/panda/src/cull/cullBinStateSorted.I b/panda/src/cull/cullBinStateSorted.I index fd8558e846..e035c433bb 100644 --- a/panda/src/cull/cullBinStateSorted.I +++ b/panda/src/cull/cullBinStateSorted.I @@ -1,23 +1,19 @@ -// Filename: cullBinStateSorted.I -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinStateSorted.I + * @author drose + * @date 2005-03-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinStateSorted:: CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : @@ -26,11 +22,9 @@ CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg, { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::ObjectData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinStateSorted::ObjectData:: ObjectData(CullableObject *object) : _object(object) @@ -42,16 +36,13 @@ ObjectData(CullableObject *object) : } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::ObjectData::operator < -// Access: Public -// Description: Specifies the correct sort ordering for these -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the correct sort ordering for these objects. + */ INLINE bool CullBinStateSorted::ObjectData:: operator < (const ObjectData &other) const { - // Group by state changes, in approximate order from heaviest - // change to lightest change. + // Group by state changes, in approximate order from heaviest change to + // lightest change. const RenderState *sa = _object->_state; const RenderState *sb = other._object->_state; int compare = sa->compare_sort(*sb); @@ -76,4 +67,3 @@ operator < (const ObjectData &other) const { return 0; } - diff --git a/panda/src/cull/cullBinStateSorted.cxx b/panda/src/cull/cullBinStateSorted.cxx index 1f71c483e1..c7ba58c295 100644 --- a/panda/src/cull/cullBinStateSorted.cxx +++ b/panda/src/cull/cullBinStateSorted.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinStateSorted.cxx -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinStateSorted.cxx + * @author drose + * @date 2005-03-22 + */ #include "cullBinStateSorted.h" #include "graphicsStateGuardianBase.h" @@ -23,11 +22,9 @@ TypeHandle CullBinStateSorted::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBinStateSorted:: ~CullBinStateSorted() { Objects::iterator oi; @@ -37,37 +34,28 @@ CullBinStateSorted:: } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::make_bin -// Access: Public, Static -// Description: Factory constructor for passing to the CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Factory constructor for passing to the CullBinManager. + */ CullBin *CullBinStateSorted:: make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinStateSorted(name, gsg, draw_region_pcollector); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::add_object -// Access: Public, Virtual -// Description: Adds a geom, along with its associated state, to -// the bin for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Adds a geom, along with its associated state, to the bin for rendering. + */ void CullBinStateSorted:: add_object(CullableObject *object, Thread *current_thread) { _objects.push_back(ObjectData(object)); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::finish_cull -// Access: Public -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullBinStateSorted:: finish_cull(SceneSetup *, Thread *current_thread) { PStatTimer timer(_cull_this_pcollector, current_thread); @@ -75,12 +63,9 @@ finish_cull(SceneSetup *, Thread *current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::draw -// Access: Public, Virtual -// Description: Draws all the geoms in the bin, in the appropriate -// order. -//////////////////////////////////////////////////////////////////// +/** + * Draws all the geoms in the bin, in the appropriate order. + */ void CullBinStateSorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); @@ -91,12 +76,10 @@ draw(bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinStateSorted::fill_result_graph -// Access: Protected, Virtual -// Description: Called by CullBin::make_result_graph() to add all the -// geoms to the special cull result scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Called by CullBin::make_result_graph() to add all the geoms to the special + * cull result scene graph. + */ void CullBinStateSorted:: fill_result_graph(CullBin::ResultGraphBuilder &builder) { Objects::const_iterator oi; diff --git a/panda/src/cull/cullBinStateSorted.h b/panda/src/cull/cullBinStateSorted.h index 70b0f85803..6f20882135 100644 --- a/panda/src/cull/cullBinStateSorted.h +++ b/panda/src/cull/cullBinStateSorted.h @@ -1,16 +1,15 @@ -// Filename: cullBinStateSorted.h -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinStateSorted.h + * @author drose + * @date 2005-03-22 + */ #ifndef CULLBINSTATESORTED_H #define CULLBINSTATESORTED_H @@ -24,26 +23,23 @@ #include "renderState.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinStateSorted -// Description : A specific kind of CullBin that sorts geometry to -// collect items of the same state together, so that -// minimal state changes are required on the GSG to -// render them. -// -// This also sorts objects front-to-back within a -// particular state, to take advantage of hierarchical -// Z-buffer algorithms which can early-out when an -// object appears behind another one. -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of CullBin that sorts geometry to collect items of the same + * state together, so that minimal state changes are required on the GSG to + * render them. + * + * This also sorts objects front-to-back within a particular state, to take + * advantage of hierarchical Z-buffer algorithms which can early-out when an + * object appears behind another one. + */ class EXPCL_PANDA_CULL CullBinStateSorted : public CullBin { public: - INLINE CullBinStateSorted(const string &name, + INLINE CullBinStateSorted(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); virtual ~CullBinStateSorted(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); @@ -59,7 +55,7 @@ private: public: INLINE ObjectData(CullableObject *object); INLINE bool operator < (const ObjectData &other) const; - + CullableObject *_object; const GeomVertexFormat *_format; }; @@ -88,6 +84,3 @@ private: #include "cullBinStateSorted.I" #endif - - - diff --git a/panda/src/cull/cullBinUnsorted.I b/panda/src/cull/cullBinUnsorted.I index 482803b60c..f9a8d37dc0 100644 --- a/panda/src/cull/cullBinUnsorted.I +++ b/panda/src/cull/cullBinUnsorted.I @@ -1,23 +1,19 @@ -// Filename: cullBinUnsorted.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinUnsorted.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBinUnsorted:: CullBinUnsorted(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : diff --git a/panda/src/cull/cullBinUnsorted.cxx b/panda/src/cull/cullBinUnsorted.cxx index 9957c61132..e9de061fb1 100644 --- a/panda/src/cull/cullBinUnsorted.cxx +++ b/panda/src/cull/cullBinUnsorted.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinUnsorted.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinUnsorted.cxx + * @author drose + * @date 2002-02-28 + */ #include "cullBinUnsorted.h" #include "cullHandler.h" @@ -20,11 +19,9 @@ TypeHandle CullBinUnsorted::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBinUnsorted:: ~CullBinUnsorted() { Objects::iterator oi; @@ -34,34 +31,26 @@ CullBinUnsorted:: } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::make_bin -// Access: Public, Static -// Description: Factory constructor for passing to the CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Factory constructor for passing to the CullBinManager. + */ CullBin *CullBinUnsorted:: make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { return new CullBinUnsorted(name, gsg, draw_region_pcollector); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::add_object -// Access: Public, Virtual -// Description: Adds a geom, along with its associated state, to -// the bin for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Adds a geom, along with its associated state, to the bin for rendering. + */ void CullBinUnsorted:: add_object(CullableObject *object, Thread *current_thread) { _objects.push_back(object); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::draw -// Access: Public, Virtual -// Description: Draws all the objects in the bin, in the appropriate -// order. -//////////////////////////////////////////////////////////////////// +/** + * Draws all the objects in the bin, in the appropriate order. + */ void CullBinUnsorted:: draw(bool force, Thread *current_thread) { PStatTimer timer(_draw_this_pcollector, current_thread); @@ -72,12 +61,10 @@ draw(bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinUnsorted::fill_result_graph -// Access: Protected, Virtual -// Description: Called by CullBin::make_result_graph() to add all the -// geoms to the special cull result scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Called by CullBin::make_result_graph() to add all the geoms to the special + * cull result scene graph. + */ void CullBinUnsorted:: fill_result_graph(CullBin::ResultGraphBuilder &builder) { Objects::const_iterator oi; diff --git a/panda/src/cull/cullBinUnsorted.h b/panda/src/cull/cullBinUnsorted.h index f7e069828c..0c682155d8 100644 --- a/panda/src/cull/cullBinUnsorted.h +++ b/panda/src/cull/cullBinUnsorted.h @@ -1,16 +1,15 @@ -// Filename: cullBinUnsorted.h -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinUnsorted.h + * @author drose + * @date 2002-02-28 + */ #ifndef CULLBINUNSORTED_H #define CULLBINUNSORTED_H @@ -20,21 +19,19 @@ #include "cullBin.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinUnsorted -// Description : A specific kind of CullBin that does not reorder the -// geometry; it simply passes it through to the GSG in -// the same order it was encountered, which will be in -// scene-graph order. -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of CullBin that does not reorder the geometry; it simply + * passes it through to the GSG in the same order it was encountered, which + * will be in scene-graph order. + */ class EXPCL_PANDA_CULL CullBinUnsorted : public CullBin { public: - INLINE CullBinUnsorted(const string &name, + INLINE CullBinUnsorted(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); ~CullBinUnsorted(); - static CullBin *make_bin(const string &name, + static CullBin *make_bin(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); @@ -69,6 +66,3 @@ private: #include "cullBinUnsorted.I" #endif - - - diff --git a/panda/src/cull/drawCullHandler.I b/panda/src/cull/drawCullHandler.I index e359fb5dbd..d321817cfb 100644 --- a/panda/src/cull/drawCullHandler.I +++ b/panda/src/cull/drawCullHandler.I @@ -1,23 +1,19 @@ -// Filename: drawCullHandler.I -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawCullHandler.I + * @author drose + * @date 2002-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DrawCullHandler::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DrawCullHandler:: DrawCullHandler(GraphicsStateGuardianBase *gsg) : _gsg(gsg) diff --git a/panda/src/cull/drawCullHandler.cxx b/panda/src/cull/drawCullHandler.cxx index bbaa2fe1b3..78e27a0086 100644 --- a/panda/src/cull/drawCullHandler.cxx +++ b/panda/src/cull/drawCullHandler.cxx @@ -1,16 +1,15 @@ -// Filename: drawCullHandler.cxx -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawCullHandler.cxx + * @author drose + * @date 2002-02-25 + */ #include "drawCullHandler.h" #include "cullableObject.h" @@ -21,17 +20,14 @@ #include "config_pgraph.h" #include "cullTraverser.h" -//////////////////////////////////////////////////////////////////// -// Function: DrawCullHandler::record_object -// Access: Public, Virtual -// Description: This callback function is intended to be overridden -// by a derived class. This is called as each Geom is -// discovered by the CullTraverser. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is intended to be overridden by a derived class. + * This is called as each Geom is discovered by the CullTraverser. + */ void DrawCullHandler:: record_object(CullableObject *object, const CullTraverser *traverser) { - // Munge vertices as needed for the GSG's requirements, and the - // object's current state. + // Munge vertices as needed for the GSG's requirements, and the object's + // current state. bool force = !_gsg->get_effective_incomplete_render(); Thread *current_thread = traverser->get_current_thread(); diff --git a/panda/src/cull/drawCullHandler.h b/panda/src/cull/drawCullHandler.h index 7fea30c8b3..5d8b5d3e41 100644 --- a/panda/src/cull/drawCullHandler.h +++ b/panda/src/cull/drawCullHandler.h @@ -1,16 +1,15 @@ -// Filename: drawCullHandler.h -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawCullHandler.h + * @author drose + * @date 2002-02-25 + */ #ifndef DRAWCULLHANDLER_H #define DRAWCULLHANDLER_H @@ -20,17 +19,14 @@ class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : DrawCullHandler -// Description : This special kind of CullHandler immediately draws -// its contents as soon as it receives them. This draws -// geometry immediately as it is encountered in the -// scene graph by cull, mixing the draw and cull -// traversals into one traversal, and prohibiting state -// sorting. However, it has somewhat lower overhead -// than separating out draw and cull, if state sorting -// and multiprocessing are not required. -//////////////////////////////////////////////////////////////////// +/** + * This special kind of CullHandler immediately draws its contents as soon as + * it receives them. This draws geometry immediately as it is encountered in + * the scene graph by cull, mixing the draw and cull traversals into one + * traversal, and prohibiting state sorting. However, it has somewhat lower + * overhead than separating out draw and cull, if state sorting and + * multiprocessing are not required. + */ class EXPCL_PANDA_CULL DrawCullHandler : public CullHandler { public: INLINE DrawCullHandler(GraphicsStateGuardianBase *gsg); @@ -45,4 +41,3 @@ private: #include "drawCullHandler.I" #endif - diff --git a/panda/src/device/analogNode.I b/panda/src/device/analogNode.I index 9747587b73..ec41944491 100644 --- a/panda/src/device/analogNode.I +++ b/panda/src/device/analogNode.I @@ -1,47 +1,38 @@ -// Filename: analogNode.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file analogNode.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::OutputData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AnalogNode::OutputData:: OutputData() { _index = -1; _flip = false; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::is_valid -// Access: Public -// Description: Returns true if the AnalogNode is valid and -// connected to a server, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the AnalogNode is valid and connected to a server, false + * otherwise. + */ INLINE bool AnalogNode:: is_valid() const { return (_analog != (ClientAnalogDevice *)NULL) && _analog->is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::get_num_controls -// Access: Public -// Description: Returns the number of analog controls known to the -// AnalogNode. This number may change as more controls -// are discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of analog controls known to the AnalogNode. This number + * may change as more controls are discovered. + */ INLINE int AnalogNode:: get_num_controls() const { _analog->acquire(); @@ -50,14 +41,11 @@ get_num_controls() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::get_control_state -// Access: Public -// Description: Returns the current position of indicated analog -// control identified by its index number, or 0.0 if -// the control is unknown. The normal range of a single -// control is -1.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of indicated analog control identified by its + * index number, or 0.0 if the control is unknown. The normal range of a + * single control is -1.0 to 1.0. + */ INLINE double AnalogNode:: get_control_state(int index) const { _analog->acquire(); @@ -66,13 +54,10 @@ get_control_state(int index) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::is_control_known -// Access: Public -// Description: Returns true if the state of the indicated analog -// control is known, or false if we have never heard -// anything about this particular control. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated analog control is known, or + * false if we have never heard anything about this particular control. + */ INLINE bool AnalogNode:: is_control_known(int index) const { _analog->acquire(); @@ -81,16 +66,12 @@ is_control_known(int index) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::set_output -// Access: Public -// Description: Causes a particular analog control to be placed in -// the data graph for the indicated channel. Normally, -// a mouse uses channels 0 and 1 for the X and Y -// information, respectively; channels 0, 1, and 2 are -// available. If flip is true, the analog control value -// will be reversed before outputting it. -//////////////////////////////////////////////////////////////////// +/** + * Causes a particular analog control to be placed in the data graph for the + * indicated channel. Normally, a mouse uses channels 0 and 1 for the X and Y + * information, respectively; channels 0, 1, and 2 are available. If flip is + * true, the analog control value will be reversed before outputting it. + */ INLINE void AnalogNode:: set_output(int channel, int index, bool flip) { nassertv(channel >= 0 && channel < max_outputs); @@ -98,38 +79,31 @@ set_output(int channel, int index, bool flip) { _outputs[channel]._flip = flip; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::clear_output -// Access: Public -// Description: Removes the output to the data graph associated with -// the indicated channel. See set_output(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the output to the data graph associated with the indicated channel. + * See set_output(). + */ INLINE void AnalogNode:: clear_output(int channel) { nassertv(channel >= 0 && channel < max_outputs); _outputs[channel]._index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::get_output -// Access: Public -// Description: Returns the analog control index that is output to -// the data graph on the indicated channel, or -1 if no -// control is output on that channel. See set_output(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the analog control index that is output to the data graph on the + * indicated channel, or -1 if no control is output on that channel. See + * set_output(). + */ INLINE int AnalogNode:: get_output(int channel) const { nassertr(channel >= 0 && channel < max_outputs, -1); return _outputs[channel]._index; } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::is_output_flipped -// Access: Public -// Description: Returns true if the analog control index that is -// output to the data graph on the indicated channel is -// flipped. See set_output(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the analog control index that is output to the data graph + * on the indicated channel is flipped. See set_output(). + */ INLINE bool AnalogNode:: is_output_flipped(int channel) const { nassertr(channel >= 0 && channel < max_outputs, false); diff --git a/panda/src/device/analogNode.cxx b/panda/src/device/analogNode.cxx index 1bea47ceb2..d577496554 100644 --- a/panda/src/device/analogNode.cxx +++ b/panda/src/device/analogNode.cxx @@ -1,16 +1,15 @@ -// Filename: analogNode.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file analogNode.cxx + * @author drose + * @date 2002-03-12 + */ #include "analogNode.h" #include "config_device.h" @@ -20,11 +19,9 @@ TypeHandle AnalogNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnalogNode:: AnalogNode(ClientBase *client, const string &device_name) : DataNode(device_name) @@ -52,23 +49,19 @@ AnalogNode(ClientBase *client, const string &device_name) : _analog = DCAST(ClientAnalogDevice, device); } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnalogNode:: ~AnalogNode() { - // When the _analog pointer destructs, the ClientAnalogDevice - // disconnects itself from the ClientBase, and everything that needs - // to get turned off does. Magic. + // When the _analog pointer destructs, the ClientAnalogDevice disconnects + // itself from the ClientBase, and everything that needs to get turned off + // does. Magic. } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnalogNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); @@ -80,21 +73,16 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AnalogNode::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void AnalogNode:: -do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, +do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { if (is_valid()) { _analog->poll(); diff --git a/panda/src/device/analogNode.h b/panda/src/device/analogNode.h index 216c4ae0d4..862277e90b 100644 --- a/panda/src/device/analogNode.h +++ b/panda/src/device/analogNode.h @@ -1,16 +1,15 @@ -// Filename: analogNode.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file analogNode.h + * @author drose + * @date 2002-03-12 + */ #ifndef ANALOGNODE_H #define ANALOGNODE_H @@ -23,25 +22,20 @@ #include "linmath_events.h" -//////////////////////////////////////////////////////////////////// -// Class : AnalogNode -// Description : This is the primary interface to analog controls like -// sliders and joysticks associated with a ClientBase. -// This creates a node that connects to the named analog -// device, if it exists, and provides hooks to the user -// to read the state of any of the sequentially numbered -// controls associated with that device. -// -// Each control can return a value ranging from -1 to 1, -// reflecting the current position of the control within -// its total range of motion. -// -// The user may choose up to two analog controls to -// place on the data graph as the two channels of an -// xy datagram, similarly to the way a mouse places its -// position data. In this way, an AnalogNode may be -// used in place of a mouse. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary interface to analog controls like sliders and joysticks + * associated with a ClientBase. This creates a node that connects to the + * named analog device, if it exists, and provides hooks to the user to read + * the state of any of the sequentially numbered controls associated with that + * device. + * + * Each control can return a value ranging from -1 to 1, reflecting the + * current position of the control within its total range of motion. + * + * The user may choose up to two analog controls to place on the data graph as + * the two channels of an xy datagram, similarly to the way a mouse places its + * position data. In this way, an AnalogNode may be used in place of a mouse. + */ class EXPCL_PANDA_DEVICE AnalogNode : public DataNode { PUBLISHED: AnalogNode(ClientBase *client, const string &device_name); diff --git a/panda/src/device/buttonNode.I b/panda/src/device/buttonNode.I index 27faac8325..1fa5efd21b 100644 --- a/panda/src/device/buttonNode.I +++ b/panda/src/device/buttonNode.I @@ -1,39 +1,31 @@ -// Filename: buttonNode.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonNode.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::is_valid -// Access: Public -// Description: Returns true if the ButtonNode is valid and -// connected to a server, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ButtonNode is valid and connected to a server, false + * otherwise. + */ INLINE bool ButtonNode:: is_valid() const { return (_button != (ClientButtonDevice *)NULL) && _button->is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::get_num_buttons -// Access: Public -// Description: Returns the number of buttons known to the -// ButtonNode. This includes those buttons whose state -// has been seen, as well as buttons that have been -// associated with a ButtonHandle even if their state is -// unknown. This number may change as more buttons are -// discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of buttons known to the ButtonNode. This includes those + * buttons whose state has been seen, as well as buttons that have been + * associated with a ButtonHandle even if their state is unknown. This number + * may change as more buttons are discovered. + */ INLINE int ButtonNode:: get_num_buttons() const { _button->acquire(); @@ -42,20 +34,16 @@ get_num_buttons() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::set_button_map -// Access: Public -// Description: Associates the indicated ButtonHandle with the button -// of the indicated index number. When the given button -// index changes state, a corresponding ButtonEvent will -// be generated with the given ButtonHandle. Pass -// ButtonHandle::none() to turn off any association. -// -// It is not necessary to call this if you simply want -// to query the state of the various buttons by index -// number; this is only necessary in order to generate -// ButtonEvents when the buttons change state. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated ButtonHandle with the button of the indicated + * index number. When the given button index changes state, a corresponding + * ButtonEvent will be generated with the given ButtonHandle. Pass + * ButtonHandle::none() to turn off any association. + * + * It is not necessary to call this if you simply want to query the state of + * the various buttons by index number; this is only necessary in order to + * generate ButtonEvents when the buttons change state. + */ INLINE void ButtonNode:: set_button_map(int index, ButtonHandle button) { _button->acquire(); @@ -63,14 +51,11 @@ set_button_map(int index, ButtonHandle button) { _button->unlock(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::get_button_map -// Access: Public -// Description: Returns the ButtonHandle that was previously -// associated with the given index number by -// a call to set_button_map(), or ButtonHandle::none() -// if no button was associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle that was previously associated with the given + * index number by a call to set_button_map(), or ButtonHandle::none() if no + * button was associated. + */ INLINE ButtonHandle ButtonNode:: get_button_map(int index) const { _button->acquire(); @@ -79,13 +64,10 @@ get_button_map(int index) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::get_button_state -// Access: Public -// Description: Returns true if the indicated button (identified by -// its index number) is currently known to be down, or -// false if it is up or unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button (identified by its index number) is + * currently known to be down, or false if it is up or unknown. + */ INLINE bool ButtonNode:: get_button_state(int index) const { _button->acquire(); @@ -94,13 +76,10 @@ get_button_state(int index) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::is_button_known -// Access: Public -// Description: Returns true if the state of the indicated button is -// known, or false if we have never heard anything about -// this particular button. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated button is known, or false if we + * have never heard anything about this particular button. + */ INLINE bool ButtonNode:: is_button_known(int index) const { _button->acquire(); diff --git a/panda/src/device/buttonNode.cxx b/panda/src/device/buttonNode.cxx index ebae5309a3..e3125a2db3 100644 --- a/panda/src/device/buttonNode.cxx +++ b/panda/src/device/buttonNode.cxx @@ -1,16 +1,15 @@ -// Filename: buttonNode.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonNode.cxx + * @author drose + * @date 2002-03-12 + */ #include "buttonNode.h" #include "config_device.h" @@ -20,11 +19,9 @@ TypeHandle ButtonNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonNode:: ButtonNode(ClientBase *client, const string &device_name) : DataNode(device_name) @@ -52,23 +49,19 @@ ButtonNode(ClientBase *client, const string &device_name) : _button = DCAST(ClientButtonDevice, device); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonNode:: ~ButtonNode() { - // When the _button pointer destructs, the ClientButtonDevice - // disconnects itself from the ClientBase, and everything that needs - // to get turned off does. Magic. + // When the _button pointer destructs, the ClientButtonDevice disconnects + // itself from the ClientBase, and everything that needs to get turned off + // does. Magic. } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonNode:: output(ostream &out) const { DataNode::output(out); @@ -82,11 +75,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonNode:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); @@ -98,21 +89,16 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonNode::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void ButtonNode:: -do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, +do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { if (is_valid()) { _button->poll(); diff --git a/panda/src/device/buttonNode.h b/panda/src/device/buttonNode.h index e5298a57ac..4399151d4f 100644 --- a/panda/src/device/buttonNode.h +++ b/panda/src/device/buttonNode.h @@ -1,16 +1,15 @@ -// Filename: buttonNode.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonNode.h + * @author drose + * @date 2002-03-12 + */ #ifndef BUTTONNODE_H #define BUTTONNODE_H @@ -23,21 +22,16 @@ #include "buttonEventList.h" -//////////////////////////////////////////////////////////////////// -// Class : ButtonNode -// Description : This is the primary interface to on/off button -// devices associated with a ClientBase. This creates a -// node that connects to the named button device, if it -// exists, and provides hooks to the user to read the -// state of any of the sequentially numbered buttons -// associated with that device. -// -// It also can associate an arbitrary ButtonHandle with -// each button; when buttons are associated with -// ButtonHandles, this node will put appropriate up and -// down events on the data graph for each button state -// change. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary interface to on/off button devices associated with a + * ClientBase. This creates a node that connects to the named button device, + * if it exists, and provides hooks to the user to read the state of any of + * the sequentially numbered buttons associated with that device. + * + * It also can associate an arbitrary ButtonHandle with each button; when + * buttons are associated with ButtonHandles, this node will put appropriate + * up and down events on the data graph for each button state change. + */ class EXPCL_PANDA_DEVICE ButtonNode : public DataNode { PUBLISHED: ButtonNode(ClientBase *client, const string &device_name); diff --git a/panda/src/device/clientAnalogDevice.I b/panda/src/device/clientAnalogDevice.I index c36619d4f1..aad2deafd4 100644 --- a/panda/src/device/clientAnalogDevice.I +++ b/panda/src/device/clientAnalogDevice.I @@ -1,23 +1,19 @@ -// Filename: clientAnalogDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientAnalogDevice.I + * @author drose + * @date 2001-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::AnalogState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientAnalogDevice::AnalogState:: AnalogState() : _state(0.0), @@ -25,38 +21,30 @@ AnalogState() : { } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientAnalogDevice:: ClientAnalogDevice(ClientBase *client, const string &device_name): ClientDevice(client, get_class_type(), device_name) { } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::get_num_controls -// Access: Public -// Description: Returns the number of analog controls known to the -// ClientAnalogDevice. This number may change as -// more controls are discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of analog controls known to the ClientAnalogDevice. + * This number may change as more controls are discovered. + */ INLINE int ClientAnalogDevice:: get_num_controls() const { return _controls.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::set_control_state -// Access: Public -// Description: Sets the state of the indicated analog index. The -// caller should ensure that acquire() is in effect while -// this call is made. This should be a number in the -// range -1.0 to 1.0, representing the current position -// of the control within its total range of movement. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the indicated analog index. The caller should ensure + * that acquire() is in effect while this call is made. This should be a + * number in the range -1.0 to 1.0, representing the current position of the + * control within its total range of movement. + */ INLINE void ClientAnalogDevice:: set_control_state(int index, double state) { ensure_control_index(index); @@ -65,14 +53,11 @@ set_control_state(int index, double state) { _controls[index]._known = true; } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::get_control_state -// Access: Public -// Description: Returns the current position of indicated analog -// control (identified by its index number), or 0.0 if -// the control is unknown. The normal range of a single -// control is -1.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of indicated analog control (identified by its + * index number), or 0.0 if the control is unknown. The normal range of a + * single control is -1.0 to 1.0. + */ INLINE double ClientAnalogDevice:: get_control_state(int index) const { if (index >= 0 && index < (int)_controls.size()) { @@ -82,13 +67,10 @@ get_control_state(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::is_control_known -// Access: Public -// Description: Returns true if the state of the indicated analog -// control is known, or false if we have never heard -// anything about this particular control. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated analog control is known, or + * false if we have never heard anything about this particular control. + */ INLINE bool ClientAnalogDevice:: is_control_known(int index) const { if (index >= 0 && index < (int)_controls.size()) { diff --git a/panda/src/device/clientAnalogDevice.cxx b/panda/src/device/clientAnalogDevice.cxx index 1dbe277c82..47ddde620b 100644 --- a/panda/src/device/clientAnalogDevice.cxx +++ b/panda/src/device/clientAnalogDevice.cxx @@ -1,17 +1,15 @@ -// Filename: clientAnalogDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientAnalogDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "clientAnalogDevice.h" @@ -21,13 +19,10 @@ TypeHandle ClientAnalogDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::ensure_control_index -// Access: Private -// Description: Guarantees that there is a slot in the array for the -// indicated index number, by filling the array up to -// that index if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Guarantees that there is a slot in the array for the indicated index + * number, by filling the array up to that index if necessary. + */ void ClientAnalogDevice:: ensure_control_index(int index) { nassertv(index >= 0); @@ -38,23 +33,18 @@ ensure_control_index(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClientAnalogDevice:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_device_name() << ":\n"; write_controls(out, indent_level + 2); } -//////////////////////////////////////////////////////////////////// -// Function: ClientAnalogDevice::write_analogs -// Access: Public -// Description: Writes a multi-line description of the current analog -// control states. -//////////////////////////////////////////////////////////////////// +/** + * Writes a multi-line description of the current analog control states. + */ void ClientAnalogDevice:: write_controls(ostream &out, int indent_level) const { bool any_controls = false; diff --git a/panda/src/device/clientAnalogDevice.h b/panda/src/device/clientAnalogDevice.h index 4db8fa53c4..95040f49a4 100644 --- a/panda/src/device/clientAnalogDevice.h +++ b/panda/src/device/clientAnalogDevice.h @@ -1,16 +1,15 @@ -// Filename: clientAnalogDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientAnalogDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef CLIENTANALOGDEVICE_H #define CLIENTANALOGDEVICE_H @@ -19,18 +18,14 @@ #include "clientDevice.h" -//////////////////////////////////////////////////////////////////// -// Class : ClientAnalogDevice -// Description : A device, attached to the ClientBase by a -// AnalogNode, that records the data from a single -// named analog device. The named device can contain -// any number of analog controls, numbered in -// sequence beginning at zero. -// -// Each analog control returns a value ranging from -1 -// to 1, reflecting the current position of the control -// within its total range of motion. -//////////////////////////////////////////////////////////////////// +/** + * A device, attached to the ClientBase by a AnalogNode, that records the data + * from a single named analog device. The named device can contain any number + * of analog controls, numbered in sequence beginning at zero. + * + * Each analog control returns a value ranging from -1 to 1, reflecting the + * current position of the control within its total range of motion. + */ class EXPCL_PANDA_DEVICE ClientAnalogDevice : public ClientDevice { protected: INLINE ClientAnalogDevice(ClientBase *client, const string &device_name); diff --git a/panda/src/device/clientBase.I b/panda/src/device/clientBase.I index c68b467b95..a237ce9653 100644 --- a/panda/src/device/clientBase.I +++ b/panda/src/device/clientBase.I @@ -1,39 +1,30 @@ -// Filename: clientBase.I -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientBase.I + * @author drose + * @date 2001-01-25 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::is_forked -// Access: Public -// Description: Returns true if the ClientBase has been forked (and, -// therefore, poll() does not need to be called), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ClientBase has been forked (and, therefore, poll() does + * not need to be called), false otherwise. + */ INLINE bool ClientBase:: is_forked() const { return _forked; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::poll -// Access: Public -// Description: Initiates a poll of the client devices, if we are not -// forked and if we have not already polled this frame. -// Returns true if the poll occurred, or false if it did -// not. -//////////////////////////////////////////////////////////////////// +/** + * Initiates a poll of the client devices, if we are not forked and if we have + * not already polled this frame. Returns true if the poll occurred, or false + * if it did not. + */ INLINE bool ClientBase:: poll() { if (_forked || @@ -45,37 +36,28 @@ poll() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::get_last_poll_time -// Access: Public -// Description: Returns the time (according to the global -// ClockObject's get_real_time() method) of the last -// device poll. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time (according to the global ClockObject's get_real_time() + * method) of the last device poll. + */ INLINE double ClientBase:: get_last_poll_time() const { return _last_poll_time; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::set_coordinate_system -// Access: Published -// Description: Specifies the coordinate system that all devices -// associated with this client will operate in. -// Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the coordinate system that all devices associated with this + * client will operate in. Normally, this is CS_default. + */ void ClientBase:: set_coordinate_system(CoordinateSystem cs) { _cs = cs; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::get_coordinate_system -// Access: Published -// Description: Returns the coordinate system that all devices -// associated with this client will operate in. -// Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system that all devices associated with this client + * will operate in. Normally, this is CS_default. + */ INLINE CoordinateSystem ClientBase:: get_coordinate_system() const { return _cs; diff --git a/panda/src/device/clientBase.cxx b/panda/src/device/clientBase.cxx index bf50c26d12..8a061ce5f5 100644 --- a/panda/src/device/clientBase.cxx +++ b/panda/src/device/clientBase.cxx @@ -1,28 +1,24 @@ -// Filename: clientBase.cxx -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientBase.cxx + * @author jason + * @date 2000-08-04 + */ #include "clientBase.h" #include "config_device.h" TypeHandle ClientBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClientBase:: ClientBase() { _forked = false; @@ -37,11 +33,9 @@ ClientBase() { } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClientBase:: ~ClientBase() { // We have to disconnect all of our devices before destructing. @@ -60,24 +54,20 @@ ClientBase:: if (_forked) { _shutdown = true; - // Join the loader thread - calling process blocks until the loader - // thread returns. + // Join the loader thread - calling process blocks until the loader thread + // returns. void *ret; _client_thread->join(&ret); } #endif } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::fork_asynchronous_thread -// Access: Public -// Description: Forks a separate thread to do all the polling of -// connected devices. The forked thread will poll after -// every poll_time seconds has elapsed. Returns true if -// the fork was successful, or false otherwise (for -// instance, because we were already forked, or because -// asynchronous threads are disabled). -//////////////////////////////////////////////////////////////////// +/** + * Forks a separate thread to do all the polling of connected devices. The + * forked thread will poll after every poll_time seconds has elapsed. Returns + * true if the fork was successful, or false otherwise (for instance, because + * we were already forked, or because asynchronous threads are disabled). + */ bool ClientBase:: fork_asynchronous_thread(double poll_time) { #ifdef OLD_HAVE_IPC @@ -104,30 +94,24 @@ fork_asynchronous_thread(double poll_time) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::get_device -// Access: Public -// Description: Returns a ClientDevice pointer that corresponds to -// the named device of the indicated device type. The -// device_type should be one of ClientTrackerDevice, -// ClientAnalogDevice, etc.; the device_name is -// implementation defined. -// -// Normally, the user does not need to call this -// function directly; it is called automatically by -// creating a TrackerNode or AnalogNode or some such -// data graph node. -// -// The return value is the pointer to the created device -// (which might be the same pointer returned by a -// previous call to this function with the same -// parameters). When the pointer destructs (i.e. its -// reference count reaches zero) it will automatically -// be disconnected. -// -// If the named device does not exist or cannot be -// connected for some reason, NULL is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ClientDevice pointer that corresponds to the named device of the + * indicated device type. The device_type should be one of + * ClientTrackerDevice, ClientAnalogDevice, etc.; the device_name is + * implementation defined. + * + * Normally, the user does not need to call this function directly; it is + * called automatically by creating a TrackerNode or AnalogNode or some such + * data graph node. + * + * The return value is the pointer to the created device (which might be the + * same pointer returned by a previous call to this function with the same + * parameters). When the pointer destructs (i.e. its reference count reaches + * zero) it will automatically be disconnected. + * + * If the named device does not exist or cannot be connected for some reason, + * NULL is returned. + */ PT(ClientDevice) ClientBase:: get_device(TypeHandle device_type, const string &device_name) { DevicesByName &dbn = _devices[device_type]; @@ -150,19 +134,14 @@ get_device(TypeHandle device_type, const string &device_name) { return device; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::disconnect_device -// Access: Protected, Virtual -// Description: Removes the device, which is presumably about to -// destruct, from the list of connected devices, and -// frees any data required to support it. This device -// will no longer receive automatic updates with each -// poll. -// -// The return value is true if the device was -// disconnected, or false if it was unknown (e.g. it was -// disconnected previously). -//////////////////////////////////////////////////////////////////// +/** + * Removes the device, which is presumably about to destruct, from the list of + * connected devices, and frees any data required to support it. This device + * will no longer receive automatic updates with each poll. + * + * The return value is true if the device was disconnected, or false if it was + * unknown (e.g. it was disconnected previously). + */ bool ClientBase:: disconnect_device(TypeHandle device_type, const string &device_name, ClientDevice *device) { @@ -182,15 +161,12 @@ disconnect_device(TypeHandle device_type, const string &device_name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::do_poll -// Access: Protected, Virtual -// Description: Implements the polling and updating of connected -// devices, if the ClientBase requires this. This may -// be called in a sub-thread if -// fork_asynchronous_thread() was called; otherwise, it -// will be called once per frame. -//////////////////////////////////////////////////////////////////// +/** + * Implements the polling and updating of connected devices, if the ClientBase + * requires this. This may be called in a sub-thread if + * fork_asynchronous_thread() was called; otherwise, it will be called once + * per frame. + */ void ClientBase:: do_poll() { ClockObject *global_clock = ClockObject::get_global_clock(); @@ -199,18 +175,14 @@ do_poll() { } #ifdef OLD_HAVE_IPC -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::st_callback -// Access: Private, Static -// Description: Call back function for thread (if thread has been -// spawned). A call back function must be static, so -// this merely calls the non-static member callback In -// addition, the function has a void* return type even -// though we don't actually return anything. This is -// necessary because ipc assumes a function that does -// not return anything indicates that the associated -// thread should be created as unjoinable (detached). -//////////////////////////////////////////////////////////////////// +/** + * Call back function for thread (if thread has been spawned). A call back + * function must be static, so this merely calls the non-static member + * callback In addition, the function has a void* return type even though we + * don't actually return anything. This is necessary because ipc assumes a + * function that does not return anything indicates that the associated thread + * should be created as unjoinable (detached). + */ void *ClientBase:: st_callback(void *arg) { nassertr(arg != NULL, NULL); @@ -218,13 +190,10 @@ st_callback(void *arg) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ClientBase::callback -// Access: Private -// Description: This is the main body of the sub-thread. It sleeps -// a certain time and then polls all devices currently -// being watched -//////////////////////////////////////////////////////////////////// +/** + * This is the main body of the sub-thread. It sleeps a certain time and then + * polls all devices currently being watched + */ void ClientBase:: callback() { while (true) { diff --git a/panda/src/device/clientBase.h b/panda/src/device/clientBase.h index c1bcab3ee0..d7ee1cf605 100644 --- a/panda/src/device/clientBase.h +++ b/panda/src/device/clientBase.h @@ -1,16 +1,15 @@ -// Filename: clientBase.h -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientBase.h + * @author jason + * @date 2000-08-04 + */ #ifndef CLIENTBASE_H #define CLIENTBASE_H @@ -33,17 +32,14 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ClientBase -// Description : An abstract base class for a family of client -// device interfaces--including trackers, buttons, -// dials, and other analog inputs. -// -// This provides a common interface to connect to such -// devices and extract their data; it is used by -// TrackerNode etc. to put these devices in the data -// graph. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for a family of client device interfaces--including + * trackers, buttons, dials, and other analog inputs. + * + * This provides a common interface to connect to such devices and extract + * their data; it is used by TrackerNode etc. to put these devices in the + * data graph. + */ class EXPCL_PANDA_DEVICE ClientBase : public TypedReferenceCount { protected: ClientBase(); diff --git a/panda/src/device/clientButtonDevice.I b/panda/src/device/clientButtonDevice.I index 21308006c9..90aafce0c5 100644 --- a/panda/src/device/clientButtonDevice.I +++ b/panda/src/device/clientButtonDevice.I @@ -1,23 +1,19 @@ -// Filename: clientButtonDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientButtonDevice.I + * @author drose + * @date 2001-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::ButtonState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientButtonDevice::ButtonState:: ButtonState() : _handle(ButtonHandle::none()), @@ -26,35 +22,27 @@ ButtonState() : } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::get_num_buttons -// Access: Public -// Description: Returns the number of buttons known to the -// ClientButtonDevice. This includes those buttons -// whose state has been seen, as well as buttons that -// have been associated with a ButtonHandle even if -// their state is unknown. This number may change as -// more buttons are discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of buttons known to the ClientButtonDevice. This + * includes those buttons whose state has been seen, as well as buttons that + * have been associated with a ButtonHandle even if their state is unknown. + * This number may change as more buttons are discovered. + */ INLINE int ClientButtonDevice:: get_num_buttons() const { return _buttons.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::set_button_map -// Access: Public -// Description: Associates the indicated ButtonHandle with the button -// of the indicated index number. When the given button -// index changes state, a corresponding ButtonEvent will -// be generated with the given ButtonHandle. Pass -// ButtonHandle::none() to turn off any association. -// -// It is not necessary to call this if you simply want -// to query the state of the various buttons by index -// number; this is only necessary in order to generate -// ButtonEvents when the buttons change state. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated ButtonHandle with the button of the indicated + * index number. When the given button index changes state, a corresponding + * ButtonEvent will be generated with the given ButtonHandle. Pass + * ButtonHandle::none() to turn off any association. + * + * It is not necessary to call this if you simply want to query the state of + * the various buttons by index number; this is only necessary in order to + * generate ButtonEvents when the buttons change state. + */ INLINE void ClientButtonDevice:: set_button_map(int index, ButtonHandle button) { ensure_button_index(index); @@ -62,14 +50,11 @@ set_button_map(int index, ButtonHandle button) { _buttons[index]._handle = button; } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::get_button_map -// Access: Public -// Description: Returns the ButtonHandle that was previously -// associated with the given index number by -// a call to set_button_map(), or ButtonHandle::none() -// if no button was associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle that was previously associated with the given + * index number by a call to set_button_map(), or ButtonHandle::none() if no + * button was associated. + */ INLINE ButtonHandle ClientButtonDevice:: get_button_map(int index) const { if (index >= 0 && index < (int)_buttons.size()) { @@ -79,13 +64,10 @@ get_button_map(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::get_button_state -// Access: Public -// Description: Returns true if the indicated button (identified by -// its index number) is currently known to be down, or -// false if it is up or unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button (identified by its index number) is + * currently known to be down, or false if it is up or unknown. + */ INLINE bool ClientButtonDevice:: get_button_state(int index) const { if (index >= 0 && index < (int)_buttons.size()) { @@ -95,13 +77,10 @@ get_button_state(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::is_button_known -// Access: Public -// Description: Returns true if the state of the indicated button is -// known, or false if we have never heard anything about -// this particular button. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated button is known, or false if we + * have never heard anything about this particular button. + */ INLINE bool ClientButtonDevice:: is_button_known(int index) const { if (index >= 0 && index < (int)_buttons.size()) { @@ -111,13 +90,10 @@ is_button_known(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::get_button_events -// Access: Public -// Description: Returns the list of recently-generated ButtonEvents. -// This must be periodically cleared, or the buttons -// will accumulate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of recently-generated ButtonEvents. This must be + * periodically cleared, or the buttons will accumulate. + */ INLINE ButtonEventList *ClientButtonDevice:: get_button_events() const { return _button_events; diff --git a/panda/src/device/clientButtonDevice.cxx b/panda/src/device/clientButtonDevice.cxx index e45561ac5a..60952f6a2c 100644 --- a/panda/src/device/clientButtonDevice.cxx +++ b/panda/src/device/clientButtonDevice.cxx @@ -1,17 +1,15 @@ -// Filename: clientButtonDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientButtonDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "clientButtonDevice.h" @@ -19,11 +17,9 @@ TypeHandle ClientButtonDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClientButtonDevice:: ClientButtonDevice(ClientBase *client, const string &device_name): ClientDevice(client, get_class_type(), device_name) @@ -32,15 +28,12 @@ ClientButtonDevice(ClientBase *client, const string &device_name): } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::set_button_state -// Access: Public -// Description: Sets the state of the indicated button index, where -// true indicates down, and false indicates up. This -// may generate a ButtonEvent if the button has an -// associated ButtonHandle. The caller should ensure -// that acquire() is in effect while this call is made. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the indicated button index, where true indicates down, + * and false indicates up. This may generate a ButtonEvent if the button has + * an associated ButtonHandle. The caller should ensure that acquire() is in + * effect while this call is made. + */ void ClientButtonDevice:: set_button_state(int index, bool down) { ensure_button_index(index); @@ -54,13 +47,10 @@ set_button_state(int index, bool down) { } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::ensure_button_index -// Access: Private -// Description: Guarantees that there is a slot in the array for the -// indicated index number, by filling the array up to -// that index if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Guarantees that there is a slot in the array for the indicated index + * number, by filling the array up to that index if necessary. + */ void ClientButtonDevice:: ensure_button_index(int index) { nassertv(index >= 0); @@ -71,11 +61,9 @@ ensure_button_index(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClientButtonDevice:: output(ostream &out) const { out << get_type() << " " << get_device_name() << " ("; @@ -83,23 +71,18 @@ output(ostream &out) const { out << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClientButtonDevice:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " " << get_device_name() << ":\n"; write_buttons(out, indent_level + 2); } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::output_buttons -// Access: Public -// Description: Writes a one-line string of all of the current button -// states. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line string of all of the current button states. + */ void ClientButtonDevice:: output_buttons(ostream &out) const { bool any_buttons = false; @@ -125,12 +108,9 @@ output_buttons(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientButtonDevice::write_buttons -// Access: Public -// Description: Writes a multi-line description of the current button -// states. -//////////////////////////////////////////////////////////////////// +/** + * Writes a multi-line description of the current button states. + */ void ClientButtonDevice:: write_buttons(ostream &out, int indent_level) const { bool any_buttons = false; diff --git a/panda/src/device/clientButtonDevice.h b/panda/src/device/clientButtonDevice.h index b9643d26c2..3c7a285e36 100644 --- a/panda/src/device/clientButtonDevice.h +++ b/panda/src/device/clientButtonDevice.h @@ -1,16 +1,15 @@ -// Filename: clientButtonDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientButtonDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef CLIENTBUTTONDEVICE_H #define CLIENTBUTTONDEVICE_H @@ -24,16 +23,12 @@ #include "buttonEventList.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : ClientButtonDevice -// Description : A device, attached to the ClientBase by a -// ButtonNode, that records the data from a single -// named button device. The named device can contain -// any number of up/down style buttons, numbered in -// sequence beginning at zero; these are mapped by this -// class to a sequence of ButtonHandles specified by the -// user. -//////////////////////////////////////////////////////////////////// +/** + * A device, attached to the ClientBase by a ButtonNode, that records the data + * from a single named button device. The named device can contain any number + * of up/down style buttons, numbered in sequence beginning at zero; these are + * mapped by this class to a sequence of ButtonHandles specified by the user. + */ class EXPCL_PANDA_DEVICE ClientButtonDevice : public ClientDevice { protected: ClientButtonDevice(ClientBase *client, const string &device_name); diff --git a/panda/src/device/clientDevice.I b/panda/src/device/clientDevice.I index efcb92e050..c4e1e5a7b7 100644 --- a/panda/src/device/clientDevice.I +++ b/panda/src/device/clientDevice.I @@ -1,77 +1,59 @@ -// Filename: clientDevice.I -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDevice.I + * @author drose + * @date 2001-01-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::get_client -// Access: Public -// Description: Returns the ClientBase this device is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ClientBase this device is associated with. + */ INLINE ClientBase *ClientDevice:: get_client() const { return _client; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::is_connected -// Access: Public -// Description: Returns true if the device is still connected to its -// ClientBase, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the device is still connected to its ClientBase, false + * otherwise. + */ INLINE bool ClientDevice:: is_connected() const { return _is_connected; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::get_device_type -// Access: Public -// Description: Returns the type of device this is considered to be -// to the ClientBase: a ClientTrackerDevice, -// ClientAnalogDevice, or what have you. This is not -// exactly the same thing as get_type(), because it does -// not return the exact type of the ClientDevice -// (e.g. it reports ClientTrackerDevice, not -// VrpnTrackerDevice). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of device this is considered to be to the ClientBase: a + * ClientTrackerDevice, ClientAnalogDevice, or what have you. This is not + * exactly the same thing as get_type(), because it does not return the exact + * type of the ClientDevice (e.g. it reports ClientTrackerDevice, not + * VrpnTrackerDevice). + */ INLINE TypeHandle ClientDevice:: get_device_type() const { return _device_type; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::get_device_name -// Access: Public -// Description: Returns the device name reported to the ClientBase. -// This has some implementation-defined meaning to -// identify particular devices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the device name reported to the ClientBase. This has some + * implementation-defined meaning to identify particular devices. + */ INLINE const string &ClientDevice:: get_device_name() const { return _device_name; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::acquire -// Access: Public -// Description: Grabs the mutex associated with this particular -// device. The device will not update asynchronously -// while the mutex is held, allowing the user to copy -// the data out without fear of getting a partial update -// during the copy. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the mutex associated with this particular device. The device will + * not update asynchronously while the mutex is held, allowing the user to + * copy the data out without fear of getting a partial update during the copy. + */ INLINE void ClientDevice:: acquire() { #ifdef OLD_HAVE_IPC @@ -79,13 +61,10 @@ acquire() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::unlock -// Access: Public -// Description: Releases the mutex associated with this particular -// device. This should be called after all the data has -// been successfully copied out. See acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the mutex associated with this particular device. This should be + * called after all the data has been successfully copied out. See acquire(). + */ INLINE void ClientDevice:: unlock() { #ifdef OLD_HAVE_IPC diff --git a/panda/src/device/clientDevice.cxx b/panda/src/device/clientDevice.cxx index d7f7aa90f4..f6bca213e5 100644 --- a/panda/src/device/clientDevice.cxx +++ b/panda/src/device/clientDevice.cxx @@ -1,17 +1,15 @@ -// Filename: clientDevice.cxx -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDevice.cxx + * @author drose + * @date 2001-01-25 + */ #include "clientDevice.h" #include "clientBase.h" @@ -20,11 +18,9 @@ TypeHandle ClientDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClientDevice:: ClientDevice(ClientBase *client, TypeHandle device_type, const string &device_name) : @@ -32,21 +28,17 @@ ClientDevice(ClientBase *client, TypeHandle device_type, _device_type(device_type), _device_name(device_name) { - // We have to explicitly ref the client pointer, since we can't use - // a PT(ClientBase) for circular include reasons. + // We have to explicitly ref the client pointer, since we can't use a + // PT(ClientBase) for circular include reasons. _client->ref(); _is_connected = false; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::Destructor -// Access: Public, Virtual -// Description: We don't actually call disconnect() at the -// ClientDevice level destructor, because by the time -// we get here we're already partly destructed. -// Instead, we should call disconnect() from each -// specific kind of derived class. -//////////////////////////////////////////////////////////////////// +/** + * We don't actually call disconnect() at the ClientDevice level destructor, + * because by the time we get here we're already partly destructed. Instead, + * we should call disconnect() from each specific kind of derived class. + */ ClientDevice:: ~ClientDevice() { nassertv(!_is_connected); @@ -55,21 +47,17 @@ ClientDevice:: unref_delete(_client); } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::disconnect -// Access: Public -// Description: Disconnects the ClientDevice from its ClientBase -// object. The device will stop receiving -// updates. -// -// Normally, you should not need to call this explicitly -// (and it is probably a mistake to do so); it will -// automatically be called when the ClientDevice object -// destructs. -// -// The lock should *not* be held while this call is -// made; it will explicitly grab the lock itself. -//////////////////////////////////////////////////////////////////// +/** + * Disconnects the ClientDevice from its ClientBase object. The device will + * stop receiving updates. + * + * Normally, you should not need to call this explicitly (and it is probably a + * mistake to do so); it will automatically be called when the ClientDevice + * object destructs. + * + * The lock should *not* be held while this call is made; it will explicitly + * grab the lock itself. + */ void ClientDevice:: disconnect() { if (_is_connected) { @@ -82,37 +70,30 @@ disconnect() { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::poll -// Access: Public -// Description: Causes the connected ClientBase to poll all of its -// clients, if necessary. This will be a no-op if the -// client is running in forked mode, or if it has -// already polled everything this frame. -// -// This should generally be called before accessing the -// data in this ClientDevice to ensure that it is fresh. -//////////////////////////////////////////////////////////////////// +/** + * Causes the connected ClientBase to poll all of its clients, if necessary. + * This will be a no-op if the client is running in forked mode, or if it has + * already polled everything this frame. + * + * This should generally be called before accessing the data in this + * ClientDevice to ensure that it is fresh. + */ void ClientDevice:: poll() { _client->poll(); } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClientDevice:: output(ostream &out) const { out << get_type() << " " << get_device_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ClientDevice::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClientDevice:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; diff --git a/panda/src/device/clientDevice.h b/panda/src/device/clientDevice.h index b0dbb116e3..d8424e9a1f 100644 --- a/panda/src/device/clientDevice.h +++ b/panda/src/device/clientDevice.h @@ -1,16 +1,15 @@ -// Filename: clientDevice.h -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDevice.h + * @author drose + * @date 2001-01-25 + */ #ifndef CLIENTDEVICE_H #define CLIENTDEVICE_H @@ -25,13 +24,11 @@ class ClientBase; -//////////////////////////////////////////////////////////////////// -// Class : ClientDevice -// Description : Any of a number of different devices that might be -// attached to a ClientBase, including trackers, etc. -// This is an abstract interface; the actual -// implementations are in ClientTrackerDevice, etc. -//////////////////////////////////////////////////////////////////// +/** + * Any of a number of different devices that might be attached to a + * ClientBase, including trackers, etc. This is an abstract interface; the + * actual implementations are in ClientTrackerDevice, etc. + */ class EXPCL_PANDA_DEVICE ClientDevice : public TypedReferenceCount { protected: ClientDevice(ClientBase *client, TypeHandle device_type, diff --git a/panda/src/device/clientDialDevice.I b/panda/src/device/clientDialDevice.I index f14e8a6e87..bf7fc3bca7 100644 --- a/panda/src/device/clientDialDevice.I +++ b/panda/src/device/clientDialDevice.I @@ -1,22 +1,19 @@ -// Filename: clientDialDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDialDevice.I + * @author drose + * @date 2001-01-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::DialState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientDialDevice::DialState:: DialState() : _offset(0.0), @@ -24,36 +21,29 @@ DialState() : { } -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientDialDevice:: ClientDialDevice(ClientBase *client, const string &device_name): ClientDevice(client, get_class_type(), device_name) { } -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::get_num_dials -// Access: Public -// Description: Returns the number of dial dials known to the -// ClientDialDevice. This number may change as -// more dials are discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of dial dials known to the ClientDialDevice. This + * number may change as more dials are discovered. + */ INLINE int ClientDialDevice:: get_num_dials() const { return _dials.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::push_dial -// Access: Public -// Description: Marks that the dial has been offset by the indicated -// amount. It is the user's responsibility to ensure -// that this call is protected within acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Marks that the dial has been offset by the indicated amount. It is the + * user's responsibility to ensure that this call is protected within + * acquire(). + */ INLINE void ClientDialDevice:: push_dial(int index, double offset) { ensure_dial_index(index); @@ -62,17 +52,14 @@ push_dial(int index, double offset) { _dials[index]._known = true; } -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::read_dial -// Access: Public -// Description: Returns the number of complete revolutions of the -// dial since the last time read_dial() was called. -// This is a destructive operation; it is not possible -// to read the dial without resetting the counter. -// -// It is the user's responsibility to ensure that this -// call is protected within acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of complete revolutions of the dial since the last time + * read_dial() was called. This is a destructive operation; it is not + * possible to read the dial without resetting the counter. + * + * It is the user's responsibility to ensure that this call is protected + * within acquire(). + */ INLINE double ClientDialDevice:: read_dial(int index) { if (index >= 0 && index < (int)_dials.size()) { @@ -84,13 +71,10 @@ read_dial(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::is_dial_known -// Access: Public -// Description: Returns true if the state of the indicated dial -// dial is known, or false if we have never heard -// anything about this particular dial. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated dial dial is known, or false if + * we have never heard anything about this particular dial. + */ INLINE bool ClientDialDevice:: is_dial_known(int index) const { if (index >= 0 && index < (int)_dials.size()) { diff --git a/panda/src/device/clientDialDevice.cxx b/panda/src/device/clientDialDevice.cxx index 044b9af413..4bb1292403 100644 --- a/panda/src/device/clientDialDevice.cxx +++ b/panda/src/device/clientDialDevice.cxx @@ -1,17 +1,15 @@ -// Filename: clientDialDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDialDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "clientDialDevice.h" @@ -21,13 +19,10 @@ TypeHandle ClientDialDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClientDialDevice::ensure_dial_index -// Access: Private -// Description: Guarantees that there is a slot in the array for the -// indicated index number, by filling the array up to -// that index if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Guarantees that there is a slot in the array for the indicated index + * number, by filling the array up to that index if necessary. + */ void ClientDialDevice:: ensure_dial_index(int index) { nassertv(index >= 0); diff --git a/panda/src/device/clientDialDevice.h b/panda/src/device/clientDialDevice.h index 75bbcd9669..0da5604583 100644 --- a/panda/src/device/clientDialDevice.h +++ b/panda/src/device/clientDialDevice.h @@ -1,16 +1,15 @@ -// Filename: clientDialDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientDialDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef CLIENTDIALDEVICE_H #define CLIENTDIALDEVICE_H @@ -19,19 +18,15 @@ #include "clientDevice.h" -//////////////////////////////////////////////////////////////////// -// Class : ClientDialDevice -// Description : A device, attached to the ClientBase by a -// DialNode, that records the data from a single -// named dial device. The named device can contain -// any number of dials, numbered in sequence beginning -// at zero. -// -// A dial is a rotating device that does not have -// stops--it can keep rotating any number of times. -// Therefore it does not have a specific position at any -// given time, unlike an AnalogDevice. -//////////////////////////////////////////////////////////////////// +/** + * A device, attached to the ClientBase by a DialNode, that records the data + * from a single named dial device. The named device can contain any number + * of dials, numbered in sequence beginning at zero. + * + * A dial is a rotating device that does not have stops--it can keep rotating + * any number of times. Therefore it does not have a specific position at any + * given time, unlike an AnalogDevice. + */ class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice { protected: INLINE ClientDialDevice(ClientBase *client, const string &device_name); diff --git a/panda/src/device/clientTrackerDevice.I b/panda/src/device/clientTrackerDevice.I index 938ac26922..030c4eea47 100644 --- a/panda/src/device/clientTrackerDevice.I +++ b/panda/src/device/clientTrackerDevice.I @@ -1,37 +1,29 @@ -// Filename: clientTrackerDevice.I -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientTrackerDevice.I + * @author drose + * @date 2001-01-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ClientTrackerDevice::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClientTrackerDevice:: ClientTrackerDevice(ClientBase *client, const string &device_name): ClientDevice(client, get_class_type(), device_name) { } -//////////////////////////////////////////////////////////////////// -// Function: ClientTrackerDevice::get_data -// Access: Public -// Description: Returns the TrackerData that this device is -// reporting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TrackerData that this device is reporting. + */ INLINE const TrackerData &ClientTrackerDevice:: get_data() const { return _data; } - diff --git a/panda/src/device/clientTrackerDevice.cxx b/panda/src/device/clientTrackerDevice.cxx index 65c5cb575b..65e3204e2e 100644 --- a/panda/src/device/clientTrackerDevice.cxx +++ b/panda/src/device/clientTrackerDevice.cxx @@ -1,17 +1,15 @@ -// Filename: clientTrackerDevice.cxx -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientTrackerDevice.cxx + * @author drose + * @date 2001-01-25 + */ #include "clientTrackerDevice.h" diff --git a/panda/src/device/clientTrackerDevice.h b/panda/src/device/clientTrackerDevice.h index 8fbfd00c55..468ed342f5 100644 --- a/panda/src/device/clientTrackerDevice.h +++ b/panda/src/device/clientTrackerDevice.h @@ -1,16 +1,15 @@ -// Filename: clientTrackerDevice.h -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clientTrackerDevice.h + * @author drose + * @date 2001-01-25 + */ #ifndef CLIENTTRACKERDEVICE_H #define CLIENTTRACKERDEVICE_H @@ -20,12 +19,10 @@ #include "clientDevice.h" #include "trackerData.h" -//////////////////////////////////////////////////////////////////// -// Class : ClientTrackerDevice -// Description : A device, attached to the ClientBase by a -// TrackerNode, that records the data from a single -// tracker device. -//////////////////////////////////////////////////////////////////// +/** + * A device, attached to the ClientBase by a TrackerNode, that records the + * data from a single tracker device. + */ class EXPCL_PANDA_DEVICE ClientTrackerDevice : public ClientDevice { protected: INLINE ClientTrackerDevice(ClientBase *client, const string &device_name); diff --git a/panda/src/device/config_device.cxx b/panda/src/device/config_device.cxx index a86986ed05..51f1159f33 100644 --- a/panda/src/device/config_device.cxx +++ b/panda/src/device/config_device.cxx @@ -1,17 +1,15 @@ -// Filename: config_device.cxx -// Created by: drose (04May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_device.cxx + * @author drose + * @date 2000-05-04 + */ #include "config_device.h" #include "analogNode.h" @@ -39,14 +37,12 @@ ConfigureFn(config_device) { init_libdevice(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libdevice -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdevice() { static bool initialized = false; diff --git a/panda/src/device/config_device.h b/panda/src/device/config_device.h index ea0ef35f40..8a7b6542a7 100644 --- a/panda/src/device/config_device.h +++ b/panda/src/device/config_device.h @@ -1,16 +1,15 @@ -// Filename: config_device.h -// Created by: drose (04May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_device.h + * @author drose + * @date 2000-05-04 + */ #ifndef CONFIG_DEVICE_H #define CONFIG_DEVICE_H diff --git a/panda/src/device/dialNode.I b/panda/src/device/dialNode.I index bd04635e46..c342eba997 100644 --- a/panda/src/device/dialNode.I +++ b/panda/src/device/dialNode.I @@ -1,36 +1,29 @@ -// Filename: dialNode.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dialNode.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DialNode::is_valid -// Access: Public -// Description: Returns true if the DialNode is valid and -// connected to a server, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the DialNode is valid and connected to a server, false + * otherwise. + */ INLINE bool DialNode:: is_valid() const { return (_dial != (ClientDialDevice *)NULL) && _dial->is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: DialNode::get_num_dials -// Access: Public -// Description: Returns the number of dial dials known to the -// DialNode. This number may change as more dials -// are discovered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of dial dials known to the DialNode. This number may + * change as more dials are discovered. + */ INLINE int DialNode:: get_num_dials() const { _dial->acquire(); @@ -39,14 +32,11 @@ get_num_dials() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DialNode::read_dial -// Access: Public -// Description: Returns the number of complete revolutions of the -// dial since the last time read_dial() was called. -// This is a destructive operation; it is not possible -// to read the dial without resetting the counter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of complete revolutions of the dial since the last time + * read_dial() was called. This is a destructive operation; it is not + * possible to read the dial without resetting the counter. + */ INLINE double DialNode:: read_dial(int index) { _dial->acquire(); @@ -55,13 +45,10 @@ read_dial(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DialNode::is_dial_known -// Access: Public -// Description: Returns true if the state of the indicated dial -// dial is known, or false if we have never heard -// anything about this particular dial. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state of the indicated dial dial is known, or false if + * we have never heard anything about this particular dial. + */ INLINE bool DialNode:: is_dial_known(int index) const { _dial->acquire(); diff --git a/panda/src/device/dialNode.cxx b/panda/src/device/dialNode.cxx index c4ca14b5de..b86305ac00 100644 --- a/panda/src/device/dialNode.cxx +++ b/panda/src/device/dialNode.cxx @@ -1,16 +1,15 @@ -// Filename: dialNode.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dialNode.cxx + * @author drose + * @date 2002-03-12 + */ #include "dialNode.h" #include "config_device.h" @@ -19,11 +18,9 @@ TypeHandle DialNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DialNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DialNode:: DialNode(ClientBase *client, const string &device_name) : DataNode(device_name) @@ -48,31 +45,24 @@ DialNode(ClientBase *client, const string &device_name) : _dial = DCAST(ClientDialDevice, device); } -//////////////////////////////////////////////////////////////////// -// Function: DialNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DialNode:: ~DialNode() { - // When the _dial pointer destructs, the ClientDialDevice - // disconnects itself from the ClientBase, and everything that needs - // to get turned off does. Magic. + // When the _dial pointer destructs, the ClientDialDevice disconnects itself + // from the ClientBase, and everything that needs to get turned off does. + // Magic. } -//////////////////////////////////////////////////////////////////// -// Function: DialNode::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void DialNode:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { diff --git a/panda/src/device/dialNode.h b/panda/src/device/dialNode.h index 006c919bab..04c65b1050 100644 --- a/panda/src/device/dialNode.h +++ b/panda/src/device/dialNode.h @@ -1,16 +1,15 @@ -// Filename: dialNode.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dialNode.h + * @author drose + * @date 2002-03-12 + */ #ifndef DIALNODE_H #define DIALNODE_H @@ -22,20 +21,16 @@ #include "dataNode.h" -//////////////////////////////////////////////////////////////////// -// Class : DialNode -// Description : This is the primary interface to infinite dial type -// devices associated with a ClientBase. This creates a -// node that connects to the named dial device, if it -// exists, and provides hooks to the user to read the -// state of any of the sequentially numbered dial -// controls associated with that device. -// -// A dial is a rotating device that does not have -// stops--it can keep rotating any number of times. -// Therefore it does not have a specific position at any -// given time, unlike an AnalogDevice. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary interface to infinite dial type devices associated with + * a ClientBase. This creates a node that connects to the named dial device, + * if it exists, and provides hooks to the user to read the state of any of + * the sequentially numbered dial controls associated with that device. + * + * A dial is a rotating device that does not have stops--it can keep rotating + * any number of times. Therefore it does not have a specific position at any + * given time, unlike an AnalogDevice. + */ class EXPCL_PANDA_DEVICE DialNode : public DataNode { PUBLISHED: DialNode(ClientBase *client, const string &device_name); diff --git a/panda/src/device/mouseAndKeyboard.cxx b/panda/src/device/mouseAndKeyboard.cxx index e8c102746e..4a431c5e5e 100644 --- a/panda/src/device/mouseAndKeyboard.cxx +++ b/panda/src/device/mouseAndKeyboard.cxx @@ -1,16 +1,15 @@ -// Filename: mouseAndKeyboard.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseAndKeyboard.cxx + * @author drose + * @date 2002-03-12 + */ #include "mouseAndKeyboard.h" #include "mouseData.h" @@ -21,11 +20,9 @@ TypeHandle MouseAndKeyboard::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseAndKeyboard::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseAndKeyboard:: MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : DataNode(name), @@ -44,52 +41,40 @@ MouseAndKeyboard(GraphicsWindow *window, int device, const string &name) : _button_events = new ButtonEventList; } -//////////////////////////////////////////////////////////////////// -// Function: MouseAndKeyboard::set_source -// Access: Published -// Description: Redirects the class to get the data from the mouse -// and keyboard associated with a different window -// and/or device number. -//////////////////////////////////////////////////////////////////// +/** + * Redirects the class to get the data from the mouse and keyboard associated + * with a different window and/or device number. + */ void MouseAndKeyboard:: set_source(GraphicsWindow *window, int device) { _window = window; _device = device; } -//////////////////////////////////////////////////////////////////// -// Function: MouseAndKeyboard::get_source_window -// Access: Published -// Description: Returns the associated source window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the associated source window. + */ PT(GraphicsWindow) MouseAndKeyboard:: get_source_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: MouseAndKeyboard::get_source_device -// Access: Published -// Description: Returns the associated source device. -//////////////////////////////////////////////////////////////////// +/** + * Returns the associated source device. + */ int MouseAndKeyboard:: get_source_device() const { return _device; } -//////////////////////////////////////////////////////////////////// -// Function: MouseAndKeyboard::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void MouseAndKeyboard:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { @@ -106,7 +91,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, PT(PointerEventList) pel = _window->get_pointer_events(_device); output.set_data(_pointer_events_output, EventParameter(pel)); } - + // Get the window size. WindowProperties properties = _window->get_properties(); if (properties.has_size()) { @@ -123,11 +108,11 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, // Get mouse motion in pixels. _pixel_xy->set_value(LPoint2(mdata._xpos, mdata._ypos)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); - + // Normalize pixel motion to range [-1,1]. PN_stdfloat xf = (PN_stdfloat)(2 * mdata._xpos) / (PN_stdfloat)w - 1.0f; PN_stdfloat yf = 1.0f - (PN_stdfloat)(2 * mdata._ypos) / (PN_stdfloat)h; - + _xy->set_value(LPoint2(xf, yf)); output.set_data(_xy_output, EventParameter(_xy)); } diff --git a/panda/src/device/mouseAndKeyboard.h b/panda/src/device/mouseAndKeyboard.h index 939a04aa8a..673e999da2 100644 --- a/panda/src/device/mouseAndKeyboard.h +++ b/panda/src/device/mouseAndKeyboard.h @@ -1,16 +1,15 @@ -// Filename: mouseAndKeyboard.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseAndKeyboard.h + * @author drose + * @date 2002-03-12 + */ #ifndef MOUSEANDKEYBOARD_H #define MOUSEANDKEYBOARD_H @@ -24,26 +23,21 @@ #include "pointerTo.h" #include "graphicsWindow.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseAndKeyboard -// Description : Reads the mouse and/or keyboard data sent from a -// GraphicsWindow, and transmits it down the data graph. -// -// The mouse and keyboard devices are bundled together -// into one device here, because they interrelate so -// much. A mouse might be constrained by the holding -// down of the shift key, for instance, or the clicking -// of the mouse button might be handled in much the same -// way as a keyboard key. -// -// Mouse data is sent down the data graph as an x,y -// position as well as the set of buttons currently -// being held down; keyboard data is sent down as a set -// of keypress events in an EventDataTransition. To -// throw these events to the system, you must attach an -// EventThrower to the MouseAndKeyboard object; -// otherwise, the events will be discarded. -//////////////////////////////////////////////////////////////////// +/** + * Reads the mouse and/or keyboard data sent from a GraphicsWindow, and + * transmits it down the data graph. + * + * The mouse and keyboard devices are bundled together into one device here, + * because they interrelate so much. A mouse might be constrained by the + * holding down of the shift key, for instance, or the clicking of the mouse + * button might be handled in much the same way as a keyboard key. + * + * Mouse data is sent down the data graph as an x,y position as well as the + * set of buttons currently being held down; keyboard data is sent down as a + * set of keypress events in an EventDataTransition. To throw these events to + * the system, you must attach an EventThrower to the MouseAndKeyboard object; + * otherwise, the events will be discarded. + */ class EXPCL_PANDA_DEVICE MouseAndKeyboard : public DataNode { PUBLISHED: MouseAndKeyboard(GraphicsWindow *window, int device, const string &name); @@ -51,7 +45,7 @@ PUBLISHED: PT(GraphicsWindow) get_source_window() const; int get_source_device() const; - + protected: // Inherited from DataNode virtual void do_transmit_data(DataGraphTraverser *trav, diff --git a/panda/src/device/trackerData.I b/panda/src/device/trackerData.I index f190e41778..580425fc6d 100644 --- a/panda/src/device/trackerData.I +++ b/panda/src/device/trackerData.I @@ -1,119 +1,96 @@ -// Filename: trackerData.I -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerData.I + * @author jason + * @date 2000-08-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TrackerData:: TrackerData() : _flags(0) { } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TrackerData:: TrackerData(const TrackerData ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::clear -// Access: Public -// Description: Removes all data from the structure. -//////////////////////////////////////////////////////////////////// +/** + * Removes all data from the structure. + */ INLINE void TrackerData:: clear() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::set_time -// Access: Public -// Description: Indicates the time at which the position information -// (pos and orient) are effective. This is a time -// elapsed in seconds since some undefined epoch; it may -// or may not correspond to the clock time indicated in -// the global ClockObject. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the time at which the position information (pos and orient) are + * effective. This is a time elapsed in seconds since some undefined epoch; + * it may or may not correspond to the clock time indicated in the global + * ClockObject. + */ INLINE void TrackerData:: set_time(double time) { _time = time; _flags |= F_has_time; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::has_time -// Access: Public -// Description: Returns true if the position information time is -// available. See set_time(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the position information time is available. See + * set_time(). + */ INLINE bool TrackerData:: has_time() const { return (_flags & F_has_time) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::get_time -// Access: Public -// Description: Returns the time at which the position information -// (pos and orient) are effective. It is an error to -// call this if has_time() does not return true. See -// set_time(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the time at which the position information (pos and orient) are + * effective. It is an error to call this if has_time() does not return true. + * See set_time(). + */ INLINE double TrackerData:: get_time() const { nassertr(has_time(), 0.0); return _time; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::set_pos -// Access: Public -// Description: Indicates the current position of the tracker sensor -// in space. The coordinate system of this position is -// defined by the tracker. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the current position of the tracker sensor in space. The + * coordinate system of this position is defined by the tracker. + */ INLINE void TrackerData:: set_pos(const LPoint3 &pos) { _pos = pos; _flags |= F_has_pos; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::has_pos -// Access: Public -// Description: Returns true if the current position is available. -// See set_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current position is available. See set_pos(). + */ INLINE bool TrackerData:: has_pos() const { return (_flags & F_has_pos) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::get_pos -// Access: Public -// Description: Returns the current position of the tracker. It is -// legal to call this if has_pos() returns false; in -// this case, the position will always be (0, 0, 0). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of the tracker. It is legal to call this if + * has_pos() returns false; in this case, the position will always be (0, 0, + * 0). + */ INLINE const LPoint3 &TrackerData:: get_pos() const { if (has_pos()) { @@ -124,40 +101,30 @@ get_pos() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::set_orient -// Access: Public -// Description: Indicates the current orientation of the tracker -// sensor in space. The coordinate system of this -// orientation is defined by the tracker, but should be -// the same coordinate system as that reflected by -// set_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Indicates the current orientation of the tracker sensor in space. The + * coordinate system of this orientation is defined by the tracker, but should + * be the same coordinate system as that reflected by set_pos(). + */ INLINE void TrackerData:: set_orient(const LOrientation &orient) { _orient = orient; _flags |= F_has_orient; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::has_orient -// Access: Public -// Description: Returns true if the current orientation is available. -// See set_orient(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current orientation is available. See set_orient(). + */ INLINE bool TrackerData:: has_orient() const { return (_flags & F_has_orient) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::get_orient -// Access: Public -// Description: Returns the current orientation of the tracker. It -// is legal to call this if has_orient() returns false; -// in this case, the result is always the identity -// orientation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current orientation of the tracker. It is legal to call this + * if has_orient() returns false; in this case, the result is always the + * identity orientation. + */ INLINE const LOrientation &TrackerData:: get_orient() const { if (has_orient()) { @@ -168,40 +135,31 @@ get_orient() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::set_dt -// Access: Public -// Description: Indicates the amount of elapsed time over which which -// the information (pos and orient) were computed. This -// only makes sense if the information represents -// velocity or acceleration, rather than position. This -// is an elapsed time in seconds. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the amount of elapsed time over which which the information (pos + * and orient) were computed. This only makes sense if the information + * represents velocity or acceleration, rather than position. This is an + * elapsed time in seconds. + */ INLINE void TrackerData:: set_dt(double dt) { _dt = dt; _flags |= F_has_dt; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::has_dt -// Access: Public -// Description: Returns true if the computed elapsed time is -// available. See set_dt(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the computed elapsed time is available. See set_dt(). + */ INLINE bool TrackerData:: has_dt() const { return (_flags & F_has_dt) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::get_dt -// Access: Public -// Description: Returns the amount of elapsed time over which the -// information (pos and orient) were computed. It -// is an error to call this if has_dt() does not return -// true. See set_dt(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of elapsed time over which the information (pos and + * orient) were computed. It is an error to call this if has_dt() does not + * return true. See set_dt(). + */ INLINE double TrackerData:: get_dt() const { nassertr(has_dt(), 0.0); diff --git a/panda/src/device/trackerData.cxx b/panda/src/device/trackerData.cxx index 3269f5a59a..56ae3d25a0 100644 --- a/panda/src/device/trackerData.cxx +++ b/panda/src/device/trackerData.cxx @@ -1,24 +1,21 @@ -// Filename: trackerData.cxx -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerData.cxx + * @author jason + * @date 2000-08-04 + */ #include "trackerData.h" -//////////////////////////////////////////////////////////////////// -// Function: TrackerData::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TrackerData:: operator = (const TrackerData ©) { _flags = copy._flags; diff --git a/panda/src/device/trackerData.h b/panda/src/device/trackerData.h index d0ce12100a..7fdd756bb6 100644 --- a/panda/src/device/trackerData.h +++ b/panda/src/device/trackerData.h @@ -1,16 +1,15 @@ -// Filename: trackerData.h -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerData.h + * @author jason + * @date 2000-08-04 + */ #ifndef TRACKERDATA_H #define TRACKERDATA_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : TrackerData -// Description : Stores the kinds of data that a tracker might output. -//////////////////////////////////////////////////////////////////// +/** + * Stores the kinds of data that a tracker might output. + */ class EXPCL_PANDA_DEVICE TrackerData { public: INLINE TrackerData(); diff --git a/panda/src/device/trackerNode.I b/panda/src/device/trackerNode.I index 5f872c7ea3..75d91d1d82 100644 --- a/panda/src/device/trackerNode.I +++ b/panda/src/device/trackerNode.I @@ -1,92 +1,74 @@ -// Filename: trackerNode.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerNode.I + * @author drose + * @date 2002-03-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::is_valid -// Access: Public -// Description: Returns true if the TrackerNode is valid and -// connected to a server, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TrackerNode is valid and connected to a server, false + * otherwise. + */ INLINE bool TrackerNode:: is_valid() const { return (_tracker != (ClientTrackerDevice *)NULL) && _tracker->is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_pos -// Access: Public -// Description: Returns the current position of the tracker, if it is -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of the tracker, if it is available. + */ INLINE const LPoint3 &TrackerNode:: get_pos() const { return _data.get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_orient -// Access: Public -// Description: Returns the current orientation of the tracker, if it -// is available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current orientation of the tracker, if it is available. + */ INLINE const LOrientation &TrackerNode:: get_orient() const { return _data.get_orient(); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_time -// Access: Public -// Description: Returns the time of the tracker's last update. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time of the tracker's last update. + */ INLINE double TrackerNode:: get_time() const { return _data.get_time(); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::has_time -// Access: Public -// Description: True if this data comes with timestamps. -//////////////////////////////////////////////////////////////////// +/** + * True if this data comes with timestamps. + */ INLINE bool TrackerNode:: has_time() const { return _data.has_time(); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_transform -// Access: Public -// Description: Returns the current position and orientation of the -// tracker, as a combined matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position and orientation of the tracker, as a combined + * matrix. + */ INLINE const LMatrix4 &TrackerNode:: get_transform() const { return _mat; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::set_tracker_coordinate_system -// Access: Published -// Description: Specifies the coordinate system that the tracker -// associated with this node will operate in. Normally, -// this is set from the ClientBase that's used to create -// the TrackerNode, so it should not need to be set on -// an individual tracker basis. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the coordinate system that the tracker associated with this node + * will operate in. Normally, this is set from the ClientBase that's used to + * create the TrackerNode, so it should not need to be set on an individual + * tracker basis. + */ INLINE void TrackerNode:: set_tracker_coordinate_system(CoordinateSystem cs) { _tracker_cs = cs; @@ -95,24 +77,20 @@ set_tracker_coordinate_system(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_tracker_coordinate_system -// Access: Published -// Description: Returns the coordinate system that the tracker -// associated with this node will operate in. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system that the tracker associated with this node + * will operate in. + */ INLINE CoordinateSystem TrackerNode:: get_tracker_coordinate_system() const { return _tracker_cs; } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::set_graph_coordinate_system -// Access: Published -// Description: Specifies the coordinate system that the TrackerNode -// will convert its transform into for passing down the -// data graph. Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the coordinate system that the TrackerNode will convert its + * transform into for passing down the data graph. Normally, this is + * CS_default. + */ INLINE void TrackerNode:: set_graph_coordinate_system(CoordinateSystem cs) { _graph_cs = cs; @@ -121,13 +99,11 @@ set_graph_coordinate_system(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::get_graph_coordinate_system -// Access: Published -// Description: Returns the coordinate system that the TrackerNode -// will convert its transform into for passing down the -// data graph. Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system that the TrackerNode will convert its + * transform into for passing down the data graph. Normally, this is + * CS_default. + */ INLINE CoordinateSystem TrackerNode:: get_graph_coordinate_system() const { return _graph_cs; diff --git a/panda/src/device/trackerNode.cxx b/panda/src/device/trackerNode.cxx index edc20ca07d..e4c9356b13 100644 --- a/panda/src/device/trackerNode.cxx +++ b/panda/src/device/trackerNode.cxx @@ -1,16 +1,15 @@ -// Filename: trackerNode.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerNode.cxx + * @author drose + * @date 2002-03-12 + */ #include "trackerNode.h" #include "config_device.h" @@ -18,11 +17,9 @@ TypeHandle TrackerNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TrackerNode:: TrackerNode(ClientBase *client, const string &device_name) : DataNode(device_name) @@ -54,11 +51,9 @@ TrackerNode(ClientBase *client, const string &device_name) : _tracker = DCAST(ClientTrackerDevice, device); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TrackerNode:: TrackerNode(ClientTrackerDevice *device) : DataNode(device->get_device_name()), @@ -75,31 +70,24 @@ TrackerNode(ClientTrackerDevice *device) : set_graph_coordinate_system(CS_default); } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TrackerNode:: ~TrackerNode() { - // When the _tracker pointer destructs, the ClientTrackerDevice - // disconnects itself from the ClientBase, and everything that needs - // to get turned off does. Magic. + // When the _tracker pointer destructs, the ClientTrackerDevice disconnects + // itself from the ClientBase, and everything that needs to get turned off + // does. Magic. } -//////////////////////////////////////////////////////////////////// -// Function: TrackerNode::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void TrackerNode:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { @@ -116,8 +104,8 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, } _mat.set_row(3, _data.get_pos()); - // Now send our matrix down the pipe. TODO: store this - // componentwise instead of just as a matrix-based transform. + // Now send our matrix down the pipe. TODO: store this componentwise + // instead of just as a matrix-based transform. _transform = TransformState::make_mat(_mat); output.set_data(_transform_output, EventParameter(_transform)); } diff --git a/panda/src/device/trackerNode.h b/panda/src/device/trackerNode.h index 8010c9da7b..3c18f65294 100644 --- a/panda/src/device/trackerNode.h +++ b/panda/src/device/trackerNode.h @@ -1,16 +1,15 @@ -// Filename: trackerNode.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackerNode.h + * @author drose + * @date 2002-03-12 + */ #ifndef TRACKERNODE_H #define TRACKERNODE_H @@ -25,14 +24,11 @@ #include "linmath_events.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : TrackerNode -// Description : This is the primary interface to a Tracker object -// associated with a ClientBase. It reads the position -// and orientation information from the tracker and -// makes it available as a transformation on the data -// graph. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary interface to a Tracker object associated with a + * ClientBase. It reads the position and orientation information from the + * tracker and makes it available as a transformation on the data graph. + */ class EXPCL_PANDA_DEVICE TrackerNode : public DataNode { PUBLISHED: TrackerNode(ClientBase *client, const string &device_name); diff --git a/panda/src/device/virtualMouse.cxx b/panda/src/device/virtualMouse.cxx index 8eec32b47c..fc0782828b 100644 --- a/panda/src/device/virtualMouse.cxx +++ b/panda/src/device/virtualMouse.cxx @@ -1,27 +1,24 @@ -// Filename: virtualMouse.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualMouse.cxx + * @author drose + * @date 2002-03-12 + */ #include "virtualMouse.h" #include "dataNodeTransmit.h" TypeHandle VirtualMouse::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualMouse:: VirtualMouse(const string &name) : DataNode(name) @@ -44,82 +41,63 @@ VirtualMouse(const string &name) : _mouse_on = false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::set_mouse_pos -// Access: Published -// Description: Sets the current mouse pixel location, where (0,0) is -// the upper left, and (width-1, height-1) is the lower -// right pixel of the virtual window. -//////////////////////////////////////////////////////////////////// +/** + * Sets the current mouse pixel location, where (0,0) is the upper left, and + * (width-1, height-1) is the lower right pixel of the virtual window. + */ void VirtualMouse:: set_mouse_pos(int x, int y) { _mouse_x = x; _mouse_y = y; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::set_window_size -// Access: Published -// Description: Sets the size of the "window" in which the mouse -// rolls. This changes the meaning of the values passed -// to set_mouse_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the "window" in which the mouse rolls. This changes the + * meaning of the values passed to set_mouse_pos(). + */ void VirtualMouse:: set_window_size(int width, int height) { _win_width = width; _win_height = height; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::set_mouse_on -// Access: Published -// Description: Sets whether the mouse should appear to be within the -// window or not. If this is true, the mouse is within -// the window; if false, the mouse is not within the -// window (and set_mouse_pos() means nothing). -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the mouse should appear to be within the window or not. If + * this is true, the mouse is within the window; if false, the mouse is not + * within the window (and set_mouse_pos() means nothing). + */ void VirtualMouse:: set_mouse_on(bool flag) { _mouse_on = flag; } - -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::press_button -// Access: Published -// Description: Simulates a mouse or keyboard button being depressed. -// This should be followed up by a call to -// release_button() sometime later (possibly -// immediately). -//////////////////////////////////////////////////////////////////// + +/** + * Simulates a mouse or keyboard button being depressed. This should be + * followed up by a call to release_button() sometime later (possibly + * immediately). + */ void VirtualMouse:: press_button(ButtonHandle button) { _next_button_events->add_event(ButtonEvent(button, ButtonEvent::T_down)); } - -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::release_button -// Access: Published -// Description: Simulates the button being released. This should -// follow a previous call to press_button(). -//////////////////////////////////////////////////////////////////// + +/** + * Simulates the button being released. This should follow a previous call to + * press_button(). + */ void VirtualMouse:: release_button(ButtonHandle button) { _next_button_events->add_event(ButtonEvent(button, ButtonEvent::T_up)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualMouse::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void VirtualMouse:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &output) { diff --git a/panda/src/device/virtualMouse.h b/panda/src/device/virtualMouse.h index 2a398f6ca9..885d3a883c 100644 --- a/panda/src/device/virtualMouse.h +++ b/panda/src/device/virtualMouse.h @@ -1,16 +1,15 @@ -// Filename: virtualMouse.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualMouse.h + * @author drose + * @date 2002-03-12 + */ #ifndef VIRTUALMOUSE_H #define VIRTUALMOUSE_H @@ -24,15 +23,12 @@ #include "linmath_events.h" #include "buttonEventList.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualMouse -// Description : Poses as a MouseAndKeyboard object in the datagraph, -// but accepts input from user calls, rather than -// reading the actual mouse and keyboard from an input -// device. The user can write high-level code to put -// the mouse wherever he/she wants, and to insert -// keypresses on demand. -//////////////////////////////////////////////////////////////////// +/** + * Poses as a MouseAndKeyboard object in the datagraph, but accepts input from + * user calls, rather than reading the actual mouse and keyboard from an input + * device. The user can write high-level code to put the mouse wherever + * he/she wants, and to insert keypresses on demand. + */ class EXPCL_PANDA_DEVICE VirtualMouse : public DataNode { PUBLISHED: VirtualMouse(const string &name); @@ -40,7 +36,7 @@ PUBLISHED: void set_mouse_pos(int x, int y); void set_window_size(int width, int height); void set_mouse_on(bool flag); - + void press_button(ButtonHandle button); void release_button(ButtonHandle button); @@ -87,4 +83,3 @@ private: }; #endif - diff --git a/panda/src/dgraph/config_dgraph.cxx b/panda/src/dgraph/config_dgraph.cxx index 0fe9ec61e4..fbaec8b78d 100644 --- a/panda/src/dgraph/config_dgraph.cxx +++ b/panda/src/dgraph/config_dgraph.cxx @@ -1,16 +1,15 @@ -// Filename: config_dgraph.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dgraph.cxx + * @author drose + * @date 2000-03-01 + */ #include "config_dgraph.h" #include "dataNode.h" diff --git a/panda/src/dgraph/config_dgraph.h b/panda/src/dgraph/config_dgraph.h index 70d8d7ffe4..52ea5fd983 100644 --- a/panda/src/dgraph/config_dgraph.h +++ b/panda/src/dgraph/config_dgraph.h @@ -1,16 +1,15 @@ -// Filename: config_dgraph.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dgraph.h + * @author drose + * @date 2000-03-01 + */ #ifndef CONFIG_DGRAPH_H #define CONFIG_DGRAPH_H diff --git a/panda/src/dgraph/dataGraphTraverser.I b/panda/src/dgraph/dataGraphTraverser.I index a0768860bf..a890d798d4 100644 --- a/panda/src/dgraph/dataGraphTraverser.I +++ b/panda/src/dgraph/dataGraphTraverser.I @@ -1,34 +1,28 @@ -// Filename: dataGraphTraverser.I -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataGraphTraverser.I + * @author drose + * @date 2002-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::get_current_thread -// Access: Public -// Description: Returns the currently-executing thread object, as -// passed to the DataGraphTraverser constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the currently-executing thread object, as passed to the + * DataGraphTraverser constructor. + */ INLINE Thread *DataGraphTraverser:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::CollectedData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DataGraphTraverser::CollectedData:: CollectedData() : _num_parents(0) diff --git a/panda/src/dgraph/dataGraphTraverser.cxx b/panda/src/dgraph/dataGraphTraverser.cxx index f8a5cba685..3b3900d8ea 100644 --- a/panda/src/dgraph/dataGraphTraverser.cxx +++ b/panda/src/dgraph/dataGraphTraverser.cxx @@ -1,16 +1,15 @@ -// Filename: dataGraphTraverser.cxx -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataGraphTraverser.cxx + * @author drose + * @date 2002-03-11 + */ #include "dataGraphTraverser.h" #include "dataNode.h" @@ -18,12 +17,10 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::CollectedData::set_data -// Access: Public -// Description: Sets the data associated with the indicated parent of -// this CollectedData object's node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the data associated with the indicated parent of this CollectedData + * object's node. + */ void DataGraphTraverser::CollectedData:: set_data(int parent_index, const DataNodeTransmit &data) { if ((int)_data.size() <= parent_index) { @@ -37,30 +34,23 @@ set_data(int parent_index, const DataNodeTransmit &data) { _data[parent_index] = data; } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DataGraphTraverser:: DataGraphTraverser(Thread *current_thread) : _current_thread(current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DataGraphTraverser:: ~DataGraphTraverser() { } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::traverse -// Access: Public -// Description: Starts the traversal of the data graph at the -// indicated root node. -//////////////////////////////////////////////////////////////////// +/** + * Starts the traversal of the data graph at the indicated root node. + */ void DataGraphTraverser:: traverse(PandaNode *node) { if (node->is_of_type(DataNode::get_class_type())) { @@ -77,13 +67,11 @@ traverse(PandaNode *node) { collect_leftovers(); } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::traverse_below -// Access: Public -// Description: Continues the traversal to all the children of the -// indicated node, passing in the given data, without -// actually calling transmit_data() on the given node. -//////////////////////////////////////////////////////////////////// +/** + * Continues the traversal to all the children of the indicated node, passing + * in the given data, without actually calling transmit_data() on the given + * node. + */ void DataGraphTraverser:: traverse_below(PandaNode *node, const DataNodeTransmit &output) { PandaNode::Children cr = node->get_children(_current_thread); @@ -93,19 +81,17 @@ traverse_below(PandaNode *node, const DataNodeTransmit &output) { PandaNode *child_node = cr.get_child(i); if (child_node->is_of_type(DataNode::get_class_type())) { DataNode *data_node = DCAST(DataNode, child_node); - // If it's a DataNode-type child, we need to pass it the data. - // Maybe it has only one parent, and can accept the data - // immediately. + // If it's a DataNode-type child, we need to pass it the data. Maybe it + // has only one parent, and can accept the data immediately. int num_parents = data_node->get_num_parents(_current_thread); if (num_parents == 1) { - // The easy, common case: only one parent. We make our output - // into a one-element array of inputs by turning it into a - // pointer. + // The easy, common case: only one parent. We make our output into a + // one-element array of inputs by turning it into a pointer. r_transmit(data_node, &output); } else { - // A more difficult case: multiple parents. We must collect - // instances together, meaning we must hold onto this node - // until we have reached it through all paths. + // A more difficult case: multiple parents. We must collect instances + // together, meaning we must hold onto this node until we have reached + // it through all paths. CollectedData &collected_data = _multipass_data[data_node]; int parent_index = data_node->find_parent(node, _current_thread); nassertv(parent_index != -1); @@ -121,24 +107,21 @@ traverse_below(PandaNode *node, const DataNodeTransmit &output) { } } else { // The child node is not a DataNode-type child. We continue the - // traversal, but data does not pass through this node, and - // instances are not collected together. (Although we appear to - // be passing the data through here, it doesn't do any good - // anyway, since the child nodes of this node will not know how - // to interpret the data from a non-DataNode parent.) + // traversal, but data does not pass through this node, and instances + // are not collected together. (Although we appear to be passing the + // data through here, it doesn't do any good anyway, since the child + // nodes of this node will not know how to interpret the data from a + // non-DataNode parent.) traverse_below(child_node, output); } } } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::collect_leftovers -// Access: Public -// Description: Pick up any nodes that didn't get completely -// traversed. These must be nodes that have multiple -// parents, with at least one parent completely outside -// of the data graph. -//////////////////////////////////////////////////////////////////// +/** + * Pick up any nodes that didn't get completely traversed. These must be + * nodes that have multiple parents, with at least one parent completely + * outside of the data graph. + */ void DataGraphTraverser:: collect_leftovers() { while (!_multipass_data.empty()) { @@ -151,17 +134,14 @@ collect_leftovers() { r_transmit(data_node, &collected_data._data[0]); _multipass_data.erase(mi); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: DataGraphTraverser::r_transmit -// Access: Private -// Description: Part of the recursive implementation of traverse(). -// This transmits the given data into the indicated -// DataNode, and then sends the output data to each of -// the node's children. -//////////////////////////////////////////////////////////////////// +/** + * Part of the recursive implementation of traverse(). This transmits the + * given data into the indicated DataNode, and then sends the output data to + * each of the node's children. + */ void DataGraphTraverser:: r_transmit(DataNode *data_node, const DataNodeTransmit inputs[]) { DataNodeTransmit output; diff --git a/panda/src/dgraph/dataGraphTraverser.h b/panda/src/dgraph/dataGraphTraverser.h index 12b92423d1..291958cbca 100644 --- a/panda/src/dgraph/dataGraphTraverser.h +++ b/panda/src/dgraph/dataGraphTraverser.h @@ -1,16 +1,15 @@ -// Filename: dataGraphTraverser.h -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataGraphTraverser.h + * @author drose + * @date 2002-03-11 + */ #ifndef DATAGRAPHTRAVERSER_H #define DATAGRAPHTRAVERSER_H @@ -24,14 +23,12 @@ class DataNode; class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : DataGraphTraverser -// Description : This object supervises the traversal of the data -// graph and the moving of data from one DataNode to its -// children. The data graph is used to manage data from -// input devices, etc. See the overview of the data -// graph in dataNode.h. -//////////////////////////////////////////////////////////////////// +/** + * This object supervises the traversal of the data graph and the moving of + * data from one DataNode to its children. The data graph is used to manage + * data from input devices, etc. See the overview of the data graph in + * dataNode.h. + */ class EXPCL_PANDA_DGRAPH DataGraphTraverser { PUBLISHED: DataGraphTraverser(Thread *current_thread = Thread::get_current_thread()); diff --git a/panda/src/dgraph/dataNode.I b/panda/src/dgraph/dataNode.I index 2d38743d1f..b9bcbb2fa1 100644 --- a/panda/src/dgraph/dataNode.I +++ b/panda/src/dgraph/dataNode.I @@ -1,34 +1,28 @@ -// Filename: dataNode.I -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNode.I + * @author drose + * @date 2002-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DataNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DataNode:: DataNode(const string &name) : PandaNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DataNode:: DataNode(const DataNode ©) : PandaNode(copy) @@ -36,27 +30,21 @@ DataNode(const DataNode ©) : // Copying a DataNode doesn't copy its inputs or outputs. } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::get_num_inputs -// Access: Public -// Description: Returns the number of different inputs that have been -// defined for this node using define_input(). This -// indicates the size of the DataNodeTransmit object -// that should be passed to do_transmit_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different inputs that have been defined for this node + * using define_input(). This indicates the size of the DataNodeTransmit + * object that should be passed to do_transmit_data(). + */ INLINE int DataNode:: get_num_inputs() const { return _input_wires.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::get_num_outputs -// Access: Public -// Description: Returns the number of different outputs that have been -// defined for this node using define_output(). This -// indicates the size of the DataNodeTransmit object -// that should be passed to do_transmit_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different outputs that have been defined for this + * node using define_output(). This indicates the size of the + * DataNodeTransmit object that should be passed to do_transmit_data(). + */ INLINE int DataNode:: get_num_outputs() const { return _output_wires.size(); diff --git a/panda/src/dgraph/dataNode.cxx b/panda/src/dgraph/dataNode.cxx index 829bb9e2cf..564a19f45d 100644 --- a/panda/src/dgraph/dataNode.cxx +++ b/panda/src/dgraph/dataNode.cxx @@ -1,16 +1,15 @@ -// Filename: dataNode.cxx -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNode.cxx + * @author drose + * @date 2002-03-11 + */ #include "dataNode.h" #include "dataNodeTransmit.h" @@ -19,27 +18,21 @@ TypeHandle DataNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DataNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *DataNode:: make_copy() const { return new DataNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::transmit_data -// Access: Public -// Description: Collects the data from all of the parent nodes and -// puts it into one DataNodeTransmit object, for -// processing; calls do_transmit_data() to read all the -// inputs and put the result into the indicated output. -//////////////////////////////////////////////////////////////////// +/** + * Collects the data from all of the parent nodes and puts it into one + * DataNodeTransmit object, for processing; calls do_transmit_data() to read + * all the inputs and put the result into the indicated output. + */ void DataNode:: transmit_data(DataGraphTraverser *trav, const DataNodeTransmit inputs[], @@ -50,7 +43,7 @@ transmit_data(DataGraphTraverser *trav, DataConnections::const_iterator ci; for (ci = _data_connections.begin(); ci != _data_connections.end(); ++ci) { const DataConnection &connect = (*ci); - const EventParameter &data = + const EventParameter &data = inputs[connect._parent_index].get_data(connect._output_index); if (!data.is_empty()) { new_input.set_data(connect._input_index, data); @@ -70,7 +63,7 @@ transmit_data(DataGraphTraverser *trav, << *this << " receives:\n"; any_data = true; } - dgraph_cat.spam(false) + dgraph_cat.spam(false) << " " << name << " = " << new_input.get_data(def._index) << "\n"; } @@ -93,7 +86,7 @@ transmit_data(DataGraphTraverser *trav, << *this << " transmits:\n"; any_data = true; } - dgraph_cat.spam(false) + dgraph_cat.spam(false) << " " << name << " = " << output.get_data(def._index) << "\n"; } @@ -102,12 +95,10 @@ transmit_data(DataGraphTraverser *trav, #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::write_inputs -// Access: Published -// Description: Writes to the indicated ostream a list of all the -// inputs this DataNode might expect to receive. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a list of all the inputs this DataNode + * might expect to receive. + */ void DataNode:: write_inputs(ostream &out) const { Wires::const_iterator wi; @@ -118,12 +109,10 @@ write_inputs(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::write_outputs -// Access: Published -// Description: Writes to the indicated ostream a list of all the -// outputs this DataNode might generate. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a list of all the outputs this DataNode + * might generate. + */ void DataNode:: write_outputs(ostream &out) const { Wires::const_iterator wi; @@ -134,13 +123,10 @@ write_outputs(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::write_connections -// Access: Published -// Description: Writes to the indicated ostream a list of all the -// connections currently showing between this DataNode -// and its parent(s). -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a list of all the connections currently + * showing between this DataNode and its parent(s). + */ void DataNode:: write_connections(ostream &out) const { DataConnections::const_iterator ci; @@ -148,15 +134,15 @@ write_connections(ostream &out) const { const DataConnection &connect = (*ci); nassertv(connect._parent_index >= 0 && connect._parent_index < get_num_parents()); - // Now we have to search exhaustively for the input with the - // matching index number. + // Now we have to search exhaustively for the input with the matching + // index number. Wires::const_iterator wi; bool found = false; for (wi = _input_wires.begin(); wi != _input_wires.end() && !found; ++wi) { const string &name = (*wi).first; const WireDef &def = (*wi).second; if (def._index == connect._input_index) { - out << name << " " << def._data_type << " from " + out << name << " " << def._data_type << " from " << *get_parent(connect._parent_index) << "\n"; found = true; } @@ -165,23 +151,18 @@ write_connections(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::define_input -// Access: Protected -// Description: Adds a new input wire with the given name and the -// indicated data type. The data type should be the -// TypeHandle for some type that derives from -// TypedReferenceCount, e.g. EventStoreInt, -// EventStoreDouble, or some fancier data type like -// Texture. -// -// If there is already an input wire defined with the -// indicated name, its type is changed. -// -// The return value is the index into the "input" -// parameter to do_transmit_data() that can be used to -// access the input data. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new input wire with the given name and the indicated data type. The + * data type should be the TypeHandle for some type that derives from + * TypedReferenceCount, e.g. EventStoreInt, EventStoreDouble, or some fancier + * data type like Texture. + * + * If there is already an input wire defined with the indicated name, its type + * is changed. + * + * The return value is the index into the "input" parameter to + * do_transmit_data() that can be used to access the input data. + */ int DataNode:: define_input(const string &name, TypeHandle data_type) { // We shouldn't already be connected. @@ -190,8 +171,7 @@ define_input(const string &name, TypeHandle data_type) { Wires::iterator wi; wi = _input_wires.find(name); if (wi != _input_wires.end()) { - // This wire already existed; modify it and return the original - // index. + // This wire already existed; modify it and return the original index. WireDef &def = (*wi).second; def._data_type = data_type; return def._index; @@ -204,23 +184,18 @@ define_input(const string &name, TypeHandle data_type) { return def._index; } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::define_output -// Access: Protected -// Description: Adds a new output wire with the given name and the -// indicated data type. The data type should be the -// TypeHandle for some type that derives from -// TypedReferenceCount, e.g. EventStoreInt, -// EventStoreDouble, or some fancier data type like -// Texture. -// -// If there is already an output wire defined with the -// indicated name, its type is changed. -// -// The return value is the index into the "output" -// parameter to do_transmit_data() where the output data -// should be stored. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new output wire with the given name and the indicated data type. + * The data type should be the TypeHandle for some type that derives from + * TypedReferenceCount, e.g. EventStoreInt, EventStoreDouble, or some fancier + * data type like Texture. + * + * If there is already an output wire defined with the indicated name, its + * type is changed. + * + * The return value is the index into the "output" parameter to + * do_transmit_data() where the output data should be stored. + */ int DataNode:: define_output(const string &name, TypeHandle data_type) { // We shouldn't already be connected. @@ -229,8 +204,7 @@ define_output(const string &name, TypeHandle data_type) { Wires::iterator wi; wi = _output_wires.find(name); if (wi != _output_wires.end()) { - // This wire already existed; modify it and return the original - // index. + // This wire already existed; modify it and return the original index. WireDef &def = (*wi).second; def._data_type = data_type; return def._index; @@ -243,46 +217,34 @@ define_output(const string &name, TypeHandle data_type) { return def._index; } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::parents_changed -// Access: Protected, Virtual -// Description: Called after a scene graph update that either adds or -// remove parents from this node, this just provides a -// hook for derived PandaNode objects that need to -// update themselves based on the set of parents the -// node has. -//////////////////////////////////////////////////////////////////// +/** + * Called after a scene graph update that either adds or remove parents from + * this node, this just provides a hook for derived PandaNode objects that + * need to update themselves based on the set of parents the node has. + */ void DataNode:: parents_changed() { PandaNode::parents_changed(); reconnect(); } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void DataNode:: -do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, +do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &, DataNodeTransmit &) { } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::reconnect -// Access: Private -// Description: Establishes the input(s) that this DataNode has in -// common with its parents' output(s). Builds up the -// _data_connections list correspondingly. -//////////////////////////////////////////////////////////////////// +/** + * Establishes the input(s) that this DataNode has in common with its parents' + * output(s). Builds up the _data_connections list correspondingly. + */ void DataNode:: reconnect() { int num_parents = get_num_parents(); @@ -308,7 +270,7 @@ reconnect() { num_found++; if (output_def._data_type != input_def._data_type) { dgraph_cat.warning() - << "Ignoring mismatched type for connection " << name + << "Ignoring mismatched type for connection " << name << " between " << *data_node << " and " << *this << "\n"; } else { DataConnection dc; @@ -329,32 +291,27 @@ reconnect() { } } } - - if (_data_connections.empty() && get_num_inputs() != 0 && + + if (_data_connections.empty() && get_num_inputs() != 0 && num_datanode_parents != 0) { dgraph_cat.warning() << "No data connected to " << *this << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DataNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: DataNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Lens. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Lens. + */ void DataNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/dgraph/dataNode.h b/panda/src/dgraph/dataNode.h index a5a3d11467..0519cc5fdd 100644 --- a/panda/src/dgraph/dataNode.h +++ b/panda/src/dgraph/dataNode.h @@ -1,45 +1,36 @@ -// Filename: dataNode.h -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNode.h + * @author drose + * @date 2002-03-11 + */ #ifndef DATANODE_H #define DATANODE_H -//////////////////////////////////////////////////////////////////// -// -// The Data Graph. -// -// The data graph is intended to hook up devices and their inputs -// and/or outputs in a clean interface. It uses the same graph -// relationship that is used to construct the scene graph, with the -// same sort of nodes and NodePaths. -// -// In a data graph, each node may potentially produce and/or consume -// data, and the arcs transmit data downward, from the root of the -// graph to its leaves. Thus, an input device such as a mouse might -// be added to the graph near the root, and a tformer-style object -// that interprets the mouse data as a trackball motion and outputs a -// matrix might be the immediate child of the mouse, followed by an -// object that accepts a matrix and sets it on some particular arc in -// the scene graph. -// -// Each different kind of DataNode defines its own set of input values -// and output values, identified by name. When a DataNode is attached -// to another DataNode, the inputs of the child are automatically -// connected up to the corresponding outputs of the parent, and an -// error message is issued if there are no matching connections. -// -//////////////////////////////////////////////////////////////////// +/* + * The Data Graph. The data graph is intended to hook up devices and their + * inputs andor outputs in a clean interface. It uses the same graph + * relationship that is used to construct the scene graph, with the same sort + * of nodes and NodePaths. In a data graph, each node may potentially produce + * andor consume data, and the arcs transmit data downward, from the root of + * the graph to its leaves. Thus, an input device such as a mouse might be + * added to the graph near the root, and a tformer-style object that + * interprets the mouse data as a trackball motion and outputs a matrix might + * be the immediate child of the mouse, followed by an object that accepts a + * matrix and sets it on some particular arc in the scene graph. Each + * different kind of DataNode defines its own set of input values and output + * values, identified by name. When a DataNode is attached to another + * DataNode, the inputs of the child are automatically connected up to the + * corresponding outputs of the parent, and an error message is issued if + * there are no matching connections. + */ #include "pandabase.h" @@ -49,18 +40,15 @@ class DataGraphTraverser; class DataNodeTransmit; -//////////////////////////////////////////////////////////////////// -// Class : DataNode -// Description : The fundamental type of node for the data graph. The -// DataNode class is itself primarily intended as an -// abstract class; it defines no inputs and no outputs. -// Most kinds of data nodes will derive from this to -// specify the inputs and outputs in the constructor. -// -// DataNode does not attempt to cycle its data with a -// PipelineCycler. The data graph is intended to be -// used only within a single thread. -//////////////////////////////////////////////////////////////////// +/** + * The fundamental type of node for the data graph. The DataNode class is + * itself primarily intended as an abstract class; it defines no inputs and no + * outputs. Most kinds of data nodes will derive from this to specify the + * inputs and outputs in the constructor. + * + * DataNode does not attempt to cycle its data with a PipelineCycler. The + * data graph is intended to be used only within a single thread. + */ class EXPCL_PANDA_DGRAPH DataNode : public PandaNode { PUBLISHED: INLINE DataNode(const string &name); diff --git a/panda/src/dgraph/dataNodeTransmit.I b/panda/src/dgraph/dataNodeTransmit.I index bd94ff5c83..4b911ea60d 100644 --- a/panda/src/dgraph/dataNodeTransmit.I +++ b/panda/src/dgraph/dataNodeTransmit.I @@ -1,65 +1,53 @@ -// Filename: dataNodeTransmit.I -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNodeTransmit.I + * @author drose + * @date 2002-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DataNodeTransmit:: DataNodeTransmit() { } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DataNodeTransmit:: DataNodeTransmit(const DataNodeTransmit ©) : _data(copy._data) { } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DataNodeTransmit:: operator = (const DataNodeTransmit ©) { _data = copy._data; } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::reserve -// Access: Public -// Description: Tells the DataNodeTransmit object how many wires it -// is expected to store data for. -//////////////////////////////////////////////////////////////////// +/** + * Tells the DataNodeTransmit object how many wires it is expected to store + * data for. + */ INLINE void DataNodeTransmit:: reserve(int num_wires) { _data.reserve(num_wires); } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::get_data -// Access: Public -// Description: Extracts the data for the indicated index, if it has -// been stored, or the empty parameter if it has not. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the data for the indicated index, if it has been stored, or the + * empty parameter if it has not. + */ INLINE const EventParameter &DataNodeTransmit:: get_data(int index) const { if (index >= 0 && index < (int)_data.size()) { @@ -69,12 +57,9 @@ get_data(int index) const { return empty_parameter; } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::has_data -// Access: Public -// Description: Returns true if the indicated parameter has been -// stored, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated parameter has been stored, false otherwise. + */ INLINE bool DataNodeTransmit:: has_data(int index) const { if (index >= 0 && index < (int)_data.size()) { @@ -83,11 +68,9 @@ has_data(int index) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::set_data -// Access: Public -// Description: Sets the data for the indicated parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets the data for the indicated parameter. + */ INLINE void DataNodeTransmit:: set_data(int index, const EventParameter &data) { if (index >= (int)_data.size()) { diff --git a/panda/src/dgraph/dataNodeTransmit.cxx b/panda/src/dgraph/dataNodeTransmit.cxx index ce754380e8..f376943566 100644 --- a/panda/src/dgraph/dataNodeTransmit.cxx +++ b/panda/src/dgraph/dataNodeTransmit.cxx @@ -1,16 +1,15 @@ -// Filename: dataNodeTransmit.cxx -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNodeTransmit.cxx + * @author drose + * @date 2002-03-11 + */ #include "dataNodeTransmit.h" #include "bamReader.h" @@ -18,21 +17,16 @@ TypeHandle DataNodeTransmit::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DataNodeTransmit:: ~DataNodeTransmit() { } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::slot_data -// Access: Private -// Description: Ensures that the given index number exists in the -// data array. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the given index number exists in the data array. + */ void DataNodeTransmit:: slot_data(int index) { nassertv(index < 1000); @@ -41,23 +35,18 @@ slot_data(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void DataNodeTransmit:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DataNodeTransmit:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -71,13 +60,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int DataNodeTransmit:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -90,14 +76,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *DataNodeTransmit:: make_from_bam(const FactoryParams ¶ms) { DataNodeTransmit *xmit = new DataNodeTransmit; @@ -110,13 +93,10 @@ make_from_bam(const FactoryParams ¶ms) { return xmit; } -//////////////////////////////////////////////////////////////////// -// Function: DataNodeTransmit::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Lens. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Lens. + */ void DataNodeTransmit:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/dgraph/dataNodeTransmit.h b/panda/src/dgraph/dataNodeTransmit.h index bff2d72634..3f1c0412ed 100644 --- a/panda/src/dgraph/dataNodeTransmit.h +++ b/panda/src/dgraph/dataNodeTransmit.h @@ -1,16 +1,15 @@ -// Filename: dataNodeTransmit.h -// Created by: drose (11Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dataNodeTransmit.h + * @author drose + * @date 2002-03-11 + */ #ifndef DATANODETRANSMIT_H #define DATANODETRANSMIT_H @@ -25,13 +24,11 @@ class DatagramIterator; class BamReader; class BamWriter; -//////////////////////////////////////////////////////////////////// -// Class : DataNodeTransmit -// Description : Encapsulates the data generated from (or sent into) -// any particular DataNode. This is basically just an -// array of EventParameters, one for each registered -// input or output wire. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data generated from (or sent into) any particular + * DataNode. This is basically just an array of EventParameters, one for each + * registered input or output wire. + */ class EXPCL_PANDA_DGRAPH DataNodeTransmit : public TypedWritable { public: INLINE DataNodeTransmit(); @@ -61,7 +58,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/display/callbackGraphicsWindow.I b/panda/src/display/callbackGraphicsWindow.I index 12592b5ebb..1a1f104a36 100644 --- a/panda/src/display/callbackGraphicsWindow.I +++ b/panda/src/display/callbackGraphicsWindow.I @@ -1,167 +1,130 @@ -// Filename: callbackGraphicsWindow.I -// Created by: drose (06Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackGraphicsWindow.I + * @author drose + * @date 2011-01-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::set_events_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// this window is polled for window events, including -// mouse and keyboard events, as well as window resize -// events and other system-generated events. -// -// This callback will receive a -// CallbackGraphicsWindow::EventsCallbackData. -// -// This callback should process any system-generated -// events, and call data->upcall() to process requested -// property change requests made via -// request_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when this window is polled + * for window events, including mouse and keyboard events, as well as window + * resize events and other system-generated events. + * + * This callback will receive a CallbackGraphicsWindow::EventsCallbackData. + * + * This callback should process any system-generated events, and call + * data->upcall() to process requested property change requests made via + * request_properties(). + */ INLINE void CallbackGraphicsWindow:: set_events_callback(CallbackObject *object) { _events_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::clear_events_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_events_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_events_callback(). + */ INLINE void CallbackGraphicsWindow:: clear_events_callback() { set_events_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::get_events_callback -// Access: Published -// Description: Returns the CallbackObject set by set_events_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_events_callback(). + */ INLINE CallbackObject *CallbackGraphicsWindow:: get_events_callback() const { return _events_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::set_properties_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// this window receives a property change request from -// user code (e.g. via request_properties). -// -// This callback will receive a -// CallbackGraphicsWindow::PropertiesCallbackData, which -// provides a get_properties() method that returns a -// modifiable reference to a WindowsProperties object. -// This object will contain only those properties -// requested by user code. The callback should handle -// any of the requests it finds, including and -// especially set_open(), and remove them from the -// object when it has handled them. Any unhandled -// properties should be left unchanged in the properties -// object. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when this window receives a + * property change request from user code (e.g. via request_properties). + * + * This callback will receive a + * CallbackGraphicsWindow::PropertiesCallbackData, which provides a + * get_properties() method that returns a modifiable reference to a + * WindowsProperties object. This object will contain only those properties + * requested by user code. The callback should handle any of the requests it + * finds, including and especially set_open(), and remove them from the object + * when it has handled them. Any unhandled properties should be left + * unchanged in the properties object. + */ INLINE void CallbackGraphicsWindow:: set_properties_callback(CallbackObject *object) { _properties_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::clear_properties_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_properties_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_properties_callback(). + */ INLINE void CallbackGraphicsWindow:: clear_properties_callback() { set_properties_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::get_properties_callback -// Access: Published -// Description: Returns the CallbackObject set by set_properties_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_properties_callback(). + */ INLINE CallbackObject *CallbackGraphicsWindow:: get_properties_callback() const { return _properties_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::set_render_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// this window is invoked (in the draw thread) to render -// its contents, and/or flip the graphics buffers. -// -// This callback will actually serve several different -// functions. It receivces a RenderCallbackData, and -// you can query data->get_callback_type() to return the -// actual function of each particular callback. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when this window is invoked + * (in the draw thread) to render its contents, and/or flip the graphics + * buffers. + * + * This callback will actually serve several different functions. It + * receivces a RenderCallbackData, and you can query data->get_callback_type() + * to return the actual function of each particular callback. + */ INLINE void CallbackGraphicsWindow:: set_render_callback(CallbackObject *object) { _render_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::clear_render_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_render_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_render_callback(). + */ INLINE void CallbackGraphicsWindow:: clear_render_callback() { set_render_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::get_render_callback -// Access: Published -// Description: Returns the CallbackObject set by set_render_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_render_callback(). + */ INLINE CallbackObject *CallbackGraphicsWindow:: get_render_callback() const { return _render_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::WindowCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackGraphicsWindow::WindowCallbackData:: WindowCallbackData(CallbackGraphicsWindow *window) : _window(window) { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::WindowCallbackData::get_window -// Access: Published -// Description: Returns the window this callback was triggered from. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window this callback was triggered from. + */ INLINE CallbackGraphicsWindow *CallbackGraphicsWindow::WindowCallbackData:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::EventsCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackGraphicsWindow::EventsCallbackData:: EventsCallbackData(CallbackGraphicsWindow *window) : WindowCallbackData(window) @@ -169,11 +132,9 @@ EventsCallbackData(CallbackGraphicsWindow *window) : } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::PropertiesCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackGraphicsWindow::PropertiesCallbackData:: PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &properties) : WindowCallbackData(window), @@ -181,79 +142,62 @@ PropertiesCallbackData(CallbackGraphicsWindow *window, WindowProperties &propert { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::PropertiesCallbackData::get_properties -// Access: Published -// Description: Returns the WindowProperties object that this -// callback should process. Any properties that are -// handled should be removed from this object; -// properties that are unhandled should be left alone. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WindowProperties object that this callback should process. Any + * properties that are handled should be removed from this object; properties + * that are unhandled should be left alone. + */ INLINE WindowProperties &CallbackGraphicsWindow::PropertiesCallbackData:: get_properties() const { return _properties; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackGraphicsWindow::RenderCallbackData:: -RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode) : +RenderCallbackData(CallbackGraphicsWindow *window, RenderCallbackType callback_type, FrameMode frame_mode) : WindowCallbackData(window), _callback_type(callback_type), _frame_mode(frame_mode), _render_flag(true) { } - -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::get_callback_type -// Access: Published -// Description: Since the render callback is shared for several -// functions, this method is needed to indicate which -// particular function is being invoked with this -// callback. -//////////////////////////////////////////////////////////////////// + +/** + * Since the render callback is shared for several functions, this method is + * needed to indicate which particular function is being invoked with this + * callback. + */ INLINE CallbackGraphicsWindow::RenderCallbackType CallbackGraphicsWindow::RenderCallbackData:: get_callback_type() const { return _callback_type; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::get_frame_mode -// Access: Published -// Description: If the callback type (returned by get_callback_type) -// is RCT_begin_frame or RCT_end_frame, then this method -// will return the particular frame mode indicating -// what, precisely, we want to do this frame. -//////////////////////////////////////////////////////////////////// +/** + * If the callback type (returned by get_callback_type) is RCT_begin_frame or + * RCT_end_frame, then this method will return the particular frame mode + * indicating what, precisely, we want to do this frame. + */ INLINE GraphicsOutput::FrameMode CallbackGraphicsWindow::RenderCallbackData:: get_frame_mode() const { return _frame_mode; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::set_render_flag -// Access: Published -// Description: If the callback type is RCT_begin_frame, this call is -// available to specify the return value from the -// begin_frame() call. If this is true (the default), -// the frame is rendered normally; if it is false, the -// frame is omitted. -//////////////////////////////////////////////////////////////////// +/** + * If the callback type is RCT_begin_frame, this call is available to specify + * the return value from the begin_frame() call. If this is true (the + * default), the frame is rendered normally; if it is false, the frame is + * omitted. + */ INLINE void CallbackGraphicsWindow::RenderCallbackData:: set_render_flag(bool render_flag) { _render_flag = render_flag; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::get_render_flag -// Access: Published -// Description: Returns the current setting of the render flag. See -// set_render_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the render flag. See set_render_flag(). + */ INLINE bool CallbackGraphicsWindow::RenderCallbackData:: get_render_flag() const { return _render_flag; diff --git a/panda/src/display/callbackGraphicsWindow.cxx b/panda/src/display/callbackGraphicsWindow.cxx index 6de33cc9d6..f9c2362ed7 100644 --- a/panda/src/display/callbackGraphicsWindow.cxx +++ b/panda/src/display/callbackGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: callbackGraphicsWindow.cxx -// Created by: drose (06Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackGraphicsWindow.cxx + * @author drose + * @date 2011-01-06 + */ #include "callbackGraphicsWindow.h" @@ -20,12 +19,9 @@ TypeHandle CallbackGraphicsWindow::EventsCallbackData::_type_handle; TypeHandle CallbackGraphicsWindow::PropertiesCallbackData::_type_handle; TypeHandle CallbackGraphicsWindow::RenderCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::Constructor -// Access: Protected -// Description: Use GraphicsEngine::make_output() to construct a -// CallbackGraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Use GraphicsEngine::make_output() to construct a CallbackGraphicsWindow. + */ CallbackGraphicsWindow:: CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -39,30 +35,24 @@ CallbackGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, MemoryUsage::update_type(this, this); #endif - // Let's ensure that these properties are set to *something* - // initially. + // Let's ensure that these properties are set to *something* initially. _properties.set_origin(0, 0); _properties.set_size(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CallbackGraphicsWindow:: ~CallbackGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::get_input_device -// Access: Published -// Description: Returns a writable reference to the nth input device -// (mouse). This is intended to be used for the window -// implementation to record mouse and keyboard input -// information for the Panda system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a writable reference to the nth input device (mouse). This is + * intended to be used for the window implementation to record mouse and + * keyboard input information for the Panda system. + */ GraphicsWindowInputDevice &CallbackGraphicsWindow:: get_input_device(int device) { LightMutexHolder holder(_input_lock); @@ -70,13 +60,10 @@ get_input_device(int device) { return _input_devices[device]; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::create_input_device -// Access: Published -// Description: Adds a new input device (mouse) to the window with -// the indicated name. Returns the index of the new -// device. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new input device (mouse) to the window with the indicated name. + * Returns the index of the new device. + */ int CallbackGraphicsWindow:: create_input_device(const string &name) { GraphicsWindowInputDevice device = @@ -84,15 +71,12 @@ create_input_device(const string &name) { return add_input_device(device); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool CallbackGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { bool result = false; @@ -110,22 +94,20 @@ begin_frame(FrameMode mode, Thread *current_thread) { _gsg->reset_if_new(); _gsg->set_current_properties(&get_fb_properties()); - + return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void CallbackGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { if (_render_callback != NULL) { - // In case the callback or the application hosting the OpenGL - // context wants to do more rendering, let's give it a blank slate. + // In case the callback or the application hosting the OpenGL context + // wants to do more rendering, let's give it a blank slate. _gsg->set_state_and_transform(RenderState::make_empty(), _gsg->get_internal_transform()); _gsg->clear_before_callback(); @@ -143,20 +125,17 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void CallbackGraphicsWindow:: begin_flip() { if (_render_callback != NULL) { @@ -167,16 +146,13 @@ begin_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void CallbackGraphicsWindow:: end_flip() { if (_render_callback != NULL) { @@ -187,16 +163,13 @@ end_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties(). -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties(). + * + * This function is called only within the window thread. + */ void CallbackGraphicsWindow:: process_events() { if (_events_callback != NULL) { @@ -207,13 +180,10 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + */ void CallbackGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (_properties_callback != NULL) { @@ -224,21 +194,17 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool CallbackGraphicsWindow:: open_window() { - // In this case, we assume the callback has handled the window - // opening. + // In this case, we assume the callback has handled the window opening. // We also assume the callback has given us an accurate - // FramebufferProperties, but we do go ahead and assume some certain - // minimum properties. + // FramebufferProperties, but we do go ahead and assume some certain minimum + // properties. _fb_properties.set_rgb_color(1); if (_fb_properties.get_color_bits() == 0) { @@ -247,20 +213,16 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::do_reshape_request -// Access: Protected, Virtual -// Description: Called from the window thread in response to a request -// from within the code (via request_properties()) to -// change the size and/or position of the window. -// Returns true if the window is successfully changed, -// or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Called from the window thread in response to a request from within the code + * (via request_properties()) to change the size and/or position of the + * window. Returns true if the window is successfully changed, or false if + * there was a problem. + */ bool CallbackGraphicsWindow:: do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size) { - // In this case, we assume the callback has handled the window - // resizing. + // In this case, we assume the callback has handled the window resizing. WindowProperties properties; if (has_origin) { properties.set_origin(x_origin, y_origin); @@ -271,31 +233,25 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::EventsCallbackData::upcall -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CallbackGraphicsWindow::EventsCallbackData:: upcall() { _window->GraphicsWindow::process_events(); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::PropertiesCallbackData::upcall -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CallbackGraphicsWindow::PropertiesCallbackData:: upcall() { _window->GraphicsWindow::set_properties_now(_properties); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackGraphicsWindow::RenderCallbackData::upcall -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CallbackGraphicsWindow::RenderCallbackData:: upcall() { switch (_callback_type) { diff --git a/panda/src/display/callbackGraphicsWindow.h b/panda/src/display/callbackGraphicsWindow.h index c34d324126..a676dff9f4 100644 --- a/panda/src/display/callbackGraphicsWindow.h +++ b/panda/src/display/callbackGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: callbackGraphicsWindow.h -// Created by: drose (06Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackGraphicsWindow.h + * @author drose + * @date 2011-01-06 + */ #ifndef CALLBACKGRAPHICSWINDOW_H #define CALLBACKGRAPHICSWINDOW_H @@ -18,19 +17,16 @@ #include "pandabase.h" #include "graphicsWindow.h" -//////////////////////////////////////////////////////////////////// -// Class : CallbackGraphicsWindow -// Description : This special window object doesn't represent a window -// in its own right, but instead hooks into some -// third-party API for creating and rendering to windows -// via callbacks. This can be used to allow Panda to -// render into an already-created OpenGL context, for -// instance. -//////////////////////////////////////////////////////////////////// +/** + * This special window object doesn't represent a window in its own right, but + * instead hooks into some third-party API for creating and rendering to + * windows via callbacks. This can be used to allow Panda to render into an + * already-created OpenGL context, for instance. + */ class EXPCL_PANDA_DISPLAY CallbackGraphicsWindow : public GraphicsWindow { protected: CallbackGraphicsWindow(GraphicsEngine *engine, - GraphicsPipe *pipe, + GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -89,7 +85,7 @@ PUBLISHED: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -119,7 +115,7 @@ PUBLISHED: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -169,7 +165,7 @@ PUBLISHED: private: static TypeHandle _type_handle; }; - + INLINE void set_events_callback(CallbackObject *object); INLINE void clear_events_callback(); INLINE CallbackObject *get_events_callback() const; diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index a62e6a4fb0..0b46da0252 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -1,16 +1,15 @@ -// Filename: config_display.cxx -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_display.cxx + * @author drose + * @date 1999-10-06 + */ #include "config_display.h" #include "callbackGraphicsWindow.h" @@ -52,11 +51,10 @@ ConfigVariableBool pstats_unused_states "of per-frame overhead to count these things up.")); -// Warning! The code that uses this is currently experimental and -// incomplete, and will almost certainly crash! Do not set -// threading-model to anything other than its default of a -// single-threaded model unless you are developing Panda's threading -// system! +// Warning! The code that uses this is currently experimental and incomplete, +// and will almost certainly crash! Do not set threading-model to anything +// other than its default of a single-threaded model unless you are developing +// Panda's threading system! ConfigVariableString threading_model ("threading-model", "", PRC_DESC("This is the default threading model to use for new windows. Use " @@ -474,14 +472,12 @@ ConfigVariableBool basic_shaders_only "flaky becomes reliable, we may expand the definition of what " "constitutes 'basic' shaders.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libdisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdisplay() { static bool initialized = false; diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index 23afbf578f..1196389f5a 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -1,16 +1,15 @@ -// Filename: config_display.h -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_display.h + * @author drose + * @date 1999-10-06 + */ #ifndef CONFIG_DISPLAY_H #define CONFIG_DISPLAY_H diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index 3cdcd067ec..aa83cfdf97 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -1,25 +1,22 @@ -// Filename: displayInformation.cxx -// Created by: aignacio (17Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayInformation.cxx + * @author aignacio + * @date 2007-01-17 + */ #include "graphicsStateGuardian.h" #include "displayInformation.h" -//////////////////////////////////////////////////////////////////// -// Function: DisplayMode::Comparison Operator -// Access: Published -// Description: Returns true if these two DisplayModes are identical. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if these two DisplayModes are identical. + */ bool DisplayMode:: operator == (const DisplayMode &other) const { return (width == other.width && height == other.height && @@ -28,21 +25,17 @@ operator == (const DisplayMode &other) const { fullscreen_only == other.fullscreen_only); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayMode::Comparison Operator -// Access: Published -// Description: Returns false if these two DisplayModes are identical. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if these two DisplayModes are identical. + */ bool DisplayMode:: operator != (const DisplayMode &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayMode::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayMode:: output(ostream &out) const { out << width << 'x' << height; @@ -57,11 +50,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayInformation:: ~DisplayInformation() { if (_display_mode_array != NULL) { @@ -75,11 +66,9 @@ DisplayInformation:: } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayInformation:: DisplayInformation() { DisplayInformation::DetectionState state; @@ -172,60 +161,48 @@ DisplayInformation() { _os_platform_id = -1; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation:: -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation::get_display_state() { return _state; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_maximum_window_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_maximum_window_width() { return _maximum_window_width; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_maximum_window_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_maximum_window_height() { return _maximum_window_height; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_window_bits_per_pixel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_window_bits_per_pixel() { return _window_bits_per_pixel; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_total_display_modes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_total_display_modes() { return _total_display_modes; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const DisplayMode &DisplayInformation:: get_display_mode(int display_index) { #ifndef NDEBUG @@ -236,126 +213,108 @@ get_display_mode(int display_index) { return _display_mode_array[display_index]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_display_mode_width (int display_index) { int value; - + value = 0; if (display_index >= 0 && display_index < _total_display_modes) { value = _display_mode_array [display_index].width; } - + return value; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_display_mode_height (int display_index) { int value; - + value = 0; if (display_index >= 0 && display_index < _total_display_modes) { value = _display_mode_array [display_index].height; } - + return value; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode_bits_per_pixel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_display_mode_bits_per_pixel (int display_index) { int value; - + value = 0; if (display_index >= 0 && display_index < _total_display_modes) { value = _display_mode_array [display_index].bits_per_pixel; } - + return value; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode_refresh_rate -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_display_mode_refresh_rate (int display_index) { int value; - + value = 0; if (display_index >= 0 && display_index < _total_display_modes) { value = _display_mode_array [display_index].refresh_rate; } - + return value; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_display_mode_fullscreen_only -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_display_mode_fullscreen_only (int display_index) { int value; - + value = 0; if (display_index >= 0 && display_index < _total_display_modes) { value = _display_mode_array [display_index].fullscreen_only; } - + return value; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_shader_model -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsStateGuardian::ShaderModel DisplayInformation:: get_shader_model() { return _shader_model; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_video_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_video_memory ( ) { return _video_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_texture_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_texture_memory() { return _texture_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::update_memory_information -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayInformation:: update_memory_information() { if (_get_memory_information_function) { @@ -363,243 +322,193 @@ update_memory_information() { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_physical_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_physical_memory() { return _physical_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_available_physical_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_available_physical_memory() { return _available_physical_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_page_file_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_page_file_size() { return _page_file_size; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_available_page_file_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_available_page_file_size() { return _available_page_file_size; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::_process_virtual_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_process_virtual_memory() { return _process_virtual_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_available_process_virtual_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_available_process_virtual_memory() { return _available_process_virtual_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_memory_load -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_memory_load() { return _memory_load; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_page_fault_count -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_page_fault_count() { return _page_fault_count; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_process_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_process_memory() { return _process_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_peak_process_memory -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_peak_process_memory() { return _peak_process_memory; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_page_file_usage -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_page_file_usage() { return _page_file_usage; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_peak_page_file_usage -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_peak_page_file_usage() { return _peak_page_file_usage; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_vendor_id -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_vendor_id() { return _vendor_id; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_device_id -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_device_id() { return _device_id; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_product -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_product() { return _driver_product; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_version -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_version() { return _driver_version; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_sub_version -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_sub_version() { return _driver_sub_version; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_build -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_build() { return _driver_build; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_date_month -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_date_month() { return _driver_date_month; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_date_day -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_date_day() { return _driver_date_day; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_driver_date_year -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_driver_date_year() { return _driver_date_year; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_id_version -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DisplayInformation:: get_cpu_id_version() { return _cpu_id_version; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_id_size -// Access: Published -// Description: Returns the number of 32-bit values for cpu id -// binary data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of 32-bit values for cpu id binary data. + */ int DisplayInformation:: get_cpu_id_size() { return _cpu_id_size; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_id_data -// Access: Published -// Description: Returns part of cpu id binary data based on the -// index. -//////////////////////////////////////////////////////////////////// +/** + * Returns part of cpu id binary data based on the index. + */ unsigned int DisplayInformation:: get_cpu_id_data(int index) { unsigned int data; @@ -608,116 +517,98 @@ get_cpu_id_data(int index) { if (index >= 0 && index < _cpu_id_size) { data = _cpu_id_data [index]; } - + return data; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_vendor_string -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *DisplayInformation:: -get_cpu_vendor_string() { +get_cpu_vendor_string() { const char *string; - + string = _cpu_vendor_string; if (string == 0) { string = ""; } - + return string; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_brand_string -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *DisplayInformation:: -get_cpu_brand_string() { +get_cpu_brand_string() { const char *string; - + string = _cpu_brand_string; if (string == 0) { string = ""; } - + return string; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_version_information -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int DisplayInformation:: -get_cpu_version_information() { +get_cpu_version_information() { return _cpu_version_information; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_brand_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int DisplayInformation:: -get_cpu_brand_index() { +get_cpu_brand_index() { return _cpu_brand_index; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_frequency -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_cpu_frequency() { return _cpu_frequency; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_cpu_time -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_cpu_time() { PN_uint64 cpu_time; - + cpu_time = 0; if (_cpu_time_function) { cpu_time = _cpu_time_function(); } - + return cpu_time; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_maximum_cpu_frequency -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_maximum_cpu_frequency() { return _maximum_cpu_frequency; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_current_cpu_frequency -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint64 DisplayInformation:: get_current_cpu_frequency() { return _current_cpu_frequency; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::update_cpu_frequency -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayInformation:: update_cpu_frequency(int processor_number) { if (_update_cpu_frequency_function) { @@ -725,66 +616,52 @@ update_cpu_frequency(int processor_number) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_num_cpu_cores -// Access: Published -// Description: Returns the number of individual CPU cores in the -// system, or 0 if this number is not available. A -// hyperthreaded CPU counts once here. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual CPU cores in the system, or 0 if this + * number is not available. A hyperthreaded CPU counts once here. + */ int DisplayInformation:: get_num_cpu_cores() { return _num_cpu_cores; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_num_logical_cpus -// Access: Published -// Description: Returns the number of logical CPU's in the -// system, or 0 if this number is not available. A -// hyperthreaded CPU counts as two or more here. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of logical CPU's in the system, or 0 if this number is + * not available. A hyperthreaded CPU counts as two or more here. + */ int DisplayInformation:: get_num_logical_cpus() { return _num_logical_cpus; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_os_version_major -// Access: Published -// Description: Returns -1 if not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if not set. + */ int DisplayInformation:: -get_os_version_major() { +get_os_version_major() { return _os_version_major; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_os_version_minor -// Access: Published -// Description: Returns -1 if not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if not set. + */ int DisplayInformation:: -get_os_version_minor() { +get_os_version_minor() { return _os_version_minor; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_os_version_build -// Access: Published -// Description: Returns -1 if not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if not set. + */ int DisplayInformation:: -get_os_version_build() { +get_os_version_build() { return _os_version_build; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayInformation::get_os_platform_id -// Access: Published -// Description: Returns -1 if not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1 if not set. + */ int DisplayInformation:: -get_os_platform_id() { +get_os_platform_id() { return _os_platform_id; } diff --git a/panda/src/display/displayInformation.h b/panda/src/display/displayInformation.h index c4d624097e..e8ddfd2a72 100644 --- a/panda/src/display/displayInformation.h +++ b/panda/src/display/displayInformation.h @@ -1,16 +1,15 @@ -// Filename: displayInformation.h -// Created by: aignacio (17Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayInformation.h + * @author aignacio + * @date 2007-01-17 + */ #ifndef DISPLAYINFORMATION_H #define DISPLAYINFORMATION_H @@ -31,10 +30,9 @@ PUBLISHED: void output(ostream &out) const; }; -//////////////////////////////////////////////////////////////////// -// Class : DisplayInformation -// Description : This class contains various display information. -//////////////////////////////////////////////////////////////////// +/** + * This class contains various display information. + */ class EXPCL_PANDA_DISPLAY DisplayInformation { PUBLISHED: enum DetectionState { @@ -104,7 +102,7 @@ PUBLISHED: const char *get_cpu_brand_string(); unsigned int get_cpu_version_information(); unsigned int get_cpu_brand_index(); - + PN_uint64 get_cpu_frequency(); PN_uint64 get_cpu_time(); @@ -119,7 +117,7 @@ PUBLISHED: int get_os_version_minor(); int get_os_version_build(); int get_os_platform_id(); - + public: DetectionState _state; int _get_adapter_display_mode_state; @@ -145,7 +143,7 @@ public: PN_uint64 _peak_process_memory; PN_uint64 _page_file_usage; PN_uint64 _peak_page_file_usage; - + int _memory_load; int _vendor_id; @@ -168,19 +166,19 @@ public: char *_cpu_brand_string; unsigned int _cpu_version_information; unsigned int _cpu_brand_index; - + PN_uint64 _cpu_frequency; - + PN_uint64 _maximum_cpu_frequency; PN_uint64 _current_cpu_frequency; int _num_cpu_cores; int _num_logical_cpus; - + void (*_get_memory_information_function) (DisplayInformation *display_information); PN_uint64 (*_cpu_time_function) (void); int (*_update_cpu_frequency_function) (int processor_number, DisplayInformation *display_information); - + int _os_version_major; int _os_version_minor; int _os_version_build; diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index 8ff398ee0e..11492a3a5e 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -1,64 +1,51 @@ -// Filename: displayRegion.I -// Created by: frang (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegion.I + * @author frang + * @date 1999-03-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::operator < -// Access: Public -// Description: Returns true if this DisplayRegion should be sorted -// before the other one, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this DisplayRegion should be sorted before the other one, + * false otherwise. + */ INLINE bool DisplayRegion:: operator < (const DisplayRegion &other) const { return get_sort() < other.get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_lens_index -// Access: Public -// Description: Returns the specific lens of the associated Camera -// that will be used for rendering this scene. Most -// Cameras hold only one lens, but for multiple lenses -// this method may be used to selected between them. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specific lens of the associated Camera that will be used for + * rendering this scene. Most Cameras hold only one lens, but for multiple + * lenses this method may be used to selected between them. + */ INLINE int DisplayRegion:: get_lens_index() const { CDReader cdata(_cycler); return cdata->_lens_index; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_num_regions -// Access: Published -// Description: Returns the number of regions, see set_num_regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of regions, see set_num_regions. + */ INLINE int DisplayRegion:: get_num_regions() const { CDReader cdata(_cycler); return cdata->_regions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_num_regions -// Access: Published -// Description: Sets the number of regions that this DisplayRegion -// indicates. Usually, this number is 1 (and it is -// always at least 1), and only the first is used for -// rendering. However, if more than one is provided, -// you may select which one to render into using a -// geometry shader (gl_ViewportIndex in GLSL). -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of regions that this DisplayRegion indicates. Usually, + * this number is 1 (and it is always at least 1), and only the first is used + * for rendering. However, if more than one is provided, you may select which + * one to render into using a geometry shader (gl_ViewportIndex in GLSL). + */ INLINE void DisplayRegion:: set_num_regions(int i) { nassertv(i >= 1); @@ -66,25 +53,19 @@ set_num_regions(int i) { cdata->_regions.resize(i); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_dimensions -// Access: Published -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE void DisplayRegion:: get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { get_dimensions(0, l, r, b, t); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_dimensions -// Access: Published -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE void DisplayRegion:: get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { CDReader cdata(_cycler); @@ -95,414 +76,317 @@ get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloa t = region._dimensions[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_dimensions -// Access: Published -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE LVecBase4 DisplayRegion:: get_dimensions(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_left -// Access: Published -// Description: Retrieves the x coordinate of the left edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the left edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegion:: get_left(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._dimensions[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_right -// Access: Published -// Description: Retrieves the x coordinate of the right edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the right edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegion:: get_right(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._dimensions[1]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_bottom -// Access: Published -// Description: Retrieves the y coordinate of the bottom edge of -// the rectangle within its GraphicsOutput. This -// number will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the bottom edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegion:: get_bottom(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._dimensions[2]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_top -// Access: Published -// Description: Retrieves the y coordinate of the top edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the top edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegion:: get_top(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._dimensions[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_dimensions -// Access: Published, Virtual -// Description: Changes the portion of the framebuffer this -// DisplayRegion corresponds to. The parameters range -// from 0 to 1, where 0,0 is the lower left corner and -// 1,1 is the upper right; (0, 1, 0, 1) represents the -// whole screen. -//////////////////////////////////////////////////////////////////// +/** + * Changes the portion of the framebuffer this DisplayRegion corresponds to. + * The parameters range from 0 to 1, where 0,0 is the lower left corner and + * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen. + */ INLINE void DisplayRegion:: set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { set_dimensions(0, LVecBase4(l, r, b, t)); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_dimensions -// Access: Published, Virtual -// Description: Changes the portion of the framebuffer this -// DisplayRegion corresponds to. The parameters range -// from 0 to 1, where 0,0 is the lower left corner and -// 1,1 is the upper right; (0, 1, 0, 1) represents the -// whole screen. -//////////////////////////////////////////////////////////////////// +/** + * Changes the portion of the framebuffer this DisplayRegion corresponds to. + * The parameters range from 0 to 1, where 0,0 is the lower left corner and + * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen. + */ INLINE void DisplayRegion:: set_dimensions(int i, PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { set_dimensions(i, LVecBase4(l, r, b, t)); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_dimensions -// Access: Published, Virtual -// Description: Changes the portion of the framebuffer this -// DisplayRegion corresponds to. The parameters range -// from 0 to 1, where 0,0 is the lower left corner and -// 1,1 is the upper right; (0, 1, 0, 1) represents the -// whole screen. -//////////////////////////////////////////////////////////////////// +/** + * Changes the portion of the framebuffer this DisplayRegion corresponds to. + * The parameters range from 0 to 1, where 0,0 is the lower left corner and + * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen. + */ INLINE void DisplayRegion:: set_dimensions(const LVecBase4 &dimensions) { set_dimensions(0, dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_window -// Access: Published -// Description: Returns the GraphicsOutput that this DisplayRegion is -// ultimately associated with, or NULL if no window is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsOutput that this DisplayRegion is ultimately associated + * with, or NULL if no window is associated. + */ INLINE GraphicsOutput *DisplayRegion:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_camera -// Access: Published -// Description: Returns the camera associated with this -// DisplayRegion, or an empty NodePath if no camera is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera associated with this DisplayRegion, or an empty NodePath + * if no camera is associated. + */ INLINE NodePath DisplayRegion:: get_camera(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_camera; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::is_active -// Access: Published -// Description: Returns the active flag associated with the -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag associated with the DisplayRegion. + */ INLINE bool DisplayRegion:: is_active() const { CDReader cdata(_cycler); return cdata->_active; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_sort -// Access: Published -// Description: Returns the sort value associated with the -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort value associated with the DisplayRegion. + */ INLINE int DisplayRegion:: get_sort() const { CDReader cdata(_cycler); return cdata->_sort; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_stereo_channel -// Access: Published -// Description: Returns whether the DisplayRegion is specified as the -// left or right channel of a stereo pair, or whether it -// is a normal, monocular image. See -// set_stereo_channel(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the DisplayRegion is specified as the left or right channel + * of a stereo pair, or whether it is a normal, monocular image. See + * set_stereo_channel(). + */ INLINE Lens::StereoChannel DisplayRegion:: get_stereo_channel() const { CDReader cdata(_cycler); return cdata->_stereo_channel; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_tex_view_offset -// Access: Public -// Description: Returns the current texture view offset for this -// DisplayRegion. This is normally set to zero. If -// nonzero, it is used to select a particular view of -// any multiview textures that are rendered within this -// DisplayRegion. -// -// For a StereoDisplayRegion, this is normally 0 for the -// left eye, and 1 for the right eye, to support stereo -// textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current texture view offset for this DisplayRegion. This is + * normally set to zero. If nonzero, it is used to select a particular view + * of any multiview textures that are rendered within this DisplayRegion. + * + * For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for + * the right eye, to support stereo textures. + */ INLINE int DisplayRegion:: get_tex_view_offset() const { CDReader cdata(_cycler); return cdata->_tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_incomplete_render -// Access: Published -// Description: Returns the incomplete_render flag. See -// set_incomplete_render(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the incomplete_render flag. See set_incomplete_render(). + */ INLINE bool DisplayRegion:: get_incomplete_render() const { return _incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_texture_reload_priority -// Access: Published -// Description: Returns the priority which is assigned to -// asynchronous texture reload requests. See -// set_texture_reload_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the priority which is assigned to asynchronous texture reload + * requests. See set_texture_reload_priority(). + */ INLINE int DisplayRegion:: get_texture_reload_priority() const { return _texture_reload_priority; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_cube_map_index -// Access: Published -// Description: Deprecated; replaced by set_target_tex_page(). -//////////////////////////////////////////////////////////////////// +/** + * Deprecated; replaced by set_target_tex_page(). + */ INLINE void DisplayRegion:: set_cube_map_index(int cube_map_index) { set_target_tex_page(cube_map_index); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_target_tex_page -// Access: Published -// Description: Returns the target page number associated with this -// particular DisplayRegion, or -1 if it is not -// associated with a page. See -// set_target_tex_page(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the target page number associated with this particular + * DisplayRegion, or -1 if it is not associated with a page. See + * set_target_tex_page(). + */ INLINE int DisplayRegion:: get_target_tex_page() const { CDReader cdata(_cycler); return cdata->_target_tex_page; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_scissor_enabled -// Access: Published -// Description: Sets whether or not scissor testing is enabled -// for this region. The default is true, except for -// the overlay display region. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether or not scissor testing is enabled for this region. The + * default is true, except for the overlay display region. + */ INLINE void DisplayRegion:: set_scissor_enabled(bool scissor_enabled) { CDWriter cdata(_cycler); cdata->_scissor_enabled = scissor_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_scissor_enabled -// Access: Published -// Description: Returns whether or not scissor testing is enabled -// for this region. The default is true, except for -// the overlay display region. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether or not scissor testing is enabled for this region. The + * default is true, except for the overlay display region. + */ INLINE bool DisplayRegion:: get_scissor_enabled() const { CDReader cdata(_cycler); return cdata->_scissor_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_cull_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// the DisplayRegion is visited during the cull -// traversal. This callback will be made during the -// cull thread. -// -// The cull traversal is responsible for determining -// which nodes are visible and within the view frustum, -// and for accumulating state and transform, and -// generally building up the list of CullableObjects -// that are to be eventually passed to the draw -// traversal for rendering. -// -// At the time the cull traversal callback is made, the -// traversal for this DisplayRegion has not yet started. -// -// The callback is passed an instance of a -// DisplayRegionCullCallbackData, which contains -// pointers to the current scene information, as well as -// the current DisplayRegion and GSG. The callback -// *replaces* the normal cull behavior, so if your -// callback does nothing, the scene graph will not be -// traversed and therefore nothing will be drawn. If -// you wish the normal cull traversal to be performed -// for this DisplayRegion, you must call -// cbdata->upcall() from your callback. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when the DisplayRegion is + * visited during the cull traversal. This callback will be made during the + * cull thread. + * + * The cull traversal is responsible for determining which nodes are visible + * and within the view frustum, and for accumulating state and transform, and + * generally building up the list of CullableObjects that are to be eventually + * passed to the draw traversal for rendering. + * + * At the time the cull traversal callback is made, the traversal for this + * DisplayRegion has not yet started. + * + * The callback is passed an instance of a DisplayRegionCullCallbackData, + * which contains pointers to the current scene information, as well as the + * current DisplayRegion and GSG. The callback *replaces* the normal cull + * behavior, so if your callback does nothing, the scene graph will not be + * traversed and therefore nothing will be drawn. If you wish the normal cull + * traversal to be performed for this DisplayRegion, you must call + * cbdata->upcall() from your callback. + */ INLINE void DisplayRegion:: set_cull_callback(CallbackObject *object) { CDWriter cdata(_cycler); cdata->_cull_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::clear_cull_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_cull_callback(). + */ INLINE void DisplayRegion:: clear_cull_callback() { set_cull_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_cull_callback -// Access: Published -// Description: Returns the CallbackObject set by set_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_cull_callback(). + */ INLINE CallbackObject *DisplayRegion:: get_cull_callback() const { CDReader cdata(_cycler); return cdata->_cull_callback; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_draw_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// the contents of DisplayRegion is drawn during the -// draw traversal. This callback will be made during -// the draw thread. -// -// The draw traversal is responsible for actually -// issuing the commands to the graphics engine to draw -// primitives. Its job is to walk through the list of -// CullableObjects build up by the cull traversal, as -// quickly as possible, issuing the appropriate commands -// to draw each one. -// -// At the time the draw traversal callback is made, the -// graphics state is in the initial state, and no -// projection matrix or modelview matrix is in effect. -// begin_scene() has not yet been called, and no objects -// have yet been drawn. However, the viewport has -// already been set to the appropriate part of the -// window, and the clear commands for this DisplayRegion -// (if any) have been issued. -// -// The callback is passed an instance of a -// DisplayRegionDrawCallbackData, which contains -// pointers to the current scene information, as well as -// the current DisplayRegion and GSG. The callback -// *replaces* the normal draw behavior, so if your -// callback does nothing, nothing in the DisplayRegion -// will be drawn. If you wish the draw traversal to -// continue to draw the contents of this DisplayRegion, -// you must call cbdata->upcall() from your callback. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when the contents of + * DisplayRegion is drawn during the draw traversal. This callback will be + * made during the draw thread. + * + * The draw traversal is responsible for actually issuing the commands to the + * graphics engine to draw primitives. Its job is to walk through the list of + * CullableObjects build up by the cull traversal, as quickly as possible, + * issuing the appropriate commands to draw each one. + * + * At the time the draw traversal callback is made, the graphics state is in + * the initial state, and no projection matrix or modelview matrix is in + * effect. begin_scene() has not yet been called, and no objects have yet + * been drawn. However, the viewport has already been set to the appropriate + * part of the window, and the clear commands for this DisplayRegion (if any) + * have been issued. + * + * The callback is passed an instance of a DisplayRegionDrawCallbackData, + * which contains pointers to the current scene information, as well as the + * current DisplayRegion and GSG. The callback *replaces* the normal draw + * behavior, so if your callback does nothing, nothing in the DisplayRegion + * will be drawn. If you wish the draw traversal to continue to draw the + * contents of this DisplayRegion, you must call cbdata->upcall() from your + * callback. + */ INLINE void DisplayRegion:: set_draw_callback(CallbackObject *object) { CDWriter cdata(_cycler); cdata->_draw_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::clear_draw_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_draw_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_draw_callback(). + */ INLINE void DisplayRegion:: clear_draw_callback() { set_draw_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_draw_callback -// Access: Published -// Description: Returns the CallbackObject set by set_draw_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_draw_callback(). + */ INLINE CallbackObject *DisplayRegion:: get_draw_callback() const { CDReader cdata(_cycler); return cdata->_draw_callback; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pixel_width -// Access: Published -// Description: Returns the width of the DisplayRegion in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the DisplayRegion in pixels. + */ INLINE int DisplayRegion:: get_pixel_width(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._pixels[1] - cdata->_regions[i]._pixels[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pixel_height -// Access: Published -// Description: Returns the height of the DisplayRegion in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the DisplayRegion in pixels. + */ INLINE int DisplayRegion:: get_pixel_height(int i) const { CDReader cdata(_cycler); return cdata->_regions[i]._pixels[3] - cdata->_regions[i]._pixels[2]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pixel_size -// Access: Published -// Description: Returns the size of the DisplayRegion in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the DisplayRegion in pixels. + */ INLINE LVecBase2i DisplayRegion:: get_pixel_size(int i) const { CDReader cdata(_cycler); @@ -510,23 +394,19 @@ get_pixel_size(int i) const { cdata->_regions[i]._pixels[3] - cdata->_regions[i]._pixels[2]); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, in + * pixels. + */ INLINE void DisplayRegion:: get_pixels(int &pl, int &pr, int &pb, int &pt) const { get_pixels(0, pl, pr, pb, pt); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, in + * pixels. + */ INLINE void DisplayRegion:: get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const { CDReader cdata(_cycler); @@ -537,25 +417,21 @@ get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const { pt = region._pixels[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_region_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, as the pixel location of its bottom-left -// corner, along with a pixel width and height. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, as the + * pixel location of its bottom-left corner, along with a pixel width and + * height. + */ INLINE void DisplayRegion:: get_region_pixels(int &xo, int &yo, int &w, int &h) const { get_region_pixels(0, xo, yo, w, h); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_region_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, as the pixel location of its bottom-left -// corner, along with a pixel width and height. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, as the + * pixel location of its bottom-left corner, along with a pixel width and + * height. + */ INLINE void DisplayRegion:: get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const { CDReader cdata(_cycler); @@ -566,27 +442,21 @@ get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const { h = region._pixels[3] - yo; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_region_pixels_i -// Access: Public -// Description: Similar to get_region_pixels(), but returns the upper -// left corner, and the pixel numbers are numbered from -// the top-left corner down, in the DirectX way of -// things. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_region_pixels(), but returns the upper left corner, and the + * pixel numbers are numbered from the top-left corner down, in the DirectX + * way of things. + */ INLINE void DisplayRegion:: get_region_pixels_i(int &xo, int &yo, int &w, int &h) const { get_region_pixels_i(0, xo, yo, w, h); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_region_pixels_i -// Access: Public -// Description: Similar to get_region_pixels(), but returns the upper -// left corner, and the pixel numbers are numbered from -// the top-left corner down, in the DirectX way of -// things. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_region_pixels(), but returns the upper left corner, and the + * pixel numbers are numbered from the top-left corner down, in the DirectX + * way of things. + */ INLINE void DisplayRegion:: get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const { CDReader cdata(_cycler); @@ -597,17 +467,14 @@ get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const { h = region._pixels_i[2] - yo; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_cull_result -// Access: Public -// Description: Stores the result of performing a cull operation on -// this DisplayRegion. Normally, this will only be -// called by the GraphicsEngine; you should not call -// this directly. -// -// The stored result will automatically be applied back -// to all upstream pipeline stages. -//////////////////////////////////////////////////////////////////// +/** + * Stores the result of performing a cull operation on this DisplayRegion. + * Normally, this will only be called by the GraphicsEngine; you should not + * call this directly. + * + * The stored result will automatically be applied back to all upstream + * pipeline stages. + */ INLINE void DisplayRegion:: set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup, Thread *current_thread) { @@ -621,63 +488,49 @@ set_cull_result(PT(CullResult) cull_result, PT(SceneSetup) scene_setup, #endif } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_cull_result -// Access: Public -// Description: Returns the CullResult value that was stored on this -// DisplayRegion, presumably by the last successful cull -// operation. This method is for the benefit of the -// GraphicsEngine; normally you shouldn't call this -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CullResult value that was stored on this DisplayRegion, + * presumably by the last successful cull operation. This method is for the + * benefit of the GraphicsEngine; normally you shouldn't call this directly. + */ INLINE CullResult *DisplayRegion:: get_cull_result(Thread *current_thread) const { CDCullReader cdata(_cycler_cull, current_thread); return cdata->_cull_result; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_scene_setup -// Access: Public -// Description: Returns the SceneSetup value that was stored on this -// DisplayRegion, presumably by the last successful cull -// operation. This method is for the benefit of the -// GraphicsEngine; normally you shouldn't call this -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SceneSetup value that was stored on this DisplayRegion, + * presumably by the last successful cull operation. This method is for the + * benefit of the GraphicsEngine; normally you shouldn't call this directly. + */ INLINE SceneSetup *DisplayRegion:: get_scene_setup(Thread *current_thread) const { CDCullReader cdata(_cycler_cull, current_thread); return cdata->_scene_setup; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_cull_region_pcollector -// Access: Public -// Description: Returns a PStatCollector for timing the cull -// operation for just this DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector for timing the cull operation for just this + * DisplayRegion. + */ INLINE PStatCollector &DisplayRegion:: get_cull_region_pcollector() { return _cull_region_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_draw_region_pcollector -// Access: Public -// Description: Returns a PStatCollector for timing the draw -// operation for just this DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector for timing the draw operation for just this + * DisplayRegion. + */ INLINE PStatCollector &DisplayRegion:: get_draw_region_pcollector() { return _draw_region_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Region::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegion::Region:: Region() : _dimensions(0, 1, 0, 1), @@ -685,20 +538,16 @@ Region() : _pixels_i(0) { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CDataCull::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegion::CDataCull:: CDataCull() { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CDataCull::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegion::CDataCull:: CDataCull(const DisplayRegion::CDataCull ©) : _cull_result(copy._cull_result), @@ -706,11 +555,9 @@ CDataCull(const DisplayRegion::CDataCull ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegionPipelineReader:: DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread) : _object(object), @@ -725,31 +572,25 @@ DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread) : #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE DisplayRegionPipelineReader:: DisplayRegionPipelineReader(const DisplayRegionPipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void DisplayRegionPipelineReader:: operator = (const DisplayRegionPipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegionPipelineReader:: ~DisplayRegionPipelineReader() { #ifdef _DEBUG @@ -766,65 +607,51 @@ INLINE DisplayRegionPipelineReader:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegion *DisplayRegionPipelineReader:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *DisplayRegionPipelineReader:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::is_any_clear_active -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool DisplayRegionPipelineReader:: is_any_clear_active() const { return _object->is_any_clear_active(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_num_regions -// Access: Published -// Description: Returns the number of regions, see set_num_regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of regions, see set_num_regions. + */ INLINE int DisplayRegionPipelineReader:: get_num_regions() const { return _cdata->_regions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_dimensions -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE void DisplayRegionPipelineReader:: get_dimensions(PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { return get_dimensions(0, l, r, b, t); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_dimensions -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE void DisplayRegionPipelineReader:: get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloat &t) const { const DisplayRegion::Region ®ion = _cdata->_regions[i]; @@ -834,195 +661,148 @@ get_dimensions(int i, PN_stdfloat &l, PN_stdfloat &r, PN_stdfloat &b, PN_stdfloa t = region._dimensions[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_dimensions -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsOutput. These numbers -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion's rectangle within its + * GraphicsOutput. These numbers will be in the range [0..1]. + */ INLINE const LVecBase4 &DisplayRegionPipelineReader:: get_dimensions(int i) const { return _cdata->_regions[i]._dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_left -// Access: Public -// Description: Retrieves the x coordinate of the left edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the left edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegionPipelineReader:: get_left(int i) const { return _cdata->_regions[i]._dimensions[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_right -// Access: Public -// Description: Retrieves the x coordinate of the right edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the right edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegionPipelineReader:: get_right(int i) const { return _cdata->_regions[i]._dimensions[1]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_bottom -// Access: Public -// Description: Retrieves the y coordinate of the bottom edge of -// the rectangle within its GraphicsOutput. This -// number will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the bottom edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegionPipelineReader:: get_bottom(int i) const { return _cdata->_regions[i]._dimensions[2]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_top -// Access: Public -// Description: Retrieves the y coordinate of the top edge of the -// rectangle within its GraphicsOutput. This number -// will be in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the top edge of the rectangle within its + * GraphicsOutput. This number will be in the range [0..1]. + */ INLINE PN_stdfloat DisplayRegionPipelineReader:: get_top(int i) const { return _cdata->_regions[i]._dimensions[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_window -// Access: Public -// Description: Returns the GraphicsOutput that this DisplayRegion is -// ultimately associated with, or NULL if no window is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsOutput that this DisplayRegion is ultimately associated + * with, or NULL if no window is associated. + */ INLINE GraphicsOutput *DisplayRegionPipelineReader:: get_window() const { return _object->_window; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_camera -// Access: Public -// Description: Returns the camera associated with this -// DisplayRegion, or an empty NodePath if no camera is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera associated with this DisplayRegion, or an empty NodePath + * if no camera is associated. + */ INLINE NodePath DisplayRegionPipelineReader:: get_camera() const { return _cdata->_camera; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::is_active -// Access: Public -// Description: Returns the active flag associated with the -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag associated with the DisplayRegion. + */ INLINE bool DisplayRegionPipelineReader:: is_active() const { return _cdata->_active; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_sort -// Access: Public -// Description: Returns the sort value associated with the -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort value associated with the DisplayRegion. + */ INLINE int DisplayRegionPipelineReader:: get_sort() const { return _cdata->_sort; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_stereo_channel -// Access: Public -// Description: Returns whether the DisplayRegion is specified as the -// left or right channel of a stereo pair, or whether it -// is a normal, monocular image. See -// set_stereo_channel(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the DisplayRegion is specified as the left or right channel + * of a stereo pair, or whether it is a normal, monocular image. See + * set_stereo_channel(). + */ INLINE Lens::StereoChannel DisplayRegionPipelineReader:: get_stereo_channel() const { return _cdata->_stereo_channel; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_tex_view_offset -// Access: Public -// Description: Returns the current texture view offset for this -// DisplayRegion. This is normally set to zero. If -// nonzero, it is used to select a particular view of -// any multiview textures that are rendered within this -// DisplayRegion. -// -// For a StereoDisplayRegion, this is normally 0 for the -// left eye, and 1 for the right eye, to support stereo -// textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current texture view offset for this DisplayRegion. This is + * normally set to zero. If nonzero, it is used to select a particular view + * of any multiview textures that are rendered within this DisplayRegion. + * + * For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for + * the right eye, to support stereo textures. + */ INLINE int DisplayRegionPipelineReader:: get_tex_view_offset() { return _cdata->_tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_target_tex_page -// Access: Published -// Description: Returns the target page number associated with this -// particular DisplayRegion, or -1 if it is not -// associated with a page. See -// set_target_tex_page(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the target page number associated with this particular + * DisplayRegion, or -1 if it is not associated with a page. See + * set_target_tex_page(). + */ INLINE int DisplayRegionPipelineReader:: get_target_tex_page() const { return _cdata->_target_tex_page; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_scissor_enabled -// Access: Published -// Description: Returns whether or not scissor testing is enabled -// for this region. The default is true, except for -// the overlay display region. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether or not scissor testing is enabled for this region. The + * default is true, except for the overlay display region. + */ INLINE bool DisplayRegionPipelineReader:: get_scissor_enabled() const { return _cdata->_scissor_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_draw_callback -// Access: Published -// Description: Returns the CallbackObject set by set_draw_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_draw_callback(). + */ INLINE CallbackObject *DisplayRegionPipelineReader:: get_draw_callback() const { return _cdata->_draw_callback; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, in + * pixels. + */ INLINE void DisplayRegionPipelineReader:: get_pixels(int &pl, int &pr, int &pb, int &pt) const { get_pixels(0, pl, pr, pb, pt); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, in + * pixels. + */ INLINE void DisplayRegionPipelineReader:: get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const { const DisplayRegion::Region ®ion = _cdata->_regions[i]; @@ -1032,25 +812,21 @@ get_pixels(int i, int &pl, int &pr, int &pb, int &pt) const { pt = region._pixels[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_region_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, as the pixel location of its bottom-left -// corner, along with a pixel width and height. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, as the + * pixel location of its bottom-left corner, along with a pixel width and + * height. + */ INLINE void DisplayRegionPipelineReader:: get_region_pixels(int &xo, int &yo, int &w, int &h) const { get_region_pixels(0, xo, yo, w, h); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_region_pixels -// Access: Public -// Description: Retrieves the coordinates of the DisplayRegion within -// its window, as the pixel location of its bottom-left -// corner, along with a pixel width and height. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the coordinates of the DisplayRegion within its window, as the + * pixel location of its bottom-left corner, along with a pixel width and + * height. + */ INLINE void DisplayRegionPipelineReader:: get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const { const DisplayRegion::Region ®ion = _cdata->_regions[i]; @@ -1060,27 +836,21 @@ get_region_pixels(int i, int &xo, int &yo, int &w, int &h) const { h = region._pixels[3] - yo; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_region_pixels_i -// Access: Public -// Description: Similar to get_region_pixels(), but returns the upper -// left corner, and the pixel numbers are numbered from -// the top-left corner down, in the DirectX way of -// things. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_region_pixels(), but returns the upper left corner, and the + * pixel numbers are numbered from the top-left corner down, in the DirectX + * way of things. + */ INLINE void DisplayRegionPipelineReader:: get_region_pixels_i(int &xo, int &yo, int &w, int &h) const { get_region_pixels_i(0, xo, yo, w, h); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_region_pixels_i -// Access: Public -// Description: Similar to get_region_pixels(), but returns the upper -// left corner, and the pixel numbers are numbered from -// the top-left corner down, in the DirectX way of -// things. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_region_pixels(), but returns the upper left corner, and the + * pixel numbers are numbered from the top-left corner down, in the DirectX + * way of things. + */ INLINE void DisplayRegionPipelineReader:: get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const { const DisplayRegion::Region ®ion = _cdata->_regions[i]; @@ -1090,31 +860,25 @@ get_region_pixels_i(int i, int &xo, int &yo, int &w, int &h) const { h = region._pixels_i[2] - yo; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_pixel_width -// Access: Public -// Description: Returns the width of the DisplayRegion in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the DisplayRegion in pixels. + */ INLINE int DisplayRegionPipelineReader:: get_pixel_width(int i) const { return _cdata->_regions[i]._pixels[1] - _cdata->_regions[i]._pixels[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_lens_index -// Access: Public -// Description: Gets the index into a lens_node lens array. 0 default -//////////////////////////////////////////////////////////////////// +/** + * Gets the index into a lens_node lens array. 0 default + */ INLINE int DisplayRegionPipelineReader:: get_lens_index() const { return _cdata->_lens_index; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_pixel_height -// Access: Public -// Description: Returns the height of the DisplayRegion in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the DisplayRegion in pixels. + */ INLINE int DisplayRegionPipelineReader:: get_pixel_height(int i) const { return _cdata->_regions[i]._pixels[3] - _cdata->_regions[i]._pixels[2]; diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 8e2fc71e4e..d0eb6362b2 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -1,16 +1,15 @@ -// Filename: displayRegion.cxx -// Created by: cary (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegion.cxx + * @author cary + * @date 1999-02-10 + */ #include "displayRegion.h" #include "stereoDisplayRegion.h" @@ -27,11 +26,9 @@ TypeHandle DisplayRegion::_type_handle; TypeHandle DisplayRegionPipelineReader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegion:: DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions) : _window(window), @@ -49,51 +46,42 @@ DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions) : _window->add_display_region(this); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegion:: -DisplayRegion(const DisplayRegion ©) : +DisplayRegion(const DisplayRegion ©) : _window(NULL), _cull_region_pcollector("Cull:Invalid"), _draw_region_pcollector("Draw:Invalid") { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayRegion:: operator = (const DisplayRegion&) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegion:: ~DisplayRegion() { cleanup(); - // The window pointer should already have been cleared by the time - // the DisplayRegion destructs (since the GraphicsOutput class keeps - // a reference count on the DisplayRegion). + // The window pointer should already have been cleared by the time the + // DisplayRegion destructs (since the GraphicsOutput class keeps a reference + // count on the DisplayRegion). nassertv(_window == (GraphicsOutput *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::cleanup -// Access: Public -// Description: Cleans up some pointers associated with the -// DisplayRegion to help reduce the chance of memory -// leaks due to circular reference counts. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up some pointers associated with the DisplayRegion to help reduce + * the chance of memory leaks due to circular reference counts. + */ void DisplayRegion:: cleanup() { set_camera(NodePath()); @@ -102,14 +90,11 @@ cleanup() { cdata->_cull_result = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_lens_index -// Access: Published -// Description: Sets the lens index, allows for multiple lenses to -// be attached to a camera. This is useful for a -// variety of setups, such as fish eye rendering. -// The default is 0. -//////////////////////////////////////////////////////////////////// +/** + * Sets the lens index, allows for multiple lenses to be attached to a camera. + * This is useful for a variety of setups, such as fish eye rendering. The + * default is 0. + */ void DisplayRegion:: set_lens_index(int index) { int pipeline_stage = Thread::get_current_pipeline_stage(); @@ -118,15 +103,11 @@ set_lens_index(int index) { cdata->_lens_index = index; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_dimensions -// Access: Published, Virtual -// Description: Changes the portion of the framebuffer this -// DisplayRegion corresponds to. The parameters range -// from 0 to 1, where 0,0 is the lower left corner and -// 1,1 is the upper right; (0, 1, 0, 1) represents the -// whole screen. -//////////////////////////////////////////////////////////////////// +/** + * Changes the portion of the framebuffer this DisplayRegion corresponds to. + * The parameters range from 0 to 1, where 0,0 is the lower left corner and + * 1,1 is the upper right; (0, 1, 0, 1) represents the whole screen. + */ void DisplayRegion:: set_dimensions(int i, const LVecBase4 &dimensions) { int pipeline_stage = Thread::get_current_pipeline_stage(); @@ -140,47 +121,37 @@ set_dimensions(int i, const LVecBase4 &dimensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_pipe -// Access: Published -// Description: Returns the GraphicsPipe that this DisplayRegion is -// ultimately associated with, or NULL if no pipe is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsPipe that this DisplayRegion is ultimately associated + * with, or NULL if no pipe is associated. + */ GraphicsPipe *DisplayRegion:: get_pipe() const { return (_window != (GraphicsOutput *)NULL) ? _window->get_pipe() : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::is_stereo -// Access: Published, Virtual -// Description: Returns true if this is a StereoDisplayRegion, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is a StereoDisplayRegion, false otherwise. + */ bool DisplayRegion:: is_stereo() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_camera -// Access: Published, Virtual -// Description: Sets the camera that is associated with this -// DisplayRegion. There is a one-to-many association -// between cameras and DisplayRegions; one camera may be -// shared by multiple DisplayRegions. -// -// The camera is actually set via a NodePath, which -// clarifies which instance of the camera (if there -// happen to be multiple instances) we should use. -//////////////////////////////////////////////////////////////////// +/** + * Sets the camera that is associated with this DisplayRegion. There is a + * one-to-many association between cameras and DisplayRegions; one camera may + * be shared by multiple DisplayRegions. + * + * The camera is actually set via a NodePath, which clarifies which instance + * of the camera (if there happen to be multiple instances) we should use. + */ void DisplayRegion:: set_camera(const NodePath &camera) { int pipeline_stage = Thread::get_current_pipeline_stage(); - // We allow set_camera(NodePath()) to happen in cleanup(), which can - // be called from any pipeline stage. + // We allow set_camera(NodePath()) to happen in cleanup(), which can be + // called from any pipeline stage. nassertv(pipeline_stage == 0 || camera.is_empty()); CDStageWriter cdata(_cycler, 0); @@ -190,10 +161,9 @@ set_camera(const NodePath &camera) { } if (camera_node != cdata->_camera_node) { - // Note that these operations on the DisplayRegion are not - // pipelined: they operate across all pipeline stages. Since we - // have already asserted we are running in pipeline stage 0, no - // problem. + // Note that these operations on the DisplayRegion are not pipelined: they + // operate across all pipeline stages. Since we have already asserted we + // are running in pipeline stage 0, no problem. if (cdata->_camera_node != (Camera *)NULL) { // We need to tell the old camera we're not using him anymore. cdata->_camera_node->remove_display_region(this); @@ -208,13 +178,10 @@ set_camera(const NodePath &camera) { cdata->_camera = camera; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_active -// Access: Published, Virtual -// Description: Sets the active flag associated with the -// DisplayRegion. If the DisplayRegion is marked -// inactive, nothing is rendered. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag associated with the DisplayRegion. If the + * DisplayRegion is marked inactive, nothing is rendered. + */ void DisplayRegion:: set_active(bool active) { int pipeline_stage = Thread::get_current_pipeline_stage(); @@ -228,14 +195,11 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_sort -// Access: Published, Virtual -// Description: Sets the sort value associated with the -// DisplayRegion. Within a window, DisplayRegions will -// be rendered in order from the lowest sort value to -// the highest. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sort value associated with the DisplayRegion. Within a window, + * DisplayRegions will be rendered in order from the lowest sort value to the + * highest. + */ void DisplayRegion:: set_sort(int sort) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -248,40 +212,32 @@ set_sort(int sort) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_stereo_channel -// Access: Published, Virtual -// Description: Specifies whether the DisplayRegion represents the -// left or right channel of a stereo pair, or whether it -// is a normal, monocular image. This automatically -// adjusts the lens that is used to render to this -// DisplayRegion to its left or right eye, according to -// the lens's stereo properties. -// -// When the DisplayRegion is attached to a stereo window -// (one for which is_stereo() returns true), this also -// specifies which physical channel the DisplayRegion -// renders to. -// -// Normally you would create at least two DisplayRegions -// for a stereo window, one for each of the left and -// right channels. The two DisplayRegions may share the -// same camera (and thus the same lens); this parameter -// is used to control the exact properties of the lens -// when it is used to render into this DisplayRegion. -// -// Also see the StereoDisplayRegion, which automates -// managing a pair of left/right DisplayRegions. -// -// An ordinary DisplayRegion may be set to SC_mono, -// SC_left, or SC_right. You may set SC_stereo only on -// a StereoDisplayRegion. -// -// This call also resets tex_view_offset to its default -// value, which is 0 for the left eye or 1 for the right -// eye of a stereo display region, or 0 for a mono -// display region. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the DisplayRegion represents the left or right channel of + * a stereo pair, or whether it is a normal, monocular image. This + * automatically adjusts the lens that is used to render to this DisplayRegion + * to its left or right eye, according to the lens's stereo properties. + * + * When the DisplayRegion is attached to a stereo window (one for which + * is_stereo() returns true), this also specifies which physical channel the + * DisplayRegion renders to. + * + * Normally you would create at least two DisplayRegions for a stereo window, + * one for each of the left and right channels. The two DisplayRegions may + * share the same camera (and thus the same lens); this parameter is used to + * control the exact properties of the lens when it is used to render into + * this DisplayRegion. + * + * Also see the StereoDisplayRegion, which automates managing a pair of + * left/right DisplayRegions. + * + * An ordinary DisplayRegion may be set to SC_mono, SC_left, or SC_right. You + * may set SC_stereo only on a StereoDisplayRegion. + * + * This call also resets tex_view_offset to its default value, which is 0 for + * the left eye or 1 for the right eye of a stereo display region, or 0 for a + * mono display region. + */ void DisplayRegion:: set_stereo_channel(Lens::StereoChannel stereo_channel) { nassertv(is_stereo() || stereo_channel != Lens::SC_stereo); @@ -293,20 +249,15 @@ set_stereo_channel(Lens::StereoChannel stereo_channel) { cdata->_tex_view_offset = (stereo_channel == Lens::SC_right) ? 1 : 0; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_tex_view_offset -// Access: Published, Virtual -// Description: Sets the current texture view offset for this -// DisplayRegion. This is normally set to zero. If -// nonzero, it is used to select a particular view of -// any multiview textures that are rendered within this -// DisplayRegion. -// -// For a StereoDisplayRegion, this is normally 0 for the -// left eye, and 1 for the right eye, to support stereo -// textures. This is set automatically when you call -// set_stereo_channel(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the current texture view offset for this DisplayRegion. This is + * normally set to zero. If nonzero, it is used to select a particular view + * of any multiview textures that are rendered within this DisplayRegion. + * + * For a StereoDisplayRegion, this is normally 0 for the left eye, and 1 for + * the right eye, to support stereo textures. This is set automatically when + * you call set_stereo_channel(). + */ void DisplayRegion:: set_tex_view_offset(int tex_view_offset) { nassertv(Thread::get_current_pipeline_stage() == 0); @@ -315,70 +266,53 @@ set_tex_view_offset(int tex_view_offset) { cdata->_tex_view_offset = tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_incomplete_render -// Access: Published, Virtual -// Description: Sets the incomplete_render flag. When this is -// true, the frame will be rendered even if some of the -// geometry or textures in the scene are not available -// (e.g. they have been temporarily paged out). When -// this is false, the frame will be held up while this -// data is reloaded. -// -// This flag may also be set on the -// GraphicsStateGuardian. It will be considered true -// for a given DisplayRegion only if it is true on both -// the GSG and on the DisplayRegion. -// -// See GraphicsStateGuardian::set_incomplete_render() -// for more detail. -//////////////////////////////////////////////////////////////////// +/** + * Sets the incomplete_render flag. When this is true, the frame will be + * rendered even if some of the geometry or textures in the scene are not + * available (e.g. they have been temporarily paged out). When this is + * false, the frame will be held up while this data is reloaded. + * + * This flag may also be set on the GraphicsStateGuardian. It will be + * considered true for a given DisplayRegion only if it is true on both the + * GSG and on the DisplayRegion. + * + * See GraphicsStateGuardian::set_incomplete_render() for more detail. + */ void DisplayRegion:: set_incomplete_render(bool incomplete_render) { _incomplete_render = incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_texture_reload_priority -// Access: Published, Virtual -// Description: Specifies an integer priority which is assigned to -// any asynchronous texture reload requests spawned -// while processing this DisplayRegion. This controls -// which textures are loaded first when multiple -// textures need to be reloaded at once; it also -// controls the relative priority between asynchronous -// texture loads and asynchronous model or animation -// loads. -// -// Specifying a larger number here makes the textures -// rendered by this DisplayRegion load up first. This -// may be particularly useful to do, for instance, for -// the DisplayRegion that renders the gui. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an integer priority which is assigned to any asynchronous texture + * reload requests spawned while processing this DisplayRegion. This controls + * which textures are loaded first when multiple textures need to be reloaded + * at once; it also controls the relative priority between asynchronous + * texture loads and asynchronous model or animation loads. + * + * Specifying a larger number here makes the textures rendered by this + * DisplayRegion load up first. This may be particularly useful to do, for + * instance, for the DisplayRegion that renders the gui. + */ void DisplayRegion:: set_texture_reload_priority(int texture_reload_priority) { _texture_reload_priority = texture_reload_priority; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_cull_traverser -// Access: Published, Virtual -// Description: Specifies the CullTraverser that will be used to draw -// the contents of this DisplayRegion. Normally the -// default CullTraverser is sufficient, but this may be -// changed to change the default cull behavior. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the CullTraverser that will be used to draw the contents of this + * DisplayRegion. Normally the default CullTraverser is sufficient, but this + * may be changed to change the default cull behavior. + */ void DisplayRegion:: set_cull_traverser(CullTraverser *trav) { _trav = trav; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_cull_traverser -// Access: Published -// Description: Returns the CullTraverser that will be used to draw -// the contents of this DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CullTraverser that will be used to draw the contents of this + * DisplayRegion. + */ CullTraverser *DisplayRegion:: get_cull_traverser() { if (_trav == (CullTraverser *)NULL) { @@ -387,23 +321,18 @@ get_cull_traverser() { return _trav; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_target_tex_page -// Access: Published, Virtual -// Description: This is a special parameter that is only used when -// rendering the faces of a cube map or multipage and/or -// multiview texture. -// -// This sets up the DisplayRegion to render to the ith -// page and jth view of its associated texture(s); the -// value must be consistent with the range of values -// availble to the texture. A normal DisplayRegion that -// is not associated with any particular page should be -// set to page -1 and view 0. -// -// This is particularly useful when rendering cube maps -// and/or stereo textures. -//////////////////////////////////////////////////////////////////// +/** + * This is a special parameter that is only used when rendering the faces of a + * cube map or multipage and/or multiview texture. + * + * This sets up the DisplayRegion to render to the ith page and jth view of + * its associated texture(s); the value must be consistent with the range of + * values availble to the texture. A normal DisplayRegion that is not + * associated with any particular page should be set to page -1 and view 0. + * + * This is particularly useful when rendering cube maps and/or stereo + * textures. + */ void DisplayRegion:: set_target_tex_page(int page) { int pipeline_stage = Thread::get_current_pipeline_stage(); @@ -412,11 +341,9 @@ set_target_tex_page(int page) { cdata->_target_tex_page = page; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayRegion:: output(ostream &out) const { CDReader cdata(_cycler); @@ -424,22 +351,15 @@ output(ostream &out) const { << ")=pixels(" << cdata->_regions[0]._pixels << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::make_screenshot_filename -// Access: Published, Static -// Description: Synthesizes a suitable default filename for passing -// to save_screenshot(). -// -// The default filename is generated from the supplied -// prefix and from the Config variable -// screenshot-filename, which contains the following -// strings: -// -// %~p - the supplied prefix -// %~f - the frame count -// %~e - the value of screenshot-extension -// All other % strings in strftime(). -//////////////////////////////////////////////////////////////////// +/** + * Synthesizes a suitable default filename for passing to save_screenshot(). + * + * The default filename is generated from the supplied prefix and from the + * Config variable screenshot-filename, which contains the following strings: + * + * %~p - the supplied prefix %~f - the frame count %~e - the value of + * screenshot-extension All other % strings in strftime(). + */ Filename DisplayRegion:: make_screenshot_filename(const string &prefix) { time_t now = time(NULL); @@ -502,14 +422,11 @@ make_screenshot_filename(const string &prefix) { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::save_screenshot_default -// Access: Published -// Description: Saves a screenshot of the region to a default -// filename, and returns the filename, or empty string -// if the screenshot failed. The filename is generated -// by make_screenshot_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Saves a screenshot of the region to a default filename, and returns the + * filename, or empty string if the screenshot failed. The filename is + * generated by make_screenshot_filename(). + */ Filename DisplayRegion:: save_screenshot_default(const string &prefix) { Filename filename = make_screenshot_filename(prefix); @@ -519,12 +436,10 @@ save_screenshot_default(const string &prefix) { return Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::save_screenshot -// Access: Published -// Description: Saves a screenshot of the region to the indicated -// filename. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Saves a screenshot of the region to the indicated filename. Returns true + * on success, false on failure. + */ bool DisplayRegion:: save_screenshot(const Filename &filename, const string &image_comment) { PNMImage image; @@ -539,13 +454,10 @@ save_screenshot(const Filename &filename, const string &image_comment) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_screenshot -// Access: Published -// Description: Captures the most-recently rendered image from the -// framebuffer into the indicated PNMImage. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Captures the most-recently rendered image from the framebuffer into the + * indicated PNMImage. Returns true on success, false on failure. + */ bool DisplayRegion:: get_screenshot(PNMImage &image) { PT(Texture) tex = get_screenshot(); @@ -553,69 +465,60 @@ get_screenshot(PNMImage &image) { if (tex == NULL) { return false; } - + if (!tex->store(image)) { return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_screenshot -// Access: Published -// Description: Captures the most-recently rendered image from the -// framebuffer and returns it as a Texture, or NULL -// on failure. -//////////////////////////////////////////////////////////////////// +/** + * Captures the most-recently rendered image from the framebuffer and returns + * it as a Texture, or NULL on failure. + */ PT(Texture) DisplayRegion:: get_screenshot() { Thread *current_thread = Thread::get_current_thread(); GraphicsOutput *window = get_window(); nassertr(window != (GraphicsOutput *)NULL, NULL); - + GraphicsStateGuardian *gsg = window->get_gsg(); nassertr(gsg != (GraphicsStateGuardian *)NULL, NULL); - + if (!window->begin_frame(GraphicsOutput::FM_refresh, current_thread)) { return NULL; } PT(Texture) tex = new Texture; - + RenderBuffer buffer = gsg->get_render_buffer(get_screenshot_buffer_type(), _window->get_fb_properties()); if (!gsg->framebuffer_copy_to_ram(tex, 0, -1, this, buffer)) { return NULL; } - + window->end_frame(GraphicsOutput::FM_refresh, current_thread); - + return tex; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::make_cull_result_graph -// Access: Published -// Description: Returns a special scene graph constructed to -// represent the results of the last frame's cull -// operation. -// -// This will be a hierarchy of nodes, one node for each -// bin, each of which will in term be a parent of a -// number of GeomNodes, representing the geometry drawn -// in each bin. -// -// This is useful mainly for high-level debugging and -// abstraction tools; it should not be mistaken for the -// low-level cull result itself, which is constructed -// and maintained internally. No such scene graph is -// normally constructed during the rendering of a frame; -// this is an artificial construct created for the -// purpose of making it easy to analyze the results of -// the cull operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special scene graph constructed to represent the results of the + * last frame's cull operation. + * + * This will be a hierarchy of nodes, one node for each bin, each of which + * will in term be a parent of a number of GeomNodes, representing the + * geometry drawn in each bin. + * + * This is useful mainly for high-level debugging and abstraction tools; it + * should not be mistaken for the low-level cull result itself, which is + * constructed and maintained internally. No such scene graph is normally + * constructed during the rendering of a frame; this is an artificial + * construct created for the purpose of making it easy to analyze the results + * of the cull operation. + */ PT(PandaNode) DisplayRegion:: make_cull_result_graph() { CullResult *cull_result = get_cull_result(Thread::get_current_thread()); @@ -625,31 +528,25 @@ make_cull_result_graph() { return cull_result->make_result_graph(); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::compute_pixels -// Access: Public -// Description: Computes the pixel locations of the DisplayRegion -// within its window. The DisplayRegion will request -// the size from the window. -//////////////////////////////////////////////////////////////////// +/** + * Computes the pixel locations of the DisplayRegion within its window. The + * DisplayRegion will request the size from the window. + */ void DisplayRegion:: compute_pixels() { if (_window != (GraphicsOutput *)NULL) { CDWriter cdata(_cycler, false); for (size_t i = 0; i < cdata->_regions.size(); ++i) { - do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), + do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::compute_pixels_all_stages -// Access: Public -// Description: Computes the pixel locations of the DisplayRegion -// within its window. The DisplayRegion will request -// the size from the window. -//////////////////////////////////////////////////////////////////// +/** + * Computes the pixel locations of the DisplayRegion within its window. The + * DisplayRegion will request the size from the window. + */ void DisplayRegion:: compute_pixels_all_stages() { int pipeline_stage = Thread::get_current_pipeline_stage(); @@ -659,7 +556,7 @@ compute_pixels_all_stages() { OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); for (size_t i = 0; i < cdata->_regions.size(); ++i) { - do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), + do_compute_pixels(i, _window->get_fb_x_size(), _window->get_fb_y_size(), cdata); } } @@ -667,13 +564,10 @@ compute_pixels_all_stages() { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::compute_pixels -// Access: Public -// Description: Computes the pixel locations of the DisplayRegion -// within its window, given the size of the window in -// pixels. -//////////////////////////////////////////////////////////////////// +/** + * Computes the pixel locations of the DisplayRegion within its window, given + * the size of the window in pixels. + */ void DisplayRegion:: compute_pixels(int x_size, int y_size) { CDWriter cdata(_cycler, false); @@ -682,15 +576,12 @@ compute_pixels(int x_size, int y_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::compute_pixels_all_stages -// Access: Public -// Description: Performs a compute_pixels() operation for all stages -// of the pipeline. This is appropriate, for instance, -// when a window changes sizes, since this is a global -// operation; and you want the new window size to be -// immediately available even to the downstream stages. -//////////////////////////////////////////////////////////////////// +/** + * Performs a compute_pixels() operation for all stages of the pipeline. This + * is appropriate, for instance, when a window changes sizes, since this is a + * global operation; and you want the new window size to be immediately + * available even to the downstream stages. + */ void DisplayRegion:: compute_pixels_all_stages(int x_size, int y_size) { OPEN_ITERATE_ALL_STAGES(_cycler) { @@ -698,24 +589,20 @@ compute_pixels_all_stages(int x_size, int y_size) { for (size_t i = 0; i < cdata->_regions.size(); ++i) { do_compute_pixels(i, x_size, y_size, cdata); } - } + } CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::supports_pixel_zoom -// Access: Public, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool DisplayRegion:: supports_pixel_zoom() const { if (_window != (GraphicsOutput *)NULL) { @@ -726,15 +613,11 @@ supports_pixel_zoom() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::win_display_regions_changed -// Access: Private -// Description: Intended to be called when the active state on a -// nested channel or layer or display region changes, -// forcing the window to recompute its list of active -// display regions. It is assumed the lock is already -// held. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called when the active state on a nested channel or layer or + * display region changes, forcing the window to recompute its list of active + * display regions. It is assumed the lock is already held. + */ void DisplayRegion:: win_display_regions_changed() { if (_window != (GraphicsOutput *)NULL) { @@ -742,12 +625,10 @@ win_display_regions_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::do_compute_pixels -// Access: Private -// Description: The private implementation of compute_pixels, this -// assumes that we already have the lock. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of compute_pixels, this assumes that we already + * have the lock. + */ void DisplayRegion:: do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { if (display_cat.is_debug()) { @@ -782,18 +663,14 @@ do_compute_pixels(int i, int x_size, int y_size, CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::set_active_index -// Access: Private -// Description: This is called by GraphicsOutput to indicate that the -// index of this DisplayRegion within the window's list -// of active DisplayRegions might have changed. The -// index number will be -1 if the DisplayRegion is not -// active. -// -// This is primarily intended only for updating the -// PStatCollector name appropriately. -//////////////////////////////////////////////////////////////////// +/** + * This is called by GraphicsOutput to indicate that the index of this + * DisplayRegion within the window's list of active DisplayRegions might have + * changed. The index number will be -1 if the DisplayRegion is not active. + * + * This is primarily intended only for updating the PStatCollector name + * appropriately. + */ void DisplayRegion:: set_active_index(int index) { #ifdef DO_PSTATS @@ -806,12 +683,10 @@ set_active_index(int index) { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::do_cull -// Access: Protected, Virtual -// Description: Performs a cull traversal. The default -// implementation simply calls GraphicsEngine::do_cull. -//////////////////////////////////////////////////////////////////// +/** + * Performs a cull traversal. The default implementation simply calls + * GraphicsEngine::do_cull. + */ void DisplayRegion:: do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg, Thread *current_thread) { @@ -819,11 +694,9 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsEngine::do_cull(cull_handler, scene_setup, gsg, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegion::CData:: CData() : _lens_index(0), @@ -838,11 +711,9 @@ CData() : _regions.push_back(Region()); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegion::CData:: CData(const DisplayRegion::CData ©) : _regions(copy._regions), @@ -858,33 +729,26 @@ CData(const DisplayRegion::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *DisplayRegion::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::CDataCull::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *DisplayRegion::CDataCull:: make_copy() const { return new CDataCull(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionPipelineReader::get_pipe -// Access: Public -// Description: Returns the GraphicsPipe that this DisplayRegion is -// ultimately associated with, or NULL if no pipe is -// associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsPipe that this DisplayRegion is ultimately associated + * with, or NULL if no pipe is associated. + */ GraphicsPipe *DisplayRegionPipelineReader:: get_pipe() const { return (_object->_window != (GraphicsOutput *)NULL) ? _object->_window->get_pipe() : NULL; diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index 588d122acc..742cf22bd4 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -1,16 +1,15 @@ -// Filename: displayRegion.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegion.h + * @author mike + * @date 1997-01-09 + */ #ifndef DISPLAYREGION_H #define DISPLAYREGION_H @@ -47,17 +46,14 @@ class Camera; class PNMImage; class CullTraverser; -//////////////////////////////////////////////////////////////////// -// Class : DisplayRegion -// Description : A rectangular subregion within a window for rendering -// into. Typically, there is one DisplayRegion that -// covers the whole window, but you may also create -// smaller DisplayRegions for having different regions -// within the window that represent different scenes. -// You may also stack up DisplayRegions like panes of -// glass, usually for layering 2-d interfaces on top of -// a 3-d scene. -//////////////////////////////////////////////////////////////////// +/** + * A rectangular subregion within a window for rendering into. Typically, + * there is one DisplayRegion that covers the whole window, but you may also + * create smaller DisplayRegions for having different regions within the + * window that represent different scenes. You may also stack up + * DisplayRegions like panes of glass, usually for layering 2-d interfaces on + * top of a 3-d scene. + */ class EXPCL_PANDA_DISPLAY DisplayRegion : public DisplayRegionBase, public DrawableRegion { protected: DisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions); @@ -211,8 +207,8 @@ protected: GraphicsStateGuardian *gsg, Thread *current_thread); protected: - // The associated window is a permanent property of the - // DisplayRegion. It doesn't need to be cycled. + // The associated window is a permanent property of the DisplayRegion. It + // doesn't need to be cycled. GraphicsOutput *_window; bool _incomplete_render; @@ -222,10 +218,9 @@ protected: PT(CullTraverser) _trav; private: - // This is the data that is associated with the DisplayRegion that - // needs to be cycled every frame, but represents the parameters as - // specified by the user, and which probably will not change that - // often. + // This is the data that is associated with the DisplayRegion that needs to + // be cycled every frame, but represents the parameters as specified by the + // user, and which probably will not change that often. class EXPCL_PANDA_DISPLAY CData : public CycleData { public: CData(); @@ -260,12 +255,11 @@ private: typedef CycleDataWriter CDWriter; typedef CycleDataStageWriter CDStageWriter; - // This is a special cycler created to hold the results from the - // cull traversal, for (a) the draw traversal, and (b) the next - // frame's cull traversal. It needs to be cycled, but it gets its - // own cycler because it will certainly change every frame, so we - // don't need to lump all the heavy data above in with this - // lightweight cycler. + // This is a special cycler created to hold the results from the cull + // traversal, for (a) the draw traversal, and (b) the next frame's cull + // traversal. It needs to be cycled, but it gets its own cycler because it + // will certainly change every frame, so we don't need to lump all the heavy + // data above in with this lightweight cycler. class EXPCL_PANDA_DISPLAY CDataCull : public CycleData { public: CDataCull(); @@ -309,11 +303,10 @@ private: friend class DisplayRegionPipelineReader; }; -//////////////////////////////////////////////////////////////////// -// Class : DisplayRegionPipelineReader -// Description : Encapsulates the data from a DisplayRegion, -// pre-fetched for one stage of the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a DisplayRegion, pre-fetched for one stage of + * the pipeline. + */ class EXPCL_PANDA_DISPLAY DisplayRegionPipelineReader { public: INLINE DisplayRegionPipelineReader(DisplayRegion *object, Thread *current_thread); diff --git a/panda/src/display/displayRegionCullCallbackData.I b/panda/src/display/displayRegionCullCallbackData.I index d21771edec..0f862e00e2 100644 --- a/panda/src/display/displayRegionCullCallbackData.I +++ b/panda/src/display/displayRegionCullCallbackData.I @@ -1,35 +1,29 @@ -// Filename: displayRegionCullCallbackData.I -// Created by: drose (14Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionCullCallbackData.I + * @author drose + * @date 2009-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionCullCallbackData::get_cull_handler -// Access: Published -// Description: Returns a pointer to the CullHandler, which accepts -// each object to be added to the list for drawing. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the CullHandler, which accepts each object to be added + * to the list for drawing. + */ INLINE CullHandler *DisplayRegionCullCallbackData:: get_cull_handler() const { return _cull_handler; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionCullCallbackData::get_scene_setup -// Access: Published -// Description: Returns a pointer to the SceneSetup object, which -// contains information about the camera and such. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the SceneSetup object, which contains information + * about the camera and such. + */ INLINE SceneSetup *DisplayRegionCullCallbackData:: get_scene_setup() const { return _scene_setup; diff --git a/panda/src/display/displayRegionCullCallbackData.cxx b/panda/src/display/displayRegionCullCallbackData.cxx index daf85e3ad0..39268fbabe 100644 --- a/panda/src/display/displayRegionCullCallbackData.cxx +++ b/panda/src/display/displayRegionCullCallbackData.cxx @@ -1,16 +1,15 @@ -// Filename: displayRegionCullCallbackData.cxx -// Created by: drose (14Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionCullCallbackData.cxx + * @author drose + * @date 2009-03-14 + */ #include "displayRegionCullCallbackData.h" #include "cullHandler.h" @@ -20,11 +19,9 @@ TypeHandle DisplayRegionCullCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionCullCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegionCullCallbackData:: DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup) : _cull_handler(cull_handler), @@ -32,28 +29,24 @@ DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionCullCallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayRegionCullCallbackData:: output(ostream &out) const { - out << get_type() << "(" << (void *)_cull_handler << ", " + out << get_type() << "(" << (void *)_cull_handler << ", " << (void *)_scene_setup << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionCullCallbackData::upcall -// Access: Published, Virtual -// Description: You should make this call during the callback if you -// want to continue the normal rendering function that -// would have been done in the absence of a callback. -// -// Specifically, this method will perform the cull -// traversal for the DisplayRegion's scene graph, and -// add all renderable objects to its CullResult. -//////////////////////////////////////////////////////////////////// +/** + * You should make this call during the callback if you want to continue the + * normal rendering function that would have been done in the absence of a + * callback. + * + * Specifically, this method will perform the cull traversal for the + * DisplayRegion's scene graph, and add all renderable objects to its + * CullResult. + */ void DisplayRegionCullCallbackData:: upcall() { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/display/displayRegionCullCallbackData.h b/panda/src/display/displayRegionCullCallbackData.h index 0e18ed8406..509f5e2e2c 100644 --- a/panda/src/display/displayRegionCullCallbackData.h +++ b/panda/src/display/displayRegionCullCallbackData.h @@ -1,16 +1,15 @@ -// Filename: displayRegionCullCallbackData.h -// Created by: drose (14Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionCullCallbackData.h + * @author drose + * @date 2009-03-14 + */ #ifndef DISPLAYREGIONCULLCALLBACKDATA_H #define DISPLAYREGIONCULLCALLBACKDATA_H @@ -21,12 +20,10 @@ class CullHandler; class SceneSetup; -//////////////////////////////////////////////////////////////////// -// Class : DisplayRegionCullCallbackData -// Description : This specialization on CallbackData is passed when -// the callback is initiated from the cull traversal, -// for a DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on CallbackData is passed when the callback is + * initiated from the cull traversal, for a DisplayRegion. + */ class EXPCL_PANDA_PGRAPH DisplayRegionCullCallbackData : public CallbackData { public: DisplayRegionCullCallbackData(CullHandler *cull_handler, SceneSetup *scene_setup); diff --git a/panda/src/display/displayRegionDrawCallbackData.I b/panda/src/display/displayRegionDrawCallbackData.I index dfccf90685..741a6f3614 100644 --- a/panda/src/display/displayRegionDrawCallbackData.I +++ b/panda/src/display/displayRegionDrawCallbackData.I @@ -1,36 +1,29 @@ -// Filename: displayRegionDrawCallbackData.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionDrawCallbackData.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionDrawCallbackData::get_cull_result -// Access: Published -// Description: Returns a pointer to the CullResult, the list of -// CullableObjects that should be drawn in this -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the CullResult, the list of CullableObjects that + * should be drawn in this DisplayRegion. + */ INLINE CullResult *DisplayRegionDrawCallbackData:: get_cull_result() const { return _cull_result; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionDrawCallbackData::get_scene_setup -// Access: Published -// Description: Returns a pointer to the SceneSetup object, which -// contains information about the camera and such. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the SceneSetup object, which contains information + * about the camera and such. + */ INLINE SceneSetup *DisplayRegionDrawCallbackData:: get_scene_setup() const { return _scene_setup; diff --git a/panda/src/display/displayRegionDrawCallbackData.cxx b/panda/src/display/displayRegionDrawCallbackData.cxx index 07e2242463..e0ecfcbffb 100644 --- a/panda/src/display/displayRegionDrawCallbackData.cxx +++ b/panda/src/display/displayRegionDrawCallbackData.cxx @@ -1,16 +1,15 @@ -// Filename: displayRegionDrawCallbackData.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionDrawCallbackData.cxx + * @author drose + * @date 2009-03-13 + */ #include "displayRegionDrawCallbackData.h" @@ -24,11 +23,9 @@ TypeHandle DisplayRegionDrawCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionDrawCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegionDrawCallbackData:: DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup) : _cull_result(cull_result), @@ -36,28 +33,24 @@ DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup) { } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionDrawCallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplayRegionDrawCallbackData:: output(ostream &out) const { - out << get_type() << "(" << (void *)_cull_result << ", " + out << get_type() << "(" << (void *)_cull_result << ", " << (void *)_scene_setup << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionDrawCallbackData::upcall -// Access: Published, Virtual -// Description: You should make this call during the callback if you -// want to continue the normal rendering function that -// would have been done in the absence of a callback. -// -// Specifically, this method will draw all of the -// objects in the CullResult list that have been built -// up for the DisplayRegion during the cull traversal. -//////////////////////////////////////////////////////////////////// +/** + * You should make this call during the callback if you want to continue the + * normal rendering function that would have been done in the absence of a + * callback. + * + * Specifically, this method will draw all of the objects in the CullResult + * list that have been built up for the DisplayRegion during the cull + * traversal. + */ void DisplayRegionDrawCallbackData:: upcall() { Thread *current_thread = Thread::get_current_thread(); @@ -68,12 +61,11 @@ upcall() { // Nothing to see here. } else if (dr->is_stereo()) { - // We don't actually draw the stereo DisplayRegions. These are - // just placeholders; we draw the individual left and right eyes - // instead. (We might still clear the stereo DisplayRegions, - // though, since it's probably faster to clear right and left - // channels in one pass, than to clear them in two separate - // passes.) + // We don't actually draw the stereo DisplayRegions. These are just + // placeholders; we draw the individual left and right eyes instead. (We + // might still clear the stereo DisplayRegions, though, since it's + // probably faster to clear right and left channels in one pass, than to + // clear them in two separate passes.) } else if (!gsg->set_scene(_scene_setup)) { // The scene or lens is inappropriate somehow. @@ -90,4 +82,3 @@ upcall() { } } } - diff --git a/panda/src/display/displayRegionDrawCallbackData.h b/panda/src/display/displayRegionDrawCallbackData.h index 8b7b39b2da..55f76baf2e 100644 --- a/panda/src/display/displayRegionDrawCallbackData.h +++ b/panda/src/display/displayRegionDrawCallbackData.h @@ -1,16 +1,15 @@ -// Filename: displayRegionDrawCallbackData.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionDrawCallbackData.h + * @author drose + * @date 2009-03-13 + */ #ifndef DISPLAYREGIONDRAWCALLBACKDATA_H #define DISPLAYREGIONDRAWCALLBACKDATA_H @@ -21,12 +20,10 @@ class CullResult; class SceneSetup; -//////////////////////////////////////////////////////////////////// -// Class : DisplayRegionDrawCallbackData -// Description : This specialization on CallbackData is passed when -// the callback is initiated from the draw traversal, -// for a DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on CallbackData is passed when the callback is + * initiated from the draw traversal, for a DisplayRegion. + */ class EXPCL_PANDA_PGRAPH DisplayRegionDrawCallbackData : public CallbackData { public: DisplayRegionDrawCallbackData(CullResult *cull_result, SceneSetup *scene_setup); diff --git a/panda/src/display/displaySearchParameters.cxx b/panda/src/display/displaySearchParameters.cxx index 16297825cb..d1b3d0d1ba 100644 --- a/panda/src/display/displaySearchParameters.cxx +++ b/panda/src/display/displaySearchParameters.cxx @@ -1,34 +1,29 @@ -// Filename: displaySearchParameters.cxx -// Created by: aignacio (17Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displaySearchParameters.cxx + * @author aignacio + * @date 2007-01-17 + */ #include "displaySearchParameters.h" -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplaySearchParameters:: ~DisplaySearchParameters() { } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplaySearchParameters:: DisplaySearchParameters() { _minimum_width = 640; @@ -39,61 +34,49 @@ DisplaySearchParameters() { _maximum_bits_per_pixel = 32; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_minimum_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_minimum_width (int minimum_width) { _minimum_width = minimum_width; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_maximum_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_maximum_width (int maximum_width) { _maximum_width = maximum_width; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_minimum_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_minimum_height (int minimum_height) { _minimum_height = minimum_height; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_maximum_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_maximum_height (int maximum_height) { _maximum_height = maximum_height; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_minimum_bits_per_pixel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_minimum_bits_per_pixel (int minimum_bits_per_pixel) { _minimum_bits_per_pixel = minimum_bits_per_pixel; } -//////////////////////////////////////////////////////////////////// -// Function: DisplaySearchParameters::set_maximum_bits_per_pixel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DisplaySearchParameters:: set_maximum_bits_per_pixel (int maximum_bits_per_pixel) { _maximum_bits_per_pixel = maximum_bits_per_pixel; diff --git a/panda/src/display/displaySearchParameters.h b/panda/src/display/displaySearchParameters.h index bb4e397c02..de9b5cecde 100644 --- a/panda/src/display/displaySearchParameters.h +++ b/panda/src/display/displaySearchParameters.h @@ -1,26 +1,24 @@ -// Filename: displaySearchParameters.h -// Created by: aignacio (17Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displaySearchParameters.h + * @author aignacio + * @date 2007-01-17 + */ #ifndef DISPLAYSEARCHPARAMETERS_H #define DISPLAYSEARCHPARAMETERS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : DisplaySearchParameters -// Description : Parameters used for searching display capabilities. -//////////////////////////////////////////////////////////////////// +/** + * Parameters used for searching display capabilities. + */ class EXPCL_PANDA_DISPLAY DisplaySearchParameters { PUBLISHED: diff --git a/panda/src/display/drawableRegion.I b/panda/src/display/drawableRegion.I index 6383b5a40f..b7bf511df6 100644 --- a/panda/src/display/drawableRegion.I +++ b/panda/src/display/drawableRegion.I @@ -1,23 +1,19 @@ -// Filename: drawableRegion.I -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawableRegion.I + * @author drose + * @date 2002-07-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DrawableRegion:: DrawableRegion() : _screenshot_buffer_type(RenderBuffer::T_front), @@ -32,11 +28,9 @@ DrawableRegion() : _pixel_factor = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DrawableRegion:: DrawableRegion(const DrawableRegion ©) : _screenshot_buffer_type(copy._screenshot_buffer_type), @@ -50,11 +44,9 @@ DrawableRegion(const DrawableRegion ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DrawableRegion:: operator = (const DrawableRegion ©) { _screenshot_buffer_type = copy._screenshot_buffer_type; @@ -67,12 +59,9 @@ operator = (const DrawableRegion ©) { _pixel_factor = copy._pixel_factor; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::copy_clear_settings -// Access: Public -// Description: Copies only the clear settings from the other drawable -// region. -//////////////////////////////////////////////////////////////////// +/** + * Copies only the clear settings from the other drawable region. + */ INLINE void DrawableRegion:: copy_clear_settings(const DrawableRegion ©) { for (int i=0; i= 0)&&(n < RTP_COUNT)); @@ -37,33 +32,27 @@ set_clear_active(int n, bool clear_active) { update_pixel_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::get_clear_active -// Access: Published, Virtual -// Description: Gets the clear-active flag for any bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Gets the clear-active flag for any bitplane. + */ bool DrawableRegion:: get_clear_active(int n) const { nassertr((n >= 0)&&(n < RTP_COUNT), false); return _clear_active[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::set_clear_value -// Access: Published, Virtual -// Description: Sets the clear value for any bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Sets the clear value for any bitplane. + */ void DrawableRegion:: set_clear_value(int n, const LColor &clear_value) { nassertv((n >= 0) && (n < RTP_COUNT)); _clear_value[n] = clear_value; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::get_clear_value -// Access: Published, Virtual -// Description: Returns the clear value for any bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Returns the clear value for any bitplane. + */ const LColor &DrawableRegion:: get_clear_value(int n) const { static LColor blank(0.5,0.5,0.5,0.0); @@ -71,12 +60,10 @@ get_clear_value(int n) const { return _clear_value[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::disable_clears -// Access: Published, Virtual -// Description: Disables both the color and depth clear. See -// set_clear_color_active and set_clear_depth_active. -//////////////////////////////////////////////////////////////////// +/** + * Disables both the color and depth clear. See set_clear_color_active and + * set_clear_depth_active. + */ void DrawableRegion:: disable_clears() { for (int i = 0; i < RTP_COUNT; ++i) { @@ -85,14 +72,11 @@ disable_clears() { update_pixel_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::is_any_clear_active -// Access: Published, Virtual -// Description: Returns true if any of the clear types (so far there -// are just color or depth) have been set active, or -// false if none of them are active and there is no need -// to clear. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the clear types (so far there are just color or + * depth) have been set active, or false if none of them are active and there + * is no need to clear. + */ bool DrawableRegion:: is_any_clear_active() const { for (int i = 0; i < RTP_COUNT; ++i) { @@ -103,63 +87,48 @@ is_any_clear_active() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::set_pixel_zoom -// Access: Published, Virtual -// Description: Sets the amount by which the pixels of the region are -// scaled internally when filling the image interally. -// Setting this number larger makes the pixels blockier, -// but may make the rendering faster, particularly for -// software renderers. Setting this number to 2.0 -// reduces the number of pixels that have to be filled -// by the renderer by a factor of 2.0. It doesn't make -// sense to set this lower than 1.0. -// -// It is possible to set this on either individual -// DisplayRegions or on overall GraphicsWindows, but you -// will get better performance for setting it on the -// window rather than its individual DisplayRegions. -// Also, you may not set it on a DisplayRegion that -// doesn't have both clear_color() and clear_depth() -// enabled. -// -// This property is only supported on renderers for -// which it is particularly useful--currently, this is -// the tinydisplay software renderer. Other kinds of -// renderers allow you to set this property, but ignore -// it. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount by which the pixels of the region are scaled internally + * when filling the image interally. Setting this number larger makes the + * pixels blockier, but may make the rendering faster, particularly for + * software renderers. Setting this number to 2.0 reduces the number of + * pixels that have to be filled by the renderer by a factor of 2.0. It + * doesn't make sense to set this lower than 1.0. + * + * It is possible to set this on either individual DisplayRegions or on + * overall GraphicsWindows, but you will get better performance for setting it + * on the window rather than its individual DisplayRegions. Also, you may not + * set it on a DisplayRegion that doesn't have both clear_color() and + * clear_depth() enabled. + * + * This property is only supported on renderers for which it is particularly + * useful--currently, this is the tinydisplay software renderer. Other kinds + * of renderers allow you to set this property, but ignore it. + */ void DrawableRegion:: set_pixel_zoom(PN_stdfloat pixel_zoom) { _pixel_zoom = pixel_zoom; update_pixel_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::supports_pixel_zoom -// Access: Published, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool DrawableRegion:: supports_pixel_zoom() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::get_renderbuffer_type -// Access: Static, Published -// Description: Returns the RenderBuffer::Type that corresponds -// to a RenderTexturePlane. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderBuffer::Type that corresponds to a RenderTexturePlane. + */ int DrawableRegion:: get_renderbuffer_type(int rtp) { switch(rtp) { @@ -185,11 +154,9 @@ get_renderbuffer_type(int rtp) { }; } -//////////////////////////////////////////////////////////////////// -// Function: DrawableRegion::pixel_factor_changed -// Access: Protected, Virtual -// Description: Called internally when the pixel factor changes. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the pixel factor changes. + */ void DrawableRegion:: pixel_factor_changed() { } diff --git a/panda/src/display/drawableRegion.h b/panda/src/display/drawableRegion.h index f115c50839..10fafcf687 100644 --- a/panda/src/display/drawableRegion.h +++ b/panda/src/display/drawableRegion.h @@ -1,16 +1,15 @@ -// Filename: drawableRegion.h -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawableRegion.h + * @author drose + * @date 2002-07-11 + */ #ifndef DRAWABLEREGION_H #define DRAWABLEREGION_H @@ -20,16 +19,13 @@ #include "renderBuffer.h" #include "typedWritableReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : DrawableRegion -// Description : This is a base class for GraphicsWindow (actually, -// GraphicsOutput) and DisplayRegion, both of which are -// conceptually rectangular regions into which drawing -// commands may be issued. Sometimes you want to deal -// with a single display region, and sometimes you want -// to deal with the whole window at once, particularly -// for issuing clear commands and capturing screenshots. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for GraphicsWindow (actually, GraphicsOutput) and + * DisplayRegion, both of which are conceptually rectangular regions into + * which drawing commands may be issued. Sometimes you want to deal with a + * single display region, and sometimes you want to deal with the whole window + * at once, particularly for issuing clear commands and capturing screenshots. + */ class EXPCL_PANDA_DISPLAY DrawableRegion { public: INLINE DrawableRegion(); @@ -40,9 +36,9 @@ public: INLINE void copy_clear_settings(const DrawableRegion ©); PUBLISHED: - // It seems awkward to have this type, and also - // RenderBuffer::Type. However, the fact that RenderBuffer::Type - // is a bitmask makes it awfully awkward to work with. + // It seems awkward to have this type, and also RenderBuffer::Type. + // However, the fact that RenderBuffer::Type is a bitmask makes it awfully + // awkward to work with. enum RenderTexturePlane { RTP_stencil=0, RTP_depth_stencil=1, @@ -65,10 +61,10 @@ PUBLISHED: INLINE void set_clear_color_active(bool clear_color_active); INLINE bool get_clear_color_active() const; - + INLINE void set_clear_depth_active(bool clear_depth_active); INLINE bool get_clear_depth_active() const; - + INLINE void set_clear_stencil_active(bool clear_stencil_active); INLINE bool get_clear_stencil_active() const; @@ -89,7 +85,7 @@ PUBLISHED: virtual void set_clear_value(int n, const LColor &clear_value); virtual const LColor &get_clear_value(int n) const; - + virtual void disable_clears(); virtual bool is_any_clear_active() const; @@ -101,7 +97,7 @@ PUBLISHED: MAKE_PROPERTY(pixel_factor, get_pixel_factor); static int get_renderbuffer_type(int plane); - + public: INLINE int get_screenshot_buffer_type() const; INLINE int get_draw_buffer_type() const; diff --git a/panda/src/display/frameBufferProperties.I b/panda/src/display/frameBufferProperties.I index a6fc122af4..6f2d3257ee 100644 --- a/panda/src/display/frameBufferProperties.I +++ b/panda/src/display/frameBufferProperties.I @@ -1,93 +1,75 @@ -// Filename: frameBufferProperties.I -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameBufferProperties.I + * @author drose + * @date 2003-01-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FrameBufferProperties:: FrameBufferProperties(const FrameBufferProperties ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FrameBufferProperties:: ~FrameBufferProperties() { } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: operator != (const FrameBufferProperties &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::is_single_buffered -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: is_single_buffered() const { return (_property[FBP_back_buffers] == 0); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::is_stereo -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: is_stereo() const { return (_flags & FBF_stereo) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::operator << -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream & operator << (ostream &out, const FrameBufferProperties &properties) { properties.output(out); return out; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_depth_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_depth_bits() const { return _property[FBP_depth_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_color_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_color_bits() const { return max(_property[FBP_color_bits], @@ -96,241 +78,194 @@ get_color_bits() const { _property[FBP_blue_bits]); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_red_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_red_bits() const { return _property[FBP_red_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_green_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_green_bits() const { return _property[FBP_green_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_blue_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_blue_bits() const { return _property[FBP_blue_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_alpha_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_alpha_bits() const { return _property[FBP_alpha_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_stencil_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_stencil_bits() const { return _property[FBP_stencil_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_accum_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_accum_bits() const { return _property[FBP_accum_bits]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_aux_rgba -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_aux_rgba() const { return _property[FBP_aux_rgba]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_aux_hrgba -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_aux_hrgba() const { return _property[FBP_aux_hrgba]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_aux_float -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_aux_float() const { return _property[FBP_aux_float]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_multisamples -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_multisamples() const { return _property[FBP_multisamples]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_coverage_samples -// Access: Published -// Description: If coverage samples are specified, and there is -// hardware support, we use coverage multisampling. -//////////////////////////////////////////////////////////////////// +/** + * If coverage samples are specified, and there is hardware support, we use + * coverage multisampling. + */ INLINE int FrameBufferProperties:: get_coverage_samples() const { return _property[FBP_coverage_samples]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_back_buffers -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int FrameBufferProperties:: get_back_buffers() const { return _property[FBP_back_buffers]; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_indexed_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_indexed_color() const { return (_flags & FBF_indexed_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_rgb_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_rgb_color() const { return (_flags & FBF_rgb_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_stereo -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_stereo() const { return (_flags & FBF_stereo) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_force_hardware -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_force_hardware() const { return (_flags & FBF_force_hardware) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_force_software -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_force_software() const { return (_flags & FBF_force_software) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_srgb_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_srgb_color() const { return (_flags & FBF_srgb_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_float_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_float_color() const { return (_flags & FBF_float_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_float_depth -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool FrameBufferProperties:: get_float_depth() const { return (_flags & FBF_float_depth) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_depth_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_depth_bits(int n) { _property[FBP_depth_bits] = n; _specified |= (1 << FBP_depth_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_color_bits -// Access: Published -// Description: Sets the number of requested color bits as a single -// number that represents the sum of the individual -// numbers of red, green and blue bits. Panda won't -// care how the individual bits are divided up. -// -// See also set_rgba_bits, which allows you to specify -// requirements for the individual components. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of requested color bits as a single number that represents + * the sum of the individual numbers of red, green and blue bits. Panda won't + * care how the individual bits are divided up. + * + * See also set_rgba_bits, which allows you to specify requirements for the + * individual components. + */ INLINE void FrameBufferProperties:: set_color_bits(int n) { _property[FBP_color_bits] = n; _specified |= (1 << FBP_color_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_rgba_bits -// Access: Published -// Description: Convenience method for setting the red, green, blue -// and alpha bits in one go. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method for setting the red, green, blue and alpha bits in one + * go. + */ INLINE void FrameBufferProperties:: set_rgba_bits(int r, int g, int b, int a) { _property[FBP_red_bits] = r; @@ -343,77 +278,63 @@ set_rgba_bits(int r, int g, int b, int a) { (1 << FBP_alpha_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_red_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_red_bits(int n) { _property[FBP_red_bits] = n; _specified |= (1 << FBP_red_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_green_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_green_bits(int n) { _property[FBP_green_bits] = n; _specified |= (1 << FBP_green_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_blue_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_blue_bits(int n) { _property[FBP_blue_bits] = n; _specified |= (1 << FBP_blue_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_alpha_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_alpha_bits(int n) { _property[FBP_alpha_bits] = n; _specified |= (1 << FBP_alpha_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_stencil_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_stencil_bits(int n) { _property[FBP_stencil_bits] = n; _specified |= (1 << FBP_stencil_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_accum_bits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_accum_bits(int n) { _property[FBP_accum_bits] = n; _specified |= (1 << FBP_accum_bits); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_aux_rgba -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_aux_rgba(int n) { nassertv(n < 4); @@ -421,11 +342,9 @@ set_aux_rgba(int n) { _specified |= (1 << FBP_aux_rgba); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_aux_hrgba -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_aux_hrgba(int n) { nassertv(n < 4); @@ -433,11 +352,9 @@ set_aux_hrgba(int n) { _specified |= (1 << FBP_aux_hrgba); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_aux_float -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_aux_float(int n) { nassertv(n < 4); @@ -445,45 +362,37 @@ set_aux_float(int n) { _specified |= (1 << FBP_aux_float); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_multisamples -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_multisamples(int n) { _property[FBP_multisamples] = n; _specified |= (1 << FBP_multisamples); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_coverage_samples -// Access: Published -// Description: If coverage samples are specified, and there is -// hardware support, we use coverage multisampling -//////////////////////////////////////////////////////////////////// +/** + * If coverage samples are specified, and there is hardware support, we use + * coverage multisampling + */ INLINE void FrameBufferProperties:: set_coverage_samples(int n) { _property[FBP_coverage_samples] = n; _specified |= (1 << FBP_coverage_samples); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_back_buffers -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_back_buffers(int n) { _property[FBP_back_buffers] = n; _specified |= (1 << FBP_back_buffers); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_indexed_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_indexed_color(bool n) { if (n) { @@ -494,11 +403,9 @@ set_indexed_color(bool n) { _flags_specified |= FBF_indexed_color; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_rgb_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_rgb_color(bool n) { if (n) { @@ -509,11 +416,9 @@ set_rgb_color(bool n) { _flags_specified |= FBF_rgb_color; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_stereo -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_stereo(bool n) { if (n) { @@ -524,11 +429,9 @@ set_stereo(bool n) { _flags_specified |= FBF_stereo; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_force_hardware -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_force_hardware(bool n) { if (n) { @@ -539,11 +442,9 @@ set_force_hardware(bool n) { _flags_specified |= FBF_force_hardware; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_force_software -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_force_software(bool n) { if (n) { @@ -554,11 +455,9 @@ set_force_software(bool n) { _flags_specified |= FBF_force_software; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_srgb_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_srgb_color(bool n) { if (n) { @@ -569,11 +468,9 @@ set_srgb_color(bool n) { _flags_specified |= FBF_srgb_color; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_float_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_float_color(bool n) { if (n) { @@ -584,11 +481,9 @@ set_float_color(bool n) { _flags_specified |= FBF_float_color; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_float_depth -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FrameBufferProperties:: set_float_depth(bool n) { if (n) { diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 01928f75b7..5cb0f05973 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -1,16 +1,15 @@ -// Filename: frameBufferProperties.cxx -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameBufferProperties.cxx + * @author drose + * @date 2003-01-27 + */ #include "frameBufferProperties.h" #include "string_utils.h" @@ -18,21 +17,17 @@ #include "config_display.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FrameBufferProperties:: FrameBufferProperties() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FrameBufferProperties:: operator = (const FrameBufferProperties ©) { _flags_specified = copy._flags_specified; @@ -44,13 +39,10 @@ operator = (const FrameBufferProperties ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::subsumes -// Access: Public -// Description: Returns true if this set of properties makes -// strictly greater or equal demands of the framebuffer -// than the other set of framebuffer properties. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this set of properties makes strictly greater or equal + * demands of the framebuffer than the other set of framebuffer properties. + */ bool FrameBufferProperties:: subsumes(const FrameBufferProperties &other) const { if (((other._flags & other._flags_specified) & ~(_flags & _flags_specified)) != 0) { @@ -67,13 +59,10 @@ subsumes(const FrameBufferProperties &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_default -// Access: Published, Static -// Description: Returns a FrameBufferProperties structure with all of -// the default values filled in according to the user's -// config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FrameBufferProperties structure with all of the default values + * filled in according to the user's config file. + */ const FrameBufferProperties &FrameBufferProperties:: get_default() { static bool default_ready = false; @@ -185,11 +174,9 @@ get_default() { return default_props; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FrameBufferProperties:: operator == (const FrameBufferProperties &other) const { if ((_flags & _flags_specified) != (other._flags & other._flags_specified)) { @@ -209,13 +196,10 @@ operator == (const FrameBufferProperties &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::clear -// Access: Published -// Description: Unsets all properties that have been specified so -// far, and resets the FrameBufferProperties structure to its -// initial empty state. -//////////////////////////////////////////////////////////////////// +/** + * Unsets all properties that have been specified so far, and resets the + * FrameBufferProperties structure to its initial empty state. + */ void FrameBufferProperties:: clear() { _flags = 0; @@ -227,13 +211,10 @@ clear() { _specified = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::add_properties -// Access: Published -// Description: Sets any properties that are explicitly specified in -// other on this object. Leaves other properties -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Sets any properties that are explicitly specified in other on this object. + * Leaves other properties unchanged. + */ void FrameBufferProperties:: add_properties(const FrameBufferProperties &other) { _flags &= ~other._flags_specified; @@ -247,11 +228,9 @@ add_properties(const FrameBufferProperties &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::output -// Access: Published -// Description: Generates a string representation. -//////////////////////////////////////////////////////////////////// +/** + * Generates a string representation. + */ void FrameBufferProperties:: output(ostream &out) const { if ((_flags & FBF_float_depth) != 0) { @@ -319,12 +298,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_aux_mask -// Access: Published -// Description: Converts the aux bitplanes of the -// framebuffer into a RenderBuffer::Type. -//////////////////////////////////////////////////////////////////// +/** + * Converts the aux bitplanes of the framebuffer into a RenderBuffer::Type. + */ int FrameBufferProperties:: get_aux_mask() const { int mask = 0; @@ -340,12 +316,10 @@ get_aux_mask() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_buffer_mask -// Access: Private -// Description: Converts the non-aux bitplanes of the -// framebuffer into a RenderBuffer::Type. -//////////////////////////////////////////////////////////////////// +/** + * Converts the non-aux bitplanes of the framebuffer into a + * RenderBuffer::Type. + */ int FrameBufferProperties:: get_buffer_mask() const { int mask = 0; @@ -364,36 +338,28 @@ get_buffer_mask() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::is_any_specified -// Access: Published -// Description: Returns true if any properties have been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any properties have been specified, false otherwise. + */ bool FrameBufferProperties:: is_any_specified() const { return (_flags_specified | _specified) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_all_specified -// Access: Published -// Description: Marks all bits as having been specified. -//////////////////////////////////////////////////////////////////// +/** + * Marks all bits as having been specified. + */ void FrameBufferProperties:: set_all_specified() { _flags_specified = FBF_all; _specified = (1 << FBP_COUNT) - 1; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::is_basic -// Access: Published -// Description: Returns true if the properties are extremely basic. -// The following count as basic: rgb or rgba, depth. -// If anything else is specified, the properties are -// non-basic. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the properties are extremely basic. The following count as + * basic: rgb or rgba, depth. If anything else is specified, the properties + * are non-basic. + */ bool FrameBufferProperties:: is_basic() const { if (_property[FBP_depth_bits] > 1) { @@ -456,13 +422,10 @@ is_basic() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::set_one_bit_per_channel -// Access: Published -// Description: If any of the depth, color, alpha, accum, or -// stencil properties is set to more than one, -// then they are reduced to one. -//////////////////////////////////////////////////////////////////// +/** + * If any of the depth, color, alpha, accum, or stencil properties is set to + * more than one, then they are reduced to one. + */ void FrameBufferProperties:: set_one_bit_per_channel() { for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) { @@ -472,31 +435,24 @@ set_one_bit_per_channel() { } } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::get_quality -// Access: Published -// Description: Assumes that these properties are a description of -// a window. -// -// Measures how well this window satisfies a specified -// set of requirements. A higher quality number means -// that more requirements were satisfied. A quality of -// zero means that the window is unsuitable. -// -// The routine deducts a lot if the window fails to -// provide a requested feature. It deducts less -// if the window provides a feature, but at a degraded -// level of functionality (ie, the user asks for rgba8, -// color, but the window only provides rgba4). The -// routine also deducts a small amount for unnecessary -// features. For example, if the window has an -// accumulation buffer when one is not requested will -// reduce quality slightly. Maximum quality is obtained -// when the window exactly matches the request. -// -// If you want to know whether the window satisfies -// all of the requirements, use the "subsumes" function. -//////////////////////////////////////////////////////////////////// +/** + * Assumes that these properties are a description of a window. + * + * Measures how well this window satisfies a specified set of requirements. A + * higher quality number means that more requirements were satisfied. A + * quality of zero means that the window is unsuitable. + * + * The routine deducts a lot if the window fails to provide a requested + * feature. It deducts less if the window provides a feature, but at a + * degraded level of functionality (ie, the user asks for rgba8, color, but + * the window only provides rgba4). The routine also deducts a small amount + * for unnecessary features. For example, if the window has an accumulation + * buffer when one is not requested will reduce quality slightly. Maximum + * quality is obtained when the window exactly matches the request. + * + * If you want to know whether the window satisfies all of the requirements, + * use the "subsumes" function. + */ int FrameBufferProperties:: get_quality(const FrameBufferProperties &reqs) const { @@ -513,16 +469,16 @@ get_quality(const FrameBufferProperties &reqs) const { int quality = 100000000; - // Deduct for using the wrong kind of renderer (hardware or software). - // Cost: 10,000,000 + // Deduct for using the wrong kind of renderer (hardware or software). Cost: + // 10,000,000 if ((reqs._flags & FBF_force_hardware) > (_flags & FBF_force_hardware) || (reqs._flags & FBF_force_software) > (_flags & FBF_force_software)) { quality -= 10000000; } - // Deduct for missing depth, color, alpha, stencil, or accum. - // Cost: 1,000,000 + // Deduct for missing depth, color, alpha, stencil, or accum. Cost: + // 1,000,000 for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) { if (reqs._property[prop] && _property[prop] == 0) { @@ -530,8 +486,7 @@ get_quality(const FrameBufferProperties &reqs) const { } } - // Deduct for missing aux bitplanes. - // Cost: 100,000 + // Deduct for missing aux bitplanes. Cost: 100,000 for (int prop = FBP_aux_rgba; prop <= FBP_aux_float; ++prop) { if (reqs._property[prop] > _property[prop]) { @@ -539,22 +494,20 @@ get_quality(const FrameBufferProperties &reqs) const { } } - // Deduct for stereo not enabled. - // Cost: 100,000 + // Deduct for stereo not enabled. Cost: 100,000 if (reqs.get_stereo() && !get_stereo()) { quality -= 100000; } - // Deduct for not being sRGB-capable. - // Cost: 100,000 + // Deduct for not being sRGB-capable. Cost: 100,000 if (reqs.get_srgb_color() && !get_srgb_color()) { quality -= 100000; } - // Deduct for not having a floating-point format if we requested it. - // Cost: 100,000 + // Deduct for not having a floating-point format if we requested it. Cost: + // 100,000 if (reqs.get_float_color() && !get_float_color()) { quality -= 100000; @@ -564,15 +517,13 @@ get_quality(const FrameBufferProperties &reqs) const { quality -= 100000; } - // Deduct for insufficient back-buffers. - // Cost: 100,000 + // Deduct for insufficient back-buffers. Cost: 100,000 if (reqs._property[FBP_back_buffers] > _property[FBP_back_buffers]) { quality -= 100000; } - // Deduct for lacking multisamples altogether. - // Cost: 100,000 + // Deduct for lacking multisamples altogether. Cost: 100,000 if (reqs._property[FBP_multisamples] != 0 && _property[FBP_multisamples] == 0) { quality -= 100000; } @@ -586,16 +537,14 @@ get_quality(const FrameBufferProperties &reqs) const { } } - // deduct for insufficient multisamples. - // Cost: 1,000 + // deduct for insufficient multisamples. Cost: 1,000 if (_property[FBP_multisamples] != 0 && reqs._property[FBP_multisamples] > _property[FBP_multisamples]) { quality -= 1000; } - // Deduct for unrequested bitplanes. - // Cost: 50 + // Deduct for unrequested bitplanes. Cost: 50 for (int prop = FBP_depth_bits; prop <= FBP_accum_bits; ++prop) { if ((_property[prop]) && (reqs._property[prop] == 0)) { @@ -610,8 +559,8 @@ get_quality(const FrameBufferProperties &reqs) const { } } - // Deduct for excessive resolution in any bitplane (unless we asked - // for only 1 bit, which is the convention for any amount). + // Deduct for excessive resolution in any bitplane (unless we asked for only + // 1 bit, which is the convention for any amount). // Cost: 50 @@ -622,26 +571,22 @@ get_quality(const FrameBufferProperties &reqs) const { } } - // Bonus for each depth bit. - // Extra: 2 per bit. + // Bonus for each depth bit. Extra: 2 per bit. if (reqs._property[FBP_depth_bits] != 0) { quality += 2 * _property[FBP_depth_bits]; } - // Bonus for each multisample. - // Extra: 2 per sample. + // Bonus for each multisample. Extra: 2 per sample. if (reqs._property[FBP_multisamples] != 0) { quality += 2 * _property[FBP_multisamples]; } - // Bonus for each coverage sample. - // Extra: 2 per sample. + // Bonus for each coverage sample. Extra: 2 per sample. if (reqs._property[FBP_coverage_samples] != 0) { quality += 2 * _property[FBP_coverage_samples]; } - // Bonus for each color, alpha, stencil, and accum. - // Extra: 1 per bit. + // Bonus for each color, alpha, stencil, and accum. Extra: 1 per bit. for (int prop=FBP_color_bits; prop<=FBP_accum_bits; prop++) { if (reqs._property[prop] != 0) { quality += _property[prop]; @@ -651,13 +596,11 @@ get_quality(const FrameBufferProperties &reqs) const { return quality; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::verify_hardware_software -// Access: Public -// Description: Validates that the properties represent the desired -// kind of renderer (hardware or software). If not, -// prints out an error message and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Validates that the properties represent the desired kind of renderer + * (hardware or software). If not, prints out an error message and returns + * false. + */ bool FrameBufferProperties:: verify_hardware_software(const FrameBufferProperties &props, const string &renderer) const { @@ -690,25 +633,21 @@ verify_hardware_software(const FrameBufferProperties &props, const string &rende return true; } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::setup_color_texture -// Access: Public -// Description: Sets the texture up for render-to-texture matching -// these framebuffer properties. -// -// Returns true if there was a format that had enough -// bits, false otherwise. Of course, this is no -// guarantee that a particular graphics back-end -// supports rendering to textures of that format. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture up for render-to-texture matching these framebuffer + * properties. + * + * Returns true if there was a format that had enough bits, false otherwise. + * Of course, this is no guarantee that a particular graphics back-end + * supports rendering to textures of that format. + */ bool FrameBufferProperties:: setup_color_texture(Texture *tex) const { - // Note by rdb: I'm not entirely happy about this system. I'd - // eventually like to move to a system in which framebuffer color - // formats and texture formats are unified (like in Direct3D and - // OpenGL) and where a table such as the below one would be - // generated dynamically by the GSG to reflect the formats that - // are supported for render-to-texture. + // Note by rdb: I'm not entirely happy about this system. I'd eventually + // like to move to a system in which framebuffer color formats and texture + // formats are unified (like in Direct3D and OpenGL) and where a table such + // as the below one would be generated dynamically by the GSG to reflect the + // formats that are supported for render-to-texture. static const int num_formats = 13; static const struct { @@ -716,7 +655,7 @@ setup_color_texture(Texture *tex) const { bool has_float; Texture::Format format; } formats[num_formats] = { - //{ 1, 1, 0, 0, 0, false, Texture::F_red}, + // { 1, 1, 0, 0, 0, false, Texture::F_red}, { 1, 1, 1, 1, 0, false, Texture::F_rgb }, { 1, 1, 1, 1, 1, false, Texture::F_rgba }, { 24, 8, 8, 8, 0, false, Texture::F_rgb8 }, @@ -770,17 +709,14 @@ setup_color_texture(Texture *tex) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FrameBufferProperties::setup_depth_texture -// Access: Public -// Description: Sets the texture up for render-to-texture matching -// these framebuffer properties. -// -// Returns true if there was a format that had enough -// bits, false otherwise. Of course, this is no -// guarantee that a particular graphics back-end -// supports rendering to textures of that format. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture up for render-to-texture matching these framebuffer + * properties. + * + * Returns true if there was a format that had enough bits, false otherwise. + * Of course, this is no guarantee that a particular graphics back-end + * supports rendering to textures of that format. + */ bool FrameBufferProperties:: setup_depth_texture(Texture *tex) const { if (get_float_depth()) { diff --git a/panda/src/display/frameBufferProperties.h b/panda/src/display/frameBufferProperties.h index dcdeb587ec..9ac6c015ea 100644 --- a/panda/src/display/frameBufferProperties.h +++ b/panda/src/display/frameBufferProperties.h @@ -1,16 +1,15 @@ -// Filename: frameBufferProperties.h -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameBufferProperties.h + * @author drose + * @date 2003-01-27 + */ #ifndef FRAMEBUFFERPROPERTIES_H #define FRAMEBUFFERPROPERTIES_H @@ -20,12 +19,10 @@ class Texture; -//////////////////////////////////////////////////////////////////// -// Class : FrameBufferProperties -// Description : A container for the various kinds of properties we -// might ask to have on a graphics frameBuffer before we -// create a GSG. -//////////////////////////////////////////////////////////////////// +/** + * A container for the various kinds of properties we might ask to have on a + * graphics frameBuffer before we create a GSG. + */ class EXPCL_PANDA_DISPLAY FrameBufferProperties { private: diff --git a/panda/src/display/get_x11.h b/panda/src/display/get_x11.h index 5e246e5ae0..c188164598 100644 --- a/panda/src/display/get_x11.h +++ b/panda/src/display/get_x11.h @@ -1,16 +1,15 @@ -// Filename: get_x11.h -// Created by: drose (28Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file get_x11.h + * @author drose + * @date 2011-08-28 + */ #ifndef GET_X11_H #define GET_X11_H @@ -18,18 +17,16 @@ #include "pandabase.h" #ifdef HAVE_X11 -// This header file is designed to help work around some of the -// namespace spamming that X11 causes, by renaming the symbols that -// X11 declares that are known to conflict with other library names -// (like Apple's Core Graphics, for instance). +// This header file is designed to help work around some of the namespace +// spamming that X11 causes, by renaming the symbols that X11 declares that +// are known to conflict with other library names (like Apple's Core Graphics, +// for instance). -// In order for this to work, everyone who uses X11 within Panda -// should include this file instead of including the X11 headers -// directly. +// In order for this to work, everyone who uses X11 within Panda should +// include this file instead of including the X11 headers directly. #ifdef CPPPARSER -// A simple hack so interrogate can get all of the necessary -// typenames. +// A simple hack so interrogate can get all of the necessary typenames. typedef struct _XDisplay X11_Display; typedef unsigned int XID; typedef unsigned int Atom; diff --git a/panda/src/display/graphicsBuffer.I b/panda/src/display/graphicsBuffer.I index 1e6ae497c1..6035f35303 100644 --- a/panda/src/display/graphicsBuffer.I +++ b/panda/src/display/graphicsBuffer.I @@ -1,14 +1,12 @@ -// Filename: graphicsBuffer.I -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsBuffer.I + * @author drose + * @date 2004-02-06 + */ diff --git a/panda/src/display/graphicsBuffer.cxx b/panda/src/display/graphicsBuffer.cxx index b98dc38b34..bb0b086309 100644 --- a/panda/src/display/graphicsBuffer.cxx +++ b/panda/src/display/graphicsBuffer.cxx @@ -1,28 +1,24 @@ -// Filename: graphicsBuffer.cxx -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsBuffer.cxx + * @author drose + * @date 2004-02-06 + */ #include "graphicsBuffer.h" TypeHandle GraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::Constructor -// Access: Protected -// Description: Normally, the GraphicsBuffer constructor is not -// called directly; these are created instead via the -// GraphicsEngine::make_buffer() function. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the GraphicsBuffer constructor is not called directly; these are + * created instead via the GraphicsEngine::make_buffer() function. + */ GraphicsBuffer:: GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -45,24 +41,19 @@ GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, _open_request = OR_none; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsBuffer:: ~GraphicsBuffer() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::set_size -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the buffer resize itself. Although calls to get the -// size will return the new value, much of the actual -// resizing work doesn't take place until the next -// begin_frame. Not all buffers are resizeable. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the buffer resize + * itself. Although calls to get the size will return the new value, much of + * the actual resizing work doesn't take place until the next begin_frame. + * Not all buffers are resizeable. + */ void GraphicsBuffer:: set_size(int x, int y) { if ((_creation_flags & GraphicsPipe::BF_resizeable) == 0) { @@ -72,59 +63,46 @@ set_size(int x, int y) { set_size_and_recalc(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::request_open -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the buffer (or whatever) open itself or, in general, -// make itself valid, at the next call to -// process_events(). -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the buffer (or + * whatever) open itself or, in general, make itself valid, at the next call + * to process_events(). + */ void GraphicsBuffer:: request_open() { _open_request = OR_open; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::request_close -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the buffer (or whatever) close itself or, in general, -// make itself invalid, at the next call to -// process_events(). By that time we promise the gsg -// pointer will be cleared. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the buffer (or + * whatever) close itself or, in general, make itself invalid, at the next + * call to process_events(). By that time we promise the gsg pointer will be + * cleared. + */ void GraphicsBuffer:: request_close() { _open_request = OR_none; } - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::set_close_now -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to insist that -// the buffer be closed immediately. This is only -// called from the buffer thread. -//////////////////////////////////////////////////////////////////// + +/** + * This is called by the GraphicsEngine to insist that the buffer be closed + * immediately. This is only called from the buffer thread. + */ void GraphicsBuffer:: set_close_now() { _open_request = OR_none; close_buffer(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::process_events -// Access: Public, Virtual -// Description: Honor any requests recently made via request_open() -// or request_close(). -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Honor any requests recently made via request_open() or request_close(). + * + * This function is called only within the window thread. + */ void GraphicsBuffer:: process_events() { - // Save the current request and reset it immediately, in case we end - // up calling recursively back into this function. + // Save the current request and reset it immediately, in case we end up + // calling recursively back into this function. OpenRequest this_request = _open_request; _open_request = OR_none; @@ -145,25 +123,19 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void GraphicsBuffer:: close_buffer() { display_cat.info() << "Closing " << get_type() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the buffer right now. Called from the window -// thread. Returns true if the buffer is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the buffer right now. Called from the window thread. Returns true + * if the buffer is successfully opened, or false if there was a problem. + */ bool GraphicsBuffer:: open_buffer() { return false; diff --git a/panda/src/display/graphicsBuffer.h b/panda/src/display/graphicsBuffer.h index cf6600347b..caff1d9284 100644 --- a/panda/src/display/graphicsBuffer.h +++ b/panda/src/display/graphicsBuffer.h @@ -1,16 +1,15 @@ -// Filename: graphicsBuffer.h -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsBuffer.h + * @author drose + * @date 2004-02-06 + */ #ifndef GRAPHICSBUFFER_H #define GRAPHICSBUFFER_H @@ -21,16 +20,14 @@ #include "texture.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : GraphicsBuffer -// Description : An offscreen buffer for rendering into. This is -// similar in function to a GraphicsWindow, except that -// the output is not visible to the user. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen buffer for rendering into. This is similar in function to a + * GraphicsWindow, except that the output is not visible to the user. + */ class EXPCL_PANDA_DISPLAY GraphicsBuffer : public GraphicsOutput { protected: GraphicsBuffer(GraphicsEngine *engine, - GraphicsPipe *pipe, + GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -46,9 +43,9 @@ public: virtual void request_open(); virtual void request_close(); - // It is an error to call any of the following methods from any - // thread other than the window thread. These methods are normally - // called by the GraphicsEngine. + // It is an error to call any of the following methods from any thread other + // than the window thread. These methods are normally called by the + // GraphicsEngine. virtual void set_close_now(); virtual void process_events(); @@ -63,7 +60,7 @@ protected: OR_close, }; OpenRequest _open_request; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/display/graphicsDevice.I b/panda/src/display/graphicsDevice.I index cad62ce658..5676307eda 100644 --- a/panda/src/display/graphicsDevice.I +++ b/panda/src/display/graphicsDevice.I @@ -1,26 +1,20 @@ -// Filename: graphicsDevice.I -// Created by: masad (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsDevice.I + * @author masad + * @date 2003-07-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsDevice::get_pipe -// Access: Published -// Description: Returns the GraphicsPipe that this device is -// associated with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsPipe that this device is associated with. + */ INLINE GraphicsPipe *GraphicsDevice:: get_pipe() const { return _pipe; } - diff --git a/panda/src/display/graphicsDevice.cxx b/panda/src/display/graphicsDevice.cxx index e39c12095b..fb74bca7d8 100644 --- a/panda/src/display/graphicsDevice.cxx +++ b/panda/src/display/graphicsDevice.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsDevice.cxx -// Created by: masad (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsDevice.cxx + * @author masad + * @date 2003-07-21 + */ #include "graphicsDevice.h" #include "graphicsPipe.h" @@ -18,12 +17,10 @@ TypeHandle GraphicsDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsDevice::Constructor -// Access: Protected -// Description: Normally, the GraphicsDevice constructor holds -// a reference to the Graphics Pipe that it is part of -//////////////////////////////////////////////////////////////////// +/** + * Normally, the GraphicsDevice constructor holds a reference to the Graphics + * Pipe that it is part of + */ GraphicsDevice:: GraphicsDevice(GraphicsPipe *pipe) { #ifdef DO_MEMORY_USAGE @@ -37,34 +34,27 @@ GraphicsDevice(GraphicsPipe *pipe) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsDevice::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsDevice:: GraphicsDevice(const GraphicsDevice &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsDevice::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GraphicsDevice:: operator = (const GraphicsDevice &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsDevice::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsDevice:: ~GraphicsDevice() { - // And we shouldn't have a GraphicsPipe pointer anymore. - // nassertv(_pipe == (GraphicsPipe *)NULL); + // And we shouldn't have a GraphicsPipe pointer anymore. nassertv(_pipe == + // (GraphicsPipe *)NULL); } - diff --git a/panda/src/display/graphicsDevice.h b/panda/src/display/graphicsDevice.h index f9a53ef137..afb1edb697 100644 --- a/panda/src/display/graphicsDevice.h +++ b/panda/src/display/graphicsDevice.h @@ -1,16 +1,15 @@ -// Filename: graphicsDevice.h -// Created by: masad (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsDevice.h + * @author masad + * @date 2003-07-21 + */ #ifndef GRAPHICSDEVICE_H #define GRAPHICSDEVICE_H @@ -21,15 +20,13 @@ class GraphicsPipe; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsDevice -// Description : An abstract device object that is part of Graphics -// Pipe. This device is set to NULL for OpenGL. But -// DirectX uses it to take control of multiple windows -// under single device or multiple devices (i.e. more -// than one adapters in the machine). -// -//////////////////////////////////////////////////////////////////// +/** + * An abstract device object that is part of Graphics Pipe. This device is + * set to NULL for OpenGL. But DirectX uses it to take control of multiple + * windows under single device or multiple devices (i.e. more than one + * adapters in the machine). + * + */ class EXPCL_PANDA_DISPLAY GraphicsDevice : public TypedReferenceCount { public: GraphicsDevice(GraphicsPipe *pipe); diff --git a/panda/src/display/graphicsEngine.I b/panda/src/display/graphicsEngine.I index a634c71ca7..eccf5cfee4 100644 --- a/panda/src/display/graphicsEngine.I +++ b/panda/src/display/graphicsEngine.I @@ -1,147 +1,113 @@ -// Filename: graphicsEngine.I -// Created by: drose (24Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsEngine.I + * @author drose + * @date 2002-02-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_render_lock -// Access: Published -// Description: Returns a ReMutex object that is held by the -// GraphicsEngine during the entire call to -// render_frame(). While you hold this lock you can be -// confident that no part of the frame will be rendered -// (at least by the app thread). -//////////////////////////////////////////////////////////////////// +/** + * Returns a ReMutex object that is held by the GraphicsEngine during the + * entire call to render_frame(). While you hold this lock you can be + * confident that no part of the frame will be rendered (at least by the app + * thread). + */ INLINE const ReMutex &GraphicsEngine:: get_render_lock() const { return _public_lock; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::set_auto_flip -// Access: Published -// Description: Set this flag true to indicate the GraphicsEngine -// should automatically cause windows to sync and flip -// as soon as they have finished drawing, rather than -// waiting for all of the windows to finish drawing -// first so they can flip together. -// -// This only affects the timing of when the flip occurs. -// If this is true (the default), the flip occurs before -// render_frame() returns. If this is false, the flip -// occurs whenever flip_frame() is called, or at the -// beginning of the next call to render_frame(), if -// flip_frame() is never called. -//////////////////////////////////////////////////////////////////// +/** + * Set this flag true to indicate the GraphicsEngine should automatically + * cause windows to sync and flip as soon as they have finished drawing, + * rather than waiting for all of the windows to finish drawing first so they + * can flip together. + * + * This only affects the timing of when the flip occurs. If this is true (the + * default), the flip occurs before render_frame() returns. If this is false, + * the flip occurs whenever flip_frame() is called, or at the beginning of the + * next call to render_frame(), if flip_frame() is never called. + */ INLINE void GraphicsEngine:: set_auto_flip(bool auto_flip) { - // We don't bother with the mutex here. It's just a bool, after - // all. + // We don't bother with the mutex here. It's just a bool, after all. _auto_flip = auto_flip; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_auto_flip -// Access: Published -// Description: Returns the current setting for the auto-flip flag. -// See set_auto_flip. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting for the auto-flip flag. See set_auto_flip. + */ INLINE bool GraphicsEngine:: get_auto_flip() const { - // We don't bother with the mutex here. It's just a bool, after - // all. + // We don't bother with the mutex here. It's just a bool, after all. return _auto_flip; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::set_portal_cull -// Access: Published -// Description: Set this flag true to indicate the GraphicsEngine -// should start portal culling -//////////////////////////////////////////////////////////////////// +/** + * Set this flag true to indicate the GraphicsEngine should start portal + * culling + */ INLINE void GraphicsEngine:: set_portal_cull(bool value) { - // We don't bother with the mutex here. It's just a bool, after - // all. + // We don't bother with the mutex here. It's just a bool, after all. _portal_enabled = value; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_portal_cull -// Access: Published -// Description: Returns the current setting for the portal culling flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting for the portal culling flag. + */ INLINE bool GraphicsEngine:: get_portal_cull() const { - // We don't bother with the mutex here. It's just a bool, after - // all. + // We don't bother with the mutex here. It's just a bool, after all. return _portal_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::set_default_loader -// Access: Public -// Description: Sets the Loader object that will be assigned to every -// GSG created with this GraphicsEngine. See -// GraphicsStateGuardian::set_loader(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the Loader object that will be assigned to every GSG created with this + * GraphicsEngine. See GraphicsStateGuardian::set_loader(). + */ INLINE void GraphicsEngine:: set_default_loader(Loader *loader) { _default_loader = loader; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_default_loader -// Access: Public, Virtual -// Description: Returns the Loader object that will be assigned to -// every GSG created with this GraphicsEngine. See -// GraphicsStateGuardian::set_loader(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the Loader object that will be assigned to every GSG created with + * this GraphicsEngine. See GraphicsStateGuardian::set_loader(). + */ INLINE Loader *GraphicsEngine:: get_default_loader() const { return _default_loader; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::close_gsg -// Access: Published -// Description: Calls GraphicsPipe::close_gsg() on the indicated pipe -// and GSG. This function mainly exists to allow -// GraphicsEngine::WindowRenderer to call the protected -// method GraphicsPipe::close_gsg(). -//////////////////////////////////////////////////////////////////// +/** + * Calls GraphicsPipe::close_gsg() on the indicated pipe and GSG. This + * function mainly exists to allow GraphicsEngine::WindowRenderer to call the + * protected method GraphicsPipe::close_gsg(). + */ INLINE void GraphicsEngine:: close_gsg(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { pipe->close_gsg(gsg); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::make_buffer -// Access: Published -// Description: Syntactic shorthand for make_output. This is the -// preferred way to create an offscreen buffer, when you -// already have an onscreen window or another buffer to -// start with. For the first parameter, pass an -// existing GraphicsOutput object, e.g. the main window; -// this allows the buffer to adapt itself to that -// window's framebuffer properties, and allows maximum -// sharing of resources. -//////////////////////////////////////////////////////////////////// +/** + * Syntactic shorthand for make_output. This is the preferred way to create + * an offscreen buffer, when you already have an onscreen window or another + * buffer to start with. For the first parameter, pass an existing + * GraphicsOutput object, e.g. the main window; this allows the buffer to + * adapt itself to that window's framebuffer properties, and allows maximum + * sharing of resources. + */ INLINE GraphicsOutput *GraphicsEngine:: make_buffer(GraphicsOutput *host, const string &name, int sort, int x_size, int y_size) { GraphicsOutput *result = make_output(host->get_pipe(), name, sort, - FrameBufferProperties(), + FrameBufferProperties(), WindowProperties::size(x_size, y_size), GraphicsPipe::BF_refuse_window | GraphicsPipe::BF_fb_props_optional, @@ -149,26 +115,20 @@ make_buffer(GraphicsOutput *host, const string &name, return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::make_buffer -// Access: Published -// Description: Syntactic shorthand for make_output. This flavor -// accepts a GSG rather than a GraphicsOutput as the -// first parameter, which is too limiting and disallows -// the possibility of creating a ParasiteBuffer if the -// user's graphics hardware prefers that. It also -// attempts to request specific framebuffer properties -// and may therefore do a poorer job of sharing the GSG -// between the old buffer and the new. -// -// For these reasons, this variant is a poor choice -// unless you are creating an offscreen buffer for the -// first time, without an onscreen window already in -// existence. If you already have an onscreen window, -// you should use the other flavor of make_buffer() -// instead, which accepts a GraphicsOutput as the first -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Syntactic shorthand for make_output. This flavor accepts a GSG rather than + * a GraphicsOutput as the first parameter, which is too limiting and + * disallows the possibility of creating a ParasiteBuffer if the user's + * graphics hardware prefers that. It also attempts to request specific + * framebuffer properties and may therefore do a poorer job of sharing the GSG + * between the old buffer and the new. + * + * For these reasons, this variant is a poor choice unless you are creating an + * offscreen buffer for the first time, without an onscreen window already in + * existence. If you already have an onscreen window, you should use the + * other flavor of make_buffer() instead, which accepts a GraphicsOutput as + * the first parameter. + */ INLINE GraphicsOutput *GraphicsEngine:: make_buffer(GraphicsStateGuardian *gsg, const string &name, int sort, int x_size, int y_size) { @@ -180,7 +140,7 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name, fb_props.set_force_hardware(0); fb_props.set_force_software(0); GraphicsOutput *result = make_output(gsg->get_pipe(), name, sort, - fb_props, + fb_props, WindowProperties::size(x_size, y_size), GraphicsPipe::BF_refuse_window | GraphicsPipe::BF_fb_props_optional, @@ -188,13 +148,11 @@ make_buffer(GraphicsStateGuardian *gsg, const string &name, return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::make_parasite -// Access: Published -// Description: Syntactic shorthand for make_buffer. -//////////////////////////////////////////////////////////////////// +/** + * Syntactic shorthand for make_buffer. + */ INLINE GraphicsOutput *GraphicsEngine:: -make_parasite(GraphicsOutput *host, const string &name, +make_parasite(GraphicsOutput *host, const string &name, int sort, int x_size, int y_size) { GraphicsOutput *result = make_output(host->get_pipe(), name, sort, FrameBufferProperties(), diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index fa95aff9d9..41f6df5f34 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsEngine.cxx -// Created by: drose (24Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsEngine.cxx + * @author drose + * @date 2002-02-24 + */ #include "graphicsEngine.h" #include "graphicsPipe.h" @@ -92,8 +91,8 @@ PStatCollector GraphicsEngine::_vertex_data_compressed_pcollector("Vertex Data:C PStatCollector GraphicsEngine::_vertex_data_unused_disk_pcollector("Vertex Data:Disk:Unused"); PStatCollector GraphicsEngine::_vertex_data_used_disk_pcollector("Vertex Data:Disk:Used"); -// These are counted independently by the collision system; we -// redefine them here so we can reset them at each frame. +// These are counted independently by the collision system; we redefine them +// here so we can reset them at each frame. PStatCollector GraphicsEngine::_cnode_volume_pcollector("Collision Volumes:CollisionNode"); PStatCollector GraphicsEngine::_gnode_volume_pcollector("Collision Volumes:GeomNode"); PStatCollector GraphicsEngine::_geom_volume_pcollector("Collision Volumes:Geom"); @@ -119,14 +118,11 @@ PStatCollector GraphicsEngine::_occlusion_passed_pcollector("Occlusion results:V PStatCollector GraphicsEngine::_occlusion_failed_pcollector("Occlusion results:Occluded"); PStatCollector GraphicsEngine::_occlusion_tests_pcollector("Occlusion tests"); -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::Constructor -// Access: Published -// Description: Creates a new GraphicsEngine object. The Pipeline is -// normally left to default to NULL, which indicates the -// global render pipeline, but it may be any Pipeline -// you choose. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GraphicsEngine object. The Pipeline is normally left to + * default to NULL, which indicates the global render pipeline, but it may be + * any Pipeline you choose. + */ GraphicsEngine:: GraphicsEngine(Pipeline *pipeline) : _pipeline(pipeline), @@ -155,12 +151,10 @@ GraphicsEngine(Pipeline *pipeline) : _singular_warning_this_frame = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::Destructor -// Access: Published -// Description: Gracefully cleans up the graphics engine and its -// related threads and windows. -//////////////////////////////////////////////////////////////////// +/** + * Gracefully cleans up the graphics engine and its related threads and + * windows. + */ GraphicsEngine:: ~GraphicsEngine() { #ifdef DO_PSTATS @@ -172,13 +166,11 @@ GraphicsEngine:: remove_all_windows(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::set_threading_model -// Access: Published -// Description: Specifies how future objects created via make_gsg(), -// make_buffer(), and make_window() will be threaded. -// This does not affect any already-created objects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how future objects created via make_gsg(), make_buffer(), and + * make_window() will be threaded. This does not affect any already-created + * objects. + */ void GraphicsEngine:: set_threading_model(const GraphicsThreadingModel &threading_model) { if (!Thread::is_threading_supported()) { @@ -208,12 +200,10 @@ set_threading_model(const GraphicsThreadingModel &threading_model) { _threading_model = threading_model; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_threading_model -// Access: Published -// Description: Returns the threading model that will be applied to -// future objects. See set_threading_model(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the threading model that will be applied to future objects. See + * set_threading_model(). + */ GraphicsThreadingModel GraphicsEngine:: get_threading_model() const { GraphicsThreadingModel result; @@ -224,24 +214,21 @@ get_threading_model() const { return result; } -// THIS IS THE OLD CODE FOR make_gsg -// PT(GraphicsStateGuardian) gsg = pipe->make_gsg(properties, share_with); +// THIS IS THE OLD CODE FOR make_gsg PT(GraphicsStateGuardian) gsg = +// pipe->make_gsg(properties, share_with); -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::make_output -// Access: Published -// Description: Creates a new window (or buffer) and returns it. -// The GraphicsEngine becomes the owner of the window, -// it will persist at least until remove_window() is -// called later. -// -// If a null pointer is supplied for the gsg, then this -// routine will create a new gsg. -// -// This routine is only called from the app thread. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window (or buffer) and returns it. The GraphicsEngine + * becomes the owner of the window, it will persist at least until + * remove_window() is called later. + * + * If a null pointer is supplied for the gsg, then this routine will create a + * new gsg. + * + * This routine is only called from the app thread. + */ GraphicsOutput *GraphicsEngine:: make_output(GraphicsPipe *pipe, @@ -252,36 +239,28 @@ make_output(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, GraphicsOutput *host) { - // The code here is tricky because the gsg that is passed in - // might be in the uninitialized state. As a result, - // pipe::make_output may not be able to tell which DirectX - // capabilities or OpenGL extensions are supported and which - // are not. Worse yet, it can't query the API, because that - // can only be done from the draw thread, and this is the app - // thread. - // - // So here's the workaround: this routine calls pipe::make_output, - // which returns a "non-certified" window. That means that - // the pipe doesn't promise that the draw thread will actually - // succeed in initializing the window. This routine then calls - // open_windows, which attempts to initialize the window. - // - // If open_windows fails to initialize the window, then - // this routine will ask pipe::make_output to try again, this - // time using a different set of OpenGL extensions or DirectX - // capabilities. This is what the "retry" parameter to - // pipe::make_output is for - it specifies, in an abstract - // manner, which set of capabilties/extensions to try. - // - // The only problem with this design is that it requires the - // engine to call open_windows, which is slow. To make - // things faster, the pipe can choose to "precertify" - // its creations. If it chooses to do so, this is a guarantee - // that the windows it returns will not fail in open_windows. - // However, most graphics pipes will only precertify if you - // pass them an already-initialized gsg. Long story short, - // if you want make_output to be fast, use an - // already-initialized gsg. +/* + * The code here is tricky because the gsg that is passed in might be in the + * uninitialized state. As a result, pipe::make_output may not be able to + * tell which DirectX capabilities or OpenGL extensions are supported and + * which are not. Worse yet, it can't query the API, because that can only be + * done from the draw thread, and this is the app thread. So here's the + * workaround: this routine calls pipe::make_output, which returns a "non- + * certified" window. That means that the pipe doesn't promise that the draw + * thread will actually succeed in initializing the window. This routine then + * calls open_windows, which attempts to initialize the window. If + * open_windows fails to initialize the window, then this routine will ask + * pipe::make_output to try again, this time using a different set of OpenGL + * extensions or DirectX capabilities. This is what the "retry" parameter to + * pipe::make_output is for - it specifies, in an abstract manner, which set + * of capabiltiesextensions to try. The only problem with this design is that + * it requires the engine to call open_windows, which is slow. To make things + * faster, the pipe can choose to "precertify" its creations. If it chooses + * to do so, this is a guarantee that the windows it returns will not fail in + * open_windows. However, most graphics pipes will only precertify if you + * pass them an already-initialized gsg. Long story short, if you want + * make_output to be fast, use an already-initialized gsg. + */ // Simplify the input parameters. @@ -297,9 +276,9 @@ make_output(GraphicsPipe *pipe, host = host->get_host(); } - // If a gsg or host was supplied, and either is not yet initialized, - // then call open_windows to get both ready. If that fails, - // give up on using the supplied gsg and host. + // If a gsg or host was supplied, and either is not yet initialized, then + // call open_windows to get both ready. If that fails, give up on using the + // supplied gsg and host. if (host == (GraphicsOutput *)NULL) { if (gsg != (GraphicsStateGuardian*)NULL) { @@ -343,8 +322,8 @@ make_output(GraphicsPipe *pipe, if ((flags & GraphicsPipe::BF_require_callback_window)!=0) { PT(GraphicsStateGuardian) this_gsg = gsg; if (this_gsg == (GraphicsStateGuardian *)NULL) { - // If we don't already have a GSG, we have to ask the pipe to - // make a new one, unencumbered by window dressing. + // If we don't already have a GSG, we have to ask the pipe to make a new + // one, unencumbered by window dressing. this_gsg = pipe->make_callback_gsg(this); } if (this_gsg != (GraphicsStateGuardian *)NULL) { @@ -356,8 +335,8 @@ make_output(GraphicsPipe *pipe, return window; } - // Couldn't make a callback window, because the pipe wouldn't make - // an unencumbered GSG. + // Couldn't make a callback window, because the pipe wouldn't make an + // unencumbered GSG. return NULL; } @@ -378,10 +357,10 @@ make_output(GraphicsPipe *pipe, } } - // If parasite buffers are preferred, then try a parasite first. - // Even if prefer-parasite-buffer is set, parasites are not preferred - // if the host window is too small, or if the host window does not - // have the requested properties. + // If parasite buffers are preferred, then try a parasite first. Even if + // prefer-parasite-buffer is set, parasites are not preferred if the host + // window is too small, or if the host window does not have the requested + // properties. if ((prefer_parasite_buffer) && (can_use_parasite) && @@ -396,9 +375,9 @@ make_output(GraphicsPipe *pipe, return buffer; } - // If force-parasite-buffer is set, we create a parasite buffer even - // if it's less than ideal. You might set this if you really don't - // trust your graphics driver's support for offscreen buffers. + // If force-parasite-buffer is set, we create a parasite buffer even if it's + // less than ideal. You might set this if you really don't trust your + // graphics driver's support for offscreen buffers. if (force_parasite_buffer && can_use_parasite) { ParasiteBuffer *buffer = new ParasiteBuffer(host, name, x_size, y_size, flags); buffer->_sort = sort; @@ -457,9 +436,8 @@ make_output(GraphicsPipe *pipe, } } - // Parasite buffers were not preferred, but the pipe could not - // create a window to the user's specs. Try a parasite as a - // last hope. + // Parasite buffers were not preferred, but the pipe could not create a + // window to the user's specs. Try a parasite as a last hope. if (can_use_parasite) { ParasiteBuffer *buffer = new ParasiteBuffer(host, name, x_size, y_size, flags); @@ -475,17 +453,13 @@ make_output(GraphicsPipe *pipe, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::add_window -// Access: Published -// Description: This can be used to add a newly-created -// GraphicsOutput object (and its GSG) to the engine's -// list of windows, and requests that it be opened. -// This shouldn't be called by user code as -// make_output normally does this under the hood; it -// may be useful in esoteric cases in which a custom -// window object is used. -//////////////////////////////////////////////////////////////////// +/** + * This can be used to add a newly-created GraphicsOutput object (and its GSG) + * to the engine's list of windows, and requests that it be opened. This + * shouldn't be called by user code as make_output normally does this under + * the hood; it may be useful in esoteric cases in which a custom window + * object is used. + */ bool GraphicsEngine:: add_window(GraphicsOutput *window, int sort) { nassertr(window != NULL, false); @@ -511,30 +485,23 @@ add_window(GraphicsOutput *window, int sort) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::remove_window -// Access: Published -// Description: Removes the indicated window or offscreen buffer from -// the set of windows that will be processed when -// render_frame() is called. This also closes the -// window if it is open, and removes the window from its -// GraphicsPipe, allowing the window to be destructed if -// there are no other references to it. (However, the -// window may not be actually closed until next frame, -// if it is controlled by a sub-thread.) -// -// The return value is true if the window was removed, -// false if it was not found. -// -// Unlike remove_all_windows(), this function does not -// terminate any of the threads that may have been -// started to service this window; they are left running -// (since you might open a new window later on these -// threads). If your intention is to clean up before -// shutting down, it is better to call -// remove_all_windows() then to call remove_window() one -// at a time. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated window or offscreen buffer from the set of windows + * that will be processed when render_frame() is called. This also closes the + * window if it is open, and removes the window from its GraphicsPipe, + * allowing the window to be destructed if there are no other references to + * it. (However, the window may not be actually closed until next frame, if + * it is controlled by a sub-thread.) + * + * The return value is true if the window was removed, false if it was not + * found. + * + * Unlike remove_all_windows(), this function does not terminate any of the + * threads that may have been started to service this window; they are left + * running (since you might open a new window later on these threads). If + * your intention is to clean up before shutting down, it is better to call + * remove_all_windows() then to call remove_window() one at a time. + */ bool GraphicsEngine:: remove_window(GraphicsOutput *window) { nassertr(window != NULL, false); @@ -561,8 +528,7 @@ remove_window(GraphicsOutput *window) { if (gsg != (GraphicsStateGuardian *)NULL) { PreparedGraphicsObjects *pgo = gsg->get_prepared_objects(); if (pgo != (PreparedGraphicsObjects *)NULL) { - // Check to see if any other still-active windows share this - // context. + // Check to see if any other still-active windows share this context. bool any_common = false; { ReMutexHolder holder(_lock, current_thread); @@ -576,12 +542,11 @@ remove_window(GraphicsOutput *window) { } } if (!any_common) { - // If no windows still use this context, release all textures, - // etc. We do this in case there is a floating pointer - // somewhere keeping the GSG from destructing when its window - // goes away. A leaked GSG pointer is bad enough, but there's - // no reason we also need to keep around all of the objects - // allocated on graphics memory. + // If no windows still use this context, release all textures, etc. + // We do this in case there is a floating pointer somewhere keeping + // the GSG from destructing when its window goes away. A leaked GSG + // pointer is bad enough, but there's no reason we also need to keep + // around all of the objects allocated on graphics memory. pgo->release_all(); } } @@ -591,22 +556,18 @@ remove_window(GraphicsOutput *window) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::remove_all_windows -// Access: Published -// Description: Removes and closes all windows from the engine. This -// also cleans up and terminates any threads that have -// been started to service those windows. -//////////////////////////////////////////////////////////////////// +/** + * Removes and closes all windows from the engine. This also cleans up and + * terminates any threads that have been started to service those windows. + */ void GraphicsEngine:: remove_all_windows() { Thread *current_thread = Thread::get_current_thread(); - // Let's move the _windows vector into a local copy first, and walk - // through that local copy, just in case someone we call during the - // loop attempts to modify _windows. I don't know what code would - // be doing this, but it appeared to be happening, and this worked - // around it. + // Let's move the _windows vector into a local copy first, and walk through + // that local copy, just in case someone we call during the loop attempts to + // modify _windows. I don't know what code would be doing this, but it + // appeared to be happening, and this worked around it. Windows old_windows; old_windows.swap(_windows); Windows::iterator wi; @@ -624,11 +585,10 @@ remove_all_windows() { _app.do_pending(this, current_thread); terminate_threads(current_thread); - // It seems a safe assumption that we're about to exit the - // application or otherwise shut down Panda. Although it's a bit of - // a hack, since it's not really related to removing windows, this - // would nevertheless be a fine time to ensure the model cache (if - // any) has been flushed to disk. + // It seems a safe assumption that we're about to exit the application or + // otherwise shut down Panda. Although it's a bit of a hack, since it's not + // really related to removing windows, this would nevertheless be a fine + // time to ensure the model cache (if any) has been flushed to disk. BamCache::flush_global_index(); // And, hey, let's stop the vertex paging threads, if any. @@ -644,53 +604,41 @@ remove_all_windows() { Thread::prepare_for_exit(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::reset_all_windows -// Access: Published -// Description: Resets the framebuffer of the current window. This -// is currently used by DirectX 8 only. It calls a -// reset_window function on each active window to -// release/create old/new framebuffer -//////////////////////////////////////////////////////////////////// +/** + * Resets the framebuffer of the current window. This is currently used by + * DirectX 8 only. It calls a reset_window function on each active window to + * release/create old/new framebuffer + */ void GraphicsEngine:: reset_all_windows(bool swapchain) { Windows::iterator wi; for (wi = _windows.begin(); wi != _windows.end(); ++wi) { GraphicsOutput *win = (*wi); - // if (win->is_active()) + // if (win->is_active()) win->reset_window(swapchain); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::is_empty -// Access: Published -// Description: Returns true if there are no windows or buffers -// managed by the engine, false if there is at least -// one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no windows or buffers managed by the engine, + * false if there is at least one. + */ bool GraphicsEngine:: is_empty() const { return _windows.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_num_windows -// Access: Published -// Description: Returns the number of windows (or buffers) managed by -// the engine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of windows (or buffers) managed by the engine. + */ int GraphicsEngine:: get_num_windows() const { return _windows.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_window -// Access: Published -// Description: Returns the nth window or buffers managed by the -// engine, in sorted order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth window or buffers managed by the engine, in sorted order. + */ GraphicsOutput *GraphicsEngine:: get_window(int n) const { nassertr(n >= 0 && n < (int)_windows.size(), NULL); @@ -701,23 +649,21 @@ get_window(int n) const { return _windows[n]; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::render_frame -// Access: Published -// Description: Renders the next frame in all the registered windows, -// and flips all of the frame buffers. -//////////////////////////////////////////////////////////////////// +/** + * Renders the next frame in all the registered windows, and flips all of the + * frame buffers. + */ void GraphicsEngine:: render_frame() { Thread *current_thread = Thread::get_current_thread(); ReMutexHolder public_holder(_public_lock); - // Since this gets called every frame, we should take advantage of - // the opportunity to flush the cache if necessary. + // Since this gets called every frame, we should take advantage of the + // opportunity to flush the cache if necessary. BamCache::consider_flush_global_index(); - // Anything that happens outside of GraphicsEngine::render_frame() - // is deemed to be App. + // Anything that happens outside of GraphicsEngine::render_frame() is deemed + // to be App. #ifdef DO_PSTATS _render_frame_pcollector.start(); if (_app_pcollector.is_started()) { @@ -726,11 +672,11 @@ render_frame() { #endif if (_needs_open_windows) { - // Make sure our buffers and windows are fully realized before we - // render a frame. We do this particularly to realize our - // offscreen buffers, so that we don't render a frame before the - // offscreen buffers are ready (which might result in a frame - // going by without some textures having been rendered). + // Make sure our buffers and windows are fully realized before we render a + // frame. We do this particularly to realize our offscreen buffers, so + // that we don't render a frame before the offscreen buffers are ready + // (which might result in a frame going by without some textures having + // been rendered). open_windows(); } @@ -765,12 +711,11 @@ render_frame() { } else { new_windows.push_back(win); - // Let's calculate each scene's bounding volume here in App, - // before we cycle the pipeline. The cull traversal will - // calculate it anyway, but if we calculate it in App first - // before it gets calculated in the Cull thread, it will be more - // likely to stick for subsequent frames, so we won't have to - // recompute it each frame. + // Let's calculate each scene's bounding volume here in App, before we + // cycle the pipeline. The cull traversal will calculate it anyway, + // but if we calculate it in App first before it gets calculated in + // the Cull thread, it will be more likely to stick for subsequent + // frames, so we won't have to recompute it each frame. int num_drs = win->get_num_active_display_regions(); for (int i = 0; i < num_drs; ++i) { DisplayRegion *dr = win->get_active_display_region(i); @@ -792,8 +737,8 @@ render_frame() { } _windows.swap(new_windows); - // Go ahead and release any textures' ram images for textures that - // were drawn in the previous frame. + // Go ahead and release any textures' ram images for textures that were + // drawn in the previous frame. { MutexHolder holder2(_loaded_textures_lock); LoadedTextures::iterator lti; @@ -806,12 +751,12 @@ render_frame() { _loaded_textures.clear(); } - // Now it's time to do any drawing from the main frame--after all of - // the App code has executed, but before we begin the next frame. + // Now it's time to do any drawing from the main frame--after all of the + // App code has executed, but before we begin the next frame. _app.do_frame(this, current_thread); - // Grab each thread's mutex again after all windows have flipped, - // and wait for the thread to finish. + // Grab each thread's mutex again after all windows have flipped, and wait + // for the thread to finish. { PStatTimer timer(_wait_pcollector, current_thread); Threads::const_iterator ti; @@ -940,16 +885,16 @@ render_frame() { thread->_cv_mutex.release(); } - // Some threads may still be drawing, so indicate that we have to - // wait for those threads before we can flip. + // Some threads may still be drawing, so indicate that we have to wait for + // those threads before we can flip. _flip_state = _auto_flip ? FS_flip : FS_draw; } // Now the lock is released. if (yield_timeslice) { - // Nap for a moment to yield the timeslice, to be polite to other - // running applications. + // Nap for a moment to yield the timeslice, to be polite to other running + // applications. PStatTimer timer(_yield_pcollector, current_thread); Thread::force_yield(); } else if (!Thread::is_true_threads()) { @@ -957,24 +902,20 @@ render_frame() { Thread::consider_yield(); } - // Anything that happens outside of GraphicsEngine::render_frame() - // is deemed to be App. + // Anything that happens outside of GraphicsEngine::render_frame() is deemed + // to be App. _app_pcollector.start(); _render_frame_pcollector.stop(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::open_windows -// Access: Published -// Description: Fully opens (or closes) any windows that have -// recently been requested open or closed, without -// rendering any frames. It is not necessary to call -// this explicitly, since windows will be automatically -// opened or closed when the next frame is rendered, but -// you may call this if you want your windows now -// without seeing a frame go by. -//////////////////////////////////////////////////////////////////// +/** + * Fully opens (or closes) any windows that have recently been requested open + * or closed, without rendering any frames. It is not necessary to call this + * explicitly, since windows will be automatically opened or closed when the + * next frame is rendered, but you may call this if you want your windows now + * without seeing a frame go by. + */ void GraphicsEngine:: open_windows() { Thread *current_thread = Thread::get_current_thread(); @@ -985,8 +926,7 @@ open_windows() { do_resort_windows(); } - // We do it twice, to allow both cull and draw to process the - // window. + // We do it twice, to allow both cull and draw to process the window. for (int i = 0; i < 2; ++i) { _app.do_windows(this, current_thread); _app.do_pending(this, current_thread); @@ -1010,15 +950,12 @@ open_windows() { _needs_open_windows = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::sync_frame -// Access: Published -// Description: Waits for all the threads that started drawing their -// last frame to finish drawing. The windows are not -// yet flipped when this returns; see also flip_frame(). -// It is not usually necessary to call this explicitly, -// unless you need to see the previous frame right away. -//////////////////////////////////////////////////////////////////// +/** + * Waits for all the threads that started drawing their last frame to finish + * drawing. The windows are not yet flipped when this returns; see also + * flip_frame(). It is not usually necessary to call this explicitly, unless + * you need to see the previous frame right away. + */ void GraphicsEngine:: sync_frame() { Thread *current_thread = Thread::get_current_thread(); @@ -1030,20 +967,16 @@ sync_frame() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::ready_flip -// Access: Published -// Description: Waits for all the threads that started drawing their -// last frame to finish drawing. Returns when all threads have -// actually finished drawing, as opposed to 'sync_frame' -// we seems to return once all draw calls have been submitted. -// Calling 'flip_frame' after this function should immediately -// cause a buffer flip. This function will only work in -// opengl right now, for all other graphics pipelines it will -// simply return immediately. In opengl it's a bit of a hack: -// it will attempt to read a single pixel from the frame buffer to -// force the graphics card to finish drawing before it returns -//////////////////////////////////////////////////////////////////// +/** + * Waits for all the threads that started drawing their last frame to finish + * drawing. Returns when all threads have actually finished drawing, as + * opposed to 'sync_frame' we seems to return once all draw calls have been + * submitted. Calling 'flip_frame' after this function should immediately + * cause a buffer flip. This function will only work in opengl right now, for + * all other graphics pipelines it will simply return immediately. In opengl + * it's a bit of a hack: it will attempt to read a single pixel from the frame + * buffer to force the graphics card to finish drawing before it returns + */ void GraphicsEngine:: ready_flip() { Thread *current_thread = Thread::get_current_thread(); @@ -1054,15 +987,11 @@ ready_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::flip_frame -// Access: Published -// Description: Waits for all the threads that started drawing their -// last frame to finish drawing, and then flips all the -// windows. It is not usually necessary to call this -// explicitly, unless you need to see the previous frame -// right away. -//////////////////////////////////////////////////////////////////// +/** + * Waits for all the threads that started drawing their last frame to finish + * drawing, and then flips all the windows. It is not usually necessary to + * call this explicitly, unless you need to see the previous frame right away. + */ void GraphicsEngine:: flip_frame() { Thread *current_thread = Thread::get_current_thread(); @@ -1073,35 +1002,27 @@ flip_frame() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::extract_texture_data -// Access: Published -// Description: Asks the indicated GraphicsStateGuardian to retrieve -// the texture memory image of the indicated texture and -// store it in the texture's ram_image field. The image -// can then be written to disk via Texture::write(), or -// otherwise manipulated on the CPU. -// -// This is useful for retrieving the contents of a -// texture that has been somehow generated on the -// graphics card, instead of having been loaded the -// normal way via Texture::read() or Texture::load(). -// It is particularly useful for getting the data -// associated with a compressed texture image. -// -// Since this requires a round-trip to the draw thread, -// it may require waiting for the current thread to -// finish rendering if it is called in a multithreaded -// environment. However, you can call this several -// consecutive times on different textures for little -// additional cost. -// -// If the texture has not yet been loaded to the GSG in -// question, it will be loaded immediately. -// -// The return value is true if the operation is -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Asks the indicated GraphicsStateGuardian to retrieve the texture memory + * image of the indicated texture and store it in the texture's ram_image + * field. The image can then be written to disk via Texture::write(), or + * otherwise manipulated on the CPU. + * + * This is useful for retrieving the contents of a texture that has been + * somehow generated on the graphics card, instead of having been loaded the + * normal way via Texture::read() or Texture::load(). It is particularly + * useful for getting the data associated with a compressed texture image. + * + * Since this requires a round-trip to the draw thread, it may require waiting + * for the current thread to finish rendering if it is called in a + * multithreaded environment. However, you can call this several consecutive + * times on different textures for little additional cost. + * + * If the texture has not yet been loaded to the GSG in question, it will be + * loaded immediately. + * + * The return value is true if the operation is successful, false otherwise. + */ bool GraphicsEngine:: extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { ReMutexHolder holder(_lock); @@ -1112,8 +1033,8 @@ extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { return gsg->extract_texture_data(tex); } else { - // A multi-threaded environment. We have to wait until the draw - // thread has finished its current task. + // A multi-threaded environment. We have to wait until the draw thread + // has finished its current task. WindowRenderer *wr = get_window_renderer(draw_name, 0); RenderThread *thread = (RenderThread *)wr; MutexHolder holder2(thread->_cv_mutex); @@ -1122,34 +1043,27 @@ extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { thread->_cv_done.wait(); } - // OK, now the draw thread is idle. That's really good enough for - // our purposes; we don't *actually* need to make the draw thread - // do the work--it's sufficient that it's not doing anything else - // while we access the GSG. + // OK, now the draw thread is idle. That's really good enough for our + // purposes; we don't *actually* need to make the draw thread do the work + // --it's sufficient that it's not doing anything else while we access the + // GSG. return gsg->extract_texture_data(tex); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::dispatch_compute -// Access: Published -// Description: Asks the indicated GraphicsStateGuardian to dispatch -// the compute shader in the given ShaderAttrib using -// the given work group counts. This can act as an -// interface for running a one-off compute shader, -// without having to store it in the scene graph using -// a ComputeNode. -// -// Since this requires a round-trip to the draw thread, -// it may require waiting for the current thread to -// finish rendering if it is called in a multithreaded -// environment. However, you can call this several -// consecutive times on different textures for little -// additional cost. -// -// The return value is true if the operation is -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Asks the indicated GraphicsStateGuardian to dispatch the compute shader in + * the given ShaderAttrib using the given work group counts. This can act as + * an interface for running a one-off compute shader, without having to store + * it in the scene graph using a ComputeNode. + * + * Since this requires a round-trip to the draw thread, it may require waiting + * for the current thread to finish rendering if it is called in a + * multithreaded environment. However, you can call this several consecutive + * times on different textures for little additional cost. + * + * The return value is true if the operation is successful, false otherwise. + */ void GraphicsEngine:: dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, GraphicsStateGuardian *gsg) { nassertv(sattr->get_shader() != (Shader *)NULL); @@ -1163,8 +1077,8 @@ dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, Graph // A single-threaded environment. No problem. } else { - // A multi-threaded environment. We have to wait until the draw - // thread has finished its current task. + // A multi-threaded environment. We have to wait until the draw thread + // has finished its current task. WindowRenderer *wr = get_window_renderer(draw_name, 0); RenderThread *thread = (RenderThread *)wr; MutexHolder holder2(thread->_cv_mutex); @@ -1173,21 +1087,19 @@ dispatch_compute(const LVecBase3i &work_groups, const ShaderAttrib *sattr, Graph thread->_cv_done.wait(); } - // OK, now the draw thread is idle. That's really good enough for - // our purposes; we don't *actually* need to make the draw thread - // do the work--it's sufficient that it's not doing anything else - // while we access the GSG. + // OK, now the draw thread is idle. That's really good enough for our + // purposes; we don't *actually* need to make the draw thread do the work + // --it's sufficient that it's not doing anything else while we access the + // GSG. } gsg->set_state_and_transform(state, TransformState::make_identity()); gsg->dispatch_compute(work_groups[0], work_groups[1], work_groups[2]); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_global_ptr -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsEngine *GraphicsEngine:: get_global_ptr() { if (_global_ptr == NULL) { @@ -1197,37 +1109,30 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::texture_uploaded -// Access: Public -// Description: This method is called by the GraphicsStateGuardian -// after a texture has been successfully uploaded to -// graphics memory. It is intended as a callback so the -// texture can release its RAM image, if _keep_ram_image -// is false. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian. It will be called in the draw -// thread. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the GraphicsStateGuardian after a texture has been + * successfully uploaded to graphics memory. It is intended as a callback so + * the texture can release its RAM image, if _keep_ram_image is false. + * + * Normally, this is not called directly except by the GraphicsStateGuardian. + * It will be called in the draw thread. + */ void GraphicsEngine:: texture_uploaded(Texture *tex) { MutexHolder holder(_loaded_textures_lock); // We defer this until the end of the frame; multiple GSG's might be - // rendering the texture within the same frame, and we don't want to - // dump the texture image until they've all had a chance at it. + // rendering the texture within the same frame, and we don't want to dump + // the texture image until they've all had a chance at it. _loaded_textures.push_back(LoadedTexture()); LoadedTexture < = _loaded_textures.back(); lt._tex = tex; lt._image_modified = tex->get_image_modified(); -// Usually only called by DisplayRegion::do_cull. +// Usually only called by DisplayRegion::do_cull. } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_cull -// Access: Public, Static -// Description: Fires off a cull traversal using the indicated camera. -//////////////////////////////////////////////////////////////////// +/** + * Fires off a cull traversal using the indicated camera. + */ void GraphicsEngine:: do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg, Thread *current_thread) { @@ -1240,11 +1145,11 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, trav->set_view_frustum(NULL); if (view_frustum_cull) { - // If we're to be performing view-frustum culling, determine the - // bounding volume associated with the current viewing frustum. + // If we're to be performing view-frustum culling, determine the bounding + // volume associated with the current viewing frustum. - // First, we have to get the current viewing frustum, which comes - // from the lens. + // First, we have to get the current viewing frustum, which comes from the + // lens. PT(BoundingVolume) bv = scene_setup->get_cull_bounds(); if (bv != (BoundingVolume *)NULL && !bv->is_infinite() && @@ -1268,24 +1173,19 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::scene_root_func -// Access: Private, Static -// Description: This function is added to PandaNode::scene_root_func -// to implement PandaNode::is_scene_root(). -//////////////////////////////////////////////////////////////////// +/** + * This function is added to PandaNode::scene_root_func to implement + * PandaNode::is_scene_root(). + */ bool GraphicsEngine:: scene_root_func(const PandaNode *node) { return _global_ptr->is_scene_root(node); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::is_scene_root -// Access: Private -// Description: Returns true if the indicated node is known to be -// the render root of some active DisplayRegion -// associated with this GraphicsEngine, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated node is known to be the render root of some + * active DisplayRegion associated with this GraphicsEngine, false otherwise. + */ bool GraphicsEngine:: is_scene_root(const PandaNode *node) { Thread *current_thread = Thread::get_current_thread(); @@ -1328,16 +1228,12 @@ is_scene_root(const PandaNode *node) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::set_window_sort -// Access: Private -// Description: Changes the sort value of a particular window (or -// buffer) on the GraphicsEngine. This requires -// securing the mutex. -// -// Users shouldn't call this directly; use -// GraphicsOutput::set_sort() instead. -//////////////////////////////////////////////////////////////////// +/** + * Changes the sort value of a particular window (or buffer) on the + * GraphicsEngine. This requires securing the mutex. + * + * Users shouldn't call this directly; use GraphicsOutput::set_sort() instead. + */ void GraphicsEngine:: set_window_sort(GraphicsOutput *window, int sort) { ReMutexHolder holder(_lock); @@ -1345,15 +1241,12 @@ set_window_sort(GraphicsOutput *window, int sort) { _windows_sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::cull_and_draw_together -// Access: Private -// Description: This is called in the cull+draw thread by individual -// RenderThread objects during the frame rendering. It -// culls the geometry and immediately draws it, without -// first collecting it into bins. This is used when the -// threading model begins with the "-" character. -//////////////////////////////////////////////////////////////////// +/** + * This is called in the cull+draw thread by individual RenderThread objects + * during the frame rendering. It culls the geometry and immediately draws + * it, without first collecting it into bins. This is used when the threading + * model begins with the "-" character. + */ void GraphicsEngine:: cull_and_draw_together(const GraphicsEngine::Windows &wlist, Thread *current_thread) { @@ -1403,12 +1296,9 @@ cull_and_draw_together(const GraphicsEngine::Windows &wlist, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::cull_and_draw_together -// Access: Private -// Description: Called only from within the inner loop in -// cull_and_draw_together(), above. -//////////////////////////////////////////////////////////////////// +/** + * Called only from within the inner loop in cull_and_draw_together(), above. + */ void GraphicsEngine:: cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { @@ -1465,14 +1355,11 @@ cull_and_draw_together(GraphicsOutput *win, DisplayRegion *dr, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::cull_to_bins -// Access: Private -// Description: This is called in the cull thread by individual -// RenderThread objects during the frame rendering. It -// collects the geometry into bins in preparation for -// drawing. -//////////////////////////////////////////////////////////////////// +/** + * This is called in the cull thread by individual RenderThread objects during + * the frame rendering. It collects the geometry into bins in preparation for + * drawing. + */ void GraphicsEngine:: cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { PStatTimer timer(_cull_pcollector, current_thread); @@ -1480,8 +1367,8 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { _singular_warning_last_frame = _singular_warning_this_frame; _singular_warning_this_frame = false; - // Keep track of the cameras we have already used in this thread to - // render DisplayRegions. + // Keep track of the cameras we have already used in this thread to render + // DisplayRegions. typedef pair CullKey; typedef pmap AlreadyCulled; AlreadyCulled already_culled; @@ -1502,21 +1389,20 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { AlreadyCulled::iterator aci = already_culled.insert(AlreadyCulled::value_type(CullKey(camera, lens_index), (DisplayRegion *)NULL)).first; if ((*aci).second == NULL) { - // We have not used this camera already in this thread. - // Perform the cull operation. + // We have not used this camera already in this thread. Perform + // the cull operation. delete dr_reader; dr_reader = NULL; (*aci).second = dr; cull_to_bins(win, dr, current_thread); } else { - // We have already culled a scene using this camera in - // this thread, and now we're being asked to cull another - // scene using the same camera. (Maybe this represents - // two different DisplayRegions for the left and right - // channels of a stereo image.) Of course, the cull - // result will be the same, so just use the result from - // the other DisplayRegion. + // We have already culled a scene using this camera in this + // thread, and now we're being asked to cull another scene using + // the same camera. (Maybe this represents two different + // DisplayRegions for the left and right channels of a stereo + // image.) Of course, the cull result will be the same, so just + // use the result from the other DisplayRegion. DisplayRegion *other_dr = (*aci).second; dr->set_cull_result(other_dr->get_cull_result(current_thread), setup_scene(win->get_gsg(), dr_reader), @@ -1532,12 +1418,9 @@ cull_to_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::cull_to_bins -// Access: Private -// Description: Called only within the inner loop of cull_to_bins(), -// above. -//////////////////////////////////////////////////////////////////// +/** + * Called only within the inner loop of cull_to_bins(), above. + */ void GraphicsEngine:: cull_to_bins(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { GraphicsStateGuardian *gsg = win->get_gsg(); @@ -1585,15 +1468,11 @@ cull_to_bins(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { dr->set_cull_result(MOVE(cull_result), MOVE(scene_setup), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::draw_bins -// Access: Private -// Description: This is called in the draw thread by individual -// RenderThread objects during the frame rendering. It -// issues the graphics commands to draw the objects that -// have been collected into bins by a previous call to -// cull_to_bins(). -//////////////////////////////////////////////////////////////////// +/** + * This is called in the draw thread by individual RenderThread objects during + * the frame rendering. It issues the graphics commands to draw the objects + * that have been collected into bins by a previous call to cull_to_bins(). + */ void GraphicsEngine:: draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { nassertv(wlist.verify_list()); @@ -1608,8 +1487,8 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { GraphicsOutput *host = win->get_host(); if (host->flip_ready()) { { - // We can't use a PStatGPUTimer before begin_frame, so when using GPU - // timing, it is advisable to set auto-flip to #t. + // We can't use a PStatGPUTimer before begin_frame, so when using + // GPU timing, it is advisable to set auto-flip to #t. PStatTimer timer(GraphicsEngine::_flip_begin_pcollector, current_thread); host->begin_flip(); } @@ -1620,8 +1499,8 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } if (win->begin_frame(GraphicsOutput::FM_render, current_thread)) { - // We have to place this collector inside begin_frame, because - // we need a current context for PStatGPUTimer to work. + // We have to place this collector inside begin_frame, because we need + // a current context for PStatGPUTimer to work. { PStatGPUTimer timer(win->get_gsg(), win->get_draw_window_pcollector(), current_thread); win->clear(current_thread); @@ -1650,7 +1529,8 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { if (win->flip_ready()) { { - // begin_flip doesn't do anything interesting, let's not waste two timer queries on that. + // begin_flip doesn't do anything interesting, let's not waste + // two timer queries on that. PStatTimer timer(GraphicsEngine::_flip_begin_pcollector, current_thread); win->begin_flip(); } @@ -1677,13 +1557,10 @@ draw_bins(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::draw_bins -// Access: Private -// Description: This variant on draw_bins() is only called from -// draw_bins(), above. It draws the cull result for a -// particular DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * This variant on draw_bins() is only called from draw_bins(), above. It + * draws the cull result for a particular DisplayRegion. + */ void GraphicsEngine:: draw_bins(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { GraphicsStateGuardian *gsg = win->get_gsg(); @@ -1696,13 +1573,10 @@ draw_bins(GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { do_draw(cull_result, scene_setup, win, dr, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::make_contexts -// Access: Private -// Description: Called in the draw thread, this calls make_context() -// on each window on the list to guarantee its gsg and -// graphics context both get created. -//////////////////////////////////////////////////////////////////// +/** + * Called in the draw thread, this calls make_context() on each window on the + * list to guarantee its gsg and graphics context both get created. + */ void GraphicsEngine:: make_contexts(const GraphicsEngine::Windows &wlist, Thread *current_thread) { Windows::const_iterator wi; @@ -1714,30 +1588,26 @@ make_contexts(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::process_events -// Access: Private -// Description: This is called by the RenderThread object to process -// all the windows events (resize, etc.) for the given -// list of windows. This is run in the window thread. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the RenderThread object to process all the windows events + * (resize, etc.) for the given list of windows. This is run in the window + * thread. + */ void GraphicsEngine:: process_events(const GraphicsEngine::Windows &wlist, Thread *current_thread) { - // We're not using a vector iterator here, since it's possible that - // the window list changes in an event, which would invalidate the - // iterator and cause a crash. + // We're not using a vector iterator here, since it's possible that the + // window list changes in an event, which would invalidate the iterator and + // cause a crash. for (size_t i = 0; i < wlist.size(); ++i) { wlist[i]->process_events(); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::flip_windows -// Access: Private -// Description: This is called by the RenderThread object to flip the -// buffers for all of the non-single-buffered windows in -// the given list. This is run in the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the RenderThread object to flip the buffers for all of + * the non-single-buffered windows in the given list. This is run in the draw + * thread. + */ void GraphicsEngine:: flip_windows(const GraphicsEngine::Windows &wlist, Thread *current_thread) { size_t num_windows = wlist.size(); @@ -1765,13 +1635,11 @@ flip_windows(const GraphicsEngine::Windows &wlist, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::ready_flip_windows -// Access: Private -// Description: This is called by the RenderThread object to flip the -// buffers for all of the non-single-buffered windows in -// the given list. This is run in the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the RenderThread object to flip the buffers for all of + * the non-single-buffered windows in the given list. This is run in the draw + * thread. + */ void GraphicsEngine:: ready_flip_windows(const GraphicsEngine::Windows &wlist, Thread *current_thread) { Windows::const_iterator wi; @@ -1784,12 +1652,10 @@ ready_flip_windows(const GraphicsEngine::Windows &wlist, Thread *current_thread) } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_sync_frame -// Access: Private -// Description: The implementation of sync_frame(). We assume _lock -// is already held before this method is called. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of sync_frame(). We assume _lock is already held before + * this method is called. + */ void GraphicsEngine:: do_sync_frame(Thread *current_thread) { nassertv(_lock.debug_is_locked()); @@ -1799,8 +1665,8 @@ do_sync_frame(Thread *current_thread) { nassertv(_flip_state == FS_draw); - // Wait for all the threads to finish their current frame. Grabbing - // and releasing the mutex should achieve that. + // Wait for all the threads to finish their current frame. Grabbing and + // releasing the mutex should achieve that. Threads::const_iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { RenderThread *thread = (*ti).second; @@ -1811,12 +1677,10 @@ do_sync_frame(Thread *current_thread) { _flip_state = FS_sync; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_ready_flip -// Access: Private -// Description: Wait until all draw calls have finished drawing and -// the frame is ready to flip -//////////////////////////////////////////////////////////////////// +/** + * Wait until all draw calls have finished drawing and the frame is ready to + * flip + */ void GraphicsEngine:: do_ready_flip(Thread *current_thread) { nassertv(_lock.debug_is_locked()); @@ -1826,8 +1690,8 @@ do_ready_flip(Thread *current_thread) { nassertv(_flip_state == FS_draw); - // Wait for all the threads to finish their current frame. Grabbing - // and releasing the mutex should achieve that. + // Wait for all the threads to finish their current frame. Grabbing and + // releasing the mutex should achieve that. Threads::const_iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { RenderThread *thread = (*ti).second; @@ -1838,12 +1702,10 @@ do_ready_flip(Thread *current_thread) { _flip_state = FS_sync; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_flip_frame -// Access: Private -// Description: The implementation of flip_frame(). We assume _lock -// is already held before this method is called. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of flip_frame(). We assume _lock is already held before + * this method is called. + */ void GraphicsEngine:: do_flip_frame(Thread *current_thread) { nassertv(_lock.debug_is_locked()); @@ -1854,8 +1716,8 @@ do_flip_frame(Thread *current_thread) { nassertv(_flip_state == FS_draw || _flip_state == FS_sync); // First, wait for all the threads to finish their current frame, if - // necessary. Grabbing the mutex (and waiting for TS_wait) should - // achieve that. + // necessary. Grabbing the mutex (and waiting for TS_wait) should achieve + // that. { PStatTimer timer(_wait_pcollector, current_thread); Threads::const_iterator ti; @@ -1886,23 +1748,19 @@ do_flip_frame(Thread *current_thread) { _flip_state = FS_flip; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::setup_scene -// Access: Private -// Description: Returns a new SceneSetup object appropriate for -// rendering the scene from the indicated camera, or -// NULL if the scene should not be rendered for some -// reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new SceneSetup object appropriate for rendering the scene from + * the indicated camera, or NULL if the scene should not be rendered for some + * reason. + */ PT(SceneSetup) GraphicsEngine:: setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { Thread *current_thread = dr->get_current_thread(); PStatTimer timer(_cull_setup_pcollector, current_thread); GraphicsOutput *window = dr->get_window(); - // The window pointer shouldn't be NULL, since we presumably got to - // this particular DisplayRegion by walking through a list on a - // window. + // The window pointer shouldn't be NULL, since we presumably got to this + // particular DisplayRegion by walking through a list on a window. nassertr(window != (GraphicsOutput *)NULL, NULL); NodePath camera = dr->get_camera(); @@ -1929,21 +1787,21 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { NodePath scene_root = camera_node->get_scene(); if (scene_root.is_empty()) { - // If there's no explicit scene specified, use whatever scene the - // camera is parented within. This is the normal and preferred - // case; the use of an explicit scene is now deprecated. + // If there's no explicit scene specified, use whatever scene the camera + // is parented within. This is the normal and preferred case; the use of + // an explicit scene is now deprecated. scene_root = camera.get_top(current_thread); } PT(SceneSetup) scene_setup = new SceneSetup; - // We will need both the camera transform (the net transform to the - // camera from the scene) and the world transform (the camera - // transform inverse, or the net transform to the scene from the - // camera). These are actually defined from the parent of the - // scene_root, because the scene_root's own transform is immediately - // applied to these during rendering. (Normally, the parent of the - // scene_root is the empty NodePath, although it need not be.) + // We will need both the camera transform (the net transform to the camera + // from the scene) and the world transform (the camera transform inverse, or + // the net transform to the scene from the camera). These are actually + // defined from the parent of the scene_root, because the scene_root's own + // transform is immediately applied to these during rendering. (Normally, + // the parent of the scene_root is the empty NodePath, although it need not + // be.) NodePath scene_parent = scene_root.get_parent(current_thread); CPT(TransformState) camera_transform = camera.get_transform(scene_parent, current_thread); CPT(TransformState) world_transform = scene_parent.get_transform(camera, current_thread); @@ -1973,13 +1831,13 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { CPT(RenderState) initial_state = camera_node->get_initial_state(); if (window->get_inverted()) { - // If the window is to be inverted, we must set the inverted flag - // on the SceneSetup object, so that the GSG will be able to - // invert the projection matrix at the last minute. + // If the window is to be inverted, we must set the inverted flag on the + // SceneSetup object, so that the GSG will be able to invert the + // projection matrix at the last minute. scene_setup->set_inverted(true); - // This also means we need to globally invert the sense of polygon - // vertex ordering. + // This also means we need to globally invert the sense of polygon vertex + // ordering. initial_state = initial_state->compose(get_invert_polygon_state()); } @@ -1999,10 +1857,10 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { CPT(TransformState) cs_world_transform = cs_transform->compose(world_transform); scene_setup->set_cs_world_transform(cs_world_transform); - // Make sure that the GSG has a ShaderGenerator for the munger - // to use. We have to do this here because the ShaderGenerator - // needs a host window pointer. Hopefully we'll be able to - // eliminate that requirement in the future. + // Make sure that the GSG has a ShaderGenerator for the munger to use. We + // have to do this here because the ShaderGenerator needs a host window + // pointer. Hopefully we'll be able to eliminate that requirement in the + // future. #ifdef HAVE_CG if (gsg->get_shader_generator() == NULL) { gsg->set_shader_generator(new ShaderGenerator(gsg, window)); @@ -2012,11 +1870,9 @@ setup_scene(GraphicsStateGuardian *gsg, DisplayRegionPipelineReader *dr) { return scene_setup; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_draw -// Access: Private -// Description: Draws the previously-culled scene. -//////////////////////////////////////////////////////////////////// +/** + * Draws the previously-culled scene. + */ void GraphicsEngine:: do_draw(CullResult *cull_result, SceneSetup *scene_setup, GraphicsOutput *win, DisplayRegion *dr, Thread *current_thread) { @@ -2059,12 +1915,11 @@ do_draw(CullResult *cull_result, SceneSetup *scene_setup, // Nothing to see here. } else if (dr->is_stereo()) { - // We don't actually draw the stereo DisplayRegions. These are - // just placeholders; we draw the individual left and right eyes - // instead. (We might still clear the stereo DisplayRegions, - // though, since it's probably faster to clear right and left - // channels in one pass, than to clear them in two separate - // passes.) + // We don't actually draw the stereo DisplayRegions. These are just + // placeholders; we draw the individual left and right eyes instead. (We + // might still clear the stereo DisplayRegions, though, since it's + // probably faster to clear right and left channels in one pass, than to + // clear them in two separate passes.) } else if (!gsg->set_scene(scene_setup)) { // The scene or lens is inappropriate somehow. @@ -2079,15 +1934,11 @@ do_draw(CullResult *cull_result, SceneSetup *scene_setup, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_add_window -// Access: Private -// Description: An internal function called by make_window() and -// make_buffer() and similar functions to add the -// newly-created GraphicsOutput object to the engine's -// list of windows, and to request that the window be -// opened. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by make_window() and make_buffer() and similar + * functions to add the newly-created GraphicsOutput object to the engine's + * list of windows, and to request that the window be opened. + */ void GraphicsEngine:: do_add_window(GraphicsOutput *window, const GraphicsThreadingModel &threading_model) { @@ -2095,9 +1946,8 @@ do_add_window(GraphicsOutput *window, ReMutexHolder holder(_lock); nassertv(window->get_engine() == this); - // We have a special counter that is unique per window that allows - // us to assure that recently-added windows end up on the end of the - // list. + // We have a special counter that is unique per window that allows us to + // assure that recently-added windows end up on the end of the list. window->_internal_sort_index = _window_sort_index; ++_window_sort_index; @@ -2118,15 +1968,15 @@ do_add_window(GraphicsOutput *window, cull->add_window(cull->_cdraw, window); } - // Ask the pipe which thread it prefers to run its windowing - // commands in (the "window thread"). This is the thread that - // handles the commands to open, resize, etc. the window. X - // requires this to be done in the app thread (along with all the - // other windows, since X is strictly single-threaded), but Windows - // requires this to be done in draw (because once an OpenGL context - // has been bound in a given thread, it cannot subsequently be bound - // in any other thread, and we have to bind a context in - // open_window()). +/* + * Ask the pipe which thread it prefers to run its windowing commands in (the + * "window thread"). This is the thread that handles the commands to open, + * resize, etc. the window. X requires this to be done in the app thread + * (along with all the other windows, since X is strictly single-threaded), + * but Windows requires this to be done in draw (because once an OpenGL + * context has been bound in a given thread, it cannot subsequently be bound + * in any other thread, and we have to bind a context in open_window()). + */ switch (window->get_pipe()->get_preferred_window_thread()) { case GraphicsPipe::PWT_app: @@ -2147,14 +1997,11 @@ do_add_window(GraphicsOutput *window, _needs_open_windows = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_add_gsg -// Access: Private -// Description: An internal function called by make_output to add -// the newly-created gsg object to the engine's -// list of gsg's. It also adjusts various config -// variables based on the gsg's capabilities. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by make_output to add the newly-created gsg + * object to the engine's list of gsg's. It also adjusts various config + * variables based on the gsg's capabilities. + */ void GraphicsEngine:: do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe, const GraphicsThreadingModel &threading_model) { @@ -2176,14 +2023,11 @@ do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe, draw->add_gsg(gsg); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_remove_window -// Access: Private -// Description: An internal function called by remove_window() and -// remove_all_windows() to actually remove the indicated -// window from all relevant structures, except the -// _windows list itself. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by remove_window() and remove_all_windows() to + * actually remove the indicated window from all relevant structures, except + * the _windows list itself. + */ void GraphicsEngine:: do_remove_window(GraphicsOutput *window, Thread *current_thread) { nassertv(window != NULL); @@ -2202,8 +2046,8 @@ do_remove_window(GraphicsOutput *window, Thread *current_thread) { thread->remove_window(window); } - // If the window happened to be controlled by the app thread, we - // might as well close it now rather than waiting for next frame. + // If the window happened to be controlled by the app thread, we might as + // well close it now rather than waiting for next frame. _app.do_pending(this, current_thread); if (display_cat.is_debug()) { @@ -2212,13 +2056,10 @@ do_remove_window(GraphicsOutput *window, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::do_resort_windows -// Access: Private -// Description: Resorts all of the Windows lists. This may need to -// be done if one or more of the windows' sort -// properties has changed. -//////////////////////////////////////////////////////////////////// +/** + * Resorts all of the Windows lists. This may need to be done if one or more + * of the windows' sort properties has changed. + */ void GraphicsEngine:: do_resort_windows() { _windows_sorted = true; @@ -2233,65 +2074,47 @@ do_resort_windows() { _windows.sort(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::auto_adjust_capabilities -// Access: Private -// Description: Video card capability flags are stored on a -// per-gsg basis. However, there are a few cases -// where panda needs to know not the capabilities -// of an individual GSG, but rather, the -// collective capabilities of all the GSGs. -// -// Non-power-of-two (NPOT) texture support is the -// classic example. Panda makes a single global -// decision to either create NPOT textures, or not. -// Therefore, it doesn't need to know whether one GSG -// supports NPOT textures. It needs to know whether ALL -// the GSGs support NPOT textures. -// -// The purpose of this routine is to maintain global -// capability flags that summarize the collective -// capabilities of the computer as a whole. -// -// These global capability flags are initialized from -// config variables. Then, they can be auto-reconfigured -// using built-in heuristic mechanisms if the user so -// desires. Whether auto-reconfiguration is enabled or -// not, the configured values are checked against -// the actual capabilities of the machine and error -// messages will be printed if there is a mismatch. -// -//////////////////////////////////////////////////////////////////// +/** + * Video card capability flags are stored on a per-gsg basis. However, there + * are a few cases where panda needs to know not the capabilities of an + * individual GSG, but rather, the collective capabilities of all the GSGs. + * + * Non-power-of-two (NPOT) texture support is the classic example. Panda + * makes a single global decision to either create NPOT textures, or not. + * Therefore, it doesn't need to know whether one GSG supports NPOT textures. + * It needs to know whether ALL the GSGs support NPOT textures. + * + * The purpose of this routine is to maintain global capability flags that + * summarize the collective capabilities of the computer as a whole. + * + * These global capability flags are initialized from config variables. Then, + * they can be auto-reconfigured using built-in heuristic mechanisms if the + * user so desires. Whether auto-reconfiguration is enabled or not, the + * configured values are checked against the actual capabilities of the + * machine and error messages will be printed if there is a mismatch. + * + */ void GraphicsEngine:: auto_adjust_capabilities(GraphicsStateGuardian *gsg) { - // The rule we use when auto-reconfiguring is as follows. The - // global capabilities must initially be set to conservative - // values. When the first GSG comes into existence, its - // capabilities will be checked, and the global capabilities - // may be elevated to more aggressive values. - // - // At first glance, this might seem backward, and it might seem - // better to do it the other way: start with all global capabilities - // aggressively set, and then disable capabilities when you discover - // a gsg that doesn't support them. - // - // However, that approach doesn't work, because once a global - // capability is enabled, there is no going back. If - // textures_power_2 has ever been set to 'none', there may be NPOT - // textures already floating about the system. Ie, it's too late: - // you can't turn these global capability flags off, once they've - // been turned on. - // - // That's why we have to start with conservative settings, and then - // elevate those settings to more aggressive values later when - // we're fairly sure it's OK to do so. - // - // For each global capability, we must: - // 1. Make sure the initial setting is conservative. - // 2. Possibly elevate to a more aggressive value. - // 3. Check that we haven't over-elevated. - // +/* + * The rule we use when auto-reconfiguring is as follows. The global + * capabilities must initially be set to conservative values. When the first + * GSG comes into existence, its capabilities will be checked, and the global + * capabilities may be elevated to more aggressive values. At first glance, + * this might seem backward, and it might seem better to do it the other way: + * start with all global capabilities aggressively set, and then disable + * capabilities when you discover a gsg that doesn't support them. However, + * that approach doesn't work, because once a global capability is enabled, + * there is no going back. If textures_power_2 has ever been set to 'none', + * there may be NPOT textures already floating about the system. Ie, it's too + * late: you can't turn these global capability flags off, once they've been + * turned on. That's why we have to start with conservative settings, and + * then elevate those settings to more aggressive values later when we're + * fairly sure it's OK to do so. For each global capability, we must: 1. Make + * sure the initial setting is conservative. 2. Possibly elevate to a more + * aggressive value. 3. Check that we haven't over-elevated. + */ if (textures_auto_power_2 && (textures_power_2 == ATS_none)) { display_cat.error() @@ -2338,22 +2161,19 @@ auto_adjust_capabilities(GraphicsStateGuardian *gsg) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::terminate_threads -// Access: Private -// Description: Signals our child threads to terminate and waits for -// them to clean up. -//////////////////////////////////////////////////////////////////// +/** + * Signals our child threads to terminate and waits for them to clean up. + */ void GraphicsEngine:: terminate_threads(Thread *current_thread) { ReMutexHolder holder(_lock, current_thread); - // We spend almost our entire time in this method just waiting for - // threads. Time it appropriately. + // We spend almost our entire time in this method just waiting for threads. + // Time it appropriately. PStatTimer timer(_wait_pcollector, current_thread); - // First, wait for all the threads to finish their current frame. - // Grabbing the mutex should achieve that. + // First, wait for all the threads to finish their current frame. Grabbing + // the mutex should achieve that. Threads::const_iterator ti; for (ti = _threads.begin(); ti != _threads.end(); ++ti) { RenderThread *thread = (*ti).second; @@ -2379,13 +2199,10 @@ terminate_threads(Thread *current_thread) { #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::pstats_count_cycler_type -// Access: Private, Static -// Description: A callback function for -// Pipeline::iterate_all_cycler_types() to report the -// cycler types to PStats. -//////////////////////////////////////////////////////////////////// +/** + * A callback function for Pipeline::iterate_all_cycler_types() to report the + * cycler types to PStats. + */ void GraphicsEngine:: pstats_count_cycler_type(TypeHandle type, int count, void *data) { GraphicsEngine *self = (GraphicsEngine *)data; @@ -2399,13 +2216,10 @@ pstats_count_cycler_type(TypeHandle type, int count, void *data) { #endif // DO_PSTATS #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::pstats_count_dirty_cycler_type -// Access: Private, Static -// Description: A callback function for -// Pipeline::iterate_dirty_cycler_types() to report the -// cycler types to PStats. -//////////////////////////////////////////////////////////////////// +/** + * A callback function for Pipeline::iterate_dirty_cycler_types() to report + * the cycler types to PStats. + */ void GraphicsEngine:: pstats_count_dirty_cycler_type(TypeHandle type, int count, void *data) { GraphicsEngine *self = (GraphicsEngine *)data; @@ -2418,18 +2232,15 @@ pstats_count_dirty_cycler_type(TypeHandle type, int count, void *data) { } #endif // DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_invert_polygon_state -// Access: Protected, Static -// Description: Returns a RenderState for inverting the sense of -// polygon vertex ordering: if the scene graph specifies -// a clockwise ordering, this changes it to -// counterclockwise, and vice-versa. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for inverting the sense of polygon vertex ordering: + * if the scene graph specifies a clockwise ordering, this changes it to + * counterclockwise, and vice-versa. + */ const RenderState *GraphicsEngine:: get_invert_polygon_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make(CullFaceAttrib::make_reverse()); @@ -2438,18 +2249,14 @@ get_invert_polygon_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::get_window_renderer -// Access: Private -// Description: Returns the WindowRenderer with the given name. -// Creates a new RenderThread if there is no such thread -// already. The pipeline_stage number specifies the -// pipeline stage that will be assigned to the thread -// (unless was previously given a higher stage). -// -// You must already be holding the lock before calling -// this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WindowRenderer with the given name. Creates a new RenderThread + * if there is no such thread already. The pipeline_stage number specifies + * the pipeline stage that will be assigned to the thread (unless was + * previously given a higher stage). + * + * You must already be holding the lock before calling this method. + */ GraphicsEngine::WindowRenderer *GraphicsEngine:: get_window_renderer(const string &name, int pipeline_stage) { nassertr(_lock.debug_is_locked(), NULL); @@ -2476,49 +2283,39 @@ get_window_renderer(const string &name, int pipeline_stage) { return thread.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsEngine::WindowRenderer:: WindowRenderer(const string &name) : _wl_lock(string("GraphicsEngine::WindowRenderer::_wl_lock ") + name) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::add_gsg -// Access: Public -// Description: Adds a new GSG to the _gsg list, if it is not already -// there. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new GSG to the _gsg list, if it is not already there. + */ void GraphicsEngine::WindowRenderer:: add_gsg(GraphicsStateGuardian *gsg) { LightReMutexHolder holder(_wl_lock); _gsgs.insert(gsg); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::add_window -// Access: Public -// Description: Adds a new window to the indicated list, which should -// be a member of the WindowRenderer. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new window to the indicated list, which should be a member of the + * WindowRenderer. + */ void GraphicsEngine::WindowRenderer:: add_window(Windows &wlist, GraphicsOutput *window) { LightReMutexHolder holder(_wl_lock); wlist.insert(window); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::remove_window -// Access: Public -// Description: Immediately removes the indicated window from all -// lists. If the window is currently open and is -// already on the _window list, moves it to the _pending_close -// list for later closure. -//////////////////////////////////////////////////////////////////// +/** + * Immediately removes the indicated window from all lists. If the window is + * currently open and is already on the _window list, moves it to the + * _pending_close list for later closure. + */ void GraphicsEngine::WindowRenderer:: remove_window(GraphicsOutput *window) { nassertv(window != NULL); @@ -2533,16 +2330,15 @@ remove_window(GraphicsOutput *window) { wi = _window.find(ptwin); if (wi != _window.end()) { - // The window is on our _window list, meaning its open/close - // operations (among other window ops) are serviced by this - // thread. + // The window is on our _window list, meaning its openclose operations + // (among other window ops) are serviced by this thread. // Make sure the window isn't about to request itself open. ptwin->request_close(); - // If the window is already open, move it to the _pending_close list so - // it can be closed later. We can't close it immediately, because - // we might not have been called from the subthread. + // If the window is already open, move it to the _pending_close list so it + // can be closed later. We can't close it immediately, because we might + // not have been called from the subthread. if (ptwin->is_valid()) { _pending_close.push_back(ptwin); } @@ -2551,12 +2347,9 @@ remove_window(GraphicsOutput *window) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::resort_windows -// Access: Public -// Description: Resorts all the lists of windows, assuming they may -// have become unsorted. -//////////////////////////////////////////////////////////////////// +/** + * Resorts all the lists of windows, assuming they may have become unsorted. + */ void GraphicsEngine::WindowRenderer:: resort_windows() { LightReMutexHolder holder(_wl_lock); @@ -2588,14 +2381,11 @@ resort_windows() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_frame -// Access: Public -// Description: Executes one stage of the pipeline for the current -// thread: calls cull on all windows that are on the -// cull list for this thread, draw on all the windows on -// the draw list, etc. -//////////////////////////////////////////////////////////////////// +/** + * Executes one stage of the pipeline for the current thread: calls cull on + * all windows that are on the cull list for this thread, draw on all the + * windows on the draw list, etc. + */ void GraphicsEngine::WindowRenderer:: do_frame(GraphicsEngine *engine, Thread *current_thread) { PStatTimer timer(engine->_do_frame_pcollector, current_thread); @@ -2606,8 +2396,8 @@ do_frame(GraphicsEngine *engine, Thread *current_thread) { engine->draw_bins(_draw, current_thread); engine->process_events(_window, current_thread); - // If any GSG's on the list have no more outstanding pointers, clean - // them up. (We are in the draw thread for all of these GSG's.) + // If any GSG's on the list have no more outstanding pointers, clean them + // up. (We are in the draw thread for all of these GSG's.) if (any_done_gsgs()) { GSGs new_gsgs; GSGs::iterator gi; @@ -2627,15 +2417,12 @@ do_frame(GraphicsEngine *engine, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_windows -// Access: Public -// Description: Attempts to fully open or close any windows or -// buffers associated with this thread, but does not -// otherwise perform any rendering. (Normally, this -// step is handled during do_frame(); call this method -// only if you want these things to open immediately.) -//////////////////////////////////////////////////////////////////// +/** + * Attempts to fully open or close any windows or buffers associated with this + * thread, but does not otherwise perform any rendering. (Normally, this step + * is handled during do_frame(); call this method only if you want these + * things to open immediately.) + */ void GraphicsEngine::WindowRenderer:: do_windows(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); @@ -2646,12 +2433,9 @@ do_windows(GraphicsEngine *engine, Thread *current_thread) { engine->make_contexts(_draw, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_flip -// Access: Public -// Description: Flips the windows as appropriate for the current -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Flips the windows as appropriate for the current thread. + */ void GraphicsEngine::WindowRenderer:: do_flip(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); @@ -2659,12 +2443,9 @@ do_flip(GraphicsEngine *engine, Thread *current_thread) { engine->flip_windows(_draw, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_ready_flip -// Access: Public -// Description: Prepares windows for flipping by waiting until all draw -// calls are finished -//////////////////////////////////////////////////////////////////// +/** + * Prepares windows for flipping by waiting until all draw calls are finished + */ void GraphicsEngine::WindowRenderer:: do_ready_flip(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); @@ -2673,11 +2454,9 @@ do_ready_flip(GraphicsEngine *engine, Thread *current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_close -// Access: Public -// Description: Closes all the windows on the _window list. -//////////////////////////////////////////////////////////////////// +/** + * Closes all the windows on the _window list. + */ void GraphicsEngine::WindowRenderer:: do_close(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); @@ -2705,12 +2484,10 @@ do_close(GraphicsEngine *engine, Thread *current_thread) { _gsgs.swap(new_gsgs); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::do_pending -// Access: Public -// Description: Actually closes any windows that were recently -// removed from the WindowRenderer. -//////////////////////////////////////////////////////////////////// +/** + * Actually closes any windows that were recently removed from the + * WindowRenderer. + */ void GraphicsEngine::WindowRenderer:: do_pending(GraphicsEngine *engine, Thread *current_thread) { LightReMutexHolder holder(_wl_lock); @@ -2721,9 +2498,9 @@ do_pending(GraphicsEngine *engine, Thread *current_thread) { << "_pending_close.size() = " << _pending_close.size() << "\n"; } - // Close any windows that were pending closure. Carefully protect - // against recursive entry to this function by swapping the vector - // to a local copy first. + // Close any windows that were pending closure. Carefully protect against + // recursive entry to this function by swapping the vector to a local copy + // first. Windows::iterator wi; Windows pending_close; _pending_close.swap(pending_close); @@ -2734,14 +2511,11 @@ do_pending(GraphicsEngine *engine, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::WindowRenderer::any_done_gsgs -// Access: Public -// Description: Returns true if any of the GSG's on this thread's -// draw list are done (they have no outstanding pointers -// other than this one), or false if all of them are -// still good. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the GSG's on this thread's draw list are done (they + * have no outstanding pointers other than this one), or false if all of them + * are still good. + */ bool GraphicsEngine::WindowRenderer:: any_done_gsgs() const { GSGs::const_iterator gi; @@ -2754,11 +2528,9 @@ any_done_gsgs() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::RenderThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsEngine::RenderThread:: RenderThread(const string &name, GraphicsEngine *engine) : Thread(name, "Main"), @@ -2771,13 +2543,10 @@ RenderThread(const string &name, GraphicsEngine *engine) : _thread_state = TS_wait; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsEngine::RenderThread::thread_main -// Access: Public, Virtual -// Description: The main loop for a particular render thread. The -// thread will process whatever cull or draw windows it -// has assigned to it. -//////////////////////////////////////////////////////////////////// +/** + * The main loop for a particular render thread. The thread will process + * whatever cull or draw windows it has assigned to it. + */ void GraphicsEngine::RenderThread:: thread_main() { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 8d65f9faba..7945b6d039 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -1,16 +1,15 @@ -// Filename: graphicsEngine.h -// Created by: drose (24Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsEngine.h + * @author drose + * @date 2002-02-24 + */ #ifndef GRAPHICSENGINE_H #define GRAPHICSENGINE_H @@ -40,21 +39,17 @@ class GraphicsPipe; class FrameBufferProperties; class Texture; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsEngine -// Description : This class is the main interface to controlling the -// render process. There is typically only one -// GraphicsEngine in an application, and it synchronizes -// rendering to all all of the active windows; although -// it is possible to have multiple GraphicsEngine -// objects if multiple synchronicity groups are -// required. -// -// The GraphicsEngine is responsible for managing the -// various cull and draw threads. The application -// simply calls engine->render_frame() and considers it -// done. -//////////////////////////////////////////////////////////////////// +/** + * This class is the main interface to controlling the render process. There + * is typically only one GraphicsEngine in an application, and it synchronizes + * rendering to all all of the active windows; although it is possible to have + * multiple GraphicsEngine objects if multiple synchronicity groups are + * required. + * + * The GraphicsEngine is responsible for managing the various cull and draw + * threads. The application simply calls engine->render_frame() and considers + * it done. + */ class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount { PUBLISHED: GraphicsEngine(Pipeline *pipeline = NULL); @@ -188,83 +183,80 @@ private: static const RenderState *get_invert_polygon_state(); - // The WindowRenderer class records the stages of the pipeline that - // each thread (including the main thread, a.k.a. "app") should - // process, and the list of windows for each stage. + // The WindowRenderer class records the stages of the pipeline that each + // thread (including the main thread, a.k.a. "app") should process, and the + // list of windows for each stage. - // There is one WindowRenderer instance for app, and another - // instance for each thread (the thread-specific WindowRenderers are - // actually instances of RenderThread, below, which inherits from - // WindowRenderer). + // There is one WindowRenderer instance for app, and another instance for + // each thread (the thread-specific WindowRenderers are actually instances + // of RenderThread, below, which inherits from WindowRenderer). // The idea is that each window is associated with one or more - // WindowRenderer objects, according to the threads in which its - // rendering tasks (window, cull, and draw) are divided into. + // WindowRenderer objects, according to the threads in which its rendering + // tasks (window, cull, and draw) are divided into. - // The "window" task is responsible for doing any updates to the - // window itself, such as size and placement, and is wholly - // responsible for any API calls to the windowing system itself, - // unrelated to OpenGL-type calls. This is normally done in app - // (the design of X-Windows is such that all X calls must be issued - // in the same thread). + // The "window" task is responsible for doing any updates to the window + // itself, such as size and placement, and is wholly responsible for any API + // calls to the windowing system itself, unrelated to OpenGL-type calls. + // This is normally done in app (the design of X-Windows is such that all X + // calls must be issued in the same thread). - // The "cull" task is responsible for crawling through the scene - // graph and discovering all of the Geoms that are within the - // viewing frustum. It assembles all such Geoms, along with their - // computed net state and transform, in a linked list of - // CullableObjects, which it stores for the "draw" task, next. + // The "cull" task is responsible for crawling through the scene graph and + // discovering all of the Geoms that are within the viewing frustum. It + // assembles all such Geoms, along with their computed net state and + // transform, in a linked list of CullableObjects, which it stores for the + // "draw" task, next. // The "draw" task is responsible for walking through the list of - // CullableObjects recorded by the cull task, and issuing the - // appropriate graphics commands to draw them. + // CullableObjects recorded by the cull task, and issuing the appropriate + // graphics commands to draw them. - // There is an additional task, not often used, called "cdraw". - // This task, if activated, will crawl through the scene graph and - // issue graphics commands immediately, as each Geom is discovered. - // It is only rarely used because it cannot perform sorting beyond - // basic scene graph order, making it less useful than a separate - // cull and draw task. + // There is an additional task, not often used, called "cdraw". This task, + // if activated, will crawl through the scene graph and issue graphics + // commands immediately, as each Geom is discovered. It is only rarely used + // because it cannot perform sorting beyond basic scene graph order, making + // it less useful than a separate cull and draw task. - // It is possible for all three of the normal tasks: window, cull, - // and draw, to be handled by the same thread. This is the normal, - // single-threaded model: all tasks are handled by the app thread. - // In this case, the window will be added to _app's _window, _cull, - // and _draw lists. + // It is possible for all three of the normal tasks: window, cull, and draw, + // to be handled by the same thread. This is the normal, single-threaded + // model: all tasks are handled by the app thread. In this case, the window + // will be added to _app's _window, _cull, and _draw lists. - // On the other hand, a window's tasks may also be distributed among - // as many as three threads. For instance, if the window is listed - // on _app's _window list, but on thread A's _cull list, and thread - // B's _draw list, then the window task will be handled in the app - // thread, while the cull task will be handled by thread A, and the - // draw task will be handled (in parallel) by thread B. (In order - // for this to work, it will be necessary that thread A and B are - // configured to view different stages of the graphics pipeline. - // This is a more advanced topic than there is room to discuss in - // this comment.) +/* + * On the other hand, a window's tasks may also be distributed among as many + * as three threads. For instance, if the window is listed on _app's _window + * list, but on thread A's _cull list, and thread B's _draw list, then the + * window task will be handled in the app thread, while the cull task will be + * handled by thread A, and the draw task will be handled (in parallel) by + * thread B. (In order for this to work, it will be necessary that thread A + * and B are configured to view different stages of the graphics pipeline. + * This is a more advanced topic than there is room to discuss in this + * comment.) + */ - // Manipulation of the various window lists in each WindowRenderer - // object is always performed in the app thread. The auxiliary - // threads are slaves to the app thread, and they can only perform - // one of a handful of specified tasks, none of which includes - // adding or removing windows from its lists. The full set of tasks - // that a WindowRenderer may perform is enumerated in ThreadState, - // above; see RenderThread::thread_main(). + // Manipulation of the various window lists in each WindowRenderer object is + // always performed in the app thread. The auxiliary threads are slaves to + // the app thread, and they can only perform one of a handful of specified + // tasks, none of which includes adding or removing windows from its lists. + // The full set of tasks that a WindowRenderer may perform is enumerated in + // ThreadState, above; see RenderThread::thread_main(). - // There is a pair of condition variables for each thread, _cv_start - // and _cv_done, that is used to synchronize requests made by app to - // a particular thread. The usual procedure to request a thread to - // perform a particular task is the following: the app thread waits - // on the thread's _cv_done variable, stores the value corresponding - // to the desired task in the thread's _thread_state value, then - // signals the thread's _cv_start variable. The thread, in turn, - // will perform its requested task, set its _thread_state to - // TS_wait, and signal _cv_done. See examples in the code, - // e.g. open_windows(), for more details on this process. +/* + * There is a pair of condition variables for each thread, _cv_start and + * _cv_done, that is used to synchronize requests made by app to a particular + * thread. The usual procedure to request a thread to perform a particular + * task is the following: the app thread waits on the thread's _cv_done + * variable, stores the value corresponding to the desired task in the + * thread's _thread_state value, then signals the thread's _cv_start variable. + * The thread, in turn, will perform its requested task, set its _thread_state + * to TS_wait, and signal _cv_done. See examples in the code, e.g. + * open_windows(), for more details on this process. + */ - // It is of course not necessary to signal any threads in order to - // perform tasks listed in the _app WindowRenderer. For this object - // only, we simply call the appropriate methods on _app when we want - // the tasks to be performed. + // It is of course not necessary to signal any threads in order to perform + // tasks listed in the _app WindowRenderer. For this object only, we simply + // call the appropriate methods on _app when we want the tasks to be + // performed. class WindowRenderer { public: @@ -413,4 +405,3 @@ private: #include "graphicsEngine.I" #endif - diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index b24390146b..40a90af57e 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -1,114 +1,88 @@ -// Filename: graphicsOutput.I -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutput.I + * @author drose + * @date 2004-02-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_gsg -// Access: Published -// Description: Returns the GSG that is associated with this window. -// There is a one-to-one association between windows and -// GSG's. -// -// This may return NULL if the graphics context has not -// yet been created for the window, e.g. before the -// first frame has rendered; or after the window has -// been closed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GSG that is associated with this window. There is a one-to-one + * association between windows and GSG's. + * + * This may return NULL if the graphics context has not yet been created for + * the window, e.g. before the first frame has rendered; or after the window + * has been closed. + */ INLINE GraphicsStateGuardian *GraphicsOutput:: get_gsg() const { return _gsg; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_pipe -// Access: Published -// Description: Returns the GraphicsPipe that this window is -// associated with. It is possible that the -// GraphicsPipe might have been deleted while an -// outstanding PT(GraphicsOutput) prevented all of its -// children windows from also being deleted; in this -// unlikely case, get_pipe() may return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsPipe that this window is associated with. It is + * possible that the GraphicsPipe might have been deleted while an outstanding + * PT(GraphicsOutput) prevented all of its children windows from also being + * deleted; in this unlikely case, get_pipe() may return NULL. + */ INLINE GraphicsPipe *GraphicsOutput:: get_pipe() const { return _pipe; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_engine -// Access: Published -// Description: Returns the graphics engine that created this output. -// Since there is normally only one GraphicsEngine -// object in an application, this is usually the same as -// the global GraphicsEngine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphics engine that created this output. Since there is + * normally only one GraphicsEngine object in an application, this is usually + * the same as the global GraphicsEngine. + */ INLINE GraphicsEngine *GraphicsOutput:: get_engine() const { return _engine; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_name -// Access: Published -// Description: Returns the name that was passed to the -// GraphicsOutput constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name that was passed to the GraphicsOutput constructor. + */ INLINE const string &GraphicsOutput:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::count_textures -// Access: Published -// Description: If the GraphicsOutput is set to render into a -// texture, returns the number of textures that are -// being rendered into. Normally, the textures would -// be associated with different buffers - a color -// texture, a depth texture, and a stencil texture. -//////////////////////////////////////////////////////////////////// +/** + * If the GraphicsOutput is set to render into a texture, returns the number + * of textures that are being rendered into. Normally, the textures would be + * associated with different buffers - a color texture, a depth texture, and a + * stencil texture. + */ INLINE int GraphicsOutput:: count_textures() const { CDReader cdata(_cycler); return cdata->_textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::has_texture -// Access: Published -// Description: Returns true if the GraphicsOutput is rendering -// into any textures at all. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the GraphicsOutput is rendering into any textures at all. + */ INLINE bool GraphicsOutput:: has_texture() const { CDReader cdata(_cycler); return (cdata->_textures.size() > 0); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_texture -// Access: Published -// Description: Returns the nth texture into which the GraphicsOutput -// renders. Returns NULL if there is no such texture. -// -// If the texture is non-NULL, it may be applied to -// geometry to be rendered for any other windows or -// outputs that share the same GSG as this -// GraphicsOutput. The effect is undefined for windows -// that share a different GSG; usually in these cases -// the texture will be invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth texture into which the GraphicsOutput renders. Returns + * NULL if there is no such texture. + * + * If the texture is non-NULL, it may be applied to geometry to be rendered + * for any other windows or outputs that share the same GSG as this + * GraphicsOutput. The effect is undefined for windows that share a different + * GSG; usually in these cases the texture will be invalid. + */ INLINE Texture *GraphicsOutput:: get_texture(int i) const { CDReader cdata(_cycler); @@ -118,13 +92,10 @@ get_texture(int i) const { return cdata->_textures[i]._texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_texture_plane -// Access: Published -// Description: Returns the RenderTexturePlane associated with the -// nth render-texture. Returns 0 if there is no such -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderTexturePlane associated with the nth render-texture. + * Returns 0 if there is no such texture. + */ INLINE GraphicsOutput::RenderTexturePlane GraphicsOutput:: get_texture_plane(int i) const { CDReader cdata(_cycler); @@ -134,13 +105,10 @@ get_texture_plane(int i) const { return cdata->_textures[i]._plane; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_rtm_mode -// Access: Published -// Description: Returns the RenderTextureMode associated with the -// nth render-texture. Returns RTM_none if there is -// no such texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderTextureMode associated with the nth render-texture. + * Returns RTM_none if there is no such texture. + */ INLINE GraphicsOutput::RenderTextureMode GraphicsOutput:: get_rtm_mode(int i) const { CDReader cdata(_cycler); @@ -150,112 +118,84 @@ get_rtm_mode(int i) const { return cdata->_textures[i]._rtm_mode; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_size -// Access: Published -// Description: Returns the visible size of the window or buffer, if -// it is known. In certain cases (e.g. fullscreen -// windows), the size may not be known until after the -// object has been fully created. Check has_size() -// first. -// -// Certain objects (like windows) may change size -// spontaneously; this method is not thread-safe. To -// get the size of a window in a thread-safe manner, -// query get_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the visible size of the window or buffer, if it is known. In + * certain cases (e.g. fullscreen windows), the size may not be known until + * after the object has been fully created. Check has_size() first. + * + * Certain objects (like windows) may change size spontaneously; this method + * is not thread-safe. To get the size of a window in a thread-safe manner, + * query get_properties(). + */ INLINE const LVecBase2i &GraphicsOutput:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_x_size -// Access: Published -// Description: Returns the visible width of the window or buffer, if -// it is known. In certain cases (e.g. fullscreen -// windows), the size may not be known until after the -// object has been fully created. Check has_size() -// first. -// -// Certain objects (like windows) may change size -// spontaneously; this method is not thread-safe. To -// get the size of a window in a thread-safe manner, -// query get_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the visible width of the window or buffer, if it is known. In + * certain cases (e.g. fullscreen windows), the size may not be known until + * after the object has been fully created. Check has_size() first. + * + * Certain objects (like windows) may change size spontaneously; this method + * is not thread-safe. To get the size of a window in a thread-safe manner, + * query get_properties(). + */ INLINE int GraphicsOutput:: get_x_size() const { return _size.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_y_size -// Access: Published -// Description: Returns the visible height of the window or buffer, -// if it is known. In certain cases (e.g. fullscreen -// windows), the size may not be known until after the -// object has been fully created. Check has_size() -// first. -// -// Certain objects (like windows) may change size -// spontaneously; this method is not thread-safe. To -// get the size of a window in a thread-safe manner, -// query get_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the visible height of the window or buffer, if it is known. In + * certain cases (e.g. fullscreen windows), the size may not be known until + * after the object has been fully created. Check has_size() first. + * + * Certain objects (like windows) may change size spontaneously; this method + * is not thread-safe. To get the size of a window in a thread-safe manner, + * query get_properties(). + */ INLINE int GraphicsOutput:: get_y_size() const { return _size.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_fb_size -// Access: Published -// Description: Returns the internal size of the window or buffer. -// This is almost always the same as get_size(), -// except when a pixel_zoom is in effect--see -// set_pixel_zoom(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal size of the window or buffer. This is almost always + * the same as get_size(), except when a pixel_zoom is in effect--see + * set_pixel_zoom(). + */ INLINE LVecBase2i GraphicsOutput:: get_fb_size() const { return LVecBase2i(max(int(_size.get_x() * get_pixel_factor()), 1), max(int(_size.get_y() * get_pixel_factor()), 1)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_fb_x_size -// Access: Published -// Description: Returns the internal width of the window or buffer. -// This is almost always the same as get_x_size(), -// except when a pixel_zoom is in effect--see -// set_pixel_zoom(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal width of the window or buffer. This is almost always + * the same as get_x_size(), except when a pixel_zoom is in effect--see + * set_pixel_zoom(). + */ INLINE int GraphicsOutput:: get_fb_x_size() const { return max(int(_size.get_x() * get_pixel_factor()), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_fb_y_size -// Access: Published -// Description: Returns the internal height of the window or buffer. -// This is almost always the same as get_y_size(), -// except when a pixel_zoom is in effect--see -// set_pixel_zoom(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal height of the window or buffer. This is almost always + * the same as get_y_size(), except when a pixel_zoom is in effect--see + * set_pixel_zoom(). + */ INLINE int GraphicsOutput:: get_fb_y_size() const { return max(int(_size.get_y() * get_pixel_factor()), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_left_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel size of the left eye, based on scaling -// get_size() by get_sbs_left_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel size of the left + * eye, based on scaling get_size() by get_sbs_left_dimensions(). If side-by- + * side stereo is not enabled, this returns the same as get_size(). + */ INLINE LVecBase2i GraphicsOutput:: get_sbs_left_size() const { PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; @@ -264,45 +204,33 @@ get_sbs_left_size() const { max(int(_size.get_y() * left_h), 1)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_left_x_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel width of the left eye, based on scaling -// get_x_size() by get_sbs_left_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_x_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel width of the left + * eye, based on scaling get_x_size() by get_sbs_left_dimensions(). If side- + * by-side stereo is not enabled, this returns the same as get_x_size(). + */ INLINE int GraphicsOutput:: get_sbs_left_x_size() const { PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; return max(int(_size.get_x() * left_w), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_left_y_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel height of the left eye, based on scaling -// get_y_size() by get_sbs_left_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_y_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel height of the + * left eye, based on scaling get_y_size() by get_sbs_left_dimensions(). If + * side-by-side stereo is not enabled, this returns the same as get_y_size(). + */ INLINE int GraphicsOutput:: get_sbs_left_y_size() const { PN_stdfloat left_h = _sbs_left_dimensions[3] - _sbs_left_dimensions[2]; return max(int(_size.get_y() * left_h), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_right_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel size of the right eye, based on scaling -// get_size() by get_sbs_right_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel size of the right + * eye, based on scaling get_size() by get_sbs_right_dimensions(). If side- + * by-side stereo is not enabled, this returns the same as get_size(). + */ INLINE LVecBase2i GraphicsOutput:: get_sbs_right_size() const { PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; @@ -311,130 +239,101 @@ get_sbs_right_size() const { max(int(_size.get_y() * right_h), 1)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_right_x_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel width of the right eye, based on scaling -// get_x_size() by get_sbs_right_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_x_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel width of the + * right eye, based on scaling get_x_size() by get_sbs_right_dimensions(). If + * side-by-side stereo is not enabled, this returns the same as get_x_size(). + */ INLINE int GraphicsOutput:: get_sbs_right_x_size() const { PN_stdfloat right_w = _sbs_right_dimensions[1] - _sbs_right_dimensions[0]; return max(int(_size.get_x() * right_w), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_right_y_size -// Access: Published -// Description: If side-by-side stereo is enabled, this returns the -// pixel height of the right eye, based on scaling -// get_y_size() by get_sbs_right_dimensions(). If -// side-by-side stereo is not enabled, this returns the -// same as get_y_size(). -//////////////////////////////////////////////////////////////////// +/** + * If side-by-side stereo is enabled, this returns the pixel height of the + * right eye, based on scaling get_y_size() by get_sbs_right_dimensions(). If + * side-by-side stereo is not enabled, this returns the same as get_y_size(). + */ INLINE int GraphicsOutput:: get_sbs_right_y_size() const { PN_stdfloat right_h = _sbs_right_dimensions[3] - _sbs_right_dimensions[2]; return max(int(_size.get_y() * right_h), 1); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::has_size -// Access: Published -// Description: Returns true if the size of the window/frame buffer -// is known, false otherwise. In certain cases the size -// may not be known until after the object has been -// fully created. Also, certain objects (like windows) -// may change size spontaneously. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the size of the window/frame buffer is known, false + * otherwise. In certain cases the size may not be known until after the + * object has been fully created. Also, certain objects (like windows) may + * change size spontaneously. + */ INLINE bool GraphicsOutput:: has_size() const { return _has_size; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::is_valid -// Access: Published -// Description: Returns true if the output is fully created and ready -// for rendering, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the output is fully created and ready for rendering, false + * otherwise. + */ INLINE bool GraphicsOutput:: is_valid() const { return _is_valid && _is_nonzero_size; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::is_nonzero_size -// Access: Published -// Description: Returns true if the output has a nonzero size in both -// X and Y, or false if it is zero (and therefore -// invalid). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the output has a nonzero size in both X and Y, or false if + * it is zero (and therefore invalid). + */ INLINE bool GraphicsOutput:: is_nonzero_size() const { return _is_nonzero_size; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_inverted -// Access: Published -// Description: Returns the current setting of the inverted flag. -// When this is true, the scene is rendered into the -// window upside-down, flipped like a mirror along the X -// axis. See set_inverted(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the inverted flag. When this is true, the + * scene is rendered into the window upside-down, flipped like a mirror along + * the X axis. See set_inverted(). + */ INLINE bool GraphicsOutput:: get_inverted() const { return _inverted; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_swap_eyes -// Access: Public -// Description: Changes the "swap eyes" flag. This flag is normally -// false. When it is true, the left and right channels -// of a stereo DisplayRegion are sent to the opposite -// channels in the rendering backend. This is meant to -// work around hardware that inadvertently swaps the -// output channels, or hardware for which it cannot be -// determined which channel is which until runtime. -//////////////////////////////////////////////////////////////////// +/** + * Changes the "swap eyes" flag. This flag is normally false. When it is + * true, the left and right channels of a stereo DisplayRegion are sent to the + * opposite channels in the rendering backend. This is meant to work around + * hardware that inadvertently swaps the output channels, or hardware for + * which it cannot be determined which channel is which until runtime. + */ INLINE void GraphicsOutput:: set_swap_eyes(bool swap_eyes) { _swap_eyes = swap_eyes; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_swap_eyes -// Access: Public -// Description: Returns the current setting of the "swap eyes" flag. -// See set_swap_eyes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the "swap eyes" flag. See set_swap_eyes(). + */ INLINE bool GraphicsOutput:: get_swap_eyes() const { return _swap_eyes; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_red_blue_stereo -// Access: Published -// Description: Enables red-blue stereo mode on this particular -// window. When red-blue stereo mode is in effect, -// DisplayRegions that have the "left" channel set will -// render in the red (or specified) channel only, while -// DisplayRegions that have the "right" channel set will -// render in the blue (or specified) channel only. -// -// The remaining two parameters specify the particular -// color channel(s) to associate with each eye. Use the -// bits defined in ColorWriteAttrib::Channels. -// -// This can be used to achieve a cheesy stereo mode in -// the absence of hardware-supported stereo. -//////////////////////////////////////////////////////////////////// +/** + * Enables red-blue stereo mode on this particular window. When red-blue + * stereo mode is in effect, DisplayRegions that have the "left" channel set + * will render in the red (or specified) channel only, while DisplayRegions + * that have the "right" channel set will render in the blue (or specified) + * channel only. + * + * The remaining two parameters specify the particular color channel(s) to + * associate with each eye. Use the bits defined in + * ColorWriteAttrib::Channels. + * + * This can be used to achieve a cheesy stereo mode in the absence of + * hardware-supported stereo. + */ INLINE void GraphicsOutput:: set_red_blue_stereo(bool red_blue_stereo, unsigned int left_eye_color_mask, @@ -449,171 +348,135 @@ set_red_blue_stereo(bool red_blue_stereo, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_red_blue_stereo -// Access: Published -// Description: Returns whether red-blue stereo mode is in effect for -// this particular window. See set_red_blue_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether red-blue stereo mode is in effect for this particular + * window. See set_red_blue_stereo(). + */ INLINE bool GraphicsOutput:: get_red_blue_stereo() const { return _red_blue_stereo; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_left_eye_color_mask -// Access: Published -// Description: Returns the color mask in effect when rendering a -// left-eye view in red_blue stereo mode. This is one -// or more bits defined in ColorWriteAttrib::Channels. -// See set_red_blue_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color mask in effect when rendering a left-eye view in red_blue + * stereo mode. This is one or more bits defined in + * ColorWriteAttrib::Channels. See set_red_blue_stereo(). + */ INLINE unsigned int GraphicsOutput:: get_left_eye_color_mask() const { return _left_eye_color_mask; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_right_eye_color_mask -// Access: Published -// Description: Returns the color mask in effect when rendering a -// right-eye view in red_blue stereo mode. This is one -// or more bits defined in ColorWriteAttrib::Channels. -// See set_red_blue_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color mask in effect when rendering a right-eye view in + * red_blue stereo mode. This is one or more bits defined in + * ColorWriteAttrib::Channels. See set_red_blue_stereo(). + */ INLINE unsigned int GraphicsOutput:: get_right_eye_color_mask() const { return _right_eye_color_mask; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_side_by_side_stereo -// Access: Published -// Description: Returns whether side-by-side stereo mode is in effect for -// this particular window. See set_side_by_side_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether side-by-side stereo mode is in effect for this particular + * window. See set_side_by_side_stereo(). + */ INLINE bool GraphicsOutput:: get_side_by_side_stereo() const { return _side_by_side_stereo; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_left_dimensions -// Access: Published -// Description: Returns the effective sub-region of the window for -// displaying the left channel, if side-by-side stereo -// mode is in effect for the window. See -// set_side_by_side_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the effective sub-region of the window for displaying the left + * channel, if side-by-side stereo mode is in effect for the window. See + * set_side_by_side_stereo(). + */ INLINE const LVecBase4 &GraphicsOutput:: get_sbs_left_dimensions() const { return _sbs_left_dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sbs_right_dimensions -// Access: Published -// Description: Returns the effective sub-region of the window for -// displaying the right channel, if side-by-side stereo -// mode is in effect for the window. See -// set_side_by_side_stereo(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the effective sub-region of the window for displaying the right + * channel, if side-by-side stereo mode is in effect for the window. See + * set_side_by_side_stereo(). + */ INLINE const LVecBase4 &GraphicsOutput:: get_sbs_right_dimensions() const { return _sbs_right_dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_fb_properties -// Access: Published -// Description: Returns the framebuffer properties of the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the framebuffer properties of the window. + */ INLINE const FrameBufferProperties &GraphicsOutput:: get_fb_properties() const { return _fb_properties; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::is_stereo -// Access: Published -// Description: Returns Returns true if this window can render stereo -// DisplayRegions, either through red-blue stereo (see -// set_red_blue_stereo()) or through true hardware -// stereo rendering. -//////////////////////////////////////////////////////////////////// +/** + * Returns Returns true if this window can render stereo DisplayRegions, + * either through red-blue stereo (see set_red_blue_stereo()) or through true + * hardware stereo rendering. + */ INLINE bool GraphicsOutput:: is_stereo() const { return _red_blue_stereo || _side_by_side_stereo || _fb_properties.is_stereo(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear_delete_flag -// Access: Published -// Description: Resets the delete flag, so the GraphicsOutput will -// not be automatically deleted before the beginning of -// the next frame. -//////////////////////////////////////////////////////////////////// +/** + * Resets the delete flag, so the GraphicsOutput will not be automatically + * deleted before the beginning of the next frame. + */ INLINE void GraphicsOutput:: clear_delete_flag() { _delete_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_sort -// Access: Published -// Description: Returns the sorting order of this particular -// GraphicsOutput. The various GraphicsOutputs within a -// particular thread will be rendered in the indicated -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sorting order of this particular GraphicsOutput. The various + * GraphicsOutputs within a particular thread will be rendered in the + * indicated order. + */ INLINE int GraphicsOutput:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_child_sort -// Access: Published -// Description: Specifies the sort value of future offscreen buffers -// created by make_texture_sort(). -// -// The purpose of this method is to allow the user to -// limit the sort value chosen for a buffer created via -// make_texture_buffer(). Normally, this buffer will be -// assigned a value of get_sort() - 1, so that it -// will be rendered before this window is rendered; but -// sometimes this isn't sufficiently early, especially -// if other buffers also have a view into the same -// scene. -// -// If you specify a value here, then new buffers created -// via make_texture_buffer() will be given that sort -// value instead of get_sort() - 1. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the sort value of future offscreen buffers created by + * make_texture_sort(). + * + * The purpose of this method is to allow the user to limit the sort value + * chosen for a buffer created via make_texture_buffer(). Normally, this + * buffer will be assigned a value of get_sort() - 1, so that it will be + * rendered before this window is rendered; but sometimes this isn't + * sufficiently early, especially if other buffers also have a view into the + * same scene. + * + * If you specify a value here, then new buffers created via + * make_texture_buffer() will be given that sort value instead of get_sort() - + * 1. + */ INLINE void GraphicsOutput:: set_child_sort(int child_sort) { _child_sort = child_sort; _got_child_sort = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear_child_sort -// Access: Published -// Description: Resets the sort value of future offscreen buffers -// created by make_texture_sort() to the default value. -// See set_child_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the sort value of future offscreen buffers created by + * make_texture_sort() to the default value. See set_child_sort(). + */ INLINE void GraphicsOutput:: clear_child_sort() { _got_child_sort = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_child_sort -// Access: Published -// Description: Returns the sort value of future offscreen buffers -// created by make_texture_sort(). See set_child_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort value of future offscreen buffers created by + * make_texture_sort(). See set_child_sort(). + */ INLINE int GraphicsOutput:: get_child_sort() const { if (_got_child_sort) { @@ -623,220 +486,164 @@ get_child_sort() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::trigger_copy -// Access: Published -// Description: When the GraphicsOutput is in triggered copy mode, -// this function triggers the copy (at the end of the -// next frame). -//////////////////////////////////////////////////////////////////// +/** + * When the GraphicsOutput is in triggered copy mode, this function triggers + * the copy (at the end of the next frame). + */ INLINE void GraphicsOutput:: trigger_copy() { _trigger_copy = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// window. -// -// If is_stereo() is true for this window, and -// default-stereo-camera is configured true, this -// actually makes a StereoDisplayRegion. Call -// make_mono_display_region() or -// make_stereo_display_region() if you want to insist on -// one or the other. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the entire window. + * + * If is_stereo() is true for this window, and default-stereo-camera is + * configured true, this actually makes a StereoDisplayRegion. Call + * make_mono_display_region() or make_stereo_display_region() if you want to + * insist on one or the other. + */ INLINE DisplayRegion *GraphicsOutput:: make_display_region() { return make_display_region(0.0f, 1.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the indicated -// sub-rectangle within the window. The range on all -// parameters is 0..1. -// -// If is_stereo() is true for this window, and -// default-stereo-camera is configured true, this -// actually makes a StereoDisplayRegion. Call -// make_mono_display_region() or -// make_stereo_display_region() if you want to insist on -// one or the other. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the indicated sub-rectangle within + * the window. The range on all parameters is 0..1. + * + * If is_stereo() is true for this window, and default-stereo-camera is + * configured true, this actually makes a StereoDisplayRegion. Call + * make_mono_display_region() or make_stereo_display_region() if you want to + * insist on one or the other. + */ DisplayRegion *GraphicsOutput:: make_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { return make_display_region(LVecBase4(l, r, b, t)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_mono_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// window. -// -// This generally returns a mono DisplayRegion, even if -// is_stereo() is true. However, if side-by-side stereo -// is enabled, this will return a StereoDisplayRegion -// whose two eyes are both set to SC_mono. (This is -// necessary because in side-by-side stereo mode, it is -// necessary to draw even mono DisplayRegions twice). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the entire window. + * + * This generally returns a mono DisplayRegion, even if is_stereo() is true. + * However, if side-by-side stereo is enabled, this will return a + * StereoDisplayRegion whose two eyes are both set to SC_mono. (This is + * necessary because in side-by-side stereo mode, it is necessary to draw even + * mono DisplayRegions twice). + */ INLINE DisplayRegion *GraphicsOutput:: make_mono_display_region() { return make_mono_display_region(0.0f, 1.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_mono_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// window. -// -// This generally returns a mono DisplayRegion, even if -// is_stereo() is true. However, if side-by-side stereo -// is enabled, this will return a StereoDisplayRegion -// whose two eyes are both set to SC_mono. (This is -// necessary because in side-by-side stereo mode, it is -// necessary to draw even mono DisplayRegions twice). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the entire window. + * + * This generally returns a mono DisplayRegion, even if is_stereo() is true. + * However, if side-by-side stereo is enabled, this will return a + * StereoDisplayRegion whose two eyes are both set to SC_mono. (This is + * necessary because in side-by-side stereo mode, it is necessary to draw even + * mono DisplayRegions twice). + */ INLINE DisplayRegion *GraphicsOutput:: make_mono_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { return make_mono_display_region(LVecBase4(l, r, b, t)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_stereo_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// window. -// -// This always returns a stereo DisplayRegion, even if -// is_stereo() is false. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the entire window. + * + * This always returns a stereo DisplayRegion, even if is_stereo() is false. + */ INLINE StereoDisplayRegion *GraphicsOutput:: make_stereo_display_region() { return make_stereo_display_region(0.0f, 1.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_stereo_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// window. -// -// This always returns a stereo DisplayRegion, even if -// is_stereo() is false. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the entire window. + * + * This always returns a stereo DisplayRegion, even if is_stereo() is false. + */ INLINE StereoDisplayRegion *GraphicsOutput:: make_stereo_display_region(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { return make_stereo_display_region(LVecBase4(l, r, b, t)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_overlay_display_region -// Access: Published -// Description: Returns the special "overlay" DisplayRegion that is -// created for each window or buffer. This -// DisplayRegion covers the entire window, but cannot be -// used for rendering. It is a placeholder only, to -// indicate the dimensions of the window, and is usually -// used internally for purposes such as clearing the -// window, or grabbing a screenshot of the window. -// -// There are very few applications that require access -// to this DisplayRegion. Normally, you should create -// your own DisplayRegion that covers the window, if you -// want to render to the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the special "overlay" DisplayRegion that is created for each window + * or buffer. This DisplayRegion covers the entire window, but cannot be used + * for rendering. It is a placeholder only, to indicate the dimensions of the + * window, and is usually used internally for purposes such as clearing the + * window, or grabbing a screenshot of the window. + * + * There are very few applications that require access to this DisplayRegion. + * Normally, you should create your own DisplayRegion that covers the window, + * if you want to render to the window. + */ INLINE DisplayRegion *GraphicsOutput:: get_overlay_display_region() const { return _overlay_display_region; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_screenshot_filename -// Access: Published, Static -// Description: Saves a screenshot of the region to a default -// filename, and returns the filename, or empty string -// if the screenshot failed. The default filename is -// generated from the supplied prefix and from the -// Config variable screenshot-filename, which contains -// the following strings: -// -// %~p - the supplied prefix -// %~f - the frame count -// %~e - the value of screenshot-extension -// All other % strings in strftime(). -//////////////////////////////////////////////////////////////////// +/** + * Saves a screenshot of the region to a default filename, and returns the + * filename, or empty string if the screenshot failed. The default filename + * is generated from the supplied prefix and from the Config variable + * screenshot-filename, which contains the following strings: + * + * %~p - the supplied prefix %~f - the frame count %~e - the value of + * screenshot-extension All other % strings in strftime(). + */ INLINE Filename GraphicsOutput:: make_screenshot_filename(const string &prefix) { return DisplayRegion::make_screenshot_filename(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::save_screenshot_default -// Access: Published -// Description: Saves a screenshot of the region to a default -// filename, and returns the filename, or empty string -// if the screenshot failed. The filename is generated -// by make_screenshot_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Saves a screenshot of the region to a default filename, and returns the + * filename, or empty string if the screenshot failed. The filename is + * generated by make_screenshot_filename(). + */ INLINE Filename GraphicsOutput:: save_screenshot_default(const string &prefix) { return _overlay_display_region->save_screenshot_default(prefix); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::save_screenshot -// Access: Published -// Description: Saves a screenshot of the region to the indicated -// filename. The image comment is an optional user -// readable string that will be saved with the header -// of the image (if the file format supports embedded -// data; for example jpg allows comments). Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Saves a screenshot of the region to the indicated filename. The image + * comment is an optional user readable string that will be saved with the + * header of the image (if the file format supports embedded data; for example + * jpg allows comments). Returns true on success, false on failure. + */ INLINE bool GraphicsOutput:: save_screenshot(const Filename &filename, const string &image_comment) { return _overlay_display_region->save_screenshot(filename, image_comment); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_screenshot -// Access: Published -// Description: Captures the most-recently rendered image from the -// framebuffer into the indicated PNMImage. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Captures the most-recently rendered image from the framebuffer into the + * indicated PNMImage. Returns true on success, false on failure. + */ INLINE bool GraphicsOutput:: get_screenshot(PNMImage &image) { return _overlay_display_region->get_screenshot(image); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_screenshot -// Access: Published -// Description: Captures the most-recently rendered image from the -// framebuffer and returns it as Texture, or NULL on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Captures the most-recently rendered image from the framebuffer and returns + * it as Texture, or NULL on failure. + */ INLINE PT(Texture) GraphicsOutput:: get_screenshot() { return _overlay_display_region->get_screenshot(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::operator < -// Access: Public -// Description: The sorting operator is used to order the -// GraphicsOutput object in order by their sort number, -// so that they will render in the correct order in the -// GraphicsEngine. -//////////////////////////////////////////////////////////////////// +/** + * The sorting operator is used to order the GraphicsOutput object in order by + * their sort number, so that they will render in the correct order in the + * GraphicsEngine. + */ INLINE bool GraphicsOutput:: operator < (const GraphicsOutput &other) const { if (_sort != other._sort) { @@ -846,16 +653,14 @@ operator < (const GraphicsOutput &other) const { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::determine_display_regions -// Access: Private -// Description: Recomputes the list of active DisplayRegions within -// the window, if they have changed recently. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the list of active DisplayRegions within the window, if they + * have changed recently. + */ INLINE void GraphicsOutput:: determine_display_regions() const { - // This function isn't strictly speaking const, but we pretend it is - // because it only updates a transparent cache value. + // This function isn't strictly speaking const, but we pretend it is because + // it only updates a transparent cache value. CDLockedReader cdata(_cycler); if (cdata->_active_display_regions_stale) { CDWriter cdataw(((GraphicsOutput *)this)->_cycler, cdata, false); @@ -863,46 +668,38 @@ determine_display_regions() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::win_display_regions_changed -// Access: Private -// Description: Intended to be called when the active state on a -// nested display region changes, forcing the window to -// recompute its list of active display regions. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called when the active state on a nested display region + * changes, forcing the window to recompute its list of active display + * regions. + */ INLINE void GraphicsOutput:: win_display_regions_changed() { CDWriter cdata(_cycler, true); cdata->_active_display_regions_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_cull_window_pcollector -// Access: Public -// Description: Returns a PStatCollector for timing the cull -// operation for just this GraphicsOutput. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector for timing the cull operation for just this + * GraphicsOutput. + */ INLINE PStatCollector &GraphicsOutput:: get_cull_window_pcollector() { return _cull_window_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_draw_window_pcollector -// Access: Public -// Description: Returns a PStatCollector for timing the draw -// operation for just this GraphicsOutput. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector for timing the draw operation for just this + * GraphicsOutput. + */ INLINE PStatCollector &GraphicsOutput:: get_draw_window_pcollector() { return _draw_window_pcollector; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::begin_frame_spam -// Access: Public -// Description: Display the spam message associated with begin_frame -//////////////////////////////////////////////////////////////////// +/** + * Display the spam message associated with begin_frame + */ INLINE void GraphicsOutput:: begin_frame_spam(FrameMode mode) { if (display_cat.is_spam()) { @@ -912,11 +709,9 @@ begin_frame_spam(FrameMode mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::end_frame_spam -// Access: Public -// Description: Display the spam message associated with end_frame -//////////////////////////////////////////////////////////////////// +/** + * Display the spam message associated with end_frame + */ INLINE void GraphicsOutput:: end_frame_spam(FrameMode mode) { if (display_cat.is_spam()) { @@ -926,29 +721,23 @@ end_frame_spam(FrameMode mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear_cube_map_selection -// Access: Public -// Description: Clear the variables that select a cube-map face (or -// other multipage texture face). -//////////////////////////////////////////////////////////////////// +/** + * Clear the variables that select a cube-map face (or other multipage texture + * face). + */ INLINE void GraphicsOutput:: clear_cube_map_selection() { _target_tex_page = -1; _prev_page_dr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::trigger_flip -// Access: Protected -// Description: To be called at the end of the frame, after the -// window has successfully been drawn and is ready to be -// flipped (if appropriate). -//////////////////////////////////////////////////////////////////// +/** + * To be called at the end of the frame, after the window has successfully + * been drawn and is ready to be flipped (if appropriate). + */ INLINE void GraphicsOutput:: trigger_flip() { if (!_fb_properties.is_single_buffered()) { _flip_ready = true; } } - diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 6a63b77a7c..afdaddf3d4 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsOutput.cxx -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutput.cxx + * @author drose + * @date 2004-02-06 + */ #include "graphicsOutput.h" #include "graphicsPipe.h" @@ -60,13 +59,10 @@ static CubeFaceDef cube_faces[6] = { CubeFaceDef("negative_z", LPoint3(0, 0, -1), LVector3(0, -1, 0)) }; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::Constructor -// Access: Protected -// Description: Normally, the GraphicsOutput constructor is not -// called directly; these are created instead via the -// GraphicsEngine::make_window() function. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the GraphicsOutput constructor is not called directly; these are + * created instead via the GraphicsEngine::make_window() function. + */ GraphicsOutput:: GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -98,8 +94,7 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, _is_nonzero_size = (_size[0] > 0 && _size[1] > 0); } if (_creation_flags & GraphicsPipe::BF_size_track_host) { - // If we're tracking the host size, we assume we'll be nonzero - // eventually. + // If we're tracking the host size, we assume we'll be nonzero eventually. _is_nonzero_size = true; } @@ -129,8 +124,8 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, } if (default_stereo_flags) { - // Check the config variables to see if we should make this a - // "stereo" buffer or window. + // Check the config variables to see if we should make this a "stereo" + // buffer or window. _red_blue_stereo = red_blue_stereo && !fb_prop.is_stereo(); if (_red_blue_stereo) { _left_eye_color_mask = parse_color_mask(red_blue_stereo_colors.get_word(0)); @@ -145,9 +140,9 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, } } - // We start out with one DisplayRegion that covers the whole window, - // which we may use internally for full-window operations like - // clear() and get_screenshot(). + // We start out with one DisplayRegion that covers the whole window, which + // we may use internally for full-window operations like clear() and + // get_screenshot(). _overlay_display_region = make_mono_display_region(0.0f, 1.0f, 0.0f, 1.0f); _overlay_display_region->set_active(false); _overlay_display_region->set_scissor_enabled(false); @@ -158,19 +153,16 @@ GraphicsOutput(GraphicsEngine *engine, GraphicsPipe *pipe, cdata->_active = true; } - // By default, each new GraphicsOutput is set up to clear color and - // depth. + // By default, each new GraphicsOutput is set up to clear color and depth. set_clear_color_active(true); set_clear_depth_active(true); set_clear_stencil_active(true); set_clear_color(background_color.get_value()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsOutput:: GraphicsOutput(const GraphicsOutput &) : _cull_window_pcollector(_cull_pcollector, "Invalid"), @@ -179,21 +171,17 @@ GraphicsOutput(const GraphicsOutput &) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GraphicsOutput:: operator = (const GraphicsOutput &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsOutput:: ~GraphicsOutput() { // The window should be closed by the time we destruct. @@ -202,10 +190,9 @@ GraphicsOutput:: // We shouldn't have a GraphicsPipe pointer anymore. nassertv(_pipe == (GraphicsPipe *)NULL); - // We don't have to destruct our child display regions explicitly, - // since they are all reference-counted and will go away when their - // pointers do. However, we do need to zero out their pointers to - // us. + // We don't have to destruct our child display regions explicitly, since + // they are all reference-counted and will go away when their pointers do. + // However, we do need to zero out their pointers to us. TotalDisplayRegions::iterator dri; for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); @@ -217,13 +204,10 @@ GraphicsOutput:: _overlay_display_region = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear_render_textures -// Access: Published -// Description: If the GraphicsOutput is currently rendering to -// a texture, then all textures are dissociated from -// the GraphicsOuput. -//////////////////////////////////////////////////////////////////// +/** + * If the GraphicsOutput is currently rendering to a texture, then all + * textures are dissociated from the GraphicsOuput. + */ void GraphicsOutput:: clear_render_textures() { CDWriter cdata(_cycler, true); @@ -232,47 +216,34 @@ clear_render_textures() { throw_event("render-texture-targets-changed"); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::add_render_texture -// Access: Published -// Description: Creates a new Texture object, suitable for rendering -// the contents of this buffer into, and appends it to -// the list of render textures. -// -// If tex is not NULL, it is the texture that will be -// set up for rendering into; otherwise, a new Texture -// object will be created, in which case you may call -// get_texture() to retrieve the new texture pointer. -// -// You can specify a bitplane to attach the texture to. -// the legal choices are: -// -// * RTP_depth -// * RTP_depth_stencil -// * RTP_color -// * RTP_aux_rgba_0 -// * RTP_aux_rgba_1 -// * RTP_aux_rgba_2 -// * RTP_aux_rgba_3 -// -// If you do not specify a bitplane to attach the -// texture to, this routine will use a default based -// on the texture's format: -// -// * F_depth_component attaches to RTP_depth -// * F_depth_stencil attaches to RTP_depth_stencil -// * all other formats attach to RTP_color. -// -// The texture's format will be changed to match -// the format of the bitplane to which it is attached. -// For example, if you pass in an F_rgba texture and -// order that it be attached to RTP_depth_stencil, it will turn -// into an F_depth_stencil texture. -// -// Also see make_texture_buffer(), which is a -// higher-level interface for preparing -// render-to-a-texture mode. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Texture object, suitable for rendering the contents of this + * buffer into, and appends it to the list of render textures. + * + * If tex is not NULL, it is the texture that will be set up for rendering + * into; otherwise, a new Texture object will be created, in which case you + * may call get_texture() to retrieve the new texture pointer. + * + * You can specify a bitplane to attach the texture to. the legal choices + * are: + * + * * RTP_depth * RTP_depth_stencil * RTP_color * RTP_aux_rgba_0 * + * RTP_aux_rgba_1 * RTP_aux_rgba_2 * RTP_aux_rgba_3 + * + * If you do not specify a bitplane to attach the texture to, this routine + * will use a default based on the texture's format: + * + * * F_depth_component attaches to RTP_depth * F_depth_stencil attaches to + * RTP_depth_stencil * all other formats attach to RTP_color. + * + * The texture's format will be changed to match the format of the bitplane to + * which it is attached. For example, if you pass in an F_rgba texture and + * order that it be attached to RTP_depth_stencil, it will turn into an + * F_depth_stencil texture. + * + * Also see make_texture_buffer(), which is a higher-level interface for + * preparing render-to-a-texture mode. + */ void GraphicsOutput:: add_render_texture(Texture *tex, RenderTextureMode mode, RenderTexturePlane plane) { @@ -291,10 +262,10 @@ add_render_texture(Texture *tex, RenderTextureMode mode, tex->clear_ram_image(); } - // Set it to have no compression by default. You can restore - // compression later if you really, really want it; but this freaks - // out some drivers, and presumably it's a mistake if you have - // compression enabled for a rendered texture. + // Set it to have no compression by default. You can restore compression + // later if you really, really want it; but this freaks out some drivers, + // and presumably it's a mistake if you have compression enabled for a + // rendered texture. tex->set_compression(Texture::CM_off); // Choose a default bitplane. @@ -308,8 +279,8 @@ add_render_texture(Texture *tex, RenderTextureMode mode, } } - // Set the texture's format to match the bitplane. - // (And validate the bitplane, while we're at it). + // Set the texture's format to match the bitplane. (And validate the + // bitplane, while we're at it). if (plane == RTP_depth) { tex->set_format(Texture::F_depth_component); @@ -344,9 +315,9 @@ add_render_texture(Texture *tex, RenderTextureMode mode, return; } - // Go ahead and tell the texture our anticipated size, even if it - // might be inaccurate (particularly if this is a GraphicsWindow, - // which has system-imposed restrictions on size). + // Go ahead and tell the texture our anticipated size, even if it might be + // inaccurate (particularly if this is a GraphicsWindow, which has system- + // imposed restrictions on size). tex->set_size_padded(get_x_size(), get_y_size(), tex->get_z_size()); if (_fb_properties.is_stereo() && plane == RTP_color) { @@ -356,14 +327,13 @@ add_render_texture(Texture *tex, RenderTextureMode mode, } if (!support_render_texture || !get_supports_render_texture()) { - // Binding is not supported or it is disabled, so just fall back - // to copy instead. + // Binding is not supported or it is disabled, so just fall back to copy + // instead. if (mode == RTM_bind_or_copy) { mode = RTM_copy_texture; } else if (mode == RTM_bind_layered) { - // We can't fallback to copy, because that doesn't work - // for layered textures. The best thing we can do is raise - // an error message. + // We can't fallback to copy, because that doesn't work for layered + // textures. The best thing we can do is raise an error message. display_cat.error() << "add_render_texture: RTM_bind_layered was requested but " "render-to-texture is not supported or has been disabled!\n"; @@ -371,16 +341,15 @@ add_render_texture(Texture *tex, RenderTextureMode mode, } if (mode == RTM_bind_layered && _gsg != NULL && !_gsg->get_supports_geometry_shaders()) { - // Layered FBOs require a geometry shader to write to - // any but the first layer. + // Layered FBOs require a geometry shader to write to any but the first + // layer. display_cat.warning() << "add_render_texture: RTM_bind_layered was requested but " "geometry shaders are not supported!\n"; } if (mode == RTM_bind_or_copy || mode == RTM_bind_layered) { - // If we're still planning on binding, indicate it in texture - // properly. + // If we're still planning on binding, indicate it in texture properly. tex->set_render_to_texture(true); } @@ -395,15 +364,11 @@ add_render_texture(Texture *tex, RenderTextureMode mode, throw_event("render-texture-targets-changed"); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::setup_render_texture -// Access: Published -// Description: This is a deprecated interface that made sense back -// when GraphicsOutputs could only render into one -// texture at a time. From now on, use -// clear_render_textures and add_render_texture -// instead. -//////////////////////////////////////////////////////////////////// +/** + * This is a deprecated interface that made sense back when GraphicsOutputs + * could only render into one texture at a time. From now on, use + * clear_render_textures and add_render_texture instead. + */ void GraphicsOutput:: setup_render_texture(Texture *tex, bool allow_bind, bool to_ram) { display_cat.warning() << @@ -418,13 +383,10 @@ setup_render_texture(Texture *tex, bool allow_bind, bool to_ram) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_active -// Access: Published -// Description: Sets the active flag associated with the -// GraphicsOutput. If the GraphicsOutput is marked -// inactive, nothing is rendered. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag associated with the GraphicsOutput. If the + * GraphicsOutput is marked inactive, nothing is rendered. + */ void GraphicsOutput:: set_active(bool active) { CDLockedReader cdata(_cycler); @@ -434,12 +396,9 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::is_active -// Access: Published, Virtual -// Description: Returns true if the window is ready to be rendered -// into, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is ready to be rendered into, false otherwise. + */ bool GraphicsOutput:: is_active() const { if (!is_valid()) { @@ -448,8 +407,8 @@ is_active() const { CDReader cdata(_cycler); if (cdata->_one_shot_frame != -1) { - // If one_shot is in effect, then we are active only for the one - // indicated frame. + // If one_shot is in effect, then we are active only for the one indicated + // frame. if (cdata->_one_shot_frame != ClockObject::get_global_clock()->get_frame_count()) { return false; } @@ -457,27 +416,21 @@ is_active() const { return cdata->_active; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_one_shot -// Access: Published -// Description: Changes the current setting of the one-shot flag. -// When this is true, the GraphicsOutput will render the -// current frame and then automatically set itself -// inactive. This is particularly useful for buffers -// that are created for the purposes of -// render-to-texture, for static textures that don't -// need to be continually re-rendered once they have -// been rendered the first time. -// -// Setting the buffer inactive is not the same thing as -// destroying it. You are still responsible for passing -// this buffer to GraphicsEngine::remove_window() when -// you no longer need the texture, in order to clean up -// fully. (However, you should not call remove_window() -// on this buffer while the texture is still needed, -// because depending on the render-to-texture mechanism -// in use, this may invalidate the texture contents.) -//////////////////////////////////////////////////////////////////// +/** + * Changes the current setting of the one-shot flag. When this is true, the + * GraphicsOutput will render the current frame and then automatically set + * itself inactive. This is particularly useful for buffers that are created + * for the purposes of render-to-texture, for static textures that don't need + * to be continually re-rendered once they have been rendered the first time. + * + * Setting the buffer inactive is not the same thing as destroying it. You + * are still responsible for passing this buffer to + * GraphicsEngine::remove_window() when you no longer need the texture, in + * order to clean up fully. (However, you should not call remove_window() on + * this buffer while the texture is still needed, because depending on the + * render-to-texture mechanism in use, this may invalidate the texture + * contents.) + */ void GraphicsOutput:: set_one_shot(bool one_shot) { CDWriter cdata(_cycler, true); @@ -488,44 +441,35 @@ set_one_shot(bool one_shot) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_one_shot -// Access: Published -// Description: Returns the current setting of the one-shot flag. -// When this is true, the GraphicsOutput will -// automatically set itself inactive after the next -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the one-shot flag. When this is true, the + * GraphicsOutput will automatically set itself inactive after the next frame. + */ bool GraphicsOutput:: get_one_shot() const { CDReader cdata(_cycler); return (cdata->_one_shot_frame == ClockObject::get_global_clock()->get_frame_count()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_inverted -// Access: Published -// Description: Changes the current setting of the inverted flag. -// When this is true, the scene is rendered into the -// window upside-down and backwards, that is, inverted -// as if viewed through a mirror placed on the floor. -// -// This is primarily intended to support DirectX (and a -// few buggy OpenGL graphics drivers) that perform a -// framebuffer-to-texture copy upside-down from the -// usual OpenGL (and Panda) convention. Panda will -// automatically set this flag for offscreen buffers on -// hardware that is known to do this, to compensate when -// rendering offscreen into a texture. -//////////////////////////////////////////////////////////////////// +/** + * Changes the current setting of the inverted flag. When this is true, the + * scene is rendered into the window upside-down and backwards, that is, + * inverted as if viewed through a mirror placed on the floor. + * + * This is primarily intended to support DirectX (and a few buggy OpenGL + * graphics drivers) that perform a framebuffer-to-texture copy upside-down + * from the usual OpenGL (and Panda) convention. Panda will automatically set + * this flag for offscreen buffers on hardware that is known to do this, to + * compensate when rendering offscreen into a texture. + */ void GraphicsOutput:: set_inverted(bool inverted) { if (_inverted != inverted) { _inverted = inverted; if (get_y_size() != 0) { - // All of our DisplayRegions need to recompute their pixel - // positions now. + // All of our DisplayRegions need to recompute their pixel positions + // now. TotalDisplayRegions::iterator dri; for (dri = _total_display_regions.begin(); dri != _total_display_regions.end(); @@ -536,23 +480,17 @@ set_inverted(bool inverted) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_side_by_side_stereo -// Access: Published -// Description: Enables side-by-side stereo mode on this particular -// window. When side-by-side stereo mode is in effect, -// DisplayRegions that have the "left" channel set will -// render on the part of the window specified by -// sbs_left_dimensions (typically the left half: (0, -// 0.5, 0, 1)), while DisplayRegions that have the -// "right" channel set will render on the part of the -// window specified by sbs_right_dimensions (typically -// the right half: (0.5, 1, 0, 1)). -// -// This is commonly used in a dual-monitor mode, where a -// window is opened that spans two monitors, and each -// monitor represents a different eye. -//////////////////////////////////////////////////////////////////// +/** + * Enables side-by-side stereo mode on this particular window. When side-by- + * side stereo mode is in effect, DisplayRegions that have the "left" channel + * set will render on the part of the window specified by sbs_left_dimensions + * (typically the left half: (0, 0.5, 0, 1)), while DisplayRegions that have + * the "right" channel set will render on the part of the window specified by + * sbs_right_dimensions (typically the right half: (0.5, 1, 0, 1)). + * + * This is commonly used in a dual-monitor mode, where a window is opened that + * spans two monitors, and each monitor represents a different eye. + */ void GraphicsOutput:: set_side_by_side_stereo(bool side_by_side_stereo) { LVecBase4 left, right; @@ -563,23 +501,17 @@ set_side_by_side_stereo(bool side_by_side_stereo) { set_side_by_side_stereo(side_by_side_stereo, left, right); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_side_by_side_stereo -// Access: Published -// Description: Enables side-by-side stereo mode on this particular -// window. When side-by-side stereo mode is in effect, -// DisplayRegions that have the "left" channel set will -// render on the part of the window specified by -// sbs_left_dimensions (typically the left half: (0, -// 0.5, 0, 1)), while DisplayRegions that have the -// "right" channel set will render on the part of the -// window specified by sbs_right_dimensions (typically -// the right half: (0.5, 1, 0, 1)). -// -// This is commonly used in a dual-monitor mode, where a -// window is opened that spans two monitors, and each -// monitor represents a different eye. -//////////////////////////////////////////////////////////////////// +/** + * Enables side-by-side stereo mode on this particular window. When side-by- + * side stereo mode is in effect, DisplayRegions that have the "left" channel + * set will render on the part of the window specified by sbs_left_dimensions + * (typically the left half: (0, 0.5, 0, 1)), while DisplayRegions that have + * the "right" channel set will render on the part of the window specified by + * sbs_right_dimensions (typically the right half: (0.5, 1, 0, 1)). + * + * This is commonly used in a dual-monitor mode, where a window is opened that + * spans two monitors, and each monitor represents a different eye. + */ void GraphicsOutput:: set_side_by_side_stereo(bool side_by_side_stereo, const LVecBase4 &sbs_left_dimensions, @@ -594,18 +526,15 @@ set_side_by_side_stereo(bool side_by_side_stereo, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_delete_flag -// Access: Published -// Description: Returns the current setting of the delete flag. When -// this is true, the GraphicsOutput will automatically -// be removed before the beginning of the next frame by -// the GraphicsEngine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the delete flag. When this is true, the + * GraphicsOutput will automatically be removed before the beginning of the + * next frame by the GraphicsEngine. + */ bool GraphicsOutput:: get_delete_flag() const { - // We only delete the window or buffer automatically when it is - // no longer associated with a texture. + // We only delete the window or buffer automatically when it is no longer + // associated with a texture. for (int i = 0; i < (int)_hold_textures.size(); i++) { if (_hold_textures[i].is_valid_pointer()) { return false; @@ -615,12 +544,10 @@ get_delete_flag() const { return _delete_flag; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_sort -// Access: Published, Virtual -// Description: Adjusts the sorting order of this particular -// GraphicsOutput, relative to other GraphicsOutputs. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the sorting order of this particular GraphicsOutput, relative to + * other GraphicsOutputs. + */ void GraphicsOutput:: set_sort(int sort) { if (_sort != sort) { @@ -631,20 +558,15 @@ set_sort(int sort) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the indicated -// sub-rectangle within the window. The range on all -// parameters is 0..1. -// -// If is_stereo() is true for this window, and -// default-stereo-camera is configured true, this -// actually makes a StereoDisplayRegion. Call -// make_mono_display_region() or -// make_stereo_display_region() if you want to insist on -// one or the other. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the indicated sub-rectangle within + * the window. The range on all parameters is 0..1. + * + * If is_stereo() is true for this window, and default-stereo-camera is + * configured true, this actually makes a StereoDisplayRegion. Call + * make_mono_display_region() or make_stereo_display_region() if you want to + * insist on one or the other. + */ DisplayRegion *GraphicsOutput:: make_display_region(const LVecBase4 &dimensions) { if (is_stereo() && default_stereo_camera) { @@ -654,20 +576,16 @@ make_display_region(const LVecBase4 &dimensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_mono_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the indicated -// sub-rectangle within the window. The range on all -// parameters is 0..1. -// -// This generally returns a mono DisplayRegion, even if -// is_stereo() is true. However, if side-by-side stereo -// is enabled, this will return a StereoDisplayRegion -// whose two eyes are both set to SC_mono. (This is -// necessary because in side-by-side stereo mode, it is -// necessary to draw even mono DisplayRegions twice). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the indicated sub-rectangle within + * the window. The range on all parameters is 0..1. + * + * This generally returns a mono DisplayRegion, even if is_stereo() is true. + * However, if side-by-side stereo is enabled, this will return a + * StereoDisplayRegion whose two eyes are both set to SC_mono. (This is + * necessary because in side-by-side stereo mode, it is necessary to draw even + * mono DisplayRegions twice). + */ DisplayRegion *GraphicsOutput:: make_mono_display_region(const LVecBase4 &dimensions) { if (_side_by_side_stereo) { @@ -680,23 +598,19 @@ make_mono_display_region(const LVecBase4 &dimensions) { return new DisplayRegion(this, dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_stereo_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the indicated -// sub-rectangle within the window. The range on all -// parameters is 0..1. -// -// This always returns a stereo DisplayRegion, even if -// is_stereo() is false. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DisplayRegion that covers the indicated sub-rectangle within + * the window. The range on all parameters is 0..1. + * + * This always returns a stereo DisplayRegion, even if is_stereo() is false. + */ StereoDisplayRegion *GraphicsOutput:: make_stereo_display_region(const LVecBase4 &dimensions) { PT(DisplayRegion) left, right; if (_side_by_side_stereo) { - // On a side-by-side stereo window, each eye gets the - // corresponding dimensions of its own sub-region. + // On a side-by-side stereo window, each eye gets the corresponding + // dimensions of its own sub-region. PN_stdfloat left_l = _sbs_left_dimensions[0]; PN_stdfloat left_b = _sbs_left_dimensions[2]; PN_stdfloat left_w = _sbs_left_dimensions[1] - _sbs_left_dimensions[0]; @@ -724,14 +638,14 @@ make_stereo_display_region(const LVecBase4 &dimensions) { } } else { - // Not a side-by-side stereo window; thus, both the left and right - // eyes are the same region: the region specified. + // Not a side-by-side stereo window; thus, both the left and right eyes + // are the same region: the region specified. left = new DisplayRegion(this, dimensions); right = new DisplayRegion(this, dimensions); - // In this case, we assume that the two eyes will share the same - // depth buffer, which means the right eye should clear the depth - // buffer by default. + // In this case, we assume that the two eyes will share the same depth + // buffer, which means the right eye should clear the depth buffer by + // default. if (get_clear_depth_active()) { right->set_clear_depth_active(true); } @@ -746,15 +660,13 @@ make_stereo_display_region(const LVecBase4 &dimensions) { return stereo; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::remove_display_region -// Access: Published -// Description: Removes the indicated DisplayRegion from the window, -// and destructs it if there are no other references. -// -// Returns true if the DisplayRegion is found and -// removed, false if it was not a part of the window. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated DisplayRegion from the window, and destructs it if + * there are no other references. + * + * Returns true if the DisplayRegion is found and removed, false if it was not + * a part of the window. + */ bool GraphicsOutput:: remove_display_region(DisplayRegion *display_region) { LightMutexHolder holder(_lock); @@ -771,12 +683,10 @@ remove_display_region(DisplayRegion *display_region) { return do_remove_display_region(display_region); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::remove_all_display_regions -// Access: Published -// Description: Removes all display regions from the window, except -// the default one that is created with the window. -//////////////////////////////////////////////////////////////////// +/** + * Removes all display regions from the window, except the default one that is + * created with the window. + */ void GraphicsOutput:: remove_all_display_regions() { LightMutexHolder holder(_lock); @@ -799,37 +709,29 @@ remove_all_display_regions() { _total_display_regions.push_back(_overlay_display_region); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_overlay_display_region -// Access: Published -// Description: Replaces the special "overlay" DisplayRegion that is -// created for each window or buffer. See -// get_overlay_display_region(). This must be a new -// DisplayRegion that has already been created for this -// window, for instance via a call to -// make_mono_display_region(). You are responsible for -// ensuring that the new DisplayRegion covers the entire -// window. The previous overlay display region is not -// automatically removed; you must explicitly call -// remove_display_region() on it after replacing it with -// this method, if you wish it to be removed. -// -// Normally, there is no reason to change the overlay -// DisplayRegion, so this method should be used only -// in very unusual circumstances. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the special "overlay" DisplayRegion that is created for each + * window or buffer. See get_overlay_display_region(). This must be a new + * DisplayRegion that has already been created for this window, for instance + * via a call to make_mono_display_region(). You are responsible for ensuring + * that the new DisplayRegion covers the entire window. The previous overlay + * display region is not automatically removed; you must explicitly call + * remove_display_region() on it after replacing it with this method, if you + * wish it to be removed. + * + * Normally, there is no reason to change the overlay DisplayRegion, so this + * method should be used only in very unusual circumstances. + */ void GraphicsOutput:: set_overlay_display_region(DisplayRegion *display_region) { nassertv(display_region->get_window() == this); _overlay_display_region = display_region; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_num_display_regions -// Access: Published -// Description: Returns the number of DisplayRegions that have -// been created within the window, active or otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of DisplayRegions that have been created within the + * window, active or otherwise. + */ int GraphicsOutput:: get_num_display_regions() const { determine_display_regions(); @@ -841,15 +743,12 @@ get_num_display_regions() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_display_region -// Access: Published -// Description: Returns the nth DisplayRegion of those that have been -// created within the window. This may return NULL if n -// is out of bounds; particularly likely if the number -// of display regions has changed since the last call to -// get_num_display_regions(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth DisplayRegion of those that have been created within the + * window. This may return NULL if n is out of bounds; particularly likely if + * the number of display regions has changed since the last call to + * get_num_display_regions(). + */ PT(DisplayRegion) GraphicsOutput:: get_display_region(int n) const { determine_display_regions(); @@ -865,12 +764,10 @@ get_display_region(int n) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_num_active_display_regions -// Access: Published -// Description: Returns the number of active DisplayRegions that have -// been created within the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of active DisplayRegions that have been created within + * the window. + */ int GraphicsOutput:: get_num_active_display_regions() const { determine_display_regions(); @@ -878,15 +775,12 @@ get_num_active_display_regions() const { return cdata->_active_display_regions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_active_display_region -// Access: Published -// Description: Returns the nth active DisplayRegion of those that -// have been created within the window. This may return -// NULL if n is out of bounds; particularly likely if -// the number of display regions has changed since the -// last call to get_num_active_display_regions(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth active DisplayRegion of those that have been created within + * the window. This may return NULL if n is out of bounds; particularly + * likely if the number of display regions has changed since the last call to + * get_num_active_display_regions(). + */ PT(DisplayRegion) GraphicsOutput:: get_active_display_region(int n) const { determine_display_regions(); @@ -898,39 +792,30 @@ get_active_display_region(int n) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_texture_buffer -// Access: Published -// Description: Creates and returns an offscreen buffer for rendering -// into, the result of which will be a texture suitable -// for applying to geometry within the scene rendered -// into this window. -// -// If tex is not NULL, it is the texture that will be -// set up for rendering into; otherwise, a new Texture -// object will be created. In either case, the target -// texture can be retrieved from the return value with -// buffer->get_texture() (assuming the return value is -// not NULL). -// -// If to_ram is true, the buffer will be set up to -// download its contents to the system RAM memory -// associated with the Texture object, instead of -// keeping it strictly within texture memory; this is -// much slower, but it allows using the texture with any -// GSG. -// -// This will attempt to be smart about maximizing render -// performance while minimizing framebuffer waste. It -// might return a GraphicsBuffer set to render directly -// into a texture, if possible; or it might return a -// ParasiteBuffer that renders into this window. The -// return value is NULL if the buffer could not be -// created for some reason. -// -// When you are done using the buffer, you should remove -// it with a call to GraphicsEngine::remove_window(). -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns an offscreen buffer for rendering into, the result of + * which will be a texture suitable for applying to geometry within the scene + * rendered into this window. + * + * If tex is not NULL, it is the texture that will be set up for rendering + * into; otherwise, a new Texture object will be created. In either case, the + * target texture can be retrieved from the return value with + * buffer->get_texture() (assuming the return value is not NULL). + * + * If to_ram is true, the buffer will be set up to download its contents to + * the system RAM memory associated with the Texture object, instead of + * keeping it strictly within texture memory; this is much slower, but it + * allows using the texture with any GSG. + * + * This will attempt to be smart about maximizing render performance while + * minimizing framebuffer waste. It might return a GraphicsBuffer set to + * render directly into a texture, if possible; or it might return a + * ParasiteBuffer that renders into this window. The return value is NULL if + * the buffer could not be created for some reason. + * + * When you are done using the buffer, you should remove it with a call to + * GraphicsEngine::remove_window(). + */ GraphicsOutput *GraphicsOutput:: make_texture_buffer(const string &name, int x_size, int y_size, Texture *tex, bool to_ram, FrameBufferProperties *fbp) { @@ -963,9 +848,9 @@ make_texture_buffer(const string &name, int x_size, int y_size, if (buffer != (GraphicsOutput *)NULL) { if (buffer->get_gsg() == (GraphicsStateGuardian *)NULL || buffer->get_gsg()->get_prepared_objects() != get_gsg()->get_prepared_objects()) { - // If the newly-created buffer doesn't share texture objects - // with the current GSG, then we will have to force the texture - // copy to go through RAM. + // If the newly-created buffer doesn't share texture objects with the + // current GSG, then we will have to force the texture copy to go + // through RAM. to_ram = true; } @@ -976,35 +861,27 @@ make_texture_buffer(const string &name, int x_size, int y_size, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_cube_map -// Access: Published -// Description: This is similar to make_texture_buffer() in that it -// allocates a separate buffer suitable for rendering to -// a texture that can be assigned to geometry in this -// window, but in this case, the buffer is set up to -// render the six faces of a cube map. -// -// The buffer is automatically set up with six display -// regions and six cameras, each of which are assigned -// the indicated draw_mask and parented to the given -// camera_rig node (which you should then put in your -// scene to render the cube map from the appropriate -// point of view). -// -// You may take the texture associated with the buffer -// and apply it to geometry, particularly with -// TexGenAttrib::M_world_cube_map also in effect, to -// apply a reflection of everything seen by the camera -// rig. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to make_texture_buffer() in that it allocates a separate + * buffer suitable for rendering to a texture that can be assigned to geometry + * in this window, but in this case, the buffer is set up to render the six + * faces of a cube map. + * + * The buffer is automatically set up with six display regions and six + * cameras, each of which are assigned the indicated draw_mask and parented to + * the given camera_rig node (which you should then put in your scene to + * render the cube map from the appropriate point of view). + * + * You may take the texture associated with the buffer and apply it to + * geometry, particularly with TexGenAttrib::M_world_cube_map also in effect, + * to apply a reflection of everything seen by the camera rig. + */ GraphicsOutput *GraphicsOutput:: make_cube_map(const string &name, int size, NodePath &camera_rig, DrawMask camera_mask, bool to_ram, FrameBufferProperties *fbp) { if (!to_ram) { - // Check the limits imposed by the GSG. (However, if we're - // rendering the texture to RAM only, these limits may be - // irrelevant.) + // Check the limits imposed by the GSG. (However, if we're rendering the + // texture to RAM only, these limits may be irrelevant.) GraphicsStateGuardian *gsg = get_gsg(); int max_dimension = gsg->get_max_cube_map_dimension(); if (max_dimension == 0 || !gsg->get_supports_cube_map()) { @@ -1018,11 +895,11 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, } } - // Usually, we want the whole camera_rig to keep itself unrotated - // with respect to the world coordinate space, so the user can apply - // TexGenAttrib::M_world_cube_map to the objects on which the cube - // map texture is applied. If for some reason the user doesn't want - // this behavior, he can take this effect off again. + // Usually, we want the whole camera_rig to keep itself unrotated with + // respect to the world coordinate space, so the user can apply + // TexGenAttrib::M_world_cube_map to the objects on which the cube map + // texture is applied. If for some reason the user doesn't want this + // behavior, he can take this effect off again. camera_rig.node()->set_effect(CompassEffect::make(NodePath())); PT(Texture) tex = new Texture(name); @@ -1033,8 +910,8 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, buffer = make_texture_buffer(name, size, size, tex, to_ram, fbp); - // We don't need to clear the overall buffer; instead, we'll clear - // each display region. + // We don't need to clear the overall buffer; instead, we'll clear each + // display region. buffer->set_clear_color_active(false); buffer->set_clear_depth_active(false); buffer->set_clear_stencil_active(false); @@ -1059,23 +936,17 @@ make_cube_map(const string &name, int size, NodePath &camera_rig, return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_texture_card -// Access: Published -// Description: Returns a PandaNode containing a square polygon. -// The dimensions are (-1,0,-1) to (1,0,1). The texture -// coordinates are such that the texture of this -// GraphicsOutput is aligned properly to the polygon. -// The GraphicsOutput promises to surgically update -// the Geom inside the PandaNode if necessary to maintain -// this invariant. -// -// Each invocation of this function returns a freshly- -// allocated PandaNode. You can therefore safely modify -// the RenderAttribs of the PandaNode. The -// PandaNode is initially textured with the texture -// of this GraphicOutput. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PandaNode containing a square polygon. The dimensions are + * (-1,0,-1) to (1,0,1). The texture coordinates are such that the texture of + * this GraphicsOutput is aligned properly to the polygon. The GraphicsOutput + * promises to surgically update the Geom inside the PandaNode if necessary to + * maintain this invariant. + * + * Each invocation of this function returns a freshly- allocated PandaNode. + * You can therefore safely modify the RenderAttribs of the PandaNode. The + * PandaNode is initially textured with the texture of this GraphicOutput. + */ NodePath GraphicsOutput:: get_texture_card() { if (_texture_card == NULL) { @@ -1093,10 +964,9 @@ get_texture_card() { NodePath path("texture card"); path.node()->add_child(_texture_card); - // The texture card, by default, is textured with the first - // render-to-texture output texture. Depth and stencil - // textures are ignored. The user can freely alter the - // card's texture attrib. + // The texture card, by default, is textured with the first render-to- + // texture output texture. Depth and stencil textures are ignored. The + // user can freely alter the card's texture attrib. CDReader cdata(_cycler); RenderTextures::const_iterator ri; for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) { @@ -1110,134 +980,102 @@ get_texture_card() { return path; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::share_depth_buffer -// Access: Published, Virtual -// Description: Will attempt to use the depth buffer of the input -// graphics_output. The buffer sizes must be exactly -// the same. -//////////////////////////////////////////////////////////////////// +/** + * Will attempt to use the depth buffer of the input graphics_output. The + * buffer sizes must be exactly the same. + */ bool GraphicsOutput:: share_depth_buffer(GraphicsOutput *graphics_output) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::unshare_depth_buffer -// Access: Published, Virtual -// Description: Discontinue sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Discontinue sharing the depth buffer. + */ void GraphicsOutput:: unshare_depth_buffer() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_supports_render_texture -// Access: Published, Virtual -// Description: Returns true if this particular GraphicsOutput can -// render directly into a texture, or false if it must -// always copy-to-texture at the end of each frame to -// achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GraphicsOutput can render directly into a + * texture, or false if it must always copy-to-texture at the end of each + * frame to achieve this effect. + */ bool GraphicsOutput:: get_supports_render_texture() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::flip_ready -// Access: Published, Virtual -// Description: Returns true if a frame has been rendered and needs -// to be flipped, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a frame has been rendered and needs to be flipped, false + * otherwise. + */ bool GraphicsOutput:: flip_ready() const { return _flip_ready; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_host -// Access: Published, Virtual -// Description: This is normally called only from within -// make_texture_buffer(). When called on a -// ParasiteBuffer, it returns the host of that buffer; -// but when called on some other buffer, it returns the -// buffer itself. -//////////////////////////////////////////////////////////////////// +/** + * This is normally called only from within make_texture_buffer(). When + * called on a ParasiteBuffer, it returns the host of that buffer; but when + * called on some other buffer, it returns the buffer itself. + */ GraphicsOutput *GraphicsOutput:: get_host() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::request_open -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the window (or whatever) open itself or, in general, -// make itself valid, at the next call to -// process_events(). -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the window (or + * whatever) open itself or, in general, make itself valid, at the next call + * to process_events(). + */ void GraphicsOutput:: request_open() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::request_close -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the window (or whatever) close itself or, in general, -// make itself invalid, at the next call to -// process_events(). By that time we promise the gsg -// pointer will be cleared. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the window (or + * whatever) close itself or, in general, make itself invalid, at the next + * call to process_events(). By that time we promise the gsg pointer will be + * cleared. + */ void GraphicsOutput:: request_close() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_close_now -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to insist that -// the output be closed immediately. This is only -// called from the window thread. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to insist that the output be closed + * immediately. This is only called from the window thread. + */ void GraphicsOutput:: set_close_now() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::reset_window -// Access: Protected, Virtual -// Description: Resets the window framebuffer from its derived -// children. Does nothing here. -//////////////////////////////////////////////////////////////////// +/** + * Resets the window framebuffer from its derived children. Does nothing + * here. + */ void GraphicsOutput:: reset_window(bool swapchain) { display_cat.info() << "Resetting " << get_type() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear_pipe -// Access: Protected, Virtual -// Description: Sets the window's _pipe pointer to NULL; this is -// generally called only as a precursor to deleting the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Sets the window's _pipe pointer to NULL; this is generally called only as a + * precursor to deleting the window. + */ void GraphicsOutput:: clear_pipe() { _pipe = (GraphicsPipe *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::set_size_and_recalc -// Access: Public -// Description: Changes the x_size and y_size, then recalculates -// structures that depend on size. The recalculation -// currently includes: -// - compute_pixels on all the graphics regions. -// - updating the texture card, if one is present. -//////////////////////////////////////////////////////////////////// +/** + * Changes the x_size and y_size, then recalculates structures that depend on + * size. The recalculation currently includes: - compute_pixels on all the + * graphics regions. - updating the texture card, if one is present. + */ void GraphicsOutput:: set_size_and_recalc(int x, int y) { _size.set(x, y); @@ -1260,16 +1098,13 @@ set_size_and_recalc(int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::clear -// Access: Public, Virtual -// Description: Clears the entire framebuffer before rendering, -// according to the settings of get_color_clear_active() -// and get_depth_clear_active() (inherited from -// DrawableRegion). -// -// This function is called only within the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Clears the entire framebuffer before rendering, according to the settings + * of get_color_clear_active() and get_depth_clear_active() (inherited from + * DrawableRegion). + * + * This function is called only within the draw thread. + */ void GraphicsOutput:: clear(Thread *current_thread) { if (is_any_clear_active()) { @@ -1287,40 +1122,31 @@ clear(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool GraphicsOutput:: begin_frame(FrameMode mode, Thread *current_thread) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void GraphicsOutput:: end_frame(FrameMode mode, Thread *current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::change_scenes -// Access: Public -// Description: Called by the GraphicsEngine when the window is about -// to change to another DisplayRegion. This exists -// mainly to provide a callback for switching the cube -// map face, if we are rendering to the different faces -// of a cube map. -//////////////////////////////////////////////////////////////////// +/** + * Called by the GraphicsEngine when the window is about to change to another + * DisplayRegion. This exists mainly to provide a callback for switching the + * cube map face, if we are rendering to the different faces of a cube map. + */ void GraphicsOutput:: change_scenes(DisplayRegionPipelineReader *new_dr) { int new_target_tex_page = new_dr->get_target_tex_page(); @@ -1343,14 +1169,14 @@ change_scenes(DisplayRegionPipelineReader *new_dr) { Texture *texture = (*ri)._texture; if (rtm_mode != RTM_none) { if (rtm_mode == RTM_bind_or_copy || rtm_mode == RTM_bind_layered) { - // In render-to-texture mode, switch the rendering backend - // to the new page, so that the subsequent frame will be - // rendered to the correct page. + // In render-to-texture mode, switch the rendering backend to the + // new page, so that the subsequent frame will be rendered to the + // correct page. select_target_tex_page(_target_tex_page); } else if (old_target_tex_page != -1) { - // In copy-to-texture mode, copy the just-rendered framebuffer - // to the old texture page. + // In copy-to-texture mode, copy the just-rendered framebuffer to + // the old texture page. nassertv(old_page_dr != (DisplayRegion *)NULL); if (display_cat.is_debug()) { @@ -1393,85 +1219,69 @@ change_scenes(DisplayRegionPipelineReader *new_dr) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::select_target_tex_page -// Access: Public, Virtual -// Description: Called internally when the window is in -// render-to-a-texture mode and we are in the process of -// rendering the six faces of a cube map, or any other -// multi-page texture. This should do whatever needs -// to be done to switch the buffer to the indicated page. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the window is in render-to-a-texture mode and we are + * in the process of rendering the six faces of a cube map, or any other + * multi-page texture. This should do whatever needs to be done to switch the + * buffer to the indicated page. + */ void GraphicsOutput:: select_target_tex_page(int) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void GraphicsOutput:: begin_flip() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::ready_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip when it is command but not actually flip -// -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip when it is command + * but not actually flip + * + */ void GraphicsOutput:: ready_flip() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void GraphicsOutput:: end_flip() { _flip_ready = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::process_events -// Access: Public, Virtual -// Description: Do whatever processing in the window thread is -// appropriate for this output object each frame. -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing in the window thread is appropriate for this output + * object each frame. + * + * This function is called only within the window thread. + */ void GraphicsOutput:: process_events() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::pixel_factor_changed -// Access: Published, Virtual -// Description: Called internally when the pixel factor changes. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the pixel factor changes. + */ void GraphicsOutput:: pixel_factor_changed() { if (_has_size) { @@ -1479,19 +1289,17 @@ pixel_factor_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::prepare_for_deletion -// Access: Protected -// Description: Set the delete flag, and do the usual cleanup -// activities associated with that. -//////////////////////////////////////////////////////////////////// +/** + * Set the delete flag, and do the usual cleanup activities associated with + * that. + */ void GraphicsOutput:: prepare_for_deletion() { CDWriter cdata(_cycler, true); cdata->_active = false; - // If we were rendering directly to texture, we can't delete the - // buffer until all the textures are gone too. + // If we were rendering directly to texture, we can't delete the buffer + // until all the textures are gone too. RenderTextures::iterator ri; for (ri = cdata->_textures.begin(); ri != cdata->_textures.end(); ++ri) { if ((*ri)._rtm_mode == RTM_bind_or_copy || (*ri)._rtm_mode == RTM_bind_layered) { @@ -1502,22 +1310,18 @@ prepare_for_deletion() { _delete_flag = true; - // We have to be sure to remove all of the display regions - // immediately, so that circular reference counts can be cleared - // up (each display region keeps a pointer to a CullResult, - // which can hold all sorts of pointers). + // We have to be sure to remove all of the display regions immediately, so + // that circular reference counts can be cleared up (each display region + // keeps a pointer to a CullResult, which can hold all sorts of pointers). remove_all_display_regions(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::promote_to_copy_texture -// Access: Protected -// Description: If any textures are marked RTM_bind_or_copy, change -// them to RTM_copy_texture. This does not change -// textures that are set to RTM_bind_layered, as -// layered framebuffers aren't supported with -// RTM_copy_texture. -//////////////////////////////////////////////////////////////////// +/** + * If any textures are marked RTM_bind_or_copy, change them to + * RTM_copy_texture. This does not change textures that are set to + * RTM_bind_layered, as layered framebuffers aren't supported with + * RTM_copy_texture. + */ void GraphicsOutput:: promote_to_copy_texture() { CDLockedReader cdata(_cycler); @@ -1541,16 +1345,13 @@ promote_to_copy_texture() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::copy_to_textures -// Access: Protected -// Description: For all textures marked RTM_copy_texture, -// RTM_copy_ram, RTM_triggered_copy_texture, or -// RTM_triggered_copy_ram, do the necessary copies. -// -// Returns true if all copies are successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * For all textures marked RTM_copy_texture, RTM_copy_ram, + * RTM_triggered_copy_texture, or RTM_triggered_copy_ram, do the necessary + * copies. + * + * Returns true if all copies are successful, false otherwise. + */ bool GraphicsOutput:: copy_to_textures() { bool okflag = true; @@ -1624,11 +1425,9 @@ copy_to_textures() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOuput::create_texture_card_vdata -// Access: Private -// Description: Generates a GeomVertexData for a texture card. -//////////////////////////////////////////////////////////////////// +/** + * Generates a GeomVertexData for a texture card. + */ PT(GeomVertexData) GraphicsOutput:: create_texture_card_vdata(int x, int y) { PN_stdfloat xhi = 1.0; @@ -1668,12 +1467,10 @@ create_texture_card_vdata(int x, int y) { return vdata; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::add_display_region -// Access: Private -// Description: Called by the DisplayRegion constructor to -// add the new DisplayRegion to the list. -//////////////////////////////////////////////////////////////////// +/** + * Called by the DisplayRegion constructor to add the new DisplayRegion to the + * list. + */ DisplayRegion *GraphicsOutput:: add_display_region(DisplayRegion *display_region) { LightMutexHolder holder(_lock); @@ -1685,12 +1482,10 @@ add_display_region(DisplayRegion *display_region) { return display_region; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::do_remove_display_region -// Access: Private -// Description: Internal implementation of remove_display_region. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Internal implementation of remove_display_region. Assumes the lock is + * already held. + */ bool GraphicsOutput:: do_remove_display_region(DisplayRegion *display_region) { nassertr(display_region != _overlay_display_region, false); @@ -1713,12 +1508,9 @@ do_remove_display_region(DisplayRegion *display_region) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::do_determine_display_regions -// Access: Private -// Description: Re-sorts the list of active DisplayRegions within -// the window. -//////////////////////////////////////////////////////////////////// +/** + * Re-sorts the list of active DisplayRegions within the window. + */ void GraphicsOutput:: do_determine_display_regions(GraphicsOutput::CData *cdata) { cdata->_active_display_regions_stale = false; @@ -1744,15 +1536,12 @@ do_determine_display_regions(GraphicsOutput::CData *cdata) { stable_sort(cdata->_active_display_regions.begin(), cdata->_active_display_regions.end(), IndirectLess()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::parse_color_mask -// Access: Private, Static -// Description: Parses one of the keywords in the -// red-blue-stereo-colors Config.prc variable, and -// returns the corresponding bitmask. -// -// These bitmask values are taken from ColorWriteAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Parses one of the keywords in the red-blue-stereo-colors Config.prc + * variable, and returns the corresponding bitmask. + * + * These bitmask values are taken from ColorWriteAttrib. + */ unsigned int GraphicsOutput:: parse_color_mask(const string &word) { unsigned int result = 0; @@ -1794,26 +1583,22 @@ parse_color_mask(const string &word) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsOutput::CData:: CData() { - // The default is *not* active, so the entire pipeline stage is - // initially populated with inactive outputs. Pipeline stage 0 is - // set to active in the constructor. + // The default is *not* active, so the entire pipeline stage is initially + // populated with inactive outputs. Pipeline stage 0 is set to active in + // the constructor. _active = false; _one_shot_frame = -1; _active_display_regions_stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsOutput::CData:: CData(const GraphicsOutput::CData ©) : _textures(copy._textures), @@ -1824,20 +1609,17 @@ CData(const GraphicsOutput::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GraphicsOutput::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::FrameMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, GraphicsOutput::FrameMode fm) { switch (fm) { diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index c592b3a09d..59d94489cf 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -1,16 +1,15 @@ -// Filename: graphicsOutput.h -// Created by: drose (06Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutput.h + * @author drose + * @date 2004-02-06 + */ #ifndef GRAPHICSOUTPUT_H #define GRAPHICSOUTPUT_H @@ -45,26 +44,21 @@ class PNMImage; class GraphicsEngine; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsOutput -// Description : This is a base class for the various different -// classes that represent the result of a frame of -// rendering. The most common kind of GraphicsOutput is -// a GraphicsWindow, which is a real-time window on the -// desktop, but another example is GraphicsBuffer, which -// is an offscreen buffer. -// -// The actual rendering, and anything associated with -// the graphics context itself, is managed by the -// associated GraphicsStateGuardian (which might output -// to multiple GraphicsOutput objects). -// -// GraphicsOutputs are not actually writable to bam -// files, of course, but they may be passed as event -// parameters, so they inherit from -// TypedWritableReferenceCount instead of -// TypedReferenceCount for that convenience. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for the various different classes that represent the + * result of a frame of rendering. The most common kind of GraphicsOutput is + * a GraphicsWindow, which is a real-time window on the desktop, but another + * example is GraphicsBuffer, which is an offscreen buffer. + * + * The actual rendering, and anything associated with the graphics context + * itself, is managed by the associated GraphicsStateGuardian (which might + * output to multiple GraphicsOutput objects). + * + * GraphicsOutputs are not actually writable to bam files, of course, but they + * may be passed as event parameters, so they inherit from + * TypedWritableReferenceCount instead of TypedReferenceCount for that + * convenience. + */ class EXPCL_PANDA_DISPLAY GraphicsOutput : public GraphicsOutputBase, public DrawableRegion { protected: GraphicsOutput(GraphicsEngine *engine, @@ -84,8 +78,8 @@ PUBLISHED: enum RenderTextureMode { RTM_none, - // Try to render to the texture directly, but if that is - // not possible, fall back to RTM_copy_texture. + // Try to render to the texture directly, but if that is not possible, + // fall back to RTM_copy_texture. RTM_bind_or_copy, // Copy the image from the buffer to the texture every frame. @@ -94,21 +88,21 @@ PUBLISHED: // Copy the image from the buffer to system RAM every frame. RTM_copy_ram, - // Copy the image from the buffer to the texture after a - // call to trigger_copy(). + // Copy the image from the buffer to the texture after a call to + // trigger_copy(). RTM_triggered_copy_texture, - // Copy the image from the buffer to system RAM after a - // call to trigger_copy(). + // Copy the image from the buffer to system RAM after a call to + // trigger_copy(). RTM_triggered_copy_ram, - // Render directly to a layered texture, such as a cube map, - // 3D texture or 2D texture array. The layer that is being - // rendered to is selected by a geometry shader. + // Render directly to a layered texture, such as a cube map, 3D texture or + // 2D texture array. The layer that is being rendered to is selected by a + // geometry shader. RTM_bind_layered, }; - // There are many reasons to call begin_frame/end_frame. + // There are many reasons to call begin_frameend_frame. enum FrameMode { FM_render, // We are rendering a frame. FM_parasite, // We are rendering a frame of a parasite. @@ -253,9 +247,9 @@ PUBLISHED: MAKE_PROPERTY(supports_render_texture, get_supports_render_texture); PUBLISHED: - // These are not intended to be called directly by the user, but - // they're published anyway since they might occasionally be useful - // for low-level debugging. + // These are not intended to be called directly by the user, but they're + // published anyway since they might occasionally be useful for low-level + // debugging. virtual bool flip_ready() const; virtual GraphicsOutput *get_host(); @@ -271,9 +265,9 @@ public: void set_size_and_recalc(int x, int y); - // It is an error to call any of the following methods from any - // thread other than the draw thread. These methods are normally - // called by the GraphicsEngine. + // It is an error to call any of the following methods from any thread other + // than the draw thread. These methods are normally called by the + // GraphicsEngine. virtual void clear(Thread *current_thread); virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); @@ -286,9 +280,9 @@ public: virtual void ready_flip(); virtual void end_flip(); - // It is an error to call any of the following methods from any - // thread other than the window thread. These methods are normally - // called by the GraphicsEngine. + // It is an error to call any of the following methods from any thread other + // than the window thread. These methods are normally called by the + // GraphicsEngine. virtual void process_events(); INLINE PStatCollector &get_cull_window_pcollector(); @@ -360,10 +354,10 @@ protected: LVecBase4 _sbs_right_dimensions; bool _delete_flag; - // These weak pointers are used to keep track of whether the - // buffer's bound Textures have been deleted or not. Until they - // have, we don't auto-close the buffer (since that would deallocate - // the memory associated with the texture). + // These weak pointers are used to keep track of whether the buffer's bound + // Textures have been deleted or not. Until they have, we don't auto-close + // the buffer (since that would deallocate the memory associated with the + // texture). pvector _hold_textures; protected: @@ -374,9 +368,9 @@ protected: TotalDisplayRegions _total_display_regions; typedef pvector ActiveDisplayRegions; - // This is the data that is associated with the GraphicsOutput that - // needs to be cycled every frame. Mostly we don't cycle this data, - // but we do cycle the textures list, and the active flag. + // This is the data that is associated with the GraphicsOutput that needs to + // be cycled every frame. Mostly we don't cycle this data, but we do cycle + // the textures list, and the active flag. class EXPCL_PANDA_DISPLAY CData : public CycleData { public: CData(); diff --git a/panda/src/display/graphicsPipe.I b/panda/src/display/graphicsPipe.I index 8a178c1230..891c52e2c9 100644 --- a/panda/src/display/graphicsPipe.I +++ b/panda/src/display/graphicsPipe.I @@ -1,105 +1,83 @@ -// Filename: graphicsPipe.I -// Created by: frang (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipe.I + * @author frang + * @date 1999-03-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::is_valid -// Access: Published -// Description: Returns false if this pipe is known to be invalid, -// meaning that an attempt to create a GraphicsWindow -// with the pipe will certainly fail. Returns true if -// the pipe is probably valid (is this case, an attempt -// to create a GraphicsWindow should succeed, but might -// still fail). -// -// Use the GraphicsEngine class to create a -// GraphicsWindow on a particular pipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if this pipe is known to be invalid, meaning that an attempt + * to create a GraphicsWindow with the pipe will certainly fail. Returns true + * if the pipe is probably valid (is this case, an attempt to create a + * GraphicsWindow should succeed, but might still fail). + * + * Use the GraphicsEngine class to create a GraphicsWindow on a particular + * pipe. + */ INLINE bool GraphicsPipe:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_supported_types -// Access: Published -// Description: Returns the mask of bits that represents the kinds of -// GraphicsOutput objects this pipe might be able to -// successfully create. The return value is the union -// of bits in GraphicsPipe::OutputTypes that represents -// the set of GraphicsOutput types. -// -// A 1 bit in a particular position is not a guarantee -// of success, but a 0 bit is a guarantee of failure. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mask of bits that represents the kinds of GraphicsOutput + * objects this pipe might be able to successfully create. The return value + * is the union of bits in GraphicsPipe::OutputTypes that represents the set + * of GraphicsOutput types. + * + * A 1 bit in a particular position is not a guarantee of success, but a 0 bit + * is a guarantee of failure. + */ INLINE int GraphicsPipe:: get_supported_types() const { return _supported_types; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::supports_type -// Access: Published -// Description: A convenience function to ask if a particular type or -// types of GraphicsObjects are supported. The -// parameter is a union of one or more bits defined in -// GrpahicsPipe::OutputTypes. -// -// Returns true if all of the requested types are listed -// in the supported_types mask, false if any one of them -// is not. This is not a guarantee that the indicated -// output type will successfully be created when it is -// attempted. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to ask if a particular type or types of + * GraphicsObjects are supported. The parameter is a union of one or more + * bits defined in GrpahicsPipe::OutputTypes. + * + * Returns true if all of the requested types are listed in the + * supported_types mask, false if any one of them is not. This is not a + * guarantee that the indicated output type will successfully be created when + * it is attempted. + */ INLINE bool GraphicsPipe:: supports_type(int flags) const { return (_supported_types & flags) == flags; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_display_width -// Access: Published -// Description: Returns the width of the entire display, if it is -// known. This may return 0. This is not a guarantee -// that windows (particularly fullscreen windows) may -// not be created larger than this width, but it is -// intended to provide a hint to the application. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the entire display, if it is known. This may return + * 0. This is not a guarantee that windows (particularly fullscreen windows) + * may not be created larger than this width, but it is intended to provide a + * hint to the application. + */ INLINE int GraphicsPipe:: get_display_width() const { return _display_width; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_display_height -// Access: Published -// Description: Returns the height of the entire display, if it is -// known. This may return 0. See the caveats for -// get_display_width(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the entire display, if it is known. This may return + * 0. See the caveats for get_display_width(). + */ INLINE int GraphicsPipe:: get_display_height() const { return _display_height; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_device -// Access: Public -// Description: Returns a pointer to device object -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to device object + */ INLINE GraphicsDevice *GraphicsPipe:: get_device() const { return _device; } - diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index 0a6978db78..996b5694ff 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsPipe.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipe.cxx + * @author mike + * @date 1997-01-09 + */ #include "graphicsPipe.h" #include "graphicsWindow.h" @@ -21,21 +20,19 @@ TypeHandle GraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsPipe:: GraphicsPipe() : _lock("GraphicsPipe") { - // Initially, we assume the GraphicsPipe is valid. A derived class - // should set this to false if it determines otherwise. + // Initially, we assume the GraphicsPipe is valid. A derived class should + // set this to false if it determines otherwise. _is_valid = true; - // A derived class must indicate the kinds of GraphicsOutput objects - // it can create. + // A derived class must indicate the kinds of GraphicsOutput objects it can + // create. _supported_types = 0; _display_width = 0; @@ -44,70 +41,56 @@ GraphicsPipe() : _display_information = new DisplayInformation ( ); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::Copy Constructor -// Access: Private -// Description: Don't try to copy GraphicsPipes. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to copy GraphicsPipes. + */ GraphicsPipe:: GraphicsPipe(const GraphicsPipe &) { _is_valid = false; nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::Copy Assignment Operator -// Access: Private -// Description: Don't try to copy GraphicsPipes. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to copy GraphicsPipes. + */ void GraphicsPipe:: operator = (const GraphicsPipe &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsPipe:: ~GraphicsPipe() { delete _display_information; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ GraphicsPipe::PreferredWindowThread GraphicsPipe::get_preferred_window_thread() const { return PWT_draw; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::make_callback_gsg -// Access: Public, Virtual -// Description: This is called when make_output() is used to create a -// CallbackGraphicsWindow. If the GraphicsPipe can -// construct a GSG that's not associated with any -// particular window object, do so now, assuming the -// correct graphics context has been set up externally. -//////////////////////////////////////////////////////////////////// +/** + * This is called when make_output() is used to create a + * CallbackGraphicsWindow. If the GraphicsPipe can construct a GSG that's not + * associated with any particular window object, do so now, assuming the + * correct graphics context has been set up externally. + */ PT(GraphicsStateGuardian) GraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::make_device -// Access: Public, Virtual -// Description: Creates a new device for the pipe. Only DirectX uses -// this device, for other api's it is NULL. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new device for the pipe. Only DirectX uses this device, for + * other api's it is NULL. + */ PT(GraphicsDevice) GraphicsPipe:: make_device(void *scrn) { display_cat.error() @@ -115,17 +98,13 @@ make_device(void *scrn) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::close_gsg -// Access: Protected, Virtual -// Description: This will be called in the draw thread (the same -// thread in which the GSG was created via make_gsg, -// above) to close the indicated GSG and free its -// associated graphics objects just before it is -// destructed. This method exists to provide a hook for -// the graphics pipe to do any necessary cleanup, if -// any. -//////////////////////////////////////////////////////////////////// +/** + * This will be called in the draw thread (the same thread in which the GSG + * was created via make_gsg, above) to close the indicated GSG and free its + * associated graphics objects just before it is destructed. This method + * exists to provide a hook for the graphics pipe to do any necessary cleanup, + * if any. + */ void GraphicsPipe:: close_gsg(GraphicsStateGuardian *gsg) { if (gsg != (GraphicsStateGuardian *)NULL) { @@ -133,11 +112,9 @@ close_gsg(GraphicsStateGuardian *gsg) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) GraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -153,23 +130,19 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::get_display_information -// Access: Published -// Description: Gets the pipe's DisplayInformation. -//////////////////////////////////////////////////////////////////// +/** + * Gets the pipe's DisplayInformation. + */ DisplayInformation *GraphicsPipe:: get_display_information() { return _display_information; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipe::lookup_cpu_data -// Access: Public, Virtual -// Description: Looks up the detailed CPU information and stores it -// in _display_information, if supported by the OS. -// This may take a second or two. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the detailed CPU information and stores it in + * _display_information, if supported by the OS. This may take a second or + * two. + */ void GraphicsPipe:: lookup_cpu_data() { } diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 83536944e9..462fa3afcf 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: graphicsPipe.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipe.h + * @author mike + * @date 1997-01-09 + */ #ifndef GRAPHICSPIPE_H #define GRAPHICSPIPE_H @@ -33,28 +32,23 @@ class Texture; class WindowHandle; class DisplayInformation; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsPipe -// Description : An object to create GraphicsOutputs that share a -// particular 3-D API. Normally, there will only be one -// GraphicsPipe in an application, although it is -// possible to have multiple of these at once if there -// are multiple different API's available in the same -// machine. -// -// Often, the GraphicsPipe corresponds to a physical -// output device, hence the term "pipe", but this is not -// necessarily the case. -// -// The GraphicsPipe is used by the GraphicsEngine object -// to create and destroy windows; it keeps ownership of -// the windows it creates. -// -// M. Asad added new/interim functionality where GraphicsPipe -// now contains a device interface to directx/opengl which -// will be used to handle multiple windows from same device. -// -//////////////////////////////////////////////////////////////////// +/** + * An object to create GraphicsOutputs that share a particular 3-D API. + * Normally, there will only be one GraphicsPipe in an application, although + * it is possible to have multiple of these at once if there are multiple + * different API's available in the same machine. + * + * Often, the GraphicsPipe corresponds to a physical output device, hence the + * term "pipe", but this is not necessarily the case. + * + * The GraphicsPipe is used by the GraphicsEngine object to create and destroy + * windows; it keeps ownership of the windows it creates. + * + * M. Asad added new/interim functionality where GraphicsPipe now contains a + * device interface to directx/opengl which will be used to handle multiple + * windows from same device. + * + */ class EXPCL_PANDA_DISPLAY GraphicsPipe : public TypedReferenceCount { protected: GraphicsPipe(); diff --git a/panda/src/display/graphicsPipeSelection.I b/panda/src/display/graphicsPipeSelection.I index b7a6a38214..100557bcc5 100644 --- a/panda/src/display/graphicsPipeSelection.I +++ b/panda/src/display/graphicsPipeSelection.I @@ -1,36 +1,29 @@ -// Filename: graphicsPipeSelection.I -// Created by: drose (15Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipeSelection.I + * @author drose + * @date 2002-08-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::get_num_aux_modules -// Access: Published -// Description: Returns the number of display modules that are still -// to be loaded. If this is nonzero, then calling -// load_aux_modules() will likely increase the number of -// GraphicsPipes available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of display modules that are still to be loaded. If this + * is nonzero, then calling load_aux_modules() will likely increase the number + * of GraphicsPipes available. + */ INLINE int GraphicsPipeSelection:: get_num_aux_modules() const { return _display_modules.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the one global -// GraphicsPipeSelection object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the one global GraphicsPipeSelection object. + */ INLINE GraphicsPipeSelection *GraphicsPipeSelection:: get_global_ptr() { if (_global_ptr == (GraphicsPipeSelection *)NULL) { @@ -39,12 +32,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::load_default_module -// Access: Private -// Description: Conditionally calls do_load_default_module(), if it has -// not been called before. -//////////////////////////////////////////////////////////////////// +/** + * Conditionally calls do_load_default_module(), if it has not been called + * before. + */ INLINE void GraphicsPipeSelection:: load_default_module() const { if (!_default_module_loaded) { @@ -52,11 +43,9 @@ load_default_module() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::PipeType::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GraphicsPipeSelection::PipeType:: PipeType(TypeHandle type, PipeConstructorFunc *constructor) : _type(type), diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 4dc7e234b0..9ac0e8aa1f 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsPipeSelection.cxx -// Created by: drose (15Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipeSelection.cxx + * @author drose + * @date 2002-08-15 + */ #include "graphicsPipeSelection.h" #include "lightMutexHolder.h" @@ -26,22 +25,20 @@ GraphicsPipeSelection *GraphicsPipeSelection::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsPipeSelection:: GraphicsPipeSelection() : _lock("GraphicsPipeSelection") { - // We declare these variables here instead of in config_display, in - // case this constructor is running at static init time. + // We declare these variables here instead of in config_display, in case + // this constructor is running at static init time. ConfigVariableString load_display ("load-display", "*", PRC_DESC("Specify the name of the default graphics display library or " "GraphicsPipe to load. It is the name of a shared library (or * for " "all libraries named in aux-display), optionally followed by the " "name of the particular GraphicsPipe class to create.")); - + ConfigVariableList aux_display ("aux-display", PRC_DESC("Names each of the graphics display libraries that are available on " @@ -60,9 +57,8 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") { _display_modules.push_back(_default_display_module); } - // Also get the set of modules named in the various aux-display - // Config variables. We'll want to know this when we call - // load_modules() later. + // Also get the set of modules named in the various aux-display Config + // variables. We'll want to know this when we call load_modules() later. int num_aux = aux_display.get_num_unique_values(); for (int i = 0; i < num_aux; i++) { string name = aux_display.get_unique_value(i); @@ -74,22 +70,17 @@ GraphicsPipeSelection() : _lock("GraphicsPipeSelection") { _default_module_loaded = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsPipeSelection:: ~GraphicsPipeSelection() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::get_num_pipe_types -// Access: Published -// Description: Returns the number of different types of -// GraphicsPipes that are available to create through -// this interface. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different types of GraphicsPipes that are available + * to create through this interface. + */ int GraphicsPipeSelection:: get_num_pipe_types() const { load_default_module(); @@ -102,12 +93,9 @@ get_num_pipe_types() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::get_pipe_type -// Access: Published -// Description: Returns the nth type of GraphicsPipe available -// through this interface. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth type of GraphicsPipe available through this interface. + */ TypeHandle GraphicsPipeSelection:: get_pipe_type(int n) const { load_default_module(); @@ -122,12 +110,10 @@ get_pipe_type(int n) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::print_pipe_types -// Access: Published -// Description: Writes a list of the currently known GraphicsPipe -// types to nout, for the user's information. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the currently known GraphicsPipe types to nout, for the + * user's information. + */ void GraphicsPipeSelection:: print_pipe_types() const { load_default_module(); @@ -142,23 +128,19 @@ print_pipe_types() const { if (_display_modules.empty()) { nout << "(all display modules loaded.)\n"; } else { - nout << "(" << _display_modules.size() + nout << "(" << _display_modules.size() << " aux display modules not yet loaded.)\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::make_pipe -// Access: Published -// Description: Creates a new GraphicsPipe of the indicated type (or -// a type more specific than the indicated type, if -// necessary) and returns it. Returns NULL if the type -// cannot be matched. -// -// If the type is not already defined, this will -// implicitly load the named module, or if module_name -// is empty, it will call load_aux_modules(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GraphicsPipe of the indicated type (or a type more specific + * than the indicated type, if necessary) and returns it. Returns NULL if the + * type cannot be matched. + * + * If the type is not already defined, this will implicitly load the named + * module, or if module_name is empty, it will call load_aux_modules(). + */ PT(GraphicsPipe) GraphicsPipeSelection:: make_pipe(const string &type_name, const string &module_name) { TypeRegistry *type_reg = TypeRegistry::ptr(); @@ -193,14 +175,11 @@ make_pipe(const string &type_name, const string &module_name) { return make_pipe(type); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::make_pipe -// Access: Published -// Description: Creates a new GraphicsPipe of the indicated type (or -// a type more specific than the indicated type, if -// necessary) and returns it. Returns NULL if the type -// cannot be matched. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GraphicsPipe of the indicated type (or a type more specific + * than the indicated type, if necessary) and returns it. Returns NULL if the + * type cannot be matched. + */ PT(GraphicsPipe) GraphicsPipeSelection:: make_pipe(TypeHandle type) { LightMutexHolder holder(_lock); @@ -247,13 +226,11 @@ make_pipe(TypeHandle type) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::make_module_pipe -// Access: Published -// Description: Returns a new GraphicsPipe of a type defined by the -// indicated module. Returns NULL if the module is not -// found or does not properly recommend a GraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GraphicsPipe of a type defined by the indicated module. + * Returns NULL if the module is not found or does not properly recommend a + * GraphicsPipe. + */ PT(GraphicsPipe) GraphicsPipeSelection:: make_module_pipe(const string &module_name) { if (display_cat.is_debug()) { @@ -265,17 +242,15 @@ make_module_pipe(const string &module_name) { if (pipe_type == TypeHandle::none()) { return NULL; } - + return make_pipe(pipe_type); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::make_default_pipe -// Access: Published -// Description: Creates a new GraphicsPipe of some arbitrary type. -// The user may specify a preference using the Configrc -// file; otherwise, one will be chosen arbitrarily. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GraphicsPipe of some arbitrary type. The user may specify a + * preference using the Configrc file; otherwise, one will be chosen + * arbitrarily. + */ PT(GraphicsPipe) GraphicsPipeSelection:: make_default_pipe() { load_default_module(); @@ -284,8 +259,8 @@ make_default_pipe() { PipeTypes::const_iterator ti; if (!_default_pipe_name.empty()) { - // First, look for an exact match of the default type name from - // the Configrc file (excepting case and hyphen/underscore). + // First, look for an exact match of the default type name from the + // Configrc file (excepting case and hyphenunderscore). for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { const PipeType &ptype = (*ti); if (cmp_nocase_uh(ptype._type.get_name(), _default_pipe_name) == 0) { @@ -296,7 +271,7 @@ make_default_pipe() { } } } - + // No match; look for a substring match. string preferred_name = downcase(_default_pipe_name); for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { @@ -311,9 +286,8 @@ make_default_pipe() { } } } - - // Couldn't find a matching pipe type; choose the first one on the - // list. + + // Couldn't find a matching pipe type; choose the first one on the list. for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { const PipeType &ptype = (*ti); PT(GraphicsPipe) pipe = (*ptype._constructor)(); @@ -326,13 +300,10 @@ make_default_pipe() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::load_aux_modules -// Access: Published -// Description: Loads all the modules named in the aux-display -// Configrc variable, making as many graphics pipes as -// possible available. -//////////////////////////////////////////////////////////////////// +/** + * Loads all the modules named in the aux-display Configrc variable, making as + * many graphics pipes as possible available. + */ void GraphicsPipeSelection:: load_aux_modules() { DisplayModules::iterator di; @@ -344,15 +315,12 @@ load_aux_modules() { _default_module_loaded = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::add_pipe_type -// Access: Public -// Description: Adds a new kind of GraphicsPipe to the list of -// available pipes for creation. Normally, this is -// called at static init type by the various shared -// libraries as they are linked in. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new kind of GraphicsPipe to the list of available pipes for + * creation. Normally, this is called at static init type by the various + * shared libraries as they are linked in. Returns true on success, false on + * failure. + */ bool GraphicsPipeSelection:: add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { nassertr(func != NULL, false); @@ -362,9 +330,8 @@ add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { << "Attempt to register " << type << " as a GraphicsPipe type.\n"; return false; } - - // First, make sure we don't already have a GraphicsPipe of this - // type. + + // First, make sure we don't already have a GraphicsPipe of this type. LightMutexHolder holder(_lock); PipeTypes::const_iterator ti; for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { @@ -389,14 +356,11 @@ add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::do_load_default_module -// Access: Private -// Description: Loads the particular display module listed in the -// load-display Configrc variable, which should default -// the default pipe time. If this string is empty or -// "*", loads all modules named in aux-display. -//////////////////////////////////////////////////////////////////// +/** + * Loads the particular display module listed in the load-display Configrc + * variable, which should default the default pipe time. If this string is + * empty or "*", loads all modules named in aux-display. + */ void GraphicsPipeSelection:: do_load_default_module() { if (_default_display_module.empty()) { @@ -407,7 +371,7 @@ do_load_default_module() { load_named_module(_default_display_module); DisplayModules::iterator di = - find(_display_modules.begin(), _display_modules.end(), + find(_display_modules.begin(), _display_modules.end(), _default_display_module); if (di != _display_modules.end()) { _display_modules.erase(di); @@ -416,28 +380,24 @@ do_load_default_module() { _default_module_loaded = true; if (_pipe_types.empty()) { - // If we still don't have any pipes after loading the default - // module, automatically load the aux modules. + // If we still don't have any pipes after loading the default module, + // automatically load the aux modules. load_aux_modules(); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsPipeSelection::load_named_module -// Access: Private -// Description: Loads the indicated display module by looking for a -// matching .dll or .so file. Returns the TypeHandle -// recommended by the module, or TypeHandle::none() on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Loads the indicated display module by looking for a matching .dll or .so + * file. Returns the TypeHandle recommended by the module, or + * TypeHandle::none() on failure. + */ TypeHandle GraphicsPipeSelection:: load_named_module(const string &name) { LightMutexHolder holder(_loaded_modules_lock); LoadedModules::iterator mi = _loaded_modules.find(name); if (mi != _loaded_modules.end()) { - // We have previously loaded this module. Don't attempt to - // re-load it. + // We have previously loaded this module. Don't attempt to re-load it. return (*mi).second._default_pipe_type; } @@ -452,9 +412,8 @@ load_named_module(const string &name) { return TypeHandle::none(); } - // Now get the module's recommended pipe type. This requires - // calling a specially-named function that should have been exported - // from the module. + // Now get the module's recommended pipe type. This requires calling a + // specially-named function that should have been exported from the module. string symbol_name = "get_pipe_type_" + name; void *dso_symbol = get_dso_symbol(handle, symbol_name); if (display_cat.is_debug()) { @@ -471,16 +430,16 @@ load_named_module(const string &name) { << "\n"; } else { - // We successfully loaded the module, and we found the - // get_pipe_type_* recommendation function. Call it to figure - // out what pipe type we should expect. + // We successfully loaded the module, and we found the get_pipe_type_* + // recommendation function. Call it to figure out what pipe type we + // should expect. typedef int FuncType(); int pipe_type_index = (*(FuncType *)dso_symbol)(); if (display_cat.is_debug()) { display_cat.debug() << "pipe_type_index = " << pipe_type_index << "\n"; } - + if (pipe_type_index != 0) { TypeRegistry *type_reg = TypeRegistry::ptr(); pipe_type = type_reg->find_type_by_id(pipe_type_index); @@ -490,11 +449,11 @@ load_named_module(const string &name) { } } } - + if (pipe_type == TypeHandle::none()) { // The recommendation function returned a bogus type index, or the - // function didn't work at all. We can't safely unload the - // module, though, because it may have assigned itself into the + // function didn't work at all. We can't safely unload the module, + // though, because it may have assigned itself into the // GraphicsPipeSelection table. So we carry on. display_cat.warning() << "No default pipe type available for " << dlname.get_basename() diff --git a/panda/src/display/graphicsPipeSelection.h b/panda/src/display/graphicsPipeSelection.h index 5a7d747560..2f0955211c 100644 --- a/panda/src/display/graphicsPipeSelection.h +++ b/panda/src/display/graphicsPipeSelection.h @@ -1,16 +1,15 @@ -// Filename: graphicsPipeSelection.h -// Created by: drose (15Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsPipeSelection.h + * @author drose + * @date 2002-08-15 + */ #ifndef GRAPHICSPIPESELECTION_H #define GRAPHICSPIPESELECTION_H @@ -26,13 +25,11 @@ class HardwareChannel; class GraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsPipeSelection -// Description : This maintains a list of GraphicsPipes by type that -// are available for creation. Normally there is one -// default interactive GraphicsPipe, and possibly other -// types available as well. -//////////////////////////////////////////////////////////////////// +/** + * This maintains a list of GraphicsPipes by type that are available for + * creation. Normally there is one default interactive GraphicsPipe, and + * possibly other types available as well. + */ class EXPCL_PANDA_DISPLAY GraphicsPipeSelection { protected: GraphicsPipeSelection(); @@ -91,9 +88,8 @@ private: bool _default_module_loaded; static GraphicsPipeSelection *_global_ptr; -}; +}; #include "graphicsPipeSelection.I" #endif - diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index 0db5ceeeb6..db8e1f198f 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -1,328 +1,252 @@ -// Filename: graphicsStateGuardian.I -// Created by: drose (24Sep99) -// Updated by: fperazzi, PandaSE (29Apr10) (added -// get_max_2d_texture_array_layers and related) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardian.I + * @author drose + * @date 1999-09-24 + * @author fperazzi, PandaSE + * @date 2010-04-29 + * get_max_2d_texture_array_layers and related) + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all -// Access: Public -// Description: Releases all prepared objects. -//////////////////////////////////////////////////////////////////// +/** + * Releases all prepared objects. + */ INLINE void GraphicsStateGuardian:: release_all() { _prepared_objects->release_all(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all_textures -// Access: Public -// Description: Frees the resources for all textures associated with -// this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources for all textures associated with this GSG. + */ INLINE int GraphicsStateGuardian:: release_all_textures() { return _prepared_objects->release_all_textures(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all_samplers -// Access: Public -// Description: Frees the resources for all samplers associated with -// this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources for all samplers associated with this GSG. + */ INLINE int GraphicsStateGuardian:: release_all_samplers() { return _prepared_objects->release_all_samplers(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all_geoms -// Access: Public -// Description: Frees the resources for all geoms associated with -// this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources for all geoms associated with this GSG. + */ INLINE int GraphicsStateGuardian:: release_all_geoms() { return _prepared_objects->release_all_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all_vertex_buffers -// Access: Public -// Description: Frees the resources for all vertex buffers associated -// with this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources for all vertex buffers associated with this GSG. + */ INLINE int GraphicsStateGuardian:: release_all_vertex_buffers() { return _prepared_objects->release_all_vertex_buffers(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_all_index_buffers -// Access: Public -// Description: Frees the resources for all index buffers associated -// with this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources for all index buffers associated with this GSG. + */ INLINE int GraphicsStateGuardian:: release_all_index_buffers() { return _prepared_objects->release_all_index_buffers(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_active -// Access: Published -// Description: Sets the active flag associated with the -// GraphicsStateGuardian. If the GraphicsStateGuardian -// is marked inactive, nothing is rendered. This is not -// normally turned off unless there is a problem with -// the rendering detected at a low level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag associated with the GraphicsStateGuardian. If the + * GraphicsStateGuardian is marked inactive, nothing is rendered. This is not + * normally turned off unless there is a problem with the rendering detected + * at a low level. + */ INLINE void GraphicsStateGuardian:: set_active(bool active) { _active = active; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::is_active -// Access: Published -// Description: Returns the active flag associated with the -// GraphicsStateGuardian. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag associated with the GraphicsStateGuardian. + */ INLINE bool GraphicsStateGuardian:: is_active() const { return _active && _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::is_valid -// Access: Published -// Description: Returns true if the GSG has been correctly -// initialized within a graphics context, false if there -// has been some problem or it hasn't been initialized -// yet. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the GSG has been correctly initialized within a graphics + * context, false if there has been some problem or it hasn't been initialized + * yet. + */ INLINE bool GraphicsStateGuardian:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::needs_reset -// Access: Public -// Description: Returns true if the gsg is marked as needing a -// reset. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the gsg is marked as needing a reset. + */ INLINE bool GraphicsStateGuardian:: needs_reset() const { return _needs_reset; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_incomplete_render -// Access: Public -// Description: Sets the incomplete_render flag. When this is -// true, the frame will be rendered even if some of the -// geometry or textures in the scene are not available -// (e.g. they have been temporarily paged out). When -// this is false, the frame will be held up while this -// data is reloaded. -// -// Setting this true allows for a smoother frame rate, -// but occasionally parts of the frame will be invisible -// or missing (they will generally come in within a -// second or two). Setting this false guarantees that -// every frame will be complete, but may cause more -// chugs as things are loaded up at runtime. -// -// You may want to set this false during loading -// screens, to guarantee that all of your assets are -// available by the time you take the loading screen -// down. -// -// This flag may also be set individually on each -// DisplayRegion. It will be considered true for a -// given DisplayRegion only if it is true on both the -// GSG and on the DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Sets the incomplete_render flag. When this is true, the frame will be + * rendered even if some of the geometry or textures in the scene are not + * available (e.g. they have been temporarily paged out). When this is + * false, the frame will be held up while this data is reloaded. + * + * Setting this true allows for a smoother frame rate, but occasionally parts + * of the frame will be invisible or missing (they will generally come in + * within a second or two). Setting this false guarantees that every frame + * will be complete, but may cause more chugs as things are loaded up at + * runtime. + * + * You may want to set this false during loading screens, to guarantee that + * all of your assets are available by the time you take the loading screen + * down. + * + * This flag may also be set individually on each DisplayRegion. It will be + * considered true for a given DisplayRegion only if it is true on both the + * GSG and on the DisplayRegion. + */ INLINE void GraphicsStateGuardian:: set_incomplete_render(bool incomplete_render) { _incomplete_render = incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_incomplete_render -// Access: Public, Virtual -// Description: Returns the incomplete_render flag. See -// set_incomplete_render(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the incomplete_render flag. See set_incomplete_render(). + */ INLINE bool GraphicsStateGuardian:: get_incomplete_render() const { return _incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_effective_incomplete_render -// Access: Public, Virtual -// Description: Returns true if the GSG is effectively in -// incomplete_render state, considering both the GSG's -// incomplete_render and its current DisplayRegion's -// incomplete_render flags. It only makes sense to call -// this during the draw traversal; at other times this -// return value will be meaningless. -// -// See CullTraverser::get_effective_incomplete_render() -// for this same information during the cull traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the GSG is effectively in incomplete_render state, + * considering both the GSG's incomplete_render and its current + * DisplayRegion's incomplete_render flags. It only makes sense to call this + * during the draw traversal; at other times this return value will be + * meaningless. + * + * See CullTraverser::get_effective_incomplete_render() for this same + * information during the cull traversal. + */ INLINE bool GraphicsStateGuardian:: get_effective_incomplete_render() const { return _effective_incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_loader -// Access: Public -// Description: Sets the Loader object that will be used by this GSG -// to load textures when necessary, if -// get_incomplete_render() is true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Loader object that will be used by this GSG to load textures when + * necessary, if get_incomplete_render() is true. + */ INLINE void GraphicsStateGuardian:: set_loader(Loader *loader) { _loader = loader; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_loader -// Access: Public -// Description: Returns the Loader object that will be used by this -// GSG to load textures when necessary, if -// get_incomplete_render() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Loader object that will be used by this GSG to load textures + * when necessary, if get_incomplete_render() is true. + */ INLINE Loader *GraphicsStateGuardian:: get_loader() const { return _loader; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_shader_generator -// Access: Public -// Description: Sets the ShaderGenerator object that will be used -// by this GSG to generate shaders when necessary. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ShaderGenerator object that will be used by this GSG to generate + * shaders when necessary. + */ INLINE void GraphicsStateGuardian:: set_shader_generator(ShaderGenerator *shader_generator) { _shader_generator = shader_generator; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_shader_generator -// Access: Public -// Description: Returns the ShaderGenerator object that will be used -// by this GSG to generate shaders when necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ShaderGenerator object that will be used by this GSG to + * generate shaders when necessary. + */ INLINE ShaderGenerator *GraphicsStateGuardian:: get_shader_generator() const { return _shader_generator; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_pipe -// Access: Published -// Description: Returns the graphics pipe on which this GSG was -// created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphics pipe on which this GSG was created. + */ INLINE GraphicsPipe *GraphicsStateGuardian:: get_pipe() const { return _pipe; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_threading_model -// Access: Published -// Description: Returns the threading model that was used to create -// this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the threading model that was used to create this GSG. + */ INLINE const GraphicsThreadingModel &GraphicsStateGuardian:: get_threading_model() const { return _threading_model; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::is_hardware -// Access: Published -// Description: Returns true if this GSG appears to be -// hardware-accelerated, or false if it is known to be -// software only. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG appears to be hardware-accelerated, or false if it + * is known to be software only. + */ INLINE bool GraphicsStateGuardian:: is_hardware() const { return _is_hardware; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prefers_triangle_strips -// Access: Published, Virtual -// Description: Returns true if this GSG strongly prefers triangle -// strips to individual triangles (such as SGI), or -// false if it prefers to minimize the number of -// primitive batches, even at the expense of triangle -// strips (such as most PC hardware). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG strongly prefers triangle strips to individual + * triangles (such as SGI), or false if it prefers to minimize the number of + * primitive batches, even at the expense of triangle strips (such as most PC + * hardware). + */ INLINE bool GraphicsStateGuardian:: prefers_triangle_strips() const { return _prefers_triangle_strips; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_vertices_per_array -// Access: Published, Virtual -// Description: Returns the maximum number of vertices that should be -// put into any one GeomVertexData object for use with -// this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of vertices that should be put into any one + * GeomVertexData object for use with this GSG. + */ INLINE int GraphicsStateGuardian:: get_max_vertices_per_array() const { return _max_vertices_per_array; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_vertices_per_primitive -// Access: Published, Virtual -// Description: Returns the maximum number of vertex indices that -// should be put into any one GeomPrimitive object for -// use with this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of vertex indices that should be put into any + * one GeomPrimitive object for use with this GSG. + */ INLINE int GraphicsStateGuardian:: get_max_vertices_per_primitive() const { return _max_vertices_per_primitive; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_texture_stages -// Access: Published -// Description: Returns the maximum number of simultaneous textures -// that may be applied to geometry with multitexturing, -// as supported by this particular GSG. If you exceed -// this number, the lowest-priority texture stages will -// not be applied. Use TextureStage::set_priority() to -// adjust the relative importance of the different -// texture stages. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of simultaneous textures that may be applied to + * geometry with multitexturing, as supported by this particular GSG. If you + * exceed this number, the lowest-priority texture stages will not be applied. + * Use TextureStage::set_priority() to adjust the relative importance of the + * different texture stages. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_texture_stages() const { if (max_texture_stages > 0) { @@ -331,313 +255,238 @@ get_max_texture_stages() const { return _max_texture_stages; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_texture_dimension -// Access: Published -// Description: Returns the largest possible texture size in any one -// dimension supported by the GSG, or -1 if there is no -// particular limit. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest possible texture size in any one dimension supported by + * the GSG, or -1 if there is no particular limit. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_texture_dimension() const { return _max_texture_dimension; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_3d_texture_dimension -// Access: Published -// Description: Returns the largest possible texture size in any one -// dimension for a 3-d texture, or -1 if there is no -// particular limit. Returns 0 if 3-d textures are not -// supported. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest possible texture size in any one dimension for a 3-d + * texture, or -1 if there is no particular limit. Returns 0 if 3-d textures + * are not supported. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_3d_texture_dimension() const { return _max_3d_texture_dimension; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_2d_texture_array_layers -// Access: Published -// Description: Returns the largest possible number of pages, or -1 -// if there is no particular limit. Returns 0 if 2-d -// texture arrays not supported. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest possible number of pages, or -1 if there is no + * particular limit. Returns 0 if 2-d texture arrays not supported. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_2d_texture_array_layers() const { return _max_2d_texture_array_layers; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_cube_map_dimension -// Access: Published -// Description: Returns the largest possible texture size in any one -// dimension for a cube map texture, or -1 if there is -// no particular limit. Returns 0 if cube map textures -// are not supported. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest possible texture size in any one dimension for a cube + * map texture, or -1 if there is no particular limit. Returns 0 if cube map + * textures are not supported. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_cube_map_dimension() const { return _max_cube_map_dimension; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_buffer_texture_size -// Access: Published -// Description: Returns the largest possible buffer texture size, -// or -1 if there is no particular limit. Returns 0 -// if cube map textures are not supported. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest possible buffer texture size, or -1 if there is no + * particular limit. Returns 0 if cube map textures are not supported. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_buffer_texture_size() const { return _max_buffer_texture_size; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_texture_combine -// Access: Published -// Description: Returns true if this particular GSG can use the -// TextureStage::M_combine mode, which includes all of -// the texture blend modes specified by -// set_combine_rgb() and/or set_combine_alpha(). If -// this is false, you must limit yourself to using the -// simpler blend modes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can use the TextureStage::M_combine + * mode, which includes all of the texture blend modes specified by + * set_combine_rgb() and/or set_combine_alpha(). If this is false, you must + * limit yourself to using the simpler blend modes. + */ INLINE bool GraphicsStateGuardian:: get_supports_texture_combine() const { return _supports_texture_combine; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_texture_saved_result -// Access: Published -// Description: Returns true if this GSG can use the -// TextureStage::CS_last_saved_result source, which -// allows you to save the result of a TextureStage and -// re-use it for multiple inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can use the TextureStage::CS_last_saved_result + * source, which allows you to save the result of a TextureStage and re-use it + * for multiple inputs. + */ INLINE bool GraphicsStateGuardian:: get_supports_texture_saved_result() const { return _supports_texture_saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_texture_dot3 -// Access: Published -// Description: Returns true if this GSG can use the -// TextureStage::CM_dot3_rgb or CM_dot3_rgba combine -// modes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can use the TextureStage::CM_dot3_rgb or + * CM_dot3_rgba combine modes. + */ INLINE bool GraphicsStateGuardian:: get_supports_texture_dot3() const { return _supports_texture_dot3; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_3d_texture -// Access: Published -// Description: Returns true if this GSG can render 3-d (volumetric) -// textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can render 3-d (volumetric) textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_3d_texture() const { return _supports_3d_texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_2d_texture_array -// Access: Published -// Description: Returns true if this GSG can render 2-d textures -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can render 2-d textures array. + */ INLINE bool GraphicsStateGuardian:: get_supports_2d_texture_array() const { return _supports_2d_texture_array; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_cube_map -// Access: Published -// Description: Returns true if this GSG can render cube map textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can render cube map textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_cube_map() const { return _supports_cube_map; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_buffer_texture -// Access: Published -// Description: Returns true if this GSG can render buffer textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can render buffer textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_buffer_texture() const { return _supports_buffer_texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_cube_map_array -// Access: Published -// Description: Returns true if this GSG can render cube map arrays. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can render cube map arrays. + */ INLINE bool GraphicsStateGuardian:: get_supports_cube_map_array() const { return _supports_cube_map_array; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_tex_non_pow2 -// Access: Published -// Description: Returns true if this GSG can handle non power of two -// sized textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can handle non power of two sized textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_tex_non_pow2() const { return _supports_tex_non_pow2; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_texture_srgb -// Access: Published -// Description: Returns true if this GSG can handle sRGB textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can handle sRGB textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_texture_srgb() const { return _supports_texture_srgb; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_compressed_texture -// Access: Published -// Description: Returns true if this GSG can compress textures as it -// loads them into texture memory, and/or accept -// pre-compressed textures for storing. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can compress textures as it loads them into + * texture memory, and/or accept pre-compressed textures for storing. + */ INLINE bool GraphicsStateGuardian:: get_supports_compressed_texture() const { return _supports_compressed_texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_compressed_texture_format -// Access: Published, Virtual -// Description: Returns true if this GSG can accept textures -// pre-compressed in the indicated format. -// compression_mode may be any of the -// Texture::CompressionMode enums. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can accept textures pre-compressed in the + * indicated format. compression_mode may be any of the + * Texture::CompressionMode enums. + */ INLINE bool GraphicsStateGuardian:: get_supports_compressed_texture_format(int compression_mode) const { return _compressed_texture_formats.get_bit(compression_mode); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_lights -// Access: Published -// Description: Returns the maximum number of simultaneous lights -// that may be rendered on geometry, or -1 if there is -// no particular limit. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of simultaneous lights that may be rendered on + * geometry, or -1 if there is no particular limit. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_lights() const { return _max_lights; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_clip_planes -// Access: Published -// Description: Returns the maximum number of simultaneous clip planes -// that may be applied to geometry, or -1 if there is -// no particular limit. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of simultaneous clip planes that may be applied + * to geometry, or -1 if there is no particular limit. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_clip_planes() const { return _max_clip_planes; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_vertex_transforms -// Access: Published -// Description: Returns the maximum number of transform matrices that -// may be simultaneously used to transform any one -// vertex by the graphics hardware. If this number is -// 0, then the hardware (or the graphics backend) -// doesn't support soft-skinned vertices (in which case -// Panda will animate the vertices in software). -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of transform matrices that may be simultaneously + * used to transform any one vertex by the graphics hardware. If this number + * is 0, then the hardware (or the graphics backend) doesn't support soft- + * skinned vertices (in which case Panda will animate the vertices in + * software). + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_vertex_transforms() const { return _max_vertex_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_vertex_transform_indices -// Access: Published -// Description: Returns the maximum number of transforms there may be -// in a single TransformTable for this graphics -// hardware. If this number is 0 (but -// get_max_transforms() is nonzero), then the graphics -// hardware (or API) doesn't support indexed transforms, -// but can support direct transform references. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of transforms there may be in a single + * TransformTable for this graphics hardware. If this number is 0 (but + * get_max_transforms() is nonzero), then the graphics hardware (or API) + * doesn't support indexed transforms, but can support direct transform + * references. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_vertex_transform_indices() const { return _max_vertex_transform_indices; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_copy_texture_inverted -// Access: Published -// Description: Returns true if this particular GSG has the property -// that any framebuffer-to-texture copy results in a -// texture that is upside-down and backwards from -// Panda's usual convention; that is, it copies into a -// texture from the bottom up instead of from the top -// down. -// -// If this is true, then on offscreen GraphicsBuffer -// created for the purposes of rendering into a texture -// should be created with the invert flag set true, to -// compensate. Panda will do this automatically if you -// create an offscreen buffer using -// GraphicsOutput::make_texture_buffer(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG has the property that any framebuffer- + * to-texture copy results in a texture that is upside-down and backwards from + * Panda's usual convention; that is, it copies into a texture from the bottom + * up instead of from the top down. + * + * If this is true, then on offscreen GraphicsBuffer created for the purposes + * of rendering into a texture should be created with the invert flag set + * true, to compensate. Panda will do this automatically if you create an + * offscreen buffer using GraphicsOutput::make_texture_buffer(). + */ INLINE bool GraphicsStateGuardian:: get_copy_texture_inverted() const { // If this is set from a Config variable, that overrides. @@ -649,218 +498,165 @@ get_copy_texture_inverted() const { return _copy_texture_inverted; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_generate_mipmap -// Access: Published -// Description: Returns true if this particular GSG can generate -// mipmaps for a texture automatically, or if they must -// be generated in software. If this is true, then -// mipmaps can safely be enabled for rendered textures -// (e.g. using the MultitexReducer). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can generate mipmaps for a texture + * automatically, or if they must be generated in software. If this is true, + * then mipmaps can safely be enabled for rendered textures (e.g. using the + * MultitexReducer). + */ INLINE bool GraphicsStateGuardian:: get_supports_generate_mipmap() const { return _supports_generate_mipmap; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_depth_texture -// Access: Published -// Description: Returns true if this particular GSG supports -// textures whose format is F_depth_stencil. This -// returns true if the GSG supports GL_DEPTH_COMPONENT -// textures, which are considered a limited but still -// valid case of F_depth_stencil. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports textures whose format is + * F_depth_stencil. This returns true if the GSG supports GL_DEPTH_COMPONENT + * textures, which are considered a limited but still valid case of + * F_depth_stencil. + */ INLINE bool GraphicsStateGuardian:: get_supports_depth_texture() const { return _supports_depth_texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_depth_stencil -// Access: Published -// Description: Returns true if this particular GSG supports -// textures whose format is F_depth_stencil. This -// only returns true if the GSG supports the full -// packed depth-stencil functionality. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports textures whose format is + * F_depth_stencil. This only returns true if the GSG supports the full + * packed depth-stencil functionality. + */ INLINE bool GraphicsStateGuardian:: get_supports_depth_stencil() const { return _supports_depth_stencil; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_shadow_filter -// Access: Published -// Description: Returns true if this particular GSG supports -// the filter mode FT_shadow for depth textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports the filter mode FT_shadow for + * depth textures. + */ INLINE bool GraphicsStateGuardian:: get_supports_shadow_filter() const { return _supports_shadow_filter; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_sampler_objects -// Access: Published -// Description: Returns true if this particular GSG supports the -// use of sampler objects to record texture sampling -// parameters separately from the texture objects. -// This doesn't really affect functionality, but if -// this is false, it may mean that using the same -// texture with different SamplerState objects will -// result in reduced performance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports the use of sampler objects to + * record texture sampling parameters separately from the texture objects. + * This doesn't really affect functionality, but if this is false, it may mean + * that using the same texture with different SamplerState objects will result + * in reduced performance. + */ INLINE bool GraphicsStateGuardian:: get_supports_sampler_objects() const { return _supports_sampler_objects; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_basic_shaders -// Access: Published -// Description: Returns true if this particular GSG supports -// arbfp1+arbvp1 or above. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports arbfp1+arbvp1 or above. + */ INLINE bool GraphicsStateGuardian:: get_supports_basic_shaders() const { return _supports_basic_shaders; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_geometry_shaders -// Access: Published -// Description: Returns true if this particular GSG supports -// geometry shaders. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports geometry shaders. + */ INLINE bool GraphicsStateGuardian:: get_supports_geometry_shaders() const { return _supports_geometry_shaders; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_tessellation_shaders -// Access: Published -// Description: Returns true if this particular GSG supports -// tesselation shaders. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports tesselation shaders. + */ INLINE bool GraphicsStateGuardian:: get_supports_tessellation_shaders() const { return _supports_tessellation_shaders; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_compute_shaders -// Access: Published -// Description: Returns true if this particular GSG supports -// compute shaders. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports compute shaders. + */ INLINE bool GraphicsStateGuardian:: get_supports_compute_shaders() const { return _supports_compute_shaders; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_glsl -// Access: Published -// Description: Returns true if this particular GSG supports -// GLSL shaders. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports GLSL shaders. + */ INLINE bool GraphicsStateGuardian:: get_supports_glsl() const { return _supports_glsl; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_hlsl -// Access: Published -// Description: Returns true if this particular GSG supports -// HLSL shaders. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports HLSL shaders. + */ INLINE bool GraphicsStateGuardian:: get_supports_hlsl() const { return _supports_hlsl; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_stencil -// Access: Published -// Description: Returns true if this particular GSG supports -// stencil buffers at all. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports stencil buffers at all. + */ INLINE bool GraphicsStateGuardian:: get_supports_stencil() const { return _supports_stencil; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_two_sided_stencil -// Access: Published -// Description: Returns true if this particular GSG supports -// two sided stencil: different stencil settings for the -// front and back side of the same polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports two sided stencil: different + * stencil settings for the front and back side of the same polygon. + */ INLINE bool GraphicsStateGuardian:: get_supports_two_sided_stencil() const { return _supports_two_sided_stencil; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_geometry_instancing -// Access: Published -// Description: Returns true if this particular GSG supports -// hardware geometry instancing: the ability to render -// multiple copies of a model. In OpenGL, this is -// done using the EXT_draw_instanced extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports hardware geometry instancing: + * the ability to render multiple copies of a model. In OpenGL, this is done + * using the EXT_draw_instanced extension. + */ INLINE bool GraphicsStateGuardian:: get_supports_geometry_instancing() const { return _supports_geometry_instancing; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_indirect_draw -// Access: Published -// Description: Returns true if this particular GSG supports -// draw calls for which the information comes from a -// buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports draw calls for which the + * information comes from a buffer. + */ INLINE bool GraphicsStateGuardian:: get_supports_indirect_draw() const { return _supports_indirect_draw; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_occlusion_query -// Access: Published -// Description: Returns true if this GSG supports an occlusion query. -// If this is true, then begin_occlusion_query() and -// end_occlusion_query() may be called to bracket a -// sequence of draw_triangles() (or whatever) calls to -// measure pixels that pass the depth test. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG supports an occlusion query. If this is true, + * then begin_occlusion_query() and end_occlusion_query() may be called to + * bracket a sequence of draw_triangles() (or whatever) calls to measure + * pixels that pass the depth test. + */ bool GraphicsStateGuardian:: get_supports_occlusion_query() const { return _supports_occlusion_query; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_timer_query -// Access: Published -// Description: Returns true if this GSG supports a timer query. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG supports a timer query. + */ bool GraphicsStateGuardian:: get_supports_timer_query() const { return _supports_timer_query; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_timer_queries_active -// Access: Published -// Description: Returns true if timer queries are currently -// enabled on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if timer queries are currently enabled on this GSG. + */ bool GraphicsStateGuardian:: get_timer_queries_active() const { #ifdef DO_PSTATS @@ -870,21 +666,16 @@ get_timer_queries_active() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_max_color_targets -// Access: Published -// Description: Returns the maximum number of simultaneous color -// textures that may be attached for render-to-texture, -// as supported by this particular GSG. If you exceed -// this number, the lowest-priority render targets will -// not be applied. Use RenderTarget::set_priority() to -// adjust the relative importance of the different -// render targets. -// -// The value returned may not be meaningful until after -// the graphics context has been fully created (e.g. the -// window has been opened). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of simultaneous color textures that may be + * attached for render-to-texture, as supported by this particular GSG. If + * you exceed this number, the lowest-priority render targets will not be + * applied. Use RenderTarget::set_priority() to adjust the relative + * importance of the different render targets. + * + * The value returned may not be meaningful until after the graphics context + * has been fully created (e.g. the window has been opened). + */ INLINE int GraphicsStateGuardian:: get_max_color_targets() const { if (max_color_targets > 0) { @@ -893,34 +684,27 @@ get_max_color_targets() const { return _max_color_targets; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_maximum_simultaneous_render_targets -// Access: Published -// Description: Deprecated. Use get_max_color_targets() instead, -// which returns the exact same value. -//////////////////////////////////////////////////////////////////// +/** + * Deprecated. Use get_max_color_targets() instead, which returns the exact + * same value. + */ INLINE int GraphicsStateGuardian:: get_maximum_simultaneous_render_targets() const { return get_max_color_targets(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_shader_model -// Access: Published -// Description: Returns the ShaderModel -//////////////////////////////////////////////////////////////////// +/** + * Returns the ShaderModel + */ INLINE GraphicsStateGuardian::ShaderModel GraphicsStateGuardian:: get_shader_model() const { return _shader_model; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_shader_model -// Access: Published -// Description: Sets the ShaderModel. This will override the auto- -// detected shader model during GSG reset. Useful for -// testing lower-end shaders. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ShaderModel. This will override the auto- detected shader model + * during GSG reset. Useful for testing lower-end shaders. + */ INLINE void GraphicsStateGuardian:: set_shader_model(ShaderModel shader_model) { if (shader_model <= _auto_detect_shader_model) { @@ -928,42 +712,33 @@ set_shader_model(ShaderModel shader_model) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_color_scale_via_lighting -// Access: Published -// Description: Returns true if this particular GSG can implement (or -// would prefer to implement) set color and/or color -// scale using materials and/or ambient lights, or -// false if we need to actually munge the color. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can implement (or would prefer to + * implement) set color and/or color scale using materials and/or ambient + * lights, or false if we need to actually munge the color. + */ INLINE bool GraphicsStateGuardian:: get_color_scale_via_lighting() const { return _color_scale_via_lighting; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_alpha_scale_via_texture -// Access: Published -// Description: Returns true if this particular GSG can implement (or -// would prefer to implement) an alpha scale via an -// additional Texture layer, or false if we need to -// actually munge the alpha. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can implement (or would prefer to + * implement) an alpha scale via an additional Texture layer, or false if we + * need to actually munge the alpha. + */ INLINE bool GraphicsStateGuardian:: get_alpha_scale_via_texture() const { return _alpha_scale_via_texture; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_alpha_scale_via_texture -// Access: Published -// Description: This variant of get_alpha_scale_via_texture() answers -// the question of whether the GSG can implement an -// alpha scale via an additional Texture layer, -// considering the current TextureAttrib that will be in -// effect. This considers whether there is at least one -// additional texture slot available on the GSG. -//////////////////////////////////////////////////////////////////// +/** + * This variant of get_alpha_scale_via_texture() answers the question of + * whether the GSG can implement an alpha scale via an additional Texture + * layer, considering the current TextureAttrib that will be in effect. This + * considers whether there is at least one additional texture slot available + * on the GSG. + */ INLINE bool GraphicsStateGuardian:: get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { return _alpha_scale_via_texture && @@ -971,13 +746,10 @@ get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { tex_attrib->get_num_on_stages() < get_max_texture_stages()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_alpha_scale_texture_stage -// Access: Published, Static -// Description: Returns the TextureStage that will be used to apply -// an alpha scale, if get_alpha_scale_via_texture() -// returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextureStage that will be used to apply an alpha scale, if + * get_alpha_scale_via_texture() returns true. + */ INLINE TextureStage *GraphicsStateGuardian:: get_alpha_scale_texture_stage() { if (_alpha_scale_texture_stage == (TextureStage *)NULL) { @@ -987,71 +759,56 @@ get_alpha_scale_texture_stage() { return _alpha_scale_texture_stage; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_runtime_color_scale -// Access: Published -// Description: Returns true if this particular GSG can implement (or -// would prefer to implement) set color and/or color -// scale directly, without requiring any munging of -// vertices or tricks with lighting. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can implement (or would prefer to + * implement) set color and/or color scale directly, without requiring any + * munging of vertices or tricks with lighting. + */ INLINE bool GraphicsStateGuardian:: get_runtime_color_scale() const { return _runtime_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_coordinate_system -// Access: Published -// Description: Returns the coordinate system in effect on this -// particular gsg. Normally, this will be the default -// coordinate system, but it might be set differently at -// runtime. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system in effect on this particular gsg. Normally, + * this will be the default coordinate system, but it might be set differently + * at runtime. + */ INLINE CoordinateSystem GraphicsStateGuardian:: get_coordinate_system() const { return _coordinate_system; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_texture_quality_override -// Access: Published -// Description: Specifies the global quality_level to be imposed for -// all Textures rendered by this GSG. This overrides -// the value set on individual textures via -// Texture::set_quality_level(). Set this to -// Texture::QL_default in order to allow the individual -// texture quality levels to be respected. -// -// This is mainly useful for the tinydisplay software -// renderer. See Texture::set_quality_level(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the global quality_level to be imposed for all Textures rendered + * by this GSG. This overrides the value set on individual textures via + * Texture::set_quality_level(). Set this to Texture::QL_default in order to + * allow the individual texture quality levels to be respected. + * + * This is mainly useful for the tinydisplay software renderer. See + * Texture::set_quality_level(). + */ INLINE void GraphicsStateGuardian:: set_texture_quality_override(Texture::QualityLevel quality_level) { _texture_quality_override = quality_level; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_texture_quality_override -// Access: Published -// Description: Returns the global quality_level override specified -// by set_texture_quality_override. -// -// This is mainly useful for the tinydisplay software -// renderer. See Texture::set_quality_level(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the global quality_level override specified by + * set_texture_quality_override. + * + * This is mainly useful for the tinydisplay software renderer. See + * Texture::set_quality_level(). + */ INLINE Texture::QualityLevel GraphicsStateGuardian:: get_texture_quality_override() const { return _texture_quality_override; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::reset_if_new -// Access: Public -// Description: Calls reset() to initialize the GSG, but only if it -// hasn't been called yet. Returns true if the GSG was -// new, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Calls reset() to initialize the GSG, but only if it hasn't been called yet. + * Returns true if the GSG was new, false otherwise. + */ INLINE bool GraphicsStateGuardian:: reset_if_new() { if (_needs_reset) { @@ -1061,110 +818,84 @@ reset_if_new() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::mark_new -// Access: Public -// Description: Marks the GSG as "new", so that the next call to -// reset_if_new() will be effective. -//////////////////////////////////////////////////////////////////// +/** + * Marks the GSG as "new", so that the next call to reset_if_new() will be + * effective. + */ INLINE void GraphicsStateGuardian:: mark_new() { _needs_reset = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_external_transform -// Access: Public -// Description: Fetches the external net transform. This -// transform is generally only set when geometry is -// about to be rendered. Therefore, this "get" function -// is typically only meaningful during the geometry -// rendering process. -//////////////////////////////////////////////////////////////////// +/** + * Fetches the external net transform. This transform is generally only set + * when geometry is about to be rendered. Therefore, this "get" function is + * typically only meaningful during the geometry rendering process. + */ INLINE CPT(TransformState) GraphicsStateGuardian:: get_external_transform() const { return _inv_cs_transform->compose(_internal_transform); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_internal_transform -// Access: Public -// Description: Fetches the external net transform. This -// transform is generally only set when geometry is -// about to be rendered. Therefore, this "get" function -// is typically only meaningful during the geometry -// rendering process. -//////////////////////////////////////////////////////////////////// +/** + * Fetches the external net transform. This transform is generally only set + * when geometry is about to be rendered. Therefore, this "get" function is + * typically only meaningful during the geometry rendering process. + */ INLINE CPT(TransformState) GraphicsStateGuardian:: get_internal_transform() const { return _internal_transform; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_current_display_region -// Access: Public -// Description: Returns the current display region being rendered to, -// as set by the last call to prepare_display_region(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current display region being rendered to, as set by the last + * call to prepare_display_region(). + */ INLINE const DisplayRegion *GraphicsStateGuardian:: get_current_display_region() const { return _current_display_region; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_current_stereo_channel -// Access: Public -// Description: Returns the current stereo channel being rendered to, -// as set by the last call to prepare_display_region(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current stereo channel being rendered to, as set by the last + * call to prepare_display_region(). + */ INLINE Lens::StereoChannel GraphicsStateGuardian:: get_current_stereo_channel() const { return _current_stereo_channel; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_current_tex_view_offset -// Access: Public -// Description: Returns the current tex view offset, as set by the -// last call to prepare_display_region(). This is read -// from the current DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current tex view offset, as set by the last call to + * prepare_display_region(). This is read from the current DisplayRegion. + */ INLINE int GraphicsStateGuardian:: get_current_tex_view_offset() const { return _current_tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_current_lens -// Access: Public -// Description: Returns the current lens being used to render, -// according to the scene specified via the last call to -// set_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current lens being used to render, according to the scene + * specified via the last call to set_scene(). + */ INLINE const Lens *GraphicsStateGuardian:: get_current_lens() const { return _current_lens; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_inv_cs_transform -// Access: Public -// Description: Returns the inverse of the transform returned by -// get_cs_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of the transform returned by get_cs_transform(). + */ INLINE CPT(TransformState) GraphicsStateGuardian:: get_inv_cs_transform() const { return _inv_cs_transform; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_current_properties -// Access: Protected -// Description: Notifies the gsg that it is about to render into a -// window/buffer with the given FrameBufferProperties -//////////////////////////////////////////////////////////////////// +/** + * Notifies the gsg that it is about to render into a window/buffer with the + * given FrameBufferProperties + */ INLINE void GraphicsStateGuardian:: set_current_properties(const FrameBufferProperties *prop) { _current_properties = prop; } - diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 1fbdd40a69..6f5e873779 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -1,19 +1,19 @@ -// Filename: graphicsStateGuardian.cxx -// Created by: drose (02eb99) -// Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter, -// _max_2d_texture_array_layers, _supports_2d_texture_array, -// get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardian.cxx + * @author drose + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + * _max_2d_texture_array_layers, _supports_2d_texture_array, + * get_supports_cg_profile) + */ #include "graphicsStateGuardian.h" #include "graphicsEngine.h" @@ -133,11 +133,9 @@ PT(TextureStage) GraphicsStateGuardian::_alpha_scale_texture_stage = NULL; TypeHandle GraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsStateGuardian:: GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, @@ -175,21 +173,19 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _max_vertices_per_array = INT_MAX; _max_vertices_per_primitive = INT_MAX; - // Initially, we set this to 1 (the default--no multitexturing - // supported). A derived GSG may set this differently if it - // supports multitexturing. + // Initially, we set this to 1 (the default--no multitexturing supported). + // A derived GSG may set this differently if it supports multitexturing. _max_texture_stages = 1; - // Also initially, we assume there are no limits on texture sizes, - // and that 3-d and cube-map textures are not supported. + // Also initially, we assume there are no limits on texture sizes, and that + // 3-d and cube-map textures are not supported. _max_texture_dimension = -1; _max_3d_texture_dimension = 0; _max_2d_texture_array_layers = 0; _max_cube_map_dimension = 0; _max_buffer_texture_size = 0; - // Assume we don't support these fairly advanced texture combiner - // modes. + // Assume we don't support these fairly advanced texture combiner modes. _supports_texture_combine = false; _supports_texture_saved_result = false; _supports_texture_dot3 = false; @@ -220,13 +216,13 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _timer_queries_active = false; _last_query_frame = 0; _last_num_queried = 0; - //_timer_delta = 0.0; + // _timer_delta = 0.0; _pstats_gpu_thread = -1; #endif - // Initially, we set this to false; a GSG that knows it has this - // property should set it to true. + // Initially, we set this to false; a GSG that knows it has this property + // should set it to true. _copy_texture_inverted = false; // Similarly with these capabilities flags. @@ -253,17 +249,16 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _supported_geom_rendering = 0; - // If this is true, then we can apply a color and/or color scale by - // twiddling the material and/or ambient light (which could mean - // enabling lighting even without a LightAttrib). + // If this is true, then we can apply a color andor color scale by twiddling + // the material andor ambient light (which could mean enabling lighting even + // without a LightAttrib). _color_scale_via_lighting = color_scale_via_lighting; - // Similarly for applying a texture to achieve uniform alpha - // scaling. + // Similarly for applying a texture to achieve uniform alpha scaling. _alpha_scale_via_texture = alpha_scale_via_texture; - // Few GSG's can do this, since it requires touching each vertex as - // it is rendered. + // Few GSG's can do this, since it requires touching each vertex as it is + // rendered. _runtime_color_scale = false; // The default is no shader support. @@ -274,90 +269,72 @@ GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, _texture_quality_override = Texture::QL_default; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsStateGuardian:: ~GraphicsStateGuardian() { remove_gsg(this); GeomMunger::unregister_mungers_for_gsg(this); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_engine -// Access: Published -// Description: Returns the graphics engine that created this GSG. -// Since there is normally only one GraphicsEngine -// object in an application, this is usually the same as -// the global GraphicsEngine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphics engine that created this GSG. Since there is normally + * only one GraphicsEngine object in an application, this is usually the same + * as the global GraphicsEngine. + */ GraphicsEngine *GraphicsStateGuardian:: get_engine() const { nassertr(_engine != (GraphicsEngine *)NULL, GraphicsEngine::get_global_ptr()); return _engine; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_multisample -// Access: Published, Virtual -// Description: Returns true if this particular GSG supports using -// the multisample bits to provide antialiasing, and -// also supports M_multisample and M_multisample_mask -// transparency modes. If this is not true for a -// particular GSG, Panda will map the M_multisample -// modes to M_binary. -// -// This method is declared virtual solely so that it can -// be queried from cullResult.cxx. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports using the multisample bits to + * provide antialiasing, and also supports M_multisample and + * M_multisample_mask transparency modes. If this is not true for a + * particular GSG, Panda will map the M_multisample modes to M_binary. + * + * This method is declared virtual solely so that it can be queried from + * cullResult.cxx. + */ bool GraphicsStateGuardian:: get_supports_multisample() const { return _supports_multisample; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supported_geom_rendering -// Access: Published, Virtual -// Description: Returns the union of Geom::GeomRendering values that -// this particular GSG can support directly. If a Geom -// needs to be rendered that requires some additional -// properties, the StandardMunger and/or the -// CullableObject will convert it as needed. -// -// This method is declared virtual solely so that it can -// be queried from cullableObject.cxx. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of Geom::GeomRendering values that this particular GSG + * can support directly. If a Geom needs to be rendered that requires some + * additional properties, the StandardMunger and/or the CullableObject will + * convert it as needed. + * + * This method is declared virtual solely so that it can be queried from + * cullableObject.cxx. + */ int GraphicsStateGuardian:: get_supported_geom_rendering() const { return _supported_geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_supports_cg_profile -// Access: Published, Virtual -// Description: Returns true if this particular GSG supports the -// specified Cg Shader Profile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports the specified Cg Shader + * Profile. + */ bool GraphicsStateGuardian:: get_supports_cg_profile(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_coordinate_system -// Access: Published -// Description: Changes the coordinate system in effect on this -// particular gsg. This is also called the "external" -// coordinate system, since it is the coordinate system -// used by the scene graph, external to to GSG. -// -// Normally, this will be the default coordinate system, -// but it might be set differently at runtime. It will -// automatically be copied from the current lens's -// coordinate system as each DisplayRegion is rendered. -//////////////////////////////////////////////////////////////////// +/** + * Changes the coordinate system in effect on this particular gsg. This is + * also called the "external" coordinate system, since it is the coordinate + * system used by the scene graph, external to to GSG. + * + * Normally, this will be the default coordinate system, but it might be set + * differently at runtime. It will automatically be copied from the current + * lens's coordinate system as each DisplayRegion is rendered. + */ void GraphicsStateGuardian:: set_coordinate_system(CoordinateSystem cs) { if (cs == CS_default) { @@ -386,41 +363,32 @@ set_coordinate_system(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_internal_coordinate_system -// Access: Published, Virtual -// Description: Returns the coordinate system used internally by the -// GSG. This may be the same as the external coordinate -// system reported by get_coordinate_system(), or it may -// be something different. -// -// In any case, vertices that have been transformed -// before being handed to the GSG (that is, vertices -// with a contents value of C_clip_point) will be -// expected to be in this coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system used internally by the GSG. This may be the + * same as the external coordinate system reported by get_coordinate_system(), + * or it may be something different. + * + * In any case, vertices that have been transformed before being handed to the + * GSG (that is, vertices with a contents value of C_clip_point) will be + * expected to be in this coordinate system. + */ CoordinateSystem GraphicsStateGuardian:: get_internal_coordinate_system() const { return _internal_coordinate_system; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_prepared_objects -// Access: Public, Virtual -// Description: Returns the set of texture and geom objects that have -// been prepared with this GSG (and possibly other GSG's -// that share objects). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of texture and geom objects that have been prepared with + * this GSG (and possibly other GSG's that share objects). + */ PreparedGraphicsObjects *GraphicsStateGuardian:: get_prepared_objects() { return _prepared_objects; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_gamma -// Access: Published, Virtual -// Description: Set gamma. Returns true on success. -//////////////////////////////////////////////////////////////////// +/** + * Set gamma. Returns true on success. + */ bool GraphicsStateGuardian:: set_gamma(PN_stdfloat gamma) { _gamma = gamma; @@ -428,32 +396,25 @@ set_gamma(PN_stdfloat gamma) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_gamma -// Access: Published -// Description: Get the current gamma setting. -//////////////////////////////////////////////////////////////////// +/** + * Get the current gamma setting. + */ PN_stdfloat GraphicsStateGuardian:: get_gamma() const { return _gamma; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::restore_gamma -// Access: Published, Virtual -// Description: Restore original gamma setting. -//////////////////////////////////////////////////////////////////// +/** + * Restore original gamma setting. + */ void GraphicsStateGuardian:: restore_gamma() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::traverse_prepared_textures -// Access: Public -// Description: Calls the indicated function on all -// currently-prepared textures, or until the callback -// function returns false. -//////////////////////////////////////////////////////////////////// +/** + * Calls the indicated function on all currently-prepared textures, or until + * the callback function returns false. + */ void GraphicsStateGuardian:: traverse_prepared_textures(GraphicsStateGuardian::TextureCallback *func, void *callback_arg) { @@ -470,29 +431,23 @@ traverse_prepared_textures(GraphicsStateGuardian::TextureCallback *func, } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_flash_texture -// Access: Published -// Description: Sets the "flash texture". This is a debug feature; -// when enabled, the specified texture will begin -// flashing in the scene, helping you to find it -// visually. -// -// The texture also flashes with a color code: blue for -// mipmap level 0, yellow for mipmap level 1, and red -// for mipmap level 2 or higher (even for textures that -// don't have mipmaps). This gives you an idea of the -// choice of the texture size. If it is blue, the -// texture is being drawn the proper size or magnified; -// if it is yellow, it is being minified a little bit; -// and if it red, it is being minified considerably. If -// you see a red texture when you are right in front of -// it, you should consider reducing the size of the -// texture to avoid wasting texture memory. -// -// Not all rendering backends support the flash_texture -// feature. Presently, it is only supported by OpenGL. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "flash texture". This is a debug feature; when enabled, the + * specified texture will begin flashing in the scene, helping you to find it + * visually. + * + * The texture also flashes with a color code: blue for mipmap level 0, yellow + * for mipmap level 1, and red for mipmap level 2 or higher (even for textures + * that don't have mipmaps). This gives you an idea of the choice of the + * texture size. If it is blue, the texture is being drawn the proper size or + * magnified; if it is yellow, it is being minified a little bit; and if it + * red, it is being minified considerably. If you see a red texture when you + * are right in front of it, you should consider reducing the size of the + * texture to avoid wasting texture memory. + * + * Not all rendering backends support the flash_texture feature. Presently, + * it is only supported by OpenGL. + */ void GraphicsStateGuardian:: set_flash_texture(Texture *tex) { _flash_texture = tex; @@ -500,12 +455,10 @@ set_flash_texture(Texture *tex) { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::clear_flash_texture -// Access: Published -// Description: Resets the "flash texture", so that no textures will -// flash. See set_flash_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the "flash texture", so that no textures will flash. See + * set_flash_texture(). + */ void GraphicsStateGuardian:: clear_flash_texture() { _flash_texture = NULL; @@ -513,27 +466,22 @@ clear_flash_texture() { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_flash_texture -// Access: Published -// Description: Returns the current "flash texture", if any, or NULL -// if none. See set_flash_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current "flash texture", if any, or NULL if none. See + * set_flash_texture(). + */ Texture *GraphicsStateGuardian:: get_flash_texture() const { return _flash_texture; } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_scene -// Access: Published -// Description: Sets the SceneSetup object that indicates the initial -// camera position, etc. This must be called before -// traversal begins. Returns true if the scene is -// acceptable, false if something's wrong. This should -// be called in the draw thread only. -//////////////////////////////////////////////////////////////////// +/** + * Sets the SceneSetup object that indicates the initial camera position, etc. + * This must be called before traversal begins. Returns true if the scene is + * acceptable, false if something's wrong. This should be called in the draw + * thread only. + */ bool GraphicsStateGuardian:: set_scene(SceneSetup *scene_setup) { _scene_setup = scene_setup; @@ -552,233 +500,179 @@ set_scene(SceneSetup *scene_setup) { return prepare_lens(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_scene -// Access: Published, Virtual -// Description: Returns the current SceneSetup object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current SceneSetup object. + */ SceneSetup *GraphicsStateGuardian:: get_scene() const { return _scene_setup; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_texture -// Access: Public, Virtual -// Description: Creates whatever structures the GSG requires to -// represent the texture internally, and returns a -// newly-allocated TextureContext object with this data. -// It is the responsibility of the calling function to -// later call release_texture() with this same pointer -// (which will also delete the pointer). -// -// This function should not be called directly to -// prepare a texture. Instead, call Texture::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates whatever structures the GSG requires to represent the texture + * internally, and returns a newly-allocated TextureContext object with this + * data. It is the responsibility of the calling function to later call + * release_texture() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a texture. Instead, + * call Texture::prepare(). + */ TextureContext *GraphicsStateGuardian:: prepare_texture(Texture *) { return (TextureContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::update_texture -// Access: Public, Virtual -// Description: Ensures that the current Texture data is refreshed -// onto the GSG. This means updating the texture -// properties and/or re-uploading the texture image, if -// necessary. This should only be called within the -// draw thread. -// -// If force is true, this function will not return until -// the texture has been fully uploaded. If force is -// false, the function may choose to upload a simple -// version of the texture instead, if the texture is not -// fully resident (and if get_incomplete_render() is -// true). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the current Texture data is refreshed onto the GSG. This + * means updating the texture properties and/or re-uploading the texture + * image, if necessary. This should only be called within the draw thread. + * + * If force is true, this function will not return until the texture has been + * fully uploaded. If force is false, the function may choose to upload a + * simple version of the texture instead, if the texture is not fully resident + * (and if get_incomplete_render() is true). + */ bool GraphicsStateGuardian:: update_texture(TextureContext *, bool) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_texture -// Access: Public, Virtual -// Description: Frees the resources previously allocated via a call -// to prepare_texture(), including deleting the -// TextureContext itself, if it is non-NULL. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources previously allocated via a call to prepare_texture(), + * including deleting the TextureContext itself, if it is non-NULL. + */ void GraphicsStateGuardian:: release_texture(TextureContext *) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::extract_texture_data -// Access: Public, Virtual -// Description: This method should only be called by the -// GraphicsEngine. Do not call it directly; call -// GraphicsEngine::extract_texture_data() instead. -// -// This method will be called in the draw thread to -// download the texture memory's image into its -// ram_image value. It returns true on success, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method should only be called by the GraphicsEngine. Do not call it + * directly; call GraphicsEngine::extract_texture_data() instead. + * + * This method will be called in the draw thread to download the texture + * memory's image into its ram_image value. It returns true on success, false + * otherwise. + */ bool GraphicsStateGuardian:: extract_texture_data(Texture *) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_sampler -// Access: Public, Virtual -// Description: Creates whatever structures the GSG requires to -// represent the sampler internally, and returns a -// newly-allocated SamplerContext object with this data. -// It is the responsibility of the calling function to -// later call release_sampler() with this same pointer -// (which will also delete the pointer). -// -// This function should not be called directly to -// prepare a sampler. Instead, call Texture::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates whatever structures the GSG requires to represent the sampler + * internally, and returns a newly-allocated SamplerContext object with this + * data. It is the responsibility of the calling function to later call + * release_sampler() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a sampler. Instead, + * call Texture::prepare(). + */ SamplerContext *GraphicsStateGuardian:: prepare_sampler(const SamplerState &sampler) { return (SamplerContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_sampler -// Access: Public, Virtual -// Description: Frees the resources previously allocated via a call -// to prepare_sampler(), including deleting the -// SamplerContext itself, if it is non-NULL. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources previously allocated via a call to prepare_sampler(), + * including deleting the SamplerContext itself, if it is non-NULL. + */ void GraphicsStateGuardian:: release_sampler(SamplerContext *) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_geom -// Access: Public, Virtual -// Description: Prepares the indicated Geom for retained-mode -// rendering, by creating whatever structures are -// necessary in the GSG (for instance, vertex buffers). -// Returns the newly-allocated GeomContext that can be -// used to render the geom. -//////////////////////////////////////////////////////////////////// +/** + * Prepares the indicated Geom for retained-mode rendering, by creating + * whatever structures are necessary in the GSG (for instance, vertex + * buffers). Returns the newly-allocated GeomContext that can be used to + * render the geom. + */ GeomContext *GraphicsStateGuardian:: prepare_geom(Geom *) { return (GeomContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_geom -// Access: Public, Virtual -// Description: Frees the resources previously allocated via a call -// to prepare_geom(), including deleting the GeomContext -// itself, if it is non-NULL. -// -// This function should not be called directly to -// prepare a Geom. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources previously allocated via a call to prepare_geom(), + * including deleting the GeomContext itself, if it is non-NULL. + * + * This function should not be called directly to prepare a Geom. Instead, + * call Geom::prepare(). + */ void GraphicsStateGuardian:: release_geom(GeomContext *) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_shader -// Access: Public, Virtual -// Description: Compile a vertex/fragment shader body. -//////////////////////////////////////////////////////////////////// +/** + * Compile a vertex/fragment shader body. + */ ShaderContext *GraphicsStateGuardian:: prepare_shader(Shader *shader) { return (ShaderContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_shader -// Access: Public, Virtual -// Description: Releases the resources allocated by prepare_shader -//////////////////////////////////////////////////////////////////// +/** + * Releases the resources allocated by prepare_shader + */ void GraphicsStateGuardian:: release_shader(ShaderContext *sc) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_vertex_buffer -// Access: Public, Virtual -// Description: Prepares the indicated buffer for retained-mode -// rendering. -//////////////////////////////////////////////////////////////////// +/** + * Prepares the indicated buffer for retained-mode rendering. + */ VertexBufferContext *GraphicsStateGuardian:: prepare_vertex_buffer(GeomVertexArrayData *) { return (VertexBufferContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_vertex_buffer -// Access: Public, Virtual -// Description: Frees the resources previously allocated via a call -// to prepare_data(), including deleting the -// VertexBufferContext itself, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources previously allocated via a call to prepare_data(), + * including deleting the VertexBufferContext itself, if necessary. + */ void GraphicsStateGuardian:: release_vertex_buffer(VertexBufferContext *) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_index_buffer -// Access: Public, Virtual -// Description: Prepares the indicated buffer for retained-mode -// rendering. -//////////////////////////////////////////////////////////////////// +/** + * Prepares the indicated buffer for retained-mode rendering. + */ IndexBufferContext *GraphicsStateGuardian:: prepare_index_buffer(GeomPrimitive *) { return (IndexBufferContext *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::release_index_buffer -// Access: Public, Virtual -// Description: Frees the resources previously allocated via a call -// to prepare_data(), including deleting the -// IndexBufferContext itself, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources previously allocated via a call to prepare_data(), + * including deleting the IndexBufferContext itself, if necessary. + */ void GraphicsStateGuardian:: release_index_buffer(IndexBufferContext *) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_occlusion_query -// Access: Public, Virtual -// Description: Begins a new occlusion query. After this call, you -// may call begin_draw_primitives() and -// draw_triangles()/draw_whatever() repeatedly. -// Eventually, you should call end_occlusion_query() -// before the end of the frame; that will return a new -// OcclusionQueryContext object that will tell you how -// many pixels represented by the bracketed geometry -// passed the depth test. -// -// It is not valid to call begin_occlusion_query() -// between another begin_occlusion_query() -// .. end_occlusion_query() sequence. -//////////////////////////////////////////////////////////////////// +/** + * Begins a new occlusion query. After this call, you may call + * begin_draw_primitives() and draw_triangles()/draw_whatever() repeatedly. + * Eventually, you should call end_occlusion_query() before the end of the + * frame; that will return a new OcclusionQueryContext object that will tell + * you how many pixels represented by the bracketed geometry passed the depth + * test. + * + * It is not valid to call begin_occlusion_query() between another + * begin_occlusion_query() .. end_occlusion_query() sequence. + */ void GraphicsStateGuardian:: begin_occlusion_query() { nassertv(_current_occlusion_query == (OcclusionQueryContext *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_occlusion_query -// Access: Public, Virtual -// Description: Ends a previous call to begin_occlusion_query(). -// This call returns the OcclusionQueryContext object -// that will (eventually) report the number of pixels -// that passed the depth test between the call to -// begin_occlusion_query() and end_occlusion_query(). -//////////////////////////////////////////////////////////////////// +/** + * Ends a previous call to begin_occlusion_query(). This call returns the + * OcclusionQueryContext object that will (eventually) report the number of + * pixels that passed the depth test between the call to + * begin_occlusion_query() and end_occlusion_query(). + */ PT(OcclusionQueryContext) GraphicsStateGuardian:: end_occlusion_query() { nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); @@ -787,44 +681,37 @@ end_occlusion_query() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::issue_timer_query -// Access: Public, Virtual -// Description: Adds a timer query to the command stream, associated -// with the given PStats collector index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a timer query to the command stream, associated with the given PStats + * collector index. + */ PT(TimerQueryContext) GraphicsStateGuardian:: issue_timer_query(int pstats_index) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::dispatch_compute -// Access: Public, Virtual -// Description: Dispatches a currently bound compute shader using -// the given work group counts. -//////////////////////////////////////////////////////////////////// +/** + * Dispatches a currently bound compute shader using the given work group + * counts. + */ void GraphicsStateGuardian:: dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { nassertv(false /* Compute shaders not supported by GSG */); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_geom_munger -// Access: Public, Virtual -// Description: Looks up or creates a GeomMunger object to munge -// vertices appropriate to this GSG for the indicated -// state. -//////////////////////////////////////////////////////////////////// +/** + * Looks up or creates a GeomMunger object to munge vertices appropriate to + * this GSG for the indicated state. + */ PT(GeomMunger) GraphicsStateGuardian:: get_geom_munger(const RenderState *state, Thread *current_thread) { RenderState::Mungers &mungers = state->_mungers; if (!mungers.is_empty()) { - // Before we even look up the map, see if the _last_mi value points - // to this GSG. This is likely because we tend to visit the same - // state multiple times during a frame. Also, this might well be - // the only GSG in the world anyway. + // Before we even look up the map, see if the _last_mi value points to + // this GSG. This is likely because we tend to visit the same state + // multiple times during a frame. Also, this might well be the only GSG + // in the world anyway. int mi = state->_last_mi; if (mi >= 0 && mungers.has_element(mi) && mungers.get_key(mi) == this) { PT(GeomMunger) munger = mungers.get_data(mi); @@ -841,8 +728,7 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { state->_last_mi = mi; return munger; } else { - // This GeomMunger is no longer registered. Remove it from - // the map. + // This GeomMunger is no longer registered. Remove it from the map. mungers.remove_element(mi); } } @@ -857,29 +743,23 @@ get_geom_munger(const RenderState *state, Thread *current_thread) { return munger; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::make_geom_munger -// Access: Public, Virtual -// Description: Creates a new GeomMunger object to munge vertices -// appropriate to this GSG for the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GeomMunger object to munge vertices appropriate to this GSG + * for the indicated state. + */ PT(GeomMunger) GraphicsStateGuardian:: make_geom_munger(const RenderState *state, Thread *current_thread) { - // The default implementation returns no munger at all, but - // presumably, every kind of GSG needs some special munging action, - // so real GSG's will override this to return something more - // useful. + // The default implementation returns no munger at all, but presumably, + // every kind of GSG needs some special munging action, so real GSG's will + // override this to return something more useful. return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::compute_distance_to -// Access: Public, Virtual -// Description: This function will compute the distance to the -// indicated point, assumed to be in eye coordinates, -// from the camera plane. The point is assumed to be -// in the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * This function will compute the distance to the indicated point, assumed to + * be in eye coordinates, from the camera plane. The point is assumed to be + * in the GSG's internal coordinate system. + */ PN_stdfloat GraphicsStateGuardian:: compute_distance_to(const LPoint3 &point) const { switch (_internal_coordinate_system) { @@ -903,39 +783,31 @@ compute_distance_to(const LPoint3 &point) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::fetch_specified_value -// Access: Public -// Description: The gsg contains a large number of useful matrices: -// -// * the world transform, -// * the modelview matrix, -// * the cs_transform, -// * etc, etc. -// -// A shader can request any of these values, and -// furthermore, it can request that various compositions, -// inverses, and transposes be performed. The -// ShaderMatSpec is a data structure indicating what -// datum is desired and what conversions to perform. -// This routine, fetch_specified_value, is responsible for -// doing the actual retrieval and conversions. -// -// Some values, like the following, aren't matrices: -// -// * window size -// * texture coordinates of card center -// -// This routine can fetch these values as well, by -// shoehorning them into a matrix. In this way, we avoid -// the need for a separate routine to fetch these values. -// -// The "altered" bits indicate what parts of the -// state_and_transform have changed since the last -// time this particular ShaderMatSpec was evaluated. -// This may allow data to be cached and not reevaluated. -// -//////////////////////////////////////////////////////////////////// +/** + * The gsg contains a large number of useful matrices: + * + * * the world transform, * the modelview matrix, * the cs_transform, * etc, + * etc. + * + * A shader can request any of these values, and furthermore, it can request + * that various compositions, inverses, and transposes be performed. The + * ShaderMatSpec is a data structure indicating what datum is desired and what + * conversions to perform. This routine, fetch_specified_value, is + * responsible for doing the actual retrieval and conversions. + * + * Some values, like the following, aren't matrices: + * + * * window size * texture coordinates of card center + * + * This routine can fetch these values as well, by shoehorning them into a + * matrix. In this way, we avoid the need for a separate routine to fetch + * these values. + * + * The "altered" bits indicate what parts of the state_and_transform have + * changed since the last time this particular ShaderMatSpec was evaluated. + * This may allow data to be cached and not reevaluated. + * + */ const LMatrix4 *GraphicsStateGuardian:: fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { LVecBase3 v; @@ -992,11 +864,9 @@ fetch_specified_value(Shader::ShaderMatSpec &spec, int altered) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::fetch_specified_part -// Access: Public -// Description: See fetch_specified_value -//////////////////////////////////////////////////////////////////// +/** + * See fetch_specified_value + */ const LMatrix4 *GraphicsStateGuardian:: fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, LMatrix4 &t, int index) { @@ -1240,8 +1110,8 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } } case Shader::SMO_tex_is_alpha_i: { - // This is a hack so we can support both F_alpha and other - // formats in the default shader, to fix font rendering in GLES2 + // This is a hack so we can support both F_alpha and other formats in the + // default shader, to fix font rendering in GLES2 const TextureAttrib *ta; if (_target_rs->get_attrib(ta) && index < ta->get_num_on_stages()) { @@ -1441,8 +1311,8 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_mat_constant_x_attrib: { if (_target_shader->has_shader_input(name)) { - // There is an input specifying precisely this whole thing, with - // dot and all. Support this, even if only for backward compatibility. + // There is an input specifying precisely this whole thing, with dot and + // all. Support this, even if only for backward compatibility. return &_target_shader->get_shader_input_matrix(name, t); } @@ -1453,8 +1323,8 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } case Shader::SMO_vec_constant_x_attrib: { if (_target_shader->has_shader_input(name)) { - // There is an input specifying precisely this whole thing, with - // dot and all. Support this, even if only for backward compatibility. + // There is an input specifying precisely this whole thing, with dot and + // all. Support this, even if only for backward compatibility. const LVecBase4 &data = _target_shader->get_shader_input_vector(name); t = LMatrix4(data[0],data[1],data[2],data[3], data[0],data[1],data[2],data[3], @@ -1472,9 +1342,9 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, const LightAttrib *target_light; _target_rs->get_attrib_def(target_light); - // We want to ignore ambient lights. To that effect, iterate through - // the list of lights. In the future, we will improve this system, by - // also filtering down to the number of lights specified by the shader. + // We want to ignore ambient lights. To that effect, iterate through the + // list of lights. In the future, we will improve this system, by also + // filtering down to the number of lights specified by the shader. int i = 0; int num_on_lights = target_light->get_num_on_lights(); @@ -1500,12 +1370,10 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name, } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::fetch_specified_member -// Access: Public -// Description: Given a NodePath passed into a shader input that is -// a structure, fetches the value for the given member. -//////////////////////////////////////////////////////////////////// +/** + * Given a NodePath passed into a shader input that is a structure, fetches + * the value for the given member. + */ const LMatrix4 *GraphicsStateGuardian:: fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) { // This system is not ideal. It will be improved in the future. @@ -1743,11 +1611,9 @@ fetch_specified_member(const NodePath &np, CPT_InternalName attrib, LMatrix4 &t) } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::fetch_specified_texture -// Access: Public -// Description: Like fetch_specified_value, but for texture inputs. -//////////////////////////////////////////////////////////////////// +/** + * Like fetch_specified_value, but for texture inputs. + */ PT(Texture) GraphicsStateGuardian:: fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, int &view) { @@ -1849,23 +1715,18 @@ fetch_specified_texture(Shader::ShaderTexSpec &spec, SamplerState &sampler, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::fetch_ptr_parameter -// Access: Public -// Description: Return a pointer to struct ShaderPtrData -//////////////////////////////////////////////////////////////////// +/** + * Return a pointer to struct ShaderPtrData + */ const Shader::ShaderPtrData *GraphicsStateGuardian:: fetch_ptr_parameter(const Shader::ShaderPtrSpec& spec) { return (_target_shader->get_shader_input_ptr(spec._arg)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_display_region -// Access: Public, Virtual -// Description: Makes the specified DisplayRegion current. All -// future drawing and clear operations will be -// constrained within the given DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Makes the specified DisplayRegion current. All future drawing and clear + * operations will be constrained within the given DisplayRegion. + */ void GraphicsStateGuardian:: prepare_display_region(DisplayRegionPipelineReader *dr) { _current_display_region = dr->get_object(); @@ -1913,29 +1774,22 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::clear_before_callback -// Access: Public, Virtual -// Description: Resets any non-standard graphics state that might -// give a callback apoplexy. Some drivers require that -// the graphics state be restored to neutral before -// performing certain operations. In OpenGL, for -// instance, this closes any open vertex buffers. -//////////////////////////////////////////////////////////////////// +/** + * Resets any non-standard graphics state that might give a callback apoplexy. + * Some drivers require that the graphics state be restored to neutral before + * performing certain operations. In OpenGL, for instance, this closes any + * open vertex buffers. + */ void GraphicsStateGuardian:: clear_before_callback() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::clear_state_and_transform -// Access: Public, Virtual -// Description: Forgets the current graphics state and current -// transform, so that the next call to -// set_state_and_transform() will have to reload -// everything. This is a good thing to call when you -// are no longer sure what the graphics state is. This -// should only be called from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Forgets the current graphics state and current transform, so that the next + * call to set_state_and_transform() will have to reload everything. This is + * a good thing to call when you are no longer sure what the graphics state + * is. This should only be called from the draw thread. + */ void GraphicsStateGuardian:: clear_state_and_transform() { // Re-issue the modelview and projection transforms. @@ -1946,15 +1800,11 @@ clear_state_and_transform() { _state_mask.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::remove_window -// Access: Public, Virtual -// Description: This is simply a transparent call to -// GraphicsEngine::remove_window(). It exists primary -// to support removing a window from that compiles -// before the display module, and therefore has no -// knowledge of a GraphicsEngine object. -//////////////////////////////////////////////////////////////////// +/** + * This is simply a transparent call to GraphicsEngine::remove_window(). It + * exists primary to support removing a window from that compiles before the + * display module, and therefore has no knowledge of a GraphicsEngine object. + */ void GraphicsStateGuardian:: remove_window(GraphicsOutputBase *window) { nassertv(_engine != (GraphicsEngine *)NULL); @@ -1963,30 +1813,24 @@ remove_window(GraphicsOutputBase *window) { _engine->remove_window(win); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::prepare_lens -// Access: Public, Virtual -// Description: Makes the current lens (whichever lens was most -// recently specified with set_scene()) active, so -// that it will transform future rendered geometry. -// Normally this is only called from the draw process, -// and usually it is called by set_scene(). -// -// The return value is true if the lens is acceptable, -// false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Makes the current lens (whichever lens was most recently specified with + * set_scene()) active, so that it will transform future rendered geometry. + * Normally this is only called from the draw process, and usually it is + * called by set_scene(). + * + * The return value is true if the lens is acceptable, false if it is not. + */ bool GraphicsStateGuardian:: prepare_lens() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::calc_projection_mat -// Access: Public, Virtual -// Description: Given a lens, this function calculates the appropriate -// projection matrix for this gsg. The result depends -// on the peculiarities of the rendering API. -//////////////////////////////////////////////////////////////////// +/** + * Given a lens, this function calculates the appropriate projection matrix + * for this gsg. The result depends on the peculiarities of the rendering + * API. + */ CPT(TransformState) GraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { if (lens == (Lens *)NULL) { @@ -2000,49 +1844,42 @@ calc_projection_mat(const Lens *lens) { return TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_frame -// Access: Public, Virtual -// Description: Called before each frame is rendered, to allow the -// GSG a chance to do any internal cleanup before -// beginning the frame. -// -// The return value is true if successful (in which case -// the frame will be drawn and end_frame() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_frame() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called before each frame is rendered, to allow the GSG a chance to do any + * internal cleanup before beginning the frame. + * + * The return value is true if successful (in which case the frame will be + * drawn and end_frame() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_frame() will not be called). + */ bool GraphicsStateGuardian:: begin_frame(Thread *current_thread) { _prepared_objects->begin_frame(this, current_thread); - // We should reset the state to the default at the beginning of - // every frame. Although this will incur additional overhead, - // particularly in a simple scene, it helps ensure that states that - // have changed properties since last time without changing - // attribute pointers--like textures, lighting, or fog--will still - // be accurately updated. + // We should reset the state to the default at the beginning of every frame. + // Although this will incur additional overhead, particularly in a simple + // scene, it helps ensure that states that have changed properties since + // last time without changing attribute pointers--like textures, lighting, + // or fog--will still be accurately updated. _state_rs = RenderState::make_empty(); _state_mask.clear(); #ifdef DO_PSTATS - // We have to do this here instead of in GraphicsEngine because - // we need a current context to issue timer queries. + // We have to do this here instead of in GraphicsEngine because we need a + // current context to issue timer queries. int frame = ClockObject::get_global_clock()->get_frame_count(); if (_last_query_frame < frame) { _last_query_frame = frame; _timer_queries_pcollector.clear_level(); - // Now is a good time to flush previous frame's queries. We - // may not actually have all of the previous frame's results - // in yet, but that's okay; the GPU data is allowed to lag a - // few frames behind. + // Now is a good time to flush previous frame's queries. We may not + // actually have all of the previous frame's results in yet, but that's + // okay; the GPU data is allowed to lag a few frames behind. flush_timer_queries(); if (_timer_queries_active) { - // Issue a stop and start event for collector 0, marking the - // beginning of the new frame. + // Issue a stop and start event for collector 0, marking the beginning + // of the new frame. issue_timer_query(0x8000); issue_timer_query(0x0000); } @@ -2052,47 +1889,39 @@ begin_frame(Thread *current_thread) { return !_needs_reset; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_scene -// Access: Published, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the beginning of drawing commands for a "scene" -// (usually a particular DisplayRegion) within a frame. -// All 3-D drawing commands, except the clear operation, -// must be enclosed within begin_scene() .. end_scene(). -// This must be called in the draw thread. -// -// The return value is true if successful (in which case -// the scene will be drawn and end_scene() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_scene() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the beginning of + * drawing commands for a "scene" (usually a particular DisplayRegion) within + * a frame. All 3-D drawing commands, except the clear operation, must be + * enclosed within begin_scene() .. end_scene(). This must be called in the + * draw thread. + * + * The return value is true if successful (in which case the scene will be + * drawn and end_scene() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_scene() will not be called). + */ bool GraphicsStateGuardian:: begin_scene() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_scene -// Access: Published, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the end of drawing commands for a "scene" (usually a -// particular DisplayRegion) within a frame. All 3-D -// drawing commands, except the clear operation, must be -// enclosed within begin_scene() .. end_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the end of drawing + * commands for a "scene" (usually a particular DisplayRegion) within a frame. + * All 3-D drawing commands, except the clear operation, must be enclosed + * within begin_scene() .. end_scene(). + */ void GraphicsStateGuardian:: end_scene() { // We should clear this pointer now, so that we don't keep unneeded - // reference counts dangling. We keep around a "null" scene setup - // object instead of using a null pointer to avoid special-case code - // in set_state_and_transform. + // reference counts dangling. We keep around a "null" scene setup object + // instead of using a null pointer to avoid special-case code in + // set_state_and_transform. _scene_setup = _scene_null; - // Undo any lighting we had enabled last scene, to force the lights - // to be reissued, in case their parameters or positions have - // changed between scenes. + // Undo any lighting we had enabled last scene, to force the lights to be + // reissued, in case their parameters or positions have changed between + // scenes. int i; for (i = 0; i < _num_lights_enabled; ++i) { enable_light(i, false); @@ -2110,13 +1939,10 @@ end_scene() { _state_mask.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_frame -// Access: Public, Virtual -// Description: Called after each frame is rendered, to allow the -// GSG a chance to do any internal cleanup after -// rendering the frame, and before the window flips. -//////////////////////////////////////////////////////////////////// +/** + * Called after each frame is rendered, to allow the GSG a chance to do any + * internal cleanup after rendering the frame, and before the window flips. + */ void GraphicsStateGuardian:: end_frame(Thread *current_thread) { _prepared_objects->end_frame(current_thread); @@ -2141,23 +1967,20 @@ end_frame(Thread *current_thread) { _transform_state_pcollector.flush_level(); _draw_primitive_pcollector.flush_level(); - // Evict any textures and/or vbuffers that exceed our texture memory. + // Evict any textures andor vbuffers that exceed our texture memory. _prepared_objects->_graphics_memory_lru.begin_epoch(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::flush_timer_queries -// Access: Public -// Description: Called by the graphics engine on the draw thread -// to check the status of the running timer queries -// and submit their results to the PStats server. -//////////////////////////////////////////////////////////////////// +/** + * Called by the graphics engine on the draw thread to check the status of the + * running timer queries and submit their results to the PStats server. + */ void GraphicsStateGuardian:: flush_timer_queries() { #ifdef DO_PSTATS - // This uses the lower-level PStats interfaces for now because - // of all the unnecessary overhead that would otherwise be incurred - // when adding such a large amount of data at once. + // This uses the lower-level PStats interfaces for now because of all the + // unnecessary overhead that would otherwise be incurred when adding such a + // large amount of data at once. PStatClient *client = PStatClient::get_global_pstats(); @@ -2175,8 +1998,8 @@ flush_timer_queries() { } } - // Currently, we use one thread per GSG, for convenience. In the - // future, we may want to try and use one thread per graphics card. + // Currently, we use one thread per GSG, for convenience. In the future, we + // may want to try and use one thread per graphics card. if (_pstats_gpu_thread == -1) { _pstats_gpu_thread = client->make_gpu_thread(get_driver_renderer()).get_index(); } @@ -2193,8 +2016,8 @@ flush_timer_queries() { PStatGPUTimer timer(this, _wait_timer_pcollector); if (_last_num_queried > 0) { - // We know how many queries were available last frame, and this - // usually stays fairly constant, so use this as a starting point. + // We know how many queries were available last frame, and this usually + // stays fairly constant, so use this as a starting point. int i = min(_last_num_queried, count) - 1; if (_pending_timer_queries[i]->is_answer_ready()) { @@ -2215,9 +2038,9 @@ flush_timer_queries() { } } } else { - // We figure out which tasks the GPU has already finished by doing - // a binary search for the first query that does not have an answer - // ready. We know then that everything before that must be ready. + // We figure out which tasks the GPU has already finished by doing a + // binary search for the first query that does not have an answer ready. + // We know then that everything before that must be ready. while (count > 0) { int step = count / 2; int i = first + step; @@ -2256,9 +2079,9 @@ flush_timer_queries() { _pstats_gpu_data.add_start(query->_pstats_index & 0x7fff, time_data); } - // We found an end-frame marker (a stop event for collector 0). - // This means that the GPU actually caught up with that frame, - // and we can flush the GPU thread's frame data to the pstats server. + // We found an end-frame marker (a stop event for collector 0). This + // means that the GPU actually caught up with that frame, and we can + // flush the GPU thread's frame data to the pstats server. if (query->_pstats_index == 0x8000) { gpu_thread.add_frame(_pstats_gpu_data); _pstats_gpu_data.clear(); @@ -2277,30 +2100,23 @@ flush_timer_queries() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can implement decals using a DepthOffsetAttrib, or + * false if that is unreliable and the three-step rendering process should be + * used instead. + */ bool GraphicsStateGuardian:: depth_offset_decals() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_decal_base_first -// Access: Public, Virtual -// Description: Called during draw to begin a three-step rendering -// phase to draw decals. The first step, -// begin_decal_base_first(), is called prior to drawing the -// base geometry. It should set up whatever internal -// state is appropriate, as well as returning a -// RenderState object that should be applied to the base -// geometry for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Called during draw to begin a three-step rendering phase to draw decals. + * The first step, begin_decal_base_first(), is called prior to drawing the + * base geometry. It should set up whatever internal state is appropriate, as + * well as returning a RenderState object that should be applied to the base + * geometry for rendering. + */ CPT(RenderState) GraphicsStateGuardian:: begin_decal_base_first() { // Turn off writing the depth buffer to render the base geometry. @@ -2313,20 +2129,16 @@ begin_decal_base_first() { return decal_base_first; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_decal_nested -// Access: Public, Virtual -// Description: Called during draw to begin a three-step rendering -// phase to draw decals. The second step, -// begin_decal_nested(), is called after drawing the -// base geometry and prior to drawing any of the nested -// decal geometry that is to be applied to the base -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Called during draw to begin a three-step rendering phase to draw decals. + * The second step, begin_decal_nested(), is called after drawing the base + * geometry and prior to drawing any of the nested decal geometry that is to + * be applied to the base geometry. + */ CPT(RenderState) GraphicsStateGuardian:: begin_decal_nested() { - // We should keep the depth buffer off during this operation, so - // that decals on decals will render properly. + // We should keep the depth buffer off during this operation, so that decals + // on decals will render properly. static CPT(RenderState) decal_nested; if (decal_nested == (const RenderState *)NULL) { decal_nested = RenderState::make @@ -2336,58 +2148,46 @@ begin_decal_nested() { return decal_nested; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_decal_base_second -// Access: Public, Virtual -// Description: Called during draw to begin a three-step rendering -// phase to draw decals. The third step, -// begin_decal_base_second(), is called after drawing the -// base geometry and the nested decal geometry, and -// prior to drawing the base geometry one more time (if -// needed). -// -// It should return a RenderState object appropriate for -// rendering the base geometry the second time, or NULL -// if it is not necessary to re-render the base -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Called during draw to begin a three-step rendering phase to draw decals. + * The third step, begin_decal_base_second(), is called after drawing the base + * geometry and the nested decal geometry, and prior to drawing the base + * geometry one more time (if needed). + * + * It should return a RenderState object appropriate for rendering the base + * geometry the second time, or NULL if it is not necessary to re-render the + * base geometry. + */ CPT(RenderState) GraphicsStateGuardian:: begin_decal_base_second() { - // Now let the depth buffer go back on, but turn off writing the - // color buffer to render the base geometry after the second pass. - // Also, turn off texturing since there's no need for it now. + // Now let the depth buffer go back on, but turn off writing the color + // buffer to render the base geometry after the second pass. Also, turn off + // texturing since there's no need for it now. static CPT(RenderState) decal_base_second; if (decal_base_second == (const RenderState *)NULL) { decal_base_second = RenderState::make (ColorWriteAttrib::make(ColorWriteAttrib::C_off), - // On reflection, we need to leave texturing on so the alpha - // test mechanism can work (if it is enabled, e.g. we are - // rendering an object with M_dual transparency). - // TextureAttrib::make_off(), + // On reflection, we need to leave texturing on so the alpha test + // mechanism can work (if it is enabled, e.g. we are rendering an + // object with M_dual transparency). TextureAttrib::make_off(), RenderState::get_max_priority()); } return decal_base_second; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::finish_decal -// Access: Public, Virtual -// Description: Called during draw to clean up after decals are -// finished. -//////////////////////////////////////////////////////////////////// +/** + * Called during draw to clean up after decals are finished. + */ void GraphicsStateGuardian:: finish_decal() { // No need to do anything special here. } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_draw_primitives() -// Access: Public, Virtual -// Description: Called before a sequence of draw_primitive() -// functions are called, this should prepare the vertex -// data for rendering. It returns true if the vertices -// are ok, false to abort this group of primitives. -//////////////////////////////////////////////////////////////////// +/** + * Called before a sequence of draw_primitive() functions are called, this + * should prepare the vertex data for rendering. It returns true if the + * vertices are ok, false to abort this group of primitives. + */ bool GraphicsStateGuardian:: begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, @@ -2398,96 +2198,76 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return _data_reader->has_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_triangles -// Access: Public, Virtual -// Description: Draws a series of disconnected triangles. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected triangles. + */ bool GraphicsStateGuardian:: draw_triangles(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_tristrips -// Access: Public, Virtual -// Description: Draws a series of triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle strips. + */ bool GraphicsStateGuardian:: draw_tristrips(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_trifans -// Access: Public, Virtual -// Description: Draws a series of triangle fans. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle fans. + */ bool GraphicsStateGuardian:: draw_trifans(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_patches -// Access: Public, Virtual -// Description: Draws a series of "patches", which can only be -// processed by a tessellation shader. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of "patches", which can only be processed by a tessellation + * shader. + */ bool GraphicsStateGuardian:: draw_patches(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_lines -// Access: Public, Virtual -// Description: Draws a series of disconnected line segments. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected line segments. + */ bool GraphicsStateGuardian:: draw_lines(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_linestrips -// Access: Public, Virtual -// Description: Draws a series of line strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of line strips. + */ bool GraphicsStateGuardian:: draw_linestrips(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::draw_points -// Access: Public, Virtual -// Description: Draws a series of disconnected points. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected points. + */ bool GraphicsStateGuardian:: draw_points(const GeomPrimitivePipelineReader *, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_draw_primitives() -// Access: Public, Virtual -// Description: Called after a sequence of draw_primitive() -// functions are called, this should do whatever cleanup -// is appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Called after a sequence of draw_primitive() functions are called, this + * should do whatever cleanup is appropriate. + */ void GraphicsStateGuardian:: end_draw_primitives() { _munger = NULL; _data_reader = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void GraphicsStateGuardian:: reset() { _needs_reset = false; @@ -2527,64 +2307,50 @@ reset() { _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_state_and_transform -// Access: Public -// Description: Simultaneously resets the render state and the -// transform state. -// -// This transform specified is the "internal" net -// transform, already converted into the GSG's internal -// coordinate space by composing it to -// get_cs_transform(). (Previously, this used to be the -// "external" net transform, with the assumption that -// that GSG would convert it internally, but that is no -// longer the case.) -// -// Special case: if (state==NULL), then the target -// state is already stored in _target. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously resets the render state and the transform state. + * + * This transform specified is the "internal" net transform, already converted + * into the GSG's internal coordinate space by composing it to + * get_cs_transform(). (Previously, this used to be the "external" net + * transform, with the assumption that that GSG would convert it internally, + * but that is no longer the case.) + * + * Special case: if (state==NULL), then the target state is already stored in + * _target. + */ void GraphicsStateGuardian:: set_state_and_transform(const RenderState *state, const TransformState *trans) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::clear -// Access: Public -// Description: Clears the framebuffer within the current -// DisplayRegion, according to the flags indicated by -// the given DrawableRegion object. -// -// This does not set the DisplayRegion first. You -// should call prepare_display_region() to specify the -// region you wish the clear operation to apply to. -//////////////////////////////////////////////////////////////////// +/** + * Clears the framebuffer within the current DisplayRegion, according to the + * flags indicated by the given DrawableRegion object. + * + * This does not set the DisplayRegion first. You should call + * prepare_display_region() to specify the region you wish the clear operation + * to apply to. + */ void GraphicsStateGuardian:: clear(DrawableRegion *clearable) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_render_buffer -// Access: Public -// Description: Returns a RenderBuffer object suitable for operating -// on the requested set of buffers. buffer_type is the -// union of all the desired RenderBuffer::Type values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderBuffer object suitable for operating on the requested set + * of buffers. buffer_type is the union of all the desired RenderBuffer::Type + * values. + */ RenderBuffer GraphicsStateGuardian:: get_render_buffer(int buffer_type, const FrameBufferProperties &prop) { return RenderBuffer(this, buffer_type & prop.get_buffer_mask() & _stereo_buffer_mask); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_cs_transform_for -// Access: Public, Virtual -// Description: Returns what the cs_transform would be set to after a -// call to set_coordinate_system(cs). This is another -// way of saying the cs_transform when rendering the -// scene for a camera with the indicated coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns what the cs_transform would be set to after a call to + * set_coordinate_system(cs). This is another way of saying the cs_transform + * when rendering the scene for a camera with the indicated coordinate system. + */ CPT(TransformState) GraphicsStateGuardian:: get_cs_transform_for(CoordinateSystem cs) const { if (_coordinate_system == cs) { @@ -2601,28 +2367,21 @@ get_cs_transform_for(CoordinateSystem cs) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_cs_transform -// Access: Public, Virtual -// Description: Returns a transform that converts from the GSG's -// external coordinate system (as returned by -// get_coordinate_system()) to its internal coordinate -// system (as returned by -// get_internal_coordinate_system()). This is used for -// rendering. -//////////////////////////////////////////////////////////////////// +/** + * Returns a transform that converts from the GSG's external coordinate system + * (as returned by get_coordinate_system()) to its internal coordinate system + * (as returned by get_internal_coordinate_system()). This is used for + * rendering. + */ CPT(TransformState) GraphicsStateGuardian:: get_cs_transform() const { return _cs_transform; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::do_issue_clip_plane -// Access: Public -// Description: This is fundametically similar to do_issue_light(), with -// calls to apply_clip_plane() and enable_clip_planes(), -// as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * This is fundametically similar to do_issue_light(), with calls to + * apply_clip_plane() and enable_clip_planes(), as appropriate. + */ void GraphicsStateGuardian:: do_issue_clip_plane() { int num_enabled = 0; @@ -2675,19 +2434,14 @@ do_issue_clip_plane() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::do_issue_color -// Access: Public -// Description: This method is defined in the base class because it -// is likely that this functionality will be used for -// all (or at least most) kinds of -// GraphicsStateGuardians--it's not specific to any one -// rendering backend. -// -// The ColorAttribute just changes the interpretation of -// the color on the vertices, and fiddles with -// _vertex_colors_enabled, etc. -//////////////////////////////////////////////////////////////////// +/** + * This method is defined in the base class because it is likely that this + * functionality will be used for all (or at least most) kinds of + * GraphicsStateGuardians--it's not specific to any one rendering backend. + * + * The ColorAttribute just changes the interpretation of the color on the + * vertices, and fiddles with _vertex_colors_enabled, etc. + */ void GraphicsStateGuardian:: do_issue_color() { const ColorAttrib *target_color = (const ColorAttrib *) @@ -2695,24 +2449,24 @@ do_issue_color() { switch (target_color->get_color_type()) { case ColorAttrib::T_flat: - // Color attribute flat: it specifies a scene graph color that - // overrides the vertex color. + // Color attribute flat: it specifies a scene graph color that overrides + // the vertex color. _scene_graph_color = target_color->get_color(); _has_scene_graph_color = true; _vertex_colors_enabled = false; break; case ColorAttrib::T_off: - // Color attribute off: it specifies that no scene graph color is - // in effect, and vertex color is not important either. + // Color attribute off: it specifies that no scene graph color is in + // effect, and vertex color is not important either. _scene_graph_color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_scene_graph_color = false; _vertex_colors_enabled = false; break; case ColorAttrib::T_vertex: - // Color attribute vertex: it specifies that vertex color should - // be revealed. + // Color attribute vertex: it specifies that vertex color should be + // revealed. _scene_graph_color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_scene_graph_color = false; _vertex_colors_enabled = true; @@ -2727,15 +2481,13 @@ do_issue_color() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::do_issue_color_scale -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GraphicsStateGuardian:: do_issue_color_scale() { - // If the previous color scale had set a special texture, clear the - // texture now. + // If the previous color scale had set a special texture, clear the texture + // now. if (_has_texture_alpha_scale) { _state_mask.clear_bit(TextureAttrib::get_class_slot()); } @@ -2762,8 +2514,8 @@ do_issue_color_scale() { if (_alpha_scale_via_texture && !_has_scene_graph_color && target_color_scale->has_alpha_scale()) { - // This color scale will set a special texture--so again, clear - // the texture. + // This color scale will set a special texture--so again, clear the + // texture. _state_mask.clear_bit(TextureAttrib::get_class_slot()); _state_mask.clear_bit(TexMatrixAttrib::get_class_slot()); @@ -2771,30 +2523,22 @@ do_issue_color_scale() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::do_issue_light -// Access: Protected, Virtual -// Description: This implementation of do_issue_light() assumes -// we have a limited number of hardware lights -// available. This function assigns each light to a -// different hardware light id, trying to keep each -// light associated with the same id where possible, but -// reusing id's when necessary. When it is no longer -// possible to reuse existing id's (e.g. all id's are in -// use), the next sequential id is assigned (if -// available). -// -// It will call apply_light() each time a light is -// assigned to a particular id for the first time in a -// given frame, and it will subsequently call -// enable_light() to enable or disable each light as the -// frame is rendered, as well as enable_lighting() to -// enable or disable overall lighting. -//////////////////////////////////////////////////////////////////// +/** + * This implementation of do_issue_light() assumes we have a limited number of + * hardware lights available. This function assigns each light to a different + * hardware light id, trying to keep each light associated with the same id + * where possible, but reusing id's when necessary. When it is no longer + * possible to reuse existing id's (e.g. all id's are in use), the next + * sequential id is assigned (if available). + * + * It will call apply_light() each time a light is assigned to a particular id + * for the first time in a given frame, and it will subsequently call + * enable_light() to enable or disable each light as the frame is rendered, as + * well as enable_lighting() to enable or disable overall lighting. + */ void GraphicsStateGuardian:: do_issue_light() { - // Initialize the current ambient light total and newly enabled - // light list + // Initialize the current ambient light total and newly enabled light list LColor cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); int i; @@ -2828,8 +2572,8 @@ do_issue_light() { } if (light_obj->get_type() == AmbientLight::get_class_type()) { - // Ambient lights don't require specific light ids; simply add - // in the ambient contribution to the current total + // Ambient lights don't require specific light ids; simply add in the + // ambient contribution to the current total cur_ambient_light += light_obj->get_color(); } else { @@ -2856,8 +2600,7 @@ do_issue_light() { // If no lights were set, disable lighting if (num_on_lights == 0) { if (_color_scale_via_lighting && (_has_material_force_color || _light_color_scale != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f))) { - // Unless we need lighting anyway to apply a color or color - // scale. + // Unless we need lighting anyway to apply a color or color scale. if (!_lighting_enabled) { enable_lighting(true); _lighting_enabled = true; @@ -2880,15 +2623,12 @@ do_issue_light() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::framebuffer_copy_to_texture -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display -// region from the framebuffer into texture memory. -// -// If z > -1, it is the cube map index into which to -// copy. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into texture memory. + * + * If z > -1, it is the cube map index into which to copy. + */ bool GraphicsStateGuardian:: framebuffer_copy_to_texture(Texture *, int, int, const DisplayRegion *, const RenderBuffer &) { @@ -2896,65 +2636,50 @@ framebuffer_copy_to_texture(Texture *, int, int, const DisplayRegion *, } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::framebuffer_copy_to_ram -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display region -// from the framebuffer into system memory, not texture -// memory. Returns true on success, false on failure. -// -// This completely redefines the ram image of the -// indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into system memory, not texture memory. Returns true on success, false on + * failure. + * + * This completely redefines the ram image of the indicated texture. + */ bool GraphicsStateGuardian:: framebuffer_copy_to_ram(Texture *, int, int, const DisplayRegion *, const RenderBuffer &) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void GraphicsStateGuardian:: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void GraphicsStateGuardian:: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void GraphicsStateGuardian:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { } #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::init_frame_pstats -// Access: Public, Static -// Description: Initializes the relevant PStats data at the beginning -// of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the relevant PStats data at the beginning of the frame. + */ void GraphicsStateGuardian:: init_frame_pstats() { if (PStatClient::is_connected()) { @@ -2982,11 +2707,9 @@ init_frame_pstats() { #endif // DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::create_gamma_table -// Access: Public, Static -// Description: Create a gamma table. -//////////////////////////////////////////////////////////////////// +/** + * Create a gamma table. + */ void GraphicsStateGuardian:: create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short *green_table, unsigned short *blue_table) { int i; @@ -3015,153 +2738,116 @@ create_gamma_table (PN_stdfloat gamma, unsigned short *red_table, unsigned short } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::reissue_transforms -// Access: Protected, Virtual -// Description: Called by clear_state_and_transform() to ensure that -// the current modelview and projection matrices are -// properly loaded in the graphics state, after a -// callback might have mucked them up. -//////////////////////////////////////////////////////////////////// +/** + * Called by clear_state_and_transform() to ensure that the current modelview + * and projection matrices are properly loaded in the graphics state, after a + * callback might have mucked them up. + */ void GraphicsStateGuardian:: reissue_transforms() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::enable_lighting -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable or disable the use of lighting overall. This -// is called by do_issue_light() according to whether any -// lights are in use or not. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable or disable the use + * of lighting overall. This is called by do_issue_light() according to + * whether any lights are in use or not. + */ void GraphicsStateGuardian:: enable_lighting(bool enable) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::set_ambient_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// indicate the color of the ambient light that should -// be in effect. This is called by do_issue_light() after -// all other lights have been enabled or disabled. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to indicate the color of the + * ambient light that should be in effect. This is called by do_issue_light() + * after all other lights have been enabled or disabled. + */ void GraphicsStateGuardian:: set_ambient_light(const LColor &color) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::enable_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated light id. A specific Light will -// already have been bound to this id via bind_light(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated light + * id. A specific Light will already have been bound to this id via + * bind_light(). + */ void GraphicsStateGuardian:: enable_light(int light_id, bool enable) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_bind_lights -// Access: Protected, Virtual -// Description: Called immediately before bind_light() is called, -// this is intended to provide the derived class a hook -// in which to set up some state (like transform) that -// might apply to several lights. -// -// The sequence is: begin_bind_lights() will be called, -// then one or more bind_light() calls, then -// end_bind_lights(). -//////////////////////////////////////////////////////////////////// +/** + * Called immediately before bind_light() is called, this is intended to + * provide the derived class a hook in which to set up some state (like + * transform) that might apply to several lights. + * + * The sequence is: begin_bind_lights() will be called, then one or more + * bind_light() calls, then end_bind_lights(). + */ void GraphicsStateGuardian:: begin_bind_lights() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_bind_lights -// Access: Protected, Virtual -// Description: Called after before bind_light() has been called one -// or more times (but before any geometry is issued or -// additional state is changed), this is intended to -// clean up any temporary changes to the state that may -// have been made by begin_bind_lights(). -//////////////////////////////////////////////////////////////////// +/** + * Called after before bind_light() has been called one or more times (but + * before any geometry is issued or additional state is changed), this is + * intended to clean up any temporary changes to the state that may have been + * made by begin_bind_lights(). + */ void GraphicsStateGuardian:: end_bind_lights() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::enable_clip_planes -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable or disable the use of clipping planes overall. -// This is called by do_issue_clip_plane() according to -// whether any planes are in use or not. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable or disable the use + * of clipping planes overall. This is called by do_issue_clip_plane() + * according to whether any planes are in use or not. + */ void GraphicsStateGuardian:: enable_clip_planes(bool enable) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::enable_clip_plane -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated plane id. A specific PlaneNode -// will already have been bound to this id via -// bind_clip_plane(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated plane + * id. A specific PlaneNode will already have been bound to this id via + * bind_clip_plane(). + */ void GraphicsStateGuardian:: enable_clip_plane(int plane_id, bool enable) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_bind_clip_planes -// Access: Protected, Virtual -// Description: Called immediately before bind_clip_plane() is called, -// this is intended to provide the derived class a hook -// in which to set up some state (like transform) that -// might apply to several planes. -// -// The sequence is: begin_bind_clip_planes() will be -// called, then one or more bind_clip_plane() calls, -// then end_bind_clip_planes(). -//////////////////////////////////////////////////////////////////// +/** + * Called immediately before bind_clip_plane() is called, this is intended to + * provide the derived class a hook in which to set up some state (like + * transform) that might apply to several planes. + * + * The sequence is: begin_bind_clip_planes() will be called, then one or more + * bind_clip_plane() calls, then end_bind_clip_planes(). + */ void GraphicsStateGuardian:: begin_bind_clip_planes() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::bind_clip_plane -// Access: Public, Virtual -// Description: Called the first time a particular clipping plane has been -// bound to a given id within a frame, this should set -// up the associated hardware (or API) clipping plane -// with the plane's properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular clipping plane has been bound to a given + * id within a frame, this should set up the associated hardware (or API) + * clipping plane with the plane's properties. + */ void GraphicsStateGuardian:: bind_clip_plane(const NodePath &plane, int plane_id) { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_bind_clip_planes -// Access: Protected, Virtual -// Description: Called after before bind_clip_plane() has been called one -// or more times (but before any geometry is issued or -// additional state is changed), this is intended to -// clean up any temporary changes to the state that may -// have been made by begin_bind_clip_planes(). -//////////////////////////////////////////////////////////////////// +/** + * Called after before bind_clip_plane() has been called one or more times + * (but before any geometry is issued or additional state is changed), this is + * intended to clean up any temporary changes to the state that may have been + * made by begin_bind_clip_planes(). + */ void GraphicsStateGuardian:: end_bind_clip_planes() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::determine_target_texture -// Access: Protected -// Description: Assigns _target_texture and _target_tex_gen -// based on the _target_rs. -//////////////////////////////////////////////////////////////////// +/** + * Assigns _target_texture and _target_tex_gen based on the _target_rs. + */ void GraphicsStateGuardian:: determine_target_texture() { const TextureAttrib *target_texture = (const TextureAttrib *) @@ -3188,28 +2874,22 @@ determine_target_texture() { nassertv(_target_texture->get_num_on_stages() <= max_texture_stages); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::free_pointers -// Access: Protected, Virtual -// Description: Frees some memory that was explicitly allocated -// within the glgsg. -//////////////////////////////////////////////////////////////////// +/** + * Frees some memory that was explicitly allocated within the glgsg. + */ void GraphicsStateGuardian:: free_pointers() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::close_gsg -// Access: Protected, Virtual -// Description: This is called by the associated GraphicsWindow when -// close_window() is called. It should null out the -// _win pointer and possibly free any open resources -// associated with the GSG. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the associated GraphicsWindow when close_window() is + * called. It should null out the _win pointer and possibly free any open + * resources associated with the GSG. + */ void GraphicsStateGuardian:: close_gsg() { - // Protect from multiple calls, and also inform any other functions - // not to try to create new stuff while we're going down. + // Protect from multiple calls, and also inform any other functions not to + // try to create new stuff while we're going down. if (_closing_gsg) { return; } @@ -3220,16 +2900,15 @@ close_gsg() { << this << " close_gsg " << get_type() << "\n"; } - // As tempting as it may be to try to release all the textures and - // geoms now, we can't, because we might not be the currently-active - // GSG (this is particularly important in OpenGL, which maintains - // one currently-active GL state in each thread). If we start - // deleting textures, we'll be inadvertently deleting textures from - // some other OpenGL state. + // As tempting as it may be to try to release all the textures and geoms + // now, we can't, because we might not be the currently-active GSG (this is + // particularly important in OpenGL, which maintains one currently-active GL + // state in each thread). If we start deleting textures, we'll be + // inadvertently deleting textures from some other OpenGL state. - // Fortunately, it doesn't really matter, since the graphics API - // will be responsible for cleaning up anything we don't clean up - // explicitly. We'll just let them drop. + // Fortunately, it doesn't really matter, since the graphics API will be + // responsible for cleaning up anything we don't clean up explicitly. We'll + // just let them drop. // Make sure that all the contexts belonging to the GSG are deleted. _prepared_objects.clear(); @@ -3240,15 +2919,11 @@ close_gsg() { free_pointers(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::panic_deactivate -// Access: Protected -// Description: This is called internally when it is determined that -// things are just fubar. It temporarily deactivates -// the GSG just so things don't get out of hand, and -// throws an event so the application can deal with this -// if it needs to. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally when it is determined that things are just fubar. + * It temporarily deactivates the GSG just so things don't get out of hand, + * and throws an event so the application can deal with this if it needs to. + */ void GraphicsStateGuardian:: panic_deactivate() { if (_active) { @@ -3259,20 +2934,17 @@ panic_deactivate() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::determine_light_color_scale -// Access: Protected -// Description: Called whenever the color or color scale is changed, -// if _color_scale_via_lighting is true. This will -// rederive _material_force_color and _light_color_scale -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the color or color scale is changed, if + * _color_scale_via_lighting is true. This will rederive + * _material_force_color and _light_color_scale appropriately. + */ void GraphicsStateGuardian:: determine_light_color_scale() { if (_has_scene_graph_color) { - // If we have a scene graph color, it, plus the color scale, goes - // directly into the material; we don't color scale the - // lights--this allows an alpha color scale to work properly. + // If we have a scene graph color, it, plus the color scale, goes directly + // into the material; we don't color scale the lights--this allows an + // alpha color scale to work properly. _has_material_force_color = true; _material_force_color = _scene_graph_color; _light_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -3284,8 +2956,8 @@ determine_light_color_scale() { } } else { - // Otherise, leave the materials alone, but we might still scale - // the lights. + // Otherise, leave the materials alone, but we might still scale the + // lights. _has_material_force_color = false; _light_color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); if (!_color_blend_involves_color_scale && _color_scale_enabled) { @@ -3294,11 +2966,9 @@ determine_light_color_scale() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_unlit_state -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderState) GraphicsStateGuardian:: get_unlit_state() { static CPT(RenderState) state = NULL; @@ -3308,11 +2978,9 @@ get_unlit_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_unclipped_state -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderState) GraphicsStateGuardian:: get_unclipped_state() { static CPT(RenderState) state = NULL; @@ -3322,11 +2990,9 @@ get_unclipped_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_untextured_state -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderState) GraphicsStateGuardian:: get_untextured_state() { static CPT(RenderState) state = NULL; @@ -3336,17 +3002,13 @@ get_untextured_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::async_reload_texture -// Access: Protected -// Description: Should be called when a texture is encountered that -// needs to have its RAM image reloaded, and -// get_incomplete_render() is true. This will fire off -// a thread on the current Loader object that will -// request the texture to load its image. The image -// will be available at some point in the future (no -// event will be generated). -//////////////////////////////////////////////////////////////////// +/** + * Should be called when a texture is encountered that needs to have its RAM + * image reloaded, and get_incomplete_render() is true. This will fire off a + * thread on the current Loader object that will request the texture to load + * its image. The image will be available at some point in the future (no + * event will be generated). + */ void GraphicsStateGuardian:: async_reload_texture(TextureContext *tc) { nassertv(_loader != (Loader *)NULL); @@ -3366,15 +3028,14 @@ async_reload_texture(TextureContext *tc) { AsyncTask *task = orig_tasks.get_task(ti); if (task->is_exact_type(TextureReloadRequest::get_class_type()) && DCAST(TextureReloadRequest, task)->get_texture() == tc->get_texture()) { - // This texture is already queued to be reloaded. Don't queue - // it again, just make sure the priority is updated, and return. + // This texture is already queued to be reloaded. Don't queue it again, + // just make sure the priority is updated, and return. task->set_priority(max(task->get_priority(), priority)); return; } } - // This texture has not yet been queued to be reloaded. Queue it up - // now. + // This texture has not yet been queued to be reloaded. Queue it up now. PT(AsyncTask) request = new TextureReloadRequest(task_name, _prepared_objects, tc->get_texture(), @@ -3383,14 +3044,11 @@ async_reload_texture(TextureContext *tc) { _loader->load_async(request); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_shadow_map -// Access: Protected -// Description: Returns a shadow map for the given light source. -// If none exists, it is created, using the given host -// window to create the buffer, or the current window -// if that is set to NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns a shadow map for the given light source. If none exists, it is + * created, using the given host window to create the buffer, or the current + * window if that is set to NULL. + */ PT(Texture) GraphicsStateGuardian:: get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host) { nassertr(light_np.node()->is_of_type(DirectionalLight::get_class_type()) || @@ -3399,11 +3057,11 @@ get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host) { PT(LightLensNode) light = DCAST(LightLensNode, light_np.node()); if (light == NULL || !light->_shadow_caster) { - //TODO: return dummy shadow map (all white). + // TODO: return dummy shadow map (all white). return NULL; } - // See if we already have a buffer. If not, create one. + // See if we already have a buffer. If not, create one. if (light->_sbuffers.count(this) == 0) { if (host == (GraphicsOutputBase *)NULL) { host = _current_display_region->get_window(); @@ -3419,15 +3077,11 @@ get_shadow_map(const NodePath &light_np, GraphicsOutputBase *host) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::make_shadow_buffer -// Access: Protected -// Description: Creates a depth buffer for shadow mapping. This -// is a convenience function for the ShaderGenerator; -// putting this directly in the ShaderGenerator would -// cause circular dependency issues. -// Returns the depth texture. -//////////////////////////////////////////////////////////////////// +/** + * Creates a depth buffer for shadow mapping. This is a convenience function + * for the ShaderGenerator; putting this directly in the ShaderGenerator would + * cause circular dependency issues. Returns the depth texture. + */ PT(Texture) GraphicsStateGuardian:: make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) { // Make sure everything is valid. @@ -3466,7 +3120,8 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) { light->_sb_sort, fbp, props, flags, this, DCAST(GraphicsOutput, host)); nassertr(sbuffer != NULL, NULL); - // Create a texture and fill it in with some data to workaround an OpenGL error + // Create a texture and fill it in with some data to workaround an OpenGL + // error PT(Texture) tex = new Texture(light->get_name()); if (is_point) { if (light->_sb_xsize != light->_sb_ysize) { @@ -3519,91 +3174,71 @@ make_shadow_buffer(const NodePath &light_np, GraphicsOutputBase *host) { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::has_extension -// Access: Public, Virtual -// Description: Returns true if the GSG implements the extension -// identified by the given string. This currently -// is only implemented by the OpenGL back-end. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the GSG implements the extension identified by the given + * string. This currently is only implemented by the OpenGL back-end. + */ bool GraphicsStateGuardian:: has_extension(const string &extension) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_vendor -// Access: Public, Virtual -// Description: Returns the vendor of the video card driver -//////////////////////////////////////////////////////////////////// +/** + * Returns the vendor of the video card driver + */ string GraphicsStateGuardian:: get_driver_vendor() { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_renderer -// Access: Public, Virtual -// Description: Returns GL_Renderer -//////////////////////////////////////////////////////////////////// +/** + * Returns GL_Renderer + */ string GraphicsStateGuardian::get_driver_renderer() { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_version -// Access: Public, Virtual -// Description: Returns driver version -// This has an implementation-defined meaning, and may -// be "" if the particular graphics implementation -// does not provide a way to query this information. -//////////////////////////////////////////////////////////////////// +/** + * Returns driver version This has an implementation-defined meaning, and may + * be "" if the particular graphics implementation does not provide a way to + * query this information. + */ string GraphicsStateGuardian:: get_driver_version() { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_version_major -// Access: Public, Virtual -// Description: Returns major version of the video driver. -// This has an implementation-defined meaning, and may -// be -1 if the particular graphics implementation -// does not provide a way to query this information. -//////////////////////////////////////////////////////////////////// +/** + * Returns major version of the video driver. This has an implementation- + * defined meaning, and may be -1 if the particular graphics implementation + * does not provide a way to query this information. + */ int GraphicsStateGuardian:: get_driver_version_major() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_version_minor -// Access: Public, Virtual -// Description: Returns the minor version of the video driver. -// This has an implementation-defined meaning, and may -// be -1 if the particular graphics implementation -// does not provide a way to query this information. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version of the video driver. This has an implementation- + * defined meaning, and may be -1 if the particular graphics implementation + * does not provide a way to query this information. + */ int GraphicsStateGuardian:: get_driver_version_minor() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_shader_version_major -// Access: Public, Virtual -// Description: Returns the major version of the shader model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version of the shader model. + */ int GraphicsStateGuardian:: get_driver_shader_version_major() { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_driver_shader_version_minor -// Access: Public, Virtual -// Description: Returns the minor version of the shader model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version of the shader model. + */ int GraphicsStateGuardian:: get_driver_shader_version_minor() { return -1; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 79ba8d1c7d..401c538b31 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -1,18 +1,18 @@ -// Filename: graphicsStateGuardian.h -// Created by: drose (02eb99) -// Updated by: fperazzi, PandaSE (05May10) (added fetch_ptr_parameter, -// _max_2d_texture_array_layers on z axis, get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardian.h + * @author drose + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + * _max_2d_texture_array_layers on z axis, get_supports_cg_profile) + */ #ifndef GRAPHICSSTATEGUARDIAN_H #define GRAPHICSSTATEGUARDIAN_H @@ -54,20 +54,16 @@ class DrawableRegion; class GraphicsEngine; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsStateGuardian -// Description : Encapsulates all the communication with a particular -// instance of a given rendering backend. Tries to -// guarantee that redundant state-change requests are -// not issued (hence "state guardian"). -// -// There will be one of these objects for each different -// graphics context active in the system. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates all the communication with a particular instance of a given + * rendering backend. Tries to guarantee that redundant state-change requests + * are not issued (hence "state guardian"). + * + * There will be one of these objects for each different graphics context + * active in the system. + */ class EXPCL_PANDA_DISPLAY GraphicsStateGuardian : public GraphicsStateGuardianBase { - // // Interfaces all GSGs should have - // public: GraphicsStateGuardian(CoordinateSystem internal_coordinate_system, GraphicsEngine *engine, GraphicsPipe *pipe); @@ -467,35 +463,32 @@ protected: // set_state_and_transform(). CPT(RenderState) _target_rs; - // This bitmask contains a 1 bit everywhere that _state_rs has a - // known value. If a bit is 0, the corresponding state must be - // re-sent. - // - // Derived GSGs should initialize _inv_state_mask in reset() as a mask of - // 1's where they don't care, and 0's where they do care, about the state. + // This bitmask contains a 1 bit everywhere that _state_rs has a known + // value. If a bit is 0, the corresponding state must be re-sent. Derived + // GSGs should initialize _inv_state_mask in reset() as a mask of 1's where + // they don't care, and 0's where they do care, about the state. RenderState::SlotMask _state_mask; RenderState::SlotMask _inv_state_mask; - // The current transform, as of the last call to - // set_state_and_transform(). + // The current transform, as of the last call to set_state_and_transform(). CPT(TransformState) _internal_transform; - // The current TextureAttrib is a special case; we may further - // restrict it (according to graphics cards limits) or extend it - // (according to ColorScaleAttribs in effect) beyond what is - // specifically requested in the scene graph. + // The current TextureAttrib is a special case; we may further restrict it + // (according to graphics cards limits) or extend it (according to + // ColorScaleAttribs in effect) beyond what is specifically requested in the + // scene graph. CPT(TextureAttrib) _target_texture; CPT(TextureAttrib) _state_texture; CPT(TexGenAttrib) _target_tex_gen; CPT(TexGenAttrib) _state_tex_gen; - // Also, the shader might be the explicitly-requested shader, or it - // might be an auto-generated one. + // Also, the shader might be the explicitly-requested shader, or it might be + // an auto-generated one. CPT(ShaderAttrib) _state_shader; CPT(ShaderAttrib) _target_shader; - // These are set by begin_draw_primitives(), and are only valid - // between begin_draw_primitives() and end_draw_primitives(). + // These are set by begin_draw_primitives(), and are only valid between + // begin_draw_primitives() and end_draw_primitives(). CPT(GeomMunger) _munger; const GeomVertexDataPipelineReader *_data_reader; @@ -588,7 +581,7 @@ protected: int _last_query_frame; int _last_num_queried; - //double _timer_delta; + // double _timer_delta; typedef pdeque TimerQueryQueue; TimerQueryQueue _pending_timer_queries; #endif @@ -685,8 +678,8 @@ public: static PStatCollector _prepare_vertex_buffer_pcollector; static PStatCollector _prepare_index_buffer_pcollector; - // A whole slew of collectors to measure the cost of individual - // state changes. These are disabled by default. + // A whole slew of collectors to measure the cost of individual state + // changes. These are disabled by default. static PStatCollector _draw_set_state_transform_pcollector; static PStatCollector _draw_set_state_alpha_test_pcollector; static PStatCollector _draw_set_state_antialias_pcollector; diff --git a/panda/src/display/graphicsStateGuardian_ext.cxx b/panda/src/display/graphicsStateGuardian_ext.cxx index 53407f500f..0677741ac7 100644 --- a/panda/src/display/graphicsStateGuardian_ext.cxx +++ b/panda/src/display/graphicsStateGuardian_ext.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsStateGuardian_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardian_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "graphicsStateGuardian_ext.h" #include "textureContext.h" @@ -34,12 +33,10 @@ static bool traverse_callback(TextureContext *tc, void *data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::get_prepared_textures -// Access: Published -// Description: Returns a Python list of all of the -// currently-prepared textures within the GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Python list of all of the currently-prepared textures within the + * GSG. + */ PyObject *Extension:: get_prepared_textures() const { PyObject *list = PyList_New(0); diff --git a/panda/src/display/graphicsStateGuardian_ext.h b/panda/src/display/graphicsStateGuardian_ext.h index cc1d9a3fe5..4c062f58c2 100644 --- a/panda/src/display/graphicsStateGuardian_ext.h +++ b/panda/src/display/graphicsStateGuardian_ext.h @@ -1,16 +1,15 @@ -// Filename: graphicsStateGuardian_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardian_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef GRAPHICSSTATEGUARDIAN_EXT_H #define GRAPHICSSTATEGUARDIAN_EXT_H @@ -23,12 +22,10 @@ #include "graphicsStateGuardian.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// Ramfile, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for Ramfile, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/display/graphicsThreadingModel.I b/panda/src/display/graphicsThreadingModel.I index f488432910..bfd0161518 100644 --- a/panda/src/display/graphicsThreadingModel.I +++ b/panda/src/display/graphicsThreadingModel.I @@ -1,23 +1,19 @@ -// Filename: graphicsThreadingModel.I -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsThreadingModel.I + * @author drose + * @date 2003-01-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GraphicsThreadingModel:: GraphicsThreadingModel(const GraphicsThreadingModel ©) : _cull_name(copy._cull_name), @@ -28,11 +24,9 @@ GraphicsThreadingModel(const GraphicsThreadingModel ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GraphicsThreadingModel:: operator = (const GraphicsThreadingModel ©) { _cull_name = copy._cull_name; @@ -42,142 +36,109 @@ operator = (const GraphicsThreadingModel ©) { _cull_sorting = copy._cull_sorting; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_cull_name -// Access: Published -// Description: Returns the name of the thread that will handle -// culling in this model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the thread that will handle culling in this model. + */ INLINE const string &GraphicsThreadingModel:: get_cull_name() const { return _cull_name; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::set_cull_name -// Access: Published -// Description: Changes the name of the thread that will handle -// culling in this model. This won't change any windows -// that were already created with this model; this only -// has an effect on newly-opened windows. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the thread that will handle culling in this model. + * This won't change any windows that were already created with this model; + * this only has an effect on newly-opened windows. + */ INLINE void GraphicsThreadingModel:: set_cull_name(const string &cull_name) { _cull_name = cull_name; update_stages(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_cull_stage -// Access: Published -// Description: Returns the pipeline stage from which the cull thread -// should access data. This will be 0 if the cull is -// run in the same thread as app, or 1 if it is its own -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pipeline stage from which the cull thread should access data. + * This will be 0 if the cull is run in the same thread as app, or 1 if it is + * its own thread. + */ INLINE int GraphicsThreadingModel:: get_cull_stage() const { return _cull_stage; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_draw_name -// Access: Published -// Description: Returns the name of the thread that will handle -// sending the actual graphics primitives to the -// graphics API in this model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the thread that will handle sending the actual graphics + * primitives to the graphics API in this model. + */ INLINE const string &GraphicsThreadingModel:: get_draw_name() const { return _draw_name; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::set_draw_name -// Access: Published -// Description: Changes the name of the thread that will handle -// drawing in this model. This won't change any windows -// that were already created with this model; this only -// has an effect on newly-opened windows. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the thread that will handle drawing in this model. + * This won't change any windows that were already created with this model; + * this only has an effect on newly-opened windows. + */ INLINE void GraphicsThreadingModel:: set_draw_name(const string &draw_name) { _draw_name = draw_name; update_stages(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_draw_stage -// Access: Published -// Description: Returns the pipeline stage from which the draw thread -// should access data. This will be the same value as -// get_cull_stage() if cull and draw are run in the same -// thread, or one more than that value if draw should be -// in its own thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pipeline stage from which the draw thread should access data. + * This will be the same value as get_cull_stage() if cull and draw are run in + * the same thread, or one more than that value if draw should be in its own + * thread. + */ INLINE int GraphicsThreadingModel:: get_draw_stage() const { return _draw_stage; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_cull_sorting -// Access: Published -// Description: Returns true if the model involves a separate cull -// pass, or false if culling happens implicitly, at the -// same time as draw. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the model involves a separate cull pass, or false if + * culling happens implicitly, at the same time as draw. + */ INLINE bool GraphicsThreadingModel:: get_cull_sorting() const { return _cull_sorting; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::set_cull_sorting -// Access: Published -// Description: Changes the flag that indicates whether the threading -// model involves a separate cull pass. This won't -// change any windows that were already created with -// this model; this only has an effect on newly-opened -// windows. -//////////////////////////////////////////////////////////////////// +/** + * Changes the flag that indicates whether the threading model involves a + * separate cull pass. This won't change any windows that were already + * created with this model; this only has an effect on newly-opened windows. + */ INLINE void GraphicsThreadingModel:: set_cull_sorting(bool cull_sorting) { _cull_sorting = cull_sorting; update_stages(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::is_single_threaded -// Access: Published -// Description: Returns true if the threading model is a -// single-threaded model, or false if it involves -// threads. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the threading model is a single-threaded model, or false if + * it involves threads. + */ INLINE bool GraphicsThreadingModel:: is_single_threaded() const { return _cull_name.empty() && _draw_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::is_default -// Access: Published -// Description: Returns true if the threading model is the default, -// cull-then-draw single-threaded model, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the threading model is the default, cull-then-draw single- + * threaded model, or false otherwise. + */ INLINE bool GraphicsThreadingModel:: is_default() const { return is_single_threaded() && _cull_sorting; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GraphicsThreadingModel:: output(ostream &out) const { out << get_model(); diff --git a/panda/src/display/graphicsThreadingModel.cxx b/panda/src/display/graphicsThreadingModel.cxx index d42715913b..113352ecba 100644 --- a/panda/src/display/graphicsThreadingModel.cxx +++ b/panda/src/display/graphicsThreadingModel.cxx @@ -1,49 +1,40 @@ -// Filename: graphicsThreadingModel.cxx -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsThreadingModel.cxx + * @author drose + * @date 2003-01-27 + */ #include "graphicsThreadingModel.h" -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::Constructor -// Access: Published -// Description: The threading model accepts a string representing the -// names of the two threads that will process cull and -// draw for the given window, separated by a slash. The -// names are completely arbitrary and are used only to -// differentiate threads. The two names may be the -// same, meaning the same thread, or each may be the -// empty string, which represents the previous thread. -// -// Thus, for example, "cull/draw" indicates that the -// window will be culled in a thread called "cull", and -// drawn in a separate thread called "draw". -// "draw/draw" or simply "draw" indicates the window -// will be culled and drawn in the same thread, "draw". -// On the other hand, "/draw" indicates the thread will -// be culled in the main, or app thread, and drawn in a -// separate thread named "draw". The empty string, "" -// or "/", indicates the thread will be culled and drawn -// in the main thread; that is to say, a single-process -// model. -// -// Finally, if the threading model begins with a "-" -// character, then cull and draw are run simultaneously, -// in the same thread, with no binning or state sorting. -// It simplifies the cull process but it forces the -// scene to render in scene graph order; state sorting -// and alpha sorting is lost. -//////////////////////////////////////////////////////////////////// +/** + * The threading model accepts a string representing the names of the two + * threads that will process cull and draw for the given window, separated by + * a slash. The names are completely arbitrary and are used only to + * differentiate threads. The two names may be the same, meaning the same + * thread, or each may be the empty string, which represents the previous + * thread. + * + * Thus, for example, "cull/draw" indicates that the window will be culled in + * a thread called "cull", and drawn in a separate thread called "draw". + * "draw/draw" or simply "draw" indicates the window will be culled and drawn + * in the same thread, "draw". On the other hand, "/draw" indicates the thread + * will be culled in the main, or app thread, and drawn in a separate thread + * named "draw". The empty string, "" or "/", indicates the thread will be + * culled and drawn in the main thread; that is to say, a single-process + * model. + * + * Finally, if the threading model begins with a "-" character, then cull and + * draw are run simultaneously, in the same thread, with no binning or state + * sorting. It simplifies the cull process but it forces the scene to render + * in scene graph order; state sorting and alpha sorting is lost. + */ GraphicsThreadingModel:: GraphicsThreadingModel(const string &model) { _cull_sorting = true; @@ -64,12 +55,10 @@ GraphicsThreadingModel(const string &model) { update_stages(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::get_model -// Access: Published -// Description: Returns the string that describes the threading -// model. See the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that describes the threading model. See the + * constructor. + */ string GraphicsThreadingModel:: get_model() const { if (get_cull_sorting()) { @@ -79,12 +68,10 @@ get_model() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsThreadingModel::update_stages -// Access: Private -// Description: Called internally to recompute _cull_stage and -// _draw_stage after either name has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to recompute _cull_stage and _draw_stage after either + * name has been changed. + */ void GraphicsThreadingModel:: update_stages() { if (_cull_name.empty()) { @@ -102,4 +89,3 @@ update_stages() { _draw_stage = _cull_stage + 1; } } - diff --git a/panda/src/display/graphicsThreadingModel.h b/panda/src/display/graphicsThreadingModel.h index 85dc02cf45..7d189250df 100644 --- a/panda/src/display/graphicsThreadingModel.h +++ b/panda/src/display/graphicsThreadingModel.h @@ -1,33 +1,31 @@ -// Filename: graphicsThreadingModel.h -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsThreadingModel.h + * @author drose + * @date 2003-01-27 + */ #ifndef GRAPHICSTHREADINGMODEL_H #define GRAPHICSTHREADINGMODEL_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : GraphicsThreadingModel -// Description : This represents the user's specification of how a -// particular frame is handled by the various threads. -//////////////////////////////////////////////////////////////////// +/** + * This represents the user's specification of how a particular frame is + * handled by the various threads. + */ class EXPCL_PANDA_DISPLAY GraphicsThreadingModel { PUBLISHED: GraphicsThreadingModel(const string &model = string()); INLINE GraphicsThreadingModel(const GraphicsThreadingModel ©); INLINE void operator = (const GraphicsThreadingModel ©); - + string get_model() const; INLINE const string &get_cull_name() const; INLINE void set_cull_name(const string &cull_name); @@ -39,7 +37,7 @@ PUBLISHED: INLINE bool get_cull_sorting() const; INLINE void set_cull_sorting(bool cull_sorting); - + INLINE bool is_single_threaded() const; INLINE bool is_default() const; INLINE void output(ostream &out) const; diff --git a/panda/src/display/graphicsWindow.I b/panda/src/display/graphicsWindow.I index 39ba7c71b7..186da942ad 100644 --- a/panda/src/display/graphicsWindow.I +++ b/panda/src/display/graphicsWindow.I @@ -1,88 +1,68 @@ -// Filename: graphicsWindow.I -// Created by: frang (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindow.I + * @author frang + * @date 1999-03-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::is_closed -// Access: Published -// Description: Returns true if the window has not yet been opened, -// or has been fully closed, false if it is open. The -// window is not opened immediately after -// GraphicsEngine::make_window() is called; nor is it -// closed immediately after -// GraphicsEngine::remove_window() is called. Either -// operation may take a frame or two. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window has not yet been opened, or has been fully + * closed, false if it is open. The window is not opened immediately after + * GraphicsEngine::make_window() is called; nor is it closed immediately after + * GraphicsEngine::remove_window() is called. Either operation may take a + * frame or two. + */ INLINE bool GraphicsWindow:: is_closed() const { return !_properties.get_open(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::is_fullscreen -// Access: Published -// Description: Returns true if the window has been opened as a -// fullscreen window, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window has been opened as a fullscreen window, false + * otherwise. + */ INLINE bool GraphicsWindow:: is_fullscreen() const { return _properties.get_fullscreen(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::set_unexposed_draw -// Access: Published -// Description: If this flag is false, the window is redrawn only -// after it has received a recent "unexpose" or "draw" -// event from the underlying windowing systme. If this -// flag is true, the window is redrawn every frame -// regardless. Setting this false may prevent the -// window from redrawing unnecessarily when it is -// hidden, and may play nicer with other windows on the -// desktop, but may adversely affect frame rate even -// when the window is fully visible; setting it true will -// ensure that the window contents are always current. -//////////////////////////////////////////////////////////////////// +/** + * If this flag is false, the window is redrawn only after it has received a + * recent "unexpose" or "draw" event from the underlying windowing systme. If + * this flag is true, the window is redrawn every frame regardless. Setting + * this false may prevent the window from redrawing unnecessarily when it is + * hidden, and may play nicer with other windows on the desktop, but may + * adversely affect frame rate even when the window is fully visible; setting + * it true will ensure that the window contents are always current. + */ INLINE void GraphicsWindow:: set_unexposed_draw(bool unexposed_draw) { _unexposed_draw = unexposed_draw; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_unexposed_draw -// Access: Published -// Description: See set_unexposed_draw(). -//////////////////////////////////////////////////////////////////// +/** + * See set_unexposed_draw(). + */ INLINE bool GraphicsWindow:: get_unexposed_draw() const { return _unexposed_draw; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_window_handle -// Access: Published -// Description: Returns the WindowHandle corresponding to this window -// on the desktop. This is mainly useful for -// communicating with external libraries. Use -// window_handle->get_os_handle()->get_handle(), or -// window_handle->get_string_handle(), to get the actual -// OS-specific window handle object, whatever type that -// might be. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WindowHandle corresponding to this window on the desktop. This + * is mainly useful for communicating with external libraries. Use + * window_handle->get_os_handle()->get_handle(), or + * window_handle->get_string_handle(), to get the actual OS-specific window + * handle object, whatever type that might be. + */ INLINE WindowHandle *GraphicsWindow:: get_window_handle() const { return _window_handle; } - diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 6166f9cbac..88ee617f40 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsWindow.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindow.cxx + * @author mike + * @date 1997-01-09 + */ #include "graphicsWindow.h" #include "graphicsPipe.h" @@ -24,13 +23,10 @@ TypeHandle GraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::Constructor -// Access: Protected -// Description: Normally, the GraphicsWindow constructor is not -// called directly; these are created instead via the -// GraphicsEngine::make_window() function. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the GraphicsWindow constructor is not called directly; these are + * created instead via the GraphicsEngine::make_window() function. + */ GraphicsWindow:: GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -67,11 +63,9 @@ GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, set_pixel_zoom(pixel_zoom); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsWindow:: ~GraphicsWindow() { // Clean up python event handlers. @@ -85,11 +79,9 @@ GraphicsWindow:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_properties -// Access: Published -// Description: Returns the current properties of the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current properties of the window. + */ const WindowProperties GraphicsWindow:: get_properties() const { WindowProperties result; @@ -100,14 +92,11 @@ get_properties() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_requested_properties -// Access: Published -// Description: Returns the properties of the window that are -// currently requested. These properties will be -// applied to the window (if valid) at the next -// execution of process_events(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the properties of the window that are currently requested. These + * properties will be applied to the window (if valid) at the next execution + * of process_events(). + */ const WindowProperties GraphicsWindow:: get_requested_properties() const { WindowProperties result; @@ -118,27 +107,22 @@ get_requested_properties() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::clear_rejected_properties -// Access: Published -// Description: Empties the set of failed properties that will be -// returned by get_rejected_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Empties the set of failed properties that will be returned by + * get_rejected_properties(). + */ void GraphicsWindow:: clear_rejected_properties() { LightReMutexHolder holder(_properties_lock); _rejected_properties.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_rejected_properties -// Access: Published -// Description: Returns the set of properties that have recently been -// requested, but could not be applied to the window for -// some reason. This set of properties will remain -// unchanged until they are changed by a new failed -// request, or clear_rejected_properties() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of properties that have recently been requested, but could + * not be applied to the window for some reason. This set of properties will + * remain unchanged until they are changed by a new failed request, or + * clear_rejected_properties() is called. + */ WindowProperties GraphicsWindow:: get_rejected_properties() const { WindowProperties result; @@ -149,70 +133,58 @@ get_rejected_properties() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::request_properties -// Access: Published -// Description: Requests a property change on the window. For -// example, use this method to request a window change -// size or minimize or something. -// -// The change is not made immediately; rather, the -// request is saved and will be applied the next time -// the window task is run (probably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Requests a property change on the window. For example, use this method to + * request a window change size or minimize or something. + * + * The change is not made immediately; rather, the request is saved and will + * be applied the next time the window task is run (probably at the next + * frame). + */ void GraphicsWindow:: request_properties(const WindowProperties &requested_properties) { LightReMutexHolder holder(_properties_lock); _requested_properties.add_properties(requested_properties); if (!_has_size && _requested_properties.has_size()) { - // If we just requested a particular size, anticipate that it will - // stick. This is helpful for the MultitexReducer, which needs to - // know the size of the textures that it will be working with, - // even if the texture hasn't been fully generated yet. + // If we just requested a particular size, anticipate that it will stick. + // This is helpful for the MultitexReducer, which needs to know the size + // of the textures that it will be working with, even if the texture + // hasn't been fully generated yet. _size = _requested_properties.get_size(); // Don't set _has_size yet, because we don't really know yet. } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::is_active -// Access: Published, Virtual -// Description: Returns true if the window is ready to be rendered -// into, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is ready to be rendered into, false otherwise. + */ bool GraphicsWindow:: is_active() const { // Make this smarter? return GraphicsOutput::is_active() && _properties.get_open() && !_properties.get_minimized(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::set_window_event -// Access: Published -// Description: Changes the name of the event that is generated when -// this window is modified externally, e.g. to be -// resized or closed by the user. -// -// By default, all windows have the same window event -// unless they are explicitly changed. When the event -// is generated, it includes one parameter: the window -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the event that is generated when this window is + * modified externally, e.g. to be resized or closed by the user. + * + * By default, all windows have the same window event unless they are + * explicitly changed. When the event is generated, it includes one + * parameter: the window itself. + */ void GraphicsWindow:: set_window_event(const string &window_event) { LightReMutexHolder holder(_properties_lock); _window_event = window_event; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_window_event -// Access: Published -// Description: Returns the name of the event that is generated when -// this window is modified externally, e.g. to be -// resized or closed by the user. See set_window_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the event that is generated when this window is + * modified externally, e.g. to be resized or closed by the user. See + * set_window_event(). + */ string GraphicsWindow:: get_window_event() const { string result; @@ -221,45 +193,34 @@ get_window_event() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::set_close_request_event -// Access: Published -// Description: Sets the event that is triggered when the user -// requests to close the window, e.g. via alt-F4, or -// clicking on the close box. -// -// The default for each window is for this event to be -// the empty string, which means the window-close -// request is handled immediately by Panda (and the -// window will be closed without the app getting a -// chance to intervene). If you set this to a nonempty -// string, then the window is not closed, but instead -// the event is thrown. It is then up to the app to -// respond appropriately, for instance by presenting an -// "are you sure?" dialog box, and eventually calling -// close_window() when the user is sure. -// -// It is considered poor form to set this string and -// then not handle the event. This can frustrate the -// user by making it difficult for him to cleanly shut -// down the application (and may force the user to -// hard-kill the app, or reboot the machine). -//////////////////////////////////////////////////////////////////// +/** + * Sets the event that is triggered when the user requests to close the + * window, e.g. via alt-F4, or clicking on the close box. + * + * The default for each window is for this event to be the empty string, which + * means the window-close request is handled immediately by Panda (and the + * window will be closed without the app getting a chance to intervene). If + * you set this to a nonempty string, then the window is not closed, but + * instead the event is thrown. It is then up to the app to respond + * appropriately, for instance by presenting an "are you sure?" dialog box, + * and eventually calling close_window() when the user is sure. + * + * It is considered poor form to set this string and then not handle the + * event. This can frustrate the user by making it difficult for him to + * cleanly shut down the application (and may force the user to hard-kill the + * app, or reboot the machine). + */ void GraphicsWindow:: set_close_request_event(const string &close_request_event) { LightReMutexHolder holder(_properties_lock); _close_request_event = close_request_event; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_close_request_event -// Access: Published -// Description: Returns the name of the event set via -// set_close_request_event(). If this string is -// nonempty, then when the user requests to close -// window, this event will be generated instead. See -// set_close_request_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the event set via set_close_request_event(). If this + * string is nonempty, then when the user requests to close window, this event + * will be generated instead. See set_close_request_event(). + */ string GraphicsWindow:: get_close_request_event() const { string result; @@ -268,16 +229,12 @@ get_close_request_event() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_num_input_devices -// Access: Published -// Description: Returns the number of separate input devices -// associated with the window. Typically, a window will -// have exactly one input device: the keyboard/mouse -// pair. However, some windows may have no input -// devices, and others may add additional devices, for -// instance for a joystick. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of separate input devices associated with the window. + * Typically, a window will have exactly one input device: the keyboard/mouse + * pair. However, some windows may have no input devices, and others may add + * additional devices, for instance for a joystick. + */ int GraphicsWindow:: get_num_input_devices() const { int result; @@ -288,11 +245,9 @@ get_num_input_devices() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_input_device_name -// Access: Published -// Description: Returns the name of the nth input device. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth input device. + */ string GraphicsWindow:: get_input_device_name(int device) const { string result; @@ -304,13 +259,10 @@ get_input_device_name(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::has_pointer -// Access: Published -// Description: Returns true if the nth input device has a -// screen-space pointer (for instance, a mouse), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth input device has a screen-space pointer (for + * instance, a mouse), false otherwise. + */ bool GraphicsWindow:: has_pointer(int device) const { bool result; @@ -322,12 +274,9 @@ has_pointer(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::has_keyboard -// Access: Published -// Description: Returns true if the nth input device has a keyboard, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth input device has a keyboard, false otherwise. + */ bool GraphicsWindow:: has_keyboard(int device) const { bool result; @@ -339,22 +288,18 @@ has_keyboard(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_keyboard_map -// Access: Published, Virtual -// Description: Returns a ButtonMap containing the association -// between raw buttons and virtual buttons. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ButtonMap containing the association between raw buttons and + * virtual buttons. + */ ButtonMap *GraphicsWindow:: get_keyboard_map() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::enable_pointer_events -// Access: Published -// Description: Turn on the generation of pointer events. -//////////////////////////////////////////////////////////////////// +/** + * Turn on the generation of pointer events. + */ void GraphicsWindow:: enable_pointer_events(int device) { LightMutexHolder holder(_input_lock); @@ -362,11 +307,9 @@ enable_pointer_events(int device) { _input_devices[device].enable_pointer_events(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::disable_pointer_events -// Access: Published -// Description: Turn off the generation of pointer events. -//////////////////////////////////////////////////////////////////// +/** + * Turn off the generation of pointer events. + */ void GraphicsWindow:: disable_pointer_events(int device) { LightMutexHolder holder(_input_lock); @@ -374,11 +317,9 @@ disable_pointer_events(int device) { _input_devices[device].disable_pointer_events(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::enable_pointer_mode -// Access: Published -// Description: See GraphicsWindowInputDevice::enable_pointer_mode -//////////////////////////////////////////////////////////////////// +/** + * See GraphicsWindowInputDevice::enable_pointer_mode + */ void GraphicsWindow:: enable_pointer_mode(int device, double speed) { LightMutexHolder holder(_input_lock); @@ -386,11 +327,9 @@ enable_pointer_mode(int device, double speed) { _input_devices[device].enable_pointer_mode(speed); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::disable_pointer_events -// Access: Published -// Description: See GraphicsWindowInputDevice::disable_pointer_mode -//////////////////////////////////////////////////////////////////// +/** + * See GraphicsWindowInputDevice::disable_pointer_mode + */ void GraphicsWindow:: disable_pointer_mode(int device) { LightMutexHolder holder(_input_lock); @@ -398,14 +337,11 @@ disable_pointer_mode(int device) { _input_devices[device].disable_pointer_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_pointer -// Access: Published -// Description: Returns the MouseData associated with the nth -// input device's pointer. This is deprecated; use -// get_pointer_device().get_pointer() instead, or for -// raw mice, use the InputDeviceManager interface. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MouseData associated with the nth input device's pointer. This + * is deprecated; use get_pointer_device().get_pointer() instead, or for raw + * mice, use the InputDeviceManager interface. + */ MouseData GraphicsWindow:: get_pointer(int device) const { MouseData result; @@ -417,41 +353,33 @@ get_pointer(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool GraphicsWindow:: move_pointer(int, int, int) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::close_ime -// Access: Published, Virtual -// Description: Forces the ime window to close if any -// -//////////////////////////////////////////////////////////////////// +/** + * Forces the ime window to close if any + * + */ void GraphicsWindow:: close_ime() { return; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::has_button_event -// Access: Public -// Description: Returns true if the indicated device has a pending -// button event (a mouse button or keyboard button -// down/up), false otherwise. If this returns true, the -// particular event may be extracted via -// get_button_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated device has a pending button event (a mouse + * button or keyboard button down/up), false otherwise. If this returns true, + * the particular event may be extracted via get_button_event(). + */ bool GraphicsWindow:: has_button_event(int device) const { bool result; @@ -463,12 +391,10 @@ has_button_event(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_button_event -// Access: Public -// Description: Assuming a previous call to has_button_event() -// returned true, this returns the pending button event. -//////////////////////////////////////////////////////////////////// +/** + * Assuming a previous call to has_button_event() returned true, this returns + * the pending button event. + */ ButtonEvent GraphicsWindow:: get_button_event(int device) { ButtonEvent result; @@ -481,14 +407,11 @@ get_button_event(int device) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::has_pointer_event -// Access: Public -// Description: Returns true if the indicated device has a pending -// pointer event (a mouse movement). If this returns -// true, the particular event may be extracted via -// get_pointer_events(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated device has a pending pointer event (a mouse + * movement). If this returns true, the particular event may be extracted via + * get_pointer_events(). + */ bool GraphicsWindow:: has_pointer_event(int device) const { bool result; @@ -500,12 +423,10 @@ has_pointer_event(int device) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_pointer_events -// Access: Public -// Description: Assuming a previous call to has_pointer_event() -// returned true, this returns the pending pointer event list. -//////////////////////////////////////////////////////////////////// +/** + * Assuming a previous call to has_pointer_event() returned true, this returns + * the pending pointer event list. + */ PT(PointerEventList) GraphicsWindow:: get_pointer_events(int device) { PT(PointerEventList) result; @@ -518,71 +439,57 @@ get_pointer_events(int device) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::verify_window_sizes -// Access: Public, Virtual -// Description: Determines which of the indicated window sizes are -// supported by available hardware (e.g. in fullscreen -// mode). -// -// On entry, dimen is an array containing contiguous x,y -// pairs specifying possible display sizes; it is -// numsizes*2 words long. The function will zero out -// any invalid x,y size pairs. The return value is the -// number of valid sizes that were found. -// -// Note this doesn't guarantee a resize attempt will -// work; you still need to check the return value. -// -// (It might be better to implement some sort of query -// interface that returns an array of supported sizes, -// but this way is somewhat simpler and will do the job -// on most cards, assuming they handle the std sizes the -// app knows about.) -//////////////////////////////////////////////////////////////////// +/** + * Determines which of the indicated window sizes are supported by available + * hardware (e.g. in fullscreen mode). + * + * On entry, dimen is an array containing contiguous x,y pairs specifying + * possible display sizes; it is numsizes*2 words long. The function will + * zero out any invalid x,y size pairs. The return value is the number of + * valid sizes that were found. + * + * Note this doesn't guarantee a resize attempt will work; you still need to + * check the return value. + * + * (It might be better to implement some sort of query interface that returns + * an array of supported sizes, but this way is somewhat simpler and will do + * the job on most cards, assuming they handle the std sizes the app knows + * about.) + */ int GraphicsWindow:: verify_window_sizes(int numsizes, int *dimen) { return numsizes; } - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::request_open -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the window (or whatever) open itself or, in general, -// make itself valid, at the next call to -// process_events(). -//////////////////////////////////////////////////////////////////// + +/** + * This is called by the GraphicsEngine to request that the window (or + * whatever) open itself or, in general, make itself valid, at the next call + * to process_events(). + */ void GraphicsWindow:: request_open() { WindowProperties open_properties; open_properties.set_open(true); request_properties(open_properties); } - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::request_close -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the window (or whatever) close itself or, in general, -// make itself invalid, at the next call to -// process_events(). By that time we promise the gsg -// pointer will be cleared. -//////////////////////////////////////////////////////////////////// + +/** + * This is called by the GraphicsEngine to request that the window (or + * whatever) close itself or, in general, make itself invalid, at the next + * call to process_events(). By that time we promise the gsg pointer will be + * cleared. + */ void GraphicsWindow:: request_close() { WindowProperties close_properties; close_properties.set_open(false); request_properties(close_properties); } - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::set_close_now -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to insist that -// the window be closed immediately. This is only -// called from the window thread. -//////////////////////////////////////////////////////////////////// + +/** + * This is called by the GraphicsEngine to insist that the window be closed + * immediately. This is only called from the window thread. + */ void GraphicsWindow:: set_close_now() { WindowProperties close_properties; @@ -590,23 +497,19 @@ set_close_now() { set_properties_now(close_properties); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties(). -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties(). + * + * This function is called only within the window thread. + */ void GraphicsWindow:: process_events() { if (_requested_properties.is_any_specified()) { - // We don't bother to grab the mutex until after we have already - // checked whether any properties have been specified. This is - // technically sloppy, but it ought to be o.k. since it's just a - // bitmask after all. + // We don't bother to grab the mutex until after we have already checked + // whether any properties have been specified. This is technically + // sloppy, but it ought to be o.k. since it's just a bitmask after all. WindowProperties properties; { LightReMutexHolder holder(_properties_lock); @@ -623,28 +526,23 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void GraphicsWindow:: set_properties_now(WindowProperties &properties) { - if (properties.has_open() && + if (properties.has_open() && properties.get_open() != _properties.get_open()) { // Open or close a new window. In this case we can get all of the // properties at once. @@ -654,15 +552,14 @@ set_properties_now(WindowProperties &properties) { if (_properties.get_open()) { if (open_window()) { - // When the window is first opened, force its size to be - // broadcast to its display regions. + // When the window is first opened, force its size to be broadcast to + // its display regions. _is_valid = true; set_size_and_recalc(_properties.get_x_size(), _properties.get_y_size()); } else { - // Since we can't even open the window, tag the - // _rejected_properties with all of the window properties that - // failed. + // Since we can't even open the window, tag the _rejected_properties + // with all of the window properties that failed. _rejected_properties.add_properties(_properties); // And mark the window closed. @@ -671,9 +568,9 @@ set_properties_now(WindowProperties &properties) { } } else { - // We used to resist closing a window before its GSG has been - // released. Now it seems we never release a GSG, so go ahead - // and close the window. + // We used to resist closing a window before its GSG has been released. + // Now it seems we never release a GSG, so go ahead and close the + // window. close_window(); _is_valid = false; } @@ -681,8 +578,7 @@ set_properties_now(WindowProperties &properties) { } if (!_properties.get_open()) { - // The window is not currently open; we can set properties at - // will. + // The window is not currently open; we can set properties at will. _properties.add_properties(properties); properties.clear(); return; @@ -690,11 +586,11 @@ set_properties_now(WindowProperties &properties) { properties.clear_open(); - // The window is already open; we are limited to what we can change - // on the fly. + // The window is already open; we are limited to what we can change on the + // fly. if (properties.has_size() || properties.has_origin()) { - // Consider changing the window's size and/or position. + // Consider changing the window's size andor position. WindowProperties reshape_props; if (properties.has_size()) { reshape_props.set_size(properties.get_x_size(), properties.get_y_size()); @@ -714,7 +610,7 @@ set_properties_now(WindowProperties &properties) { x_origin = reshape_props.get_x_origin(); y_origin = reshape_props.get_y_origin(); } - + if (reshape_props.get_x_size() != _properties.get_x_size() || reshape_props.get_y_size() != _properties.get_y_size() || (has_origin && (x_origin != _properties.get_x_origin() || @@ -731,7 +627,7 @@ set_properties_now(WindowProperties &properties) { } } - if (properties.has_fullscreen() && + if (properties.has_fullscreen() && properties.get_fullscreen() == _properties.get_fullscreen()) { // Fullscreen property specified, but unchanged. properties.clear_fullscreen(); @@ -743,12 +639,9 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void GraphicsWindow:: close_window() { display_cat.info() @@ -765,53 +658,42 @@ close_window() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool GraphicsWindow:: open_window() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::reset_window -// Access: Protected, Virtual -// Description: resets the window framebuffer from its derived -// children. Does nothing here. -//////////////////////////////////////////////////////////////////// +/** + * resets the window framebuffer from its derived children. Does nothing + * here. + */ void GraphicsWindow:: reset_window(bool swapchain) { display_cat.info() << "Resetting " << get_type() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::do_reshape_request -// Access: Protected, Virtual -// Description: Called from the window thread in response to a request -// from within the code (via request_properties()) to -// change the size and/or position of the window. -// Returns true if the window is successfully changed, -// or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Called from the window thread in response to a request from within the code + * (via request_properties()) to change the size and/or position of the + * window. Returns true if the window is successfully changed, or false if + * there was a problem. + */ bool GraphicsWindow:: do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::system_changed_properties -// Access: Protected -// Description: Should be called (from within the window thread) when -// process_events() detects an external change in some -// important window property; for instance, when the -// user resizes the window. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (from within the window thread) when process_events() + * detects an external change in some important window property; for instance, + * when the user resizes the window. + */ void GraphicsWindow:: system_changed_properties(const WindowProperties &properties) { if (display_cat.is_debug()) { @@ -832,33 +714,28 @@ system_changed_properties(const WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::system_changed_size -// Access: Protected -// Description: An internal function to update all the DisplayRegions -// with the new size of the window. This should always -// be called before changing the _size members of the -// _properties structure. -//////////////////////////////////////////////////////////////////// +/** + * An internal function to update all the DisplayRegions with the new size of + * the window. This should always be called before changing the _size members + * of the _properties structure. + */ void GraphicsWindow:: system_changed_size(int x_size, int y_size) { if (display_cat.is_debug()) { display_cat.debug() << "system_changed_size(" << x_size << ", " << y_size << ")\n"; } - - if (!_properties.has_size() || (x_size != _properties.get_x_size() || + + if (!_properties.has_size() || (x_size != _properties.get_x_size() || y_size != _properties.get_y_size())) { set_size_and_recalc(x_size, y_size); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::add_input_device -// Access: Protected -// Description: Adds a GraphicsWindowInputDevice to the vector. -// Returns the index of the new device. -//////////////////////////////////////////////////////////////////// +/** + * Adds a GraphicsWindowInputDevice to the vector. Returns the index of the + * new device. + */ int GraphicsWindow:: add_input_device(const GraphicsWindowInputDevice &device) { LightMutexHolder holder(_input_lock); @@ -868,66 +745,54 @@ add_input_device(const GraphicsWindowInputDevice &device) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::mouse_mode_relative -// Access: Protected, Virtual -// Description: detaches mouse. Only mouse delta from now on. -// -//////////////////////////////////////////////////////////////////// +/** + * detaches mouse. Only mouse delta from now on. + * + */ void GraphicsWindow:: mouse_mode_relative() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::mouse_mode_absolute -// Access: Protected, Virtual -// Description: reattaches mouse to location -// -//////////////////////////////////////////////////////////////////// +/** + * reattaches mouse to location + * + */ void GraphicsWindow:: mouse_mode_absolute() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::is_touch_event -// Access: Published, Virtual -// Description: Returns whether the specified event msg is a touch message. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the specified event msg is a touch message. + * + */ bool GraphicsWindow:: is_touch_event(GraphicsWindowProcCallbackData* callbackData){ return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_num_touches -// Access: Published, Virtual -// Description: Returns the current number of touches on this window. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of touches on this window. + * + */ int GraphicsWindow:: get_num_touches(){ return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::get_touch_info -// Access: Published, Virtual -// Description: Returns the TouchInfo object describing the specified touch. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the TouchInfo object describing the specified touch. + * + */ TouchInfo GraphicsWindow:: get_touch_info(int index){ return TouchInfo(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindow::supports_window_procs -// Access: Published, Virtual -// Description: Returns whether this window supports adding of Windows proc handlers. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns whether this window supports adding of Windows proc handlers. + * + */ bool GraphicsWindow::supports_window_procs() const{ return false; } diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index e7ebab8c80..86986f52c4 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: graphicsWindow.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindow.h + * @author mike + * @date 1997-01-09 + */ #ifndef GRAPHICSWINDOW_H #define GRAPHICSWINDOW_H @@ -34,16 +33,14 @@ #include "windowHandle.h" #include "touchInfo.h" -//////////////////////////////////////////////////////////////////// -// Class : GraphicsWindow -// Description : A window, fullscreen or on a desktop, into which a -// graphics device sends its output for interactive -// display. -//////////////////////////////////////////////////////////////////// +/** + * A window, fullscreen or on a desktop, into which a graphics device sends + * its output for interactive display. + */ class EXPCL_PANDA_DISPLAY GraphicsWindow : public GraphicsOutput { protected: GraphicsWindow(GraphicsEngine *engine, - GraphicsPipe *pipe, + GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -82,7 +79,7 @@ PUBLISHED: INLINE WindowHandle *get_window_handle() const; MAKE_PROPERTY(window_handle, get_window_handle); - + // Mouse and keyboard routines int get_num_input_devices() const; string get_input_device_name(int device) const; @@ -122,9 +119,9 @@ public: virtual void request_open(); virtual void request_close(); - // It is an error to call any of the following methods from any - // thread other than the window thread. These methods are normally - // called by the GraphicsEngine. + // It is an error to call any of the following methods from any thread other + // than the window thread. These methods are normally called by the + // GraphicsEngine. virtual void set_close_now(); virtual void process_events(); virtual void set_properties_now(WindowProperties &properties); @@ -140,8 +137,8 @@ protected: virtual void mouse_mode_absolute(); virtual void mouse_mode_relative(); - // It is an error to call any of the following methods from any - // thread other than the window thread. + // It is an error to call any of the following methods from any thread other + // than the window thread. void system_changed_properties(const WindowProperties &properties); void system_changed_size(int x_size, int y_size); @@ -159,9 +156,8 @@ protected: bool _got_expose_event; private: - LightReMutex _properties_lock; - // protects _requested_properties, _rejected_properties, and - // _window_event. + LightReMutex _properties_lock; + // protects _requested_properties, _rejected_properties, and _window_event. WindowProperties _requested_properties; WindowProperties _rejected_properties; diff --git a/panda/src/display/graphicsWindowInputDevice.I b/panda/src/display/graphicsWindowInputDevice.I index 3763d7baa4..2d69d042d9 100644 --- a/panda/src/display/graphicsWindowInputDevice.I +++ b/panda/src/display/graphicsWindowInputDevice.I @@ -1,115 +1,94 @@ -// Filename: graphicsWindowInputDevice.I -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowInputDevice.I + * @author drose + * @date 2000-05-24 + */ -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GraphicsWindowInputDevice:: GraphicsWindowInputDevice() { LightMutexHolder holder(_lock); _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string GraphicsWindowInputDevice:: get_name() const { LightMutexHolder holder(_lock); return _name; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::has_pointer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GraphicsWindowInputDevice:: has_pointer() const { LightMutexHolder holder(_lock); return ((_flags & IDF_has_pointer) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::has_keyboard -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GraphicsWindowInputDevice:: has_keyboard() const { LightMutexHolder holder(_lock); return ((_flags & IDF_has_keyboard) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::get_pointer -// Access: Public -// Description: Returns the MouseData associated with the input -// device's pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MouseData associated with the input device's pointer. + */ INLINE MouseData GraphicsWindowInputDevice:: get_pointer() const { LightMutexHolder holder(_lock); return _mouse_data; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::get_raw_pointer -// Access: Public -// Description: Returns the MouseData associated with the input -// device's pointer, in raw form (ie, prior to any -// pointer_mode interpretation). -//////////////////////////////////////////////////////////////////// +/** + * Returns the MouseData associated with the input device's pointer, in raw + * form (ie, prior to any pointer_mode interpretation). + */ INLINE MouseData GraphicsWindowInputDevice:: get_raw_pointer() const { LightMutexHolder holder(_lock); return _true_mouse_data; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_device_index -// Access: Public -// Description: Set the device index. This is reported in pointer -// events. The device index will be equal to the position -// of the GraphicsWindowInputDevice in the window's list. -//////////////////////////////////////////////////////////////////// +/** + * Set the device index. This is reported in pointer events. The device + * index will be equal to the position of the GraphicsWindowInputDevice in the + * window's list. + */ INLINE void GraphicsWindowInputDevice:: set_device_index(int index) { LightMutexHolder holder(_lock); _device_index = index; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::enable_pointer_events -// Access: Public -// Description: Enables the generation of mouse-movement events. -//////////////////////////////////////////////////////////////////// +/** + * Enables the generation of mouse-movement events. + */ INLINE void GraphicsWindowInputDevice:: enable_pointer_events() { LightMutexHolder holder(_lock); _enable_pointer_events = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::disable_pointer_events -// Access: Public -// Description: Disables the generation of mouse-movement events. -//////////////////////////////////////////////////////////////////// +/** + * Disables the generation of mouse-movement events. + */ INLINE void GraphicsWindowInputDevice:: disable_pointer_events() { LightMutexHolder holder(_lock); @@ -117,106 +96,82 @@ disable_pointer_events() { _pointer_events.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_down -// Access: Published -// Description: Records that the indicated button has been depressed. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been depressed. + */ INLINE void GraphicsWindowInputDevice:: button_down(ButtonHandle button) { button_down(button, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_resume_down -// Access: Published -// Description: Records that the indicated button was depressed -// earlier, and we only just detected the event after -// the fact. This is mainly useful for tracking the -// state of modifier keys. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button was depressed earlier, and we only just + * detected the event after the fact. This is mainly useful for tracking the + * state of modifier keys. + */ INLINE void GraphicsWindowInputDevice:: button_resume_down(ButtonHandle button) { button_resume_down(button, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_up -// Access: Published -// Description: Records that the indicated button has been released. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been released. + */ INLINE void GraphicsWindowInputDevice:: button_up(ButtonHandle button) { button_up(button, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::keystroke -// Access: Published -// Description: Records that the indicated keystroke has been -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated keystroke has been generated. + */ INLINE void GraphicsWindowInputDevice:: keystroke(int keycode) { keystroke(keycode, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::focus_lost -// Access: Published -// Description: This should be called when the window focus is lost, -// so that we may miss upcoming button events -// (especially "up" events) for the next period of time. -// It generates keyboard and mouse "up" events for those -// buttons that we previously sent unpaired "down" -// events, so that the Panda application will believe -// all buttons are now released. -//////////////////////////////////////////////////////////////////// +/** + * This should be called when the window focus is lost, so that we may miss + * upcoming button events (especially "up" events) for the next period of + * time. It generates keyboard and mouse "up" events for those buttons that + * we previously sent unpaired "down" events, so that the Panda application + * will believe all buttons are now released. + */ INLINE void GraphicsWindowInputDevice:: focus_lost() { focus_lost(ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::raw_button_down -// Access: Published -// Description: Records that the indicated button has been depressed. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been depressed. + */ INLINE void GraphicsWindowInputDevice:: raw_button_down(ButtonHandle button) { raw_button_down(button, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::raw_button_up -// Access: Published -// Description: Records that the indicated button has been released. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been released. + */ INLINE void GraphicsWindowInputDevice:: raw_button_up(ButtonHandle button) { raw_button_up(button, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_pointer_in_window -// Access: Published -// Description: To be called by a particular kind of GraphicsWindow -// to indicate that the pointer is within the window, at -// the given pixel coordinates. -//////////////////////////////////////////////////////////////////// +/** + * To be called by a particular kind of GraphicsWindow to indicate that the + * pointer is within the window, at the given pixel coordinates. + */ INLINE void GraphicsWindowInputDevice:: set_pointer_in_window(double x, double y) { // mutex is handled in set pointer .. convience function set_pointer(true, x, y, ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_pointer_out_of_window -// Access: Published -// Description: To be called by a particular kind of GraphicsWindow -// to indicate that the pointer is no longer within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * To be called by a particular kind of GraphicsWindow to indicate that the + * pointer is no longer within the window. + */ INLINE void GraphicsWindowInputDevice:: set_pointer_out_of_window() { // mutex is handled in set pointer .. convience function @@ -224,57 +179,45 @@ set_pointer_out_of_window() { ClockObject::get_global_clock()->get_frame_time()); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_pointer_in_window -// Access: Published -// Description: To be called by a particular kind of GraphicsWindow -// to indicate that the pointer is within the window, at -// the given pixel coordinates. -//////////////////////////////////////////////////////////////////// +/** + * To be called by a particular kind of GraphicsWindow to indicate that the + * pointer is within the window, at the given pixel coordinates. + */ INLINE void GraphicsWindowInputDevice:: set_pointer_in_window(double x, double y, double time) { // mutex is handled in set pointer .. convience function set_pointer(true, x, y, time); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_pointer_out_of_window -// Access: Published -// Description: To be called by a particular kind of GraphicsWindow -// to indicate that the pointer is no longer within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * To be called by a particular kind of GraphicsWindow to indicate that the + * pointer is no longer within the window. + */ INLINE void GraphicsWindowInputDevice:: set_pointer_out_of_window(double time) { // mutex is handled in set pointer .. convience function set_pointer(false, _mouse_data._xpos, _mouse_data._ypos, time); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GraphicsWindowInputDevice:: operator == (const GraphicsWindowInputDevice &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GraphicsWindowInputDevice:: operator != (const GraphicsWindowInputDevice &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GraphicsWindowInputDevice:: operator < (const GraphicsWindowInputDevice &) const { return false; diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index a1d4950205..4e0b0a08c2 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -1,17 +1,15 @@ -// Filename: graphicsWindowInputDevice.cxx -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowInputDevice.cxx + * @author drose + * @date 2000-05-24 + */ #include "graphicsWindowInputDevice.h" #include "graphicsWindow.h" @@ -30,17 +28,14 @@ #pragma implementation #endif -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::Constructor -// Access: Private -// Description: Defines a new InputDevice for the window. Most -// windows will have exactly one InputDevice: a -// keyboard/mouse pair. Some may also add joystick -// data, or additional mice or something. -// -// This private constructor is only used internally by -// the named constructors, below. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new InputDevice for the window. Most windows will have exactly + * one InputDevice: a keyboard/mouse pair. Some may also add joystick data, + * or additional mice or something. + * + * This private constructor is only used internally by the named constructors, + * below. + */ GraphicsWindowInputDevice:: GraphicsWindowInputDevice(GraphicsWindow *host, const string &name, int flags) : _host(host), @@ -54,56 +49,46 @@ GraphicsWindowInputDevice(GraphicsWindow *host, const string &name, int flags) : { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::pointer_only -// Access: Public -// Description: This named constructor returns an input device that -// only has a pointing device, no keyboard. -//////////////////////////////////////////////////////////////////// +/** + * This named constructor returns an input device that only has a pointing + * device, no keyboard. + */ GraphicsWindowInputDevice GraphicsWindowInputDevice:: pointer_only(GraphicsWindow *host, const string &name) { return GraphicsWindowInputDevice(host, name, IDF_has_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::keyboard_only -// Access: Public -// Description: This named constructor returns an input device that -// only has a keyboard, no pointing device. -//////////////////////////////////////////////////////////////////// +/** + * This named constructor returns an input device that only has a keyboard, no + * pointing device. + */ GraphicsWindowInputDevice GraphicsWindowInputDevice:: keyboard_only(GraphicsWindow *host, const string &name) { return GraphicsWindowInputDevice(host, name, IDF_has_keyboard); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::pointer_and_keyboard -// Access: Public -// Description: This named constructor returns an input device that -// has both a keyboard and pointer. -//////////////////////////////////////////////////////////////////// +/** + * This named constructor returns an input device that has both a keyboard and + * pointer. + */ GraphicsWindowInputDevice GraphicsWindowInputDevice:: pointer_and_keyboard(GraphicsWindow *host, const string &name) { return GraphicsWindowInputDevice(host, name, IDF_has_pointer | IDF_has_keyboard); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsWindowInputDevice:: GraphicsWindowInputDevice(const GraphicsWindowInputDevice ©) { *this = copy; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GraphicsWindowInputDevice:: operator = (const GraphicsWindowInputDevice ©) { @@ -123,36 +108,28 @@ operator = (const GraphicsWindowInputDevice ©) _pointer_events = copy._pointer_events; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GraphicsWindowInputDevice:: ~GraphicsWindowInputDevice() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::has_button_event -// Access: Public -// Description: Returns true if this device has a pending button -// event (a mouse button or keyboard button down/up), -// false otherwise. If this returns true, the -// particular event may be extracted via -// get_button_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this device has a pending button event (a mouse button or + * keyboard button down/up), false otherwise. If this returns true, the + * particular event may be extracted via get_button_event(). + */ bool GraphicsWindowInputDevice:: has_button_event() const { LightMutexHolder holder(_lock); return !_button_events.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::get_button_event -// Access: Public -// Description: Assuming a previous call to has_button_event() -// returned true, this returns the pending button event. -//////////////////////////////////////////////////////////////////// +/** + * Assuming a previous call to has_button_event() returned true, this returns + * the pending button event. + */ ButtonEvent GraphicsWindowInputDevice:: get_button_event() { LightMutexHolder holder(_lock); @@ -161,26 +138,20 @@ get_button_event() { return be; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::has_pointer_event -// Access: Public -// Description: Returns true if this device has a pending pointer -// event (a mouse movement), or false otherwise. If -// this returns true, the particular event may be -// extracted via get_pointer_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this device has a pending pointer event (a mouse movement), + * or false otherwise. If this returns true, the particular event may be + * extracted via get_pointer_event(). + */ bool GraphicsWindowInputDevice:: has_pointer_event() const { LightMutexHolder holder(_lock); return (_pointer_events != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::get_pointer_events -// Access: Public -// Description: Returns a PointerEventList containing all the recent -// pointer events. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PointerEventList containing all the recent pointer events. + */ PT(PointerEventList) GraphicsWindowInputDevice:: get_pointer_events() { LightMutexHolder holder(_lock); @@ -189,24 +160,19 @@ get_pointer_events() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::enable_pointer_mode -// Access: Public -// Description: There are two modes: raw mode, and pointer mode. -// In pointer mode, the mouse stops when it reaches the -// edges of the window. In raw mode, the mouse ignores -// the screen boundaries and can continue indefinitely, -// even into negative coordinates. In raw mode, each -// "blip" from the mouse hardware corresponds to a -// change of 1 unit in the mouse's (x,y) coordinate. -// In pointer mode, a variety of speed adjustment factors -// and concepts like "mouse acceleration" may be applied. -// -// Mouse zero represents the system mouse pointer. This -// is by definition a pointer, not a raw mouse. It is -// an error to try to enable or disable pointer mode on -// mouse zero. -//////////////////////////////////////////////////////////////////// +/** + * There are two modes: raw mode, and pointer mode. In pointer mode, the + * mouse stops when it reaches the edges of the window. In raw mode, the + * mouse ignores the screen boundaries and can continue indefinitely, even + * into negative coordinates. In raw mode, each "blip" from the mouse + * hardware corresponds to a change of 1 unit in the mouse's (x,y) coordinate. + * In pointer mode, a variety of speed adjustment factors and concepts like + * "mouse acceleration" may be applied. + * + * Mouse zero represents the system mouse pointer. This is by definition a + * pointer, not a raw mouse. It is an error to try to enable or disable + * pointer mode on mouse zero. + */ void GraphicsWindowInputDevice:: enable_pointer_mode(double speed) { LightMutexHolder holder(_lock); @@ -218,11 +184,9 @@ enable_pointer_mode(double speed) { _mouse_data._in_window = true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::disable_pointer_mode -// Access: Public -// Description: see enable_pointer_mode. -//////////////////////////////////////////////////////////////////// +/** + * see enable_pointer_mode. + */ void GraphicsWindowInputDevice:: disable_pointer_mode() { LightMutexHolder holder(_lock); @@ -232,11 +196,9 @@ disable_pointer_mode() { _mouse_data = _true_mouse_data; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::set_pointer -// Access: Published -// Description: Records that a mouse movement has taken place. -//////////////////////////////////////////////////////////////////// +/** + * Records that a mouse movement has taken place. + */ void GraphicsWindowInputDevice:: set_pointer(bool inwin, double x, double y, double time) { LightMutexHolder holder(_lock); @@ -277,11 +239,9 @@ set_pointer(bool inwin, double x, double y, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_down -// Access: Published -// Description: Records that the indicated button has been depressed. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been depressed. + */ void GraphicsWindowInputDevice:: button_down(ButtonHandle button, double time) { LightMutexHolder holder(_lock); @@ -289,14 +249,11 @@ button_down(ButtonHandle button, double time) { _buttons_held.insert(button); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_resume_down -// Access: Published -// Description: Records that the indicated button was depressed -// earlier, and we only just detected the event after -// the fact. This is mainly useful for tracking the -// state of modifier keys. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button was depressed earlier, and we only just + * detected the event after the fact. This is mainly useful for tracking the + * state of modifier keys. + */ void GraphicsWindowInputDevice:: button_resume_down(ButtonHandle button, double time) { LightMutexHolder holder(_lock); @@ -304,11 +261,9 @@ button_resume_down(ButtonHandle button, double time) { _buttons_held.insert(button); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::button_up -// Access: Published -// Description: Records that the indicated button has been released. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been released. + */ void GraphicsWindowInputDevice:: button_up(ButtonHandle button, double time) { LightMutexHolder holder(_lock); @@ -316,26 +271,20 @@ button_up(ButtonHandle button, double time) { _buttons_held.erase(button); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::keystroke -// Access: Published -// Description: Records that the indicated keystroke has been -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated keystroke has been generated. + */ void GraphicsWindowInputDevice:: keystroke(int keycode, double time) { LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(keycode, time)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::candidate -// Access: Published -// Description: Records that the indicated candidate string has been -// highlighted. This is used to implement IME support -// for typing in international languages, especially -// Chinese/Japanese/Korean. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated candidate string has been highlighted. This is + * used to implement IME support for typing in international languages, + * especially Chinese/Japanese/Korean. + */ void GraphicsWindowInputDevice:: candidate(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { @@ -345,17 +294,13 @@ candidate(const wstring &candidate_string, size_t highlight_start, cursor_pos)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::focus_lost -// Access: Published -// Description: This should be called when the window focus is lost, -// so that we may miss upcoming button events -// (especially "up" events) for the next period of time. -// It generates keyboard and mouse "up" events for those -// buttons that we previously sent unpaired "down" -// events, so that the Panda application will believe -// all buttons are now released. -//////////////////////////////////////////////////////////////////// +/** + * This should be called when the window focus is lost, so that we may miss + * upcoming button events (especially "up" events) for the next period of + * time. It generates keyboard and mouse "up" events for those buttons that + * we previously sent unpaired "down" events, so that the Panda application + * will believe all buttons are now released. + */ void GraphicsWindowInputDevice:: focus_lost(double time) { LightMutexHolder holder(_lock); @@ -366,22 +311,18 @@ focus_lost(double time) { _buttons_held.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::raw_button_down -// Access: Published -// Description: Records that the indicated button has been depressed. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been depressed. + */ void GraphicsWindowInputDevice:: raw_button_down(ButtonHandle button, double time) { LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(button, ButtonEvent::T_raw_down, time)); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowInputDevice::raw_button_up -// Access: Published -// Description: Records that the indicated button has been released. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated button has been released. + */ void GraphicsWindowInputDevice:: raw_button_up(ButtonHandle button, double time) { LightMutexHolder holder(_lock); diff --git a/panda/src/display/graphicsWindowInputDevice.h b/panda/src/display/graphicsWindowInputDevice.h index e76d48c5bc..7523ea7e91 100644 --- a/panda/src/display/graphicsWindowInputDevice.h +++ b/panda/src/display/graphicsWindowInputDevice.h @@ -1,16 +1,15 @@ -// Filename: graphicsWindowInputDevice.h -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowInputDevice.h + * @author drose + * @date 2000-05-24 + */ #ifndef GRAPHICSWINDOWINPUTDEVICE_H #define GRAPHICSWINDOWINPUTDEVICE_H @@ -31,14 +30,12 @@ // Forward declarations class GraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsWindowInputDevice -// Description : This is a structure representing a single input -// device that may be associated with a window. -// Typically this will be a keyboard/mouse pair, and -// there will be exactly one of these associated with -// each window, but other variants are possible. -//////////////////////////////////////////////////////////////////// +/** + * This is a structure representing a single input device that may be + * associated with a window. Typically this will be a keyboard/mouse pair, + * and there will be exactly one of these associated with each window, but + * other variants are possible. + */ class EXPCL_PANDA_DISPLAY GraphicsWindowInputDevice { private: GraphicsWindowInputDevice(GraphicsWindow *host, const string &name, int flags); @@ -74,8 +71,8 @@ public: PT(PointerEventList) get_pointer_events(); PUBLISHED: - // The following interface is for the various kinds of - // GraphicsWindows to record the data incoming on the device. + // The following interface is for the various kinds of GraphicsWindows to + // record the data incoming on the device. INLINE void button_down(ButtonHandle button); INLINE void button_resume_down(ButtonHandle button); INLINE void button_up(ButtonHandle button); @@ -101,9 +98,8 @@ PUBLISHED: void set_pointer(bool inwin, double x, double y, double time); public: - // We need these methods to make VC++ happy when we try to - // instantiate a pvector. They don't do - // anything useful. + // We need these methods to make VC++ happy when we try to instantiate a + // pvector. They don't do anything useful. INLINE bool operator == (const GraphicsWindowInputDevice &other) const; INLINE bool operator != (const GraphicsWindowInputDevice &other) const; INLINE bool operator < (const GraphicsWindowInputDevice &other) const; diff --git a/panda/src/display/graphicsWindowProc.cxx b/panda/src/display/graphicsWindowProc.cxx index 18593b296d..177f2e3425 100644 --- a/panda/src/display/graphicsWindowProc.cxx +++ b/panda/src/display/graphicsWindowProc.cxx @@ -1,41 +1,35 @@ -// Filename: graphicsWindowProc.cxx -// Created by: Bei (Mar2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowProc.cxx + * @author Bei + * @date 2010-03 + */ #include "graphicsWindowProc.h" -//////////////////////////////////////////////////////////////////// -// Function: GraphicWindowProc::Constructor -// Access: Public -// Description: Does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Does nothing. + */ GraphicsWindowProc:: GraphicsWindowProc(){ } #if defined(__WIN32__) || defined(_WIN32) -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProc::wnd_proc -// Access: Public, Virtual -// Description: A WIN32-specific method that is called when a Window -// proc event occurrs. Should be overridden by a derived -// class. -//////////////////////////////////////////////////////////////////// +/** + * A WIN32-specific method that is called when a Window proc event occurrs. + * Should be overridden by a derived class. + */ LONG GraphicsWindowProc:: wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){ return 0; } #endif -//most an empty file. +// most an empty file. diff --git a/panda/src/display/graphicsWindowProc.h b/panda/src/display/graphicsWindowProc.h index 68dbeb1f76..c9c056eebd 100644 --- a/panda/src/display/graphicsWindowProc.h +++ b/panda/src/display/graphicsWindowProc.h @@ -1,16 +1,15 @@ -// Filename: graphicsWindowProc.h -// Created by: Bei Yang (Mar 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowProc.h + * @author Bei Yang + * @date 2010-03 + */ #ifndef GRAPHICSWINDOWPROC_H #define GRAPHICSWINDOWPROC_H @@ -26,11 +25,10 @@ class GraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsWindowProc -// Description : Defines an interface for storing platform-specific -// window processor methods. -//////////////////////////////////////////////////////////////////// +/** + * Defines an interface for storing platform-specific window processor + * methods. + */ class EXPCL_PANDA_DISPLAY GraphicsWindowProc { public: GraphicsWindowProc(); @@ -38,7 +36,7 @@ public: virtual LONG wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); #endif - //purely virtual class + // purely virtual class }; #endif // GRAPHICSWINDOWPROC_H diff --git a/panda/src/display/graphicsWindowProcCallbackData.I b/panda/src/display/graphicsWindowProcCallbackData.I index 90eb6e5669..55fc325ad9 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.I +++ b/panda/src/display/graphicsWindowProcCallbackData.I @@ -1,32 +1,27 @@ -// Filename: graphicsWindowProcCallbackData.I -// Created by: Walt Destler (June 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowProcCallbackData.I + * @author Walt Destler + * @date 2010-06 + */ -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GraphicsWindowProcCallbackData:: GraphicsWindowProcCallbackData(GraphicsWindow* graphicsWindow){ _graphicsWindow = graphicsWindow; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_hwnd -// Access: Published -// Description: Returns the GraphicsWindow that generated this event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsWindow that generated this event. + */ INLINE GraphicsWindow* GraphicsWindowProcCallbackData:: get_graphics_window() const { return _graphicsWindow; @@ -34,81 +29,65 @@ get_graphics_window() const { #ifdef WIN32 -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_hwnd -// Access: Published -// Description: Returns the Windows proc hwnd parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows proc hwnd parameter. + */ INLINE int GraphicsWindowProcCallbackData:: get_hwnd() const { return _hwnd; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_msg -// Access: Published -// Description: Returns the Windows proc msg parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows proc msg parameter. + */ INLINE int GraphicsWindowProcCallbackData:: get_msg() const { return _msg; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_wparam -// Access: Published -// Description: Returns the Windows proc wparam parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows proc wparam parameter. + */ INLINE int GraphicsWindowProcCallbackData:: get_wparam() const { return _wparam; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_lparam -// Access: Published -// Description: Returns the Windows proc lparam parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows proc lparam parameter. + */ INLINE int GraphicsWindowProcCallbackData:: get_lparam() const { return _lparam; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::set_hwnd -// Access: Published -// Description: Sets the Windows proc hwnd parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Windows proc hwnd parameter. + */ INLINE void GraphicsWindowProcCallbackData:: set_hwnd(int hwnd) { _hwnd = hwnd; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::set_msg -// Access: Published -// Description: Sets the Windows proc msg parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Windows proc msg parameter. + */ INLINE void GraphicsWindowProcCallbackData:: set_msg(int msg) { _msg = msg; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::set_wparam -// Access: Published -// Description: Sets the Windows proc wparam parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Windows proc wparam parameter. + */ INLINE void GraphicsWindowProcCallbackData:: set_wparam(int wparam) { _wparam = wparam; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::set_lparam -// Access: Published -// Description: Sets the Windows proc lparam parameter. -//////////////////////////////////////////////////////////////////// +/** + * Sets the Windows proc lparam parameter. + */ INLINE void GraphicsWindowProcCallbackData:: set_lparam(int lparam) { _lparam = lparam; diff --git a/panda/src/display/graphicsWindowProcCallbackData.cxx b/panda/src/display/graphicsWindowProcCallbackData.cxx index aab668839b..8bf1da03af 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.cxx +++ b/panda/src/display/graphicsWindowProcCallbackData.cxx @@ -1,27 +1,24 @@ -// Filename: graphicsWindowProcCallbackData.cxx -// Created by: Walt Destler (June 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowProcCallbackData.cxx + * @author Walt Destler + * @date 2010-06 + */ #include "graphicsWindowProcCallbackData.h" #include "graphicsWindow.h" TypeHandle GraphicsWindowProcCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GraphicsWindowProcCallbackData:: output(ostream &out) const { #ifdef WIN32 @@ -31,34 +28,28 @@ output(ostream &out) const { out << get_type() << "()"; #endif } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::is_touch_event -// Access: Public, Virtual -// Description: Returns whether the event is a touch event. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the event is a touch event. + * + */ bool GraphicsWindowProcCallbackData:: is_touch_event(){ return _graphicsWindow->is_touch_event(this); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_num_touches -// Access: Public, Virtual -// Description: Returns the current number of touches on the window. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of touches on the window. + * + */ int GraphicsWindowProcCallbackData:: get_num_touches(){ return _graphicsWindow->get_num_touches(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsWindowProcCallbackData::get_touch_info -// Access: Public, Virtual -// Description: Returns the TouchInfo object describing the specified touch. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the TouchInfo object describing the specified touch. + * + */ TouchInfo GraphicsWindowProcCallbackData:: get_touch_info(int index){ return _graphicsWindow->get_touch_info(index); diff --git a/panda/src/display/graphicsWindowProcCallbackData.h b/panda/src/display/graphicsWindowProcCallbackData.h index e247b0943d..9e3c747d50 100644 --- a/panda/src/display/graphicsWindowProcCallbackData.h +++ b/panda/src/display/graphicsWindowProcCallbackData.h @@ -1,16 +1,15 @@ -// Filename: graphicsWindowProcCallbackData.h -// Created by: Walt Destler (June 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindowProcCallbackData.h + * @author Walt Destler + * @date 2010-06 + */ #ifndef GRAPHICSWINDOWPROCCALLBACKDATA_H #define GRAPHICSWINDOWPROCCALLBACKDATA_H @@ -21,12 +20,11 @@ class GraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsWindowProcCallbackData -// Description : This specialization on CallbackData is passed when -// the callback is initiated from from an implementation -// of the GraphicsWindowProc class, such as PythonGraphicsWindowProc. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on CallbackData is passed when the callback is + * initiated from from an implementation of the GraphicsWindowProc class, such + * as PythonGraphicsWindowProc. + */ class EXPCL_PANDA_DISPLAY GraphicsWindowProcCallbackData : public CallbackData { public: INLINE GraphicsWindowProcCallbackData(GraphicsWindow* graphicsWindow); diff --git a/panda/src/display/graphicsWindow_ext.cxx b/panda/src/display/graphicsWindow_ext.cxx index 5bbd4a0107..06260b4c83 100644 --- a/panda/src/display/graphicsWindow_ext.cxx +++ b/panda/src/display/graphicsWindow_ext.cxx @@ -1,27 +1,23 @@ -// Filename: graphicsWindow_ext.cxx -// Created by: CFSworks (11Oct14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindow_ext.cxx + * @author CFSworks + * @date 2014-10-11 + */ #include "graphicsWindow_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::add_custom_event_handler -// Access: Published -// Description: Adds a python event handler to be called -// when a window event occurs. -//////////////////////////////////////////////////////////////////// +/** + * Adds a python event handler to be called when a window event occurs. + */ void Extension:: add_python_event_handler(PyObject* handler, PyObject* name){ PythonGraphicsWindowProc* pgwp = new PythonGraphicsWindowProc(handler, name); @@ -29,11 +25,9 @@ add_python_event_handler(PyObject* handler, PyObject* name){ _this->add_window_proc(pgwp); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::remove_custom_event_handler -// Access: Published -// Description: Removes the specified python event handler. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specified python event handler. + */ void Extension:: remove_python_event_handler(PyObject* name){ list toRemove; diff --git a/panda/src/display/graphicsWindow_ext.h b/panda/src/display/graphicsWindow_ext.h index 3b14159f38..166e40f401 100644 --- a/panda/src/display/graphicsWindow_ext.h +++ b/panda/src/display/graphicsWindow_ext.h @@ -1,16 +1,15 @@ -// Filename: graphicsWindow_ext.h -// Created by: CFSworks (11Oct14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsWindow_ext.h + * @author CFSworks + * @date 2014-10-11 + */ #ifndef GRAPHICSWINDOW_EXT_H #define GRAPHICSWINDOW_EXT_H @@ -24,12 +23,10 @@ #include "pythonGraphicsWindowProc.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// GraphicsWindow, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for GraphicsWindow, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/display/nativeWindowHandle.I b/panda/src/display/nativeWindowHandle.I index 8c0a6ba518..b897aa2f1c 100644 --- a/panda/src/display/nativeWindowHandle.I +++ b/panda/src/display/nativeWindowHandle.I @@ -1,73 +1,59 @@ -// Filename: nativeWindowHandle.I -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeWindowHandle.I + * @author drose + * @date 2009-09-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::IntHandle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NativeWindowHandle::IntHandle:: IntHandle(size_t handle) : _handle(handle) { } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::IntHandle::get_handle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t NativeWindowHandle::IntHandle:: get_handle() const { return _handle; } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::SubprocessHandle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NativeWindowHandle::SubprocessHandle:: SubprocessHandle(const Filename &filename) : _filename(filename) { } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::SubprocessHandle::get_filename -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const Filename &NativeWindowHandle::SubprocessHandle:: get_filename() const { return _filename; } #if defined(HAVE_X11) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::X11Handle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NativeWindowHandle::X11Handle:: X11Handle(X11_Window handle) : _handle(handle) { } #endif // HAVE_X11 #if defined(HAVE_X11) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::X11Handle::get_handle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE X11_Window NativeWindowHandle::X11Handle:: get_handle() const { return _handle; @@ -75,22 +61,18 @@ get_handle() const { #endif // HAVE_X11 #if defined(WIN32) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::WinHandle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NativeWindowHandle::WinHandle:: WinHandle(HWND handle) : _handle(handle) { } #endif // WIN32 #if defined(WIN32) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::WinHandle::get_handle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HWND NativeWindowHandle::WinHandle:: get_handle() const { return _handle; diff --git a/panda/src/display/nativeWindowHandle.cxx b/panda/src/display/nativeWindowHandle.cxx index 964b6f4a3c..7616471172 100644 --- a/panda/src/display/nativeWindowHandle.cxx +++ b/panda/src/display/nativeWindowHandle.cxx @@ -1,16 +1,15 @@ -// Filename: nativeWindowHandle.cxx -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeWindowHandle.cxx + * @author drose + * @date 2009-09-30 + */ #include "nativeWindowHandle.h" @@ -25,45 +24,34 @@ TypeHandle NativeWindowHandle::X11Handle::_type_handle; TypeHandle NativeWindowHandle::WinHandle::_type_handle; #endif -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::make_int -// Access: Published, Static -// Description: Constructs a new WindowHandle with an int value, -// which is understood to be either an HWND or a Window, -// cast to int. This method exists for the convenience -// of Python, which likes to deal with ints; C++ code -// should use one of the more specific make_x11() or -// make_win32() methods instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new WindowHandle with an int value, which is understood to be + * either an HWND or a Window, cast to int. This method exists for the + * convenience of Python, which likes to deal with ints; C++ code should use + * one of the more specific make_x11() or make_win32() methods instead. + */ PT(WindowHandle) NativeWindowHandle:: make_int(size_t window) { return new WindowHandle(new IntHandle(window)); } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::make_subprocess -// Access: Published, Static -// Description: Constructs a new WindowHandle that references a -// SubprocessWindowBuffer read in another process, with -// the named pipe filename that it uses for -// communication. -// -// This is (at present, and maybe always) useful only on -// the OS X platform, where parenting child windows is -// particularly problematic. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new WindowHandle that references a SubprocessWindowBuffer read + * in another process, with the named pipe filename that it uses for + * communication. + * + * This is (at present, and maybe always) useful only on the OS X platform, + * where parenting child windows is particularly problematic. + */ PT(WindowHandle) NativeWindowHandle:: make_subprocess(const Filename &filename) { return new WindowHandle(new SubprocessHandle(filename)); } #if defined(HAVE_X11) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::make_x11 -// Access: Published, Static -// Description: Constructs a new WindowHandle that references an -// X11 window. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new WindowHandle that references an X11 window. + */ PT(WindowHandle) NativeWindowHandle:: make_x11(X11_Window window) { return new WindowHandle(new X11Handle(window)); @@ -71,58 +59,45 @@ make_x11(X11_Window window) { #endif // HAVE_X11 #if defined(WIN32) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::make_win -// Access: Published, Static -// Description: Constructs a new WindowHandle that references a -// window on Windows. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new WindowHandle that references a window on Windows. + */ PT(WindowHandle) NativeWindowHandle:: make_win(HWND window) { return new WindowHandle(new WinHandle(window)); } #endif // WIN32 -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::IntHandle::get_int_handle -// Access: Public, Virtual -// Description: Returns the OS-specific handle converted to an -// integer, if this is possible for the particular -// representation. Returns 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle converted to an integer, if this is possible + * for the particular representation. Returns 0 if it is not. + */ size_t NativeWindowHandle::IntHandle:: get_int_handle() const { return _handle; } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::IntHandle::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NativeWindowHandle::IntHandle:: output(ostream &out) const { out << "(" << _handle << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::SubprocessHandle::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NativeWindowHandle::SubprocessHandle:: output(ostream &out) const { out << "(" << _filename << ")"; } #if defined(HAVE_X11) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::X11Handle::get_int_handle -// Access: Public, Virtual -// Description: Returns the OS-specific handle converted to an -// integer, if this is possible for the particular -// representation. Returns 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle converted to an integer, if this is possible + * for the particular representation. Returns 0 if it is not. + */ size_t NativeWindowHandle::X11Handle:: get_int_handle() const { return (size_t)_handle; @@ -130,11 +105,9 @@ get_int_handle() const { #endif // HAVE_X11 #if defined(HAVE_X11) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::X11Handle::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NativeWindowHandle::X11Handle:: output(ostream &out) const { out << _handle; @@ -142,13 +115,10 @@ output(ostream &out) const { #endif // HAVE_X11 #if defined(WIN32) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::WinHandle::get_int_handle -// Access: Public, Virtual -// Description: Returns the OS-specific handle converted to an -// integer, if this is possible for the particular -// representation. Returns 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle converted to an integer, if this is possible + * for the particular representation. Returns 0 if it is not. + */ size_t NativeWindowHandle::WinHandle:: get_int_handle() const { return (size_t)_handle; @@ -156,11 +126,9 @@ get_int_handle() const { #endif // WIN32 #if defined(WIN32) && !defined(CPPPARSER) -//////////////////////////////////////////////////////////////////// -// Function: NativeWindowHandle::WinHandle::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NativeWindowHandle::WinHandle:: output(ostream &out) const { out << _handle; diff --git a/panda/src/display/nativeWindowHandle.h b/panda/src/display/nativeWindowHandle.h index 172ff84d6f..da6096533a 100644 --- a/panda/src/display/nativeWindowHandle.h +++ b/panda/src/display/nativeWindowHandle.h @@ -1,16 +1,15 @@ -// Filename: nativeWindowHandle.h -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nativeWindowHandle.h + * @author drose + * @date 2009-09-30 + */ #ifndef NATIVEWINDOWHANDLE_H #define NATIVEWINDOWHANDLE_H @@ -27,16 +26,13 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Class : NativeWindowHandle -// Description : This subclass of WindowHandle exists to allow simple -// creation of a WindowHandle of the appropriate type to -// the current OS. -// -// This class exists for name scoping only. Don't use -// the constructor directly; use one of the make_* -// methods. -//////////////////////////////////////////////////////////////////// +/** + * This subclass of WindowHandle exists to allow simple creation of a + * WindowHandle of the appropriate type to the current OS. + * + * This class exists for name scoping only. Don't use the constructor + * directly; use one of the make_* methods. + */ class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle { private: INLINE NativeWindowHandle(); @@ -54,7 +50,7 @@ public: #if defined(WIN32) && !defined(CPPPARSER) static PT(WindowHandle) make_win(HWND window); #endif // WIN32 - + public: class EXPCL_PANDA_DISPLAY IntHandle : public OSHandle { public: @@ -80,7 +76,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -108,7 +104,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -119,12 +115,12 @@ public: INLINE X11Handle(X11_Window handle); virtual size_t get_int_handle() const; virtual void output(ostream &out) const; - + INLINE X11_Window get_handle() const; - + private: X11_Window _handle; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -138,7 +134,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; @@ -170,7 +166,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/display/pStatGPUTimer.I b/panda/src/display/pStatGPUTimer.I index 4493f4ab9b..aaf8e531a8 100644 --- a/panda/src/display/pStatGPUTimer.I +++ b/panda/src/display/pStatGPUTimer.I @@ -1,25 +1,21 @@ -// Filename: pStatGPUTimer.I -// Created by: rdb (21Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatGPUTimer.I + * @author rdb + * @date 2014-08-21 + */ #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatGPUTimer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatGPUTimer:: PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector) : PStatTimer(collector), @@ -27,15 +23,14 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector) : { if (gsg->get_timer_queries_active() && collector.is_active()) { gsg->issue_timer_query(collector.get_index()); - //cerr << "issuing " << collector << " active " << collector.is_active() << "\n"; + // cerr << "issuing " << collector << " active " << collector.is_active() + // << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: PStatGPUTimer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatGPUTimer:: PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *current_thread) : PStatTimer(collector, current_thread), @@ -46,11 +41,9 @@ PStatGPUTimer(GraphicsStateGuardian *gsg, PStatCollector &collector, Thread *cur } } -//////////////////////////////////////////////////////////////////// -// Function: PStatGPUTimer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatGPUTimer:: ~PStatGPUTimer() { if (_gsg->get_timer_queries_active() && _collector.is_active()) { diff --git a/panda/src/display/pStatGPUTimer.h b/panda/src/display/pStatGPUTimer.h index 6f7ede9d49..f5185778ec 100644 --- a/panda/src/display/pStatGPUTimer.h +++ b/panda/src/display/pStatGPUTimer.h @@ -1,16 +1,15 @@ -// Filename: pStatGPUTimer.h -// Created by: rdb (21Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatGPUTimer.h + * @author rdb + * @date 2014-08-21 + */ #ifndef PSTATGPUTIMER_H #define PSTATGPUTIMER_H @@ -24,20 +23,16 @@ class Thread; class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : PStatGPUTimer -// Description : This is a special type of PStatTimer that also -// uses a timer query on the GSG to measure how long -// a task actually takes to execute on the GPU, rather -// than how long it took for the API commands to be -// queued up. -// -// This class may only be used on the draw thread. -// -// At present, it tracks both the CPU time (like a -// regular PStatTimer does) and the GPU time, which -// is recorded using a special PStatThread. -//////////////////////////////////////////////////////////////////// +/** + * This is a special type of PStatTimer that also uses a timer query on the + * GSG to measure how long a task actually takes to execute on the GPU, rather + * than how long it took for the API commands to be queued up. + * + * This class may only be used on the draw thread. + * + * At present, it tracks both the CPU time (like a regular PStatTimer does) + * and the GPU time, which is recorded using a special PStatThread. + */ class EXPCL_PANDA_DISPLAY PStatGPUTimer : public PStatTimer { public: #ifdef DO_PSTATS diff --git a/panda/src/display/parasiteBuffer.I b/panda/src/display/parasiteBuffer.I index fb0ff49c26..f49a903836 100644 --- a/panda/src/display/parasiteBuffer.I +++ b/panda/src/display/parasiteBuffer.I @@ -1,14 +1,12 @@ -// Filename: parasiteBuffer.I -// Created by: drose (27Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parasiteBuffer.I + * @author drose + * @date 2004-02-27 + */ diff --git a/panda/src/display/parasiteBuffer.cxx b/panda/src/display/parasiteBuffer.cxx index cd49d18ca8..ace66cfdbc 100644 --- a/panda/src/display/parasiteBuffer.cxx +++ b/panda/src/display/parasiteBuffer.cxx @@ -1,29 +1,25 @@ -// Filename: parasiteBuffer.cxx -// Created by: drose (27Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parasiteBuffer.cxx + * @author drose + * @date 2004-02-27 + */ #include "parasiteBuffer.h" #include "texture.h" TypeHandle ParasiteBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::Constructor -// Access: Public -// Description: Normally, the ParasiteBuffer constructor is not -// called directly; these are created instead via the -// GraphicsEngine::make_parasite() function. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the ParasiteBuffer constructor is not called directly; these are + * created instead via the GraphicsEngine::make_parasite() function. + */ ParasiteBuffer:: ParasiteBuffer(GraphicsOutput *host, const string &name, int x_size, int y_size, int flags) : @@ -57,36 +53,28 @@ ParasiteBuffer(GraphicsOutput *host, const string &name, set_inverted(host->get_gsg()->get_copy_texture_inverted()); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParasiteBuffer:: ~ParasiteBuffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::is_active -// Access: Published, Virtual -// Description: Returns true if the window is ready to be rendered -// into, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is ready to be rendered into, false otherwise. + */ bool ParasiteBuffer:: is_active() const { return GraphicsOutput::is_active() && _host->is_active(); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::set_size -// Access: Public, Virtual -// Description: This is called by the GraphicsEngine to request that -// the buffer resize itself. Although calls to get the -// size will return the new value, much of the actual -// resizing work doesn't take place until the next -// begin_frame. Not all buffers are resizeable. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsEngine to request that the buffer resize + * itself. Although calls to get the size will return the new value, much of + * the actual resizing work doesn't take place until the next begin_frame. + * Not all buffers are resizeable. + */ void ParasiteBuffer:: set_size(int x, int y) { if ((_creation_flags & GraphicsPipe::BF_resizeable) == 0) { @@ -96,11 +84,9 @@ set_size(int x, int y) { set_size_and_recalc(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::set_size_and_recalc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ParasiteBuffer:: set_size_and_recalc(int x, int y) { if (!(_creation_flags & GraphicsPipe::BF_size_track_host)) { @@ -116,65 +102,55 @@ set_size_and_recalc(int x, int y) { GraphicsOutput::set_size_and_recalc(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::flip_ready -// Access: Public, Virtual -// Description: Returns true if a frame has been rendered and needs -// to be flipped, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a frame has been rendered and needs to be flipped, false + * otherwise. + */ bool ParasiteBuffer:: flip_ready() const { nassertr(_host != NULL, false); return _host->flip_ready(); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void ParasiteBuffer:: begin_flip() { nassertv(_host != NULL); _host->begin_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::ready_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip when it is command but not actually flip -// -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip when it is command + * but not actually flip + * + */ void ParasiteBuffer:: ready_flip() { nassertv(_host != NULL); _host->ready_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void ParasiteBuffer:: end_flip() { nassertv(_host != NULL); @@ -182,15 +158,12 @@ end_flip() { _flip_ready = false; } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool ParasiteBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -216,13 +189,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void ParasiteBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -234,7 +205,7 @@ end_frame(FrameMode mode, Thread *current_thread) { if (mode == FM_refresh) { return; } - + if (mode == FM_render) { promote_to_copy_texture(); copy_to_textures(); @@ -242,17 +213,12 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParasiteBuffer::get_host -// Access: Public, Virtual -// Description: This is normally called only from within -// make_texture_buffer(). When called on a -// ParasiteBuffer, it returns the host of that buffer; -// but when called on some other buffer, it returns the -// buffer itself. -//////////////////////////////////////////////////////////////////// +/** + * This is normally called only from within make_texture_buffer(). When + * called on a ParasiteBuffer, it returns the host of that buffer; but when + * called on some other buffer, it returns the buffer itself. + */ GraphicsOutput *ParasiteBuffer:: get_host() { return _host; } - diff --git a/panda/src/display/parasiteBuffer.h b/panda/src/display/parasiteBuffer.h index 2b73440354..421b932584 100644 --- a/panda/src/display/parasiteBuffer.h +++ b/panda/src/display/parasiteBuffer.h @@ -1,16 +1,15 @@ -// Filename: parasiteBuffer.h -// Created by: drose (27Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parasiteBuffer.h + * @author drose + * @date 2004-02-27 + */ #ifndef PARASITEBUFFER_H #define PARASITEBUFFER_H @@ -21,38 +20,31 @@ #include "texture.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : ParasiteBuffer -// Description : This is a special GraphicsOutput type that acts a lot -// like a GraphicsBuffer, effectively allowing rendering -// to an offscreen buffer, except it does not create any -// framebuffer space for itself. Instead, it renders -// into the framebuffer owned by some other -// GraphicsOutput. -// -// The x_size and y_size must therefore fit within the -// bounds of the source GraphicsOutput. -// -// Since the framebuffer will be subsequently cleared -// when the actual owner draws in it later, this only -// makes sense if we are going to copy the contents of -// the framebuffer to a texture immediately after we -// draw it. Thus, has_texture() is implicitly true for -// a ParasiteBuffer. -// -// This class is useful to render offscreen to a texture -// while preventing the waste of framebuffer memory for -// API's that are unable to render directly into a -// texture (and must render into a separate framebuffer -// first and then copy to texture). It is also the only -// way to render to a texture on API's that do not -// support offscreen rendering. -//////////////////////////////////////////////////////////////////// +/** + * This is a special GraphicsOutput type that acts a lot like a + * GraphicsBuffer, effectively allowing rendering to an offscreen buffer, + * except it does not create any framebuffer space for itself. Instead, it + * renders into the framebuffer owned by some other GraphicsOutput. + * + * The x_size and y_size must therefore fit within the bounds of the source + * GraphicsOutput. + * + * Since the framebuffer will be subsequently cleared when the actual owner + * draws in it later, this only makes sense if we are going to copy the + * contents of the framebuffer to a texture immediately after we draw it. + * Thus, has_texture() is implicitly true for a ParasiteBuffer. + * + * This class is useful to render offscreen to a texture while preventing the + * waste of framebuffer memory for API's that are unable to render directly + * into a texture (and must render into a separate framebuffer first and then + * copy to texture). It is also the only way to render to a texture on API's + * that do not support offscreen rendering. + */ class EXPCL_PANDA_DISPLAY ParasiteBuffer : public GraphicsOutput { public: ParasiteBuffer(GraphicsOutput *host, const string &name, int x_size, int y_size, int flags); - + PUBLISHED: virtual ~ParasiteBuffer(); @@ -69,10 +61,10 @@ public: virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); virtual GraphicsOutput *get_host(); - + private: int _creation_flags; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/display/post_x11_include.h b/panda/src/display/post_x11_include.h index 09ebf0ae6c..78b16dd638 100644 --- a/panda/src/display/post_x11_include.h +++ b/panda/src/display/post_x11_include.h @@ -1,21 +1,19 @@ -// Filename: post_x11_include.h -// Created by: drose (28Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file post_x11_include.h + * @author drose + * @date 2011-08-28 + */ -// To be included after including X11/*.h. +// To be included after including X11*.h. #undef Display #undef Window #undef Cursor #undef Connection - diff --git a/panda/src/display/pre_x11_include.h b/panda/src/display/pre_x11_include.h index 6103c3ba56..ad1f48f5b3 100644 --- a/panda/src/display/pre_x11_include.h +++ b/panda/src/display/pre_x11_include.h @@ -1,18 +1,17 @@ -// Filename: pre_x11_include.h -// Created by: drose (28Aug11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pre_x11_include.h + * @author drose + * @date 2011-08-28 + */ -// To be included prior to including X11/*.h. +// To be included prior to including X11*.h. #define Display X11_Display #define Window X11_Window diff --git a/panda/src/display/pythonGraphicsWindowProc.cxx b/panda/src/display/pythonGraphicsWindowProc.cxx index b4cdfeb828..d114d9ba3d 100644 --- a/panda/src/display/pythonGraphicsWindowProc.cxx +++ b/panda/src/display/pythonGraphicsWindowProc.cxx @@ -1,16 +1,15 @@ -// Filename: pythonGraphicsWindowProc.cxx -// Created by: Walt Destler (May 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonGraphicsWindowProc.cxx + * @author Walt Destler + * @date 2010-05 + */ #include "pythonGraphicsWindowProc.h" #include "graphicsWindowProcCallbackData.h" @@ -19,12 +18,10 @@ TypeHandle PythonGraphicsWindowProc::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PythonGraphicWindowProc::Constructor -// Access: Public -// Description: Initializes this PythonGraphicsWindowProc to use the -// specified callback handler and name. -//////////////////////////////////////////////////////////////////// +/** + * Initializes this PythonGraphicsWindowProc to use the specified callback + * handler and name. + */ PythonGraphicsWindowProc:: PythonGraphicsWindowProc(PyObject* function, PyObject* name) : PythonCallbackObject(function) @@ -33,11 +30,9 @@ PythonGraphicsWindowProc(PyObject* function, PyObject* name) : Py_INCREF(_name); } -//////////////////////////////////////////////////////////////////// -// Function: PythonGraphicWindowProc::Constructor -// Access: Public, Virtual -// Description: Decrements references to the handler and name objects. -//////////////////////////////////////////////////////////////////// +/** + * Decrements references to the handler and name objects. + */ PythonGraphicsWindowProc:: ~PythonGraphicsWindowProc(){ Py_DECREF(_name); @@ -45,12 +40,10 @@ PythonGraphicsWindowProc:: #ifdef WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PythonGraphicWindowProc::wnd_proc -// Access: Public, Virtual -// Description: A WIN32-specific method that is called when a Window -// proc event occurrs. Calls the python handler. -//////////////////////////////////////////////////////////////////// +/** + * A WIN32-specific method that is called when a Window proc event occurrs. + * Calls the python handler. + */ LONG PythonGraphicsWindowProc:: wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){ GraphicsWindowProcCallbackData cdata(graphicsWindow); @@ -65,11 +58,9 @@ wnd_proc(GraphicsWindow* graphicsWindow, HWND hwnd, UINT msg, WPARAM wparam, LPA #endif // WIN32 -//////////////////////////////////////////////////////////////////// -// Function: PythonGraphicWindowProc::get_name -// Access: Public -// Description: Returns the python name object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the python name object. + */ PyObject* PythonGraphicsWindowProc:: get_name(){ return _name; diff --git a/panda/src/display/pythonGraphicsWindowProc.h b/panda/src/display/pythonGraphicsWindowProc.h index 091307020e..902cb83fb7 100644 --- a/panda/src/display/pythonGraphicsWindowProc.h +++ b/panda/src/display/pythonGraphicsWindowProc.h @@ -1,16 +1,15 @@ -// Filename: pythonGraphicsWindowProc.h -// Created by: Walt Destler (May 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonGraphicsWindowProc.h + * @author Walt Destler + * @date 2010-05 + */ #ifndef PYTHONGRAPHICSWINDOWPROC_H #define PYTHONGRAPHICSWINDOWPROC_H @@ -21,11 +20,10 @@ #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Class : PythonGraphicsWindowProc -// Description : Extends GraphicsWindowProc to provde callback functionality -// to a python program. -//////////////////////////////////////////////////////////////////// +/** + * Extends GraphicsWindowProc to provde callback functionality to a python + * program. + */ class PythonGraphicsWindowProc: public GraphicsWindowProc, public PythonCallbackObject { public: diff --git a/panda/src/display/renderBuffer.h b/panda/src/display/renderBuffer.h index d2aac2f45e..14466c732e 100644 --- a/panda/src/display/renderBuffer.h +++ b/panda/src/display/renderBuffer.h @@ -1,16 +1,15 @@ -// Filename: renderBuffer.h -// Created by: drose (02Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderBuffer.h + * @author drose + * @date 1999-02-02 + */ #ifndef RENDERBUFFER_H #define RENDERBUFFER_H @@ -19,14 +18,12 @@ class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : RenderBuffer -// Description : A RenderBuffer is an arbitrary subset of the various -// layers (depth buffer, color buffer, etc.) of a -// drawing region. It consists of a -// GraphicsStateGuardian pointer, along with a bitmask -// of the layers we're interested in. -//////////////////////////////////////////////////////////////////// +/** + * A RenderBuffer is an arbitrary subset of the various layers (depth buffer, + * color buffer, etc.) of a drawing region. It consists of a + * GraphicsStateGuardian pointer, along with a bitmask of the layers we're + * interested in. + */ class EXPCL_PANDA_DISPLAY RenderBuffer { public: enum Type { @@ -36,13 +33,13 @@ public: T_aux_rgba_3 = 0x00000008, T_aux_rgba_ALL = 0x0000000F, - T_aux_hrgba_0 = 0x00000010, // These can't really be implemented until + T_aux_hrgba_0 = 0x00000010, // These can't really be implemented until T_aux_hrgba_1 = 0x00000020, // we have support for hrgba textures. T_aux_hrgba_2 = 0x00000040, // I've just added the bits for the future. T_aux_hrgba_3 = 0x00000080, T_aux_hrgba_ALL = 0x000000F0, - T_aux_float_0 = 0x00000100, // These can't really be implemented until + T_aux_float_0 = 0x00000100, // These can't really be implemented until T_aux_float_1 = 0x00000200, // we have support for float textures. T_aux_float_2 = 0x00000400, // I've just added the bits for the future. T_aux_float_3 = 0x00000800, @@ -64,7 +61,7 @@ public: T_back = 0x000a0000, T_left = 0x00030000, T_right = 0x000c0000, - + T_color = 0x000F0000, T_depth = 0x00100000, diff --git a/panda/src/display/standardMunger.I b/panda/src/display/standardMunger.I index 17a973cb4c..4ebd308de2 100644 --- a/panda/src/display/standardMunger.I +++ b/panda/src/display/standardMunger.I @@ -1,36 +1,28 @@ -// Filename: standardMunger.I -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standardMunger.I + * @author drose + * @date 2005-03-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::get_gsg -// Access: Public -// Description: Returns a pointer to the GSG that created this -// munger. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the GSG that created this munger. + */ INLINE GraphicsStateGuardian *StandardMunger:: get_gsg() const { return (GraphicsStateGuardian *)GeomMunger::get_gsg(); } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::get_render_mode -// Access: Protected -// Description: Returns the render mode active on this munger. -// Intended for derived classes that may have to munge -// differently depending on render mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render mode active on this munger. Intended for derived + * classes that may have to munge differently depending on render mode. + */ INLINE RenderModeAttrib::Mode StandardMunger:: get_render_mode() const { return (_render_mode != NULL) ? _render_mode->get_mode() diff --git a/panda/src/display/standardMunger.cxx b/panda/src/display/standardMunger.cxx index 53b4485303..1f88f23c46 100644 --- a/panda/src/display/standardMunger.cxx +++ b/panda/src/display/standardMunger.cxx @@ -1,16 +1,15 @@ -// Filename: standardMunger.cxx -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standardMunger.cxx + * @author drose + * @date 2005-03-21 + */ #include "standardMunger.h" #include "renderState.h" @@ -20,14 +19,11 @@ TypeHandle StandardMunger::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::Constructor -// Access: Public -// Description: The StandardMunger constructor accepts additional -// parameters that specify the GSG's preferred color -// format (since we might be munging the color anyway, -// we might as well convert it as we munge). -//////////////////////////////////////////////////////////////////// +/** + * The StandardMunger constructor accepts additional parameters that specify + * the GSG's preferred color format (since we might be munging the color + * anyway, we might as well convert it as we munge). + */ StandardMunger:: StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, int num_components, @@ -54,9 +50,9 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, color_attrib->get_color_type() == ColorAttrib::T_flat) { if (!get_gsg()->get_color_scale_via_lighting()) { - // We only need to munge the color directly if the GSG says it - // can't cheat the color via lighting (presumably, in this case, - // by applying a material). + // We only need to munge the color directly if the GSG says it can't + // cheat the color via lighting (presumably, in this case, by applying + // a material). _color = color_attrib->get_color(); if (state->get_attrib(color_scale_attrib) && color_scale_attrib->has_scale()) { @@ -76,18 +72,17 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, const TextureAttrib *tex_attrib = (const TextureAttrib *) state->get_attrib(TextureAttrib::get_class_slot()); - // If the GSG says it can't cheat this RGB or alpha scale, we have - // to apply the color scale directly. + // If the GSG says it can't cheat this RGB or alpha scale, we have to + // apply the color scale directly. if ((color_scale_attrib->has_rgb_scale() && !get_gsg()->get_color_scale_via_lighting()) || (color_scale_attrib->has_alpha_scale() && !get_gsg()->get_alpha_scale_via_texture(tex_attrib))) { _munge_color_scale = true; } - // Known bug: if there is a material on an object that would - // obscure the effect of color_scale, we scale the lighting - // anyway, thus applying the effect even if it should be obscured. - // It doesn't seem worth the effort to detect this contrived - // situation and handle it correctly. + // Known bug: if there is a material on an object that would obscure the + // effect of color_scale, we scale the lighting anyway, thus applying + // the effect even if it should be obscured. It doesn't seem worth the + // effort to detect this contrived situation and handle it correctly. } } @@ -101,21 +96,16 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StandardMunger:: ~StandardMunger() { } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::munge_data_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexData, converts it as -// necessary for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexData, converts it as necessary for rendering. + */ CPT(GeomVertexData) StandardMunger:: munge_data_impl(const GeomVertexData *data) { CPT(GeomVertexData) new_data = data; @@ -146,15 +136,14 @@ munge_data_impl(const GeomVertexData *data) { table->get_num_transforms() <= get_gsg()->get_max_vertex_transform_indices()) { if (table->get_num_transforms() == table->get_max_simultaneous_transforms()) { - // We can support an indexed palette, but since that won't - // save us any per-vertex blends, go ahead and do a plain - // old nonindexed table instead. + // We can support an indexed palette, but since that won't save us + // any per-vertex blends, go ahead and do a plain old nonindexed + // table instead. animation.set_hardware(table->get_num_transforms(), false); } else { - // We can support an indexed palette, and that means we can - // reduce the number of blends we have to specify for each - // vertex. + // We can support an indexed palette, and that means we can reduce + // the number of blends we have to specify for each vertex. animation.set_hardware(table->get_max_simultaneous_transforms(), true); } @@ -178,11 +167,9 @@ munge_data_impl(const GeomVertexData *data) { return new_data->convert_to(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::munge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void StandardMunger:: munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, Thread *) { @@ -190,21 +177,20 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, int unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering; if (unsupported_bits != 0) { - // Even beyond munging the vertex format, we have to convert the - // Geom itself into a new primitive type the GSG can render - // directly. - // If we don't support a strip cut index, it might be faster to - // just decompose it rather than draw them one by one. + // Even beyond munging the vertex format, we have to convert the Geom + // itself into a new primitive type the GSG can render directly. If we + // don't support a strip cut index, it might be faster to just decompose + // it rather than draw them one by one. if ((unsupported_bits & Geom::GR_composite_bits) != 0 || (unsupported_bits & Geom::GR_strip_cut_index) != 0) { - // This decomposes everything in the primitive, so that if (for - // instance) the primitive contained both strips and fans, but - // the GSG didn't support fans, it would decompose the strips - // too. To handle this correctly, we'd need a separate - // decompose_fans() and decompose_strips() call; but for now, - // we'll just say it's good enough. In practice, we don't have - // any GSG's that can support strips without also supporting - // fans. +/* + * This decomposes everything in the primitive, so that if (for instance) the + * primitive contained both strips and fans, but the GSG didn't support fans, + * it would decompose the strips too. To handle this correctly, we'd need a + * separate decompose_fans() and decompose_strips() call; but for now, we'll + * just say it's good enough. In practice, we don't have any GSG's that can + * support strips without also supporting fans. + */ geom = geom->decompose(); // Decomposing might produce an indexed Geom, so re-check the @@ -212,9 +198,8 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering; } if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) { - // Rotate the vertices to account for different shade-model - // expectations (e.g. SM_flat_last_vertex to - // SM_flat_first_vertex) + // Rotate the vertices to account for different shade-model expectations + // (e.g. SM_flat_last_vertex to SM_flat_first_vertex) geom = geom->rotate(); } if ((unsupported_bits & Geom::GR_indexed_bits) != 0) { @@ -228,32 +213,29 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, } } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::premunge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void StandardMunger:: premunge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) { int supported_geom_rendering = get_gsg()->get_supported_geom_rendering(); int unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering; if (unsupported_bits != 0) { - // Even beyond munging the vertex format, we have to convert the - // Geom itself into a new primitive type the GSG can render - // directly. - // If we don't support a strip cut index, it might be faster to - // just decompose it rather than draw them one by one. + // Even beyond munging the vertex format, we have to convert the Geom + // itself into a new primitive type the GSG can render directly. If we + // don't support a strip cut index, it might be faster to just decompose + // it rather than draw them one by one. if ((unsupported_bits & Geom::GR_composite_bits) != 0 || (unsupported_bits & Geom::GR_strip_cut_index) != 0) { - // This decomposes everything in the primitive, so that if (for - // instance) the primitive contained both strips and fans, but - // the GSG didn't support fans, it would decompose the strips - // too. To handle this correctly, we'd need a separate - // decompose_fans() and decompose_strips() call; but for now, - // we'll just say it's good enough. In practice, we don't have - // any GSG's that can support strips without also supporting - // fans. +/* + * This decomposes everything in the primitive, so that if (for instance) the + * primitive contained both strips and fans, but the GSG didn't support fans, + * it would decompose the strips too. To handle this correctly, we'd need a + * separate decompose_fans() and decompose_strips() call; but for now, we'll + * just say it's good enough. In practice, we don't have any GSG's that can + * support strips without also supporting fans. + */ geom = geom->decompose(); // Decomposing might produce an indexed Geom, so re-check the @@ -261,9 +243,8 @@ premunge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) { unsupported_bits = geom->get_geom_rendering() & ~supported_geom_rendering; } if ((unsupported_bits & Geom::GR_shade_model_bits) != 0) { - // Rotate the vertices to account for different shade-model - // expectations (e.g. SM_flat_last_vertex to - // SM_flat_first_vertex) + // Rotate the vertices to account for different shade-model expectations + // (e.g. SM_flat_last_vertex to SM_flat_first_vertex) geom = geom->rotate(); } if ((unsupported_bits & Geom::GR_indexed_bits) != 0) { @@ -277,14 +258,11 @@ premunge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) { } } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int StandardMunger:: compare_to_impl(const GeomMunger *other) const { const StandardMunger *om = (const StandardMunger *)other; @@ -321,16 +299,12 @@ compare_to_impl(const GeomMunger *other) const { return StateMunger::compare_to_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::geom_compare_to_impl -// Access: Protected, Virtual -// Description: Compares two GeomMungers, considering only whether -// they would produce a different answer to -// munge_format(), munge_data(), or munge_geom(). (They -// still might be different in other ways, but if they -// would produce the same answer, this function consider -// them to be the same.) -//////////////////////////////////////////////////////////////////// +/** + * Compares two GeomMungers, considering only whether they would produce a + * different answer to munge_format(), munge_data(), or munge_geom(). (They + * still might be different in other ways, but if they would produce the same + * answer, this function consider them to be the same.) + */ int StandardMunger:: geom_compare_to_impl(const GeomMunger *other) const { const StandardMunger *om = (const StandardMunger *)other; @@ -360,11 +334,9 @@ geom_compare_to_impl(const GeomMunger *other) const { return StateMunger::geom_compare_to_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: StandardMunger::munge_state_impl -// Access: Protectes, Virtual -// Description: Given an input state, returns the munged state. -//////////////////////////////////////////////////////////////////// +/** + * Given an input state, returns the munged state. + */ CPT(RenderState) StandardMunger:: munge_state_impl(const RenderState *state) { CPT(RenderState) munged_state = state; @@ -389,8 +361,8 @@ munge_state_impl(const RenderState *state) { // Cache the generated ShaderAttrib on the shader state. GeomVertexAnimationSpec spec; - // Currently we overload this flag to request vertex animation - // for the shader generator. + // Currently we overload this flag to request vertex animation for the + // shader generator. const ShaderAttrib *sattr; shader_state->get_attrib_def(sattr); if (sattr->get_flag(ShaderAttrib::F_hardware_skinning)) { diff --git a/panda/src/display/standardMunger.h b/panda/src/display/standardMunger.h index 515a1d1ace..6a6dd9e675 100644 --- a/panda/src/display/standardMunger.h +++ b/panda/src/display/standardMunger.h @@ -1,16 +1,15 @@ -// Filename: standardMunger.h -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standardMunger.h + * @author drose + * @date 2005-03-21 + */ #ifndef STANDARDMUNGER_H #define STANDARDMUNGER_H @@ -24,13 +23,11 @@ #include "pointerTo.h" #include "weakPointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : StandardMunger -// Description : Performs some generic munging that is appropriate for -// all GSG types; for instance, applies ColorAttrib and -// ColorScaleAttrib to the vertices, and checks for -// hardware-accelerated animation capabilities. -//////////////////////////////////////////////////////////////////// +/** + * Performs some generic munging that is appropriate for all GSG types; for + * instance, applies ColorAttrib and ColorScaleAttrib to the vertices, and + * checks for hardware-accelerated animation capabilities. + */ class EXPCL_PANDA_DISPLAY StandardMunger : public StateMunger { public: StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state, @@ -86,4 +83,3 @@ private: #include "standardMunger.I" #endif - diff --git a/panda/src/display/stereoDisplayRegion.I b/panda/src/display/stereoDisplayRegion.I index 323765d9a2..5364f2f563 100644 --- a/panda/src/display/stereoDisplayRegion.I +++ b/panda/src/display/stereoDisplayRegion.I @@ -1,35 +1,27 @@ -// Filename: stereoDisplayRegion.I -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stereoDisplayRegion.I + * @author drose + * @date 2009-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::get_left_eye -// Access: Published -// Description: Returns a pointer to the left DisplayRegion managed -// by this stereo object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the left DisplayRegion managed by this stereo object. + */ INLINE DisplayRegion *StereoDisplayRegion:: get_left_eye() { return _left_eye; } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::get_right_eye -// Access: Published -// Description: Returns a pointer to the right DisplayRegion managed -// by this stereo object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the right DisplayRegion managed by this stereo object. + */ INLINE DisplayRegion *StereoDisplayRegion:: get_right_eye() { return _right_eye; diff --git a/panda/src/display/stereoDisplayRegion.cxx b/panda/src/display/stereoDisplayRegion.cxx index 1c87590b0a..3b3a7cf9f8 100644 --- a/panda/src/display/stereoDisplayRegion.cxx +++ b/panda/src/display/stereoDisplayRegion.cxx @@ -1,27 +1,24 @@ -// Filename: stereoDisplayRegion.cxx -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stereoDisplayRegion.cxx + * @author drose + * @date 2009-02-19 + */ #include "stereoDisplayRegion.h" #include "pandaNode.h" TypeHandle StereoDisplayRegion::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StereoDisplayRegion:: StereoDisplayRegion(GraphicsOutput *window, const LVecBase4 &dimensions, @@ -36,40 +33,33 @@ StereoDisplayRegion(GraphicsOutput *window, set_sort(0); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StereoDisplayRegion:: ~StereoDisplayRegion() { } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_clear_active -// Access: Published, Virtual -// Description: Sets the clear-active flag for any bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Sets the clear-active flag for any bitplane. + */ void StereoDisplayRegion:: set_clear_active(int n, bool clear_active) { - // The clear_active flag gets set only on the parent, stereo display - // region. + // The clear_active flag gets set only on the parent, stereo display region. DisplayRegion::set_clear_active(n, clear_active); - // Except for non-color buffers. These also get set on the - // right display region by default, on the assumption that we want - // to clear these buffers between drawing the eyes, and that the - // right eye is the second of the pair. + // Except for non-color buffers. These also get set on the right display + // region by default, on the assumption that we want to clear these buffers + // between drawing the eyes, and that the right eye is the second of the + // pair. if (n != RTP_color) { _right_eye->set_clear_active(n, clear_active); } } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_clear_value -// Access: Published, Virtual -// Description: Sets the clear value for any bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Sets the clear value for any bitplane. + */ void StereoDisplayRegion:: set_clear_value(int n, const LColor &clear_value) { DisplayRegion::set_clear_value(n, clear_value); @@ -77,12 +67,10 @@ set_clear_value(int n, const LColor &clear_value) { _right_eye->set_clear_value(n, clear_value); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::disable_clears -// Access: Published, Virtual -// Description: Disables both the color and depth clear. See -// set_clear_color_active and set_clear_depth_active. -//////////////////////////////////////////////////////////////////// +/** + * Disables both the color and depth clear. See set_clear_color_active and + * set_clear_depth_active. + */ void StereoDisplayRegion:: disable_clears() { DisplayRegion::disable_clears(); @@ -90,11 +78,9 @@ disable_clears() { _right_eye->disable_clears(); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_pixel_zoom -// Access: Published, Virtual -// Description: Sets the pixel_zoom for left and right eyes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pixel_zoom for left and right eyes. + */ void StereoDisplayRegion:: set_pixel_zoom(PN_stdfloat pixel_zoom) { DisplayRegion::set_pixel_zoom(pixel_zoom); @@ -102,12 +88,9 @@ set_pixel_zoom(PN_stdfloat pixel_zoom) { _right_eye->set_pixel_zoom(pixel_zoom); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_dimensions -// Access: Published, Virtual -// Description: Sets both the left and right DisplayRegions to the -// indicated dimensions. -//////////////////////////////////////////////////////////////////// +/** + * Sets both the left and right DisplayRegions to the indicated dimensions. + */ void StereoDisplayRegion:: set_dimensions(int i, const LVecBase4 &dimensions) { DisplayRegion::set_dimensions(i, dimensions); @@ -115,23 +98,17 @@ set_dimensions(int i, const LVecBase4 &dimensions) { _right_eye->set_dimensions(i, dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::is_stereo -// Access: Published, Virtual -// Description: Returns true if this is a StereoDisplayRegion, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is a StereoDisplayRegion, false otherwise. + */ bool StereoDisplayRegion:: is_stereo() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_camera -// Access: Published, Virtual -// Description: Sets both the left and right DisplayRegions to the -// indicated camera. -//////////////////////////////////////////////////////////////////// +/** + * Sets both the left and right DisplayRegions to the indicated camera. + */ void StereoDisplayRegion:: set_camera(const NodePath &camera) { DisplayRegion::set_camera(camera); @@ -139,32 +116,26 @@ set_camera(const NodePath &camera) { _right_eye->set_camera(camera); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_active -// Access: Published, Virtual -// Description: Sets the active flag on both the left and right -// DisplayRegions to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag on both the left and right DisplayRegions to the + * indicated value. + */ void StereoDisplayRegion:: set_active(bool active) { DisplayRegion::set_active(active); _left_eye->set_active(active); _right_eye->set_active(active); if (active) { - // Reenable the appropriate eyes according to our stereo_channel - // setting. + // Reenable the appropriate eyes according to our stereo_channel setting. set_stereo_channel(get_stereo_channel()); } } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_sort -// Access: Published, Virtual -// Description: Sets the indicated sort value on the overall -// DisplayRegion, the indicated sort value + 1 on the -// left eye, and the indicated sort value + 2 on the -// right eye. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated sort value on the overall DisplayRegion, the indicated + * sort value + 1 on the left eye, and the indicated sort value + 2 on the + * right eye. + */ void StereoDisplayRegion:: set_sort(int sort) { DisplayRegion::set_sort(sort); @@ -172,31 +143,27 @@ set_sort(int sort) { _right_eye->set_sort(sort + 2); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_stereo_channel -// Access: Published, Virtual -// Description: Sets the stereo channels on the left and right eyes, -// and also sets the active flags independently on both -// eyes. For a StereoDisplayRegion, a different action -// is performed for each different value: -// -// SC_stereo - the left eye is set to SC_left, the right -// eye to SC_right, and both eyes are activated. -// -// SC_left - the left eye is set to SC_left and -// activated; the right eye is deactivated. -// -// SC_right - the right eye is set to SC_right and -// activated; the left eye is deactivated. -// -// SC_mono - the left eye is set to SC_mono and -// activated; the right eye is deactivated. -// -// This call also resets tex_view_offset to its default -// value, which is 0 for the left eye or 1 for the right -// eye of a stereo display region, or 0 for a mono -// display region. -//////////////////////////////////////////////////////////////////// +/** + * Sets the stereo channels on the left and right eyes, and also sets the + * active flags independently on both eyes. For a StereoDisplayRegion, a + * different action is performed for each different value: + * + * SC_stereo - the left eye is set to SC_left, the right eye to SC_right, and + * both eyes are activated. + * + * SC_left - the left eye is set to SC_left and activated; the right eye is + * deactivated. + * + * SC_right - the right eye is set to SC_right and activated; the left eye is + * deactivated. + * + * SC_mono - the left eye is set to SC_mono and activated; the right eye is + * deactivated. + * + * This call also resets tex_view_offset to its default value, which is 0 for + * the left eye or 1 for the right eye of a stereo display region, or 0 for a + * mono display region. + */ void StereoDisplayRegion:: set_stereo_channel(Lens::StereoChannel stereo_channel) { DisplayRegion::set_stereo_channel(stereo_channel); @@ -232,19 +199,15 @@ set_stereo_channel(Lens::StereoChannel stereo_channel) { } } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_tex_view_offset -// Access: Published, Virtual -// Description: Sets the current texture view offset for this -// DisplayRegion. This is normally set to zero. If -// nonzero, it is used to select a particular view of -// any multiview textures that are rendered within this -// DisplayRegion. -// -// When you call this on a StereoDisplayRegion, it -// automatically sets the specified value on the left -// eye, and the specified value + 1 on the right eye. -//////////////////////////////////////////////////////////////////// +/** + * Sets the current texture view offset for this DisplayRegion. This is + * normally set to zero. If nonzero, it is used to select a particular view + * of any multiview textures that are rendered within this DisplayRegion. + * + * When you call this on a StereoDisplayRegion, it automatically sets the + * specified value on the left eye, and the specified value + 1 on the right + * eye. + */ void StereoDisplayRegion:: set_tex_view_offset(int tex_view_offset) { DisplayRegion::set_tex_view_offset(tex_view_offset); @@ -252,12 +215,10 @@ set_tex_view_offset(int tex_view_offset) { _right_eye->set_tex_view_offset(tex_view_offset + 1); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_incomplete_render -// Access: Published, Virtual -// Description: Sets the incomplete_render flag on both the left and -// right DisplayRegions to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the incomplete_render flag on both the left and right DisplayRegions + * to the indicated value. + */ void StereoDisplayRegion:: set_incomplete_render(bool incomplete_render) { DisplayRegion::set_incomplete_render(incomplete_render); @@ -265,12 +226,10 @@ set_incomplete_render(bool incomplete_render) { _right_eye->set_incomplete_render(incomplete_render); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_texture_reload_priority -// Access: Published, Virtual -// Description: Sets the texture_reload_priority on both the left and -// right DisplayRegions to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture_reload_priority on both the left and right DisplayRegions + * to the indicated value. + */ void StereoDisplayRegion:: set_texture_reload_priority(int texture_reload_priority) { DisplayRegion::set_texture_reload_priority(texture_reload_priority); @@ -278,12 +237,9 @@ set_texture_reload_priority(int texture_reload_priority) { _right_eye->set_texture_reload_priority(texture_reload_priority); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_cull_traverser -// Access: Published, Virtual -// Description: Sets the CullTraverser for both the left and right -// DisplayRegions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CullTraverser for both the left and right DisplayRegions. + */ void StereoDisplayRegion:: set_cull_traverser(CullTraverser *trav) { DisplayRegion::set_cull_traverser(trav); @@ -291,12 +247,10 @@ set_cull_traverser(CullTraverser *trav) { _right_eye->set_cull_traverser(trav); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::set_target_tex_page -// Access: Published, Virtual -// Description: Sets the page and view on both the left and -// right DisplayRegions to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the page and view on both the left and right DisplayRegions to the + * indicated value. + */ void StereoDisplayRegion:: set_target_tex_page(int page) { DisplayRegion::set_target_tex_page(page); @@ -304,23 +258,18 @@ set_target_tex_page(int page) { _right_eye->set_target_tex_page(page); } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void StereoDisplayRegion:: output(ostream &out) const { out << "StereoDisplayRegion(" << *_left_eye << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: StereoDisplayRegion::make_cull_result_graph -// Access: Published, Virtual -// Description: Returns a special scene graph constructed to -// represent the results of the last frame's cull -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special scene graph constructed to represent the results of the + * last frame's cull operation. + */ PT(PandaNode) StereoDisplayRegion:: make_cull_result_graph() { PT(PandaNode) root = new PandaNode("stereo"); diff --git a/panda/src/display/stereoDisplayRegion.h b/panda/src/display/stereoDisplayRegion.h index e6f3d57197..b1d27bd361 100644 --- a/panda/src/display/stereoDisplayRegion.h +++ b/panda/src/display/stereoDisplayRegion.h @@ -1,16 +1,15 @@ -// Filename: stereoDisplayRegion.h -// Created by: drose (19Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stereoDisplayRegion.h + * @author drose + * @date 2009-02-19 + */ #ifndef STEREODISPLAYREGION_H #define STEREODISPLAYREGION_H @@ -19,21 +18,17 @@ #include "displayRegion.h" -//////////////////////////////////////////////////////////////////// -// Class : StereoDisplayRegion -// Description : This is a special DisplayRegion wrapper that actually -// includes a pair of DisplayRegions internally: the -// left and right eyes. The DisplayRegion represented -// here does not have a physical association with the -// window, but it pretends it does. Instead, it -// maintains a pointer to the left and right -// DisplayRegions separately. -// -// Operations on the StereoDisplayRegion object affect -// both left and right eyes together. To access the -// left or right eyes independently, use get_left_eye() -// and get_right_eye(). -//////////////////////////////////////////////////////////////////// +/** + * This is a special DisplayRegion wrapper that actually includes a pair of + * DisplayRegions internally: the left and right eyes. The DisplayRegion + * represented here does not have a physical association with the window, but + * it pretends it does. Instead, it maintains a pointer to the left and right + * DisplayRegions separately. + * + * Operations on the StereoDisplayRegion object affect both left and right + * eyes together. To access the left or right eyes independently, use + * get_left_eye() and get_right_eye(). + */ class EXPCL_PANDA_DISPLAY StereoDisplayRegion : public DisplayRegion { protected: StereoDisplayRegion(GraphicsOutput *window, diff --git a/panda/src/display/subprocessWindow.I b/panda/src/display/subprocessWindow.I index 940b8845cb..4a2440d495 100644 --- a/panda/src/display/subprocessWindow.I +++ b/panda/src/display/subprocessWindow.I @@ -1,14 +1,12 @@ -// Filename: subprocessWindow.I -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindow.I + * @author drose + * @date 2009-07-11 + */ diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index ee48608370..d001f3b1f6 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -1,16 +1,15 @@ -// Filename: subprocessWindow.cxx -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindow.cxx + * @author drose + * @date 2009-07-11 + */ #include "subprocessWindow.h" @@ -22,13 +21,10 @@ TypeHandle SubprocessWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::Constructor -// Access: Protected -// Description: Normally, the SubprocessWindow constructor is not -// called directly; these are created instead via the -// GraphicsEngine::make_window() function. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the SubprocessWindow constructor is not called directly; these + * are created instead via the GraphicsEngine::make_window() function. + */ SubprocessWindow:: SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -47,8 +43,8 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, // contents. _buffer = NULL; - // Create a texture to receive the contents of the framebuffer from - // the offscreen buffer. + // Create a texture to receive the contents of the framebuffer from the + // offscreen buffer. _texture = new Texture(name); _fd = -1; @@ -58,27 +54,22 @@ SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _last_event_flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SubprocessWindow:: ~SubprocessWindow() { nassertv(_buffer == NULL); nassertv(_swbuffer == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties(). -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties(). + * + * This function is called only within the window thread. + */ void SubprocessWindow:: process_events() { GraphicsWindow::process_events(); @@ -130,15 +121,12 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool SubprocessWindow:: begin_frame(FrameMode mode, Thread *current_thread) { if (_swbuffer == NULL || _buffer == NULL) { @@ -149,13 +137,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void SubprocessWindow:: end_frame(FrameMode mode, Thread *current_thread) { _buffer->end_frame(mode, current_thread); @@ -165,20 +151,17 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void SubprocessWindow:: begin_flip() { nassertv(_buffer != (GraphicsBuffer *)NULL); @@ -190,7 +173,7 @@ begin_flip() { buffer = _gsg->get_render_buffer(_buffer->get_draw_buffer_type(), _buffer->get_fb_properties()); - bool copied = + bool copied = _gsg->framebuffer_copy_to_ram(_texture, 0, -1, _overlay_display_region, buffer); @@ -201,10 +184,10 @@ begin_flip() { if (!_swbuffer->ready_for_write()) { // We have to wait for the other end to remove the last frame we - // rendered. We only wait so long before we give up, so we - // don't completely starve the Python process just because the - // render window is offscreen or something. - + // rendered. We only wait so long before we give up, so we don't + // completely starve the Python process just because the render window + // is offscreen or something. + ClockObject *clock = ClockObject::get_global_clock(); double start = clock->get_real_time(); while (!_swbuffer->ready_for_write()) { @@ -224,25 +207,20 @@ begin_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void SubprocessWindow:: set_properties_now(WindowProperties &properties) { Filename filename; @@ -258,8 +236,8 @@ set_properties_now(WindowProperties &properties) { } if (!filename.empty() && filename != _filename) { - // We're changing the subprocess buffer filename; that means we - // might as well completely close and re-open the window. + // We're changing the subprocess buffer filename; that means we might as + // well completely close and re-open the window. display_cat.info() << "Re-opening SubprocessWindow\n"; internal_close_window(); @@ -284,12 +262,9 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void SubprocessWindow:: close_window() { internal_close_window(); @@ -300,13 +275,10 @@ close_window() { system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool SubprocessWindow:: open_window() { if (!internal_open_window()) { @@ -321,12 +293,10 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::internal_close_window -// Access: Private -// Description: Closes the "window" and resets the buffer, without -// changing the WindowProperties. -//////////////////////////////////////////////////////////////////// +/** + * Closes the "window" and resets the buffer, without changing the + * WindowProperties. + */ void SubprocessWindow:: internal_close_window() { if (_swbuffer != NULL) { @@ -356,12 +326,10 @@ internal_close_window() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::internal_open_window -// Access: Private -// Description: Opens the "window" and the associated offscreen -// buffer, without changing the WindowProperties. -//////////////////////////////////////////////////////////////////// +/** + * Opens the "window" and the associated offscreen buffer, without changing + * the WindowProperties. + */ bool SubprocessWindow:: internal_open_window() { nassertr(_buffer == NULL, false); @@ -371,13 +339,13 @@ internal_open_window() { flags = ((flags & ~GraphicsPipe::BF_require_window) | GraphicsPipe::BF_refuse_window); WindowProperties win_props = WindowProperties::size(_properties.get_x_size(), _properties.get_y_size()); - GraphicsOutput *buffer = - _engine->make_output(_pipe, _name, 0, _fb_properties, win_props, + GraphicsOutput *buffer = + _engine->make_output(_pipe, _name, 0, _fb_properties, win_props, flags, _gsg, _host); if (buffer != NULL) { _buffer = DCAST(GraphicsBuffer, buffer); - // However, the buffer is not itself intended to be rendered. We - // only render it indirectly, via callbacks in here. + // However, the buffer is not itself intended to be rendered. We only + // render it indirectly, via callbacks in here. _buffer->set_active(false); _buffer->request_open(); @@ -443,13 +411,11 @@ internal_open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::translate_key -// Access: Private -// Description: Converts the os-specific keycode into the appropriate -// ButtonHandle object. Also stores the corresponding -// Unicode keycode in keycode, if any; or 0 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Converts the os-specific keycode into the appropriate ButtonHandle object. + * Also stores the corresponding Unicode keycode in keycode, if any; or 0 + * otherwise. + */ ButtonHandle SubprocessWindow:: translate_key(int &keycode, int os_code, unsigned int flags) const { keycode = 0; @@ -508,13 +474,13 @@ translate_key(int &keycode, int os_code, unsigned int flags) const { case 91: nk = KeyboardButton::ascii_key('8'); break; case 92: nk = KeyboardButton::ascii_key('9'); break; - // case 36: nk = KeyboardButton::ret(); break; // no return in panda ??? + // case 36: nk = KeyboardButton::ret(); break; no return in panda ??? case 49: nk = KeyboardButton::space(); break; case 51: nk = KeyboardButton::backspace(); break; case 48: nk = KeyboardButton::tab(); break; case 53: nk = KeyboardButton::escape(); break; - case 76: nk = KeyboardButton::enter(); break; - case 36: nk = KeyboardButton::enter(); break; + case 76: nk = KeyboardButton::enter(); break; + case 36: nk = KeyboardButton::enter(); break; case 123: nk = KeyboardButton::left(); break; case 124: nk = KeyboardButton::right(); break; @@ -524,10 +490,10 @@ translate_key(int &keycode, int os_code, unsigned int flags) const { case 121: nk = KeyboardButton::page_down(); break; case 115: nk = KeyboardButton::home(); break; case 119: nk = KeyboardButton::end(); break; - case 114: nk = KeyboardButton::help(); break; - case 117: nk = KeyboardButton::del(); break; + case 114: nk = KeyboardButton::help(); break; + case 117: nk = KeyboardButton::del(); break; - // case 71: nk = KeyboardButton::num_lock() break; + // case 71: nk = KeyboardButton::num_lock() break; case 122: nk = KeyboardButton::f1(); break; case 120: nk = KeyboardButton::f2(); break; @@ -547,7 +513,7 @@ translate_key(int &keycode, int os_code, unsigned int flags) const { case 113: nk = KeyboardButton::f15(); break; case 106: nk = KeyboardButton::f16(); break; - // shiftable chartablet + // shiftable chartablet case 50: nk = KeyboardButton::ascii_key('`'); break; case 27: nk = KeyboardButton::ascii_key('-'); break; case 24: nk = KeyboardButton::ascii_key('='); break; @@ -562,35 +528,32 @@ translate_key(int &keycode, int os_code, unsigned int flags) const { default: // Punt. - nk = KeyboardButton::ascii_key(os_code & 0xff); + nk = KeyboardButton::ascii_key(os_code & 0xff); } if (nk.has_ascii_equivalent()) { - // If we assigned an ASCII button, then get the original ASCII - // code from the event (it will include shift et al). + // If we assigned an ASCII button, then get the original ASCII code from + // the event (it will include shift et al). - // TODO: is it possible to get any international characters via - // this old EventRecord interface? + // TODO: is it possible to get any international characters via this old + // EventRecord interface? keycode = os_code & 0xff; } - + #endif // __APPLE__ return nk; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindow::transition_button -// Access: Private -// Description: Sends the appropriate up/down transition for the -// indicated modifier key, as determined implicitly from -// the flags. -//////////////////////////////////////////////////////////////////// +/** + * Sends the appropriate up/down transition for the indicated modifier key, as + * determined implicitly from the flags. + */ void SubprocessWindow:: transition_button(unsigned int flags, ButtonHandle button) { if (flags) { _input_devices[0].button_down(button); - } else { + } else { _input_devices[0].button_up(button); } } diff --git a/panda/src/display/subprocessWindow.h b/panda/src/display/subprocessWindow.h index 9e9f519fa5..8065721f42 100644 --- a/panda/src/display/subprocessWindow.h +++ b/panda/src/display/subprocessWindow.h @@ -1,25 +1,24 @@ -// Filename: subprocessWindow.h -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindow.h + * @author drose + * @date 2009-07-11 + */ #ifndef SUBPROCESSWINDOW_H #define SUBPROCESSWINDOW_H #include "pandabase.h" -// For now, a simple trigger whether to enable the subprocess window -// support. We only build it on OSX, because this is (presently) the -// only case where it's useful. +// For now, a simple trigger whether to enable the subprocess window support. +// We only build it on OSX, because this is (presently) the only case where +// it's useful. #ifdef IS_OSX #define SUPPORT_SUBPROCESS_WINDOW 1 #else @@ -34,22 +33,18 @@ #include "subprocessWindowBuffer.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : SubprocessWindow -// Description : This is a special "window" that actually renders to -// an offscreen buffer, copies the pixels to RAM, and -// then ships them to a parent process via shared memory -// for rendering to the window. -// -// This whole nonsense is necessary because OSX doesn't -// allow child processes to draw to, or attach windows -// to, windows created in the parent process. There's a -// rumor that 10.6 fixes this nonsense; this will remain -// to be seen. -//////////////////////////////////////////////////////////////////// +/** + * This is a special "window" that actually renders to an offscreen buffer, + * copies the pixels to RAM, and then ships them to a parent process via + * shared memory for rendering to the window. + * + * This whole nonsense is necessary because OSX doesn't allow child processes + * to draw to, or attach windows to, windows created in the parent process. + * There's a rumor that 10.6 fixes this nonsense; this will remain to be seen. + */ class SubprocessWindow : public GraphicsWindow { public: - SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + SubprocessWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -111,4 +106,3 @@ private: #endif // SUPPORT_SUBPROCESS_WINDOW #endif - diff --git a/panda/src/display/subprocessWindowBuffer.I b/panda/src/display/subprocessWindowBuffer.I index 289f8712df..8a348902ac 100644 --- a/panda/src/display/subprocessWindowBuffer.I +++ b/panda/src/display/subprocessWindowBuffer.I @@ -1,141 +1,111 @@ -// Filename: subprocessWindowBuffer.I -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindowBuffer.I + * @author drose + * @date 2009-07-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::get_x_size -// Access: Public -// Description: Returns the width of the framebuffer in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the framebuffer in pixels. + */ inline int SubprocessWindowBuffer:: get_x_size() const { return _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::get_y_size -// Access: Public -// Description: Returns the height of the framebuffer in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the framebuffer in pixels. + */ inline int SubprocessWindowBuffer:: get_y_size() const { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::get_row_size -// Access: Public -// Description: Returns the length of a row of the framebuffer, in -// bytes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of a row of the framebuffer, in bytes. + */ inline size_t SubprocessWindowBuffer:: get_row_size() const { return _row_size; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::get_framebuffer_size -// Access: Public -// Description: Returns the total number of bytes in the framebuffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes in the framebuffer. + */ inline size_t SubprocessWindowBuffer:: get_framebuffer_size() const { return _framebuffer_size; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::ready_for_read -// Access: Public -// Description: Returns true if the framebuffer data has been updated -// since open_read_framebuffer() was last called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the framebuffer data has been updated since + * open_read_framebuffer() was last called. + */ inline bool SubprocessWindowBuffer:: ready_for_read() const { return (_last_written != _last_read); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::ready_for_write -// Access: Public -// Description: Returns true if the framebuffer data has been read -// since open_write_framebuffer() was last called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the framebuffer data has been read since + * open_write_framebuffer() was last called. + */ inline bool SubprocessWindowBuffer:: ready_for_write() const { return (_last_written == _last_read); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::open_read_framebuffer -// Access: Public -// Description: Returns a read-only pointer to the framebuffer. It -// is only valid to call this if ready_for_read() has -// returned true. -// -// You must call close_read_framebuffer() to indicate -// you have finished reading. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the framebuffer. It is only valid to call + * this if ready_for_read() has returned true. + * + * You must call close_read_framebuffer() to indicate you have finished + * reading. + */ inline const void *SubprocessWindowBuffer:: open_read_framebuffer() { assert(ready_for_read()); return (void *)(this + 1); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::close_read_framebuffer -// Access: Public -// Description: Releases the framebuffer after a previous call to -// open_read_framebuffer(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the framebuffer after a previous call to open_read_framebuffer(). + */ inline void SubprocessWindowBuffer:: close_read_framebuffer() { _last_read = _last_written; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::open_write_framebuffer -// Access: Public -// Description: Returns a writable pointer to the framebuffer. It -// is only valid to call this if ready_for_write() has -// returned true. -// -// You must call close_write_framebuffer() to indicate -// you have finished writing. -//////////////////////////////////////////////////////////////////// +/** + * Returns a writable pointer to the framebuffer. It is only valid to call + * this if ready_for_write() has returned true. + * + * You must call close_write_framebuffer() to indicate you have finished + * writing. + */ inline void *SubprocessWindowBuffer:: open_write_framebuffer() { assert(ready_for_write()); return (void *)(this + 1); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::close_write_framebuffer -// Access: Public -// Description: Releases the framebuffer after a previous call to -// open_write_framebuffer(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the framebuffer after a previous call to open_write_framebuffer(). + */ inline void SubprocessWindowBuffer:: close_write_framebuffer() { ++_last_written; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::add_event -// Access: Public -// Description: Adds a new Event to the queue. Returns false -// if the queue was full. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Event to the queue. Returns false if the queue was full. + */ inline bool SubprocessWindowBuffer:: add_event(const SubprocessWindowBuffer::Event &event) { if (((_event_in + 1) % max_events) == _event_out) { @@ -147,24 +117,19 @@ add_event(const SubprocessWindowBuffer::Event &event) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::has_event -// Access: Public -// Description: Returns true if the queue has at least one -// Event to extract, false if it is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the queue has at least one Event to extract, false if it is + * empty. + */ inline bool SubprocessWindowBuffer:: has_event() const { return (_event_in != _event_out); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::get_event -// Access: Public -// Description: If the queue is nonempty, fills event with the first -// Event on the queue and returns true. If the queue is -// empty, returns false. -//////////////////////////////////////////////////////////////////// +/** + * If the queue is nonempty, fills event with the first Event on the queue and + * returns true. If the queue is empty, returns false. + */ inline bool SubprocessWindowBuffer:: get_event(SubprocessWindowBuffer::Event &event) { if (_event_in == _event_out) { diff --git a/panda/src/display/subprocessWindowBuffer.cxx b/panda/src/display/subprocessWindowBuffer.cxx index fa31624daf..36eec2def3 100644 --- a/panda/src/display/subprocessWindowBuffer.cxx +++ b/panda/src/display/subprocessWindowBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: subprocessWindowBuffer.cxx -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindowBuffer.cxx + * @author drose + * @date 2009-07-11 + */ #include "subprocessWindowBuffer.h" #include @@ -24,25 +23,19 @@ using namespace std; const char SubprocessWindowBuffer:: _magic_number[SubprocessWindowBuffer::magic_number_length] = "pNdaSWB"; -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::operator new -// Access: Private -// Description: Placement operator. Returns addr, a trivial -// pass-through. -//////////////////////////////////////////////////////////////////// +/** + * Placement operator. Returns addr, a trivial pass-through. + */ void *SubprocessWindowBuffer:: operator new(size_t, void *addr) { return addr; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::Constructor -// Access: Private -// Description: This constructor is private; it is not intended to be -// called directly. It is used in make_buffer() to -// create a temporary local object, to determine the -// required mmap_size for a given window size. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is private; it is not intended to be called directly. It + * is used in make_buffer() to create a temporary local object, to determine + * the required mmap_size for a given window size. + */ SubprocessWindowBuffer:: SubprocessWindowBuffer(int x_size, int y_size) { memcpy(_this_magic, _magic_number, magic_number_length); @@ -58,11 +51,9 @@ SubprocessWindowBuffer(int x_size, int y_size) { _mmap_size = sizeof(*this) + _framebuffer_size; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SubprocessWindowBuffer:: SubprocessWindowBuffer(const SubprocessWindowBuffer ©) : _mmap_size(copy._mmap_size), @@ -78,32 +69,26 @@ SubprocessWindowBuffer(const SubprocessWindowBuffer ©) : _last_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::Destructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SubprocessWindowBuffer:: ~SubprocessWindowBuffer() { } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::new_buffer -// Access: Public, Static -// Description: Call this method to create a new buffer in shared -// memory space. Supply the desired size of the window. -// -// This method will create the required shared-memory -// buffer and return a SubprocessWindowBuffer allocated -// within that shared memory, or NULL if there is a -// failure allocating sufficient shared memory. -// -// It also creates a temporary file on disk and returns -// fd, mmap_size, and filename, which the caller must -// retain and eventually pass to destroy_buffer(). The -// filename should be passed to the child process to -// open with open_buffer(). -//////////////////////////////////////////////////////////////////// +/** + * Call this method to create a new buffer in shared memory space. Supply the + * desired size of the window. + * + * This method will create the required shared-memory buffer and return a + * SubprocessWindowBuffer allocated within that shared memory, or NULL if + * there is a failure allocating sufficient shared memory. + * + * It also creates a temporary file on disk and returns fd, mmap_size, and + * filename, which the caller must retain and eventually pass to + * destroy_buffer(). The filename should be passed to the child process to + * open with open_buffer(). + */ SubprocessWindowBuffer *SubprocessWindowBuffer:: new_buffer(int &fd, size_t &mmap_size, string &filename, int x_size, int y_size) { @@ -144,14 +129,11 @@ new_buffer(int &fd, size_t &mmap_size, string &filename, return new(shared_mem) SubprocessWindowBuffer(temp); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::destroy_buffer -// Access: Public, Static -// Description: Destroys a buffer object created via a previous call -// to new_buffer(). This destructs objects within the -// buffer, unmaps the shared memory, and closes the file -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Destroys a buffer object created via a previous call to new_buffer(). This + * destructs objects within the buffer, unmaps the shared memory, and closes + * the file descriptor. + */ void SubprocessWindowBuffer:: destroy_buffer(int fd, size_t mmap_size, const string &filename, SubprocessWindowBuffer *buffer) { @@ -162,21 +144,16 @@ destroy_buffer(int fd, size_t mmap_size, const string &filename, unlink(filename.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::open_buffer -// Access: Public, Static -// Description: Call this method to open a reference to an existing -// buffer in shared memory space. Supply the temporary -// filename returned by new_buffer(), above (presumably -// from the parent process). -// -// This method will mmap the required shared-memory -// buffer and return a SubprocessWindowBuffer allocated -// within that shared memory, or NULL if there is some -// failure. The caller must retain fd, mmap_size, and -// filename and eventually pass all three to -// close_buffer(). -//////////////////////////////////////////////////////////////////// +/** + * Call this method to open a reference to an existing buffer in shared memory + * space. Supply the temporary filename returned by new_buffer(), above + * (presumably from the parent process). + * + * This method will mmap the required shared-memory buffer and return a + * SubprocessWindowBuffer allocated within that shared memory, or NULL if + * there is some failure. The caller must retain fd, mmap_size, and filename + * and eventually pass all three to close_buffer(). + */ SubprocessWindowBuffer *SubprocessWindowBuffer:: open_buffer(int &fd, size_t &mmap_size, const string &filename) { mmap_size = 0; @@ -216,7 +193,7 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { fd = -1; return NULL; } - + mmap_size = temp->_mmap_size; @@ -238,26 +215,22 @@ open_buffer(int &fd, size_t &mmap_size, const string &filename) { return NULL; } - // Now that we've successfully opened and mapped the file, we can - // safely delete it from the file system. + // Now that we've successfully opened and mapped the file, we can safely + // delete it from the file system. - // Actually, unlinking it now prevents us from detaching and - // reattaching to the same file later. Boo. - // unlink(filename.c_str()); + // Actually, unlinking it now prevents us from detaching and reattaching to + // the same file later. Boo. unlink(filename.c_str()); SubprocessWindowBuffer *buffer = (SubprocessWindowBuffer *)shared_mem; assert(buffer->_mmap_size == mmap_size); return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::close_buffer -// Access: Public, Static -// Description: Closes a buffer object created via a previous call -// to open_buffer(). This unmaps the shared memory -// and closes the file descriptor, but does not molest -// the shared buffer itself. -//////////////////////////////////////////////////////////////////// +/** + * Closes a buffer object created via a previous call to open_buffer(). This + * unmaps the shared memory and closes the file descriptor, but does not + * molest the shared buffer itself. + */ void SubprocessWindowBuffer:: close_buffer(int fd, size_t mmap_size, const string &filename, SubprocessWindowBuffer *buffer) { @@ -265,12 +238,9 @@ close_buffer(int fd, size_t mmap_size, const string &filename, close(fd); } -//////////////////////////////////////////////////////////////////// -// Function: SubprocessWindowBuffer::verify_magic_number -// Access: Public -// Description: Returns true if the buffer's magic number matches, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the buffer's magic number matches, false otherwise. + */ bool SubprocessWindowBuffer:: verify_magic_number() const { return (memcmp(_this_magic, _magic_number, magic_number_length) == 0); diff --git a/panda/src/display/subprocessWindowBuffer.h b/panda/src/display/subprocessWindowBuffer.h index eaf8073a7d..2fecbcadbc 100644 --- a/panda/src/display/subprocessWindowBuffer.h +++ b/panda/src/display/subprocessWindowBuffer.h @@ -1,16 +1,15 @@ -// Filename: subprocessWindowBuffer.h -// Created by: drose (11Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subprocessWindowBuffer.h + * @author drose + * @date 2009-07-11 + */ #ifndef SUBPROCESSWINDOWBUFFER_H #define SUBPROCESSWINDOWBUFFER_H @@ -20,25 +19,20 @@ #include using namespace std; -//////////////////////////////////////////////////////////////////// -// Class : SubprocessWindowBuffer -// Description : This is a special class that is designed to faciliate -// SubprocessWindow. It's intended to be allocated -// within a shared memory buffer, and it contains space -// for a framebuffer image to be stored for transferring -// between processes, as well as appropriate -// synchronization primitives. -// -// It's designed to be compiled outside of Panda, so -// that code that doesn't link with Panda (in -// particular, the Panda3D plugin core API) may still -// link with this and use it. -// -// At the moment, and maybe indefinitely, it is only -// compiled on OSX, and only when we are building -// support for the plugin; because it is only needed -// then. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class that is designed to faciliate SubprocessWindow. + * It's intended to be allocated within a shared memory buffer, and it + * contains space for a framebuffer image to be stored for transferring + * between processes, as well as appropriate synchronization primitives. + * + * It's designed to be compiled outside of Panda, so that code that doesn't + * link with Panda (in particular, the Panda3D plugin core API) may still link + * with this and use it. + * + * At the moment, and maybe indefinitely, it is only compiled on OSX, and only + * when we are building support for the plugin; because it is only needed + * then. + */ class SubprocessWindowBuffer { private: void *operator new(size_t, void *addr); @@ -50,7 +44,7 @@ public: static SubprocessWindowBuffer *new_buffer(int &fd, size_t &mmap_size, string &filename, int x_size, int y_size); - static void destroy_buffer(int fd, size_t mmap_size, + static void destroy_buffer(int fd, size_t mmap_size, const string &filename, SubprocessWindowBuffer *buffer); @@ -80,7 +74,7 @@ public: ES_mouse, ES_keyboard }; - + enum EventType { ET_none, ET_button_down, @@ -112,15 +106,15 @@ public: inline bool get_event(Event &event); private: - // The first thing we store in the buffer is a magic number, so we - // don't accidentally memory-map the wrong file and attempt to treat - // it as a window buffer. + // The first thing we store in the buffer is a magic number, so we don't + // accidentally memory-map the wrong file and attempt to treat it as a + // window buffer. enum { magic_number_length = 8 }; static const char _magic_number[magic_number_length]; char _this_magic[magic_number_length]; - // Then we have the required size of the entire structure, including - // its data blocks. + // Then we have the required size of the entire structure, including its + // data blocks. size_t _mmap_size; // Then some other important parameters. @@ -133,11 +127,10 @@ private: int _event_in; // next slot to write an event to int _event_out; // next slot to read an event from Event _events[max_events]; - // The queue is empty when _event_in == _event_out. - // It is full when _event_in == _event_out - 1, circularly. + // The queue is empty when _event_in == _event_out. It is full when + // _event_in == _event_out - 1, circularly. - // These sequence numbers are incremented as frames are written and - // read. + // These sequence numbers are incremented as frames are written and read. int _last_written; int _last_read; diff --git a/panda/src/display/test_display.cxx b/panda/src/display/test_display.cxx index 9f8dd8e2ee..6adfdaf269 100644 --- a/panda/src/display/test_display.cxx +++ b/panda/src/display/test_display.cxx @@ -1,16 +1,15 @@ -// Filename: test_display.cxx -// Created by: shochet (02Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_display.cxx + * @author shochet + * @date 2000-02-02 + */ #include "graphicsWindow.h" diff --git a/panda/src/display/touchInfo.cxx b/panda/src/display/touchInfo.cxx index 9a766c404f..731616142c 100644 --- a/panda/src/display/touchInfo.cxx +++ b/panda/src/display/touchInfo.cxx @@ -1,16 +1,15 @@ -// Filename: touchInfo.cxx -// Created by: Walt Destler (May 25, 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file touchInfo.cxx + * @author Walt Destler + * @date 2010-05-25 + */ #include "touchInfo.h" diff --git a/panda/src/display/touchInfo.h b/panda/src/display/touchInfo.h index b449c4bc50..dff9f82d09 100644 --- a/panda/src/display/touchInfo.h +++ b/panda/src/display/touchInfo.h @@ -1,26 +1,24 @@ -// Filename: touchInfo.h -// Created by: Walt Destler (May 25, 2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file touchInfo.h + * @author Walt Destler + * @date 2010-05-25 + */ #ifndef TOUCHINFO_H #define TOUCHINFO_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : TouchInfo -// Description : Stores information for a single touch event. -//////////////////////////////////////////////////////////////////// +/** + * Stores information for a single touch event. + */ class EXPCL_PANDA_DISPLAY TouchInfo { PUBLISHED: @@ -48,7 +46,7 @@ PUBLISHED: int get_flags(); private: - + int _x; int _y; int _id; diff --git a/panda/src/display/windowHandle.I b/panda/src/display/windowHandle.I index d1035080cc..cd66b117d5 100644 --- a/panda/src/display/windowHandle.I +++ b/panda/src/display/windowHandle.I @@ -1,67 +1,54 @@ -// Filename: windowHandle.I -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowHandle.I + * @author drose + * @date 2009-09-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowHandle:: WindowHandle(OSHandle *os_handle) : _os_handle(os_handle) { } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowHandle:: WindowHandle(const WindowHandle ©) : _os_handle(copy._os_handle) { } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::get_os_handle -// Access: Published -// Description: Returns the OS-specific handle stored internally to -// the WindowHandle wrapper. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle stored internally to the WindowHandle + * wrapper. + */ INLINE WindowHandle::OSHandle *WindowHandle:: get_os_handle() const { return _os_handle; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::set_os_handle -// Access: Published -// Description: Changes the OS-specific handle stored internally to -// the WindowHandle wrapper. -//////////////////////////////////////////////////////////////////// +/** + * Changes the OS-specific handle stored internally to the WindowHandle + * wrapper. + */ INLINE void WindowHandle:: set_os_handle(OSHandle *os_handle) { _os_handle = os_handle; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::OSHandle::Constructor -// Access: Protected -// Description: The base class of OSHandle doesn't have a usable -// constructor. Always construct an instance of some -// specialized type, that stores the appropriate kind of -// window handle for each OS. -//////////////////////////////////////////////////////////////////// +/** + * The base class of OSHandle doesn't have a usable constructor. Always + * construct an instance of some specialized type, that stores the appropriate + * kind of window handle for each OS. + */ INLINE WindowHandle::OSHandle:: OSHandle() { } diff --git a/panda/src/display/windowHandle.cxx b/panda/src/display/windowHandle.cxx index a030a936e5..ecc903595f 100644 --- a/panda/src/display/windowHandle.cxx +++ b/panda/src/display/windowHandle.cxx @@ -1,40 +1,34 @@ -// Filename: windowHandle.cxx -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowHandle.cxx + * @author drose + * @date 2009-09-30 + */ #include "windowHandle.h" TypeHandle WindowHandle::_type_handle; TypeHandle WindowHandle::OSHandle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowHandle:: ~WindowHandle() { } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::send_windows_message -// Access: Published -// Description: Call this method on a parent WindowHandle to deliver -// a Windows message to the current child window, if any. -// This is used in the web plugin system to deliver -// button events detected directly by the browser system -// into Panda, which is particularly necessary on Vista. -//////////////////////////////////////////////////////////////////// +/** + * Call this method on a parent WindowHandle to deliver a Windows message to + * the current child window, if any. This is used in the web plugin system to + * deliver button events detected directly by the browser system into Panda, + * which is particularly necessary on Vista. + */ void WindowHandle:: send_windows_message(unsigned int msg, int wparam, int lparam) { if (_keyboard_window != NULL) { @@ -42,13 +36,10 @@ send_windows_message(unsigned int msg, int wparam, int lparam) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::get_int_handle -// Access: Published -// Description: Returns the OS-specific handle converted to an -// integer, if this is possible for the particular -// representation. Returns 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle converted to an integer, if this is possible + * for the particular representation. Returns 0 if it is not. + */ size_t WindowHandle:: get_int_handle() const { if (_os_handle != NULL) { @@ -57,11 +48,9 @@ get_int_handle() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WindowHandle:: output(ostream &out) const { if (_os_handle == NULL) { @@ -71,22 +60,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::attach_child -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's intention to attach itself. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's intention to attach + * itself. + */ void WindowHandle:: attach_child(WindowHandle *child) { } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::detach_child -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's intention to detach itself. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's intention to detach + * itself. + */ void WindowHandle:: detach_child(WindowHandle *child) { if (_keyboard_window == child) { @@ -94,54 +79,43 @@ detach_child(WindowHandle *child) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::request_keyboard_focus -// Access: Public, Virtual -// Description: Called on a parent handle to indicate a child -// window's wish to receive keyboard button events. -//////////////////////////////////////////////////////////////////// +/** + * Called on a parent handle to indicate a child window's wish to receive + * keyboard button events. + */ void WindowHandle:: request_keyboard_focus(WindowHandle *child) { _keyboard_window = child; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::receive_windows_message -// Access: Public, Virtual -// Description: Called on a child handle to deliver a keyboard button -// event generated in the parent window. -//////////////////////////////////////////////////////////////////// +/** + * Called on a child handle to deliver a keyboard button event generated in + * the parent window. + */ void WindowHandle:: receive_windows_message(unsigned int msg, int wparam, int lparam) { nout << "receive_windows_message(" << msg << ", " << wparam << ", " << lparam << ")\n"; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::OSHandle::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowHandle::OSHandle:: ~OSHandle() { } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::OSHandle::get_int_handle -// Access: Published, Virtual -// Description: Returns the OS-specific handle converted to an -// integer, if this is possible for the particular -// representation. Returns 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OS-specific handle converted to an integer, if this is possible + * for the particular representation. Returns 0 if it is not. + */ size_t WindowHandle::OSHandle:: get_int_handle() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowHandle::OSHandle::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WindowHandle::OSHandle:: output(ostream &out) const { out << "(no type)"; diff --git a/panda/src/display/windowHandle.h b/panda/src/display/windowHandle.h index ef4a64f763..1679e3d95f 100644 --- a/panda/src/display/windowHandle.h +++ b/panda/src/display/windowHandle.h @@ -1,16 +1,15 @@ -// Filename: windowHandle.h -// Created by: drose (30Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowHandle.h + * @author drose + * @date 2009-09-30 + */ #ifndef WINDOWHANDLE_H #define WINDOWHANDLE_H @@ -20,23 +19,18 @@ #include "typedReferenceCount.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : WindowHandle -// Description : This object represents a window on the desktop, not -// necessarily a Panda window. This structure can be -// assigned to a WindowProperties to indicate a parent -// window. -// -// It also has callbacks so the Panda window can -// communicate with its parent window, which is -// particularly important when running embedded in a -// browser. -// -// To create a WindowHandle, you would usually call one -// of the NativeWindowHandle::make_*() methods, -// depending on the kind of native window handle object -// you already have. -//////////////////////////////////////////////////////////////////// +/** + * This object represents a window on the desktop, not necessarily a Panda + * window. This structure can be assigned to a WindowProperties to indicate a + * parent window. + * + * It also has callbacks so the Panda window can communicate with its parent + * window, which is particularly important when running embedded in a browser. + * + * To create a WindowHandle, you would usually call one of the + * NativeWindowHandle::make_*() methods, depending on the kind of native + * window handle object you already have. + */ class EXPCL_PANDA_DISPLAY WindowHandle : public TypedReferenceCount { PUBLISHED: class OSHandle; @@ -64,9 +58,8 @@ public: virtual void receive_windows_message(unsigned int msg, int wparam, int lparam); PUBLISHED: - // This internal pointer within WindowHandle stores the actual - // OS-specific window handle type, whatever type that is. It is - // subclassed for each OS. + // This internal pointer within WindowHandle stores the actual OS-specific + // window handle type, whatever type that is. It is subclassed for each OS. class EXPCL_PANDA_DISPLAY OSHandle : public TypedReferenceCount { protected: INLINE OSHandle(); @@ -89,7 +82,7 @@ PUBLISHED: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/display/windowProperties.I b/panda/src/display/windowProperties.I index 3597adbc55..9179124705 100644 --- a/panda/src/display/windowProperties.I +++ b/panda/src/display/windowProperties.I @@ -1,284 +1,222 @@ -// Filename: windowProperties.I -// Created by: drose (13Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowProperties.I + * @author drose + * @date 2002-08-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowProperties:: WindowProperties(const WindowProperties ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowProperties:: ~WindowProperties() { } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool WindowProperties:: operator != (const WindowProperties &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::is_any_specified -// Access: Published -// Description: Returns true if any properties have been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any properties have been specified, false otherwise. + */ INLINE bool WindowProperties:: is_any_specified() const { return (_specified != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_origin -// Access: Published -// Description: Specifies the origin on the screen (in pixels, -// relative to the top-left corner) at which the window -// should appear. This is the origin of the top-left -// corner of the useful part of the window, not -// including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the origin on the screen (in pixels, relative to the top-left + * corner) at which the window should appear. This is the origin of the top- + * left corner of the useful part of the window, not including decorations. + */ INLINE void WindowProperties:: set_origin(const LPoint2i &origin) { _origin = origin; _specified |= S_origin; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_origin -// Access: Published -// Description: Specifies the origin on the screen (in pixels, -// relative to the top-left corner) at which the window -// should appear. This is the origin of the top-left -// corner of the useful part of the window, not -// including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the origin on the screen (in pixels, relative to the top-left + * corner) at which the window should appear. This is the origin of the top- + * left corner of the useful part of the window, not including decorations. + */ INLINE void WindowProperties:: set_origin(int x_origin, int y_origin) { _origin.set(x_origin, y_origin); _specified |= S_origin; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_origin -// Access: Published -// Description: Returns the coordinates of the window's top-left -// corner, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinates of the window's top-left corner, not including + * decorations. + */ INLINE const LPoint2i &WindowProperties:: get_origin() const { nassertr(has_origin(), LPoint2i::zero()); return _origin; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_x_origin -// Access: Published -// Description: Returns the x coordinate of the window's top-left -// corner, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x coordinate of the window's top-left corner, not including + * decorations. + */ INLINE int WindowProperties:: get_x_origin() const { nassertr(has_origin(), 0); return _origin.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_y_origin -// Access: Published -// Description: Returns the y coordinate of the window's top-left -// corner, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y coordinate of the window's top-left corner, not including + * decorations. + */ INLINE int WindowProperties:: get_y_origin() const { nassertr(has_origin(), 0); return _origin.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_origin -// Access: Published -// Description: Returns true if the window origin has been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window origin has been specified, false otherwise. + */ INLINE bool WindowProperties:: has_origin() const { return ((_specified & S_origin) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_origin -// Access: Published -// Description: Removes the origin specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the origin specification from the properties. + */ INLINE void WindowProperties:: clear_origin() { _specified &= ~S_origin; _origin = LPoint2i::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_size -// Access: Published -// Description: Specifies the requested size of the window, in -// pixels. This is the size of the useful part of the -// window, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the requested size of the window, in pixels. This is the size of + * the useful part of the window, not including decorations. + */ INLINE void WindowProperties:: set_size(const LVector2i &size) { _size = size; _specified |= S_size; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_size -// Access: Published -// Description: Specifies the requested size of the window, in -// pixels. This is the size of the useful part of the -// window, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the requested size of the window, in pixels. This is the size of + * the useful part of the window, not including decorations. + */ INLINE void WindowProperties:: set_size(int x_size, int y_size) { _size.set(x_size, y_size); _specified |= S_size; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_origin -// Access: Published -// Description: Returns size in pixels of the useful part of the -// window, not including decorations. -//////////////////////////////////////////////////////////////////// +/** + * Returns size in pixels of the useful part of the window, not including + * decorations. + */ INLINE const LVector2i &WindowProperties:: get_size() const { nassertr(has_size(), LVector2i::zero()); return _size; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_x_size -// Access: Published -// Description: Returns size in pixels in the x dimension of the -// useful part of the window, not including decorations. -// That is, this is the window's width. -//////////////////////////////////////////////////////////////////// +/** + * Returns size in pixels in the x dimension of the useful part of the window, + * not including decorations. That is, this is the window's width. + */ INLINE int WindowProperties:: get_x_size() const { nassertr(has_size(), 0); return _size.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_y_size -// Access: Published -// Description: Returns size in pixels in the y dimension of the -// useful part of the window, not including decorations. -// That is, this is the window's height. -//////////////////////////////////////////////////////////////////// +/** + * Returns size in pixels in the y dimension of the useful part of the window, + * not including decorations. That is, this is the window's height. + */ INLINE int WindowProperties:: get_y_size() const { nassertr(has_size(), 0); return _size.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_size -// Access: Published -// Description: Returns true if the window size has been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window size has been specified, false otherwise. + */ INLINE bool WindowProperties:: has_size() const { return ((_specified & S_size) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_size -// Access: Published -// Description: Removes the size specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the size specification from the properties. + */ INLINE void WindowProperties:: clear_size() { _specified &= ~S_size; _size = LVector2i::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_title -// Access: Published -// Description: Specifies the title that should be assigned to the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the title that should be assigned to the window. + */ INLINE void WindowProperties:: set_title(const string &title) { _title = title; _specified |= S_title; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_title -// Access: Published -// Description: Returns the window's title. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window's title. + */ INLINE const string &WindowProperties:: get_title() const { nassertr(has_title(), _title); return _title; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_title -// Access: Published -// Description: Returns true if the window title has been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window title has been specified, false otherwise. + */ INLINE bool WindowProperties:: has_title() const { return ((_specified & S_title) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_title -// Access: Published -// Description: Removes the title specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the title specification from the properties. + */ INLINE void WindowProperties:: clear_title() { _specified &= ~S_title; _title = string(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_undecorated -// Access: Published -// Description: Specifies whether the window should be created with a -// visible title and border (false, the default) or not -// (true). -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be created with a visible title and + * border (false, the default) or not (true). + */ INLINE void WindowProperties:: set_undecorated(bool undecorated) { if (undecorated) { @@ -289,43 +227,34 @@ set_undecorated(bool undecorated) { _specified |= S_undecorated; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_undecorated -// Access: Published -// Description: Returns true if the window has no border. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window has no border. + */ INLINE bool WindowProperties:: get_undecorated() const { return (_flags & F_undecorated) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_undecorated -// Access: Published -// Description: Returns true if set_undecorated() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_undecorated() has been specified. + */ INLINE bool WindowProperties:: has_undecorated() const { return ((_specified & S_undecorated) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_undecorated -// Access: Published -// Description: Removes the undecorated specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the undecorated specification from the properties. + */ INLINE void WindowProperties:: clear_undecorated() { _specified &= ~S_undecorated; _flags &= ~F_undecorated; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_fixed_size -// Access: Published -// Description: Specifies whether the window should be resizable by -// the user. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be resizable by the user. + */ INLINE void WindowProperties:: set_fixed_size(bool fixed_size) { if (fixed_size) { @@ -336,45 +265,35 @@ set_fixed_size(bool fixed_size) { _specified |= S_fixed_size; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_fixed_size -// Access: Published -// Description: Returns true if the window cannot be resized by the -// user, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window cannot be resized by the user, false otherwise. + */ INLINE bool WindowProperties:: get_fixed_size() const { return (_flags & F_fixed_size) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_fixed_size -// Access: Published -// Description: Returns true if set_fixed_size() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_fixed_size() has been specified. + */ INLINE bool WindowProperties:: has_fixed_size() const { return ((_specified & S_fixed_size) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_fixed_size -// Access: Published -// Description: Removes the fixed_size specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the fixed_size specification from the properties. + */ INLINE void WindowProperties:: clear_fixed_size() { _specified &= ~S_fixed_size; _flags &= ~F_fixed_size; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_fullscreen -// Access: Published -// Description: Specifies whether the window should be opened in -// fullscreen mode (true) or normal windowed mode -// (false, the default). -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be opened in fullscreen mode (true) or + * normal windowed mode (false, the default). + */ INLINE void WindowProperties:: set_fullscreen(bool fullscreen) { if (fullscreen) { @@ -385,44 +304,35 @@ set_fullscreen(bool fullscreen) { _specified |= S_fullscreen; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_fullscreen -// Access: Published -// Description: Returns true if the window is in fullscreen mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is in fullscreen mode. + */ INLINE bool WindowProperties:: get_fullscreen() const { return (_flags & F_fullscreen) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_fullscreen -// Access: Published -// Description: Returns true if set_fullscreen() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_fullscreen() has been specified. + */ INLINE bool WindowProperties:: has_fullscreen() const { return ((_specified & S_fullscreen) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_fullscreen -// Access: Published -// Description: Removes the fullscreen specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the fullscreen specification from the properties. + */ INLINE void WindowProperties:: clear_fullscreen() { _specified &= ~S_fullscreen; _flags &= ~F_fullscreen; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_foreground -// Access: Published -// Description: Specifies whether the window should be opened in -// the foreground (true), or left in the background -// (false). -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be opened in the foreground (true), or + * left in the background (false). + */ INLINE void WindowProperties:: set_foreground(bool foreground) { if (foreground) { @@ -433,43 +343,35 @@ set_foreground(bool foreground) { _specified |= S_foreground; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_foreground -// Access: Published -// Description: Returns true if the window is in the foreground. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is in the foreground. + */ INLINE bool WindowProperties:: get_foreground() const { return (_flags & F_foreground) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_foreground -// Access: Published -// Description: Returns true if set_foreground() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_foreground() has been specified. + */ INLINE bool WindowProperties:: has_foreground() const { return ((_specified & S_foreground) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_foreground -// Access: Published -// Description: Removes the foreground specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the foreground specification from the properties. + */ INLINE void WindowProperties:: clear_foreground() { _specified &= ~S_foreground; _flags &= ~F_foreground; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_minimized -// Access: Published -// Description: Specifies whether the window should be created -// minimized (true), or normal (false). -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be created minimized (true), or normal + * (false). + */ INLINE void WindowProperties:: set_minimized(bool minimized) { if (minimized) { @@ -480,43 +382,34 @@ set_minimized(bool minimized) { _specified |= S_minimized; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_minimized -// Access: Published -// Description: Returns true if the window is minimized. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is minimized. + */ INLINE bool WindowProperties:: get_minimized() const { return (_flags & F_minimized) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_minimized -// Access: Published -// Description: Returns true if set_minimized() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_minimized() has been specified. + */ INLINE bool WindowProperties:: has_minimized() const { return ((_specified & S_minimized) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_minimized -// Access: Published -// Description: Removes the minimized specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the minimized specification from the properties. + */ INLINE void WindowProperties:: clear_minimized() { _specified &= ~S_minimized; _flags &= ~F_minimized; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_raw_mice -// Access: Published -// Description: Specifies whether the window should read the raw -// mouse devices. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should read the raw mouse devices. + */ INLINE void WindowProperties:: set_raw_mice(bool raw_mice) { if (raw_mice) { @@ -527,44 +420,36 @@ set_raw_mice(bool raw_mice) { _specified |= S_raw_mice; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_raw_mice -// Access: Published -// Description: Returns true if the window reads the raw mice. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window reads the raw mice. + */ INLINE bool WindowProperties:: get_raw_mice() const { return (_flags & F_raw_mice) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_raw_mice -// Access: Published -// Description: Returns true if set_raw_mice() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_raw_mice() has been specified. + */ INLINE bool WindowProperties:: has_raw_mice() const { return ((_specified & S_raw_mice) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_raw_mice -// Access: Published -// Description: Removes the raw_mice specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the raw_mice specification from the properties. + */ INLINE void WindowProperties:: clear_raw_mice() { _specified &= ~S_raw_mice; _flags &= ~F_raw_mice; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_open -// Access: Published -// Description: Specifies whether the window should be open. It is -// legal to create a GraphicsWindow in the closed state, -// and later request it to open by changing this flag. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the window should be open. It is legal to create a + * GraphicsWindow in the closed state, and later request it to open by + * changing this flag. + */ INLINE void WindowProperties:: set_open(bool open) { if (open) { @@ -575,42 +460,34 @@ set_open(bool open) { _specified |= S_open; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_open -// Access: Published -// Description: Returns true if the window is open. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window is open. + */ INLINE bool WindowProperties:: get_open() const { return (_flags & F_open) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_open -// Access: Published -// Description: Returns true if set_open() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_open() has been specified. + */ INLINE bool WindowProperties:: has_open() const { return ((_specified & S_open) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_open -// Access: Published -// Description: Removes the open specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the open specification from the properties. + */ INLINE void WindowProperties:: clear_open() { _specified &= ~S_open; _flags &= ~F_open; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_cursor_hidden -// Access: Published -// Description: Specifies whether the mouse cursor should be visible. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the mouse cursor should be visible. + */ INLINE void WindowProperties:: set_cursor_hidden(bool cursor_hidden) { if (cursor_hidden) { @@ -621,43 +498,35 @@ set_cursor_hidden(bool cursor_hidden) { _specified |= S_cursor_hidden; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_cursor_hidden -// Access: Published -// Description: Returns true if the mouse cursor is invisible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse cursor is invisible. + */ INLINE bool WindowProperties:: get_cursor_hidden() const { return (_flags & F_cursor_hidden) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_cursor_hidden -// Access: Published -// Description: Returns true if set_cursor_hidden() has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_cursor_hidden() has been specified. + */ INLINE bool WindowProperties:: has_cursor_hidden() const { return ((_specified & S_cursor_hidden) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_cursor_hidden -// Access: Published -// Description: Removes the cursor_hidden specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the cursor_hidden specification from the properties. + */ INLINE void WindowProperties:: clear_cursor_hidden() { _specified &= ~S_cursor_hidden; _flags &= ~F_cursor_hidden; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_icon_filename -// Access: Published -// Description: Specifies the file that contains the icon to -// associate with the window when it is minimized. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the file that contains the icon to associate with the window when + * it is minimized. + */ INLINE void WindowProperties:: set_icon_filename(const Filename &icon_filename) { _icon_filename = icon_filename; @@ -665,128 +534,98 @@ set_icon_filename(const Filename &icon_filename) { } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_icon_filename -// Access: Published -// Description: Returns the icon filename associated with the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the icon filename associated with the window. + */ INLINE const Filename &WindowProperties:: get_icon_filename() const { return _icon_filename; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_icon_filename -// Access: Published -// Description: Returns true if set_icon_filename() has been -// specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_icon_filename() has been specified. + */ INLINE bool WindowProperties:: has_icon_filename() const { return ((_specified & S_icon_filename) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_icon_filename -// Access: Published -// Description: Removes the icon_filename specification from the -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the icon_filename specification from the properties. + */ INLINE void WindowProperties:: clear_icon_filename() { _specified &= ~S_icon_filename; _icon_filename = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_cursor_filename -// Access: Published -// Description: Specifies the file that contains the icon to -// associate with the mouse cursor when it is within the -// window (and visible). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the file that contains the icon to associate with the mouse + * cursor when it is within the window (and visible). + */ INLINE void WindowProperties:: set_cursor_filename(const Filename &cursor_filename) { _cursor_filename = cursor_filename; _specified |= S_cursor_filename; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_cursor_filename -// Access: Published -// Description: Returns the icon filename associated with the mouse -// cursor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the icon filename associated with the mouse cursor. + */ INLINE const Filename &WindowProperties:: get_cursor_filename() const { return _cursor_filename; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_cursor_filename -// Access: Published -// Description: Returns true if set_cursor_filename() has been -// specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_cursor_filename() has been specified. + */ INLINE bool WindowProperties:: has_cursor_filename() const { return ((_specified & S_cursor_filename) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_cursor_filename -// Access: Published -// Description: Removes the cursor_filename specification from the -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the cursor_filename specification from the properties. + */ INLINE void WindowProperties:: clear_cursor_filename() { _specified &= ~S_cursor_filename; _cursor_filename = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_z_order -// Access: Published -// Description: Specifies the relative ordering of the window with -// respect to other windows. If the z_order is Z_top, -// the window will always be on top of other windows; if -// it is Z_bottom, it will always be below other -// windows. Most windows will want to be Z_normal, -// which allows the user to control the order. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the relative ordering of the window with respect to other + * windows. If the z_order is Z_top, the window will always be on top of + * other windows; if it is Z_bottom, it will always be below other windows. + * Most windows will want to be Z_normal, which allows the user to control the + * order. + */ INLINE void WindowProperties:: set_z_order(WindowProperties::ZOrder z_order) { _z_order = z_order; _specified |= S_z_order; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_z_order -// Access: Published -// Description: Returns the window's z_order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window's z_order. + */ INLINE WindowProperties::ZOrder WindowProperties:: get_z_order() const { return _z_order; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_z_order -// Access: Published -// Description: Returns true if the window z_order has been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the window z_order has been specified, false otherwise. + */ INLINE bool WindowProperties:: has_z_order() const { return ((_specified & S_z_order) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_z_order -// Access: Published -// Description: Removes the z_order specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the z_order specification from the properties. + */ INLINE void WindowProperties:: clear_z_order() { _specified &= ~S_z_order; @@ -794,122 +633,96 @@ clear_z_order() { } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_mouse_mode -// Access: Published -// Description: Specifies the mode in which the window is to operate -// its mouse pointer. -// -// M_absolute: the normal mode in which a mouse pointer -// operates, where the mouse can move outside the window -// and the mouse coordinates are relative to its -// position in the window. -// -// M_relative (OSX or Unix/X11 only): a mode where only -// relative movements are reported; particularly useful -// for FPS-style mouse movements where you have hidden -// the mouse pointer and are are more interested in how -// fast the mouse is moving, rather than precisely where -// the pointer is hovering. -// -// This has no effect on Windows. On Unix/X11, this -// requires the Xxf86dga extension to be available. -// -// M_confined: this mode reports absolute mouse -// positions, but confines the mouse pointer to -// the window boundary. It can portably replace -// M_relative for an FPS, but you need to periodically -// move the pointer to the center of the window -// and track movement deltas. -// -//////////////////////////////////////////////////////////////////// +/** + * Specifies the mode in which the window is to operate its mouse pointer. + * + * M_absolute: the normal mode in which a mouse pointer operates, where the + * mouse can move outside the window and the mouse coordinates are relative to + * its position in the window. + * + * M_relative (OSX or Unix/X11 only): a mode where only relative movements are + * reported; particularly useful for FPS-style mouse movements where you have + * hidden the mouse pointer and are are more interested in how fast the mouse + * is moving, rather than precisely where the pointer is hovering. + * + * This has no effect on Windows. On Unix/X11, this requires the Xxf86dga + * extension to be available. + * + * M_confined: this mode reports absolute mouse positions, but confines the + * mouse pointer to the window boundary. It can portably replace M_relative + * for an FPS, but you need to periodically move the pointer to the center of + * the window and track movement deltas. + * + */ INLINE void WindowProperties:: set_mouse_mode(MouseMode mode) { _mouse_mode=mode; _specified |= S_mouse_mode; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_mouse_mode -// Access: Published -// Description: See set_mouse_mode(). -//////////////////////////////////////////////////////////////////// +/** + * See set_mouse_mode(). + */ INLINE WindowProperties::MouseMode WindowProperties:: get_mouse_mode() const { return _mouse_mode; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_mouse_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool WindowProperties:: has_mouse_mode() const { return ((_specified & S_mouse_mode)!=0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_mouse_mode -// Access: Published -// Description: Removes the mouse_mode specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the mouse_mode specification from the properties. + */ INLINE void WindowProperties:: clear_mouse_mode() { _specified &= ~S_mouse_mode; _mouse_mode = M_absolute; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_parent_window -// Access: Published -// Description: Specifies the window that this window should be -// attached to. If this is NULL or unspecified, the -// window will be created as a toplevel window on the -// desktop; if this is non-NULL, the window will be -// bound as a child window to the indicated parent -// window. -// -// You should use GraphicsPipe::make_window_handle() to -// create an instance of a WindowHandle object given an -// appropriate OS-specific window handle representation. -// Each OS-specific GraphicsPipe class defines a -// make_window_handle() method that returns an -// appropriate WindowHandle object to wrap the -// particular OS-specific representation. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the window that this window should be attached to. If this is + * NULL or unspecified, the window will be created as a toplevel window on the + * desktop; if this is non-NULL, the window will be bound as a child window to + * the indicated parent window. + * + * You should use GraphicsPipe::make_window_handle() to create an instance of + * a WindowHandle object given an appropriate OS-specific window handle + * representation. Each OS-specific GraphicsPipe class defines a + * make_window_handle() method that returns an appropriate WindowHandle object + * to wrap the particular OS-specific representation. + */ INLINE void WindowProperties:: set_parent_window(WindowHandle *parent_window) { _parent_window = parent_window; _specified |= S_parent_window; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_parent_window -// Access: Published -// Description: Returns the parent window specification, or NULL if -// there is no parent window specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent window specification, or NULL if there is no parent + * window specified. + */ INLINE WindowHandle *WindowProperties:: get_parent_window() const { return _parent_window; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::has_parent_window -// Access: Published -// Description: Checks the S_parent_window specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Checks the S_parent_window specification from the properties. + */ INLINE bool WindowProperties:: has_parent_window() const { return ((_specified & S_parent_window)!=0); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_parent_window -// Access: Published -// Description: Removes the S_parent_window specification from the properties. -//////////////////////////////////////////////////////////////////// +/** + * Removes the S_parent_window specification from the properties. + */ INLINE void WindowProperties:: clear_parent_window() { _specified &= ~S_parent_window; @@ -922,5 +735,3 @@ operator << (ostream &out, const WindowProperties &properties) { properties.output(out); return out; } - - diff --git a/panda/src/display/windowProperties.cxx b/panda/src/display/windowProperties.cxx index 8e4178526f..c0af101b41 100644 --- a/panda/src/display/windowProperties.cxx +++ b/panda/src/display/windowProperties.cxx @@ -1,16 +1,15 @@ -// Filename: windowProperties.cxx -// Created by: drose (13Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowProperties.cxx + * @author drose + * @date 2002-08-13 + */ #include "windowProperties.h" #include "config_display.h" @@ -18,21 +17,17 @@ WindowProperties *WindowProperties::_default_properties = NULL; -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowProperties:: WindowProperties() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WindowProperties:: operator = (const WindowProperties ©) { _specified = copy._specified; @@ -47,13 +42,10 @@ operator = (const WindowProperties ©) { _parent_window = copy._parent_window; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_config_properties -// Access: Published, Static -// Description: Returns a WindowProperties structure with all of the -// default values filled in according to the user's -// config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns a WindowProperties structure with all of the default values filled + * in according to the user's config file. + */ WindowProperties WindowProperties:: get_config_properties() { WindowProperties props; @@ -94,14 +86,11 @@ get_config_properties() { return props; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::get_default -// Access: Published, Static -// Description: Returns the "default" WindowProperties. If -// set_default() has been called, this returns that -// WindowProperties structure; otherwise, this returns -// get_config_properties(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "default" WindowProperties. If set_default() has been called, + * this returns that WindowProperties structure; otherwise, this returns + * get_config_properties(). + */ WindowProperties WindowProperties:: get_default() { if (_default_properties != NULL) { @@ -111,17 +100,14 @@ get_default() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_default -// Access: Published, Static -// Description: Replaces the "default" WindowProperties with the -// specified structure. The specified WindowProperties -// will be returned by future calls to get_default(), -// until clear_default() is called. -// -// Note that this completely replaces the default -// properties; it is not additive. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the "default" WindowProperties with the specified structure. The + * specified WindowProperties will be returned by future calls to + * get_default(), until clear_default() is called. + * + * Note that this completely replaces the default properties; it is not + * additive. + */ void WindowProperties:: set_default(const WindowProperties &default_properties) { if (_default_properties == NULL) { @@ -130,12 +116,10 @@ set_default(const WindowProperties &default_properties) { (*_default_properties) = default_properties; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear_default -// Access: Published, Static -// Description: Returns the "default" WindowProperties to whatever -// is specified in the user's config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "default" WindowProperties to whatever is specified in the + * user's config file. + */ void WindowProperties:: clear_default() { if (_default_properties != NULL) { @@ -144,13 +128,10 @@ clear_default() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::size -// Access: Published, Static -// Description: Returns a WindowProperties structure with only the -// size specified. The size is the only property that -// matters to buffers. -//////////////////////////////////////////////////////////////////// +/** + * Returns a WindowProperties structure with only the size specified. The + * size is the only property that matters to buffers. + */ WindowProperties WindowProperties:: size(int x_size, int y_size) { WindowProperties props; @@ -158,11 +139,9 @@ size(int x_size, int y_size) { return props; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool WindowProperties:: operator == (const WindowProperties &other) const { return (_specified == other._specified && @@ -177,13 +156,10 @@ operator == (const WindowProperties &other) const { _parent_window == other._parent_window); } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::clear -// Access: Published -// Description: Unsets all properties that have been specified so -// far, and resets the WindowProperties structure to its -// initial empty state. -//////////////////////////////////////////////////////////////////// +/** + * Unsets all properties that have been specified so far, and resets the + * WindowProperties structure to its initial empty state. + */ void WindowProperties:: clear() { _specified = 0; @@ -198,26 +174,20 @@ clear() { _parent_window = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::set_parent_window -// Access: Published -// Description: Specifies the window that this window should be -// attached to. -// -// This is a deprecated variant on this method, and -// exists only for backward compatibility. Future code -// should use the version of set_parent_window() below -// that receives a WindowHandle object; that interface -// is much more robust. -// -// In this deprecated variant, the actual value for -// "parent" is platform-specific. On Windows, it is the -// HWND of the parent window, cast to an unsigned -// integer. On X11, it is the Window pointer of the -// parent window, similarly cast. On OSX, this is the -// NSWindow pointer, which doesn't appear to work at -// all. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the window that this window should be attached to. + * + * This is a deprecated variant on this method, and exists only for backward + * compatibility. Future code should use the version of set_parent_window() + * below that receives a WindowHandle object; that interface is much more + * robust. + * + * In this deprecated variant, the actual value for "parent" is platform- + * specific. On Windows, it is the HWND of the parent window, cast to an + * unsigned integer. On X11, it is the Window pointer of the parent window, + * similarly cast. On OSX, this is the NSWindow pointer, which doesn't appear + * to work at all. + */ void WindowProperties:: set_parent_window(size_t parent) { if (parent == 0) { @@ -228,13 +198,10 @@ set_parent_window(size_t parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::add_properties -// Access: Published -// Description: Sets any properties that are explicitly specified in -// other on this object. Leaves other properties -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Sets any properties that are explicitly specified in other on this object. + * Leaves other properties unchanged. + */ void WindowProperties:: add_properties(const WindowProperties &other) { if (other.has_origin()) { @@ -287,13 +254,10 @@ add_properties(const WindowProperties &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowProperties::output -// Access: Published -// Description: Sets any properties that are explicitly specified in -// other on this object. Leaves other properties -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Sets any properties that are explicitly specified in other on this object. + * Leaves other properties unchanged. + */ void WindowProperties:: output(ostream &out) const { if (has_origin()) { @@ -389,9 +353,7 @@ operator >> (istream &in, WindowProperties::ZOrder &z_order) { return in; } -// // MouseMode operators -// ostream & operator << (ostream &out, WindowProperties::MouseMode mode) { diff --git a/panda/src/display/windowProperties.h b/panda/src/display/windowProperties.h index 16dd0d1dcd..efb58255b6 100644 --- a/panda/src/display/windowProperties.h +++ b/panda/src/display/windowProperties.h @@ -1,16 +1,15 @@ -// Filename: windowProperties.h -// Created by: drose (13Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowProperties.h + * @author drose + * @date 2002-08-13 + */ #ifndef WINDOWPROPERTIES_H #define WINDOWPROPERTIES_H @@ -22,13 +21,11 @@ #include "lpoint2.h" #include "lvector2.h" -//////////////////////////////////////////////////////////////////// -// Class : WindowProperties -// Description : A container for the various kinds of properties we -// might ask to have on a graphics window before we open -// it. This also serves to hold the current properties -// for a window after it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * A container for the various kinds of properties we might ask to have on a + * graphics window before we open it. This also serves to hold the current + * properties for a window after it has been opened. + */ class EXPCL_PANDA_DISPLAY WindowProperties { PUBLISHED: enum ZOrder { @@ -36,7 +33,7 @@ PUBLISHED: Z_normal, Z_top, }; - + enum MouseMode { M_absolute, M_relative, @@ -179,8 +176,7 @@ PUBLISHED: private: // This bitmask indicates which of the parameters in the properties - // structure have been filled in by the user, and which remain - // unspecified. + // structure have been filled in by the user, and which remain unspecified. enum Specified { S_origin = 0x00001, S_size = 0x00002, @@ -200,9 +196,8 @@ private: S_raw_mice = 0x08000, }; - // This bitmask represents the true/false settings for various - // boolean flags (assuming the corresponding S_* bit has been set, - // above). + // This bitmask represents the truefalse settings for various boolean flags + // (assuming the corresponding S_* bit has been set, above). enum Flags { F_undecorated = S_undecorated, F_fullscreen = S_fullscreen, diff --git a/panda/src/distort/config_distort.cxx b/panda/src/distort/config_distort.cxx index 3eb3060960..7dc7055c3c 100644 --- a/panda/src/distort/config_distort.cxx +++ b/panda/src/distort/config_distort.cxx @@ -1,16 +1,15 @@ -// Filename: config_distort.cxx -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_distort.cxx + * @author drose + * @date 2001-12-11 + */ #include "config_distort.h" #include "cylindricalLens.h" @@ -37,14 +36,12 @@ ConfigVariableBool project_invert_uvs "these graphics drivers. If it fails to do this, you should " "probably set copy-texture-inverted instead, which is more general.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libdistort -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdistort() { static bool initialized = false; diff --git a/panda/src/distort/config_distort.h b/panda/src/distort/config_distort.h index 06e47201a1..4881e0f143 100644 --- a/panda/src/distort/config_distort.h +++ b/panda/src/distort/config_distort.h @@ -1,16 +1,15 @@ -// Filename: config_distort.h -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_distort.h + * @author drose + * @date 2001-12-11 + */ #ifndef CONFIG_DISTORT_H #define CONFIG_DISTORT_H diff --git a/panda/src/distort/cylindricalLens.I b/panda/src/distort/cylindricalLens.I index 1a7c7591cb..b4716a5a3e 100644 --- a/panda/src/distort/cylindricalLens.I +++ b/panda/src/distort/cylindricalLens.I @@ -1,42 +1,34 @@ -// Filename: cylindricalLens.I -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cylindricalLens.I + * @author drose + * @date 2001-12-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CylindricalLens:: CylindricalLens() { } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CylindricalLens:: CylindricalLens(const CylindricalLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CylindricalLens:: operator = (const CylindricalLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/distort/cylindricalLens.cxx b/panda/src/distort/cylindricalLens.cxx index 53f2fb432c..0926ee5cfd 100644 --- a/panda/src/distort/cylindricalLens.cxx +++ b/panda/src/distort/cylindricalLens.cxx @@ -1,60 +1,50 @@ -// Filename: cylindricalLens.cxx -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cylindricalLens.cxx + * @author drose + * @date 2001-12-12 + */ #include "cylindricalLens.h" #include "deg_2_rad.h" TypeHandle CylindricalLens::_type_handle; -// This is the focal-length constant for fisheye lenses. See -// fisheyeLens.cxx. +// This is the focal-length constant for fisheye lenses. See fisheyeLens.cxx. static const PN_stdfloat cylindrical_k = 60.0f; -// focal_length = film_size * cylindrical_k / fov; +// focal_length = film_size * cylindrical_k fov; -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) CylindricalLens:: make_copy() const { return new CylindricalLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::do_extrude -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool CylindricalLens:: -do_extrude(const Lens::CData *lens_cdata, +do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { - // Undo the shifting from film offsets, etc. This puts the point - // into the range [-film_size/2, film_size/2] in x and y. + // Undo the shifting from film offsets, etc. This puts the point into the + // range [-film_size2, film_size2] in x and y. LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata); PN_stdfloat focal_length = do_get_focal_length(lens_cdata); @@ -62,12 +52,12 @@ do_extrude(const Lens::CData *lens_cdata, PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); - // Define a unit vector (well, a unit vector in the XY plane, at - // least) that represents the vector corresponding to this point. + // Define a unit vector (well, a unit vector in the XY plane, at least) that + // represents the vector corresponding to this point. LPoint3 v(sinAngle, cosAngle, f[1] / focal_length); - // And we'll need to account for the lens's rotations, etc. at the - // end of the day. + // And we'll need to account for the lens's rotations, etc. at the end of + // the day. const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata); const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata); @@ -76,30 +66,24 @@ do_extrude(const Lens::CData *lens_cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::do_extrude_vec -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the vector that corresponds to the view -// direction. This will be parallel to the normal on -// the surface (the far plane) corresponding to the lens -// shape at this point. -// -// See the comment block on Lens::extrude_vec_impl() for -// a more in-depth comment on the meaning of this -// vector. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * vector that corresponds to the view direction. This will be parallel to + * the normal on the surface (the far plane) corresponding to the lens shape + * at this point. + * + * See the comment block on Lens::extrude_vec_impl() for a more in-depth + * comment on the meaning of this vector. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool CylindricalLens:: do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &vec) const { - // Undo the shifting from film offsets, etc. This puts the point - // into the range [-film_size/2, film_size/2] in x and y. + // Undo the shifting from film offsets, etc. This puts the point into the + // range [-film_size2, film_size2] in x and y. LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata); PN_stdfloat focal_length = do_get_focal_length(lens_cdata); @@ -112,35 +96,29 @@ do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 & return true; } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::do_project -// Access: Protected, Virtual -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// Some lens types also set the z coordinate of the 2-d -// point to a value in the range (-1, 1), where -1 -// represents a point on the near plane, and 1 -// represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * Some lens types also set the z coordinate of the 2-d point to a value in + * the range (-1, 1), where -1 represents a point on the near plane, and 1 + * represents a point on the far plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise. + */ bool CylindricalLens:: do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const { - // First, account for any rotations, etc. on the lens. + // First, account for any rotations, etc. on the lens. LPoint3 p = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata); - // To compute the x position on the frame, we only need to consider - // the angle of the vector about the Z axis. Project the vector - // into the XY plane to do this. + // To compute the x position on the frame, we only need to consider the + // angle of the vector about the Z axis. Project the vector into the XY + // plane to do this. LVector2 xy(p[0], p[1]); - // The perspective distance is the length of this vector in the XY - // plane. + // The perspective distance is the length of this vector in the XY plane. PN_stdfloat pdist = xy.length(); if (pdist == 0.0f) { point2d.set(0.0f, 0.0f, 0.0f); @@ -156,31 +134,26 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point ( // The x position is the angle about the Z axis. rad_2_deg(catan2(xy[0], xy[1])) * focal_length / cylindrical_k, - // The y position is the Z height divided by the perspective - // distance. + // The y position is the Z height divided by the perspective distance. p[2] * focal_length / pdist, // Z is the distance scaled into the range -1 .. 1. 2.0 * z - 1.0 ); - // Now we have to transform the point according to the film - // adjustments. + // Now we have to transform the point according to the film adjustments. point2d = point2d * do_get_film_mat(lens_cdata); return - point2d[0] >= -1.0f && point2d[0] <= 1.0f && + point2d[0] >= -1.0f && point2d[0] <= 1.0f && point2d[1] >= -1.0f && point2d[1] <= 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the correspdonding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * correspdonding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat CylindricalLens:: fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const { if (horiz) { @@ -190,15 +163,12 @@ fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat CylindricalLens:: fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const { if (horiz) { @@ -208,15 +178,12 @@ fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool horiz) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CylindricalLens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat CylindricalLens:: film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool horiz) const { if (horiz) { diff --git a/panda/src/distort/cylindricalLens.h b/panda/src/distort/cylindricalLens.h index 9a7492e9ca..fc7037e9f4 100644 --- a/panda/src/distort/cylindricalLens.h +++ b/panda/src/distort/cylindricalLens.h @@ -1,16 +1,15 @@ -// Filename: cylindricalLens.h -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cylindricalLens.h + * @author drose + * @date 2001-12-12 + */ #ifndef CYLINDRICALLENS_H #define CYLINDRICALLENS_H @@ -19,24 +18,18 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : CylindricalLens -// Description : A cylindrical lens. This is the kind of lens -// generally used for extremely wide panoramic shots. -// It behaves like a normal perspective lens in the -// vertical direction, but it is non-linear in the -// horizontal dimension: a point on the film corresponds -// to a point in space in linear proportion to its angle -// to the camera, not to its straight-line distance from -// the center. -// -// This allows up to 360 degree lenses in the horizontal -// dimension, with relatively little distortion. The -// distortion is not very apparent between two -// relatively nearby points on the film, but it becomes -// increasingly evident as you compare points widely -// spaced on the film. -//////////////////////////////////////////////////////////////////// +/** + * A cylindrical lens. This is the kind of lens generally used for extremely + * wide panoramic shots. It behaves like a normal perspective lens in the + * vertical direction, but it is non-linear in the horizontal dimension: a + * point on the film corresponds to a point in space in linear proportion to + * its angle to the camera, not to its straight-line distance from the center. + * + * This allows up to 360 degree lenses in the horizontal dimension, with + * relatively little distortion. The distortion is not very apparent between + * two relatively nearby points on the film, but it becomes increasingly + * evident as you compare points widely spaced on the film. + */ class EXPCL_PANDAFX CylindricalLens : public Lens { PUBLISHED: INLINE CylindricalLens(); @@ -49,11 +42,11 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const; - virtual bool do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &vec) const; - virtual bool do_project(const Lens::CData *lens_cdata, + virtual bool do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const; virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; diff --git a/panda/src/distort/fisheyeLens.I b/panda/src/distort/fisheyeLens.I index 2e0a1a3eb4..605b2c5e70 100644 --- a/panda/src/distort/fisheyeLens.I +++ b/panda/src/distort/fisheyeLens.I @@ -1,42 +1,34 @@ -// Filename: fisheyeLens.I -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeLens.I + * @author drose + * @date 2001-12-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FisheyeLens:: FisheyeLens() { } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FisheyeLens:: FisheyeLens(const FisheyeLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FisheyeLens:: operator = (const FisheyeLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/distort/fisheyeLens.cxx b/panda/src/distort/fisheyeLens.cxx index 5e5131977f..a214a2d8b5 100644 --- a/panda/src/distort/fisheyeLens.cxx +++ b/panda/src/distort/fisheyeLens.cxx @@ -1,77 +1,67 @@ -// Filename: fisheyeLens.cxx -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeLens.cxx + * @author drose + * @date 2001-12-12 + */ #include "fisheyeLens.h" #include "deg_2_rad.h" TypeHandle FisheyeLens::_type_handle; -// This is the focal-length constant for fisheye lenses. The focal -// length of a fisheye lens relates to its fov by the equation: +// This is the focal-length constant for fisheye lenses. The focal length of +// a fisheye lens relates to its fov by the equation: -// w = Fd/k +// w = Fdk -// Where w is the width of the negative, F is the focal length, and d -// is the total field of view in degrees. +// Where w is the width of the negative, F is the focal length, and d is the +// total field of view in degrees. -// k is chosen to make the focal lengths for a fisheye lens roughly -// correspond to the equivalent field of view for a conventional, -// perspective lens. It was determined empirically by simple -// examination of a couple of actual lenses for 35mm film. I don't -// know how well this extends to other lenses and other negative -// sizes. +// k is chosen to make the focal lengths for a fisheye lens roughly correspond +// to the equivalent field of view for a conventional, perspective lens. It +// was determined empirically by simple examination of a couple of actual +// lenses for 35mm film. I don't know how well this extends to other lenses +// and other negative sizes. static const PN_stdfloat fisheye_k = 60.0f; -// focal_length = film_size * fisheye_k / fov; +// focal_length = film_size * fisheye_k fov; -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) FisheyeLens:: make_copy() const { return new FisheyeLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::do_extrude -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool FisheyeLens:: -do_extrude(const Lens::CData *lens_cdata, +do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { - // Undo the shifting from film offsets, etc. This puts the point - // into the range [-film_size/2, film_size/2] in x and y. + // Undo the shifting from film offsets, etc. This puts the point into the + // range [-film_size2, film_size2] in x and y. LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata); - // First, get the vector from the center of the film to the point, - // and normalize it. + // First, get the vector from the center of the film to the point, and + // normalize it. LVector2 v2(f[0], f[1]); LPoint3 v; @@ -98,8 +88,8 @@ do_extrude(const Lens::CData *lens_cdata, p[2]*v2[1] - p[0]*v2[0]); } - // And we'll need to account for the lens's rotations, etc. at the - // end of the day. + // And we'll need to account for the lens's rotations, etc. at the end of + // the day. const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata); const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata); @@ -108,26 +98,20 @@ do_extrude(const Lens::CData *lens_cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::do_extrude_vec -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the vector that corresponds to the view -// direction. This will be parallel to the normal on -// the surface (the far plane) corresponding to the lens -// shape at this point. -// -// See the comment block on Lens::extrude_vec_impl() for -// a more in-depth comment on the meaning of this -// vector. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * vector that corresponds to the view direction. This will be parallel to + * the normal on the surface (the far plane) corresponding to the lens shape + * at this point. + * + * See the comment block on Lens::extrude_vec_impl() for a more in-depth + * comment on the meaning of this vector. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool FisheyeLens:: do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &vec) const { LPoint3 near_point, far_point; @@ -140,59 +124,52 @@ do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 & return true; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::do_project -// Access: Protected, Virtual -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// Some lens types also set the z coordinate of the 2-d -// point to a value in the range (-1, 1), where -1 -// represents a point on the near plane, and 1 -// represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * Some lens types also set the z coordinate of the 2-d point to a value in + * the range (-1, 1), where -1 represents a point on the near plane, and 1 + * represents a point on the far plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise. + */ bool FisheyeLens:: do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const { - // First, account for any rotations, etc. on the lens. + // First, account for any rotations, etc. on the lens. LVector3 v2 = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata); - // A fisheye lens projection has the property that the distance from - // the center point to any other point on the projection is - // proportional to the actual distance on the sphere along the great - // circle. Also, the angle to the point on the projection is equal - // to the angle to the point on the sphere. + // A fisheye lens projection has the property that the distance from the + // center point to any other point on the projection is proportional to the + // actual distance on the sphere along the great circle. Also, the angle to + // the point on the projection is equal to the angle to the point on the + // sphere. - // First, get the straight-line distance from the lens, and use it - // to normalize the vector. + // First, get the straight-line distance from the lens, and use it to + // normalize the vector. PN_stdfloat dist = v2.length(); v2 /= dist; - // Now, project the point into the XZ plane and measure its angle - // to the Z axis. This is the same angle it will have to the - // vertical axis on the film. + // Now, project the point into the XZ plane and measure its angle to the Z + // axis. This is the same angle it will have to the vertical axis on the + // film. LVector2 y(v2[0], v2[2]); y.normalize(); if (y == LVector2(0.0f, 0.0f)) { - // Special case. This point is either directly ahead or directly - // behind. - point2d.set(0.0f, 0.0f, + // Special case. This point is either directly ahead or directly behind. + point2d.set(0.0f, 0.0f, (do_get_near(lens_cdata) - dist) / (do_get_far(lens_cdata) - do_get_near(lens_cdata))); return v2[1] >= 0.0f; } - // Now bring the vector into the YZ plane by rotating about the Y - // axis. + // Now bring the vector into the YZ plane by rotating about the Y axis. LVector2 x(v2[1], v2[0]*y[0]+v2[2]*y[1]); - // Now the angle of x to the forward vector represents the distance - // along the great circle to the point. + // Now the angle of x to the forward vector represents the distance along + // the great circle to the point. PN_stdfloat r = 90.0f - rad_2_deg(catan2(x[0], x[1])); PN_stdfloat focal_length = do_get_focal_length(lens_cdata); @@ -208,54 +185,43 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point 2.0 * z - 1.0 ); - // Now we have to transform the point according to the film - // adjustments. + // Now we have to transform the point according to the film adjustments. point2d = point2d * do_get_film_mat(lens_cdata); return - point2d[0] >= -1.0f && point2d[0] <= 1.0f && + point2d[0] >= -1.0f && point2d[0] <= 1.0f && point2d[1] >= -1.0f && point2d[1] <= 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the correspdonding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * correspdonding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat FisheyeLens:: fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / fisheye_k; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat FisheyeLens:: fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * fisheye_k / fov; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeLens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat FisheyeLens:: film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * fisheye_k / focal_length; } - diff --git a/panda/src/distort/fisheyeLens.h b/panda/src/distort/fisheyeLens.h index 84c6573833..dbca0ed3dd 100644 --- a/panda/src/distort/fisheyeLens.h +++ b/panda/src/distort/fisheyeLens.h @@ -1,16 +1,15 @@ -// Filename: fisheyeLens.h -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeLens.h + * @author drose + * @date 2001-12-12 + */ #ifndef FISHEYELENS_H #define FISHEYELENS_H @@ -19,14 +18,11 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : FisheyeLens -// Description : A fisheye lens. This nonlinear lens introduces a -// spherical distortion to the image, which is minimal -// at small angles from the lens, and increases at -// larger angles from the lens. The field of view may -// extend to 360 degrees. -//////////////////////////////////////////////////////////////////// +/** + * A fisheye lens. This nonlinear lens introduces a spherical distortion to + * the image, which is minimal at small angles from the lens, and increases at + * larger angles from the lens. The field of view may extend to 360 degrees. + */ class EXPCL_PANDAFX FisheyeLens : public Lens { PUBLISHED: INLINE FisheyeLens(); @@ -39,11 +35,11 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const; - virtual bool do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude_vec(const Lens::CData *lens_cdata, const LPoint3 &point2d, LVector3 &vec) const; - virtual bool do_project(const Lens::CData *lens_cdata, + virtual bool do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const; virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; diff --git a/panda/src/distort/nonlinearImager.I b/panda/src/distort/nonlinearImager.I index f4f892c006..9598c5fa54 100644 --- a/panda/src/distort/nonlinearImager.I +++ b/panda/src/distort/nonlinearImager.I @@ -1,14 +1,12 @@ -// Filename: nonlinearImager.I -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nonlinearImager.I + * @author drose + * @date 2001-12-12 + */ diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index 7a17a61b8f..fb264061c3 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -1,16 +1,15 @@ -// Filename: nonlinearImager.cxx -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nonlinearImager.cxx + * @author drose + * @date 2001-12-12 + */ #include "nonlinearImager.h" #include "config_distort.h" @@ -24,22 +23,18 @@ #include "asyncTaskManager.h" #include "genericAsyncTask.h" -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NonlinearImager:: NonlinearImager() { _engine = (GraphicsEngine *)NULL; _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NonlinearImager:: ~NonlinearImager() { remove_all_screens(); @@ -51,41 +46,33 @@ NonlinearImager:: } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::add_screen -// Access: Published -// Description: This version of this method is deprecated and will -// soon be removed. Use the version that takes two -// parameters instead. -//////////////////////////////////////////////////////////////////// +/** + * This version of this method is deprecated and will soon be removed. Use + * the version that takes two parameters instead. + */ int NonlinearImager:: add_screen(ProjectionScreen *screen) { return add_screen(NodePath(screen), screen->get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::add_screen -// Access: Published -// Description: Adds a new ProjectionScreen to the list of screens -// that will be processed by the NonlinearImager. Each -// ProjectionScreen represents a view into the world. -// It must be based on a linear camera (or whatever kind -// of camera is respected by the graphics engine). -// -// Each ProjectionScreen object should already have some -// screen geometry created. -// -// As each frame is rendered, an offscreen image will be -// rendered from the source camera associated with each -// ProjectionScreen, and the resulting image will be -// applied to the screen geometry. -// -// The return value is the index number of the new -// screen. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new ProjectionScreen to the list of screens that will be processed + * by the NonlinearImager. Each ProjectionScreen represents a view into the + * world. It must be based on a linear camera (or whatever kind of camera is + * respected by the graphics engine). + * + * Each ProjectionScreen object should already have some screen geometry + * created. + * + * As each frame is rendered, an offscreen image will be rendered from the + * source camera associated with each ProjectionScreen, and the resulting + * image will be applied to the screen geometry. + * + * The return value is the index number of the new screen. + */ int NonlinearImager:: add_screen(const NodePath &screen, const string &name) { - nassertr(!screen.is_empty() && + nassertr(!screen.is_empty() && screen.node()->is_of_type(ProjectionScreen::get_class_type()), -1); ProjectionScreen *screen_node = DCAST(ProjectionScreen, screen.node()); @@ -118,13 +105,10 @@ add_screen(const NodePath &screen, const string &name) { return _screens.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::find_screen -// Access: Published -// Description: Returns the index number of the first appearance of -// the indicated screen within the imager's list, or -1 -// if it does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first appearance of the indicated screen + * within the imager's list, or -1 if it does not appear. + */ int NonlinearImager:: find_screen(const NodePath &screen) const { for (size_t i = 0; i < _screens.size(); i++) { @@ -136,12 +120,9 @@ find_screen(const NodePath &screen) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::remove_screen -// Access: Published -// Description: Removes the screen with the indicated index number -// from the imager. -//////////////////////////////////////////////////////////////////// +/** + * Removes the screen with the indicated index number from the imager. + */ void NonlinearImager:: remove_screen(int index) { nassertv_always(index >= 0 && index < (int)_screens.size()); @@ -152,11 +133,9 @@ remove_screen(int index) { _screens.erase(_screens.begin() + index); } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::remove_all_screens -// Access: Published -// Description: Removes all screens from the imager. -//////////////////////////////////////////////////////////////////// +/** + * Removes all screens from the imager. + */ void NonlinearImager:: remove_all_screens() { while (!_screens.empty()) { @@ -164,54 +143,42 @@ remove_all_screens() { } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_num_screens -// Access: Published -// Description: Returns the number of screens that have been added to -// the imager. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of screens that have been added to the imager. + */ int NonlinearImager:: get_num_screens() const { return _screens.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_screen -// Access: Published -// Description: Returns the nth screen that has been added to the -// imager. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth screen that has been added to the imager. + */ NodePath NonlinearImager:: get_screen(int index) const { nassertr(index >= 0 && index < (int)_screens.size(), NodePath()); return _screens[index]._screen; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_buffer -// Access: Published -// Description: Returns the offscreen buffer that is automatically -// created for the nth projection screen. This may -// return NULL if the screen is inactive or if it has -// not been rendered yet. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offscreen buffer that is automatically created for the nth + * projection screen. This may return NULL if the screen is inactive or if it + * has not been rendered yet. + */ GraphicsOutput *NonlinearImager:: get_buffer(int index) const { nassertr(index >= 0 && index < (int)_screens.size(), (GraphicsOutput *)NULL); return _screens[index]._buffer; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::set_texture_size -// Access: Published -// Description: Sets the width and height of the texture used to -// render the scene for the indicated screen. This must -// be less than or equal to the window size, and it -// should be a power of two. -// -// In general, the larger the texture, the greater the -// detail of the rendered scene. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width and height of the texture used to render the scene for the + * indicated screen. This must be less than or equal to the window size, and + * it should be a power of two. + * + * In general, the larger the texture, the greater the detail of the rendered + * scene. + */ void NonlinearImager:: set_texture_size(int index, int width, int height) { nassertv(index >= 0 && index < (int)_screens.size()); @@ -230,31 +197,25 @@ set_texture_size(int index, int width, int height) { _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::set_source_camera -// Access: Published -// Description: Specifies the camera that will be used to render the -// image for this particular screen. -// -// The parameter must be a NodePath whose node is a -// Camera. The camera itself indicates the scene that -// is to be rendered. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the camera that will be used to render the image for this + * particular screen. + * + * The parameter must be a NodePath whose node is a Camera. The camera itself + * indicates the scene that is to be rendered. + */ void NonlinearImager:: set_source_camera(int index, const NodePath &source_camera) { nassertv(index >= 0 && index < (int)_screens.size()); - nassertv(!source_camera.is_empty() && + nassertv(!source_camera.is_empty() && source_camera.node()->is_of_type(Camera::get_class_type())); _screens[index]._source_camera = source_camera; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::set_screen_active -// Access: Published -// Description: Sets the active flag on the indicated screen. If the -// active flag is true, the screen will be used; -// otherwise, it will not appear. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag on the indicated screen. If the active flag is true, + * the screen will be used; otherwise, it will not appear. + */ void NonlinearImager:: set_screen_active(int index, bool active) { nassertv(index >= 0 && index < (int)_screens.size()); @@ -275,9 +236,9 @@ set_screen_active(int index, bool active) { nassertv(removed); } - // Hide the screen in the dark room. This doesn't really matter, - // since the dark room isn't normally rendered, but hide it anyway - // in case the user stuck a camera in there for fun. + // Hide the screen in the dark room. This doesn't really matter, since + // the dark room isn't normally rendered, but hide it anyway in case the + // user stuck a camera in there for fun. screen._screen.hide(); } else { @@ -288,11 +249,9 @@ set_screen_active(int index, bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_screen_active -// Access: Published -// Description: Returns the active flag on the indicated screen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag on the indicated screen. + */ bool NonlinearImager:: get_screen_active(int index) const { nassertr(index >= 0 && index < (int)_screens.size(), false); @@ -300,25 +259,20 @@ get_screen_active(int index) const { } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::add_viewer -// Access: Published -// Description: Adds the indicated DisplayRegion as a viewer into the -// NonlinearImager room. The camera associated with the -// DisplayRegion at the time add_viewer() is called is -// used as the initial viewer camera; it may have a -// nonlinear lens, like a fisheye or cylindrical lens. -// -// This sets up a special scene graph for this -// DisplayRegion alone and sets up the DisplayRegion -// with a specialty camera. If future changes to the -// camera are desired, you should use the -// set_viewer_camera() interface. -// -// All viewers must share the same GraphicsEngine. -// -// The return value is the index of the new viewer. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated DisplayRegion as a viewer into the NonlinearImager room. + * The camera associated with the DisplayRegion at the time add_viewer() is + * called is used as the initial viewer camera; it may have a nonlinear lens, + * like a fisheye or cylindrical lens. + * + * This sets up a special scene graph for this DisplayRegion alone and sets up + * the DisplayRegion with a specialty camera. If future changes to the camera + * are desired, you should use the set_viewer_camera() interface. + * + * All viewers must share the same GraphicsEngine. + * + * The return value is the index of the new viewer. + */ int NonlinearImager:: add_viewer(DisplayRegion *dr) { GraphicsOutput *window = dr->get_window(); @@ -336,7 +290,7 @@ add_viewer(DisplayRegion *dr) { } if (_recompute_task == (AsyncTask *)NULL) { - _recompute_task = + _recompute_task = new GenericAsyncTask("nli_recompute", recompute_callback, (void *)this); AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr(); task_mgr->add(_recompute_task); @@ -361,8 +315,8 @@ add_viewer(DisplayRegion *dr) { viewer._viewer_node = DCAST(LensNode, viewer._viewer.node()); } - // The internal camera is an identity-matrix camera that simply - // views the meshes that represent the user's specified camera. + // The internal camera is an identity-matrix camera that simply views the + // meshes that represent the user's specified camera. viewer._internal_camera = new Camera("internal_camera"); viewer._internal_camera->set_lens(new MatrixLens); viewer._internal_scene = NodePath("internal_screens"); @@ -371,9 +325,9 @@ add_viewer(DisplayRegion *dr) { NodePath camera_np = viewer._internal_scene.attach_new_node(viewer._internal_camera); viewer._dr->set_camera(camera_np); - // Enable face culling on the wireframe mesh. This will help us to - // cull out invalid polygons that result from vertices crossing a - // singularity (for instance, at the back of a fisheye lens). + // Enable face culling on the wireframe mesh. This will help us to cull out + // invalid polygons that result from vertices crossing a singularity (for + // instance, at the back of a fisheye lens). viewer._internal_scene.set_two_sided(0); // Finally, slot a new mesh for each screen. @@ -395,13 +349,10 @@ add_viewer(DisplayRegion *dr) { return vi; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::find_viewer -// Access: Published -// Description: Returns the index number of the indicated -// DisplayRegion within the list of viewers, or -1 if it -// is not found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the indicated DisplayRegion within the list of + * viewers, or -1 if it is not found. + */ int NonlinearImager:: find_viewer(DisplayRegion *dr) const { for (size_t vi = 0; vi < _viewers.size(); vi++) { @@ -413,12 +364,9 @@ find_viewer(DisplayRegion *dr) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::remove_viewer -// Access: Published -// Description: Removes the viewer with the indicated index number -// from the imager. -//////////////////////////////////////////////////////////////////// +/** + * Removes the viewer with the indicated index number from the imager. + */ void NonlinearImager:: remove_viewer(int index) { nassertv_always(index >= 0 && index < (int)_viewers.size()); @@ -438,11 +386,9 @@ remove_viewer(int index) { _viewers.erase(_viewers.begin() + index); } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::remove_all_viewers -// Access: Published -// Description: Removes all viewers from the imager. -//////////////////////////////////////////////////////////////////// +/** + * Removes all viewers from the imager. + */ void NonlinearImager:: remove_all_viewers() { while (!_viewers.empty()) { @@ -450,27 +396,22 @@ remove_all_viewers() { } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::set_viewer_camera -// Access: Published -// Description: Specifies the LensNode that is to serve as the -// viewer for this screen. The relative position of -// the LensNode to the NonlinearImager, as well as the -// properties of the lens associated with the LensNode, -// determines the UV's that will be assigned to the -// geometry within the NonlinearImager. -// -// It is not necessary to call this except to change the -// camera after a viewer has been added, since the -// default is to use whatever camera is associated with -// the DisplayRegion at the time the viewer is added. -// -// The NodePath must refer to a LensNode (or a Camera). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the LensNode that is to serve as the viewer for this screen. The + * relative position of the LensNode to the NonlinearImager, as well as the + * properties of the lens associated with the LensNode, determines the UV's + * that will be assigned to the geometry within the NonlinearImager. + * + * It is not necessary to call this except to change the camera after a viewer + * has been added, since the default is to use whatever camera is associated + * with the DisplayRegion at the time the viewer is added. + * + * The NodePath must refer to a LensNode (or a Camera). + */ void NonlinearImager:: set_viewer_camera(int index, const NodePath &viewer_camera) { nassertv(index >= 0 && index < (int)_viewers.size()); - nassertv(!viewer_camera.is_empty() && + nassertv(!viewer_camera.is_empty() && viewer_camera.node()->is_of_type(LensNode::get_class_type())); Viewer &viewer = _viewers[index]; viewer._viewer = viewer_camera; @@ -484,98 +425,76 @@ set_viewer_camera(int index, const NodePath &viewer_camera) { } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_viewer_camera -// Access: Published -// Description: Returns the NodePath to the LensNode that is to serve -// as nth viewer for this screen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath to the LensNode that is to serve as nth viewer for + * this screen. + */ NodePath NonlinearImager:: get_viewer_camera(int index) const { nassertr(index >= 0 && index < (int)_viewers.size(), NodePath()); return _viewers[index]._viewer; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_viewer_scene -// Access: Published -// Description: Returns a pointer to the root node of the internal -// scene graph for the nth viewer, which is used to -// render all of the screen meshes for this viewer. -// -// This is the scene graph in which the screen meshes -// within the dark room have been flattened into the -// appropriate transformation according to the viewer's -// lens properties (and position relative to the -// screens). It is this scene graph that is finally -// rendered to the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the root node of the internal scene graph for the nth + * viewer, which is used to render all of the screen meshes for this viewer. + * + * This is the scene graph in which the screen meshes within the dark room + * have been flattened into the appropriate transformation according to the + * viewer's lens properties (and position relative to the screens). It is + * this scene graph that is finally rendered to the window. + */ NodePath NonlinearImager:: get_viewer_scene(int index) const { nassertr(index >= 0 && index < (int)_viewers.size(), NodePath()); return _viewers[index]._internal_scene; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_num_viewers -// Access: Published -// Description: Returns the number of viewers that have been added to -// the imager. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of viewers that have been added to the imager. + */ int NonlinearImager:: get_num_viewers() const { return _viewers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_viewer -// Access: Published -// Description: Returns the nth viewer's DisplayRegion that has been -// added to the imager. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth viewer's DisplayRegion that has been added to the imager. + */ DisplayRegion *NonlinearImager:: get_viewer(int index) const { nassertr(index >= 0 && index < (int)_viewers.size(), (DisplayRegion *)NULL); return _viewers[index]._dr; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_dark_room -// Access: Published -// Description: Returns the NodePath to the root of the dark room -// scene. This is the scene in which all of the -// ProjectionScreens and the viewer cameras reside. -// It's a standalone scene with a few projection screens -// arranged artfully around one or more viewers; it's so -// named because it's a little virtual theater. -// -// Normally this scene is not rendered directly; it only -// exists as an abstract concept, and to define the -// relation between the ProjectionScreens and the -// viewers. But it may be rendered to help visualize -// the NonlinearImager's behavior. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath to the root of the dark room scene. This is the scene + * in which all of the ProjectionScreens and the viewer cameras reside. It's + * a standalone scene with a few projection screens arranged artfully around + * one or more viewers; it's so named because it's a little virtual theater. + * + * Normally this scene is not rendered directly; it only exists as an abstract + * concept, and to define the relation between the ProjectionScreens and the + * viewers. But it may be rendered to help visualize the NonlinearImager's + * behavior. + */ NodePath NonlinearImager:: get_dark_room() const { return _dark_room; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::get_graphics_engine -// Access: Published -// Description: Returns the GraphicsEngine that all of the viewers -// added to the NonlinearImager have in common. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsEngine that all of the viewers added to the + * NonlinearImager have in common. + */ GraphicsEngine *NonlinearImager:: get_graphics_engine() const { return _engine; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::recompute -// Access: Published -// Description: Forces a regeneration of all the mesh objects, etc. -//////////////////////////////////////////////////////////////////// +/** + * Forces a regeneration of all the mesh objects, etc. + */ void NonlinearImager:: recompute() { size_t vi; @@ -590,9 +509,9 @@ recompute() { } } - if (viewer._viewer_node != (LensNode *)NULL && + if (viewer._viewer_node != (LensNode *)NULL && viewer._viewer_node->get_lens() != (Lens *)NULL) { - viewer._viewer_lens_change = + viewer._viewer_lens_change = viewer._viewer_node->get_lens()->get_last_change(); } } @@ -600,12 +519,9 @@ recompute() { _stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::recompute_callback -// Access: Private, Static -// Description: This function is added as a task, to ensure that all -// frames are up-to-date. -//////////////////////////////////////////////////////////////////// +/** + * This function is added as a task, to ensure that all frames are up-to-date. + */ AsyncTask::DoneStatus NonlinearImager:: recompute_callback(GenericAsyncTask *, void *data) { NonlinearImager *self = (NonlinearImager *)data; @@ -613,11 +529,9 @@ recompute_callback(GenericAsyncTask *, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::recompute_if_stale -// Access: Private -// Description: Calls recompute() if it needs to be called. -//////////////////////////////////////////////////////////////////// +/** + * Calls recompute() if it needs to be called. + */ void NonlinearImager:: recompute_if_stale() { if (_stale) { @@ -627,11 +541,11 @@ recompute_if_stale() { for (vi = 0; vi < _viewers.size(); ++vi) { Viewer &viewer = _viewers[vi]; if (viewer._viewer_node != (LensNode *)NULL) { - UpdateSeq lens_change = + UpdateSeq lens_change = viewer._viewer_node->get_lens()->get_last_change(); if (lens_change != viewer._viewer_lens_change) { - // The viewer has changed, so we need to recompute all screens - // on this viewer. + // The viewer has changed, so we need to recompute all screens on + // this viewer. Screens::iterator si; for (si = _screens.begin(); si != _screens.end(); ++si) { Screen &screen = (*si); @@ -639,14 +553,13 @@ recompute_if_stale() { recompute_screen(screen, vi); } } - + } else { - // We may not need to recompute all screens, but maybe some of - // them. + // We may not need to recompute all screens, but maybe some of them. Screens::iterator si; for (si = _screens.begin(); si != _screens.end(); ++si) { Screen &screen = (*si); - if (screen._active && + if (screen._active && screen._meshes[vi]._last_screen != screen._screen_node->get_last_screen()) { recompute_screen(screen, vi); } else { @@ -659,12 +572,9 @@ recompute_if_stale() { } } -//////////////////////////////////////////////////////////////////// -// Function: NonlinearImager::recompute_screen -// Access: Private -// Description: Regenerates the mesh objects just for the indicated -// screen. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates the mesh objects just for the indicated screen. + */ void NonlinearImager:: recompute_screen(NonlinearImager::Screen &screen, size_t vi) { nassertv(vi < screen._meshes.size()); @@ -676,7 +586,7 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { screen._screen_node->recompute_if_stale(screen._screen); Viewer &viewer = _viewers[vi]; - PT(PandaNode) mesh = + PT(PandaNode) mesh = screen._screen_node->make_flat_mesh(screen._screen, viewer._viewer); if (mesh != (PandaNode *)NULL) { screen._meshes[vi]._mesh = viewer._internal_scene.attach_new_node(mesh); @@ -700,10 +610,10 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { if (screen._buffer != (GraphicsOutput *)NULL) { screen._meshes[vi]._mesh.set_texture(screen._buffer->get_texture()); - // We don't really need to set the texture on the dark room - // screen, since that's normally not rendered, but we do anyway - // just for debugging purposes (in case the user does try to - // render it, to see what's going on). + // We don't really need to set the texture on the dark room screen, since + // that's normally not rendered, but we do anyway just for debugging + // purposes (in case the user does try to render it, to see what's going + // on). screen._screen.set_texture(screen._buffer->get_texture()); } diff --git a/panda/src/distort/nonlinearImager.h b/panda/src/distort/nonlinearImager.h index 518b7adebd..621ad0d139 100644 --- a/panda/src/distort/nonlinearImager.h +++ b/panda/src/distort/nonlinearImager.h @@ -1,16 +1,15 @@ -// Filename: nonlinearImager.h -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nonlinearImager.h + * @author drose + * @date 2001-12-12 + */ #ifndef NONLINEARIMAGER_H #define NONLINEARIMAGER_H @@ -35,62 +34,50 @@ class GraphicsStateGuardian; class GraphicsOutput; class GenericAsyncTask; -//////////////////////////////////////////////////////////////////// -// Class : NonlinearImager -// Description : This class object combines the rendered output of a -// 3-d from one or more linear (e.g. perspective) -// cameras, as seen through a single, possibly nonlinear -// camera. -// -// This can be used to generate real-time imagery of a -// 3-d scene using a nonlinear camera, for instance a -// fisheye camera, even though the underlying graphics -// engine may only support linear cameras. It can also -// pre-distort imagery to compensate for off-axis -// projectors, and/or curved screens of any complexity. -// -// -// A NonlinearImager may be visualized as a dark room -// into which a number of projection screens have been -// placed, of arbitrary size and shape and at any -// arbitrary position and orientation to each other. -// Onto each of these screens is projected the view as -// seen by a normal perspective camera that exists in -// the world (that is, under render). -// -// There also exist in the room one or more (possibly -// nonlinear) cameras, called viewers, that observe -// these screens. The image of the projection screens -// seen by each viewer is finally displayed on the -// viewer's associated DisplayRegion. By placing the -// viewer(s) appropriately relative to the screens, and -// by choosing suitable lens properties for the -// viewer(s), you can achieve a wide variety of -// distortion effects. -// -// -// There are several different LensNode (Camera) objects -// involved at each stage in the process. To help keep -// them all straight, different words are used to refer -// to each different kind of Camera used within this -// object. The camera(s) under render, that capture the -// original view of the world to be projected onto the -// screens, are called source cameras, and are set per -// screen via set_source_camera(). The LensNode that is -// associated with each screen to project the image as -// seen from the screen's source camera is called a -// projector; these are set via the -// ProjectionScreen::set_projector() interface. -// Finally, the cameras that view the whole -// configuration of screens are called viewers; each of -// these is associated with a DisplayRegion, and they -// are set via set_viewer_camera(). -// -// Of all these lenses, only the source cameras must use -// linear (that is, perspective or orthographic) lenses. -// The projectors and viewers may be any arbitrary lens, -// linear or otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This class object combines the rendered output of a 3-d from one or more + * linear (e.g. perspective) cameras, as seen through a single, possibly + * nonlinear camera. + * + * This can be used to generate real-time imagery of a 3-d scene using a + * nonlinear camera, for instance a fisheye camera, even though the underlying + * graphics engine may only support linear cameras. It can also pre-distort + * imagery to compensate for off-axis projectors, and/or curved screens of any + * complexity. + * + + * + * A NonlinearImager may be visualized as a dark room into which a number of + * projection screens have been placed, of arbitrary size and shape and at any + * arbitrary position and orientation to each other. Onto each of these + * screens is projected the view as seen by a normal perspective camera that + * exists in the world (that is, under render). + * + * There also exist in the room one or more (possibly nonlinear) cameras, + * called viewers, that observe these screens. The image of the projection + * screens seen by each viewer is finally displayed on the viewer's associated + * DisplayRegion. By placing the viewer(s) appropriately relative to the + * screens, and by choosing suitable lens properties for the viewer(s), you + * can achieve a wide variety of distortion effects. + * + + * + * There are several different LensNode (Camera) objects involved at each + * stage in the process. To help keep them all straight, different words are + * used to refer to each different kind of Camera used within this object. + * The camera(s) under render, that capture the original view of the world to + * be projected onto the screens, are called source cameras, and are set per + * screen via set_source_camera(). The LensNode that is associated with each + * screen to project the image as seen from the screen's source camera is + * called a projector; these are set via the ProjectionScreen::set_projector() + * interface. Finally, the cameras that view the whole configuration of + * screens are called viewers; each of these is associated with a + * DisplayRegion, and they are set via set_viewer_camera(). + * + * Of all these lenses, only the source cameras must use linear (that is, + * perspective or orthographic) lenses. The projectors and viewers may be any + * arbitrary lens, linear or otherwise. + */ class EXPCL_PANDAFX NonlinearImager { PUBLISHED: NonlinearImager(); diff --git a/panda/src/distort/oSphereLens.I b/panda/src/distort/oSphereLens.I index f0be9e5b49..440807ba11 100644 --- a/panda/src/distort/oSphereLens.I +++ b/panda/src/distort/oSphereLens.I @@ -1,42 +1,34 @@ -// Filename: oSphereLens.I -// Created by: drose (25Feb11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file oSphereLens.I + * @author drose + * @date 2011-02-25 + */ -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OSphereLens:: OSphereLens() { } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OSphereLens:: OSphereLens(const OSphereLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void OSphereLens:: operator = (const OSphereLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/distort/oSphereLens.cxx b/panda/src/distort/oSphereLens.cxx index 1d9ceb7f12..7b8bd35591 100644 --- a/panda/src/distort/oSphereLens.cxx +++ b/panda/src/distort/oSphereLens.cxx @@ -1,60 +1,50 @@ -// Filename: oSphereLens.cxx -// Created by: drose (25Feb11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file oSphereLens.cxx + * @author drose + * @date 2011-02-25 + */ #include "oSphereLens.h" #include "deg_2_rad.h" TypeHandle OSphereLens::_type_handle; -// This is the focal-length constant for fisheye lenses. See -// fisheyeLens.cxx. +// This is the focal-length constant for fisheye lenses. See fisheyeLens.cxx. static const PN_stdfloat ospherical_k = 60.0f; -// focal_length = film_size * ospherical_k / fov; +// focal_length = film_size * ospherical_k fov; -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) OSphereLens:: make_copy() const { return new OSphereLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::do_extrude -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool OSphereLens:: -do_extrude(const Lens::CData *lens_cdata, +do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { - // Undo the shifting from film offsets, etc. This puts the point - // into the range [-film_size/2, film_size/2] in x and y. + // Undo the shifting from film offsets, etc. This puts the point into the + // range [-film_size2, film_size2] in x and y. LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata); PN_stdfloat focal_length = do_get_focal_length(lens_cdata); @@ -62,8 +52,8 @@ do_extrude(const Lens::CData *lens_cdata, PN_stdfloat sinAngle, cosAngle; csincos(deg_2_rad(angle), &sinAngle, &cosAngle); - // Define a unit vector that represents the vector corresponding to - // this point. + // Define a unit vector that represents the vector corresponding to this + // point. LPoint3 v(sinAngle, cosAngle, 0.0f); near_point = (v * do_get_near(lens_cdata)); @@ -71,8 +61,8 @@ do_extrude(const Lens::CData *lens_cdata, near_point[2] = f[1]; far_point[2] = f[1]; - // And we'll need to account for the lens's rotations, etc. at the - // end of the day. + // And we'll need to account for the lens's rotations, etc. at the end of + // the day. const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata); const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata); @@ -81,31 +71,26 @@ do_extrude(const Lens::CData *lens_cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::do_project -// Access: Protected, Virtual -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// Some lens types also set the z coordinate of the 2-d -// point to a value in the range (-1, 1), where -1 -// represents a point on the near plane, and 1 -// represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * Some lens types also set the z coordinate of the 2-d point to a value in + * the range (-1, 1), where -1 represents a point on the near plane, and 1 + * represents a point on the far plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise. + */ bool OSphereLens:: do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const { - // First, account for any rotations, etc. on the lens. + // First, account for any rotations, etc. on the lens. LPoint3 p = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata); - // To compute the x position on the frame, we only need to consider - // the angle of the vector about the Z axis. Project the vector - // into the XY plane to do this. + // To compute the x position on the frame, we only need to consider the + // angle of the vector about the Z axis. Project the vector into the XY + // plane to do this. LVector2 xy(p[0], p[1]); PN_stdfloat dist = xy.length(); @@ -128,52 +113,42 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point 2.0 * z - 1.0 ); - // Now we have to transform the point according to the film - // adjustments. + // Now we have to transform the point according to the film adjustments. point2d = point2d * do_get_film_mat(lens_cdata); return - point2d[0] >= -1.0f && point2d[0] <= 1.0f && + point2d[0] >= -1.0f && point2d[0] <= 1.0f && point2d[1] >= -1.0f && point2d[1] <= 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the correspdonding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * correspdonding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat OSphereLens:: fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / ospherical_k; } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat OSphereLens:: fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * ospherical_k / fov; } -//////////////////////////////////////////////////////////////////// -// Function: OSphereLens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat OSphereLens:: film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * ospherical_k / focal_length; diff --git a/panda/src/distort/oSphereLens.h b/panda/src/distort/oSphereLens.h index acc884f884..f76954aa6f 100644 --- a/panda/src/distort/oSphereLens.h +++ b/panda/src/distort/oSphereLens.h @@ -1,16 +1,15 @@ -// Filename: oSphereLens.h -// Created by: drose (25Feb11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file oSphereLens.h + * @author drose + * @date 2011-02-25 + */ #ifndef OSPHERELENS_H #define OSPHERELENS_H @@ -19,18 +18,15 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : OSphereLens -// Description : A OSphereLens is a special nonlinear lens that -// doesn't correspond to any real physical lenses. It's -// primarily useful for generating 360-degree wraparound -// images while avoiding the distortion associated with -// fisheye images. -// -// A OSphereLens is similar to a Cylindrical lens and -// PSphereLens, except that it is orthographic in the -// vertical direction. -//////////////////////////////////////////////////////////////////// +/** + * A OSphereLens is a special nonlinear lens that doesn't correspond to any + * real physical lenses. It's primarily useful for generating 360-degree + * wraparound images while avoiding the distortion associated with fisheye + * images. + * + * A OSphereLens is similar to a Cylindrical lens and PSphereLens, except that + * it is orthographic in the vertical direction. + */ class EXPCL_PANDAFX OSphereLens : public Lens { PUBLISHED: INLINE OSphereLens(); @@ -43,9 +39,9 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const; - virtual bool do_project(const Lens::CData *lens_cdata, + virtual bool do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const; virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; diff --git a/panda/src/distort/pSphereLens.I b/panda/src/distort/pSphereLens.I index 5f3a70e6ac..2f482a7d94 100644 --- a/panda/src/distort/pSphereLens.I +++ b/panda/src/distort/pSphereLens.I @@ -1,42 +1,34 @@ -// Filename: pSphereLens.I -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pSphereLens.I + * @author drose + * @date 2001-12-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PSphereLens:: PSphereLens() { } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PSphereLens:: PSphereLens(const PSphereLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PSphereLens:: operator = (const PSphereLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/distort/pSphereLens.cxx b/panda/src/distort/pSphereLens.cxx index 757d677bb5..01c4aa58af 100644 --- a/panda/src/distort/pSphereLens.cxx +++ b/panda/src/distort/pSphereLens.cxx @@ -1,71 +1,61 @@ -// Filename: pSphereLens.cxx -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pSphereLens.cxx + * @author drose + * @date 2001-12-12 + */ #include "pSphereLens.h" #include "deg_2_rad.h" TypeHandle PSphereLens::_type_handle; -// This is the focal-length constant for fisheye lenses. See -// fisheyeLens.cxx. +// This is the focal-length constant for fisheye lenses. See fisheyeLens.cxx. static const PN_stdfloat pspherical_k = 60.0f; -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) PSphereLens:: make_copy() const { return new PSphereLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::do_extrude -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool PSphereLens:: -do_extrude(const Lens::CData *lens_cdata, +do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { - // Undo the shifting from film offsets, etc. This puts the point - // into the range [-film_size/2, film_size/2] in x and y. + // Undo the shifting from film offsets, etc. This puts the point into the + // range [-film_size2, film_size2] in x and y. LPoint3 f = point2d * do_get_film_mat_inv(lens_cdata); PN_stdfloat focal_length = do_get_focal_length(lens_cdata); - // Rotate the forward vector through the rotation angles - // corresponding to this point. + // Rotate the forward vector through the rotation angles corresponding to + // this point. LPoint3 v = LPoint3(0.0f, 1.0f, 0.0f) * LMatrix3::rotate_mat(f[1] * pspherical_k / focal_length, LVector3(1.0f, 0.0f, 0.0f)) * LMatrix3::rotate_mat(f[0] * pspherical_k / focal_length, LVector3(0.0f, 0.0f, -1.0f)); - // And we'll need to account for the lens's rotations, etc. at the - // end of the day. + // And we'll need to account for the lens's rotations, etc. at the end of + // the day. const LMatrix4 &lens_mat = do_get_lens_mat(lens_cdata); const LMatrix4 &proj_inv_mat = do_get_projection_mat_inv(lens_cdata); @@ -74,26 +64,21 @@ do_extrude(const Lens::CData *lens_cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::do_project -// Access: Protected, Virtual -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// Some lens types also set the z coordinate of the 2-d -// point to a value in the range (-1, 1), where -1 -// represents a point on the near plane, and 1 -// represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * Some lens types also set the z coordinate of the 2-d point to a value in + * the range (-1, 1), where -1 represents a point on the near plane, and 1 + * represents a point on the far plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise. + */ bool PSphereLens:: do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const { - // First, account for any rotations, etc. on the lens. + // First, account for any rotations, etc. on the lens. LVector3 v3 = point3d * do_get_lens_mat_inv(lens_cdata) * do_get_projection_mat(lens_cdata); PN_stdfloat dist = v3.length(); if (dist == 0.0f) { @@ -105,13 +90,12 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point PN_stdfloat focal_length = do_get_focal_length(lens_cdata); - // To compute the x position on the frame, we only need to consider - // the angle of the vector about the Z axis. Project the vector - // into the XY plane to do this. + // To compute the x position on the frame, we only need to consider the + // angle of the vector about the Z axis. Project the vector into the XY + // plane to do this. LVector2 xy(v3[0], v3[1]); - // Unroll the Z angle, and the y position is the angle about the X - // axis. + // Unroll the Z angle, and the y position is the angle about the X axis. xy.normalize(); LVector2d yz(v3[0]*xy[0] + v3[1]*xy[1], v3[2]); @@ -128,52 +112,42 @@ do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point 2.0 * z - 1.0 ); - // Now we have to transform the point according to the film - // adjustments. + // Now we have to transform the point according to the film adjustments. point2d = point2d * do_get_film_mat(lens_cdata); return - point2d[0] >= -1.0f && point2d[0] <= 1.0f && + point2d[0] >= -1.0f && point2d[0] <= 1.0f && point2d[1] >= -1.0f && point2d[1] <= 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the correspdonding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * correspdonding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat PSphereLens:: fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return focal_length * fov / pspherical_k; } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat PSphereLens:: fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * pspherical_k / fov; } -//////////////////////////////////////////////////////////////////// -// Function: PSphereLens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat PSphereLens:: film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return film_size * pspherical_k / focal_length; diff --git a/panda/src/distort/pSphereLens.h b/panda/src/distort/pSphereLens.h index 0277d05563..8d79ed5e58 100644 --- a/panda/src/distort/pSphereLens.h +++ b/panda/src/distort/pSphereLens.h @@ -1,16 +1,15 @@ -// Filename: pSphereLens.h -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pSphereLens.h + * @author drose + * @date 2001-12-12 + */ #ifndef PSPHERELENS_H #define PSPHERELENS_H @@ -19,22 +18,18 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : PSphereLens -// Description : A PSphereLens is a special nonlinear lens that -// doesn't correspond to any real physical lenses. It's -// primarily useful for generating 360-degree wraparound -// images while avoiding the distortion associated with -// fisheye images. -// -// A PSphereLens is similar to a cylindrical lens, -// except it is also curved in the vertical direction. -// This allows it to extend to both poles in the -// vertical direction. The mapping is similar to what -// many modeling packages call a sphere mapping: the x -// coordinate is proportional to azimuth, while the y -// coordinate is proportional to altitude. -//////////////////////////////////////////////////////////////////// +/** + * A PSphereLens is a special nonlinear lens that doesn't correspond to any + * real physical lenses. It's primarily useful for generating 360-degree + * wraparound images while avoiding the distortion associated with fisheye + * images. + * + * A PSphereLens is similar to a cylindrical lens, except it is also curved in + * the vertical direction. This allows it to extend to both poles in the + * vertical direction. The mapping is similar to what many modeling packages + * call a sphere mapping: the x coordinate is proportional to azimuth, while + * the y coordinate is proportional to altitude. + */ class EXPCL_PANDAFX PSphereLens : public Lens { PUBLISHED: INLINE PSphereLens(); @@ -47,9 +42,9 @@ public: virtual PT(Lens) make_copy() const; protected: - virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, + virtual bool do_extrude(const Lens::CData *lens_cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const; - virtual bool do_project(const Lens::CData *lens_cdata, + virtual bool do_project(const Lens::CData *lens_cdata, const LPoint3 &point3d, LPoint3 &point2d) const; virtual PN_stdfloat fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool horiz) const; diff --git a/panda/src/distort/projectionScreen.I b/panda/src/distort/projectionScreen.I index 560138cf7f..b1fa41f7f5 100644 --- a/panda/src/distort/projectionScreen.I +++ b/panda/src/distort/projectionScreen.I @@ -1,124 +1,96 @@ -// Filename: projectionScreen.I -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file projectionScreen.I + * @author drose + * @date 2001-12-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_projector -// Access: Published -// Description: Returns the NodePath to the LensNode that is to serve -// as the projector for this screen, or empty if no -// projector is associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath to the LensNode that is to serve as the projector for + * this screen, or empty if no projector is associated. + */ INLINE const NodePath &ProjectionScreen:: get_projector() const { return _projector; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::clear_undist_lut -// Access: Published -// Description: Removes the distortion lookup table from the -// projector, if specified. -//////////////////////////////////////////////////////////////////// +/** + * Removes the distortion lookup table from the projector, if specified. + */ INLINE void ProjectionScreen:: clear_undist_lut() { _has_undist_lut = false; _undist_lut = PfmFile(); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_undist_lut -// Access: Published -// Description: Applies a distortion lookup table to the -// projector. This mapping warps the lens effect by -// passing each ray through an indirection table: the -// point (u,v) in the indicated lookup table stores the -// actual (u,v) that the lens produces. -// -// This does not affect the operation of -// generate_screen(). -//////////////////////////////////////////////////////////////////// +/** + * Applies a distortion lookup table to the projector. This mapping warps the + * lens effect by passing each ray through an indirection table: the point + * (u,v) in the indicated lookup table stores the actual (u,v) that the lens + * produces. + * + * This does not affect the operation of generate_screen(). + */ INLINE void ProjectionScreen:: set_undist_lut(const PfmFile &undist_lut) { _has_undist_lut = undist_lut.is_valid(); _undist_lut = undist_lut; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::has_undist_lut -// Access: Published -// Description: Returns true if a valid distortion lookup table was -// provided via set_undist_lut(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a valid distortion lookup table was provided via + * set_undist_lut(), false otherwise. + */ INLINE bool ProjectionScreen:: has_undist_lut() const { return _has_undist_lut; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_undist_lut -// Access: Published -// Description: Returns the distortion lookup table provided via -// set_undist_lut(), if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the distortion lookup table provided via set_undist_lut(), if any. + */ INLINE const PfmFile &ProjectionScreen:: get_undist_lut() const { return _undist_lut; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_texcoord_name -// Access: Published -// Description: Specifies the name of the texture coordinates that -// are generated by this particular ProjectionScreen. -// This can be used in the presence of multitexturing to -// compute the UV's for just a subset of all of the -// active stages of the multitexture pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of the texture coordinates that are generated by this + * particular ProjectionScreen. This can be used in the presence of + * multitexturing to compute the UV's for just a subset of all of the active + * stages of the multitexture pipeline. + */ INLINE void ProjectionScreen:: set_texcoord_name(const string &texcoord_name) { _texcoord_name = InternalName::get_texcoord_name(texcoord_name); _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_texcoord_name -// Access: Published -// Description: Returns the name of the texture coordinates that -// will be generated by this particular -// ProjectionScreen, as set by set_texcoord_name(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the texture coordinates that will be generated by this + * particular ProjectionScreen, as set by set_texcoord_name(). + */ INLINE string ProjectionScreen:: get_texcoord_name() const { return _texcoord_name->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_invert_uvs -// Access: Published -// Description: Some OpenGL graphics drivers are known to invert the -// framebuffer image when they copy it to texture. -// (This is arguably a problem with the OpenGL spec, -// which seems to be unclear about the proper ordering -// of pixels in this operation.) -// -// In any case, set this true to compensate for this -// effect by inverting the UV's of the projection -// screen. The default is taken from the Configrc -// variable project-invert-uvs. -//////////////////////////////////////////////////////////////////// +/** + * Some OpenGL graphics drivers are known to invert the framebuffer image when + * they copy it to texture. (This is arguably a problem with the OpenGL spec, + * which seems to be unclear about the proper ordering of pixels in this + * operation.) + * + * In any case, set this true to compensate for this effect by inverting the + * UV's of the projection screen. The default is taken from the Configrc + * variable project-invert-uvs. + */ INLINE void ProjectionScreen:: set_invert_uvs(bool invert_uvs) { _invert_uvs = invert_uvs; @@ -126,28 +98,22 @@ set_invert_uvs(bool invert_uvs) { } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_invert_uvs -// Access: Published -// Description: Returns whether this screen is compensating for a -// graphics driver inverting the framebuffer image. See -// set_invert_uvs(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether this screen is compensating for a graphics driver inverting + * the framebuffer image. See set_invert_uvs(). + */ INLINE bool ProjectionScreen:: get_invert_uvs() const { return _invert_uvs; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_texcoord_3d -// Access: Published -// Description: Set this true to force 3-D texture coordinates to be -// created for the geometry. When this is true and the -// geometry has only 2-D texture coordinates, those -// texture coordinates are dumped in favor of 3-D -// coordinates. When this is false, whatever texture -// coordinates already exist are preserved as-is. -//////////////////////////////////////////////////////////////////// +/** + * Set this true to force 3-D texture coordinates to be created for the + * geometry. When this is true and the geometry has only 2-D texture + * coordinates, those texture coordinates are dumped in favor of 3-D + * coordinates. When this is false, whatever texture coordinates already + * exist are preserved as-is. + */ INLINE void ProjectionScreen:: set_texcoord_3d(bool texcoord_3d) { _texcoord_3d = texcoord_3d; @@ -155,30 +121,24 @@ set_texcoord_3d(bool texcoord_3d) { } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_texcoord_3d -// Access: Published -// Description: See set_texcoord_3d(). -//////////////////////////////////////////////////////////////////// +/** + * See set_texcoord_3d(). + */ INLINE bool ProjectionScreen:: get_texcoord_3d() const { return _texcoord_3d; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_vignette_on -// Access: Published -// Description: Specifies whether vertex-based vignetting should be -// on. When this is enabled, vertex color will be set -// on the screen vertices to color the screen two -// distinct colors, usually white and black, for the -// parts of the screen in front of and outside the lens' -// frustum, respectively. When this is not enabled, the -// screen color will be left alone. -// -// This effect generally looks terrible, but it does -// at least make the boundaries of the lens clear. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether vertex-based vignetting should be on. When this is + * enabled, vertex color will be set on the screen vertices to color the + * screen two distinct colors, usually white and black, for the parts of the + * screen in front of and outside the lens' frustum, respectively. When this + * is not enabled, the screen color will be left alone. + * + * This effect generally looks terrible, but it does at least make the + * boundaries of the lens clear. + */ INLINE void ProjectionScreen:: set_vignette_on(bool vignette_on) { _vignette_on = vignette_on; @@ -186,113 +146,86 @@ set_vignette_on(bool vignette_on) { } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_vignette_on -// Access: Published -// Description: Returns true if vertex-based vignetting is on, false -// otherwise. See set_vignette_on(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if vertex-based vignetting is on, false otherwise. See + * set_vignette_on(). + */ INLINE bool ProjectionScreen:: get_vignette_on() const { return _vignette_on; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_vignette_color -// Access: Published -// Description: Specifies the color the screen will be painted at the -// portions outside of the lens' frustum; i.e. where the -// lens can't see it or illuminate it. This color is -// only used if the vignette_on flag is true; see -// set_vignette_on(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the color the screen will be painted at the portions outside of + * the lens' frustum; i.e. where the lens can't see it or illuminate it. + * This color is only used if the vignette_on flag is true; see + * set_vignette_on(). + */ INLINE void ProjectionScreen:: set_vignette_color(const LColor &vignette_color) { _vignette_color = vignette_color; _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_vignette_color -// Access: Published -// Description: Returns the color the screen will be painted at the -// portions outside of the lens' frustum. See -// set_vignette_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color the screen will be painted at the portions outside of the + * lens' frustum. See set_vignette_color(). + */ INLINE const LColor &ProjectionScreen:: get_vignette_color() const { return _vignette_color; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_frame_color -// Access: Published -// Description: Specifies the color the screen will be painted at the -// portions outside of the lens' frustum; i.e. where the -// lens can't see it or illuminate it. This color is -// only used if the vignette_on flag is true; see -// set_vignette_on(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the color the screen will be painted at the portions outside of + * the lens' frustum; i.e. where the lens can't see it or illuminate it. + * This color is only used if the vignette_on flag is true; see + * set_vignette_on(). + */ INLINE void ProjectionScreen:: set_frame_color(const LColor &frame_color) { _frame_color = frame_color; _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_frame_color -// Access: Published -// Description: Returns the color the screen will be painted at the -// portions outside of the lens' frustum. See -// set_frame_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color the screen will be painted at the portions outside of the + * lens' frustum. See set_frame_color(). + */ INLINE const LColor &ProjectionScreen:: get_frame_color() const { return _frame_color; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_auto_recompute -// Access: Published -// Description: Sets the auto_recompute flag. When this is true, -// the ProjectionScreen will always be recomputed if -// necessary before the frame is drawn; when it is -// false, an explicit call to recompute_if_stale() may -// be required. -//////////////////////////////////////////////////////////////////// +/** + * Sets the auto_recompute flag. When this is true, the ProjectionScreen will + * always be recomputed if necessary before the frame is drawn; when it is + * false, an explicit call to recompute_if_stale() may be required. + */ INLINE void ProjectionScreen:: set_auto_recompute(bool auto_recompute) { _auto_recompute = auto_recompute; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_auto_recompute -// Access: Published -// Description: Returns the auto_recompute flag. When this is true, -// the ProjectionScreen will always be recomputed if -// necessary before the frame is drawn; when it is -// false, an explicit call to recompute_if_stale() may -// be required. -//////////////////////////////////////////////////////////////////// +/** + * Returns the auto_recompute flag. When this is true, the ProjectionScreen + * will always be recomputed if necessary before the frame is drawn; when it + * is false, an explicit call to recompute_if_stale() may be required. + */ INLINE bool ProjectionScreen:: get_auto_recompute() const { return _auto_recompute; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::get_last_screen -// Access: Published -// Description: Returns an UpdateSeq corresponding to the last time a -// screen mesh was generated for the ProjectionScreen. -// Each time generate_screen() is called, this number is -// incremented; this allows other objects (like -// NonlinearImager) to know when they need to recompute -// themselves. -//////////////////////////////////////////////////////////////////// +/** + * Returns an UpdateSeq corresponding to the last time a screen mesh was + * generated for the ProjectionScreen. Each time generate_screen() is called, + * this number is incremented; this allows other objects (like + * NonlinearImager) to know when they need to recompute themselves. + */ INLINE const UpdateSeq &ProjectionScreen:: get_last_screen() const { return _last_screen; } - diff --git a/panda/src/distort/projectionScreen.cxx b/panda/src/distort/projectionScreen.cxx index 3d424f6601..fd319031e6 100644 --- a/panda/src/distort/projectionScreen.cxx +++ b/panda/src/distort/projectionScreen.cxx @@ -1,16 +1,15 @@ -// Filename: projectionScreen.cxx -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file projectionScreen.cxx + * @author drose + * @date 2001-12-11 + */ #include "projectionScreen.h" #include "geomNode.h" @@ -27,11 +26,9 @@ TypeHandle ProjectionScreen::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ProjectionScreen:: ProjectionScreen(const string &name) : PandaNode(name) { @@ -50,20 +47,16 @@ ProjectionScreen(const string &name) : PandaNode(name) _auto_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ProjectionScreen:: ~ProjectionScreen() { } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ProjectionScreen:: ProjectionScreen(const ProjectionScreen ©) : PandaNode(copy), @@ -79,44 +72,34 @@ ProjectionScreen(const ProjectionScreen ©) : _stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *ProjectionScreen:: make_copy() const { return new ProjectionScreen(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool ProjectionScreen:: cull_callback(CullTraverser *, CullTraverserData &data) { if (_auto_recompute) { @@ -125,18 +108,14 @@ cull_callback(CullTraverser *, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::set_projector -// Access: Published -// Description: Specifies the LensNode that is to serve as the -// projector for this screen. The relative position of -// the LensNode to the ProjectionScreen, as well as the -// properties of the lens associated with the LensNode, -// determines the UV's that will be assigned to the -// geometry within the ProjectionScreen. -// -// The NodePath must refer to a LensNode (or a Camera). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the LensNode that is to serve as the projector for this screen. + * The relative position of the LensNode to the ProjectionScreen, as well as + * the properties of the lens associated with the LensNode, determines the + * UV's that will be assigned to the geometry within the ProjectionScreen. + * + * The NodePath must refer to a LensNode (or a Camera). + */ void ProjectionScreen:: set_projector(const NodePath &projector) { _projector_node = (LensNode *)NULL; @@ -148,42 +127,34 @@ set_projector(const NodePath &projector) { } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::generate_screen -// Access: Published -// Description: Synthesizes a polygon mesh based on the projection -// area of the indicated projector. This generates and -// returns a new GeomNode but does not automatically -// parent it to the ProjectionScreen node; see -// regenerate_screen(). -// -// The specified projector need not be the same as the -// projector given to the ProjectionScreen with -// set_projector() (although this is often what you -// want). -// -// num_x_verts and num_y_verts specify the number of -// vertices to make in the grid across the horizontal -// and vertical dimension of the projector, -// respectively; distance represents the approximate -// distance of the screen from the lens center. -// -// The fill_ratio parameter specifies the fraction of -// the image to cover. If it is 1.0, the entire image -// is shown full-size; if it is 0.9, 10% of the image -// around the edges is not part of the grid (and the -// grid is drawn smaller by the same 10%). This is -// intended to work around graphics drivers that tend to -// show dark edges or other unsatisfactory artifacts -// around the edges of textures: render the texture -// larger than necessary by a certain fraction, and make -// the screen smaller by the inverse fraction. -//////////////////////////////////////////////////////////////////// +/** + * Synthesizes a polygon mesh based on the projection area of the indicated + * projector. This generates and returns a new GeomNode but does not + * automatically parent it to the ProjectionScreen node; see + * regenerate_screen(). + * + * The specified projector need not be the same as the projector given to the + * ProjectionScreen with set_projector() (although this is often what you + * want). + * + * num_x_verts and num_y_verts specify the number of vertices to make in the + * grid across the horizontal and vertical dimension of the projector, + * respectively; distance represents the approximate distance of the screen + * from the lens center. + * + * The fill_ratio parameter specifies the fraction of the image to cover. If + * it is 1.0, the entire image is shown full-size; if it is 0.9, 10% of the + * image around the edges is not part of the grid (and the grid is drawn + * smaller by the same 10%). This is intended to work around graphics drivers + * that tend to show dark edges or other unsatisfactory artifacts around the + * edges of textures: render the texture larger than necessary by a certain + * fraction, and make the screen smaller by the inverse fraction. + */ PT(GeomNode) ProjectionScreen:: generate_screen(const NodePath &projector, const string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, PN_stdfloat fill_ratio) { - nassertr(!projector.is_empty() && + nassertr(!projector.is_empty() && projector.node()->is_of_type(LensNode::get_class_type()), NULL); LensNode *projector_node = DCAST(LensNode, projector.node()); @@ -197,8 +168,8 @@ generate_screen(const NodePath &projector, const string &screen_name, // Create a GeomNode to hold this mesh. PT(GeomNode) geom_node = new GeomNode(screen_name); - // Now compute all the vertices for the screen. These are arranged - // in order from left to right and bottom to top. + // Now compute all the vertices for the screen. These are arranged in order + // from left to right and bottom to top. int num_verts = num_x_verts * num_y_verts; Lens *lens = projector_node->get_lens(); PN_stdfloat t = (distance - lens->get_near()) / (lens->get_far() - lens->get_near()); @@ -211,35 +182,35 @@ generate_screen(const NodePath &projector, const string &screen_name, Geom::UH_dynamic); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter normal(vdata, InternalName::get_normal()); - + for (int yi = 0; yi < num_y_verts; yi++) { for (int xi = 0; xi < num_x_verts; xi++) { LPoint2 film = LPoint2((PN_stdfloat)xi * x_scale - 1.0f, (PN_stdfloat)yi * y_scale - 1.0f); - + // Reduce the image by the fill ratio. film *= fill_ratio; - + LPoint3 near_point, far_point; lens->extrude(film, near_point, far_point); LPoint3 point = near_point + t * (far_point - near_point); - - // Normals aren't often needed on projection screens, but you - // never know. + + // Normals aren't often needed on projection screens, but you never + // know. LVector3 norm; lens->extrude_vec(film, norm); - + vertex.add_data3(point * rel_mat); normal.add_data3(-normalize(norm * rel_mat)); } } nassertr(vdata->get_num_rows() == num_verts, NULL); - // Now synthesize a triangle mesh. We run triangle strips - // horizontally across the grid. + // Now synthesize a triangle mesh. We run triangle strips horizontally + // across the grid. PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); - // Fill up the index array into the vertices. This lays out the - // order of the vertices in each tristrip. + // Fill up the index array into the vertices. This lays out the order of + // the vertices in each tristrip. int ti, si; for (ti = 1; ti < num_y_verts; ti++) { strip->add_vertex(ti * num_x_verts); @@ -253,7 +224,7 @@ generate_screen(const NodePath &projector, const string &screen_name, PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + geom_node->add_geom(geom); _stale = true; @@ -261,13 +232,10 @@ generate_screen(const NodePath &projector, const string &screen_name, return geom_node; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::regenerate_screen -// Access: Published -// Description: Removes all the children from the ProjectionScreen -// node, and adds the newly generated child returned by -// generate_screen(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all the children from the ProjectionScreen node, and adds the newly + * generated child returned by generate_screen(). + */ void ProjectionScreen:: regenerate_screen(const NodePath &projector, const string &screen_name, int num_x_verts, int num_y_verts, PN_stdfloat distance, @@ -276,35 +244,29 @@ regenerate_screen(const NodePath &projector, const string &screen_name, remove_all_children(); // And attach a new child. - PT(GeomNode) geom_node = - generate_screen(projector, screen_name, num_x_verts, num_y_verts, + PT(GeomNode) geom_node = + generate_screen(projector, screen_name, num_x_verts, num_y_verts, distance, fill_ratio); add_child(geom_node); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_flat_mesh -// Access: Published -// Description: Generates a deep copy of the hierarchy at the -// ProjectionScreen node and below, with vertices -// flattened into two dimensions as if they were seen by -// the indicated camera node. -// -// This is useful for rendering an image as seen through -// a non-linear lens. The resulting mesh will have -// vertices in the range [-1, 1] in both x and y, and -// may be then rendered with an ordinary orthographic -// lens, to generate the effect of seeing the image -// through the specified non-linear lens. -// -// The returned node has no parent; it is up to the -// caller to parent it somewhere or store it so that it -// does not get dereferenced and deleted. -//////////////////////////////////////////////////////////////////// +/** + * Generates a deep copy of the hierarchy at the ProjectionScreen node and + * below, with vertices flattened into two dimensions as if they were seen by + * the indicated camera node. + * + * This is useful for rendering an image as seen through a non-linear lens. + * The resulting mesh will have vertices in the range [-1, 1] in both x and y, + * and may be then rendered with an ordinary orthographic lens, to generate + * the effect of seeing the image through the specified non-linear lens. + * + * The returned node has no parent; it is up to the caller to parent it + * somewhere or store it so that it does not get dereferenced and deleted. + */ PT(PandaNode) ProjectionScreen:: make_flat_mesh(const NodePath &this_np, const NodePath &camera) { nassertr(!this_np.is_empty() && this_np.node() == this, NULL); - nassertr(!camera.is_empty() && + nassertr(!camera.is_empty() && camera.node()->is_of_type(LensNode::get_class_type()), NULL); LensNode *camera_node = DCAST(LensNode, camera.node()); @@ -322,54 +284,41 @@ make_flat_mesh(const NodePath &this_np, const NodePath &camera) { return top; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute -// Access: Published -// Description: Recomputes all the UV's for geometry below the -// ProjectionScreen node, as if the texture were -// projected from the associated projector. -// -// This function is normally called automatically -// whenever the relevant properties change, so it should -// not normally need to be called directly by the user. -// However, it does no harm to call this if there is any -// doubt. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all the UV's for geometry below the ProjectionScreen node, as if + * the texture were projected from the associated projector. + * + * This function is normally called automatically whenever the relevant + * properties change, so it should not normally need to be called directly by + * the user. However, it does no harm to call this if there is any doubt. + */ void ProjectionScreen:: recompute() { NodePath this_np(NodePath::any_path(this)); do_recompute(this_np); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_if_stale -// Access: Published -// Description: Calls recompute() only if the relative transform -// between the ProjectionScreen and the projector has -// changed, or if any other relevant property has -// changed. Returns true if recomputed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Calls recompute() only if the relative transform between the + * ProjectionScreen and the projector has changed, or if any other relevant + * property has changed. Returns true if recomputed, false otherwise. + */ bool ProjectionScreen:: recompute_if_stale() { NodePath this_np(NodePath::any_path(this)); return recompute_if_stale(this_np); } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_if_stale -// Access: Published -// Description: Calls recompute() only if the relative transform -// between the ProjectionScreen and the projector has -// changed, or if any other relevant property has -// changed. Returns true if recomputed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Calls recompute() only if the relative transform between the + * ProjectionScreen and the projector has changed, or if any other relevant + * property has changed. Returns true if recomputed, false otherwise. + */ bool ProjectionScreen:: recompute_if_stale(const NodePath &this_np) { nassertr(!this_np.is_empty() && this_np.node() == this, false); - if (_projector_node != (LensNode *)NULL && + if (_projector_node != (LensNode *)NULL && _projector_node->get_lens() != (Lens *)NULL) { UpdateSeq lens_change = _projector_node->get_lens()->get_last_change(); if (_stale || lens_change != _projector_lens_change) { @@ -392,14 +341,12 @@ recompute_if_stale(const NodePath &this_np) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::do_recompute -// Access: Private -// Description: Starts the recomputation process. -//////////////////////////////////////////////////////////////////// +/** + * Starts the recomputation process. + */ void ProjectionScreen:: do_recompute(const NodePath &this_np) { - if (_projector_node != (LensNode *)NULL && + if (_projector_node != (LensNode *)NULL && _projector_node->get_lens() != (Lens *)NULL) { recompute_node(this_np, _rel_top_mat, _computed_rel_top_mat); @@ -411,14 +358,11 @@ do_recompute(const NodePath &this_np) { } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_node -// Access: Private -// Description: Recurses over all geometry at the indicated node and -// below, looking for GeomNodes that want to have new -// UV's computed. When a new transform space is -// encountered, a new relative matrix is computed. -//////////////////////////////////////////////////////////////////// +/** + * Recurses over all geometry at the indicated node and below, looking for + * GeomNodes that want to have new UV's computed. When a new transform space + * is encountered, a new relative matrix is computed. + */ void ProjectionScreen:: recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { @@ -428,10 +372,10 @@ recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, } if (node->is_exact_type(SwitchNode::get_class_type())) { - // We make a special case for switch nodes only. Other kinds of - // selective child nodes, like LOD's and sequence nodes, will get - // all of their children traversed; switch nodes will only - // traverse the currently active child. + // We make a special case for switch nodes only. Other kinds of selective + // child nodes, like LOD's and sequence nodes, will get all of their + // children traversed; switch nodes will only traverse the currently + // active child. int i = DCAST(SwitchNode, node)->get_visible_child(); if (i >= 0 && i < node->get_num_children()) { PandaNode *child = node->get_child(i); @@ -448,13 +392,10 @@ recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_child -// Access: Private -// Description: Works in conjunction with recompute_node() to recurse -// over the whole graph. This is called on each child -// of a given node. -//////////////////////////////////////////////////////////////////// +/** + * Works in conjunction with recompute_node() to recurse over the whole graph. + * This is called on each child of a given node. + */ void ProjectionScreen:: recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { @@ -462,8 +403,8 @@ recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, const TransformState *transform = child->get_transform(); if (!transform->is_identity()) { - // This child node has a transform; therefore, we must recompute - // the relative matrix from this point. + // This child node has a transform; therefore, we must recompute the + // relative matrix from this point. LMatrix4 new_rel_mat; bool computed_new_rel_mat = false; @@ -473,21 +414,19 @@ recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, } recompute_node(np, new_rel_mat, computed_new_rel_mat); - + } else { - // This child has no transform, so we can use the same transform - // space from before. + // This child has no transform, so we can use the same transform space + // from before. recompute_node(np, rel_mat, computed_rel_mat); } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_geom_node -// Access: Private -// Description: Recomputes the UV's just for the indicated GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the UV's just for the indicated GeomNode. + */ void ProjectionScreen:: -recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, +recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat) { GeomNode *node = DCAST(GeomNode, np.node()); if (!computed_rel_mat) { @@ -512,7 +451,7 @@ recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, int num_geoms = node->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { PT(Geom) geom = node->modify_geom(i); - distort_cat.debug() + distort_cat.debug() << " " << *node << " got geom " << geom << ", cache_ref = " << geom->get_cache_ref_count() << "\n"; geom->test_ref_count_integrity(); @@ -520,23 +459,21 @@ recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::recompute_geom -// Access: Private -// Description: Recomputes the UV's just for the indicated Geom. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the UV's just for the indicated Geom. + */ void ProjectionScreen:: recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { static const LMatrix4 lens_to_uv (0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f); static const LMatrix4 lens_to_uv_inverted (0.5f, 0.0f, 0.0f, 0.0f, - 0.0f,-0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f,-0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f); Thread *current_thread = Thread::get_current_thread(); @@ -575,21 +512,21 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { GeomVertexWriter texcoord(modify_vdata, _texcoord_name, current_thread); GeomVertexWriter color(modify_vdata, current_thread); GeomVertexReader vertex(animated_vdata, InternalName::get_vertex(), current_thread); - + if (_vignette_on) { color.set_column(InternalName::get_color()); } - + while (!vertex.is_at_end()) { LVertex vert = vertex.get_data3(); - + // For each vertex, project to the film plane. LPoint3 vert3d = vert * rel_mat; LPoint3 film(0.0f, 0.0f, 0.0f); bool good = lens->project(vert3d, film); - - // Now the lens gives us coordinates in the range [-1, 1]. - // Rescale these to [0, 1]. + + // Now the lens gives us coordinates in the range [-1, 1]. Rescale these + // to [0, 1]. LPoint3 uvw = film * to_uv; if (good && _has_undist_lut) { @@ -597,11 +534,10 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { if (!_undist_lut.calc_bilinear_point(p, uvw[0], 1.0 - uvw[1])) { // Point is missing. - // We're better off keeping the point where it is, - // undistorted--it's probably close to where it should - // be--than we are changing it arbitrarily to (0, 0), which - // might be far away from where it should be. - //uvw.set(0, 0, 0); + // We're better off keeping the point where it is, undistorted--it's + // probably close to where it should be--than we are changing it + // arbitrarily to (0, 0), which might be far away from where it should + // be. uvw.set(0, 0, 0); good = false; } else { @@ -610,9 +546,9 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { } } texcoord.set_data3(uvw); - - // If we have vignette color in effect, color the vertex according - // to whether it fell in front of the lens or not. + + // If we have vignette color in effect, color the vertex according to + // whether it fell in front of the lens or not. if (_vignette_on) { if (good) { color.set_data4(_frame_color); @@ -623,15 +559,12 @@ recompute_geom(Geom *geom, const LMatrix4 &rel_mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_mesh_node -// Access: Private -// Description: Recurses over all geometry at the indicated node and -// below, and generates a corresponding node hierarchy -// with all the geometry copied, but flattened into 2-d, -// as seen from the indicated camera. Returns the newly -// created node, or NULL if no node was created. -//////////////////////////////////////////////////////////////////// +/** + * Recurses over all geometry at the indicated node and below, and generates a + * corresponding node hierarchy with all the geometry copied, but flattened + * into 2-d, as seen from the indicated camera. Returns the newly created + * node, or NULL if no node was created. + */ PandaNode *ProjectionScreen:: make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, const NodePath &camera, @@ -645,8 +578,8 @@ make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, new_node = node->make_copy(); new_node->clear_transform(); } else { - // If we can't safely flatten the node, just make a plain node in - // its place. + // If we can't safely flatten the node, just make a plain node in its + // place. new_node = new PandaNode(node->get_name()); new_node->set_state(node->get_state()); } @@ -657,12 +590,10 @@ make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np, return new_node; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_mesh_children -// Access: Private -// Description: Walks over the list of children for the indicated -// node, calling make_mesh_node() on each one. -//////////////////////////////////////////////////////////////////// +/** + * Walks over the list of children for the indicated node, calling + * make_mesh_node() on each one. + */ void ProjectionScreen:: make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, const NodePath &camera, @@ -675,35 +606,31 @@ make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, const TransformState *transform = child->get_transform(); if (!transform->is_identity()) { - // This child node has a transform; therefore, we must recompute - // the relative matrix from this point. + // This child node has a transform; therefore, we must recompute the + // relative matrix from this point. LMatrix4 new_rel_mat; bool computed_new_rel_mat = false; new_child = make_mesh_node(new_node, WorkingNodePath(np, child), camera, new_rel_mat, computed_new_rel_mat); } else { - // This child has no transform, so we can use the same transform - // space from before. + // This child has no transform, so we can use the same transform space + // from before. new_child = make_mesh_node(new_node, WorkingNodePath(np, child), camera, rel_mat, computed_rel_mat); } if (new_child != NULL) { - // Copy all of the render state (except TransformState) to the - // new arc. + // Copy all of the render state (except TransformState) to the new arc. new_child->set_state(child->get_state()); } } } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_mesh_geom_node -// Access: Private -// Description: Makes a new GeomNode, just like the given one, except -// flattened into two dimensions as seen by the -// indicated camera. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new GeomNode, just like the given one, except flattened into two + * dimensions as seen by the indicated camera. + */ PT(GeomNode) ProjectionScreen:: make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, LMatrix4 &rel_mat, bool &computed_rel_mat) { @@ -721,7 +648,7 @@ make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, int num_geoms = node->get_num_geoms(); for (int i = 0; i < num_geoms; i++) { const Geom *geom = node->get_geom(i); - PT(Geom) new_geom = + PT(Geom) new_geom = make_mesh_geom(geom, lens_node->get_lens(), rel_mat); if (new_geom != (Geom *)NULL) { new_node->add_geom(new_geom, node->get_geom_state(i)); @@ -731,20 +658,17 @@ make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, return new_node; } -//////////////////////////////////////////////////////////////////// -// Function: ProjectionScreen::make_mesh_geom -// Access: Private -// Description: Makes a new Geom, just like the given one, except -// flattened into two dimensions as seen by the -// indicated lens. Any triangle in the original mesh -// that involves an unprojectable vertex is eliminated. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new Geom, just like the given one, except flattened into two + * dimensions as seen by the indicated lens. Any triangle in the original + * mesh that involves an unprojectable vertex is eliminated. + */ PT(Geom) ProjectionScreen:: make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat) { static const LMatrix4 lens_to_uv (0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.5f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, 0.5f, 0.5f, 0.0f, 1.0f); static const LMatrix4 uv_to_lens = invert(lens_to_uv); @@ -756,19 +680,19 @@ make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat) { GeomVertexRewriter vertex(vdata, InternalName::get_vertex()); while (!vertex.is_at_end()) { LVertex vert = vertex.get_data3(); - - // Project each vertex into the film plane, but use three - // dimensions so the Z coordinate remains meaningful. + + // Project each vertex into the film plane, but use three dimensions so + // the Z coordinate remains meaningful. LPoint3 vert3d = vert * rel_mat; LPoint3 film(0.0f, 0.0f, 0.0f); bool good = lens->project(vert3d, film); if (good && _has_undist_lut) { - - // Now the lens gives us coordinates in the range [-1, 1]. - // Rescale these to [0, 1]. + + // Now the lens gives us coordinates in the range [-1, 1]. Rescale these + // to [0, 1]. LPoint3 uvw = film * lens_to_uv; - + LPoint3f p; if (!_undist_lut.calc_bilinear_point(p, uvw[0], 1.0 - uvw[1])) { // Point is missing. @@ -783,7 +707,7 @@ make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat) { } vertex.set_data3(film); - } - + } + return new_geom; } diff --git a/panda/src/distort/projectionScreen.h b/panda/src/distort/projectionScreen.h index 6d4b8bc215..963e38370a 100644 --- a/panda/src/distort/projectionScreen.h +++ b/panda/src/distort/projectionScreen.h @@ -1,16 +1,15 @@ -// Filename: projectionScreen.h -// Created by: drose (11Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file projectionScreen.h + * @author drose + * @date 2001-12-11 + */ #ifndef PROJECTIONSCREEN_H #define PROJECTIONSCREEN_H @@ -28,30 +27,24 @@ class Geom; class WorkingNodePath; -//////////////////////////////////////////////////////////////////// -// Class : ProjectionScreen -// Description : A ProjectionScreen implements a simple system for -// projective texturing. The ProjectionScreen node is -// the parent of a hierarchy of geometry that is -// considered a "screen"; the ProjectionScreen will -// automatically recompute all the UV's (for a -// particular texture stage) on its subordinate geometry -// according to the relative position and lens -// parameters of the indicated LensNode. -// -// All this does is recompute UV's; the caller is -// responsible for applying the appropriate texture(s) -// to the geometry. -// -// This does not take advantage of any hardware-assisted -// projective texturing; all of the UV's are computed in -// the CPU. (Use NodePath::project_texture() to enable -// hardware-assisted projective texturing.) However, -// the ProjectionScreen interface does support any kind -// of lens, linear or nonlinear, that might be defined -// using the Lens interface, including fisheye and -// cylindrical lenses. -//////////////////////////////////////////////////////////////////// +/** + * A ProjectionScreen implements a simple system for projective texturing. + * The ProjectionScreen node is the parent of a hierarchy of geometry that is + * considered a "screen"; the ProjectionScreen will automatically recompute + * all the UV's (for a particular texture stage) on its subordinate geometry + * according to the relative position and lens parameters of the indicated + * LensNode. + * + * All this does is recompute UV's; the caller is responsible for applying the + * appropriate texture(s) to the geometry. + * + * This does not take advantage of any hardware-assisted projective texturing; + * all of the UV's are computed in the CPU. (Use NodePath::project_texture() + * to enable hardware-assisted projective texturing.) However, the + * ProjectionScreen interface does support any kind of lens, linear or + * nonlinear, that might be defined using the Lens interface, including + * fisheye and cylindrical lenses. + */ class EXPCL_PANDAFX ProjectionScreen : public PandaNode { PUBLISHED: ProjectionScreen(const string &name = ""); @@ -121,7 +114,7 @@ private: void make_mesh_children(PandaNode *new_node, const WorkingNodePath &np, const NodePath &camera, LMatrix4 &rel_mat, bool &computed_rel_mat); - PT(GeomNode) make_mesh_geom_node(const WorkingNodePath &np, + PT(GeomNode) make_mesh_geom_node(const WorkingNodePath &np, const NodePath &camera, LMatrix4 &rel_mat, bool &computed_rel_mat); diff --git a/panda/src/doc/sampleClass.I b/panda/src/doc/sampleClass.I index fcecde54e1..05ea9c053b 100644 --- a/panda/src/doc/sampleClass.I +++ b/panda/src/doc/sampleClass.I @@ -1,23 +1,19 @@ -// Filename: sampleClass.I -// Created by: drose (10Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sampleClass.I + * @author drose + * @date 2000-06-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SampleClass:: SampleClass(const SampleClass ©) : _public_data_member(copy._public_data_member), @@ -26,36 +22,27 @@ SampleClass(const SampleClass ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SampleClass:: ~SampleClass() { } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::set_flag -// Access: Public -// Description: A few sentences describing the purpose of flag, the -// legal values it may be set to, and the implications -// of setting it to certain values. -//////////////////////////////////////////////////////////////////// +/** + * A few sentences describing the purpose of flag, the legal values it may be + * set to, and the implications of setting it to certain values. + */ INLINE void SampleClass:: set_flag(int flag) { _flag = flag; } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::get_flag -// Access: Public -// Description: A few sentences describing the purpose of flag, the -// legal values it may be set to, and the implications -// of setting it to certain values. -//////////////////////////////////////////////////////////////////// +/** + * A few sentences describing the purpose of flag, the legal values it may be + * set to, and the implications of setting it to certain values. + */ INLINE int SampleClass:: get_flag() const { return _flag; } - diff --git a/panda/src/doc/sampleClass.cxx b/panda/src/doc/sampleClass.cxx index 1f87dac93e..95f6f41e6b 100644 --- a/panda/src/doc/sampleClass.cxx +++ b/panda/src/doc/sampleClass.cxx @@ -1,36 +1,31 @@ -// Filename: sampleClass.cxx -// Created by: drose (10Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sampleClass.cxx + * @author drose + * @date 2000-06-10 + */ #include "sampleClass.h" TypeHandle SampleClass::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SampleClass:: SampleClass() { } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::public_method -// Access: Public -// Description: A few sentences describing what public_method is -// supposed to do and why you'd want to call it. -//////////////////////////////////////////////////////////////////// +/** + * A few sentences describing what public_method is supposed to do and why + * you'd want to call it. + */ int SampleClass:: public_method() { switch (_private_data_member) { @@ -45,12 +40,9 @@ public_method() { } } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::protected_method -// Access: Protected -// Description: A few sentences describing what protected_method is -// supposed to do. -//////////////////////////////////////////////////////////////////// +/** + * A few sentences describing what protected_method is supposed to do. + */ bool SampleClass:: protected_method() { if (_flag > 0) { @@ -61,12 +53,9 @@ protected_method() { } } -//////////////////////////////////////////////////////////////////// -// Function: SampleClass::private_method -// Access: Private -// Description: A few sentences describing what private_method is -// supposed to do. -//////////////////////////////////////////////////////////////////// +/** + * A few sentences describing what private_method is supposed to do. + */ void SampleClass:: private_method() { } diff --git a/panda/src/doc/sampleClass.h b/panda/src/doc/sampleClass.h index fd4207c08d..e957d47d67 100644 --- a/panda/src/doc/sampleClass.h +++ b/panda/src/doc/sampleClass.h @@ -1,24 +1,23 @@ -// Filename: sampleClass.h -// Created by: drose (10Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sampleClass.h + * @author drose + * @date 2000-06-10 + */ #ifndef SAMPLECLASS_H #define SAMPLECLASS_H -// This file shows some sample code that illustrates our general -// naming and style conventions for Panda coding. Note that there is -// generally one .h file per class, with the .h file named after the -// class but the first letter lowercase. +// This file shows some sample code that illustrates our general naming and +// style conventions for Panda coding. Note that there is generally one .h +// file per class, with the .h file named after the class but the first letter +// lowercase. #include "pandabase.h" @@ -30,13 +29,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : SampleClass -// Description : A basic description of the function and purpose of -// SampleClass. Note that class names are generally -// mixed case, no underscore, beginning with a capital -// letter. -//////////////////////////////////////////////////////////////////// +/** + * A basic description of the function and purpose of SampleClass. Note that + * class names are generally mixed case, no underscore, beginning with a + * capital letter. + */ class EXPCL_PANDA SampleClass : public TypedObject { public: enum NestedEnum { @@ -53,13 +50,12 @@ public: INLINE SampleClass(const SampleClass ©); INLINE ~SampleClass(); - // Note that inline function bodies are generally not given here in - // the .h file--they're defined in the associated .I file. + // Note that inline function bodies are generally not given here in the .h + // file--they're defined in the associated .I file. - // Method names are generally lower case, with underscores - // separating words. Accessors are generally of the form set_*() - // and get_*(). Respect the const convention for methods which - // should be const. + // Method names are generally lower case, with underscores separating words. + // Accessors are generally of the form set_*() and get_*(). Respect the + // const convention for methods which should be const. INLINE void set_flag(int flag); INLINE int get_flag() const; @@ -74,9 +70,8 @@ private: public: - // Data members, whether private or public, are generally lower - // case, with underscores separating words, and beginning with a - // leading underscore. + // Data members, whether private or public, are generally lower case, with + // underscores separating words, and beginning with a leading underscore. bool _public_data_member; @@ -86,10 +81,10 @@ private: int _flag; - // The TypeHandle stuff, below, need be present only for classes - // that inherit from TypedObject. Classes that do not inherit from - // TypedObject may optionally define just the non-virtual methods - // below: get_class_type(), init_type(). + // The TypeHandle stuff, below, need be present only for classes that + // inherit from TypedObject. Classes that do not inherit from TypedObject + // may optionally define just the non-virtual methods below: + // get_class_type(), init_type(). public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/downloader/bioPtr.I b/panda/src/downloader/bioPtr.I index 51278cf011..a1e1f13e1d 100644 --- a/panda/src/downloader/bioPtr.I +++ b/panda/src/downloader/bioPtr.I @@ -1,94 +1,74 @@ -// Filename: bioPtr.I -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioPtr.I + * @author drose + * @date 2002-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioPtr:: BioPtr(BIO *bio) : _bio(bio) { } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::operator * -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BIO &BioPtr:: operator *() const { return *_bio; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::operator -> -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BIO *BioPtr:: operator ->() const { return _bio; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::operator typecast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioPtr:: operator BIO * () const { return _bio; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::get_bio -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BioPtr:: set_bio(BIO *bio) { _bio = bio; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::get_bio -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BIO *BioPtr:: get_bio() const { return _bio; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::get_server_name -// Access: Public -// Description: Returns the name of the server we are (or should be) -// connected to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the server we are (or should be) connected to. + */ INLINE const string &BioPtr:: get_server_name() const { return _server_name; } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::get_port -// Access: Public -// Description: Returns the port on which we are (or should be) -// connected. -//////////////////////////////////////////////////////////////////// +/** + * Returns the port on which we are (or should be) connected. + */ INLINE int BioPtr:: get_port() const { return _port; diff --git a/panda/src/downloader/bioPtr.cxx b/panda/src/downloader/bioPtr.cxx index 9bb03ab017..1aee90d207 100644 --- a/panda/src/downloader/bioPtr.cxx +++ b/panda/src/downloader/bioPtr.cxx @@ -1,16 +1,15 @@ -// Filename: bioPtr.cxx -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioPtr.cxx + * @author drose + * @date 2002-10-15 + */ #include "bioPtr.h" @@ -19,23 +18,20 @@ #include "urlSpec.h" #include "config_downloader.h" -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::Constructor -// Access: Public -// Description: This flavor of the constructor automatically creates -// a socket BIO and feeds it the server and port name -// from the indicated URL. It doesn't call -// BIO_do_connect(), though. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor automatically creates a socket BIO and feeds + * it the server and port name from the indicated URL. It doesn't call + * BIO_do_connect(), though. + */ BioPtr:: BioPtr(const URLSpec &url) { if (url.get_scheme() == "file") { // We're just reading a disk file. string filename = URLSpec::unquote(url.get_path()); -#ifdef _WIN32 - // On Windows, we have to munge the filename specially, because it's - // been URL-munged. It might begin with a leading slash as well as - // a drive letter. Clean up that nonsense. +#ifdef _WIN32 + // On Windows, we have to munge the filename specially, because it's been + // URL-munged. It might begin with a leading slash as well as a drive + // letter. Clean up that nonsense. if (!filename.empty()) { if (filename[0] == '/' || filename[0] == '\\') { Filename fname = Filename::from_os_specific(filename.substr(1)); @@ -60,11 +56,9 @@ BioPtr(const URLSpec &url) { } } -//////////////////////////////////////////////////////////////////// -// Function: BioPtr::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BioPtr:: ~BioPtr() { if (_bio != (BIO *)NULL) { @@ -72,7 +66,7 @@ BioPtr:: downloader_cat.debug() << "Dropping connection to " << _server_name << ":" << _port << "\n"; } - + BIO_free_all(_bio); _bio = (BIO *)NULL; } diff --git a/panda/src/downloader/bioPtr.h b/panda/src/downloader/bioPtr.h index f50c239e9f..077a37ea84 100644 --- a/panda/src/downloader/bioPtr.h +++ b/panda/src/downloader/bioPtr.h @@ -1,16 +1,15 @@ -// Filename: bioPtr.h -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioPtr.h + * @author drose + * @date 2002-10-15 + */ #ifndef BIOPTR_H #define BIOPTR_H @@ -30,15 +29,12 @@ class URLSpec; -//////////////////////////////////////////////////////////////////// -// Class : BioPtr -// Description : A wrapper around an OpenSSL BIO object to make a -// reference-counting pointer to it. It appears that -// the OpenSSL library already uses reference counts on -// these things internally, but the interface doesn't -// appear to be public; so we might as well wrap the -// whole thing at the high level. -//////////////////////////////////////////////////////////////////// +/** + * A wrapper around an OpenSSL BIO object to make a reference-counting pointer + * to it. It appears that the OpenSSL library already uses reference counts + * on these things internally, but the interface doesn't appear to be public; + * so we might as well wrap the whole thing at the high level. + */ class EXPCL_PANDAEXPRESS BioPtr : public ReferenceCount { public: INLINE BioPtr(BIO *bio); @@ -54,7 +50,7 @@ public: INLINE const string &get_server_name() const; INLINE int get_port() const; - + private: BIO *_bio; string _server_name; @@ -67,5 +63,3 @@ private: #endif - - diff --git a/panda/src/downloader/bioStream.I b/panda/src/downloader/bioStream.I index 5ae0beb873..9cf1717e84 100644 --- a/panda/src/downloader/bioStream.I +++ b/panda/src/downloader/bioStream.I @@ -1,42 +1,34 @@ -// Filename: bioStream.I -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStream.I + * @author drose + * @date 2002-09-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IBioStream:: IBioStream() : ISocketStream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IBioStream:: IBioStream(BioPtr *source) : ISocketStream(&_buf) { open(source); } -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IBioStream &IBioStream:: open(BioPtr *source) { clear((ios_iostate)0); @@ -44,30 +36,24 @@ open(BioPtr *source) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: OBioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OBioStream:: OBioStream() : OSocketStream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: OBioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OBioStream:: OBioStream(BioPtr *source) : OSocketStream(&_buf) { open(source); } -//////////////////////////////////////////////////////////////////// -// Function: OBioStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OBioStream &OBioStream:: open(BioPtr *source) { clear((ios_iostate)0); @@ -75,30 +61,24 @@ open(BioPtr *source) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: BioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream:: BioStream() : SocketStream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: BioStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream:: BioStream(BioPtr *source) : SocketStream(&_buf) { open(source); } -//////////////////////////////////////////////////////////////////// -// Function: BioStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream &BioStream:: open(BioPtr *source) { clear((ios_iostate)0); diff --git a/panda/src/downloader/bioStream.cxx b/panda/src/downloader/bioStream.cxx index 7bae40c4bb..00b87ab8e1 100644 --- a/panda/src/downloader/bioStream.cxx +++ b/panda/src/downloader/bioStream.cxx @@ -1,29 +1,26 @@ -// Filename: bioStream.cxx -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStream.cxx + * @author drose + * @date 2002-09-25 + */ #include "bioStream.h" #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::is_closed -// Access: Public, Virtual -// Description: Returns true if the last eof condition was triggered -// because the socket has genuinely closed, or false if -// we can expect more data to come along shortly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last eof condition was triggered because the socket has + * genuinely closed, or false if we can expect more data to come along + * shortly. + */ bool IBioStream:: is_closed() { if (!_buf._read_open) { @@ -33,25 +30,20 @@ is_closed() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::close -// Access: Public, Virtual -// Description: Resets the BioStream to empty, but does not actually -// close the source BIO unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the BioStream to empty, but does not actually close the source BIO + * unless owns_source was true. + */ void IBioStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: OBioStream::is_closed -// Access: Public, Virtual -// Description: Returns true if the last write fail condition was -// triggered because the socket has genuinely closed, or -// false if we can expect to send more data along -// shortly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last write fail condition was triggered because the + * socket has genuinely closed, or false if we can expect to send more data + * along shortly. + */ bool OBioStream:: is_closed() { if (!_buf._write_open) { @@ -61,25 +53,20 @@ is_closed() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: OBioStream::close -// Access: Public, Virtual -// Description: Resets the BioStream to empty, but does not actually -// close the source BIO unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the BioStream to empty, but does not actually close the source BIO + * unless owns_source was true. + */ void OBioStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: BioStream::is_closed -// Access: Public, Virtual -// Description: Returns true if the last eof or failure condition was -// triggered because the socket has genuinely closed, or -// false if we can expect to read or send more data -// shortly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last eof or failure condition was triggered because the + * socket has genuinely closed, or false if we can expect to read or send more + * data shortly. + */ bool BioStream:: is_closed() { if (!_buf._read_open) { @@ -89,30 +76,25 @@ is_closed() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BioStream::close -// Access: Public, Virtual -// Description: Resets the BioStream to empty, but does not actually -// close the source BIO unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the BioStream to empty, but does not actually close the source BIO + * unless owns_source was true. + */ void BioStream:: close() { _buf.close(); } -//////////////////////////////////////////////////////////////////// -// Function: IBioStream::get_read_state -// Access: Public, Virtual -// Description: Returns an enum indicating how we are coming along in -// reading the document. -//////////////////////////////////////////////////////////////////// +/** + * Returns an enum indicating how we are coming along in reading the document. + */ IBioStream::ReadState IBioStream:: get_read_state() { // For an IBioStream, this method is meaningless, and always returns // RS_error. - // This method is intended for those specialized streams that scan - // through an HTTP document. + // This method is intended for those specialized streams that scan through + // an HTTP document. return RS_error; } diff --git a/panda/src/downloader/bioStream.h b/panda/src/downloader/bioStream.h index 7f0a6f2663..b47a17020a 100644 --- a/panda/src/downloader/bioStream.h +++ b/panda/src/downloader/bioStream.h @@ -1,16 +1,15 @@ -// Filename: bioStream.h -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStream.h + * @author drose + * @date 2002-09-25 + */ #ifndef BIOSTREAM_H #define BIOSTREAM_H @@ -23,15 +22,13 @@ #include "socketStream.h" #include "bioStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : IBioStream -// Description : An input stream object that reads data from an -// OpenSSL BIO object. This is used by the HTTPClient -// and HTTPChannel classes to provide a C++ interface -// to OpenSSL. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An input stream object that reads data from an OpenSSL BIO object. This is + * used by the HTTPClient and HTTPChannel classes to provide a C++ interface + * to OpenSSL. + * + * Seeking is not supported. + */ class EXPCL_PANDAEXPRESS IBioStream : public ISocketStream { public: INLINE IBioStream(); @@ -47,15 +44,13 @@ private: BioStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : OBioStream -// Description : An output stream object that writes data to an -// OpenSSL BIO object. This is used by the HTTPClient -// and HTTPChannel classes to provide a C++ interface -// to OpenSSL. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An output stream object that writes data to an OpenSSL BIO object. This is + * used by the HTTPClient and HTTPChannel classes to provide a C++ interface + * to OpenSSL. + * + * Seeking is not supported. + */ class EXPCL_PANDAEXPRESS OBioStream : public OSocketStream { public: INLINE OBioStream(); @@ -70,11 +65,10 @@ private: BioStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : BioStream -// Description : A bi-directional stream object that reads and writes -// data to an OpenSSL BIO object. -//////////////////////////////////////////////////////////////////// +/** + * A bi-directional stream object that reads and writes data to an OpenSSL BIO + * object. + */ class EXPCL_PANDAEXPRESS BioStream : public SocketStream { public: INLINE BioStream(); @@ -95,5 +89,3 @@ private: #endif - - diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index 0c07acbab1..d0bd04e027 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: bioStreamBuf.cxx -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStreamBuf.cxx + * @author drose + * @date 2002-09-25 + */ #include "bioStreamBuf.h" #include "config_downloader.h" @@ -30,11 +29,9 @@ typedef int streamsize; #endif /* HAVE_STREAMSIZE */ -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BioStreamBuf:: BioStreamBuf() { _read_open = false; @@ -49,8 +46,8 @@ BioStreamBuf() { #else allocate(); - // Chop the buffer in half. The bottom half goes to the get buffer; - // the top half goes to the put buffer. + // Chop the buffer in half. The bottom half goes to the get buffer; the top + // half goes to the put buffer. char *b = base(); char *t = ebuf(); char *m = b + (t - b) / 2; @@ -59,11 +56,9 @@ BioStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BioStreamBuf:: ~BioStreamBuf() { close(); @@ -72,11 +67,9 @@ BioStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BioStreamBuf:: open(BioPtr *source) { _source = source; @@ -84,11 +77,9 @@ open(BioPtr *source) { _write_open = true; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::close -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BioStreamBuf:: close() { sync(); @@ -97,12 +88,10 @@ close() { _write_open = false; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int BioStreamBuf:: overflow(int ch) { size_t n = pptr() - pbase(); @@ -127,12 +116,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int BioStreamBuf:: sync() { /* @@ -157,12 +144,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int BioStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -172,32 +157,30 @@ underflow() { size_t num_bytes = buffer_size; - // BIO_read might return -1 or -2 on eof or error, so we have to - // allow for negative numbers. + // BIO_read might return -1 or -2 on eof or error, so we have to allow for + // negative numbers. int read_count = BIO_read(*_source, gptr(), buffer_size); thread_consider_yield(); if (read_count != (int)num_bytes) { // Oops, we didn't read what we thought we would. if (read_count <= 0) { - // Immediately save the os error in case we screw up and do - // something that will change its value before we can output - // it. + // Immediately save the os error in case we screw up and do something + // that will change its value before we can output it. #if defined(WIN32_VC) || defined(WIN64_VC) int os_error = WSAGetLastError(); #else int os_error = errno; #endif // WIN32_VC - // Though BIO_eof() is tempting, it appears there are cases in - // which that never returns true, if the socket is closed by - // the server. But BIO_should_retry() *appears* to be - // reliable. + // Though BIO_eof() is tempting, it appears there are cases in which + // that never returns true, if the socket is closed by the server. + // But BIO_should_retry() *appears* to be reliable. _read_open = (BIO_should_retry(*_source) != 0); #ifdef IS_OSX - // occassionally we get -1 on read_open on the mac - // the os_error is 35 which means "Resource temporarily unavailable". + // occassionally we get -1 on read_open on the mac the os_error is 35 + // which means "Resource temporarily unavailable". if (!_read_open && os_error == 35) { downloader_cat.warning() << "forcing retry to true again and _read_open to true\n"; BIO_set_retry_read(*_source); @@ -207,7 +190,7 @@ underflow() { if (!_read_open) { downloader_cat.info() << "Lost connection to " - << _source->get_server_name() << ":" + << _source->get_server_name() << ":" << _source->get_port() << " (" << read_count << ").\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); @@ -229,8 +212,8 @@ underflow() { } gbump(num_bytes); return EOF; - } - + } + // Slide what we did read to the top of the buffer. nassertr(read_count < (int)num_bytes, EOF); size_t delta = (int)num_bytes - read_count; @@ -247,13 +230,11 @@ underflow() { return (unsigned char)*gptr(); } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamBuf::write_chars -// Access: Private -// Description: Sends some characters to the dest stream. Does not -// return until all characters are sent or the socket is -// closed, even if the underlying BIO is non-blocking. -//////////////////////////////////////////////////////////////////// +/** + * Sends some characters to the dest stream. Does not return until all + * characters are sent or the socket is closed, even if the underlying BIO is + * non-blocking. + */ size_t BioStreamBuf:: write_chars(const char *start, size_t length) { if (length != 0) { @@ -263,22 +244,19 @@ write_chars(const char *start, size_t length) { thread_consider_yield(); while (write_count != (int)(length - wrote_so_far)) { if (write_count <= 0) { - // http://www.openssl.org/docs/crypto/BIO_s_bio.html - // "Calls to BIO_write() will place data in the buffer or - // request a retry if the buffer is full." - // - // when the server is terminated, this seems to be the best - // way of detecting that case on the client: a BIO write error - // without a retry request - //_write_open = BIO_should_retry(*_source); - //_write_open = !BIO_eof(*_source); +/* + * http:www.openssl.orgdocscryptoBIO_s_bio.html "Calls to BIO_write() will + * place data in the buffer or request a retry if the buffer is full." when + * the server is terminated, this seems to be the best way of detecting that + * case on the client: a BIO write error without a retry request _write_open = + * BIO_should_retry(*_source); _write_open = !BIO_eof(*_source); + */ _write_open = (BIO_should_write(*_source) != 0 || BIO_should_retry(*_source) != 0); if (!_write_open) { return wrote_so_far; } - - // Block on the underlying socket before we try to write some - // more. + + // Block on the underlying socket before we try to write some more. int fd = -1; BIO_get_fd(*_source, &fd); if (fd < 0) { @@ -290,8 +268,8 @@ write_chars(const char *start, size_t length) { << "waiting to write to BIO.\n"; } #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In SIMPLE_THREADS mode, instead of blocking, simply yield - // the thread. + // In SIMPLE_THREADS mode, instead of blocking, simply yield the + // thread. thread_yield(); #else // In any other threading mode, we actually want to block. @@ -300,8 +278,8 @@ write_chars(const char *start, size_t length) { FD_SET(fd, &wset); select(fd + 1, NULL, &wset, NULL, NULL); #endif // SIMPLE_THREADS - } - + } + } else { // wrote some characters. wrote_so_far += write_count; @@ -310,7 +288,7 @@ write_chars(const char *start, size_t length) { << "wrote " << write_count << " bytes to " << _source << "\n"; } } - + // Try to write some more. write_count = BIO_write(*_source, start + wrote_so_far, length - wrote_so_far); if (downloader_cat.is_spam()) { diff --git a/panda/src/downloader/bioStreamBuf.h b/panda/src/downloader/bioStreamBuf.h index c03de76c02..c9174b30b1 100644 --- a/panda/src/downloader/bioStreamBuf.h +++ b/panda/src/downloader/bioStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: bioStreamBuf.h -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStreamBuf.h + * @author drose + * @date 2002-09-25 + */ #ifndef BIOSTREAMBUF_H #define BIOSTREAMBUF_H @@ -29,11 +28,9 @@ #include "openSSLWrapper.h" // must be included before any other openssl. #include "openssl/ssl.h" -//////////////////////////////////////////////////////////////////// -// Class : BioStreamBuf -// Description : The streambuf object that implements -// IBioStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements IBioStream. + */ class EXPCL_PANDAEXPRESS BioStreamBuf : public streambuf { public: BioStreamBuf(); diff --git a/panda/src/downloader/bioStreamPtr.I b/panda/src/downloader/bioStreamPtr.I index 56bd964f0b..6a5c761525 100644 --- a/panda/src/downloader/bioStreamPtr.I +++ b/panda/src/downloader/bioStreamPtr.I @@ -1,72 +1,58 @@ -// Filename: bioStreamPtr.I -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStreamPtr.I + * @author drose + * @date 2002-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStreamPtr:: BioStreamPtr(BioStream *stream) : _stream(stream) { } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::operator * -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream &BioStreamPtr:: operator *() const { return *_stream; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::operator -> -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream *BioStreamPtr:: operator ->() const { return _stream; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::operator typecast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStreamPtr:: operator BioStream * () const { return _stream; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::get_stream -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void BioStreamPtr:: set_stream(BioStream *stream) { _stream = stream; } -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::get_stream -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BioStream *BioStreamPtr:: get_stream() const { return _stream; diff --git a/panda/src/downloader/bioStreamPtr.cxx b/panda/src/downloader/bioStreamPtr.cxx index 5e417ccfd8..80d5e4838a 100644 --- a/panda/src/downloader/bioStreamPtr.cxx +++ b/panda/src/downloader/bioStreamPtr.cxx @@ -1,26 +1,23 @@ -// Filename: bioStreamPtr.cxx -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStreamPtr.cxx + * @author drose + * @date 2002-10-15 + */ #include "bioStreamPtr.h" #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: BioStreamPtr::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BioStreamPtr:: ~BioStreamPtr() { if (_stream != (BioStream *)NULL) { diff --git a/panda/src/downloader/bioStreamPtr.h b/panda/src/downloader/bioStreamPtr.h index d56d439bf2..aa5c8a28bf 100644 --- a/panda/src/downloader/bioStreamPtr.h +++ b/panda/src/downloader/bioStreamPtr.h @@ -1,16 +1,15 @@ -// Filename: bioStreamPtr.h -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bioStreamPtr.h + * @author drose + * @date 2002-10-15 + */ #ifndef BIOSTREAMPTR_H #define BIOSTREAMPTR_H @@ -29,11 +28,10 @@ #include "openSSLWrapper.h" // must be included before any other openssl. #include "openssl/ssl.h" -//////////////////////////////////////////////////////////////////// -// Class : BioStreamPtr -// Description : A wrapper around an BioStream object to make a -// reference-counting pointer to it. -//////////////////////////////////////////////////////////////////// +/** + * A wrapper around an BioStream object to make a reference-counting pointer + * to it. + */ class EXPCL_PANDAEXPRESS BioStreamPtr : public ReferenceCount { public: INLINE BioStreamPtr(BioStream *stream); @@ -56,5 +54,3 @@ private: #endif - - diff --git a/panda/src/downloader/chunkedStream.I b/panda/src/downloader/chunkedStream.I index 1875387661..b85382192d 100644 --- a/panda/src/downloader/chunkedStream.I +++ b/panda/src/downloader/chunkedStream.I @@ -1,42 +1,34 @@ -// Filename: chunkedStream.I -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStream.I + * @author drose + * @date 2002-09-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IChunkedStream:: IChunkedStream() : ISocketStream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IChunkedStream:: IChunkedStream(BioStreamPtr *source, HTTPChannel *doc) : ISocketStream(&_buf) { open(source, doc); } -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IChunkedStream &IChunkedStream:: open(BioStreamPtr *source, HTTPChannel *doc) { clear((ios_iostate)0); diff --git a/panda/src/downloader/chunkedStream.cxx b/panda/src/downloader/chunkedStream.cxx index 698ae3b463..2b6f316c0b 100644 --- a/panda/src/downloader/chunkedStream.cxx +++ b/panda/src/downloader/chunkedStream.cxx @@ -1,27 +1,24 @@ -// Filename: chunkedStream.cxx -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStream.cxx + * @author drose + * @date 2002-09-25 + */ #include "chunkedStream.h" // This module is not compiled if OpenSSL is not available. #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IChunkedStream:: ~IChunkedStream() { if (_channel != (HTTPChannel *)NULL) { @@ -30,13 +27,11 @@ IChunkedStream:: } } -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::is_closed -// Access: Public, Virtual -// Description: Returns true if the last eof condition was triggered -// because the socket has genuinely closed, or false if -// we can expect more data to come along shortly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last eof condition was triggered because the socket has + * genuinely closed, or false if we can expect more data to come along + * shortly. + */ bool IChunkedStream:: is_closed() { if (_buf._done || _buf.is_closed()) { @@ -46,23 +41,18 @@ is_closed() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::close -// Access: Public, Virtual -// Description: Resets the ChunkedStream to empty, but does not actually -// close the source BIO unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the ChunkedStream to empty, but does not actually close the source + * BIO unless owns_source was true. + */ void IChunkedStream:: close() { _buf.close_read(); } -//////////////////////////////////////////////////////////////////// -// Function: IChunkedStream::get_read_state -// Access: Public, Virtual -// Description: Returns an enum indicating how we are coming along in -// reading the document. -//////////////////////////////////////////////////////////////////// +/** + * Returns an enum indicating how we are coming along in reading the document. + */ IChunkedStream::ReadState IChunkedStream:: get_read_state() { return _buf.get_read_state(); diff --git a/panda/src/downloader/chunkedStream.h b/panda/src/downloader/chunkedStream.h index a0a8a22e76..346b9f8056 100644 --- a/panda/src/downloader/chunkedStream.h +++ b/panda/src/downloader/chunkedStream.h @@ -1,16 +1,15 @@ -// Filename: chunkedStream.h -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStream.h + * @author drose + * @date 2002-09-25 + */ #ifndef CHUNKEDSTREAM_H #define CHUNKEDSTREAM_H @@ -26,15 +25,13 @@ class HTTPChannel; class BioStreamPtr; -//////////////////////////////////////////////////////////////////// -// Class : IChunkedStream -// Description : An input stream object that reads data from a source -// istream, but automatically decodes the "chunked" -// transfer-coding specified by an HTTP server. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// -// No need to export from DLL. +/** + * An input stream object that reads data from a source istream, but + * automatically decodes the "chunked" transfer-coding specified by an HTTP + * server. + * + * Seeking is not supported. No need to export from DLL. + */ class IChunkedStream : public ISocketStream { public: INLINE IChunkedStream(); @@ -56,6 +53,3 @@ private: #endif // HAVE_OPENSSL #endif - - - diff --git a/panda/src/downloader/chunkedStreamBuf.I b/panda/src/downloader/chunkedStreamBuf.I index e15bf6410a..b890d7349b 100644 --- a/panda/src/downloader/chunkedStreamBuf.I +++ b/panda/src/downloader/chunkedStreamBuf.I @@ -1,33 +1,27 @@ -// Filename: chunkedStreamBuf.I -// Created by: drose (14Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStreamBuf.I + * @author drose + * @date 2006-11-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::is_closed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ChunkedStreamBuf:: is_closed() const { return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::get_read_state -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ISocketStream::ReadState ChunkedStreamBuf:: get_read_state() const { return _read_state; diff --git a/panda/src/downloader/chunkedStreamBuf.cxx b/panda/src/downloader/chunkedStreamBuf.cxx index 6606a4554c..9464a9c730 100644 --- a/panda/src/downloader/chunkedStreamBuf.cxx +++ b/panda/src/downloader/chunkedStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: chunkedStreamBuf.cxx -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStreamBuf.cxx + * @author drose + * @date 2002-09-25 + */ #include "chunkedStreamBuf.h" #include "config_downloader.h" @@ -24,11 +23,9 @@ typedef int streamsize; #endif /* HAVE_STREAMSIZE */ -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ChunkedStreamBuf:: ChunkedStreamBuf() { _chunk_remaining = 0; @@ -49,11 +46,9 @@ ChunkedStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ChunkedStreamBuf:: ~ChunkedStreamBuf() { close_read(); @@ -62,13 +57,10 @@ ChunkedStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::open_read -// Access: Public -// Description: If the document pointer is non-NULL, it will be -// updated with the length of the file as it is derived -// from the chunked encoding. -//////////////////////////////////////////////////////////////////// +/** + * If the document pointer is non-NULL, it will be updated with the length of + * the file as it is derived from the chunked encoding. + */ void ChunkedStreamBuf:: open_read(BioStreamPtr *source, HTTPChannel *doc) { _source = source; @@ -84,29 +76,24 @@ open_read(BioStreamPtr *source, HTTPChannel *doc) { _doc->_transfer_file_size = 0; _doc->_got_transfer_file_size = true; - // Read a little bit from the file to get the first chunk (and - // therefore the file size, or at least the size of the first - // chunk). + // Read a little bit from the file to get the first chunk (and therefore + // the file size, or at least the size of the first chunk). underflow(); } } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::close_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ChunkedStreamBuf:: close_read() { _source.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int ChunkedStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -136,11 +123,9 @@ underflow() { } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::read_chars -// Access: Private -// Description: Gets some characters from the source stream. -//////////////////////////////////////////////////////////////////// +/** + * Gets some characters from the source stream. + */ size_t ChunkedStreamBuf:: read_chars(char *start, size_t length) { while (true) { @@ -148,7 +133,7 @@ read_chars(char *start, size_t length) { if (_done) { return 0; } - + if (_chunk_remaining != 0) { // Extract some of the bytes remaining in the chunk. length = min(length, _chunk_remaining); @@ -163,22 +148,22 @@ read_chars(char *start, size_t length) { } } _chunk_remaining -= read_count; - + if (read_count == 0 && (*_source)->is_closed()) { // Whoops, the socket closed while we were downloading. _read_state = ISocketStream::RS_error; } - + return read_count; } - + // Read the next chunk. string line; bool got_line = http_getline(line); while (got_line && line.empty()) { - // Skip blank lines. There really should be exactly one blank - // line, but who's counting? It's tricky to count and maintain - // reentry for nonblocking I/O. + // Skip blank lines. There really should be exactly one blank line, but + // who's counting? It's tricky to count and maintain reentry for + // nonblocking IO. got_line = http_getline(line); } if (!got_line) { @@ -187,7 +172,7 @@ read_chars(char *start, size_t length) { // Whoops, the socket closed while we were downloading. _read_state = ISocketStream::RS_error; } - + if (!_wanted_nonblocking) { // Simulate blocking. thread_yield(); @@ -201,7 +186,7 @@ read_chars(char *start, size_t length) { downloader_cat.spam() << "Got chunk of size " << chunk_size << " bytes.\n"; } - + if (chunk_size == 0) { // Last chunk; we're done. _done = true; @@ -212,11 +197,11 @@ read_chars(char *start, size_t length) { _read_state = ISocketStream::RS_complete; return 0; } - + if (_doc != (HTTPChannel *)NULL && _read_index == _doc->_read_index) { _doc->_transfer_file_size += chunk_size; } - + _chunk_remaining = chunk_size; // Back to the top. @@ -226,14 +211,11 @@ read_chars(char *start, size_t length) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ChunkedStreamBuf::http_getline -// Access: Private -// Description: Reads a single line from the stream. Returns -// true if the line is successfully retrieved, or false -// if a complete line has not yet been received or if -// the connection has been closed. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single line from the stream. Returns true if the line is + * successfully retrieved, or false if a complete line has not yet been + * received or if the connection has been closed. + */ bool ChunkedStreamBuf:: http_getline(string &str) { nassertr(!_source.is_null(), false); diff --git a/panda/src/downloader/chunkedStreamBuf.h b/panda/src/downloader/chunkedStreamBuf.h index a5c4b51d09..675914772c 100644 --- a/panda/src/downloader/chunkedStreamBuf.h +++ b/panda/src/downloader/chunkedStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: chunkedStreamBuf.h -// Created by: drose (25Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file chunkedStreamBuf.h + * @author drose + * @date 2002-09-25 + */ #ifndef CHUNKEDSTREAMBUF_H #define CHUNKEDSTREAMBUF_H @@ -24,11 +23,9 @@ #include "bioStreamPtr.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : ChunkedStreamBuf -// Description : The streambuf object that implements -// IChunkedStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements IChunkedStream. + */ class ChunkedStreamBuf : public streambuf { // No need to export from DLL. public: diff --git a/panda/src/downloader/config_downloader.cxx b/panda/src/downloader/config_downloader.cxx index 535a31693b..e1ee26ace5 100644 --- a/panda/src/downloader/config_downloader.cxx +++ b/panda/src/downloader/config_downloader.cxx @@ -1,16 +1,15 @@ -// Filename: config_downloader.cxx -// Created by: mike (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_downloader.cxx + * @author mike + * @date 2000-03-19 + */ #include "dconfig.h" #include "config_downloader.h" @@ -116,14 +115,12 @@ ConfigureFn(config_downloader) { init_libdownloader(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libdownloader -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdownloader() { static bool initialized = false; @@ -139,8 +136,8 @@ init_libdownloader() { VirtualFileMountHTTP::reload_vfs_mount_url(); - // We need to define this here, rather than above, to guarantee that - // it has been initialized by the time we check it. + // We need to define this here, rather than above, to guarantee that it has + // been initialized by the time we check it. ConfigVariableBool early_random_seed ("early-random-seed", false, PRC_DESC("Configure this true to compute the SSL random seed " diff --git a/panda/src/downloader/config_downloader.h b/panda/src/downloader/config_downloader.h index ffd64f81f6..b31a7d2bd8 100644 --- a/panda/src/downloader/config_downloader.h +++ b/panda/src/downloader/config_downloader.h @@ -1,16 +1,15 @@ -// Filename: config_downloader.h -// Created by: mike (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_downloader.h + * @author mike + * @date 2000-03-19 + */ #ifndef CONFIG_DOWNLOADER_H #define CONFIG_DOWNLOADER_H diff --git a/panda/src/downloader/decompressor.I b/panda/src/downloader/decompressor.I index 3b7c226900..66e7f51904 100644 --- a/panda/src/downloader/decompressor.I +++ b/panda/src/downloader/decompressor.I @@ -1,13 +1,12 @@ -// Filename: decompressor.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decompressor.I + * @author mike + * @date 1997-01-09 + */ diff --git a/panda/src/downloader/decompressor.cxx b/panda/src/downloader/decompressor.cxx index 7f8739f55b..61b564a9eb 100644 --- a/panda/src/downloader/decompressor.cxx +++ b/panda/src/downloader/decompressor.cxx @@ -1,16 +1,15 @@ -// Filename: decompressor.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decompressor.cxx + * @author mike + * @date 1997-01-09 + */ #include "pandabase.h" @@ -30,11 +29,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Decompressor:: Decompressor() { _source = NULL; @@ -42,24 +39,19 @@ Decompressor() { _dest = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Decompressor:: ~Decompressor() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::initiate -// Access: Public -// Description: Begins a background decompression of the named file -// (whose filename must end in ".pz") to a new file -// without the .pz extension. The source file is -// removed after successful completion. -//////////////////////////////////////////////////////////////////// +/** + * Begins a background decompression of the named file (whose filename must + * end in ".pz") to a new file without the .pz extension. The source file is + * removed after successful completion. + */ int Decompressor:: initiate(const Filename &source_file) { string extension = source_file.get_extension(); @@ -77,13 +69,10 @@ initiate(const Filename &source_file) { return EU_error_abort; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::initiate -// Access: Public -// Description: Begins a background decompression from the named -// source file to the named destination file. The -// source file is removed after successful completion. -//////////////////////////////////////////////////////////////////// +/** + * Begins a background decompression from the named source file to the named + * destination file. The source file is removed after successful completion. + */ int Decompressor:: initiate(const Filename &source_file, const Filename &dest_file) { cleanup(); @@ -141,15 +130,11 @@ initiate(const Filename &source_file, const Filename &dest_file) { return EU_success; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::run -// Access: Public -// Description: Called each frame to do the next bit of work in the -// background task. Returns EU_ok if a chunk is -// completed but there is more to go, or EU_success when -// we're all done. Any other return value indicates an -// error. -//////////////////////////////////////////////////////////////////// +/** + * Called each frame to do the next bit of work in the background task. + * Returns EU_ok if a chunk is completed but there is more to go, or + * EU_success when we're all done. Any other return value indicates an error. + */ int Decompressor:: run() { if (_decompress == (istream *)NULL) { @@ -187,13 +172,10 @@ run() { return EU_success; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::decompress -// Access: Public -// Description: Performs a foreground decompression of the named -// file; does not return until the decompression is -// complete. -//////////////////////////////////////////////////////////////////// +/** + * Performs a foreground decompression of the named file; does not return + * until the decompression is complete. + */ bool Decompressor:: decompress(const Filename &source_file) { int ret = initiate(source_file); @@ -213,13 +195,10 @@ decompress(const Filename &source_file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::decompress -// Access: Public -// Description: Does an in-memory decompression of the indicated -// Ramfile. The decompressed contents are written back -// into the same Ramfile on completion. -//////////////////////////////////////////////////////////////////// +/** + * Does an in-memory decompression of the indicated Ramfile. The decompressed + * contents are written back into the same Ramfile on completion. + */ bool Decompressor:: decompress(Ramfile &source_and_dest_file) { istringstream source(source_and_dest_file._data); @@ -238,12 +217,9 @@ decompress(Ramfile &source_and_dest_file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::get_progress -// Access: Public -// Description: Returns the ratio through the decompression step -// in the background. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ratio through the decompression step in the background. + */ PN_stdfloat Decompressor:: get_progress() const { if (_decompress == (istream *)NULL) { @@ -254,17 +230,14 @@ get_progress() const { nassertr(_source_length > 0, 0.0); size_t source_pos = _source->tellg(); - // We stop the scale at 0.99 because there may be a little bit more - // to do even after the decompressor has read all of the source. + // We stop the scale at 0.99 because there may be a little bit more to do + // even after the decompressor has read all of the source. return (0.99f * (PN_stdfloat)source_pos / (PN_stdfloat)_source_length); } -//////////////////////////////////////////////////////////////////// -// Function: Decompressor::cleanup -// Access: Private -// Description: Called to reset a previous decompressor state and -// clean up properly. -//////////////////////////////////////////////////////////////////// +/** + * Called to reset a previous decompressor state and clean up properly. + */ void Decompressor:: cleanup() { if (_source != (istream *)NULL) { diff --git a/panda/src/downloader/decompressor.h b/panda/src/downloader/decompressor.h index d0d6d9b354..fe15352355 100644 --- a/panda/src/downloader/decompressor.h +++ b/panda/src/downloader/decompressor.h @@ -1,16 +1,15 @@ -// Filename: decompressor.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decompressor.h + * @author mike + * @date 1997-01-09 + */ #ifndef DECOMPRESSOR_H #define DECOMPRESSOR_H @@ -23,12 +22,10 @@ class Ramfile; -//////////////////////////////////////////////////////////////////// -// Class : Decompressor -// Description : This manages run-time decompression of a -// zlib-compressed stream, as a background or foreground -// task. -//////////////////////////////////////////////////////////////////// +/** + * This manages run-time decompression of a zlib-compressed stream, as a + * background or foreground task. + */ class EXPCL_PANDAEXPRESS Decompressor { PUBLISHED: Decompressor(); diff --git a/panda/src/downloader/documentSpec.I b/panda/src/downloader/documentSpec.I index f248c787ef..aeb962671d 100644 --- a/panda/src/downloader/documentSpec.I +++ b/panda/src/downloader/documentSpec.I @@ -1,23 +1,19 @@ -// Filename: documentSpec.I -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file documentSpec.I + * @author drose + * @date 2003-01-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DocumentSpec:: DocumentSpec() { _request_mode = RM_any; @@ -25,11 +21,9 @@ DocumentSpec() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DocumentSpec:: DocumentSpec(const string &url) : _url(url) @@ -39,11 +33,9 @@ DocumentSpec(const string &url) : _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DocumentSpec:: DocumentSpec(const URLSpec &url) : _url(url) @@ -53,11 +45,9 @@ DocumentSpec(const URLSpec &url) : _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DocumentSpec:: DocumentSpec(const DocumentSpec ©) : _url(copy._url), @@ -69,11 +59,9 @@ DocumentSpec(const DocumentSpec ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DocumentSpec:: operator = (const DocumentSpec ©) { _url = copy._url; @@ -84,246 +72,191 @@ operator = (const DocumentSpec ©) { _flags = copy._flags; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool DocumentSpec:: operator == (const DocumentSpec &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool DocumentSpec:: operator != (const DocumentSpec &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool DocumentSpec:: operator < (const DocumentSpec &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::set_url -// Access: Published -// Description: Changes the URL of the DocumentSpec without modifying -// its other properties. Normally this would be a -// strange thing to do, because the tag and date are -// usually strongly associated with the URL. To get a -// DocumentSpec pointing to a new URL, you would -// normally create a new DocumentSpec object. -//////////////////////////////////////////////////////////////////// +/** + * Changes the URL of the DocumentSpec without modifying its other properties. + * Normally this would be a strange thing to do, because the tag and date are + * usually strongly associated with the URL. To get a DocumentSpec pointing + * to a new URL, you would normally create a new DocumentSpec object. + */ INLINE void DocumentSpec:: set_url(const URLSpec &url) { _url = url; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::get_url -// Access: Published -// Description: Retrieves the URL of the DocumentSpec. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the URL of the DocumentSpec. + */ INLINE const URLSpec &DocumentSpec:: get_url() const { return _url; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::set_tag -// Access: Published -// Description: Changes the identity tag associated with the -// DocumentSpec. -//////////////////////////////////////////////////////////////////// +/** + * Changes the identity tag associated with the DocumentSpec. + */ INLINE void DocumentSpec:: set_tag(const HTTPEntityTag &tag) { _tag = tag; _flags |= F_has_tag; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::has_tag -// Access: Published -// Description: Returns true if an identity tag is associated with -// the DocumentSpec. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an identity tag is associated with the DocumentSpec. + */ INLINE bool DocumentSpec:: has_tag() const { return (_flags & F_has_tag) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::get_tag -// Access: Published -// Description: Returns the identity tag associated with the -// DocumentSpec, if there is one. It is an error to -// call this if has_tag() returns false. -// -// The identity tag is set by the HTTP server to -// uniquely refer to a particular version of a document. -//////////////////////////////////////////////////////////////////// +/** + * Returns the identity tag associated with the DocumentSpec, if there is one. + * It is an error to call this if has_tag() returns false. + * + * The identity tag is set by the HTTP server to uniquely refer to a + * particular version of a document. + */ INLINE const HTTPEntityTag &DocumentSpec:: get_tag() const { nassertr(has_tag(), _tag); return _tag; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::clear_tag -// Access: Published -// Description: Removes the identity tag associated with the -// DocumentSpec, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the identity tag associated with the DocumentSpec, if there is one. + */ INLINE void DocumentSpec:: clear_tag() { _flags &= ~F_has_tag; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::set_date -// Access: Published -// Description: Changes the last-modified date associated with the -// DocumentSpec. -//////////////////////////////////////////////////////////////////// +/** + * Changes the last-modified date associated with the DocumentSpec. + */ INLINE void DocumentSpec:: set_date(const HTTPDate &date) { _date = date; _flags |= F_has_date; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::has_date -// Access: Published -// Description: Returns true if a last-modified date is associated -// with the DocumentSpec. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a last-modified date is associated with the DocumentSpec. + */ INLINE bool DocumentSpec:: has_date() const { return (_flags & F_has_date) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::get_date -// Access: Published -// Description: Returns the last-modified date associated with the -// DocumentSpec, if there is one. It is an error to -// call this if has_date() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last-modified date associated with the DocumentSpec, if there + * is one. It is an error to call this if has_date() returns false. + */ INLINE const HTTPDate &DocumentSpec:: get_date() const { nassertr(has_date(), _date); return _date; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::clear_date -// Access: Published -// Description: Removes the last-modified date associated with the -// DocumentSpec, if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the last-modified date associated with the DocumentSpec, if there + * is one. + */ INLINE void DocumentSpec:: clear_date() { _flags &= ~F_has_date; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::set_request_mode -// Access: Published -// Description: Sets the request mode of this DocumentSpec. This is -// only relevant when using the DocumentSpec to generate -// a request (for instance, in HTTPChannel). This -// specifies whether the document request will ask the -// server for a newer version than the indicated -// version, or the exact version, neither, or either. -// -// The possible values are: -// -// RM_any: ignore date and tag (if specified), and -// retrieve any document that matches the URL. For a -// subrange request, if the document matches the -// version indicated exactly, retrieve the subrange -// only; otherwise, retrieve the entire document. -// -// RM_equal: request only the precise version of the -// document that matches the particular date and/or -// tag exactly, if specified; fail if this version is -// not available. -// -// RM_newer: request any document that is newer than -// the version indicated by the particular date and/or -// tag; fail if only that version (or older versions) -// are available. -// -// RM_newer_or_equal: request any document that -// matches the version indicated by the particular -// date and/or tag, or is a newer version; fail if -// only older versions are available. -// -// In any of the above, you may specify either or both -// of the last-modified date and the identity tag, -// whichever is known to the client. -// -// The default mode is RM_any. -//////////////////////////////////////////////////////////////////// +/** + * Sets the request mode of this DocumentSpec. This is only relevant when + * using the DocumentSpec to generate a request (for instance, in + * HTTPChannel). This specifies whether the document request will ask the + * server for a newer version than the indicated version, or the exact + * version, neither, or either. + * + * The possible values are: + * + * RM_any: ignore date and tag (if specified), and retrieve any document that + * matches the URL. For a subrange request, if the document matches the + * version indicated exactly, retrieve the subrange only; otherwise, retrieve + * the entire document. + * + * RM_equal: request only the precise version of the document that matches the + * particular date and/or tag exactly, if specified; fail if this version is + * not available. + * + * RM_newer: request any document that is newer than the version indicated by + * the particular date and/or tag; fail if only that version (or older + * versions) are available. + * + * RM_newer_or_equal: request any document that matches the version indicated + * by the particular date and/or tag, or is a newer version; fail if only + * older versions are available. + * + * In any of the above, you may specify either or both of the last-modified + * date and the identity tag, whichever is known to the client. + * + * The default mode is RM_any. + */ INLINE void DocumentSpec:: set_request_mode(DocumentSpec::RequestMode request_mode) { _request_mode = request_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::get_request_mode -// Access: Published -// Description: Returns the request mode of this DocumentSpec. See -// set_request_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the request mode of this DocumentSpec. See set_request_mode(). + */ INLINE DocumentSpec::RequestMode DocumentSpec:: get_request_mode() const { return _request_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::set_cache_control -// Access: Published -// Description: Specifies what kind of cached value is acceptable for -// this document. Warning: some HTTP proxies may not -// respect this setting and may return a cached result -// anyway. -// -// CC_allow_cache: the normal HTTP behavior; the -// server may return a cached value if it believes it -// is valid. -// -// CC_revalidate: a proxy is forced to contact the -// origin server and verify that is cached value is in -// fact still valid before it returns it. -// -// CC_no_cache: a proxy must not return its cached -// value at all, but is forced to go all the way back -// to the origin server for the official document. -// -// The default mode is CC_allow_cache. -//////////////////////////////////////////////////////////////////// +/** + * Specifies what kind of cached value is acceptable for this document. + * Warning: some HTTP proxies may not respect this setting and may return a + * cached result anyway. + * + * CC_allow_cache: the normal HTTP behavior; the server may return a cached + * value if it believes it is valid. + * + * CC_revalidate: a proxy is forced to contact the origin server and verify + * that is cached value is in fact still valid before it returns it. + * + * CC_no_cache: a proxy must not return its cached value at all, but is forced + * to go all the way back to the origin server for the official document. + * + * The default mode is CC_allow_cache. + */ INLINE void DocumentSpec:: set_cache_control(DocumentSpec::CacheControl cache_control) { _cache_control = cache_control; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::get_cache_control -// Access: Published -// Description: Returns the request mode of this DocumentSpec. See -// set_cache_control(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the request mode of this DocumentSpec. See set_cache_control(). + */ INLINE DocumentSpec::CacheControl DocumentSpec:: get_cache_control() const { return _cache_control; diff --git a/panda/src/downloader/documentSpec.cxx b/panda/src/downloader/documentSpec.cxx index b1011a8028..b9ccc7097d 100644 --- a/panda/src/downloader/documentSpec.cxx +++ b/panda/src/downloader/documentSpec.cxx @@ -1,26 +1,23 @@ -// Filename: documentSpec.cxx -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file documentSpec.cxx + * @author drose + * @date 2003-01-28 + */ #include "documentSpec.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::compare_to -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DocumentSpec:: compare_to(const DocumentSpec &other) const { if (_flags != other._flags) { @@ -43,19 +40,16 @@ compare_to(const DocumentSpec &other) const { } } - // We don't consider _request_mode or _cache_control significant in - // the comparison. + // We don't consider _request_mode or _cache_control significant in the + // comparison. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::input -// Access: Published -// Description: Can be used to read in the DocumentSpec from a stream -// generated either by output() or write(). Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Can be used to read in the DocumentSpec from a stream generated either by + * output() or write(). Returns true on success, false on failure. + */ bool DocumentSpec:: input(istream &in) { // First, clear the spec. @@ -101,11 +95,9 @@ input(istream &in) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DocumentSpec:: output(ostream &out) const { out << "[ " << get_url(); @@ -118,11 +110,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: DocumentSpec::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DocumentSpec:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/panda/src/downloader/documentSpec.h b/panda/src/downloader/documentSpec.h index 988a6dcc42..8fd205ef9b 100644 --- a/panda/src/downloader/documentSpec.h +++ b/panda/src/downloader/documentSpec.h @@ -1,16 +1,15 @@ -// Filename: documentSpec.h -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file documentSpec.h + * @author drose + * @date 2003-01-28 + */ #ifndef DOCUMENTSPEC_H #define DOCUMENTSPEC_H @@ -20,16 +19,14 @@ #include "httpEntityTag.h" #include "httpDate.h" -//////////////////////////////////////////////////////////////////// -// Class : DocumentSpec -// Description : A descriptor that refers to a particular version of a -// document. This includes the URL of the document and -// its identity tag and last-modified dates. -// -// The DocumentSpec may also be used to request a newer -// document than a particular one if available, for -// instance to refresh a cached document. -//////////////////////////////////////////////////////////////////// +/** + * A descriptor that refers to a particular version of a document. This + * includes the URL of the document and its identity tag and last-modified + * dates. + * + * The DocumentSpec may also be used to request a newer document than a + * particular one if available, for instance to refresh a cached document. + */ class EXPCL_PANDAEXPRESS DocumentSpec { PUBLISHED: INLINE DocumentSpec(); diff --git a/panda/src/downloader/downloadDb.I b/panda/src/downloader/downloadDb.I index fd826f72a6..a97e1d7595 100644 --- a/panda/src/downloader/downloadDb.I +++ b/panda/src/downloader/downloadDb.I @@ -1,74 +1,60 @@ -// Filename: downloadDb.I -// Created by: shochet (08Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file downloadDb.I + * @author shochet + * @date 2000-09-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: get_client_num_multifiles() const { return _client_db.get_num_multifiles(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: get_server_num_multifiles() const { return _server_db.get_num_multifiles(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string DownloadDb:: get_client_multifile_name(int index) const { return _client_db.get_multifile_name(index); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string DownloadDb:: get_server_multifile_name(int index) const { return _server_db.get_multifile_name(index); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Phase DownloadDb:: get_client_multifile_phase(string mfname) const { return (_client_db.get_multifile_record_named(mfname))->_phase; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Phase DownloadDb:: get_server_multifile_phase(string mfname) const { return (_server_db.get_multifile_record_named(mfname))->_phase; @@ -76,21 +62,17 @@ get_server_multifile_phase(string mfname) const { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: get_client_multifile_size(string mfname) const { return (_client_db.get_multifile_record_named(mfname))->_size; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_client_multifile_size(string mfname, int size) { (_client_db.get_multifile_record_named(mfname))->_size = size; @@ -98,11 +80,9 @@ set_client_multifile_size(string mfname, int size) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: set_client_multifile_delta_size(string mfname, int size) { (_client_db.get_multifile_record_named(mfname))->_size += size; @@ -113,87 +93,71 @@ set_client_multifile_delta_size(string mfname, int size) { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: get_server_multifile_size(string mfname) const { return (_server_db.get_multifile_record_named(mfname))->_size; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_server_multifile_size(string mfname, int size) { (_server_db.get_multifile_record_named(mfname))->_size = size; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_client_multifile_incomplete(string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_incomplete; write_client_db(_client_db._filename); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_client_multifile_complete(string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_complete; write_client_db(_client_db._filename); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_client_multifile_decompressed(string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_decompressed; write_client_db(_client_db._filename); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DownloadDb:: set_client_multifile_extracted(string mfname) { (_client_db.get_multifile_record_named(mfname))->_status = Status_extracted; write_client_db(_client_db._filename); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int DownloadDb:: get_server_num_files(string mfname) const { return (_server_db.get_multifile_record_named(mfname))->get_num_files(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string DownloadDb:: get_server_file_name(string mfname, int index) const { return (_server_db.get_multifile_record_named(mfname))->get_file_name(index); diff --git a/panda/src/downloader/downloadDb.cxx b/panda/src/downloader/downloadDb.cxx index c3998476ba..7e56101ffa 100644 --- a/panda/src/downloader/downloadDb.cxx +++ b/panda/src/downloader/downloadDb.cxx @@ -1,16 +1,15 @@ -// Filename: downloadDb.cxx -// Created by: shochet (08Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file downloadDb.cxx + * @author shochet + * @date 2000-09-08 + */ #include "config_downloader.h" #include "downloadDb.h" @@ -21,17 +20,15 @@ #include -//////////////////////////////////////////////////////////////////// // Defines -//////////////////////////////////////////////////////////////////// // Written at the top of the file so we know this is a downloadDb PN_uint32 DownloadDb::_magic_number = 0xfeedfeed; -// Written at the top of the file to signify we are not done -// writing to the file yet. If you load a db with this magic -// number that means the previous time it got written out was -// probably interrupted in the middle of the write. +// Written at the top of the file to signify we are not done writing to the +// file yet. If you load a db with this magic number that means the previous +// time it got written out was probably interrupted in the middle of the +// write. PN_uint32 DownloadDb::_bogus_magic_number = 0x11111111; @@ -49,11 +46,9 @@ back_to_front_slash(const string &str) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Constructor -// Access: Public -// Description: Create a download db with these client and server dbs -//////////////////////////////////////////////////////////////////// +/** + * Create a download db with these client and server dbs + */ DownloadDb:: DownloadDb(Ramfile &server_file, Filename &client_file) { if (downloader_cat.is_debug()) @@ -64,11 +59,9 @@ DownloadDb(Ramfile &server_file, Filename &client_file) { _server_db = read_db(server_file, 1); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Constructor -// Access: Public -// Description: Create a download db with these client and server dbs -//////////////////////////////////////////////////////////////////// +/** + * Create a download db with these client and server dbs + */ DownloadDb:: DownloadDb(Filename &server_file, Filename &client_file) { if (downloader_cat.is_debug()) @@ -80,45 +73,37 @@ DownloadDb(Filename &server_file, Filename &client_file) { _server_db._filename = server_file; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Constructor -// Access: Public -// Description: Primarily used for testing. -//////////////////////////////////////////////////////////////////// +/** + * Primarily used for testing. + */ DownloadDb:: DownloadDb() { _client_db = Db(); _server_db = Db(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb:: ~DownloadDb() { if (downloader_cat.is_debug()) downloader_cat.debug() - << "DownloadDb destructor called" << endl; + << "DownloadDb destructor called" << endl; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: output(ostream &out) const { out << "[" << _server_db._filename << " " << _client_db._filename << "]"; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: write(ostream &out) const { out << "DownloadDb" << endl; @@ -136,66 +121,53 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: write_client_db(Filename &file) { return write_db(file, _client_db, 0); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: write_server_db(Filename &file) { return write_db(file, _server_db, 1); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: client_multifile_exists(string mfname) const { return (_client_db.multifile_exists(mfname)); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: A multifile is complete when it is completely -// downloaded. Note: it may already be decompressed -// or extracted and it is still complete -//////////////////////////////////////////////////////////////////// +/** + * A multifile is complete when it is completely downloaded. Note: it may + * already be decompressed or extracted and it is still complete + */ bool DownloadDb:: client_multifile_complete(string mfname) const { int client_status = _client_db.get_multifile_record_named(mfname)->_status; return (client_status >= Status_complete); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: client_multifile_decompressed(string mfname) const { int client_status = _client_db.get_multifile_record_named(mfname)->_status; return (client_status >= Status_decompressed); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: client_multifile_extracted(string mfname) const { int client_status = _client_db.get_multifile_record_named(mfname)->_status; @@ -203,33 +175,27 @@ client_multifile_extracted(string mfname) const { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: Return the hash value of the file we are working on -//////////////////////////////////////////////////////////////////// +/** + * Return the hash value of the file we are working on + */ HashVal DownloadDb:: get_client_multifile_hash(string mfname) const { return _client_db.get_multifile_record_named(mfname)->_hash; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: Return the hash value of the server file -//////////////////////////////////////////////////////////////////// +/** + * Return the hash value of the server file + */ HashVal DownloadDb:: get_server_multifile_hash(string mfname) const { return _server_db.get_multifile_record_named(mfname)->_hash; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: Set the hash value of file we are working on -//////////////////////////////////////////////////////////////////// +/** + * Set the hash value of file we are working on + */ void DownloadDb:: set_client_multifile_hash(string mfname, HashVal val) { _client_db.get_multifile_record_named(mfname)->_hash = val; @@ -237,11 +203,9 @@ set_client_multifile_hash(string mfname, HashVal val) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: Set the hash value of file we are working on -//////////////////////////////////////////////////////////////////// +/** + * Set the hash value of file we are working on + */ void DownloadDb:: set_server_multifile_hash(string mfname, HashVal val) { _server_db.get_multifile_record_named(mfname)->_hash = val; @@ -249,20 +213,16 @@ set_server_multifile_hash(string mfname, HashVal val) { // Operations on multifiles -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: delete_client_multifile(string mfname) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: add_client_multifile(string server_mfname) { PT(MultifileRecord) server_mfr = _server_db.get_multifile_record_named(server_mfname); @@ -273,21 +233,17 @@ add_client_multifile(string server_mfname) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: expand_client_multifile(string mfname) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::read_db -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::Db DownloadDb:: read_db(Filename &file, bool want_server_info) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -326,11 +282,9 @@ read_db(Filename &file, bool want_server_info) { return db; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::read_db -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::Db DownloadDb:: read_db(Ramfile &file, bool want_server_info) { // Open the multifile for reading @@ -355,11 +309,9 @@ read_db(Ramfile &file, bool want_server_info) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::write_db -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: write_db(Filename &file, Db db, bool want_server_info) { pofstream write_stream; @@ -389,23 +341,18 @@ write_db(Filename &file, Db db, bool want_server_info) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::create_new_server_db -// Access: Public -// Description: Used on the server side makefiles to create a -// new clean server db -//////////////////////////////////////////////////////////////////// +/** + * Used on the server side makefiles to create a new clean server db + */ void DownloadDb:: create_new_server_db() { _server_db = Db(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: server_add_multifile(string mfname, Phase phase, int size, int status) { PT(MultifileRecord) mfr = new MultifileRecord(mfname, phase, size, status); @@ -413,11 +360,9 @@ server_add_multifile(string mfname, Phase phase, int size, int status) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: server_add_file(string mfname, string fname) { // Make the new file record @@ -440,16 +385,12 @@ server_add_file(string mfname, string fname) { } -//////////////////////////////////////////////////////////////////// // Multifile methods -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::MultifileRecord:: MultifileRecord() { _name = ""; @@ -459,11 +400,9 @@ MultifileRecord() { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::MultifileRecord:: MultifileRecord(string name, Phase phase, int size, int status) { _name = name; @@ -473,11 +412,9 @@ MultifileRecord(string name, Phase phase, int size, int status) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb::MultifileRecord:: write(ostream &out) const { out << "==================================================" << endl; @@ -495,32 +432,26 @@ write(ostream &out) const { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DownloadDb::MultifileRecord:: get_num_files() const { return _file_records.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string DownloadDb::MultifileRecord:: get_file_name(int index) const { return _file_records[index]->_name; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb::MultifileRecord:: file_exists(string fname) const { pvector< PT(FileRecord) >::const_iterator i = _file_records.begin(); @@ -533,11 +464,9 @@ file_exists(string fname) const { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(DownloadDb::FileRecord) DownloadDb::MultifileRecord:: get_file_record_named(string fname) const { pvector< PT(FileRecord) >::const_iterator i = _file_records.begin(); @@ -555,11 +484,9 @@ get_file_record_named(string fname) const { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::MultifileRecord:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb::MultifileRecord:: add_file_record(PT(FileRecord) fr) { _file_records.push_back(fr); @@ -567,18 +494,14 @@ add_file_record(PT(FileRecord) fr) { -//////////////////////////////////////////////////////////////////// // Db methods -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::Db:: Db() { // The head is a magic number and the number of multifiles in the db @@ -586,11 +509,9 @@ Db() { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb::Db:: write(ostream &out) const { pvector< PT(MultifileRecord) >::const_iterator i = _mfile_records.begin(); @@ -600,31 +521,25 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int DownloadDb::Db:: get_num_multifiles() const { return _mfile_records.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string DownloadDb::Db:: get_multifile_name(int index) const { return _mfile_records[index]->_name; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb::Db:: multifile_exists(string mfname) const { pvector< PT(MultifileRecord) >::const_iterator i = _mfile_records.begin(); @@ -636,11 +551,9 @@ multifile_exists(string mfname) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(DownloadDb::MultifileRecord) DownloadDb::Db:: get_multifile_record_named(string mfname) const { pvector< PT(MultifileRecord) >::const_iterator i = _mfile_records.begin(); @@ -657,23 +570,18 @@ get_multifile_record_named(string mfname) const { return foo; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db:: -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb::Db:: add_multifile_record(PT(MultifileRecord) mfr) { _mfile_records.push_back(mfr); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::parse_header -// Access: Private -// Description: Verifies magic number, returns the number of -// multifiles or -1 if invalid -//////////////////////////////////////////////////////////////////// +/** + * Verifies magic number, returns the number of multifiles or -1 if invalid + */ int DownloadDb::Db:: parse_header(const string &data) { Datagram dg(data); @@ -683,8 +591,8 @@ parse_header(const string &data) { PN_uint32 magic_number = di.get_uint32(); 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 the magic number is equal to the bogus magic number it signifies that + // the previous write was interrupted if (magic_number == _bogus_magic_number) { downloader_cat.error() << "DownloadDb::parse_header() - " @@ -692,8 +600,7 @@ parse_header(const string &data) { << magic_number << " expected: " << _magic_number << endl; return -1; } - // If the magic number does not match at all, something is - // really wrong + // If the magic number does not match at all, something is really wrong else if (magic_number != _magic_number) { downloader_cat.error() << "DownloadDb::parse_header() - Invalid magic number: " @@ -711,12 +618,10 @@ parse_header(const string &data) { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::parse_fr_header -// Access: Private -// Description: Parses a file record (fr) header and returns -// the length of the next file record -//////////////////////////////////////////////////////////////////// +/** + * Parses a file record (fr) header and returns the length of the next file + * record + */ int DownloadDb::Db:: parse_record_header(const string &data) { Datagram dg(data); @@ -730,11 +635,9 @@ parse_record_header(const string &data) { } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::parse_mfr -// Access: Private -// Description: Parses a multifile record (mfr) and returns one -//////////////////////////////////////////////////////////////////// +/** + * Parses a multifile record (mfr) and returns one + */ PT(DownloadDb::MultifileRecord) DownloadDb::Db:: parse_mfr(const string &data) { @@ -749,11 +652,11 @@ parse_mfr(const string &data) { mfr->_status = di.get_int32(); mfr->_num_files = di.get_int32(); - // At one time, we stored files in the database with a backslash - // separator. Nowadays we use a forward slash, but we should make - // sure we properly convert any old records we might read. + // At one time, we stored files in the database with a backslash separator. + // Nowadays we use a forward slash, but we should make sure we properly + // convert any old records we might read. mfr->_name = back_to_front_slash(mfr->_name); - + // Read the hash value mfr->_hash.read_datagram(di); @@ -769,11 +672,9 @@ parse_mfr(const string &data) { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::parse_fr -// Access: Private -// Description: Parses a file record (fr) and returns one -//////////////////////////////////////////////////////////////////// +/** + * Parses a file record (fr) and returns one + */ PT(DownloadDb::FileRecord) DownloadDb::Db:: parse_fr(const string &data) { @@ -784,9 +685,9 @@ parse_fr(const string &data) { PN_int32 fr_name_length = di.get_int32(); fr->_name = di.extract_bytes(fr_name_length); - // At one time, we stored files in the database with a backslash - // separator. Nowadays we use a forward slash, but we should make - // sure we properly convert any old records we might read. + // At one time, we stored files in the database with a backslash separator. + // Nowadays we use a forward slash, but we should make sure we properly + // convert any old records we might read. fr->_name = back_to_front_slash(fr->_name); downloader_cat.spam() @@ -799,11 +700,9 @@ parse_fr(const string &data) { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::read -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb::Db:: read(StreamReader &sr, bool want_server_info) { // Read the header @@ -821,11 +720,11 @@ read(StreamReader &sr, bool want_server_info) { return false; } - // Now that we know how many multifiles this db has, we can iterate - // reading them off one by one + // Now that we know how many multifiles this db has, we can iterate reading + // them off one by one for (int i = 0; i < num_multifiles; i++) { - // The multifile record header is just one int which - // represents the size of the record + // The multifile record header is just one int which represents the size + // of the record int mfr_header_length = sizeof(PN_int32); string mfr_header = sr.extract_bytes(mfr_header_length); @@ -837,9 +736,8 @@ read(StreamReader &sr, bool want_server_info) { // Parse the header int mfr_length = parse_record_header(mfr_header); - // Ok, now that we know the size of the mfr, read it in - // Make a buffer to read the multifile record into - // do not count the header length twice + // Ok, now that we know the size of the mfr, read it in Make a buffer to + // read the multifile record into do not count the header length twice int read_length = (mfr_length - mfr_header_length); string mfr_record = sr.extract_bytes(read_length); if (mfr_record.size() != (size_t)read_length) { @@ -855,8 +753,8 @@ read(StreamReader &sr, bool want_server_info) { // Read off all the file records this multifile has for (int j = 0; j < mfr->_num_files; j++) { - // The file record header is just one int which - // represents the size of the record + // The file record header is just one int which represents the size of + // the record int fr_header_length = sizeof(PN_int32); // Read the header @@ -869,8 +767,8 @@ read(StreamReader &sr, bool want_server_info) { // Parse the header int fr_length = parse_record_header(fr_header); - // Ok, now that we know the size of the mfr, read it in - // do not count the header length twice + // Ok, now that we know the size of the mfr, read it in do not count + // the header length twice int read_length = (fr_length - fr_header_length); string fr_record = sr.extract_bytes(read_length); @@ -896,15 +794,13 @@ read(StreamReader &sr, bool want_server_info) { -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::write -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb::Db:: write(StreamWriter &sw, bool want_server_info) { - // Declare these outside the loop so we do not keep creating - // and deleting them + // Declare these outside the loop so we do not keep creating and deleting + // them PN_float64 phase; PN_int32 size; PN_int32 status; @@ -944,7 +840,7 @@ write(StreamWriter &sw, bool want_server_info) { sw.add_int32(size); sw.add_int32(status); sw.add_int32(num_files); - + (*i)->_hash.write_stream(sw); // Only write out the file information if you are the server @@ -975,14 +871,11 @@ write(StreamWriter &sw, bool want_server_info) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::write_bogus_header -// Access: Private -// Description: Writes the bogus header uncompressed with platform- -// independent byte ordering. This header will get -// overwritten with the real magic number as the last -// step in the write -//////////////////////////////////////////////////////////////////// +/** + * Writes the bogus header uncompressed with platform- independent byte + * ordering. This header will get overwritten with the real magic number as + * the last step in the write + */ bool DownloadDb::Db:: write_bogus_header(StreamWriter &sw) { // Write the db magic number @@ -994,12 +887,9 @@ write_bogus_header(StreamWriter &sw) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::Db::write_header -// Access: Private -// Description: Writes the header uncompressed with platform- -// independent byte ordering -//////////////////////////////////////////////////////////////////// +/** + * Writes the header uncompressed with platform- independent byte ordering + */ bool DownloadDb::Db:: write_header(ostream &write_stream) { Datagram dg; @@ -1021,51 +911,40 @@ write_header(ostream &write_stream) { -//////////////////////////////////////////////////////////////////// // FileRecord methods -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::FileRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::FileRecord:: FileRecord() { _name = ""; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::FileRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DownloadDb::FileRecord:: FileRecord(string name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::FileRecord::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb::FileRecord:: write(ostream &out) const { out << " FileRecord: " << _name << endl; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::add_version -// Access: Published -// Description: Appends a new version of the file onto the end of the -// list, or changes the hash associated with a version -// previously added. -// -// Note: version numbers start at 1 -//////////////////////////////////////////////////////////////////// +/** + * Appends a new version of the file onto the end of the list, or changes the + * hash associated with a version previously added. + * + * Note: version numbers start at 1 + */ void DownloadDb:: add_version(const Filename &name, const HashVal &hash, int version) { nassertv(version >= 1); @@ -1086,36 +965,29 @@ add_version(const Filename &name, const HashVal &hash, int version) { } } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::insert_new_version -// Access: Published -// Description: Inserts a new version 1 copy of the file, sliding all -// the other versions up by one. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a new version 1 copy of the file, sliding all the other versions up + * by one. + */ void DownloadDb:: insert_new_version(const Filename &name, const HashVal &hash) { VectorHash &vhash = _versions[name]; vhash.insert(vhash.begin(), hash); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::has_version -// Access: Published -// Description: Returns true if the indicated file has version -// information, false otherwise. Some files recorded in -// the database may not bother to track versions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file has version information, false + * otherwise. Some files recorded in the database may not bother to track + * versions. + */ bool DownloadDb:: has_version(const Filename &name) const { return (_versions.find(name) != _versions.end()); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::get_num_versions -// Access: Published -// Description: Returns the number of versions stored for the -// indicated file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of versions stored for the indicated file. + */ int DownloadDb:: get_num_versions(const Filename &name) const { VersionMap::const_iterator vmi = _versions.find(name); @@ -1126,13 +998,10 @@ get_num_versions(const Filename &name) const { return (int)(*vmi).second.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::set_num_versions -// Access: Published -// Description: Reduces the number of versions of a particular file -// stored in the ddb by throwing away all versions -// higher than the indicated index. -//////////////////////////////////////////////////////////////////// +/** + * Reduces the number of versions of a particular file stored in the ddb by + * throwing away all versions higher than the indicated index. + */ void DownloadDb:: set_num_versions(const Filename &name, int num_versions) { VersionMap::iterator vmi = _versions.find(name); @@ -1147,14 +1016,11 @@ set_num_versions(const Filename &name, int num_versions) { vhash.erase(vhash.begin() + num_versions, vhash.end()); } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::get_version -// Access: Published -// Description: Returns the version number of this particular file, -// determined by looking up the hash generated from the -// file. Returns -1 if the version number cannot be -// determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version number of this particular file, determined by looking + * up the hash generated from the file. Returns -1 if the version number + * cannot be determined. + */ int DownloadDb:: get_version(const Filename &name, const HashVal &hash) const { VersionMap::const_iterator vmi = _versions.find(name); @@ -1172,12 +1038,10 @@ get_version(const Filename &name, const HashVal &hash) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::get_hash -// Access: Published -// Description: Returns the MD5 hash associated with the indicated -// version of the indicated file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MD5 hash associated with the indicated version of the indicated + * file. + */ const HashVal &DownloadDb:: get_hash(const Filename &name, int version) const { static HashVal bogus_hash; @@ -1192,18 +1056,16 @@ get_hash(const Filename &name, int version) const { const VectorHash &vhash = (*vmi).second; if (version < 1 || version > (int)vhash.size()) { downloader_cat.error() - << "DownloadDb::get_hash() - no version " << version + << "DownloadDb::get_hash() - no version " << version << " for " << name << endl; return bogus_hash; } return vhash[version - 1]; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::write_version_map -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: write_version_map(StreamWriter &sw) { VersionMap::iterator vmi; @@ -1226,11 +1088,9 @@ write_version_map(StreamWriter &sw) { } } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::read_version_map -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DownloadDb:: read_version_map(StreamReader &sr) { int num_entries = sr.get_int32(); @@ -1275,11 +1135,9 @@ read_version_map(StreamReader &sr) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DownloadDb::write_version_map -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DownloadDb:: write_version_map(ostream &out) const { out << "Version Map: " << endl; diff --git a/panda/src/downloader/downloadDb.h b/panda/src/downloader/downloadDb.h index 1ef6ddcaec..d46f3a1890 100644 --- a/panda/src/downloader/downloadDb.h +++ b/panda/src/downloader/downloadDb.h @@ -1,16 +1,16 @@ -// Filename: downloadDb.h -// Created by: shochet (06Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file downloadDb.h + * @author shochet + * @date 2000-09-06 + */ + #ifndef DOWNLOADDB_H #define DOWNLOADDB_H @@ -33,9 +33,7 @@ typedef PN_stdfloat Phase; class Ramfile; /* -//////////////////////////////////////////////////////////////////// -// Database Format -//////////////////////////////////////////////////////////////////// +// Database Format magic_number number_of_multifiles header_length multifile_name phase version size status num_files @@ -53,23 +51,19 @@ MultifileRecord is a Vector */ -//////////////////////////////////////////////////////////////////// -// Class : DownloadDb -// Description : A listing of files within multifiles for management -// of client-side synchronization with a server-provided -// set of files. -// -// This class manages one copy of the database for the -// client, representing the files on the client system, -// and another copy for the server, representing the -// files the server has available. -//////////////////////////////////////////////////////////////////// +/** + * A listing of files within multifiles for management of client-side + * synchronization with a server-provided set of files. + * + * This class manages one copy of the database for the client, representing + * the files on the client system, and another copy for the server, + * representing the files the server has available. + */ class EXPCL_PANDAEXPRESS DownloadDb { PUBLISHED: - // Status of a multifile is stored in this enum - // Note these values are in increasing order of "doneness" - // So if you are decompressed, you are complete - // If you are extracted, you are decompressed and complete + // Status of a multifile is stored in this enum Note these values are in + // increasing order of "doneness" So if you are decompressed, you are + // complete If you are extracted, you are decompressed and complete enum Status { Status_incomplete = 0, Status_complete = 1, @@ -197,8 +191,8 @@ PUBLISHED: bool write_db(Filename &file, Db db, bool want_server_info); public: - // The download db stores two databases, one that represents the - // client's state and one that represents the server state. + // The download db stores two databases, one that represents the client's + // state and one that represents the server state. Db _client_db; Db _server_db; diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx index d1aba78fd6..48f717145f 100644 --- a/panda/src/downloader/download_utils.cxx +++ b/panda/src/downloader/download_utils.cxx @@ -1,16 +1,15 @@ -// Filename: download_utils.cxx -// Created by: mike (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file download_utils.cxx + * @author mike + * @date 1999-01-18 + */ #include "pandabase.h" diff --git a/panda/src/downloader/download_utils.h b/panda/src/downloader/download_utils.h index d6a0cc5b7e..cd27e86666 100644 --- a/panda/src/downloader/download_utils.h +++ b/panda/src/downloader/download_utils.h @@ -1,16 +1,15 @@ -// Filename: download_utils.h -// Created by: mike (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file download_utils.h + * @author mike + * @date 1999-01-18 + */ #ifndef DOWNLOAD_UTILS_H #define DOWNLOAD_UTILS_H @@ -30,4 +29,3 @@ END_PUBLISH #endif // HAVE_ZLIB #endif - diff --git a/panda/src/downloader/extractor.I b/panda/src/downloader/extractor.I index e4d0a6d966..b4734206ac 100644 --- a/panda/src/downloader/extractor.I +++ b/panda/src/downloader/extractor.I @@ -1,13 +1,12 @@ -// Filename: extractor.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file extractor.I + * @author mike + * @date 1997-01-09 + */ diff --git a/panda/src/downloader/extractor.cxx b/panda/src/downloader/extractor.cxx index 210e7fca48..d387b51dd2 100644 --- a/panda/src/downloader/extractor.cxx +++ b/panda/src/downloader/extractor.cxx @@ -1,16 +1,15 @@ -// Filename: extractor.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file extractor.cxx + * @author mike + * @date 1997-01-09 + */ #include "extractor.h" #include "config_downloader.h" @@ -19,34 +18,27 @@ #include "error_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: Extractor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Extractor:: Extractor() { _initiated = false; _multifile = new Multifile; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Extractor:: ~Extractor() { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::set_multifile -// Access: Published -// Description: Specifies the filename of the Multifile that the -// Extractor will read. Returns true on success, false -// if the mulifile name is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the filename of the Multifile that the Extractor will read. + * Returns true on success, false if the mulifile name is invalid. + */ bool Extractor:: set_multifile(const Filename &multifile_name) { reset(); @@ -54,26 +46,20 @@ set_multifile(const Filename &multifile_name) { return _multifile->open_read(multifile_name); } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::set_extract_dir -// Access: Published -// Description: Specifies the directory into which all extracted -// subfiles will be written. Relative paths of subfiles -// within the Multifile will be written as relative -// paths to this directory. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the directory into which all extracted subfiles will be written. + * Relative paths of subfiles within the Multifile will be written as relative + * paths to this directory. + */ void Extractor:: set_extract_dir(const Filename &extract_dir) { _extract_dir = extract_dir; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::reset -// Access: Published -// Description: Interrupts the Extractor in the middle of its -// business and makes it ready to accept a new list of -// subfiles to extract. -//////////////////////////////////////////////////////////////////// +/** + * Interrupts the Extractor in the middle of its business and makes it ready + * to accept a new list of subfiles to extract. + */ void Extractor:: reset() { if (_initiated) { @@ -89,13 +75,10 @@ reset() { _requests_total_length = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::request_subfile -// Access: Published -// Description: Requests a particular subfile to be extracted when -// step() or run() is called. Returns true if the -// subfile exists, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Requests a particular subfile to be extracted when step() or run() is + * called. Returns true if the subfile exists, false otherwise. + */ bool Extractor:: request_subfile(const Filename &subfile_name) { int index = _multifile->find_subfile(subfile_name); @@ -107,12 +90,10 @@ request_subfile(const Filename &subfile_name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::request_all_subfiles -// Access: Published -// Description: Requests all subfiles in the Multifile to be -// extracted. Returns the number requested. -//////////////////////////////////////////////////////////////////// +/** + * Requests all subfiles in the Multifile to be extracted. Returns the number + * requested. + */ int Extractor:: request_all_subfiles() { _requests.clear(); @@ -125,20 +106,17 @@ request_all_subfiles() { return num_subfiles; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::step -// Access: Published -// Description: After all of the requests have been made via -// request_file() or request_all_subfiles(), call step() -// repeatedly until it stops returning EU_ok. -// -// step() extracts the next small unit of data from the -// Multifile. Returns EU_ok if progress is continuing, -// EU_error_abort if there is a problem, or EU_success -// when the last piece has been extracted. -// -// Also see run(). -//////////////////////////////////////////////////////////////////// +/** + * After all of the requests have been made via request_file() or + * request_all_subfiles(), call step() repeatedly until it stops returning + * EU_ok. + * + * step() extracts the next small unit of data from the Multifile. Returns + * EU_ok if progress is continuing, EU_error_abort if there is a problem, or + * EU_success when the last piece has been extracted. + * + * Also see run(). + */ int Extractor:: step() { if (!_initiated) { @@ -167,9 +145,9 @@ step() { reset(); return EU_success; } - + _subfile_index = _requests[_request_index]; - _subfile_filename = Filename(_extract_dir, + _subfile_filename = Filename(_extract_dir, _multifile->get_subfile_name(_subfile_index)); if (downloader_cat.is_debug()) { @@ -185,7 +163,7 @@ step() { reset(); return EU_error_abort; } - + _subfile_length = _multifile->get_subfile_length(_subfile_index); _subfile_pos = 0; _read = _multifile->open_read_subfile(_subfile_index); @@ -196,7 +174,7 @@ step() { reset(); return EU_error_abort; } - + } else if (_subfile_pos >= _subfile_length) { // Time to close this subfile. @@ -208,13 +186,12 @@ step() { _read = (istream *)NULL; _write.close(); _request_index++; - + } else { - // Read a number of bytes from the subfile and write them to the - // output. + // Read a number of bytes from the subfile and write them to the output. static const size_t buffer_size = 1024; char buffer[buffer_size]; - + size_t max_bytes = min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); size_t count = _read->gcount(); @@ -230,21 +207,21 @@ step() { reset(); return EU_error_abort; } - + _subfile_pos += count; _total_bytes_extracted += count; - + now = clock->get_short_time(); if (now >= finish) { // That's enough for now. return EU_ok; } - + max_bytes = min(buffer_size, _subfile_length - _subfile_pos); _read->read(buffer, max_bytes); count = _read->gcount(); } - + if (max_bytes != 0) { downloader_cat.error() << "Unexpected EOF on multifile " << _multifile_name << ".\n"; @@ -252,7 +229,7 @@ step() { return EU_error_abort; } } - + now = clock->get_short_time(); } while (now < finish); @@ -260,12 +237,9 @@ step() { return EU_ok; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::get_progress -// Access: Public -// Description: Returns the fraction of the Multifile extracted so -// far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fraction of the Multifile extracted so far. + */ PN_stdfloat Extractor:: get_progress() const { if (!_initiated) { @@ -278,19 +252,15 @@ get_progress() const { return (PN_stdfloat)_total_bytes_extracted / (PN_stdfloat)_requests_total_length; } -//////////////////////////////////////////////////////////////////// -// Function: Extractor::run -// Access: Published -// Description: A convenience function to extract the Multifile all -// at once, when you don't care about doing it in the -// background. -// -// First, call request_file() or request_all_files() to -// specify the files you would like to extract, then -// call run() to do the extraction. Also see step() for -// when you would like the extraction to happen as a -// background task. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to extract the Multifile all at once, when you don't + * care about doing it in the background. + * + * First, call request_file() or request_all_files() to specify the files you + * would like to extract, then call run() to do the extraction. Also see + * step() for when you would like the extraction to happen as a background + * task. + */ bool Extractor:: run() { while (true) { diff --git a/panda/src/downloader/extractor.h b/panda/src/downloader/extractor.h index 43390d33e7..0747eed350 100644 --- a/panda/src/downloader/extractor.h +++ b/panda/src/downloader/extractor.h @@ -1,16 +1,16 @@ -// Filename: extractor.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file extractor.h + * @author mike + * @date 1997-01-09 + */ + #ifndef EXTRACTOR_H #define EXTRACTOR_H @@ -21,21 +21,17 @@ #include "pointerTo.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : Extractor -// Description : This class automatically extracts the contents of a -// Multifile to the current directory (or to a specified -// directory) in the background. -// -// It is designed to limit its use of system resources -// and run unobtrusively in the background. After -// specifying the files you wish to extract via repeated -// calls to request_subfile(), begin the process by -// calling run() repeatedly. Each call to run() -// extracts another small portion of the Multifile. -// Call run() whenever you have spare cycles until run() -// returns EU_success. -//////////////////////////////////////////////////////////////////// +/** + * This class automatically extracts the contents of a Multifile to the + * current directory (or to a specified directory) in the background. + * + * It is designed to limit its use of system resources and run unobtrusively + * in the background. After specifying the files you wish to extract via + * repeated calls to request_subfile(), begin the process by calling run() + * repeatedly. Each call to run() extracts another small portion of the + * Multifile. Call run() whenever you have spare cycles until run() returns + * EU_success. + */ class EXPCL_PANDAEXPRESS Extractor { PUBLISHED: Extractor(); @@ -66,7 +62,7 @@ private: typedef vector_int Requests; Requests _requests; size_t _requests_total_length; - + bool _initiated; // These are used only while processing. diff --git a/panda/src/downloader/httpAuthorization.I b/panda/src/downloader/httpAuthorization.I index d485b14a42..bc105214df 100644 --- a/panda/src/downloader/httpAuthorization.I +++ b/panda/src/downloader/httpAuthorization.I @@ -1,39 +1,31 @@ -// Filename: httpAuthorization.I -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpAuthorization.I + * @author drose + * @date 2002-10-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::get_realm -// Access: Public -// Description: Returns the realm to which this authorization -// applies. This is the server-supplied string that may -// have meaning to the user, and describes the general -// collection of things protected by this password. -//////////////////////////////////////////////////////////////////// +/** + * Returns the realm to which this authorization applies. This is the server- + * supplied string that may have meaning to the user, and describes the + * general collection of things protected by this password. + */ const string &HTTPAuthorization:: get_realm() const { return _realm; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::get_domain -// Access: Public -// Description: Returns the set of domain strings on which this -// authorization applies. This is the set of URL -// prefixes for which this authorization should be -// used. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of domain strings on which this authorization applies. + * This is the set of URL prefixes for which this authorization should be + * used. + */ const vector_string &HTTPAuthorization:: get_domain() const { return _domain; diff --git a/panda/src/downloader/httpAuthorization.cxx b/panda/src/downloader/httpAuthorization.cxx index 17d561507a..d067b96d97 100644 --- a/panda/src/downloader/httpAuthorization.cxx +++ b/panda/src/downloader/httpAuthorization.cxx @@ -1,16 +1,15 @@ -// Filename: httpAuthorization.cxx -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpAuthorization.cxx + * @author drose + * @date 2002-10-22 + */ #include "httpAuthorization.h" #include "httpChannel.h" @@ -20,7 +19,7 @@ static const char base64_table[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', @@ -32,13 +31,11 @@ static const char base64_table[64] = { static unsigned char base64_invert[128]; static bool got_base64_invert = false; -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPAuthorization:: -HTTPAuthorization(const HTTPAuthorization::Tokens &tokens, +HTTPAuthorization(const HTTPAuthorization::Tokens &tokens, const URLSpec &url, bool is_proxy) { Tokens::const_iterator ti; ti = tokens.find("realm"); @@ -50,8 +47,7 @@ HTTPAuthorization(const HTTPAuthorization::Tokens &tokens, ti = tokens.find("domain"); if (ti != tokens.end() && !is_proxy) { - // Now the domain consists of a series of space-separated URL - // prefixes. + // Now the domain consists of a series of space-separated URL prefixes. const string &domain = (*ti).second; size_t p = 0; while (p < domain.length()) { @@ -79,8 +75,8 @@ HTTPAuthorization(const HTTPAuthorization::Tokens &tokens, } } else { - // If no domain is defined by the server, use the supplied URL. - // Truncate it to the rightmost slash. + // If no domain is defined by the server, use the supplied URL. Truncate + // it to the rightmost slash. string canon_str = canon.get_url(); size_t slash = canon_str.rfind('/'); nassertv(slash != string::npos); @@ -88,43 +84,33 @@ HTTPAuthorization(const HTTPAuthorization::Tokens &tokens, } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPAuthorization:: ~HTTPAuthorization() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::is_valid -// Access: Public, Virtual -// Description: Returns true if the authorization challenge was -// correctly parsed and is usable, or false if there was -// some unsupported algorithm or some such requested by -// the server, rendering the challenge unmeetable. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the authorization challenge was correctly parsed and is + * usable, or false if there was some unsupported algorithm or some such + * requested by the server, rendering the challenge unmeetable. + */ bool HTTPAuthorization:: is_valid() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::parse_authentication_schemes -// Access: Public, Static -// Description: Decodes the text following a WWW-Authenticate: or -// Proxy-Authenticate: header field. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the text following a WWW-Authenticate: or Proxy-Authenticate: + * header field. + */ void HTTPAuthorization:: parse_authentication_schemes(HTTPAuthorization::AuthenticationSchemes &schemes, const string &field_value) { - // This string will consist of one or more records of the form: - // - // scheme token=value[,token=value[,...]] - // - // If there are multiple records, they will be comma-delimited, - // which makes parsing just a bit tricky. + // This string will consist of one or more records of the form: scheme + // token=value[,token=value[,...]] If there are multiple records, they will + // be comma-delimited, which makes parsing just a bit tricky. // Start by skipping initial whitespace. size_t p = 0; @@ -140,12 +126,12 @@ parse_authentication_schemes(HTTPAuthorization::AuthenticationSchemes &schemes, // Here's our first scheme. string scheme = HTTPChannel::downcase(field_value.substr(p, q - p)); Tokens *tokens = &(schemes[scheme]); - + // Now pull off the tokens, one at a time. p = q + 1; while (p < field_value.length()) { q = p; - while (q < field_value.length() && field_value[q] != '=' && + while (q < field_value.length() && field_value[q] != '=' && field_value[q] != ',' && !isspace(field_value[q])) { ++q; } @@ -157,7 +143,7 @@ parse_authentication_schemes(HTTPAuthorization::AuthenticationSchemes &schemes, (*tokens)[token] = value; // Skip trailing whitespace and extra commas. - while (p < field_value.length() && + while (p < field_value.length() && (field_value[p] == ',' || isspace(field_value[p]))) { ++p; } @@ -172,14 +158,11 @@ parse_authentication_schemes(HTTPAuthorization::AuthenticationSchemes &schemes, } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::get_canonical_url -// Access: Public, Static -// Description: Returns the "canonical" URL corresponding to this -// URL. This is the same URL with an explicit port -// indication, an explicit scheme, and a non-empty path, -// etc. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "canonical" URL corresponding to this URL. This is the same + * URL with an explicit port indication, an explicit scheme, and a non-empty + * path, etc. + */ URLSpec HTTPAuthorization:: get_canonical_url(const URLSpec &url) { URLSpec canon = url; @@ -191,22 +174,20 @@ get_canonical_url(const URLSpec &url) { return canon; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::base64_encode -// Access: Public, Static -// Description: Returns the input string encoded using base64. No -// respect is paid to maintaining a 76-char line length. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input string encoded using base64. No respect is paid to + * maintaining a 76-char line length. + */ string HTTPAuthorization:: base64_encode(const string &s) { - // Collect the string 3 bytes at a time into 24-bit words, then - // output each word using 4 bytes. + // Collect the string 3 bytes at a time into 24-bit words, then output each + // word using 4 bytes. size_t num_words = (s.size() + 2) / 3; string result; result.reserve(num_words * 4); size_t p; for (p = 0; p + 2 < s.size(); p += 3) { - unsigned int word = + unsigned int word = ((unsigned)s[p] << 16) | ((unsigned)s[p + 1] << 8) | ((unsigned)s[p + 2]); @@ -239,11 +220,9 @@ base64_encode(const string &s) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::base64_decode -// Access: Public, Static -// Description: Returns the string decoded from base64. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string decoded from base64. + */ string HTTPAuthorization:: base64_decode(const string &s) { // Build up the invert table if this is the first time. @@ -262,8 +241,8 @@ base64_decode(const string &s) { got_base64_invert = true; } - // Collect the string 4 bytes at a time; decode this back into a - // 24-bit word and output the 3 corresponding bytes. + // Collect the string 4 bytes at a time; decode this back into a 24-bit word + // and output the 3 corresponding bytes. size_t num_words = s.size() / 4; string result; result.reserve(num_words * 3); @@ -274,7 +253,7 @@ base64_decode(const string &s) { unsigned int c2 = base64_invert[s[p + 2] & 0x7f]; unsigned int c3 = base64_invert[s[p + 3] & 0x7f]; - unsigned int word = + unsigned int word = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3; result += (char)((word >> 16) & 0xff); @@ -289,19 +268,15 @@ base64_decode(const string &s) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPAuthorization::scan_quoted_or_unquoted_string -// Access: Protected, Static -// Description: Scans the string source beginning at character -// position start, to identify either the -// (space-delimited) unquoted string there, or the -// (quote-delimited) quoted string. In either case, -// fills the string found into result, and returns the -// next character position after the string (or after -// its closing quote mark). -//////////////////////////////////////////////////////////////////// +/** + * Scans the string source beginning at character position start, to identify + * either the (space-delimited) unquoted string there, or the (quote- + * delimited) quoted string. In either case, fills the string found into + * result, and returns the next character position after the string (or after + * its closing quote mark). + */ size_t HTTPAuthorization:: -scan_quoted_or_unquoted_string(string &result, const string &source, +scan_quoted_or_unquoted_string(string &result, const string &source, size_t start) { result = string(); diff --git a/panda/src/downloader/httpAuthorization.h b/panda/src/downloader/httpAuthorization.h index dd27c23c95..4ac0457242 100644 --- a/panda/src/downloader/httpAuthorization.h +++ b/panda/src/downloader/httpAuthorization.h @@ -1,25 +1,24 @@ -// Filename: httpAuthorization.h -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpAuthorization.h + * @author drose + * @date 2002-10-22 + */ #ifndef HTTPAUTHORIZATION_H #define HTTPAUTHORIZATION_H #include "pandabase.h" -// This module requires OpenSSL to compile, even though it doesn't -// actually use any OpenSSL code, because it is a support module for -// HTTPChannel, which *does* use OpenSSL code. +// This module requires OpenSSL to compile, even though it doesn't actually +// use any OpenSSL code, because it is a support module for HTTPChannel, which +// *does* use OpenSSL code. #ifdef HAVE_OPENSSL @@ -29,13 +28,11 @@ class URLSpec; -//////////////////////////////////////////////////////////////////// -// Class : HTTPAuthorization -// Description : A base class for storing information used to fulfill -// authorization requests in the past, which can -// possibly be re-used for future requests to the same -// server. -//////////////////////////////////////////////////////////////////// +/** + * A base class for storing information used to fulfill authorization requests + * in the past, which can possibly be re-used for future requests to the same + * server. + */ class EXPCL_PANDAEXPRESS HTTPAuthorization : public ReferenceCount { public: typedef pmap Tokens; @@ -63,8 +60,8 @@ public: static string base64_decode(const string &s); protected: - static size_t scan_quoted_or_unquoted_string(string &result, - const string &source, + static size_t scan_quoted_or_unquoted_string(string &result, + const string &source, size_t start); protected: @@ -77,4 +74,3 @@ protected: #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/httpBasicAuthorization.I b/panda/src/downloader/httpBasicAuthorization.I index aae736648c..75ab48716f 100644 --- a/panda/src/downloader/httpBasicAuthorization.I +++ b/panda/src/downloader/httpBasicAuthorization.I @@ -1,13 +1,12 @@ -// Filename: httpBasicAuthorization.I -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpBasicAuthorization.I + * @author drose + * @date 2002-10-22 + */ diff --git a/panda/src/downloader/httpBasicAuthorization.cxx b/panda/src/downloader/httpBasicAuthorization.cxx index 3f39ed2f18..8e86c25a94 100644 --- a/panda/src/downloader/httpBasicAuthorization.cxx +++ b/panda/src/downloader/httpBasicAuthorization.cxx @@ -1,16 +1,15 @@ -// Filename: httpBasicAuthorization.cxx -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpBasicAuthorization.cxx + * @author drose + * @date 2002-10-22 + */ #include "httpBasicAuthorization.h" @@ -18,46 +17,37 @@ const string HTTPBasicAuthorization::_mechanism = "basic"; -//////////////////////////////////////////////////////////////////// -// Function: HTTPBasicAuthorization::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPBasicAuthorization:: -HTTPBasicAuthorization(const HTTPAuthorization::Tokens &tokens, - const URLSpec &url, bool is_proxy) : +HTTPBasicAuthorization(const HTTPAuthorization::Tokens &tokens, + const URLSpec &url, bool is_proxy) : HTTPAuthorization(tokens, url, is_proxy) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPBasicAuthorization::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPBasicAuthorization:: ~HTTPBasicAuthorization() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPBasicAuthorization::get_mechanism -// Access: Public, Virtual -// Description: Returns the type of authorization mechanism, -// represented as a string, e.g. "basic". -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of authorization mechanism, represented as a string, e.g. + * "basic". + */ const string &HTTPBasicAuthorization:: get_mechanism() const { return _mechanism; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPBasicAuthorization::generate -// Access: Public, Virtual -// Description: Generates a suitable authorization string to send -// to the server, based on the data stored within this -// object, for retrieving the indicated URL with the -// given username:password. -//////////////////////////////////////////////////////////////////// +/** + * Generates a suitable authorization string to send to the server, based on + * the data stored within this object, for retrieving the indicated URL with + * the given username:password. + */ string HTTPBasicAuthorization:: generate(HTTPEnum::Method, const string &, const string &username, const string &) { diff --git a/panda/src/downloader/httpBasicAuthorization.h b/panda/src/downloader/httpBasicAuthorization.h index d629c15a27..2d18a29a25 100644 --- a/panda/src/downloader/httpBasicAuthorization.h +++ b/panda/src/downloader/httpBasicAuthorization.h @@ -1,38 +1,35 @@ -// Filename: httpBasicAuthorization.h -// Created by: drose (22Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpBasicAuthorization.h + * @author drose + * @date 2002-10-22 + */ #ifndef HTTPBASICAUTHORIZATION_H #define HTTPBASICAUTHORIZATION_H #include "pandabase.h" -// This module requires OpenSSL to compile, even though it doesn't -// actually use any OpenSSL code, because it is a support module for -// HTTPChannel, which *does* use OpenSSL code. +// This module requires OpenSSL to compile, even though it doesn't actually +// use any OpenSSL code, because it is a support module for HTTPChannel, which +// *does* use OpenSSL code. #ifdef HAVE_OPENSSL #include "httpAuthorization.h" -//////////////////////////////////////////////////////////////////// -// Class : HTTPBasicAuthorization -// Description : Implements the "Basic" type of HTTP authorization. -// This authorization sends usernames and passwords over -// the net in cleartext, so it's not much in the way of -// security, but it's easy to implement and therefore -// widely supported. -//////////////////////////////////////////////////////////////////// +/** + * Implements the "Basic" type of HTTP authorization. This authorization + * sends usernames and passwords over the net in cleartext, so it's not much + * in the way of security, but it's easy to implement and therefore widely + * supported. + */ class HTTPBasicAuthorization : public HTTPAuthorization { public: HTTPBasicAuthorization(const Tokens &tokens, const URLSpec &url, @@ -52,4 +49,3 @@ private: #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/httpChannel.I b/panda/src/downloader/httpChannel.I index a914ba1ac7..ccc30d504d 100644 --- a/panda/src/downloader/httpChannel.I +++ b/panda/src/downloader/httpChannel.I @@ -1,541 +1,414 @@ -// Filename: httpChannel.I -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpChannel.I + * @author drose + * @date 2002-09-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_client -// Access: Published -// Description: Returns the HTTPClient object that owns this channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTTPClient object that owns this channel. + */ INLINE HTTPClient *HTTPChannel:: get_client() const { return _client; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::is_valid -// Access: Published -// Description: Returns true if the last-requested document was -// successfully retrieved and is ready to be read, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last-requested document was successfully retrieved and + * is ready to be read, false otherwise. + */ INLINE bool HTTPChannel:: is_valid() const { return (_state != S_failure && (get_status_code() / 100) == 2 && (_server_response_has_no_body || !_source.is_null())); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::is_connection_ready -// Access: Published -// Description: Returns true if a connection has been established to -// the named server in a previous call to connect_to() -// or begin_connect_to(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a connection has been established to the named server in a + * previous call to connect_to() or begin_connect_to(), false otherwise. + */ INLINE bool HTTPChannel:: is_connection_ready() const { return (!_source.is_null() && _state == S_ready); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_url -// Access: Published -// Description: Returns the URL that was used to retrieve the -// most recent document: whatever URL was last passed to -// get_document() or get_header(). If a redirect has -// transparently occurred, this will return the new, -// redirected URL (the actual URL at which the document -// was located). -//////////////////////////////////////////////////////////////////// +/** + * Returns the URL that was used to retrieve the most recent document: + * whatever URL was last passed to get_document() or get_header(). If a + * redirect has transparently occurred, this will return the new, redirected + * URL (the actual URL at which the document was located). + */ INLINE const URLSpec &HTTPChannel:: get_url() const { return _document_spec.get_url(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_document_spec -// Access: Published -// Description: Returns the DocumentSpec associated with the most -// recent document. This includes its actual URL -// (following redirects) along with the identity tag and -// last-modified date, if supplied by the server. -// -// This structure may be saved and used to retrieve the -// same version of the document later, or to -// conditionally retrieve a newer version if it is -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DocumentSpec associated with the most recent document. This + * includes its actual URL (following redirects) along with the identity tag + * and last-modified date, if supplied by the server. + * + * This structure may be saved and used to retrieve the same version of the + * document later, or to conditionally retrieve a newer version if it is + * available. + */ INLINE const DocumentSpec &HTTPChannel:: get_document_spec() const { return _document_spec; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_http_version -// Access: Published -// Description: Returns the HTTP version number returned by the -// server, as one of the HTTPClient enumerated types, -// e.g. HTTPClient::HV_11. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTTP version number returned by the server, as one of the + * HTTPClient enumerated types, e.g. HTTPClient::HV_11. + */ INLINE HTTPEnum::HTTPVersion HTTPChannel:: get_http_version() const { return _http_version; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_http_version_string -// Access: Published -// Description: Returns the HTTP version number returned by the -// server, formatted as a string, e.g. "HTTP/1.1". -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTTP version number returned by the server, formatted as a + * string, e.g. "HTTP/1.1". + */ INLINE const string &HTTPChannel:: get_http_version_string() const { return _http_version_string; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_status_code -// Access: Published -// Description: Returns the HTML return code from the document -// retrieval request. This will be in the 200 range if -// the document is successfully retrieved, or some other -// value in the case of an error. -// -// Some proxy errors during an https-over-proxy request -// would return the same status code as a different -// error that occurred on the host server. To -// differentiate these cases, status codes that are -// returned by the proxy during the CONNECT phase -// (except code 407) are incremented by 1000. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTML return code from the document retrieval request. This + * will be in the 200 range if the document is successfully retrieved, or some + * other value in the case of an error. + * + * Some proxy errors during an https-over-proxy request would return the same + * status code as a different error that occurred on the host server. To + * differentiate these cases, status codes that are returned by the proxy + * during the CONNECT phase (except code 407) are incremented by 1000. + */ INLINE int HTTPChannel:: get_status_code() const { return _status_entry._status_code; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_www_realm -// Access: Published -// Description: If the document failed to connect because of a 401 -// (Authorization required), this method will return the -// "realm" returned by the server in which the requested -// document must be authenticated. This string may be -// presented to the user to request an associated -// username and password (which then should be stored in -// HTTPClient::set_username()). -//////////////////////////////////////////////////////////////////// +/** + * If the document failed to connect because of a 401 (Authorization + * required), this method will return the "realm" returned by the server in + * which the requested document must be authenticated. This string may be + * presented to the user to request an associated username and password (which + * then should be stored in HTTPClient::set_username()). + */ INLINE const string &HTTPChannel:: get_www_realm() const { return _www_realm; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_proxy_realm -// Access: Published -// Description: If the document failed to connect because of a 407 -// (Proxy authorization required), this method will -// return the "realm" returned by the proxy. This -// string may be presented to the user to request an -// associated username and password (which then should -// be stored in HTTPClient::set_username()). -//////////////////////////////////////////////////////////////////// +/** + * If the document failed to connect because of a 407 (Proxy authorization + * required), this method will return the "realm" returned by the proxy. This + * string may be presented to the user to request an associated username and + * password (which then should be stored in HTTPClient::set_username()). + */ INLINE const string &HTTPChannel:: get_proxy_realm() const { return _proxy_realm; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_redirect -// Access: Published -// Description: If the document failed with a redirect code (300 -// series), this will generally contain the new URL the -// server wants us to try. In many cases, the client -// will automatically follow redirects; if these are -// successful the client will return a successful code -// and get_redirect() will return empty, but get_url() -// will return the new, redirected URL. -//////////////////////////////////////////////////////////////////// +/** + * If the document failed with a redirect code (300 series), this will + * generally contain the new URL the server wants us to try. In many cases, + * the client will automatically follow redirects; if these are successful the + * client will return a successful code and get_redirect() will return empty, + * but get_url() will return the new, redirected URL. + */ INLINE const URLSpec &HTTPChannel:: get_redirect() const { return _redirect; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_num_redirect_steps -// Access: Published -// Description: If the document automatically followed one or more -// redirects, this will return the number of redirects -// that were automatically followed. Use -// get_redirect_step() to retrieve each URL in -// sequence. -//////////////////////////////////////////////////////////////////// +/** + * If the document automatically followed one or more redirects, this will + * return the number of redirects that were automatically followed. Use + * get_redirect_step() to retrieve each URL in sequence. + */ INLINE int HTTPChannel:: get_num_redirect_steps() const { return _redirect_trail.size(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_redirect_step -// Access: Published -// Description: Use in conjunction with get_num_redirect_steps() to -// extract the chain of URL's that the channel was -// automatically redirected through to arrive at the -// final document. -//////////////////////////////////////////////////////////////////// +/** + * Use in conjunction with get_num_redirect_steps() to extract the chain of + * URL's that the channel was automatically redirected through to arrive at + * the final document. + */ INLINE const URLSpec &HTTPChannel:: get_redirect_step(int n) const { nassertr(n >= 0 && n < (int)_redirect_trail.size(), _redirect_trail[0]); return _redirect_trail[n]; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_persistent_connection -// Access: Published -// Description: Indicates whether the HTTPChannel should try to keep -// the connection to the server open and reuse that -// connection for multiple documents, or whether it -// should close the connection and open a new one for -// each request. Set this true to keep the connections -// around when possible, false to recycle them. -// -// It makes most sense to set this false when the -// HTTPChannel will be used only once to retrieve a -// single document, true when you will be using the same -// HTTPChannel object to retrieve multiple documents. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the HTTPChannel should try to keep the connection to the + * server open and reuse that connection for multiple documents, or whether it + * should close the connection and open a new one for each request. Set this + * true to keep the connections around when possible, false to recycle them. + * + * It makes most sense to set this false when the HTTPChannel will be used + * only once to retrieve a single document, true when you will be using the + * same HTTPChannel object to retrieve multiple documents. + */ INLINE void HTTPChannel:: set_persistent_connection(bool persistent_connection) { _persistent_connection = persistent_connection; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_persistent_connection -// Access: Published -// Description: Returns whether the HTTPChannel should try to keep -// the connection to the server open and reuse that -// connection for multiple documents, or whether it -// should close the connection and open a new one for -// each request. See set_persistent_connection(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the HTTPChannel should try to keep the connection to the + * server open and reuse that connection for multiple documents, or whether it + * should close the connection and open a new one for each request. See + * set_persistent_connection(). + */ INLINE bool HTTPChannel:: get_persistent_connection() const { return _persistent_connection; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_allow_proxy -// Access: Published -// Description: If this is true (the normal case), the HTTPClient -// will be consulted for information about the proxy to -// be used for each connection via this HTTPChannel. If -// this has been set to false by the user, then all -// connections will be made directly, regardless of the -// proxy settings indicated on the HTTPClient. -//////////////////////////////////////////////////////////////////// +/** + * If this is true (the normal case), the HTTPClient will be consulted for + * information about the proxy to be used for each connection via this + * HTTPChannel. If this has been set to false by the user, then all + * connections will be made directly, regardless of the proxy settings + * indicated on the HTTPClient. + */ INLINE void HTTPChannel:: set_allow_proxy(bool allow_proxy) { _allow_proxy = allow_proxy; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_allow_proxy -// Access: Published -// Description: If this is true (the normal case), the HTTPClient -// will be consulted for information about the proxy to -// be used for each connection via this HTTPChannel. If -// this has been set to false by the user, then all -// connections will be made directly, regardless of the -// proxy settings indicated on the HTTPClient. -//////////////////////////////////////////////////////////////////// +/** + * If this is true (the normal case), the HTTPClient will be consulted for + * information about the proxy to be used for each connection via this + * HTTPChannel. If this has been set to false by the user, then all + * connections will be made directly, regardless of the proxy settings + * indicated on the HTTPClient. + */ INLINE bool HTTPChannel:: get_allow_proxy() const { return _allow_proxy; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_proxy_tunnel -// Access: Published -// Description: Normally, a proxy is itself asked for ordinary URL's, -// and the proxy decides whether to hand the client a -// cached version of the document or to contact the -// server for a fresh version. The proxy may also -// modify the headers and transfer encoding on the way. -// -// If this is set to true, then instead of asking for -// URL's from the proxy, we will ask the proxy to open a -// connection to the server (for instance, on port 80); -// if the proxy honors this request, then we contact the -// server directly through this connection to retrieve -// the document. If the proxy does not honor the -// connect request, then the retrieve operation fails. -// -// SSL connections (e.g. https), and connections through -// a Socks proxy, are always tunneled, regardless of the -// setting of this flag. -//////////////////////////////////////////////////////////////////// +/** + * Normally, a proxy is itself asked for ordinary URL's, and the proxy decides + * whether to hand the client a cached version of the document or to contact + * the server for a fresh version. The proxy may also modify the headers and + * transfer encoding on the way. + * + * If this is set to true, then instead of asking for URL's from the proxy, we + * will ask the proxy to open a connection to the server (for instance, on + * port 80); if the proxy honors this request, then we contact the server + * directly through this connection to retrieve the document. If the proxy + * does not honor the connect request, then the retrieve operation fails. + * + * SSL connections (e.g. https), and connections through a Socks proxy, are + * always tunneled, regardless of the setting of this flag. + */ INLINE void HTTPChannel:: set_proxy_tunnel(bool proxy_tunnel) { _proxy_tunnel = proxy_tunnel; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_proxy_tunnel -// Access: Published -// Description: Returns true if connections always tunnel through a -// proxy, or false (the normal case) if we allow the -// proxy to serve up documents. See set_proxy_tunnel(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if connections always tunnel through a proxy, or false (the + * normal case) if we allow the proxy to serve up documents. See + * set_proxy_tunnel(). + */ INLINE bool HTTPChannel:: get_proxy_tunnel() const { return _proxy_tunnel; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_connect_timeout -// Access: Published -// Description: Sets the maximum length of time, in seconds, that the -// channel will wait before giving up on establishing a -// TCP connection. -// -// At present, this is used only for the nonblocking -// interfaces (e.g. begin_get_document(), -// begin_connect_to()), but it is used whether -// set_blocking_connect() is true or false. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum length of time, in seconds, that the channel will wait + * before giving up on establishing a TCP connection. + * + * At present, this is used only for the nonblocking interfaces (e.g. + * begin_get_document(), begin_connect_to()), but it is used whether + * set_blocking_connect() is true or false. + */ INLINE void HTTPChannel:: set_connect_timeout(double connect_timeout) { _connect_timeout = connect_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_connect_timeout -// Access: Published -// Description: Returns the length of time, in seconds, to wait for a -// new nonblocking socket to connect. See -// set_connect_timeout(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of time, in seconds, to wait for a new nonblocking + * socket to connect. See set_connect_timeout(). + */ INLINE double HTTPChannel:: get_connect_timeout() const { return _connect_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_blocking_connect -// Access: Published -// Description: If this flag is true, a socket connect will block -// even for nonblocking I/O calls like -// begin_get_document(), begin_connect_to(), etc. If -// false, a socket connect will not block for -// nonblocking I/O calls, but will block for blocking -// I/O calls (get_document(), connect_to(), etc.). -// -// Setting this true is useful when you want to use -// non-blocking I/O once you have established the -// connection, but you don't want to bother with polling -// for the initial connection. It's also useful when -// you don't particularly care about non-blocking I/O, -// but you need to respect timeouts like connect_timeout -// and http_timeout. -//////////////////////////////////////////////////////////////////// +/** + * If this flag is true, a socket connect will block even for nonblocking I/O + * calls like begin_get_document(), begin_connect_to(), etc. If false, a + * socket connect will not block for nonblocking I/O calls, but will block for + * blocking I/O calls (get_document(), connect_to(), etc.). + * + * Setting this true is useful when you want to use non-blocking I/O once you + * have established the connection, but you don't want to bother with polling + * for the initial connection. It's also useful when you don't particularly + * care about non-blocking I/O, but you need to respect timeouts like + * connect_timeout and http_timeout. + */ INLINE void HTTPChannel:: set_blocking_connect(bool blocking_connect) { _blocking_connect = blocking_connect; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_blocking_connect -// Access: Published -// Description: If this flag is true, a socket connect will block -// even for nonblocking I/O calls like -// begin_get_document(), begin_connect_to(), etc. If -// false, a socket connect will not block for -// nonblocking I/O calls, but will block for blocking -// I/O calls (get_document(), connect_to(), etc.). -//////////////////////////////////////////////////////////////////// +/** + * If this flag is true, a socket connect will block even for nonblocking I/O + * calls like begin_get_document(), begin_connect_to(), etc. If false, a + * socket connect will not block for nonblocking I/O calls, but will block for + * blocking I/O calls (get_document(), connect_to(), etc.). + */ INLINE bool HTTPChannel:: get_blocking_connect() const { return _blocking_connect; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_http_timeout -// Access: Published -// Description: Sets the maximum length of time, in seconds, that the -// channel will wait for the HTTP server to finish -// sending its response to our request. -// -// The timer starts counting after the TCP connection -// has been established (see set_connect_timeout(), -// above) and the request has been sent. -// -// At present, this is used only for the nonblocking -// interfaces (e.g. begin_get_document(), -// begin_connect_to()), but it is used whether -// set_blocking_connect() is true or false. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum length of time, in seconds, that the channel will wait for + * the HTTP server to finish sending its response to our request. + * + * The timer starts counting after the TCP connection has been established + * (see set_connect_timeout(), above) and the request has been sent. + * + * At present, this is used only for the nonblocking interfaces (e.g. + * begin_get_document(), begin_connect_to()), but it is used whether + * set_blocking_connect() is true or false. + */ INLINE void HTTPChannel:: set_http_timeout(double http_timeout) { _http_timeout = http_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_http_timeout -// Access: Published -// Description: Returns the length of time, in seconds, to wait for -// the HTTP server to respond to our request. See -// set_http_timeout(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of time, in seconds, to wait for the HTTP server to + * respond to our request. See set_http_timeout(). + */ INLINE double HTTPChannel:: get_http_timeout() const { return _http_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_skip_body_size -// Access: Published -// Description: Specifies the maximum number of bytes in a received -// (but unwanted) body that will be skipped past, in -// order to reset to a new request. -// -// That is, if this HTTPChannel requests a file via -// get_document(), but does not call download_to_ram(), -// download_to_file(), or open_read_body(), and instead -// immediately requests a new file, then the HTTPChannel -// has a choice whether to skip past the unwanted -// document, or to close the connection and open a new -// one. If the number of bytes to skip is more than -// this threshold, the connection will be closed; -// otherwise, the data will simply be read and -// discarded. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum number of bytes in a received (but unwanted) body + * that will be skipped past, in order to reset to a new request. + * + * That is, if this HTTPChannel requests a file via get_document(), but does + * not call download_to_ram(), download_to_file(), or open_read_body(), and + * instead immediately requests a new file, then the HTTPChannel has a choice + * whether to skip past the unwanted document, or to close the connection and + * open a new one. If the number of bytes to skip is more than this + * threshold, the connection will be closed; otherwise, the data will simply + * be read and discarded. + */ INLINE void HTTPChannel:: set_skip_body_size(size_t skip_body_size) { _skip_body_size = skip_body_size; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_skip_body_size -// Access: Published -// Description: Returns the maximum number of bytes in a received -// (but unwanted) body that will be skipped past, in -// order to reset to a new request. See -// set_skip_body_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of bytes in a received (but unwanted) body that + * will be skipped past, in order to reset to a new request. See + * set_skip_body_size(). + */ INLINE size_t HTTPChannel:: get_skip_body_size() const { return _skip_body_size; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_idle_timeout -// Access: Published -// Description: Specifies the amount of time, in seconds, in which a -// previously-established connection is allowed to -// remain open and unused. If a previous connection has -// remained unused for at least this number of seconds, -// it will be closed and a new connection will be -// opened; otherwise, the same connection will be reused -// for the next request (for this particular -// HTTPChannel). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the amount of time, in seconds, in which a previously-established + * connection is allowed to remain open and unused. If a previous connection + * has remained unused for at least this number of seconds, it will be closed + * and a new connection will be opened; otherwise, the same connection will be + * reused for the next request (for this particular HTTPChannel). + */ INLINE void HTTPChannel:: set_idle_timeout(double idle_timeout) { _idle_timeout = idle_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_idle_timeout -// Access: Published -// Description: Returns the amount of time, in seconds, in which an -// previously-established connection is allowed to -// remain open and unused. See set_idle_timeout(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, in which an previously-established + * connection is allowed to remain open and unused. See set_idle_timeout(). + */ INLINE double HTTPChannel:: get_idle_timeout() const { return _idle_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_download_throttle -// Access: Published -// Description: Specifies whether nonblocking downloads (via -// download_to_file() or download_to_ram()) will be -// limited so as not to use all available bandwidth. -// -// If this is true, when a download has been started on -// this channel it will be invoked no more frequently -// than get_max_updates_per_second(), and the total -// bandwidth used by the download will be no more than -// get_max_bytes_per_second(). If this is false, -// downloads will proceed as fast as the server can send -// the data. -// -// This only has effect on the nonblocking I/O methods -// like begin_get_document(), etc. The blocking methods -// like get_document() always use as much CPU and -// bandwidth as they can get. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether nonblocking downloads (via download_to_file() or + * download_to_ram()) will be limited so as not to use all available + * bandwidth. + * + * If this is true, when a download has been started on this channel it will + * be invoked no more frequently than get_max_updates_per_second(), and the + * total bandwidth used by the download will be no more than + * get_max_bytes_per_second(). If this is false, downloads will proceed as + * fast as the server can send the data. + * + * This only has effect on the nonblocking I/O methods like + * begin_get_document(), etc. The blocking methods like get_document() always + * use as much CPU and bandwidth as they can get. + */ INLINE void HTTPChannel:: set_download_throttle(bool download_throttle) { _download_throttle = download_throttle; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_download_throttle -// Access: Published -// Description: Returns whether the nonblocking downloads will be -// bandwidth-limited. See set_download_throttle(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the nonblocking downloads will be bandwidth-limited. See + * set_download_throttle(). + */ INLINE bool HTTPChannel:: get_download_throttle() const { return _download_throttle; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_max_bytes_per_second -// Access: Published -// Description: When bandwidth throttling is in effect (see -// set_download_throttle()), this specifies the maximum -// number of bytes per second that may be consumed by -// this channel. -//////////////////////////////////////////////////////////////////// +/** + * When bandwidth throttling is in effect (see set_download_throttle()), this + * specifies the maximum number of bytes per second that may be consumed by + * this channel. + */ INLINE void HTTPChannel:: set_max_bytes_per_second(double max_bytes_per_second) { _max_bytes_per_second = max_bytes_per_second; _bytes_per_update = int(_max_bytes_per_second * _seconds_per_update); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_max_bytes_per_second -// Access: Published -// Description: Returns the maximum number of bytes per second that -// may be consumed by this channel when -// get_download_throttle() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of bytes per second that may be consumed by this + * channel when get_download_throttle() is true. + */ INLINE double HTTPChannel:: get_max_bytes_per_second() const { return _max_bytes_per_second; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_max_updates_per_second -// Access: Published -// Description: When bandwidth throttling is in effect (see -// set_download_throttle()), this specifies the maximum -// number of times per second that run() will attempt to -// do any downloading at all. -//////////////////////////////////////////////////////////////////// +/** + * When bandwidth throttling is in effect (see set_download_throttle()), this + * specifies the maximum number of times per second that run() will attempt to + * do any downloading at all. + */ INLINE void HTTPChannel:: set_max_updates_per_second(double max_updates_per_second) { nassertv(max_updates_per_second != 0.0f); @@ -544,28 +417,22 @@ set_max_updates_per_second(double max_updates_per_second) { _bytes_per_update = int(_max_bytes_per_second * _seconds_per_update); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_max_updates_per_second -// Access: Published -// Description: Returns the maximum number of times per second that -// run() will do anything at all, when -// get_download_throttle() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of times per second that run() will do anything + * at all, when get_download_throttle() is true. + */ INLINE double HTTPChannel:: get_max_updates_per_second() const { return _max_updates_per_second; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::set_expected_file_size -// Access: Published -// Description: This may be called immediately after a call to -// get_document() or some related function to specify -// the expected size of the document we are retrieving, -// if we happen to know. This is used as the return -// value to get_file_size() only in the case that the -// server does not tell us the actual file size. -//////////////////////////////////////////////////////////////////// +/** + * This may be called immediately after a call to get_document() or some + * related function to specify the expected size of the document we are + * retrieving, if we happen to know. This is used as the return value to + * get_file_size() only in the case that the server does not tell us the + * actual file size. + */ INLINE void HTTPChannel:: set_expected_file_size(size_t file_size) { _expected_file_size = file_size; @@ -573,102 +440,75 @@ set_expected_file_size(size_t file_size) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::is_file_size_known -// Access: Published -// Description: Returns true if the size of the file we are currently -// retrieving was told us by the server and thus is -// reliably known, or false if the size reported by -// get_file_size() represents an educated guess -// (possibly as set by set_expected_file_size(), or as -// inferred from a chunked transfer encoding in -// progress). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the size of the file we are currently retrieving was told + * us by the server and thus is reliably known, or false if the size reported + * by get_file_size() represents an educated guess (possibly as set by + * set_expected_file_size(), or as inferred from a chunked transfer encoding + * in progress). + */ INLINE bool HTTPChannel:: is_file_size_known() const { return _got_file_size; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_first_byte_requested -// Access: Published -// Description: Returns the first byte of the file requested by the -// request. This will normally be 0 to indicate that -// the file is being requested from the beginning, but -// if the file was requested via a get_subdocument() -// call, this will contain the first_byte parameter from -// that call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first byte of the file requested by the request. This will + * normally be 0 to indicate that the file is being requested from the + * beginning, but if the file was requested via a get_subdocument() call, this + * will contain the first_byte parameter from that call. + */ INLINE size_t HTTPChannel:: get_first_byte_requested() const { return _first_byte_requested; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_last_byte_requested -// Access: Published -// Description: Returns the last byte of the file requested by the -// request. This will normally be 0 to indicate that -// the file is being requested to its last byte, but if -// the file was requested via a get_subdocument() call, -// this will contain the last_byte parameter from that -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last byte of the file requested by the request. This will + * normally be 0 to indicate that the file is being requested to its last + * byte, but if the file was requested via a get_subdocument() call, this will + * contain the last_byte parameter from that call. + */ INLINE size_t HTTPChannel:: get_last_byte_requested() const { return _last_byte_requested; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_first_byte_delivered -// Access: Published -// Description: Returns the first byte of the file (that will be) -// delivered by the server in response to the current -// request. Normally, this is the same as -// get_first_byte_requested(), but some servers will -// ignore a subdocument request and always return the -// whole file, in which case this value will be 0, -// regardless of what was requested to -// get_subdocument(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first byte of the file (that will be) delivered by the server + * in response to the current request. Normally, this is the same as + * get_first_byte_requested(), but some servers will ignore a subdocument + * request and always return the whole file, in which case this value will be + * 0, regardless of what was requested to get_subdocument(). + */ INLINE size_t HTTPChannel:: get_first_byte_delivered() const { return _first_byte_delivered; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_last_byte_delivered -// Access: Published -// Description: Returns the last byte of the file (that will be) -// delivered by the server in response to the current -// request. Normally, this is the same as -// get_last_byte_requested(), but some servers will -// ignore a subdocument request and always return the -// whole file, in which case this value will be 0, -// regardless of what was requested to -// get_subdocument(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the last byte of the file (that will be) delivered by the server in + * response to the current request. Normally, this is the same as + * get_last_byte_requested(), but some servers will ignore a subdocument + * request and always return the whole file, in which case this value will be + * 0, regardless of what was requested to get_subdocument(). + */ INLINE size_t HTTPChannel:: get_last_byte_delivered() const { return _last_byte_delivered; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset -// Access: Published -// Description: Stops whatever file transaction is currently in -// progress, closes the connection, and resets to begin -// anew. You shouldn't ever need to call this, since -// the channel should be able to reset itself cleanly -// between requests, but it is provided in case you are -// an especially nervous type. -// -// Don't call this after every request unless you set -// set_persistent_connection() to false, since calling -// reset() rudely closes the connection regardless of -// whether we have told the server we intend to keep it -// open or not. -//////////////////////////////////////////////////////////////////// +/** + * Stops whatever file transaction is currently in progress, closes the + * connection, and resets to begin anew. You shouldn't ever need to call + * this, since the channel should be able to reset itself cleanly between + * requests, but it is provided in case you are an especially nervous type. + * + * Don't call this after every request unless you set + * set_persistent_connection() to false, since calling reset() rudely closes + * the connection regardless of whether we have told the server we intend to + * keep it open or not. + */ INLINE void HTTPChannel:: reset() { reset_for_new_request(); @@ -676,50 +516,40 @@ reset() { _status_list.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::preserve_status -// Access: Published -// Description: Preserves the previous status code (presumably a -// failure) from the previous connection attempt. If -// the subsequent connection attempt also fails, the -// returned status code will be the better of the -// previous code and the current code. -// -// This can be called to daisy-chain subsequent attempts -// to download the same document from different servers. -// After all servers have been attempted, the final -// status code will reflect the attempt that most nearly -// succeeded. -//////////////////////////////////////////////////////////////////// +/** + * Preserves the previous status code (presumably a failure) from the previous + * connection attempt. If the subsequent connection attempt also fails, the + * returned status code will be the better of the previous code and the + * current code. + * + * This can be called to daisy-chain subsequent attempts to download the same + * document from different servers. After all servers have been attempted, + * the final status code will reflect the attempt that most nearly succeeded. + */ INLINE void HTTPChannel:: preserve_status() { _status_list.push_back(_status_entry); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::clear_extra_headers -// Access: Published -// Description: Resets the extra headers that were previously added -// via calls to send_extra_header(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the extra headers that were previously added via calls to + * send_extra_header(). + */ INLINE void HTTPChannel:: clear_extra_headers() { _send_extra_headers = string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::send_extra_header -// Access: Published -// Description: Specifies an additional key: value pair that is added -// into the header sent to the server with the next -// request. This is passed along with no interpretation -// by the HTTPChannel code. You may call this -// repeatedly to append multiple headers. -// -// This is persistent for one request only; it must be -// set again for each new request. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an additional key: value pair that is added into the header sent + * to the server with the next request. This is passed along with no + * interpretation by the HTTPChannel code. You may call this repeatedly to + * append multiple headers. + * + * This is persistent for one request only; it must be set again for each new + * request. + */ INLINE void HTTPChannel:: send_extra_header(const string &key, const string &value) { _send_extra_headers += key; @@ -728,12 +558,10 @@ send_extra_header(const string &key, const string &value) { _send_extra_headers += "\r\n"; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_document -// Access: Published -// Description: Opens the named document for reading, if available. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named document for reading, if available. Returns true if + * successful, false otherwise. + */ INLINE bool HTTPChannel:: get_document(const DocumentSpec &url) { begin_request(HTTPEnum::M_get, url, string(), false, 0, 0); @@ -742,16 +570,13 @@ get_document(const DocumentSpec &url) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_subdocument -// Access: Published -// Description: Retrieves only the specified byte range of the -// indicated document. If last_byte is 0, it stands for -// the last byte of the document. When a subdocument is -// requested, get_file_size() and get_bytes_downloaded() -// will report the number of bytes of the subdocument, -// not of the complete document. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves only the specified byte range of the indicated document. If + * last_byte is 0, it stands for the last byte of the document. When a + * subdocument is requested, get_file_size() and get_bytes_downloaded() will + * report the number of bytes of the subdocument, not of the complete + * document. + */ INLINE bool HTTPChannel:: get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { begin_request(HTTPEnum::M_get, url, string(), false, first_byte, last_byte); @@ -760,15 +585,12 @@ get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_header -// Access: Published -// Description: Like get_document(), except only the header -// associated with the document is retrieved. This may -// be used to test for existence of the document; it -// might also return the size of the document (if the -// server gives us this information). -//////////////////////////////////////////////////////////////////// +/** + * Like get_document(), except only the header associated with the document is + * retrieved. This may be used to test for existence of the document; it + * might also return the size of the document (if the server gives us this + * information). + */ INLINE bool HTTPChannel:: get_header(const DocumentSpec &url) { begin_request(HTTPEnum::M_head, url, string(), false, 0, 0); @@ -777,12 +599,9 @@ get_header(const DocumentSpec &url) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::post_form -// Access: Published -// Description: Posts form data to a particular URL and retrieves the -// response. -//////////////////////////////////////////////////////////////////// +/** + * Posts form data to a particular URL and retrieves the response. + */ INLINE bool HTTPChannel:: post_form(const DocumentSpec &url, const string &body) { begin_request(HTTPEnum::M_post, url, body, false, 0, 0); @@ -791,12 +610,10 @@ post_form(const DocumentSpec &url, const string &body) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::put_document -// Access: Published -// Description: Uploads the indicated body to the server to replace -// the indicated URL, if the server allows this. -//////////////////////////////////////////////////////////////////// +/** + * Uploads the indicated body to the server to replace the indicated URL, if + * the server allows this. + */ INLINE bool HTTPChannel:: put_document(const DocumentSpec &url, const string &body) { begin_request(HTTPEnum::M_put, url, body, false, 0, 0); @@ -805,11 +622,9 @@ put_document(const DocumentSpec &url, const string &body) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::delete_document -// Access: Published -// Description: Requests the server to remove the indicated URL. -//////////////////////////////////////////////////////////////////// +/** + * Requests the server to remove the indicated URL. + */ INLINE bool HTTPChannel:: delete_document(const DocumentSpec &url) { begin_request(HTTPEnum::M_delete, url, string(), false, 0, 0); @@ -818,13 +633,10 @@ delete_document(const DocumentSpec &url) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_trace -// Access: Published -// Description: Sends a TRACE message to the server, which should -// return back the same message as the server received -// it, allowing inspection of proxy hops, etc. -//////////////////////////////////////////////////////////////////// +/** + * Sends a TRACE message to the server, which should return back the same + * message as the server received it, allowing inspection of proxy hops, etc. + */ INLINE bool HTTPChannel:: get_trace(const DocumentSpec &url) { begin_request(HTTPEnum::M_trace, url, string(), false, 0, 0); @@ -833,18 +645,13 @@ get_trace(const DocumentSpec &url) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::connect_to -// Access: Published -// Description: Establish a direct connection to the server and port -// indicated by the URL, but do not issue any HTTP -// requests. If successful, the connection may then be -// taken to use for whatever purposes you like by -// calling get_connection(). -// -// This establishes a blocking I/O socket. Also see -// begin_connect_to(). -//////////////////////////////////////////////////////////////////// +/** + * Establish a direct connection to the server and port indicated by the URL, + * but do not issue any HTTP requests. If successful, the connection may then + * be taken to use for whatever purposes you like by calling get_connection(). + * + * This establishes a blocking I/O socket. Also see begin_connect_to(). + */ INLINE bool HTTPChannel:: connect_to(const DocumentSpec &url) { begin_request(HTTPEnum::M_connect, url, string(), false, 0, 0); @@ -853,13 +660,10 @@ connect_to(const DocumentSpec &url) { return is_connection_ready(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_options -// Access: Published -// Description: Sends an OPTIONS message to the server, which should -// query the available options, possibly in relation to -// a specified URL. -//////////////////////////////////////////////////////////////////// +/** + * Sends an OPTIONS message to the server, which should query the available + * options, possibly in relation to a specified URL. + */ INLINE bool HTTPChannel:: get_options(const DocumentSpec &url) { begin_request(HTTPEnum::M_options, url, string(), false, 0, 0); @@ -868,163 +672,124 @@ get_options(const DocumentSpec &url) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_get_document -// Access: Published -// Description: Begins a non-blocking request to retrieve a given -// document. This method will return immediately, even -// before a connection to the server has necessarily -// been established; you must then call run() from time -// to time until the return value of run() is false. -// Then you may check is_valid() and get_status_code() -// to determine the status of your request. -// -// If a previous request had been pending, that request -// is discarded. -//////////////////////////////////////////////////////////////////// +/** + * Begins a non-blocking request to retrieve a given document. This method + * will return immediately, even before a connection to the server has + * necessarily been established; you must then call run() from time to time + * until the return value of run() is false. Then you may check is_valid() + * and get_status_code() to determine the status of your request. + * + * If a previous request had been pending, that request is discarded. + */ INLINE void HTTPChannel:: begin_get_document(const DocumentSpec &url) { begin_request(HTTPEnum::M_get, url, string(), true, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_get_subdocument -// Access: Published -// Description: Begins a non-blocking request to retrieve only the -// specified byte range of the indicated document. If -// last_byte is 0, it stands for the last byte of the -// document. When a subdocument is requested, -// get_file_size() and get_bytes_downloaded() will -// report the number of bytes of the subdocument, not of -// the complete document. -//////////////////////////////////////////////////////////////////// +/** + * Begins a non-blocking request to retrieve only the specified byte range of + * the indicated document. If last_byte is 0, it stands for the last byte of + * the document. When a subdocument is requested, get_file_size() and + * get_bytes_downloaded() will report the number of bytes of the subdocument, + * not of the complete document. + */ INLINE void HTTPChannel:: -begin_get_subdocument(const DocumentSpec &url, size_t first_byte, +begin_get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte) { begin_request(HTTPEnum::M_get, url, string(), true, first_byte, last_byte); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_get_header -// Access: Published -// Description: Begins a non-blocking request to retrieve a given -// header. See begin_get_document() and get_header(). -//////////////////////////////////////////////////////////////////// +/** + * Begins a non-blocking request to retrieve a given header. See + * begin_get_document() and get_header(). + */ INLINE void HTTPChannel:: begin_get_header(const DocumentSpec &url) { begin_request(HTTPEnum::M_head, url, string(), true, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_post_form -// Access: Published -// Description: Posts form data to a particular URL and retrieves the -// response, all using non-blocking I/O. See -// begin_get_document() and post_form(). -// -// It is important to note that you *must* call run() -// repeatedly after calling this method until run() -// returns false, and you may not call any other -// document posting or retrieving methods using the -// HTTPChannel object in the interim, or your form data -// may not get posted. -//////////////////////////////////////////////////////////////////// +/** + * Posts form data to a particular URL and retrieves the response, all using + * non-blocking I/O. See begin_get_document() and post_form(). + * + * It is important to note that you *must* call run() repeatedly after calling + * this method until run() returns false, and you may not call any other + * document posting or retrieving methods using the HTTPChannel object in the + * interim, or your form data may not get posted. + */ INLINE void HTTPChannel:: begin_post_form(const DocumentSpec &url, const string &body) { begin_request(HTTPEnum::M_post, url, body, true, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_connect_to -// Access: Published -// Description: Begins a non-blocking request to establish a direct -// connection to the server and port indicated by the -// URL. No HTTP requests will be issued beyond what is -// necessary to establish the connection. When run() -// has finished, you may call is_connection_ready() to -// determine if the connection was successfully -// established. -// -// If successful, the connection may then be taken to -// use for whatever purposes you like by calling -// get_connection(). -// -// This establishes a nonblocking I/O socket. Also see -// connect_to(). -//////////////////////////////////////////////////////////////////// +/** + * Begins a non-blocking request to establish a direct connection to the + * server and port indicated by the URL. No HTTP requests will be issued + * beyond what is necessary to establish the connection. When run() has + * finished, you may call is_connection_ready() to determine if the connection + * was successfully established. + * + * If successful, the connection may then be taken to use for whatever + * purposes you like by calling get_connection(). + * + * This establishes a nonblocking I/O socket. Also see connect_to(). + */ INLINE void HTTPChannel:: begin_connect_to(const DocumentSpec &url) { begin_request(HTTPEnum::M_connect, url, string(), true, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_bytes_downloaded -// Access: Published -// Description: Returns the number of bytes downloaded during the -// last (or current) download_to_file() or -// download_to_ram operation(). This can be used in -// conjunction with get_file_size() to report the -// percent complete (but be careful, since -// get_file_size() may return 0 if the server has not -// told us the size of the file). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes downloaded during the last (or current) + * download_to_file() or download_to_ram operation(). This can be used in + * conjunction with get_file_size() to report the percent complete (but be + * careful, since get_file_size() may return 0 if the server has not told us + * the size of the file). + */ INLINE size_t HTTPChannel:: get_bytes_downloaded() const { return _bytes_downloaded; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_bytes_requested -// Access: Published -// Description: When download throttling is in effect -// (set_download_throttle() has been set to true) and -// non-blocking I/O methods (like begin_get_document()) -// are used, this returns the number of bytes -// "requested" from the server so far: that is, the -// theoretical maximum value for get_bytes_downloaded(), -// if the server has been keeping up with our demand. -// -// If this number is less than get_bytes_downloaded(), -// then the server has not been supplying bytes fast -// enough to meet our own download throttle rate. -// -// When download throttling is not in effect, or when -// the blocking I/O methods (like get_document(), etc.) -// are used, this returns 0. -//////////////////////////////////////////////////////////////////// +/** + * When download throttling is in effect (set_download_throttle() has been set + * to true) and non-blocking I/O methods (like begin_get_document()) are used, + * this returns the number of bytes "requested" from the server so far: that + * is, the theoretical maximum value for get_bytes_downloaded(), if the server + * has been keeping up with our demand. + * + * If this number is less than get_bytes_downloaded(), then the server has not + * been supplying bytes fast enough to meet our own download throttle rate. + * + * When download throttling is not in effect, or when the blocking I/O methods + * (like get_document(), etc.) are used, this returns 0. + */ INLINE size_t HTTPChannel:: get_bytes_requested() const { return _bytes_requested; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::is_download_complete -// Access: Published -// Description: Returns true when a download_to() or -// download_to_ram() has executed and the file has been -// fully downloaded. If this still returns false after -// processing has completed, there was an error in -// transmission. -// -// Note that simply testing is_download_complete() does -// not prove that the requested document was successfully -// retrieved--you might have just downloaded the "404 -// not found" stub (for instance) that a server would -// provide in response to some error condition. You -// should also check is_valid() to prove that the file -// you expected has been successfully retrieved. -//////////////////////////////////////////////////////////////////// +/** + * Returns true when a download_to() or download_to_ram() has executed and the + * file has been fully downloaded. If this still returns false after + * processing has completed, there was an error in transmission. + * + * Note that simply testing is_download_complete() does not prove that the + * requested document was successfully retrieved--you might have just + * downloaded the "404 not found" stub (for instance) that a server would + * provide in response to some error condition. You should also check + * is_valid() to prove that the file you expected has been successfully + * retrieved. + */ INLINE bool HTTPChannel:: is_download_complete() const { return (_download_dest != DD_none && (_state == S_read_body || _state == S_read_trailer)); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::StatusEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPChannel::StatusEntry:: StatusEntry() { _status_code = SC_incomplete; diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 454cec9d97..7dbe4d1a32 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -1,16 +1,15 @@ -// Filename: httpChannel.cxx -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpChannel.cxx + * @author drose + * @date 2002-09-24 + */ #include "httpChannel.h" #include "httpClient.h" @@ -38,18 +37,16 @@ TypeHandle HTTPChannel::_type_handle; #define _NOTIFY_HTTP_CHANNEL_ID "[" << this << "] " -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPChannel:: HTTPChannel(HTTPClient *client) : _client(client) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "created.\n"; } @@ -72,14 +69,13 @@ HTTPChannel(HTTPClient *client) : _seconds_per_update = downloader_frequency; _max_updates_per_second = 1.0f / _seconds_per_update; _bytes_per_update = int(_max_bytes_per_second * _seconds_per_update); - + // _nonblocking is true if the socket is actually in non-blocking mode. _nonblocking = false; - // _wanted_nonblocking is true if the user specifically requested - // one of the non-blocking interfaces. It is false if the socket is - // only incidentally non-blocking (for instance, because - // SIMPLE_THREADS is on). + // _wanted_nonblocking is true if the user specifically requested one of the + // non-blocking interfaces. It is false if the socket is only incidentally + // non-blocking (for instance, because SIMPLE_THREADS is on). _wanted_nonblocking = false; _want_ssl = false; @@ -116,16 +112,14 @@ HTTPChannel(HTTPClient *client) : _download_to_stream = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPChannel:: ~HTTPChannel() { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "destroyed.\n"; } @@ -133,13 +127,10 @@ HTTPChannel:: reset_download_to(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_status_string -// Access: Published -// Description: Returns the string as returned by the server -// describing the status code for humans. This may or -// may not be meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string as returned by the server describing the status code for + * humans. This may or may not be meaningful. + */ string HTTPChannel:: get_status_string() const { switch (_status_entry._status_code) { @@ -205,13 +196,10 @@ get_status_string() const { return _status_entry._status_string; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_header_value -// Access: Published -// Description: Returns the HTML header value associated with the -// indicated key, or empty string if the key was not -// defined in the message returned by the server. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTML header value associated with the indicated key, or empty + * string if the key was not defined in the message returned by the server. + */ string HTTPChannel:: get_header_value(const string &key) const { Headers::const_iterator hi = _headers.find(downcase(key)); @@ -221,14 +209,11 @@ get_header_value(const string &key) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::will_close_connection -// Access: Published -// Description: Returns true if the server has indicated it will -// close the connection after this document has been -// read, or false if it will remain open (and future -// documents may be requested on the same connection). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the server has indicated it will close the connection after + * this document has been read, or false if it will remain open (and future + * documents may be requested on the same connection). + */ bool HTTPChannel:: will_close_connection() const { if (get_http_version() < HTTPEnum::HV_11) { @@ -251,22 +236,17 @@ will_close_connection() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_file_size -// Access: Published, Virtual -// Description: Returns the size of the file, if it is known. -// Returns the value set by set_expected_file_size() if -// the file size is not known, or 0 if this value was -// not set. -// -// If the file is dynamically generated, the size may -// not be available until a read has started -// (e.g. open_read_body() has been called); and even -// then it may increase as more of the file is read due -// to the nature of HTTP/1.1 requests which can change -// their minds midstream about how much data they're -// sending you. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the file, if it is known. Returns the value set by + * set_expected_file_size() if the file size is not known, or 0 if this value + * was not set. + * + * If the file is dynamically generated, the size may not be available until a + * read has started (e.g. open_read_body() has been called); and even then it + * may increase as more of the file is read due to the nature of HTTP/1.1 + * requests which can change their minds midstream about how much data they're + * sending you. + */ streamsize HTTPChannel:: get_file_size() const { if (_got_file_size) { @@ -280,12 +260,10 @@ get_file_size() const { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::write_headers -// Access: Published -// Description: Outputs a list of all headers defined by the server -// to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of all headers defined by the server to the indicated output + * stream. + */ void HTTPChannel:: write_headers(ostream &out) const { Headers::const_iterator hi; @@ -294,24 +272,21 @@ write_headers(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run -// Access: Published -// Description: This must be called from time to time when -// non-blocking I/O is in use. It checks for data -// coming in on the socket and writes data out to the -// socket when possible, and does whatever processing is -// required towards completing the current task. -// -// The return value is true if the task is still pending -// (and run() will need to be called again in the -// future), or false if the current task is complete. -//////////////////////////////////////////////////////////////////// +/** + * This must be called from time to time when non-blocking I/O is in use. It + * checks for data coming in on the socket and writes data out to the socket + * when possible, and does whatever processing is required towards completing + * the current task. + * + * The return value is true if the task is still pending (and run() will need + * to be called again in the future), or false if the current task is + * complete. + */ bool HTTPChannel:: run() { if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "run().\n"; } @@ -336,9 +311,9 @@ run() { _bytes_requested += _bytes_per_update * num_potential_updates; if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID - << "elapsed = " << elapsed << " num_potential_updates = " - << num_potential_updates << " bytes_requested = " + << _NOTIFY_HTTP_CHANNEL_ID + << "elapsed = " << elapsed << " num_potential_updates = " + << num_potential_updates << " bytes_requested = " << _bytes_requested << "\n"; } } @@ -370,7 +345,7 @@ run() { /* if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "begin run(), _state = " << _state << ", _done_state = " << _done_state << "\n"; } @@ -382,17 +357,17 @@ run() { bool repeat_later; do { - // If we're in a state that expects to have a connection already - // (that is, any state other that S_try_next_proxy), then - // reestablish the connection if it has been dropped. + // If we're in a state that expects to have a connection already (that is, + // any state other that S_try_next_proxy), then reestablish the connection + // if it has been dropped. if (_bio.is_null() && _state != S_try_next_proxy) { if (_connect_count > http_max_connect_count) { - // Too many connection attempts; just give up. We should - // never trigger this failsafe, since the code in each - // individual case has similar logic to prevent more than two - // consecutive lost connections. + // Too many connection attempts; just give up. We should never + // trigger this failsafe, since the code in each individual case has + // similar logic to prevent more than two consecutive lost + // connections. downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Too many lost connections, giving up.\n"; _status_entry._status_code = SC_lost_connection; _state = S_failure; @@ -413,19 +388,19 @@ run() { if (downloader_cat.is_debug()) { if (_connect_count > 0) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "Reconnecting to " << _bio->get_server_name() << ":" + << _NOTIFY_HTTP_CHANNEL_ID + << "Reconnecting to " << _bio->get_server_name() << ":" << _bio->get_port() << "\n"; } else { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "Connecting to " << _bio->get_server_name() << ":" + << _NOTIFY_HTTP_CHANNEL_ID + << "Connecting to " << _bio->get_server_name() << ":" << _bio->get_port() << "\n"; } } - + _state = S_connecting; - _started_connecting_time = + _started_connecting_time = TrueClock::get_global_ptr()->get_short_time(); _connect_count++; } @@ -433,7 +408,7 @@ run() { /* if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "continue run(), _state = " << _state << "\n"; } */ @@ -446,71 +421,71 @@ run() { case S_connecting: repeat_later = run_connecting(); break; - + case S_connecting_wait: repeat_later = run_connecting_wait(); break; - + case S_http_proxy_ready: repeat_later = run_http_proxy_ready(); break; - + case S_http_proxy_request_sent: repeat_later = run_http_proxy_request_sent(); break; - + case S_http_proxy_reading_header: repeat_later = run_http_proxy_reading_header(); break; - + case S_socks_proxy_greet: repeat_later = run_socks_proxy_greet(); break; - + case S_socks_proxy_greet_reply: repeat_later = run_socks_proxy_greet_reply(); break; - + case S_socks_proxy_connect: repeat_later = run_socks_proxy_connect(); break; - + case S_socks_proxy_connect_reply: repeat_later = run_socks_proxy_connect_reply(); break; - + case S_setup_ssl: repeat_later = run_setup_ssl(); break; - + case S_ssl_handshake: repeat_later = run_ssl_handshake(); break; - + case S_ready: repeat_later = run_ready(); break; - + case S_request_sent: repeat_later = run_request_sent(); break; - + case S_reading_header: repeat_later = run_reading_header(); break; - + case S_start_direct_file_read: repeat_later = run_start_direct_file_read(); break; - + case S_read_header: repeat_later = run_read_header(); break; - + case S_begin_body: repeat_later = run_begin_body(); break; - + case S_reading_body: repeat_later = run_reading_body(); break; @@ -522,10 +497,10 @@ run() { case S_read_trailer: repeat_later = run_read_trailer(); break; - + default: downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Unhandled state " << _state << "\n"; return false; } @@ -541,7 +516,7 @@ run() { /* if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "later run(), _state = " << _state << ", _done_state = " << _done_state << "\n"; } @@ -551,24 +526,19 @@ run() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::open_read_body -// Access: Published -// Description: Returns a newly-allocated istream suitable for -// reading the body of the document. This may only be -// called immediately after a call to get_document() or -// post_form(), or after a call to run() has returned -// false. -// -// Note that, in nonblocking mode, the returned stream -// may report an early EOF, even before the actual end -// of file. When this happens, you should call -// stream->is_closed() to determine whether you should -// attempt to read some more later. -// -// The user is responsible for passing the returned -// istream to close_read_body() later. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated istream suitable for reading the body of the + * document. This may only be called immediately after a call to + * get_document() or post_form(), or after a call to run() has returned false. + * + * Note that, in nonblocking mode, the returned stream may report an early + * EOF, even before the actual end of file. When this happens, you should + * call stream->is_closed() to determine whether you should attempt to read + * some more later. + * + * The user is responsible for passing the returned istream to + * close_read_body() later. + */ ISocketStream *HTTPChannel:: open_read_body() { reset_body_stream(); @@ -581,18 +551,18 @@ open_read_body() { ISocketStream *result; if (transfer_coding == "chunked") { - // "chunked" transfer encoding. This means we will have to decode - // the length of the file as we read it in chunks. The - // IChunkedStream does this. + // "chunked" transfer encoding. This means we will have to decode the + // length of the file as we read it in chunks. The IChunkedStream does + // this. _state = S_reading_body; _read_index++; result = new IChunkedStream(_source, this); } else { - // If the transfer encoding is anything else, assume "identity". - // This is just the literal characters following the header, up - // until _file_size bytes have been read (if content-length was - // specified), or till end of file otherwise. + // If the transfer encoding is anything else, assume "identity". This is + // just the literal characters following the header, up until _file_size + // bytes have been read (if content-length was specified), or till end of + // file otherwise. _state = S_reading_body; _read_index++; result = new IIdentityStream(_source, this, _got_file_size, _file_size); @@ -605,22 +575,19 @@ open_read_body() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::close_read_body -// Access: Public -// Description: Closes a file opened by a previous call to -// open_read_body(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_body(). This really + * just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void HTTPChannel:: close_read_body(istream *stream) const { if (stream != (istream *)NULL) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~istream(); (*global_operator_delete)(stream); @@ -630,40 +597,30 @@ close_read_body(istream *stream) const { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::download_to_file -// Access: Published -// Description: Specifies the name of a file to download the -// resulting document to. This should be called -// immediately after get_document() or -// begin_get_document() or related functions. -// -// In the case of the blocking I/O methods like -// get_document(), this function will download the -// entire document to the file and return true if it was -// successfully downloaded, false otherwise. -// -// In the case of non-blocking I/O methods like -// begin_get_document(), this function simply indicates an -// intention to download to the indicated file. It -// returns true if the file can be opened for writing, -// false otherwise, but the contents will not be -// completely downloaded until run() has returned false. -// At this time, it is possible that a communications -// error will have left a partial file, so -// is_download_complete() may be called to test this. -// -// If subdocument_resumes is true and the document in -// question was previously requested as a subdocument -// (i.e. get_subdocument() with a first_byte value -// greater than zero), this will automatically seek to -// the appropriate byte within the file for writing the -// output. In this case, the file must already exist -// and must have at least first_byte bytes in it. If -// subdocument_resumes is false, a subdocument will -// always be downloaded beginning at the first byte of -// the file. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a file to download the resulting document to. This + * should be called immediately after get_document() or begin_get_document() + * or related functions. + * + * In the case of the blocking I/O methods like get_document(), this function + * will download the entire document to the file and return true if it was + * successfully downloaded, false otherwise. + * + * In the case of non-blocking I/O methods like begin_get_document(), this + * function simply indicates an intention to download to the indicated file. + * It returns true if the file can be opened for writing, false otherwise, but + * the contents will not be completely downloaded until run() has returned + * false. At this time, it is possible that a communications error will have + * left a partial file, so is_download_complete() may be called to test this. + * + * If subdocument_resumes is true and the document in question was previously + * requested as a subdocument (i.e. get_subdocument() with a first_byte value + * greater than zero), this will automatically seek to the appropriate byte + * within the file for writing the output. In this case, the file must + * already exist and must have at least first_byte bytes in it. If + * subdocument_resumes is false, a subdocument will always be downloaded + * beginning at the first byte of the file. + */ bool HTTPChannel:: download_to_file(const Filename &filename, bool subdocument_resumes) { reset_download_to(); @@ -674,8 +631,8 @@ download_to_file(const Filename &filename, bool subdocument_resumes) { _download_dest = DD_file; if (_wanted_nonblocking && _state != S_read_header) { - // In nonblocking mode, we can't start the download yet; that will - // be done later as run() is called. + // In nonblocking mode, we can't start the download yet; that will be done + // later as run() is called. return true; } @@ -690,37 +647,29 @@ download_to_file(const Filename &filename, bool subdocument_resumes) { return is_download_complete() && is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::download_to_ram -// Access: Published -// Description: Specifies a Ramfile object to download the -// resulting document to. This should be called -// immediately after get_document() or -// begin_get_document() or related functions. -// -// In the case of the blocking I/O methods like -// get_document(), this function will download the -// entire document to the Ramfile and return true if it -// was successfully downloaded, false otherwise. -// -// In the case of non-blocking I/O methods like -// begin_get_document(), this function simply indicates an -// intention to download to the indicated Ramfile. It -// returns true if the file can be opened for writing, -// false otherwise, but the contents will not be -// completely downloaded until run() has returned false. -// At this time, it is possible that a communications -// error will have left a partial file, so -// is_download_complete() may be called to test this. -// -// If subdocument_resumes is true and the document in -// question was previously requested as a subdocument -// (i.e. get_subdocument() with a first_byte value -// greater than zero), this will automatically seek to -// the appropriate byte within the Ramfile for writing -// the output. In this case, the Ramfile must already -// have at least first_byte bytes in it. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a Ramfile object to download the resulting document to. This + * should be called immediately after get_document() or begin_get_document() + * or related functions. + * + * In the case of the blocking I/O methods like get_document(), this function + * will download the entire document to the Ramfile and return true if it was + * successfully downloaded, false otherwise. + * + * In the case of non-blocking I/O methods like begin_get_document(), this + * function simply indicates an intention to download to the indicated + * Ramfile. It returns true if the file can be opened for writing, false + * otherwise, but the contents will not be completely downloaded until run() + * has returned false. At this time, it is possible that a communications + * error will have left a partial file, so is_download_complete() may be + * called to test this. + * + * If subdocument_resumes is true and the document in question was previously + * requested as a subdocument (i.e. get_subdocument() with a first_byte value + * greater than zero), this will automatically seek to the appropriate byte + * within the Ramfile for writing the output. In this case, the Ramfile must + * already have at least first_byte bytes in it. + */ bool HTTPChannel:: download_to_ram(Ramfile *ramfile, bool subdocument_resumes) { nassertr(ramfile != (Ramfile *)NULL, false); @@ -731,8 +680,8 @@ download_to_ram(Ramfile *ramfile, bool subdocument_resumes) { _subdocument_resumes = (subdocument_resumes && _first_byte_delivered != 0); if (_wanted_nonblocking && _state != S_read_header) { - // In nonblocking mode, we can't start the download yet; that will - // be done later as run() is called. + // In nonblocking mode, we can't start the download yet; that will be done + // later as run() is called. return true; } @@ -747,40 +696,30 @@ download_to_ram(Ramfile *ramfile, bool subdocument_resumes) { return is_download_complete() && is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::download_to_stream -// Access: Published -// Description: Specifies the name of an ostream to download the -// resulting document to. This should be called -// immediately after get_document() or -// begin_get_document() or related functions. -// -// In the case of the blocking I/O methods like -// get_document(), this function will download the -// entire document to the file and return true if it was -// successfully downloaded, false otherwise. -// -// In the case of non-blocking I/O methods like -// begin_get_document(), this function simply indicates an -// intention to download to the indicated file. It -// returns true if the file can be opened for writing, -// false otherwise, but the contents will not be -// completely downloaded until run() has returned false. -// At this time, it is possible that a communications -// error will have left a partial file, so -// is_download_complete() may be called to test this. -// -// If subdocument_resumes is true and the document in -// question was previously requested as a subdocument -// (i.e. get_subdocument() with a first_byte value -// greater than zero), this will automatically seek to -// the appropriate byte within the file for writing the -// output. In this case, the file must already exist -// and must have at least first_byte bytes in it. If -// subdocument_resumes is false, a subdocument will -// always be downloaded beginning at the first byte of -// the file. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of an ostream to download the resulting document to. + * This should be called immediately after get_document() or + * begin_get_document() or related functions. + * + * In the case of the blocking I/O methods like get_document(), this function + * will download the entire document to the file and return true if it was + * successfully downloaded, false otherwise. + * + * In the case of non-blocking I/O methods like begin_get_document(), this + * function simply indicates an intention to download to the indicated file. + * It returns true if the file can be opened for writing, false otherwise, but + * the contents will not be completely downloaded until run() has returned + * false. At this time, it is possible that a communications error will have + * left a partial file, so is_download_complete() may be called to test this. + * + * If subdocument_resumes is true and the document in question was previously + * requested as a subdocument (i.e. get_subdocument() with a first_byte value + * greater than zero), this will automatically seek to the appropriate byte + * within the file for writing the output. In this case, the file must + * already exist and must have at least first_byte bytes in it. If + * subdocument_resumes is false, a subdocument will always be downloaded + * beginning at the first byte of the file. + */ bool HTTPChannel:: download_to_stream(ostream *strm, bool subdocument_resumes) { reset_download_to(); @@ -791,8 +730,8 @@ download_to_stream(ostream *strm, bool subdocument_resumes) { _download_dest = DD_stream; if (_wanted_nonblocking && _state != S_read_header) { - // In nonblocking mode, we can't start the download yet; that will - // be done later as run() is called. + // In nonblocking mode, we can't start the download yet; that will be done + // later as run() is called. return true; } @@ -807,18 +746,14 @@ download_to_stream(ostream *strm, bool subdocument_resumes) { return is_download_complete() && is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_connection -// Access: Published -// Description: Returns the connection that was established via a -// previous call to connect_to() or begin_connect_to(), -// or NULL if the connection attempt failed or if those -// methods have not recently been called. -// -// This stream has been allocated from the free store. -// It is the user's responsibility to delete this -// pointer when finished with it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the connection that was established via a previous call to + * connect_to() or begin_connect_to(), or NULL if the connection attempt + * failed or if those methods have not recently been called. + * + * This stream has been allocated from the free store. It is the user's + * responsibility to delete this pointer when finished with it. + */ SocketStream *HTTPChannel:: get_connection() { if (!is_connection_ready()) { @@ -831,7 +766,7 @@ get_connection() { // We're now passing ownership of the connection to the caller. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "passing ownership of connection to caller.\n"; } reset_to_new(); @@ -839,12 +774,9 @@ get_connection() { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::downcase -// Access: Public, Static -// Description: Returns the input string with all uppercase letters -// converted to lowercase. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input string with all uppercase letters converted to lowercase. + */ string HTTPChannel:: downcase(const string &s) { string result; @@ -856,12 +788,9 @@ downcase(const string &s) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::body_stream_destructs -// Access: Public -// Description: Called by ISocketStream destructor when _body_stream -// is destructing. -//////////////////////////////////////////////////////////////////// +/** + * Called by ISocketStream destructor when _body_stream is destructing. + */ void HTTPChannel:: body_stream_destructs(ISocketStream *stream) { if (stream == _body_stream) { @@ -870,12 +799,12 @@ body_stream_destructs(ISocketStream *stream) { case ISocketStream::RS_complete: finished_body(false); break; - + case ISocketStream::RS_error: _state = HTTPChannel::S_failure; _status_entry._status_code = HTTPChannel::SC_lost_connection; break; - + default: break; } @@ -886,57 +815,54 @@ body_stream_destructs(ISocketStream *stream) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reached_done_state -// Access: Private -// Description: Called by run() after it reaches the done state, this -// simply checks to see if a download was requested, and -// begins the download if it has been. -//////////////////////////////////////////////////////////////////// +/** + * Called by run() after it reaches the done state, this simply checks to see + * if a download was requested, and begins the download if it has been. + */ bool HTTPChannel:: reached_done_state() { /* if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "terminating run(), _state = " << _state << ", _done_state = " << _done_state << "\n"; } */ if (_state == S_failure) { - // We had to give up. Each proxy we tried, in sequence, failed. - // But maybe the last attempt didn't give us the most informative - // response; go back and find the best one. + // We had to give up. Each proxy we tried, in sequence, failed. But + // maybe the last attempt didn't give us the most informative response; go + // back and find the best one. if (!_status_list.empty()) { _status_list.push_back(_status_entry); if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Reexamining failure responses.\n"; } size_t best_i = 0; if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << " " << 0 << ". " << _status_list[0]._status_code << " " << _status_list[0]._status_string << "\n"; } for (size_t i = 1; i < _status_list.size(); i++) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << " " << i << ". " << _status_list[i]._status_code << " " << _status_list[i]._status_string << "\n"; } - if (more_useful_status_code(_status_list[i]._status_code, + if (more_useful_status_code(_status_list[i]._status_code, _status_list[best_i]._status_code)) { best_i = i; } } if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "chose index " << best_i << ", above.\n"; } _status_entry = _status_list[best_i]; @@ -952,14 +878,14 @@ reached_done_state() { if (_download_dest == DD_none) { // All done. return false; - + } else { // Oops, we have to download the body now. open_read_body(); if (_body_stream == (ISocketStream *)NULL) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Unable to download body: " << _request.get_url() << "\n"; } return false; @@ -977,21 +903,17 @@ reached_done_state() { } } } - -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_try_next_proxy -// Access: Private -// Description: This state is reached when a previous connection -// attempt fails. If we have multiple proxies in line -// to try, it sets us up for the next proxy and tries to -// connect again; otherwise, it sets the state to -// S_failure. -//////////////////////////////////////////////////////////////////// + +/** + * This state is reached when a previous connection attempt fails. If we have + * multiple proxies in line to try, it sets us up for the next proxy and tries + * to connect again; otherwise, it sets the state to S_failure. + */ bool HTTPChannel:: run_try_next_proxy() { if (_proxy_next_index < _proxies.size()) { - // Record the previous proxy's status entry, so we can come back - // to it later if we get nonsense from the remaining proxies. + // Record the previous proxy's status entry, so we can come back to it + // later if we get nonsense from the remaining proxies. _status_list.push_back(_status_entry); _status_entry = StatusEntry(); @@ -1010,13 +932,11 @@ run_try_next_proxy() { _state = S_failure; return false; } - -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_connecting -// Access: Private -// Description: In this state, we have not yet established a -// network connection to the server (or proxy). -//////////////////////////////////////////////////////////////////// + +/** + * In this state, we have not yet established a network connection to the + * server (or proxy). + */ bool HTTPChannel:: run_connecting() { _status_entry = StatusEntry(); @@ -1027,8 +947,8 @@ run_connecting() { return false; } downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID - << "Could not connect to " << _bio->get_server_name() << ":" + << _NOTIFY_HTTP_CHANNEL_ID + << "Could not connect to " << _bio->get_server_name() << ":" << _bio->get_port() << "\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); _status_entry._status_code = SC_no_connection; @@ -1038,8 +958,8 @@ run_connecting() { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "Connected to " << _bio->get_server_name() << ":" + << _NOTIFY_HTTP_CHANNEL_ID + << "Connected to " << _bio->get_server_name() << ":" << _bio->get_port() << "\n"; } @@ -1060,20 +980,18 @@ run_connecting() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_connecting_wait -// Access: Private -// Description: Here we have begun to establish a nonblocking -// connection, but we got a come-back-later message, so -// we are waiting for the socket to finish connecting. -//////////////////////////////////////////////////////////////////// +/** + * Here we have begun to establish a nonblocking connection, but we got a + * come-back-later message, so we are waiting for the socket to finish + * connecting. + */ bool HTTPChannel:: run_connecting_wait() { int fd = -1; BIO_get_fd(*_bio, &fd); if (fd < 0) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "nonblocking socket BIO has no file descriptor.\n"; // This shouldn't be possible. _status_entry._status_code = SC_internal_error; @@ -1083,7 +1001,7 @@ run_connecting_wait() { if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "waiting to connect to " << _request.get_url().get_server_and_port() << ".\n"; } fd_set wset; @@ -1091,8 +1009,8 @@ run_connecting_wait() { FD_SET(fd, &wset); struct timeval tv; if (get_blocking_connect()) { - // Since we'll be blocking on this connect, fill in the timeout - // into the structure. + // Since we'll be blocking on this connect, fill in the timeout into the + // structure. tv.tv_sec = (int)_connect_timeout; tv.tv_usec = (int)((_connect_timeout - tv.tv_sec) * 1000000.0); } else { @@ -1103,24 +1021,24 @@ run_connecting_wait() { int errcode = select(fd + 1, NULL, &wset, NULL, &tv); if (errcode < 0) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Error in select.\n"; // This shouldn't be possible. _status_entry._status_code = SC_internal_error; _state = S_try_next_proxy; return false; } - + if (errcode == 0) { // Nothing's happened so far; come back later. if (get_blocking_connect() || - (TrueClock::get_global_ptr()->get_short_time() - + (TrueClock::get_global_ptr()->get_short_time() - _started_connecting_time > get_connect_timeout())) { // Time to give up. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID - << "Timeout connecting to " - << _request.get_url().get_server_and_port() + << _NOTIFY_HTTP_CHANNEL_ID + << "Timeout connecting to " + << _request.get_url().get_server_and_port() << " for " << _request.get_url() << ".\n"; _status_entry._status_code = SC_timeout; @@ -1129,20 +1047,18 @@ run_connecting_wait() { } return true; } - + // The socket is now ready for writing. _state = S_connecting; return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_http_proxy_ready -// Access: Private -// Description: This state is reached only after first establishing a -// connection to the proxy, if a proxy is in use and we -// are tunneling through it via a CONNECT command. -//////////////////////////////////////////////////////////////////// +/** + * This state is reached only after first establishing a connection to the + * proxy, if a proxy is in use and we are tunneling through it via a CONNECT + * command. + */ bool HTTPChannel:: run_http_proxy_ready() { // If there's a request to be sent to the proxy, send it now. @@ -1150,22 +1066,19 @@ run_http_proxy_ready() { if (!server_send(_proxy_request_text, false)) { return true; } - + // All done sending request. _state = S_http_proxy_request_sent; _sent_request_time = TrueClock::get_global_ptr()->get_short_time(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_http_proxy_request_sent -// Access: Private -// Description: This state is reached only after we have sent a -// special message to the proxy and we are waiting for -// the proxy's response. It is not used in the normal -// http-over-proxy case, which does not require a -// special message to the proxy. -//////////////////////////////////////////////////////////////////// +/** + * This state is reached only after we have sent a special message to the + * proxy and we are waiting for the proxy's response. It is not used in the + * normal http-over-proxy case, which does not require a special message to + * the proxy. + */ bool HTTPChannel:: run_http_proxy_request_sent() { // Wait for the first line to come back from the server. @@ -1194,12 +1107,10 @@ run_http_proxy_request_sent() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_http_proxy_reading_header -// Access: Private -// Description: In this state we are reading the header lines from -// the proxy's response to our special message. -//////////////////////////////////////////////////////////////////// +/** + * In this state we are reading the header lines from the proxy's response to + * our special message. + */ bool HTTPChannel:: run_http_proxy_reading_header() { if (parse_http_header()) { @@ -1207,10 +1118,10 @@ run_http_proxy_reading_header() { } _redirect = get_header_value("Location"); - // We can take the proxy's word for it that this is the actual URL - // for the redirect. + // We can take the proxy's word for it that this is the actual URL for the + // redirect. - _server_response_has_no_body = + _server_response_has_no_body = (get_status_code() / 100 == 1 || get_status_code() == 204 || get_status_code() == 304); @@ -1238,9 +1149,9 @@ run_http_proxy_reading_header() { if (!is_valid()) { // Proxy wouldn't open connection. - // Change some of the status codes a proxy might return to - // differentiate them from similar status codes the destination - // server might have returned. + // Change some of the status codes a proxy might return to differentiate + // them from similar status codes the destination server might have + // returned. if (get_status_code() != 407) { _status_entry._status_code += 1000; } @@ -1261,13 +1172,10 @@ run_http_proxy_reading_header() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_socks_proxy_greet -// Access: Private -// Description: This state is reached only after first establishing a -// connection to a SOCKS proxy, with which we now have -// to negotiate a connection. -//////////////////////////////////////////////////////////////////// +/** + * This state is reached only after first establishing a connection to a SOCKS + * proxy, with which we now have to negotiate a connection. + */ bool HTTPChannel:: run_socks_proxy_greet() { static const char socks_greeting[] = { @@ -1284,18 +1192,15 @@ run_socks_proxy_greet() { return true; } _sent_request_time = TrueClock::get_global_ptr()->get_short_time(); - + // All done sending request. _state = S_socks_proxy_greet_reply; return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_socks_proxy_greet_reply -// Access: Private -// Description: We are waiting for the SOCKS proxy to respond to our -// greeting. -//////////////////////////////////////////////////////////////////// +/** + * We are waiting for the SOCKS proxy to respond to our greeting. + */ bool HTTPChannel:: run_socks_proxy_greet_reply() { string reply; @@ -1308,7 +1213,7 @@ run_socks_proxy_greet_reply() { if (reply[0] != 0x05) { // We only speak Socks5. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Rejecting Socks version " << (int)reply[0] << "\n"; _status_entry._status_code = SC_socks_invalid_version; _state = S_try_next_proxy; @@ -1317,7 +1222,7 @@ run_socks_proxy_greet_reply() { if (reply[1] == (char)0xff) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Socks server does not accept our available login methods.\n"; _status_entry._status_code = SC_socks_no_acceptable_login_method; _state = S_try_next_proxy; @@ -1325,15 +1230,14 @@ run_socks_proxy_greet_reply() { } if (reply[1] == 0x00) { - // No login method required. Proceed directly to the connect - // message. + // No login method required. Proceed directly to the connect message. _state = S_socks_proxy_connect; return false; } // The server accepted a login method we didn't offer! downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Socks server accepted unrequested login method " << (int)reply[1] << "\n"; _status_entry._status_code = SC_socks_no_acceptable_login_method; @@ -1341,12 +1245,9 @@ run_socks_proxy_greet_reply() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_socks_proxy_connect -// Access: Private -// Description: The SOCKS proxy has accepted us, and now we may issue -// the connect request. -//////////////////////////////////////////////////////////////////// +/** + * The SOCKS proxy has accepted us, and now we may issue the connect request. + */ bool HTTPChannel:: run_socks_proxy_connect() { static const char socks_connect[] = { @@ -1362,12 +1263,12 @@ run_socks_proxy_connect() { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "Requesting SOCKS5 connection to " + << _NOTIFY_HTTP_CHANNEL_ID + << "Requesting SOCKS5 connection to " << _request.get_url().get_server_and_port() << "\n"; } - string connect = + string connect = string(socks_connect, socks_connect_len) + string(1, (char)hostname.length()) + hostname + @@ -1378,17 +1279,14 @@ run_socks_proxy_connect() { return true; } _sent_request_time = TrueClock::get_global_ptr()->get_short_time(); - + _state = S_socks_proxy_connect_reply; return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_socks_proxy_connect_reply -// Access: Private -// Description: We are waiting for the SOCKS proxy to honor our -// connect request. -//////////////////////////////////////////////////////////////////// +/** + * We are waiting for the SOCKS proxy to honor our connect request. + */ bool HTTPChannel:: run_socks_proxy_connect_reply() { string reply; @@ -1401,7 +1299,7 @@ run_socks_proxy_connect_reply() { if (reply[0] != 0x05) { // We only speak Socks5. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Rejecting Socks version " << (int)reply[0] << "\n"; close_connection(); // connection is now bad. _status_entry._status_code = SC_socks_invalid_version; @@ -1411,7 +1309,7 @@ run_socks_proxy_connect_reply() { if (reply[1] != 0x00) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Connection refused, SOCKS code " << (int)reply[1] << "\n"; /* Socks error codes (from RFC1928): @@ -1432,15 +1330,15 @@ run_socks_proxy_connect_reply() { case 0x04: case 0x05: case 0x06: - // These generally mean the same thing: the SOCKS proxy tried, - // but couldn't reach the host. + // These generally mean the same thing: the SOCKS proxy tried, but + // couldn't reach the host. _status_entry._status_code = SC_socks_no_connection; break; default: _status_entry._status_code = SC_socks_refused; } - + close_connection(); // connection is now bad. _state = S_try_next_proxy; return false; @@ -1466,15 +1364,14 @@ run_socks_proxy_connect_reply() { default: downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Unsupported SOCKS address type: " << (int)reply[3] << "\n"; _status_entry._status_code = SC_socks_invalid_version; _state = S_try_next_proxy; return false; } - // Now put back the bytes we've read so far, and get the rest of - // them. + // Now put back the bytes we've read so far, and get the rest of them. _working_get = reply; if (!server_get_failsafe(reply, total_bytes)) { return true; @@ -1488,25 +1385,25 @@ run_socks_proxy_connect_reply() { case 0x01: // IPv4 { ostringstream strm; - strm << (unsigned int)(unsigned char)reply[4] << "." + strm << (unsigned int)(unsigned char)reply[4] << "." << (unsigned int)(unsigned char)reply[5] << "." - << (unsigned int)(unsigned char)reply[6] << "." + << (unsigned int)(unsigned char)reply[6] << "." << (unsigned int)(unsigned char)reply[7]; connect_host = strm.str(); } break; - + case 0x03: // DNS connect_host = string(&reply[5], (unsigned int)reply[4]); break; } - + int connect_port = (((unsigned int)(unsigned char)reply[total_bytes - 2]) << 8) | ((unsigned int)(unsigned char)reply[total_bytes - 1]); - + downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << _proxy << " directed us to " << connect_host << ":" << connect_port << "\n"; } @@ -1520,12 +1417,10 @@ run_socks_proxy_connect_reply() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_setup_ssl -// Access: Private -// Description: This state begins elevating our existing, unsecure -// connection to a secure, SSL connection. -//////////////////////////////////////////////////////////////////// +/** + * This state begins elevating our existing, unsecure connection to a secure, + * SSL connection. + */ bool HTTPChannel:: run_setup_ssl() { _sbio = BIO_new_ssl(_client->get_ssl_ctx(), true); @@ -1547,13 +1442,13 @@ run_setup_ssl() { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Setting ssl-cipher-list '" << cipher_list << "'\n"; } int result = SSL_set_cipher_list(ssl, cipher_list.c_str()); if (result == 0) { downloader_cat.error() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Invalid cipher list: '" << cipher_list << "'\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); _status_entry._status_code = SC_ssl_internal_failure; @@ -1561,35 +1456,35 @@ run_setup_ssl() { return false; } - // It would be nice to use something like SSL_set_client_cert_cb() - // here to set a callback to provide the certificate should it be - // requested, or even to potentially provide any of a number of - // certificates according to the server's CA presented, but that - // interface as provided by OpenSSL is broken since there's no way - // to pass additional data to the callback function (and hence no - // way to tie it back to the HTTPChannel object, other than by - // building a messy mapping of SSL pointers back to HTTPChannel - // pointers). +/* + * It would be nice to use something like SSL_set_client_cert_cb() here to set + * a callback to provide the certificate should it be requested, or even to + * potentially provide any of a number of certificates according to the + * server's CA presented, but that interface as provided by OpenSSL is broken + * since there's no way to pass additional data to the callback function (and + * hence no way to tie it back to the HTTPChannel object, other than by + * building a messy mapping of SSL pointers back to HTTPChannel pointers). + */ if (_client->load_client_certificate()) { SSL_use_certificate(ssl, _client->_client_certificate_pub); SSL_use_PrivateKey(ssl, _client->_client_certificate_priv); if (!SSL_check_private_key(ssl)) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Client private key does not match public key!\n"; } } if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "SSL Ciphers available:\n"; const char *name; int pri = 0; name = SSL_get_cipher_list(ssl, pri); while (name != NULL) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << " " << pri + 1 << ". " << name << "\n"; pri++; name = SSL_get_cipher_list(ssl, pri); @@ -1598,26 +1493,22 @@ run_setup_ssl() { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "performing SSL handshake\n"; } _state = S_ssl_handshake; - // We start the connect timer over again when we reach the SSL - // handshake. - _started_connecting_time = + // We start the connect timer over again when we reach the SSL handshake. + _started_connecting_time = TrueClock::get_global_ptr()->get_short_time(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_ssl_handshake -// Access: Private -// Description: This state performs the SSL handshake with the -// server, and also verifies the server's identity when -// the handshake has successfully completed. -//////////////////////////////////////////////////////////////////// +/** + * This state performs the SSL handshake with the server, and also verifies + * the server's identity when the handshake has successfully completed. + */ bool HTTPChannel:: run_ssl_handshake() { if (BIO_do_handshake(_sbio) <= 0) { @@ -1633,13 +1524,13 @@ run_ssl_handshake() { } downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID - << "Could not establish SSL handshake with " + << _NOTIFY_HTTP_CHANNEL_ID + << "Could not establish SSL handshake with " << _request.get_url().get_server_and_port() << "\n"; OpenSSLWrapper::get_global_ptr()->notify_ssl_errors(); - // It seems to be an error to free sbio at this point; perhaps - // it's already been freed? + // It seems to be an error to free sbio at this point; perhaps it's + // already been freed? if (!_cipher_list.empty()) { // If we've got another cipher to try, do so. @@ -1676,25 +1567,25 @@ run_ssl_handshake() { const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl); if (cipher == (const SSL_CIPHER *)NULL) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "No current cipher on SSL connection.\n"; } else { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Using cipher " << SSL_CIPHER_get_name((SSL_CIPHER *) cipher) << "\n"; } } - // Now that we've made an SSL handshake, we can use the SSL bio to - // do all of our communication henceforth. + // Now that we've made an SSL handshake, we can use the SSL bio to do all of + // our communication henceforth. _bio->set_bio(_sbio); _sbio = NULL; X509 *cert = SSL_get_peer_certificate(ssl); if (cert == (X509 *)NULL) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "No certificate was presented by server.\n"; // This shouldn't be possible, per the SSL specs. @@ -1702,21 +1593,21 @@ run_ssl_handshake() { _state = S_failure; return false; } - + X509_NAME *subject = X509_get_subject_name(cert); if (downloader_cat.is_debug()) { string org_name = get_x509_name_component(subject, NID_organizationName); string org_unit_name = get_x509_name_component(subject, NID_organizationalUnitName); string common_name = get_x509_name_component(subject, NID_commonName); - + downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Server is " << common_name << " from " << org_unit_name << " / " << org_name << "\n"; if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Received certificate from server:\n" << flush; X509_print_fp(stderr, cert); fflush(stderr); @@ -1733,15 +1624,15 @@ run_ssl_handshake() { if (verify_result == X509_V_ERR_CERT_HAS_EXPIRED) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Expired certificate from " << _request.get_url().get_server_and_port() << "\n"; - if (_client->get_verify_ssl() == HTTPClient::VS_normal && !cert_preapproved) { + if (_client->get_verify_ssl() == HTTPClient::VS_normal && !cert_preapproved) { cert_valid = false; } } else if (verify_result == X509_V_ERR_CERT_NOT_YET_VALID) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Premature certificate from " << _request.get_url().get_server_and_port() << "\n"; if (_client->get_verify_ssl() == HTTPClient::VS_normal && !cert_preapproved) { cert_valid = false; @@ -1750,7 +1641,7 @@ run_ssl_handshake() { } else if (verify_result == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT || verify_result == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Self-signed certificate from " << _request.get_url().get_server_and_port() << "\n"; if (_client->get_verify_ssl() != HTTPClient::VS_no_verify && !cert_preapproved) { cert_valid = false; @@ -1758,48 +1649,43 @@ run_ssl_handshake() { } else if (verify_result != X509_V_OK) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Unable to verify identity of " << _request.get_url().get_server_and_port() << ", verify error code " << verify_result << "\n"; if (_client->get_verify_ssl() != HTTPClient::VS_no_verify && !cert_preapproved) { cert_valid = false; } } - + if (!cert_valid) { _status_entry._status_code = SC_ssl_invalid_server_certificate; _state = S_failure; return false; } - + if (_client->get_verify_ssl() != HTTPClient::VS_no_verify && !cert_name_preapproved) { - // Check that the server is someone we expected to be talking - // to. + // Check that the server is someone we expected to be talking to. if (!validate_server_name(cert)) { _status_entry._status_code = SC_ssl_unexpected_server; _state = S_failure; return false; } } - + X509_free(cert); _state = S_ready; return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_ready -// Access: Private -// Description: This is the main "ready" state. In this state, we -// have established a (possibly secure) connection to -// the server (or proxy), and the server (or proxy) is -// idle and waiting for us to send a request. -// -// If persistent_connection is true, we will generally -// come back to this state after finishing each request -// on a given connection. -//////////////////////////////////////////////////////////////////// +/** + * This is the main "ready" state. In this state, we have established a + * (possibly secure) connection to the server (or proxy), and the server (or + * proxy) is idle and waiting for us to send a request. + * + * If persistent_connection is true, we will generally come back to this state + * after finishing each request on a given connection. + */ bool HTTPChannel:: run_ready() { // If there's a request to be sent upstream, send it now. @@ -1808,19 +1694,17 @@ run_ready() { return true; } } - + // All done sending request. _state = S_request_sent; _sent_request_time = TrueClock::get_global_ptr()->get_short_time(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_request_sent -// Access: Private -// Description: In this state we have sent our request to the server -// (or proxy) and we are waiting for a response. -//////////////////////////////////////////////////////////////////// +/** + * In this state we have sent our request to the server (or proxy) and we are + * waiting for a response. + */ bool HTTPChannel:: run_request_sent() { // Wait for the first line to come back from the server. @@ -1850,26 +1734,23 @@ run_request_sent() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_reading_header -// Access: Private -// Description: In this state we have received the first response to -// our request from the server (or proxy) and we are -// reading the set of header lines preceding the -// requested document. -//////////////////////////////////////////////////////////////////// +/** + * In this state we have received the first response to our request from the + * server (or proxy) and we are reading the set of header lines preceding the + * requested document. + */ bool HTTPChannel:: run_reading_header() { if (parse_http_header()) { if (_bio.is_null()) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Connection lost while reading HTTP response.\n"; if (_response_type == RT_http_hangup) { // This was our second hangup in a row. Give up. _status_entry._status_code = SC_lost_connection; _state = S_try_next_proxy; - + } else { // Try again, once. _response_type = RT_http_hangup; @@ -1882,10 +1763,10 @@ run_reading_header() { if (elapsed > get_http_timeout()) { // Time to give up. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Timeout waiting for " - << _request.get_url().get_server_and_port() - << " in run_reading_header (" << elapsed + << _request.get_url().get_server_and_port() + << " in run_reading_header (" << elapsed << " seconds elapsed).\n"; _status_entry._status_code = SC_timeout; _state = S_try_next_proxy; @@ -1895,14 +1776,14 @@ run_reading_header() { } _response_type = RT_http_complete; - // Ok, we've established an HTTP connection to the server. Our - // extra send headers have done their job; clear them for next time. + // Ok, we've established an HTTP connection to the server. Our extra send + // headers have done their job; clear them for next time. clear_extra_headers(); - _server_response_has_no_body = + _server_response_has_no_body = (get_status_code() / 100 == 1 || get_status_code() == 204 || - get_status_code() == 304 || + get_status_code() == 304 || _method == HTTPEnum::M_head); // Look for key properties in the header fields. @@ -1910,7 +1791,7 @@ run_reading_header() { string content_range = get_header_value("Content-Range"); if (content_range.empty()) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Got 206 response without Content-Range header!\n"; _status_entry._status_code = SC_invalid_http; _state = S_failure; @@ -1919,7 +1800,7 @@ run_reading_header() { } else { if (!parse_content_range(content_range)) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Couldn't parse Content-Range: " << content_range << "\n"; _status_entry._status_code = SC_invalid_http; _state = S_failure; @@ -1935,7 +1816,7 @@ run_reading_header() { if (_first_byte_requested != 0 || _last_byte_requested != 0 || _first_byte_delivered != 0 || _last_byte_delivered != 0) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Requested byte range " << _first_byte_requested << " to " << _last_byte_delivered << "; server delivers range " << _first_byte_delivered @@ -1955,9 +1836,9 @@ run_reading_header() { _document_spec.set_date(HTTPDate(date)); } - // In case we've got a download in effect, now we know what the - // first byte of the subdocument request will be, so we can open the - // file and position it. + // In case we've got a download in effect, now we know what the first byte + // of the subdocument request will be, so we can open the file and position + // it. if (_server_response_has_no_body) { // Never mind on the download. reset_download_to(); @@ -1970,23 +1851,23 @@ run_reading_header() { _got_expected_file_size = false; _got_file_size = false; _got_transfer_file_size = false; - + string content_length = get_header_value("Content-Length"); if (!content_length.empty()) { _file_size = atoi(content_length.c_str()); _got_file_size = true; } else if (get_status_code() == 206) { - // Well, we didn't get a content-length from the server, but we - // can infer the number of bytes based on the range we're given. + // Well, we didn't get a content-length from the server, but we can infer + // the number of bytes based on the range we're given. _file_size = _last_byte_delivered - _first_byte_delivered + 1; _got_file_size = true; } _redirect = get_header_value("Location"); - // The server might have given us just a filename for the redirect. - // In that case, it's relative to the same server. If it's a - // relative path, it's relative to the same directory. + // The server might have given us just a filename for the redirect. In that + // case, it's relative to the same server. If it's a relative path, it's + // relative to the same directory. if (_redirect.has_path() && !_redirect.has_authority()) { URLSpec url = _document_spec.get_url(); Filename path = _redirect.get_path(); @@ -2001,8 +1882,8 @@ run_reading_header() { _state = S_read_header; if (_server_response_has_no_body && will_close_connection()) { - // If the server said it will close the connection, we should - // close it too. + // If the server said it will close the connection, we should close it + // too. close_connection(); } @@ -2013,7 +1894,7 @@ run_reading_header() { if (get_status_code() == 407 && last_status != 407 && !_proxy.empty()) { // 407: not authorized to proxy. Try to get the authorization. string authenticate_request = get_header_value("Proxy-Authenticate"); - _proxy_auth = + _proxy_auth = _client->generate_auth(_proxy, true, authenticate_request); if (_proxy_auth != (HTTPAuthorization *)NULL) { _proxy_realm = _proxy_auth->get_realm(); @@ -2037,7 +1918,7 @@ run_reading_header() { _www_username = _client->select_username(_request.get_url(), false, _www_realm); if (!_www_username.empty()) { make_request_text(); - + // Roll the state forward to force a new request. _state = S_begin_body; return false; @@ -2045,18 +1926,18 @@ run_reading_header() { } } - if ((get_status_code() == 300 || + if ((get_status_code() == 300 || get_status_code() == 301 || get_status_code() == 302 || get_status_code() == 303 || get_status_code() == 307) && !get_redirect().empty()) { // Redirect. Should we handle it automatically? - // According to the letter of RFC 2616, 301 and 302 responses to - // POST requests must not be automatically redirected without - // confirmation by the user. In reality, browsers do allow - // automatic redirection of these responses, changing the POST to - // a GET, and we reproduce this behavior here. + // According to the letter of RFC 2616, 301 and 302 responses to POST + // requests must not be automatically redirected without confirmation by + // the user. In reality, browsers do allow automatic redirection of these + // responses, changing the POST to a GET, and we reproduce this behavior + // here. if (_method == HTTPEnum::M_post) { _method = HTTPEnum::M_get; _body = string(); @@ -2068,15 +1949,15 @@ run_reading_header() { if (find(_redirect_trail.begin(), _redirect_trail.end(), new_url) != _redirect_trail.end()) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "cycle detected in redirect to " << new_url << "\n"; - + } else { _redirect_trail.push_back(new_url); if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "following redirect to " << new_url << "\n"; } if (_request.get_url().has_username()) { @@ -2096,16 +1977,15 @@ run_reading_header() { } } - if (_state == S_read_header && + if (_state == S_read_header && ((get_status_code() / 100) == 4 || (get_status_code() / 100) == 5) && _proxy_serves_document && _proxy_next_index < _proxies.size()) { - // If we were using a proxy (but not tunneling through the proxy) - // and we got some kind of a server error, try the next proxy in - // sequence (if we have one). This handles the case of a working - // proxy that cannot see the host (and so returns 504 or something - // along those lines). Some proxies are so broken they return a - // 404 in this case, so we have to consider that along the same - // lines. + // If we were using a proxy (but not tunneling through the proxy) and we + // got some kind of a server error, try the next proxy in sequence (if we + // have one). This handles the case of a working proxy that cannot see + // the host (and so returns 504 or something along those lines). Some + // proxies are so broken they return a 404 in this case, so we have to + // consider that along the same lines. _state = S_try_next_proxy; return false; } @@ -2114,12 +1994,10 @@ run_reading_header() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_start_direct_file_read -// Access: Private -// Description: This is the first state when reading a file:// URL. -// All it does is skip past the non-existent "header". -//////////////////////////////////////////////////////////////////// +/** + * This is the first state when reading a file:// URL. All it does is skip + * past the non-existent "header". + */ bool HTTPChannel:: run_start_direct_file_read() { _state = S_read_header; @@ -2129,44 +2007,36 @@ run_start_direct_file_read() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_read_header -// Access: Private -// Description: In this state we have completely read the header -// lines returned by the server (or proxy) in response -// to our request. This state represents the normal -// stopping point of a call to get_document(), etc.; -// further reads will return the body of the request, -// the requested document. -// -// Normally run_read_header() is not called unless the -// user has elected not to read the returned document -// himself. In fact, the state itself only exists so we -// can make a distinction between S_read_header and -// S_begin_body, where S_read_header is safe to return -// to the user and S_begin_body means we need to start -// skipping the document. -//////////////////////////////////////////////////////////////////// +/** + * In this state we have completely read the header lines returned by the + * server (or proxy) in response to our request. This state represents the + * normal stopping point of a call to get_document(), etc.; further reads will + * return the body of the request, the requested document. + * + * Normally run_read_header() is not called unless the user has elected not to + * read the returned document himself. In fact, the state itself only exists + * so we can make a distinction between S_read_header and S_begin_body, where + * S_read_header is safe to return to the user and S_begin_body means we need + * to start skipping the document. + */ bool HTTPChannel:: run_read_header() { _state = S_begin_body; return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_begin_body -// Access: Private -// Description: This state begins to skip over the body in -// preparation for making a new request. -//////////////////////////////////////////////////////////////////// +/** + * This state begins to skip over the body in preparation for making a new + * request. + */ bool HTTPChannel:: run_begin_body() { if (will_close_connection()) { - // If the socket will close anyway, no point in skipping past the - // previous body; just reset. + // If the socket will close anyway, no point in skipping past the previous + // body; just reset. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to begin body; server would close anyway.\n"; } reset_to_new(); @@ -2178,13 +2048,13 @@ run_begin_body() { _state = S_read_trailer; } else if (get_file_size() > (int)_skip_body_size) { - // If we know the size of the body we are about to skip and it's - // too large, then don't bother skipping it--just drop the - // connection and get a new one. + // If we know the size of the body we are about to skip and it's too + // large, then don't bother skipping it--just drop the connection and get + // a new one. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "Dropping connection rather than skipping past " + << _NOTIFY_HTTP_CHANNEL_ID + << "Dropping connection rather than skipping past " << get_file_size() << " bytes.\n"; } reset_to_new(); @@ -2194,11 +2064,11 @@ run_begin_body() { if (_body_stream == (ISocketStream *)NULL) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Unable to skip body.\n"; } reset_to_new(); - + } else { _owns_body_stream = true; if (_state != S_reading_body) { @@ -2210,25 +2080,22 @@ run_begin_body() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_reading_body -// Access: Private -// Description: In this state we are in the process of reading the -// response's body. We will only come to this function -// if the user did not choose to read the entire body -// himself (by calling open_read_body()). -// -// In this case we should skip past the body to reset -// the connection for making a new request. -//////////////////////////////////////////////////////////////////// +/** + * In this state we are in the process of reading the response's body. We + * will only come to this function if the user did not choose to read the + * entire body himself (by calling open_read_body()). + * + * In this case we should skip past the body to reset the connection for + * making a new request. + */ bool HTTPChannel:: run_reading_body() { if (will_close_connection()) { - // If the socket will close anyway, no point in skipping past the - // previous body; just reset. + // If the socket will close anyway, no point in skipping past the previous + // body; just reset. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to read body; server would close anyway.\n"; } reset_to_new(); @@ -2240,7 +2107,7 @@ run_reading_body() { // Whoops, we're not in skip-body mode. Better reset. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting, not in skip-body mode.\n"; } reset_to_new(); @@ -2251,8 +2118,8 @@ run_reading_body() { getline(*_body_stream, line); while (!_body_stream->fail() && !_body_stream->eof()) { if (downloader_cat.is_spam()) { - downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + downloader_cat.spam() + << _NOTIFY_HTTP_CHANNEL_ID << "skip: " << line << "\n"; } getline(*_body_stream, line); @@ -2270,28 +2137,23 @@ run_reading_body() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_read_body -// Access: Private -// Description: In this state we have completely read (or skipped -// over) the body of the response. We should continue -// skipping past the trailer following the body. -// -// Not all bodies come with trailers; in particular, the -// "identity" transfer encoding does not include a -// trailer. It is therefore the responsibility of the -// IdentityStreamBuf or ChunkedStreamBuf to set the -// state appropriately to either S_read_body or -// S_read_trailer following the completion of the body. -//////////////////////////////////////////////////////////////////// +/** + * In this state we have completely read (or skipped over) the body of the + * response. We should continue skipping past the trailer following the body. + * + * Not all bodies come with trailers; in particular, the "identity" transfer + * encoding does not include a trailer. It is therefore the responsibility of + * the IdentityStreamBuf or ChunkedStreamBuf to set the state appropriately to + * either S_read_body or S_read_trailer following the completion of the body. + */ bool HTTPChannel:: run_read_body() { if (will_close_connection()) { - // If the socket will close anyway, no point in skipping past the - // previous body; just reset. + // If the socket will close anyway, no point in skipping past the previous + // body; just reset. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to read body; server would close anyway.\n"; } reset_to_new(); @@ -2313,21 +2175,18 @@ run_read_body() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_read_trailer -// Access: Private -// Description: In this state we have completely read the body and -// the trailer. This state is simply a pass-through -// back to S_ready. -//////////////////////////////////////////////////////////////////// +/** + * In this state we have completely read the body and the trailer. This state + * is simply a pass-through back to S_ready. + */ bool HTTPChannel:: run_read_trailer() { if (will_close_connection()) { - // If the socket will close anyway, no point in skipping past the - // previous body; just reset. + // If the socket will close anyway, no point in skipping past the previous + // body; just reset. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to read trailer; server would close anyway.\n"; } reset_to_new(); @@ -2338,12 +2197,10 @@ run_read_trailer() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_download_to_file -// Access: Private -// Description: After the headers, etc. have been read, this streams -// the download to the named file. -//////////////////////////////////////////////////////////////////// +/** + * After the headers, etc. have been read, this streams the download to the + * named file. + */ bool HTTPChannel:: run_download_to_file() { nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); @@ -2379,7 +2236,7 @@ run_download_to_file() { if (_download_to_stream->fail()) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Error writing to " << _download_to_filename << "\n"; _status_entry._status_code = SC_download_write_error; _state = S_failure; @@ -2401,12 +2258,10 @@ run_download_to_file() { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_download_to_ram -// Access: Private -// Description: After the headers, etc. have been read, this streams -// the download to the specified Ramfile object. -//////////////////////////////////////////////////////////////////// +/** + * After the headers, etc. have been read, this streams the download to the + * specified Ramfile object. + */ bool HTTPChannel:: run_download_to_ram() { nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); @@ -2453,12 +2308,10 @@ run_download_to_ram() { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::run_download_to_stream -// Access: Private -// Description: After the headers, etc. have been read, this streams -// the download to the named file. -//////////////////////////////////////////////////////////////////// +/** + * After the headers, etc. have been read, this streams the download to the + * named file. + */ bool HTTPChannel:: run_download_to_stream() { nassertr(_body_stream != (ISocketStream *)NULL && _owns_body_stream, false); @@ -2494,7 +2347,7 @@ run_download_to_stream() { if (_download_to_stream->fail()) { downloader_cat.warning() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Error writing to stream\n"; _status_entry._status_code = SC_download_write_error; _state = S_failure; @@ -2517,28 +2370,25 @@ run_download_to_stream() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::begin_request -// Access: Private -// Description: Begins a new document request to the server, throwing -// away whatever request was currently pending if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Begins a new document request to the server, throwing away whatever request + * was currently pending if necessary. + */ void HTTPChannel:: begin_request(HTTPEnum::Method method, const DocumentSpec &url, - const string &body, bool nonblocking, + const string &body, bool nonblocking, size_t first_byte, size_t last_byte) { - + downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "begin " << method << " " << url << "\n"; - + reset_for_new_request(); _wanted_nonblocking = nonblocking; #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In the presence of SIMPLE_THREADS, we always use non-blocking - // I/O. We simulate blocking by yielding the thread. + // In the presence of SIMPLE_THREADS, we always use non-blocking IO. We + // simulate blocking by yielding the thread. nonblocking = true; #endif @@ -2549,9 +2399,9 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, _client->get_proxies_for_url(url.get_url(), _proxies); } - // If we still have a live connection to a proxy that is on the - // list, that proxy should be moved immediately to the front of the - // list (to minimize restarting connections unnecessarily). + // If we still have a live connection to a proxy that is on the list, that + // proxy should be moved immediately to the front of the list (to minimize + // restarting connections unnecessarily). if (!_bio.is_null() && !_proxies.empty() && !_proxy.empty()) { Proxies::iterator pi = find(_proxies.begin(), _proxies.end(), _proxy); if (pi != _proxies.end()) { @@ -2566,14 +2416,13 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, _proxy_next_index++; } - // Changing the proxy is grounds for dropping the old connection, if - // any. + // Changing the proxy is grounds for dropping the old connection, if any. if (_proxy != new_proxy) { _proxy = new_proxy; _proxy_auth = (HTTPAuthorization *)NULL; if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to change proxy to " << _proxy << "\n"; } reset_to_new(); @@ -2584,7 +2433,7 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, _nonblocking = nonblocking; if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to change nonblocking state to " << _nonblocking << ".\n"; } reset_to_new(); @@ -2596,8 +2445,7 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, _method = method; _body = body; - // An https-style request means we'll need to establish an SSL - // connection. + // An https-style request means we'll need to establish an SSL connection. _want_ssl = _request.get_url().is_ssl(); _first_byte_requested = first_byte; @@ -2608,9 +2456,9 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, // Reset from whatever previous request might still be pending. if (_request.get_url().get_scheme() == "file") { - // A "file" URL just means we're reading a raw file. This only - // supports actual disk files, not the VFS, because we use a - // BIO_new_file() underneath this. + // A "file" URL just means we're reading a raw file. This only supports + // actual disk files, not the VFS, because we use a BIO_new_file() + // underneath this. reset_to_new(); _bio = new BioPtr(_request.get_url()); if (_bio->get_bio() != NULL) { @@ -2642,24 +2490,23 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, if (_state == S_failure || (_state < S_read_header && _state != S_ready)) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to clear previous request.\n"; } reset_to_new(); - + } else if (TrueClock::get_global_ptr()->get_short_time() - _last_run_time >= _idle_timeout) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "resetting old connection: " + << _NOTIFY_HTTP_CHANNEL_ID + << "resetting old connection: " << TrueClock::get_global_ptr()->get_short_time() - _last_run_time << " s old.\n"; } reset_to_new(); - + } else if (_state == S_read_header) { - // Roll one step forwards to start skipping past the previous - // body. + // Roll one step forwards to start skipping past the previous body. _state = S_begin_body; } } @@ -2671,32 +2518,29 @@ begin_request(HTTPEnum::Method method, const DocumentSpec &url, } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reconsider_proxy -// Access: Private -// Description: Reevaluates the flags and strings that are computed -// based on the particular proxy we are attempting to -// connect to. This should be called when we initiate a -// request, and also whenever we change proxies while -// processing a request. -//////////////////////////////////////////////////////////////////// +/** + * Reevaluates the flags and strings that are computed based on the particular + * proxy we are attempting to connect to. This should be called when we + * initiate a request, and also whenever we change proxies while processing a + * request. + */ void HTTPChannel:: reconsider_proxy() { _proxy_tunnel_now = false; _proxy_serves_document = false; - + if (!_proxy.empty()) { - // If the user insists we always tunnel through a proxy, or if - // we're opening an SSL connection, or the user has explicitly - // asked for a direct connection of some kind, or if we have a - // SOCKS-style proxy; each of these demands a tunnel through the - // proxy to speak directly to the http server. + // If the user insists we always tunnel through a proxy, or if we're + // opening an SSL connection, or the user has explicitly asked for a + // direct connection of some kind, or if we have a SOCKS-style proxy; each + // of these demands a tunnel through the proxy to speak directly to the + // http server. _proxy_tunnel_now = (get_proxy_tunnel() || _want_ssl || _method == HTTPEnum::M_connect || _proxy.get_scheme() == "socks"); - // Otherwise (but we still have a proxy), then we ask the proxy to - // hand us the document. + // Otherwise (but we still have a proxy), then we ask the proxy to hand us + // the document. _proxy_serves_document = !_proxy_tunnel_now; } @@ -2704,14 +2548,14 @@ reconsider_proxy() { make_request_text(); if (_proxy_tunnel_now) { - // Maybe we need to tunnel through the proxy to connect to the - // server directly. + // Maybe we need to tunnel through the proxy to connect to the server + // directly. ostringstream request; - request + request << "CONNECT " << _request.get_url().get_server_and_port() << " " << _client->get_http_version_string() << "\r\n"; if (_client->get_http_version() >= HTTPEnum::HV_11) { - request + request << "Host: " << _request.get_url().get_server_and_port() << "\r\n"; } _proxy_header = request.str(); @@ -2724,20 +2568,18 @@ reconsider_proxy() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset_for_new_request -// Access: Private -// Description: Resets the internal state variables in preparation -// for beginning a new request. -//////////////////////////////////////////////////////////////////// +/** + * Resets the internal state variables in preparation for beginning a new + * request. + */ void HTTPChannel:: reset_for_new_request() { if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "reset_for_new_request.\n"; } - + reset_download_to(); reset_body_stream(); @@ -2750,24 +2592,20 @@ reset_for_new_request() { _bytes_requested = 0; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::finished_body -// Access: Private -// Description: This is called by the body reading -// classes--ChunkedStreamBuf and IdentityStreamBuf--when -// they have finished reading the body. It advances the -// state appropriately. -// -// has_trailer should be set true if the body type has -// an associated trailer which should be read or -// skipped, or false if there is no trailer. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the body reading classes--ChunkedStreamBuf and + * IdentityStreamBuf--when they have finished reading the body. It advances + * the state appropriately. + * + * has_trailer should be set true if the body type has an associated trailer + * which should be read or skipped, or false if there is no trailer. + */ void HTTPChannel:: finished_body(bool has_trailer) { if (will_close_connection() && _download_dest == DD_none) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "resetting to finish body; server would close anyway.\n"; } reset_to_new(); @@ -2781,17 +2619,14 @@ finished_body(bool has_trailer) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::open_download_file -// Access: Private -// Description: If a download has been requested, opens the file on -// disk (or prepares the RamFile or stream) and seeks -// within it to the appropriate _first_byte_delivered -// position, so that downloaded bytes will be written to -// the appropriate point within the file. Returns true -// if the starting position is valid, false otherwise -// (in which case the state is set to S_failure). -//////////////////////////////////////////////////////////////////// +/** + * If a download has been requested, opens the file on disk (or prepares the + * RamFile or stream) and seeks within it to the appropriate + * _first_byte_delivered position, so that downloaded bytes will be written to + * the appropriate point within the file. Returns true if the starting + * position is valid, false otherwise (in which case the state is set to + * S_failure). + */ bool HTTPChannel:: open_download_file() { _subdocument_resumes = (_subdocument_resumes && _first_byte_delivered != 0); @@ -2801,7 +2636,7 @@ open_download_file() { _download_to_stream = vfs->open_write_file(_download_to_filename, false, !_subdocument_resumes); if (_download_to_stream == NULL) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Could not open " << _download_to_filename << " for writing.\n"; _status_entry._status_code = SC_download_open_error; _state = S_failure; @@ -2811,31 +2646,30 @@ open_download_file() { if (_subdocument_resumes) { if (_download_dest == DD_file) { - // Windows doesn't complain if you try to seek past the end of - // file--it happily appends enough zero bytes to make the - // difference. Blecch. That means we need to get the file size - // first to check it ourselves. + // Windows doesn't complain if you try to seek past the end of file--it + // happily appends enough zero bytes to make the difference. Blecch. + // That means we need to get the file size first to check it ourselves. _download_to_stream->seekp(0, ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Invalid starting position of byte " << _first_byte_delivered - << " within " << _download_to_filename << " (which has " + << " within " << _download_to_filename << " (which has " << _download_to_stream->tellp() << " bytes)\n"; close_download_stream(); _status_entry._status_code = SC_download_invalid_range; _state = S_failure; return false; } - + _download_to_stream->seekp(_first_byte_delivered); - + } else if (_download_dest == DD_ram) { if (_first_byte_delivered > _download_to_ramfile->_data.length()) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID - << "Invalid starting position of byte " << _first_byte_delivered - << " within Ramfile (which has " + << _NOTIFY_HTTP_CHANNEL_ID + << "Invalid starting position of byte " << _first_byte_delivered + << " within Ramfile (which has " << _download_to_ramfile->_data.length() << " bytes)\n"; close_download_stream(); _status_entry._status_code = SC_download_invalid_range; @@ -2846,33 +2680,32 @@ open_download_file() { if (_first_byte_delivered == 0) { _download_to_ramfile->_data = string(); } else { - _download_to_ramfile->_data = + _download_to_ramfile->_data = _download_to_ramfile->_data.substr(0, _first_byte_delivered); } } else if (_download_dest == DD_stream) { - // Windows doesn't complain if you try to seek past the end of - // file--it happily appends enough zero bytes to make the - // difference. Blecch. That means we need to get the file size - // first to check it ourselves. + // Windows doesn't complain if you try to seek past the end of file--it + // happily appends enough zero bytes to make the difference. Blecch. + // That means we need to get the file size first to check it ourselves. _download_to_stream->seekp(0, ios::end); if (_first_byte_delivered > (size_t)_download_to_stream->tellp()) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Invalid starting position of byte " << _first_byte_delivered - << " within stream (which has " + << " within stream (which has " << _download_to_stream->tellp() << " bytes)\n"; close_download_stream(); _status_entry._status_code = SC_download_invalid_range; _state = S_failure; return false; } - + _download_to_stream->seekp(_first_byte_delivered); } } else { - // If _subdocument_resumes is false, we should be sure to reset to - // the beginning of the file, regardless of the value of + // If _subdocument_resumes is false, we should be sure to reset to the + // beginning of the file, regardless of the value of // _first_byte_delivered. if (_download_dest == DD_file || _download_dest == DD_stream) { _download_to_stream->seekp(0); @@ -2885,14 +2718,11 @@ open_download_file() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::server_getline -// Access: Private -// Description: Reads a single line from the server's reply. Returns -// true if the line is successfully retrieved, or false -// if a complete line has not yet been received or if -// the connection has been closed. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single line from the server's reply. Returns true if the line is + * successfully retrieved, or false if a complete line has not yet been + * received or if the connection has been closed. + */ bool HTTPChannel:: server_getline(string &str) { nassertr(!_source.is_null(), false); @@ -2913,8 +2743,8 @@ server_getline(string &str) { str = str.substr(0, p); } if (downloader_cat.is_debug()) { - downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + downloader_cat.debug() + << _NOTIFY_HTTP_CHANNEL_ID << "recv: " << str << "\n"; } return true; @@ -2933,14 +2763,11 @@ server_getline(string &str) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::server_getline_failsafe -// Access: Private -// Description: Reads a line from the server's reply. If the server -// disconnects or times out before sending a reply, -// moves on to the next proxy server (or sets failure -// mode) and returns false; otherwise, returns true. -//////////////////////////////////////////////////////////////////// +/** + * Reads a line from the server's reply. If the server disconnects or times + * out before sending a reply, moves on to the next proxy server (or sets + * failure mode) and returns false; otherwise, returns true. + */ bool HTTPChannel:: server_getline_failsafe(string &str) { if (!server_getline(str)) { @@ -2950,7 +2777,7 @@ server_getline_failsafe(string &str) { // This was our second immediate hangup in a row. Give up. _status_entry._status_code = SC_lost_connection; _state = S_try_next_proxy; - + } else { // Try again, once. _response_type = RT_hangup; @@ -2963,30 +2790,27 @@ server_getline_failsafe(string &str) { if (elapsed > get_http_timeout()) { // Time to give up. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Timeout waiting for " - << _request.get_url().get_server_and_port() - << " in server_getline_failsafe (" << elapsed + << _request.get_url().get_server_and_port() + << " in server_getline_failsafe (" << elapsed << " seconds elapsed).\n"; _status_entry._status_code = SC_timeout; _state = S_try_next_proxy; } } - + return false; } return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::server_get -// Access: Private -// Description: Reads a fixed number of bytes from the server's -// reply. Returns true if the indicated number of bytes -// are successfully retrieved, or false if the complete -// set has not yet been received or if the connection -// has been closed. -//////////////////////////////////////////////////////////////////// +/** + * Reads a fixed number of bytes from the server's reply. Returns true if the + * indicated number of bytes are successfully retrieved, or false if the + * complete set has not yet been received or if the connection has been + * closed. + */ bool HTTPChannel:: server_get(string &str, size_t num_bytes) { nassertr(!_source.is_null(), false); @@ -3006,15 +2830,11 @@ server_get(string &str, size_t num_bytes) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::server_get_failsafe -// Access: Private -// Description: Reads a fixed number of bytes from the server. If -// the server disconnects or times out before sending a -// reply, moves on to the next proxy server (or sets -// failure mode) and returns false; otherwise, returns -// true. -//////////////////////////////////////////////////////////////////// +/** + * Reads a fixed number of bytes from the server. If the server disconnects + * or times out before sending a reply, moves on to the next proxy server (or + * sets failure mode) and returns false; otherwise, returns true. + */ bool HTTPChannel:: server_get_failsafe(string &str, size_t num_bytes) { if (!server_get(str, num_bytes)) { @@ -3024,12 +2844,12 @@ server_get_failsafe(string &str, size_t num_bytes) { // This was our second immediate hangup in a row. Give up. _status_entry._status_code = SC_lost_connection; _state = S_try_next_proxy; - + } else { // Try again, once. _response_type = RT_hangup; } - + } else { double elapsed = TrueClock::get_global_ptr()->get_short_time() - @@ -3037,46 +2857,42 @@ server_get_failsafe(string &str, size_t num_bytes) { if (elapsed > get_http_timeout()) { // Time to give up. downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Timeout waiting for " - << _request.get_url().get_server_and_port() - << " in server_get_failsafe (" << elapsed + << _request.get_url().get_server_and_port() + << " in server_get_failsafe (" << elapsed << " seconds elapsed).\n"; _status_entry._status_code = SC_timeout; _state = S_try_next_proxy; } } - + return false; } return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::server_send -// Access: Private -// Description: Sends a series of lines to the server. Returns true -// if the buffer is fully sent, or false if some of it -// remains. If this returns false, the function must be -// called again later, passing in the exact same string, -// until the return value is true. -// -// If the secret flag is true, the data is not echoed to -// the log (even in spam mode). This may be desirable -// if the data may contain binary data, or if it may -// contain passwords etc. -//////////////////////////////////////////////////////////////////// +/** + * Sends a series of lines to the server. Returns true if the buffer is fully + * sent, or false if some of it remains. If this returns false, the function + * must be called again later, passing in the exact same string, until the + * return value is true. + * + * If the secret flag is true, the data is not echoed to the log (even in spam + * mode). This may be desirable if the data may contain binary data, or if it + * may contain passwords etc. + */ bool HTTPChannel:: server_send(const string &str, bool secret) { nassertr(str.length() > _sent_so_far, true); - // Use the underlying BIO to write to the server, instead of the - // BIOStream, which would insist on blocking (and might furthermore - // delay the send due to collect-tcp mode being enabled). + // Use the underlying BIO to write to the server, instead of the BIOStream, + // which would insist on blocking (and might furthermore delay the send due + // to collect-tcp mode being enabled). size_t bytes_to_send = str.length() - _sent_so_far; int write_count = BIO_write(*_bio, str.data() + _sent_so_far, bytes_to_send); - + if (write_count <= 0) { if (BIO_should_retry(*_bio)) { // Temporary failure: the pipe is full. Wait till later. @@ -3085,7 +2901,7 @@ server_send(const string &str, bool secret) { // Oops, the connection has been closed! if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Lost connection to server unexpectedly during write.\n"; } reset_to_new(); @@ -3094,16 +2910,16 @@ server_send(const string &str, bool secret) { if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "wrote " << write_count << " bytes to " << _bio << "\n"; } - + #ifndef NDEBUG if (!secret && downloader_cat.is_debug()) { show_send(str.substr(0, write_count)); } #endif - + if (write_count < (int)bytes_to_send) { _sent_so_far += write_count; return false; @@ -3114,18 +2930,14 @@ server_send(const string &str, bool secret) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::parse_http_response -// Access: Private -// Description: Parses the first line sent back from an HTTP server -// or proxy and stores the result in _status_code and -// _http_version, etc. Returns true on success, false -// on invalid response. -//////////////////////////////////////////////////////////////////// +/** + * Parses the first line sent back from an HTTP server or proxy and stores the + * result in _status_code and _http_version, etc. Returns true on success, + * false on invalid response. + */ bool HTTPChannel:: parse_http_response(const string &line) { - // The first line back should include the HTTP version and the - // result code. + // The first line back should include the HTTP version and the result code. if (line.length() < 5 || line.substr(0, 5) != string("HTTP/")) { // Not an HTTP response. _status_entry._status_code = SC_non_http_response; @@ -3134,11 +2946,11 @@ parse_http_response(const string &line) { _state = S_try_next_proxy; } else { - // Maybe we were just in some bad state. Drop the connection - // and try again, once. + // Maybe we were just in some bad state. Drop the connection and try + // again, once. if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "got non-HTTP response, resetting.\n"; } reset_to_new(); @@ -3173,13 +2985,10 @@ parse_http_response(const string &line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::parse_http_header -// Access: Private -// Description: Reads the series of header lines from the server and -// stores them in _headers. Returns true if there is -// more to read, false when done. -//////////////////////////////////////////////////////////////////// +/** + * Reads the series of header lines from the server and stores them in + * _headers. Returns true if there is more to read, false when done. + */ bool HTTPChannel:: parse_http_header() { string line; @@ -3189,8 +2998,7 @@ parse_http_header() { while (!line.empty()) { if (isspace(line[0])) { - // If the line begins with a space, that continues the previous - // field. + // If the line begins with a space, that continues the previous field. size_t p = 0; while (p < line.length() && isspace(line[p])) { p++; @@ -3198,8 +3006,7 @@ parse_http_header() { _current_field_value += line.substr(p - 1); } else { - // If the line does not begin with a space, that defines a new - // field. + // If the line does not begin with a space, that defines a new field. if (!_current_field_name.empty()) { store_header_field(_current_field_name, _current_field_value); _current_field_value = string(); @@ -3230,14 +3037,11 @@ parse_http_header() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::parse_content_range -// Access: Private -// Description: Interprets the "Content-Range" header in the reply, -// and fills in _first_byte_delivered and -// _last_byte_delivered appropriately if the header -// response can be understood. -//////////////////////////////////////////////////////////////////// +/** + * Interprets the "Content-Range" header in the reply, and fills in + * _first_byte_delivered and _last_byte_delivered appropriately if the header + * response can be understood. + */ bool HTTPChannel:: parse_content_range(const string &content_range) { // First, get the units indication. @@ -3262,7 +3066,7 @@ parse_content_range(const string &content_range) { if (p < content_range.length() && isdigit(content_range[p])) { long last_byte = strtol(c_str + p, &endptr, 10); p = endptr - c_str; - + if (last_byte >= first_byte) { _first_byte_delivered = first_byte; _last_byte_delivered = last_byte; @@ -3272,26 +3076,23 @@ parse_content_range(const string &content_range) { } } } - + // Invalid or unhandled response. return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::check_socket -// Access: Private -// Description: Checks whether the connection to the server has been -// closed after a failed read. If it has, issues a -// warning and calls reset_to_new(). -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the connection to the server has been closed after a failed + * read. If it has, issues a warning and calls reset_to_new(). + */ void HTTPChannel:: check_socket() { nassertv(!_source.is_null()); if ((*_source)->is_closed()) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Lost connection to server unexpectedly during read.\n"; } reset_to_new(); @@ -3473,40 +3274,33 @@ certificate signing */ -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::check_preapproved_server_certificate -// Access: Private -// Description: Checks to see if the indicated certificate is on the -// pre-approved list for the current server. -// -// If the full cert itself (including its key) is on the -// pre-approved list, sets both cert_preapproved and -// cert_name_preapproved to true. -// -// If the full cert is not on the pre-approved list, but -// its name matches a name on the pre-approved list, -// sets cert_name_preapproved to true, and -// cert_preapproved to false. -// -// Otherwise, sets both values to false. This doesn't -// mean the cert is necessarily invalid, just that it -// wasn't on the pre-approved list (which is usually -// empty anyway). -//////////////////////////////////////////////////////////////////// +/** + * Checks to see if the indicated certificate is on the pre-approved list for + * the current server. + * + * If the full cert itself (including its key) is on the pre-approved list, + * sets both cert_preapproved and cert_name_preapproved to true. + * + * If the full cert is not on the pre-approved list, but its name matches a + * name on the pre-approved list, sets cert_name_preapproved to true, and + * cert_preapproved to false. + * + * Otherwise, sets both values to false. This doesn't mean the cert is + * necessarily invalid, just that it wasn't on the pre-approved list (which is + * usually empty anyway). + */ void HTTPChannel:: -check_preapproved_server_certificate(X509 *cert, bool &cert_preapproved, +check_preapproved_server_certificate(X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const { return _client->check_preapproved_server_certificate(_request.get_url(), cert, cert_preapproved, cert_name_preapproved); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::validate_server_name -// Access: Private -// Description: Returns true if the name in the cert matches the -// hostname of the server, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the name in the cert matches the hostname of the server, + * false otherwise. + */ bool HTTPChannel:: validate_server_name(X509 *cert) { string hostname = _request.get_url().get_server(); @@ -3521,9 +3315,9 @@ validate_server_name(X509 *cert) { int num_alts = sk_GENERAL_NAME_num(subject_alt_names); for (int i = 0; i < num_alts; ++i) { // Get the ith alt name. - const GENERAL_NAME *alt_name = + const GENERAL_NAME *alt_name = sk_GENERAL_NAME_value(subject_alt_names, i); - + if (alt_name->type == GEN_DNS) { char *buffer = NULL; int len = ASN1_STRING_to_UTF8((unsigned char**)&buffer, @@ -3540,7 +3334,7 @@ validate_server_name(X509 *cert) { if (cert_names.empty()) { // If there were no DNS names, use the common name instead. - + X509_NAME *xname = X509_get_subject_name(cert); if (xname != NULL) { string common_name = get_x509_name_component(xname, NID_commonName); @@ -3550,7 +3344,7 @@ validate_server_name(X509 *cert) { if (cert_names.empty()) { downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Server certificate from " << hostname << " provides no name.\n"; return false; @@ -3558,7 +3352,7 @@ validate_server_name(X509 *cert) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Server certificate from " << hostname << " provides name(s):"; vector_string::const_iterator si; @@ -3571,8 +3365,8 @@ validate_server_name(X509 *cert) { << "\n"; } - // Now validate the names we found. If any of them matches, the - // cert matches. + // Now validate the names we found. If any of them matches, the cert + // matches. vector_string::const_iterator si; for (si = cert_names.begin(); si != cert_names.end(); ++si) { const string &cert_name = (*si); @@ -3583,7 +3377,7 @@ validate_server_name(X509 *cert) { } downloader_cat.info() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "Server certificate from " << hostname << " provides wrong name(s):"; for (si = cert_names.begin(); si != cert_names.end(); ++si) { @@ -3597,38 +3391,32 @@ validate_server_name(X509 *cert) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::match_cert_name -// Access: Private, Static -// Description: Returns true if this particular name from the -// certificate matches the indicated hostname, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular name from the certificate matches the + * indicated hostname, false otherwise. + */ bool HTTPChannel:: match_cert_name(const string &cert_name, const string &hostname) { - // We use GlobPattern to match the name. This isn't quite - // consistent with RFC2818, since it also accepts additional - // wildcard characters like "?" and "[]", but I think it's close - // enough. + // We use GlobPattern to match the name. This isn't quite consistent with + // RFC2818, since it also accepts additional wildcard characters like "?" + // and "[]", but I think it's close enough. GlobPattern pattern(cert_name); pattern.set_case_sensitive(false); pattern.set_nomatch_chars("."); return pattern.matches(hostname); } - -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::get_x509_name_component -// Access: Private, Static -// Description: Returns the indicated component of the X509 name as a -// string, if defined, or empty string if it is not. -//////////////////////////////////////////////////////////////////// + +/** + * Returns the indicated component of the X509 name as a string, if defined, + * or empty string if it is not. + */ string HTTPChannel:: get_x509_name_component(X509_NAME *name, int nid) { ASN1_OBJECT *obj = OBJ_nid2obj(nid); if (obj == NULL) { - // Unknown nid. See openssl/objects.h. + // Unknown nid. See opensslobjects.h. return string(); } @@ -3638,16 +3426,14 @@ get_x509_name_component(X509_NAME *name, int nid) { } ASN1_STRING *data = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); - return string((char *)data->data, data->length); + return string((char *)data->data, data->length); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::make_header -// Access: Private -// Description: Formats the appropriate GET or POST (or whatever) -// request to send to the server, based on the current -// _method, _document_spec, _body, and _proxy settings. -//////////////////////////////////////////////////////////////////// +/** + * Formats the appropriate GET or POST (or whatever) request to send to the + * server, based on the current _method, _document_spec, _body, and _proxy + * settings. + */ void HTTPChannel:: make_header() { _proxy_auth = _client->select_auth(_proxy, true, _proxy_realm); @@ -3658,10 +3444,9 @@ make_header() { } if (_method == HTTPEnum::M_connect) { - // This method doesn't require an HTTP header at all; we'll just - // open a plain connection. (Except when we're using a proxy; but - // in that case, it's the proxy_header we'll need, not the regular - // HTTP header.) + // This method doesn't require an HTTP header at all; we'll just open a + // plain connection. (Except when we're using a proxy; but in that case, + // it's the proxy_header we'll need, not the regular HTTP header.) _header = string(); return; } @@ -3675,40 +3460,39 @@ make_header() { string request_path; if (_proxy_serves_document) { - // If we'll be asking the proxy for the document, we need its full - // URL--but we omit the username, which is information just for us. + // If we'll be asking the proxy for the document, we need its full URL-- + // but we omit the username, which is information just for us. URLSpec url_no_username = _request.get_url(); url_no_username.set_username(string()); request_path = url_no_username.get_url(); } else { - // If we'll be asking the server directly for the document, we - // just want its path relative to the server. + // If we'll be asking the server directly for the document, we just want + // its path relative to the server. request_path = _request.get_url().get_path_and_query(); } - // HTTP syntax always requires something in the request path. If it - // is empty, put in a star as a placeholder (OPTIONS, for instance, - // uses this). + // HTTP syntax always requires something in the request path. If it is + // empty, put in a star as a placeholder (OPTIONS, for instance, uses this). if (request_path.empty()) { request_path = "*"; } ostringstream stream; - stream - << _method << " " << request_path << " " + stream + << _method << " " << request_path << " " << _client->get_http_version_string() << "\r\n"; if (_client->get_http_version() >= HTTPEnum::HV_11) { - - stream + + stream << "Host: " << _request.get_url().get_server(); if (!_request.get_url().is_default_port()) { - // It appears that some servers (notably gstatic.com) might - // return a 404 if you include an explicit port number in with - // the Host: header, even if it is the default port. So, don't - // include the port number unless we need to. + // It appears that some servers (notably gstatic.com) might return a 404 + // if you include an explicit port number in with the Host: header, even + // if it is the default port. So, don't include the port number unless + // we need to. stream << ":" << _request.get_url().get_port(); } stream << "\r\n"; @@ -3719,23 +3503,22 @@ make_header() { } if (_last_byte_requested != 0) { - stream - << "Range: bytes=" << _first_byte_requested << "-" + stream + << "Range: bytes=" << _first_byte_requested << "-" << _last_byte_requested << "\r\n"; } else if (_first_byte_requested != 0) { - stream + stream << "Range: bytes=" << _first_byte_requested << "-\r\n"; } switch (_request.get_request_mode()) { case DocumentSpec::RM_any: - // No particular request; give us any document that matches the - // URL. + // No particular request; give us any document that matches the URL. if (_first_byte_requested != 0) { - // Unless we're requesting a subrange, in which case if the - // exact document matches, retrieve the subrange indicated; - // otherwise, retrieve the entire document. + // Unless we're requesting a subrange, in which case if the exact + // document matches, retrieve the subrange indicated; otherwise, + // retrieve the entire document. if (_request.has_tag()) { stream << "If-Range: " << _request.get_tag().get_string() << "\r\n"; @@ -3747,8 +3530,7 @@ make_header() { break; case DocumentSpec::RM_equal: - // Give us only this particular version of the document, or - // nothing. + // Give us only this particular version of the document, or nothing. if (_request.has_tag()) { stream << "If-Match: " << _request.get_tag().get_string() << "\r\n"; @@ -3776,9 +3558,9 @@ make_header() { case DocumentSpec::RM_equal_or_newer: // Just don't give us anything older. if (_request.has_date()) { - // This is a little unreliable: we ask for any document that's - // been modified since one second before our last-modified-date. - // Who knows whether the server will honor this properly. + // This is a little unreliable: we ask for any document that's been + // modified since one second before our last-modified-date. Who knows + // whether the server will honor this properly. stream << "If-Modified-Since: " << (_request.get_date() - 1).get_string() << "\r\n"; @@ -3816,37 +3598,31 @@ make_header() { _header = stream.str(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::make_proxy_request_text -// Access: Private -// Description: Builds the _proxy_request_text string. This is a -// special request that will be sent directly to the -// proxy prior to the request tailored for the server. -// Generally this is used to open a tunnelling -// connection for https-over-proxy. -//////////////////////////////////////////////////////////////////// +/** + * Builds the _proxy_request_text string. This is a special request that will + * be sent directly to the proxy prior to the request tailored for the server. + * Generally this is used to open a tunnelling connection for https-over- + * proxy. + */ void HTTPChannel:: make_proxy_request_text() { _proxy_request_text = _proxy_header; if (_proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { _proxy_request_text += "Proxy-Authorization: "; - _proxy_request_text += + _proxy_request_text += _proxy_auth->generate(HTTPEnum::M_connect, _request.get_url().get_server_and_port(), _proxy_username, _body); _proxy_request_text += "\r\n"; } - + _proxy_request_text += "\r\n"; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::make_request_text -// Access: Private -// Description: Builds the _request_text string. This is the -// specific request that will be sent to the server this -// pass, based on the current header and body. -//////////////////////////////////////////////////////////////////// +/** + * Builds the _request_text string. This is the specific request that will be + * sent to the server this pass, based on the current header and body. + */ void HTTPChannel:: make_request_text() { _request_text = _header; @@ -3854,13 +3630,13 @@ make_request_text() { if (_proxy_serves_document && _proxy_auth != (HTTPAuthorization *)NULL && !_proxy_username.empty()) { _request_text += "Proxy-Authorization: "; - _request_text += + _request_text += _proxy_auth->generate(_method, _request.get_url().get_url(), _proxy_username, _body); _request_text += "\r\n"; } if (_www_auth != (HTTPAuthorization *)NULL && !_www_username.empty()) { - string authorization = + string authorization = _request_text += "Authorization: "; _request_text += _www_auth->generate(_method, _request.get_url().get_path_and_query(), _www_username, _body); @@ -3871,49 +3647,42 @@ make_request_text() { _request_text += "\r\n"; _request_text += _body; } - -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset_url -// Access: Private -// Description: Redirects the next connection to the indicated URL -// (from the previous URL). This resets the socket if -// necessary when we are about to switch servers. -//////////////////////////////////////////////////////////////////// + +/** + * Redirects the next connection to the indicated URL (from the previous URL). + * This resets the socket if necessary when we are about to switch servers. + */ void HTTPChannel:: reset_url(const URLSpec &old_url, const URLSpec &new_url) { - // If we change between http and https, we have to reset the - // connection regardless of proxy. Otherwise, we have to drop the - // connection if the server or port changes, unless we're - // communicating through a proxy. + // If we change between http and https, we have to reset the connection + // regardless of proxy. Otherwise, we have to drop the connection if the + // server or port changes, unless we're communicating through a proxy. if (new_url.get_scheme() != old_url.get_scheme() || - (_proxy.empty() && (new_url.get_server() != old_url.get_server() || + (_proxy.empty() && (new_url.get_server() != old_url.get_server() || new_url.get_port() != old_url.get_port()))) { if (downloader_cat.is_debug()) { downloader_cat.debug() - << _NOTIFY_HTTP_CHANNEL_ID - << "resetting for new server " + << _NOTIFY_HTTP_CHANNEL_ID + << "resetting for new server " << new_url.get_server_and_port() << "\n"; } reset_to_new(); } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::store_header_field -// Access: Private -// Description: Stores a single name: value pair in the header list, -// or appends the value to the end of the existing -// value, if the header has been repeated. -//////////////////////////////////////////////////////////////////// +/** + * Stores a single name: value pair in the header list, or appends the value + * to the end of the existing value, if the header has been repeated. + */ void HTTPChannel:: store_header_field(const string &field_name, const string &field_value) { pair insert_result = _headers.insert(Headers::value_type(field_name, field_value)); if (!insert_result.second) { - // It didn't insert; thus, the field already existed. Append the - // new value. + // It didn't insert; thus, the field already existed. Append the new + // value. Headers::iterator hi = insert_result.first; (*hi).second += ", "; (*hi).second += field_value; @@ -3925,12 +3694,9 @@ store_header_field(const string &field_name, const string &field_value) { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::show_send -// Access: Private, Static -// Description: Writes the outgoing message, one line at a time, to -// the debugging log. -//////////////////////////////////////////////////////////////////// +/** + * Writes the outgoing message, one line at a time, to the debugging log. + */ void HTTPChannel:: show_send(const string &message) { size_t start = 0; @@ -3950,13 +3716,10 @@ show_send(const string &message) { } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset_download_to -// Access: Private -// Description: Resets the indication of how the document will be -// downloaded. This must be re-specified after each -// get_document() (or related) call. -//////////////////////////////////////////////////////////////////// +/** + * Resets the indication of how the document will be downloaded. This must be + * re-specified after each get_document() (or related) call. + */ void HTTPChannel:: reset_download_to() { _started_download = false; @@ -3964,12 +3727,10 @@ reset_download_to() { _download_dest = DD_none; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::close_download_stream -// Access: Private -// Description: Ensures the file opened for receiving the download -// has been correctly closed. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the file opened for receiving the download has been correctly + * closed. + */ void HTTPChannel:: close_download_stream() { if (_download_to_stream != NULL) { @@ -3983,28 +3744,24 @@ close_download_stream() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset_to_new -// Access: Private -// Description: Closes the connection and resets the state to S_new. -//////////////////////////////////////////////////////////////////// +/** + * Closes the connection and resets the state to S_new. + */ void HTTPChannel:: reset_to_new() { if (downloader_cat.is_spam()) { downloader_cat.spam() - << _NOTIFY_HTTP_CHANNEL_ID + << _NOTIFY_HTTP_CHANNEL_ID << "reset_to_new.\n"; } - + close_connection(); _state = S_new; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::reset_body_stream -// Access: Private -// Description: Clears the _body_stream pointer, if it is set. -//////////////////////////////////////////////////////////////////// +/** + * Clears the _body_stream pointer, if it is set. + */ void HTTPChannel:: reset_body_stream() { if (_owns_body_stream) { @@ -4018,12 +3775,9 @@ reset_body_stream() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::close_connection -// Access: Private -// Description: Closes the connection but leaves the _state -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Closes the connection but leaves the _state unchanged. + */ void HTTPChannel:: close_connection() { reset_body_stream(); @@ -4034,25 +3788,22 @@ close_connection() { _read_index++; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::more_useful_status_code -// Access: Private, Static -// Description: Returns true if status code a is a more useful value -// (that is, it represents a more-nearly successfully -// connection attempt, or contains more information) -// than b, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if status code a is a more useful value (that is, it + * represents a more-nearly successfully connection attempt, or contains more + * information) than b, or false otherwise. + */ bool HTTPChannel:: more_useful_status_code(int a, int b) { if (a >= 100 && b >= 100) { - // Both represent HTTP responses. Responses from a server (< - // 1000) are better than those from a proxy; we take advantage of - // the fact that we have already added 1000 to proxy responses. - // Except for 407, so let's fix that now. - if (a == 407) { + // Both represent HTTP responses. Responses from a server (< 1000) are + // better than those from a proxy; we take advantage of the fact that we + // have already added 1000 to proxy responses. Except for 407, so let's + // fix that now. + if (a == 407) { a += 1000; } - if (b == 407) { + if (b == 407) { b += 1000; } @@ -4065,8 +3816,7 @@ more_useful_status_code(int a, int b) { } if (a < 100 && b < 100) { - // Both represent non-HTTP responses. Here a larger number is - // better. + // Both represent non-HTTP responses. Here a larger number is better. return (a > b); } @@ -4081,10 +3831,9 @@ more_useful_status_code(int a, int b) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPChannel::State output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, HTTPChannel::State state) { #ifdef NDEBUG diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index 490265748e..4c4ddfa312 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -1,26 +1,24 @@ -// Filename: httpChannel.h -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpChannel.h + * @author drose + * @date 2002-09-24 + */ #ifndef HTTPCHANNEL_H #define HTTPCHANNEL_H #include "pandabase.h" -// This module requires OpenSSL to compile, even if you do not intend -// to use this to establish https connections; this is because it uses -// the OpenSSL library to portably handle all of the socket -// communications. +// This module requires OpenSSL to compile, even if you do not intend to use +// this to establish https connections; this is because it uses the OpenSSL +// library to portably handle all of the socket communications. #ifdef HAVE_OPENSSL @@ -46,21 +44,17 @@ class Ramfile; class HTTPClient; -//////////////////////////////////////////////////////////////////// -// Class : HTTPChannel -// Description : A single channel of communication from an HTTPClient. -// This is similar to the concept of a 'connection', -// except that HTTP is technically connectionless; in -// fact, a channel may represent one unbroken connection -// or it may transparently close and reopen a new -// connection with each request. -// -// A channel is conceptually a single thread of I/O. -// One document at a time may be requested using a -// channel; a new document may (in general) not be -// requested from the same HTTPChannel until the first -// document has been fully retrieved. -//////////////////////////////////////////////////////////////////// +/** + * A single channel of communication from an HTTPClient. This is similar to + * the concept of a 'connection', except that HTTP is technically + * connectionless; in fact, a channel may represent one unbroken connection or + * it may transparently close and reopen a new connection with each request. + * + * A channel is conceptually a single thread of I/O. One document at a time + * may be requested using a channel; a new document may (in general) not be + * requested from the same HTTPChannel until the first document has been fully + * retrieved. + */ class EXPCL_PANDAEXPRESS HTTPChannel : public TypedReferenceCount { private: HTTPChannel(HTTPClient *client); @@ -69,9 +63,9 @@ public: virtual ~HTTPChannel(); PUBLISHED: - // get_status_code() will either return an HTTP-style status code >= - // 100 (e.g. 404), or one of the following values. In general, - // these are ordered from less-successful to more-successful. + // get_status_code() will either return an HTTP-style status code >= 100 + // (e.g. 404), or one of the following values. In general, these are + // ordered from less-successful to more-successful. enum StatusCode { SC_incomplete = 0, SC_internal_error, @@ -87,16 +81,16 @@ PUBLISHED: SC_ssl_internal_failure, SC_ssl_no_handshake, - // No one returns this code, but StatusCode values higher than - // this are deemed more successful than any generic HTTP response. + // No one returns this code, but StatusCode values higher than this are + // deemed more successful than any generic HTTP response. SC_http_error_watermark, SC_ssl_invalid_server_certificate, SC_ssl_self_signed_server_certificate, SC_ssl_unexpected_server, - - // These errors are only generated after a download_to_*() call - // been issued. + + // These errors are only generated after a download_to_*() call been + // issued. SC_download_open_error, SC_download_write_error, SC_download_invalid_range, @@ -171,7 +165,7 @@ PUBLISHED: INLINE void send_extra_header(const string &key, const string &value); BLOCKING INLINE bool get_document(const DocumentSpec &url); - BLOCKING INLINE bool get_subdocument(const DocumentSpec &url, + BLOCKING INLINE bool get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte); BLOCKING INLINE bool get_header(const DocumentSpec &url); BLOCKING INLINE bool post_form(const DocumentSpec &url, const string &body); @@ -182,7 +176,7 @@ PUBLISHED: BLOCKING INLINE bool get_options(const DocumentSpec &url); INLINE void begin_get_document(const DocumentSpec &url); - INLINE void begin_get_subdocument(const DocumentSpec &url, + INLINE void begin_get_subdocument(const DocumentSpec &url, size_t first_byte, size_t last_byte); INLINE void begin_get_header(const DocumentSpec &url); INLINE void begin_post_form(const DocumentSpec &url, const string &body); @@ -233,7 +227,7 @@ private: bool run_download_to_ram(); bool run_download_to_stream(); - void begin_request(HTTPEnum::Method method, const DocumentSpec &url, + void begin_request(HTTPEnum::Method method, const DocumentSpec &url, const string &body, bool nonblocking, size_t first_byte, size_t last_byte); void reconsider_proxy(); @@ -253,7 +247,7 @@ private: void check_socket(); - void check_preapproved_server_certificate(X509 *cert, bool &cert_preapproved, + void check_preapproved_server_certificate(X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const; bool validate_server_name(X509 *cert); static bool match_cert_name(const string &cert_name, const string &hostname); @@ -279,8 +273,7 @@ private: static bool more_useful_status_code(int a, int b); public: - // This is declared public solely so we can make an ostream operator - // for it. + // This is declared public solely so we can make an ostream operator for it. enum State { S_new, S_try_next_proxy, @@ -387,13 +380,13 @@ private: // What type of response do we get to our HTTP request? enum ResponseType { RT_none, - RT_hangup, // immediately lost connection + RT_hangup, // immediately lost connection RT_non_http, // something that wasn't an expected HTTP response RT_http_hangup, // the start of an HTTP response, then a lost connection RT_http_complete // a valid HTTP response completed }; ResponseType _response_type; - + // Not a phash_map, to maintain sorted order. typedef pmap Headers; Headers _headers; @@ -407,12 +400,11 @@ private: bool _got_file_size; bool _got_transfer_file_size; - // These members are used to maintain the current state while - // communicating with the server. We need to store everything in - // the class object instead of using local variables because in the - // case of nonblocking I/O we have to be able to return to the - // caller after any I/O operation and resume later where we left - // off. + // These members are used to maintain the current state while communicating + // with the server. We need to store everything in the class object instead + // of using local variables because in the case of nonblocking IO we have to + // be able to return to the caller after any IO operation and resume later + // where we left off. State _state; State _done_state; double _started_connecting_time; @@ -433,8 +425,8 @@ private: int _last_status_code; double _last_run_time; - // RAU we find that we may need a little more time for the - // ssl handshake when the phase files are downloading + // RAU we find that we may need a little more time for the ssl handshake + // when the phase files are downloading double _extra_ssl_handshake_time; public: @@ -465,5 +457,3 @@ ostream &operator << (ostream &out, HTTPChannel::State state); #endif // HAVE_OPENSSL #endif - - diff --git a/panda/src/downloader/httpClient.I b/panda/src/downloader/httpClient.I index 03fc01a9b4..15047431c2 100644 --- a/panda/src/downloader/httpClient.I +++ b/panda/src/downloader/httpClient.I @@ -1,54 +1,42 @@ -// Filename: httpClient.I -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpClient.I + * @author drose + * @date 2002-09-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_try_all_direct -// Access: Published -// Description: If this is set true, then after a connection attempt -// through a proxy fails, we always try a direct -// connection, regardless of whether the host is listed -// on the direct_host_spec list. If this is false, a -// direct attempt is not made when we have a proxy in -// effect, even if the proxy fails. -//////////////////////////////////////////////////////////////////// +/** + * If this is set true, then after a connection attempt through a proxy fails, + * we always try a direct connection, regardless of whether the host is listed + * on the direct_host_spec list. If this is false, a direct attempt is not + * made when we have a proxy in effect, even if the proxy fails. + */ INLINE void HTTPClient:: set_try_all_direct(bool try_all_direct) { _try_all_direct = try_all_direct; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_try_all_direct -// Access: Published -// Description: Returns whether a failed connection through a proxy -// will be followed up by a direct connection attempt, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether a failed connection through a proxy will be followed up by + * a direct connection attempt, false otherwise. + */ INLINE bool HTTPClient:: get_try_all_direct() const { return _try_all_direct; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_client_certificate_filename -// Access: Published -// Description: Sets the filename of the pem-formatted file that will -// be read for the client public and private keys if an -// SSL server requests a certificate. Either this or -// set_client_certificate_pem() may be used to specify a -// client certificate. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filename of the pem-formatted file that will be read for the + * client public and private keys if an SSL server requests a certificate. + * Either this or set_client_certificate_pem() may be used to specify a client + * certificate. + */ INLINE void HTTPClient:: set_client_certificate_filename(const Filename &filename) { _client_certificate_filename = filename; @@ -56,15 +44,12 @@ set_client_certificate_filename(const Filename &filename) { unload_client_certificate(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_client_certificate_pem -// Access: Published -// Description: Sets the pem-formatted contents of the certificate -// that will be parsed for the client public and private -// keys if an SSL server requests a certificate. Either -// this or set_client_certificate_filename() may be used -// to specify a client certificate. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pem-formatted contents of the certificate that will be parsed for + * the client public and private keys if an SSL server requests a certificate. + * Either this or set_client_certificate_filename() may be used to specify a + * client certificate. + */ INLINE void HTTPClient:: set_client_certificate_pem(const string &pem) { _client_certificate_pem = pem; @@ -72,121 +57,93 @@ set_client_certificate_pem(const string &pem) { unload_client_certificate(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_client_certificate_passphrase -// Access: Published -// Description: Sets the passphrase used to decrypt the private key -// in the certificate named by -// set_client_certificate_filename() or -// set_client_certificate_pem(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the passphrase used to decrypt the private key in the certificate + * named by set_client_certificate_filename() or set_client_certificate_pem(). + */ INLINE void HTTPClient:: set_client_certificate_passphrase(const string &passphrase) { _client_certificate_passphrase = passphrase; unload_client_certificate(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_http_version -// Access: Published -// Description: Specifies the version of HTTP that the client uses to -// identify itself to the server. The default is HV_11, -// or HTTP 1.0; you can set this to HV_10 (HTTP 1.0) to -// request the server use the older interface. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the version of HTTP that the client uses to identify itself to + * the server. The default is HV_11, or HTTP 1.0; you can set this to HV_10 + * (HTTP 1.0) to request the server use the older interface. + */ INLINE void HTTPClient:: set_http_version(HTTPEnum::HTTPVersion version) { _http_version = version; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_http_version -// Access: Published -// Description: Returns the client's current setting for HTTP -// version. See set_http_version(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the client's current setting for HTTP version. See + * set_http_version(). + */ INLINE HTTPEnum::HTTPVersion HTTPClient:: get_http_version() const { return _http_version; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_verify_ssl -// Access: Published -// Description: Specifies whether the client will insist on verifying -// the identity of the servers it connects to via SSL -// (that is, https). -// -// The parameter value is an enumerated type which -// indicates the level of security to which the client -// will insist upon. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether the client will insist on verifying the identity of the + * servers it connects to via SSL (that is, https). + * + * The parameter value is an enumerated type which indicates the level of + * security to which the client will insist upon. + */ INLINE void HTTPClient:: set_verify_ssl(HTTPClient::VerifySSL verify_ssl) { _verify_ssl = verify_ssl; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_verify_ssl -// Access: Published -// Description: Returns whether the client will insist on verifying -// the identity of the servers it connects to via SSL -// (that is, https). See set_verify_ssl(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the client will insist on verifying the identity of the + * servers it connects to via SSL (that is, https). See set_verify_ssl(). + */ INLINE HTTPClient::VerifySSL HTTPClient:: get_verify_ssl() const { return _verify_ssl; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_cipher_list -// Access: Published -// Description: Specifies the set of ciphers that are to be made -// available for SSL connections. This is a string as -// described in the ciphers(1) man page of the OpenSSL -// documentation (or see -// http://www.openssl.org/docs/apps/ciphers.html ). If -// this is not specified, the default is provided by the -// Config file. You may also specify "DEFAULT" to use -// the built-in OpenSSL default value. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the set of ciphers that are to be made available for SSL + * connections. This is a string as described in the ciphers(1) man page of + * the OpenSSL documentation (or see + * http://www.openssl.org/docs/apps/ciphers.html ). If this is not specified, + * the default is provided by the Config file. You may also specify "DEFAULT" + * to use the built-in OpenSSL default value. + */ INLINE void HTTPClient:: set_cipher_list(const string &cipher_list) { _cipher_list = cipher_list; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_cipher_list -// Access: Published -// Description: Returns the set of ciphers as set by -// set_cipher_list(). See set_cipher_list(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of ciphers as set by set_cipher_list(). See + * set_cipher_list(). + */ INLINE const string &HTTPClient:: get_cipher_list() const { return _cipher_list; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::base64_encode -// Access: Published, Static -// Description: Implements HTTPAuthorization::base64_encode(). This -// is provided here just as a convenient place to -// publish it for access by the scripting language; C++ -// code should probably use HTTPAuthorization directly. -//////////////////////////////////////////////////////////////////// +/** + * Implements HTTPAuthorization::base64_encode(). This is provided here just + * as a convenient place to publish it for access by the scripting language; + * C++ code should probably use HTTPAuthorization directly. + */ INLINE string HTTPClient:: base64_encode(const string &s) { return HTTPAuthorization::base64_encode(s); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::base64_decode -// Access: Published, Static -// Description: Implements HTTPAuthorization::base64_decode(). This -// is provided here just as a convenient place to -// publish it for access by the scripting language; C++ -// code should probably use HTTPAuthorization directly. -//////////////////////////////////////////////////////////////////// +/** + * Implements HTTPAuthorization::base64_decode(). This is provided here just + * as a convenient place to publish it for access by the scripting language; + * C++ code should probably use HTTPAuthorization directly. + */ INLINE string HTTPClient:: base64_decode(const string &s) { return HTTPAuthorization::base64_decode(s); diff --git a/panda/src/downloader/httpClient.cxx b/panda/src/downloader/httpClient.cxx index fcab207736..0366107669 100644 --- a/panda/src/downloader/httpClient.cxx +++ b/panda/src/downloader/httpClient.cxx @@ -1,16 +1,15 @@ -// Filename: httpClient.cxx -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpClient.cxx + * @author drose + * @date 2002-09-24 + */ #include "httpClient.h" #include "httpChannel.h" @@ -27,10 +26,9 @@ PT(HTTPClient) HTTPClient::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: trim_blanks -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static string trim_blanks(const string &str) { size_t start = 0; @@ -46,18 +44,15 @@ trim_blanks(const string &str) { return str.substr(start, end - start); } -//////////////////////////////////////////////////////////////////// -// Function: tokenize -// Description: Chops the source string up into pieces delimited by -// any of the characters specified in delimiters. -// Repeated delimiter characters represent zero-length -// tokens. -// -// It is the user's responsibility to ensure the output -// vector is cleared before calling this function; the -// results will simply be appended to the end of the -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Chops the source string up into pieces delimited by any of the characters + * specified in delimiters. Repeated delimiter characters represent zero- + * length tokens. + * + * It is the user's responsibility to ensure the output vector is cleared + * before calling this function; the results will simply be appended to the + * end of the vector. + */ static void tokenize(const string &str, vector_string &words, const string &delimiters) { size_t p = 0; @@ -73,11 +68,9 @@ tokenize(const string &str, vector_string &words, const string &delimiters) { words.push_back(string()); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPClient:: HTTPClient() { ConfigVariableBool verify_ssl @@ -110,7 +103,7 @@ HTTPClient() { PRC_DESC("This specifies the default value for HTTPClient::set_try_all_direct(). " "If this is true, a direct connection will always be attempted after an " "attempt to connect through a proxy fails.")); - + ConfigVariableString http_proxy_username ("http-proxy-username", "", PRC_DESC("This specifies a default username:password to pass to the proxy.")); @@ -132,7 +125,7 @@ HTTPClient() { "connection-specific certificate may also be specified at runtime on " "the HTTPClient object, but this will require having a different " "HTTPClient object for each differently-certificated connection.")); - + ConfigVariableString http_client_certificate_passphrase ("http-client-certificate-passphrase", "", PRC_DESC("This specifies the passphrase to use to decode the certificate named " @@ -156,7 +149,7 @@ HTTPClient() { "it does, we will accept the cert, but only if it also matches " "a known certificate authority. This option may appear " "multiple times.")); - + _http_version = HTTPEnum::HV_11; _verify_ssl = verify_ssl ? VS_normal : VS_no_verify; _ssl_ctx = (SSL_CTX *)NULL; @@ -204,16 +197,14 @@ HTTPClient() { add_preapproved_server_certificate_name(URLSpec(a, true), b); } - // The first time we create an HTTPClient, we must initialize the - // OpenSSL library. The OpenSSLWrapper object does that. + // The first time we create an HTTPClient, we must initialize the OpenSSL + // library. The OpenSSLWrapper object does that. OpenSSLWrapper::get_global_ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPClient:: HTTPClient(const HTTPClient ©) { _ssl_ctx = (SSL_CTX *)NULL; @@ -221,11 +212,9 @@ HTTPClient(const HTTPClient ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void HTTPClient:: operator = (const HTTPClient ©) { _proxies_by_scheme = copy._proxies_by_scheme; @@ -237,16 +226,14 @@ operator = (const HTTPClient ©) { _cookies = copy._cookies; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPClient:: ~HTTPClient() { - // Before we can free the context, we must remove the X509_STORE - // pointer from it, so it won't be destroyed along with it (this - // object is shared among all contexts). + // Before we can free the context, we must remove the X509_STORE pointer + // from it, so it won't be destroyed along with it (this object is shared + // among all contexts). if (_ssl_ctx != (SSL_CTX *)NULL) { _ssl_ctx->cert_store = NULL; SSL_CTX_free(_ssl_ctx); @@ -255,43 +242,33 @@ HTTPClient:: unload_client_certificate(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::init_random_seed -// Access: Published, Static -// Description: This may be called once, presumably at the beginning -// of an application, to initialize OpenSSL's random -// seed. On Windows, it is particularly important to -// call this at startup if you are going to be performing -// any https operations or otherwise use encryption, -// since the Windows algorithm for getting a random seed -// takes 2-3 seconds at startup, but can take 30 seconds -// or more after you have opened a 3-D graphics window -// and started rendering. -// -// There is no harm in calling this method multiple -// times, or in not calling it at all. -//////////////////////////////////////////////////////////////////// +/** + * This may be called once, presumably at the beginning of an application, to + * initialize OpenSSL's random seed. On Windows, it is particularly important + * to call this at startup if you are going to be performing any https + * operations or otherwise use encryption, since the Windows algorithm for + * getting a random seed takes 2-3 seconds at startup, but can take 30 seconds + * or more after you have opened a 3-D graphics window and started rendering. + * + * There is no harm in calling this method multiple times, or in not calling + * it at all. + */ void HTTPClient:: init_random_seed() { - // Creating the global OpenSSLWrapper object is nowadays sufficient - // to ensure that OpenSSL and its random seed have been initialized. + // Creating the global OpenSSLWrapper object is nowadays sufficient to + // ensure that OpenSSL and its random seed have been initialized. OpenSSLWrapper::get_global_ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_proxy_spec -// Access: Published -// Description: Specifies the complete set of proxies to use for all -// schemes. This is either a semicolon-delimited set of -// hostname:ports, or a semicolon-delimited set of pairs -// of the form "scheme=hostname:port", or a combination. -// Use the keyword DIRECT, or an empty string, to -// represent a direct connection. A particular scheme -// and/or proxy host may be listed more than once. This -// is a convenience function that can be used in place -// of explicit calls to add_proxy() for each -// scheme/proxy pair. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the complete set of proxies to use for all schemes. This is + * either a semicolon-delimited set of hostname:ports, or a semicolon- + * delimited set of pairs of the form "scheme=hostname:port", or a + * combination. Use the keyword DIRECT, or an empty string, to represent a + * direct connection. A particular scheme and/or proxy host may be listed + * more than once. This is a convenience function that can be used in place + * of explicit calls to add_proxy() for each scheme/proxy pair. + */ void HTTPClient:: set_proxy_spec(const string &proxy_spec) { clear_proxy(); @@ -307,7 +284,7 @@ set_proxy_spec(const string &proxy_spec) { pi != proxies.end(); ++pi) { const string &spec = (*pi); - + // Divide out the scheme and the hostname. string scheme; string proxy; @@ -319,7 +296,7 @@ set_proxy_spec(const string &proxy_spec) { scheme = trim_blanks(spec.substr(0, equals)); proxy = trim_blanks(spec.substr(equals + 1)); } - + if (proxy == "DIRECT" || proxy.empty()) { add_proxy(scheme, URLSpec()); } else { @@ -329,17 +306,13 @@ set_proxy_spec(const string &proxy_spec) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_proxy_spec -// Access: Published -// Description: Returns the complete set of proxies to use for all -// schemes. This is a string of the form specified by -// set_proxy_spec(), above. Note that the string -// returned by this function may not be exactly the same -// as the string passed into set_proxy_spec(), since the -// string is regenerated from the internal storage -// structures and may therefore be reordered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete set of proxies to use for all schemes. This is a + * string of the form specified by set_proxy_spec(), above. Note that the + * string returned by this function may not be exactly the same as the string + * passed into set_proxy_spec(), since the string is regenerated from the + * internal storage structures and may therefore be reordered. + */ string HTTPClient:: get_proxy_spec() const { string result; @@ -369,14 +342,11 @@ get_proxy_spec() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_direct_host_spec -// Access: Published -// Description: Specifies the set of hosts that should be connected -// to directly, without using a proxy. This is a -// semicolon-separated list of hostnames that may -// contain wildcard characters ("*"). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the set of hosts that should be connected to directly, without + * using a proxy. This is a semicolon-separated list of hostnames that may + * contain wildcard characters ("*"). + */ void HTTPClient:: set_direct_host_spec(const string &direct_host_spec) { clear_direct_host(); @@ -384,29 +354,26 @@ set_direct_host_spec(const string &direct_host_spec) { // Tokenize the string based on the semicolons. vector_string hosts; tokenize(direct_host_spec, hosts, ";"); - + for (vector_string::const_iterator hi = hosts.begin(); hi != hosts.end(); ++hi) { string spec = trim_blanks(*hi); - // We should be careful to avoid adding any empty hostnames to the - // list. In particular, we will get one empty hostname if the - // direct_host_spec is empty. + // We should be careful to avoid adding any empty hostnames to the list. + // In particular, we will get one empty hostname if the direct_host_spec + // is empty. if (!spec.empty()) { add_direct_host(spec); } } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_direct_host_spec -// Access: Published -// Description: Returns the set of hosts that should be connected -// to directly, without using a proxy, as a -// semicolon-separated list of hostnames that may -// contain wildcard characters ("*"). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of hosts that should be connected to directly, without + * using a proxy, as a semicolon-separated list of hostnames that may contain + * wildcard characters ("*"). + */ string HTTPClient:: get_direct_host_spec() const { string result; @@ -424,31 +391,25 @@ get_direct_host_spec() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_proxy -// Access: Published -// Description: Resets the proxy spec to empty. Subsequent calls to -// add_proxy() may be made to build up the set of proxy -// servers. -//////////////////////////////////////////////////////////////////// +/** + * Resets the proxy spec to empty. Subsequent calls to add_proxy() may be + * made to build up the set of proxy servers. + */ void HTTPClient:: clear_proxy() { _proxies_by_scheme.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_proxy -// Access: Published -// Description: Adds the indicated proxy host as a proxy for -// communications on the given scheme. Usually the -// scheme is "http" or "https". It may be the empty -// string to indicate a general proxy. The proxy string -// may be the empty URL to indicate a direct connection. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated proxy host as a proxy for communications on the given + * scheme. Usually the scheme is "http" or "https". It may be the empty + * string to indicate a general proxy. The proxy string may be the empty URL + * to indicate a direct connection. + */ void HTTPClient:: add_proxy(const string &scheme, const URLSpec &proxy) { URLSpec proxy_url(proxy); - + // The scheme is always converted to lowercase. string lc_scheme; lc_scheme.reserve(scheme.length()); @@ -456,61 +417,55 @@ add_proxy(const string &scheme, const URLSpec &proxy) { for (si = scheme.begin(); si != scheme.end(); ++si) { lc_scheme += tolower(*si); } - + // Remove the trailing colon, if there is one. if (!lc_scheme.empty() && lc_scheme[lc_scheme.length() - 1] == ':') { lc_scheme = lc_scheme.substr(0, lc_scheme.length() - 1); } if (!proxy_url.empty()) { - // Enforce the scheme that we use to communicate to the proxy - // itself. This is not the same as lc_scheme, which is the scheme - // of the requested connection. Generally, all proxies speak - // HTTP, except for Socks proxies. + // Enforce the scheme that we use to communicate to the proxy itself. + // This is not the same as lc_scheme, which is the scheme of the requested + // connection. Generally, all proxies speak HTTP, except for Socks + // proxies. if (lc_scheme == "socks") { - // Scheme "socks" implies we talk to the proxy via the "socks" - // scheme, no matter what scheme the user actually specified. + // Scheme "socks" implies we talk to the proxy via the "socks" scheme, + // no matter what scheme the user actually specified. proxy_url.set_scheme("socks"); - + } else if (!proxy_url.has_scheme()) { - // Otherwise, if the user didn't specify a scheme to talk to the - // proxy, the default is "http". + // Otherwise, if the user didn't specify a scheme to talk to the proxy, + // the default is "http". proxy_url.set_scheme("http"); } } - + _proxies_by_scheme[lc_scheme].push_back(proxy_url); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_direct_host -// Access: Published -// Description: Resets the set of direct hosts to empty. Subsequent -// calls to add_direct_host() may be made to build up -// the list of hosts that do not require a proxy -// connection. -//////////////////////////////////////////////////////////////////// +/** + * Resets the set of direct hosts to empty. Subsequent calls to + * add_direct_host() may be made to build up the list of hosts that do not + * require a proxy connection. + */ void HTTPClient:: clear_direct_host() { _direct_hosts.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_direct_host -// Access: Published -// Description: Adds the indicated name to the set of hostnames that -// are connected to directly, without using a proxy. -// This name may be either a DNS name or an IP address, -// and it may include the * as a wildcard character. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated name to the set of hostnames that are connected to + * directly, without using a proxy. This name may be either a DNS name or an + * IP address, and it may include the * as a wildcard character. + */ void HTTPClient:: add_direct_host(const string &hostname) { // The hostname is always converted to lowercase. string lc_hostname; lc_hostname.reserve(hostname.length()); - for (string::const_iterator si = hostname.begin(); - si != hostname.end(); + for (string::const_iterator si = hostname.begin(); + si != hostname.end(); ++si) { lc_hostname += tolower(*si); } @@ -518,26 +473,22 @@ add_direct_host(const string &hostname) { _direct_hosts.push_back(GlobPattern(lc_hostname)); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_proxies_for_url -// Access: Published -// Description: Fills up the indicated vector with the list of -// URLSpec objects, in the order in which they should be -// tried, that are appropriate proxies to try for the -// indicated URL. The empty URL is returned for a -// direct connection. -// -// It is the user's responsibility to empty this vector -// before calling this method; otherwise, the proxy -// URL's will simply be appended to the existing list. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated vector with the list of URLSpec objects, in the + * order in which they should be tried, that are appropriate proxies to try + * for the indicated URL. The empty URL is returned for a direct connection. + * + * It is the user's responsibility to empty this vector before calling this + * method; otherwise, the proxy URL's will simply be appended to the existing + * list. + */ void HTTPClient:: get_proxies_for_url(const URLSpec &url, pvector &proxies) const { // First, check if the hostname matches any listed in direct_hosts. string hostname = url.get_server(); - // If the hostname is empty, treat it as a special case: we don't - // match any of the hostnames listed in direct_hosts (even "*"). + // If the hostname is empty, treat it as a special case: we don't match any + // of the hostnames listed in direct_hosts (even "*"). if (!hostname.empty()) { DirectHosts::const_iterator si; for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) { @@ -549,8 +500,8 @@ get_proxies_for_url(const URLSpec &url, pvector &proxies) const { } } - // Build our list of proxies into a temporary vector, so we can pull - // out duplicates later. + // Build our list of proxies into a temporary vector, so we can pull out + // duplicates later. pvector temp_list; // Now choose the appropriate proxy based on the scheme. @@ -565,9 +516,9 @@ get_proxies_for_url(const URLSpec &url, pvector &proxies) const { } if (!got_any && (scheme.empty() || url.is_ssl())) { - // An empty scheme (or an ssl-style scheme) implies we will need - // to make a direct connection, so fallback to a socks-style - // and/or https-style scheme. + // An empty scheme (or an ssl-style scheme) implies we will need to make a + // direct connection, so fallback to a socks-style andor https-style + // scheme. if (get_proxies_for_scheme("socks", temp_list)) { got_any = true; @@ -578,8 +529,8 @@ get_proxies_for_url(const URLSpec &url, pvector &proxies) const { } if (!got_any) { - // If we didn't find our scheme of choice, fall back to the default - // proxy type, if we've got one. + // If we didn't find our scheme of choice, fall back to the default proxy + // type, if we've got one. if (get_proxies_for_scheme("", temp_list)) { got_any = true; } @@ -606,14 +557,11 @@ get_proxies_for_url(const URLSpec &url, pvector &proxies) const { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_proxies_for_url -// Access: Published -// Description: Returns a semicolon-delimited list of proxies, in the -// order in which they should be tried, that are -// appropriate for the indicated URL. The keyword -// DIRECT indicates a direct connection should be tried. -//////////////////////////////////////////////////////////////////// +/** + * Returns a semicolon-delimited list of proxies, in the order in which they + * should be tried, that are appropriate for the indicated URL. The keyword + * DIRECT indicates a direct connection should be tried. + */ string HTTPClient:: get_proxies_for_url(const URLSpec &url) const { pvector proxies; @@ -643,20 +591,15 @@ get_proxies_for_url(const URLSpec &url) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_username -// Access: Published -// Description: Specifies the username:password string corresponding -// to a particular server and/or realm, when demanded by -// the server. Either or both of the server or realm -// may be empty; if so, they match anything. Also, the -// server may be set to the special string "*proxy", -// which will match any proxy server. -// -// If the username is set to the empty string, this -// clears the password for the particular server/realm -// pair. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the username:password string corresponding to a particular server + * and/or realm, when demanded by the server. Either or both of the server or + * realm may be empty; if so, they match anything. Also, the server may be + * set to the special string "*proxy", which will match any proxy server. + * + * If the username is set to the empty string, this clears the password for + * the particular server/realm pair. + */ void HTTPClient:: set_username(const string &server, const string &realm, const string &username) { string key = server + ":" + realm; @@ -667,13 +610,10 @@ set_username(const string &server, const string &realm, const string &username) } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_username -// Access: Published -// Description: Returns the username:password string set for this -// server/realm pair, or empty string if nothing has -// been set. See set_username(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the username:password string set for this server/realm pair, or + * empty string if nothing has been set. See set_username(). + */ string HTTPClient:: get_username(const string &server, const string &realm) const { string key = server + ":" + realm; @@ -685,12 +625,10 @@ get_username(const string &server, const string &realm) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::set_cookie -// Access: Published -// Description: Stores the indicated cookie in the client's list of -// cookies, as if it had been received from a server. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated cookie in the client's list of cookies, as if it had + * been received from a server. + */ void HTTPClient:: set_cookie(const HTTPCookie &cookie) { if (cookie.is_expired()) { @@ -699,21 +637,19 @@ set_cookie(const HTTPCookie &cookie) { } else { pair result = _cookies.insert(cookie); if (!result.second) { - // We already had a cookie matching the supplied domain/path/name, - // so replace it. + // We already had a cookie matching the supplied domainpathname, so + // replace it. const HTTPCookie &orig_cookie = *result.first; ((HTTPCookie &)orig_cookie).update_from(cookie); } } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_cookie -// Access: Published -// Description: Removes the cookie with the matching domain/path/name -// from the client's list of cookies. Returns true if -// it was removed, false if the cookie was not matched. -//////////////////////////////////////////////////////////////////// +/** + * Removes the cookie with the matching domain/path/name from the client's + * list of cookies. Returns true if it was removed, false if the cookie was + * not matched. + */ bool HTTPClient:: clear_cookie(const HTTPCookie &cookie) { Cookies::iterator ci = _cookies.find(cookie); @@ -725,36 +661,28 @@ clear_cookie(const HTTPCookie &cookie) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_all_cookies -// Access: Published -// Description: Removes the all stored cookies from the client. -//////////////////////////////////////////////////////////////////// +/** + * Removes the all stored cookies from the client. + */ void HTTPClient:: clear_all_cookies() { _cookies.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::has_cookie -// Access: Published -// Description: Returns true if there is a cookie in the client -// matching the given cookie's domain/path/name, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a cookie in the client matching the given cookie's + * domain/path/name, false otherwise. + */ bool HTTPClient:: has_cookie(const HTTPCookie &cookie) const { Cookies::const_iterator ci = _cookies.find(cookie); return (ci != _cookies.end()); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_cookie -// Access: Published -// Description: Looks up and returns the cookie in the client -// matching the given cookie's domain/path/name. If -// there is no matching cookie, returns an empty cookie. -//////////////////////////////////////////////////////////////////// +/** + * Looks up and returns the cookie in the client matching the given cookie's + * domain/path/name. If there is no matching cookie, returns an empty cookie. + */ HTTPCookie HTTPClient:: get_cookie(const HTTPCookie &cookie) const { Cookies::const_iterator ci = _cookies.find(cookie); @@ -765,14 +693,11 @@ get_cookie(const HTTPCookie &cookie) const { return HTTPCookie(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::copy_cookies_from -// Access: Published -// Description: Copies all the cookies from the indicated HTTPClient -// into this one. Existing cookies in this client are -// not affected, unless they are shadowed by the new -// cookies. -//////////////////////////////////////////////////////////////////// +/** + * Copies all the cookies from the indicated HTTPClient into this one. + * Existing cookies in this client are not affected, unless they are shadowed + * by the new cookies. + */ void HTTPClient:: copy_cookies_from(const HTTPClient &other) { Cookies::const_iterator ci; @@ -781,14 +706,11 @@ copy_cookies_from(const HTTPClient &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::write_cookies -// Access: Published -// Description: Outputs the complete list of cookies stored on the -// client, for all domains, including the expired -// cookies (which will normally not be sent back to a -// host). -//////////////////////////////////////////////////////////////////// +/** + * Outputs the complete list of cookies stored on the client, for all domains, + * including the expired cookies (which will normally not be sent back to a + * host). + */ void HTTPClient:: write_cookies(ostream &out) const { Cookies::const_iterator ci; @@ -797,14 +719,11 @@ write_cookies(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::send_cookies -// Access: Published -// Description: Writes to the indicated ostream a "Cookie" header -// line for sending the cookies appropriate to the -// indicated URL along with an HTTP request. This also -// removes expired cookies. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a "Cookie" header line for sending the + * cookies appropriate to the indicated URL along with an HTTP request. This + * also removes expired cookies. + */ void HTTPClient:: send_cookies(ostream &out, const URLSpec &url) { HTTPDate now = HTTPDate::now(); @@ -845,18 +764,14 @@ send_cookies(ostream &out, const URLSpec &url) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::load_client_certificate -// Access: Published -// Description: Attempts to load the certificate named by -// set_client_certificate_filename() immediately, and -// returns true if successful, false otherwise. -// -// Normally this need not be explicitly called, since it -// will be called automatically if the server requests a -// certificate, but it may be useful to determine ahead -// of time if the certificate can be loaded correctly. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to load the certificate named by set_client_certificate_filename() + * immediately, and returns true if successful, false otherwise. + * + * Normally this need not be explicitly called, since it will be called + * automatically if the server requests a certificate, but it may be useful to + * determine ahead of time if the certificate can be loaded correctly. + */ bool HTTPClient:: load_client_certificate() { if (!_client_certificate_loaded) { @@ -868,7 +783,7 @@ load_client_certificate() { // First, read the complete file into memory. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - if (!vfs->read_file(_client_certificate_filename, + if (!vfs->read_file(_client_certificate_filename, _client_certificate_pem, true)) { // Could not find or read file. downloader_cat.warning() @@ -878,35 +793,33 @@ load_client_certificate() { } if (!_client_certificate_pem.empty()) { - // Create an in-memory BIO to read the "file" from the memory - // buffer, and call the low-level routines to read the - // keys from the BIO. - BIO *mbio = BIO_new_mem_buf((void *)_client_certificate_pem.data(), + // Create an in-memory BIO to read the "file" from the memory buffer, + // and call the low-level routines to read the keys from the BIO. + BIO *mbio = BIO_new_mem_buf((void *)_client_certificate_pem.data(), _client_certificate_pem.length()); - + ERR_clear_error(); - _client_certificate_priv = - PEM_read_bio_PrivateKey(mbio, NULL, NULL, + _client_certificate_priv = + PEM_read_bio_PrivateKey(mbio, NULL, NULL, (char *)_client_certificate_passphrase.c_str()); - - // Rewind the "file" to the beginning in order to read the public - // key (which might appear first in the file). + + // Rewind the "file" to the beginning in order to read the public key + // (which might appear first in the file). BIO_reset(mbio); - + ERR_clear_error(); - _client_certificate_pub = + _client_certificate_pub = PEM_read_bio_X509(mbio, NULL, NULL, NULL); - + BIO_free(mbio); - - + + NotifySeverity sev = NS_debug; string source = "memory"; if (!_client_certificate_filename.empty()) { // Only report status to "info" severity if we have read the - // certificate from a file. If it came from an in-memory image, - // a failure will presumably be handled by whoever set the - // image. + // certificate from a file. If it came from an in-memory image, a + // failure will presumably be handled by whoever set the image. sev = NS_info; source = _client_certificate_filename; } @@ -914,15 +827,15 @@ load_client_certificate() { if (downloader_cat.is_on(sev)) { if (_client_certificate_priv != (EVP_PKEY *)NULL && _client_certificate_pub != (X509 *)NULL) { - downloader_cat.out(sev) + downloader_cat.out(sev) << "Read client certificate from " << source << "\n"; - + } else { if (_client_certificate_priv == (EVP_PKEY *)NULL) { downloader_cat.out(sev) << "Could not read private key from " << source << "\n"; } - + if (_client_certificate_pub == (X509 *)NULL) { downloader_cat.out(sev) << "Could not read public key from " << source << "\n"; @@ -936,24 +849,18 @@ load_client_certificate() { _client_certificate_pub != (X509 *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_preapproved_server_certificate_filename -// Access: Published -// Description: Adds the certificate defined in the indicated PEM -// filename as a "pre-approved" certificate for the -// indicated server, defined by the hostname and port -// (only) from the given URL. -// -// If the server offers this particular certificate on a -// secure connection, it will be accepted without -// question. This is particularly useful for -// communicating with a server using a known self-signed -// certificate. -// -// See also the similar -// add_preapproved_server_certificate_pem(), and the -// weaker add_preapproved_server_certificate_name(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the certificate defined in the indicated PEM filename as a "pre- + * approved" certificate for the indicated server, defined by the hostname and + * port (only) from the given URL. + * + * If the server offers this particular certificate on a secure connection, it + * will be accepted without question. This is particularly useful for + * communicating with a server using a known self-signed certificate. + * + * See also the similar add_preapproved_server_certificate_pem(), and the + * weaker add_preapproved_server_certificate_name(). + */ bool HTTPClient:: add_preapproved_server_certificate_filename(const URLSpec &url, const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -969,31 +876,24 @@ add_preapproved_server_certificate_filename(const URLSpec &url, const Filename & return add_preapproved_server_certificate_pem(url, pem); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_preapproved_server_certificate_pem -// Access: Published -// Description: Adds the certificate defined in the indicated data -// string, formatted as a PEM block, as a "pre-approved" -// certificate for the indicated server, defined by the -// hostname and port (only) from the given URL. -// -// If the server offers this particular certificate on a -// secure connection, it will be accepted without -// question. This is particularly useful for -// communicating with a server using a known self-signed -// certificate. -// -// See also the similar -// add_preapproved_server_certificate_filename(), and -// the weaker add_preapproved_server_certificate_name(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the certificate defined in the indicated data string, formatted as a + * PEM block, as a "pre-approved" certificate for the indicated server, + * defined by the hostname and port (only) from the given URL. + * + * If the server offers this particular certificate on a secure connection, it + * will be accepted without question. This is particularly useful for + * communicating with a server using a known self-signed certificate. + * + * See also the similar add_preapproved_server_certificate_filename(), and the + * weaker add_preapproved_server_certificate_name(). + */ bool HTTPClient:: add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { - // Create an in-memory BIO to read the "file" from the memory - // buffer, and call the low-level routine to read the - // cert from the BIO. + // Create an in-memory BIO to read the "file" from the memory buffer, and + // call the low-level routine to read the cert from the BIO. BIO *mbio = BIO_new_mem_buf((void *)pem.data(), pem.length()); - + ERR_clear_error(); X509 *cert = PEM_read_bio_X509(mbio, NULL, NULL, NULL); BIO_free(mbio); @@ -1005,7 +905,7 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { } string server_and_port = url.get_server_and_port(); - PreapprovedServerCerts::iterator psci = + PreapprovedServerCerts::iterator psci = _preapproved_server_certs.insert(PreapprovedServerCerts::value_type(server_and_port, PreapprovedServerCert())).first; PreapprovedServerCert &psc = (*psci).second; @@ -1014,30 +914,26 @@ add_preapproved_server_certificate_pem(const URLSpec &url, const string &pem) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_preapproved_server_certificate_name -// Access: Published -// Description: Adds the certificate *name* only, as a "pre-approved" -// certificate name for the indicated server, defined by -// the hostname and port (only) from the given URL. -// -// This is a weaker function than -// add_preapproved_server_certificate_filename(). This -// checks only the subject name of the certificate, -// without checking for a particular certificate by key. -// This means that a variety of server certificates may -// match the indicated name. -// -// Because this is a weaker verification, it only -// applies to server certificates that are signed by a -// recognized certificate authority. Thus, it cannot be -// used to pre-approve self-signed certificates, but it -// can be used to accept a server certificate offered by -// a different hostname than the one in the cert itself. -// -// The certificate name should be formatted in the form -// /type0=value0/type1=value1/type2=... -//////////////////////////////////////////////////////////////////// +/** + * Adds the certificate *name* only, as a "pre-approved" certificate name for + * the indicated server, defined by the hostname and port (only) from the + * given URL. + * + * This is a weaker function than + * add_preapproved_server_certificate_filename(). This checks only the + * subject name of the certificate, without checking for a particular + * certificate by key. This means that a variety of server certificates may + * match the indicated name. + * + * Because this is a weaker verification, it only applies to server + * certificates that are signed by a recognized certificate authority. Thus, + * it cannot be used to pre-approve self-signed certificates, but it can be + * used to accept a server certificate offered by a different hostname than + * the one in the cert itself. + * + * The certificate name should be formatted in the form + * type0=value0/type1=value1/type2=... + */ bool HTTPClient:: add_preapproved_server_certificate_name(const URLSpec &url, const string &name) { X509_NAME *cert_name = parse_x509_name(name); @@ -1048,7 +944,7 @@ add_preapproved_server_certificate_name(const URLSpec &url, const string &name) } string server_and_port = url.get_server_and_port(); - PreapprovedServerCerts::iterator psci = + PreapprovedServerCerts::iterator psci = _preapproved_server_certs.insert(PreapprovedServerCerts::value_type(server_and_port, PreapprovedServerCert())).first; PreapprovedServerCert &psc = (*psci).second; @@ -1057,35 +953,28 @@ add_preapproved_server_certificate_name(const URLSpec &url, const string &name) return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_preapproved_server_certificates -// Access: Published -// Description: Removes all preapproved server certificates for the -// indicated server and port. -//////////////////////////////////////////////////////////////////// +/** + * Removes all preapproved server certificates for the indicated server and + * port. + */ void HTTPClient:: clear_preapproved_server_certificates(const URLSpec &url) { string server_and_port = url.get_server_and_port(); _preapproved_server_certs.erase(server_and_port); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::clear_all_preapproved_server_certificates -// Access: Published -// Description: Removes all preapproved server certificates for all -// servers. -//////////////////////////////////////////////////////////////////// +/** + * Removes all preapproved server certificates for all servers. + */ void HTTPClient:: clear_all_preapproved_server_certificates() { _preapproved_server_certs.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_http_version_string -// Access: Published -// Description: Returns the current HTTP version setting as a string, -// e.g. "HTTP/1.0" or "HTTP/1.1". -//////////////////////////////////////////////////////////////////// +/** + * Returns the current HTTP version setting as a string, e.g. "HTTP/1.0" or + * "HTTP/1.1". + */ string HTTPClient:: get_http_version_string() const { switch (_http_version) { @@ -1106,14 +995,11 @@ get_http_version_string() const { return "unknown"; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::parse_http_version_string -// Access: Published -// Description: Matches the string representing a particular HTTP -// version against any of the known versions and returns -// the appropriate enumerated value, or HV_other if the -// version is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Matches the string representing a particular HTTP version against any of + * the known versions and returns the appropriate enumerated value, or + * HV_other if the version is unknown. + */ HTTPEnum::HTTPVersion HTTPClient:: parse_http_version_string(const string &version) { if (version == "HTTP/1.0") { @@ -1127,42 +1013,33 @@ parse_http_version_string(const string &version) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::load_certificates -// Access: Published -// Description: Reads the certificate(s) (delimited by -----BEGIN -// CERTIFICATE----- and -----END CERTIFICATE-----) from -// the indicated file and makes them known as trusted -// public keys for validating future connections. -// Returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the certificate(s) (delimited by -----BEGIN CERTIFICATE----- and + * -----END CERTIFICATE-----) from the indicated file and makes them known as + * trusted public keys for validating future connections. Returns true on + * success, false otherwise. + */ bool HTTPClient:: load_certificates(const Filename &filename) { OpenSSLWrapper *sslw = OpenSSLWrapper::get_global_ptr(); return (sslw->load_certificates(filename) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::make_channel -// Access: Published -// Description: Returns a new HTTPChannel object that may be used -// for reading multiple documents using the same -// connection, for greater network efficiency than -// calling HTTPClient::get_document() repeatedly (which -// would force a new connection for each document). -// -// Also, HTTPChannel has some additional, less common -// interface methods than the basic interface methods -// that exist on HTTPClient; if you wish to call any of -// these methods you must first obtain an HTTPChannel. -// -// Pass true for persistent_connection to gain this -// network efficiency. If, on the other hand, your -// intention is to use the channel to retrieve only one -// document, then pass false to inform the server that -// we will be dropping the connection after the first -// document. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new HTTPChannel object that may be used for reading multiple + * documents using the same connection, for greater network efficiency than + * calling HTTPClient::get_document() repeatedly (which would force a new + * connection for each document). + * + * Also, HTTPChannel has some additional, less common interface methods than + * the basic interface methods that exist on HTTPClient; if you wish to call + * any of these methods you must first obtain an HTTPChannel. + * + * Pass true for persistent_connection to gain this network efficiency. If, + * on the other hand, your intention is to use the channel to retrieve only + * one document, then pass false to inform the server that we will be dropping + * the connection after the first document. + */ PT(HTTPChannel) HTTPClient:: make_channel(bool persistent_connection) { PT(HTTPChannel) doc = new HTTPChannel(this); @@ -1170,15 +1047,12 @@ make_channel(bool persistent_connection) { return doc; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::post_form -// Access: Published -// Description: Posts form data to a particular URL and retrieves the -// response. Returns a new HTTPChannel object whether -// the document is successfully read or not; you can -// test is_valid() and get_return_code() to determine -// whether the document was retrieved. -//////////////////////////////////////////////////////////////////// +/** + * Posts form data to a particular URL and retrieves the response. Returns a + * new HTTPChannel object whether the document is successfully read or not; + * you can test is_valid() and get_return_code() to determine whether the + * document was retrieved. + */ PT(HTTPChannel) HTTPClient:: post_form(const URLSpec &url, const string &body) { PT(HTTPChannel) doc = new HTTPChannel(this); @@ -1186,15 +1060,11 @@ post_form(const URLSpec &url, const string &body) { return doc; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_document -// Access: Published -// Description: Opens the named document for reading. Returns a new -// HTTPChannel object whether the document is -// successfully read or not; you can test is_valid() and -// get_return_code() to determine whether the document -// was retrieved. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named document for reading. Returns a new HTTPChannel object + * whether the document is successfully read or not; you can test is_valid() + * and get_return_code() to determine whether the document was retrieved. + */ PT(HTTPChannel) HTTPClient:: get_document(const URLSpec &url) { PT(HTTPChannel) doc = new HTTPChannel(this); @@ -1202,15 +1072,12 @@ get_document(const URLSpec &url) { return doc; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_header -// Access: Published -// Description: Like get_document(), except only the header -// associated with the document is retrieved. This may -// be used to test for existence of the document; it -// might also return the size of the document (if the -// server gives us this information). -//////////////////////////////////////////////////////////////////// +/** + * Like get_document(), except only the header associated with the document is + * retrieved. This may be used to test for existence of the document; it + * might also return the size of the document (if the server gives us this + * information). + */ PT(HTTPChannel) HTTPClient:: get_header(const URLSpec &url) { PT(HTTPChannel) doc = new HTTPChannel(this); @@ -1218,11 +1085,9 @@ get_header(const URLSpec &url) { return doc; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_global_ptr -// Access: Published, Static -// Description: Returns the default global HTTPClient. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default global HTTPClient. + */ HTTPClient *HTTPClient:: get_global_ptr() { if (_global_ptr == NULL) { @@ -1232,12 +1097,9 @@ get_global_ptr() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_ssl_ctx -// Access: Public -// Description: Returns the OpenSSL context object, creating it first -// if needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the OpenSSL context object, creating it first if needed. + */ SSL_CTX *HTTPClient:: get_ssl_ctx() { if (_ssl_ctx != (SSL_CTX *)NULL) { @@ -1249,8 +1111,8 @@ get_ssl_ctx() { _ssl_ctx = SSL_CTX_new(SSLv23_client_method()); #if defined(SSL_097) && !defined(NDEBUG) - // If we have debugging enabled, set a callback that allows us to - // report the SSL messages as they are sent and received. + // If we have debugging enabled, set a callback that allows us to report the + // SSL messages as they are sent and received. if (downloader_cat.is_debug()) { SSL_CTX_set_msg_callback(_ssl_ctx, ssl_msg_callback); } @@ -1265,26 +1127,21 @@ get_ssl_ctx() { return _ssl_ctx; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::check_preapproved_server_certificate -// Access: Private -// Description: Checks to see if the indicated certificate is on the -// pre-approved list for the indicated server's URL. -// -// If the full cert itself (including its key) is on the -// pre-approved list, sets both cert_preapproved and -// cert_name_preapproved to true. -// -// If the full cert is not on the pre-approved list, but -// its name matches a name on the pre-approved list, -// sets cert_name_preapproved to true, and -// cert_preapproved to false. -// -// Otherwise, sets both values to false. This doesn't -// mean the cert is necessarily invalid, just that it -// wasn't on the pre-approved list (which is usually -// empty anyway). -//////////////////////////////////////////////////////////////////// +/** + * Checks to see if the indicated certificate is on the pre-approved list for + * the indicated server's URL. + * + * If the full cert itself (including its key) is on the pre-approved list, + * sets both cert_preapproved and cert_name_preapproved to true. + * + * If the full cert is not on the pre-approved list, but its name matches a + * name on the pre-approved list, sets cert_name_preapproved to true, and + * cert_preapproved to false. + * + * Otherwise, sets both values to false. This doesn't mean the cert is + * necessarily invalid, just that it wasn't on the pre-approved list (which is + * usually empty anyway). + */ void HTTPClient:: check_preapproved_server_certificate(const URLSpec &url, X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const { @@ -1292,7 +1149,7 @@ check_preapproved_server_certificate(const URLSpec &url, X509 *cert, cert_name_preapproved = false; string server_and_port = url.get_server_and_port(); - PreapprovedServerCerts::const_iterator psci = + PreapprovedServerCerts::const_iterator psci = _preapproved_server_certs.find(server_and_port); if (psci == _preapproved_server_certs.end()) { @@ -1331,13 +1188,10 @@ check_preapproved_server_certificate(const URLSpec &url, X509 *cert, return; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::get_proxies_for_scheme -// Access: Private -// Description: Adds the proxy servers associated with the indicated -// scheme, if any, to the list. Returns true if any -// were added, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Adds the proxy servers associated with the indicated scheme, if any, to the + * list. Returns true if any were added, false otherwise. + */ bool HTTPClient:: get_proxies_for_scheme(const string &scheme, pvector &proxies) const { ProxiesByScheme::const_iterator si = _proxies_by_scheme.find(scheme); @@ -1357,14 +1211,11 @@ get_proxies_for_scheme(const string &scheme, pvector &proxies) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::add_http_username -// Access: Private -// Description: Handles a Config definition for http-username as -// server:realm:username:password, where either or both -// of server and realm may be empty, or just -// server:username:password or username:password. -//////////////////////////////////////////////////////////////////// +/** + * Handles a Config definition for http-username as + * server:realm:username:password, where either or both of server and realm + * may be empty, or just server:username:password or username:password. + */ void HTTPClient:: add_http_username(const string &http_username) { size_t c1 = http_username.find(':'); @@ -1403,41 +1254,38 @@ add_http_username(const string &http_username) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::select_username -// Access: Private -// Description: Chooses a suitable username:password string for the -// given URL and realm. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a suitable username:password string for the given URL and realm. + */ string HTTPClient:: select_username(const URLSpec &url, bool is_proxy, const string &realm) const { string username; // Look in several places in order to find the matching username. - // Fist, if there's a username on the URL, that always wins (except - // when we are looking for a proxy username). + // Fist, if there's a username on the URL, that always wins (except when we + // are looking for a proxy username). if (url.has_username() && !is_proxy) { username = url.get_username(); } - // Otherwise, start looking on the HTTPClient. + // Otherwise, start looking on the HTTPClient. if (is_proxy) { if (username.empty()) { - // Try the *proxy/realm. + // Try the *proxyrealm. username = get_username("*proxy", realm); } if (username.empty()) { - // Then, try *proxy/any realm. + // Then, try *proxyany realm. username = get_username("*proxy", string()); } } if (username.empty()) { - // Try the specific server/realm. + // Try the specific serverrealm. username = get_username(url.get_server(), realm); } if (username.empty()) { - // Then, try the specific server/any realm. + // Then, try the specific serverany realm. username = get_username(url.get_server(), string()); } if (username.empty()) { @@ -1452,20 +1300,17 @@ select_username(const URLSpec &url, bool is_proxy, const string &realm) const { return username; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::select_auth -// Access: Private -// Description: Chooses a suitable pre-computed authorization for the -// indicated URL. Returns NULL if no authorization -// matches. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a suitable pre-computed authorization for the indicated URL. + * Returns NULL if no authorization matches. + */ HTTPAuthorization *HTTPClient:: select_auth(const URLSpec &url, bool is_proxy, const string &last_realm) { Domains &domains = is_proxy ? _proxy_domains : _www_domains; string canon = HTTPAuthorization::get_canonical_url(url).get_url(); - // Look for the longest domain string that is a prefix of our - // canonical URL. We have to make a linear scan through the list. + // Look for the longest domain string that is a prefix of our canonical URL. + // We have to make a linear scan through the list. Domains::const_iterator best_di = domains.end(); size_t longest_length = 0; Domains::const_iterator di; @@ -1505,16 +1350,12 @@ select_auth(const URLSpec &url, bool is_proxy, const string &last_realm) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::generate_auth -// Access: Private -// Description: Generates a new authorization entry in response to a -// 401 or 407 challenge from the server or proxy. The -// new authorization entry is stored for future -// connections to the same server (or, more precisely, -// the same domain, which may be a subset of the server, -// or it may include multiple servers). -//////////////////////////////////////////////////////////////////// +/** + * Generates a new authorization entry in response to a 401 or 407 challenge + * from the server or proxy. The new authorization entry is stored for future + * connections to the same server (or, more precisely, the same domain, which + * may be a subset of the server, or it may include multiple servers). + */ PT(HTTPAuthorization) HTTPClient:: generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { HTTPAuthorization::AuthenticationSchemes schemes; @@ -1536,15 +1377,15 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { } if (auth == (HTTPAuthorization *)NULL || !auth->is_valid()) { - downloader_cat.warning() + downloader_cat.warning() << "Don't know how to use any of the server's available authorization schemes:\n"; for (si = schemes.begin(); si != schemes.end(); ++si) { downloader_cat.warning() << (*si).first << "\n"; } } else { - // Now that we've got an authorization, store it under under each - // of its suggested domains for future use. + // Now that we've got an authorization, store it under under each of its + // suggested domains for future use. Domains &domains = is_proxy ? _proxy_domains : _www_domains; const vector_string &domain = auth->get_domain(); vector_string::const_iterator si; @@ -1556,13 +1397,10 @@ generate_auth(const URLSpec &url, bool is_proxy, const string &challenge) { return auth; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::unload_client_certificate -// Access: Private -// Description: Frees the resources allocated by a previous call to -// load_client_certificate(), and marks the certificate -// unloaded. -//////////////////////////////////////////////////////////////////// +/** + * Frees the resources allocated by a previous call to + * load_client_certificate(), and marks the certificate unloaded. + */ void HTTPClient:: unload_client_certificate() { if (_client_certificate_priv != (EVP_PKEY *)NULL) { @@ -1578,14 +1416,10 @@ unload_client_certificate() { _client_certificate_loaded = false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::parse_x509_name -// Access: Private, Static -// Description: Parses a string of the form -// /type0=value0/type1=value1/type2=... into a newly -// allocated X509_NAME object. Returns NULL if the -// string is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Parses a string of the form type0=value0/type1=value1/type2=... into a + * newly allocated X509_NAME object. Returns NULL if the string is invalid. + */ X509_NAME *HTTPClient:: parse_x509_name(const string &source) { X509_NAME *result = NULL; @@ -1624,7 +1458,7 @@ parse_x509_name(const string &source) { } string value; - + if (si != source.end() && (*si) == '=') { ++si; while (si != source.end() && (*si) != '/') { @@ -1643,7 +1477,7 @@ parse_x509_name(const string &source) { if (!value.empty()) { int add_result = - X509_NAME_add_entry_by_NID(result, nid, V_ASN1_APP_CHOOSE, + X509_NAME_add_entry_by_NID(result, nid, V_ASN1_APP_CHOOSE, (unsigned char *)value.c_str(), -1, -1, 0); if (!add_result) { downloader_cat.info() @@ -1667,13 +1501,10 @@ parse_x509_name(const string &source) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::x509_name_subset -// Access: Private, Static -// Description: Returns true if name_a is a subset of name_b: each -// property of name_a is defined in name_b, and the -// defined value is equivalent to that of name_a. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if name_a is a subset of name_b: each property of name_a is + * defined in name_b, and the defined value is equivalent to that of name_a. + */ bool HTTPClient:: x509_name_subset(X509_NAME *name_a, X509_NAME *name_b) { int count_a = X509_NAME_entry_count(name_a); @@ -1696,12 +1527,9 @@ x509_name_subset(X509_NAME *name_a, X509_NAME *name_b) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::split_whitespace -// Access: Private, Static -// Description: Puts the first word of c into a, and the remainder -// into b. -//////////////////////////////////////////////////////////////////// +/** + * Puts the first word of c into a, and the remainder into b. + */ void HTTPClient:: split_whitespace(string &a, string &b, const string &c) { size_t p = 0; @@ -1727,12 +1555,10 @@ split_whitespace(string &a, string &b, const string &c) { } #if defined(SSL_097) && !defined(NDEBUG) -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::ssl_msg_callback -// Access: Private, Static -// Description: This method is attached as a callback for SSL -// messages only when debug output is enabled. -//////////////////////////////////////////////////////////////////// +/** + * This method is attached as a callback for SSL messages only when debug + * output is enabled. + */ void HTTPClient:: ssl_msg_callback(int write_p, int version, int content_type, const void *, size_t len, SSL *, void *) { @@ -1751,7 +1577,7 @@ ssl_msg_callback(int write_p, int version, int content_type, describe << "SSL 3.0 "; break; - case TLS1_VERSION: + case TLS1_VERSION: describe << "TLS 1.0 "; break; @@ -1766,19 +1592,19 @@ ssl_msg_callback(int write_p, int version, int content_type, case 20: describe << "change cipher spec, "; break; - + case 21: describe << "alert, "; break; - + case 22: describe << "handshake, "; break; - + case 23: describe << "application data, "; break; - + default: describe << "unknown content type, "; } @@ -1790,11 +1616,9 @@ ssl_msg_callback(int write_p, int version, int content_type, } #endif // defined(SSL_097) && !defined(NDEBUG) -//////////////////////////////////////////////////////////////////// -// Function: HTTPClient::PreapprovedServerCert::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPClient::PreapprovedServerCert:: ~PreapprovedServerCert() { ServerCerts::const_iterator sci; diff --git a/panda/src/downloader/httpClient.h b/panda/src/downloader/httpClient.h index cabc03c924..32f9d38a7b 100644 --- a/panda/src/downloader/httpClient.h +++ b/panda/src/downloader/httpClient.h @@ -1,26 +1,24 @@ -// Filename: httpClient.h -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpClient.h + * @author drose + * @date 2002-09-24 + */ #ifndef HTTPCLIENT_H #define HTTPCLIENT_H #include "pandabase.h" -// This module requires OpenSSL to compile, even if you do not intend -// to use this to establish https connections; this is because it uses -// the OpenSSL library to portably handle all of the socket -// communications. +// This module requires OpenSSL to compile, even if you do not intend to use +// this to establish https connections; this is because it uses the OpenSSL +// library to portably handle all of the socket communications. #ifdef HAVE_OPENSSL @@ -39,21 +37,18 @@ class Filename; class HTTPChannel; -//////////////////////////////////////////////////////////////////// -// Class : HTTPClient -// Description : Handles contacting an HTTP server and retrieving a -// document. Each HTTPClient object represents a -// separate context, and stores its own list of cookies, -// passwords, and certificates; however, a given -// HTTPClient is capable of making multiple simultaneous -// requests to the same or different servers. -// -// It is up to the programmer whether one HTTPClient -// should be used to retrieve all documents, or a -// separate one should be created each time. There is a -// default, global HTTPClient available in -// HTTPClient::get_global_ptr(). -//////////////////////////////////////////////////////////////////// +/** + * Handles contacting an HTTP server and retrieving a document. Each + * HTTPClient object represents a separate context, and stores its own list of + * cookies, passwords, and certificates; however, a given HTTPClient is + * capable of making multiple simultaneous requests to the same or different + * servers. + * + * It is up to the programmer whether one HTTPClient should be used to + * retrieve all documents, or a separate one should be created each time. + * There is a default, global HTTPClient available in + * HTTPClient::get_global_ptr(). + */ class EXPCL_PANDAEXPRESS HTTPClient : public ReferenceCount { PUBLISHED: HTTPClient(); @@ -91,7 +86,7 @@ PUBLISHED: void write_cookies(ostream &out) const; void send_cookies(ostream &out, const URLSpec &url); - + INLINE void set_client_certificate_filename(const Filename &filename); INLINE void set_client_certificate_pem(const string &pem); INLINE void set_client_certificate_passphrase(const string &passphrase); @@ -141,11 +136,11 @@ private: void check_preapproved_server_certificate(const URLSpec &url, X509 *cert, bool &cert_preapproved, bool &cert_name_preapproved) const; - bool get_proxies_for_scheme(const string &scheme, + bool get_proxies_for_scheme(const string &scheme, pvector &proxies) const; void add_http_username(const string &http_username); - string select_username(const URLSpec &url, bool is_proxy, + string select_username(const URLSpec &url, bool is_proxy, const string &realm) const; HTTPAuthorization *select_auth(const URLSpec &url, bool is_proxy, @@ -224,4 +219,3 @@ private: #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/httpCookie.I b/panda/src/downloader/httpCookie.I index 293723c1bf..163e34652d 100644 --- a/panda/src/downloader/httpCookie.I +++ b/panda/src/downloader/httpCookie.I @@ -1,50 +1,40 @@ -// Filename: httpCookie.I -// Created by: drose (26Aug04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpCookie.I + * @author drose + * @date 2004-08-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::Constructor -// Access: Published -// Description: Constructs an empty cookie. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty cookie. + */ INLINE HTTPCookie:: HTTPCookie() : _secure(false) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::Constructor -// Access: Published -// Description: Constructs a cookie according to the indicated -// string, presumably the tag of a Set-Cookie header. -// There is no way to detect a formatting error in the -// string with this constructor. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a cookie according to the indicated string, presumably the tag + * of a Set-Cookie header. There is no way to detect a formatting error in + * the string with this constructor. + */ INLINE HTTPCookie:: HTTPCookie(const string &format, const URLSpec &url) { parse_set_cookie(format, url); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::Constructor -// Access: Published -// Description: Constructs a cookie with the indicated name, path, -// and domain values, but no other data. This is most -// useful for looking up an existing cookie in the -// HTTPClient. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a cookie with the indicated name, path, and domain values, but + * no other data. This is most useful for looking up an existing cookie in + * the HTTPClient. + */ INLINE HTTPCookie:: HTTPCookie(const string &name, const string &path, const string &domain) : _name(name), @@ -54,169 +44,134 @@ HTTPCookie(const string &name, const string &path, const string &domain) : { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPCookie:: ~HTTPCookie() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_name -// Access: Published -// Description: Returns the name of the cookie. This is the key -// value specified by the server. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the cookie. This is the key value specified by the + * server. + */ INLINE const string &HTTPCookie:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_value(const string &value) { _value = value; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_value -// Access: Published -// Description: Returns the value of the cookie. This is the -// arbitrary string associated with the cookie's name, -// as specified by the server. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the cookie. This is the arbitrary string associated + * with the cookie's name, as specified by the server. + */ INLINE const string &HTTPCookie:: get_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_domain -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_domain(const string &domain) { _domain = domain; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_domain -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &HTTPCookie:: get_domain() const { return _domain; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_path -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_path(const string &path) { _path = path; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_path -// Access: Published -// Description: Returns the prefix of the URL paths on the server for -// which this cookie will be sent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix of the URL paths on the server for which this cookie + * will be sent. + */ INLINE const string &HTTPCookie:: get_path() const { return _path; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_expires -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_expires(const HTTPDate &expires) { _expires = expires; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::clear_expires -// Access: Published -// Description: Removes the expiration date on the cookie. -//////////////////////////////////////////////////////////////////// +/** + * Removes the expiration date on the cookie. + */ INLINE void HTTPCookie:: clear_expires() { _expires = HTTPDate(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::has_expires -// Access: Published -// Description: Returns true if the cookie has an expiration date, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cookie has an expiration date, false otherwise. + */ INLINE bool HTTPCookie:: has_expires() const { return _expires.is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_expires -// Access: Published -// Description: Returns the expiration date of the cookie if it is -// set, or an invalid date if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the expiration date of the cookie if it is set, or an invalid date + * if it is not. + */ INLINE HTTPDate HTTPCookie:: get_expires() const { return _expires; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::set_secure -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPCookie:: set_secure(bool secure) { _secure = secure; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::get_secure -// Access: Published -// Description: Returns true if the server has indicated this is a -// "secure" cookie which should only be sent over an -// HTTPS channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the server has indicated this is a "secure" cookie which + * should only be sent over an HTTPS channel. + */ INLINE bool HTTPCookie:: get_secure() const { return _secure; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::is_expired -// Access: Published -// Description: Returns true if the cookie's expiration date is -// before the indicated date, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cookie's expiration date is before the indicated date, + * false otherwise. + */ INLINE bool HTTPCookie:: is_expired(const HTTPDate &now) const { return _expires.is_valid() && _expires < now; diff --git a/panda/src/downloader/httpCookie.cxx b/panda/src/downloader/httpCookie.cxx index c237760e64..cbe095cd8d 100644 --- a/panda/src/downloader/httpCookie.cxx +++ b/panda/src/downloader/httpCookie.cxx @@ -1,16 +1,15 @@ -// Filename: httpCookie.cxx -// Created by: drose (26Aug04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpCookie.cxx + * @author drose + * @date 2004-08-26 + */ #include "httpCookie.h" @@ -19,13 +18,11 @@ #include "ctype.h" #include "httpChannel.h" -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::operator < -// Access: Published -// Description: The sorting operator allows the cookies to be stored -// in a single dictionary; it returns nonequal only if -// the cookies are different in name, path, or domain. -//////////////////////////////////////////////////////////////////// +/** + * The sorting operator allows the cookies to be stored in a single + * dictionary; it returns nonequal only if the cookies are different in name, + * path, or domain. + */ bool HTTPCookie:: operator < (const HTTPCookie &other) const { if (_domain != other._domain) { @@ -33,9 +30,8 @@ operator < (const HTTPCookie &other) const { } if (_path != other._path) { - // We use reverse sorting on the path, so that cookies with longer - // paths will be sent to the server before cookies with shorter - // paths. + // We use reverse sorting on the path, so that cookies with longer paths + // will be sent to the server before cookies with shorter paths. return _path > other._path; } @@ -46,17 +42,13 @@ operator < (const HTTPCookie &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::update_from -// Access: Published -// Description: Assuming the operator < method, above, has already -// evaluated these two cookies as equal, then assign the -// remaining values (value, expiration date, secure -// flag) from the indicated cookie. This is guaranteed -// not to change the ordering of the cookie in a set, -// and so can be used to update an existing cookie -// within a set with new values. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the operator < method, above, has already evaluated these two + * cookies as equal, then assign the remaining values (value, expiration date, + * secure flag) from the indicated cookie. This is guaranteed not to change + * the ordering of the cookie in a set, and so can be used to update an + * existing cookie within a set with new values. + */ void HTTPCookie:: update_from(const HTTPCookie &other) { nassertv(!(other < *this) && !(*this < other)); @@ -66,15 +58,11 @@ update_from(const HTTPCookie &other) { _secure = other._secure; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::parse_set_cookie -// Access: Published -// Description: Separates out the parameter/value pairs of the -// Set-Cookie header and assigns the values of the -// cookie appropriate. Returns true if the header is -// parsed correctly, false if something is not -// understood. -//////////////////////////////////////////////////////////////////// +/** + * Separates out the parameter/value pairs of the Set-Cookie header and + * assigns the values of the cookie appropriate. Returns true if the header + * is parsed correctly, false if something is not understood. + */ bool HTTPCookie:: parse_set_cookie(const string &format, const URLSpec &url) { _name = string(); @@ -86,7 +74,7 @@ parse_set_cookie(const string &format, const URLSpec &url) { bool okflag = true; bool first_param = true; - + size_t start = 0; while (start < format.length() && isspace(format[start])) { start++; @@ -94,7 +82,7 @@ parse_set_cookie(const string &format, const URLSpec &url) { size_t semicolon = format.find(';', start); while (semicolon != string::npos) { - if (!parse_cookie_param(format.substr(start, semicolon - start), + if (!parse_cookie_param(format.substr(start, semicolon - start), first_param)) { okflag = false; } @@ -113,19 +101,17 @@ parse_set_cookie(const string &format, const URLSpec &url) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::matches_url -// Access: Published -// Description: Returns true if the cookie is appropriate to send -// with the indicated URL request, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cookie is appropriate to send with the indicated URL + * request, false otherwise. + */ bool HTTPCookie:: matches_url(const URLSpec &url) const { if (_domain.empty()) { return false; } string server = url.get_server(); - if (server == _domain || + if (server == _domain || (string(".") + server) == _domain || (server.length() > _domain.length() && server.substr(server.length() - _domain.length()) == _domain && @@ -149,11 +135,9 @@ matches_url(const URLSpec &url) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void HTTPCookie:: output(ostream &out) const { out << _name << "=" << _value @@ -162,21 +146,18 @@ output(ostream &out) const { if (has_expires()) { out << "; expires=" << _expires; } - + if (_secure) { out << "; secure"; } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPCookie::parse_cookie_param -// Access: Private -// Description: Called internally by parse_set_cookie() with each -// parameter=value pair split out from the header -// string. first_param will be true for the first -// parameter (which has special meaning). This should -// return true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Called internally by parse_set_cookie() with each parameter=value pair + * split out from the header string. first_param will be true for the first + * parameter (which has special meaning). This should return true on success, + * false on failure. + */ bool HTTPCookie:: parse_cookie_param(const string ¶m, bool first_param) { size_t equals = param.find('='); @@ -207,8 +188,8 @@ parse_cookie_param(const string ¶m, bool first_param) { } else if (key == "domain") { _domain = HTTPChannel::downcase(value); - // From RFC 2965: If an explicitly specified value does not - // start with a dot, the user agent supplies a leading dot. + // From RFC 2965: If an explicitly specified value does not start with a + // dot, the user agent supplies a leading dot. if (!_domain.empty() && _domain[0] != '.') { _domain = string(".") + _domain; } diff --git a/panda/src/downloader/httpCookie.h b/panda/src/downloader/httpCookie.h index 3b43f06b15..5a458f9af2 100644 --- a/panda/src/downloader/httpCookie.h +++ b/panda/src/downloader/httpCookie.h @@ -1,38 +1,34 @@ -// Filename: httpCookie.h -// Created by: drose (26Aug04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpCookie.h + * @author drose + * @date 2004-08-26 + */ #ifndef HTTPCOOKIE_H #define HTTPCOOKIE_H #include "pandabase.h" -// This module requires OpenSSL to compile, even if you do not intend -// to use this to establish https connections; this is because it uses -// the OpenSSL library to portably handle all of the socket -// communications. +// This module requires OpenSSL to compile, even if you do not intend to use +// this to establish https connections; this is because it uses the OpenSSL +// library to portably handle all of the socket communications. #ifdef HAVE_OPENSSL #include "httpDate.h" #include "urlSpec.h" -//////////////////////////////////////////////////////////////////// -// Class : HTTPCookie -// Description : A cookie sent from an HTTP server to be stored on the -// client and returned when the path and/or domain -// matches. -//////////////////////////////////////////////////////////////////// +/** + * A cookie sent from an HTTP server to be stored on the client and returned + * when the path and/or domain matches. + */ class EXPCL_PANDAEXPRESS HTTPCookie { PUBLISHED: INLINE HTTPCookie(); diff --git a/panda/src/downloader/httpDate.I b/panda/src/downloader/httpDate.I index 2b876e67bf..9b5adbefe4 100644 --- a/panda/src/downloader/httpDate.I +++ b/panda/src/downloader/httpDate.I @@ -1,185 +1,146 @@ -// Filename: httpDate.I -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDate.I + * @author drose + * @date 2003-01-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPDate:: HTTPDate() : _time(-1) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPDate:: HTTPDate(time_t time) : _time(time) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPDate:: HTTPDate(const HTTPDate ©) : _time(copy._time) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPDate:: operator = (const HTTPDate ©) { _time = copy._time; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::now (named constructor) -// Access: Published, Static -// Description: Returns an HTTPDate that represents the current time -// and date. -//////////////////////////////////////////////////////////////////// +/** + * Returns an HTTPDate that represents the current time and date. + */ INLINE HTTPDate HTTPDate:: now() { return HTTPDate(time(NULL)); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::is_valid -// Access: Published -// Description: Returns true if the date is meaningful, or false if -// it is -1 (which generally indicates the source string -// could not be parsed.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the date is meaningful, or false if it is -1 (which + * generally indicates the source string could not be parsed.) + */ INLINE bool HTTPDate:: is_valid() const { return (_time != (time_t)(-1)); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::get_time -// Access: Published -// Description: Returns the date as a C time_t value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the date as a C time_t value. + */ INLINE time_t HTTPDate:: get_time() const { return _time; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPDate:: operator == (const HTTPDate &other) const { return _time == other._time; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPDate:: operator != (const HTTPDate &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPDate:: operator < (const HTTPDate &other) const { return _time < other._time; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Operator > -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPDate:: operator > (const HTTPDate &other) const { return _time > other._time; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::compare_to -// Access: Published -// Description: Returns a number less than zero if this HTTPDate -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this HTTPDate sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + */ INLINE int HTTPDate:: compare_to(const HTTPDate &other) const { return (int)(_time - other._time); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::operator += -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPDate:: operator += (int seconds) { _time += seconds; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::operator -= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPDate:: operator -= (int seconds) { _time -= seconds; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::operator + -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPDate HTTPDate:: operator + (int seconds) const { return HTTPDate(_time + seconds); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::operator - -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPDate HTTPDate:: operator - (int seconds) const { return HTTPDate(_time - seconds); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::operator - -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int HTTPDate:: operator - (const HTTPDate &other) const { return (int)(_time - other._time); @@ -199,5 +160,3 @@ operator << (ostream &out, const HTTPDate &date) { date.output(out); return out; } - - diff --git a/panda/src/downloader/httpDate.cxx b/panda/src/downloader/httpDate.cxx index 726306e8ae..e2df9d1530 100644 --- a/panda/src/downloader/httpDate.cxx +++ b/panda/src/downloader/httpDate.cxx @@ -1,16 +1,15 @@ -// Filename: httpDate.cxx -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDate.cxx + * @author drose + * @date 2003-01-28 + */ #include "httpDate.h" @@ -28,13 +27,10 @@ static const char * const months[num_months] = { }; -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::Constructor -// Access: Published -// Description: Decodes the string into a sensible date. Returns 0 -// (!is_valid()) if the string cannot be correctly -// decoded. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the string into a sensible date. Returns 0 (!is_valid()) if the + * string cannot be correctly decoded. + */ HTTPDate:: HTTPDate(const string &format) { _time = (time_t)(-1); @@ -50,7 +46,7 @@ HTTPDate(const string &format) { bool got_minute = false; bool got_second = false; - enum ExpectNext { + enum ExpectNext { EN_none, EN_second, EN_year @@ -71,7 +67,7 @@ HTTPDate(const string &format) { if (!got_hour) { t.tm_hour = value; got_hour = true; - + } else if (!got_minute) { t.tm_min = value; got_minute = true; @@ -82,11 +78,11 @@ HTTPDate(const string &format) { } } else if (token[token.length() - 1] == '/') { - // If it ends in a colon, it must be mm/dd/. + // If it ends in a colon, it must be mmdd. if (!got_month) { t.tm_mon = value - 1; got_month = true; - + } else if (!got_day) { t.tm_mday = value; got_day = true; @@ -103,32 +99,32 @@ HTTPDate(const string &format) { got_second = true; } else if (expected == EN_year) { - // The first number following mm/dd/ is always the year. + // The first number following mmdd is always the year. t.tm_year = value; got_year = true; - + } else if (!got_day) { // Assume it's a day. t.tm_mday = value; got_day = true; - + } else if (!got_year) { // It must be the year. t.tm_year = value; got_year = true; - + } else if (!got_hour) { t.tm_hour = value; got_hour = true; - + } else if (!got_minute) { t.tm_min = value; got_minute = true; - + } else if (!got_second) { t.tm_sec = value; got_second = true; - + } else { // Huh, an unexpected numeric value. return; @@ -136,9 +132,9 @@ HTTPDate(const string &format) { } } else { - // This is a string token. It should be either a month name or - // a day name, or a timezone name--but the only timezone name we - // expect to see is "GMT". + // This is a string token. It should be either a month name or a day + // name, or a timezone name--but the only timezone name we expect to see + // is "GMT". bool matched = false; int i; @@ -184,23 +180,23 @@ HTTPDate(const string &format) { // Also validate the tokens we did get. if (t.tm_year < 100) { - // Two-digit year. Assume it's in the same century, unless - // that assumption puts it more than 50 years in the future. + // Two-digit year. Assume it's in the same century, unless that + // assumption puts it more than 50 years in the future. time_t now = time(NULL); struct tm *tp = gmtime(&now); t.tm_year += 100 * (tp->tm_year / 100); if (t.tm_year - tp->tm_year > 50) { t.tm_year -= 100; } - + } else if (t.tm_year < 1900) { // Invalid three- or four-digit year. Give up. return; - + } else { t.tm_year -= 1900; } - + if (!((t.tm_mon >= 0 && t.tm_mon < num_months) && (t.tm_mday >= 1 && t.tm_mday <= 31) && (t.tm_hour >= 0 && t.tm_hour < 60) && @@ -209,9 +205,9 @@ HTTPDate(const string &format) { return; } - // Everything checks out; convert the date. - // rdb made this an #if 0 check as timegm is a nonstandard extension - // so it fails in some situations even if the compiler defines __GNUC__ + // Everything checks out; convert the date. rdb made this an if 0 check as + // timegm is a nonstandard extension so it fails in some situations even if + // the compiler defines __GNUC__ #if 0 _time = timegm(&t); @@ -221,8 +217,7 @@ HTTPDate(const string &format) { _time = mktime(&t); if (_time != (time_t)-1) { - // Unfortunately, mktime() assumes local time; convert this back - // to GMT. + // Unfortunately, mktime() assumes local time; convert this back to GMT. #if defined(IS_FREEBSD) time_t now = time(NULL); struct tm *tp = localtime(&now); @@ -238,11 +233,9 @@ HTTPDate(const string &format) { #endif // __GNUC__ } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::get_string -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string HTTPDate:: get_string() const { if (!is_valid()) { @@ -253,7 +246,7 @@ get_string() const { ostringstream result; result - << weekdays[tp->tm_wday] << ", " + << weekdays[tp->tm_wday] << ", " << setw(2) << setfill('0') << tp->tm_mday << " " << months[tp->tm_mon] << " " << setw(4) << setfill('0') << tp->tm_year + 1900 << " " @@ -265,11 +258,9 @@ get_string() const { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool HTTPDate:: input(istream &in) { (*this) = HTTPDate(); @@ -298,34 +289,27 @@ input(istream &in) { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void HTTPDate:: output(ostream &out) const { - // We put quotes around the string on output, so we can reliably - // detect the end of the date string on input, above. + // We put quotes around the string on output, so we can reliably detect the + // end of the date string on input, above. out << '"' << get_string() << '"'; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDate::get_token -// Access: Published -// Description: Extracts the next token from the string starting at -// the indicated position. Returns the token and -// updates pos. When the last token has been extracted, -// returns empty string. -// -// A token is defined as a contiguous sequence of digits -// or letters. If it is a sequence of letters, the -// function quietly truncates it to three letters before -// returning, and forces the first letter to capital and -// the second two to lowercase. If it is a sequence of -// digits, the function also returns the next character -// following the last digit (unless it is a letter). -//////////////////////////////////////////////////////////////////// +/** + * Extracts the next token from the string starting at the indicated position. + * Returns the token and updates pos. When the last token has been extracted, + * returns empty string. + * + * A token is defined as a contiguous sequence of digits or letters. If it is + * a sequence of letters, the function quietly truncates it to three letters + * before returning, and forces the first letter to capital and the second two + * to lowercase. If it is a sequence of digits, the function also returns the + * next character following the last digit (unless it is a letter). + */ string HTTPDate:: get_token(const string &str, size_t &pos) { // Start by scanning for the first alphanumeric character. diff --git a/panda/src/downloader/httpDate.h b/panda/src/downloader/httpDate.h index 8158426720..9d6011336a 100644 --- a/panda/src/downloader/httpDate.h +++ b/panda/src/downloader/httpDate.h @@ -1,16 +1,15 @@ -// Filename: httpDate.h -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDate.h + * @author drose + * @date 2003-01-28 + */ #ifndef HTTPDATE_H #define HTTPDATE_H @@ -19,14 +18,12 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : HTTPDate -// Description : A container for an HTTP-legal time/date indication. -// This can accept a string from an HTTP header and will -// decode it into a C time_t value; conversely, it can -// accept a time_t value and encode it for output as a -// string. -//////////////////////////////////////////////////////////////////// +/** + * A container for an HTTP-legal time/date indication. This can accept a + * string from an HTTP header and will decode it into a C time_t value; + * conversely, it can accept a time_t value and encode it for output as a + * string. + */ class EXPCL_PANDAEXPRESS HTTPDate { PUBLISHED: INLINE HTTPDate(); diff --git a/panda/src/downloader/httpDigestAuthorization.I b/panda/src/downloader/httpDigestAuthorization.I index 31f2d05333..ea181c336c 100644 --- a/panda/src/downloader/httpDigestAuthorization.I +++ b/panda/src/downloader/httpDigestAuthorization.I @@ -1,25 +1,20 @@ -// Filename: httpDigestAuthorization.I -// Created by: drose (25Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDigestAuthorization.I + * @author drose + * @date 2002-10-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::hexdigit -// Access: Private, Static -// Description: Returns the ASCII character corresponding to the -// hexadecimal representation of the indicated value, -// which must be 0 <= value <= 15. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ASCII character corresponding to the hexadecimal representation + * of the indicated value, which must be 0 <= value <= 15. + */ INLINE char HTTPDigestAuthorization:: hexdigit(int value) { return (value < 10) ? (value + '0') : (value - 10 + 'a'); diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index e00a92fac0..e8cddbb18b 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -1,16 +1,15 @@ -// Filename: httpDigestAuthorization.cxx -// Created by: drose (25Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDigestAuthorization.cxx + * @author drose + * @date 2002-10-25 + */ #include "httpDigestAuthorization.h" @@ -24,14 +23,12 @@ const string HTTPDigestAuthorization::_mechanism = "digest"; -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPDigestAuthorization:: -HTTPDigestAuthorization(const HTTPAuthorization::Tokens &tokens, - const URLSpec &url, bool is_proxy) : +HTTPDigestAuthorization(const HTTPAuthorization::Tokens &tokens, + const URLSpec &url, bool is_proxy) : HTTPAuthorization(tokens, url, is_proxy) { Tokens::const_iterator ti; @@ -89,53 +86,43 @@ HTTPDigestAuthorization(const HTTPAuthorization::Tokens &tokens, // Compute an arbitrary client nonce. ostringstream strm; - strm << time(NULL) << ":" << clock() << ":" + strm << time(NULL) << ":" << clock() << ":" << url.get_url() << ":Panda"; _cnonce = calc_md5(strm.str()); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HTTPDigestAuthorization:: ~HTTPDigestAuthorization() { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::is_valid -// Access: Public, Virtual -// Description: Returns true if the authorization challenge was -// correctly parsed and is usable, or false if there was -// some unsupported algorithm or some such requested by -// the server, rendering the challenge unmeetable. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the authorization challenge was correctly parsed and is + * usable, or false if there was some unsupported algorithm or some such + * requested by the server, rendering the challenge unmeetable. + */ bool HTTPDigestAuthorization:: is_valid() { return (_algorithm != A_unknown); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::get_mechanism -// Access: Public, Virtual -// Description: Returns the type of authorization mechanism, -// represented as a string, e.g. "digest". -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of authorization mechanism, represented as a string, e.g. + * "digest". + */ const string &HTTPDigestAuthorization:: get_mechanism() const { return _mechanism; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::generate -// Access: Public, Virtual -// Description: Generates a suitable authorization string to send -// to the server, based on the data stored within this -// object, for retrieving the indicated URL with the -// given username:password. -//////////////////////////////////////////////////////////////////// +/** + * Generates a suitable authorization string to send to the server, based on + * the data stored within this object, for retrieving the indicated URL with + * the given username:password. + */ string HTTPDigestAuthorization:: generate(HTTPEnum::Method method, const string &request_path, const string &username, const string &body) { @@ -169,13 +156,10 @@ generate(HTTPEnum::Method method, const string &request_path, return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::match_qop_token -// Access: Private, Static -// Description: Returns the bitfield corresponding to the indicated -// qop token string, or 0 if the token string is -// unrecognized. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bitfield corresponding to the indicated qop token string, or 0 + * if the token string is unrecognized. + */ int HTTPDigestAuthorization:: match_qop_token(const string &token) { if (token == "auth") { @@ -186,15 +170,12 @@ match_qop_token(const string &token) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::calc_request_digest -// Access: Private -// Description: Calculates the appropriate digest response, according -// to RFC 2617. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the appropriate digest response, according to RFC 2617. + */ string HTTPDigestAuthorization:: calc_request_digest(const string &username, const string &password, - HTTPEnum::Method method, const string &request_path, + HTTPEnum::Method method, const string &request_path, const string &body) { _chosen_qop = Q_unused; string h_a1 = calc_h(get_a1(username, password)); @@ -215,12 +196,10 @@ calc_request_digest(const string &username, const string &password, return calc_kd(h_a1, strm.str()); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::calc_h -// Access: Private -// Description: Applies the specified checksum algorithm to the data, -// according to RFC 2617. -//////////////////////////////////////////////////////////////////// +/** + * Applies the specified checksum algorithm to the data, according to RFC + * 2617. + */ string HTTPDigestAuthorization:: calc_h(const string &data) const { switch (_algorithm) { @@ -233,13 +212,10 @@ calc_h(const string &data) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::calc_kd -// Access: Private -// Description: Applies the specified digest algorithm to the -// indicated data with the indicated secret, according -// to RFC 2617. -//////////////////////////////////////////////////////////////////// +/** + * Applies the specified digest algorithm to the indicated data with the + * indicated secret, according to RFC 2617. + */ string HTTPDigestAuthorization:: calc_kd(const string &secret, const string &data) const { switch (_algorithm) { @@ -252,11 +228,9 @@ calc_kd(const string &secret, const string &data) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::get_a1 -// Access: Private -// Description: Returns the A1 value, as defined by RFC 2617. -//////////////////////////////////////////////////////////////////// +/** + * Returns the A1 value, as defined by RFC 2617. + */ string HTTPDigestAuthorization:: get_a1(const string &username, const string &password) { switch (_algorithm) { @@ -275,11 +249,9 @@ get_a1(const string &username, const string &password) { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::get_a2 -// Access: Private -// Description: Returns the A2 value, as defined by RFC 2617. -//////////////////////////////////////////////////////////////////// +/** + * Returns the A2 value, as defined by RFC 2617. + */ string HTTPDigestAuthorization:: get_a2(HTTPEnum::Method method, const string &request_path, const string &body) { @@ -297,13 +269,11 @@ get_a2(HTTPEnum::Method method, const string &request_path, return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::get_hex_nonce_count -// Access: Private -// Description: Returns the current nonce count (the number of times -// we have used the server's nonce value, including this -// time) as an eight-digit hexadecimal value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current nonce count (the number of times we have used the + * server's nonce value, including this time) as an eight-digit hexadecimal + * value. + */ string HTTPDigestAuthorization:: get_hex_nonce_count() const { ostringstream strm; @@ -311,13 +281,10 @@ get_hex_nonce_count() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPDigestAuthorization::calc_md5 -// Access: Private, Static -// Description: Computes the MD5 of the indicated source string and -// returns it as a hexadecimal string of 32 ASCII -// characters. -//////////////////////////////////////////////////////////////////// +/** + * Computes the MD5 of the indicated source string and returns it as a + * hexadecimal string of 32 ASCII characters. + */ string HTTPDigestAuthorization:: calc_md5(const string &source) { unsigned char binary[MD5_DIGEST_LENGTH]; diff --git a/panda/src/downloader/httpDigestAuthorization.h b/panda/src/downloader/httpDigestAuthorization.h index bdd7b0136c..a3b8c7147a 100644 --- a/panda/src/downloader/httpDigestAuthorization.h +++ b/panda/src/downloader/httpDigestAuthorization.h @@ -1,37 +1,34 @@ -// Filename: httpDigestAuthorization.h -// Created by: drose (25Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpDigestAuthorization.h + * @author drose + * @date 2002-10-25 + */ #ifndef HTTPDIGESTAUTHORIZATION_H #define HTTPDIGESTAUTHORIZATION_H #include "pandabase.h" -// This module requires OpenSSL to compile, even though it doesn't -// actually use any OpenSSL code, because it is a support module for -// HTTPChannel, which *does* use OpenSSL code. +// This module requires OpenSSL to compile, even though it doesn't actually +// use any OpenSSL code, because it is a support module for HTTPChannel, which +// *does* use OpenSSL code. #ifdef HAVE_OPENSSL #include "httpAuthorization.h" -//////////////////////////////////////////////////////////////////// -// Class : HTTPDigestAuthorization -// Description : Implements the "Digest" type of HTTP authorization. -// This is designed to be an improvement over "Basic" -// authorization, in that it does not send passwords -// over the net in cleartext, and it is harder to spoof. -//////////////////////////////////////////////////////////////////// +/** + * Implements the "Digest" type of HTTP authorization. This is designed to be + * an improvement over "Basic" authorization, in that it does not send + * passwords over the net in cleartext, and it is harder to spoof. + */ class HTTPDigestAuthorization : public HTTPAuthorization { public: HTTPDigestAuthorization(const Tokens &tokens, const URLSpec &url, @@ -61,12 +58,12 @@ private: static int match_qop_token(const string &token); string calc_request_digest(const string &username, const string &password, - HTTPEnum::Method method, + HTTPEnum::Method method, const string &request_path, const string &body); string calc_h(const string &data) const; string calc_kd(const string &secret, const string &data) const; string get_a1(const string &username, const string &password); - string get_a2(HTTPEnum::Method method, const string &request_path, + string get_a2(HTTPEnum::Method method, const string &request_path, const string &body); string get_hex_nonce_count() const; @@ -95,4 +92,3 @@ ostream &operator << (ostream &out, HTTPDigestAuthorization::Qop qop); #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/httpEntityTag.I b/panda/src/downloader/httpEntityTag.I index 76ae597af6..d713302da2 100644 --- a/panda/src/downloader/httpEntityTag.I +++ b/panda/src/downloader/httpEntityTag.I @@ -1,34 +1,28 @@ -// Filename: httpEntityTag.I -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpEntityTag.I + * @author drose + * @date 2003-01-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPEntityTag:: HTTPEntityTag() { _weak = false; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Constructor -// Access: Published -// Description: This constructor accepts an explicit weak flag and a -// literal (not quoted) tag string. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts an explicit weak flag and a literal (not quoted) + * tag string. + */ INLINE HTTPEntityTag:: HTTPEntityTag(bool weak, const string &tag) : _weak(weak), @@ -36,102 +30,82 @@ HTTPEntityTag(bool weak, const string &tag) : { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HTTPEntityTag:: -HTTPEntityTag(const HTTPEntityTag ©) : +HTTPEntityTag(const HTTPEntityTag ©) : _weak(copy._weak), _tag(copy._tag) { } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPEntityTag:: operator = (const HTTPEntityTag ©) { _weak = copy._weak; _tag = copy._tag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::is_weak -// Access: Published -// Description: Returns true if the entity tag is marked as "weak". -// A consistent weak entity tag does not guarantee that -// its resource has not changed in any way, but it does -// promise that the resource has not changed in any -// semantically meaningful way. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entity tag is marked as "weak". A consistent weak + * entity tag does not guarantee that its resource has not changed in any way, + * but it does promise that the resource has not changed in any semantically + * meaningful way. + */ INLINE bool HTTPEntityTag:: is_weak() const { return _weak; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::get_tag -// Access: Published -// Description: Returns the tag as a literal string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tag as a literal string. + */ INLINE const string &HTTPEntityTag:: get_tag() const { return _tag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::strong_equiv -// Access: Published -// Description: Returns true if the two tags have "strong" equivalence: -// they are the same tag, and both are "strong". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two tags have "strong" equivalence: they are the same + * tag, and both are "strong". + */ INLINE bool HTTPEntityTag:: strong_equiv(const HTTPEntityTag &other) const { return _tag == other._tag && !_weak && !other._weak; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::weak_equiv -// Access: Published -// Description: Returns true if the two tags have "weak" equivalence: -// they are the same tag, and one or both may be "weak". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two tags have "weak" equivalence: they are the same + * tag, and one or both may be "weak". + */ INLINE bool HTTPEntityTag:: weak_equiv(const HTTPEntityTag &other) const { return _tag == other._tag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Operator == -// Access: Published -// Description: The == operator tests object equivalence; see also -// strong_equiv() and weak_equiv() for the two kinds of -// HTTP equivalence. -//////////////////////////////////////////////////////////////////// +/** + * The == operator tests object equivalence; see also strong_equiv() and + * weak_equiv() for the two kinds of HTTP equivalence. + */ INLINE bool HTTPEntityTag:: operator == (const HTTPEntityTag &other) const { return _weak == other._weak && _tag == other._tag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPEntityTag:: operator != (const HTTPEntityTag &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HTTPEntityTag:: operator < (const HTTPEntityTag &other) const { if (_weak != other._weak) { @@ -140,13 +114,11 @@ operator < (const HTTPEntityTag &other) const { return _tag < other._tag; } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::compare_to -// Access: Published -// Description: Returns a number less than zero if this HTTPEntityTag -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this HTTPEntityTag sorts before the + * other one, greater than zero if it sorts after, or zero if they are + * equivalent. + */ INLINE int HTTPEntityTag:: compare_to(const HTTPEntityTag &other) const { if (_weak != other._weak) { @@ -155,11 +127,9 @@ compare_to(const HTTPEntityTag &other) const { return strcmp(_tag.c_str(), other._tag.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HTTPEntityTag:: output(ostream &out) const { out << get_string(); @@ -171,5 +141,3 @@ operator << (ostream &out, const HTTPEntityTag &entityTag) { entityTag.output(out); return out; } - - diff --git a/panda/src/downloader/httpEntityTag.cxx b/panda/src/downloader/httpEntityTag.cxx index 0afe468f33..9c756024ee 100644 --- a/panda/src/downloader/httpEntityTag.cxx +++ b/panda/src/downloader/httpEntityTag.cxx @@ -1,27 +1,23 @@ -// Filename: httpEntityTag.cxx -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpEntityTag.cxx + * @author drose + * @date 2003-01-28 + */ #include "httpEntityTag.h" -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::Constructor -// Access: Published -// Description: This constructor accepts a string as formatted from -// an HTTP server (e.g. the tag is quoted, with an -// optional W/ prefix.) -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts a string as formatted from an HTTP server (e.g. + * the tag is quoted, with an optional W/ prefix.) + */ HTTPEntityTag:: HTTPEntityTag(const string &text) { _weak = false; @@ -50,13 +46,10 @@ HTTPEntityTag(const string &text) { } } -//////////////////////////////////////////////////////////////////// -// Function: HTTPEntityTag::get_string -// Access: Published -// Description: Returns the entity tag formatted for sending to an -// HTTP server (the tag is quoted, with a conditional W/ -// prefix). -//////////////////////////////////////////////////////////////////// +/** + * Returns the entity tag formatted for sending to an HTTP server (the tag is + * quoted, with a conditional W prefix). + */ string HTTPEntityTag:: get_string() const { ostringstream result; @@ -64,7 +57,7 @@ get_string() const { result << "W/"; } result << '"'; - + for (string::const_iterator ti = _tag.begin(); ti != _tag.end(); ++ti) { switch (*ti) { case '"': diff --git a/panda/src/downloader/httpEntityTag.h b/panda/src/downloader/httpEntityTag.h index 6e3ad6fb8b..280ce9d0c9 100644 --- a/panda/src/downloader/httpEntityTag.h +++ b/panda/src/downloader/httpEntityTag.h @@ -1,29 +1,26 @@ -// Filename: httpEntityTag.h -// Created by: drose (28Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpEntityTag.h + * @author drose + * @date 2003-01-28 + */ #ifndef HTTPENTITYTAG_H #define HTTPENTITYTAG_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : HTTPEntityTag -// Description : A container for an "entity tag" from an HTTP server. -// This is used to identify a particular version of a -// document or resource, particularly useful for -// verifying caches. -//////////////////////////////////////////////////////////////////// +/** + * A container for an "entity tag" from an HTTP server. This is used to + * identify a particular version of a document or resource, particularly + * useful for verifying caches. + */ class EXPCL_PANDAEXPRESS HTTPEntityTag { PUBLISHED: INLINE HTTPEntityTag(); diff --git a/panda/src/downloader/httpEnum.cxx b/panda/src/downloader/httpEnum.cxx index 3eda85890e..1ef09de254 100644 --- a/panda/src/downloader/httpEnum.cxx +++ b/panda/src/downloader/httpEnum.cxx @@ -1,25 +1,23 @@ -// Filename: httpEnum.cxx -// Created by: drose (25Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpEnum.cxx + * @author drose + * @date 2002-10-25 + */ #include "httpEnum.h" #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HTTPEnum::Method::output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, HTTPEnum::Method method) { switch (method) { diff --git a/panda/src/downloader/httpEnum.h b/panda/src/downloader/httpEnum.h index 319e223648..587c5b8b28 100644 --- a/panda/src/downloader/httpEnum.h +++ b/panda/src/downloader/httpEnum.h @@ -1,35 +1,31 @@ -// Filename: httpEnum.h -// Created by: drose (25Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file httpEnum.h + * @author drose + * @date 2002-10-25 + */ #ifndef HTTPENUM_H #define HTTPENUM_H #include "pandabase.h" -// This module requires OpenSSL to compile, even if you do not intend -// to use this to establish https connections; this is because it uses -// the OpenSSL library to portably handle all of the socket -// communications. +// This module requires OpenSSL to compile, even if you do not intend to use +// this to establish https connections; this is because it uses the OpenSSL +// library to portably handle all of the socket communications. #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Class : HTTPEnum -// Description : This class is just used as a namespace wrapper for -// some of the enumerated types used by various classes -// within the HTTPClient family. -//////////////////////////////////////////////////////////////////// +/** + * This class is just used as a namespace wrapper for some of the enumerated + * types used by various classes within the HTTPClient family. + */ class EXPCL_PANDAEXPRESS HTTPEnum { PUBLISHED: enum HTTPVersion { @@ -56,4 +52,3 @@ ostream &operator << (ostream &out, HTTPEnum::Method method); #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/identityStream.I b/panda/src/downloader/identityStream.I index dcaef1f8ca..4ef7e6e096 100644 --- a/panda/src/downloader/identityStream.I +++ b/panda/src/downloader/identityStream.I @@ -1,47 +1,39 @@ -// Filename: identityStream.I -// Created by: drose (09Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStream.I + * @author drose + * @date 2002-10-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IIdentityStream:: IIdentityStream() : ISocketStream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IIdentityStream:: IIdentityStream(BioStreamPtr *source, HTTPChannel *doc, - bool has_content_length, size_t content_length) : - ISocketStream(&_buf) + bool has_content_length, size_t content_length) : + ISocketStream(&_buf) { open(source, doc, has_content_length, content_length); } -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IIdentityStream &IIdentityStream:: -open(BioStreamPtr *source, HTTPChannel *doc, +open(BioStreamPtr *source, HTTPChannel *doc, bool has_content_length, size_t content_length) { clear((ios_iostate)0); _buf.open_read(source, doc, has_content_length, content_length); diff --git a/panda/src/downloader/identityStream.cxx b/panda/src/downloader/identityStream.cxx index ce78718426..f047ac1a6e 100644 --- a/panda/src/downloader/identityStream.cxx +++ b/panda/src/downloader/identityStream.cxx @@ -1,16 +1,15 @@ -// Filename: identityStream.cxx -// Created by: drose (09Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStream.cxx + * @author drose + * @date 2002-10-09 + */ #include "identityStream.h" @@ -18,11 +17,9 @@ #ifdef HAVE_OPENSSL #include "httpChannel.h" -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IIdentityStream:: ~IIdentityStream() { if (_channel != (HTTPChannel *)NULL) { @@ -31,16 +28,14 @@ IIdentityStream:: } } -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::is_closed -// Access: Public, Virtual -// Description: Returns true if the last eof condition was triggered -// because the socket has genuinely closed, or false if -// we can expect more data to come along shortly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last eof condition was triggered because the socket has + * genuinely closed, or false if we can expect more data to come along + * shortly. + */ bool IIdentityStream:: is_closed() { - if ((_buf._has_content_length && _buf._bytes_remaining == 0) || + if ((_buf._has_content_length && _buf._bytes_remaining == 0) || _buf.is_closed()) { return true; } @@ -48,23 +43,18 @@ is_closed() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::close -// Access: Public, Virtual -// Description: Resets the IdentityStream to empty, but does not actually -// close the source BIO unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the IdentityStream to empty, but does not actually close the source + * BIO unless owns_source was true. + */ void IIdentityStream:: close() { _buf.close_read(); } -//////////////////////////////////////////////////////////////////// -// Function: IIdentityStream::get_read_state -// Access: Public, Virtual -// Description: Returns an enum indicating how we are coming along in -// reading the document. -//////////////////////////////////////////////////////////////////// +/** + * Returns an enum indicating how we are coming along in reading the document. + */ INLINE IIdentityStream::ReadState IIdentityStream:: get_read_state() { return _buf.get_read_state(); diff --git a/panda/src/downloader/identityStream.h b/panda/src/downloader/identityStream.h index db95b1dd9f..ea071ec69f 100644 --- a/panda/src/downloader/identityStream.h +++ b/panda/src/downloader/identityStream.h @@ -1,16 +1,15 @@ -// Filename: identityStream.h -// Created by: drose (09Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStream.h + * @author drose + * @date 2002-10-09 + */ #ifndef IDENTITYSTREAM_H #define IDENTITYSTREAM_H @@ -26,20 +25,17 @@ class HTTPChannel; class BioStreamPtr; -//////////////////////////////////////////////////////////////////// -// Class : IIdentityStream -// Description : An input stream object that reads data from a source -// istream, but automatically decodes the "identity" -// transfer-coding specified by an HTTP server. -// -// In practice, this just means it reads from the sub -// stream (like a SubStreamBuf) up to but not past the -// specified content-length. (If the content-length was -// unspecified, this class cannot be used.) It also -// updates the HTTPChannel when the stream is -// completely read. -//////////////////////////////////////////////////////////////////// -// No need to export from DLL. +/** + * An input stream object that reads data from a source istream, but + * automatically decodes the "identity" transfer-coding specified by an HTTP + * server. + * + * In practice, this just means it reads from the sub stream (like a + * SubStreamBuf) up to but not past the specified content-length. (If the + * content-length was unspecified, this class cannot be used.) It also + * updates the HTTPChannel when the stream is completely read. No need to + * export from DLL. + */ class IIdentityStream : public ISocketStream { public: INLINE IIdentityStream(); @@ -63,5 +59,3 @@ private: #endif // HAVE_OPENSSL #endif - - diff --git a/panda/src/downloader/identityStreamBuf.I b/panda/src/downloader/identityStreamBuf.I index 629d2c5c4f..6001a14fc0 100644 --- a/panda/src/downloader/identityStreamBuf.I +++ b/panda/src/downloader/identityStreamBuf.I @@ -1,33 +1,27 @@ -// Filename: identityStreamBuf.I -// Created by: drose (14Nov06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStreamBuf.I + * @author drose + * @date 2006-11-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::is_closed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool IdentityStreamBuf:: is_closed() const { return (_source == (BioStreamPtr *)NULL || (*_source)->is_closed()); } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::get_read_state -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ISocketStream::ReadState IdentityStreamBuf:: get_read_state() const { return _read_state; diff --git a/panda/src/downloader/identityStreamBuf.cxx b/panda/src/downloader/identityStreamBuf.cxx index f4b2076291..a11f1cfda3 100644 --- a/panda/src/downloader/identityStreamBuf.cxx +++ b/panda/src/downloader/identityStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: identityStreamBuf.cxx -// Created by: drose (09Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStreamBuf.cxx + * @author drose + * @date 2002-10-09 + */ #include "identityStreamBuf.h" @@ -23,11 +22,9 @@ typedef int streamsize; #endif /* HAVE_STREAMSIZE */ -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IdentityStreamBuf:: IdentityStreamBuf() { _has_content_length = true; @@ -48,11 +45,9 @@ IdentityStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IdentityStreamBuf:: ~IdentityStreamBuf() { close_read(); @@ -61,13 +56,10 @@ IdentityStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::open_read -// Access: Public -// Description: If the document pointer is non-NULL, it will be -// updated with the length of the file as it is derived -// from the identity encoding. -//////////////////////////////////////////////////////////////////// +/** + * If the document pointer is non-NULL, it will be updated with the length of + * the file as it is derived from the identity encoding. + */ void IdentityStreamBuf:: open_read(BioStreamPtr *source, HTTPChannel *doc, bool has_content_length, size_t content_length) { @@ -78,22 +70,18 @@ open_read(BioStreamPtr *source, HTTPChannel *doc, _read_state = ISocketStream::RS_reading; } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::close_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IdentityStreamBuf:: close_read() { _source.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int IdentityStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -123,18 +111,15 @@ underflow() { } -//////////////////////////////////////////////////////////////////// -// Function: IdentityStreamBuf::read_chars -// Access: Private -// Description: Gets some characters from the source stream. -//////////////////////////////////////////////////////////////////// +/** + * Gets some characters from the source stream. + */ size_t IdentityStreamBuf:: read_chars(char *start, size_t length) { size_t read_count = 0; if (!_has_content_length) { - // If we have no restrictions on content length, read till end of - // file. + // If we have no restrictions on content length, read till end of file. (*_source)->read(start, length); read_count = (*_source)->gcount(); @@ -146,7 +131,7 @@ read_chars(char *start, size_t length) { read_count = (*_source)->gcount(); } } - + if (read_count == 0) { if ((*_source)->is_closed()) { // socket closed; we're done. @@ -173,7 +158,7 @@ read_chars(char *start, size_t length) { } nassertr(read_count <= _bytes_remaining, 0); _bytes_remaining -= read_count; - + if (read_count == 0) { if ((*_source)->is_closed()) { // socket closed unexpectedly; problem. @@ -182,7 +167,7 @@ read_chars(char *start, size_t length) { return 0; } } - + if (_bytes_remaining == 0) { // We're done. _read_state = ISocketStream::RS_complete; diff --git a/panda/src/downloader/identityStreamBuf.h b/panda/src/downloader/identityStreamBuf.h index b546f24e3e..f9d00a6626 100644 --- a/panda/src/downloader/identityStreamBuf.h +++ b/panda/src/downloader/identityStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: identityStreamBuf.h -// Created by: drose (09Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file identityStreamBuf.h + * @author drose + * @date 2002-10-09 + */ #ifndef IDENTITYSTREAMBUF_H #define IDENTITYSTREAMBUF_H @@ -26,11 +25,9 @@ class HTTPChannel; -//////////////////////////////////////////////////////////////////// -// Class : IdentityStreamBuf -// Description : The streambuf object that implements -// IIdentityStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements IIdentityStream. + */ class EXPCL_PANDAEXPRESS IdentityStreamBuf : public streambuf { public: IdentityStreamBuf(); diff --git a/panda/src/downloader/multiplexStream.I b/panda/src/downloader/multiplexStream.I index 3951c13f7d..1da8528d0b 100644 --- a/panda/src/downloader/multiplexStream.I +++ b/panda/src/downloader/multiplexStream.I @@ -1,34 +1,28 @@ -// Filename: multiplexStream.I -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStream.I + * @author drose + * @date 2000-11-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MultiplexStream:: MultiplexStream() : ostream(&_msb) { setf(ios::unitbuf); } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::add_ostream -// Access: Public -// Description: Adds the indicated generic ostream to the multiplex -// output. The ostream will receive whatever data is -// sent to the pipe. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated generic ostream to the multiplex output. The ostream + * will receive whatever data is sent to the pipe. + */ INLINE void MultiplexStream:: add_ostream(ostream *out, bool delete_later) { _msb.add_output(MultiplexStreamBuf::BT_none, @@ -36,12 +30,10 @@ add_ostream(ostream *out, bool delete_later) { out, NULL, delete_later); } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::add_stdio_file -// Access: Public -// Description: Adds the given file, previously opened using the C -// stdio library, to the multiplex output. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given file, previously opened using the C stdio library, to the + * multiplex output. + */ INLINE bool MultiplexStream:: add_stdio_file(FILE *fout, bool close_when_done) { _msb.add_output(MultiplexStreamBuf::BT_line, @@ -50,11 +42,9 @@ add_stdio_file(FILE *fout, bool close_when_done) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::add_standard_output -// Access: Public -// Description: Adds the standard output channel. -//////////////////////////////////////////////////////////////////// +/** + * Adds the standard output channel. + */ INLINE void MultiplexStream:: add_standard_output() { _msb.add_output(MultiplexStreamBuf::BT_none, @@ -62,13 +52,10 @@ add_standard_output() { &cout, NULL, false); } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::add_file -// Access: Public -// Description: Adds the given file to the multiplex output. The -// file is opened in append mode with line buffering. -// Returns false if the file cannot be opened. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given file to the multiplex output. The file is opened in append + * mode with line buffering. Returns false if the file cannot be opened. + */ INLINE bool MultiplexStream:: add_file(Filename file) { file.set_text(); @@ -85,28 +72,22 @@ add_file(Filename file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::add_system_debug -// Access: Public -// Description: Adds the system debug output the the multiplex -// output. This may map to a syslog or some such -// os-specific output system. It may do nothing on a -// particular system. -// -// Presently, this maps only to OutputDebugString() on -// Windows. -//////////////////////////////////////////////////////////////////// +/** + * Adds the system debug output the the multiplex output. This may map to a + * syslog or some such os-specific output system. It may do nothing on a + * particular system. + * + * Presently, this maps only to OutputDebugString() on Windows. + */ INLINE void MultiplexStream:: add_system_debug() { _msb.add_output(MultiplexStreamBuf::BT_line, MultiplexStreamBuf::OT_system_debug); } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStream::flush -// Access: Public -// Description: Forces out all output that hasn't yet been written. -//////////////////////////////////////////////////////////////////// +/** + * Forces out all output that hasn't yet been written. + */ INLINE void MultiplexStream:: flush() { _msb.flush(); diff --git a/panda/src/downloader/multiplexStream.cxx b/panda/src/downloader/multiplexStream.cxx index 967ba2093a..d6c84f57a0 100644 --- a/panda/src/downloader/multiplexStream.cxx +++ b/panda/src/downloader/multiplexStream.cxx @@ -1,16 +1,14 @@ -// Filename: multiplexStream.cxx -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStream.cxx + * @author drose + * @date 2000-11-27 + */ #include "multiplexStream.h" - diff --git a/panda/src/downloader/multiplexStream.h b/panda/src/downloader/multiplexStream.h index a82ed96233..cf421860cf 100644 --- a/panda/src/downloader/multiplexStream.h +++ b/panda/src/downloader/multiplexStream.h @@ -1,16 +1,15 @@ -// Filename: multiplexStream.h -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStream.h + * @author drose + * @date 2000-11-27 + */ #ifndef MULTIPLEXSTREAM_H #define MULTIPLEXSTREAM_H @@ -23,15 +22,12 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : MultiplexStream -// Description : This is a special ostream that forwards the data that -// is written to it to any number of other sources, for -// instance other ostreams, or explicitly to a disk file -// or to system logging utilities. It's a very handy -// thing to set Notify to refer to when running in batch -// mode. -//////////////////////////////////////////////////////////////////// +/** + * This is a special ostream that forwards the data that is written to it to + * any number of other sources, for instance other ostreams, or explicitly to + * a disk file or to system logging utilities. It's a very handy thing to set + * Notify to refer to when running in batch mode. + */ class EXPCL_PANDAEXPRESS MultiplexStream : public ostream { PUBLISHED: INLINE MultiplexStream(); diff --git a/panda/src/downloader/multiplexStreamBuf.I b/panda/src/downloader/multiplexStreamBuf.I index 221702cf5d..021cb17b5e 100644 --- a/panda/src/downloader/multiplexStreamBuf.I +++ b/panda/src/downloader/multiplexStreamBuf.I @@ -1,14 +1,12 @@ -// Filename: multiplexStreamBuf.I -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStreamBuf.I + * @author drose + * @date 2000-11-27 + */ diff --git a/panda/src/downloader/multiplexStreamBuf.cxx b/panda/src/downloader/multiplexStreamBuf.cxx index 33cfd03f44..e78eb1d838 100644 --- a/panda/src/downloader/multiplexStreamBuf.cxx +++ b/panda/src/downloader/multiplexStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: multiplexStreamBuf.cxx -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStreamBuf.cxx + * @author drose + * @date 2000-11-27 + */ #include "multiplexStreamBuf.h" @@ -20,9 +19,9 @@ #undef WINDOWS_LEAN_AND_MEAN #endif -// We use real assert() instead of nassert(), because we're likely -// to be invoked directly by pnotify.here, and we don't want to -// risk infinite recursion. +// We use real assert() instead of nassert(), because we're likely to be +// invoked directly by pnotify.here, and we don't want to risk infinite +// recursion. #include #ifndef HAVE_STREAMSIZE @@ -30,12 +29,9 @@ typedef int streamsize; #endif -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::Output::close -// Access: Public -// Description: Closes or deletes the relevant pointers, if _owns_obj -// is true. -//////////////////////////////////////////////////////////////////// +/** + * Closes or deletes the relevant pointers, if _owns_obj is true. + */ void MultiplexStreamBuf::Output:: close() { if (_owns_obj) { @@ -56,11 +52,9 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::Output::write_string -// Access: Public -// Description: Dumps the indicated string to the appropriate place. -//////////////////////////////////////////////////////////////////// +/** + * Dumps the indicated string to the appropriate place. + */ void MultiplexStreamBuf::Output:: write_string(const string &str) { switch (_output_type) { @@ -84,11 +78,9 @@ write_string(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MultiplexStreamBuf:: MultiplexStreamBuf() { #ifndef PHAVE_IOSTREAM @@ -98,11 +90,9 @@ MultiplexStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MultiplexStreamBuf:: ~MultiplexStreamBuf() { sync(); @@ -115,20 +105,16 @@ MultiplexStreamBuf:: } } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::add_output -// Access: Public -// Description: Adds the indicated output destinition to the set of -// things that will be written to when characters are -// output to the MultiplexStream. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated output destinition to the set of things that will be + * written to when characters are output to the MultiplexStream. + */ void MultiplexStreamBuf:: add_output(MultiplexStreamBuf::BufferType buffer_type, MultiplexStreamBuf::OutputType output_type, ostream *out, FILE *fout, bool owns_obj) { #ifdef OLD_HAVE_IPC - // Ensure that we have the mutex while we fiddle with the list of - // outputs. + // Ensure that we have the mutex while we fiddle with the list of outputs. mutex_lock m(_lock); #endif @@ -142,11 +128,9 @@ add_output(MultiplexStreamBuf::BufferType buffer_type, } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::flush -// Access: Public -// Description: Forces out all output that hasn't yet been written. -//////////////////////////////////////////////////////////////////// +/** + * Forces out all output that hasn't yet been written. + */ void MultiplexStreamBuf:: flush() { #ifdef OLD_HAVE_IPC @@ -156,12 +140,10 @@ flush() { write_chars("", 0, true); } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::overflow -// Access: Public, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int MultiplexStreamBuf:: overflow(int ch) { #ifdef OLD_HAVE_IPC @@ -184,13 +166,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::sync -// Access: Public, Virtual -// Description: Called by the system ostream implementation when the -// buffer should be flushed to output (for instance, on -// destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when the buffer should be + * flushed to output (for instance, on destruction). + */ int MultiplexStreamBuf:: sync() { #ifdef OLD_HAVE_IPC @@ -199,28 +178,25 @@ sync() { streamsize n = pptr() - pbase(); - // We pass in false for the flush value, even though our - // transmitting ostream said to sync. This allows us to get better - // line buffering, since our transmitting ostream is often set - // unitbuf, and might call sync multiple times in one line. We - // still have an explicit flush() call to force the issue. + // We pass in false for the flush value, even though our transmitting + // ostream said to sync. This allows us to get better line buffering, since + // our transmitting ostream is often set unitbuf, and might call sync + // multiple times in one line. We still have an explicit flush() call to + // force the issue. write_chars(pbase(), n, false); pbump(-n); return 0; // Return 0 for success, EOF to indicate write full. } -//////////////////////////////////////////////////////////////////// -// Function: MultiplexStreamBuf::write_chars -// Access: Private -// Description: An internal function called by sync() and overflow() -// to store one or more characters written to the stream -// into the memory buffer. -// -// It is assumed that there is only one thread at a time -// running this code; it is the responsibility of the -// caller to grab the _lock mutex before calling this. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by sync() and overflow() to store one or more + * characters written to the stream into the memory buffer. + * + * It is assumed that there is only one thread at a time running this code; it + * is the responsibility of the caller to grab the _lock mutex before calling + * this. + */ void MultiplexStreamBuf:: write_chars(const char *start, int length, bool flush) { size_t orig = _line_buffer.length(); @@ -231,14 +207,14 @@ write_chars(const char *start, int length, bool flush) { string line; if (flush) { - // If we're to flush the stream now, we dump the whole thing - // regardless of whether we have reached end-of-line. + // If we're to flush the stream now, we dump the whole thing regardless of + // whether we have reached end-of-line. line = _line_buffer + latest; _line_buffer = ""; } else { - // Otherwise, we check for the end-of-line character, for our - // ostreams that only want a complete line at a time. + // Otherwise, we check for the end-of-line character, for our ostreams + // that only want a complete line at a time. _line_buffer += latest; size_t eol = _line_buffer.rfind('\n', orig); if (eol != string::npos) { @@ -259,8 +235,7 @@ write_chars(const char *start, int length, bool flush) { break; case BT_line: - // Line buffering: send only when a complete line has been - // received. + // Line buffering: send only when a complete line has been received. if (!line.empty()) { out.write_string(line); } diff --git a/panda/src/downloader/multiplexStreamBuf.h b/panda/src/downloader/multiplexStreamBuf.h index b9385904fc..e2d0f589b5 100644 --- a/panda/src/downloader/multiplexStreamBuf.h +++ b/panda/src/downloader/multiplexStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: multiplexStreamBuf.h -// Created by: drose (27Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multiplexStreamBuf.h + * @author drose + * @date 2000-11-27 + */ #ifndef MULTIPLEXSTREAMBUF_H #define MULTIPLEXSTREAMBUF_H @@ -20,12 +19,10 @@ #include "pvector.h" #include -//////////////////////////////////////////////////////////////////// -// Class : MultiplexStreamBuf -// Description : Used by MultiplexStream to implement an ostream that -// sends what is written to it to any number of -// additional sources, like other ostreams. -//////////////////////////////////////////////////////////////////// +/** + * Used by MultiplexStream to implement an ostream that sends what is written + * to it to any number of additional sources, like other ostreams. + */ class EXPCL_PANDAEXPRESS MultiplexStreamBuf : public streambuf { public: MultiplexStreamBuf(); diff --git a/panda/src/downloader/patcher.I b/panda/src/downloader/patcher.I index 494375e3c2..90c97c783f 100644 --- a/panda/src/downloader/patcher.I +++ b/panda/src/downloader/patcher.I @@ -1,22 +1,19 @@ -// Filename: patcher.I -// Created by: darren (20Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patcher.I + * @author darren + * @date 2000-12-20 + */ -//////////////////////////////////////////////////////////////////// -// Function: Patcher::get_progress -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat Patcher:: get_progress() const { if(_patchfile) { diff --git a/panda/src/downloader/patcher.cxx b/panda/src/downloader/patcher.cxx index f688a413f6..70d0f99ef2 100644 --- a/panda/src/downloader/patcher.cxx +++ b/panda/src/downloader/patcher.cxx @@ -1,16 +1,15 @@ -// Filename: patcher.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patcher.cxx + * @author mike + * @date 1997-01-09 + */ #include "pandabase.h" @@ -20,32 +19,26 @@ #include "patcher.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Function: Patcher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Patcher:: Patcher() { PT(Buffer) buffer = new Buffer(patcher_buffer_size); init(buffer); } -//////////////////////////////////////////////////////////////////// -// Function: Patcher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Patcher:: Patcher(PT(Buffer) buffer) { init(buffer); } -//////////////////////////////////////////////////////////////////// -// Function: Patcher::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Patcher:: init(PT(Buffer) buffer) { nassertv(!buffer.is_null()); @@ -55,31 +48,25 @@ init(PT(Buffer) buffer) { _patchfile = new Patchfile(_buffer); } -//////////////////////////////////////////////////////////////////// -// Function: Patcher::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Patcher:: ~Patcher() { delete _patchfile; } -//////////////////////////////////////////////////////////////////// -// Function: Patcher::initiate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Patcher:: initiate(Filename &patch, Filename &infile) { return _patchfile->initiate(patch, infile); } -//////////////////////////////////////////////////////////////////// -// Function: Patcher::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Patcher:: run() { return _patchfile->run(); diff --git a/panda/src/downloader/patcher.h b/panda/src/downloader/patcher.h index 6404a17545..a480f079bb 100644 --- a/panda/src/downloader/patcher.h +++ b/panda/src/downloader/patcher.h @@ -1,16 +1,15 @@ -// Filename: patcher.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patcher.h + * @author mike + * @date 1997-01-09 + */ #ifndef PATCHER_H #define PATCHER_H @@ -23,10 +22,9 @@ #include "buffer.h" #include "patchfile.h" -//////////////////////////////////////////////////////////////////// -// Class : Patcher -// Description : Applies a patch synchronously -//////////////////////////////////////////////////////////////////// +/** + * Applies a patch synchronously + */ class EXPCL_PANDAEXPRESS Patcher { PUBLISHED: Patcher(); diff --git a/panda/src/downloader/socketStream.I b/panda/src/downloader/socketStream.I index ad70035e8a..21026ebdb4 100644 --- a/panda/src/downloader/socketStream.I +++ b/panda/src/downloader/socketStream.I @@ -1,27 +1,22 @@ -// Filename: socketStream.I -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStream.I + * @author drose + * @date 2002-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SSReader::receive_datagram -// Access: Published -// Description: Receives a datagram over the socket by expecting a -// little-endian 16-bit byte count as a prefix. If the -// socket stream is non-blocking, may return false if -// the data is not available; otherwise, returns false -// only if the socket closes. -//////////////////////////////////////////////////////////////////// +/** + * Receives a datagram over the socket by expecting a little-endian 16-bit + * byte count as a prefix. If the socket stream is non-blocking, may return + * false if the data is not available; otherwise, returns false only if the + * socket closes. + */ INLINE bool SSReader:: receive_datagram(Datagram &dg) { #ifdef SIMULATE_NETWORK_DELAY @@ -32,8 +27,8 @@ receive_datagram(Datagram &dg) { return get_delayed(dg); } - // Pick up any datagrams that might have been leftover in the queue - // when we disabled the delay. + // Pick up any datagrams that might have been leftover in the queue when we + // disabled the delay. if (get_delayed(dg)) { return true; } @@ -42,140 +37,107 @@ receive_datagram(Datagram &dg) { return do_receive_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: SSReader::set_tcp_header_size -// Access: Published -// Description: Sets the header size for datagrams. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size for datagrams. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ INLINE void SSReader:: set_tcp_header_size(int tcp_header_size) { nassertv(tcp_header_size == 0 || tcp_header_size == 2 || tcp_header_size == 4); _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: SSReader::get_tcp_header_size -// Access: Published -// Description: Returns the header size for datagrams. See -// set_tcp_header_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the header size for datagrams. See set_tcp_header_size(). + */ INLINE int SSReader:: get_tcp_header_size() const { return _tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::set_collect_tcp -// Access: Published -// Description: Enables or disables "collect-tcp" mode. In this -// mode, individual TCP packets are not sent -// immediately, but rather they are collected together -// and accumulated to be sent periodically as one larger -// TCP packet. This cuts down on overhead from the -// TCP/IP protocol, especially if many small packets -// need to be sent on the same connection, but it -// introduces additional latency (since packets must be -// held before they can be sent). -// -// See set_collect_tcp_interval() to specify the -// interval of time for which to hold packets before -// sending them. -// -// If you enable this mode, you may also need to -// periodically call consider_flush() to flush the queue -// if no packets have been sent recently. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables "collect-tcp" mode. In this mode, individual TCP + * packets are not sent immediately, but rather they are collected together + * and accumulated to be sent periodically as one larger TCP packet. This + * cuts down on overhead from the TCP/IP protocol, especially if many small + * packets need to be sent on the same connection, but it introduces + * additional latency (since packets must be held before they can be sent). + * + * See set_collect_tcp_interval() to specify the interval of time for which to + * hold packets before sending them. + * + * If you enable this mode, you may also need to periodically call + * consider_flush() to flush the queue if no packets have been sent recently. + */ INLINE void SSWriter:: set_collect_tcp(bool collect_tcp) { _collect_tcp = collect_tcp; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::get_collect_tcp -// Access: Published -// Description: Returns the current setting of "collect-tcp" mode. -// See set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of "collect-tcp" mode. See set_collect_tcp(). + */ INLINE bool SSWriter:: get_collect_tcp() const { return _collect_tcp; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::set_collect_tcp_interval -// Access: Published -// Description: Specifies the interval in time, in seconds, for which -// to hold TCP packets before sending all of the -// recently received packets at once. This only has -// meaning if "collect-tcp" mode is enabled; see -// set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the interval in time, in seconds, for which to hold TCP packets + * before sending all of the recently received packets at once. This only has + * meaning if "collect-tcp" mode is enabled; see set_collect_tcp(). + */ INLINE void SSWriter:: set_collect_tcp_interval(double interval) { _collect_tcp_interval = interval; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::get_collect_tcp_interval -// Access: Published -// Description: Returns the interval in time, in seconds, for which -// to hold TCP packets before sending all of the -// recently received packets at once. This only has -// meaning if "collect-tcp" mode is enabled; see -// set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval in time, in seconds, for which to hold TCP packets + * before sending all of the recently received packets at once. This only has + * meaning if "collect-tcp" mode is enabled; see set_collect_tcp(). + */ INLINE double SSWriter:: get_collect_tcp_interval() const { return _collect_tcp_interval; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::set_tcp_header_size -// Access: Published -// Description: Sets the header size for datagrams. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size for datagrams. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ INLINE void SSWriter:: set_tcp_header_size(int tcp_header_size) { nassertv(tcp_header_size == 0 || tcp_header_size == 2 || tcp_header_size == 4); _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::get_tcp_header_size -// Access: Published -// Description: Returns the header size for datagrams. See -// set_tcp_header_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the header size for datagrams. See set_tcp_header_size(). + */ INLINE int SSWriter:: get_tcp_header_size() const { return _tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::consider_flush -// Access: Published -// Description: Sends the most recently queued data if enough time -// has elapsed. This only has meaning if -// set_collect_tcp() has been set to true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data if enough time has elapsed. This only + * has meaning if set_collect_tcp() has been set to true. + */ INLINE bool SSWriter:: consider_flush() { if (!_collect_tcp) { return flush(); } else { - double elapsed = + double elapsed = TrueClock::get_global_ptr()->get_short_time() - _queued_data_start; - // If the elapsed time is negative, someone must have reset the - // clock back, so just go ahead and flush. + // If the elapsed time is negative, someone must have reset the clock + // back, so just go ahead and flush. if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) { return flush(); } @@ -184,13 +146,10 @@ consider_flush() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::flush -// Access: Published -// Description: Sends the most recently queued data now. This only -// has meaning if set_collect_tcp() has been set to -// true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data now. This only has meaning if + * set_collect_tcp() has been set to true. + */ INLINE bool SSWriter:: flush() { _ostream->flush(); @@ -198,79 +157,61 @@ flush() { return !is_closed(); } -//////////////////////////////////////////////////////////////////// -// Function: ISocketStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ISocketStream:: ISocketStream(streambuf *buf) : istream(buf), SSReader(this) { _channel = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: OSocketStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OSocketStream:: OSocketStream(streambuf *buf) : ostream(buf), SSWriter(this) { } -//////////////////////////////////////////////////////////////////// -// Function: OSocketStream::flush -// Access: Published -// Description: Sends the most recently queued data now. This only -// has meaning if set_collect_tcp() has been set to -// true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data now. This only has meaning if + * set_collect_tcp() has been set to true. + */ INLINE bool OSocketStream:: flush() { return SSWriter::flush(); } -//////////////////////////////////////////////////////////////////// -// Function: SocketStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SocketStream:: SocketStream(streambuf *buf) : iostream(buf), SSReader(this), SSWriter(this) { } -//////////////////////////////////////////////////////////////////// -// Function: SocketStream::set_tcp_header_size -// Access: Published -// Description: Sets the header size for datagrams. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size for datagrams. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ INLINE void SocketStream:: set_tcp_header_size(int tcp_header_size) { SSReader::set_tcp_header_size(tcp_header_size); SSWriter::set_tcp_header_size(tcp_header_size); } -//////////////////////////////////////////////////////////////////// -// Function: SocketStream::get_tcp_header_size -// Access: Published -// Description: Returns the header size for datagrams. See -// set_tcp_header_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the header size for datagrams. See set_tcp_header_size(). + */ INLINE int SocketStream:: get_tcp_header_size() const { return SSReader::get_tcp_header_size(); } -//////////////////////////////////////////////////////////////////// -// Function: SocketStream::flush -// Access: Published -// Description: Sends the most recently queued data now. This only -// has meaning if set_collect_tcp() has been set to -// true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued data now. This only has meaning if + * set_collect_tcp() has been set to true. + */ INLINE bool SocketStream:: flush() { return SSWriter::flush(); diff --git a/panda/src/downloader/socketStream.cxx b/panda/src/downloader/socketStream.cxx index 88f26762eb..af43847fb5 100644 --- a/panda/src/downloader/socketStream.cxx +++ b/panda/src/downloader/socketStream.cxx @@ -1,16 +1,15 @@ -// Filename: socketStream.cxx -// Created by: drose (19Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStream.cxx + * @author drose + * @date 2002-10-19 + */ #include "socketStream.h" #include "datagram.h" @@ -20,11 +19,9 @@ #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: SSReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SSReader:: SSReader(istream *stream) : _istream(stream) { _data_expected = 0; @@ -37,24 +34,19 @@ SSReader(istream *stream) : _istream(stream) { #endif // SIMULATE_NETWORK_DELAY } -//////////////////////////////////////////////////////////////////// -// Function: SSReader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SSReader:: ~SSReader() { } -//////////////////////////////////////////////////////////////////// -// Function: SSReader::do_receive_datagram -// Access: Private -// Description: Receives a datagram over the socket by expecting a -// little-endian 16-bit byte count as a prefix. If the -// socket stream is non-blocking, may return false if -// the data is not available; otherwise, returns false -// only if the socket closes. -//////////////////////////////////////////////////////////////////// +/** + * Receives a datagram over the socket by expecting a little-endian 16-bit + * byte count as a prefix. If the socket stream is non-blocking, may return + * false if the data is not available; otherwise, returns false only if the + * socket closes. + */ bool SSReader:: do_receive_datagram(Datagram &dg) { if (_tcp_header_size == 0) { @@ -98,7 +90,7 @@ do_receive_datagram(Datagram &dg) { size_t count = _istream->gcount(); while (count != 0) { _data_so_far.append(buffer, count); - + read_count = min(_data_expected - _data_so_far.length(), buffer_size); _istream->read(buffer, read_count); @@ -122,20 +114,16 @@ do_receive_datagram(Datagram &dg) { } #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: SSReader::start_delay -// Access: Published -// Description: Enables a simulated network latency. All datagrams -// received from this point on will be held for a random -// interval of least min_delay seconds, and no more than -// max_delay seconds, before being visible. It is as if -// datagrams suddenly took much longer to arrive. -// -// This should *only* be called if the underlying socket -// is non-blocking. If you call this on a blocking -// socket, it will force all datagrams to be held up -// until the socket closes. -//////////////////////////////////////////////////////////////////// +/** + * Enables a simulated network latency. All datagrams received from this + * point on will be held for a random interval of least min_delay seconds, and + * no more than max_delay seconds, before being visible. It is as if + * datagrams suddenly took much longer to arrive. + * + * This should *only* be called if the underlying socket is non-blocking. If + * you call this on a blocking socket, it will force all datagrams to be held + * up until the socket closes. + */ void SSReader:: start_delay(double min_delay, double max_delay) { _min_delay = min_delay; @@ -145,13 +133,11 @@ start_delay(double min_delay, double max_delay) { #endif // SIMULATE_NETWORK_DELAY #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: SSReader::stop_delay -// Access: Published -// Description: Disables the simulated network latency started by a -// previous call to start_delay(). Datagrams will once -// again be visible as soon as they are received. -//////////////////////////////////////////////////////////////////// +/** + * Disables the simulated network latency started by a previous call to + * start_delay(). Datagrams will once again be visible as soon as they are + * received. + */ void SSReader:: stop_delay() { _delay_active = false; @@ -159,19 +145,16 @@ stop_delay() { #endif // SIMULATE_NETWORK_DELAY #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: SSReader::delay_datagram -// Access: Private -// Description: Adds the datagram to the delay queue for a random -// time interval. -//////////////////////////////////////////////////////////////////// +/** + * Adds the datagram to the delay queue for a random time interval. + */ void SSReader:: delay_datagram(const Datagram &datagram) { nassertv(_delay_active); double now = TrueClock::get_global_ptr()->get_short_time(); double reveal_time = now + _min_delay; - + if (_delay_variance > 0.0) { reveal_time += _delay_variance * ((double)rand() / (double)RAND_MAX); } @@ -183,13 +166,10 @@ delay_datagram(const Datagram &datagram) { #endif // SIMULATE_NETWORK_DELAY #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: SSReader::get_delayed -// Access: Private -// Description: Checks the delayed queue for any now available -// datagrams. If any are available, returns true and -// fills datagram with its value. -//////////////////////////////////////////////////////////////////// +/** + * Checks the delayed queue for any now available datagrams. If any are + * available, returns true and fills datagram with its value. + */ bool SSReader:: get_delayed(Datagram &datagram) { if (_delayed.empty()) { @@ -211,11 +191,9 @@ get_delayed(Datagram &datagram) { } #endif // SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SSWriter:: SSWriter(ostream *stream) : _ostream(stream) { _collect_tcp = collect_tcp; @@ -224,24 +202,18 @@ SSWriter(ostream *stream) : _ostream(stream) { _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SSWriter:: ~SSWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: SSWriter::send_datagram -// Access: Public -// Description: Transmits the indicated datagram over the socket by -// prepending it with a little-endian 16-bit byte count. -// Does not return until the data is sent or the -// connection is closed, even if the socket stream is -// non-blocking. -//////////////////////////////////////////////////////////////////// +/** + * Transmits the indicated datagram over the socket by prepending it with a + * little-endian 16-bit byte count. Does not return until the data is sent or + * the connection is closed, even if the socket stream is non-blocking. + */ bool SSWriter:: send_datagram(const Datagram &dg) { Datagram header; @@ -253,29 +225,27 @@ send_datagram(const Datagram &dg) { nassert_raise("Datagram too long"); return false; } - + header.add_uint16(dg.get_length()); } else if (_tcp_header_size == 4) { header.add_uint32(dg.get_length()); } - // These two writes don't generate two socket calls, because the - // socket stream is always buffered. + // These two writes don't generate two socket calls, because the socket + // stream is always buffered. _ostream->write((const char *)header.get_data(), header.get_length()); _ostream->write((const char *)dg.get_data(), dg.get_length()); - // Now flush the buffer immediately, forcing the data to be sent - // (unless collect-tcp mode is in effect). + // Now flush the buffer immediately, forcing the data to be sent (unless + // collect-tcp mode is in effect). flush(); return !is_closed(); } -//////////////////////////////////////////////////////////////////// -// Function: ISocketStream::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ISocketStream:: ~ISocketStream() { // This should already have been cleared by the subclass destructor. diff --git a/panda/src/downloader/socketStream.h b/panda/src/downloader/socketStream.h index 67d72bd467..48c7524cbc 100644 --- a/panda/src/downloader/socketStream.h +++ b/panda/src/downloader/socketStream.h @@ -1,16 +1,15 @@ -// Filename: socketStream.h -// Created by: drose (15Oct02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStream.h + * @author drose + * @date 2002-10-15 + */ #ifndef SOCKETSTREAM_H #define SOCKETSTREAM_H @@ -23,21 +22,19 @@ #include "typedReferenceCount.h" #include "pointerTo.h" -// At the present, this module is not compiled if OpenSSL is not -// available, since the only current use for it is to implement -// OpenSSL-defined constructs (like ISocketStream). +// At the present, this module is not compiled if OpenSSL is not available, +// since the only current use for it is to implement OpenSSL-defined +// constructs (like ISocketStream). #ifdef HAVE_OPENSSL class HTTPChannel; -//////////////////////////////////////////////////////////////////// -// Class : SSReader -// Description : An internal class for reading from a socket stream. -// This serves as a base class for both ISocketStream -// and SocketStream; its purpose is to minimize -// redundant code between them. Do not use it directly. -//////////////////////////////////////////////////////////////////// +/** + * An internal class for reading from a socket stream. This serves as a base + * class for both ISocketStream and SocketStream; its purpose is to minimize + * redundant code between them. Do not use it directly. + */ class EXPCL_PANDAEXPRESS SSReader { public: SSReader(istream *stream); @@ -74,7 +71,7 @@ private: double _reveal_time; Datagram _datagram; }; - + typedef pdeque Delayed; Delayed _delayed; bool _delay_active; @@ -83,13 +80,11 @@ private: #endif // SIMULATE_NETWORK_DELAY }; -//////////////////////////////////////////////////////////////////// -// Class : SSWriter -// Description : An internal class for writing to a socket stream. -// This serves as a base class for both OSocketStream -// and SocketStream; its purpose is to minimize -// redundant code between them. Do not use it directly. -//////////////////////////////////////////////////////////////////// +/** + * An internal class for writing to a socket stream. This serves as a base + * class for both OSocketStream and SocketStream; its purpose is to minimize + * redundant code between them. Do not use it directly. + */ class EXPCL_PANDAEXPRESS SSWriter { public: SSWriter(ostream *stream); @@ -120,15 +115,12 @@ private: int _tcp_header_size; }; -//////////////////////////////////////////////////////////////////// -// Class : ISocketStream -// Description : This is a base class for istreams implemented in -// Panda that read from a (possibly non-blocking) -// socket. It adds is_closed(), which can be called -// after an eof condition to check whether the socket -// has been closed, or whether more data may be -// available later. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for istreams implemented in Panda that read from a + * (possibly non-blocking) socket. It adds is_closed(), which can be called + * after an eof condition to check whether the socket has been closed, or + * whether more data may be available later. + */ class EXPCL_PANDAEXPRESS ISocketStream : public istream, public SSReader { public: INLINE ISocketStream(streambuf *buf); @@ -153,14 +145,12 @@ private: friend class HTTPChannel; }; -//////////////////////////////////////////////////////////////////// -// Class : OSocketStream -// Description : A base class for ostreams that write to a (possibly -// non-blocking) socket. It adds is_closed(), which can -// be called after any write operation fails to check -// whether the socket has been closed, or whether more -// data may be sent later. -//////////////////////////////////////////////////////////////////// +/** + * A base class for ostreams that write to a (possibly non-blocking) socket. + * It adds is_closed(), which can be called after any write operation fails to + * check whether the socket has been closed, or whether more data may be sent + * later. + */ class EXPCL_PANDAEXPRESS OSocketStream : public ostream, public SSWriter { public: INLINE OSocketStream(streambuf *buf); @@ -172,11 +162,10 @@ PUBLISHED: INLINE bool flush(); }; -//////////////////////////////////////////////////////////////////// -// Class : SocketStream -// Description : A base class for iostreams that read and write to a -// (possibly non-blocking) socket. -//////////////////////////////////////////////////////////////////// +/** + * A base class for iostreams that read and write to a (possibly non-blocking) + * socket. + */ class EXPCL_PANDAEXPRESS SocketStream : public iostream, public SSReader, public SSWriter { public: INLINE SocketStream(streambuf *buf); @@ -198,5 +187,3 @@ PUBLISHED: #endif - - diff --git a/panda/src/downloader/stringStream.I b/panda/src/downloader/stringStream.I index 5bb892f32f..6e1b173c40 100644 --- a/panda/src/downloader/stringStream.I +++ b/panda/src/downloader/stringStream.I @@ -1,65 +1,52 @@ -// Filename: stringStream.I -// Created by: drose (03Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStream.I + * @author drose + * @date 2007-07-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StringStream::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StringStream:: StringStream() : iostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::Constructor -// Access: Published -// Description: This version of the constructor preloads the buffer -// with the indicated data. -//////////////////////////////////////////////////////////////////// +/** + * This version of the constructor preloads the buffer with the indicated + * data. + */ INLINE StringStream:: StringStream(const string &source) : iostream(&_buf) { set_data(source); } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::clear_data -// Access: Published -// Description: Empties the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Empties the buffer. + */ INLINE void StringStream:: clear_data() { _buf.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::get_data_size -// Access: Published -// Description: Returns the number of characters available to be read -// from the data stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of characters available to be read from the data stream. + */ INLINE size_t StringStream:: get_data_size() { flush(); return _buf.get_data().size(); } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::get_data -// Access: Published -// Description: Returns the contents of the data stream as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the contents of the data stream as a string. + */ INLINE string StringStream:: get_data() { flush(); @@ -70,12 +57,9 @@ get_data() { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::set_data -// Access: Published -// Description: Replaces the contents of the data stream. This -// implicitly reseeks to 0. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the contents of the data stream. This implicitly reseeks to 0. + */ INLINE void StringStream:: set_data(const string &data) { _buf.clear(); @@ -84,12 +68,9 @@ set_data(const string &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::swap_data -// Access: Published -// Description: Swaps the indicated buffer for the contents of the -// internal buffer. -//////////////////////////////////////////////////////////////////// +/** + * Swaps the indicated buffer for the contents of the internal buffer. + */ INLINE void StringStream:: swap_data(vector_uchar &data) { flush(); diff --git a/panda/src/downloader/stringStream.cxx b/panda/src/downloader/stringStream.cxx index 1a72c17f6a..6966391a52 100644 --- a/panda/src/downloader/stringStream.cxx +++ b/panda/src/downloader/stringStream.cxx @@ -1,25 +1,21 @@ -// Filename: stringStream.cxx -// Created by: drose (03Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStream.cxx + * @author drose + * @date 2007-07-03 + */ #include "stringStream.h" -//////////////////////////////////////////////////////////////////// -// Function: StringStream::set_data -// Access: Public -// Description: Replaces the contents of the data stream. This -// implicitly reseeks to 0. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the contents of the data stream. This implicitly reseeks to 0. + */ void StringStream:: set_data(const unsigned char *data, size_t size) { _buf.clear(); diff --git a/panda/src/downloader/stringStream.h b/panda/src/downloader/stringStream.h index 6970887a25..2075f817fd 100644 --- a/panda/src/downloader/stringStream.h +++ b/panda/src/downloader/stringStream.h @@ -1,16 +1,15 @@ -// Filename: stringStream.h -// Created by: drose (03Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStream.h + * @author drose + * @date 2007-07-03 + */ #ifndef STRINGSTREAM_H #define STRINGSTREAM_H @@ -20,13 +19,11 @@ #include "vector_uchar.h" #include "extension.h" -//////////////////////////////////////////////////////////////////// -// Class : StringStream -// Description : A bi-directional stream object that reads and writes -// data to an internal buffer, which can be retrieved -// and/or set as a string in Python 2 or a bytes object -// in Python 3. -//////////////////////////////////////////////////////////////////// +/** + * A bi-directional stream object that reads and writes data to an internal + * buffer, which can be retrieved and/or set as a string in Python 2 or a + * bytes object in Python 3. + */ class EXPCL_PANDAEXPRESS StringStream : public iostream { public: INLINE StringStream(const string &source); diff --git a/panda/src/downloader/stringStreamBuf.I b/panda/src/downloader/stringStreamBuf.I index 0c0a54bda6..fa2a7a87de 100644 --- a/panda/src/downloader/stringStreamBuf.I +++ b/panda/src/downloader/stringStreamBuf.I @@ -1,36 +1,29 @@ -// Filename: stringStreamBuf.I -// Created by: drose (03Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStreamBuf.I + * @author drose + * @date 2007-07-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::swap_data -// Access: Public -// Description: Swaps the indicated buffer for the contents of the -// internal buffer. Does not affect the ppos or gpos, -// or the iostream buffer. -//////////////////////////////////////////////////////////////////// +/** + * Swaps the indicated buffer for the contents of the internal buffer. Does + * not affect the ppos or gpos, or the iostream buffer. + */ INLINE void StringStreamBuf:: swap_data(vector_uchar &data) { _data.swap(data); } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::get_data -// Access: Public -// Description: Returns a reference to the contents of the internal -// buffer, without any of the iostream buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the contents of the internal buffer, without any of + * the iostream buffer. + */ INLINE const vector_uchar &StringStreamBuf:: get_data() const { return _data; diff --git a/panda/src/downloader/stringStreamBuf.cxx b/panda/src/downloader/stringStreamBuf.cxx index e3d7cf4f2e..4067ca1acb 100644 --- a/panda/src/downloader/stringStreamBuf.cxx +++ b/panda/src/downloader/stringStreamBuf.cxx @@ -1,26 +1,23 @@ -// Filename: stringStreamBuf.cxx -// Created by: drose (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStreamBuf.cxx + * @author drose + * @date 2007-07-02 + */ #include "stringStreamBuf.h" #include "pnotify.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StringStreamBuf:: StringStreamBuf() { #ifdef PHAVE_IOSTREAM @@ -32,8 +29,8 @@ StringStreamBuf() { #else allocate(); - // Chop the buffer in half. The bottom half goes to the get buffer; - // the top half goes to the put buffer. + // Chop the buffer in half. The bottom half goes to the get buffer; the top + // half goes to the put buffer. char *b = base(); char *t = ebuf(); char *m = b + (t - b) / 2; @@ -45,11 +42,9 @@ StringStreamBuf() { _ppos = 0; } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StringStreamBuf:: ~StringStreamBuf() { #ifdef PHAVE_IOSTREAM @@ -57,11 +52,9 @@ StringStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::clear -// Access: Public -// Description: Empties the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Empties the buffer. + */ void StringStreamBuf:: clear() { _data.clear(); @@ -72,13 +65,10 @@ clear() { gbump(egptr() - gptr()); } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::read_chars -// Access: Public -// Description: Attempts to extract the indicated number of -// characters from the current file position. Returns -// the number of characters extracted. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to extract the indicated number of characters from the current + * file position. Returns the number of characters extracted. + */ size_t StringStreamBuf:: read_chars(char *start, size_t length) { if (length == 0) { @@ -98,12 +88,9 @@ read_chars(char *start, size_t length) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::write_chars -// Access: Public -// Description: Appends the indicated stream of characters to the -// current file position. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicated stream of characters to the current file position. + */ void StringStreamBuf:: write_chars(const char *start, size_t length) { if (length != 0) { @@ -126,7 +113,7 @@ write_chars(const char *start, size_t length) { // We need to append some zeroes. _data.insert(_data.end(), _ppos - _data.size(), (unsigned char)0); } - + if (length != 0) { // We are appending some data. _data.insert(_data.begin() + _ppos, (const unsigned char *)start, (const unsigned char *)start + length); @@ -135,11 +122,9 @@ write_chars(const char *start, size_t length) { } } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::seekoff -// Access: Public, Virtual -// Description: Implements seeking within the stream. -//////////////////////////////////////////////////////////////////// +/** + * Implements seeking within the stream. + */ streampos StringStreamBuf:: seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { streampos result = -1; @@ -154,17 +139,17 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { _gpos -= n; size_t cur_pos = _gpos; size_t new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (size_t)off; break; - + case ios::cur: new_pos = (size_t)((int)cur_pos + off); break; - + case ios::end: new_pos = (size_t)((int)_data.size() + off); break; @@ -183,17 +168,17 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { size_t n = pptr() - pbase(); size_t cur_pos = _ppos + n; size_t new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (size_t)off; break; - + case ios::cur: new_pos = (size_t)((int)cur_pos + off); break; - + case ios::end: new_pos = (size_t)((int)_data.size() + off); break; @@ -210,31 +195,24 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::seekpos -// Access: Public, Virtual -// Description: A variant on seekoff() to implement seeking within a -// stream. -// -// The MSDN Library claims that it is only necessary to -// redefine seekoff(), and not seekpos() as well, as the -// default implementation of seekpos() is supposed to -// map to seekoff() exactly as I am doing here; but in -// fact it must do something else, because seeking -// didn't work on Windows until I redefined this -// function as well. -//////////////////////////////////////////////////////////////////// +/** + * A variant on seekoff() to implement seeking within a stream. + * + * The MSDN Library claims that it is only necessary to redefine seekoff(), + * and not seekpos() as well, as the default implementation of seekpos() is + * supposed to map to seekoff() exactly as I am doing here; but in fact it + * must do something else, because seeking didn't work on Windows until I + * redefined this function as well. + */ streampos StringStreamBuf:: seekpos(streampos pos, ios_openmode which) { return seekoff(pos, ios::beg, which); } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int StringStreamBuf:: overflow(int ch) { size_t n = pptr() - pbase(); @@ -252,12 +230,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int StringStreamBuf:: sync() { size_t n = pptr() - pbase(); @@ -268,12 +244,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: StringStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int StringStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -302,4 +276,3 @@ underflow() { return (unsigned char)*gptr(); } - diff --git a/panda/src/downloader/stringStreamBuf.h b/panda/src/downloader/stringStreamBuf.h index ae42cf623d..9ddff66ae7 100644 --- a/panda/src/downloader/stringStreamBuf.h +++ b/panda/src/downloader/stringStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: stringStreamBuf.h -// Created by: drose (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStreamBuf.h + * @author drose + * @date 2007-07-02 + */ #ifndef STRINGSTREAMBUF_H #define STRINGSTREAMBUF_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "vector_uchar.h" -//////////////////////////////////////////////////////////////////// -// Class : StringStreamBuf -// Description : Used by StringStream to implement an stream that -// reads from and/or writes to a memory buffer, whose -// contents can be appended to or extracted at any time -// by application code. -//////////////////////////////////////////////////////////////////// +/** + * Used by StringStream to implement an stream that reads from and/or writes + * to a memory buffer, whose contents can be appended to or extracted at any + * time by application code. + */ class EXPCL_PANDAEXPRESS StringStreamBuf : public streambuf { public: StringStreamBuf(); diff --git a/panda/src/downloader/stringStream_ext.cxx b/panda/src/downloader/stringStream_ext.cxx index 54c889d7e3..c9d66ca0a7 100644 --- a/panda/src/downloader/stringStream_ext.cxx +++ b/panda/src/downloader/stringStream_ext.cxx @@ -1,36 +1,31 @@ -// Filename: stringStream_ext.cxx -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStream_ext.cxx + * @author rdb + * @date 2013-12-09 + */ #include "stringStream_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: StringStream::__init__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Extension:: __init__(PyObject *source) { set_data(source); } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::get_data -// Access: Published -// Description: Returns the contents of the data stream as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the contents of the data stream as a string. + */ PyObject *Extension:: get_data() { _this->flush(); @@ -49,12 +44,9 @@ get_data() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: StringStream::set_data -// Access: Published -// Description: Replaces the contents of the data stream. This -// implicitly reseeks to 0. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the contents of the data stream. This implicitly reseeks to 0. + */ void Extension:: set_data(PyObject *data) { _this->_buf.clear(); diff --git a/panda/src/downloader/stringStream_ext.h b/panda/src/downloader/stringStream_ext.h index 200a9c25c9..a19a4b3a36 100644 --- a/panda/src/downloader/stringStream_ext.h +++ b/panda/src/downloader/stringStream_ext.h @@ -1,16 +1,15 @@ -// Filename: stringStream_ext.h -// Created by: rdb (06Aug15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stringStream_ext.h + * @author rdb + * @date 2015-08-06 + */ #ifndef STRINGSTREAM_EXT_H #define STRINGSTREAM_EXT_H @@ -23,12 +22,10 @@ #include "stringStream.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// StringStream, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for StringStream, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/downloader/urlSpec.I b/panda/src/downloader/urlSpec.I index c532471a88..5d4654e1f7 100644 --- a/panda/src/downloader/urlSpec.I +++ b/panda/src/downloader/urlSpec.I @@ -1,240 +1,188 @@ -// Filename: urlSpec.I -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file urlSpec.I + * @author drose + * @date 2002-09-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE URLSpec:: URLSpec(const string &url, bool server_name_expected) { set_url(url, server_name_expected); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE URLSpec:: URLSpec(const URLSpec ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void URLSpec:: operator = (const string &url) { set_url(url); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool URLSpec:: operator == (const URLSpec &other) const { return _url == other._url; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool URLSpec:: operator != (const URLSpec &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool URLSpec:: operator < (const URLSpec &other) const { return _url < other._url; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::compare_to -// Access: Published -// Description: Returns a number less than zero if this URLSpec -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this URLSpec sorts before the other one, + * greater than zero if it sorts after, or zero if they are equivalent. + */ INLINE int URLSpec:: compare_to(const URLSpec &other) const { return strcmp(_url.c_str(), other._url.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_scheme -// Access: Published -// Description: Returns true if the URL specifies a scheme -// (e.g. "http:"), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL specifies a scheme (e.g. "http:"), false + * otherwise. + */ INLINE bool URLSpec:: has_scheme() const { return (_flags & F_has_scheme) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_authority -// Access: Published -// Description: Returns true if the URL specifies an authority -// (this includes username, server, and/or port), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL specifies an authority (this includes username, + * server, and/or port), false otherwise. + */ INLINE bool URLSpec:: has_authority() const { return (_flags & F_has_authority) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_username -// Access: Published -// Description: Returns true if the URL specifies a username -// (and/or password), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL specifies a username (and/or password), false + * otherwise. + */ INLINE bool URLSpec:: has_username() const { return (_flags & F_has_username) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_server -// Access: Published -// Description: Returns true if the URL specifies a server name, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL specifies a server name, false otherwise. + */ INLINE bool URLSpec:: has_server() const { return (_flags & F_has_server) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_port -// Access: Published -// Description: Returns true if the URL specifies a port number, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL specifies a port number, false otherwise. + */ INLINE bool URLSpec:: has_port() const { return (_flags & F_has_port) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_path -// Access: Published -// Description: Returns true if the URL includes a path specification -// (that is, the particular filename on the server to -// retrieve), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL includes a path specification (that is, the + * particular filename on the server to retrieve), false otherwise. + */ INLINE bool URLSpec:: has_path() const { return (_flags & F_has_path) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::has_query -// Access: Published -// Description: Returns true if the URL includes a query -// specification, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL includes a query specification, false otherwise. + */ INLINE bool URLSpec:: has_query() const { return (_flags & F_has_query) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_authority -// Access: Published -// Description: Returns the authority specified by the URL (this -// includes username, server, and/or port), or empty -// string if no authority is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the authority specified by the URL (this includes username, server, + * and/or port), or empty string if no authority is specified. + */ INLINE string URLSpec:: get_authority() const { return _url.substr(_username_start, _port_end - _username_start); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_username -// Access: Published -// Description: Returns the username specified by the URL, if any. -// This might also include a password, -// e.g. "username:password", although putting a password -// on the URL is probably a bad idea. -//////////////////////////////////////////////////////////////////// +/** + * Returns the username specified by the URL, if any. This might also include + * a password, e.g. "username:password", although putting a password on the + * URL is probably a bad idea. + */ INLINE string URLSpec:: get_username() const { return _url.substr(_username_start, _username_end - _username_start); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_server -// Access: Published -// Description: Returns the server name specified by the URL, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the server name specified by the URL, if any. + */ INLINE string URLSpec:: get_server() const { return _url.substr(_server_start, _server_end - _server_start); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_port_str -// Access: Published -// Description: Returns the port specified by the URL as a string, or -// the empty string if no port is specified. Compare -// this with get_port(), which returns a default port -// number if no port is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the port specified by the URL as a string, or the empty string if + * no port is specified. Compare this with get_port(), which returns a + * default port number if no port is specified. + */ INLINE string URLSpec:: get_port_str() const { return _url.substr(_port_start, _port_end - _port_start); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_query -// Access: Published -// Description: Returns the query specified by the URL, or empty -// string if no query is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the query specified by the URL, or empty string if no query is + * specified. + */ INLINE string URLSpec:: get_query() const { return _url.substr(_query_start); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::is_ssl -// Access: Published -// Description: Returns true if the URL's scheme specifies an -// SSL-secured protocol such as https, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the URL's scheme specifies an SSL-secured protocol such as + * https, or false otherwise. + */ INLINE bool URLSpec:: is_ssl() const { if (has_scheme() && _scheme_end > 0) { - // If we have a scheme specification, assume it is SSL-secured if - // it ends in "s", except for the special case of "socks". + // If we have a scheme specification, assume it is SSL-secured if it ends + // in "s", except for the special case of "socks". if (_url.substr(0, _scheme_end) == "socks") { return false; } @@ -245,61 +193,49 @@ is_ssl() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_url -// Access: Published -// Description: Returns the complete URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete URL specification. + */ INLINE const string &URLSpec:: get_url() const { return _url; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::string typecast operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE URLSpec:: operator const string & () const { return _url; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::c_str -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const char *URLSpec:: c_str() const { return _url.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool URLSpec:: empty() const { return _url.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t URLSpec:: length() const { return _url.length(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE char URLSpec:: operator [] (int n) const { nassertr(n >= 0 && n < (int)_url.length(), '\0'); @@ -319,5 +255,3 @@ operator << (ostream &out, const URLSpec &url) { url.output(out); return out; } - - diff --git a/panda/src/downloader/urlSpec.cxx b/panda/src/downloader/urlSpec.cxx index 52f919973f..e724e9a044 100644 --- a/panda/src/downloader/urlSpec.cxx +++ b/panda/src/downloader/urlSpec.cxx @@ -1,27 +1,24 @@ -// Filename: urlSpec.cxx -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file urlSpec.cxx + * @author drose + * @date 2002-09-24 + */ #include "urlSpec.h" #include -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ URLSpec:: URLSpec() { _port = 0; @@ -38,11 +35,9 @@ URLSpec() { _query_start = 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void URLSpec:: operator = (const URLSpec ©) { _url = copy._url; @@ -60,12 +55,10 @@ operator = (const URLSpec ©) { _query_start = copy._query_start; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_scheme -// Access: Published -// Description: Returns the scheme specified by the URL, or empty -// string if no scheme is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scheme specified by the URL, or empty string if no scheme is + * specified. + */ string URLSpec:: get_scheme() const { if (has_scheme()) { @@ -74,12 +67,10 @@ get_scheme() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_port -// Access: Published -// Description: Returns the port number specified by the URL, or the -// default port if not specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the port number specified by the URL, or the default port if not + * specified. + */ int URLSpec:: get_port() const { if (has_port()) { @@ -88,14 +79,11 @@ get_port() const { return get_default_port_for_scheme(get_scheme()); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::is_default_port -// Access: Published -// Description: Returns true if the port number encoded in this URL -// is the default port number for the scheme (or if -// there is no port number), or false if it is a -// nonstandard port. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the port number encoded in this URL is the default port + * number for the scheme (or if there is no port number), or false if it is a + * nonstandard port. + */ bool URLSpec:: is_default_port() const { if (!has_port()) { @@ -104,12 +92,10 @@ is_default_port() const { return (_port == get_default_port_for_scheme(get_scheme())); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_default_port_for_scheme -// Access: Published, Static -// Description: Returns the default port number for the indicated -// scheme, or 0 if there is no known default. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default port number for the indicated scheme, or 0 if there is + * no known default. + */ int URLSpec:: get_default_port_for_scheme(const string &scheme) { if (scheme == "http" || scheme.empty()) { @@ -125,14 +111,11 @@ get_default_port_for_scheme(const string &scheme) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_server_and_port -// Access: Published -// Description: Returns a string consisting of the server name, -// followed by a colon, followed by the port number. If -// the port number is not explicitly given in the URL, -// this string will include the implicit port number. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string consisting of the server name, followed by a colon, + * followed by the port number. If the port number is not explicitly given in + * the URL, this string will include the implicit port number. + */ string URLSpec:: get_server_and_port() const { if (has_port()) { @@ -143,12 +126,9 @@ get_server_and_port() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_path -// Access: Published -// Description: Returns the path specified by the URL, or "/" if no -// path is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the path specified by the URL, or "/" if no path is specified. + */ string URLSpec:: get_path() const { if (has_path()) { @@ -157,12 +137,10 @@ get_path() const { return "/"; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::get_path_and_query -// Access: Published -// Description: Returns the path (or "/" if no path is specified), -// followed by the query if it is specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the path (or "/" if no path is specified), followed by the query if + * it is specified. + */ string URLSpec:: get_path_and_query() const { if (has_path()) { @@ -174,11 +152,9 @@ get_path_and_query() const { return "/"; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_scheme -// Access: Published -// Description: Replaces the scheme part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the scheme part of the URL specification. + */ void URLSpec:: set_scheme(const string &scheme) { int length_adjust; @@ -202,8 +178,8 @@ set_scheme(const string &scheme) { _flags &= ~F_has_scheme; } else if (!has_scheme()) { - // Insert a new scheme specification. The user may or may not - // have specified a colon. + // Insert a new scheme specification. The user may or may not have + // specified a colon. if (lc_scheme[lc_scheme.length() - 1] == ':') { length_adjust = lc_scheme.length(); _url = lc_scheme + _url; @@ -213,16 +189,15 @@ set_scheme(const string &scheme) { _url = lc_scheme + ":" + _url; } - // Since the length_adjust flag, above, now accounts for the - // colon, subtract one from _scheme_end (which should not include - // the colon). + // Since the length_adjust flag, above, now accounts for the colon, + // subtract one from _scheme_end (which should not include the colon). _scheme_end--; _flags |= F_has_scheme; } else { - // Replace the existing scheme specification. Since the existing - // scheme will already be trailed by a colon, remove the colon - // from the string if the user appended one. + // Replace the existing scheme specification. Since the existing scheme + // will already be trailed by a colon, remove the colon from the string if + // the user appended one. if (lc_scheme[lc_scheme.length() - 1] == ':') { lc_scheme = lc_scheme.substr(0, lc_scheme.length() - 1); } @@ -244,12 +219,10 @@ set_scheme(const string &scheme) { _query_start += length_adjust; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_authority -// Access: Published -// Description: Replaces the authority part of the URL specification. -// This includes the username, server, and port. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the authority part of the URL specification. This includes the + * username, server, and port. + */ void URLSpec:: set_authority(const string &authority) { int length_adjust; @@ -299,11 +272,9 @@ set_authority(const string &authority) { parse_authority(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_username -// Access: Published -// Description: Replaces the username part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the username part of the URL specification. + */ void URLSpec:: set_username(const string &username) { if (username.empty() && !has_authority()) { @@ -323,11 +294,9 @@ set_username(const string &username) { set_authority(authority); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_server -// Access: Published -// Description: Replaces the server part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the server part of the URL specification. + */ void URLSpec:: set_server(const string &server) { if (server.empty() && !has_authority()) { @@ -347,11 +316,9 @@ set_server(const string &server) { set_authority(authority); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_port -// Access: Published -// Description: Replaces the port part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the port part of the URL specification. + */ void URLSpec:: set_port(const string &port) { if (port.empty() && !has_authority()) { @@ -372,12 +339,10 @@ set_port(const string &port) { set_authority(authority); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_port -// Access: Published -// Description: Replaces the port part of the URL specification, -// given a numeric port number. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the port part of the URL specification, given a numeric port + * number. + */ void URLSpec:: set_port(int port) { ostringstream str; @@ -385,14 +350,11 @@ set_port(int port) { set_port(str.str()); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_server_and_port -// Access: Published -// Description: Replaces the server and port parts of the URL -// specification simultaneously. The input string -// should be of the form "server:port", or just -// "server" to make the port number implicit. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the server and port parts of the URL specification simultaneously. + * The input string should be of the form "server:port", or just "server" to + * make the port number implicit. + */ void URLSpec:: set_server_and_port(const string &server_and_port) { if (server_and_port.empty() && !has_authority()) { @@ -407,11 +369,9 @@ set_server_and_port(const string &server_and_port) { set_authority(authority); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_path -// Access: Published -// Description: Replaces the path part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the path part of the URL specification. + */ void URLSpec:: set_path(const string &path) { int length_adjust; @@ -453,11 +413,9 @@ set_path(const string &path) { _query_start += length_adjust; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_query -// Access: Published -// Description: Replaces the query part of the URL specification. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the query part of the URL specification. + */ void URLSpec:: set_query(const string &query) { if (query.empty()) { @@ -481,14 +439,11 @@ set_query(const string &query) { } } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::set_url -// Access: Published -// Description: Completely replaces the URL with the indicated -// string. If server_name_expected is true, it is a -// hint that an undecorated URL is probably a server -// name, not a local filename. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the URL with the indicated string. If + * server_name_expected is true, it is a hint that an undecorated URL is + * probably a server name, not a local filename. + */ void URLSpec:: set_url(const string &url, bool server_name_expected) { size_t p, q; @@ -511,10 +466,10 @@ set_url(const string &url, bool server_name_expected) { server_name_expected = false; } - // First, replace backslashes with forward slashes, since this is a - // common mistake among Windows users. But don't do this after an - // embedded question mark, which begins parameters sent directly to - // the host (and maybe these parameters should include backslashes). + // First, replace backslashes with forward slashes, since this is a common + // mistake among Windows users. But don't do this after an embedded + // question mark, which begins parameters sent directly to the host (and + // maybe these parameters should include backslashes). for (p = 0; p < _url.length() && _url[p] != '?'; p++) { if (_url[p] == '\\') { _url[p] = '/'; @@ -543,8 +498,8 @@ set_url(const string &url, bool server_name_expected) { start = next + 1; } - // Look for the authority specification, which may include any of - // username, server, and/or port. + // Look for the authority specification, which may include any of username, + // server, andor port. _username_start = start; _username_end = start; _server_start = start; @@ -552,24 +507,23 @@ set_url(const string &url, bool server_name_expected) { _port_start = start; _port_end = start; - // Try to determine if an authority is present. It is will - // generally be present if a scheme was present; also, we have a - // hint passed in from the context as to whether we expect an - // authority (e.g. a server name) to be present. + // Try to determine if an authority is present. It is will generally be + // present if a scheme was present; also, we have a hint passed in from the + // context as to whether we expect an authority (e.g. a server name) to be + // present. bool has_authority = (has_scheme() || server_name_expected); - // We also know we have an authority if the url contains two slashes - // at this point. - bool leading_slashes = + // We also know we have an authority if the url contains two slashes at this + // point. + bool leading_slashes = (start < _url.length() - 1 && _url.substr(start, 2) == "//"); if (leading_slashes) { has_authority = true; } if (has_authority) { - // Now that we know we have an authority, we should ensure there - // are two slashes here, since there should be before the - // authority. + // Now that we know we have an authority, we should ensure there are two + // slashes here, since there should be before the authority. if (!leading_slashes) { if (start < _url.length() && _url[start] == '/') { // Well, at least we had one slash. Double it. @@ -615,11 +569,9 @@ set_url(const string &url, bool server_name_expected) { } } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool URLSpec:: input(istream &in) { string url; @@ -631,27 +583,20 @@ input(istream &in) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void URLSpec:: output(ostream &out) const { out << get_url(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::quote -// Access: Published, Static -// Description: Returns the source string with all "unsafe" -// characters quoted, making a string suitable for -// placing in a URL. Letters, digits, and the -// underscore, comma, period, and hyphen characters, as -// well as any included in the safe string, are left -// alone; all others are converted to hex -// representation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source string with all "unsafe" characters quoted, making a + * string suitable for placing in a URL. Letters, digits, and the underscore, + * comma, period, and hyphen characters, as well as any included in the safe + * string, are left alone; all others are converted to hex representation. + */ string URLSpec:: quote(const string &source, const string &safe) { ostringstream result; @@ -687,12 +632,10 @@ quote(const string &source, const string &safe) { return result.str(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::quote_plus -// Access: Published, Static -// Description: Behaves like quote() with the additional behavior of -// replacing spaces with plus signs. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like quote() with the additional behavior of replacing spaces with + * plus signs. + */ string URLSpec:: quote_plus(const string &source, const string &safe) { ostringstream result; @@ -732,13 +675,10 @@ quote_plus(const string &source, const string &safe) { return result.str(); } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::unquote -// Access: Published, Static -// Description: Reverses the operation of quote(): converts escaped -// characters of the form "%xx" to their ascii -// equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the operation of quote(): converts escaped characters of the form + * "%xx" to their ascii equivalent. + */ string URLSpec:: unquote(const string &source) { string result; @@ -770,13 +710,11 @@ unquote(const string &source) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::unquote_plus -// Access: Published, Static -// Description: Reverses the operation of quote_plus(): converts escaped -// characters of the form "%xx" to their ascii -// equivalent, and also converts plus signs to spaces. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the operation of quote_plus(): converts escaped characters of the + * form "%xx" to their ascii equivalent, and also converts plus signs to + * spaces. + */ string URLSpec:: unquote_plus(const string &source) { string result; @@ -812,15 +750,11 @@ unquote_plus(const string &source) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: URLSpec::parse_authority -// Access: Private -// Description: Assumes _url[_username_start .. _port_end - 1] is -// the authority component if the URL, consisting of -// [username@]server[:port]. Parses out the three -// pieces and updates the various _start and _end -// parameters accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Assumes _url[_username_start .. _port_end - 1] is the authority component + * if the URL, consisting of [username@]server[:port]. Parses out the three + * pieces and updates the various _start and _end parameters accordingly. + */ void URLSpec:: parse_authority() { _flags &= ~(F_has_username | F_has_server | F_has_port); @@ -854,9 +788,9 @@ parse_authority() { _flags |= F_has_port; _server_end = colon; _port_start = colon + 1; - - // Decode the port into an integer. Don't bother to error - // check if it's not really an integer. + + // Decode the port into an integer. Don't bother to error check if it's + // not really an integer. string port_str = _url.substr(_port_start, _port_end - _port_start); _port = atoi(port_str.c_str()); } @@ -866,8 +800,8 @@ parse_authority() { _url[si] = tolower(_url[si]); } - // Also make sure the server name doesn't end with a dot. It's - // happened! Silly users. + // Also make sure the server name doesn't end with a dot. It's happened! + // Silly users. if (_server_end > _server_start && _url[_server_end - 1] == '.') { _url = _url.substr(0, _server_end - 1) + _url.substr(_server_end); _server_end--; diff --git a/panda/src/downloader/urlSpec.h b/panda/src/downloader/urlSpec.h index f4cbfed47c..7b7cc4e9b2 100644 --- a/panda/src/downloader/urlSpec.h +++ b/panda/src/downloader/urlSpec.h @@ -1,16 +1,15 @@ -// Filename: urlSpec.h -// Created by: drose (24Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file urlSpec.h + * @author drose + * @date 2002-09-24 + */ #ifndef URLSPEC_H #define URLSPEC_H @@ -18,14 +17,12 @@ #include "pandabase.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : URLSpec -// Description : A container for a URL, e.g. "http://server:port/path". -// -// The URLSpec object is similar to a Filename in that -// it contains logic to identify the various parts of a -// URL and return (or modify) them separately. -//////////////////////////////////////////////////////////////////// +/** + * A container for a URL, e.g. "http://server:port/path". + * + * The URLSpec object is similar to a Filename in that it contains logic to + * identify the various parts of a URL and return (or modify) them separately. + */ class EXPCL_PANDAEXPRESS URLSpec { PUBLISHED: URLSpec(); @@ -124,4 +121,3 @@ INLINE ostream &operator << (ostream &out, const URLSpec &url); #include "urlSpec.I" #endif - diff --git a/panda/src/downloader/virtualFileHTTP.I b/panda/src/downloader/virtualFileHTTP.I index 88c620f09c..019c524b30 100644 --- a/panda/src/downloader/virtualFileHTTP.I +++ b/panda/src/downloader/virtualFileHTTP.I @@ -1,25 +1,21 @@ -// Filename: virtualFileHTTP.I -// Created by: drose (31Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileHTTP.I + * @author drose + * @date 2008-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::is_implicit_pz_file -// Access: Published -// Description: Returns true if this file is a .pz file that should -// be implicitly decompressed on load, or false if it is -// not a .pz file or if it should not be decompressed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file is a .pz file that should be implicitly + * decompressed on load, or false if it is not a .pz file or if it should not + * be decompressed. + */ INLINE bool VirtualFileHTTP:: is_implicit_pz_file() const { return _implicit_pz_file; diff --git a/panda/src/downloader/virtualFileHTTP.cxx b/panda/src/downloader/virtualFileHTTP.cxx index 1374f40575..03bfaa1737 100644 --- a/panda/src/downloader/virtualFileHTTP.cxx +++ b/panda/src/downloader/virtualFileHTTP.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileHTTP.cxx -// Created by: drose (31Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileHTTP.cxx + * @author drose + * @date 2008-10-31 + */ #include "virtualFileHTTP.h" #include "virtualFileMountHTTP.h" @@ -22,11 +21,9 @@ TypeHandle VirtualFileHTTP::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileHTTP:: VirtualFileHTTP(VirtualFileMountHTTP *mount, const Filename &local_filename, bool implicit_pz_file, int open_flags) : @@ -45,35 +42,27 @@ VirtualFileHTTP(VirtualFileMountHTTP *mount, const Filename &local_filename, } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileHTTP:: ~VirtualFileHTTP() { - // Recycle the associated HTTPChannel, so we can use it again later - // without having to close the connection to the server. + // Recycle the associated HTTPChannel, so we can use it again later without + // having to close the connection to the server. _mount->recycle_channel(_channel); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::get_file_system -// Access: Published, Virtual -// Description: Returns the VirtualFileSystem this file is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFileSystem this file is associated with. + */ VirtualFileSystem *VirtualFileHTTP:: get_file_system() const { return _mount->get_file_system(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::get_filename -// Access: Published, Virtual -// Description: Returns the full pathname to this file within the -// virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to this file within the virtual file system. + */ Filename VirtualFileHTTP:: get_filename() const { string mount_point = _mount->get_mount_point(); @@ -93,82 +82,68 @@ get_filename() const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::has_file -// Access: Published, Virtual -// Description: Returns true if this file exists, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file exists, false otherwise. + */ bool VirtualFileHTTP:: has_file() const { return _channel->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::is_directory -// Access: Published, Virtual -// Description: Returns true if this file represents a directory (and -// scan_directory() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a directory (and scan_directory() may + * be called), false otherwise. + */ bool VirtualFileHTTP:: is_directory() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::is_regular_file -// Access: Published, Virtual -// Description: Returns true if this file represents a regular file -// (and read_file() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a regular file (and read_file() may be + * called), false otherwise. + */ bool VirtualFileHTTP:: is_regular_file() const { return _channel->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::open_read_file -// Access: Published, Virtual -// Description: Opens the file for reading. Returns a newly -// allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading. Returns a newly allocated istream on success + * (which you should eventually delete when you are done reading). Returns + * NULL on failure. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ istream *VirtualFileHTTP:: open_read_file(bool auto_unwrap) const { if (_status_only) { return NULL; } - // We pre-download the file into a StringStream, then return a - // buffer to that. It seems safer, since we can guarantee the file - // comes all at once without timeouts along the way. + // We pre-download the file into a StringStream, then return a buffer to + // that. It seems safer, since we can guarantee the file comes all at once + // without timeouts along the way. StringStream *strstream = new StringStream; if (!fetch_file(strstream)) { delete strstream; return NULL; } - + return return_file(strstream, auto_unwrap); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::fetch_file -// Access: Private -// Description: Downloads the entire file from the web server into -// the indicated iostream. Returns true on success, -// false on failure. -// -// This seems to be safer than returning the socket -// stream directly, since this way we can better control -// timeouts and other internet hiccups. We can also -// offer seeking on the resulting stream. -//////////////////////////////////////////////////////////////////// +/** + * Downloads the entire file from the web server into the indicated iostream. + * Returns true on success, false on failure. + * + * This seems to be safer than returning the socket stream directly, since + * this way we can better control timeouts and other internet hiccups. We can + * also offer seeking on the resulting stream. + */ bool VirtualFileHTTP:: fetch_file(ostream *buffer_stream) const { _channel->download_to_stream(buffer_stream, false); @@ -192,13 +167,10 @@ fetch_file(ostream *buffer_stream) const { return _channel->is_download_complete() && _channel->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::return_file -// Access: Private -// Description: After downloading the entire file via fetch_file(), -// rewinds the file stream and returns it as its own -// readable stream. -//////////////////////////////////////////////////////////////////// +/** + * After downloading the entire file via fetch_file(), rewinds the file stream + * and returns it as its own readable stream. + */ istream *VirtualFileHTTP:: return_file(istream *buffer_stream, bool auto_unwrap) const { // Will we be automatically unwrapping a .pz file? @@ -216,60 +188,47 @@ return_file(istream *buffer_stream, bool auto_unwrap) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::was_read_successful -// Access: Public -// Description: Call this method after a reading the istream returned -// by open_read_file() to completion. If it returns -// true, the file was read completely and without error; -// if it returns false, there may have been some errors -// or a truncated file read. This is particularly -// likely if the stream is a VirtualFileHTTP. -//////////////////////////////////////////////////////////////////// +/** + * Call this method after a reading the istream returned by open_read_file() + * to completion. If it returns true, the file was read completely and + * without error; if it returns false, there may have been some errors or a + * truncated file read. This is particularly likely if the stream is a + * VirtualFileHTTP. + */ bool VirtualFileHTTP:: was_read_successful() const { return _channel->is_valid() && _channel->is_download_complete(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileHTTP:: get_file_size(istream *stream) const { return _channel->get_file_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileHTTP:: get_file_size() const { return _channel->get_file_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileHTTP::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileHTTP:: get_timestamp() const { const DocumentSpec &spec = _channel->get_document_spec(); @@ -280,4 +239,3 @@ get_timestamp() const { } #endif // HAVE_OPENSSL - diff --git a/panda/src/downloader/virtualFileHTTP.h b/panda/src/downloader/virtualFileHTTP.h index 40e54c288a..7b5426566c 100644 --- a/panda/src/downloader/virtualFileHTTP.h +++ b/panda/src/downloader/virtualFileHTTP.h @@ -1,16 +1,15 @@ -// Filename: virtualFileHTTP.h -// Created by: drose (31Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileHTTP.h + * @author drose + * @date 2008-10-31 + */ #ifndef VIRTUALFILEHTTP_H #define VIRTUALFILEHTTP_H @@ -25,12 +24,11 @@ class VirtualFileMountHTTP; -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileHTTP -// Description : This maps a document retrieved from an HTTPClient -// into the VirtualFileSystem, allowing models etc. to -// be loaded directly from a web page. -//////////////////////////////////////////////////////////////////// +/** + * This maps a document retrieved from an HTTPClient into the + * VirtualFileSystem, allowing models etc. to be loaded directly from a web + * page. + */ class EXPCL_PANDAEXPRESS VirtualFileHTTP : public VirtualFile { public: VirtualFileHTTP(VirtualFileMountHTTP *mount, @@ -91,4 +89,3 @@ private: #endif // HAVE_OPENSSL #endif - diff --git a/panda/src/downloader/virtualFileMountHTTP.I b/panda/src/downloader/virtualFileMountHTTP.I index 1ee2759a6f..0e6854fdd5 100644 --- a/panda/src/downloader/virtualFileMountHTTP.I +++ b/panda/src/downloader/virtualFileMountHTTP.I @@ -1,35 +1,27 @@ -// Filename: virtualFileMountHTTP.I -// Created by: drose (30Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountHTTP.I + * @author drose + * @date 2008-10-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_http_client -// Access: Published -// Description: Returns the HTTPClient object that services this -// mount point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HTTPClient object that services this mount point. + */ INLINE HTTPClient *VirtualFileMountHTTP:: get_http_client() const { return _http; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_root -// Access: Published -// Description: Returns the URL that represents the root of this -// mount point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the URL that represents the root of this mount point. + */ INLINE const URLSpec &VirtualFileMountHTTP:: get_root() const { return _root; diff --git a/panda/src/downloader/virtualFileMountHTTP.cxx b/panda/src/downloader/virtualFileMountHTTP.cxx index aedcbf91bf..78b06a2f44 100644 --- a/panda/src/downloader/virtualFileMountHTTP.cxx +++ b/panda/src/downloader/virtualFileMountHTTP.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMountHTTP.cxx -// Created by: drose (30Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountHTTP.cxx + * @author drose + * @date 2008-10-30 + */ #include "virtualFileMountHTTP.h" #include "virtualFileHTTP.h" @@ -21,18 +20,16 @@ TypeHandle VirtualFileMountHTTP::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountHTTP:: VirtualFileMountHTTP(const URLSpec &root, HTTPClient *http) : _http(http), _root(root) { - // Make sure the root ends on a slash. The implicit trailing slash - // is a semi-standard internet convention. + // Make sure the root ends on a slash. The implicit trailing slash is a + // semi-standard internet convention. string path = _root.get_path(); if (!path.empty() && path[path.length() - 1] != '/') { path += '/'; @@ -40,30 +37,23 @@ VirtualFileMountHTTP(const URLSpec &root, HTTPClient *http) : } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountHTTP:: ~VirtualFileMountHTTP() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::reload_vfs_mount_url -// Access: Published, Static -// Description: Reads all of the vfs-mount-url lines in the -// Config.prc file and replaces the mount settings to -// match them. -// -// This will mount any url's mentioned in the config -// file, and unmount and unmount any url's no longer -// mentioned in the config file. Normally, it is called -// automatically at startup, and need not be called -// again, unless you have fiddled with some config -// settings. -//////////////////////////////////////////////////////////////////// +/** + * Reads all of the vfs-mount-url lines in the Config.prc file and replaces + * the mount settings to match them. + * + * This will mount any url's mentioned in the config file, and unmount and + * unmount any url's no longer mentioned in the config file. Normally, it is + * called automatically at startup, and need not be called again, unless you + * have fiddled with some config settings. + */ void VirtualFileMountHTTP:: reload_vfs_mount_url() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -88,12 +78,12 @@ reload_vfs_mount_url() { int num_unique_values = mounts.get_num_unique_values(); for (int i = 0; i < num_unique_values; i++) { string mount_desc = mounts.get_unique_value(i); - + size_t space = mount_desc.rfind(' '); if (space == string::npos) { downloader_cat.warning() << "No space in vfs-mount-url descriptor: " << mount_desc << "\n"; - + } else { string mount_point = mount_desc.substr(space + 1); while (space > 0 && isspace(mount_desc[space - 1])) { @@ -101,7 +91,7 @@ reload_vfs_mount_url() { } mount_desc = mount_desc.substr(0, space); string options; - + space = mount_desc.rfind(' '); if (space != string::npos) { // If there's another space, we have the optional options field. @@ -112,13 +102,13 @@ reload_vfs_mount_url() { } mount_desc = mount_desc.substr(0, space); } - + mount_desc = ExecutionEnvironment::expand_string(mount_desc); URLSpec root(mount_desc); - + int flags = 0; string password; - + // Split the options up by commas. size_t p = 0; size_t q = options.find(',', p); @@ -136,155 +126,124 @@ reload_vfs_mount_url() { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::has_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system. + */ bool VirtualFileMountHTTP:: has_file(const Filename &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::is_directory -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * directory. + */ bool VirtualFileMountHTTP:: is_directory(const Filename &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::is_regular_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * regular file. + */ bool VirtualFileMountHTTP:: is_regular_file(const Filename &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::make_virtual_file -// Access: Public, Virtual -// Description: Constructs and returns a new VirtualFile instance -// that corresponds to the indicated filename within -// this mount point. The returned VirtualFile object -// does not imply that the given file actually exists; -// but if the file does exist, then the handle can be -// used to read it. -//////////////////////////////////////////////////////////////////// +/** + * Constructs and returns a new VirtualFile instance that corresponds to the + * indicated filename within this mount point. The returned VirtualFile + * object does not imply that the given file actually exists; but if the file + * does exist, then the handle can be used to read it. + */ PT(VirtualFile) VirtualFileMountHTTP:: make_virtual_file(const Filename &local_filename, const Filename &original_filename, bool implicit_pz_file, int open_flags) { - PT(VirtualFileHTTP) vfile = + PT(VirtualFileHTTP) vfile = new VirtualFileHTTP(this, local_filename, implicit_pz_file, open_flags); vfile->set_original_filename(original_filename); return vfile.p(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::open_read_file -// Access: Public, Virtual -// Description: Opens the file for reading, if it exists. Returns a -// newly allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading, if it exists. Returns a newly allocated + * istream on success (which you should eventually delete when you are done + * reading). Returns NULL on failure. + */ istream *VirtualFileMountHTTP:: open_read_file(const Filename &) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileMountHTTP:: get_file_size(const Filename &, istream *) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileMountHTTP:: get_file_size(const Filename &) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileMountHTTP:: get_timestamp(const Filename &) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::scan_directory -// Access: Public, Virtual -// Description: Fills the given vector up with the list of filenames -// that are local to this directory, if the filename is -// a directory. Returns true if successful, or false if -// the file is not a directory or cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of filenames that are local to this + * directory, if the filename is a directory. Returns true if successful, or + * false if the file is not a directory or cannot be read. + */ bool VirtualFileMountHTTP:: scan_directory(vector_string &, const Filename &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMountHTTP:: output(ostream &out) const { out << _root; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::get_channel -// Access: Public -// Description: Returns an HTTPChannel object suitable for use for -// extracting a document from the current URL root. -//////////////////////////////////////////////////////////////////// +/** + * Returns an HTTPChannel object suitable for use for extracting a document + * from the current URL root. + */ PT(HTTPChannel) VirtualFileMountHTTP:: get_channel() { PT(HTTPChannel) channel; _channels_lock.acquire(); if (!_channels.empty()) { - // If we have some channels sitting around, grab one. Grab the - // one on the end; it was most recently pushed, and therefore most - // likely to be still alive. + // If we have some channels sitting around, grab one. Grab the one on the + // end; it was most recently pushed, and therefore most likely to be still + // alive. channel = _channels.back(); _channels.pop_back(); } else { @@ -296,13 +255,11 @@ get_channel() { return channel; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountHTTP::recycle_channel -// Access: Public -// Description: Accepts an HTTPChannel that is no longer being used, -// and restores it to standby duty, so that it will be -// returned by a future call to get_channel(). -//////////////////////////////////////////////////////////////////// +/** + * Accepts an HTTPChannel that is no longer being used, and restores it to + * standby duty, so that it will be returned by a future call to + * get_channel(). + */ void VirtualFileMountHTTP:: recycle_channel(HTTPChannel *channel) { _channels_lock.acquire(); diff --git a/panda/src/downloader/virtualFileMountHTTP.h b/panda/src/downloader/virtualFileMountHTTP.h index 37281140bc..0759d35fdd 100644 --- a/panda/src/downloader/virtualFileMountHTTP.h +++ b/panda/src/downloader/virtualFileMountHTTP.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMountHTTP.h -// Created by: drose (30Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountHTTP.h + * @author drose + * @date 2008-10-30 + */ #ifndef VIRTUALFILEMOUNTHTTP_H #define VIRTUALFILEMOUNTHTTP_H @@ -26,11 +25,9 @@ #include "pointerTo.h" #include "mutexImpl.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMountHTTP -// Description : Maps a web page (URL root) into the -// VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Maps a web page (URL root) into the VirtualFileSystem. + */ class EXPCL_PANDAEXPRESS VirtualFileMountHTTP : public VirtualFileMount { PUBLISHED: VirtualFileMountHTTP(const URLSpec &root, HTTPClient *http = HTTPClient::get_global_ptr()); @@ -43,7 +40,7 @@ PUBLISHED: public: virtual PT(VirtualFile) make_virtual_file(const Filename &local_filename, - const Filename &original_filename, + const Filename &original_filename, bool implicit_pz_file, int open_flags); @@ -56,7 +53,7 @@ public: virtual streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const; virtual void output(ostream &out) const; diff --git a/panda/src/downloadertools/apply_patch.cxx b/panda/src/downloadertools/apply_patch.cxx index 8e66e471d3..105064f3c9 100644 --- a/panda/src/downloadertools/apply_patch.cxx +++ b/panda/src/downloadertools/apply_patch.cxx @@ -1,16 +1,13 @@ -// Filename: apply_patch.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file apply_patch.cxx + */ #include "pandabase.h" #include "pystub.h" diff --git a/panda/src/downloadertools/build_patch.cxx b/panda/src/downloadertools/build_patch.cxx index c1789c97a1..a107c45ad6 100644 --- a/panda/src/downloadertools/build_patch.cxx +++ b/panda/src/downloadertools/build_patch.cxx @@ -1,16 +1,13 @@ -// Filename: build_patch.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file build_patch.cxx + */ #include "pandabase.h" #include "pystub.h" @@ -19,7 +16,7 @@ #include "patchfile.h" #include "filename.h" -void +void usage() { cerr << "Usage: build_patch [opts] " << endl; } @@ -61,7 +58,7 @@ main(int argc, char **argv) { bool complete_file = false; int footprint_length = 0; - // extern char *optarg; + // extern char *optarg; extern int optind; static const char *optflags = "o:cf:h"; preprocess_argv(argc, argv); diff --git a/panda/src/downloadertools/check_adler.cxx b/panda/src/downloadertools/check_adler.cxx index 04e058b5dd..8c98b4c3d6 100644 --- a/panda/src/downloadertools/check_adler.cxx +++ b/panda/src/downloadertools/check_adler.cxx @@ -1,16 +1,13 @@ -// Filename: check_adler.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file check_adler.cxx + */ #include "download_utils.h" #include "pystub.h" diff --git a/panda/src/downloadertools/check_crc.cxx b/panda/src/downloadertools/check_crc.cxx index 9105e38a76..49313f818b 100644 --- a/panda/src/downloadertools/check_crc.cxx +++ b/panda/src/downloadertools/check_crc.cxx @@ -1,16 +1,13 @@ -// Filename: check_crc.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file check_crc.cxx + */ #include "download_utils.h" #include "pystub.h" diff --git a/panda/src/downloadertools/check_md5.cxx b/panda/src/downloadertools/check_md5.cxx index 35f365df54..c706d4fb2a 100644 --- a/panda/src/downloadertools/check_md5.cxx +++ b/panda/src/downloadertools/check_md5.cxx @@ -1,16 +1,13 @@ -// Filename: check_md5.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file check_md5.cxx + */ #include "pandabase.h" #include "pystub.h" @@ -25,7 +22,7 @@ pofstream binary_output; void usage() { - cerr << + cerr << "\n" "Usage:\n\n" "check_md5 [-q] [-d] [-b filename] [-i \"input string\"] [file1 file2 ...]\n" @@ -35,7 +32,7 @@ usage() { void help() { usage(); - cerr << + cerr << "This program outputs the MD5 hash of one or more files (or of a string\n" "passed on the command line with -i).\n\n" @@ -43,7 +40,7 @@ help() { "hexadecimal string by default, but with -d, it is presented as four\n" "big-endian unsigned 32-bit decimal integers. Normally the filename\n" "of each file is printed along with the hash; -q suppresses this.\n\n" - + "To write the 16 bytes (per input file) of the output directly to a\n" "binary file, use -b with the name of the file to receive the output.\n"; } @@ -60,11 +57,11 @@ output_hash(const string &filename, const HashVal &hash) { } cout << "\n"; - // Also output to the binary_output file if it is open. No sweat if - // it's not. + // Also output to the binary_output file if it is open. No sweat if it's + // not. hash.output_binary(binary_output); } - + int main(int argc, char **argv) { diff --git a/panda/src/downloadertools/multify.cxx b/panda/src/downloadertools/multify.cxx index 460c34b9a5..8caaa80736 100644 --- a/panda/src/downloadertools/multify.cxx +++ b/panda/src/downloadertools/multify.cxx @@ -1,16 +1,13 @@ -// Filename: multify.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multify.cxx + */ #include "pandabase.h" #include "pystub.h" @@ -58,18 +55,15 @@ string text_ext_str = "txt"; bool got_record_timestamp_flag = false; bool record_timestamp_flag = true; -//////////////////////////////////////////////////////////////////// -// Function: string_to_int -// Description: A string-interface wrapper around the C library -// strtol(). This parses the ASCII representation of an -// integer, and then sets tail to everything that -// follows the first valid integer read. If, on exit, -// str == tail, there was no valid integer in the -// source string; if !tail.empty(), there was garbage -// after the integer. -// -// It is legal if str and tail refer to the same string. -//////////////////////////////////////////////////////////////////// +/** + * A string-interface wrapper around the C library strtol(). This parses the + * ASCII representation of an integer, and then sets tail to everything that + * follows the first valid integer read. If, on exit, str == tail, there was + * no valid integer in the source string; if !tail.empty(), there was garbage + * after the integer. + * + * It is legal if str and tail refer to the same string. + */ static int string_to_int(const string &str, string &tail) { const char *nptr = str.c_str(); @@ -79,12 +73,11 @@ string_to_int(const string &str, string &tail) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: string_to_int -// Description: Another flavor of string_to_int(), this one returns -// true if the string is a perfectly valid integer (and -// sets result to that value), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Another flavor of string_to_int(), this one returns true if the string is a + * perfectly valid integer (and sets result to that value), or false + * otherwise. + */ static bool string_to_int(const string &str, int &result) { string tail; @@ -92,13 +85,13 @@ string_to_int(const string &str, int &result) { return tail.empty(); } -void +void usage() { cerr << "Usage: multify -[c|r|u|t|x] -f [options] ...\n"; } -void +void help() { usage(); cerr << "\n" @@ -114,7 +107,7 @@ help() { "for tar, the traditional Unix archiver utility.\n\n" "Options:\n\n" - + " You must specify exactly one of the following command switches:\n\n" " -c\n" @@ -262,8 +255,8 @@ get_password() { bool is_named(const string &subfile_name, const vector_string ¶ms) { - // Returns true if the indicated subfile appears on the list of - // files named on the command line. + // Returns true if the indicated subfile appears on the list of files named + // on the command line. if (params.empty()) { // No named files; everything is listed. return true; @@ -281,8 +274,8 @@ is_named(const string &subfile_name, const vector_string ¶ms) { bool is_text(const Filename &subfile_name) { - // Returns true if this filename should be read as a text file, - // false otherwise. + // Returns true if this filename should be read as a text file, false + // otherwise. string ext = subfile_name.get_extension(); if (text_ext.find(ext) != text_ext.end()) { @@ -303,8 +296,7 @@ get_compression_level(const Filename &subfile_name) { string ext = subfile_name.get_extension(); if (dont_compress.find(ext) != dont_compress.end()) { - // This extension is listed on the -Z parameter list; don't - // compress it. + // This extension is listed on the -Z parameter list; don't compress it. return 0; } @@ -392,7 +384,7 @@ add_files(const vector_string ¶ms) { return false; } } - + if (got_record_timestamp_flag) { multifile->set_record_timestamp(record_timestamp_flag); } @@ -463,8 +455,8 @@ extract_files(const vector_string ¶ms) { int num_subfiles = multifile->get_num_subfiles(); // First, check to see whether any of the named subfiles have been - // encrypted. If any have, we may need to prompt the user to enter - // a password before we can extract them. + // encrypted. If any have, we may need to prompt the user to enter a + // password before we can extract them. int i; bool any_encrypted = false; for (i = 0; i < num_subfiles && !any_encrypted; i++) { @@ -560,8 +552,8 @@ sign_multifile() { return false; #else // HAVE_OPENSSL - // Re-open the Multifile, and sign it with the indicated certificate - // and key files. + // Re-open the Multifile, and sign it with the indicated certificate and key + // files. PT(Multifile) multifile = new Multifile; if (!multifile->open_read_write(multifile_name)) { cerr << "Unable to re-open " << multifile_name << " for signing.\n"; @@ -597,7 +589,7 @@ sign_multifile() { if (!multifile->add_signature(certificate, chain, pkey, password)) { return false; } - } + } return true; #endif // HAVE_OPENSSL @@ -612,7 +604,7 @@ format_timestamp(bool record_timestamp, time_t timestamp) { // No timestamps. return ""; } - + if (timestamp == 0) { // A zero timestamp is a special case. return " (no date) "; @@ -622,8 +614,8 @@ format_timestamp(bool record_timestamp, time_t timestamp) { struct tm *tm_p = localtime(×tamp); if (timestamp > now || (now - timestamp > 86400 * 365)) { - // A timestamp in the future, or more than a year in the past, - // gets a year appended. + // A timestamp in the future, or more than a year in the past, gets a year + // appended. strftime(buffer, buffer_size, "%b %d %Y", tm_p); } else { // Otherwise, within the past year, show the date and time. @@ -646,7 +638,7 @@ list_files(const vector_string ¶ms) { } int num_subfiles = multifile->get_num_subfiles(); - + int i; if (verbose) { cout << num_subfiles << " subfiles:\n" << flush; @@ -678,14 +670,14 @@ list_files(const vector_string ¶ms) { } else { printf("%12d %3.0f%% %c%c %s %s\n", (int)multifile->get_subfile_length(i), - 100.0 - ratio * 100.0, + 100.0 - ratio * 100.0, encrypted_symbol, text_symbol, format_timestamp(multifile->get_record_timestamp(), multifile->get_subfile_timestamp(i)), subfile_name.c_str()); } } else { - printf("%12d %c%c %s %s\n", + printf("%12d %c%c %s %s\n", (int)multifile->get_subfile_length(i), encrypted_symbol, text_symbol, format_timestamp(multifile->get_record_timestamp(), @@ -697,7 +689,7 @@ list_files(const vector_string ¶ms) { fflush(stdout); if (multifile->get_record_timestamp()) { - cout << "Last modification " + cout << "Last modification " << format_timestamp(true, multifile->get_timestamp()) << "\n"; } @@ -765,8 +757,8 @@ main(int argc, char **argv) { return 1; } - // To emulate tar, we assume an implicit hyphen in front of the - // first argument if there is not one already. + // To emulate tar, we assume an implicit hyphen in front of the first + // argument if there is not one already. if (argc >= 2) { if (*argv[1] != '-' && *argv[1] != '\0') { char *new_arg = (char *)PANDA_MALLOC_ARRAY(strlen(argv[1]) + 2); diff --git a/panda/src/downloadertools/pdecrypt.cxx b/panda/src/downloadertools/pdecrypt.cxx index 9da4a3b252..55791f14c3 100644 --- a/panda/src/downloadertools/pdecrypt.cxx +++ b/panda/src/downloadertools/pdecrypt.cxx @@ -1,16 +1,15 @@ -// Filename: pdecrypt.cxx -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pdecrypt.cxx + * @author drose + * @date 2004-09-01 + */ #include "pystub.h" #include "filename.h" @@ -22,14 +21,14 @@ string password; bool got_password = false; -void +void usage() { cerr << "\nUsage:\n" << " pdecrypt file.pe [file2.pe file3.pe ...]\n" << " pdecrypt -o dest_file file.pe\n\n" << "\n" - + << "This program reverses the operation of a previous pencrypt command. It\n" << "decrypts the contents of the named source file(s) and removes the .pe\n" << "extension. The encryption algorithm need not be specified; it can be\n" @@ -39,7 +38,7 @@ usage() { << "if no error is reported.\n\n" << "Options:\n\n" - + << " -p \"password\"\n" << " Specifies the password to use for decryption. If this is not specified,\n" << " the user is prompted from standard input.\n\n"; @@ -98,7 +97,7 @@ main(int argc, char **argv) { for (int i = 1; i < argc; i++) { Filename source_file = Filename::from_os_specific(argv[i]); if (!got_dest_filename && source_file.get_extension() != "pe") { - cerr << source_file + cerr << source_file << " doesn't end in .pe; can't derive filename of output file.\n"; all_ok = false; @@ -133,15 +132,15 @@ main(int argc, char **argv) { cerr << dest_file << "\n"; bool success = decrypt_stream(read_stream, write_stream, password); - + read_stream.close(); write_stream.close(); - + if (!success) { cerr << "Failure decrypting " << source_file << "\n"; all_ok = false; dest_file.unlink(); - + } else { if (!got_dest_filename) { source_file.unlink(); diff --git a/panda/src/downloadertools/pencrypt.cxx b/panda/src/downloadertools/pencrypt.cxx index 59b969b7c1..d37cd64a48 100644 --- a/panda/src/downloadertools/pencrypt.cxx +++ b/panda/src/downloadertools/pencrypt.cxx @@ -1,16 +1,15 @@ -// Filename: pencrypt.cxx -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pencrypt.cxx + * @author drose + * @date 2004-09-01 + */ #include "pystub.h" #include "filename.h" @@ -28,13 +27,13 @@ bool got_key_length = false; int iteration_count = -1; bool got_iteration_count = false; -void +void usage() { cerr << "\nUsage:\n" << " pencrypt [opts] file [file2 file3 ...]\n" << " pencrypt -o dest_file file\n\n" - + << "This program will apply an encryption algorithm to a file (or multiple files),\n" << "creating an encrypted version of each file which can only be recovered using\n" << "pdecrypt and the same password that was supplied to pencrypt. The compressed\n" @@ -190,15 +189,15 @@ main(int argc, char **argv) { cerr << dest_file << "\n"; bool success = encrypt_stream(read_stream, write_stream, password, algorithm, key_length, iteration_count); - + read_stream.close(); write_stream.close(); - + if (!success) { cerr << "Failure writing " << dest_file << "\n"; all_ok = false; dest_file.unlink(); - + } else { if (!got_dest_filename) { source_file.unlink(); diff --git a/panda/src/downloadertools/punzip.cxx b/panda/src/downloadertools/punzip.cxx index 381608d1f5..82d3693522 100644 --- a/panda/src/downloadertools/punzip.cxx +++ b/panda/src/downloadertools/punzip.cxx @@ -1,16 +1,13 @@ -// Filename: punzip.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file punzip.cxx + */ #include "pystub.h" #include "filename.h" @@ -26,7 +23,7 @@ usage() { << " punzip file.pz [file2.pz file3.pz ...]\n" << " punzip -c dest_file\n" << " punzip -o dest_file file.pz\n\n" - + << "This program reverses the operation of a previous pzip command. It\n" << "uncompresses the contents of the named source file(s) and removes the .pz\n" << "extension.\n\n"; @@ -99,7 +96,7 @@ main(int argc, char **argv) { for (int i = 1; i < argc; i++) { Filename source_file = Filename::from_os_specific(argv[i]); if (!got_dest_filename && source_file.get_extension() != "pz") { - cerr << source_file + cerr << source_file << " doesn't end in .pz; can't derive filename of output file.\n"; all_ok = false; @@ -127,15 +124,15 @@ main(int argc, char **argv) { } else { cerr << dest_file << "\n"; bool success = decompress_stream(read_stream, write_stream); - + read_stream.close(); write_stream.close(); - + if (!success) { cerr << "Failure decompressing " << source_file << "\n"; all_ok = false; dest_file.unlink(); - + } else { if (!got_dest_filename) { source_file.unlink(); diff --git a/panda/src/downloadertools/pzip.cxx b/panda/src/downloadertools/pzip.cxx index 07332af600..25eb02ac7c 100644 --- a/panda/src/downloadertools/pzip.cxx +++ b/panda/src/downloadertools/pzip.cxx @@ -1,16 +1,13 @@ -// Filename: pzip.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pzip.cxx + */ #include "pystub.h" #include "filename.h" @@ -34,7 +31,7 @@ usage() { << "filename, and the original file is removed (unless the version with\n" << "-o is used, in which case you can compress only one file, you specify\n" << "the destination file name, and the original file is not removed).\n\n" - + << "In many cases, Panda can read the resulting .pz file directly,\n" << "exactly as if it were still in its uncompressed original form.\n" << "In fact, unless vfs-implicit-pz is set to false in your Config.prc\n" @@ -53,7 +50,7 @@ usage() { << " -1 compress faster\n" << " -6 compress default\n" << " -9 compress better (intermediate compression levels supported also)\n\n"; - + } int @@ -185,15 +182,15 @@ main(int argc, char **argv) { } else { cerr << dest_file << "\n"; bool success = compress_stream(read_stream, write_stream, compression_level); - + read_stream.close(); write_stream.close(); - + if (!success) { cerr << "Failure writing " << dest_file << "\n"; all_ok = false; dest_file.unlink(); - + } else { if (!got_dest_filename) { source_file.unlink(); diff --git a/panda/src/downloadertools/show_ddb.cxx b/panda/src/downloadertools/show_ddb.cxx index 92095738cd..6d82df7f02 100644 --- a/panda/src/downloadertools/show_ddb.cxx +++ b/panda/src/downloadertools/show_ddb.cxx @@ -1,16 +1,15 @@ -// Filename: show_ddb.cxx -// Created by: drose (02Nov02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file show_ddb.cxx + * @author drose + * @date 2002-11-02 + */ #include "pandabase.h" #include "pystub.h" diff --git a/panda/src/dxgsg9/config_dxgsg9.cxx b/panda/src/dxgsg9/config_dxgsg9.cxx index d614fa9608..64831d08c9 100644 --- a/panda/src/dxgsg9/config_dxgsg9.cxx +++ b/panda/src/dxgsg9/config_dxgsg9.cxx @@ -1,16 +1,15 @@ -// Filename: config_dxgsg9.cxx -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dxgsg9.cxx + * @author drose + * @date 1999-10-06 + */ #include "config_dxgsg9.h" #include "dxGraphicsStateGuardian9.h" @@ -32,17 +31,19 @@ DToolConfigure(config_dxgsg9); NotifyCategoryDef(dxgsg9, ":display:gsg"); NotifyCategoryDef(wdxdisplay9, "display"); -// Configure this variable true to cause the DXGSG to show each -// transform space it renders by drawing a little unit axis. This -// cannot be enabled when the player is compiled in NDEBUG mode. +// Configure this variable true to cause the DXGSG to show each transform +// space it renders by drawing a little unit axis. This cannot be enabled +// when the player is compiled in NDEBUG mode. ConfigVariableBool dx_show_transforms ("dx-show-transforms", false); -// if true, if card only supports per-vertex fog, it will be treated as no-HW fog capability +// if true, if card only supports per-vertex fog, it will be treated as no-HW +// fog capability ConfigVariableBool dx_no_vertex_fog ("dx-no-vertex-fog", false); -// if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI cursor +// if true, overwrite cursor bitmap tip with "D3D" to distinguish it from GDI +// cursor ConfigVariableBool dx_show_cursor_watermark ("dx-show-cursor-watermark", #ifdef _DEBUG @@ -52,7 +53,8 @@ ConfigVariableBool dx_show_cursor_watermark #endif ); -// if true, triangle filter will be used to generate mipmap levels instead of default box filter +// if true, triangle filter will be used to generate mipmap levels instead of +// default box filter ConfigVariableBool dx_use_triangle_mipgen_filter ("dx-use-triangle-mipgen-filter", false); @@ -89,8 +91,8 @@ ConfigVariableBool dx_count_all_cards_memory "via DX7 calls.")); #ifndef NDEBUG -// debugging flag -// values are same as D3DCULL enumtype, 0 - no force, 1 - force none, 2 - force CW, 3 - force CCW +// debugging flag values are same as D3DCULL enumtype, 0 - no force, 1 - force +// none, 2 - force CW, 3 - force CCW ConfigVariableInt dx_force_backface_culling ("dx-force-backface-culling", 0); #endif @@ -100,7 +102,8 @@ ConfigVariableBool dx_mipmap_everything ConfigVariableBool dx_ignore_mipmaps ("dx-ignore-mipmaps", false); -// if this is set, more accurate but more expensive fog computations are performed +// if this is set, more accurate but more expensive fog computations are +// performed ConfigVariableBool dx_use_rangebased_fog ("dx-use-rangebased-fog", false); ConfigVariableBool dx_no_dithering @@ -109,12 +112,12 @@ ConfigVariableBool dx_force_16bpp_zbuffer ("dx-force-16bpp-zbuffer", false); ConfigVariableBool dx_do_vidmemsize_check ("do-vidmemsize-check", true); -// Setting this true theoretically hinders render performance, because -// it forces the FPU to go through some extra work to clean itself up -// after rendering a frame, but the performance cost seems to be -// small. On the other hand, setting it false can force the -// application to run in single-precision arithmetic mode, even if -// it believes it is using double-precision variables. +// Setting this true theoretically hinders render performance, because it +// forces the FPU to go through some extra work to clean itself up after +// rendering a frame, but the performance cost seems to be small. On the +// other hand, setting it false can force the application to run in single- +// precision arithmetic mode, even if it believes it is using double-precision +// variables. ConfigVariableBool dx_preserve_fpu_state ("dx-preserve-fpu-state", true); @@ -140,37 +143,34 @@ ConfigVariableBool dx_debug_view_mipmaps ConfigVariableBool dx_force_anisotropic_filtering ("dx-force-anisotropic-filtering", false); -// set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom -// together using degenerate tris +// set 'retained-mode #t' and this to have prepare_geom concatenate all +// tristrips within a geom together using degenerate tris ConfigVariableBool link_tristrips ("link-tristrips", false); -// true = use DirectX management of video memory -// false = see dx_lru_management config variable below +// true = use DirectX management of video memory false = see dx_lru_management +// config variable below ConfigVariableBool dx_management ("dx-management", false); -// valid only if dx_management == false -// true = use DirectX management of texture memory -// false = lru will manage texture memory +// valid only if dx_management == false true = use DirectX management of +// texture memory false = lru will manage texture memory ConfigVariableBool dx_texture_management ("dx-texture-management", true); -// valid only if dx_management == false -// true = enable LRU management of video memory -// false = no video memory management +// valid only if dx_management == false true = enable LRU management of video +// memory false = no video memory management ConfigVariableBool dx_lru_management ("dx-lru-management", true); -// number of LRU pages to pre-allocate -// if the maximum number of pages is used up, -// then LRU pages will be dynamically allocated/freed +// number of LRU pages to pre-allocate if the maximum number of pages is used +// up, then LRU pages will be dynamically allocatedfreed ConfigVariableInt dx_lru_maximum_pages ("dx-lru-maximum-pages", 8192); -// the amount of video memory the LRU will try not to use -// this will allow DirectX some space in case of memory fragmentation, ... -// this does not apply if dx_lru_minimum_memory_requirement is not met +// the amount of video memory the LRU will try not to use this will allow +// DirectX some space in case of memory fragmentation, ... this does not apply +// if dx_lru_minimum_memory_requirement is not met ConfigVariableInt dx_lru_free_memory_requirement ("dx-lru-free-memory-requirement", 12000000); @@ -178,30 +178,30 @@ ConfigVariableInt dx_lru_free_memory_requirement ConfigVariableInt dx_lru_minimum_memory_requirement ("dx-lru-minimum-memory-requirement", 64000000); -// used to cap the amount of video memory used -// 0 = use all available DirectX video memory +// used to cap the amount of video memory used 0 = use all available DirectX +// video memory ConfigVariableInt dx_lru_maximum_memory_requirement ("dx-lru-maximum-memory-requirement", 0); -// the number of LRU pages the LRU will update per frame -// do not set this too high or it will degrade performance +// the number of LRU pages the LRU will update per frame do not set this too +// high or it will degrade performance ConfigVariableInt dx_lru_maximum_page_updates_per_frame ("dx-lru-maximum-page-updates-per-frame", 40); -// lru debug on/off +// lru debug onoff ConfigVariableBool dx_lru_debug ("dx-lru-debug", false); -// valid only if dx_lru_debug == true -// number of frames to wait until printing out the LRU status +// valid only if dx_lru_debug == true number of frames to wait until printing +// out the LRU status ConfigVariableInt dx_lru_debug_frames_til_output ("dx-lru-debug-frames-til-output", 500); -// valid only if dx_lru_debug == true +// valid only if dx_lru_debug == true ConfigVariableBool dx_lru_debug_textures ("dx-lru-debug-textures", false); -// valid only if dx_lru_debug == true +// valid only if dx_lru_debug == true ConfigVariableBool dx_lru_debug_vertex_buffers ("dx-lru-debug-vertex-buffers", false); @@ -232,14 +232,12 @@ ConfigureFn(config_dxgsg9) { init_libdxgsg9(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libdxgsg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdxgsg9() { static bool initialized = false; diff --git a/panda/src/dxgsg9/config_dxgsg9.h b/panda/src/dxgsg9/config_dxgsg9.h index df042f5682..d9079c3810 100644 --- a/panda/src/dxgsg9/config_dxgsg9.h +++ b/panda/src/dxgsg9/config_dxgsg9.h @@ -1,16 +1,15 @@ -// Filename: config_dxgsg9.h -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dxgsg9.h + * @author drose + * @date 1999-10-06 + */ #ifndef CONFIG_DXGSG9_H #define CONFIG_DXGSG9_H diff --git a/panda/src/dxgsg9/dxGeomMunger9.I b/panda/src/dxgsg9/dxGeomMunger9.I index f8da07223a..eee877c668 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.I +++ b/panda/src/dxgsg9/dxGeomMunger9.I @@ -1,23 +1,19 @@ -// Filename: dxGeomMunger9.I -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGeomMunger9.I + * @author drose + * @date 2005-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DXGeomMunger9:: DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : StandardMunger(gsg, state, 1, NT_packed_dabc, C_color), @@ -33,9 +29,8 @@ DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state) : _reffed_filtered_texture = true; } } - // Set a callback to unregister ourselves when either the Texture or - // the TexGen object gets deleted. + // Set a callback to unregister ourselves when either the Texture or the + // TexGen object gets deleted. _texture.set_callback(this); _tex_gen.set_callback(this); } - diff --git a/panda/src/dxgsg9/dxGeomMunger9.cxx b/panda/src/dxgsg9/dxGeomMunger9.cxx index 70b5ff8f47..aaadacb119 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.cxx +++ b/panda/src/dxgsg9/dxGeomMunger9.cxx @@ -1,16 +1,15 @@ -// Filename: dxGeomMunger9.cxx -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGeomMunger9.cxx + * @author drose + * @date 2005-03-11 + */ #include "dxGeomMunger9.h" #include "geomVertexReader.h" @@ -20,11 +19,9 @@ GeomMunger *DXGeomMunger9::_deleted_chain = NULL; TypeHandle DXGeomMunger9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXGeomMunger9:: ~DXGeomMunger9() { if (_reffed_filtered_texture) { @@ -33,14 +30,11 @@ DXGeomMunger9:: } } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::wp_callback -// Access: Public, Virtual -// Description: This callback is set to be made whenever the -// associated _texture or _tex_gen attributes are -// destructed, in which case the GeomMunger is invalid -// and should no longer be used. -//////////////////////////////////////////////////////////////////// +/** + * This callback is set to be made whenever the associated _texture or + * _tex_gen attributes are destructed, in which case the GeomMunger is invalid + * and should no longer be used. + */ void DXGeomMunger9:: wp_callback(void *) { unregister_myself(); @@ -51,12 +45,10 @@ wp_callback(void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::munge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) DXGeomMunger9:: munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &animation) { @@ -68,8 +60,7 @@ munge_format_impl(const GeomVertexFormat *orig, } } // We have to build a completely new format that includes only the - // appropriate components, in the appropriate order, in just one - // array. + // appropriate components, in the appropriate order, in just one array. PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig); new_format->set_animation(animation); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; @@ -92,23 +83,22 @@ munge_format_impl(const GeomVertexFormat *orig, if (animation.get_animation_type() == AT_hardware && animation.get_num_transforms() > 0) { if (animation.get_num_transforms() > 1) { - // If we want hardware animation, we need to reserve space for the - // blend weights. + // If we want hardware animation, we need to reserve space for the blend + // weights. new_array_format->add_column (InternalName::get_transform_weight(), animation.get_num_transforms() - 1, NT_float32, C_other); } if (animation.get_indexed_transforms()) { - // Also, if we'll be indexing into the transform table, reserve - // space for the index. + // Also, if we'll be indexing into the transform table, reserve space + // for the index. new_array_format->add_column (InternalName::get_transform_index(), 1, NT_packed_dcba, C_index); } - // Make sure the old weights and indices are removed, just in - // case. + // Make sure the old weights and indices are removed, just in case. new_format->remove_column(InternalName::get_transform_weight()); new_format->remove_column(InternalName::get_transform_index()); @@ -128,21 +118,19 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->remove_column(color_type->get_name()); } - // To support multitexture, we will need to add all of the relevant - // texcoord types, and in the order specified by the TextureAttrib. + // To support multitexture, we will need to add all of the relevant texcoord + // types, and in the order specified by the TextureAttrib. - // Now set up each of the active texture coordinate stages--or at - // least those for which we're not generating texture coordinates - // automatically. + // Now set up each of the active texture coordinate stages--or at least + // those for which we're not generating texture coordinates automatically. if (_filtered_texture != (TextureAttrib *)NULL) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); - // Be sure we add the texture coordinates in the right order, as - // specified by the attrib. To ensure this, we first walk through - // the stages of the attrib and get the index numbers in the - // appropriate order. + // Be sure we add the texture coordinates in the right order, as specified + // by the attrib. To ensure this, we first walk through the stages of the + // attrib and get the index numbers in the appropriate order. int si, tc_index; int max_tc_index = -1; for (si = 0; si < num_stages; ++si) { @@ -152,9 +140,9 @@ munge_format_impl(const GeomVertexFormat *orig, max_tc_index = max(tc_index, max_tc_index); } - // Now walk through the texture coordinates in the order they will - // appear on the final geometry. For each one, get the texture - // coordinate name from the associated stage. + // Now walk through the texture coordinates in the order they will appear + // on the final geometry. For each one, get the texture coordinate name + // from the associated stage. for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) { si = ff_tc_index[tc_index]; TextureStage *stage = _filtered_texture->get_on_ff_stage(si); @@ -166,16 +154,16 @@ munge_format_impl(const GeomVertexFormat *orig, new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { - // We have to add something as a placeholder, even if the - // texture coordinates aren't defined. + // We have to add something as a placeholder, even if the texture + // coordinates aren't defined. new_array_format->add_column(name, 2, NT_float32, C_texcoord); } new_format->remove_column(name); } } - // Now go through the remaining arrays and make sure they are - // tightly packed. If not, repack them. + // Now go through the remaining arrays and make sure they are tightly + // packed. If not, repack them. for (int i = 0; i < new_format->get_num_arrays(); ++i) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { @@ -189,24 +177,20 @@ munge_format_impl(const GeomVertexFormat *orig, } } - // Make sure the FVF-style array we just built up is first in the - // list. + // Make sure the FVF-style array we just built up is first in the list. new_format->insert_array(0, new_array_format); return GeomVertexFormat::register_format(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::premunge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) DXGeomMunger9:: premunge_format_impl(const GeomVertexFormat *orig) { // We have to build a completely new format that includes only the - // appropriate components, in the appropriate order, in just one - // array. + // appropriate components, in the appropriate order, in just one array. PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; @@ -237,21 +221,19 @@ premunge_format_impl(const GeomVertexFormat *orig) { new_format->remove_column(color_type->get_name()); } - // To support multitexture, we will need to add all of the relevant - // texcoord types, and in the order specified by the TextureAttrib. + // To support multitexture, we will need to add all of the relevant texcoord + // types, and in the order specified by the TextureAttrib. - // Now set up each of the active texture coordinate stages--or at - // least those for which we're not generating texture coordinates - // automatically. + // Now set up each of the active texture coordinate stages--or at least + // those for which we're not generating texture coordinates automatically. if (_filtered_texture != (TextureAttrib *)NULL) { int num_stages = _filtered_texture->get_num_on_ff_stages(); vector_int ff_tc_index(num_stages, 0); - // Be sure we add the texture coordinates in the right order, as - // specified by the attrib. To ensure this, we first walk through - // the stages of the attrib and get the index numbers in the - // appropriate order. + // Be sure we add the texture coordinates in the right order, as specified + // by the attrib. To ensure this, we first walk through the stages of the + // attrib and get the index numbers in the appropriate order. int si, tc_index; int max_tc_index = -1; for (si = 0; si < num_stages; ++si) { @@ -261,9 +243,9 @@ premunge_format_impl(const GeomVertexFormat *orig) { max_tc_index = max(tc_index, max_tc_index); } - // Now walk through the texture coordinates in the order they will - // appear on the final geometry. For each one, get the texture - // coordinate name from the associated stage. + // Now walk through the texture coordinates in the order they will appear + // on the final geometry. For each one, get the texture coordinate name + // from the associated stage. for (tc_index = 0; tc_index <= max_tc_index; ++tc_index) { si = ff_tc_index[tc_index]; TextureStage *stage = _filtered_texture->get_on_ff_stage(si); @@ -275,16 +257,16 @@ premunge_format_impl(const GeomVertexFormat *orig) { new_array_format->add_column (name, texcoord_type->get_num_values(), NT_float32, C_texcoord); } else { - // We have to add something as a placeholder, even if the - // texture coordinates aren't defined. + // We have to add something as a placeholder, even if the texture + // coordinates aren't defined. new_array_format->add_column(name, 2, NT_float32, C_texcoord); } new_format->remove_column(name); } } - // Now go through the remaining arrays and make sure they are - // tightly packed. If not, repack them. + // Now go through the remaining arrays and make sure they are tightly + // packed. If not, repack them. for (int i = 0; i < new_format->get_num_arrays(); ++i) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { @@ -298,21 +280,17 @@ premunge_format_impl(const GeomVertexFormat *orig) { } } - // Make sure the FVF-style array we just built up is first in the - // list. + // Make sure the FVF-style array we just built up is first in the list. new_format->insert_array(0, new_array_format); return GeomVertexFormat::register_format(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int DXGeomMunger9:: compare_to_impl(const GeomMunger *other) const { const DXGeomMunger9 *om = DCAST(DXGeomMunger9, other); @@ -326,20 +304,16 @@ compare_to_impl(const GeomMunger *other) const { return StandardMunger::compare_to_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: DXGeomMunger9::geom_compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int DXGeomMunger9:: geom_compare_to_impl(const GeomMunger *other) const { - // Unlike GLGeomMunger, we do consider _filtered_texture and - // _tex_gen important for this purpose, since they control the - // number and order of texture coordinates we might put into the - // FVF. + // Unlike GLGeomMunger, we do consider _filtered_texture and _tex_gen + // important for this purpose, since they control the number and order of + // texture coordinates we might put into the FVF. const DXGeomMunger9 *om = DCAST(DXGeomMunger9, other); if (_filtered_texture != om->_filtered_texture) { return _filtered_texture < om->_filtered_texture ? -1 : 1; diff --git a/panda/src/dxgsg9/dxGeomMunger9.h b/panda/src/dxgsg9/dxGeomMunger9.h index 0a7d08c8a8..c0762e3cf3 100644 --- a/panda/src/dxgsg9/dxGeomMunger9.h +++ b/panda/src/dxgsg9/dxGeomMunger9.h @@ -1,16 +1,15 @@ -// Filename: dxGeomMunger9.h -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGeomMunger9.h + * @author drose + * @date 2005-03-11 + */ #ifndef DXGEOMMUNGER9_H #define DXGEOMMUNGER9_H @@ -21,14 +20,12 @@ #include "weakPointerTo.h" #include "weakPointerCallback.h" -//////////////////////////////////////////////////////////////////// -// Class : DXGeomMunger9 -// Description : This specialization on GeomMunger finesses vertices -// for DirectX rendering. In particular, it makes sure -// colors are stored in DirectX's packed_argb format, -// and that all relevant components are packed into a -// single array, in the correct order. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on GeomMunger finesses vertices for DirectX rendering. + * In particular, it makes sure colors are stored in DirectX's packed_argb + * format, and that all relevant components are packed into a single array, in + * the correct order. + */ class EXPCL_PANDADX DXGeomMunger9 : public StandardMunger, public WeakPointerCallback { public: INLINE DXGeomMunger9(GraphicsStateGuardian *gsg, const RenderState *state); @@ -49,11 +46,10 @@ private: WCPT(TextureAttrib) _texture; WCPT(TexGenAttrib) _tex_gen; - // This pointer is derived from _texture, above. In the case that - // it is a different pointer, we maintain its reference count - // explicitly. If it is the same pointer, we don't reference count - // it at all (so we won't hold on to the reference count - // unnecessarily). + // This pointer is derived from _texture, above. In the case that it is a + // different pointer, we maintain its reference count explicitly. If it is + // the same pointer, we don't reference count it at all (so we won't hold on + // to the reference count unnecessarily). const TextureAttrib *_filtered_texture; bool _reffed_filtered_texture; @@ -80,4 +76,3 @@ private: #include "dxGeomMunger9.I" #endif - diff --git a/panda/src/dxgsg9/dxGraphicsDevice9.cxx b/panda/src/dxgsg9/dxGraphicsDevice9.cxx index e50a6bbda5..6e79bb3c98 100644 --- a/panda/src/dxgsg9/dxGraphicsDevice9.cxx +++ b/panda/src/dxgsg9/dxGraphicsDevice9.cxx @@ -1,26 +1,23 @@ -// Filename: dxGraphicsDevice9.cxx -// Created by: masad (22Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGraphicsDevice9.cxx + * @author masad + * @date 2003-07-22 + */ #include "config_dxgsg9.h" #include "dxGraphicsDevice9.h" -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsDevice9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXGraphicsDevice9:: DXGraphicsDevice9(wdxGraphicsPipe9 *pipe) : GraphicsDevice(pipe) { @@ -30,11 +27,9 @@ DXGraphicsDevice9(wdxGraphicsPipe9 *pipe) : _swap_chain = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsDevice9::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXGraphicsDevice9:: ~DXGraphicsDevice9() { } diff --git a/panda/src/dxgsg9/dxGraphicsDevice9.h b/panda/src/dxgsg9/dxGraphicsDevice9.h index 3b0710617e..25180170d0 100644 --- a/panda/src/dxgsg9/dxGraphicsDevice9.h +++ b/panda/src/dxgsg9/dxGraphicsDevice9.h @@ -1,32 +1,29 @@ -// Filename: dxGraphicsDevice9.h -// Created by: masad (22Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGraphicsDevice9.h + * @author masad + * @date 2003-07-22 + */ #ifndef DXGRAPHICSDEVICE_H #define DXGRAPHICSDEVICE_H -//#define GSG_VERBOSE 1 +// #define GSG_VERBOSE 1 #include "dxgsg9base.h" #include "graphicsDevice.h" #include "wdxGraphicsPipe9.h" -//////////////////////////////////////////////////////////////////// -// Class : DXGraphicsDevice9 -// Description : A GraphicsDevice necessary for multi-window rendering -// in DX. -//////////////////////////////////////////////////////////////////// +/** + * A GraphicsDevice necessary for multi-window rendering in DX. + */ class EXPCL_PANDADX DXGraphicsDevice9 : public GraphicsDevice { friend class wdxGraphicsPipe9; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I index 36e54ee69d..7b5133ccf4 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.I +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.I @@ -1,32 +1,29 @@ -// Filename: dxGraphicsStateGuardian9.I -// Created by: mike (02Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGraphicsStateGuardian9.I + * @author mike + * @date 1999-02-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::LColor_to_D3DCOLOR -// Access: Public, Static -// Description: Converts Panda's floating-point LColor structure to -// DirectX's D3DCOLOR packed structure. -//////////////////////////////////////////////////////////////////// +/** + * Converts Panda's floating-point LColor structure to DirectX's D3DCOLOR + * packed structure. + */ INLINE DWORD DXGraphicsStateGuardian9:: LColor_to_D3DCOLOR(const LColor &cLColor) { // MS VC defines _M_IX86 for x86. gcc should define _X86_ #if (defined(_M_IX86) || defined(_X86_)) && !defined(STDFLOAT_DOUBLE) DWORD d3dcolor, tempcolorval=255; - // note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as VC would force it to by resetting rounding mode - // don't think this makes much difference + // note the default FPU rounding mode will give 255*0.5f=0x80, not 0x7F as + // VC would force it to by resetting rounding mode don't think this makes + // much difference __asm { push ebx ; want to save this in case this fn is inlined @@ -65,19 +62,16 @@ LColor_to_D3DCOLOR(const LColor &cLColor) { pop ebx } - // dxgsg9_cat.debug() << (void*)d3dcolor << endl; + // dxgsg9_cat.debug() << (void*)d3dcolor << endl; return d3dcolor; #else //!_X86_ return D3DCOLOR_COLORVALUE(cLColor[0], cLColor[1], cLColor[2], cLColor[3]); #endif //!_X86_ } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_texture_wrap_mode -// Access: Protected, Static -// Description: Maps from the Texture's internal wrap mode symbols to -// GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's internal wrap mode symbols to GL's. + */ INLINE D3DTEXTUREADDRESS DXGraphicsStateGuardian9:: get_texture_wrap_mode(SamplerState::WrapMode wm) { switch (wm) { @@ -96,11 +90,9 @@ get_texture_wrap_mode(SamplerState::WrapMode wm) { return D3DTADDRESS_WRAP; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_fog_mode_type -// Access: Protected, Static -// Description: Maps from the fog types to gl version -//////////////////////////////////////////////////////////////////// +/** + * Maps from the fog types to gl version + */ INLINE D3DFOGMODE DXGraphicsStateGuardian9:: get_fog_mode_type(Fog::Mode m) { switch (m) { @@ -115,29 +107,25 @@ get_fog_mode_type(Fog::Mode m) { return D3DFOG_EXP; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_tex_mat_sym -// Access: Protected, Static -// Description: Returns the nth D3DTS_TEXTURE(n) constant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth D3DTS_TEXTURE(n) constant. + */ INLINE D3DTRANSFORMSTATETYPE DXGraphicsStateGuardian9:: get_tex_mat_sym(int stage_index) { return (D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0 + stage_index); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_safe_buffer_start -// Access: Protected, Static -// Description: Returns the address of a 64K buffer that is allocated -// at the beginning of a 64K block. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of a 64K buffer that is allocated at the beginning of a + * 64K block. + */ INLINE unsigned char *DXGraphicsStateGuardian9:: get_safe_buffer_start() { if (_temp_buffer == NULL) { - // Guarantee we get a buffer of size 0x10000 bytes that begins - // on an even multiple of 0x10000. We do this by allocating - // double the required buffer, and then pointing to the first - // multiple of 0x10000 within that buffer. + // Guarantee we get a buffer of size 0x10000 bytes that begins on an even + // multiple of 0x10000. We do this by allocating double the required + // buffer, and then pointing to the first multiple of 0x10000 within that + // buffer. _temp_buffer = new unsigned char[0x1ffff]; _safe_buffer_start = (unsigned char *)(((long)_temp_buffer + 0xffff) & ~0xffff); } @@ -147,13 +135,10 @@ get_safe_buffer_start() { #define ALWAYS_SET_RENDER_STATE true -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_render_state -// Access: -// Description: This function creates a common layer between DX -// and Panda for SetRenderState. It also keeps avoids -// setting redundant render states. -//////////////////////////////////////////////////////////////////// +/** + * This function creates a common layer between DX and Panda for + * SetRenderState. It also keeps avoids setting redundant render states. + */ INLINE HRESULT DXGraphicsStateGuardian9:: set_render_state (D3DRENDERSTATETYPE state, DWORD value) { @@ -169,13 +154,10 @@ set_render_state (D3DRENDERSTATETYPE state, DWORD value) return hr; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_texture_stage_state -// Access: -// Description: This function creates a common layer between DX -// and Panda. It also keeps avoids setting redundant -// render states. -//////////////////////////////////////////////////////////////////// +/** + * This function creates a common layer between DX and Panda. It also keeps + * avoids setting redundant render states. + */ INLINE HRESULT DXGraphicsStateGuardian9:: set_texture_stage_state (DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value) { @@ -191,13 +173,10 @@ set_texture_stage_state (DWORD stage, D3DTEXTURESTAGESTATETYPE type, DWORD value return hr; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_sampler_state -// Access: -// Description: This function creates a common layer between DX -// and Panda. It also keeps avoids setting redundant -// render states. -//////////////////////////////////////////////////////////////////// +/** + * This function creates a common layer between DX and Panda. It also keeps + * avoids setting redundant render states. + */ INLINE HRESULT DXGraphicsStateGuardian9:: set_sampler_state (DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value) { @@ -214,14 +193,11 @@ set_sampler_state (DWORD sampler, D3DSAMPLERSTATETYPE type, DWORD value) } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_supports_render_texture -// Access: Published -// Description: Returns true if this particular GSG can render -// from a wdxGraphicsBuffer9 directly into a texture, or -// false if it must always copy-to-texture at the end of -// each frame to achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can render from a wdxGraphicsBuffer9 + * directly into a texture, or false if it must always copy-to-texture at the + * end of each frame to achieve this effect. + */ INLINE bool DXGraphicsStateGuardian9:: get_supports_render_texture() const { return _supports_render_texture; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index acde3cf2d0..5cc7d8d0f6 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -1,17 +1,17 @@ -// Filename: dxGraphicsStateGuardian9.cxx -// Created by: mike (02Feb99) -// Updated by: fperazzi, PandaSE (05May10) (added get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGraphicsStateGuardian9.cxx + * @author mike + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + */ #include "dxGraphicsStateGuardian9.h" #include "config_dxgsg9.h" @@ -92,11 +92,9 @@ LPDIRECT3DDEVICE9 DXGraphicsStateGuardian9::_cg_device = NULL; #define MY_D3DRGBA(r, g, b, a) ((D3DCOLOR) D3DCOLOR_COLORVALUE(r, g, b, a)) -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXGraphicsStateGuardian9:: DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : GraphicsStateGuardian(CS_yup_left, engine, pipe) @@ -106,8 +104,8 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : << "DXGraphicsStateGuardian9 " << this << " constructing\n"; } - // Assume that we will get a hardware-accelerated context, unless - // the window tells us otherwise. + // Assume that we will get a hardware-accelerated context, unless the window + // tells us otherwise. _is_hardware = true; _screen = NULL; @@ -121,16 +119,15 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : _active_ibuffer = NULL; - // This is a static member, but we initialize it here in the - // constructor anyway. It won't hurt if it gets repeatedly - // initalized. + // This is a static member, but we initialize it here in the constructor + // anyway. It won't hurt if it gets repeatedly initalized. ZeroMemory(&_d3d_ident_mat, sizeof(D3DMATRIX)); _d3d_ident_mat._11 = _d3d_ident_mat._22 = _d3d_ident_mat._33 = _d3d_ident_mat._44 = 1.0f; _cur_read_pixel_buffer = RenderBuffer::T_front; - // DirectX drivers seem to consistently invert the texture when - // they copy framebuffer-to-texture. Ok. + // DirectX drivers seem to consistently invert the texture when they copy + // framebuffer-to-texture. Ok. _copy_texture_inverted = true; _gsg_managed_textures = dx_management | dx_texture_management; @@ -160,11 +157,9 @@ DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe) : atexit (atexit_function); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXGraphicsStateGuardian9:: ~DXGraphicsStateGuardian9() { if (dxgsg9_cat.is_debug()) { @@ -179,19 +174,15 @@ DXGraphicsStateGuardian9:: free_nondx_resources(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_texture -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given texture, and returns a newly-allocated -// TextureContext pointer to reference it. It is the -// responsibility of the calling function to later -// call release_texture() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a texture. Instead, call Texture::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given texture, and + * returns a newly-allocated TextureContext pointer to reference it. It is + * the responsibility of the calling function to later call release_texture() + * with this same pointer (which will also delete the pointer). + * + * This function should not be called directly to prepare a texture. Instead, + * call Texture::prepare(). + */ TextureContext *DXGraphicsStateGuardian9:: prepare_texture(Texture *tex, int view) { DXTextureContext9 *dtc = new DXTextureContext9(_prepared_objects, tex, view); @@ -205,17 +196,15 @@ prepare_texture(Texture *tex, int view) { return dtc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::apply_texture -// Access: Public -// Description: Makes the texture the currently available texture for -// rendering on the ith stage. -//////////////////////////////////////////////////////////////////// +/** + * Makes the texture the currently available texture for rendering on the ith + * stage. + */ void DXGraphicsStateGuardian9:: apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { if (tc == (TextureContext *)NULL) { - // The texture wasn't bound properly or something, so ensure - // texturing is disabled and just return. + // The texture wasn't bound properly or something, so ensure texturing is + // disabled and just return. set_texture_stage_state(i, D3DTSS_COLOROP, D3DTOP_DISABLE); return; } @@ -230,7 +219,7 @@ apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); Texture *tex = tc->get_texture(); - //if (tex->get_color_space() == CS_srgb) { + // if (tex->get_color_space() == CS_srgb) { if (Texture::is_srgb(tex->get_format())) { set_sampler_state(i, D3DSAMP_SRGBTEXTURE, TRUE); } else { @@ -276,14 +265,14 @@ apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { << new_mag_filter << ") failed for sampler: " << sampler << endl; } - // map Panda composite min+mip filter types to d3d's separate min & mip filter types + // map Panda composite min+mip filter types to d3d's separate min & mip + // filter types D3DTEXTUREFILTERTYPE new_min_filter = get_d3d_min_type(sampler.get_effective_minfilter()); D3DTEXTUREFILTERTYPE new_mip_filter = get_d3d_mip_type(sampler.get_effective_minfilter()); if (!tex->might_have_ram_image()) { - // If the texture is completely dynamic, don't try to issue - // mipmaps--pandadx doesn't support auto-generated mipmaps at this - // point. + // If the texture is completely dynamic, don't try to issue mipmaps-- + // pandadx doesn't support auto-generated mipmaps at this point. new_mip_filter = D3DTEXF_NONE; } @@ -305,28 +294,22 @@ apply_texture(int i, TextureContext *tc, const SamplerState &sampler) { _d3d_device->SetTexture(i, dtc->get_d3d_texture()); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::update_texture -// Access: Public, Virtual -// Description: Ensures that the current Texture data is refreshed -// onto the GSG. This means updating the texture -// properties and/or re-uploading the texture image, if -// necessary. This should only be called within the -// draw thread. -// -// If force is true, this function will not return until -// the texture has been fully uploaded. If force is -// false, the function may choose to upload a simple -// version of the texture instead, if the texture is not -// fully resident (and if get_incomplete_render() is -// true). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the current Texture data is refreshed onto the GSG. This + * means updating the texture properties and/or re-uploading the texture + * image, if necessary. This should only be called within the draw thread. + * + * If force is true, this function will not return until the texture has been + * fully uploaded. If force is false, the function may choose to upload a + * simple version of the texture instead, if the texture is not fully resident + * (and if get_incomplete_render() is true). + */ bool DXGraphicsStateGuardian9:: update_texture(TextureContext *tc, bool force) { DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); - // If the texture image has changed, or if its use of mipmaps has - // changed, we need to re-create the image. + // If the texture image has changed, or if its use of mipmaps has changed, + // we need to re-create the image. if (dtc->was_modified()) { if (!upload_texture(dtc, force)) { @@ -342,12 +325,10 @@ update_texture(TextureContext *tc, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::upload_texture -// Access: Public -// Description: Creates a texture surface on the graphics card and -// fills it with its pixel data. -//////////////////////////////////////////////////////////////////// +/** + * Creates a texture surface on the graphics card and fills it with its pixel + * data. + */ bool DXGraphicsStateGuardian9:: upload_texture(DXTextureContext9 *dtc, bool force) { Texture *tex = dtc->get_texture(); @@ -366,8 +347,8 @@ upload_texture(DXTextureContext9 *dtc, bool force) { if (!has_image && tex->might_have_ram_image() && tex->has_simple_ram_image() && !_loader.is_null()) { - // If we don't have the texture data right now, go get it, but in - // the meantime load a temporary simple image in its place. + // If we don't have the texture data right now, go get it, but in the + // meantime load a temporary simple image in its place. async_reload_texture(dtc); has_image = _supports_compressed_texture ? tex->has_ram_image() : tex->has_uncompressed_ram_image(); if (!has_image) { @@ -382,30 +363,23 @@ upload_texture(DXTextureContext9 *dtc, bool force) { return dtc->create_texture(*_screen); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::release_texture -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the texture. + */ void DXGraphicsStateGuardian9:: release_texture(TextureContext *tc) { DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc); delete dtc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::extract_texture_data -// Access: Public, Virtual -// Description: This method should only be called by the -// GraphicsEngine. Do not call it directly; call -// GraphicsEngine::extract_texture_data() instead. -// -// This method will be called in the draw thread to -// download the texture memory's image into its -// ram_image value. It returns true on success, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method should only be called by the GraphicsEngine. Do not call it + * directly; call GraphicsEngine::extract_texture_data() instead. + * + * This method will be called in the draw thread to download the texture + * memory's image into its ram_image value. It returns true on success, false + * otherwise. + */ bool DXGraphicsStateGuardian9:: extract_texture_data(Texture *tex) { bool success = true; @@ -424,11 +398,9 @@ extract_texture_data(Texture *tex) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_shader -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShaderContext *DXGraphicsStateGuardian9:: prepare_shader(Shader *se) { #ifdef HAVE_CG @@ -438,30 +410,25 @@ prepare_shader(Shader *se) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::release_shader -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: release_shader(ShaderContext *sc) { CLP(ShaderContext) *gsc = DCAST(CLP(ShaderContext), sc); delete gsc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_vertex_buffer -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given data, and returns a newly-allocated -// VertexBufferContext pointer to reference it. It is the -// responsibility of the calling function to later -// call release_vertex_buffer() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a buffer. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given data, and returns a + * newly-allocated VertexBufferContext pointer to reference it. It is the + * responsibility of the calling function to later call + * release_vertex_buffer() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a buffer. Instead, + * call Geom::prepare(). + */ VertexBufferContext *CLP(GraphicsStateGuardian):: prepare_vertex_buffer(GeomVertexArrayData *data) { CLP(VertexBufferContext) *dvbc = new CLP(VertexBufferContext)(this, _prepared_objects, data); @@ -510,12 +477,10 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::apply_vertex_buffer -// Access: Public -// Description: Updates the vertex buffer with the current data, and -// makes it the current vertex buffer for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Updates the vertex buffer with the current data, and makes it the current + * vertex buffer for rendering. + */ bool CLP(GraphicsStateGuardian):: apply_vertex_buffer(VertexBufferContext *vbc, const GeomVertexArrayDataHandle *reader, bool force ) { @@ -542,8 +507,7 @@ apply_vertex_buffer(VertexBufferContext *vbc, #if 0 if (dvbc->changed_size(reader)) { - // We have to destroy the old vertex buffer and create a new - // one. + // We have to destroy the old vertex buffer and create a new one. dvbc->create_vbuffer(*_screen, reader); } #endif @@ -575,14 +539,11 @@ apply_vertex_buffer(VertexBufferContext *vbc, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::release_vertex_buffer -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// data. This function should never be called -// directly; instead, call Data::release() (or simply -// let the Data destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the data. This function + * should never be called directly; instead, call Data::release() (or simply + * let the Data destruct). + */ void CLP(GraphicsStateGuardian):: release_vertex_buffer(VertexBufferContext *vbc) { @@ -601,24 +562,19 @@ release_vertex_buffer(VertexBufferContext *vbc) { delete dvbc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::setup_array_data -// Access: Public -// Description: Internal function to bind a buffer object for the -// indicated data array, if appropriate, or to unbind a -// buffer object if it should be rendered from client -// memory. -// -// If the buffer object is bound, this function sets -// client_pointer to NULL (representing the start of the -// buffer object in server memory); if the buffer object -// is not bound, this function sets client_pointer the -// pointer to the data array in client memory, that is, -// the data array passed in. -// -// If force is not true, the function may return false -// indicating the data is not currently available. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to bind a buffer object for the indicated data array, if + * appropriate, or to unbind a buffer object if it should be rendered from + * client memory. + * + * If the buffer object is bound, this function sets client_pointer to NULL + * (representing the start of the buffer object in server memory); if the + * buffer object is not bound, this function sets client_pointer the pointer + * to the data array in client memory, that is, the data array passed in. + * + * If force is not true, the function may return false indicating the data is + * not currently available. + */ bool CLP(GraphicsStateGuardian):: setup_array_data(CLP(VertexBufferContext)*& dvbc, const GeomVertexArrayDataHandle* array_reader, @@ -635,31 +591,25 @@ setup_array_data(CLP(VertexBufferContext)*& dvbc, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_index_buffer -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given data, and returns a newly-allocated -// IndexBufferContext pointer to reference it. It is the -// responsibility of the calling function to later call -// release_index_buffer() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a buffer. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given data, and returns a + * newly-allocated IndexBufferContext pointer to reference it. It is the + * responsibility of the calling function to later call release_index_buffer() + * with this same pointer (which will also delete the pointer). + * + * This function should not be called directly to prepare a buffer. Instead, + * call Geom::prepare(). + */ IndexBufferContext *DXGraphicsStateGuardian9:: prepare_index_buffer(GeomPrimitive *data) { DXIndexBufferContext9 *dibc = new DXIndexBufferContext9(_prepared_objects, data); return dibc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::apply_index_buffer -// Access: Public -// Description: Updates the index buffer with the current data, and -// makes it the current index buffer for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Updates the index buffer with the current data, and makes it the current + * index buffer for rendering. + */ bool DXGraphicsStateGuardian9:: apply_index_buffer(IndexBufferContext *ibc, const GeomPrimitivePipelineReader *reader, bool force) { @@ -687,8 +637,7 @@ apply_index_buffer(IndexBufferContext *ibc, } else { if (dibc->was_modified(reader)) { if (dibc->changed_size(reader)) { - // We have to destroy the old index buffer and create a new - // one. + // We have to destroy the old index buffer and create a new one. dibc->create_ibuffer(*_screen, reader); } @@ -711,36 +660,28 @@ apply_index_buffer(IndexBufferContext *ibc, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::release_index_buffer -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// data. This function should never be called -// directly; instead, call Data::release() (or simply -// let the Data destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the data. This function + * should never be called directly; instead, call Data::release() (or simply + * let the Data destruct). + */ void DXGraphicsStateGuardian9:: release_index_buffer(IndexBufferContext *ibc) { DXIndexBufferContext9 *dibc = DCAST(DXIndexBufferContext9, ibc); delete dibc; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::begin_occlusion_query -// Access: Public, Virtual -// Description: Begins a new occlusion query. After this call, you -// may call begin_draw_primitives() and -// draw_triangles()/draw_whatever() repeatedly. -// Eventually, you should call end_occlusion_query() -// before the end of the frame; that will return a new -// OcclusionQueryContext object that will tell you how -// many pixels represented by the bracketed geometry -// passed the depth test. -// -// It is not valid to call begin_occlusion_query() -// between another begin_occlusion_query() -// .. end_occlusion_query() sequence. -//////////////////////////////////////////////////////////////////// +/** + * Begins a new occlusion query. After this call, you may call + * begin_draw_primitives() and draw_triangles()/draw_whatever() repeatedly. + * Eventually, you should call end_occlusion_query() before the end of the + * frame; that will return a new OcclusionQueryContext object that will tell + * you how many pixels represented by the bracketed geometry passed the depth + * test. + * + * It is not valid to call begin_occlusion_query() between another + * begin_occlusion_query() .. end_occlusion_query() sequence. + */ void DXGraphicsStateGuardian9:: begin_occlusion_query() { nassertv(_supports_occlusion_query); @@ -765,15 +706,12 @@ begin_occlusion_query() { _current_occlusion_query = queryobj; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::end_occlusion_query -// Access: Public, Virtual -// Description: Ends a previous call to begin_occlusion_query(). -// This call returns the OcclusionQueryContext object -// that will (eventually) report the number of pixels -// that passed the depth test between the call to -// begin_occlusion_query() and end_occlusion_query(). -//////////////////////////////////////////////////////////////////// +/** + * Ends a previous call to begin_occlusion_query(). This call returns the + * OcclusionQueryContext object that will (eventually) report the number of + * pixels that passed the depth test between the call to + * begin_occlusion_query() and end_occlusion_query(). + */ PT(OcclusionQueryContext) DXGraphicsStateGuardian9:: end_occlusion_query() { if (_current_occlusion_query == (OcclusionQueryContext *)NULL) { @@ -795,24 +733,19 @@ end_occlusion_query() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::make_geom_munger -// Access: Public, Virtual -// Description: Creates a new GeomMunger object to munge vertices -// appropriate to this GSG for the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GeomMunger object to munge vertices appropriate to this GSG + * for the indicated state. + */ PT(GeomMunger) DXGraphicsStateGuardian9:: make_geom_munger(const RenderState *state, Thread *current_thread) { PT(DXGeomMunger9) munger = new DXGeomMunger9(this, state); return GeomMunger::register_munger(munger, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::clear -// Access: Public, Virtual -// Description: Clears all of the indicated buffers to their assigned -// colors. -//////////////////////////////////////////////////////////////////// +/** + * Clears all of the indicated buffers to their assigned colors. + */ void DXGraphicsStateGuardian9:: clear(DrawableRegion *clearable) { @@ -831,7 +764,7 @@ clear(DrawableRegion *clearable) { PN_stdfloat depth_clear_value = clearable->get_clear_depth(); DWORD stencil_clear_value = (DWORD)(clearable->get_clear_stencil()); - //set appropriate flags + // set appropriate flags if (clearable->get_clear_color_active()) { main_flags |= D3DCLEAR_TARGET; } @@ -858,8 +791,8 @@ clear(DrawableRegion *clearable) { hr = _d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, color_clear_value, depth_clear_value, stencil_clear_value); if (!FAILED(hr)) { - // Yep, it worked without them. That's a problem. Which buffer - // poses the problem? + // Yep, it worked without them. That's a problem. Which buffer poses + // the problem? if (clearable->get_clear_depth_active()) { aux_flags |= D3DCLEAR_ZBUFFER; HRESULT hr2 = _d3d_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, color_clear_value, @@ -893,12 +826,9 @@ clear(DrawableRegion *clearable) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_display_region -// Access: Public, Virtual -// Description: Prepare a display region for rendering (set up -// scissor region and viewport) -//////////////////////////////////////////////////////////////////// +/** + * Prepare a display region for rendering (set up scissor region and viewport) + */ void DXGraphicsStateGuardian9:: prepare_display_region(DisplayRegionPipelineReader *dr) { nassertv(dr != (DisplayRegionPipelineReader *)NULL); @@ -938,17 +868,14 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::calc_projection_mat -// Access: Public, Virtual -// Description: Given a lens, calculates the appropriate projection -// matrix for use with this gsg. Note that the -// projection matrix depends a lot upon the coordinate -// system of the rendering API. -// -// The return value is a TransformState if the lens is -// acceptable, NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Given a lens, calculates the appropriate projection matrix for use with + * this gsg. Note that the projection matrix depends a lot upon the + * coordinate system of the rendering API. + * + * The return value is a TransformState if the lens is acceptable, NULL if it + * is not. + */ CPT(TransformState) DXGraphicsStateGuardian9:: calc_projection_mat(const Lens *lens) { if (lens == (Lens *)NULL) { @@ -959,9 +886,9 @@ calc_projection_mat(const Lens *lens) { return NULL; } - // DirectX also uses a Z range of 0 to 1, whereas the Panda - // convention is for the projection matrix to produce a Z range of - // -1 to 1. We have to rescale to compensate. + // DirectX also uses a Z range of 0 to 1, whereas the Panda convention is + // for the projection matrix to produce a Z range of -1 to 1. We have to + // rescale to compensate. static const LMatrix4 rescale_mat (1, 0, 0, 0, 0, 1, 0, 0, @@ -974,26 +901,22 @@ calc_projection_mat(const Lens *lens) { rescale_mat; if (_scene_setup->get_inverted()) { - // If the scene is supposed to be inverted, then invert the - // projection matrix. + // If the scene is supposed to be inverted, then invert the projection + // matrix. result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::prepare_lens -// Access: Public, Virtual -// Description: Makes the current lens (whichever lens was most -// recently specified with set_scene()) active, so -// that it will transform future rendered geometry. -// Normally this is only called from the draw process, -// and usually it is called by set_scene(). -// -// The return value is true if the lens is acceptable, -// false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Makes the current lens (whichever lens was most recently specified with + * set_scene()) active, so that it will transform future rendered geometry. + * Normally this is only called from the draw process, and usually it is + * called by set_scene(). + * + * The return value is true if the lens is acceptable, false if it is not. + */ bool DXGraphicsStateGuardian9:: prepare_lens() { LMatrix4f mat = LCAST(float, _projection_mat->get_mat()); @@ -1003,19 +926,14 @@ prepare_lens() { return SUCCEEDED(hr); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::begin_frame -// Access: Public, Virtual -// Description: Called before each frame is rendered, to allow the -// GSG a chance to do any internal cleanup before -// beginning the frame. -// -// The return value is true if successful (in which case -// the frame will be drawn and end_frame() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_frame() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called before each frame is rendered, to allow the GSG a chance to do any + * internal cleanup before beginning the frame. + * + * The return value is true if successful (in which case the frame will be + * drawn and end_frame() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_frame() will not be called). + */ bool DXGraphicsStateGuardian9:: begin_frame(Thread *current_thread) { @@ -1056,21 +974,16 @@ begin_frame(Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::begin_scene -// Access: Public, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the beginning of drawing commands for a "scene" -// (usually a particular DisplayRegion) within a frame. -// All 3-D drawing commands, except the clear operation, -// must be enclosed within begin_scene() .. end_scene(). -// -// The return value is true if successful (in which case -// the scene will be drawn and end_scene() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_scene() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the beginning of + * drawing commands for a "scene" (usually a particular DisplayRegion) within + * a frame. All 3-D drawing commands, except the clear operation, must be + * enclosed within begin_scene() .. end_scene(). + * + * The return value is true if successful (in which case the scene will be + * drawn and end_scene() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_scene() will not be called). + */ bool DXGraphicsStateGuardian9:: begin_scene() { if (!GraphicsStateGuardian::begin_scene()) { @@ -1102,15 +1015,12 @@ begin_scene() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::end_scene -// Access: Public, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the end of drawing commands for a "scene" (usually a -// particular DisplayRegion) within a frame. All 3-D -// drawing commands, except the clear operation, must be -// enclosed within begin_scene() .. end_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the end of drawing + * commands for a "scene" (usually a particular DisplayRegion) within a frame. + * All 3-D drawing commands, except the clear operation, must be enclosed + * within begin_scene() .. end_scene(). + */ void DXGraphicsStateGuardian9:: end_scene() { GraphicsStateGuardian::end_scene(); @@ -1155,13 +1065,10 @@ end_scene() { } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::end_frame -// Access: Public, Virtual -// Description: Called after each frame is rendered, to allow the -// GSG a chance to do any internal cleanup after -// rendering the frame, and before the window flips. -//////////////////////////////////////////////////////////////////// +/** + * Called after each frame is rendered, to allow the GSG a chance to do any + * internal cleanup after rendering the frame, and before the window flips. + */ void DXGraphicsStateGuardian9:: end_frame(Thread *current_thread) { @@ -1196,20 +1103,17 @@ end_frame(Thread *current_thread) { } #endif - // Note: regular GraphicsWindow::end_frame is being called, - // but we override gsg::end_frame, so need to explicitly call it here - // (currently it's an empty fn) + // Note: regular GraphicsWindow::end_frame is being called, but we override + // gsg::end_frame, so need to explicitly call it here (currently it's an + // empty fn) GraphicsStateGuardian::end_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::begin_draw_primitives -// Access: Public, Virtual -// Description: Called before a sequence of draw_primitive() -// functions are called, this should prepare the vertex -// data for rendering. It returns true if the vertices -// are ok, false to abort this group of primitives. -//////////////////////////////////////////////////////////////////// +/** + * Called before a sequence of draw_primitive() functions are called, this + * should prepare the vertex data for rendering. It returns true if the + * vertices are ok, false to abort this group of primitives. + */ bool DXGraphicsStateGuardian9:: begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, @@ -1229,12 +1133,11 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Set up vertex blending. switch (animation.get_num_transforms()) { case 1: - // The MSDN docs suggest we should use D3DVBF_0WEIGHTS here, but - // that doesn't seem to work at all. On the other hand, - // D3DVBF_DISABLE *does* work, because it disables special - // handling, meaning only the world matrix affects these - // vertices--and by accident or design, the first matrix, - // D3DTS_WORLDMATRIX(0), *is* the world matrix. + // The MSDN docs suggest we should use D3DVBF_0WEIGHTS here, but that + // doesn't seem to work at all. On the other hand, D3DVBF_DISABLE + // *does* work, because it disables special handling, meaning only the + // world matrix affects these vertices--and by accident or design, the + // first matrix, D3DTS_WORLDMATRIX(0), *is* the world matrix. set_render_state(D3DRS_VERTEXBLEND, D3DVBF_DISABLE); break; case 2: @@ -1264,8 +1167,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, _d3d_device->SetTransform(D3DTS_WORLDMATRIX(i), d3d_mat); } - // Setting the first animation matrix steps on the world matrix, - // so we have to set a flag to reload the world matrix later. + // Setting the first animation matrix steps on the world matrix, so we + // have to set a flag to reload the world matrix later. _transform_stale = true; } _vertex_blending_enabled = true; @@ -1287,13 +1190,12 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (_data_reader->is_vertex_transformed()) { // If the vertex data claims to be already transformed into clip - // coordinates, wipe out the current projection and modelview - // matrix (so we don't attempt to transform it again). + // coordinates, wipe out the current projection and modelview matrix (so + // we don't attempt to transform it again). - // It's tempting just to use the D3DFVF_XYZRHW specification on - // these vertices, but that turns out to be a bigger hammer than - // we want: that also prevents lighting calculations and user clip - // planes. + // It's tempting just to use the D3DFVF_XYZRHW specification on these + // vertices, but that turns out to be a bigger hammer than we want: that + // also prevents lighting calculations and user clip planes. _d3d_device->SetTransform(D3DTS_WORLD, &_d3d_ident_mat); static const LMatrix4f rescale_mat (1, 0, 0, 0, @@ -1334,15 +1236,12 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::update_standard_vertex_arrays -// Access: Protected -// Description: Binds vertex buffers as stream sources and sets the -// correct FVF format for fixed-function rendering. -// Used only when the standard (non-shader) pipeline -// is about to be used - dxShaderContexts are responsible -// for setting up their own vertex arrays. -//////////////////////////////////////////////////////////////////// +/** + * Binds vertex buffers as stream sources and sets the correct FVF format for + * fixed-function rendering. Used only when the standard (non-shader) + * pipeline is about to be used - dxShaderContexts are responsible for setting + * up their own vertex arrays. + */ bool CLP(GraphicsStateGuardian):: update_standard_vertex_arrays(bool force) { @@ -1385,15 +1284,12 @@ update_standard_vertex_arrays(bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::disable_standard_vertex_arrays -// Access: Protected -// Description: Unbinds all of the streams that are currently enabled. -// dxShaderContexts are responsible for setting up their -// own streams, but before they can do so, the standard -// streams need to be disabled to get them "out of the -// way." Called only from begin_draw_primitives. -//////////////////////////////////////////////////////////////////// +/** + * Unbinds all of the streams that are currently enabled. dxShaderContexts + * are responsible for setting up their own streams, but before they can do + * so, the standard streams need to be disabled to get them "out of the way." + * Called only from begin_draw_primitives. + */ void CLP(GraphicsStateGuardian):: disable_standard_vertex_arrays() { for ( int array_index = 0; array_index < _num_bound_streams; ++array_index ) @@ -1403,14 +1299,12 @@ disable_standard_vertex_arrays() { _num_bound_streams = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_triangles -// Access: Public, Virtual -// Description: Draws a series of disconnected triangles. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected triangles. + */ bool DXGraphicsStateGuardian9:: draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatTimer timer(_draw_primitive_pcollector); + // PStatTimer timer(_draw_primitive_pcollector); _vertices_tri_pcollector.add_level(reader->get_num_vertices()); _primitive_batches_tri_pcollector.add_level(1); @@ -1472,18 +1366,16 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_tristrips -// Access: Public, Virtual -// Description: Draws a series of triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle strips. + */ bool DXGraphicsStateGuardian9:: draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatTimer timer(_draw_primitive_pcollector); + // PStatTimer timer(_draw_primitive_pcollector); if (connect_triangle_strips && _current_fill_mode != RenderModeAttrib::M_wireframe) { - // One long triangle strip, connected by the degenerate vertices - // that have already been set up within the primitive. + // One long triangle strip, connected by the degenerate vertices that have + // already been set up within the primitive. _vertices_tristrip_pcollector.add_level(reader->get_num_vertices()); _primitive_batches_tristrip_pcollector.add_level(1); @@ -1543,7 +1435,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { } } else { - // Send the individual triangle strips, stepping over the degenerate vertices. + // Send the individual triangle strips, stepping over the degenerate + // vertices. CPTA_int ends = reader->get_ends(); _primitive_batches_tristrip_pcollector.add_level(ends.size()); @@ -1641,14 +1534,12 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_trifans -// Access: Public, Virtual -// Description: Draws a series of triangle fans. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle fans. + */ bool DXGraphicsStateGuardian9:: draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatTimer timer(_draw_primitive_pcollector); + // PStatTimer timer(_draw_primitive_pcollector); CPTA_int ends = reader->get_ends(); _primitive_batches_trifan_pcollector.add_level(ends.size()); @@ -1657,8 +1548,8 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { int min_vertex = dx_broken_max_index ? 0 : reader->get_min_vertex(); int max_vertex = reader->get_max_vertex(); - // Send the individual triangle fans. There's no connecting fans - // with degenerate vertices, so no worries about that. + // Send the individual triangle fans. There's no connecting fans with + // degenerate vertices, so no worries about that. int index_stride = reader->get_index_stride(); GeomVertexReader mins(reader->get_mins(), 0); @@ -1749,14 +1640,12 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_lines -// Access: Public, Virtual -// Description: Draws a series of disconnected line segments. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected line segments. + */ bool DXGraphicsStateGuardian9:: draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatTimer timer(_draw_primitive_pcollector); + // PStatTimer timer(_draw_primitive_pcollector); _vertices_other_pcollector.add_level(reader->get_num_vertices()); _primitive_batches_other_pcollector.add_level(1); @@ -1817,30 +1706,26 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_linestrips -// Access: Public, Virtual -// Description: Draws a series of line strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of line strips. + */ bool DXGraphicsStateGuardian9:: draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_points -// Access: Public, Virtual -// Description: Draws a series of disconnected points. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected points. + */ bool DXGraphicsStateGuardian9:: draw_points(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatTimer timer(_draw_primitive_pcollector); + // PStatTimer timer(_draw_primitive_pcollector); _vertices_other_pcollector.add_level(reader->get_num_vertices()); _primitive_batches_other_pcollector.add_level(1); - // The munger should have protected us from indexed points--DirectX - // doesn't support them. + // The munger should have protected us from indexed points--DirectX doesn't + // support them. nassertr(!reader->is_indexed(), false); // Nonindexed, vbuffers. @@ -1863,17 +1748,13 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::end_draw_primitives() -// Access: Public, Virtual -// Description: Called after a sequence of draw_primitive() -// functions are called, this should do whatever cleanup -// is appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Called after a sequence of draw_primitive() functions are called, this + * should do whatever cleanup is appropriate. + */ void DXGraphicsStateGuardian9:: end_draw_primitives() { - // Turn off vertex blending--it seems to cause problems if we leave - // it on. + // Turn off vertex blending--it seems to cause problems if we leave it on. if (_vertex_blending_enabled) { set_render_state(D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE); set_render_state(D3DRS_VERTEXBLEND, D3DVBF_DISABLE); @@ -1890,15 +1771,12 @@ end_draw_primitives() { GraphicsStateGuardian::end_draw_primitives(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::framebuffer_copy_to_texture -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display -// region from the framebuffer into texture memory. -// -// If z > -1, it is the cube map index into which to -// copy. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into texture memory. + * + * If z > -1, it is the cube map index into which to copy. + */ bool DXGraphicsStateGuardian9:: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { @@ -1928,8 +1806,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } if (tex->get_texture_type() != Texture::TT_2d_texture) { - // For a specialty texture like a cube map, go the slow route - // through RAM for now. + // For a specialty texture like a cube map, go the slow route through RAM + // for now. return do_framebuffer_copy_to_ram(tex, view, z, dr, rb, true); } nassertr(dtc->get_d3d_2d_texture() != NULL, false); @@ -1951,7 +1829,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } if ((texdesc.Width != tex->get_x_size())||(texdesc.Height != tex->get_y_size())) { if ((orig_x != tex->get_x_size()) || (orig_y != tex->get_y_size())) { - // Texture might be wrong size because we resized it and need to recreate. + // Texture might be wrong size because we resized it and need to + // recreate. SAFE_RELEASE(tex_level_0); if (!dtc->create_texture(*_screen)) { // Oops, we can't re-create the texture for some reason. @@ -1973,7 +1852,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } if ((texdesc.Width != tex->get_x_size())||(texdesc.Height != tex->get_y_size())) { // If it's still the wrong size, it's because driver can't create size - // that we want. In that case, there's no helping it, we have to give up. + // that we want. In that case, there's no helping it, we have to give + // up. dxgsg9_cat.error() << "Unable to copy to texture, texture is wrong size: " << *dtc->get_texture() << endl; SAFE_RELEASE(tex_level_0); @@ -2003,10 +1883,10 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, src_rect.top = yo; src_rect.bottom = yo+h; -// THE DX8 WAY -// hr = _d3d_device->CopyRects(render_target, &src_rect, 1, tex_level_0, 0); +// THE DX8 WAY hr = _d3d_device->CopyRects(render_target, &src_rect, 1, +// tex_level_0, 0); -// DX9 +// DX9 D3DTEXTUREFILTERTYPE filter; filter = D3DTEXF_POINT; @@ -2030,8 +1910,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, dtc->enqueue_lru(&_prepared_objects->_graphics_memory_lru); } else { - // The copy failed. Fall back to copying it to RAM and back. - // Terribly slow, but what are you going to do? + // The copy failed. Fall back to copying it to RAM and back. Terribly + // slow, but what are you going to do? return do_framebuffer_copy_to_ram(tex, view, z, dr, rb, true); } @@ -2039,31 +1919,24 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::framebuffer_copy_to_ram -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display region -// from the framebuffer into system memory, not texture -// memory. Returns true on success, false on failure. -// -// This completely redefines the ram image of the -// indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into system memory, not texture memory. Returns true on success, false on + * failure. + * + * This completely redefines the ram image of the indicated texture. + */ bool DXGraphicsStateGuardian9:: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { return do_framebuffer_copy_to_ram(tex, view, z, dr, rb, false); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_framebuffer_copy_to_ram -// Access: Public -// Description: This is the implementation of -// framebuffer_copy_to_ram(); it adds one additional -// parameter, which should be true if the framebuffer is -// to be inverted during the copy (as in the same way it -// copies to texture memory). -//////////////////////////////////////////////////////////////////// +/** + * This is the implementation of framebuffer_copy_to_ram(); it adds one + * additional parameter, which should be true if the framebuffer is to be + * inverted during the copy (as in the same way it copies to texture memory). + */ bool DXGraphicsStateGuardian9:: do_framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb, @@ -2114,15 +1987,14 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, IDirect3DSurface9 *temp_surface = NULL; HRESULT hr; - // Note if you try to grab the backbuffer and full-screen - // anti-aliasing is on, the backbuffer might be larger than the - // window size. For screenshots it's safer to get the front buffer. + // Note if you try to grab the backbuffer and full-screen anti-aliasing is + // on, the backbuffer might be larger than the window size. For screenshots + // it's safer to get the front buffer. if (_cur_read_pixel_buffer & RenderBuffer::T_back) { DWORD render_target_index; IDirect3DSurface9 *backbuffer = NULL; // GetRenderTarget() seems to be a little more reliable than - // GetBackBuffer(). Might just be related to the swap_chain - // thing. + // GetBackBuffer(). Might just be related to the swap_chain thing. render_target_index = 0; hr = _d3d_device->GetRenderTarget(render_target_index, &backbuffer); @@ -2132,9 +2004,8 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, return false; } - // Since we might not be able to Lock the back buffer, we will - // need to copy it to a temporary surface of the appropriate type - // first. + // Since we might not be able to Lock the back buffer, we will need to + // copy it to a temporary surface of the appropriate type first. D3DPOOL pool; D3DSURFACE_DESC surface_description; @@ -2172,11 +2043,11 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, } else if (_cur_read_pixel_buffer & RenderBuffer::T_front) { if (_screen->_presentation_params.Windowed) { - // GetFrontBuffer() retrieves the entire desktop for a monitor, - // so we need to reserve space for that. + // GetFrontBuffer() retrieves the entire desktop for a monitor, so we + // need to reserve space for that. - // We have to use GetMonitorInfo(), since this GSG may not be - // for the primary monitor. + // We have to use GetMonitorInfo(), since this GSG may not be for the + // primary monitor. MONITORINFO minfo; minfo.cbSize = sizeof(MONITORINFO); GetMonitorInfo(_screen->_monitor, &minfo); @@ -2189,9 +2060,8 @@ do_framebuffer_copy_to_ram(Texture *tex, int view, int z, ClientToScreen(_screen->_window, (POINT*)&rect.right); } - // For GetFrontBuffer(), we need a temporary surface of type - // A8R8G8B8. Unlike GetBackBuffer(), GetFrontBuffer() implicitly - // performs a copy. + // For GetFrontBuffer(), we need a temporary surface of type A8R8G8B8. + // Unlike GetBackBuffer(), GetFrontBuffer() implicitly performs a copy. hr = _d3d_device->CreateOffscreenPlainSurface(w, h, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &temp_surface, NULL); if (FAILED(hr)) { dxgsg9_cat.error() @@ -2244,14 +2114,17 @@ void DXGraphicsStateGuardian9::reset_render_states (void) memset (_render_state_array, -1, sizeof (_render_state_array)); memset (_texture_stage_states_array, -1, sizeof (_texture_stage_states_array)); - // states that may be set intially to -1 by the user, so set it to D3D's default value + // states that may be set intially to -1 by the user, so set it to D3D's + // default value _render_state_array [D3DRS_FOGCOLOR] = 0; _render_state_array [D3DRS_AMBIENT] = 0; - // set to D3D default values or invalid values so that the state will always be set the first time + // set to D3D default values or invalid values so that the state will always + // be set the first time memset (_texture_render_states_array, 0, sizeof (_texture_render_states_array)); - // states that may be set intially to 0 by the user, so set it to D3D's default value + // states that may be set intially to 0 by the user, so set it to D3D's + // default value for (index = 0; index < MAXIMUM_TEXTURES; index++) { TextureRenderStates *texture_render_states; @@ -2267,21 +2140,18 @@ void DXGraphicsStateGuardian9::reset_render_states (void) _last_fvf = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. The GraphicsWindow pointer represents a -// typical window that might be used for this context; -// it may be required to set up the frame buffer -// properly the first time. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. The + * GraphicsWindow pointer represents a typical window that might be used for + * this context; it may be required to set up the frame buffer properly the + * first time. + */ void DXGraphicsStateGuardian9:: reset() { GraphicsStateGuardian::reset(); - // Build _inv_state_mask as a mask of 1's where we don't care, and - // 0's where we do care, about the state. + // Build _inv_state_mask as a mask of 1's where we don't care, and 0's where + // we do care, about the state. _inv_state_mask.clear_bit(ShaderAttrib::get_class_slot()); _inv_state_mask.clear_bit(AlphaTestAttrib::get_class_slot()); _inv_state_mask.clear_bit(ClipPlaneAttrib::get_class_slot()); @@ -2306,8 +2176,8 @@ reset() { _inv_state_mask.clear_bit(FogAttrib::get_class_slot()); _inv_state_mask.clear_bit(ScissorAttrib::get_class_slot()); - // D3DRS_POINTSPRITEENABLE doesn't seem to support remapping the - // texture coordinates via a texture matrix, so we don't advertise + // D3DRS_POINTSPRITEENABLE doesn't seem to support remapping the texture + // coordinates via a texture matrix, so we don't advertise // GR_point_sprite_tex_matrix. _supported_geom_rendering = Geom::GR_point | Geom::GR_point_uniform_size | @@ -2322,8 +2192,8 @@ reset() { // make sure gsg passes all current state down to us // set_state_and_transform(RenderState::make_empty(), - // TransformState::make_identity()); - // want gsg to pass all state settings down so any non-matching defaults we set here get overwritten + // TransformState::make_identity()); want gsg to pass all state settings + // down so any non-matching defaults we set here get overwritten nassertv(_screen->_d3d9 != NULL); @@ -2592,7 +2462,7 @@ reset() { } // override default config setting since it is really supported or not ??? -// support_render_texture = _supports_render_texture; + // support_render_texture = _supports_render_texture; _supports_3d_texture = ((d3d_caps.TextureCaps & D3DPTEXTURECAPS_VOLUMEMAP) != 0); if (_supports_3d_texture) { @@ -2620,7 +2490,7 @@ reset() { set_render_state(D3DRS_ZWRITEENABLE, TRUE); /* ***** DX9 ??? D3DRS_EDGEANTIALIAS NOT IN DX9 */ -// set_render_state(D3DRS_EDGEANTIALIAS, false); +// set_render_state(D3DRS_EDGEANTIALIAS, false); set_render_state(D3DRS_ZENABLE, D3DZB_FALSE); @@ -2709,25 +2579,24 @@ reset() { _screen->_d3dcaps.MaxTextureHeight = 256; if (_screen->_d3dcaps.RasterCaps & D3DPRASTERCAPS_FOGTABLE) { - // Watch out for drivers that emulate per-pixel fog with - // per-vertex fog (Riva128, Matrox Millen G200). Some of these - // require gouraud-shading to be set to work, as if you were using - // vertex fog + // Watch out for drivers that emulate per-pixel fog with per-vertex fog + // (Riva128, Matrox Millen G200). Some of these require gouraud-shading + // to be set to work, as if you were using vertex fog _do_fog_type = PerPixelFog; } else { - // every card is going to have vertex fog, since it's implemented - // in d3d runtime. + // every card is going to have vertex fog, since it's implemented in d3d + // runtime. nassertv((_screen->_d3dcaps.RasterCaps & D3DPRASTERCAPS_FOGVERTEX) != 0); - // vertex fog may look crappy if you have large polygons in the - // foreground and they get clipped, so you may want to disable it + // vertex fog may look crappy if you have large polygons in the foreground + // and they get clipped, so you may want to disable it if (dx_no_vertex_fog) { _do_fog_type = None; } else { _do_fog_type = PerVertexFog; - // range-based fog only works with vertex fog in dx7/8 + // range-based fog only works with vertex fog in dx78 if (dx_use_rangebased_fog && (_screen->_d3dcaps.RasterCaps & D3DPRASTERCAPS_FOGRANGE)) { set_render_state(D3DRS_RANGEFOGENABLE, true); } @@ -2739,7 +2608,7 @@ reset() { // Lighting, let's turn it off initially. set_render_state(D3DRS_LIGHTING, false); - // turn on dithering if the rendertarget is < 8bits/color channel + // turn on dithering if the rendertarget is < 8bitscolor channel bool dither_enabled = ((!dx_no_dithering) && IS_16BPP_DISPLAY_FORMAT(_screen->_presentation_params.BackBufferFormat) && (_screen->_d3dcaps.RasterCaps & D3DPRASTERCAPS_DITHER)); set_render_state(D3DRS_DITHERENABLE, dither_enabled); @@ -2754,14 +2623,13 @@ reset() { // Antialiasing. /* ***** DX9 ??? D3DRS_EDGEANTIALIAS NOT IN DX9 */ -// set_render_state(D3DRS_EDGEANTIALIAS, FALSE); +// set_render_state(D3DRS_EDGEANTIALIAS, FALSE); _current_fill_mode = RenderModeAttrib::M_filled; set_render_state(D3DRS_FILLMODE, D3DFILL_SOLID); - // must do SetTSS here because redundant states are filtered out by - // our code based on current values above, so initial conditions - // must be correct + // must do SetTSS here because redundant states are filtered out by our code + // based on current values above, so initial conditions must be correct set_texture_stage_state(0, D3DTSS_COLOROP, D3DTOP_DISABLE); // disables texturing _cull_face_mode = CullFaceAttrib::M_cull_none; @@ -2771,8 +2639,10 @@ reset() { set_render_state(D3DRS_ALPHAREF, 255); set_render_state(D3DRS_ALPHATESTENABLE, FALSE); - // this is a new DX8 state that lets you do additional operations other than ADD (e.g. subtract/max/min) - // must check (_screen->_d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_BLENDOP) (yes on GF2/Radeon8500, no on TNT) + // this is a new DX8 state that lets you do additional operations other than + // ADD (e.g. subtractmaxmin) must check + // (_screen->_d3dcaps.PrimitiveMiscCaps & D3DPMISCCAPS_BLENDOP) (yes on + // GF2Radeon8500, no on TNT) set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD); _current_shader = (Shader *)NULL; @@ -2789,11 +2659,9 @@ reset() { add_gsg(this); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::apply_fog -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: apply_fog(Fog *fog) { if (_do_fog_type == None) @@ -2808,8 +2676,9 @@ apply_fog(Fog *fog) { set_render_state(D3DRS_FOGCOLOR, MY_D3DRGBA(fog_colr[0], fog_colr[1], fog_colr[2], 0.0f)); // Alpha bits are not used - // do we need to adjust fog start/end values based on D3DPRASTERCAPS_WFOG/D3DPRASTERCAPS_ZFOG ? - // if not WFOG, then docs say we need to adjust values to range [0, 1] + // do we need to adjust fog startend values based on + // D3DPRASTERCAPS_WFOGD3DPRASTERCAPS_ZFOG ? if not WFOG, then docs say we + // need to adjust values to range [0, 1] switch (panda_fogmode) { case Fog::M_linear: @@ -2835,25 +2704,24 @@ apply_fog(Fog *fog) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_transform -// Access: Protected -// Description: Sends the indicated transform matrix to the graphics -// API to be applied to future vertices. -// -// This transform is the internal_transform, already -// converted into the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Sends the indicated transform matrix to the graphics API to be applied to + * future vertices. + * + * This transform is the internal_transform, already converted into the GSG's + * internal coordinate system. + */ void DXGraphicsStateGuardian9:: do_issue_transform() { const TransformState *transform = _internal_transform; DO_PSTATS_STUFF(_transform_state_pcollector.add_level(1)); if (_current_shader_context) { -// _current_shader_context->issue_transform(this); +// _current_shader_context->issue_transform(this); _current_shader_context->issue_parameters(this, Shader::SSD_transform); -// ??? NO NEED TO SET THE D3D TRANSFORM VIA SetTransform SINCE THE TRANSFORM IS ONLY USED IN THE SHADER +// ??? NO NEED TO SET THE D3D TRANSFORM VIA SetTransform SINCE THE TRANSFORM +// IS ONLY USED IN THE SHADER LMatrix4f mat = LCAST(float, transform->get_mat()); const D3DMATRIX *d3d_mat = (const D3DMATRIX *)mat.get_data(); _d3d_device->SetTransform(D3DTS_WORLD, d3d_mat); @@ -2880,11 +2748,9 @@ do_issue_transform() { _transform_stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_alpha_test -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_alpha_test() { if (_target_shader->get_flag(ShaderAttrib::F_subsume_alpha_test)) { @@ -2895,7 +2761,7 @@ do_issue_alpha_test() { if (mode == AlphaTestAttrib::M_none) { set_render_state(D3DRS_ALPHATESTENABLE, FALSE); } else { - // AlphaTestAttrib::PandaCompareFunc === D3DCMPFUNC + // AlphaTestAttrib::PandaCompareFunc === D3DCMPFUNC set_render_state(D3DRS_ALPHAFUNC, (D3DCMPFUNC)mode); set_render_state(D3DRS_ALPHAREF, (UINT) (target_alpha_test->get_reference_alpha()*255.0f)); //d3d uses 0x0-0xFF, not a float set_render_state(D3DRS_ALPHATESTENABLE, TRUE); @@ -2903,11 +2769,9 @@ do_issue_alpha_test() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_shader -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_shader() { @@ -2931,8 +2795,8 @@ do_issue_shader() { } if (context != _current_shader_context) { - // Use a completely different shader than before. - // Unbind old shader, bind the new one. + // Use a completely different shader than before. Unbind old shader, bind + // the new one. if (_current_shader_context != 0) { _current_shader_context->unbind(this); _current_shader_context = 0; @@ -2950,11 +2814,9 @@ do_issue_shader() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_render_mode -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_render_mode() { const RenderModeAttrib *target_render_mode = DCAST(RenderModeAttrib, _target_rs->get_attrib_def(RenderModeAttrib::get_class_slot())); @@ -3004,11 +2866,9 @@ do_issue_render_mode() { _current_fill_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_rescale_normal -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_rescale_normal() { RescaleNormalAttrib::Mode mode = RescaleNormalAttrib::M_none; @@ -3034,11 +2894,9 @@ do_issue_rescale_normal() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_depth_test -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_depth_test() { const DepthTestAttrib *target_depth_test = DCAST(DepthTestAttrib, _target_rs->get_attrib_def(DepthTestAttrib::get_class_slot())); @@ -3051,11 +2909,9 @@ do_issue_depth_test() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_depth_write -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_depth_write() { const DepthWriteAttrib *target_depth_write = DCAST(DepthWriteAttrib, _target_rs->get_attrib_def(DepthWriteAttrib::get_class_slot())); @@ -3067,11 +2923,9 @@ do_issue_depth_write() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_cull_face -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_cull_face() { const CullFaceAttrib *target_cull_face = DCAST(CullFaceAttrib, _target_rs->get_attrib_def(CullFaceAttrib::get_class_slot())); @@ -3103,11 +2957,9 @@ do_issue_cull_face() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_fog -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_fog() { const FogAttrib *target_fog = DCAST(FogAttrib, _target_rs->get_attrib_def(FogAttrib::get_class_slot())); @@ -3121,11 +2973,9 @@ do_issue_fog() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_depth_offset -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_depth_offset() { const DepthOffsetAttrib *target_depth_offset = DCAST(DepthOffsetAttrib, _target_rs->get_attrib_def(DepthOffsetAttrib::get_class_slot())); @@ -3136,9 +2986,8 @@ do_issue_depth_offset() { set_render_state(D3DRS_SLOPESCALEDEPTHBIAS, offset); } else { - // DirectX depth bias isn't directly supported by the driver. - // Cheese a depth bias effect by sliding the viewport backward a - // bit. + // DirectX depth bias isn't directly supported by the driver. Cheese a + // depth bias effect by sliding the viewport backward a bit. static const PN_stdfloat bias_scale = dx_depth_bias_scale; D3DVIEWPORT9 vp = _current_viewport; vp.MinZ -= bias_scale * offset; @@ -3147,11 +2996,9 @@ do_issue_depth_offset() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_shade_model -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_shade_model() { const ShadeModelAttrib *target_shade_model = DCAST(ShadeModelAttrib, _target_rs->get_attrib_def(ShadeModelAttrib::get_class_slot())); @@ -3166,23 +3013,18 @@ do_issue_shade_model() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_state_and_transform -// Access: Public, Virtual -// Description: Simultaneously resets the render state and the -// transform state. -// -// This transform specified is the "internal" net -// transform, already converted into the GSG's internal -// coordinate space by composing it to -// get_cs_transform(). (Previously, this used to be the -// "external" net transform, with the assumption that -// that GSG would convert it internally, but that is no -// longer the case.) -// -// Special case: if (state==NULL), then the target -// state is already stored in _target. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously resets the render state and the transform state. + * + * This transform specified is the "internal" net transform, already converted + * into the GSG's internal coordinate space by composing it to + * get_cs_transform(). (Previously, this used to be the "external" net + * transform, with the assumption that that GSG would convert it internally, + * but that is no longer the case.) + * + * Special case: if (state==NULL), then the target state is already stored in + * _target. + */ void DXGraphicsStateGuardian9:: set_state_and_transform(const RenderState *target, const TransformState *transform) { @@ -3196,7 +3038,7 @@ set_state_and_transform(const RenderState *target, PStatTimer timer1(_draw_set_state_pcollector); if (transform != _internal_transform) { - //PStatTimer timer(_draw_set_state_transform_pcollector); + // PStatTimer timer(_draw_set_state_transform_pcollector); _state_pcollector.add_level(1); _internal_transform = transform; do_issue_transform(); @@ -3212,7 +3054,7 @@ set_state_and_transform(const RenderState *target, int alpha_test_slot = AlphaTestAttrib::get_class_slot(); if (_target_rs->get_attrib(alpha_test_slot) != _state_rs->get_attrib(alpha_test_slot) || !_state_mask.get_bit(alpha_test_slot)) { - //PStatTimer timer(_draw_set_state_alpha_test_pcollector); + // PStatTimer timer(_draw_set_state_alpha_test_pcollector); do_issue_alpha_test(); _state_mask.set_bit(alpha_test_slot); } @@ -3220,7 +3062,7 @@ set_state_and_transform(const RenderState *target, int clip_plane_slot = ClipPlaneAttrib::get_class_slot(); if (_target_rs->get_attrib(clip_plane_slot) != _state_rs->get_attrib(clip_plane_slot) || !_state_mask.get_bit(clip_plane_slot)) { - //PStatTimer timer(_draw_set_state_clip_plane_pcollector); + // PStatTimer timer(_draw_set_state_clip_plane_pcollector); do_issue_clip_plane(); _state_mask.set_bit(clip_plane_slot); } @@ -3231,7 +3073,7 @@ set_state_and_transform(const RenderState *target, _target_rs->get_attrib(color_scale_slot) != _state_rs->get_attrib(color_scale_slot) || !_state_mask.get_bit(color_slot) || !_state_mask.get_bit(color_scale_slot)) { - //PStatTimer timer(_draw_set_state_color_pcollector); + // PStatTimer timer(_draw_set_state_color_pcollector); do_issue_color(); do_issue_color_scale(); _state_mask.set_bit(color_slot); @@ -3245,7 +3087,7 @@ set_state_and_transform(const RenderState *target, int cull_face_slot = CullFaceAttrib::get_class_slot(); if (_target_rs->get_attrib(cull_face_slot) != _state_rs->get_attrib(cull_face_slot) || !_state_mask.get_bit(cull_face_slot)) { - //PStatTimer timer(_draw_set_state_cull_face_pcollector); + // PStatTimer timer(_draw_set_state_cull_face_pcollector); do_issue_cull_face(); _state_mask.set_bit(cull_face_slot); } @@ -3253,7 +3095,7 @@ set_state_and_transform(const RenderState *target, int depth_offset_slot = DepthOffsetAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_offset_slot) != _state_rs->get_attrib(depth_offset_slot) || !_state_mask.get_bit(depth_offset_slot)) { - //PStatTimer timer(_draw_set_state_depth_offset_pcollector); + // PStatTimer timer(_draw_set_state_depth_offset_pcollector); do_issue_depth_offset(); _state_mask.set_bit(depth_offset_slot); } @@ -3261,7 +3103,7 @@ set_state_and_transform(const RenderState *target, int depth_test_slot = DepthTestAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_test_slot) != _state_rs->get_attrib(depth_test_slot) || !_state_mask.get_bit(depth_test_slot)) { - //PStatTimer timer(_draw_set_state_depth_test_pcollector); + // PStatTimer timer(_draw_set_state_depth_test_pcollector); do_issue_depth_test(); _state_mask.set_bit(depth_test_slot); } @@ -3269,7 +3111,7 @@ set_state_and_transform(const RenderState *target, int depth_write_slot = DepthWriteAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_write_slot) != _state_rs->get_attrib(depth_write_slot) || !_state_mask.get_bit(depth_write_slot)) { - //PStatTimer timer(_draw_set_state_depth_write_pcollector); + // PStatTimer timer(_draw_set_state_depth_write_pcollector); do_issue_depth_write(); _state_mask.set_bit(depth_write_slot); } @@ -3277,7 +3119,7 @@ set_state_and_transform(const RenderState *target, int render_mode_slot = RenderModeAttrib::get_class_slot(); if (_target_rs->get_attrib(render_mode_slot) != _state_rs->get_attrib(render_mode_slot) || !_state_mask.get_bit(render_mode_slot)) { - //PStatTimer timer(_draw_set_state_render_mode_pcollector); + // PStatTimer timer(_draw_set_state_render_mode_pcollector); do_issue_render_mode(); _state_mask.set_bit(render_mode_slot); } @@ -3285,7 +3127,7 @@ set_state_and_transform(const RenderState *target, int rescale_normal_slot = RescaleNormalAttrib::get_class_slot(); if (_target_rs->get_attrib(rescale_normal_slot) != _state_rs->get_attrib(rescale_normal_slot) || !_state_mask.get_bit(rescale_normal_slot)) { - //PStatTimer timer(_draw_set_state_rescale_normal_pcollector); + // PStatTimer timer(_draw_set_state_rescale_normal_pcollector); do_issue_rescale_normal(); _state_mask.set_bit(rescale_normal_slot); } @@ -3293,7 +3135,7 @@ set_state_and_transform(const RenderState *target, int shade_model_slot = ShadeModelAttrib::get_class_slot(); if (_target_rs->get_attrib(shade_model_slot) != _state_rs->get_attrib(shade_model_slot) || !_state_mask.get_bit(shade_model_slot)) { - //PStatTimer timer(_draw_set_state_shade_model_pcollector); + // PStatTimer timer(_draw_set_state_shade_model_pcollector); do_issue_shade_model(); _state_mask.set_bit(shade_model_slot); } @@ -3309,7 +3151,7 @@ set_state_and_transform(const RenderState *target, !_state_mask.get_bit(color_blend_slot) || (_target_shader->get_flag(ShaderAttrib::F_disable_alpha_write) != _state_shader->get_flag(ShaderAttrib::F_disable_alpha_write))) { - //PStatTimer timer(_draw_set_state_blending_pcollector); + // PStatTimer timer(_draw_set_state_blending_pcollector); do_issue_blending(); _state_mask.set_bit(transparency_slot); _state_mask.set_bit(color_write_slot); @@ -3317,7 +3159,7 @@ set_state_and_transform(const RenderState *target, } if (_target_shader != _state_shader) { - //PStatTimer timer(_draw_set_state_shader_pcollector); + // PStatTimer timer(_draw_set_state_shader_pcollector); do_issue_shader(); _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); @@ -3332,7 +3174,7 @@ set_state_and_transform(const RenderState *target, !_state_mask.get_bit(texture_slot) || !_state_mask.get_bit(tex_matrix_slot) || !_state_mask.get_bit(tex_gen_slot)) { - //PStatTimer timer(_draw_set_state_texture_pcollector); + // PStatTimer timer(_draw_set_state_texture_pcollector); determine_target_texture(); do_issue_texture(); @@ -3345,7 +3187,7 @@ set_state_and_transform(const RenderState *target, int material_slot = MaterialAttrib::get_class_slot(); if (_target_rs->get_attrib(material_slot) != _state_rs->get_attrib(material_slot) || !_state_mask.get_bit(material_slot)) { - //PStatTimer timer(_draw_set_state_material_pcollector); + // PStatTimer timer(_draw_set_state_material_pcollector); do_issue_material(); _state_mask.set_bit(material_slot); if (_current_shader_context) { @@ -3356,7 +3198,7 @@ set_state_and_transform(const RenderState *target, int light_slot = LightAttrib::get_class_slot(); if (_target_rs->get_attrib(light_slot) != _state_rs->get_attrib(light_slot) || !_state_mask.get_bit(light_slot)) { - //PStatTimer timer(_draw_set_state_light_pcollector); + // PStatTimer timer(_draw_set_state_light_pcollector); do_issue_light(); _state_mask.set_bit(light_slot); } @@ -3364,7 +3206,7 @@ set_state_and_transform(const RenderState *target, int stencil_slot = StencilAttrib::get_class_slot(); if (_target_rs->get_attrib(stencil_slot) != _state_rs->get_attrib(stencil_slot) || !_state_mask.get_bit(stencil_slot)) { - //PStatTimer timer(_draw_set_state_stencil_pcollector); + // PStatTimer timer(_draw_set_state_stencil_pcollector); do_issue_stencil(); _state_mask.set_bit(stencil_slot); } @@ -3372,7 +3214,7 @@ set_state_and_transform(const RenderState *target, int fog_slot = FogAttrib::get_class_slot(); if (_target_rs->get_attrib(fog_slot) != _state_rs->get_attrib(fog_slot) || !_state_mask.get_bit(fog_slot)) { - //PStatTimer timer(_draw_set_state_fog_pcollector); + // PStatTimer timer(_draw_set_state_fog_pcollector); do_issue_fog(); _state_mask.set_bit(fog_slot); if (_current_shader_context) { @@ -3383,7 +3225,7 @@ set_state_and_transform(const RenderState *target, int scissor_slot = ScissorAttrib::get_class_slot(); if (_target_rs->get_attrib(scissor_slot) != _state_rs->get_attrib(scissor_slot) || !_state_mask.get_bit(scissor_slot)) { - //PStatTimer timer(_draw_set_state_scissor_pcollector); + // PStatTimer timer(_draw_set_state_scissor_pcollector); do_issue_scissor(); _state_mask.set_bit(scissor_slot); } @@ -3391,19 +3233,16 @@ set_state_and_transform(const RenderState *target, _state_rs = _target_rs; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void DXGraphicsStateGuardian9:: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { - // Get the light in "world coordinates" (actually, view - // coordinates). This means the light in the coordinate space of - // the camera, converted to DX's coordinate system. + // Get the light in "world coordinates" (actually, view coordinates). This + // means the light in the coordinate space of the camera, converted to DX's + // coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); const LMatrix4 &light_mat = transform->get_mat(); LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); @@ -3418,8 +3257,8 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { LColorf color = LCAST(float, light_obj->get_specular_color()); alight.Specular = *(D3DCOLORVALUE *)(color.get_data()); - // Position needs to specify x, y, z, and w - // w == 1 implies non-infinite position + // Position needs to specify x, y, z, and w w == 1 implies non-infinite + // position alight.Position = *(D3DVECTOR *)pos.get_data(); alight.Range = __D3DLIGHT_RANGE_MAX; @@ -3438,25 +3277,22 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void DXGraphicsStateGuardian9:: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { static PStatCollector _draw_set_state_light_bind_directional_pcollector("Draw:Set State:Light:Bind:Directional"); - //PStatTimer timer(_draw_set_state_light_bind_directional_pcollector); + // PStatTimer timer(_draw_set_state_light_bind_directional_pcollector); pair lookup = _dlights.insert(DirectionalLights::value_type(light, D3DLIGHT9())); D3DLIGHT9 &fdata = (*lookup.first).second; if (lookup.second) { - // Get the light in "world coordinates" (actually, view - // coordinates). This means the light in the coordinate space of - // the camera, converted to DX's coordinate system. + // Get the light in "world coordinates" (actually, view coordinates). + // This means the light in the coordinate space of the camera, converted + // to DX's coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); const LMatrix4 &light_mat = transform->get_mat(); LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); @@ -3482,8 +3318,8 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { fdata.Attenuation2 = 0.0f; // quadratic } - // We have to reset the Diffuse color at each call, because it might - // have changed independently of the light object itself (due to + // We have to reset the Diffuse color at each call, because it might have + // changed independently of the light object itself (due to // color_scale_via_lighting being in effect). fdata.Diffuse = get_light_color(light_obj); @@ -3495,22 +3331,19 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void DXGraphicsStateGuardian9:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { Lens *lens = light_obj->get_lens(); nassertv(lens != (Lens *)NULL); - // Get the light in "world coordinates" (actually, view - // coordinates). This means the light in the coordinate space of - // the camera, converted to DX's coordinate system. + // Get the light in "world coordinates" (actually, view coordinates). This + // means the light in the coordinate space of the camera, converted to DX's + // coordinate system. CPT(TransformState) transform = light.get_transform(_scene_setup->get_camera_path()); const LMatrix4 &light_mat = transform->get_mat(); LMatrix4 rel_mat = light_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); @@ -3535,9 +3368,8 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { alight.Range = __D3DLIGHT_RANGE_MAX; - // I determined this formular empirically. It seems to mostly - // approximate the OpenGL spotlight equation, for a reasonable range - // of values for FOV. + // I determined this formular empirically. It seems to mostly approximate + // the OpenGL spotlight equation, for a reasonable range of values for FOV. PN_stdfloat fov = lens->get_hfov(); alight.Falloff = light_obj->get_exponent() * (fov * fov * fov) / 1620000.0f; @@ -3557,12 +3389,9 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_index_type -// Access: Protected, Static -// Description: Maps from the Geom's internal numeric type symbols -// to DirectX's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Geom's internal numeric type symbols to DirectX's. + */ D3DFORMAT DXGraphicsStateGuardian9:: get_index_type(Geom::NumericType numeric_type) { switch (numeric_type) { @@ -3578,11 +3407,9 @@ get_index_type(Geom::NumericType numeric_type) { return D3DFMT_INDEX16; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_material -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_material() { static Material empty; @@ -3647,11 +3474,9 @@ do_issue_material() { _d3d_device->SetMaterial(&cur_material); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_texture -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_texture() { DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1)); @@ -3676,11 +3501,9 @@ do_issue_texture() { _texture_binding_shader_context = _current_shader_context; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::disable_standard_texture_bindings -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: disable_standard_texture_bindings() { // Disable the texture stages that are no longer used. @@ -3701,11 +3524,9 @@ disable_standard_texture_bindings() { _num_active_texture_stages = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::update_standard_texture_bindings -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: update_standard_texture_bindings() { DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1)); @@ -3721,9 +3542,9 @@ update_standard_texture_bindings() { _texture_involves_color_scale = false; - // We have to match up the texcoord stage index to the order written - // out by the DXGeomMunger. This means the texcoord names are - // written in the order indicated by the TextureAttrib. + // We have to match up the texcoord stage index to the order written out by + // the DXGeomMunger. This means the texcoord names are written in the order + // indicated by the TextureAttrib. int si; for (si = 0; si < num_stages; si++) { @@ -3734,8 +3555,8 @@ update_standard_texture_bindings() { nassertv(texture != (Texture *)NULL); const SamplerState &sampler = _target_texture->get_on_sampler(stage); - // We always reissue every stage in DX, just in case the texcoord - // index or texgen mode or some other property has changed. + // We always reissue every stage in DX, just in case the texcoord index or + // texgen mode or some other property has changed. int view = get_current_tex_view_offset() + stage->get_tex_view_offset(); TextureContext *tc = texture->prepare_now(view, _prepared_objects, this); apply_texture(si, tc, sampler); @@ -3763,9 +3584,9 @@ update_standard_texture_bindings() { { set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); - // This texture matrix, applied on top of the texcoord - // computed by D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, - // approximates the effect produced by OpenGL's GL_SPHERE_MAP. + // This texture matrix, applied on top of the texcoord computed by + // D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, approximates the effect + // produced by OpenGL's GL_SPHERE_MAP. static CPT(TransformState) sphere_map = TransformState::make_mat(LMatrix4(0.33, 0.0f, 0.0f, 0.0f, 0.0f, 0.33, 0.0f, 0.0f, @@ -3778,9 +3599,9 @@ update_standard_texture_bindings() { case TexGenAttrib::M_world_cube_map: // To achieve world reflection vector, we must transform camera - // coordinates to world coordinates; i.e. apply the camera - // transform. In the case of a vector, we should not apply the - // pos component of the transform. + // coordinates to world coordinates; i.e. apply the camera transform. + // In the case of a vector, we should not apply the pos component of the + // transform. { set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR); @@ -3798,10 +3619,9 @@ update_standard_texture_bindings() { break; case TexGenAttrib::M_world_normal: - // To achieve world normal, we must transform camera coordinates - // to world coordinates; i.e. apply the camera transform. In - // the case of a normal, we should not apply the pos component - // of the transform. + // To achieve world normal, we must transform camera coordinates to + // world coordinates; i.e. apply the camera transform. In the case of + // a normal, we should not apply the pos component of the transform. { set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACENORMAL); @@ -3819,9 +3639,8 @@ update_standard_texture_bindings() { break; case TexGenAttrib::M_world_position: - // To achieve world position, we must transform camera - // coordinates to world coordinates; i.e. apply the - // camera transform. + // To achieve world position, we must transform camera coordinates to + // world coordinates; i.e. apply the camera transform. { set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACEPOSITION); @@ -3845,15 +3664,15 @@ update_standard_texture_bindings() { case TexGenAttrib::M_constant: // To generate a constant UV(w) coordinate everywhere, we use - // CAMERASPACEPOSITION coordinates, but we construct a special - // matrix that flattens the existing values to zero and then - // adds our desired value. + // CAMERASPACEPOSITION coordinates, but we construct a special matrix + // that flattens the existing values to zero and then adds our desired + // value. - // The only reason we need to specify CAMERASPACEPOSITION at - // all, instead of using whatever texture coordinates (if any) - // happen to be on the vertices, is because we need to guarantee - // that there are 3-d texture coordinates, because of the - // 3-component texture coordinate in get_constant_value(). + // The only reason we need to specify CAMERASPACEPOSITION at all, + // instead of using whatever texture coordinates (if any) happen to be + // on the vertices, is because we need to guarantee that there are 3-d + // texture coordinates, because of the 3-component texture coordinate in + // get_constant_value(). { set_texture_stage_state(si, D3DTSS_TEXCOORDINDEX, texcoord_index | D3DTSS_TCI_CAMERASPACEPOSITION); @@ -3887,8 +3706,8 @@ update_standard_texture_bindings() { _d3d_device->SetTransform(get_tex_mat_sym(si), (D3DMATRIX *)mf.get_data()); DWORD transform_flags = texcoord_dimensions; if (mf.get_col(3) != LVecBase4f(0.0f, 0.0f, 0.0f, 1.0f)) { - // If we have a projected texture matrix, we also need to - // set D3DTTFF_COUNT4. + // If we have a projected texture matrix, we also need to set + // D3DTTFF_COUNT4. transform_flags = D3DTTFF_COUNT4 | D3DTTFF_PROJECTED; } set_texture_stage_state(si, D3DTSS_TEXTURETRANSFORMFLAGS, @@ -3898,9 +3717,9 @@ update_standard_texture_bindings() { } else { set_texture_stage_state(si, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); - // For some reason, "disabling" texture coordinate transforms - // doesn't seem to be sufficient. We'll load an identity matrix - // to underscore the point. + // For some reason, "disabling" texture coordinate transforms doesn't + // seem to be sufficient. We'll load an identity matrix to underscore + // the point. _d3d_device->SetTransform(get_tex_mat_sym(si), &_d3d_ident_mat); } } @@ -3915,20 +3734,16 @@ update_standard_texture_bindings() { _num_active_texture_stages = num_stages; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_blending -// Access: Protected, Virtual -// Description: Called after any of the things that might change -// blending state have changed, this function is -// responsible for setting the appropriate color -// blending mode based on the current properties. -//////////////////////////////////////////////////////////////////// +/** + * Called after any of the things that might change blending state have + * changed, this function is responsible for setting the appropriate color + * blending mode based on the current properties. + */ void DXGraphicsStateGuardian9:: do_issue_blending() { - // Handle the color_write attrib. If color_write is off, then - // all the other blending-related stuff doesn't matter. If the - // device doesn't support color-write, we use blending tricks - // to effectively disable color write. + // Handle the color_write attrib. If color_write is off, then all the other + // blending-related stuff doesn't matter. If the device doesn't support + // color-write, we use blending tricks to effectively disable color write. const ColorWriteAttrib *target_color_write = DCAST(ColorWriteAttrib, _target_rs->get_attrib_def(ColorWriteAttrib::get_class_slot())); unsigned int color_channels = target_color_write->get_channels() & _color_write_mask; @@ -4017,41 +3832,32 @@ do_issue_blending() { set_render_state(D3DRS_ALPHABLENDENABLE, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::reissue_transforms -// Access: Protected, Virtual -// Description: Called by clear_state_and_transform() to ensure that -// the current modelview and projection matrices are -// properly loaded in the graphics state, after a -// callback might have mucked them up. -//////////////////////////////////////////////////////////////////// +/** + * Called by clear_state_and_transform() to ensure that the current modelview + * and projection matrices are properly loaded in the graphics state, after a + * callback might have mucked them up. + */ void DXGraphicsStateGuardian9:: reissue_transforms() { prepare_lens(); do_issue_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::enable_lighting -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable or disable the use of lighting overall. This -// is called by issue_light() according to whether any -// lights are in use or not. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable or disable the use + * of lighting overall. This is called by issue_light() according to whether + * any lights are in use or not. + */ void DXGraphicsStateGuardian9:: enable_lighting(bool enable) { set_render_state(D3DRS_LIGHTING, (DWORD)enable); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_ambient_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// indicate the color of the ambient light that should -// be in effect. This is called by issue_light() after -// all other lights have been enabled or disabled. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to indicate the color of the + * ambient light that should be in effect. This is called by issue_light() + * after all other lights have been enabled or disabled. + */ void DXGraphicsStateGuardian9:: set_ambient_light(const LColor &color) { LColor c = color; @@ -4063,13 +3869,11 @@ set_ambient_light(const LColor &color) { set_render_state(D3DRS_AMBIENT, LColor_to_D3DCOLOR(c)); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::enable_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated light id. A specific Light will -// already have been bound to this id via bind_light(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated light + * id. A specific Light will already have been bound to this id via + * bind_light(). + */ void DXGraphicsStateGuardian9:: enable_light(int light_id, bool enable) { HRESULT hr = _d3d_device->LightEnable(light_id, enable); @@ -4081,14 +3885,11 @@ enable_light(int light_id, bool enable) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::enable_clip_plane -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated clip_plane id. A specific -// PlaneNode will already have been bound to this id via -// bind_clip_plane(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated + * clip_plane id. A specific PlaneNode will already have been bound to this + * id via bind_clip_plane(). + */ void DXGraphicsStateGuardian9:: enable_clip_plane(int plane_id, bool enable) { if (enable) { @@ -4099,19 +3900,16 @@ enable_clip_plane(int plane_id, bool enable) { set_render_state(D3DRS_CLIPPLANEENABLE, _clip_plane_bits); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::bind_clip_plane -// Access: Protected, Virtual -// Description: Called the first time a particular clip_plane has been -// bound to a given id within a frame, this should set -// up the associated hardware clip_plane with the clip_plane's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular clip_plane has been bound to a given id + * within a frame, this should set up the associated hardware clip_plane with + * the clip_plane's properties. + */ void DXGraphicsStateGuardian9:: bind_clip_plane(const NodePath &plane, int plane_id) { - // Get the plane in "world coordinates" (actually, view - // coordinates). This means the plane in the coordinate space of - // the camera, converted to DX's coordinate system. + // Get the plane in "world coordinates" (actually, view coordinates). This + // means the plane in the coordinate space of the camera, converted to DX's + // coordinate system. CPT(TransformState) transform = plane.get_transform(_scene_setup->get_camera_path()); const LMatrix4 &plane_mat = transform->get_mat(); LMatrix4 rel_mat = plane_mat * LMatrix4::convert_mat(CS_yup_left, CS_default); @@ -4127,14 +3925,11 @@ bind_clip_plane(const NodePath &plane, int plane_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::close_gsg -// Access: Protected, Virtual -// Description: This is called by the associated GraphicsWindow when -// close_window() is called. It should null out the -// _win pointer and possibly free any open resources -// associated with the GSG. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the associated GraphicsWindow when close_window() is + * called. It should null out the _win pointer and possibly free any open + * resources associated with the GSG. + */ void DXGraphicsStateGuardian9:: close_gsg() { GraphicsStateGuardian::close_gsg(); @@ -4149,25 +3944,21 @@ close_gsg() { << _prepared_objects->get_ref_count() << "\n"; } - // Unlike in OpenGL, in DX9 it is safe to try to explicitly release - // any textures here. And it may even be a good idea. + // Unlike in OpenGL, in DX9 it is safe to try to explicitly release any + // textures here. And it may even be a good idea. if (_prepared_objects->get_ref_count() == 1) { release_all(); - // Now we need to actually delete all of the objects we just - // released. + // Now we need to actually delete all of the objects we just released. Thread *current_thread = Thread::get_current_thread(); _prepared_objects->begin_frame(this, current_thread); _prepared_objects->end_frame(current_thread); } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::free_nondx_resources -// Access: Public -// Description: Frees some memory that was explicitly allocated -// within the dxgsg. -//////////////////////////////////////////////////////////////////// +/** + * Frees some memory that was explicitly allocated within the dxgsg. + */ void DXGraphicsStateGuardian9:: free_nondx_resources() { #ifdef HAVE_CG @@ -4178,12 +3969,10 @@ free_nondx_resources() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::free_d3d_device -// Access: Public -// Description: setup for re-calling dx_init(), this is not the final -// exit cleanup routine (see dx_cleanup) -//////////////////////////////////////////////////////////////////// +/** + * setup for re-calling dx_init(), this is not the final exit cleanup routine + * (see dx_cleanup) + */ void DXGraphicsStateGuardian9:: free_d3d_device() { // dont want a full reset of gsg, just a state clear @@ -4212,25 +4001,20 @@ free_d3d_device() { // obviously we dont release ID3D9, just ID3DDevice9 } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_draw_buffer -// Access: Protected -// Description: Sets up the glDrawBuffer to render into the buffer -// indicated by the RenderBuffer object. This only sets -// up the color bits; it does not affect the depth, -// stencil, accum layers. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the glDrawBuffer to render into the buffer indicated by the + * RenderBuffer object. This only sets up the color bits; it does not affect + * the depth, stencil, accum layers. + */ void DXGraphicsStateGuardian9:: set_draw_buffer(const RenderBuffer &rb) { dxgsg9_cat.fatal() << "DX set_draw_buffer unimplemented!!!"; return; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_read_buffer -// Access: Protected -// Description: Vestigial analog of glReadBuffer -//////////////////////////////////////////////////////////////////// +/** + * Vestigial analog of glReadBuffer + */ void DXGraphicsStateGuardian9:: set_read_buffer(const RenderBuffer &rb) { if (rb._buffer_type & RenderBuffer::T_front) { @@ -4245,14 +4029,11 @@ set_read_buffer(const RenderBuffer &rb) { return; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_light_color -// Access: Public -// Description: Returns the array of four floats that should be -// issued as the light's color, as scaled by the current -// value of _light_color_scale, in the case of -// color_scale_via_lighting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array of four floats that should be issued as the light's + * color, as scaled by the current value of _light_color_scale, in the case of + * color_scale_via_lighting. + */ const D3DCOLORVALUE &DXGraphicsStateGuardian9:: get_light_color(Light *light) const { LColor c = light->get_color(); @@ -4264,12 +4045,9 @@ get_light_color(Light *light) const { return *(D3DCOLORVALUE *)cf.get_data(); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_blend_func -// Access: Protected, Static -// Description: Maps from ColorBlendAttrib::Operand to D3DBLEND -// value. -//////////////////////////////////////////////////////////////////// +/** + * Maps from ColorBlendAttrib::Operand to D3DBLEND value. + */ D3DBLEND DXGraphicsStateGuardian9:: get_blend_func(ColorBlendAttrib::Operand operand) { switch (operand) { @@ -4328,11 +4106,9 @@ get_blend_func(ColorBlendAttrib::Operand operand) { return D3DBLEND_ZERO; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::report_texmgr_stats -// Access: Protected -// Description: Reports the DX texture manager's activity to PStats. -//////////////////////////////////////////////////////////////////// +/** + * Reports the DX texture manager's activity to PStats. + */ void DXGraphicsStateGuardian9:: report_texmgr_stats() { @@ -4406,11 +4182,9 @@ report_texmgr_stats() { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_context -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: set_context(DXScreenData *new_context) { nassertv(new_context != NULL); @@ -4422,12 +4196,9 @@ set_context(DXScreenData *new_context) { set_cg_device(_d3d_device); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_render_target -// Access: Protected -// Description: Set render target to the backbuffer of current swap -// chain. -//////////////////////////////////////////////////////////////////// +/** + * Set render target to the backbuffer of current swap chain. + */ void DXGraphicsStateGuardian9:: set_render_target() { if (_d3d_device == NULL) { @@ -4446,12 +4217,12 @@ set_render_target() { else _swap_chain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &back); - //wdxdisplay9_cat.debug() << "swapchain is " << _swap_chain << "\n"; - //wdxdisplay9_cat.debug() << "back buffer is " << back << "\n"; + // wdxdisplay9_cat.debug() << "swapchain is " << _swap_chain << "\n"; + // wdxdisplay9_cat.debug() << "back buffer is " << back << "\n"; _d3d_device->GetDepthStencilSurface(&stencil); -// _d3d_device->SetRenderTarget(back, stencil); +// _d3d_device->SetRenderTarget(back, stencil); DWORD render_target_index; render_target_index = 0; _d3d_device->SetRenderTarget(render_target_index, back); @@ -4464,11 +4235,9 @@ set_render_target() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_texture_blend_mode -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: set_texture_blend_mode(int i, const TextureStage *stage) { switch (stage->get_mode()) { @@ -4527,8 +4296,8 @@ set_texture_blend_mode(int i, const TextureStage *stage) { break; case TextureStage::M_combine: - // M_combine mode begins a collection of more sophisticated modes, - // which match up more closely with DirectX's built-in modes. + // M_combine mode begins a collection of more sophisticated modes, which + // match up more closely with DirectX's built-in modes. set_texture_stage_state (i, D3DTSS_COLOROP, get_texture_operation(stage->get_combine_rgb_mode(), @@ -4622,19 +4391,17 @@ set_texture_blend_mode(int i, const TextureStage *stage) { if (_supports_texture_constant_color) { set_texture_stage_state(i, D3DTSS_CONSTANT, constant_color); } else { - // This device doesn't supoprt a per-stage constant color, so we - // have to fall back to a single constant color for the overall - // texture pipeline. + // This device doesn't supoprt a per-stage constant color, so we have to + // fall back to a single constant color for the overall texture + // pipeline. set_render_state(D3DRS_TEXTUREFACTOR, constant_color); } } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::dx_cleanup -// Access: Protected -// Description: Clean up the DirectX environment, accounting for exit() -//////////////////////////////////////////////////////////////////// +/** + * Clean up the DirectX environment, accounting for exit() + */ void DXGraphicsStateGuardian9:: dx_cleanup() { if (!_d3d_device) { @@ -4644,25 +4411,21 @@ dx_cleanup() { free_nondx_resources(); PRINT_REFCNT(dxgsg9, _d3d_device); - // Do a safe check for releasing the D3DDEVICE. RefCount should be zero. - // if we're called from exit(), _d3d_device may already have been released + // Do a safe check for releasing the D3DDEVICE. RefCount should be zero. if + // we're called from exit(), _d3d_device may already have been released RELEASE(_d3d_device, dxgsg9, "d3dDevice", RELEASE_DOWN_TO_ZERO); _screen->_d3d_device = NULL; // Releasing pD3D is now the responsibility of the GraphicsPipe destructor } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::reset_d3d_device -// Access: Protected -// Description: This function checks current device's framebuffer -// dimension against passed p_presentation_params backbuffer -// dimension to determine a device reset if there is -// only one window or it is the main window or -// fullscreen mode then, it resets the device. Finally -// it returns the new DXScreenData through parameter -// screen -//////////////////////////////////////////////////////////////////// +/** + * This function checks current device's framebuffer dimension against passed + * p_presentation_params backbuffer dimension to determine a device reset if + * there is only one window or it is the main window or fullscreen mode then, + * it resets the device. Finally it returns the new DXScreenData through + * parameter screen + */ HRESULT DXGraphicsStateGuardian9:: reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, DXScreenData **screen) { @@ -4672,15 +4435,15 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, nassertr(IS_VALID_PTR(_screen->_d3d9), E_FAIL); nassertr(IS_VALID_PTR(_d3d_device), E_FAIL); - // for windowed mode make sure our format matches the desktop fmt, - // in case the desktop mode has been changed + // for windowed mode make sure our format matches the desktop fmt, in case + // the desktop mode has been changed _screen->_d3d9->GetAdapterDisplayMode(_screen->_card_id, &_screen->_display_mode); presentation_params->BackBufferFormat = _screen->_display_mode.Format; - // here we have to look at the _presentation_reset frame buffer dimension - // if current window's dimension is bigger than _presentation_reset - // we have to reset the device before creating new swapchain. - // inorder to reset properly, we need to release all swapchains + // here we have to look at the _presentation_reset frame buffer dimension if + // current window's dimension is bigger than _presentation_reset we have to + // reset the device before creating new swapchain. inorder to reset + // properly, we need to release all swapchains if (true || !(_screen->_swap_chain) || (_presentation_reset.BackBufferWidth < presentation_params->BackBufferWidth) @@ -4704,13 +4467,12 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, _presentation_reset.BackBufferHeight = presentation_params->BackBufferHeight; } - // Calling this forces all of the textures and vbuffers to be - // regenerated, a prerequisite to calling Reset(). + // Calling this forces all of the textures and vbuffers to be regenerated, + // a prerequisite to calling Reset(). release_all(); - // Just to be extra-conservative for now, we'll go ahead and - // release the vbuffers and ibuffers at least; they're relatively - // cheap to replace. + // Just to be extra-conservative for now, we'll go ahead and release the + // vbuffers and ibuffers at least; they're relatively cheap to replace. release_all_vertex_buffers(); release_all_index_buffers(); @@ -4776,11 +4538,9 @@ reset_d3d_device(D3DPRESENT_PARAMETERS *presentation_params, return hr; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::check_cooperative_level -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DXGraphicsStateGuardian9:: check_cooperative_level() { bool bDoReactivateWindow = false; @@ -4839,11 +4599,9 @@ check_cooperative_level() { return SUCCEEDED(hr); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::show_frame -// Access: Protected -// Description: redraw primary buffer -//////////////////////////////////////////////////////////////////// +/** + * redraw primary buffer + */ void DXGraphicsStateGuardian9:: show_frame() { if (_d3d_device == NULL) { @@ -4872,16 +4630,14 @@ show_frame() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::create_swap_chain -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DXGraphicsStateGuardian9:: create_swap_chain(DXScreenData *new_context) { - // Instead of creating a device and rendering as d3ddevice->present() - // we should render using SwapChain->present(). This is done to support - // multiple windows rendering. For that purpose, we need to set additional + // Instead of creating a device and rendering as d3ddevice->present() we + // should render using SwapChain->present(). This is done to support + // multiple windows rendering. For that purpose, we need to set additional // swap chains here. HRESULT hr; @@ -4893,11 +4649,9 @@ create_swap_chain(DXScreenData *new_context) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::release_swap_chain -// Access: Protected -// Description: Release the swap chain on this DXScreenData -//////////////////////////////////////////////////////////////////// +/** + * Release the swap chain on this DXScreenData + */ bool DXGraphicsStateGuardian9:: release_swap_chain(DXScreenData *new_context) { HRESULT hr; @@ -4911,21 +4665,17 @@ release_swap_chain(DXScreenData *new_context) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::copy_pres_reset -// Access: Protected -// Description: copies the PresReset from passed DXScreenData -//////////////////////////////////////////////////////////////////// +/** + * copies the PresReset from passed DXScreenData + */ void DXGraphicsStateGuardian9:: copy_pres_reset(DXScreenData *screen) { memcpy(&_presentation_reset, &_screen->_presentation_params, sizeof(D3DPRESENT_PARAMETERS)); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_d3d_min_type -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ D3DTEXTUREFILTERTYPE DXGraphicsStateGuardian9:: get_d3d_min_type(SamplerState::FilterType filter_type) { switch (filter_type) { @@ -4957,11 +4707,9 @@ get_d3d_min_type(SamplerState::FilterType filter_type) { return D3DTEXF_POINT; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_d3d_mip_type -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ D3DTEXTUREFILTERTYPE DXGraphicsStateGuardian9:: get_d3d_mip_type(SamplerState::FilterType filter_type) { switch (filter_type) { @@ -4993,12 +4741,10 @@ get_d3d_mip_type(SamplerState::FilterType filter_type) { return D3DTEXF_NONE; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_texture_operation -// Access: Protected, Static -// Description: Returns the D3DTEXTUREOP value corresponding to the -// indicated TextureStage::CombineMode enumerated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the D3DTEXTUREOP value corresponding to the indicated + * TextureStage::CombineMode enumerated type. + */ D3DTEXTUREOP DXGraphicsStateGuardian9:: get_texture_operation(TextureStage::CombineMode mode, int scale) { switch (mode) { @@ -5041,13 +4787,11 @@ get_texture_operation(TextureStage::CombineMode mode, int scale) { return D3DTOP_DISABLE; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_texture_argument -// Access: Protected -// Description: Returns the D3DTA value corresponding to the -// indicated TextureStage::CombineSource and -// TextureStage::CombineOperand enumerated types. -//////////////////////////////////////////////////////////////////// +/** + * Returns the D3DTA value corresponding to the indicated + * TextureStage::CombineSource and TextureStage::CombineOperand enumerated + * types. + */ DWORD DXGraphicsStateGuardian9:: get_texture_argument(TextureStage::CombineSource source, TextureStage::CombineOperand operand) const { @@ -5074,13 +4818,10 @@ get_texture_argument(TextureStage::CombineSource source, return D3DTA_CURRENT; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_texture_argument_modifier -// Access: Protected, Static -// Description: Returns the extra bits that modify the D3DTA -// argument, according to the indicated -// TextureStage::CombineOperand enumerated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extra bits that modify the D3DTA argument, according to the + * indicated TextureStage::CombineOperand enumerated type. + */ DWORD DXGraphicsStateGuardian9:: get_texture_argument_modifier(TextureStage::CombineOperand operand) { switch (operand) { @@ -5104,14 +4845,11 @@ get_texture_argument_modifier(TextureStage::CombineOperand operand) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_primitive_up -// Access: Protected -// Description: Issues the DrawPrimitiveUP call to draw the indicated -// primitive_type from the given buffer. We add the -// num_vertices parameter, so we can determine the size -// of the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Issues the DrawPrimitiveUP call to draw the indicated primitive_type from + * the given buffer. We add the num_vertices parameter, so we can determine + * the size of the buffer. + */ void DXGraphicsStateGuardian9:: draw_primitive_up(D3DPRIMITIVETYPE primitive_type, unsigned int primitive_count, @@ -5119,18 +4857,17 @@ draw_primitive_up(D3DPRIMITIVETYPE primitive_type, unsigned int num_vertices, const unsigned char *buffer, size_t stride) { - // It appears that the common ATI driver seems to fail to draw - // anything in the DrawPrimitiveUP() call if the address range of - // the buffer supplied crosses over a multiple of 0x10000. That's - // incredibly broken, yet it undeniably appears to be true. We'll - // have to hack around it. + // It appears that the common ATI driver seems to fail to draw anything in + // the DrawPrimitiveUP() call if the address range of the buffer supplied + // crosses over a multiple of 0x10000. That's incredibly broken, yet it + // undeniably appears to be true. We'll have to hack around it. const unsigned char *buffer_start = buffer + stride * first_vertex; const unsigned char *buffer_end = buffer_start + stride * num_vertices; if (buffer_end - buffer_start > 0x10000) { - // Actually, the buffer doesn't fit within the required limit - // anyway. Go ahead and draw it and hope for the best. + // Actually, the buffer doesn't fit within the required limit anyway. Go + // ahead and draw it and hope for the best. _d3d_device->DrawPrimitiveUP(primitive_type, primitive_count, buffer_start, stride); @@ -5140,9 +4877,8 @@ draw_primitive_up(D3DPRIMITIVETYPE primitive_type, buffer_start, stride); } else { - // We have a problem--the buffer crosses over a 0x10000 boundary. - // We have to copy the buffer to a temporary buffer that we can - // draw from. + // We have a problem--the buffer crosses over a 0x10000 boundary. We have + // to copy the buffer to a temporary buffer that we can draw from. unsigned char *safe_buffer_start = get_safe_buffer_start(); memcpy(safe_buffer_start, buffer_start, buffer_end - buffer_start); _d3d_device->DrawPrimitiveUP(primitive_type, primitive_count, @@ -5151,17 +4887,13 @@ draw_primitive_up(D3DPRIMITIVETYPE primitive_type, } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::draw_indexed_primitive_up -// Access: Protected -// Description: Issues the DrawIndexedPrimitiveUP call to draw the -// indicated primitive_type from the given buffer. As -// in draw_primitive_up(), above, the parameter list is -// not exactly one-for-one with the -// DrawIndexedPrimitiveUP() call, but it's similar (in -// particular, we pass max_index instead of NumVertices, -// which always seemed ambiguous to me). -//////////////////////////////////////////////////////////////////// +/** + * Issues the DrawIndexedPrimitiveUP call to draw the indicated primitive_type + * from the given buffer. As in draw_primitive_up(), above, the parameter + * list is not exactly one-for-one with the DrawIndexedPrimitiveUP() call, but + * it's similar (in particular, we pass max_index instead of NumVertices, + * which always seemed ambiguous to me). + */ void DXGraphicsStateGuardian9:: draw_indexed_primitive_up(D3DPRIMITIVETYPE primitive_type, unsigned int min_index, unsigned int max_index, @@ -5175,8 +4907,8 @@ draw_indexed_primitive_up(D3DPRIMITIVETYPE primitive_type, const unsigned char *buffer_end = buffer + stride * (max_index + 1); if (buffer_end - buffer_start > 0x10000) { - // Actually, the buffer doesn't fit within the required limit - // anyway. Go ahead and draw it and hope for the best. + // Actually, the buffer doesn't fit within the required limit anyway. Go + // ahead and draw it and hope for the best. _d3d_device->DrawIndexedPrimitiveUP (primitive_type, min_index, max_index - min_index + 1, num_primitives, index_data, index_type, buffer, stride); @@ -5188,9 +4920,8 @@ draw_indexed_primitive_up(D3DPRIMITIVETYPE primitive_type, index_data, index_type, buffer, stride); } else { - // We have a problem--the buffer crosses over a 0x10000 boundary. - // We have to copy the buffer to a temporary buffer that we can - // draw from. + // We have a problem--the buffer crosses over a 0x10000 boundary. We have + // to copy the buffer to a temporary buffer that we can draw from. unsigned char *safe_buffer_start = get_safe_buffer_start(); memcpy(safe_buffer_start, buffer_start, buffer_end - buffer_start); _d3d_device->DrawIndexedPrimitiveUP @@ -5199,18 +4930,13 @@ draw_indexed_primitive_up(D3DPRIMITIVETYPE primitive_type, } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::check_dx_allocation -// Access: -// Description: This function is called after the creation of -// textures, vertex buffers, and index buffers to -// check if DirectX is out of memory. If DirectX is -// out of memory and the LRU is being used, then -// page out some memory. This function is a fail-safe -// just in case another process allocates video -// memory, DirectX is fragmented, or there are some -// borderline memory allocation cases, ... -//////////////////////////////////////////////////////////////////// +/** + * This function is called after the creation of textures, vertex buffers, and + * index buffers to check if DirectX is out of memory. If DirectX is out of + * memory and the LRU is being used, then page out some memory. This function + * is a fail-safe just in case another process allocates video memory, DirectX + * is fragmented, or there are some borderline memory allocation cases, ... + */ bool DXGraphicsStateGuardian9:: check_dx_allocation (HRESULT result, int allocation_size, int attempts) { @@ -5246,9 +4972,7 @@ check_dx_allocation (HRESULT result, int allocation_size, int attempts) return retry; } -//////////////////////////////////////////////////////////////////// -// DX stencil code section -//////////////////////////////////////////////////////////////////// +// DX stencil code section static int dx_stencil_comparison_function_array[] = { D3DCMP_NEVER, D3DCMP_LESS, @@ -5272,11 +4996,9 @@ static int dx_stencil_operation_array[] = { D3DSTENCILOP_DECRSAT, }; -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::do_issue_stencil -// Access: Protected -// Description: Set stencil render states. -//////////////////////////////////////////////////////////////////// +/** + * Set stencil render states. + */ void DXGraphicsStateGuardian9:: do_issue_stencil() { if (!_supports_stencil) { @@ -5364,11 +5086,9 @@ do_issue_stencil() { } } -//////////////////////////////////////////////////////////////////// -// Function: dxGraphicsStateGuardian9::do_issue_scissor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXGraphicsStateGuardian9:: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); @@ -5383,12 +5103,10 @@ do_issue_scissor() { set_render_state(D3DRS_SCISSORTESTENABLE, TRUE); } -//////////////////////////////////////////////////////////////////// -// Function: dxGraphicsStateGuardian9::calc_fb_properties -// Access: Public -// Description: Convert DirectX framebuffer format ids into a -// FrameBufferProperties structure. -//////////////////////////////////////////////////////////////////// +/** + * Convert DirectX framebuffer format ids into a FrameBufferProperties + * structure. + */ FrameBufferProperties DXGraphicsStateGuardian9:: calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype, DWORD multisamplequality) { @@ -5499,11 +5217,9 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, } } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_gamma_table -// Access: Public, Static -// Description: Static function for getting the original gamma. -//////////////////////////////////////////////////////////////////// +/** + * Static function for getting the original gamma. + */ bool DXGraphicsStateGuardian9:: get_gamma_table(void) { bool get; @@ -5525,12 +5241,9 @@ get_gamma_table(void) { return get; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::static_set_gamma -// Access: Public, Static -// Description: Static function for setting gamma which is needed -// for atexit. -//////////////////////////////////////////////////////////////////// +/** + * Static function for setting gamma which is needed for atexit. + */ bool DXGraphicsStateGuardian9:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; @@ -5557,12 +5270,9 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_gamma -// Access: Published -// Description: Non static version of setting gamma. Returns true -// on success. -//////////////////////////////////////////////////////////////////// +/** + * Non static version of setting gamma. Returns true on success. + */ bool DXGraphicsStateGuardian9:: set_gamma(PN_stdfloat gamma) { bool set; @@ -5575,33 +5285,27 @@ set_gamma(PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::restore_gamma -// Access: Published -// Description: Restore original gamma. -//////////////////////////////////////////////////////////////////// +/** + * Restore original gamma. + */ void DXGraphicsStateGuardian9:: restore_gamma() { static_set_gamma(true, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::atexit_function -// Access: Public, Static -// Description: This function is passed to the atexit function. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the atexit function. + */ void DXGraphicsStateGuardian9:: atexit_function(void) { set_cg_device(NULL); static_set_gamma(true, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::get_supports_cg_profile -// Access: Public, Virtual -// Description: Returns true if this particular GSG supports the -// specified Cg Shader Profile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports the specified Cg Shader + * Profile. + */ bool DXGraphicsStateGuardian9:: get_supports_cg_profile(const string &name) const { #ifndef HAVE_CG @@ -5617,13 +5321,10 @@ get_supports_cg_profile(const string &name) const { #endif // HAVE_CG } -//////////////////////////////////////////////////////////////////// -// Function: DXGraphicsStateGuardian9::set_cg_device -// Access: Protected, Static -// Description: Sets the global Cg device pointer. TODO: make this -// thread-safe somehow. Maybe Cg is inherently not -// thread-safe. -//////////////////////////////////////////////////////////////////// +/** + * Sets the global Cg device pointer. TODO: make this thread-safe somehow. + * Maybe Cg is inherently not thread-safe. + */ void DXGraphicsStateGuardian9:: set_cg_device(LPDIRECT3DDEVICE9 cg_device) { #ifdef HAVE_CG diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index b31e1940f4..4a51d214cb 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -1,17 +1,17 @@ -// Filename: dxGraphicsStateGuardian9.h -// Created by: mike (02Feb99) -// Updated by: fperazzi, PandaSE (05May10) (added get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxGraphicsStateGuardian9.h + * @author mike + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + */ #ifndef DXGRAPHICSSTATEGUARDIAN9_H #define DXGRAPHICSSTATEGUARDIAN9_H @@ -51,11 +51,9 @@ class DXIndexBufferContext9; class wdxGraphicsBuffer9; -//////////////////////////////////////////////////////////////////// -// Class : DXGraphicsStateGuardian9 -// Description : A GraphicsStateGuardian for rendering into DirectX9 -// contexts. -//////////////////////////////////////////////////////////////////// +/** + * A GraphicsStateGuardian for rendering into DirectX9 contexts. + */ class EXPCL_PANDADX DXGraphicsStateGuardian9 : public GraphicsStateGuardian { public: DXGraphicsStateGuardian9(GraphicsEngine *engine, GraphicsPipe *pipe); @@ -323,9 +321,9 @@ protected: DWORD _last_fvf; int _num_bound_streams; - // Cache the data necessary to bind each particular light each - // frame, so if we bind a given light multiple times, we only have - // to compute its data once. + // Cache the data necessary to bind each particular light each frame, so if + // we bind a given light multiple times, we only have to compute its data + // once. typedef pmap DirectionalLights; DirectionalLights _dlights; diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.I b/panda/src/dxgsg9/dxIndexBufferContext9.I index b184a9d390..0c0d3dbf11 100644 --- a/panda/src/dxgsg9/dxIndexBufferContext9.I +++ b/panda/src/dxgsg9/dxIndexBufferContext9.I @@ -1,13 +1,12 @@ -// Filename: dxIndexBufferContext9.I -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxIndexBufferContext9.I + * @author drose + * @date 2005-03-18 + */ diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.cxx b/panda/src/dxgsg9/dxIndexBufferContext9.cxx index deaf5740bc..51429d67c8 100644 --- a/panda/src/dxgsg9/dxIndexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxIndexBufferContext9.cxx @@ -1,16 +1,15 @@ -// Filename: dxIndexBufferContext9.cxx -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxIndexBufferContext9.cxx + * @author drose + * @date 2005-03-18 + */ #include "dxIndexBufferContext9.h" #include "geomPrimitive.h" @@ -22,11 +21,9 @@ TypeHandle DXIndexBufferContext9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXIndexBufferContext9:: DXIndexBufferContext9(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : IndexBufferContext(pgo, data), @@ -35,32 +32,25 @@ DXIndexBufferContext9(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : _managed = -1; } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXIndexBufferContext9:: ~DXIndexBufferContext9() { this -> free_ibuffer ( ); } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void DXIndexBufferContext9:: evict_lru() { dequeue_lru(); @@ -69,11 +59,9 @@ evict_lru() { mark_unloaded(); } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::free_ibuffer -// Access: Public -// Description: Free index buffer. -//////////////////////////////////////////////////////////////////// +/** + * Free index buffer. + */ void DXIndexBufferContext9:: free_ibuffer(void) { if (_ibuffer != NULL) { @@ -95,11 +83,9 @@ free_ibuffer(void) { } } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::allocate_ibuffer -// Access: Public -// Description: Allocates index buffer memory. -//////////////////////////////////////////////////////////////////// +/** + * Allocates index buffer memory. + */ void DXIndexBufferContext9:: allocate_ibuffer(DXScreenData &scrn, const GeomPrimitivePipelineReader *reader) { @@ -152,14 +138,11 @@ allocate_ibuffer(DXScreenData &scrn, } } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::create_ibuffer -// Access: Public -// Description: Creates a new index buffer (but does not upload data -// to it). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new index buffer (but does not upload data to it). + */ void DXIndexBufferContext9:: -create_ibuffer(DXScreenData &scrn, +create_ibuffer(DXScreenData &scrn, const GeomPrimitivePipelineReader *reader) { nassertv(reader->get_object() == get_data()); Thread *current_thread = reader->get_current_thread(); @@ -176,12 +159,9 @@ create_ibuffer(DXScreenData &scrn, this -> allocate_ibuffer(scrn, reader); } -//////////////////////////////////////////////////////////////////// -// Function: DXIndexBufferContext9::upload_data -// Access: Public -// Description: Copies the latest data from the client store to -// DirectX. -//////////////////////////////////////////////////////////////////// +/** + * Copies the latest data from the client store to DirectX. + */ bool DXIndexBufferContext9:: upload_data(const GeomPrimitivePipelineReader *reader, bool force) { nassertr(reader->get_object() == get_data(), false); diff --git a/panda/src/dxgsg9/dxIndexBufferContext9.h b/panda/src/dxgsg9/dxIndexBufferContext9.h index 37349449a4..f7354665dd 100644 --- a/panda/src/dxgsg9/dxIndexBufferContext9.h +++ b/panda/src/dxgsg9/dxIndexBufferContext9.h @@ -1,16 +1,15 @@ -// Filename: dxIndexBufferContext9.h -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxIndexBufferContext9.h + * @author drose + * @date 2005-03-18 + */ #ifndef DXINDEXBUFFERCONTEXT9_H #define DXINDEXBUFFERCONTEXT9_H @@ -19,11 +18,9 @@ #include "dxgsg9base.h" #include "indexBufferContext.h" -//////////////////////////////////////////////////////////////////// -// Class : DXIndexBufferContext9 -// Description : Caches a GeomPrimitive in the DirectX device as -// an index buffer. -//////////////////////////////////////////////////////////////////// +/** + * Caches a GeomPrimitive in the DirectX device as an index buffer. + */ class EXPCL_PANDADX DXIndexBufferContext9 : public IndexBufferContext { public: DXIndexBufferContext9(PreparedGraphicsObjects *pgo, GeomPrimitive *data); diff --git a/panda/src/dxgsg9/dxInput9.cxx b/panda/src/dxgsg9/dxInput9.cxx index d4f49bc5ac..24e3ea16f3 100644 --- a/panda/src/dxgsg9/dxInput9.cxx +++ b/panda/src/dxgsg9/dxInput9.cxx @@ -1,16 +1,15 @@ -// Filename: dxInput9.cxx -// Created by: angelina jolie (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxInput9.cxx + * @author angelina jolie + * @date 1999-10-07 + */ #include "config_wdxdisplay9.h" #include "dxInput9.h" @@ -44,9 +43,7 @@ DInput9Info::~DInput9Info() { SAFE_RELEASE(_DeviceList[i]); } - // bugbug: need to handle this - // if(_JoystickPollTimer!=NULL) - // KillTimer(...) + // bugbug: need to handle this if(_JoystickPollTimer!=NULL) KillTimer(...) SAFE_RELEASE(_pDInput9); if(_hDInputDLL) { @@ -58,8 +55,8 @@ DInput9Info::~DInput9Info() { bool DInput9Info::InitDirectInput() { HRESULT hr; - // assumes dx9 exists - // use dynamic load so non-dinput programs don't have to load dinput + // assumes dx9 exists use dynamic load so non-dinput programs don't have + // to load dinput #define DLLNAME "dinput9.dll" #define DINPUTCREATE "DirectInput9Create" @@ -78,16 +75,15 @@ bool DInput9Info::InitDirectInput() { exit(1); } - // Register with the DirectInput subsystem and get a pointer - // to a IDirectInput interface we can use. - // Create a DInput object + // Register with the DirectInput subsystem and get a pointer to a + // IDirectInput interface we can use. Create a DInput object if( FAILED( hr = (*pDInputCreate9)(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput9, (VOID**)&_pDInput9, NULL ) ) ) { wdxdisplay_cat.error() << DINPUTCREATE << "failed" << D3DERRORSTRING(hr); return false; } - // enum all the joysticks,etc (but not keybd/mouse) + // enum all the joysticks,etc (but not keybdmouse) if( FAILED( hr = _pDInput9->EnumDevices(DI9DEVCLASS_GAMECTRL, EnumGameCtrlsCallback, (LPVOID)&_DevInfos, DIEDFL_ATTACHEDONLY ) ) ) { @@ -129,11 +125,11 @@ bool DInput9Info::CreateJoystickOrPad(HWND _window) { assert(pJoyDevice!=NULL); _DeviceList.push_back(pJoyDevice); - // Set the data format to "simple joystick" - a predefined data format - // - // A data format specifies which controls on a device we are interested in, - // and how they should be reported. This tells DInput that we will be - // passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState(). + // Set the data format to "simple joystick" - a predefined data format A + // data format specifies which controls on a device we are interested in, + // and how they should be reported. This tells DInput that we will be + // passing a DIJOYSTATE2 structure to + // IDirectInputDevice::GetDeviceState(). hr = pJoyDevice->SetDataFormat(&c_dfDIJoystick2); if(FAILED(hr)) { errstr="SetDataFormat"; @@ -158,7 +154,7 @@ bool DInput9Info::CreateJoystickOrPad(HWND _window) { goto handle_error; } - // set the min/max values property for discovered axes. + // set the minmax values property for discovered axes. hr = pJoyDevice->EnumObjects(EnumObjectsCallbackJoystick, (LPVOID)pJoyDevice, DIDFT_AXIS); if(FAILED(hr)) { errstr="EnumObjects"; @@ -172,12 +168,12 @@ bool DInput9Info::CreateJoystickOrPad(HWND _window) { return false; } -//----------------------------------------------------------------------------- -// Name: EnumObjectsCallback() -// Desc: Callback function for enumerating objects (axes, buttons, POVs) on a -// joystick. This function enables user interface elements for objects -// that are found to exist, and scales axes min/max values. -//----------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// -- Name: EnumObjectsCallback() Desc: Callback function for enumerating +// objects (axes, buttons, POVs) on a joystick. This function enables user +// interface elements for objects that are found to exist, and scales axes +// minmax values. ----------------------------------------------------------- +// ------------------ BOOL CALLBACK EnumObjectsCallbackJoystick( const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext ) { @@ -185,7 +181,7 @@ BOOL CALLBACK EnumObjectsCallbackJoystick( const DIDEVICEOBJECTINSTANCE* pdidoi, HRESULT hr; // For axes that are returned, set the DIPROP_RANGE property for the - // enumerated axis in order to scale min/max values. + // enumerated axis in order to scale minmax values. if( pdidoi->dwType & DIDFT_AXIS ) { DIPROPRANGE diprg; diprg.diph.dwSize = sizeof(DIPROPRANGE); @@ -223,10 +219,10 @@ bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { hr = pJoystick->Poll(); if( FAILED(hr) ) { - // DInput is telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. We - // just re-acquire and try again. + // DInput is telling us that the input stream has been interrupted. + // We aren't tracking any state between polls, so we don't have any + // special reset that needs to be done. We just re-acquire and try + // again. if((hr==DIERR_NOTACQUIRED)||(hr == DIERR_INPUTLOST)) { hr = pJoystick->Acquire(); @@ -235,8 +231,8 @@ bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { if(wdxdisplay_cat.is_spam()) wdxdisplay_cat.spam() << "Acquire failed" << D3DERRORSTRING(hr); - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of + // hr may be DIERR_OTHERAPPHASPRIO or other errors. This may + // occur when the app is minimized or in the process of // switching, so just try again later return false; } @@ -253,7 +249,8 @@ bool DInput9Info::ReadJoystick(int devnum, DIJOYSTATE2 &js) { } } - // should we make a vector of devstate dataformats to generalize this fn for all device types? + // should we make a vector of devstate dataformats to generalize this fn + // for all device types? // Get the input's device state hr = pJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &js); diff --git a/panda/src/dxgsg9/dxInput9.h b/panda/src/dxgsg9/dxInput9.h index 03c2c3376c..77f3f31a37 100644 --- a/panda/src/dxgsg9/dxInput9.h +++ b/panda/src/dxgsg9/dxInput9.h @@ -1,16 +1,15 @@ -// Filename: dxInput9.h -// Created by: blllyjo (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxInput9.h + * @author blllyjo + * @date 1999-10-07 + */ #ifndef DXINPUT9_H #define DXINPUT9_H @@ -32,11 +31,10 @@ public: UINT_PTR _JoystickPollTimer; LPDIRECTINPUT8 _pDInput9; DI_DeviceInfos _DevInfos; - // arrays for all created devices. Should probably put these together in a struct, - // along with the data fmt info + // arrays for all created devices. Should probably put these together in a + // struct, along with the data fmt info vector _DeviceList; vector _DevCaps; }; #endif - diff --git a/panda/src/dxgsg9/dxOcclusionQueryContext9.I b/panda/src/dxgsg9/dxOcclusionQueryContext9.I index 728c0fb9de..56fc763780 100644 --- a/panda/src/dxgsg9/dxOcclusionQueryContext9.I +++ b/panda/src/dxgsg9/dxOcclusionQueryContext9.I @@ -1,23 +1,19 @@ -// Filename: dxOcclusionQueryContext9.I -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxOcclusionQueryContext9.I + * @author drose + * @date 2007-06-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DXOcclusionQueryContext9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DXOcclusionQueryContext9:: DXOcclusionQueryContext9(IDirect3DQuery9 *query) : _query(query) { } diff --git a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx index a143728181..0999821080 100644 --- a/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx +++ b/panda/src/dxgsg9/dxOcclusionQueryContext9.cxx @@ -1,16 +1,15 @@ -// Filename: dxOcclusionQueryContext9.cxx -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxOcclusionQueryContext9.cxx + * @author drose + * @date 2007-06-04 + */ #include "dxOcclusionQueryContext9.h" #include "dxGraphicsStateGuardian9.h" @@ -20,26 +19,21 @@ TypeHandle DXOcclusionQueryContext9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXOcclusionQueryContext9:: ~DXOcclusionQueryContext9() { _query->Release(); _query = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::is_answer_ready -// Access: Public, Virtual -// Description: Returns true if the query's answer is ready, false -// otherwise. If this returns false, the application -// must continue to poll until it returns true. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the query's answer is ready, false otherwise. If this + * returns false, the application must continue to poll until it returns true. + * + * It is only valid to call this from the draw thread. + */ bool DXOcclusionQueryContext9:: is_answer_ready() const { DWORD result; @@ -47,30 +41,24 @@ is_answer_ready() const { return (hr != S_FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::waiting_for_answer -// Access: Public, Virtual -// Description: Requests the graphics engine to expedite the pending -// answer--the application is now waiting until the -// answer is ready. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Requests the graphics engine to expedite the pending answer--the + * application is now waiting until the answer is ready. + * + * It is only valid to call this from the draw thread. + */ void DXOcclusionQueryContext9:: waiting_for_answer() { get_num_fragments(); } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::get_num_fragments -// Access: Public, Virtual -// Description: Returns the number of fragments (pixels) of the -// specified geometry that passed the depth test. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of fragments (pixels) of the specified geometry that + * passed the depth test. If is_answer_ready() did not return true, this + * function may block before it returns. + * + * It is only valid to call this from the draw thread. + */ int DXOcclusionQueryContext9:: get_num_fragments() const { DWORD result; @@ -89,8 +77,8 @@ get_num_fragments() const { } if (FAILED(hr)) { - // Some failure, e.g. devicelost. Return a nonzero value as a - // worst-case answer. + // Some failure, e.g. devicelost. Return a nonzero value as a worst-case + // answer. dxgsg9_cat.info() << "occlusion query failed " << D3DERRORSTRING(hr); return 1; diff --git a/panda/src/dxgsg9/dxOcclusionQueryContext9.h b/panda/src/dxgsg9/dxOcclusionQueryContext9.h index 591e17f446..f930bc71e0 100644 --- a/panda/src/dxgsg9/dxOcclusionQueryContext9.h +++ b/panda/src/dxgsg9/dxOcclusionQueryContext9.h @@ -1,16 +1,15 @@ -// Filename: dxOcclusionQueryContext9.h -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxOcclusionQueryContext9.h + * @author drose + * @date 2007-06-04 + */ #ifndef DXOCCLUSIONQUERYCONTEXT9_H #define DXOCCLUSIONQUERYCONTEXT9_H @@ -21,10 +20,9 @@ class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : DXOcclusionQueryContext9 -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDADX DXOcclusionQueryContext9 : public OcclusionQueryContext { public: INLINE DXOcclusionQueryContext9(IDirect3DQuery9 *query); diff --git a/panda/src/dxgsg9/dxShaderContext9.I b/panda/src/dxgsg9/dxShaderContext9.I index 2566d8ff02..ba79e89d74 100644 --- a/panda/src/dxgsg9/dxShaderContext9.I +++ b/panda/src/dxgsg9/dxShaderContext9.I @@ -1,27 +1,22 @@ -// Filename: dxShaderContext9.I -// Created by: aignacio (Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxShaderContext9.I + * @author aignacio + * @date 2006-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::valid -// Access: Public -// Description: Returns true if the shader is "valid", ie, if the -// compilation was successful. The compilation could -// fail if there is a syntax error in the shader, or -// if the current video card isn't shader-capable, -// or if no shader languages are compiled into panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader is "valid", ie, if the compilation was + * successful. The compilation could fail if there is a syntax error in the + * shader, or if the current video card isn't shader-capable, or if no shader + * languages are compiled into panda. + */ INLINE bool CLP(ShaderContext):: valid(GSG *gsg) { #ifdef HAVE_CG diff --git a/panda/src/dxgsg9/dxShaderContext9.cxx b/panda/src/dxgsg9/dxShaderContext9.cxx index 0e86d46c16..2dbfd6da9c 100644 --- a/panda/src/dxgsg9/dxShaderContext9.cxx +++ b/panda/src/dxgsg9/dxShaderContext9.cxx @@ -1,16 +1,15 @@ -// Filename: dxShaderContext9.cxx -// Created by: jyelon (01Sep05), conversion aignacio (Jan-Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxShaderContext9.cxx + * @author jyelon + * @date 2005-09-01 + */ #include "dxGraphicsStateGuardian9.h" #include "dxShaderContext9.h" @@ -31,11 +30,9 @@ TypeHandle CLP(ShaderContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::Constructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(ShaderContext):: CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) { _vertex_element_array = NULL; @@ -50,8 +47,8 @@ CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) { if (s->get_language() == Shader::SL_Cg) { - // Ask the shader to compile itself for us and - // to give us the resulting Cg program objects. + // Ask the shader to compile itself for us and to give us the resulting Cg + // program objects. if (!s->cg_compile_for(gsg->_shader_caps, context, _cg_program, _cg_parameter_map)) { return; @@ -80,11 +77,9 @@ CLP(ShaderContext)(Shader *s, GSG *gsg) : ShaderContext(s) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::Destructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(ShaderContext):: ~CLP(ShaderContext)() { release_resources(); @@ -100,60 +95,30 @@ CLP(ShaderContext):: } } -// int save_file (int size, void *data, char *file_path) -// { -// int state; -// int file_handle; -// -// state = false; -// file_handle = _open (file_path, _O_CREAT | _O_RDWR | _O_TRUNC, _S_IREAD | _S_IWRITE); -// if (file_handle != -1) { -// if (_write (file_handle, data, size) == size) { -// state = true; -// } -// _close (file_handle); -// } -// -// return state; -// } -// -// if (dxgsg9_cat.is_debug()) { -// // DEBUG: output the generated program -// const char *vertex_program; -// const char *pixel_program; -// -// vertex_program = cgGetProgramString (_cg_program[0], CG_COMPILED_PROGRAM); -// pixel_program = cgGetProgramString (_cg_program[1], CG_COMPILED_PROGRAM); -// -// dxgsg9_cat.debug() << vertex_program << "\n"; -// dxgsg9_cat.debug() << pixel_program << "\n"; -// -// // save the generated program to a file -// int size; -// char file_path [512]; -// -// char drive[_MAX_DRIVE]; -// char dir[_MAX_DIR]; -// char fname[_MAX_FNAME]; -// char ext[_MAX_EXT]; -// -// _splitpath (_name.c_str ( ), drive, dir, fname, ext); -// -// size = strlen (vertex_program); -// sprintf (file_path, "%s.vasm", fname); -// save_file (size, (void *) vertex_program, file_path); -// -// size = strlen (pixel_program); -// sprintf (file_path, "%s.pasm", fname); -// save_file (size, (void *) pixel_program, file_path); -// } +/* + * int save_file (int size, void *data, char *file_path) { int state; int + * file_handle; state = false; file_handle = _open (file_path, _O_CREAT | + * _O_RDWR | _O_TRUNC, _S_IREAD | _S_IWRITE); if (file_handle != -1) { if + * (_write (file_handle, data, size) == size) { state = true; } _close + * (file_handle); } return state; } if (dxgsg9_cat.is_debug()) { DEBUG: output + * the generated program const char *vertex_program; const char + * *pixel_program; vertex_program = cgGetProgramString (_cg_program[0], + * CG_COMPILED_PROGRAM); pixel_program = cgGetProgramString (_cg_program[1], + * CG_COMPILED_PROGRAM); dxgsg9_cat.debug() << vertex_program << "\n"; + * dxgsg9_cat.debug() << pixel_program << "\n"; save the generated program to + * a file int size; char file_path [512]; char drive[_MAX_DRIVE]; char + * dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath + * (_name.c_str ( ), drive, dir, fname, ext); size = strlen (vertex_program); + * sprintf (file_path, "%s.vasm", fname); save_file (size, (void *) + * vertex_program, file_path); size = strlen (pixel_program); sprintf + * (file_path, "%s.pasm", fname); save_file (size, (void *) pixel_program, + * file_path); } + */ -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::release_resources -// Access: Public -// Description: Should deallocate all system resources (such as -// vertex program handles or Cg contexts). -//////////////////////////////////////////////////////////////////// +/** + * Should deallocate all system resources (such as vertex program handles or + * Cg contexts). + */ void CLP(ShaderContext):: release_resources() { #ifdef HAVE_CG @@ -164,18 +129,16 @@ release_resources() { } #endif - // I think we need to call SetStreamSource for _num_bound_streams -- basically the logic from - // disable_shader_vertex_arrays -- but to do that we need to introduce logic like the GL code - // has to manage _last_gsg, so we can get at the device. Sigh. + // I think we need to call SetStreamSource for _num_bound_streams -- + // basically the logic from disable_shader_vertex_arrays -- but to do that + // we need to introduce logic like the GL code has to manage _last_gsg, so + // we can get at the device. Sigh. } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::bind -// Access: Public -// Description: This function is to be called to enable a new -// shader. It also initializes all of the shader's -// input parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function is to be called to enable a new shader. It also initializes + * all of the shader's input parameters. + */ bool CLP(ShaderContext):: bind(GSG *gsg) { @@ -183,7 +146,8 @@ bind(GSG *gsg) { #ifdef HAVE_CG if (_cg_program) { - // clear the last cached FVF to make sure the next SetFVF call goes through + // clear the last cached FVF to make sure the next SetFVF call goes + // through gsg -> _last_fvf = 0; @@ -211,11 +175,9 @@ bind(GSG *gsg) { return bind_state; } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::unbind -// Access: Public -// Description: This function disables a currently-bound shader. -//////////////////////////////////////////////////////////////////// +/** + * This function disables a currently-bound shader. + */ void CLP(ShaderContext):: unbind(GSG *gsg) { @@ -231,21 +193,16 @@ unbind(GSG *gsg) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::issue_parameters -// Access: Public -// Description: This function gets called whenever the RenderState -// or TransformState has changed, but the Shader -// itself has not changed. It loads new values into the -// shader's parameters. -// -// If "altered" is false, that means you promise that -// the parameters for this shader context have already -// been issued once, and that since the last time the -// parameters were issued, no part of the render -// state has changed except the external and internal -// transforms. -//////////////////////////////////////////////////////////////////// +/** + * This function gets called whenever the RenderState or TransformState has + * changed, but the Shader itself has not changed. It loads new values into + * the shader's parameters. + * + * If "altered" is false, that means you promise that the parameters for this + * shader context have already been issued once, and that since the last time + * the parameters were issued, no part of the render state has changed except + * the external and internal transforms. + */ #if DEBUG_SHADER PN_stdfloat *global_data = 0; @@ -394,11 +351,9 @@ issue_parameters(GSG *gsg, int altered) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::disable_shader_vertex_arrays -// Access: Public -// Description: Disable all the vertex arrays used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the vertex arrays used by this shader. + */ void CLP(ShaderContext):: disable_shader_vertex_arrays(GSG *gsg) { LPDIRECT3DDEVICE9 device = gsg->_screen->_d3d_device; @@ -410,17 +365,13 @@ disable_shader_vertex_arrays(GSG *gsg) { _num_bound_streams = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::update_shader_vertex_arrays -// Access: Public -// Description: Disables all vertex arrays used by the previous -// shader, then enables all the vertex arrays needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -// The current implementation is inefficient, because -// it may unnecessarily disable arrays then immediately -// reenable them. We may optimize this someday. -//////////////////////////////////////////////////////////////////// +/** + * Disables all vertex arrays used by the previous shader, then enables all + * the vertex arrays needed by this shader. Extracts the relevant vertex + * array data from the gsg. The current implementation is inefficient, + * because it may unnecessarily disable arrays then immediately reenable them. + * We may optimize this someday. + */ bool CLP(ShaderContext):: update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { if (prev) prev->disable_shader_vertex_arrays(gsg); @@ -441,7 +392,8 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { LPDIRECT3DDEVICE9 device = gsg->_screen->_d3d_device; HRESULT hr; - // Discard and recreate the VertexElementArray. This thrashes pretty bad.... + // Discard and recreate the VertexElementArray. This thrashes pretty + // bad.... if ( _vertex_element_array != NULL ) { delete _vertex_element_array; } @@ -449,10 +401,11 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { VertexElementArray* vertex_element_array = _vertex_element_array; // Experimentally determined that DX doesn't like us crossing the streams! - // It seems to be okay with out-of-order offsets in both source and destination, - // but it wants all stream X entries grouped together, then all stream Y entries, etc. - // To accomplish this out outer loop processes arrays ("streams"), and we repeatedly - // iterate the parameters to pull out only those for a single stream. + // It seems to be okay with out-of-order offsets in both source and + // destination, but it wants all stream X entries grouped together, then + // all stream Y entries, etc. To accomplish this out outer loop processes + // arrays ("streams"), and we repeatedly iterate the parameters to pull + // out only those for a single stream. int number_of_arrays = gsg->_data_reader->get_num_arrays(); for ( int array_index = 0; array_index < number_of_arrays; ++array_index ) { @@ -474,8 +427,8 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { InternalName *name = _shader->_var_spec[var_index]._name; - // This is copied from the GL version of this function, and I've yet to 100% convince - // myself that it works properly.... + // This is copied from the GL version of this function, and I've yet + // to 100% convince myself that it works properly.... int texslot = _shader->_var_spec[var_index]._append_uv; if (texslot >= 0 && texslot < gsg->_state_texture->get_num_on_stages()) { TextureStage *stage = gsg->_state_texture->get_on_stage(texslot); @@ -495,11 +448,11 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { if ( gsg->_data_reader->get_array_info( name, param_array_reader, num_values, numeric_type, start, stride ) == false ) { - // This is apparently not an error (actually I think it is, just not a fatal one). - // - // The GL implementation fails silently in this case, but the net result is that we - // end up not supplying input for a shader parameter, which can cause Bad Things to - // happen so I'd like to at least get a hint as to what's gone wrong. + // This is apparently not an error (actually I think it is, just not + // a fatal one). The GL implementation fails silently in this case, + // but the net result is that we end up not supplying input for a + // shader parameter, which can cause Bad Things to happen so I'd + // like to at least get a hint as to what's gone wrong. dxgsg9_cat.info() << "Geometry contains no data for shader parameter " << *name << "\n"; continue; } @@ -633,9 +586,10 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { if (( _vertex_element_array != NULL ) && ( _vertex_element_array->add_end_vertex_element() != false )) { if (dxgsg9_cat.is_debug()) { - // Note that the currently generated vertex declaration works but never validates. - // My theory is that this is due to the shader programs always using float4 whereas - // the vertex declaration correctly sets the number of inputs (float2, float3, etc.). + // Note that the currently generated vertex declaration works but + // never validates. My theory is that this is due to the shader + // programs always using float4 whereas the vertex declaration + // correctly sets the number of inputs (float2, float3, etc.). if (cgD3D9ValidateVertexDeclaration(_cg_program, _vertex_element_array->_vertex_element_array) == CG_TRUE) { dxgsg9_cat.debug() << "cgD3D9ValidateVertexDeclaration succeeded\n"; @@ -669,11 +623,9 @@ update_shader_vertex_arrays(CLP(ShaderContext) *prev, GSG *gsg, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::disable_shader_texture_bindings -// Access: Public -// Description: Disable all the texture bindings used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the texture bindings used by this shader. + */ void CLP(ShaderContext):: disable_shader_texture_bindings(GSG *gsg) { @@ -701,17 +653,13 @@ disable_shader_texture_bindings(GSG *gsg) #endif } -//////////////////////////////////////////////////////////////////// -// Function: DXShaderContext9::update_shader_texture_bindings -// Access: Public -// Description: Disables all texture bindings used by the previous -// shader, then enables all the texture bindings needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -// The current implementation is inefficient, because -// it may unnecessarily disable textures then immediately -// reenable them. We may optimize this someday. -//////////////////////////////////////////////////////////////////// +/** + * Disables all texture bindings used by the previous shader, then enables all + * the texture bindings needed by this shader. Extracts the relevant vertex + * array data from the gsg. The current implementation is inefficient, + * because it may unnecessarily disable textures then immediately reenable + * them. We may optimize this someday. + */ void CLP(ShaderContext):: update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) { @@ -750,7 +698,7 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg) view += stage->get_tex_view_offset(); } if (_shader->_tex_spec[i]._suffix != 0) { - // The suffix feature is inefficient. It is a temporary hack. + // The suffix feature is inefficient. It is a temporary hack. if (tex == 0) { continue; } diff --git a/panda/src/dxgsg9/dxShaderContext9.h b/panda/src/dxgsg9/dxShaderContext9.h index c680443268..df873e3c1b 100644 --- a/panda/src/dxgsg9/dxShaderContext9.h +++ b/panda/src/dxgsg9/dxShaderContext9.h @@ -1,16 +1,15 @@ -// Filename: dxShaderContext9.h -// Created by: aignacio (Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxShaderContext9.h + * @author aignacio + * @date 2006-01 + */ #ifndef DXSHADERCONTEXT9_H #define DXSHADERCONTEXT9_H @@ -28,38 +27,21 @@ class VertexElementArray; class CLP(GraphicsStateGuardian); -// Caution: adding HLSL support is going to be tricky, as the parsing needs -// to be done in the cull thread, which cannot use the DX API. - Josh -// -// -// typedef struct -// { -// int vertex_shader; -// int total_constant_descriptions; -// D3DXCONSTANT_DESC *constant_description_array; -// } -// DX_PARAMETER; -// -// typedef struct -// { -// int state; -// union -// { -// DIRECT_3D_VERTEX_SHADER direct_3d_vertex_shader; -// DIRECT_3D_PIXEL_SHADER direct_3d_pixel_shader; -// }; -// LPD3DXCONSTANTTABLE constant_table; -// D3DXCONSTANTTABLE_DESC constant_table_description; -// -// int total_semantics; -// D3DXSEMANTIC *semantic_array; -// } -// DIRECT_3D_SHADER; +/* + * Caution: adding HLSL support is going to be tricky, as the parsing needs to + * be done in the cull thread, which cannot use the DX API. - Josh typedef + * struct { int vertex_shader; int total_constant_descriptions; + * D3DXCONSTANT_DESC *constant_description_array; } DX_PARAMETER; typedef + * struct { int state; union { DIRECT_3D_VERTEX_SHADER + * direct_3d_vertex_shader; DIRECT_3D_PIXEL_SHADER direct_3d_pixel_shader; }; + * LPD3DXCONSTANTTABLE constant_table; D3DXCONSTANTTABLE_DESC + * constant_table_description; int total_semantics; D3DXSEMANTIC + * *semantic_array; } DIRECT_3D_SHADER; + */ -//////////////////////////////////////////////////////////////////// -// Class : DXShaderContext9 -// Description : xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ class EXPCL_PANDADX CLP(ShaderContext) : public ShaderContext { public: typedef CLP(GraphicsStateGuardian) GSG; diff --git a/panda/src/dxgsg9/dxTextureContext9.I b/panda/src/dxgsg9/dxTextureContext9.I index 6fa8c05e78..6dbfea34a0 100644 --- a/panda/src/dxgsg9/dxTextureContext9.I +++ b/panda/src/dxgsg9/dxTextureContext9.I @@ -1,68 +1,55 @@ -// Filename: dxTextureContext9.I -// Created by: drose (23May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxTextureContext9.I + * @author drose + * @date 2005-05-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::has_mipmaps -// Access: Public -// Description: Returns true if the texture was created with mipmaps, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture was created with mipmaps, false otherwise. + */ INLINE bool DXTextureContext9:: has_mipmaps() const { return _has_mipmaps; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::get_d3d_texture -// Access: Public -// Description: Returns the Direct3D object that represents the -// texture, whatever kind of texture it is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Direct3D object that represents the texture, whatever kind of + * texture it is. + */ INLINE IDirect3DBaseTexture9 *DXTextureContext9:: get_d3d_texture() const { return _d3d_texture; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::get_d3d_2d_texture -// Access: Public -// Description: Returns the Direct3D object that represents the -// texture, in the case of a 1-d or 2-d texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Direct3D object that represents the texture, in the case of a + * 1-d or 2-d texture. + */ INLINE IDirect3DTexture9 *DXTextureContext9:: get_d3d_2d_texture() const { return _d3d_2d_texture; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::get_d3d_volume_texture -// Access: Public -// Description: Returns the Direct3D object that represents the -// texture, in the case of a 3-d texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Direct3D object that represents the texture, in the case of a + * 3-d texture. + */ INLINE IDirect3DVolumeTexture9 *DXTextureContext9:: get_d3d_volume_texture() const { return _d3d_volume_texture; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::get_d3d_cube_texture -// Access: Public -// Description: Returns the Direct3D object that represents the -// texture, in the case of a cube map texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Direct3D object that represents the texture, in the case of a + * cube map texture. + */ INLINE IDirect3DCubeTexture9 *DXTextureContext9:: get_d3d_cube_texture() const { return _d3d_cube_texture; diff --git a/panda/src/dxgsg9/dxTextureContext9.cxx b/panda/src/dxgsg9/dxTextureContext9.cxx index 857d57978f..39b92342aa 100644 --- a/panda/src/dxgsg9/dxTextureContext9.cxx +++ b/panda/src/dxgsg9/dxTextureContext9.cxx @@ -1,16 +1,15 @@ -// Filename: dxTextureContext9.cxx -// Created by: georges (02Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxTextureContext9.cxx + * @author georges + * @date 2002-02-02 + */ #include "config_dxgsg9.h" #include "dxGraphicsStateGuardian9.h" @@ -29,11 +28,9 @@ TypeHandle DXTextureContext9::_type_handle; static const DWORD g_LowByteMask = 0x000000FF; -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXTextureContext9:: DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view) : TextureContext(pgo, tex, view) { @@ -52,31 +49,24 @@ DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view) : _managed = -1; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXTextureContext9:: ~DXTextureContext9() { delete_texture(); } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void DXTextureContext9:: evict_lru() { if (get_texture()->get_render_to_texture()) { @@ -96,16 +86,13 @@ evict_lru() { mark_unloaded(); } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::create_texture -// Access: Public -// Description: Use panda texture's pixelbuffer to create a texture -// for the specified device. This code gets the -// attributes of the texture from the bitmap, creates -// the texture, and then copies the bitmap into the -// texture. The return value is true if the texture is -// successfully created, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Use panda texture's pixelbuffer to create a texture for the specified + * device. This code gets the attributes of the texture from the bitmap, + * creates the texture, and then copies the bitmap into the texture. The + * return value is true if the texture is successfully created, false + * otherwise. + */ bool DXTextureContext9:: create_texture(DXScreenData &scrn) { @@ -159,8 +146,7 @@ create_texture(DXScreenData &scrn) { case Texture::TT_1d_texture: case Texture::TT_2d_texture: case Texture::TT_cube_map: - // no compression for render target textures, or very small - // textures + // no compression for render target textures, or very small textures if (!tex->get_render_to_texture() && orig_width >= 4 && orig_height >= 4) { if (texture_wants_compressed){ @@ -174,13 +160,12 @@ create_texture(DXScreenData &scrn) { } if (texture_stored_compressed && !compress_texture) { - // If we're going to need to reload the texture to get its - // uncompressed image, we'd better do so now, *before* we figure - // out the source format. We have to do this early, even though - // we're going to do it again in fill_d3d_texture_pixels(), - // because sometimes reloading the original ram image will change - // the texture's apparent pixel format (the compressed form may - // have a different format than the uncompressed form). + // If we're going to need to reload the texture to get its uncompressed + // image, we'd better do so now, *before* we figure out the source format. + // We have to do this early, even though we're going to do it again in + // fill_d3d_texture_pixels(), because sometimes reloading the original ram + // image will change the texture's apparent pixel format (the compressed + // form may have a different format than the uncompressed form). tex->get_uncompressed_ram_image(); orig_width = (DWORD)tex->get_x_size(); @@ -192,7 +177,8 @@ create_texture(DXScreenData &scrn) { DWORD target_bpp = get_bits_per_pixel(tex->get_format(), &num_alpha_bits); DWORD num_color_channels = tex->get_num_components(); - // figure out what 'D3DFMT' the Texture is in, so D3DXLoadSurfFromMem knows how to perform copy + // figure out what 'D3DFMT' the Texture is in, so D3DXLoadSurfFromMem knows + // how to perform copy switch (tex->get_format()) { case Texture::F_depth_stencil: _d3d_format = D3DFMT_D24S8; @@ -349,8 +335,8 @@ create_texture(DXScreenData &scrn) { // checks for SQUARE reqmt (nvidia riva128 needs this) if ((target_width != target_height) && (scrn._d3dcaps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY) != 0) { - // assume pow2 textures. sum exponents, divide by 2 rounding down - // to get sq size + // assume pow2 textures. sum exponents, divide by 2 rounding down to get + // sq size int i, width_exp, height_exp; for (i = target_width, width_exp = 0; i > 1; width_exp++, i >>= 1) { } @@ -390,8 +376,8 @@ create_texture(DXScreenData &scrn) { } // I could possibly replace some of this logic with - // D3DXCheckTextureRequirements(), but it wouldn't handle all my - // specialized low-memory cases perfectly + // D3DXCheckTextureRequirements(), but it wouldn't handle all my specialized + // low-memory cases perfectly #define CHECK_FOR_FMT(FMT) \ if (scrn._supported_tex_formats_mask & FMT##_FLAG) { \ @@ -400,8 +386,8 @@ create_texture(DXScreenData &scrn) { if (texture_stored_compressed && compress_texture) { // if the texture is already compressed, we need to choose the - // corresponding format, otherwise we might end up - // cross-compressing from e.g. DXT5 to DXT3 + // corresponding format, otherwise we might end up cross-compressing from + // e.g. DXT5 to DXT3 switch (compression_mode){ case Texture::CM_dxt1: CHECK_FOR_FMT(DXT1); @@ -445,8 +431,8 @@ create_texture(DXScreenData &scrn) { } } - // We can't compress for some reason, so ensure the uncompressed - // image is ready to load. + // We can't compress for some reason, so ensure the uncompressed image is + // ready to load. if (texture_stored_compressed) { tex->get_uncompressed_ram_image(); compression_mode = tex->get_ram_image_compression(); @@ -454,14 +440,12 @@ create_texture(DXScreenData &scrn) { compress_texture = false; } - // handle each target bitdepth separately. might be less confusing - // to reorg by num_color_channels (input type, rather than desired - // 1st target) + // handle each target bitdepth separately. might be less confusing to reorg + // by num_color_channels (input type, rather than desired 1st target) switch (target_bpp) { - // IMPORTANT NOTE: - // target_bpp is REQUESTED bpp, not what exists in the texture - // array (the texture array contains num_color_channels*8bits) + // IMPORTANT NOTE: target_bpp is REQUESTED bpp, not what exists in the + // texture array (the texture array contains num_color_channels*8bits) case 128: // check if format is supported @@ -500,19 +484,19 @@ create_texture(DXScreenData &scrn) { if (num_alpha_bits>0) { nassertr(num_color_channels == 4, false); - // no 32-bit fmt, look for 16 bit w/alpha (1-15) + // no 32-bit fmt, look for 16 bit walpha (1-15) - // 32 bit RGBA was requested, but only 16 bit alpha fmts are - // avail. By default, convert to 4-4-4-4 which has 4-bit alpha - // for blurry edges. If we know tex only needs 1 bit alpha - // (i.e. for a mask), use 1555 instead. + // 32 bit RGBA was requested, but only 16 bit alpha fmts are avail. By + // default, convert to 4-4-4-4 which has 4-bit alpha for blurry edges. + // If we know tex only needs 1 bit alpha (i.e. for a mask), use 1555 + // instead. - // ConversionType ConvTo1 = Conv32to16_4444, ConvTo2 = Conv32to16_1555; - // DWORD dwAlphaMask1 = 0xF000, dwAlphaMask2 = 0x8000; + // ConversionType ConvTo1 = Conv32to16_4444, ConvTo2 = Conv32to16_1555; + // DWORD dwAlphaMask1 = 0xF000, dwAlphaMask2 = 0x8000; - // assume ALPHAMASK is x8000 and RGBMASK is x7fff to simplify - // 32->16 conversion. This should be true on most cards. + // assume ALPHAMASK is x8000 and RGBMASK is x7fff to simplify 32->16 + // conversion. This should be true on most cards. if (num_alpha_bits == 1) { CHECK_FOR_FMT(A1R5G5B5); @@ -522,8 +506,8 @@ create_texture(DXScreenData &scrn) { CHECK_FOR_FMT(A4R4G4B4); CHECK_FOR_FMT(A1R5G5B5); - // At this point, bail. Don't worry about converting to - // non-alpha formats yet, I think this will be a very rare case. + // At this point, bail. Don't worry about converting to non-alpha + // formats yet, I think this will be a very rare case. error_message = "create_texture failed: couldn't find compatible Tex DDPIXELFORMAT! no available 16 or 32-bit alpha formats!"; } else { // convert 3 or 4 channel to closest 16bpp color fmt @@ -559,9 +543,9 @@ create_texture(DXScreenData &scrn) { goto found_matching_format; } - // We fall back to a depth format. Chances are that it is going to - // be used for shadow mapping, in which case the depth comparison - // will probably still result in a useful value. + // We fall back to a depth format. Chances are that it is going to be + // used for shadow mapping, in which case the depth comparison will + // probably still result in a useful value. CHECK_FOR_FMT(D24X8); } } else { @@ -569,9 +553,8 @@ create_texture(DXScreenData &scrn) { CHECK_FOR_FMT(R8G8B8); - // no 24-bit fmt. look for 32 bit fmt (note: this is - // memory-hogging choice instead I could look for - // memory-conserving 16-bit fmt). + // no 24-bit fmt. look for 32 bit fmt (note: this is memory-hogging + // choice instead I could look for memory-conserving 16-bit fmt). CHECK_FOR_FMT(X8R8G8B8); CHECK_FOR_FMT(A8R8G8B8); @@ -604,9 +587,9 @@ create_texture(DXScreenData &scrn) { goto found_matching_format; } - // We fall back to a depth format. Chances are that it is going to - // be used for shadow mapping, in which case the depth comparison - // will probably still result in a useful value. + // We fall back to a depth format. Chances are that it is going to be + // used for shadow mapping, in which case the depth comparison will + // probably still result in a useful value. CHECK_FOR_FMT(D24X8); } @@ -626,8 +609,8 @@ create_texture(DXScreenData &scrn) { CHECK_FOR_FMT(A1R5G5B5); } else { nassertr((num_color_channels == 3)||(num_color_channels == 4), false); - // look for compatible 16bit fmts, if none then give up - // (don't worry about other bitdepths for 16 bit) + // look for compatible 16bit fmts, if none then give up (don't worry + // about other bitdepths for 16 bit) switch(num_alpha_bits) { case 0: if (num_color_channels == 3) { @@ -642,15 +625,14 @@ create_texture(DXScreenData &scrn) { break; case 1: // app specifically requests 1-5-5-5 F_rgba5 case, where you - // explicitly want 1-5-5-5 fmt, as opposed to F_rgbm, which - // could use 32bpp ARGB. fail if this particular fmt not - // avail. + // explicitly want 1-5-5-5 fmt, as opposed to F_rgbm, which could use + // 32bpp ARGB. fail if this particular fmt not avail. nassertr(num_color_channels == 4, false); CHECK_FOR_FMT(X1R5G5B5); break; case 4: - // app specifically requests 4-4-4-4 F_rgba4 case, as opposed - // to F_rgba, which could use 32bpp ARGB + // app specifically requests 4-4-4-4 F_rgba4 case, as opposed to + // F_rgba, which could use 32bpp ARGB nassertr(num_color_channels == 4, false); CHECK_FOR_FMT(A4R4G4B4); break; @@ -660,8 +642,8 @@ create_texture(DXScreenData &scrn) { } case 8: if (needs_luminance) { - // don't bother handling those other 8bit lum fmts like 4-4, - // since 16 8-8 is usually supported too + // don't bother handling those other 8bit lum fmts like 4-4, since 16 + // 8-8 is usually supported too nassertr(num_color_channels == 1, false); // look for native lum fmt first @@ -678,9 +660,9 @@ create_texture(DXScreenData &scrn) { // look for 16bpp A8L8, else 32-bit ARGB, else 16-4444. // skip 8bit alpha only (D3DFMT_A8), because I think only voodoo - // supports it and the voodoo support isn't the kind of blending - // model we need somehow (is it that voodoo assumes color is - // white? isnt that what we do in ConvAlpha8to32 anyway?) + // supports it and the voodoo support isn't the kind of blending model + // we need somehow (is it that voodoo assumes color is white? isnt that + // what we do in ConvAlpha8to32 anyway?) CHECK_FOR_FMT(A8L8); CHECK_FOR_FMT(A8R8G8B8); @@ -702,15 +684,14 @@ create_texture(DXScreenData &scrn) { << "; NeedLuminance: " << needs_luminance << endl; goto error_exit; -//////////////////////////////////////////////////////////////////// found_matching_format: // We found a suitable format that matches the texture's format. if (tex->get_match_framebuffer_format()) { - // Instead of creating a texture with the found format, we will - // need to make one that exactly matches the framebuffer's - // format. Look up what that format is. + // Instead of creating a texture with the found format, we will need to + // make one that exactly matches the framebuffer's format. Look up what + // that format is. IDirect3DSurface9 *render_target; if (needs_depth) { @@ -743,8 +724,7 @@ create_texture(DXScreenData &scrn) { } } - // validate magfilter setting - // degrade filtering if no HW support + // validate magfilter setting degrade filtering if no HW support SamplerState::FilterType ft; @@ -810,8 +790,8 @@ create_texture(DXScreenData &scrn) { if (filter_caps & D3DPTFILTERCAPS_MINFLINEAR) { ft = SamplerState::FT_linear_mipmap_nearest; } else { - // if you cant do linear in a level, you probably cant do - // linear b/w levels, so just do nearest-all + // if you cant do linear in a level, you probably cant do linear bw + // levels, so just do nearest-all ft = SamplerState::FT_nearest_mipmap_nearest; } } @@ -875,8 +855,8 @@ create_texture(DXScreenData &scrn) { } } - // DirectX will corrupt memory if we try to load mipmaps smaller than - // 4x4 for ATI1 or ATI2 textures. + // DirectX will corrupt memory if we try to load mipmaps smaller than 4x4 + // for ATI1 or ATI2 textures. if (target_pixel_format == D3DFMT_ATI1 || target_pixel_format == D3DFMT_ATI2) { @@ -911,9 +891,8 @@ create_texture(DXScreenData &scrn) { } else { usage = D3DUSAGE_RENDERTARGET; } - //if (target_bpp <= 32) { - // target_pixel_format = scrn._render_to_texture_d3d_format; - //} + // if (target_bpp <= 32) { target_pixel_format = + // scrn._render_to_texture_d3d_format; } dxgsg9_cat.debug () << "*** RENDER TO TEXTURE ***: format " @@ -940,8 +919,8 @@ create_texture(DXScreenData &scrn) { usage = D3DUSAGE_DYNAMIC; } else { - // can't lock textures so go back to managed for now - // need to use UpdateTexture or UpdateSurface + // can't lock textures so go back to managed for now need to use + // UpdateTexture or UpdateSurface _managed = true; pool = D3DPOOL_MANAGED; usage = 0; @@ -1090,11 +1069,9 @@ create_texture(DXScreenData &scrn) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::create_simple_texture -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DXTextureContext9:: create_simple_texture(DXScreenData &scrn) { nassertr(IS_VALID_PTR(get_texture()), false); @@ -1139,7 +1116,7 @@ create_simple_texture(DXScreenData &scrn) { CPTA_uchar image = get_texture()->get_simple_ram_image(); hr = -1; - // hr = fill_d3d_texture_pixels(scrn); + // hr = fill_d3d_texture_pixels(scrn); IDirect3DSurface9 *surface = NULL; _d3d_2d_texture->GetSurfaceLevel(0, &surface); @@ -1179,11 +1156,9 @@ create_simple_texture(DXScreenData &scrn) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::delete_texture -// Access: Public -// Description: Release the surface used to store the texture -//////////////////////////////////////////////////////////////////// +/** + * Release the surface used to store the texture + */ void DXTextureContext9:: delete_texture() { @@ -1198,14 +1173,11 @@ delete_texture() { _d3d_cube_texture = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::extract_texture_data -// Access: Public -// Description: This method will be called in the draw thread to -// download the texture memory's image into its -// ram_image value. It returns true on success, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method will be called in the draw thread to download the texture + * memory's image into its ram_image value. It returns true on success, false + * otherwise. + */ bool DXTextureContext9:: extract_texture_data(DXScreenData &screen) { bool state; @@ -1410,8 +1382,8 @@ extract_texture_data(DXScreenData &screen) { // Easy copy. memcpy(image.p(), rect.pBits, size); } else { - // Harder copy: we have to de-interleave DirectX's extra bytes - // on the end of each row. + // Harder copy: we have to de-interleave DirectX's extra bytes on + // the end of each row. unsigned char *dest = image.p(); unsigned char *source = (unsigned char *)rect.pBits; for (int yi = 0; yi < y_size; ++yi) { @@ -1442,17 +1414,14 @@ extract_texture_data(DXScreenData &screen) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::d3d_surface_to_texture -// Access: Public, Static -// Description: copies source_rect in pD3DSurf to upper left of -// texture -//////////////////////////////////////////////////////////////////// +/** + * copies source_rect in pD3DSurf to upper left of texture + */ HRESULT DXTextureContext9:: d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, bool inverted, Texture *result, int view, int z) { - // still need custom conversion since d3d/d3dx has no way to convert + // still need custom conversion since d3dd3dx has no way to convert // arbitrary fmt to ARGB in-memory user buffer HRESULT hr; @@ -1491,8 +1460,8 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, copy_width = RECT_XSIZE(source_rect); copy_height = RECT_YSIZE(source_rect); - // make sure there's enough space in the texture, its size must - // match (especially xsize) or scanlines will be too long + // make sure there's enough space in the texture, its size must match + // (especially xsize) or scanlines will be too long if (!((copy_width == result->get_x_size()) && (copy_height <= (DWORD)result->get_y_size()))) { dxgsg9_cat.error() @@ -1520,7 +1489,7 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, (surface_desc.Format == D3DFMT_A1R5G5B5) || (surface_desc.Format == D3DFMT_A4R4G4B4), E_FAIL); - //buf contains raw ARGB in Texture byteorder + // buf contains raw ARGB in Texture byteorder int byte_pitch = locked_rect.Pitch; BYTE *surface_bytes = (BYTE *)locked_rect.pBits; @@ -1647,11 +1616,11 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, } if (num_components == 4) { - // Note: these 16bpp loops ignore input alpha completely (alpha - // is set to fully opaque in texture!) + // Note: these 16bpp loops ignore input alpha completely (alpha is set + // to fully opaque in texture!) - // if we need to capture alpha, probably need to make separate - // loops for diff 16bpp fmts for best speed + // if we need to capture alpha, probably need to make separate loops for + // diff 16bpp fmts for best speed for (DWORD y = 0; y < copy_height; y++) { source_word = ((WORD*)surface_bytes) + x_window_offset; @@ -1704,24 +1673,23 @@ d3d_surface_to_texture(RECT &source_rect, IDirect3DSurface9 *d3d_surface, return S_OK; } -//////////////////////////////////////////////////////////////////// -// Function: calculate_row_byte_length -// Access: Private, Hidden -// Description: local helper function, which calculates the -// 'row_byte_length' or 'pitch' needed for calling -// D3DXLoadSurfaceFromMemory. -// Takes compressed formats (DXTn) into account. -//////////////////////////////////////////////////////////////////// +/** + * local helper function, which calculates the 'row_byte_length' or 'pitch' + * needed for calling D3DXLoadSurfaceFromMemory. Takes compressed formats + * (DXTn) into account. + */ static UINT calculate_row_byte_length (int width, int num_color_channels, D3DFORMAT tex_format) { UINT source_row_byte_length = 0; - // check for compressed textures and adjust source_row_byte_length and source_format accordingly + // check for compressed textures and adjust source_row_byte_length and + // source_format accordingly switch (tex_format) { case D3DFMT_DXT1: case D3DFMT_ATI1: - // for dxt1 compressed textures, the row_byte_lenght is "the width of one row of cells, in bytes" - // cells are 4 pixels wide, take up 8 bytes, and at least 1 cell has to be there. + // for dxt1 compressed textures, the row_byte_lenght is "the width + // of one row of cells, in bytes" cells are 4 pixels wide, take up 8 + // bytes, and at least 1 cell has to be there. source_row_byte_length = max(1,width / 4)*8; break; case D3DFMT_DXT2: @@ -1740,18 +1708,15 @@ static UINT calculate_row_byte_length (int width, int num_color_channels, D3DFOR return source_row_byte_length; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::fill_d3d_texture_mipmap_pixels -// Access: Private -// Description: Called from fill_d3d_texture_pixels, this function -// fills a single mipmap with texture data. -// Takes care of all necessary conversions and error -// handling. -//////////////////////////////////////////////////////////////////// +/** + * Called from fill_d3d_texture_pixels, this function fills a single mipmap + * with texture data. Takes care of all necessary conversions and error + * handling. + */ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int depth_index, D3DFORMAT source_format) { - // This whole function was refactored out of fill_d3d_texture_pixels to make the code - // more readable and to avoid code duplication. + // This whole function was refactored out of fill_d3d_texture_pixels to make + // the code more readable and to avoid code duplication. IDirect3DSurface9 *mip_surface = NULL; bool using_temp_buffer = false; HRESULT hr = E_FAIL; @@ -1798,8 +1763,8 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep mip_filter |= D3DX_FILTER_SRGB; } - // D3DXLoadSurfaceFromMemory will load black luminance and we want - // full white, so convert to explicit luminance-alpha format + // D3DXLoadSurfaceFromMemory will load black luminance and we want full + // white, so convert to explicit luminance-alpha format if (_d3d_format == D3DFMT_A8) { // alloc buffer for explicit D3DFMT_A8L8 USHORT *temp_buffer = new USHORT[width * height]; @@ -1814,9 +1779,8 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep BYTE *source_pixels = pixels + component_width - 1; for (UINT y = 0; y < height; y++) { for (UINT x = 0; x < width; x++, source_pixels += component_width, out_pixels++) { - // add full white, which is our interpretation of alpha-only - // (similar to default adding full opaque alpha 0xFF to - // RGB-only textures) + // add full white, which is our interpretation of alpha-only (similar + // to default adding full opaque alpha 0xFF to RGB-only textures) *out_pixels = ((*source_pixels) << 8 ) | 0xFF; } } @@ -1826,10 +1790,9 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep pixels = (BYTE*)temp_buffer; } else if (component_width != 1) { - // Convert from 16-bit per channel (or larger) format down to - // 8-bit per channel. This throws away precision in the - // original image, but dx8 doesn't support high-precision images - // anyway. + // Convert from 16-bit per channel (or larger) format down to 8-bit per + // channel. This throws away precision in the original image, but dx8 + // doesn't support high-precision images anyway. int num_components = get_texture()->get_num_components(); int num_pixels = width * height * num_components; @@ -1884,11 +1847,9 @@ exit_FillMipmapSurf: return hr; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::fill_d3d_texture_pixels -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HRESULT DXTextureContext9:: fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { IDirect3DDevice9 *device = scrn._d3d_device; @@ -1903,24 +1864,22 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { CPTA_uchar image; Texture::CompressionMode image_compression = Texture::CM_off; if (compress_texture) { - // If we are to be compressing this texture, accept a - // pre-compressed ram image if it is already so. + // If we are to be compressing this texture, accept a pre-compressed ram + // image if it is already so. image = tex->get_ram_image(); if (!image.is_null()) { image_compression = tex->get_ram_image_compression(); } } else { - // If we are not to be compressing this texture, we can only - // accept an uncompressed ram image. Ask the texture to give us - // one, so that there's no danger of accidentally getting a - // pre-compressed image. + // If we are not to be compressing this texture, we can only accept an + // uncompressed ram image. Ask the texture to give us one, so that + // there's no danger of accidentally getting a pre-compressed image. image = tex->get_uncompressed_ram_image(); } if (image.is_null()) { - // The texture doesn't have an image to load. That's ok; it - // might be a texture we've rendered to by frame buffer - // operations or something. + // The texture doesn't have an image to load. That's ok; it might be a + // texture we've rendered to by frame buffer operations or something. if (tex->get_render_to_texture()) { HRESULT result; @@ -2022,7 +1981,8 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { } if (_has_mipmaps) { - // if we have pre-calculated mipmap levels, use them, otherwise generate on the fly + // if we have pre-calculated mipmap levels, use them, otherwise generate + // on the fly int miplevel_count = _d3d_texture->GetLevelCount(); if (miplevel_count <= tex->get_num_loadable_ram_mipmap_images()) { dxgsg9_cat.debug() @@ -2041,9 +2001,10 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { if (_managed == false && scrn._supports_automatic_mipmap_generation) { if (false) { - //hr = _d3d_texture -> SetAutoGenFilterType (D3DTEXF_PYRAMIDALQUAD); - //hr = _d3d_texture -> SetAutoGenFilterType (D3DTEXF_GAUSSIANQUAD); - //hr = _d3d_texture -> SetAutoGenFilterType (D3DTEXF_ANISOTROPIC); + // hr = _d3d_texture -> SetAutoGenFilterType + // (D3DTEXF_PYRAMIDALQUAD); hr = _d3d_texture -> + // SetAutoGenFilterType (D3DTEXF_GAUSSIANQUAD); hr = _d3d_texture + // -> SetAutoGenFilterType (D3DTEXF_ANISOTROPIC); hr = _d3d_texture -> SetAutoGenFilterType (D3DTEXF_LINEAR); if (FAILED(hr)) { dxgsg9_cat.error() << "SetAutoGenFilterType failed " << D3DERRORSTRING(hr); @@ -2082,11 +2043,9 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) { } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::fill_d3d_volume_texture_pixels -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HRESULT DXTextureContext9:: fill_d3d_volume_texture_pixels(DXScreenData &scrn) { Texture *tex = get_texture(); @@ -2113,9 +2072,8 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { } if (image.is_null()) { - // The texture doesn't have an image to load. That's ok; it - // might be a texture we've rendered to by frame buffer - // operations or something. + // The texture doesn't have an image to load. That's ok; it might be a + // texture we've rendered to by frame buffer operations or something. return S_OK; } @@ -2171,8 +2129,8 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { level_0_filter |= D3DX_FILTER_SRGB; } - // D3DXLoadSurfaceFromMemory will load black luminance and we want - // full white, so convert to explicit luminance-alpha format + // D3DXLoadSurfaceFromMemory will load black luminance and we want full + // white, so convert to explicit luminance-alpha format if (_d3d_format == D3DFMT_A8) { // alloc buffer for explicit D3DFMT_A8L8 USHORT *temp_buffer = new USHORT[orig_width * orig_height * orig_depth]; @@ -2191,8 +2149,8 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { x < orig_width; x++, source_pixels += component_width, out_pixels++) { // add full white, which is our interpretation of alpha-only - // (similar to default adding full opaque alpha 0xFF to - // RGB-only textures) + // (similar to default adding full opaque alpha 0xFF to RGB-only + // textures) *out_pixels = ((*source_pixels) << 8 ) | 0xFF; } } @@ -2204,10 +2162,9 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { pixels = (BYTE*)temp_buffer; } else if (component_width != 1) { - // Convert from 16-bit per channel (or larger) format down to - // 8-bit per channel. This throws away precision in the - // original image, but dx8 doesn't support high-precision images - // anyway. + // Convert from 16-bit per channel (or larger) format down to 8-bit per + // channel. This throws away precision in the original image, but dx8 + // doesn't support high-precision images anyway. int num_components = tex->get_num_components(); int num_pixels = orig_width * orig_height * orig_depth * num_components; @@ -2254,7 +2211,7 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { mip_filter_flags |= D3DX_FILTER_SRGB; } - // mip_filter_flags| = D3DX_FILTER_DITHER; + // mip_filter_flags| = D3DX_FILTER_DITHER; hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0, mip_filter_flags); @@ -2275,12 +2232,9 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) { } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::down_to_power_2 -// Access: Private, Static -// Description: Returns the largest power of 2 less than or equal -// to value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest power of 2 less than or equal to value. + */ int DXTextureContext9:: down_to_power_2(int value) { int x = 1; @@ -2290,14 +2244,11 @@ down_to_power_2(int value) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::get_bits_per_pixel -// Access: Private -// Description: Maps from the Texture's Format symbols to bpp. -// Returns # of alpha bits. Note: Texture's format -// indicates REQUESTED final format, not the stored -// format, which is indicated by pixelbuffer type -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's Format symbols to bpp. Returns # of alpha bits. + * Note: Texture's format indicates REQUESTED final format, not the stored + * format, which is indicated by pixelbuffer type + */ unsigned int DXTextureContext9:: get_bits_per_pixel(Texture::Format format, int *alphbits) { *alphbits = 0; // assume no alpha bits @@ -2370,11 +2321,9 @@ get_bits_per_pixel(Texture::Format format, int *alphbits) { return 8; } -//////////////////////////////////////////////////////////////////// -// Function: DXTextureContext9::d3d_format_to_bytes_per_pixel -// Access: Private -// Description: Determines bytes per pixel from D3DFORMAT. -//////////////////////////////////////////////////////////////////// +/** + * Determines bytes per pixel from D3DFORMAT. + */ PN_stdfloat DXTextureContext9:: d3d_format_to_bytes_per_pixel (D3DFORMAT format) { diff --git a/panda/src/dxgsg9/dxTextureContext9.h b/panda/src/dxgsg9/dxTextureContext9.h index 4fa7d4d5e7..53558d39f0 100644 --- a/panda/src/dxgsg9/dxTextureContext9.h +++ b/panda/src/dxgsg9/dxTextureContext9.h @@ -1,16 +1,15 @@ -// Filename: dxTextureContext9.h -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxTextureContext9.h + * @author drose + * @date 1999-10-07 + */ #ifndef DXTEXTURECONTEXT9_H #define DXTEXTURECONTEXT9_H @@ -19,10 +18,9 @@ #include "texture.h" #include "textureContext.h" -//////////////////////////////////////////////////////////////////// -// Class : DXTextureContext9 -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDADX DXTextureContext9 : public TextureContext { public: DXTextureContext9(PreparedGraphicsObjects *pgo, Texture *tex, int view); @@ -66,7 +64,7 @@ private: private: bool _has_mipmaps; bool _is_render_target; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.I b/panda/src/dxgsg9/dxVertexBufferContext9.I index a40f049099..3f322c40ff 100644 --- a/panda/src/dxgsg9/dxVertexBufferContext9.I +++ b/panda/src/dxgsg9/dxVertexBufferContext9.I @@ -1,13 +1,12 @@ -// Filename: dxVertexBufferContext9.I -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxVertexBufferContext9.I + * @author drose + * @date 2005-03-18 + */ diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.cxx b/panda/src/dxgsg9/dxVertexBufferContext9.cxx index b83ab2b790..b5374b1afd 100644 --- a/panda/src/dxgsg9/dxVertexBufferContext9.cxx +++ b/panda/src/dxgsg9/dxVertexBufferContext9.cxx @@ -1,16 +1,15 @@ -// Filename: dxVertexBufferContext9.cxx -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxVertexBufferContext9.cxx + * @author drose + * @date 2005-03-18 + */ #include "dxVertexBufferContext9.h" #include "geomVertexArrayData.h" @@ -24,11 +23,9 @@ TypeHandle DXVertexBufferContext9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DXVertexBufferContext9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(VertexBufferContext):: CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *dxgsg, PreparedGraphicsObjects *pgo, @@ -39,8 +36,8 @@ CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *dxgsg, // Now fill in the FVF code. const GeomVertexArrayFormat *array_format = data->get_array_format(); - // We have to start with the vertex data, and work up from there in - // order, since that's the way the FVF is defined. + // We have to start with the vertex data, and work up from there in order, + // since that's the way the FVF is defined. int n = 0; int num_columns = array_format->get_num_columns(); @@ -106,8 +103,8 @@ CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *dxgsg, ++n; } - // Now look for all of the texcoord names and enable them in the - // same order they appear in the array. + // Now look for all of the texcoord names and enable them in the same order + // they appear in the array. int texcoord_index = 0; while (n < num_columns && array_format->get_column(n)->get_contents() == Geom::C_texcoord) { @@ -163,21 +160,16 @@ CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *dxgsg, } } -//////////////////////////////////////////////////////////////////// -// Function: DXVertexBufferContext9::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void CLP(VertexBufferContext):: evict_lru() { dequeue_lru(); @@ -190,4 +182,3 @@ evict_lru() { update_data_size_bytes(0); mark_unloaded(); } - diff --git a/panda/src/dxgsg9/dxVertexBufferContext9.h b/panda/src/dxgsg9/dxVertexBufferContext9.h index a7799fc0a6..9295dcb07c 100644 --- a/panda/src/dxgsg9/dxVertexBufferContext9.h +++ b/panda/src/dxgsg9/dxVertexBufferContext9.h @@ -1,16 +1,15 @@ -// Filename: dxVertexBufferContext9.h -// Created by: drose (18Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxVertexBufferContext9.h + * @author drose + * @date 2005-03-18 + */ #ifndef DXVERTEXBUFFERCONTEXT9_H #define DXVERTEXBUFFERCONTEXT9_H @@ -22,11 +21,9 @@ class CLP(GraphicsStateGuardian); -//////////////////////////////////////////////////////////////////// -// Class : DXVertexBufferContext9 -// Description : Caches a GeomVertexArrayData in the DirectX device as -// a vertex buffer. -//////////////////////////////////////////////////////////////////// +/** + * Caches a GeomVertexArrayData in the DirectX device as a vertex buffer. + */ class EXPCL_PANDADX CLP(VertexBufferContext) : public VertexBufferContext { public: CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *dxgsg, diff --git a/panda/src/dxgsg9/dxgsg9base.h b/panda/src/dxgsg9/dxgsg9base.h index 56862920b0..1566a55ba5 100644 --- a/panda/src/dxgsg9/dxgsg9base.h +++ b/panda/src/dxgsg9/dxgsg9base.h @@ -1,16 +1,15 @@ -// Filename: dxgsg9base.h -// Created by: georges (07Oct01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxgsg9base.h + * @author georges + * @date 2001-10-07 + */ #ifndef DXGSG9BASE_H #define DXGSG9BASE_H @@ -30,14 +29,14 @@ #include #define D3D_OVERLOADS // get D3DVECTOR '+' operator, etc from d3dtypes.h -//#define D3D_DEBUG_INFO +// #define D3D_DEBUG_INFO #undef Configure #include #include -// This symbol is defined (or not defined) in Config.pp. -//#define USE_GENERIC_DXERR_LIBRARY 1 +// This symbol is defined (or not defined) in Config.pp. #define +// USE_GENERIC_DXERR_LIBRARY 1 #ifdef USE_GENERIC_DXERR_LIBRARY #include @@ -63,7 +62,8 @@ #endif #endif -// imperfect method to ID NVid? could also scan desc str, but that isnt fullproof either +// imperfect method to ID NVid? could also scan desc str, but that isnt +// fullproof either #define IS_NVIDIA(DDDEVICEID) ((DDDEVICEID.VendorId==0x10DE) || (DDDEVICEID.VendorId==0x12D2)) #define IS_ATI(DDDEVICEID) (DDDEVICEID.VendorId==0x1002) #define IS_MATROX(DDDEVICEID) (DDDEVICEID.VendorId==0x102B) @@ -96,8 +96,7 @@ typedef DWORD DXShaderHandle; #define RELEASE_ONCE false -// uncomment to add refcnt debug output -// #define DEBUG_RELEASES +// uncomment to add refcnt debug output #define DEBUG_RELEASES #ifdef DEBUG_RELEASES #define RELEASE(OBJECT,MODULE,DBGSTR,bDoDownToZero) { \ @@ -185,7 +184,8 @@ typedef enum { #define D3DFMT_ATI1 ((D3DFORMAT)MAKEFOURCC('A', 'T', 'I', '1')) #define D3DFMT_ATI2 ((D3DFORMAT)MAKEFOURCC('A', 'T', 'I', '2')) -// this is only used in conjunction w/rendertgt fmts, so just make it something that can never be a rtgt +// this is only used in conjunction wrendertgt fmts, so just make it something +// that can never be a rtgt #define DISPLAY_32BPP_REQUIRES_16BPP_ZBUFFER_FLAG DXT1_FLAG #define DISPLAY_16BPP_REQUIRES_16BPP_ZBUFFER_FLAG DXT2_FLAG @@ -235,7 +235,7 @@ struct DXScreenData { }; -//utility stuff +// utility stuff extern pmap g_D3DFORMATmap; extern void Init_D3DFORMAT_map(); extern const char *D3DFormatStr(D3DFORMAT fmt); diff --git a/panda/src/dxgsg9/vertexElementArray.cxx b/panda/src/dxgsg9/vertexElementArray.cxx index 30d99ec8bb..4b7cbfbf1b 100644 --- a/panda/src/dxgsg9/vertexElementArray.cxx +++ b/panda/src/dxgsg9/vertexElementArray.cxx @@ -1,16 +1,15 @@ -// Filename: vertexElementArray.cxx -// Created by: aignacio (Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexElementArray.cxx + * @author aignacio + * @date 2006-01 + */ #include "dxGraphicsStateGuardian9.h" #include "vertexElementArray.h" @@ -243,4 +242,3 @@ bool VertexElementArray::add_end_vertex_element(void) { return true; } - diff --git a/panda/src/dxgsg9/vertexElementArray.h b/panda/src/dxgsg9/vertexElementArray.h index d000b64274..52b6536118 100644 --- a/panda/src/dxgsg9/vertexElementArray.h +++ b/panda/src/dxgsg9/vertexElementArray.h @@ -1,35 +1,29 @@ -// Filename: vertexElementArray.h -// Created by: aignacio (Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexElementArray.h + * @author aignacio + * @date 2006-01 + */ #ifndef VERTEX_ELEMENT_ARRAY_H #define VERTEX_ELEMENT_ARRAY_H -//////////////////////////////////////////////////////////////////// -// Class : VertexElementArray -// Description : This class gives the ability for a user-friendly way -// of creating a vertex declaration for DirectX 9. -// Since a vertex shader has a fixed input, the vertex -// element array can be cached so that a new vertex -// declaration for different vertex buffers can be -// quickly created. Be sure to call -// add_end_vertex_element ( ) when finished creating a -// vertex element array. -// VERTEX_ELEMENT_TYPE is used for a simplified mapping -// of vertex buffer data to vertex shader inputs. -// This class is used with DXShaderContext9 and in -// conjunction with DXVertexBufferContext9. -//////////////////////////////////////////////////////////////////// +/** + * This class gives the ability for a user-friendly way of creating a vertex + * declaration for DirectX 9. Since a vertex shader has a fixed input, the + * vertex element array can be cached so that a new vertex declaration for + * different vertex buffers can be quickly created. Be sure to call + * add_end_vertex_element ( ) when finished creating a vertex element array. + * VERTEX_ELEMENT_TYPE is used for a simplified mapping of vertex buffer data + * to vertex shader inputs. This class is used with DXShaderContext9 and in + * conjunction with DXVertexBufferContext9. + */ class VertexElementArray { public: diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.I b/panda/src/dxgsg9/wdxGraphicsBuffer9.I index 7dc69fd67b..fc3a570d14 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.I +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.I @@ -1,27 +1,23 @@ -// Filename: wdxGraphicsBuffer9.I -// Created by: zhao (29Sept12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsBuffer9.I + * @author zhao + * @date 2012-09-29 + */ -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::get_supports_render_texture -// Access: Published, Virtual -// Description: Returns true if this particular GraphicsOutput can -// render directly into a texture, or false if it must -// always copy-to-texture at the end of each frame to -// achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GraphicsOutput can render directly into a + * texture, or false if it must always copy-to-texture at the end of each + * frame to achieve this effect. + */ INLINE bool wdxGraphicsBuffer9:: get_supports_render_texture() const { // DX9 buffers can always bind-to-texture. return true; -} \ No newline at end of file +} diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx index 6101dd99ca..f1853879ae 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.cxx @@ -1,16 +1,15 @@ -// Filename: wdxGraphicsBuffer9.cxx -// Created by: drose (08Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsBuffer9.cxx + * @author drose + * @date 2004-02-08 + */ #include "wdxGraphicsPipe9.h" #include "wdxGraphicsBuffer9.h" @@ -23,11 +22,9 @@ TypeHandle wdxGraphicsBuffer9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsBuffer9:: wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -45,9 +42,8 @@ wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, _color_backing_store = NULL; _depth_backing_store = NULL; - // is this correct ??? - // Since the pbuffer never gets flipped, we get screenshots from the - // same buffer we draw into. + // is this correct ??? Since the pbuffer never gets flipped, we get + // screenshots from the same buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; _shared_depth_buffer = 0; @@ -69,11 +65,9 @@ wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsBuffer9:: ~wdxGraphicsBuffer9() { @@ -116,15 +110,12 @@ wdxGraphicsBuffer9:: this -> close_buffer ( ); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool wdxGraphicsBuffer9:: begin_frame(FrameMode mode, Thread *current_thread) { @@ -151,13 +142,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void wdxGraphicsBuffer9:: end_frame(FrameMode mode, Thread *current_thread) { @@ -177,12 +166,10 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::save_bitplanes -// Access: Public -// Description: After rendering, d3d_device will need to be restored -// to its initial state. This function saves the state. -//////////////////////////////////////////////////////////////////// +/** + * After rendering, d3d_device will need to be restored to its initial state. + * This function saves the state. + */ bool wdxGraphicsBuffer9:: save_bitplanes() { HRESULT hr; @@ -210,12 +197,10 @@ save_bitplanes() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::restore_bitplanes -// Access: Public -// Description: After rendering, d3d_device will need to be restored -// to its initial state. This function restores the state. -//////////////////////////////////////////////////////////////////// +/** + * After rendering, d3d_device will need to be restored to its initial state. + * This function restores the state. + */ void wdxGraphicsBuffer9:: restore_bitplanes() { DXGraphicsStateGuardian9 *dxgsg; @@ -256,12 +241,9 @@ restore_bitplanes() { -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::rebuild_bitplanes -// Access: Public -// Description: If necessary, reallocates (or allocates) the -// bitplanes for the buffer. -//////////////////////////////////////////////////////////////////// +/** + * If necessary, reallocates (or allocates) the bitplanes for the buffer. + */ bool wdxGraphicsBuffer9:: rebuild_bitplanes() { HRESULT hr; @@ -294,8 +276,7 @@ rebuild_bitplanes() { bitplane_y = Texture::up_to_power_2(bitplane_y); } - // Find the color and depth textures. Either may be present, - // or neither. + // Find the color and depth textures. Either may be present, or neither. int color_tex_index = -1; int depth_tex_index = -1; @@ -375,7 +356,7 @@ rebuild_bitplanes() { } color_tex = get_texture(color_tex_index); color_tex->set_size_padded(get_x_size(), get_y_size()); -// color_tex->set_format(Texture::F_rgba); +// color_tex->set_format(Texture::F_rgba); color_ctx = DCAST(DXTextureContext9, color_tex->prepare_now(0, _gsg->get_prepared_objects(), _gsg)); @@ -508,7 +489,7 @@ rebuild_bitplanes() { RenderTexturePlane plane = get_texture_plane(i); if (_debug) { -// printf ("i = %d, RenderTexturePlane = %d \n", i, plane); +// printf ("i = %d, RenderTexturePlane = %d \n", i, plane); } switch (plane) { @@ -566,8 +547,8 @@ rebuild_bitplanes() { } } - // Decrement the reference counts on these surfaces. The refcounts - // were incremented earlier when we called GetSurfaceLevel. + // Decrement the reference counts on these surfaces. The refcounts were + // incremented earlier when we called GetSurfaceLevel. if ((color_surf != 0)&&(color_surf != _color_backing_store)) { color_surf->Release(); @@ -582,15 +563,11 @@ rebuild_bitplanes() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::select_target_tex_page -// Access: Public, Virtual -// Description: Called internally when the window is in -// render-to-a-texture mode and we are in the process of -// rendering the six faces of a cube map. This should -// do whatever needs to be done to switch the buffer to -// the indicated face. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the window is in render-to-a-texture mode and we are + * in the process of rendering the six faces of a cube map. This should do + * whatever needs to be done to switch the buffer to the indicated face. + */ void wdxGraphicsBuffer9:: select_target_tex_page(int page) { @@ -710,36 +687,29 @@ select_target_tex_page(int page) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void wdxGraphicsBuffer9:: process_events() { GraphicsBuffer::process_events(); MSG msg; - // Handle all the messages on the queue in a row. Some of these - // might be for another window, but they will get dispatched - // appropriately. + // Handle all the messages on the queue in a row. Some of these might be + // for another window, but they will get dispatched appropriately. while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { process_1_event(); } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void wdxGraphicsBuffer9:: close_buffer() { @@ -756,22 +726,18 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::open_buffer -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool wdxGraphicsBuffer9:: open_buffer() { - // GSG creation/initialization. + // GSG creationinitialization. if (_gsg == 0) { - // The code below doesn't support creating a GSG on the fly. - // Just error out for now. - //_dxgsg = new DXGraphicsStateGuardian9(_engine, _pipe); - //_gsg = _dxgsg; + // The code below doesn't support creating a GSG on the fly. Just error + // out for now. _dxgsg = new DXGraphicsStateGuardian9(_engine, _pipe); + // _gsg = _dxgsg; return false; } @@ -809,18 +775,16 @@ open_buffer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::process_1_event -// Access: Private, Static -// Description: Handles one event from the message queue. -//////////////////////////////////////////////////////////////////// +/** + * Handles one event from the message queue. + */ void wdxGraphicsBuffer9:: process_1_event() { MSG msg; if (!GetMessage(&msg, NULL, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. - // DestroyAllWindows(false); + // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn } @@ -833,13 +797,10 @@ process_1_event() { -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::share_depth_buffer -// Access: Published -// Description: Will attempt to use the depth buffer of the input -// graphics_output. The buffer sizes must be exactly -// the same. -//////////////////////////////////////////////////////////////////// +/** + * Will attempt to use the depth buffer of the input graphics_output. The + * buffer sizes must be exactly the same. + */ bool wdxGraphicsBuffer9:: share_depth_buffer(GraphicsOutput *graphics_output) { @@ -873,8 +834,8 @@ share_depth_buffer(GraphicsOutput *graphics_output) { } if (state) { - // let the input GraphicsOutput know that there is an object - // sharing its depth buffer + // let the input GraphicsOutput know that there is an object sharing its + // depth buffer input_graphics_output -> register_shared_depth_buffer(this); _shared_depth_buffer = input_graphics_output; state = true; @@ -884,11 +845,9 @@ share_depth_buffer(GraphicsOutput *graphics_output) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::unshare_depth_buffer -// Access: Published -// Description: Discontinue sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Discontinue sharing the depth buffer. + */ void wdxGraphicsBuffer9:: unshare_depth_buffer() { if (_shared_depth_buffer) { @@ -896,18 +855,16 @@ unshare_depth_buffer() { printf ("wdxGraphicsBuffer9 unshare_depth_buffer \n"); } - // let the GraphicsOutput know that this object is no longer - // sharing its depth buffer + // let the GraphicsOutput know that this object is no longer sharing its + // depth buffer _shared_depth_buffer -> unregister_shared_depth_buffer(this); _shared_depth_buffer = 0; } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::register_shared_depth_buffer -// Access: Public -// Description: Register/save who is sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Register/save who is sharing the depth buffer. + */ void wdxGraphicsBuffer9:: register_shared_depth_buffer(GraphicsOutput *graphics_output) { wdxGraphicsBuffer9 *input_graphics_output; @@ -919,11 +876,9 @@ register_shared_depth_buffer(GraphicsOutput *graphics_output) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsBuffer9::unregister_shared_depth_buffer -// Access: Public -// Description: Unregister who is sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Unregister who is sharing the depth buffer. + */ void wdxGraphicsBuffer9:: unregister_shared_depth_buffer(GraphicsOutput *graphics_output) { wdxGraphicsBuffer9 *input_graphics_output; diff --git a/panda/src/dxgsg9/wdxGraphicsBuffer9.h b/panda/src/dxgsg9/wdxGraphicsBuffer9.h index d876c2505e..d603a73bf6 100644 --- a/panda/src/dxgsg9/wdxGraphicsBuffer9.h +++ b/panda/src/dxgsg9/wdxGraphicsBuffer9.h @@ -1,16 +1,15 @@ -// Filename: wdxGraphicsBuffer9.h -// Created by: drose (08Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsBuffer9.h + * @author drose + * @date 2004-02-08 + */ #ifndef wdxGraphicsBuffer9_H #define wdxGraphicsBuffer9_H @@ -20,16 +19,13 @@ #include "dxgsg9base.h" #include "dxTextureContext9.h" -//////////////////////////////////////////////////////////////////// -// Class : wdxGraphicsBuffer9 -// Description : An offscreen render buffer. In OpenGL under Windows, -// this simply renders into a window that is never made -// visible. There's a Windows interface for rendering -// into a DIB, but this puts restrictions on the kind of -// pixelformat we can use, and thus makes it difficult -// to support one GSG rendering into an offscreen buffer -// and also into a window. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen render buffer. In OpenGL under Windows, this simply renders + * into a window that is never made visible. There's a Windows interface for + * rendering into a DIB, but this puts restrictions on the kind of pixelformat + * we can use, and thus makes it difficult to support one GSG rendering into + * an offscreen buffer and also into a window. + */ class EXPCL_PANDADX wdxGraphicsBuffer9 : public GraphicsBuffer { public: wdxGraphicsBuffer9(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -41,8 +37,8 @@ public: GraphicsOutput *host); virtual ~wdxGraphicsBuffer9(); - virtual INLINE bool get_supports_render_texture() const; - + virtual INLINE bool get_supports_render_texture() const; + virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread); diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.I b/panda/src/dxgsg9/wdxGraphicsPipe9.I index d52abf26ef..9fd3c9526f 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.I +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.I @@ -1,13 +1,12 @@ -// Filename: wdxGraphicsPipe9.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsPipe9.I + * @author drose + * @date 2002-12-20 + */ diff --git a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx index 2bcfd8e336..8174105f39 100644 --- a/panda/src/dxgsg9/wdxGraphicsPipe9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsPipe9.cxx @@ -1,16 +1,15 @@ -// Filename: wdxGraphicsPipe9.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsPipe9.cxx + * @author drose + * @date 2002-12-20 + */ #include "wdxGraphicsPipe9.h" #include "dxGraphicsDevice9.h" @@ -24,11 +23,9 @@ TypeHandle wdxGraphicsPipe9::_type_handle; #define CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD 1000000 // if # is > 1MB, card is lying and I cant tell what it is #define UNKNOWN_VIDMEM_SIZE 0xFFFFFFFF -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsPipe9:: wdxGraphicsPipe9() { _hDDrawDLL = NULL; @@ -37,11 +34,9 @@ wdxGraphicsPipe9() { _is_valid = init(); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsPipe9:: ~wdxGraphicsPipe9() { RELEASE(__d3d9, wdxdisplay9, "ID3D9", RELEASE_DOWN_TO_ZERO); @@ -49,38 +44,29 @@ wdxGraphicsPipe9:: SAFE_FREELIB(_hDDrawDLL); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string wdxGraphicsPipe9:: get_interface_name() const { return "DirectX9"; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// wdxGraphicsPipe9. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default wdxGraphicsPipe9. + */ PT(GraphicsPipe) wdxGraphicsPipe9:: pipe_constructor() { return new wdxGraphicsPipe9; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) wdxGraphicsPipe9:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -113,8 +99,8 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_rgba() > 0)|| @@ -136,8 +122,8 @@ make_output(const string &name, ((flags&BF_can_bind_every)!=0)) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() || (fb_prop.get_back_buffers() > 0)|| @@ -147,9 +133,8 @@ make_output(const string &name, } } - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. - // This looks rather overly optimistic -- ie, buggy. + // Early success - if we are sure that this buffer WILL meet specs, we can + // precertify it. This looks rather overly optimistic -- ie, buggy. if ((wdxgsg != NULL) && wdxgsg->is_valid() && !wdxgsg->needs_reset() && wdxgsg->get_supports_render_texture()) { precertify = true; @@ -162,15 +147,11 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::init -// Access: Private -// Description: Performs some initialization steps to load up -// function pointers from the relevant DLL's, and -// determine the number and type of available graphics -// adapters, etc. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Performs some initialization steps to load up function pointers from the + * relevant DLL's, and determine the number and type of available graphics + * adapters, etc. Returns true on success, false on failure. + */ bool wdxGraphicsPipe9:: init() { if (!MyLoadLib(_hDDrawDLL, "ddraw.dll")) { @@ -210,8 +191,7 @@ init() { hFind = FindFirstFile (tmppath, &TempFindData); if (hFind != INVALID_HANDLE_VALUE) { FindClose(hFind); -// ??? This was from DX8 -// __is_dx9_1 = true; +// ??? This was from DX8 __is_dx9_1 = true; __d3d9 = (*_Direct3DCreate9)(D3D_SDK_VERSION_9_1); } else { __is_dx9_1 = false; @@ -219,7 +199,7 @@ init() { } if (__d3d9 == NULL) { wdxdisplay9_cat.error() << "Direct3DCreate9(9." << (__is_dx9_1 ? "1" : "0") << ") failed!, error = " << GetLastError() << endl; - //release_gsg(); + // release_gsg(); goto error; } @@ -235,13 +215,10 @@ init() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::find_all_card_memavails -// Access: Private -// Description: Uses DX7 calls to determine how much video memory is -// available for each video adapter in the system. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Uses DX7 calls to determine how much video memory is available for each + * video adapter in the system. Returns true on success, false on failure. + */ bool wdxGraphicsPipe9:: find_all_card_memavails() { HRESULT hr; @@ -301,19 +278,18 @@ find_all_card_memavails() { _card_ids[i].DeviceID = pDX7DeviceID->dwDeviceId; _card_ids[i].VendorID = pDX7DeviceID->dwVendorId; - // Get Current VidMem avail. Note this is only an estimate, when - // we switch to fullscreen mode from desktop, more vidmem will be - // available (typically 1.2 meg). I don't want to switch to - // fullscreen more than once due to the annoying monitor flicker, - // so try to figure out optimal mode using this estimate + // Get Current VidMem avail. Note this is only an estimate, when we + // switch to fullscreen mode from desktop, more vidmem will be available + // (typically 1.2 meg). I don't want to switch to fullscreen more than + // once due to the annoying monitor flicker, so try to figure out optimal + // mode using this estimate DDSCAPS2 ddsGAVMCaps; DWORD dwVidMemTotal, dwVidMemFree; dwVidMemTotal = dwVidMemFree = 0; { - // print out total INCLUDING AGP just for information purposes - // and future use. The real value I'm interested in for - // purposes of measuring possible valid screen sizes shouldnt - // include AGP. + // print out total INCLUDING AGP just for information purposes and + // future use. The real value I'm interested in for purposes of + // measuring possible valid screen sizes shouldnt include AGP. ZeroMemory(&ddsGAVMCaps, sizeof(DDSCAPS2)); ddsGAVMCaps.dwCaps = DDSCAPS_VIDEOMEMORY; @@ -322,8 +298,8 @@ find_all_card_memavails() { wdxdisplay9_cat.error() << "GetAvailableVidMem failed for device #" << i << D3DERRORSTRING(hr); - //goto skip_device; - //exit(1); // probably want to exit, since it may be my fault + // goto skip_device; exit(1); probably want to exit, since it may be + // my fault } } @@ -340,8 +316,9 @@ find_all_card_memavails() { hr = pDD->GetAvailableVidMem(&ddsGAVMCaps, &dwVidMemTotal, &dwVidMemFree); if (FAILED(hr)) { wdxdisplay9_cat.error() << "GetAvailableVidMem failed for device #" << i<< D3DERRORSTRING(hr); - // sometimes GetAvailableVidMem fails with hr = DDERR_NODIRECTDRAWHW for some unknown reason (bad drivers?) - // see bugs: 15327, 18122, others. is it because D3D9 object has already been created? + // sometimes GetAvailableVidMem fails with hr = DDERR_NODIRECTDRAWHW for + // some unknown reason (bad drivers?) see bugs: 15327, 18122, others. + // is it because D3D9 object has already been created? if (hr == DDERR_NODIRECTDRAWHW) continue; exit(1); // probably want to exit, since it may be my fault @@ -364,8 +341,8 @@ find_all_card_memavails() { dwVidMemTotal = UNKNOWN_VIDMEM_SIZE; } else { if (!ISPOW2(dwVidMemTotal)) { - // assume they wont return a proper max value, so - // round up to next pow of 2 + // assume they wont return a proper max value, so round up to next pow + // of 2 UINT count = 0; while ((dwVidMemTotal >> count) != 0x0) { count++; @@ -374,20 +351,20 @@ find_all_card_memavails() { } } - // after Set_display_mode, GetAvailVidMem totalmem seems to go down - // by 1.2 meg (contradicting above comment and what I think would - // be correct behavior (shouldnt FS mode release the desktop - // vidmem?), so this is the true value + // after Set_display_mode, GetAvailVidMem totalmem seems to go down by 1.2 + // meg (contradicting above comment and what I think would be correct + // behavior (shouldnt FS mode release the desktop vidmem?), so this is the + // true value _card_ids[i]._max_available_video_memory = dwVidMemTotal; - // I can never get this stuff to work reliably, so I'm just - // rounding up to nearest pow2. Could try to get - // HardwareInformation.Memory_size MB number from registry like - // video control panel, but its not clear how to find the proper - // registry location for a given card + // I can never get this stuff to work reliably, so I'm just rounding up to + // nearest pow2. Could try to get HardwareInformation.Memory_size MB + // number from registry like video control panel, but its not clear how to + // find the proper registry location for a given card - // assume buggy drivers (this means you, FireGL2) may return zero - // (or small amts) for dwVidMemTotal, so ignore value if its < CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD + // assume buggy drivers (this means you, FireGL2) may return zero (or + // small amts) for dwVidMemTotal, so ignore value if its < + // CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD bool bLowVidMemFlag = ((dwVidMemTotal > CRAPPY_DRIVER_IS_LYING_VIDMEMTHRESHOLD) && (dwVidMemTotal< LOWVIDMEMTHRESHOLD)); @@ -400,11 +377,9 @@ find_all_card_memavails() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsPipe9::dx7_driver_enum_callback -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BOOL WINAPI wdxGraphicsPipe9:: dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName, VOID *argptr, HMONITOR hm) { @@ -431,11 +406,9 @@ dx7_driver_enum_callback(GUID *pGUID, TCHAR *strDesc, TCHAR *strName, return DDENUMRET_OK; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::find_best_depth_format -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool wdxGraphicsPipe9:: find_best_depth_format(DXScreenData &Display, D3DDISPLAYMODE &Test_display_mode, D3DFORMAT *pBestFmt, bool bWantStencil, @@ -453,7 +426,8 @@ find_best_depth_format(DXScreenData &Display, D3DDISPLAYMODE &Test_display_mode, D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D16 // without stencil }; - // do not use Display._display_mode since that is probably not set yet, use Test_display_mode instead + // do not use Display._display_mode since that is probably not set yet, use + // Test_display_mode instead *pBestFmt = D3DFMT_UNKNOWN; HRESULT hr; @@ -531,12 +505,9 @@ find_best_depth_format(DXScreenData &Display, D3DDISPLAYMODE &Test_display_mode, } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::special_check_fullscreen_resolution -// Access: Private -// Description: overrides of the general estimator for known working -// cases -//////////////////////////////////////////////////////////////////// +/** + * overrides of the general estimator for known working cases + */ bool wdxGraphicsPipe9:: special_check_fullscreen_resolution(DXScreenData &scrn, UINT x_size, UINT y_size) { DWORD VendorId = scrn._dx_device_id.VendorId; @@ -559,12 +530,10 @@ special_check_fullscreen_resolution(DXScreenData &scrn, UINT x_size, UINT y_size return false; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::search_for_valid_displaymode -// Access: Private -// Description: All ptr args are output parameters. If no valid mode -// found, returns *pSuggestedPixFmt = D3DFMT_UNKNOWN; -//////////////////////////////////////////////////////////////////// +/** + * All ptr args are output parameters. If no valid mode found, returns + * *pSuggestedPixFmt = D3DFMT_UNKNOWN; + */ void wdxGraphicsPipe9:: search_for_valid_displaymode(DXScreenData &scrn, UINT RequestedX_Size, UINT RequestedY_Size, @@ -615,9 +584,9 @@ search_for_valid_displaymode(DXScreenData &scrn, << "), TotalModes: " << cNumModes << endl; } - // ignore memory based checks for min res 640x480. some cards just - // don't give accurate memavails. (should I do the check anyway for - // 640x480 32bpp?) + // ignore memory based checks for min res 640x480. some cards just don't + // give accurate memavails. (should I do the check anyway for 640x480 + // 32bpp?) bool bDoMemBasedChecks = ((!((RequestedX_Size == 640)&&(RequestedY_Size == 480))) && (scrn._max_available_video_memory != UNKNOWN_VIDMEM_SIZE) && @@ -649,12 +618,12 @@ search_for_valid_displaymode(DXScreenData &scrn, continue; } - // disable refresh rate checking since SLI video cards may use - // refresh rates less than 60 + // disable refresh rate checking since SLI video cards may use refresh + // rates less than 60 if (0) { if ((dispmode.RefreshRate<60) && (dispmode.RefreshRate>1)) { - // don't want refresh rates under 60Hz, but 0 or 1 might indicate - // a default refresh rate, which is usually > = 60 + // don't want refresh rates under 60Hz, but 0 or 1 might indicate a + // default refresh rate, which is usually > = 60 if (bVerboseMode) { wdxdisplay9_cat.info() << "skipping mode[" << i << "], bad refresh rate: " @@ -664,9 +633,9 @@ search_for_valid_displaymode(DXScreenData &scrn, } } - // Note no attempt is made to verify if format will work at - // requested size, so even if this call succeeds, could still get - // an out-of-video-mem error + // Note no attempt is made to verify if format will work at requested + // size, so even if this call succeeds, could still get an out-of-video- + // mem error hr = scrn._d3d9->CheckDeviceFormat(scrn._card_id, D3DDEVTYPE_HAL, dispmode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, @@ -691,12 +660,12 @@ search_for_valid_displaymode(DXScreenData &scrn, bool bIs16bppRenderTgt = IS_16BPP_DISPLAY_FORMAT(dispmode.Format); PN_stdfloat RendTgtMinMemReqmt = 0.0f; - // if we have a valid memavail value, try to determine if we have - // enough space + // if we have a valid memavail value, try to determine if we have enough + // space if (bDoMemBasedChecks) { - // assume user is testing fullscreen, not windowed, so use the - // dwTotal value see if 3 scrnbufs (front/back/z)at 16bpp at - // x_size*y_size will fit with a few extra megs for texmem + // assume user is testing fullscreen, not windowed, so use the dwTotal + // value see if 3 scrnbufs (frontbackz)at 16bpp at x_size*y_size will + // fit with a few extra megs for texmem // 8MB Rage Pro says it has 6.8 megs Total free and will run at // 1024x768, so formula makes it so that is OK @@ -761,7 +730,7 @@ search_for_valid_displaymode(DXScreenData &scrn, } } -// Optimizing for 16-bit depth does not work in all cases so turn it off. +// Optimizing for 16-bit depth does not work in all cases so turn it off. if (false) { if ((!bDoMemBasedChecks) || (MinMemReqmt -//////////////////////////////////////////////////////////////////// -// Class : wdxGraphicsPipe9 -// Description : This graphics pipe represents the interface for -// creating DirectX9 graphics windows. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating DirectX9 graphics + * windows. + */ class EXPCL_PANDADX wdxGraphicsPipe9 : public WinGraphicsPipe { public: wdxGraphicsPipe9(); @@ -84,7 +82,7 @@ private: Direct3DCreate9_ProcPtr _Direct3DCreate9; // CardID is used in DX7 lowmem card-classification pass so DX8 can - // establish correspondence b/w DX7 mem info & DX8 device + // establish correspondence bw DX7 mem info & DX8 device struct CardID { HMONITOR _monitor; DWORD _max_available_video_memory; diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.I b/panda/src/dxgsg9/wdxGraphicsWindow9.I index e692e5b26b..41f8b5f8c7 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.I +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.I @@ -1,14 +1,12 @@ -// Filename: wdxGraphicsWindow9.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsWindow9.I + * @author drose + * @date 2002-12-20 + */ diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx index dcf2699820..4dd8285f69 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.cxx +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.cxx @@ -1,16 +1,15 @@ -// Filename: wdxGraphicsWindow9.cxx -// Created by: mike (09Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsWindow9.cxx + * @author mike + * @date 2000-01-09 + */ #include "wdxGraphicsPipe9.h" #include "wdxGraphicsWindow9.h" @@ -29,11 +28,9 @@ TypeHandle wdxGraphicsWindow9::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsWindow9:: wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -44,9 +41,9 @@ wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsOutput *host): WinGraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host) { - // don't actually create the window in the constructor. reason: - // multi-threading requires panda C++ window object to exist in - // separate thread from actual API window + // don't actually create the window in the constructor. reason: multi- + // threading requires panda C++ window object to exist in separate thread + // from actual API window _dxgsg = DCAST(DXGraphicsStateGuardian9, gsg); _depth_buffer_bpp = 0; @@ -54,42 +51,35 @@ wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, ZeroMemory(&_wcontext, sizeof(_wcontext)); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wdxGraphicsWindow9:: ~wdxGraphicsWindow9() { } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::make_current -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void wdxGraphicsWindow9:: make_current() { PStatTimer timer(_make_current_pcollector); _dxgsg->set_context(&_wcontext); - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) _dxgsg->reset_if_new(); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool wdxGraphicsWindow9:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -106,8 +96,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { } if (_awaiting_restore) { - // The fullscreen window was recently restored; we can't continue - // until the GSG says we can. + // The fullscreen window was recently restored; we can't continue until + // the GSG says we can. if (!_dxgsg->check_cooperative_level()) { // Keep waiting. return false; @@ -128,13 +118,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return return_val; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void wdxGraphicsWindow9:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -152,16 +140,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void wdxGraphicsWindow9:: end_flip() { if (_dxgsg != (DXGraphicsStateGuardian9 *)NULL && is_active()) { @@ -170,23 +155,19 @@ end_flip() { WinGraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::verify_window_sizes -// Access: Public, Virtual -// Description: Determines which of the indicated window sizes are -// supported by available hardware (e.g. in fullscreen -// mode). -// -// On entry, dimen is an array containing contiguous x, y -// pairs specifying possible display sizes; it is -// numsizes*2 words long. The function will zero out -// any invalid x, y size pairs. The return value is the -// number of valid sizes that were found. -//////////////////////////////////////////////////////////////////// +/** + * Determines which of the indicated window sizes are supported by available + * hardware (e.g. in fullscreen mode). + * + * On entry, dimen is an array containing contiguous x, y pairs specifying + * possible display sizes; it is numsizes*2 words long. The function will + * zero out any invalid x, y size pairs. The return value is the number of + * valid sizes that were found. + */ int wdxGraphicsWindow9:: verify_window_sizes(int numsizes, int *dimen) { - // unfortunately this only works AFTER you make the window - // initially, so its really mostly useful for resizes only + // unfortunately this only works AFTER you make the window initially, so its + // really mostly useful for resizes only nassertr(IS_VALID_PTR(_dxgsg), 0); int num_valid_modes = 0; @@ -194,8 +175,8 @@ verify_window_sizes(int numsizes, int *dimen) { wdxGraphicsPipe9 *dxpipe; DCAST_INTO_R(dxpipe, _pipe, 0); - // not requesting same refresh rate since changing res might not - // support same refresh rate at new size + // not requesting same refresh rate since changing res might not support + // same refresh rate at new size int *pCurDim = dimen; @@ -242,13 +223,10 @@ verify_window_sizes(int numsizes, int *dimen) { return num_valid_modes; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow::close_window -// Access: Public -// Description: Some cleanup is necessary for directx closeup of window. -// Handle close window events for this particular -// window. -//////////////////////////////////////////////////////////////////// +/** + * Some cleanup is necessary for directx closeup of window. Handle close + * window events for this particular window. + */ void wdxGraphicsWindow9:: close_window() { if (wdxdisplay9_cat.is_debug()) { @@ -266,22 +244,18 @@ close_window() { WinGraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool wdxGraphicsWindow9:: open_window() { PT(DXGraphicsDevice9) dxdev; WindowProperties props; - // For now, let's make this configurable. If this is true, then you - // can't open multiple different windows with the same GSG, but you - // may have more luck opening different windows with different - // GSG's. + // For now, let's make this configurable. If this is true, then you can't + // open multiple different windows with the same GSG, but you may have more + // luck opening different windows with different GSG's. static ConfigVariableBool always_discard_device("always-discard-device", true); bool discard_device = always_discard_device; @@ -296,8 +270,7 @@ open_window() { return false; } - // Ensure the window properties get set to the actual size of the - // window. + // Ensure the window properties get set to the actual size of the window. { WindowProperties resized_props; resized_props.set_size(_wcontext._display_mode.Width, @@ -313,9 +286,9 @@ open_window() { 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 case just create an additional swapchain for this window + // 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 + // case just create an additional swapchain for this window while (true) { if (_dxgsg->get_pipe()->get_device() == NULL || discard_device) { @@ -338,8 +311,8 @@ open_window() { break; } else { - // fill in the DXScreenData from dxdevice here and change the - // reference to _window. + // fill in the DXScreenData from dxdevice here and change the reference + // to _window. wdxdisplay9_cat.debug() << "device is not null\n"; dxdev = (DXGraphicsDevice9*)_dxgsg->get_pipe()->get_device(); @@ -363,15 +336,12 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::reset_window -// Access: Public, Virtual -// Description: Resets the window framebuffer right now. Called -// from graphicsEngine. It releases the current swap -// chain / creates a new one. If this is the initial -// window and swapchain is false, then it calls reset_ -// main_device to Reset the device. -//////////////////////////////////////////////////////////////////// +/** + * Resets the window framebuffer right now. Called from graphicsEngine. It + * releases the current swap chain / creates a new one. If this is the + * initial window and swapchain is false, then it calls reset_ main_device to + * Reset the device. + */ void wdxGraphicsWindow9:: reset_window(bool swapchain) { if (swapchain) { @@ -388,34 +358,27 @@ reset_window(bool swapchain) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::fullscreen_restored -// Access: Protected, Virtual -// Description: This is a hook for derived classes to do something -// special, if necessary, when a fullscreen window has -// been restored after being minimized. The given -// WindowProperties struct will be applied to this -// window's properties after this function returns. -//////////////////////////////////////////////////////////////////// +/** + * This is a hook for derived classes to do something special, if necessary, + * when a fullscreen window has been restored after being minimized. The + * given WindowProperties struct will be applied to this window's properties + * after this function returns. + */ void wdxGraphicsWindow9:: fullscreen_restored(WindowProperties &properties) { - // In DX8, unlike DX7, for some reason we can't immediately start - // rendering as soon as the window is restored, even though - // BeginScene() says we can. Instead, we have to wait until - // TestCooperativeLevel() lets us in. We need to set a flag so we - // can handle this special case in begin_frame(). + // In DX8, unlike DX7, for some reason we can't immediately start rendering + // as soon as the window is restored, even though BeginScene() says we can. + // Instead, we have to wait until TestCooperativeLevel() lets us in. We + // need to set a flag so we can handle this special case in begin_frame(). if (_dxgsg != NULL) { _awaiting_restore = true; } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::handle_reshape -// Access: Protected, Virtual -// Description: Called in the window thread when the window size or -// location is changed, this updates the properties -// structure accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread when the window size or location is changed, + * this updates the properties structure accordingly. + */ void wdxGraphicsWindow9:: handle_reshape() { GdiFlush(); @@ -449,12 +412,9 @@ handle_reshape() { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::do_fullscreen_resize -// Access: Protected, Virtual -// Description: Called in the window thread to resize a fullscreen -// window. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread to resize a fullscreen window. + */ bool wdxGraphicsWindow9:: do_fullscreen_resize(int x_size, int y_size) { if (!WinGraphicsWindow::do_fullscreen_resize(x_size, y_size)) { @@ -473,7 +433,8 @@ do_fullscreen_resize(int x_size, int y_size) { bool bResizeSucceeded = false; if (!dxpipe->special_check_fullscreen_resolution(_wcontext, x_size, y_size)) { - // bypass the lowvidmem test below for certain "lowmem" cards we know have valid modes + // bypass the lowvidmem test below for certain "lowmem" cards we know have + // valid modes if (_wcontext._is_low_memory_card && (!((x_size == 640) && (y_size == 480)))) { wdxdisplay9_cat.error() << "resize() failed: will not try to resize low vidmem device #" << _wcontext._card_id << " to non-640x480!\n"; @@ -481,8 +442,8 @@ do_fullscreen_resize(int x_size, int y_size) { } } - // must ALWAYS use search_for_valid_displaymode even if we know - // a-priori that res is valid so we can get a valid pixfmt + // must ALWAYS use search_for_valid_displaymode even if we know a-priori + // that res is valid so we can get a valid pixfmt dxpipe->search_for_valid_displaymode(_wcontext, x_size, y_size, bNeedZBuffer, bNeedStencilBuffer, &_wcontext._supported_screen_depths_mask, @@ -497,13 +458,14 @@ do_fullscreen_resize(int x_size, int y_size) { return bResizeSucceeded; } - // reset_device_resize_window handles both windowed & fullscrn, - // so need to set new displaymode manually here + // reset_device_resize_window handles both windowed & fullscrn, so need to + // set new displaymode manually here _wcontext._display_mode.Width = x_size; _wcontext._display_mode.Height = y_size; _wcontext._display_mode.Format = pixFmt; _wcontext._display_mode.RefreshRate = D3DPRESENT_RATE_DEFAULT; - // keep the previous setting for _wcontext._presentation_params.BackBufferFormat + // keep the previous setting for + // _wcontext._presentation_params.BackBufferFormat bResizeSucceeded = reset_device_resize_window(x_size, y_size); @@ -525,14 +487,12 @@ do_fullscreen_resize(int x_size, int y_size) { return bResizeSucceeded; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::create_screen_buffers_and_device -// Access: Private -// Description: Called whenever the window is resized, this recreates -// the necessary buffers for rendering. -// -// Sets _depth_buffer_bpp appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the window is resized, this recreates the necessary buffers + * for rendering. + * + * Sets _depth_buffer_bpp appropriately. + */ bool wdxGraphicsWindow9:: create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer) { wdxGraphicsPipe9 *dxpipe; @@ -572,8 +532,8 @@ 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"; - // BUGBUG: need to change panda to put frame buffer properties with GraphicsWindow, not GSG!! - // Update: Did I fix the bug? - Josh + // BUGBUG: need to change panda to put frame buffer properties with + // GraphicsWindow, not GSG!! Update: Did I fix the bug? - Josh bool bWantStencil = (_fb_properties.get_stencil_bits() > 0); bool bWantAlpha = (_fb_properties.get_alpha_bits() > 0); @@ -604,8 +564,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer } } - // check for same format as display_mode - // verify the rendertarget fmt + // check for same format as display_mode verify the rendertarget fmt if (FAILED(_d3d9->CheckDeviceFormat(adapter, device_type, display._display_mode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, presentation_params->BackBufferFormat))) { wdxdisplay9_cat.error() << "adapter #" << adapter << " CheckDeviceFmt failed for surface fmt " << D3DFormatStr(presentation_params->BackBufferFormat) << endl; @@ -673,8 +632,8 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer if (_wcontext._is_tnl_device) { dwBehaviorFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING; - // note: we could create a pure device in this case if I - // eliminated the GetRenderState calls in dxgsg + // note: we could create a pure device in this case if I eliminated the + // GetRenderState calls in dxgsg // also, no software vertex processing available since I specify // D3DCREATE_HARDWARE_VERTEXPROCESSING and not @@ -686,11 +645,11 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer if (dx_preserve_fpu_state) dwBehaviorFlags |= D3DCREATE_FPU_PRESERVE; - // if window is not foreground in exclusive mode, ddraw thinks you - // are 'not active', so it changes your WM_ACTIVATEAPP from true to - // false, causing us to go into a 'wait-for WM_ACTIVATEAPP true' - // loop, and the event never comes so we hang in fullscreen wait. - // also doing this for windowed mode since it was requested. + // if window is not foreground in exclusive mode, ddraw thinks you are 'not + // active', so it changes your WM_ACTIVATEAPP from true to false, causing us + // to go into a 'wait-for WM_ACTIVATEAPP true' loop, and the event never + // comes so we hang in fullscreen wait. also doing this for windowed mode + // since it was requested. if (!SetForegroundWindow(display._window)) { wdxdisplay9_cat.warning() << "SetForegroundWindow() failed!\n"; } @@ -750,41 +709,39 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer return false; } - //From d3d8caps.h - //D3DPRESENT_INTERVAL_DEFAULT = 0x00000000L - //#define D3DPRESENT_INTERVAL_ONE 0x00000001L - //Next line is really sloppy, should either be D3DPRESENT_INTERVAL_DEFAULT or D3DPRESENT_INTERVAL_ONE - //not a direct number! but I'm not going to touch it because it's working as is. Zhao 12/15/2011 + // From d3d8caps.h D3DPRESENT_INTERVAL_DEFAULT = 0x00000000L #define + // D3DPRESENT_INTERVAL_ONE 0x00000001L Next line is really sloppy, + // should either be D3DPRESENT_INTERVAL_DEFAULT or D3DPRESENT_INTERVAL_ONE + // not a direct number! but I'm not going to touch it because it's + // working as is. Zhao 12152011 presentation_params->PresentationInterval = 0; - //ATI 5450 doesn't like D3DSWAPEFFECT_FLIP + // ATI 5450 doesn't like D3DSWAPEFFECT_FLIP presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; if (do_sync == false) { presentation_params->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } - // if (supported_multisamples<2) { - // if (do_sync) { - // // It turns out that COPY_VSYNC has real performance problems - // // on many nVidia cards--it syncs at some random interval, - // // possibly skipping over several video syncs. Screw it, - // // we'll effectively disable sync-video with windowed mode - // // using DirectX8. - // //presentation_params->SwapEffect = D3DSWAPEFFECT_COPY_VSYNC; - // presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; - // } else { - // presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; - // } +/* + * if (supported_multisamples<2) { if (do_sync) { It turns out that COPY_VSYNC + * has real performance problems on many nVidia cards--it syncs at some random + * interval, possibly skipping over several video syncs. Screw it, we'll + * effectively disable sync-video with windowed mode using DirectX8. + * presentation_params->SwapEffect = D3DSWAPEFFECT_COPY_VSYNC; + * presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; } else { + * presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; } + */ - // // override presentation parameters for windowed mode, render and display at maximum speed - // if (do_sync == false) { - // presentation_params->SwapEffect = D3DSWAPEFFECT_FLIP; - // presentation_params->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - // } - // } else { - // presentation_params->SwapEffect = D3DSWAPEFFECT_DISCARD; - // } +/* + * override presentation parameters for windowed mode, render and display at + * maximum speed if (do_sync == false) { presentation_params->SwapEffect = + * D3DSWAPEFFECT_FLIP; presentation_params->PresentationInterval = + * D3DPRESENT_INTERVAL_IMMEDIATE; } } else { presentation_params->SwapEffect = + * D3DSWAPEFFECT_DISCARD; } + */ - //assert((dwRenderWidth == presentation_params->BackBufferWidth)&&(dwRenderHeight == presentation_params->BackBufferHeight)); + // assert((dwRenderWidth == + // presentation_params->BackBufferWidth)&&(dwRenderHeight == + // presentation_params->BackBufferHeight)); hr = _d3d9->CreateDevice(adapter, device_type, _hWnd, dwBehaviorFlags, presentation_params, &display._d3d_device); @@ -799,7 +756,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer } } // end create windowed buffers - // ======================================================== + // ======================================================== PRINT_REFCNT(wdxdisplay9, _wcontext._d3d_device); @@ -871,7 +828,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer << adapter << endl; } return create_screen_buffers_and_device(display, true); - //return; + // return; } else if (!((dwRenderWidth == 640)&&(dwRenderHeight == 480))) { if (wdxdisplay9_cat.info()) @@ -880,7 +837,7 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer display._display_mode.Width = 640; display._display_mode.Height = 480; return create_screen_buffers_and_device(display, true); - //return; + // return; } else { wdxdisplay9_cat.fatal() @@ -889,14 +846,12 @@ create_screen_buffers_and_device(DXScreenData &display, bool force_16bpp_zbuffer } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::choose_device -// Access: Private -// Description: Looks at the list of available graphics adapters and -// chooses a suitable one for the window. -// -// Returns true if successful, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Looks at the list of available graphics adapters and chooses a suitable one + * for the window. + * + * Returns true if successful, false on failure. + */ bool wdxGraphicsWindow9:: choose_device() { HRESULT hr; @@ -960,16 +915,16 @@ choose_device() { return false; } - // Since some adapters may have been disabled, we should re-obtain - // the number of available adapters. + // Since some adapters may have been disabled, we should re-obtain the + // number of available adapters. num_adapters = (int)device_infos.size(); // Now choose a suitable adapter. int adapter_num = D3DADAPTER_DEFAULT; - // Eventually, we should have some interface for specifying a device - // index interactively, instead of only via Configrc. + // Eventually, we should have some interface for specifying a device index + // interactively, instead of only via Configrc. if (dx_preferred_device_id != -1) { if (dx_preferred_device_id < 0 || dx_preferred_device_id >= num_adapters) { wdxdisplay9_cat.error() @@ -992,8 +947,7 @@ choose_device() { << "Could not select device " << adapter_num << "\n"; } - // Iterate through all available devices to find the first suitable - // one. + // Iterate through all available devices to find the first suitable one. for (UINT devnum = 0; devnum < device_infos.size(); ++devnum) { if (consider_device(dxpipe, &device_infos[devnum])) { wdxdisplay9_cat.info() @@ -1007,13 +961,10 @@ choose_device() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::consider_device -// Access: Private -// Description: If the specified device is acceptable, sets it as the -// current device and returns true; otherwise, returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * If the specified device is acceptable, sets it as the current device and + * returns true; otherwise, returns false. + */ bool wdxGraphicsWindow9:: consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { @@ -1054,16 +1005,16 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { return false; } - //search_for_valid_displaymode needs these to be set + // search_for_valid_displaymode needs these to be set memcpy(&_wcontext._d3dcaps, &_d3dcaps, sizeof(D3DCAPS9)); _wcontext._card_id = device_info->cardID; _wcontext._max_available_video_memory = UNKNOWN_VIDMEM_SIZE; _wcontext._is_low_memory_card = false; - // bugbug: wouldnt we like to do GetAVailVidMem so we can do - // upper-limit memory computation for dx8 cards too? otherwise - // verify_window_sizes cant do much + // bugbug: wouldnt we like to do GetAVailVidMem so we can do upper-limit + // memory computation for dx8 cards too? otherwise verify_window_sizes cant + // do much if (_d3dcaps.MaxStreams == 0) { if (wdxdisplay9_cat.is_debug()) { wdxdisplay9_cat.debug() @@ -1072,7 +1023,7 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { UINT IDnum; - // simple linear search to match DX7 card info w/DX8 card ID + // simple linear search to match DX7 card info wDX8 card ID for (IDnum = 0; IDnum < dxpipe->_card_ids.size(); IDnum++) { if ((device_info->VendorID == dxpipe->_card_ids[IDnum].VendorID) && (device_info->DeviceID == dxpipe->_card_ids[IDnum].DeviceID) && @@ -1097,10 +1048,9 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { return false; } - // just because TNL is true, it doesnt mean vtx shaders are - // supported in HW (see GF2) for this case, you probably want MIXED - // processing to use HW for fixed-fn vertex processing and SW for - // vtx shaders + // just because TNL is true, it doesnt mean vtx shaders are supported in HW + // (see GF2) for this case, you probably want MIXED processing to use HW for + // fixed-fn vertex processing and SW for vtx shaders _wcontext._is_tnl_device = ((_d3dcaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0); _wcontext._can_use_hw_vertex_shaders = @@ -1125,8 +1075,8 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { &bCouldntFindValidZBuf, &pixFmt, dx_force_16bpp_zbuffer, true); - // note I'm not saving refresh rate, will just use adapter - // default at given res for now + // note I'm not saving refresh rate, will just use adapter default at + // given res for now if (pixFmt == D3DFMT_UNKNOWN) { wdxdisplay9_cat.error() @@ -1157,22 +1107,18 @@ consider_device(wdxGraphicsPipe9 *dxpipe, DXDeviceInfo *device_info) { if (strcmp(device_info->szDriver, "igdumd32.dll") == 0 && device_info->_driver_version.QuadPart <= 0x0007000e000affffLL && dx_intel_compressed_texture_bug) { - // Disable compressed textures for this buggy driver (7.14.10.65535 - // and earlier--I don't know whether any other drivers also - // exhibit the bug). + // Disable compressed textures for this buggy driver (7.14.10.65535 and + // earlier--I don't know whether any other drivers also exhibit the bug). _wcontext._intel_compressed_texture_bug = true; } return true; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::reset_device_resize_window -// Access: Private -// Description: Called after a window (either fullscreen or windowed) -// has been resized, this recreates the D3D structures -// to match the new size. -//////////////////////////////////////////////////////////////////// +/** + * Called after a window (either fullscreen or windowed) has been resized, + * this recreates the D3D structures to match the new size. + */ bool wdxGraphicsWindow9:: reset_device_resize_window(UINT new_xsize, UINT new_ysize) { bool retval = true; @@ -1212,7 +1158,8 @@ reset_device_resize_window(UINT new_xsize, UINT new_ysize) { return false; } } - // before you init_resized_window you need to copy certain changes to _wcontext + // before you init_resized_window you need to copy certain changes to + // _wcontext if (screen) { _wcontext._swap_chain = screen->_swap_chain; } @@ -1222,16 +1169,13 @@ reset_device_resize_window(UINT new_xsize, UINT new_ysize) { return retval; } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::init_resized_window -// Access: Private -// Description: Reinitializes the window after it has been resized, -// or after it is first created. -// -// Assumes CreateDevice or Device->Reset() has just been -// called, and the new size is specified in -// _wcontext._presentation_params. -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes the window after it has been resized, or after it is first + * created. + * + * Assumes CreateDevice or Device->Reset() has just been called, and the new + * size is specified in _wcontext._presentation_params. + */ void wdxGraphicsWindow9:: init_resized_window() { HRESULT hr; @@ -1305,12 +1249,10 @@ init_resized_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::D3DFMT_to_DepthBits -// Access: Private, Static -// Description: Returns the number of depth bits represented by the -// indicated D3DFORMAT value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of depth bits represented by the indicated D3DFORMAT + * value. + */ int wdxGraphicsWindow9:: D3DFMT_to_DepthBits(D3DFORMAT fmt) { switch(fmt) { @@ -1335,13 +1277,10 @@ D3DFMT_to_DepthBits(D3DFORMAT fmt) { } } -//////////////////////////////////////////////////////////////////// -// Function: wdxGraphicsWindow9::is_badvidmem_card -// Access: Private, Static -// Description: Returns true if the indicated video adapter card is -// known to report an inaccurate figure for available -// video memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated video adapter card is known to report an + * inaccurate figure for available video memory. + */ bool wdxGraphicsWindow9:: is_badvidmem_card(D3DADAPTER_IDENTIFIER9 *pDevID) { // don't trust Intel cards since they often use regular memory as vidmem @@ -1351,4 +1290,3 @@ is_badvidmem_card(D3DADAPTER_IDENTIFIER9 *pDevID) { return false; } - diff --git a/panda/src/dxgsg9/wdxGraphicsWindow9.h b/panda/src/dxgsg9/wdxGraphicsWindow9.h index 6b0b430c88..9bbe8b5eed 100644 --- a/panda/src/dxgsg9/wdxGraphicsWindow9.h +++ b/panda/src/dxgsg9/wdxGraphicsWindow9.h @@ -1,16 +1,15 @@ -// Filename: wdxGraphicsWindow9.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wdxGraphicsWindow9.h + * @author mike + * @date 1997-01-09 + */ #ifndef WDXGRAPHICSWINDOW9_H #define WDXGRAPHICSWINDOW9_H @@ -23,11 +22,9 @@ class wdxGraphicsPipe9; -//////////////////////////////////////////////////////////////////// -// Class : wdxGraphicsWindow9 -// Description : A single graphics window for rendering DirectX under -// Microsoft Windows. -//////////////////////////////////////////////////////////////////// +/** + * A single graphics window for rendering DirectX under Microsoft Windows. + */ class EXPCL_PANDADX wdxGraphicsWindow9 : public WinGraphicsWindow { public: wdxGraphicsWindow9(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index 077e79b275..48c9161805 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -1,16 +1,15 @@ -// Filename: config_dxml.cxx -// Created by: drose (08Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dxml.cxx + * @author drose + * @date 2009-08-08 + */ #include "config_dxml.h" #include "dconfig.h" diff --git a/panda/src/dxml/config_dxml.h b/panda/src/dxml/config_dxml.h index 8a08d45ad4..4596df95bb 100644 --- a/panda/src/dxml/config_dxml.h +++ b/panda/src/dxml/config_dxml.h @@ -1,16 +1,15 @@ -// Filename: config_dxml.h -// Created by: drose (08Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_dxml.h + * @author drose + * @date 2009-08-08 + */ #ifndef CONFIG_DXML_H #define CONFIG_DXML_H diff --git a/panda/src/egg/config_egg.cxx b/panda/src/egg/config_egg.cxx index 166d6488e0..83d11dad04 100644 --- a/panda/src/egg/config_egg.cxx +++ b/panda/src/egg/config_egg.cxx @@ -1,16 +1,15 @@ -// Filename: config_egg.cxx -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg.cxx + * @author drose + * @date 2000-03-19 + */ #include "config_egg.h" #include "eggRenderMode.h" @@ -166,14 +165,12 @@ ConfigVariableInt egg_precision "an egg file. Leave this at 0 to use the default setting for the " "stream.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libegg() { static bool initialized = false; diff --git a/panda/src/egg/config_egg.h b/panda/src/egg/config_egg.h index 20119cd07c..1df45a4359 100644 --- a/panda/src/egg/config_egg.h +++ b/panda/src/egg/config_egg.h @@ -1,16 +1,15 @@ -// Filename: config_egg.h -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg.h + * @author drose + * @date 2000-03-19 + */ #ifndef CONFIG_EGG_H #define CONFIG_EGG_H diff --git a/panda/src/egg/eggAnimData.I b/panda/src/egg/eggAnimData.I index 82ba9c528c..aec67eb1a3 100644 --- a/panda/src/egg/eggAnimData.I +++ b/panda/src/egg/eggAnimData.I @@ -1,35 +1,30 @@ -// Filename: eggAnimData.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimData.I + * @author drose + * @date 1999-02-19 + */ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimData:: EggAnimData(const string &name) : EggNode(name) { _has_fps = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimData:: EggAnimData(const EggAnimData ©) : EggNode(copy), _data(copy._data), @@ -37,11 +32,9 @@ EggAnimData(const EggAnimData ©) : } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimData &EggAnimData:: operator = (const EggAnimData ©) { EggNode::operator = (copy); @@ -53,11 +46,9 @@ operator = (const EggAnimData ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::set_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimData:: set_fps(double fps) { _fps = fps; @@ -65,31 +56,25 @@ set_fps(double fps) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::clear_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimData:: clear_fps() { _has_fps = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::has_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggAnimData:: has_fps() const { return _has_fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::get_fps -// Access: Public -// Description: This is only valid if has_fps() returns true. -//////////////////////////////////////////////////////////////////// +/** + * This is only valid if has_fps() returns true. + */ INLINE double EggAnimData:: get_fps() const { nassertr(has_fps(), 0.0); @@ -97,21 +82,17 @@ get_fps() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::clear_data -// Access: Public -// Description: Removes all data and empties the table. -//////////////////////////////////////////////////////////////////// +/** + * Removes all data and empties the table. + */ INLINE void EggAnimData:: clear_data() { _data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::add_data -// Access: Public -// Description: Adds a single element to the table. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single element to the table. + */ INLINE void EggAnimData:: add_data(double value) { _data.push_back(value); @@ -119,35 +100,28 @@ add_data(double value) { -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::get_size -// Access: Public -// Description: Returns the number of elements in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the table. + */ INLINE int EggAnimData:: get_size() const { return _data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::get_data -// Access: Public -// Description: Returns the entire table of data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire table of data. + */ INLINE PTA_double EggAnimData:: get_data() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::set_data -// Access: Public -// Description: Replaces the entire table of data. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the entire table of data. + */ INLINE void EggAnimData:: set_data(const PTA_double &data) { _data = data; } - diff --git a/panda/src/egg/eggAnimData.cxx b/panda/src/egg/eggAnimData.cxx index 4fdf973260..927bec4382 100644 --- a/panda/src/egg/eggAnimData.cxx +++ b/panda/src/egg/eggAnimData.cxx @@ -1,27 +1,23 @@ -// Filename: eggAnimData.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimData.cxx + * @author drose + * @date 1999-02-19 + */ #include "eggAnimData.h" TypeHandle EggAnimData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggAnimData::quantize -// Access: Public -// Description: Rounds each element of the table to the nearest -// multiple of quantum. -//////////////////////////////////////////////////////////////////// +/** + * Rounds each element of the table to the nearest multiple of quantum. + */ void EggAnimData:: quantize(double quantum) { for (size_t i = 0; i < _data.size(); i++) { diff --git a/panda/src/egg/eggAnimData.h b/panda/src/egg/eggAnimData.h index c0e5fddc30..745f98595b 100644 --- a/panda/src/egg/eggAnimData.h +++ b/panda/src/egg/eggAnimData.h @@ -1,16 +1,15 @@ -// Filename: eggAnimData.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimData.h + * @author drose + * @date 1999-02-19 + */ #ifndef EGGANIMDATA_H #define EGGANIMDATA_H @@ -24,11 +23,10 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : EggAnimData -// Description : A base class for EggSAnimData and EggXfmAnimData, -// which contain rows and columns of numbers. -//////////////////////////////////////////////////////////////////// +/** + * A base class for EggSAnimData and EggXfmAnimData, which contain rows and + * columns of numbers. + */ class EXPCL_PANDAEGG EggAnimData : public EggNode { PUBLISHED: diff --git a/panda/src/egg/eggAnimPreload.I b/panda/src/egg/eggAnimPreload.I index 310890dc95..7cfb879347 100644 --- a/panda/src/egg/eggAnimPreload.I +++ b/panda/src/egg/eggAnimPreload.I @@ -1,23 +1,19 @@ -// Filename: eggAnimPreload.I -// Created by: drose (06Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimPreload.I + * @author drose + * @date 2008-08-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimPreload:: EggAnimPreload(const string &name) : EggNode(name) { _has_fps = false; @@ -25,13 +21,11 @@ EggAnimPreload(const string &name) : EggNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimPreload:: -EggAnimPreload(const EggAnimPreload ©) : +EggAnimPreload(const EggAnimPreload ©) : EggNode(copy), _fps(copy._fps), _has_fps(copy._has_fps), @@ -41,11 +35,9 @@ EggAnimPreload(const EggAnimPreload ©) : } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggAnimPreload &EggAnimPreload:: operator = (const EggAnimPreload ©) { EggNode::operator = (copy); @@ -58,11 +50,9 @@ operator = (const EggAnimPreload ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::set_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimPreload:: set_fps(double fps) { _fps = fps; @@ -70,42 +60,34 @@ set_fps(double fps) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::clear_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimPreload:: clear_fps() { _has_fps = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::has_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggAnimPreload:: has_fps() const { return _has_fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::get_fps -// Access: Public -// Description: This is only valid if has_fps() returns true. -//////////////////////////////////////////////////////////////////// +/** + * This is only valid if has_fps() returns true. + */ INLINE double EggAnimPreload:: get_fps() const { nassertr(has_fps(), 0.0); return _fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::set_num_frames -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimPreload:: set_num_frames(int num_frames) { _num_frames = num_frames; @@ -113,31 +95,25 @@ set_num_frames(int num_frames) { } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::clear_num_frames -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAnimPreload:: clear_num_frames() { _has_num_frames = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::has_num_frames -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggAnimPreload:: has_num_frames() const { return _has_num_frames; } -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::get_num_frames -// Access: Public -// Description: This is only valid if has_num_frames() returns true. -//////////////////////////////////////////////////////////////////// +/** + * This is only valid if has_num_frames() returns true. + */ INLINE int EggAnimPreload:: get_num_frames() const { nassertr(has_num_frames(), 0); diff --git a/panda/src/egg/eggAnimPreload.cxx b/panda/src/egg/eggAnimPreload.cxx index 56cab9a683..ff05b12a3c 100644 --- a/panda/src/egg/eggAnimPreload.cxx +++ b/panda/src/egg/eggAnimPreload.cxx @@ -1,16 +1,15 @@ -// Filename: eggAnimPreload.cxx -// Created by: drose (06Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimPreload.cxx + * @author drose + * @date 2008-08-06 + */ #include "eggAnimPreload.h" @@ -19,12 +18,10 @@ TypeHandle EggAnimPreload::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggAnimPreload::write -// Access: Public, Virtual -// Description: Writes the table and all of its children to the -// indicated output stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the table and all of its children to the indicated output stream in + * Egg format. + */ void EggAnimPreload:: write(ostream &out, int indent_level) const { test_under_integrity(); diff --git a/panda/src/egg/eggAnimPreload.h b/panda/src/egg/eggAnimPreload.h index 1bf7fe0914..10374caf9f 100644 --- a/panda/src/egg/eggAnimPreload.h +++ b/panda/src/egg/eggAnimPreload.h @@ -1,16 +1,15 @@ -// Filename: eggAnimPreload.h -// Created by: drose (06Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAnimPreload.h + * @author drose + * @date 2008-08-06 + */ #ifndef EGGANIMPRELOAD_H #define EGGANIMPRELOAD_H @@ -19,10 +18,9 @@ #include "eggNode.h" -//////////////////////////////////////////////////////////////////// -// Class : EggAnimPreload -// Description : This corresponds to an entry. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to an entry. + */ class EXPCL_PANDAEGG EggAnimPreload : public EggNode { PUBLISHED: INLINE EggAnimPreload(const string &name = ""); @@ -68,4 +66,3 @@ private: #include "eggAnimPreload.I" #endif - diff --git a/panda/src/egg/eggAttributes.I b/panda/src/egg/eggAttributes.I index fdb7e1e9c9..b47c3a648d 100644 --- a/panda/src/egg/eggAttributes.I +++ b/panda/src/egg/eggAttributes.I @@ -1,66 +1,54 @@ -// Filename: eggAttributes.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAttributes.I + * @author drose + * @date 1999-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::has_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggAttributes:: has_normal() const { return (_flags & F_has_normal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::get_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LNormald &EggAttributes:: get_normal() const { nassertr(has_normal(), _normal); return _normal; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::set_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAttributes:: set_normal(const LNormald &normal) { _normal = normal; _flags |= F_has_normal; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::clear_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAttributes:: clear_normal() { _flags &= ~F_has_normal; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::matches_normal -// Access: Published -// Description: Returns true if this normal matches that of the other -// EggAttributes object, include the morph list. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this normal matches that of the other EggAttributes object, + * include the morph list. + */ INLINE bool EggAttributes:: matches_normal(const EggAttributes &other) const { if (((_flags ^ other._flags) & F_has_normal) != 0) { @@ -69,17 +57,14 @@ matches_normal(const EggAttributes &other) const { if (!has_normal()) { return true; } - return (get_normal() == other.get_normal() && + return (get_normal() == other.get_normal() && _dnormals.compare_to(other._dnormals, egg_parameters->_normal_threshold) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::copy_normal -// Access: Published -// Description: Sets this normal to be the same as the other's, -// include morphs. If the other has no normal, this -// clears the normal. -//////////////////////////////////////////////////////////////////// +/** + * Sets this normal to be the same as the other's, include morphs. If the + * other has no normal, this clears the normal. + */ INLINE void EggAttributes:: copy_normal(const EggAttributes &other) { if (!other.has_normal()) { @@ -90,22 +75,18 @@ copy_normal(const EggAttributes &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::has_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggAttributes:: has_color() const { return (_flags & F_has_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::get_color -// Access: Published -// Description: Returns the color set on this particular attribute. -// If there is no color set, returns white. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color set on this particular attribute. If there is no color + * set, returns white. + */ INLINE LColor EggAttributes:: get_color() const { if (has_color()) { @@ -115,33 +96,27 @@ get_color() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes:: -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAttributes:: set_color(const LColor &color) { _color = color; _flags |= F_has_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes:: -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggAttributes:: clear_color() { _flags &= ~F_has_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::matches_color -// Access: Published -// Description: Returns true if this color matches that of the other -// EggAttributes object, include the morph list. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this color matches that of the other EggAttributes object, + * include the morph list. + */ INLINE bool EggAttributes:: matches_color(const EggAttributes &other) const { if (((_flags ^ other._flags) & F_has_color) != 0) { @@ -150,17 +125,14 @@ matches_color(const EggAttributes &other) const { if (!has_color()) { return true; } - return (get_color() == other.get_color() && + return (get_color() == other.get_color() && _drgbas.compare_to(other._drgbas, egg_parameters->_color_threshold) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::copy_color -// Access: Published -// Description: Sets this color to be the same as the other's, -// include morphs. If the other has no color, this -// clears the color. -//////////////////////////////////////////////////////////////////// +/** + * Sets this color to be the same as the other's, include morphs. If the + * other has no color, this clears the color. + */ INLINE void EggAttributes:: copy_color(const EggAttributes &other) { if (!other.has_color()) { @@ -171,13 +143,10 @@ copy_color(const EggAttributes &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::sorts_less_than -// Access: Published -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + */ INLINE bool EggAttributes:: sorts_less_than(const EggAttributes &other) const { return compare_to(other) < 0; diff --git a/panda/src/egg/eggAttributes.cxx b/panda/src/egg/eggAttributes.cxx index 41784417d4..4f27c5a8b3 100644 --- a/panda/src/egg/eggAttributes.cxx +++ b/panda/src/egg/eggAttributes.cxx @@ -1,16 +1,15 @@ -// Filename: eggAttributes.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAttributes.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggAttributes.h" #include "eggParameters.h" @@ -22,31 +21,25 @@ TypeHandle EggAttributes::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggAttributes:: EggAttributes() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggAttributes:: EggAttributes(const EggAttributes ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggAttributes &EggAttributes:: operator = (const EggAttributes ©) { _flags = copy._flags; @@ -57,22 +50,17 @@ operator = (const EggAttributes ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggAttributes:: ~EggAttributes() { } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::write -// Access: Published -// Description: Writes the attributes to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the attributes to the indicated output stream in Egg format. + */ void EggAttributes:: write(ostream &out, int indent_level) const { if (has_normal()) { @@ -100,13 +88,10 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::compare_to -// Access: Published -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + */ int EggAttributes:: compare_to(const EggAttributes &other) const { if (_flags != other._flags) { @@ -140,12 +125,9 @@ compare_to(const EggAttributes &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggAttributes::transform -// Access: Published, Virtual -// Description: Applies the indicated transformation matrix to the -// attributes. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation matrix to the attributes. + */ void EggAttributes:: transform(const LMatrix4d &mat) { if (has_normal()) { @@ -155,15 +137,14 @@ transform(const LMatrix4d &mat) { EggMorphNormalList::iterator mi; for (mi = _dnormals.begin(); mi != _dnormals.end(); ++mi) { - // We can safely cast the morph object to a non-const, because - // we're not changing its name, which is the only thing the set - // cares about preserving. + // We can safely cast the morph object to a non-const, because we're not + // changing its name, which is the only thing the set cares about + // preserving. EggMorphNormal &morph = (EggMorphNormal &)(*mi); - // A bit of funny business to ensure the offset normal is - // normalized after the transform. This will break strange - // normal morphs that want to change the length of the normal, - // but what else can we do? + // A bit of funny business to ensure the offset normal is normalized + // after the transform. This will break strange normal morphs that want + // to change the length of the normal, but what else can we do? LVector3d offset = (*mi).get_offset() * mat; LVector3d n = old_normal + offset; n.normalize(); diff --git a/panda/src/egg/eggAttributes.h b/panda/src/egg/eggAttributes.h index c38d66a315..02e9c112ac 100644 --- a/panda/src/egg/eggAttributes.h +++ b/panda/src/egg/eggAttributes.h @@ -1,16 +1,15 @@ -// Filename: eggAttributes.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggAttributes.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGATTRIBUTES_H #define EGGATTRIBUTES_H @@ -23,17 +22,14 @@ #include "luse.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : EggAttributes -// Description : The set of attributes that may be applied to vertices -// as well as polygons, such as surface normal and -// color. -// -// This class cannot inherit from EggObject, because it -// causes problems at the EggPolygon level with multiple -// appearances of the EggObject base class. And making -// EggObject a virtual base class is just no fun. -//////////////////////////////////////////////////////////////////// +/** + * The set of attributes that may be applied to vertices as well as polygons, + * such as surface normal and color. + * + * This class cannot inherit from EggObject, because it causes problems at the + * EggPolygon level with multiple appearances of the EggObject base class. + * And making EggObject a virtual base class is just no fun. + */ class EXPCL_PANDAEGG EggAttributes : public MemoryBase { PUBLISHED: EggAttributes(); @@ -90,4 +86,3 @@ private: #include "eggAttributes.I" #endif - diff --git a/panda/src/egg/eggBin.cxx b/panda/src/egg/eggBin.cxx index 02a2847d39..789eaffb21 100644 --- a/panda/src/egg/eggBin.cxx +++ b/panda/src/egg/eggBin.cxx @@ -1,16 +1,15 @@ -// Filename: eggBin.cxx -// Created by: drose (21Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBin.cxx + * @author drose + * @date 1999-01-21 + */ #include "eggBin.h" @@ -18,54 +17,44 @@ TypeHandle EggBin::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggBin::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBin:: EggBin(const string &name) : EggGroup(name) { _bin_number = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggBin::EggGroup copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBin:: EggBin(const EggGroup ©) : EggGroup(copy) { _bin_number = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggBin::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBin:: EggBin(const EggBin ©) : EggGroup(copy), _bin_number(copy._bin_number) { } -//////////////////////////////////////////////////////////////////// -// Function: EggBin::set_bin_number -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggBin:: set_bin_number(int bin_number) { _bin_number = bin_number; } -//////////////////////////////////////////////////////////////////// -// Function: EggBin::get_bin_number -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int EggBin:: get_bin_number() const { return _bin_number; diff --git a/panda/src/egg/eggBin.h b/panda/src/egg/eggBin.h index 3aabf7d3bc..7ea017d8c6 100644 --- a/panda/src/egg/eggBin.h +++ b/panda/src/egg/eggBin.h @@ -1,16 +1,15 @@ -// Filename: eggBin.h -// Created by: drose (21Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBin.h + * @author drose + * @date 1999-01-21 + */ #ifndef EGGBIN_H #define EGGBIN_H @@ -19,14 +18,11 @@ #include "eggGroup.h" -//////////////////////////////////////////////////////////////////// -// Class : EggBin -// Description : A type of group node that holds related subnodes. -// This is a special kind of node that will never be -// read in from an egg file, but can only exist in the -// egg scene graph if it is created via the use of an -// EggBinMaker. -//////////////////////////////////////////////////////////////////// +/** + * A type of group node that holds related subnodes. This is a special kind + * of node that will never be read in from an egg file, but can only exist in + * the egg scene graph if it is created via the use of an EggBinMaker. + */ class EXPCL_PANDAEGG EggBin : public EggGroup { PUBLISHED: EggBin(const string &name = ""); diff --git a/panda/src/egg/eggBinMaker.cxx b/panda/src/egg/eggBinMaker.cxx index c4a084f25c..294c76de0d 100644 --- a/panda/src/egg/eggBinMaker.cxx +++ b/panda/src/egg/eggBinMaker.cxx @@ -1,16 +1,15 @@ -// Filename: eggBinMaker.cxx -// Created by: drose (21Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBinMaker.cxx + * @author drose + * @date 1999-01-21 + */ #include "eggBinMaker.h" #include "eggGroupNode.h" @@ -23,21 +22,19 @@ TypeHandle EggBinMaker::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggBinMakerCompareNodes::Function operator -// Access: Public -// Description: Called by the SortedNodes set to put nodes into bin -// order. Returns true if the first node falls into an -// earlier bin than the second node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Called by the SortedNodes set to put nodes into bin order. Returns true if + * the first node falls into an earlier bin than the second node, false + * otherwise. + */ bool EggBinMakerCompareNodes:: operator ()(const EggNode *a, const EggNode *b) const { int bin_number_a = _ebm->get_bin_number(a); int bin_number_b = _ebm->get_bin_number(b); if (bin_number_a != bin_number_b) { - // If the two nodes return different bin numbers, then they - // sort based on those numbers. + // If the two nodes return different bin numbers, then they sort based on + // those numbers. return bin_number_a < bin_number_b; } @@ -46,33 +43,26 @@ operator ()(const EggNode *a, const EggNode *b) const { return _ebm->sorts_less(bin_number_a, a, b); } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBinMaker:: EggBinMaker() { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBinMaker:: ~EggBinMaker() { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::make_bins -// Access: Public -// Description: The main entry point to EggBinMaker. Walks the egg -// scene graph beginning at the indicated root node, and -// moves all binnable nodes into EggBin objects. -// Returns the number of EggBins created. -//////////////////////////////////////////////////////////////////// +/** + * The main entry point to EggBinMaker. Walks the egg scene graph beginning + * at the indicated root node, and moves all binnable nodes into EggBin + * objects. Returns the number of EggBins created. + */ int EggBinMaker:: make_bins(EggGroupNode *root_group) { _group_nodes.clear(); @@ -88,69 +78,54 @@ make_bins(EggGroupNode *root_group) { return num_bins; } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::prepare_node -// Access: Public, Virtual -// Description: May be overridden in derived classes to perform some -// setup work as each node is encountered. This will be -// called once for each node in the egg hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to perform some setup work as each + * node is encountered. This will be called once for each node in the egg + * hierarchy. + */ void EggBinMaker:: prepare_node(EggNode *) { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::sorts_less -// Access: Public, Virtual -// Description: May be overridden in derived classes to create -// additional bins within a particular bin number, based -// on some arbitrary property of nodes. This function -// establishes an arbitrary but fixed ordering between -// nodes; if two nodes do not sort to the same position, -// different bins are created for each one (with the -// same bin number on each bin). -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to create additional bins within a + * particular bin number, based on some arbitrary property of nodes. This + * function establishes an arbitrary but fixed ordering between nodes; if two + * nodes do not sort to the same position, different bins are created for each + * one (with the same bin number on each bin). + */ bool EggBinMaker:: sorts_less(int, const EggNode *, const EggNode *) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::collapse_group -// Access: Public, Virtual -// Description: May be overridden in derived classes to specify -// whether a particular group node, apparently -// redundant, may be safely collapsed out. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to specify whether a particular group + * node, apparently redundant, may be safely collapsed out. + */ bool EggBinMaker:: collapse_group(const EggGroup *, int) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::get_bin_name -// Access: Public, Virtual -// Description: May be overridden in derived classes to define a name -// for each new bin, based on its bin number, and a -// sample child. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to define a name for each new bin, + * based on its bin number, and a sample child. + */ string EggBinMaker:: -get_bin_name(int, const EggNode *) { +get_bin_name(int, const EggNode *) { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::make_bin -// Access: Public, Virtual -// Description: May be overridden in derived classes to construct a -// new EggBin object (or some derived class, if needed), -// and preload some initial data into as required. -// -// child is an arbitrary child of the bin, and -// collapse_from is the group the bin is being collapsed -// with, if any (implying collapse_group() returned -// true), or NULL if not. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to construct a new EggBin object (or + * some derived class, if needed), and preload some initial data into as + * required. + * + * child is an arbitrary child of the bin, and collapse_from is the group the + * bin is being collapsed with, if any (implying collapse_group() returned + * true), or NULL if not. + */ PT(EggBin) EggBinMaker:: make_bin(int, const EggNode *, EggGroup *collapse_from) { if (collapse_from == (EggGroup *)NULL) { @@ -160,17 +135,14 @@ make_bin(int, const EggNode *, EggGroup *collapse_from) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::collect_nodes -// Access: Private -// Description: Walks the egg scene graph, identifying nodes to be -// binned and moving them from the scene graph into the -// internal bin structure. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg scene graph, identifying nodes to be binned and moving them + * from the scene graph into the internal bin structure. + */ void EggBinMaker:: collect_nodes(EggGroupNode *group) { - // We have to play games with this next iterator, because we might - // be destructively operating on the child list as we traverse it. + // We have to play games with this next iterator, because we might be + // destructively operating on the child list as we traverse it. EggGroupNode::iterator i, next; bool first_in_group = true; @@ -185,11 +157,10 @@ collect_nodes(EggGroupNode *group) { prepare_node(node); if (get_bin_number(node) != 0) { - // Ok, here's a node to be binned. Add it to the appropriate - // bin. + // Ok, here's a node to be binned. Add it to the appropriate bin. if (first_in_group) { - // If this is the first time this group has been encountered, - // we need to create a new entry in _group_nodes for it. + // If this is the first time this group has been encountered, we need + // to create a new entry in _group_nodes for it. pair result; result = _group_nodes.insert @@ -201,8 +172,8 @@ collect_nodes(EggGroupNode *group) { first_in_group = false; } - // Add this node to the set of all nodes being binned for the - // group. This also puts the nodes into bin order. + // Add this node to the set of all nodes being binned for the group. + // This also puts the nodes into bin order. nassertv(gni != _group_nodes.end()); (*gni).second.insert(node); @@ -220,12 +191,9 @@ collect_nodes(EggGroupNode *group) { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::get_bins_for_group -// Access: Private -// Description: Breaks the set of nodes for a given group up into -// individual bins. -//////////////////////////////////////////////////////////////////// +/** + * Breaks the set of nodes for a given group up into individual bins. + */ int EggBinMaker:: get_bins_for_group(GroupNodes::const_iterator gi) { EggGroupNode *group = (*gi).first; @@ -258,21 +226,18 @@ get_bins_for_group(GroupNodes::const_iterator gi) { return bins.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::make_bins_for_group -// Access: Private -// Description: Creates the EggBin nodes indicated by the internal -// bin structure for each group. -//////////////////////////////////////////////////////////////////// +/** + * Creates the EggBin nodes indicated by the internal bin structure for each + * group. + */ void EggBinMaker:: make_bins_for_group(EggGroupNode *group, const Bins &bins) { // We shouldn't be able to get here if we have no bins! nassertv(!bins.empty()); - // If the group will have only one bin, and no other children, and - // the group is not the root node (and it is not some funny - // group-like node like a ), maybe we should collapse the - // group and its bin together. + // If the group will have only one bin, and no other children, and the group + // is not the root node (and it is not some funny group-like node like a + //
), maybe we should collapse the group and its bin together. bool collapse = false; @@ -312,12 +277,9 @@ make_bins_for_group(EggGroupNode *group, const Bins &bins) { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinMaker::setup_bin -// Access: Private -// Description: Sets up a recently-created EggBin structure with all -// of its children. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a recently-created EggBin structure with all of its children. + */ void EggBinMaker:: setup_bin(EggBin *bin, const Nodes &nodes) { nassertv(!nodes.empty()); @@ -334,4 +296,3 @@ setup_bin(EggBin *bin, const Nodes &nodes) { bin->add_child(*ni); } } - diff --git a/panda/src/egg/eggBinMaker.h b/panda/src/egg/eggBinMaker.h index 1218b93565..2e3da3418f 100644 --- a/panda/src/egg/eggBinMaker.h +++ b/panda/src/egg/eggBinMaker.h @@ -1,211 +1,122 @@ -// Filename: eggBinMaker.h -// Created by: drose (21Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBinMaker.h + * @author drose + * @date 1999-01-21 + */ #ifndef EGGBINMAKER_H #define EGGBINMAKER_H -//////////////////////////////////////////////////////////////////// -// -// EggBinMaker -// -// This is a handy class for collecting related nodes together. Its -// purpose is to make it easier to process egg files for converting to -// another scene graph format. Egg is very general and allows nodes -// to be parented willy-nilly anywhere you like, while many other -// scene graph formats have requirements that certain kinds of nodes -// be grouped together. -// -// Although EggBinMaker can be used to group any kinds of nodes -// together, one of the most common examples is grouping polygons into -// polysets. Egg allows individual polygons to be parented directly -// to any group node, while most scene graph formats prefer to have -// polygons with similar attributes grouped into some kind of a -// polyset node. Therefore, the following usage discussion will use -// grouping polygons into polysets as an example. -// -// EggBinMaker is actually an abstract class; it cannot be used -// directly. To use it, you must create a subclass and redefine some -// or all of its virtual functions to specify the precise behavior you -// require. -// -// You must define at least the following function: -// -// virtual int get_bin_number(const EggNode *node); -// -// This function identifies the kinds of nodes in the graph, for -// instance EggPolygons, that are to be put into bins. It will be -// called once for each node encountered, and it should return -// nonzero if the node is to be binned, and zero otherwise. To -// group polygons into polysets, this function might look like: -// -// virtual int get_bin_number(const EggNode *node) { -// if (node->is_of_type(EggPolygon::get_class_type())) { -// return 1; -// } else { -// return 0; -// } -// } -// -// -// This function may also return the bin number that a given node -// should be dropped into. The bin number is completely arbitrary, -// and it just serves to differentiate different bins. -// -// By default, all sibling nodes will be dropped into the same bin; -// you can redefine this to sort nodes further into categories. -// For instance, if you wanted to put textured polygons into a -// different polyset than untextured polygons, you might define -// this function as follows: -// -// virtual int get_bin_number(const EggNode *node) { -// if (node->is_of_type(EggPolygon::get_class_type())) { -// EggPolygon *poly = DCAST(EggPolygon, node); -// return (poly->has_texture()) ? 1 : 2; -// } else { -// return 0; -// } -// } -// -// Of course, unrelated nodes--nodes that belong to different -// parents--will never be placed into the same bin together, -// regardless of the bin number. -// -// It is important to note that it is not necessarily true that -// there is only one bin for each bin number. If you redefine -// sorts_less(), below, you provide a finer-grained control that -// may create multiple bins for a given bin number. -// -// This function may be called several times for a given node, and -// it should return the same number each time. -// -// -// You may also redefine any or all of the following functions: -// -// virtual void prepare_node(EggNode *node); -// -// This method is called, once, on each node in the egg hierarchy -// as it is visited the first time. It allows the subclass a -// chance to analyze the node or do any other initial processing. -// This is a fine opportunity to tag an EggUserData onto the node, -// for instance. -// -// virtual bool sorts_less(int bin_number, const EggNode *a, const EggNode *b); -// -// Sometimes a simple bin number alone is not enough. For -// instance, suppose you needed to group together not just all -// textured polygons, but all polygons that shared a particular -// texture map. Two polygons that are each textured with a -// different texture map should go into different polysets. To do -// this with bin numbers, you'd have to know ahead of time all the -// texture maps that are in use, and assign a unique number to each -// one. -// -// sorts_less() can make this unnecessary. It's a finer-grained -// sorting than by bin numbers. Once two nodes have been grouped -// together into the same bin number, sorts_less is called on them. -// If it returns true, then node a should be placed into an earlier -// bin than node b, even though they share the same bin number. If -// sorts_less(a, b) and sorts_less(b, a) both return false, then -// nodes a and b are placed into the same bin. -// -// To continue the example, and sort polygons into different bins -// based on the texture map: -// -// virtual bool sorts_less(int bin_number, -// const EggNode *a, const EggNode *b) { -// if (bin_number == 2) { -// // bin 2, textured geometry -// return (a->get_texture() < b->get_texture()); -// } else { -// // bin 1, untextured geometry -// return false; -// } -// } -// -// The actual comparison can be arbitrary, as long as it is -// consistent. Its only purpose is to assign some ordering among -// bins. In the example, for instance, the comparison is based on -// the pointer to the texture maps--it doesn't matter which comes -// before the other, as long as it's consistent. -// -// In particular, it should never be true that sorts_less(a, b) and -// sorts_less(b, a) both return true--that is a clear -// contradiction. -// -// Of course, if you're using sorts_less() anyway, you could put -// *all* of the logic for binning into this function; there's no -// need to use both get_bin_number() and sorts_less(), necessarily. -// In the current example, here's another version of sorts_less() -// that accomplishes the same thing as the combined effects of the -// above get_bin_number() and sorts_less() working together: -// -// virtual bool sorts_less(int bin_number, -// const EggNode *a, const EggNode *b) { -// if (a->has_texture() != b->has_texture()) { -// return ((int)a->has_texture() < (int)b->has_texture()); -// } -// if (a->has_texture()) { -// return (a->get_texture() < b->get_texture()); -// } -// return false; -// } -// -// -// virtual bool collapse_group(const EggGroup *group, int bin_number); -// -// After all the nodes have been assigned to bins and the -// individual bins (polysets) have been created, it might turn out -// that some groups have had all their children placed into the -// same bin. In this case, the group node is now redundant, since -// it contains just the one child, the new EggBin (polyset) node. -// It might be advantageous to remove the group and collapse its -// properties into the new node. -// -// In this case (and this case only), collapse_group() will be -// called, given the node and the bin number. If it returns true, -// the node will indeed be collapsed into its bin; otherwise, they -// will be left separate. -// -// The point is that there might be some attributes in the group -// node (for instance, a matrix transform) that cannot be -// represented in a polyset node in the new scene graph format, so -// there may be some cases in which the group cannot be safely -// collapsed. Since the egg library cannot know about which such -// cases cause problems, it leaves it up to you. The default -// behavior is never to collapse nodes. -// -// -// virtual string get_bin_name(int bin_number, EggNode *child); -// -// This function is called as each new bin is created, to -// optionally define a name for the new node. If it returns the -// empty string, the node name will be empty, unless it was -// collapsed with its parent group, in which case it will inherit -// its former parent's name. -// -// -// -// Once you have subclassed EggBinMaker and defined the functions as -// you require, you use it by simply calling make_bins() one or more -// times, passing it the pointer to the root of the scene graph or of -// some subgraph. It will traverse the subgraph and create a series -// of EggBin objects, as required, moving all the binned geometry -// under the EggBin objects. The return value is the number of -// EggBins created. Each EggBin stores its bin number, which may be -// retrieved via get_bin_number(). -// -//////////////////////////////////////////////////////////////////// +/* + * EggBinMaker This is a handy class for collecting related nodes together. + * Its purpose is to make it easier to process egg files for converting to + * another scene graph format. Egg is very general and allows nodes to be + * parented willy-nilly anywhere you like, while many other scene graph + * formats have requirements that certain kinds of nodes be grouped together. + * Although EggBinMaker can be used to group any kinds of nodes together, one + * of the most common examples is grouping polygons into polysets. Egg allows + * individual polygons to be parented directly to any group node, while most + * scene graph formats prefer to have polygons with similar attributes grouped + * into some kind of a polyset node. Therefore, the following usage + * discussion will use grouping polygons into polysets as an example. + * EggBinMaker is actually an abstract class; it cannot be used directly. To + * use it, you must create a subclass and redefine some or all of its virtual + * functions to specify the precise behavior you require. You must define at + * least the following function: virtual int get_bin_number(const EggNode + * *node); This function identifies the kinds of nodes in the graph, for + * instance EggPolygons, that are to be put into bins. It will be called once + * for each node encountered, and it should return nonzero if the node is to + * be binned, and zero otherwise. To group polygons into polysets, this + * function might look like: virtual int get_bin_number(const EggNode *node) { + * if (node->is_of_type(EggPolygon::get_class_type())) { return 1; } else { + * return 0; } } This function may also return the bin number that a given + * node should be dropped into. The bin number is completely arbitrary, and + * it just serves to differentiate different bins. By default, all sibling + * nodes will be dropped into the same bin; you can redefine this to sort + * nodes further into categories. For instance, if you wanted to put textured + * polygons into a different polyset than untextured polygons, you might + * define this function as follows: virtual int get_bin_number(const EggNode + * *node) { if (node->is_of_type(EggPolygon::get_class_type())) { EggPolygon + * *poly = DCAST(EggPolygon, node); return (poly->has_texture()) ? 1 : 2; } + * else { return 0; } } Of course, unrelated nodes--nodes that belong to + * different parents--will never be placed into the same bin together, + * regardless of the bin number. It is important to note that it is not + * necessarily true that there is only one bin for each bin number. If you + * redefine sorts_less(), below, you provide a finer-grained control that may + * create multiple bins for a given bin number. This function may be called + * several times for a given node, and it should return the same number each + * time. You may also redefine any or all of the following functions: virtual + * void prepare_node(EggNode *node); This method is called, once, on each node + * in the egg hierarchy as it is visited the first time. It allows the + * subclass a chance to analyze the node or do any other initial processing. + * This is a fine opportunity to tag an EggUserData onto the node, for + * instance. virtual bool sorts_less(int bin_number, const EggNode *a, const + * EggNode *b); Sometimes a simple bin number alone is not enough. For + * instance, suppose you needed to group together not just all textured + * polygons, but all polygons that shared a particular texture map. Two + * polygons that are each textured with a different texture map should go into + * different polysets. To do this with bin numbers, you'd have to know ahead + * of time all the texture maps that are in use, and assign a unique number to + * each one. sorts_less() can make this unnecessary. It's a finer-grained + * sorting than by bin numbers. Once two nodes have been grouped together + * into the same bin number, sorts_less is called on them. If it returns + * true, then node a should be placed into an earlier bin than node b, even + * though they share the same bin number. If sorts_less(a, b) and + * sorts_less(b, a) both return false, then nodes a and b are placed into the + * same bin. To continue the example, and sort polygons into different bins + * based on the texture map: virtual bool sorts_less(int bin_number, const + * EggNode *a, const EggNode *b) { if (bin_number == 2) { bin 2, textured + * geometry return (a->get_texture() < b->get_texture()); } else { bin 1, + * untextured geometry return false; } } The actual comparison can be + * arbitrary, as long as it is consistent. Its only purpose is to assign some + * ordering among bins. In the example, for instance, the comparison is based + * on the pointer to the texture maps--it doesn't matter which comes before + * the other, as long as it's consistent. In particular, it should never be + * true that sorts_less(a, b) and sorts_less(b, a) both return true--that is a + * clear contradiction. Of course, if you're using sorts_less() anyway, you + * could put *all* of the logic for binning into this function; there's no + * need to use both get_bin_number() and sorts_less(), necessarily. In the + * current example, here's another version of sorts_less() that accomplishes + * the same thing as the combined effects of the above get_bin_number() and + * sorts_less() working together: virtual bool sorts_less(int bin_number, + * const EggNode *a, const EggNode *b) { if (a->has_texture() != + * b->has_texture()) { return ((int)a->has_texture() < (int)b->has_texture()); + * } if (a->has_texture()) { return (a->get_texture() < b->get_texture()); } + * return false; } virtual bool collapse_group(const EggGroup *group, int + * bin_number); After all the nodes have been assigned to bins and the + * individual bins (polysets) have been created, it might turn out that some + * groups have had all their children placed into the same bin. In this case, + * the group node is now redundant, since it contains just the one child, the + * new EggBin (polyset) node. It might be advantageous to remove the group + * and collapse its properties into the new node. In this case (and this case + * only), collapse_group() will be called, given the node and the bin number. + * If it returns true, the node will indeed be collapsed into its bin; + * otherwise, they will be left separate. The point is that there might be + * some attributes in the group node (for instance, a matrix transform) that + * cannot be represented in a polyset node in the new scene graph format, so + * there may be some cases in which the group cannot be safely collapsed. + * Since the egg library cannot know about which such cases cause problems, it + * leaves it up to you. The default behavior is never to collapse nodes. + * virtual string get_bin_name(int bin_number, EggNode *child); This function + * is called as each new bin is created, to optionally define a name for the + * new node. If it returns the empty string, the node name will be empty, + * unless it was collapsed with its parent group, in which case it will + * inherit its former parent's name. Once you have subclassed EggBinMaker and + * defined the functions as you require, you use it by simply calling + * make_bins() one or more times, passing it the pointer to the root of the + * scene graph or of some subgraph. It will traverse the subgraph and create + * a series of EggBin objects, as required, moving all the binned geometry + * under the EggBin objects. The return value is the number of EggBins + * created. Each EggBin stores its bin number, which may be retrieved via + * get_bin_number(). + */ #include "pandabase.h" @@ -224,17 +135,15 @@ class EggGroupNode; class EggBin; class EggBinMaker; -//////////////////////////////////////////////////////////////////// -// Class : EggBinMakerCompareNodes -// Description : This is just an STL function object, used to sort -// nodes within EggBinMaker. It's part of the private -// interface; ignore it. -//////////////////////////////////////////////////////////////////// +/** + * This is just an STL function object, used to sort nodes within EggBinMaker. + * It's part of the private interface; ignore it. + */ class EXPCL_PANDAEGG EggBinMakerCompareNodes { public: EggBinMakerCompareNodes() { - // We need to have a default constructor to compile, but it should - // never be called. + // We need to have a default constructor to compile, but it should never + // be called. nassertv(false); } EggBinMakerCompareNodes(EggBinMaker *ebm) : _ebm(ebm) { } @@ -244,13 +153,11 @@ public: }; -//////////////////////////////////////////////////////////////////// -// Class : EggBinMaker -// Description : This is a handy class for collecting related nodes -// together. It is an abstract class; to use it you -// must subclass off of it. See the somewhat lengthy -// comment above. -//////////////////////////////////////////////////////////////////// +/** + * This is a handy class for collecting related nodes together. It is an + * abstract class; to use it you must subclass off of it. See the somewhat + * lengthy comment above. + */ class EXPCL_PANDAEGG EggBinMaker : public EggObject { PUBLISHED: EggBinMaker(); @@ -273,20 +180,18 @@ PUBLISHED: virtual string get_bin_name(int bin_number, const EggNode *child); - virtual PT(EggBin) + virtual PT(EggBin) make_bin(int bin_number, const EggNode *child, EggGroup *collapse_from); private: - // The logic is two-pass. First, we make a scene graph traversal - // and store all the pointers into the GroupNodes/SortedNodes - // structure, which groups nodes by their parent group, and then - // sorted into bin order. + // The logic is two-pass. First, we make a scene graph traversal and store + // all the pointers into the GroupNodesSortedNodes structure, which groups + // nodes by their parent group, and then sorted into bin order. typedef pmultiset SortedNodes; typedef pmap GroupNodes; - // Then we walk through that list and create a Bins/Nodes structure - // for each group, which separates out the nodes into the individual - // bins. + // Then we walk through that list and create a BinsNodes structure for each + // group, which separates out the nodes into the individual bins. typedef pvector< PT(EggNode) > Nodes; typedef pvector Bins; @@ -319,5 +224,3 @@ private: }; #endif - - diff --git a/panda/src/egg/eggComment.I b/panda/src/egg/eggComment.I index 5e1a403769..cd26e3b12d 100644 --- a/panda/src/egg/eggComment.I +++ b/panda/src/egg/eggComment.I @@ -1,43 +1,35 @@ -// Filename: eggComment.I -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComment.I + * @author drose + * @date 1999-01-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggComment::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggComment:: EggComment(const string &node_name, const string &comment) : EggNode(node_name), _comment(comment) { } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggComment:: EggComment(const EggComment ©) : EggNode(copy), _comment(copy._comment) { } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggComment &EggComment:: operator = (const string &comment) { _comment = comment; @@ -45,11 +37,9 @@ operator = (const string &comment) { } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggComment &EggComment:: operator = (const EggComment ©) { _comment = copy._comment; @@ -57,35 +47,28 @@ operator = (const EggComment ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::String typecast operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggComment:: operator const string & () const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::set_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggComment:: set_comment(const string &comment) { _comment = comment; } -//////////////////////////////////////////////////////////////////// -// Function: EggComment::set_comment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string EggComment:: get_comment() const { return _comment; } - diff --git a/panda/src/egg/eggComment.cxx b/panda/src/egg/eggComment.cxx index 2fea2147cc..a55dd0787c 100644 --- a/panda/src/egg/eggComment.cxx +++ b/panda/src/egg/eggComment.cxx @@ -1,16 +1,15 @@ -// Filename: eggComment.cxx -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComment.cxx + * @author drose + * @date 1999-01-20 + */ #include "eggComment.h" #include "eggMiscFuncs.h" @@ -21,12 +20,9 @@ TypeHandle EggComment::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggComment::write -// Access: Public, Virtual -// Description: Writes the comment definition to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the comment definition to the indicated output stream in Egg format. + */ void EggComment:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggComment.h b/panda/src/egg/eggComment.h index 06ec0410cd..d0b7632876 100644 --- a/panda/src/egg/eggComment.h +++ b/panda/src/egg/eggComment.h @@ -1,16 +1,15 @@ -// Filename: eggComment.h -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComment.h + * @author drose + * @date 1999-01-20 + */ #ifndef EGGCOMMENT_H #define EGGCOMMENT_H @@ -19,18 +18,16 @@ #include "eggNode.h" -//////////////////////////////////////////////////////////////////// -// Class : EggComment -// Description : A comment that appears in an egg file within a -// entry. -//////////////////////////////////////////////////////////////////// +/** + * A comment that appears in an egg file within a entry. + */ class EXPCL_PANDAEGG EggComment : public EggNode { PUBLISHED: INLINE EggComment(const string &node_name, const string &comment); INLINE EggComment(const EggComment ©); - // You can use the string operators to directly set and manipulate - // the comment. + // You can use the string operators to directly set and manipulate the + // comment. INLINE EggComment &operator = (const string &comment); INLINE EggComment &operator = (const EggComment ©); diff --git a/panda/src/egg/eggCompositePrimitive.I b/panda/src/egg/eggCompositePrimitive.I index 0764f06e89..a3c805f4a0 100644 --- a/panda/src/egg/eggCompositePrimitive.I +++ b/panda/src/egg/eggCompositePrimitive.I @@ -1,107 +1,83 @@ -// Filename: eggCompositePrimitive.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCompositePrimitive.I + * @author drose + * @date 2005-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCompositePrimitive:: EggCompositePrimitive(const string &name) : EggPrimitive(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCompositePrimitive:: EggCompositePrimitive(const EggCompositePrimitive ©) : EggPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCompositePrimitive &EggCompositePrimitive:: operator = (const EggCompositePrimitive ©) { EggPrimitive::operator = (copy); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::get_num_components -// Access: Published -// Description: Returns the number of individual component triangles -// within the composite. Each one of these might have a -// different set of attributes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual component triangles within the composite. + * Each one of these might have a different set of attributes. + */ INLINE int EggCompositePrimitive:: get_num_components() const { return _components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::get_component -// Access: Published -// Description: Returns the attributes for the nth component -// triangle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the attributes for the nth component triangle. + */ INLINE const EggAttributes *EggCompositePrimitive:: get_component(int i) const { nassertr(i >= 0 && i < (int)_components.size(), NULL); return _components[i]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::get_component -// Access: Published -// Description: Returns the attributes for the nth component -// triangle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the attributes for the nth component triangle. + */ INLINE EggAttributes *EggCompositePrimitive:: get_component(int i) { nassertr(i >= 0 && i < (int)_components.size(), NULL); return _components[i]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::set_component -// Access: Published -// Description: Changes the attributes for the nth component -// triangle. -//////////////////////////////////////////////////////////////////// +/** + * Changes the attributes for the nth component triangle. + */ INLINE void EggCompositePrimitive:: set_component(int i, const EggAttributes *attrib) { nassertv(i >= 0 && i < (int)_components.size()); _components[i] = new EggAttributes(*attrib); } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::triangulate_into -// Access: Published -// Description: Subdivides the composite primitive into triangles and -// adds those triangles to the indicated container. -// Does not remove the primitive from its existing -// parent or modify it in any way. -// -// Returns true if the triangulation is successful, or -// false if there was some error (in which case the -// container may contain some partial triangulation). -//////////////////////////////////////////////////////////////////// +/** + * Subdivides the composite primitive into triangles and adds those triangles + * to the indicated container. Does not remove the primitive from its + * existing parent or modify it in any way. + * + * Returns true if the triangulation is successful, or false if there was some + * error (in which case the container may contain some partial triangulation). + */ INLINE bool EggCompositePrimitive:: triangulate_into(EggGroupNode *container) const { return do_triangulate(container); diff --git a/panda/src/egg/eggCompositePrimitive.cxx b/panda/src/egg/eggCompositePrimitive.cxx index 8234b2b31c..65c7e338dd 100644 --- a/panda/src/egg/eggCompositePrimitive.cxx +++ b/panda/src/egg/eggCompositePrimitive.cxx @@ -1,16 +1,15 @@ -// Filename: eggCompositePrimitive.cxx -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCompositePrimitive.cxx + * @author drose + * @date 2005-03-13 + */ #include "eggCompositePrimitive.h" #include "eggGroupNode.h" @@ -19,37 +18,29 @@ TypeHandle EggCompositePrimitive::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCompositePrimitive:: ~EggCompositePrimitive() { - // Every derived class of EggCompositePrimitive must call clear() in - // its destructor. + // Every derived class of EggCompositePrimitive must call clear() in its + // destructor. nassertv(_components.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::get_shading -// Access: Published, Virtual -// Description: Returns the shading properties apparent on this -// particular primitive. This returns S_per_vertex if -// the vertices have colors or normals (and they are not -// all the same values), or for a simple primitive, -// S_overall otherwise. A composite primitive may also -// return S_per_face if the individual component -// primitives have colors or normals that are not all -// the same values. -// -// To get the most accurate results, you should call -// clear_shading() on all connected primitives (or on -// all primitives in the egg file), followed by -// get_shading() on each primitive. You may find it -// easiest to call these methods on the EggData root -// node (they are defined on EggGroupNode). -//////////////////////////////////////////////////////////////////// +/** + * Returns the shading properties apparent on this particular primitive. This + * returns S_per_vertex if the vertices have colors or normals (and they are + * not all the same values), or for a simple primitive, S_overall otherwise. + * A composite primitive may also return S_per_face if the individual + * component primitives have colors or normals that are not all the same + * values. + * + * To get the most accurate results, you should call clear_shading() on all + * connected primitives (or on all primitives in the egg file), followed by + * get_shading() on each primitive. You may find it easiest to call these + * methods on the EggData root node (they are defined on EggGroupNode). + */ EggPrimitive::Shading EggCompositePrimitive:: get_shading() const { Shading basic_shading = EggPrimitive::get_shading(); @@ -97,21 +88,15 @@ get_shading() const { return S_overall; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::triangulate_in_place -// Access: Published -// Description: Subdivides the composite primitive into triangles and -// adds those triangles to the parent group node in -// place of the original primitive. Returns a pointer -// to the original primitive, which is likely about to -// be destructed. -// -// If convex_also is true, both concave and convex -// polygons will be subdivided into triangles; -// otherwise, only concave polygons will be subdivided, -// and convex polygons will be copied unchanged into the -// container. -//////////////////////////////////////////////////////////////////// +/** + * Subdivides the composite primitive into triangles and adds those triangles + * to the parent group node in place of the original primitive. Returns a + * pointer to the original primitive, which is likely about to be destructed. + * + * If convex_also is true, both concave and convex polygons will be subdivided + * into triangles; otherwise, only concave polygons will be subdivided, and + * convex polygons will be copied unchanged into the container. + */ PT(EggCompositePrimitive) EggCompositePrimitive:: triangulate_in_place() { EggGroupNode *parent = get_parent(); @@ -124,30 +109,24 @@ triangulate_in_place() { return save_me; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::unify_attributes -// Access: Published, Virtual -// Description: If the shading property is S_per_vertex, ensures that -// all vertices have a normal and a color, and the -// overall primitive does not. -// -// If the shading property is S_per_face, and this is a -// composite primitive, ensures that all components have -// a normal and a color, and the vertices and overall -// primitive do not. (If this is a simple primitive, -// S_per_face works the same as S_overall, below). -// -// If the shading property is S_overall, ensures that no -// vertices or components have a normal or a color, and -// the overall primitive does (if any exists at all). -// -// After this call, either the primitive will have -// normals or its vertices will, but not both. Ditto -// for colors. -// -// This may create redundant vertices in the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * If the shading property is S_per_vertex, ensures that all vertices have a + * normal and a color, and the overall primitive does not. + * + * If the shading property is S_per_face, and this is a composite primitive, + * ensures that all components have a normal and a color, and the vertices and + * overall primitive do not. (If this is a simple primitive, S_per_face works + * the same as S_overall, below). + * + * If the shading property is S_overall, ensures that no vertices or + * components have a normal or a color, and the overall primitive does (if any + * exists at all). + * + * After this call, either the primitive will have normals or its vertices + * will, but not both. Ditto for colors. + * + * This may create redundant vertices in the vertex pool. + */ void EggCompositePrimitive:: unify_attributes(EggPrimitive::Shading shading) { if (shading == S_unknown) { @@ -219,7 +198,7 @@ unify_attributes(EggPrimitive::Shading shading) { PT(EggVertex) vertex = new EggVertex(*orig_vertex); vertex->clear_normal(); vertex->clear_color(); - + EggVertexPool *vertex_pool = orig_vertex->get_pool(); nassertv(vertex_pool != (EggVertexPool *)NULL); vertex = vertex_pool->create_unique_vertex(*vertex); @@ -303,23 +282,18 @@ unify_attributes(EggPrimitive::Shading shading) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::apply_last_attribute -// Access: Published, Virtual -// Description: Sets the last vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// OpenGL convention of storing flat-shaded properties on -// the last vertex, although it is not usually a -// convention in Egg. -// -// This may introduce redundant vertices to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Sets the last vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * OpenGL convention of storing flat-shaded properties on the last vertex, + * although it is not usually a convention in Egg. + * + * This may introduce redundant vertices to the vertex pool. + */ void EggCompositePrimitive:: apply_last_attribute() { - // The first component gets applied to the third vertex, and so on - // from there. + // The first component gets applied to the third vertex, and so on from + // there. int num_lead_vertices = get_num_lead_vertices(); for (int i = 0; i < get_num_components(); i++) { EggAttributes *component = get_component(i); @@ -327,37 +301,29 @@ apply_last_attribute() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::apply_first_attribute -// Access: Published, Virtual -// Description: Sets the first vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// DirectX convention of storing flat-shaded properties -// on the first vertex, although it is not usually a -// convention in Egg. -// -// This may introduce redundant vertices to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Sets the first vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * DirectX convention of storing flat-shaded properties on the first vertex, + * although it is not usually a convention in Egg. + * + * This may introduce redundant vertices to the vertex pool. + */ void EggCompositePrimitive:: apply_first_attribute() { - // The first component gets applied to the first vertex, and so on - // from there. + // The first component gets applied to the first vertex, and so on from + // there. for (int i = 0; i < get_num_components(); i++) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i, component); } } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::post_apply_flat_attribute -// Access: Published, Virtual -// Description: Intended as a followup to apply_last_attribute(), -// this also sets an attribute on the first vertices of -// the primitive, if they don't already have an -// attribute set, just so they end up with *something*. -//////////////////////////////////////////////////////////////////// +/** + * Intended as a followup to apply_last_attribute(), this also sets an + * attribute on the first vertices of the primitive, if they don't already + * have an attribute set, just so they end up with *something*. + */ void EggCompositePrimitive:: post_apply_flat_attribute() { if (!empty()) { @@ -366,9 +332,9 @@ post_apply_flat_attribute() { EggVertex *vertex = get_vertex(i); EggAttributes *component = get_component(max(i - num_lead_vertices, 0)); - // Use set_normal() instead of copy_normal(), to avoid getting - // the morphs--we don't want them here, since we're just putting - // a bogus value on the normal anyway. + // Use set_normal() instead of copy_normal(), to avoid getting the + // morphs--we don't want them here, since we're just putting a bogus + // value on the normal anyway. if (component->has_normal() && !vertex->has_normal()) { vertex->set_normal(component->get_normal()); @@ -385,32 +351,25 @@ post_apply_flat_attribute() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::cleanup -// Access: Published, Virtual -// Description: Cleans up modeling errors in whatever context this -// makes sense. For instance, for a polygon, this calls -// remove_doubled_verts(true). For a point, it calls -// remove_nonunique_verts(). Returns true if the -// primitive is valid, or false if it is degenerate. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up modeling errors in whatever context this makes sense. For + * instance, for a polygon, this calls remove_doubled_verts(true). For a + * point, it calls remove_nonunique_verts(). Returns true if the primitive is + * valid, or false if it is degenerate. + */ bool EggCompositePrimitive:: cleanup() { return (int)size() >= get_num_lead_vertices() + 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::prepare_add_vertex -// Access: Protected, Virtual -// Description: Marks the vertex as belonging to the primitive. This -// is an internal function called by the STL-like -// functions push_back() and insert(), in preparation -// for actually adding the vertex. -// -// i indicates the new position of the vertex in the -// list; n indicates the new number of vertices after -// the operation has completed. -//////////////////////////////////////////////////////////////////// +/** + * Marks the vertex as belonging to the primitive. This is an internal + * function called by the STL-like functions push_back() and insert(), in + * preparation for actually adding the vertex. + * + * i indicates the new position of the vertex in the list; n indicates the new + * number of vertices after the operation has completed. + */ void EggCompositePrimitive:: prepare_add_vertex(EggVertex *vertex, int i, int n) { EggPrimitive::prepare_add_vertex(vertex, i, n); @@ -424,21 +383,17 @@ prepare_add_vertex(EggVertex *vertex, int i, int n) { } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::prepare_remove_vertex -// Access: Protected, Virtual -// Description: Marks the vertex as removed from the primitive. This -// is an internal function called by the STL-like -// functions pop_back() and erase(), in preparation for -// actually doing the removal. -// -// i indicates the former position of the vertex in the -// list; n indicates the current number of vertices -// before the operation has completed. -// -// It is an error to attempt to remove a vertex that is -// not already a vertex of this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Marks the vertex as removed from the primitive. This is an internal + * function called by the STL-like functions pop_back() and erase(), in + * preparation for actually doing the removal. + * + * i indicates the former position of the vertex in the list; n indicates the + * current number of vertices before the operation has completed. + * + * It is an error to attempt to remove a vertex that is not already a vertex + * of this primitive. + */ void EggCompositePrimitive:: prepare_remove_vertex(EggVertex *vertex, int i, int n) { EggPrimitive::prepare_remove_vertex(vertex, i, n); @@ -452,34 +407,26 @@ prepare_remove_vertex(EggVertex *vertex, int i, int n) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::triangulate_poly -// Access: Protected, Virtual -// Description: Fills the container up with EggPolygons that -// represent the component triangles of this triangle -// strip. -// -// It is assumed that the EggCompositePrimitive is not -// already a child of any other group when this function -// is called. -// -// Returns true if the triangulation is successful, or -// false if there was some error (in which case the -// container may contain some partial triangulation). -//////////////////////////////////////////////////////////////////// +/** + * Fills the container up with EggPolygons that represent the component + * triangles of this triangle strip. + * + * It is assumed that the EggCompositePrimitive is not already a child of any + * other group when this function is called. + * + * Returns true if the triangulation is successful, or false if there was some + * error (in which case the container may contain some partial triangulation). + */ bool EggCompositePrimitive:: do_triangulate(EggGroupNode *container) const { container->add_child((EggCompositePrimitive *)this); return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggCompositePrimitive::write_body -// Access: Protected -// Description: Writes the attributes and the vertices referenced by -// the primitive to the indicated output stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the attributes and the vertices referenced by the primitive to the + * indicated output stream in Egg format. + */ void EggCompositePrimitive:: write_body(ostream &out, int indent_level) const { EggPrimitive::write_body(out, indent_level); diff --git a/panda/src/egg/eggCompositePrimitive.h b/panda/src/egg/eggCompositePrimitive.h index 389c2fbdcb..7cbbcf0204 100644 --- a/panda/src/egg/eggCompositePrimitive.h +++ b/panda/src/egg/eggCompositePrimitive.h @@ -1,16 +1,15 @@ -// Filename: eggCompositePrimitive.h -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCompositePrimitive.h + * @author drose + * @date 2005-03-13 + */ #ifndef EGGCOMPOSITEPRIMITIVE_H #define EGGCOMPOSITEPRIMITIVE_H @@ -19,13 +18,11 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggCompositePrimitive -// Description : The base class for primitives such as triangle strips -// and triangle fans, which include several component -// triangles, each of which might have its own color -// and/or normal. -//////////////////////////////////////////////////////////////////// +/** + * The base class for primitives such as triangle strips and triangle fans, + * which include several component triangles, each of which might have its own + * color and/or normal. + */ class EXPCL_PANDAEGG EggCompositePrimitive : public EggPrimitive { PUBLISHED: INLINE EggCompositePrimitive(const string &name = ""); diff --git a/panda/src/egg/eggCoordinateSystem.I b/panda/src/egg/eggCoordinateSystem.I index db19e84b43..46747e8876 100644 --- a/panda/src/egg/eggCoordinateSystem.I +++ b/panda/src/egg/eggCoordinateSystem.I @@ -1,58 +1,46 @@ -// Filename: eggCoordinateSystem.I -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCoordinateSystem.I + * @author drose + * @date 1999-01-20 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: EggCoordinateSystem::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCoordinateSystem:: EggCoordinateSystem(CoordinateSystem value) { _value = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggCoordinateSystem::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCoordinateSystem:: EggCoordinateSystem(const EggCoordinateSystem ©) : EggNode(copy), _value(copy._value) { } -//////////////////////////////////////////////////////////////////// -// Function: EggCoordinateSystem::set_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggCoordinateSystem:: set_value(CoordinateSystem value) { _value = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggCoordinateSystem::set_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CoordinateSystem EggCoordinateSystem:: get_value() const { return _value; } - diff --git a/panda/src/egg/eggCoordinateSystem.cxx b/panda/src/egg/eggCoordinateSystem.cxx index 7bc40bbd96..9ef0ce14f9 100644 --- a/panda/src/egg/eggCoordinateSystem.cxx +++ b/panda/src/egg/eggCoordinateSystem.cxx @@ -1,16 +1,15 @@ -// Filename: eggCoordinateSystem.cxx -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCoordinateSystem.cxx + * @author drose + * @date 1999-01-20 + */ #include "eggCoordinateSystem.h" @@ -19,12 +18,10 @@ TypeHandle EggCoordinateSystem::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggCoordinateSystem::write -// Access: Public, Virtual -// Description: Writes the coordinate system definition to the -// indicated output stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the coordinate system definition to the indicated output stream in + * Egg format. + */ void EggCoordinateSystem:: write(ostream &out, int indent_level) const { if (get_value() != CS_default && diff --git a/panda/src/egg/eggCoordinateSystem.h b/panda/src/egg/eggCoordinateSystem.h index c513c0937f..bf8469b375 100644 --- a/panda/src/egg/eggCoordinateSystem.h +++ b/panda/src/egg/eggCoordinateSystem.h @@ -1,16 +1,15 @@ -// Filename: eggCoordinateSystem.h -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCoordinateSystem.h + * @author drose + * @date 1999-01-20 + */ #ifndef EGGCOORDINATESYSTEM_H #define EGGCOORDINATESYSTEM_H @@ -22,13 +21,11 @@ #include "coordinateSystem.h" -//////////////////////////////////////////////////////////////////// -// Class : EggCoordinateSystem -// Description : The entry at the top of an egg -// file. Don't confuse this with the enum -// EggData::CoordinateSystem, which is the value -// contained by this entry. -//////////////////////////////////////////////////////////////////// +/** + * The entry at the top of an egg file. Don't confuse this + * with the enum EggData::CoordinateSystem, which is the value contained by + * this entry. + */ class EXPCL_PANDAEGG EggCoordinateSystem : public EggNode { PUBLISHED: INLINE EggCoordinateSystem(CoordinateSystem value = CS_default); diff --git a/panda/src/egg/eggCurve.I b/panda/src/egg/eggCurve.I index 4ce0fb73f1..e8a665fcda 100644 --- a/panda/src/egg/eggCurve.I +++ b/panda/src/egg/eggCurve.I @@ -1,34 +1,28 @@ -// Filename: eggCurve.I -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCurve.I + * @author drose + * @date 2000-02-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCurve:: EggCurve(const string &name) : EggPrimitive(name) { _subdiv = 0; _type = CT_none; } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCurve:: EggCurve(const EggCurve ©) : EggPrimitive(copy), @@ -37,11 +31,9 @@ EggCurve(const EggCurve ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCurve &EggCurve:: operator = (const EggCurve ©) { EggPrimitive::operator = (copy); @@ -51,50 +43,39 @@ operator = (const EggCurve ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::set_subdiv -// Access: Public -// Description: Sets the number of subdivisions that will be -// requested across the curve. (This doesn't necessary -// guarantee that this number of subdivisions will be -// made; it's just a hint to any curve renderer or quick -// tesselator.) Set the number to 0 to disable the -// hint. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of subdivisions that will be requested across the curve. + * (This doesn't necessary guarantee that this number of subdivisions will be + * made; it's just a hint to any curve renderer or quick tesselator.) Set the + * number to 0 to disable the hint. + */ INLINE void EggCurve:: set_subdiv(int subdiv) { _subdiv = subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::get_subdiv -// Access: Public -// Description: Returns the requested number of subdivisions, or 0 if -// no particular subdivisions have been requested. -//////////////////////////////////////////////////////////////////// +/** + * Returns the requested number of subdivisions, or 0 if no particular + * subdivisions have been requested. + */ INLINE int EggCurve:: get_subdiv() const { return _subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::set_curve_type -// Access: Public -// Description: Sets the type of the curve. This is primarily used -// as a hint to any code that may need to deal with this -// curve. -//////////////////////////////////////////////////////////////////// +/** + * Sets the type of the curve. This is primarily used as a hint to any code + * that may need to deal with this curve. + */ INLINE void EggCurve:: set_curve_type(EggCurve::CurveType type) { _type = type; } -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::get_curve_type -// Access: Public -// Description: Returns the indicated type of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated type of the curve. + */ INLINE EggCurve::CurveType EggCurve:: get_curve_type() const { return _type; diff --git a/panda/src/egg/eggCurve.cxx b/panda/src/egg/eggCurve.cxx index dfec6b2879..932e4a6c9d 100644 --- a/panda/src/egg/eggCurve.cxx +++ b/panda/src/egg/eggCurve.cxx @@ -1,16 +1,15 @@ -// Filename: eggCurve.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCurve.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggCurve.h" @@ -20,13 +19,11 @@ TypeHandle EggCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggCurve::string_curve_type -// Access: Public, Static -// Description: Returns the CurveType value associated with the given -// string representation, or CT_invalid if the string -// does not match any known CurveType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CurveType value associated with the given string + * representation, or CT_invalid if the string does not match any known + * CurveType value. + */ EggCurve::CurveType EggCurve:: string_curve_type(const string &string) { if (cmp_nocase_uh(string, "xyz") == 0) { @@ -40,10 +37,9 @@ string_curve_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: CurveType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggCurve::CurveType t) { switch (t) { case EggCurve::CT_none: @@ -59,4 +55,3 @@ ostream &operator << (ostream &out, EggCurve::CurveType t) { nassertr(false, out); return out << "(**invalid**)"; } - diff --git a/panda/src/egg/eggCurve.h b/panda/src/egg/eggCurve.h index ff24a0d740..fa43f9700a 100644 --- a/panda/src/egg/eggCurve.h +++ b/panda/src/egg/eggCurve.h @@ -1,16 +1,15 @@ -// Filename: eggCurve.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCurve.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGCURVE_H #define EGGCURVE_H @@ -19,11 +18,9 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggCurve -// Description : A parametric curve of some kind. See -// EggNurbsCurve. -//////////////////////////////////////////////////////////////////// +/** + * A parametric curve of some kind. See EggNurbsCurve. + */ class EXPCL_PANDAEGG EggCurve : public EggPrimitive { PUBLISHED: INLINE EggCurve(const string &name = ""); diff --git a/panda/src/egg/eggData.I b/panda/src/egg/eggData.I index 2cf6853239..ac35aa3f48 100644 --- a/panda/src/egg/eggData.I +++ b/panda/src/egg/eggData.I @@ -1,23 +1,19 @@ -// Filename: eggData.I -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggData.I + * @author drose + * @date 1999-02-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggData:: EggData() { _auto_resolve_externals = false; @@ -27,11 +23,9 @@ EggData() { } -//////////////////////////////////////////////////////////////////// -// Function: EggData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggData:: EggData(const EggData ©) : EggGroupNode(copy), @@ -43,11 +37,9 @@ EggData(const EggData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggData &EggData:: operator = (const EggData ©) { EggGroupNode::operator = (copy); @@ -59,167 +51,128 @@ operator = (const EggData ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::set_auto_resolve_externals -// Access: Public -// Description: Indicates whether the EggData object will -// automatically resolve any external references when -// read() is called. The default is false. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the EggData object will automatically resolve any + * external references when read() is called. The default is false. + */ INLINE void EggData:: set_auto_resolve_externals(bool resolve) { _auto_resolve_externals = resolve; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::get_auto_resolve_externals -// Access: Public -// Description: Indicates whether the EggData object will -// automatically resolve any external references when -// read() is called. The default is false. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the EggData object will automatically resolve any + * external references when read() is called. The default is false. + */ INLINE bool EggData:: get_auto_resolve_externals() const { return _auto_resolve_externals; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::original_had_absolute_pathnames -// Access: Public -// Description: Returns true if the data processed in the last call -// to read() contained absolute pathnames, or false if -// those pathnames were all relative. -// -// This method is necessary because if -// auto_resolve_externals() is in effect, it may modify -// the pathnames to be absolute whether or not they were -// as loaded from disk. This method can be used to -// query the state of the original egg file from disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data processed in the last call to read() contained + * absolute pathnames, or false if those pathnames were all relative. + * + * This method is necessary because if auto_resolve_externals() is in effect, + * it may modify the pathnames to be absolute whether or not they were as + * loaded from disk. This method can be used to query the state of the + * original egg file from disk. + */ INLINE bool EggData:: original_had_absolute_pathnames() const { return _had_absolute_pathnames; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::get_coordinate_system -// Access: Public -// Description: Returns the coordinate system in which the egg file -// is defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system in which the egg file is defined. + */ INLINE CoordinateSystem EggData:: get_coordinate_system() const { return _coordsys; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::set_egg_filename -// Access: Public -// Description: Sets the filename--especially the directory part--in -// which the egg file is considered to reside. This is -// also implicitly set by read(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the filename--especially the directory part--in which the egg file is + * considered to reside. This is also implicitly set by read(). + */ INLINE void EggData:: set_egg_filename(const Filename &egg_filename) { _egg_filename = egg_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::get_egg_filename -// Access: Public -// Description: Returns the directory in which the egg file is -// considered to reside. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory in which the egg file is considered to reside. + */ INLINE const Filename &EggData:: get_egg_filename() const { return _egg_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::set_egg_timestamp -// Access: Public -// Description: Sets the timestamp of the egg file on disk, at the -// time it was opened for reading. This is also -// implicitly set by read(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the timestamp of the egg file on disk, at the time it was opened for + * reading. This is also implicitly set by read(). + */ INLINE void EggData:: set_egg_timestamp(time_t egg_timestamp) { _egg_timestamp = egg_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::get_egg_timestamp -// Access: Public -// Description: Returns the timestamp of the egg file on disk, at the -// time it was opened for reading, or 0 if this -// information is not available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp of the egg file on disk, at the time it was opened + * for reading, or 0 if this information is not available. + */ INLINE time_t EggData:: get_egg_timestamp() const { return _egg_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::recompute_vertex_normals -// Access: Public -// Description: Recomputes all the vertex normals for polygon -// geometry at this group node and below so that they -// accurately reflect the vertex positions. A shared -// edge between two polygons (even in different groups) -// is considered smooth if the angle between the two -// edges is less than threshold degrees. -// -// This function also removes degenerate polygons that -// do not have enough vertices to define a normal. It -// does not affect normals for other kinds of primitives -// like Nurbs or Points. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// correct normals. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all the vertex normals for polygon geometry at this group node + * and below so that they accurately reflect the vertex positions. A shared + * edge between two polygons (even in different groups) is considered smooth + * if the angle between the two edges is less than threshold degrees. + * + * This function also removes degenerate polygons that do not have enough + * vertices to define a normal. It does not affect normals for other kinds of + * primitives like Nurbs or Points. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the correct normals. Thus, it is a good idea + * to call remove_unused_vertices() after calling this. + */ INLINE void EggData:: recompute_vertex_normals(double threshold) { EggGroupNode::recompute_vertex_normals(threshold, _coordsys); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::recompute_polygon_normals -// Access: Public -// Description: Recomputes all the polygon normals for polygon -// geometry at this group node and below so that they -// accurately reflect the vertex positions. Normals are -// removed from the vertices and defined only on -// polygons, giving the geometry a faceted appearance. -// -// This function also removes degenerate polygons that -// do not have enough vertices to define a normal. It -// does not affect normals for other kinds of primitives -// like Nurbs or Points. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// normals removed. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all the polygon normals for polygon geometry at this group node + * and below so that they accurately reflect the vertex positions. Normals + * are removed from the vertices and defined only on polygons, giving the + * geometry a faceted appearance. + * + * This function also removes degenerate polygons that do not have enough + * vertices to define a normal. It does not affect normals for other kinds of + * primitives like Nurbs or Points. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the normals removed. Thus, it is a good idea + * to call remove_unused_vertices() after calling this. + */ INLINE void EggData:: recompute_polygon_normals() { EggGroupNode::recompute_polygon_normals(_coordsys); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::strip_normals -// Access: Public -// Description: Removes all normals from primitives, and the vertices -// they reference, at this node and below. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// normal removed. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Removes all normals from primitives, and the vertices they reference, at + * this node and below. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the normal removed. Thus, it is a good idea to + * call remove_unused_vertices() after calling this. + */ INLINE void EggData:: strip_normals() { EggGroupNode::strip_normals(); diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index da891bfb9e..f81755f8d9 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -1,16 +1,15 @@ -// Filename: eggData.cxx -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggData.cxx + * @author drose + * @date 1999-01-20 + */ #include "eggData.h" #include "eggCoordinateSystem.h" @@ -33,14 +32,11 @@ extern int eggyyparse(); TypeHandle EggData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggData::resolve_egg_filename -// Access: Public, Static -// Description: Looks for the indicated filename, first along the -// indicated searchpath, and then along the model_path. -// If found, updates the filename to the full path and -// returns true; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Looks for the indicated filename, first along the indicated searchpath, and + * then along the model_path. If found, updates the filename to the full path + * and returns true; otherwise, returns false. + */ bool EggData:: resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -55,18 +51,13 @@ resolve_egg_filename(Filename &egg_filename, const DSearchPath &searchpath) { return vfs->exists(egg_filename); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::read -// Access: Public -// Description: Opens the indicated filename and reads the egg data -// contents from it. Returns true if the file was -// successfully opened and read, false if there were -// some errors, in which case the data may be partially -// read. -// -// error is the output stream to which to write error -// messages. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename and reads the egg data contents from it. + * Returns true if the file was successfully opened and read, false if there + * were some errors, in which case the data may be partially read. + * + * error is the output stream to which to write error messages. + */ bool EggData:: read(Filename filename, string display_name) { filename.set_text(); @@ -100,29 +91,24 @@ read(Filename filename, string display_name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggData::read -// Access: Public -// Description: Parses the egg syntax contained in the indicated -// input stream. Returns true if the stream was a -// completely valid egg file, false if there were some -// errors, in which case the data may be partially read. -// -// Before you call this routine, you should probably -// call set_egg_filename() to set the name of the egg -// file we're processing, if at all possible. If there -// is no such filename, you may set it to the empty -// string. -//////////////////////////////////////////////////////////////////// +/** + * Parses the egg syntax contained in the indicated input stream. Returns + * true if the stream was a completely valid egg file, false if there were + * some errors, in which case the data may be partially read. + * + * Before you call this routine, you should probably call set_egg_filename() + * to set the name of the egg file we're processing, if at all possible. If + * there is no such filename, you may set it to the empty string. + */ bool EggData:: read(istream &in) { - // First, dispense with any children we had previously. We will - // replace them with the new data. + // First, dispense with any children we had previously. We will replace + // them with the new data. clear(); - // Create a temporary EggData structure to read into. We initialize - // it with a copy of ourselves, so that it will get our _coordsys - // value, if the user set it. + // Create a temporary EggData structure to read into. We initialize it with + // a copy of ourselves, so that it will get our _coordsys value, if the user + // set it. PT(EggData) data = new EggData(*this); int error_count; @@ -142,72 +128,58 @@ read(istream &in) { return (error_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::merge -// Access: Public -// Description: Appends the other egg structure to the end of this -// one. The other egg structure is invalidated. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other egg structure to the end of this one. The other egg + * structure is invalidated. + */ void EggData:: merge(EggData &other) { if (get_coordinate_system() == CS_default) { - // If we haven't specified a coordinate system yet, we inherit the - // other one's. + // If we haven't specified a coordinate system yet, we inherit the other + // one's. set_coordinate_system(other.get_coordinate_system()); } else { - // Otherwise, the other one is forced into our coordinate system - // before we merge. + // Otherwise, the other one is forced into our coordinate system before we + // merge. other.set_coordinate_system(get_coordinate_system()); } steal_children(other); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::load_externals -// Access: Public -// Description: Loads up all the egg files referenced by -// entries within the egg structure, and inserts their -// contents in place of the entries. Searches -// for files in the searchpath, if not found directly, -// and writes error messages to the indicated output -// stream. Returns true if all externals were loaded -// successfully, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all the egg files referenced by entries within the egg + * structure, and inserts their contents in place of the entries. + * Searches for files in the searchpath, if not found directly, and writes + * error messages to the indicated output stream. Returns true if all + * externals were loaded successfully, false otherwise. + */ bool EggData:: load_externals(const DSearchPath &searchpath) { return r_load_externals(searchpath, get_coordinate_system(), NULL); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::load_externals -// Access: Public -// Description: Loads up all the egg files referenced by -// entries within the egg structure, and inserts their -// contents in place of the entries. Searches -// for files in the searchpath, if not found directly, -// and writes error messages to the indicated output -// stream. Returns true if all externals were loaded -// successfully, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all the egg files referenced by entries within the egg + * structure, and inserts their contents in place of the entries. + * Searches for files in the searchpath, if not found directly, and writes + * error messages to the indicated output stream. Returns true if all + * externals were loaded successfully, false otherwise. + */ bool EggData:: load_externals(const DSearchPath &searchpath, BamCacheRecord *record) { return r_load_externals(searchpath, get_coordinate_system(), record); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::collapse_equivalent_textures -// Access: Public -// Description: Removes duplicate references to the same texture -// image with the same properties. Considers two -// texture references with identical properties, but -// different tref names, to be equivalent, and collapses -// them, choosing one tref name to keep arbitrarily. -// Returns the number of textures removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes duplicate references to the same texture image with the same + * properties. Considers two texture references with identical properties, + * but different tref names, to be equivalent, and collapses them, choosing + * one tref name to keep arbitrarily. Returns the number of textures removed. + */ int EggData:: collapse_equivalent_textures() { EggTextureCollection textures; @@ -216,16 +188,12 @@ collapse_equivalent_textures() { textures.collapse_equivalent_textures(~EggTexture::E_tref_name, this); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::collapse_equivalent_materials -// Access: Public -// Description: Removes duplicate references to the same material -// with the same properties. Considers two material -// references with identical properties, but different -// mref names, to be equivalent, and collapses them, -// choosing one mref name to keep arbitrarily. Returns -// the number of materials removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes duplicate references to the same material with the same properties. + * Considers two material references with identical properties, but different + * mref names, to be equivalent, and collapses them, choosing one mref name to + * keep arbitrarily. Returns the number of materials removed. + */ int EggData:: collapse_equivalent_materials() { EggMaterialCollection materials; @@ -234,11 +202,9 @@ collapse_equivalent_materials() { materials.collapse_equivalent_materials(~EggMaterial::E_mref_name, this); } -//////////////////////////////////////////////////////////////////// -// Function: EggData::write_egg -// Access: Public -// Description: The main interface for writing complete egg files. -//////////////////////////////////////////////////////////////////// +/** + * The main interface for writing complete egg files. + */ bool EggData:: write_egg(Filename filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -255,11 +221,9 @@ write_egg(Filename filename) { return wrote_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::write_egg -// Access: Public -// Description: The main interface for writing complete egg files. -//////////////////////////////////////////////////////////////////// +/** + * The main interface for writing complete egg files. + */ bool EggData:: write_egg(ostream &out) { pre_write(); @@ -278,13 +242,10 @@ write_egg(ostream &out) { } -//////////////////////////////////////////////////////////////////// -// Function: EggData::set_coordinate_system -// Access: Public -// Description: Changes the coordinate system of the EggData. If the -// coordinate system was previously different, this may -// result in a conversion of the data. -//////////////////////////////////////////////////////////////////// +/** + * Changes the coordinate system of the EggData. If the coordinate system was + * previously different, this may result in a conversion of the data. + */ void EggData:: set_coordinate_system(CoordinateSystem new_coordsys) { if (new_coordsys == CS_default) { @@ -299,20 +260,17 @@ set_coordinate_system(CoordinateSystem new_coordsys) { r_transform(mat, inv, new_coordsys); r_transform_vertices(mat); - // Now we have to update the under_flags to ensure that all the - // cached relative matrices are correct. + // Now we have to update the under_flags to ensure that all the cached + // relative matrices are correct. update_under(0); } _coordsys = new_coordsys; } -//////////////////////////////////////////////////////////////////// -// Function: EggData::write -// Access: Protected, Virtual -// Description: Writes the egg data out to the indicated output -// stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the egg data out to the indicated output stream. + */ void EggData:: write(ostream &out, int indent_level) const { PT(EggCoordinateSystem) ecs = new EggCoordinateSystem(_coordsys); @@ -322,20 +280,18 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggData::post_read -// Access: Private -// Description: Does whatever processing is appropriate after reading -// the data in from an egg file. -//////////////////////////////////////////////////////////////////// +/** + * Does whatever processing is appropriate after reading the data in from an + * egg file. + */ void EggData:: post_read() { CoordinateSystem old_coordsys = _coordsys; _coordsys = find_coordsys_entry(); if (_coordsys == CS_default) { - // If the egg file didn't contain a entry, - // assume it's Y-up, by convention. + // If the egg file didn't contain a entry, assume it's + // Y-up, by convention. _coordsys = CS_yup_right; } else if (_coordsys == CS_invalid) { @@ -347,8 +303,8 @@ post_read() { r_mark_coordsys(_coordsys); if (old_coordsys != CS_default) { - // Now if we had a previous definition, enforce it. This might - // convert the data to the given coordinate system. + // Now if we had a previous definition, enforce it. This might convert + // the data to the given coordinate system. set_coordinate_system(old_coordsys); } @@ -363,26 +319,24 @@ post_read() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggData::pre_write -// Access: Private -// Description: Does whatever processing is appropriate just before -// writing the data out to an egg file. This includes -// verifying that vertex pool names are unique, etc. -//////////////////////////////////////////////////////////////////// +/** + * Does whatever processing is appropriate just before writing the data out to + * an egg file. This includes verifying that vertex pool names are unique, + * etc. + */ void EggData:: pre_write() { - // Pull out all of the texture definitions in the file and massage - // them a bit. + // Pull out all of the texture definitions in the file and massage them a + // bit. EggTextureCollection textures; textures.extract_textures(this); // Remove any textures that aren't being used. textures.remove_unused_textures(this); - // Collapse out any textures that are completely equivalent. For - // this purpose, we consider two textures with identical properties - // but different tref names to be different. + // Collapse out any textures that are completely equivalent. For this + // purpose, we consider two textures with identical properties but different + // tref names to be different. textures.collapse_equivalent_textures(~0, this); // Make sure all of the textures have unique TRef names. @@ -397,8 +351,8 @@ pre_write() { materials.uniquify_mrefs(); materials.sort_by_mref(); - // Now put them all back at the head of the file, after any initial - // comment records. + // Now put them all back at the head of the file, after any initial comment + // records. iterator ci = begin(); while (ci != end() && (*ci)->is_of_type(EggComment::get_class_type())) { ++ci; @@ -406,9 +360,9 @@ pre_write() { textures.insert_textures(this, ci); materials.insert_materials(this, ci); - // Also make sure that the vertex pools are uniquely named. This - // also checks textures and materials, which is kind of redundant - // since we just did that, but we don't mind. + // Also make sure that the vertex pools are uniquely named. This also + // checks textures and materials, which is kind of redundant since we just + // did that, but we don't mind. EggPoolUniquifier pu; pu.uniquify(this); } diff --git a/panda/src/egg/eggData.h b/panda/src/egg/eggData.h index ab299a9abb..5544f28d60 100644 --- a/panda/src/egg/eggData.h +++ b/panda/src/egg/eggData.h @@ -1,16 +1,15 @@ -// Filename: eggData.h -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggData.h + * @author drose + * @date 1999-01-20 + */ #ifndef EGGDATA_H #define EGGDATA_H @@ -25,19 +24,16 @@ class BamCacheRecord; -//////////////////////////////////////////////////////////////////// -// Class : EggData -// Description : This is the primary interface into all the egg data, -// and the root of the egg file structure. An EggData -// structure corresponds exactly with an egg file on the -// disk. -// -// The EggData class inherits from EggGroupNode its -// collection of children, which are accessed by using -// the EggData itself as an STL container with begin() -// and end() calls. The children of the EggData class -// are the toplevel nodes in the egg file. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary interface into all the egg data, and the root of the + * egg file structure. An EggData structure corresponds exactly with an egg + * file on the disk. + * + * The EggData class inherits from EggGroupNode its collection of children, + * which are accessed by using the EggData itself as an STL container with + * begin() and end() calls. The children of the EggData class are the + * toplevel nodes in the egg file. + */ class EXPCL_PANDAEGG EggData : public EggGroupNode { PUBLISHED: INLINE EggData(); diff --git a/panda/src/egg/eggExternalReference.I b/panda/src/egg/eggExternalReference.I index ff0f0233ed..6c5b32191b 100644 --- a/panda/src/egg/eggExternalReference.I +++ b/panda/src/egg/eggExternalReference.I @@ -1,14 +1,12 @@ -// Filename: eggExternalReference.I -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggExternalReference.I + * @author drose + * @date 1999-02-11 + */ diff --git a/panda/src/egg/eggExternalReference.cxx b/panda/src/egg/eggExternalReference.cxx index 8a9237e3ac..d70a5003db 100644 --- a/panda/src/egg/eggExternalReference.cxx +++ b/panda/src/egg/eggExternalReference.cxx @@ -1,16 +1,15 @@ -// Filename: eggExternalReference.cxx -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggExternalReference.cxx + * @author drose + * @date 1999-02-11 + */ #include "eggExternalReference.h" #include "eggMiscFuncs.h" @@ -21,43 +20,34 @@ TypeHandle EggExternalReference::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggExternalReference::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggExternalReference:: EggExternalReference(const string &node_name, const string &filename) : EggFilenameNode(node_name, filename) { } -//////////////////////////////////////////////////////////////////// -// Function: EggExternalReference::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggExternalReference:: EggExternalReference(const EggExternalReference ©) : EggFilenameNode(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggExternalReference::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggExternalReference &EggExternalReference:: operator = (const EggExternalReference ©) { EggFilenameNode::operator = (copy); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggExternalReference::write -// Access: Public, Virtual -// Description: Writes the reference to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the reference to the indicated output stream in Egg format. + */ void EggExternalReference:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -65,11 +55,9 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggExternalReference::get_default_extension -// Access: Public, Virtual -// Description: Returns the default extension for this filename type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default extension for this filename type. + */ string EggExternalReference:: get_default_extension() const { return string("egg"); diff --git a/panda/src/egg/eggExternalReference.h b/panda/src/egg/eggExternalReference.h index b5c944d96f..48ea165b9b 100644 --- a/panda/src/egg/eggExternalReference.h +++ b/panda/src/egg/eggExternalReference.h @@ -1,16 +1,15 @@ -// Filename: eggExternalReference.h -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggExternalReference.h + * @author drose + * @date 1999-02-11 + */ #ifndef EGGEXTERNALREFERENCE_H #define EGGEXTERNALREFERENCE_H @@ -19,11 +18,10 @@ #include "eggFilenameNode.h" -//////////////////////////////////////////////////////////////////// -// Class : EggExternalReference -// Description : Defines a reference to another egg file which should -// be inserted at this point. -//////////////////////////////////////////////////////////////////// +/** + * Defines a reference to another egg file which should be inserted at this + * point. + */ class EXPCL_PANDAEGG EggExternalReference : public EggFilenameNode { PUBLISHED: EggExternalReference(const string &node_name, const string &filename); diff --git a/panda/src/egg/eggFilenameNode.I b/panda/src/egg/eggFilenameNode.I index ba1777cd50..d2aecbb943 100644 --- a/panda/src/egg/eggFilenameNode.I +++ b/panda/src/egg/eggFilenameNode.I @@ -1,32 +1,26 @@ -// Filename: eggFilenameNode.I -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFilenameNode.I + * @author drose + * @date 1999-02-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::Default constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggFilenameNode:: EggFilenameNode() { } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggFilenameNode:: EggFilenameNode(const string &node_name, const Filename &filename) : EggNode(node_name), @@ -35,11 +29,9 @@ EggFilenameNode(const string &node_name, const Filename &filename) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggFilenameNode:: EggFilenameNode(const EggFilenameNode ©) : EggNode(copy), @@ -48,11 +40,9 @@ EggFilenameNode(const EggFilenameNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggFilenameNode &EggFilenameNode:: operator = (const EggFilenameNode ©) { EggNode::operator = (copy); @@ -61,53 +51,41 @@ operator = (const EggFilenameNode ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::get_filename -// Access: Public -// Description: Returns a nonmodifiable reference to the filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns a nonmodifiable reference to the filename. + */ INLINE const Filename &EggFilenameNode:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::set_filename -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggFilenameNode:: set_filename(const Filename &filename) { _filename = filename; _fullpath = filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::get_fullpath -// Access: Public -// Description: Returns the full pathname to the file, if it is -// known; otherwise, returns the same thing as -// get_filename(). -// -// This function simply returns whatever was set by the -// last call to set_fullpath(). This string is not -// written to the egg file; its main purpose is to -// record the full path to a filename (for instance, a -// texture filename) if it is known, for egg structures -// that are generated in-memory and then immediately -// converted to a scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to the file, if it is known; otherwise, returns + * the same thing as get_filename(). + * + * This function simply returns whatever was set by the last call to + * set_fullpath(). This string is not written to the egg file; its main + * purpose is to record the full path to a filename (for instance, a texture + * filename) if it is known, for egg structures that are generated in-memory + * and then immediately converted to a scene graph. + */ INLINE const Filename &EggFilenameNode:: get_fullpath() const { return _fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::set_fullpath -// Access: Public -// Description: Records the full pathname to the file, for the -// benefit of get_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Records the full pathname to the file, for the benefit of get_fullpath(). + */ INLINE void EggFilenameNode:: set_fullpath(const Filename &fullpath) { _fullpath = fullpath; diff --git a/panda/src/egg/eggFilenameNode.cxx b/panda/src/egg/eggFilenameNode.cxx index 3ab10d2554..b0a257c9a4 100644 --- a/panda/src/egg/eggFilenameNode.cxx +++ b/panda/src/egg/eggFilenameNode.cxx @@ -1,26 +1,23 @@ -// Filename: eggFilenameNode.cxx -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFilenameNode.cxx + * @author drose + * @date 1999-02-11 + */ #include "eggFilenameNode.h" TypeHandle EggFilenameNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggFilenameNode::get_default_extension -// Access: Public, Virtual -// Description: Returns the default extension for this filename type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default extension for this filename type. + */ string EggFilenameNode:: get_default_extension() const { return string(); diff --git a/panda/src/egg/eggFilenameNode.h b/panda/src/egg/eggFilenameNode.h index ef0b6637c0..d4ac734ce7 100644 --- a/panda/src/egg/eggFilenameNode.h +++ b/panda/src/egg/eggFilenameNode.h @@ -1,16 +1,15 @@ -// Filename: eggFilenameNode.h -// Created by: drose (11Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFilenameNode.h + * @author drose + * @date 1999-02-11 + */ #ifndef EGGFILENAMENODE_H #define EGGFILENAMENODE_H @@ -20,13 +19,11 @@ #include "eggNode.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : EggFilenameNode -// Description : This is an egg node that contains a filename. It -// references a physical file relative to the directory -// the egg file was loaded in. It is a base class for -// EggTexture and EggExternalReference. -//////////////////////////////////////////////////////////////////// +/** + * This is an egg node that contains a filename. It references a physical + * file relative to the directory the egg file was loaded in. It is a base + * class for EggTexture and EggExternalReference. + */ class EXPCL_PANDAEGG EggFilenameNode : public EggNode { PUBLISHED: INLINE EggFilenameNode(); diff --git a/panda/src/egg/eggGroup.I b/panda/src/egg/eggGroup.I index f88d7c40c0..d66de55e0f 100644 --- a/panda/src/egg/eggGroup.I +++ b/panda/src/egg/eggGroup.I @@ -1,52 +1,43 @@ -// Filename: eggGroup.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroup.I + * @author drose + * @date 1999-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_group_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::GroupType EggGroup:: get_group_type() const { return (GroupType)(_flags & F_group_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::is_instance_type -// Access: Published -// Description: Returns true if this group is an instance type node; -// i.e. it begins the root of a local coordinate space. -// This is not related to instancing (multiple copies of -// a node in a scene graph). -// -// This also includes the case of the node including a -// billboard flag without an explicit center, which -// implicitly makes the node behave like an instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this group is an instance type node; i.e. it begins the + * root of a local coordinate space. This is not related to instancing + * (multiple copies of a node in a scene graph). + * + * This also includes the case of the node including a billboard flag without + * an explicit center, which implicitly makes the node behave like an + * instance. + */ INLINE bool EggGroup:: is_instance_type() const { - return + return (get_group_type() == GT_instance) || (get_billboard_type() != BT_none && !has_billboard_center()); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_billboard_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_billboard_type(BillboardType type) { // Make sure the user didn't give us any stray bits. @@ -56,37 +47,29 @@ set_billboard_type(BillboardType type) { update_under(0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_billboard_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::BillboardType EggGroup:: get_billboard_type() const { return (BillboardType)(_flags & F_billboard_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_billboard_center -// Access: Published -// Description: Sets the point around which the billboard will -// rotate, if this node contains a billboard -// specification. -// -// If a billboard type is given but no billboard_center -// is specified, then the group node is treated as an -// , and the billboard rotates around the -// origin. If, however, a billboard_center is -// specified, then the group node is *not* treated as an -// , and the billboard rotates around the -// specified point. -// -// The point is in the same coordinate system as the -// vertices of this node: usually global, but possibly -// local if there is an somewhere above. -// Specifically, this is the coordinate system defined -// by get_vertex_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the point around which the billboard will rotate, if this node + * contains a billboard specification. + * + * If a billboard type is given but no billboard_center is specified, then the + * group node is treated as an , and the billboard rotates around + * the origin. If, however, a billboard_center is specified, then the group + * node is *not* treated as an , and the billboard rotates around + * the specified point. + * + * The point is in the same coordinate system as the vertices of this node: + * usually global, but possibly local if there is an somewhere + * above. Specifically, this is the coordinate system defined by + * get_vertex_frame(). + */ INLINE void EggGroup:: set_billboard_center(const LPoint3d &billboard_center) { _billboard_center = billboard_center; @@ -95,11 +78,9 @@ set_billboard_center(const LPoint3d &billboard_center) { update_under(0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_billboard_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_billboard_center() { _flags2 &= ~F2_billboard_center; @@ -107,32 +88,26 @@ clear_billboard_center() { update_under(0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_billboard_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_billboard_center() const { return (_flags2 & F2_billboard_center) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_billboard_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LPoint3d &EggGroup:: get_billboard_center() const { nassertr(has_billboard_center(), _billboard_center); return _billboard_center; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_cs_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_cs_type(CollisionSolidType type) { // Make sure the user didn't give us any stray bits. @@ -140,61 +115,49 @@ set_cs_type(CollisionSolidType type) { _flags = (_flags & ~F_cs_type) | type; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_cs_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::CollisionSolidType EggGroup:: get_cs_type() const { return (CollisionSolidType)(_flags & F_cs_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_collision_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_collision_name(const string &collision_name) { _collision_name = collision_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_collision_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_collision_name() { _collision_name = ""; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_collision_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_collision_name() const { return !_collision_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_collision_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &EggGroup:: get_collision_name() const { return _collision_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_collide_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_collide_flags(int flags) { // Make sure the user didn't give us any stray bits. @@ -202,21 +165,17 @@ set_collide_flags(int flags) { _flags = (_flags & ~F_collide_flags) | flags; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_collide_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::CollideFlags EggGroup:: get_collide_flags() const { return (EggGroup::CollideFlags)(_flags & F_collide_flags); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_dcs_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_dcs_type(EggGroup::DCSType type) { // Make sure the user didn't give us any stray bits. @@ -224,33 +183,27 @@ set_dcs_type(EggGroup::DCSType type) { _flags2 = (_flags2 & ~F2_dcs_type) | type; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_dcs_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::DCSType EggGroup:: get_dcs_type() const { return (DCSType)(_flags2 & F2_dcs_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_dcs_type -// Access: Published -// Description: Returns true if the specified DCS type is not -// DC_none and not DC_unspecified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the specified DCS type is not DC_none and not + * DC_unspecified. + */ INLINE bool EggGroup:: has_dcs_type() const { DCSType type = get_dcs_type(); return (type != DC_none && type != DC_unspecified); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_dart_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_dart_type(EggGroup::DartType type) { // Make sure the user didn't give us any stray bits. @@ -258,21 +211,17 @@ set_dart_type(EggGroup::DartType type) { _flags = (_flags & ~F_dart_type) | type; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_dart_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::DartType EggGroup:: get_dart_type() const { return (DartType)(_flags & F_dart_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_switch_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_switch_flag(bool flag) { if (flag) { @@ -282,82 +231,66 @@ set_switch_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_switch_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_switch_flag() const { return ((_flags & F_switch_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_switch_fps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_switch_fps(double fps) { _fps = fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_switch_fps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double EggGroup:: get_switch_fps() const { return _fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::add_object_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: add_object_type(const string &object_type) { _object_types.push_back(object_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_object_types -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_object_types() { _object_types.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_num_object_types -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int EggGroup:: get_num_object_types() const { return _object_types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_object_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE string EggGroup:: get_object_type(int index) const { nassertr(index >= 0 && index < (int)_object_types.size(), string()); return _object_types[index]; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_model_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_model_flag(bool flag) { if (flag) { @@ -367,21 +300,17 @@ set_model_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_model_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_model_flag() const { return ((_flags & F_model_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_texlist_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_texlist_flag(bool flag) { if (flag) { @@ -391,21 +320,17 @@ set_texlist_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_texlist_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_texlist_flag() const { return ((_flags & F_texlist_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_nofog_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_nofog_flag(bool flag) { if (flag) { @@ -415,21 +340,17 @@ set_nofog_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_nofog_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_nofog_flag() const { return ((_flags & F_nofog_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_decal_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_decal_flag(bool flag) { if (flag) { @@ -439,21 +360,17 @@ set_decal_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_decal_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_decal_flag() const { return ((_flags & F_decal_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_direct_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_direct_flag(bool flag) { if (flag) { @@ -463,22 +380,18 @@ set_direct_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_direct_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_direct_flag() const { return ((_flags & F_direct_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_portal_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_portal_flag(bool flag) { if (flag) { @@ -488,21 +401,17 @@ set_portal_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_portal_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_portal_flag() const { return ((_flags2 & F2_portal_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_occluder_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_occluder_flag(bool flag) { if (flag) { @@ -512,21 +421,17 @@ set_occluder_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_occluder_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_occluder_flag() const { return ((_flags2 & F2_occluder_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_polylight_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_polylight_flag(bool flag) { if (flag) { @@ -536,22 +441,18 @@ set_polylight_flag(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_polylight_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_polylight_flag() const { return ((_flags2 & F2_polylight_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_indexed_flag -// Access: Published -// Description: If this flag is true, geometry at this node and below -// will be generated as indexed geometry. -//////////////////////////////////////////////////////////////////// +/** + * If this flag is true, geometry at this node and below will be generated as + * indexed geometry. + */ INLINE void EggGroup:: set_indexed_flag(bool flag) { if (flag) { @@ -562,336 +463,269 @@ set_indexed_flag(bool flag) { _flags2 |= F2_has_indexed_flag; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_indexed_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_indexed_flag() { _flags2 &= ~(F2_indexed_flag | F2_has_indexed_flag); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_indexed_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_indexed_flag() const { return (_flags2 & F2_has_indexed_flag) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_indexed_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: get_indexed_flag() const { nassertr(has_indexed_flag(), false); return ((_flags2 & F2_indexed_flag) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_collide_mask(CollideMask mask) { _collide_mask = mask; _flags2 |= F2_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_collide_mask() { _flags2 &= ~F2_collide_mask; _collide_mask = CollideMask::all_off(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_collide_mask() const { return (_flags2 & F2_collide_mask) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollideMask EggGroup:: get_collide_mask() const { return _collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_from_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_from_collide_mask(CollideMask mask) { _from_collide_mask = mask; _flags2 |= F2_from_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_from_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_from_collide_mask() { _flags2 &= ~F2_from_collide_mask; _from_collide_mask = CollideMask::all_off(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_from_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_from_collide_mask() const { return (_flags2 & F2_from_collide_mask) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_from_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollideMask EggGroup:: get_from_collide_mask() const { return _from_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_into_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_into_collide_mask(CollideMask mask) { _into_collide_mask = mask; _flags2 |= F2_into_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_into_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_into_collide_mask() { _flags2 &= ~F2_into_collide_mask; _into_collide_mask = CollideMask::all_off(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_into_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_into_collide_mask() const { return (_flags2 & F2_into_collide_mask) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_into_collide_mask -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CollideMask EggGroup:: get_into_collide_mask() const { return _into_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_blend_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_blend_mode(EggGroup::BlendMode blend_mode) { _blend_mode = blend_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_blend_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::BlendMode EggGroup:: get_blend_mode() const { return _blend_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_blend_operand_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_blend_operand_a(EggGroup::BlendOperand blend_operand_a) { _blend_operand_a = blend_operand_a; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_blend_operand_a -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::BlendOperand EggGroup:: get_blend_operand_a() const { return _blend_operand_a; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_blend_operand_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_blend_operand_b(EggGroup::BlendOperand blend_operand_b) { _blend_operand_b = blend_operand_b; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_blend_operand_b -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroup::BlendOperand EggGroup:: get_blend_operand_b() const { return _blend_operand_b; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_blend_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_blend_color(const LColor &blend_color) { _blend_color = blend_color; _flags2 |= F2_has_blend_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_blend_color -// Access: Published -// Description: Removes the blend color specification. -//////////////////////////////////////////////////////////////////// +/** + * Removes the blend color specification. + */ INLINE void EggGroup:: clear_blend_color() { _blend_color = LColor::zero(); _flags2 &= ~F2_has_blend_color; } - -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_blend_color -// Access: Published -// Description: Returns true if the blend color has been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// + +/** + * Returns true if the blend color has been specified, false otherwise. + */ INLINE bool EggGroup:: has_blend_color() const { return (_flags2 & F2_has_blend_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_blend_color -// Access: Published -// Description: Returns the blend color if one has been specified, or -// (0, 0, 0, 0) if one has not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blend color if one has been specified, or (0, 0, 0, 0) if one + * has not. + */ INLINE const LColor &EggGroup:: get_blend_color() const { return _blend_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_lod -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: set_lod(const EggSwitchCondition &lod) { _lod = lod.make_copy(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_lod -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggGroup:: clear_lod() { _lod = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_lod -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggGroup:: has_lod() const { return (_lod != (EggSwitchCondition *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_lod -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const EggSwitchCondition &EggGroup:: get_lod() const { return *_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_tag -// Access: Published -// Description: Associates a user-defined value with a user-defined -// key which is stored on the node. This value has no -// meaning to Panda; but it is stored indefinitely on -// the node until it is requested again. This value -// will be copied to the PandaNode that is created for -// this particular EggGroup if the egg file is loaded as -// a scene. -// -// Each unique key stores a different string value. -// There is no effective limit on the number of -// different keys that may be stored or on the length of -// any one key's value. -//////////////////////////////////////////////////////////////////// +/** + * Associates a user-defined value with a user-defined key which is stored on + * the node. This value has no meaning to Panda; but it is stored + * indefinitely on the node until it is requested again. This value will be + * copied to the PandaNode that is created for this particular EggGroup if the + * egg file is loaded as a scene. + * + * Each unique key stores a different string value. There is no effective + * limit on the number of different keys that may be stored or on the length + * of any one key's value. + */ INLINE void EggGroup:: set_tag(const string &key, const string &value) { _tag_data[key] = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_tag -// Access: Published -// Description: Retrieves the user-defined value that was previously -// set on this node for the particular key, if any. If -// no value has been previously set, returns the empty -// string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the user-defined value that was previously set on this node for + * the particular key, if any. If no value has been previously set, returns + * the empty string. + */ INLINE string EggGroup:: get_tag(const string &key) const { TagData::const_iterator ti; @@ -902,13 +736,11 @@ get_tag(const string &key) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_tag -// Access: Published -// Description: Returns true if a value has been defined on this node -// for the particular key (even if that value is the -// empty string), or false if no value has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value has been defined on this node for the particular + * key (even if that value is the empty string), or false if no value has been + * set. + */ INLINE bool EggGroup:: has_tag(const string &key) const { TagData::const_iterator ti; @@ -916,161 +748,121 @@ has_tag(const string &key) const { return (ti != _tag_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_tag -// Access: Published -// Description: Removes the value defined for this key on this -// particular node. After a call to clear_tag(), -// has_tag() will return false for the indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Removes the value defined for this key on this particular node. After a + * call to clear_tag(), has_tag() will return false for the indicated key. + */ INLINE void EggGroup:: clear_tag(const string &key) { _tag_data.erase(key); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_default_pose -// Access: Published -// Description: Returns a read-only accessor to the initial pose -// transform. This is the entry for a -// Joint, and defines only the initial transform pose -// for the unanimated joint; it has nothing to do with -// the group's entry, which defines the -// (eventual) space of the group's vertices. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only accessor to the initial pose transform. This is the + * entry for a Joint, and defines only the initial transform + * pose for the unanimated joint; it has nothing to do with the group's + * entry, which defines the (eventual) space of the group's + * vertices. + */ INLINE const EggTransform &EggGroup:: get_default_pose() const { return _default_pose; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::modify_default_pose -// Access: Published -// Description: Returns a writable accessor to the initial pose -// transform. This is the entry for a -// Joint, and defines only the initial transform pose -// for the unanimated joint; it has nothing to do with -// the group's entry, which defines the -// (eventual) space of the group's vertices. -//////////////////////////////////////////////////////////////////// +/** + * Returns a writable accessor to the initial pose transform. This is the + * entry for a Joint, and defines only the initial transform + * pose for the unanimated joint; it has nothing to do with the group's + * entry, which defines the (eventual) space of the group's + * vertices. + */ INLINE EggTransform &EggGroup:: modify_default_pose() { return _default_pose; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_default_pose -// Access: Published -// Description: Replaces the initial pose transform. This is the -// entry for a Joint, and defines only the -// initial transform pose for the unanimated joint; it -// has nothing to do with the group's entry, -// which defines the (eventual) space of the group's -// vertices. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the initial pose transform. This is the entry for a + * Joint, and defines only the initial transform pose for the unanimated + * joint; it has nothing to do with the group's entry, which + * defines the (eventual) space of the group's vertices. + */ INLINE void EggGroup:: set_default_pose(const EggTransform &transform) { _default_pose = transform; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_default_pose -// Access: Published -// Description: Removes the initial pose transform. See -// set_default_pose(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the initial pose transform. See set_default_pose(). + */ INLINE void EggGroup:: clear_default_pose() { _default_pose.clear_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::tag_begin -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// tag_end(), be used to traverse the entire set of -// tag keys. Each iterator returns a pair. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with tag_end(), be used to + * traverse the entire set of tag keys. Each iterator returns a pair. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::TagData::const_iterator EggGroup:: tag_begin() const { return _tag_data.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::tag_end -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// tag_begin(), be used to traverse the entire set of -// tag keys. Each iterator returns a pair. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with tag_begin(), be used to + * traverse the entire set of tag keys. Each iterator returns a pair. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::TagData::const_iterator EggGroup:: tag_end() const { return _tag_data.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::tag_size -// Access: Public -// Description: Returns the number of elements between tag_begin() -// and tag_end(). -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements between tag_begin() and tag_end(). + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::TagData::size_type EggGroup:: tag_size() const { return _tag_data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::vref_begin -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// vref_end(), be used to traverse the entire set of -// referenced vertices. Each iterator returns a -// pair. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with vref_end(), be used to + * traverse the entire set of referenced vertices. Each iterator returns a + * pair. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::VertexRef::const_iterator EggGroup:: vref_begin() const { return _vref.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::vref_end -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// vref_begin(), be used to traverse the entire set of -// referenced vertices. Each iterator returns a -// pair. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with vref_begin(), be used to + * traverse the entire set of referenced vertices. Each iterator returns a + * pair. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::VertexRef::const_iterator EggGroup:: vref_end() const { return _vref.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::vref_size -// Access: Published -// Description: Returns the number of elements between vref_begin() -// and vref_end(). -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements between vref_begin() and vref_end(). + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggGroup::VertexRef::size_type EggGroup:: vref_size() const { return _vref.size(); diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 451f6d72b7..2377006bab 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -1,16 +1,15 @@ -// Filename: eggGroup.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroup.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggGroup.h" #include "eggMiscFuncs.h" @@ -26,11 +25,9 @@ TypeHandle EggGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroup:: EggGroup(const string &name) : EggGroupNode(name) { _flags = 0; @@ -46,21 +43,17 @@ EggGroup(const string &name) : EggGroupNode(name) { _r_speed = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroup:: EggGroup(const EggGroup ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroup &EggGroup:: operator = (const EggGroup ©) { EggTransform::operator = (copy); @@ -88,22 +81,21 @@ operator = (const EggGroup ©) { unref_all_vertices(); _vref = copy._vref; - // We must walk through the vertex ref list, and flag each vertex as - // now reffed by this group. + // We must walk through the vertex ref list, and flag each vertex as now + // reffed by this group. VertexRef::iterator vri; for (vri = _vref.begin(); vri != _vref.end(); ++vri) { EggVertex *vert = (*vri).first; bool inserted = vert->_gref.insert(this).second; - // Did the group not exist previously in the vertex's gref list? - // If it was there already, we must be out of sync between - // vertices and groups. + // Did the group not exist previously in the vertex's gref list? If it + // was there already, we must be out of sync between vertices and groups. nassertr(inserted, *this); } - // These must be down here, because the EggNode assignment operator - // will force an update_under(). Therefore, we can't call it until - // all the attributes that affect adjust_under() are in place. + // These must be down here, because the EggNode assignment operator will + // force an update_under(). Therefore, we can't call it until all the + // attributes that affect adjust_under() are in place. EggGroupNode::operator = (copy); EggRenderMode::operator = (copy); @@ -111,48 +103,41 @@ operator = (const EggGroup ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroup:: ~EggGroup() { unref_all_vertices(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_group_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggGroup:: set_group_type(GroupType type) { if (type != get_group_type()) { #ifndef NDEBUG if (type != GT_instance) { - // Only valid to change to a non-instance type if we have no - // group refs. + // Only valid to change to a non-instance type if we have no group refs. nassertv(_group_refs.empty()); } -#endif +#endif // Make sure the user didn't give us any stray bits. nassertv((type & ~F_group_type)==0); _flags = (_flags & ~F_group_type) | type; - // Now we might have changed the type to or from an instance node, - // so we have to recompute the under_flags. + // Now we might have changed the type to or from an instance node, so we + // have to recompute the under_flags. update_under(0); } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::has_object_type -// Access: Published -// Description: Returns true if the indicated object type has been -// added to the group, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated object type has been added to the group, or + * false otherwise. + */ bool EggGroup:: has_object_type(const string &object_type) const { vector_string::const_iterator oi; @@ -164,14 +149,11 @@ has_object_type(const string &object_type) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::remove_object_type -// Access: Published -// Description: Removes the first instance of the indicated object -// type from the group if it is present. Returns true -// if the object type was found and removed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the first instance of the indicated object type from the group if + * it is present. Returns true if the object type was found and removed, + * false otherwise. + */ bool EggGroup:: remove_object_type(const string &object_type) { vector_string::iterator oi; @@ -184,12 +166,10 @@ remove_object_type(const string &object_type) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write -// Access: Published, Virtual -// Description: Writes the group and all of its children to the -// indicated output stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the group and all of its children to the indicated output stream in + * Egg format. + */ void EggGroup:: write(ostream &out, int indent_level) const { test_under_integrity(); @@ -235,13 +215,13 @@ write(ostream &out, int indent_level) const { } if (get_scroll_u() != 0) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " scroll_u { " << get_scroll_u() << " }\n"; } if (get_scroll_v() != 0) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " scroll_v { " << get_scroll_v() << " }\n"; } @@ -253,7 +233,7 @@ write(ostream &out, int indent_level) const { } if (get_scroll_r() != 0) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " scroll_r { " << get_scroll_r() << " }\n"; } @@ -276,7 +256,7 @@ write(ostream &out, int indent_level) const { } if (has_indexed_flag()) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " indexed { " << get_indexed_flag() << " }\n"; } @@ -315,20 +295,18 @@ write(ostream &out, int indent_level) const { } // We have to write the children nodes before we write the vertex - // references, since we might be referencing a vertex that's defined - // in one of those children nodes! + // references, since we might be referencing a vertex that's defined in one + // of those children nodes! EggGroupNode::write(out, indent_level + 2); write_vertex_ref(out, indent_level + 2); indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_billboard_flags -// Access: Published -// Description: Writes just the entry and related fields to -// the indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the entry and related fields to the indicated + * ostream. + */ void EggGroup:: write_billboard_flags(ostream &out, int indent_level) const { if (get_billboard_type() != BT_none) { @@ -342,12 +320,10 @@ write_billboard_flags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_collide_flags -// Access: Published -// Description: Writes just the entry and related fields to -// the indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the entry and related fields to the indicated + * ostream. + */ void EggGroup:: write_collide_flags(ostream &out, int indent_level) const { if (get_cs_type() != CST_none) { @@ -384,16 +360,13 @@ write_collide_flags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_model_flags -// Access: Published -// Description: Writes the flag and related flags to the -// indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the flag and related flags to the indicated ostream. + */ void EggGroup:: write_model_flags(ostream &out, int indent_level) const { if (get_dcs_type() != DC_unspecified) { - indent(out, indent_level) + indent(out, indent_level) << " { " << get_dcs_type() << " }\n"; } @@ -415,12 +388,9 @@ write_model_flags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_switch_flags -// Access: Published -// Description: Writes the flag and related flags to the -// indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the flag and related flags to the indicated ostream. + */ void EggGroup:: write_switch_flags(ostream &out, int indent_level) const { if (get_switch_flag()) { @@ -432,12 +402,9 @@ write_switch_flags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_object_types -// Access: Published -// Description: Writes just the entries, if any, to the -// indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the entries, if any, to the indicated ostream. + */ void EggGroup:: write_object_types(ostream &out, int indent_level) const { vector_string::const_iterator oi; @@ -448,11 +415,9 @@ write_object_types(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_decal_flags -// Access: Published -// Description: Writes the flags related to decaling, if any. -//////////////////////////////////////////////////////////////////// +/** + * Writes the flags related to decaling, if any. + */ void EggGroup:: write_decal_flags(ostream &out, int indent_level) const { if (get_decal_flag()) { @@ -460,12 +425,9 @@ write_decal_flags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_tags -// Access: Published -// Description: Writes just the entries, if any, to the -// indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the entries, if any, to the indicated ostream. + */ void EggGroup:: write_tags(ostream &out, int indent_level) const { TagData::const_iterator ti; @@ -480,12 +442,10 @@ write_tags(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_render_mode -// Access: Published -// Description: Writes the flags inherited from EggRenderMode and -// similar flags that control obscure render effects. -//////////////////////////////////////////////////////////////////// +/** + * Writes the flags inherited from EggRenderMode and similar flags that + * control obscure render effects. + */ void EggGroup:: write_render_mode(ostream &out, int indent_level) const { EggRenderMode::write(out, indent_level); @@ -495,29 +455,22 @@ write_render_mode(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::is_joint -// Access: Published, Virtual -// Description: Returns true if this particular node represents a -// entry or not. This is a handy thing to know -// since Joints are sorted to the end of their sibling -// list when writing an egg file. See -// EggGroupNode::write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular node represents a entry or not. + * This is a handy thing to know since Joints are sorted to the end of their + * sibling list when writing an egg file. See EggGroupNode::write(). + */ bool EggGroup:: is_joint() const { return (get_group_type() == GT_joint); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_alpha_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has an alpha_mode other than -// AM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has an alpha_mode + * other than AM_unspecified. Returns a valid EggRenderMode pointer if one is + * found, or NULL otherwise. + */ EggRenderMode *EggGroup:: determine_alpha_mode() { if (get_alpha_mode() != AM_unspecified) { @@ -526,15 +479,12 @@ determine_alpha_mode() { return EggGroupNode::determine_alpha_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_depth_write_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a depth_write_mode other -// than DWM_unspecified. Returns a valid EggRenderMode -// pointer if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a + * depth_write_mode other than DWM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggGroup:: determine_depth_write_mode() { if (get_depth_write_mode() != DWM_unspecified) { @@ -543,15 +493,12 @@ determine_depth_write_mode() { return EggGroupNode::determine_depth_write_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_depth_test_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a depth_test_mode other -// than DTM_unspecified. Returns a valid EggRenderMode -// pointer if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a + * depth_test_mode other than DTM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggGroup:: determine_depth_test_mode() { if (get_depth_test_mode() != DTM_unspecified) { @@ -560,15 +507,12 @@ determine_depth_test_mode() { return EggGroupNode::determine_depth_test_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_visibility_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a visibility_mode other -// than VM_unspecified. Returns a valid EggRenderMode -// pointer if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a + * visibility_mode other than VM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggGroup:: determine_visibility_mode() { if (get_visibility_mode() != VM_unspecified) { @@ -577,15 +521,12 @@ determine_visibility_mode() { return EggGroupNode::determine_visibility_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_depth_offset -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a depth_offset specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a depth_offset + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggGroup:: determine_depth_offset() { if (has_depth_offset()) { @@ -594,15 +535,12 @@ determine_depth_offset() { return EggGroupNode::determine_depth_offset(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_draw_order -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a draw_order specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a draw_order + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggGroup:: determine_draw_order() { if (has_draw_order()) { @@ -611,15 +549,12 @@ determine_draw_order() { return EggGroupNode::determine_draw_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_bin -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this group that has a bin specified. Returns a -// valid EggRenderMode pointer if one is found, or NULL -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this group that has a bin + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggGroup:: determine_bin() { if (has_bin()) { @@ -628,17 +563,14 @@ determine_bin() { return EggGroupNode::determine_bin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_indexed -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// at this level or above that has the "indexed" scalar -// set. Returns the value of the indexed scalar if it -// is found, or false if it is not. -// -// In other words, returns true if the "indexed" flag is -// in effect for the indicated node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup at this level or above + * that has the "indexed" scalar set. Returns the value of the indexed scalar + * if it is found, or false if it is not. + * + * In other words, returns true if the "indexed" flag is in effect for the + * indicated node, false otherwise. + */ bool EggGroup:: determine_indexed() { if (has_indexed_flag()) { @@ -647,17 +579,14 @@ determine_indexed() { return EggGroupNode::determine_indexed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::determine_decal -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// at this level or above that has the "decal" flag -// set. Returns the value of the decal flag if it -// is found, or false if it is not. -// -// In other words, returns true if the "decal" flag is -// in effect for the indicated node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup at this level or above + * that has the "decal" flag set. Returns the value of the decal flag if it + * is found, or false if it is not. + * + * In other words, returns true if the "decal" flag is in effect for the + * indicated node, false otherwise. + */ bool EggGroup:: determine_decal() { if (get_decal_flag()) { @@ -666,21 +595,17 @@ determine_decal() { return EggGroupNode::determine_decal(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::ref_vertex -// Access: Published -// Description: Adds the vertex to the set of those referenced by the -// group, at the indicated membership level. If the -// vertex is already being referenced, increases the -// membership amount by the indicated amount. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vertex to the set of those referenced by the group, at the + * indicated membership level. If the vertex is already being referenced, + * increases the membership amount by the indicated amount. + */ void EggGroup:: ref_vertex(EggVertex *vert, double membership) { VertexRef::iterator vri = _vref.find(vert); if (vri != _vref.end()) { - // The vertex was already being reffed; increment its membership - // amount. + // The vertex was already being reffed; increment its membership amount. (*vri).second += membership; // If that takes us down to zero, go ahead and unref the vertex. @@ -694,22 +619,19 @@ ref_vertex(EggVertex *vert, double membership) { _vref[vert] = membership; bool inserted = vert->_gref.insert(this).second; - // Did the group not exist previously in the vertex's gref list? - // If it was there already, we must be out of sync between - // vertices and groups. + // Did the group not exist previously in the vertex's gref list? If it + // was there already, we must be out of sync between vertices and + // groups. nassertv(inserted); } } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::unref_vertex -// Access: Published -// Description: Removes the vertex from the set of those referenced -// by the group. Does nothing if the vertex is not -// already reffed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the vertex from the set of those referenced by the group. Does + * nothing if the vertex is not already reffed. + */ void EggGroup:: unref_vertex(EggVertex *vert) { VertexRef::iterator vri = _vref.find(vert); @@ -717,17 +639,15 @@ unref_vertex(EggVertex *vert) { if (vri != _vref.end()) { _vref.erase(vri); int count = vert->_gref.erase(this); - // Did the group exist in the vertex's gref list? If it didn't, - // we must be out of sync between vertices and groups. + // Did the group exist in the vertex's gref list? If it didn't, we must + // be out of sync between vertices and groups. nassertv(count == 1); } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::unref_all_vertices -// Access: Published -// Description: Removes all vertices from the reference list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices from the reference list. + */ void EggGroup:: unref_all_vertices() { // We must walk through the vertex ref list, and flag each vertex as @@ -736,8 +656,8 @@ unref_all_vertices() { for (vri = _vref.begin(); vri != _vref.end(); ++vri) { EggVertex *vert = (*vri).first; int count = vert->_gref.erase(this); - // Did the group exist in the vertex's gref list? If it didn't, - // we must be out of sync between vertices and groups. + // Did the group exist in the vertex's gref list? If it didn't, we must + // be out of sync between vertices and groups. nassertv(count == 1); } @@ -745,13 +665,10 @@ unref_all_vertices() { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_vertex_membership -// Access: Published -// Description: Returns the amount of membership of the indicated -// vertex in this group. If the vertex is not reffed by -// the group, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of membership of the indicated vertex in this group. If + * the vertex is not reffed by the group, returns 0. + */ double EggGroup:: get_vertex_membership(const EggVertex *vert) const { VertexRef::const_iterator vri = _vref.find((EggVertex *)vert); @@ -763,12 +680,10 @@ get_vertex_membership(const EggVertex *vert) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::set_vertex_membership -// Access: Published -// Description: Explicitly sets the net membership of the indicated -// vertex in this group to the given value. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the net membership of the indicated vertex in this group to + * the given value. + */ void EggGroup:: set_vertex_membership(EggVertex *vert, double membership) { if (membership == 0.0) { @@ -779,8 +694,7 @@ set_vertex_membership(EggVertex *vert, double membership) { VertexRef::iterator vri = _vref.find(vert); if (vri != _vref.end()) { - // The vertex was already being reffed; just change its membership - // amount. + // The vertex was already being reffed; just change its membership amount. (*vri).second = membership; } else { @@ -788,21 +702,17 @@ set_vertex_membership(EggVertex *vert, double membership) { _vref[vert] = membership; bool inserted = vert->_gref.insert(this).second; - // Did the group not exist previously in the vertex's gref list? - // If it was there already, we must be out of sync between - // vertices and groups. + // Did the group not exist previously in the vertex's gref list? If it + // was there already, we must be out of sync between vertices and groups. nassertv(inserted); } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::steal_vrefs -// Access: Published -// Description: Moves all of the vertex references from the indicated -// other group into this one. If a given vertex was -// previously shared by both groups, the relative -// memberships will be summed. -//////////////////////////////////////////////////////////////////// +/** + * Moves all of the vertex references from the indicated other group into this + * one. If a given vertex was previously shared by both groups, the relative + * memberships will be summed. + */ void EggGroup:: steal_vrefs(EggGroup *other) { nassertv(other != this); @@ -818,12 +728,10 @@ steal_vrefs(EggGroup *other) { #ifdef _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::test_vref_integrity -// Access: Published -// Description: Verifies that each vertex in the group exists and -// that it knows it is referenced by the group. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that each vertex in the group exists and that it knows it is + * referenced by the group. + */ void EggGroup:: test_vref_integrity() const { test_ref_count_integrity(); @@ -839,61 +747,47 @@ test_vref_integrity() const { #endif // _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::add_group_ref -// Access: Published -// Description: Adds a new entry to the group. This declares -// an internal reference to another node, and is used to -// implement scene-graph instancing; it is only valid if -// the group_type is GT_instance. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new entry to the group. This declares an internal reference + * to another node, and is used to implement scene-graph instancing; it is + * only valid if the group_type is GT_instance. + */ void EggGroup:: add_group_ref(EggGroup *group) { nassertv(get_group_type() == GT_instance); _group_refs.push_back(group); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_num_group_refs -// Access: Published -// Description: Returns the number of entries within this -// group. See add_group_ref(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries within this group. See + * add_group_ref(). + */ int EggGroup:: get_num_group_refs() const { return _group_refs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::get_group_ref -// Access: Published -// Description: Returns the nth entry within this group. See -// add_group_ref(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth entry within this group. See add_group_ref(). + */ EggGroup *EggGroup:: get_group_ref(int n) const { nassertr(n >= 0 && n < (int)_group_refs.size(), NULL); return _group_refs[n]; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::remove_group_ref -// Access: Published -// Description: Removes the nth entry within this group. See -// add_group_ref(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth entry within this group. See add_group_ref(). + */ void EggGroup:: remove_group_ref(int n) { nassertv(n >= 0 && n < (int)_group_refs.size()); _group_refs.erase(_group_refs.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::clear_group_refs -// Access: Published -// Description: Removes all of the entries within this group. -// See add_group_ref(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the entries within this group. See add_group_ref(). + */ void EggGroup:: clear_group_refs() { _group_refs.clear(); @@ -901,13 +795,11 @@ clear_group_refs() { -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_group_type -// Access: Published, Static -// Description: Returns the GroupType value associated with the given -// string representation, or GT_invalid if the string -// does not match any known GroupType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GroupType value associated with the given string + * representation, or GT_invalid if the string does not match any known + * GroupType value. + */ EggGroup::GroupType EggGroup:: string_group_type(const string &strval) { if (cmp_nocase_uh(strval, "group") == 0) { @@ -921,13 +813,10 @@ string_group_type(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_dart_type -// Access: Published, Static -// Description: Returns the DartType value associated with the given -// string representation, or DT_none if the string -// does not match any known DartType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DartType value associated with the given string representation, + * or DT_none if the string does not match any known DartType value. + */ EggGroup::DartType EggGroup:: string_dart_type(const string &strval) { if (cmp_nocase_uh(strval, "sync") == 0) { @@ -943,13 +832,10 @@ string_dart_type(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_dcs_type -// Access: Published, Static -// Description: Returns the DCSType value associated with the given -// string representation, or DC_unspecified if the -// string does not match any known DCSType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DCSType value associated with the given string representation, + * or DC_unspecified if the string does not match any known DCSType value. + */ EggGroup::DCSType EggGroup:: string_dcs_type(const string &strval) { if (cmp_nocase_uh(strval, "none") == 0) { @@ -967,13 +853,11 @@ string_dcs_type(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_billboard_type -// Access: Published, Static -// Description: Returns the BillboardType value associated with the -// given string representation, or BT_none if the string -// does not match any known BillboardType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BillboardType value associated with the given string + * representation, or BT_none if the string does not match any known + * BillboardType value. + */ EggGroup::BillboardType EggGroup:: string_billboard_type(const string &strval) { if (cmp_nocase_uh(strval, "axis") == 0) { @@ -989,13 +873,11 @@ string_billboard_type(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_cs_type -// Access: Published, Static -// Description: Returns the CollisionSolidType value associated with the -// given string representation, or CST_none if the string -// does not match any known CollisionSolidType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CollisionSolidType value associated with the given string + * representation, or CST_none if the string does not match any known + * CollisionSolidType value. + */ EggGroup::CollisionSolidType EggGroup:: string_cs_type(const string &strval) { if (cmp_nocase_uh(strval, "plane") == 0) { @@ -1021,15 +903,12 @@ string_cs_type(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_collide_flags -// Access: Published, Static -// Description: Returns the CollideFlags value associated with the -// given string representation, or CF_none if the string -// does not match any known CollideFlags value. This -// only recognizes a single keyword; it does not attempt -// to parse a string of keywords. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CollideFlags value associated with the given string + * representation, or CF_none if the string does not match any known + * CollideFlags value. This only recognizes a single keyword; it does not + * attempt to parse a string of keywords. + */ EggGroup::CollideFlags EggGroup:: string_collide_flags(const string &strval) { if (cmp_nocase_uh(strval, "intangible") == 0) { @@ -1053,13 +932,11 @@ string_collide_flags(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_blend_mode -// Access: Published, Static -// Description: Returns the BlendMode value associated with the -// given string representation, or BM_none if the string -// does not match any known BlendMode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BlendMode value associated with the given string + * representation, or BM_none if the string does not match any known + * BlendMode. + */ EggGroup::BlendMode EggGroup:: string_blend_mode(const string &strval) { if (cmp_nocase_uh(strval, "none") == 0) { @@ -1079,13 +956,11 @@ string_blend_mode(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::string_blend_operand -// Access: Published, Static -// Description: Returns the BlendOperand value associated with the -// given string representation, or BO_none if the string -// does not match any known BlendOperand. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BlendOperand value associated with the given string + * representation, or BO_none if the string does not match any known + * BlendOperand. + */ EggGroup::BlendOperand EggGroup:: string_blend_operand(const string &strval) { if (cmp_nocase_uh(strval, "zero") == 0) { @@ -1131,32 +1006,27 @@ string_blend_operand(const string &strval) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::as_transform -// Access: Public, Virtual -// Description: Returns this object cross-cast to an EggTransform -// pointer, if it inherits from EggTransform, or NULL if -// it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object cross-cast to an EggTransform pointer, if it inherits + * from EggTransform, or NULL if it does not. + */ EggTransform *EggGroup:: as_transform() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::write_vertex_ref -// Access: Protected -// Description: Writes out the vertex ref component of the group body -// only. This may consist of a number of -// entries, each with its own membership value. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the vertex ref component of the group body only. This may + * consist of a number of entries, each with its own membership + * value. + */ void EggGroup:: write_vertex_ref(ostream &out, int indent_level) const { - // We want to put the vertices together into groups first by vertex - // pool, then by membership value. Each of these groups becomes a - // separate VertexRef entry. Within each group, we'll sort the - // vertices by index number. + // We want to put the vertices together into groups first by vertex pool, + // then by membership value. Each of these groups becomes a separate + // VertexRef entry. Within each group, we'll sort the vertices by index + // number. typedef pset Indices; typedef pmap Memberships; @@ -1177,8 +1047,8 @@ write_vertex_ref(ostream &out, int indent_level) const { _entries[vert->get_pool()][membership].insert(vert->get_index()); } - // Now that we've reordered them, we can simply traverse the entries - // and write them out. + // Now that we've reordered them, we can simply traverse the entries and + // write them out. Pools::const_iterator pi; for (pi = _entries.begin(); pi != _entries.end(); ++pi) { EggVertexPool *pool = (*pi).first; @@ -1193,8 +1063,8 @@ write_vertex_ref(ostream &out, int indent_level) const { write_long_list(out, indent_level+2, indices.begin(), indices.end(), "", "", 72); - // If all vrefs in this group have membership of 1, don't bother - // to write out the membership scalar. + // If all vrefs in this group have membership of 1, don't bother to + // write out the membership scalar. if (!all_membership_one) { indent(out, indent_level + 2) << " membership { " << membership << " }\n"; @@ -1212,38 +1082,31 @@ write_vertex_ref(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::egg_start_parse_body -// Access: Protected, Virtual -// Description: This function is called within parse_egg(). It -// should call the appropriate function on the lexer to -// initialize the parser into the state associated with -// this object. If the object cannot be parsed into -// directly, it should return false. -//////////////////////////////////////////////////////////////////// +/** + * This function is called within parse_egg(). It should call the appropriate + * function on the lexer to initialize the parser into the state associated + * with this object. If the object cannot be parsed into directly, it should + * return false. + */ bool EggGroup:: egg_start_parse_body() { egg_start_group_body(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::adjust_under -// Access: Protected, Virtual -// Description: This is called within update_under() after all the -// various under settings have been inherited directly -// from the parent node. It is responsible for -// adjusting these settings to reflect states local to -// the current node; for instance, an node -// will force the UF_under_instance bit on. -//////////////////////////////////////////////////////////////////// +/** + * This is called within update_under() after all the various under settings + * have been inherited directly from the parent node. It is responsible for + * adjusting these settings to reflect states local to the current node; for + * instance, an node will force the UF_under_instance bit on. + */ void EggGroup:: adjust_under() { // If we have our own transform, it carries forward. - // As of 4/18/01, this now also affects the local_coord flag, below. - // This means that a entry within an node - // transforms the instance itself. + // As of 41801, this now also affects the local_coord flag, below. This + // means that a entry within an node transforms the + // instance itself. if (has_transform()) { _under_flags |= UF_under_transform; @@ -1271,15 +1134,14 @@ adjust_under() { if (is_instance_type()) { _under_flags |= UF_under_instance; if (_under_flags & UF_under_transform) { - // If we've reached an instance node and we're under a - // transform, that means we've just defined a local coordinate - // system. + // If we've reached an instance node and we're under a transform, that + // means we've just defined a local coordinate system. _under_flags |= UF_local_coord; } - // An instance node means that from this point and below, vertices - // are defined relative to this node. Thus, the node frame - // becomes the vertex frame. + // An instance node means that from this point and below, vertices are + // defined relative to this node. Thus, the node frame becomes the vertex + // frame. _vertex_frame = _node_frame; _vertex_frame_inv = _node_frame_inv; _vertex_to_node = NULL; @@ -1287,37 +1149,31 @@ adjust_under() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggGroup:: r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) { if (has_transform() || get_group_type() == GT_joint) { - // Since we want to apply this transform to all matrices, - // including nested matrices, we can't simply premult it in and - // leave it, because that would leave the rotational component in - // the scene graph's matrix, and all nested matrices would inherit - // the same rotational component. So we have to premult and then - // postmult by the inverse to undo the rotational component each - // time. + // Since we want to apply this transform to all matrices, including nested + // matrices, we can't simply premult it in and leave it, because that + // would leave the rotational component in the scene graph's matrix, and + // all nested matrices would inherit the same rotational component. So we + // have to premult and then postmult by the inverse to undo the rotational + // component each time. LMatrix4d mat1 = mat; LMatrix4d inv1 = inv; - // If we have a translation component, we should only apply - // it to the top matrix. All subsequent matrices get just the - // rotational component. + // If we have a translation component, we should only apply it to the top + // matrix. All subsequent matrices get just the rotational component. mat1.set_row(3, LVector3d(0.0, 0.0, 0.0)); inv1.set_row(3, LVector3d(0.0, 0.0, 0.0)); @@ -1343,11 +1199,9 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::r_flatten_transforms -// Access: Protected, Virtual -// Description: The recursive implementation of flatten_transforms(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of flatten_transforms(). + */ void EggGroup:: r_flatten_transforms() { EggGroupNode::r_flatten_transforms(); @@ -1359,8 +1213,8 @@ r_flatten_transforms() { } if (get_billboard_type() != BT_none && !has_billboard_center()) { - // If we had a billboard without an explicit center, it was an - // implicit instance. Now it's not any more. + // If we had a billboard without an explicit center, it was an implicit + // instance. Now it's not any more. set_billboard_center(LPoint3d(0.0, 0.0, 0.0) * mat); } else if (has_billboard_center()) { @@ -1378,27 +1232,24 @@ r_flatten_transforms() { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroup::transform_changed -// Access: Protected, Virtual -// Description: This virtual method is inherited by EggTransform3d; -// it is called whenever the transform is changed. -//////////////////////////////////////////////////////////////////// +/** + * This virtual method is inherited by EggTransform3d; it is called whenever + * the transform is changed. + */ void EggGroup:: transform_changed() { - // Recompute all of the cached transforms at this node and below. - // We should probably make this smarter and do lazy evaluation of - // these transforms, rather than having to recompute the whole tree - // with every change to a parent node's transform. + // Recompute all of the cached transforms at this node and below. We should + // probably make this smarter and do lazy evaluation of these transforms, + // rather than having to recompute the whole tree with every change to a + // parent node's transform. update_under(0); } -//////////////////////////////////////////////////////////////////// -// Function: GroupType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::GroupType t) { switch (t) { case EggGroup::GT_invalid: @@ -1415,10 +1266,9 @@ ostream &operator << (ostream &out, EggGroup::GroupType t) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: DartType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::DartType t) { switch (t) { case EggGroup::DT_none: @@ -1437,10 +1287,9 @@ ostream &operator << (ostream &out, EggGroup::DartType t) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: DCSType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::DCSType t) { switch (t) { case EggGroup::DC_unspecified: @@ -1461,10 +1310,9 @@ ostream &operator << (ostream &out, EggGroup::DCSType t) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::BillboardType t) { switch (t) { case EggGroup::BT_none: @@ -1481,10 +1329,9 @@ ostream &operator << (ostream &out, EggGroup::BillboardType t) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionSolidType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::CollisionSolidType t) { switch (t) { case EggGroup::CST_none: @@ -1511,10 +1358,9 @@ ostream &operator << (ostream &out, EggGroup::CollisionSolidType t) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: CollideFlags output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggGroup::CollideFlags t) { if (t == EggGroup::CF_none) { return out << "none"; @@ -1557,10 +1403,9 @@ ostream &operator << (ostream &out, EggGroup::CollideFlags t) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: ostream << EggGroup::BlendMode -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, EggGroup::BlendMode t) { switch (t) { @@ -1589,10 +1434,9 @@ operator << (ostream &out, EggGroup::BlendMode t) { return out << "**invalid EggGroup::BlendMode(" << (int)t << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: ostream << EggGroup::BlendOperand -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, EggGroup::BlendOperand t) { switch (t) { diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 77d0fa33fb..fc23e97554 100644 --- a/panda/src/egg/eggGroup.h +++ b/panda/src/egg/eggGroup.h @@ -1,16 +1,15 @@ -// Filename: eggGroup.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroup.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGGROUP_H #define EGGGROUP_H @@ -28,11 +27,10 @@ #include "collideMask.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : EggGroup -// Description : The main glue of the egg hierarchy, this corresponds -// to the , , and type nodes. -//////////////////////////////////////////////////////////////////// +/** + * The main glue of the egg hierarchy, this corresponds to the , + * , and type nodes. + */ class EXPCL_PANDAEGG EggGroup : public EggGroupNode, public EggRenderMode, public EggTransform { PUBLISHED: typedef pmap VertexRef; @@ -63,8 +61,8 @@ PUBLISHED: BT_point_world_relative = 0x00000080, }; enum CollisionSolidType { - // The bits here must correspond to those in Flags, below, and - // they must fit within F_cs_type. + // The bits here must correspond to those in Flags, below, and they must + // fit within F_cs_type. CST_none = 0x00000000, CST_plane = 0x00010000, CST_polygon = 0x00020000, @@ -76,8 +74,8 @@ PUBLISHED: CST_floor_mesh = 0x00080000, }; enum CollideFlags { - // The bits here must correspond to those in Flags, below, and - // they must fit within F_collide_flags. + // The bits here must correspond to those in Flags, below, and they must + // fit within F_collide_flags. CF_none = 0x00000000, CF_descend = 0x00100000, CF_event = 0x00200000, @@ -390,9 +388,9 @@ private: double _w_speed; double _r_speed; - // This is the entry for a . It is not the - // entry (that is stored via inheritance, in the - // EggTransform class we inherit from). + // This is the entry for a . It is not the + // entry (that is stored via inheritance, in the EggTransform class we + // inherit from). EggTransform _default_pose; VertexRef _vref; @@ -435,4 +433,3 @@ ostream &operator << (ostream &out, EggGroup::BlendOperand t); #include "eggGroup.I" #endif - diff --git a/panda/src/egg/eggGroupNode.I b/panda/src/egg/eggGroupNode.I index 28acacd0b9..06c481f486 100644 --- a/panda/src/egg/eggGroupNode.I +++ b/panda/src/egg/eggGroupNode.I @@ -1,33 +1,27 @@ -// Filename: eggGroupNode.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupNode.I + * @author drose + * @date 1999-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::is_right -// Access: Private, Static -// Description: Returns true if the 2-d v1 is to the right of v2. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the 2-d v1 is to the right of v2. + */ INLINE bool EggGroupNode:: is_right(const LVector2d &v1, const LVector2d &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::TBNVertexValue::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggGroupNode::TBNVertexValue:: operator < (const TBNVertexValue &other) const { if (_facing != other._facing) { diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index bb8891d982..acf509274a 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -1,16 +1,15 @@ -// Filename: eggGroupNode.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupNode.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggGroupNode.h" #include "eggGroup.h" @@ -43,11 +42,9 @@ TypeHandle EggGroupNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode:: EggGroupNode(const EggGroupNode ©) : EggNode(copy) { if (!copy.empty()) { @@ -56,11 +53,9 @@ EggGroupNode(const EggGroupNode ©) : EggNode(copy) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode &EggGroupNode:: operator =(const EggGroupNode ©) { if (!copy.empty()) { @@ -71,31 +66,26 @@ operator =(const EggGroupNode ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode:: ~EggGroupNode() { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::write -// Access: Published, Virtual -// Description: Writes the group and all of its children to the -// indicated output stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the group and all of its children to the indicated output stream in + * Egg format. + */ void EggGroupNode:: write(ostream &out, int indent_level) const { iterator i; - // Since joints tend to reference vertex pools, which sometimes - // appear later in the file, and since generally non-joints don't - // reference joints, we try to maximize our chance of writing out a - // one-pass readable egg file by writing joints at the end of the - // list of children of a particular node. + // Since joints tend to reference vertex pools, which sometimes appear later + // in the file, and since generally non-joints don't reference joints, we + // try to maximize our chance of writing out a one-pass readable egg file by + // writing joints at the end of the list of children of a particular node. for (i = begin(); i != end(); ++i) { PT(EggNode) child = (*i); @@ -112,73 +102,59 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::begin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::iterator EggGroupNode:: begin() const { return _children.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::end -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::iterator EggGroupNode:: end() const { return _children.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::rbegin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::reverse_iterator EggGroupNode:: rbegin() const { return _children.rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::rend -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::reverse_iterator EggGroupNode:: rend() const { return _children.rend(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::insert -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::iterator EggGroupNode:: insert(iterator position, PT(EggNode) x) { prepare_add_child(x); return _children.insert((Children::iterator &)position, x); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::erase -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::iterator EggGroupNode:: erase(iterator position) { prepare_remove_child(*position); return _children.erase((Children::iterator &)position); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::erase -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::iterator EggGroupNode:: erase(iterator first, iterator last) { iterator i; @@ -189,13 +165,10 @@ erase(iterator first, iterator last) { (Children::iterator &)last); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::replace -// Access: Published -// Description: Replaces the node at the indicated position with -// the indicated node. It is an error to call this -// with an invalid position iterator (e.g. end()). -//////////////////////////////////////////////////////////////////// +/** + * Replaces the node at the indicated position with the indicated node. It is + * an error to call this with an invalid position iterator (e.g. end()). + */ void EggGroupNode:: replace(iterator position, PT(EggNode) x) { nassertv(position != end()); @@ -205,68 +178,53 @@ replace(iterator position, PT(EggNode) x) { *(Children::iterator &)position = x; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::empty -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggGroupNode:: empty() const { return _children.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode::size_type EggGroupNode:: size() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::clear -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggGroupNode:: clear() { erase(begin(), end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::get_first_child -// Access: Published -// Description: Returns the first child in the group's list of -// children, or NULL if the list of children is empty. -// Can be used with get_next_child() to return the -// complete list of children without using the iterator -// class; however, this is non-thread-safe, and so is -// not recommended except for languages other than C++ -// which cannot use the iterators. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first child in the group's list of children, or NULL if the + * list of children is empty. Can be used with get_next_child() to return the + * complete list of children without using the iterator class; however, this + * is non-thread-safe, and so is not recommended except for languages other + * than C++ which cannot use the iterators. + */ EggNode *EggGroupNode:: get_first_child() { _gnc_iterator = begin(); return get_next_child(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::get_next_child -// Access: Published -// Description: Returns the next child in the group's list of -// children since the last call to get_first_child() or -// get_next_child(), or NULL if the last child has been -// returned. Can be used with get_first_child() to -// return the complete list of children without using -// the iterator class; however, this is non-thread-safe, -// and so is not recommended except for languages other -// than C++ which cannot use the iterators. -// -// It is an error to call this without previously -// calling get_first_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the next child in the group's list of children since the last call + * to get_first_child() or get_next_child(), or NULL if the last child has + * been returned. Can be used with get_first_child() to return the complete + * list of children without using the iterator class; however, this is non- + * thread-safe, and so is not recommended except for languages other than C++ + * which cannot use the iterators. + * + * It is an error to call this without previously calling get_first_child(). + */ EggNode *EggGroupNode:: get_next_child() { if (_gnc_iterator != end()) { @@ -275,13 +233,10 @@ get_next_child() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::add_child -// Access: Published -// Description: Adds the indicated child to the group and returns it. -// If the child node is already a child of some other -// node, removes it first. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated child to the group and returns it. If the child node is + * already a child of some other node, removes it first. + */ EggNode *EggGroupNode:: add_child(EggNode *node) { test_ref_count_integrity(); @@ -294,13 +249,10 @@ add_child(EggNode *node) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::remove_child -// Access: Published -// Description: Removes the indicated child node from the group and -// returns it. If the child was not already in the -// group, does nothing and returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated child node from the group and returns it. If the + * child was not already in the group, does nothing and returns NULL. + */ PT(EggNode) EggGroupNode:: remove_child(EggNode *node) { PT(EggNode) ptnode = node; @@ -315,13 +267,11 @@ remove_child(EggNode *node) { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::steal_children -// Access: Published -// Description: Moves all the children from the other node to this -// one. This is especially useful because the group -// node copy assignment operator does not copy children. -//////////////////////////////////////////////////////////////////// +/** + * Moves all the children from the other node to this one. This is especially + * useful because the group node copy assignment operator does not copy + * children. + */ void EggGroupNode:: steal_children(EggGroupNode &other) { Children::iterator ci; @@ -335,13 +285,11 @@ steal_children(EggGroupNode &other) { _children.splice(_children.end(), other._children); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::find_child -// Access: Published -// Description: Returns the child of this node whose name is the -// indicated string, or NULL if there is no child of -// this node by that name. Does not search recursively. -//////////////////////////////////////////////////////////////////// +/** + * Returns the child of this node whose name is the indicated string, or NULL + * if there is no child of this node by that name. Does not search + * recursively. + */ EggNode *EggGroupNode:: find_child(const string &name) const { Children::const_iterator ci; @@ -355,13 +303,10 @@ find_child(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::has_absolute_pathnames -// Access: Published -// Description: Returns true if any nodes at this level and below -// include a reference to a file via an absolute -// pathname, or false if all references are relative. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any nodes at this level and below include a reference to a + * file via an absolute pathname, or false if all references are relative. + */ bool EggGroupNode:: has_absolute_pathnames() const { Children::const_iterator ci; @@ -412,18 +357,15 @@ has_absolute_pathnames() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::resolve_filenames -// Access: Published -// Description: Walks the tree and attempts to resolve any filenames -// encountered. This looks up filenames along the -// specified search path; it does not automatically -// search the model_path for missing files. -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree and attempts to resolve any filenames encountered. This + * looks up filenames along the specified search path; it does not + * automatically search the model_path for missing files. + */ void EggGroupNode:: resolve_filenames(const DSearchPath &searchpath) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - + Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); @@ -434,7 +376,7 @@ resolve_filenames(const DSearchPath &searchpath) { Filename tex_filename = tex->get_filename(); vfs->resolve_filename(tex_filename, searchpath); tex->set_filename(tex_filename); - + if (tex->has_alpha_filename()) { Filename alpha_filename = tex->get_alpha_filename(); vfs->resolve_filename(alpha_filename, searchpath); @@ -453,14 +395,11 @@ resolve_filenames(const DSearchPath &searchpath) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::force_filenames -// Access: Published -// Description: Similar to resolve_filenames, but each non-absolute -// filename encountered is arbitrarily taken to be in -// the indicated directory, whether or not the so-named -// filename exists. -//////////////////////////////////////////////////////////////////// +/** + * Similar to resolve_filenames, but each non-absolute filename encountered is + * arbitrarily taken to be in the indicated directory, whether or not the so- + * named filename exists. + */ void EggGroupNode:: force_filenames(const Filename &directory) { Children::iterator ci; @@ -495,13 +434,10 @@ force_filenames(const Filename &directory) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::reverse_vertex_ordering -// Access: Published -// Description: Reverses the vertex ordering of all polygons defined -// at this node and below. Does not change the surface -// normals, if any. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the vertex ordering of all polygons defined at this node and + * below. Does not change the surface normals, if any. + */ void EggGroupNode:: reverse_vertex_ordering() { Children::iterator ci; @@ -519,37 +455,29 @@ reverse_vertex_ordering() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::recompute_vertex_normals -// Access: Published -// Description: Recomputes all the vertex normals for polygon -// geometry at this group node and below so that they -// accurately reflect the vertex positions. A shared -// edge between two polygons (even in different groups) -// is considered smooth if the angle between the two -// edges is less than threshold degrees. -// -// This function also removes degenerate polygons that -// do not have enough vertices to define a normal. It -// does not affect normals for other kinds of primitives -// like Nurbs or Points. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// correct normals. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all the vertex normals for polygon geometry at this group node + * and below so that they accurately reflect the vertex positions. A shared + * edge between two polygons (even in different groups) is considered smooth + * if the angle between the two edges is less than threshold degrees. + * + * This function also removes degenerate polygons that do not have enough + * vertices to define a normal. It does not affect normals for other kinds of + * primitives like Nurbs or Points. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the correct normals. Thus, it is a good idea + * to call remove_unused_vertices() after calling this. + */ void EggGroupNode:: recompute_vertex_normals(double threshold, CoordinateSystem cs) { - // First, collect all the vertices together with their shared - // polygons. + // First, collect all the vertices together with their shared polygons. NVertexCollection collection; r_collect_vertex_normals(collection, threshold, cs); - // Now bust them into separate groups according to the edge - // threshold. Two polygons that share a vertex belong in the same - // group only if the angle between their normals is within the - // threshold. + // Now bust them into separate groups according to the edge threshold. Two + // polygons that share a vertex belong in the same group only if the angle + // between their normals is within the threshold. double cos_angle = cos(deg_2_rad(threshold)); @@ -557,9 +485,9 @@ recompute_vertex_normals(double threshold, CoordinateSystem cs) { for (ci = collection.begin(); ci != collection.end(); ++ci) { NVertexGroup &group = (*ci).second; - // Here's a group of polygons that share a vertex. Build up a new - // group that consists of just the first polygon and all the ones - // that are within threshold degrees from it. + // Here's a group of polygons that share a vertex. Build up a new group + // that consists of just the first polygon and all the ones that are + // within threshold degrees from it. NVertexGroup::iterator gi; gi = group.begin(); while (gi != group.end()) { @@ -582,8 +510,8 @@ recompute_vertex_normals(double threshold, CoordinateSystem cs) { ++gi; } - // Now new_group is a collection of connected polygons and the - // vertices that connect them. Smooth these vertices. + // Now new_group is a collection of connected polygons and the vertices + // that connect them. Smooth these vertices. do_compute_vertex_normals(new_group); // And reset the group of remaining polygons. @@ -593,25 +521,20 @@ recompute_vertex_normals(double threshold, CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::recompute_polygon_normals -// Access: Published -// Description: Recomputes all the polygon normals for polygon -// geometry at this group node and below so that they -// accurately reflect the vertex positions. Normals are -// removed from the vertices and defined only on -// polygons, giving the geometry a faceted appearance. -// -// This function also removes degenerate polygons that -// do not have enough vertices to define a normal. It -// does not affect normals for other kinds of primitives -// like Nurbs or Points. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// normals removed. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes all the polygon normals for polygon geometry at this group node + * and below so that they accurately reflect the vertex positions. Normals + * are removed from the vertices and defined only on polygons, giving the + * geometry a faceted appearance. + * + * This function also removes degenerate polygons that do not have enough + * vertices to define a normal. It does not affect normals for other kinds of + * primitives like Nurbs or Points. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the normals removed. Thus, it is a good idea + * to call remove_unused_vertices() after calling this. + */ void EggGroupNode:: recompute_polygon_normals(CoordinateSystem cs) { Children::iterator ci, cnext; @@ -655,17 +578,14 @@ recompute_polygon_normals(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::strip_normals -// Access: Published -// Description: Removes all normals from primitives, and the vertices -// they reference, at this node and below. -// -// This function does not remove or adjust vertices in -// the vertex pool; it only adds new vertices with the -// normal removed. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Removes all normals from primitives, and the vertices they reference, at + * this node and below. + * + * This function does not remove or adjust vertices in the vertex pool; it + * only adds new vertices with the normal removed. Thus, it is a good idea to + * call remove_unused_vertices() after calling this. + */ void EggGroupNode:: strip_normals() { Children::iterator ci; @@ -698,36 +618,29 @@ strip_normals() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::recompute_tangent_binormal -// Access: Published -// Description: This function recomputes the tangent and binormal for -// the named texture coordinate set for all vertices at -// this level and below. Use the empty string for the -// default texture coordinate set. -// -// It is necessary for each vertex to already have a -// normal (or at least a polygon normal), as well as a -// texture coordinate in the named texture coordinate -// set, before calling this function. You might precede -// this with recompute_vertex_normals() to ensure that -// the normals exist. -// -// Like recompute_vertex_normals(), this function does -// not remove or adjust vertices in the vertex pool; it -// only adds new vertices with the new tangents and -// binormals computed. Thus, it is a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * This function recomputes the tangent and binormal for the named texture + * coordinate set for all vertices at this level and below. Use the empty + * string for the default texture coordinate set. + * + * It is necessary for each vertex to already have a normal (or at least a + * polygon normal), as well as a texture coordinate in the named texture + * coordinate set, before calling this function. You might precede this with + * recompute_vertex_normals() to ensure that the normals exist. + * + * Like recompute_vertex_normals(), this function does not remove or adjust + * vertices in the vertex pool; it only adds new vertices with the new + * tangents and binormals computed. Thus, it is a good idea to call + * remove_unused_vertices() after calling this. + */ bool EggGroupNode:: recompute_tangent_binormal(const GlobPattern &uv_name) { - // First, collect all the vertices together with their shared - // polygons. + // First, collect all the vertices together with their shared polygons. TBNVertexCollection collection; r_collect_tangent_binormal(uv_name, collection); - // Now compute the tangent and binormal separately for each common - // group of vertices. + // Now compute the tangent and binormal separately for each common group of + // vertices. TBNVertexCollection::const_iterator ci; for (ci = collection.begin(); ci != collection.end(); ++ci) { const TBNVertexValue &value = (*ci).first; @@ -735,17 +648,14 @@ recompute_tangent_binormal(const GlobPattern &uv_name) { do_compute_tangent_binormal(value, group); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::recompute_tangent_binormal -// Access: Published -// Description: This function recomputes the tangent and binormal for -// the named texture coordinate sets. -// Returns true if anything was done. -//////////////////////////////////////////////////////////////////// +/** + * This function recomputes the tangent and binormal for the named texture + * coordinate sets. Returns true if anything was done. + */ bool EggGroupNode:: recompute_tangent_binormal(const vector_string &names) { bool changed = false; @@ -758,17 +668,15 @@ recompute_tangent_binormal(const vector_string &names) { recompute_tangent_binormal(uv_name); changed = true; } - + return changed; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::recompute_tangent_binormal_auto -// Access: Published -// Description: This function recomputes the tangent and binormal for -// any texture coordinate set that affects a normal map. -// Returns true if anything was done. -//////////////////////////////////////////////////////////////////// +/** + * This function recomputes the tangent and binormal for any texture + * coordinate set that affects a normal map. Returns true if anything was + * done. + */ bool EggGroupNode:: recompute_tangent_binormal_auto() { vector_string names; @@ -790,20 +698,15 @@ recompute_tangent_binormal_auto() { return recompute_tangent_binormal(names); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::triangulate_polygons -// Access: Published -// Description: Replace all higher-order polygons at this point in -// the scene graph and below with triangles. Returns -// the total number of new triangles produced, less -// degenerate polygons removed. -// -// If flags contains T_polygon and T_convex, both -// concave and convex polygons will be subdivided into -// triangles; with only T_polygon, only concave polygons -// will be subdivided, and convex polygons will be -// largely unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Replace all higher-order polygons at this point in the scene graph and + * below with triangles. Returns the total number of new triangles produced, + * less degenerate polygons removed. + * + * If flags contains T_polygon and T_convex, both concave and convex polygons + * will be subdivided into triangles; with only T_polygon, only concave + * polygons will be subdivided, and convex polygons will be largely unchanged. + */ int EggGroupNode:: triangulate_polygons(int flags) { int num_produced = 0; @@ -839,12 +742,9 @@ triangulate_polygons(int flags) { return num_produced; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::mesh_triangles -// Access: Published -// Description: Combine triangles together into triangle strips, at -// this group and below. -//////////////////////////////////////////////////////////////////// +/** + * Combine triangles together into triangle strips, at this group and below. + */ void EggGroupNode:: mesh_triangles(int flags) { EggMesher mesher; @@ -861,18 +761,15 @@ mesh_triangles(int flags) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::make_point_primitives -// Access: Published -// Description: Creates PointLight primitives to reference any -// otherwise unreferences vertices discovered in this -// group or below. -//////////////////////////////////////////////////////////////////// +/** + * Creates PointLight primitives to reference any otherwise unreferences + * vertices discovered in this group or below. + */ void EggGroupNode:: make_point_primitives() { - // Create a temporary node to hold the EggPoint objects we might - // create while we iterate. (We don't add them during the iteration - // to avoid invalidating the iterator.) + // Create a temporary node to hold the EggPoint objects we might create + // while we iterate. (We don't add them during the iteration to avoid + // invalidating the iterator.) PT(EggGroupNode) temp = new EggGroup("temp"); EggGroupNode::iterator ci; @@ -894,11 +791,9 @@ make_point_primitives() { steal_children(*temp); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::rename_nodes -// Access: Published -// Description: Rename by stripping out the prefix -//////////////////////////////////////////////////////////////////// +/** + * Rename by stripping out the prefix + */ int EggGroupNode:: rename_nodes(vector_string strip_prefix, bool recurse) { int num_renamed = 0; @@ -906,7 +801,7 @@ rename_nodes(vector_string strip_prefix, bool recurse) { string axe_name = strip_prefix[ni]; if (this->get_name().substr(0, axe_name.size()) == axe_name) { string new_name = this->get_name().substr(axe_name.size()); - //cout << "renaming " << this->get_name() << "->" << new_name << endl; + // cout << "renaming " << this->get_name() << "->" << new_name << endl; this->set_name(new_name); num_renamed += 1; } @@ -927,25 +822,19 @@ rename_nodes(vector_string strip_prefix, bool recurse) { return num_renamed; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::remove_unused_vertices -// Access: Published -// Description: Removes all vertices from VertexPools within this -// group or below that are not referenced by at least -// one primitive. Also collapses together equivalent -// vertices, and renumbers all vertices after the -// operation so their indices are consecutive, beginning -// at zero. Returns the total number of vertices -// removed. -// -// Note that this operates on the VertexPools within -// this group level, without respect to primitives that -// reference these vertices (unlike other functions like -// strip_normals()). It is therefore most useful to -// call this on the EggData root, rather than on a -// subgroup within the hierarchy, since a VertexPool may -// appear anywhere in the hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices from VertexPools within this group or below that are + * not referenced by at least one primitive. Also collapses together + * equivalent vertices, and renumbers all vertices after the operation so + * their indices are consecutive, beginning at zero. Returns the total number + * of vertices removed. + * + * Note that this operates on the VertexPools within this group level, without + * respect to primitives that reference these vertices (unlike other functions + * like strip_normals()). It is therefore most useful to call this on the + * EggData root, rather than on a subgroup within the hierarchy, since a + * VertexPool may appear anywhere in the hierarchy. + */ int EggGroupNode:: remove_unused_vertices(bool recurse) { int num_removed = 0; @@ -962,8 +851,8 @@ remove_unused_vertices(bool recurse) { num_removed += vpool->remove_unused_vertices(); if (vpool->empty()) { - // If, after removing all the vertices, there's nothing left - // in the vertex pool, then remove the whole vertex pool. + // If, after removing all the vertices, there's nothing left in the + // vertex pool, then remove the whole vertex pool. _children.erase(ci); } @@ -979,14 +868,11 @@ remove_unused_vertices(bool recurse) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::remove_invalid_primitives -// Access: Published -// Description: Removes primitives at this level and below which -// appear to be degenerate; e.g. polygons with fewer -// than 3 vertices, etc. Returns the number of -// primitives removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes primitives at this level and below which appear to be degenerate; + * e.g. polygons with fewer than 3 vertices, etc. Returns the number of + * primitives removed. + */ int EggGroupNode:: remove_invalid_primitives(bool recurse) { int num_removed = 0; @@ -1017,18 +903,14 @@ remove_invalid_primitives(bool recurse) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::clear_connected_shading -// Access: Published -// Description: Resets the connected_shading information on all -// primitives at this node and below, so that it may be -// accurately rederived by the next call to -// get_connected_shading(). -// -// It may be a good idea to call -// remove_unused_vertices() as well, to establish the -// correct connectivity between common vertices. -//////////////////////////////////////////////////////////////////// +/** + * Resets the connected_shading information on all primitives at this node and + * below, so that it may be accurately rederived by the next call to + * get_connected_shading(). + * + * It may be a good idea to call remove_unused_vertices() as well, to + * establish the correct connectivity between common vertices. + */ void EggGroupNode:: clear_connected_shading() { Children::iterator ci; @@ -1044,14 +926,11 @@ clear_connected_shading() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::get_connected_shading -// Access: Published -// Description: Queries the connected_shading information on all -// primitives at this node and below, to ensure that it -// has been completely filled in before we start mucking -// around with vertices. -//////////////////////////////////////////////////////////////////// +/** + * Queries the connected_shading information on all primitives at this node + * and below, to ensure that it has been completely filled in before we start + * mucking around with vertices. + */ void EggGroupNode:: get_connected_shading() { Children::iterator ci; @@ -1067,37 +946,28 @@ get_connected_shading() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::unify_attributes -// Access: Published -// Description: Applies per-vertex normal and color to all vertices, -// if they are in fact per-vertex (and different for -// each vertex), or moves them to the primitive if they -// are all the same. -// -// After this call, either the primitive will have -// normals or its vertices will, but not both. Ditto -// for colors. -// -// If use_connected_shading is true, each polygon is -// considered in conjunction with all connected -// polygons; otherwise, each polygon is considered -// individually. -// -// If allow_per_primitive is false, S_per_face or -// S_overall will treated like S_per_vertex: normals and -// colors will always be assigned to the vertices. In -// this case, there will never be per-primitive colors -// or normals after this call returns. On the other -// hand, if allow_per_primitive is true, then S_per_face -// means that normals and colors should be assigned to -// the primitives, and removed from the vertices, as -// described above. -// -// This may create redundant vertices in the vertex -// pool, so it may be a good idea to follow this up with -// remove_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Applies per-vertex normal and color to all vertices, if they are in fact + * per-vertex (and different for each vertex), or moves them to the primitive + * if they are all the same. + * + * After this call, either the primitive will have normals or its vertices + * will, but not both. Ditto for colors. + * + * If use_connected_shading is true, each polygon is considered in conjunction + * with all connected polygons; otherwise, each polygon is considered + * individually. + * + * If allow_per_primitive is false, S_per_face or S_overall will treated like + * S_per_vertex: normals and colors will always be assigned to the vertices. + * In this case, there will never be per-primitive colors or normals after + * this call returns. On the other hand, if allow_per_primitive is true, then + * S_per_face means that normals and colors should be assigned to the + * primitives, and removed from the vertices, as described above. + * + * This may create redundant vertices in the vertex pool, so it may be a good + * idea to follow this up with remove_unused_vertices(). + */ void EggGroupNode:: unify_attributes(bool use_connected_shading, bool allow_per_primitive, bool recurse) { @@ -1128,20 +998,15 @@ unify_attributes(bool use_connected_shading, bool allow_per_primitive, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::apply_last_attribute -// Access: Published -// Description: Sets the last vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// OpenGL convention of storing flat-shaded properties on -// the last vertex, although it is not usually a -// convention in Egg. -// -// This may create redundant vertices in the vertex -// pool, so it may be a good idea to follow this up with -// remove_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the last vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * OpenGL convention of storing flat-shaded properties on the last vertex, + * although it is not usually a convention in Egg. + * + * This may create redundant vertices in the vertex pool, so it may be a good + * idea to follow this up with remove_unused_vertices(). + */ void EggGroupNode:: apply_last_attribute(bool recurse) { Children::iterator ci; @@ -1159,20 +1024,15 @@ apply_last_attribute(bool recurse) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::apply_first_attribute -// Access: Published -// Description: Sets the first vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// DirectX convention of storing flat-shaded properties on -// the first vertex, although it is not usually a -// convention in Egg. -// -// This may create redundant vertices in the vertex -// pool, so it may be a good idea to follow this up with -// remove_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the first vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * DirectX convention of storing flat-shaded properties on the first vertex, + * although it is not usually a convention in Egg. + * + * This may create redundant vertices in the vertex pool, so it may be a good + * idea to follow this up with remove_unused_vertices(). + */ void EggGroupNode:: apply_first_attribute(bool recurse) { Children::iterator ci; @@ -1190,14 +1050,11 @@ apply_first_attribute(bool recurse) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::post_apply_flat_attribute -// Access: Published -// Description: Intended as a followup to apply_last_attribute(), -// this also sets an attribute on the first vertices of -// the primitive, if they don't already have an -// attribute set, just so they end up with *something*. -//////////////////////////////////////////////////////////////////// +/** + * Intended as a followup to apply_last_attribute(), this also sets an + * attribute on the first vertices of the primitive, if they don't already + * have an attribute set, just so they end up with *something*. + */ void EggGroupNode:: post_apply_flat_attribute(bool recurse) { Children::iterator ci; @@ -1215,13 +1072,10 @@ post_apply_flat_attribute(bool recurse) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::has_primitives -// Access: Published, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, false otherwise. + */ bool EggGroupNode:: has_primitives() const { Children::const_iterator ci; @@ -1236,13 +1090,10 @@ has_primitives() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::joint_has_primitives -// Access: Published, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// but the search does not include nested joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, but the search does not include nested joints. + */ bool EggGroupNode:: joint_has_primitives() const { Children::const_iterator ci; @@ -1261,13 +1112,10 @@ joint_has_primitives() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::has_normals -// Access: Published, Virtual -// Description: Returns true if any of the primitives (e.g. polygons) -// defined within this group or below have either face -// or vertex normals defined, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the primitives (e.g. polygons) defined within this + * group or below have either face or vertex normals defined, false otherwise. + */ bool EggGroupNode:: has_normals() const { Children::const_iterator ci; @@ -1282,20 +1130,15 @@ has_normals() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::rebuild_vertex_pools -// Access: Published -// Description: Copies vertices used by the primitives at this group -// node (and below, if recurse is true) into one or more -// new vertex pools, and updates the primitives to -// reference these pools. It is up to the caller to -// parent the newly-created vertex pools somewhere -// appropriate in the egg hierarchy. -// -// No more than max_vertices will be placed into any one -// vertex pool. This is the sole criteria for splitting -// vertex pools. -//////////////////////////////////////////////////////////////////// +/** + * Copies vertices used by the primitives at this group node (and below, if + * recurse is true) into one or more new vertex pools, and updates the + * primitives to reference these pools. It is up to the caller to parent the + * newly-created vertex pools somewhere appropriate in the egg hierarchy. + * + * No more than max_vertices will be placed into any one vertex pool. This is + * the sole criteria for splitting vertex pools. + */ void EggGroupNode:: rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, bool recurse) { @@ -1318,8 +1161,8 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, Attributes attributes; if (prim->is_of_type(EggCompositePrimitive::get_class_type())) { - // A compositive primitive has the additional complication of - // dealing with its attributes. + // A compositive primitive has the additional complication of dealing + // with its attributes. EggCompositePrimitive *cprim = DCAST(EggCompositePrimitive, prim); int i; int num_components = cprim->get_num_components(); @@ -1330,16 +1173,16 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, prim->clear(); - // Now look for a new home for the vertices. First, see if any - // of the vertex pools we've already created already have a copy - // of each one of the vertices. + // Now look for a new home for the vertices. First, see if any of the + // vertex pools we've already created already have a copy of each one of + // the vertices. bool found_pool = false; EggVertexPool *best_pool = NULL; int best_new_vertices = 0; Vertices new_vertices; EggVertexPools::iterator vpi; - for (vpi = vertex_pools.begin(); + for (vpi = vertex_pools.begin(); vpi != vertex_pools.end() && !found_pool; ++vpi) { EggVertexPool *vertex_pool = (*vpi); @@ -1349,8 +1192,8 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, new_vertices.reserve(vertices.size()); Vertices::const_iterator vi; - for (vi = vertices.begin(); - vi != vertices.end() && !found_pool; + for (vi = vertices.begin(); + vi != vertices.end() && !found_pool; ++vi) { EggVertex *vertex = (*vi); EggVertex *new_vertex = vertex_pool->find_matching_vertex(*vertex); @@ -1361,14 +1204,14 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, } if (num_new_vertices == 0) { - // Great, we found a vertex pool that already shares all - // these vertices. No need to look any further. + // Great, we found a vertex pool that already shares all these + // vertices. No need to look any further. found_pool = true; } else if (vertex_pool->size() + num_new_vertices <= max_vertices) { - // We would have to add some vertices to this pool, so this - // vertex pool qualifies only if the number of vertices we - // have to add would still keep it within our limit. + // We would have to add some vertices to this pool, so this vertex + // pool qualifies only if the number of vertices we have to add + // would still keep it within our limit. if (best_pool == (EggVertexPool *)NULL || num_new_vertices < best_new_vertices) { // This is currently our most favorable vertex pool. @@ -1380,8 +1223,8 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, if (!found_pool) { if (best_pool == (EggVertexPool *)NULL) { - // There was no vertex pool that qualified. We will have to - // create a new vertex pool. + // There was no vertex pool that qualified. We will have to create + // a new vertex pool. best_pool = new EggVertexPool(""); vertex_pools.push_back(best_pool); } @@ -1416,7 +1259,7 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, cprim->set_component(i, &attributes[i]); } } - + } else if (child->is_of_type(EggGroupNode::get_class_type())) { if (recurse) { DCAST(EggGroupNode, child)->rebuild_vertex_pools(vertex_pools, max_vertices, recurse); @@ -1425,19 +1268,15 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::update_under -// Access: Protected, Virtual -// Description: This function is called from within EggGroupNode -// whenever the parentage of the node has changed. It -// should update the depth and under_instance flags -// accordingly. -// -// Offset is the difference between the old depth value -// and the new value. It should be consistent with the -// supplied depth value. If it is not, we have some -// error. -//////////////////////////////////////////////////////////////////// +/** + * This function is called from within EggGroupNode whenever the parentage of + * the node has changed. It should update the depth and under_instance flags + * accordingly. + * + * Offset is the difference between the old depth value and the new value. It + * should be consistent with the supplied depth value. If it is not, we have + * some error. + */ void EggGroupNode:: update_under(int depth_offset) { EggNode::update_under(depth_offset); @@ -1451,19 +1290,15 @@ update_under(int depth_offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggGroupNode:: r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) { @@ -1475,15 +1310,12 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_transform_vertices -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform_vertices_only()(). It applies a -// transformation matrix to the current node in some -// sensible way (if the current node is a vertex pool -// with vertices), then continues down the tree. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform_vertices_only()(). It + * applies a transformation matrix to the current node in some sensible way + * (if the current node is a vertex pool with vertices), then continues down + * the tree. + */ void EggGroupNode:: r_transform_vertices(const LMatrix4d &mat) { Children::iterator ci; @@ -1494,15 +1326,12 @@ r_transform_vertices(const LMatrix4d &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_mark_coordsys -// Access: Protected, Virtual -// Description: This is only called immediately after loading an egg -// file from disk, to propagate the value found in the -// CoordinateSystem entry (or the default Y-up -// coordinate system) to all nodes that care about what -// the coordinate system is. -//////////////////////////////////////////////////////////////////// +/** + * This is only called immediately after loading an egg file from disk, to + * propagate the value found in the CoordinateSystem entry (or the default + * Y-up coordinate system) to all nodes that care about what the coordinate + * system is. + */ void EggGroupNode:: r_mark_coordsys(CoordinateSystem cs) { Children::iterator ci; @@ -1513,11 +1342,9 @@ r_mark_coordsys(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_flatten_transforms -// Access: Protected, Virtual -// Description: The recursive implementation of flatten_transforms(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of flatten_transforms(). + */ void EggGroupNode:: r_flatten_transforms() { Children::iterator ci; @@ -1528,11 +1355,9 @@ r_flatten_transforms() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_apply_texmats -// Access: Protected, Virtual -// Description: The recursive implementation of apply_texmats(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of apply_texmats(). + */ void EggGroupNode:: r_apply_texmats(EggTextureCollection &textures) { Children::iterator ci; @@ -1543,22 +1368,18 @@ r_apply_texmats(EggTextureCollection &textures) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::find_coordsys_entry() -// Access: Protected -// Description: Walks the tree, looking for an EggCoordinateSystem -// entry. If one is found, extracts it and returns its -// value. If multiple entries are found, extracts all -// of them and returns CS_invalid if they disagree. -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree, looking for an EggCoordinateSystem entry. If one is found, + * extracts it and returns its value. If multiple entries are found, extracts + * all of them and returns CS_invalid if they disagree. + */ CoordinateSystem EggGroupNode:: find_coordsys_entry() { CoordinateSystem coordsys = CS_default; - // We can do this ci/cnext iteration through the list as we modify - // it, only because we know this works with an STL list type - // container. If this were a vector or a set, this wouldn't - // necessarily work. + // We can do this cicnext iteration through the list as we modify it, only + // because we know this works with an STL list type container. If this were + // a vector or a set, this wouldn't necessarily work. Children::iterator ci, cnext; ci = _children.begin(); @@ -1601,22 +1422,18 @@ find_coordsys_entry() { return coordsys; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::find_textures() -// Access: Protected -// Description: Walks the tree, looking for EggTextures. Each -// EggTexture that is found is removed from the -// hierarchy and added to the EggTextureCollection. -// Returns the number of EggTextures found. -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree, looking for EggTextures. Each EggTexture that is found is + * removed from the hierarchy and added to the EggTextureCollection. Returns + * the number of EggTextures found. + */ int EggGroupNode:: find_textures(EggTextureCollection *collection) { int num_found = 0; - // We can do this ci/cnext iteration through the list as we modify - // it, only because we know this works with an STL list type - // container. If this were a vector or a set, this wouldn't - // necessarily work. + // We can do this cicnext iteration through the list as we modify it, only + // because we know this works with an STL list type container. If this were + // a vector or a set, this wouldn't necessarily work. Children::iterator ci, cnext; ci = _children.begin(); @@ -1647,22 +1464,18 @@ find_textures(EggTextureCollection *collection) { return num_found; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::find_materials() -// Access: Protected -// Description: Walks the tree, looking for EggMaterials. Each -// EggMaterial that is found is removed from the -// hierarchy and added to the EggMaterialCollection. -// Returns the number of EggMaterials found. -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree, looking for EggMaterials. Each EggMaterial that is found + * is removed from the hierarchy and added to the EggMaterialCollection. + * Returns the number of EggMaterials found. + */ int EggGroupNode:: find_materials(EggMaterialCollection *collection) { int num_found = 0; - // We can do this ci/cnext iteration through the list as we modify - // it, only because we know this works with an STL list type - // container. If this were a vector or a set, this wouldn't - // necessarily work. + // We can do this cicnext iteration through the list as we modify it, only + // because we know this works with an STL list type container. If this were + // a vector or a set, this wouldn't necessarily work. Children::iterator ci, cnext; ci = _children.begin(); @@ -1693,15 +1506,12 @@ find_materials(EggMaterialCollection *collection) { return num_found; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_load_externals -// Access: Protected -// Description: Walks the tree and locates unloaded external -// reference nodes, which it attempts to locate and load -// in. The reference node is replaced with the entire -// subtree loaded. This is intended to be called from -// EggData::load_externals(). -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree and locates unloaded external reference nodes, which it + * attempts to locate and load in. The reference node is replaced with the + * entire subtree loaded. This is intended to be called from + * EggData::load_externals(). + */ bool EggGroupNode:: r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, BamCacheRecord *record) { @@ -1715,8 +1525,8 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, if (child->is_of_type(EggExternalReference::get_class_type())) { PT(EggExternalReference) ref = DCAST(EggExternalReference, child); - // Replace the reference with an empty group node. When we load - // the external file successfully, we'll put its contents here. + // Replace the reference with an empty group node. When we load the + // external file successfully, we'll put its contents here. Filename filename = ref->get_filename(); EggGroupNode *new_node = new EggGroupNode(filename.get_basename_wo_extension()); @@ -1727,14 +1537,14 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, << "Could not locate " << filename << " in " << searchpath << "\n"; } else { - // Now define a new EggData structure to hold the external - // reference, and load it. + // Now define a new EggData structure to hold the external reference, + // and load it. EggData ext_data; ext_data.set_coordinate_system(coordsys); ext_data.set_auto_resolve_externals(true); if (ext_data.read(filename)) { - // The external file was read correctly. Add its contents - // into the tree at this point. + // The external file was read correctly. Add its contents into the + // tree at this point. if (record != (BamCacheRecord *)NULL) { record->add_dependent_file(filename); } @@ -1757,17 +1567,14 @@ r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::prepare_add_child -// Access: Private -// Description: Marks the node as a child of the group. This is an -// internal function called by the STL-like functions -// push_back() and insert(), in preparation for actually -// adding the child. -// -// It is an error to add a node that is already a child -// of this group or some other group. -//////////////////////////////////////////////////////////////////// +/** + * Marks the node as a child of the group. This is an internal function + * called by the STL-like functions push_back() and insert(), in preparation + * for actually adding the child. + * + * It is an error to add a node that is already a child of this group or some + * other group. + */ void EggGroupNode:: prepare_add_child(EggNode *node) { nassertv(node != (EggNode *)NULL); @@ -1782,17 +1589,14 @@ prepare_add_child(EggNode *node) { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::prepare_remove_child -// Access: Private -// Description: Marks the node as removed from the group. This is an -// internal function called by the STL-like functions -// pop_back() and erase(), in preparation for actually -// doing the removal. -// -// It is an error to attempt to remove a node that is -// not already a child of this group. -//////////////////////////////////////////////////////////////////// +/** + * Marks the node as removed from the group. This is an internal function + * called by the STL-like functions pop_back() and erase(), in preparation for + * actually doing the removal. + * + * It is an error to attempt to remove a node that is not already a child of + * this group. + */ void EggGroupNode:: prepare_remove_child(EggNode *node) { nassertv(node != (EggNode *)NULL); @@ -1806,21 +1610,17 @@ prepare_remove_child(EggNode *node) { -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_collect_vertex_normals -// Access: Private -// Description: This is part of the implementation of -// recompute_vertex_normals(). It walks the scene graph -// at this group node and below, identifying all the -// polygons and the vertices they have in common. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the implementation of recompute_vertex_normals(). It walks + * the scene graph at this group node and below, identifying all the polygons + * and the vertices they have in common. + */ void EggGroupNode:: r_collect_vertex_normals(EggGroupNode::NVertexCollection &collection, double threshold, CoordinateSystem cs) { - // We can do this ci/cnext iteration through the list as we modify - // it, only because we know this works with an STL list type - // container. If this were a vector or a set, this wouldn't - // necessarily work. + // We can do this cicnext iteration through the list as we modify it, only + // because we know this works with an STL list type container. If this were + // a vector or a set, this wouldn't necessarily work. Children::iterator ci, cnext; ci = _children.begin(); @@ -1842,8 +1642,7 @@ r_collect_vertex_normals(EggGroupNode::NVertexCollection &collection, _children.erase(ci); } else { - // Now add each vertex from the polygon separately to our - // collection. + // Now add each vertex from the polygon separately to our collection. size_t num_vertices = polygon->size(); for (size_t i = 0; i < num_vertices; i++) { EggVertex *vertex = polygon->get_vertex(i); @@ -1855,8 +1654,8 @@ r_collect_vertex_normals(EggGroupNode::NVertexCollection &collection, } else if (child->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *group = DCAST(EggGroupNode, child); - // We can't share vertices across an Instance node. Don't - // even bother trying. Instead, just restart. + // We can't share vertices across an Instance node. Don't even bother + // trying. Instead, just restart. if (group->is_under_instance()) { group->recompute_vertex_normals(threshold, cs); } else { @@ -1868,20 +1667,17 @@ r_collect_vertex_normals(EggGroupNode::NVertexCollection &collection, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::do_compute_vertex_normals -// Access: Private -// Description: This is part of the implementation of -// recompute_vertex_normals(). It accepts a group of -// polygons and their common normals, and computes the -// same normal for all their shared vertices. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the implementation of recompute_vertex_normals(). It + * accepts a group of polygons and their common normals, and computes the same + * normal for all their shared vertices. + */ void EggGroupNode:: do_compute_vertex_normals(const NVertexGroup &group) { nassertv(!group.empty()); - // Determine the common normal. This is simply the average of all - // the polygon normals that share this vertex. + // Determine the common normal. This is simply the average of all the + // polygon normals that share this vertex. LNormald normal(0.0, 0.0, 0.0); NVertexGroup::const_iterator gi; for (gi = group.begin(); gi != group.end(); ++gi) { @@ -1908,14 +1704,11 @@ do_compute_vertex_normals(const NVertexGroup &group) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::r_collect_tangent_binormal -// Access: Private -// Description: This is part of the implementation of -// recompute_tangent_binormal(). It walks the scene -// graph at this group node and below, identifying all -// the polygons and the vertices they have in common. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the implementation of recompute_tangent_binormal(). It + * walks the scene graph at this group node and below, identifying all the + * polygons and the vertices they have in common. + */ void EggGroupNode:: r_collect_tangent_binormal(const GlobPattern &uv_name, EggGroupNode::TBNVertexCollection &collection) { @@ -1929,20 +1722,19 @@ r_collect_tangent_binormal(const GlobPattern &uv_name, TBNVertexReference ref; ref._polygon = polygon; - // Now add each vertex from the polygon separately to our - // collection. + // Now add each vertex from the polygon separately to our collection. size_t num_vertices = polygon->size(); for (size_t i = 0; i < num_vertices; i++) { - // We look at the triangle formed by each three consecutive - // vertices to determine the s direction and t direction at - // each vertex. v1 is the key vertex, the one at position i; - // v2 is vertex i + 1, and v3 is vertex i - 1. + // We look at the triangle formed by each three consecutive vertices + // to determine the s direction and t direction at each vertex. v1 is + // the key vertex, the one at position i; v2 is vertex i + 1, and v3 + // is vertex i - 1. EggVertex *v1 = polygon->get_vertex(i); EggVertex *v2 = polygon->get_vertex((i + 1) % num_vertices); EggVertex *v3 = polygon->get_vertex((i + num_vertices - 1) % num_vertices); if (v1->has_normal() || polygon->has_normal()) { - // Go through all of the UV names on the vertex, looking for - // one that matches the glob pattern. + // Go through all of the UV names on the vertex, looking for one + // that matches the glob pattern. EggVertex::const_uv_iterator uvi; for (uvi = v1->uv_begin(); uvi != v1->uv_end(); ++uvi) { EggVertexUV *uv_obj = (*uvi); @@ -1958,22 +1750,22 @@ r_collect_tangent_binormal(const GlobPattern &uv_name, value._normal = polygon->get_normal(); } value._uv = v1->get_uv(name); - + // Compute the s direction and t direction for this vertex. LPoint3d p1 = v1->get_pos3(); LPoint3d p2 = v2->get_pos3(); LPoint3d p3 = v3->get_pos3(); - + LTexCoordd w1 = v1->get_uv(name); LTexCoordd w2 = v2->get_uv(name); LTexCoordd w3 = v3->get_uv(name); - // Check the facing of the texture; we will have to - // split vertices whose UV's are mirrored along a seam. - // The facing is determined by the winding order of the - // texcoords on the polygon. A front-facing polygon - // should not contribute to the tangent and binormal of - // a back-facing polygon, and vice-versa. + // Check the facing of the texture; we will have to split + // vertices whose UV's are mirrored along a seam. The facing is + // determined by the winding order of the texcoords on the + // polygon. A front-facing polygon should not contribute to the + // tangent and binormal of a back-facing polygon, and vice- + // versa. value._facing = is_right(w1 - w2, w3 - w1); double x1 = p2[0] - p1[0]; @@ -1982,12 +1774,12 @@ r_collect_tangent_binormal(const GlobPattern &uv_name, double y2 = p3[1] - p1[1]; double z1 = p2[2] - p1[2]; double z2 = p3[2] - p1[2]; - + double s1 = w2[0] - w1[0]; double s2 = w3[0] - w1[0]; double t1 = w2[1] - w1[1]; double t2 = w3[1] - w1[1]; - + double denom = (s1 * t2 - s2 * t1); if (denom == 0.0) { ref._sdir.set(0.0, 0.0, 0.0); @@ -2011,8 +1803,8 @@ r_collect_tangent_binormal(const GlobPattern &uv_name, } else if (child->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *group = DCAST(EggGroupNode, child); - // We can't share vertices across an Instance node. Don't - // even bother trying. Instead, just restart. + // We can't share vertices across an Instance node. Don't even bother + // trying. Instead, just restart. if (group->is_under_instance()) { group->recompute_tangent_binormal(uv_name); } else { @@ -2022,22 +1814,18 @@ r_collect_tangent_binormal(const GlobPattern &uv_name, } } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::do_compute_tangent_binormal -// Access: Private -// Description: This is part of the implementation of -// recompute_tangent_binormal(). It accepts a group of -// polygons and their common normals and UV's, and -// computes the tangent and binormal for all their -// shared vertices. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the implementation of recompute_tangent_binormal(). It + * accepts a group of polygons and their common normals and UV's, and computes + * the tangent and binormal for all their shared vertices. + */ void EggGroupNode:: do_compute_tangent_binormal(const TBNVertexValue &value, const TBNVertexGroup &group) { nassertv(!group.empty()); - // Accumulate together all of the s vectors and t vectors computed - // for the different vertices that are together here. + // Accumulate together all of the s vectors and t vectors computed for the + // different vertices that are together here. LNormald sdir(0.0, 0.0, 0.0); LNormald tdir(0.0, 0.0, 0.0); @@ -2048,10 +1836,10 @@ do_compute_tangent_binormal(const TBNVertexValue &value, tdir += ref._tdir; } - // If sdir and/or tdir are zero, choose an arbitrary vector instead. - // (This is really the only reason we normalize sdir and tdir, - // though it also helps stabilize the math below in case the vectors - // are very small but not quite zero.) + // If sdir andor tdir are zero, choose an arbitrary vector instead. (This + // is really the only reason we normalize sdir and tdir, though it also + // helps stabilize the math below in case the vectors are very small but not + // quite zero.) if (!sdir.normalize()) { sdir.set(1.0, 0.0, 0.0); } @@ -2069,8 +1857,8 @@ do_compute_tangent_binormal(const TBNVertexValue &value, // Shouldn't need to normalize this, but we do just for good measure. binormal.normalize(); - // Now we have the common tangent and binormal; apply them to all - // the vertices. + // Now we have the common tangent and binormal; apply them to all the + // vertices. for (gi = group.begin(); gi != group.end(); ++gi) { const TBNVertexReference &ref = (*gi); diff --git a/panda/src/egg/eggGroupNode.h b/panda/src/egg/eggGroupNode.h index b7c318941b..62dda7dd12 100644 --- a/panda/src/egg/eggGroupNode.h +++ b/panda/src/egg/eggGroupNode.h @@ -1,16 +1,15 @@ -// Filename: eggGroupNode.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupNode.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGGROUPNODE_H #define EGGGROUPNODE_H @@ -35,29 +34,25 @@ class EggVertex; class EggVertexPool; class DSearchPath; -//////////////////////////////////////////////////////////////////// -// Class : EggGroupNode -// Description : A base class for nodes in the hierarchy that are not -// leaf nodes. (See also EggGroup, which is -// specifically the "" node in egg.) -// -// An EggGroupNode is an STL-style container of pointers -// to EggNodes, like a vector. Functions -// push_back()/pop_back() and insert()/erase() are -// provided to manipulate the list. The list may also -// be operated on (read-only) via iterators and -// begin()/end(). -//////////////////////////////////////////////////////////////////// +/** + * A base class for nodes in the hierarchy that are not leaf nodes. (See also + * EggGroup, which is specifically the "" node in egg.) + * + * An EggGroupNode is an STL-style container of pointers to EggNodes, like a + * vector. Functions push_back()/pop_back() and insert()/erase() are provided + * to manipulate the list. The list may also be operated on (read-only) via + * iterators and begin()/end(). + */ class EXPCL_PANDAEGG EggGroupNode : public EggNode { - // This is a bit of private interface stuff that must be here as a - // forward reference. This allows us to define the EggGroupNode as - // an STL container. + // This is a bit of private interface stuff that must be here as a forward + // reference. This allows us to define the EggGroupNode as an STL + // container. private: - // We define the list of children as a list and not a vector, so we - // can avoid the bad iterator-invalidating properties of vectors as - // we insert/delete elements. + // We define the list of children as a list and not a vector, so we can + // avoid the bad iterator-invalidating properties of vectors as we + // insertdelete elements. typedef plist< PT(EggNode) > Children; // Here begins the actual public interface to EggGroupNode. @@ -70,10 +65,10 @@ PUBLISHED: virtual void write(ostream &out, int indent_level) const; - // The EggGroupNode itself appears to be an STL container of - // pointers to EggNodes. The set of children is read-only, however, - // except through the limited add_child/remove_child or insert/erase - // interface. The following implements this. + // The EggGroupNode itself appears to be an STL container of pointers to + // EggNodes. The set of children is read-only, however, except through the + // limited add_childremove_child or inserterase interface. The following + // implements this. public: #if defined(WIN32_VC) || defined(WIN64_VC) typedef const PT(EggNode) *pointer; @@ -106,10 +101,10 @@ PUBLISHED: size_type size() const; void clear(); - // This is an alternate way to traverse the list of children. It is - // mainly provided for scripting code, which can't use the iterators - // defined above (they don't export through interrogate very well). - // These are, of course, non-thread-safe. + // This is an alternate way to traverse the list of children. It is mainly + // provided for scripting code, which can't use the iterators defined above + // (they don't export through interrogate very well). These are, of course, + // non-thread-safe. EggNode *get_first_child(); EggNode *get_next_child(); @@ -162,7 +157,7 @@ PUBLISHED: virtual bool has_normals() const; public: - void rebuild_vertex_pools(EggVertexPools &vertex_pools, + void rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, bool recurse); @@ -180,7 +175,7 @@ protected: CoordinateSystem find_coordsys_entry(); int find_textures(EggTextureCollection *collection); int find_materials(EggMaterialCollection *collection); - bool r_load_externals(const DSearchPath &searchpath, + bool r_load_externals(const DSearchPath &searchpath, CoordinateSystem coordsys, BamCacheRecord *record); @@ -191,9 +186,9 @@ private: Children _children; const_iterator _gnc_iterator; - // Don't try to use these private functions. User code should add - // and remove children via add_child()/remove_child(), or via the - // STL-like push_back()/pop_back() or insert()/erase(), above. + // Don't try to use these private functions. User code should add and + // remove children via add_child()remove_child(), or via the STL-like + // push_back()pop_back() or insert()erase(), above. void prepare_add_child(EggNode *node); void prepare_remove_child(EggNode *node); @@ -260,4 +255,3 @@ private: #include "eggGroupNode.I" #endif - diff --git a/panda/src/egg/eggGroupNode_ext.cxx b/panda/src/egg/eggGroupNode_ext.cxx index 92b343b972..a0ac3fcb8e 100644 --- a/panda/src/egg/eggGroupNode_ext.cxx +++ b/panda/src/egg/eggGroupNode_ext.cxx @@ -1,16 +1,15 @@ -// Filename: eggGroupNode_ext.cxx -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupNode_ext.cxx + * @author rdb + * @date 2013-12-09 + */ #include "eggGroupNode_ext.h" @@ -20,11 +19,9 @@ extern struct Dtool_PyTypedObject Dtool_EggNode; #endif -//////////////////////////////////////////////////////////////////// -// Function: EggGroupNode::get_children -// Access: Published -// Description: Returns a Python list containing the node's children. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Python list containing the node's children. + */ PyObject *Extension:: get_children() const { EggGroupNode::iterator it; diff --git a/panda/src/egg/eggGroupNode_ext.h b/panda/src/egg/eggGroupNode_ext.h index ae29cc54b4..409ac08574 100644 --- a/panda/src/egg/eggGroupNode_ext.h +++ b/panda/src/egg/eggGroupNode_ext.h @@ -1,16 +1,15 @@ -// Filename: eggGroupNode_ext.h -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupNode_ext.h + * @author rdb + * @date 2013-12-09 + */ #ifndef EGGGROUPNODE_EXT_H #define EGGGROUPNODE_EXT_H @@ -23,12 +22,10 @@ #include "eggGroupNode.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// EggGroupNode, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for EggGroupNode, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/egg/eggGroupUniquifier.cxx b/panda/src/egg/eggGroupUniquifier.cxx index 6799175211..f19b15e10d 100644 --- a/panda/src/egg/eggGroupUniquifier.cxx +++ b/panda/src/egg/eggGroupUniquifier.cxx @@ -1,16 +1,15 @@ -// Filename: eggGroupUniquifier.cxx -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupUniquifier.cxx + * @author drose + * @date 2001-02-22 + */ #include "eggGroupUniquifier.h" #include "eggGroup.h" @@ -22,28 +21,22 @@ TypeHandle EggGroupUniquifier::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggGroupUniquifier::Constructor -// Access: Public -// Description: If filter_names is true, then the group names will be -// coerced into a fairly safe, standard convention that -// uses no characters other than a-z, A-Z, 0-9, and -// underscore. If filter_names is false, the group -// names will be left unchanged. -//////////////////////////////////////////////////////////////////// +/** + * If filter_names is true, then the group names will be coerced into a fairly + * safe, standard convention that uses no characters other than a-z, A-Z, 0-9, + * and underscore. If filter_names is false, the group names will be left + * unchanged. + */ EggGroupUniquifier:: EggGroupUniquifier(bool filter_names) : _filter_names(filter_names) { } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupUniquifier::get_category -// Access: Public -// Description: Returns the category name into which the given node -// should be collected, or the empty string if the -// node's name should be left alone. -//////////////////////////////////////////////////////////////////// +/** + * Returns the category name into which the given node should be collected, or + * the empty string if the node's name should be left alone. + */ string EggGroupUniquifier:: get_category(EggNode *node) { if (node->is_of_type(EggGroup::get_class_type()) && node->has_name()) { @@ -53,14 +46,11 @@ get_category(EggNode *node) { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupUniquifier::filter_name -// Access: Public, Virtual -// Description: Returns the name of the given node, or at least the -// name it should be. This provides a hook to adjust -// the name before attempting to uniquify it, if -// desired, for instance to remove invalid characters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the given node, or at least the name it should be. + * This provides a hook to adjust the name before attempting to uniquify it, + * if desired, for instance to remove invalid characters. + */ string EggGroupUniquifier:: filter_name(EggNode *node) { string name = node->get_name(); @@ -71,8 +61,8 @@ filter_name(EggNode *node) { string result; - // First, replace characters not A-Z, a-z, 0-9, or '_' with - // underscore, and remove consecutive underscores. + // First, replace characters not A-Z, a-z, 0-9, or '_' with underscore, and + // remove consecutive underscores. string::const_iterator pi; bool last_underscore = false; for (pi = name.begin(); pi != name.end(); ++pi) { @@ -95,18 +85,14 @@ filter_name(EggNode *node) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggGroupUniquifier::generate_name -// Access: Public, Virtual -// Description: Generates a new name for the given node when its -// existing name clashes with some other node. This -// function will be called repeatedly, if necessary, -// until it returns a name that actually is unique. -// -// The category is the string returned by -// get_category(), and index is a uniquely-generated -// number that may be useful for synthesizing the name. -//////////////////////////////////////////////////////////////////// +/** + * Generates a new name for the given node when its existing name clashes with + * some other node. This function will be called repeatedly, if necessary, + * until it returns a name that actually is unique. + * + * The category is the string returned by get_category(), and index is a + * uniquely-generated number that may be useful for synthesizing the name. + */ string EggGroupUniquifier:: generate_name(EggNode *node, const string &category, int index) { ostringstream str; diff --git a/panda/src/egg/eggGroupUniquifier.h b/panda/src/egg/eggGroupUniquifier.h index 4d6ce2c30f..97c3a12226 100644 --- a/panda/src/egg/eggGroupUniquifier.h +++ b/panda/src/egg/eggGroupUniquifier.h @@ -1,16 +1,15 @@ -// Filename: eggGroupUniquifier.h -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggGroupUniquifier.h + * @author drose + * @date 2001-02-22 + */ #ifndef EGGGROUPUNIQUIFIER_H #define EGGGROUPUNIQUIFIER_H @@ -19,13 +18,11 @@ #include "eggNameUniquifier.h" -//////////////////////////////////////////////////////////////////// -// Class : EggGroupUniquifier -// Description : This is a specialization of EggNameUniquifier to -// generate unique names for EggGroup nodes. It's not -// called automatically; you must invoke it yourself if -// you want it. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization of EggNameUniquifier to generate unique names for + * EggGroup nodes. It's not called automatically; you must invoke it yourself + * if you want it. + */ class EXPCL_PANDAEGG EggGroupUniquifier : public EggNameUniquifier { PUBLISHED: EggGroupUniquifier(bool filter_names = true); @@ -58,5 +55,3 @@ private: }; #endif - - diff --git a/panda/src/egg/eggLine.I b/panda/src/egg/eggLine.I index 525ec83337..39e894e798 100644 --- a/panda/src/egg/eggLine.I +++ b/panda/src/egg/eggLine.I @@ -1,48 +1,40 @@ -// Filename: eggLine.I -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLine.I + * @author drose + * @date 2003-10-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggLine::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggLine:: -EggLine(const string &name) : +EggLine(const string &name) : EggCompositePrimitive(name), _has_thick(false) { } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggLine:: -EggLine(const EggLine ©) : +EggLine(const EggLine ©) : EggCompositePrimitive(copy), _thick(copy._thick), _has_thick(copy._has_thick) { } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggLine &EggLine:: operator = (const EggLine ©) { EggCompositePrimitive::operator = (copy); @@ -51,22 +43,18 @@ operator = (const EggLine ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::has_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggLine:: has_thick() const { return _has_thick; } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::get_thick -// Access: Published -// Description: Returns the thickness set on this particular line. -// If there is no thickness set, returns 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the thickness set on this particular line. If there is no + * thickness set, returns 1.0. + */ INLINE double EggLine:: get_thick() const { if (has_thick()) { @@ -76,22 +64,18 @@ get_thick() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::set_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggLine:: set_thick(double thick) { _thick = thick; _has_thick = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::clear_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggLine:: clear_thick() { _has_thick = false; diff --git a/panda/src/egg/eggLine.cxx b/panda/src/egg/eggLine.cxx index 81fd58bd64..4da9b87d7d 100644 --- a/panda/src/egg/eggLine.cxx +++ b/panda/src/egg/eggLine.cxx @@ -1,16 +1,15 @@ -// Filename: eggLine.cxx -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLine.cxx + * @author drose + * @date 2003-10-14 + */ #include "eggLine.h" @@ -19,28 +18,23 @@ TypeHandle EggLine::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggLine::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggLine:: ~EggLine() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::write -// Access: Public, Virtual -// Description: Writes the point to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the point to the indicated output stream in Egg format. + */ void EggLine:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " thick { " << get_thick() << " }\n"; } @@ -48,14 +42,11 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggLine::get_num_lead_vertices -// Access: Protected, Virtual -// Description: Returns the number of initial vertices that are not -// used in defining any component; the first component -// is defined by the (n + 1)th vertex, and then a new -// component at each vertex thereafter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of initial vertices that are not used in defining any + * component; the first component is defined by the (n + 1)th vertex, and then + * a new component at each vertex thereafter. + */ int EggLine:: get_num_lead_vertices() const { return 1; diff --git a/panda/src/egg/eggLine.h b/panda/src/egg/eggLine.h index 8996dd01d8..ce036c40f3 100644 --- a/panda/src/egg/eggLine.h +++ b/panda/src/egg/eggLine.h @@ -1,16 +1,15 @@ -// Filename: eggLine.h -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLine.h + * @author drose + * @date 2003-10-14 + */ #ifndef EGGLINE_H #define EGGLINE_H @@ -19,11 +18,10 @@ #include "eggCompositePrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggLine -// Description : A line segment, or a series of connected line -// segments, defined by a entry. -//////////////////////////////////////////////////////////////////// +/** + * A line segment, or a series of connected line segments, defined by a + * entry. + */ class EXPCL_PANDAEGG EggLine : public EggCompositePrimitive { PUBLISHED: INLINE EggLine(const string &name = ""); diff --git a/panda/src/egg/eggMaterial.I b/panda/src/egg/eggMaterial.I index 4b6560ec13..f12a50c00d 100644 --- a/panda/src/egg/eggMaterial.I +++ b/panda/src/egg/eggMaterial.I @@ -1,56 +1,45 @@ -// Filename: eggMaterial.I -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterial.I + * @author drose + * @date 1999-01-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_base -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_base(const LColor &base) { _base = base; _flags |= F_base; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_base -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_base() { _flags &= ~F_base; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_base -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_base() const { return (_flags & F_base) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_base -// Access: Public -// Description: It is legal to call this even if has_base() returns -// false. If so, it simply returns the default base -// color. -//////////////////////////////////////////////////////////////////// +/** + * It is legal to call this even if has_base() returns false. If so, it + * simply returns the default base color. + */ INLINE LColor EggMaterial:: get_base() const { if (has_base()) { @@ -60,44 +49,35 @@ get_base() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_diff -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_diff(const LColor &diff) { _diff = diff; _flags |= F_diff; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_diff -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_diff() { _flags &= ~F_diff; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_diff -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_diff() const { return (_flags & F_diff) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_diff -// Access: Public -// Description: It is legal to call this even if has_diff() returns -// false. If so, it simply returns the default diff -// color. -//////////////////////////////////////////////////////////////////// +/** + * It is legal to call this even if has_diff() returns false. If so, it + * simply returns the default diff color. + */ INLINE LColor EggMaterial:: get_diff() const { if (has_diff()) { @@ -107,44 +87,35 @@ get_diff() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_amb -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_amb(const LColor &amb) { _amb = amb; _flags |= F_amb; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_amb -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_amb() { _flags &= ~F_amb; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_amb -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_amb() const { return (_flags & F_amb) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_amb -// Access: Public -// Description: It is legal to call this even if has_amb() returns -// false. If so, it simply returns the default amb -// color. -//////////////////////////////////////////////////////////////////// +/** + * It is legal to call this even if has_amb() returns false. If so, it simply + * returns the default amb color. + */ INLINE LColor EggMaterial:: get_amb() const { if (has_amb()) { @@ -154,44 +125,35 @@ get_amb() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_emit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_emit(const LColor &emit) { _emit = emit; _flags |= F_emit; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_emit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_emit() { _flags &= ~F_emit; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_emit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_emit() const { return (_flags & F_emit) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_emit -// Access: Public -// Description: It is legal to call this even if has_emit() returns -// false. If so, it simply returns the default emit -// color. -//////////////////////////////////////////////////////////////////// +/** + * It is legal to call this even if has_emit() returns false. If so, it + * simply returns the default emit color. + */ INLINE LColor EggMaterial:: get_emit() const { if (has_emit()) { @@ -201,44 +163,35 @@ get_emit() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_spec -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_spec(const LColor &spec) { _spec = spec; _flags |= F_spec; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_spec -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_spec() { _flags &= ~F_spec; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_spec -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_spec() const { return (_flags & F_spec) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_spec -// Access: Public -// Description: It is legal to call this even if has_spec() returns -// false. If so, it simply returns the default spec -// color. -//////////////////////////////////////////////////////////////////// +/** + * It is legal to call this even if has_spec() returns false. If so, it + * simply returns the default spec color. + */ INLINE LColor EggMaterial:: get_spec() const { if (has_spec()) { @@ -248,42 +201,34 @@ get_spec() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_shininess -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_shininess(double shininess) { _shininess = shininess; _flags |= F_shininess; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_shininess -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_shininess() { _flags &= ~F_shininess; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_shininess -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_shininess() const { return (_flags & F_shininess) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_shininess -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double EggMaterial:: get_shininess() const { if (has_shininess()) { @@ -293,42 +238,34 @@ get_shininess() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_roughness -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_roughness(double roughness) { _roughness = roughness; _flags |= F_roughness; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_roughness -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_roughness() { _flags &= ~F_roughness; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_roughness -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_roughness() const { return (_flags & F_roughness) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_roughness -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double EggMaterial:: get_roughness() const { if (has_roughness()) { @@ -338,42 +275,34 @@ get_roughness() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_metallic -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_metallic(double metallic) { _metallic = metallic; _flags |= F_metallic; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_metallic -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_metallic() { _flags &= ~F_metallic; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_metallic -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_metallic() const { return (_flags & F_metallic) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_metallic -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double EggMaterial:: get_metallic() const { if (has_metallic()) { @@ -383,42 +312,34 @@ get_metallic() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_ior -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_ior(double ior) { _ior = ior; _flags |= F_ior; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_ior -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_ior() { _flags &= ~F_ior; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_ior -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_ior() const { return (_flags & F_ior) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_ior -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double EggMaterial:: get_ior() const { if (has_ior()) { @@ -428,42 +349,34 @@ get_ior() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::set_local -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: set_local(bool local) { _local = local; _flags |= F_local; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::clear_local -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggMaterial:: clear_local() { _flags &= ~F_local; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::has_local -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: has_local() const { return (_flags & F_local) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::get_local -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMaterial:: get_local() const { if (has_local()) { @@ -473,22 +386,17 @@ get_local() const { } } -//////////////////////////////////////////////////////////////////// -// Function: UniqueEggMaterials::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UniqueEggMaterials:: UniqueEggMaterials(int eq) : _eq(eq) { } -//////////////////////////////////////////////////////////////////// -// Function: UniqueEggMaterials::Function operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool UniqueEggMaterials:: operator ()(const EggMaterial *t1, const EggMaterial *t2) const { return t1->sorts_less_than(*t2, _eq); } - diff --git a/panda/src/egg/eggMaterial.cxx b/panda/src/egg/eggMaterial.cxx index c9121a0d39..8a77c9c0cc 100644 --- a/panda/src/egg/eggMaterial.cxx +++ b/panda/src/egg/eggMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: eggMaterial.cxx -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterial.cxx + * @author drose + * @date 1999-01-29 + */ #include "eggMaterial.h" @@ -19,11 +18,9 @@ TypeHandle EggMaterial::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterial:: EggMaterial(const string &mref_name) : EggNode(mref_name) @@ -31,11 +28,9 @@ EggMaterial(const string &mref_name) _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterial:: EggMaterial(const EggMaterial ©) : EggNode(copy), @@ -54,12 +49,10 @@ EggMaterial(const EggMaterial ©) } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::write -// Access: Public, Virtual -// Description: Writes the material definition to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the material definition to the indicated output stream in Egg + * format. + */ void EggMaterial:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -157,24 +150,18 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::is_equivalent_to -// Access: Public -// Description: Returns true if the two materials are equivalent in -// all relevant properties (according to eq), false -// otherwise. -// -// The Equivalence parameter, eq, should be set to the -// bitwise OR of the following properties, according to -// what you consider relevant: -// -// EggMaterial::E_attributes: -// All material attributes (diff, spec, -// etc.) except MRef name. -// -// EggMaterial::E_mref_name: -// The MRef name. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two materials are equivalent in all relevant properties + * (according to eq), false otherwise. + * + * The Equivalence parameter, eq, should be set to the bitwise OR of the + * following properties, according to what you consider relevant: + * + * EggMaterial::E_attributes: All material attributes (diff, spec, etc.) + * except MRef name. + * + * EggMaterial::E_mref_name: The MRef name. + */ bool EggMaterial:: is_equivalent_to(const EggMaterial &other, int eq) const { if (eq & E_attributes) { @@ -202,15 +189,11 @@ is_equivalent_to(const EggMaterial &other, int eq) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterial::sorts_less_than -// Access: Public -// Description: An ordering operator to compare two materials for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique materials, according to the -// indicated Equivalence factor. See -// is_equivalent_to(). -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two materials for sorting order. This + * imposes an arbitrary ordering useful to identify unique materials, + * according to the indicated Equivalence factor. See is_equivalent_to(). + */ bool EggMaterial:: sorts_less_than(const EggMaterial &other, int eq) const { if (eq & E_attributes) { diff --git a/panda/src/egg/eggMaterial.h b/panda/src/egg/eggMaterial.h index ddc4fcfd60..a28d779699 100644 --- a/panda/src/egg/eggMaterial.h +++ b/panda/src/egg/eggMaterial.h @@ -1,16 +1,15 @@ -// Filename: eggMaterial.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterial.h + * @author drose + * @date 1999-01-29 + */ #ifndef EGGMATERIAL_H #define EGGMATERIAL_H @@ -21,10 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMaterial -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAEGG EggMaterial : public EggNode { PUBLISHED: EggMaterial(const string &mref_name); @@ -148,13 +146,11 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : UniqueEggMaterials -// Description : An STL function object for sorting materials into -// order by properties. Returns true if the two -// referenced EggMaterial pointers are in sorted order, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object for sorting materials into order by properties. + * Returns true if the two referenced EggMaterial pointers are in sorted + * order, false otherwise. + */ class EXPCL_PANDAEGG UniqueEggMaterials { public: INLINE UniqueEggMaterials(int eq = ~0); diff --git a/panda/src/egg/eggMaterialCollection.I b/panda/src/egg/eggMaterialCollection.I index d768b25567..49777ab014 100644 --- a/panda/src/egg/eggMaterialCollection.I +++ b/panda/src/egg/eggMaterialCollection.I @@ -1,16 +1,15 @@ -// Filename: eggMaterialCollection.I -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterialCollection.I + * @author drose + * @date 2001-04-30 + */ INLINE EggMaterialCollection::iterator EggMaterialCollection:: begin() const { diff --git a/panda/src/egg/eggMaterialCollection.cxx b/panda/src/egg/eggMaterialCollection.cxx index 4b91ffed57..b89f3a1900 100644 --- a/panda/src/egg/eggMaterialCollection.cxx +++ b/panda/src/egg/eggMaterialCollection.cxx @@ -1,16 +1,15 @@ -// Filename: eggMaterialCollection.cxx -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterialCollection.cxx + * @author drose + * @date 2001-04-30 + */ #include "eggMaterialCollection.h" #include "eggGroupNode.h" @@ -22,20 +21,16 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterialCollection:: EggMaterialCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterialCollection:: EggMaterialCollection(const EggMaterialCollection ©) : _materials(copy._materials), @@ -43,11 +38,9 @@ EggMaterialCollection(const EggMaterialCollection ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterialCollection &EggMaterialCollection:: operator = (const EggMaterialCollection ©) { _materials = copy._materials; @@ -55,34 +48,27 @@ operator = (const EggMaterialCollection ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMaterialCollection:: ~EggMaterialCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::clear -// Access: Public -// Description: Removes all materials from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all materials from the collection. + */ void EggMaterialCollection:: clear() { _materials.clear(); _ordered_materials.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::extract_materials -// Access: Public -// Description: Walks the egg hierarchy beginning at the indicated -// node, and removes any EggMaterials encountered in the -// hierarchy, adding them to the collection. Returns -// the number of EggMaterials encountered. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy beginning at the indicated node, and removes any + * EggMaterials encountered in the hierarchy, adding them to the collection. + * Returns the number of EggMaterials encountered. + */ int EggMaterialCollection:: extract_materials(EggGroupNode *node) { // Since this traversal is destructive, we'll handle it within the @@ -90,27 +76,21 @@ extract_materials(EggGroupNode *node) { return node->find_materials(this); } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::insert_materials -// Access: Public -// Description: Adds a series of EggMaterial nodes to the beginning of -// the indicated node to reflect each of the materials in -// the collection. Returns an iterator representing the -// first position after the newly inserted materials. -//////////////////////////////////////////////////////////////////// +/** + * Adds a series of EggMaterial nodes to the beginning of the indicated node + * to reflect each of the materials in the collection. Returns an iterator + * representing the first position after the newly inserted materials. + */ EggGroupNode::iterator EggMaterialCollection:: insert_materials(EggGroupNode *node) { return insert_materials(node, node->begin()); } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::insert_materials -// Access: Public -// Description: Adds a series of EggMaterial nodes to the beginning of -// the indicated node to reflect each of the materials in -// the collection. Returns an iterator representing the -// first position after the newly inserted materials. -//////////////////////////////////////////////////////////////////// +/** + * Adds a series of EggMaterial nodes to the beginning of the indicated node + * to reflect each of the materials in the collection. Returns an iterator + * representing the first position after the newly inserted materials. + */ EggGroupNode::iterator EggMaterialCollection:: insert_materials(EggGroupNode *node, EggGroupNode::iterator position) { OrderedMaterials::iterator oti; @@ -124,32 +104,24 @@ insert_materials(EggGroupNode *node, EggGroupNode::iterator position) { return position; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::find_used_materials -// Access: Public -// Description: Walks the egg hierarchy beginning at the indicated -// node, looking for materials that are referenced by -// primitives but are not already members of the -// collection, adding them to the collection. -// -// If this is called following extract_materials(), it -// can be used to pick up any additional material -// references that appeared in the egg hierarchy (but -// whose EggMaterial node was not actually part of the -// hierarchy). -// -// If this is called in lieu of extract_materials(), it -// will fill up the collection with all of the -// referenced materials (and only the referenced -// materials), without destructively removing the -// EggMaterials from the hierarchy. -// -// This also has the side effect of incrementing the -// internal usage count for a material in the collection -// each time a material reference is encountered. This -// side effect is taken advantage of by -// remove_unused_materials(). -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy beginning at the indicated node, looking for + * materials that are referenced by primitives but are not already members of + * the collection, adding them to the collection. + * + * If this is called following extract_materials(), it can be used to pick up + * any additional material references that appeared in the egg hierarchy (but + * whose EggMaterial node was not actually part of the hierarchy). + * + * If this is called in lieu of extract_materials(), it will fill up the + * collection with all of the referenced materials (and only the referenced + * materials), without destructively removing the EggMaterials from the + * hierarchy. + * + * This also has the side effect of incrementing the internal usage count for + * a material in the collection each time a material reference is encountered. + * This side effect is taken advantage of by remove_unused_materials(). + */ int EggMaterialCollection:: find_used_materials(EggNode *node) { int num_found = 0; @@ -165,8 +137,8 @@ find_used_materials(EggNode *node) { _materials.insert(Materials::value_type(tex, 1)); _ordered_materials.push_back(tex); } else { - // Here's a material we'd already known about. Increment its - // usage count. + // Here's a material we'd already known about. Increment its usage + // count. (*ti).second++; } } @@ -185,66 +157,54 @@ find_used_materials(EggNode *node) { return num_found; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::remove_unused_materials -// Access: Public -// Description: Removes any materials from the collection that aren't -// referenced by any primitives in the indicated egg -// hierarchy. This also, incidentally, adds materials to -// the collection that had been referenced by primitives -// but had not previously appeared in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes any materials from the collection that aren't referenced by any + * primitives in the indicated egg hierarchy. This also, incidentally, adds + * materials to the collection that had been referenced by primitives but had + * not previously appeared in the collection. + */ void EggMaterialCollection:: remove_unused_materials(EggNode *node) { - // We'll do this the easy way: First, we'll remove *all* the - // materials from the collection, and then we'll add back only those - // that appear in the hierarchy. + // We'll do this the easy way: First, we'll remove *all* the materials from + // the collection, and then we'll add back only those that appear in the + // hierarchy. clear(); find_used_materials(node); } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::collapse_equivalent_materials -// Access: Public -// Description: Walks through the collection and collapses together -// any separate materials that are equivalent according -// to the indicated equivalence factor, eq (see -// EggMaterial::is_equivalent_to()). The return value is -// the number of materials removed. -// -// This flavor of collapse_equivalent_materials() -// automatically adjusts all the primitives in the egg -// hierarchy to refer to the new material pointers. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the collection and collapses together any separate materials + * that are equivalent according to the indicated equivalence factor, eq (see + * EggMaterial::is_equivalent_to()). The return value is the number of + * materials removed. + * + * This flavor of collapse_equivalent_materials() automatically adjusts all + * the primitives in the egg hierarchy to refer to the new material pointers. + */ int EggMaterialCollection:: collapse_equivalent_materials(int eq, EggGroupNode *node) { MaterialReplacement removed; int num_collapsed = collapse_equivalent_materials(eq, removed); - // And now walk the egg hierarchy and replace any references to a - // removed material with its replacement. + // And now walk the egg hierarchy and replace any references to a removed + // material with its replacement. replace_materials(node, removed); return num_collapsed; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::collapse_equivalent_materials -// Access: Public -// Description: Walks through the collection and collapses together -// any separate materials that are equivalent according -// to the indicated equivalence factor, eq (see -// EggMaterial::is_equivalent_to()). The return value is -// the number of materials removed. -// -// This flavor of collapse_equivalent_materials() does -// not adjust any primitives in the egg hierarchy; -// instead, it fills up the 'removed' map with an entry -// for each removed material, mapping it back to the -// equivalent retained material. It's up to the user to -// then call replace_materials() with this map, if -// desired, to apply these changes to the egg hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the collection and collapses together any separate materials + * that are equivalent according to the indicated equivalence factor, eq (see + * EggMaterial::is_equivalent_to()). The return value is the number of + * materials removed. + * + * This flavor of collapse_equivalent_materials() does not adjust any + * primitives in the egg hierarchy; instead, it fills up the 'removed' map + * with an entry for each removed material, mapping it back to the equivalent + * retained material. It's up to the user to then call replace_materials() + * with this map, if desired, to apply these changes to the egg hierarchy. + */ int EggMaterialCollection:: collapse_equivalent_materials(int eq, EggMaterialCollection::MaterialReplacement &removed) { int num_collapsed = 0; @@ -253,8 +213,8 @@ collapse_equivalent_materials(int eq, EggMaterialCollection::MaterialReplacement UniqueEggMaterials uet(eq); Collapser collapser(uet); - // First, put all of the materials into the Collapser structure, to - // find out the unique materials. + // First, put all of the materials into the Collapser structure, to find out + // the unique materials. OrderedMaterials::const_iterator oti; for (oti = _ordered_materials.begin(); oti != _ordered_materials.end(); @@ -280,16 +240,13 @@ collapse_equivalent_materials(int eq, EggMaterialCollection::MaterialReplacement return num_collapsed; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::replace_materials -// Access: Public, Static -// Description: Walks the egg hierarchy, changing out any reference -// to a material appearing on the left side of the map -// with its corresponding material on the right side. -// This is most often done following a call to -// collapse_equivalent_materials(). It does not directly -// affect the Collection. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy, changing out any reference to a material appearing + * on the left side of the map with its corresponding material on the right + * side. This is most often done following a call to + * collapse_equivalent_materials(). It does not directly affect the + * Collection. + */ void EggMaterialCollection:: replace_materials(EggGroupNode *node, const EggMaterialCollection::MaterialReplacement &replace) { @@ -317,13 +274,10 @@ replace_materials(EggGroupNode *node, } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::uniquify_mrefs -// Access: Public -// Description: Guarantees that each material in the collection has a -// unique MRef name. This is essential before writing -// an egg file. -//////////////////////////////////////////////////////////////////// +/** + * Guarantees that each material in the collection has a unique MRef name. + * This is essential before writing an egg file. + */ void EggMaterialCollection:: uniquify_mrefs() { NameUniquifier nu(".mref", "mref"); @@ -338,26 +292,21 @@ uniquify_mrefs() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::sort_by_mref -// Access: Public -// Description: Sorts all the materials into alphabetical order by -// MRef name. Subsequent operations using begin()/end() -// will traverse in this sorted order. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the materials into alphabetical order by MRef name. Subsequent + * operations using begin()/end() will traverse in this sorted order. + */ void EggMaterialCollection:: sort_by_mref() { sort(_ordered_materials.begin(), _ordered_materials.end(), NamableOrderByName()); } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::add_material -// Access: Public -// Description: Explicitly adds a new material to the collection. -// Returns true if the material was added, false if it -// was already there or if there was some error. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly adds a new material to the collection. Returns true if the + * material was added, false if it was already there or if there was some + * error. + */ bool EggMaterialCollection:: add_material(EggMaterial *material) { nassertr(_materials.size() == _ordered_materials.size(), false); @@ -378,13 +327,10 @@ add_material(EggMaterial *material) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::remove_material -// Access: Public -// Description: Explicitly removes a material from the collection. -// Returns true if the material was removed, false if it -// wasn't there or if there was some error. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly removes a material from the collection. Returns true if the + * material was removed, false if it wasn't there or if there was some error. + */ bool EggMaterialCollection:: remove_material(EggMaterial *material) { nassertr(_materials.size() == _ordered_materials.size(), false); @@ -409,18 +355,14 @@ remove_material(EggMaterial *material) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::create_unique_material -// Access: Public -// Description: Creates a new material if there is not already one -// equivalent (according to eq, see -// EggMaterial::is_equivalent_to()) to the indicated -// material, or returns the existing one if there is. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new material if there is not already one equivalent (according to + * eq, see EggMaterial::is_equivalent_to()) to the indicated material, or + * returns the existing one if there is. + */ EggMaterial *EggMaterialCollection:: create_unique_material(const EggMaterial ©, int eq) { - // This requires a complete linear traversal, not terribly - // efficient. + // This requires a complete linear traversal, not terribly efficient. OrderedMaterials::const_iterator oti; for (oti = _ordered_materials.begin(); oti != _ordered_materials.end(); @@ -436,16 +378,13 @@ create_unique_material(const EggMaterial ©, int eq) { return new_material; } -//////////////////////////////////////////////////////////////////// -// Function: EggMaterialCollection::find_mref -// Access: Public -// Description: Returns the material with the indicated MRef name, or -// NULL if no material matches. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material with the indicated MRef name, or NULL if no material + * matches. + */ EggMaterial *EggMaterialCollection:: find_mref(const string &mref_name) const { - // This requires a complete linear traversal, not terribly - // efficient. + // This requires a complete linear traversal, not terribly efficient. OrderedMaterials::const_iterator oti; for (oti = _ordered_materials.begin(); oti != _ordered_materials.end(); diff --git a/panda/src/egg/eggMaterialCollection.h b/panda/src/egg/eggMaterialCollection.h index 5f7d01a0dd..1041f2f668 100644 --- a/panda/src/egg/eggMaterialCollection.h +++ b/panda/src/egg/eggMaterialCollection.h @@ -1,16 +1,15 @@ -// Filename: eggMaterialCollection.h -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMaterialCollection.h + * @author drose + * @date 2001-04-30 + */ #ifndef EGGMATERIALCOLLECTION_H #define EGGMATERIALCOLLECTION_H @@ -23,19 +22,16 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMaterialCollection -// Description : This is a collection of materials by MRef name. It -// can extract the materials from an egg file and sort -// them all together; it can also manage the creation of -// unique materials and the assignment of unique MRef -// names. -//////////////////////////////////////////////////////////////////// +/** + * This is a collection of materials by MRef name. It can extract the + * materials from an egg file and sort them all together; it can also manage + * the creation of unique materials and the assignment of unique MRef names. + */ class EXPCL_PANDAEGG EggMaterialCollection { - // This is a bit of private interface stuff that must be here as a - // forward reference. This allows us to define the - // EggMaterialCollection as an STL container. + // This is a bit of private interface stuff that must be here as a forward + // reference. This allows us to define the EggMaterialCollection as an STL + // container. private: typedef pmap Materials; @@ -76,8 +72,8 @@ PUBLISHED: void uniquify_mrefs(); void sort_by_mref(); - // Can be used to traverse all the materials in the collection, in - // order as last sorted. + // Can be used to traverse all the materials in the collection, in order as + // last sorted. public: INLINE iterator begin() const; INLINE iterator end() const; @@ -88,10 +84,9 @@ PUBLISHED: bool add_material(EggMaterial *material); bool remove_material(EggMaterial *material); - // create_unique_material() creates a new material if there is not - // already one equivalent (according to eq, see - // EggMaterial::is_equivalent_to()) to the indicated material, or - // returns the existing one if there is. + // create_unique_material() creates a new material if there is not already + // one equivalent (according to eq, see EggMaterial::is_equivalent_to()) to + // the indicated material, or returns the existing one if there is. EggMaterial *create_unique_material(const EggMaterial ©, int eq); // Find a material with a particular MRef name. diff --git a/panda/src/egg/eggMesher.I b/panda/src/egg/eggMesher.I index b482909dfb..9a9df069ed 100644 --- a/panda/src/egg/eggMesher.I +++ b/panda/src/egg/eggMesher.I @@ -1,14 +1,12 @@ -// Filename: eggMesher.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesher.I + * @author drose + * @date 2005-03-13 + */ diff --git a/panda/src/egg/eggMesher.cxx b/panda/src/egg/eggMesher.cxx index d81a5efc71..98e583b3e0 100644 --- a/panda/src/egg/eggMesher.cxx +++ b/panda/src/egg/eggMesher.cxx @@ -1,16 +1,15 @@ -// Filename: eggMesher.cxx -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesher.cxx + * @author drose + * @date 2005-03-13 + */ #include "eggMesher.h" #include "eggMesherFanMaker.h" @@ -26,49 +25,40 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMesher:: EggMesher() { _vertex_pool = NULL; _strip_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::mesh -// Access: Public -// Description: Accepts an EggGroupNode, which contains a set of -// EggPrimitives--typically, triangles and quads--as -// children. Removes these primitives and replaces them -// with (mostly) equivalent EggTriangleStrips and -// EggTriangleFans where possible. -// -// If flat_shaded is true, then odd-length triangle -// strips, and triangle fans of any length, are not -// permitted (because these can't be rotated when -// required to move the colored vertex of each triangle -// to the first or last position). -//////////////////////////////////////////////////////////////////// +/** + * Accepts an EggGroupNode, which contains a set of EggPrimitives--typically, + * triangles and quads--as children. Removes these primitives and replaces + * them with (mostly) equivalent EggTriangleStrips and EggTriangleFans where + * possible. + * + * If flat_shaded is true, then odd-length triangle strips, and triangle fans + * of any length, are not permitted (because these can't be rotated when + * required to move the colored vertex of each triangle to the first or last + * position). + */ void EggMesher:: mesh(EggGroupNode *group, bool flat_shaded) { _flat_shaded = flat_shaded; // Create a temporary node to hold the children of group that aren't - // involved in the meshing, as well as the newly-generate triangle - // strips. + // involved in the meshing, as well as the newly-generate triangle strips. PT(EggGroupNode) output_children = new EggGroupNode; - // And another to hold the children that will be processed next - // time. + // And another to hold the children that will be processed next time. PT(EggGroupNode) next_children = new EggGroupNode; PT(EggGroupNode) this_children = group; - // Only primitives that share a common vertex pool can be meshed - // together. Thus, pull out the primitives with the same vertex - // pool in groups. + // Only primitives that share a common vertex pool can be meshed together. + // Thus, pull out the primitives with the same vertex pool in groups. while (this_children->size() != 0) { clear(); @@ -76,7 +66,7 @@ mesh(EggGroupNode *group, bool flat_shaded) { while (!this_children->empty()) { PT(EggNode) child = this_children->get_first_child(); this_children->remove_child(child); - + if (child->is_of_type(EggPolygon::get_class_type())) { EggPolygon *poly = DCAST(EggPolygon, child); @@ -93,14 +83,13 @@ mesh(EggGroupNode *group, bool flat_shaded) { } } else { - // If it's not a polygon of any kind, just output it - // unchanged. + // If it's not a polygon of any kind, just output it unchanged. output_children->add_child(child); } } - + do_mesh(); - + Strips::iterator si; for (si = _done.begin(); si != _done.end(); ++si) { PT(EggPrimitive) egg_prim = get_prim(*si); @@ -120,11 +109,9 @@ mesh(EggGroupNode *group, bool flat_shaded) { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMesher:: write(ostream &out) const { /* @@ -164,12 +151,9 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::clear -// Access: Private -// Description: Empties the pool of meshable primitives and resets to -// an initial state. -//////////////////////////////////////////////////////////////////// +/** + * Empties the pool of meshable primitives and resets to an initial state. + */ void EggMesher:: clear() { _tris.clear(); @@ -184,12 +168,9 @@ clear() { _color_sheets.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::add_polygon -// Access: Private -// Description: Adds a single polygon into the pool of available -// primitives for meshing. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single polygon into the pool of available primitives for meshing. + */ bool EggMesher:: add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { CPT(EggPolygon) this_poly = egg_poly; @@ -210,8 +191,8 @@ add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { return result; } - // Convert just the one polygon we got out of the group. Don't - // recurse, since it might be the same polygon we sent in. + // Convert just the one polygon we got out of the group. Don't recurse, + // since it might be the same polygon we sent in. ci = temp_group->begin(); this_poly = DCAST(EggPolygon, *ci); } @@ -223,7 +204,7 @@ add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { } // Define an initial strip (probably of length 1) for the prim. - EggMesherStrip temp_strip(this_poly, _strip_index++, _vertex_pool, + EggMesherStrip temp_strip(this_poly, _strip_index++, _vertex_pool, _flat_shaded); Strips &list = choose_strip_list(temp_strip); list.push_back(temp_strip); @@ -250,41 +231,38 @@ add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin) { // Now identify the common edges. for (i = 0; i < num_verts; i++) { // Define an inner and outer edge. A polygon shares an edge with a - // neighbor only when one of its inner edges matches a neighbor's - // outer edge (and vice-versa). + // neighbor only when one of its inner edges matches a neighbor's outer + // edge (and vice-versa). EggMesherEdge inner(vptrs[i], vptrs[(i+1) % num_verts]); EggMesherEdge outer(vptrs[(i+1) % num_verts], vptrs[i]); - + // Add it to the list and get its common pointer. EggMesherEdge &inner_ref = (EggMesherEdge &)*_edges.insert(inner).first; EggMesherEdge &outer_ref = (EggMesherEdge &)*_edges.insert(outer).first; - + // Tell the edges about each other. inner_ref._opposite = &outer_ref; outer_ref._opposite = &inner_ref; - + // Associate the common edge to the strip. strip._edges.push_back(&inner_ref); - + // Associate the strip, as well as the original prim, to the edge. outer_ref._strips.push_back(&strip); - + // Associate the common edge with the vertices that share it. - // EggMesherEdge *edge_ptr = inner_ref.common_ptr(); + // EggMesherEdge *edge_ptr = inner_ref.common_ptr(); eptrs[i]->insert(&outer_ref); eptrs[(i+1) % num_verts]->insert(&outer_ref); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::do_mesh -// Access: Private -// Description: Performs the meshing process on the set of primitives -// that have been added via add_prim(), leaving the -// result in _done. -//////////////////////////////////////////////////////////////////// +/** + * Performs the meshing process on the set of primitives that have been added + * via add_prim(), leaving the result in _done. + */ void EggMesher:: do_mesh() { if (egg_consider_fans && !_flat_shaded) { @@ -326,12 +304,10 @@ do_mesh() { Thread::consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::get_prim -// Access: Private -// Description: Creates an EggPrimitive that represents the result of -// the meshed EggMesherStrip object. -//////////////////////////////////////////////////////////////////// +/** + * Creates an EggPrimitive that represents the result of the meshed + * EggMesherStrip object. + */ PT(EggPrimitive) EggMesher:: get_prim(EggMesherStrip &strip) { EggMesherStrip::PrimType orig_type = strip._type; @@ -354,8 +330,8 @@ get_prim(EggMesherStrip &strip) { color2.set(0.85, 0.85, 0.85, 1.0); } - // Now color1 and color2 indicate the color for the first triangle - // and the rest of the primitive, respectively. + // Now color1 and color2 indicate the color for the first triangle and the + // rest of the primitive, respectively. if (egg_prim->is_of_type(EggCompositePrimitive::get_class_type())) { EggCompositePrimitive *egg_comp = DCAST(EggCompositePrimitive, egg_prim); int num_components = egg_comp->get_num_components(); @@ -375,9 +351,9 @@ get_prim(EggMesherStrip &strip) { } } else if (egg_show_qsheets) { - // egg_show_qsheets means to color every primitive according to - // which, if any, quadsheet it is in. This is a bit easier, - // because the entire primitive gets the same color. + // egg_show_qsheets means to color every primitive according to which, if + // any, quadsheet it is in. This is a bit easier, because the entire + // primitive gets the same color. // Is this a quadsheet? LColor color1; @@ -393,8 +369,7 @@ get_prim(EggMesherStrip &strip) { } } - // Now color1 is the color we want to assign to the whole - // primitive. + // Now color1 is the color we want to assign to the whole primitive. egg_prim->set_color(color1); if (egg_prim->is_of_type(EggCompositePrimitive::get_class_type())) { EggCompositePrimitive *egg_comp = DCAST(EggCompositePrimitive, egg_prim); @@ -409,17 +384,16 @@ get_prim(EggMesherStrip &strip) { } } else if (egg_show_quads) { - // egg_show_quads means to show the assembling of tris into quads - // and fans. + // egg_show_quads means to show the assembling of tris into quads and + // fans. // We use the following color convention: - // white: unchanged; as supplied by user. - // dark blue: quads made in the initial pass. These are more certain. - // light blue: quads made in the second pass. These are less certain. - // very light blue: quadstrips. These are unlikely to appear. - // random shades of red: triangles and tristrips. - // green: fans and retesselated fan polygons. + // white: unchanged; as supplied by user. dark blue: quads made in the + // initial pass. These are more certain. light blue: quads made in the + // second pass. These are less certain. very light blue: quadstrips. + // These are unlikely to appear. random shades of red: triangles and + // tristrips. green: fans and retesselated fan polygons. // We need a handful of entries. LColor white(0.85, 0.85, 0.85, 1.0); @@ -472,8 +446,7 @@ get_prim(EggMesherStrip &strip) { } } - // Now color1 is the color we want to assign to the whole - // primitive. + // Now color1 is the color we want to assign to the whole primitive. egg_prim->set_color(color1); if (egg_prim->is_of_type(EggCompositePrimitive::get_class_type())) { EggCompositePrimitive *egg_comp = DCAST(EggCompositePrimitive, egg_prim); @@ -491,12 +464,10 @@ get_prim(EggMesherStrip &strip) { return egg_prim; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::count_vert_edges -// Access: Private -// Description: Returns the number of edges in the list that are used -// by at least one EggMesherStrip object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of edges in the list that are used by at least one + * EggMesherStrip object. + */ int EggMesher:: count_vert_edges(const EdgePtrs &edges) const { int count = 0; @@ -507,13 +478,10 @@ count_vert_edges(const EdgePtrs &edges) const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::choose_strip_list -// Access: Private -// Description: Selects which of several strip lists on the EggMesher -// class the indicated EggMesherStrip should be added -// to. -//////////////////////////////////////////////////////////////////// +/** + * Selects which of several strip lists on the EggMesher class the indicated + * EggMesherStrip should be added to. + */ plist &EggMesher:: choose_strip_list(const EggMesherStrip &strip) { switch (strip._status) { @@ -543,18 +511,14 @@ choose_strip_list(const EggMesherStrip &strip) { return _strips; // Unreachable; this is just to make the compiler happy. } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::build_sheets -// Access: Private -// Description: Attempts to locate large quadsheets in the polygon -// soup. A quadsheet is defined as a uniform -// rectangular mesh of quads joined at the corners. -// -// Sheets like this are commonly output by modeling -// packages, especially uniform tesselators, and they -// are trivially converted into a row of triangle -// strips. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to locate large quadsheets in the polygon soup. A quadsheet is + * defined as a uniform rectangular mesh of quads joined at the corners. + * + * Sheets like this are commonly output by modeling packages, especially + * uniform tesselators, and they are trivially converted into a row of + * triangle strips. + */ void EggMesher:: build_sheets() { int first_row_id = 1; @@ -568,15 +532,15 @@ build_sheets() { Strips::iterator best = pre_sheeted.begin(); - // If the row_id is negative, we've already built a sheet out of - // this quad. Leave it alone. We also need to leave it be if it - // has no available edges. + // If the row_id is negative, we've already built a sheet out of this + // quad. Leave it alone. We also need to leave it be if it has no + // available edges. if ((*best)._row_id >= 0 && (*best)._status == EggMesherStrip::MS_alive && !(*best)._edges.empty()) { - // There are two possible sheets we could make from this quad, - // in two different orientations. Measure them both and figure - // out which one is best. + // There are two possible sheets we could make from this quad, in two + // different orientations. Measure them both and figure out which one + // is best. const EggMesherEdge *edge_a = (*best)._edges.front(); const EggMesherEdge *edge_b = (*best).find_adjacent_edge(edge_a); @@ -606,10 +570,9 @@ build_sheets() { (*best).cut_sheet(first_row_id_b, true, _vertex_pool); } else { - // Nope, sheet a is better. This is a bit of a nuisance - // because we've unfortunately wiped out the information we - // stored when we measured sheet a. We'll have to do it - // again. + // Nope, sheet a is better. This is a bit of a nuisance because we've + // unfortunately wiped out the information we stored when we measured + // sheet a. We'll have to do it again. num_prims_a = 0; num_rows_a = 0; @@ -630,36 +593,33 @@ build_sheets() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::find_fans -// Access: Private -// Description: Looks for cases of multiple polygons all sharing a -// common vertex, and replaces these with a single fan. -// -// This step is performed before detecting triangle -// strips. We have to be careful: if we are too -// aggressive in detecting fans, we may ruin the ability -// to build good triangle strips, and we may thereby end -// up with a less-than-optimal solution. -//////////////////////////////////////////////////////////////////// +/** + * Looks for cases of multiple polygons all sharing a common vertex, and + * replaces these with a single fan. + * + * This step is performed before detecting triangle strips. We have to be + * careful: if we are too aggressive in detecting fans, we may ruin the + * ability to build good triangle strips, and we may thereby end up with a + * less-than-optimal solution. + */ void EggMesher:: find_fans() { PT(EggGroupNode) unrolled_tris = new EggGroup; - // Consider all vertices. Any vertex with over a certain number of - // edges connected to it is eligible to become a fan. + // Consider all vertices. Any vertex with over a certain number of edges + // connected to it is eligible to become a fan. Verts::iterator vi; for (vi = _verts.begin(); vi != _verts.end(); ++vi) { EdgePtrs &edges = (*vi).second; - // 14 is the magic number of edges. 12 edges or fewer are likely - // to be found on nearly every vertex in a quadsheet (six edges - // times two, one each way). We don't want to waste time fanning - // out each vertex of a quadsheet, and we don't want to break up - // the quadsheets anyway. We bump this up to 14 because some - // quadsheets are defined with triangles flipped here and there. + // 14 is the magic number of edges. 12 edges or fewer are likely to be + // found on nearly every vertex in a quadsheet (six edges times two, one + // each way). We don't want to waste time fanning out each vertex of a + // quadsheet, and we don't want to break up the quadsheets anyway. We + // bump this up to 14 because some quadsheets are defined with triangles + // flipped here and there. if (edges.size() > 6) { int v = (*vi).first; @@ -714,42 +674,35 @@ find_fans() { } } - // Finally, add back in the triangles we might have produced by - // unrolling some of the fans. We can't add these back in safely - // until we're done traversing all the vertices and primitives we - // had in the first place (since adding them will affect the edge - // lists). + // Finally, add back in the triangles we might have produced by unrolling + // some of the fans. We can't add these back in safely until we're done + // traversing all the vertices and primitives we had in the first place + // (since adding them will affect the edge lists). EggGroupNode::iterator ti; for (ti = unrolled_tris->begin(); ti != unrolled_tris->end(); ++ti) { add_polygon(DCAST(EggPolygon, (*ti)), EggMesherStrip::MO_fanpoly); } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::make_quads -// Access: Private -// Description: Attempts to join up each single tri to its neighbor, -// to reconstruct a pattern of quads, suitable for -// making into quadsheets or at least quadstrips. -// -// Quads have some nice properties that make them easy -// to manipulate when meshing. We will ultimately -// convert the quadsheets and quadstrips into tristrips, -// but it's easier to work with them first while they're -// quads. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to join up each single tri to its neighbor, to reconstruct a + * pattern of quads, suitable for making into quadsheets or at least + * quadstrips. + * + * Quads have some nice properties that make them easy to manipulate when + * meshing. We will ultimately convert the quadsheets and quadstrips into + * tristrips, but it's easier to work with them first while they're quads. + */ void EggMesher:: make_quads() { - // Ideally, we want to match tris across their hypotenuse to make a - // pattern of quads. (This assumes that we are working with a - // triangulated mesh pattern, of course. If we have some other - // pattern of tris, all bets are off and it doesn't really matter - // anyway.) + // Ideally, we want to match tris across their hypotenuse to make a pattern + // of quads. (This assumes that we are working with a triangulated mesh + // pattern, of course. If we have some other pattern of tris, all bets are + // off and it doesn't really matter anyway.) - // First, we'll find all the tris that have no doubt about their - // ideal mate, and pair them up right away. The others we'll get to - // later. This way, the uncertain matches won't pollute the quad - // alignment for everyone else. + // First, we'll find all the tris that have no doubt about their ideal mate, + // and pair them up right away. The others we'll get to later. This way, + // the uncertain matches won't pollute the quad alignment for everyone else. typedef pair Pair; typedef pair Matched; @@ -767,7 +720,7 @@ make_quads() { if (tri->_status == EggMesherStrip::MS_alive) { if (tri->find_ideal_mate(mate, common_edge, _vertex_pool)) { // Does our chosen mate want us too? - if (mate->_type == EggMesherStrip::PT_tri && + if (mate->_type == EggMesherStrip::PT_tri && mate->_status == EggMesherStrip::MS_alive && mate->find_ideal_mate(mate2, common_edge2, _vertex_pool) && mate2 == tri) { @@ -781,8 +734,8 @@ make_quads() { } } - // Now that we've found all the tris that are sure about each other, - // mate them. + // Now that we've found all the tris that are sure about each other, mate + // them. SoulMates::iterator mi; for (mi = soulmates.begin(); mi != soulmates.end(); ++mi) { tri = (*mi).first.first; @@ -814,11 +767,9 @@ make_quads() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::mesh_list -// Access: Private -// Description: Processes all of the strips on the indicated list. -//////////////////////////////////////////////////////////////////// +/** + * Processes all of the strips on the indicated list. + */ void EggMesher:: mesh_list(Strips &strips) { while (!strips.empty()) { @@ -830,19 +781,17 @@ mesh_list(Strips &strips) { (*best).mate(_vertex_pool); } - // Put the strip back on the end of whichever list it wants. This - // might be the same list, if the strip is still alive, or it - // might be _done or _dead. + // Put the strip back on the end of whichever list it wants. This might + // be the same list, if the strip is still alive, or it might be _done or + // _dead. Strips &list = choose_strip_list(*best); list.splice(list.end(), strips, best); } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesher::make_random_color -// Access: Private, Static -// Description: Chooses a reasonable random color. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a reasonable random color. + */ void EggMesher:: make_random_color(LColor &color) { LVector3 rgb; @@ -859,4 +808,3 @@ make_random_color(LColor &color) { color.set(rgb[0], rgb[1], rgb[2], 0.25 + 0.75 * (double)rand() / (double)RAND_MAX); } - diff --git a/panda/src/egg/eggMesher.h b/panda/src/egg/eggMesher.h index 05bbef48b3..740b0d38cc 100644 --- a/panda/src/egg/eggMesher.h +++ b/panda/src/egg/eggMesher.h @@ -1,16 +1,15 @@ -// Filename: eggMesher.h -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesher.h + * @author drose + * @date 2005-03-13 + */ #ifndef EGGMESHER_H #define EGGMESHER_H @@ -26,12 +25,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : EggMesher -// Description : Collects together unrelated EggPrimitives, determines -// their edge connectivity, and generates a set of -// EggTriangleStrips that represent the same geometry. -//////////////////////////////////////////////////////////////////// +/** + * Collects together unrelated EggPrimitives, determines their edge + * connectivity, and generates a set of EggTriangleStrips that represent the + * same geometry. + */ class EggMesher { public: EggMesher(); @@ -47,7 +45,7 @@ public: private: void clear(); - bool add_polygon(const EggPolygon *egg_poly, + bool add_polygon(const EggPolygon *egg_poly, EggMesherStrip::MesherOrigin origin); void do_mesh(); PT(EggPrimitive) get_prim(EggMesherStrip &strip); diff --git a/panda/src/egg/eggMesherEdge.I b/panda/src/egg/eggMesherEdge.I index 44167f4753..9d83e936e0 100644 --- a/panda/src/egg/eggMesherEdge.I +++ b/panda/src/egg/eggMesherEdge.I @@ -1,34 +1,28 @@ -// Filename: eggMesherEdge.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherEdge.I + * @author drose + * @date 2005-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::Constructor -// Access: Public -// Description: Defines an edge as a pair of vertices. The _opposite -// pointer should be filled in explicitly by the caller. -//////////////////////////////////////////////////////////////////// +/** + * Defines an edge as a pair of vertices. The _opposite pointer should be + * filled in explicitly by the caller. + */ INLINE EggMesherEdge:: EggMesherEdge(int vi_a, int vi_b) : _vi_a(vi_a), _vi_b(vi_b) { _opposite = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggMesherEdge:: EggMesherEdge(const EggMesherEdge ©) : _vi_a(copy._vi_a), @@ -38,68 +32,55 @@ EggMesherEdge(const EggMesherEdge ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::contains_vertex -// Access: Public -// Description: Returns true if the edge contains the indicated -// vertex index, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the edge contains the indicated vertex index, false + * otherwise. + */ INLINE bool EggMesherEdge:: contains_vertex(int vi) const { return (_vi_a == vi || _vi_b == vi); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::matches -// Access: Public -// Description: Returns true if this edge represents the same line -// segment as the other edge, in either direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this edge represents the same line segment as the other + * edge, in either direction. + */ INLINE bool EggMesherEdge:: matches(const EggMesherEdge &other) const { return ((_vi_a == other._vi_a && _vi_b == other._vi_b) || (_vi_b == other._vi_a && _vi_a == other._vi_b)); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::common_ptr -// Access: Public -// Description: Returns an arbitrary pointer that is used to -// represent both this edge and its opposite. -// this->common_ptr() is guaranteed to be the same as -// this->_opposite->common_ptr(). -//////////////////////////////////////////////////////////////////// +/** + * Returns an arbitrary pointer that is used to represent both this edge and + * its opposite. this->common_ptr() is guaranteed to be the same as + * this->_opposite->common_ptr(). + */ INLINE EggMesherEdge *EggMesherEdge:: common_ptr() { return min(this, _opposite); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMesherEdge:: operator == (const EggMesherEdge &other) const { return _vi_a == other._vi_a && _vi_b == other._vi_b; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMesherEdge:: operator != (const EggMesherEdge &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::operator < -// Access: Public -// Description: Defines an arbitrary ordering for edges, used for -// putting edges in a sorted container. -//////////////////////////////////////////////////////////////////// +/** + * Defines an arbitrary ordering for edges, used for putting edges in a sorted + * container. + */ INLINE bool EggMesherEdge:: operator < (const EggMesherEdge &other) const { if (_vi_a != other._vi_a) { @@ -108,11 +89,9 @@ operator < (const EggMesherEdge &other) const { return _vi_b < other._vi_b; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::compute_length -// Access: Public -// Description: Returns the length of the edge in model units. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the edge in model units. + */ INLINE double EggMesherEdge:: compute_length(const EggVertexPool *vertex_pool) const { LPoint3d a = vertex_pool->get_vertex(_vi_a)->get_pos3(); @@ -120,14 +99,11 @@ compute_length(const EggVertexPool *vertex_pool) const { return (a - b).length(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::compute_box -// Access: Public -// Description: Returns a 3-component vector that represents the -// lengths of the sides of the smalled axis-aligned box -// that contains the edge. That is, the projection the -// edge onto each axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 3-component vector that represents the lengths of the sides of + * the smalled axis-aligned box that contains the edge. That is, the + * projection the edge onto each axis. + */ INLINE LVecBase3d EggMesherEdge:: compute_box(const EggVertexPool *vertex_pool) const { LPoint3d a = vertex_pool->get_vertex(_vi_a)->get_pos3(); diff --git a/panda/src/egg/eggMesherEdge.cxx b/panda/src/egg/eggMesherEdge.cxx index 6dce2e70ca..a37d6785f7 100644 --- a/panda/src/egg/eggMesherEdge.cxx +++ b/panda/src/egg/eggMesherEdge.cxx @@ -1,25 +1,22 @@ -// Filename: eggMesherEdge.cxx -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherEdge.cxx + * @author drose + * @date 2005-03-13 + */ #include "eggMesherEdge.h" #include "eggMesherStrip.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::remove -// Access: Public -// Description: Removes an edge from a particular strip. -//////////////////////////////////////////////////////////////////// +/** + * Removes an edge from a particular strip. + */ void EggMesherEdge:: remove(EggMesherStrip *strip) { strip->_edges.remove(this); @@ -29,11 +26,9 @@ remove(EggMesherStrip *strip) { _opposite->_strips.remove(strip); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::change_strip -// Access: Public -// Description: Reparents the edge from strip "from" to strip "to". -//////////////////////////////////////////////////////////////////// +/** + * Reparents the edge from strip "from" to strip "to". + */ void EggMesherEdge:: change_strip(EggMesherStrip *from, EggMesherStrip *to) { Strips::iterator si; @@ -53,11 +48,9 @@ change_strip(EggMesherStrip *from, EggMesherStrip *to) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherEdge::output -// Access: Public -// Description: Formats the edge for output in some sensible way. -//////////////////////////////////////////////////////////////////// +/** + * Formats the edge for output in some sensible way. + */ void EggMesherEdge:: output(ostream &out) const { out << "Edge [" << _vi_a << " to " << _vi_b << "], " diff --git a/panda/src/egg/eggMesherEdge.h b/panda/src/egg/eggMesherEdge.h index 15317efc2c..82975bd7fb 100644 --- a/panda/src/egg/eggMesherEdge.h +++ b/panda/src/egg/eggMesherEdge.h @@ -1,16 +1,15 @@ -// Filename: eggMesherEdge.h -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherEdge.h + * @author drose + * @date 2005-03-13 + */ #ifndef EGGMESHEREDGE_H #define EGGMESHEREDGE_H @@ -22,13 +21,11 @@ class EggMesherStrip; -//////////////////////////////////////////////////////////////////// -// Class : EggMesherEdge -// Description : Represents one edge of a triangle, as used by the -// EggMesher to discover connected triangles. The edge -// is actually represented as a pair of vertex indices -// into the same vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * Represents one edge of a triangle, as used by the EggMesher to discover + * connected triangles. The edge is actually represented as a pair of vertex + * indices into the same vertex pool. + */ class EggMesherEdge { public: INLINE EggMesherEdge(int vi_a, int vi_b); diff --git a/panda/src/egg/eggMesherFanMaker.I b/panda/src/egg/eggMesherFanMaker.I index e3d7731de6..3bca4a4560 100644 --- a/panda/src/egg/eggMesherFanMaker.I +++ b/panda/src/egg/eggMesherFanMaker.I @@ -1,80 +1,64 @@ -// Filename: eggMesherFanMaker.I -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherFanMaker.I + * @author drose + * @date 2005-03-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::operator < -// Access: Public -// Description: Provides a unique ordering between different fan -// makers based on the leading edge. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering between different fan makers based on the + * leading edge. + */ INLINE bool EggMesherFanMaker:: operator < (const EggMesherFanMaker &other) const { nassertr(!_edges.empty() && !other._edges.empty(), false); return _edges.front() < other._edges.front(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::operator != -// Access: Public -// Description: Provides a unique ordering between different fan -// makers based on the leading edge. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering between different fan makers based on the + * leading edge. + */ INLINE bool EggMesherFanMaker:: operator != (const EggMesherFanMaker &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::operator == -// Access: Public -// Description: Provides a unique ordering between different fan -// makers based on the leading edge. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering between different fan makers based on the + * leading edge. + */ INLINE bool EggMesherFanMaker:: operator == (const EggMesherFanMaker &other) const { return _edges.front() == other._edges.front(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::is_empty -// Access: Public -// Description: Returns true if the fan maker has no edges, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the fan maker has no edges, false otherwise. + */ INLINE bool EggMesherFanMaker:: is_empty() const { return (_edges.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::is_valid -// Access: Public -// Description: Returns true if the fan maker has enough edges to -// define at least one fan, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the fan maker has enough edges to define at least one fan, + * false otherwise. + */ INLINE bool EggMesherFanMaker:: is_valid() const { return (_edges.size() > 2); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::is_coplanar_with -// Access: Public -// Description: Returns true if the strip and the other strip are -// coplanar. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the strip and the other strip are coplanar. + */ INLINE bool EggMesherFanMaker:: is_coplanar_with(const EggMesherFanMaker &other) const { return _planar && other._planar && diff --git a/panda/src/egg/eggMesherFanMaker.cxx b/panda/src/egg/eggMesherFanMaker.cxx index 59e73e6d17..efbfad25a2 100644 --- a/panda/src/egg/eggMesherFanMaker.cxx +++ b/panda/src/egg/eggMesherFanMaker.cxx @@ -1,29 +1,26 @@ -// Filename: eggMesherFanMaker.cxx -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherFanMaker.cxx + * @author drose + * @date 2005-03-22 + */ #include "eggMesherFanMaker.h" #include "eggMesher.h" #include "eggPolygon.h" #include "eggGroupNode.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMesherFanMaker:: -EggMesherFanMaker(int vertex, EggMesherStrip *tri, +EggMesherFanMaker(int vertex, EggMesherStrip *tri, EggMesher *mesher) { _vertex = vertex; const EggMesherEdge *edge = tri->find_opposite_edge(vertex); @@ -35,11 +32,9 @@ EggMesherFanMaker(int vertex, EggMesherStrip *tri, _mesher = mesher; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMesherFanMaker:: EggMesherFanMaker(const EggMesherFanMaker ©) : _vertex(copy._vertex), @@ -50,11 +45,9 @@ EggMesherFanMaker(const EggMesherFanMaker ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMesherFanMaker:: operator = (const EggMesherFanMaker ©) { _vertex = copy._vertex; @@ -64,15 +57,13 @@ operator = (const EggMesherFanMaker ©) { _mesher = copy._mesher; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::join -// Access: Public -// Description: Attempts to connect two fans end-to-end. They must -// both share the same common vertex and a common edge. -// -// The return value is true if the fans were -// successfully joined, or false if they could not be. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to connect two fans end-to-end. They must both share the same + * common vertex and a common edge. + * + * The return value is true if the fans were successfully joined, or false if + * they could not be. + */ bool EggMesherFanMaker:: join(EggMesherFanMaker &other) { nassertr(_vertex == other._vertex, false); @@ -82,7 +73,7 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_back = _edges.back(); const EggMesherEdge *other_front = other._edges.front(); - nassertr(my_back != (EggMesherEdge *)NULL && + nassertr(my_back != (EggMesherEdge *)NULL && other_front != (EggMesherEdge *)NULL, false); int my_back_b = my_back->_vi_b; @@ -97,7 +88,7 @@ join(EggMesherFanMaker &other) { const EggMesherEdge *my_front = _edges.front(); const EggMesherEdge *other_back = other._edges.back(); - nassertr(my_front != (EggMesherEdge *)NULL && + nassertr(my_front != (EggMesherEdge *)NULL && other_back != (EggMesherEdge *)NULL, false); int my_front_a = my_front->_vi_a; @@ -113,21 +104,19 @@ join(EggMesherFanMaker &other) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::compute_angle -// Access: Public -// Description: Returns the overall angle subtended by the fan, from -// the leading edge to the trailing edge, in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall angle subtended by the fan, from the leading edge to + * the trailing edge, in degrees. + */ double EggMesherFanMaker:: compute_angle() const { - // We sum up the angles of each triangle. This is more correct than - // taking the net angle from the first edge to the last (since we - // may not be in a plane). + // We sum up the angles of each triangle. This is more correct than taking + // the net angle from the first edge to the last (since we may not be in a + // plane). nassertr(is_valid(), 0.0); EggVertexPool *vertex_pool = _mesher->_vertex_pool; - + double angle = 0.0; LPoint3d v0 = vertex_pool->get_vertex(_vertex)->get_pos3(); @@ -144,21 +133,17 @@ compute_angle() const { return rad_2_deg(angle); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::build -// Access: Public -// Description: Begins the fanning process. Searches for triangles -// and connects them into a fan. -// -// In certain cases, if egg_unroll_fans is enabled, the -// resulting fan may be retesselated into a series of -// zig-zag triangles, which are stored in unrolled_tris. -// Otherwise, an EggMesherStrip (representing the fan) -// is created and added to the mesher. -// -// The return value is (loosely) the number of -// primitives created. -//////////////////////////////////////////////////////////////////// +/** + * Begins the fanning process. Searches for triangles and connects them into + * a fan. + * + * In certain cases, if egg_unroll_fans is enabled, the resulting fan may be + * retesselated into a series of zig-zag triangles, which are stored in + * unrolled_tris. Otherwise, an EggMesherStrip (representing the fan) is + * created and added to the mesher. + * + * The return value is (loosely) the number of primitives created. + */ int EggMesherFanMaker:: build(EggGroupNode *unrolled_tris) { nassertr(_edges.size() == _strips.size(), 0); @@ -168,8 +153,8 @@ build(EggGroupNode *unrolled_tris) { double avg_angle = net_angle / (double)num_tris; if (avg_angle > egg_max_tfan_angle) { - // The triangles are too loose to justify making a fan; it'll - // probably make a better quadsheet. + // The triangles are too loose to justify making a fan; it'll probably + // make a better quadsheet. return 0; } @@ -182,20 +167,20 @@ build(EggGroupNode *unrolled_tris) { // However, we could (maybe) make it a few tristrips! // Each section of the fan which is made up of coplanar tris, with - // identical properties, may be retesselated into a tristrip. - // What a sneaky trick! To do this, we must first identify each - // such qualifying section. + // identical properties, may be retesselated into a tristrip. What a + // sneaky trick! To do this, we must first identify each such qualifying + // section. - // We define a seam as the edge between any two tris which are - // noncoplanar or have different properties. Then we can send - // each piece between the seams to unroll(). + // We define a seam as the edge between any two tris which are noncoplanar + // or have different properties. Then we can send each piece between the + // seams to unroll(). Strips::iterator si, last_si; Edges::iterator ei, last_ei; - // First, rotate the fan so it begins at a seam. We do this so we - // won't be left out with part of one piece at the beginning and - // also at the end. + // First, rotate the fan so it begins at a seam. We do this so we won't + // be left out with part of one piece at the beginning and also at the + // end. si = _strips.begin(); last_si = si; ei = _edges.begin(); @@ -213,8 +198,7 @@ build(EggGroupNode *unrolled_tris) { } } - // Now break the fan up along its seams and unroll each piece - // separately. + // Now break the fan up along its seams and unroll each piece separately. si = _strips.begin(); last_si = si; ei = _edges.begin(); @@ -253,29 +237,24 @@ build(EggGroupNode *unrolled_tris) { (*si)->_status = EggMesherStrip::MS_dead; } - // If we'd built our list of edges and strips right, this sum should - // come out so that there are two more vertices than triangles in - // the new fan. + // If we'd built our list of edges and strips right, this sum should come + // out so that there are two more vertices than triangles in the new fan. nassertr(new_fan._verts.size() == new_fan._prims.size() + 2, 0); - // Now we've built a fan, and it won't be able to mate with - // anything else, so add it to the done list. + // Now we've built a fan, and it won't be able to mate with anything else, + // so add it to the done list. _mesher->_done.push_back(new_fan); } return 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::unroll -// Access: Public -// Description: Unrolls a planar subset of the current working fan, -// defined by the given iterators, into a series of -// triangles that zig-zag back and forth for better -// tristripping properties. The new triangles are added -// to unrolled_tris; the return value is 1 if -// successful, or 0 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Unrolls a planar subset of the current working fan, defined by the given + * iterators, into a series of triangles that zig-zag back and forth for + * better tristripping properties. The new triangles are added to + * unrolled_tris; the return value is 1 if successful, or 0 otherwise. + */ int EggMesherFanMaker:: unroll(Strips::iterator strip_begin, Strips::iterator strip_end, Edges::iterator edge_begin, Edges::iterator edge_end, @@ -303,9 +282,8 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end, ei = edge_end; --ei; if ((*ei)->_vi_b != (*edge_begin)->_vi_a) { - // If the fan is less than a full circle, we need to keep the - // hub vertex and initial vertex in the poly. Otherwise, we'll - // discard them. + // If the fan is less than a full circle, we need to keep the hub vertex + // and initial vertex in the poly. Otherwise, we'll discard them. poly->add_vertex(vertex_pool->get_vertex(_vertex)); poly->add_vertex(vertex_pool->get_vertex((*edge_begin)->_vi_a)); } @@ -319,11 +297,10 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end, if (egg_show_quads) { // If we're showing quads, also show retesselated triangles. - // We can't add it directly to the mesher, that's unsafe; instead, - // we'll just add it to the end of the unrolled_tris list. This - // does mean we won't be able to color it a fancy color, but too - // bad. - //_mesher->add_polygon(poly, EggMesherStrip::MO_fanpoly); + // We can't add it directly to the mesher, that's unsafe; instead, we'll + // just add it to the end of the unrolled_tris list. This does mean we + // won't be able to color it a fancy color, but too bad. + // _mesher->add_polygon(poly, EggMesherStrip::MO_fanpoly); unrolled_tris->add_child(poly); } else { @@ -345,11 +322,9 @@ unroll(Strips::iterator strip_begin, Strips::iterator strip_end, } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherFanMaker::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMesherFanMaker:: output(ostream &out) const { out << _vertex << ":["; diff --git a/panda/src/egg/eggMesherFanMaker.h b/panda/src/egg/eggMesherFanMaker.h index 586b3c8773..fcfc65b879 100644 --- a/panda/src/egg/eggMesherFanMaker.h +++ b/panda/src/egg/eggMesherFanMaker.h @@ -1,16 +1,15 @@ -// Filename: eggMesherFanMaker.h -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherFanMaker.h + * @author drose + * @date 2005-03-22 + */ #ifndef EGGMESHERFANMAKER_H #define EGGMESHERFANMAKER_H @@ -28,18 +27,16 @@ class EggMesher; -//////////////////////////////////////////////////////////////////// -// Class : EggMesherFanMaker -// Description : This class is used by EggMesher::find_fans() to -// attempt to make an EggTriangleFan out of the polygons -// connected to the indicated vertex. -//////////////////////////////////////////////////////////////////// +/** + * This class is used by EggMesher::find_fans() to attempt to make an + * EggTriangleFan out of the polygons connected to the indicated vertex. + */ class EggMesherFanMaker { public: typedef plist Edges; typedef plist Strips; - EggMesherFanMaker(int vertex, EggMesherStrip *tri, + EggMesherFanMaker(int vertex, EggMesherStrip *tri, EggMesher *mesher); EggMesherFanMaker(const EggMesherFanMaker ©); void operator = (const EggMesherFanMaker ©); diff --git a/panda/src/egg/eggMesherStrip.I b/panda/src/egg/eggMesherStrip.I index a38b1ed4bb..2ea3d2a3f4 100644 --- a/panda/src/egg/eggMesherStrip.I +++ b/panda/src/egg/eggMesherStrip.I @@ -1,23 +1,19 @@ -// Filename: eggMesherStrip.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherStrip.I + * @author drose + * @date 2005-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggMesherStrip:: EggMesherStrip(const EggMesherStrip ©) : _prims(copy._prims), @@ -34,27 +30,21 @@ EggMesherStrip(const EggMesherStrip ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::is_coplanar_with -// Access: Public -// Description: Returns true if the strip and the other strip are -// coplanar, within the indicated threshold. See -// coplanarity(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the strip and the other strip are coplanar, within the + * indicated threshold. See coplanarity(). + */ INLINE bool EggMesherStrip:: is_coplanar_with(const EggMesherStrip &other, PN_stdfloat threshold) const { return (coplanarity(other) <= threshold); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::coplanarity -// Access: Public -// Description: Returns the degree to which the two strips are -// coplanar. 0.0 is exactly coplanar; numbers somewhat -// larger than zero indicate less coplanar. 1.0 is -// at right angles; 2.0 is exactly backfacing. If -// either strip is not itself planar, 3.0 is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree to which the two strips are coplanar. 0.0 is exactly + * coplanar; numbers somewhat larger than zero indicate less coplanar. 1.0 is + * at right angles; 2.0 is exactly backfacing. If either strip is not itself + * planar, 3.0 is returned. + */ INLINE PN_stdfloat EggMesherStrip:: coplanarity(const EggMesherStrip &other) const { if (_planar && other._planar) { @@ -63,13 +53,10 @@ coplanarity(const EggMesherStrip &other) const { return 3.0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::type_category -// Access: Public -// Description: Returns an integer which gives a heuristic about the -// similarity of different strip types. In general, -// closer numbers are more similar. -//////////////////////////////////////////////////////////////////// +/** + * Returns an integer which gives a heuristic about the similarity of + * different strip types. In general, closer numbers are more similar. + */ INLINE int EggMesherStrip:: type_category() const { switch (_type) { @@ -89,24 +76,18 @@ type_category() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::rotate_forward -// Access: Public -// Description: Rotates a triangle or quad by bringing its first -// vertex to the back. -//////////////////////////////////////////////////////////////////// +/** + * Rotates a triangle or quad by bringing its first vertex to the back. + */ INLINE void EggMesherStrip:: rotate_forward() { _verts.push_back(_verts.front()); _verts.pop_front(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::rotate_back -// Access: Public -// Description: Rotates a triangle or quad by bringing its last -// vertex to the front. -//////////////////////////////////////////////////////////////////// +/** + * Rotates a triangle or quad by bringing its last vertex to the front. + */ INLINE void EggMesherStrip:: rotate_back() { _verts.push_front(_verts.back()); @@ -114,14 +95,11 @@ rotate_back() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::get_head_edge -// Access: Public -// Description: Returns an EggMesherEdge which represents the leading -// edge in the quadstrip or tristrip. This -// EggMesherEdge will not have pointer equality with any -// shared EggMesherEdge. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggMesherEdge which represents the leading edge in the quadstrip + * or tristrip. This EggMesherEdge will not have pointer equality with any + * shared EggMesherEdge. + */ INLINE EggMesherEdge EggMesherStrip:: get_head_edge() const { Verts::const_iterator vi = _verts.begin(); @@ -130,14 +108,11 @@ get_head_edge() const { return EggMesherEdge(_verts.front(), *vi); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::get_tail_edge -// Access: Public -// Description: Returns an EggMesherEdge which represents the -// trailing edge in the quadstrip or tristrip. This -// EggMesherEdge will not have pointer equality with any -// shared EggMesherEdge. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggMesherEdge which represents the trailing edge in the + * quadstrip or tristrip. This EggMesherEdge will not have pointer equality + * with any shared EggMesherEdge. + */ INLINE EggMesherEdge EggMesherStrip:: get_tail_edge() const { Verts::const_reverse_iterator vi = _verts.rbegin(); @@ -146,23 +121,18 @@ get_tail_edge() const { return EggMesherEdge(*vi, _verts.back()); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::operator == -// Access: Public -// Description: Defines equality for strips. This actually tests -// only pointer equality; it's used only when removing a -// strip from the list. -//////////////////////////////////////////////////////////////////// +/** + * Defines equality for strips. This actually tests only pointer equality; + * it's used only when removing a strip from the list. + */ INLINE bool EggMesherStrip:: operator == (const EggMesherStrip &other) const { return this == &other; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggMesherStrip:: operator != (const EggMesherStrip &other) const { return !operator == (other); diff --git a/panda/src/egg/eggMesherStrip.cxx b/panda/src/egg/eggMesherStrip.cxx index aa9ee91ec3..5059105ceb 100644 --- a/panda/src/egg/eggMesherStrip.cxx +++ b/panda/src/egg/eggMesherStrip.cxx @@ -1,16 +1,15 @@ -// Filename: eggMesherStrip.cxx -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherStrip.cxx + * @author drose + * @date 2005-03-13 + */ #include "eggMesherStrip.h" #include "eggMesherEdge.h" @@ -21,11 +20,9 @@ #include "dcast.h" #include "config_egg.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMesherStrip:: EggMesherStrip(PrimType prim_type, MesherOrigin origin) { _origin = origin; @@ -38,13 +35,11 @@ EggMesherStrip(PrimType prim_type, MesherOrigin origin) { _flat_shaded = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMesherStrip:: -EggMesherStrip(const EggPrimitive *prim, int index, +EggMesherStrip(const EggPrimitive *prim, int index, const EggVertexPool *vertex_pool, bool flat_shaded) { _index = index; @@ -55,8 +50,8 @@ EggMesherStrip(const EggPrimitive *prim, int index, _type = PT_poly; //prim.get_type(); - // We care only about the prim's attributes in the _prims array. - // The vertices get re-added later by EggMesher::add_prim(). + // We care only about the prim's attributes in the _prims array. The + // vertices get re-added later by EggMesher::add_prim(). _prims.push_back(prim); if (_type == PT_poly) { @@ -80,9 +75,8 @@ EggMesherStrip(const EggPrimitive *prim, int index, _planar = false; if (prim->is_of_type(EggPolygon::get_class_type())) { - // Although for the most part we ignore the actual value of the - // vertices, we will ask the polygon for its plane equation - // (i.e. its normal). + // Although for the most part we ignore the actual value of the vertices, + // we will ask the polygon for its plane equation (i.e. its normal). LNormald normal; if (DCAST(EggPolygon, prim)->calculate_normal(normal)) { _plane_normal = normal; @@ -94,12 +88,10 @@ EggMesherStrip(const EggPrimitive *prim, int index, } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::make_prim -// Access: Public -// Description: Creates an EggPrimitive corresponding to the strip -// represented by this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates an EggPrimitive corresponding to the strip represented by this + * node. + */ PT(EggPrimitive) EggMesherStrip:: make_prim(const EggVertexPool *vertex_pool) { PT(EggPrimitive) prim; @@ -121,7 +113,7 @@ make_prim(const EggVertexPool *vertex_pool) { } if (dest_type != PT_tristrip && dest_type != PT_trifan) { - // The easy case: a simple primitive, i.e. a polygon. + // The easy case: a simple primitive, i.e. a polygon. prim = new EggPolygon; prim->copy_attributes(*_prims.front()); @@ -140,9 +132,8 @@ make_prim(const EggVertexPool *vertex_pool) { } prim->copy_attributes(*_prims.front()); - // Now store all the vertices. Each individual triangle's - // attributes, if any, get applied to the third vertex of each - // triangle. + // Now store all the vertices. Each individual triangle's attributes, if + // any, get applied to the third vertex of each triangle. Verts::iterator vi; Prims::iterator pi; pi = _prims.begin(); @@ -152,20 +143,20 @@ make_prim(const EggVertexPool *vertex_pool) { ++vi) { PT(EggVertex) vertex = vertex_pool->get_vertex(*vi); prim->add_vertex(vertex); - + ++count; if (count >= 3) { - // Beginning with the third vertex, we increment pi. Thus, the - // first two vertices stand alone, then each vertex beginning - // with the third completes a triangle. + // Beginning with the third vertex, we increment pi. Thus, the first + // two vertices stand alone, then each vertex beginning with the third + // completes a triangle. const EggAttributes *attrib = (*pi); ++pi; DCAST(EggCompositePrimitive, prim)->set_component(count - 3, attrib); } } - // If either of these fail, there weren't num_prims + 2 vertices in - // the tristrip! + // If either of these fail, there weren't num_prims + 2 vertices in the + // tristrip! nassertr(vi == _verts.end(), prim); nassertr(pi == _prims.end(), prim); } @@ -173,27 +164,24 @@ make_prim(const EggVertexPool *vertex_pool) { return prim; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::measure_sheet -// Access: Public -// Description: Determines the extents of the quadsheet that can be -// derived by starting with this strip, and searching in -// the direction indicated by the given edge. -//////////////////////////////////////////////////////////////////// +/** + * Determines the extents of the quadsheet that can be derived by starting + * with this strip, and searching in the direction indicated by the given + * edge. + */ void EggMesherStrip:: -measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, - int &num_rows, int first_row_id, int this_row_id, +measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, + int &num_rows, int first_row_id, int this_row_id, int this_row_distance) { if (new_row) { - // If we would create a new row by stepping here, we won't stay if - // there was any other row already defined here. + // If we would create a new row by stepping here, we won't stay if there + // was any other row already defined here. if (_row_id >= first_row_id) { return; } } else { - // On the other hand, if this is a continuation of the current - // row, we'll stay if the other row had to travel farther to get - // here. + // On the other hand, if this is a continuation of the current row, we'll + // stay if the other row had to travel farther to get here. if (_row_id >= first_row_id && _row_distance <= this_row_distance) { return; } @@ -211,37 +199,36 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, EggMesherEdge::Strips::iterator si; if (_type == PT_quad) { - // If this is a quad, it has four neighbors: two in the direction - // we are testing, and two in an orthagonal direction. + // If this is a quad, it has four neighbors: two in the direction we are + // testing, and two in an orthagonal direction. int vi_a = edge->_vi_a; int vi_b = edge->_vi_b; - // We use these vertices to differentiate the edges that run in - // our primary direction from those in the secondary direction. - // For each edge, we count the number of vertices that the edge - // shares with our starting edge. There are then three cases: + // We use these vertices to differentiate the edges that run in our + // primary direction from those in the secondary direction. For each + // edge, we count the number of vertices that the edge shares with our + // starting edge. There are then three cases: - // (a) The edge shares two vertices. It is the direction we came - // from; forget it. + // (a) The edge shares two vertices. It is the direction we came from; + // forget it. - // (b) The edge shares one vertex. It is at right angles to our - // starting edge. This is the primary direction if new_row is - // true, and the secondary direction if new_row is false. + // (b) The edge shares one vertex. It is at right angles to our starting + // edge. This is the primary direction if new_row is true, and the + // secondary direction if new_row is false. - // (c) The edge shares no vertices. It is directly opposite our - // starting edge. This is the primary direction if new_row is - // false, and the secondary direction if new_row is true. + // (c) The edge shares no vertices. It is directly opposite our starting + // edge. This is the primary direction if new_row is false, and the + // secondary direction if new_row is true. - // Here's a silly little for loop that executes the following code - // twice: once with secondary == 0, and once with secondary == 1. - // This is because we want to find all the primary edges first, - // and then all the secondary edges. + // Here's a silly little for loop that executes the following code twice: + // once with secondary == 0, and once with secondary == 1. This is because + // we want to find all the primary edges first, and then all the secondary + // edges. for (int secondary = 0; secondary <= 1; secondary++) { - // How many common vertices are we looking for this pass (see - // above)? + // How many common vertices are we looking for this pass (see above)? int want_count; if (secondary) { @@ -256,9 +243,9 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, ((*ei)->_vi_b == vi_a || (*ei)->_vi_b == vi_b); if (common_verts == want_count) { - // Here's the edge. Look at all its connections. Hopefully, - // there will only be one besides ourselves, but there may be - // more. Pick the best. + // Here's the edge. Look at all its connections. Hopefully, there + // will only be one besides ourselves, but there may be more. Pick + // the best. EggMesherEdge::Strips &strips = (*ei)->_strips; EggMesherStrip *mate = NULL; @@ -279,15 +266,15 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, } } else { - // Otherwise, this is not a quad. It's certainly not a triangle, - // because we've built all the single triangles already. + // Otherwise, this is not a quad. It's certainly not a triangle, because + // we've built all the single triangles already. nassertv(_type != PT_tri); // Therefore, it must be a tristrip or quadstrip. nassertv(_type == PT_tristrip || _type == PT_quadstrip); - // Since it's a strip, it only has two neighbors: the one we came - // from, and the other one. Find the other one. + // Since it's a strip, it only has two neighbors: the one we came from, + // and the other one. Find the other one. for (ei = _edges.begin(); ei != _edges.end(); ++ei) { if (!(*ei)->matches(*edge)) { @@ -312,23 +299,21 @@ measure_sheet(const EggMesherEdge *edge, int new_row, int &num_prims, } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::cut_sheet -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMesherStrip:: cut_sheet(int first_row_id, int do_mate, const EggVertexPool *vertex_pool) { Edges::iterator ei; EggMesherEdge::Strips::iterator si; - // First, start the process going on any neighbors that belong to a - // later row. (We must do these first, because we'll change our - // neighbor list when we start to mate.) + // First, start the process going on any neighbors that belong to a later + // row. (We must do these first, because we'll change our neighbor list + // when we start to mate.) - // We need to build a temporary list of neighbors first, because - // calling cut_sheet() recursively will start things mating, and - // could damage our edge list. + // We need to build a temporary list of neighbors first, because calling + // cut_sheet() recursively will start things mating, and could damage our + // edge list. typedef plist StripPtrs; StripPtrs strip_ptrs; @@ -343,9 +328,9 @@ cut_sheet(int first_row_id, int do_mate, const EggVertexPool *vertex_pool) { } } - // Now walk the temporary list and do some damage. We pass do_mate - // = true to each of these neighbors, because as far as we know, - // they're the first nodes of a particular row. + // Now walk the temporary list and do some damage. We pass do_mate = true + // to each of these neighbors, because as far as we know, they're the first + // nodes of a particular row. StripPtrs::iterator spi; for (spi = strip_ptrs.begin(); spi != strip_ptrs.end(); ++spi) { if ((*spi)->_status == MS_alive) { @@ -370,19 +355,19 @@ cut_sheet(int first_row_id, int do_mate, const EggVertexPool *vertex_pool) { not_any = false; EggMesherStrip *mate = *si; - // We also recurse on these guys so they can spread the - // word to their own neighbors. This time we don't need - // to build a temporary list, because we'll be restarting - // from the beginning of our edge list after we do this. - // We also pass do_mate = false to these guys because - // we're the ones doing the mating here. + // We also recurse on these guys so they can spread the word to + // their own neighbors. This time we don't need to build a + // temporary list, because we'll be restarting from the beginning + // of our edge list after we do this. We also pass do_mate = + // false to these guys because we're the ones doing the mating + // here. mate->cut_sheet(first_row_id, false, vertex_pool); if (_status == MS_alive && mate->_status == MS_alive) { - // Now mate. This will either succeed or fail. It ought - // to succeed, but if it doesn't, no harm done; it will - // simply remove the common edge and return. We'll go - // around again and not encounter this neighbor next time. + // Now mate. This will either succeed or fail. It ought to + // succeed, but if it doesn't, no harm done; it will simply + // remove the common edge and return. We'll go around again and + // not encounter this neighbor next time. mate_pieces(*ei, *this, *mate, vertex_pool); } } @@ -404,18 +389,14 @@ cut_sheet(int first_row_id, int do_mate, const EggVertexPool *vertex_pool) { -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::mate -// Access: Public -// Description: Finds a neighboring strip and joins up with it to -// make a larger strip. Returns true if mating was -// successful or at least possible, false if the strip -// has no neighbors. -//////////////////////////////////////////////////////////////////// +/** + * Finds a neighboring strip and joins up with it to make a larger strip. + * Returns true if mating was successful or at least possible, false if the + * strip has no neighbors. + */ bool EggMesherStrip:: mate(const EggVertexPool *vertex_pool) { - // We must walk through the list of our neighbors and choose our - // best mate. + // We must walk through the list of our neighbors and choose our best mate. nassertr(_status == MS_alive, false); EggMesherStrip *mate; @@ -433,18 +414,15 @@ mate(const EggVertexPool *vertex_pool) { mate_pieces(common_edge, *this, *mate, vertex_pool); - // Whether the mate failed or not, the strip still (probably) has - // other neighbors to consider. Return true regardless. + // Whether the mate failed or not, the strip still (probably) has other + // neighbors to consider. Return true regardless. return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::find_ideal_mate -// Access: Public -// Description: Searches our neighbors for the most suitable mate. -// Returns true if one is found, false if we have no -// neighbors. -//////////////////////////////////////////////////////////////////// +/** + * Searches our neighbors for the most suitable mate. Returns true if one is + * found, false if we have no neighbors. + */ bool EggMesherStrip:: find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, const EggVertexPool *vertex_pool) { @@ -473,22 +451,20 @@ find_ideal_mate(EggMesherStrip *&mate, EggMesherEdge *&common_edge, -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::mate_pieces -// Access: Public, Static -// Description: Connects two pieces of arbitrary type, if possible. -// Returns true if successful, false if failure. -//////////////////////////////////////////////////////////////////// +/** + * Connects two pieces of arbitrary type, if possible. Returns true if + * successful, false if failure. + */ bool EggMesherStrip:: -mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, +mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, const EggVertexPool *vertex_pool) { nassertr(front._status == MS_alive, false); nassertr(back._status == MS_alive, false); nassertr(&front != &back, false); bool success = true; - // remove_sides tracks whether we want to remove all but the leading - // edges of the newly joined piece if we succeed. + // remove_sides tracks whether we want to remove all but the leading edges + // of the newly joined piece if we succeed. bool remove_sides = true; bool is_coplanar = front.is_coplanar_with(back, egg_coplanar_threshold); @@ -499,17 +475,16 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, front._prims.front() == back._prims.front() && convex_quad(common_edge, front, back, vertex_pool)) { - // If we're joining two equivalent coplanar triangles, call it a - // quad. + // If we're joining two equivalent coplanar triangles, call it a quad. front._type = PT_quad; - // We add one additional vertex for the new triangle, the one - // vertex we didn't already share. + // We add one additional vertex for the new triangle, the one vertex we + // didn't already share. int new_vert = back.find_uncommon_vertex(common_edge); - // Now we just need to find the right place to insert it. It - // belongs in the middle of the common edge, i.e. after the first - // vertex that is on the common edge and before the second vertex. + // Now we just need to find the right place to insert it. It belongs in + // the middle of the common edge, i.e. after the first vertex that is + // on the common edge and before the second vertex. Verts::iterator a = front._verts.begin(); Verts::iterator b = a; ++b; @@ -531,8 +506,8 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, front._prims.splice(front._prims.end(), back._prims); back._verts.clear(); - // We leave all four surrounding edges for now, since the quad - // might still be joined up in any direction. + // We leave all four surrounding edges for now, since the quad might + // still be joined up in any direction. remove_sides = false; } else { @@ -549,36 +524,34 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, } else if ((front._type == PT_quad || front._type == PT_quadstrip) && (back._type == PT_quad || back._type == PT_quadstrip)) { - // Joining two quads, two quadstrips, or a quad and a quadstrip. - // This makes another quadstrip. + // Joining two quads, two quadstrips, or a quad and a quadstrip. This + // makes another quadstrip. // We expect this to succeed every time with quadstrips. success = mate_strips(common_edge, front, back, PT_quadstrip); if (!success) { - // Although it might fail in rare circumstances (specifically, - // if the two strips we attempted to join were backfacing to - // each other). If so, remove the adjoining edge so these two - // don't get tried again. + // Although it might fail in rare circumstances (specifically, if the + // two strips we attempted to join were backfacing to each other). If + // so, remove the adjoining edge so these two don't get tried again. common_edge->remove(&front); common_edge->remove(&back); } } else { - // Otherwise. This might be two tristrips, a quad and a tristrip, - // a triangle and a quad, a triangle and a tristrip, a triangle - // and a quadstrip, or a tristrip and a quadstrip. In any case, - // we'll end up with a tristrip. + // Otherwise. This might be two tristrips, a quad and a tristrip, a + // triangle and a quad, a triangle and a tristrip, a triangle and a + // quadstrip, or a tristrip and a quadstrip. In any case, we'll end up + // with a tristrip. // This might fail if the tristrips don't match polarity. success = mate_strips(common_edge, front, back, PT_tristrip); if (!success) { - // If it does fail, we'll try reversing the connection. This - // makes sense if we are joining a tri or tristrip to a quad or - // quadstrip, which might fail in one direction but succeed in - // the other. + // If it does fail, we'll try reversing the connection. This makes + // sense if we are joining a tri or tristrip to a quad or quadstrip, + // which might fail in one direction but succeed in the other. success = mate_strips(common_edge, back, front, PT_tristrip); if (success) { @@ -597,8 +570,8 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, if (success) { front.combine_edges(back, remove_sides); if (!remove_sides) { - // If we didn't want to remove the side edges, at least remove - // the join edge, which is now internal. + // If we didn't want to remove the side edges, at least remove the join + // edge, which is now internal. common_edge->remove(&front); } @@ -608,8 +581,7 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, // Strip back is no more. back._status = MS_dead; - // The result is planar if and only if we joined two coplanar - // pieces. + // The result is planar if and only if we joined two coplanar pieces. front._planar = is_coplanar; front._origin = MO_mate; } @@ -617,29 +589,25 @@ mate_pieces(EggMesherEdge *common_edge, EggMesherStrip &front, return success; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::mate_strips -// Access: Public, Static -// Description: Stitches two strips together, producing in "front" a -// new strip of the indicated type (quadstrip or -// tristrip). The front strip stores the result, and -// the back strip is emptied on success. -// -// Returns true if successful, false if failure -// (generally because of incorrect polarity of -// tristrips), in which case nothing has changed (or at -// least, not much). -//////////////////////////////////////////////////////////////////// +/** + * Stitches two strips together, producing in "front" a new strip of the + * indicated type (quadstrip or tristrip). The front strip stores the result, + * and the back strip is emptied on success. + * + * Returns true if successful, false if failure (generally because of + * incorrect polarity of tristrips), in which case nothing has changed (or at + * least, not much). + */ bool EggMesherStrip:: -mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, +mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, EggMesherStrip::PrimType type) { - // We don't allow making odd-length strips at all. Odd-length - // strips can't be rotated if they're flat-shaded, and they can't be - // joined end-to-end using degenerate triangles. So forget 'em. + // We don't allow making odd-length strips at all. Odd-length strips can't + // be rotated if they're flat-shaded, and they can't be joined end-to-end + // using degenerate triangles. So forget 'em. - // This might not be the right place to impose this rule, because it - // tends to end up with lots of independent triangles in certain - // kinds of meshes, but it's the easiest place to impose it. + // This might not be the right place to impose this rule, because it tends + // to end up with lots of independent triangles in certain kinds of meshes, + // but it's the easiest place to impose it. if ((front._type != PT_tri && back._type == PT_tri) || (front._type == PT_tri && back._type != PT_tri) || (front._type == PT_tristrip && back._type == PT_tristrip && @@ -647,8 +615,8 @@ mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, return false; } - // If we start with a quad or tri, rotate the vertices around so we - // start with the common edge. + // If we start with a quad or tri, rotate the vertices around so we start + // with the common edge. if (front._type == PT_tri || front._type == PT_quad) { front.rotate_to_back(common_edge); } @@ -663,9 +631,9 @@ mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, bool invert_back = false; if (reverse_front && front.is_odd()) { - // If we're going to reverse the front strip, we have to be - // careful. This will also reverse the facing direction if it has - // an odd number of prims. + // If we're going to reverse the front strip, we have to be careful. This + // will also reverse the facing direction if it has an odd number of + // prims. if (!front.can_invert()) { return false; } @@ -697,10 +665,9 @@ mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, bool will_reverse = front.would_reverse_tail(type); bool is_headtotail = (front.get_tail_edge() == back.get_head_edge()); if (will_reverse == is_headtotail) { - // Oops, we tried to join two backfacing strips. This really - // shouldn't happen, but it occasionally does for some mysterious - // reason. Maybe one day I'll understand why. In the meantime, - // just recover and carry on. + // Oops, we tried to join two backfacing strips. This really shouldn't + // happen, but it occasionally does for some mysterious reason. Maybe one + // day I'll understand why. In the meantime, just recover and carry on. if (reverse_back) { reverse(back._verts.begin(), back._verts.end()); reverse(back._prims.begin(), back._prims.end()); @@ -744,11 +711,11 @@ mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, } */ - // If this assertion fails, we were misinformed about our ability to - // join these two strips. Either the must_invert() call returned the - // incorrect value, or our edge-detection logic failed and we - // attempted to join two oppositely-facing strips. - //nassertr(front.get_tail_edge() == back.get_head_edge(), false); + // If this assertion fails, we were misinformed about our ability to join + // these two strips. Either the must_invert() call returned the incorrect + // value, or our edge-detection logic failed and we attempted to join two + // oppositely-facing strips. nassertr(front.get_tail_edge() == + // back.get_head_edge(), false); front._verts.pop_back(); front._verts.pop_back(); @@ -758,13 +725,10 @@ mate_strips(EggMesherEdge *common_edge, EggMesherStrip &front, return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::must_invert -// Access: Public, Static -// Description: Returns false if the strips can be mated as they -// currently are. Returns true if the back strip must -// be inverted first. -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the strips can be mated as they currently are. Returns + * true if the back strip must be inverted first. + */ bool EggMesherStrip:: must_invert(const EggMesherStrip &front, const EggMesherStrip &back, bool will_reverse_back, EggMesherStrip::PrimType type) { @@ -772,8 +736,8 @@ must_invert(const EggMesherStrip &front, const EggMesherStrip &back, if ((front._type == PT_quad || front._type == PT_quadstrip) && type == PT_tristrip) { - // If we'll be converting from quads to tris, the tail edge of the - // front strip will always be even. + // If we'll be converting from quads to tris, the tail edge of the front + // strip will always be even. } else if (front.is_odd()) { // Otherwise, we have to flip if the tail edge is odd. @@ -781,12 +745,12 @@ must_invert(const EggMesherStrip &front, const EggMesherStrip &back, } if (will_reverse_back) { - // With the back strip, we don't care about what will happen to - // its tail edge when we convert it, but we do care what happens - // to its front edge if we reverse it. + // With the back strip, we don't care about what will happen to its tail + // edge when we convert it, but we do care what happens to its front edge + // if we reverse it. if (back.is_odd()) { - // Specifically, the front edge will be reversed when the strip - // is reversed only if the strip is odd. + // Specifically, the front edge will be reversed when the strip is + // reversed only if the strip is odd. invert = !invert; } } @@ -794,19 +758,16 @@ must_invert(const EggMesherStrip &front, const EggMesherStrip &back, return invert; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::convex_quad -// Access: Public, Static -// Description: Returns true if the quad that would be formed by -// connecting coplanar tris front and back along -// common_edge is convex, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the quad that would be formed by connecting coplanar tris + * front and back along common_edge is convex, false otherwise. + */ bool EggMesherStrip:: -convex_quad(EggMesherEdge *common_edge, EggMesherStrip &front, +convex_quad(EggMesherEdge *common_edge, EggMesherStrip &front, EggMesherStrip &back, const EggVertexPool *vertex_pool) { - // Find the edge from the apex of one triangle to the apex of the - // other. This is the "other" diagonal of the quad-to-be, other - // than the common_edge. + // Find the edge from the apex of one triangle to the apex of the other. + // This is the "other" diagonal of the quad-to-be, other than the + // common_edge. int vi_a = front.find_uncommon_vertex(common_edge); int vi_b = back.find_uncommon_vertex(common_edge); nassertr(vi_a >= 0 && vi_b >= 0, false); @@ -818,9 +779,8 @@ convex_quad(EggMesherEdge *common_edge, EggMesherStrip &front, c3 = vertex_pool->get_vertex(common_edge->_vi_a)->get_pos3(); d3 = vertex_pool->get_vertex(common_edge->_vi_b)->get_pos3(); - // Project both edges into the 2-d axis plane most nearly - // perpendicular to the normal. We're assuming both tris have the - // same normal. + // Project both edges into the 2-d axis plane most nearly perpendicular to + // the normal. We're assuming both tris have the same normal. nassertr(front._planar, false); @@ -852,20 +812,17 @@ convex_quad(EggMesherEdge *common_edge, EggMesherStrip &front, c2.set(c3[xi], c3[yi]); d2.set(d3[xi], d3[yi]); - // Now (c2-d2) is the common edge, and (a2-b2) is the new edge. The - // quad is convex iff (c2-d2) intersects (a2-b2). We actually only - // need to test whether (c2-d2) intersects the infinite line passing - // through (a2-b2). + // Now (c2-d2) is the common edge, and (a2-b2) is the new edge. The quad is + // convex iff (c2-d2) intersects (a2-b2). We actually only need to test + // whether (c2-d2) intersects the infinite line passing through (a2-b2). - // The equation for the infinite line containing (a2-b2): - // Ax + By + C = 0 + // The equation for the infinite line containing (a2-b2): Ax + By + C = 0 double A = (b2[1] - a2[1]); double B = (a2[0] - b2[0]); double C = -(A*b2[0] + B*b2[1]); - // The parametric equations for the line segment (c2-d2): - // x = c2[0] + (d2[0]-c2[0])t - // y = c2[1] + (d2[1]-c2[1])t + // The parametric equations for the line segment (c2-d2): x = c2[0] + + // (d2[0]-c2[0])t y = c2[1] + (d2[1]-c2[1])t // Solved for t: double t = - ((A*c2[0] + B*c2[1]) + C) / (A*(d2[0]-c2[0]) + B*(d2[1]-c2[1])); @@ -874,11 +831,9 @@ convex_quad(EggMesherEdge *common_edge, EggMesherStrip &front, return (0.0 <= t && t <= 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::count_neighbors -// Access: Public -// Description: Returns the number of neighbors the strip shares. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of neighbors the strip shares. + */ int EggMesherStrip:: count_neighbors() const { int count = 0; @@ -890,11 +845,9 @@ count_neighbors() const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::output_neighbors -// Access: Public -// Description: Writes all the neighbor indexes to the ostream. -//////////////////////////////////////////////////////////////////// +/** + * Writes all the neighbor indexes to the ostream. + */ void EggMesherStrip:: output_neighbors(ostream &out) const { Edges::const_iterator ei; @@ -909,12 +862,9 @@ output_neighbors(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::find_uncommon_vertex -// Access: Public -// Description: Returns the first vertex found that is not shared by -// the given edge. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first vertex found that is not shared by the given edge. + */ int EggMesherStrip:: find_uncommon_vertex(const EggMesherEdge *edge) const { int vi_a = edge->_vi_a; @@ -934,13 +884,10 @@ find_uncommon_vertex(const EggMesherEdge *edge) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::find_opposite_edge -// Access: Public -// Description: Returns the first edge found that does not contain -// the given vertex. In a tri, this will be the edge -// opposite the given vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first edge found that does not contain the given vertex. In a + * tri, this will be the edge opposite the given vertex. + */ const EggMesherEdge *EggMesherStrip:: find_opposite_edge(int vi) const { Edges::const_iterator ei; @@ -954,13 +901,10 @@ find_opposite_edge(int vi) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::find_opposite_edge -// Access: Public -// Description: Returns the first edge found that shares no vertices -// with the given edge. In a quad, this will be the -// edge opposite the given edge. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first edge found that shares no vertices with the given edge. + * In a quad, this will be the edge opposite the given edge. + */ const EggMesherEdge *EggMesherStrip:: find_opposite_edge(const EggMesherEdge *edge) const { int vi_a = edge->_vi_a; @@ -977,13 +921,10 @@ find_opposite_edge(const EggMesherEdge *edge) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::find_adjacent_edge -// Access: Public -// Description: Returns the first edge found that shares exactly one -// vertex with the given edge. In a quad, this will be -// one of two edges adjacent to the given edge. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first edge found that shares exactly one vertex with the given + * edge. In a quad, this will be one of two edges adjacent to the given edge. + */ const EggMesherEdge *EggMesherStrip:: find_adjacent_edge(const EggMesherEdge *edge) const { int vi_a = edge->_vi_a; @@ -1000,12 +941,10 @@ find_adjacent_edge(const EggMesherEdge *edge) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::rotate_to_front -// Access: Public -// Description: Rotates a triangle or quad so that the given edge is -// first in the vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Rotates a triangle or quad so that the given edge is first in the vertex + * list. + */ void EggMesherStrip:: rotate_to_front(const EggMesherEdge *edge) { int vi_a = edge->_vi_a; @@ -1042,12 +981,10 @@ rotate_to_front(const EggMesherEdge *edge) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::rotate_to_back -// Access: Public -// Description: Rotates a triangle or quad so that the given edge is -// last in the vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Rotates a triangle or quad so that the given edge is last in the vertex + * list. + */ void EggMesherStrip:: rotate_to_back(const EggMesherEdge *edge) { int vi_a = edge->_vi_a; @@ -1085,25 +1022,19 @@ rotate_to_back(const EggMesherEdge *edge) { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::can_invert -// Access: Public -// Description: Returns true if the strip can be inverted (reverse -// its facing direction). Generally, this is true for -// quadstrips and false for tristrips. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the strip can be inverted (reverse its facing direction). + * Generally, this is true for quadstrips and false for tristrips. + */ bool EggMesherStrip:: can_invert() const { return (_type == PT_quadstrip || _type == PT_quad); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::invert -// Access: Public -// Description: Reverses the facing of a quadstrip by reversing pairs -// of vertices. Returns true if successful, false if -// failure (for instance, on a tristrip). -//////////////////////////////////////////////////////////////////// +/** + * Reverses the facing of a quadstrip by reversing pairs of vertices. Returns + * true if successful, false if failure (for instance, on a tristrip). + */ bool EggMesherStrip:: invert() { if (!can_invert()) { @@ -1128,31 +1059,26 @@ invert() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::is_odd -// Access: Public -// Description: Returns true if the tristrip or quadstrip contains an -// odd number of pieces. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the tristrip or quadstrip contains an odd number of pieces. + */ bool EggMesherStrip:: is_odd() const { if (_type == PT_quadstrip || _type == PT_quad) { - // If a quadstrip has a multiple of four vertices, it has an - // odd number of quads. + // If a quadstrip has a multiple of four vertices, it has an odd number of + // quads. return (_verts.size() % 4 == 0); } else { - // If a tristrip has an odd number of vertices, it has an odd - // number of tris. + // If a tristrip has an odd number of vertices, it has an odd number of + // tris. return (_verts.size() % 2 == 1); } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::would_reverse_tail -// Access: Public -// Description: Returns true if convert_to_type() would reverse the -// tail edge of the given strip, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if convert_to_type() would reverse the tail edge of the given + * strip, false otherwise. + */ bool EggMesherStrip:: would_reverse_tail(EggMesherStrip::PrimType want_type) const { bool reverse = false; @@ -1168,8 +1094,8 @@ would_reverse_tail(EggMesherStrip::PrimType want_type) const { case PT_quad: case PT_quadstrip: - // When we convert a quadstrip to a tristrip, we reverse the - // tail edge if we have a multiple of four verts. + // When we convert a quadstrip to a tristrip, we reverse the tail edge + // if we have a multiple of four verts. reverse = (_verts.size() % 4 == 0); break; @@ -1200,13 +1126,10 @@ would_reverse_tail(EggMesherStrip::PrimType want_type) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::convert_to_type -// Access: Public -// Description: Converts the EggMesherStrip from whatever form it -// is--triangle, quad, or quadstrip--into a tristrip or -// quadstrip. -//////////////////////////////////////////////////////////////////// +/** + * Converts the EggMesherStrip from whatever form it is--triangle, quad, or + * quadstrip--into a tristrip or quadstrip. + */ void EggMesherStrip:: convert_to_type(EggMesherStrip::PrimType want_type) { Verts::iterator vi, vi2; @@ -1223,8 +1146,8 @@ convert_to_type(EggMesherStrip::PrimType want_type) { case PT_quad: case PT_quadstrip: - // To convert from quad/quadstrip to tristrip, we reverse every - // other pair of vertices. + // To convert from quadquadstrip to tristrip, we reverse every other + // pair of vertices. vi = _verts.begin(); even = 0; @@ -1271,13 +1194,11 @@ convert_to_type(EggMesherStrip::PrimType want_type) { _type = want_type; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::combine_edges -// Access: Public -// Description: Removes the edges from the given strip and appends -// them to our own. If remove_sides is true, then -// removes all the edges except the head and the tail. -//////////////////////////////////////////////////////////////////// +/** + * Removes the edges from the given strip and appends them to our own. If + * remove_sides is true, then removes all the edges except the head and the + * tail. + */ void EggMesherStrip:: combine_edges(EggMesherStrip &other, int remove_sides) { Edges::iterator ei; @@ -1288,14 +1209,13 @@ combine_edges(EggMesherStrip &other, int remove_sides) { _edges.splice(_edges.end(), other._edges); if (remove_sides) { - // Identify the head and tail edges so we can remove everything - // else. + // Identify the head and tail edges so we can remove everything else. EggMesherEdge head = get_head_edge(); EggMesherEdge tail = get_tail_edge(); if (!is_odd()) { - // If the strip is odd, its true tail edge is the inverse of its - // actual edge. + // If the strip is odd, its true tail edge is the inverse of its actual + // edge. tail = EggMesherEdge(tail._vi_b, tail._vi_a); } @@ -1309,9 +1229,8 @@ combine_edges(EggMesherStrip &other, int remove_sides) { // Is this edge to be saved or is it fodder? if (!(**ei == head) && !(**ei == tail)) { - // Fodder! But we can't remove it right away, because this - // will upset the current list; instead, we'll splice it to - // junk_edges. + // Fodder! But we can't remove it right away, because this will upset + // the current list; instead, we'll splice it to junk_edges. junk_edges.splice(junk_edges.end(), _edges, ei); } ei = next_ei; @@ -1325,17 +1244,14 @@ combine_edges(EggMesherStrip &other, int remove_sides) { } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::remove_all_edges -// Access: Public -// Description: Removes all active edges from the strip. This -// effectively renders it ineligible to mate with -// anything else. -//////////////////////////////////////////////////////////////////// +/** + * Removes all active edges from the strip. This effectively renders it + * ineligible to mate with anything else. + */ void EggMesherStrip:: remove_all_edges() { - // First, move all the edges to a safe place so we can traverse the - // list without it changing on us. + // First, move all the edges to a safe place so we can traverse the list + // without it changing on us. Edges junk_edges; junk_edges.splice(junk_edges.end(), _edges); @@ -1346,23 +1262,20 @@ remove_all_edges() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::pick_mate -// Access: Public -// Description: Defines an ordering to select neighbors to mate with. -// This compares strip a with strip b and returns true -// if strip a is the preferable choice, false if strip -// b. -//////////////////////////////////////////////////////////////////// +/** + * Defines an ordering to select neighbors to mate with. This compares strip + * a with strip b and returns true if strip a is the preferable choice, false + * if strip b. + */ bool EggMesherStrip:: pick_mate(const EggMesherStrip &a_strip, const EggMesherStrip &b_strip, const EggMesherEdge &a_edge, const EggMesherEdge &b_edge, const EggVertexPool *vertex_pool) const { - // First, try to avoid polluting quads, quadstrips, and tristrips - // with arbitrary triangles. When we mate a tri or tristrip to a - // quadstrip, we end up with a tristrip that may be less versatile - // than the original quadstrip. Better to avoid this if we can. - // Try to choose a mate that more closely matches our own type. + // First, try to avoid polluting quads, quadstrips, and tristrips with + // arbitrary triangles. When we mate a tri or tristrip to a quadstrip, we + // end up with a tristrip that may be less versatile than the original + // quadstrip. Better to avoid this if we can. Try to choose a mate that + // more closely matches our own type. int a_cat = a_strip.type_category(); int b_cat = b_strip.type_category(); if (a_cat != b_cat) { @@ -1370,16 +1283,15 @@ pick_mate(const EggMesherStrip &a_strip, const EggMesherStrip &b_strip, return abs(a_cat - me_cat) < abs(b_cat - me_cat); } - // Now, if we're connecting two tris, try to connect them up so they - // make good quads. + // Now, if we're connecting two tris, try to connect them up so they make + // good quads. if (_type == PT_tri && a_strip._type == PT_tri && b_strip._type == PT_tri) { - // This will depend on both coplanarity and edge length. We can't - // use just one or the other, because some tris are nearly - // isosceles, and some have more than one coplanar neighbor. - // Hopefully the combination of both factors will zero us in on - // the correct neighbor first. + // This will depend on both coplanarity and edge length. We can't use + // just one or the other, because some tris are nearly isosceles, and some + // have more than one coplanar neighbor. Hopefully the combination of + // both factors will zero us in on the correct neighbor first. double a_coplanar = coplanarity(a_strip); double b_coplanar = coplanarity(b_strip); @@ -1403,17 +1315,14 @@ pick_mate(const EggMesherStrip &a_strip, const EggMesherStrip &b_strip, return a_strip.count_neighbors() < b_strip.count_neighbors(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::pick_sheet_mate -// Access: Public -// Description: Defines an ordering to select neighbors to follow -// when measuring out a quadsheet. This is only called -// when three or more prims share a single edge, which -// should be rarely--generally only when coplanar polys -// are going on. -//////////////////////////////////////////////////////////////////// +/** + * Defines an ordering to select neighbors to follow when measuring out a + * quadsheet. This is only called when three or more prims share a single + * edge, which should be rarely--generally only when coplanar polys are going + * on. + */ bool EggMesherStrip:: -pick_sheet_mate(const EggMesherStrip &a_strip, +pick_sheet_mate(const EggMesherStrip &a_strip, const EggMesherStrip &b_strip) const { // First, try to get the poly which is closest to our own normal. if (_planar && a_strip._planar && b_strip._planar) { @@ -1437,11 +1346,9 @@ pick_sheet_mate(const EggMesherStrip &a_strip, return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggMesherStrip::output -// Access: Public -// Description: Formats the vertex for output in some sensible way. -//////////////////////////////////////////////////////////////////// +/** + * Formats the vertex for output in some sensible way. + */ void EggMesherStrip:: output(ostream &out) const { switch (_status) { @@ -1508,4 +1415,3 @@ output(ostream &out) const { out << "."; } - diff --git a/panda/src/egg/eggMesherStrip.h b/panda/src/egg/eggMesherStrip.h index 366be0d23a..d8a40e3558 100644 --- a/panda/src/egg/eggMesherStrip.h +++ b/panda/src/egg/eggMesherStrip.h @@ -1,16 +1,15 @@ -// Filename: eggMesherStrip.h -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMesherStrip.h + * @author drose + * @date 2005-03-13 + */ #ifndef EGGMESHERSTRIP_H #define EGGMESHERSTRIP_H @@ -23,13 +22,11 @@ class EggMesherEdge; -//////////////////////////////////////////////////////////////////// -// Class : EggMesherStrip -// Description : Represents a triangle strip or quad strip in -// progress, as assembled by the mesher. It might also -// represent a single polygon such as a triangle or -// quad, since that's how strips generally start out. -//////////////////////////////////////////////////////////////////// +/** + * Represents a triangle strip or quad strip in progress, as assembled by the + * mesher. It might also represent a single polygon such as a triangle or + * quad, since that's how strips generally start out. + */ class EggMesherStrip { public: enum PrimType { @@ -45,10 +42,10 @@ public: }; enum MesherOrigin { - MO_unknown, - MO_user, - MO_firstquad, - MO_fanpoly, + MO_unknown, + MO_user, + MO_firstquad, + MO_fanpoly, MO_mate }; @@ -129,9 +126,9 @@ public: Verts _verts; enum MesherStatus { - MS_alive, - MS_dead, - MS_done, + MS_alive, + MS_dead, + MS_done, MS_paired }; diff --git a/panda/src/egg/eggMiscFuncs.I b/panda/src/egg/eggMiscFuncs.I index f7a97b77e0..d822d68d95 100644 --- a/panda/src/egg/eggMiscFuncs.I +++ b/panda/src/egg/eggMiscFuncs.I @@ -1,14 +1,12 @@ -// Filename: eggMiscFuncs.I -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMiscFuncs.I + * @author drose + * @date 1999-01-29 + */ diff --git a/panda/src/egg/eggMiscFuncs.cxx b/panda/src/egg/eggMiscFuncs.cxx index 6cc9af1813..2181622df5 100644 --- a/panda/src/egg/eggMiscFuncs.cxx +++ b/panda/src/egg/eggMiscFuncs.cxx @@ -1,16 +1,15 @@ -// Filename: eggMiscFuncs.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMiscFuncs.cxx + * @author drose + * @date 1999-01-16 + */ #include "pandabase.h" #include "eggMiscFuncs.h" @@ -19,13 +18,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: enquote_string -// Description: Writes the string to the indicated output stream. If -// the string contains any characters special to egg, -// writes quotation marks around it. If always_quote is -// true, writes quotation marks regardless. -//////////////////////////////////////////////////////////////////// +/** + * Writes the string to the indicated output stream. If the string contains + * any characters special to egg, writes quotation marks around it. If + * always_quote is true, writes quotation marks regardless. + */ ostream & enquote_string(ostream &out, const string &str, int indent_level, bool always_quote) { @@ -52,8 +49,8 @@ enquote_string(ostream &out, const string &str, int indent_level, break; case '\n': - // A newline necessitates ending the quotes, newlining, and - // beginning again. + // A newline necessitates ending the quotes, newlining, and beginning + // again. out << "\"\n"; indent(out, indent_level) << '"'; break; @@ -69,11 +66,9 @@ enquote_string(ostream &out, const string &str, int indent_level, } -//////////////////////////////////////////////////////////////////// -// Function: write_transform -// Description: A helper function to write out a 3x3 transform -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * A helper function to write out a 3x3 transform matrix. + */ void write_transform(ostream &out, const LMatrix3d &mat, int indent_level) { indent(out, indent_level) << " {\n"; @@ -91,11 +86,9 @@ write_transform(ostream &out, const LMatrix3d &mat, int indent_level) { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: write_transform -// Description: A helper function to write out a 4x4 transform -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * A helper function to write out a 4x4 transform matrix. + */ void write_transform(ostream &out, const LMatrix4d &mat, int indent_level) { indent(out, indent_level) << " {\n"; diff --git a/panda/src/egg/eggMiscFuncs.h b/panda/src/egg/eggMiscFuncs.h index d3a6934951..c157e7c9c9 100644 --- a/panda/src/egg/eggMiscFuncs.h +++ b/panda/src/egg/eggMiscFuncs.h @@ -1,41 +1,32 @@ -// Filename: eggMiscFuncs.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMiscFuncs.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGMISCFUNCS_H #define EGGMISCFUNCS_H -//////////////////////////////////////////////////////////////////// -// -// eggMiscFuncs.h -// -// This contains the prototypes for functions that are useful to -// internal egg code. Also see eggUtilities.h, which contains -// functions that may be useful to the rest of the world. -// -//////////////////////////////////////////////////////////////////// +// eggMiscFuncs.h This contains the prototypes for functions that are useful +// to internal egg code. Also see eggUtilities.h, which contains functions +// that may be useful to the rest of the world. #include "pandabase.h" #include "lmatrix.h" -//////////////////////////////////////////////////////////////////// -// Function: enquote_string -// Description: Writes the string to the indicated output stream. If -// the string contains any characters special to egg, -// writes quotation marks around it. If always_quote is -// true, writes quotation marks regardless. -//////////////////////////////////////////////////////////////////// +/** + * Writes the string to the indicated output stream. If the string contains + * any characters special to egg, writes quotation marks around it. If + * always_quote is true, writes quotation marks regardless. + */ ostream & enquote_string(ostream &out, const string &str, int indent_level = 0, @@ -43,19 +34,15 @@ enquote_string(ostream &out, const string &str, -//////////////////////////////////////////////////////////////////// -// Function: write_transform -// Description: A helper function to write out a 3x3 transform -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * A helper function to write out a 3x3 transform matrix. + */ void write_transform(ostream &out, const LMatrix3d &mat, int indent_level); -//////////////////////////////////////////////////////////////////// -// Function: write_transform -// Description: A helper function to write out a 4x4 transform -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * A helper function to write out a 4x4 transform matrix. + */ void write_transform(ostream &out, const LMatrix4d &mat, int indent_level); @@ -63,4 +50,3 @@ write_transform(ostream &out, const LMatrix4d &mat, int indent_level); #include "eggMiscFuncs.I" #endif - diff --git a/panda/src/egg/eggMorph.I b/panda/src/egg/eggMorph.I index a7e6c29583..6b39b2a13e 100644 --- a/panda/src/egg/eggMorph.I +++ b/panda/src/egg/eggMorph.I @@ -1,23 +1,19 @@ -// Filename: eggMorph.I -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMorph.I + * @author drose + * @date 1999-01-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE EggMorph:: EggMorph(const string &name, const Parameter &offset) @@ -26,11 +22,9 @@ EggMorph(const string &name, const Parameter &offset) -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::set_offset -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void EggMorph:: set_offset(const Parameter &offset) { @@ -38,11 +32,9 @@ set_offset(const Parameter &offset) { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::get_offset -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const Parameter &EggMorph:: get_offset() const { @@ -50,11 +42,9 @@ get_offset() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::Ordering operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorph:: operator < (const EggMorph &other) const { @@ -62,35 +52,28 @@ operator < (const EggMorph &other) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::Equality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorph:: operator == (const EggMorph &other) const { return get_name() == other.get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::Inequality operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorph:: operator != (const EggMorph &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::compare_to -// Access: Public -// Description: compare_to() compares a different space than the -// operator methods, which only check the name. -// compare_to() compares the name and the value as well. -//////////////////////////////////////////////////////////////////// +/** + * compare_to() compares a different space than the operator methods, which + * only check the name. compare_to() compares the name and the value as well. + */ template INLINE int EggMorph:: compare_to(const EggMorph &other, double threshold) const { @@ -101,11 +84,9 @@ compare_to(const EggMorph &other, double threshold) const { return _offset.compare_to(other._offset, threshold); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorph::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void EggMorph:: output(ostream &out, const string &tag, int num_dimensions) const { diff --git a/panda/src/egg/eggMorph.h b/panda/src/egg/eggMorph.h index 04644e9ec7..f58a5f56b8 100644 --- a/panda/src/egg/eggMorph.h +++ b/panda/src/egg/eggMorph.h @@ -1,16 +1,15 @@ -// Filename: eggMorph.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMorph.h + * @author drose + * @date 1999-01-29 + */ #ifndef EGGMORPH_H #define EGGMORPH_H @@ -21,14 +20,12 @@ #include "luse.h" #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMorph -// Description : A single or or some such entry. This -// simply contains the morph name and the offset value. -// The class EggMorph is actually a template class on -// the type of value that is being offset; the specific -// kinds of morphs are instantiated from this below. -//////////////////////////////////////////////////////////////////// +/** + * A single or or some such entry. This simply contains the + * morph name and the offset value. The class EggMorph is actually a template + * class on the type of value that is being offset; the specific kinds of + * morphs are instantiated from this below. + */ template class EggMorph : public Namable { public: @@ -49,8 +46,8 @@ private: Parameter _offset; }; -// I'd love to export these, but it produces a strange linker issue -// with Mac OS X's version of GCC. We'll do it only on Windows, then. +// I'd love to export these, but it produces a strange linker issue with Mac +// OS X's version of GCC. We'll do it only on Windows, then. #ifdef _MSC_VER EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, EggMorph); diff --git a/panda/src/egg/eggMorphList.I b/panda/src/egg/eggMorphList.I index 2b922ff936..5b665247da 100644 --- a/panda/src/egg/eggMorphList.I +++ b/panda/src/egg/eggMorphList.I @@ -1,33 +1,27 @@ -// Filename: eggMorphList.I -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMorphList.I + * @author drose + * @date 1999-01-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE EggMorphList:: EggMorphList() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE EggMorphList:: EggMorphList(const EggMorphList ©) : @@ -35,67 +29,55 @@ EggMorphList(const EggMorphList ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void EggMorphList:: operator = (const EggMorphList ©) { _morphs = copy._morphs; } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE EggMorphList:: ~EggMorphList() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorphList:: operator == (const EggMorphList &other) const { return (_morphs == other._morphs); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorphList:: operator != (const EggMorphList &other) const { return (_morphs != other._morphs); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorphList:: operator < (const EggMorphList &other) const { return (_morphs < other._morphs); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::compare_to -// Access: Public -// Description: compare_to() compares a different space than the -// operator methods, which only check the morph's name. -// compare_to() compares the name and the value as well. -//////////////////////////////////////////////////////////////////// +/** + * compare_to() compares a different space than the operator methods, which + * only check the morph's name. compare_to() compares the name and the value + * as well. + */ template int EggMorphList:: compare_to(const EggMorphList &other, double threshold) const { @@ -111,83 +93,67 @@ compare_to(const EggMorphList &other, double threshold) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME EggMorphList::iterator EggMorphList:: begin() { return _morphs.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: begin() const { return _morphs.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME EggMorphList::iterator EggMorphList:: end() { return _morphs.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME EggMorphList::const_iterator EggMorphList:: end() const { return _morphs.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME EggMorphList::size_type EggMorphList:: size() const { return _morphs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool EggMorphList:: empty() const { return _morphs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::insert -// Access: Public -// Description: This is similar to the insert() interface for sets, -// except it does not guarantee that the resulting list -// is sorted. -// -// We have this member function so the EggMorphList -// resembles a set. It used to *be* a set, but we -// cannot export STL sets from a Windows DLL. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to the insert() interface for sets, except it does not + * guarantee that the resulting list is sorted. + * + * We have this member function so the EggMorphList resembles a set. It used + * to *be* a set, but we cannot export STL sets from a Windows DLL. + */ template pair::iterator, bool> EggMorphList:: insert(const MorphType &value) { @@ -209,25 +175,21 @@ insert(const MorphType &value) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::clear -// Access: Public -// Description: Empties the list of morphs. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of morphs. + */ template INLINE void EggMorphList:: clear() { _morphs.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMorphList::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void EggMorphList:: -write(ostream &out, int indent_level, const string &tag, +write(ostream &out, int indent_level, const string &tag, int num_dimensions) const { const_iterator i; @@ -237,4 +199,3 @@ write(ostream &out, int indent_level, const string &tag, out << "\n"; } } - diff --git a/panda/src/egg/eggMorphList.cxx b/panda/src/egg/eggMorphList.cxx index 626721ee74..eb5a12a9b1 100644 --- a/panda/src/egg/eggMorphList.cxx +++ b/panda/src/egg/eggMorphList.cxx @@ -1,16 +1,15 @@ -// Filename: eggMorphList.cxx -// Created by: drose (15May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMorphList.cxx + * @author drose + * @date 2001-05-15 + */ #include "eggMorphList.h" diff --git a/panda/src/egg/eggMorphList.h b/panda/src/egg/eggMorphList.h index fb6013190e..c6e86388ba 100644 --- a/panda/src/egg/eggMorphList.h +++ b/panda/src/egg/eggMorphList.h @@ -1,16 +1,15 @@ -// Filename: eggMorphList.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMorphList.h + * @author drose + * @date 1999-01-29 + */ #ifndef EGGMORPHLIST_H #define EGGMORPHLIST_H @@ -23,10 +22,9 @@ #include "epvector.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMorphList -// Description : A collection of 's or 's or some such. -//////////////////////////////////////////////////////////////////// +/** + * A collection of 's or 's or some such. + */ template class EggMorphList { private: diff --git a/panda/src/egg/eggNameUniquifier.cxx b/panda/src/egg/eggNameUniquifier.cxx index 35a249b4ba..0e50320d45 100644 --- a/panda/src/egg/eggNameUniquifier.cxx +++ b/panda/src/egg/eggNameUniquifier.cxx @@ -1,16 +1,15 @@ -// Filename: eggNameUniquifier.cxx -// Created by: drose (09Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNameUniquifier.cxx + * @author drose + * @date 2000-11-09 + */ #include "eggNameUniquifier.h" #include "eggNode.h" @@ -23,42 +22,33 @@ TypeHandle EggNameUniquifier::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggNameUniquifier:: EggNameUniquifier() { _index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggNameUniquifier:: ~EggNameUniquifier() { } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::clear -// Access: Public -// Description: Empties the table of used named and prepares the -// Uniquifier for a new tree. -//////////////////////////////////////////////////////////////////// +/** + * Empties the table of used named and prepares the Uniquifier for a new tree. + */ void EggNameUniquifier:: clear() { _categories.clear(); _index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::uniquify -// Access: Public -// Description: Begins the traversal from the indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Begins the traversal from the indicated node. + */ void EggNameUniquifier:: uniquify(EggNode *node) { string category = get_category(node); @@ -105,12 +95,10 @@ uniquify(EggNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::get_node -// Access: Public -// Description: Returns the node associated with the given category -// and name, or NULL if the name has not been used. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node associated with the given category and name, or NULL if + * the name has not been used. + */ EggNode *EggNameUniquifier:: get_node(const string &category, const string &name) const { Categories::const_iterator ci; @@ -129,12 +117,10 @@ get_node(const string &category, const string &name) const { return (*ni).second; } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::has_name -// Access: Public -// Description: Returns true if the name has been used for the -// indicated category already, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the name has been used for the indicated category already, + * false otherwise. + */ bool EggNameUniquifier:: has_name(const string &category, const string &name) const { Categories::const_iterator ci; @@ -153,14 +139,11 @@ has_name(const string &category, const string &name) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::add_name -// Access: Public -// Description: Adds the name to the indicated category. This name -// will not be used for any other egg node within this -// category. Returns true if the name was added, or -// false if it was already in use for the category. -//////////////////////////////////////////////////////////////////// +/** + * Adds the name to the indicated category. This name will not be used for + * any other egg node within this category. Returns true if the name was + * added, or false if it was already in use for the category. + */ bool EggNameUniquifier:: add_name(const string &category, const string &name, EggNode *node) { UsedNames &names = _categories[category]; @@ -168,31 +151,24 @@ add_name(const string &category, const string &name, EggNode *node) { return inserted; } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::filter_name -// Access: Public, Virtual -// Description: Returns the name of the given node, or at least the -// name it should be. This provides a hook to adjust -// the name before attempting to uniquify it, if -// desired, for instance to remove invalid characters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the given node, or at least the name it should be. + * This provides a hook to adjust the name before attempting to uniquify it, + * if desired, for instance to remove invalid characters. + */ string EggNameUniquifier:: filter_name(EggNode *node) { return node->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNameUniquifier::generate_name -// Access: Public, Virtual -// Description: Generates a new name for the given node when its -// existing name clashes with some other node. This -// function will be called repeatedly, if necessary, -// until it returns a name that actually is unique. -// -// The category is the string returned by -// get_category(), and index is a uniquely-generated -// number that may be useful for synthesizing the name. -//////////////////////////////////////////////////////////////////// +/** + * Generates a new name for the given node when its existing name clashes with + * some other node. This function will be called repeatedly, if necessary, + * until it returns a name that actually is unique. + * + * The category is the string returned by get_category(), and index is a + * uniquely-generated number that may be useful for synthesizing the name. + */ string EggNameUniquifier:: generate_name(EggNode *node, const string &category, int index) { string name = filter_name(node); diff --git a/panda/src/egg/eggNameUniquifier.h b/panda/src/egg/eggNameUniquifier.h index d41136ba58..d28457a97d 100644 --- a/panda/src/egg/eggNameUniquifier.h +++ b/panda/src/egg/eggNameUniquifier.h @@ -1,74 +1,47 @@ -// Filename: eggNameUniquifier.h -// Created by: drose (09Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNameUniquifier.h + * @author drose + * @date 2000-11-09 + */ #ifndef EGGNAMEUNIQUIFIER_H #define EGGNAMEUNIQUIFIER_H -//////////////////////////////////////////////////////////////////// -// -// EggNameUniquifier -// -// This is a utility class for renaming nodes in an egg hierarchy so -// that no two nodes share the same name. It's useful, for instance, -// as a preprocess before translating the egg hierarchy to a scene -// graph format that doesn't tolerate two identically-named nodes; -// it's also particularly useful for guaranteeing that VertexPools and -// Textures do not have conflicting names. -// -// This is actually an abstract class; in order to use it, you must -// derive your own class and redefine some key functions (but see -// EggPoolUniquifier and EggGroupUniquifier). -// -// You must define at least the following function: -// -// virtual string get_category(EggNode *node); -// -// This function defines the particular category that the -// particular node should be grouped into. All nodes that share -// the same category name will be considered in the same name pool -// and may not have the same name; two nodes that have different -// categories will be allowed to keep the same name. -// -// If the category is the empty string, the node will not be -// considered for uniquification. -// -// -// You may also define the following function: -// -// virtual string filter_name(EggNode *node); -// -// This returns the name of the node, or at least the name it ought -// to be. This provides a hook for, for instance, filtering out -// invalid characters before the node name is uniquified. -// -// -// virtual string generate_name(EggNode *node, -// const string &category, int index); -// -// This returns a new name for the given node, once a node has been -// identified as having the same name as another node. It may use -// any algorithm you please to generate a new name, using any -// combination of the node's original name, the category (as -// returned by get_category()), and/or the supplied unique index -// number. -// -// If this function returns a name that happens to collide with -// some other already-existing node, it will simply be called again -// (with a new index number) until it finally returns a unique -// name. -// -//////////////////////////////////////////////////////////////////// +/* + * EggNameUniquifier This is a utility class for renaming nodes in an egg + * hierarchy so that no two nodes share the same name. It's useful, for + * instance, as a preprocess before translating the egg hierarchy to a scene + * graph format that doesn't tolerate two identically-named nodes; it's also + * particularly useful for guaranteeing that VertexPools and Textures do not + * have conflicting names. This is actually an abstract class; in order to + * use it, you must derive your own class and redefine some key functions (but + * see EggPoolUniquifier and EggGroupUniquifier). You must define at least the + * following function: virtual string get_category(EggNode *node); This + * function defines the particular category that the particular node should be + * grouped into. All nodes that share the same category name will be + * considered in the same name pool and may not have the same name; two nodes + * that have different categories will be allowed to keep the same name. If + * the category is the empty string, the node will not be considered for + * uniquification. You may also define the following function: virtual string + * filter_name(EggNode *node); This returns the name of the node, or at least + * the name it ought to be. This provides a hook for, for instance, filtering + * out invalid characters before the node name is uniquified. virtual string + * generate_name(EggNode *node, const string &category, int index); This + * returns a new name for the given node, once a node has been identified as + * having the same name as another node. It may use any algorithm you please + * to generate a new name, using any combination of the node's original name, + * the category (as returned by get_category()), andor the supplied unique + * index number. If this function returns a name that happens to collide with + * some other already-existing node, it will simply be called again (with a + * new index number) until it finally returns a unique name. + */ #include "pandabase.h" @@ -78,13 +51,11 @@ class EggNode; -//////////////////////////////////////////////////////////////////// -// Class : EggNameUniquifier -// Description : This is a handy class for guaranteeing unique node -// names in an egg hierarchy. It is an abstract class; -// to use it you must subclass off of it. See the -// comment above. -//////////////////////////////////////////////////////////////////// +/** + * This is a handy class for guaranteeing unique node names in an egg + * hierarchy. It is an abstract class; to use it you must subclass off of it. + * See the comment above. + */ class EXPCL_PANDAEGG EggNameUniquifier : public EggObject { PUBLISHED: EggNameUniquifier(); @@ -132,5 +103,3 @@ private: }; #endif - - diff --git a/panda/src/egg/eggNamedObject.I b/panda/src/egg/eggNamedObject.I index 043c743800..6227e51696 100644 --- a/panda/src/egg/eggNamedObject.I +++ b/panda/src/egg/eggNamedObject.I @@ -1,43 +1,35 @@ -// Filename: eggNamedObject.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNamedObject.I + * @author drose + * @date 1999-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggNamedObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNamedObject:: EggNamedObject(const string &name) : Namable(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNamedObject::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNamedObject:: EggNamedObject(const EggNamedObject ©) : EggObject(copy), Namable(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNamedObject::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNamedObject &EggNamedObject:: operator = (const EggNamedObject ©) { EggObject::operator = (copy); diff --git a/panda/src/egg/eggNamedObject.cxx b/panda/src/egg/eggNamedObject.cxx index e61d79cf3e..663cfc3ed6 100644 --- a/panda/src/egg/eggNamedObject.cxx +++ b/panda/src/egg/eggNamedObject.cxx @@ -1,16 +1,15 @@ -// Filename: eggNamedObject.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNamedObject.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggNamedObject.h" #include "eggMiscFuncs.h" @@ -19,11 +18,9 @@ TypeHandle EggNamedObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggNamedObject::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggNamedObject:: output(ostream &out) const { out << get_type(); @@ -32,15 +29,12 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNamedObject::write_header -// Access: Public -// Description: Writes the first line of the egg object, -// e.g. " group_name {" or some such. It -// automatically enquotes the name if it contains any -// special characters. egg_keyword is the keyword that -// begins the line, e.g. "". -//////////////////////////////////////////////////////////////////// +/** + * Writes the first line of the egg object, e.g. " group_name {" or + * some such. It automatically enquotes the name if it contains any special + * characters. egg_keyword is the keyword that begins the line, e.g. + * "". + */ void EggNamedObject:: write_header(ostream &out, int indent_level, const char *egg_keyword) const { indent(out, indent_level) << egg_keyword << " "; diff --git a/panda/src/egg/eggNamedObject.h b/panda/src/egg/eggNamedObject.h index 989446d957..9f002961cb 100644 --- a/panda/src/egg/eggNamedObject.h +++ b/panda/src/egg/eggNamedObject.h @@ -1,16 +1,15 @@ -// Filename: eggNamedObject.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNamedObject.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGNAMEDOBJECT_H #define EGGNAMEDOBJECT_H @@ -21,11 +20,9 @@ #include "namable.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : EggNamedObject -// Description : This is a fairly low-level base class--any egg -// object that has a name. -//////////////////////////////////////////////////////////////////// +/** + * This is a fairly low-level base class--any egg object that has a name. + */ class EXPCL_PANDAEGG EggNamedObject : public EggObject, public Namable { PUBLISHED: INLINE EggNamedObject(const string &name = ""); diff --git a/panda/src/egg/eggNode.I b/panda/src/egg/eggNode.I index d215971950..08f2f8989b 100644 --- a/panda/src/egg/eggNode.I +++ b/panda/src/egg/eggNode.I @@ -1,23 +1,19 @@ -// Filename: eggNode.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNode.I + * @author drose + * @date 1999-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNode:: EggNode(const string &name) : EggNamedObject(name) { _parent = NULL; @@ -25,11 +21,9 @@ EggNode(const string &name) : EggNamedObject(name) { _under_flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNode:: EggNode(const EggNode ©) : EggNamedObject(copy) { _parent = NULL; @@ -38,11 +32,9 @@ EggNode(const EggNode ©) : EggNamedObject(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNode &EggNode:: operator = (const EggNode ©) { EggNamedObject::operator = (copy); @@ -51,86 +43,67 @@ operator = (const EggNode ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_parent -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggGroupNode *EggNode:: get_parent() const { return _parent; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_depth -// Access: Public -// Description: Returns the number of nodes above this node in the -// egg hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nodes above this node in the egg hierarchy. + */ INLINE int EggNode:: get_depth() const { return _depth; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::is_under_instance -// Access: Public -// Description: Returns true if there is an node somewhere -// in the egg tree at or above this node, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an node somewhere in the egg tree at or + * above this node, false otherwise. + */ INLINE bool EggNode:: is_under_instance() const { return (_under_flags & UF_under_instance) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::is_under_transform -// Access: Public -// Description: Returns true if there is a entry somewhere -// in the egg tree at or above this node, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a entry somewhere in the egg tree at + * or above this node, false otherwise. + */ INLINE bool EggNode:: is_under_transform() const { return (_under_flags & UF_under_transform) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::is_local_coord -// Access: Public -// Description: Returns true if this node's vertices are not in the -// global coordinate space. This will be the case if -// there was an node under a transform at or -// above this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node's vertices are not in the global coordinate + * space. This will be the case if there was an node under a + * transform at or above this node. + */ INLINE bool EggNode:: is_local_coord() const { return (_under_flags & UF_local_coord) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_frame -// Access: Public -// Description: Returns the coordinate frame of the vertices -// referenced by primitives at or under this node. This -// is not the same as get_node_frame(). -// -// Generally, vertices in an egg file are stored in the -// global coordinate space, regardless of the transforms -// defined at each node. Thus, get_vertex_frame() will -// usually return the identity transform (global -// coordinate space). However, primitives under an -// entry reference their vertices in the -// coordinate system under effect at the time of the -// . Thus, nodes under an entry -// may return this non-identity matrix. -// -// Specifically, this may return a non-identity matrix -// only if is_local_coord() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate frame of the vertices referenced by primitives at or + * under this node. This is not the same as get_node_frame(). + * + * Generally, vertices in an egg file are stored in the global coordinate + * space, regardless of the transforms defined at each node. Thus, + * get_vertex_frame() will usually return the identity transform (global + * coordinate space). However, primitives under an entry reference + * their vertices in the coordinate system under effect at the time of the + * . Thus, nodes under an entry may return this non- + * identity matrix. + * + * Specifically, this may return a non-identity matrix only if + * is_local_coord() is true. + */ INLINE const LMatrix4d &EggNode:: get_vertex_frame() const { if (_vertex_frame == (LMatrix4d *)NULL) { @@ -141,13 +114,10 @@ get_vertex_frame() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_frame -// Access: Public -// Description: Returns the coordinate frame of the node itself. -// This is simply the net product of all transformations -// up to the root. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate frame of the node itself. This is simply the net + * product of all transformations up to the root. + */ INLINE const LMatrix4d &EggNode:: get_node_frame() const { if (_node_frame == (LMatrix4d *)NULL) { @@ -157,12 +127,10 @@ get_node_frame() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_frame_inv -// Access: Public -// Description: Returns the inverse of the matrix returned by -// get_vertex_frame(). See get_vertex_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of the matrix returned by get_vertex_frame(). See + * get_vertex_frame(). + */ INLINE const LMatrix4d &EggNode:: get_vertex_frame_inv() const { if (_vertex_frame_inv == (LMatrix4d *)NULL) { @@ -173,12 +141,10 @@ get_vertex_frame_inv() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_frame_inv -// Access: Public -// Description: Returns the inverse of the matrix returned by -// get_node_frame(). See get_node_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of the matrix returned by get_node_frame(). See + * get_node_frame(). + */ INLINE const LMatrix4d &EggNode:: get_node_frame_inv() const { if (_node_frame_inv == (LMatrix4d *)NULL) { @@ -188,17 +154,14 @@ get_node_frame_inv() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_to_node -// Access: Public -// Description: Returns the transformation matrix suitable for -// converting the vertices as read from the egg file -// into the coordinate space of the node. This is the -// same thing as: -// -// get_vertex_frame() * get_node_frame_inv() -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the transformation matrix suitable for converting the vertices as + * read from the egg file into the coordinate space of the node. This is the + * same thing as: + * + * get_vertex_frame() * get_node_frame_inv() + * + */ INLINE const LMatrix4d &EggNode:: get_vertex_to_node() const { if (_vertex_to_node == (LMatrix4d *)NULL) { @@ -208,17 +171,14 @@ get_vertex_to_node() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_to_vertex -// Access: Public -// Description: Returns the transformation matrix suitable for -// converting vertices in the coordinate space of the -// node to the appropriate coordinate space for storing -// in the egg file. This is the same thing as: -// -// get_node_frame() * get_vertex_frame_inv() -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the transformation matrix suitable for converting vertices in the + * coordinate space of the node to the appropriate coordinate space for + * storing in the egg file. This is the same thing as: + * + * get_node_frame() * get_vertex_frame_inv() + * + */ INLINE const LMatrix4d &EggNode:: get_node_to_vertex() const { if (_node_to_vertex == (LMatrix4d *)NULL) { @@ -228,87 +188,67 @@ get_node_to_vertex() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_frame_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_vertex_frame() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_vertex_frame() matrix. + */ INLINE const LMatrix4d *EggNode:: get_vertex_frame_ptr() const { return _vertex_frame; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_frame_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_node_frame() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_node_frame() matrix. + */ INLINE const LMatrix4d *EggNode:: get_node_frame_ptr() const { return _node_frame; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_frame_inv_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_vertex_frame_inv() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_vertex_frame_inv() matrix. + */ INLINE const LMatrix4d *EggNode:: get_vertex_frame_inv_ptr() const { return _vertex_frame_inv; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_frame_inv_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_node_frame_inv() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_node_frame_inv() matrix. + */ INLINE const LMatrix4d *EggNode:: get_node_frame_inv_ptr() const { return _node_frame_inv; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_vertex_to_node_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_vertex_to_node() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_vertex_to_node() matrix. + */ INLINE const LMatrix4d *EggNode:: get_vertex_to_node_ptr() const { return _vertex_to_node; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::get_node_to_vertex_ptr -// Access: Public -// Description: Returns either a NULL pointer or a unique pointer -// shared by nodes with the same get_node_to_vertex() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns either a NULL pointer or a unique pointer shared by nodes with the + * same get_node_to_vertex() matrix. + */ INLINE const LMatrix4d *EggNode:: get_node_to_vertex_ptr() const { return _node_to_vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::transform -// Access: Public -// Description: Applies the indicated transformation to the node and -// all of its descendants. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation to the node and all of its + * descendants. + */ INLINE void EggNode:: transform(const LMatrix4d &mat) { LMatrix4d inv = invert(mat); @@ -316,37 +256,30 @@ transform(const LMatrix4d &mat) { r_transform(mat, inv, CS_default); r_transform_vertices(mat); - // Now we have to recompute the under_flags to ensure that all the - // cached relative matrices are correct. + // Now we have to recompute the under_flags to ensure that all the cached + // relative matrices are correct. update_under(0); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::transform_vertices_only -// Access: Public -// Description: Applies the indicated transformation only to vertices -// that appear in global space within vertex pools at -// this node and below. Joints and other transforms are -// not affected, nor are local vertices. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation only to vertices that appear in global + * space within vertex pools at this node and below. Joints and other + * transforms are not affected, nor are local vertices. + */ INLINE void EggNode:: transform_vertices_only(const LMatrix4d &mat) { r_transform_vertices(mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::flatten_transforms -// Access: Public -// Description: Removes any transform and instance records from this -// node in the scene graph and below. If an instance -// node is encountered, removes the instance and applies -// the transform to its vertices, duplicating vertices -// if necessary. -// -// Since this function may result in duplicated -// vertices, it may be a good idea to call -// remove_unused_vertices() after calling this. -//////////////////////////////////////////////////////////////////// +/** + * Removes any transform and instance records from this node in the scene + * graph and below. If an instance node is encountered, removes the instance + * and applies the transform to its vertices, duplicating vertices if + * necessary. + * + * Since this function may result in duplicated vertices, it may be a good + * idea to call remove_unused_vertices() after calling this. + */ INLINE void EggNode:: flatten_transforms() { r_flatten_transforms(); diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index 4077561239..016ae01994 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -1,16 +1,15 @@ -// Filename: eggNode.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNode.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggNode.h" #include "eggGroupNode.h" @@ -28,11 +27,9 @@ extern int eggyyparse(); TypeHandle EggNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggNode::rename_node -// Access: Published -// Description: Rename by stripping out the prefix -//////////////////////////////////////////////////////////////////// +/** + * Rename by stripping out the prefix + */ int EggNode:: rename_node(vector_string strip_prefix) { int num_renamed = 0; @@ -40,7 +37,7 @@ rename_node(vector_string strip_prefix) { string axe_name = strip_prefix[ni]; if (this->get_name().substr(0, axe_name.size()) == axe_name) { string new_name = this->get_name().substr(axe_name.size()); - //cout << "renaming " << this->get_name() << "->" << new_name << endl; + // cout << "renaming " << this->get_name() << "->" << new_name << endl; this->set_name(new_name); num_renamed += 1; } @@ -48,13 +45,10 @@ rename_node(vector_string strip_prefix) { return num_renamed; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::apply_texmats -// Access: Public -// Description: Applies the texture matrices to the UV's of the -// vertices that reference them, and then removes the -// texture matrices from the textures themselves. -//////////////////////////////////////////////////////////////////// +/** + * Applies the texture matrices to the UV's of the vertices that reference + * them, and then removes the texture matrices from the textures themselves. + */ void EggNode:: apply_texmats() { EggTextureCollection textures; @@ -62,40 +56,31 @@ apply_texmats() { r_apply_texmats(textures); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::is_joint -// Access: Public, Virtual -// Description: Returns true if this particular node represents a -// entry or not. This is a handy thing to know -// since Joints are sorted to the end of their sibling -// list when writing an egg file. See -// EggGroupNode::write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular node represents a entry or not. + * This is a handy thing to know since Joints are sorted to the end of their + * sibling list when writing an egg file. See EggGroupNode::write(). + */ bool EggNode:: is_joint() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::is_anim_matrix -// Access: Public, Virtual -// Description: Returns true if this node represents a table of -// animation transformation data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents a table of animation transformation + * data, false otherwise. + */ bool EggNode:: is_anim_matrix() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_alpha_mode -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has an alpha_mode other than -// AM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has an alpha_mode + * other than AM_unspecified. Returns a valid EggRenderMode pointer if one is + * found, or NULL otherwise. + */ EggRenderMode *EggNode:: determine_alpha_mode() { if (_parent == (EggGroupNode *)NULL) { @@ -105,15 +90,12 @@ determine_alpha_mode() { return _parent->determine_alpha_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_depth_write_mode -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a depth_write_mode other than -// DWM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * depth_write_mode other than DWM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggNode:: determine_depth_write_mode() { if (_parent == (EggGroupNode *)NULL) { @@ -123,15 +105,12 @@ determine_depth_write_mode() { return _parent->determine_depth_write_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_depth_test_mode -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a depth_test_mode other than -// DTM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * depth_test_mode other than DTM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggNode:: determine_depth_test_mode() { if (_parent == (EggGroupNode *)NULL) { @@ -141,15 +120,12 @@ determine_depth_test_mode() { return _parent->determine_depth_test_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_visibility_mode -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a visibility_mode other than -// VM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * visibility_mode other than VM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggNode:: determine_visibility_mode() { if (_parent == (EggGroupNode *)NULL) { @@ -159,15 +135,12 @@ determine_visibility_mode() { return _parent->determine_visibility_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_depth_offset -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a depth_offset specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a depth_offset + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggNode:: determine_depth_offset() { if (_parent == (EggGroupNode *)NULL) { @@ -177,15 +150,12 @@ determine_depth_offset() { return _parent->determine_depth_offset(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_draw_order -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a draw_order specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a draw_order + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggNode:: determine_draw_order() { if (_parent == (EggGroupNode *)NULL) { @@ -195,15 +165,11 @@ determine_draw_order() { return _parent->determine_draw_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_bin -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a bin specified. Returns a -// valid EggRenderMode pointer if one is found, or NULL -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a bin specified. + * Returns a valid EggRenderMode pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggNode:: determine_bin() { if (_parent == (EggGroupNode *)NULL) { @@ -213,17 +179,14 @@ determine_bin() { return _parent->determine_bin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_indexed -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// at this level or above that has the "indexed" scalar -// set. Returns the value of the indexed scalar if it -// is found, or false if it is not. -// -// In other words, returns true if the "indexed" flag is -// in effect for the indicated node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup at this level or above + * that has the "indexed" scalar set. Returns the value of the indexed scalar + * if it is found, or false if it is not. + * + * In other words, returns true if the "indexed" flag is in effect for the + * indicated node, false otherwise. + */ bool EggNode:: determine_indexed() { if (_parent == (EggGroupNode *)NULL) { @@ -233,17 +196,14 @@ determine_indexed() { return _parent->determine_indexed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::determine_decal -// Access: Public, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// at this level or above that has the "decal" flag -// set. Returns the value of the decal flag if it -// is found, or false if it is not. -// -// In other words, returns true if the "decal" flag is -// in effect for the indicated node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup at this level or above + * that has the "decal" flag set. Returns the value of the decal flag if it + * is found, or false if it is not. + * + * In other words, returns true if the "decal" flag is in effect for the + * indicated node, false otherwise. + */ bool EggNode:: determine_decal() { if (_parent == (EggGroupNode *)NULL) { @@ -254,16 +214,12 @@ determine_decal() { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::parse_egg -// Access: Public -// Description: Parses the egg syntax given in the indicate string as -// if it had been read from the egg file within this -// object's definition. Updates the object accordingly. -// Returns true if successful, false if there was some -// parse error or if the object does not support this -// functionality. -//////////////////////////////////////////////////////////////////// +/** + * Parses the egg syntax given in the indicate string as if it had been read + * from the egg file within this object's definition. Updates the object + * accordingly. Returns true if successful, false if there was some parse + * error or if the object does not support this functionality. + */ bool EggNode:: parse_egg(const string &egg_syntax) { EggGroupNode *group = get_parent(); @@ -290,13 +246,10 @@ parse_egg(const string &egg_syntax) { #ifdef _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggNode::test_under_integrity -// Access: Public -// Description: Recursively checks the integrity of the _under_flags, -// _parent, and _depth members of this node and all of -// its ancestors. -//////////////////////////////////////////////////////////////////// +/** + * Recursively checks the integrity of the _under_flags, _parent, and _depth + * members of this node and all of its ancestors. + */ void EggNode:: test_under_integrity() const { if (_parent == NULL) { @@ -309,10 +262,9 @@ test_under_integrity() const { nassertv(_depth == _parent->_depth + 1); - // We can't perform too much checking on the under_flags, since we - // don't know which bits should have been added for this node. - // We'll verify that at least we didn't accidentally take some - // bits away. + // We can't perform too much checking on the under_flags, since we don't + // know which bits should have been added for this node. We'll verify + // that at least we didn't accidentally take some bits away. nassertv((_under_flags & _parent->_under_flags) == _parent->_under_flags); // Make sure we're mentioned in our parent's children list. @@ -328,33 +280,26 @@ test_under_integrity() const { #endif // _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggNode::egg_start_parse_body -// Access: Protected, Virtual -// Description: This function is called within parse_egg(). It -// should call the appropriate function on the lexer to -// initialize the parser into the state associated with -// this object. If the object cannot be parsed into -// directly, it should return false. -//////////////////////////////////////////////////////////////////// +/** + * This function is called within parse_egg(). It should call the appropriate + * function on the lexer to initialize the parser into the state associated + * with this object. If the object cannot be parsed into directly, it should + * return false. + */ bool EggNode:: egg_start_parse_body() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::update_under -// Access: Protected, Virtual -// Description: This function is called from within EggGroupNode -// whenever the parentage of the node has changed. It -// should update the depth and under_instance flags -// accordingly. -// -// depth_offset is the difference between the old depth -// value and the new value. It should be consistent -// with the supplied depth value. If it is not, we have -// some error. -//////////////////////////////////////////////////////////////////// +/** + * This function is called from within EggGroupNode whenever the parentage of + * the node has changed. It should update the depth and under_instance flags + * accordingly. + * + * depth_offset is the difference between the old depth value and the new + * value. It should be consistent with the supplied depth value. If it is + * not, we have some error. + */ void EggNode:: update_under(int depth_offset) { int depth; @@ -388,114 +333,87 @@ update_under(int depth_offset) { adjust_under(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::adjust_under -// Access: Protected, Virtual -// Description: This is called within update_under() after all the -// various under settings have been inherited directly -// from the parent node. It is responsible for -// adjusting these settings to reflect states local to -// the current node; for instance, an node -// will force the UF_under_instance bit on. -//////////////////////////////////////////////////////////////////// +/** + * This is called within update_under() after all the various under settings + * have been inherited directly from the parent node. It is responsible for + * adjusting these settings to reflect states local to the current node; for + * instance, an node will force the UF_under_instance bit on. + */ void EggNode:: adjust_under() { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::has_primitives -// Access: Protected, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, false otherwise. + */ bool EggNode:: has_primitives() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::joint_has_primitives -// Access: Protected, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// but the search does not include nested joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, but the search does not include nested joints. + */ bool EggNode:: joint_has_primitives() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::has_normals -// Access: Published, Virtual -// Description: Returns true if any of the primitives (e.g. polygons) -// defined within this group or below have either face -// or vertex normals defined, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the primitives (e.g. polygons) defined within this + * group or below have either face or vertex normals defined, false otherwise. + */ bool EggNode:: has_normals() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggNode:: r_transform(const LMatrix4d &, const LMatrix4d &, CoordinateSystem) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::r_transform_vertices -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform_vertices_only()(). It applies a -// transformation matrix to the current node in some -// sensible way (if the current node is a vertex pool -// with vertices), then continues down the tree. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform_vertices_only()(). It + * applies a transformation matrix to the current node in some sensible way + * (if the current node is a vertex pool with vertices), then continues down + * the tree. + */ void EggNode:: r_transform_vertices(const LMatrix4d &) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::r_mark_coordsys -// Access: Protected, Virtual -// Description: This is only called immediately after loading an egg -// file from disk, to propagate the value found in the -// CoordinateSystem entry (or the default Y-up -// coordinate system) to all nodes that care about what -// the coordinate system is. -//////////////////////////////////////////////////////////////////// +/** + * This is only called immediately after loading an egg file from disk, to + * propagate the value found in the CoordinateSystem entry (or the default + * Y-up coordinate system) to all nodes that care about what the coordinate + * system is. + */ void EggNode:: r_mark_coordsys(CoordinateSystem) { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::r_flatten_transforms -// Access: Protected, Virtual -// Description: The recursive implementation of flatten_transforms(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of flatten_transforms(). + */ void EggNode:: r_flatten_transforms() { } -//////////////////////////////////////////////////////////////////// -// Function: EggNode::r_apply_texmats -// Access: Protected, Virtual -// Description: The recursive implementation of apply_texmats(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of apply_texmats(). + */ void EggNode:: r_apply_texmats(EggTextureCollection &textures) { } diff --git a/panda/src/egg/eggNode.h b/panda/src/egg/eggNode.h index 1292b1e2f0..0eab76d40d 100644 --- a/panda/src/egg/eggNode.h +++ b/panda/src/egg/eggNode.h @@ -1,16 +1,15 @@ -// Filename: eggNode.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNode.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGNODE_H #define EGGNODE_H @@ -28,13 +27,11 @@ class EggGroupNode; class EggRenderMode; class EggTextureCollection; -//////////////////////////////////////////////////////////////////// -// Class : EggNode -// Description : A base class for things that may be directly added -// into the egg hierarchy. This includes groups, -// joints, polygons, vertex pools, etc., but does not -// include things like vertices. -//////////////////////////////////////////////////////////////////// +/** + * A base class for things that may be directly added into the egg hierarchy. + * This includes groups, joints, polygons, vertex pools, etc., but does not + * include things like vertices. + */ class EXPCL_PANDAEGG EggNode : public EggNamedObject { PUBLISHED: INLINE EggNode(const string &name = ""); @@ -114,8 +111,8 @@ protected: virtual void r_apply_texmats(EggTextureCollection &textures); // These members are updated automatically by prepare_add_child(), - // prepare_remove_child(), and update_under(). Other functions - // shouldn't be fiddling with them. + // prepare_remove_child(), and update_under(). Other functions shouldn't be + // fiddling with them. EggGroupNode *_parent; int _depth; diff --git a/panda/src/egg/eggNurbsCurve.I b/panda/src/egg/eggNurbsCurve.I index 8e6222892b..f426541d55 100644 --- a/panda/src/egg/eggNurbsCurve.I +++ b/panda/src/egg/eggNurbsCurve.I @@ -1,32 +1,27 @@ -// Filename: eggNurbsCurve.I -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsCurve.I + * @author drose + * @date 2000-02-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsCurve:: EggNurbsCurve(const string &name) : EggCurve(name) { _order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsCurve:: EggNurbsCurve(const EggNurbsCurve ©) : EggCurve(copy), @@ -35,11 +30,9 @@ EggNurbsCurve(const EggNurbsCurve ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsCurve &EggNurbsCurve:: operator = (const EggNurbsCurve ©) { EggCurve::operator = (copy); @@ -48,93 +41,72 @@ operator = (const EggNurbsCurve ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::set_order -// Access: Public -// Description: Directly changes the order to the indicated value -// (which must be an integer in the range 1 <= order <= -// 4). If possible, it is preferable to use the setup() -// method instead of this method, since changing the -// order directly may result in an invalid curve. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the order to the indicated value (which must be an integer + * in the range 1 <= order <= 4). If possible, it is preferable to use the + * setup() method instead of this method, since changing the order directly + * may result in an invalid curve. + */ INLINE void EggNurbsCurve:: set_order(int order) { nassertv(order >= 1 && order <= 4); _order = order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::set_knot -// Access: Public -// Description: Resets the value of the indicated knot as indicated. -// k must be in the range 0 <= k < get_num_knots(), -// and the value must be in the range get_knot(k - 1) -// <= value <= get_knot(k + 1). -//////////////////////////////////////////////////////////////////// +/** + * Resets the value of the indicated knot as indicated. k must be in the + * range 0 <= k < get_num_knots(), and the value must be in the range + * get_knot(k - 1) <= value <= get_knot(k + 1). + */ INLINE void EggNurbsCurve:: set_knot(int k, double value) { nassertv(k >= 0 && k < (int)_knots.size()); _knots[k] = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::get_order -// Access: Public -// Description: Returns the order of the curve. The order is the -// degree of the NURBS equation plus 1; for a typical -// NURBS, the order is 4. With this implementation of -// NURBS, the order must be in the range [1, 4]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the curve. The order is the degree of the NURBS + * equation plus 1; for a typical NURBS, the order is 4. With this + * implementation of NURBS, the order must be in the range [1, 4]. + */ INLINE int EggNurbsCurve:: get_order() const { return _order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::get_degree -// Access: Public -// Description: Returns the degree of the curve. For a typical -// NURBS, the degree is 3. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of the curve. For a typical NURBS, the degree is 3. + */ INLINE int EggNurbsCurve:: get_degree() const { return _order - 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::get_num_knots -// Access: Public -// Description: Returns the number of knots. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knots. + */ INLINE int EggNurbsCurve:: get_num_knots() const { return _knots.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::get_num_cvs -// Access: Public -// Description: Returns the total number of control vertices that -// *should* be defined for the curve. This is -// determined by the number of knots and the order, in -// each direction; it does not necessarily reflect the -// number of vertices that have actually been added to -// the curve. (However, if the number of vertices in -// the curve are wrong, the curve is invalid.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of control vertices that *should* be defined for + * the curve. This is determined by the number of knots and the order, in + * each direction; it does not necessarily reflect the number of vertices that + * have actually been added to the curve. (However, if the number of vertices + * in the curve are wrong, the curve is invalid.) + */ INLINE int EggNurbsCurve:: get_num_cvs() const { return get_num_knots() - get_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::get_knot -// Access: Public -// Description: Returns the nth knot value defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth knot value defined. + */ INLINE double EggNurbsCurve:: get_knot(int k) const { nassertr(k >= 0 && k < (int)_knots.size(), 0.0); return _knots[k]; } - diff --git a/panda/src/egg/eggNurbsCurve.cxx b/panda/src/egg/eggNurbsCurve.cxx index 9b5348bc14..f00528f0f0 100644 --- a/panda/src/egg/eggNurbsCurve.cxx +++ b/panda/src/egg/eggNurbsCurve.cxx @@ -1,16 +1,15 @@ -// Filename: eggNurbsCurve.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsCurve.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggNurbsCurve.h" @@ -18,16 +17,12 @@ TypeHandle EggNurbsCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::setup -// Access: Public -// Description: Prepares a new curve definition with the indicated -// order and number of knots. This also implies a -// particular number of vertices as well (the number of -// knots minus the order), but it is up to the user to -// add the correct number of vertices to the curve by -// repeatedly calling push_back(). -//////////////////////////////////////////////////////////////////// +/** + * Prepares a new curve definition with the indicated order and number of + * knots. This also implies a particular number of vertices as well (the + * number of knots minus the order), but it is up to the user to add the + * correct number of vertices to the curve by repeatedly calling push_back(). + */ void EggNurbsCurve:: setup(int order, int num_knots) { _order = order; @@ -40,17 +35,13 @@ setup(int order, int num_knots) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::set_num_knots -// Access: Public -// Description: Directly changes the number of knots. This will -// either add zero-valued knots onto the end, or -// truncate knot values from the end, depending on -// whether the list is being increased or decreased. If -// possible, it is preferable to use the setup() method -// instead of directly setting the number of knots, as -// this may result in an invalid curve. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the number of knots. This will either add zero-valued + * knots onto the end, or truncate knot values from the end, depending on + * whether the list is being increased or decreased. If possible, it is + * preferable to use the setup() method instead of directly setting the number + * of knots, as this may result in an invalid curve. + */ void EggNurbsCurve:: set_num_knots(int num) { if ((int)_knots.size() >= num) { @@ -65,14 +56,11 @@ set_num_knots(int num) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::is_valid -// Access: Public -// Description: Returns true if the NURBS parameters are all -// internally consistent (e.g. it has the right number -// of vertices to match its number of knots and order in -// each dimension), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NURBS parameters are all internally consistent (e.g. + * it has the right number of vertices to match its number of knots and order + * in each dimension), or false otherwise. + */ bool EggNurbsCurve:: is_valid() const { if (_order < 1 || _order > 4) { @@ -97,21 +85,17 @@ is_valid() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::is_closed -// Access: Public -// Description: Returns true if the curve appears to be closed. -// Since the Egg syntax does not provide a means for -// explicit indication of closure, this has to be -// guessed at by examining the curve itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the curve appears to be closed. Since the Egg syntax does + * not provide a means for explicit indication of closure, this has to be + * guessed at by examining the curve itself. + */ bool EggNurbsCurve:: is_closed() const { - // Technically, the curve is closed if the CV's at the end are - // repeated from the beginning. We'll do a cheesy test for - // expediency's sake: the curve is closed if the first n knots are - // not repeated. I think this will catch all the normal curves - // we're likely to see. + // Technically, the curve is closed if the CV's at the end are repeated from + // the beginning. We'll do a cheesy test for expediency's sake: the curve + // is closed if the first n knots are not repeated. I think this will catch + // all the normal curves we're likely to see. int i; for (i = 1; i < get_order(); i++) { @@ -122,12 +106,9 @@ is_closed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsCurve::write -// Access: Public, Virtual -// Description: Writes the nurbsCurve to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the nurbsCurve to the indicated output stream in Egg format. + */ void EggNurbsCurve:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggNurbsCurve.h b/panda/src/egg/eggNurbsCurve.h index a00a2a6e5e..29f567573a 100644 --- a/panda/src/egg/eggNurbsCurve.h +++ b/panda/src/egg/eggNurbsCurve.h @@ -1,16 +1,15 @@ -// Filename: eggNurbsCurve.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsCurve.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGNURBSCURVE_H #define EGGNURBSCURVE_H @@ -21,10 +20,9 @@ #include "vector_double.h" -//////////////////////////////////////////////////////////////////// -// Class : EggNurbsCurve -// Description : A parametric NURBS curve. -//////////////////////////////////////////////////////////////////// +/** + * A parametric NURBS curve. + */ class EXPCL_PANDAEGG EggNurbsCurve : public EggCurve { PUBLISHED: INLINE EggNurbsCurve(const string &name = ""); diff --git a/panda/src/egg/eggNurbsSurface.I b/panda/src/egg/eggNurbsSurface.I index 289f76cf4b..1a23a6074a 100644 --- a/panda/src/egg/eggNurbsSurface.I +++ b/panda/src/egg/eggNurbsSurface.I @@ -1,33 +1,28 @@ -// Filename: eggNurbsSurface.I -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsSurface.I + * @author drose + * @date 2000-02-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsSurface:: EggNurbsSurface(const string &name) : EggSurface(name) { _u_order = 0; _v_order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsSurface:: EggNurbsSurface(const EggNurbsSurface ©) : EggSurface(copy), @@ -38,11 +33,9 @@ EggNurbsSurface(const EggNurbsSurface ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggNurbsSurface &EggNurbsSurface:: operator = (const EggNurbsSurface ©) { EggSurface::operator = (copy); @@ -53,234 +46,181 @@ operator = (const EggNurbsSurface ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_u_order -// Access: Public -// Description: Directly changes the order in the U direction to the -// indicated value (which must be an integer in the -// range 1 <= u_order <= 4). If possible, it is -// preferable to use the setup() method instead of this -// method, since changing the order directly may result -// in an invalid surface. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the order in the U direction to the indicated value (which + * must be an integer in the range 1 <= u_order <= 4). If possible, it is + * preferable to use the setup() method instead of this method, since changing + * the order directly may result in an invalid surface. + */ INLINE void EggNurbsSurface:: set_u_order(int u_order) { nassertv(u_order >= 1 && u_order <= 4); _u_order = u_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_v_order -// Access: Public -// Description: Directly changes the order in the V direction to the -// indicated value (which must be an integer in the -// range 1 <= v_order <= 4). If possible, it is -// preferable to use the setup() method instead of this -// method, since changing the order directly may result -// in an invalid surface. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the order in the V direction to the indicated value (which + * must be an integer in the range 1 <= v_order <= 4). If possible, it is + * preferable to use the setup() method instead of this method, since changing + * the order directly may result in an invalid surface. + */ INLINE void EggNurbsSurface:: set_v_order(int v_order) { nassertv(v_order >= 1 && v_order <= 4); _v_order = v_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_u_knot -// Access: Public -// Description: Resets the value of the indicated knot as indicated. -// k must be in the range 0 <= k < get_num_u_knots(), -// and the value must be in the range get_u_knot(k - 1) -// <= value <= get_u_knot(k + 1). -//////////////////////////////////////////////////////////////////// +/** + * Resets the value of the indicated knot as indicated. k must be in the + * range 0 <= k < get_num_u_knots(), and the value must be in the range + * get_u_knot(k - 1) <= value <= get_u_knot(k + 1). + */ INLINE void EggNurbsSurface:: set_u_knot(int k, double value) { nassertv(k >= 0 && k < (int)_u_knots.size()); _u_knots[k] = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_v_knot -// Access: Public -// Description: Resets the value of the indicated knot as indicated. -// k must be in the range 0 <= k < get_num_v_knots(), -// and the value must be in the range get_v_knot(k - 1) -// <= value <= get_v_knot(k + 1). -//////////////////////////////////////////////////////////////////// +/** + * Resets the value of the indicated knot as indicated. k must be in the + * range 0 <= k < get_num_v_knots(), and the value must be in the range + * get_v_knot(k - 1) <= value <= get_v_knot(k + 1). + */ INLINE void EggNurbsSurface:: set_v_knot(int k, double value) { nassertv(k >= 0 && k < (int)_v_knots.size()); _v_knots[k] = value; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_cv -// Access: Public -// Description: Redefines the control vertex associated with a -// particular u, v coordinate pair. This is just a -// shorthand to access the EggPrimitive's normal vertex -// assignment for a 2-d control vertex. -//////////////////////////////////////////////////////////////////// +/** + * Redefines the control vertex associated with a particular u, v coordinate + * pair. This is just a shorthand to access the EggPrimitive's normal vertex + * assignment for a 2-d control vertex. + */ INLINE void EggNurbsSurface:: set_cv(int ui, int vi, EggVertex *vertex) { int vertex_index = get_vertex_index(ui, vi); set_vertex(vertex_index, vertex); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_u_order -// Access: Public -// Description: Returns the order of the surface in the U direction. -// The order is the degree of the NURBS equation plus 1; -// for a typical NURBS, the order is 4. With this -// implementation of NURBS, the order must be in the -// range [1, 4]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the surface in the U direction. The order is the + * degree of the NURBS equation plus 1; for a typical NURBS, the order is 4. + * With this implementation of NURBS, the order must be in the range [1, 4]. + */ INLINE int EggNurbsSurface:: get_u_order() const { return _u_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_v_order -// Access: Public -// Description: Returns the order of the surface in the V direction. -// The order is the degree of the NURBS equation plus 1; -// for a typical NURBS, the order is 4. With this -// implementation of NURBS, the order must be in the -// range [1, 4]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the surface in the V direction. The order is the + * degree of the NURBS equation plus 1; for a typical NURBS, the order is 4. + * With this implementation of NURBS, the order must be in the range [1, 4]. + */ INLINE int EggNurbsSurface:: get_v_order() const { return _v_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_u_degree -// Access: Public -// Description: Returns the degree of the surface in the U direction. -// For a typical NURBS, the degree is 3. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of the surface in the U direction. For a typical NURBS, + * the degree is 3. + */ INLINE int EggNurbsSurface:: get_u_degree() const { return _u_order - 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_v_degree -// Access: Public -// Description: Returns the degree of the surface in the V direction. -// for a typical NURBS, the degree is 3. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of the surface in the V direction. for a typical NURBS, + * the degree is 3. + */ INLINE int EggNurbsSurface:: get_v_degree() const { return _v_order - 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_num_u_knots -// Access: Public -// Description: Returns the number of knots in the U direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knots in the U direction. + */ INLINE int EggNurbsSurface:: get_num_u_knots() const { return _u_knots.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_num_v_knots -// Access: Public -// Description: Returns the number of knots in the V direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knots in the V direction. + */ INLINE int EggNurbsSurface:: get_num_v_knots() const { return _v_knots.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_num_u_cvs -// Access: Public -// Description: Returns the number of control vertices that should be -// present in the U direction. This is determined by -// the number of knots and the order; it does not -// necessarily reflect the number of vertices that have -// actually been added to the surface. (However, if the -// number of vertices in the surface are wrong, the -// surface is invalid.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control vertices that should be present in the U + * direction. This is determined by the number of knots and the order; it + * does not necessarily reflect the number of vertices that have actually been + * added to the surface. (However, if the number of vertices in the surface + * are wrong, the surface is invalid.) + */ INLINE int EggNurbsSurface:: get_num_u_cvs() const { return get_num_u_knots() - get_u_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_num_v_cvs -// Access: Public -// Description: Returns the number of control vertices that should be -// present in the V direction. This is determined by -// the number of knots and the order; it does not -// necessarily reflect the number of vertices that have -// actually been added to the surface. (However, if the -// number of vertices in the surface are wrong, the -// surface is invalid.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control vertices that should be present in the V + * direction. This is determined by the number of knots and the order; it + * does not necessarily reflect the number of vertices that have actually been + * added to the surface. (However, if the number of vertices in the surface + * are wrong, the surface is invalid.) + */ INLINE int EggNurbsSurface:: get_num_v_cvs() const { return get_num_v_knots() - get_v_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_num_cvs -// Access: Public -// Description: Returns the total number of control vertices that -// *should* be defined for the surface. This is -// determined by the number of knots and the order, in -// each direction; it does not necessarily reflect the -// number of vertices that have actually been added to -// the surface. (However, if the number of vertices in -// the surface are wrong, the surface is invalid.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of control vertices that *should* be defined for + * the surface. This is determined by the number of knots and the order, in + * each direction; it does not necessarily reflect the number of vertices that + * have actually been added to the surface. (However, if the number of + * vertices in the surface are wrong, the surface is invalid.) + */ INLINE int EggNurbsSurface:: get_num_cvs() const { return get_num_u_cvs() * get_num_v_cvs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_u_index -// Access: Public -// Description: Returns the U index number of the given vertex within -// the EggPrimitive's linear list of vertices. An -// EggNurbsSurface maps a linear list of vertices to its -// 2-d mesh; this returns the U index number that -// corresponds to the nth vertex in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the U index number of the given vertex within the EggPrimitive's + * linear list of vertices. An EggNurbsSurface maps a linear list of vertices + * to its 2-d mesh; this returns the U index number that corresponds to the + * nth vertex in the list. + */ INLINE int EggNurbsSurface:: get_u_index(int vertex_index) const { nassertr(vertex_index >= 0 && vertex_index < get_num_cvs(), 0); return vertex_index % get_num_u_cvs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_v_index -// Access: Public -// Description: Returns the V index number of the given vertex within -// the EggPrimitive's linear list of vertices. An -// EggNurbsSurface maps a linear list of vertices to its -// 2-d mesh; this returns the V index number that -// corresponds to the nth vertex in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the V index number of the given vertex within the EggPrimitive's + * linear list of vertices. An EggNurbsSurface maps a linear list of vertices + * to its 2-d mesh; this returns the V index number that corresponds to the + * nth vertex in the list. + */ INLINE int EggNurbsSurface:: get_v_index(int vertex_index) const { nassertr(vertex_index >= 0 && vertex_index < get_num_cvs(), 0); return vertex_index / get_num_u_cvs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_vertex_index -// Access: Public -// Description: Returns the index number within the EggPrimitive's -// list of the control vertex at position ui, vi. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number within the EggPrimitive's list of the control + * vertex at position ui, vi. + */ INLINE int EggNurbsSurface:: get_vertex_index(int ui, int vi) const { nassertr(ui >= 0 && ui < get_num_u_cvs(), 0); @@ -288,36 +228,27 @@ get_vertex_index(int ui, int vi) const { return vi * get_num_u_cvs() + ui; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_u_knot -// Access: Public -// Description: Returns the nth knot value defined in the U -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth knot value defined in the U direction. + */ INLINE double EggNurbsSurface:: get_u_knot(int k) const { nassertr(k >= 0 && k < (int)_u_knots.size(), 0.0); return _u_knots[k]; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_v_knot -// Access: Public -// Description: Returns the nth knot value defined in the V -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth knot value defined in the V direction. + */ INLINE double EggNurbsSurface:: get_v_knot(int k) const { nassertr(k >= 0 && k < (int)_v_knots.size(), 0.0); return _v_knots[k]; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::get_cv -// Access: Public -// Description: Returns the control vertex at the indicate U, V -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the control vertex at the indicate U, V position. + */ INLINE EggVertex *EggNurbsSurface:: get_cv(int ui, int vi) const { int vertex_index = get_vertex_index(ui, vi); diff --git a/panda/src/egg/eggNurbsSurface.cxx b/panda/src/egg/eggNurbsSurface.cxx index af45601a59..a5bd29cc78 100644 --- a/panda/src/egg/eggNurbsSurface.cxx +++ b/panda/src/egg/eggNurbsSurface.cxx @@ -1,16 +1,15 @@ -// Filename: eggNurbsSurface.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsSurface.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggNurbsSurface.h" @@ -18,17 +17,13 @@ TypeHandle EggNurbsSurface::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::setup -// Access: Public -// Description: Prepares a new surface definition with the indicated -// order and number of knots in each dimension. This -// also implies a particular number of vertices in each -// dimension as well (the number of knots minus the -// order), but it is up to the user to add the correct -// number of vertices to the surface by repeatedly -// calling push_back(). -//////////////////////////////////////////////////////////////////// +/** + * Prepares a new surface definition with the indicated order and number of + * knots in each dimension. This also implies a particular number of vertices + * in each dimension as well (the number of knots minus the order), but it is + * up to the user to add the correct number of vertices to the surface by + * repeatedly calling push_back(). + */ void EggNurbsSurface:: setup(int u_order, int v_order, int num_u_knots, int num_v_knots) { @@ -48,17 +43,13 @@ setup(int u_order, int v_order, } } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_num_u_knots -// Access: Public -// Description: Directly changes the number of knots in the U -// direction. This will either add zero-valued knots -// onto the end, or truncate knot values from the end, -// depending on whether the list is being increased or -// decreased. If possible, it is preferable to use the -// setup() method instead of directly setting the number -// of knots, as this may result in an invalid surface. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the number of knots in the U direction. This will either + * add zero-valued knots onto the end, or truncate knot values from the end, + * depending on whether the list is being increased or decreased. If + * possible, it is preferable to use the setup() method instead of directly + * setting the number of knots, as this may result in an invalid surface. + */ void EggNurbsSurface:: set_num_u_knots(int num) { if ((int)_u_knots.size() >= num) { @@ -73,17 +64,13 @@ set_num_u_knots(int num) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::set_num_v_knots -// Access: Public -// Description: Directly changes the number of knots in the V -// direction. This will either add zero-valued knots -// onto the end, or truncate knot values from the end, -// depending on whether the list is being increased or -// decreased. If possible, it is preferable to use the -// setup() method instead of directly setting the number -// of knots, as this may result in an invalid surface. -//////////////////////////////////////////////////////////////////// +/** + * Directly changes the number of knots in the V direction. This will either + * add zero-valued knots onto the end, or truncate knot values from the end, + * depending on whether the list is being increased or decreased. If + * possible, it is preferable to use the setup() method instead of directly + * setting the number of knots, as this may result in an invalid surface. + */ void EggNurbsSurface:: set_num_v_knots(int num) { if ((int)_v_knots.size() >= num) { @@ -98,14 +85,11 @@ set_num_v_knots(int num) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::is_valid -// Access: Public -// Description: Returns true if the NURBS parameters are all -// internally consistent (e.g. it has the right number -// of vertices to match its number of knots and order in -// each dimension), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NURBS parameters are all internally consistent (e.g. + * it has the right number of vertices to match its number of knots and order + * in each dimension), or false otherwise. + */ bool EggNurbsSurface:: is_valid() const { if (_u_order < 1 || _u_order > 4 || _v_order < 1 || _v_order > 4) { @@ -135,22 +119,17 @@ is_valid() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::is_closed_u -// Access: Public -// Description: Returns true if the surface appears to be closed in -// the U direction. Since the Egg syntax does not -// provide a means for explicit indication of closure, -// this has to be guessed at by examining the surface -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the surface appears to be closed in the U direction. Since + * the Egg syntax does not provide a means for explicit indication of closure, + * this has to be guessed at by examining the surface itself. + */ bool EggNurbsSurface:: is_closed_u() const { - // Technically, the surface is closed if the CV's at the end are - // repeated from the beginning. We'll do a cheesy test for - // expediency's sake: the surface is closed if the first n knots are - // not repeated. I think this will catch all the normal surfaces - // we're likely to see. + // Technically, the surface is closed if the CV's at the end are repeated + // from the beginning. We'll do a cheesy test for expediency's sake: the + // surface is closed if the first n knots are not repeated. I think this + // will catch all the normal surfaces we're likely to see. int i; for (i = 1; i < get_u_order(); i++) { @@ -161,15 +140,11 @@ is_closed_u() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::is_closed_v -// Access: Public -// Description: Returns true if the surface appears to be closed in -// the V direction. Since the Egg syntax does not -// provide a means for explicit indication of closure, -// this has to be guessed at by examining the surface -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the surface appears to be closed in the V direction. Since + * the Egg syntax does not provide a means for explicit indication of closure, + * this has to be guessed at by examining the surface itself. + */ bool EggNurbsSurface:: is_closed_v() const { int i; @@ -181,12 +156,9 @@ is_closed_v() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::write -// Access: Public, Virtual -// Description: Writes the nurbsSurface to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the nurbsSurface to the indicated output stream in Egg format. + */ void EggNurbsSurface:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -239,13 +211,10 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggNurbsSurface::r_apply_texmats -// Access: Protected, Virtual -// Description: The recursive implementation of apply_texmats(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of apply_texmats(). + */ void EggNurbsSurface:: r_apply_texmats(EggTextureCollection &textures) { - // A NURBS cannot safely apply texture matrices, so we leave it - // alone. + // A NURBS cannot safely apply texture matrices, so we leave it alone. } diff --git a/panda/src/egg/eggNurbsSurface.h b/panda/src/egg/eggNurbsSurface.h index e658943435..35d5daba88 100644 --- a/panda/src/egg/eggNurbsSurface.h +++ b/panda/src/egg/eggNurbsSurface.h @@ -1,16 +1,15 @@ -// Filename: eggNurbsSurface.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggNurbsSurface.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGNURBSSURFACE_H #define EGGNURBSSURFACE_H @@ -22,10 +21,9 @@ #include "vector_double.h" #include "plist.h" -//////////////////////////////////////////////////////////////////// -// Class : EggNurbsSurface -// Description : A parametric NURBS surface. -//////////////////////////////////////////////////////////////////// +/** + * A parametric NURBS surface. + */ class EXPCL_PANDAEGG EggNurbsSurface : public EggSurface { PUBLISHED: typedef plist< PT(EggNurbsCurve) > Curves; diff --git a/panda/src/egg/eggObject.I b/panda/src/egg/eggObject.I index a9939df0bb..041fe8b2a4 100644 --- a/panda/src/egg/eggObject.I +++ b/panda/src/egg/eggObject.I @@ -1,14 +1,12 @@ -// Filename: eggObject.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggObject.I + * @author drose + * @date 1999-02-10 + */ diff --git a/panda/src/egg/eggObject.cxx b/panda/src/egg/eggObject.cxx index 93a7d8226a..b75d2ea64f 100644 --- a/panda/src/egg/eggObject.cxx +++ b/panda/src/egg/eggObject.cxx @@ -1,39 +1,34 @@ -// Filename: eggObject.cxx -// Created by: drose (17Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggObject.cxx + * @author drose + * @date 1999-01-17 + */ #include "eggObject.h" TypeHandle EggObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggObject:: EggObject() { } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggObject:: -EggObject(const EggObject ©) : +EggObject(const EggObject ©) : TypedReferenceCount(copy), _user_data(copy._user_data), _default_user_data(copy._default_user_data) @@ -41,11 +36,9 @@ EggObject(const EggObject ©) : } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggObject &EggObject:: operator = (const EggObject ©) { TypedReferenceCount::operator = (copy); @@ -54,61 +47,48 @@ operator = (const EggObject ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggObject:: ~EggObject() { } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::set_user_data -// Access: Published -// Description: Sets the user data associated with this object. This -// may be any EggUserData-derived object. The egg -// library will do nothing with this pointer, except to -// hold its reference count and return the pointer on -// request. -// -// The EggObject maintains multiple different -// EggUserData pointers, one for each unique type (as -// reported by get_type()). If you know that only one -// type of EggUserData object will be added in your -// application, you may use the query functions that -// accept no parameters, but it is recommended that in -// general you pass in the type of your particular user -// data, to allow multiple applications to coexist in -// the same egg data. -// -// This pointer is also copied by the copy assignment -// operator and copy constructor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the user data associated with this object. This may be any + * EggUserData-derived object. The egg library will do nothing with this + * pointer, except to hold its reference count and return the pointer on + * request. + * + * The EggObject maintains multiple different EggUserData pointers, one for + * each unique type (as reported by get_type()). If you know that only one + * type of EggUserData object will be added in your application, you may use + * the query functions that accept no parameters, but it is recommended that + * in general you pass in the type of your particular user data, to allow + * multiple applications to coexist in the same egg data. + * + * This pointer is also copied by the copy assignment operator and copy + * constructor. + */ void EggObject:: set_user_data(EggUserData *user_data) { _user_data[user_data->get_type()] = user_data; _default_user_data = user_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::get_user_data -// Access: Published -// Description: Returns the user data pointer most recently stored on -// this object, or NULL if nothing was previously -// stored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the user data pointer most recently stored on this object, or NULL + * if nothing was previously stored. + */ EggUserData *EggObject:: get_user_data() const { return _default_user_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::get_user_data -// Access: Published -// Description: Returns the user data pointer of the indicated type, -// if it exists, or NULL if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the user data pointer of the indicated type, if it exists, or NULL + * if it does not. + */ EggUserData *EggObject:: get_user_data(TypeHandle type) const { UserData::const_iterator ui; @@ -119,24 +99,19 @@ get_user_data(TypeHandle type) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::has_user_data -// Access: Published -// Description: Returns true if a generic user data pointer has -// recently been set and not yet cleared, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a generic user data pointer has recently been set and not + * yet cleared, false otherwise. + */ bool EggObject:: has_user_data() const { return !_default_user_data.is_null(); } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::has_user_data -// Access: Published -// Description: Returns true if the user data pointer of the -// indicated type has been set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the user data pointer of the indicated type has been set, + * false otherwise. + */ bool EggObject:: has_user_data(TypeHandle type) const { UserData::const_iterator ui; @@ -144,22 +119,18 @@ has_user_data(TypeHandle type) const { return (ui != _user_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::clear_user_data -// Access: Published -// Description: Removes *all* user data pointers from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes *all* user data pointers from the node. + */ void EggObject:: clear_user_data() { _user_data.clear(); _default_user_data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::clear_user_data -// Access: Published -// Description: Removes the user data pointer of the indicated type. -//////////////////////////////////////////////////////////////////// +/** + * Removes the user data pointer of the indicated type. + */ void EggObject:: clear_user_data(TypeHandle type) { UserData::iterator ui; @@ -172,13 +143,10 @@ clear_user_data(TypeHandle type) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggObject::as_transform -// Access: Public, Virtual -// Description: Returns this object cross-cast to an EggTransform -// pointer, if it inherits from EggTransform, or NULL if -// it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object cross-cast to an EggTransform pointer, if it inherits + * from EggTransform, or NULL if it does not. + */ EggTransform *EggObject:: as_transform() { return NULL; diff --git a/panda/src/egg/eggObject.h b/panda/src/egg/eggObject.h index e67c314d80..f293b19503 100644 --- a/panda/src/egg/eggObject.h +++ b/panda/src/egg/eggObject.h @@ -1,16 +1,15 @@ -// Filename: eggObject.h -// Created by: drose (17Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggObject.h + * @author drose + * @date 1999-01-17 + */ #ifndef EGGOBJECT_H #define EGGOBJECT_H @@ -23,11 +22,10 @@ class EggTransform; -//////////////////////////////////////////////////////////////////// -// Class : EggObject -// Description : The highest-level base class in the egg directory. -// (Almost) all things egg inherit from this. -//////////////////////////////////////////////////////////////////// +/** + * The highest-level base class in the egg directory. (Almost) all things egg + * inherit from this. + */ class EXPCL_PANDAEGG EggObject : public TypedReferenceCount { PUBLISHED: EggObject(); diff --git a/panda/src/egg/eggParameters.cxx b/panda/src/egg/eggParameters.cxx index 5c2993026b..14b63ba8ea 100644 --- a/panda/src/egg/eggParameters.cxx +++ b/panda/src/egg/eggParameters.cxx @@ -1,16 +1,15 @@ -// Filename: eggParameters.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggParameters.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggParameters.h" @@ -20,11 +19,9 @@ static EggParameters default_egg_parameters; EggParameters *egg_parameters = &default_egg_parameters; -//////////////////////////////////////////////////////////////////// -// Function: EggParameters::Constructor -// Access: Public -// Description: Initializes all the parameters with default values. -//////////////////////////////////////////////////////////////////// +/** + * Initializes all the parameters with default values. + */ EggParameters:: EggParameters() { _pos_threshold = 0.0001; @@ -36,11 +33,9 @@ EggParameters() { } -//////////////////////////////////////////////////////////////////// -// Function: EggParameters::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggParameters:: EggParameters(const EggParameters &other) { memcpy(this, &other, sizeof(EggParameters)); diff --git a/panda/src/egg/eggParameters.h b/panda/src/egg/eggParameters.h index 56ba5799a1..36bd1e48f6 100644 --- a/panda/src/egg/eggParameters.h +++ b/panda/src/egg/eggParameters.h @@ -1,16 +1,15 @@ -// Filename: eggParameters.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggParameters.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGPARAMETERS_H #define EGGPARAMETERS_H @@ -19,44 +18,40 @@ #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : EggParameters -// Description : The values stored in this structure are global -// parameters that control some aspects of the egg -// library. User code may adjust these parameters by -// meddling with the values in structure directly, or by -// fiddling with the pointer to completely replace the -// structure. -// -// However, these parameters should not be changed at -// any time during the processing of any egg structure: -// set the parameters, load an egg file, process it, and -// write the egg file out again before resetting the -// parameters again. -//////////////////////////////////////////////////////////////////// +/** + * The values stored in this structure are global parameters that control some + * aspects of the egg library. User code may adjust these parameters by + * meddling with the values in structure directly, or by fiddling with the + * pointer to completely replace the structure. + * + * However, these parameters should not be changed at any time during the + * processing of any egg structure: set the parameters, load an egg file, + * process it, and write the egg file out again before resetting the + * parameters again. + */ class EXPCL_PANDAEGG EggParameters { public: EggParameters(); EggParameters(const EggParameters ©); - // The per-component difference below which two vertices are deemed - // to be at the same position. + // The per-component difference below which two vertices are deemed to be at + // the same position. double _pos_threshold; - // The per-component difference below which two vertices are deemed - // to have the same normal. + // The per-component difference below which two vertices are deemed to have + // the same normal. double _normal_threshold; - // The per-component difference below which two vertices are deemed - // to have the same texture coordinates. + // The per-component difference below which two vertices are deemed to have + // the same texture coordinates. double _uv_threshold; - // The per-component difference below which two vertices are deemed - // to have the same color. + // The per-component difference below which two vertices are deemed to have + // the same color. PN_stdfloat _color_threshold; - // The per-component difference below which two anim table values - // are deemed to be equivalent. + // The per-component difference below which two anim table values are deemed + // to be equivalent. double _table_threshold; }; diff --git a/panda/src/egg/eggPatch.I b/panda/src/egg/eggPatch.I index e68869e086..b75db18d2d 100644 --- a/panda/src/egg/eggPatch.I +++ b/panda/src/egg/eggPatch.I @@ -1,41 +1,33 @@ -// Filename: eggPatch.I -// Created by: drose (27Apr12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPatch.I + * @author drose + * @date 2012-04-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggPatch::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPatch:: EggPatch(const string &name) : EggPrimitive(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPatch::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPatch:: EggPatch(const EggPatch ©) : EggPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPatch::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPatch &EggPatch:: operator = (const EggPatch ©) { EggPrimitive::operator = (copy); diff --git a/panda/src/egg/eggPatch.cxx b/panda/src/egg/eggPatch.cxx index b816e5c6a3..274217d0c2 100644 --- a/panda/src/egg/eggPatch.cxx +++ b/panda/src/egg/eggPatch.cxx @@ -1,16 +1,15 @@ -// Filename: eggPatch.cxx -// Created by: drose (27Apr12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPatch.cxx + * @author drose + * @date 2012-04-27 + */ #include "eggPatch.h" #include "eggGroupNode.h" @@ -23,12 +22,9 @@ TypeHandle EggPatch::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPatch::write -// Access: Published, Virtual -// Description: Writes the patch to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the patch to the indicated output stream in Egg format. + */ void EggPatch:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggPatch.h b/panda/src/egg/eggPatch.h index 14498a1a67..d7a0989aef 100644 --- a/panda/src/egg/eggPatch.h +++ b/panda/src/egg/eggPatch.h @@ -1,16 +1,15 @@ -// Filename: eggPatch.h -// Created by: drose (27Apr12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPatch.h + * @author drose + * @date 2012-04-27 + */ #ifndef EGGPATCH_H #define EGGPATCH_H @@ -19,11 +18,10 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPatch -// Description : A single "patch", a special primitive to be rendered -// only with a tessellation shader. -//////////////////////////////////////////////////////////////////// +/** + * A single "patch", a special primitive to be rendered only with a + * tessellation shader. + */ class EXPCL_PANDAEGG EggPatch : public EggPrimitive { PUBLISHED: INLINE EggPatch(const string &name = ""); diff --git a/panda/src/egg/eggPoint.I b/panda/src/egg/eggPoint.I index b09c45a57c..6fa3e252ef 100644 --- a/panda/src/egg/eggPoint.I +++ b/panda/src/egg/eggPoint.I @@ -1,49 +1,41 @@ -// Filename: eggPoint.I -// Created by: drose (15Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPoint.I + * @author drose + * @date 1999-12-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPoint:: -EggPoint(const string &name) : +EggPoint(const string &name) : EggPrimitive(name), _flags(0), _thick(1.0) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPoint:: -EggPoint(const EggPoint ©) : +EggPoint(const EggPoint ©) : EggPrimitive(copy), _flags(copy._flags), _thick(copy._thick) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPoint &EggPoint:: operator = (const EggPoint ©) { EggPrimitive::operator = (copy); @@ -52,76 +44,61 @@ operator = (const EggPoint ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::has_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggPoint:: has_thick() const { return (_flags & F_has_thick) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::get_thick -// Access: Published -// Description: Returns the thickness set on this particular point. -// If there is no thickness set, returns 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the thickness set on this particular point. If there is no + * thickness set, returns 1.0. + */ INLINE double EggPoint:: get_thick() const { return _thick; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::set_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggPoint:: set_thick(double thick) { _thick = thick; _flags |= F_has_thick; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::clear_thick -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggPoint:: clear_thick() { _thick = 1.0; _flags &= ~F_has_thick; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::has_perspective -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggPoint:: has_perspective() const { return (_flags & F_has_perspective) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::get_perspective -// Access: Published -// Description: Returns the perspective flag set on this particular -// point. If there is no perspective flag set, returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the perspective flag set on this particular point. If there is no + * perspective flag set, returns false. + */ INLINE bool EggPoint:: get_perspective() const { return (_flags & F_perspective) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::set_perspective -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggPoint:: set_perspective(bool perspective) { if (perspective) { @@ -132,11 +109,9 @@ set_perspective(bool perspective) { _flags |= F_has_perspective; } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::clear_perspective -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggPoint:: clear_perspective() { _flags &= ~(F_has_perspective | F_perspective); diff --git a/panda/src/egg/eggPoint.cxx b/panda/src/egg/eggPoint.cxx index 2307add071..95eef093ea 100644 --- a/panda/src/egg/eggPoint.cxx +++ b/panda/src/egg/eggPoint.cxx @@ -1,16 +1,15 @@ -// Filename: eggPoint.cxx -// Created by: drose (15Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPoint.cxx + * @author drose + * @date 1999-12-15 + */ #include "eggPoint.h" @@ -19,38 +18,32 @@ TypeHandle EggPoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::cleanup -// Access: Public, Virtual -// Description: Cleans up modeling errors in whatever context this -// makes sense. For instance, for a polygon, this calls -// remove_doubled_verts(true). For a point, it calls -// remove_nonunique_verts(). Returns true if the -// primitive is valid, or false if it is degenerate. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up modeling errors in whatever context this makes sense. For + * instance, for a polygon, this calls remove_doubled_verts(true). For a + * point, it calls remove_nonunique_verts(). Returns true if the primitive is + * valid, or false if it is degenerate. + */ bool EggPoint:: cleanup() { remove_nonunique_verts(); return !empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPoint::write -// Access: Public, Virtual -// Description: Writes the point to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the point to the indicated output stream in Egg format. + */ void EggPoint:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); if (has_thick()) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " thick { " << get_thick() << " }\n"; } if (has_perspective()) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << " perspective { " << get_perspective() << " }\n"; } diff --git a/panda/src/egg/eggPoint.h b/panda/src/egg/eggPoint.h index d84ce47109..74edd1b04d 100644 --- a/panda/src/egg/eggPoint.h +++ b/panda/src/egg/eggPoint.h @@ -1,16 +1,15 @@ -// Filename: eggPoint.h -// Created by: drose (15Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPoint.h + * @author drose + * @date 1999-12-15 + */ #ifndef EGGPOINT_H #define EGGPOINT_H @@ -19,11 +18,10 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPoint -// Description : A single point, or a collection of points as defined -// by a single entry. -//////////////////////////////////////////////////////////////////// +/** + * A single point, or a collection of points as defined by a single + * entry. + */ class EXPCL_PANDAEGG EggPoint : public EggPrimitive { PUBLISHED: INLINE EggPoint(const string &name = ""); diff --git a/panda/src/egg/eggPolygon.I b/panda/src/egg/eggPolygon.I index 9311ebb694..69b6d4b7fe 100644 --- a/panda/src/egg/eggPolygon.I +++ b/panda/src/egg/eggPolygon.I @@ -1,55 +1,44 @@ -// Filename: eggPolygon.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPolygon.I + * @author drose + * @date 1999-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPolygon:: EggPolygon(const string &name) : EggPrimitive(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPolygon:: EggPolygon(const EggPolygon ©) : EggPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPolygon &EggPolygon:: operator = (const EggPolygon ©) { EggPrimitive::operator = (copy); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::recompute_polygon_normal -// Access: Published -// Description: Recalculates the normal according to the order of the -// vertices, and sets it. Returns true if the normal is -// computed correctly, or false if the polygon is -// degenerate and does not have a normal. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the normal according to the order of the vertices, and sets + * it. Returns true if the normal is computed correctly, or false if the + * polygon is degenerate and does not have a normal. + */ INLINE bool EggPolygon:: recompute_polygon_normal(CoordinateSystem cs) { LNormald normal; @@ -61,25 +50,19 @@ recompute_polygon_normal(CoordinateSystem cs) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::triangulate_into -// Access: Published -// Description: Subdivides the polygon into triangles and adds each -// one to the indicated container. If the polygon is -// already a triangle, adds an exact copy of the polygon -// to the container. Does not remove the polygon from -// its existing parent or modify it in any way. -// -// Returns true if the triangulation is successful, or -// false if there was some error (in which case the -// container may contain some partial triangulation). -// -// If convex_also is true, both concave and convex -// polygons will be subdivided into triangles; -// otherwise, only concave polygons will be subdivided, -// and convex polygons will be copied unchanged into the -// container. -//////////////////////////////////////////////////////////////////// +/** + * Subdivides the polygon into triangles and adds each one to the indicated + * container. If the polygon is already a triangle, adds an exact copy of the + * polygon to the container. Does not remove the polygon from its existing + * parent or modify it in any way. + * + * Returns true if the triangulation is successful, or false if there was some + * error (in which case the container may contain some partial triangulation). + * + * If convex_also is true, both concave and convex polygons will be subdivided + * into triangles; otherwise, only concave polygons will be subdivided, and + * convex polygons will be copied unchanged into the container. + */ INLINE bool EggPolygon:: triangulate_into(EggGroupNode *container, bool convex_also) const { PT(EggPolygon) copy = new EggPolygon(*this); diff --git a/panda/src/egg/eggPolygon.cxx b/panda/src/egg/eggPolygon.cxx index 0cd24a9151..e10252c2ae 100644 --- a/panda/src/egg/eggPolygon.cxx +++ b/panda/src/egg/eggPolygon.cxx @@ -1,16 +1,15 @@ -// Filename: eggPolygon.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPolygon.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggPolygon.h" #include "eggGroupNode.h" @@ -23,15 +22,12 @@ TypeHandle EggPolygon::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::cleanup -// Access: Published, Virtual -// Description: Cleans up modeling errors in whatever context this -// makes sense. For instance, for a polygon, this calls -// remove_doubled_verts(true). For a point, it calls -// remove_nonunique_verts(). Returns true if the -// primitive is valid, or false if it is degenerate. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up modeling errors in whatever context this makes sense. For + * instance, for a polygon, this calls remove_doubled_verts(true). For a + * point, it calls remove_nonunique_verts(). Returns true if the primitive is + * valid, or false if it is degenerate. + */ bool EggPolygon:: cleanup() { remove_doubled_verts(true); @@ -41,27 +37,23 @@ cleanup() { return calculate_normal(normal); } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::calculate_normal -// Access: Published -// Description: Calculates the true polygon normal--the vector -// pointing out of the front of the polygon--based on -// the vertices. This does not return or change the -// polygon's normal as set via set_normal(). -// -// The return value is true if the normal is computed -// correctly, or false if the polygon is degenerate and -// does not have at least three noncollinear vertices. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the true polygon normal--the vector pointing out of the front of + * the polygon--based on the vertices. This does not return or change the + * polygon's normal as set via set_normal(). + * + * The return value is true if the normal is computed correctly, or false if + * the polygon is degenerate and does not have at least three noncollinear + * vertices. + */ bool EggPolygon:: calculate_normal(LNormald &result, CoordinateSystem cs) const { result = LNormald::zero(); - // Project the polygon into each of the three major planes and - // calculate the area of each 2-d projection. This becomes the - // polygon normal. This works because the ratio between these - // different areas corresponds to the angle at which the polygon is - // tilted toward each plane. + // Project the polygon into each of the three major planes and calculate the + // area of each 2-d projection. This becomes the polygon normal. This + // works because the ratio between these different areas corresponds to the + // angle at which the polygon is tilted toward each plane. size_t num_verts = size(); for (size_t i = 0; i < num_verts; i++) { LVertexd p0 = get_vertex(i)->get_pos3(); @@ -86,40 +78,37 @@ calculate_normal(LNormald &result, CoordinateSystem cs) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::is_planar -// Access: Published -// Description: Returns true if all of the polygon's vertices lie -// within the same plane, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the polygon's vertices lie within the same plane, + * false otherwise. + */ bool EggPolygon:: is_planar() const { if (size() <= 3) { - // If we don't have more than three vertices, we can't be - // non-planar. + // If we don't have more than three vertices, we can't be non-planar. return true; } LNormald normal; if (!calculate_normal(normal)) { - // A degenerate polygon--all of the vertices are within one line, - // or all in the same point--is technically planar. Not sure if - // this is a useful return value or not. + // A degenerate polygon--all of the vertices are within one line, or all + // in the same point--is technically planar. Not sure if this is a useful + // return value or not. return true; } - // There should be at least one vertex (actually, at least three) - // since we have already shown that the polygon is nondegenerate. + // There should be at least one vertex (actually, at least three) since we + // have already shown that the polygon is nondegenerate. nassertr(!empty(), false); - // Create a plane perpendicular to the polygon's normal, containing - // the first vertex. + // Create a plane perpendicular to the polygon's normal, containing the + // first vertex. const_iterator vi = begin(); LVecBase3d first_point = (*vi)->get_pos3(); LPlaned plane(normal, first_point); - // And check that all of the remaining vertices are sufficiently - // close to the plane. + // And check that all of the remaining vertices are sufficiently close to + // the plane. ++vi; while (vi != end()) { LVecBase3d this_point = (*vi)->get_pos3(); @@ -138,20 +127,15 @@ is_planar() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::triangulate_in_place -// Access: Published -// Description: Subdivides the polygon into triangles and adds those -// triangles to the parent group node in place of the -// original polygon. Returns a pointer to the original -// polygon, which is likely about to be destructed. -// -// If convex_also is true, both concave and convex -// polygons will be subdivided into triangles; -// otherwise, only concave polygons will be subdivided, -// and convex polygons will be copied unchanged into the -// container. -//////////////////////////////////////////////////////////////////// +/** + * Subdivides the polygon into triangles and adds those triangles to the + * parent group node in place of the original polygon. Returns a pointer to + * the original polygon, which is likely about to be destructed. + * + * If convex_also is true, both concave and convex polygons will be subdivided + * into triangles; otherwise, only concave polygons will be subdivided, and + * convex polygons will be copied unchanged into the container. + */ PT(EggPolygon) EggPolygon:: triangulate_in_place(bool convex_also) { EggGroupNode *parent = get_parent(); @@ -164,12 +148,9 @@ triangulate_in_place(bool convex_also) { return save_me; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::write -// Access: Published, Virtual -// Description: Writes the polygon to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the polygon to the indicated output stream in Egg format. + */ void EggPolygon:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -177,13 +158,10 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::decomp_concave -// Access: Private -// Description: Decomposes a concave polygon into triangles. Returns -// true if successful, false if the polygon is -// self-intersecting. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a concave polygon into triangles. Returns true if successful, + * false if the polygon is self-intersecting. + */ bool EggPolygon:: decomp_concave(EggGroupNode *container, int asum, int x, int y) const { #define VX(p, c) p->coord[c] @@ -213,8 +191,8 @@ decomp_concave(EggGroupNode *container, int asum, int x, int y) const { p0 = (DecompVtx *) alloca(sizeof(DecompVtx)); p0->index = i; p0->coord = get_vertex(i)->get_pos3(); - // There shouldn't be two consecutive identical vertices. If - // there are, skip one. + // There shouldn't be two consecutive identical vertices. If there are, + // skip one. if (!(p0->coord == p1->coord)) { p1->next = p0; p1 = p0; @@ -343,25 +321,18 @@ decomp_concave(EggGroupNode *container, int asum, int x, int y) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggPolygon::triangulate_poly -// Access: Private -// Description: Breaks a (possibly concave) higher-order polygon into -// a series of constituent triangles. Fills the -// container up with EggPolygons that represent the -// triangles. Returns true if successful, false on -// failure. -// -// If convex_also is true, both concave and convex -// polygons will be subdivided into triangles; -// otherwise, only concave polygons will be subdivided, -// and convex polygons will be copied unchanged into the -// container. -// -// It is assumed that the EggPolygon is not already a -// child of any other group when this function is -// called. -//////////////////////////////////////////////////////////////////// +/** + * Breaks a (possibly concave) higher-order polygon into a series of + * constituent triangles. Fills the container up with EggPolygons that + * represent the triangles. Returns true if successful, false on failure. + * + * If convex_also is true, both concave and convex polygons will be subdivided + * into triangles; otherwise, only concave polygons will be subdivided, and + * convex polygons will be copied unchanged into the container. + * + * It is assumed that the EggPolygon is not already a child of any other group + * when this function is called. + */ bool EggPolygon:: triangulate_poly(EggGroupNode *container, bool convex_also) { LPoint3d p0, p1, as; @@ -466,8 +437,8 @@ triangulate_poly(EggGroupNode *container, bool convex_also) { // It's a convex polygon. if (!convex_also) { - // Make sure that it's also coplanar. If it's not, we should - // triangulate it anyway. + // Make sure that it's also coplanar. If it's not, we should triangulate + // it anyway. if (is_planar()) { container->add_child(this); return true; diff --git a/panda/src/egg/eggPolygon.h b/panda/src/egg/eggPolygon.h index 0078abfea6..7c0298d9bd 100644 --- a/panda/src/egg/eggPolygon.h +++ b/panda/src/egg/eggPolygon.h @@ -1,16 +1,15 @@ -// Filename: eggPolygon.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPolygon.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGPOLYGON_H #define EGGPOLYGON_H @@ -19,10 +18,9 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPolygon -// Description : A single polygon. -//////////////////////////////////////////////////////////////////// +/** + * A single polygon. + */ class EXPCL_PANDAEGG EggPolygon : public EggPrimitive { PUBLISHED: INLINE EggPolygon(const string &name = ""); diff --git a/panda/src/egg/eggPolysetMaker.cxx b/panda/src/egg/eggPolysetMaker.cxx index 4f8a5d3e12..ddd2200df6 100644 --- a/panda/src/egg/eggPolysetMaker.cxx +++ b/panda/src/egg/eggPolysetMaker.cxx @@ -1,52 +1,43 @@ -// Filename: eggPolysetMaker.cxx -// Created by: drose (20Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPolysetMaker.cxx + * @author drose + * @date 2001-06-20 + */ #include "eggPolysetMaker.h" #include "eggPolygon.h" TypeHandle EggPolysetMaker::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPolysetMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggPolysetMaker:: EggPolysetMaker() { _properties = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolysetMaker::set_properties -// Access: Public -// Description: Sets the set of properties that determines which -// polygons are allowed to be grouped together into a -// single polyset. This is the bitwise 'or' of all the -// properties that matter. If this is 0, all polygons -// (within a given group) will be lumped into a common -// polyset regardless of their properties. -//////////////////////////////////////////////////////////////////// +/** + * Sets the set of properties that determines which polygons are allowed to be + * grouped together into a single polyset. This is the bitwise 'or' of all + * the properties that matter. If this is 0, all polygons (within a given + * group) will be lumped into a common polyset regardless of their properties. + */ void EggPolysetMaker:: set_properties(int properties) { _properties = properties; } -//////////////////////////////////////////////////////////////////// -// Function: EggPolysetMaker::get_bin_number -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int EggPolysetMaker:: get_bin_number(const EggNode *node) { if (node->is_of_type(EggPolygon::get_class_type())) { @@ -57,11 +48,9 @@ get_bin_number(const EggNode *node) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPolysetMaker::sorts_less -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggPolysetMaker:: sorts_less(int bin_number, const EggNode *a, const EggNode *b) { nassertr((BinNumber)bin_number == BN_polyset, false); diff --git a/panda/src/egg/eggPolysetMaker.h b/panda/src/egg/eggPolysetMaker.h index 8f824a01ee..5fa5eebc94 100644 --- a/panda/src/egg/eggPolysetMaker.h +++ b/panda/src/egg/eggPolysetMaker.h @@ -1,16 +1,15 @@ -// Filename: eggPolysetMaker.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPolysetMaker.h + * @author drose + * @date 2001-06-19 + */ #ifndef EGGPOLYSETMAKER_H #define EGGPOLYSETMAKER_H @@ -21,22 +20,18 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPolysetMaker -// Description : A specialization on EggBinMaker for making polysets -// that share the same basic rendering characteristic. -// This really just defines the example functions -// described in the leading comment to EggBinMaker. -// -// It makes some common assumptions about how polysets -// should be grouped; if these are not sufficient, you -// can always rederive your own further specialization -// of this class. -//////////////////////////////////////////////////////////////////// +/** + * A specialization on EggBinMaker for making polysets that share the same + * basic rendering characteristic. This really just defines the example + * functions described in the leading comment to EggBinMaker. + * + * It makes some common assumptions about how polysets should be grouped; if + * these are not sufficient, you can always rederive your own further + * specialization of this class. + */ class EXPCL_PANDAEGG EggPolysetMaker : public EggBinMaker { PUBLISHED: - // The BinNumber serves to identify why a particular EggBin was - // created. + // The BinNumber serves to identify why a particular EggBin was created. enum BinNumber { BN_none = 0, BN_polyset, diff --git a/panda/src/egg/eggPoolUniquifier.cxx b/panda/src/egg/eggPoolUniquifier.cxx index 4b090c6bd8..859bd0aff0 100644 --- a/panda/src/egg/eggPoolUniquifier.cxx +++ b/panda/src/egg/eggPoolUniquifier.cxx @@ -1,16 +1,15 @@ -// Filename: eggPoolUniquifier.cxx -// Created by: drose (09Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPoolUniquifier.cxx + * @author drose + * @date 2000-11-09 + */ #include "eggPoolUniquifier.h" #include "eggNode.h" @@ -23,22 +22,17 @@ TypeHandle EggPoolUniquifier::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPoolUniquifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggPoolUniquifier:: EggPoolUniquifier() { } -//////////////////////////////////////////////////////////////////// -// Function: EggPoolUniquifier::get_category -// Access: Public -// Description: Returns the category name into which the given node -// should be collected, or the empty string if the -// node's name should be left alone. -//////////////////////////////////////////////////////////////////// +/** + * Returns the category name into which the given node should be collected, or + * the empty string if the node's name should be left alone. + */ string EggPoolUniquifier:: get_category(EggNode *node) { if (node->is_of_type(EggTexture::get_class_type())) { diff --git a/panda/src/egg/eggPoolUniquifier.h b/panda/src/egg/eggPoolUniquifier.h index 7fdc113be8..0fb7d1b9d5 100644 --- a/panda/src/egg/eggPoolUniquifier.h +++ b/panda/src/egg/eggPoolUniquifier.h @@ -1,16 +1,15 @@ -// Filename: eggPoolUniquifier.h -// Created by: drose (09Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPoolUniquifier.h + * @author drose + * @date 2000-11-09 + */ #ifndef EGGPOOLUNIQUIFIER_H #define EGGPOOLUNIQUIFIER_H @@ -19,14 +18,11 @@ #include "eggNameUniquifier.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPoolUniquifier -// Description : This is a specialization of EggNameUniquifier to -// generate unique names for textures, materials, and -// vertex pools prior to writing out an egg file. It's -// automatically called by EggData prior to writing out -// an egg file. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization of EggNameUniquifier to generate unique names for + * textures, materials, and vertex pools prior to writing out an egg file. + * It's automatically called by EggData prior to writing out an egg file. + */ class EXPCL_PANDAEGG EggPoolUniquifier : public EggNameUniquifier { PUBLISHED: EggPoolUniquifier(); @@ -53,5 +49,3 @@ private: }; #endif - - diff --git a/panda/src/egg/eggPrimitive.I b/panda/src/egg/eggPrimitive.I index 65b00a10a5..56fa2f8792 100644 --- a/panda/src/egg/eggPrimitive.I +++ b/panda/src/egg/eggPrimitive.I @@ -1,34 +1,28 @@ -// Filename: eggPrimitive.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPrimitive.I + * @author drose + * @date 1999-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive:: EggPrimitive(const string &name): EggNode(name) { _bface = false; _connected_shading = S_unknown; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive:: EggPrimitive(const EggPrimitive ©) : EggNode(copy), @@ -41,11 +35,9 @@ EggPrimitive(const EggPrimitive ©) : _connected_shading = S_unknown; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive &EggPrimitive:: operator = (const EggPrimitive ©) { EggNode::operator = (copy); @@ -58,26 +50,21 @@ operator = (const EggPrimitive ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive:: ~EggPrimitive() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_sort_name -// Access: Published -// Description: Returns the name of the primitive for the purposes of -// sorting primitives into different groups, if there is -// one. -// -// Presently, this is defined as the primitive name -// itself, unless it begins with a digit. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the primitive for the purposes of sorting primitives + * into different groups, if there is one. + * + * Presently, this is defined as the primitive name itself, unless it begins + * with a digit. + */ INLINE string EggPrimitive:: get_sort_name() const { const string &name = get_name(); @@ -87,35 +74,27 @@ get_sort_name() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::clear_connected_shading -// Access: Published -// Description: Resets the connected_shading member in this -// primitive, so that get_connected_shading() will -// recompute a new value. -//////////////////////////////////////////////////////////////////// +/** + * Resets the connected_shading member in this primitive, so that + * get_connected_shading() will recompute a new value. + */ INLINE void EggPrimitive:: clear_connected_shading() { _connected_shading = S_unknown; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_connected_shading -// Access: Published -// Description: Determines what sort of shading properties this -// primitive's connected neighbors have. -// -// To get the most accurate results, you should first -// call clear_connected_shading() on all connected -// primitives (or on all primitives in the egg file). -// It might also be a good idea to call -// remove_unused_vertices() to ensure proper -// connectivity. -// -// You may find it easiest to call these other methods -// on the EggData root node (they are defined on -// EggGroupNode). -//////////////////////////////////////////////////////////////////// +/** + * Determines what sort of shading properties this primitive's connected + * neighbors have. + * + * To get the most accurate results, you should first call + * clear_connected_shading() on all connected primitives (or on all primitives + * in the egg file). It might also be a good idea to call + * remove_unused_vertices() to ensure proper connectivity. + * + * You may find it easiest to call these other methods on the EggData root + * node (they are defined on EggGroupNode). + */ INLINE EggPrimitive::Shading EggPrimitive:: get_connected_shading() const { if (_connected_shading == S_unknown) { @@ -125,106 +104,82 @@ get_connected_shading() const { return _connected_shading; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::set_texture -// Access: Published -// Description: Replaces the current list of textures with the -// indicated texture. -// -// This method is deprecated and is used in support of -// single-texturing only. Please use the multitexture -// variant add_texture instead. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current list of textures with the indicated texture. + * + * This method is deprecated and is used in support of single-texturing only. + * Please use the multitexture variant add_texture instead. + */ INLINE void EggPrimitive:: set_texture(EggTexture *texture) { clear_texture(); add_texture(texture); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_texture -// Access: Published -// Description: Returns true if the primitive has any textures -// specified, false otherwise. -// -// This method is deprecated and is used in support of -// single-texturing only. New code should be written to -// use the multitexture variants instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive has any textures specified, false otherwise. + * + * This method is deprecated and is used in support of single-texturing only. + * New code should be written to use the multitexture variants instead. + */ INLINE bool EggPrimitive:: has_texture() const { return get_num_textures() > 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_texture -// Access: Published -// Description: Returns true if the primitive has the particular -// indicated texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive has the particular indicated texture, false + * otherwise. + */ INLINE bool EggPrimitive:: has_texture(EggTexture *texture) const { PT_EggTexture t = texture; return (::find(_textures.begin(), _textures.end(), t) != _textures.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_texture -// Access: Published -// Description: Returns the first texture on the primitive, if any, -// or NULL if there are no textures on the primitive. -// -// This method is deprecated and is used in support of -// single-texturing only. New code should be written to -// use the multitexture variants instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first texture on the primitive, if any, or NULL if there are no + * textures on the primitive. + * + * This method is deprecated and is used in support of single-texturing only. + * New code should be written to use the multitexture variants instead. + */ INLINE EggTexture *EggPrimitive:: get_texture() const { return has_texture() ? get_texture(0) : (EggTexture *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::add_texture -// Access: Published -// Description: Applies the indicated texture to the primitive. -// -// Note that, in the case of multiple textures being -// applied to a single primitive, the order in which the -// textures are applied does not affect the rendering -// order; use EggTexture::set_sort() to specify that. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated texture to the primitive. + * + * Note that, in the case of multiple textures being applied to a single + * primitive, the order in which the textures are applied does not affect the + * rendering order; use EggTexture::set_sort() to specify that. + */ INLINE void EggPrimitive:: add_texture(EggTexture *texture) { _textures.push_back(texture); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::clear_texture -// Access: Published -// Description: Removes any texturing from the primitive. -//////////////////////////////////////////////////////////////////// +/** + * Removes any texturing from the primitive. + */ INLINE void EggPrimitive:: clear_texture() { _textures.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_num_textures -// Access: Published -// Description: Returns the number of textures applied to the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of textures applied to the primitive. + */ INLINE int EggPrimitive:: get_num_textures() const { return _textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_texture -// Access: Published -// Description: Returns the nth texture that has been applied to the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth texture that has been applied to the primitive. + */ INLINE EggTexture *EggPrimitive:: get_texture(int n) const { nassertr(n >= 0 && n < (int)_textures.size(), NULL); @@ -232,154 +187,123 @@ get_texture(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::set_material -// Access: Published -// Description: Applies the indicated material to the primitive. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated material to the primitive. + */ INLINE void EggPrimitive:: set_material(EggMaterial *material) { _material = material; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::clear_material -// Access: Published -// Description: Removes any material from the primitive. -//////////////////////////////////////////////////////////////////// +/** + * Removes any material from the primitive. + */ INLINE void EggPrimitive:: clear_material() { _material = (EggMaterial *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_material -// Access: Published -// Description: Returns a pointer to the applied material, or NULL if -// there is no material applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the applied material, or NULL if there is no material + * applied. + */ INLINE EggMaterial *EggPrimitive:: get_material() const { return _material; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_material -// Access: Published -// Description: Returns true if the primitive is materiald (and -// get_material() will return a real pointer), false -// otherwise (and get_material() will return NULL). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive is materiald (and get_material() will return + * a real pointer), false otherwise (and get_material() will return NULL). + */ INLINE bool EggPrimitive:: has_material() const { return _material != (EggMaterial *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::set_bface_flag -// Access: Published -// Description: Sets the backfacing flag of the polygon. If this is -// true, the polygon will be rendered so that both faces -// are visible; if it is false, only the front face of -// the polygon will be visible. -//////////////////////////////////////////////////////////////////// +/** + * Sets the backfacing flag of the polygon. If this is true, the polygon will + * be rendered so that both faces are visible; if it is false, only the front + * face of the polygon will be visible. + */ INLINE void EggPrimitive:: set_bface_flag(bool flag) { _bface = flag; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_bface_flag -// Access: Published -// Description: Retrieves the backfacing flag of the polygon. See -// set_bface_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the backfacing flag of the polygon. See set_bface_flag(). + */ INLINE bool EggPrimitive:: get_bface_flag() const { return _bface; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::iterator EggPrimitive:: begin() const { return _vertices.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::iterator EggPrimitive:: end() const { return _vertices.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::rbegin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::reverse_iterator EggPrimitive:: rbegin() const { return _vertices.rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::rend -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::reverse_iterator EggPrimitive:: rend() const { return _vertices.rend(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggPrimitive:: empty() const { return _vertices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::size_type EggPrimitive:: size() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::Indexing operator -// Access: Public -// Description: This is read-only: you can't assign directly to an -// indexed vertex. See set_vertex() instead. -//////////////////////////////////////////////////////////////////// +/** + * This is read-only: you can't assign directly to an indexed vertex. See + * set_vertex() instead. + */ INLINE EggVertex *EggPrimitive:: operator [] (int index) const { nassertr(index >= 0 && index < (int)size(), NULL); return *(begin() + index); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::iterator EggPrimitive:: insert(iterator position, EggVertex *x) { prepare_add_vertex(x, position - _vertices.begin(), _vertices.size() + 1); @@ -389,11 +313,9 @@ insert(iterator position, EggVertex *x) { return i; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::erase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggPrimitive::iterator EggPrimitive:: erase(iterator position) { prepare_remove_vertex(*position, position - _vertices.begin(), _vertices.size()); @@ -402,19 +324,17 @@ erase(iterator position) { return i; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::replace -// Access: Public -// Description: Replaces the vertex at the indicated position with -// the indicated vertex. It is an error to call this -// with an invalid position iterator (e.g. end()). -//////////////////////////////////////////////////////////////////// +/** + * Replaces the vertex at the indicated position with the indicated vertex. + * It is an error to call this with an invalid position iterator (e.g. + * end()). + */ INLINE void EggPrimitive:: replace(iterator position, EggVertex *x) { nassertv(position != end()); - // We pass -1 for i and n so that EggCompositePrimitive won't try to - // adjust its _components list. + // We pass -1 for i and n so that EggCompositePrimitive won't try to adjust + // its _components list. prepare_remove_vertex(*position, -1, -1); prepare_add_vertex(x, -1, -1); *(Vertices::iterator &)position = x; @@ -423,45 +343,36 @@ replace(iterator position, EggVertex *x) { test_vref_integrity(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::clear -// Access: Published -// Description: Removes all of the vertices from the primitive. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the vertices from the primitive. + */ INLINE void EggPrimitive:: clear() { erase(begin(), end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_num_vertices -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int EggPrimitive:: get_num_vertices() const { return size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::set_vertex -// Access: Published -// Description: Replaces a particular vertex based on its index -// number in the list of vertices. This is just a -// convenience function for people who don't want to -// mess with the iterators. -//////////////////////////////////////////////////////////////////// +/** + * Replaces a particular vertex based on its index number in the list of + * vertices. This is just a convenience function for people who don't want to + * mess with the iterators. + */ INLINE void EggPrimitive:: set_vertex(int index, EggVertex *vertex) { nassertv(index >= 0 && index < (int)size()); replace(begin() + index, vertex); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_vertex -// Access: Published -// Description: Returns a particular index based on its index number. -//////////////////////////////////////////////////////////////////// +/** + * Returns a particular index based on its index number. + */ INLINE EggVertex *EggPrimitive:: get_vertex(int index) const { nassertr(index >= 0 && index < (int)size(), NULL); @@ -469,13 +380,10 @@ get_vertex(int index) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_pool -// Access: Published -// Description: Returns the vertex pool associated with the vertices -// of the primitive, or NULL if the primitive has no -// vertices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex pool associated with the vertices of the primitive, or + * NULL if the primitive has no vertices. + */ INLINE EggVertexPool *EggPrimitive:: get_pool() const { return empty() ? (EggVertexPool *)NULL : _vertices.front()->get_pool(); diff --git a/panda/src/egg/eggPrimitive.cxx b/panda/src/egg/eggPrimitive.cxx index 615fc368b5..630c784ed3 100644 --- a/panda/src/egg/eggPrimitive.cxx +++ b/panda/src/egg/eggPrimitive.cxx @@ -1,16 +1,15 @@ -// Filename: eggPrimitive.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPrimitive.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggPrimitive.h" #include "eggVertexPool.h" @@ -25,15 +24,12 @@ TypeHandle EggPrimitive::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_alpha_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this primitive that has an alpha_mode other than -// AM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this primitive that has an + * alpha_mode other than AM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_alpha_mode() { if (get_alpha_mode() != AM_unspecified) { @@ -46,12 +42,12 @@ determine_alpha_mode() { for (int i = 0; i < num_textures && result == (EggRenderMode *)NULL; i++) { EggTexture *egg_tex = get_texture(i); - // We only want to consider the alpha mode on those textures - // that can affect the transparency of the polygon. This - // mostly depends on the envtype flag. + // We only want to consider the alpha mode on those textures that can + // affect the transparency of the polygon. This mostly depends on the + // envtype flag. if (egg_tex->affects_polygon_alpha()) { - // This texture might affect the polygon alpha, so it gets to - // decide the polygon transparency mode. + // This texture might affect the polygon alpha, so it gets to decide + // the polygon transparency mode. if (egg_tex->get_alpha_mode() != AM_unspecified) { result = get_texture(i); } @@ -61,15 +57,12 @@ determine_alpha_mode() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_depth_write_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a depth_write_mode other than -// DWM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * depth_write_mode other than DWM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_depth_write_mode() { if (get_depth_write_mode() != DWM_unspecified) { @@ -88,15 +81,12 @@ determine_depth_write_mode() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_depth_test_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a depth_test_mode other than -// DTM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * depth_test_mode other than DTM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_depth_test_mode() { if (get_depth_test_mode() != DTM_unspecified) { @@ -115,15 +105,12 @@ determine_depth_test_mode() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_visibility_mode -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this node that has a visibility_mode other than -// VM_unspecified. Returns a valid EggRenderMode pointer -// if one is found, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this node that has a + * visibility_mode other than VM_unspecified. Returns a valid EggRenderMode + * pointer if one is found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_visibility_mode() { if (get_visibility_mode() != VM_unspecified) { @@ -142,15 +129,12 @@ determine_visibility_mode() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_depth_offset -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this primitive that has a depth_offset specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this primitive that has a + * depth_offset specified. Returns a valid EggRenderMode pointer if one is + * found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_depth_offset() { if (has_depth_offset()) { @@ -169,15 +153,12 @@ determine_depth_offset() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_draw_order -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this primitive that has a draw_order specified. -// Returns a valid EggRenderMode pointer if one is found, -// or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this primitive that has a + * draw_order specified. Returns a valid EggRenderMode pointer if one is + * found, or NULL otherwise. + */ EggRenderMode *EggPrimitive:: determine_draw_order() { if (has_draw_order()) { @@ -196,15 +177,12 @@ determine_draw_order() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::determine_bin -// Access: Published, Virtual -// Description: Walks back up the hierarchy, looking for an EggGroup -// or EggPrimitive or some such object at this level or -// above this primitive that has a bin specified. Returns a -// valid EggRenderMode pointer if one is found, or NULL -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or + * some such object at this level or above this primitive that has a bin + * specified. Returns a valid EggRenderMode pointer if one is found, or NULL + * otherwise. + */ EggRenderMode *EggPrimitive:: determine_bin() { if (has_bin()) { @@ -224,25 +202,19 @@ determine_bin() { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::get_shading -// Access: Published, Virtual -// Description: Returns the shading properties apparent on this -// particular primitive. This returns S_per_vertex if -// the vertices have colors or normals (and they are not -// all the same values), or for a simple primitive, -// S_overall otherwise. A composite primitive may also -// return S_per_face if the individual component -// primitives have colors or normals that are not all -// the same values. -// -// To get the most accurate results, you should call -// clear_shading() on all connected primitives (or on -// all primitives in the egg file), followed by -// get_shading() on each primitive. You may find it -// easiest to call these methods on the EggData root -// node (they are defined on EggGroupNode). -//////////////////////////////////////////////////////////////////// +/** + * Returns the shading properties apparent on this particular primitive. This + * returns S_per_vertex if the vertices have colors or normals (and they are + * not all the same values), or for a simple primitive, S_overall otherwise. + * A composite primitive may also return S_per_face if the individual + * component primitives have colors or normals that are not all the same + * values. + * + * To get the most accurate results, you should call clear_shading() on all + * connected primitives (or on all primitives in the egg file), followed by + * get_shading() on each primitive. You may find it easiest to call these + * methods on the EggData root node (they are defined on EggGroupNode). + */ EggPrimitive::Shading EggPrimitive:: get_shading() const { if (empty()) { @@ -286,23 +258,17 @@ get_shading() const { return S_overall; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::copy_attributes -// Access: Published -// Description: Copies the rendering attributes from the indicated -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Copies the rendering attributes from the indicated primitive. + */ void EggPrimitive:: copy_attributes(const EggAttributes &other) { EggAttributes::operator = (other); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::copy_attributes -// Access: Published -// Description: Copies the rendering attributes from the indicated -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Copies the rendering attributes from the indicated primitive. + */ void EggPrimitive:: copy_attributes(const EggPrimitive &other) { EggAttributes::operator = (other); @@ -311,17 +277,14 @@ copy_attributes(const EggPrimitive &other) { set_bface_flag(other.get_bface_flag()); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_vertex_normal -// Access: Published -// Description: Returns true if any vertex on the primitive has a -// specific normal set, false otherwise. -// -// If you call unify_attributes() first, this will also -// return false even if all the vertices were set to the -// same value (since unify_attributes() removes -// redundant vertex properties). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex on the primitive has a specific normal set, + * false otherwise. + * + * If you call unify_attributes() first, this will also return false even if + * all the vertices were set to the same value (since unify_attributes() + * removes redundant vertex properties). + */ bool EggPrimitive:: has_vertex_normal() const { Vertices::const_iterator vi; @@ -333,17 +296,14 @@ has_vertex_normal() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_vertex_color -// Access: Published -// Description: Returns true if any vertex on the primitive has a -// specific color set, false otherwise. -// -// If you call unify_attributes() first, this will also -// return false even if all the vertices were set to the -// same value (since unify_attributes() removes -// redundant vertex properties). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex on the primitive has a specific color set, false + * otherwise. + * + * If you call unify_attributes() first, this will also return false even if + * all the vertices were set to the same value (since unify_attributes() + * removes redundant vertex properties). + */ bool EggPrimitive:: has_vertex_color() const { Vertices::const_iterator vi; @@ -355,30 +315,24 @@ has_vertex_color() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::unify_attributes -// Access: Published, Virtual -// Description: If the shading property is S_per_vertex, ensures that -// all vertices have a normal and a color, and the -// overall primitive does not. -// -// If the shading property is S_per_face, and this is a -// composite primitive, ensures that all components have -// a normal and a color, and the vertices and overall -// primitive do not. (If this is a simple primitive, -// S_per_face works the same as S_overall, below). -// -// If the shading property is S_overall, ensures that no -// vertices or components have a normal or a color, and -// the overall primitive does (if any exists at all). -// -// After this call, either the primitive will have -// normals or its vertices will, but not both. Ditto -// for colors. -// -// This may create redundant vertices in the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * If the shading property is S_per_vertex, ensures that all vertices have a + * normal and a color, and the overall primitive does not. + * + * If the shading property is S_per_face, and this is a composite primitive, + * ensures that all components have a normal and a color, and the vertices and + * overall primitive do not. (If this is a simple primitive, S_per_face works + * the same as S_overall, below). + * + * If the shading property is S_overall, ensures that no vertices or + * components have a normal or a color, and the overall primitive does (if any + * exists at all). + * + * After this call, either the primitive will have normals or its vertices + * will, but not both. Ditto for colors. + * + * This may create redundant vertices in the vertex pool. + */ void EggPrimitive:: unify_attributes(EggPrimitive::Shading shading) { if (shading == S_unknown) { @@ -469,19 +423,14 @@ unify_attributes(EggPrimitive::Shading shading) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::apply_last_attribute -// Access: Published, Virtual -// Description: Sets the last vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// OpenGL convention of storing flat-shaded properties on -// the last vertex, although it is not usually a -// convention in Egg. -// -// This may introduce redundant vertices to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Sets the last vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * OpenGL convention of storing flat-shaded properties on the last vertex, + * although it is not usually a convention in Egg. + * + * This may introduce redundant vertices to the vertex pool. + */ void EggPrimitive:: apply_last_attribute() { if (!empty()) { @@ -489,19 +438,14 @@ apply_last_attribute() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::apply_first_attribute -// Access: Published, Virtual -// Description: Sets the first vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// DirectX convention of storing flat-shaded properties on -// the first vertex, although it is not usually a -// convention in Egg. -// -// This may introduce redundant vertices to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Sets the first vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * DirectX convention of storing flat-shaded properties on the first vertex, + * although it is not usually a convention in Egg. + * + * This may introduce redundant vertices to the vertex pool. + */ void EggPrimitive:: apply_first_attribute() { if (!empty()) { @@ -509,23 +453,20 @@ apply_first_attribute() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::post_apply_flat_attribute -// Access: Published, Virtual -// Description: Intended as a followup to apply_last_attribute(), -// this also sets an attribute on the first vertices of -// the primitive, if they don't already have an -// attribute set, just so they end up with *something*. -//////////////////////////////////////////////////////////////////// +/** + * Intended as a followup to apply_last_attribute(), this also sets an + * attribute on the first vertices of the primitive, if they don't already + * have an attribute set, just so they end up with *something*. + */ void EggPrimitive:: post_apply_flat_attribute() { if (!empty()) { for (int i = 0; i < (int)size(); i++) { EggVertex *vertex = get_vertex(i); - // Use set_normal() instead of copy_normal(), to avoid getting - // the morphs--we don't want them here, since we're just putting - // a bogus value on the normal anyway. + // Use set_normal() instead of copy_normal(), to avoid getting the + // morphs--we don't want them here, since we're just putting a bogus + // value on the normal anyway. if (has_normal() && !vertex->has_normal()) { vertex->set_normal(get_normal()); @@ -537,54 +478,43 @@ post_apply_flat_attribute() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::reverse_vertex_ordering -// Access: Published, Virtual -// Description: Reverses the ordering of the vertices in this -// primitive, if appropriate, in order to change the -// direction the polygon appears to be facing. Does not -// adjust the surface normal, if any. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the ordering of the vertices in this primitive, if appropriate, in + * order to change the direction the polygon appears to be facing. Does not + * adjust the surface normal, if any. + */ void EggPrimitive:: reverse_vertex_ordering() { - // This really only makes sense for polygons. Lights don't care - // about vertex ordering, and NURBS surfaces have to do a bit more - // work in addition to this. + // This really only makes sense for polygons. Lights don't care about + // vertex ordering, and NURBS surfaces have to do a bit more work in + // addition to this. reverse(_vertices.begin(), _vertices.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::cleanup -// Access: Published, Virtual -// Description: Cleans up modeling errors in whatever context this -// makes sense. For instance, for a polygon, this calls -// remove_doubled_verts(true). For a point, it calls -// remove_nonunique_verts(). Returns true if the -// primitive is valid, or false if it is degenerate. -//////////////////////////////////////////////////////////////////// +/** + * Cleans up modeling errors in whatever context this makes sense. For + * instance, for a polygon, this calls remove_doubled_verts(true). For a + * point, it calls remove_nonunique_verts(). Returns true if the primitive is + * valid, or false if it is degenerate. + */ bool EggPrimitive:: cleanup() { return !empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::remove_doubled_verts -// Access: Published -// Description: Certain kinds of primitives, particularly polygons, -// don't like to have the same vertex repeated -// consecutively. Unfortunately, some modeling programs -// (like MultiGen) make this an easy mistake to make. -// -// It's handy to have a function to remove these -// redundant vertices. If closed is true, it also -// checks that the first and last vertices are not the -// same. -// -// This function identifies repeated vertices by -// position only; it does not consider any other -// properties, such as color or UV, significant in -// differentiating vertices. -//////////////////////////////////////////////////////////////////// +/** + * Certain kinds of primitives, particularly polygons, don't like to have the + * same vertex repeated consecutively. Unfortunately, some modeling programs + * (like MultiGen) make this an easy mistake to make. + * + * It's handy to have a function to remove these redundant vertices. If + * closed is true, it also checks that the first and last vertices are not the + * same. + * + * This function identifies repeated vertices by position only; it does not + * consider any other properties, such as color or UV, significant in + * differentiating vertices. + */ void EggPrimitive:: remove_doubled_verts(bool closed) { if (!_vertices.empty()) { @@ -600,7 +530,7 @@ remove_doubled_verts(bool closed) { if ((*vi)->get_pos4() != (*vlast)->get_pos4()) { new_vertices.push_back(*vi); } else { - prepare_remove_vertex(*vi, vi - _vertices.begin() - num_removed, + prepare_remove_vertex(*vi, vi - _vertices.begin() - num_removed, _vertices.size() - num_removed); num_removed++; } @@ -611,27 +541,23 @@ remove_doubled_verts(bool closed) { } if (closed) { - // Then, if this is a polygon (which will be closed anyway), - // remove the vertex from the end if it's a repeat of the - // beginning. - while (_vertices.size() > 1 && + // Then, if this is a polygon (which will be closed anyway), remove the + // vertex from the end if it's a repeat of the beginning. + while (_vertices.size() > 1 && _vertices.back()->get_pos4() == _vertices.front()->get_pos4()) { - prepare_remove_vertex(_vertices.back(), _vertices.size() - 1, + prepare_remove_vertex(_vertices.back(), _vertices.size() - 1, _vertices.size()); _vertices.pop_back(); } } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::remove_nonunique_verts -// Access: Published -// Description: Removes any multiple appearances of the same vertex -// from the primitive. This primarily makes sense for a -// point primitive, which is really a collection of -// points and which doesn't make sense to include the -// same point twice, in any order. -//////////////////////////////////////////////////////////////////// +/** + * Removes any multiple appearances of the same vertex from the primitive. + * This primarily makes sense for a point primitive, which is really a + * collection of points and which doesn't make sense to include the same point + * twice, in any order. + */ void EggPrimitive:: remove_nonunique_verts() { Vertices::iterator vi, vj; @@ -653,37 +579,28 @@ remove_nonunique_verts() { _vertices.swap(new_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_primitives -// Access: Published, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, false otherwise. + */ bool EggPrimitive:: has_primitives() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::joint_has_primitives -// Access: Published, Virtual -// Description: Returns true if there are any primitives -// (e.g. polygons) defined within this group or below, -// but the search does not include nested joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any primitives (e.g. polygons) defined within + * this group or below, but the search does not include nested joints. + */ bool EggPrimitive:: joint_has_primitives() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::has_normals -// Access: Published, Virtual -// Description: Returns true if any of the primitives (e.g. polygons) -// defined within this group or below have either face -// or vertex normals defined, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the primitives (e.g. polygons) defined within this + * group or below have either face or vertex normals defined, false otherwise. + */ bool EggPrimitive:: has_normals() const { if (has_normal()) { @@ -701,19 +618,16 @@ has_normals() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::erase -// Access: Public -// Description: Part of the implementaion of the EggPrimitive as an -// STL container. Most of the rest of these functions -// are inline and declared in EggPrimitive.I. -//////////////////////////////////////////////////////////////////// +/** + * Part of the implementaion of the EggPrimitive as an STL container. Most of + * the rest of these functions are inline and declared in EggPrimitive.I. + */ EggPrimitive::iterator EggPrimitive:: erase(iterator first, iterator last) { iterator i; int num_removed = 0; for (i = first; i != last; ++i) { - prepare_remove_vertex(*i, first - _vertices.begin(), + prepare_remove_vertex(*i, first - _vertices.begin(), _vertices.size() - num_removed); num_removed++; } @@ -723,13 +637,10 @@ erase(iterator first, iterator last) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::find -// Access: Public -// Description: Returns the iterator pointing to the indicated -// vertex, or end() if the vertex is not part of the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator pointing to the indicated vertex, or end() if the + * vertex is not part of the primitive. + */ EggPrimitive::iterator EggPrimitive:: find(EggVertex *vertex) { PT_EggVertex vpt = vertex; @@ -737,12 +648,10 @@ find(EggVertex *vertex) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::add_vertex -// Access: Published -// Description: Adds the indicated vertex to the end of the -// primitive's list of vertices, and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated vertex to the end of the primitive's list of vertices, + * and returns it. + */ EggVertex *EggPrimitive:: add_vertex(EggVertex *vertex) { prepare_add_vertex(vertex, _vertices.size(), _vertices.size() + 1); @@ -754,14 +663,10 @@ add_vertex(EggVertex *vertex) { return vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::remove_vertex -// Access: Published -// Description: Removes the indicated vertex from the -// primitive and returns it. If the vertex was not -// already in the primitive, does nothing and returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated vertex from the primitive and returns it. If the + * vertex was not already in the primitive, does nothing and returns NULL. + */ EggVertex *EggPrimitive:: remove_vertex(EggVertex *vertex) { PT_EggVertex vpt = vertex; @@ -780,13 +685,10 @@ remove_vertex(EggVertex *vertex) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::copy_vertices -// Access: Published -// Description: Replaces the current primitive's list of vertices -// with a copy of the list of vertices on the other -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current primitive's list of vertices with a copy of the list + * of vertices on the other primitive. + */ void EggPrimitive:: copy_vertices(const EggPrimitive &other) { clear(); @@ -803,29 +705,27 @@ copy_vertices(const EggPrimitive &other) { #ifdef _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::test_vref_integrity -// Access: Published -// Description: Verifies that each vertex in the primitive exists and -// that it knows it is referenced by the primitive. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that each vertex in the primitive exists and that it knows it is + * referenced by the primitive. + */ void EggPrimitive:: test_vref_integrity() const { test_ref_count_integrity(); - + if ((int)size() <= egg_test_vref_integrity) { - // First, we need to know how many times each vertex appears. - // Usually, this will be only one, but it's possible for a vertex to - // appear more than once. + // First, we need to know how many times each vertex appears. Usually, + // this will be only one, but it's possible for a vertex to appear more + // than once. typedef pmap VertexCount; VertexCount _count; - + // Now count up the vertices. iterator vi; for (vi = begin(); vi != end(); ++vi) { const EggVertex *vert = *vi; vert->test_ref_count_integrity(); - + VertexCount::iterator vci = _count.find(vert); if (vci == _count.end()) { _count[vert] = 1; @@ -833,16 +733,16 @@ test_vref_integrity() const { (*vci).second++; } } - - // Ok, now walk through the vertices found and make sure the vertex - // has the proper number of entries of this primitive in its pref. + + // Ok, now walk through the vertices found and make sure the vertex has + // the proper number of entries of this primitive in its pref. VertexCount::iterator vci; for (vci = _count.begin(); vci != _count.end(); ++vci) { const EggVertex *vert = (*vci).first; - + int count = (*vci).second; int vert_count = vert->has_pref(this); - + nassertv(count == vert_count); } } @@ -850,77 +750,65 @@ test_vref_integrity() const { #endif // _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::prepare_add_vertex -// Access: Protected, Virtual -// Description: Marks the vertex as belonging to the primitive. This -// is an internal function called by the STL-like -// functions push_back() and insert(), in preparation -// for actually adding the vertex. -// -// i indicates the new position of the vertex in the -// list; n indicates the new number of vertices after -// the operation has completed. -//////////////////////////////////////////////////////////////////// +/** + * Marks the vertex as belonging to the primitive. This is an internal + * function called by the STL-like functions push_back() and insert(), in + * preparation for actually adding the vertex. + * + * i indicates the new position of the vertex in the list; n indicates the new + * number of vertices after the operation has completed. + */ void EggPrimitive:: prepare_add_vertex(EggVertex *vertex, int i, int n) { - // We can't test integrity within this function, because it might be - // called when the primitive is in an incomplete state. + // We can't test integrity within this function, because it might be called + // when the primitive is in an incomplete state. - // The vertex must have the same vertex pool as the vertices already - // added. + // The vertex must have the same vertex pool as the vertices already added. nassertv(empty() || vertex->get_pool() == get_pool()); // Since a given vertex might appear more than once in a particular - // primitive, we can't conclude anything about data integrity by - // inspecting the return value of insert(). (In fact, the vertex's - // pref is a multiset, so the insert() will always succeed.) + // primitive, we can't conclude anything about data integrity by inspecting + // the return value of insert(). (In fact, the vertex's pref is a multiset, + // so the insert() will always succeed.) vertex->_pref.insert(this); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::prepare_remove_vertex -// Access: Protected, Virtual -// Description: Marks the vertex as removed from the primitive. This -// is an internal function called by the STL-like -// functions pop_back() and erase(), in preparation for -// actually doing the removal. -// -// i indicates the former position of the vertex in the -// list; n indicates the current number of vertices -// before the operation has completed. -// -// It is an error to attempt to remove a vertex that is -// not already a vertex of this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Marks the vertex as removed from the primitive. This is an internal + * function called by the STL-like functions pop_back() and erase(), in + * preparation for actually doing the removal. + * + * i indicates the former position of the vertex in the list; n indicates the + * current number of vertices before the operation has completed. + * + * It is an error to attempt to remove a vertex that is not already a vertex + * of this primitive. + */ void EggPrimitive:: prepare_remove_vertex(EggVertex *vertex, int i, int n) { - // We can't test integrity within this function, because it might be - // called when the primitive is in an incomplete state. + // We can't test integrity within this function, because it might be called + // when the primitive is in an incomplete state. - // Now we must remove the primitive from the vertex's pref. We - // can't just use the simple erase() function, since that will - // remove all instances of this primitive from the pref; instead, we - // must find one instance and remove that. + // Now we must remove the primitive from the vertex's pref. We can't just + // use the simple erase() function, since that will remove all instances of + // this primitive from the pref; instead, we must find one instance and + // remove that. EggVertex::PrimitiveRef::iterator pri = vertex->_pref.find(this); - // We should have found the primitive in the vertex's pref. If we - // did not, something's out of sync internally. + // We should have found the primitive in the vertex's pref. If we did not, + // something's out of sync internally. nassertv(pri != vertex->_pref.end()); vertex->_pref.erase(pri); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::write_body -// Access: Protected -// Description: Writes the attributes and the vertices referenced by -// the primitive to the indicated output stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the attributes and the vertices referenced by the primitive to the + * indicated output stream in Egg format. + */ void EggPrimitive:: write_body(ostream &out, int indent_level) const { test_vref_integrity(); @@ -959,8 +847,7 @@ write_body(ostream &out, int indent_level) const { nassertv(pool->has_name()); if ((int)size() < 10) { - // A simple primitive gets all its vertex indices written on one - // line. + // A simple primitive gets all its vertex indices written on one line. indent(out, indent_level) << " {"; const_iterator i; for (i = begin(); i != end(); ++i) { @@ -977,8 +864,7 @@ write_body(ostream &out, int indent_level) const { } else { - // A larger primitive gets its vertex indices written as - // multiple lines. + // A larger primitive gets its vertex indices written as multiple lines. vector_int indices; const_iterator i; for (i = begin(); i != end(); ++i) { @@ -1001,44 +887,35 @@ write_body(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::egg_start_parse_body -// Access: Protected, Virtual -// Description: This function is called within parse_egg(). It -// should call the appropriate function on the lexer to -// initialize the parser into the state associated with -// this object. If the object cannot be parsed into -// directly, it should return false. -//////////////////////////////////////////////////////////////////// +/** + * This function is called within parse_egg(). It should call the appropriate + * function on the lexer to initialize the parser into the state associated + * with this object. If the object cannot be parsed into directly, it should + * return false. + */ bool EggPrimitive:: egg_start_parse_body() { egg_start_primitive_body(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggPrimitive:: r_transform(const LMatrix4d &mat, const LMatrix4d &, CoordinateSystem) { EggAttributes::transform(mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::r_flatten_transforms -// Access: Protected, Virtual -// Description: The recursive implementation of flatten_transforms(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of flatten_transforms(). + */ void EggPrimitive:: r_flatten_transforms() { if (is_local_coord()) { @@ -1061,11 +938,9 @@ r_flatten_transforms() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::r_apply_texmats -// Access: Protected, Virtual -// Description: The recursive implementation of apply_texmats(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of apply_texmats(). + */ void EggPrimitive:: r_apply_texmats(EggTextureCollection &textures) { Textures new_textures; @@ -1077,15 +952,14 @@ r_apply_texmats(EggTextureCollection &textures) { new_textures.push_back(texture); } else if (texture->transform_is_identity()) { - // Now, what's the point of a texture with an identity - // transform? + // Now, what's the point of a texture with an identity transform? texture->clear_transform(); new_textures.push_back(texture); } else { - // We've got a texture with a matrix applied. Save the matrix, - // and get a new texture without the matrix. + // We've got a texture with a matrix applied. Save the matrix, and get + // a new texture without the matrix. LMatrix4d mat = texture->get_transform3d(); EggTexture new_texture(*texture); new_texture.clear_transform(); @@ -1094,8 +968,8 @@ r_apply_texmats(EggTextureCollection &textures) { new_textures.push_back(unique); string uv_name = unique->get_uv_name(); - // Now apply the matrix to the vertex UV's. Create new vertices - // as necessary. + // Now apply the matrix to the vertex UV's. Create new vertices as + // necessary. size_t num_vertices = size(); for (size_t i = 0; i < num_vertices; i++) { EggVertex *vertex = get_vertex(i); @@ -1111,11 +985,11 @@ r_apply_texmats(EggTextureCollection &textures) { new_uv_obj->set_uv(LTexCoordd(uvw[0], uvw[1])); } new_vertex.set_uv_obj(new_uv_obj); - + EggVertexPool *pool = vertex->get_pool(); EggVertex *unique = pool->create_unique_vertex(new_vertex); unique->copy_grefs_from(*vertex); - + set_vertex(i, unique); } } @@ -1125,21 +999,18 @@ r_apply_texmats(EggTextureCollection &textures) { _textures.swap(new_textures); } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::apply_attribute_to_vertex -// Access: Protected -// Description: This is used to implement apply_first_attribute() and -// apply_last_attribute(). It copies the indicated -// attributes to the specified vertex. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement apply_first_attribute() and + * apply_last_attribute(). It copies the indicated attributes to the + * specified vertex. + */ void EggPrimitive:: do_apply_flat_attribute(int vertex_index, EggAttributes *attrib) { - // The significant_change flag is set if we have changed the - // vertex in some important way, that will invalidate it for other - // primitives that might share it. We don't consider *adding* a - // normal where there wasn't one before to be significant, but we - // do consider it significant to change a vertex's normal to - // something different. Similarly for color. + // The significant_change flag is set if we have changed the vertex in some + // important way, that will invalidate it for other primitives that might + // share it. We don't consider *adding* a normal where there wasn't one + // before to be significant, but we do consider it significant to change a + // vertex's normal to something different. Similarly for color. bool significant_change = false; EggVertex *orig_vertex = get_vertex(vertex_index); @@ -1147,15 +1018,15 @@ do_apply_flat_attribute(int vertex_index, EggAttributes *attrib) { if (attrib->has_normal()) { new_vertex->copy_normal(*attrib); - - if (orig_vertex->has_normal() && + + if (orig_vertex->has_normal() && !orig_vertex->matches_normal(*new_vertex)) { significant_change = true; } } else if (has_normal()) { new_vertex->copy_normal(*this); - - if (orig_vertex->has_normal() && + + if (orig_vertex->has_normal() && !orig_vertex->matches_normal(*new_vertex)) { significant_change = true; } @@ -1163,15 +1034,15 @@ do_apply_flat_attribute(int vertex_index, EggAttributes *attrib) { if (attrib->has_color()) { new_vertex->copy_color(*attrib); - - if (orig_vertex->has_color() && + + if (orig_vertex->has_color() && !orig_vertex->matches_color(*new_vertex)) { significant_change = true; } } else if (has_color()) { new_vertex->copy_color(*this); - - if (orig_vertex->has_color() && + + if (orig_vertex->has_color() && !orig_vertex->matches_color(*new_vertex)) { significant_change = true; } @@ -1187,21 +1058,19 @@ do_apply_flat_attribute(int vertex_index, EggAttributes *attrib) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::set_connected_shading -// Access: Private -// Description: Recursively updates the connected_shading member in -// all connected primitives. -//////////////////////////////////////////////////////////////////// +/** + * Recursively updates the connected_shading member in all connected + * primitives. + */ void EggPrimitive:: -set_connected_shading(EggPrimitive::Shading shading, +set_connected_shading(EggPrimitive::Shading shading, const EggAttributes *neighbor) { ConnectedShadingNodes connected_nodes; r_set_connected_shading(0, shading, neighbor, connected_nodes); - - // Pick up any additional nodes we couldn't visit because of the - // stack depth restrictions. + + // Pick up any additional nodes we couldn't visit because of the stack depth + // restrictions. while (!connected_nodes.empty()) { ConnectedShadingNodes next_nodes; next_nodes.swap(connected_nodes); @@ -1213,15 +1082,13 @@ set_connected_shading(EggPrimitive::Shading shading, } } -//////////////////////////////////////////////////////////////////// -// Function: EggPrimitive::r_set_connected_shading -// Access: Private -// Description: Implements set_connected_shading, with some -// restrictions to prevent stack overflow. -//////////////////////////////////////////////////////////////////// +/** + * Implements set_connected_shading, with some restrictions to prevent stack + * overflow. + */ void EggPrimitive:: -r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, - const EggAttributes *neighbor, +r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, + const EggAttributes *neighbor, ConnectedShadingNodes &next_nodes) { if (stack_depth > egg_recursion_limit) { // Too deep. Limit recursion. @@ -1241,15 +1108,14 @@ r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, } if (shading > _connected_shading) { - // More specific information just came in. Save it, and propagate - // it to all connected primitives. + // More specific information just came in. Save it, and propagate it to + // all connected primitives. _connected_shading = shading; propagate = true; } else if (shading == S_overall && _connected_shading == S_overall) { - // If both neighbors are overall shaded, check if the two - // neighbors have different properties. If they do, elevate to - // per_face. + // If both neighbors are overall shaded, check if the two neighbors have + // different properties. If they do, elevate to per_face. bool matches_normal = this->matches_normal(*neighbor); bool matches_color = this->matches_color(*neighbor); @@ -1267,7 +1133,7 @@ r_set_connected_shading(int stack_depth, EggPrimitive::Shading shading, if (!matches_normal || !matches_color) { _connected_shading = S_per_face; propagate = true; - } + } } if (propagate) { diff --git a/panda/src/egg/eggPrimitive.h b/panda/src/egg/eggPrimitive.h index 29c2a6bbff..f1e26c0478 100644 --- a/panda/src/egg/eggPrimitive.h +++ b/panda/src/egg/eggPrimitive.h @@ -1,16 +1,15 @@ -// Filename: eggPrimitive.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPrimitive.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGPRIMITIVE_H #define EGGPRIMITIVE_H @@ -35,26 +34,23 @@ class EggVertexPool; -//////////////////////////////////////////////////////////////////// -// Class : EggPrimitive -// Description : A base class for any of a number of kinds of geometry -// primitives: polygons, point lights, nurbs patches, -// parametrics curves, etc. Things with a set of -// vertices and some rendering properties like color. -// -// An EggPrimitive is an STL-style container of pointers -// to EggVertex's. In fact, it IS a vector, and can be -// manipulated in all the ways that vectors can. -// However, it is necessary that all vertices belong to -// the same vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * A base class for any of a number of kinds of geometry primitives: polygons, + * point lights, nurbs patches, parametrics curves, etc. Things with a set of + * vertices and some rendering properties like color. + * + * An EggPrimitive is an STL-style container of pointers to EggVertex's. In + * fact, it IS a vector, and can be manipulated in all the ways that vectors + * can. However, it is necessary that all vertices belong to the same vertex + * pool. + */ class EXPCL_PANDAEGG EggPrimitive : public EggNode, public EggAttributes, public EggRenderMode { - // This is a bit of private interface stuff that must be here as a - // forward reference. This allows us to define the EggPrimitive as - // an STL container. + // This is a bit of private interface stuff that must be here as a forward + // reference. This allows us to define the EggPrimitive as an STL + // container. private: typedef vector_PT_EggVertex Vertices; @@ -63,8 +59,8 @@ private: PUBLISHED: enum Shading { - // The order here is important. The later choices are more - // specific than the earlier ones. + // The order here is important. The later choices are more specific than + // the earlier ones. S_unknown, S_overall, S_per_face, @@ -129,10 +125,10 @@ PUBLISHED: virtual bool has_normals() const; - // The EggPrimitive itself appears to be an STL container of - // pointers to EggVertex objects. The set of vertices is read-only, - // however, except through the limited add_vertex/remove_vertex or - // insert/erase interface. The following implements this. + // The EggPrimitive itself appears to be an STL container of pointers to + // EggVertex objects. The set of vertices is read-only, however, except + // through the limited add_vertexremove_vertex or inserterase interface. + // The following implements this. public: #if defined(WIN32_VC) || defined(WIN64_VC) typedef PT_EggVertex *pointer; @@ -191,9 +187,9 @@ PUBLISHED: protected: Vertices _vertices; - // Don't try to use these private functions. User code should add - // and remove vertices via add_vertex()/remove_vertex(), or via the - // STL-like push_back()/pop_back() or insert()/erase(), above. + // Don't try to use these private functions. User code should add and + // remove vertices via add_vertex()remove_vertex(), or via the STL-like + // push_back()pop_back() or insert()erase(), above. virtual void prepare_add_vertex(EggVertex *vertex, int i, int n); virtual void prepare_remove_vertex(EggVertex *vertex, int i, int n); diff --git a/panda/src/egg/eggRenderMode.I b/panda/src/egg/eggRenderMode.I index 83eb7c17b5..10d40d01fb 100644 --- a/panda/src/egg/eggRenderMode.I +++ b/panda/src/egg/eggRenderMode.I @@ -1,144 +1,109 @@ -// Filename: eggRenderMode.I -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderMode.I + * @author drose + * @date 1999-01-20 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggRenderMode:: EggRenderMode(const EggRenderMode ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_depth_write_mode -// Access: Public -// Description: Specifies whether writes should be made to the depth -// buffer (assuming the rendering backend provides a -// depth buffer) when rendering this geometry. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether writes should be made to the depth buffer (assuming the + * rendering backend provides a depth buffer) when rendering this geometry. + */ INLINE void EggRenderMode:: set_depth_write_mode(DepthWriteMode mode) { _depth_write_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_depth_write_mode -// Access: Public -// Description: Returns the depth_write mode that was set, or -// DWM_unspecified if nothing was set. See -// set_depth_write_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth_write mode that was set, or DWM_unspecified if nothing + * was set. See set_depth_write_mode(). + */ INLINE EggRenderMode::DepthWriteMode EggRenderMode:: get_depth_write_mode() const { return _depth_write_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_depth_test_mode -// Access: Public -// Description: Specifies whether this geometry should be tested -// against the depth buffer when it is drawn (assuming -// the rendering backend provides a depth buffer). Note -// that this is different, and independent from, the -// depth_write mode. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether this geometry should be tested against the depth buffer + * when it is drawn (assuming the rendering backend provides a depth buffer). + * Note that this is different, and independent from, the depth_write mode. + */ INLINE void EggRenderMode:: set_depth_test_mode(DepthTestMode mode) { _depth_test_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_depth_test_mode -// Access: Public -// Description: Returns the depth_test mode that was set, or -// DTM_unspecified if nothing was set. See -// set_depth_test_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth_test mode that was set, or DTM_unspecified if nothing was + * set. See set_depth_test_mode(). + */ INLINE EggRenderMode::DepthTestMode EggRenderMode:: get_depth_test_mode() const { return _depth_test_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_visibility_mode -// Access: Public -// Description: Specifies whether this geometry is to be considered -// normally visible, or hidden. If it is hidden, it is -// either not loaded into the scene graph at all, or -// loaded as a "stashed" node, according to the setting -// of egg-suppress-hidden. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether this geometry is to be considered normally visible, or + * hidden. If it is hidden, it is either not loaded into the scene graph at + * all, or loaded as a "stashed" node, according to the setting of egg- + * suppress-hidden. + */ INLINE void EggRenderMode:: set_visibility_mode(VisibilityMode mode) { _visibility_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_visibility_mode -// Access: Public -// Description: Returns the visibility mode that was set, or -// VM_unspecified if nothing was set. See -// set_visibility_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the visibility mode that was set, or VM_unspecified if nothing was + * set. See set_visibility_mode(). + */ INLINE EggRenderMode::VisibilityMode EggRenderMode:: get_visibility_mode() const { return _visibility_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_alpha_mode -// Access: Public -// Description: Specifies precisely how the transparency for this -// geometry should be achieved, or if it should be used. -// The default, AM_unspecified, is to use transparency -// if the geometry has a color whose alpha value is -// non-1, or if it has a four-channel texture applied; -// otherwise, AM_on forces transparency on, and AM_off -// forces it off. The other flavors of transparency are -// specific ways to turn on transparency, which may or -// may not be supported by a particular rendering -// backend. -//////////////////////////////////////////////////////////////////// +/** + * Specifies precisely how the transparency for this geometry should be + * achieved, or if it should be used. The default, AM_unspecified, is to use + * transparency if the geometry has a color whose alpha value is non-1, or if + * it has a four-channel texture applied; otherwise, AM_on forces transparency + * on, and AM_off forces it off. The other flavors of transparency are + * specific ways to turn on transparency, which may or may not be supported by + * a particular rendering backend. + */ INLINE void EggRenderMode:: set_alpha_mode(AlphaMode mode) { _alpha_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_alpha_mode -// Access: Public -// Description: Returns the alpha mode that was set, or -// AM_unspecified if nothing was set. See -// set_alpha_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha mode that was set, or AM_unspecified if nothing was set. + * See set_alpha_mode(). + */ INLINE EggRenderMode::AlphaMode EggRenderMode:: get_alpha_mode() const { return _alpha_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_depth_offset -// Access: Public -// Description: Sets the "depth-offset" flag associated with this -// object. This adds or subtracts an offset bias -// into the depth buffer. See also DepthOffsetAttrib -// and NodePath::set_depth_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the "depth-offset" flag associated with this object. This adds or + * subtracts an offset bias into the depth buffer. See also DepthOffsetAttrib + * and NodePath::set_depth_offset(). + */ INLINE void EggRenderMode:: set_depth_offset(int order) { _depth_offset = order; @@ -146,143 +111,115 @@ set_depth_offset(int order) { } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_depth_offset -// Access: Public -// Description: Returns the "depth-offset" flag as set for this -// particular object. See set_depth_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "depth-offset" flag as set for this particular object. See + * set_depth_offset(). + */ INLINE int EggRenderMode:: get_depth_offset() const { return _depth_offset; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::has_depth_offset -// Access: Public -// Description: Returns true if the depth-offset flag has been set for -// this particular object. See set_depth_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the depth-offset flag has been set for this particular + * object. See set_depth_offset(). + */ INLINE bool EggRenderMode:: has_depth_offset() const { return _has_depth_offset; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::clear_depth_offset -// Access: Public -// Description: Removes the depth-offset flag from this particular -// object. See set_depth_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the depth-offset flag from this particular object. See + * set_depth_offset(). + */ INLINE void EggRenderMode:: clear_depth_offset() { _has_depth_offset = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_draw_order -// Access: Public -// Description: Sets the "draw-order" flag associated with this -// object. This specifies a particular order in which -// objects of this type should be drawn, within the -// specified bin. If a bin is not explicitly specified, -// "fixed" is used. See also set_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the "draw-order" flag associated with this object. This specifies a + * particular order in which objects of this type should be drawn, within the + * specified bin. If a bin is not explicitly specified, "fixed" is used. See + * also set_bin(). + */ INLINE void EggRenderMode:: set_draw_order(int order) { _draw_order = order; _has_draw_order = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_draw_order -// Access: Public -// Description: Returns the "draw-order" flag as set for this -// particular object. See set_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "draw-order" flag as set for this particular object. See + * set_draw_order(). + */ INLINE int EggRenderMode:: get_draw_order() const { return _draw_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::has_draw_order -// Access: Public -// Description: Returns true if the draw-order flag has been set for -// this particular object. See set_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the draw-order flag has been set for this particular + * object. See set_draw_order(). + */ INLINE bool EggRenderMode:: has_draw_order() const { return _has_draw_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::clear_draw_order -// Access: Public -// Description: Removes the draw-order flag from this particular -// object. See set_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the draw-order flag from this particular object. See + * set_draw_order(). + */ INLINE void EggRenderMode:: clear_draw_order() { _has_draw_order = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::set_bin -// Access: Public -// Description: Sets the "bin" string for this particular object. -// This names a particular bin in which the object -// should be rendered. The exact meaning of a bin is -// implementation defined, but generally a GeomBin -// matching each bin name must also be specifically -// added to the rendering engine (e.g. the -// CullTraverser) in use for this to work. See also -// set_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the "bin" string for this particular object. This names a particular + * bin in which the object should be rendered. The exact meaning of a bin is + * implementation defined, but generally a GeomBin matching each bin name must + * also be specifically added to the rendering engine (e.g. the + * CullTraverser) in use for this to work. See also set_draw_order(). + */ INLINE void EggRenderMode:: set_bin(const string &bin) { _bin = bin; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::get_bin -// Access: Public -// Description: Returns the bin name that has been set for this -// particular object, if any. See set_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bin name that has been set for this particular object, if any. + * See set_bin(). + */ INLINE string EggRenderMode:: get_bin() const { return _bin; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::has_bin -// Access: Public -// Description: Returns true if a bin name has been set for this -// particular object. See set_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a bin name has been set for this particular object. See + * set_bin(). + */ INLINE bool EggRenderMode:: has_bin() const { return !_bin.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::clear_bin -// Access: Public -// Description: Removes the bin name that was set for this particular -// object. See set_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the bin name that was set for this particular object. See + * set_bin(). + */ INLINE void EggRenderMode:: clear_bin() { _bin = string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggRenderMode:: operator != (const EggRenderMode &other) const { return !(*this == other); diff --git a/panda/src/egg/eggRenderMode.cxx b/panda/src/egg/eggRenderMode.cxx index 58b34d7cf4..0be5d41edf 100644 --- a/panda/src/egg/eggRenderMode.cxx +++ b/panda/src/egg/eggRenderMode.cxx @@ -1,16 +1,15 @@ -// Filename: eggRenderMode.cxx -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderMode.cxx + * @author drose + * @date 1999-01-20 + */ #include "eggRenderMode.h" #include "indent.h" @@ -19,11 +18,9 @@ TypeHandle EggRenderMode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggRenderMode:: EggRenderMode() { _alpha_mode = AM_unspecified; @@ -36,11 +33,9 @@ EggRenderMode() { _has_draw_order = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggRenderMode &EggRenderMode:: operator = (const EggRenderMode ©) { _alpha_mode = copy._alpha_mode; @@ -54,12 +49,9 @@ operator = (const EggRenderMode ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::write -// Access: Public -// Description: Writes the attributes to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the attributes to the indicated output stream in Egg format. + */ void EggRenderMode:: write(ostream &out, int indent_level) const { if (get_alpha_mode() != AM_unspecified) { @@ -92,11 +84,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Equality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggRenderMode:: operator == (const EggRenderMode &other) const { if (_alpha_mode != other._alpha_mode || @@ -127,11 +117,9 @@ operator == (const EggRenderMode &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggRenderMode:: operator < (const EggRenderMode &other) const { if (_alpha_mode != other._alpha_mode) { @@ -172,13 +160,11 @@ operator < (const EggRenderMode &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::string_alpha_mode -// Access: Public -// Description: Returns the AlphaMode value associated with the given -// string representation, or AM_unspecified if the string -// does not match any known AlphaMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AlphaMode value associated with the given string + * representation, or AM_unspecified if the string does not match any known + * AlphaMode value. + */ EggRenderMode::AlphaMode EggRenderMode:: string_alpha_mode(const string &string) { if (cmp_nocase_uh(string, "off") == 0) { @@ -202,14 +188,11 @@ string_alpha_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::string_depth_write_mode -// Access: Public -// Description: Returns the DepthWriteMode value associated with the -// given string representation, or DWM_unspecified if -// the string does not match any known DepthWriteMode -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DepthWriteMode value associated with the given string + * representation, or DWM_unspecified if the string does not match any known + * DepthWriteMode value. + */ EggRenderMode::DepthWriteMode EggRenderMode:: string_depth_write_mode(const string &string) { if (cmp_nocase_uh(string, "off") == 0) { @@ -221,14 +204,11 @@ string_depth_write_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::string_depth_test_mode -// Access: Public -// Description: Returns the DepthTestMode value associated with the -// given string representation, or DTM_unspecified if -// the string does not match any known DepthTestMode -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DepthTestMode value associated with the given string + * representation, or DTM_unspecified if the string does not match any known + * DepthTestMode value. + */ EggRenderMode::DepthTestMode EggRenderMode:: string_depth_test_mode(const string &string) { if (cmp_nocase_uh(string, "off") == 0) { @@ -240,14 +220,11 @@ string_depth_test_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderMode::string_visibility_mode -// Access: Public -// Description: Returns the HiddenMode value associated with the -// given string representation, or VM_unspecified if -// the string does not match any known HiddenMode -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HiddenMode value associated with the given string + * representation, or VM_unspecified if the string does not match any known + * HiddenMode value. + */ EggRenderMode::VisibilityMode EggRenderMode:: string_visibility_mode(const string &string) { if (cmp_nocase_uh(string, "hidden") == 0) { @@ -260,10 +237,9 @@ string_visibility_mode(const string &string) { } -//////////////////////////////////////////////////////////////////// -// Function: AlphaMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) { switch (mode) { case EggRenderMode::AM_unspecified: @@ -290,10 +266,9 @@ ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaMode input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode) { string word; in >> word; @@ -301,10 +276,9 @@ istream &operator >> (istream &in, EggRenderMode::AlphaMode &mode) { return in; } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode) { switch (mode) { case EggRenderMode::DWM_unspecified: @@ -319,10 +293,9 @@ ostream &operator << (ostream &out, EggRenderMode::DepthWriteMode mode) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode) { switch (mode) { case EggRenderMode::DTM_unspecified: @@ -339,10 +312,9 @@ ostream &operator << (ostream &out, EggRenderMode::DepthTestMode mode) { -//////////////////////////////////////////////////////////////////// -// Function: VisibilityMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode) { switch (mode) { case EggRenderMode::VM_unspecified: @@ -356,5 +328,3 @@ ostream &operator << (ostream &out, EggRenderMode::VisibilityMode mode) { nassertr(false, out); return out << "(**invalid**)"; } - - diff --git a/panda/src/egg/eggRenderMode.h b/panda/src/egg/eggRenderMode.h index 8508a5f067..b4664db736 100644 --- a/panda/src/egg/eggRenderMode.h +++ b/panda/src/egg/eggRenderMode.h @@ -1,16 +1,15 @@ -// Filename: eggRenderMode.h -// Created by: drose (20Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderMode.h + * @author drose + * @date 1999-01-20 + */ #ifndef EGGRENDERMODE_H #define EGGRENDERMODE_H @@ -19,20 +18,16 @@ #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : EggRenderMode -// Description : This class stores miscellaneous rendering properties -// that is associated with geometry, and which may be -// set on the geometry primitive level, on the group -// above it, or indirectly via a texture. It's intended -// to be a base class for egg objects that can have -// these properties set. -// -// This class cannot inherit from EggObject, because it -// causes problems at the EggPolygon level with multiple -// appearances of the EggObject base class. And making -// EggObject a virtual base class is just no fun. -//////////////////////////////////////////////////////////////////// +/** + * This class stores miscellaneous rendering properties that is associated + * with geometry, and which may be set on the geometry primitive level, on the + * group above it, or indirectly via a texture. It's intended to be a base + * class for egg objects that can have these properties set. + * + * This class cannot inherit from EggObject, because it causes problems at the + * EggPolygon level with multiple appearances of the EggObject base class. + * And making EggObject a virtual base class is just no fun. + */ class EXPCL_PANDAEGG EggRenderMode { PUBLISHED: EggRenderMode(); @@ -42,7 +37,7 @@ PUBLISHED: void write(ostream &out, int indent_level) const; enum AlphaMode { // Specifies implementation of transparency. - AM_unspecified, + AM_unspecified, AM_off, // No transparency. AM_on, // Use whatever the default model is. AM_blend, // Normal alpha blending, e.g. TransparencyAttrib::M_alpha. @@ -136,4 +131,3 @@ EXPCL_PANDAEGG ostream &operator << (ostream &out, EggRenderMode::VisibilityMode #include "eggRenderMode.I" #endif - diff --git a/panda/src/egg/eggSAnimData.I b/panda/src/egg/eggSAnimData.I index af83f5fc10..866fdd753a 100644 --- a/panda/src/egg/eggSAnimData.I +++ b/panda/src/egg/eggSAnimData.I @@ -1,43 +1,35 @@ -// Filename: eggSAnimData.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSAnimData.I + * @author drose + * @date 1999-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSAnimData:: EggSAnimData(const string &name) : EggAnimData(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSAnimData:: EggSAnimData(const EggSAnimData ©) : EggAnimData(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSAnimData &EggSAnimData:: operator = (const EggSAnimData ©) { EggAnimData::operator = (copy); @@ -46,24 +38,20 @@ operator = (const EggSAnimData ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::get_num_rows -// Access: Public -// Description: Returns the number of rows in the table. For an -// SAnim table, each row has one column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows in the table. For an SAnim table, each row has + * one column. + */ INLINE int EggSAnimData:: get_num_rows() const { return get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::get_value -// Access: Public -// Description: Returns the value at the indicated row. Row must be -// in the range 0 <= row < get_num_rows(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value at the indicated row. Row must be in the range 0 <= row + * < get_num_rows(). + */ INLINE double EggSAnimData:: get_value(int row) const { nassertr(row >= 0 && row < get_num_rows(), 0.0); @@ -71,16 +59,12 @@ get_value(int row) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::set_value -// Access: Public -// Description: Changes the value at the indicated row. Row must be -// in the range 0 <= row < get_num_rows(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the value at the indicated row. Row must be in the range 0 <= row + * < get_num_rows(). + */ INLINE void EggSAnimData:: set_value(int row, double value) { nassertv(row >= 0 && row < get_num_rows()); _data[row] = value; } - - diff --git a/panda/src/egg/eggSAnimData.cxx b/panda/src/egg/eggSAnimData.cxx index d02c903865..27d3a88ed6 100644 --- a/panda/src/egg/eggSAnimData.cxx +++ b/panda/src/egg/eggSAnimData.cxx @@ -1,16 +1,15 @@ -// Filename: eggSAnimData.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSAnimData.cxx + * @author drose + * @date 1999-02-19 + */ #include "eggSAnimData.h" #include "eggMiscFuncs.h" @@ -22,12 +21,10 @@ TypeHandle EggSAnimData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::optimize -// Access: Public -// Description: Optimizes the data by collapsing a long table of -// duplicate values into a single value. -//////////////////////////////////////////////////////////////////// +/** + * Optimizes the data by collapsing a long table of duplicate values into a + * single value. + */ void EggSAnimData:: optimize() { if (get_num_rows() > 1) { @@ -40,24 +37,22 @@ optimize() { // Ok, all the rows had the same value. Collapse them. - // We have to use the call to v() to work around an apparent compiler bug with Win64. + // We have to use the call to v() to work around an apparent compiler bug + // with Win64. _data.v().erase(_data.v().begin() + 1, _data.v().end()); } } -//////////////////////////////////////////////////////////////////// -// Function: EggSAnimData::write -// Access: Public, Virtual -// Description: Writes the data to the indicated output stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the data to the indicated output stream in Egg format. + */ void EggSAnimData:: write(ostream &out, int indent_level) const { if (get_num_rows() <= 1) { - // We get a lot of these little tiny tables. For brevity, we'll - // write these all on one line, because we can. This just makes - // it easier for a human to scan the egg file. + // We get a lot of these little tiny tables. For brevity, we'll write + // these all on one line, because we can. This just makes it easier for a + // human to scan the egg file. indent(out, indent_level) << " "; if (has_name()) { @@ -79,8 +74,8 @@ write(ostream &out, int indent_level) const { out << " }\n"; } else { - // If there are at least two values in the table, we'll write it - // out over multiple lines. + // If there are at least two values in the table, we'll write it out over + // multiple lines. write_header(out, indent_level, ""); diff --git a/panda/src/egg/eggSAnimData.h b/panda/src/egg/eggSAnimData.h index 939c89cda1..b09000f55d 100644 --- a/panda/src/egg/eggSAnimData.h +++ b/panda/src/egg/eggSAnimData.h @@ -1,16 +1,15 @@ -// Filename: eggSAnimData.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSAnimData.h + * @author drose + * @date 1999-02-19 + */ #ifndef EGGSANIMDATA_H #define EGGSANIMDATA_H @@ -19,12 +18,10 @@ #include "eggAnimData.h" -//////////////////////////////////////////////////////////////////// -// Class : EggSAnimData -// Description : Corresponding to an entry, this stores a -// single column of numbers, for instance for a morph -// target, or as one column in an EggXfmSAnim. -//////////////////////////////////////////////////////////////////// +/** + * Corresponding to an entry, this stores a single column of numbers, + * for instance for a morph target, or as one column in an EggXfmSAnim. + */ class EXPCL_PANDAEGG EggSAnimData : public EggAnimData { PUBLISHED: INLINE EggSAnimData(const string &name = ""); @@ -61,4 +58,3 @@ private: #include "eggSAnimData.I" #endif - diff --git a/panda/src/egg/eggSurface.I b/panda/src/egg/eggSurface.I index 704d2b43df..f7856d3ec7 100644 --- a/panda/src/egg/eggSurface.I +++ b/panda/src/egg/eggSurface.I @@ -1,34 +1,28 @@ -// Filename: eggSurface.I -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSurface.I + * @author drose + * @date 2000-02-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSurface:: EggSurface(const string &name) : EggPrimitive(name) { _u_subdiv = 0; _v_subdiv = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSurface:: EggSurface(const EggSurface ©) : EggPrimitive(copy), @@ -37,11 +31,9 @@ EggSurface(const EggSurface ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggSurface &EggSurface:: operator = (const EggSurface ©) { EggPrimitive::operator = (copy); @@ -51,55 +43,41 @@ operator = (const EggSurface ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::set_u_subdiv -// Access: Public -// Description: Sets the number of subdivisions in the U direction -// that will be requested across the surface. (This -// doesn't necessary guarantee that this number of -// subdivisions will be made; it's just a hint to any -// surface renderer or quick tesselator.) Set the -// number to 0 to disable the hint. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of subdivisions in the U direction that will be requested + * across the surface. (This doesn't necessary guarantee that this number of + * subdivisions will be made; it's just a hint to any surface renderer or + * quick tesselator.) Set the number to 0 to disable the hint. + */ INLINE void EggSurface:: set_u_subdiv(int subdiv) { _u_subdiv = subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::get_u_subdiv -// Access: Public -// Description: Returns the requested number of subdivisions in the U -// direction, or 0 if no particular subdivisions have -// been requested. -//////////////////////////////////////////////////////////////////// +/** + * Returns the requested number of subdivisions in the U direction, or 0 if no + * particular subdivisions have been requested. + */ INLINE int EggSurface:: get_u_subdiv() const { return _u_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::set_v_subdiv -// Access: Public -// Description: Sets the number of subdivisions in the U direction -// that will be requested across the surface. (This -// doesn't necessary guarantee that this number of -// subdivisions will be made; it's just a hint to any -// surface renderer or quick tesselator.) Set the -// number to 0 to disable the hint. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of subdivisions in the U direction that will be requested + * across the surface. (This doesn't necessary guarantee that this number of + * subdivisions will be made; it's just a hint to any surface renderer or + * quick tesselator.) Set the number to 0 to disable the hint. + */ INLINE void EggSurface:: set_v_subdiv(int subdiv) { _v_subdiv = subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: EggSurface::get_v_subdiv -// Access: Public -// Description: Returns the requested number of subdivisions in the U -// direction, or 0 if no particular subdivisions have -// been requested. -//////////////////////////////////////////////////////////////////// +/** + * Returns the requested number of subdivisions in the U direction, or 0 if no + * particular subdivisions have been requested. + */ INLINE int EggSurface:: get_v_subdiv() const { return _v_subdiv; diff --git a/panda/src/egg/eggSurface.cxx b/panda/src/egg/eggSurface.cxx index 37fb7a02df..309a0c1bfc 100644 --- a/panda/src/egg/eggSurface.cxx +++ b/panda/src/egg/eggSurface.cxx @@ -1,18 +1,16 @@ -// Filename: eggSurface.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSurface.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggSurface.h" TypeHandle EggSurface::_type_handle; - diff --git a/panda/src/egg/eggSurface.h b/panda/src/egg/eggSurface.h index 7b82a79ab6..eea88f18a8 100644 --- a/panda/src/egg/eggSurface.h +++ b/panda/src/egg/eggSurface.h @@ -1,16 +1,15 @@ -// Filename: eggSurface.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSurface.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGSURFACE_H #define EGGSURFACE_H @@ -19,11 +18,9 @@ #include "eggPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggSurface -// Description : A parametric surface of some kind. See -// EggNurbsSurface. -//////////////////////////////////////////////////////////////////// +/** + * A parametric surface of some kind. See EggNurbsSurface. + */ class EXPCL_PANDAEGG EggSurface : public EggPrimitive { PUBLISHED: INLINE EggSurface(const string &name = ""); diff --git a/panda/src/egg/eggSwitchCondition.cxx b/panda/src/egg/eggSwitchCondition.cxx index 50b3637d8d..d461c406f7 100644 --- a/panda/src/egg/eggSwitchCondition.cxx +++ b/panda/src/egg/eggSwitchCondition.cxx @@ -1,16 +1,15 @@ -// Filename: eggSwitchCondition.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSwitchCondition.cxx + * @author drose + * @date 1999-02-08 + */ #include "eggSwitchCondition.h" @@ -20,11 +19,9 @@ TypeHandle EggSwitchCondition::_type_handle; TypeHandle EggSwitchConditionDistance::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggSwitchConditionDistance::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggSwitchConditionDistance:: EggSwitchConditionDistance(double switch_in, double switch_out, const LPoint3d ¢er, double fade) { @@ -35,22 +32,18 @@ EggSwitchConditionDistance(double switch_in, double switch_out, } -//////////////////////////////////////////////////////////////////// -// Function: EggSwitchConditionDistance::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggSwitchCondition *EggSwitchConditionDistance:: make_copy() const { return new EggSwitchConditionDistance(*this); } -//////////////////////////////////////////////////////////////////// -// Function: EggSwitchConditionDistance::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggSwitchConditionDistance:: write(ostream &out, int indent_level) const { indent(out, indent_level) << " {\n"; @@ -66,12 +59,10 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggSwitchConditionDistance::transform -// Access: Public, Virtual -// Description: Applies the indicated transformation matrix to the -// switch condition parameters. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation matrix to the switch condition + * parameters. + */ void EggSwitchConditionDistance:: transform(const LMatrix4d &mat) { _center = _center * mat; diff --git a/panda/src/egg/eggSwitchCondition.h b/panda/src/egg/eggSwitchCondition.h index 5fcc2dc8de..aec6a5f545 100644 --- a/panda/src/egg/eggSwitchCondition.h +++ b/panda/src/egg/eggSwitchCondition.h @@ -1,16 +1,15 @@ -// Filename: eggSwitchCondition.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSwitchCondition.h + * @author drose + * @date 1999-02-08 + */ #ifndef EGGSWITCHCONDITION #define EGGSWITCHCONDITION @@ -20,16 +19,13 @@ #include "eggObject.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggSwitchCondition -// Description : This corresponds to a entry within -// a group. It indicates the condition at which a -// level-of-detail is switched in or out. This is -// actually an abstract base class for potentially any -// number of specific different kinds of switching -// conditions; presently, only a type is -// actually supported. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to a entry within a group. It indicates + * the condition at which a level-of-detail is switched in or out. This is + * actually an abstract base class for potentially any number of specific + * different kinds of switching conditions; presently, only a type + * is actually supported. + */ class EXPCL_PANDAEGG EggSwitchCondition : public EggObject { PUBLISHED: virtual EggSwitchCondition *make_copy() const=0; @@ -58,11 +54,10 @@ private: }; -//////////////////////////////////////////////////////////////////// -// Class : EggSwitchConditionDistance -// Description : A SwitchCondition that switches the levels-of-detail -// based on distance from the camera's eyepoint. -//////////////////////////////////////////////////////////////////// +/** + * A SwitchCondition that switches the levels-of-detail based on distance from + * the camera's eyepoint. + */ class EXPCL_PANDAEGG EggSwitchConditionDistance : public EggSwitchCondition { PUBLISHED: EggSwitchConditionDistance(double switch_in, double switch_out, @@ -96,4 +91,3 @@ private: #endif - diff --git a/panda/src/egg/eggTable.I b/panda/src/egg/eggTable.I index 1ba3e7f46f..33fe8b343a 100644 --- a/panda/src/egg/eggTable.I +++ b/panda/src/egg/eggTable.I @@ -1,44 +1,36 @@ -// Filename: eggTable.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTable.I + * @author drose + * @date 1999-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggTable::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTable:: EggTable(const string &name) : EggGroupNode(name) { _type = TT_table; } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTable:: EggTable(const EggTable ©) : EggGroupNode(copy), _type(copy._type) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTable &EggTable:: operator = (const EggTable ©) { EggGroupNode::operator = (copy); @@ -48,22 +40,18 @@ operator = (const EggTable ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::set_table_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTable:: set_table_type(TableType type) { _type = type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::get_table_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTable::TableType EggTable:: get_table_type() const { return _type; diff --git a/panda/src/egg/eggTable.cxx b/panda/src/egg/eggTable.cxx index fd97275161..b8372e41af 100644 --- a/panda/src/egg/eggTable.cxx +++ b/panda/src/egg/eggTable.cxx @@ -1,16 +1,15 @@ -// Filename: eggTable.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTable.cxx + * @author drose + * @date 1999-02-19 + */ #include "eggTable.h" @@ -19,12 +18,10 @@ TypeHandle EggTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggTable::has_transform -// Access: Public -// Description: Returns true if the table contains a transform -// description, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the table contains a transform description, false + * otherwise. + */ bool EggTable:: has_transform() const { const_iterator ci; @@ -35,16 +32,14 @@ has_transform() const { return true; } } - + return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::write -// Access: Public, Virtual -// Description: Writes the table and all of its children to the -// indicated output stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the table and all of its children to the indicated output stream in + * Egg format. + */ void EggTable:: write(ostream &out, int indent_level) const { test_under_integrity(); @@ -68,13 +63,11 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::string_table_type -// Access: Public, Static -// Description: Returns the TableType value associated with the given -// string representation, or TT_invalid if the string -// does not match any known TableType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TableType value associated with the given string + * representation, or TT_invalid if the string does not match any known + * TableType value. + */ EggTable::TableType EggTable:: string_table_type(const string &string) { if (cmp_nocase_uh(string, "table") == 0) { @@ -86,46 +79,40 @@ string_table_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTable::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggTable:: r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) { - // We need to duplicate the logic in EggGroup: if we have a matrix - // transform witin this table, apply the transformation to it, but - // then apply only the scale/rotational part of the transformation - // to any children. + // We need to duplicate the logic in EggGroup: if we have a matrix transform + // witin this table, apply the transformation to it, but then apply only the + // scalerotational part of the transformation to any children. - // On the other hand, if we have no matrix transform within this - // table, pass the transformation through. + // On the other hand, if we have no matrix transform within this table, pass + // the transformation through. - // This logic is complicated by the fact that matrix transforms with - // a
group are not stored within the table itself, but - // rather within a child named "xform". Fortunately, - // has_transform() abstracts out this detail for us. + // This logic is complicated by the fact that matrix transforms with a + //
group are not stored within the table itself, but rather within a + // child named "xform". Fortunately, has_transform() abstracts out this + // detail for us. if (has_transform()) { // At least one child of this table represents an animation matrix - // transform: that child gets the real matrix, while all other - // children get the truncated matrix. + // transform: that child gets the real matrix, while all other children + // get the truncated matrix. LMatrix4d mat1 = mat; LMatrix4d inv1 = inv; - // If we have a translation component, we should only apply - // it to the top matrix. All subsequent matrices get just the - // rotational component. + // If we have a translation component, we should only apply it to the top + // matrix. All subsequent matrices get just the rotational component. mat1.set_row(3, LVector3d(0.0, 0.0, 0.0)); inv1.set_row(3, LVector3d(0.0, 0.0, 0.0)); @@ -140,17 +127,16 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, } } else { - // No children of this table represent an animation matrix - // transform: all children get the real matrix. + // No children of this table represent an animation matrix transform: all + // children get the real matrix. EggGroupNode::r_transform(mat, inv, to_cs); } } -//////////////////////////////////////////////////////////////////// -// Function: TableType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTable::TableType t) { switch (t) { case EggTable::TT_invalid: diff --git a/panda/src/egg/eggTable.h b/panda/src/egg/eggTable.h index 8ab76d885a..848973d261 100644 --- a/panda/src/egg/eggTable.h +++ b/panda/src/egg/eggTable.h @@ -1,16 +1,15 @@ -// Filename: eggTable.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTable.h + * @author drose + * @date 1999-02-19 + */ #ifndef EGGTABLE_H #define EGGTABLE_H @@ -19,15 +18,12 @@ #include "eggGroupNode.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTable -// Description : This corresponds to a
or a entry. -// As such, it doesn't actually contain a table of -// numbers, but it may be a parent to an EggSAnimData or -// an EggXfmAnimData, which do. It may also be a parent -// to another
or , establishing a -// hierarchy of tables. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to a
or a entry. As such, it doesn't + * actually contain a table of numbers, but it may be a parent to an + * EggSAnimData or an EggXfmAnimData, which do. It may also be a parent to + * another
or , establishing a hierarchy of tables. + */ class EXPCL_PANDAEGG EggTable : public EggGroupNode { PUBLISHED: enum TableType { @@ -80,4 +76,3 @@ ostream &operator << (ostream &out, EggTable::TableType t); #include "eggTable.I" #endif - diff --git a/panda/src/egg/eggTexture.I b/panda/src/egg/eggTexture.I index a6b49f7bd2..6380934886 100644 --- a/panda/src/egg/eggTexture.I +++ b/panda/src/egg/eggTexture.I @@ -1,344 +1,275 @@ -// Filename: eggTexture.I -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTexture.I + * @author drose + * @date 1999-01-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_texture_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_texture_type(TextureType texture_type) { _texture_type = texture_type; - bool pattern_filename = + bool pattern_filename = (_texture_type == TT_3d_texture || _texture_type == TT_cube_map); _filename.set_pattern(pattern_filename); _fullpath.set_pattern(pattern_filename); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_texture_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::TextureType EggTexture:: get_texture_type() const { return _texture_type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_format -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_format(Format format) { _format = format; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_format -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::Format EggTexture:: get_format() const { return _format; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_compression_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_compression_mode(CompressionMode mode) { _compression_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_compression_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::CompressionMode EggTexture:: get_compression_mode() const { return _compression_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_wrap_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_wrap_mode(WrapMode mode) { _wrap_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_wrap_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::WrapMode EggTexture:: get_wrap_mode() const { return _wrap_mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_wrap_u -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_wrap_u(WrapMode mode) { _wrap_u = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_wrap_u -// Access: Published -// Description: Returns the amount specified for U wrap. This may be -// unspecified, even if there is an overall wrap value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount specified for U wrap. This may be unspecified, even if + * there is an overall wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: get_wrap_u() const { return _wrap_u; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::determine_wrap_u -// Access: Published -// Description: Determines the appropriate wrap in the U direction. -// This is different from get_wrap_u() in that if the U -// wrap is unspecified, it returns the overall wrap -// value. -//////////////////////////////////////////////////////////////////// +/** + * Determines the appropriate wrap in the U direction. This is different from + * get_wrap_u() in that if the U wrap is unspecified, it returns the overall + * wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: determine_wrap_u() const { return (_wrap_u == WM_unspecified) ? get_wrap_mode() : get_wrap_u(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_wrap_v -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_wrap_v(WrapMode mode) { _wrap_v = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_wrap_v -// Access: Published -// Description: Returns the amount specified for V wrap. This may be -// unspecified, even if there is an overall wrap value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount specified for V wrap. This may be unspecified, even if + * there is an overall wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: get_wrap_v() const { return _wrap_v; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::determine_wrap_v -// Access: Published -// Description: Determines the appropriate wrap in the V direction. -// This is different from get_wrap_v() in that if the V -// wrap is unspecified, it returns the overall wrap -// value. -//////////////////////////////////////////////////////////////////// +/** + * Determines the appropriate wrap in the V direction. This is different from + * get_wrap_v() in that if the V wrap is unspecified, it returns the overall + * wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: determine_wrap_v() const { return (_wrap_v == WM_unspecified) ? get_wrap_mode() : get_wrap_v(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_wrap_w -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_wrap_w(WrapMode mode) { _wrap_w = mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_wrap_w -// Access: Published -// Description: Returns the amount specified for W wrap. This may be -// unspecified, even if there is an overall wrap value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount specified for W wrap. This may be unspecified, even if + * there is an overall wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: get_wrap_w() const { return _wrap_w; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::determine_wrap_w -// Access: Published -// Description: Determines the appropriate wrap in the W direction. -// This is different from get_wrap_w() in that if the W -// wrap is unspecified, it returns the overall wrap -// value. -//////////////////////////////////////////////////////////////////// +/** + * Determines the appropriate wrap in the W direction. This is different from + * get_wrap_w() in that if the W wrap is unspecified, it returns the overall + * wrap value. + */ INLINE EggTexture::WrapMode EggTexture:: determine_wrap_w() const { return (_wrap_w == WM_unspecified) ? get_wrap_mode() : get_wrap_w(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_minfilter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_minfilter(FilterType type) { _minfilter = type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_minfilter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::FilterType EggTexture:: get_minfilter() const { return _minfilter; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_magfilter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_magfilter(FilterType type) { _magfilter = type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_magfilter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::FilterType EggTexture:: get_magfilter() const { return _magfilter; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_anisotropic_degree -// Access: Published -// Description: Sets the degree of anisotropic filtering for this -// texture. 1 is off; higher levels indicate filtering -// in effect. -//////////////////////////////////////////////////////////////////// +/** + * Sets the degree of anisotropic filtering for this texture. 1 is off; + * higher levels indicate filtering in effect. + */ INLINE void EggTexture:: set_anisotropic_degree(int anisotropic_degree) { _anisotropic_degree = anisotropic_degree; _flags |= F_has_anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_anisotropic_degree -// Access: Published -// Description: Removes the specification of anisotropic filtering -// from the texture. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of anisotropic filtering from the texture. + */ INLINE void EggTexture:: clear_anisotropic_degree() { _anisotropic_degree = 0; _flags &= ~F_has_anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_anisotropic_degree -// Access: Published -// Description: Returns true if a value for the anisotropic filtering -// degree has been specified for this texture, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value for the anisotropic filtering degree has been + * specified for this texture, false otherwise. + */ INLINE bool EggTexture:: has_anisotropic_degree() const { return (_flags & F_has_anisotropic_degree) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_anisotropic_degree -// Access: Published -// Description: Returns the anisotropic filtering degree that has -// been specified for this texture, or 0 if nothing has -// been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anisotropic filtering degree that has been specified for this + * texture, or 0 if nothing has been specified. + */ INLINE int EggTexture:: get_anisotropic_degree() const { - // note: _anisotropic_degree of 0 and 1 are equivalent (no - // anisotropic filtering to be done by gsg) + // note: _anisotropic_degree of 0 and 1 are equivalent (no anisotropic + // filtering to be done by gsg) return _anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_env_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_env_type(EnvType type) { _env_type = type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_env_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::EnvType EggTexture:: get_env_type() const { return _env_type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_combine_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_combine_mode(CombineChannel channel, CombineMode cm) { nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); _combiner[channel]._mode = cm; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_combine_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::CombineMode EggTexture:: get_combine_mode(CombineChannel channel) const { nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CM_unspecified); return _combiner[channel]._mode; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_combine_source -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_combine_source(CombineChannel channel, int n, CombineSource cs) { nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); @@ -346,11 +277,9 @@ set_combine_source(CombineChannel channel, int n, CombineSource cs) { _combiner[channel]._ops[n]._source = cs; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_combine_source -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::CombineSource EggTexture:: get_combine_source(CombineChannel channel, int n) const { nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CS_unspecified); @@ -358,11 +287,9 @@ get_combine_source(CombineChannel channel, int n) const { return _combiner[channel]._ops[n]._source; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_combine_operand -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_combine_operand(CombineChannel channel, int n, CombineOperand co) { nassertv((int)channel >= 0 && (int)channel < (int)CC_num_channels); @@ -370,11 +297,9 @@ set_combine_operand(CombineChannel channel, int n, CombineOperand co) { _combiner[channel]._ops[n]._operand = co; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_combine_operand -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::CombineOperand EggTexture:: get_combine_operand(CombineChannel channel, int n) const { nassertr((int)channel >= 0 && (int)channel < (int)CC_num_channels, CO_unspecified); @@ -382,284 +307,224 @@ get_combine_operand(CombineChannel channel, int n) const { return _combiner[channel]._ops[n]._operand; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_saved_result -// Access: Published -// Description: Sets the saved_result flag. When this is true, the -// output of this stage is not part of the normal -// pipeline--that is, it will not be supplied as the -// "previous" source for the next texture stage--but it -// will instead be supplied as the "last_saved_result" -// source for any future stages, until the next -// TextureStage with a saved_result set true is -// encountered. -// -// This can be used to reuse the results of this texture -// stage as input to more than one stage later in the -// pipeline. -// -// The last texture in the pipeline (the one with the -// highest sort value) should not have this flag set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the saved_result flag. When this is true, the output of this stage is + * not part of the normal pipeline--that is, it will not be supplied as the + * "previous" source for the next texture stage--but it will instead be + * supplied as the "last_saved_result" source for any future stages, until the + * next TextureStage with a saved_result set true is encountered. + * + * This can be used to reuse the results of this texture stage as input to + * more than one stage later in the pipeline. + * + * The last texture in the pipeline (the one with the highest sort value) + * should not have this flag set. + */ INLINE void EggTexture:: set_saved_result(bool saved_result) { _saved_result = saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_saved_result -// Access: Published -// Description: Returns the current setting of the saved_result flag. -// See set_saved_result(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the saved_result flag. See + * set_saved_result(). + */ INLINE bool EggTexture:: get_saved_result() const { return _saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_tex_gen -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_tex_gen(TexGen tex_gen) { _tex_gen = tex_gen; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_tex_gen -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::TexGen EggTexture:: get_tex_gen() const { return _tex_gen; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_quality_level -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_quality_level(QualityLevel quality_level) { _quality_level = quality_level; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_quality_level -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::QualityLevel EggTexture:: get_quality_level() const { return _quality_level; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_stage_name -// Access: Published -// Description: Specifies the particular TextureStage this texture -// will be rendered on by name. If this is omitted, the -// texture will be rendered on the default TextureStage, -// unless some other stage-specific property is -// specificied, in which case the texture will be -// rendered on a TextureStage with the same name as the -// tref. This is in support of multitexturing. -// -// Each different TextureStage in the world must be -// uniquely named. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular TextureStage this texture will be rendered on by + * name. If this is omitted, the texture will be rendered on the default + * TextureStage, unless some other stage-specific property is specificied, in + * which case the texture will be rendered on a TextureStage with the same + * name as the tref. This is in support of multitexturing. + * + * Each different TextureStage in the world must be uniquely named. + */ INLINE void EggTexture:: set_stage_name(const string &stage_name) { _stage_name = stage_name; _flags |= F_has_stage_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_stage_name -// Access: Published -// Description: Removes the named TextureStage specification. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named TextureStage specification. + */ INLINE void EggTexture:: clear_stage_name() { _stage_name = string(); _flags &= ~F_has_stage_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_stage_name -// Access: Published -// Description: Returns true if a stage name has been explicitly -// specified for this texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a stage name has been explicitly specified for this + * texture, false otherwise. + */ INLINE bool EggTexture:: has_stage_name() const { return (_flags & F_has_stage_name) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_stage_name -// Access: Published -// Description: Returns the stage name that has been specified for -// this texture, or the tref name if no texture stage -// has explicitly been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stage name that has been specified for this texture, or the + * tref name if no texture stage has explicitly been specified. + */ INLINE const string &EggTexture:: get_stage_name() const { return has_stage_name() ? _stage_name : get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_priority -// Access: Published -// Description: Sets the importance of this texture with respect to -// other textures also applied on the same geometry. -// This is only meaningful in the presence of -// multitexturing. -//////////////////////////////////////////////////////////////////// +/** + * Sets the importance of this texture with respect to other textures also + * applied on the same geometry. This is only meaningful in the presence of + * multitexturing. + */ INLINE void EggTexture:: set_priority(int priority) { _priority = priority; _flags |= F_has_priority; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_priority -// Access: Published -// Description: Removes the specification of multitexture priority -// from the texture. The default priority value is 0. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of multitexture priority from the texture. The + * default priority value is 0. + */ INLINE void EggTexture:: clear_priority() { _priority = 0; _flags &= ~F_has_priority; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_priority -// Access: Published -// Description: Returns true if a priority value for multitexture -// importance has been specified for the texture, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a priority value for multitexture importance has been + * specified for the texture, false otherwise. + */ INLINE bool EggTexture:: has_priority() const { return (_flags & F_has_priority) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_priority -// Access: Published -// Description: Returns the multitexture importance value that has been -// specified for the texture, or 0 if no priority value has -// been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the multitexture importance value that has been specified for the + * texture, or 0 if no priority value has been specified. + */ INLINE int EggTexture:: get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_color(const LColor &color) { _color = color; _flags |= F_has_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: clear_color() { _color.set(0.0f, 0.0f, 0.0f, 1.0f); _flags &= ~F_has_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_color -// Access: Published -// Description: Returns true if a blend color has been -// specified for the texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a blend color has been specified for the texture. + */ INLINE bool EggTexture:: has_color() const { return (_flags & F_has_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_color -// Access: Published -// Description: Returns the blend color if one has been -// specified, or (0, 0, 0, 1) otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blend color if one has been specified, or (0, 0, 0, 1) + * otherwise. + */ INLINE const LColor &EggTexture:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_border_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: set_border_color(const LColor &border_color) { _border_color = border_color; _flags |= F_has_border_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_border_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: clear_border_color() { _border_color.set(0.0f, 0.0f, 0.0f, 1.0f); _flags &= ~F_has_border_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_border_color -// Access: Published -// Description: Returns true if a border color has been -// specified for the texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a border color has been specified for the texture. + */ INLINE bool EggTexture:: has_border_color() const { return (_flags & F_has_border_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_border_color -// Access: Published -// Description: Returns the border color if one has been -// specified, or (0, 0, 0, 1) otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the border color if one has been specified, or (0, 0, 0, 1) + * otherwise. + */ INLINE const LColor &EggTexture:: get_border_color() const { return _border_color; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_uv_name -// Access: Published -// Description: Specifies the named set of texture coordinates that -// this texture will use when it is applied to geometry. -// Geometry may have multiple sets of texture -// coordinates defined, by name. -// -// If this is not specified for a particular texture, -// the default set of texture coordinates will be used. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the named set of texture coordinates that this texture will use + * when it is applied to geometry. Geometry may have multiple sets of texture + * coordinates defined, by name. + * + * If this is not specified for a particular texture, the default set of + * texture coordinates will be used. + */ INLINE void EggTexture:: set_uv_name(const string &uv_name) { if (uv_name == "default" || uv_name.empty()) { @@ -670,152 +535,121 @@ set_uv_name(const string &uv_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_uv_name -// Access: Published -// Description: Removes the restriction to a particular named set of -// texture coordinates and restores the texture to using -// the default texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Removes the restriction to a particular named set of texture coordinates + * and restores the texture to using the default texture coordinates. + */ INLINE void EggTexture:: clear_uv_name() { _uv_name = string(); _flags &= ~F_has_uv_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_uv_name -// Access: Published -// Description: Returns true if a texcoord name has been explicitly -// specified for this texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a texcoord name has been explicitly specified for this + * texture, false otherwise. + */ INLINE bool EggTexture:: has_uv_name() const { return (_flags & F_has_uv_name) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_uv_name -// Access: Published -// Description: Returns the texcoord name that has been specified for -// this texture, or the empty string if no texcoord name -// has explicitly been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texcoord name that has been specified for this texture, or the + * empty string if no texcoord name has explicitly been specified. + */ INLINE const string &EggTexture:: get_uv_name() const { return _uv_name; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_rgb_scale -// Access: Published -// Description: Sets an additional factor that will scale all three -// r, g, b components after the texture has been -// applied. This is used only when a combine mode is in -// effect. -// -// The only legal values are 1, 2, or 4. -//////////////////////////////////////////////////////////////////// +/** + * Sets an additional factor that will scale all three r, g, b components + * after the texture has been applied. This is used only when a combine mode + * is in effect. + * + * The only legal values are 1, 2, or 4. + */ INLINE void EggTexture:: set_rgb_scale(int rgb_scale) { _rgb_scale = rgb_scale; _flags |= F_has_rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_rgb_scale -// Access: Published -// Description: Removes the rgb_scale from the texture and restores -// it to the default value of 1. -//////////////////////////////////////////////////////////////////// +/** + * Removes the rgb_scale from the texture and restores it to the default value + * of 1. + */ INLINE void EggTexture:: clear_rgb_scale() { _rgb_scale = 1; _flags &= ~F_has_rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_rgb_scale -// Access: Published -// Description: Returns true if an rgb_scale has been specified for -// the texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an rgb_scale has been specified for the texture, false + * otherwise. + */ INLINE bool EggTexture:: has_rgb_scale() const { return (_flags & F_has_rgb_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_rgb_scale -// Access: Published -// Description: Returns the rgb_scale value that has been -// specified for the texture, or 1 if no rgb_scale value -// has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rgb_scale value that has been specified for the texture, or 1 + * if no rgb_scale value has been specified. + */ INLINE int EggTexture:: get_rgb_scale() const { return _rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_alpha_scale -// Access: Published -// Description: Sets an additional factor that will scale the -// alpha component after the texture has been applied. -// This is used only when a combine mode is in effect. -// -// The only legal values are 1, 2, or 4. -//////////////////////////////////////////////////////////////////// +/** + * Sets an additional factor that will scale the alpha component after the + * texture has been applied. This is used only when a combine mode is in + * effect. + * + * The only legal values are 1, 2, or 4. + */ INLINE void EggTexture:: set_alpha_scale(int alpha_scale) { _alpha_scale = alpha_scale; _flags |= F_has_alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_alpha_scale -// Access: Published -// Description: Removes the alpha_scale from the texture and restores -// it to the default value of 1. -//////////////////////////////////////////////////////////////////// +/** + * Removes the alpha_scale from the texture and restores it to the default + * value of 1. + */ INLINE void EggTexture:: clear_alpha_scale() { _alpha_scale = 1; _flags &= ~F_has_alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_alpha_scale -// Access: Published -// Description: Returns true if an alpha_scale has been specified for -// the texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an alpha_scale has been specified for the texture, false + * otherwise. + */ INLINE bool EggTexture:: has_alpha_scale() const { return (_flags & F_has_alpha_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_alpha_scale -// Access: Published -// Description: Returns the alpha_scale value that has been -// specified for the texture, or 1 if no alpha_scale -// value has been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha_scale value that has been specified for the texture, or 1 + * if no alpha_scale value has been specified. + */ INLINE int EggTexture:: get_alpha_scale() const { return _alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_alpha_filename -// Access: Published -// Description: Specifies a separate file that will be loaded in with -// the 1- or 3-component texture and applied as the -// alpha channel. This is useful when loading textures -// from file formats that do not support alpha, for -// instance jpg. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a separate file that will be loaded in with the 1- or 3-component + * texture and applied as the alpha channel. This is useful when loading + * textures from file formats that do not support alpha, for instance jpg. + */ INLINE void EggTexture:: set_alpha_filename(const Filename &alpha_filename) { _alpha_filename = alpha_filename; @@ -823,11 +657,9 @@ set_alpha_filename(const Filename &alpha_filename) { _flags |= F_has_alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_alpha_filename -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTexture:: clear_alpha_filename() { _alpha_filename = Filename(); @@ -835,384 +667,301 @@ clear_alpha_filename() { _flags &= ~F_has_alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_alpha_filename -// Access: Published -// Description: Returns true if a separate file for the alpha -// component has been applied, false otherwise. See -// set_alpha_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a separate file for the alpha component has been applied, + * false otherwise. See set_alpha_filename(). + */ INLINE bool EggTexture:: has_alpha_filename() const { return (_flags & F_has_alpha_filename) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_alpha_filename -// Access: Published -// Description: Returns the separate file assigned for the alpha -// channel. It is an error to call this unless -// has_alpha_filename() returns true. See set_alpha_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the separate file assigned for the alpha channel. It is an error + * to call this unless has_alpha_filename() returns true. See + * set_alpha_filename(). + */ INLINE const Filename &EggTexture:: get_alpha_filename() const { nassertr(has_alpha_filename(), _alpha_filename); return _alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_alpha_fullpath -// Access: Published -// Description: Returns the full pathname to the alpha file, if it is -// known; otherwise, returns the same thing as -// get_alpha_filename(). -// -// This function simply returns whatever was set by the -// last call to set_alpha_fullpath(). This string is -// not written to the egg file; its main purpose is to -// record the full path to the alpha filename if it is -// known, for egg structures that are generated -// in-memory and then immediately converted to a scene -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to the alpha file, if it is known; otherwise, + * returns the same thing as get_alpha_filename(). + * + * This function simply returns whatever was set by the last call to + * set_alpha_fullpath(). This string is not written to the egg file; its main + * purpose is to record the full path to the alpha filename if it is known, + * for egg structures that are generated in-memory and then immediately + * converted to a scene graph. + */ INLINE const Filename &EggTexture:: get_alpha_fullpath() const { return _alpha_fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_alpha_fullpath -// Access: Published -// Description: Records the full pathname to the file, for the -// benefit of get_alpha_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Records the full pathname to the file, for the benefit of + * get_alpha_fullpath(). + */ INLINE void EggTexture:: set_alpha_fullpath(const Filename &alpha_fullpath) { _alpha_fullpath = alpha_fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_alpha_file_channel -// Access: Published -// Description: If a separate alpha-file is specified, this indicates -// which channel number should be extracted from this -// file to derive the alpha channel for the final image. -// The default is 0, which means the grayscale -// combination of r, g, b. Otherwise, this should be -// the 1-based channel number, for instance 1, 2, or 3 -// for r, g, or b, respectively, or 4 for the alpha -// channel of a four-component image. -//////////////////////////////////////////////////////////////////// +/** + * If a separate alpha-file is specified, this indicates which channel number + * should be extracted from this file to derive the alpha channel for the + * final image. The default is 0, which means the grayscale combination of r, + * g, b. Otherwise, this should be the 1-based channel number, for instance + * 1, 2, or 3 for r, g, or b, respectively, or 4 for the alpha channel of a + * four-component image. + */ INLINE void EggTexture:: set_alpha_file_channel(int alpha_file_channel) { _alpha_file_channel = alpha_file_channel; _flags |= F_has_alpha_file_channel; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_alpha_file_channel -// Access: Published -// Description: Removes the specification of a particular channel to -// use from the alpha-file image. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of a particular channel to use from the alpha- + * file image. + */ INLINE void EggTexture:: clear_alpha_file_channel() { _alpha_file_channel = 0; _flags &= ~F_has_alpha_file_channel; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_alpha_file_channel -// Access: Published -// Description: Returns true if a particular channel has been -// specified for the alpha-file image, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a particular channel has been specified for the alpha-file + * image, false otherwise. + */ INLINE bool EggTexture:: has_alpha_file_channel() const { return (_flags & F_has_alpha_file_channel) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_alpha_file_channel -// Access: Published -// Description: Returns the particular channel that has been -// specified for the alpha-file image, or 0 if no -// channel has been specified. See -// set_alpha_file_channel(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular channel that has been specified for the alpha-file + * image, or 0 if no channel has been specified. See + * set_alpha_file_channel(). + */ INLINE int EggTexture:: get_alpha_file_channel() const { return _alpha_file_channel; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_multiview -// Access: Published -// Description: Sets the multiview flag. -// -// If multiview is true, the filename should contain a -// hash mark ('#'), which will be filled in with the -// view number; and a multiview texture will be defined -// with a series of images, one for each view. -// -// A multiview texture is most often used for stereo -// textures, but other uses are also possible, such as -// for texture animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the multiview flag. + * + * If multiview is true, the filename should contain a hash mark ('#'), which + * will be filled in with the view number; and a multiview texture will be + * defined with a series of images, one for each view. + * + * A multiview texture is most often used for stereo textures, but other uses + * are also possible, such as for texture animation. + */ INLINE void EggTexture:: set_multiview(bool multiview) { _multiview = multiview; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_multiview -// Access: Published -// Description: Returns the current setting of the multiview flag. -// See set_multiview(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the multiview flag. See set_multiview(). + */ INLINE bool EggTexture:: get_multiview() const { return _multiview; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_num_views -// Access: Published -// Description: When loading a 3-D multiview texture, this parameter -// is necessary to specify how many views will be -// expected. The z size is determined implicitly from -// the number of images loaded. -//////////////////////////////////////////////////////////////////// +/** + * When loading a 3-D multiview texture, this parameter is necessary to + * specify how many views will be expected. The z size is determined + * implicitly from the number of images loaded. + */ INLINE void EggTexture:: set_num_views(int num_views) { _num_views = num_views; _flags |= F_has_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_num_views -// Access: Published -// Description: Removes the specification of the number of views -// for a 3-D multiview texture. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of the number of views for a 3-D multiview + * texture. + */ INLINE void EggTexture:: clear_num_views() { _num_views = 0; _flags &= ~F_has_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_num_views -// Access: Published -// Description: Returns true if the number of views has been -// specified for the 3-D multiview texture, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the number of views has been specified for the 3-D + * multiview texture, false otherwise. + */ INLINE bool EggTexture:: has_num_views() const { return (_flags & F_has_num_views) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_num_views -// Access: Published -// Description: Returns the specified number of views specified for -// the 3-D multiview texture. See set_num_views(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified number of views specified for the 3-D multiview + * texture. See set_num_views(). + */ INLINE int EggTexture:: get_num_views() const { return _num_views; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_read_mipmaps -// Access: Published -// Description: Sets the read_mipmaps flag. -// -// If read_mipmaps is true, the filename should contain -// a hash mark ('#'), which will be filled in with the -// mipmap level number; and the texture will be defined -// with a series of images, one for each mipmap level. -// -// If the filename is of a type that already requires a -// hash mark, such as a cube map or a 3-d texture, then -// the filename should now require two hash marks, and -// the first one indicates the mipmap level number, -// while the second indicates the face number or 3-d -// level number. -//////////////////////////////////////////////////////////////////// +/** + * Sets the read_mipmaps flag. + * + * If read_mipmaps is true, the filename should contain a hash mark ('#'), + * which will be filled in with the mipmap level number; and the texture will + * be defined with a series of images, one for each mipmap level. + * + * If the filename is of a type that already requires a hash mark, such as a + * cube map or a 3-d texture, then the filename should now require two hash + * marks, and the first one indicates the mipmap level number, while the + * second indicates the face number or 3-d level number. + */ INLINE void EggTexture:: set_read_mipmaps(bool read_mipmaps) { _read_mipmaps = read_mipmaps; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_read_mipmaps -// Access: Published -// Description: Returns the current setting of the read_mipmaps flag. -// See set_read_mipmaps(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the read_mipmaps flag. See + * set_read_mipmaps(). + */ INLINE bool EggTexture:: get_read_mipmaps() const { return _read_mipmaps; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_min_lod -// Access: Published -// Description: Sets the minimum mipmap level that may be sampled. -//////////////////////////////////////////////////////////////////// +/** + * Sets the minimum mipmap level that may be sampled. + */ INLINE void EggTexture:: set_min_lod(double min_lod) { _min_lod = min_lod; _flags |= F_has_min_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_min_lod -// Access: Published -// Description: Removes the specification of a minimum mipmap level -// from the texture. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of a minimum mipmap level from the texture. + */ INLINE void EggTexture:: clear_min_lod() { _min_lod = -1000; _flags &= ~F_has_min_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_min_lod -// Access: Published -// Description: Returns true if a value for the minimum mipmap level -// has been specified for this texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value for the minimum mipmap level has been specified for + * this texture, false otherwise. + */ INLINE bool EggTexture:: has_min_lod() const { return (_flags & F_has_min_lod) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_min_lod -// Access: Published -// Description: Returns the minimum mipmap level that has been -// specified for this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum mipmap level that has been specified for this texture. + */ INLINE double EggTexture:: get_min_lod() const { return _min_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_max_lod -// Access: Published -// Description: Sets the maximum mipmap level that may be sampled. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum mipmap level that may be sampled. + */ INLINE void EggTexture:: set_max_lod(double max_lod) { _max_lod = max_lod; _flags |= F_has_max_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_max_lod -// Access: Published -// Description: Removes the specification of a maximum mipmap level -// from the texture. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of a maximum mipmap level from the texture. + */ INLINE void EggTexture:: clear_max_lod() { _max_lod = 1000; _flags &= ~F_has_max_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_max_lod -// Access: Published -// Description: Returns true if a value for the maximum mipmap level -// has been specified for this texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value for the maximum mipmap level has been specified for + * this texture, false otherwise. + */ INLINE bool EggTexture:: has_max_lod() const { return (_flags & F_has_max_lod) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_max_lod -// Access: Published -// Description: Returns the maximum mipmap level that has been -// specified for this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum mipmap level that has been specified for this texture. + */ INLINE double EggTexture:: get_max_lod() const { return _max_lod; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::set_lod_bias -// Access: Published -// Description: Sets the mipmap level bias that is added to the -// mipmap level to be sampled. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mipmap level bias that is added to the mipmap level to be sampled. + */ INLINE void EggTexture:: set_lod_bias(double lod_bias) { _lod_bias = lod_bias; _flags |= F_has_lod_bias; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_lod_bias -// Access: Published -// Description: Removes the specification of a maximum mipmap level -// from the texture. -//////////////////////////////////////////////////////////////////// +/** + * Removes the specification of a maximum mipmap level from the texture. + */ INLINE void EggTexture:: clear_lod_bias() { _lod_bias = 1000; _flags &= ~F_has_lod_bias; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_lod_bias -// Access: Published -// Description: Returns true if a value for the maximum mipmap level -// has been specified for this texture, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value for the maximum mipmap level has been specified for + * this texture, false otherwise. + */ INLINE bool EggTexture:: has_lod_bias() const { return (_flags & F_has_lod_bias) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_lod_bias -// Access: Published -// Description: Returns the maximum mipmap level that has been -// specified for this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum mipmap level that has been specified for this texture. + */ INLINE double EggTexture:: get_lod_bias() const { return _lod_bias; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::get_multitexture_sort -// Access: Published -// Description: Returns an integer that represents the depth to which -// this texture is layered on all other textures in the -// egg file. In general, if texture A is layered over -// texture B, then sort(A) > sort(B). If texture A is -// never layered over any other texture, then sort(A) == -// 0. More than that is difficult to guarantee. -//////////////////////////////////////////////////////////////////// +/** + * Returns an integer that represents the depth to which this texture is + * layered on all other textures in the egg file. In general, if texture A is + * layered over texture B, then sort(A) > sort(B). If texture A is never + * layered over any other texture, then sort(A) == 0. More than that is + * difficult to guarantee. + */ INLINE int EggTexture:: get_multitexture_sort() const { return _multitexture_sort; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::SourceAndOperand::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::SourceAndOperand:: SourceAndOperand() : _source(CS_unspecified), @@ -1220,33 +969,26 @@ SourceAndOperand() : { } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::Combiner::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTexture::Combiner:: Combiner() : _mode(CM_unspecified) { } -//////////////////////////////////////////////////////////////////// -// Function: UniqueEggTextures::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UniqueEggTextures:: UniqueEggTextures(int eq) : _eq(eq) { } -//////////////////////////////////////////////////////////////////// -// Function: UniqueEggTextures::Function operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool UniqueEggTextures:: operator ()(const EggTexture *t1, const EggTexture *t2) const { return t1->sorts_less_than(*t2, _eq); } - diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 6931ef657b..85327cb915 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -1,16 +1,15 @@ -// Filename: eggTexture.cxx -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTexture.cxx + * @author drose + * @date 1999-01-18 + */ #include "eggTexture.h" #include "eggMiscFuncs.h" @@ -22,11 +21,9 @@ TypeHandle EggTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTexture:: EggTexture(const string &tref_name, const Filename &filename) : EggFilenameNode(tref_name, filename) @@ -56,21 +53,17 @@ EggTexture(const string &tref_name, const Filename &filename) _multitexture_sort = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTexture:: EggTexture(const EggTexture ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTexture &EggTexture:: operator = (const EggTexture ©) { clear_multitexture(); @@ -114,22 +107,17 @@ operator = (const EggTexture ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTexture:: ~EggTexture() { clear_multitexture(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::write -// Access: Public, Virtual -// Description: Writes the texture definition to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the texture definition to the indicated output stream in Egg format. + */ void EggTexture:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -144,7 +132,7 @@ write(ostream &out, int indent_level) const { if (has_alpha_file_channel()) { indent(out, indent_level + 2) - << " alpha-file-channel { " + << " alpha-file-channel { " << get_alpha_file_channel() << " }\n"; } @@ -212,7 +200,7 @@ write(ostream &out, int indent_level) const { CombineChannel channel = (CombineChannel)ci; if (get_combine_mode(channel) != CM_unspecified) { indent(out, indent_level + 2) - << " combine-" << channel + << " combine-" << channel << " { " << get_combine_mode(channel) << " }\n"; } for (int i = 0; i < (int)CI_num_indices; i++) { @@ -310,50 +298,39 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::is_equivalent_to -// Access: Published -// Description: Returns true if the two textures are equivalent in -// all relevant properties (according to eq), false -// otherwise. -// -// The Equivalence parameter, eq, should be set to the -// bitwise OR of the following properties, according to -// what you consider relevant: -// -// EggTexture::E_basename: -// The basename part of the texture filename, without -// the directory prefix *or* the filename extension. -// -// EggTexture::E_extension: -// The extension part of the texture filename. -// -// EggTexture::E_dirname: -// The directory prefix of the texture filename. -// -// EggTexture::E_complete_filename: -// The union of the above three; that is, the complete -// filename, with directory, basename, and extension. -// -// EggTexture::E_transform: -// The texture matrix. -// -// EggTexture::E_attributes: -// All remaining texture attributes (mode, mipmap, -// etc.) except TRef name. -// -// EggTexture::E_tref_name: -// The TRef name. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two textures are equivalent in all relevant properties + * (according to eq), false otherwise. + * + * The Equivalence parameter, eq, should be set to the bitwise OR of the + * following properties, according to what you consider relevant: + * + * EggTexture::E_basename: The basename part of the texture filename, without + * the directory prefix *or* the filename extension. + * + * EggTexture::E_extension: The extension part of the texture filename. + * + * EggTexture::E_dirname: The directory prefix of the texture filename. + * + * EggTexture::E_complete_filename: The union of the above three; that is, the + * complete filename, with directory, basename, and extension. + * + * EggTexture::E_transform: The texture matrix. + * + * EggTexture::E_attributes: All remaining texture attributes (mode, mipmap, + * etc.) except TRef name. + * + * EggTexture::E_tref_name: The TRef name. + */ bool EggTexture:: is_equivalent_to(const EggTexture &other, int eq) const { if ((eq & E_complete_filename) == E_complete_filename) { - //cout << "compared by filename" << endl; + // cout << "compared by filename" << endl; if (get_filename() != other.get_filename()) { return false; } } else { - //cout << "compared by not complete filename" << endl; + // cout << "compared by not complete filename" << endl; const Filename &a = get_filename(); const Filename &b = other.get_filename(); @@ -375,7 +352,7 @@ is_equivalent_to(const EggTexture &other, int eq) const { } if (eq & E_transform) { - //cout << "compared by transform" << endl; + // cout << "compared by transform" << endl; if (transform_is_identity() != other.transform_is_identity()) { return false; } @@ -388,7 +365,7 @@ is_equivalent_to(const EggTexture &other, int eq) const { } if (eq & E_attributes) { - //cout << "compared by attributes" << endl; + // cout << "compared by attributes" << endl; if (_texture_type != other._texture_type || _format != other._format || _compression_mode != other._compression_mode || @@ -407,7 +384,7 @@ is_equivalent_to(const EggTexture &other, int eq) const { } if (eq & E_tref_name) { - //cout << "compared by tref_name" << endl; + // cout << "compared by tref_name" << endl; if (get_name() != other.get_name()) { return false; } @@ -416,15 +393,11 @@ is_equivalent_to(const EggTexture &other, int eq) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::sorts_less_than -// Access: Published -// Description: An ordering operator to compare two textures for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique textures, according to the -// indicated Equivalence factor. See -// is_equivalent_to(). -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two textures for sorting order. This + * imposes an arbitrary ordering useful to identify unique textures, according + * to the indicated Equivalence factor. See is_equivalent_to(). + */ bool EggTexture:: sorts_less_than(const EggTexture &other, int eq) const { if ((eq & E_complete_filename) == E_complete_filename) { @@ -515,15 +488,12 @@ sorts_less_than(const EggTexture &other, int eq) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::has_alpha_channel -// Access: Published -// Description: Given the number of color components (channels) in -// the image file as actually read from the disk, return -// true if this texture seems to have an alpha channel -// or not. This depends on the EggTexture's format as -// well as the number of channels. -//////////////////////////////////////////////////////////////////// +/** + * Given the number of color components (channels) in the image file as + * actually read from the disk, return true if this texture seems to have an + * alpha channel or not. This depends on the EggTexture's format as well as + * the number of channels. + */ bool EggTexture:: has_alpha_channel(int num_components) const { switch (_format) { @@ -536,8 +506,8 @@ has_alpha_channel(int num_components) const { case F_rgb8: case F_rgb5: case F_rgb332: - // These formats never use alpha, regardless of the number of - // components we have. + // These formats never use alpha, regardless of the number of components + // we have. return false; case F_alpha: @@ -560,13 +530,10 @@ has_alpha_channel(int num_components) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::affects_polygon_alpha -// Access: Published -// Description: Returns true if this texture's environment type or -// combine mode allows the texture to have an effect on -// the polygon's alpha values, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this texture's environment type or combine mode allows the + * texture to have an effect on the polygon's alpha values, false otherwise. + */ bool EggTexture:: affects_polygon_alpha() const { switch (_env_type) { @@ -612,62 +579,54 @@ affects_polygon_alpha() const { break; } - // A completely unspecified texture environment implies "modulate", - // which does affect alpha. + // A completely unspecified texture environment implies "modulate", which + // does affect alpha. return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::clear_multitexture -// Access: Published -// Description: Resets the multitexture flags set by -// multitexture_over(). After this call, -// get_multitexture() will return false, and -// get_multitexture_sort() will return 0. -//////////////////////////////////////////////////////////////////// +/** + * Resets the multitexture flags set by multitexture_over(). After this call, + * get_multitexture() will return false, and get_multitexture_sort() will + * return 0. + */ void EggTexture:: clear_multitexture() { _multitexture_sort = 0; - // Now empty out the _over_textures and _under_textures sets. This - // requires a bit of care so we don't end up in mutual recursion or - // iterating through self-modifying structures. To avoid this, we - // empty the sets first, and then walk through their original - // contents. + // Now empty out the _over_textures and _under_textures sets. This requires + // a bit of care so we don't end up in mutual recursion or iterating through + // self-modifying structures. To avoid this, we empty the sets first, and + // then walk through their original contents. MultiTextures orig_over_textures, orig_under_textures; orig_over_textures.swap(_over_textures); orig_under_textures.swap(_under_textures); MultiTextures::iterator mti; - for (mti = orig_over_textures.begin(); - mti != orig_over_textures.end(); + for (mti = orig_over_textures.begin(); + mti != orig_over_textures.end(); ++mti) { EggTexture *other = (*mti); other->_under_textures.erase(this); } - for (mti = orig_under_textures.begin(); - mti != orig_under_textures.end(); + for (mti = orig_under_textures.begin(); + mti != orig_under_textures.end(); ++mti) { EggTexture *other = (*mti); other->_over_textures.erase(this); } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::multitexture_over -// Access: Published -// Description: Indicates that this texture should be layered on top -// of the other texture. This will guarantee that -// this->get_multitexture_sort() > -// other->get_multitexture_sort(), at least until -// clear_multitexture() is called on either one. -// -// The return value is true if successful, or false if -// there is a failure because the other texture was -// already layered on top of this one (or there is a -// three- or more-way cycle). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this texture should be layered on top of the other texture. + * This will guarantee that this->get_multitexture_sort() > + * other->get_multitexture_sort(), at least until clear_multitexture() is + * called on either one. + * + * The return value is true if successful, or false if there is a failure + * because the other texture was already layered on top of this one (or there + * is a three- or more-way cycle). + */ bool EggTexture:: multitexture_over(EggTexture *other) { if (get_multitexture_sort() <= other->get_multitexture_sort()) { @@ -688,13 +647,11 @@ multitexture_over(EggTexture *other) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_texture_type -// Access: Published, Static -// Description: Returns the Texture_ype value associated with the given -// string representation, or TT_unspecified if the string -// does not match any known TextureType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Texture_ype value associated with the given string + * representation, or TT_unspecified if the string does not match any known + * TextureType value. + */ EggTexture::TextureType EggTexture:: string_texture_type(const string &string) { if (cmp_nocase_uh(string, "1d") == 0 || @@ -722,13 +679,10 @@ string_texture_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_format -// Access: Published, Static -// Description: Returns the Format value associated with the given -// string representation, or F_unspecified if the string -// does not match any known Format value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Format value associated with the given string representation, + * or F_unspecified if the string does not match any known Format value. + */ EggTexture::Format EggTexture:: string_format(const string &string) { if (cmp_nocase_uh(string, "rgba") == 0) { @@ -773,13 +727,11 @@ string_format(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_compression_mode -// Access: Published, Static -// Description: Returns the CompressionMode value associated with the given -// string representation, or CM_default if the string -// does not match any known CompressionMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CompressionMode value associated with the given string + * representation, or CM_default if the string does not match any known + * CompressionMode value. + */ EggTexture::CompressionMode EggTexture:: string_compression_mode(const string &string) { if (cmp_nocase_uh(string, "off") == 0) { @@ -803,13 +755,10 @@ string_compression_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_wrap_mode -// Access: Published, Static -// Description: Returns the WrapMode value associated with the given -// string representation, or WM_unspecified if the string -// does not match any known WrapMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WrapMode value associated with the given string representation, + * or WM_unspecified if the string does not match any known WrapMode value. + */ EggTexture::WrapMode EggTexture:: string_wrap_mode(const string &string) { if (cmp_nocase_uh(string, "repeat") == 0) { @@ -827,13 +776,11 @@ string_wrap_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_filter_type -// Access: Published, Static -// Description: Returns the FilterType value associated with the given -// string representation, or FT_unspecified if the string -// does not match any known FilterType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FilterType value associated with the given string + * representation, or FT_unspecified if the string does not match any known + * FilterType value. + */ EggTexture::FilterType EggTexture:: string_filter_type(const string &string) { // Old egg filter types. @@ -875,13 +822,10 @@ string_filter_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_env_type -// Access: Published, Static -// Description: Returns the EnvType value associated with the given -// string representation, or ET_unspecified if the string -// does not match any known EnvType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EnvType value associated with the given string representation, + * or ET_unspecified if the string does not match any known EnvType value. + */ EggTexture::EnvType EggTexture:: string_env_type(const string &string) { if (cmp_nocase_uh(string, "modulate") == 0) { @@ -934,13 +878,11 @@ string_env_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_combine_mode -// Access: Published, Static -// Description: Returns the CombineMode value associated with the given -// string representation, or CM_unspecified if the string -// does not match any known CombineMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CombineMode value associated with the given string + * representation, or CM_unspecified if the string does not match any known + * CombineMode value. + */ EggTexture::CombineMode EggTexture:: string_combine_mode(const string &string) { if (cmp_nocase_uh(string, "replace") == 0) { @@ -972,13 +914,11 @@ string_combine_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_combine_source -// Access: Published, Static -// Description: Returns the CombineSource value associated with the given -// string representation, or CS_unspecified if the string -// does not match any known CombineSource value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CombineSource value associated with the given string + * representation, or CS_unspecified if the string does not match any known + * CombineSource value. + */ EggTexture::CombineSource EggTexture:: string_combine_source(const string &string) { if (cmp_nocase_uh(string, "texture") == 0) { @@ -1004,13 +944,11 @@ string_combine_source(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_combine_operand -// Access: Published, Static -// Description: Returns the CombineOperand value associated with the given -// string representation, or CO_unspecified if the string -// does not match any known CombineOperand value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CombineOperand value associated with the given string + * representation, or CO_unspecified if the string does not match any known + * CombineOperand value. + */ EggTexture::CombineOperand EggTexture:: string_combine_operand(const string &string) { if (cmp_nocase_uh(string, "src_color") == 0) { @@ -1030,13 +968,10 @@ string_combine_operand(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_tex_gen -// Access: Published, Static -// Description: Returns the TexGen value associated with the given -// string representation, or ET_unspecified if the string -// does not match any known TexGen value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TexGen value associated with the given string representation, + * or ET_unspecified if the string does not match any known TexGen value. + */ EggTexture::TexGen EggTexture:: string_tex_gen(const string &string) { if (cmp_nocase_uh(string, "unspecified") == 0) { @@ -1073,13 +1008,10 @@ string_tex_gen(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::string_quality_level -// Access: Published, Static -// Description: Returns the TexGen value associated with the given -// string representation, or ET_unspecified if the string -// does not match any known TexGen value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TexGen value associated with the given string representation, + * or ET_unspecified if the string does not match any known TexGen value. + */ EggTexture::QualityLevel EggTexture:: string_quality_level(const string &string) { if (cmp_nocase_uh(string, "unspecified") == 0) { @@ -1102,39 +1034,30 @@ string_quality_level(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::as_transform -// Access: Public, Virtual -// Description: Returns this object cross-cast to an EggTransform -// pointer, if it inherits from EggTransform, or NULL if -// it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object cross-cast to an EggTransform pointer, if it inherits + * from EggTransform, or NULL if it does not. + */ EggTransform *EggTexture:: as_transform() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::egg_start_parse_body -// Access: Protected, Virtual -// Description: This function is called within parse_egg(). It -// should call the appropriate function on the lexer to -// initialize the parser into the state associated with -// this object. If the object cannot be parsed into -// directly, it should return false. -//////////////////////////////////////////////////////////////////// +/** + * This function is called within parse_egg(). It should call the appropriate + * function on the lexer to initialize the parser into the state associated + * with this object. If the object cannot be parsed into directly, it should + * return false. + */ bool EggTexture:: egg_start_parse_body() { egg_start_texture_body(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTexture::r_min_multitexture_sort -// Access: Private -// Description: Ensures that our multitexture_sort is at least the -// indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that our multitexture_sort is at least the indicated value. + */ bool EggTexture:: r_min_multitexture_sort(int sort, EggTexture::MultiTextures &cycle_detector) { if (_multitexture_sort >= sort) { @@ -1149,8 +1072,7 @@ r_min_multitexture_sort(int sort, EggTexture::MultiTextures &cycle_detector) { _multitexture_sort = sort; - // Now we also have to increment all of the textures that we are - // under. + // Now we also have to increment all of the textures that we are under. bool no_cycles = true; MultiTextures::iterator mti; @@ -1168,10 +1090,9 @@ r_min_multitexture_sort(int sort, EggTexture::MultiTextures &cycle_detector) { } -//////////////////////////////////////////////////////////////////// -// Function: TextureType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::TextureType texture_type) { switch (texture_type) { case EggTexture::TT_unspecified: @@ -1195,10 +1116,9 @@ ostream &operator << (ostream &out, EggTexture::TextureType texture_type) { } -//////////////////////////////////////////////////////////////////// -// Function: Format output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::Format format) { switch (format) { case EggTexture::F_unspecified: @@ -1248,10 +1168,9 @@ ostream &operator << (ostream &out, EggTexture::Format format) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: CompressionMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::CompressionMode mode) { switch (mode) { case EggTexture::CM_default: @@ -1278,10 +1197,9 @@ ostream &operator << (ostream &out, EggTexture::CompressionMode mode) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: WrapMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::WrapMode mode) { switch (mode) { case EggTexture::WM_unspecified: @@ -1302,10 +1220,9 @@ ostream &operator << (ostream &out, EggTexture::WrapMode mode) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: FilterType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::FilterType type) { switch (type) { case EggTexture::FT_unspecified: @@ -1330,10 +1247,9 @@ ostream &operator << (ostream &out, EggTexture::FilterType type) { return out << "(**invalid**)"; } -//////////////////////////////////////////////////////////////////// -// Function: EnvType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream &operator << (ostream &out, EggTexture::EnvType type) { switch (type) { case EggTexture::ET_unspecified: @@ -1371,13 +1287,13 @@ ostream &operator << (ostream &out, EggTexture::EnvType type) { case EggTexture::ET_glow: return out << "glow"; - + case EggTexture::ET_gloss: return out << "gloss"; - + case EggTexture::ET_height: return out << "height"; - + case EggTexture::ET_selector: return out << "selector"; @@ -1433,8 +1349,8 @@ operator << (ostream &out, EggTexture::CombineChannel cm) { return out << "alpha"; case EggTexture::CC_num_channels: - // This case is here just to prevent a compiler warning. Fall out - // of the switch and return the error message. + // This case is here just to prevent a compiler warning. Fall out of the + // switch and return the error message. break; } diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 1aa2a63513..66636b77bf 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -1,16 +1,15 @@ -// Filename: eggTexture.h -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTexture.h + * @author drose + * @date 1999-01-18 + */ #ifndef EGGTEXTURE_H #define EGGTEXTURE_H @@ -25,17 +24,15 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTexture -// Description : Defines a texture map that may be applied to -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Defines a texture map that may be applied to geometry. + */ class EXPCL_PANDAEGG EggTexture : public EggFilenameNode, public EggRenderMode, public EggTransform { PUBLISHED: EggTexture(const string &tref_name, const Filename &filename); EggTexture(const EggTexture ©); EggTexture &operator = (const EggTexture ©); - virtual ~EggTexture(); + virtual ~EggTexture(); virtual void write(ostream &out, int indent_level) const; @@ -74,10 +71,10 @@ PUBLISHED: WM_mirror, WM_mirror_once, WM_border_color }; enum FilterType { - // Note that these type values match up, name-for-name, with a - // similar enumerated type in Panda's Texture object. However, - // they do *not* match up numerically. You must convert between - // them using a switch statement. + // Note that these type values match up, name-for-name, with a similar + // enumerated type in Panda's Texture object. However, they do *not* + // match up numerically. You must convert between them using a switch + // statement. FT_unspecified, // Mag Filter and Min Filter @@ -91,8 +88,8 @@ PUBLISHED: FT_linear_mipmap_linear, // "mipmap trilinear" }; enum EnvType { - ET_unspecified, - ET_modulate, + ET_unspecified, + ET_modulate, ET_decal, ET_blend, ET_replace, @@ -432,9 +429,8 @@ private: Combiner _combiner[CC_num_channels]; - // This is the set of all of the textures that are multitextured on - // top of (and under) this one. This is filled in by - // multitexture_over(). + // This is the set of all of the textures that are multitextured on top of + // (and under) this one. This is filled in by multitexture_over(). MultiTextures _over_textures, _under_textures; public: @@ -457,13 +453,11 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : UniqueEggTextures -// Description : An STL function object for sorting textures into -// order by properties. Returns true if the two -// referenced EggTexture pointers are in sorted order, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object for sorting textures into order by properties. + * Returns true if the two referenced EggTexture pointers are in sorted order, + * false otherwise. + */ class EXPCL_PANDAEGG UniqueEggTextures { public: INLINE UniqueEggTextures(int eq = ~0); diff --git a/panda/src/egg/eggTextureCollection.I b/panda/src/egg/eggTextureCollection.I index f6526032ae..f31c0c728f 100644 --- a/panda/src/egg/eggTextureCollection.I +++ b/panda/src/egg/eggTextureCollection.I @@ -1,23 +1,19 @@ -// Filename: eggTextureCollection.I -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTextureCollection.I + * @author drose + * @date 2000-02-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTextureCollection::iterator EggTextureCollection:: begin() const { nassertr(_ordered_textures.size() == _textures.size(), @@ -25,41 +21,33 @@ begin() const { return _ordered_textures.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTextureCollection::iterator EggTextureCollection:: end() const { return _ordered_textures.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggTextureCollection:: empty() const { return _ordered_textures.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::operator [] -// Access: Published -// Description: Returns the nth EggTexture in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth EggTexture in the collection. + */ EggTexture *EggTextureCollection:: operator [] (size_type n) const { return get_texture(n); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::size -// Access: Published -// Description: Returns the number of EggTextures in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of EggTextures in the collection. + */ INLINE EggTextureCollection::size_type EggTextureCollection:: size() const { nassertr(_ordered_textures.size() == _textures.size(), 0); diff --git a/panda/src/egg/eggTextureCollection.cxx b/panda/src/egg/eggTextureCollection.cxx index 7ea46ccc39..f53c9d0ddc 100644 --- a/panda/src/egg/eggTextureCollection.cxx +++ b/panda/src/egg/eggTextureCollection.cxx @@ -1,16 +1,15 @@ -// Filename: eggTextureCollection.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTextureCollection.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggTextureCollection.h" #include "eggGroupNode.h" @@ -23,20 +22,16 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTextureCollection:: EggTextureCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTextureCollection:: EggTextureCollection(const EggTextureCollection ©) : _textures(copy._textures), @@ -44,11 +39,9 @@ EggTextureCollection(const EggTextureCollection ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTextureCollection &EggTextureCollection:: operator = (const EggTextureCollection ©) { _textures = copy._textures; @@ -56,34 +49,27 @@ operator = (const EggTextureCollection ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTextureCollection:: ~EggTextureCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::clear -// Access: Public -// Description: Removes all textures from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all textures from the collection. + */ void EggTextureCollection:: clear() { _textures.clear(); _ordered_textures.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::extract_textures -// Access: Public -// Description: Walks the egg hierarchy beginning at the indicated -// node, and removes any EggTextures encountered in the -// hierarchy, adding them to the collection. Returns -// the number of EggTextures encountered. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy beginning at the indicated node, and removes any + * EggTextures encountered in the hierarchy, adding them to the collection. + * Returns the number of EggTextures encountered. + */ int EggTextureCollection:: extract_textures(EggGroupNode *node) { // Since this traversal is destructive, we'll handle it within the @@ -92,32 +78,25 @@ extract_textures(EggGroupNode *node) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::is_empty -// Access: Published -// Description: Returns true if there are no EggTexures in the -// collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no EggTexures in the collection, false otherwise. + */ bool EggTextureCollection:: is_empty() const { return _ordered_textures.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::get_num_textures -// Access: Published -// Description: Returns the number of EggTextures in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of EggTextures in the collection. + */ int EggTextureCollection:: get_num_textures() const { return _ordered_textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::get_texture -// Access: Published -// Description: Returns the nth EggTexture in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth EggTexture in the collection. + */ EggTexture *EggTextureCollection:: get_texture(int index) const { nassertr(index >= 0 && index < (int)_ordered_textures.size(), NULL); @@ -125,27 +104,21 @@ get_texture(int index) const { return _ordered_textures[index]; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::insert_textures -// Access: Public -// Description: Adds a series of EggTexture nodes to the beginning of -// the indicated node to reflect each of the textures in -// the collection. Returns an iterator representing the -// first position after the newly inserted textures. -//////////////////////////////////////////////////////////////////// +/** + * Adds a series of EggTexture nodes to the beginning of the indicated node to + * reflect each of the textures in the collection. Returns an iterator + * representing the first position after the newly inserted textures. + */ EggGroupNode::iterator EggTextureCollection:: insert_textures(EggGroupNode *node) { return insert_textures(node, node->begin()); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::insert_textures -// Access: Public -// Description: Adds a series of EggTexture nodes to the beginning of -// the indicated node to reflect each of the textures in -// the collection. Returns an iterator representing the -// first position after the newly inserted textures. -//////////////////////////////////////////////////////////////////// +/** + * Adds a series of EggTexture nodes to the beginning of the indicated node to + * reflect each of the textures in the collection. Returns an iterator + * representing the first position after the newly inserted textures. + */ EggGroupNode::iterator EggTextureCollection:: insert_textures(EggGroupNode *node, EggGroupNode::iterator position) { OrderedTextures::iterator oti; @@ -159,39 +132,29 @@ insert_textures(EggGroupNode *node, EggGroupNode::iterator position) { return position; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::find_used_textures -// Access: Public -// Description: Walks the egg hierarchy beginning at the indicated -// node, looking for textures that are referenced by -// primitives but are not already members of the -// collection, adding them to the collection. -// -// If this is called following extract_textures(), it -// can be used to pick up any additional texture -// references that appeared in the egg hierarchy (but -// whose EggTexture node was not actually part of the -// hierarchy). -// -// If this is called in lieu of extract_textures(), it -// will fill up the collection with all of the -// referenced textures (and only the referenced -// textures), without destructively removing the -// EggTextures from the hierarchy. -// -// This also has the side effect of incrementing the -// internal usage count for a texture in the collection -// each time a texture reference is encountered. This -// side effect is taken advantage of by -// remove_unused_textures(). -// -// And one more side effect: this function identifies -// the presence of multitexturing in the egg file, and -// calls multitexture_over() on each texture -// appropriately so that, after this call, you may -// expect get_multitexture_sort() to return a reasonable -// value for each texture. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy beginning at the indicated node, looking for + * textures that are referenced by primitives but are not already members of + * the collection, adding them to the collection. + * + * If this is called following extract_textures(), it can be used to pick up + * any additional texture references that appeared in the egg hierarchy (but + * whose EggTexture node was not actually part of the hierarchy). + * + * If this is called in lieu of extract_textures(), it will fill up the + * collection with all of the referenced textures (and only the referenced + * textures), without destructively removing the EggTextures from the + * hierarchy. + * + * This also has the side effect of incrementing the internal usage count for + * a texture in the collection each time a texture reference is encountered. + * This side effect is taken advantage of by remove_unused_textures(). + * + * And one more side effect: this function identifies the presence of + * multitexturing in the egg file, and calls multitexture_over() on each + * texture appropriately so that, after this call, you may expect + * get_multitexture_sort() to return a reasonable value for each texture. + */ int EggTextureCollection:: find_used_textures(EggNode *node) { int num_found = 0; @@ -210,22 +173,22 @@ find_used_textures(EggNode *node) { _textures.insert(Textures::value_type(tex, 1)); _ordered_textures.push_back(tex); } else { - // Here's a texture we'd already known about. Increment its - // usage count. + // Here's a texture we'd already known about. Increment its usage + // count. (*ti).second++; } // Get the multitexture ordering right. for (int j = 0; j < i; j++) { - // The return value of this function will be false if there is - // some cycle in the texture layout order; e.g. A layers over - // B on one primitive, but B layers over A on another - // primitive. In that case the Egg Loader won't be able to - // assign a unique ordering between A and B, so it's probably - // an error worth reporting to the user--but we don't report - // it here, because this is a much lower-level function that - // gets called in other contexts too. That means it doesn't - // get reported at all, but too bad. +/* + * The return value of this function will be false if there is some cycle in + * the texture layout order; e.g. A layers over B on one primitive, but B + * layers over A on another primitive. In that case the Egg Loader won't be + * able to assign a unique ordering between A and B, so it's probably an error + * worth reporting to the user--but we don't report it here, because this is a + * much lower-level function that gets called in other contexts too. That + * means it doesn't get reported at all, but too bad. + */ tex->multitexture_over(primitive->get_texture(j)); } } @@ -244,66 +207,54 @@ find_used_textures(EggNode *node) { return num_found; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::remove_unused_textures -// Access: Public -// Description: Removes any textures from the collection that aren't -// referenced by any primitives in the indicated egg -// hierarchy. This also, incidentally, adds textures to -// the collection that had been referenced by primitives -// but had not previously appeared in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes any textures from the collection that aren't referenced by any + * primitives in the indicated egg hierarchy. This also, incidentally, adds + * textures to the collection that had been referenced by primitives but had + * not previously appeared in the collection. + */ void EggTextureCollection:: remove_unused_textures(EggNode *node) { - // We'll do this the easy way: First, we'll remove *all* the - // textures from the collection, and then we'll add back only those - // that appear in the hierarchy. + // We'll do this the easy way: First, we'll remove *all* the textures from + // the collection, and then we'll add back only those that appear in the + // hierarchy. clear(); find_used_textures(node); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::collapse_equivalent_textures -// Access: Public -// Description: Walks through the collection and collapses together -// any separate textures that are equivalent according -// to the indicated equivalence factor, eq (see -// EggTexture::is_equivalent_to()). The return value is -// the number of textures removed. -// -// This flavor of collapse_equivalent_textures() -// automatically adjusts all the primitives in the egg -// hierarchy to refer to the new texture pointers. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the collection and collapses together any separate textures + * that are equivalent according to the indicated equivalence factor, eq (see + * EggTexture::is_equivalent_to()). The return value is the number of + * textures removed. + * + * This flavor of collapse_equivalent_textures() automatically adjusts all the + * primitives in the egg hierarchy to refer to the new texture pointers. + */ int EggTextureCollection:: collapse_equivalent_textures(int eq, EggGroupNode *node) { TextureReplacement removed; int num_collapsed = collapse_equivalent_textures(eq, removed); - // And now walk the egg hierarchy and replace any references to a - // removed texture with its replacement. + // And now walk the egg hierarchy and replace any references to a removed + // texture with its replacement. replace_textures(node, removed); return num_collapsed; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::collapse_equivalent_textures -// Access: Public -// Description: Walks through the collection and collapses together -// any separate textures that are equivalent according -// to the indicated equivalence factor, eq (see -// EggTexture::is_equivalent_to()). The return value is -// the number of textures removed. -// -// This flavor of collapse_equivalent_textures() does -// not adjust any primitives in the egg hierarchy; -// instead, it fills up the 'removed' map with an entry -// for each removed texture, mapping it back to the -// equivalent retained texture. It's up to the user to -// then call replace_textures() with this map, if -// desired, to apply these changes to the egg hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the collection and collapses together any separate textures + * that are equivalent according to the indicated equivalence factor, eq (see + * EggTexture::is_equivalent_to()). The return value is the number of + * textures removed. + * + * This flavor of collapse_equivalent_textures() does not adjust any + * primitives in the egg hierarchy; instead, it fills up the 'removed' map + * with an entry for each removed texture, mapping it back to the equivalent + * retained texture. It's up to the user to then call replace_textures() with + * this map, if desired, to apply these changes to the egg hierarchy. + */ int EggTextureCollection:: collapse_equivalent_textures(int eq, EggTextureCollection::TextureReplacement &removed) { int num_collapsed = 0; @@ -312,8 +263,8 @@ collapse_equivalent_textures(int eq, EggTextureCollection::TextureReplacement &r UniqueEggTextures uet(eq); Collapser collapser(uet); - // First, put all of the textures into the Collapser structure, to - // find out the unique textures. + // First, put all of the textures into the Collapser structure, to find out + // the unique textures. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); oti != _ordered_textures.end(); @@ -339,16 +290,13 @@ collapse_equivalent_textures(int eq, EggTextureCollection::TextureReplacement &r return num_collapsed; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::replace_textures -// Access: Public, Static -// Description: Walks the egg hierarchy, changing out any reference -// to a texture appearing on the left side of the map -// with its corresponding texture on the right side. -// This is most often done following a call to -// collapse_equivalent_textures(). It does not directly -// affect the Collection. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg hierarchy, changing out any reference to a texture appearing + * on the left side of the map with its corresponding texture on the right + * side. This is most often done following a call to + * collapse_equivalent_textures(). It does not directly affect the + * Collection. + */ void EggTextureCollection:: replace_textures(EggGroupNode *node, const EggTextureCollection::TextureReplacement &replace) { @@ -361,7 +309,7 @@ replace_textures(EggGroupNode *node, EggPrimitive *primitive = DCAST(EggPrimitive, child); EggPrimitive::Textures new_textures; EggPrimitive::Textures::const_iterator ti; - for (ti = primitive->_textures.begin(); + for (ti = primitive->_textures.begin(); ti != primitive->_textures.end(); ++ti) { PT_EggTexture tex = (*ti); @@ -383,13 +331,10 @@ replace_textures(EggGroupNode *node, } } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::uniquify_trefs -// Access: Public -// Description: Guarantees that each texture in the collection has a -// unique TRef name. This is essential before writing -// an egg file. -//////////////////////////////////////////////////////////////////// +/** + * Guarantees that each texture in the collection has a unique TRef name. + * This is essential before writing an egg file. + */ void EggTextureCollection:: uniquify_trefs() { NameUniquifier nu(".tref", "tref"); @@ -404,40 +349,32 @@ uniquify_trefs() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::sort_by_tref -// Access: Public -// Description: Sorts all the textures into alphabetical order by -// TRef name. Subsequent operations using begin()/end() -// will traverse in this sorted order. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the textures into alphabetical order by TRef name. Subsequent + * operations using begin()/end() will traverse in this sorted order. + */ void EggTextureCollection:: sort_by_tref() { sort(_ordered_textures.begin(), _ordered_textures.end(), NamableOrderByName()); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::sort_by_basename -// Access: Public -// Description: Sorts all the textures into alphabetical order by -// the basename part (including extension) of the -// filename. Subsequent operations using begin()/end() -// will traverse in this sorted order. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the textures into alphabetical order by the basename part + * (including extension) of the filename. Subsequent operations using + * begin()/end() will traverse in this sorted order. + */ void EggTextureCollection:: sort_by_basename() { sort(_ordered_textures.begin(), _ordered_textures.end(), EggFilenameNode::IndirectOrderByBasename()); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::add_texture -// Access: Public -// Description: Explicitly adds a new texture to the collection. -// Returns true if the texture was added, false if it -// was already there or if there was some error. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly adds a new texture to the collection. Returns true if the + * texture was added, false if it was already there or if there was some + * error. + */ bool EggTextureCollection:: add_texture(EggTexture *texture) { nassertr(_textures.size() == _ordered_textures.size(), false); @@ -458,13 +395,10 @@ add_texture(EggTexture *texture) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::remove_texture -// Access: Public -// Description: Explicitly removes a texture from the collection. -// Returns true if the texture was removed, false if it -// wasn't there or if there was some error. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly removes a texture from the collection. Returns true if the + * texture was removed, false if it wasn't there or if there was some error. + */ bool EggTextureCollection:: remove_texture(EggTexture *texture) { nassertr(_textures.size() == _ordered_textures.size(), false); @@ -489,44 +423,38 @@ remove_texture(EggTexture *texture) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::create_unique_texture -// Access: Public -// Description: Creates a new texture if there is not already one -// equivalent (according to eq, see -// EggTexture::is_equivalent_to()) to the indicated -// texture, or returns the existing one if there is. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new texture if there is not already one equivalent (according to + * eq, see EggTexture::is_equivalent_to()) to the indicated texture, or + * returns the existing one if there is. + */ EggTexture *EggTextureCollection:: create_unique_texture(const EggTexture ©, int eq) { - // This requires a complete linear traversal, not terribly - // efficient. + // This requires a complete linear traversal, not terribly efficient. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); oti != _ordered_textures.end(); ++oti) { EggTexture *tex = (*oti); if (copy.is_equivalent_to(*tex, eq)) { - //cout << "tex:" << tex->get_name() << "---copy:" << copy.get_name() << endl; + // cout << "tex:" << tex->get_name() << "---copy:" << copy.get_name() << + // endl; return tex; } } - //cout << "adding a texture to collection: " << copy.get_name() << endl; + // cout << "adding a texture to collection: " << copy.get_name() << endl; EggTexture *new_texture = new EggTexture(copy); add_texture(new_texture); return new_texture; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::find_tref -// Access: Public -// Description: Returns the texture with the indicated TRef name, or -// NULL if no texture matches. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture with the indicated TRef name, or NULL if no texture + * matches. + */ EggTexture *EggTextureCollection:: find_tref(const string &tref_name) const { - // This requires a complete linear traversal, not terribly - // efficient. + // This requires a complete linear traversal, not terribly efficient. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); oti != _ordered_textures.end(); @@ -540,16 +468,13 @@ find_tref(const string &tref_name) const { return (EggTexture *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCollection::find_filename -// Access: Public -// Description: Returns the texture with the indicated filename, or -// NULL if no texture matches. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture with the indicated filename, or NULL if no texture + * matches. + */ EggTexture *EggTextureCollection:: find_filename(const Filename &filename) const { - // This requires a complete linear traversal, not terribly - // efficient. + // This requires a complete linear traversal, not terribly efficient. OrderedTextures::const_iterator oti; for (oti = _ordered_textures.begin(); oti != _ordered_textures.end(); diff --git a/panda/src/egg/eggTextureCollection.h b/panda/src/egg/eggTextureCollection.h index b097aead36..e5276eef5c 100644 --- a/panda/src/egg/eggTextureCollection.h +++ b/panda/src/egg/eggTextureCollection.h @@ -1,16 +1,15 @@ -// Filename: eggTextureCollection.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTextureCollection.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGTEXTURECOLLECTION_H #define EGGTEXTURECOLLECTION_H @@ -23,19 +22,16 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTextureCollection -// Description : This is a collection of textures by TRef name. It -// can extract the textures from an egg file and sort -// them all together; it can also manage the creation of -// unique textures and the assignment of unique TRef -// names. -//////////////////////////////////////////////////////////////////// +/** + * This is a collection of textures by TRef name. It can extract the textures + * from an egg file and sort them all together; it can also manage the + * creation of unique textures and the assignment of unique TRef names. + */ class EXPCL_PANDAEGG EggTextureCollection { - // This is a bit of private interface stuff that must be here as a - // forward reference. This allows us to define the - // EggTextureCollection as an STL container. + // This is a bit of private interface stuff that must be here as a forward + // reference. This allows us to define the EggTextureCollection as an STL + // container. private: typedef pmap Textures; @@ -83,8 +79,8 @@ PUBLISHED: void sort_by_basename(); public: - // Can be used to traverse all the textures in the collection, in - // order as last sorted. + // Can be used to traverse all the textures in the collection, in order as + // last sorted. INLINE iterator begin() const; INLINE iterator end() const; INLINE bool empty() const; @@ -96,10 +92,9 @@ PUBLISHED: bool add_texture(EggTexture *texture); bool remove_texture(EggTexture *texture); - // create_unique_texture() creates a new texture if there is not - // already one equivalent (according to eq, see - // EggTexture::is_equivalent_to()) to the indicated texture, or - // returns the existing one if there is. + // create_unique_texture() creates a new texture if there is not already one + // equivalent (according to eq, see EggTexture::is_equivalent_to()) to the + // indicated texture, or returns the existing one if there is. EggTexture *create_unique_texture(const EggTexture ©, int eq); // Find a texture with a particular TRef name. diff --git a/panda/src/egg/eggTransform.I b/panda/src/egg/eggTransform.I index 7b554ecfde..bff92d6194 100644 --- a/panda/src/egg/eggTransform.I +++ b/panda/src/egg/eggTransform.I @@ -1,22 +1,19 @@ -// Filename: eggTransform.I -// Created by: drose (21Jun02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTransform.I + * @author drose + * @date 2002-06-21 + */ -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Component::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTransform::Component:: Component(EggTransform::ComponentType type, double number) : _type(type), @@ -28,11 +25,9 @@ Component(EggTransform::ComponentType type, double number) : _mat4 = (LMatrix4d *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Component::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTransform::Component:: Component(const EggTransform::Component ©) : _type(copy._type), @@ -56,11 +51,9 @@ Component(const EggTransform::Component ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Component::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggTransform::Component:: operator = (const EggTransform::Component ©) { _type = copy._type; @@ -95,11 +88,9 @@ operator = (const EggTransform::Component ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Component::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTransform::Component:: ~Component() { if (_vec2 != (LVecBase2d *)NULL) { @@ -116,120 +107,93 @@ INLINE EggTransform::Component:: } } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::clear_transform -// Access: Public -// Description: Resets the transform to empty, identity. -//////////////////////////////////////////////////////////////////// +/** + * Resets the transform to empty, identity. + */ INLINE void EggTransform:: clear_transform() { internal_clear_transform(); transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_matrix3 -// Access: Public -// Description: Appends an arbitrary 3x3 matrix to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends an arbitrary 3x3 matrix to the current transform. + */ INLINE void EggTransform:: add_matrix3(const LMatrix3d &mat) { internal_add_matrix(mat); transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_matrix4 -// Access: Public -// Description: Appends an arbitrary 4x4 matrix to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends an arbitrary 4x4 matrix to the current transform. + */ INLINE void EggTransform:: add_matrix4(const LMatrix4d &mat) { internal_add_matrix(mat); transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::has_transform -// Access: Public -// Description: Returns true if the transform is nonempty, false if -// it is empty (no transform components have been -// added). This is true for either a 2-d or a 3-d -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform is nonempty, false if it is empty (no + * transform components have been added). This is true for either a 2-d or a + * 3-d transform. + */ INLINE bool EggTransform:: has_transform() const { return !_components.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::has_transform2d -// Access: Public -// Description: Returns true if the transform is specified as a 2-d -// transform, e.g. with a 3x3 matrix, or false if it is -// specified as a 3-d transform (with a 4x4 matrix), or -// not specified at all. -// -// Normally, EggTextures have a 2-d matrix (but -// occasionally they use a 3-d matrix), and EggGroups -// always have a 3-d matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform is specified as a 2-d transform, e.g. with a + * 3x3 matrix, or false if it is specified as a 3-d transform (with a 4x4 + * matrix), or not specified at all. + * + * Normally, EggTextures have a 2-d matrix (but occasionally they use a 3-d + * matrix), and EggGroups always have a 3-d matrix. + */ INLINE bool EggTransform:: has_transform2d() const { return has_transform() && _is_transform_2d; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::set_transform2d -// Access: Public -// Description: Sets the overall transform as a 3x3 matrix. This -// completely replaces whatever componentwise transform -// may have been defined. -//////////////////////////////////////////////////////////////////// +/** + * Sets the overall transform as a 3x3 matrix. This completely replaces + * whatever componentwise transform may have been defined. + */ INLINE void EggTransform:: set_transform2d(const LMatrix3d &mat) { internal_set_transform(mat); transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::has_transform3d -// Access: Public -// Description: Returns true if the transform is specified as a 3-d -// transform, e.g. with a 4x4 matrix, or false if it is -// specified as a 2-d transform (with a 2x2 matrix), or -// not specified at all. -// -// Normally, EggTextures have a 3-d matrix (but -// occasionally they use a 3-d matrix), and EggGroups -// always have a 3-d matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform is specified as a 3-d transform, e.g. with a + * 4x4 matrix, or false if it is specified as a 2-d transform (with a 2x2 + * matrix), or not specified at all. + * + * Normally, EggTextures have a 3-d matrix (but occasionally they use a 3-d + * matrix), and EggGroups always have a 3-d matrix. + */ INLINE bool EggTransform:: has_transform3d() const { return has_transform() && !_is_transform_2d; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::set_transform3d -// Access: Public -// Description: Sets the overall transform as a 4x4 matrix. This -// completely replaces whatever componentwise transform -// may have been defined. -//////////////////////////////////////////////////////////////////// +/** + * Sets the overall transform as a 4x4 matrix. This completely replaces + * whatever componentwise transform may have been defined. + */ INLINE void EggTransform:: set_transform3d(const LMatrix4d &mat) { internal_set_transform(mat); transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_transform2d -// Access: Public -// Description: Returns the overall transform as a 3x3 matrix. It is -// an error to call this if has_transform3d() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall transform as a 3x3 matrix. It is an error to call this + * if has_transform3d() is true. + */ INLINE LMatrix3d EggTransform:: get_transform2d() const { nassertr(!has_transform3d(), LMatrix3d::ident_mat()); @@ -239,77 +203,59 @@ get_transform2d() const { t(3, 0), t(3, 1), t(3, 3)); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_transform3d -// Access: Public -// Description: Returns the overall transform as a 4x4 matrix. It is -// valid to call this even if has_transform2d() is true; -// in this case, the 3x3 transform will be expanded to a -// 4x4 matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall transform as a 4x4 matrix. It is valid to call this + * even if has_transform2d() is true; in this case, the 3x3 transform will be + * expanded to a 4x4 matrix. + */ INLINE const LMatrix4d &EggTransform:: get_transform3d() const { return _transform; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::transform_is_identity -// Access: Public -// Description: Returns true if the described transform is identity, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the described transform is identity, false otherwise. + */ INLINE bool EggTransform:: transform_is_identity() const { return _components.empty() || _transform.almost_equal(LMatrix4d::ident_mat(), 0.0001); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_num_components -// Access: Public -// Description: Returns the number of components that make up the -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components that make up the transform. + */ INLINE int EggTransform:: get_num_components() const { return _components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_type -// Access: Public -// Description: Returns the type of the nth component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the nth component. + */ INLINE EggTransform::ComponentType EggTransform:: get_component_type(int n) const { nassertr(n >= 0 && n < (int)_components.size(), CT_invalid); return _components[n]._type; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_number -// Access: Public -// Description: Returns the solitary number associated with the nth -// component. In the case of a rotation, this is the -// angle in degrees to rotate; in the case of uniform -// scale, this is the amount of the scale. Other types -// do not use this property. -//////////////////////////////////////////////////////////////////// +/** + * Returns the solitary number associated with the nth component. In the case + * of a rotation, this is the angle in degrees to rotate; in the case of + * uniform scale, this is the amount of the scale. Other types do not use + * this property. + */ INLINE double EggTransform:: get_component_number(int n) const { nassertr(n >= 0 && n < (int)_components.size(), 0.0); return _components[n]._number; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_vec2 -// Access: Public -// Description: Returns the 2-component vector associated with the -// nth component. This may be the translate vector, -// rotate axis, or non-uniform scale. It is an error to -// call this if the component type does not use a 2-d -// vector property. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 2-component vector associated with the nth component. This may + * be the translate vector, rotate axis, or non-uniform scale. It is an error + * to call this if the component type does not use a 2-d vector property. + */ INLINE const LVecBase2d &EggTransform:: get_component_vec2(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector2d::zero()); @@ -317,15 +263,11 @@ get_component_vec2(int n) const { return *_components[n]._vec2; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_vec3 -// Access: Public -// Description: Returns the 3-component vector associated with the -// nth component. This may be the translate vector, -// rotate axis, or non-uniform scale. It is an error to -// call this if the component type does not use a 3-d -// vector property. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-component vector associated with the nth component. This may + * be the translate vector, rotate axis, or non-uniform scale. It is an error + * to call this if the component type does not use a 3-d vector property. + */ INLINE const LVecBase3d &EggTransform:: get_component_vec3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LVector3d::zero()); @@ -333,13 +275,10 @@ get_component_vec3(int n) const { return *_components[n]._vec3; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_mat3 -// Access: Public -// Description: Returns the 3x3 matrix associated with the nth -// component. It is an error to call this if the -// component type is not CT_matrix3. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3x3 matrix associated with the nth component. It is an error + * to call this if the component type is not CT_matrix3. + */ INLINE const LMatrix3d &EggTransform:: get_component_mat3(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix3d::ident_mat()); @@ -347,13 +286,10 @@ get_component_mat3(int n) const { return *_components[n]._mat3; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::get_component_mat4 -// Access: Public -// Description: Returns the 4x4 matrix associated with the nth -// component. It is an error to call this if the -// component type is not CT_matrix4. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 4x4 matrix associated with the nth component. It is an error + * to call this if the component type is not CT_matrix4. + */ INLINE const LMatrix4d &EggTransform:: get_component_mat4(int n) const { nassertr(n >= 0 && n < (int)_components.size(), LMatrix4d::ident_mat()); @@ -361,24 +297,18 @@ get_component_mat4(int n) const { return *_components[n]._mat4; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::internal_set_transform -// Access: Protected -// Description: Sets the overall transform without calling -// transform_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the overall transform without calling transform_changed(). + */ INLINE void EggTransform:: internal_set_transform(const LMatrix3d &mat) { internal_clear_transform(); internal_add_matrix(mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::internal_set_transform -// Access: Protected -// Description: Sets the overall transform without calling -// transform_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the overall transform without calling transform_changed(). + */ INLINE void EggTransform:: internal_set_transform(const LMatrix4d &mat) { internal_clear_transform(); diff --git a/panda/src/egg/eggTransform.cxx b/panda/src/egg/eggTransform.cxx index a373aad599..67ce77e1bc 100644 --- a/panda/src/egg/eggTransform.cxx +++ b/panda/src/egg/eggTransform.cxx @@ -1,25 +1,22 @@ -// Filename: eggTransform.cxx -// Created by: drose (21Jun02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTransform.cxx + * @author drose + * @date 2002-06-21 + */ #include "eggTransform.h" -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTransform:: EggTransform() : _is_transform_2d(true), @@ -27,11 +24,9 @@ EggTransform() : { } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTransform:: EggTransform(const EggTransform ©) : _is_transform_2d(copy._is_transform_2d), @@ -40,11 +35,9 @@ EggTransform(const EggTransform ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTransform &EggTransform:: operator = (const EggTransform ©) { _is_transform_2d = copy._is_transform_2d; @@ -53,21 +46,16 @@ operator = (const EggTransform ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTransform:: ~EggTransform() { } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_translate2d -// Access: Public -// Description: Appends a 2-d translation operation to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends a 2-d translation operation to the current transform. + */ void EggTransform:: add_translate2d(const LVector2d &translate) { _components.push_back(Component(CT_translate2d)); @@ -76,12 +64,9 @@ add_translate2d(const LVector2d &translate) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_translate3d -// Access: Public -// Description: Appends a 3-d translation operation to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends a 3-d translation operation to the current transform. + */ void EggTransform:: add_translate3d(const LVector3d &translate) { _is_transform_2d = false; @@ -91,13 +76,10 @@ add_translate3d(const LVector3d &translate) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_rotate2d -// Access: Public -// Description: Appends a 2-d rotation to the current transform. The -// rotation angle is specified in degrees -// counterclockwise about the origin. -//////////////////////////////////////////////////////////////////// +/** + * Appends a 2-d rotation to the current transform. The rotation angle is + * specified in degrees counterclockwise about the origin. + */ void EggTransform:: add_rotate2d(double angle) { _components.push_back(Component(CT_rotate2d, angle)); @@ -105,13 +87,10 @@ add_rotate2d(double angle) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_rotx -// Access: Public -// Description: Appends a rotation about the X axis to the current -// transform. The rotation angle is specified in -// degrees counterclockwise about the axis. -//////////////////////////////////////////////////////////////////// +/** + * Appends a rotation about the X axis to the current transform. The rotation + * angle is specified in degrees counterclockwise about the axis. + */ void EggTransform:: add_rotx(double angle) { _is_transform_2d = false; @@ -120,13 +99,10 @@ add_rotx(double angle) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_roty -// Access: Public -// Description: Appends a rotation about the Y axis to the current -// transform. The rotation angle is specified in -// degrees counterclockwise about the axis. -//////////////////////////////////////////////////////////////////// +/** + * Appends a rotation about the Y axis to the current transform. The rotation + * angle is specified in degrees counterclockwise about the axis. + */ void EggTransform:: add_roty(double angle) { _is_transform_2d = false; @@ -135,13 +111,10 @@ add_roty(double angle) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_rotz -// Access: Public -// Description: Appends a rotation about the Z axis to the current -// transform. The rotation angle is specified in -// degrees counterclockwise about the axis. -//////////////////////////////////////////////////////////////////// +/** + * Appends a rotation about the Z axis to the current transform. The rotation + * angle is specified in degrees counterclockwise about the axis. + */ void EggTransform:: add_rotz(double angle) { _is_transform_2d = false; @@ -150,13 +123,10 @@ add_rotz(double angle) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_rotate3d -// Access: Public -// Description: Appends a 3-d rotation about an arbitrary axis to the -// current transform. The rotation angle is specified -// in degrees counterclockwise about the axis. -//////////////////////////////////////////////////////////////////// +/** + * Appends a 3-d rotation about an arbitrary axis to the current transform. + * The rotation angle is specified in degrees counterclockwise about the axis. + */ void EggTransform:: add_rotate3d(double angle, const LVector3d &axis) { _is_transform_2d = false; @@ -167,13 +137,10 @@ add_rotate3d(double angle, const LVector3d &axis) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_rotate3d -// Access: Public -// Description: Appends an arbitrary 3-d rotation to the current -// transform, expressed as a quaternion. This is -// converted to axis-angle notation for the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Appends an arbitrary 3-d rotation to the current transform, expressed as a + * quaternion. This is converted to axis-angle notation for the egg file. + */ void EggTransform:: add_rotate3d(const LQuaterniond &quat) { _is_transform_2d = false; @@ -181,12 +148,9 @@ add_rotate3d(const LQuaterniond &quat) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_scale2d -// Access: Public -// Description: Appends a possibly non-uniform scale to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends a possibly non-uniform scale to the current transform. + */ void EggTransform:: add_scale2d(const LVecBase2d &scale) { _is_transform_2d = false; @@ -196,12 +160,9 @@ add_scale2d(const LVecBase2d &scale) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_scale3d -// Access: Public -// Description: Appends a possibly non-uniform scale to the current -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends a possibly non-uniform scale to the current transform. + */ void EggTransform:: add_scale3d(const LVecBase3d &scale) { _is_transform_2d = false; @@ -211,11 +172,9 @@ add_scale3d(const LVecBase3d &scale) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::add_uniform_scale -// Access: Public -// Description: Appends a uniform scale to the current transform. -//////////////////////////////////////////////////////////////////// +/** + * Appends a uniform scale to the current transform. + */ void EggTransform:: add_uniform_scale(double scale) { _components.push_back(Component(CT_uniform_scale, scale)); @@ -223,12 +182,9 @@ add_uniform_scale(double scale) { transform_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::write -// Access: Public -// Description: Writes the transform to the indicated stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the transform to the indicated stream in Egg format. + */ void EggTransform:: write(ostream &out, int indent_level, const string &label) const { indent(out, indent_level) << label << " {\n"; @@ -268,7 +224,7 @@ write(ostream &out, int indent_level, const string &label) const { case CT_rotate3d: indent(out, indent_level + 2) - << " { " << get_component_number(i) << " " + << " { " << get_component_number(i) << " " << get_component_vec3(i) << " }\n"; break; @@ -308,12 +264,9 @@ write(ostream &out, int indent_level, const string &label) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::internal_clear_transform -// Access: Public -// Description: Resets the transform to empty without calling -// transform_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the transform to empty without calling transform_changed(). + */ void EggTransform:: internal_clear_transform() { _is_transform_2d = true; @@ -321,12 +274,10 @@ internal_clear_transform() { _transform = LMatrix4d::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::internal_add_matrix -// Access: Public -// Description: Appends an arbitrary 4x4 matrix to the current -// transform, without calling transform_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Appends an arbitrary 4x4 matrix to the current transform, without calling + * transform_changed(). + */ void EggTransform:: internal_add_matrix(const LMatrix3d &mat) { _components.push_back(Component(CT_matrix3)); @@ -338,12 +289,10 @@ internal_add_matrix(const LMatrix3d &mat) { _transform *= mat4; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::internal_add_matrix -// Access: Public -// Description: Appends an arbitrary 4x4 matrix to the current -// transform, without calling transform_changed(). -//////////////////////////////////////////////////////////////////// +/** + * Appends an arbitrary 4x4 matrix to the current transform, without calling + * transform_changed(). + */ void EggTransform:: internal_add_matrix(const LMatrix4d &mat) { _is_transform_2d = false; @@ -352,15 +301,11 @@ internal_add_matrix(const LMatrix4d &mat) { _transform *= mat; } -//////////////////////////////////////////////////////////////////// -// Function: EggTransform::transform_changed -// Access: Protected, Virtual -// Description: This virtual method is called whenever the transform -// is changed; it is intended to provide a hook for -// derived classes (e.g. EggGroup) to update their -// internal cache appropriately. -//////////////////////////////////////////////////////////////////// +/** + * This virtual method is called whenever the transform is changed; it is + * intended to provide a hook for derived classes (e.g. EggGroup) to update + * their internal cache appropriately. + */ void EggTransform:: transform_changed() { } - diff --git a/panda/src/egg/eggTransform.h b/panda/src/egg/eggTransform.h index b055ab92ca..857617ff43 100644 --- a/panda/src/egg/eggTransform.h +++ b/panda/src/egg/eggTransform.h @@ -1,16 +1,15 @@ -// Filename: eggTransform.h -// Created by: drose (21Jun02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTransform.h + * @author drose + * @date 2002-06-21 + */ #ifndef EGGTRANSFORM_H #define EGGTRANSFORM_H @@ -19,17 +18,14 @@ #include "luse.h" #include "eggObject.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTransform -// Description : This represents the entry of a group -// or texture node: a list of component transform -// operations, applied in order, that describe a net -// transform matrix. -// -// This may be either a 3-d transform, and therefore -// described by a 4x4 matrix, or a 2-d transform, -// described by a 3x3 matrix. -//////////////////////////////////////////////////////////////////// +/** + * This represents the entry of a group or texture node: a list of + * component transform operations, applied in order, that describe a net + * transform matrix. + * + * This may be either a 3-d transform, and therefore described by a 4x4 + * matrix, or a 2-d transform, described by a 3x3 matrix. + */ class EXPCL_PANDAEGG EggTransform { PUBLISHED: EggTransform(); @@ -42,9 +38,9 @@ PUBLISHED: void add_translate2d(const LVector2d &translate); void add_translate3d(const LVector3d &translate); void add_rotate2d(double angle); - void add_rotx(double angle); - void add_roty(double angle); - void add_rotz(double angle); + void add_rotx(double angle); + void add_roty(double angle); + void add_rotz(double angle); void add_rotate3d(double angle, const LVector3d &axis); void add_rotate3d(const LQuaterniond &quat); void add_scale2d(const LVecBase2d &scale); diff --git a/panda/src/egg/eggTriangleFan.I b/panda/src/egg/eggTriangleFan.I index 38680ed7dd..367b956e9e 100644 --- a/panda/src/egg/eggTriangleFan.I +++ b/panda/src/egg/eggTriangleFan.I @@ -1,41 +1,33 @@ -// Filename: eggTriangleFan.I -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleFan.I + * @author drose + * @date 2005-03-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleFan:: EggTriangleFan(const string &name) : EggCompositePrimitive(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleFan:: EggTriangleFan(const EggTriangleFan ©) : EggCompositePrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleFan &EggTriangleFan:: operator = (const EggTriangleFan ©) { EggCompositePrimitive::operator = (copy); diff --git a/panda/src/egg/eggTriangleFan.cxx b/panda/src/egg/eggTriangleFan.cxx index 782353a262..d71ad75fed 100644 --- a/panda/src/egg/eggTriangleFan.cxx +++ b/panda/src/egg/eggTriangleFan.cxx @@ -1,16 +1,15 @@ -// Filename: eggTriangleFan.cxx -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleFan.cxx + * @author drose + * @date 2005-03-23 + */ #include "eggTriangleFan.h" #include "eggGroupNode.h" @@ -20,22 +19,17 @@ TypeHandle EggTriangleFan::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTriangleFan:: ~EggTriangleFan() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::write -// Access: Published, Virtual -// Description: Writes the triangle fan to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the triangle fan to the indicated output stream in Egg format. + */ void EggTriangleFan:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -43,58 +37,45 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::apply_first_attribute -// Access: Published, Virtual -// Description: Sets the first vertex of the triangle (or each -// component) to the primitive normal and/or color, if -// the primitive is flat-shaded. This reflects the -// DirectX convention of storing flat-shaded properties -// on the first vertex, although it is not usually a -// convention in Egg. -// -// This may introduce redundant vertices to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Sets the first vertex of the triangle (or each component) to the primitive + * normal and/or color, if the primitive is flat-shaded. This reflects the + * DirectX convention of storing flat-shaded properties on the first vertex, + * although it is not usually a convention in Egg. + * + * This may introduce redundant vertices to the vertex pool. + */ void EggTriangleFan:: apply_first_attribute() { - // In the case of a triangle fan, the first vertex of the fan is the - // common vertex, so we consider the second vertex to be the key - // vertex of the first triangle, and move from there. + // In the case of a triangle fan, the first vertex of the fan is the common + // vertex, so we consider the second vertex to be the key vertex of the + // first triangle, and move from there. for (int i = 0; i < get_num_components(); i++) { EggAttributes *component = get_component(i); do_apply_flat_attribute(i + 1, component); } } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::get_num_lead_vertices -// Access: Protected, Virtual -// Description: Returns the number of initial vertices that are not -// used in defining any component; the first component -// is defined by the (n + 1)th vertex, and then a new -// component at each vertex thereafter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of initial vertices that are not used in defining any + * component; the first component is defined by the (n + 1)th vertex, and then + * a new component at each vertex thereafter. + */ int EggTriangleFan:: get_num_lead_vertices() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleFan::triangulate_poly -// Access: Protected, Virtual -// Description: Fills the container up with EggPolygons that -// represent the component triangles of this triangle -// fan. -// -// It is assumed that the EggTriangleFan is not -// already a child of any other group when this function -// is called. -// -// Returns true if the triangulation is successful, or -// false if there was some error (in which case the -// container may contain some partial triangulation). -//////////////////////////////////////////////////////////////////// +/** + * Fills the container up with EggPolygons that represent the component + * triangles of this triangle fan. + * + * It is assumed that the EggTriangleFan is not already a child of any other + * group when this function is called. + * + * Returns true if the triangulation is successful, or false if there was some + * error (in which case the container may contain some partial triangulation). + */ bool EggTriangleFan:: do_triangulate(EggGroupNode *container) const { if (size() < 3) { diff --git a/panda/src/egg/eggTriangleFan.h b/panda/src/egg/eggTriangleFan.h index f83b93398e..1cf6e1edf9 100644 --- a/panda/src/egg/eggTriangleFan.h +++ b/panda/src/egg/eggTriangleFan.h @@ -1,16 +1,15 @@ -// Filename: eggTriangleFan.h -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleFan.h + * @author drose + * @date 2005-03-23 + */ #ifndef EGGTRIANGLEFAN_H #define EGGTRIANGLEFAN_H @@ -19,12 +18,10 @@ #include "eggCompositePrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTriangleFan -// Description : A connected fan of triangles. This does not -// normally appear in an egg file; it is typically -// generated as a result of meshing. -//////////////////////////////////////////////////////////////////// +/** + * A connected fan of triangles. This does not normally appear in an egg + * file; it is typically generated as a result of meshing. + */ class EXPCL_PANDAEGG EggTriangleFan : public EggCompositePrimitive { PUBLISHED: INLINE EggTriangleFan(const string &name = ""); diff --git a/panda/src/egg/eggTriangleStrip.I b/panda/src/egg/eggTriangleStrip.I index 559233921d..4fcb25b907 100644 --- a/panda/src/egg/eggTriangleStrip.I +++ b/panda/src/egg/eggTriangleStrip.I @@ -1,41 +1,33 @@ -// Filename: eggTriangleStrip.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleStrip.I + * @author drose + * @date 2005-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleStrip:: EggTriangleStrip(const string &name) : EggCompositePrimitive(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleStrip:: EggTriangleStrip(const EggTriangleStrip ©) : EggCompositePrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggTriangleStrip &EggTriangleStrip:: operator = (const EggTriangleStrip ©) { EggCompositePrimitive::operator = (copy); diff --git a/panda/src/egg/eggTriangleStrip.cxx b/panda/src/egg/eggTriangleStrip.cxx index fb711e5866..41bd5c4668 100644 --- a/panda/src/egg/eggTriangleStrip.cxx +++ b/panda/src/egg/eggTriangleStrip.cxx @@ -1,16 +1,15 @@ -// Filename: eggTriangleStrip.cxx -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleStrip.cxx + * @author drose + * @date 2005-03-13 + */ #include "eggTriangleStrip.h" #include "eggGroupNode.h" @@ -20,22 +19,17 @@ TypeHandle EggTriangleStrip::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTriangleStrip:: ~EggTriangleStrip() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::write -// Access: Published, Virtual -// Description: Writes the triangle strip to the indicated output -// stream in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the triangle strip to the indicated output stream in Egg format. + */ void EggTriangleStrip:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -43,34 +37,26 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::get_num_lead_vertices -// Access: Protected, Virtual -// Description: Returns the number of initial vertices that are not -// used in defining any component; the first component -// is defined by the (n + 1)th vertex, and then a new -// component at each vertex thereafter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of initial vertices that are not used in defining any + * component; the first component is defined by the (n + 1)th vertex, and then + * a new component at each vertex thereafter. + */ int EggTriangleStrip:: get_num_lead_vertices() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: EggTriangleStrip::triangulate_poly -// Access: Protected, Virtual -// Description: Fills the container up with EggPolygons that -// represent the component triangles of this triangle -// strip. -// -// It is assumed that the EggTriangleStrip is not -// already a child of any other group when this function -// is called. -// -// Returns true if the triangulation is successful, or -// false if there was some error (in which case the -// container may contain some partial triangulation). -//////////////////////////////////////////////////////////////////// +/** + * Fills the container up with EggPolygons that represent the component + * triangles of this triangle strip. + * + * It is assumed that the EggTriangleStrip is not already a child of any other + * group when this function is called. + * + * Returns true if the triangulation is successful, or false if there was some + * error (in which case the container may contain some partial triangulation). + */ bool EggTriangleStrip:: do_triangulate(EggGroupNode *container) const { if (size() < 3) { diff --git a/panda/src/egg/eggTriangleStrip.h b/panda/src/egg/eggTriangleStrip.h index c4486e55f7..1400aefbd9 100644 --- a/panda/src/egg/eggTriangleStrip.h +++ b/panda/src/egg/eggTriangleStrip.h @@ -1,16 +1,15 @@ -// Filename: eggTriangleStrip.h -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTriangleStrip.h + * @author drose + * @date 2005-03-13 + */ #ifndef EGGTRIANGLESTRIP_H #define EGGTRIANGLESTRIP_H @@ -19,12 +18,10 @@ #include "eggCompositePrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTriangleStrip -// Description : A connected strip of triangles. This does not -// normally appear in an egg file; it is typically -// generated as a result of meshing. -//////////////////////////////////////////////////////////////////// +/** + * A connected strip of triangles. This does not normally appear in an egg + * file; it is typically generated as a result of meshing. + */ class EXPCL_PANDAEGG EggTriangleStrip : public EggCompositePrimitive { PUBLISHED: INLINE EggTriangleStrip(const string &name = ""); diff --git a/panda/src/egg/eggUserData.I b/panda/src/egg/eggUserData.I index 2b17a74d3f..8e77c46c56 100644 --- a/panda/src/egg/eggUserData.I +++ b/panda/src/egg/eggUserData.I @@ -1,43 +1,35 @@ -// Filename: eggUserData.I -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUserData.I + * @author drose + * @date 2003-06-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggUserData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggUserData:: EggUserData() { } -//////////////////////////////////////////////////////////////////// -// Function: EggUserData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggUserData:: EggUserData(const EggUserData ©) : TypedReferenceCount(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggUserData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggUserData &EggUserData:: operator = (const EggUserData ©) { TypedReferenceCount::operator = (copy); diff --git a/panda/src/egg/eggUserData.cxx b/panda/src/egg/eggUserData.cxx index 459cc8273d..676041523b 100644 --- a/panda/src/egg/eggUserData.cxx +++ b/panda/src/egg/eggUserData.cxx @@ -1,27 +1,24 @@ -// Filename: eggUserData.cxx -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUserData.cxx + * @author drose + * @date 2003-06-03 + */ #include "eggUserData.h" TypeHandle EggUserData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggUserData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggUserData:: ~EggUserData() { } diff --git a/panda/src/egg/eggUserData.h b/panda/src/egg/eggUserData.h index e01e7dae42..cec2587946 100644 --- a/panda/src/egg/eggUserData.h +++ b/panda/src/egg/eggUserData.h @@ -1,16 +1,15 @@ -// Filename: eggUserData.h -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUserData.h + * @author drose + * @date 2003-06-03 + */ #ifndef EGGUSERDATA_H #define EGGUSERDATA_H @@ -19,18 +18,14 @@ #include "typedReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : EggUserData -// Description : This is a base class for a user-defined data type to -// extend egg structures in processing code. The user -// of the egg library may derive from EggUserData to -// associate any arbitrary data with various egg -// objects. -// -// However, this data will not be written out to the -// disk when the egg file is written; it is an in-memory -// object only. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for a user-defined data type to extend egg structures + * in processing code. The user of the egg library may derive from + * EggUserData to associate any arbitrary data with various egg objects. + * + * However, this data will not be written out to the disk when the egg file is + * written; it is an in-memory object only. + */ class EXPCL_PANDAEGG EggUserData : public TypedReferenceCount { PUBLISHED: INLINE EggUserData(); @@ -60,4 +55,3 @@ private: #include "eggUserData.I" #endif - diff --git a/panda/src/egg/eggUtilities.I b/panda/src/egg/eggUtilities.I index 33257a546b..04430db8f5 100644 --- a/panda/src/egg/eggUtilities.I +++ b/panda/src/egg/eggUtilities.I @@ -1,16 +1,15 @@ -// Filename: eggUtilities.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUtilities.I + * @author drose + * @date 1999-02-10 + */ #include "eggGroup.h" #include "eggPrimitive.h" @@ -18,33 +17,27 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: split_vertex -// Description: Splits a vertex into two or more vertices, each an -// exact copy of the original and in the same vertex -// pool. -// -// The splitting is based on some arbitrary property of -// the primitives that own the vertex. In the extreme, -// each primitive may get a different copy of the -// vertex, although it is also possible for some -// primitives to still share vertices. -// -// This decision is made based on the function object -// 'sequence'. This object must define the following -// function: -// -// int operator () (const EggPrimitive *prim) const; -// -// This function returns a sequence number, which -// determines which primitives will share which -// vertices. The sequence number 0 refers to the -// original vertex pointer; other sequence numbers -// indicate new vertices. Other than that, the sequence -// number is totally arbitrary. Primitives for which -// the sequence number is the same will end up sharing -// the same copy of the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Splits a vertex into two or more vertices, each an exact copy of the + * original and in the same vertex pool. + * + * The splitting is based on some arbitrary property of the primitives that + * own the vertex. In the extreme, each primitive may get a different copy of + * the vertex, although it is also possible for some primitives to still share + * vertices. + * + * This decision is made based on the function object 'sequence'. This object + * must define the following function: + * + * int operator () (const EggPrimitive *prim) const; + * + * This function returns a sequence number, which determines which primitives + * will share which vertices. The sequence number 0 refers to the original + * vertex pointer; other sequence numbers indicate new vertices. Other than + * that, the sequence number is totally arbitrary. Primitives for which the + * sequence number is the same will end up sharing the same copy of the + * vertex. + */ template void split_vertex(EggVertex *vert, const FunctionObject &sequence) { @@ -54,21 +47,19 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { EggVertexPool *pool = vert->get_pool(); - // Define a map of ints to vert pointers, to indicate which sequence - // numbers we have already created vertices for. + // Define a map of ints to vert pointers, to indicate which sequence numbers + // we have already created vertices for. typedef pmap Sequences; Sequences _sequences; - // Get a copy of the list of primitives that reference this vertex. - // We must have a copy because we will be modifying the list as we - // traverse it. + // Get a copy of the list of primitives that reference this vertex. We must + // have a copy because we will be modifying the list as we traverse it. typedef pvector Prims; Prims prims; prims.reserve(vert->pref_size()); copy(vert->pref_begin(), vert->pref_end(), back_inserter(prims)); - // Now walk through the list of primitives that reference this - // vertex. + // Now walk through the list of primitives that reference this vertex. Prims::const_iterator pri; for (pri = prims.begin(); pri != prims.end(); ++pri) { EggPrimitive *prim = *pri; @@ -83,19 +74,17 @@ split_vertex(EggVertex *vert, const FunctionObject &sequence) { Sequences::const_iterator si = _sequences.find(seq); if (si != _sequences.end()) { - // Yes, we've seen this sequence number before. Use the same - // vertex. + // Yes, we've seen this sequence number before. Use the same vertex. new_vert = (*si).second; } else { - // No, this is the first time we've encountered this sequence. - // Split the vertex. + // No, this is the first time we've encountered this sequence. Split + // the vertex. new_vert = new EggVertex(*vert); pool->add_vertex(new_vert); _sequences[seq] = new_vert; - // The new vertex gets all the same group memberships as the - // old one. + // The new vertex gets all the same group memberships as the old one. EggVertex::GroupRef::const_iterator gri; for (gri = vert->gref_begin(); gri != vert->gref_end(); ++gri) { EggGroup *group = *gri; diff --git a/panda/src/egg/eggUtilities.cxx b/panda/src/egg/eggUtilities.cxx index cf2805d554..9e7a38e93c 100644 --- a/panda/src/egg/eggUtilities.cxx +++ b/panda/src/egg/eggUtilities.cxx @@ -1,16 +1,15 @@ -// Filename: eggUtilities.cxx -// Created by: drose (28Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUtilities.cxx + * @author drose + * @date 1999-01-28 + */ #include "eggUtilities.h" #include "eggPrimitive.h" @@ -19,15 +18,12 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: get_textures_by_filename -// Description: Extracts from the egg subgraph beginning at the -// indicated node a set of all the texture objects -// referenced, grouped together by filename. Texture -// objects that share a common filename (but possibly -// differ in other properties) are returned together in -// the same element of the map. -//////////////////////////////////////////////////////////////////// +/** + * Extracts from the egg subgraph beginning at the indicated node a set of all + * the texture objects referenced, grouped together by filename. Texture + * objects that share a common filename (but possibly differ in other + * properties) are returned together in the same element of the map. + */ void get_textures_by_filename(const EggNode *node, EggTextureFilenames &result) { if (node->is_of_type(EggPrimitive::get_class_type())) { @@ -48,4 +44,3 @@ get_textures_by_filename(const EggNode *node, EggTextureFilenames &result) { } } } - diff --git a/panda/src/egg/eggUtilities.h b/panda/src/egg/eggUtilities.h index 4bf2a82797..0ea65499f4 100644 --- a/panda/src/egg/eggUtilities.h +++ b/panda/src/egg/eggUtilities.h @@ -1,28 +1,21 @@ -// Filename: eggUtilities.h -// Created by: drose (28Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggUtilities.h + * @author drose + * @date 1999-01-28 + */ #ifndef EGGUTILITIES_H #define EGGUTILITIES_H -//////////////////////////////////////////////////////////////////// -// -// eggUtilities.h -// -// Handy functions that operate on egg structures, but don't +// eggUtilities.h Handy functions that operate on egg structures, but don't // necessarily belong in any one class. -// -//////////////////////////////////////////////////////////////////// #include "pandabase.h" @@ -42,26 +35,21 @@ typedef pset< PT_EggTexture > EggTextures; typedef pmap EggTextureFilenames; -//////////////////////////////////////////////////////////////////// -// Function: get_textures_by_filename -// Description: Extracts from the egg subgraph beginning at the -// indicated node a set of all the texture objects -// referenced, grouped together by filename. Texture -// objects that share a common filename (but possibly -// differ in other properties) are returned together in -// the same element of the map. -//////////////////////////////////////////////////////////////////// +/** + * Extracts from the egg subgraph beginning at the indicated node a set of all + * the texture objects referenced, grouped together by filename. Texture + * objects that share a common filename (but possibly differ in other + * properties) are returned together in the same element of the map. + */ void get_textures_by_filename(const EggNode *node, EggTextureFilenames &result); -//////////////////////////////////////////////////////////////////// -// Function: split_vertex -// Description: Splits a vertex into two or more vertices, each an -// exact copy of the original and in the same vertex -// pool. See the more detailed comments in -// eggUtilities.I. -//////////////////////////////////////////////////////////////////// +/** + * Splits a vertex into two or more vertices, each an exact copy of the + * original and in the same vertex pool. See the more detailed comments in + * eggUtilities.I. + */ template void split_vertex(EggVertex *vert, const FunctionObject &sequence); diff --git a/panda/src/egg/eggVertex.I b/panda/src/egg/eggVertex.I index bf13637d39..1b7c807e5a 100644 --- a/panda/src/egg/eggVertex.I +++ b/panda/src/egg/eggVertex.I @@ -1,55 +1,43 @@ -// Filename: eggVertex.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertex.I + * @author drose + * @date 1999-01-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_pool -// Access: Published -// Description: Returns the vertex pool this vertex belongs in. This -// may be NULL if the vertex has not been added to a -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex pool this vertex belongs in. This may be NULL if the + * vertex has not been added to a pool. + */ INLINE EggVertexPool *EggVertex:: get_pool() const { return _pool; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::is_forward_reference -// Access: Published -// Description: Returns true if the vertex is a forward reference to -// some vertex that hasn't been defined yet. In this -// case, the vertex may not have any properties filled -// in yet. -// -// This can only happen if you implicitly create a -// vertex via EggVertexPool::get_forward_vertex(). -// Presumably, when the vertex pool is later filled in, -// this vertex will be replaced with real data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex is a forward reference to some vertex that + * hasn't been defined yet. In this case, the vertex may not have any + * properties filled in yet. + * + * This can only happen if you implicitly create a vertex via + * EggVertexPool::get_forward_vertex(). Presumably, when the vertex pool is + * later filled in, this vertex will be replaced with real data. + */ INLINE bool EggVertex:: is_forward_reference() const { return _forward_reference; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_pos -// Access: Published -// Description: Sets the vertex position. This variant sets the -// vertex to a one-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertex position. This variant sets the vertex to a one- + * dimensional value. + */ INLINE void EggVertex:: set_pos(double pos) { _num_dimensions = 1; @@ -57,12 +45,10 @@ set_pos(double pos) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_pos -// Access: Published -// Description: Sets the vertex position. This variant sets the -// vertex to a two-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertex position. This variant sets the vertex to a two- + * dimensional value. + */ INLINE void EggVertex:: set_pos(const LPoint2d &pos) { _num_dimensions = 2; @@ -70,12 +56,10 @@ set_pos(const LPoint2d &pos) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_pos -// Access: Published -// Description: Sets the vertex position. This variant sets the -// vertex to a three-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertex position. This variant sets the vertex to a three- + * dimensional value. + */ INLINE void EggVertex:: set_pos(const LPoint3d &pos) { _num_dimensions = 3; @@ -83,12 +67,10 @@ set_pos(const LPoint3d &pos) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_pos -// Access: Published -// Description: Sets the vertex position. This variant sets the -// vertex to a four-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertex position. This variant sets the vertex to a four- + * dimensional value. + */ INLINE void EggVertex:: set_pos(const LPoint4d &pos) { _num_dimensions = 4; @@ -96,40 +78,33 @@ set_pos(const LPoint4d &pos) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_pos4 -// Access: Published -// Description: This special flavor of set_pos() sets the vertex as a -// four-component value, but does not change the set -// number of dimensions. It's handy for retrieving the -// vertex position via get_pos4, manipulating it, then -// storing it back again, without worrying about the -// number of dimensions it actually had. -//////////////////////////////////////////////////////////////////// +/** + * This special flavor of set_pos() sets the vertex as a four-component value, + * but does not change the set number of dimensions. It's handy for + * retrieving the vertex position via get_pos4, manipulating it, then storing + * it back again, without worrying about the number of dimensions it actually + * had. + */ INLINE void EggVertex:: set_pos4(const LPoint4d &pos) { _pos = pos; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_num_dimensions -// Access: Published -// Description: Returns the number of dimensions the vertex uses. -// Usually this will be 3, but it may be 1, 2, 3, or 4. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of dimensions the vertex uses. Usually this will be 3, + * but it may be 1, 2, 3, or 4. + */ INLINE int EggVertex:: get_num_dimensions() const { return _num_dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_pos1 -// Access: Published -// Description: Only valid if get_num_dimensions() returns 1. -// Returns the position as a one-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Only valid if get_num_dimensions() returns 1. Returns the position as a + * one-dimensional value. + */ INLINE double EggVertex:: get_pos1() const { nassertr(_num_dimensions == 1, 0.0); @@ -137,12 +112,10 @@ get_pos1() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_pos2 -// Access: Published -// Description: Only valid if get_num_dimensions() returns 2. -// Returns the position as a two-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Only valid if get_num_dimensions() returns 2. Returns the position as a + * two-dimensional value. + */ INLINE LPoint2d EggVertex:: get_pos2() const { nassertr(_num_dimensions == 2, LPoint2d(0.0, 0.0)); @@ -150,12 +123,10 @@ get_pos2() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_pos3 -// Access: Published -// Description: Valid if get_num_dimensions() returns 3 or 4. -// Returns the position as a three-dimensional value. -//////////////////////////////////////////////////////////////////// +/** + * Valid if get_num_dimensions() returns 3 or 4. Returns the position as a + * three-dimensional value. + */ INLINE LVertexd EggVertex:: get_pos3() const { nassertr(_num_dimensions == 3 || _num_dimensions == 4, @@ -164,251 +135,195 @@ get_pos3() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_pos4 -// Access: Published -// Description: This is always valid, regardless of the value of -// get_num_dimensions. It returns the position as a -// four-dimensional value. If the pos has fewer than -// four dimensions, this value represents the pos -// extended into four-dimensional homogenous space, -// e.g. by adding 1 as the fourth component. -//////////////////////////////////////////////////////////////////// +/** + * This is always valid, regardless of the value of get_num_dimensions. It + * returns the position as a four-dimensional value. If the pos has fewer + * than four dimensions, this value represents the pos extended into four- + * dimensional homogenous space, e.g. by adding 1 as the fourth component. + */ INLINE LPoint4d EggVertex:: get_pos4() const { return _pos; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_uv -// Access: Published -// Description: Returns true if the vertex has an unnamed UV -// coordinate pair, false otherwise. -// -// This is the more restrictive interface, and is -// generally useful only in the absence of -// multitexturing; see has_uv(name) for the interface -// that supports multitexturing. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has an unnamed UV coordinate pair, false + * otherwise. + * + * This is the more restrictive interface, and is generally useful only in the + * absence of multitexturing; see has_uv(name) for the interface that supports + * multitexturing. + */ INLINE bool EggVertex:: has_uv() const { return has_uv(""); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_aux -// Access: Published -// Description: Returns true if the vertex has any auxiliary -// data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has any auxiliary data, false otherwise. + */ INLINE bool EggVertex:: has_aux() const { return (_aux_map.size() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_uv -// Access: Published -// Description: Returns the unnamed UV coordinate pair on the -// vertex. It is an error to call this if has_uv() has -// returned false. -// -// This is the more restrictive interface, and is -// generally useful only in the absence of -// multitexturing; see get_uv(name) for the interface -// that supports multitexturing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the unnamed UV coordinate pair on the vertex. It is an error to + * call this if has_uv() has returned false. + * + * This is the more restrictive interface, and is generally useful only in the + * absence of multitexturing; see get_uv(name) for the interface that supports + * multitexturing. + */ INLINE LTexCoordd EggVertex:: get_uv() const { nassertr(has_uv(), LTexCoordd::zero()); return get_uv(""); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_uv -// Access: Published -// Description: Replaces the unnamed UV coordinate pair on the vertex -// with the indicated value. -// -// This is the more restrictive interface, and is -// generally useful only in the absence of -// multitexturing; see set_uv(name, uv) for the -// interface that supports multitexturing. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the unnamed UV coordinate pair on the vertex with the indicated + * value. + * + * This is the more restrictive interface, and is generally useful only in the + * absence of multitexturing; see set_uv(name, uv) for the interface that + * supports multitexturing. + */ INLINE void EggVertex:: set_uv(const LTexCoordd &uv) { set_uv("", uv); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::clear_uv -// Access: Published -// Description: Removes all UV coordinate pairs from the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Removes all UV coordinate pairs from the vertex. + */ INLINE void EggVertex:: clear_uv() { _uv_map.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::clear_aux -// Access: Published -// Description: Removes all auxiliary data from the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Removes all auxiliary data from the vertex. + */ INLINE void EggVertex:: clear_aux() { _aux_map.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::uv_begin -// Access: Public -// Description: Returns an iterator that allows walking through the -// complete set of named UV's on the vertex. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that allows walking through the complete set of named + * UV's on the vertex. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggVertex::const_uv_iterator EggVertex:: uv_begin() const { return _uv_map.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::aux_begin -// Access: Public -// Description: Returns an iterator that allows walking through the -// complete set of auxiliary data on the vertex. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that allows walking through the complete set of + * auxiliary data on the vertex. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggVertex::const_aux_iterator EggVertex:: aux_begin() const { return _aux_map.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::uv_end -// Access: Public -// Description: Returns an iterator that allows walking through the -// complete set of named UV's on the vertex. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that allows walking through the complete set of named + * UV's on the vertex. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggVertex::const_uv_iterator EggVertex:: uv_end() const { return _uv_map.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::aux_end -// Access: Public -// Description: Returns an iterator that allows walking through the -// complete set of auxiliary data on the vertex. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that allows walking through the complete set of + * auxiliary data on the vertex. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ INLINE EggVertex::const_aux_iterator EggVertex:: aux_end() const { return _aux_map.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::uv_size -// Access: Public -// Description: Returns the number of named UV's on the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of named UV's on the vertex. + */ INLINE EggVertex::uv_size_type EggVertex:: uv_size() const { return _uv_map.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::aux_size -// Access: Public -// Description: Returns the number of auxiliary datas on the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of auxiliary datas on the vertex. + */ INLINE EggVertex::aux_size_type EggVertex:: aux_size() const { return _aux_map.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_index -// Access: Published -// Description: Returns the index number of the vertex within its -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the vertex within its pool. + */ INLINE int EggVertex:: get_index() const { return _index; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_external_index -// Access: Published -// Description: Sets a special index number that is associated with -// the EggVertex (but is not written to the egg file). -// This number is not interpreted by any egg code; it is -// simply maintained along with the vertex. It *is* -// used to differentiate otherwise identical vertices in -// EggVertexPool::create_unique_vertex(), however. -// -// The intention of this number is as an aid for file -// converters, to associate an EggVertex back to the -// index number of the original source vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets a special index number that is associated with the EggVertex (but is + * not written to the egg file). This number is not interpreted by any egg + * code; it is simply maintained along with the vertex. It *is* used to + * differentiate otherwise identical vertices in + * EggVertexPool::create_unique_vertex(), however. + * + * The intention of this number is as an aid for file converters, to associate + * an EggVertex back to the index number of the original source vertex. + */ INLINE void EggVertex:: set_external_index(int external_index) { _external_index = external_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_external_index -// Access: Published -// Description: Returns the number set by set_external_index(). See -// set_external_index(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number set by set_external_index(). See set_external_index(). + */ INLINE int EggVertex:: get_external_index() const { return _external_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_external_index2 -// Access: Published -// Description: Similar to set_external_index(), but this is a -// different number which may be used for a different -// purpose by the calling code. The egg library does -// not assign any meaning to this number or use it in -// any way. -//////////////////////////////////////////////////////////////////// +/** + * Similar to set_external_index(), but this is a different number which may + * be used for a different purpose by the calling code. The egg library does + * not assign any meaning to this number or use it in any way. + */ INLINE void EggVertex:: set_external_index2(int external_index2) { _external_index2 = external_index2; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_external_index2 -// Access: Published -// Description: Returns the number set by set_external_index2(). See -// set_external_index2(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number set by set_external_index2(). See + * set_external_index2(). + */ INLINE int EggVertex:: get_external_index2() const { return _external_index2; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::sorts_less_than -// Access: Published -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + */ INLINE bool EggVertex:: sorts_less_than(const EggVertex &other) const { return (compare_to(other) < 0); @@ -418,13 +333,10 @@ sorts_less_than(const EggVertex &other) const { -//////////////////////////////////////////////////////////////////// -// Function: UniqueEggVertices::Function operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool UniqueEggVertices:: operator ()(const EggVertex *v1, const EggVertex *v2) const { return v1->sorts_less_than(*v2); } - diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index 29f2cdeeab..973f583b7b 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -1,16 +1,15 @@ -// Filename: eggVertex.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertex.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggVertex.h" #include "eggVertexPool.h" @@ -30,11 +29,9 @@ TypeHandle EggVertex::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertex:: EggVertex() { _pool = NULL; @@ -47,12 +44,10 @@ EggVertex() { test_gref_integrity(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::Copy constructor -// Access: Published -// Description: Copies all properties of the vertex except its vertex -// pool, index number, and group membership. -//////////////////////////////////////////////////////////////////// +/** + * Copies all properties of the vertex except its vertex pool, index number, + * and group membership. + */ EggVertex:: EggVertex(const EggVertex ©) : EggObject(copy), EggAttributes(copy), @@ -72,12 +67,10 @@ EggVertex(const EggVertex ©) } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::Copy assignment operator -// Access: Published -// Description: Copies all properties of the vertex except its vertex -// pool, index number, and group membership. -//////////////////////////////////////////////////////////////////// +/** + * Copies all properties of the vertex except its vertex pool, index number, + * and group membership. + */ EggVertex &EggVertex:: operator = (const EggVertex ©) { EggObject::operator = (copy); @@ -96,31 +89,25 @@ operator = (const EggVertex ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertex:: ~EggVertex() { - // We should never destruct a vertex while it still thinks it - // belongs to a VertexPool. If we do, we've probably lost a - // reference count somewhere. + // We should never destruct a vertex while it still thinks it belongs to a + // VertexPool. If we do, we've probably lost a reference count somewhere. nassertv(_pool == NULL); - // Also, a vertex shouldn't be destructed while it's being - // referenced by a group or a primitive, for the same reason. + // Also, a vertex shouldn't be destructed while it's being referenced by a + // group or a primitive, for the same reason. nassertv(_gref.empty()); nassertv(_pref.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_uv -// Access: Published -// Description: Returns true if the vertex has the named UV -// coordinate pair, and the named UV coordinate pair is -// 2-d, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has the named UV coordinate pair, and the named + * UV coordinate pair is 2-d, false otherwise. + */ bool EggVertex:: has_uv(const string &name) const { UVMap::const_iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -131,13 +118,10 @@ has_uv(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_uvw -// Access: Published -// Description: Returns true if the vertex has the named UV -// coordinate triple, and the named UV coordinate triple is -// 3-d, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has the named UV coordinate triple, and the + * named UV coordinate triple is 3-d, false otherwise. + */ bool EggVertex:: has_uvw(const string &name) const { UVMap::const_iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -148,12 +132,9 @@ has_uvw(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_aux -// Access: Published -// Description: Returns true if the vertex has the named -// auxiliary data quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has the named auxiliary data quadruple. + */ bool EggVertex:: has_aux(const string &name) const { AuxMap::const_iterator xi = _aux_map.find(name); @@ -164,13 +145,10 @@ has_aux(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_uv -// Access: Published -// Description: Returns the named UV coordinate pair on the vertex. -// It is an error to call this if has_uv(name) -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named UV coordinate pair on the vertex. It is an error to call + * this if has_uv(name) returned false. + */ LTexCoordd EggVertex:: get_uv(const string &name) const { UVMap::const_iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -178,13 +156,10 @@ get_uv(const string &name) const { return (*ui).second->get_uv(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_uvw -// Access: Published -// Description: Returns the named UV coordinate triple on the vertex. -// It is an error to call this if has_uvw(name) -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named UV coordinate triple on the vertex. It is an error to + * call this if has_uvw(name) returned false. + */ const LTexCoord3d &EggVertex:: get_uvw(const string &name) const { UVMap::const_iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -192,13 +167,10 @@ get_uvw(const string &name) const { return (*ui).second->get_uvw(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_aux -// Access: Published -// Description: Returns the named auxiliary data quadruple on the -// vertex. It is an error to call this if has_aux(name) -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named auxiliary data quadruple on the vertex. It is an error + * to call this if has_aux(name) returned false. + */ const LVecBase4d &EggVertex:: get_aux(const string &name) const { AuxMap::const_iterator xi = _aux_map.find(name); @@ -206,13 +178,11 @@ get_aux(const string &name) const { return (*xi).second->get_aux(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_uv -// Access: Published -// Description: Sets the indicated UV coordinate pair on the vertex. -// This replaces any UV coordinate pair with the same -// name already on the vertex, but preserves UV morphs. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated UV coordinate pair on the vertex. This replaces any UV + * coordinate pair with the same name already on the vertex, but preserves UV + * morphs. + */ void EggVertex:: set_uv(const string &name, const LTexCoordd &uv) { string fname = EggVertexUV::filter_name(name); @@ -228,14 +198,11 @@ set_uv(const string &name, const LTexCoordd &uv) { nassertv(get_uv(fname) == uv); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_uvw -// Access: Published -// Description: Sets the indicated UV coordinate triple on the vertex. -// This replaces any UV coordinate pair or triple with -// the same name already on the vertex, but preserves UV -// morphs. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated UV coordinate triple on the vertex. This replaces any + * UV coordinate pair or triple with the same name already on the vertex, but + * preserves UV morphs. + */ void EggVertex:: set_uvw(const string &name, const LTexCoord3d &uvw) { string fname = EggVertexUV::filter_name(name); @@ -251,13 +218,10 @@ set_uvw(const string &name, const LTexCoord3d &uvw) { nassertv(get_uvw(fname) == uvw); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_aux -// Access: Published -// Description: Sets the indicated auxiliary data quadruple on the -// vertex. This replaces any auxiliary data with the -// same name already on the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated auxiliary data quadruple on the vertex. This replaces + * any auxiliary data with the same name already on the vertex. + */ void EggVertex:: set_aux(const string &name, const LVecBase4d &aux) { PT(EggVertexAux) &aux_obj = _aux_map[name]; @@ -272,16 +236,12 @@ set_aux(const string &name, const LVecBase4d &aux) { nassertv(get_aux(name) == aux); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_uv_obj -// Access: Published -// Description: Returns the named EggVertexUV object, which defines -// both the UV coordinate pair for this name and the UV -// morphs. This object might be shared between multiple -// vertices. You should not attempt to modify this -// object; instead, call modify_uv_object to return a -// modifiable pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named EggVertexUV object, which defines both the UV coordinate + * pair for this name and the UV morphs. This object might be shared between + * multiple vertices. You should not attempt to modify this object; instead, + * call modify_uv_object to return a modifiable pointer. + */ const EggVertexUV *EggVertex:: get_uv_obj(const string &name) const { UVMap::const_iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -291,15 +251,12 @@ get_uv_obj(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_aux_obj -// Access: Published -// Description: Returns the named EggVertexAux object, which defines -// the auxiliary data for this name. This object might -// be shared between multiple vertices. You should not -// attempt to modify this object; instead, call -// modify_aux_object to return a modifiable pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named EggVertexAux object, which defines the auxiliary data for + * this name. This object might be shared between multiple vertices. You + * should not attempt to modify this object; instead, call modify_aux_object + * to return a modifiable pointer. + */ const EggVertexAux *EggVertex:: get_aux_obj(const string &name) const { AuxMap::const_iterator xi = _aux_map.find(name); @@ -309,14 +266,11 @@ get_aux_obj(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::modify_uv_obj -// Access: Published -// Description: Returns a modifiable pointer to the named EggVertexUV -// object, which defines both the UV coordinate pair for -// this name and the UV morphs. Returns NULL if there -// is no such named UV object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the named EggVertexUV object, which defines + * both the UV coordinate pair for this name and the UV morphs. Returns NULL + * if there is no such named UV object. + */ EggVertexUV *EggVertex:: modify_uv_obj(const string &name) { UVMap::iterator ui = _uv_map.find(EggVertexUV::filter_name(name)); @@ -331,14 +285,11 @@ modify_uv_obj(const string &name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::modify_aux_obj -// Access: Published -// Description: Returns a modifiable pointer to the named EggVertexAux -// object, which defines the auxiliary data for -// this name. Returns NULL if there is no such -// named UV object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the named EggVertexAux object, which + * defines the auxiliary data for this name. Returns NULL if there is no such + * named UV object. + */ EggVertexAux *EggVertex:: modify_aux_obj(const string &name) { AuxMap::iterator xi = _aux_map.find(name); @@ -353,69 +304,56 @@ modify_aux_obj(const string &name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_uv_obj -// Access: Published -// Description: Sets the indicated EggVertexUV on the vertex. -// This replaces any UV coordinate pair with the same -// name already on the vertex, including UV morphs. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated EggVertexUV on the vertex. This replaces any UV + * coordinate pair with the same name already on the vertex, including UV + * morphs. + */ void EggVertex:: set_uv_obj(EggVertexUV *uv) { _uv_map[uv->get_name()] = uv; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::set_aux_obj -// Access: Published -// Description: Sets the indicated EggVertexAux on the vertex. -// This replaces any auxiliary data with the same -// name already on the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated EggVertexAux on the vertex. This replaces any auxiliary + * data with the same name already on the vertex. + */ void EggVertex:: set_aux_obj(EggVertexAux *aux) { _aux_map[aux->get_name()] = aux; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::clear_uv -// Access: Published -// Description: Removes the named UV coordinate pair from the vertex, -// along with any UV morphs. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named UV coordinate pair from the vertex, along with any UV + * morphs. + */ void EggVertex:: clear_uv(const string &name) { _uv_map.erase(EggVertexUV::filter_name(name)); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::clear_aux -// Access: Published -// Description: Removes the named auxiliary data from the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named auxiliary data from the vertex. + */ void EggVertex:: clear_aux(const string &name) { _aux_map.erase(name); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::make_average -// Access: Published, Static -// Description: Creates a new vertex that lies in between the two -// given vertices. The attributes for the UV sets -// they have in common are averaged. -// -// Both vertices need to be either in no pool, or in -// the same pool. In the latter case, the new vertex -// will be placed in that pool. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vertex that lies in between the two given vertices. The + * attributes for the UV sets they have in common are averaged. + * + * Both vertices need to be either in no pool, or in the same pool. In the + * latter case, the new vertex will be placed in that pool. + */ PT(EggVertex) EggVertex:: make_average(const EggVertex *first, const EggVertex *second) { PT(EggVertexPool) pool = first->get_pool(); nassertr(pool == second->get_pool(), NULL); - // If both vertices are in a pool, the new vertex will be part of - // the pool as well. + // If both vertices are in a pool, the new vertex will be part of the pool + // as well. PT(EggVertex) middle; if (pool == NULL) { middle = new EggVertex; @@ -434,8 +372,8 @@ make_average(const EggVertex *first, const EggVertex *second) { middle->set_color((first->get_color() + second->get_color()) / 2); } - // Average out the EggVertexUV objects, but only for the UV sets - // that they have in common. + // Average out the EggVertexUV objects, but only for the UV sets that they + // have in common. const_uv_iterator it; for (it = first->uv_begin(); it != first->uv_end(); ++it) { const EggVertexUV *first_uv = it->second; @@ -500,14 +438,14 @@ make_average(const EggVertex *first, const EggVertex *second) { (group->get_vertex_membership(first) + group->get_vertex_membership(second)) / 2.); } else { - // Hmm, unfortunate, only one of the vertices is member of this - // group, so we can't make an average. We'll have to assign the - // only group membership we have. + // Hmm, unfortunate, only one of the vertices is member of this group, + // so we can't make an average. We'll have to assign the only group + // membership we have. group->set_vertex_membership(middle, group->get_vertex_membership(first)); } } - // Also assign memberships to the grefs in the second vertex that - // aren't part of the first vertex. + // Also assign memberships to the grefs in the second vertex that aren't + // part of the first vertex. for (gi = second->_gref.begin(); gi != second->_gref.end(); ++gi) { EggGroup *group = *gi; if (second->_gref.count(group) == 0) { @@ -518,12 +456,10 @@ make_average(const EggVertex *first, const EggVertex *second) { return middle; } -//////////////////////////////////////////////////////////////////// -// Class : GroupRefEntry -// Description : A temporary class used in EggVertex::write(), below, -// to hold the groups that reference each vertex prior -// to outputting them as a formatted list. -//////////////////////////////////////////////////////////////////// +/** + * A temporary class used in EggVertex::write(), below, to hold the groups + * that reference each vertex prior to outputting them as a formatted list. + */ class GroupRefEntry { public: GroupRefEntry(EggGroup *group, double membership) @@ -545,12 +481,9 @@ INLINE ostream &operator << (ostream &out, const GroupRefEntry &gre) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::write -// Access: Published -// Description: Writes the vertex to the indicated output stream in -// Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vertex to the indicated output stream in Egg format. + */ void EggVertex:: write(ostream &out, int indent_level) const { test_pref_integrity(); @@ -559,8 +492,8 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << " " << _index << " {\n"; - // Now output the position. This might have any number of - // dimensions up to 4. + // Now output the position. This might have any number of dimensions up to + // 4. indent(out, indent_level+1); for (int i = 0; i < _num_dimensions; i++) { out << " " << _pos[i]; @@ -581,8 +514,8 @@ write(ostream &out, int indent_level) const { _dxyzs.write(out, indent_level + 2, "", 3); - // If the vertex is referenced by one or more groups, write that as - // a helpful comment. + // If the vertex is referenced by one or more groups, write that as a + // helpful comment. if (!_gref.empty()) { // We need to build a list of group entries. pset gre; @@ -602,27 +535,21 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::compare_to -// Access: Published -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -// -// Group membership is not considered in this -// comparison. This is somewhat problematic, but cannot -// easily be helped, because considering group -// membership would make it difficult to add and remove -// groups from vertices. It also makes it impossible to -// meaningfully compare with a concrete EggVertex object -// (which cannot have group memberships). -// -// However, this is not altogether bad, because two -// vertices that are identical in all other properties -// should generally also be identical in group -// memberships, else the vertices will tend to fly apart -// when the joints animate. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + * + * Group membership is not considered in this comparison. This is somewhat + * problematic, but cannot easily be helped, because considering group + * membership would make it difficult to add and remove groups from vertices. + * It also makes it impossible to meaningfully compare with a concrete + * EggVertex object (which cannot have group memberships). + * + * However, this is not altogether bad, because two vertices that are + * identical in all other properties should generally also be identical in + * group memberships, else the vertices will tend to fly apart when the joints + * animate. + */ int EggVertex:: compare_to(const EggVertex &other) const { if (_external_index != other._external_index) { @@ -702,13 +629,10 @@ compare_to(const EggVertex &other) const { return EggAttributes::compare_to(other); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_num_local_coord -// Access: Published -// Description: Returns the number of primitives that own this vertex -// whose vertices are interpreted to be in a local -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of primitives that own this vertex whose vertices are + * interpreted to be in a local coordinate system. + */ int EggVertex:: get_num_local_coord() const { test_pref_integrity(); @@ -723,13 +647,10 @@ get_num_local_coord() const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::get_num_global_coord -// Access: Published -// Description: Returns the number of primitives that own this vertex -// whose vertices are interpreted in the global -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of primitives that own this vertex whose vertices are + * interpreted in the global coordinate system. + */ int EggVertex:: get_num_global_coord() const { test_pref_integrity(); @@ -745,21 +666,18 @@ get_num_global_coord() const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::transform -// Access: Published, Virtual -// Description: Applies the indicated transformation matrix to the -// vertex. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation matrix to the vertex. + */ void EggVertex:: transform(const LMatrix4d &mat) { _pos = _pos * mat; EggMorphVertexList::iterator mi; for (mi = _dxyzs.begin(); mi != _dxyzs.end(); ++mi) { - // We can safely cast the morph object to a non-const, because - // we're not changing its name, which is the only thing the set - // cares about preserving. + // We can safely cast the morph object to a non-const, because we're not + // changing its name, which is the only thing the set cares about + // preserving. EggMorphVertex &morph = (EggMorphVertex &)(*mi); morph.set_offset((*mi).get_offset() * mat); @@ -774,76 +692,58 @@ transform(const LMatrix4d &mat) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::gref_begin -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// gref_end(), be used to traverse the entire set of -// groups that reference this vertex. Each iterator -// returns a pointer to a group. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with gref_end(), be used to + * traverse the entire set of groups that reference this vertex. Each + * iterator returns a pointer to a group. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::GroupRef::const_iterator EggVertex:: gref_begin() const { return _gref.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::gref_end -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// gref_begin(), be used to traverse the entire set of -// groups that reference this vertex. Each iterator -// returns a pointer to a group. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with gref_begin(), be used to + * traverse the entire set of groups that reference this vertex. Each + * iterator returns a pointer to a group. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::GroupRef::const_iterator EggVertex:: gref_end() const { return _gref.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::gref_size -// Access: Public -// Description: Returns the number of elements between gref_begin() -// and gref_end(). -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements between gref_begin() and gref_end(). + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::GroupRef::size_type EggVertex:: gref_size() const { return _gref.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_gref -// Access: Published -// Description: Returns true if the indicated group references this -// vertex, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated group references this vertex, false + * otherwise. + */ bool EggVertex:: has_gref(const EggGroup *group) const { return _gref.count((EggGroup *)group) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::copy_grefs_from -// Access: Published -// Description: Copies all the group references from the other vertex -// onto this one. This assigns the current vertex to -// exactly the same groups, with exactly the same -// memberships, as the given one. -// -// Warning: only an EggVertex allocated from the free -// store may have groups assigned to it. Do not attempt -// to call this on a temporary concrete EggVertex -// object; a core dump will certainly result. -//////////////////////////////////////////////////////////////////// +/** + * Copies all the group references from the other vertex onto this one. This + * assigns the current vertex to exactly the same groups, with exactly the + * same memberships, as the given one. + * + * Warning: only an EggVertex allocated from the free store may have groups + * assigned to it. Do not attempt to call this on a temporary concrete + * EggVertex object; a core dump will certainly result. + */ void EggVertex:: copy_grefs_from(const EggVertex &other) { if (&other == this) { @@ -865,12 +765,10 @@ copy_grefs_from(const EggVertex &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::clear_grefs -// Access: Published -// Description: Removes all group references from the vertex, so that -// it is not assigned to any group. -//////////////////////////////////////////////////////////////////// +/** + * Removes all group references from the vertex, so that it is not assigned to + * any group. + */ void EggVertex:: clear_grefs() { GroupRef gref_copy = _gref; @@ -885,58 +783,44 @@ clear_grefs() { nassertv(_gref.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::pref_begin -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// pref_end(), be used to traverse the entire set of -// primitives that reference this vertex. Each iterator -// returns a pointer to a primitive. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with pref_end(), be used to + * traverse the entire set of primitives that reference this vertex. Each + * iterator returns a pointer to a primitive. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::PrimitiveRef::const_iterator EggVertex:: pref_begin() const { return _pref.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::pref_end -// Access: Public -// Description: Returns an iterator that can, in conjunction with -// pref_begin(), be used to traverse the entire set of -// primitives that reference this vertex. Each iterator -// returns a pointer to a primitive. -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can, in conjunction with pref_begin(), be used to + * traverse the entire set of primitives that reference this vertex. Each + * iterator returns a pointer to a primitive. + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::PrimitiveRef::const_iterator EggVertex:: pref_end() const { return _pref.end(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::pref_size -// Access: Public -// Description: Returns the number of elements between pref_begin() -// and pref_end(). -// -// This interface is not safe to use outside of -// PANDAEGG.DLL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements between pref_begin() and pref_end(). + * + * This interface is not safe to use outside of PANDAEGG.DLL. + */ EggVertex::GroupRef::size_type EggVertex:: pref_size() const { return _pref.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::has_pref -// Access: Published -// Description: Returns the number of times the vertex appears in the -// indicated primitive, or 0 if it does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times the vertex appears in the indicated primitive, + * or 0 if it does not appear. + */ int EggVertex:: has_pref(const EggPrimitive *prim) const { return _pref.count((EggPrimitive *)prim); @@ -944,13 +828,10 @@ has_pref(const EggPrimitive *prim) const { #ifdef _DEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::test_gref_integrity -// Access: Published -// Description: Verifies that the gref list is correct and that all -// the groups included actually exist and do reference -// the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the gref list is correct and that all the groups included + * actually exist and do reference the vertex. + */ void EggVertex:: test_gref_integrity() const { test_ref_count_integrity(); @@ -967,13 +848,10 @@ test_gref_integrity() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::test_pref_integrity -// Access: Published -// Description: Verifies that the pref list is correct and that all -// the primitives included actually exist and do -// reference the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the pref list is correct and that all the primitives included + * actually exist and do reference the vertex. + */ void EggVertex:: test_pref_integrity() const { test_ref_count_integrity(); @@ -993,11 +871,9 @@ test_pref_integrity() const { #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: EggVertex::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggVertex:: output(ostream &out) const { if (get_pool() == NULL) { diff --git a/panda/src/egg/eggVertex.h b/panda/src/egg/eggVertex.h index e56036fec4..4bbbd773d1 100644 --- a/panda/src/egg/eggVertex.h +++ b/panda/src/egg/eggVertex.h @@ -1,16 +1,15 @@ -// Filename: eggVertex.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertex.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGVERTEX_H #define EGGVERTEX_H @@ -33,11 +32,10 @@ class EggGroup; class EggPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : EggVertex -// Description : Any one-, two-, three-, or four-component vertex, -// possibly with attributes such as a normal. -//////////////////////////////////////////////////////////////////// +/** + * Any one-, two-, three-, or four-component vertex, possibly with attributes + * such as a normal. + */ class EXPCL_PANDAEGG EggVertex : public EggObject, public EggAttributes { public: typedef pset GroupRef; @@ -64,20 +62,19 @@ PUBLISHED: INLINE bool is_forward_reference() const; - // The pos might have 1, 2, 3, or 4 dimensions. That complicates - // things a bit. + // The pos might have 1, 2, 3, or 4 dimensions. That complicates things a + // bit. INLINE void set_pos(double pos); INLINE void set_pos(const LPoint2d &pos); INLINE void set_pos(const LPoint3d &pos); INLINE void set_pos(const LPoint4d &pos); INLINE void set_pos4(const LPoint4d &pos); - // get_pos[123] return the pos as the corresponding type. It is an - // error to call any of these without first verifying that - // get_num_dimensions() matches the desired type. However, - // get_pos4() may always be called; it returns the pos as a - // four-component point in homogeneous space (with a 1.0 in the last - // position if the pos has fewer than four components). + // get_pos[123] return the pos as the corresponding type. It is an error to + // call any of these without first verifying that get_num_dimensions() + // matches the desired type. However, get_pos4() may always be called; it + // returns the pos as a four-component point in homogeneous space (with a + // 1.0 in the last position if the pos has fewer than four components). INLINE int get_num_dimensions() const; INLINE double get_pos1() const; INLINE LPoint2d get_pos2() const; @@ -209,13 +206,11 @@ INLINE ostream &operator << (ostream &out, const EggVertex &vert) { return out; } -//////////////////////////////////////////////////////////////////// -// Class : UniqueEggVertices -// Description : An STL function object for sorting vertices into -// order by properties. Returns true if the two -// referenced EggVertex pointers are in sorted order, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object for sorting vertices into order by properties. + * Returns true if the two referenced EggVertex pointers are in sorted order, + * false otherwise. + */ class EXPCL_PANDAEGG UniqueEggVertices { public: INLINE bool operator ()(const EggVertex *v1, const EggVertex *v2) const; @@ -224,6 +219,3 @@ public: #include "eggVertex.I" #endif - - - diff --git a/panda/src/egg/eggVertexAux.I b/panda/src/egg/eggVertexAux.I index 315358da8b..40a41e26ac 100644 --- a/panda/src/egg/eggVertexAux.I +++ b/panda/src/egg/eggVertexAux.I @@ -1,43 +1,35 @@ -// Filename: eggVertexAux.I -// Created by: jenes (15Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexAux.I + * @author jenes + * @date 2011-11-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexAux:: set_name(const string &name) { Namable::set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::get_aux -// Access: Published -// Description: Returns the auxiliary data quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Returns the auxiliary data quadruple. + */ INLINE const LVecBase4d &EggVertexAux:: get_aux() const { return _aux; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::set_aux -// Access: Published -// Description: Sets the auxiliary data quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Sets the auxiliary data quadruple. + */ INLINE void EggVertexAux:: set_aux(const LVecBase4d &aux) { _aux = aux; diff --git a/panda/src/egg/eggVertexAux.cxx b/panda/src/egg/eggVertexAux.cxx index 1f839a21fd..ec6528e380 100644 --- a/panda/src/egg/eggVertexAux.cxx +++ b/panda/src/egg/eggVertexAux.cxx @@ -1,16 +1,15 @@ -// Filename: eggVertexAux.cxx -// Created by: jenes (15Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexAux.cxx + * @author jenes + * @date 2011-11-15 + */ #include "eggVertexAux.h" #include "eggParameters.h" @@ -19,11 +18,9 @@ TypeHandle EggVertexAux::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexAux:: EggVertexAux(const string &name, const LVecBase4d &aux) : EggNamedObject(name), @@ -31,11 +28,9 @@ EggVertexAux(const string &name, const LVecBase4d &aux) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexAux:: EggVertexAux(const EggVertexAux ©) : EggNamedObject(copy), @@ -43,11 +38,9 @@ EggVertexAux(const EggVertexAux ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexAux &EggVertexAux:: operator = (const EggVertexAux ©) { EggNamedObject::operator = (copy); @@ -56,22 +49,17 @@ operator = (const EggVertexAux ©) { return (*this); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexAux:: ~EggVertexAux() { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::make_average -// Access: Published, Static -// Description: Creates a new EggVertexAux that contains the -// averaged values of the two given objects. It is -// an error if they don't have the same name. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new EggVertexAux that contains the averaged values of the two + * given objects. It is an error if they don't have the same name. + */ PT(EggVertexAux) EggVertexAux:: make_average(const EggVertexAux *first, const EggVertexAux *second) { nassertr(first->get_name() == second->get_name(), NULL); @@ -80,11 +68,9 @@ make_average(const EggVertexAux *first, const EggVertexAux *second) { return new EggVertexAux(first->get_name(), aux); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggVertexAux:: write(ostream &out, int indent_level) const { string inline_name = get_name(); @@ -95,13 +81,10 @@ write(ostream &out, int indent_level) const { << " " << inline_name << "{ " << get_aux() << " }\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexAux::compare_to -// Access: Public -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + */ int EggVertexAux:: compare_to(const EggVertexAux &other) const { int compare; diff --git a/panda/src/egg/eggVertexAux.h b/panda/src/egg/eggVertexAux.h index 7d3aac7483..1d87fe8ad5 100644 --- a/panda/src/egg/eggVertexAux.h +++ b/panda/src/egg/eggVertexAux.h @@ -1,16 +1,15 @@ -// Filename: eggVertexAux.h -// Created by: jenes (15Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexAux.h + * @author jenes + * @date 2011-11-15 + */ #ifndef EGGVERTEXAUX_H #define EGGVERTEXAUX_H @@ -22,14 +21,12 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggVertexAux -// Description : The set of named auxiliary data that may or may not -// be assigned to a vertex. Panda will import this data -// and create a custom column for it in the vertex data, -// but will not otherwise interpret it. Presumably, a -// shader will process the data later. -//////////////////////////////////////////////////////////////////// +/** + * The set of named auxiliary data that may or may not be assigned to a + * vertex. Panda will import this data and create a custom column for it in + * the vertex data, but will not otherwise interpret it. Presumably, a shader + * will process the data later. + */ class EXPCL_PANDAEGG EggVertexAux : public EggNamedObject { PUBLISHED: EggVertexAux(const string &name, const LVecBase4d &aux); @@ -72,4 +69,3 @@ private: #include "eggVertexAux.I" #endif - diff --git a/panda/src/egg/eggVertexPool.I b/panda/src/egg/eggVertexPool.I index b883ec8108..3a13278063 100644 --- a/panda/src/egg/eggVertexPool.I +++ b/panda/src/egg/eggVertexPool.I @@ -1,66 +1,51 @@ -// Filename: eggVertexPool.I -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexPool.I + * @author drose + * @date 1999-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_vertex -// Access: Public -// Description: Returns true if the indicated vertex has been defined -// in the vertex pool, false otherwise. This does not -// include forward references. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated vertex has been defined in the vertex pool, + * false otherwise. This does not include forward references. + */ INLINE bool EggVertexPool:: has_vertex(int index) const { return get_vertex(index) != (EggVertex *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::indexing operator -// Access: Public -// Description: Returns the vertex in the pool with the indicated -// index number, or NULL if no vertices have that index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex in the pool with the indicated index number, or NULL if + * no vertices have that index number. + */ INLINE EggVertex *EggVertexPool:: operator [](int index) const { return get_vertex(index); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::make_new_vertex() -// Access: Public -// Description: Allocates and returns a new vertex from the pool. -// This is one of three ways to add new vertices to a -// vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the pool. This is one of three + * ways to add new vertices to a vertex pool. + */ INLINE EggVertex *EggVertexPool:: make_new_vertex() { PT(EggVertex) vertex = new EggVertex; return add_vertex(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::make_new_vertex() -// Access: Public -// Description: Allocates and returns a new vertex from the pool. -// This is one of three ways to add new vertices to a -// vertex pool. -// -// This flavor of make_new_vertex() explicitly sets the -// vertex position as it is allocated. It does not -// attempt to share vertices. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the pool. This is one of three + * ways to add new vertices to a vertex pool. + * + * This flavor of make_new_vertex() explicitly sets the vertex position as it + * is allocated. It does not attempt to share vertices. + */ INLINE EggVertex *EggVertexPool:: make_new_vertex(double pos) { EggVertex *vertex = make_new_vertex(); @@ -68,17 +53,13 @@ make_new_vertex(double pos) { return vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::make_new_vertex() -// Access: Public -// Description: Allocates and returns a new vertex from the pool. -// This is one of three ways to add new vertices to a -// vertex pool. -// -// This flavor of make_new_vertex() explicitly sets the -// vertex position as it is allocated. It does not -// attempt to share vertices. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the pool. This is one of three + * ways to add new vertices to a vertex pool. + * + * This flavor of make_new_vertex() explicitly sets the vertex position as it + * is allocated. It does not attempt to share vertices. + */ INLINE EggVertex *EggVertexPool:: make_new_vertex(const LPoint2d &pos) { EggVertex *vertex = make_new_vertex(); @@ -86,17 +67,13 @@ make_new_vertex(const LPoint2d &pos) { return vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::make_new_vertex() -// Access: Public -// Description: Allocates and returns a new vertex from the pool. -// This is one of three ways to add new vertices to a -// vertex pool. -// -// This flavor of make_new_vertex() explicitly sets the -// vertex position as it is allocated. It does not -// attempt to share vertices. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the pool. This is one of three + * ways to add new vertices to a vertex pool. + * + * This flavor of make_new_vertex() explicitly sets the vertex position as it + * is allocated. It does not attempt to share vertices. + */ INLINE EggVertex *EggVertexPool:: make_new_vertex(const LPoint3d &pos) { EggVertex *vertex = make_new_vertex(); @@ -104,17 +81,13 @@ make_new_vertex(const LPoint3d &pos) { return vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::make_new_vertex() -// Access: Public -// Description: Allocates and returns a new vertex from the pool. -// This is one of three ways to add new vertices to a -// vertex pool. -// -// This flavor of make_new_vertex() explicitly sets the -// vertex position as it is allocated. It does not -// attempt to share vertices. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the pool. This is one of three + * ways to add new vertices to a vertex pool. + * + * This flavor of make_new_vertex() explicitly sets the vertex position as it + * is allocated. It does not attempt to share vertices. + */ INLINE EggVertex *EggVertexPool:: make_new_vertex(const LPoint4d &pos) { EggVertex *vertex = make_new_vertex(); diff --git a/panda/src/egg/eggVertexPool.cxx b/panda/src/egg/eggVertexPool.cxx index a3d35cb1d9..f1783d8158 100644 --- a/panda/src/egg/eggVertexPool.cxx +++ b/panda/src/egg/eggVertexPool.cxx @@ -1,16 +1,15 @@ -// Filename: eggVertexPool.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexPool.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggVertexPool.h" #include "eggPrimitive.h" @@ -23,24 +22,19 @@ TypeHandle EggVertexPool::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexPool:: EggVertexPool(const string &name) : EggNode(name) { _highest_index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::Copy Constructor -// Access: Public -// Description: Copying a vertex pool is of questionable value, since -// it will copy all of the vertices and assign new -// pointers to them all. There will be no polygons -// referring to the new vertices. -//////////////////////////////////////////////////////////////////// +/** + * Copying a vertex pool is of questionable value, since it will copy all of + * the vertices and assign new pointers to them all. There will be no + * polygons referring to the new vertices. + */ EggVertexPool:: EggVertexPool(const EggVertexPool ©) : EggNode(copy) { iterator i; @@ -50,11 +44,9 @@ EggVertexPool(const EggVertexPool ©) : EggNode(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexPool:: ~EggVertexPool() { // Remove all vertices from the pool when it destructs. @@ -79,13 +71,10 @@ EggVertexPool:: _unique_vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_forward_vertices -// Access: Published -// Description: Returns true if any vertices in the pool are -// undefined forward-reference vertices, false if all -// vertices are defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertices in the pool are undefined forward-reference + * vertices, false if all vertices are defined. + */ bool EggVertexPool:: has_forward_vertices() const { IndexVertices::const_iterator ivi; @@ -99,13 +88,10 @@ has_forward_vertices() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_defined_vertices -// Access: Published -// Description: Returns true if any vertices in the pool are -// fully defined vertices, false if all vertices are -// forward references. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertices in the pool are fully defined vertices, false + * if all vertices are forward references. + */ bool EggVertexPool:: has_defined_vertices() const { IndexVertices::const_iterator ivi; @@ -119,13 +105,10 @@ has_defined_vertices() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_vertex -// Access: Public -// Description: Returns the vertex in the pool with the indicated -// index number, or NULL if no vertices have that index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex in the pool with the indicated index number, or NULL if + * no vertices have that index number. + */ EggVertex *EggVertexPool:: get_vertex(int index) const { IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -141,16 +124,13 @@ get_vertex(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_forward_vertex -// Access: Public -// Description: Returns the vertex in the pool with the indicated -// index number. If there is not a vertex in the pool -// with the indicated index number, creates a special -// forward-reference EggVertex that has no data, on the -// assumption that the vertex pool has not yet been -// fully read and more data will be available later. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex in the pool with the indicated index number. If there + * is not a vertex in the pool with the indicated index number, creates a + * special forward-reference EggVertex that has no data, on the assumption + * that the vertex pool has not yet been fully read and more data will be + * available later. + */ EggVertex *EggVertexPool:: get_forward_vertex(int index) { nassertr(index >= 0, NULL); @@ -166,38 +146,29 @@ get_forward_vertex(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_highest_index -// Access: Public -// Description: Returns the highest index number used by any vertex -// in the pool (except forward references). Returns -1 -// if the pool is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns the highest index number used by any vertex in the pool (except + * forward references). Returns -1 if the pool is empty. + */ int EggVertexPool:: get_highest_index() const { return _highest_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::set_highest_index -// Access: Public -// Description: Artificially changes the "highest index number", so -// that a newly created vertex will begin at this number -// plus 1. This can be used to default a vertex pool to -// start counting at 1 (or any other index number), -// instead of the default of 0. Use with caution. -//////////////////////////////////////////////////////////////////// +/** + * Artificially changes the "highest index number", so that a newly created + * vertex will begin at this number plus 1. This can be used to default a + * vertex pool to start counting at 1 (or any other index number), instead of + * the default of 0. Use with caution. + */ void EggVertexPool:: set_highest_index(int highest_index) { _highest_index = highest_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_num_dimensions -// Access: Public -// Description: Returns the maximum number of dimensions used by any -// vertex in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of dimensions used by any vertex in the pool. + */ int EggVertexPool:: get_num_dimensions() const { int num_dimensions = 0; @@ -211,12 +182,10 @@ get_num_dimensions() const { return num_dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_normals -// Access: Public -// Description: Returns true if any vertex in the pool has a normal -// defined, false if none of them do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex in the pool has a normal defined, false if none + * of them do. + */ bool EggVertexPool:: has_normals() const { IndexVertices::const_iterator ivi; @@ -230,12 +199,10 @@ has_normals() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_colors -// Access: Public -// Description: Returns true if any vertex in the pool has a color -// defined, false if none of them do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex in the pool has a color defined, false if none + * of them do. + */ bool EggVertexPool:: has_colors() const { IndexVertices::const_iterator ivi; @@ -249,19 +216,16 @@ has_colors() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_nonwhite_colors -// Access: Public -// Description: Returns true if any vertex in the pool has a color -// defined other than white, false if no vertices have -// colors, or if all colors are white. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex in the pool has a color defined other than + * white, false if no vertices have colors, or if all colors are white. + */ bool EggVertexPool:: has_nonwhite_colors() const { IndexVertices::const_iterator ivi; for (ivi = _index_vertices.begin(); ivi != _index_vertices.end(); ++ivi) { EggVertex *vertex = (*ivi).second; - if (vertex->has_color() && + if (vertex->has_color() && (vertex->get_color() != LColor(1.0, 1.0, 1.0, 1.0) || !vertex->_drgbas.empty())) { return true; @@ -271,17 +235,13 @@ has_nonwhite_colors() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::check_overall_color -// Access: Public -// Description: Scans the vertex pool for different colors on -// different vertices. If all vertices are the same -// color, sets has_overall_color to true and fills the -// color into overall_color. If no vertices have any -// color, set has_overall_color to true and fills white -// into overall_color. If at least two vertices have -// different colors, sets has_overall_color to false. -//////////////////////////////////////////////////////////////////// +/** + * Scans the vertex pool for different colors on different vertices. If all + * vertices are the same color, sets has_overall_color to true and fills the + * color into overall_color. If no vertices have any color, set + * has_overall_color to true and fills white into overall_color. If at least + * two vertices have different colors, sets has_overall_color to false. + */ void EggVertexPool:: check_overall_color(bool &has_overall_color, LColor &overall_color) const { if (empty()) { @@ -308,12 +268,10 @@ check_overall_color(bool &has_overall_color, LColor &overall_color) const { has_overall_color = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_uvs -// Access: Public -// Description: Returns true if any vertex in the pool has a uv -// defined, false if none of them do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex in the pool has a uv defined, false if none of + * them do. + */ bool EggVertexPool:: has_uvs() const { IndexVertices::const_iterator ivi; @@ -327,12 +285,10 @@ has_uvs() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::has_aux -// Access: Public -// Description: Returns true if any vertex in the pool has -// auxiliary data defined, false if none of them do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any vertex in the pool has auxiliary data defined, false if + * none of them do. + */ bool EggVertexPool:: has_aux() const { IndexVertices::const_iterator ivi; @@ -346,19 +302,15 @@ has_aux() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_uv_names -// Access: Public -// Description: Returns the list of UV names that are defined by any -// vertices in the pool, as well as the subset of UV -// names that actually define 3-d texture coordinates -// ("uvw_names"). Also returns the subset of UV/UVW -// names that define a tangent and binormal. It is the -// user's responsibility to clear both vectors before -// calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of UV names that are defined by any vertices in the pool, + * as well as the subset of UV names that actually define 3-d texture + * coordinates ("uvw_names"). Also returns the subset of UV/UVW names that + * define a tangent and binormal. It is the user's responsibility to clear + * both vectors before calling this method. + */ void EggVertexPool:: -get_uv_names(vector_string &uv_names, vector_string &uvw_names, +get_uv_names(vector_string &uv_names, vector_string &uvw_names, vector_string &tbn_names) const { pset uv_names_set, uvw_names_set, tbn_names_set; IndexVertices::const_iterator ivi; @@ -389,12 +341,10 @@ get_uv_names(vector_string &uv_names, vector_string &uvw_names, } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::get_aux_names -// Access: Public -// Description: Returns the list of auxiliary data names that are -// defined by any vertices in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of auxiliary data names that are defined by any vertices + * in the pool. + */ void EggVertexPool:: get_aux_names(vector_string &aux_names) const { pset aux_names_set; @@ -414,12 +364,10 @@ get_aux_names(vector_string &aux_names) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::begin() -// Access: Public -// Description: Returns an iterator that can be used to traverse -// through all the vertices in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can be used to traverse through all the vertices + * in the pool. + */ EggVertexPool::iterator EggVertexPool:: begin() const { nassertr(_index_vertices.size() == _unique_vertices.size(), @@ -427,59 +375,46 @@ begin() const { return iterator(_index_vertices.begin()); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::end() -// Access: Public -// Description: Returns an iterator that can be used to traverse -// through all the vertices in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that can be used to traverse through all the vertices + * in the pool. + */ EggVertexPool::iterator EggVertexPool:: end() const { return iterator(_index_vertices.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::empty() -// Access: Public -// Description: Returns true if the pool is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pool is empty. + */ bool EggVertexPool:: empty() const { return _index_vertices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::size() -// Access: Public -// Description: Returns the number of vertices in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the pool. + */ EggVertexPool::size_type EggVertexPool:: size() const { nassertr(_index_vertices.size() == _unique_vertices.size(), 0); return _index_vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::add_vertex -// Access: Public -// Description: Adds the indicated vertex to the pool. It is an -// error if the vertex is already a member of this or -// any other pool. The vertex must have been allocated -// from the free store; its pointer will now be owned by -// the vertex pool. If the index number is supplied, -// tries to assign that index number; it is an error if -// the index number is already in use. -// -// It is possible that a forward reference to this -// vertex was requested in the past; if so, the data -// from the supplied vertex is copied onto the forward -// reference, which becomes the actual vertex. In this -// case, a different pointer is saved (and returned) -// than the one actually passed in. In the usual case, -// however, the vertex pointer passed in is the one that -// is saved in the vertex pool and returned from this -// method. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated vertex to the pool. It is an error if the vertex is + * already a member of this or any other pool. The vertex must have been + * allocated from the free store; its pointer will now be owned by the vertex + * pool. If the index number is supplied, tries to assign that index number; + * it is an error if the index number is already in use. + * + * It is possible that a forward reference to this vertex was requested in the + * past; if so, the data from the supplied vertex is copied onto the forward + * reference, which becomes the actual vertex. In this case, a different + * pointer is saved (and returned) than the one actually passed in. In the + * usual case, however, the vertex pointer passed in is the one that is saved + * in the vertex pool and returned from this method. + */ EggVertex *EggVertexPool:: add_vertex(EggVertex *vertex, int index) { // Save a pointer to the vertex. @@ -510,7 +445,7 @@ add_vertex(EggVertex *vertex, int index) { // Oops, you duplicated a vertex index. nassertr(false, NULL); } - + _unique_vertices.insert(vertex); _index_vertices[index] = vertex; @@ -525,14 +460,11 @@ add_vertex(EggVertex *vertex, int index) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::create_unique_vertex -// Access: Public -// Description: Creates a new vertex in the pool that is a copy of -// the indicated one and returns it. If there is -// already a vertex in the pool like the indicated one, -// simply returns that one. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vertex in the pool that is a copy of the indicated one and + * returns it. If there is already a vertex in the pool like the indicated + * one, simply returns that one. + */ EggVertex *EggVertexPool:: create_unique_vertex(const EggVertex ©) { UniqueVertices::iterator uvi; @@ -547,14 +479,11 @@ create_unique_vertex(const EggVertex ©) { return add_vertex(new EggVertex(copy)); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::find_matching_vertex -// Access: Public -// Description: If the EggVertexPool already has a vertex matching -// the indicated vertex, returns it; otherwise, returns -// NULL. This is similar to create_unique_vertex() -// except that a new vertex is never created. -//////////////////////////////////////////////////////////////////// +/** + * If the EggVertexPool already has a vertex matching the indicated vertex, + * returns it; otherwise, returns NULL. This is similar to + * create_unique_vertex() except that a new vertex is never created. + */ EggVertex *EggVertexPool:: find_matching_vertex(const EggVertex ©) { UniqueVertices::iterator uvi; @@ -570,12 +499,10 @@ find_matching_vertex(const EggVertex ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::remove_vertex -// Access: Public -// Description: Removes the vertex from the pool. It is an error if -// the vertex is not already a member of the pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the vertex from the pool. It is an error if the vertex is not + * already a member of the pool. + */ void EggVertexPool:: remove_vertex(EggVertex *vertex) { // Make sure the vertex is already a member of this pool. @@ -605,10 +532,10 @@ remove_vertex(EggVertex *vertex) { } } - // Removing the vertex from the unique list is a bit trickier--there - // might be several other vertices that are considered identical to - // this one, and so we have to walk through all the identical - // vertices until we find the right one. + // Removing the vertex from the unique list is a bit trickier--there might + // be several other vertices that are considered identical to this one, and + // so we have to walk through all the identical vertices until we find the + // right one. UniqueVertices::iterator uvi; uvi = _unique_vertices.find(vertex); @@ -626,16 +553,12 @@ remove_vertex(EggVertex *vertex) { vertex->_pool = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::remove_unused_vertices -// Access: Public -// Description: Removes all vertices from the pool that are not -// referenced by at least one primitive. Also collapses -// together equivalent vertices, and renumbers all -// vertices after the operation so their indices are -// consecutive, beginning at zero. Returns the number -// of vertices removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices from the pool that are not referenced by at least one + * primitive. Also collapses together equivalent vertices, and renumbers all + * vertices after the operation so their indices are consecutive, beginning at + * zero. Returns the number of vertices removed. + */ int EggVertexPool:: remove_unused_vertices() { int num_removed = 0; @@ -653,14 +576,14 @@ remove_unused_vertices() { num_removed++; } else { - // The vertex *is* used somewhere. Is it identical to an - // existing vertex? + // The vertex *is* used somewhere. Is it identical to an existing + // vertex? UniqueVertices::iterator uvi; uvi = new_unique_vertices.find(vertex); if (uvi != new_unique_vertices.end()) { - // Yes, there's already another vertex just like this one. - // Redirect all the primitives currently referencing this - // vertex to reference the other one instead. + // Yes, there's already another vertex just like this one. Redirect + // all the primitives currently referencing this vertex to reference + // the other one instead. EggVertex *orig_vertex = (*uvi); EggVertex::PrimitiveRef pref = vertex->_pref; @@ -679,8 +602,7 @@ remove_unused_vertices() { num_removed++; } else { - // It's a unique vertex. Renumber it and add it to the new - // lists. + // It's a unique vertex. Renumber it and add it to the new lists. vertex->_index = new_index_vertices.size(); new_index_vertices.insert(IndexVertices::value_type(vertex->_index, vertex)); new_unique_vertices.insert(vertex); @@ -698,12 +620,10 @@ remove_unused_vertices() { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::add_unused_vertices_to_prim -// Access: Public -// Description: Adds all of the unused vertices in this vertex pool -// to the indicated primitive, in ascending order. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the unused vertices in this vertex pool to the indicated + * primitive, in ascending order. + */ void EggVertexPool:: add_unused_vertices_to_prim(EggPrimitive *prim) { IndexVertices::iterator ivi; @@ -723,26 +643,21 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::transform -// Access: Public -// Description: Applies the indicated transformation matrix to all -// the vertices. However, vertices that are attached to -// primitives that believe their vertices are in a local -// coordinate system are transformed only by the scale -// and rotation component. If a vertex happens to be -// attached both to a local and a global primitive, and -// the transformation includes a translation component, -// the vertex will be split. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation matrix to all the vertices. However, + * vertices that are attached to primitives that believe their vertices are in + * a local coordinate system are transformed only by the scale and rotation + * component. If a vertex happens to be attached both to a local and a global + * primitive, and the transformation includes a translation component, the + * vertex will be split. + */ void EggVertexPool:: transform(const LMatrix4d &mat) { LVector3d translation = mat.get_row3(3); if (translation == LVector3d(0.0, 0.0, 0.0)) { - // If the matrix does not have a translation component, we can - // treat the local and global vertices the same. This makes - // things much easier. + // If the matrix does not have a translation component, we can treat the + // local and global vertices the same. This makes things much easier. iterator i; for (i = begin(); i != end(); ++i) { EggVertex *vert = *i; @@ -750,13 +665,12 @@ transform(const LMatrix4d &mat) { } } else { - // The matrix does have a translation component. That means we - // have to treat the global and local vertices differently. - // Yucky. + // The matrix does have a translation component. That means we have to + // treat the global and local vertices differently. Yucky. - // First, transform the global vertices. Get a copy of the list - // of vertices in this pool. We must have a copy because we might - // be modifying the list as we traverse it. + // First, transform the global vertices. Get a copy of the list of + // vertices in this pool. We must have a copy because we might be + // modifying the list as we traverse it. typedef pvector Verts; Verts verts; @@ -790,8 +704,7 @@ transform(const LMatrix4d &mat) { EggVertex *vert = *i; if (vert->get_num_local_coord() != 0) { - // This should be guaranteed by the vertex-splitting logic - // above. + // This should be guaranteed by the vertex-splitting logic above. nassertv(vert->get_num_global_coord() == 0); vert->transform(local_mat); } @@ -813,14 +726,11 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::sort_by_external_index -// Access: Published -// Description: Re-orders (and re-numbers) the vertices in this -// vertex pool so that they appear in increasing order -// by the optional external_index that has been assigned -// to each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Re-orders (and re-numbers) the vertices in this vertex pool so that they + * appear in increasing order by the optional external_index that has been + * assigned to each vertex. + */ void EggVertexPool:: sort_by_external_index() { // Copy the vertices into a vector for sorting. @@ -847,12 +757,9 @@ sort_by_external_index() { _index_vertices.swap(new_index_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::write -// Access: Public -// Description: Writes the vertex pool to the indicated output stream -// in Egg format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vertex pool to the indicated output stream in Egg format. + */ void EggVertexPool:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -867,32 +774,25 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::r_transform -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform(). It applies a transformation matrix -// to the current node in some sensible way, then -// continues down the tree. -// -// The first matrix is the transformation to apply; the -// second is its inverse. The third parameter is the -// coordinate system we are changing to, or CS_default -// if we are not changing coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform(). It applies a + * transformation matrix to the current node in some sensible way, then + * continues down the tree. + * + * The first matrix is the transformation to apply; the second is its inverse. + * The third parameter is the coordinate system we are changing to, or + * CS_default if we are not changing coordinate systems. + */ void EggVertexPool:: r_transform(const LMatrix4d &mat, const LMatrix4d &, CoordinateSystem) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPool::r_transform_vertices -// Access: Protected, Virtual -// Description: This is called from within the egg code by -// transform_vertices_only()(). It applies a -// transformation matrix to the current node in some -// sensible way (if the current node is a vertex pool -// with vertices), then continues down the tree. -//////////////////////////////////////////////////////////////////// +/** + * This is called from within the egg code by transform_vertices_only()(). It + * applies a transformation matrix to the current node in some sensible way + * (if the current node is a vertex pool with vertices), then continues down + * the tree. + */ void EggVertexPool:: r_transform_vertices(const LMatrix4d &mat) { transform(mat); diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index 8fc34f83fb..71e3ac4798 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -1,16 +1,15 @@ -// Filename: eggVertexPool.h -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexPool.h + * @author drose + * @date 1999-01-16 + */ #ifndef EGGVERTEXPOOL_H #define EGGVERTEXPOOL_H @@ -28,38 +27,34 @@ #include "lmatrix.h" #include "iterator_types.h" -//////////////////////////////////////////////////////////////////// -// Class : EggVertexPool -// Description : A collection of vertices. There may be any number of -// vertex pools in a single egg structure. The vertices -// in a single pool need not necessarily have any -// connection to each other, but it is necessary that -// any one primitive (e.g. a polygon) must pull all its -// vertices from the same pool. -// -// An EggVertexPool is an STL-style container of -// pointers to EggVertex's. Functions add_vertex() and -// remove_vertex() are provided to manipulate the list. -// The list may also be operated on (read-only) via -// iterators and begin()/end(). -//////////////////////////////////////////////////////////////////// +/** + * A collection of vertices. There may be any number of vertex pools in a + * single egg structure. The vertices in a single pool need not necessarily + * have any connection to each other, but it is necessary that any one + * primitive (e.g. a polygon) must pull all its vertices from the same pool. + * + * An EggVertexPool is an STL-style container of pointers to EggVertex's. + * Functions add_vertex() and remove_vertex() are provided to manipulate the + * list. The list may also be operated on (read-only) via iterators and + * begin()/end(). + */ class EXPCL_PANDAEGG EggVertexPool : public EggNode { - // This is a bit of private interface stuff that must be here as a - // forward reference. This allows us to define the EggVertexPool as - // an STL container. + // This is a bit of private interface stuff that must be here as a forward + // reference. This allows us to define the EggVertexPool as an STL + // container. private: - // IndexVertices is the main storage mechanism of the vertex pool. - // It stores a reference-counting pointer to each vertex, ordered by - // vertex index number. + // IndexVertices is the main storage mechanism of the vertex pool. It + // stores a reference-counting pointer to each vertex, ordered by vertex + // index number. typedef pmap IndexVertices; - // UniqueVertices is an auxiliary indexing mechanism. It stores the - // same vertex pointers as IndexVertices (although these pointers - // are not reference-counted), this time ordered by vertex - // properties. This makes it easy to determine when one or more - // vertices already exist in the pool with identical properties. + // UniqueVertices is an auxiliary indexing mechanism. It stores the same + // vertex pointers as IndexVertices (although these pointers are not + // reference-counted), this time ordered by vertex properties. This makes + // it easy to determine when one or more vertices already exist in the pool + // with identical properties. typedef pmultiset UniqueVertices; public: @@ -97,7 +92,7 @@ PUBLISHED: void check_overall_color(bool &has_overall_color, LColor &overall_color) const; bool has_uvs() const; bool has_aux() const; - void get_uv_names(vector_string &uv_names, vector_string &uvw_names, + void get_uv_names(vector_string &uv_names, vector_string &uvw_names, vector_string &tbn_names) const; void get_aux_names(vector_string &aux_names) const; @@ -110,21 +105,20 @@ public: PUBLISHED: size_type size() const; - // add_vertex() adds a freshly-allocated vertex. It is up to the - // user to allocate the vertex. + // add_vertex() adds a freshly-allocated vertex. It is up to the user to + // allocate the vertex. EggVertex *add_vertex(EggVertex *vertex, int index = -1); - // make_new_vertex() allocates and returns a new vertex from the - // pool. + // make_new_vertex() allocates and returns a new vertex from the pool. INLINE EggVertex *make_new_vertex(); INLINE EggVertex *make_new_vertex(double pos); INLINE EggVertex *make_new_vertex(const LPoint2d &pos); INLINE EggVertex *make_new_vertex(const LPoint3d &pos); INLINE EggVertex *make_new_vertex(const LPoint4d &pos); - // create_unique_vertex() creates a new vertex if there is not - // already one identical to the indicated vertex, or returns the - // existing one if there is. + // create_unique_vertex() creates a new vertex if there is not already one + // identical to the indicated vertex, or returns the existing one if there + // is. EggVertex *create_unique_vertex(const EggVertex ©); EggVertex *find_matching_vertex(const EggVertex ©); diff --git a/panda/src/egg/eggVertexUV.I b/panda/src/egg/eggVertexUV.I index a49de4a36c..4eb9983d21 100644 --- a/panda/src/egg/eggVertexUV.I +++ b/panda/src/egg/eggVertexUV.I @@ -1,27 +1,21 @@ -// Filename: eggVertexUV.I -// Created by: drose (20Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexUV.I + * @author drose + * @date 2004-07-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::filter_name -// Access: Published, Static -// Description: Returns the actual name that should be set for a -// given name string. Usually this is the same string -// that is input, but for historical reasons the texture -// coordinate name "default" is mapped to the empty -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual name that should be set for a given name string. + * Usually this is the same string that is input, but for historical reasons + * the texture coordinate name "default" is mapped to the empty string. + */ INLINE string EggVertexUV:: filter_name(const string &name) { if (name == "default") { @@ -30,169 +24,134 @@ filter_name(const string &name) { return name; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexUV:: set_name(const string &name) { Namable::set_name(filter_name(name)); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::get_num_dimensions -// Access: Published -// Description: Returns the number of components of the texture -// coordinate set. This is either 2 (the normal case) -// or 3 (for a 3-d texture coordinate). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components of the texture coordinate set. This is + * either 2 (the normal case) or 3 (for a 3-d texture coordinate). + */ INLINE int EggVertexUV:: get_num_dimensions() const { return has_w() ? 3 : 2; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::has_w -// Access: Published -// Description: Returns true if the texture coordinate has a third, w -// component, false if it is just a normal 2-d texture -// coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture coordinate has a third, w component, false if + * it is just a normal 2-d texture coordinate. + */ INLINE bool EggVertexUV:: has_w() const { return (_flags & F_has_w) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::get_uv -// Access: Published -// Description: Returns the texture coordinate pair, if -// get_num_dimensions() is 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture coordinate pair, if get_num_dimensions() is 2. + */ INLINE LTexCoordd EggVertexUV:: get_uv() const { nassertr(!has_w(), LTexCoordd::zero()); return LTexCoordd(_uvw[0], _uvw[1]); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::get_uvw -// Access: Published -// Description: Returns the texture coordinate triple, if -// get_num_dimensions() is 3. This is also legal to -// call if get_num_dimensions() is 2 (but the last -// dimension will be zero). -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture coordinate triple, if get_num_dimensions() is 3. This + * is also legal to call if get_num_dimensions() is 2 (but the last dimension + * will be zero). + */ INLINE const LTexCoord3d &EggVertexUV:: get_uvw() const { return _uvw; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::set_uv -// Access: Published -// Description: Sets the texture coordinate pair. This makes the -// texture coordinate a 2-d texture coordinate, which is -// the usual case. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture coordinate pair. This makes the texture coordinate a 2-d + * texture coordinate, which is the usual case. + */ INLINE void EggVertexUV:: set_uv(const LTexCoordd &uv) { _uvw.set(uv[0], uv[1], 0.0); _flags &= ~F_has_w; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::set_uvw -// Access: Published -// Description: Sets the texture coordinate triple. This makes the -// texture coordinate a 3-d texture coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture coordinate triple. This makes the texture coordinate a + * 3-d texture coordinate. + */ INLINE void EggVertexUV:: set_uvw(const LTexCoord3d &uvw) { _uvw = uvw; _flags |= F_has_w; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::has_tangent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggVertexUV:: has_tangent() const { return (_flags & F_has_tangent) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::get_tangent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LNormald &EggVertexUV:: get_tangent() const { nassertr(has_tangent(), _tangent); return _tangent; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::set_tangent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexUV:: set_tangent(const LNormald &tangent) { _tangent = tangent; _flags |= F_has_tangent; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::clear_tangent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexUV:: clear_tangent() { _flags &= ~F_has_tangent; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::has_binormal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggVertexUV:: has_binormal() const { return (_flags & F_has_binormal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::get_binormal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LNormald &EggVertexUV:: get_binormal() const { nassertr(has_binormal(), _binormal); return _binormal; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::set_binormal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexUV:: set_binormal(const LNormald &binormal) { _binormal = binormal; _flags |= F_has_binormal; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::clear_binormal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggVertexUV:: clear_binormal() { _flags &= ~F_has_binormal; diff --git a/panda/src/egg/eggVertexUV.cxx b/panda/src/egg/eggVertexUV.cxx index 7d1aac7e91..ded4e39dd0 100644 --- a/panda/src/egg/eggVertexUV.cxx +++ b/panda/src/egg/eggVertexUV.cxx @@ -1,16 +1,15 @@ -// Filename: eggVertexUV.cxx -// Created by: drose (20Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexUV.cxx + * @author drose + * @date 2004-07-20 + */ #include "eggVertexUV.h" #include "eggParameters.h" @@ -19,11 +18,9 @@ TypeHandle EggVertexUV::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexUV:: EggVertexUV(const string &name, const LTexCoordd &uv) : EggNamedObject(name), @@ -35,11 +32,9 @@ EggVertexUV(const string &name, const LTexCoordd &uv) : } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexUV:: EggVertexUV(const string &name, const LTexCoord3d &uvw) : EggNamedObject(name), @@ -51,11 +46,9 @@ EggVertexUV(const string &name, const LTexCoord3d &uvw) : } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexUV:: EggVertexUV(const EggVertexUV ©) : EggNamedObject(copy), @@ -67,11 +60,9 @@ EggVertexUV(const EggVertexUV ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexUV &EggVertexUV:: operator = (const EggVertexUV ©) { EggNamedObject::operator = (copy); @@ -84,22 +75,17 @@ operator = (const EggVertexUV ©) { return (*this); } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexUV:: ~EggVertexUV() { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::make_average -// Access: Published, Static -// Description: Creates a new EggVertexUV that contains the -// averaged values of the two given objects. It is -// an error if they don't have the same name. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new EggVertexUV that contains the averaged values of the two + * given objects. It is an error if they don't have the same name. + */ PT(EggVertexUV) EggVertexUV:: make_average(const EggVertexUV *first, const EggVertexUV *second) { nassertr(first->get_name() == second->get_name(), NULL); @@ -118,13 +104,10 @@ make_average(const EggVertexUV *first, const EggVertexUV *second) { return new_obj; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::transform -// Access: Published, Virtual -// Description: Applies the indicated transformation matrix to the -// UV's tangent and/or binormal. This does nothing if -// there is no tangent or binormal. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transformation matrix to the UV's tangent and/or + * binormal. This does nothing if there is no tangent or binormal. + */ void EggVertexUV:: transform(const LMatrix4d &mat) { if (has_tangent()) { @@ -137,11 +120,9 @@ transform(const LMatrix4d &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggVertexUV:: write(ostream &out, int indent_level) const { string inline_name = get_name(); @@ -177,13 +158,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexUV::compare_to -// Access: Public -// Description: An ordering operator to compare two vertices for -// sorting order. This imposes an arbitrary ordering -// useful to identify unique vertices. -//////////////////////////////////////////////////////////////////// +/** + * An ordering operator to compare two vertices for sorting order. This + * imposes an arbitrary ordering useful to identify unique vertices. + */ int EggVertexUV:: compare_to(const EggVertexUV &other) const { if (_flags != other._flags) { diff --git a/panda/src/egg/eggVertexUV.h b/panda/src/egg/eggVertexUV.h index d250e9f58e..8a5bbc03a7 100644 --- a/panda/src/egg/eggVertexUV.h +++ b/panda/src/egg/eggVertexUV.h @@ -1,16 +1,15 @@ -// Filename: eggVertexUV.h -// Created by: drose (20Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexUV.h + * @author drose + * @date 2004-07-20 + */ #ifndef EGGVERTEXUV_H #define EGGVERTEXUV_H @@ -22,13 +21,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggVertexUV -// Description : The set of UV's that may or may not be assigned to a -// vertex. To support multitexturing, there may be -// multiple sets of UV's on a particular vertex, each -// with its own name. -//////////////////////////////////////////////////////////////////// +/** + * The set of UV's that may or may not be assigned to a vertex. To support + * multitexturing, there may be multiple sets of UV's on a particular vertex, + * each with its own name. + */ class EXPCL_PANDAEGG EggVertexUV : public EggNamedObject { PUBLISHED: EggVertexUV(const string &name, const LTexCoordd &uv); @@ -100,4 +97,3 @@ private: #include "eggVertexUV.I" #endif - diff --git a/panda/src/egg/eggXfmAnimData.I b/panda/src/egg/eggXfmAnimData.I index c27e6d132d..41bbaaa103 100644 --- a/panda/src/egg/eggXfmAnimData.I +++ b/panda/src/egg/eggXfmAnimData.I @@ -1,34 +1,28 @@ -// Filename: eggXfmAnimData.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmAnimData.I + * @author drose + * @date 1999-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmAnimData:: EggXfmAnimData(const string &name, CoordinateSystem cs) : EggAnimData(name) { _coordsys = cs; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmAnimData:: EggXfmAnimData(const EggXfmAnimData ©) : EggAnimData(copy), @@ -38,11 +32,9 @@ EggXfmAnimData(const EggXfmAnimData ©) } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmAnimData &EggXfmAnimData:: operator = (const EggXfmAnimData ©) { EggAnimData::operator = (copy); @@ -54,41 +46,33 @@ operator = (const EggXfmAnimData ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::set_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmAnimData:: set_order(const string &order) { _order = order; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::clear_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmAnimData:: clear_order() { _order = ""; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::has_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggXfmAnimData:: has_order() const { return !_order.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &EggXfmAnimData:: get_order() const { if (has_order()) { @@ -98,81 +82,64 @@ get_order() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_standard_order -// Access: Public, Static -// Description: Returns the standard order of matrix component -// composition. This is what the order string must be -// set to in order to use set_value() or add_data() -// successfully. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard order of matrix component composition. This is what + * the order string must be set to in order to use set_value() or add_data() + * successfully. + */ INLINE const string &EggXfmAnimData:: get_standard_order() { return EggXfmSAnim::get_standard_order(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::set_contents -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmAnimData:: set_contents(const string &contents) { _contents = contents; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::clear_contents -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmAnimData:: clear_contents() { _contents = ""; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::has_contents -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggXfmAnimData:: has_contents() const { return !_contents.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_contents -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &EggXfmAnimData:: get_contents() const { return _contents; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_coordinate_system -// Access: Public -// Description: Returns the coordinate system this table believes it -// is defined within. This should always match the -// coordinate system of the EggData structure that owns -// it. It is necessary to store it here because the -// meaning of the h, p, and r columns depends on the -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system this table believes it is defined within. + * This should always match the coordinate system of the EggData structure + * that owns it. It is necessary to store it here because the meaning of the + * h, p, and r columns depends on the coordinate system. + */ INLINE CoordinateSystem EggXfmAnimData:: get_coordinate_system() const { return _coordsys; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_num_rows -// Access: Public -// Description: Returns the number of rows in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows in the table. + */ INLINE int EggXfmAnimData:: get_num_rows() const { if (get_num_cols() == 0) { @@ -181,26 +148,20 @@ get_num_rows() const { return get_size() / get_num_cols(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_num_cols -// Access: Public -// Description: Returns the number of columns in the table. This is -// set according to the "contents" string, which defines -// the meaning of each column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of columns in the table. This is set according to the + * "contents" string, which defines the meaning of each column. + */ INLINE int EggXfmAnimData:: get_num_cols() const { return _contents.length(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_value -// Access: Public -// Description: Returns the value at the indicated row. Row must be -// in the range 0 <= row < get_num_rows(); col must be -// in the range 0 <= col < get_num_cols(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value at the indicated row. Row must be in the range 0 <= row + * < get_num_rows(); col must be in the range 0 <= col < get_num_cols(). + */ INLINE double EggXfmAnimData:: get_value(int row, int col) const { nassertr(get_num_cols() != 0, 0.0); @@ -208,5 +169,3 @@ get_value(int row, int col) const { nassertr(col >= 0 && col < get_num_cols(), 0.0); return _data[row * get_num_cols() + col]; } - - diff --git a/panda/src/egg/eggXfmAnimData.cxx b/panda/src/egg/eggXfmAnimData.cxx index d1ae40fbb5..62ed89f1c3 100644 --- a/panda/src/egg/eggXfmAnimData.cxx +++ b/panda/src/egg/eggXfmAnimData.cxx @@ -1,16 +1,15 @@ -// Filename: eggXfmAnimData.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmAnimData.cxx + * @author drose + * @date 1999-02-19 + */ #include "eggXfmAnimData.h" #include "eggXfmSAnim.h" @@ -27,12 +26,9 @@ TypeHandle EggXfmAnimData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::Conversion constructor -// Access: Public -// Description: Converts the newer-style XfmSAnim table to the -// older-style XfmAnim table. -//////////////////////////////////////////////////////////////////// +/** + * Converts the newer-style XfmSAnim table to the older-style XfmAnim table. + */ EggXfmAnimData:: EggXfmAnimData(const EggXfmSAnim &convert_from) : EggAnimData(convert_from.get_name()) @@ -45,9 +41,9 @@ EggXfmAnimData(const EggXfmSAnim &convert_from) } _coordsys = convert_from.get_coordinate_system(); - // First, get the table names so we know how to build up our - // contents string. Also store up the SAnim tables themselves in a - // temporary vector for convenience. + // First, get the table names so we know how to build up our contents + // string. Also store up the SAnim tables themselves in a temporary vector + // for convenience. pvector subtables; @@ -80,14 +76,11 @@ EggXfmAnimData(const EggXfmSAnim &convert_from) } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::get_value -// Access: Public -// Description: Returns the value of the aggregate row of the table -// as a matrix. This is a convenience function that -// treats the 2-d table as if it were a single table of -// matrices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the aggregate row of the table as a matrix. This is a + * convenience function that treats the 2-d table as if it were a single table + * of matrices. + */ void EggXfmAnimData:: get_value(int row, LMatrix4d &mat) const { LVector3d scale(1.0, 1.0, 1.0); @@ -114,11 +107,11 @@ get_value(int row, LMatrix4d &mat) const { case 'a': shear[0] = value; break; - + case 'b': shear[1] = value; break; - + case 'c': shear[2] = value; break; @@ -158,23 +151,18 @@ get_value(int row, LMatrix4d &mat) const { _coordsys); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::is_anim_matrix -// Access: Public, Virtual -// Description: Returns true if this node represents a table of -// animation transformation data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents a table of animation transformation + * data, false otherwise. + */ bool EggXfmAnimData:: is_anim_matrix() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::write -// Access: Public, Virtual -// Description: Writes the data to the indicated output stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the data to the indicated output stream in Egg format. + */ void EggXfmAnimData:: write(ostream &out, int indent_level) const { write_header(out, indent_level, ""); @@ -201,24 +189,20 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::r_transform -// Access: Protected, Virtual -// Description: Applies the indicated transform to all the rows of -// the table. This actually forces the generation of a -// totally new set of rows. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform to all the rows of the table. This + * actually forces the generation of a totally new set of rows. + */ void EggXfmAnimData:: r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) { - // We need to build an inverse matrix that doesn't reflect the - // translation component. + // We need to build an inverse matrix that doesn't reflect the translation + // component. LMatrix4d inv1 = inv; inv1.set_row(3, LVector3d(0.0, 0.0, 0.0)); - // Now we build a temporary copy of the table as an EggXfmSAnim. We - // do this because this kind of table is easier to build and - // optimize. + // Now we build a temporary copy of the table as an EggXfmSAnim. We do this + // because this kind of table is easier to build and optimize. if (to_cs == CS_default) { to_cs = _coordsys; @@ -263,9 +247,8 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, << "\n trans: " << trans << "\n"; } - // If this assertion fails, we attempted to transform by non-affine - // matrix or some such thing that cannot be represented in an anim - // file. + // If this assertion fails, we attempted to transform by non-affine matrix + // or some such thing that cannot be represented in an anim file. nassertv(result); } @@ -277,15 +260,12 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, (*this) = copy_table; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmAnimData::r_mark_coordsys -// Access: Protected, Virtual -// Description: This is only called immediately after loading an egg -// file from disk, to propagate the value found in the -// CoordinateSystem entry (or the default Y-up -// coordinate system) to all nodes that care about what -// the coordinate system is. -//////////////////////////////////////////////////////////////////// +/** + * This is only called immediately after loading an egg file from disk, to + * propagate the value found in the CoordinateSystem entry (or the default + * Y-up coordinate system) to all nodes that care about what the coordinate + * system is. + */ void EggXfmAnimData:: r_mark_coordsys(CoordinateSystem cs) { _coordsys = cs; diff --git a/panda/src/egg/eggXfmAnimData.h b/panda/src/egg/eggXfmAnimData.h index e81fd53e25..ab4d485481 100644 --- a/panda/src/egg/eggXfmAnimData.h +++ b/panda/src/egg/eggXfmAnimData.h @@ -1,16 +1,15 @@ -// Filename: eggXfmAnimData.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmAnimData.h + * @author drose + * @date 1999-02-19 + */ #ifndef EGGXFMANIMDATA_H #define EGGXFMANIMDATA_H @@ -21,14 +20,12 @@ #include "eggXfmSAnim.h" -//////////////////////////////////////////////////////////////////// -// Class : EggXfmAnimData -// Description : Corresponding to an entry, this stores a -// two-dimensional table with up to nine columns, one -// for each component of a transformation. This is an -// older syntax of egg anim table, not often used -// currently--it's replaced by EggXfmSAnim. -//////////////////////////////////////////////////////////////////// +/** + * Corresponding to an entry, this stores a two-dimensional table + * with up to nine columns, one for each component of a transformation. This + * is an older syntax of egg anim table, not often used currently--it's + * replaced by EggXfmSAnim. + */ class EXPCL_PANDAEGG EggXfmAnimData : public EggAnimData { PUBLISHED: INLINE EggXfmAnimData(const string &name = "", @@ -92,4 +89,3 @@ private: #include "eggXfmAnimData.I" #endif - diff --git a/panda/src/egg/eggXfmSAnim.I b/panda/src/egg/eggXfmSAnim.I index fef8704140..a16a7ef2cb 100644 --- a/panda/src/egg/eggXfmSAnim.I +++ b/panda/src/egg/eggXfmSAnim.I @@ -1,23 +1,19 @@ -// Filename: eggXfmSAnim.I -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmSAnim.I + * @author drose + * @date 1999-02-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmSAnim:: EggXfmSAnim(const string &name, CoordinateSystem cs) : EggGroupNode(name) { _has_fps = false; @@ -25,11 +21,9 @@ EggXfmSAnim(const string &name, CoordinateSystem cs) : EggGroupNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmSAnim:: EggXfmSAnim(const EggXfmSAnim ©) : EggGroupNode(copy), @@ -40,11 +34,9 @@ EggXfmSAnim(const EggXfmSAnim ©) } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggXfmSAnim &EggXfmSAnim:: operator = (const EggXfmSAnim ©) { EggGroupNode::operator = (copy); @@ -57,11 +49,9 @@ operator = (const EggXfmSAnim ©) { } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::set_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmSAnim:: set_fps(double fps) { _fps = fps; @@ -69,72 +59,58 @@ set_fps(double fps) { } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::clear_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmSAnim:: clear_fps() { _has_fps = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::has_fps -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggXfmSAnim:: has_fps() const { return _has_fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_fps -// Access: Public -// Description: This is only valid if has_fps() returns true. -//////////////////////////////////////////////////////////////////// +/** + * This is only valid if has_fps() returns true. + */ INLINE double EggXfmSAnim:: get_fps() const { nassertr(has_fps(), 0.0); return _fps; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::set_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmSAnim:: set_order(const string &order) { _order = order; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::clear_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggXfmSAnim:: clear_order() { _order = ""; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::has_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggXfmSAnim:: has_order() const { return !_order.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_order -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &EggXfmSAnim:: get_order() const { if (has_order()) { @@ -144,40 +120,31 @@ get_order() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_standard_order -// Access: Public, Static -// Description: Returns the standard order of matrix component -// composition. This is what the order string must be -// set to in order to use set_value() or add_data() -// successfully. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard order of matrix component composition. This is what + * the order string must be set to in order to use set_value() or add_data() + * successfully. + */ INLINE const string &EggXfmSAnim:: get_standard_order() { return _standard_order; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_coordinate_system -// Access: Public -// Description: Returns the coordinate system this table believes it -// is defined within. This should always match the -// coordinate system of the EggData structure that owns -// it. It is necessary to store it here because the -// meaning of the h, p, and r columns depends on the -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system this table believes it is defined within. + * This should always match the coordinate system of the EggData structure + * that owns it. It is necessary to store it here because the meaning of the + * h, p, and r columns depends on the coordinate system. + */ INLINE CoordinateSystem EggXfmSAnim:: get_coordinate_system() const { return _coordsys; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::clear_data -// Access: Public -// Description: Removes all data from the table. It does this by -// removing all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Removes all data from the table. It does this by removing all of its + * children. + */ INLINE void EggXfmSAnim:: clear_data() { EggGroupNode::clear(); diff --git a/panda/src/egg/eggXfmSAnim.cxx b/panda/src/egg/eggXfmSAnim.cxx index 189831ad00..167cb531b7 100644 --- a/panda/src/egg/eggXfmSAnim.cxx +++ b/panda/src/egg/eggXfmSAnim.cxx @@ -1,16 +1,15 @@ -// Filename: eggXfmSAnim.cxx -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmSAnim.cxx + * @author drose + * @date 1999-02-19 + */ #include "eggXfmSAnim.h" #include "eggSAnimData.h" @@ -28,12 +27,9 @@ TypeHandle EggXfmSAnim::_type_handle; const string EggXfmSAnim::_standard_order = "srpht"; -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::Conversion constructor -// Access: Public -// Description: Converts the older-style XfmAnim table to the -// newer-style XfmSAnim table. -//////////////////////////////////////////////////////////////////// +/** + * Converts the older-style XfmAnim table to the newer-style XfmSAnim table. + */ EggXfmSAnim:: EggXfmSAnim(const EggXfmAnimData &convert_from) : EggGroupNode(convert_from.get_name()) @@ -58,12 +54,9 @@ EggXfmSAnim(const EggXfmAnimData &convert_from) } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::optimize -// Access: Public -// Description: Optimizes the table by collapsing redundant -// sub-tables. -//////////////////////////////////////////////////////////////////// +/** + * Optimizes the table by collapsing redundant sub-tables. + */ void EggXfmSAnim:: optimize() { iterator ci = begin(); @@ -76,8 +69,8 @@ optimize() { sanim->optimize(); if (sanim->get_num_rows() == 1) { - // If we've optimized down to one value, check to see if it is - // a default value. + // If we've optimized down to one value, check to see if it is a + // default value. double value = sanim->get_value(0); double default_value; if (sanim->has_name() && strchr("ijk", sanim->get_name()[0]) != NULL) { @@ -87,8 +80,7 @@ optimize() { } if (fabs(value - default_value) < egg_parameters->_table_threshold) { - // It's a default-valued table, and therefore redundant: - // remove it. + // It's a default-valued table, and therefore redundant: remove it. erase(ci); } } @@ -98,15 +90,11 @@ optimize() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::optimize_to_standard_order -// Access: Public -// Description: Optimizes the table by collapsing redundant -// sub-tables, and simultaneously ensures that the order -// string is the standard order (which is the same as -// that supported by compose_matrix() and -// decompose_matrix()). -//////////////////////////////////////////////////////////////////// +/** + * Optimizes the table by collapsing redundant sub-tables, and simultaneously + * ensures that the order string is the standard order (which is the same as + * that supported by compose_matrix() and decompose_matrix()). + */ void EggXfmSAnim:: optimize_to_standard_order() { if (get_order() != get_standard_order()) { @@ -115,15 +103,12 @@ optimize_to_standard_order() { optimize(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::normalize -// Access: Public -// Description: The inverse operation of optimize(), this ensures -// that all the sub-tables have the same length by -// duplicating rows as necessary. This is needed before -// doing operations like add_data() or set_value() on an -// existing table. -//////////////////////////////////////////////////////////////////// +/** + * The inverse operation of optimize(), this ensures that all the sub-tables + * have the same length by duplicating rows as necessary. This is needed + * before doing operations like add_data() or set_value() on an existing + * table. + */ void EggXfmSAnim:: normalize() { if (get_order() != get_standard_order()) { @@ -133,30 +118,25 @@ normalize() { normalize_by_rebuilding(); } else { - // Otherwise, if the order string is already the standard order - // string, we can do this the easy way (from a computational - // standpoint), which is just to lengthen the tables directly. + // Otherwise, if the order string is already the standard order string, we + // can do this the easy way (from a computational standpoint), which is + // just to lengthen the tables directly. normalize_by_expanding(); } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::is_anim_matrix -// Access: Public, Virtual -// Description: Returns true if this node represents a table of -// animation transformation data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents a table of animation transformation + * data, false otherwise. + */ bool EggXfmSAnim:: is_anim_matrix() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::write -// Access: Public, Virtual -// Description: Writes the data to the indicated output stream in Egg -// format. -//////////////////////////////////////////////////////////////////// +/** + * Writes the data to the indicated output stream in Egg format. + */ void EggXfmSAnim:: write(ostream &out, int indent_level) const { test_under_integrity(); @@ -172,11 +152,10 @@ write(ostream &out, int indent_level) const { << " order { " << get_order() << " }\n"; } - // Rather than calling EggGroupNode::write() to write out the - // children, we do it directly here so we can control the order. We - // write out all the non-table children first, then write out the - // table children in our expected order. (Normally there are only - // table children.) + // Rather than calling EggGroupNode::write() to write out the children, we + // do it directly here so we can control the order. We write out all the + // non-table children first, then write out the table children in our + // expected order. (Normally there are only table children.) EggSAnimData *tables[num_matrix_components]; memset(tables, 0, sizeof(EggSAnimData *) * num_matrix_components); @@ -213,14 +192,11 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::compose_with_order -// Access: Public, Static -// Description: Composes a matrix out of the nine individual -// components, respecting the order string. The -// components will be applied in the order indicated by -// the string. -//////////////////////////////////////////////////////////////////// +/** + * Composes a matrix out of the nine individual components, respecting the + * order string. The components will be applied in the order indicated by the + * string. + */ void EggXfmSAnim:: compose_with_order(LMatrix4d &mat, const LVecBase3d &scale, @@ -235,9 +211,9 @@ compose_with_order(LMatrix4d &mat, bool reverse_roll = false; if (order == "sphrt" && egg_support_old_anims) { - // As a special case, if the order string is exactly "sphrt" - // (which is what all our legacy anim files used), we interpret - // roll in the opposite direction (as our legacy anim files did). + // As a special case, if the order string is exactly "sphrt" (which is + // what all our legacy anim files used), we interpret roll in the opposite + // direction (as our legacy anim files did). reverse_roll = true; } @@ -275,15 +251,12 @@ compose_with_order(LMatrix4d &mat, } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_num_rows -// Access: Public -// Description: Returns the effective number of rows in the table. -// This is actually the number of rows of the smallest -// subtable larger than one row. This is a convenience -// function that treats the table of tables as if it -// were a single table of matrices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the effective number of rows in the table. This is actually the + * number of rows of the smallest subtable larger than one row. This is a + * convenience function that treats the table of tables as if it were a single + * table of matrices. + */ int EggXfmSAnim:: get_num_rows() const { bool found_any = false; @@ -307,17 +280,13 @@ get_num_rows() const { return min_rows; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::get_value -// Access: Public -// Description: Returns the value of the aggregate row of the table -// as a matrix. This is a convenience function that -// treats the table of tables as if it were a single -// table of matrices. It is an error to call this if -// any SAnimData children of this node have an improper -// name (e.g. not a single letter, or not one of -// "ijkabchprxyz"). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the aggregate row of the table as a matrix. This is a + * convenience function that treats the table of tables as if it were a single + * table of matrices. It is an error to call this if any SAnimData children + * of this node have an improper name (e.g. not a single letter, or not one + * of "ijkabchprxyz"). + */ void EggXfmSAnim:: get_value(int row, LMatrix4d &mat) const { LVector3d scale(1.0, 1.0, 1.0); @@ -331,8 +300,7 @@ get_value(int row, LMatrix4d &mat) const { EggSAnimData *sanim = DCAST(EggSAnimData, *ci); if (sanim->get_num_rows() == 0) { - // If the table is totally empty, let's keep the default - // value. + // If the table is totally empty, let's keep the default value. break; } @@ -407,21 +375,16 @@ get_value(int row, LMatrix4d &mat) const { compose_with_order(mat, scale, shear, hpr, translate, get_order(), _coordsys); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::set_value -// Access: Public -// Description: Replaces the indicated row of the table with the -// given matrix. -// -// This function can only be called if all the -// constraints of add_data(), below, are met. Call -// normalize() first if you are not sure. -// -// The return value is true if the matrix can be -// decomposed and stored as scale, shear, rotate, and -// translate, or false otherwise. The data is set in -// either case. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated row of the table with the given matrix. + * + * This function can only be called if all the constraints of add_data(), + * below, are met. Call normalize() first if you are not sure. + * + * The return value is true if the matrix can be decomposed and stored as + * scale, shear, rotate, and translate, or false otherwise. The data is set + * in either case. + */ bool EggXfmSAnim:: set_value(int row, const LMatrix4d &mat) { nassertr(get_order() == get_standard_order(), false); @@ -437,7 +400,7 @@ set_value(int row, const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != (EggNode *)NULL && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -465,12 +428,12 @@ set_value(int row, const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i += 3) { egg_cat.warning(false) << " " - << matrix_component_letters[i] + << matrix_component_letters[i] << matrix_component_letters[i + 1] << matrix_component_letters[i + 2] << ": " - << components[i] << " " - << components[i + 1] << " " + << components[i] << " " + << components[i + 1] << " " << components[i + 2] << "\n"; } egg_cat.warning(false) @@ -483,37 +446,29 @@ set_value(int row, const LMatrix4d &mat) { return add_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::add_data -// Access: Public -// Description: Adds a new matrix to the table, by adding a new row -// to each of the subtables. -// -// This is a convenience function that -// treats the table of tables as if it were a single -// table of matrices. It is an error to call this if -// any SAnimData children of this node have an improper -// name (e.g. not a single letter, or not one of -// "ijkabchprxyz"). -// -// This function has the further requirement that all -// nine of the subtables must exist and be of the same -// length. Furthermore, the order string must be the -// standard order string, which matches the system -// compose_matrix() and decompose_matrix() functions. -// -// Thus, you probably cannot take an existing -// EggXfmSAnim object and start adding matrices to the -// end; you must clear out the original data first. (As -// a special exception, if no tables exist, they will be -// created.) The method normalize() will do this for -// you on an existing EggXfmSAnim. -// -// This function may fail silently if the matrix cannot -// be decomposed into scale, shear, rotate, and -// translate. In this case, the closest approximation -// is added to the table, and false is returned. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new matrix to the table, by adding a new row to each of the + * subtables. + * + * This is a convenience function that treats the table of tables as if it + * were a single table of matrices. It is an error to call this if any + * SAnimData children of this node have an improper name (e.g. not a single + * letter, or not one of "ijkabchprxyz"). + * + * This function has the further requirement that all nine of the subtables + * must exist and be of the same length. Furthermore, the order string must + * be the standard order string, which matches the system compose_matrix() and + * decompose_matrix() functions. + * + * Thus, you probably cannot take an existing EggXfmSAnim object and start + * adding matrices to the end; you must clear out the original data first. + * (As a special exception, if no tables exist, they will be created.) The + * method normalize() will do this for you on an existing EggXfmSAnim. + * + * This function may fail silently if the matrix cannot be decomposed into + * scale, shear, rotate, and translate. In this case, the closest + * approximation is added to the table, and false is returned. + */ bool EggXfmSAnim:: add_data(const LMatrix4d &mat) { double components[num_matrix_components]; @@ -540,7 +495,7 @@ add_data(const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i++) { string name(1, matrix_component_letters[i]); EggNode *child = find_child(name); - nassertr(child != (EggNode *)NULL && + nassertr(child != (EggNode *)NULL && child->is_of_type(EggSAnimData::get_class_type()), false); EggSAnimData *sanim = DCAST(EggSAnimData, child); @@ -572,12 +527,12 @@ add_data(const LMatrix4d &mat) { for (int i = 0; i < num_matrix_components; i += 3) { egg_cat.warning(false) << " " - << matrix_component_letters[i] + << matrix_component_letters[i] << matrix_component_letters[i + 1] << matrix_component_letters[i + 2] << ": " - << components[i] << " " - << components[i + 1] << " " + << components[i] << " " + << components[i + 1] << " " << components[i + 2] << "\n"; } egg_cat.warning(false) @@ -590,12 +545,10 @@ add_data(const LMatrix4d &mat) { return add_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::add_component_data -// Access: Public -// Description: Adds a new row to the named component (one of -// matrix_component_letters) of the table. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new row to the named component (one of matrix_component_letters) of + * the table. + */ void EggXfmSAnim:: add_component_data(const string &component_name, double value) { EggNode *child = find_child(component_name); @@ -612,12 +565,9 @@ add_component_data(const string &component_name, double value) { sanim->add_data(value); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::add_component_data -// Access: Public -// Description: Adds a new row to the indicated component (0-12) of -// the table. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new row to the indicated component (0-12) of the table. + */ void EggXfmSAnim:: add_component_data(int component, double value) { nassertv(component >= 0 && component < num_matrix_components); @@ -626,19 +576,16 @@ add_component_data(int component, double value) { add_component_data(name, value); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::r_transform -// Access: Protected, Virtual -// Description: Applies the indicated transform to all the rows of -// the table. This actually forces the generation of a -// totally new set of rows, and will quietly change the -// order to the standard order (if it is different). -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform to all the rows of the table. This + * actually forces the generation of a totally new set of rows, and will + * quietly change the order to the standard order (if it is different). + */ void EggXfmSAnim:: r_transform(const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs) { - // We need to build an inverse matrix that doesn't reflect the - // translation component. + // We need to build an inverse matrix that doesn't reflect the translation + // component. LMatrix4d inv1 = inv; inv1.set_row(3, LVector3d(0.0, 0.0, 0.0)); @@ -658,9 +605,8 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, original.get_value(r, orig_mat); bool result = add_data(inv1 * orig_mat * mat); - // If this assertion fails, we attempted to transform by a skew - // matrix or some such thing that cannot be represented in an anim - // file. + // If this assertion fails, we attempted to transform by a skew matrix or + // some such thing that cannot be represented in an anim file. nassertv(result); } @@ -668,30 +614,23 @@ r_transform(const LMatrix4d &mat, const LMatrix4d &inv, optimize(); } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::r_mark_coordsys -// Access: Protected, Virtual -// Description: This is only called immediately after loading an egg -// file from disk, to propagate the value found in the -// CoordinateSystem entry (or the default Y-up -// coordinate system) to all nodes that care about what -// the coordinate system is. -//////////////////////////////////////////////////////////////////// +/** + * This is only called immediately after loading an egg file from disk, to + * propagate the value found in the CoordinateSystem entry (or the default + * Y-up coordinate system) to all nodes that care about what the coordinate + * system is. + */ void EggXfmSAnim:: r_mark_coordsys(CoordinateSystem cs) { _coordsys = cs; } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::normalize_by_rebuilding -// Access: Private -// Description: One implementation of normalize() that rebuilds the -// entire table by composing and decomposing the rows. -// This has the advantage that it will also reset the -// order string to the standard order string, but it is -// more computationally intensive and is subject to -// roundoff error. -//////////////////////////////////////////////////////////////////// +/** + * One implementation of normalize() that rebuilds the entire table by + * composing and decomposing the rows. This has the advantage that it will + * also reset the order string to the standard order string, but it is more + * computationally intensive and is subject to roundoff error. + */ void EggXfmSAnim:: normalize_by_rebuilding() { // Save a temporary copy of the original data. @@ -706,29 +645,24 @@ normalize_by_rebuilding() { original.get_value(r, orig_mat); bool result = add_data(orig_mat); - // If this assertion fails, we somehow got a matrix out of the - // original table that we could not represent in the new table. - // That shouldn't be possible; there's probably something wrong - // in decompose_matrix(). + // If this assertion fails, we somehow got a matrix out of the original + // table that we could not represent in the new table. That shouldn't be + // possible; there's probably something wrong in decompose_matrix(). nassertv(result); } } -//////////////////////////////////////////////////////////////////// -// Function: EggXfmSAnim::normalize_by_expanding -// Access: Private -// Description: Another implementation of normalize() that simply -// expands any one-row tables and creates default-valued -// tables where none were before. This will not change -// the order string, but is much faster and does not -// introduce roundoff error. -//////////////////////////////////////////////////////////////////// +/** + * Another implementation of normalize() that simply expands any one-row + * tables and creates default-valued tables where none were before. This will + * not change the order string, but is much faster and does not introduce + * roundoff error. + */ void EggXfmSAnim:: normalize_by_expanding() { iterator ci; - // First, determine which tables we already have, and how long they - // are. + // First, determine which tables we already have, and how long they are. int num_tables = 0; int table_length = 1; string remaining_tables = matrix_component_letters; diff --git a/panda/src/egg/eggXfmSAnim.h b/panda/src/egg/eggXfmSAnim.h index abd0e3cb34..7e46af5f5c 100644 --- a/panda/src/egg/eggXfmSAnim.h +++ b/panda/src/egg/eggXfmSAnim.h @@ -1,16 +1,15 @@ -// Filename: eggXfmSAnim.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggXfmSAnim.h + * @author drose + * @date 1999-02-19 + */ #ifndef EGGXFMSANIM_H #define EGGXFMSANIM_H @@ -20,14 +19,12 @@ class EggXfmAnimData; -//////////////////////////////////////////////////////////////////// -// Class : EggXfmSAnim -// Description : This corresponds to an entry, which is -// a collection of up to nine entries that -// specify the nine components of a transformation. -// It's implemented as a group that can contain -// any number of EggSAnimData children. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to an entry, which is a collection of up to + * nine entries that specify the nine components of a transformation. + * It's implemented as a group that can contain any number of EggSAnimData + * children. + */ class EXPCL_PANDAEGG EggXfmSAnim : public EggGroupNode { PUBLISHED: INLINE EggXfmSAnim(const string &name = "", @@ -91,7 +88,7 @@ private: CoordinateSystem _coordsys; static const string _standard_order; - + public: static TypeHandle get_class_type() { @@ -114,5 +111,3 @@ private: #include "eggXfmSAnim.I" #endif - - diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index b5b5b7d713..1ce4a0006e 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -1,9 +1,8 @@ -/* -// Filename: lexer.lxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -*/ +/** + * @file lexer.lxx + * @author drose + * @date 1999-01-16 + */ %{ #include "pandabase.h" diff --git a/panda/src/egg/lexerDefs.h b/panda/src/egg/lexerDefs.h index 2a9827cf67..0337830028 100644 --- a/panda/src/egg/lexerDefs.h +++ b/panda/src/egg/lexerDefs.h @@ -1,16 +1,15 @@ -// Filename: lexerDefs.h -// Created by: drose (17Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lexerDefs.h + * @author drose + * @date 1999-01-17 + */ #ifndef LEXER_H #define LEXER_H diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index c07a859583..02e83f18ec 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -1,7 +1,8 @@ -// Filename: parser.yxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// +/** + * @file parser.yxx + * @author drose + * @date 1999-01-16 + */ %{ diff --git a/panda/src/egg/parserDefs.h b/panda/src/egg/parserDefs.h index 3ea01ad75a..b0938d567d 100644 --- a/panda/src/egg/parserDefs.h +++ b/panda/src/egg/parserDefs.h @@ -1,16 +1,15 @@ -// Filename: parserDefs.h -// Created by: drose (17Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parserDefs.h + * @author drose + * @date 1999-01-17 + */ #ifndef PARSER_H #define PARSER_H @@ -35,12 +34,11 @@ void egg_init_parser(istream &in, const string &filename, void egg_cleanup_parser(); -// This structure holds the return value for each token. -// Traditionally, this is a union, and is declared with the %union -// declaration in the parser.y file, but unions are pretty worthless -// in C++ (you can't include an object that has member functions in a -// union), so we'll use a class instead. That means we need to -// declare it externally, here. +// This structure holds the return value for each token. Traditionally, this +// is a union, and is declared with the %union declaration in the parser.y +// file, but unions are pretty worthless in C++ (you can't include an object +// that has member functions in a union), so we'll use a class instead. That +// means we need to declare it externally, here. class EXPCL_PANDAEGG EggTokenType { public: @@ -51,8 +49,8 @@ public: PTA_double _number_list; }; -// The yacc-generated code expects to use the symbol 'YYSTYPE' to -// refer to the above class. +// The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the +// above class. #define YYSTYPE EggTokenType #endif diff --git a/panda/src/egg/pt_EggMaterial.cxx b/panda/src/egg/pt_EggMaterial.cxx index 1a4207000f..2750824e5a 100644 --- a/panda/src/egg/pt_EggMaterial.cxx +++ b/panda/src/egg/pt_EggMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: pt_EggMaterial.cxx -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggMaterial.cxx + * @author drose + * @date 2001-05-01 + */ #include "pt_EggMaterial.h" diff --git a/panda/src/egg/pt_EggMaterial.h b/panda/src/egg/pt_EggMaterial.h index ee88991c75..218de12074 100644 --- a/panda/src/egg/pt_EggMaterial.h +++ b/panda/src/egg/pt_EggMaterial.h @@ -1,16 +1,15 @@ -// Filename: pt_EggMaterial.h -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggMaterial.h + * @author drose + * @date 2001-05-01 + */ #ifndef PT_EGGMATERIAL_H #define PT_EGGMATERIAL_H @@ -20,12 +19,10 @@ #include "eggMaterial.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PT_EggMaterial -// Description : A PT(EggMaterial). This is defined here solely we can -// explicitly export the template class. It's not -// strictly necessary, but it doesn't hurt. -//////////////////////////////////////////////////////////////////// +/** + * A PT(EggMaterial). This is defined here solely we can explicitly export + * the template class. It's not strictly necessary, but it doesn't hurt. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) diff --git a/panda/src/egg/pt_EggTexture.cxx b/panda/src/egg/pt_EggTexture.cxx index 4cff50aa93..8a90ad2a24 100644 --- a/panda/src/egg/pt_EggTexture.cxx +++ b/panda/src/egg/pt_EggTexture.cxx @@ -1,16 +1,15 @@ -// Filename: pt_EggTexture.cxx -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggTexture.cxx + * @author drose + * @date 2001-05-01 + */ #include "pt_EggTexture.h" diff --git a/panda/src/egg/pt_EggTexture.h b/panda/src/egg/pt_EggTexture.h index 0564ffc66f..15a9738f96 100644 --- a/panda/src/egg/pt_EggTexture.h +++ b/panda/src/egg/pt_EggTexture.h @@ -1,16 +1,15 @@ -// Filename: pt_EggTexture.h -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggTexture.h + * @author drose + * @date 2001-05-01 + */ #ifndef PT_EGGTEXTURE_H #define PT_EGGTEXTURE_H @@ -20,12 +19,10 @@ #include "eggTexture.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PT_EggTexture -// Description : A PT(EggTexture). This is defined here solely we can -// explicitly export the template class. It's not -// strictly necessary, but it doesn't hurt. -//////////////////////////////////////////////////////////////////// +/** + * A PT(EggTexture). This is defined here solely we can explicitly export the + * template class. It's not strictly necessary, but it doesn't hurt. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) diff --git a/panda/src/egg/pt_EggVertex.cxx b/panda/src/egg/pt_EggVertex.cxx index d5c7057b0b..b1b932328b 100644 --- a/panda/src/egg/pt_EggVertex.cxx +++ b/panda/src/egg/pt_EggVertex.cxx @@ -1,16 +1,15 @@ -// Filename: pt_EggVertex.cxx -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggVertex.cxx + * @author drose + * @date 2001-02-22 + */ #include "pt_EggVertex.h" diff --git a/panda/src/egg/pt_EggVertex.h b/panda/src/egg/pt_EggVertex.h index f16982ff49..483a893a13 100644 --- a/panda/src/egg/pt_EggVertex.h +++ b/panda/src/egg/pt_EggVertex.h @@ -1,16 +1,15 @@ -// Filename: pt_EggVertex.h -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_EggVertex.h + * @author drose + * @date 2001-02-22 + */ #ifndef PT_EGGVERTEX_H #define PT_EGGVERTEX_H @@ -20,12 +19,10 @@ #include "eggVertex.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PT_EggVertex -// Description : A PT(EggVertex). This is defined here solely we can -// explicitly export the template class. It's not -// strictly necessary, but it doesn't hurt. -//////////////////////////////////////////////////////////////////// +/** + * A PT(EggVertex). This is defined here solely we can explicitly export the + * template class. It's not strictly necessary, but it doesn't hurt. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerTo) diff --git a/panda/src/egg/test_egg.cxx b/panda/src/egg/test_egg.cxx index 11c315e663..ae91d3548d 100644 --- a/panda/src/egg/test_egg.cxx +++ b/panda/src/egg/test_egg.cxx @@ -1,16 +1,15 @@ -// Filename: test_egg.cxx -// Created by: drose (16Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_egg.cxx + * @author drose + * @date 1999-01-16 + */ #include "eggData.h" #include "pnotify.h" @@ -35,4 +34,3 @@ main(int argc, char *argv[]) { } return (0); } - diff --git a/panda/src/egg/vector_PT_EggMaterial.cxx b/panda/src/egg/vector_PT_EggMaterial.cxx index ef575c74ac..ce183b5aa0 100644 --- a/panda/src/egg/vector_PT_EggMaterial.cxx +++ b/panda/src/egg/vector_PT_EggMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggMaterial.cxx -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggMaterial.cxx + * @author drose + * @date 2001-05-01 + */ #include "vector_PT_EggMaterial.h" diff --git a/panda/src/egg/vector_PT_EggMaterial.h b/panda/src/egg/vector_PT_EggMaterial.h index f6fcfa5639..0aaab728a7 100644 --- a/panda/src/egg/vector_PT_EggMaterial.h +++ b/panda/src/egg/vector_PT_EggMaterial.h @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggMaterial.h -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggMaterial.h + * @author drose + * @date 2001-05-01 + */ #ifndef VECTOR_PT_EGGMATERIAL_H #define VECTOR_PT_EGGMATERIAL_H @@ -22,14 +21,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_PT_EggMaterial -// Description : A vector of PT(EggMaterial)'s. This class is defined once -// here, and exported to PANDAEGG.DLL; other packages -// that want to use a vector of this type (whether they -// need to export it or not) should include this header -// file, rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of PT(EggMaterial)'s. This class is defined once here, and + * exported to PANDAEGG.DLL; other packages that want to use a vector of this + * type (whether they need to export it or not) should include this header + * file, rather than defining the vector again. + */ #define EXPCL EXPCL_PANDAEGG #define EXPTP EXPTP_PANDAEGG diff --git a/panda/src/egg/vector_PT_EggTexture.cxx b/panda/src/egg/vector_PT_EggTexture.cxx index 004d38808d..f95063202e 100644 --- a/panda/src/egg/vector_PT_EggTexture.cxx +++ b/panda/src/egg/vector_PT_EggTexture.cxx @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggTexture.cxx -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggTexture.cxx + * @author drose + * @date 2001-05-01 + */ #include "vector_PT_EggTexture.h" diff --git a/panda/src/egg/vector_PT_EggTexture.h b/panda/src/egg/vector_PT_EggTexture.h index 3b62da1026..44849ec364 100644 --- a/panda/src/egg/vector_PT_EggTexture.h +++ b/panda/src/egg/vector_PT_EggTexture.h @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggTexture.h -// Created by: drose (01May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggTexture.h + * @author drose + * @date 2001-05-01 + */ #ifndef VECTOR_PT_EGGTEXTURE_H #define VECTOR_PT_EGGTEXTURE_H @@ -22,14 +21,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_PT_EggTexture -// Description : A vector of PT(EggTexture)'s. This class is defined once -// here, and exported to PANDAEGG.DLL; other packages -// that want to use a vector of this type (whether they -// need to export it or not) should include this header -// file, rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of PT(EggTexture)'s. This class is defined once here, and + * exported to PANDAEGG.DLL; other packages that want to use a vector of this + * type (whether they need to export it or not) should include this header + * file, rather than defining the vector again. + */ #define EXPCL EXPCL_PANDAEGG #define EXPTP EXPTP_PANDAEGG diff --git a/panda/src/egg/vector_PT_EggVertex.cxx b/panda/src/egg/vector_PT_EggVertex.cxx index ce8abffa0a..0343a4771b 100644 --- a/panda/src/egg/vector_PT_EggVertex.cxx +++ b/panda/src/egg/vector_PT_EggVertex.cxx @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggVertex.cxx -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggVertex.cxx + * @author drose + * @date 2001-02-22 + */ #include "vector_PT_EggVertex.h" diff --git a/panda/src/egg/vector_PT_EggVertex.h b/panda/src/egg/vector_PT_EggVertex.h index 37c0252683..6827f35783 100644 --- a/panda/src/egg/vector_PT_EggVertex.h +++ b/panda/src/egg/vector_PT_EggVertex.h @@ -1,16 +1,15 @@ -// Filename: vector_PT_EggVertex.h -// Created by: drose (22Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_PT_EggVertex.h + * @author drose + * @date 2001-02-22 + */ #ifndef VECTOR_PT_EGGVERTEX_H #define VECTOR_PT_EGGVERTEX_H @@ -22,14 +21,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_PT_EggVertex -// Description : A vector of PT(EggVertex)'s. This class is defined once -// here, and exported to PANDAEGG.DLL; other packages -// that want to use a vector of this type (whether they -// need to export it or not) should include this header -// file, rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of PT(EggVertex)'s. This class is defined once here, and exported + * to PANDAEGG.DLL; other packages that want to use a vector of this type + * (whether they need to export it or not) should include this header file, + * rather than defining the vector again. + */ #define EXPCL EXPCL_PANDAEGG #define EXPTP EXPTP_PANDAEGG diff --git a/panda/src/egg2pg/animBundleMaker.cxx b/panda/src/egg2pg/animBundleMaker.cxx index b1244ca27f..18e7447923 100644 --- a/panda/src/egg2pg/animBundleMaker.cxx +++ b/panda/src/egg2pg/animBundleMaker.cxx @@ -1,16 +1,15 @@ -// Filename: animBundleMaker.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundleMaker.cxx + * @author drose + * @date 1999-02-22 + */ #include "animBundleMaker.h" #include "config_egg2pg.h" @@ -26,11 +25,9 @@ #include "animChannelMatrixXfmTable.h" #include "animChannelScalarTable.h" -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::Construtor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimBundleMaker:: AnimBundleMaker(EggTable *root) : _root(root) { _fps = 0.0f; @@ -60,21 +57,17 @@ AnimBundleMaker(EggTable *root) : _root(root) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::make_node -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimBundleNode *AnimBundleMaker:: make_node() { return new AnimBundleNode(_root->get_name(), make_bundle()); } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::make_bundle -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimBundle *AnimBundleMaker:: make_bundle() { AnimBundle *bundle = new AnimBundle(_root->get_name(), _fps, _num_frames); @@ -93,12 +86,9 @@ make_bundle() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::inspect_tree -// Access: Private -// Description: Walks the egg tree, getting out the fps and the -// number of frames. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg tree, getting out the fps and the number of frames. + */ void AnimBundleMaker:: inspect_tree(EggNode *egg_node) { if (egg_node->is_of_type(EggAnimData::get_class_type())) { @@ -172,19 +162,16 @@ inspect_tree(EggNode *egg_node) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::build_hierarchy -// Access: Private -// Description: Walks the egg tree again, creating the AnimChannels -// as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Walks the egg tree again, creating the AnimChannels as appropriate. + */ void AnimBundleMaker:: build_hierarchy(EggTable *egg_table, AnimGroup *parent) { AnimGroup *this_node = NULL; - // First, scan the children of egg_table for anim data tables. If - // any of them is named "xform", it's a special case--this one - // stands for the egg_table node itself. Don't ask me why. + // First, scan the children of egg_table for anim data tables. If any of + // them is named "xform", it's a special case--this one stands for the + // egg_table node itself. Don't ask me why. EggTable::const_iterator ci; for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) { @@ -199,14 +186,12 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { } } - // If none of them were named "xform", just create a plain old - // AnimGroup. + // If none of them were named "xform", just create a plain old AnimGroup. if (this_node == NULL) { this_node = new AnimGroup(parent, egg_table->get_name()); } - // Now walk the children again, creating any leftover tables, and - // recursing. + // Now walk the children again, creating any leftover tables, and recursing. for (ci = egg_table->begin(); ci != egg_table->end(); ++ci) { if ((*ci)->get_name() == "xform") { // Skip this one. We already got it. @@ -222,20 +207,17 @@ build_hierarchy(EggTable *egg_table, AnimGroup *parent) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::create_s_channel -// Access: Private -// Description: Creates an AnimChannelScalarTable corresponding to -// the given EggSAnimData structure. -//////////////////////////////////////////////////////////////////// +/** + * Creates an AnimChannelScalarTable corresponding to the given EggSAnimData + * structure. + */ AnimChannelScalarTable *AnimBundleMaker:: create_s_channel(EggSAnimData *egg_anim, const string &name, AnimGroup *parent) { AnimChannelScalarTable *table = new AnimChannelScalarTable(parent, name); - // First we have to copy the table data from PTA_double to - // PTA_stdfloat. + // First we have to copy the table data from PTA_double to PTA_stdfloat. PTA_stdfloat new_data = PTA_stdfloat::empty_array(egg_anim->get_num_rows(), table->get_class_type()); for (int i = 0; i < egg_anim->get_num_rows(); i++) { @@ -249,12 +231,10 @@ create_s_channel(EggSAnimData *egg_anim, const string &name, } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::create_xfm_channel (EggNode) -// Access: Private -// Description: Creates an AnimChannelMatrixXfmTable corresponding to -// the given EggNode structure, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates an AnimChannelMatrixXfmTable corresponding to the given EggNode + * structure, if possible. + */ AnimChannelMatrixXfmTable *AnimBundleMaker:: create_xfm_channel(EggNode *egg_node, const string &name, AnimGroup *parent) { @@ -275,25 +255,22 @@ create_xfm_channel(EggNode *egg_node, const string &name, } -//////////////////////////////////////////////////////////////////// -// Function: AnimBundleMaker::create_xfm_channel (EggXfmSAnim) -// Access: Private -// Description: Creates an AnimChannelMatrixXfmTable corresponding to -// the given EggXfmSAnim structure. -//////////////////////////////////////////////////////////////////// +/** + * Creates an AnimChannelMatrixXfmTable corresponding to the given EggXfmSAnim + * structure. + */ AnimChannelMatrixXfmTable *AnimBundleMaker:: create_xfm_channel(EggXfmSAnim *egg_anim, const string &name, AnimGroup *parent) { - // Ensure that the anim table is optimal and that it is standard - // order. + // Ensure that the anim table is optimal and that it is standard order. egg_anim->optimize_to_standard_order(); AnimChannelMatrixXfmTable *table = new AnimChannelMatrixXfmTable(parent, name); - // The EggXfmSAnim structure has a number of children which are - // EggSAnimData tables. Each of these represents a separate - // component of the transform data, and will be added to the table. + // The EggXfmSAnim structure has a number of children which are EggSAnimData + // tables. Each of these represents a separate component of the transform + // data, and will be added to the table. EggXfmSAnim::const_iterator ci; for (ci = egg_anim->begin(); ci != egg_anim->end(); ++ci) { diff --git a/panda/src/egg2pg/animBundleMaker.h b/panda/src/egg2pg/animBundleMaker.h index 0fa0d0d9b8..48d97635ba 100644 --- a/panda/src/egg2pg/animBundleMaker.h +++ b/panda/src/egg2pg/animBundleMaker.h @@ -1,16 +1,15 @@ -// Filename: animBundleMaker.h -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animBundleMaker.h + * @author drose + * @date 1999-02-22 + */ #ifndef ANIMBUNDLEMAKER_H #define ANIMBUNDLEMAKER_H @@ -29,11 +28,10 @@ class AnimBundleNode; class AnimChannelScalarTable; class AnimChannelMatrixXfmTable; -//////////////////////////////////////////////////////////////////// -// Class : AnimBundleMaker -// Description : Converts an EggTable hierarchy, beginning with a -// entry, into an AnimBundle hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Converts an EggTable hierarchy, beginning with a entry, into an + * AnimBundle hierarchy. + */ class EXPCL_PANDAEGG AnimBundleMaker { public: AnimBundleMaker(EggTable *root); diff --git a/panda/src/egg2pg/characterMaker.cxx b/panda/src/egg2pg/characterMaker.cxx index 5450a3ab6d..99bbf54f47 100644 --- a/panda/src/egg2pg/characterMaker.cxx +++ b/panda/src/egg2pg/characterMaker.cxx @@ -1,16 +1,15 @@ -// Filename: characterMaker.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterMaker.cxx + * @author drose + * @date 2002-03-06 + */ #include "characterMaker.h" #include "eggLoader.h" @@ -39,11 +38,9 @@ -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::Construtor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterMaker:: CharacterMaker(EggGroup *root, EggLoader &loader, bool structured) : _loader(loader), _egg_root(root) { @@ -56,56 +53,46 @@ CharacterMaker(EggGroup *root, EggLoader &loader, bool structured) _structured = structured; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::make_node -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Character *CharacterMaker:: make_node() { make_bundle(); return _character_node; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::get_name -// Access: Public -// Description: Returns the name of the character. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the character. + */ string CharacterMaker:: get_name() const { return _egg_root->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::egg_to_part -// Access: Public -// Description: Returns the PartGroup node associated with the given -// egg node. If the egg node is not a node in the -// character's hierarchy, returns the top of the -// character's hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PartGroup node associated with the given egg node. If the egg + * node is not a node in the character's hierarchy, returns the top of the + * character's hierarchy. + */ PartGroup *CharacterMaker:: egg_to_part(EggNode *egg_node) const { int index = egg_to_index(egg_node); if (index < 0) { - // If there's a reference to the geometry outside of the - // character, just return the root of the character. + // If there's a reference to the geometry outside of the character, just + // return the root of the character. return _bundle; } nassertr(index < (int)_parts.size(), NULL); return _parts[index]; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::egg_to_transform -// Access: Public -// Description: Returns a JointVertexTransform suitable for -// applying the animation associated with the given -// egg node (which should be a joint). Returns an -// identity transform if the egg node is not a joint in -// the character's hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns a JointVertexTransform suitable for applying the animation + * associated with the given egg node (which should be a joint). Returns an + * identity transform if the egg node is not a joint in the character's + * hierarchy. + */ VertexTransform *CharacterMaker:: egg_to_transform(EggNode *egg_node) { int index = egg_to_index(egg_node); @@ -129,12 +116,10 @@ egg_to_transform(EggNode *egg_node) { return vt; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::egg_to_index -// Access: Public -// Description: Returns the index number associated with the -// PartGroup node for the given egg node, or -1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number associated with the PartGroup node for the given + * egg node, or -1. + */ int CharacterMaker:: egg_to_index(EggNode *egg_node) const { NodeMap::const_iterator nmi = _node_map.find(egg_node); @@ -144,14 +129,11 @@ egg_to_index(EggNode *egg_node) const { return (*nmi).second; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::part_to_node -// Access: Public -// Description: Returns the scene graph node associated with the -// given PartGroup node, if there is one. If the -// PartGroup does not have an associated node, returns -// the character's top node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene graph node associated with the given PartGroup node, if + * there is one. If the PartGroup does not have an associated node, returns + * the character's top node. + */ PandaNode *CharacterMaker:: part_to_node(PartGroup *part, const string &name) const { PandaNode *node = _character_node; @@ -163,11 +145,10 @@ part_to_node(PartGroup *part, const string &name) const { } } - // We should always return a GeomNode, so that all polysets - // created at the same level will get added into the same - // GeomNode. Look for a child of this node. If it doesn't have a - // child yet, add a GeomNode and return it. Otherwise, if it - // already has a child, return that. + // We should always return a GeomNode, so that all polysets created at the + // same level will get added into the same GeomNode. Look for a child of + // this node. If it doesn't have a child yet, add a GeomNode and return it. + // Otherwise, if it already has a child, return that. if (node->is_geom_node() && node->get_name() == name) { return node; } @@ -183,12 +164,9 @@ part_to_node(PartGroup *part, const string &name) const { } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::create_slider -// Access: Public -// Description: Creates a new morph slider of the given name, and -// returns its index. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new morph slider of the given name, and returns its index. + */ int CharacterMaker:: create_slider(const string &name) { if (_morph_root == (PartGroup *)NULL) { @@ -200,12 +178,9 @@ create_slider(const string &name) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::egg_to_slider -// Access: Public -// Description: Returns the VertexSlider corresponding to the -// indicated egg slider name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VertexSlider corresponding to the indicated egg slider name. + */ VertexSlider *CharacterMaker:: egg_to_slider(const string &name) { VertexSliders::iterator vi = _vertex_sliders.find(name); @@ -214,42 +189,39 @@ egg_to_slider(const string &name) { } int index = create_slider(name); - PT(VertexSlider) slider = + PT(VertexSlider) slider = new CharacterVertexSlider(DCAST(CharacterSlider, _parts[index])); _vertex_sliders[name] = slider; return slider; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::make_bundle -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CharacterJointBundle *CharacterMaker:: make_bundle() { build_joint_hierarchy(_egg_root, _skeleton_root, -1); - //if we are structured, the egg loader is going to take care of making the geometry + // if we are structured, the egg loader is going to take care of making the + // geometry if(!_structured) { make_geometry(_egg_root); } _bundle->sort_descendants(); parent_joint_nodes(_skeleton_root); - // Now call update() one more time, to ensure that all of the joints - // have their correct transform (since we might have modified the - // default transform after construction). + // Now call update() one more time, to ensure that all of the joints have + // their correct transform (since we might have modified the default + // transform after construction). _bundle->force_update(); return _bundle; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::build_joint_hierarchy -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CharacterMaker:: build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { if (egg_node->is_of_type(EggAnimPreload::get_class_type())) { @@ -280,12 +252,12 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { // Each joint we come across is significant, and gets added to the // hierarchy. Non-joints we encounter are ignored. if (egg_group->get_group_type() == EggGroup::GT_joint) { - // We need to get the transform of the joint, and then convert - // it to single-precision. + // We need to get the transform of the joint, and then convert it to + // single-precision. LMatrix4d matd; - // First, we get the original, initial transform from the - // entry. + // First, we get the original, initial transform from the + // entry. if (egg_group->has_transform()) { matd = egg_group->get_transform3d(); } else { @@ -300,9 +272,9 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { index = _parts.size(); _parts.push_back(joint); - // Now that we have computed _net_transform (which we need to - // convert the vertices), update the default transform from the - // entry. + // Now that we have computed _net_transform (which we need to convert + // the vertices), update the default transform from the + // entry. if (egg_group->get_default_pose().has_transform()) { matd = egg_group->get_default_pose().get_transform3d(); matf = LCAST(PN_stdfloat, matd); @@ -311,12 +283,10 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { } if (egg_group->has_dcs_type()) { - // If the joint requested an explicit DCS, create a node for - // it. + // If the joint requested an explicit DCS, create a node for it. PT(ModelNode) geom_node = new ModelNode(egg_group->get_name()); - // To prevent flattening from messing with geometry on - // exposed joints + // To prevent flattening from messing with geometry on exposed joints geom_node->set_preserve_transform(ModelNode::PT_net); joint->_geom_node = geom_node.p(); @@ -334,13 +304,10 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part, int index) { _node_map[egg_node] = index; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::parent_joint_nodes -// Access: Private -// Description: Walks the joint hierarchy, and parents any explicit -// nodes created for the joints under the character -// node. -//////////////////////////////////////////////////////////////////// +/** + * Walks the joint hierarchy, and parents any explicit nodes created for the + * joints under the character node. + */ void CharacterMaker:: parent_joint_nodes(PartGroup *part) { if (part->is_character_joint()) { @@ -358,33 +325,30 @@ parent_joint_nodes(PartGroup *part) { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::make_geometry -// Access: Private -// Description: Walks the hierarchy, looking for bins that represent -// polysets, which are to be animated with the -// character. Invokes the egg loader to create the -// animated geometry. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, looking for bins that represent polysets, which are to + * be animated with the character. Invokes the egg loader to create the + * animated geometry. + */ void CharacterMaker:: make_geometry(EggNode *egg_node) { if (egg_node->is_of_type(EggBin::get_class_type())) { EggBin *egg_bin = DCAST(EggBin, egg_node); - if (!egg_bin->empty() && + if (!egg_bin->empty() && (egg_bin->get_bin_number() == EggBinner::BN_polyset || egg_bin->get_bin_number() == EggBinner::BN_patches)) { EggGroupNode *bin_home = determine_bin_home(egg_bin); bool is_dynamic; if (bin_home == (EggGroupNode *)NULL) { - // This is a dynamic polyset that lives under the character's - // root node. + // This is a dynamic polyset that lives under the character's root + // node. bin_home = _egg_root; is_dynamic = true; } else { - // This is a totally static polyset that is parented under - // some animated joint node. + // This is a totally static polyset that is parented under some + // animated joint node. is_dynamic = false; } @@ -392,7 +356,7 @@ make_geometry(EggNode *egg_node) { LMatrix4d transform = egg_bin->get_vertex_frame() * bin_home->get_node_frame_inv(); - + _loader.make_polyset(egg_bin, parent, &transform, is_dynamic, this); } @@ -408,24 +372,21 @@ make_geometry(EggNode *egg_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::determine_primitive_home -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggGroupNode *CharacterMaker:: determine_primitive_home(EggPrimitive *egg_primitive) { - // A primitive's vertices may be referenced by any joint in the - // character. Or, the primitive itself may be explicitly placed - // under a joint. + // A primitive's vertices may be referenced by any joint in the character. + // Or, the primitive itself may be explicitly placed under a joint. - // If any of the vertices are referenced by multiple joints, or if - // any two vertices are referenced by different joints, then the - // entire primitive must be considered dynamic. (We'll indicate a - // dynamic primitive by returning NULL.) + // If any of the vertices are referenced by multiple joints, or if any two + // vertices are referenced by different joints, then the entire primitive + // must be considered dynamic. (We'll indicate a dynamic primitive by + // returning NULL.) - // We need to keep track of the one joint we've encountered so far, - // to see if all the vertices are referenced by the same joint. + // We need to keep track of the one joint we've encountered so far, to see + // if all the vertices are referenced by the same joint. EggGroupNode *home = NULL; EggPrimitive::const_iterator vi; @@ -434,8 +395,8 @@ determine_primitive_home(EggPrimitive *egg_primitive) { ++vi) { EggVertex *vertex = (*vi); if (vertex->gref_size() > 1) { - // This vertex is referenced by multiple joints; the primitive - // is dynamic. + // This vertex is referenced by multiple joints; the primitive is + // dynamic. return NULL; } @@ -449,8 +410,8 @@ determine_primitive_home(EggPrimitive *egg_primitive) { EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { - // Ditto: the vertex has some UV morphs; therefore the - // primitive is dynamic. + // Ditto: the vertex has some UV morphs; therefore the primitive is + // dynamic. return NULL; } } @@ -458,8 +419,8 @@ determine_primitive_home(EggPrimitive *egg_primitive) { EggGroupNode *vertex_home; if (vertex->gref_size() == 0) { - // This vertex is not referenced at all, which means it belongs - // right where it is. + // This vertex is not referenced at all, which means it belongs right + // where it is. vertex_home = egg_primitive->get_parent(); } else { nassertr(vertex->gref_size() == 1, NULL); @@ -468,23 +429,23 @@ determine_primitive_home(EggPrimitive *egg_primitive) { } if (home != NULL && home != vertex_home) { - // Oops, two vertices are referenced by different joints! The - // primitive is dynamic. + // Oops, two vertices are referenced by different joints! The primitive + // is dynamic. return NULL; } home = vertex_home; } - // This shouldn't be possible, unless there are no vertices--but we - // check for that before calling this function. + // This shouldn't be possible, unless there are no vertices--but we check + // for that before calling this function. nassertr(home != NULL, NULL); - // So, all the vertices are assigned to the same group. This means - // the polygon belongs entirely to one joint. + // So, all the vertices are assigned to the same group. This means the + // polygon belongs entirely to one joint. - // If the group is not, in fact, a joint then we return the first - // joint above the group. + // If the group is not, in fact, a joint then we return the first joint + // above the group. EggGroup *egg_group = (EggGroup *)NULL; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); @@ -503,46 +464,41 @@ determine_primitive_home(EggPrimitive *egg_primitive) { if (egg_group != (EggGroup *)NULL && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { - // If the home is a joint without a flag--this is the normal - // case--we'll move the polygon under the character node and - // animate it from there explicitly. + // If the home is a joint without a flag--this is the normal case-- + // we'll move the polygon under the character node and animate it from + // there explicitly. return NULL; } - // Otherwise, if the joint *does* have a flag, we'll create - // static geometry that we parent directly to the joint node. - // We'll also create static geometry for polygons that have no - // explicit joint assignment. + // Otherwise, if the joint *does* have a flag, we'll create static + // geometry that we parent directly to the joint node. We'll also create + // static geometry for polygons that have no explicit joint assignment. return home; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::determine_bin_home -// Access: Private -// Description: Examines the joint assignment of the vertices of all -// of the primitives within this bin to determine which -// parent node the bin's polyset should be created -// under. -//////////////////////////////////////////////////////////////////// +/** + * Examines the joint assignment of the vertices of all of the primitives + * within this bin to determine which parent node the bin's polyset should be + * created under. + */ EggGroupNode *CharacterMaker:: determine_bin_home(EggBin *egg_bin) { - // A primitive's vertices may be referenced by any joint in the - // character. Or, the primitive itself may be explicitly placed - // under a joint. + // A primitive's vertices may be referenced by any joint in the character. + // Or, the primitive itself may be explicitly placed under a joint. - // If any of the vertices, in any primitive, are referenced by - // multiple joints, or if any two vertices are referenced by - // different joints, then the entire bin must be considered dynamic. - // (We'll indicate a dynamic bin by returning NULL.) + // If any of the vertices, in any primitive, are referenced by multiple + // joints, or if any two vertices are referenced by different joints, then + // the entire bin must be considered dynamic. (We'll indicate a dynamic bin + // by returning NULL.) if (!egg_rigid_geometry) { - // If we don't have egg-rigid-geometry enabled, then all geometry - // is considered dynamic. + // If we don't have egg-rigid-geometry enabled, then all geometry is + // considered dynamic. return NULL; } - // We need to keep track of the one joint we've encountered so far, - // to see if all the vertices are referenced by the same joint. + // We need to keep track of the one joint we've encountered so far, to see + // if all the vertices are referenced by the same joint. EggGroupNode *home = NULL; EggGroupNode::const_iterator ci; @@ -555,11 +511,11 @@ determine_bin_home(EggBin *egg_bin) { ++vi) { EggVertex *vertex = (*vi); if (vertex->gref_size() > 1) { - // This vertex is referenced by multiple joints; the primitive - // is dynamic. + // This vertex is referenced by multiple joints; the primitive is + // dynamic. return NULL; } - + if (!vertex->_dxyzs.empty() || !vertex->_dnormals.empty() || !vertex->_drgbas.empty()) { @@ -570,24 +526,24 @@ determine_bin_home(EggBin *egg_bin) { EggVertex::const_uv_iterator uvi; for (uvi = vertex->uv_begin(); uvi != vertex->uv_end(); ++uvi) { if (!(*uvi)->_duvs.empty()) { - // Ditto: the vertex has some UV morphs; therefore the - // primitive is dynamic. + // Ditto: the vertex has some UV morphs; therefore the primitive is + // dynamic. return NULL; } } EggGroupNode *vertex_home; - + if (vertex->gref_size() == 0) { - // This vertex is not referenced at all, which means it belongs - // right where it is. + // This vertex is not referenced at all, which means it belongs right + // where it is. vertex_home = egg_primitive->get_parent(); } else { nassertr(vertex->gref_size() == 1, NULL); // This vertex is referenced exactly once. vertex_home = *vertex->gref_begin(); } - + if (home != NULL && home != vertex_home) { // Oops, two vertices are referenced by different joints! The // primitive is dynamic. @@ -599,15 +555,15 @@ determine_bin_home(EggBin *egg_bin) { } // This shouldn't be possible, unless there are no vertices--but we - // eliminate invalid primitives before we begin, so all primitives - // should have vertices, and all bins should have primitives. + // eliminate invalid primitives before we begin, so all primitives should + // have vertices, and all bins should have primitives. nassertr(home != NULL, NULL); - // So, all the vertices are assigned to the same group. This means - // all the primitives in the bin belong entirely to one joint. + // So, all the vertices are assigned to the same group. This means all the + // primitives in the bin belong entirely to one joint. - // If the group is not, in fact, a joint then we return the first - // joint above the group. + // If the group is not, in fact, a joint then we return the first joint + // above the group. EggGroup *egg_group = (EggGroup *)NULL; if (home->is_of_type(EggGroup::get_class_type())) { egg_group = DCAST(EggGroup, home); @@ -626,21 +582,21 @@ determine_bin_home(EggBin *egg_bin) { if (egg_group != (EggGroup *)NULL && egg_group->get_group_type() == EggGroup::GT_joint && !egg_group->has_dcs_type()) { - // If we have rigid geometry that is assigned to a joint without a - // flag, which means the joint didn't get created as its own - // node, go ahead and make an implicit node for the joint. + // If we have rigid geometry that is assigned to a joint without a + // flag, which means the joint didn't get created as its own node, go + // ahead and make an implicit node for the joint. if (egg_group->get_dcs_type() == EggGroup::DC_none) { - // Unless the user specifically forbade exposing the joint by - // putting an explicit " { none }" entry in the joint. In - // this case, we return NULL to treat the geometry as dynamic - // (and animate it by animating its vertices), but display lists - // and vertex buffers will perform better if more geometry is - // rigid. There's a tradeoff, though, since the cull traverser - // will have to do more work with additional transforms in the - // scene graph, and this may also break up the geometry into - // more individual pieces, which is the biggest limiting factor - // on modern PC graphics cards. +/* + * Unless the user specifically forbade exposing the joint by putting an + * explicit " { none }" entry in the joint. In this case, we return NULL + * to treat the geometry as dynamic (and animate it by animating its + * vertices), but display lists and vertex buffers will perform better if more + * geometry is rigid. There's a tradeoff, though, since the cull traverser + * will have to do more work with additional transforms in the scene graph, + * and this may also break up the geometry into more individual pieces, which + * is the biggest limiting factor on modern PC graphics cards. + */ return NULL; } @@ -656,12 +612,10 @@ determine_bin_home(EggBin *egg_bin) { return home; } -//////////////////////////////////////////////////////////////////// -// Function: CharacterMaker::get_identity_transform -// Access: Private -// Description: Returns a VertexTransform that represents the root of -// the character--it never animates. -//////////////////////////////////////////////////////////////////// +/** + * Returns a VertexTransform that represents the root of the character--it + * never animates. + */ VertexTransform *CharacterMaker:: get_identity_transform() { if (_identity_transform == (VertexTransform *)NULL) { diff --git a/panda/src/egg2pg/characterMaker.h b/panda/src/egg2pg/characterMaker.h index f9417f8ff9..b2309c0be7 100644 --- a/panda/src/egg2pg/characterMaker.h +++ b/panda/src/egg2pg/characterMaker.h @@ -1,16 +1,15 @@ -// Filename: characterMaker.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file characterMaker.h + * @author drose + * @date 2002-03-06 + */ #ifndef CHARACTERMAKER_H #define CHARACTERMAKER_H @@ -39,12 +38,10 @@ class MovingPartBase; class EggLoader; class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : CharacterMaker -// Description : Converts an EggGroup hierarchy, beginning with a -// group with set, to a character node with -// joints. -//////////////////////////////////////////////////////////////////// +/** + * Converts an EggGroup hierarchy, beginning with a group with set, to + * a character node with joints. + */ class EXPCL_PANDAEGG CharacterMaker { public: CharacterMaker(EggGroup *root, EggLoader &loader, bool structured = false); @@ -90,7 +87,7 @@ private: CharacterJointBundle *_bundle; PartGroup *_morph_root; PartGroup *_skeleton_root; - + bool _structured; }; diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index f17dedbe4f..79c3e40a2b 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -1,16 +1,15 @@ -// Filename: config_egg2pg.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg2pg.cxx + * @author drose + * @date 2002-02-26 + */ #include "config_egg2pg.h" @@ -195,14 +194,12 @@ ConfigureFn(config_egg2pg) { init_libegg2pg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libegg2pg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libegg2pg() { static bool initialized = false; @@ -211,10 +208,10 @@ init_libegg2pg() { } initialized = true; - // Define a template for all egg-object-type-* variables, so the - // system knows that these variables are defined when it finds them - // in a user's prc file, even if we haven't actually read an egg - // file that uses the particular field. + // Define a template for all egg-object-type-* variables, so the system + // knows that these variables are defined when it finds them in a user's prc + // file, even if we haven't actually read an egg file that uses the + // particular field. ConfigVariableManager *cv_mgr = ConfigVariableManager::get_global_ptr(); cv_mgr->make_variable_template ("egg-object-type-*", diff --git a/panda/src/egg2pg/config_egg2pg.h b/panda/src/egg2pg/config_egg2pg.h index e0fe18cd90..874d413319 100644 --- a/panda/src/egg2pg/config_egg2pg.h +++ b/panda/src/egg2pg/config_egg2pg.h @@ -1,16 +1,15 @@ -// Filename: config_egg2pg.h -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg2pg.h + * @author drose + * @date 2002-02-26 + */ #ifndef CONFIG_EGG2PG_H #define CONFIG_EGG2PG_H diff --git a/panda/src/egg2pg/deferredNodeProperty.cxx b/panda/src/egg2pg/deferredNodeProperty.cxx index aae062dde3..1d6f15fc45 100644 --- a/panda/src/egg2pg/deferredNodeProperty.cxx +++ b/panda/src/egg2pg/deferredNodeProperty.cxx @@ -1,16 +1,15 @@ -// Filename: deferredNodeProperty.cxx -// Created by: drose (20Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deferredNodeProperty.cxx + * @author drose + * @date 2002-03-20 + */ #include "deferredNodeProperty.h" @@ -18,21 +17,17 @@ #include "pandaNode.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: DeferredNodeProperty::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DeferredNodeProperty:: DeferredNodeProperty() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DeferredNodeProperty::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DeferredNodeProperty:: DeferredNodeProperty(const DeferredNodeProperty ©) : _flags(copy._flags), @@ -41,11 +36,9 @@ DeferredNodeProperty(const DeferredNodeProperty ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DeferredNodeProperty::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DeferredNodeProperty:: operator = (const DeferredNodeProperty ©) { _flags = copy._flags; @@ -53,12 +46,10 @@ operator = (const DeferredNodeProperty ©) { _into_collide_mask = copy._into_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: DeferredNodeProperty::compose -// Access: Public -// Description: Composes this state with the next one encountered on -// a lower node during the apply traversal. -//////////////////////////////////////////////////////////////////// +/** + * Composes this state with the next one encountered on a lower node during + * the apply traversal. + */ void DeferredNodeProperty:: compose(const DeferredNodeProperty &other) { _flags |= other._flags; @@ -72,11 +63,9 @@ compose(const DeferredNodeProperty &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: DeferredNodeProperty::apply_to_node -// Access: Public -// Description: Applies whatever state is appropriate to the node. -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever state is appropriate to the node. + */ void DeferredNodeProperty:: apply_to_node(PandaNode *node) { if (node->is_of_type(CollisionNode::get_class_type())) { @@ -89,4 +78,3 @@ apply_to_node(PandaNode *node) { } } } - diff --git a/panda/src/egg2pg/deferredNodeProperty.h b/panda/src/egg2pg/deferredNodeProperty.h index 268797af69..42bdd9e8d4 100644 --- a/panda/src/egg2pg/deferredNodeProperty.h +++ b/panda/src/egg2pg/deferredNodeProperty.h @@ -1,16 +1,15 @@ -// Filename: deferredNodeProperty.h -// Created by: drose (20Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deferredNodeProperty.h + * @author drose + * @date 2002-03-20 + */ #ifndef DEFERREDNODEPROPERTY_H #define DEFERREDNODEPROPERTY_H @@ -22,18 +21,15 @@ class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : DeferredNodeProperty -// Description : This class keeps track of all the state we must make -// note of during the graph traversal, but cannot apply -// immediately. An instance of this class may be -// assigned to nodes as they are created, and then later, -// after the geometry has been created, the graph will -// be traversed again and the state will be applied. -// -// This class is only local to this package; it is not -// exported. -//////////////////////////////////////////////////////////////////// +/** + * This class keeps track of all the state we must make note of during the + * graph traversal, but cannot apply immediately. An instance of this class + * may be assigned to nodes as they are created, and then later, after the + * geometry has been created, the graph will be traversed again and the state + * will be applied. + * + * This class is only local to this package; it is not exported. + */ class DeferredNodeProperty { public: DeferredNodeProperty(); diff --git a/panda/src/egg2pg/eggBinner.cxx b/panda/src/egg2pg/eggBinner.cxx index f06cf04ff9..3f03a92515 100644 --- a/panda/src/egg2pg/eggBinner.cxx +++ b/panda/src/egg2pg/eggBinner.cxx @@ -1,16 +1,15 @@ -// Filename: eggBinner.cxx -// Created by: drose (17Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBinner.cxx + * @author drose + * @date 2000-02-17 + */ #include "eggBinner.h" #include "eggRenderState.h" @@ -22,24 +21,20 @@ #include "eggGroup.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: EggBinner::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBinner:: EggBinner(EggLoader &loader) : _loader(loader) { } -//////////////////////////////////////////////////////////////////// -// Function: EggBinner::prepare_node -// Access: Public, Virtual -// Description: May be overridden in derived classes to perform some -// setup work as each node is encountered. This will be -// called once for each node in the egg hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to perform some setup work as each + * node is encountered. This will be called once for each node in the egg + * hierarchy. + */ void EggBinner:: prepare_node(EggNode *node) { if (node->is_of_type(EggPrimitive::get_class_type())) { @@ -50,11 +45,9 @@ prepare_node(EggNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggBinner::get_bin_number -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int EggBinner:: get_bin_number(const EggNode *node) { if (node->is_of_type(EggPrimitive::get_class_type())) { @@ -79,15 +72,12 @@ get_bin_number(const EggNode *node) { return (int)BN_none; } -//////////////////////////////////////////////////////////////////// -// Function: EggBinner::get_bin_name -// Access: Public, Virtual -// Description: May be overridden in derived classes to define a name -// for each new bin, based on its bin number, and a -// sample child. -//////////////////////////////////////////////////////////////////// +/** + * May be overridden in derived classes to define a name for each new bin, + * based on its bin number, and a sample child. + */ string EggBinner:: -get_bin_name(int bin_number, const EggNode *child) { +get_bin_name(int bin_number, const EggNode *child) { if (bin_number == BN_polyset || bin_number == BN_patches) { return DCAST(EggPrimitive, child)->get_sort_name(); } @@ -95,11 +85,9 @@ get_bin_name(int bin_number, const EggNode *child) { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggBinner::sorts_less -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggBinner:: sorts_less(int bin_number, const EggNode *a, const EggNode *b) { switch (bin_number) { @@ -129,8 +117,8 @@ sorts_less(int bin_number, const EggNode *a, const EggNode *b) { } } - // Also, if the primitive was given a name (that does not begin - // with a digit), it gets binned with similar-named primitives. + // Also, if the primitive was given a name (that does not begin with a + // digit), it gets binned with similar-named primitives. return pa->get_sort_name() < pb->get_sort_name(); } @@ -138,16 +126,16 @@ sorts_less(int bin_number, const EggNode *a, const EggNode *b) { { const EggGroup *ga = DCAST(EggGroup, a); const EggGroup *gb = DCAST(EggGroup, b); - + const EggSwitchCondition &swa = ga->get_lod(); const EggSwitchCondition &swb = gb->get_lod(); - + // For now, this is the only kind of switch condition there is. const EggSwitchConditionDistance &swda = *DCAST(EggSwitchConditionDistance, &swa); const EggSwitchConditionDistance &swdb = *DCAST(EggSwitchConditionDistance, &swb); - + // Group LOD nodes in order by switching center. return (swda._center.compare_to(swdb._center) < 0); } @@ -156,7 +144,7 @@ sorts_less(int bin_number, const EggNode *a, const EggNode *b) { case BN_nurbs_curve: // Nurbs curves and surfaces are always binned individually. return a < b; - + case BN_none: break; } diff --git a/panda/src/egg2pg/eggBinner.h b/panda/src/egg2pg/eggBinner.h index 7d5a69cccd..a259e522d9 100644 --- a/panda/src/egg2pg/eggBinner.h +++ b/panda/src/egg2pg/eggBinner.h @@ -1,16 +1,15 @@ -// Filename: eggBinner.h -// Created by: drose (17Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBinner.h + * @author drose + * @date 2000-02-17 + */ #ifndef EGGBINNER_H #define EGGBINNER_H @@ -21,20 +20,16 @@ class EggLoader; -//////////////////////////////////////////////////////////////////// -// Class : EggBinner -// Description : A special binner used only within this package to -// pre-process the egg tree for the loader and group -// things together as appropriate. -// -// It is used to collect similar polygons together for a -// Geom, as well as to group related LOD children -// together under a single LOD node. -//////////////////////////////////////////////////////////////////// +/** + * A special binner used only within this package to pre-process the egg tree + * for the loader and group things together as appropriate. + * + * It is used to collect similar polygons together for a Geom, as well as to + * group related LOD children together under a single LOD node. + */ class EggBinner : public EggBinMaker { public: - // The BinNumber serves to identify why a particular EggBin was - // created. + // The BinNumber serves to identify why a particular EggBin was created. enum BinNumber { BN_none = 0, BN_polyset, diff --git a/panda/src/egg2pg/eggLoader.I b/panda/src/egg2pg/eggLoader.I index c65313a37c..c2a047d3ba 100644 --- a/panda/src/egg2pg/eggLoader.I +++ b/panda/src/egg2pg/eggLoader.I @@ -1,23 +1,19 @@ -// Filename: eggLoader.I -// Created by: drose (13Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLoader.I + * @author drose + * @date 2005-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::PrimitiveUnifier::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggLoader::PrimitiveUnifier:: PrimitiveUnifier(const GeomPrimitive *prim) : _type(prim->get_type()), @@ -26,11 +22,9 @@ PrimitiveUnifier(const GeomPrimitive *prim) : } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::PrimitiveUnifier::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggLoader::PrimitiveUnifier:: operator < (const PrimitiveUnifier &other) const { if (_type != other._type) { diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 11d3e4f499..ad309e0174 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -1,16 +1,15 @@ -// Filename: eggLoader.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLoader.cxx + * @author drose + * @date 2002-02-26 + */ #include "pandabase.h" @@ -101,8 +100,8 @@ #include #include -// This class is used in make_node(EggBin *) to sort LOD instances in -// order by switching distance. +// This class is used in make_node(EggBin *) to sort LOD instances in order by +// switching distance. class LODInstance { public: LODInstance(EggNode *egg_node); @@ -119,9 +118,8 @@ LODInstance(EggNode *egg_node) { nassertv(egg_node != NULL); _egg_node = egg_node; - // We expect this egg node to be an EggGroup with an LOD - // specification. That's what the EggBinner collected together, - // after all. + // We expect this egg node to be an EggGroup with an LOD specification. + // That's what the EggBinner collected together, after all. EggGroup *egg_group = DCAST(EggGroup, egg_node); nassertv(egg_group->has_lod()); const EggSwitchCondition &sw = egg_group->get_lod(); @@ -131,11 +129,9 @@ LODInstance(EggNode *egg_node) { } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggLoader:: EggLoader() { // We need to enforce whatever coordinate system the user asked for. @@ -146,12 +142,9 @@ EggLoader() { _dynamic_override_char_maker = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::Constructor -// Access: Public -// Description: The EggLoader constructor makes a copy of the EggData -// passed in. -//////////////////////////////////////////////////////////////////// +/** + * The EggLoader constructor makes a copy of the EggData passed in. + */ EggLoader:: EggLoader(const EggData *data) : _data(new EggData(*data)) @@ -162,17 +155,15 @@ EggLoader(const EggData *data) : } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::build_graph -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: build_graph() { _deferred_nodes.clear(); - // Expand all of the ObjectType flags before we do anything else; - // that might prune out large portions of the scene. + // Expand all of the ObjectType flags before we do anything else; that might + // prune out large portions of the scene. if (!expand_all_object_types(_data)) { return; } @@ -186,18 +177,16 @@ build_graph() { _data->get_connected_shading(); _data->unify_attributes(true, egg_flat_shading, true); - // Now we need to get the connected shading again, since in unifying - // the attributes we may have made vertices suddenly become - // identical to each other, thereby connecting more primitives than - // before. + // Now we need to get the connected shading again, since in unifying the + // attributes we may have made vertices suddenly become identical to each + // other, thereby connecting more primitives than before. _data->clear_connected_shading(); _data->remove_unused_vertices(true); _data->get_connected_shading(); - // Sequences and switches have special needs. Make sure that - // primitives parented directly to a sequence or switch are sorted - // into sub-groups first, to prevent them being unified into a - // single polyset. + // Sequences and switches have special needs. Make sure that primitives + // parented directly to a sequence or switch are sorted into sub-groups + // first, to prevent them being unified into a single polyset. separate_switches(_data); if (egg_emulate_bface) { @@ -209,7 +198,7 @@ build_graph() { EggBinner binner(*this); binner.make_bins(_data); - // ((EggGroupNode *)_data)->write(cerr, 0); + // ((EggGroupNode *)_data)->write(cerr, 0); // Now build up the scene graph. _root = new ModelRoot(_data->get_egg_filename(), _data->get_egg_timestamp()); @@ -225,14 +214,11 @@ build_graph() { apply_deferred_nodes(_root, DeferredNodeProperty()); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::reparent_decals -// Access: Public -// Description: For each node representing a decal base geometry -// (i.e. a node corresponding to an EggGroup with the -// decal flag set), move all of its nested geometry -// directly below the GeomNode representing the group. -//////////////////////////////////////////////////////////////////// +/** + * For each node representing a decal base geometry (i.e. a node + * corresponding to an EggGroup with the decal flag set), move all of its + * nested geometry directly below the GeomNode representing the group. + */ void EggLoader:: reparent_decals() { ExtraNodes::const_iterator di; @@ -268,9 +254,8 @@ reparent_decals() { << "; no geometry within group.\n"; _error = true; } else { - // Now reparent all of the non-GeomNodes to this node. We have - // to be careful so we don't get lost as we self-modify this - // list. + // Now reparent all of the non-GeomNodes to this node. We have to be + // careful so we don't get lost as we self-modify this list. int i = 0; while (i < num_children) { NodePath child = parent.get_child(i); @@ -289,15 +274,11 @@ reparent_decals() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::start_sequences -// Access: Public -// Description: Starts all of the SequenceNodes we created looping. -// We have to wait until the entire graph is built up to -// do this, because the SequenceNode needs its full set -// of children before it can know how many frames to -// loop. -//////////////////////////////////////////////////////////////////// +/** + * Starts all of the SequenceNodes we created looping. We have to wait until + * the entire graph is built up to do this, because the SequenceNode needs its + * full set of children before it can know how many frames to loop. + */ void EggLoader:: start_sequences() { ExtraNodes::const_iterator ni; @@ -307,16 +288,12 @@ start_sequences() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_polyset -// Access: Public -// Description: Creates a polyset--that is, a Geom--from the -// primitives that have already been grouped into a bin. -// If transform is non-NULL, it represents the transform -// to apply to the vertices (instead of the default -// transform based on the bin's position within the -// hierarchy). -//////////////////////////////////////////////////////////////////// +/** + * Creates a polyset--that is, a Geom--from the primitives that have already + * been grouped into a bin. If transform is non-NULL, it represents the + * transform to apply to the vertices (instead of the default transform based + * on the bin's position within the hierarchy). + */ void EggLoader:: make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, bool is_dynamic, CharacterMaker *character_maker) { @@ -325,9 +302,8 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, return; } - // We know that all of the primitives in the bin have the same - // render state, so we can get that information from the first - // primitive. + // We know that all of the primitives in the bin have the same render state, + // so we can get that information from the first primitive. EggGroupNode::const_iterator ci = egg_bin->begin(); nassertv(ci != egg_bin->end()); CPT(EggPrimitive) first_prim = DCAST(EggPrimitive, (*ci)); @@ -340,12 +316,11 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, return; } - // Generate an optimal vertex pool (or multiple vertex pools, if we - // have a lot of vertex) for the polygons within just the bin. Each - // EggVertexPool translates directly to an optimal GeomVertexData - // structure. + // Generate an optimal vertex pool (or multiple vertex pools, if we have a + // lot of vertex) for the polygons within just the bin. Each EggVertexPool + // translates directly to an optimal GeomVertexData structure. EggVertexPools vertex_pools; - egg_bin->rebuild_vertex_pools(vertex_pools, (unsigned int)egg_max_vertices, + egg_bin->rebuild_vertex_pools(vertex_pools, (unsigned int)egg_max_vertices, false); if (egg_mesh) { @@ -353,56 +328,55 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, egg_bin->mesh_triangles(render_state->_flat_shaded ? EggGroupNode::T_flat_shaded : 0); } else { - // If we're not using the mesher, at least triangulate any - // higher-order polygons we might have. + // If we're not using the mesher, at least triangulate any higher-order + // polygons we might have. egg_bin->triangulate_polygons(EggGroupNode::T_polygon | EggGroupNode::T_convex); } - // Now that we've meshed, apply the per-prim attributes onto the - // vertices, so we can copy them to the GeomVertexData. + // Now that we've meshed, apply the per-prim attributes onto the vertices, + // so we can copy them to the GeomVertexData. egg_bin->apply_first_attribute(false); egg_bin->post_apply_flat_attribute(false); - //egg_bin->write(cerr, 0); + // egg_bin->write(cerr, 0); PT(GeomNode) geom_node; - // Now iterate through each EggVertexPool. Normally, there's only - // one, but if we have a really big mesh, it might have been split - // into multiple vertex pools (to keep each one within the - // egg_max_vertices constraint). + // Now iterate through each EggVertexPool. Normally, there's only one, but + // if we have a really big mesh, it might have been split into multiple + // vertex pools (to keep each one within the egg_max_vertices constraint). EggVertexPools::iterator vpi; for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { EggVertexPool *vertex_pool = (*vpi); vertex_pool->remove_unused_vertices(); - // vertex_pool->write(cerr, 0); + // vertex_pool->write(cerr, 0); bool has_overall_color; LColor overall_color; vertex_pool->check_overall_color(has_overall_color, overall_color); if (!egg_flat_colors) { - // If flat colors aren't allowed, then we don't care whether - // there is an overall color. In that case, treat all vertex - // pools as if they contain a combination of multiple colors. + // If flat colors aren't allowed, then we don't care whether there is an + // overall color. In that case, treat all vertex pools as if they + // contain a combination of multiple colors. has_overall_color = false; } PT(TransformBlendTable) blend_table; if (is_dynamic) { - // Dynamic vertex pools will require a TransformBlendTable to - // indicate how the vertices are to be animated. + // Dynamic vertex pools will require a TransformBlendTable to indicate + // how the vertices are to be animated. blend_table = make_blend_table(vertex_pool, egg_bin, character_maker); - // Now that we've created the blend table, we can re-order the - // vertices in the pool to efficiently group vertices together - // that will share the same transform matrix. (We have to - // re-order them before we create primitives, below, because - // this will change the vertex index numbers.) + // Now that we've created the blend table, we can re-order the vertices + // in the pool to efficiently group vertices together that will share + // the same transform matrix. (We have to re-order them before we + // create primitives, below, because this will change the vertex index + // numbers.) vertex_pool->sort_by_external_index(); } - - // Create a handful of GeomPrimitives corresponding to the various - // types of primitives that reference this vertex pool. + + // Create a handful of GeomPrimitives corresponding to the various types + // of primitives that reference this vertex pool. UniquePrimitives unique_primitives; Primitives primitives; for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) { @@ -423,40 +397,39 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, } // Now convert this vertex pool to a GeomVertexData. - PT(GeomVertexData) vertex_data = + PT(GeomVertexData) vertex_data = make_vertex_data(render_state, vertex_pool, egg_bin, mat, blend_table, is_dynamic, character_maker, has_overall_color); nassertv(vertex_data != (GeomVertexData *)NULL); // And create a Geom to hold the primitives. PT(Geom) geom = new Geom(vertex_data); - + // Add each new primitive to the Geom. Primitives::const_iterator pi; for (pi = primitives.begin(); pi != primitives.end(); ++pi) { PT(GeomPrimitive) primitive = (*pi); if (primitive->is_indexed()) { - // Since we may have over-allocated while we were filling up - // the primitives, down-allocate now. + // Since we may have over-allocated while we were filling up the + // primitives, down-allocate now. primitive->reserve_num_vertices(primitive->get_num_vertices()); } geom->add_primitive(primitive); } - - // vertex_data->write(cerr); - // geom->write(cerr); - // render_state->_state->write(cerr, 0); + + // vertex_data->write(cerr); geom->write(cerr); + // render_state->_state->write(cerr, 0); // Create a new GeomNode if we haven't already. if (geom_node == (GeomNode *)NULL) { - // Now, is our parent node a GeomNode, or just an ordinary - // PandaNode? If it's a GeomNode, we can add the new Geom directly - // to our parent; otherwise, we need to create a new node. + // Now, is our parent node a GeomNode, or just an ordinary PandaNode? + // If it's a GeomNode, we can add the new Geom directly to our parent; + // otherwise, we need to create a new node. if (parent->is_geom_node() && !render_state->_hidden) { geom_node = DCAST(GeomNode, parent); - + } else { geom_node = new GeomNode(egg_bin->get_name()); if (render_state->_hidden) { @@ -479,7 +452,7 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, geom_node->add_geom(geom, geom_state); } } - + if (geom_node != (GeomNode *)NULL && egg_show_normals) { // Create some more geometry to visualize each normal. for (vpi = vertex_pools.begin(); vpi != vertex_pools.end(); ++vpi) { @@ -489,12 +462,10 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_transform -// Access: Public -// Description: Creates a TransformState object corresponding to the -// indicated EggTransform. -//////////////////////////////////////////////////////////////////// +/** + * Creates a TransformState object corresponding to the indicated + * EggTransform. + */ CPT(TransformState) EggLoader:: make_transform(const EggTransform *egg_transform) { // We'll build up the transform componentwise, so we preserve any @@ -610,24 +581,20 @@ make_transform(const EggTransform *egg_transform) { return ts; } - // Finally, we uniquify all the matrix-based TransformStates we - // create by complete matrix value. The TransformState class - // doesn't normally go this far, because of the cost of this - // additional uniquification step, but this is the egg loader so we - // don't mind spending a little bit of extra time here to get a more - // optimal result. + // Finally, we uniquify all the matrix-based TransformStates we create by + // complete matrix value. The TransformState class doesn't normally go this + // far, because of the cost of this additional uniquification step, but this + // is the egg loader so we don't mind spending a little bit of extra time + // here to get a more optimal result. TransformStates::iterator tsi = _transform_states.insert(TransformStates::value_type(ts->get_mat(), ts)).first; - + return (*tsi).second; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::show_normals -// Access: Private -// Description: In the presence of egg-show-normals, generate some -// additional geometry to represent the normals, -// tangents, and binormals of each vertex. -//////////////////////////////////////////////////////////////////// +/** + * In the presence of egg-show-normals, generate some additional geometry to + * represent the normals, tangents, and binormals of each vertex. + */ void EggLoader:: show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node) { PT(GeomPrimitive) primitive = new GeomLines(Geom::UH_static); @@ -652,8 +619,7 @@ show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node) { primitive->close_primitive(); } - // Also look for tangents and binormals in each texture coordinate - // set. + // Also look for tangents and binormals in each texture coordinate set. EggVertex::const_uv_iterator uvi; for (uvi = vert->uv_begin(); uvi != vert->uv_end(); ++uvi) { EggVertexUV *uv_obj = (*uvi); @@ -681,13 +647,11 @@ show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node) { geom_node->add_geom(geom); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_nurbs_curve -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: -make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, +make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, const LMatrix4d &mat) { if (egg_load_old_curves) { // Make a NurbsCurve instead of a RopeNode (old interface). @@ -728,7 +692,7 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, // Respect the subdivision values in the egg file, if any. if (egg_curve->get_subdiv() != 0) { - int subdiv_per_segment = + int subdiv_per_segment = (int)((egg_curve->get_subdiv() + 0.5) / nurbs->get_num_segments()); rope->set_num_subdiv(max(subdiv_per_segment, 1)); } @@ -754,14 +718,11 @@ make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, parent->add_child(rope); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_old_nurbs_curve -// Access: Private -// Description: This deprecated interface creates a NurbsCurve object -// for the EggNurbsCurve entry. It will eventually be -// removed in favor of the above, which creates a -// RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * This deprecated interface creates a NurbsCurve object for the EggNurbsCurve + * entry. It will eventually be removed in favor of the above, which creates + * a RopeNode. + */ void EggLoader:: make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, const LMatrix4d &mat) { @@ -831,11 +792,9 @@ make_old_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, parent->add_child(curve); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_nurbs_surface -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: make_nurbs_surface(EggNurbsSurface *egg_surface, PandaNode *parent, const LMatrix4d &mat) { @@ -853,12 +812,12 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, PandaNode *parent, // Respect the subdivision values in the egg file, if any. if (egg_surface->get_u_subdiv() != 0) { - int u_subdiv_per_segment = + int u_subdiv_per_segment = (int)((egg_surface->get_u_subdiv() + 0.5) / nurbs->get_num_u_segments()); sheet->set_num_u_subdiv(max(u_subdiv_per_segment, 1)); } if (egg_surface->get_v_subdiv() != 0) { - int v_subdiv_per_segment = + int v_subdiv_per_segment = (int)((egg_surface->get_v_subdiv() + 0.5) / nurbs->get_num_v_segments()); sheet->set_num_v_subdiv(max(v_subdiv_per_segment, 1)); } @@ -883,11 +842,9 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, PandaNode *parent, parent->add_child(sheet); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::load_textures -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: load_textures() { // First, collect all the textures that are referenced. @@ -900,23 +857,20 @@ load_textures() { TextureDef def; if (load_texture(def, egg_tex)) { - // Now associate the pointers, so we'll be able to look up the - // Texture pointer given an EggTexture pointer, later. + // Now associate the pointers, so we'll be able to look up the Texture + // pointer given an EggTexture pointer, later. _textures[egg_tex] = def; } } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::load_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggLoader:: load_texture(TextureDef &def, EggTexture *egg_tex) { - // Check to see if we should reduce the number of channels in - // the texture. + // Check to see if we should reduce the number of channels in the texture. int wanted_channels = 0; bool wanted_alpha = false; switch (egg_tex->get_format()) { @@ -958,10 +912,9 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { wanted_alpha = egg_tex->has_alpha_filename(); } - // Since some properties of the textures are inferred from the - // texture files themselves (if the properties are not explicitly - // specified in the egg file), then we add the textures as - // dependents for the egg file. + // Since some properties of the textures are inferred from the texture files + // themselves (if the properties are not explicitly specified in the egg + // file), then we add the textures as dependents for the egg file. if (_record != (BamCacheRecord *)NULL) { _record->add_dependent_file(egg_tex->get_fullpath()); if (egg_tex->has_alpha_filename() && wanted_alpha) { @@ -981,7 +934,7 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { case EggTexture::FT_linear: case EggTexture::FT_unspecified: break; - + case EggTexture::FT_nearest_mipmap_nearest: case EggTexture::FT_linear_mipmap_nearest: case EggTexture::FT_nearest_mipmap_linear: @@ -1033,16 +986,16 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { return false; } - // Record the original filenames in the textures (as loaded from the - // egg file). These filenames will be written back to the bam file - // if the bam file is written out. + // Record the original filenames in the textures (as loaded from the egg + // file). These filenames will be written back to the bam file if the bam + // file is written out. tex->set_filename(egg_tex->get_filename()); if (egg_tex->has_alpha_filename() && wanted_alpha) { tex->set_alpha_filename(egg_tex->get_alpha_filename()); } - // See if there is some egg data hanging on the texture. In - // particular, the TxaFileFilter might have left that here for us. + // See if there is some egg data hanging on the texture. In particular, the + // TxaFileFilter might have left that here for us. TypedReferenceCount *aux = tex->get_aux_data("egg"); if (aux != (TypedReferenceCount *)NULL && aux->is_of_type(EggTexture::get_class_type())) { @@ -1077,11 +1030,9 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::apply_texture_attributes -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { if (egg_tex->get_compression_mode() != EggTexture::CM_default) { @@ -1287,9 +1238,8 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { break; case EggTexture::F_rgb8: case EggTexture::F_rgba8: - // We'll quietly accept RGBA8 for a 3-component texture, since - // flt2egg generates these for 3-component as well as for - // 4-component textures. + // We'll quietly accept RGBA8 for a 3-component texture, since flt2egg + // generates these for 3-component as well as for 4-component textures. tex->set_format(Texture::F_rgb8); break; case EggTexture::F_rgb5: @@ -1366,14 +1316,11 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::convert_compression_mode -// Access: Private -// Description: Returns the Texture::CompressionMode enum -// corresponding to the EggTexture::CompressionMode. -// Returns CM_default if the compression mode is -// unspecified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Texture::CompressionMode enum corresponding to the + * EggTexture::CompressionMode. Returns CM_default if the compression mode is + * unspecified. + */ Texture::CompressionMode EggLoader:: convert_compression_mode(EggTexture::CompressionMode compression_mode) const { switch (compression_mode) { @@ -1410,13 +1357,10 @@ convert_compression_mode(EggTexture::CompressionMode compression_mode) const { return Texture::CM_default; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::convert_wrap_mode -// Access: Private -// Description: Returns the SamplerState::WrapMode enum corresponding to -// the EggTexture::WrapMode. Returns WM_repeat if the -// wrap mode is unspecified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SamplerState::WrapMode enum corresponding to the + * EggTexture::WrapMode. Returns WM_repeat if the wrap mode is unspecified. + */ SamplerState::WrapMode EggLoader:: convert_wrap_mode(EggTexture::WrapMode wrap_mode) const { switch (wrap_mode) { @@ -1444,21 +1388,17 @@ convert_wrap_mode(EggTexture::WrapMode wrap_mode) const { return SamplerState::WM_repeat; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_texture_stage -// Access: Private -// Description: Creates a TextureStage object suitable for rendering -// the indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Creates a TextureStage object suitable for rendering the indicated texture. + */ PT(TextureStage) EggLoader:: make_texture_stage(const EggTexture *egg_tex) { - // If the egg texture specifies any relevant TextureStage - // properties, or if it is multitextured on top of anything else, it - // gets its own texture stage; otherwise, it gets the default - // texture stage. + // If the egg texture specifies any relevant TextureStage properties, or if + // it is multitextured on top of anything else, it gets its own texture + // stage; otherwise, it gets the default texture stage. if (!egg_tex->has_stage_name() && !egg_tex->has_uv_name() && - !egg_tex->has_color() && + !egg_tex->has_color() && (egg_tex->get_env_type() == EggTexture::ET_unspecified || egg_tex->get_env_type() == EggTexture::ET_modulate) && egg_tex->get_combine_mode(EggTexture::CC_rgb) == EggTexture::CM_unspecified && @@ -1476,23 +1416,23 @@ make_texture_stage(const EggTexture *egg_tex) { case EggTexture::ET_modulate: stage->set_mode(TextureStage::M_modulate); break; - + case EggTexture::ET_decal: stage->set_mode(TextureStage::M_decal); break; - + case EggTexture::ET_blend: stage->set_mode(TextureStage::M_blend); break; - + case EggTexture::ET_replace: stage->set_mode(TextureStage::M_replace); break; - + case EggTexture::ET_add: stage->set_mode(TextureStage::M_add); break; - + case EggTexture::ET_blend_color_scale: stage->set_mode(TextureStage::M_blend_color_scale); break; @@ -1588,7 +1528,7 @@ make_texture_stage(const EggTexture *egg_tex) { get_combine_source(egg_tex, EggTexture::CC_alpha, 1), get_combine_operand(egg_tex, EggTexture::CC_alpha, 1)); break; - + case EggTexture::CM_interpolate: stage->set_combine_alpha(get_combine_mode(egg_tex, EggTexture::CC_alpha), get_combine_source(egg_tex, EggTexture::CC_alpha, 0), @@ -1607,7 +1547,7 @@ make_texture_stage(const EggTexture *egg_tex) { if (egg_tex->has_uv_name()) { - PT(InternalName) name = + PT(InternalName) name = InternalName::get_texcoord_name(egg_tex->get_uv_name()); stage->set_texcoord_name(name); } @@ -1635,15 +1575,11 @@ make_texture_stage(const EggTexture *egg_tex) { return TextureStagePool::get_stage(stage); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::separate_switches -// Access: Private -// Description: Walks the tree recursively, looking for EggPrimitives -// that are children of sequence or switch nodes. If -// any are found, they are moved within their own group -// to protect them from being flattened with their -// neighbors. -//////////////////////////////////////////////////////////////////// +/** + * Walks the tree recursively, looking for EggPrimitives that are children of + * sequence or switch nodes. If any are found, they are moved within their + * own group to protect them from being flattened with their neighbors. + */ void EggLoader:: separate_switches(EggNode *egg_node) { bool parent_has_switch = false; @@ -1663,7 +1599,7 @@ separate_switches(EggNode *egg_node) { ++cnext; PT(EggNode) child = (*ci); - if (parent_has_switch && + if (parent_has_switch && child->is_of_type(EggPrimitive::get_class_type())) { // Move this child under a new node. PT(EggGroup) new_group = new EggGroup(child->get_name()); @@ -1678,14 +1614,11 @@ separate_switches(EggNode *egg_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::emulate_bface -// Access: Private -// Description: Looks for EggPolygons with a bface flag applied to -// them. Any such polygons are duplicated into a pair -// of back-to-back polygons, and the bface flag is -// removed. -//////////////////////////////////////////////////////////////////// +/** + * Looks for EggPolygons with a bface flag applied to them. Any such polygons + * are duplicated into a pair of back-to-back polygons, and the bface flag is + * removed. + */ void EggLoader:: emulate_bface(EggNode *egg_node) { if (egg_node->is_of_type(EggGroupNode::get_class_type())) { @@ -1727,17 +1660,15 @@ emulate_bface(EggNode *egg_node) { emulate_bface(child); } - // Now that we've iterated through all the children, add in any - // duplicated polygons we generated. + // Now that we've iterated through all the children, add in any duplicated + // polygons we generated. egg_group->steal_children(*dup_prims); } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_node -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_node(EggNode *egg_node, PandaNode *parent) { if (egg_node->is_of_type(EggBin::get_class_type())) { @@ -1753,16 +1684,14 @@ make_node(EggNode *egg_node, PandaNode *parent) { return (PandaNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_node (EggBin) -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_node(EggBin *egg_bin, PandaNode *parent) { - // An EggBin might mean an LOD node (i.e. a parent of one or more - // EggGroups with LOD specifications), or it might mean a polyset - // node (a parent of one or more similar EggPrimitives). + // An EggBin might mean an LOD node (i.e. a parent of one or more EggGroups + // with LOD specifications), or it might mean a polyset node (a parent of + // one or more similar EggPrimitives). switch (egg_bin->get_bin_number()) { case EggBinner::BN_polyset: case EggBinner::BN_patches: @@ -1802,43 +1731,41 @@ make_node(EggBin *egg_bin, PandaNode *parent) { return (PandaNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_lod -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_lod(EggBin *egg_bin, PandaNode *parent) { PT(LODNode) lod_node = LODNode::make_default_lod(egg_bin->get_name()); pvector instances; - + EggGroup::const_iterator ci; for (ci = egg_bin->begin(); ci != egg_bin->end(); ++ci) { LODInstance instance(*ci); instances.push_back(instance); } - - // Now that we've created all of our children, put them in the - // proper order and tell the LOD node about them. + + // Now that we've created all of our children, put them in the proper order + // and tell the LOD node about them. sort(instances.begin(), instances.end()); - + if (!instances.empty()) { - // Set up the LOD node's center. All of the children should have - // the same center, because that's how we binned them. + // Set up the LOD node's center. All of the children should have the same + // center, because that's how we binned them. lod_node->set_center(LCAST(PN_stdfloat, instances[0]._d->_center)); } - + for (size_t i = 0; i < instances.size(); i++) { // Create the children in the proper order within the scene graph. const LODInstance &instance = instances[i]; make_node(instance._egg_node, lod_node); - - // All of the children should have the same center, because that's - // how we binned them. + + // All of the children should have the same center, because that's how we + // binned them. nassertr(lod_node->get_center().almost_equal (LCAST(PN_stdfloat, instance._d->_center), 0.01), NULL); - + // Tell the LOD node about this child's switching distances. lod_node->add_switch(instance._d->_switch_in, instance._d->_switch_out); } @@ -1847,11 +1774,9 @@ make_lod(EggBin *egg_bin, PandaNode *parent) { return create_group_arc(egg_bin, parent, lod_node); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_node (EggGroup) -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_node(EggGroup *egg_group, PandaNode *parent) { PT(PandaNode) node = NULL; @@ -1859,13 +1784,13 @@ make_node(EggGroup *egg_group, PandaNode *parent) { if (egg_group->get_dart_type() != EggGroup::DT_none) { // A group with the flag set means to create a character. bool structured = (egg_group->get_dart_type() == EggGroup::DT_structured); - - CharacterMaker char_maker(egg_group, *this, structured); + + CharacterMaker char_maker(egg_group, *this, structured); node = char_maker.make_node(); if(structured) { - //we're going to generate the rest of the children normally - //except we'll be making dynamic geometry + // we're going to generate the rest of the children normally except + // we'll be making dynamic geometry _dynamic_override = true; _dynamic_override_char_maker = &char_maker; EggGroup::const_iterator ci; @@ -1886,14 +1811,14 @@ make_node(EggGroup *egg_group, PandaNode *parent) { node->xform(LCAST(PN_stdfloat, egg_group->get_vertex_to_node())); if ((egg_group->get_collide_flags() & EggGroup::CF_keep) != 0) { - // If we also specified to keep the geometry, continue the - // traversal. In this case, we create a new PandaNode to be the - // parent of the visible geometry and the collision geometry. + // If we also specified to keep the geometry, continue the traversal. + // In this case, we create a new PandaNode to be the parent of the + // visible geometry and the collision geometry. PandaNode *combined = new PandaNode(""); parent->add_child(combined); combined->add_child(node); node = combined; - + EggGroup::const_iterator ci; for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { make_node(*ci, combined); @@ -1904,9 +1829,9 @@ make_node(EggGroup *egg_group, PandaNode *parent) { return node; } else if (egg_group->get_portal_flag()) { - // Create a portal instead of a regular polyset. Scan the - // children of this node looking for a polygon, similar to the - // collision polygon case, above. + // Create a portal instead of a regular polyset. Scan the children of + // this node looking for a polygon, similar to the collision polygon case, + // above. PortalNode *pnode = new PortalNode(egg_group->get_name()); node = pnode; @@ -1917,9 +1842,9 @@ make_node(EggGroup *egg_group, PandaNode *parent) { } } else if (egg_group->get_occluder_flag()) { - // Create an occluder instead of a regular polyset. Scan the - // children of this node looking for a polygon, the same as the - // portal polygon case, above. + // Create an occluder instead of a regular polyset. Scan the children of + // this node looking for a polygon, the same as the portal polygon case, + // above. OccluderNode *pnode = new OccluderNode(egg_group->get_name()); node = pnode; @@ -1930,13 +1855,13 @@ make_node(EggGroup *egg_group, PandaNode *parent) { } } else if (egg_group->get_polylight_flag()) { - // Create a polylight instead of a regular polyset. - // use make_sphere to get the center, radius and color - //egg2pg_cat.debug() << "polylight node\n"; + // Create a polylight instead of a regular polyset. use make_sphere to + // get the center, radius and color egg2pg_cat.debug() << "polylight + // node\n"; LPoint3 center; LColor color; PN_stdfloat radius; - + if (!make_sphere(egg_group, EggGroup::CF_none, center, radius, color)) { egg2pg_cat.warning() << "Polylight " << egg_group->get_name() << " make_sphere failed!\n"; @@ -1960,19 +1885,19 @@ make_node(EggGroup *egg_group, PandaNode *parent) { // Create a switch node. node = new SwitchNode(egg_group->get_name()); } - + EggGroup::const_iterator ci; for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { make_node(*ci, node); } } else if (egg_group->has_scrolling_uvs()) { node = new UvScrollNode(egg_group->get_name(), egg_group->get_scroll_u(), egg_group->get_scroll_v(), egg_group->get_scroll_w(), egg_group->get_scroll_r()); - + EggGroup::const_iterator ci; for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { make_node(*ci, node); } - + } else if (egg_group->get_model_flag() || egg_group->has_dcs_type()) { // A model or DCS flag; create a model node. node = new ModelNode(egg_group->get_name()); @@ -2001,15 +1926,15 @@ make_node(EggGroup *egg_group, PandaNode *parent) { } } else { - // A normal group; just create a normal node, and traverse. But - // if all of the children of this group are polysets, anticipate - // this for the benefit of smaller grouping, and create a single - // GeomNode for all of the children. + // A normal group; just create a normal node, and traverse. But if all of + // the children of this group are polysets, anticipate this for the + // benefit of smaller grouping, and create a single GeomNode for all of + // the children. bool all_polysets = false; bool any_hidden = false; - // We don't want to ever create a GeomNode under a "decal" flag, - // since that can confuse the decal reparenting. + // We don't want to ever create a GeomNode under a "decal" flag, since + // that can confuse the decal reparenting. if (!egg_group->determine_decal()) { check_for_polysets(egg_group, all_polysets, any_hidden); } @@ -2045,14 +1970,11 @@ make_node(EggGroup *egg_group, PandaNode *parent) { return create_group_arc(egg_group, parent, node); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::create_group_arc -// Access: Private -// Description: Creates the arc parenting a new group to the scene -// graph, and applies any relevant attribs to the -// arc according to the EggGroup node that inspired the -// group. -//////////////////////////////////////////////////////////////////// +/** + * Creates the arc parenting a new group to the scene graph, and applies any + * relevant attribs to the arc according to the EggGroup node that inspired + * the group. + */ PandaNode *EggLoader:: create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { parent->add_child(node); @@ -2090,9 +2012,8 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { } // If the group has the "decal" flag set, it means that all of the - // descendant groups will be decaled onto the geometry within - // this group. This means we'll need to reparent things a bit - // afterward. + // descendant groups will be decaled onto the geometry within this group. + // This means we'll need to reparent things a bit afterward. _decals.insert(node); } @@ -2112,9 +2033,9 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { node->set_attrib(ColorBlendAttrib::make(mode, a, b, color)); } - // If the group specified some property that should propagate down - // to the leaves, we have to remember this node and apply the - // property later, after we've created the actual geometry. + // If the group specified some property that should propagate down to the + // leaves, we have to remember this node and apply the property later, after + // we've created the actual geometry. DeferredNodeProperty def; if (egg_group->has_collide_mask()) { def._from_collide_mask = egg_group->get_collide_mask(); @@ -2139,21 +2060,18 @@ create_group_arc(EggGroup *egg_group, PandaNode *parent, PandaNode *node) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_node (EggTable) -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_node(EggTable *egg_table, PandaNode *parent) { if (egg_table->get_table_type() != EggTable::TT_bundle) { - // We only do anything with bundles. Isolated tables are treated - // as ordinary groups. + // We only do anything with bundles. Isolated tables are treated as + // ordinary groups. return make_node(DCAST(EggGroupNode, egg_table), parent); } - // It's an actual bundle, so make an AnimBundle from it and its - // descendants. + // It's an actual bundle, so make an AnimBundle from it and its descendants. AnimBundleMaker bundle_maker(egg_table); AnimBundleNode *node = bundle_maker.make_node(); parent->add_child(node); @@ -2161,11 +2079,9 @@ make_node(EggTable *egg_table, PandaNode *parent) { } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_node (EggGroupNode) -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode *EggLoader:: make_node(EggGroupNode *egg_group, PandaNode *parent) { PandaNode *node = new PandaNode(egg_group->get_name()); @@ -2179,13 +2095,10 @@ make_node(EggGroupNode *egg_group, PandaNode *parent) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::check_for_polysets -// Access: Private -// Description: Sets all_polysets true if all of the children of this -// node represent a polyset. Sets any_hidden true if -// any of those polysets are flagged hidden. -//////////////////////////////////////////////////////////////////// +/** + * Sets all_polysets true if all of the children of this node represent a + * polyset. Sets any_hidden true if any of those polysets are flagged hidden. + */ void EggLoader:: check_for_polysets(EggGroup *egg_group, bool &all_polysets, bool &any_hidden) { all_polysets = (!egg_group->empty()); @@ -2196,9 +2109,8 @@ check_for_polysets(EggGroup *egg_group, bool &all_polysets, bool &any_hidden) { if ((*ci)->is_of_type(EggBin::get_class_type())) { EggBin *egg_bin = DCAST(EggBin, (*ci)); if (egg_bin->get_bin_number() == EggBinner::BN_polyset) { - // We know that all of the primitives in the bin have the same - // render state, so we can get that information from the first - // primitive. + // We know that all of the primitives in the bin have the same render + // state, so we can get that information from the first primitive. EggGroup::const_iterator bci = egg_bin->begin(); nassertv(bci != egg_bin->end()); const EggPrimitive *first_prim; @@ -2214,23 +2126,20 @@ check_for_polysets(EggGroup *egg_group, bool &all_polysets, bool &any_hidden) { return; } } else if ((*ci)->is_of_type(EggGroup::get_class_type())) { - // Other kinds of children, like vertex pools, comments, - // textures, etc., are ignored; but groups indicate more nodes, - // so if we find a nested group it means we're not all polysets. + // Other kinds of children, like vertex pools, comments, textures, etc., + // are ignored; but groups indicate more nodes, so if we find a nested + // group it means we're not all polysets. all_polysets = false; return; } } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_vertex_data -// Access: Private -// Description: Creates a GeomVertexData structure from the vertex -// pool, for the indicated transform space. If a -// GeomVertexData has already been created for this -// transform, just returns it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a GeomVertexData structure from the vertex pool, for the indicated + * transform space. If a GeomVertexData has already been created for this + * transform, just returns it. + */ PT(GeomVertexData) EggLoader:: make_vertex_data(const EggRenderState *render_state, EggVertexPool *vertex_pool, EggNode *primitive_home, @@ -2260,8 +2169,8 @@ make_vertex_data(const EggRenderState *render_state, } if (!ignore_color) { - // Let's not use Direct3D-style colors on platforms where we only - // have OpenGL anyway. + // Let's not use Direct3D-style colors on platforms where we only have + // OpenGL anyway. #ifdef _WIN32 array_format->add_column(InternalName::get_color(), 1, Geom::NT_packed_dabc, Geom::C_color); @@ -2315,20 +2224,19 @@ make_vertex_data(const EggRenderState *render_state, string name = _data->get_egg_filename().get_basename_wo_extension(); if (is_dynamic) { - // If it's a dynamic object, we need a TransformBlendTable and - // maybe a SliderTable, and additional columns in the vertex data: - // one that indexes into the blend table per vertex, and also - // one for each different type of morph delta. + // If it's a dynamic object, we need a TransformBlendTable and maybe a + // SliderTable, and additional columns in the vertex data: one that + // indexes into the blend table per vertex, and also one for each + // different type of morph delta. - // Tell the format that we're setting it up for Panda-based - // animation. + // Tell the format that we're setting it up for Panda-based animation. GeomVertexAnimationSpec animation; animation.set_panda(); temp_format->set_animation(animation); PT(GeomVertexArrayFormat) anim_array_format = new GeomVertexArrayFormat; anim_array_format->add_column - (InternalName::get_transform_blend(), 1, + (InternalName::get_transform_blend(), 1, Geom::NT_uint16, Geom::C_index); temp_format->add_array(anim_array_format); @@ -2336,7 +2244,7 @@ make_vertex_data(const EggRenderState *render_state, EggVertexPool::const_iterator vi; for (vi = vertex_pool->begin(); vi != vertex_pool->end(); ++vi) { EggVertex *vertex = (*vi); - + EggMorphVertexList::const_iterator mvi; for (mvi = vertex->_dxyzs.begin(); mvi != vertex->_dxyzs.end(); ++mvi) { slider_names[(*mvi).get_name()].set_bit(vertex->get_index()); @@ -2379,7 +2287,7 @@ make_vertex_data(const EggRenderState *render_state, // If we have any sliders at all, create a table for them. slider_table = new SliderTable; - + pmap::iterator si; for (si = slider_names.begin(); si != slider_names.end(); ++si) { PT(VertexSlider) slider = character_maker->egg_to_slider((*si).first); @@ -2387,8 +2295,8 @@ make_vertex_data(const EggRenderState *render_state, } } - // We'll also assign the character name to the vertex data, so it - // will show up in PStats. + // We'll also assign the character name to the vertex data, so it will + // show up in PStats. name = character_maker->get_name(); } @@ -2397,11 +2305,10 @@ make_vertex_data(const EggRenderState *render_state, CPT(GeomVertexFormat) format = GeomVertexFormat::register_format(temp_format); - // Now create a new GeomVertexData using the indicated format. It - // is actually correct to create it with UH_static even though it - // represents a dynamic object, because the vertex data itself won't - // be changing--just the result of applying the animation is - // dynamic. + // Now create a new GeomVertexData using the indicated format. It is + // actually correct to create it with UH_static even though it represents a + // dynamic object, because the vertex data itself won't be changing--just + // the result of applying the animation is dynamic. PT(GeomVertexData) vertex_data = new GeomVertexData(name, format, Geom::UH_static); vertex_data->reserve_num_rows(vertex_pool->size()); @@ -2425,7 +2332,7 @@ make_vertex_data(const EggRenderState *render_state, EggMorphVertexList::const_iterator mvi; for (mvi = vertex->_dxyzs.begin(); mvi != vertex->_dxyzs.end(); ++mvi) { const EggMorphVertex &morph = (*mvi); - CPT(InternalName) delta_name = + CPT(InternalName) delta_name = InternalName::get_morph(InternalName::get_vertex(), morph.get_name()); gvw.set_column(delta_name); gvw.add_data3d(morph.get_offset() * transform); @@ -2442,7 +2349,7 @@ make_vertex_data(const EggRenderState *render_state, EggMorphNormalList::const_iterator mni; for (mni = vertex->_dnormals.begin(); mni != vertex->_dnormals.end(); ++mni) { const EggMorphNormal &morph = (*mni); - CPT(InternalName) delta_name = + CPT(InternalName) delta_name = InternalName::get_morph(InternalName::get_normal(), morph.get_name()); gvw.set_column(delta_name); LNormald morphed_normal = orig_normal + morph.get_offset(); @@ -2461,7 +2368,7 @@ make_vertex_data(const EggRenderState *render_state, EggMorphColorList::const_iterator mci; for (mci = vertex->_drgbas.begin(); mci != vertex->_drgbas.end(); ++mci) { const EggMorphColor &morph = (*mci); - CPT(InternalName) delta_name = + CPT(InternalName) delta_name = InternalName::get_morph(InternalName::get_color(), morph.get_name()); gvw.set_column(delta_name); gvw.add_data4(morph.get_offset()); @@ -2491,7 +2398,7 @@ make_vertex_data(const EggRenderState *render_state, EggMorphTexCoordList::const_iterator mti; for (mti = egg_uv->_duvs.begin(); mti != egg_uv->_duvs.end(); ++mti) { const EggMorphTexCoord &morph = (*mti); - CPT(InternalName) delta_name = + CPT(InternalName) delta_name = InternalName::get_morph(iname, morph.get_name()); gvw.set_column(delta_name); LTexCoord3d duvw = morph.get_offset(); @@ -2499,7 +2406,7 @@ make_vertex_data(const EggRenderState *render_state, LTexCoord3d new_uvw = orig_uvw + duvw; duvw = (new_uvw * (*buv).second->get_transform3d()) - uvw; } - + gvw.add_data3d(duvw); } } @@ -2514,7 +2421,7 @@ make_vertex_data(const EggRenderState *render_state, gvw.add_data3d(tangent); gvw.set_column(InternalName::get_binormal_name(name)); gvw.add_data3d(binormal); - } + } } } @@ -2545,11 +2452,9 @@ make_vertex_data(const EggRenderState *render_state, return vertex_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_blend_table -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(TransformBlendTable) EggLoader:: make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, CharacterMaker *character_maker) { @@ -2564,14 +2469,14 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, // Figure out the transforms affecting this particular vertex. TransformBlend blend; if (vertex->gref_size() == 0) { - // If the vertex has no explicit membership, it belongs right - // where it is. + // If the vertex has no explicit membership, it belongs right where it + // is. PT(VertexTransform) vt = character_maker->egg_to_transform(primitive_home); nassertr(vt != (VertexTransform *)NULL, NULL); blend.add_transform(vt, 1.0f); } else { - // If the vertex does have an explicit membership, ignore its - // parentage and assign it where it wants to be. + // If the vertex does have an explicit membership, ignore its parentage + // and assign it where it wants to be. double quantize = egg_vertex_membership_quantize; EggVertex::GroupRef::const_iterator gri; for (gri = vertex->gref_begin(); gri != vertex->gref_end(); ++gri) { @@ -2580,7 +2485,7 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, if (quantize != 0.0) { membership = cfloor(membership / quantize + 0.5) * quantize; } - + PT(VertexTransform) vt = character_maker->egg_to_transform(egg_joint); nassertr(vt != (VertexTransform *)NULL, NULL); blend.add_transform(vt, membership); @@ -2590,28 +2495,26 @@ make_blend_table(EggVertexPool *vertex_pool, EggNode *primitive_home, blend.limit_transforms(egg_vertex_max_num_joints); } blend.normalize_weights(); - + int table_index = blend_table->add_blend(blend); - // We take advantage of the "external index" field of the - // EggVertex to temporarily store the transform blend index. + // We take advantage of the "external index" field of the EggVertex to + // temporarily store the transform blend index. vertex->set_external_index(table_index); - } + } return blend_table; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::record_morph -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggLoader:: record_morph(GeomVertexArrayFormat *array_format, CharacterMaker *character_maker, const string &morph_name, InternalName *column_name, int num_components) { - PT(InternalName) delta_name = + PT(InternalName) delta_name = InternalName::get_morph(column_name, morph_name); if (!array_format->has_column(delta_name)) { array_format->add_column @@ -2620,14 +2523,12 @@ record_morph(GeomVertexArrayFormat *array_format, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_primitive -// Access: Private -// Description: Creates a GeomPrimitive corresponding to the -// indicated EggPrimitive, and adds it to the set. -//////////////////////////////////////////////////////////////////// +/** + * Creates a GeomPrimitive corresponding to the indicated EggPrimitive, and + * adds it to the set. + */ void EggLoader:: -make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, +make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, EggLoader::UniquePrimitives &unique_primitives, EggLoader::Primitives &primitives, bool has_overall_color, const LColor &overall_color) { @@ -2675,8 +2576,8 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, primitive->set_shade_model(GeomPrimitive::SM_smooth); } - // Insert the primitive into the set, but if we already have a - // primitive of that type, reset the pointer to that one instead. + // Insert the primitive into the set, but if we already have a primitive of + // that type, reset the pointer to that one instead. PrimitiveUnifier pu(primitive); pair result = unique_primitives.insert(UniquePrimitives::value_type(pu, primitive)); @@ -2687,26 +2588,25 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, if (egg2pg_cat.is_debug()) { egg2pg_cat.debug() - << "First primitive of type " << primitive->get_type() + << "First primitive of type " << primitive->get_type() << ": " << primitive << "\n"; } } GeomPrimitive *orig_prim = (*result.first).second; - // Make sure we don't try to put more than egg_max_indices into any - // one GeomPrimitive. + // Make sure we don't try to put more than egg_max_indices into any one + // GeomPrimitive. if (orig_prim->get_num_vertices() + egg_prim->size() <= (unsigned int)egg_max_indices) { primitive = orig_prim; } else if (orig_prim != primitive) { - // If the old primitive is full, keep the new primitive from now - // on. + // If the old primitive is full, keep the new primitive from now on. (*result.first).second = primitive; if (egg2pg_cat.is_debug()) { egg2pg_cat.debug() - << "Next primitive of type " << primitive->get_type() + << "Next primitive of type " << primitive->get_type() << ": " << primitive << "\n"; } primitives.push_back(primitive); @@ -2720,12 +2620,9 @@ make_primitive(const EggRenderState *render_state, EggPrimitive *egg_prim, primitive->close_primitive(); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::set_portal_polygon -// Access: Private -// Description: Defines the PortalNode from the first polygon found -// within this group. -//////////////////////////////////////////////////////////////////// +/** + * Defines the PortalNode from the first polygon found within this group. + */ void EggLoader:: set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { pnode->clear_vertices(); @@ -2742,12 +2639,9 @@ set_portal_polygon(EggGroup *egg_group, PortalNode *pnode) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::set_occluder_polygon -// Access: Private -// Description: Defines the OccluderNode from the first polygon found -// within this group. -//////////////////////////////////////////////////////////////////// +/** + * Defines the OccluderNode from the first polygon found within this group. + */ void EggLoader:: set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { PT(EggPolygon) poly = find_first_polygon(egg_group); @@ -2775,12 +2669,9 @@ set_occluder_polygon(EggGroup *egg_group, OccluderNode *pnode) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::find_first_polygon -// Access: Private -// Description: Returns the first EggPolygon found at or below the -// indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first EggPolygon found at or below the indicated node. + */ PT(EggPolygon) EggLoader:: find_first_polygon(EggGroup *egg_group) { // Does this group have any polygons? @@ -2792,8 +2683,7 @@ find_first_polygon(EggGroup *egg_group) { } } - // Well, the group had no polygons; look for a child group that - // does. + // Well, the group had no polygons; look for a child group that does. for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { if ((*ci)->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, *ci); @@ -2808,16 +2698,13 @@ find_first_polygon(EggGroup *egg_group) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_sphere -// Access: Private -// Description: Creates a single generic Sphere corresponding -// to the polygons associated with this group. -// This sphere is used by make_collision_sphere and -// Polylight sphere. It could be used for other spheres. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single generic Sphere corresponding to the polygons associated + * with this group. This sphere is used by make_collision_sphere and + * Polylight sphere. It could be used for other spheres. + */ bool EggLoader:: -make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, +make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 ¢er, PN_stdfloat &radius, LColor &color) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); if (geom_group != (EggGroup *)NULL) { @@ -2848,7 +2735,7 @@ make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, if (num_vertices > 0) { d_center /= (double)num_vertices; - //egg2pg_cat.debug() << "make_sphere d_center: " << d_center << "\n"; + // egg2pg_cat.debug() << "make_sphere d_center: " << d_center << "\n"; // And the furthest vertex determines the radius. double radius2 = 0.0; @@ -2862,7 +2749,7 @@ make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, center = LCAST(PN_stdfloat, d_center); radius = sqrtf(radius2); - //egg2pg_cat.debug() << "make_sphere radius: " << radius << "\n"; + // egg2pg_cat.debug() << "make_sphere radius: " << radius << "\n"; vi = vertices.begin(); EggVertex *clr_vtx = (*vi); color = clr_vtx->get_color(); @@ -2872,13 +2759,10 @@ make_sphere(EggGroup *egg_group, EggGroup::CollideFlags flags, return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_box -// Access: Private -// Description: Creates a single generic Box corresponding -// to the polygons associated with this group. -// This box is used by make_collision_box. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single generic Box corresponding to the polygons associated with + * this group. This box is used by make_collision_box. + */ bool EggLoader:: make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, LPoint3 &min_p, LPoint3 &max_p, LColor &color) { @@ -2898,7 +2782,7 @@ make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, } } - // Now find the min/max points + // Now find the minmax points pset::const_iterator vi; vi = vertices.begin(); @@ -2932,13 +2816,10 @@ make_box(EggGroup *egg_group, EggGroup::CollideFlags flags, return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_solids -// Access: Private -// Description: Creates CollisionSolids corresponding to the -// collision geometry indicated at the given node and -// below. -//////////////////////////////////////////////////////////////////// +/** + * Creates CollisionSolids corresponding to the collision geometry indicated + * at the given node and below. + */ void EggLoader:: make_collision_solids(EggGroup *start_group, EggGroup *egg_group, CollisionNode *cnode) { @@ -2999,12 +2880,10 @@ make_collision_solids(EggGroup *start_group, EggGroup *egg_group, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_plane -// Access: Private -// Description: Creates a single CollisionPlane corresponding -// to the first polygon associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionPlane corresponding to the first polygon + * associated with this group. + */ void EggLoader:: make_collision_plane(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3034,30 +2913,26 @@ make_collision_plane(EggGroup *egg_group, CollisionNode *cnode, -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_floor_mesh -// Access: Private -// Description: Creates a single CollisionPolygon corresponding -// to the first polygon associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionPolygon corresponding to the first polygon + * associated with this group. + */ void EggLoader:: make_collision_floor_mesh(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); - + if (geom_group != (EggGroup *)NULL) { create_collision_floor_mesh(cnode, geom_group,flags); } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_polygon -// Access: Private -// Description: Creates a single CollisionPolygon corresponding -// to the first polygon associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionPolygon corresponding to the first polygon + * associated with this group. + */ void EggLoader:: make_collision_polygon(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3082,12 +2957,10 @@ make_collision_polygon(EggGroup *egg_group, CollisionNode *cnode, } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_polyset -// Access: Private -// Description: Creates a series of CollisionPolygons corresponding -// to the polygons associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a series of CollisionPolygons corresponding to the polygons + * associated with this group. + */ void EggLoader:: make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3109,12 +2982,10 @@ make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_sphere -// Access: Private -// Description: Creates a single CollisionSphere corresponding -// to the polygons associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionSphere corresponding to the polygons associated + * with this group. + */ void EggLoader:: make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3129,12 +3000,10 @@ make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_box -// Access: Private -// Description: Creates a single CollisionBox corresponding -// to the polygons associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionBox corresponding to the polygons associated with + * this group. + */ void EggLoader:: make_collision_box(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3149,12 +3018,10 @@ make_collision_box(EggGroup *egg_group, CollisionNode *cnode, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_inv_sphere -// Access: Private -// Description: Creates a single CollisionInvSphere corresponding -// to the polygons associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionInvSphere corresponding to the polygons + * associated with this group. + */ void EggLoader:: make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3169,12 +3036,10 @@ make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::make_collision_tube -// Access: Private -// Description: Creates a single CollisionTube corresponding -// to the polygons associated with this group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionTube corresponding to the polygons associated + * with this group. + */ void EggLoader:: make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags) { @@ -3194,13 +3059,13 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } } - // Now store the 3-d values in a vector for convenient access (and - // also determine the centroid). We compute this in node space. + // Now store the 3-d values in a vector for convenient access (and also + // determine the centroid). We compute this in node space. size_t num_vertices = vertices.size(); if (num_vertices != 0) { pvector vpos; vpos.reserve(num_vertices); - + LPoint3d center(0.0, 0.0, 0.0); pset::const_iterator vi; for (vi = vertices.begin(); vi != vertices.end(); ++vi) { @@ -3211,9 +3076,9 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } center /= (double)num_vertices; - // Now that we have the centroid, we have to try to figure out - // the cylinder's major axis. Start by finding a point farthest - // from the centroid. + // Now that we have the centroid, we have to try to figure out the + // cylinder's major axis. Start by finding a point farthest from the + // centroid. size_t i; double radius2 = 0.0; LPoint3d far_a = center; @@ -3225,9 +3090,9 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } } - // The point we have found above, far_a, must be one one of the - // endcaps. Now find another point, far_b, that is the farthest - // from far_a. This will be a point on the other endcap. + // The point we have found above, far_a, must be one one of the endcaps. + // Now find another point, far_b, that is the farthest from far_a. This + // will be a point on the other endcap. radius2 = 0.0; LPoint3d far_b = center; for (i = 0; i < num_vertices; i++) { @@ -3238,34 +3103,32 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } } - // Now we have far_a and far_b, one point on each endcap. - // However, these points are not necessarily centered on the - // endcaps, so we haven't figured out the cylinder's axis yet - // (the line between far_a and far_b will probably pass through - // the cylinder at an angle). + // Now we have far_a and far_b, one point on each endcap. However, + // these points are not necessarily centered on the endcaps, so we + // haven't figured out the cylinder's axis yet (the line between far_a + // and far_b will probably pass through the cylinder at an angle). - // So we still need to determine the full set of points in each - // endcap. To do this, we pass back through the set of points, - // categorizing each point into either "endcap a" or "endcap b". - // We also leave a hefty chunk of points in the middle - // uncategorized; this helps prevent us from getting a little - // bit lopsided with points near the middle that may appear to - // be closer to the wrong endcap. + // So we still need to determine the full set of points in each endcap. + // To do this, we pass back through the set of points, categorizing each + // point into either "endcap a" or "endcap b". We also leave a hefty + // chunk of points in the middle uncategorized; this helps prevent us + // from getting a little bit lopsided with points near the middle that + // may appear to be closer to the wrong endcap. LPoint3d cap_a_center(0.0, 0.0, 0.0); LPoint3d cap_b_center(0.0, 0.0, 0.0); int num_a = 0; int num_b = 0; - // This is the threshold length; points farther away from the - // center than this are deemed to be in one endcap or the other. + // This is the threshold length; points farther away from the center + // than this are deemed to be in one endcap or the other. double center_length = (far_a - far_b).length() / 4.0; double center_length2 = center_length * center_length; for (i = 0; i < num_vertices; i++) { double dist2 = (vpos[i] - center).length_squared(); if (dist2 > center_length2) { - // This point is farther away from the center than - // center_length; therefore it belongs in an endcap. + // This point is farther away from the center than center_length; + // therefore it belongs in an endcap. double dist_a2 = (vpos[i] - far_a).length_squared(); double dist_b2 = (vpos[i] - far_b).length_squared(); if (dist_a2 < dist_b2) { @@ -3289,8 +3152,8 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, LVector3d axis = cap_b_center - cap_a_center; axis.normalize(); - // If the axis is *almost* parallel with a major axis, assume - // it is meant to be exactly parallel. + // If the axis is *almost* parallel with a major axis, assume it is + // meant to be exactly parallel. if (IS_THRESHOLD_ZERO(axis[0], 0.01)) { axis[0] = 0.0; } @@ -3302,13 +3165,12 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } axis.normalize(); - // Transform all of the points so that the major axis is along - // the Y axis, and the origin is the center. This is very - // similar to the CollisionTube's idea of its canonical - // orientation (although not exactly the same, since it is - // centered on the origin instead of having point_a on the - // origin). It makes it easier to determine the length and - // radius of the cylinder. + // Transform all of the points so that the major axis is along the Y + // axis, and the origin is the center. This is very similar to the + // CollisionTube's idea of its canonical orientation (although not + // exactly the same, since it is centered on the origin instead of + // having point_a on the origin). It makes it easier to determine the + // length and radius of the cylinder. LMatrix4d mat; look_at(mat, axis, LVector3d(0.0, 0.0, 1.0), CS_zup_right); mat.set_row(3, center); @@ -3330,9 +3192,9 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } } - // And with the radius, we can determine the length. We need - // to know the radius first because we want the round endcaps - // to enclose all points. + // And with the radius, we can determine the length. We need to know + // the radius first because we want the round endcaps to enclose all + // points. double min_y = 0.0; double max_y = 0.0; @@ -3341,8 +3203,8 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, double radius2 = v.length_squared(); if (vpos[i][1] < min_y) { - // Adjust the Y pos to account for the point's distance - // from the axis. + // Adjust the Y pos to account for the point's distance from the + // axis. double factor = sqrt(max_radius2 - radius2); min_y = min(min_y, vpos[i][1] + factor); @@ -3370,13 +3232,10 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::apply_collision_flags -// Access: Private -// Description: Does funny stuff to the CollisionSolid as -// appropriate, based on the settings of the given -// CollideFlags. -//////////////////////////////////////////////////////////////////// +/** + * Does funny stuff to the CollisionSolid as appropriate, based on the + * settings of the given CollideFlags. + */ void EggLoader:: apply_collision_flags(CollisionSolid *solid, EggGroup::CollideFlags flags) { if ((flags & EggGroup::CF_intangible) != 0) { @@ -3387,17 +3246,15 @@ apply_collision_flags(CollisionSolid *solid, EggGroup::CollideFlags flags) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::find_collision_geometry -// Access: Private -// Description: Looks for the node, at or below the indicated node, -// that contains the associated collision geometry. -//////////////////////////////////////////////////////////////////// +/** + * Looks for the node, at or below the indicated node, that contains the + * associated collision geometry. + */ EggGroup *EggLoader:: find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags) { if ((flags & EggGroup::CF_descend) != 0) { - // If we have the "descend" instruction, we'll get to it when we - // get to it. Don't worry about it now. + // If we have the "descend" instruction, we'll get to it when we get to + // it. Don't worry about it now. return egg_group; } @@ -3410,8 +3267,8 @@ find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags) { } } - // Well, the group had no polygons; look for a child group that has - // the same collision type. + // Well, the group had no polygons; look for a child group that has the same + // collision type. for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { if ((*ci)->is_of_type(EggGroup::get_class_type())) { EggGroup *child_group = DCAST(EggGroup, *ci); @@ -3425,12 +3282,9 @@ find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::create_collision_plane -// Access: Private -// Description: Creates a single CollisionPlane from the indicated -// EggPolygon. -//////////////////////////////////////////////////////////////////// +/** + * Creates a single CollisionPlane from the indicated EggPolygon. + */ CollisionPlane *EggLoader:: create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { if (!egg_poly->cleanup()) { @@ -3475,13 +3329,10 @@ create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group) { return new CollisionPlane(plane); } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::create_collision_polygons -// Access: Private -// Description: Creates one or more CollisionPolygons from the -// indicated EggPolygon, and adds them to the indicated -// CollisionNode. -//////////////////////////////////////////////////////////////////// +/** + * Creates one or more CollisionPolygons from the indicated EggPolygon, and + * adds them to the indicated CollisionNode. + */ void EggLoader:: create_collision_polygons(CollisionNode *cnode, EggPolygon *egg_poly, EggGroup *parent_group, @@ -3542,15 +3393,12 @@ create_collision_polygons(CollisionNode *cnode, EggPolygon *egg_poly, } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::create_collision_floor_mesh -// Access: Private -// Description: Creates a CollisionFloorMesh from the -// indicated EggPolygons, and adds it to the indicated -// CollisionNode. -//////////////////////////////////////////////////////////////////// +/** + * Creates a CollisionFloorMesh from the indicated EggPolygons, and adds it to + * the indicated CollisionNode. + */ void EggLoader:: -create_collision_floor_mesh(CollisionNode *cnode, +create_collision_floor_mesh(CollisionNode *cnode, EggGroup *parent_group, EggGroup::CollideFlags flags) { @@ -3568,8 +3416,8 @@ create_collision_floor_mesh(CollisionNode *cnode, << "\n"; return; } - - } + + } } if(group->size() == 0) { egg2pg_cat.info() @@ -3584,37 +3432,37 @@ create_collision_floor_mesh(CollisionNode *cnode, EggPolygon *poly = DCAST(EggPolygon, *ci); if (poly->get_num_vertices() == 3) { CollisionFloorMesh::TriangleIndices tri; - - //generate a shared vertex triangle from the vertex pool + + // generate a shared vertex triangle from the vertex pool tri.p1=pool.create_unique_vertex(*poly->get_vertex(0))->get_index(); tri.p2=pool.create_unique_vertex(*poly->get_vertex(1))->get_index(); tri.p3=pool.create_unique_vertex(*poly->get_vertex(2))->get_index(); - + triangles.push_back(tri); } else if (poly->get_num_vertices() == 4) { - //this is a case that really shouldn't happen, but appears to be required - //-split up the quad int 2 tris. + // this is a case that really shouldn't happen, but appears to be + // required -split up the quad int 2 tris. CollisionFloorMesh::TriangleIndices tri; CollisionFloorMesh::TriangleIndices tri2; - - //generate a shared vertex triangle from the vertex pool + + // generate a shared vertex triangle from the vertex pool tri.p1=pool.create_unique_vertex(*poly->get_vertex(0))->get_index(); tri.p2=pool.create_unique_vertex(*poly->get_vertex(1))->get_index(); tri.p3=pool.create_unique_vertex(*poly->get_vertex(2))->get_index(); - + triangles.push_back(tri); - //generate a shared vertex triangle from the vertex pool + // generate a shared vertex triangle from the vertex pool tri2.p1=tri.p1; - tri2.p2=tri.p3; + tri2.p2=tri.p3; tri2.p3=pool.create_unique_vertex(*poly->get_vertex(3))->get_index(); - + triangles.push_back(tri2); - } + } } - - //Now we have a set of triangles, and a pool + + // Now we have a set of triangles, and a pool PT(CollisionFloorMesh) csfloor = new CollisionFloorMesh; @@ -3633,13 +3481,10 @@ create_collision_floor_mesh(CollisionNode *cnode, } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::apply_deferred_nodes -// Access: Private -// Description: Walks back over the tree and applies the -// DeferredNodeProperties that were saved up along the -// way. -//////////////////////////////////////////////////////////////////// +/** + * Walks back over the tree and applies the DeferredNodeProperties that were + * saved up along the way. + */ void EggLoader:: apply_deferred_nodes(PandaNode *node, const DeferredNodeProperty &prop) { DeferredNodeProperty next_prop(prop); @@ -3662,17 +3507,14 @@ apply_deferred_nodes(PandaNode *node, const DeferredNodeProperty &prop) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::expand_all_object_types -// Access: Private -// Description: Walks the hierarchy and calls expand_object_types() -// on each node, to expand all of the ObjectType -// definitions in the file at once. Also prunes any -// nodes that are flagged "backstage". -// -// The return value is true if this node should be kept, -// false if it should be pruned. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy and calls expand_object_types() on each node, to expand + * all of the ObjectType definitions in the file at once. Also prunes any + * nodes that are flagged "backstage". + * + * The return value is true if this node should be kept, false if it should be + * pruned. + */ bool EggLoader:: expand_all_object_types(EggNode *egg_node) { if (egg_node->is_of_type(EggGroup::get_class_type())) { @@ -3687,8 +3529,8 @@ expand_all_object_types(EggNode *egg_node) { } } - // Now recurse on children, and we might prune children from this - // list as we go. + // Now recurse on children, and we might prune children from this list as we + // go. if (egg_node->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *egg_group_node = DCAST(EggGroupNode, egg_node); EggGroupNode::const_iterator ci; @@ -3708,25 +3550,21 @@ expand_all_object_types(EggNode *egg_node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::expand_object_types -// Access: Private -// Description: Recursively expands the group's ObjectType string(s). -// It's recursive because an ObjectType string might -// itself expand to another ObjectType string, which is -// allowed; but we don't want to get caught in a cycle. -// -// The return value is true if the object type is -// expanded and the node is valid, or false if the node -// should be ignored (e.g. ObjectType "backstage"). -//////////////////////////////////////////////////////////////////// +/** + * Recursively expands the group's ObjectType string(s). It's recursive + * because an ObjectType string might itself expand to another ObjectType + * string, which is allowed; but we don't want to get caught in a cycle. + * + * The return value is true if the object type is expanded and the node is + * valid, or false if the node should be ignored (e.g. ObjectType + * "backstage"). + */ bool EggLoader:: expand_object_types(EggGroup *egg_group, const pset &expanded, const pvector &expanded_history) { int num_object_types = egg_group->get_num_object_types(); - // First, copy out the object types so we can recursively modify the - // list. + // First, copy out the object types so we can recursively modify the list. vector_string object_types; int i; for (i = 0; i < num_object_types; i++) { @@ -3746,7 +3584,7 @@ expand_object_types(EggGroup *egg_group, const pset &expanded, for (pi = expanded_history.begin(); pi != expanded_history.end(); ++pi) { - egg2pg_cat.error(false) + egg2pg_cat.error(false) << (*pi) << " -> "; } egg2pg_cat.error(false) << object_type << "\n"; @@ -3757,7 +3595,7 @@ expand_object_types(EggGroup *egg_group, const pset &expanded, pvector new_expanded_history(expanded_history); new_expanded_history.push_back(object_type); - if (!do_expand_object_type(egg_group, new_expanded, + if (!do_expand_object_type(egg_group, new_expanded, new_expanded_history, object_type)) { // Ignorable group; stop here. return false; @@ -3768,17 +3606,15 @@ expand_object_types(EggGroup *egg_group, const pset &expanded, return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::do_expand_object_types -// Access: Private -// Description: Further implementation of expand_object_types(). -//////////////////////////////////////////////////////////////////// +/** + * Further implementation of expand_object_types(). + */ bool EggLoader:: do_expand_object_type(EggGroup *egg_group, const pset &expanded, const pvector &expanded_history, const string &object_type) { - // Try to find the egg syntax that the given objecttype is - // shorthand for. First, look in the config file. + // Try to find the egg syntax that the given objecttype is shorthand for. + // First, look in the config file. ConfigVariableString egg_object_type ("egg-object-type-" + downcase(object_type), ""); @@ -3786,51 +3622,51 @@ do_expand_object_type(EggGroup *egg_group, const pset &expanded, if (!egg_object_type.has_value()) { // It wasn't defined in a config file. Maybe it's built in? - + if (cmp_nocase_uh(object_type, "barrier") == 0) { egg_syntax = " { Polyset descend }"; - + } else if (cmp_nocase_uh(object_type, "solidpoly") == 0) { egg_syntax = " { Polyset descend solid }"; - + } else if (cmp_nocase_uh(object_type, "turnstile") == 0) { egg_syntax = " { Polyset descend turnstile }"; - + } else if (cmp_nocase_uh(object_type, "sphere") == 0) { egg_syntax = " { Sphere descend }"; } else if (cmp_nocase_uh(object_type, "tube") == 0) { egg_syntax = " { Tube descend }"; - + } else if (cmp_nocase_uh(object_type, "trigger") == 0) { egg_syntax = " { Polyset descend intangible }"; - + } else if (cmp_nocase_uh(object_type, "trigger_sphere") == 0) { egg_syntax = " { Sphere descend intangible }"; - + } else if (cmp_nocase_uh(object_type, "eye_trigger") == 0) { egg_syntax = " { Polyset descend intangible center }"; - + } else if (cmp_nocase_uh(object_type, "bubble") == 0) { egg_syntax = " { Sphere keep descend }"; - + } else if (cmp_nocase_uh(object_type, "ghost") == 0) { egg_syntax = " collide-mask { 0 }"; - + } else if (cmp_nocase_uh(object_type, "dcs") == 0) { egg_syntax = " { 1 }"; - + } else if (cmp_nocase_uh(object_type, "model") == 0) { egg_syntax = " { 1 }"; - + } else if (cmp_nocase_uh(object_type, "none") == 0) { // ObjectType "none" is a special case, meaning nothing in particular. return true; - + } else if (cmp_nocase_uh(object_type, "backstage") == 0) { // Ignore "backstage" geometry. return false; - + } else { egg2pg_cat.error() << "Unknown ObjectType " << object_type << "\n"; @@ -3848,8 +3684,8 @@ do_expand_object_type(EggGroup *egg_group, const pset &expanded, _error = true; } else { - // Now we've parsed the object type syntax, which might have - // added more object types. Recurse if necessary. + // Now we've parsed the object type syntax, which might have added more + // object types. Recurse if necessary. if (egg_group->get_num_object_types() != 0) { if (!expand_object_types(egg_group, expanded, expanded_history)) { return false; @@ -3861,14 +3697,12 @@ do_expand_object_type(EggGroup *egg_group, const pset &expanded, return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::get_combine_mode -// Access: Private, Static -// Description: Extracts the combine_mode from the given egg texture, -// and returns its corresponding TextureStage value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the combine_mode from the given egg texture, and returns its + * corresponding TextureStage value. + */ TextureStage::CombineMode EggLoader:: -get_combine_mode(const EggTexture *egg_tex, +get_combine_mode(const EggTexture *egg_tex, EggTexture::CombineChannel channel) { switch (egg_tex->get_combine_mode(channel)) { case EggTexture::CM_unspecified: @@ -3902,19 +3736,17 @@ get_combine_mode(const EggTexture *egg_tex, return TextureStage::CM_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::get_combine_source -// Access: Private, Static -// Description: Extracts the combine_source from the given egg texture, -// and returns its corresponding TextureStage value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the combine_source from the given egg texture, and returns its + * corresponding TextureStage value. + */ TextureStage::CombineSource EggLoader:: -get_combine_source(const EggTexture *egg_tex, +get_combine_source(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n) { switch (egg_tex->get_combine_source(channel, n)) { case EggTexture::CS_unspecified: - // The default source if it is unspecified is based on the - // parameter index. + // The default source if it is unspecified is based on the parameter + // index. switch (n) { case 0: return TextureStage::CS_previous; @@ -3947,20 +3779,18 @@ get_combine_source(const EggTexture *egg_tex, return TextureStage::CS_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::get_combine_operand -// Access: Private, Static -// Description: Extracts the combine_operand from the given egg texture, -// and returns its corresponding TextureStage value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the combine_operand from the given egg texture, and returns its + * corresponding TextureStage value. + */ TextureStage::CombineOperand EggLoader:: -get_combine_operand(const EggTexture *egg_tex, +get_combine_operand(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n) { switch (egg_tex->get_combine_operand(channel, n)) { case EggTexture::CS_unspecified: if (channel == EggTexture::CC_rgb) { - // The default operand for RGB is src_color, except for the - // third parameter, which defaults to src_alpha. + // The default operand for RGB is src_color, except for the third + // parameter, which defaults to src_alpha. return n < 2 ? TextureStage::CO_src_color : TextureStage::CO_src_alpha; } else { // The default operand for alpha is always src_alpha. @@ -3983,12 +3813,10 @@ get_combine_operand(const EggTexture *egg_tex, return TextureStage::CO_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::get_color_blend_mode -// Access: Private, Static -// Description: Converts the EggGroup's BlendMode to the -// corresponding ColorBlendAttrib::Mode value. -//////////////////////////////////////////////////////////////////// +/** + * Converts the EggGroup's BlendMode to the corresponding + * ColorBlendAttrib::Mode value. + */ ColorBlendAttrib::Mode EggLoader:: get_color_blend_mode(EggGroup::BlendMode mode) { switch (mode) { @@ -4010,12 +3838,10 @@ get_color_blend_mode(EggGroup::BlendMode mode) { return ColorBlendAttrib::M_none; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::get_color_blend_operand -// Access: Private, Static -// Description: Converts the EggGroup's BlendOperand to the -// corresponding ColorBlendAttrib::Operand value. -//////////////////////////////////////////////////////////////////// +/** + * Converts the EggGroup's BlendOperand to the corresponding + * ColorBlendAttrib::Operand value. + */ ColorBlendAttrib::Operand EggLoader:: get_color_blend_operand(EggGroup::BlendOperand operand) { switch (operand) { @@ -4063,11 +3889,9 @@ get_color_blend_operand(EggGroup::BlendOperand operand) { return ColorBlendAttrib::O_zero; } -//////////////////////////////////////////////////////////////////// -// Function: EggLoader::VertexPoolTransform::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggLoader::VertexPoolTransform:: operator < (const EggLoader::VertexPoolTransform &other) const { if (_vertex_pool != other._vertex_pool) { @@ -4077,7 +3901,7 @@ operator < (const EggLoader::VertexPoolTransform &other) const { if (compare != 0) { return compare < 0; } - + if (_bake_in_uvs.size() != other._bake_in_uvs.size()) { return _bake_in_uvs.size() < other._bake_in_uvs.size(); } diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index 19a4c01782..504028432e 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -1,16 +1,15 @@ -// Filename: eggLoader.h -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggLoader.h + * @author drose + * @date 2002-02-26 + */ #ifndef EGGLOADER_H #define EGGLOADER_H @@ -59,14 +58,12 @@ class EggRenderState; class CharacterMaker; -//////////////////////////////////////////////////////////////////// -// Class : EggLoader -// Description : Converts an egg data structure, possibly read from an -// egg file but not necessarily, into a scene graph -// suitable for rendering. -// -// This class isn't exported from this package. -//////////////////////////////////////////////////////////////////// +/** + * Converts an egg data structure, possibly read from an egg file but not + * necessarily, into a scene graph suitable for rendering. + * + * This class isn't exported from this package. + */ class EggLoader { public: EggLoader(); @@ -76,7 +73,7 @@ public: void reparent_decals(); void start_sequences(); - void make_polyset(EggBin *egg_bin, PandaNode *parent, + void make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, bool is_dynamic, CharacterMaker *character_maker); @@ -110,7 +107,7 @@ private: typedef pmap UniquePrimitives; typedef pvector< PT(GeomPrimitive) > Primitives; - void show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node); + void show_normals(EggVertexPool *vertex_pool, GeomNode *geom_node); void make_nurbs_curve(EggNurbsCurve *egg_curve, PandaNode *parent, const LMatrix4d &mat); @@ -139,10 +136,10 @@ private: PandaNode *make_node(EggTable *egg_table, PandaNode *parent); PandaNode *make_node(EggGroupNode *egg_group, PandaNode *parent); - void check_for_polysets(EggGroup *egg_group, bool &all_polysets, + void check_for_polysets(EggGroup *egg_group, bool &all_polysets, bool &any_hidden); PT(GeomVertexData) make_vertex_data - (const EggRenderState *render_state, EggVertexPool *vertex_pool, + (const EggRenderState *render_state, EggVertexPool *vertex_pool, EggNode *primitive_home, const LMatrix4d &transform, TransformBlendTable *blend_table, bool is_dynamic, CharacterMaker *character_maker, bool ignore_color); PT(TransformBlendTable) make_blend_table @@ -150,11 +147,11 @@ private: CharacterMaker *character_maker); void record_morph (GeomVertexArrayFormat *array_format, - CharacterMaker *character_maker, const string &morph_name, + CharacterMaker *character_maker, const string &morph_name, InternalName *column_name, int num_components); - void make_primitive(const EggRenderState *render_state, - EggPrimitive *egg_prim, + void make_primitive(const EggRenderState *render_state, + EggPrimitive *egg_prim, UniquePrimitives &unique_primitives, Primitives &primitives, bool has_overall_color, const LColor &overall_color); @@ -189,7 +186,7 @@ private: EggGroup::CollideFlags flags); void apply_collision_flags(CollisionSolid *solid, EggGroup::CollideFlags flags); - EggGroup *find_collision_geometry(EggGroup *egg_group, + EggGroup *find_collision_geometry(EggGroup *egg_group, EggGroup::CollideFlags flags); CollisionPlane *create_collision_plane(EggPolygon *egg_poly, EggGroup *parent_group); @@ -197,7 +194,7 @@ private: EggGroup *parent_group, EggGroup::CollideFlags flags); - void create_collision_floor_mesh(CollisionNode *cnode, + void create_collision_floor_mesh(CollisionNode *cnode, EggGroup *parent_group, EggGroup::CollideFlags flags); @@ -209,16 +206,16 @@ private: const pvector &expanded_history, const string &object_type); - static TextureStage::CombineMode - get_combine_mode(const EggTexture *egg_tex, + static TextureStage::CombineMode + get_combine_mode(const EggTexture *egg_tex, EggTexture::CombineChannel channel); static TextureStage::CombineSource - get_combine_source(const EggTexture *egg_tex, + get_combine_source(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n); static TextureStage::CombineOperand - get_combine_operand(const EggTexture *egg_tex, + get_combine_operand(const EggTexture *egg_tex, EggTexture::CombineChannel channel, int n); static ColorBlendAttrib::Mode diff --git a/panda/src/egg2pg/eggRenderState.I b/panda/src/egg2pg/eggRenderState.I index add0cc9691..f194937a85 100644 --- a/panda/src/egg2pg/eggRenderState.I +++ b/panda/src/egg2pg/eggRenderState.I @@ -1,23 +1,19 @@ -// Filename: eggRenderState.I -// Created by: drose (12Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderState.I + * @author drose + * @date 2005-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggRenderState:: EggRenderState(EggLoader &loader) : _state(RenderState::make_empty()), @@ -28,12 +24,10 @@ EggRenderState(EggLoader &loader) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::add_attrib -// Access: Public -// Description: A convenience function to add the indicated render -// attribute to the aggregate state. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to add the indicated render attribute to the + * aggregate state. + */ INLINE void EggRenderState:: add_attrib(const RenderAttrib *attrib) { _state = _state->add_attrib(attrib); diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index 079aca3beb..1f068c4655 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -1,16 +1,15 @@ -// Filename: eggRenderState.cxx -// Created by: drose (12Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderState.cxx + * @author drose + * @date 2005-03-12 + */ #include "eggRenderState.h" #include "eggRenderMode.h" @@ -39,19 +38,16 @@ #include "config_egg2pg.h" -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::fill_state -// Access: Public -// Description: Sets up the state as appropriate for the indicated -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the state as appropriate for the indicated primitive. + */ void EggRenderState:: fill_state(EggPrimitive *egg_prim) { - // The various EggRenderMode properties can be defined directly at - // the primitive, at a group above the primitive, or an a texture - // applied to the primitive. The EggNode::determine_*() functions - // can find the right pointer to the level at which this is actually - // defined for a given primitive. + // The various EggRenderMode properties can be defined directly at the + // primitive, at a group above the primitive, or an a texture applied to the + // primitive. The EggNode::determine_*() functions can find the right + // pointer to the level at which this is actually defined for a given + // primitive. EggRenderMode::AlphaMode am = EggRenderMode::AM_unspecified; EggRenderMode::DepthWriteMode dwm = EggRenderMode::DWM_unspecified; EggRenderMode::DepthTestMode dtm = EggRenderMode::DTM_unspecified; @@ -98,7 +94,7 @@ fill_state(EggPrimitive *egg_prim) { bin = render_mode->get_bin(); } - // add_attrib(TextureAttrib::make_off()); + // add_attrib(TextureAttrib::make_off()); int num_textures = egg_prim->get_num_textures(); CPT(RenderAttrib) texture_attrib = NULL; CPT(RenderAttrib) tex_gen_attrib = NULL; @@ -128,10 +124,10 @@ fill_state(EggPrimitive *egg_prim) { } if (am == EggRenderMode::AM_unspecified) { - // If neither the primitive nor the texture specified an - // alpha mode, assume it should be alpha'ed if the texture - // has an alpha channel (unless the texture environment type - // is one that doesn't apply its alpha to the result). + // If neither the primitive nor the texture specified an alpha mode, + // assume it should be alpha'ed if the texture has an alpha channel + // (unless the texture environment type is one that doesn't apply + // its alpha to the result). int num_components = tex->get_num_components(); if (egg_tex->has_alpha_channel(num_components)) { implicit_alpha = true; @@ -150,10 +146,10 @@ fill_state(EggPrimitive *egg_prim) { add_stage(def._stage, get_tex_gen(egg_tex)); } - // Record the texture's associated texture matrix, so we can see - // if we can safely bake it into the UV's. (We need to get the - // complete list of textures that share this same set of UV's - // per each unique texture matrix. Whew!) + // Record the texture's associated texture matrix, so we can see if we + // can safely bake it into the UV's. (We need to get the complete list + // of textures that share this same set of UV's per each unique texture + // matrix. Whew!) CPT(InternalName) uv_name; if (egg_tex->has_uv_name() && egg_tex->get_uv_name() != string("default")) { uv_name = InternalName::get_texcoord_name(egg_tex->get_uv_name()); @@ -162,64 +158,62 @@ fill_state(EggPrimitive *egg_prim) { } if (has_tex_gen) { - // If the texture has a texgen mode, we will always apply its - // texture transform, never bake it in. In fact, we don't - // even care about its UV's in this case, since we won't be - // using them. + // If the texture has a texgen mode, we will always apply its texture + // transform, never bake it in. In fact, we don't even care about its + // UV's in this case, since we won't be using them. tex_mat_attrib = apply_tex_mat(tex_mat_attrib, def._stage, egg_tex); } else { - // Otherwise, we need to record that there is at least one - // texture on this particular UV name and with this particular - // texture matrix. If there are no other textures, or if all - // of the other textures use the same texture matrix, then - // tex_mats[uv_name].size() will remain 1 (which tells us we - // can bake in the texture matrix to the UV's). On the other - // hand, if there is another texture on the same uv name but - // with a different transform, it will increase - // tex_mats[uv_name].size() to at least 2, indicating we can't - // bake in the texture matrix. +/* + * Otherwise, we need to record that there is at least one texture on this + * particular UV name and with this particular texture matrix. If there are + * no other textures, or if all of the other textures use the same texture + * matrix, then tex_mats[uv_name].size() will remain 1 (which tells us we can + * bake in the texture matrix to the UV's). On the other hand, if there is + * another texture on the same uv name but with a different transform, it will + * increase tex_mats[uv_name].size() to at least 2, indicating we can't bake + * in the texture matrix. + */ tex_mats[uv_name][egg_tex->get_transform3d()].push_back(&def); } } } - // These parametric primitive types can't have their UV's baked in, - // so if we have one of these we always need to apply the texture - // matrix as a separate attribute, regardless of how many textures - // share the particular UV set. + // These parametric primitive types can't have their UV's baked in, so if we + // have one of these we always need to apply the texture matrix as a + // separate attribute, regardless of how many textures share the particular + // UV set. bool needs_tex_mat = (egg_prim->is_of_type(EggCurve::get_class_type()) || egg_prim->is_of_type(EggSurface::get_class_type())); - // Now that we've visited all of the textures in the above loop, we - // can go back and see how many of them share the same UV name and - // texture matrix. + // Now that we've visited all of the textures in the above loop, we can go + // back and see how many of them share the same UV name and texture matrix. TexMats::const_iterator tmi; for (tmi = tex_mats.begin(); tmi != tex_mats.end(); ++tmi) { const InternalName *uv_name = (*tmi).first; const TexMatTransforms &tmt = (*tmi).second; if (tmt.size() == 1 && !needs_tex_mat) { - // Only one unique transform sharing this set of UV's. We can - // bake in the transform! + // Only one unique transform sharing this set of UV's. We can bake in + // the transform! const TexMatTextures &tmtex = (*tmt.begin()).second; - // The first EggTexture on the list is sufficient, since we know - // they all have the same transform. + // The first EggTexture on the list is sufficient, since we know they + // all have the same transform. nassertv(!tmtex.empty()); TexMatTextures::const_iterator tmtexi = tmtex.begin(); const EggTexture *egg_tex = (*tmtexi)->_egg_tex; if (egg_tex->has_transform()) { - // If there's no transform, it's an identity matrix; don't - // bother recording it. Of course, it would do no harm to - // record it if we felt like it. + // If there's no transform, it's an identity matrix; don't bother + // recording it. Of course, it would do no harm to record it if we + // felt like it. _bake_in_uvs[uv_name] = egg_tex; } } else { - // Multiple transforms on this UV set, or a geometry type that - // doesn't support baking in UV's. We have to apply the - // texture matrix to each stage. + // Multiple transforms on this UV set, or a geometry type that doesn't + // support baking in UV's. We have to apply the texture matrix to each + // stage. TexMatTransforms::const_iterator tmti; for (tmti = tmt.begin(); tmti != tmt.end(); ++tmti) { const TexMatTextures &tmtex = (*tmti).second; @@ -227,7 +221,7 @@ fill_state(EggPrimitive *egg_prim) { for (tmtexi = tmtex.begin(); tmtexi != tmtex.end(); ++tmtexi) { const EggTexture *egg_tex = (*tmtexi)->_egg_tex; TextureStage *stage = (*tmtexi)->_stage; - + tex_mat_attrib = apply_tex_mat(tex_mat_attrib, stage, egg_tex); } } @@ -259,8 +253,8 @@ fill_state(EggPrimitive *egg_prim) { } - // Also check the color of the primitive to see if we should assume - // alpha based on the alpha values specified in the egg file. + // Also check the color of the primitive to see if we should assume alpha + // based on the alpha values specified in the egg file. if (am == EggRenderMode::AM_unspecified) { if (egg_prim->has_color()) { if (egg_prim->get_color()[3] != 1.0) { @@ -300,9 +294,8 @@ fill_state(EggPrimitive *egg_prim) { case EggRenderMode::AM_ms_mask: case EggRenderMode::AM_dual: if (egg_implicit_alpha_binary) { - // Any of these modes gets implicitly downgraded to AM_binary, if - // all of the alpha sources only contribute a binary value to - // alpha. + // Any of these modes gets implicitly downgraded to AM_binary, if all of + // the alpha sources only contribute a binary value to alpha. if (binary_alpha_only) { am = EggRenderMode::AM_binary; } @@ -380,7 +373,7 @@ fill_state(EggPrimitive *egg_prim) { break; } - _flat_shaded = + _flat_shaded = (egg_flat_shading && egg_prim->get_connected_shading() == EggPrimitive::S_per_face); @@ -392,14 +385,14 @@ fill_state(EggPrimitive *egg_prim) { _primitive_type = Geom::PT_lines; EggLine *egg_line = DCAST(EggLine, egg_prim); if (egg_line->get_thick() != 1.0) { - add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, + add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, egg_line->get_thick())); } } else if (egg_prim->is_of_type(EggPoint::get_class_type())) { _primitive_type = Geom::PT_points; EggPoint *egg_point = DCAST(EggPoint, egg_prim); if (egg_point->get_thick() != 1.0 || egg_point->get_perspective()) { - add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, + add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, egg_point->get_thick(), egg_point->get_perspective())); } @@ -416,22 +409,19 @@ fill_state(EggPrimitive *egg_prim) { if (has_depth_offset) { add_attrib(DepthOffsetAttrib::make(depth_offset)); } - + if (egg_prim->get_bface_flag()) { - // The primitive is marked with backface culling disabled--we want - // to see both sides. + // The primitive is marked with backface culling disabled--we want to see + // both sides. add_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_none)); } } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::int compare_to -// Access: Public -// Description: Provides a unique ordering for different -// EggRenderState objects, so that primitives of similar -// state can be grouped together by the EggBinner. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering for different EggRenderState objects, so that + * primitives of similar state can be grouped together by the EggBinner. + */ int EggRenderState:: compare_to(const EggRenderState &other) const { if (_state != other._state) { @@ -473,16 +463,13 @@ compare_to(const EggRenderState &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::get_material_attrib -// Access: Private -// Description: Returns a RenderAttrib suitable for enabling the -// material indicated by the given EggMaterial, and with -// the indicated backface flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib suitable for enabling the material indicated by the + * given EggMaterial, and with the indicated backface flag. + */ CPT(RenderAttrib) EggRenderState:: get_material_attrib(const EggMaterial *egg_mat, bool bface) { - Materials &materials = + Materials &materials = bface ? _loader._materials_bface : _loader._materials; // First, check whether we've seen this material before. @@ -492,16 +479,16 @@ get_material_attrib(const EggMaterial *egg_mat, bool bface) { return (*mi).second; } - // Ok, this is the first time we've seen this particular - // EggMaterial. Create a new Material that matches it. + // Ok, this is the first time we've seen this particular EggMaterial. + // Create a new Material that matches it. PT(Material) mat = new Material(egg_mat->get_name()); if (egg_mat->has_base()) { mat->set_base_color(egg_mat->get_base()); } if (egg_mat->has_diff()) { mat->set_diffuse(egg_mat->get_diff()); - // By default, ambient is the same as diffuse, if diffuse is - // specified but ambient is not. + // By default, ambient is the same as diffuse, if diffuse is specified but + // ambient is not. mat->set_ambient(egg_mat->get_diff()); } if (egg_mat->has_amb()) { @@ -541,12 +528,10 @@ get_material_attrib(const EggMaterial *egg_mat, bool bface) { return mt; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::get_tex_gen -// Access: Private, Static -// Description: Extracts the tex_gen from the given egg texture, -// and returns its corresponding TexGenAttrib mode. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the tex_gen from the given egg texture, and returns its + * corresponding TexGenAttrib mode. + */ TexGenAttrib::Mode EggRenderState:: get_tex_gen(const EggTexture *egg_tex) { switch (egg_tex->get_tex_gen()) { @@ -581,25 +566,22 @@ get_tex_gen(const EggTexture *egg_tex) { return TexGenAttrib::M_off; } -//////////////////////////////////////////////////////////////////// -// Function: EggRenderState::apply_tex_mat -// Access: Private -// Description: Applies the texture matrix from the indicated egg -// texture to the given TexMatrixAttrib, and returns the -// new attrib. -//////////////////////////////////////////////////////////////////// +/** + * Applies the texture matrix from the indicated egg texture to the given + * TexMatrixAttrib, and returns the new attrib. + */ CPT(RenderAttrib) EggRenderState:: -apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, +apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, TextureStage *stage, const EggTexture *egg_tex) { if (egg_tex->has_transform()) { CPT(TransformState) transform = _loader.make_transform(egg_tex); - + if (tex_mat_attrib == (const RenderAttrib *)NULL) { tex_mat_attrib = TexMatrixAttrib::make(); } tex_mat_attrib = DCAST(TexMatrixAttrib, tex_mat_attrib)-> add_stage(stage, transform); } - + return tex_mat_attrib; } diff --git a/panda/src/egg2pg/eggRenderState.h b/panda/src/egg2pg/eggRenderState.h index 61bf5d1bc5..44993dffcf 100644 --- a/panda/src/egg2pg/eggRenderState.h +++ b/panda/src/egg2pg/eggRenderState.h @@ -1,16 +1,15 @@ -// Filename: eggRenderState.h -// Created by: drose (12Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRenderState.h + * @author drose + * @date 2005-03-12 + */ #ifndef EGGRENDERSTATE_H #define EGGRENDERSTATE_H @@ -32,13 +31,11 @@ class EggPrimitive; class EggTexture; class EggMaterial; -//////////////////////////////////////////////////////////////////// -// Class : EggRenderState -// Description : This class is used within this package only to record -// the render state that should be assigned to each -// primitive. It is assigned to EggPrimitive objects -// via the EggBinner. -//////////////////////////////////////////////////////////////////// +/** + * This class is used within this package only to record the render state that + * should be assigned to each primitive. It is assigned to EggPrimitive + * objects via the EggBinner. + */ class EggRenderState : public EggUserData { public: INLINE EggRenderState(EggLoader &loader); @@ -54,7 +51,7 @@ private: static TexGenAttrib::Mode get_tex_gen(const EggTexture *egg_tex); CPT(RenderAttrib) - apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, + apply_tex_mat(CPT(RenderAttrib) tex_mat_attrib, TextureStage *stage, const EggTexture *egg_tex); public: @@ -80,4 +77,3 @@ private: #include "eggRenderState.I" #endif - diff --git a/panda/src/egg2pg/eggSaver.I b/panda/src/egg2pg/eggSaver.I index 97a40f1764..89d6c0e1ad 100644 --- a/panda/src/egg2pg/eggSaver.I +++ b/panda/src/egg2pg/eggSaver.I @@ -1,25 +1,20 @@ -// Filename: eggSaver.I -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSaver.I + * @author drose + * @date 2012-12-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::get_egg_data -// Access: Published -// Description: Returns the EggData populated within this class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggData populated within this class. + */ INLINE EggData *EggSaver:: get_egg_data() const { return _data; } - diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index e4511ca64b..4ca97a9aeb 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -1,16 +1,15 @@ -// Filename: eggSaver.cxx -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSaver.cxx + * @author drose + * @date 2012-12-19 + */ #include "eggSaver.h" @@ -71,11 +70,9 @@ #include "eggTable.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggSaver:: EggSaver(EggData *data) : _data(data) @@ -85,13 +82,10 @@ EggSaver(EggData *data) : } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::add_node -// Access: Published -// Description: Adds the scene graph rooted at the indicated node to -// the accumulated egg data within this object. Call -// get_egg_data() to retrieve the result. -//////////////////////////////////////////////////////////////////// +/** + * Adds the scene graph rooted at the indicated node to the accumulated egg + * data within this object. Call get_egg_data() to retrieve the result. + */ void EggSaver:: add_node(PandaNode *node) { _vpool = new EggVertexPool(node->get_name()); @@ -107,13 +101,10 @@ add_node(PandaNode *node) { _vpool = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_node -// Access: Private -// Description: Converts the indicated node to the corresponding Egg -// constructs, by first determining what kind of node it -// is. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated node to the corresponding Egg constructs, by first + * determining what kind of node it is. + */ void EggSaver:: convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { @@ -144,22 +135,19 @@ convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent, EggGroup *egg_group = new EggGroup(node->get_name()); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node); - + recurse_nodes(node_path, egg_group, has_decal); } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_lod_node -// Access: Private -// Description: Converts the indicated LODNode to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated LODNode to the corresponding Egg constructs. + */ void EggSaver:: convert_lod_node(LODNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - // An LOD node gets converted to an ordinary EggGroup, but we apply - // the appropriate switch conditions to each of our children. + // An LOD node gets converted to an ordinary EggGroup, but we apply the + // appropriate switch conditions to each of our children. EggGroup *egg_group = new EggGroup(node->get_name()); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node); @@ -197,17 +185,14 @@ convert_lod_node(LODNode *node, const WorkingNodePath &node_path, } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_sequence_node -// Access: Private -// Description: Converts the indicated SequenceNode to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated SequenceNode to the corresponding Egg constructs. + */ void EggSaver:: convert_sequence_node(SequenceNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - // A sequence node gets converted to an ordinary EggGroup, we only apply - // the appropriate switch attributes to turn it into a sequence + // A sequence node gets converted to an ordinary EggGroup, we only apply the + // appropriate switch attributes to turn it into a sequence EggGroup *egg_group = new EggGroup(node->get_name()); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node); @@ -230,17 +215,14 @@ convert_sequence_node(SequenceNode *node, const WorkingNodePath &node_path, } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_switch_node -// Access: Private -// Description: Converts the indicated SwitchNode to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated SwitchNode to the corresponding Egg constructs. + */ void EggSaver:: convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - // A sequence node gets converted to an ordinary EggGroup, we only apply - // the appropriate switch attributes to turn it into a sequence + // A sequence node gets converted to an ordinary EggGroup, we only apply the + // appropriate switch attributes to turn it into a sequence EggGroup *egg_group = new EggGroup(node->get_name()); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node); @@ -261,12 +243,10 @@ convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path, } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_animGroup_node -// Access: Private -// Description: Converts the indicated AnimationGroupNodes to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated AnimationGroupNodes to the corresponding Egg + * constructs. + */ EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps ) { int num_children = animGroup->get_num_children(); @@ -305,44 +285,38 @@ EggGroupNode * EggSaver::convert_animGroup_node(AnimGroup *animGroup, double fps nassertr(eggNode!=NULL, NULL); eggNode->add_child(eggChildNode); } - } + } return eggNode; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_anim_node -// Access: Private -// Description: Converts the indicated AnimNode to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated AnimNode to the corresponding Egg constructs. + */ void EggSaver:: convert_anim_node(AnimBundleNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - - // A sequence node gets converted to an ordinary EggGroup, we only apply - // the appropriate switch attributes to turn it into a sequence + + // A sequence node gets converted to an ordinary EggGroup, we only apply the + // appropriate switch attributes to turn it into a sequence EggTable *eggTable = new EggTable(); - //egg_parent->add_child(eggTable); + // egg_parent->add_child(eggTable); _data->add_child(eggTable); - + AnimBundle *animBundle = node->get_bundle(); - // turn it into a switch.. - //egg_group->set_switch_flag(true); + // turn it into a switch.. egg_group->set_switch_flag(true); EggGroupNode *eggAnimation = convert_animGroup_node(animBundle, animBundle->get_base_frame_rate()); eggTable->add_child(eggAnimation); } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_character_bundle -// Access: Private -// Description: Converts the indicated Character Bundle to the corresponding -// Egg joints structure. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Character Bundle to the corresponding Egg joints + * structure. + */ void EggSaver:: convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, CharacterJointMap *jointMap) { int num_children = bundleNode->get_num_children(); - + EggGroupNode *joint_group = egg_parent; if (bundleNode->is_of_type(CharacterJoint::get_class_type())) { CharacterJoint *character_joint = DCAST(CharacterJoint, bundleNode); @@ -374,27 +348,23 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_character_node -// Access: Private -// Description: Converts the indicated Character to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Character to the corresponding Egg constructs. + */ void EggSaver:: convert_character_node(Character *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - - // A sequence node gets converted to an ordinary EggGroup, we only apply - // the appropriate switch attributes to turn it into a sequence + + // A sequence node gets converted to an ordinary EggGroup, we only apply the + // appropriate switch attributes to turn it into a sequence EggGroup *egg_group = new EggGroup(node->get_name()); egg_group->set_dart_type(EggGroup::DT_default); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node); CharacterJointMap jointMap; - - // turn it into a switch.. - //egg_group->set_switch_flag(true); + + // turn it into a switch.. egg_group->set_switch_flag(true); int num_children = node->get_num_children(); int num_bundles = node->get_num_bundles(); @@ -415,17 +385,14 @@ convert_character_node(Character *node, const WorkingNodePath &node_path, } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_collision_node -// Access: Private -// Description: Converts the indicated CollisionNode to the corresponding -// Egg constructs. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated CollisionNode to the corresponding Egg constructs. + */ void EggSaver:: convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { - // A sequence node gets converted to an ordinary EggGroup, we only apply - // the appropriate switch attributes to turn it into a sequence + // A sequence node gets converted to an ordinary EggGroup, we only apply the + // appropriate switch attributes to turn it into a sequence EggGroup *egg_group = new EggGroup(node->get_name()); egg_parent->add_child(egg_group); apply_node_properties(egg_group, node, false); @@ -542,18 +509,15 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, } } - // recurse over children - hm. do I need to do this? + // recurse over children - hm. do I need to do this? recurse_nodes(node_path, egg_group, has_decal); } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_geom_node -// Access: Private -// Description: Converts a GeomNode to the corresponding egg -// structures. -//////////////////////////////////////////////////////////////////// +/** + * Converts a GeomNode to the corresponding egg structures. + */ void EggSaver:: -convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, +convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap) { PT(EggGroup) egg_group = new EggGroup(node->get_name()); bool fancy_attributes = apply_node_properties(egg_group, node); @@ -567,9 +531,9 @@ convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, } if (fancy_attributes || has_decal || !node->get_name().empty()) { - // If we have any fancy attributes on the node, or if we're making - // decal geometry, we have to make a special node to hold the - // geometry (normally it would just appear within its parent). + // If we have any fancy attributes on the node, or if we're making decal + // geometry, we have to make a special node to hold the geometry (normally + // it would just appear within its parent). egg_parent->add_child(egg_group.p()); egg_parent = egg_group; } @@ -592,24 +556,22 @@ convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, const GeomPrimitive *primitive = geom->get_primitive(j); CPT(GeomPrimitive) simple = primitive->decompose(); CPT(GeomVertexData) vdata = geom->get_vertex_data(); - // vdata = vdata->animate_vertices(true, Thread::get_current_thread()); + // vdata = vdata->animate_vertices(true, Thread::get_current_thread()); convert_primitive(vdata, simple, geom_state, net_mat, egg_parent, jointMap); } } - + recurse_nodes(node_path, egg_parent, has_decal); } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::convert_primitive -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggSaver:: convert_primitive(const GeomVertexData *vertex_data, const GeomPrimitive *primitive, - const RenderState *net_state, + const RenderState *net_state, const LMatrix4 &net_mat, EggGroupNode *egg_parent, CharacterJointMap *jointMap) { GeomVertexReader reader(vertex_data); @@ -785,21 +747,21 @@ convert_primitive(const GeomVertexData *vertex_data, if (egg_tex != (EggTexture *)NULL) { egg_prim->set_texture(egg_tex); } - + if (bface) { egg_prim->set_bface_flag(true); } for (int j = 0; j < num_vertices; j++) { EggVertex egg_vert; - + // Get per-vertex properties. reader.set_row(primitive->get_vertex(i * num_vertices + j)); - + reader.set_column(InternalName::get_vertex()); LVertex vertex = reader.get_data3(); egg_vert.set_pos(LCAST(double, vertex * net_mat)); - + if (vertex_data->has_column(InternalName::get_normal())) { reader.set_column(InternalName::get_normal()); LNormal normal = reader.get_data3(); @@ -807,7 +769,7 @@ convert_primitive(const GeomVertexData *vertex_data, } if (has_color_override) { egg_vert.set_color(color_override); - + } else if (!has_color_off) { LColor color(1.0f, 1.0f, 1.0f, 1.0f); if (vertex_data->has_column(InternalName::get_color())) { @@ -819,16 +781,16 @@ convert_primitive(const GeomVertexData *vertex_data, color[2] * color_scale[2], color[3] * color_scale[3])); } - + if (vertex_data->has_column(InternalName::get_texcoord())) { reader.set_column(InternalName::get_texcoord()); LTexCoord uv = reader.get_data2(); egg_vert.set_uv(LCAST(double, uv)); } - + EggVertex *new_egg_vert = _vpool->create_unique_vertex(egg_vert); - - if ((vertex_data->has_column(InternalName::get_transform_blend())) && + + if ((vertex_data->has_column(InternalName::get_transform_blend())) && (jointMap!=NULL) && (transformBlendTable!=NULL)) { reader.set_column(InternalName::get_transform_blend()); int idx = reader.get_data1i(); @@ -857,38 +819,33 @@ convert_primitive(const GeomVertexData *vertex_data, } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::recurse_nodes -// Access: Private -// Description: Converts all the children of the indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Converts all the children of the indicated node. + */ void EggSaver:: recurse_nodes(const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal) { PandaNode *node = node_path.node(); int num_children = node->get_num_children(); - + for (int i = 0; i < num_children; i++) { PandaNode *child = node->get_child(i); convert_node(WorkingNodePath(node_path, child), egg_parent, has_decal); } } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::apply_node_properties -// Access: Private -// Description: Applies any special properties that might be stored -// on the node, like billboarding. Returns true if any -// were applied, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Applies any special properties that might be stored on the node, like + * billboarding. Returns true if any were applied, false otherwise. + */ bool EggSaver:: apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage) { bool any_applied = false; if (node->is_overall_hidden() && allow_backstage) { - // This node is hidden. We'll go ahead and convert it, but we'll - // put in the "backstage" flag to mean it's not real geometry. - // unless the caller wants to keep it (by setting allow_backstage to false) + // This node is hidden. We'll go ahead and convert it, but we'll put in + // the "backstage" flag to mean it's not real geometry. unless the caller + // wants to keep it (by setting allow_backstage to false) egg_group->add_object_type("backstage"); } @@ -940,8 +897,8 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage const TransformState *transform = node->get_transform(); if (!transform->is_identity()) { if (transform->has_components()) { - // If the transform can be represented componentwise, we prefer - // storing it that way in the egg file. + // If the transform can be represented componentwise, we prefer storing + // it that way in the egg file. const LVecBase3 &scale = transform->get_scale(); const LQuaternion &quat = transform->get_quat(); const LVecBase3 &pos = transform->get_pos(); @@ -966,12 +923,10 @@ apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage return any_applied; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::apply_tags -// Access: Private -// Description: Applies string tags to the egg file. Returns true if -// any were applied, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Applies string tags to the egg file. Returns true if any were applied, + * false otherwise. + */ bool EggSaver:: apply_tags(EggGroup *egg_group, PandaNode *node) { ostringstream strm; @@ -996,7 +951,7 @@ apply_tags(EggGroup *egg_group, PandaNode *node) { p = q + 1; q = data.find(delimiter, p); } - + string tag = data.substr(p); if (apply_tag(egg_group, node, tag)) { any_applied = true; @@ -1005,11 +960,9 @@ apply_tags(EggGroup *egg_group, PandaNode *node) { return any_applied; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::apply_tag -// Access: Private -// Description: Applies the named string tags to the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the named string tags to the egg file. + */ bool EggSaver:: apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag) { if (!node->has_tag(tag)) { @@ -1021,12 +974,9 @@ apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::get_egg_material -// Access: Private -// Description: Returns an EggMaterial pointer that corresponds to -// the indicated Material. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggMaterial pointer that corresponds to the indicated Material. + */ EggMaterial *EggSaver:: get_egg_material(Material *mat) { if (mat != (Material *)NULL) { @@ -1073,12 +1023,9 @@ get_egg_material(Material *mat) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::get_egg_texture -// Access: Private -// Description: Returns an EggTexture pointer that corresponds to the -// indicated Texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggTexture pointer that corresponds to the indicated Texture. + */ EggTexture *EggSaver:: get_egg_texture(Texture *tex) { if (tex != (Texture *)NULL) { @@ -1220,41 +1167,33 @@ get_egg_texture(Texture *tex) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::make_egg_polygon -// Access: Private, Static -// Description: A factory function to make a new EggPolygon instance. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new EggPolygon instance. + */ EggPrimitive *EggSaver:: make_egg_polygon() { return new EggPolygon; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::make_egg_patch -// Access: Private, Static -// Description: A factory function to make a new EggPatch instance. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new EggPatch instance. + */ EggPrimitive *EggSaver:: make_egg_patch() { return new EggPatch; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::make_egg_point -// Access: Private, Static -// Description: A factory function to make a new EggPoint instance. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new EggPoint instance. + */ EggPrimitive *EggSaver:: make_egg_point() { return new EggPoint; } -//////////////////////////////////////////////////////////////////// -// Function: EggSaver::make_egg_line -// Access: Private, Static -// Description: A factory function to make a new EggLine instance. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new EggLine instance. + */ EggPrimitive *EggSaver:: make_egg_line() { return new EggLine; diff --git a/panda/src/egg2pg/eggSaver.h b/panda/src/egg2pg/eggSaver.h index 7cb52908cd..0944f0a4eb 100644 --- a/panda/src/egg2pg/eggSaver.h +++ b/panda/src/egg2pg/eggSaver.h @@ -1,16 +1,15 @@ -// Filename: eggSaver.h -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSaver.h + * @author drose + * @date 2012-12-19 + */ #ifndef EGGSAVER_H #define EGGSAVER_H @@ -45,14 +44,12 @@ class Texture; class CharacterJoint; class EggVertex; -//////////////////////////////////////////////////////////////////// -// Class : EggSaver -// Description : Converts the scene graph beginning at the indicated -// node into an EggData structure, for writing to an egg -// file. The conversion is not necessarily complete -// (some Panda or egg constructs are not fully supported -// by this class). -//////////////////////////////////////////////////////////////////// +/** + * Converts the scene graph beginning at the indicated node into an EggData + * structure, for writing to an egg file. The conversion is not necessarily + * complete (some Panda or egg constructs are not fully supported by this + * class). + */ class EggSaver { PUBLISHED: EggSaver(EggData *data = NULL); @@ -79,11 +76,11 @@ private: void convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, CharacterJointMap *jointMap); void convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal); - void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, + void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=NULL); void convert_primitive(const GeomVertexData *vertex_data, - const GeomPrimitive *primitive, - const RenderState *net_state, + const GeomPrimitive *primitive, + const RenderState *net_state, const LMatrix4 &net_mat, EggGroupNode *egg_parent, CharacterJointMap *jointMap); diff --git a/panda/src/egg2pg/egg_parametrics.cxx b/panda/src/egg2pg/egg_parametrics.cxx index 00b8d91dc9..e57f49e297 100644 --- a/panda/src/egg2pg/egg_parametrics.cxx +++ b/panda/src/egg2pg/egg_parametrics.cxx @@ -1,29 +1,25 @@ -// Filename: egg_parametrics.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file egg_parametrics.cxx + * @author drose + * @date 2003-10-13 + */ #include "egg_parametrics.h" #include "config_egg2pg.h" -//////////////////////////////////////////////////////////////////// -// Function: make_nurbs_surface -// Description: Returns a new NurbsSurfaceEvaluator that's filled in -// with the values from the given EggSurface (and -// transformed by the indicated matrix), or NULL if the -// object is invalid. If there is vertex color, it will -// be applied to values 0 - 3 of the extended vertex -// values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new NurbsSurfaceEvaluator that's filled in with the values from + * the given EggSurface (and transformed by the indicated matrix), or NULL if + * the object is invalid. If there is vertex color, it will be applied to + * values 0 - 3 of the extended vertex values. + */ PT(NurbsSurfaceEvaluator) make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { if (egg_surface->get_u_order() < 1 || egg_surface->get_u_order() > 4) { @@ -88,15 +84,12 @@ make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat) { return nurbs; } -//////////////////////////////////////////////////////////////////// -// Function: make_nurbs_curve -// Description: Returns a new NurbsCurveEvaluator that's filled in -// with the values from the given EggCurve (and -// transformed by the indicated matrix), or NULL if the -// object is invalid. If there is vertex color, it will -// be applied to values 0 - 3 of the extended vertex -// values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new NurbsCurveEvaluator that's filled in with the values from the + * given EggCurve (and transformed by the indicated matrix), or NULL if the + * object is invalid. If there is vertex color, it will be applied to values + * 0 - 3 of the extended vertex values. + */ PT(NurbsCurveEvaluator) make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat) { if (egg_curve->get_order() < 1 || egg_curve->get_order() > 4) { diff --git a/panda/src/egg2pg/egg_parametrics.h b/panda/src/egg2pg/egg_parametrics.h index 627a94bc28..639561dc0e 100644 --- a/panda/src/egg2pg/egg_parametrics.h +++ b/panda/src/egg2pg/egg_parametrics.h @@ -1,16 +1,15 @@ -// Filename: egg_parametrics.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file egg_parametrics.h + * @author drose + * @date 2003-10-13 + */ #ifndef EGG_PARAMETRICS_H #define EGG_PARAMETRICS_H @@ -24,27 +23,21 @@ BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: make_nurbs_surface -// Description: Returns a new NurbsSurfaceEvaluator that's filled in -// with the values from the given EggSurface (and -// transformed by the indicated matrix), or NULL if the -// object is invalid. If there is vertex color, it will -// be applied to values 0 - 3 of the extended vertex -// values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new NurbsSurfaceEvaluator that's filled in with the values from + * the given EggSurface (and transformed by the indicated matrix), or NULL if + * the object is invalid. If there is vertex color, it will be applied to + * values 0 - 3 of the extended vertex values. + */ EXPCL_PANDAEGG PT(NurbsSurfaceEvaluator) make_nurbs_surface(EggNurbsSurface *egg_surface, const LMatrix4d &mat); -//////////////////////////////////////////////////////////////////// -// Function: make_nurbs_curve -// Description: Returns a new NurbsCurveEvaluator that's filled in -// with the values from the given EggCurve (and -// transformed by the indicated matrix), or NULL if the -// object is invalid. If there is vertex color, it will -// be applied to values 0 - 3 of the extended vertex -// values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new NurbsCurveEvaluator that's filled in with the values from the + * given EggCurve (and transformed by the indicated matrix), or NULL if the + * object is invalid. If there is vertex color, it will be applied to values + * 0 - 3 of the extended vertex values. + */ EXPCL_PANDAEGG PT(NurbsCurveEvaluator) make_nurbs_curve(EggNurbsCurve *egg_curve, const LMatrix4d &mat); diff --git a/panda/src/egg2pg/load_egg_file.cxx b/panda/src/egg2pg/load_egg_file.cxx index 1f0873f7c6..a3a5dd5fbf 100644 --- a/panda/src/egg2pg/load_egg_file.cxx +++ b/panda/src/egg2pg/load_egg_file.cxx @@ -1,16 +1,15 @@ -// Filename: load_egg_file.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_egg_file.cxx + * @author drose + * @date 2002-02-26 + */ #include "load_egg_file.h" #include "eggLoader.h" @@ -64,15 +63,12 @@ load_from_loader(EggLoader &loader) { return loader._root; } -//////////////////////////////////////////////////////////////////// -// Function: load_egg_file -// Description: A convenience function. Loads up the indicated egg -// file, and returns the root of a scene graph. Returns -// NULL if the file cannot be read for some reason. -// Does not search along the egg path for the filename -// first; use EggData::resolve_egg_filename() if this is -// required. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function. Loads up the indicated egg file, and returns the + * root of a scene graph. Returns NULL if the file cannot be read for some + * reason. Does not search along the egg path for the filename first; use + * EggData::resolve_egg_filename() if this is required. + */ PT(PandaNode) load_egg_file(const Filename &filename, CoordinateSystem cs, BamCacheRecord *record) { @@ -120,17 +116,15 @@ load_egg_file(const Filename &filename, CoordinateSystem cs, return load_from_loader(loader); } -//////////////////////////////////////////////////////////////////// -// Function: load_egg_data -// Description: Another convenience function; works like -// load_egg_file() but starts from an already-filled -// EggData structure. The structure is destroyed in the -// loading. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function; works like load_egg_file() but starts from an + * already-filled EggData structure. The structure is destroyed in the + * loading. + */ PT(PandaNode) load_egg_data(EggData *data, CoordinateSystem cs) { - // We temporarily shuttle the children to a holding node so we can - // copy them into the EggLoader's structure without it complaining. + // We temporarily shuttle the children to a holding node so we can copy them + // into the EggLoader's structure without it complaining. EggGroupNode children_holder; children_holder.steal_children(*data); diff --git a/panda/src/egg2pg/load_egg_file.h b/panda/src/egg2pg/load_egg_file.h index 379b9f449f..296d1aaa60 100644 --- a/panda/src/egg2pg/load_egg_file.h +++ b/panda/src/egg2pg/load_egg_file.h @@ -1,16 +1,15 @@ -// Filename: load_egg_file.h -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_egg_file.h + * @author drose + * @date 2002-02-26 + */ #ifndef LOAD_EGG_FILE_H #define LOAD_EGG_FILE_H @@ -24,27 +23,23 @@ class BamCacheRecord; BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: load_egg_file -// Description: A convenience function; the primary interface to this -// package. Loads up the indicated egg file, and -// returns the root of a scene graph. Returns NULL if -// the file cannot be read for some reason. -// -// Also see the EggLoader class, which can exercise a -// bit more manual control over the loading process. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function; the primary interface to this package. Loads up + * the indicated egg file, and returns the root of a scene graph. Returns + * NULL if the file cannot be read for some reason. + * + * Also see the EggLoader class, which can exercise a bit more manual control + * over the loading process. + */ EXPCL_PANDAEGG PT(PandaNode) load_egg_file(const Filename &filename, CoordinateSystem cs = CS_default, BamCacheRecord *record = NULL); -//////////////////////////////////////////////////////////////////// -// Function: load_egg_data -// Description: Another convenience function; works like -// load_egg_file() but starts from an already-filled -// EggData structure. The structure is destroyed in the -// loading. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function; works like load_egg_file() but starts from an + * already-filled EggData structure. The structure is destroyed in the + * loading. + */ EXPCL_PANDAEGG PT(PandaNode) load_egg_data(EggData *data, CoordinateSystem cs = CS_default); END_PUBLISH diff --git a/panda/src/egg2pg/loaderFileTypeEgg.cxx b/panda/src/egg2pg/loaderFileTypeEgg.cxx index 760001ef47..be2af1dfe1 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.cxx +++ b/panda/src/egg2pg/loaderFileTypeEgg.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeEgg.cxx -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeEgg.cxx + * @author drose + * @date 2000-06-20 + */ #include "loaderFileTypeEgg.h" #include "load_egg_file.h" @@ -20,88 +19,71 @@ TypeHandle LoaderFileTypeEgg::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeEgg:: LoaderFileTypeEgg() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeEgg:: get_name() const { return "Egg"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeEgg:: get_extension() const { return "egg"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeEgg:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::supports_load -// Access: Published, Virtual -// Description: Returns true if the file type can be used to load -// files, and load_file() is supported. Returns false -// if load_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to load files, and load_file() is + * supported. Returns false if load_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypeEgg:: supports_load() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::supports_save -// Access: Published, Virtual -// Description: Returns true if the file type can be used to save -// files, and save_file() is supported. Returns false -// if save_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to save files, and save_file() is + * supported. Returns false if save_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypeEgg:: supports_save() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeEgg:: -load_file(const Filename &path, const LoaderOptions &, +load_file(const Filename &path, const LoaderOptions &, BamCacheRecord *record) const { PT(PandaNode) result = load_egg_file(path, CS_default, record); return result; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeEgg::save_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool LoaderFileTypeEgg:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { diff --git a/panda/src/egg2pg/loaderFileTypeEgg.h b/panda/src/egg2pg/loaderFileTypeEgg.h index f08f91911d..b1c9c00e7b 100644 --- a/panda/src/egg2pg/loaderFileTypeEgg.h +++ b/panda/src/egg2pg/loaderFileTypeEgg.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeEgg.h -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeEgg.h + * @author drose + * @date 2000-06-20 + */ #ifndef LOADERFILETYPEEGG_H #define LOADERFILETYPEEGG_H @@ -19,10 +18,9 @@ #include "loaderFileType.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeEgg -// Description : This defines the Loader interface to read Egg files. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to read Egg files. + */ class EXPCL_PANDAEGG LoaderFileTypeEgg : public LoaderFileType { public: LoaderFileTypeEgg(); @@ -58,4 +56,3 @@ private: }; #endif - diff --git a/panda/src/egg2pg/save_egg_file.cxx b/panda/src/egg2pg/save_egg_file.cxx index 0241684d38..db129802ba 100644 --- a/panda/src/egg2pg/save_egg_file.cxx +++ b/panda/src/egg2pg/save_egg_file.cxx @@ -1,16 +1,15 @@ -// Filename: save_egg_file.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file save_egg_file.cxx + * @author drose + * @date 2002-02-26 + */ #include "save_egg_file.h" #include "eggSaver.h" @@ -19,11 +18,10 @@ #include "virtualFileSystem.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Function: save_egg_file -// Description: A convenience function; converts the indicated scene -// graph to an egg file and writes it to disk. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function; converts the indicated scene graph to an egg file + * and writes it to disk. + */ bool save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs) { PT(EggData) data = new EggData; @@ -38,12 +36,10 @@ save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs) { return data->write_egg(filename); } -//////////////////////////////////////////////////////////////////// -// Function: save_egg_data -// Description: Another convenience function; works like -// save_egg_file() but populates an EggData instead of -// writing the results to disk. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function; works like save_egg_file() but populates an + * EggData instead of writing the results to disk. + */ bool save_egg_data(EggData *data, PandaNode *node) { EggSaver saver(data); diff --git a/panda/src/egg2pg/save_egg_file.h b/panda/src/egg2pg/save_egg_file.h index 524cd51c51..0c522cffa0 100644 --- a/panda/src/egg2pg/save_egg_file.h +++ b/panda/src/egg2pg/save_egg_file.h @@ -1,16 +1,15 @@ -// Filename: save_egg_file.h -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file save_egg_file.h + * @author drose + * @date 2012-12-19 + */ #ifndef SAVE_EGG_FILE_H #define SAVE_EGG_FILE_H @@ -22,21 +21,18 @@ #include "eggData.h" BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: save_egg_file -// Description: A convenience function; converts the indicated scene -// graph to an egg file and writes it to disk. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function; converts the indicated scene graph to an egg file + * and writes it to disk. + */ EXPCL_PANDAEGG bool save_egg_file(const Filename &filename, PandaNode *node, CoordinateSystem cs = CS_default); -//////////////////////////////////////////////////////////////////// -// Function: save_egg_data -// Description: Another convenience function; works like -// save_egg_file() but populates an EggData instead of -// writing the results to disk. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function; works like save_egg_file() but populates an + * EggData instead of writing the results to disk. + */ EXPCL_PANDAEGG bool save_egg_data(EggData *data, PandaNode *node); END_PUBLISH diff --git a/panda/src/egldisplay/config_egldisplay.cxx b/panda/src/egldisplay/config_egldisplay.cxx index a289ae7bf1..7277e517f8 100644 --- a/panda/src/egldisplay/config_egldisplay.cxx +++ b/panda/src/egldisplay/config_egldisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_egldisplay.cxx -// Created by: cary (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egldisplay.cxx + * @author cary + * @date 1999-10-07 + */ #include "config_egldisplay.h" #include "eglGraphicsPipe.h" @@ -62,14 +61,12 @@ ConfigVariableInt x_wheel_right_button "mouse button number does the system report when one scrolls " "to the right?")); -//////////////////////////////////////////////////////////////////// -// Function: init_libegldisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libegldisplay() { static bool initialized = false; @@ -94,10 +91,9 @@ init_libegldisplay() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_egl_error_string -// Description: Returns the given EGL error as string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the given EGL error as string. + */ const string get_egl_error_string(int error) { switch (error) { case 0x3000: return "EGL_SUCCESS"; break; diff --git a/panda/src/egldisplay/config_egldisplay.h b/panda/src/egldisplay/config_egldisplay.h index e8601dd806..1c403ec513 100644 --- a/panda/src/egldisplay/config_egldisplay.h +++ b/panda/src/egldisplay/config_egldisplay.h @@ -1,16 +1,15 @@ -// Filename: config_egldisplay.h -// Created by: cary (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egldisplay.h + * @author cary + * @date 2009-05-21 + */ #ifndef CONFIG_EGLDISPLAY_H #define CONFIG_EGLDISPLAY_H @@ -30,12 +29,12 @@ #ifdef OPENGLES_2 NotifyCategoryDecl(egldisplay, EXPCL_PANDAGLES2, EXPTP_PANDAGLES2); - + extern EXPCL_PANDAGLES2 void init_libegldisplay(); extern EXPCL_PANDAGLES2 const string get_egl_error_string(int error); #else NotifyCategoryDecl(egldisplay, EXPCL_PANDAGLES, EXPTP_PANDAGLES); - + extern EXPCL_PANDAGLES void init_libegldisplay(); extern EXPCL_PANDAGLES const string get_egl_error_string(int error); #endif diff --git a/panda/src/egldisplay/eglGraphicsBuffer.cxx b/panda/src/egldisplay/eglGraphicsBuffer.cxx index b18781aa97..14f6121653 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.cxx +++ b/panda/src/egldisplay/eglGraphicsBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: eglGraphicsBuffer.cxx -// Created by: rdb (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsBuffer.cxx + * @author rdb + * @date 2009-06-13 + */ #include "eglGraphicsBuffer.h" #include "eglGraphicsStateGuardian.h" @@ -22,11 +21,9 @@ TypeHandle eglGraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsBuffer:: eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -41,30 +38,25 @@ eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, DCAST_INTO_V(egl_pipe, _pipe); _pbuffer = EGL_NO_SURFACE; - // Since the pbuffer never gets flipped, we get screenshots from the - // same buffer we draw into. + // Since the pbuffer never gets flipped, we get screenshots from the same + // buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsBuffer:: ~eglGraphicsBuffer() { nassertv(_pbuffer == EGL_NO_SURFACE); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool eglGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -81,10 +73,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { << get_egl_error_string(eglGetError()) << "\n"; } - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) eglgsg->reset_if_new(); if (mode == FM_render) { @@ -100,18 +92,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { } clear_cube_map_selection(); } - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void eglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -129,12 +119,9 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void eglGraphicsBuffer:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -145,7 +132,7 @@ close_buffer() { << get_egl_error_string(eglGetError()) << "\n"; } _gsg.clear(); - + if (_pbuffer != EGL_NO_SURFACE) { if (!eglDestroySurface(_egl_display, _pbuffer)) { egldisplay_cat.error() << "Failed to destroy surface: " @@ -158,19 +145,16 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the buffer right now. Called from the window -// thread. Returns true if the buffer is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the buffer right now. Called from the window thread. Returns true + * if the buffer is successfully opened, or false if there was a problem. + */ bool eglGraphicsBuffer:: open_buffer() { eglGraphicsPipe *egl_pipe; DCAST_INTO_R(egl_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -178,8 +162,8 @@ open_buffer() { eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), true, false); _gsg = eglgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(eglgsg, _gsg, false); if (!eglgsg->get_fb_properties().subsumes(_fb_properties)) { eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, eglgsg); @@ -189,8 +173,8 @@ open_buffer() { } if (eglgsg->_fbconfig == None) { - // If we didn't use an fbconfig to create the GSG, we can't create - // a PBuffer. + // If we didn't use an fbconfig to create the GSG, we can't create a + // PBuffer. return false; } diff --git a/panda/src/egldisplay/eglGraphicsBuffer.h b/panda/src/egldisplay/eglGraphicsBuffer.h index a1f2c92b69..0d5d473d36 100644 --- a/panda/src/egldisplay/eglGraphicsBuffer.h +++ b/panda/src/egldisplay/eglGraphicsBuffer.h @@ -1,16 +1,15 @@ -// Filename: eglGraphicsBuffer.h -// Created by: rdb (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsBuffer.h + * @author rdb + * @date 2009-06-13 + */ #ifndef EGLGRAPHICSBUFFER_H #define EGLGRAPHICSBUFFER_H @@ -20,14 +19,12 @@ #include "eglGraphicsPipe.h" #include "graphicsBuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : eglGraphicsBuffer -// Description : An offscreen buffer in the EGL environment. This -// creates an EGL pbuffer. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen buffer in the EGL environment. This creates an EGL pbuffer. + */ class eglGraphicsBuffer : public GraphicsBuffer { public: - eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, + eglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/egldisplay/eglGraphicsPipe.I b/panda/src/egldisplay/eglGraphicsPipe.I index a4b9508aea..bec9e98a34 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.I +++ b/panda/src/egldisplay/eglGraphicsPipe.I @@ -1,68 +1,54 @@ -// Filename: eglGraphicsPipe.I -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsPipe.I + * @author rdb + * @date 2009-05-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_display -// Access: Public -// Description: Returns a pointer to the X display associated with -// the pipe: the display on which to create the windows. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the X display associated with the pipe: the display on + * which to create the windows. + */ INLINE X11_Display *eglGraphicsPipe:: get_display() const { return _display; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_screen -// Access: Public -// Description: Returns the X screen number associated with the pipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X screen number associated with the pipe. + */ INLINE int eglGraphicsPipe:: get_screen() const { return _screen; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_root -// Access: Public -// Description: Returns the handle to the root window on the pipe's -// display. -//////////////////////////////////////////////////////////////////// +/** + * Returns the handle to the root window on the pipe's display. + */ INLINE X11_Window eglGraphicsPipe:: get_root() const { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_im -// Access: Public -// Description: Returns the input method opened for the pipe, or NULL -// if the input method could not be opened for some -// reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input method opened for the pipe, or NULL if the input method + * could not be opened for some reason. + */ INLINE XIM eglGraphicsPipe:: get_im() const { return _im; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_hidden_cursor -// Access: Public -// Description: Returns an invisible Cursor suitable for assigning to -// windows that have the cursor_hidden property set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an invisible Cursor suitable for assigning to windows that have the + * cursor_hidden property set. + */ INLINE X11_Cursor eglGraphicsPipe:: get_hidden_cursor() { if (_hidden_cursor == None) { diff --git a/panda/src/egldisplay/eglGraphicsPipe.cxx b/panda/src/egldisplay/eglGraphicsPipe.cxx index cc9d44969c..0280b2bd7d 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.cxx +++ b/panda/src/egldisplay/eglGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: eglGraphicsPipe.cxx -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsPipe.cxx + * @author rdb + * @date 2009-05-21 + */ #include "eglGraphicsBuffer.h" #include "eglGraphicsPipe.h" @@ -28,11 +27,9 @@ eglGraphicsPipe::IOErrorHandlerFunc *eglGraphicsPipe::_prev_io_error_handler; LightReMutex eglGraphicsPipe::_x_mutex; -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsPipe:: eglGraphicsPipe(const string &display) { string display_spec = display; @@ -46,13 +43,13 @@ eglGraphicsPipe(const string &display) { display_spec = ":0.0"; } - // The X docs say we should do this to get international character - // support from the keyboard. + // The X docs say we should do this to get international character support + // from the keyboard. setlocale(LC_ALL, ""); - // But it's important that we use the "C" locale for numeric - // formatting, since all of the internal Panda code assumes this--we - // need a decimal point to mean a decimal point. + // But it's important that we use the "C" locale for numeric formatting, + // since all of the internal Panda code assumes this--we need a decimal + // point to mean a decimal point. setlocale(LC_NUMERIC, "C"); _is_valid = false; @@ -98,8 +95,7 @@ eglGraphicsPipe(const string &display) { << get_egl_error_string(eglGetError()) << "\n"; } - // Connect to an input method for supporting international text - // entry. + // Connect to an input method for supporting international text entry. _im = XOpenIM(_display, NULL, NULL, NULL); if (_im == (XIM)NULL) { egldisplay_cat.warning() @@ -132,11 +128,9 @@ eglGraphicsPipe(const string &display) { _net_wm_state_remove = XInternAtom(_display, "_NET_WM_STATE_REMOVE", false); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsPipe:: ~eglGraphicsPipe() { release_hidden_cursor(); @@ -154,62 +148,49 @@ eglGraphicsPipe:: } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string eglGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// eglGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default eglGraphicsPipe. + */ PT(GraphicsPipe) eglGraphicsPipe:: pipe_constructor() { return new eglGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ GraphicsPipe::PreferredWindowThread eglGraphicsPipe::get_preferred_window_thread() const { - // Actually, since we're creating the graphics context in - // open_window() now, it appears we need to ensure the open_window() - // call is performed in the draw thread for now, even though X wants - // all of its calls to be single-threaded. + // Actually, since we're creating the graphics context in open_window() now, + // it appears we need to ensure the open_window() call is performed in the + // draw thread for now, even though X wants all of its calls to be single- + // threaded. - // This means that all X windows may have to be handled by the same - // draw thread, which we didn't intend (though the global _x_mutex - // may allow them to be technically served by different threads, - // even though the actual X calls will be serialized). There might - // be a better way. + // This means that all X windows may have to be handled by the same draw + // thread, which we didn't intend (though the global _x_mutex may allow them + // to be technically served by different threads, even though the actual X + // calls will be serialized). There might be a better way. return PWT_draw; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) eglGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -260,13 +241,13 @@ make_output(const string &name, // Second thing to try: a GLES(2)GraphicsBuffer if (retry == 1) { if ((host==0)|| - // (!gl_support_fbo)|| + // (!gl_support_fbo)|| ((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional)==0) { if ((fb_prop.get_indexed_color() > 0)|| (fb_prop.get_back_buffers() > 0)|| @@ -275,8 +256,8 @@ make_output(const string &name, return NULL; } } - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we can + // precertify it. if ((eglgsg != 0) && (eglgsg->is_valid()) && (!eglgsg->needs_reset()) && @@ -306,8 +287,8 @@ make_output(const string &name, if (!support_rtt) { if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - // If we require Render-to-Texture, but can't be sure we - // support it, bail. + // If we require Render-to-Texture, but can't be sure we support it, + // bail. return NULL; } } @@ -338,12 +319,10 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::make_hidden_cursor -// Access: Private -// Description: Called once to make an invisible Cursor for return -// from get_hidden_cursor(). -//////////////////////////////////////////////////////////////////// +/** + * Called once to make an invisible Cursor for return from + * get_hidden_cursor(). + */ void eglGraphicsPipe:: make_hidden_cursor() { nassertv(_hidden_cursor == None); @@ -361,12 +340,10 @@ make_hidden_cursor() { XFreePixmap(_display, empty); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::release_hidden_cursor -// Access: Private -// Description: Called once to release the invisible cursor created -// by make_hidden_cursor(). -//////////////////////////////////////////////////////////////////// +/** + * Called once to release the invisible cursor created by + * make_hidden_cursor(). + */ void eglGraphicsPipe:: release_hidden_cursor() { if (_hidden_cursor != None) { @@ -375,17 +352,13 @@ release_hidden_cursor() { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::install_error_handlers -// Access: Private, Static -// Description: Installs new Xlib error handler functions if this is -// the first time this function has been called. These -// error handler functions will attempt to reduce Xlib's -// annoying tendency to shut down the client at the -// first error. Unfortunately, it is difficult to play -// nice with the client if it has already installed its -// own error handlers. -//////////////////////////////////////////////////////////////////// +/** + * Installs new Xlib error handler functions if this is the first time this + * function has been called. These error handler functions will attempt to + * reduce Xlib's annoying tendency to shut down the client at the first error. + * Unfortunately, it is difficult to play nice with the client if it has + * already installed its own error handlers. + */ void eglGraphicsPipe:: install_error_handlers() { if (_error_handlers_installed) { @@ -397,12 +370,9 @@ install_error_handlers() { _error_handlers_installed = true; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::error_handler -// Access: Private, Static -// Description: This function is installed as the error handler for a -// non-fatal Xlib error. -//////////////////////////////////////////////////////////////////// +/** + * This function is installed as the error handler for a non-fatal Xlib error. + */ int eglGraphicsPipe:: error_handler(X11_Display *display, XErrorEvent *error) { static const int msg_len = 80; @@ -415,25 +385,22 @@ error_handler(X11_Display *display, XErrorEvent *error) { abort(); } - // We return to allow the application to continue running, unlike - // the default X error handler which exits. + // We return to allow the application to continue running, unlike the + // default X error handler which exits. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPipe::io_error_handler -// Access: Private, Static -// Description: This function is installed as the error handler for a -// fatal Xlib error. -//////////////////////////////////////////////////////////////////// +/** + * This function is installed as the error handler for a fatal Xlib error. + */ int eglGraphicsPipe:: io_error_handler(X11_Display *display) { egldisplay_cat.fatal() << "X fatal error on display " << (void *)display << "\n"; - // Unfortunately, we can't continue from this function, even if we - // promise never to use X again. We're supposed to terminate - // without returning, and if we do return, the caller will exit - // anyway. Sigh. Very poor design on X's part. + // Unfortunately, we can't continue from this function, even if we promise + // never to use X again. We're supposed to terminate without returning, and + // if we do return, the caller will exit anyway. Sigh. Very poor design on + // X's part. return 0; } diff --git a/panda/src/egldisplay/eglGraphicsPipe.h b/panda/src/egldisplay/eglGraphicsPipe.h index fd15c88be8..3cd9682350 100644 --- a/panda/src/egldisplay/eglGraphicsPipe.h +++ b/panda/src/egldisplay/eglGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: eglGraphicsPipe.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsPipe.h + * @author rdb + * @date 2009-05-21 + */ #ifndef EGLGRAPHICSPIPE_H #define EGLGRAPHICSPIPE_H @@ -43,12 +42,10 @@ class eglGraphicsBuffer; class eglGraphicsPixmap; class eglGraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : eglGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL ES graphics windows on an X-based -// (e.g. Unix) client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL ES graphics + * windows on an X-based (e.g. Unix) client. + */ class eglGraphicsPipe : public GraphicsPipe { public: eglGraphicsPipe(const string &display = string()); @@ -114,8 +111,8 @@ private: static IOErrorHandlerFunc *_prev_io_error_handler; public: - // This Mutex protects any X library calls, which all have to be - // single-threaded. In particular, it protects eglMakeCurrent(). + // This Mutex protects any X library calls, which all have to be single- + // threaded. In particular, it protects eglMakeCurrent(). static LightReMutex _x_mutex; public: diff --git a/panda/src/egldisplay/eglGraphicsPixmap.cxx b/panda/src/egldisplay/eglGraphicsPixmap.cxx index 46e2e20c90..ce0abdfdb7 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.cxx +++ b/panda/src/egldisplay/eglGraphicsPixmap.cxx @@ -1,16 +1,15 @@ -// Filename: eglGraphicsPixmap.cxx -// Created by: rdb (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsPixmap.cxx + * @author rdb + * @date 2009-06-13 + */ #include "eglGraphicsPixmap.h" #include "eglGraphicsWindow.h" @@ -23,11 +22,9 @@ TypeHandle eglGraphicsPixmap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsPixmap:: eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -46,30 +43,25 @@ eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, _x_pixmap = None; _egl_surface = EGL_NO_SURFACE; - // Since the pixmap never gets flipped, we get screenshots from the - // same pixmap we draw into. + // Since the pixmap never gets flipped, we get screenshots from the same + // pixmap we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsPixmap:: ~eglGraphicsPixmap() { nassertv(_x_pixmap == None && _egl_surface == EGL_NO_SURFACE); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool eglGraphicsPixmap:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -86,10 +78,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { << get_egl_error_string(eglGetError()) << "\n"; } - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) eglgsg->reset_if_new(); if (mode == FM_render) { @@ -110,13 +102,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void eglGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -134,12 +124,9 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::close_buffer -// Access: Protected, Virtual -// Description: Closes the pixmap right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the pixmap right now. Called from the window thread. + */ void eglGraphicsPixmap:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -166,19 +153,16 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsPixmap::open_buffer -// Access: Protected, Virtual -// Description: Opens the pixmap right now. Called from the window -// thread. Returns true if the pixmap is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the pixmap right now. Called from the window thread. Returns true + * if the pixmap is successfully opened, or false if there was a problem. + */ bool eglGraphicsPixmap:: open_buffer() { eglGraphicsPipe *egl_pipe; DCAST_INTO_R(egl_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -186,8 +170,8 @@ open_buffer() { eglgsg->choose_pixel_format(_fb_properties, _display, egl_pipe->get_screen(), false, true); _gsg = eglgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(eglgsg, _gsg, false); if (!eglgsg->get_fb_properties().subsumes(_fb_properties)) { eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, eglgsg); @@ -197,8 +181,8 @@ open_buffer() { } if (eglgsg->_fbconfig == None) { - // If we didn't use an fbconfig to create the GSG, we can't create - // a PBuffer. + // If we didn't use an fbconfig to create the GSG, we can't create a + // PBuffer. return false; } diff --git a/panda/src/egldisplay/eglGraphicsPixmap.h b/panda/src/egldisplay/eglGraphicsPixmap.h index e1ca988965..cbd132c1ac 100644 --- a/panda/src/egldisplay/eglGraphicsPixmap.h +++ b/panda/src/egldisplay/eglGraphicsPixmap.h @@ -1,16 +1,15 @@ -// Filename: eglGraphicsPixmap.h -// Created by: rdb (13Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsPixmap.h + * @author rdb + * @date 2009-06-13 + */ #ifndef EGLGRAPHICSPIXMAP_H #define EGLGRAPHICSPIXMAP_H @@ -20,13 +19,11 @@ #include "eglGraphicsPipe.h" #include "graphicsBuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : eglGraphicsPixmap -// Description : Another offscreen buffer in the EGL environment. This -// creates a Pixmap object, which is probably less -// efficient than an EGLPBuffer, so this class is a -// second choice to eglGraphicsBuffer. -//////////////////////////////////////////////////////////////////// +/** + * Another offscreen buffer in the EGL environment. This creates a Pixmap + * object, which is probably less efficient than an EGLPBuffer, so this class + * is a second choice to eglGraphicsBuffer. + */ class eglGraphicsPixmap : public GraphicsBuffer { public: eglGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.I b/panda/src/egldisplay/eglGraphicsStateGuardian.I index 6af06e2715..28a56a6db6 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.I +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.I @@ -1,26 +1,21 @@ -// Filename: eglGraphicsStateGuardian.I -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsStateGuardian.I + * @author rdb + * @date 2009-05-21 + */ -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::get_fb_properties -// Access: Private -// Description: Gets the FrameBufferProperties for all windows and -// buffers that use this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties for all windows and buffers that use this + * GSG. + */ INLINE const FrameBufferProperties &eglGraphicsStateGuardian:: get_fb_properties() const { return _fbprops; } - - diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx index 7d434a63b5..5168bd575e 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.cxx +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: eglGraphicsStateGuardian.cxx -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsStateGuardian.cxx + * @author rdb + * @date 2009-05-21 + */ #include "eglGraphicsStateGuardian.h" #include "config_egldisplay.h" @@ -20,11 +19,9 @@ TypeHandle eglGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsStateGuardian:: eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, eglGraphicsStateGuardian *share_with) : @@ -49,11 +46,9 @@ eglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsStateGuardian:: ~eglGraphicsStateGuardian() { if (_visuals != (XVisualInfo *)NULL) { @@ -68,12 +63,9 @@ eglGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::get_properties -// Access: Private -// Description: Gets the FrameBufferProperties to match the -// indicated config. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated config. + */ void eglGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, bool &pbuffer_supported, bool &pixmap_supported, @@ -133,13 +125,10 @@ get_properties(FrameBufferProperties &properties, properties.set_force_hardware(1); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::choose_pixel_format -// Access: Private -// Description: Selects a visual or fbconfig for all the windows -// and buffers that use this gsg. Also creates the GL -// context and obtains the visual. -//////////////////////////////////////////////////////////////////// +/** + * Selects a visual or fbconfig for all the windows and buffers that use this + * gsg. Also creates the GL context and obtains the visual. + */ void eglGraphicsStateGuardian:: choose_pixel_format(const FrameBufferProperties &properties, X11_Display *display, @@ -165,7 +154,8 @@ choose_pixel_format(const FrameBufferProperties &properties, EGL_NONE }; - // First get the number of matching configurations, so we know how much memory to allocate. + // First get the number of matching configurations, so we know how much + // memory to allocate. int num_configs = 0, returned_configs; if (!eglChooseConfig(_egl_display, attrib_list, NULL, num_configs, &returned_configs) || returned_configs <= 0) { egldisplay_cat.error() << "eglChooseConfig failed: " @@ -192,8 +182,9 @@ choose_pixel_format(const FrameBufferProperties &properties, bool pbuffer_supported, pixmap_supported, slow; get_properties(fbprops, pbuffer_supported, pixmap_supported, slow, configs[i]); - // We're not protecting this code by an is_debug() check, because if we do, - // some weird compiler bug appears and somehow makes the quality always 0. + // We're not protecting this code by an is_debug() check, because if we + // do, some weird compiler bug appears and somehow makes the quality + // always 0. const char *pbuffertext = pbuffer_supported ? " (pbuffer)" : ""; const char *pixmaptext = pixmap_supported ? " (pixmap)" : ""; const char *slowtext = slow ? " (slow)" : ""; @@ -253,12 +244,9 @@ choose_pixel_format(const FrameBufferProperties &properties, delete[] configs; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void eglGraphicsStateGuardian:: reset() { #ifdef OPENGLES_2 @@ -267,9 +255,8 @@ reset() { GLESGraphicsStateGuardian::reset(); #endif - // If "Mesa" is present, assume software. However, if "Mesa DRI" is - // found, it's actually a Mesa-based OpenGL layer running over a - // hardware driver. + // If "Mesa" is present, assume software. However, if "Mesa DRI" is found, + // it's actually a Mesa-based OpenGL layer running over a hardware driver. if (_gl_renderer.find("Mesa") != string::npos && _gl_renderer.find("Mesa DRI") == string::npos) { // It's Mesa, therefore probably a software context. @@ -281,12 +268,10 @@ reset() { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::egl_is_at_least_version -// Access: Public -// Description: Returns true if the runtime GLX version number is at -// least the indicated value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the runtime GLX version number is at least the indicated + * value, false otherwise. + */ bool eglGraphicsStateGuardian:: egl_is_at_least_version(int major_version, int minor_version) const { if (_egl_version_major < major_version) { @@ -298,11 +283,9 @@ egl_is_at_least_version(int major_version, int minor_version) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::gl_flush -// Access: Protected, Virtual -// Description: Calls glFlush(). -//////////////////////////////////////////////////////////////////// +/** + * Calls glFlush(). + */ void eglGraphicsStateGuardian:: gl_flush() const { // This call requires synchronization with X. @@ -314,11 +297,9 @@ gl_flush() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::gl_get_error -// Access: Protected, Virtual -// Description: Returns the result of glGetError(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the result of glGetError(). + */ GLenum eglGraphicsStateGuardian:: gl_get_error() const { // This call requires synchronization with X. @@ -330,11 +311,9 @@ gl_get_error() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::query_gl_version -// Access: Protected, Virtual -// Description: Queries the runtime version of OpenGL in use. -//////////////////////////////////////////////////////////////////// +/** + * Queries the runtime version of OpenGL in use. + */ void eglGraphicsStateGuardian:: query_gl_version() { #ifdef OPENGLES_2 @@ -343,16 +322,16 @@ query_gl_version() { GLESGraphicsStateGuardian::query_gl_version(); #endif - // Calling eglInitialize on an already-initialized display will - // just provide us the version numbers. + // Calling eglInitialize on an already-initialized display will just provide + // us the version numbers. if (!eglInitialize(_egl_display, &_egl_version_major, &_egl_version_minor)) { egldisplay_cat.error() << "Failed to get EGL version number: " << get_egl_error_string(eglGetError()) << "\n"; } - // We output to glesgsg_cat instead of egldisplay_cat, since this is - // where the GL version has been output, and it's nice to see the - // two of these together. + // We output to glesgsg_cat instead of egldisplay_cat, since this is where + // the GL version has been output, and it's nice to see the two of these + // together. #ifdef OPENGLES_2 if (gles2gsg_cat.is_debug()) { gles2gsg_cat.debug() @@ -365,29 +344,22 @@ query_gl_version() { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::get_extra_extensions -// Access: Protected, Virtual -// Description: This may be redefined by a derived class (e.g. glx or -// wgl) to get whatever further extensions strings may -// be appropriate to that interface, in addition to the -// GL extension strings return by glGetString(). -//////////////////////////////////////////////////////////////////// +/** + * This may be redefined by a derived class (e.g. glx or wgl) to get whatever + * further extensions strings may be appropriate to that interface, in + * addition to the GL extension strings return by glGetString(). + */ void eglGraphicsStateGuardian:: get_extra_extensions() { save_extensions(eglQueryString(_egl_display, EGL_EXTENSIONS)); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *eglGraphicsStateGuardian:: do_get_extension_func(const char *name) { return (void *)eglGetProcAddress(name); diff --git a/panda/src/egldisplay/eglGraphicsStateGuardian.h b/panda/src/egldisplay/eglGraphicsStateGuardian.h index ebf00b87e9..ab47d7adf1 100644 --- a/panda/src/egldisplay/eglGraphicsStateGuardian.h +++ b/panda/src/egldisplay/eglGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: eglGraphicsStateGuardian.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsStateGuardian.h + * @author rdb + * @date 2009-05-21 + */ #ifndef EGLGRAPHICSSTATEGUARDIAN_H #define EGLGRAPHICSSTATEGUARDIAN_H @@ -19,11 +18,10 @@ #include "eglGraphicsPipe.h" #include "get_x11.h" -//////////////////////////////////////////////////////////////////// -// Class : eglGraphicsStateGuardian -// Description : A tiny specialization on GLESGraphicsStateGuardian -// to add some egl-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLESGraphicsStateGuardian to add some egl-specific + * information. + */ #ifdef OPENGLES_2 class eglGraphicsStateGuardian : public GLES2GraphicsStateGuardian { #else diff --git a/panda/src/egldisplay/eglGraphicsWindow.I b/panda/src/egldisplay/eglGraphicsWindow.I index a77400a6c2..0f3a6bb472 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.I +++ b/panda/src/egldisplay/eglGraphicsWindow.I @@ -1,23 +1,19 @@ -// Filename: eglGraphicsWindow.I -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsWindow.I + * @author rdb + * @date 2009-05-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::get_xwindow -// Access: Public -// Description: Returns the X11 Window handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X11 Window handle. + */ INLINE X11_Window eglGraphicsWindow:: get_xwindow() const { return _xwindow; diff --git a/panda/src/egldisplay/eglGraphicsWindow.cxx b/panda/src/egldisplay/eglGraphicsWindow.cxx index 7ef3efb80e..7299815739 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.cxx +++ b/panda/src/egldisplay/eglGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: eglGraphicsWindow.cxx -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsWindow.cxx + * @author rdb + * @date 2009-05-21 + */ #include "eglGraphicsWindow.h" #include "eglGraphicsStateGuardian.h" @@ -39,11 +38,9 @@ TypeHandle eglGraphicsWindow::_type_handle; #define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)&7))) -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsWindow:: eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -79,25 +76,21 @@ eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, add_input_device(device); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ eglGraphicsWindow:: ~eglGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool eglGraphicsWindow:: move_pointer(int device, int x, int y) { // Note: this is not thread-safe; it should be called only from App. @@ -106,8 +99,8 @@ move_pointer(int device, int x, int y) { // Move the system mouse pointer. if (!_properties.get_foreground() || !_input_devices[0].get_pointer().get_in_window()) { - // If the window doesn't have input focus, or the mouse isn't - // currently within the window, forget it. + // If the window doesn't have input focus, or the mouse isn't currently + // within the window, forget it. return false; } @@ -128,15 +121,12 @@ move_pointer(int device, int x, int y) { } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool eglGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -146,8 +136,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } if (_awaiting_configure) { - // Don't attempt to draw while we have just reconfigured the - // window and we haven't got the notification back yet. + // Don't attempt to draw while we have just reconfigured the window and we + // haven't got the notification back yet. return false; } @@ -160,8 +150,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { eglGetCurrentSurface(EGL_READ) == _egl_surface && eglGetCurrentSurface(EGL_DRAW) == _egl_surface && eglGetCurrentContext() == eglgsg->_context) { - // No need to make the context current again. Short-circuit - // this possibly-expensive call. + // No need to make the context current again. Short-circuit this + // possibly-expensive call. } else { // Need to set the context. if (!eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, eglgsg->_context)) { @@ -171,10 +161,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { } } - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) eglgsg->reset_if_new(); if (mode == FM_render) { @@ -186,13 +176,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void eglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -211,25 +199,22 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void eglGraphicsWindow:: end_flip() { if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { - // It doesn't appear to be necessary to ensure the graphics - // context is current before flipping the windows, and insisting - // on doing so can be a significant performance hit. + // It doesn't appear to be necessary to ensure the graphics context is + // current before flipping the windows, and insisting on doing so can be a + // significant performance hit. - //make_current(); + // make_current(); LightReMutexHolder holder(eglGraphicsPipe::_x_mutex); eglSwapBuffers(_egl_display, _egl_surface); @@ -237,16 +222,13 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void eglGraphicsWindow:: process_events() { LightReMutexHolder holder(eglGraphicsPipe::_x_mutex); @@ -269,28 +251,27 @@ process_events() { } if (got_keyrelease_event) { - // If a keyrelease event is immediately followed by a matching - // keypress event, that's just key repeat and we should treat - // the two events accordingly. It would be nice if X provided a - // way to differentiate between keyrepeat and explicit - // keypresses more generally. + // If a keyrelease event is immediately followed by a matching keypress + // event, that's just key repeat and we should treat the two events + // accordingly. It would be nice if X provided a way to differentiate + // between keyrepeat and explicit keypresses more generally. got_keyrelease_event = false; if (event.type == KeyPress && event.xkey.keycode == keyrelease_event.keycode && (event.xkey.time - keyrelease_event.time <= 1)) { - // In particular, we only generate down messages for the - // repeated keys, not down-and-up messages. + // In particular, we only generate down messages for the repeated + // keys, not down-and-up messages. handle_keystroke(event.xkey); - // We thought about not generating the keypress event, but we - // need that repeat for backspace. Rethink later. + // We thought about not generating the keypress event, but we need + // that repeat for backspace. Rethink later. handle_keypress(event.xkey); continue; } else { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } @@ -305,12 +286,11 @@ process_events() { case ConfigureNotify: _awaiting_configure = false; if (_properties.get_fixed_size()) { - // If the window properties indicate a fixed size only, undo - // any attempt by the user to change them. In X, there - // doesn't appear to be a way to universally disallow this - // directly (although we do set the min_size and max_size to - // the same value, which seems to work for most window - // managers.) + // If the window properties indicate a fixed size only, undo any + // attempt by the user to change them. In X, there doesn't appear to + // be a way to universally disallow this directly (although we do set + // the min_size and max_size to the same value, which seems to work + // for most window managers.) WindowProperties current_props = get_properties(); if (event.xconfigure.width != current_props.get_x_size() || event.xconfigure.height != current_props.get_y_size()) { @@ -351,9 +331,9 @@ process_events() { break; case KeyRelease: - // The KeyRelease can't be processed immediately, because we - // have to check first if it's immediately followed by a - // matching KeyPress event. + // The KeyRelease can't be processed immediately, because we have to + // check first if it's immediately followed by a matching KeyPress + // event. keyrelease_event = event.xkey; got_keyrelease_event = true; break; @@ -391,17 +371,17 @@ process_events() { case ClientMessage: if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) { - // This is a message from the window manager indicating that - // the user has requested to close the window. + // This is a message from the window manager indicating that the user + // has requested to close the window. string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept - // the request and process it directly. + // In this case, the app has indicated a desire to intercept the + // request and process it directly. throw_event(close_request_event); } else { - // In this case, the default case, the app does not intend - // to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to + // service the request, so we do by closing the window. // TODO: don't release the gsg in the window thread. close_window(); @@ -412,9 +392,8 @@ process_events() { break; case DestroyNotify: - // Apparently, we never get a DestroyNotify on a toplevel - // window. Instead, we rely on hints from the window manager - // (see above). + // Apparently, we never get a DestroyNotify on a toplevel window. + // Instead, we rely on hints from the window manager (see above). egldisplay_cat.info() << "DestroyNotify\n"; break; @@ -426,29 +405,24 @@ process_events() { } if (got_keyrelease_event) { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The return value is true if the properties are set, -// false if they are ignored. This is mainly useful for -// derived classes to implement extensions to this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The return value is true if the properties are set, false if they are + * ignored. This is mainly useful for derived classes to implement extensions + * to this function. + */ void eglGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (_pipe == (GraphicsPipe *)NULL) { @@ -461,10 +435,9 @@ set_properties_now(WindowProperties &properties) { DCAST_INTO_V(egl_pipe, _pipe); // Fullscreen mode is implemented with a hint to the window manager. - // However, we also implicitly set the origin to (0, 0) and the size - // to the desktop size, and request undecorated mode, in case the - // user has a less-capable window manager (or no window manager at - // all). + // However, we also implicitly set the origin to (0, 0) and the size to the + // desktop size, and request undecorated mode, in case the user has a less- + // capable window manager (or no window manager at all). if (properties.get_fullscreen()) { properties.set_undecorated(true); properties.set_origin(0, 0); @@ -478,15 +451,15 @@ set_properties_now(WindowProperties &properties) { return; } - // The window is already open; we are limited to what we can change - // on the fly. + // The window is already open; we are limited to what we can change on the + // fly. // We'll pass some property requests on as a window manager hint. WindowProperties wm_properties = _properties; wm_properties.add_properties(properties); - // The window title may be changed by issuing another hint request. - // Assume this will be honored. + // The window title may be changed by issuing another hint request. Assume + // this will be honored. if (properties.has_title()) { _properties.set_title(properties.get_title()); properties.clear_title(); @@ -498,10 +471,10 @@ set_properties_now(WindowProperties &properties) { properties.clear_fullscreen(); } - // The size and position of an already-open window are changed via - // explicit X calls. These may still get intercepted by the window - // manager. Rather than changing _properties immediately, we'll - // wait for the ConfigureNotify message to come back. + // The size and position of an already-open window are changed via explicit + // X calls. These may still get intercepted by the window manager. Rather + // than changing _properties immediately, we'll wait for the ConfigureNotify + // message to come back. XWindowChanges changes; int value_mask = 0; @@ -518,10 +491,9 @@ set_properties_now(WindowProperties &properties) { properties.clear_size(); } if (properties.has_z_order()) { - // We'll send the classic stacking request through the standard - // interface, for users of primitive window managers; but we'll - // also send it as a window manager hint, for users of modern - // window managers. + // We'll send the classic stacking request through the standard interface, + // for users of primitive window managers; but we'll also send it as a + // window manager hint, for users of modern window managers. _properties.set_z_order(properties.get_z_order()); switch (properties.get_z_order()) { case WindowProperties::Z_bottom: @@ -571,12 +543,9 @@ set_properties_now(WindowProperties &properties) { set_wm_properties(wm_properties, true); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void eglGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -610,19 +579,16 @@ close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool eglGraphicsWindow:: open_window() { eglGraphicsPipe *egl_pipe; DCAST_INTO_R(egl_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization eglGraphicsStateGuardian *eglgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -630,8 +596,8 @@ open_window() { eglgsg->choose_pixel_format(_fb_properties, egl_pipe->get_display(), egl_pipe->get_screen(), false, false); _gsg = eglgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(eglgsg, _gsg, false); if (!eglgsg->get_fb_properties().subsumes(_fb_properties)) { eglgsg = new eglGraphicsStateGuardian(_engine, _pipe, eglgsg); @@ -656,7 +622,7 @@ open_window() { if (!_properties.has_size()) { _properties.set_size(100, 100); } - + X11_Window parent_window = egl_pipe->get_root(); WindowHandle *window_handle = _properties.get_parent_window(); if (window_handle != NULL) { @@ -666,7 +632,7 @@ open_window() { if (os_handle != NULL) { egldisplay_cat.info() << "os_handle type " << os_handle->get_type() << "\n"; - + if (os_handle->is_of_type(NativeWindowHandle::X11Handle::get_class_type())) { NativeWindowHandle::X11Handle *x11_handle = DCAST(NativeWindowHandle::X11Handle, os_handle); parent_window = x11_handle->get_handle(); @@ -711,10 +677,10 @@ open_window() { } set_wm_properties(_properties, false); - // We don't specify any fancy properties of the XIC. It would be - // nicer if we could support fancy IM's that want preedit callbacks, - // etc., but that can wait until we have an X server that actually - // supports these to test it on. + // We don't specify any fancy properties of the XIC. It would be nicer if + // we could support fancy IM's that want preedit callbacks, etc., but that + // can wait until we have an X server that actually supports these to test + // it on. XIM im = egl_pipe->get_im(); _ic = NULL; if (im) { @@ -777,19 +743,16 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::set_wm_properties -// Access: Private -// Description: Asks the window manager to set the appropriate -// properties. In X, these properties cannot be -// specified directly by the application; they must be -// requested via the window manager, which may or may -// not choose to honor the request. -// -// If already_mapped is true, the window has already -// been mapped (manifested) on the display. This means -// we may need to use a different action in some cases. -//////////////////////////////////////////////////////////////////// +/** + * Asks the window manager to set the appropriate properties. In X, these + * properties cannot be specified directly by the application; they must be + * requested via the window manager, which may or may not choose to honor the + * request. + * + * If already_mapped is true, the window has already been mapped (manifested) + * on the display. This means we may need to use a different action in some + * cases. + */ void eglGraphicsWindow:: set_wm_properties(const WindowProperties &properties, bool already_mapped) { // Name the window if there is a name @@ -802,8 +765,8 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } } - // The size hints request a window of a particular size and/or a - // particular placement onscreen. + // The size hints request a window of a particular size andor a particular + // placement onscreen. XSizeHints *size_hints_p = NULL; if (properties.has_origin() || properties.has_size()) { size_hints_p = XAllocSizeHints(); @@ -829,8 +792,8 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } } - // The window manager hints include requests to the window manager - // other than those specific to window geometry. + // The window manager hints include requests to the window manager other + // than those specific to window geometry. XWMHints *wm_hints_p = NULL; wm_hints_p = XAllocWMHints(); if (wm_hints_p != (XWMHints *)NULL) { @@ -842,9 +805,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { wm_hints_p->flags = StateHint; } - // Two competing window manager interfaces have evolved. One of - // them allows to set certain properties as a "type"; the other one - // as a "state". We'll try to honor both. + // Two competing window manager interfaces have evolved. One of them allows + // to set certain properties as a "type"; the other one as a "state". We'll + // try to honor both. static const int max_type_data = 32; PN_int32 type_data[max_type_data]; int next_type_data = 0; @@ -865,8 +828,8 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { int next_set_data = 0; if (properties.get_fullscreen()) { - // For a "fullscreen" request, we pass this through, hoping the - // window manager will support EWMH. + // For a "fullscreen" request, we pass this through, hoping the window + // manager will support EWMH. type_data[next_type_data++] = _net_wm_window_type_fullscreen; // We also request it as a state. @@ -876,15 +839,15 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { set_data[next_set_data++] = SetAction(_net_wm_state_fullscreen, _net_wm_state_remove); } - // If we asked for a window without a border, there's no excellent - // way to arrange that. For users whose window managers follow the - // EWMH specification, we can ask for a "splash" screen, which is - // usually undecorated. It's not exactly right, but the spec - // doesn't give us an exactly-right option. + // If we asked for a window without a border, there's no excellent way to + // arrange that. For users whose window managers follow the EWMH + // specification, we can ask for a "splash" screen, which is usually + // undecorated. It's not exactly right, but the spec doesn't give us an + // exactly-right option. - // For other users, we'll totally punt and just set the window's - // Class to "Undecorated", and let the user configure his/her window - // manager not to put a border around windows of this class. + // For other users, we'll totally punt and just set the window's Class to + // "Undecorated", and let the user configure hisher window manager not to + // put a border around windows of this class. XClassHint *class_hints_p = NULL; if (properties.get_undecorated()) { class_hints_p = XAllocClassHint(); @@ -930,9 +893,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { (unsigned char *)state_data, next_state_data); if (already_mapped) { - // We have to request state changes differently when the window - // has been mapped. To do this, we need to send a client message - // to the root window for each change. + // We have to request state changes differently when the window has been + // mapped. To do this, we need to send a client message to the root + // window for each change. eglGraphicsPipe *egl_pipe; DCAST_INTO_V(egl_pipe, _pipe); @@ -969,10 +932,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { XFree(class_hints_p); } - // Also, indicate to the window manager that we'd like to get a - // chance to close our windows cleanly, rather than being rudely - // disconnected from the X server if the user requests a window - // close. + // Also, indicate to the window manager that we'd like to get a chance to + // close our windows cleanly, rather than being rudely disconnected from the + // X server if the user requests a window close. Atom protocols[] = { _wm_delete_window, }; @@ -981,12 +943,10 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { sizeof(protocols) / sizeof(Atom)); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::setup_colormap -// Access: Private -// Description: Allocates a colormap appropriate to the visual and -// stores in in the _colormap method. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a colormap appropriate to the visual and stores in in the + * _colormap method. + */ void eglGraphicsWindow:: setup_colormap(XVisualInfo *visual) { eglGraphicsPipe *egl_pipe; @@ -1020,11 +980,9 @@ setup_colormap(XVisualInfo *visual) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::open_raw_mice -// Access: Private -// Description: Adds raw mice to the _input_devices list. -//////////////////////////////////////////////////////////////////// +/** + * Adds raw mice to the _input_devices list. + */ void eglGraphicsWindow:: open_raw_mice() { @@ -1102,11 +1060,9 @@ open_raw_mice() #endif } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::poll_raw_mice -// Access: Private -// Description: Reads events from the raw mouse device files. -//////////////////////////////////////////////////////////////////// +/** + * Reads events from the raw mouse device files. + */ void eglGraphicsWindow:: poll_raw_mice() { @@ -1166,12 +1122,9 @@ poll_raw_mice() #endif } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::handle_keystroke -// Access: Private -// Description: Generates a keystroke corresponding to the indicated -// X KeyPress event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keystroke corresponding to the indicated X KeyPress event. + */ void eglGraphicsWindow:: handle_keystroke(XKeyEvent &event) { _input_devices[0].set_pointer_in_window(event.x, event.y); @@ -1188,8 +1141,7 @@ handle_keystroke(XKeyEvent &event) { << "Overflowed input buffer.\n"; } - // Now each of the returned wide characters represents a - // keystroke. + // Now each of the returned wide characters represents a keystroke. for (int i = 0; i < len; i++) { _input_devices[0].keystroke(buffer[i]); } @@ -1203,12 +1155,9 @@ handle_keystroke(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::handle_keypress -// Access: Private -// Description: Generates a keypress corresponding to the indicated -// X KeyPress event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keypress corresponding to the indicated X KeyPress event. + */ void eglGraphicsWindow:: handle_keypress(XKeyEvent &event) { _input_devices[0].set_pointer_in_window(event.x, event.y); @@ -1232,12 +1181,9 @@ handle_keypress(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::handle_keyrelease -// Access: Private -// Description: Generates a keyrelease corresponding to the indicated -// X KeyRelease event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keyrelease corresponding to the indicated X KeyRelease event. + */ void eglGraphicsWindow:: handle_keyrelease(XKeyEvent &event) { _input_devices[0].set_pointer_in_window(event.x, event.y); @@ -1261,20 +1207,18 @@ handle_keyrelease(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::get_button -// Access: Private -// Description: Returns the Panda ButtonHandle corresponding to the -// keyboard button indicated by the given key event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda ButtonHandle corresponding to the keyboard button + * indicated by the given key event. + */ ButtonHandle eglGraphicsWindow:: get_button(XKeyEvent &key_event, bool allow_shift) { KeySym key = XLookupKeysym(&key_event, 0); if ((key_event.state & Mod2Mask) != 0) { - // Mod2Mask corresponds to NumLock being in effect. In this case, - // we want to get the alternate keysym associated with any keypad - // keys. Weird system. + // Mod2Mask corresponds to NumLock being in effect. In this case, we want + // to get the alternate keysym associated with any keypad keys. Weird + // system. KeySym k2; ButtonHandle button; switch (key) { @@ -1317,8 +1261,8 @@ get_button(XKeyEvent &key_event, bool allow_shift) { if (button != ButtonHandle::none()) { return button; } - // If that didn't produce a button we know, just fall through - // and handle the normal, un-numlocked key. + // If that didn't produce a button we know, just fall through and handle + // the normal, un-numlocked key. break; default: @@ -1336,9 +1280,9 @@ get_button(XKeyEvent &key_event, bool allow_shift) { } } - // If caps lock is down, shift lowercase letters to uppercase. We - // can do this in just the ASCII set, because we handle - // international keyboards elsewhere (via an input context). + // If caps lock is down, shift lowercase letters to uppercase. We can do + // this in just the ASCII set, because we handle international keyboards + // elsewhere (via an input context). if ((key_event.state & (ShiftMask | LockMask)) != 0) { if (key >= XK_a and key <= XK_z) { key += (XK_A - XK_a); @@ -1349,12 +1293,10 @@ get_button(XKeyEvent &key_event, bool allow_shift) { return map_button(key); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::map_button -// Access: Private -// Description: Maps from a single X keysym to Panda's ButtonHandle. -// Called by get_button(), above. -//////////////////////////////////////////////////////////////////// +/** + * Maps from a single X keysym to Panda's ButtonHandle. Called by + * get_button(), above. + */ ButtonHandle eglGraphicsWindow:: map_button(KeySym key) { switch (key) { @@ -1669,12 +1611,10 @@ map_button(KeySym key) { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::get_mouse_button -// Access: Private -// Description: Returns the Panda ButtonHandle corresponding to the -// mouse button indicated by the given button event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda ButtonHandle corresponding to the mouse button indicated + * by the given button event. + */ ButtonHandle eglGraphicsWindow:: get_mouse_button(XButtonEvent &button_event) { int index = button_event.button; @@ -1690,14 +1630,10 @@ get_mouse_button(XButtonEvent &button_event) { return MouseButton::button(index - 1); } } -//////////////////////////////////////////////////////////////////// -// Function: eglGraphicsWindow::check_event -// Access: Private, Static -// Description: This function is used as a predicate to -// XCheckIfEvent() to determine if the indicated queued -// X event is relevant and should be returned to this -// window. -//////////////////////////////////////////////////////////////////// +/** + * This function is used as a predicate to XCheckIfEvent() to determine if the + * indicated queued X event is relevant and should be returned to this window. + */ Bool eglGraphicsWindow:: check_event(X11_Display *display, XEvent *event, char *arg) { const eglGraphicsWindow *self = (eglGraphicsWindow *)arg; diff --git a/panda/src/egldisplay/eglGraphicsWindow.h b/panda/src/egldisplay/eglGraphicsWindow.h index d35131cc04..4a17920791 100644 --- a/panda/src/egldisplay/eglGraphicsWindow.h +++ b/panda/src/egldisplay/eglGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: eglGraphicsWindow.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eglGraphicsWindow.h + * @author rdb + * @date 2009-05-21 + */ #ifndef EGLGRAPHICSWINDOW_H #define EGLGRAPHICSWINDOW_H @@ -22,11 +21,9 @@ #include "buttonHandle.h" #include "get_x11.h" -//////////////////////////////////////////////////////////////////// -// Class : eglGraphicsWindow -// Description : An interface to the egl system for managing GLES -// windows under X. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the egl system for managing GLES windows under X. + */ class eglGraphicsWindow : public GraphicsWindow { public: eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/event/asyncTask.I b/panda/src/event/asyncTask.I index cc1d52fe78..ae411d3d7c 100644 --- a/panda/src/event/asyncTask.I +++ b/panda/src/event/asyncTask.I @@ -1,38 +1,31 @@ -// Filename: asyncTask.I -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTask.I + * @author drose + * @date 2006-08-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_state -// Access: Published -// Description: Returns the current state of the task. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the task. + */ INLINE AsyncTask::State AsyncTask:: get_state() const { return _state; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::is_alive -// Access: Published -// Description: Returns true if the task is currently active or -// sleeping on some task chain, meaning that it will be -// executed in its turn, or false if it is not active. -// If the task has recently been removed while it is in -// the middle of execution, this will return false, -// because the task will not run again once it finishes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the task is currently active or sleeping on some task + * chain, meaning that it will be executed in its turn, or false if it is not + * active. If the task has recently been removed while it is in the middle of + * execution, this will return false, because the task will not run again once + * it finishes. + */ INLINE bool AsyncTask:: is_alive() const { switch (_state) { @@ -51,219 +44,173 @@ is_alive() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_manager -// Access: Published -// Description: Returns the AsyncTaskManager that this task is active -// on. This will be NULL if the state is S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AsyncTaskManager that this task is active on. This will be + * NULL if the state is S_inactive. + */ INLINE AsyncTaskManager *AsyncTask:: get_manager() const { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_delay -// Access: Published -// Description: Specifies the amount of time, in seconds, by which -// this task will be delayed after it has been added to -// the AsyncTaskManager. At least the specified amount -// of time (and possibly more) will elapse before the -// task begins. -// -// You may specify a delay of 0.0 to guarantee that the -// task will run in the next epoch following the one in -// which it is added. -// -// Setting this value after the task has already been -// added will not affect the task's wake time; it will -// only affect the task if it is re-added to the queue -// in the future, for instance if the task returns -// DS_again. However, see recalc_wake_time() if you wish -// to apply the delay effect immediately. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the amount of time, in seconds, by which this task will be + * delayed after it has been added to the AsyncTaskManager. At least the + * specified amount of time (and possibly more) will elapse before the task + * begins. + * + * You may specify a delay of 0.0 to guarantee that the task will run in the + * next epoch following the one in which it is added. + * + * Setting this value after the task has already been added will not affect + * the task's wake time; it will only affect the task if it is re-added to the + * queue in the future, for instance if the task returns DS_again. However, + * see recalc_wake_time() if you wish to apply the delay effect immediately. + */ INLINE void AsyncTask:: set_delay(double delay) { _delay = delay; _has_delay = true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::clear_delay -// Access: Published -// Description: Removes any delay specified for the task. The next -// time the task is added to the queue, it will run -// immediately. This does not affect the task's wake -// time if it has already been added to the queue. -//////////////////////////////////////////////////////////////////// +/** + * Removes any delay specified for the task. The next time the task is added + * to the queue, it will run immediately. This does not affect the task's + * wake time if it has already been added to the queue. + */ INLINE void AsyncTask:: clear_delay() { _delay = 0.0; _has_delay = false; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::has_delay -// Access: Published -// Description: Returns true if a delay has been set for this task -// via set_delay(), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a delay has been set for this task via set_delay(), or + * false otherwise. + */ INLINE bool AsyncTask:: has_delay() const { return _has_delay; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_delay -// Access: Published -// Description: Returns the delay value that has been set via -// set_delay, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the delay value that has been set via set_delay, if any. + */ INLINE double AsyncTask:: get_delay() const { return _delay; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_start_time -// Access: Published -// Description: Returns the time at which the task was started, -// according to the task manager's clock. -// -// It is only valid to call this if the task's status is -// not S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time at which the task was started, according to the task + * manager's clock. + * + * It is only valid to call this if the task's status is not S_inactive. + */ INLINE double AsyncTask:: get_start_time() const { nassertr(_state != S_inactive, 0.0); return _start_time; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_start_frame -// Access: Published -// Description: Returns the frame number at which the task was -// started, according to the task manager's clock. -// -// It is only valid to call this if the task's status is -// not S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame number at which the task was started, according to the + * task manager's clock. + * + * It is only valid to call this if the task's status is not S_inactive. + */ INLINE int AsyncTask:: get_start_frame() const { nassertr(_state != S_inactive, 0); return _start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::clear_name -// Access: Public -// Description: Resets the task's name to empty. -//////////////////////////////////////////////////////////////////// +/** + * Resets the task's name to empty. + */ INLINE void AsyncTask:: clear_name() { set_name(string()); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_task_id -// Access: Public -// Description: Returns a number guaranteed to be unique for each -// different AsyncTask object in the universe. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number guaranteed to be unique for each different AsyncTask + * object in the universe. + */ INLINE AtomicAdjust::Integer AsyncTask:: get_task_id() const { return _task_id; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_task_chain -// Access: Published -// Description: Returns the AsyncTaskChain on which this task will -// be running. Each task chain runs tasks independently -// of the others. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AsyncTaskChain on which this task will be running. Each task + * chain runs tasks independently of the others. + */ INLINE const string &AsyncTask:: get_task_chain() const { return _chain_name; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_sort -// Access: Published -// Description: Returns the task's current sort value. See -// set_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the task's current sort value. See set_sort(). + */ INLINE int AsyncTask:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_priority -// Access: Published -// Description: Returns the task's current priority value. See -// set_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the task's current priority value. See set_priority(). + */ INLINE int AsyncTask:: get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_done_event -// Access: Published -// Description: Sets the event name that will be triggered -// when the task finishes. This should only be called -// before the task has been started, or after it has -// finished and before it is about to be restarted -// (i.e. when get_state() returns S_inactive). -//////////////////////////////////////////////////////////////////// +/** + * Sets the event name that will be triggered when the task finishes. This + * should only be called before the task has been started, or after it has + * finished and before it is about to be restarted (i.e. when get_state() + * returns S_inactive). + */ INLINE void AsyncTask:: set_done_event(const string &done_event) { nassertv(_state == S_inactive); _done_event = done_event; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_done_event -// Access: Published -// Description: Returns the event name that will be triggered -// when the task finishes. See set_done_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be triggered when the task finishes. See + * set_done_event(). + */ INLINE const string &AsyncTask:: get_done_event() const { return _done_event; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_dt -// Access: Published -// Description: Returns the amount of time elapsed during the task's -// previous run cycle, in seconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time elapsed during the task's previous run cycle, in + * seconds. + */ INLINE double AsyncTask:: get_dt() const { return _dt; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_max_dt -// Access: Published -// Description: Returns the maximum amount of time elapsed during any -// one of the task's previous run cycles, in seconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum amount of time elapsed during any one of the task's + * previous run cycles, in seconds. + */ INLINE double AsyncTask:: get_max_dt() const { return _max_dt; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_average_dt -// Access: Published -// Description: Returns the average amount of time elapsed during -// each of the task's previous run cycles, in seconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average amount of time elapsed during each of the task's + * previous run cycles, in seconds. + */ INLINE double AsyncTask:: get_average_dt() const { if (_num_frames == 0) { diff --git a/panda/src/event/asyncTask.cxx b/panda/src/event/asyncTask.cxx index 3d10445475..2a83740b52 100644 --- a/panda/src/event/asyncTask.cxx +++ b/panda/src/event/asyncTask.cxx @@ -1,16 +1,15 @@ -// Filename: asyncTask.cxx -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTask.cxx + * @author drose + * @date 2006-08-23 + */ #include "asyncTask.h" #include "asyncTaskManager.h" @@ -27,13 +26,11 @@ AtomicAdjust::Integer AsyncTask::_next_task_id; PStatCollector AsyncTask::_show_code_pcollector("App:Show code"); TypeHandle AsyncTask::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTask:: -AsyncTask(const string &name) : +AsyncTask(const string &name) : _chain_name("default"), _delay(0.0), _has_delay(false), @@ -56,8 +53,7 @@ AsyncTask(const string &name) : #endif // HAVE_PYTHON set_name(name); - // Carefully copy _next_task_id and increment it so that we get a - // unique ID. + // Carefully copy _next_task_id and increment it so that we get a unique ID. AtomicAdjust::Integer current_id = _next_task_id; while (AtomicAdjust::compare_and_exchange(_next_task_id, current_id, current_id + 1) != current_id) { current_id = _next_task_id; @@ -66,11 +62,9 @@ AsyncTask(const string &name) : _task_id = current_id; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTask:: ~AsyncTask() { nassertv(_state == S_inactive && _manager == NULL && _chain == NULL); @@ -79,14 +73,11 @@ AsyncTask:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::remove -// Access: Published -// Description: Removes the task from its active manager, if any, and -// makes the state S_inactive (or possible -// S_servicing_removed). This is a no-op if the state -// is already S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Removes the task from its active manager, if any, and makes the state + * S_inactive (or possible S_servicing_removed). This is a no-op if the state + * is already S_inactive. + */ void AsyncTask:: remove() { if (_manager != (AsyncTaskManager *)NULL) { @@ -94,19 +85,14 @@ remove() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_wake_time -// Access: Published -// Description: If this task has been added to an AsyncTaskManager -// with a delay in effect, this returns the time at -// which the task is expected to awaken. It has no -// meaning if the task has not yet been added to a -// queue, or if there was no delay in effect at the time -// the task was added. -// -// If the task's status is not S_sleeping, this returns -// 0.0. -//////////////////////////////////////////////////////////////////// +/** + * If this task has been added to an AsyncTaskManager with a delay in effect, + * this returns the time at which the task is expected to awaken. It has no + * meaning if the task has not yet been added to a queue, or if there was no + * delay in effect at the time the task was added. + * + * If the task's status is not S_sleeping, this returns 0.0. + */ double AsyncTask:: get_wake_time() const { if (_manager != (AsyncTaskManager *)NULL) { @@ -116,25 +102,19 @@ get_wake_time() const { } } - // If it's not on any manager, or it's not sleeping, the wake time - // is 0.0. + // If it's not on any manager, or it's not sleeping, the wake time is 0.0. return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::recalc_wake_time -// Access: Published -// Description: If the task is currently sleeping on a task -// chain, this resets its wake time to the current time -// + get_delay(). It is as if the task had suddenly -// returned DS_again. The task will sleep for its -// current delay seconds before running again. This -// method may therefore be used to make the task wake up -// sooner or later than it would have otherwise. -// -// If the task is not already sleeping, this method has -// no effect. -//////////////////////////////////////////////////////////////////// +/** + * If the task is currently sleeping on a task chain, this resets its wake + * time to the current time + get_delay(). It is as if the task had suddenly + * returned DS_again. The task will sleep for its current delay seconds + * before running again. This method may therefore be used to make the task + * wake up sooner or later than it would have otherwise. + * + * If the task is not already sleeping, this method has no effect. + */ void AsyncTask:: recalc_wake_time() { if (_manager != (AsyncTaskManager *)NULL) { @@ -144,22 +124,18 @@ recalc_wake_time() { _wake_time = now + _delay; _start_time = _wake_time; - make_heap(_chain->_sleeping.begin(), _chain->_sleeping.end(), + make_heap(_chain->_sleeping.begin(), _chain->_sleeping.end(), AsyncTaskChain::AsyncTaskSortWakeTime()); } } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_elapsed_time -// Access: Published -// Description: Returns the amount of time that has elapsed since -// the task was started, according to the task manager's -// clock. -// -// It is only valid to call this if the task's status is -// not S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time that has elapsed since the task was started, + * according to the task manager's clock. + * + * It is only valid to call this if the task's status is not S_inactive. + */ double AsyncTask:: get_elapsed_time() const { nassertr(_state != S_inactive, 0.0); @@ -167,16 +143,12 @@ get_elapsed_time() const { return _manager->_clock->get_frame_time() - _start_time; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_elapsed_frames -// Access: Published -// Description: Returns the number of frames that have elapsed since -// the task was started, according to the task manager's -// clock. -// -// It is only valid to call this if the task's status is -// not S_inactive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames that have elapsed since the task was started, + * according to the task manager's clock. + * + * It is only valid to call this if the task's status is not S_inactive. + */ int AsyncTask:: get_elapsed_frames() const { nassertr(_state != S_inactive, 0); @@ -184,43 +156,39 @@ get_elapsed_frames() const { return _manager->_clock->get_frame_count() - _start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTask:: set_name(const string &name) { if (_manager != (AsyncTaskManager *)NULL) { MutexHolder holder(_manager->_lock); if (Namable::get_name() != name) { - // Changing an active task's name requires moving it around on - // its name index. + // Changing an active task's name requires moving it around on its name + // index. _manager->remove_task_by_name(this); Namable::set_name(name); _manager->add_task_by_name(this); } } else { - // If it hasn't been started anywhere, we can just change the - // name. + // If it hasn't been started anywhere, we can just change the name. Namable::set_name(name); } #ifdef DO_PSTATS - // Update the PStatCollector with the new name. If the name - // includes a colon, we stop the collector name there, and don't go - // further. + // Update the PStatCollector with the new name. If the name includes a + // colon, we stop the collector name there, and don't go further. size_t end = name.size(); size_t colon = name.find(':'); if (colon != string::npos) { end = min(end, colon); } - // If the name ends with a hyphen followed by a string of digits, we - // strip all that off, for the parent collector, to group related - // tasks together in the pstats graph. We still create a child - // collector that contains the full name, however. + // If the name ends with a hyphen followed by a string of digits, we strip + // all that off, for the parent collector, to group related tasks together + // in the pstats graph. We still create a child collector that contains the + // full name, however. size_t trimmed = end; size_t p = trimmed; while (true) { @@ -236,19 +204,16 @@ set_name(const string &name) { } } PStatCollector parent(_show_code_pcollector, name.substr(0, trimmed)); - // prevent memory leak - //_task_pcollector = PStatCollector(parent, name.substr(0, end)); + // prevent memory leak _task_pcollector = PStatCollector(parent, + // name.substr(0, end)); _task_pcollector = parent; #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_name_prefix -// Access: Published -// Description: Returns the initial part of the name, up to but not -// including any trailing digits following a hyphen or -// underscore. -//////////////////////////////////////////////////////////////////// +/** + * Returns the initial part of the name, up to but not including any trailing + * digits following a hyphen or underscore. + */ string AsyncTask:: get_name_prefix() const { string name = get_name(); @@ -270,21 +235,18 @@ get_name_prefix() const { return name.substr(0, trimmed); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_task_chain -// Access: Published -// Description: Specifies the AsyncTaskChain on which this task will -// be running. Each task chain runs tasks independently -// of the others. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the AsyncTaskChain on which this task will be running. Each task + * chain runs tasks independently of the others. + */ void AsyncTask:: set_task_chain(const string &chain_name) { if (chain_name != _chain_name) { if (_manager != (AsyncTaskManager *)NULL) { MutexHolder holder(_manager->_lock); if (_state == S_active) { - // Changing chains on an "active" (i.e. enqueued) task means - // removing it and re-inserting it into the queue. + // Changing chains on an "active" (i.e. enqueued) task means removing + // it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; PT(AsyncTaskManager) manager = _manager; @@ -296,42 +258,38 @@ set_task_chain(const string &chain_name) { jump_to_task_chain(manager); } else { - // If it's sleeping, currently being serviced, or something - // else, we can just change the chain_name value directly. + // If it's sleeping, currently being serviced, or something else, we + // can just change the chain_name value directly. _chain_name = chain_name; } } else { - // If it hasn't been started anywhere, we can just change the - // chain_name value. + // If it hasn't been started anywhere, we can just change the chain_name + // value. _chain_name = chain_name; } } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_sort -// Access: Published -// Description: Specifies a sort value for this task. Within a given -// AsyncTaskManager, all of the tasks with a given sort -// value are guaranteed to be completed before any tasks -// with a higher sort value are begun. -// -// To put it another way, two tasks might execute in -// parallel with each other only if they both have the -// same sort value. Tasks with a lower sort value are -// executed first. -// -// This is different from the priority, which makes no -// such exclusion guarantees. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a sort value for this task. Within a given AsyncTaskManager, all + * of the tasks with a given sort value are guaranteed to be completed before + * any tasks with a higher sort value are begun. + * + * To put it another way, two tasks might execute in parallel with each other + * only if they both have the same sort value. Tasks with a lower sort value + * are executed first. + * + * This is different from the priority, which makes no such exclusion + * guarantees. + */ void AsyncTask:: set_sort(int sort) { if (sort != _sort) { if (_manager != (AsyncTaskManager *)NULL) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { - // Changing sort on an "active" (i.e. enqueued) task means - // removing it and re-inserting it into the queue. + // Changing sort on an "active" (i.e. enqueued) task means removing + // it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); nassertv(chain != (AsyncTaskChain *)NULL); @@ -340,49 +298,42 @@ set_sort(int sort) { chain->do_add(this); } else { - // If it's sleeping, currently being serviced, or something - // else, we can just change the sort value directly. + // If it's sleeping, currently being serviced, or something else, we + // can just change the sort value directly. _sort = sort; } } else { - // If it hasn't been started anywhere, we can just change the - // sort value. + // If it hasn't been started anywhere, we can just change the sort + // value. _sort = sort; } } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_priority -// Access: Published -// Description: Specifies a priority value for this task. In -// general, tasks with a higher priority value are -// executed before tasks with a lower priority value -// (but only for tasks with the same sort value). -// -// Unlike the sort value, tasks with different -// priorities may execute at the same time, if the -// AsyncTaskManager has more than one thread servicing -// tasks. -// -// Also see AsyncTaskChain::set_timeslice_priority(), -// which changes the meaning of this value. In the -// default mode, when the timeslice_priority flag is -// false, all tasks always run once per epoch, -// regardless of their priority values (that is, the -// priority controls the order of the task execution -// only, not the number of times it runs). On the other -// hand, if you set the timeslice_priority flag to true, -// then changing a task's priority has an effect on the -// number of times it runs. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a priority value for this task. In general, tasks with a higher + * priority value are executed before tasks with a lower priority value (but + * only for tasks with the same sort value). + * + * Unlike the sort value, tasks with different priorities may execute at the + * same time, if the AsyncTaskManager has more than one thread servicing + * tasks. + * + * Also see AsyncTaskChain::set_timeslice_priority(), which changes the + * meaning of this value. In the default mode, when the timeslice_priority + * flag is false, all tasks always run once per epoch, regardless of their + * priority values (that is, the priority controls the order of the task + * execution only, not the number of times it runs). On the other hand, if + * you set the timeslice_priority flag to true, then changing a task's + * priority has an effect on the number of times it runs. + */ void AsyncTask:: set_priority(int priority) { if (priority != _priority) { if (_manager != (AsyncTaskManager *)NULL) { MutexHolder holder(_manager->_lock); if (_state == S_active && _sort >= _chain->_current_sort) { - // Changing priority on an "active" (i.e. enqueued) task means + // Changing priority on an "active" (i.e. enqueued) task means // removing it and re-inserting it into the queue. PT(AsyncTask) hold_task = this; AsyncTaskChain *chain = _manager->do_find_task_chain(_chain_name); @@ -392,25 +343,23 @@ set_priority(int priority) { chain->do_add(this); } else { - // If it's sleeping, currently being serviced, or something - // else, we can just change the priority value directly. + // If it's sleeping, currently being serviced, or something else, we + // can just change the priority value directly. _priority = priority; } } else { - // If it hasn't been started anywhere, we can just change the - // priority value. + // If it hasn't been started anywhere, we can just change the priority + // value. _priority = priority; } } } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::set_python_object -// Access: Published -// Description: Specifies an arbitrary Python object that will be -// piggybacked on the task object. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an arbitrary Python object that will be piggybacked on the task + * object. + */ void AsyncTask:: set_python_object(PyObject *python_object) { Py_XINCREF(python_object); @@ -420,13 +369,10 @@ set_python_object(PyObject *python_object) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::get_python_object -// Access: Published -// Description: Returns the Python object that was specified to -// set_python_object(), if any, or None if no object was -// specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Python object that was specified to set_python_object(), if + * any, or None if no object was specified. + */ PyObject *AsyncTask:: get_python_object() const { if (_python_object != (PyObject *)NULL) { @@ -438,11 +384,9 @@ get_python_object() const { } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTask:: output(ostream &out) const { out << get_type(); @@ -451,12 +395,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::jump_to_task_chain -// Access: Protected -// Description: Switches the AsyncTask to its new task chain, named -// by _chain_name. Called internally only. -//////////////////////////////////////////////////////////////////// +/** + * Switches the AsyncTask to its new task chain, named by _chain_name. Called + * internally only. + */ void AsyncTask:: jump_to_task_chain(AsyncTaskManager *manager) { AsyncTaskChain *chain_b = manager->do_find_task_chain(_chain_name); @@ -470,12 +412,10 @@ jump_to_task_chain(AsyncTaskManager *manager) { chain_b->do_add(this); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::unlock_and_do_task -// Access: Protected -// Description: Called by the AsyncTaskManager to actually run the -// task. Assumes the lock is held. See do_task(). -//////////////////////////////////////////////////////////////////// +/** + * Called by the AsyncTaskManager to actually run the task. Assumes the lock + * is held. See do_task(). + */ AsyncTask::DoneStatus AsyncTask:: unlock_and_do_task() { nassertr(_manager != (AsyncTaskManager *)NULL, DS_done); @@ -484,8 +424,7 @@ unlock_and_do_task() { Thread *current_thread = Thread::get_current_thread(); record_task(current_thread); - // It's important to release the lock while the task is being - // serviced. + // It's important to release the lock while the task is being serviced. _manager->_lock.release(); double start = clock->get_real_time(); @@ -508,73 +447,60 @@ unlock_and_do_task() { return status; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::is_runnable -// Access: Protected, Virtual -// Description: Override this function to return true if the task can -// be successfully executed, false if it cannot. Mainly -// intended as a sanity check when attempting to add the -// task to a task manager. -// -// This function is called with the lock held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to return true if the task can be successfully + * executed, false if it cannot. Mainly intended as a sanity check when + * attempting to add the task to a task manager. + * + * This function is called with the lock held. + */ bool AsyncTask:: is_runnable() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::do_task -// Access: Protected, Virtual -// Description: Override this function to do something useful for the -// task. The return value should be one of: -// -// DS_done: the task is finished, remove from active and -// throw the done event. -// -// DS_cont: the task has more work to do, keep it active -// and call this function again in the next epoch. -// -// DS_again: like DS_cont, but next time call the -// function from the beginning, almost as if it were -// freshly added to the task manager. The task's -// get_start_time() will be reset to now, and its -// get_elapsed_time() will be reset to 0. If the task -// has a set_delay(), it will wait again for that amount -// of time to elapse before restarting. Timing -// accounting, however, is not reset. -// -// DS_pickup: like DS_cont, but if the task chain has a -// frame budget and that budget has not yet been met, -// re-run the task again without waiting for the next -// frame. Otherwise, run it next epoch as usual. -// -// DS_exit: stop the task, and stop the enclosing -// sequence too. Outside of a sequence, this is the -// same as DS_done. -// -// DS_pause: delay the task for set_delay() seconds, -// then stop it. This is only useful within a sequence. -// -// DS_interrupt: Interrupt the whole AsyncTaskManager. -// The task will continue again next epoch, as if it had -// returned DS_cont. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful for the task. The return + * value should be one of: + * + * DS_done: the task is finished, remove from active and throw the done event. + * + * DS_cont: the task has more work to do, keep it active and call this + * function again in the next epoch. + * + * DS_again: like DS_cont, but next time call the function from the beginning, + * almost as if it were freshly added to the task manager. The task's + * get_start_time() will be reset to now, and its get_elapsed_time() will be + * reset to 0. If the task has a set_delay(), it will wait again for that + * amount of time to elapse before restarting. Timing accounting, however, is + * not reset. + * + * DS_pickup: like DS_cont, but if the task chain has a frame budget and that + * budget has not yet been met, re-run the task again without waiting for the + * next frame. Otherwise, run it next epoch as usual. + * + * DS_exit: stop the task, and stop the enclosing sequence too. Outside of a + * sequence, this is the same as DS_done. + * + * DS_pause: delay the task for set_delay() seconds, then stop it. This is + * only useful within a sequence. + * + * DS_interrupt: Interrupt the whole AsyncTaskManager. The task will continue + * again next epoch, as if it had returned DS_cont. + * + * This function is called with the lock *not* held. + */ AsyncTask::DoneStatus AsyncTask:: do_task() { return DS_done; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::upon_birth -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been added to the active queue. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been added + * to the active queue. + * + * This function is called with the lock *not* held. + */ void AsyncTask:: upon_birth(AsyncTaskManager *manager) { // Throw a generic add event for the manager. @@ -584,24 +510,19 @@ upon_birth(AsyncTaskManager *manager) { throw_event(event); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTask::upon_death -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been removed from the active queue. The -// parameter clean_exit is true if the task has been -// removed because it exited normally (returning -// DS_done), or false if it was removed for some other -// reason (e.g. AsyncTaskManager::remove()). By the -// time this method is called, _manager has been -// cleared, so the parameter manager indicates the -// original AsyncTaskManager that owned this task. -// -// The normal behavior is to throw the done_event only -// if clean_exit is true. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been + * removed from the active queue. The parameter clean_exit is true if the + * task has been removed because it exited normally (returning DS_done), or + * false if it was removed for some other reason (e.g. + * AsyncTaskManager::remove()). By the time this method is called, _manager + * has been cleared, so the parameter manager indicates the original + * AsyncTaskManager that owned this task. + * + * The normal behavior is to throw the done_event only if clean_exit is true. + * + * This function is called with the lock *not* held. + */ void AsyncTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { if (clean_exit && !_done_event.empty()) { diff --git a/panda/src/event/asyncTask.h b/panda/src/event/asyncTask.h index 838a1cba4f..48633a9d91 100644 --- a/panda/src/event/asyncTask.h +++ b/panda/src/event/asyncTask.h @@ -1,16 +1,15 @@ -// Filename: asyncTask.h -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTask.h + * @author drose + * @date 2006-08-23 + */ #ifndef ASYNCTASK_H #define ASYNCTASK_H @@ -25,13 +24,11 @@ class AsyncTaskManager; class AsyncTaskChain; -//////////////////////////////////////////////////////////////////// -// Class : AsyncTask -// Description : This class represents a concrete task performed by an -// AsyncManager. Normally, you would subclass from this -// class, and override do_task(), to define the -// functionality you wish to have the task perform. -//////////////////////////////////////////////////////////////////// +/** + * This class represents a concrete task performed by an AsyncManager. + * Normally, you would subclass from this class, and override do_task(), to + * define the functionality you wish to have the task perform. + */ class EXPCL_PANDA_EVENT AsyncTask : public AsyncTaskBase { public: AsyncTask(const string &name = string()); @@ -71,7 +68,7 @@ PUBLISHED: INLINE double get_delay() const; double get_wake_time() const; void recalc_wake_time(); - + INLINE double get_start_time() const; double get_elapsed_time() const; INLINE int get_start_frame() const; @@ -147,7 +144,7 @@ private: #ifdef HAVE_PYTHON PyObject *_python_object; #endif // HAVE_PYTHON - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/event/asyncTaskChain.I b/panda/src/event/asyncTaskChain.I index ca1b2c7350..bd85a12c2c 100644 --- a/panda/src/event/asyncTaskChain.I +++ b/panda/src/event/asyncTaskChain.I @@ -1,38 +1,30 @@ -// Filename: asyncTaskChain.I -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskChain.I + * @author drose + * @date 2006-08-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::is_started -// Access: Published -// Description: Returns true if the thread(s) have been started and -// are ready to service requests, false otherwise. If -// this is false, the next call to add() or add_and_do() -// will automatically start the threads. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the thread(s) have been started and are ready to service + * requests, false otherwise. If this is false, the next call to add() or + * add_and_do() will automatically start the threads. + */ INLINE bool AsyncTaskChain:: is_started() const { return (_state == S_started); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_get_next_wake_time -// Access: Protected -// Description: Returns the time at which the next sleeping thread -// will awaken, or -1 if there are no sleeping threads. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time at which the next sleeping thread will awaken, or -1 if + * there are no sleeping threads. Assumes the lock is already held. + */ INLINE double AsyncTaskChain:: do_get_next_wake_time() const { if (!_sleeping.empty()) { @@ -41,12 +33,10 @@ do_get_next_wake_time() const { return -1.0; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_wake_time -// Access: Protected, Static -// Description: Returns the time at which the indicated thread -// will awaken. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time at which the indicated thread will awaken. Assumes the + * lock is already held. + */ INLINE double AsyncTaskChain:: get_wake_time(AsyncTask *task) { return task->_wake_time; diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index ac160a978b..bd5c391857 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -1,16 +1,15 @@ -// Filename: asyncTaskChain.cxx -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskChain.cxx + * @author drose + * @date 2006-08-23 + */ #include "asyncTaskChain.h" #include "asyncTaskManager.h" @@ -29,11 +28,9 @@ TypeHandle AsyncTaskChain::_type_handle; PStatCollector AsyncTaskChain::_task_pcollector("Task"); PStatCollector AsyncTaskChain::_wait_pcollector("Wait"); -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskChain:: AsyncTaskChain(AsyncTaskManager *manager, const string &name) : Namable(name), @@ -57,53 +54,43 @@ AsyncTaskChain(AsyncTaskManager *manager, const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskChain:: ~AsyncTaskChain() { - // We only grab the lock if _needs_cleanup is true. This way, the - // temporary AsyncTaskChain objects created (and destructed) within - // the task manager won't risk a double-lock. + // We only grab the lock if _needs_cleanup is true. This way, the temporary + // AsyncTaskChain objects created (and destructed) within the task manager + // won't risk a double-lock. if (_needs_cleanup) { MutexHolder holder(_manager->_lock); do_cleanup(); } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_tick_clock -// Access: Published -// Description: Sets the tick_clock flag. When this is true, -// get_clock()->tick() will be called automatically at -// each task epoch. This is false by default. -//////////////////////////////////////////////////////////////////// +/** + * Sets the tick_clock flag. When this is true, get_clock()->tick() will be + * called automatically at each task epoch. This is false by default. + */ void AsyncTaskChain:: set_tick_clock(bool tick_clock) { MutexHolder holder(_manager->_lock); _tick_clock = tick_clock; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_tick_clock -// Access: Published -// Description: Returns the tick_clock flag. See set_tick_clock(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the tick_clock flag. See set_tick_clock(). + */ bool AsyncTaskChain:: get_tick_clock() const { MutexHolder holder(_manager->_lock); return _tick_clock; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_num_threads -// Access: Published -// Description: Changes the number of threads for this task chain. -// This may require stopping the threads if they are -// already running. -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of threads for this task chain. This may require + * stopping the threads if they are already running. + */ void AsyncTaskChain:: set_num_threads(int num_threads) { nassertv(num_threads >= 0); @@ -129,40 +116,31 @@ set_num_threads(int num_threads) { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_num_threads -// Access: Published -// Description: Returns the number of threads that will be servicing -// tasks for this chain. Also see -// get_num_running_threads(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads that will be servicing tasks for this chain. + * Also see get_num_running_threads(). + */ int AsyncTaskChain:: get_num_threads() const { MutexHolder holder(_manager->_lock); return _num_threads; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_num_running_threads -// Access: Published -// Description: Returns the number of threads that have been created -// and are actively running. This will return 0 before -// the threads have been started; it will also return 0 -// if thread support is not available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads that have been created and are actively + * running. This will return 0 before the threads have been started; it will + * also return 0 if thread support is not available. + */ int AsyncTaskChain:: get_num_running_threads() const { MutexHolder holder(_manager->_lock); return _threads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_thread_priority -// Access: Published -// Description: Changes the priority associated with threads that -// serve this task chain. This may require stopping the -// threads if they are already running. -//////////////////////////////////////////////////////////////////// +/** + * Changes the priority associated with threads that serve this task chain. + * This may require stopping the threads if they are already running. + */ void AsyncTaskChain:: set_thread_priority(ThreadPriority priority) { MutexHolder holder(_manager->_lock); @@ -176,138 +154,107 @@ set_thread_priority(ThreadPriority priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_thread_priority -// Access: Published -// Description: Returns the priority associated with threads that -// serve this task chain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the priority associated with threads that serve this task chain. + */ ThreadPriority AsyncTaskChain:: get_thread_priority() const { MutexHolder holder(_manager->_lock); return _thread_priority; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_frame_budget -// Access: Published -// Description: Sets the maximum amount of time per frame the tasks -// on this chain are granted for execution. If this is -// less than zero, there is no limit; if it is >= 0, it -// represents a maximum amount of time (in seconds) that -// will be used to execute tasks. If this time is -// exceeded in any one frame, the task chain will stop -// executing tasks until the next frame, as defined by -// the TaskManager's clock. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum amount of time per frame the tasks on this chain are + * granted for execution. If this is less than zero, there is no limit; if it + * is >= 0, it represents a maximum amount of time (in seconds) that will be + * used to execute tasks. If this time is exceeded in any one frame, the task + * chain will stop executing tasks until the next frame, as defined by the + * TaskManager's clock. + */ void AsyncTaskChain:: set_frame_budget(double frame_budget) { MutexHolder holder(_manager->_lock); _frame_budget = frame_budget; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_frame_budget -// Access: Published -// Description: Returns the maximum amount of time per frame the -// tasks on this chain are granted for execution. See -// set_frame_budget(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum amount of time per frame the tasks on this chain are + * granted for execution. See set_frame_budget(). + */ double AsyncTaskChain:: get_frame_budget() const { MutexHolder holder(_manager->_lock); return _frame_budget; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_frame_sync -// Access: Published -// Description: Sets the frame_sync flag. When this flag is true, -// this task chain will be forced to sync with the -// TaskManager's clock. It will run no faster than one -// epoch per clock frame. -// -// When this flag is false, the default, the task chain -// will finish all of its tasks and then immediately -// start from the first task again, regardless of the -// clock frame. When it is true, the task chain will -// finish all of its tasks and then wait for the clock -// to tick to the next frame before resuming the first -// task. -// -// This only makes sense for threaded task chains. -// Non-threaded task chains are automatically -// synchronous. -//////////////////////////////////////////////////////////////////// +/** + * Sets the frame_sync flag. When this flag is true, this task chain will be + * forced to sync with the TaskManager's clock. It will run no faster than + * one epoch per clock frame. + * + * When this flag is false, the default, the task chain will finish all of its + * tasks and then immediately start from the first task again, regardless of + * the clock frame. When it is true, the task chain will finish all of its + * tasks and then wait for the clock to tick to the next frame before resuming + * the first task. + * + * This only makes sense for threaded task chains. Non-threaded task chains + * are automatically synchronous. + */ void AsyncTaskChain:: set_frame_sync(bool frame_sync) { MutexHolder holder(_manager->_lock); _frame_sync = frame_sync; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_frame_sync -// Access: Published -// Description: Returns the frame_sync flag. See set_frame_sync(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame_sync flag. See set_frame_sync(). + */ bool AsyncTaskChain:: get_frame_sync() const { MutexHolder holder(_manager->_lock); return _frame_sync; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::set_timeslice_priority -// Access: Published -// Description: Sets the timeslice_priority flag. This changes -// the interpretation of priority, and the number of -// times per epoch each task will run. -// -// When this flag is true, some tasks might not run in -// any given epoch. Instead, tasks with priority higher -// than 1 will be given precedence, in proportion to the -// amount of time they have already used. This gives -// higher-priority tasks more runtime than -// lower-priority tasks. Each task gets the amount of -// time proportional to its priority value, so a task -// with priority 100 will get five times as much -// processing time as a task with priority 20. For -// these purposes, priority values less than 1 are -// deemed to be equal to 1. -// -// When this flag is false (the default), all tasks are -// run exactly once each epoch, round-robin style. -// Priority is only used to determine which task runs -// first within tasks of the same sort value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the timeslice_priority flag. This changes the interpretation of + * priority, and the number of times per epoch each task will run. + * + * When this flag is true, some tasks might not run in any given epoch. + * Instead, tasks with priority higher than 1 will be given precedence, in + * proportion to the amount of time they have already used. This gives + * higher-priority tasks more runtime than lower-priority tasks. Each task + * gets the amount of time proportional to its priority value, so a task with + * priority 100 will get five times as much processing time as a task with + * priority 20. For these purposes, priority values less than 1 are deemed to + * be equal to 1. + * + * When this flag is false (the default), all tasks are run exactly once each + * epoch, round-robin style. Priority is only used to determine which task + * runs first within tasks of the same sort value. + */ void AsyncTaskChain:: set_timeslice_priority(bool timeslice_priority) { MutexHolder holder(_manager->_lock); _timeslice_priority = timeslice_priority; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_timeslice_priority -// Access: Published -// Description: Returns the timeslice_priority flag. This changes -// the interpretation of priority, and the number of -// times per epoch each task will run. See -// set_timeslice_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the timeslice_priority flag. This changes the interpretation of + * priority, and the number of times per epoch each task will run. See + * set_timeslice_priority(). + */ bool AsyncTaskChain:: get_timeslice_priority() const { MutexHolder holder(_manager->_lock); return _timeslice_priority; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::stop_threads -// Access: Published -// Description: Stops any threads that are currently running. If any -// tasks are still pending and have not yet been picked -// up by a thread, they will not be serviced unless -// poll() or start_threads() is later called. -//////////////////////////////////////////////////////////////////// +/** + * Stops any threads that are currently running. If any tasks are still + * pending and have not yet been picked up by a thread, they will not be + * serviced unless poll() or start_threads() is later called. + */ void AsyncTaskChain:: stop_threads() { if (_state == S_started || _state == S_interrupted) { @@ -317,13 +264,11 @@ stop_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::start_threads -// Access: Published -// Description: Starts any requested threads to service the tasks on -// the queue. This is normally not necessary, since -// adding a task will start the threads automatically. -//////////////////////////////////////////////////////////////////// +/** + * Starts any requested threads to service the tasks on the queue. This is + * normally not necessary, since adding a task will start the threads + * automatically. + */ void AsyncTaskChain:: start_threads() { if (_state == S_initial || _state == S_interrupted) { @@ -332,12 +277,10 @@ start_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::has_task -// Access: Published -// Description: Returns true if the indicated task has been added to -// this AsyncTaskChain, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated task has been added to this AsyncTaskChain, + * false otherwise. + */ bool AsyncTaskChain:: has_task(AsyncTask *task) const { MutexHolder holder(_manager->_lock); @@ -351,40 +294,34 @@ has_task(AsyncTask *task) const { return false; } - // The task might not actually be in the active queue, since it - // might be being serviced right now. That's OK. + // The task might not actually be in the active queue, since it might be + // being serviced right now. That's OK. return true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::wait_for_tasks -// Access: Published -// Description: Blocks until the task list is empty. -//////////////////////////////////////////////////////////////////// +/** + * Blocks until the task list is empty. + */ void AsyncTaskChain:: wait_for_tasks() { MutexHolder holder(_manager->_lock); do_wait_for_tasks(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_num_tasks -// Access: Published -// Description: Returns the number of tasks that are currently active -// or sleeping within the task chain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of tasks that are currently active or sleeping within + * the task chain. + */ int AsyncTaskChain:: get_num_tasks() const { MutexHolder holder(_manager->_lock); return _num_tasks; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_tasks -// Access: Published -// Description: Returns the set of tasks that are active or sleeping -// on the task chain, at the time of the call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are active or sleeping on the task chain, at + * the time of the call. + */ AsyncTaskCollection AsyncTaskChain:: get_tasks() const { MutexHolder holder(_manager->_lock); @@ -393,96 +330,76 @@ get_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_active_tasks -// Access: Published -// Description: Returns the set of tasks that are active (and not -// sleeping) on the task chain, at the time of the -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are active (and not sleeping) on the task + * chain, at the time of the call. + */ AsyncTaskCollection AsyncTaskChain:: get_active_tasks() const { MutexHolder holder(_manager->_lock); return do_get_active_tasks(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_sleeping_tasks -// Access: Published -// Description: Returns the set of tasks that are sleeping (and not -// active) on the task chain, at the time of the -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are sleeping (and not active) on the task + * chain, at the time of the call. + */ AsyncTaskCollection AsyncTaskChain:: get_sleeping_tasks() const { MutexHolder holder(_manager->_lock); return do_get_sleeping_tasks(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::poll -// Access: Published -// Description: Runs through all the tasks in the task list, once, if -// the task chain is running in single-threaded mode -// (no threads available). This method does nothing in -// threaded mode, so it may safely be called in either -// case. -// -// Normally, you would not call this function directly; -// instead, call AsyncTaskManager::poll(), which polls -// all of the task chains in sequence. -//////////////////////////////////////////////////////////////////// +/** + * Runs through all the tasks in the task list, once, if the task chain is + * running in single-threaded mode (no threads available). This method does + * nothing in threaded mode, so it may safely be called in either case. + * + * Normally, you would not call this function directly; instead, call + * AsyncTaskManager::poll(), which polls all of the task chains in sequence. + */ void AsyncTaskChain:: poll() { MutexHolder holder(_manager->_lock); do_poll(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::get_next_wake_time -// Access: Published -// Description: Returns the scheduled time (on the manager's clock) -// of the next sleeping task, on any task chain, to -// awaken. Returns -1 if there are no sleeping tasks. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scheduled time (on the manager's clock) of the next sleeping + * task, on any task chain, to awaken. Returns -1 if there are no sleeping + * tasks. + */ double AsyncTaskChain:: get_next_wake_time() const { MutexHolder holder(_manager->_lock); return do_get_next_wake_time(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskChain:: output(ostream &out) const { MutexHolder holder(_manager->_lock); do_output(out); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskChain:: write(ostream &out, int indent_level) const { MutexHolder holder(_manager->_lock); do_write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_add -// Access: Protected -// Description: Adds the indicated task to the active queue. It is -// an error if the task is already added to this or any -// other active queue. -// -// This is normally called only by the AsyncTaskManager. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated task to the active queue. It is an error if the task is + * already added to this or any other active queue. + * + * This is normally called only by the AsyncTaskManager. Assumes the lock is + * already held. + */ void AsyncTaskChain:: do_add(AsyncTask *task) { nassertv(task->_chain == NULL && @@ -535,14 +452,11 @@ do_add(AsyncTask *task) { _cvar.notify_all(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_remove -// Access: Protected -// Description: Removes the indicated task from this chain. Returns -// true if removed, false otherwise. Assumes the lock -// is already held. The task->upon_death() method is -// *not* called. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated task from this chain. Returns true if removed, false + * otherwise. Assumes the lock is already held. The task->upon_death() + * method is *not* called. + */ bool AsyncTaskChain:: do_remove(AsyncTask *task) { bool removed = false; @@ -555,11 +469,11 @@ do_remove(AsyncTask *task) { task->_state = AsyncTask::S_servicing_removed; removed = true; break; - + case AsyncTask::S_servicing_removed: // Being serviced, though it will be removed later. break; - + case AsyncTask::S_sleeping: // Sleeping, easy. { @@ -571,7 +485,7 @@ do_remove(AsyncTask *task) { cleanup_task(task, false, false); } break; - + case AsyncTask::S_active: { // Active, but not being serviced, easy. @@ -591,7 +505,7 @@ do_remove(AsyncTask *task) { removed = true; cleanup_task(task, false, false); } - + default: break; } @@ -599,12 +513,9 @@ do_remove(AsyncTask *task) { return removed; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_wait_for_tasks -// Access: Protected -// Description: Blocks until the task list is empty. Assumes the -// lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Blocks until the task list is empty. Assumes the lock is held. + */ void AsyncTaskChain:: do_wait_for_tasks() { do_start_threads(); @@ -624,20 +535,17 @@ do_wait_for_tasks() { if (_state == S_shutdown || _state == S_interrupted) { return; } - + PStatTimer timer(_wait_pcollector); _cvar.wait(); } } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_cleanup -// Access: Protected -// Description: Stops all threads and messily empties the task list. -// This is intended to be called on destruction only. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Stops all threads and messily empties the task list. This is intended to + * be called on destruction only. Assumes the lock is already held. + */ void AsyncTaskChain:: do_cleanup() { if (task_cat.is_spam()) { @@ -649,10 +557,10 @@ do_cleanup() { _num_threads = 0; // Don't call the upon_death functions while we clean up the tasks. - // Instead, store all the tasks in a list as we clean them up, and - // then call the upon_death functions all at once. We do this - // because calling upon_death wil release the lock, allowing the - // iterators to become invalid. + // Instead, store all the tasks in a list as we clean them up, and then call + // the upon_death functions all at once. We do this because calling + // upon_death wil release the lock, allowing the iterators to become + // invalid. TaskHeap dead; dead.reserve(_num_tasks); @@ -681,10 +589,9 @@ do_cleanup() { cleanup_task(task, false, false); } - // There might still be one task remaining: the currently-executing - // task. + // There might still be one task remaining: the currently-executing task. nassertv(_num_tasks == 0 || _num_tasks == 1); - + // Now go back and call the upon_death functions. _manager->_lock.release(); for (ti = dead.begin(); ti != dead.end(); ++ti) { @@ -699,14 +606,11 @@ do_cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_has_task -// Access: Protected -// Description: Returns true if the task is on one of the task lists, -// false if it is not (false may mean that the task is -// currently being serviced). Assumes the lock is -// currently held. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the task is on one of the task lists, false if it is not + * (false may mean that the task is currently being serviced). Assumes the + * lock is currently held. + */ bool AsyncTaskChain:: do_has_task(AsyncTask *task) const { return (find_task_on_heap(_active, task) != -1 || @@ -715,15 +619,11 @@ do_has_task(AsyncTask *task) const { find_task_on_heap(_this_active, task) != -1); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::find_task_on_heap -// Access: Protected -// Description: Returns the index number of the indicated task within -// the specified task list, or -1 if the task is not -// found in the list (this may mean that it is currently -// being serviced). Assumes that the lock is currently -// held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the indicated task within the specified task + * list, or -1 if the task is not found in the list (this may mean that it is + * currently being serviced). Assumes that the lock is currently held. + */ int AsyncTaskChain:: find_task_on_heap(const TaskHeap &heap, AsyncTask *task) const { for (int i = 0; i < (int)heap.size(); ++i) { @@ -735,17 +635,13 @@ find_task_on_heap(const TaskHeap &heap, AsyncTask *task) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::service_one_task -// Access: Protected -// Description: Pops a single task off the active queue, services it, -// and restores it to the end of the queue. This is -// called internally only within one of the task -// threads. Assumes the lock is already held. -// -// Note that the lock may be temporarily released by -// this method. -//////////////////////////////////////////////////////////////////// +/** + * Pops a single task off the active queue, services it, and restores it to + * the end of the queue. This is called internally only within one of the + * task threads. Assumes the lock is already held. + * + * Note that the lock may be temporarily released by this method. + */ void AsyncTaskChain:: service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { if (!_active.empty()) { @@ -789,13 +685,12 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { } else { switch (ds) { case AsyncTask::DS_cont: - // The task is still alive; put it on the next frame's active - // queue. + // The task is still alive; put it on the next frame's active queue. task->_state = AsyncTask::S_active; _next_active.push_back(task); _cvar.notify_all(); break; - + case AsyncTask::DS_again: // The task wants to sleep again. { @@ -807,7 +702,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { push_heap(_sleeping.begin(), _sleeping.end(), AsyncTaskSortWakeTime()); if (task_cat.is_spam()) { task_cat.spam() - << "Sleeping " << *task << ", wake time at " + << "Sleeping " << *task << ", wake time at " << task->_wake_time - now << "\n"; } _cvar.notify_all(); @@ -830,7 +725,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { _cvar.notify_all(); } break; - + default: // The task has finished. cleanup_task(task, true, true); @@ -838,7 +733,7 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { } } else { task_cat.error() - << "Task is no longer on chain " << get_name() + << "Task is no longer on chain " << get_name() << ": " << *task << "\n"; } @@ -851,20 +746,15 @@ service_one_task(AsyncTaskChain::AsyncTaskChainThread *thread) { thread_consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::cleanup_task -// Access: Protected -// Description: Called internally when a task has completed (or been -// interrupted) and is about to be removed from the -// active queue. Assumes the lock is held. -// -// If upon_death is true, then task->upon_death() will -// also be called, with the indicated clean_exit -// parameter. -// -// Note that the lock may be temporarily released by -// this method. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when a task has completed (or been interrupted) and is + * about to be removed from the active queue. Assumes the lock is held. + * + * If upon_death is true, then task->upon_death() will also be called, with + * the indicated clean_exit parameter. + * + * Note that the lock may be temporarily released by this method. + */ void AsyncTaskChain:: cleanup_task(AsyncTask *task, bool upon_death, bool clean_exit) { if (task_cat.is_spam()) { @@ -892,18 +782,14 @@ cleanup_task(AsyncTask *task, bool upon_death, bool clean_exit) { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::finish_sort_group -// Access: Protected -// Description: Called internally when all tasks of a given sort -// value have been completed, and it is time to -// increment to the next sort value, or begin the next -// epoch. Assumes the lock is held. -// -// Returns true if there are more tasks on the queue -// after this operation, or false if the task list is -// empty and we need to wait. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when all tasks of a given sort value have been completed, + * and it is time to increment to the next sort value, or begin the next + * epoch. Assumes the lock is held. + * + * Returns true if there are more tasks on the queue after this operation, or + * false if the task list is empty and we need to wait. + */ bool AsyncTaskChain:: finish_sort_group() { nassertr(_num_busy_threads == 0, true); @@ -911,7 +797,7 @@ finish_sort_group() { if (!_threads.empty()) { PStatClient::thread_tick(get_name()); } - + if (!_active.empty()) { // There are more tasks; just set the next sort value. nassertr(_current_sort < _active.front()->get_sort(), true); @@ -923,10 +809,9 @@ finish_sort_group() { // There are no more tasks in this epoch; advance to the next epoch. if (!_this_active.empty() && _frame_budget >= 0.0) { - // Enter pickup mode. This is a special mode at the end of the - // epoch in which we are just re-running the tasks that think they - // can still run within the frame, in an attempt to use up our - // frame budget. + // Enter pickup mode. This is a special mode at the end of the epoch in + // which we are just re-running the tasks that think they can still run + // within the frame, in an attempt to use up our frame budget. if (task_cat.is_spam()) { do_output(task_cat.spam()); @@ -948,16 +833,16 @@ finish_sort_group() { _pickup_mode = false; - // Here, there's no difference between _this_active and - // _next_active. Combine them. + // Here, there's no difference between _this_active and _next_active. + // Combine them. _next_active.insert(_next_active.end(), _this_active.begin(), _this_active.end()); _this_active.clear(); _active.swap(_next_active); - // We only tick the clock and wake sleepers in normal mode, the - // first time through the task list; not in pickup mode when we - // are re-running the stragglers just to use up our frame budget. + // We only tick the clock and wake sleepers in normal mode, the first time + // through the task list; not in pickup mode when we are re-running the + // stragglers just to use up our frame budget. if (_tick_clock) { if (task_cat.is_spam()) { @@ -969,18 +854,18 @@ finish_sort_group() { _manager->_frame_cvar.notify_all(); } else if (_frame_sync) { - // If we're a synced chain, we have to wait at the end of the - // epoch for someone else to tick the clock. + // If we're a synced chain, we have to wait at the end of the epoch for + // someone else to tick the clock. _block_till_next_frame = true; } - + // Check for any sleeping tasks that need to be woken. double now = _manager->_clock->get_frame_time(); while (!_sleeping.empty() && _sleeping.front()->_wake_time <= now) { PT(AsyncTask) task = _sleeping.front(); if (task_cat.is_spam()) { task_cat.spam() - << "Waking " << *task << ", wake time at " + << "Waking " << *task << ", wake time at " << task->_wake_time - now << "\n"; } pop_heap(_sleeping.begin(), _sleeping.end(), AsyncTaskSortWakeTime()); @@ -996,13 +881,13 @@ finish_sort_group() { << "No more tasks on sleeping queue.\n"; } else { task_cat.spam() - << "Next sleeper: " << *_sleeping.front() << ", wake time at " + << "Next sleeper: " << *_sleeping.front() << ", wake time at " << _sleeping.front()->_wake_time - now << "\n"; } } - // Any tasks that are on the active queue at the beginning of the - // epoch are deemed to have run one frame (or to be about to). + // Any tasks that are on the active queue at the beginning of the epoch + // are deemed to have run one frame (or to be about to). TaskHeap::const_iterator ti; for (ti = _active.begin(); ti != _active.end(); ++ti) { AsyncTask *task = (*ti); @@ -1031,17 +916,13 @@ finish_sort_group() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::filter_timeslice_priority -// Access: Protected -// Description: Called to filter the _active tasks list when we are -// in the special timeslice_priority mode. In this -// mode, go through and postpone any tasks that have -// already exceeded their priority budget for this -// epoch. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called to filter the _active tasks list when we are in the special + * timeslice_priority mode. In this mode, go through and postpone any tasks + * that have already exceeded their priority budget for this epoch. + * + * Assumes the lock is already held. + */ void AsyncTaskChain:: filter_timeslice_priority() { if (_active.empty()) { @@ -1052,7 +933,7 @@ filter_timeslice_priority() { // We must first sum up the average per-epoch runtime of each task. double net_runtime = 0.0; int net_priority = 0; - + TaskHeap::iterator ti; for (ti = _active.begin(); ti != _active.end(); ++ti) { AsyncTask *task = (*ti); @@ -1061,17 +942,18 @@ filter_timeslice_priority() { net_runtime += runtime; net_priority += priority; } - + // That gives us a timeslice budget per priority value. double average_budget = net_runtime / (double)net_priority; - + TaskHeap keep, postpone; for (ti = _active.begin(); ti != _active.end(); ++ti) { AsyncTask *task = (*ti); double runtime = max(task->get_average_dt(), 0.0); int priority = max(task->_priority, 1); double consumed = runtime / (double)priority; - // cerr << *task << " consumed " << consumed << " vs. " << average_budget << "\n"; + // cerr << *task << " consumed " << consumed << " vs. " << average_budget + // << "\n"; if (consumed > average_budget) { // Postpone. Run this task next epoch. postpone.push_back(task); @@ -1094,12 +976,12 @@ filter_timeslice_priority() { } } - // cerr << "Nothing to keep, keeping " << *(*max_ti) << " instead\n"; + // cerr << "Nothing to keep, keeping " << *(*max_ti) << " instead\n"; keep.push_back(*max_ti); postpone.erase(max_ti); } - + _active.swap(keep); if (_pickup_mode) { _this_active.insert(_this_active.end(), postpone.begin(), postpone.end()); @@ -1110,49 +992,47 @@ filter_timeslice_priority() { nassertv(!_active.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_stop_threads -// Access: Protected -// Description: The private implementation of stop_threads; assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of stop_threads; assumes the lock is already + * held. + */ void AsyncTaskChain:: do_stop_threads() { if (_state == S_started || _state == S_interrupted) { if (task_cat.is_debug() && !_threads.empty()) { task_cat.debug() - << "Stopping " << _threads.size() + << "Stopping " << _threads.size() << " threads for " << _manager->get_name() - << " chain " << get_name() + << " chain " << get_name() << " in " << *Thread::get_current_thread() << "\n"; } _state = S_shutdown; _cvar.notify_all(); _manager->_frame_cvar.notify_all(); - + Threads wait_threads; wait_threads.swap(_threads); - - // We have to release the lock while we join, so the threads can - // wake up and see that we're shutting down. + + // We have to release the lock while we join, so the threads can wake up + // and see that we're shutting down. _manager->_lock.release(); Threads::iterator ti; for (ti = wait_threads.begin(); ti != wait_threads.end(); ++ti) { if (task_cat.is_debug()) { task_cat.debug() - << "Waiting for " << *(*ti) << " in " + << "Waiting for " << *(*ti) << " in " << *Thread::get_current_thread() << "\n"; } (*ti)->join(); if (task_cat.is_spam()) { task_cat.spam() - << "Done waiting for " << *(*ti) << " in " + << "Done waiting for " << *(*ti) << " in " << *Thread::get_current_thread() << "\n"; } } _manager->_lock.acquire(); - + _state = S_initial; // There might be one busy "thread" still: the main thread. @@ -1161,12 +1041,10 @@ do_stop_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_start_threads -// Access: Protected -// Description: The private implementation of start_threads; assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of start_threads; assumes the lock is already + * held. + */ void AsyncTaskChain:: do_start_threads() { if (_state == S_interrupted) { @@ -1195,13 +1073,10 @@ do_start_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_get_active_tasks -// Access: Protected -// Description: Returns the set of tasks that are active (and not -// sleeping) on the task chain, at the time of the -// call. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are active (and not sleeping) on the task + * chain, at the time of the call. Assumes the lock is held. + */ AsyncTaskCollection AsyncTaskChain:: do_get_active_tasks() const { AsyncTaskCollection result; @@ -1230,13 +1105,10 @@ do_get_active_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_get_sleeping_tasks -// Access: Published -// Description: Returns the set of tasks that are sleeping (and not -// active) on the task chain, at the time of the -// call. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are sleeping (and not active) on the task + * chain, at the time of the call. Assumes the lock is held. + */ AsyncTaskCollection AsyncTaskChain:: do_get_sleeping_tasks() const { AsyncTaskCollection result; @@ -1250,12 +1122,10 @@ do_get_sleeping_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_poll -// Access: Protected -// Description: The private implementation of poll(), this assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of poll(), this assumes the lock is already + * held. + */ void AsyncTaskChain:: do_poll() { thread_consider_yield(); @@ -1291,17 +1161,17 @@ do_poll() { } if (_block_till_next_frame || (_frame_budget >= 0.0 && _time_in_frame >= _frame_budget)) { - // If we've exceeded our budget, stop here. We'll resume from - // this point at the next call to poll(). + // If we've exceeded our budget, stop here. We'll resume from this + // point at the next call to poll(). cleanup_pickup_mode(); return; } - + _current_sort = _active.front()->get_sort(); - // Normally, there won't be any threads running at the same time - // we're in poll(). But it's possible, if someone calls - // set_num_threads() while we're processing. + // Normally, there won't be any threads running at the same time we're + // in poll(). But it's possible, if someone calls set_num_threads() + // while we're processing. _num_busy_threads++; service_one_task(NULL); _num_busy_threads--; @@ -1311,19 +1181,16 @@ do_poll() { return; } } - + finish_sort_group(); } while (_pickup_mode); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::cleanup_pickup_mode -// Access: Protected -// Description: Clean up the damage from setting pickup mode. This -// means we restore the _active and _next_active lists -// as they should have been without pickup mode, for -// next frame. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Clean up the damage from setting pickup mode. This means we restore the + * _active and _next_active lists as they should have been without pickup + * mode, for next frame. Assumes the lock is held. + */ void AsyncTaskChain:: cleanup_pickup_mode() { if (_pickup_mode) { @@ -1340,12 +1207,10 @@ cleanup_pickup_mode() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_output -// Access: Protected -// Description: The private implementation of output(), this assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of output(), this assumes the lock is already + * held. + */ void AsyncTaskChain:: do_output(ostream &out) const { if (_manager != (AsyncTaskManager *)NULL) { @@ -1357,43 +1222,41 @@ do_output(ostream &out) const { << "; " << _num_tasks << " tasks"; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::do_write -// Access: Protected -// Description: The private implementation of write(), this assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of write(), this assumes the lock is already + * held. + */ void AsyncTaskChain:: do_write(ostream &out, int indent_level) const { indent(out, indent_level) << "Task chain \"" << get_name() << "\"\n"; if (_num_threads > 0) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << _num_threads << " threads, priority " << _thread_priority << "\n"; } if (_frame_budget >= 0.0) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "frame budget " << _frame_budget << " s\n"; } if (_timeslice_priority) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "timeslice priority\n"; } if (_tick_clock) { - indent(out, indent_level + 2) + indent(out, indent_level + 2) << "tick clock\n"; } static const size_t buffer_size = 1024; char buffer[buffer_size]; sprintf(buffer, " %-32s %8s %8s %8s %8s %6s", - "Task", + "Task", "sleep(s)", "dt(ms)", "avg", "max", "sort"); nassertv(strlen(buffer) < buffer_size); - indent(out, indent_level) + indent(out, indent_level) << buffer << "\n"; indent(out, indent_level); @@ -1402,8 +1265,7 @@ do_write(ostream &out, int indent_level) const { } out << "\n"; - // Collect a list of all active tasks, then sort them into order for - // output. + // Collect a list of all active tasks, then sort them into order for output. TaskHeap tasks = _active; tasks.insert(tasks.end(), _this_active.begin(), _this_active.end()); tasks.insert(tasks.end(), _next_active.begin(), _next_active.end()); @@ -1422,8 +1284,8 @@ do_write(ostream &out, int indent_level) const { sort(tasks.begin(), tasks.end(), AsyncTaskSortPriority()); // Since AsyncTaskSortPriority() sorts backwards (because of STL's - // push_heap semantics), we go through the task list in reverse - // order to print them forwards. + // push_heap semantics), we go through the task list in reverse order to + // print them forwards. TaskHeap::reverse_iterator ti; for (ti = tasks.rbegin(); ti != tasks.rend(); ++ti) { AsyncTask *task = (*ti); @@ -1431,26 +1293,23 @@ do_write(ostream &out, int indent_level) const { } } - // Instead of iterating through the _sleeping list in heap order, - // copy it and then use repeated pops to get it out in sorted - // order, for the user's satisfaction. + // Instead of iterating through the _sleeping list in heap order, copy it + // and then use repeated pops to get it out in sorted order, for the user's + // satisfaction. TaskHeap sleeping = _sleeping; while (!sleeping.empty()) { PT(AsyncTask) task = sleeping.front(); pop_heap(sleeping.begin(), sleeping.end(), AsyncTaskSortWakeTime()); sleeping.pop_back(); - + write_task_line(out, indent_level, task, now); } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::write_task_line -// Access: Protected -// Description: Writes a single line for a task in the report -// generated by do_write(). Assumes the lock is already -// held. -//////////////////////////////////////////////////////////////////// +/** + * Writes a single line for a task in the report generated by do_write(). + * Assumes the lock is already held. + */ void AsyncTaskChain:: write_task_line(ostream &out, int indent_level, AsyncTask *task, double now) const { char servicing_flag = ' '; @@ -1464,28 +1323,28 @@ write_task_line(ostream &out, int indent_level, AsyncTask *task, double now) con char buffer[buffer_size]; if (task->_state == AsyncTask::S_sleeping) { - // For sleeping tasks, include the wake time, as an elapsed time - // in seconds. + // For sleeping tasks, include the wake time, as an elapsed time in + // seconds. string name = task->get_name().substr(0, 32); sprintf(buffer, "%c%-32s %8.1f", servicing_flag, name.c_str(), task->_wake_time - now); } else { - // For active tasks, don't include a wake time. This means we - // have more space for the name. + // For active tasks, don't include a wake time. This means we have more + // space for the name. string name = task->get_name().substr(0, 41); sprintf(buffer, "%c%-41s", servicing_flag, name.c_str()); } nassertv(strlen(buffer) < buffer_size); - indent(out, indent_level) + indent(out, indent_level) << buffer; if (task->_num_frames > 0) { sprintf(buffer, " %8.1f %8.1f %8.1f %6d", task->_dt * 1000.0, task->get_average_dt() * 1000.0, - task->_max_dt * 1000.0, + task->_max_dt * 1000.0, task->_sort); } else { // No statistics for a task that hasn't run yet. @@ -1498,11 +1357,9 @@ write_task_line(ostream &out, int indent_level, AsyncTask *task, double now) con out << buffer << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::AsyncTaskChainThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskChain::AsyncTaskChainThread:: AsyncTaskChainThread(const string &name, AsyncTaskChain *chain) : Thread(name, chain->get_name()), @@ -1511,11 +1368,9 @@ AsyncTaskChainThread(const string &name, AsyncTaskChain *chain) : { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskChain::AsyncTaskChainThread::thread_main -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskChain::AsyncTaskChainThread:: thread_main() { MutexHolder holder(_chain->_manager->_lock); @@ -1531,8 +1386,7 @@ thread_main() { _chain->_block_till_next_frame = false; } - // If we've exceeded our frame budget, sleep until the next - // frame. + // If we've exceeded our frame budget, sleep until the next frame. if (_chain->_block_till_next_frame || (_chain->_frame_budget >= 0.0 && _chain->_time_in_frame >= _chain->_frame_budget)) { while ((_chain->_block_till_next_frame || @@ -1558,9 +1412,9 @@ thread_main() { _chain->_cvar.notify_all(); } else { - // We've finished all the available tasks of the current sort - // value. We can't pick up a new task until all of the threads - // finish the tasks with the same sort value. + // We've finished all the available tasks of the current sort value. We + // can't pick up a new task until all of the threads finish the tasks + // with the same sort value. if (_chain->_num_busy_threads == 0) { // We're the last thread to finish. Update _current_sort. if (!_chain->finish_sort_group()) { @@ -1574,16 +1428,15 @@ thread_main() { double timeout = max(wake_time - now, 0.0); PStatTimer timer(_wait_pcollector); _chain->_cvar.wait(timeout); - } + } } } else { - // Wait for the other threads to finish their current task - // before we continue. + // Wait for the other threads to finish their current task before we + // continue. PStatTimer timer(_wait_pcollector); _chain->_cvar.wait(); } } } } - diff --git a/panda/src/event/asyncTaskChain.h b/panda/src/event/asyncTaskChain.h index d0768516ea..4f98ef284a 100644 --- a/panda/src/event/asyncTaskChain.h +++ b/panda/src/event/asyncTaskChain.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskChain.h -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskChain.h + * @author drose + * @date 2006-08-23 + */ #ifndef ASYNCTASKCHAIN_H #define ASYNCTASKCHAIN_H @@ -29,31 +28,25 @@ class AsyncTaskManager; -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskChain -// Description : The AsyncTaskChain is a subset of the -// AsyncTaskManager. Each chain maintains a separate -// list of tasks, and will execute them with its own set -// of threads. Each chain may thereby operate -// independently of the other chains. -// -// The AsyncTaskChain will spawn a specified number of -// threads (possibly 0) to serve the tasks. If there -// are no threads, you must call poll() from time to -// time to serve the tasks in the main thread. Normally -// this is done by calling AsyncTaskManager::poll(). -// -// Each task will run exactly once each epoch. Beyond -// that, the tasks' sort and priority values control the -// order in which they are run: tasks are run in -// increasing order by sort value, and within the same -// sort value, they are run roughly in decreasing order -// by priority value, with some exceptions for -// parallelism. Tasks with different sort values are -// never run in parallel together, but tasks with -// different priority values might be (if there is more -// than one thread). -//////////////////////////////////////////////////////////////////// +/** + * The AsyncTaskChain is a subset of the AsyncTaskManager. Each chain + * maintains a separate list of tasks, and will execute them with its own set + * of threads. Each chain may thereby operate independently of the other + * chains. + * + * The AsyncTaskChain will spawn a specified number of threads (possibly 0) to + * serve the tasks. If there are no threads, you must call poll() from time + * to time to serve the tasks in the main thread. Normally this is done by + * calling AsyncTaskManager::poll(). + * + * Each task will run exactly once each epoch. Beyond that, the tasks' sort + * and priority values control the order in which they are run: tasks are run + * in increasing order by sort value, and within the same sort value, they are + * run roughly in decreasing order by priority value, with some exceptions for + * parallelism. Tasks with different sort values are never run in parallel + * together, but tasks with different priority values might be (if there is + * more than one thread). + */ class EXPCL_PANDA_EVENT AsyncTaskChain : public TypedReferenceCount, public Namable { public: AsyncTaskChain(AsyncTaskManager *manager, const string &name); @@ -143,7 +136,7 @@ protected: return AsyncTaskChain::get_wake_time(a) > AsyncTaskChain::get_wake_time(b); } }; - + class AsyncTaskSortPriority { public: bool operator () (AsyncTask *a, AsyncTask *b) const { @@ -191,7 +184,7 @@ protected: int _current_frame; double _time_in_frame; bool _block_till_next_frame; - + static PStatCollector _task_pcollector; static PStatCollector _wait_pcollector; diff --git a/panda/src/event/asyncTaskCollection.I b/panda/src/event/asyncTaskCollection.I index 9eb5a3fa04..a56da8dd7d 100644 --- a/panda/src/event/asyncTaskCollection.I +++ b/panda/src/event/asyncTaskCollection.I @@ -1,43 +1,35 @@ -// Filename: asyncTaskCollection.I -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskCollection.I + * @author drose + * @date 2008-09-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AsyncTaskCollection:: ~AsyncTaskCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void AsyncTaskCollection:: operator += (const AsyncTaskCollection &other) { add_tasks_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::operator + -// Access: Published -// Description: Returns a AsyncTaskCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a AsyncTaskCollection representing the concatenation of the two + * lists. + */ INLINE AsyncTaskCollection AsyncTaskCollection:: operator + (const AsyncTaskCollection &other) const { AsyncTaskCollection a(*this); diff --git a/panda/src/event/asyncTaskCollection.cxx b/panda/src/event/asyncTaskCollection.cxx index 0d8f50b3f3..38a07c6875 100644 --- a/panda/src/event/asyncTaskCollection.cxx +++ b/panda/src/event/asyncTaskCollection.cxx @@ -1,61 +1,51 @@ -// Filename: asyncTaskCollection.cxx -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskCollection.cxx + * @author drose + * @date 2008-09-16 + */ #include "asyncTaskCollection.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskCollection:: AsyncTaskCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskCollection:: AsyncTaskCollection(const AsyncTaskCollection ©) : _tasks(copy._tasks) { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskCollection:: operator = (const AsyncTaskCollection ©) { _tasks = copy._tasks; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::add_task -// Access: Published -// Description: Adds a new AsyncTask to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new AsyncTask to the collection. + */ void AsyncTaskCollection:: add_task(AsyncTask *task) { // If the pointer to our internal array is shared by any other // AsyncTaskCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren AsyncTaskCollection - // objects. + // inadvertently modify any of our brethren AsyncTaskCollection objects. nassertv(task != (AsyncTask *)NULL); if (_tasks.get_ref_count() > 1) { @@ -67,13 +57,10 @@ add_task(AsyncTask *task) { _tasks.push_back(task); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::remove_task -// Access: Published -// Description: Removes the indicated AsyncTask from the collection. -// Returns true if the task was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated AsyncTask from the collection. Returns true if the + * task was removed, false if it was not a member of the collection. + */ bool AsyncTaskCollection:: remove_task(AsyncTask *task) { int task_index = -1; @@ -90,8 +77,7 @@ remove_task(AsyncTask *task) { // If the pointer to our internal array is shared by any other // AsyncTaskCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren AsyncTaskCollection - // objects. + // inadvertently modify any of our brethren AsyncTaskCollection objects. if (_tasks.get_ref_count() > 1) { AsyncTasks old_tasks = _tasks; @@ -103,14 +89,11 @@ remove_task(AsyncTask *task) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::add_tasks_from -// Access: Published -// Description: Adds all the AsyncTasks indicated in the other -// collection to this task. The other tasks are simply -// appended to the end of the tasks in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the AsyncTasks indicated in the other collection to this task. + * The other tasks are simply appended to the end of the tasks in this list; + * duplicates are not automatically removed. + */ void AsyncTaskCollection:: add_tasks_from(const AsyncTaskCollection &other) { int other_num_tasks = other.get_num_tasks(); @@ -120,12 +103,10 @@ add_tasks_from(const AsyncTaskCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::remove_tasks_from -// Access: Published -// Description: Removes from this collection all of the AsyncTasks -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the AsyncTasks listed in the other + * collection. + */ void AsyncTaskCollection:: remove_tasks_from(const AsyncTaskCollection &other) { AsyncTasks new_tasks; @@ -139,14 +120,11 @@ remove_tasks_from(const AsyncTaskCollection &other) { _tasks = new_tasks; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::remove_duplicate_tasks -// Access: Published -// Description: Removes any duplicate entries of the same AsyncTasks -// on this collection. If a AsyncTask appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same AsyncTasks on this collection. + * If a AsyncTask appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void AsyncTaskCollection:: remove_duplicate_tasks() { AsyncTasks new_tasks; @@ -168,12 +146,10 @@ remove_duplicate_tasks() { _tasks = new_tasks; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::has_task -// Access: Published -// Description: Returns true if the indicated AsyncTask appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated AsyncTask appears in this collection, false + * otherwise. + */ bool AsyncTaskCollection:: has_task(AsyncTask *task) const { for (int i = 0; i < get_num_tasks(); i++) { @@ -184,23 +160,18 @@ has_task(AsyncTask *task) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::clear -// Access: Published -// Description: Removes all AsyncTasks from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all AsyncTasks from the collection. + */ void AsyncTaskCollection:: clear() { _tasks.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::find_task -// Access: Published -// Description: Returns the task in the collection with the -// indicated name, if any, or NULL if no task has -// that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the task in the collection with the indicated name, if any, or NULL + * if no task has that name. + */ AsyncTask *AsyncTaskCollection:: find_task(const string &name) const { int num_tasks = get_num_tasks(); @@ -213,21 +184,17 @@ find_task(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::get_num_tasks -// Access: Published -// Description: Returns the number of AsyncTasks in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of AsyncTasks in the collection. + */ int AsyncTaskCollection:: get_num_tasks() const { return _tasks.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::get_task -// Access: Published -// Description: Returns the nth AsyncTask in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth AsyncTask in the collection. + */ AsyncTask *AsyncTaskCollection:: get_task(int index) const { nassertr(index >= 0 && index < (int)_tasks.size(), NULL); @@ -235,17 +202,14 @@ get_task(int index) const { return _tasks[index]; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::remove_task -// Access: Published -// Description: Removes the nth AsyncTask from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth AsyncTask from the collection. + */ void AsyncTaskCollection:: remove_task(int index) { // If the pointer to our internal array is shared by any other // AsyncTaskCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren AsyncTaskCollection - // objects. + // inadvertently modify any of our brethren AsyncTaskCollection objects. if (_tasks.get_ref_count() > 1) { AsyncTasks old_tasks = _tasks; @@ -257,13 +221,10 @@ remove_task(int index) { _tasks.erase(_tasks.begin() + index); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::operator [] -// Access: Published -// Description: Returns the nth AsyncTask in the collection. This is -// the same as get_task(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth AsyncTask in the collection. This is the same as + * get_task(), but it may be a more convenient way to access it. + */ AsyncTask *AsyncTaskCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_tasks.size(), NULL); @@ -271,23 +232,19 @@ operator [] (int index) const { return _tasks[index]; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::size -// Access: Published -// Description: Returns the number of tasks in the collection. This -// is the same thing as get_num_tasks(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of tasks in the collection. This is the same thing as + * get_num_tasks(). + */ int AsyncTaskCollection:: size() const { return _tasks.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// AsyncTaskCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the AsyncTaskCollection to the + * indicated output stream. + */ void AsyncTaskCollection:: output(ostream &out) const { if (get_num_tasks() == 1) { @@ -297,12 +254,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// AsyncTaskCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the AsyncTaskCollection to the + * indicated output stream. + */ void AsyncTaskCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_tasks(); i++) { diff --git a/panda/src/event/asyncTaskCollection.h b/panda/src/event/asyncTaskCollection.h index 29c743bc45..824ec433c2 100644 --- a/panda/src/event/asyncTaskCollection.h +++ b/panda/src/event/asyncTaskCollection.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskCollection.h -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskCollection.h + * @author drose + * @date 2008-09-16 + */ #ifndef ASYNCTASKCOLLECTION_H #define ASYNCTASKCOLLECTION_H @@ -19,14 +18,12 @@ #include "pointerToArray.h" #include "asyncTask.h" -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskCollection -// Description : A list of tasks, for instance as returned by some of -// the AsyncTaskManager query functions. This also -// serves to define an AsyncTaskSequence. -// -// TODO: None of this is thread-safe yet. -//////////////////////////////////////////////////////////////////// +/** + * A list of tasks, for instance as returned by some of the AsyncTaskManager + * query functions. This also serves to define an AsyncTaskSequence. + * + * TODO: None of this is thread-safe yet. + */ class EXPCL_PANDA_PGRAPH AsyncTaskCollection { PUBLISHED: AsyncTaskCollection(); @@ -69,5 +66,3 @@ INLINE ostream &operator << (ostream &out, const AsyncTaskCollection &col) { #include "asyncTaskCollection.I" #endif - - diff --git a/panda/src/event/asyncTaskManager.I b/panda/src/event/asyncTaskManager.I index 88a473db93..20294f63dc 100644 --- a/panda/src/event/asyncTaskManager.I +++ b/panda/src/event/asyncTaskManager.I @@ -1,64 +1,51 @@ -// Filename: asyncTaskManager.I -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskManager.I + * @author drose + * @date 2006-08-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::set_clock -// Access: Published -// Description: Replaces the clock pointer used within the -// AsyncTaskManager. This is used to control when tasks -// with a set_delay() specified will be scheduled. It -// can also be ticked automatically each epoch, if -// set_tick_clock() is true. -// -// The default is the global clock pointer. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the clock pointer used within the AsyncTaskManager. This is used + * to control when tasks with a set_delay() specified will be scheduled. It + * can also be ticked automatically each epoch, if set_tick_clock() is true. + * + * The default is the global clock pointer. + */ INLINE void AsyncTaskManager:: set_clock(ClockObject *clock) { _clock = clock; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_clock -// Access: Published -// Description: Returns the clock pointer used within the -// AsyncTaskManager. See set_clock(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the clock pointer used within the AsyncTaskManager. See + * set_clock(). + */ INLINE ClockObject *AsyncTaskManager:: get_clock() { return _clock; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_num_tasks -// Access: Published -// Description: Returns the number of tasks that are currently active -// or sleeping within the task manager. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of tasks that are currently active or sleeping within + * the task manager. + */ INLINE int AsyncTaskManager:: get_num_tasks() const { MutexHolder holder(_lock); return _num_tasks; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_global_ptr -// Access: Published -// Description: Returns a pointer to the global AsyncTaskManager. -// This is the AsyncTaskManager that most code should -// use for queueing tasks and suchlike. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global AsyncTaskManager. This is the + * AsyncTaskManager that most code should use for queueing tasks and suchlike. + */ INLINE AsyncTaskManager *AsyncTaskManager:: get_global_ptr() { if (_global_ptr == (AsyncTaskManager *)NULL) { @@ -67,12 +54,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::add_task_by_name -// Access: Protected -// Description: Adds the task to the _tasks_by_name index, if it has -// a nonempty name. -//////////////////////////////////////////////////////////////////// +/** + * Adds the task to the _tasks_by_name index, if it has a nonempty name. + */ INLINE void AsyncTaskManager:: add_task_by_name(AsyncTask *task) { if (!task->get_name().empty()) { diff --git a/panda/src/event/asyncTaskManager.cxx b/panda/src/event/asyncTaskManager.cxx index 155efc8755..b95ddbf109 100644 --- a/panda/src/event/asyncTaskManager.cxx +++ b/panda/src/event/asyncTaskManager.cxx @@ -1,16 +1,15 @@ -// Filename: asyncTaskManager.cxx -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskManager.cxx + * @author drose + * @date 2006-08-23 + */ #include "asyncTaskManager.h" #include "event.h" @@ -27,11 +26,9 @@ AsyncTaskManager *AsyncTaskManager::_global_ptr = NULL; TypeHandle AsyncTaskManager::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskManager:: AsyncTaskManager(const string &name) : Namable(name), @@ -44,22 +41,18 @@ AsyncTaskManager(const string &name) : do_make_task_chain("default"); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskManager:: ~AsyncTaskManager() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::cleanup -// Access: Published -// Description: Stops all threads and messily empties the task list. -// This is intended to be called on destruction only. -//////////////////////////////////////////////////////////////////// +/** + * Stops all threads and messily empties the task list. This is intended to + * be called on destruction only. + */ void AsyncTaskManager:: cleanup() { MutexHolder holder(_lock); @@ -78,19 +71,18 @@ cleanup() { chain->do_cleanup(); } - // There might be one remaining task, the current task. Especially - // if it wasn't running on a thread. + // There might be one remaining task, the current task. Especially if it + // wasn't running on a thread. if (_num_tasks == 1) { nassertv(_tasks_by_name.size() == 1); TasksByName::const_iterator tbni = _tasks_by_name.begin(); AsyncTask *task = (*tbni); - nassertv(task->_state == AsyncTask::S_servicing || + nassertv(task->_state == AsyncTask::S_servicing || task->_state == AsyncTask::S_servicing_removed); task->_state = AsyncTask::S_servicing_removed; } else { - // If there isn't exactly one remaining task, there should be - // none. + // If there isn't exactly one remaining task, there should be none. #ifndef NDEBUG nassertd(_num_tasks == 0 && _tasks_by_name.empty()) { task_cat.error() @@ -107,22 +99,18 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_num_task_chains -// Access: Published -// Description: Returns the number of different task chains. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different task chains. + */ int AsyncTaskManager:: get_num_task_chains() const { MutexHolder holder(_lock); return _task_chains.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_task_chain -// Access: Published -// Description: Returns the nth task chain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth task chain. + */ AsyncTaskChain *AsyncTaskManager:: get_task_chain(int n) const { MutexHolder holder(_lock); @@ -130,42 +118,33 @@ get_task_chain(int n) const { return _task_chains[n]; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::make_task_chain -// Access: Published -// Description: Creates a new AsyncTaskChain of the indicated name -// and stores it within the AsyncTaskManager. If a task -// chain with this name already exists, returns it -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AsyncTaskChain of the indicated name and stores it within the + * AsyncTaskManager. If a task chain with this name already exists, returns + * it instead. + */ AsyncTaskChain *AsyncTaskManager:: make_task_chain(const string &name) { MutexHolder holder(_lock); return do_make_task_chain(name); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::find_task_chain -// Access: Protected -// Description: Searches a new AsyncTaskChain of the indicated name -// and returns it if it exists, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Searches a new AsyncTaskChain of the indicated name and returns it if it + * exists, or NULL otherwise. + */ AsyncTaskChain *AsyncTaskManager:: find_task_chain(const string &name) { MutexHolder holder(_lock); return do_find_task_chain(name); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::remove_task_chain -// Access: Protected -// Description: Removes the AsyncTaskChain of the indicated name. -// If the chain still has tasks, this will block until -// all tasks are finished. -// -// Returns true if successful, or false if the chain did -// not exist. -//////////////////////////////////////////////////////////////////// +/** + * Removes the AsyncTaskChain of the indicated name. If the chain still has + * tasks, this will block until all tasks are finished. + * + * Returns true if successful, or false if the chain did not exist. + */ bool AsyncTaskManager:: remove_task_chain(const string &name) { MutexHolder holder(_lock); @@ -192,34 +171,31 @@ remove_task_chain(const string &name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::add -// Access: Published -// Description: Adds the indicated task to the active queue. It is -// an error if the task is already added to this or any -// other active queue. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated task to the active queue. It is an error if the task is + * already added to this or any other active queue. + */ void AsyncTaskManager:: add(AsyncTask *task) { nassertv(task->is_runnable()); { MutexHolder holder(_lock); - + if (task_cat.is_debug()) { task_cat.debug() << "Adding " << *task << "\n"; } - + if (task->_state == AsyncTask::S_servicing_removed) { if (task->_manager == this) { - // Re-adding a self-removed task; this just means clearing the - // removed flag. + // Re-adding a self-removed task; this just means clearing the removed + // flag. task->_state = AsyncTask::S_servicing; return; } } - + nassertv(task->_manager == NULL && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); @@ -230,7 +206,7 @@ add(AsyncTask *task) { nassertv(task->_manager == NULL && task->_state == AsyncTask::S_inactive); nassertv(!do_has_task(task)); - + AsyncTaskChain *chain = do_find_task_chain(task->_chain_name); if (chain == (AsyncTaskChain *)NULL) { task_cat.warning() @@ -242,12 +218,10 @@ add(AsyncTask *task) { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::has_task -// Access: Published -// Description: Returns true if the indicated task has been added to -// this AsyncTaskManager, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated task has been added to this AsyncTaskManager, + * false otherwise. + */ bool AsyncTaskManager:: has_task(AsyncTask *task) const { MutexHolder holder(_lock); @@ -261,20 +235,18 @@ has_task(AsyncTask *task) const { return false; } - // The task might not actually be in the active queue, since it - // might be being serviced right now. That's OK. + // The task might not actually be in the active queue, since it might be + // being serviced right now. That's OK. return true; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::find_task -// Access: Published -// Description: Returns the first task found with the indicated name, -// or NULL if there is no task with the indicated name. -// -// If there are multiple tasks with the same name, -// returns one of them arbitrarily. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first task found with the indicated name, or NULL if there is + * no task with the indicated name. + * + * If there are multiple tasks with the same name, returns one of them + * arbitrarily. + */ AsyncTask *AsyncTaskManager:: find_task(const string &name) const { AsyncTask sample_task(name); @@ -288,12 +260,9 @@ find_task(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::find_tasks -// Access: Published -// Description: Returns the list of tasks found with the indicated -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of tasks found with the indicated name. + */ AsyncTaskCollection AsyncTaskManager:: find_tasks(const string &name) const { AsyncTask sample_task(name); @@ -309,12 +278,10 @@ find_tasks(const string &name) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::find_tasks_matching -// Access: Published -// Description: Returns the list of tasks found whose name matches -// the indicated glob pattern, e.g. "my_task_*". -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of tasks found whose name matches the indicated glob + * pattern, e.g. "my_task_*". + */ AsyncTaskCollection AsyncTaskManager:: find_tasks_matching(const GlobPattern &pattern) const { string prefix = pattern.get_const_prefix(); @@ -334,29 +301,23 @@ find_tasks_matching(const GlobPattern &pattern) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::remove -// Access: Published -// Description: Removes the indicated task from the active queue. -// Returns true if the task is successfully removed, or -// false if it wasn't there. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated task from the active queue. Returns true if the task + * is successfully removed, or false if it wasn't there. + */ bool AsyncTaskManager:: remove(AsyncTask *task) { - // We pass this up to the multi-task remove() flavor. Do we care - // about the tiny cost of creating an AsyncTaskCollection here? - // Probably not. + // We pass this up to the multi-task remove() flavor. Do we care about the + // tiny cost of creating an AsyncTaskCollection here? Probably not. AsyncTaskCollection tasks; tasks.add_task(task); return remove(tasks) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::remove -// Access: Published -// Description: Removes all of the tasks in the AsyncTaskCollection. -// Returns the number of tasks removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the tasks in the AsyncTaskCollection. Returns the number of + * tasks removed. + */ int AsyncTaskManager:: remove(const AsyncTaskCollection &tasks) { MutexHolder holder(_lock); @@ -366,7 +327,7 @@ remove(const AsyncTaskCollection &tasks) { int i; for (i = 0; i < num_tasks; ++i) { PT(AsyncTask) task = tasks.get_task(i); - + if (task->_manager != this) { // Not a member of this manager, or already removed. nassertr(!do_has_task(task), num_removed); @@ -393,20 +354,18 @@ remove(const AsyncTaskCollection &tasks) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::wait_for_tasks -// Access: Published -// Description: Blocks until the task list is empty. -//////////////////////////////////////////////////////////////////// +/** + * Blocks until the task list is empty. + */ void AsyncTaskManager:: wait_for_tasks() { MutexHolder holder(_lock); // Wait for each of our task chains to finish. while (_num_tasks > 0) { - // We iterate through with an index, rather than with an iterator, - // because it's possible for a task to adjust the task_chain list - // during its execution. + // We iterate through with an index, rather than with an iterator, because + // it's possible for a task to adjust the task_chain list during its + // execution. for (unsigned int i = 0; i < _task_chains.size(); ++i) { AsyncTaskChain *chain = _task_chains[i]; chain->do_wait_for_tasks(); @@ -414,41 +373,36 @@ wait_for_tasks() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::stop_threads -// Access: Published -// Description: Stops any threads that are currently running. If any -// tasks are still pending and have not yet been picked -// up by a thread, they will not be serviced unless -// poll() or start_threads() is later called. -//////////////////////////////////////////////////////////////////// +/** + * Stops any threads that are currently running. If any tasks are still + * pending and have not yet been picked up by a thread, they will not be + * serviced unless poll() or start_threads() is later called. + */ void AsyncTaskManager:: stop_threads() { MutexHolder holder(_lock); - // We iterate through with an index, rather than with an iterator, - // because it's possible for a task to adjust the task_chain list - // during its execution. + // We iterate through with an index, rather than with an iterator, because + // it's possible for a task to adjust the task_chain list during its + // execution. for (unsigned int i = 0; i < _task_chains.size(); ++i) { AsyncTaskChain *chain = _task_chains[i]; chain->do_stop_threads(); } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::start_threads -// Access: Published -// Description: Starts any requested threads to service the tasks on -// the queue. This is normally not necessary, since -// adding a task will start the threads automatically. -//////////////////////////////////////////////////////////////////// +/** + * Starts any requested threads to service the tasks on the queue. This is + * normally not necessary, since adding a task will start the threads + * automatically. + */ void AsyncTaskManager:: start_threads() { MutexHolder holder(_lock); - // We iterate through with an index, rather than with an iterator, - // because it's possible for a task to adjust the task_chain list - // during its execution. + // We iterate through with an index, rather than with an iterator, because + // it's possible for a task to adjust the task_chain list during its + // execution. for (unsigned int i = 0; i < _task_chains.size(); ++i) { AsyncTaskChain *chain = _task_chains[i]; @@ -456,12 +410,10 @@ start_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_tasks -// Access: Published -// Description: Returns the set of tasks that are active or sleeping -// on the task manager, at the time of the call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are active or sleeping on the task manager, + * at the time of the call. + */ AsyncTaskCollection AsyncTaskManager:: get_tasks() const { MutexHolder holder(_lock); @@ -479,13 +431,10 @@ get_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_active_tasks -// Access: Published -// Description: Returns the set of tasks that are active (and not -// sleeping) on the task manager, at the time of the -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are active (and not sleeping) on the task + * manager, at the time of the call. + */ AsyncTaskCollection AsyncTaskManager:: get_active_tasks() const { MutexHolder holder(_lock); @@ -502,13 +451,10 @@ get_active_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_sleeping_tasks -// Access: Published -// Description: Returns the set of tasks that are sleeping (and not -// active) on the task manager, at the time of the -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tasks that are sleeping (and not active) on the task + * manager, at the time of the call. + */ AsyncTaskCollection AsyncTaskManager:: get_sleeping_tasks() const { MutexHolder holder(_lock); @@ -525,39 +471,33 @@ get_sleeping_tasks() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::poll -// Access: Published -// Description: Runs through all the tasks in the task list, once, if -// the task manager is running in single-threaded mode -// (no threads available). This method does nothing in -// threaded mode, so it may safely be called in either -// case. -//////////////////////////////////////////////////////////////////// +/** + * Runs through all the tasks in the task list, once, if the task manager is + * running in single-threaded mode (no threads available). This method does + * nothing in threaded mode, so it may safely be called in either case. + */ void AsyncTaskManager:: poll() { MutexHolder holder(_lock); - // We iterate through with an index, rather than with an iterator, - // because it's possible for a task to adjust the task_chain list - // during its execution. + // We iterate through with an index, rather than with an iterator, because + // it's possible for a task to adjust the task_chain list during its + // execution. for (unsigned int i = 0; i < _task_chains.size(); ++i) { AsyncTaskChain *chain = _task_chains[i]; chain->do_poll(); } - // Just in case the clock was ticked explicitly by one of our - // polling chains. + // Just in case the clock was ticked explicitly by one of our polling + // chains. _frame_cvar.notify_all(); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::get_next_wake_time -// Access: Published -// Description: Returns the scheduled time (on the manager's clock) -// of the next sleeping task, on any task chain, to -// awaken. Returns -1 if there are no sleeping tasks. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scheduled time (on the manager's clock) of the next sleeping + * task, on any task chain, to awaken. Returns -1 if there are no sleeping + * tasks. + */ double AsyncTaskManager:: get_next_wake_time() const { MutexHolder holder(_lock); @@ -584,22 +524,18 @@ get_next_wake_time() const { return next_wake_time; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskManager:: output(ostream &out) const { MutexHolder holder(_lock); do_output(out); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskManager:: write(ostream &out, int indent_level) const { MutexHolder holder(_lock); @@ -618,16 +554,13 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::do_make_task_chain -// Access: Protected -// Description: Creates a new AsyncTaskChain of the indicated name -// and stores it within the AsyncTaskManager. If a task -// chain with this name already exists, returns it -// instead. -// -// Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new AsyncTaskChain of the indicated name and stores it within the + * AsyncTaskManager. If a task chain with this name already exists, returns + * it instead. + * + * Assumes the lock is held. + */ AsyncTaskChain *AsyncTaskManager:: do_make_task_chain(const string &name) { PT(AsyncTaskChain) chain = new AsyncTaskChain(this, name); @@ -636,14 +569,12 @@ do_make_task_chain(const string &name) { return (*tci); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::do_find_task_chain -// Access: Protected -// Description: Searches a new AsyncTaskChain of the indicated name -// and returns it if it exists, or NULL otherwise. -// -// Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Searches a new AsyncTaskChain of the indicated name and returns it if it + * exists, or NULL otherwise. + * + * Assumes the lock is held. + */ AsyncTaskChain *AsyncTaskManager:: do_find_task_chain(const string &name) { PT(AsyncTaskChain) chain = new AsyncTaskChain(this, name); @@ -656,17 +587,13 @@ do_find_task_chain(const string &name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::remove_task_by_name -// Access: Protected -// Description: Removes the task from the _tasks_by_name index, if it -// has a nonempty name. -//////////////////////////////////////////////////////////////////// +/** + * Removes the task from the _tasks_by_name index, if it has a nonempty name. + */ void AsyncTaskManager:: remove_task_by_name(AsyncTask *task) { if (!task->get_name().empty()) { - // We have to scan linearly through all of the tasks with the same - // name. + // We have to scan linearly through all of the tasks with the same name. TasksByName::iterator tbni = _tasks_by_name.lower_bound(task); while (tbni != _tasks_by_name.end()) { if ((*tbni) == task) { @@ -677,7 +604,7 @@ remove_task_by_name(AsyncTask *task) { // Too far. break; } - + ++tbni; } @@ -686,14 +613,11 @@ remove_task_by_name(AsyncTask *task) { } } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::do_has_task -// Access: Protected -// Description: Returns true if the task is on one of the task lists, -// false if it is not (false may mean that the task is -// currently being serviced). Assumes the lock is -// currently held. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the task is on one of the task lists, false if it is not + * (false may mean that the task is currently being serviced). Assumes the + * lock is currently held. + */ bool AsyncTaskManager:: do_has_task(AsyncTask *task) const { TaskChains::const_iterator tci; @@ -709,23 +633,18 @@ do_has_task(AsyncTask *task) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::do_output -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AsyncTaskManager:: do_output(ostream &out) const { out << get_type() << " " << get_name() << "; " << _num_tasks << " tasks"; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskManager::make_global_ptr -// Access: Private, Static -// Description: Called once per application to create the global -// task manager object. -//////////////////////////////////////////////////////////////////// +/** + * Called once per application to create the global task manager object. + */ void AsyncTaskManager:: make_global_ptr() { nassertv(_global_ptr == (AsyncTaskManager *)NULL); diff --git a/panda/src/event/asyncTaskManager.h b/panda/src/event/asyncTaskManager.h index 91b5dfffba..e8cdc220b7 100644 --- a/panda/src/event/asyncTaskManager.h +++ b/panda/src/event/asyncTaskManager.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskManager.h -// Created by: drose (23Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskManager.h + * @author drose + * @date 2006-08-23 + */ #ifndef ASYNCTASKMANAGER_H #define ASYNCTASKMANAGER_H @@ -32,25 +31,20 @@ #include "ordered_vector.h" #include "indirectCompareNames.h" -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskManager -// Description : A class to manage a loose queue of isolated tasks, -// which can be performed either synchronously (in the -// foreground thread) or asynchronously (by a background -// thread). -// -// The AsyncTaskManager is actually a collection of -// AsyncTaskChains, each of which maintains a list of -// tasks. Each chain can be either foreground or -// background (it may run only in the main thread, or it -// may be serviced by one or more background threads). -// See AsyncTaskChain for more information. -// -// If you do not require background processing, it is -// perfectly acceptable to create only one -// AsyncTaskChain, which runs in the main thread. This -// is a common configuration. -//////////////////////////////////////////////////////////////////// +/** + * A class to manage a loose queue of isolated tasks, which can be performed + * either synchronously (in the foreground thread) or asynchronously (by a + * background thread). + * + * The AsyncTaskManager is actually a collection of AsyncTaskChains, each of + * which maintains a list of tasks. Each chain can be either foreground or + * background (it may run only in the main thread, or it may be serviced by + * one or more background threads). See AsyncTaskChain for more information. + * + * If you do not require background processing, it is perfectly acceptable to + * create only one AsyncTaskChain, which runs in the main thread. This is a + * common configuration. + */ class EXPCL_PANDA_EVENT AsyncTaskManager : public TypedReferenceCount, public Namable { PUBLISHED: AsyncTaskManager(const string &name); @@ -121,9 +115,9 @@ protected: typedef pmultiset TasksByName; - // Protects all the following members. This same lock is also used - // to protect all of our AsyncTaskChain members. - Mutex _lock; + // Protects all the following members. This same lock is also used to + // protect all of our AsyncTaskChain members. + Mutex _lock; typedef ov_set > TaskChains; TaskChains _task_chains; @@ -131,7 +125,7 @@ protected: int _num_tasks; TasksByName _tasks_by_name; PT(ClockObject) _clock; - + ConditionVarFull _frame_cvar; // Signalled when the clock ticks. static AsyncTaskManager* _global_ptr; diff --git a/panda/src/event/asyncTaskPause.I b/panda/src/event/asyncTaskPause.I index 33e46c4717..29220de458 100644 --- a/panda/src/event/asyncTaskPause.I +++ b/panda/src/event/asyncTaskPause.I @@ -1,14 +1,12 @@ -// Filename: asyncTaskPause.I -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskPause.I + * @author drose + * @date 2008-10-04 + */ diff --git a/panda/src/event/asyncTaskPause.cxx b/panda/src/event/asyncTaskPause.cxx index 3a7367e950..c6f1aeb8d3 100644 --- a/panda/src/event/asyncTaskPause.cxx +++ b/panda/src/event/asyncTaskPause.cxx @@ -1,26 +1,23 @@ -// Filename: asyncTaskPause.cxx -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskPause.cxx + * @author drose + * @date 2008-10-04 + */ #include "asyncTaskPause.h" TypeHandle AsyncTaskPause::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskPause::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskPause:: AsyncTaskPause(double delay) : AsyncTask("pause") @@ -28,14 +25,11 @@ AsyncTaskPause(double delay) : set_delay(delay); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskPause::do_task -// Access: Protected, Virtual -// Description: Override this function to do something useful for the -// task. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful for the task. + * + * This function is called with the lock *not* held. + */ AsyncTask::DoneStatus AsyncTaskPause:: do_task() { return DS_pause; diff --git a/panda/src/event/asyncTaskPause.h b/panda/src/event/asyncTaskPause.h index 5106a3a3f1..8bbfe9f245 100644 --- a/panda/src/event/asyncTaskPause.h +++ b/panda/src/event/asyncTaskPause.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskPause.h -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskPause.h + * @author drose + * @date 2008-10-04 + */ #ifndef ASYNCTASKPAUSE_H #define ASYNCTASKPAUSE_H @@ -21,13 +20,11 @@ class AsyncTaskManager; -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskPause -// Description : A special kind of task that simple returns DS_pause, -// to pause for a specified number of seconds and then -// finish. It's intended to be used within an -// AsyncTaskSequence. -//////////////////////////////////////////////////////////////////// +/** + * A special kind of task that simple returns DS_pause, to pause for a + * specified number of seconds and then finish. It's intended to be used + * within an AsyncTaskSequence. + */ class EXPCL_PANDA_EVENT AsyncTaskPause : public AsyncTask { PUBLISHED: AsyncTaskPause(double delay); @@ -57,4 +54,3 @@ private: #include "asyncTaskPause.I" #endif - diff --git a/panda/src/event/asyncTaskSequence.I b/panda/src/event/asyncTaskSequence.I index b11730aba6..28d94f2f75 100644 --- a/panda/src/event/asyncTaskSequence.I +++ b/panda/src/event/asyncTaskSequence.I @@ -1,50 +1,39 @@ -// Filename: asyncTaskSequence.I -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskSequence.I + * @author drose + * @date 2008-10-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::set_repeat_count -// Access: Published -// Description: Sets the repeat count of the sequence. If the count -// is 0 or 1, the sequence will run exactly once. If it -// is greater than 0, it will run that number of times. -// If it is negative, it will run forever until it is -// explicitly removed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the repeat count of the sequence. If the count is 0 or 1, the + * sequence will run exactly once. If it is greater than 0, it will run that + * number of times. If it is negative, it will run forever until it is + * explicitly removed. + */ INLINE void AsyncTaskSequence:: set_repeat_count(int repeat_count) { _repeat_count = repeat_count; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::get_repeat_count -// Access: Published -// Description: Returns the repeat count of the sequence. See -// set_repeat_count(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the repeat count of the sequence. See set_repeat_count(). + */ INLINE int AsyncTaskSequence:: get_repeat_count() const { return _repeat_count; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::get_current_task_index -// Access: Published -// Description: Returns the index of the task within the sequence -// that is currently being executed (or that will be -// executed at the next epoch). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the task within the sequence that is currently being + * executed (or that will be executed at the next epoch). + */ INLINE int AsyncTaskSequence:: get_current_task_index() const { return _task_index; diff --git a/panda/src/event/asyncTaskSequence.cxx b/panda/src/event/asyncTaskSequence.cxx index 819a4f8ee5..e8713ca05e 100644 --- a/panda/src/event/asyncTaskSequence.cxx +++ b/panda/src/event/asyncTaskSequence.cxx @@ -1,27 +1,24 @@ -// Filename: asyncTaskSequence.cxx -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskSequence.cxx + * @author drose + * @date 2008-10-04 + */ #include "asyncTaskSequence.h" #include "asyncTaskManager.h" TypeHandle AsyncTaskSequence::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskSequence:: AsyncTaskSequence(const string &name) : AsyncTask(name), @@ -30,39 +27,31 @@ AsyncTaskSequence(const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskSequence:: ~AsyncTaskSequence() { set_current_task(NULL, true); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::is_runnable -// Access: Protected, Virtual -// Description: Override this function to return true if the task can -// be successfully executed, false if it cannot. Mainly -// intended as a sanity check when attempting to add the -// task to a task manager. -// -// This function is called with the lock held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to return true if the task can be successfully + * executed, false if it cannot. Mainly intended as a sanity check when + * attempting to add the task to a task manager. + * + * This function is called with the lock held. + */ bool AsyncTaskSequence:: is_runnable() { return (get_num_tasks() > 0); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::do_task -// Access: Protected, Virtual -// Description: Override this function to do something useful for the -// task. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful for the task. + * + * This function is called with the lock *not* held. + */ AsyncTask::DoneStatus AsyncTaskSequence:: do_task() { // Clear the delay that might have been set from a previous wait. @@ -97,7 +86,7 @@ do_task() { { double now = _manager->_clock->get_frame_time(); _current_task->_start_time = now + _current_task->_delay; - + _delay = _current_task->_delay; _has_delay = _current_task->_has_delay; @@ -126,16 +115,13 @@ do_task() { return DS_exit; } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::upon_birth -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been added to the active queue. -// -// This function is called with the lock held. You may -// temporarily release if it necessary, but be sure to -// return with it held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been added + * to the active queue. + * + * This function is called with the lock held. You may temporarily release if + * it necessary, but be sure to return with it held. + */ void AsyncTaskSequence:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); @@ -143,38 +129,29 @@ upon_birth(AsyncTaskManager *manager) { set_current_task(NULL, true); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::upon_death -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been removed from the active queue. The -// parameter clean_exit is true if the task has been -// removed because it exited normally (returning -// DS_done), or false if it was removed for some other -// reason (e.g. AsyncTaskManager::remove()). By the -// time this method is called, _manager has been -// cleared, so the parameter manager indicates the -// original AsyncTaskManager that owned this task. -// -// The normal behavior is to throw the done_event only -// if clean_exit is true. -// -// This function is called with the lock held. You may -// temporarily release if it necessary, but be sure to -// return with it held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been + * removed from the active queue. The parameter clean_exit is true if the + * task has been removed because it exited normally (returning DS_done), or + * false if it was removed for some other reason (e.g. + * AsyncTaskManager::remove()). By the time this method is called, _manager + * has been cleared, so the parameter manager indicates the original + * AsyncTaskManager that owned this task. + * + * The normal behavior is to throw the done_event only if clean_exit is true. + * + * This function is called with the lock held. You may temporarily release if + * it necessary, but be sure to return with it held. + */ void AsyncTaskSequence:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); set_current_task(NULL, clean_exit); } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskSequence::set_current_task -// Access: Private -// Description: Sets the current executing task. If NULL, sets the -// current task to NULL. -//////////////////////////////////////////////////////////////////// +/** + * Sets the current executing task. If NULL, sets the current task to NULL. + */ void AsyncTaskSequence:: set_current_task(AsyncTask *task, bool clean_exit) { if (_current_task == task) { diff --git a/panda/src/event/asyncTaskSequence.h b/panda/src/event/asyncTaskSequence.h index 09285aa961..4cd4d64d58 100644 --- a/panda/src/event/asyncTaskSequence.h +++ b/panda/src/event/asyncTaskSequence.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskSequence.h -// Created by: drose (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskSequence.h + * @author drose + * @date 2008-10-04 + */ #ifndef ASYNCTASKSEQUENCE_H #define ASYNCTASKSEQUENCE_H @@ -22,18 +21,15 @@ class AsyncTaskManager; -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskSequence -// Description : A special kind of task that serves as a list of tasks -// internally. Each task on the list is executed in -// sequence, one per epoch. -// -// This is similar to a Sequence interval, though it has -// some slightly different abilities. For instance, -// although you can't start at any arbitrary point in -// the sequence, you can construct a task sequence whose -// duration changes during playback. -//////////////////////////////////////////////////////////////////// +/** + * A special kind of task that serves as a list of tasks internally. Each + * task on the list is executed in sequence, one per epoch. + * + * This is similar to a Sequence interval, though it has some slightly + * different abilities. For instance, although you can't start at any + * arbitrary point in the sequence, you can construct a task sequence whose + * duration changes during playback. + */ class EXPCL_PANDA_EVENT AsyncTaskSequence : public AsyncTask, public AsyncTaskCollection { PUBLISHED: AsyncTaskSequence(const string &name); @@ -79,4 +75,3 @@ private: #include "asyncTaskSequence.I" #endif - diff --git a/panda/src/event/buttonEvent.I b/panda/src/event/buttonEvent.I index aa228f018a..16c68cc0bc 100644 --- a/panda/src/event/buttonEvent.I +++ b/panda/src/event/buttonEvent.I @@ -1,23 +1,19 @@ -// Filename: buttonEvent.I -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEvent.I + * @author drose + * @date 2000-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEvent:: ButtonEvent() : _button(ButtonHandle::none()), @@ -27,11 +23,9 @@ ButtonEvent() : { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEvent:: ButtonEvent(ButtonHandle button, ButtonEvent::Type type, double time) : _button(button), @@ -43,11 +37,9 @@ ButtonEvent(ButtonHandle button, ButtonEvent::Type type, double time) : { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEvent:: ButtonEvent(short keycode, double time) : _button(ButtonHandle::none()), @@ -59,13 +51,11 @@ ButtonEvent(short keycode, double time) : { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEvent:: -ButtonEvent(const wstring &candidate_string, size_t highlight_start, +ButtonEvent(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) : _button(ButtonHandle::none()), _keycode(0), @@ -78,11 +68,9 @@ ButtonEvent(const wstring &candidate_string, size_t highlight_start, { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEvent:: ButtonEvent(const ButtonEvent ©) : _button(copy._button), @@ -96,11 +84,9 @@ ButtonEvent(const ButtonEvent ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ButtonEvent:: operator = (const ButtonEvent ©) { _button = copy._button; @@ -113,12 +99,9 @@ operator = (const ButtonEvent ©) { _time = copy._time; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Equality Operator -// Access: Public -// Description: The equality operator does not consider time -// significant. -//////////////////////////////////////////////////////////////////// +/** + * The equality operator does not consider time significant. + */ INLINE bool ButtonEvent:: operator == (const ButtonEvent &other) const { return (_button == other._button && @@ -126,21 +109,17 @@ operator == (const ButtonEvent &other) const { _type == other._type); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonEvent:: operator != (const ButtonEvent &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonEvent:: operator < (const ButtonEvent &other) const { if (_button != other._button) { @@ -153,12 +132,10 @@ operator < (const ButtonEvent &other) const { return _type < other._type; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::update_mods -// Access: Published -// Description: Calls button_down() or button_up(), as appropriate, -// according to the ButtonEvent. -//////////////////////////////////////////////////////////////////// +/** + * Calls button_down() or button_up(), as appropriate, according to the + * ButtonEvent. + */ INLINE bool ButtonEvent:: update_mods(ModifierButtons &mods) const { switch (_type) { diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index cc8654cf30..7353ce7e54 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/panda/src/event/buttonEvent.cxx @@ -1,16 +1,15 @@ -// Filename: buttonEvent.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEvent.cxx + * @author drose + * @date 2000-03-01 + */ #include "buttonEvent.h" #include "datagram.h" @@ -18,11 +17,9 @@ #include "buttonRegistry.h" #include "textEncoder.h" -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonEvent:: output(ostream &out) const { switch (_type) { @@ -66,11 +63,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::write_datagram -// Access: Public -// Description: Writes the event into a datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the event into a datagram. + */ void ButtonEvent:: write_datagram(Datagram &dg) const { dg.add_uint8(_type); @@ -82,9 +77,9 @@ write_datagram(Datagram &dg) const { case T_raw_down: case T_raw_up: // We write the button name. This is not particularly compact, but - // presumably we don't get thousands of button events per frame, and - // it is robust as the button index may change between sessions but - // the button name will not. + // presumably we don't get thousands of button events per frame, and it is + // robust as the button index may change between sessions but the button + // name will not. dg.add_string(_button.get_name()); break; @@ -93,9 +88,9 @@ write_datagram(Datagram &dg) const { break; case T_candidate: - // We should probably store the wtext directly in the datagram - // rather than encoding it, but I don't feel like adding - // add_wstring() to datagram right now. + // We should probably store the wtext directly in the datagram rather than + // encoding it, but I don't feel like adding add_wstring() to datagram + // right now. dg.add_string(TextEncoder::encode_wtext(_candidate_string, TextEncoder::get_default_encoding())); dg.add_uint16(_highlight_start); @@ -107,11 +102,9 @@ write_datagram(Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEvent::read_datagram -// Access: Public -// Description: Restores the event from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Restores the event from the datagram. + */ void ButtonEvent:: read_datagram(DatagramIterator &scan) { _type = (Type)scan.get_uint8(); diff --git a/panda/src/event/buttonEvent.h b/panda/src/event/buttonEvent.h index adc395d405..e37c2fe2ad 100644 --- a/panda/src/event/buttonEvent.h +++ b/panda/src/event/buttonEvent.h @@ -1,16 +1,15 @@ -// Filename: buttonEvent.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEvent.h + * @author drose + * @date 2000-03-01 + */ #ifndef BUTTONEVENT_H #define BUTTONEVENT_H @@ -24,72 +23,63 @@ class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : ButtonEvent -// Description : Records a button event of some kind. This is either -// a keyboard or mouse button (or some other kind of -// button) changing state from up to down, or -// vice-versa, or it is a single "keystroke". -// -// A keystroke is different than a button event in that -// (a) it does not necessarily correspond to a physical -// button on a keyboard, but might be the result of a -// combination of buttons (e.g. "A" is the result of -// shift + "a"); and (b) it does not manage separate -// "up" and "down" events, but is itself an -// instantaneous event. -// -// Normal up/down button events can be used to track the -// state of a particular button on the keyboard, while -// keystroke events are best used to monitor what a user -// is attempting to type. -// -// Button up/down events are defined across all the -// physical keys on the keyboard (and other buttons for -// which there is a corresponding ButtonHandle object), -// while keystroke events are defined across the entire -// Unicode character set. -//////////////////////////////////////////////////////////////////// +/** + * Records a button event of some kind. This is either a keyboard or mouse + * button (or some other kind of button) changing state from up to down, or + * vice-versa, or it is a single "keystroke". + * + * A keystroke is different than a button event in that (a) it does not + * necessarily correspond to a physical button on a keyboard, but might be the + * result of a combination of buttons (e.g. "A" is the result of shift + + * "a"); and (b) it does not manage separate "up" and "down" events, but is + * itself an instantaneous event. + * + * Normal up/down button events can be used to track the state of a particular + * button on the keyboard, while keystroke events are best used to monitor + * what a user is attempting to type. + * + * Button up/down events are defined across all the physical keys on the + * keyboard (and other buttons for which there is a corresponding ButtonHandle + * object), while keystroke events are defined across the entire Unicode + * character set. + */ class EXPCL_PANDA_EVENT ButtonEvent { public: enum Type { - // T_down and T_up represent a button changing state - // correspondingly. T_resume_down is a special event that is only - // thrown when focus is returned to a window and a button is - // detected as being held down at that point; it indicates that - // the button should be considered down now (if it wasn't - // already), but it didn't just get pressed down at this moment, - // it was depressed some time ago. It's mainly used for correct - // tracking of modifier keys like shift and control, and can be - // ignored for other keys. +/* + * T_down and T_up represent a button changing state correspondingly. + * T_resume_down is a special event that is only thrown when focus is returned + * to a window and a button is detected as being held down at that point; it + * indicates that the button should be considered down now (if it wasn't + * already), but it didn't just get pressed down at this moment, it was + * depressed some time ago. It's mainly used for correct tracking of modifier + * keys like shift and control, and can be ignored for other keys. + */ T_down, T_resume_down, T_up, - // T_repeat is sent for each a keyrepeat event generated by the - // system, for a button that is continually held down. If you - // want to respect keyrepeat, treat T_down and T_repeat - // equivalently. + // T_repeat is sent for each a keyrepeat event generated by the system, + // for a button that is continually held down. If you want to respect + // keyrepeat, treat T_down and T_repeat equivalently. T_repeat, - // T_keystroke is a special keystroke event, and is sent along - // with a Unicode keycode value, not a ButtonHandle. + // T_keystroke is a special keystroke event, and is sent along with a + // Unicode keycode value, not a ButtonHandle. T_keystroke, - // T_candidate is used to indicate that the user is using the IME - // and has in the process of selecting some possible text to type - // from a menu. + // T_candidate is used to indicate that the user is using the IME and has + // in the process of selecting some possible text to type from a menu. T_candidate, - // T_move is used to indicate that the mouse has moved within the - // current region. Button drag mode needs this, others may ignore - // this event + // T_move is used to indicate that the mouse has moved within the current + // region. Button drag mode needs this, others may ignore this event T_move, - // T_raw_down is usually sent together with T_down, except that - // this is the original, untransformed scan key sent by the keyboard. - // It is not altered by modifier keys and acts as if the user is - // using the US (qwerty) keyboard layout. + // T_raw_down is usually sent together with T_down, except that this is + // the original, untransformed scan key sent by the keyboard. It is not + // altered by modifier keys and acts as if the user is using the US + // (qwerty) keyboard layout. T_raw_down, T_raw_up, }; @@ -97,7 +87,7 @@ public: INLINE ButtonEvent(); INLINE ButtonEvent(ButtonHandle button, Type type, double time = ClockObject::get_global_clock()->get_frame_time()); INLINE ButtonEvent(short keycode, double time = ClockObject::get_global_clock()->get_frame_time()); - INLINE ButtonEvent(const wstring &candidate_string, size_t highlight_start, + INLINE ButtonEvent(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos); INLINE ButtonEvent(const ButtonEvent ©); INLINE void operator = (const ButtonEvent ©); @@ -114,12 +104,11 @@ public: void read_datagram(DatagramIterator &scan); public: - // _button will be filled in if type is T_down, T_resume_down, or - // T_up. + // _button will be filled in if type is T_down, T_resume_down, or T_up. ButtonHandle _button; - // _keycode will be filled in if type is T_keystroke. It will be - // the Unicode character that was typed. + // _keycode will be filled in if type is T_keystroke. It will be the + // Unicode character that was typed. short _keycode; // _candidate_string will be filled in if type is T_candidate. @@ -131,9 +120,9 @@ public: // This is the type of the button event (see above). Type _type; - // This is the time the event occurred, as recorded from the OS if - // that information is available. It is in seconds elapsed from an - // arbitrary epoch, and it matches the time reported by + // This is the time the event occurred, as recorded from the OS if that + // information is available. It is in seconds elapsed from an arbitrary + // epoch, and it matches the time reported by // ClockObject::get_global_clock(). double _time; }; @@ -146,4 +135,3 @@ INLINE ostream &operator << (ostream &out, const ButtonEvent &be) { #include "buttonEvent.I" #endif - diff --git a/panda/src/event/buttonEventList.I b/panda/src/event/buttonEventList.I index f405ac2628..de5b366079 100644 --- a/panda/src/event/buttonEventList.I +++ b/panda/src/event/buttonEventList.I @@ -1,76 +1,61 @@ -// Filename: buttonEventList.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEventList.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEventList:: ButtonEventList() { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonEventList:: ButtonEventList(const ButtonEventList ©) : _events(copy._events) { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ButtonEventList:: operator = (const ButtonEventList ©) { _events = copy._events; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::add_event -// Access: Public -// Description: Adds a new event to the end of the list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new event to the end of the list. + */ INLINE void ButtonEventList:: add_event(ButtonEvent event) { _events.push_back(event); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::get_num_events -// Access: Public -// Description: Returns the number of events in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of events in the list. + */ INLINE int ButtonEventList:: get_num_events() const { return _events.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::get_event -// Access: Public -// Description: Returns the nth event in the list. This does not -// remove the event from the list; the only way to -// remove events is to empty the whole list with -// clear(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth event in the list. This does not remove the event from the + * list; the only way to remove events is to empty the whole list with + * clear(). + */ INLINE const ButtonEvent &ButtonEventList:: get_event(int n) const { #ifndef NDEBUG @@ -80,11 +65,9 @@ get_event(int n) const { return _events[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::clear -// Access: Public -// Description: Empties all the events from the list. -//////////////////////////////////////////////////////////////////// +/** + * Empties all the events from the list. + */ INLINE void ButtonEventList:: clear() { _events.clear(); diff --git a/panda/src/event/buttonEventList.cxx b/panda/src/event/buttonEventList.cxx index f60ffc78b4..633329a5a1 100644 --- a/panda/src/event/buttonEventList.cxx +++ b/panda/src/event/buttonEventList.cxx @@ -1,16 +1,15 @@ -// Filename: buttonEventList.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEventList.cxx + * @author drose + * @date 2002-03-12 + */ #include "buttonEventList.h" #include "modifierButtons.h" @@ -18,12 +17,9 @@ TypeHandle ButtonEventList::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::add_events -// Access: Public -// Description: Appends the events from the other list onto the end -// of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the events from the other list onto the end of this one. + */ void ButtonEventList:: add_events(const ButtonEventList &other) { _events.reserve(_events.size() + other._events.size()); @@ -33,13 +29,10 @@ add_events(const ButtonEventList &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::update_mods -// Access: Public -// Description: Updates the indicated ModifierButtons object with all -// of the button up/down transitions indicated in the -// list. -//////////////////////////////////////////////////////////////////// +/** + * Updates the indicated ModifierButtons object with all of the button up/down + * transitions indicated in the list. + */ void ButtonEventList:: update_mods(ModifierButtons &mods) const { Events::const_iterator ei; @@ -48,11 +41,9 @@ update_mods(ModifierButtons &mods) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonEventList:: output(ostream &out) const { if (_events.empty()) { @@ -70,11 +61,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonEventList:: write(ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; @@ -84,23 +73,18 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void ButtonEventList:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ButtonEventList:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -112,14 +96,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *ButtonEventList:: make_from_bam(const FactoryParams ¶ms) { ButtonEventList *list = new ButtonEventList; @@ -132,18 +113,14 @@ make_from_bam(const FactoryParams ¶ms) { return list; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonEventList::fillin -// Access: Public -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ButtonEventList. -// -// This function is normally protected, but it is -// declared public in this case so that MouseRecorder -// may call it to read a ButtonEventList from the middle -// of a datagram. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ButtonEventList. + * + * This function is normally protected, but it is declared public in this case + * so that MouseRecorder may call it to read a ButtonEventList from the middle + * of a datagram. + */ void ButtonEventList:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/event/buttonEventList.h b/panda/src/event/buttonEventList.h index ead1a5968c..d4f097f98d 100644 --- a/panda/src/event/buttonEventList.h +++ b/panda/src/event/buttonEventList.h @@ -1,16 +1,15 @@ -// Filename: buttonEventList.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonEventList.h + * @author drose + * @date 2002-03-12 + */ #ifndef BUTTONEVENTLIST_H #define BUTTONEVENTLIST_H @@ -26,14 +25,11 @@ class ModifierButtons; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : ButtonEventList -// Description : Records a set of button events that happened -// recently. This class is usually used only in the -// data graph, to transmit the recent button presses, -// but it may be used anywhere a list of ButtonEvents -// is desired. -//////////////////////////////////////////////////////////////////// +/** + * Records a set of button events that happened recently. This class is + * usually used only in the data graph, to transmit the recent button presses, + * but it may be used anywhere a list of ButtonEvents is desired. + */ class EXPCL_PANDA_EVENT ButtonEventList : public ParamValueBase { public: INLINE ButtonEventList(); @@ -91,4 +87,3 @@ INLINE ostream &operator << (ostream &out, const ButtonEventList &buttonlist) { #include "buttonEventList.I" #endif - diff --git a/panda/src/event/config_event.cxx b/panda/src/event/config_event.cxx index aee490825a..0f335981aa 100644 --- a/panda/src/event/config_event.cxx +++ b/panda/src/event/config_event.cxx @@ -1,16 +1,15 @@ -// Filename: config_event.cxx -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_event.cxx + * @author drose + * @date 1999-12-14 + */ #include "config_event.h" #include "asyncTask.h" diff --git a/panda/src/event/config_event.h b/panda/src/event/config_event.h index 4023c9e58b..1133cc55fd 100644 --- a/panda/src/event/config_event.h +++ b/panda/src/event/config_event.h @@ -1,16 +1,15 @@ -// Filename: config_event.h -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_event.h + * @author drose + * @date 1999-12-14 + */ #ifndef CONFIG_EVENT_H #define CONFIG_EVENT_H diff --git a/panda/src/event/event.I b/panda/src/event/event.I index 377e431813..dd2b0e95f6 100644 --- a/panda/src/event/event.I +++ b/panda/src/event/event.I @@ -1,54 +1,44 @@ -// Filename: event.I -// Created by: drose (15May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file event.I + * @author drose + * @date 2001-05-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Event::set_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Event:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: Event::clear_name -// Access: Public -// Description: Resets the Event's name to empty. -//////////////////////////////////////////////////////////////////// +/** + * Resets the Event's name to empty. + */ INLINE void Event:: clear_name() { _name = ""; } -//////////////////////////////////////////////////////////////////// -// Function: Event::has_name -// Access: Public -// Description: Returns true if the Event has a nonempty name set, -// false if the name is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Event has a nonempty name set, false if the name is + * empty. + */ INLINE bool Event:: has_name() const { return !_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Event::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &Event:: get_name() const { return _name; diff --git a/panda/src/event/event.cxx b/panda/src/event/event.cxx index 1f1ae4bc7e..fb510626d2 100644 --- a/panda/src/event/event.cxx +++ b/panda/src/event/event.cxx @@ -1,27 +1,24 @@ -// Filename: event.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file event.cxx + * @author drose + * @date 1999-02-08 + */ #include "event.h" #include "config_event.h" TypeHandle Event::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Event::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Event:: Event(const string &event_name, EventReceiver *receiver) : _name(event_name) @@ -29,11 +26,9 @@ Event(const string &event_name, EventReceiver *receiver) : _receiver = receiver; } -//////////////////////////////////////////////////////////////////// -// Function: Event::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Event:: Event(const Event ©) : _parameters(copy._parameters), @@ -42,11 +37,9 @@ Event(const Event ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Event::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Event:: operator = (const Event ©) { _parameters = copy._parameters; @@ -54,41 +47,33 @@ operator = (const Event ©) { _name = copy._name; } -//////////////////////////////////////////////////////////////////// -// Function: Event::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Event:: ~Event() { } -//////////////////////////////////////////////////////////////////// -// Function: Event::add_parameter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Event:: add_parameter(const EventParameter &obj) { _parameters.push_back(obj); } -//////////////////////////////////////////////////////////////////// -// Function: Event::get_num_parameters -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Event:: get_num_parameters() const { return _parameters.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Event::get_parameter -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EventParameter Event:: get_parameter(int n) const { nassertr(n >= 0 && n < (int)_parameters.size(), EventParameter(0)); @@ -96,51 +81,41 @@ get_parameter(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: Event::has_receiver -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Event:: has_receiver() const { return _receiver != (EventReceiver *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Event::get_receiver -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EventReceiver *Event:: get_receiver() const { return _receiver; } -//////////////////////////////////////////////////////////////////// -// Function: Event::set_receiver -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Event:: set_receiver(EventReceiver *receiver) { _receiver = receiver; } -//////////////////////////////////////////////////////////////////// -// Function: Event::clear_receiver -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Event:: clear_receiver() { _receiver = (EventReceiver *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Event::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Event:: output(ostream &out) const { out << get_name(); diff --git a/panda/src/event/event.h b/panda/src/event/event.h index 5fb22e3343..47075883b8 100644 --- a/panda/src/event/event.h +++ b/panda/src/event/event.h @@ -1,16 +1,15 @@ -// Filename: event.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file event.h + * @author drose + * @date 1999-02-08 + */ // Apparently some OSX system header defines EVENT_H. Go figure. #ifndef __EVENT_H__ @@ -22,17 +21,15 @@ class EventReceiver; -//////////////////////////////////////////////////////////////////// -// Class : Event -// Description : A named event, possibly with parameters. Anyone in -// any thread may throw an event at any time; there will -// be one process responsible for reading and dispacting -// on the events (but not necessarily immediately). -// -// This function use to inherit from Namable, but that -// makes it too expensive to get its name the Python -// code. Now it just copies the Namable interface in. -//////////////////////////////////////////////////////////////////// +/** + * A named event, possibly with parameters. Anyone in any thread may throw an + * event at any time; there will be one process responsible for reading and + * dispacting on the events (but not necessarily immediately). + * + * This function use to inherit from Namable, but that makes it too expensive + * to get its name the Python code. Now it just copies the Namable interface + * in. + */ class EXPCL_PANDA_EVENT Event : public TypedReferenceCount { PUBLISHED: Event(const string &event_name, EventReceiver *receiver = NULL); diff --git a/panda/src/event/eventHandler.I b/panda/src/event/eventHandler.I index 5541747cbf..eda0b022ea 100644 --- a/panda/src/event/eventHandler.I +++ b/panda/src/event/eventHandler.I @@ -1,29 +1,24 @@ -// Filename: eventHandler.I -// Created by: skyler (27Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventHandler.I + * @author skyler + * @date 2004-01-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::get_global_event_handler -// Access: Public -// Description: Returns a pointer to the one global EventHandler -// object. If the global object has not yet been -// created, this will create it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the one global EventHandler object. If the global + * object has not yet been created, this will create it. + */ INLINE EventHandler *EventHandler:: get_global_event_handler(EventQueue *queue) { - // The event queue parameter is present for now, for backward - // compatibility, but it is ignored. + // The event queue parameter is present for now, for backward compatibility, + // but it is ignored. if (_global_event_handler == 0) { make_global_event_handler(); } diff --git a/panda/src/event/eventHandler.cxx b/panda/src/event/eventHandler.cxx index 596a607962..a71e7fc12c 100644 --- a/panda/src/event/eventHandler.cxx +++ b/panda/src/event/eventHandler.cxx @@ -1,16 +1,15 @@ -// Filename: eventHandler.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventHandler.cxx + * @author drose + * @date 1999-02-08 + */ #include "eventHandler.h" #include "eventQueue.h" @@ -21,23 +20,18 @@ TypeHandle EventHandler::_type_handle; EventHandler *EventHandler::_global_event_handler = NULL; -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EventHandler:: EventHandler(EventQueue *ev_queue) : _queue(*ev_queue) { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::process_events -// Access: Public -// Description: The main processing loop of the EventHandler. This -// function must be called periodically to service -// events. Walks through each pending event and calls -// its assigned hooks. -//////////////////////////////////////////////////////////////////// +/** + * The main processing loop of the EventHandler. This function must be called + * periodically to service events. Walks through each pending event and calls + * its assigned hooks. + */ void EventHandler:: process_events() { while (!_queue.is_queue_empty()) { @@ -45,24 +39,21 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::dispatch_event -// Access: Public, Virtual -// Description: Calls the hooks assigned to the indicated single -// event. -//////////////////////////////////////////////////////////////////// +/** + * Calls the hooks assigned to the indicated single event. + */ void EventHandler:: dispatch_event(const Event *event) { nassertv(event != (Event *)NULL); - // Is the event name defined in the hook table? It will be if - // anyone has ever assigned a hook to this particular event name. + // Is the event name defined in the hook table? It will be if anyone has + // ever assigned a hook to this particular event name. Hooks::const_iterator hi; hi = _hooks.find(event->get_name()); if (hi != _hooks.end()) { - // Yes, it is! Now walk through all the functions assigned to - // that event name. + // Yes, it is! Now walk through all the functions assigned to that event + // name. Functions copy_functions = (*hi).second; Functions::const_iterator fi; @@ -93,11 +84,9 @@ dispatch_event(const Event *event) { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventHandler:: write(ostream &out) const { Hooks::const_iterator hi; @@ -134,15 +123,11 @@ write(ostream &out) const { -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::add_hook -// Access: Public -// Description: Adds the indicated function to the list of those that -// will be called when the named event is thrown. -// Returns true if the function was successfully added, -// false if it was already defined on the indicated -// event name. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated function to the list of those that will be called when + * the named event is thrown. Returns true if the function was successfully + * added, false if it was already defined on the indicated event name. + */ bool EventHandler:: add_hook(const string &event_name, EventFunction *function) { if (event_cat.is_debug()) { @@ -156,16 +141,12 @@ add_hook(const string &event_name, EventFunction *function) { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::add_hook -// Access: Public -// Description: Adds the indicated function to the list of those that -// will be called when the named event is thrown. -// Returns true if the function was successfully added, -// false if it was already defined on the indicated -// event name. This version records an untyped pointer -// to user callback data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated function to the list of those that will be called when + * the named event is thrown. Returns true if the function was successfully + * added, false if it was already defined on the indicated event name. This + * version records an untyped pointer to user callback data. + */ bool EventHandler:: add_hook(const string &event_name, EventCallbackFunction *function, void *data) { @@ -174,12 +155,10 @@ add_hook(const string &event_name, EventCallbackFunction *function, return _cbhooks[event_name].insert(CallbackFunction(function, data)).second; } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::has_hook -// Access: Public -// Description: Returns true if there is any hook added on the -// indicated event name, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is any hook added on the indicated event name, false + * otherwise. + */ bool EventHandler:: has_hook(const string &event_name) const { assert(!event_name.empty()); @@ -203,13 +182,10 @@ has_hook(const string &event_name) const { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::remove_hook -// Access: Public -// Description: Removes the indicated function from the named event -// hook. Returns true if the hook was removed, false if -// it wasn't there in the first place. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated function from the named event hook. Returns true if + * the hook was removed, false if it wasn't there in the first place. + */ bool EventHandler:: remove_hook(const string &event_name, EventFunction *function) { assert(!event_name.empty()); @@ -218,14 +194,11 @@ remove_hook(const string &event_name, EventFunction *function) { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::remove_hook -// Access: Public -// Description: Removes the indicated function from the named event -// hook. Returns true if the hook was removed, false if -// it wasn't there in the first place. This version -// takes an untyped pointer to user callback data. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated function from the named event hook. Returns true if + * the hook was removed, false if it wasn't there in the first place. This + * version takes an untyped pointer to user callback data. + */ bool EventHandler:: remove_hook(const string &event_name, EventCallbackFunction *function, void *data) { @@ -234,13 +207,10 @@ remove_hook(const string &event_name, EventCallbackFunction *function, return _cbhooks[event_name].erase(CallbackFunction(function, data)) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::remove_hooks -// Access: Public -// Description: Removes all functions from the named event hook. -// Returns true if any functions were removed, false if -// there were no functions added to the hook. -//////////////////////////////////////////////////////////////////// +/** + * Removes all functions from the named event hook. Returns true if any + * functions were removed, false if there were no functions added to the hook. + */ bool EventHandler:: remove_hooks(const string &event_name) { assert(!event_name.empty()); @@ -265,12 +235,10 @@ remove_hooks(const string &event_name) { return any_removed; } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::remove_hooks_with -// Access: Public -// Description: Removes all CallbackFunction hooks that have the -// indicated pointer as the associated data pointer. -//////////////////////////////////////////////////////////////////// +/** + * Removes all CallbackFunction hooks that have the indicated pointer as the + * associated data pointer. + */ bool EventHandler:: remove_hooks_with(void *data) { bool any_removed = false; @@ -295,33 +263,27 @@ remove_hooks_with(void *data) { } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::remove_all_hooks -// Access: Public -// Description: Removes all hooks assigned to all events. -//////////////////////////////////////////////////////////////////// +/** + * Removes all hooks assigned to all events. + */ void EventHandler:: remove_all_hooks() { _hooks.clear(); _cbhooks.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::make_global_event_handler -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventHandler:: make_global_event_handler() { _global_event_handler = new EventHandler(EventQueue::get_global_event_queue()); } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::write_hook -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventHandler:: write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { if (!hook.second.empty()) { @@ -329,11 +291,9 @@ write_hook(ostream &out, const EventHandler::Hooks::value_type &hook) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EventHandler::write_cbhook -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventHandler:: write_cbhook(ostream &out, const EventHandler::CallbackHooks::value_type &hook) const { if (!hook.second.empty()) { diff --git a/panda/src/event/eventHandler.h b/panda/src/event/eventHandler.h index c98570e712..452082549e 100644 --- a/panda/src/event/eventHandler.h +++ b/panda/src/event/eventHandler.h @@ -1,16 +1,15 @@ -// Filename: eventHandler.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventHandler.h + * @author drose + * @date 1999-02-08 + */ #ifndef EVENTHANDLER_H #define EVENTHANDLER_H @@ -25,19 +24,15 @@ class EventQueue; -//////////////////////////////////////////////////////////////////// -// Class : EventHandler -// Description : A class to monitor events from the C++ side of -// things. It maintains a set of "hooks", function -// pointers assigned to event names, and calls the -// appropriate hooks when the matching event is -// detected. -// -// This class is not necessary when the hooks are -// detected and processed entirely by the scripting -// language, e.g. via Scheme hooks or the messenger -// in Python. -//////////////////////////////////////////////////////////////////// +/** + * A class to monitor events from the C++ side of things. It maintains a set + * of "hooks", function pointers assigned to event names, and calls the + * appropriate hooks when the matching event is detected. + * + * This class is not necessary when the hooks are detected and processed + * entirely by the scripting language, e.g. via Scheme hooks or the messenger + * in Python. + */ class EXPCL_PANDA_EVENT EventHandler : public TypedObject { public: // Define a function type suitable for receiving events. diff --git a/panda/src/event/eventParameter.I b/panda/src/event/eventParameter.I index 9f92511566..a6f512d72f 100644 --- a/panda/src/event/eventParameter.I +++ b/panda/src/event/eventParameter.I @@ -1,146 +1,112 @@ -// Filename: eventParameter.I -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventParameter.I + * @author drose + * @date 1999-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Default constructor -// Access: Published -// Description: Defines an EventParameter that stores nothing: the -// "empty" parameter. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores nothing: the "empty" parameter. + */ INLINE EventParameter:: EventParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Pointer constructor -// Access: Published -// Description: Defines an EventParameter that stores a pointer to -// any kind of TypedWritableReferenceCount object. This -// is the most general constructor. -// -// This accepts a const pointer, even though it stores -// (and eventually returns) a non-const pointer. This -// is just the simplest way to allow both const and -// non-const pointers to be stored, but it does lose the -// constness. Be careful. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores a pointer to any kind of + * TypedWritableReferenceCount object. This is the most general constructor. + * + * This accepts a const pointer, even though it stores (and eventually + * returns) a non-const pointer. This is just the simplest way to allow both + * const and non-const pointers to be stored, but it does lose the constness. + * Be careful. + */ INLINE EventParameter:: EventParameter(const TypedWritableReferenceCount *ptr) : _ptr((TypedWritableReferenceCount *)ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Pointer constructor -// Access: Published -// Description: Defines an EventParameter that stores a pointer to -// a TypedReferenceCount object. Note that a -// TypedReferenceCount is not the same kind of pointer -// as a TypedWritableReferenceCount, hence we require -// both constructors. -// -// This accepts a const pointer, even though it stores -// (and eventually returns) a non-const pointer. This -// is just the simplest way to allow both const and -// non-const pointers to be stored, but it does lose the -// constness. Be careful. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores a pointer to a TypedReferenceCount + * object. Note that a TypedReferenceCount is not the same kind of pointer as + * a TypedWritableReferenceCount, hence we require both constructors. + * + * This accepts a const pointer, even though it stores (and eventually + * returns) a non-const pointer. This is just the simplest way to allow both + * const and non-const pointers to be stored, but it does lose the constness. + * Be careful. + */ INLINE EventParameter:: EventParameter(const TypedReferenceCount *ptr) : _ptr(new EventStoreTypedRefCount((TypedReferenceCount *)ptr)) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Integer constructor -// Access: Published -// Description: Defines an EventParameter that stores an integer -// value. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores an integer value. + */ INLINE EventParameter:: EventParameter(int value) : _ptr(new EventStoreInt(value)) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Double constructor -// Access: Published -// Description: Defines an EventParameter that stores a -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores a floating-point value. + */ INLINE EventParameter:: EventParameter(double value) : _ptr(new EventStoreDouble(value)) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::String constructor -// Access: Published -// Description: Defines an EventParameter that stores a string value. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores a string value. + */ INLINE EventParameter:: EventParameter(const string &value) : _ptr(new EventStoreString(value)) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Wstring constructor -// Access: Published -// Description: Defines an EventParameter that stores a wstring value. -//////////////////////////////////////////////////////////////////// +/** + * Defines an EventParameter that stores a wstring value. + */ INLINE EventParameter:: EventParameter(const wstring &value) : _ptr(new EventStoreWstring(value)) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EventParameter:: EventParameter(const EventParameter &other) : _ptr(other._ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Copy assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EventParameter &EventParameter:: operator = (const EventParameter &other) { _ptr = other._ptr; return *this; } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EventParameter:: ~EventParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_empty -// Access: Published -// Description: Returns true if the EventParameter is the empty -// parameter, storing nothing, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter is the empty parameter, storing nothing, + * or false otherwise. + */ INLINE bool EventParameter:: is_empty() const { return (_ptr == (TypedWritableReferenceCount *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_int -// Access: Published -// Description: Returns true if the EventParameter stores an integer -// value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter stores an integer value, false + * otherwise. + */ INLINE bool EventParameter:: is_int() const { if (is_empty()) { @@ -149,28 +115,23 @@ is_int() const { return _ptr->is_of_type(EventStoreInt::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_int_value -// Access: Published -// Description: Retrieves the value stored in the EventParameter. It -// is only valid to call this if is_int() has already -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the EventParameter. It is only valid to call + * this if is_int() has already returned true. + */ INLINE int EventParameter:: get_int_value() const { nassertr(is_int(), 0); // We can't use DCAST, because EventStoreValue::init_type() breaks - // convention and takes a parameter. But the above assertion should - // protect us. + // convention and takes a parameter. But the above assertion should protect + // us. return ((const EventStoreInt *)_ptr.p())->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_double -// Access: Published -// Description: Returns true if the EventParameter stores a double -// floating-point value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter stores a double floating-point value, + * false otherwise. + */ INLINE bool EventParameter:: is_double() const { if (is_empty()) { @@ -179,25 +140,19 @@ is_double() const { return _ptr->is_of_type(EventStoreDouble::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_double_value -// Access: Published -// Description: Retrieves the value stored in the EventParameter. It -// is only valid to call this if is_double() has already -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the EventParameter. It is only valid to call + * this if is_double() has already returned true. + */ INLINE double EventParameter:: get_double_value() const { nassertr(is_double(), 0.0); return ((const EventStoreDouble *)_ptr.p())->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_string -// Access: Published -// Description: Returns true if the EventParameter stores a string -// value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter stores a string value, false otherwise. + */ INLINE bool EventParameter:: is_string() const { if (is_empty()) { @@ -206,25 +161,19 @@ is_string() const { return _ptr->is_of_type(EventStoreString::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_string_value -// Access: Published -// Description: Retrieves the value stored in the EventParameter. It -// is only valid to call this if is_string() has already -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the EventParameter. It is only valid to call + * this if is_string() has already returned true. + */ INLINE string EventParameter:: get_string_value() const { nassertr(is_string(), ""); return ((const EventStoreString *)_ptr.p())->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_wstring -// Access: Published -// Description: Returns true if the EventParameter stores a wstring -// value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter stores a wstring value, false otherwise. + */ INLINE bool EventParameter:: is_wstring() const { if (is_empty()) { @@ -233,28 +182,22 @@ is_wstring() const { return _ptr->is_of_type(EventStoreWstring::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_wstring_value -// Access: Published -// Description: Retrieves the value stored in the EventParameter. It -// is only valid to call this if is_wstring() has already -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the EventParameter. It is only valid to call + * this if is_wstring() has already returned true. + */ INLINE wstring EventParameter:: get_wstring_value() const { nassertr(is_wstring(), wstring()); return ((const EventStoreWstring *)_ptr.p())->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::is_typed_ref_count -// Access: Published -// Description: Returns true if the EventParameter stores a -// TypedReferenceCount pointer, false otherwise. Note -// that a TypedReferenceCount is not exactly the same -// kind of pointer as a TypedWritableReferenceCount, -// hence the need for this separate call. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EventParameter stores a TypedReferenceCount pointer, + * false otherwise. Note that a TypedReferenceCount is not exactly the same + * kind of pointer as a TypedWritableReferenceCount, hence the need for this + * separate call. + */ INLINE bool EventParameter:: is_typed_ref_count() const { if (is_empty()) { @@ -263,28 +206,22 @@ is_typed_ref_count() const { return _ptr->is_of_type(EventStoreTypedRefCount::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_typed_ref_count_value -// Access: Published -// Description: Retrieves the value stored in the EventParameter. It -// is only valid to call this if is_typed_ref_count() -// has already returned true. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the EventParameter. It is only valid to call + * this if is_typed_ref_count() has already returned true. + */ INLINE TypedReferenceCount *EventParameter:: get_typed_ref_count_value() const { nassertr(is_typed_ref_count(), NULL); return ((const EventStoreTypedRefCount *)_ptr.p())->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::get_ptr -// Access: Published -// Description: Retrieves a pointer to the actual value stored in the -// parameter. The TypeHandle of this pointer may be -// examined to determine the actual type of parameter it -// contains. This is the only way to retrieve the value -// when it is not one of the above predefined types. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves a pointer to the actual value stored in the parameter. The + * TypeHandle of this pointer may be examined to determine the actual type of + * parameter it contains. This is the only way to retrieve the value when it + * is not one of the above predefined types. + */ INLINE TypedWritableReferenceCount *EventParameter:: get_ptr() const { return _ptr; diff --git a/panda/src/event/eventParameter.cxx b/panda/src/event/eventParameter.cxx index 115b6f7b8f..45780e5ff0 100644 --- a/panda/src/event/eventParameter.cxx +++ b/panda/src/event/eventParameter.cxx @@ -1,16 +1,15 @@ -// Filename: eventParameter.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventParameter.cxx + * @author drose + * @date 1999-02-08 + */ #include "eventParameter.h" #include "dcast.h" @@ -23,11 +22,9 @@ template class ParamValue; template class ParamValue; -//////////////////////////////////////////////////////////////////// -// Function: EventParameter::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventParameter:: output(ostream &out) const { if (_ptr == (TypedWritableReferenceCount *)NULL) { diff --git a/panda/src/event/eventParameter.h b/panda/src/event/eventParameter.h index e44e5be9df..ea960c156e 100644 --- a/panda/src/event/eventParameter.h +++ b/panda/src/event/eventParameter.h @@ -1,16 +1,15 @@ -// Filename: eventParameter.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventParameter.h + * @author drose + * @date 1999-02-08 + */ #ifndef EVENTPARAMETER_H #define EVENTPARAMETER_H @@ -25,16 +24,14 @@ #include "bamWriter.h" #include "paramValue.h" -//////////////////////////////////////////////////////////////////// -// Class : EventParameter -// Description : An optional parameter associated with an event. Each -// event may have zero or more of these. Each parameter -// stores a pointer to a TypedWritableReferenceCount -// object, which of course could be pretty much -// anything. To store a simple value like a double or a -// string, the EventParameter constructors transparently -// use the ParamValue template class from paramValue.h. -//////////////////////////////////////////////////////////////////// +/** + * An optional parameter associated with an event. Each event may have zero + * or more of these. Each parameter stores a pointer to a + * TypedWritableReferenceCount object, which of course could be pretty much + * anything. To store a simple value like a double or a string, the + * EventParameter constructors transparently use the ParamValue template class + * from paramValue.h. + */ class EXPCL_PANDA_EVENT EventParameter { PUBLISHED: INLINE EventParameter(); @@ -50,10 +47,9 @@ PUBLISHED: INLINE ~EventParameter(); // These functions are conveniences to easily determine if the - // EventParameter is one of the predefined parameter types, and - // retrieve the corresponding value. Of course, it is possible that - // the EventParameter is some user-defined type, and is none of - // these. + // EventParameter is one of the predefined parameter types, and retrieve the + // corresponding value. Of course, it is possible that the EventParameter + // is some user-defined type, and is none of these. INLINE bool is_empty() const; INLINE bool is_int() const; INLINE int get_int_value() const; diff --git a/panda/src/event/eventQueue.I b/panda/src/event/eventQueue.I index 8d7606dc06..7887696222 100644 --- a/panda/src/event/eventQueue.I +++ b/panda/src/event/eventQueue.I @@ -1,25 +1,20 @@ -// Filename: eventQueue.I -// Created by: drose (05May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventQueue.I + * @author drose + * @date 2000-05-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::get_global_event_queue -// Access: Public -// Description: Returns a pointer to the one global EventQueue -// object. If the global object has not yet been -// created, this will create it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the one global EventQueue object. If the global + * object has not yet been created, this will create it. + */ INLINE EventQueue *EventQueue:: get_global_event_queue() { if (_global_event_queue == NULL) { diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index 4752abd6e0..fa423b0ca9 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -1,16 +1,15 @@ -// Filename: eventQueue.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventQueue.cxx + * @author drose + * @date 1999-02-08 + */ #include "eventQueue.h" #include "config_event.h" @@ -19,29 +18,23 @@ EventQueue *EventQueue::_global_event_queue = NULL; -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EventQueue:: EventQueue() : _lock("EventQueue::_lock") { } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EventQueue:: ~EventQueue() { } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::queue_event -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventQueue:: queue_event(CPT_Event event) { nassertv(!event.is_null()); @@ -65,12 +58,9 @@ queue_event(CPT_Event event) { } } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::clear -// Access: Published -// Description: Empties all events on the queue, throwing them on the -// floor. -//////////////////////////////////////////////////////////////////// +/** + * Empties all events on the queue, throwing them on the floor. + */ void EventQueue:: clear() { LightMutexHolder holder(_lock); @@ -79,34 +69,27 @@ clear() { } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::is_queue_empty -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EventQueue:: is_queue_empty() const { LightMutexHolder holder(_lock); return _queue.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::is_queue_full -// Access: Published -// Description: This function is deprecated--the queue is never full -// these days. -//////////////////////////////////////////////////////////////////// +/** + * This function is deprecated--the queue is never full these days. + */ bool EventQueue:: is_queue_full() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::dequeue_event -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT_Event EventQueue:: dequeue_event() { LightMutexHolder holder(_lock); @@ -118,11 +101,9 @@ dequeue_event() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: EventQueue::make_global_event_queue -// Access: Protected, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EventQueue:: make_global_event_queue() { _global_event_queue = new EventQueue; diff --git a/panda/src/event/eventQueue.h b/panda/src/event/eventQueue.h index 0aef01d6f6..ea761e7209 100644 --- a/panda/src/event/eventQueue.h +++ b/panda/src/event/eventQueue.h @@ -1,16 +1,15 @@ -// Filename: eventQueue.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventQueue.h + * @author drose + * @date 1999-02-08 + */ #ifndef EVENTQUEUE_H #define EVENTQUEUE_H @@ -22,13 +21,11 @@ #include "lightMutex.h" #include "pdeque.h" -//////////////////////////////////////////////////////////////////// -// Class : EventQueue -// Description : A queue of pending events. As events are thrown, -// they are added to this queue; eventually, they will -// be extracted out again by an EventHandler and -// processed. -//////////////////////////////////////////////////////////////////// +/** + * A queue of pending events. As events are thrown, they are added to this + * queue; eventually, they will be extracted out again by an EventHandler and + * processed. + */ class EXPCL_PANDA_EVENT EventQueue { PUBLISHED: EventQueue(); diff --git a/panda/src/event/eventReceiver.cxx b/panda/src/event/eventReceiver.cxx index 79bc55e58e..3a2a3bc1e5 100644 --- a/panda/src/event/eventReceiver.cxx +++ b/panda/src/event/eventReceiver.cxx @@ -1,16 +1,15 @@ -// Filename: eventReceiver.cxx -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventReceiver.cxx + * @author drose + * @date 1999-12-14 + */ #include "eventReceiver.h" diff --git a/panda/src/event/eventReceiver.h b/panda/src/event/eventReceiver.h index 66b8a2326f..61bcdb0e97 100644 --- a/panda/src/event/eventReceiver.h +++ b/panda/src/event/eventReceiver.h @@ -1,16 +1,15 @@ -// Filename: eventReceiver.h -// Created by: drose (14Dec99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eventReceiver.h + * @author drose + * @date 1999-12-14 + */ #ifndef EVENTRECEIVER_H #define EVENTRECEIVER_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : EventReceiver -// Description : An abstract base class for anything that might care -// about receiving events. An object that might receive -// an event should inherit from this class; each event -// may be sent with an optional EventReceiver pointer. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for anything that might care about receiving events. + * An object that might receive an event should inherit from this class; each + * event may be sent with an optional EventReceiver pointer. + */ class EXPCL_PANDA_EVENT EventReceiver { public: @@ -40,5 +37,3 @@ private: }; #endif - - diff --git a/panda/src/event/genericAsyncTask.I b/panda/src/event/genericAsyncTask.I index fc9317da93..944c020adc 100644 --- a/panda/src/event/genericAsyncTask.I +++ b/panda/src/event/genericAsyncTask.I @@ -1,102 +1,80 @@ -// Filename: genericAsyncTask.I -// Created by: drose (03Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericAsyncTask.I + * @author drose + * @date 2008-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::set_function -// Access: Published -// Description: Replaces the function that is called when the task -// runs. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the task runs. + */ INLINE void GenericAsyncTask:: set_function(GenericAsyncTask::TaskFunc *function) { _function = function; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::get_function -// Access: Published -// Description: Returns the function that is called when the task -// runs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the task runs. + */ INLINE GenericAsyncTask::TaskFunc *GenericAsyncTask:: get_function() const { return _function; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::set_upon_birth -// Access: Published -// Description: Replaces the function that is called when the task -// begins. This is an optional function. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the task begins. This is an + * optional function. + */ INLINE void GenericAsyncTask:: set_upon_birth(GenericAsyncTask::BirthFunc *upon_birth) { _upon_birth = upon_birth; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::get_upon_birth -// Access: Published -// Description: Returns the function that is called when the task -// begins, or NULL if the function is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the task begins, or NULL if the + * function is not defined. + */ INLINE GenericAsyncTask::BirthFunc *GenericAsyncTask:: get_upon_birth() const { return _upon_birth; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::set_upon_death -// Access: Published -// Description: Replaces the function that is called when the task -// ends. This is an optional function. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the task ends. This is an + * optional function. + */ INLINE void GenericAsyncTask:: set_upon_death(GenericAsyncTask::DeathFunc *upon_death) { _upon_death = upon_death; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::get_upon_death -// Access: Published -// Description: Returns the function that is called when the task -// ends, or NULL if the function is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the task ends, or NULL if the + * function is not defined. + */ INLINE GenericAsyncTask::DeathFunc *GenericAsyncTask:: get_upon_death() const { return _upon_death; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::set_user_data -// Access: Published -// Description: Replaces the void pointer that is passed to the task -// function. This is any arbitrary pointer; the task -// object does no processing on it. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the void pointer that is passed to the task function. This is any + * arbitrary pointer; the task object does no processing on it. + */ INLINE void GenericAsyncTask:: set_user_data(void *user_data) { _user_data = user_data; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::get_user_data -// Access: Published -// Description: Returns the void pointer that is passed to the task -// function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the void pointer that is passed to the task function. + */ INLINE void *GenericAsyncTask:: get_user_data() const { return _user_data; diff --git a/panda/src/event/genericAsyncTask.cxx b/panda/src/event/genericAsyncTask.cxx index 0b85504360..28cbebe55f 100644 --- a/panda/src/event/genericAsyncTask.cxx +++ b/panda/src/event/genericAsyncTask.cxx @@ -1,27 +1,24 @@ -// Filename: genericAsyncTask.cxx -// Created by: drose (03Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericAsyncTask.cxx + * @author drose + * @date 2008-10-03 + */ #include "genericAsyncTask.h" #include "pnotify.h" TypeHandle GenericAsyncTask::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GenericAsyncTask:: GenericAsyncTask(const string &name) : AsyncTask(name) @@ -32,11 +29,9 @@ GenericAsyncTask(const string &name) : _user_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GenericAsyncTask:: GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void *user_data) : AsyncTask(name), @@ -47,43 +42,35 @@ GenericAsyncTask(const string &name, GenericAsyncTask::TaskFunc *function, void _upon_death = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::is_runnable -// Access: Protected, Virtual -// Description: Override this function to return true if the task can -// be successfully executed, false if it cannot. Mainly -// intended as a sanity check when attempting to add the -// task to a task manager. -// -// This function is called with the lock held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to return true if the task can be successfully + * executed, false if it cannot. Mainly intended as a sanity check when + * attempting to add the task to a task manager. + * + * This function is called with the lock held. + */ bool GenericAsyncTask:: is_runnable() { return _function != NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::do_task -// Access: Protected, Virtual -// Description: Override this function to do something useful for the -// task. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful for the task. + * + * This function is called with the lock *not* held. + */ AsyncTask::DoneStatus GenericAsyncTask:: do_task() { nassertr(_function != NULL, DS_interrupt); return (*_function)(this, _user_data); } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::upon_birth -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been added to the active queue. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been added + * to the active queue. + * + * This function is called with the lock *not* held. + */ void GenericAsyncTask:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); @@ -93,24 +80,19 @@ upon_birth(AsyncTaskManager *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GenericAsyncTask::upon_death -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been removed from the active queue. The -// parameter clean_exit is true if the task has been -// removed because it exited normally (returning -// DS_done), or false if it was removed for some other -// reason (e.g. AsyncTaskManager::remove()). By the -// time this method is called, _manager has been -// cleared, so the parameter manager indicates the -// original AsyncTaskManager that owned this task. -// -// The normal behavior is to throw the done_event only -// if clean_exit is true. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been + * removed from the active queue. The parameter clean_exit is true if the + * task has been removed because it exited normally (returning DS_done), or + * false if it was removed for some other reason (e.g. + * AsyncTaskManager::remove()). By the time this method is called, _manager + * has been cleared, so the parameter manager indicates the original + * AsyncTaskManager that owned this task. + * + * The normal behavior is to throw the done_event only if clean_exit is true. + * + * This function is called with the lock *not* held. + */ void GenericAsyncTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); diff --git a/panda/src/event/genericAsyncTask.h b/panda/src/event/genericAsyncTask.h index 4ce3f351ab..9ff7ae272a 100644 --- a/panda/src/event/genericAsyncTask.h +++ b/panda/src/event/genericAsyncTask.h @@ -1,16 +1,15 @@ -// Filename: genericAsyncTask.h -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericAsyncTask.h + * @author drose + * @date 2008-09-16 + */ #ifndef GENERICASYNCTASK_H #define GENERICASYNCTASK_H @@ -19,12 +18,11 @@ #include "asyncTask.h" -//////////////////////////////////////////////////////////////////// -// Class : GenericAsyncTask -// Description : Associates a generic C-style function pointer with an -// AsyncTask object. You can use this when you want to -// create an AsyncTask without having to subclass. -//////////////////////////////////////////////////////////////////// +/** + * Associates a generic C-style function pointer with an AsyncTask object. + * You can use this when you want to create an AsyncTask without having to + * subclass. + */ class EXPCL_PANDA_PIPELINE GenericAsyncTask : public AsyncTask { public: typedef DoneStatus TaskFunc(GenericAsyncTask *task, void *user_data); @@ -80,4 +78,3 @@ private: #include "genericAsyncTask.I" #endif - diff --git a/panda/src/event/pointerEvent.I b/panda/src/event/pointerEvent.I index 5d879d5bf1..1321efe477 100644 --- a/panda/src/event/pointerEvent.I +++ b/panda/src/event/pointerEvent.I @@ -1,23 +1,19 @@ -// Filename: pointerEvent.I -// Created by: jyelon (20Sep2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEvent.I + * @author jyelon + * @date 2007-09-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerEvent:: PointerEvent() : _in_window(false), @@ -33,11 +29,9 @@ PointerEvent() : { } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerEvent:: PointerEvent(const PointerEvent ©) : _in_window(copy._in_window), @@ -53,11 +47,9 @@ PointerEvent(const PointerEvent ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PointerEvent:: operator = (const PointerEvent ©) { _in_window = copy._in_window; @@ -72,12 +64,9 @@ operator = (const PointerEvent ©) { _time = copy._time; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Equality Operator -// Access: Public -// Description: The equality operator does not consider time -// significant. -//////////////////////////////////////////////////////////////////// +/** + * The equality operator does not consider time significant. + */ INLINE bool PointerEvent:: operator == (const PointerEvent &other) const { return (_in_window == other._in_window && @@ -91,21 +80,17 @@ operator == (const PointerEvent &other) const { _rotation == other._rotation); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerEvent:: operator != (const PointerEvent &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerEvent:: operator < (const PointerEvent &other) const { if (_sequence != other._sequence) { @@ -134,4 +119,3 @@ operator < (const PointerEvent &other) const { } return _in_window < other._in_window; } - diff --git a/panda/src/event/pointerEvent.cxx b/panda/src/event/pointerEvent.cxx index 3a993a7908..8e64a3c58b 100644 --- a/panda/src/event/pointerEvent.cxx +++ b/panda/src/event/pointerEvent.cxx @@ -1,47 +1,40 @@ -// Filename: pointerEvent.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEvent.cxx + * @author drose + * @date 2000-03-01 + */ #include "pointerEvent.h" #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PointerEvent:: output(ostream &out) const { out << (_in_window ? "In@" : "Out@") << _xpos << "," << _ypos << " "; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::write_datagram -// Access: Public -// Description: Writes the event into a datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the event into a datagram. + */ void PointerEvent:: write_datagram(Datagram &dg) const { nassertv(false && "This function not implemented yet."); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEvent::read_datagram -// Access: Public -// Description: Restores the event from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Restores the event from the datagram. + */ void PointerEvent:: read_datagram(DatagramIterator &scan) { nassertv(false && "This function not implemented yet."); diff --git a/panda/src/event/pointerEvent.h b/panda/src/event/pointerEvent.h index e7604c0b51..f69d8d4223 100644 --- a/panda/src/event/pointerEvent.h +++ b/panda/src/event/pointerEvent.h @@ -1,16 +1,15 @@ -// Filename: pointerEvent.h -// Created by: jyelon (20Sep2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEvent.h + * @author jyelon + * @date 2007-09-20 + */ #ifndef POINTEREVENT_H #define POINTEREVENT_H @@ -21,10 +20,9 @@ class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : PointerEvent -// Description : Records a pointer movement event. -//////////////////////////////////////////////////////////////////// +/** + * Records a pointer movement event. + */ class EXPCL_PANDA_EVENT PointerEvent { public: @@ -62,4 +60,3 @@ INLINE ostream &operator << (ostream &out, const PointerEvent &pe) { #include "pointerEvent.I" #endif - diff --git a/panda/src/event/pointerEventList.I b/panda/src/event/pointerEventList.I index ed3572d14b..eda98b6473 100644 --- a/panda/src/event/pointerEventList.I +++ b/panda/src/event/pointerEventList.I @@ -1,183 +1,149 @@ -// Filename: pointerEventList.I -// Created by: jyelon (20Sep2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEventList.I + * @author jyelon + * @date 2007-09-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerEventList:: PointerEventList() { } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerEventList:: PointerEventList(const PointerEventList ©) : _events(copy._events) { } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PointerEventList:: operator = (const PointerEventList ©) { _events = copy._events; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_num_events -// Access: Published -// Description: Returns the number of events in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of events in the list. + */ INLINE int PointerEventList:: get_num_events() const { return _events.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_in_window -// Access: Published -// Description: Get the in-window flag of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the in-window flag of the nth event. + */ INLINE bool PointerEventList:: get_in_window(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._in_window; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_xpos -// Access: Published -// Description: Get the x-coordinate of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the x-coordinate of the nth event. + */ INLINE int PointerEventList:: get_xpos(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._xpos; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_ypos -// Access: Published -// Description: Get the y-coordinate of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the y-coordinate of the nth event. + */ INLINE int PointerEventList:: get_ypos(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._ypos; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_dx -// Access: Published -// Description: Get the x-coordinate of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the x-coordinate of the nth event. + */ INLINE int PointerEventList:: get_dx(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._dx; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_dy -// Access: Published -// Description: Get the y-coordinate of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the y-coordinate of the nth event. + */ INLINE int PointerEventList:: get_dy(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._dy; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_length -// Access: Published -// Description: Get the length of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the length of the nth event. + */ INLINE double PointerEventList:: get_length(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._length; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_direction -// Access: Published -// Description: Get the direction of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the direction of the nth event. + */ INLINE double PointerEventList:: get_direction(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._direction; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_rotation -// Access: Published -// Description: Get the rotation of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the rotation of the nth event. + */ INLINE double PointerEventList:: get_rotation(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._rotation; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_sequence -// Access: Published -// Description: Get the sequence number of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the sequence number of the nth event. + */ INLINE int PointerEventList:: get_sequence(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._sequence; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::get_time -// Access: Published -// Description: Get the timestamp of the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Get the timestamp of the nth event. + */ INLINE double PointerEventList:: get_time(int evt) const { nassertr((evt >= 0) && (evt < (int)_events.size()), 0); return _events[evt]._time; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::clear -// Access: Public -// Description: Empties all the events from the list. -//////////////////////////////////////////////////////////////////// +/** + * Empties all the events from the list. + */ INLINE void PointerEventList:: clear() { _events.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::pop_front -// Access: Public -// Description: Discards the first event on the list. -//////////////////////////////////////////////////////////////////// +/** + * Discards the first event on the list. + */ INLINE void PointerEventList:: pop_front() { _events.pop_front(); diff --git a/panda/src/event/pointerEventList.cxx b/panda/src/event/pointerEventList.cxx index 00cc7d7c18..fc376bc886 100644 --- a/panda/src/event/pointerEventList.cxx +++ b/panda/src/event/pointerEventList.cxx @@ -1,16 +1,15 @@ -// Filename: pointerEventList.cxx -// Created by: jyelon (20Sep2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEventList.cxx + * @author jyelon + * @date 2007-09-20 + */ #include "pointerEventList.h" #include "indent.h" @@ -21,12 +20,10 @@ TypeHandle PointerEventList::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: delta_angle -// Access: Static, Inline -// Description: Compute the difference between two angles. -// Returns a value in the range -180 to 180. -//////////////////////////////////////////////////////////////////// +/** + * Compute the difference between two angles. Returns a value in the range + * -180 to 180. + */ INLINE double delta_angle(double angle1, double angle2) { double deltang = angle2 - angle1; while (deltang < -180.0) deltang += 360.0; @@ -35,12 +32,10 @@ INLINE double delta_angle(double angle1, double angle2) { } -//////////////////////////////////////////////////////////////////// -// Function: delta_angle -// Access: Static, Inline -// Description: Compute the difference between two angles. -// Returns a value in the range -180 to 180. -//////////////////////////////////////////////////////////////////// +/** + * Compute the difference between two angles. Returns a value in the range + * -180 to 180. + */ INLINE double normalize_angle(double angle) { while (angle < 0.0) angle += 360.0; while (angle > 360.0) angle -= 360.0; @@ -49,11 +44,9 @@ INLINE double normalize_angle(double angle) { -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PointerEventList:: output(ostream &out) const { if (_events.empty()) { @@ -71,11 +64,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PointerEventList:: write(ostream &out, int indent_level) const { indent(out, indent_level) << _events.size() << " events:\n"; @@ -85,13 +76,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::add_event -// Access: Published -// Description: Adds a new event to the end of the list. -// Automatically calculates the dx, dy, length, -// direction, and rotation for all but the first event. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new event to the end of the list. Automatically calculates the dx, + * dy, length, direction, and rotation for all but the first event. + */ void PointerEventList:: add_event(bool in_win, int xpos, int ypos, int seq, double time) { PointerEvent pe; @@ -120,14 +108,11 @@ add_event(bool in_win, int xpos, int ypos, int seq, double time) { pe._rotation = 0.0; } _events.push_back(pe); -} +} -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::encircles -// Access: Published -// Description: Returns true if the trail loops around the -// specified point. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the trail loops around the specified point. + */ bool PointerEventList:: encircles(int x, int y) const { int tot_events = _events.size(); @@ -156,15 +141,12 @@ encircles(int x, int y) const { return (total > 360.0) || (total < -360.0); } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::total_turns -// Access: Published -// Description: returns the total angular deviation that the trail -// has made in the specified time period. A small -// number means that the trail is moving in a relatively -// straight line, a large number means that the trail -// is zig-zagging or spinning. The result is in degrees. -//////////////////////////////////////////////////////////////////// +/** + * returns the total angular deviation that the trail has made in the + * specified time period. A small number means that the trail is moving in a + * relatively straight line, a large number means that the trail is zig- + * zagging or spinning. The result is in degrees. + */ double PointerEventList:: total_turns(double sec) const { double old = ClockObject::get_global_clock()->get_frame_time() - sec; @@ -178,41 +160,34 @@ total_turns(double sec) const { return tot; } -//////////////////////////////////////////////////////////////////// -// Function: PointerEventList::match_pattern -// Access: Published -// Description: This function is not implemented yet. It is a work -// in progress. The intent is as follows: -// -// Returns a nonzero value if the mouse movements -// match the specified pattern. The higher the value, -// the better the match. The pattern is a sequence -// of compass directions (ie, "E", "NE", etc) separated -// by spaces. If rot is nonzero, then the pattern is -// rotated counterclockwise by the specified amount -// before testing. Seglen is the minimum length a -// mouse movement needs to be in order to be considered -// significant. -//////////////////////////////////////////////////////////////////// +/** + * This function is not implemented yet. It is a work in progress. The + * intent is as follows: + * + * Returns a nonzero value if the mouse movements match the specified pattern. + * The higher the value, the better the match. The pattern is a sequence of + * compass directions (ie, "E", "NE", etc) separated by spaces. If rot is + * nonzero, then the pattern is rotated counterclockwise by the specified + * amount before testing. Seglen is the minimum length a mouse movement needs + * to be in order to be considered significant. + */ double PointerEventList:: match_pattern(const string &ascpat, double rot, double seglen) { // Convert the pattern from ascii to a more usable form. vector_double pattern; parse_pattern(ascpat, pattern); - + // Apply the rotation to the pattern. for (size_t i=0; i 0) { pattern.push_back(dir); } - + cerr << "Pattern: "; for (int i=0; i<(int)pattern.size(); i++) { cerr << pattern[i] << " "; diff --git a/panda/src/event/pointerEventList.h b/panda/src/event/pointerEventList.h index dd0c6a765e..7c2400c769 100644 --- a/panda/src/event/pointerEventList.h +++ b/panda/src/event/pointerEventList.h @@ -1,16 +1,15 @@ -// Filename: pointerEventList.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerEventList.h + * @author drose + * @date 2002-03-12 + */ #ifndef POINTEREVENTLIST_H #define POINTEREVENTLIST_H @@ -26,14 +25,11 @@ class ModifierPointers; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : PointerEventList -// Description : Records a set of pointer events that happened -// recently. This class is usually used only in the -// data graph, to transmit the recent pointer presses, -// but it may be used anywhere a list of PointerEvents -// is desired. -//////////////////////////////////////////////////////////////////// +/** + * Records a set of pointer events that happened recently. This class is + * usually used only in the data graph, to transmit the recent pointer + * presses, but it may be used anywhere a list of PointerEvents is desired. + */ class EXPCL_PANDA_EVENT PointerEventList : public ParamValueBase { PUBLISHED: INLINE PointerEventList(); @@ -96,4 +92,3 @@ INLINE ostream &operator << (ostream &out, const PointerEventList &pointerlist) #include "pointerEventList.I" #endif - diff --git a/panda/src/event/pt_Event.cxx b/panda/src/event/pt_Event.cxx index 5e4d1b4f95..095ce8b56b 100644 --- a/panda/src/event/pt_Event.cxx +++ b/panda/src/event/pt_Event.cxx @@ -1,16 +1,15 @@ -// Filename: pt_Event.cxx -// Created by: drose (26May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_Event.cxx + * @author drose + * @date 2000-05-26 + */ #include "pt_Event.h" diff --git a/panda/src/event/pt_Event.h b/panda/src/event/pt_Event.h index 24c1ae887b..6c59b8fecd 100644 --- a/panda/src/event/pt_Event.h +++ b/panda/src/event/pt_Event.h @@ -1,16 +1,15 @@ -// Filename: pt_Event.h -// Created by: drose (26May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pt_Event.h + * @author drose + * @date 2000-05-26 + */ #ifndef PT_EVENT_H #define PT_EVENT_H @@ -21,11 +20,10 @@ #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PT_Event -// Description : A PointerTo. This is defined here solely we -// can explicitly export the template class. -//////////////////////////////////////////////////////////////////// +/** + * A PointerTo. This is defined here solely we can explicitly export + * the template class. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, PointerToBase) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_EVENT, EXPTP_PANDA_EVENT, PointerTo) diff --git a/panda/src/event/pythonTask.I b/panda/src/event/pythonTask.I index 3d45c2762e..7b2e5d5082 100644 --- a/panda/src/event/pythonTask.I +++ b/panda/src/event/pythonTask.I @@ -1,25 +1,20 @@ -// Filename: pythonTask.I -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonTask.I + * @author drose + * @date 2008-09-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::set_delay -// Access: Public -// Description: If None is passed, calls clear_delay, otherwise -// sets the delay time. See AsyncTask::set_delay() -// and AsyncTask::clear_delay(). -//////////////////////////////////////////////////////////////////// +/** + * If None is passed, calls clear_delay, otherwise sets the delay time. See + * AsyncTask::set_delay() and AsyncTask::clear_delay(). + */ INLINE void PythonTask:: set_delay(PyObject *delay) { if (delay == Py_None) { @@ -36,12 +31,10 @@ set_delay(PyObject *delay) { Py_DECREF(value); } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::get_delay -// Access: Public -// Description: Returns the delay time if set, None otherwise. -// See AsyncTask::has_delay() and AsyncTask::get_delay(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the delay time if set, None otherwise. See AsyncTask::has_delay() + * and AsyncTask::get_delay(). + */ INLINE PyObject *PythonTask:: get_delay() const { if (AsyncTask::has_delay()) { diff --git a/panda/src/event/pythonTask.cxx b/panda/src/event/pythonTask.cxx index a5ea42c1a7..7f288aba0a 100644 --- a/panda/src/event/pythonTask.cxx +++ b/panda/src/event/pythonTask.cxx @@ -1,16 +1,15 @@ -// Filename: pythonTask.cxx -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonTask.cxx + * @author drose + * @date 2008-09-16 + */ #include "pythonTask.h" #include "pnotify.h" @@ -30,11 +29,9 @@ ConfigureFn(config_pythonTask) { extern struct Dtool_PyTypedObject Dtool_TypedReferenceCount; #endif -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonTask:: PythonTask(PyObject *function, const string &name) : AsyncTask(name) @@ -61,11 +58,9 @@ PythonTask(PyObject *function, const string &name) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonTask:: ~PythonTask() { Py_DECREF(_function); @@ -76,13 +71,10 @@ PythonTask:: Py_XDECREF(_upon_death); } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::set_function -// Access: Published -// Description: Replaces the function that is called when the task -// runs. The parameter should be a Python callable -// object. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the task runs. The parameter + * should be a Python callable object. + */ void PythonTask:: set_function(PyObject *function) { Py_XDECREF(_function); @@ -94,25 +86,20 @@ set_function(PyObject *function) { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::get_function -// Access: Published -// Description: Returns the function that is called when the task -// runs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the task runs. + */ PyObject *PythonTask:: get_function() { Py_INCREF(_function); return _function; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::set_args -// Access: Published -// Description: Replaces the argument list that is passed to the task -// function. The parameter should be a tuple or list of -// arguments, or None to indicate the empty list. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the argument list that is passed to the task function. The + * parameter should be a tuple or list of arguments, or None to indicate the + * empty list. + */ void PythonTask:: set_args(PyObject *args, bool append_task) { Py_XDECREF(_args); @@ -135,19 +122,16 @@ set_args(PyObject *args, bool append_task) { _append_task = append_task; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::get_args -// Access: Published -// Description: Returns the argument list that is passed to the task -// function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the argument list that is passed to the task function. + */ PyObject *PythonTask:: get_args() { if (_append_task) { - // If we want to append the task, we have to create a new tuple - // with space for one more at the end. We have to do this - // dynamically each time, to avoid storing the task itself in its - // own arguments list, and thereby creating a cyclical reference. + // If we want to append the task, we have to create a new tuple with space + // for one more at the end. We have to do this dynamically each time, to + // avoid storing the task itself in its own arguments list, and thereby + // creating a cyclical reference. int num_args = PyTuple_GET_SIZE(_args); PyObject *with_task = PyTuple_New(num_args + 1); @@ -170,13 +154,10 @@ get_args() { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::set_upon_death -// Access: Published -// Description: Replaces the function that is called when the task -// finishes. The parameter should be a Python callable -// object. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the task finishes. The parameter + * should be a Python callable object. + */ void PythonTask:: set_upon_death(PyObject *upon_death) { Py_XDECREF(_upon_death); @@ -188,30 +169,23 @@ set_upon_death(PyObject *upon_death) { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::get_upon_death -// Access: Published -// Description: Returns the function that is called when the task -// finishes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the task finishes. + */ PyObject *PythonTask:: get_upon_death() { Py_INCREF(_upon_death); return _upon_death; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::set_owner -// Access: Published -// Description: Specifies a Python object that serves as the "owner" -// for the task. This owner object must have two -// methods: _addTask() and _clearTask(), which will be -// called with one parameter, the task object. -// -// owner._addTask() is called when the task is added -// into the active task list, and owner._clearTask() is -// called when it is removed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a Python object that serves as the "owner" for the task. This + * owner object must have two methods: _addTask() and _clearTask(), which will + * be called with one parameter, the task object. + * + * owner._addTask() is called when the task is added into the active task + * list, and owner._clearTask() is called when it is removed. + */ void PythonTask:: set_owner(PyObject *owner) { if (_owner != NULL && _owner != Py_None && _state != S_inactive) { @@ -227,26 +201,21 @@ set_owner(PyObject *owner) { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::get_owner -// Access: Published -// Description: Returns the "owner" object. See set_owner(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "owner" object. See set_owner(). + */ PyObject *PythonTask:: get_owner() { Py_INCREF(_owner); return _owner; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::__setattr__ -// Access: Published -// Description: Maps from an expression like "task.attr_name = v". -// This is customized here so we can support some -// traditional task interfaces that supported directly -// assigning certain values. We also support adding -// arbitrary data to the Task object. -//////////////////////////////////////////////////////////////////// +/** + * Maps from an expression like "task.attr_name = v". This is customized here + * so we can support some traditional task interfaces that supported directly + * assigning certain values. We also support adding arbitrary data to the + * Task object. + */ int PythonTask:: __setattr__(PyObject *self, PyObject *attr, PyObject *v) { if (PyObject_GenericSetAttr(self, attr, v) == 0) { @@ -276,15 +245,12 @@ __setattr__(PyObject *self, PyObject *attr, PyObject *v) { return PyDict_SetItem(__dict__, attr, v); } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::__delattr__ -// Access: Published -// Description: Maps from an expression like "del task.attr_name". -// This is customized here so we can support some -// traditional task interfaces that supported directly -// assigning certain values. We also support adding -// arbitrary data to the Task object. -//////////////////////////////////////////////////////////////////// +/** + * Maps from an expression like "del task.attr_name". This is customized here + * so we can support some traditional task interfaces that supported directly + * assigning certain values. We also support adding arbitrary data to the + * Task object. + */ int PythonTask:: __delattr__(PyObject *self, PyObject *attr) { if (PyObject_GenericSetAttr(self, attr, NULL) == 0) { @@ -314,22 +280,18 @@ __delattr__(PyObject *self, PyObject *attr) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::__getattr__ -// Access: Published -// Description: Maps from an expression like "task.attr_name". -// This is customized here so we can support some -// traditional task interfaces that supported directly -// querying certain values. We also support adding -// arbitrary data to the Task object. -//////////////////////////////////////////////////////////////////// +/** + * Maps from an expression like "task.attr_name". This is customized here so + * we can support some traditional task interfaces that supported directly + * querying certain values. We also support adding arbitrary data to the Task + * object. + */ PyObject *PythonTask:: __getattr__(PyObject *attr) const { - // Note that with the new Interrogate behavior, this method - // behaves more like the Python __getattr__ rather than being - // directly assigned to the tp_getattro slot (a la __getattribute__). - // So, we won't get here when the attribute has already been found - // via other methods. + // Note that with the new Interrogate behavior, this method behaves more + // like the Python __getattr__ rather than being directly assigned to the + // tp_getattro slot (a la __getattribute__). So, we won't get here when the + // attribute has already been found via other methods. PyObject *item = PyDict_GetItem(__dict__, attr); @@ -352,11 +314,9 @@ __getattr__(PyObject *attr) const { return item; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::__traverse__ -// Access: Published -// Description: Called by Python to implement cycle detection. -//////////////////////////////////////////////////////////////////// +/** + * Called by Python to implement cycle detection. + */ int PythonTask:: __traverse__(visitproc visit, void *arg) { Py_VISIT(_function); @@ -368,11 +328,9 @@ __traverse__(visitproc visit, void *arg) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::__clear__ -// Access: Published -// Description: Called by Python to implement cycle breaking. -//////////////////////////////////////////////////////////////////// +/** + * Called by Python to implement cycle breaking. + */ int PythonTask:: __clear__() { Py_CLEAR(_function); @@ -384,29 +342,23 @@ __clear__() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::is_runnable -// Access: Protected, Virtual -// Description: Override this function to return true if the task can -// be successfully executed, false if it cannot. Mainly -// intended as a sanity check when attempting to add the -// task to a task manager. -// -// This function is called with the lock held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to return true if the task can be successfully + * executed, false if it cannot. Mainly intended as a sanity check when + * attempting to add the task to a task manager. + * + * This function is called with the lock held. + */ bool PythonTask:: is_runnable() { return _function != Py_None; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::do_task -// Access: Protected, Virtual -// Description: Override this function to do something useful for the -// task. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful for the task. + * + * This function is called with the lock *not* held. + */ AsyncTask::DoneStatus PythonTask:: do_task() { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) @@ -424,13 +376,10 @@ do_task() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::do_python_task -// Access: Protected -// Description: The Python calls that implement do_task(). This -// function is separate so we can acquire the Python -// interpretor lock while it runs. -//////////////////////////////////////////////////////////////////// +/** + * The Python calls that implement do_task(). This function is separate so we + * can acquire the Python interpretor lock while it runs. + */ AsyncTask::DoneStatus PythonTask:: do_python_task() { PyObject *result = NULL; @@ -438,15 +387,14 @@ do_python_task() { if (_generator == (PyObject *)NULL) { // We are calling the function directly. PyObject *args = get_args(); - result = + result = Thread::get_current_thread()->call_python_func(_function, args); Py_DECREF(args); #ifdef PyGen_Check if (result != (PyObject *)NULL && PyGen_Check(result)) { // The function has yielded a generator. We will call into that - // henceforth, instead of calling the function from the top - // again. + // henceforth, instead of calling the function from the top again. if (task_cat.is_debug()) { #if PY_MAJOR_VERSION >= 3 PyObject *str = PyObject_ASCII(_function); @@ -487,8 +435,8 @@ do_python_task() { if (result == (PyObject *)NULL) { if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_SystemExit)) { - // Don't print an error message for SystemExit. Or rather, make - // it a debug message. + // Don't print an error message for SystemExit. Or rather, make it a + // debug message. if (task_cat.is_debug()) { task_cat.debug() << "SystemExit occurred in " << *this << "\n"; @@ -557,38 +505,31 @@ do_python_task() { return DS_interrupt; } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::upon_birth -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been added to the active queue. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been added + * to the active queue. + * + * This function is called with the lock *not* held. + */ void PythonTask:: upon_birth(AsyncTaskManager *manager) { AsyncTask::upon_birth(manager); register_to_owner(); } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::upon_death -// Access: Protected, Virtual -// Description: Override this function to do something useful when the -// task has been removed from the active queue. The -// parameter clean_exit is true if the task has been -// removed because it exited normally (returning -// DS_done), or false if it was removed for some other -// reason (e.g. AsyncTaskManager::remove()). By the -// time this method is called, _manager has been -// cleared, so the parameter manager indicates the -// original AsyncTaskManager that owned this task. -// -// The normal behavior is to throw the done_event only -// if clean_exit is true. -// -// This function is called with the lock *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Override this function to do something useful when the task has been + * removed from the active queue. The parameter clean_exit is true if the + * task has been removed because it exited normally (returning DS_done), or + * false if it was removed for some other reason (e.g. + * AsyncTaskManager::remove()). By the time this method is called, _manager + * has been cleared, so the parameter manager indicates the original + * AsyncTaskManager that owned this task. + * + * The normal behavior is to throw the done_event only if clean_exit is true. + * + * This function is called with the lock *not* held. + */ void PythonTask:: upon_death(AsyncTaskManager *manager, bool clean_exit) { AsyncTask::upon_death(manager, clean_exit); @@ -599,9 +540,9 @@ upon_death(AsyncTaskManager *manager, bool clean_exit) { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); #endif - + call_function(_upon_death); - + #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif @@ -609,11 +550,9 @@ upon_death(AsyncTaskManager *manager, bool clean_exit) { unregister_from_owner(); } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::register_to_owner -// Access: Private -// Description: Tells the owner we are now his task. -//////////////////////////////////////////////////////////////////// +/** + * Tells the owner we are now his task. + */ void PythonTask:: register_to_owner() { if (_owner != Py_None && !_registered_to_owner) { @@ -622,21 +561,19 @@ register_to_owner() { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); #endif - + _registered_to_owner = true; call_owner_method("_addTask"); - + #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::unregister_from_owner -// Access: Private -// Description: Tells the owner we are no longer his task. -//////////////////////////////////////////////////////////////////// +/** + * Tells the owner we are no longer his task. + */ void PythonTask:: unregister_from_owner() { // make sure every call to _clearTask corresponds to a call to _addTask @@ -646,23 +583,20 @@ unregister_from_owner() { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); #endif - + _registered_to_owner = false; call_owner_method("_clearTask"); - + #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) PyGILState_Release(gstate); #endif } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::call_owner_method -// Access: Private -// Description: Calls the indicated method name on the given object, -// if defined, passing in the task object as the only -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Calls the indicated method name on the given object, if defined, passing in + * the task object as the only parameter. + */ void PythonTask:: call_owner_method(const char *method_name) { if (_owner != Py_None) { @@ -688,22 +622,20 @@ call_owner_method(const char *method_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonTask::call_function -// Access: Private -// Description: Calls the indicated Python function, passing in the -// task object as the only parameter. -//////////////////////////////////////////////////////////////////// +/** + * Calls the indicated Python function, passing in the task object as the only + * parameter. + */ void PythonTask:: call_function(PyObject *function) { if (function != Py_None) { this->ref(); - PyObject *self = + PyObject *self = DTool_CreatePyInstanceTyped(this, Dtool_TypedReferenceCount, true, false, get_type_index()); PyObject *args = Py_BuildValue("(O)", self); Py_DECREF(self); - + PyObject *result = PyObject_CallObject(function, args); Py_XDECREF(result); Py_DECREF(args); diff --git a/panda/src/event/pythonTask.h b/panda/src/event/pythonTask.h index b93443528c..558fb7c5a8 100644 --- a/panda/src/event/pythonTask.h +++ b/panda/src/event/pythonTask.h @@ -1,16 +1,15 @@ -// Filename: pythonTask.h -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonTask.h + * @author drose + * @date 2008-09-16 + */ #ifndef PYTHONTASK_H #define PYTHONTASK_H @@ -22,11 +21,10 @@ #ifdef HAVE_PYTHON #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : PythonTask -// Description : This class exists to allow association of a Python -// function with the AsyncTaskManager. -//////////////////////////////////////////////////////////////////// +/** + * This class exists to allow association of a Python function with the + * AsyncTaskManager. + */ class PythonTask : public AsyncTask { PUBLISHED: PythonTask(PyObject *function = Py_None, const string &name = string()); @@ -59,17 +57,15 @@ PUBLISHED: // The name of this task. MAKE_PROPERTY(name, get_name, set_name); - // The amount of seconds that have elapsed since the task was - // started, according to the task manager's clock. + // The amount of seconds that have elapsed since the task was started, + // according to the task manager's clock. MAKE_PROPERTY(time, get_elapsed_time); - // If this task has been added to an AsyncTaskManager with a delay - // in effect, this contains the time at which the task is expected - // to awaken. It has no meaning of the task has not yet been added - // to a queue, or if there was no delay in effect at the time the - // task was added. - // - // If the task's status is not S_sleeping, this contains 0.0. + // If this task has been added to an AsyncTaskManager with a delay in + // effect, this contains the time at which the task is expected to awaken. + // It has no meaning of the task has not yet been added to a queue, or if + // there was no delay in effect at the time the task was added. If the + // task's status is not S_sleeping, this contains 0.0. MAKE_PROPERTY(wake_time, get_wake_time); // Alias of wake_time. @@ -81,16 +77,16 @@ PUBLISHED: // Alias of delay_time. MAKE_PROPERTY(delayTime, get_delay, set_delay); - // The number of frames that have elapsed since the task was - // started, according to the task manager's clock. + // The number of frames that have elapsed since the task was started, + // according to the task manager's clock. MAKE_PROPERTY(frame, get_elapsed_frames); - // This is a number guaranteed to be unique for each different - // AsyncTask object in the universe. + // This is a number guaranteed to be unique for each different AsyncTask + // object in the universe. MAKE_PROPERTY(id, get_task_id); - // This is a special variable to hold the instance dictionary in - // which custom variables may be stored. + // This is a special variable to hold the instance dictionary in which + // custom variables may be stored. PyObject *__dict__; protected: @@ -139,4 +135,3 @@ private: #endif // HAVE_PYTHON #endif - diff --git a/panda/src/event/test_task.cxx b/panda/src/event/test_task.cxx index a0f19e5702..958742f747 100644 --- a/panda/src/event/test_task.cxx +++ b/panda/src/event/test_task.cxx @@ -1,16 +1,15 @@ -// Filename: test_task.cxx -// Created by: drose (16Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_task.cxx + * @author drose + * @date 2008-09-16 + */ #include "pandabase.h" #include "asyncTask.h" @@ -26,7 +25,7 @@ public: { } ALLOC_DELETED_CHAIN(MyTask); - + virtual DoneStatus do_task() { cerr << "Doing " << *this << ", sort = " << get_sort() << ", priority = " << get_priority() diff --git a/panda/src/event/throw_event.I b/panda/src/event/throw_event.I index 7b9fa06edc..303b356dad 100644 --- a/panda/src/event/throw_event.I +++ b/panda/src/event/throw_event.I @@ -1,17 +1,15 @@ -// Filename: throw_event.I -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file throw_event.I + * @author drose + * @date 1999-02-08 + */ INLINE void throw_event(const CPT_Event &event) { @@ -67,7 +65,6 @@ throw_event(const string &event_name, EventQueue::get_global_event_queue()->queue_event(event); } -//////////////////////////////////////////////////////////////////// INLINE void throw_event_directly(EventHandler& handler, diff --git a/panda/src/event/throw_event.h b/panda/src/event/throw_event.h index 564a4acfd4..d1d2554c3a 100644 --- a/panda/src/event/throw_event.h +++ b/panda/src/event/throw_event.h @@ -1,16 +1,15 @@ -// Filename: throw_event.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file throw_event.h + * @author drose + * @date 1999-02-19 + */ #ifndef THROW_EVENT_H #define THROW_EVENT_H diff --git a/panda/src/express/buffer.I b/panda/src/express/buffer.I index ffdf80f010..150f4b1a63 100644 --- a/panda/src/express/buffer.I +++ b/panda/src/express/buffer.I @@ -1,22 +1,19 @@ -// Filename: buffer.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buffer.I + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: Buffer::get_length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int Buffer:: get_length() const { return _length; diff --git a/panda/src/express/buffer.cxx b/panda/src/express/buffer.cxx index 413e5e1c2b..68e8d65961 100644 --- a/panda/src/express/buffer.cxx +++ b/panda/src/express/buffer.cxx @@ -1,37 +1,31 @@ -// Filename: buffer.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buffer.cxx + * @author mike + * @date 1997-01-09 + */ #include "buffer.h" -//////////////////////////////////////////////////////////////////// -// Function: Buffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Buffer:: Buffer(int size) { _length = size; _buffer = (char *)PANDA_MALLOC_ARRAY(_length); } -//////////////////////////////////////////////////////////////////// -// Function: Buffer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Buffer:: ~Buffer() { PANDA_FREE_ARRAY(_buffer); } - diff --git a/panda/src/express/buffer.h b/panda/src/express/buffer.h index 0a11349d26..255125b21b 100644 --- a/panda/src/express/buffer.h +++ b/panda/src/express/buffer.h @@ -1,16 +1,15 @@ -// Filename: buffer.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buffer.h + * @author mike + * @date 1997-01-09 + */ #ifndef BUFFER_H #define BUFFER_H @@ -19,10 +18,9 @@ #include "typedef.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : Buffer -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAEXPRESS Buffer : public ReferenceCount { public: Buffer(int size); diff --git a/panda/src/express/checksumHashGenerator.I b/panda/src/express/checksumHashGenerator.I index 2a094eda4c..a2e9920203 100644 --- a/panda/src/express/checksumHashGenerator.I +++ b/panda/src/express/checksumHashGenerator.I @@ -1,71 +1,56 @@ -// Filename: checksumHashGenerator.I -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file checksumHashGenerator.I + * @author drose + * @date 2001-05-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_int -// Access: Public -// Description: Adds another integer to the hash so far. This -// function should be overridden in base classes; this -// is the principle implementation of the HashGenerator. -//////////////////////////////////////////////////////////////////// +/** + * Adds another integer to the hash so far. This function should be + * overridden in base classes; this is the principle implementation of the + * HashGenerator. + */ INLINE void ChecksumHashGenerator:: add_int(long sum) { _hash += (size_t)sum; } -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_bool -// Access: Public -// Description: Adds a boolean flag. -//////////////////////////////////////////////////////////////////// +/** + * Adds a boolean flag. + */ INLINE void ChecksumHashGenerator:: add_bool(bool flag) { add_int(flag); } -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_fp -// Access: Public -// Description: Adds a floating-point number, first converting it to -// fixed point by dividing it by the indicated -// threshold. -//////////////////////////////////////////////////////////////////// +/** + * Adds a floating-point number, first converting it to fixed point by + * dividing it by the indicated threshold. + */ INLINE void ChecksumHashGenerator:: add_fp(float number, float threshold) { add_int((long)(number / threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_fp -// Access: Public -// Description: Adds a floating-point number, first converting it to -// fixed point by dividing it by the indicated -// threshold. -//////////////////////////////////////////////////////////////////// +/** + * Adds a floating-point number, first converting it to fixed point by + * dividing it by the indicated threshold. + */ INLINE void ChecksumHashGenerator:: add_fp(double number, double threshold) { add_int((long)(number / threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_pointer -// Access: Public -// Description: Adds a pointer, derived simply by casting the pointer -// to an integer. This should be good enough even on -// architectures for which this cast is lossy. -//////////////////////////////////////////////////////////////////// +/** + * Adds a pointer, derived simply by casting the pointer to an integer. This + * should be good enough even on architectures for which this cast is lossy. + */ INLINE void ChecksumHashGenerator:: add_pointer(void *ptr) { #ifdef _WIN32 diff --git a/panda/src/express/checksumHashGenerator.cxx b/panda/src/express/checksumHashGenerator.cxx index 0a2f7439f7..fbcf1b7563 100644 --- a/panda/src/express/checksumHashGenerator.cxx +++ b/panda/src/express/checksumHashGenerator.cxx @@ -1,25 +1,21 @@ -// Filename: checksumHashGenerator.cxx -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file checksumHashGenerator.cxx + * @author drose + * @date 2001-05-14 + */ #include "checksumHashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Function: ChecksumHashGenerator::add_string -// Access: Public -// Description: Adds a string to the hash, by breaking it down into a -// sequence of integers. -//////////////////////////////////////////////////////////////////// +/** + * Adds a string to the hash, by breaking it down into a sequence of integers. + */ void ChecksumHashGenerator:: add_string(const string &str) { add_int(str.length()); diff --git a/panda/src/express/checksumHashGenerator.h b/panda/src/express/checksumHashGenerator.h index 73d826e456..d1ee27afa3 100644 --- a/panda/src/express/checksumHashGenerator.h +++ b/panda/src/express/checksumHashGenerator.h @@ -1,16 +1,15 @@ -// Filename: checksumHashGenerator.h -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file checksumHashGenerator.h + * @author drose + * @date 2001-05-14 + */ #ifndef CHECKSUMHASHGENERATOR_H #define CHECKSUMHASHGENERATOR_H @@ -19,12 +18,10 @@ #include "hashGeneratorBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ChecksumHashGenerator -// Description : This is a specific kind of HashGenerator that simply -// adds up all of the ints. Nothing fancy, and pretty -// quick. -//////////////////////////////////////////////////////////////////// +/** + * This is a specific kind of HashGenerator that simply adds up all of the + * ints. Nothing fancy, and pretty quick. + */ class EXPCL_PANDAEXPRESS ChecksumHashGenerator : public HashGeneratorBase { public: INLINE void add_int(long num); diff --git a/panda/src/express/circBuffer.I b/panda/src/express/circBuffer.I index d7ed6a53a7..0dd75c8879 100644 --- a/panda/src/express/circBuffer.I +++ b/panda/src/express/circBuffer.I @@ -1,51 +1,42 @@ -// Filename: circBuffer.I -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file circBuffer.I + * @author drose + * @date 1999-02-08 + */ #include "pandabase.h" #include "config_express.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CircBuffer:: CircBuffer() { _in = _out = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CircBuffer:: ~CircBuffer() { } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::size -// Access: Public -// Description: Returns the number of items currently in the buffer. -// This can safely be called without synchronization -// from either the reader or the writer thread, but the -// size may of course vary without warning after the -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of items currently in the buffer. This can safely be + * called without synchronization from either the reader or the writer thread, + * but the size may of course vary without warning after the call. + */ template INLINE int CircBuffer:: size() const { @@ -53,44 +44,35 @@ size() const { return (diff >= 0) ? diff : max_size + 1 + diff; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::empty -// Access: Public -// Description: Returns true if the buffer is empty. It is safe to -// call this without synchronization primitives from -// either the reader or the writer thread, but the -// result may vary without warning after the call. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the buffer is empty. It is safe to call this without + * synchronization primitives from either the reader or the writer thread, but + * the result may vary without warning after the call. + */ template INLINE bool CircBuffer:: empty() const { return _in == _out; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::full -// Access: Public -// Description: Returns true if the buffer is full; if this is true, -// push_back() will fail. It is safe to call this -// without synchronization primitives from either the -// reader or the writer thread, but the result may vary -// without warning after the call. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the buffer is full; if this is true, push_back() will fail. + * It is safe to call this without synchronization primitives from either the + * reader or the writer thread, but the result may vary without warning after + * the call. + */ template INLINE bool CircBuffer:: full() const { - // return _in == _out-1 || (_in==max_size && _out==0); + // return _in == _out-1 || (_in==max_size && _out==0); return ((_in + 1) % (max_size + 1)) == _out; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::front -// Access: Public -// Description: Returns a reference to the first item in the queue. -// It is invalid to call this if empty() is true. It is -// safe to call this without synchronization only from -// the reading thread: the thread that calls pop_front(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the first item in the queue. It is invalid to call + * this if empty() is true. It is safe to call this without synchronization + * only from the reading thread: the thread that calls pop_front(). + */ template INLINE const Thing &CircBuffer:: front() const { @@ -98,14 +80,11 @@ front() const { return _array[_out]; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::front -// Access: Public -// Description: Returns a reference to the first item in the queue. -// It is invalid to call this if empty() is true. It is -// safe to call this without synchronization only from -// the reading thread: the thread that calls pop_front(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the first item in the queue. It is invalid to call + * this if empty() is true. It is safe to call this without synchronization + * only from the reading thread: the thread that calls pop_front(). + */ template INLINE Thing &CircBuffer:: front() { @@ -113,13 +92,11 @@ front() { return _array[_out]; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::operator [] -// Access: Public -// Description: Returns the nth element in the buffer. It is safe to -// call this without synchronization only from the -// reading thread: the thread that calls pop_front(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth element in the buffer. It is safe to call this without + * synchronization only from the reading thread: the thread that calls + * pop_front(). + */ template INLINE const Thing &CircBuffer:: operator[] (int n) const { @@ -127,13 +104,11 @@ operator[] (int n) const { return _array[(_out + n) % (max_size + 1)]; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::operator [] -// Access: Public -// Description: Returns the nth element in the buffer. It is safe to -// call this without synchronization only from the -// reading thread: the thread that calls pop_front(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth element in the buffer. It is safe to call this without + * synchronization only from the reading thread: the thread that calls + * pop_front(). + */ template INLINE Thing &CircBuffer:: operator[] (int n) { @@ -142,20 +117,18 @@ operator[] (int n) { } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::pop_front -// Access: Public -// Description: Removes the first item from the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Removes the first item from the buffer. + */ template INLINE void CircBuffer:: pop_front() { nassertv(!empty()); - // We need to clear out the old element to force its destructor to - // be called; it might be important. This will generate yet another - // UMR warning in Purify if the default constructor doesn't fully - // initialize the class. + // We need to clear out the old element to force its destructor to be + // called; it might be important. This will generate yet another UMR + // warning in Purify if the default constructor doesn't fully initialize the + // class. _array[_out] = Thing(); _out = (_out+1)%(max_size+1); @@ -164,15 +137,11 @@ pop_front() { -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::back -// Access: Public -// Description: Returns a reference to the last item in the queue. -// It is invalid to call this if empty() is true. It is -// safe to call this without synchronization primitives -// only from the writing thread: the thread that calls -// push_back(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the last item in the queue. It is invalid to call + * this if empty() is true. It is safe to call this without synchronization + * primitives only from the writing thread: the thread that calls push_back(). + */ template INLINE const Thing &CircBuffer:: back() const { @@ -180,15 +149,11 @@ back() const { return _array[(_in + max_size) % (max_size + 1)]; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::back -// Access: Public -// Description: Returns a reference to the last item in the queue. -// It is invalid to call this if empty() is true. It is -// safe to call this without synchronization primitives -// only from the writing thread: the thread that calls -// push_back(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the last item in the queue. It is invalid to call + * this if empty() is true. It is safe to call this without synchronization + * primitives only from the writing thread: the thread that calls push_back(). + */ template INLINE Thing &CircBuffer:: back() { @@ -196,12 +161,9 @@ back() { return _array[(_in + max_size) % (max_size + 1)]; } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::push_back -// Access: Public -// Description: Adds an item to the end of the buffer. This may fail -// if full() is true. -//////////////////////////////////////////////////////////////////// +/** + * Adds an item to the end of the buffer. This may fail if full() is true. + */ template INLINE void CircBuffer:: push_back(const Thing &t) { @@ -214,11 +176,9 @@ push_back(const Thing &t) { } } -//////////////////////////////////////////////////////////////////// -// Function: CircBuffer::clear -// Access: Public -// Description: Removes all items from the queue. -//////////////////////////////////////////////////////////////////// +/** + * Removes all items from the queue. + */ template INLINE void CircBuffer:: clear() { diff --git a/panda/src/express/circBuffer.h b/panda/src/express/circBuffer.h index ed62d05f7b..5ea66e0f87 100644 --- a/panda/src/express/circBuffer.h +++ b/panda/src/express/circBuffer.h @@ -1,44 +1,40 @@ -// Filename: circBuffer.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file circBuffer.h + * @author drose + * @date 1999-02-08 + */ #ifndef CIRCBUFFER_H #define CIRCBUFFER_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : CircBuffer -// Description : This class implements a queue of some type via a -// circular buffer. The circular buffer has the -// advantage that no synchronization is required when -// one process adds to the queue while another process -// extracts. It works for any kind of Thing that has a -// valid assignment operator and copy constructor -// defined. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a queue of some type via a circular buffer. The + * circular buffer has the advantage that no synchronization is required when + * one process adds to the queue while another process extracts. It works for + * any kind of Thing that has a valid assignment operator and copy constructor + * defined. + */ template class CircBuffer { public: INLINE CircBuffer(); INLINE ~CircBuffer(); - // Methods that are safe to call without synchronization primitives - // from either thread. + // Methods that are safe to call without synchronization primitives from + // either thread. INLINE int size() const; - // Methods that are safe to call without synchronization primitives - // only from the reader thread. + // Methods that are safe to call without synchronization primitives only + // from the reader thread. INLINE bool empty() const; INLINE const Thing &front() const; @@ -48,8 +44,8 @@ public: INLINE const Thing &operator[] (int n) const; INLINE Thing &operator[] (int n); - // Methods that are safe to call without synchronization primitives - // only from the writer thread. + // Methods that are safe to call without synchronization primitives only + // from the writer thread. INLINE bool full() const; INLINE const Thing &back() const; diff --git a/panda/src/express/compress_string.cxx b/panda/src/express/compress_string.cxx index 892457c288..8a32947490 100644 --- a/panda/src/express/compress_string.cxx +++ b/panda/src/express/compress_string.cxx @@ -1,16 +1,15 @@ -// Filename: compress_string.cxx -// Created by: drose (09Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compress_string.cxx + * @author drose + * @date 2009-08-09 + */ #include "compress_string.h" @@ -19,13 +18,10 @@ #include "virtualFileSystem.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Function: compress_string -// Access: Published -// Description: Compress the indicated source string at the given -// compression level (1 through 9). Returns the -// compressed string. -//////////////////////////////////////////////////////////////////// +/** + * Compress the indicated source string at the given compression level (1 + * through 9). Returns the compressed string. + */ string compress_string(const string &source, int compression_level) { ostringstream dest; @@ -43,16 +39,13 @@ compress_string(const string &source, int compression_level) { return dest.str(); } -//////////////////////////////////////////////////////////////////// -// Function: decompress_string -// Access: Published -// Description: Decompresss the previously-compressed string()). The -// return value is the decompressed string. -// -// Note that a decompression error cannot easily be -// detected, and the return value may simply be a -// garbage or truncated string. -//////////////////////////////////////////////////////////////////// +/** + * Decompresss the previously-compressed string()). The return value is the + * decompressed string. + * + * Note that a decompression error cannot easily be detected, and the return + * value may simply be a garbage or truncated string. + */ string decompress_string(const string &source) { istringstream source_stream(source); @@ -65,17 +58,13 @@ decompress_string(const string &source) { return dest_stream.str(); } -//////////////////////////////////////////////////////////////////// -// Function: compress_file -// Access: Published -// Description: Compresss the data from the source file at the given -// compression level (1 through 9). The source file is -// read in its entirety, and the compressed results are -// written to the dest file, overwriting its contents. -// The return value is bool on success, or false on -// failure. -//////////////////////////////////////////////////////////////////// -EXPCL_PANDAEXPRESS bool +/** + * Compresss the data from the source file at the given compression level (1 + * through 9). The source file is read in its entirety, and the compressed + * results are written to the dest file, overwriting its contents. The return + * value is bool on success, or false on failure. + */ +EXPCL_PANDAEXPRESS bool compress_file(const Filename &source, const Filename &dest, int compression_level) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename source_filename = source; @@ -88,7 +77,7 @@ compress_file(const Filename &source, const Filename &dest, int compression_leve express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } - + Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, false, true); if (dest_stream == NULL) { @@ -96,27 +85,23 @@ compress_file(const Filename &source, const Filename &dest, int compression_leve vfs->close_read_file(source_stream); return false; } - + bool result = compress_stream(*source_stream, *dest_stream, compression_level); vfs->close_read_file(source_stream); vfs->close_write_file(dest_stream); return result; } -//////////////////////////////////////////////////////////////////// -// Function: decompress_file -// Access: Published -// Description: Decompresss the data from the source file. The -// source file is read in its entirety, and the -// decompressed results are written to the dest file, -// overwriting its contents. The return value is bool -// on success, or false on failure. -// -// Note that a decompression error cannot easily be -// detected, and the output may simply be a garbage -// or truncated string. -//////////////////////////////////////////////////////////////////// -EXPCL_PANDAEXPRESS bool +/** + * Decompresss the data from the source file. The source file is read in its + * entirety, and the decompressed results are written to the dest file, + * overwriting its contents. The return value is bool on success, or false on + * failure. + * + * Note that a decompression error cannot easily be detected, and the output + * may simply be a garbage or truncated string. + */ +EXPCL_PANDAEXPRESS bool decompress_file(const Filename &source, const Filename &dest) { Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -125,7 +110,7 @@ decompress_file(const Filename &source, const Filename &dest) { express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } - + Filename dest_filename = dest; if (!dest_filename.is_binary_or_text()) { // The default is binary, if not specified otherwise. @@ -137,28 +122,24 @@ decompress_file(const Filename &source, const Filename &dest) { vfs->close_read_file(source_stream); return false; } - + bool result = decompress_stream(*source_stream, *dest_stream); vfs->close_read_file(source_stream); vfs->close_write_file(dest_stream); return result; } -//////////////////////////////////////////////////////////////////// -// Function: compress_stream -// Access: Published -// Description: Compresss the data from the source stream at the -// given compression level (1 through 9). The source -// stream is read from its current position to the -// end-of-file, and the compressed results are written -// to the dest stream. The return value is bool on -// success, or false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Compresss the data from the source stream at the given compression level (1 + * through 9). The source stream is read from its current position to the + * end-of-file, and the compressed results are written to the dest stream. + * The return value is bool on success, or false on failure. + */ bool compress_stream(istream &source, ostream &dest, int compression_level) { OCompressStream compress; compress.open(&dest, false, compression_level); - + static const size_t buffer_size = 4096; char buffer[buffer_size]; @@ -174,20 +155,15 @@ compress_stream(istream &source, ostream &dest, int compression_level) { return (!source.fail() || source.eof()) && (!compress.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: decompress_stream -// Access: Published -// Description: Decompresss the data from the previously-compressed -// source stream. The source stream is read from its -// current position to the end-of-file, and the -// decompressed results are written to the dest stream. -// The return value is bool on success, or false on -// failure. -// -// Note that a decompression error cannot easily be -// detected, and the output may simply be a garbage -// or truncated string. -//////////////////////////////////////////////////////////////////// +/** + * Decompresss the data from the previously-compressed source stream. The + * source stream is read from its current position to the end-of-file, and the + * decompressed results are written to the dest stream. The return value is + * bool on success, or false on failure. + * + * Note that a decompression error cannot easily be detected, and the output + * may simply be a garbage or truncated string. + */ bool decompress_stream(istream &source, ostream &dest) { IDecompressStream decompress(&source, false); @@ -202,7 +178,7 @@ decompress_stream(istream &source, ostream &dest) { decompress.read(buffer, buffer_size); count = decompress.gcount(); } - + return (!decompress.fail() || decompress.eof()) && (!dest.fail()); } diff --git a/panda/src/express/compress_string.h b/panda/src/express/compress_string.h index abacecdb10..433f1dd3e6 100644 --- a/panda/src/express/compress_string.h +++ b/panda/src/express/compress_string.h @@ -1,16 +1,15 @@ -// Filename: compress_string.h -// Created by: drose (09Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compress_string.h + * @author drose + * @date 2009-08-09 + */ #ifndef COMPRESS_STRING_H #define COMPRESS_STRING_H diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index 8a37739c32..8bf5dff316 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -1,16 +1,15 @@ -// Filename: config_express.cxx -// Created by: drose (28Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_express.cxx + * @author drose + * @date 2006-03-28 + */ #include "config_express.h" #include "datagram.h" @@ -83,14 +82,12 @@ ConfigVariableBool collect_tcp ConfigVariableDouble collect_tcp_interval ("collect-tcp-interval", 0.2); -//////////////////////////////////////////////////////////////////// -// Function: init_libexpress -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libexpress() { static bool initialized = false; @@ -128,8 +125,8 @@ init_libexpress() { } #endif - // This is a fine place to ensure that the numeric types have been - // chosen correctly. + // This is a fine place to ensure that the numeric types have been chosen + // correctly. nassertv(sizeof(PN_int8) == 1 && sizeof(PN_uint8) == 1); nassertv(sizeof(PN_int16) == 2 && sizeof(PN_uint16) == 2); nassertv(sizeof(PN_int32) == 4 && sizeof(PN_uint32) == 4); @@ -201,30 +198,26 @@ get_config_express() { #ifdef ANDROID static JavaVM *panda_jvm = NULL; -//////////////////////////////////////////////////////////////////// -// Function: JNI_OnLoad -// Description: Called by Java when loading this library. -//////////////////////////////////////////////////////////////////// +/** + * Called by Java when loading this library. + */ jint JNI_OnLoad(JavaVM *jvm, void *reserved) { panda_jvm = jvm; return JNI_VERSION_1_4; } -//////////////////////////////////////////////////////////////////// -// Function: get_java_vm -// Description: Returns a pointer to the JavaVM object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the JavaVM object. + */ JavaVM *get_java_vm() { nassertr(panda_jvm != NULL, NULL); return panda_jvm; } -//////////////////////////////////////////////////////////////////// -// Function: get_jni_env -// Description: Returns a JNIEnv object for the current thread. -// If it doesn't already exist, attaches the JVM -// to this thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a JNIEnv object for the current thread. If it doesn't already + * exist, attaches the JVM to this thread. + */ JNIEnv *get_jni_env() { nassertr(panda_jvm != NULL, NULL); JNIEnv *env = NULL; diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index 863c0f60f5..53f33ca36a 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -1,16 +1,15 @@ -// Filename: config_express.h -// Created by: cary (04Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_express.h + * @author cary + * @date 2000-01-04 + */ #ifndef __CONFIG_EXPRESS_H__ #define __CONFIG_EXPRESS_H__ @@ -37,12 +36,11 @@ ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(clock, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); -// Actually, we can't determine this config variable the normal way, -// because we must be able to access it at static init time. Instead -// of declaring it a global constant, we'll make it a member of -// MemoryUsage. +// Actually, we can't determine this config variable the normal way, because +// we must be able to access it at static init time. Instead of declaring it +// a global constant, we'll make it a member of MemoryUsage. -//extern EXPCL_PANDAEXPRESS const bool track_memory_usage; +// extern EXPCL_PANDAEXPRESS const bool track_memory_usage; EXPCL_PANDAEXPRESS bool get_use_high_res_clock(); EXPCL_PANDAEXPRESS bool get_paranoid_clock(); diff --git a/panda/src/express/copy_stream.cxx b/panda/src/express/copy_stream.cxx index 7902716258..77d0e78364 100644 --- a/panda/src/express/copy_stream.cxx +++ b/panda/src/express/copy_stream.cxx @@ -1,27 +1,23 @@ -// Filename: copy_stream.cxx -// Created by: drose (27Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copy_stream.cxx + * @author drose + * @date 2009-08-27 + */ #include "copy_stream.h" -//////////////////////////////////////////////////////////////////// -// Function: copy_stream -// Access: Published -// Description: Reads the source stream from its current position to -// the end of the stream, and writes that data to the -// dest stream at its current position. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the source stream from its current position to the end of the stream, + * and writes that data to the dest stream at its current position. Returns + * true on success, false on failure. + */ bool copy_stream(istream &source, ostream &dest) { static const size_t buffer_size = 4096; @@ -34,6 +30,6 @@ copy_stream(istream &source, ostream &dest) { source.read(buffer, buffer_size); count = source.gcount(); } - + return (!source.fail() || source.eof()) && (!dest.fail()); } diff --git a/panda/src/express/copy_stream.h b/panda/src/express/copy_stream.h index 6e2274aa4e..b501bb682e 100644 --- a/panda/src/express/copy_stream.h +++ b/panda/src/express/copy_stream.h @@ -1,16 +1,15 @@ -// Filename: copy_stream.h -// Created by: drose (27Aug09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copy_stream.h + * @author drose + * @date 2009-08-27 + */ #ifndef COPY_STREAM_H #define COPY_STREAM_H diff --git a/panda/src/express/datagram.I b/panda/src/express/datagram.I index 2853fe6447..ded1a56d09 100644 --- a/panda/src/express/datagram.I +++ b/panda/src/express/datagram.I @@ -1,22 +1,19 @@ -// Filename: datagram.I -// Created by: drose (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagram.I + * @author drose + * @date 2000-06-06 + */ -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Constructor -// Access: Public -// Description: Constructs an empty datagram. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty datagram. + */ INLINE Datagram:: Datagram() : #ifdef STDFLOAT_DOUBLE @@ -27,11 +24,9 @@ Datagram() : { } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Constructor -// Access: Public -// Description: Constructs a datagram from an existing block of data. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a datagram from an existing block of data. + */ INLINE Datagram:: Datagram(const void *data, size_t size) : #ifdef STDFLOAT_DOUBLE @@ -43,11 +38,9 @@ Datagram(const void *data, size_t size) : append_data(data, size); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Constructor -// Access: Public -// Description: Constructs a datagram from an existing block of data. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a datagram from an existing block of data. + */ INLINE Datagram:: Datagram(const string &data) : #ifdef STDFLOAT_DOUBLE @@ -59,11 +52,9 @@ Datagram(const string &data) : append_data(data); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Datagram:: Datagram(const Datagram ©) : _data(copy._data), @@ -71,11 +62,9 @@ Datagram(const Datagram ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Datagram:: operator = (const Datagram ©) { _data = copy._data; @@ -83,11 +72,9 @@ operator = (const Datagram ©) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Datagram:: Datagram(Datagram &&from) NOEXCEPT : _data(move(from._data)), @@ -97,11 +84,9 @@ Datagram(Datagram &&from) NOEXCEPT : #endif // USE_MOVE_SEMANTICS #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Datagram:: operator = (Datagram &&from) NOEXCEPT { _data = move(from._data); @@ -109,133 +94,108 @@ operator = (Datagram &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_bool -// Access: Public -// Description: Adds a boolean value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a boolean value to the datagram. + */ INLINE void Datagram:: add_bool(bool b) { add_uint8(b); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_int8 -// Access: Public -// Description: Adds a signed 8-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 8-bit integer to the datagram. + */ INLINE void Datagram:: add_int8(PN_int8 value) { append_data(&value, 1); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_uint8 -// Access: Public -// Description: Adds an unsigned 8-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 8-bit integer to the datagram. + */ INLINE void Datagram:: add_uint8(PN_uint8 value) { append_data(&value, 1); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_int16 -// Access: Public -// Description: Adds a signed 16-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 16-bit integer to the datagram. + */ INLINE void Datagram:: add_int16(PN_int16 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_int32 -// Access: Public -// Description: Adds a signed 32-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 32-bit integer to the datagram. + */ INLINE void Datagram:: add_int32(PN_int32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_int64 -// Access: Public -// Description: Adds a signed 64-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 64-bit integer to the datagram. + */ INLINE void Datagram:: add_int64(PN_int64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_uint16 -// Access: Public -// Description: Adds an unsigned 16-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 16-bit integer to the datagram. + */ INLINE void Datagram:: add_uint16(PN_uint16 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_uint32 -// Access: Public -// Description: Adds an unsigned 32-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 32-bit integer to the datagram. + */ INLINE void Datagram:: add_uint32(PN_uint32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_uint64 -// Access: Public -// Description: Adds an unsigned 64-bit integer to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 64-bit integer to the datagram. + */ INLINE void Datagram:: add_uint64(PN_uint64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_float32 -// Access: Public -// Description: Adds a 32-bit single-precision floating-point number -// to the datagram. Since this kind of float is not -// necessarily portable across different architectures, -// special care is required. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 32-bit single-precision floating-point number to the datagram. + * Since this kind of float is not necessarily portable across different + * architectures, special care is required. + */ INLINE void Datagram:: add_float32(PN_float32 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_float64 -// Access: Public -// Description: Adds a 64-bit floating-point number to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 64-bit floating-point number to the datagram. + */ INLINE void Datagram:: add_float64(PN_float64 value) { LittleEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_stdfloat -// Access: Public -// Description: Adds either a 32-bit or a 64-bit floating-point -// number, according to set_stdfloat_double(). -//////////////////////////////////////////////////////////////////// +/** + * Adds either a 32-bit or a 64-bit floating-point number, according to + * set_stdfloat_double(). + */ INLINE void Datagram:: add_stdfloat(PN_stdfloat value) { if (_stdfloat_double) { @@ -245,108 +205,83 @@ add_stdfloat(PN_stdfloat value) { } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_int16 -// Access: Public -// Description: Adds a signed 16-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 16-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_int16(PN_int16 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_int32 -// Access: Public -// Description: Adds a signed 32-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 32-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_int32(PN_int32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_int64 -// Access: Public -// Description: Adds a signed 64-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a signed 64-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_int64(PN_int64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_uint16 -// Access: Public -// Description: Adds an unsigned 16-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 16-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_uint16(PN_uint16 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_uint32 -// Access: Public -// Description: Adds an unsigned 32-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 32-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_uint32(PN_uint32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_uint64 -// Access: Public -// Description: Adds an unsigned 64-bit big-endian integer to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds an unsigned 64-bit big-endian integer to the datagram. + */ INLINE void Datagram:: add_be_uint64(PN_uint64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_float32 -// Access: Public -// Description: Adds a 32-bit single-precision big-endian -// floating-point number to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 32-bit single-precision big-endian floating-point number to the + * datagram. + */ INLINE void Datagram:: add_be_float32(PN_float32 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_be_float64 -// Access: Public -// Description: Adds a 64-bit big-endian floating-point number to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 64-bit big-endian floating-point number to the datagram. + */ INLINE void Datagram:: add_be_float64(PN_float64 value) { BigEndian s(&value, sizeof(value)); append_data(s.get_data(), sizeof(value)); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_string -// Access: Public -// Description: Adds a variable-length string to the datagram. This -// actually adds a count followed by n bytes. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the datagram. This actually adds a count + * followed by n bytes. + */ INLINE void Datagram:: add_string(const string &str) { // The max sendable length for a string is 2^16. @@ -359,12 +294,10 @@ add_string(const string &str) { append_data(str); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_string32 -// Access: Public -// Description: Adds a variable-length string to the datagram, using -// a 32-bit length field to allow very long strings. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the datagram, using a 32-bit length field + * to allow very long strings. + */ INLINE void Datagram:: add_string32(const string &str) { // Strings always are preceded by their length @@ -374,12 +307,9 @@ add_string32(const string &str) { append_data(str); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_z_string -// Access: Public -// Description: Adds a variable-length string to the datagram, as a -// NULL-terminated string. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length string to the datagram, as a NULL-terminated string. + */ INLINE void Datagram:: add_z_string(string str) { // We must not have any nested null characters in the string. @@ -391,15 +321,11 @@ add_z_string(string str) { add_uint8('\0'); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_fixed_string -// Access: Public -// Description: Adds a fixed-length string to the datagram. If the -// string given is less than the requested size, this -// will pad the string out with zeroes; if it is greater -// than the requested size, this will silently truncate -// the string. -//////////////////////////////////////////////////////////////////// +/** + * Adds a fixed-length string to the datagram. If the string given is less + * than the requested size, this will pad the string out with zeroes; if it is + * greater than the requested size, this will silently truncate the string. + */ INLINE void Datagram:: add_fixed_string(const string &str, size_t size) { if (str.length() < size) { @@ -411,22 +337,17 @@ add_fixed_string(const string &str, size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::append_data -// Access: Public -// Description: Appends some more raw data to the end of the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Appends some more raw data to the end of the datagram. + */ INLINE void Datagram:: append_data(const string &data) { append_data(data.data(), data.length()); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::get_message -// Access: Public -// Description: Returns the datagram's data as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the datagram's data as a string. + */ INLINE string Datagram:: get_message() const { // Silly special case for gcc 3.2, which can't tolerate string(NULL, 0). @@ -437,109 +358,82 @@ get_message() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::get_data -// Access: Public -// Description: Returns a pointer to the beginning of the datagram's -// data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the beginning of the datagram's data. + */ INLINE const void *Datagram:: get_data() const { return _data.p(); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::get_length -// Access: Public -// Description: Returns the number of bytes in the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes in the datagram. + */ INLINE size_t Datagram:: get_length() const { return _data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::set_array -// Access: Public -// Description: Replaces the data in the Datagram with the data in -// the indicated PTA_uchar. This is assignment by -// reference: subsequent changes to the Datagram will -// also change the source PTA_uchar. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the data in the Datagram with the data in the indicated PTA_uchar. + * This is assignment by reference: subsequent changes to the Datagram will + * also change the source PTA_uchar. + */ INLINE void Datagram:: set_array(PTA_uchar data) { _data = data; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::copy_array -// Access: Public -// Description: Replaces the data in the Datagram with a copy of the -// data in the indicated CPTA_uchar. Unlike -// set_array(), a complete copy is made of the data; -// subsequent changes to the Datagram will *not* change -// the source CPTA_uchar. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the data in the Datagram with a copy of the data in the indicated + * CPTA_uchar. Unlike set_array(), a complete copy is made of the data; + * subsequent changes to the Datagram will *not* change the source CPTA_uchar. + */ INLINE void Datagram:: copy_array(CPTA_uchar data) { _data.clear(); _data.v() = data.v(); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::get_array -// Access: Public -// Description: Returns a const pointer to the actual data in -// the Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the actual data in the Datagram. + */ INLINE CPTA_uchar Datagram:: get_array() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::modify_array -// Access: Public -// Description: Returns a modifiable pointer to the actual data in -// the Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the actual data in the Datagram. + */ INLINE PTA_uchar Datagram:: modify_array() { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::set_stdfloat_double -// Access: Public -// Description: Changes the stdfloat_double flag, which defines the -// operation performed by add_stdfloat() and -// DatagramIterator::get_stdfloat(). When this is true, -// add_stdfloat() adds a 64-bit floating-point number; -// when it is false, it adds a 32-bit floating-point -// number. The default is based on the STDFLOAT_DOUBLE -// compilation flag. -//////////////////////////////////////////////////////////////////// +/** + * Changes the stdfloat_double flag, which defines the operation performed by + * add_stdfloat() and DatagramIterator::get_stdfloat(). When this is true, + * add_stdfloat() adds a 64-bit floating-point number; when it is false, it + * adds a 32-bit floating-point number. The default is based on the + * STDFLOAT_DOUBLE compilation flag. + */ INLINE void Datagram:: set_stdfloat_double(bool stdfloat_double) { _stdfloat_double = stdfloat_double; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::get_stdfloat_double -// Access: Public -// Description: Returns the stdfloat_double flag. See -// set_stdfloat_double(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the stdfloat_double flag. See set_stdfloat_double(). + */ INLINE bool Datagram:: get_stdfloat_double() const { return _stdfloat_double; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Datagram:: operator == (const Datagram &other) const { if (_data == other._data) { @@ -551,21 +445,17 @@ operator == (const Datagram &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Datagram:: operator != (const Datagram &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Datagram:: operator < (const Datagram &other) const { if (_data == other._data) { diff --git a/panda/src/express/datagram.cxx b/panda/src/express/datagram.cxx index 9af23acbe9..cf0d442e14 100644 --- a/panda/src/express/datagram.cxx +++ b/panda/src/express/datagram.cxx @@ -1,17 +1,15 @@ -// Filename: datagram.cxx -// Created by: drose (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagram.cxx + * @author drose + * @date 2000-06-06 + */ #include "datagram.h" @@ -22,32 +20,26 @@ TypeHandle Datagram::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Datagram::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Datagram:: ~Datagram() { } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::clear -// Access: Public, Virtual -// Description: Resets the datagram to empty, in preparation for -// building up a new datagram. -//////////////////////////////////////////////////////////////////// +/** + * Resets the datagram to empty, in preparation for building up a new + * datagram. + */ void Datagram:: clear() { _data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::dump_hex -// Access: Public -// Description: Writes a representation of the entire datagram -// contents, as a sequence of hex (and ASCII) values. -//////////////////////////////////////////////////////////////////// +/** + * Writes a representation of the entire datagram contents, as a sequence of + * hex (and ASCII) values. + */ void Datagram:: dump_hex(ostream &out, unsigned int indent) const { const char *message = (const char *)get_data(); @@ -72,7 +64,8 @@ dump_hex(ostream &out, unsigned int indent) const { } out << " "; for (p = line; p < line + 16 && p < num_bytes; p++) { - // must cast to (unsigned char) to avoid conversion to large negative integers outside of 0xFF range + // must cast to (unsigned char) to avoid conversion to large negative + // integers outside of 0xFF range if (isgraph((unsigned char)message[p]) || message[p] == ' ') { out << (char)message[p]; } else { @@ -83,30 +76,25 @@ dump_hex(ostream &out, unsigned int indent) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::add_wstring -// Access: Public -// Description: Adds a variable-length wstring to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a variable-length wstring to the datagram. + */ void Datagram:: add_wstring(const wstring &str) { // By convention, wstrings are marked with 32-bit lengths. add_uint32((PN_uint32)str.length()); - // Now append each character in the string. We store each code - // little-endian, for no real good reason. + // Now append each character in the string. We store each code little- + // endian, for no real good reason. wstring::const_iterator ci; for (ci = str.begin(); ci != str.end(); ++ci) { add_uint16((PN_uint16)*ci); } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::pad_bytes -// Access: Public -// Description: Adds the indicated number of zero bytes to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated number of zero bytes to the datagram. + */ void Datagram:: pad_bytes(size_t size) { nassertv((int)size >= 0); @@ -124,9 +112,9 @@ pad_bytes(size_t size) { // Now append the data. - // It is very important that we *don't* do this reserve() operation. - // See the further comments in append_data(), below. - // _data.reserve(_data.size() + size); + // It is very important that we *don't* do this reserve() operation. See + // the further comments in append_data(), below. _data.reserve(_data.size() + // + size); while (size > 0) { _data.push_back('\0'); @@ -134,12 +122,9 @@ pad_bytes(size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::append_data -// Access: Public -// Description: Appends some more raw data to the end of the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Appends some more raw data to the end of the datagram. + */ void Datagram:: append_data(const void *data, size_t size) { nassertv((int)size >= 0); @@ -157,23 +142,19 @@ append_data(const void *data, size_t size) { // Now append the data. - // It is very important that we *don't* do this reserve() operation. - // This actually slows it down on Windows, which takes the reserve() - // request as a fixed size the array should be set to (!) instead of - // as a minimum size to guarantee. This forces the array to - // reallocate itself with *every* call to append_data! - // _data.reserve(_data.size() + size); + // It is very important that we *don't* do this reserve() operation. This + // actually slows it down on Windows, which takes the reserve() request as a + // fixed size the array should be set to (!) instead of as a minimum size to + // guarantee. This forces the array to reallocate itself with *every* call + // to append_data! _data.reserve(_data.size() + size); _data.v().insert(_data.v().end(), (const unsigned char *)data, (const unsigned char *)data + size); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::assign -// Access: Public -// Description: Replaces the datagram's data with the indicated -// block. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the datagram's data with the indicated block. + */ void Datagram:: assign(const void *data, size_t size) { nassertv((int)size >= 0); @@ -183,12 +164,9 @@ assign(const void *data, size_t size) { (const unsigned char *)data + size); } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Datagram:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -196,12 +174,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: Datagram::write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Datagram:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/express/datagram.h b/panda/src/express/datagram.h index 5de3ce6467..b599fca10b 100644 --- a/panda/src/express/datagram.h +++ b/panda/src/express/datagram.h @@ -1,16 +1,15 @@ -// Filename: datagram.h -// Created by: drose (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagram.h + * @author drose + * @date 2000-06-06 + */ #ifndef DATAGRAM_H #define DATAGRAM_H @@ -23,23 +22,19 @@ #include "bigEndian.h" #include "pta_uchar.h" -//////////////////////////////////////////////////////////////////// -// Class : Datagram -// Description : An ordered list of data elements, formatted in memory -// for transmission over a socket or writing to a data -// file. -// -// Data elements should be added one at a time, in -// order, to the Datagram. The nature and contents of -// the data elements are totally up to the user. When a -// Datagram has been transmitted and received, its data -// elements may be extracted using a DatagramIterator; -// it is up to the caller to know the correct type of -// each data element in order. -// -// A Datagram is itself headerless; it is simply a -// collection of data elements. -//////////////////////////////////////////////////////////////////// +/** + * An ordered list of data elements, formatted in memory for transmission over + * a socket or writing to a data file. + * + * Data elements should be added one at a time, in order, to the Datagram. + * The nature and contents of the data elements are totally up to the user. + * When a Datagram has been transmitted and received, its data elements may be + * extracted using a DatagramIterator; it is up to the caller to know the + * correct type of each data element in order. + * + * A Datagram is itself headerless; it is simply a collection of data + * elements. + */ class EXPCL_PANDAEXPRESS Datagram : public TypedObject { PUBLISHED: INLINE Datagram(); @@ -138,10 +133,10 @@ private: static TypeHandle _type_handle; }; -// These generic functions are primarily for writing a value to a -// datagram from within a template in which the actual type of the -// value is not known. If you do know the type, it's preferable to -// use the explicit add_*() method from above instead. +// These generic functions are primarily for writing a value to a datagram +// from within a template in which the actual type of the value is not known. +// If you do know the type, it's preferable to use the explicit add_*() method +// from above instead. INLINE void generic_write_datagram(Datagram &dest, bool value); diff --git a/panda/src/express/datagramGenerator.I b/panda/src/express/datagramGenerator.I index a36578c5c3..bfb73f0482 100644 --- a/panda/src/express/datagramGenerator.I +++ b/panda/src/express/datagramGenerator.I @@ -1,24 +1,19 @@ -// Filename: datagramGenerator.I -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGenerator.I + * @author jason + * @date 2000-06-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::Constructor -// Access: Published -// Description: Does nothing since this is class is just -// the definition of an interface -//////////////////////////////////////////////////////////////////// +/** + * Does nothing since this is class is just the definition of an interface + */ INLINE DatagramGenerator:: DatagramGenerator() { } diff --git a/panda/src/express/datagramGenerator.cxx b/panda/src/express/datagramGenerator.cxx index 8eee70b453..a5e9f52bb8 100644 --- a/panda/src/express/datagramGenerator.cxx +++ b/panda/src/express/datagramGenerator.cxx @@ -1,58 +1,46 @@ -// Filename: datagramGenerator.cxx -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGenerator.cxx + * @author jason + * @date 2000-06-07 + */ #include "pandabase.h" #include "datagramGenerator.h" #include "temporaryFile.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::Destructor -// Access: Published, Virtual -// Description: Does nothing since this is class is just -// the definition of an interface -//////////////////////////////////////////////////////////////////// +/** + * Does nothing since this is class is just the definition of an interface + */ DatagramGenerator:: ~DatagramGenerator() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::save_datagram -// Access: Published, Virtual -// Description: Skips over the next datagram without extracting it, -// but saves the relevant file information in the -// SubfileInfo object so that its data may be read -// later. For non-file-based datagram generators, this -// may mean creating a temporary file and copying the -// contents of the datagram to disk. -// -// Returns true on success, false on failure or if this -// method is unimplemented. -//////////////////////////////////////////////////////////////////// +/** + * Skips over the next datagram without extracting it, but saves the relevant + * file information in the SubfileInfo object so that its data may be read + * later. For non-file-based datagram generators, this may mean creating a + * temporary file and copying the contents of the datagram to disk. + * + * Returns true on success, false on failure or if this method is + * unimplemented. + */ bool DatagramGenerator:: save_datagram(SubfileInfo &info) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::get_filename -// Access: Published, Virtual -// Description: Returns the filename that provides the source for -// these datagrams, if any, or empty string if the -// datagrams do not originate from a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that provides the source for these datagrams, if any, + * or empty string if the datagrams do not originate from a file on disk. + */ const Filename &DatagramGenerator:: get_filename() { const FileReference *file = get_file(); @@ -63,54 +51,41 @@ get_filename() { return empty_filename; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::get_timestamp -// Access: Published, Virtual -// Description: Returns the on-disk timestamp of the file that was -// read, at the time it was opened, if that is -// available, or 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the on-disk timestamp of the file that was read, at the time it was + * opened, if that is available, or 0 if it is not. + */ time_t DatagramGenerator:: get_timestamp() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::get_file -// Access: Published, Virtual -// Description: Returns the FileReference that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a file on disk. + */ const FileReference *DatagramGenerator:: get_file() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::get_vfile -// Access: Published, Virtual -// Description: Returns the VirtualFile that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a VirtualFile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFile that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a VirtualFile. + */ VirtualFile *DatagramGenerator:: get_vfile() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGenerator::get_file_pos -// Access: Published, Virtual -// Description: Returns the current file position within the data -// stream, if any, or 0 if the file position is not -// meaningful or cannot be determined. -// -// For DatagramGenerators that return a meaningful file -// position, this will be pointing to the first byte -// following the datagram returned after a call to -// get_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file position within the data stream, if any, or 0 if + * the file position is not meaningful or cannot be determined. + * + * For DatagramGenerators that return a meaningful file position, this will be + * pointing to the first byte following the datagram returned after a call to + * get_datagram(). + */ streampos DatagramGenerator:: get_file_pos() { return 0; diff --git a/panda/src/express/datagramGenerator.h b/panda/src/express/datagramGenerator.h index 3d8361137b..8d46f9df80 100644 --- a/panda/src/express/datagramGenerator.h +++ b/panda/src/express/datagramGenerator.h @@ -1,16 +1,15 @@ -// Filename: datagramGenerator.h -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGenerator.h + * @author jason + * @date 2000-06-07 + */ #ifndef DATAGRAMGENERATOR_H #define DATAGRAMGENERATOR_H @@ -24,12 +23,10 @@ class FileReference; class Filename; class VirtualFile; -//////////////////////////////////////////////////////////////////// -// Class : DatagramGenerator -// Description : This class defines the abstract interace to any -// source of datagrams, whether it be from a file or -// from the net. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the abstract interace to any source of datagrams, + * whether it be from a file or from the net. + */ class EXPCL_PANDAEXPRESS DatagramGenerator { PUBLISHED: INLINE DatagramGenerator(); diff --git a/panda/src/express/datagramIterator.I b/panda/src/express/datagramIterator.I index 899ea2aaf0..0e4fff93f4 100644 --- a/panda/src/express/datagramIterator.I +++ b/panda/src/express/datagramIterator.I @@ -1,34 +1,28 @@ -// Filename: datagramIterator.I -// Created by: drose (08May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramIterator.I + * @author drose + * @date 2001-05-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramIterator:: DatagramIterator() : _datagram((Datagram *)NULL), _current_index(0) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramIterator:: DatagramIterator(const Datagram &datagram, size_t offset) : _datagram(&datagram), @@ -36,64 +30,51 @@ DatagramIterator(const Datagram &datagram, size_t offset) : nassertv(_current_index <= _datagram->get_length()); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramIterator:: DatagramIterator(const DatagramIterator ©) : _datagram(copy._datagram), _current_index(copy._current_index) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void DatagramIterator:: operator = (const DatagramIterator ©) { _datagram = copy._datagram; _current_index = copy._current_index; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::assign -// Access: Public -// Description: direct Assignment to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * direct Assignment to a Datagram + */ INLINE void DatagramIterator::assign(Datagram &datagram, size_t offset) { _datagram =&datagram; - _current_index = offset; + _current_index = offset; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramIterator:: ~DatagramIterator() { } -// Various ways to get data and increment the iterator... -// Cut-and-paste-orama +// Various ways to get data and increment the iterator... Cut-and-paste-orama -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_bool -// Access: Public -// Description: Extracts a boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a boolean value. + */ INLINE bool DatagramIterator:: get_bool() { return get_uint8() != 0; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_int8 -// Access: Public -// Description: Extracts a signed 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 8-bit integer. + */ INLINE PN_int8 DatagramIterator:: get_int8() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -107,11 +88,9 @@ get_int8() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_uint8 -// Access: Public -// Description: Extracts an unsigned 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 8-bit integer. + */ INLINE PN_uint8 DatagramIterator:: get_uint8() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -125,11 +104,9 @@ get_uint8() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_int16 -// Access: Public -// Description: Extracts a signed 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 16-bit integer. + */ INLINE PN_int16 DatagramIterator:: get_int16() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -146,11 +123,9 @@ get_int16() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_int32 -// Access: Public -// Description: Extracts a signed 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 32-bit integer. + */ INLINE PN_int32 DatagramIterator:: get_int32() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -167,11 +142,9 @@ get_int32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_int64 -// Access: Public -// Description: Extracts a signed 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 64-bit integer. + */ INLINE PN_int64 DatagramIterator:: get_int64() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -188,17 +161,15 @@ get_int64() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_uint16 -// Access: Public -// Description: Extracts an unsigned 16-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 16-bit integer. + */ INLINE PN_uint16 DatagramIterator:: get_uint16() { nassertr(_datagram != (const Datagram *)NULL, 0); nassertr(_current_index < _datagram->get_length(), 0); - PN_uint16 tempvar; + PN_uint16 tempvar; // Avoid reading junk data off the end of the datagram: nassertr(_current_index + sizeof(tempvar) <= _datagram->get_length(), 0); // Get the Data: @@ -209,11 +180,9 @@ get_uint16() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_uint32 -// Access: Public -// Description: Extracts an unsigned 32-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 32-bit integer. + */ INLINE PN_uint32 DatagramIterator:: get_uint32() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -230,11 +199,9 @@ get_uint32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_uint64 -// Access: Public -// Description: Extracts an unsigned 64-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 64-bit integer. + */ INLINE PN_uint64 DatagramIterator:: get_uint64() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -251,12 +218,9 @@ get_uint64() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_float32 -// Access: Public -// Description: Extracts a 32-bit single-precision floating-point -// number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 32-bit single-precision floating-point number. + */ INLINE PN_float32 DatagramIterator:: get_float32() { nassertr(_datagram != (const Datagram *)NULL, 0.0); @@ -273,11 +237,9 @@ get_float32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_float64 -// Access: Public -// Description: Extracts a 64-bit floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 64-bit floating-point number. + */ INLINE PN_float64 DatagramIterator:: get_float64() { nassertr(_datagram != (const Datagram *)NULL, 0.0); @@ -295,12 +257,10 @@ get_float64() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_stdfloat -// Access: Public -// Description: Extracts either a 32-bit or a 64-bit floating-point -// number, according to Datagram::set_stdfloat_double(). -//////////////////////////////////////////////////////////////////// +/** + * Extracts either a 32-bit or a 64-bit floating-point number, according to + * Datagram::set_stdfloat_double(). + */ INLINE PN_stdfloat DatagramIterator:: get_stdfloat() { nassertr(_datagram != (const Datagram *)NULL, 0.0); @@ -311,11 +271,9 @@ get_stdfloat() { } } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_int16 -// Access: Public -// Description: Extracts a signed 16-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 16-bit big-endian integer. + */ INLINE PN_int16 DatagramIterator:: get_be_int16() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -332,11 +290,9 @@ get_be_int16() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_int32 -// Access: Public -// Description: Extracts a signed 32-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 32-bit big-endian integer. + */ INLINE PN_int32 DatagramIterator:: get_be_int32() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -353,11 +309,9 @@ get_be_int32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_int64 -// Access: Public -// Description: Extracts a signed 64-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 64-bit big-endian integer. + */ INLINE PN_int64 DatagramIterator:: get_be_int64() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -374,11 +328,9 @@ get_be_int64() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_uint16 -// Access: Public -// Description: Extracts an unsigned 16-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 16-bit big-endian integer. + */ INLINE PN_uint16 DatagramIterator:: get_be_uint16() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -395,11 +347,9 @@ get_be_uint16() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_uint32 -// Access: Public -// Description: Extracts an unsigned 32-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 32-bit big-endian integer. + */ INLINE PN_uint32 DatagramIterator:: get_be_uint32() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -416,11 +366,9 @@ get_be_uint32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_uint64 -// Access: Public -// Description: Extracts an unsigned 64-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 64-bit big-endian integer. + */ INLINE PN_uint64 DatagramIterator:: get_be_uint64() { nassertr(_datagram != (const Datagram *)NULL, 0); @@ -437,12 +385,9 @@ get_be_uint64() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_float32 -// Access: Public -// Description: Extracts a 32-bit big-endian single-precision -// floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 32-bit big-endian single-precision floating-point number. + */ INLINE PN_float32 DatagramIterator:: get_be_float32() { nassertr(_datagram != (const Datagram *)NULL, 0.0); @@ -459,11 +404,9 @@ get_be_float32() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_be_float64 -// Access: Public -// Description: Extracts a 64-bit big-endian floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 64-bit big-endian floating-point number. + */ INLINE PN_float64 DatagramIterator:: get_be_float64() { nassertr(_datagram != (const Datagram *)NULL, 0.0); @@ -480,12 +423,9 @@ get_be_float64() { return tempvar; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::skip_bytes -// Access: Public -// Description: Skips over the indicated number of bytes in the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Skips over the indicated number of bytes in the datagram. + */ INLINE void DatagramIterator:: skip_bytes(size_t size) { nassertv(_datagram != (const Datagram *)NULL); @@ -501,12 +441,10 @@ skip_bytes(size_t size) { _current_index += size; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_remaining_bytes -// Access: Public -// Description: Returns the remaining bytes in the datagram as a -// string, but does not extract them from the iterator. -//////////////////////////////////////////////////////////////////// +/** + * Returns the remaining bytes in the datagram as a string, but does not + * extract them from the iterator. + */ INLINE string DatagramIterator:: get_remaining_bytes() const { nassertr(_datagram != (const Datagram *)NULL, ""); @@ -517,32 +455,26 @@ get_remaining_bytes() const { return string(ptr + _current_index, remaining_size); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_remaining_size -// Access: Public -// Description: Return the bytes left in the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Return the bytes left in the datagram. + */ INLINE size_t DatagramIterator:: get_remaining_size() const { return _datagram->get_length() - _current_index; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_datagram -// Access: Public -// Description: Return the datagram of this iterator. -//////////////////////////////////////////////////////////////////// +/** + * Return the datagram of this iterator. + */ INLINE const Datagram &DatagramIterator:: get_datagram() const { return *_datagram; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_current_index -// Access: Public -// Description: Returns the current position within the datagram of the -// next piece of data to extract. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position within the datagram of the next piece of data + * to extract. + */ INLINE size_t DatagramIterator:: get_current_index() const { return _current_index; @@ -577,5 +509,3 @@ INLINE void generic_read_datagram(wstring &result, DatagramIterator &source) { result = source.get_wstring(); } - - diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index ed6910aae9..3dca573cad 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -1,27 +1,24 @@ -// Filename: datagramIterator.cxx -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramIterator.cxx + * @author jns + * @date 2000-02-07 + */ #include "datagramIterator.h" #include "pnotify.h" TypeHandle DatagramIterator::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_string -// Access: Public -// Description: Extracts a variable-length string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string. + */ string DatagramIterator:: get_string() { // First, get the length of the string @@ -38,12 +35,9 @@ get_string() { return string(ptr + last_index, s_len); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_string32 -// Access: Public -// Description: Extracts a variable-length string with a 32-bit -// length field. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string with a 32-bit length field. + */ string DatagramIterator:: get_string32() { // First, get the length of the string @@ -60,12 +54,9 @@ get_string32() { return string(ptr + last_index, s_len); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_z_string -// Access: Public -// Description: Extracts a variable-length string, as a -// NULL-terminated string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length string, as a NULL-terminated string. + */ string DatagramIterator:: get_z_string() { nassertr(_datagram != (const Datagram *)NULL, ""); @@ -85,13 +76,10 @@ get_z_string() { return string(ptr + last_index, p - last_index); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_fixed_string -// Access: Public -// Description: Extracts a fixed-length string. However, if a zero -// byte occurs within the string, it marks the end of -// the string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a fixed-length string. However, if a zero byte occurs within the + * string, it marks the end of the string. + */ string DatagramIterator:: get_fixed_string(size_t size) { nassertr(_datagram != (const Datagram *)NULL, ""); @@ -106,12 +94,9 @@ get_fixed_string(size_t size) { return s.substr(0, zero_byte); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::get_wstring -// Access: Public -// Description: Extracts a variable-length wstring (with a 32-bit -// length field). -//////////////////////////////////////////////////////////////////// +/** + * Extracts a variable-length wstring (with a 32-bit length field). + */ wstring DatagramIterator:: get_wstring() { // First, get the length of the string @@ -130,12 +115,10 @@ get_wstring() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::extract_bytes -// Access: Public -// Description: Extracts the indicated number of bytes in the -// datagram and returns them as a string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the datagram and returns them as + * a string. + */ string DatagramIterator:: extract_bytes(size_t size) { nassertr((int)size >= 0, ""); @@ -150,15 +133,12 @@ extract_bytes(size_t size) { return string(ptr + last_index, size); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramIterator::extract_bytes -// Access: Published -// Description: Extracts the indicated number of bytes in the -// datagram into the given character buffer. Assumes -// that the buffer is big enough to hold the requested -// number of bytes. Returns the number of bytes -// that were successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the datagram into the given + * character buffer. Assumes that the buffer is big enough to hold the + * requested number of bytes. Returns the number of bytes that were + * successfully written. + */ size_t DatagramIterator:: extract_bytes(unsigned char *into, size_t size) { nassertr((int)size >= 0, 0); @@ -172,12 +152,9 @@ extract_bytes(unsigned char *into, size_t size) { return size; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DatagramIterator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -185,12 +162,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DatagramIterator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -206,4 +180,3 @@ write(ostream &out, unsigned int indent) const { } #endif //] NDEBUG } - diff --git a/panda/src/express/datagramIterator.h b/panda/src/express/datagramIterator.h index cc6568eed9..a6d1dc0b6e 100644 --- a/panda/src/express/datagramIterator.h +++ b/panda/src/express/datagramIterator.h @@ -1,16 +1,15 @@ -// Filename: datagramIterator.h -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramIterator.h + * @author jns + * @date 2000-02-07 + */ #ifndef DATAGRAMITERATOR_H #define DATAGRAMITERATOR_H @@ -20,13 +19,11 @@ #include "datagram.h" #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : DatagramIterator -// Description : A class to retrieve the individual data elements -// previously stored in a Datagram. Elements may be -// retrieved one at a time; it is up to the caller to -// know the correct type and order of each element. -//////////////////////////////////////////////////////////////////// +/** + * A class to retrieve the individual data elements previously stored in a + * Datagram. Elements may be retrieved one at a time; it is up to the caller + * to know the correct type and order of each element. + */ class EXPCL_PANDAEXPRESS DatagramIterator { public: INLINE void assign(Datagram &datagram, size_t offset = 0); @@ -96,10 +93,10 @@ private: static TypeHandle _type_handle; }; -// These generic functions are primarily for reading a value from a -// datagram from within a template in which the actual type of the -// value is not known. If you do know the type, it's preferable to -// use the explicit get_*() method from above instead. +// These generic functions are primarily for reading a value from a datagram +// from within a template in which the actual type of the value is not known. +// If you do know the type, it's preferable to use the explicit get_*() method +// from above instead. INLINE void generic_read_datagram(bool &result, DatagramIterator &source); diff --git a/panda/src/express/datagramSink.I b/panda/src/express/datagramSink.I index ad2c2c00c4..d1380751fb 100644 --- a/panda/src/express/datagramSink.I +++ b/panda/src/express/datagramSink.I @@ -1,24 +1,19 @@ -// Filename: datagramSink.I -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSink.I + * @author jason + * @date 2000-06-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::Constructor -// Access: Public -// Description: Does nothing since this is class is just -// the definition of an interface -//////////////////////////////////////////////////////////////////// +/** + * Does nothing since this is class is just the definition of an interface + */ INLINE DatagramSink::DatagramSink(){ } diff --git a/panda/src/express/datagramSink.cxx b/panda/src/express/datagramSink.cxx index fa1fe33a2b..0941ce10fb 100644 --- a/panda/src/express/datagramSink.cxx +++ b/panda/src/express/datagramSink.cxx @@ -1,72 +1,58 @@ -// Filename: datagramSink.cxx -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSink.cxx + * @author jason + * @date 2000-06-07 + */ #include "datagramSink.h" #include "fileReference.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::Destructor -// Access: Public, Virtual -// Description: Does nothing since this is class is just -// the definition of an interface -//////////////////////////////////////////////////////////////////// +/** + * Does nothing since this is class is just the definition of an interface + */ DatagramSink:: ~DatagramSink() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::copy_datagram -// Access: Published, Virtual -// Description: Copies the file data from the entire indicated -// file (via the vfs) as the next datagram. This is -// intended to support potentially very large datagrams. -// -// Returns true on success, false on failure or if this -// method is unimplemented. On true, fills "result" -// with the information that references the copied file, -// if possible. -//////////////////////////////////////////////////////////////////// +/** + * Copies the file data from the entire indicated file (via the vfs) as the + * next datagram. This is intended to support potentially very large + * datagrams. + * + * Returns true on success, false on failure or if this method is + * unimplemented. On true, fills "result" with the information that + * references the copied file, if possible. + */ bool DatagramSink:: copy_datagram(SubfileInfo &result, const Filename &filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::copy_datagram -// Access: Published, Virtual -// Description: Copies the file data from the range of the indicated -// file (outside of the vfs) as the next datagram. This -// is intended to support potentially very large -// datagrams. -// -// Returns true on success, false on failure or if this -// method is unimplemented. On true, fills "result" -// with the information that references the copied file, -// if possible. -//////////////////////////////////////////////////////////////////// +/** + * Copies the file data from the range of the indicated file (outside of the + * vfs) as the next datagram. This is intended to support potentially very + * large datagrams. + * + * Returns true on success, false on failure or if this method is + * unimplemented. On true, fills "result" with the information that + * references the copied file, if possible. + */ bool DatagramSink:: copy_datagram(SubfileInfo &result, const SubfileInfo &source) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::get_filename -// Access: Published, Virtual -// Description: Returns the filename that provides the target for -// these datagrams, if any, or empty string if the -// datagrams do not get written to a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that provides the target for these datagrams, if any, + * or empty string if the datagrams do not get written to a file on disk. + */ const Filename &DatagramSink:: get_filename() { const FileReference *file = get_file(); @@ -77,30 +63,23 @@ get_filename() { return empty_filename; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::get_file -// Access: Published, Virtual -// Description: Returns the FileReference that provides the target for -// these datagrams, if any, or NULL if the datagrams do -// not written to a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that provides the target for these datagrams, if + * any, or NULL if the datagrams do not written to a file on disk. + */ const FileReference *DatagramSink:: get_file() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSink::get_file_pos -// Access: Published, Virtual -// Description: Returns the current file position within the data -// stream, if any, or 0 if the file position is not -// meaningful or cannot be determined. -// -// For DatagramSinks that return a meaningful file -// position, this will be pointing to the first byte -// following the datagram returned after a call to -// put_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file position within the data stream, if any, or 0 if + * the file position is not meaningful or cannot be determined. + * + * For DatagramSinks that return a meaningful file position, this will be + * pointing to the first byte following the datagram returned after a call to + * put_datagram(). + */ streampos DatagramSink:: get_file_pos() { return 0; diff --git a/panda/src/express/datagramSink.h b/panda/src/express/datagramSink.h index d5d7182865..0c1b74449c 100644 --- a/panda/src/express/datagramSink.h +++ b/panda/src/express/datagramSink.h @@ -1,16 +1,15 @@ -// Filename: datagramSink.h -// Created by: jason (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSink.h + * @author jason + * @date 2000-06-07 + */ #ifndef DATAGRAMSINK_H #define DATAGRAMSINK_H @@ -23,12 +22,10 @@ class SubfileInfo; class FileReference; class Filename; -//////////////////////////////////////////////////////////////////// -// Class : DatagramSink -// Description : This class defines the abstract interface to sending -// datagrams to any target, whether it be into a file -// or across the net -//////////////////////////////////////////////////////////////////// +/** + * This class defines the abstract interface to sending datagrams to any + * target, whether it be into a file or across the net + */ class EXPCL_PANDAEXPRESS DatagramSink { PUBLISHED: INLINE DatagramSink(); @@ -48,4 +45,3 @@ PUBLISHED: #include "datagramSink.I" #endif - diff --git a/panda/src/express/dcast.cxx b/panda/src/express/dcast.cxx index 34517ff28c..fcb0e02baf 100644 --- a/panda/src/express/dcast.cxx +++ b/panda/src/express/dcast.cxx @@ -1,16 +1,15 @@ -// Filename: dcast.cxx -// Created by: drose (07Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcast.cxx + * @author drose + * @date 2001-08-07 + */ #include "dcast.h" #include "config_express.h" @@ -23,25 +22,23 @@ #endif #ifdef DO_DCAST -//////////////////////////////////////////////////////////////////// -// Function: _dcast_verify -// Description: This function performs the actual check that the -// indicated TypedObject pointer is of the intended -// type. -//////////////////////////////////////////////////////////////////// +/** + * This function performs the actual check that the indicated TypedObject + * pointer is of the intended type. + */ bool -_dcast_verify(TypeHandle want_handle, size_t want_size, +_dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr) { if (get_verify_dcast()) { if (ptr == (const TypedObject *)NULL) { - // This is allowed these days. It used to be an error, but - // what the heck. + // This is allowed these days. It used to be an error, but what the + // heck. return true; } #if defined(_DEBUG) && defined(_WIN32) if (IsBadWritePtr((TypedObject *)ptr, want_size)) { express_cat->warning() - << "Attempt to cast invalid pointer to " + << "Attempt to cast invalid pointer to " << want_handle << "\n"; return false; } @@ -61,5 +58,3 @@ _dcast_verify(TypeHandle want_handle, size_t want_size, return true; } #endif // DO_DCAST - - diff --git a/panda/src/express/dcast.h b/panda/src/express/dcast.h index ba91a5d68e..4ab30bae3d 100644 --- a/panda/src/express/dcast.h +++ b/panda/src/express/dcast.h @@ -1,16 +1,15 @@ -// Filename: dcast.h -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dcast.h + * @author drose + * @date 2001-08-06 + */ #ifndef DCAST_H #define DCAST_H @@ -21,45 +20,43 @@ #include "typedObject.h" #include "config_express.h" -// The DCAST (downcast) macro is defined as a convenience for -// downcasting from some TypedObject pointer (or a PointerTo). It's -// just a normal C++-style downcast, except it first checks get_type() -// to make sure the downcasting is safe. If you compile with NDEBUG, -// or set verify-dcast to #f, this check is removed. +// The DCAST (downcast) macro is defined as a convenience for downcasting from +// some TypedObject pointer (or a PointerTo). It's just a normal C++-style +// downcast, except it first checks get_type() to make sure the downcasting is +// safe. If you compile with NDEBUG, or set verify-dcast to #f, this check is +// removed. -// DCAST will return NULL if the downcasting is unsafe. If you'd -// rather it abort out of the function (a la nassertv/nassertr), then -// see DCAST_INTO_V and DCAST_INTO_R, below. +// DCAST will return NULL if the downcasting is unsafe. If you'd rather it +// abort out of the function (a la nassertvnassertr), then see DCAST_INTO_V +// and DCAST_INTO_R, below. template INLINE WantType *_dcast(WantType *, TypedObject *ptr); template INLINE const WantType *_dcast(WantType *, const TypedObject *ptr); -// Note: it is important that DCAST not repeat the pointer parameter, -// since many users of DCAST may want to use the result of a function -// as the pointer parameter, and it could be terribly confusing and -// difficult to trace if the function were inadvertently executed -// twice. This happened! +// Note: it is important that DCAST not repeat the pointer parameter, since +// many users of DCAST may want to use the result of a function as the pointer +// parameter, and it could be terribly confusing and difficult to trace if the +// function were inadvertently executed twice. This happened! #define DCAST(want_type, pointer) _dcast((want_type*)0, pointer) -// DCAST_INTO_V and DCAST_INTO_R are similar in purpose to DCAST, -// except they: (a) automatically assign a variable instead of -// returning the downcasted pointer, and (b) they immediately return -// out of the function if the downcasting fails. DCAST_INTO_V is for -// use in a void function and returns nothing; DCAST_INTO_R is for use -// in a non-void function and returns the indicated value. +// DCAST_INTO_V and DCAST_INTO_R are similar in purpose to DCAST, except they: +// (a) automatically assign a variable instead of returning the downcasted +// pointer, and (b) they immediately return out of the function if the +// downcasting fails. DCAST_INTO_V is for use in a void function and returns +// nothing; DCAST_INTO_R is for use in a non-void function and returns the +// indicated value. -// Both DCAST_INTO_V and DCAST_INTO_R accept as the first parameter a -// variable of type (want_type *) or (const want_type *), instead of -// the name of the type. This variable will be filled with the new -// pointer. +// Both DCAST_INTO_V and DCAST_INTO_R accept as the first parameter a variable +// of type (want_type *) or (const want_type *), instead of the name of the +// type. This variable will be filled with the new pointer. // _dcast_ref is used to implement DCAST_INTO_V and DCAST_INTO_R. Its -// difference from _dcast is that it takes a reference to a pointer as -// a first parameter. The main point of this is to shut up the -// compiler about pointers used before their value is assigned. +// difference from _dcast is that it takes a reference to a pointer as a first +// parameter. The main point of this is to shut up the compiler about +// pointers used before their value is assigned. template INLINE WantType *_dcast_ref(WantType *&, TypedObject *ptr); template @@ -68,7 +65,7 @@ INLINE const WantType *_dcast_ref(WantType *&, const TypedObject *ptr); #ifdef DO_DCAST // _dcast_verify performs the actual verification. EXPCL_PANDAEXPRESS bool -_dcast_verify(TypeHandle want_handle, size_t want_size, +_dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr); #endif // DO_DCAST diff --git a/panda/src/express/encrypt_string.cxx b/panda/src/express/encrypt_string.cxx index 10fdd33524..0736e30be6 100644 --- a/panda/src/express/encrypt_string.cxx +++ b/panda/src/express/encrypt_string.cxx @@ -1,16 +1,15 @@ -// Filename: encrypt_string.cxx -// Created by: drose (30Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encrypt_string.cxx + * @author drose + * @date 2007-01-30 + */ #include "encrypt_string.h" @@ -19,13 +18,10 @@ #include "virtualFileSystem.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Function: encrypt_string -// Access: Published -// Description: Encrypts the indicated source string using the given -// password, and the algorithm specified by -// encryption-algorithm. Returns the encrypted string. -//////////////////////////////////////////////////////////////////// +/** + * Encrypts the indicated source string using the given password, and the + * algorithm specified by encryption-algorithm. Returns the encrypted string. + */ string encrypt_string(const string &source, const string &password, const string &algorithm, int key_length, int iteration_count) { @@ -53,18 +49,14 @@ encrypt_string(const string &source, const string &password, return dest.str(); } -//////////////////////////////////////////////////////////////////// -// Function: decrypt_string -// Access: Published -// Description: Decrypts the previously-encrypted string using the -// given password (which must be the same password -// passed to encrypt()). The return value is the -// decrypted string. -// -// Note that a decryption error, including an incorrect -// password, cannot easily be detected, and the return -// value may simply be a garbage string. -//////////////////////////////////////////////////////////////////// +/** + * Decrypts the previously-encrypted string using the given password (which + * must be the same password passed to encrypt()). The return value is the + * decrypted string. + * + * Note that a decryption error, including an incorrect password, cannot + * easily be detected, and the return value may simply be a garbage string. + */ string decrypt_string(const string &source, const string &password) { istringstream source_stream(source); @@ -77,16 +69,13 @@ decrypt_string(const string &source, const string &password) { return dest_stream.str(); } -//////////////////////////////////////////////////////////////////// -// Function: encrypt_file -// Access: Published -// Description: Encrypts the data from the source file using the -// given password. The source file is read in its -// entirety, and the encrypted results are written to -// the dest file, overwriting its contents. The return -// value is bool on success, or false on failure. -//////////////////////////////////////////////////////////////////// -EXPCL_PANDAEXPRESS bool +/** + * Encrypts the data from the source file using the given password. The + * source file is read in its entirety, and the encrypted results are written + * to the dest file, overwriting its contents. The return value is bool on + * success, or false on failure. + */ +EXPCL_PANDAEXPRESS bool encrypt_file(const Filename &source, const Filename &dest, const string &password, const string &algorithm, int key_length, int iteration_count) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -100,7 +89,7 @@ encrypt_file(const Filename &source, const Filename &dest, const string &passwor express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } - + Filename dest_filename = Filename::binary_filename(dest); ostream *dest_stream = vfs->open_write_file(dest_filename, true, true); if (dest_stream == NULL) { @@ -108,7 +97,7 @@ encrypt_file(const Filename &source, const Filename &dest, const string &passwor vfs->close_read_file(source_stream); return false; } - + bool result = encrypt_stream(*source_stream, *dest_stream, password, algorithm, key_length, iteration_count); vfs->close_read_file(source_stream); @@ -116,21 +105,17 @@ encrypt_file(const Filename &source, const Filename &dest, const string &passwor return result; } -//////////////////////////////////////////////////////////////////// -// Function: decrypt_file -// Access: Published -// Description: Decrypts the data from the source file using the -// given password (which must match the same password -// passed to encrypt()). The source file is read in its -// entirety, and the decrypted results are written to -// the dest file, overwriting its contents. The return -// value is bool on success, or false on failure. -// -// Note that a decryption error, including an incorrect -// password, cannot easily be detected, and the output -// may simply be a garbage string. -//////////////////////////////////////////////////////////////////// -EXPCL_PANDAEXPRESS bool +/** + * Decrypts the data from the source file using the given password (which must + * match the same password passed to encrypt()). The source file is read in + * its entirety, and the decrypted results are written to the dest file, + * overwriting its contents. The return value is bool on success, or false on + * failure. + * + * Note that a decryption error, including an incorrect password, cannot + * easily be detected, and the output may simply be a garbage string. + */ +EXPCL_PANDAEXPRESS bool decrypt_file(const Filename &source, const Filename &dest, const string &password) { Filename source_filename = Filename::binary_filename(source); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -139,7 +124,7 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor express_cat.info() << "Couldn't open file " << source_filename << "\n"; return false; } - + Filename dest_filename = dest; if (!dest_filename.is_binary_or_text()) { // The default is binary, if not specified otherwise. @@ -151,23 +136,19 @@ decrypt_file(const Filename &source, const Filename &dest, const string &passwor vfs->close_read_file(source_stream); return false; } - + bool result = decrypt_stream(*source_stream, *dest_stream, password); vfs->close_read_file(source_stream); vfs->close_write_file(dest_stream); return result; } -//////////////////////////////////////////////////////////////////// -// Function: encrypt_stream -// Access: Published -// Description: Encrypts the data from the source stream using the -// given password. The source stream is read from its -// current position to the end-of-file, and the -// encrypted results are written to the dest stream. -// The return value is bool on success, or false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Encrypts the data from the source stream using the given password. The + * source stream is read from its current position to the end-of-file, and the + * encrypted results are written to the dest stream. The return value is bool + * on success, or false on failure. + */ bool encrypt_stream(istream &source, ostream &dest, const string &password, const string &algorithm, int key_length, int iteration_count) { @@ -182,7 +163,7 @@ encrypt_stream(istream &source, ostream &dest, const string &password, encrypt.set_iteration_count(iteration_count); } encrypt.open(&dest, false, password); - + static const size_t buffer_size = 4096; char buffer[buffer_size]; @@ -198,21 +179,16 @@ encrypt_stream(istream &source, ostream &dest, const string &password, return (!source.fail() || source.eof()) && (!encrypt.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: decrypt_stream -// Access: Published -// Description: Decrypts the data from the previously-encrypted -// source stream using the given password (which must be -// the same password passed to encrypt()). The source -// stream is read from its current position to the -// end-of-file, and the decrypted results are written to -// the dest stream. The return value is bool on -// success, or false on failure. -// -// Note that a decryption error, including an incorrect -// password, cannot easily be detected, and the output -// may simply be a garbage string. -//////////////////////////////////////////////////////////////////// +/** + * Decrypts the data from the previously-encrypted source stream using the + * given password (which must be the same password passed to encrypt()). The + * source stream is read from its current position to the end-of-file, and the + * decrypted results are written to the dest stream. The return value is bool + * on success, or false on failure. + * + * Note that a decryption error, including an incorrect password, cannot + * easily be detected, and the output may simply be a garbage string. + */ bool decrypt_stream(istream &source, ostream &dest, const string &password) { IDecryptStream decrypt(&source, false, password); @@ -227,7 +203,7 @@ decrypt_stream(istream &source, ostream &dest, const string &password) { decrypt.read(buffer, buffer_size); count = decrypt.gcount(); } - + return (!decrypt.fail() || decrypt.eof()) && (!dest.fail()); } diff --git a/panda/src/express/encrypt_string.h b/panda/src/express/encrypt_string.h index 4e881394bb..4e0d12bafb 100644 --- a/panda/src/express/encrypt_string.h +++ b/panda/src/express/encrypt_string.h @@ -1,16 +1,15 @@ -// Filename: encrypt_string.h -// Created by: drose (30Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file encrypt_string.h + * @author drose + * @date 2007-01-30 + */ #ifndef ENCRYPT_STRING_H #define ENCRYPT_STRING_H @@ -25,21 +24,21 @@ BEGIN_PUBLISH EXPCL_PANDAEXPRESS string encrypt_string(const string &source, const string &password, - const string &algorithm = string(), int key_length = -1, + const string &algorithm = string(), int key_length = -1, int iteration_count = -1); EXPCL_PANDAEXPRESS string decrypt_string(const string &source, const string &password); EXPCL_PANDAEXPRESS bool encrypt_file(const Filename &source, const Filename &dest, const string &password, - const string &algorithm = string(), int key_length = -1, + const string &algorithm = string(), int key_length = -1, int iteration_count = -1); EXPCL_PANDAEXPRESS bool decrypt_file(const Filename &source, const Filename &dest, const string &password); EXPCL_PANDAEXPRESS bool encrypt_stream(istream &source, ostream &dest, const string &password, - const string &algorithm = string(), int key_length = -1, + const string &algorithm = string(), int key_length = -1, int iteration_count = -1); EXPCL_PANDAEXPRESS bool decrypt_stream(istream &source, ostream &dest, const string &password); diff --git a/panda/src/express/error_utils.cxx b/panda/src/express/error_utils.cxx index e5c7a40890..bae1da4a31 100644 --- a/panda/src/express/error_utils.cxx +++ b/panda/src/express/error_utils.cxx @@ -1,17 +1,15 @@ -// Filename: error_utils.cxx -// Created by: mike (07Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file error_utils.cxx + * @author mike + * @date 2000-11-07 + */ #include "error_utils.h" #include "config_express.h" @@ -23,10 +21,9 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: error_to_text -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string error_to_text(ErrorUtilCode err) { const char *errmsg = "Unknown error"; @@ -149,10 +146,9 @@ string error_to_text(ErrorUtilCode err) { return string(msgbuf); } -//////////////////////////////////////////////////////////////////// -// Function: get_write_error -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int get_write_error() { #if !defined(WIN32) && !defined(WIN64) @@ -187,10 +183,9 @@ get_write_error() { } #ifdef HAVE_NET -//////////////////////////////////////////////////////////////////// -// Function: handle_socket_error -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string handle_socket_error() { #if !defined(WIN32) && !defined(WIN64) return string(strerror(errno)); @@ -246,10 +241,9 @@ string handle_socket_error() { #endif #ifdef HAVE_NET -//////////////////////////////////////////////////////////////////// -// Function: get_network_error -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int get_network_error() { #if !defined(WIN32) && !defined(WIN64) diff --git a/panda/src/express/error_utils.h b/panda/src/express/error_utils.h index a5ff5dedd7..10ed4d4bd8 100644 --- a/panda/src/express/error_utils.h +++ b/panda/src/express/error_utils.h @@ -1,16 +1,15 @@ -// Filename: error_utils.h -// Created by: mike (07Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file error_utils.h + * @author mike + * @date 2000-11-07 + */ #ifndef ERROR_UTILS_H #define ERROR_UTILS_H @@ -86,4 +85,3 @@ EXPCL_PANDAEXPRESS int get_network_error(); END_PUBLISH #endif - diff --git a/panda/src/express/export_dtool.h b/panda/src/express/export_dtool.h index bee0dfff92..dd8a064339 100644 --- a/panda/src/express/export_dtool.h +++ b/panda/src/express/export_dtool.h @@ -1,24 +1,23 @@ -// Filename: export_dtool.h -// Created by: drose (15Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file export_dtool.h + * @author drose + * @date 2008-10-15 + */ #ifndef EXPORT_DTOOL_H #define EXPORT_DTOOL_H -// This header file exists to import the symbols necessary to publish -// all of the classes defined in the dtool source tree. (These must -// be published here, instead of within dtool itself, since -// interrogate is not run on dtool.) +// This header file exists to import the symbols necessary to publish all of +// the classes defined in the dtool source tree. (These must be published +// here, instead of within dtool itself, since interrogate is not run on +// dtool.) #include "pandabase.h" diff --git a/panda/src/express/fileReference.I b/panda/src/express/fileReference.I index 1e2bb1af08..01cc4f09a8 100644 --- a/panda/src/express/fileReference.I +++ b/panda/src/express/fileReference.I @@ -1,32 +1,26 @@ -// Filename: fileReference.I -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileReference.I + * @author drose + * @date 2011-06-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FileReference::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FileReference:: FileReference(const Filename &filename) : _filename(filename) { } - -//////////////////////////////////////////////////////////////////// -// Function: FileReference::get_filename -// Access: Published -// Description: Returns the filename of the reference. -//////////////////////////////////////////////////////////////////// + +/** + * Returns the filename of the reference. + */ INLINE const Filename &FileReference:: get_filename() const { return _filename; diff --git a/panda/src/express/fileReference.cxx b/panda/src/express/fileReference.cxx index 5bc0ed75f9..c68a0aa734 100644 --- a/panda/src/express/fileReference.cxx +++ b/panda/src/express/fileReference.cxx @@ -1,16 +1,15 @@ -// Filename: fileReference.cxx -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileReference.cxx + * @author drose + * @date 2011-06-23 + */ #include "fileReference.h" diff --git a/panda/src/express/fileReference.h b/panda/src/express/fileReference.h index 6243da7a52..b870121016 100644 --- a/panda/src/express/fileReference.h +++ b/panda/src/express/fileReference.h @@ -1,16 +1,15 @@ -// Filename: fileReference.h -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fileReference.h + * @author drose + * @date 2011-06-23 + */ #ifndef FILEREFERENCE_H #define FILEREFERENCE_H @@ -20,12 +19,10 @@ #include "typedReferenceCount.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : FileReference -// Description : Keeps a reference-counted pointer to a file on disk. -// As long as the FileReference is held, someone -// presumably has a use for this file. -//////////////////////////////////////////////////////////////////// +/** + * Keeps a reference-counted pointer to a file on disk. As long as the + * FileReference is held, someone presumably has a use for this file. + */ class EXPCL_PANDAEXPRESS FileReference : public TypedReferenceCount { PUBLISHED: INLINE FileReference(const Filename &filename); diff --git a/panda/src/express/filename_ext.cxx b/panda/src/express/filename_ext.cxx index 70d5bfba2c..70afd0d07d 100644 --- a/panda/src/express/filename_ext.cxx +++ b/panda/src/express/filename_ext.cxx @@ -1,32 +1,28 @@ -// Filename: filename_ext.cxx -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename_ext.cxx + * @author rdb + * @date 2014-09-17 + */ #include "filename_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyTypeObject *this_class = Py_TYPE(self); if (this_class == NULL) { return NULL; @@ -36,12 +32,10 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::__repr__ -// Access: Published -// Description: Returns a string representation of the filename that -// communicates both its type and value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representation of the filename that communicates both its + * type and value. + */ PyObject *Extension:: __repr__() const { #if PY_MAJOR_VERSION >= 3 @@ -68,12 +62,10 @@ __repr__() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::scan_directory -// Access: Published -// Description: This variant on scan_directory returns a Python list -// of strings on success, or None on failure. -//////////////////////////////////////////////////////////////////// +/** + * This variant on scan_directory returns a Python list of strings on success, + * or None on failure. + */ PyObject *Extension:: scan_directory() const { vector_string contents; @@ -97,5 +89,3 @@ scan_directory() const { return result; } #endif // HAVE_PYTHON - - diff --git a/panda/src/express/filename_ext.h b/panda/src/express/filename_ext.h index 866f8f41a4..c1d5869ec7 100644 --- a/panda/src/express/filename_ext.h +++ b/panda/src/express/filename_ext.h @@ -1,16 +1,15 @@ -// Filename: filename_ext.h -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filename_ext.h + * @author rdb + * @date 2014-09-17 + */ #ifndef FILENAME_EXT_H #define FILENAME_EXT_H @@ -23,12 +22,10 @@ #include "filename.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// Filename, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for Filename, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/globPattern_ext.cxx b/panda/src/express/globPattern_ext.cxx index 41c4773bd1..e6328bc5c0 100644 --- a/panda/src/express/globPattern_ext.cxx +++ b/panda/src/express/globPattern_ext.cxx @@ -1,27 +1,23 @@ -// Filename: globPattern_ext.cxx -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globPattern_ext.cxx + * @author rdb + * @date 2014-09-17 + */ #include "globPattern_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::match_files -// Access: Published -// Description: This variant on match_files returns a Python list -// of strings. -//////////////////////////////////////////////////////////////////// +/** + * This variant on match_files returns a Python list of strings. + */ PyObject *Extension:: match_files(const Filename &cwd) const { vector_string contents; diff --git a/panda/src/express/globPattern_ext.h b/panda/src/express/globPattern_ext.h index fe9d7ca6ed..c087ca16ce 100644 --- a/panda/src/express/globPattern_ext.h +++ b/panda/src/express/globPattern_ext.h @@ -1,16 +1,15 @@ -// Filename: globPattern_ext.h -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globPattern_ext.h + * @author rdb + * @date 2014-09-17 + */ #ifndef GLOBPATTERN_EXT_H #define GLOBPATTERN_EXT_H @@ -23,12 +22,10 @@ #include "globPattern.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// GlobPattern, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for GlobPattern, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/hashGeneratorBase.I b/panda/src/express/hashGeneratorBase.I index 6172d0374e..f6a65c756b 100644 --- a/panda/src/express/hashGeneratorBase.I +++ b/panda/src/express/hashGeneratorBase.I @@ -1,42 +1,34 @@ -// Filename: hashGeneratorBase.I -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashGeneratorBase.I + * @author drose + * @date 2001-05-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HashGeneratorBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HashGeneratorBase:: HashGeneratorBase() { _hash = 0; } -//////////////////////////////////////////////////////////////////// -// Function: HashGeneratorBase::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HashGeneratorBase:: ~HashGeneratorBase() { } -//////////////////////////////////////////////////////////////////// -// Function: HashGeneratorBase::get_hash -// Access: Public -// Description: Returns the hash number generated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the hash number generated. + */ INLINE size_t HashGeneratorBase:: get_hash() const { return _hash; diff --git a/panda/src/express/hashGeneratorBase.cxx b/panda/src/express/hashGeneratorBase.cxx index 78fa9b1bbe..11a7781b27 100644 --- a/panda/src/express/hashGeneratorBase.cxx +++ b/panda/src/express/hashGeneratorBase.cxx @@ -1,16 +1,14 @@ -// Filename: hashGeneratorBase.cxx -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashGeneratorBase.cxx + * @author drose + * @date 2001-05-14 + */ #include "hashGeneratorBase.h" - diff --git a/panda/src/express/hashGeneratorBase.h b/panda/src/express/hashGeneratorBase.h index 53e908ec35..97ddb7fe08 100644 --- a/panda/src/express/hashGeneratorBase.h +++ b/panda/src/express/hashGeneratorBase.h @@ -1,37 +1,32 @@ -// Filename: hashGeneratorBase.h -// Created by: drose (14May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashGeneratorBase.h + * @author drose + * @date 2001-05-14 + */ #ifndef HASHGENERATORBASE_H #define HASHGENERATORBASE_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : HashGeneratorBase -// Description : This is the base class for a number of classes that -// generate arbitrary hash numbers for complex objects, -// based fundamentally on a sequence of integers. -// -// There are no virtual functions here, for performance -// reasons; it is generally desirable to generate hash -// numbers as quickly as possible. The derived classes -// must redefine all the basic functionality. -// -// Thus, a compile-time decision must be made for the -// kind of HashGenerator that is appropriate for a -// particular class. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a number of classes that generate arbitrary hash + * numbers for complex objects, based fundamentally on a sequence of integers. + * + * There are no virtual functions here, for performance reasons; it is + * generally desirable to generate hash numbers as quickly as possible. The + * derived classes must redefine all the basic functionality. + * + * Thus, a compile-time decision must be made for the kind of HashGenerator + * that is appropriate for a particular class. + */ class EXPCL_PANDAEXPRESS HashGeneratorBase { public: INLINE HashGeneratorBase(); diff --git a/panda/src/express/hashVal.I b/panda/src/express/hashVal.I index 7727613f91..d866e56475 100644 --- a/panda/src/express/hashVal.I +++ b/panda/src/express/hashVal.I @@ -1,33 +1,27 @@ -// Filename: hashVal.I -// Created by: drose (14Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashVal.I + * @author drose + * @date 2000-11-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HashVal::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HashVal:: HashVal() { _hv[0] = _hv[1] = _hv[2] = _hv[3] = 0; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HashVal:: HashVal(const HashVal ©) { _hv[0] = copy._hv[0]; @@ -36,11 +30,9 @@ HashVal(const HashVal ©) { _hv[3] = copy._hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: operator = (const HashVal ©) { _hv[0] = copy._hv[0]; @@ -49,11 +41,9 @@ operator = (const HashVal ©) { _hv[3] = copy._hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HashVal:: operator == (const HashVal &other) const { return (_hv[0] == other._hv[0] && @@ -62,31 +52,25 @@ operator == (const HashVal &other) const { _hv[3] == other._hv[3]); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HashVal:: operator != (const HashVal &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool HashVal:: operator < (const HashVal &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::compare_to -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int HashVal:: compare_to(const HashVal &other) const { if (_hv[0] != other._hv[0]) { @@ -101,12 +85,9 @@ compare_to(const HashVal &other) const { return (int)_hv[3] - (int)other._hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::merge_with -// Access: Published -// Description: Generates a new HashVal representing the xor of this -// one and the other one. -//////////////////////////////////////////////////////////////////// +/** + * Generates a new HashVal representing the xor of this one and the other one. + */ INLINE void HashVal:: merge_with(const HashVal &other) { _hv[0] ^= other._hv[0]; @@ -115,42 +96,33 @@ merge_with(const HashVal &other) { _hv[3] ^= other._hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::output_dec -// Access: Published -// Description: Outputs the HashVal as four unsigned decimal -// integers. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the HashVal as four unsigned decimal integers. + */ INLINE void HashVal:: output_dec(ostream &out) const { out << _hv[0] << " " << _hv[1] << " " << _hv[2] << " " << _hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::input -// Access: Published -// Description: Inputs the HashVal as four unsigned decimal integers. -//////////////////////////////////////////////////////////////////// +/** + * Inputs the HashVal as four unsigned decimal integers. + */ INLINE void HashVal:: input_dec(istream &in) { in >> _hv[0] >> _hv[1] >> _hv[2] >> _hv[3]; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: output(ostream &out) const { output_hex(out); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::write_datagram -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: write_datagram(Datagram &destination) const { destination.add_uint32(_hv[0]); @@ -159,11 +131,9 @@ write_datagram(Datagram &destination) const { destination.add_uint32(_hv[3]); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::read_datagram -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: read_datagram(DatagramIterator &source) { _hv[0] = source.get_uint32(); @@ -172,11 +142,9 @@ read_datagram(DatagramIterator &source) { _hv[3] = source.get_uint32(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::write_stream -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: write_stream(StreamWriter &destination) const { destination.add_uint32(_hv[0]); @@ -185,11 +153,9 @@ write_stream(StreamWriter &destination) const { destination.add_uint32(_hv[3]); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::read_stream -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void HashVal:: read_stream(StreamReader &source) { _hv[0] = source.get_uint32(); @@ -199,38 +165,30 @@ read_stream(StreamReader &source) { } #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::hash_ramfile -// Access: Published -// Description: Generates the hash value by hashing the indicated -// data. This method is only defined if we have the -// OpenSSL library (which provides md5 functionality) -// available. -//////////////////////////////////////////////////////////////////// +/** + * Generates the hash value by hashing the indicated data. This method is + * only defined if we have the OpenSSL library (which provides md5 + * functionality) available. + */ INLINE void HashVal:: hash_ramfile(const Ramfile &ramfile) { hash_buffer(ramfile._data.data(), ramfile._data.length()); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::hash_string -// Access: Published -// Description: Generates the hash value by hashing the indicated -// data. This method is only defined if we have the -// OpenSSL library (which provides md5 functionality) -// available. -//////////////////////////////////////////////////////////////////// +/** + * Generates the hash value by hashing the indicated data. This method is + * only defined if we have the OpenSSL library (which provides md5 + * functionality) available. + */ INLINE void HashVal:: hash_string(const string &data) { hash_buffer(data.data(), data.length()); } #endif // HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::tohex -// Access: Private, Static -// Description: Converts a single nibble to a hex digit. -//////////////////////////////////////////////////////////////////// +/** + * Converts a single nibble to a hex digit. + */ INLINE char HashVal:: tohex(unsigned int nibble) { nibble &= 0xf; @@ -240,11 +198,9 @@ tohex(unsigned int nibble) { return nibble - 10 + 'a'; } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::fromhex -// Access: Private, Static -// Description: Converts a single hex digit to a numerical value. -//////////////////////////////////////////////////////////////////// +/** + * Converts a single hex digit to a numerical value. + */ INLINE unsigned int HashVal:: fromhex(char digit) { if (isdigit(digit)) { diff --git a/panda/src/express/hashVal.cxx b/panda/src/express/hashVal.cxx index a1f886ad32..34a2a3c116 100644 --- a/panda/src/express/hashVal.cxx +++ b/panda/src/express/hashVal.cxx @@ -1,16 +1,15 @@ -// Filename: hashVal.cxx -// Created by: drose (14Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashVal.cxx + * @author drose + * @date 2000-11-14 + */ #include "hashVal.h" #include "virtualFileSystem.h" @@ -22,11 +21,9 @@ #endif // HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::output_hex -// Access: Published -// Description: Outputs the HashVal as a 32-digit hexadecimal number. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the HashVal as a 32-digit hexadecimal number. + */ void HashVal:: output_hex(ostream &out) const { char buffer[32]; @@ -37,11 +34,9 @@ output_hex(ostream &out) const { out.write(buffer, 32); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::input_hex -// Access: Published -// Description: Inputs the HashVal as a 32-digit hexadecimal number. -//////////////////////////////////////////////////////////////////// +/** + * Inputs the HashVal as a 32-digit hexadecimal number. + */ void HashVal:: input_hex(istream &in) { in >> ws; @@ -74,13 +69,10 @@ input_hex(istream &in) { decode_hex(buffer + 24, _hv[3]); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::output_binary -// Access: Published -// Description: Outputs the HashVal as a binary stream of bytes in -// order. This is not the same order generated by -// write_stream(). -//////////////////////////////////////////////////////////////////// +/** + * Outputs the HashVal as a binary stream of bytes in order. This is not the + * same order generated by write_stream(). + */ void HashVal:: output_binary(ostream &out) const { StreamWriter writer(out); @@ -90,13 +82,10 @@ output_binary(ostream &out) const { writer.add_be_uint32(_hv[3]); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::input_binary -// Access: Published -// Description: Inputs the HashVal as a binary stream of bytes in -// order. This is not the same order expected by -// read_stream(). -//////////////////////////////////////////////////////////////////// +/** + * Inputs the HashVal as a binary stream of bytes in order. This is not the + * same order expected by read_stream(). + */ void HashVal:: input_binary(istream &in) { StreamReader reader(in); @@ -106,12 +95,9 @@ input_binary(istream &in) { _hv[3] = reader.get_be_uint32(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::as_dec -// Access: Published -// Description: Returns the HashVal as a string with four decimal -// numbers. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HashVal as a string with four decimal numbers. + */ string HashVal:: as_dec() const { ostringstream strm; @@ -119,12 +105,10 @@ as_dec() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::set_from_dec -// Access: Published -// Description: Sets the HashVal from a string with four decimal -// numbers. Returns true if valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the HashVal from a string with four decimal numbers. Returns true if + * valid, false otherwise. + */ bool HashVal:: set_from_dec(const string &text) { istringstream strm(text); @@ -132,11 +116,9 @@ set_from_dec(const string &text) { return !strm.fail(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::as_hex -// Access: Published -// Description: Returns the HashVal as a 32-byte hexadecimal string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HashVal as a 32-byte hexadecimal string. + */ string HashVal:: as_hex() const { char buffer[32]; @@ -147,12 +129,10 @@ as_hex() const { return string(buffer, 32); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::set_from_hex -// Access: Published -// Description: Sets the HashVal from a 32-byte hexademical string. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the HashVal from a 32-byte hexademical string. Returns true if + * successful, false otherwise. + */ bool HashVal:: set_from_hex(const string &text) { istringstream strm(text); @@ -160,11 +140,9 @@ set_from_hex(const string &text) { return !strm.fail(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::as_bin -// Access: Published -// Description: Returns the HashVal as a 16-byte binary string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the HashVal as a 16-byte binary string. + */ string HashVal:: as_bin() const { Datagram dg; @@ -172,12 +150,10 @@ as_bin() const { return dg.get_message(); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::set_from_bin -// Access: Published -// Description: Sets the HashVal from a 16-byte binary string. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the HashVal from a 16-byte binary string. Returns true if successful, + * false otherwise. + */ bool HashVal:: set_from_bin(const string &text) { nassertr(text.size() == 16, false); @@ -188,15 +164,11 @@ set_from_bin(const string &text) { } #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::hash_file -// Access: Published -// Description: Generates the hash value from the indicated file. -// Returns true on success, false if the file cannot be -// read. This method is only defined if we have the -// OpenSSL library (which provides md5 functionality) -// available. -//////////////////////////////////////////////////////////////////// +/** + * Generates the hash value from the indicated file. Returns true on success, + * false if the file cannot be read. This method is only defined if we have + * the OpenSSL library (which provides md5 functionality) available. + */ bool HashVal:: hash_file(const Filename &filename) { Filename bin_filename = Filename::binary_filename(filename); @@ -215,15 +187,11 @@ hash_file(const Filename &filename) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::hash_stream -// Access: Published -// Description: Generates the hash value from the indicated file. -// Returns true on success, false if the file cannot be -// read. This method is only defined if we have the -// OpenSSL library (which provides md5 functionality) -// available. -//////////////////////////////////////////////////////////////////// +/** + * Generates the hash value from the indicated file. Returns true on success, + * false if the file cannot be read. This method is only defined if we have + * the OpenSSL library (which provides md5 functionality) available. + */ bool HashVal:: hash_stream(istream &stream) { unsigned char md[16]; @@ -244,9 +212,9 @@ hash_stream(istream &stream) { stream.read(buffer, buffer_size); count = stream.gcount(); } - - // Clear the fail bit so the caller can still read the stream (if it - // wants to). + + // Clear the fail bit so the caller can still read the stream (if it wants + // to). stream.clear(); MD5_Final(md, &ctx); @@ -264,14 +232,11 @@ hash_stream(istream &stream) { #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::hash_buffer -// Access: Published -// Description: Generates the hash value by hashing the indicated -// data. This method is only defined if we have the -// OpenSSL library (which provides md5 functionality) -// available. -//////////////////////////////////////////////////////////////////// +/** + * Generates the hash value by hashing the indicated data. This method is + * only defined if we have the OpenSSL library (which provides md5 + * functionality) available. + */ void HashVal:: hash_buffer(const char *buffer, int length) { unsigned char md[16]; @@ -288,13 +253,10 @@ hash_buffer(const char *buffer, int length) { #endif // HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: HashVal::encode_hex -// Access: Private, Static -// Description: Encodes the indicated unsigned int into an -// eight-digit hex string, stored at the indicated -// buffer and the following 8 positions. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the indicated unsigned int into an eight-digit hex string, stored + * at the indicated buffer and the following 8 positions. + */ void HashVal:: encode_hex(PN_uint32 val, char *buffer) { buffer[0] = tohex(val >> 28); @@ -307,12 +269,9 @@ encode_hex(PN_uint32 val, char *buffer) { buffer[7] = tohex(val); } -//////////////////////////////////////////////////////////////////// -// Function: HashVal::decode_hex -// Access: Private, Static -// Description: Decodes the indicated eight-digit hex string into an -// unsigned integer. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the indicated eight-digit hex string into an unsigned integer. + */ void HashVal:: decode_hex(const char *buffer, PN_uint32 &val) { unsigned int bytes[8]; @@ -329,4 +288,3 @@ decode_hex(const char *buffer, PN_uint32 &val) { (bytes[6] << 4) | (bytes[7])); } - diff --git a/panda/src/express/hashVal.h b/panda/src/express/hashVal.h index 1b58f3c619..3d29fa87af 100644 --- a/panda/src/express/hashVal.h +++ b/panda/src/express/hashVal.h @@ -1,16 +1,15 @@ -// Filename: hashVal.h -// Created by: drose (14Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hashVal.h + * @author drose + * @date 2000-11-14 + */ #ifndef HASHVAL_H #define HASHVAL_H @@ -24,11 +23,10 @@ #include "streamWriter.h" #include "streamReader.h" -//////////////////////////////////////////////////////////////////// -// Class : HashVal -// Description : Stores a 128-bit value that represents the hashed -// contents (typically MD5) of a file or buffer. -//////////////////////////////////////////////////////////////////// +/** + * Stores a 128-bit value that represents the hashed contents (typically MD5) + * of a file or buffer. + */ class EXPCL_PANDAEXPRESS HashVal { PUBLISHED: INLINE HashVal(); diff --git a/panda/src/express/indirectLess.I b/panda/src/express/indirectLess.I index ed5f4f003b..b97b268fe1 100644 --- a/panda/src/express/indirectLess.I +++ b/panda/src/express/indirectLess.I @@ -1,23 +1,19 @@ -// Filename: indirectLess.I -// Created by: drose (27Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectLess.I + * @author drose + * @date 2001-06-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IndirectLess::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool IndirectLess:: operator () (const ObjectType *a, const ObjectType *b) const { diff --git a/panda/src/express/indirectLess.h b/panda/src/express/indirectLess.h index 729d98371f..5810f40eae 100644 --- a/panda/src/express/indirectLess.h +++ b/panda/src/express/indirectLess.h @@ -1,29 +1,26 @@ -// Filename: indirectLess.h -// Created by: drose (27Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectLess.h + * @author drose + * @date 2001-06-27 + */ #ifndef INDIRECTLESS_H #define INDIRECTLESS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : IndirectLess -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that contain an operator <() method. It defines the -// order of the pointers via operator <(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that contain an operator <() method. It + * defines the order of the pointers via operator <(). + */ template class IndirectLess { public: @@ -33,4 +30,3 @@ public: #include "indirectLess.I" #endif - diff --git a/panda/src/express/make_ca_bundle.cxx b/panda/src/express/make_ca_bundle.cxx index 59d8b34cf9..0794312de1 100644 --- a/panda/src/express/make_ca_bundle.cxx +++ b/panda/src/express/make_ca_bundle.cxx @@ -1,16 +1,15 @@ -// Filename: make_ca_bundle.cxx -// Created by: drose (07Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file make_ca_bundle.cxx + * @author drose + * @date 2009-10-07 + */ #include "pandabase.h" #include "openSSLWrapper.h" @@ -30,8 +29,8 @@ main(int argc, char *argv[]) { // Initialize OpenSSL. OpenSSLWrapper::get_global_ptr(); - // We have to be sure and clear the OpenSSL error state before we - // call this function, or it will get confused. + // We have to be sure and clear the OpenSSL error state before we call this + // function, or it will get confused. ERR_clear_error(); STACK_OF(X509_INFO) *inf; inf = PEM_X509_INFO_read(fin, NULL, NULL, NULL); @@ -41,7 +40,7 @@ main(int argc, char *argv[]) { cerr << "Couldn't read PEM file in " << source_filename << "\n"; return 0; } - + cerr << "PEM_X509_INFO_read() found " << sk_X509_INFO_num(inf) << " entries.\n"; @@ -69,8 +68,8 @@ main(int argc, char *argv[]) { fclose(fin); - // Now write the data to the .c file, in a compilable form, similar - // to bin2c. + // Now write the data to the .c file, in a compilable form, similar to + // bin2c. ofstream out; Filename target = Filename::text_filename(string(target_filename)); if (!target.open_write(out)) { @@ -120,10 +119,10 @@ main(int argc, char *argv[]) { ch = in.get(); } out << "\n};\n\n" - << static_keyword << length_type << table_name << "_len = " + << static_keyword << length_type << table_name << "_len = " << dec << count << ";\n\n"; - cerr << "Wrote " << cert_count << " certificates to " + cerr << "Wrote " << cert_count << " certificates to " << target_filename << "\n"; return 0; } diff --git a/panda/src/express/memoryInfo.I b/panda/src/express/memoryInfo.I index f71bb6d816..4fb25b34ca 100644 --- a/panda/src/express/memoryInfo.I +++ b/panda/src/express/memoryInfo.I @@ -1,24 +1,20 @@ -// Filename: memoryInfo.I -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryInfo.I + * @author drose + * @date 2001-06-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_void_ptr -// Access: Public -// Description: Returns the data pointer as a void pointer. This -// should always be non-NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data pointer as a void pointer. This should always be non- + * NULL. + */ void *MemoryInfo::get_void_ptr() const { if (_void_ptr != (void *)NULL) { return _void_ptr; @@ -32,57 +28,42 @@ void *MemoryInfo::get_void_ptr() const { return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_ref_ptr -// Access: Public -// Description: Returns the data pointer as a ReferenceCount pointer. -// This may be NULL if the data pointer does not -// represent a ReferenceCount object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data pointer as a ReferenceCount pointer. This may be NULL if + * the data pointer does not represent a ReferenceCount object. + */ ReferenceCount *MemoryInfo::get_ref_ptr() const { return _ref_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_typed_ptr -// Access: Public -// Description: Returns the data pointer as a TypedObject pointer. -// This may be NULL if the data pointer does not -// represent a pointer to a TypedObject. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data pointer as a TypedObject pointer. This may be NULL if the + * data pointer does not represent a pointer to a TypedObject. + */ TypedObject *MemoryInfo::get_typed_ptr() const { return _typed_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::is_size_known -// Access: Public -// Description: Returns true if the size of the memory block -// referenced by this pointer is known. Most pointers' -// sizes should be known, but some may not be. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the size of the memory block referenced by this pointer is + * known. Most pointers' sizes should be known, but some may not be. + */ bool MemoryInfo::is_size_known() const { return (_flags & F_size_known) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_size -// Access: Public -// Description: Returns the size in bytes of the memory block -// referenced by this pointer, if it is known. Returns -// zero if the size is not known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size in bytes of the memory block referenced by this pointer, + * if it is known. Returns zero if the size is not known. + */ size_t MemoryInfo::get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_time -// Access: Public -// Description: Returns the time in seconds (based on the -// GlobalClock) at which the pointer was allocated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time in seconds (based on the GlobalClock) at which the pointer + * was allocated. + */ double MemoryInfo::get_time() const { return _time; } - diff --git a/panda/src/express/memoryInfo.cxx b/panda/src/express/memoryInfo.cxx index 35c1a6d4f9..815e57448d 100644 --- a/panda/src/express/memoryInfo.cxx +++ b/panda/src/express/memoryInfo.cxx @@ -1,16 +1,15 @@ -// Filename: memoryInfo.cxx -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryInfo.cxx + * @author drose + * @date 2001-06-04 + */ #include "memoryInfo.h" @@ -19,11 +18,9 @@ #include "typedReferenceCount.h" #include "typeHandle.h" -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryInfo:: MemoryInfo() { _void_ptr = (void *)NULL; @@ -36,16 +33,13 @@ MemoryInfo() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::get_type -// Access: Public -// Description: Returns the best known type, dynamic or static, of -// the pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the best known type, dynamic or static, of the pointer. + */ TypeHandle MemoryInfo:: get_type() { - // If we don't want to consider the dynamic type any further, use - // what we've got. + // If we don't want to consider the dynamic type any further, use what we've + // got. if ((_flags & F_reconsider_dynamic_type) == 0) { if (_dynamic_type == TypeHandle::none()) { return _static_type; @@ -53,12 +47,11 @@ get_type() { return _dynamic_type; } - // Otherwise, examine the pointer again and make sure it's still the - // best information we have. We have to do this each time because - // if we happen to be examining the pointer from within the - // constructor or destructor, its dynamic type will appear to be - // less-specific than it actually is, so our idea of what type this - // thing is could change from time to time. + // Otherwise, examine the pointer again and make sure it's still the best + // information we have. We have to do this each time because if we happen + // to be examining the pointer from within the constructor or destructor, + // its dynamic type will appear to be less-specific than it actually is, so + // our idea of what type this thing is could change from time to time. determine_dynamic_type(); // Now return the more specific of the two. @@ -76,33 +69,28 @@ get_type() { return type; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::determine_dynamic_type -// Access: Private -// Description: Tries to determine the actual type of the object to -// which this thing is pointed, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Tries to determine the actual type of the object to which this thing is + * pointed, if possible. + */ void MemoryInfo:: determine_dynamic_type() { if ((_flags & F_reconsider_dynamic_type) != 0 && _static_type != TypeHandle::none()) { - // See if we know enough now to infer the dynamic type from the - // pointer. + // See if we know enough now to infer the dynamic type from the pointer. if (_typed_ptr == (TypedObject *)NULL) { - // If our static type is known to inherit from - // TypedReferenceCount, then we can directly downcast to get the - // TypedObject pointer. + // If our static type is known to inherit from TypedReferenceCount, then + // we can directly downcast to get the TypedObject pointer. if (_static_type.is_derived_from(TypedReferenceCount::get_class_type())) { _typed_ptr = (TypedReferenceCount *)_ref_ptr; } } if (_typed_ptr != (TypedObject *)NULL) { - // If we have a TypedObject pointer, we can determine the type. - // This might still not return the exact type, particularly if - // we are being called within the destructor or constructor of - // this object. + // If we have a TypedObject pointer, we can determine the type. This + // might still not return the exact type, particularly if we are being + // called within the destructor or constructor of this object. TypeHandle got_type = _typed_ptr->get_type(); if (got_type == TypeHandle::none()) { @@ -122,20 +110,17 @@ determine_dynamic_type() { TypeHandle orig_type = _dynamic_type; update_type_handle(_dynamic_type, got_type); - } + } } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryInfo::update_type_handle -// Access: Private -// Description: Updates the given destination TypeHandle with the -// refined TypeHandle, if it is in fact more specific -// than the original value for the destination. Returns -// true if the update was trouble-free, or false if the -// two types were not apparently related. -//////////////////////////////////////////////////////////////////// +/** + * Updates the given destination TypeHandle with the refined TypeHandle, if it + * is in fact more specific than the original value for the destination. + * Returns true if the update was trouble-free, or false if the two types were + * not apparently related. + */ bool MemoryInfo:: update_type_handle(TypeHandle &destination, TypeHandle refined) { if (refined == TypeHandle::none()) { @@ -150,7 +135,7 @@ update_type_handle(TypeHandle &destination, TypeHandle refined) { } else if (destination.is_derived_from(refined)) { // Updating with a less-specific type, no problem. - } else if (destination == TypeHandle::none() || + } else if (destination == TypeHandle::none() || refined.is_derived_from(destination)) { // Updating with a more-specific type, no problem. if (express_cat.is_spam()) { @@ -167,7 +152,7 @@ update_type_handle(TypeHandle &destination, TypeHandle refined) { << destination << " is now type " << refined << "!\n"; return false; } - + return true; } diff --git a/panda/src/express/memoryInfo.h b/panda/src/express/memoryInfo.h index 65c359728f..238cec05e3 100644 --- a/panda/src/express/memoryInfo.h +++ b/panda/src/express/memoryInfo.h @@ -1,16 +1,15 @@ -// Filename: memoryInfo.h -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryInfo.h + * @author drose + * @date 2001-06-04 + */ #ifndef MEMORYINFO_H #define MEMORYINFO_H @@ -24,16 +23,14 @@ class ReferenceCount; class TypedObject; -//////////////////////////////////////////////////////////////////// -// Class : MemoryInfo -// Description : This is a supporting class for MemoryUsage. It -// records the detailed information for a particular -// pointer allocated by Panda code. This record is only -// kept if track-mem-usage is configured #t. -// -// It's not exported from the DLL, and it doesn't even -// exist if we're compiling NDEBUG. -//////////////////////////////////////////////////////////////////// +/** + * This is a supporting class for MemoryUsage. It records the detailed + * information for a particular pointer allocated by Panda code. This record + * is only kept if track-mem-usage is configured #t. + * + * It's not exported from the DLL, and it doesn't even exist if we're + * compiling NDEBUG. + */ class MemoryInfo { public: MemoryInfo(); @@ -61,7 +58,7 @@ private: F_size_known = 0x0001, F_reconsider_dynamic_type = 0x0002, }; - + void *_void_ptr; ReferenceCount *_ref_ptr; TypedObject *_typed_ptr; @@ -69,7 +66,7 @@ private: TypeHandle _static_type; TypeHandle _dynamic_type; int _flags; - + double _time; int _freeze_index; @@ -81,4 +78,3 @@ private: #endif // DO_MEMORY_USAGE #endif - diff --git a/panda/src/express/memoryUsage.I b/panda/src/express/memoryUsage.I index ba2f8c197e..619da5a736 100644 --- a/panda/src/express/memoryUsage.I +++ b/panda/src/express/memoryUsage.I @@ -1,160 +1,124 @@ -// Filename: memoryUsage.I -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsage.I + * @author drose + * @date 2000-05-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::track_memory_usage -// Access: Public, Static -// Description: Returns true if the user has Configured the variable -// 'track-memory-usage' to true, indicating that this -// class will be in effect. If this returns false, the -// user has indicated not to do any of this. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the user has Configured the variable 'track-memory-usage' + * to true, indicating that this class will be in effect. If this returns + * false, the user has indicated not to do any of this. + */ INLINE bool MemoryUsage:: get_track_memory_usage() { return get_global_ptr()->_track_memory_usage; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::record_pointer -// Access: Public, Static -// Description: Indicates that the given pointer has been recently -// allocated. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given pointer has been recently allocated. + */ INLINE void MemoryUsage:: record_pointer(ReferenceCount *ptr) { get_global_ptr()->ns_record_pointer(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::update_type -// Access: Public, Static -// Description: Associates the indicated type with the given pointer. -// This should be called by functions (e.g. the -// constructor) that know more specifically what type of -// thing we've got; otherwise, the MemoryUsage database -// will know only that it's a "ReferenceCount". -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated type with the given pointer. This should be + * called by functions (e.g. the constructor) that know more specifically + * what type of thing we've got; otherwise, the MemoryUsage database will know + * only that it's a "ReferenceCount". + */ INLINE void MemoryUsage:: update_type(ReferenceCount *ptr, TypeHandle type) { get_global_ptr()->ns_update_type(ptr, type); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::update_type -// Access: Public, Static -// Description: Associates the indicated type with the given pointer. -// This flavor of update_type() also passes in the -// pointer as a TypedObject, and useful for objects that -// are, in fact, TypedObjects. Once the MemoryUsage -// database has the pointer as a TypedObject it doesn't -// need any more help. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated type with the given pointer. This flavor of + * update_type() also passes in the pointer as a TypedObject, and useful for + * objects that are, in fact, TypedObjects. Once the MemoryUsage database has + * the pointer as a TypedObject it doesn't need any more help. + */ INLINE void MemoryUsage:: update_type(ReferenceCount *ptr, TypedObject *typed_ptr) { get_global_ptr()->ns_update_type(ptr, typed_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::remove_pointer -// Access: Public, Static -// Description: Indicates that the given pointer has been recently -// freed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given pointer has been recently freed. + */ INLINE void MemoryUsage:: remove_pointer(ReferenceCount *ptr) { get_global_ptr()->ns_remove_pointer(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::is_tracking -// Access: Public, Static -// Description: Returns true if the MemoryUsage object is currently -// tracking memory (e.g. track-memory-usage is -// configured #t). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the MemoryUsage object is currently tracking memory (e.g. + * track-memory-usage is configured #t). + */ INLINE bool MemoryUsage:: is_tracking() { return get_global_ptr()->_track_memory_usage; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::is_counting -// Access: Public, Static -// Description: Returns true if the MemoryUsage object is currently -// at least counting memory (e.g. this is a Windows -// debug build), even if it's not fully tracking it. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the MemoryUsage object is currently at least counting + * memory (e.g. this is a Windows debug build), even if it's not fully + * tracking it. + */ INLINE bool MemoryUsage:: is_counting() { return get_global_ptr()->_count_memory_usage; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_current_cpp_size -// Access: Public, Static -// Description: Returns the total number of bytes of allocated memory -// consumed by C++ objects, not including the memory -// previously frozen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes of allocated memory consumed by C++ + * objects, not including the memory previously frozen. + */ INLINE size_t MemoryUsage:: get_current_cpp_size() { return get_global_ptr()->_current_cpp_size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_total_cpp_size -// Access: Public, Static -// Description: Returns the total number of bytes of allocated memory -// consumed by C++ objects, including the memory -// previously frozen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes of allocated memory consumed by C++ + * objects, including the memory previously frozen. + */ INLINE size_t MemoryUsage:: get_total_cpp_size() { return get_global_ptr()->_total_cpp_size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_panda_heap_single_size -// Access: Public, Static -// Description: Returns the total number of bytes allocated from the -// heap from code within Panda, for individual objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes allocated from the heap from code within + * Panda, for individual objects. + */ INLINE size_t MemoryUsage:: get_panda_heap_single_size() { return (size_t)AtomicAdjust::get(get_global_ptr()->_total_heap_single_size); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_panda_heap_array_size -// Access: Public, Static -// Description: Returns the total number of bytes allocated from the -// heap from code within Panda, for arrays. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes allocated from the heap from code within + * Panda, for arrays. + */ INLINE size_t MemoryUsage:: get_panda_heap_array_size() { return (size_t)AtomicAdjust::get(get_global_ptr()->_total_heap_array_size); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_panda_heap_overhead -// Access: Public, Static -// Description: Returns the extra bytes allocated from the system -// that are not immediately used for holding allocated -// objects. This can only be determined if -// ALTERNATIVE_MALLOC is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extra bytes allocated from the system that are not immediately + * used for holding allocated objects. This can only be determined if + * ALTERNATIVE_MALLOC is enabled. + */ INLINE size_t MemoryUsage:: get_panda_heap_overhead() { #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) @@ -165,47 +129,41 @@ get_panda_heap_overhead() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_panda_mmap_size -// Access: Public, Static -// Description: Returns the total number of bytes allocated from the -// virtual memory pool from code within Panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes allocated from the virtual memory pool + * from code within Panda. + */ INLINE size_t MemoryUsage:: get_panda_mmap_size() { return (size_t)AtomicAdjust::get(get_global_ptr()->_total_mmap_size); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_external_size -// Access: Public, Static -// Description: Returns the total number of bytes of allocated memory -// in the heap that Panda didn't seem to be responsible -// for. This includes a few bytes for very low-level -// objects (like ConfigVariables) that cannot use Panda -// memory tracking because they are so very low-level. -// -// This also includes all of the memory that might have -// been allocated by a high-level interpreter, like -// Python. -// -// This number is only available if Panda is able to -// hook into the actual heap callback. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes of allocated memory in the heap that + * Panda didn't seem to be responsible for. This includes a few bytes for + * very low-level objects (like ConfigVariables) that cannot use Panda memory + * tracking because they are so very low-level. + * + * This also includes all of the memory that might have been allocated by a + * high-level interpreter, like Python. + * + * This number is only available if Panda is able to hook into the actual heap + * callback. + */ INLINE size_t MemoryUsage:: get_external_size() { MemoryUsage *mu = get_global_ptr(); if (mu->_count_memory_usage) { - // We can only possibly know this with memory counting, which - // tracks every malloc call. + // We can only possibly know this with memory counting, which tracks every + // malloc call. #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) - // With alternative malloc, none of the Panda allocated memory - // shows up in total_size, so anything there is external. + // With alternative malloc, none of the Panda allocated memory shows up in + // total_size, so anything there is external. return mu->_total_size; #else - // Without alternative malloc, the Panda allocated memory is also - // included in total_size, so we have to subtract it out. + // Without alternative malloc, the Panda allocated memory is also included + // in total_size, so we have to subtract it out. return mu->_total_size - (size_t)mu->_total_heap_single_size - (size_t)mu->_total_heap_array_size; #endif } else { @@ -213,12 +171,10 @@ get_external_size() { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_total_size -// Access: Public, Static -// Description: Returns the total size of allocated memory consumed -// by the process, as nearly as can be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of allocated memory consumed by the process, as + * nearly as can be determined. + */ INLINE size_t MemoryUsage:: get_total_size() { MemoryUsage *mu = get_global_ptr(); @@ -233,146 +189,110 @@ get_total_size() { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_num_pointers -// Access: Public, Static -// Description: Returns the number of pointers currently active. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pointers currently active. + */ INLINE int MemoryUsage:: get_num_pointers() { return get_global_ptr()->ns_get_num_pointers(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_pointers -// Access: Public, Static -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers currently active. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers + * currently active. + */ INLINE void MemoryUsage:: get_pointers(MemoryUsagePointers &result) { get_global_ptr()->ns_get_pointers(result); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_pointers_of_type -// Access: Public, Static -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers of the indicated type currently -// active. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers of the + * indicated type currently active. + */ INLINE void MemoryUsage:: get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { get_global_ptr()->ns_get_pointers_of_type(result, type); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_pointers_of_age -// Access: Public, Static -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers that were allocated within the range -// of the indicated number of seconds ago. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers that + * were allocated within the range of the indicated number of seconds ago. + */ INLINE void MemoryUsage:: get_pointers_of_age(MemoryUsagePointers &result, double from, double to) { get_global_ptr()->ns_get_pointers_of_age(result, from, to); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_pointers_with_zero_count -// Access: Public, Static -// Description: Fills the indicated MemoryUsagePointers with the set -// of all currently active pointers (that is, pointers -// allocated since the last call to freeze(), and not -// yet freed) that have a zero reference count. -// -// Generally, an undeleted pointer with a zero reference -// count means its reference count has never been -// incremented beyond zero (since once it has been -// incremented, the only way it can return to zero would -// free the pointer). This may include objects that are -// allocated statically or on the stack, which are never -// intended to be deleted. Or, it might represent a -// programmer or compiler error. -// -// This function has the side-effect of incrementing -// each of their reference counts by one, thus -// preventing them from ever being freed--but since they -// hadn't been freed anyway, probably no additional harm -// is done. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all currently + * active pointers (that is, pointers allocated since the last call to + * freeze(), and not yet freed) that have a zero reference count. + * + * Generally, an undeleted pointer with a zero reference count means its + * reference count has never been incremented beyond zero (since once it has + * been incremented, the only way it can return to zero would free the + * pointer). This may include objects that are allocated statically or on the + * stack, which are never intended to be deleted. Or, it might represent a + * programmer or compiler error. + * + * This function has the side-effect of incrementing each of their reference + * counts by one, thus preventing them from ever being freed--but since they + * hadn't been freed anyway, probably no additional harm is done. + */ INLINE void MemoryUsage:: get_pointers_with_zero_count(MemoryUsagePointers &result) { get_global_ptr()->ns_get_pointers_with_zero_count(result); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::freeze -// Access: Public, Static -// Description: 'Freezes' all pointers currently stored so that they -// are no longer reported; only newly allocate pointers -// from this point on will appear in future information -// requests. This makes it easier to differentiate -// between continuous leaks and one-time memory -// allocations. -//////////////////////////////////////////////////////////////////// +/** + * 'Freezes' all pointers currently stored so that they are no longer + * reported; only newly allocate pointers from this point on will appear in + * future information requests. This makes it easier to differentiate between + * continuous leaks and one-time memory allocations. + */ INLINE void MemoryUsage:: freeze() { get_global_ptr()->ns_freeze(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::show_current_types -// Access: Public, Static -// Description: Shows the breakdown of types of all of the -// active pointers. -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of types of all of the active pointers. + */ INLINE void MemoryUsage:: show_current_types() { get_global_ptr()->ns_show_current_types(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::show_trend_types -// Access: Public, Static -// Description: Shows the breakdown of types of all of the -// pointers allocated and freed since the last call to -// freeze(). -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of types of all of the pointers allocated and freed + * since the last call to freeze(). + */ INLINE void MemoryUsage:: show_trend_types() { get_global_ptr()->ns_show_trend_types(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::show_current_ages -// Access: Public, Static -// Description: Shows the breakdown of ages of all of the -// active pointers. -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of ages of all of the active pointers. + */ INLINE void MemoryUsage:: show_current_ages() { get_global_ptr()->ns_show_current_ages(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::show_trend_ages -// Access: Public, Static -// Description: Shows the breakdown of ages of all of the -// pointers allocated and freed since the last call to -// freeze(). -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of ages of all of the pointers allocated and freed + * since the last call to freeze(). + */ INLINE void MemoryUsage:: show_trend_ages() { get_global_ptr()->ns_show_trend_ages(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_global_ptr -// Access: Private, Static -// Description: Returns the pointer to the only MemoryUsage object in -// the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the only MemoryUsage object in the world. + */ INLINE MemoryUsage *MemoryUsage:: get_global_ptr() { if (_global_ptr == (MemoryUsage *)NULL) { diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index 93315ac428..7c689fd1cd 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -1,16 +1,15 @@ -// Filename: memoryUsage.cxx -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsage.cxx + * @author drose + * @date 2000-05-25 + */ #include "memoryUsage.h" @@ -33,8 +32,8 @@ MemoryUsage *MemoryUsage::_global_ptr; -// This flag is used to protect the operator new/delete handlers -// against recursive entry. +// This flag is used to protect the operator newdelete handlers against +// recursive entry. bool MemoryUsage::_recursion_protect = false; // The cutoff ages, in seconds, for the various buckets in the AgeHistogram. @@ -47,22 +46,20 @@ double MemoryUsage::AgeHistogram::_cutoff[MemoryUsage::AgeHistogram::num_buckets }; -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::TypeHistogram::add_info -// Access: Public -// Description: Adds a single entry to the histogram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single entry to the histogram. + */ void MemoryUsage::TypeHistogram:: add_info(TypeHandle type, MemoryInfo *info) { _counts[type].add_info(info); } -// This class is a temporary class used only in TypeHistogram::show(), -// below, to sort the types in descending order by counts. +// This class is a temporary class used only in TypeHistogram::show(), below, +// to sort the types in descending order by counts. class TypeHistogramCountSorter { public: - TypeHistogramCountSorter(const MemoryUsagePointerCounts &count, + TypeHistogramCountSorter(const MemoryUsagePointerCounts &count, TypeHandle type) : _count(count), _type(type) @@ -75,15 +72,13 @@ public: TypeHandle _type; }; -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::TypeHistogram::show -// Access: Public -// Description: Shows the contents of the histogram to nout. -//////////////////////////////////////////////////////////////////// +/** + * Shows the contents of the histogram to nout. + */ void MemoryUsage::TypeHistogram:: show() const { - // First, copy the relevant information to a vector so we can sort - // by counts. Don't use a pvector. + // First, copy the relevant information to a vector so we can sort by + // counts. Don't use a pvector. typedef vector CountSorter; CountSorter count_sorter; Counts::const_iterator ci; @@ -106,31 +101,25 @@ show() const { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::TypeHistogram::clear -// Access: Public -// Description: Resets the histogram in preparation for new data. -//////////////////////////////////////////////////////////////////// +/** + * Resets the histogram in preparation for new data. + */ void MemoryUsage::TypeHistogram:: clear() { _counts.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::AgeHistogram::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryUsage::AgeHistogram:: AgeHistogram() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::AgeHistogram::add_info -// Access: Public -// Description: Adds a single entry to the histogram. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single entry to the histogram. + */ void MemoryUsage::AgeHistogram:: add_info(double age, MemoryInfo *info) { int bucket = choose_bucket(age); @@ -138,11 +127,9 @@ add_info(double age, MemoryInfo *info) { _counts[bucket].add_info(info); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::AgeHistogram::show -// Access: Public -// Description: Shows the contents of the histogram to nout. -//////////////////////////////////////////////////////////////////// +/** + * Shows the contents of the histogram to nout. + */ void MemoryUsage::AgeHistogram:: show() const { for (int i = 0; i < num_buckets - 1; i++) { @@ -155,11 +142,9 @@ show() const { nout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::AgeHistogram::clear -// Access: Public -// Description: Resets the histogram in preparation for new data. -//////////////////////////////////////////////////////////////////// +/** + * Resets the histogram in preparation for new data. + */ void MemoryUsage::AgeHistogram:: clear() { for (int i = 0; i < num_buckets; i++) { @@ -167,11 +152,9 @@ clear() { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::AgeHistogram::choose_bucket -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int MemoryUsage::AgeHistogram:: choose_bucket(double age) const { for (int i = num_buckets - 1; i >= 0; i--) { @@ -184,13 +167,10 @@ choose_bucket(double age) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::heap_alloc_single -// Access: Public, Virtual -// Description: Allocates a block of memory from the heap, similar to -// malloc(). This will never return NULL; it will abort -// instead if memory is not available. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a block of memory from the heap, similar to malloc(). This will + * never return NULL; it will abort instead if memory is not available. + */ void *MemoryUsage:: heap_alloc_single(size_t size) { void *ptr; @@ -224,12 +204,9 @@ heap_alloc_single(size_t size) { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::heap_free_single -// Access: Public, Virtual -// Description: Releases a block of memory previously allocated via -// heap_alloc_single. -//////////////////////////////////////////////////////////////////// +/** + * Releases a block of memory previously allocated via heap_alloc_single. + */ void MemoryUsage:: heap_free_single(void *ptr) { if (_recursion_protect) { @@ -256,13 +233,10 @@ heap_free_single(void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::heap_alloc_array -// Access: Public, Virtual -// Description: Allocates a block of memory from the heap, similar to -// malloc(). This will never return NULL; it will abort -// instead if memory is not available. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a block of memory from the heap, similar to malloc(). This will + * never return NULL; it will abort instead if memory is not available. + */ void *MemoryUsage:: heap_alloc_array(size_t size) { void *ptr; @@ -296,12 +270,9 @@ heap_alloc_array(size_t size) { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::heap_realloc_array -// Access: Public, Virtual -// Description: Resizes a block of memory previously returned from -// heap_alloc_array. -//////////////////////////////////////////////////////////////////// +/** + * Resizes a block of memory previously returned from heap_alloc_array. + */ void *MemoryUsage:: heap_realloc_array(void *ptr, size_t size) { if (_recursion_protect) { @@ -334,12 +305,9 @@ heap_realloc_array(void *ptr, size_t size) { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::heap_free_array -// Access: Public, Virtual -// Description: Releases a block of memory previously allocated via -// heap_alloc_array. -//////////////////////////////////////////////////////////////////// +/** + * Releases a block of memory previously allocated via heap_alloc_array. + */ void MemoryUsage:: heap_free_array(void *ptr) { if (_recursion_protect) { @@ -366,17 +334,13 @@ heap_free_array(void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::mark_pointer -// Access: Public, Virtual -// Description: This special method exists only to provide a callback -// hook into MemoryUsage. It indicates that the -// indicated pointer, allocated from somewhere other -// than a call to heap_alloc(), now contains a pointer -// to the indicated ReferenceCount object. If orig_size -// is 0, it indicates that the ReferenceCount object has -// been destroyed. -//////////////////////////////////////////////////////////////////// +/** + * This special method exists only to provide a callback hook into + * MemoryUsage. It indicates that the indicated pointer, allocated from + * somewhere other than a call to heap_alloc(), now contains a pointer to the + * indicated ReferenceCount object. If orig_size is 0, it indicates that the + * ReferenceCount object has been destroyed. + */ void MemoryUsage:: mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { if (_recursion_protect || !_track_memory_usage) { @@ -385,7 +349,7 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { if (express_cat.is_spam()) { express_cat.spam() - << "Marking pointer " << ptr << ", size " << size + << "Marking pointer " << ptr << ", size " << size << ", ref_ptr = " << ref_ptr << "\n"; } @@ -394,10 +358,9 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { ns_record_void_pointer(ptr, size); if (ref_ptr != (ReferenceCount *)NULL) { - // Make the pointer typed. This is particularly necessary in - // case the ref_ptr is a different value than the base void - // pointer; this may be our only opportunity to associate the - // two pointers. + // Make the pointer typed. This is particularly necessary in case the + // ref_ptr is a different value than the base void pointer; this may be + // our only opportunity to associate the two pointers. Table::iterator ti; ti = _table.find(ptr); nassertv(ti != _table.end()); @@ -407,10 +370,10 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { info->_static_type = ReferenceCount::get_class_type(); info->_dynamic_type = ReferenceCount::get_class_type(); info->_flags |= MemoryInfo::F_reconsider_dynamic_type; - + if (ref_ptr != ptr) { _recursion_protect = true; - + pair insert_result = _table.insert(Table::value_type((void *)ref_ptr, info)); assert(insert_result.first != _table.end()); @@ -419,7 +382,7 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { << "Attempt to mark pointer " << ptr << " as ReferenceCount " << ref_ptr << ", which was already allocated.\n"; } - + _recursion_protect = false; } } @@ -431,17 +394,14 @@ mark_pointer(void *ptr, size_t size, ReferenceCount *ref_ptr) { } #if (defined(WIN32_VC) || defined (WIN64_VC))&& defined(_DEBUG) -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::win32_malloc_hook -// Access: Public, Static -// Description: This callback is attached to the Win32 debug malloc -// system to be called whenever a pointer is allocated, -// reallocated, or freed. It's used to track the total -// memory allocated via calls to malloc(). -//////////////////////////////////////////////////////////////////// +/** + * This callback is attached to the Win32 debug malloc system to be called + * whenever a pointer is allocated, reallocated, or freed. It's used to track + * the total memory allocated via calls to malloc(). + */ int MemoryUsage:: -win32_malloc_hook(int alloc_type, void *ptr, - size_t size, int block_use, long request, +win32_malloc_hook(int alloc_type, void *ptr, + size_t size, int block_use, long request, const unsigned char *filename, int line) { MemoryUsage *mu = get_global_ptr(); int increment = 0; @@ -449,16 +409,16 @@ win32_malloc_hook(int alloc_type, void *ptr, case _HOOK_ALLOC: increment = size; break; - + case _HOOK_REALLOC: increment = size - _msize(ptr); break; - + case _HOOK_FREE: increment = - ((int)_msize(ptr)); break; } - + mu->_total_size += increment; return true; } @@ -466,26 +426,22 @@ win32_malloc_hook(int alloc_type, void *ptr, -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryUsage:: MemoryUsage(const MemoryHook ©) : MemoryHook(copy) { - // We must get these variables here instead of in - // config_express.cxx, because we need to know it at static init - // time, and who knows when the code in config_express will be - // executed. + // We must get these variables here instead of in config_express.cxx, + // because we need to know it at static init time, and who knows when the + // code in config_express will be executed. _track_memory_usage = ConfigVariableBool ("track-memory-usage", false, PRC_DESC("Set this to true to enable full-force tracking of C++ allocations " "and recordkeeping by type. It's quite expensive.")); - // Since enabling this after startup might cause bogus errors, we'd - // like to know if this happened, so we can squelch those error - // messages. + // Since enabling this after startup might cause bogus errors, we'd like to + // know if this happened, so we can squelch those error messages. _startup_track_memory_usage = _track_memory_usage; // Make sure the express category has been instantiated. @@ -519,9 +475,8 @@ MemoryUsage(const MemoryHook ©) : MemoryHook(copy) { #endif #if (defined(WIN32_VC) || defined(WIN64_VC)) && defined(_DEBUG) - // On a debug Windows build, we can set this malloc hook which - // allows tracking every malloc call, even from subordinate - // libraries. + // On a debug Windows build, we can set this malloc hook which allows + // tracking every malloc call, even from subordinate libraries. _CrtSetAllocHook(&win32_malloc_hook); _count_memory_usage = true; #endif @@ -534,15 +489,12 @@ MemoryUsage(const MemoryHook ©) : MemoryHook(copy) { _total_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::overflow_heap_size -// Access: Protected, Virtual -// Description: This callback method is called whenever the total -// allocated heap size exceeds _max_heap_size. It's -// mainly intended for reporting memory leaks, on the -// assumption that once we cross some specified -// threshold, we're just leaking memory. -//////////////////////////////////////////////////////////////////// +/** + * This callback method is called whenever the total allocated heap size + * exceeds _max_heap_size. It's mainly intended for reporting memory leaks, + * on the assumption that once we cross some specified threshold, we're just + * leaking memory. + */ void MemoryUsage:: overflow_heap_size() { MemoryHook::overflow_heap_size(); @@ -564,21 +516,18 @@ overflow_heap_size() { _report_memory_usage = true; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_record_pointer -// Access: Private -// Description: Indicates that the given pointer has been recently -// allocated. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given pointer has been recently allocated. + */ void MemoryUsage:: ns_record_pointer(ReferenceCount *ptr) { if (_track_memory_usage) { - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; pair insert_result = _table.insert(Table::value_type((void *)ptr, (MemoryInfo *)NULL)); - + // This shouldn't fail. assert(insert_result.first != _table.end()); @@ -590,8 +539,8 @@ ns_record_pointer(ReferenceCount *ptr) { MemoryInfo *info = (*insert_result.first).second; - // We might already have a ReferenceCount pointer, thanks to a - // previous call to mark_pointer(). + // We might already have a ReferenceCount pointer, thanks to a previous + // call to mark_pointer(). nassertv(info->_ref_ptr == NULL || info->_ref_ptr == ptr); info->_ref_ptr = ptr; @@ -601,9 +550,9 @@ ns_record_pointer(ReferenceCount *ptr) { info->_freeze_index = _freeze_index; info->_flags |= MemoryInfo::F_reconsider_dynamic_type; - // We close the recursion_protect flag all the way down here, so - // that we also protect ourselves against a possible recursive - // call in TrueClock::get_global_ptr(). + // We close the recursion_protect flag all the way down here, so that we + // also protect ourselves against a possible recursive call in + // TrueClock::get_global_ptr(). _recursion_protect = false; if (_report_memory_usage) { @@ -618,15 +567,12 @@ ns_record_pointer(ReferenceCount *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_update_type -// Access: Private -// Description: Associates the indicated type with the given pointer. -// This should be called by functions (e.g. the -// constructor) that know more specifically what type of -// thing we've got; otherwise, the MemoryUsage database -// will know only that it's a "ReferenceCount". -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated type with the given pointer. This should be + * called by functions (e.g. the constructor) that know more specifically + * what type of thing we've got; otherwise, the MemoryUsage database will know + * only that it's a "ReferenceCount". + */ void MemoryUsage:: ns_update_type(ReferenceCount *ptr, TypeHandle type) { if (_track_memory_usage) { @@ -651,16 +597,12 @@ ns_update_type(ReferenceCount *ptr, TypeHandle type) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_update_type -// Access: Private -// Description: Associates the indicated type with the given pointer. -// This flavor of update_type() also passes in the -// pointer as a TypedObject, and useful for objects that -// are, in fact, TypedObjects. Once the MemoryUsage -// database has the pointer as a TypedObject it doesn't -// need any more help. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated type with the given pointer. This flavor of + * update_type() also passes in the pointer as a TypedObject, and useful for + * objects that are, in fact, TypedObjects. Once the MemoryUsage database has + * the pointer as a TypedObject it doesn't need any more help. + */ void MemoryUsage:: ns_update_type(ReferenceCount *ptr, TypedObject *typed_ptr) { if (_track_memory_usage) { @@ -684,12 +626,9 @@ ns_update_type(ReferenceCount *ptr, TypedObject *typed_ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_remove_pointer -// Access: Private -// Description: Indicates that the given pointer has been recently -// freed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given pointer has been recently freed. + */ void MemoryUsage:: ns_remove_pointer(ReferenceCount *ptr) { if (_track_memory_usage) { @@ -726,8 +665,8 @@ ns_remove_pointer(ReferenceCount *ptr) { if (info->_freeze_index == _freeze_index) { double now = TrueClock::get_global_ptr()->get_long_time(); - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; _trend_types.add_info(info->get_type(), info); _trend_ages.add_info(now - info->_time, info); @@ -737,8 +676,8 @@ ns_remove_pointer(ReferenceCount *ptr) { if (ptr != info->_void_ptr || info->_void_ptr == NULL) { // Remove the entry from the table. - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; _table.erase(ti); _recursion_protect = false; @@ -758,13 +697,10 @@ ns_remove_pointer(ReferenceCount *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_record_void_pointer -// Access: Private -// Description: Records a pointer that's not even necessarily a -// ReferenceCount object (but for which we know the size -// of the allocated structure). -//////////////////////////////////////////////////////////////////// +/** + * Records a pointer that's not even necessarily a ReferenceCount object (but + * for which we know the size of the allocated structure). + */ void MemoryUsage:: ns_record_void_pointer(void *ptr, size_t size) { if (_track_memory_usage) { @@ -773,8 +709,8 @@ ns_record_void_pointer(void *ptr, size_t size) { << "Recording void pointer " << (void *)ptr << "\n"; } - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; pair insert_result = @@ -810,19 +746,16 @@ ns_record_void_pointer(void *ptr, size_t size) { info->_freeze_index = _freeze_index; info->_flags |= MemoryInfo::F_size_known; - // We close the recursion_protect flag all the way down here, so - // that we also protect ourselves against a possible recursive - // call in TrueClock::get_global_ptr(). + // We close the recursion_protect flag all the way down here, so that we + // also protect ourselves against a possible recursive call in + // TrueClock::get_global_ptr(). _recursion_protect = false; } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_remove_void_pointer -// Access: Private -// Description: Removes a pointer previously recorded via -// record_void_pointer. -//////////////////////////////////////////////////////////////////// +/** + * Removes a pointer previously recorded via record_void_pointer. + */ void MemoryUsage:: ns_remove_void_pointer(void *ptr) { if (_track_memory_usage) { @@ -836,11 +769,10 @@ ns_remove_void_pointer(void *ptr) { if (ti == _table.end()) { // The pointer we tried to delete was not recorded in the table. - // We can't report this as an error, because (a) we might have - // removed the void pointer entry already when we consolidated, - // and (b) a few objects might have been created during static - // init time, before we grabbed the operator new/delete function - // handlers. + // We can't report this as an error, because (a) we might have removed + // the void pointer entry already when we consolidated, and (b) a few + // objects might have been created during static init time, before we + // grabbed the operator newdelete function handlers. return; } @@ -866,8 +798,8 @@ ns_remove_void_pointer(void *ptr) { // Remove it from the table. - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; _table.erase(ti); _recursion_protect = false; @@ -883,23 +815,19 @@ ns_remove_void_pointer(void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_get_num_pointers -// Access: Private -// Description: Returns the number of pointers currently active. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pointers currently active. + */ int MemoryUsage:: ns_get_num_pointers() { nassertr(_track_memory_usage, 0); return _count; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_get_pointers -// Access: Private -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers currently active. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers + * currently active. + */ void MemoryUsage:: ns_get_pointers(MemoryUsagePointers &result) { nassertv(_track_memory_usage); @@ -921,13 +849,10 @@ ns_get_pointers(MemoryUsagePointers &result) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_get_pointers_of_type -// Access: Private -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers of the indicated type currently -// active. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers of the + * indicated type currently active. + */ void MemoryUsage:: ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { nassertv(_track_memory_usage); @@ -953,13 +878,10 @@ ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_get_pointers_of_age -// Access: Private -// Description: Fills the indicated MemoryUsagePointers with the set -// of all pointers that were allocated within the range -// of the indicated number of seconds ago. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all pointers that + * were allocated within the range of the indicated number of seconds ago. + */ void MemoryUsage:: ns_get_pointers_of_age(MemoryUsagePointers &result, double from, double to) { @@ -985,29 +907,22 @@ ns_get_pointers_of_age(MemoryUsagePointers &result, } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_get_pointers_with_zero_count -// Access: Private -// Description: Fills the indicated MemoryUsagePointers with the set -// of all currently active pointers (that is, pointers -// allocated since the last call to freeze(), and not -// yet freed) that have a zero reference count. -// -// Generally, an undeleted pointer with a zero reference -// count means its reference count has never been -// incremented beyond zero (since once it has been -// incremented, the only way it can return to zero would -// free the pointer). This may include objects that are -// allocated statically or on the stack, which are never -// intended to be deleted. Or, it might represent a -// programmer or compiler error. -// -// This function has the side-effect of incrementing -// each of their reference counts by one, thus -// preventing them from ever being freed--but since they -// hadn't been freed anyway, probably no additional harm -// is done. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated MemoryUsagePointers with the set of all currently + * active pointers (that is, pointers allocated since the last call to + * freeze(), and not yet freed) that have a zero reference count. + * + * Generally, an undeleted pointer with a zero reference count means its + * reference count has never been incremented beyond zero (since once it has + * been incremented, the only way it can return to zero would free the + * pointer). This may include objects that are allocated statically or on the + * stack, which are never intended to be deleted. Or, it might represent a + * programmer or compiler error. + * + * This function has the side-effect of incrementing each of their reference + * counts by one, thus preventing them from ever being freed--but since they + * hadn't been freed anyway, probably no additional harm is done. + */ void MemoryUsage:: ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { nassertv(_track_memory_usage); @@ -1021,7 +936,7 @@ ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { InfoSet::iterator si; for (si = _info_set.begin(); si != _info_set.end(); ++si) { MemoryInfo *info = (*si); - if (info->_freeze_index == _freeze_index && + if (info->_freeze_index == _freeze_index && info->_ref_ptr != (ReferenceCount *)NULL) { if (info->_ref_ptr->get_ref_count() == 0) { info->_ref_ptr->ref(); @@ -1032,16 +947,12 @@ ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_freeze -// Access: Private -// Description: 'Freezes' all pointers currently stored so that they -// are no longer reported; only newly allocate pointers -// from this point on will appear in future information -// requests. This makes it easier to differentiate -// between continuous leaks and one-time memory -// allocations. -//////////////////////////////////////////////////////////////////// +/** + * 'Freezes' all pointers currently stored so that they are no longer + * reported; only newly allocate pointers from this point on will appear in + * future information requests. This makes it easier to differentiate between + * continuous leaks and one-time memory allocations. + */ void MemoryUsage:: ns_freeze() { _count = 0; @@ -1051,12 +962,9 @@ ns_freeze() { _freeze_index++; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_show_current_types -// Access: Private -// Description: Shows the breakdown of types of all of the -// active pointers. -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of types of all of the active pointers. + */ void MemoryUsage:: ns_show_current_types() { nassertv(_track_memory_usage); @@ -1078,24 +986,18 @@ ns_show_current_types() { _recursion_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_show_trend_types -// Access: Private -// Description: Shows the breakdown of types of all of the -// pointers allocated and freed since the last call to -// freeze(). -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of types of all of the pointers allocated and freed + * since the last call to freeze(). + */ void MemoryUsage:: ns_show_trend_types() { _trend_types.show(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_show_current_ages -// Access: Private -// Description: Shows the breakdown of ages of all of the -// active pointers. -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of ages of all of the active pointers. + */ void MemoryUsage:: ns_show_current_ages() { nassertv(_track_memory_usage); @@ -1116,27 +1018,21 @@ ns_show_current_ages() { _recursion_protect = false; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::ns_show_trend_ages -// Access: Private -// Description: Shows the breakdown of ages of all of the -// pointers allocated and freed since the last call to -// freeze(). -//////////////////////////////////////////////////////////////////// +/** + * Shows the breakdown of ages of all of the pointers allocated and freed + * since the last call to freeze(). + */ void MemoryUsage:: ns_show_trend_ages() { _trend_ages.show(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::consolidate_void_ptr -// Access: Private -// Description: If the size information has not yet been determined -// for this pointer, checks to see if it has possibly -// been recorded under the TypedObject pointer (this -// will happen when the class inherits from TypedObject -// before ReferenceCount, e.g. TypedReferenceCount). -//////////////////////////////////////////////////////////////////// +/** + * If the size information has not yet been determined for this pointer, + * checks to see if it has possibly been recorded under the TypedObject + * pointer (this will happen when the class inherits from TypedObject before + * ReferenceCount, e.g. TypedReferenceCount). + */ void MemoryUsage:: consolidate_void_ptr(MemoryInfo *info) { if (info->is_size_known()) { @@ -1148,13 +1044,13 @@ consolidate_void_ptr(MemoryInfo *info) { // We don't have a typed pointer for this thing yet. return; } - + TypedObject *typed_ptr = info->_typed_ptr; if ((void *)typed_ptr == (void *)info->_ref_ptr) { - // The TypedObject pointer is the same pointer as the - // ReferenceCount pointer, so there's no point in looking it up - // separately. Actually, this really shouldn't even be possible. + // The TypedObject pointer is the same pointer as the ReferenceCount + // pointer, so there's no point in looking it up separately. Actually, + // this really shouldn't even be possible. return; } @@ -1182,8 +1078,8 @@ consolidate_void_ptr(MemoryInfo *info) { } } - // Now that we've consolidated the pointers, remove the entry for - // the typed pointer. + // Now that we've consolidated the pointers, remove the entry for the typed + // pointer. if (info->_freeze_index == _freeze_index) { _count--; _current_cpp_size -= info->_size; @@ -1195,23 +1091,20 @@ consolidate_void_ptr(MemoryInfo *info) { (*ti).second = info; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::refresh_info_set -// Access: Private -// Description: Recomputes the _info_set table, if necessary. This -// table stores a unique entry for each MemoryInfo -// object in _table. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the _info_set table, if necessary. This table stores a unique + * entry for each MemoryInfo object in _table. + */ void MemoryUsage:: refresh_info_set() { if (!_info_set_dirty) { return; } - // We have to protect modifications to the table from recursive - // calls by toggling _recursion_protect while we adjust it. + // We have to protect modifications to the table from recursive calls by + // toggling _recursion_protect while we adjust it. _recursion_protect = true; - + _info_set.clear(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index 0a2f653e7e..b52f71f7ea 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -1,16 +1,15 @@ -// Filename: memoryUsage.h -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsage.h + * @author drose + * @date 2000-05-25 + */ #ifndef MEMORYUSAGE_H #define MEMORYUSAGE_H @@ -28,16 +27,14 @@ class ReferenceCount; class MemoryUsagePointers; -//////////////////////////////////////////////////////////////////// -// Class : MemoryUsage -// Description : This class is used strictly for debugging purposes, -// specifically for tracking memory leaks of -// reference-counted objects: it keeps a record of every -// such object currently allocated. -// -// When compiled with NDEBUG set, this entire class does -// nothing and compiles to nothing. -//////////////////////////////////////////////////////////////////// +/** + * This class is used strictly for debugging purposes, specifically for + * tracking memory leaks of reference-counted objects: it keeps a record of + * every such object currently allocated. + * + * When compiled with NDEBUG set, this entire class does nothing and compiles + * to nothing. + */ class EXPCL_PANDAEXPRESS MemoryUsage : public MemoryHook { public: INLINE static bool get_track_memory_usage(); @@ -58,11 +55,11 @@ public: virtual void mark_pointer(void *ptr, size_t orig_size, ReferenceCount *ref_ptr); #if (defined(WIN32_VC) || defined(WIN64_VC)) && defined(_DEBUG) - static int win32_malloc_hook(int alloc_type, void *ptr, - size_t size, int block_use, long request, + static int win32_malloc_hook(int alloc_type, void *ptr, + size_t size, int block_use, long request, const unsigned char *filename, int line); #endif - + PUBLISHED: INLINE static bool is_tracking(); INLINE static bool is_counting(); @@ -126,19 +123,20 @@ private: static MemoryUsage *_global_ptr; - // We shouldn't use a pmap, since that would be recursive! - // Actually, it turns out that it doesn't matter, since somehow the - // pallocator gets used even though we don't specify it here, so we - // have to make special code that handles the recursion anyway. + // We shouldn't use a pmap, since that would be recursive! Actually, it + // turns out that it doesn't matter, since somehow the pallocator gets used + // even though we don't specify it here, so we have to make special code + // that handles the recursion anyway. - // This table stores up to two entiries for each MemoryInfo object: - // one for the void pointer (the pointer to the beginning of the - // allocated memory block), and one for the ReferenceCount pointer. - // For a particular object, these two pointers may be the same or - // they may be different. Some objects may be stored under both - // pointers, while others may be stored under only one pointer or - // the other. We don't store an entry for an object's TypedObject - // pointer. +/* + * This table stores up to two entiries for each MemoryInfo object: one for + * the void pointer (the pointer to the beginning of the allocated memory + * block), and one for the ReferenceCount pointer. For a particular object, + * these two pointers may be the same or they may be different. Some objects + * may be stored under both pointers, while others may be stored under only + * one pointer or the other. We don't store an entry for an object's + * TypedObject pointer. + */ typedef map Table; Table _table; @@ -199,4 +197,3 @@ private: #endif // DO_MEMORY_USAGE #endif - diff --git a/panda/src/express/memoryUsagePointerCounts.I b/panda/src/express/memoryUsagePointerCounts.I index 8cc063ddd4..79aeba084c 100644 --- a/panda/src/express/memoryUsagePointerCounts.I +++ b/panda/src/express/memoryUsagePointerCounts.I @@ -1,23 +1,19 @@ -// Filename: memoryUsagePointerCounts.I -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointerCounts.I + * @author drose + * @date 2001-06-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MemoryUsagePointerCounts:: MemoryUsagePointerCounts() { _count = 0; @@ -25,11 +21,9 @@ MemoryUsagePointerCounts() { _size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MemoryUsagePointerCounts:: MemoryUsagePointerCounts(const MemoryUsagePointerCounts ©) : _count(copy._count), @@ -38,11 +32,9 @@ MemoryUsagePointerCounts(const MemoryUsagePointerCounts ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MemoryUsagePointerCounts:: operator = (const MemoryUsagePointerCounts ©) { _count = copy._count; @@ -50,11 +42,9 @@ operator = (const MemoryUsagePointerCounts ©) { _size = copy._size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::clear -// Access: Public -// Description: Resets the counter to empty. -//////////////////////////////////////////////////////////////////// +/** + * Resets the counter to empty. + */ INLINE void MemoryUsagePointerCounts:: clear() { _count = 0; @@ -62,44 +52,35 @@ clear() { _size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::is_size_unknown -// Access: Public -// Description: Returns true if none of the pointers in the count -// have a known size, or false if at least one of them -// does. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if none of the pointers in the count have a known size, or + * false if at least one of them does. + */ INLINE bool MemoryUsagePointerCounts:: is_size_unknown() const { return _unknown_size_count == _count; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::get_size -// Access: Public -// Description: Returns the total allocated size of all pointers in -// the count whose size is known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total allocated size of all pointers in the count whose size is + * known. + */ INLINE size_t MemoryUsagePointerCounts:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::get_count -// Access: Public -// Description: Returns the total number of pointers in the count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of pointers in the count. + */ INLINE int MemoryUsagePointerCounts:: get_count() const { return _count; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MemoryUsagePointerCounts:: operator < (const MemoryUsagePointerCounts &other) const { if (is_size_unknown() != other.is_size_unknown()) { diff --git a/panda/src/express/memoryUsagePointerCounts.cxx b/panda/src/express/memoryUsagePointerCounts.cxx index b0e144d14b..d218d57589 100644 --- a/panda/src/express/memoryUsagePointerCounts.cxx +++ b/panda/src/express/memoryUsagePointerCounts.cxx @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointerCounts.cxx -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointerCounts.cxx + * @author drose + * @date 2001-06-04 + */ #include "memoryUsagePointerCounts.h" @@ -18,11 +17,9 @@ #include "memoryInfo.h" -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::add_info -// Access: Public -// Description: Adds a pointer definition to the counter. -//////////////////////////////////////////////////////////////////// +/** + * Adds a pointer definition to the counter. + */ void MemoryUsagePointerCounts:: add_info(MemoryInfo *info) { _count++; @@ -34,11 +31,9 @@ add_info(MemoryInfo *info) { } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MemoryUsagePointerCounts:: output(ostream &out) const { out << _count << " pointers"; @@ -48,31 +43,28 @@ output(ostream &out) const { out << ", avg "; output_bytes(out, _size / (_count - _unknown_size_count)); out << " each"; - + if (_unknown_size_count != 0) { out << " (" << _unknown_size_count << " of unknown size)"; } } } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointerCounts::output_bytes -// Access: Private, Static -// Description: Formats a size in bytes in a meaningful and concise -// way for output, with units. -//////////////////////////////////////////////////////////////////// +/** + * Formats a size in bytes in a meaningful and concise way for output, with + * units. + */ void MemoryUsagePointerCounts:: output_bytes(ostream &out, size_t size) { if (size < 4 * 1024) { out << size << " bytes"; - + } else if (size < 4 * 1024 * 1024) { out << size / 1024 << " Kb"; - + } else { out << size / (1024 * 1024) << " Mb"; } } #endif // DO_MEMORY_USAGE - diff --git a/panda/src/express/memoryUsagePointerCounts.h b/panda/src/express/memoryUsagePointerCounts.h index 1b06ae0ae2..935538fdee 100644 --- a/panda/src/express/memoryUsagePointerCounts.h +++ b/panda/src/express/memoryUsagePointerCounts.h @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointerCounts.h -// Created by: drose (04Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointerCounts.h + * @author drose + * @date 2001-06-04 + */ #ifndef MEMORYUSAGEPOINTERCOUNTS_H #define MEMORYUSAGEPOINTERCOUNTS_H @@ -21,14 +20,12 @@ class MemoryInfo; -//////////////////////////////////////////////////////////////////// -// Class : MemoryUsagePointerCounts -// Description : This is a supporting class for MemoryUsage. It -// tracks the relative counts of a number of pointers of -// some type (or age), for use by TypeHistogram and -// AgeHistogram. It's not exported from the DLL, and it -// doesn't even exist if we're compiling NDEBUG. -//////////////////////////////////////////////////////////////////// +/** + * This is a supporting class for MemoryUsage. It tracks the relative counts + * of a number of pointers of some type (or age), for use by TypeHistogram and + * AgeHistogram. It's not exported from the DLL, and it doesn't even exist if + * we're compiling NDEBUG. + */ class MemoryUsagePointerCounts { public: INLINE MemoryUsagePointerCounts(); @@ -61,4 +58,3 @@ INLINE ostream &operator << (ostream &out, const MemoryUsagePointerCounts &c); #endif // DO_MEMORY_USAGE #endif - diff --git a/panda/src/express/memoryUsagePointers.I b/panda/src/express/memoryUsagePointers.I index 4991d58c4d..98da2ede60 100644 --- a/panda/src/express/memoryUsagePointers.I +++ b/panda/src/express/memoryUsagePointers.I @@ -1,22 +1,19 @@ -// Filename: memoryUsagePointers.I -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointers.I + * @author drose + * @date 2000-05-25 + */ -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Entry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MemoryUsagePointers::Entry:: Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr, TypeHandle type, double age) : @@ -28,11 +25,9 @@ Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr, _ref_ptr->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Entry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MemoryUsagePointers::Entry:: Entry(const Entry ©) : _ref_ptr(copy._ref_ptr), @@ -43,18 +38,16 @@ Entry(const Entry ©) : _ref_ptr->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Entry::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MemoryUsagePointers::Entry:: operator = (const Entry ©) { if (_ref_ptr != copy._ref_ptr) { _ref_ptr->unref(); _ref_ptr = copy._ref_ptr; - // We can't call unref_delete(), because we don't know what kind - // of pointer it is precisely. Potential leak. + // We can't call unref_delete(), because we don't know what kind of + // pointer it is precisely. Potential leak. _ref_ptr->ref(); } _typed_ptr = copy._typed_ptr; @@ -62,15 +55,12 @@ operator = (const Entry ©) { _age = copy._age; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Entry::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MemoryUsagePointers::Entry:: ~Entry() { - // We can't call unref_delete(), because we don't know what kind - // of pointer it is precisely. Potential leak. + // We can't call unref_delete(), because we don't know what kind of pointer + // it is precisely. Potential leak. _ref_ptr->unref(); } - diff --git a/panda/src/express/memoryUsagePointers.cxx b/panda/src/express/memoryUsagePointers.cxx index 2eb78a1d50..fff8199c5a 100644 --- a/panda/src/express/memoryUsagePointers.cxx +++ b/panda/src/express/memoryUsagePointers.cxx @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointers.cxx -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointers.cxx + * @author drose + * @date 2000-05-25 + */ #include "memoryUsagePointers.h" @@ -20,53 +19,42 @@ #include "referenceCount.h" #include "typedReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryUsagePointers:: MemoryUsagePointers() { } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MemoryUsagePointers:: ~MemoryUsagePointers() { } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_num_pointers -// Access: Published -// Description: Returns the number of pointers in the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pointers in the set. + */ size_t MemoryUsagePointers:: get_num_pointers() const { return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_pointer -// Access: Published -// Description: Returns the nth pointer of the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth pointer of the set. + */ ReferenceCount *MemoryUsagePointers:: get_pointer(size_t n) const { nassertr(n < get_num_pointers(), NULL); return _entries[n]._ref_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_typed_pointer -// Access: Published -// Description: Returns the nth pointer of the set, typecast to a -// TypedObject if possible. If the pointer is not a -// TypedObject or if the cast cannot be made, returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth pointer of the set, typecast to a TypedObject if possible. + * If the pointer is not a TypedObject or if the cast cannot be made, returns + * NULL. + */ TypedObject *MemoryUsagePointers:: get_typed_pointer(size_t n) const { nassertr(n < get_num_pointers(), NULL); @@ -80,17 +68,18 @@ get_typed_pointer(size_t n) const { TypeHandle type = _entries[n]._type; - // We can only cast-across to a TypedObject when we explicitly know - // the inheritance path. Most of the time, this will be via - // TypedReferenceCount. There are classes defined in other packages - // that inherit from TypedObject and ReferenceCount separately (like - // Node), but we can't do anything about that here without knowing - // about the particular class. (Actually, we couldn't do anything - // about Node anyway, because it inherits virtually from - // ReferenceCount.) +/* + * We can only cast-across to a TypedObject when we explicitly know the + * inheritance path. Most of the time, this will be via TypedReferenceCount. + * There are classes defined in other packages that inherit from TypedObject + * and ReferenceCount separately (like Node), but we can't do anything about + * that here without knowing about the particular class. (Actually, we + * couldn't do anything about Node anyway, because it inherits virtually from + * ReferenceCount.) + */ - // RTTI can't help us here, because ReferenceCount has no virtual - // functions, so we can't use C++'s new dynamic_cast feature. + // RTTI can't help us here, because ReferenceCount has no virtual functions, + // so we can't use C++'s new dynamic_cast feature. if (type != TypeHandle::none() && type.is_derived_from(TypedReferenceCount::get_class_type())) { @@ -99,76 +88,60 @@ get_typed_pointer(size_t n) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_type -// Access: Published -// Description: Returns the actual type of the nth pointer, if it is -// known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual type of the nth pointer, if it is known. + */ TypeHandle MemoryUsagePointers:: get_type(size_t n) const { nassertr(n < get_num_pointers(), TypeHandle::none()); return _entries[n]._type; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_type_name -// Access: Published -// Description: Returns the type name of the nth pointer, if it is -// known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type name of the nth pointer, if it is known. + */ string MemoryUsagePointers:: get_type_name(size_t n) const { nassertr(n < get_num_pointers(), ""); return get_type(n).get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_age -// Access: Published -// Description: Returns the age of the nth pointer: the number of -// seconds elapsed between the time it was allocated and -// the time it was added to this set via a call to -// MemoryUsage::get_pointers(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the age of the nth pointer: the number of seconds elapsed between + * the time it was allocated and the time it was added to this set via a call + * to MemoryUsage::get_pointers(). + */ double MemoryUsagePointers:: get_age(size_t n) const { nassertr(n < get_num_pointers(), 0.0); return _entries[n]._age; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::clear -// Access: Published -// Description: Empties the set of pointers. -//////////////////////////////////////////////////////////////////// +/** + * Empties the set of pointers. + */ void MemoryUsagePointers:: clear() { _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MemoryUsagePointers:: output(ostream &out) const { out << _entries.size() << " pointers."; } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::clear -// Access: Private -// Description: Adds a new entry to the set. Intended to be called -// only by MemoryUsage. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new entry to the set. Intended to be called only by MemoryUsage. + */ void MemoryUsagePointers:: add_entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr, TypeHandle type, double age) { - // We can't safely add pointers with a zero reference count. They - // might be statically-allocated or something, and if we try to add - // them they'll try to destruct when the PointerTo later goes away. + // We can't safely add pointers with a zero reference count. They might be + // statically-allocated or something, and if we try to add them they'll try + // to destruct when the PointerTo later goes away. if (ref_ptr->get_ref_count() != 0) { _entries.push_back(Entry(ref_ptr, typed_ptr, type, age)); } diff --git a/panda/src/express/memoryUsagePointers.h b/panda/src/express/memoryUsagePointers.h index 532e59be6a..317910760b 100644 --- a/panda/src/express/memoryUsagePointers.h +++ b/panda/src/express/memoryUsagePointers.h @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointers.h -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointers.h + * @author drose + * @date 2000-05-25 + */ #ifndef MEMORYUSAGEPOINTERS_H #define MEMORYUSAGEPOINTERS_H @@ -24,27 +23,21 @@ #include "referenceCount.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : MemoryUsagePointers -// Description : This is a list of pointers returned by a MemoryUsage -// object in response to some query. -// -// Warning: once pointers are stored in a -// MemoryUsagePointers object, they are -// reference-counted, and will not be freed until the -// MemoryUsagePointers object is freed (or clear() is -// called on the object). However, they may not even be -// freed then; pointers may leak once they have been -// added to this structure. This is because we don't -// store enough information in this structure to -// correctly free the pointers that have been added. -// Since this is intended primarily as a debugging tool, -// this is not a major issue. -// -// This class is just a user interface to talk about -// pointers stored in a MemoryUsage object. It doesn't -// even exist when compiled with NDEBUG. -//////////////////////////////////////////////////////////////////// +/** + * This is a list of pointers returned by a MemoryUsage object in response to + * some query. + * + * Warning: once pointers are stored in a MemoryUsagePointers object, they are + * reference-counted, and will not be freed until the MemoryUsagePointers + * object is freed (or clear() is called on the object). However, they may + * not even be freed then; pointers may leak once they have been added to this + * structure. This is because we don't store enough information in this + * structure to correctly free the pointers that have been added. Since this + * is intended primarily as a debugging tool, this is not a major issue. + * + * This class is just a user interface to talk about pointers stored in a + * MemoryUsage object. It doesn't even exist when compiled with NDEBUG. + */ class EXPCL_PANDAEXPRESS MemoryUsagePointers { PUBLISHED: MemoryUsagePointers(); @@ -79,10 +72,10 @@ private: INLINE ~Entry(); // We have an ordinary pointer to a type ReferenceCount, and not a - // PT(ReferenceCount), because we can't actually delete this thing - // (since ReferenceCount has no public destructor). If we can't - // delete it, we can't make a PointerTo it, since PointerTo wants - // to be able to delete things. + // PT(ReferenceCount), because we can't actually delete this thing (since + // ReferenceCount has no public destructor). If we can't delete it, we + // can't make a PointerTo it, since PointerTo wants to be able to delete + // things. ReferenceCount *_ref_ptr; TypedObject *_typed_ptr; TypeHandle _type; @@ -104,4 +97,3 @@ INLINE ostream &operator << (ostream &out, const MemoryUsagePointers &mup) { #endif // MEMORY_USAGE_POINTERS #endif - diff --git a/panda/src/express/memoryUsagePointers_ext.cxx b/panda/src/express/memoryUsagePointers_ext.cxx index 73732e274b..c1013027ab 100644 --- a/panda/src/express/memoryUsagePointers_ext.cxx +++ b/panda/src/express/memoryUsagePointers_ext.cxx @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointers_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointers_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "memoryUsagePointers_ext.h" @@ -22,19 +21,15 @@ extern Dtool_PyTypedObject Dtool_TypedReferenceCount; extern Dtool_PyTypedObject Dtool_ReferenceCount; #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsagePointers::get_python_pointer -// Access: Published -// Description: Returns the nth object, represented as a Python -// object of the appropriate type. Reference counting -// will be properly set on the Python object. -// -// get_typed_pointer() is almost as good as this, but -// (a) it does not set the reference count, and (b) it -// does not work for objects that do not inherit from -// TypedObject. This will work for any object whose -// type is known, which has a Python representation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth object, represented as a Python object of the appropriate + * type. Reference counting will be properly set on the Python object. + * + * get_typed_pointer() is almost as good as this, but (a) it does not set the + * reference count, and (b) it does not work for objects that do not inherit + * from TypedObject. This will work for any object whose type is known, which + * has a Python representation. + */ PyObject *Extension:: get_python_pointer(size_t n) const { TypedObject *typed_ptr = _this->get_typed_pointer(n); diff --git a/panda/src/express/memoryUsagePointers_ext.h b/panda/src/express/memoryUsagePointers_ext.h index edc0e1651b..8bba830329 100644 --- a/panda/src/express/memoryUsagePointers_ext.h +++ b/panda/src/express/memoryUsagePointers_ext.h @@ -1,16 +1,15 @@ -// Filename: memoryUsagePointers_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file memoryUsagePointers_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef MEMORYUSAGEPOINTERS_EXT_H #define MEMORYUSAGEPOINTERS_EXT_H @@ -23,12 +22,10 @@ #include "memoryUsagePointers.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// VirtualFileSystem, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for VirtualFileSystem, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/multifile.I b/panda/src/express/multifile.I index f2ddf6b060..5e20779f0d 100644 --- a/panda/src/express/multifile.I +++ b/panda/src/express/multifile.I @@ -1,153 +1,117 @@ -// Filename: multifile.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multifile.I + * @author mike + * @date 1997-01-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_multifile_name -// Access: Published -// Description: Returns the filename of the Multifile, if it is -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename of the Multifile, if it is available. + */ INLINE const Filename &Multifile:: get_multifile_name() const { return _multifile_name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_multifile_name -// Access: Published -// Description: Replaces the filename of the Multifile. This is -// primarily used for documentation purposes only; -// changing this name does not open the indicated file. -// See open_read() or open_write() for that. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the filename of the Multifile. This is primarily used for + * documentation purposes only; changing this name does not open the indicated + * file. See open_read() or open_write() for that. + */ INLINE void Multifile:: set_multifile_name(const Filename &multifile_name) { _multifile_name = multifile_name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::is_read_valid -// Access: Published -// Description: Returns true if the Multifile has been opened for -// read mode and there have been no errors, and -// individual Subfile contents may be extracted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Multifile has been opened for read mode and there have + * been no errors, and individual Subfile contents may be extracted. + */ INLINE bool Multifile:: is_read_valid() const { return (_read != (IStreamWrapper *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::is_write_valid -// Access: Published -// Description: Returns true if the Multifile has been opened for -// write mode and there have been no errors, and -// Subfiles may be added or removed from the Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Multifile has been opened for write mode and there have + * been no errors, and Subfiles may be added or removed from the Multifile. + */ INLINE bool Multifile:: is_write_valid() const { return (_write != (ostream *)NULL && !_write->fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::needs_repack -// Access: Published -// Description: Returns true if the Multifile index is suboptimal and -// should be repacked. Call repack() to achieve this. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Multifile index is suboptimal and should be repacked. + * Call repack() to achieve this. + */ INLINE bool Multifile:: needs_repack() const { return _needs_repack || (_scale_factor != _new_scale_factor); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_timestamp -// Access: Published -// Description: Returns the modification timestamp of the overall -// Multifile. This indicates the most recent date at -// which subfiles were added or removed from the -// Multifile. Note that it is logically possible for an -// individual subfile to have a more recent timestamp -// than the overall timestamp. -//////////////////////////////////////////////////////////////////// +/** + * Returns the modification timestamp of the overall Multifile. This + * indicates the most recent date at which subfiles were added or removed from + * the Multifile. Note that it is logically possible for an individual + * subfile to have a more recent timestamp than the overall timestamp. + */ INLINE time_t Multifile:: get_timestamp() const { return _timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_record_timestamp -// Access: Published -// Description: Sets the flag indicating whether timestamps should be -// recorded within the Multifile or not. The default is -// true, indicating the Multifile will record timestamps -// for the overall file and also for each subfile. -// -// If this is false, the Multifile will not record -// timestamps internally. In this case, the return -// value from get_timestamp() or get_subfile_timestamp() -// will be estimations. -// -// You may want to set this false to minimize the -// bitwise difference between independently-generated -// Multifiles. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether timestamps should be recorded within the + * Multifile or not. The default is true, indicating the Multifile will + * record timestamps for the overall file and also for each subfile. + * + * If this is false, the Multifile will not record timestamps internally. In + * this case, the return value from get_timestamp() or get_subfile_timestamp() + * will be estimations. + * + * You may want to set this false to minimize the bitwise difference between + * independently-generated Multifiles. + */ INLINE void Multifile:: set_record_timestamp(bool flag) { _record_timestamp = flag; _timestamp_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_record_timestamp -// Access: Published -// Description: Returns the flag indicating whether timestamps -// should be recorded within the Multifile or not. See -// set_record_timestamp(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag indicating whether timestamps should be recorded within + * the Multifile or not. See set_record_timestamp(). + */ INLINE bool Multifile:: get_record_timestamp() const { return _record_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_scale_factor -// Access: Published -// Description: Returns the internal scale factor for this Multifile. -// See set_scale_factor(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal scale factor for this Multifile. See + * set_scale_factor(). + */ INLINE size_t Multifile:: get_scale_factor() const { return _new_scale_factor; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_encryption_flag -// Access: Published -// Description: Sets the flag indicating whether subsequently-added -// subfiles should be encrypted before writing them to -// the multifile. If true, subfiles will be encrypted; -// if false (the default), they will be written without -// encryption. -// -// When true, subfiles will be encrypted with the -// password specified by set_encryption_password(). It -// is possible to apply a different password to -// different files, but the resulting file can't be -// mounted via VFS. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether subsequently-added subfiles should be + * encrypted before writing them to the multifile. If true, subfiles will be + * encrypted; if false (the default), they will be written without encryption. + * + * When true, subfiles will be encrypted with the password specified by + * set_encryption_password(). It is possible to apply a different password to + * different files, but the resulting file can't be mounted via VFS. + */ INLINE void Multifile:: set_encryption_flag(bool flag) { #ifndef HAVE_OPENSSL @@ -160,32 +124,24 @@ set_encryption_flag(bool flag) { _encryption_flag = flag; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_encryption_flag -// Access: Published -// Description: Returns the flag indicating whether -// subsequently-added subfiles should be encrypted -// before writing them to the multifile. See -// set_encryption_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag indicating whether subsequently-added subfiles should be + * encrypted before writing them to the multifile. See set_encryption_flag(). + */ INLINE bool Multifile:: get_encryption_flag() const { return _encryption_flag; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_encryption_password -// Access: Published -// Description: Specifies the password that will be used to encrypt -// subfiles subsequently added to the multifile, if the -// encryption flag is also set true (see -// set_encryption_flag()). -// -// It is possible to apply a different password to -// different files, but the resulting file can't be -// mounted via VFS. Changing this value may cause an -// implicit call to flush(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the password that will be used to encrypt subfiles subsequently + * added to the multifile, if the encryption flag is also set true (see + * set_encryption_flag()). + * + * It is possible to apply a different password to different files, but the + * resulting file can't be mounted via VFS. Changing this value may cause an + * implicit call to flush(). + */ INLINE void Multifile:: set_encryption_password(const string &encryption_password) { if (_encryption_password != encryption_password) { @@ -196,38 +152,29 @@ set_encryption_password(const string &encryption_password) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_encryption_password -// Access: Published -// Description: Returns the password that will be used to encrypt -// subfiles subsequently added to the multifile. See -// set_encryption_password(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the password that will be used to encrypt subfiles subsequently + * added to the multifile. See set_encryption_password(). + */ INLINE const string &Multifile:: get_encryption_password() const { return _encryption_password; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_encryption_algorithm -// Access: Public -// Description: Specifies the encryption algorithm that should be -// used for future calls to add_subfile(). The default -// is whatever is specified by the encryption-algorithm -// config variable. The complete set of available -// algorithms is defined by the current version of -// OpenSSL. -// -// If an invalid algorithm is specified, there is no -// immediate error return code, but flush() will fail -// and the file will be invalid. -// -// It is possible to apply a different encryption -// algorithm to different files, and unlike the -// password, this does not interfere with mounting the -// multifile via VFS. Changing this value may cause an -// implicit call to flush(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the encryption algorithm that should be used for future calls to + * add_subfile(). The default is whatever is specified by the encryption- + * algorithm config variable. The complete set of available algorithms is + * defined by the current version of OpenSSL. + * + * If an invalid algorithm is specified, there is no immediate error return + * code, but flush() will fail and the file will be invalid. + * + * It is possible to apply a different encryption algorithm to different + * files, and unlike the password, this does not interfere with mounting the + * multifile via VFS. Changing this value may cause an implicit call to + * flush(). + */ INLINE void Multifile:: set_encryption_algorithm(const string &encryption_algorithm) { if (_encryption_algorithm != encryption_algorithm) { @@ -238,35 +185,28 @@ set_encryption_algorithm(const string &encryption_algorithm) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_encryption_algorithm -// Access: Public -// Description: Returns the encryption algorithm that was specified -// by set_encryption_algorithm(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption algorithm that was specified by + * set_encryption_algorithm(). + */ INLINE const string &Multifile:: get_encryption_algorithm() const { return _encryption_algorithm; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_encryption_key_length -// Access: Public -// Description: Specifies the length of the key, in bits, that should -// be used to encrypt the stream in future calls to -// add_subfile(). The default is whatever is specified -// by the encryption-key-length config variable. -// -// If an invalid key_length for the chosen algorithm is -// specified, there is no immediate error return code, -// but flush() will fail and the file will be invalid. -// -// It is possible to apply a different key length to -// different files, and unlike the password, this does -// not interfere with mounting the multifile via VFS. -// Changing this value may cause an implicit call to -// flush(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the length of the key, in bits, that should be used to encrypt + * the stream in future calls to add_subfile(). The default is whatever is + * specified by the encryption-key-length config variable. + * + * If an invalid key_length for the chosen algorithm is specified, there is no + * immediate error return code, but flush() will fail and the file will be + * invalid. + * + * It is possible to apply a different key length to different files, and + * unlike the password, this does not interfere with mounting the multifile + * via VFS. Changing this value may cause an implicit call to flush(). + */ INLINE void Multifile:: set_encryption_key_length(int encryption_key_length) { if (_encryption_key_length != encryption_key_length) { @@ -277,38 +217,30 @@ set_encryption_key_length(int encryption_key_length) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_encryption_key_length -// Access: Public -// Description: Returns the encryption key length, in bits, that was -// specified by set_encryption_key_length(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the encryption key length, in bits, that was specified by + * set_encryption_key_length(). + */ INLINE int Multifile:: get_encryption_key_length() const { return _encryption_key_length; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_encryption_iteration_count -// Access: Public -// Description: Specifies the number of times to repeatedly hash the -// key before writing it to the stream in future calls -// to add_subfile(). Its purpose is to make it -// computationally more expensive for an attacker to -// search the key space exhaustively. This should be a -// multiple of 1,000 and should not exceed about 65 -// million; the value 0 indicates just one application -// of the hashing algorithm. -// -// The default is whatever is specified by the -// multifile-encryption-iteration-count config variable. -// -// It is possible to apply a different iteration count -// to different files, and unlike the password, this -// does not interfere with mounting the multifile via -// VFS. Changing this value causes an implicit call to -// flush(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of times to repeatedly hash the key before writing it + * to the stream in future calls to add_subfile(). Its purpose is to make it + * computationally more expensive for an attacker to search the key space + * exhaustively. This should be a multiple of 1,000 and should not exceed + * about 65 million; the value 0 indicates just one application of the hashing + * algorithm. + * + * The default is whatever is specified by the multifile-encryption-iteration- + * count config variable. + * + * It is possible to apply a different iteration count to different files, and + * unlike the password, this does not interfere with mounting the multifile + * via VFS. Changing this value causes an implicit call to flush(). + */ INLINE void Multifile:: set_encryption_iteration_count(int encryption_iteration_count) { if (_encryption_iteration_count != encryption_iteration_count) { @@ -317,32 +249,24 @@ set_encryption_iteration_count(int encryption_iteration_count) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_encryption_iteration_count -// Access: Public -// Description: Returns the value that was specified by -// set_encryption_iteration_count(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value that was specified by set_encryption_iteration_count(). + */ INLINE int Multifile:: get_encryption_iteration_count() const { return _encryption_iteration_count; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::remove_subfile -// Access: Published -// Description: Removes the named subfile from the Multifile, if it -// exists; returns true if successfully removed, or -// false if it did not exist in the first place. The -// file will not actually be removed from the disk until -// the next call to flush(). -// -// Note that this does not actually remove the data from -// the indicated subfile; it simply removes it from the -// index. The Multifile will not be reduced in size -// after this operation, until the next call to -// repack(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the named subfile from the Multifile, if it exists; returns true if + * successfully removed, or false if it did not exist in the first place. The + * file will not actually be removed from the disk until the next call to + * flush(). + * + * Note that this does not actually remove the data from the indicated + * subfile; it simply removes it from the index. The Multifile will not be + * reduced in size after this operation, until the next call to repack(). + */ INLINE bool Multifile:: remove_subfile(const string &subfile_name) { int index = find_subfile(subfile_name); @@ -353,12 +277,10 @@ remove_subfile(const string &subfile_name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::read_subfile -// Access: Published -// Description: Returns a string that contains the entire contents of -// the indicated subfile. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that contains the entire contents of the indicated + * subfile. + */ INLINE string Multifile:: read_subfile(int index) { string result; @@ -366,67 +288,54 @@ read_subfile(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_magic_number -// Access: Published, Static -// Description: Returns a string with the first n bytes written to a -// Multifile, to identify it as a Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string with the first n bytes written to a Multifile, to identify + * it as a Multifile. + */ INLINE string Multifile:: get_magic_number() { return string(_header, _header_size); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_header_prefix -// Access: Published -// Description: Returns the string that preceded the Multifile header -// on the file, if any. See set_header_prefix(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that preceded the Multifile header on the file, if any. + * See set_header_prefix(). + */ INLINE const string &Multifile:: get_header_prefix() const { return _header_prefix; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::word_to_streampos -// Access: Private -// Description: Converts a size_t address read from the file to -// a streampos byte address within the file. -//////////////////////////////////////////////////////////////////// +/** + * Converts a size_t address read from the file to a streampos byte address + * within the file. + */ INLINE streampos Multifile:: word_to_streampos(size_t word) const { return (streampos)word * (streampos)_scale_factor; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::streampos_to_word -// Access: Private -// Description: Converts a streampos byte address within the file to -// a size_t value suitable for writing to the file. -//////////////////////////////////////////////////////////////////// +/** + * Converts a streampos byte address within the file to a size_t value + * suitable for writing to the file. + */ INLINE size_t Multifile:: streampos_to_word(streampos fpos) const { - return (size_t)((fpos + (streampos)_scale_factor - (streampos)1) / (streampos)_scale_factor); + return (size_t)((fpos + (streampos)_scale_factor - (streampos)1) / (streampos)_scale_factor); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::normalize_streampos -// Access: Private -// Description: Rounds the streampos byte address up to the next -// multiple of _scale_factor. Only multiples of -// _scale_factor may be written to the file. -//////////////////////////////////////////////////////////////////// +/** + * Rounds the streampos byte address up to the next multiple of _scale_factor. + * Only multiples of _scale_factor may be written to the file. + */ INLINE streampos Multifile:: normalize_streampos(streampos fpos) const { return word_to_streampos(streampos_to_word(fpos)); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::tohex -// Access: Private, Static -// Description: Converts a single nibble to a hex digit. -//////////////////////////////////////////////////////////////////// +/** + * Converts a single nibble to a hex digit. + */ INLINE char Multifile:: tohex(unsigned int nibble) { nibble &= 0xf; @@ -436,11 +345,9 @@ tohex(unsigned int nibble) { return nibble - 10 + 'a'; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Multifile::Subfile:: Subfile() { _index_start = 0; @@ -455,82 +362,64 @@ Subfile() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::operator < -// Access: Public -// Description: Compares two Subfiles for proper sorting within the -// index. -//////////////////////////////////////////////////////////////////// +/** + * Compares two Subfiles for proper sorting within the index. + */ INLINE bool Multifile::Subfile:: operator < (const Multifile::Subfile &other) const { - // This should only be called on normal subfiles, not on certificate - // files or signature files. (We don't attempt to sort these - // special signature files.) + // This should only be called on normal subfiles, not on certificate files + // or signature files. (We don't attempt to sort these special signature + // files.) nassertr(!is_cert_special() && !other.is_cert_special(), false); - // Normal subfiles are simply sorted in alphabetical order by - // filename. + // Normal subfiles are simply sorted in alphabetical order by filename. return _name < other._name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::is_deleted -// Access: Public -// Description: Returns true if the Subfile indicates it has been -// deleted (removed from the index), false otherwise. -// This should never be true of Subfiles that currently -// appear in either the _subfiles or _new_subfiles -// lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Subfile indicates it has been deleted (removed from the + * index), false otherwise. This should never be true of Subfiles that + * currently appear in either the _subfiles or _new_subfiles lists. + */ INLINE bool Multifile::Subfile:: is_deleted() const { return (_flags & SF_deleted) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::is_index_invalid -// Access: Public -// Description: Returns true if there was some problem reading the -// index record for this Subfile from the Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there was some problem reading the index record for this + * Subfile from the Multifile. + */ INLINE bool Multifile::Subfile:: is_index_invalid() const { return (_flags & SF_index_invalid) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::is_data_invalid -// Access: Public -// Description: Returns true if there was some problem reading the -// data contents of this Subfile, particularly when -// copying into the Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there was some problem reading the data contents of this + * Subfile, particularly when copying into the Multifile. + */ INLINE bool Multifile::Subfile:: is_data_invalid() const { return (_flags & SF_data_invalid) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::is_cert_special -// Access: Public -// Description: Returns true if this Subfile represents a signature -// record, which is treated specially; or false if it is -// an ordinary Subfile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this Subfile represents a signature record, which is + * treated specially; or false if it is an ordinary Subfile. + */ INLINE bool Multifile::Subfile:: is_cert_special() const { return (_flags & SF_signature) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::get_last_byte_pos -// Access: Public -// Description: Returns the byte position within the Multifile of the -// last byte that contributes to this Subfile, either in -// the index record or in the subfile data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the byte position within the Multifile of the last byte that + * contributes to this Subfile, either in the index record or in the subfile + * data. + */ INLINE streampos Multifile::Subfile:: get_last_byte_pos() const { - return max(_index_start + (streampos)_index_length, + return max(_index_start + (streampos)_index_length, _data_start + (streampos)_data_length) - (streampos)1; } diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index dd62271a02..21befb49dc 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -1,16 +1,15 @@ -// Filename: multifile.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multifile.cxx + * @author mike + * @date 1997-01-09 + */ #include "multifile.h" @@ -27,81 +26,67 @@ #include #include -// This sequence of bytes begins each Multifile to identify it as a -// Multifile. +// This sequence of bytes begins each Multifile to identify it as a Multifile. const char Multifile::_header[] = "pmf\0\n\r"; const size_t Multifile::_header_size = 6; -// These numbers identify the version of the Multifile. Generally, a -// change in the major version is intolerable; while a Multifile with -// an older minor version may still be read. +// These numbers identify the version of the Multifile. Generally, a change +// in the major version is intolerable; while a Multifile with an older minor +// version may still be read. const int Multifile::_current_major_ver = 1; const int Multifile::_current_minor_ver = 1; -// Bumped to version 1.1 on 6/8/06 to add timestamps. +// Bumped to version 1.1 on 6806 to add timestamps. -// To confirm that the supplied password matches, we write the -// Mutifile magic header at the beginning of the encrypted stream. -// I suppose this does compromise the encryption security a tiny -// bit by making it easy for crackers to validate that a -// particular password guess matches or doesn't match, but the -// encryption algorithm doesn't depend on this being difficult +// To confirm that the supplied password matches, we write the Mutifile magic +// header at the beginning of the encrypted stream. I suppose this does +// compromise the encryption security a tiny bit by making it easy for +// crackers to validate that a particular password guess matches or doesn't +// match, but the encryption algorithm doesn't depend on this being difficult // anyway. const char Multifile::_encrypt_header[] = "crypty"; const size_t Multifile::_encrypt_header_size = 6; -// -// A Multifile consists of the following elements: -// -// (1) A header. This is always the first n bytes of the Multifile, -// and contains a magic number to identify the file, as well as -// version numbers and any file-specific parameters. -// -// char[6] The string Multifile::_header, a magic number. -// int16 The file's major version number -// int16 The file's minor version number -// uint32 Scale factor. This scales all address references within -// the file. Normally 1, this may be set larger to -// support Multifiles larger than 4GB. -// uint32 An overall modification timestamp for the entire multifile. +/* + * A Multifile consists of the following elements: (1) A header. This is + * always the first n bytes of the Multifile, and contains a magic number to + * identify the file, as well as version numbers and any file-specific + * parameters. char[6] The string Multifile::_header, a magic number. + * int16 The file's major version number int16 The file's minor + * version number uint32 Scale factor. This scales all address references + * within the file. Normally 1, this may be set larger to support Multifiles + * larger than 4GB. uint32 An overall modification timestamp for the + * entire multifile. + */ -// -// (2) Zero or more index entries, one for each subfile within the -// Multifile. These entries are of variable length. The first one of -// these immediately follows the header, and the first word of each -// index entry contains the address of the next index entry. A zero -// "next" address marks the end of the chain. These may appear at any -// point within the Multifile; they do not necessarily appear in -// sequential order at the beginning of the file (although they will -// after the file has been "packed"). -// -// uint32 The address of the next entry. 0 to mark the end. -// uint32 The address of this subfile's data record. -// uint32 The length in bytes of this subfile's data record. -// uint16 The Subfile::_flags member. -// [uint32] The original, uncompressed and unencrypted length of the -// subfile, if it is compressed or encrypted. This field -// is only present if one or both of the SF_compressed -// or SF_encrypted bits are set in _flags. -// uint32 A modification timestamp for the subfile. -// uint16 The length in bytes of the subfile's name. -// char[n] The subfile's name. -// -// (3) Zero or more data entries, one for each subfile. These may -// appear at any point within the Multifile; they do not necessarily -// follow each index entry, nor are they necessarily all grouped -// together at the end (although they will be all grouped together at -// the end after the file has been "packed"). These are just blocks -// of literal data. -// +/* + * (2) Zero or more index entries, one for each subfile within the Multifile. + * These entries are of variable length. The first one of these immediately + * follows the header, and the first word of each index entry contains the + * address of the next index entry. A zero "next" address marks the end of + * the chain. These may appear at any point within the Multifile; they do not + * necessarily appear in sequential order at the beginning of the file + * (although they will after the file has been "packed"). uint32 The + * address of the next entry. 0 to mark the end. uint32 The address of + * this subfile's data record. uint32 The length in bytes of this + * subfile's data record. uint16 The Subfile::_flags member. [uint32] + * The original, uncompressed and unencrypted length of the subfile, if it is + * compressed or encrypted. This field is only present if one or both of the + * SF_compressed or SF_encrypted bits are set in _flags. uint32 A + * modification timestamp for the subfile. uint16 The length in bytes of + * the subfile's name. char[n] The subfile's name. (3) Zero or more data + * entries, one for each subfile. These may appear at any point within the + * Multifile; they do not necessarily follow each index entry, nor are they + * necessarily all grouped together at the end (although they will be all + * grouped together at the end after the file has been "packed"). These are + * just blocks of literal data. + */ -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Multifile:: Multifile() : _read_filew(_read_file), @@ -141,21 +126,17 @@ Multifile() : #endif } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Multifile:: ~Multifile() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Copy Constructor -// Access: Private -// Description: Don't try to copy Multifiles. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to copy Multifiles. + */ Multifile:: Multifile(const Multifile ©) : _read_filew(_read_file), @@ -164,28 +145,22 @@ Multifile(const Multifile ©) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Copy Assignment Operator -// Access: Private -// Description: Don't try to copy Multifiles. -//////////////////////////////////////////////////////////////////// +/** + * Don't try to copy Multifiles. + */ void Multifile:: operator = (const Multifile ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read -// Access: Published -// Description: Opens the named Multifile on disk for reading. The -// Multifile index is read in, and the list of subfiles -// becomes available; individual subfiles may then be -// extracted or read, but the list of subfiles may not -// be modified. -// -// Also see the version of open_read() which accepts an -// istream. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named Multifile on disk for reading. The Multifile index is read + * in, and the list of subfiles becomes available; individual subfiles may + * then be extracted or read, but the list of subfiles may not be modified. + * + * Also see the version of open_read() which accepts an istream. Returns true + * on success, false on failure. + */ bool Multifile:: open_read(const Filename &multifile_name, const streampos &offset) { close(); @@ -211,18 +186,14 @@ open_read(const Filename &multifile_name, const streampos &offset) { return read_index(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read -// Access: Public -// Description: Opens an anonymous Multifile for reading using an -// istream. There must be seek functionality via -// seekg() and tellg() on the istream. -// -// If owns_pointer is true, then the Multifile assumes -// ownership of the stream pointer and will delete it -// when the multifile is closed, including if this -// function returns false. -//////////////////////////////////////////////////////////////////// +/** + * Opens an anonymous Multifile for reading using an istream. There must be + * seek functionality via seekg() and tellg() on the istream. + * + * If owns_pointer is true, then the Multifile assumes ownership of the stream + * pointer and will delete it when the multifile is closed, including if this + * function returns false. + */ bool Multifile:: open_read(IStreamWrapper *multifile_stream, bool owns_pointer, const streampos &offset) { @@ -235,19 +206,15 @@ open_read(IStreamWrapper *multifile_stream, bool owns_pointer, return read_index(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_write -// Access: Published -// Description: Opens the named Multifile on disk for writing. If -// there already exists a file by that name, it is -// truncated. The Multifile is then prepared for -// accepting a brand new set of subfiles, which will be -// written to the indicated filename. Individual -// subfiles may not be extracted or read. -// -// Also see the version of open_write() which accepts an -// ostream. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named Multifile on disk for writing. If there already exists a + * file by that name, it is truncated. The Multifile is then prepared for + * accepting a brand new set of subfiles, which will be written to the + * indicated filename. Individual subfiles may not be extracted or read. + * + * Also see the version of open_write() which accepts an ostream. Returns + * true on success, false on failure. + */ bool Multifile:: open_write(const Filename &multifile_name) { close(); @@ -263,18 +230,14 @@ open_write(const Filename &multifile_name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_write -// Access: Public -// Description: Opens an anonymous Multifile for writing using an -// ostream. There must be seek functionality via -// seekp() and tellp() on the pstream. -// -// If owns_pointer is true, then the Multifile assumes -// ownership of the stream pointer and will delete it -// when the multifile is closed, including if this -// function returns false. -//////////////////////////////////////////////////////////////////// +/** + * Opens an anonymous Multifile for writing using an ostream. There must be + * seek functionality via seekp() and tellp() on the pstream. + * + * If owns_pointer is true, then the Multifile assumes ownership of the stream + * pointer and will delete it when the multifile is closed, including if this + * function returns false. + */ bool Multifile:: open_write(ostream *multifile_stream, bool owns_pointer) { close(); @@ -286,19 +249,15 @@ open_write(ostream *multifile_stream, bool owns_pointer) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read_write -// Access: Published -// Description: Opens the named Multifile on disk for reading and -// writing. If there already exists a file by that -// name, its index is read. Subfiles may be added or -// removed, and the resulting changes will be written to -// the named file. -// -// Also see the version of open_read_write() which -// accepts an iostream. Returns true on success, false -// on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the named Multifile on disk for reading and writing. If there + * already exists a file by that name, its index is read. Subfiles may be + * added or removed, and the resulting changes will be written to the named + * file. + * + * Also see the version of open_read_write() which accepts an iostream. + * Returns true on success, false on failure. + */ bool Multifile:: open_read_write(const Filename &multifile_name) { close(); @@ -325,29 +284,25 @@ open_read_write(const Filename &multifile_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read_write -// Access: Public -// Description: Opens an anonymous Multifile for reading and writing -// using an iostream. There must be seek functionality -// via seekg()/seekp() and tellg()/tellp() on the -// iostream. -// -// If owns_pointer is true, then the Multifile assumes -// ownership of the stream pointer and will delete it -// when the multifile is closed, including if this -// function returns false. -//////////////////////////////////////////////////////////////////// +/** + * Opens an anonymous Multifile for reading and writing using an iostream. + * There must be seek functionality via seekg()/seekp() and tellg()/tellp() on + * the iostream. + * + * If owns_pointer is true, then the Multifile assumes ownership of the stream + * pointer and will delete it when the multifile is closed, including if this + * function returns false. + */ bool Multifile:: open_read_write(iostream *multifile_stream, bool owns_pointer) { close(); _timestamp = time(NULL); _timestamp_dirty = true; - // We don't support locking when opening a file in read-write mode, - // because we don't bother with locking on write. But we need to - // have an IStreamWrapper to assign to the _read member, so we - // create one on-the-fly here. + // We don't support locking when opening a file in read-write mode, because + // we don't bother with locking on write. But we need to have an + // IStreamWrapper to assign to the _read member, so we create one on-the-fly + // here. _read = new StreamWrapper(multifile_stream, owns_pointer); _write = multifile_stream; _owns_stream = true; // Because we own the StreamWrapper, above. @@ -360,31 +315,27 @@ open_read_write(iostream *multifile_stream, bool owns_pointer) { return true; } - // The read stream is not empty, so we'd better have a valid - // Multifile. + // The read stream is not empty, so we'd better have a valid Multifile. return read_index(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::close -// Access: Published -// Description: Closes the Multifile if it is open. All changes are -// flushed to disk, and the file becomes invalid for -// further operations until the next call to open(). -//////////////////////////////////////////////////////////////////// +/** + * Closes the Multifile if it is open. All changes are flushed to disk, and + * the file becomes invalid for further operations until the next call to + * open(). + */ void Multifile:: close() { if (_new_scale_factor != _scale_factor) { - // If we have changed the scale factor recently, we need to force - // a repack. + // If we have changed the scale factor recently, we need to force a + // repack. repack(); } else { flush(); } if (_owns_stream) { - // We prefer to delete the IStreamWrapper over the ostream, if - // possible. + // We prefer to delete the IStreamWrapper over the ostream, if possible. if (_read != (IStreamWrapper *)NULL) { delete _read; } else if (_write != (ostream *)NULL) { @@ -415,67 +366,54 @@ close() { clear_subfiles(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_scale_factor -// Access: Published -// Description: Changes the internal scale factor for this Multifile. -// -// This is normally 1, but it may be set to any -// arbitrary value (greater than zero) to support -// Multifile archives that exceed 4GB, if necessary. -// (Individual subfiles may still not exceed 4GB.) -// -// All addresses within the file are rounded up to the -// next multiple of _scale_factor, and zeros are written -// to the file to fill the resulting gaps. Then the -// address is divided by _scale_factor and written out -// as a 32-bit integer. Thus, setting a scale factor of -// 2 supports up to 8GB files, 3 supports 12GB files, -// etc. -// -// Calling this function on an already-existing -// Multifile will have no immediate effect until a -// future call to repack() or close() (or until the -// Multifile is destructed). -//////////////////////////////////////////////////////////////////// +/** + * Changes the internal scale factor for this Multifile. + * + * This is normally 1, but it may be set to any arbitrary value (greater than + * zero) to support Multifile archives that exceed 4GB, if necessary. + * (Individual subfiles may still not exceed 4GB.) + * + * All addresses within the file are rounded up to the next multiple of + * _scale_factor, and zeros are written to the file to fill the resulting + * gaps. Then the address is divided by _scale_factor and written out as a + * 32-bit integer. Thus, setting a scale factor of 2 supports up to 8GB + * files, 3 supports 12GB files, etc. + * + * Calling this function on an already-existing Multifile will have no + * immediate effect until a future call to repack() or close() (or until the + * Multifile is destructed). + */ void Multifile:: set_scale_factor(size_t scale_factor) { nassertv(is_write_valid()); nassertv(scale_factor != (size_t)0); if (_next_index == (streampos)0) { - // If it's a brand new Multifile, we can go ahead and set it - // immediately. + // If it's a brand new Multifile, we can go ahead and set it immediately. _scale_factor = scale_factor; } else { - // Otherwise, we'd better have read access so we can repack it - // later. + // Otherwise, we'd better have read access so we can repack it later. nassertv(is_read_valid()); } - // Setting the _new_scale_factor different from the _scale_factor - // will force a repack operation on close. + // Setting the _new_scale_factor different from the _scale_factor will force + // a repack operation on close. _new_scale_factor = scale_factor; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_subfile -// Access: Published -// Description: Adds a file on disk as a subfile to the Multifile. -// The file named by filename will be read and added to -// the Multifile at the next call to flush(). If there -// already exists a subfile with the indicated name, it -// is replaced without examining its contents (but see -// also update_subfile). -// -// Either Filename:::set_binary() or set_text() must -// have been called previously to specify the nature of -// the source file. If set_text() was called, the text -// flag will be set on the subfile. -// -// Returns the subfile name on success (it might have -// been modified slightly), or empty string on failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds a file on disk as a subfile to the Multifile. The file named by + * filename will be read and added to the Multifile at the next call to + * flush(). If there already exists a subfile with the indicated name, it is + * replaced without examining its contents (but see also update_subfile). + * + * Either Filename:::set_binary() or set_text() must have been called + * previously to specify the nature of the source file. If set_text() was + * called, the text flag will be set on the subfile. + * + * Returns the subfile name on success (it might have been modified slightly), + * or empty string on failure. + */ string Multifile:: add_subfile(const string &subfile_name, const Filename &filename, int compression_level) { @@ -509,27 +447,21 @@ add_subfile(const string &subfile_name, const Filename &filename, return name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_subfile -// Access: Public -// Description: Adds a file from a stream as a subfile to the Multifile. -// The indicated istream will be read and its contents -// added to the Multifile at the next call to flush(). -// The file will be added as a binary subfile. -// -// Note that the istream must remain untouched and -// unused by any other code until flush() is called. At -// that time, the Multifile will read the entire -// contents of the istream from the current file -// position to the end of the file. Subsequently, the -// Multifile will *not* close or delete the istream. It -// is the caller's responsibility to ensure that the -// istream pointer does not destruct during the lifetime -// of the Multifile. -// -// Returns the subfile name on success (it might have -// been modified slightly), or empty string on failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds a file from a stream as a subfile to the Multifile. The indicated + * istream will be read and its contents added to the Multifile at the next + * call to flush(). The file will be added as a binary subfile. + * + * Note that the istream must remain untouched and unused by any other code + * until flush() is called. At that time, the Multifile will read the entire + * contents of the istream from the current file position to the end of the + * file. Subsequently, the Multifile will *not* close or delete the istream. + * It is the caller's responsibility to ensure that the istream pointer does + * not destruct during the lifetime of the Multifile. + * + * Returns the subfile name on success (it might have been modified slightly), + * or empty string on failure. + */ string Multifile:: add_subfile(const string &subfile_name, istream *subfile_data, int compression_level) { @@ -546,20 +478,16 @@ add_subfile(const string &subfile_name, istream *subfile_data, return name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::update_subfile -// Access: Published -// Description: Adds a file on disk to the subfile. If a subfile -// already exists with the same name, its contents are -// compared byte-for-byte to the disk file, and it is -// replaced only if it is different; otherwise, the -// multifile is left unchanged. -// -// Either Filename:::set_binary() or set_text() must -// have been called previously to specify the nature of -// the source file. If set_text() was called, the text -// flag will be set on the subfile. -//////////////////////////////////////////////////////////////////// +/** + * Adds a file on disk to the subfile. If a subfile already exists with the + * same name, its contents are compared byte-for-byte to the disk file, and it + * is replaced only if it is different; otherwise, the multifile is left + * unchanged. + * + * Either Filename:::set_binary() or set_text() must have been called + * previously to specify the nature of the source file. If set_text() was + * called, the text flag will be set on the subfile. + */ string Multifile:: update_subfile(const string &subfile_name, const Filename &filename, int compression_level) { @@ -586,8 +514,8 @@ update_subfile(const string &subfile_name, const Filename &filename, } } - // The subfile does not already exist or it is different from the - // source file. Add the new source file. + // The subfile does not already exist or it is different from the source + // file. Add the new source file. Subfile *subfile = new Subfile; subfile->_name = name; subfile->_source_filename = fname; @@ -605,45 +533,36 @@ update_subfile(const string &subfile_name, const Filename &filename, } #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Constructor -// Access: Public -// Description: Ownership of the X509 object is passed into the -// CertRecord; it will be freed when the CertRecord -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * Ownership of the X509 object is passed into the CertRecord; it will be + * freed when the CertRecord destructs. + */ Multifile::CertRecord:: CertRecord(X509 *cert) : _cert(cert) { } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Multifile::CertRecord:: CertRecord(const Multifile::CertRecord ©) : _cert(X509_dup(copy._cert)) { } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Multifile::CertRecord:: ~CertRecord() { X509_free(_cert); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::CertRecord::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Multifile::CertRecord:: operator = (const Multifile::CertRecord &other) { X509_free(_cert); @@ -652,55 +571,46 @@ operator = (const Multifile::CertRecord &other) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_signature -// Access: Published -// Description: Adds a new signature to the Multifile. This -// signature associates the indicated certificate with -// the current contents of the Multifile. When the -// Multifile is read later, the signature will still be -// present only if the Multifile is unchanged; any -// subsequent changes to the Multifile will -// automatically invalidate and remove the signature. -// -// The chain filename may be empty if the certificate -// does not require an authenticating certificate chain -// (e.g. because it is self-signed). -// -// The specified private key must match the certificate, -// and the Multifile must be open in read-write mode. -// The private key is only used for generating the -// signature; it is not written to the Multifile and -// cannot be retrieved from the Multifile later. -// (However, the certificate *can* be retrieved from the -// Multifile later, to identify the entity that created -// the signature.) -// -// This implicitly causes a repack() operation if one is -// needed. Returns true on success, false on failure. -// -// This flavor of add_signature() reads the certificate -// and private key from a PEM-formatted file, for -// instance as generated by the openssl command. If the -// private key file is password-encrypted, the third -// parameter will be used as the password to decrypt it. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new signature to the Multifile. This signature associates the + * indicated certificate with the current contents of the Multifile. When the + * Multifile is read later, the signature will still be present only if the + * Multifile is unchanged; any subsequent changes to the Multifile will + * automatically invalidate and remove the signature. + * + * The chain filename may be empty if the certificate does not require an + * authenticating certificate chain (e.g. because it is self-signed). + * + * The specified private key must match the certificate, and the Multifile + * must be open in read-write mode. The private key is only used for + * generating the signature; it is not written to the Multifile and cannot be + * retrieved from the Multifile later. (However, the certificate *can* be + * retrieved from the Multifile later, to identify the entity that created the + * signature.) + * + * This implicitly causes a repack() operation if one is needed. Returns true + * on success, false on failure. + * + * This flavor of add_signature() reads the certificate and private key from a + * PEM-formatted file, for instance as generated by the openssl command. If + * the private key file is password-encrypted, the third parameter will be + * used as the password to decrypt it. + */ bool Multifile:: add_signature(const Filename &certificate, const Filename &chain, const Filename &pkey, const string &password) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); if (chain.empty() && pkey.empty()) { - // If the second two filenames are empty, assume we're going for - // the composite mode, where everything's stuffed into the first - // file. + // If the second two filenames are empty, assume we're going for the + // composite mode, where everything's stuffed into the first file. return add_signature(certificate, password); } CertChain cert_chain; - // Read the certificate file from VFS. First, read the complete - // file into memory. + // Read the certificate file from VFS. First, read the complete file into + // memory. string certificate_data; if (!vfs->read_file(certificate, certificate_data, true)) { express_cat.info() @@ -718,8 +628,8 @@ add_signature(const Filename &certificate, const Filename &chain, return false; } - // Store the first X509--the actual certificate--as the first record - // in our CertChain object. + // Store the first X509--the actual certificate--as the first record in our + // CertChain object. cert_chain.push_back(CertRecord(x509)); // Read the rest of the certificates in the chain file. @@ -746,8 +656,8 @@ add_signature(const Filename &certificate, const Filename &chain, } } - // Now do the same thing with the private key. This one may be - // password-encrypted on disk. + // Now do the same thing with the private key. This one may be password- + // encrypted on disk. string pkey_data; if (!vfs->read_file(pkey, pkey_data, true)) { express_cat.info() @@ -774,25 +684,19 @@ add_signature(const Filename &certificate, const Filename &chain, #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_signature -// Access: Published -// Description: Adds a new signature to the Multifile. This -// signature associates the indicated certificate with -// the current contents of the Multifile. When the -// Multifile is read later, the signature will still be -// present only if the Multifile is unchanged; any -// subsequent changes to the Multifile will -// automatically invalidate and remove the signature. -// -// This flavor of add_signature() reads the certificate, -// private key, and certificate chain from the same -// PEM-formatted file. It takes the first private key -// found as the intended key, and then uses the first -// certificate found that matches that key as the -// signing certificate. Any other certificates in the -// file are taken to be part of the chain. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new signature to the Multifile. This signature associates the + * indicated certificate with the current contents of the Multifile. When the + * Multifile is read later, the signature will still be present only if the + * Multifile is unchanged; any subsequent changes to the Multifile will + * automatically invalidate and remove the signature. + * + * This flavor of add_signature() reads the certificate, private key, and + * certificate chain from the same PEM-formatted file. It takes the first + * private key found as the intended key, and then uses the first certificate + * found that matches that key as the signing certificate. Any other + * certificates in the file are taken to be part of the chain. + */ bool Multifile:: add_signature(const Filename &composite, const string &password) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -833,8 +737,8 @@ add_signature(const Filename &composite, const string &password) { return false; } - // Now find the certificate that matches the signature, and move it - // to the front of the chain. + // Now find the certificate that matches the signature, and move it to the + // front of the chain. size_t i; bool found_match = false; for (i = 0; i < cert_chain.size(); ++i) { @@ -865,36 +769,29 @@ add_signature(const Filename &composite, const string &password) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_signature -// Access: Published -// Description: Adds a new signature to the Multifile. This -// signature associates the indicated certificate with -// the current contents of the Multifile. When the -// Multifile is read later, the signature will still be -// present only if the Multifile is unchanged; any -// subsequent changes to the Multifile will -// automatically invalidate and remove the signature. -// -// If chain is non-NULL, it represents the certificate -// chain that validates the certificate. -// -// The specified private key must match the certificate, -// and the Multifile must be open in read-write mode. -// The private key is only used for generating the -// signature; it is not written to the Multifile and -// cannot be retrieved from the Multifile later. -// (However, the certificate *can* be retrieved from the -// Multifile later, to identify the entity that created -// the signature.) -// -// This implicitly causes a repack() operation if one is -// needed. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new signature to the Multifile. This signature associates the + * indicated certificate with the current contents of the Multifile. When the + * Multifile is read later, the signature will still be present only if the + * Multifile is unchanged; any subsequent changes to the Multifile will + * automatically invalidate and remove the signature. + * + * If chain is non-NULL, it represents the certificate chain that validates + * the certificate. + * + * The specified private key must match the certificate, and the Multifile + * must be open in read-write mode. The private key is only used for + * generating the signature; it is not written to the Multifile and cannot be + * retrieved from the Multifile later. (However, the certificate *can* be + * retrieved from the Multifile later, to identify the entity that created the + * signature.) + * + * This implicitly causes a repack() operation if one is needed. Returns true + * on success, false on failure. + */ bool Multifile:: add_signature(X509 *certificate, STACK_OF(X509) *chain, EVP_PKEY *pkey) { - // Convert the certificate and chain into our own CertChain - // structure. + // Convert the certificate and chain into our own CertChain structure. CertChain cert_chain; cert_chain.push_back(CertRecord(certificate)); if (chain != NULL) { @@ -909,33 +806,27 @@ add_signature(X509 *certificate, STACK_OF(X509) *chain, EVP_PKEY *pkey) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_signature -// Access: Published -// Description: Adds a new signature to the Multifile. This -// signature associates the indicated certificate with -// the current contents of the Multifile. When the -// Multifile is read later, the signature will still be -// present only if the Multifile is unchanged; any -// subsequent changes to the Multifile will -// automatically invalidate and remove the signature. -// -// The signature certificate is the first certificate on -// the CertChain object. Any remaining certificates are -// support certificates to authenticate the first one. -// -// The specified private key must match the certificate, -// and the Multifile must be open in read-write mode. -// The private key is only used for generating the -// signature; it is not written to the Multifile and -// cannot be retrieved from the Multifile later. -// (However, the certificate *can* be retrieved from the -// Multifile later, to identify the entity that created -// the signature.) -// -// This implicitly causes a repack() operation if one is -// needed. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new signature to the Multifile. This signature associates the + * indicated certificate with the current contents of the Multifile. When the + * Multifile is read later, the signature will still be present only if the + * Multifile is unchanged; any subsequent changes to the Multifile will + * automatically invalidate and remove the signature. + * + * The signature certificate is the first certificate on the CertChain object. + * Any remaining certificates are support certificates to authenticate the + * first one. + * + * The specified private key must match the certificate, and the Multifile + * must be open in read-write mode. The private key is only used for + * generating the signature; it is not written to the Multifile and cannot be + * retrieved from the Multifile later. (However, the certificate *can* be + * retrieved from the Multifile later, to identify the entity that created the + * signature.) + * + * This implicitly causes a repack() operation if one is needed. Returns true + * on success, false on failure. + */ bool Multifile:: add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { if (_needs_repack) { @@ -990,9 +881,8 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { subfile->_flags |= SF_signature; subfile->_source = &der_stream; - // Write the new Subfile at the end. The cert_special subfiles - // always go at the end, because they're not the part of the file - // that's signed. + // Write the new Subfile at the end. The cert_special subfiles always go at + // the end, because they're not the part of the file that's signed. nassertr(_new_subfiles.empty(), false); _new_subfiles.push_back(subfile); bool result = flush(); @@ -1004,22 +894,17 @@ add_signature(const Multifile::CertChain &cert_chain, EVP_PKEY *pkey) { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_num_signatures -// Access: Published -// Description: Returns the number of matching signatures found on -// the Multifile. These signatures may be iterated via -// get_signature() and related methods. -// -// A signature on this list is guaranteed to match the -// Multifile contents, proving that the Multifile has -// been unmodified since the signature was applied. -// However, this does not guarantee that the certificate -// itself is actually from who it says it is from; only -// that it matches the Multifile contents. See -// validate_signature_certificate() to authenticate a -// particular certificate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of matching signatures found on the Multifile. These + * signatures may be iterated via get_signature() and related methods. + * + * A signature on this list is guaranteed to match the Multifile contents, + * proving that the Multifile has been unmodified since the signature was + * applied. However, this does not guarantee that the certificate itself is + * actually from who it says it is from; only that it matches the Multifile + * contents. See validate_signature_certificate() to authenticate a + * particular certificate. + */ int Multifile:: get_num_signatures() const { ((Multifile *)this)->check_signatures(); @@ -1028,12 +913,10 @@ get_num_signatures() const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_signature -// Access: Published -// Description: Returns the nth signature found on the Multifile. -// See the comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth signature found on the Multifile. See the comments in + * get_num_signatures(). + */ const Multifile::CertChain &Multifile:: get_signature(int n) const { ((Multifile *)this)->check_signatures(); @@ -1044,17 +927,13 @@ get_signature(int n) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_signature_subject_name -// Access: Published -// Description: Returns the "subject name" for the nth signature found -// on the Multifile. This is a string formatted -// according to RFC2253 that should more-or-less -// identify a particular certificate; when paired with -// the public key (see get_signature_public_key()), it -// can uniquely identify a certificate. See the -// comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "subject name" for the nth signature found on the Multifile. + * This is a string formatted according to RFC2253 that should more-or-less + * identify a particular certificate; when paired with the public key (see + * get_signature_public_key()), it can uniquely identify a certificate. See + * the comments in get_num_signatures(). + */ string Multifile:: get_signature_subject_name(int n) const { const CertChain &cert_chain = get_signature(n); @@ -1062,9 +941,8 @@ get_signature_subject_name(int n) const { X509_NAME *xname = X509_get_subject_name(cert_chain[0]._cert); if (xname != NULL) { - // We use "print" to dump the output to a memory BIO. Is - // there an easier way to extract the X509_NAME text? Curse - // these incomplete docs. + // We use "print" to dump the output to a memory BIO. Is there an easier + // way to extract the X509_NAME text? Curse these incomplete docs. BIO *mbio = BIO_new(BIO_s_mem()); X509_NAME_print_ex(mbio, xname, 0, XN_FLAG_RFC2253); @@ -1080,17 +958,14 @@ get_signature_subject_name(int n) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_signature_friendly_name -// Access: Published -// Description: Returns a "friendly name" for the nth signature found -// on the Multifile. This attempts to extract out the -// most meaningful part of the subject name. It returns -// the emailAddress, if it is defined; otherwise, it -// returns the commonName. -// -// See the comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a "friendly name" for the nth signature found on the Multifile. + * This attempts to extract out the most meaningful part of the subject name. + * It returns the emailAddress, if it is defined; otherwise, it returns the + * commonName. + * + * See the comments in get_num_signatures(). + */ string Multifile:: get_signature_friendly_name(int n) const { const CertChain &cert_chain = get_signature(n); @@ -1112,15 +987,15 @@ get_signature_friendly_name(int n) const { if (xname != NULL) { int pos = X509_NAME_get_index_by_NID(xname, nid, -1); if (pos != -1) { - // We just get the first common name. I guess it's possible to - // have more than one; not sure what that means in this context. + // We just get the first common name. I guess it's possible to have + // more than one; not sure what that means in this context. X509_NAME_ENTRY *xentry = X509_NAME_get_entry(xname, pos); if (xentry != NULL) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(xentry); if (data != NULL) { - // We use "print" to dump the output to a memory BIO. Is - // there an easier way to decode the ASN1_STRING? Curse - // these incomplete docs. + // We use "print" to dump the output to a memory BIO. Is there an + // easier way to decode the ASN1_STRING? Curse these incomplete + // docs. BIO *mbio = BIO_new(BIO_s_mem()); ASN1_STRING_print_ex(mbio, data, ASN1_STRFLGS_RFC2253 & ~ASN1_STRFLGS_ESC_MSB); @@ -1140,18 +1015,15 @@ get_signature_friendly_name(int n) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_signature_public_key -// Access: Published -// Description: Returns the public key used for the nth signature -// found on the Multifile. This is encoded in DER form -// and returned as a string of hex digits. -// -// This can be used, in conjunction with the subject -// name (see get_signature_subject_name()), to uniquely -// identify a particular certificate and its subsequent -// reissues. See the comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the public key used for the nth signature found on the Multifile. + * This is encoded in DER form and returned as a string of hex digits. + * + * This can be used, in conjunction with the subject name (see + * get_signature_subject_name()), to uniquely identify a particular + * certificate and its subsequent reissues. See the comments in + * get_num_signatures(). + */ string Multifile:: get_signature_public_key(int n) const { const CertChain &cert_chain = get_signature(n); @@ -1177,13 +1049,10 @@ get_signature_public_key(int n) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::print_signature_certificate -// Access: Published -// Description: Writes the certificate for the nth signature, in -// user-readable verbose form, to the indicated stream. -// See the comments in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the certificate for the nth signature, in user-readable verbose + * form, to the indicated stream. See the comments in get_num_signatures(). + */ void Multifile:: print_signature_certificate(int n, ostream &out) const { const CertChain &cert_chain = get_signature(n); @@ -1200,13 +1069,10 @@ print_signature_certificate(int n, ostream &out) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::write_signature_certificate -// Access: Published -// Description: Writes the certificate for the nth signature, in -// PEM form, to the indicated stream. See the comments -// in get_num_signatures(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the certificate for the nth signature, in PEM form, to the indicated + * stream. See the comments in get_num_signatures(). + */ void Multifile:: write_signature_certificate(int n, ostream &out) const { const CertChain &cert_chain = get_signature(n); @@ -1229,16 +1095,12 @@ write_signature_certificate(int n, ostream &out) const { #endif // HAVE_OPENSSL #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::validate_signature_certificate -// Access: Published -// Description: Checks that the certificate used for the nth -// signature is a valid, authorized certificate with -// some known certificate authority. Returns 0 if it -// is valid, -1 if there is some error, or the -// corresponding OpenSSL error code if it is invalid, -// out-of-date, or self-signed. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the certificate used for the nth signature is a valid, + * authorized certificate with some known certificate authority. Returns 0 if + * it is valid, -1 if there is some error, or the corresponding OpenSSL error + * code if it is invalid, out-of-date, or self-signed. + */ int Multifile:: validate_signature_certificate(int n) const { int verify_result = -1; @@ -1248,8 +1110,8 @@ validate_signature_certificate(int n) const { OpenSSLWrapper *sslw = OpenSSLWrapper::get_global_ptr(); - // Copy our CertChain structure into an X509 pointer and - // accompanying STACK_OF(X509) pointer. + // Copy our CertChain structure into an X509 pointer and accompanying + // STACK_OF(X509) pointer. X509 *x509 = chain[0]._cert; STACK_OF(X509) *stack = NULL; if (chain.size() > 1) { @@ -1284,27 +1146,21 @@ validate_signature_certificate(int n) const { } #endif // HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: Multifile::flush -// Access: Published -// Description: Writes all contents of the Multifile to disk. Until -// flush() is called, add_subfile() and remove_subfile() -// do not actually do anything to disk. At this point, -// all of the recently-added subfiles are read and their -// contents are added to the end of the Multifile, and -// the recently-removed subfiles are marked gone from -// the Multifile. -// -// This may result in a suboptimal index. To guarantee -// that the index is written at the beginning of the -// file, call repack() instead of flush(). -// -// It is not necessary to call flush() explicitly unless -// you are concerned about reading the recently-added -// subfiles immediately. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes all contents of the Multifile to disk. Until flush() is called, + * add_subfile() and remove_subfile() do not actually do anything to disk. At + * this point, all of the recently-added subfiles are read and their contents + * are added to the end of the Multifile, and the recently-removed subfiles + * are marked gone from the Multifile. + * + * This may result in a suboptimal index. To guarantee that the index is + * written at the beginning of the file, call repack() instead of flush(). + * + * It is not necessary to call flush() explicitly unless you are concerned + * about reading the recently-added subfiles immediately. + * + * Returns true on success, false on failure. + */ bool Multifile:: flush() { if (!is_write_valid()) { @@ -1313,8 +1169,8 @@ flush() { bool new_file = (_next_index == (streampos)0); if (new_file) { - // If we don't have an index yet, we don't have a header. Write - // the header. + // If we don't have an index yet, we don't have a header. Write the + // header. if (!write_header()) { return false; } @@ -1341,8 +1197,8 @@ flush() { bool wrote_ok = true; if (!_new_subfiles.empty() || new_file) { - // Add a few more files to the end. We always add subfiles at the - // end of the multifile, so go there first. + // Add a few more files to the end. We always add subfiles at the end of + // the multifile, so go there first. sort(_new_subfiles.begin(), _new_subfiles.end(), IndirectLess()); if (_last_index != (streampos)0) { _write->seekp(0, ios::end); @@ -1354,8 +1210,8 @@ flush() { _next_index = _write->tellp(); _next_index = pad_to_streampos(_next_index); - // And update the forward link from the last_index to point to - // this new index location. + // And update the forward link from the last_index to point to this new + // index location. _write->seekp(_last_index); StreamWriter writer(_write, false); writer.add_uint32(streampos_to_word(_next_index)); @@ -1364,8 +1220,8 @@ flush() { _write->seekp(_next_index); nassertr(_next_index == _write->tellp(), false); - // Ok, here we are at the end of the file. Write out the - // recently-added subfiles here. First, count up the index size. + // Ok, here we are at the end of the file. Write out the recently-added + // subfiles here. First, count up the index size. for (pi = _new_subfiles.begin(); pi != _new_subfiles.end(); ++pi) { Subfile *subfile = (*pi); _last_index = _next_index; @@ -1375,8 +1231,7 @@ flush() { nassertr(_next_index == _write->tellp(), false); } - // Now we're at the end of the index. Write a 0 here to mark the - // end. + // Now we're at the end of the index. Write a 0 here to mark the end. StreamWriter writer(_write, false); writer.add_uint32(0); _next_index += 4; @@ -1409,10 +1264,10 @@ flush() { nassertr(_next_index == _write->tellp(), false); } - // Now go back and fill in the proper addresses for the data start. - // We didn't do it in the first pass, because we don't really want - // to keep all those file handles open, and so we didn't have to - // determine each file's length ahead of time. + // Now go back and fill in the proper addresses for the data start. We + // didn't do it in the first pass, because we don't really want to keep + // all those file handles open, and so we didn't have to determine each + // file's length ahead of time. for (pi = _new_subfiles.begin(); pi != _new_subfiles.end(); ++pi) { Subfile *subfile = (*pi); subfile->rewrite_index_data_start(*_write, this); @@ -1448,29 +1303,23 @@ flush() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::repack -// Access: Published -// Description: Forces a complete rewrite of the Multifile and all of -// its contents, so that its index will appear at the -// beginning of the file with all of the subfiles listed -// in alphabetical order. This is considered optimal -// for reading, and is the standard configuration; but -// it is not essential to do this. -// -// It is only valid to call this if the Multifile was -// opened using open_read_write() and an explicit -// filename, rather than an iostream. Also, we must -// have write permission to the directory containing the -// Multifile. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Forces a complete rewrite of the Multifile and all of its contents, so that + * its index will appear at the beginning of the file with all of the subfiles + * listed in alphabetical order. This is considered optimal for reading, and + * is the standard configuration; but it is not essential to do this. + * + * It is only valid to call this if the Multifile was opened using + * open_read_write() and an explicit filename, rather than an iostream. Also, + * we must have write permission to the directory containing the Multifile. + * + * Returns true on success, false on failure. + */ bool Multifile:: repack() { if (_next_index == (streampos)0) { - // If the Multifile hasn't yet been written, this is really just a - // flush operation. + // If the Multifile hasn't yet been written, this is really just a flush + // operation. _needs_repack = false; return flush(); } @@ -1492,8 +1341,8 @@ repack() { return false; } - // Now we scrub our internal structures so it looks like we're a - // brand new Multifile. + // Now we scrub our internal structures so it looks like we're a brand new + // Multifile. PendingSubfiles::iterator pi; for (pi = _removed_subfiles.begin(); pi != _removed_subfiles.end(); ++pi) { Subfile *subfile = (*pi); @@ -1515,8 +1364,8 @@ repack() { return false; } - // Now close everything, and move the temporary file back over our - // original file. + // Now close everything, and move the temporary file back over our original + // file. Filename orig_name = _multifile_name; temp.close(); close(); @@ -1538,25 +1387,20 @@ repack() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_num_subfiles -// Access: Published -// Description: Returns the number of subfiles within the Multifile. -// The subfiles may be accessed in alphabetical order by -// iterating through [0 .. get_num_subfiles()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subfiles within the Multifile. The subfiles may be + * accessed in alphabetical order by iterating through [0 .. + * get_num_subfiles()). + */ int Multifile:: get_num_subfiles() const { return _subfiles.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::find_subfile -// Access: Published -// Description: Returns the index of the subfile with the indicated -// name, or -1 if the named subfile is not within the -// Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the subfile with the indicated name, or -1 if the + * named subfile is not within the Multifile. + */ int Multifile:: find_subfile(const string &subfile_name) const { Subfile find_subfile; @@ -1570,14 +1414,11 @@ find_subfile(const string &subfile_name) const { return (fi - _subfiles.begin()); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::has_directory -// Access: Published -// Description: Returns true if the indicated subfile name is the -// directory prefix to one or more files within the -// Multifile. That is, the Multifile contains at least -// one file named "subfile_name/...". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated subfile name is the directory prefix to one + * or more files within the Multifile. That is, the Multifile contains at + * least one file named "subfile_name/...". + */ bool Multifile:: has_directory(const string &subfile_name) const { string prefix = subfile_name; @@ -1600,21 +1441,16 @@ has_directory(const string &subfile_name) const { subfile->_name.substr(0, prefix.length()) == prefix); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::scan_directory -// Access: Published -// Description: Considers subfile_name to be the name of a -// subdirectory within the Multifile, but not a file -// itself; fills the given vector up with the sorted list -// of subdirectories or files within the named -// directory. -// -// Note that directories do not exist explicitly within -// a Multifile; this just checks for the existence of -// files with the given initial prefix. -// -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Considers subfile_name to be the name of a subdirectory within the + * Multifile, but not a file itself; fills the given vector up with the sorted + * list of subdirectories or files within the named directory. + * + * Note that directories do not exist explicitly within a Multifile; this just + * checks for the existence of files with the given initial prefix. + * + * Returns true if successful, false otherwise. + */ bool Multifile:: scan_directory(vector_string &contents, const string &subfile_name) const { string prefix = subfile_name; @@ -1631,8 +1467,8 @@ scan_directory(vector_string &contents, const string &subfile_name) const { Subfile *subfile = (*fi); if (!(subfile->_name.length() > prefix.length() && subfile->_name.substr(0, prefix.length()) == prefix)) { - // We've reached the end of the list of subfiles beneath the - // indicated directory prefix. + // We've reached the end of the list of subfiles beneath the indicated + // directory prefix. return true; } @@ -1648,20 +1484,15 @@ scan_directory(vector_string &contents, const string &subfile_name) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::remove_subfile -// Access: Published -// Description: Removes the nth subfile from the Multifile. This -// will cause all subsequent index numbers to decrease -// by one. The file will not actually be removed from -// the disk until the next call to flush(). -// -// Note that this does not actually remove the data from -// the indicated subfile; it simply removes it from the -// index. The Multifile will not be reduced in size -// after this operation, until the next call to -// repack(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth subfile from the Multifile. This will cause all subsequent + * index numbers to decrease by one. The file will not actually be removed + * from the disk until the next call to flush(). + * + * Note that this does not actually remove the data from the indicated + * subfile; it simply removes it from the index. The Multifile will not be + * reduced in size after this operation, until the next call to repack(). + */ void Multifile:: remove_subfile(int index) { nassertv(is_write_valid()); @@ -1677,11 +1508,9 @@ remove_subfile(int index) { _needs_repack = true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_subfile_name -// Access: Published -// Description: Returns the name of the nth subfile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth subfile. + */ const string &Multifile:: get_subfile_name(int index) const { #ifndef NDEBUG @@ -1691,30 +1520,23 @@ get_subfile_name(int index) const { return _subfiles[index]->_name; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_subfile_length -// Access: Published -// Description: Returns the uncompressed data length of the nth -// subfile. This might return 0 if the subfile has -// recently been added and flush() has not yet been -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the uncompressed data length of the nth subfile. This might return + * 0 if the subfile has recently been added and flush() has not yet been + * called. + */ size_t Multifile:: get_subfile_length(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), 0); return _subfiles[index]->_uncompressed_length; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_subfile_timestamp -// Access: Published -// Description: Returns the modification time of the nth -// subfile. If this is called on an older .mf file, -// which did not store individual timestamps in the file -// (or if get_record_timestamp() is false), this will -// return the modification time of the overall -// multifile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the modification time of the nth subfile. If this is called on an + * older .mf file, which did not store individual timestamps in the file (or + * if get_record_timestamp() is false), this will return the modification time + * of the overall multifile. + */ time_t Multifile:: get_subfile_timestamp(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), 0); @@ -1725,124 +1547,96 @@ get_subfile_timestamp(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::is_subfile_compressed -// Access: Published -// Description: Returns true if the indicated subfile has been -// compressed when stored within the archive, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated subfile has been compressed when stored + * within the archive, false otherwise. + */ bool Multifile:: is_subfile_compressed(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), false); return (_subfiles[index]->_flags & SF_compressed) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::is_subfile_encrypted -// Access: Published -// Description: Returns true if the indicated subfile has been -// encrypted when stored within the archive, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated subfile has been encrypted when stored within + * the archive, false otherwise. + */ bool Multifile:: is_subfile_encrypted(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), false); return (_subfiles[index]->_flags & SF_encrypted) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::is_subfile_text -// Access: Published -// Description: Returns true if the indicated subfile represents text -// data, or false if it represents binary data. If the -// file is text data, it may have been processed by -// end-of-line conversion when it was added. (But the -// actual bits in the multifile will represent the -// standard Unix end-of-line convention, e.g. \n instead -// of \r\n.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated subfile represents text data, or false if it + * represents binary data. If the file is text data, it may have been + * processed by end-of-line conversion when it was added. (But the actual + * bits in the multifile will represent the standard Unix end-of-line + * convention, e.g. \n instead of \r\n.) + */ bool Multifile:: is_subfile_text(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), false); return (_subfiles[index]->_flags & SF_text) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_index_end -// Access: Published -// Description: Returns the first byte that is guaranteed to follow -// any index byte already written to disk in the -// Multifile. -// -// This number is largely meaningless in many cases, but -// if needs_repack() is false, and the file is flushed, -// this will indicate the number of bytes in the header -// + index. Everything at this byte position and later -// will be actual data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first byte that is guaranteed to follow any index byte already + * written to disk in the Multifile. + * + * This number is largely meaningless in many cases, but if needs_repack() is + * false, and the file is flushed, this will indicate the number of bytes in + * the header + index. Everything at this byte position and later will be + * actual data. + */ streampos Multifile:: get_index_end() const { return normalize_streampos(_next_index + (streampos)4); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_subfile_internal_start -// Access: Published -// Description: Returns the starting byte position within the -// Multifile at which the indicated subfile begins. -// This may be used, with get_subfile_internal_length(), -// for low-level access to the subfile, but usually it -// is better to use open_read_subfile() instead (which -// automatically decrypts and/or uncompresses the -// subfile data). -//////////////////////////////////////////////////////////////////// +/** + * Returns the starting byte position within the Multifile at which the + * indicated subfile begins. This may be used, with + * get_subfile_internal_length(), for low-level access to the subfile, but + * usually it is better to use open_read_subfile() instead (which + * automatically decrypts and/or uncompresses the subfile data). + */ streampos Multifile:: get_subfile_internal_start(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), 0); return _subfiles[index]->_data_start; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::get_subfile_internal_length -// Access: Published -// Description: Returns the number of bytes the indicated subfile -// consumes within the archive. For compressed -// subfiles, this will generally be smaller than -// get_subfile_length(); for encrypted (but -// noncompressed) subfiles, it may be slightly -// different, for noncompressed and nonencrypted -// subfiles, it will be equal. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes the indicated subfile consumes within the + * archive. For compressed subfiles, this will generally be smaller than + * get_subfile_length(); for encrypted (but noncompressed) subfiles, it may be + * slightly different, for noncompressed and nonencrypted subfiles, it will be + * equal. + */ size_t Multifile:: get_subfile_internal_length(int index) const { nassertr(index >= 0 && index < (int)_subfiles.size(), 0); return _subfiles[index]->_data_length; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read_subfile -// Access: Published -// Description: Returns an istream that may be used to read the -// indicated subfile. You may seek() within this -// istream to your heart's content; even though it will -// be a reference to the already-opened pfstream of the -// Multifile itself, byte 0 appears to be the beginning -// of the subfile and EOF appears to be the end of the -// subfile. -// -// The returned istream will have been allocated via -// new; you should pass the pointer to -// close_read_subfile() when you are finished with it to -// delete it and release its resources. -// -// Any future calls to repack() or close() (or the -// Multifile destructor) will invalidate all currently -// open subfile pointers. -// -// The return value will be NULL if the stream cannot be -// opened for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns an istream that may be used to read the indicated subfile. You may + * seek() within this istream to your heart's content; even though it will be + * a reference to the already-opened pfstream of the Multifile itself, byte 0 + * appears to be the beginning of the subfile and EOF appears to be the end of + * the subfile. + * + * The returned istream will have been allocated via new; you should pass the + * pointer to close_read_subfile() when you are finished with it to delete it + * and release its resources. + * + * Any future calls to repack() or close() (or the Multifile destructor) will + * invalidate all currently open subfile pointers. + * + * The return value will be NULL if the stream cannot be opened for some + * reason. + */ istream *Multifile:: open_read_subfile(int index) { nassertr(is_read_valid(), NULL); @@ -1851,34 +1645,30 @@ open_read_subfile(int index) { if (subfile->_source != (istream *)NULL || !subfile->_source_filename.empty()) { - // The subfile has not yet been copied into the physical - // Multifile. Force a flush operation to incorporate it. + // The subfile has not yet been copied into the physical Multifile. Force + // a flush operation to incorporate it. flush(); - // That shouldn't change the subfile index or delete the subfile - // pointer. + // That shouldn't change the subfile index or delete the subfile pointer. nassertr(subfile == _subfiles[index], NULL); } return open_read_subfile(subfile); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::close_read_subfile -// Access: Published, Static -// Description: Closes a file opened by a previous call to -// open_read_subfile(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_subfile(). This + * really just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void Multifile:: close_read_subfile(istream *stream) { if (stream != (istream *)NULL) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~istream(); (*global_operator_delete)(stream); @@ -1888,12 +1678,9 @@ close_read_subfile(istream *stream) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::extract_subfile -// Access: Published -// Description: Extracts the nth subfile into a file with the given -// name. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the nth subfile into a file with the given name. + */ bool Multifile:: extract_subfile(int index, const Filename &filename) { nassertr(is_read_valid(), false); @@ -1905,8 +1692,8 @@ extract_subfile(int index, const Filename &filename) { } if (!fname.is_binary_or_text()) { - // If we haven't specified binary or text, infer it from the type - // of the subfile. + // If we haven't specified binary or text, infer it from the type of the + // subfile. if ((_subfiles[index]->_flags & SF_text) != 0) { fname.set_text(); } else { @@ -1924,11 +1711,9 @@ extract_subfile(int index, const Filename &filename) { return extract_subfile_to(index, out); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::extract_subfile_to -// Access: Public -// Description: Extracts the nth subfile to the indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the nth subfile to the indicated ostream. + */ bool Multifile:: extract_subfile_to(int index, ostream &out) { nassertr(is_read_valid(), false); @@ -1957,21 +1742,16 @@ extract_subfile_to(int index, ostream &out) { return (!out.fail()); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::compare_subfile -// Access: Published -// Description: Performs a byte-for-byte comparison of the indicated -// file on disk with the nth subfile. Returns true if -// the files are equivalent, or false if they are -// different (or the file is missing). -// -// If Filename::set_binary() or set_text() has already -// been called, it specifies the nature of the source -// file. If this is different from the text flag of the -// subfile, the comparison will always return false. -// If this has not been specified, it will be set from -// the text flag of the subfile. -//////////////////////////////////////////////////////////////////// +/** + * Performs a byte-for-byte comparison of the indicated file on disk with the + * nth subfile. Returns true if the files are equivalent, or false if they + * are different (or the file is missing). + * + * If Filename::set_binary() or set_text() has already been called, it + * specifies the nature of the source file. If this is different from the + * text flag of the subfile, the comparison will always return false. If this + * has not been specified, it will be set from the text flag of the subfile. + */ bool Multifile:: compare_subfile(int index, const Filename &filename) { nassertr(is_read_valid(), false); @@ -1985,8 +1765,7 @@ compare_subfile(int index, const Filename &filename) { Filename fname = filename; if (fname.is_binary()) { - // If we've specified a binary file, it had better be a binary - // subfile. + // If we've specified a binary file, it had better be a binary subfile. if ((_subfiles[index]->_flags & SF_text) != 0) { if (express_cat.is_debug()) { express_cat.debug() @@ -1996,8 +1775,7 @@ compare_subfile(int index, const Filename &filename) { } } else if (fname.is_text()) { - // If we've specified a text file, it had better be a text - // subfile. + // If we've specified a text file, it had better be a text subfile. if ((_subfiles[index]->_flags & SF_text) == 0) { if (express_cat.is_debug()) { express_cat.debug() @@ -2007,8 +1785,8 @@ compare_subfile(int index, const Filename &filename) { } } else { - // If we haven't specified binary or text, infer it from the type - // of the subfile. + // If we haven't specified binary or text, infer it from the type of the + // subfile. if ((_subfiles[index]->_flags & SF_text) != 0) { fname.set_text(); } else { @@ -2063,22 +1841,18 @@ compare_subfile(int index, const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Multifile:: output(ostream &out) const { out << "Multifile " << _multifile_name << ", " << get_num_subfiles() << " subfiles.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::ls -// Access: Published -// Description: Shows a list of all subfiles within the Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Shows a list of all subfiles within the Multifile. + */ void Multifile:: ls(ostream &out) const { int num_subfiles = get_num_subfiles(); @@ -2088,25 +1862,19 @@ ls(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::set_header_prefix -// Access: Published -// Description: Sets the string which is written to the Multifile -// before the Multifile header. This string must begin -// with a hash mark and end with a newline character; -// and if it includes embedded newline characters, each -// one must be followed by a hash mark. If these -// conditions are not initially true, the string will be -// modified as necessary to make it so. -// -// This is primarily useful as a simple hack to allow -// p3d applications to be run directly from the command -// line on Unix-like systems. -// -// The return value is true if successful, or false on -// failure (for instance, because the header prefix -// violates the above rules). -//////////////////////////////////////////////////////////////////// +/** + * Sets the string which is written to the Multifile before the Multifile + * header. This string must begin with a hash mark and end with a newline + * character; and if it includes embedded newline characters, each one must be + * followed by a hash mark. If these conditions are not initially true, the + * string will be modified as necessary to make it so. + * + * This is primarily useful as a simple hack to allow p3d applications to be + * run directly from the command line on Unix-like systems. + * + * The return value is true if successful, or false on failure (for instance, + * because the header prefix violates the above rules). + */ void Multifile:: set_header_prefix(const string &header_prefix) { string new_header_prefix = header_prefix; @@ -2139,19 +1907,16 @@ set_header_prefix(const string &header_prefix) { } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::read_subfile -// Access: Public -// Description: Fills a string with the entire contents of -// the indicated subfile. -//////////////////////////////////////////////////////////////////// +/** + * Fills a string with the entire contents of the indicated subfile. + */ bool Multifile:: read_subfile(int index, string &result) { result = string(); - // We use a temporary pvector, because dynamic accumulation of a - // pvector seems to be many times faster than that of a string, at - // least on the Windows implementation of STL. + // We use a temporary pvector, because dynamic accumulation of a pvector + // seems to be many times faster than that of a string, at least on the + // Windows implementation of STL. pvector pv; if (!read_subfile(index, pv)) { return false; @@ -2164,12 +1929,9 @@ read_subfile(int index, string &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::read_subfile -// Access: Public -// Description: Fills a pvector with the entire contents of -// the indicated subfile. -//////////////////////////////////////////////////////////////////// +/** + * Fills a pvector with the entire contents of the indicated subfile. + */ bool Multifile:: read_subfile(int index, pvector &result) { nassertr(is_read_valid(), false); @@ -2183,12 +1945,11 @@ read_subfile(int index, pvector &result) { if (subfile->_source != (istream *)NULL || !subfile->_source_filename.empty()) { - // The subfile has not yet been copied into the physical - // Multifile. Force a flush operation to incorporate it. + // The subfile has not yet been copied into the physical Multifile. Force + // a flush operation to incorporate it. flush(); - // That shouldn't change the subfile index or delete the subfile - // pointer. + // That shouldn't change the subfile index or delete the subfile pointer. nassertr(subfile == _subfiles[index], false); } @@ -2196,8 +1957,8 @@ read_subfile(int index, pvector &result) { bool success = true; if (subfile->_flags & (SF_encrypted | SF_compressed)) { - // If the subfile is encrypted or compressed, we can't read it - // directly. Fall back to the generic implementation. + // If the subfile is encrypted or compressed, we can't read it directly. + // Fall back to the generic implementation. istream *in = open_read_subfile(index); if (in == (istream *)NULL) { return false; @@ -2207,9 +1968,8 @@ read_subfile(int index, pvector &result) { close_read_subfile(in); } else { - // But if the subfile is just a plain file, we can just read the - // data directly from the Multifile, without paying the cost of an - // ISubStream. + // But if the subfile is just a plain file, we can just read the data + // directly from the Multifile, without paying the cost of an ISubStream. static const size_t buffer_size = 4096; char buffer[buffer_size]; @@ -2245,15 +2005,11 @@ read_subfile(int index, pvector &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::pad_to_streampos -// Access: Private -// Description: Assumes the _write pointer is at the indicated fpos, -// rounds the fpos up to the next legitimate address -// (using normalize_streampos()), and writes enough -// zeroes to the stream to fill the gap. Returns the -// new fpos. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the _write pointer is at the indicated fpos, rounds the fpos up to + * the next legitimate address (using normalize_streampos()), and writes + * enough zeroes to the stream to fill the gap. Returns the new fpos. + */ streampos Multifile:: pad_to_streampos(streampos fpos) { nassertr(_write != (ostream *)NULL, fpos); @@ -2267,12 +2023,9 @@ pad_to_streampos(streampos fpos) { return fpos; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::add_new_subfile -// Access: Private -// Description: Adds a newly-allocated Subfile pointer to the -// Multifile. -//////////////////////////////////////////////////////////////////// +/** + * Adds a newly-allocated Subfile pointer to the Multifile. + */ void Multifile:: add_new_subfile(Subfile *subfile, int compression_level) { if (compression_level != 0) { @@ -2293,25 +2046,27 @@ add_new_subfile(Subfile *subfile, int compression_level) { #endif // HAVE_OPENSSL if (_next_index != (streampos)0) { - // If we're adding a Subfile to an already-existing Multifile, we - // will eventually need to repack the file. + // If we're adding a Subfile to an already-existing Multifile, we will + // eventually need to repack the file. _needs_repack = true; } pair insert_result = _subfiles.insert(subfile); if (!insert_result.second) { - // Hmm, unable to insert. There must already be a subfile by that - // name. Remove the old one. + // Hmm, unable to insert. There must already be a subfile by that name. + // Remove the old one. Subfile *old_subfile = (*insert_result.first); old_subfile->_flags |= SF_deleted; - // Maybe it was just added to the _new_subfiles list. In this case, remove it from that list. + // Maybe it was just added to the _new_subfiles list. In this case, + // remove it from that list. PendingSubfiles::iterator ni = find(_new_subfiles.begin(), _new_subfiles.end(), old_subfile); if (ni != _new_subfiles.end()) { _new_subfiles.erase(ni); } else { - // Otherwise, add it to the _removed_subfiles list, so we can remove the old one. + // Otherwise, add it to the _removed_subfiles list, so we can remove the + // old one. _removed_subfiles.push_back(old_subfile); } @@ -2321,21 +2076,18 @@ add_new_subfile(Subfile *subfile, int compression_level) { _new_subfiles.push_back(subfile); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::open_read_subfile -// Access: Private -// Description: This variant of open_read_subfile() is used -// internally only, and accepts a pointer to the -// internal Subfile object, which is assumed to be valid -// and written to the multifile. -//////////////////////////////////////////////////////////////////// +/** + * This variant of open_read_subfile() is used internally only, and accepts a + * pointer to the internal Subfile object, which is assumed to be valid and + * written to the multifile. + */ istream *Multifile:: open_read_subfile(Subfile *subfile) { nassertr(subfile->_source == (istream *)NULL && subfile->_source_filename.empty(), NULL); - // Return an ISubStream object that references into the open - // Multifile istream. + // Return an ISubStream object that references into the open Multifile + // istream. nassertr(subfile->_data_start != (streampos)0, NULL); istream *stream = new ISubStream(_read, _offset + subfile->_data_start, @@ -2348,14 +2100,13 @@ open_read_subfile(Subfile *subfile) { delete stream; return NULL; #else // HAVE_OPENSSL - // The subfile is encrypted. So actually, return an - // IDecryptStream that wraps around the ISubStream. + // The subfile is encrypted. So actually, return an IDecryptStream that + // wraps around the ISubStream. IDecryptStream *wrapper = new IDecryptStream(stream, true, _encryption_password); stream = wrapper; - // Validate the password by confirming that the encryption header - // matches. + // Validate the password by confirming that the encryption header matches. char this_header[_encrypt_header_size]; stream->read(this_header, _encrypt_header_size); if (stream->fail() || stream->gcount() != (unsigned)_encrypt_header_size || @@ -2391,11 +2142,9 @@ open_read_subfile(Subfile *subfile) { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::standardize_subfile_name -// Access: Private -// Description: Returns the standard form of the subfile name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard form of the subfile name. + */ string Multifile:: standardize_subfile_name(const string &subfile_name) const { Filename name = subfile_name; @@ -2414,12 +2163,10 @@ standardize_subfile_name(const string &subfile_name) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::clear_subfiles -// Access: Private -// Description: Removes the set of subfiles from the tables and frees -// their associated memory. -//////////////////////////////////////////////////////////////////// +/** + * Removes the set of subfiles from the tables and frees their associated + * memory. + */ void Multifile:: clear_subfiles() { PendingSubfiles::iterator pi; @@ -2430,8 +2177,8 @@ clear_subfiles() { } _removed_subfiles.clear(); - // We don't have to delete the ones in _new_subfiles, because these - // also appear in _subfiles. + // We don't have to delete the ones in _new_subfiles, because these also + // appear in _subfiles. _new_subfiles.clear(); #ifdef HAVE_OPENSSL @@ -2452,30 +2199,26 @@ clear_subfiles() { _subfiles.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::read_index -// Access: Private -// Description: Reads the Multifile header and index. Returns true -// if successful, false if the Multifile is not valid. -//////////////////////////////////////////////////////////////////// +/** + * Reads the Multifile header and index. Returns true if successful, false if + * the Multifile is not valid. + */ bool Multifile:: read_index() { nassertr(_read != (IStreamWrapper *)NULL, false); - // We acquire the IStreamWrapper lock for the duration of this - // method. + // We acquire the IStreamWrapper lock for the duration of this method. _read->acquire(); istream *read = _read->get_istream(); char this_header[_header_size]; read->seekg(_offset); - // Here's a special case: if the multifile begins with a hash - // character, then we continue reading and discarding lines of ASCII - // text, until we come across a nonempty line that does not begin - // with a hash character. This allows a P3D application (which is a - // multifile) to be run directly on the command line on Unix-based - // systems. + // Here's a special case: if the multifile begins with a hash character, + // then we continue reading and discarding lines of ASCII text, until we + // come across a nonempty line that does not begin with a hash character. + // This allows a P3D application (which is a multifile) to be run directly + // on the command line on Unix-based systems. _header_prefix = string(); int ch = read->get(); @@ -2544,8 +2287,8 @@ read_index() { if (_file_minor_ver >= 1) { time_t read_timestamp = reader.get_uint32(); if (read_timestamp == 0) { - // If we read a 0 timestamp from the file, that implies that we - // don't want to record a timestamp in this particular file. + // If we read a 0 timestamp from the file, that implies that we don't + // want to record a timestamp in this particular file. _record_timestamp = false; } else { _timestamp = read_timestamp; @@ -2572,8 +2315,7 @@ read_index() { _needs_repack = true; delete subfile; } else if (subfile->is_cert_special()) { - // Certificate chains and signature files get stored in a - // special list. + // Certificate chains and signature files get stored in a special list. _cert_special.push_back(subfile); read_cert_special = true; } else { @@ -2581,15 +2323,13 @@ read_index() { } if (!subfile->is_cert_special()) { if (bytes_skipped != 0) { - // If the index entries don't follow exactly sequentially - // (except for the cert special files), the file ought to be - // repacked. + // If the index entries don't follow exactly sequentially (except for + // the cert special files), the file ought to be repacked. _needs_repack = true; } if (read_cert_special) { - // If we read a normal subfile following a cert_special entry, - // the file ought to be repacked (certificates have to go at - // the end). + // If we read a normal subfile following a cert_special entry, the + // file ought to be repacked (certificates have to go at the end). _needs_repack = true; } _last_data_byte = max(_last_data_byte, subfile->get_last_byte_pos()); @@ -2610,8 +2350,7 @@ read_index() { return false; } - // Check if the list is already sorted. If it is not, we need a - // repack. + // Check if the list is already sorted. If it is not, we need a repack. for (size_t si = 1; si < _subfiles.size() && !_needs_repack; ++si) { if (*_subfiles[si] < *_subfiles[si - 1]) { _needs_repack = true; @@ -2624,8 +2363,8 @@ read_index() { _subfiles.sort(); size_t after_size = _subfiles.size(); - // If these don't match, the same filename appeared twice in the - // index, which shouldn't be possible. + // If these don't match, the same filename appeared twice in the index, + // which shouldn't be possible. nassertr(before_size == after_size, true); } @@ -2634,12 +2373,9 @@ read_index() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::write_header -// Access: Private -// Description: Writes just the header part of the Multifile, not the -// index. -//////////////////////////////////////////////////////////////////// +/** + * Writes just the header part of the Multifile, not the index. + */ bool Multifile:: write_header() { _file_major_ver = _current_major_ver; @@ -2675,18 +2411,14 @@ write_header() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::check_signatures -// Access: Private -// Description: Walks through the list of _cert_special entries in -// the Multifile, moving any valid signatures found to -// _signatures. After this call, _cert_special will be -// empty. -// -// This does not check the validity of the certificates -// themselves. It only checks that they correctly sign -// the Multifile contents. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the list of _cert_special entries in the Multifile, moving + * any valid signatures found to _signatures. After this call, _cert_special + * will be empty. + * + * This does not check the validity of the certificates themselves. It only + * checks that they correctly sign the Multifile contents. + */ void Multifile:: check_signatures() { #ifdef HAVE_OPENSSL @@ -2711,8 +2443,8 @@ check_signatures() { nassertv(success); close_read_subfile(stream); - // Now convert each of the certificates to an X509 object, and - // store it in our CertChain. + // Now convert each of the certificates to an X509 object, and store it in + // our CertChain. CertChain chain; EVP_PKEY *pkey = NULL; if (!buffer.empty()) { @@ -2791,21 +2523,18 @@ check_signatures() { _cert_special.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::read_index -// Access: Public -// Description: Reads the index record for the Subfile from the -// indicated istream. Assumes the istream has already -// been positioned to the indicated stream position, -// fpos, the start of the index record. Returns the -// position within the file of the next index record. -//////////////////////////////////////////////////////////////////// +/** + * Reads the index record for the Subfile from the indicated istream. Assumes + * the istream has already been positioned to the indicated stream position, + * fpos, the start of the index record. Returns the position within the file + * of the next index record. + */ streampos Multifile::Subfile:: read_index(istream &read, streampos fpos, Multifile *multifile) { nassertr(read.tellg() - multifile->_offset == fpos, fpos); - // First, get the next stream position. We do this separately, - // because if it is zero, we don't get anything else. + // First, get the next stream position. We do this separately, because if + // it is zero, we don't get anything else. StreamReader reader(read); streampos next_index = multifile->word_to_streampos(reader.get_uint32()); @@ -2864,18 +2593,14 @@ read_index(istream &read, streampos fpos, Multifile *multifile) { return next_index; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::write_index -// Access: Public -// Description: Writes the index record for the Subfile to the -// indicated ostream. Assumes the istream has already -// been positioned to the indicated stream position, -// fpos, the start of the index record, and that this is -// the effective end of the file. Returns the position -// within the file of the next index record. -// -// The _index_start member is updated by this operation. -//////////////////////////////////////////////////////////////////// +/** + * Writes the index record for the Subfile to the indicated ostream. Assumes + * the istream has already been positioned to the indicated stream position, + * fpos, the start of the index record, and that this is the effective end of + * the file. Returns the position within the file of the next index record. + * + * The _index_start member is updated by this operation. + */ streampos Multifile::Subfile:: write_index(ostream &write, streampos fpos, Multifile *multifile) { nassertr(write.tellp() - multifile->_offset == fpos, fpos); @@ -2883,8 +2608,8 @@ write_index(ostream &write, streampos fpos, Multifile *multifile) { _index_start = fpos; _index_length = 0; - // This will be the contents of this particular index record. We - // build it up first since it will be variable length. + // This will be the contents of this particular index record. We build it + // up first since it will be variable length. Datagram dg; dg.add_uint32(multifile->streampos_to_word(_data_start)); dg.add_uint32(_data_length); @@ -2895,11 +2620,10 @@ write_index(ostream &write, streampos fpos, Multifile *multifile) { dg.add_uint32(_timestamp); dg.add_uint16(_name.length()); - // For no real good reason, we'll invert all the bits in the name. - // The only reason we do this is to make it inconvenient for a - // casual browser of the Multifile to discover the names of the - // files stored within it. Naturally, this isn't real obfuscation - // or security. + // For no real good reason, we'll invert all the bits in the name. The only + // reason we do this is to make it inconvenient for a casual browser of the + // Multifile to discover the names of the files stored within it. + // Naturally, this isn't real obfuscation or security. string::iterator ni; for (ni = _name.begin(); ni != _name.end(); ++ni) { dg.add_int8((*ni) ^ 0xff); @@ -2920,26 +2644,20 @@ write_index(ostream &write, streampos fpos, Multifile *multifile) { return next_index; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::write_data -// Access: Public -// Description: Writes the data record for the Subfile to the -// indicated ostream: the actual contents of the -// Subfile. Assumes the istream has already been -// positioned to the indicated stream position, fpos, -// the start of the data record, and that this is the -// effective end of the file. Returns the position -// within the file of the next data record. -// -// The _data_start, _data_length, and -// _uncompressed_length members are updated by this -// operation. -// -// If the "read" pointer is non-NULL, it is the readable -// istream of a Multifile in which the Subfile might -// already be packed. This is used for reading the -// contents of the Subfile during a repack() operation. -//////////////////////////////////////////////////////////////////// +/** + * Writes the data record for the Subfile to the indicated ostream: the actual + * contents of the Subfile. Assumes the istream has already been positioned + * to the indicated stream position, fpos, the start of the data record, and + * that this is the effective end of the file. Returns the position within + * the file of the next data record. + * + * The _data_start, _data_length, and _uncompressed_length members are updated + * by this operation. + * + * If the "read" pointer is non-NULL, it is the readable istream of a + * Multifile in which the Subfile might already be packed. This is used for + * reading the contents of the Subfile during a repack() operation. + */ streampos Multifile::Subfile:: write_data(ostream &write, istream *read, streampos fpos, Multifile *multifile) { @@ -2962,8 +2680,8 @@ write_data(ostream &write, istream *read, streampos fpos, } if (source == (istream *)NULL) { - // We don't have any source data. Perhaps we're reading from an - // already-packed Subfile (e.g. during repack()). + // We don't have any source data. Perhaps we're reading from an already- + // packed Subfile (e.g. during repack()). if (read == (istream *)NULL) { // No, we're just screwed. express_cat.info() @@ -2985,14 +2703,13 @@ write_data(ostream &write, istream *read, streampos fpos, } } } else { - // We do have source data. Copy it in, and also measure its - // length. + // We do have source data. Copy it in, and also measure its length. ostream *putter = &write; bool delete_putter = false; #ifndef HAVE_OPENSSL - // Without OpenSSL, we can't support encryption. The flag had - // better not be set. + // Without OpenSSL, we can't support encryption. The flag had better not + // be set. nassertr((_flags & SF_encrypted) == 0, fpos); #else // HAVE_OPENSSL @@ -3005,16 +2722,15 @@ write_data(ostream &write, istream *read, streampos fpos, putter = encrypt; delete_putter = true; - // Also write the encrypt_header to the beginning of the - // encrypted stream, so we can validate the password on - // decryption. + // Also write the encrypt_header to the beginning of the encrypted + // stream, so we can validate the password on decryption. putter->write(_encrypt_header, _encrypt_header_size); } #endif // HAVE_OPENSSL #ifndef HAVE_ZLIB - // Without ZLIB, we can't support compression. The flag had - // better not be set. + // Without ZLIB, we can't support compression. The flag had better not be + // set. nassertr((_flags & SF_compressed) == 0, fpos); #else // HAVE_ZLIB if ((_flags & SF_compressed) != 0) { @@ -3033,12 +2749,12 @@ write_data(ostream &write, istream *read, streampos fpos, #else // HAVE_OPENSSL if ((_flags & SF_signature) != 0) { - // If it's a special signature record, precede the record data - // (the certificate itself) with the signature data generated - // against the multifile contents. + // If it's a special signature record, precede the record data (the + // certificate itself) with the signature data generated against the + // multifile contents. - // In order to generate a signature, we need to have a valid - // read pointer. + // In order to generate a signature, we need to have a valid read + // pointer. nassertr(read != NULL, fpos); // And we also need to have a private key. @@ -3116,13 +2832,12 @@ write_data(ostream &write, istream *read, streampos fpos, _data_length = (size_t)(write_end - write_start); } - // We can't set _data_start until down here, after we have read the - // Subfile. (In case we are running during repack()). + // We can't set _data_start until down here, after we have read the Subfile. + // (In case we are running during repack()). _data_start = fpos; - // Get the modification timestamp for this subfile. This is read - // from the source file, if we have a filename; otherwise, it's the - // current time. + // Get the modification timestamp for this subfile. This is read from the + // source file, if we have a filename; otherwise, it's the current time. if (!_source_filename.empty()) { _timestamp = _source_filename.get_timestamp(); } @@ -3137,13 +2852,10 @@ write_data(ostream &write, istream *read, streampos fpos, return fpos + (streampos)_data_length; } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::rewrite_index_data_start -// Access: Public -// Description: Seeks within the indicate pfstream back to the index -// record and rewrites just the _data_start and -// _data_length part of the index record. -//////////////////////////////////////////////////////////////////// +/** + * Seeks within the indicate pfstream back to the index record and rewrites + * just the _data_start and _data_length part of the index record. + */ void Multifile::Subfile:: rewrite_index_data_start(ostream &write, Multifile *multifile) { nassertv(_index_start != (streampos)0); @@ -3167,17 +2879,14 @@ rewrite_index_data_start(ostream &write, Multifile *multifile) { } } -//////////////////////////////////////////////////////////////////// -// Function: Multifile::Subfile::rewrite_index_flags -// Access: Public -// Description: Seeks within the indicated ostream back to the index -// record and rewrites just the _flags part of the -// index record. -//////////////////////////////////////////////////////////////////// +/** + * Seeks within the indicated ostream back to the index record and rewrites + * just the _flags part of the index record. + */ void Multifile::Subfile:: rewrite_index_flags(ostream &write) { - // If the subfile has never even been recorded to disk, we don't - // need to do anything at all in this function. + // If the subfile has never even been recorded to disk, we don't need to do + // anything at all in this function. if (_index_start != (streampos)0) { static const size_t flags_offset = 4 + 4 + 4; size_t flags_pos = _index_start + (streampos)flags_offset; diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index d9842e07c6..578ac70d6d 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -1,16 +1,15 @@ -// Filename: multifile.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multifile.h + * @author mike + * @date 1997-01-09 + */ #ifndef MULTIFILE_H #define MULTIFILE_H @@ -27,10 +26,9 @@ #include "pvector.h" #include "openSSLWrapper.h" -//////////////////////////////////////////////////////////////////// -// Class : Multifile -// Description : A file that contains a set of files. -//////////////////////////////////////////////////////////////////// +/** + * A file that contains a set of files. + */ class EXPCL_PANDAEXPRESS Multifile : public ReferenceCount { PUBLISHED: Multifile(); diff --git a/panda/src/express/namable.I b/panda/src/express/namable.I index 8d3e0b438d..e1be80d872 100644 --- a/panda/src/express/namable.I +++ b/panda/src/express/namable.I @@ -1,44 +1,37 @@ -// Filename: namable.I -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file namable.I + * @author drose + * @date 2000-02-16 + */ -//////////////////////////////////////////////////////////////////// -// Function: Namable::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Namable:: Namable(const string &initial_name) : _name(initial_name) { } -//////////////////////////////////////////////////////////////////// -// Function: Namable::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Namable:: Namable(const Namable ©) : _name(copy._name) { } -//////////////////////////////////////////////////////////////////// -// Function: Namable::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Namable &Namable:: operator = (const Namable &other) { _name = other._name; @@ -46,11 +39,9 @@ operator = (const Namable &other) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Namable::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Namable &Namable:: operator = (Namable &&other) NOEXCEPT { _name = MOVE(other._name); @@ -58,54 +49,43 @@ operator = (Namable &&other) NOEXCEPT { } #endif -//////////////////////////////////////////////////////////////////// -// Function: Namable::set_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Namable:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: Namable::clear_name -// Access: Public -// Description: Resets the Namable's name to empty. -//////////////////////////////////////////////////////////////////// +/** + * Resets the Namable's name to empty. + */ INLINE void Namable:: clear_name() { _name = ""; } -//////////////////////////////////////////////////////////////////// -// Function: Namable::has_name -// Access: Public -// Description: Returns true if the Namable has a nonempty name set, -// false if the name is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Namable has a nonempty name set, false if the name is + * empty. + */ INLINE bool Namable:: has_name() const { return !_name.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Namable::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &Namable:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: Namable::output -// Access: Public -// Description: Outputs the Namable. This function simply writes the -// name to the output stream; most Namable derivatives -// will probably redefine this. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the Namable. This function simply writes the name to the output + * stream; most Namable derivatives will probably redefine this. + */ INLINE void Namable:: output(ostream &out) const { out << get_name(); @@ -117,11 +97,9 @@ INLINE ostream &operator << (ostream &out, const Namable &n) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: NamableOrderByName::Function operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool NamableOrderByName:: operator ()(const Namable *n1, const Namable *n2) const { return (n1->get_name() < n2->get_name()); diff --git a/panda/src/express/namable.cxx b/panda/src/express/namable.cxx index 993a4d468c..c9703e654e 100644 --- a/panda/src/express/namable.cxx +++ b/panda/src/express/namable.cxx @@ -1,16 +1,15 @@ -// Filename: namable.cxx -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file namable.cxx + * @author drose + * @date 1999-01-15 + */ #include "namable.h" diff --git a/panda/src/express/namable.h b/panda/src/express/namable.h index 796c65cdb6..435426fc1b 100644 --- a/panda/src/express/namable.h +++ b/panda/src/express/namable.h @@ -1,16 +1,15 @@ -// Filename: namable.h -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file namable.h + * @author drose + * @date 1999-01-15 + */ #ifndef NAMABLE_H #define NAMABLE_H @@ -20,12 +19,10 @@ #include "typedObject.h" #include -//////////////////////////////////////////////////////////////////// -// Class : Namable -// Description : A base class for all things which can have a name. -// The name is either empty or nonempty, but it is never -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * A base class for all things which can have a name. The name is either + * empty or nonempty, but it is never NULL. + */ class EXPCL_PANDAEXPRESS Namable : public MemoryBase { PUBLISHED: INLINE explicit Namable(const string &initial_name = ""); @@ -42,8 +39,8 @@ PUBLISHED: INLINE const string &get_name() const; MAKE_PROPERTY(name, get_name, set_name); - // In the absence of any definition to the contrary, outputting a - // Namable will write out its name. + // In the absence of any definition to the contrary, outputting a Namable + // will write out its name. INLINE void output(ostream &out) const; private: @@ -63,13 +60,11 @@ private: INLINE ostream &operator << (ostream &out, const Namable &n); -//////////////////////////////////////////////////////////////////// -// Class : NamableOrderByName -// Description : An STL function object for sorting an array of -// pointers to Namables into order by name. Returns -// true if the objects are in sorted order, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object for sorting an array of pointers to Namables into + * order by name. Returns true if the objects are in sorted order, false + * otherwise. + */ class NamableOrderByName { public: INLINE bool operator ()(const Namable *n1, const Namable *n2) const; @@ -78,5 +73,3 @@ public: #include "namable.I" #endif - - diff --git a/panda/src/express/nodePointerTo.I b/panda/src/express/nodePointerTo.I index cdc2d6cbdd..e56dd902b6 100644 --- a/panda/src/express/nodePointerTo.I +++ b/panda/src/express/nodePointerTo.I @@ -1,24 +1,20 @@ -// Filename: nodePointerTo.I -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerTo.I + * @author drose + * @date 2005-05-07 + */ #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo:: NodePointerTo(To *ptr) : NodePointerToBase(ptr) { @@ -26,11 +22,9 @@ NodePointerTo(To *ptr) : NodePointerToBase(ptr) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo:: NodePointerTo(const NodePointerTo ©) : @@ -40,11 +34,9 @@ NodePointerTo(const NodePointerTo ©) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo:: ~NodePointerTo() { @@ -53,11 +45,9 @@ INLINE NodePointerTo:: #ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo:: NodePointerTo(NodePointerTo &&from) NOEXCEPT : @@ -67,11 +57,9 @@ NodePointerTo(NodePointerTo &&from) NOEXCEPT : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo &NodePointerTo:: operator = (NodePointerTo &&from) NOEXCEPT { @@ -82,11 +70,9 @@ operator = (NodePointerTo &&from) NOEXCEPT { #endif // USE_MOVE_SEMANTICS #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME NodePointerTo::To &NodePointerTo:: operator *() const { @@ -95,11 +81,9 @@ operator *() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME NodePointerTo::To *NodePointerTo:: operator -> () const { @@ -108,16 +92,12 @@ operator -> () const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert NodePointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert NodePointerTo's + * to the required kind of actual pointer. This introduces ambiguities which + * the compiler will resolve one way or the other, but we don't care which way + * it goes because either will be correct. + */ template INLINE NodePointerTo:: operator T *() const { @@ -126,13 +106,10 @@ operator T *() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::p -// Access: Public -// Description: Returns an ordinary pointer instead of a NodePointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a NodePointerTo. Useful to work + * around compiler problems, particularly for implicit upcasts. + */ template INLINE TYPENAME NodePointerTo::To *NodePointerTo:: p() const { @@ -141,11 +118,9 @@ p() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo &NodePointerTo:: operator = (To *ptr) { @@ -155,11 +130,9 @@ operator = (To *ptr) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodePointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerTo &NodePointerTo:: operator = (const NodePointerTo ©) { @@ -169,11 +142,9 @@ operator = (const NodePointerTo ©) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: NodeConstPointerTo(const TYPENAME NodeConstPointerTo::To *ptr) : @@ -183,11 +154,9 @@ NodeConstPointerTo(const TYPENAME NodeConstPointerTo::To *ptr) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: NodeConstPointerTo(const NodePointerTo ©) : @@ -197,11 +166,9 @@ NodeConstPointerTo(const NodePointerTo ©) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: NodeConstPointerTo(const NodeConstPointerTo ©) : @@ -211,11 +178,9 @@ NodeConstPointerTo(const NodeConstPointerTo ©) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: ~NodeConstPointerTo() { @@ -224,11 +189,9 @@ INLINE NodeConstPointerTo:: #ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT : @@ -238,11 +201,9 @@ NodeConstPointerTo(NodePointerTo &&from) NOEXCEPT : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo:: NodeConstPointerTo(NodeConstPointerTo &&from) NOEXCEPT : @@ -252,11 +213,9 @@ NodeConstPointerTo(NodeConstPointerTo &&from) NOEXCEPT : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (NodePointerTo &&from) NOEXCEPT { @@ -266,11 +225,9 @@ operator = (NodePointerTo &&from) NOEXCEPT { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (NodeConstPointerTo &&from) NOEXCEPT { @@ -281,11 +238,9 @@ operator = (NodeConstPointerTo &&from) NOEXCEPT { #endif // USE_MOVE_SEMANTICS #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME NodeConstPointerTo::To &NodeConstPointerTo:: operator *() const { @@ -294,11 +249,9 @@ operator *() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: operator -> () const { @@ -307,16 +260,12 @@ operator -> () const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert NodeConstPointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert + * NodeConstPointerTo's to the required kind of actual pointer. This + * introduces ambiguities which the compiler will resolve one way or the + * other, but we don't care which way it goes because either will be correct. + */ template INLINE NodeConstPointerTo:: @@ -326,13 +275,10 @@ operator const T * () const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::p -// Access: Public -// Description: Returns an ordinary pointer instead of a NodeConstPointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a NodeConstPointerTo. Useful to + * work around compiler problems, particularly for implicit upcasts. + */ template INLINE const TYPENAME NodeConstPointerTo::To *NodeConstPointerTo:: p() const { @@ -341,11 +287,9 @@ p() const { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (const To *ptr) { @@ -355,11 +299,9 @@ operator = (const To *ptr) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (const NodePointerTo ©) { @@ -369,11 +311,9 @@ operator = (const NodePointerTo ©) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: NodeConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeConstPointerTo &NodeConstPointerTo:: operator = (const NodeConstPointerTo ©) { diff --git a/panda/src/express/nodePointerTo.cxx b/panda/src/express/nodePointerTo.cxx index 828750f4e5..65373cc666 100644 --- a/panda/src/express/nodePointerTo.cxx +++ b/panda/src/express/nodePointerTo.cxx @@ -1,15 +1,14 @@ -// Filename: nodePointerTo.cxx -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerTo.cxx + * @author drose + * @date 2005-05-07 + */ #include "nodePointerTo.h" diff --git a/panda/src/express/nodePointerTo.h b/panda/src/express/nodePointerTo.h index dfd87923ab..7fc773852d 100644 --- a/panda/src/express/nodePointerTo.h +++ b/panda/src/express/nodePointerTo.h @@ -1,16 +1,15 @@ -// Filename: nodePointerTo.h -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerTo.h + * @author drose + * @date 2005-05-07 + */ #ifndef NODEPOINTERTO_H #define NODEPOINTERTO_H @@ -18,18 +17,16 @@ #include "pandabase.h" #include "nodePointerToBase.h" -//////////////////////////////////////////////////////////////////// -// Class : NodePointerTo -// Description : This implements the special NodePointerTo template -// class, which works just like PointerTo except it -// manages the objects node_ref_count instead of the -// normal ref_count. -//////////////////////////////////////////////////////////////////// +/** + * This implements the special NodePointerTo template class, which works just + * like PointerTo except it manages the objects node_ref_count instead of the + * normal ref_count. + */ template class NodePointerTo : public NodePointerToBase { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER typedef TYPENAME NodePointerToBase::To To; INLINE NodePointerTo(To *ptr = (To *)NULL); @@ -55,16 +52,15 @@ public: }; -//////////////////////////////////////////////////////////////////// -// Class : NodeConstPointerTo -// Description : A NodeConstPointerTo is similar to a NodePointerTo, -// except it keeps a const pointer to the thing. -//////////////////////////////////////////////////////////////////// +/** + * A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const + * pointer to the thing. + */ template class NodeConstPointerTo : public NodePointerToBase { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER typedef TYPENAME NodePointerToBase::To To; INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL); diff --git a/panda/src/express/nodePointerToBase.I b/panda/src/express/nodePointerToBase.I index 4729f6184d..18f04def9a 100644 --- a/panda/src/express/nodePointerToBase.I +++ b/panda/src/express/nodePointerToBase.I @@ -1,45 +1,37 @@ -// Filename: nodePointerToBase.I -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerToBase.I + * @author drose + * @date 2005-05-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerToBase:: NodePointerToBase(To *ptr) { reassign(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerToBase:: NodePointerToBase(const NodePointerToBase ©) { reassign(copy); } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerToBase:: ~NodePointerToBase() { @@ -47,11 +39,9 @@ INLINE NodePointerToBase:: } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::Move Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodePointerToBase:: NodePointerToBase(NodePointerToBase &&from) NOEXCEPT { @@ -59,15 +49,12 @@ NodePointerToBase(NodePointerToBase &&from) NOEXCEPT { from._void_ptr = (void *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::reassign -// Access: Protected -// Description: This version of reassign is called when a -// NodePointerTo is assigned to this Node PointerTo -// as an rvalue. In this case, we can steal the -// reference count from the other PointerTo, without -// needing to call ref() and unref() unnecessarily. -//////////////////////////////////////////////////////////////////// +/** + * This version of reassign is called when a NodePointerTo is assigned to this + * Node PointerTo as an rvalue. In this case, we can steal the reference + * count from the other PointerTo, without needing to call ref() and unref() + * unnecessarily. + */ template INLINE void NodePointerToBase:: reassign(NodePointerToBase &&from) NOEXCEPT { @@ -83,22 +70,18 @@ reassign(NodePointerToBase &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::reassign -// Access: Protected -// Description: This is the main work of the NodePointerTo family. When -// the pointer is reassigned, decrement the old -// reference count and increment the new one. -//////////////////////////////////////////////////////////////////// +/** + * This is the main work of the NodePointerTo family. When the pointer is + * reassigned, decrement the old reference count and increment the new one. + */ template void NodePointerToBase:: reassign(To *ptr) { if (ptr != (To *)_void_ptr) { - // First save the old pointer; we won't delete it until we have - // assigned the new one. We do this just in case there are - // cascading effects from deleting this pointer that might - // inadvertently delete the new one. (Don't laugh--it's - // happened!) + // First save the old pointer; we won't delete it until we have assigned + // the new one. We do this just in case there are cascading effects from + // deleting this pointer that might inadvertently delete the new one. + // (Don't laugh--it's happened!) To *old_ptr = (To *)_void_ptr; _void_ptr = (void *)ptr; @@ -106,8 +89,8 @@ reassign(To *ptr) { ptr->node_ref(); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { - // Make sure the MemoryUsage record knows what the TypeHandle - // is, if we know it ourselves. + // Make sure the MemoryUsage record knows what the TypeHandle is, if + // we know it ourselves. TypeHandle type = get_type_handle(To); if (type == TypeHandle::none()) { do_init_type(To); @@ -127,11 +110,9 @@ reassign(To *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::reassign -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void NodePointerToBase:: reassign(const NodePointerToBase ©) { @@ -139,24 +120,20 @@ reassign(const NodePointerToBase ©) { } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::clear -// Access: Published -// Description: A convenient way to set the NodePointerTo object to NULL. -// (Assignment to a NULL pointer also works, of course.) -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to set the NodePointerTo object to NULL. (Assignment to a + * NULL pointer also works, of course.) + */ template INLINE void NodePointerToBase:: clear() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: NodePointerToBase::output -// Access: Published -// Description: A handy function to output NodePointerTo's as a hex -// pointer followed by a reference count. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to output NodePointerTo's as a hex pointer followed by a + * reference count. + */ template INLINE void NodePointerToBase:: output(ostream &out) const { diff --git a/panda/src/express/nodePointerToBase.cxx b/panda/src/express/nodePointerToBase.cxx index f7ea119db3..39c7d951c3 100644 --- a/panda/src/express/nodePointerToBase.cxx +++ b/panda/src/express/nodePointerToBase.cxx @@ -1,15 +1,14 @@ -// Filename: nodePointerToBase.cxx -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerToBase.cxx + * @author drose + * @date 2005-05-07 + */ #include "nodePointerToBase.h" diff --git a/panda/src/express/nodePointerToBase.h b/panda/src/express/nodePointerToBase.h index 870824c2b6..e7bb9ad526 100644 --- a/panda/src/express/nodePointerToBase.h +++ b/panda/src/express/nodePointerToBase.h @@ -1,16 +1,15 @@ -// Filename: nodePointerToBase.h -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePointerToBase.h + * @author drose + * @date 2005-05-07 + */ #ifndef NODEPOINTERTOBASE_H #define NODEPOINTERTOBASE_H @@ -20,18 +19,14 @@ #include "memoryUsage.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Class : NodePointerToBase -// Description : This is similar to PointerToBase, but it manages -// objects of type NodeReferenceCount or -// NodeCachedReferenceCount, and it updates the -// node_ref_count instead of the regular ref_count. It -// is intended for use only in PandaNode, to hold a -// pointer to RenderState and TransformState, although -// it could be used by any object that wanted to -// maintain a separate reference count for reporting -// purposes. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to PointerToBase, but it manages objects of type + * NodeReferenceCount or NodeCachedReferenceCount, and it updates the + * node_ref_count instead of the regular ref_count. It is intended for use + * only in PandaNode, to hold a pointer to RenderState and TransformState, + * although it could be used by any object that wanted to maintain a separate + * reference count for reporting purposes. + */ template class NodePointerToBase : public PointerToVoid { public: @@ -50,9 +45,8 @@ protected: void reassign(To *ptr); INLINE void reassign(const NodePointerToBase ©); - // No assignment or retrieval functions are declared in - // NodePointerToBase, because we will have to specialize on const - // vs. non-const later. + // No assignment or retrieval functions are declared in NodePointerToBase, + // because we will have to specialize on const vs. non-const later. PUBLISHED: INLINE void clear(); diff --git a/panda/src/express/nodeReferenceCount.I b/panda/src/express/nodeReferenceCount.I index 3b13f58eb6..d27fa0a43a 100644 --- a/panda/src/express/nodeReferenceCount.I +++ b/panda/src/express/nodeReferenceCount.I @@ -1,137 +1,115 @@ -// Filename: nodeReferenceCount.I -// Created by: drose (01May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeReferenceCount.I + * @author drose + * @date 2006-05-01 + */ template TypeHandle NodeRefCountObj::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::Constructor -// Access: Protected -// Description: The ReferenceCount constructor is protected because -// you almost never want to create just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. -// -// ReferenceCount doesn't store any useful information -// in its own right; its only purpose is to add -// reference-counting to some other class via -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount constructor is protected because you almost never want + * to create just a ReferenceCount object by itself, and it's probably a + * mistake if you try. + * + * ReferenceCount doesn't store any useful information in its own right; its + * only purpose is to add reference-counting to some other class via + * inheritance. + */ INLINE NodeReferenceCount:: NodeReferenceCount() { _node_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::Copy Constructor -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy constructor is protected because you almost -// never want to create just a ReferenceCount object by -// itself, and it's probably a mistake if you try. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy constructor is protected because you almost never want to create + * just a ReferenceCount object by itself, and it's probably a mistake if you + * try. + */ INLINE NodeReferenceCount:: NodeReferenceCount(const NodeReferenceCount ©) : ReferenceCount(copy) { _node_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::Copy Assignment Operator -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy assignment operator is protected because -// you almost never want to copy just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. Instead, this should only be called from a -// derived class that implements this operator and then -// calls up the inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy assignment operator is protected because you almost never want to + * copy just a ReferenceCount object by itself, and it's probably a mistake if + * you try. Instead, this should only be called from a derived class that + * implements this operator and then calls up the inheritance chain. + */ INLINE void NodeReferenceCount:: operator = (const NodeReferenceCount ©) { nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. - // Possibly you used a real pointer instead of a PointerTo at some - // point, and the object was deleted when the PointerTo went out of - // scope. Maybe you tried to create an automatic (local variable) - // instance of a class that derives from ReferenceCount. Or maybe - // your headers are out of sync, and you need to make clean in - // direct or some higher tree. + // If this assertion fails, our own pointer was recently deleted. Possibly + // you used a real pointer instead of a PointerTo at some point, and the + // object was deleted when the PointerTo went out of scope. Maybe you tried + // to create an automatic (local variable) instance of a class that derives + // from ReferenceCount. Or maybe your headers are out of sync, and you need + // to make clean in direct or some higher tree. nassertv(_node_ref_count != -100); ReferenceCount::operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::Destructor -// Access: Protected -// Description: The ReferenceCount destructor is protected to -// discourage users from accidentally trying to delete a -// ReferenceCount pointer directly. This is almost -// always a bad idea, since the destructor is not -// virtual, and you've almost certainly got some pointer -// to something that inherits from ReferenceCount, not -// just a plain old ReferenceCount object. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount destructor is protected to discourage users from + * accidentally trying to delete a ReferenceCount pointer directly. This is + * almost always a bad idea, since the destructor is not virtual, and you've + * almost certainly got some pointer to something that inherits from + * ReferenceCount, not just a plain old ReferenceCount object. + */ INLINE NodeReferenceCount:: ~NodeReferenceCount() { nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertv(_node_ref_count != -100); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertv(_node_ref_count >= 0); - // If this assertion fails, someone tried to delete this object - // while its reference count was still positive. Maybe you tried - // to point a PointerTo at a static object (a local variable, - // instead of one allocated via new)? The test below against 0x7f - // is supposed to check for that, but it's a pretty hokey test. + // If this assertion fails, someone tried to delete this object while its + // reference count was still positive. Maybe you tried to point a PointerTo + // at a static object (a local variable, instead of one allocated via new)? + // The test below against 0x7f is supposed to check for that, but it's a + // pretty hokey test. - // Another possibility is you inadvertently omitted a copy - // constructor for a ReferenceCount object, and then bitwise - // copied a dynamically allocated value--reference count and - // all--onto a locally allocated one. + // Another possibility is you inadvertently omitted a copy constructor for a + // ReferenceCount object, and then bitwise copied a dynamically allocated + // value--reference count and all--onto a locally allocated one. nassertv(_node_ref_count == 0); #ifndef NDEBUG - // Ok, all clear to delete. Now set the reference count to -100, - // so we'll have a better chance of noticing if we happen to have - // a stray pointer to it still out there. + // Ok, all clear to delete. Now set the reference count to -100, so we'll + // have a better chance of noticing if we happen to have a stray pointer to + // it still out there. _node_ref_count = -100; #endif } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::get_node_ref_count -// Access: Published -// Description: Returns the current reference count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current reference count. + */ INLINE int NodeReferenceCount:: get_node_ref_count() const { #ifdef _DEBUG @@ -140,12 +118,10 @@ get_node_ref_count() const { return (int)AtomicAdjust::get(_node_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::node_ref -// Access: Published -// Description: Explicitly increments the node reference count and -// the normal reference count simultaneously. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly increments the node reference count and the normal reference + * count simultaneously. + */ INLINE void NodeReferenceCount:: node_ref() const { #ifdef _DEBUG @@ -156,27 +132,23 @@ node_ref() const { AtomicAdjust::inc(((NodeReferenceCount *)this)->_node_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::node_unref -// Access: Published -// Description: Explicitly decrements the node reference count and -// the normal reference count simultaneously. -// -// The return value is true if the new reference count -// is nonzero, false if it is zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the node reference count and the normal reference + * count simultaneously. + * + * The return value is true if the new reference count is nonzero, false if it + * is zero. + */ INLINE bool NodeReferenceCount:: node_unref() const { node_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::test_ref_count_integrity -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ INLINE bool NodeReferenceCount:: test_ref_count_integrity() const { #ifndef NDEBUG @@ -186,38 +158,32 @@ test_ref_count_integrity() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::node_unref_only -// Access: Protected -// Description: Decrements the node reference count without affecting -// the normal reference count. Intended to be called by -// derived classes only, presumably to reimplement -// node_unref(). -//////////////////////////////////////////////////////////////////// +/** + * Decrements the node reference count without affecting the normal reference + * count. Intended to be called by derived classes only, presumably to + * reimplement node_unref(). + */ INLINE void NodeReferenceCount:: node_unref_only() const { #ifdef _DEBUG nassertv(test_ref_count_integrity()); #endif - // If this assertion fails, you tried to unref an object with a - // zero reference count. Are you using ref() and unref() - // directly? Are you sure you can't use PointerTo's? + // If this assertion fails, you tried to unref an object with a zero + // reference count. Are you using ref() and unref() directly? Are you sure + // you can't use PointerTo's? nassertv(_node_ref_count > 0); AtomicAdjust::dec(((NodeReferenceCount *)this)->_node_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: node_unref_delete -// Description: This global helper function will unref the given -// ReferenceCount object, and if the reference count -// reaches zero, automatically delete it. It can't be a -// member function because it's usually a bad idea to -// delete an object from within its own member function. -// It's a template function so the destructor doesn't -// have to be virtual. -//////////////////////////////////////////////////////////////////// +/** + * This global helper function will unref the given ReferenceCount object, and + * if the reference count reaches zero, automatically delete it. It can't be + * a member function because it's usually a bad idea to delete an object from + * within its own member function. It's a template function so the destructor + * doesn't have to be virtual. + */ template INLINE void node_unref_delete(RefCountType *ptr) { @@ -228,32 +194,26 @@ node_unref_delete(RefCountType *ptr) { -//////////////////////////////////////////////////////////////////// -// Function: NodeRefCountObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeRefCountObj:: NodeRefCountObj() { } -//////////////////////////////////////////////////////////////////// -// Function: NodeRefCountObj::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE NodeRefCountObj:: NodeRefCountObj(const Base ©) : Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: NodeRefCountObj::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void NodeRefCountObj:: init_type() { diff --git a/panda/src/express/nodeReferenceCount.cxx b/panda/src/express/nodeReferenceCount.cxx index ece7b4c2f9..05c9b6d63f 100644 --- a/panda/src/express/nodeReferenceCount.cxx +++ b/panda/src/express/nodeReferenceCount.cxx @@ -1,43 +1,38 @@ -// Filename: nodeReferenceCount.cxx -// Created by: drose (01May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeReferenceCount.cxx + * @author drose + * @date 2006-05-01 + */ #include "nodeReferenceCount.h" TypeHandle NodeReferenceCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodeReferenceCount::do_test_ref_count_integrity -// Access: Protected -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ bool NodeReferenceCount:: do_test_ref_count_integrity() const { nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertr(_node_ref_count != -100, false); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertr(_node_ref_count >= 0, false); return ReferenceCount::do_test_ref_count_integrity(); diff --git a/panda/src/express/nodeReferenceCount.h b/panda/src/express/nodeReferenceCount.h index edbe2657fb..349d66660b 100644 --- a/panda/src/express/nodeReferenceCount.h +++ b/panda/src/express/nodeReferenceCount.h @@ -1,16 +1,15 @@ -// Filename: nodeReferenceCount.h -// Created by: drose (01May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeReferenceCount.h + * @author drose + * @date 2006-05-01 + */ #ifndef NODEREFERENCECOUNT_H #define NODEREFERENCECOUNT_H @@ -19,25 +18,18 @@ #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : NodeReferenceCount -// Description : This class specializes ReferenceCount to add an -// additional counter, called node_ref_count, for the -// purposes of counting the number of times the object -// is referenced by a "node", whatever that may mean in -// context. -// -// The new methods node_ref() and node_unref() -// automatically increment and decrement the primary -// reference count as well. There also exists a -// NodePointerTo<> class to maintain the node_ref -// counters automatically. -// -// See also CachedTypedWritableReferenceCount, which is -// similar in principle, as well as -// NodeCachedReferenceCount, which combines both of -// these. -//////////////////////////////////////////////////////////////////// +/** + * This class specializes ReferenceCount to add an additional counter, called + * node_ref_count, for the purposes of counting the number of times the object + * is referenced by a "node", whatever that may mean in context. + * + * The new methods node_ref() and node_unref() automatically increment and + * decrement the primary reference count as well. There also exists a + * NodePointerTo<> class to maintain the node_ref counters automatically. + * + * See also CachedTypedWritableReferenceCount, which is similar in principle, + * as well as NodeCachedReferenceCount, which combines both of these. + */ class EXPCL_PANDAEXPRESS NodeReferenceCount : public ReferenceCount { protected: INLINE NodeReferenceCount(); @@ -55,7 +47,7 @@ protected: INLINE void node_unref_only() const; bool do_test_ref_count_integrity() const; - + private: AtomicAdjust::Integer _node_ref_count; @@ -77,11 +69,10 @@ private: template INLINE void node_unref_delete(RefCountType *ptr); -//////////////////////////////////////////////////////////////////// -// Class : NodeRefCountObj -// Description : This works like RefCountObj, but it inherits from -// NodeReferenceCount instead of ReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * This works like RefCountObj, but it inherits from NodeReferenceCount + * instead of ReferenceCount. + */ template class NodeRefCountObj : public NodeReferenceCount, public Base { public: @@ -100,5 +91,4 @@ private: #include "nodeReferenceCount.I" -#endif - +#endif diff --git a/panda/src/express/openSSLWrapper.I b/panda/src/express/openSSLWrapper.I index e90339034e..3d5cf81999 100644 --- a/panda/src/express/openSSLWrapper.I +++ b/panda/src/express/openSSLWrapper.I @@ -1,49 +1,39 @@ -// Filename: openSSLWrapper.I -// Created by: drose (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openSSLWrapper.I + * @author drose + * @date 2009-09-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::load_certificates_from_pem_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be PEM-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be PEM- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ INLINE int OpenSSLWrapper:: load_certificates_from_pem_ram(const string &data) { return load_certificates_from_pem_ram(data.data(), data.size()); } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::load_certificates_from_der_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be DER-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be DER- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ INLINE int OpenSSLWrapper:: load_certificates_from_der_ram(const string &data) { return load_certificates_from_der_ram(data.data(), data.size()); diff --git a/panda/src/express/openSSLWrapper.cxx b/panda/src/express/openSSLWrapper.cxx index a24e60a4fe..6492bb1596 100644 --- a/panda/src/express/openSSLWrapper.cxx +++ b/panda/src/express/openSSLWrapper.cxx @@ -1,16 +1,15 @@ -// Filename: openSSLWrapper.cxx -// Created by: drose (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openSSLWrapper.cxx + * @author drose + * @date 2009-09-05 + */ #include "openSSLWrapper.h" @@ -21,17 +20,15 @@ OpenSSLWrapper *OpenSSLWrapper::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenSSLWrapper:: OpenSSLWrapper() { - // It is necessary to call this before making any other OpenSSL - // call, per the docs. Also, the docs say that making this call - // will seed the random number generator. Apparently you can get - // away with not calling it in versions prior to 0.9.8, however. + // It is necessary to call this before making any other OpenSSL call, per + // the docs. Also, the docs say that making this call will seed the random + // number generator. Apparently you can get away with not calling it in + // versions prior to 0.9.8, however. SSL_library_init(); OpenSSL_add_all_algorithms(); @@ -53,7 +50,7 @@ OpenSSLWrapper() { "authorities. This is a fairly standard file; a copy of " "ca-bundle.crt is included in the OpenSSL distribution, and " "is also included with Panda.")); - + if (!ca_bundle_filename.empty()) { load_certificates(ca_bundle_filename); } @@ -72,25 +69,20 @@ OpenSSLWrapper() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::Destructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenSSLWrapper:: ~OpenSSLWrapper() { // Actually, the destructor is never called. X509_STORE_free(_x509_store); } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::clear_certificates -// Access: Public -// Description: Removes all the certificates from the global store, -// including the compiled-in certificates loaded from -// ca_bundle_data.c. You can add new certificates by -// calling load_certificates(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all the certificates from the global store, including the compiled- + * in certificates loaded from ca_bundle_data.c. You can add new certificates + * by calling load_certificates(). + */ void OpenSSLWrapper:: clear_certificates() { // We do this by deleting the store and creating a new one. @@ -98,25 +90,19 @@ clear_certificates() { _x509_store = X509_STORE_new(); // We don't set the default path either. We want a squeaky-clean store. - //X509_STORE_set_default_paths(_x509_store); + // X509_STORE_set_default_paths(_x509_store); } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::load_certificates -// Access: Public -// Description: Reads the PEM-formatted certificate(s) (delimited by -// -----BEGIN CERTIFICATE----- and -----END -// CERTIFICATE-----) from the indicated file and adds -// them to the global store object, retrieved via -// get_x509_store(). -// -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads the PEM-formatted certificate(s) (delimited by -----BEGIN + * CERTIFICATE----- and -----END CERTIFICATE-----) from the indicated file and + * adds them to the global store object, retrieved via get_x509_store(). + * + * Returns the number of certificates read on success, or 0 on failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ int OpenSSLWrapper:: load_certificates(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -148,30 +134,25 @@ load_certificates(const Filename &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::load_certificates_from_pem_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be PEM-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be PEM- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ int OpenSSLWrapper:: load_certificates_from_pem_ram(const char *data, size_t data_size) { STACK_OF(X509_INFO) *inf; - // Create an in-memory BIO to read the "file" from the buffer, and - // call the low-level routines to read the certificates from the - // BIO. + // Create an in-memory BIO to read the "file" from the buffer, and call the + // low-level routines to read the certificates from the BIO. BIO *mbio = BIO_new_mem_buf((void *)data, data_size); - // We have to be sure and clear the OpenSSL error state before we - // call this function, or it will get confused. + // We have to be sure and clear the OpenSSL error state before we call this + // function, or it will get confused. ERR_clear_error(); inf = PEM_X509_INFO_read_bio(mbio, NULL, NULL, NULL); BIO_free(mbio); @@ -183,7 +164,7 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { notify_ssl_errors(); return 0; } - + if (express_cat.is_spam()) { express_cat.spam() << "PEM_X509_INFO_read_bio() found " << sk_X509_INFO_num(inf) @@ -246,19 +227,15 @@ load_certificates_from_pem_ram(const char *data, size_t data_size) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::load_certificates_from_der_ram -// Access: Public -// Description: Reads a chain of trusted certificates from the -// indicated data buffer and adds them to the X509_STORE -// object. The data buffer should be DER-formatted. -// Returns the number of certificates read on success, -// or 0 on failure. -// -// You should call this only with trusted, -// locally-stored certificates; not with certificates -// received from an untrusted source. -//////////////////////////////////////////////////////////////////// +/** + * Reads a chain of trusted certificates from the indicated data buffer and + * adds them to the X509_STORE object. The data buffer should be DER- + * formatted. Returns the number of certificates read on success, or 0 on + * failure. + * + * You should call this only with trusted, locally-stored certificates; not + * with certificates received from an untrusted source. + */ int OpenSSLWrapper:: load_certificates_from_der_ram(const char *data, size_t data_size) { if (express_cat.is_spam()) { @@ -303,34 +280,26 @@ load_certificates_from_der_ram(const char *data, size_t data_size) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::get_x509_store -// Access: Public -// Description: Returns the global X509_STORE object. -// -// It has to be a global object, because OpenSSL seems -// to store some global pointers associated with this -// object whether you want it to or not, and keeping -// independent copies of a local X509_STORE object -// doesn't seem to work that well. So, we have one -// store that keeps all certificates the application -// might need. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global X509_STORE object. + * + * It has to be a global object, because OpenSSL seems to store some global + * pointers associated with this object whether you want it to or not, and + * keeping independent copies of a local X509_STORE object doesn't seem to + * work that well. So, we have one store that keeps all certificates the + * application might need. + */ X509_STORE *OpenSSLWrapper:: get_x509_store() { return _x509_store; } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::notify_ssl_errors -// Access: Public -// Description: A convenience function that is itself a wrapper -// around the OpenSSL convenience function to output the -// recent OpenSSL errors. This function sends the error -// string to express_cat.warning(). If -// REPORT_OPENSSL_ERRORS is not defined, the function -// does nothing. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function that is itself a wrapper around the OpenSSL + * convenience function to output the recent OpenSSL errors. This function + * sends the error string to express_cat.warning(). If REPORT_OPENSSL_ERRORS + * is not defined, the function does nothing. + */ void OpenSSLWrapper:: notify_ssl_errors() { #ifdef REPORT_OPENSSL_ERRORS @@ -351,12 +320,9 @@ notify_ssl_errors() { #endif // REPORT_OPENSSL_ERRORS } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::notify_debug_ssl_errors -// Access: Public -// Description: As notify_ssl_errors(), but sends the output to debug -// instead of warning. -//////////////////////////////////////////////////////////////////// +/** + * As notify_ssl_errors(), but sends the output to debug instead of warning. + */ void OpenSSLWrapper:: notify_debug_ssl_errors() { #ifdef REPORT_OPENSSL_ERRORS @@ -379,11 +345,9 @@ notify_debug_ssl_errors() { #endif // REPORT_OPENSSL_ERRORS } -//////////////////////////////////////////////////////////////////// -// Function: OpenSSLWrapper::get_global_ptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenSSLWrapper *OpenSSLWrapper:: get_global_ptr() { if (_global_ptr == NULL) { diff --git a/panda/src/express/openSSLWrapper.h b/panda/src/express/openSSLWrapper.h index b10360a841..306039e1c0 100644 --- a/panda/src/express/openSSLWrapper.h +++ b/panda/src/express/openSSLWrapper.h @@ -1,16 +1,15 @@ -// Filename: openSSLWrapper.h -// Created by: drose (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openSSLWrapper.h + * @author drose + * @date 2009-09-05 + */ #ifndef OPENSSLWRAPPER_H #define OPENSSLWRAPPER_H @@ -39,13 +38,11 @@ #undef X509_NAME #endif -//////////////////////////////////////////////////////////////////// -// Class : OpenSSLWrapper -// Description : Provides an interface wrapper around the OpenSSL -// library, to ensure that the library is properly -// initialized in the application, and to provide some -// hooks into global OpenSSL context data. -//////////////////////////////////////////////////////////////////// +/** + * Provides an interface wrapper around the OpenSSL library, to ensure that + * the library is properly initialized in the application, and to provide some + * hooks into global OpenSSL context data. + */ class EXPCL_PANDAEXPRESS OpenSSLWrapper { private: OpenSSLWrapper(); diff --git a/panda/src/express/ordered_vector.I b/panda/src/express/ordered_vector.I index 6a5350f079..68a70b39a3 100644 --- a/panda/src/express/ordered_vector.I +++ b/panda/src/express/ordered_vector.I @@ -1,23 +1,19 @@ -// Filename: ordered_vector.I -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ordered_vector.I + * @author drose + * @date 2002-02-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ordered_vector:: ordered_vector(TypeHandle type_handle) : @@ -26,11 +22,9 @@ ordered_vector(TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ordered_vector:: ordered_vector(const Compare &compare, TypeHandle type_handle) : @@ -39,11 +33,9 @@ ordered_vector(const Compare &compare, TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ordered_vector:: ordered_vector(const ordered_vector ©) : @@ -52,11 +44,9 @@ ordered_vector(const ordered_vector ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ordered_vector &ordered_vector:: operator = (const ordered_vector ©) { @@ -65,239 +55,190 @@ operator = (const ordered_vector ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ordered_vector:: ~ordered_vector() { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::begin -// Access: Public -// Description: Returns the iterator that marks the first element in -// the ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the first element in the ordered vector. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: begin() { return _vector.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::end -// Access: Public -// Description: Returns the iterator that marks the end of the -// ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the end of the ordered vector. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: end() { return _vector.end(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::rbegin -// Access: Public -// Description: Returns the iterator that marks the first element in -// the ordered vector, when viewed in reverse order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the first element in the ordered vector, + * when viewed in reverse order. + */ template INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: rbegin() { return _vector.rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::rend -// Access: Public -// Description: Returns the iterator that marks the end of the -// ordered vector, when viewed in reverse order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the end of the ordered vector, when viewed + * in reverse order. + */ template INLINE TYPENAME ordered_vector::REVERSE_ITERATOR ordered_vector:: rend() { return _vector.rend(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::begin -// Access: Public -// Description: Returns the iterator that marks the first element in -// the ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the first element in the ordered vector. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: begin() const { return _vector.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::end -// Access: Public -// Description: Returns the iterator that marks the end of the -// ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the end of the ordered vector. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: end() const { return _vector.end(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::rbegin -// Access: Public -// Description: Returns the iterator that marks the first element in -// the ordered vector, when viewed in reverse order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the first element in the ordered vector, + * when viewed in reverse order. + */ template INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rbegin() const { return _vector.rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::rend -// Access: Public -// Description: Returns the iterator that marks the end of the -// ordered vector, when viewed in reverse order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator that marks the end of the ordered vector, when viewed + * in reverse order. + */ template INLINE TYPENAME ordered_vector::CONST_REVERSE_ITERATOR ordered_vector:: rend() const { return _vector.rend(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator [] -// Access: Public -// Description: Returns the nth element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth element. + */ template INLINE TYPENAME ordered_vector::REFERENCE ordered_vector:: operator [] (TYPENAME ordered_vector::SIZE_TYPE n) { return _vector[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator [] -// Access: Public -// Description: Returns the nth element. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth element. + */ template INLINE TYPENAME ordered_vector::CONST_REFERENCE ordered_vector:: operator [] (TYPENAME ordered_vector::SIZE_TYPE n) const { return _vector[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::size -// Access: Public -// Description: Returns the number of elements in the ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the ordered vector. + */ template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: size() const { return _vector.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::max_size -// Access: Public -// Description: Returns the maximum number of elements that can -// possibly be stored in an ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of elements that can possibly be stored in an + * ordered vector. + */ template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: max_size() const { return _vector.max_size(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::empty -// Access: Public -// Description: Returns true if the ordered vector is empty, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ordered vector is empty, false otherwise. + */ template INLINE bool ordered_vector:: empty() const { return _vector.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator == -// Access: Public -// Description: Returns true if the two ordered vectors are -// memberwise equivalent, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two ordered vectors are memberwise equivalent, false + * otherwise. + */ template INLINE bool ordered_vector:: operator == (const ordered_vector &other) const { return _vector == other._vector; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator != -// Access: Public -// Description: Returns true if the two ordered vectors are not -// memberwise equivalent, false if they are. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two ordered vectors are not memberwise equivalent, + * false if they are. + */ template INLINE bool ordered_vector:: operator != (const ordered_vector &other) const { return _vector != other._vector; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator < -// Access: Public -// Description: Returns true if this ordered vector sorts -// lexicographically before the other one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ordered vector sorts lexicographically before the + * other one, false otherwise. + */ template INLINE bool ordered_vector:: operator < (const ordered_vector &other) const { return _vector < other._vector; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator > -// Access: Public -// Description: Returns true if this ordered vector sorts -// lexicographically after the other one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ordered vector sorts lexicographically after the other + * one, false otherwise. + */ template INLINE bool ordered_vector:: operator > (const ordered_vector &other) const { return _vector > other._vector; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator <= -// Access: Public -// Description: Returns true if this ordered vector sorts -// lexicographically before the other one or is -// equivalent, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ordered vector sorts lexicographically before the + * other one or is equivalent, false otherwise. + */ template INLINE bool ordered_vector:: operator <= (const ordered_vector &other) const { return _vector <= other._vector; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::operator >= -// Access: Public -// Description: Returns true if this ordered vector sorts -// lexicographically after the other one or is -// equivalent, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ordered vector sorts lexicographically after the other + * one or is equivalent, false otherwise. + */ template INLINE bool ordered_vector:: operator >= (const ordered_vector &other) const { @@ -305,19 +246,15 @@ operator >= (const ordered_vector &other) const { } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_unique -// Access: Public -// Description: Inserts the indicated key into the ordered vector, at -// the appropriate place. If there is already an element -// sorting equivalent to the key in the vector, the new -// key is not inserted. -// -// The return value is a pair, where the first component -// is the iterator referencing the new element (or the -// original element), and the second componet is true if -// the insert operation has taken place. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated key into the ordered vector, at the appropriate + * place. If there is already an element sorting equivalent to the key in the + * vector, the new key is not inserted. + * + * The return value is a pair, where the first component is the iterator + * referencing the new element (or the original element), and the second + * componet is true if the insert operation has taken place. + */ template INLINE pair::ITERATOR, bool> ordered_vector:: insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &key) { @@ -328,8 +265,8 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &k nassertr(position >= begin() && position <= end(), bogus_result); #endif - // If there's already an equivalent key in the vector, it's at - // *(position - 1). + // If there's already an equivalent key in the vector, it's at *(position - + // 1). if (position != begin() && !_compare(*(position - 1), key)) { pair result(position - 1, false); nassertr(!_compare(key, *(position - 1)), result); @@ -340,17 +277,13 @@ insert_unique(const TYPENAME ordered_vector::VALUE_TYPE &k return pair(result, true); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_nonunique -// Access: Public -// Description: Inserts the indicated key into the ordered vector, at -// the appropriate place. If there are already elements -// sorting equivalent to the key in the vector, the new -// value is inserted following them. -// -// The return value is the iterator referencing the new -// element. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated key into the ordered vector, at the appropriate + * place. If there are already elements sorting equivalent to the key in the + * vector, the new value is inserted following them. + * + * The return value is the iterator referencing the new element. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE &key) { @@ -363,29 +296,24 @@ insert_nonunique(const TYPENAME ordered_vector::VALUE_TYPE } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::insert_unverified -// Access: Public -// Description: Inserts the indicated key into the ordered vector at -// the indicated place. The user is trusted to have -// already verified that this is the correct sorting -// position; no checks are made. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated key into the ordered vector at the indicated place. + * The user is trusted to have already verified that this is the correct + * sorting position; no checks are made. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: -insert_unverified(TYPENAME ordered_vector::ITERATOR position, +insert_unverified(TYPENAME ordered_vector::ITERATOR position, const TYPENAME ordered_vector::VALUE_TYPE &key) { TAU_PROFILE("ordered_vector::insert_unverified(iterator, const value_type &)", " ", TAU_USER); ITERATOR result = _vector.insert(position, key); return result; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::erase, with iterator -// Access: Public -// Description: Removes the element indicated by the given iterator, -// and returns the next sequential iterator. -//////////////////////////////////////////////////////////////////// +/** + * Removes the element indicated by the given iterator, and returns the next + * sequential iterator. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: erase(TYPENAME ordered_vector::ITERATOR position) { @@ -395,12 +323,10 @@ erase(TYPENAME ordered_vector::ITERATOR position) { return begin() + count; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::erase, with key -// Access: Public -// Description: Removes all elements matching the indicated key; -// returns the number of elements removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all elements matching the indicated key; returns the number of + * elements removed. + */ template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: erase(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -411,12 +337,9 @@ erase(const TYPENAME ordered_vector::KEY_TYPE &key) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::erase, a range -// Access: Public -// Description: Removes all elements indicated by the given iterator -// range. -//////////////////////////////////////////////////////////////////// +/** + * Removes all elements indicated by the given iterator range. + */ template INLINE void ordered_vector:: erase(TYPENAME ordered_vector::ITERATOR first, @@ -425,11 +348,9 @@ erase(TYPENAME ordered_vector::ITERATOR first, _vector.erase(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::clear -// Access: Public -// Description: Removes all elements from the ordered vector. -//////////////////////////////////////////////////////////////////// +/** + * Removes all elements from the ordered vector. + */ template INLINE void ordered_vector:: clear() { @@ -437,14 +358,11 @@ clear() { _vector.erase(_vector.begin(), _vector.end()); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::find -// Access: Public -// Description: Searches for an element with the indicated key and -// returns its iterator if it is found, or end() if it -// is not. If there are multiple elements matching the -// key, the particular iterator returned is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Searches for an element with the indicated key and returns its iterator if + * it is found, or end() if it is not. If there are multiple elements + * matching the key, the particular iterator returned is not defined. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: find(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -452,14 +370,11 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) { return nci(r_find(begin(), end(), end(), key)); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::find -// Access: Public -// Description: Searches for an element with the indicated key and -// returns its iterator if it is found, or end() if it -// is not. If there are multiple elements matching the -// key, the particular iterator returned is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Searches for an element with the indicated key and returns its iterator if + * it is found, or end() if it is not. If there are multiple elements + * matching the key, the particular iterator returned is not defined. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: find(const TYPENAME ordered_vector::KEY_TYPE &key) const { @@ -467,22 +382,19 @@ find(const TYPENAME ordered_vector::KEY_TYPE &key) const { return r_find(begin(), end(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::find_particular -// Access: Public -// Description: Searches for a particular element and returns its -// iterator if it is found, or end() if it is not. -// -// First, the Compare function is used to narrow down -// the range of elements the element might be located -// within; then the element is compared elementwise, via -// ==, until the exact matching element is found. If -// multiple matches exist within the vector, the -// particular iterator returned is not defined. -// -// The assumption is that == implies !Compare(a, b) and -// !Compare(b, a), but not necessarily the converse. -//////////////////////////////////////////////////////////////////// +/** + * Searches for a particular element and returns its iterator if it is found, + * or end() if it is not. + * + * First, the Compare function is used to narrow down the range of elements + * the element might be located within; then the element is compared + * elementwise, via ==, until the exact matching element is found. If + * multiple matches exist within the vector, the particular iterator returned + * is not defined. + * + * The assumption is that == implies !Compare(a, b) and !Compare(b, a), but + * not necessarily the converse. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -490,19 +402,16 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k return nci(r_find_particular(begin(), end(), end(), key)); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::find_particular -// Access: Public -// Description: Searches for a particular element and returns its -// iterator if it is found, or end() if it is not. -// -// First, the Compare function is used to narrow down -// the range of elements the element might be located -// within; then the element is compared elementwise, via -// ==, until the exact matching element is found. If -// multiple matches exist within the vector, the -// particular iterator returned is not defined./ -//////////////////////////////////////////////////////////////////// +/** + * Searches for a particular element and returns its iterator if it is found, + * or end() if it is not. + * + * First, the Compare function is used to narrow down the range of elements + * the element might be located within; then the element is compared + * elementwise, via ==, until the exact matching element is found. If + * multiple matches exist within the vector, the particular iterator returned + * is not defined. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: find_particular(const TYPENAME ordered_vector::KEY_TYPE &key) const { @@ -510,12 +419,10 @@ find_particular(const TYPENAME ordered_vector::KEY_TYPE &k return r_find_particular(begin(), end(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::count -// Access: Public -// Description: Returns the number of elements that sort equivalent -// to the key that are in the vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements that sort equivalent to the key that are in + * the vector. + */ template INLINE TYPENAME ordered_vector::SIZE_TYPE ordered_vector:: count(const key_type &key) const { @@ -523,12 +430,10 @@ count(const key_type &key) const { return r_count(begin(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::lower_bound -// Access: Public -// Description: Returns the iterator for the first element not less -// than key, or end() if all elements are less than key. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator for the first element not less than key, or end() if + * all elements are less than key. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -536,12 +441,10 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) return nci(r_lower_bound(begin(), end(), key)); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::lower_bound -// Access: Public -// Description: Returns the iterator for the first element not less -// than key, or end() if all elements are less than key. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator for the first element not less than key, or end() if + * all elements are less than key. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { @@ -549,13 +452,10 @@ lower_bound(const TYPENAME ordered_vector::KEY_TYPE &key) return r_lower_bound(begin(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::upper_bound -// Access: Public -// Description: Returns the iterator for the first element greater -// than key, or end() if no element is greater than -// key. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator for the first element greater than key, or end() if no + * element is greater than key. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -563,13 +463,10 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) return nci(r_upper_bound(begin(), end(), key)); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::upper_bound -// Access: Public -// Description: Returns the iterator for the first element greater -// than key, or end() if no element is greater than -// key. -//////////////////////////////////////////////////////////////////// +/** + * Returns the iterator for the first element greater than key, or end() if no + * element is greater than key. + */ template INLINE TYPENAME ordered_vector::CONST_ITERATOR ordered_vector:: upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) const { @@ -577,11 +474,9 @@ upper_bound(const TYPENAME ordered_vector::KEY_TYPE &key) return r_upper_bound(begin(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::equal_range -// Access: Public -// Description: Returns the pair (lower_bound(key), upper_bound(key)). -//////////////////////////////////////////////////////////////////// +/** + * Returns the pair (lower_bound(key), upper_bound(key)). + */ template INLINE pair::ITERATOR, TYPENAME ordered_vector::ITERATOR> ordered_vector:: equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) { @@ -591,11 +486,9 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) return pair::ITERATOR, TYPENAME ordered_vector::ITERATOR>(nci(result.first), nci(result.second)); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::equal_range -// Access: Public -// Description: Returns the pair (lower_bound(key), upper_bound(key)). -//////////////////////////////////////////////////////////////////// +/** + * Returns the pair (lower_bound(key), upper_bound(key)). + */ template INLINE pair::CONST_ITERATOR, TYPENAME ordered_vector::CONST_ITERATOR> ordered_vector:: equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) const { @@ -603,12 +496,10 @@ equal_range(const TYPENAME ordered_vector::KEY_TYPE &key) return r_equal_range(begin(), end(), key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::swap -// Access: Public -// Description: Exchanges the contents of this vector and the other -// vector, in constant time (e.g., with a pointer swap). -//////////////////////////////////////////////////////////////////// +/** + * Exchanges the contents of this vector and the other vector, in constant + * time (e.g., with a pointer swap). + */ template INLINE void ordered_vector:: swap(ordered_vector ©) { @@ -616,13 +507,10 @@ swap(ordered_vector ©) { _vector.swap(copy._vector); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::reserve -// Access: Public -// Description: Informs the vector of a planned change in size; -// ensures that the capacity of the vector is greater -// than or equal to n. -//////////////////////////////////////////////////////////////////// +/** + * Informs the vector of a planned change in size; ensures that the capacity + * of the vector is greater than or equal to n. + */ template INLINE void ordered_vector:: reserve(TYPENAME ordered_vector::SIZE_TYPE n) { @@ -630,18 +518,14 @@ reserve(TYPENAME ordered_vector::SIZE_TYPE n) { _vector.reserve(n); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::sort_unique -// Access: Public -// Description: Ensures that the vector is properly sorted after a -// potentially damaging operation. This should not -// normally need to be called, unless the user has -// written to the vector using the non-const iterators -// or has called push_back(). -// -// This flavor of sort also eliminates repeated -// elements. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the vector is properly sorted after a potentially damaging + * operation. This should not normally need to be called, unless the user has + * written to the vector using the non-const iterators or has called + * push_back(). + * + * This flavor of sort also eliminates repeated elements. + */ template INLINE void ordered_vector:: sort_unique() { @@ -651,15 +535,12 @@ sort_unique() { erase(new_end, end()); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::sort_nonunique -// Access: Public -// Description: Ensures that the vector is properly sorted after a -// potentially damaging operation. This should not -// normally need to be called, unless the user has -// written to the vector using the non-const iterators -// or has called push_back(). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the vector is properly sorted after a potentially damaging + * operation. This should not normally need to be called, unless the user has + * written to the vector using the non-const iterators or has called + * push_back(). + */ template INLINE void ordered_vector:: sort_nonunique() { @@ -667,14 +548,11 @@ sort_nonunique() { stable_sort(begin(), end(), _compare); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::push_back -// Access: Public -// Description: Adds the new element to the end of the vector without -// regard for proper sorting. This is a bad idea to do -// except to populate the vector the first time; be sure -// to call sort() after you have added all the elements. -//////////////////////////////////////////////////////////////////// +/** + * Adds the new element to the end of the vector without regard for proper + * sorting. This is a bad idea to do except to populate the vector the first + * time; be sure to call sort() after you have added all the elements. + */ template INLINE void ordered_vector:: push_back(const value_type &key) { @@ -682,11 +560,9 @@ push_back(const value_type &key) { _vector.push_back(key); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::pop_back -// Access: Public -// Description: Removes the last element at the end of the vector. -//////////////////////////////////////////////////////////////////// +/** + * Removes the last element at the end of the vector. + */ template INLINE void ordered_vector:: pop_back() { @@ -694,13 +570,10 @@ pop_back() { _vector.pop_back(); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::resize -// Access: Public -// Description: Resizes the vector to contain n elements. This -// should not be used except to populate the vector -// for the first time. -//////////////////////////////////////////////////////////////////// +/** + * Resizes the vector to contain n elements. This should not be used except + * to populate the vector for the first time. + */ template INLINE void ordered_vector:: resize(SIZE_TYPE n) { @@ -708,13 +581,10 @@ resize(SIZE_TYPE n) { _vector.resize(n); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::resize -// Access: Public -// Description: Resizes the vector to contain n elements. This -// should not be used except to populate the vector -// for the first time. -//////////////////////////////////////////////////////////////////// +/** + * Resizes the vector to contain n elements. This should not be used except + * to populate the vector for the first time. + */ template INLINE void ordered_vector:: resize(SIZE_TYPE n, const VALUE_TYPE &value) { @@ -722,27 +592,21 @@ resize(SIZE_TYPE n, const VALUE_TYPE &value) { _vector.resize(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::nci -// Access: Private -// Description: I.e. "non-const iterator". This function is used to -// typecast a const iterator to a non-const iterator for -// easy definition of const vs. non-const flavors of -// some of these methods. -//////////////////////////////////////////////////////////////////// +/** + * I.e. "non-const iterator". This function is used to typecast a const + * iterator to a non-const iterator for easy definition of const vs. non- + * const flavors of some of these methods. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: nci(TYPENAME ordered_vector::CONST_ITERATOR i) { return begin() + (i - begin()); } -//////////////////////////////////////////////////////////////////// -// Function: ordered_vector::find_insert_position -// Access: Private -// Description: Searches for the appropriate place in the ordered -// vector to insert the indicated key, and returns the -// corresponding iterator. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the appropriate place in the ordered vector to insert the + * indicated key, and returns the corresponding iterator. + */ template INLINE TYPENAME ordered_vector::ITERATOR ordered_vector:: find_insert_position(TYPENAME ordered_vector::ITERATOR first, @@ -752,11 +616,9 @@ find_insert_position(TYPENAME ordered_vector::ITERATOR fir return result; } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_set:: ov_set(TypeHandle type_handle) : @@ -764,11 +626,9 @@ ov_set(TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_set:: ov_set(const Compare &compare, TypeHandle type_handle) : @@ -776,11 +636,9 @@ ov_set(const Compare &compare, TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_set:: ov_set(const ov_set ©) : @@ -788,11 +646,9 @@ ov_set(const ov_set ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_set &ov_set:: operator = (const ov_set ©) { @@ -800,56 +656,46 @@ operator = (const ov_set ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::insert -// Access: Public -// Description: Maps to insert_unique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to insert_unique(). + */ template TYPENAME ov_set::ITERATOR ov_set:: -insert(TYPENAME ov_set::ITERATOR position, +insert(TYPENAME ov_set::ITERATOR position, const TYPENAME ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(position, key); } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::insert -// Access: Public -// Description: Maps to insert_unique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to insert_unique(). + */ template INLINE pair::ITERATOR, bool> ov_set:: insert(const TYPENAME ov_set::VALUE_TYPE &key) { return ordered_vector::insert_unique(key); } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::sort -// Access: Public -// Description: Maps to sort_unique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to sort_unique(). + */ template INLINE void ov_set:: sort() { ordered_vector::sort_unique(); } -//////////////////////////////////////////////////////////////////// -// Function: ov_set::verify_list -// Access: Public -// Description: Maps to verify_list_unique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to verify_list_unique(). + */ template INLINE bool ov_set:: verify_list() const { return ordered_vector::verify_list_unique(); } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_multiset:: ov_multiset(TypeHandle type_handle) : @@ -857,11 +703,9 @@ ov_multiset(TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_multiset:: ov_multiset(const Compare &compare, TypeHandle type_handle) : @@ -869,11 +713,9 @@ ov_multiset(const Compare &compare, TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_multiset:: ov_multiset(const ov_multiset ©) : @@ -881,11 +723,9 @@ ov_multiset(const ov_multiset ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ov_multiset &ov_multiset:: operator = (const ov_multiset ©) { @@ -893,45 +733,37 @@ operator = (const ov_multiset ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::insert -// Access: Public -// Description: Maps to insert_nonunique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to insert_nonunique(). + */ template TYPENAME ov_multiset::ITERATOR ov_multiset:: -insert(TYPENAME ov_multiset::ITERATOR position, +insert(TYPENAME ov_multiset::ITERATOR position, const TYPENAME ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(position, key); } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::insert -// Access: Public -// Description: Maps to insert_nonunique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to insert_nonunique(). + */ template INLINE TYPENAME ov_multiset::ITERATOR ov_multiset:: insert(const TYPENAME ov_multiset::VALUE_TYPE &key) { return ordered_vector::insert_nonunique(key); } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::sort -// Access: Public -// Description: Maps to sort_nonunique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to sort_nonunique(). + */ template INLINE void ov_multiset:: sort() { ordered_vector::sort_nonunique(); } -//////////////////////////////////////////////////////////////////// -// Function: ov_multiset::verify_list -// Access: Public -// Description: Maps to verify_list_nonunique(). -//////////////////////////////////////////////////////////////////// +/** + * Maps to verify_list_nonunique(). + */ template INLINE bool ov_multiset:: verify_list() const { diff --git a/panda/src/express/ordered_vector.cxx b/panda/src/express/ordered_vector.cxx index a56fa61b93..dc22fa9eec 100644 --- a/panda/src/express/ordered_vector.cxx +++ b/panda/src/express/ordered_vector.cxx @@ -1,15 +1,14 @@ -// Filename: ordered_vector.cxx -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ordered_vector.cxx + * @author drose + * @date 2002-02-20 + */ #include "ordered_vector.h" diff --git a/panda/src/express/ordered_vector.h b/panda/src/express/ordered_vector.h index 2eebdcfa23..aa84cc4511 100644 --- a/panda/src/express/ordered_vector.h +++ b/panda/src/express/ordered_vector.h @@ -1,26 +1,24 @@ -// Filename: ordered_vector.h -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ordered_vector.h + * @author drose + * @date 2002-02-20 + */ #ifndef ORDERED_VECTOR_H #define ORDERED_VECTOR_H #ifdef CPPPARSER // hack around this for interigate... -//****** HACK allert *** -// this code is intended to tell interigate to not expand this class definition past basic names -// It drops the interigate memory foot pront and user time by a bunch -// on pc cygwin from 3 minutes to 17 seconds ?? really need to explore interigate to figure out what is -// going on .. -// +// ****** HACK allert *** this code is intended to tell interigate to not +// expand this class definition past basic names It drops the interigate +// memory foot pront and user time by a bunch on pc cygwin from 3 minutes to +// 17 seconds ?? really need to explore interigate to figure out what is going +// on .. template, class Vector = pvector > class ov_multiset { }; @@ -43,18 +41,16 @@ template, class Vector = pvector > cla #include "pnotify.h" #include -// There are some inheritance issues with template classes and typedef -// names. Template classes that inherit typedef names from their base -// class, which is also a template class, may confuse the typedef -// names with globally scoped template names. In particular, the -// local "iterator" type is easily confused with the std::iterator -// template class. +// There are some inheritance issues with template classes and typedef names. +// Template classes that inherit typedef names from their base class, which is +// also a template class, may confuse the typedef names with globally scoped +// template names. In particular, the local "iterator" type is easily +// confused with the std::iterator template class. -// To work around this problem, as well as a problem in gcc 2.95.3 -// with value_type etc. not inheriting properly (even though we -// explicitly typedef them in the derived class), we rename the -// questionable typedefs here so that they no longer conflict with the -// global template classes. +// To work around this problem, as well as a problem in gcc 2.95.3 with +// value_type etc. not inheriting properly (even though we explicitly typedef +// them in the derived class), we rename the questionable typedefs here so +// that they no longer conflict with the global template classes. #define KEY_TYPE key_type_0 #define VALUE_TYPE value_type_0 @@ -69,42 +65,32 @@ template, class Vector = pvector > cla #define DIFFERENCE_TYPE difference_type_0 #define SIZE_TYPE size_type_0 -//////////////////////////////////////////////////////////////////// -// Class : ordered_vector -// Description : This template class presents an interface similar to -// the STL set or multiset (and ov_set and ov_multiset -// are implemented specifically, below), but it is -// implemented using a vector that is kept always in -// sorted order. -// -// In most cases, an ov_set or ov_multiset may be -// dropped in transparently in place of a set or -// multiset, but the implementation difference has a few -// implications: -// -// (1) The ov_multiset will maintain stability of order -// between elements that sort equally: they are stored -// in the order in which they were added, from back to -// front. -// -// (2) Insert and erase operations into the middle of -// the set can be slow, just as inserting into the -// middle of a vector can be slow. In fact, building up -// an ov_set by inserting elements one at a time is an -// n^2 operation. On the other hand, building up an -// ov_set by adding elements to the end, one at time, is -// somewhat faster than building up a traditional set; -// and you can even add unsorted elements with -// push_back() and then call sort() when you're done, -// for a log(n) operation. -// -// (3) Iterators may not be valid for the life of the -// ordered_vector. If the vector reallocates itself, -// all iterators are invalidated. -// -// (4) Random access into the set is easy with the [] -// operator. -//////////////////////////////////////////////////////////////////// +/** + * This template class presents an interface similar to the STL set or + * multiset (and ov_set and ov_multiset are implemented specifically, below), + * but it is implemented using a vector that is kept always in sorted order. + * + * In most cases, an ov_set or ov_multiset may be dropped in transparently in + * place of a set or multiset, but the implementation difference has a few + * implications: + * + * (1) The ov_multiset will maintain stability of order between elements that + * sort equally: they are stored in the order in which they were added, from + * back to front. + * + * (2) Insert and erase operations into the middle of the set can be slow, + * just as inserting into the middle of a vector can be slow. In fact, + * building up an ov_set by inserting elements one at a time is an n^2 + * operation. On the other hand, building up an ov_set by adding elements to + * the end, one at time, is somewhat faster than building up a traditional + * set; and you can even add unsorted elements with push_back() and then call + * sort() when you're done, for a log(n) operation. + * + * (3) Iterators may not be valid for the life of the ordered_vector. If the + * vector reallocates itself, all iterators are invalidated. + * + * (4) Random access into the set is easy with the [] operator. + */ template, class Vector = pvector > class ordered_vector { public: @@ -116,9 +102,9 @@ public: typedef Compare KEY_COMPARE; typedef Compare VALUE_COMPARE; - // Be careful when using the non-const iterators that you do not - // disturb the sorted order of the vector, or that if you do, you - // call sort() when you are done. + // Be careful when using the non-const iterators that you do not disturb the + // sorted order of the vector, or that if you do, you call sort() when you + // are done. typedef TYPENAME Vector::iterator ITERATOR; typedef TYPENAME Vector::const_iterator CONST_ITERATOR; typedef TYPENAME Vector::reverse_iterator REVERSE_ITERATOR; @@ -127,9 +113,9 @@ public: typedef TYPENAME Vector::difference_type DIFFERENCE_TYPE; typedef TYPENAME Vector::size_type SIZE_TYPE; - // Since the #define symbols do not actually expand to the correct - // names, we have to re-typedef them so callers can reference them - // by their correct, lowercase names. + // Since the #define symbols do not actually expand to the correct names, we + // have to re-typedef them so callers can reference them by their correct, + // lowercase names. typedef KEY_TYPE key_type; typedef VALUE_TYPE value_type; typedef REFERENCE reference; @@ -144,8 +130,8 @@ public: typedef SIZE_TYPE size_type; public: - // Constructors. We don't implement the whole slew of STL - // constructors here yet. + // Constructors. We don't implement the whole slew of STL constructors here + // yet. INLINE ordered_vector(TypeHandle type_handle = ov_set_type_handle); INLINE ordered_vector(const Compare &compare, TypeHandle type_handle = ov_set_type_handle); @@ -224,9 +210,9 @@ public: private: INLINE ITERATOR nci(CONST_ITERATOR i); - INLINE ITERATOR find_insert_position(ITERATOR first, ITERATOR last, + INLINE ITERATOR find_insert_position(ITERATOR first, ITERATOR last, const KEY_TYPE &key); - ITERATOR r_find_insert_position(ITERATOR first, ITERATOR last, + ITERATOR r_find_insert_position(ITERATOR first, ITERATOR last, const KEY_TYPE &key); CONST_ITERATOR r_find(CONST_ITERATOR first, CONST_ITERATOR last, CONST_ITERATOR not_found, @@ -244,14 +230,14 @@ private: r_equal_range(CONST_ITERATOR first, CONST_ITERATOR last, const KEY_TYPE &key) const; - // This function object is used in sort_unique(). It returns true - // if two consecutive sorted elements are equivalent. + // This function object is used in sort_unique(). It returns true if two + // consecutive sorted elements are equivalent. class EquivalentTest { public: - // For some reason, VC++ won't allow us to define these bodies - // outside the class; they must be defined here. The error - // message is C3206: "member functions of nested classes of a - // template class cannot be defined outside the class". + // For some reason, VC++ won't allow us to define these bodies outside the + // class; they must be defined here. The error message is C3206: "member + // functions of nested classes of a template class cannot be defined + // outside the class". INLINE EquivalentTest(const Compare &compare) : _compare(compare) { } INLINE bool operator () (const KEY_TYPE &a, const KEY_TYPE &b) { @@ -266,12 +252,10 @@ private: Vector _vector; }; -//////////////////////////////////////////////////////////////////// -// Class : ov_set -// Description : A specialization of ordered_vector that emulates a -// standard STL set: one copy of each element is -// allowed. -//////////////////////////////////////////////////////////////////// +/** + * A specialization of ordered_vector that emulates a standard STL set: one + * copy of each element is allowed. + */ template, class Vector = pvector > class ov_set : public ordered_vector { public: @@ -291,12 +275,10 @@ public: INLINE bool verify_list() const; }; -//////////////////////////////////////////////////////////////////// -// Class : ov_multiset -// Description : A specialization of ordered_vector that emulates a -// standard STL set: many copies of each element are -// allowed. -//////////////////////////////////////////////////////////////////// +/** + * A specialization of ordered_vector that emulates a standard STL set: many + * copies of each element are allowed. + */ template, class Vector = pvector > class ov_multiset : public ordered_vector { public: diff --git a/panda/src/express/pStatCollectorForwardBase.cxx b/panda/src/express/pStatCollectorForwardBase.cxx index bfad328b7c..6dae9f5702 100644 --- a/panda/src/express/pStatCollectorForwardBase.cxx +++ b/panda/src/express/pStatCollectorForwardBase.cxx @@ -1,27 +1,23 @@ -// Filename: pStatCollectorForwardBase.cxx -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorForwardBase.cxx + * @author drose + * @date 2006-10-30 + */ #include "pStatCollectorForwardBase.h" #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorForwardBase::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatCollectorForwardBase:: ~PStatCollectorForwardBase() { } #endif // DO_PSTATS - diff --git a/panda/src/express/pStatCollectorForwardBase.h b/panda/src/express/pStatCollectorForwardBase.h index 07be53f14a..79e53d8060 100644 --- a/panda/src/express/pStatCollectorForwardBase.h +++ b/panda/src/express/pStatCollectorForwardBase.h @@ -1,16 +1,15 @@ -// Filename: pStatCollectorForwardBase.h -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorForwardBase.h + * @author drose + * @date 2006-10-30 + */ #ifndef PSTATCOLLECTORFORWARDBASE_H #define PSTATCOLLECTORFORWARDBASE_H @@ -18,16 +17,14 @@ #include "pandabase.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : PStatCollectorForwardBase -// Description : This class serves as a cheap forward reference to a -// PStatCollector, which is defined in the pstatclient -// module (and is not directly accessible here in the -// express module). -// -// This is subclassed as PStatCollectorForward, which -// defines the actual functionality. -//////////////////////////////////////////////////////////////////// +/** + * This class serves as a cheap forward reference to a PStatCollector, which + * is defined in the pstatclient module (and is not directly accessible here + * in the express module). + * + * This is subclassed as PStatCollectorForward, which defines the actual + * functionality. + */ class EXPCL_PANDAEXPRESS PStatCollectorForwardBase : public ReferenceCount { PUBLISHED: #ifdef DO_PSTATS diff --git a/panda/src/express/password_hash.cxx b/panda/src/express/password_hash.cxx index 34670107e4..a3385013df 100644 --- a/panda/src/express/password_hash.cxx +++ b/panda/src/express/password_hash.cxx @@ -1,60 +1,50 @@ -// Filename: password_hash.cxx -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file password_hash.cxx + * @author drose + * @date 2004-09-01 + */ #include "password_hash.h" -// The functions defined within this file rely on algorithms defined -// within OpenSSL. +// The functions defined within this file rely on algorithms defined within +// OpenSSL. #ifdef HAVE_OPENSSL #include "pnotify.h" #include "openssl/evp.h" #include "memoryHook.h" -//////////////////////////////////////////////////////////////////// -// Function: password_hash -// Access: Published -// Description: Generates a non-reversible hash of a particular -// length based on an arbitrary password and a random -// salt. This is much stronger than the algorithm -// implemented by the standard Unix crypt(). -// -// The resulting hash can be useful for two primary -// purposes: (1) the hash may be recorded to disk in -// lieu of recording plaintext passwords, for validation -// against a password entered by the user later (which -// should produce the same hash given a particular -// salt), or (2) the hash may be used as input to an -// encryption algorithm that requires a key of a -// particular length. -// -// password is the text password provided by a user. -// -// salt should be a string of arbitrary random bytes (it -// need not be crypotographically secure, just different -// for each different hash). -// -// iters should be a number in the thousands to indicate -// the number of times the hash algorithm should be -// applied. In general, iters should be chosen to make -// the computation as expensive as it can be and still -// be tolerable, to reduce the attractiveness of a -// brute-force attack. -// -// keylen is the length in bytes of the required key -// hash. -//////////////////////////////////////////////////////////////////// +/** + * Generates a non-reversible hash of a particular length based on an + * arbitrary password and a random salt. This is much stronger than the + * algorithm implemented by the standard Unix crypt(). + * + * The resulting hash can be useful for two primary purposes: (1) the hash may + * be recorded to disk in lieu of recording plaintext passwords, for + * validation against a password entered by the user later (which should + * produce the same hash given a particular salt), or (2) the hash may be used + * as input to an encryption algorithm that requires a key of a particular + * length. + * + * password is the text password provided by a user. + * + * salt should be a string of arbitrary random bytes (it need not be + * crypotographically secure, just different for each different hash). + * + * iters should be a number in the thousands to indicate the number of times + * the hash algorithm should be applied. In general, iters should be chosen + * to make the computation as expensive as it can be and still be tolerable, + * to reduce the attractiveness of a brute-force attack. + * + * keylen is the length in bytes of the required key hash. + */ string password_hash(const string &password, const string &salt, int iters, int keylen) { @@ -74,4 +64,3 @@ password_hash(const string &password, const string &salt, #endif // HAVE_OPENSSL - diff --git a/panda/src/express/password_hash.h b/panda/src/express/password_hash.h index dbaa39fe15..8006d8d9ea 100644 --- a/panda/src/express/password_hash.h +++ b/panda/src/express/password_hash.h @@ -1,24 +1,23 @@ -// Filename: password_hash.h -// Created by: drose (01Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file password_hash.h + * @author drose + * @date 2004-09-01 + */ #ifndef PASSWORD_HASH_H #define PASSWORD_HASH_H #include "pandabase.h" -// The functions defined within this file rely on algorithms defined -// within OpenSSL. +// The functions defined within this file rely on algorithms defined within +// OpenSSL. #ifdef HAVE_OPENSSL BEGIN_PUBLISH diff --git a/panda/src/express/patchfile.I b/panda/src/express/patchfile.I index d7aae93ef2..600c7e92ca 100644 --- a/panda/src/express/patchfile.I +++ b/panda/src/express/patchfile.I @@ -1,26 +1,22 @@ -// Filename: patchfile.I -// Created by: darren, mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patchfile.I + * @author darren, mike + * @date 1997-01-09 + */ -//#include "config_downloader.h" +// #include "config_downloader.h" -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::get_progress -// Access: Published -// Description: Returns a value in the range 0..1, representing the -// amount of progress through the patchfile, during a -// session. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value in the range 0..1, representing the amount of progress + * through the patchfile, during a session. + */ INLINE PN_stdfloat Patchfile:: get_progress() const { if (!_initiated) { @@ -32,94 +28,74 @@ get_progress() const { return ((PN_stdfloat)_total_bytes_processed / (PN_stdfloat)_total_bytes_to_process); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::set_allow_multifile -// Access: Published -// Description: If this flag is set true, the Patchfile will make a -// special case for patching Panda Multifiles, if -// detected, and attempt to patch them on a -// subfile-by-subfile basis. If this flag is false, the -// Patchfile will always patch the file on a full-file -// basis. -// -// This has effect only when building patches; it is not -// used for applying patches. -//////////////////////////////////////////////////////////////////// +/** + * If this flag is set true, the Patchfile will make a special case for + * patching Panda Multifiles, if detected, and attempt to patch them on a + * subfile-by-subfile basis. If this flag is false, the Patchfile will always + * patch the file on a full-file basis. + * + * This has effect only when building patches; it is not used for applying + * patches. + */ INLINE void Patchfile:: set_allow_multifile(bool allow_multifile) { _allow_multifile = allow_multifile; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::get_allow_multifile -// Access: Published -// Description: See set_allow_multifile(). -//////////////////////////////////////////////////////////////////// +/** + * See set_allow_multifile(). + */ INLINE bool Patchfile:: get_allow_multifile() { return _allow_multifile; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::set_footprint_length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Patchfile:: set_footprint_length(int length) { nassertv(length > 0); _footprint_length = length; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::get_footprint_length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int Patchfile:: get_footprint_length() { return _footprint_length; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::reset_footprint_length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Patchfile:: reset_footprint_length() { _footprint_length = _DEFAULT_FOOTPRINT_LENGTH; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::has_source_hash -// Access: Published -// Description: Returns true if the MD5 hash for the source file is -// known. (Some early versions of the patch file did -// not store this information.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the MD5 hash for the source file is known. (Some early + * versions of the patch file did not store this information.) + */ INLINE bool Patchfile:: has_source_hash() const { return (_version_number >= 1); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::get_source_hash -// Access: Published -// Description: Returns the MD5 hash for the source file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MD5 hash for the source file. + */ INLINE const HashVal &Patchfile:: get_source_hash() const { nassertr(has_source_hash(), _MD5_ofSource); return _MD5_ofSource; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::get_result_hash -// Access: Published -// Description: Returns the MD5 hash for the file after the patch has -// been applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MD5 hash for the file after the patch has been applied. + */ INLINE const HashVal &Patchfile:: get_result_hash() const { return _MD5_ofResult; diff --git a/panda/src/express/patchfile.cxx b/panda/src/express/patchfile.cxx index 4d20403df6..b43e58456c 100644 --- a/panda/src/express/patchfile.cxx +++ b/panda/src/express/patchfile.cxx @@ -1,16 +1,15 @@ -// Filename: patchfile.cxx -// Created by: darren, mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patchfile.cxx + * @author darren, mike + * @date 1997-01-09 + */ #include "pandabase.h" @@ -36,53 +35,37 @@ istream *Patchfile::_tar_istream = NULL; #endif // HAVE_TAR -// this actually slows things down... -//#define USE_MD5_FOR_HASHTABLE_INDEX_VALUES +// this actually slows things down... #define +// USE_MD5_FOR_HASHTABLE_INDEX_VALUES -//////////////////////////////////////////////////////////////////// -// Patch File Format -// IF THIS CHANGES, UPDATE installerApplyPatch.cxx IN THE INSTALLER -// -// [ HEADER ] -// 4 bytes 0xfeebfaac ("magic number") -// (older patch files have a magic number 0xfeebfaab, -// indicating they are version number 0.) -// 2 bytes version number (if magic number == 0xfeebfaac) -// 4 bytes length of starting file (if version >= 1) -// 16 bytes MD5 of starting file (if version >= 1) -// 4 bytes length of resulting patched file -// 16 bytes MD5 of resultant patched file -// -// Note that MD5 hashes are written in the order observed by -// HashVal::read_stream() and HashVal::write_stream(), which is not -// the normal linear order. (Each group of four bytes is reversed.) -//////////////////////////////////////////////////////////////////// +/* + * Patch File Format IF THIS CHANGES, UPDATE installerApplyPatch.cxx IN THE + * INSTALLER [ HEADER ] 4 bytes 0xfeebfaac ("magic number") (older patch + * files have a magic number 0xfeebfaab, indicating they are version number + * 0.) 2 bytes version number (if magic number == 0xfeebfaac) 4 bytes length + * of starting file (if version >= 1) 16 bytes MD5 of starting file (if + * version >= 1) 4 bytes length of resulting patched file 16 bytes MD5 of + * resultant patched file Note that MD5 hashes are written in the order + * observed by HashVal::read_stream() and HashVal::write_stream(), which is + * not the normal linear order. (Each group of four bytes is reversed.) + */ const int _v0_header_length = 4 + 4 + 16; const int _v1_header_length = 4 + 2 + 4 + 16 + 4 + 16; -//////////////////////////////////////////////////////////////////// -// [ ADD/COPY pairs; repeated N times ] -// 2 bytes AL = ADD length -// AL bytes bytes to add -// 2 bytes CL = COPY length -// 4 bytes offset of data to copy from original file, if CL != 0. -// If version >= 2, offset is relative to end of previous -// copy block; if version < 2, offset is relative to -// beginning of file. -// -// [ TERMINATOR ] -// 2 bytes zero-length ADD -// 2 bytes zero-length COPY -//////////////////////////////////////////////////////////////////// +/* + * [ ADDCOPY pairs; repeated N times ] 2 bytes AL = ADD length AL bytes + * bytes to add 2 bytes CL = COPY length 4 bytes offset of data to copy from + * original file, if CL != 0. If version >= 2, offset is relative to end of + * previous copy block; if version < 2, offset is relative to beginning of + * file. [ TERMINATOR ] 2 bytes zero-length ADD 2 bytes zero-length COPY + */ -//////////////////////////////////////////////////////////////////// // Defines -//////////////////////////////////////////////////////////////////// const PN_uint32 Patchfile::_v0_magic_number = 0xfeebfaab; const PN_uint32 Patchfile::_magic_number = 0xfeebfaac; -// Created version 1 on 11/2/02 to store length and MD5 of original file. -// To version 2 on 11/2/02 to store copy offsets as relative. +// Created version 1 on 11202 to store length and MD5 of original file. To +// version 2 on 11202 to store copy offsets as relative. const PN_uint16 Patchfile::_current_version = 2; const PN_uint32 Patchfile::_HASH_BITS = 24; @@ -92,32 +75,26 @@ const PN_uint32 Patchfile::_NULL_VALUE = PN_uint32(0) - 1; const PN_uint32 Patchfile::_MAX_RUN_LENGTH = (PN_uint32(1) << 16) - 1; const PN_uint32 Patchfile::_HASH_MASK = (PN_uint32(1) << Patchfile::_HASH_BITS) - 1; -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::Constructor -// Access: Public -// Description: Create a patch file and initializes internal data -//////////////////////////////////////////////////////////////////// +/** + * Create a patch file and initializes internal data + */ Patchfile:: Patchfile() { PT(Buffer) buffer = new Buffer(patchfile_buffer_size); init(buffer); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::Constructor -// Access: Public -// Description: Create patch file with buffer to patch -//////////////////////////////////////////////////////////////////// +/** + * Create patch file with buffer to patch + */ Patchfile:: Patchfile(PT(Buffer) buffer) { init(buffer); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::init -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Patchfile:: init(PT(Buffer) buffer) { _rename_output_to_orig = false; @@ -136,11 +113,9 @@ init(PT(Buffer) buffer) { reset_footprint_length(); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Patchfile:: ~Patchfile() { if (_hash_table != (PN_uint32 *)NULL) { @@ -155,11 +130,9 @@ Patchfile:: nassertv(_origfile_stream == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::cleanup -// Access: Private -// Description: Closes and clean up internal data structures -//////////////////////////////////////////////////////////////////// +/** + * Closes and clean up internal data structures + */ void Patchfile:: cleanup() { if (!_initiated) { @@ -184,23 +157,17 @@ cleanup() { _initiated = false; } -//////////////////////////////////////////////////////////////////// -///// PATCH FILE APPLY MEMBER FUNCTIONS +// PATCH FILE APPLY MEMBER FUNCTIONS -//////////////////////////////////////////////////////////////////// -///// NOTE: this patch-application functionality unfortunately has to be -///// duplicated in the Installer. It is contained in the file -///// installerApplyPatch.cxx -///// PLEASE MAKE SURE THAT THAT FILE GETS UPDATED IF ANY OF THIS -///// LOGIC CHANGES! (i.e. if the patch file format changes) -//////////////////////////////////////////////////////////////////// +// NOTE: this patch-application functionality unfortunately has to be +// duplicated in the Installer. It is contained in the file +// installerApplyPatch.cxx PLEASE MAKE SURE THAT THAT FILE GETS UPDATED IF ANY +// OF THIS LOGIC CHANGES! (i.e. if the patch file format changes) -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::initiate -// Access: Published -// Description: Set up to apply the patch to the file (original -// file and patch are destroyed in the process). -//////////////////////////////////////////////////////////////////// +/** + * Set up to apply the patch to the file (original file and patch are + * destroyed in the process). + */ int Patchfile:: initiate(const Filename &patch_file, const Filename &file) { int result = initiate(patch_file, file, Filename::temporary("", "patch_")); @@ -209,13 +176,10 @@ initiate(const Filename &patch_file, const Filename &file) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::initiate -// Access: Published -// Description: Set up to apply the patch to the file. In this form, -// neither the original file nor the patch file are -// destroyed. -//////////////////////////////////////////////////////////////////// +/** + * Set up to apply the patch to the file. In this form, neither the original + * file nor the patch file are destroyed. + */ int Patchfile:: initiate(const Filename &patch_file, const Filename &orig_file, const Filename &target_file) { @@ -262,14 +226,11 @@ initiate(const Filename &patch_file, const Filename &orig_file, return result; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::read_header -// Access: Published -// Description: Opens the patch file for reading, and gets the header -// information from the file but does not begin to do -// any real work. This can be used to query the data -// stored in the patch. -//////////////////////////////////////////////////////////////////// +/** + * Opens the patch file for reading, and gets the header information from the + * file but does not begin to do any real work. This can be used to query the + * data stored in the patch. + */ int Patchfile:: read_header(const Filename &patch_file) { if (_initiated) { @@ -288,18 +249,13 @@ read_header(const Filename &patch_file) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::run -// Access: Published -// Description: Perform one buffer's worth of patching -// Returns EU_ok while patching -// Returns EU_success when done -// If error happens will return one of: -// EU_error_abort : Patching has not been initiated -// EU_error_file_invalid : file is corrupted -// EU_error_invalid_checksum : incompatible patch file -// EU_error_write_file_rename : could not rename file -//////////////////////////////////////////////////////////////////// +/** + * Perform one buffer's worth of patching Returns EU_ok while patching Returns + * EU_success when done If error happens will return one of: EU_error_abort : + * Patching has not been initiated EU_error_file_invalid : file is corrupted + * EU_error_invalid_checksum : incompatible patch file + * EU_error_write_file_rename : could not rename file + */ int Patchfile:: run() { // Now patch the file using the given buffer @@ -341,7 +297,8 @@ run() { return EU_error_file_invalid; } - // if there are bytes to add, read them from patch file and write them to output + // if there are bytes to add, read them from patch file and write them to + // output if (express_cat.is_spam() && ADD_length != 0) { express_cat.spam() << "ADD: " << ADD_length << " (to " @@ -378,7 +335,8 @@ run() { return EU_error_file_invalid; } - // if there are bytes to copy, read them from original file and write them to output + // if there are bytes to copy, read them from original file and write them + // to output if (0 != COPY_length) { // read copy offset nassertr(_buffer->get_length() >= (int)sizeof(COPY_offset), false); @@ -431,7 +389,7 @@ run() { if (express_cat.is_debug()) { express_cat.debug() - //<< "result file = " << _result_file_length + // << "result file = " << _result_file_length << " total bytes = " << _total_bytes_processed << endl; } @@ -455,8 +413,7 @@ run() { << " " << _MD5_ofResult << "\n"; - // This is a fine time to double-check the starting - // checksum. + // This is a fine time to double-check the starting checksum. if (!has_source_hash()) { express_cat.info() << "No source hash in patch file to verify.\n"; @@ -513,15 +470,12 @@ run() { return EU_ok; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::apply -// Access: Public -// Description: Patches the entire file in one call -// returns true on success and false on error -// -// This version will delete the patch file and overwrite -// the original file. -//////////////////////////////////////////////////////////////////// +/** + * Patches the entire file in one call returns true on success and false on + * error + * + * This version will delete the patch file and overwrite the original file. + */ bool Patchfile:: apply(Filename &patch_file, Filename &file) { int ret = initiate(patch_file, file); @@ -537,14 +491,12 @@ apply(Filename &patch_file, Filename &file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::apply -// Access: Public -// Description: Patches the entire file in one call -// returns true on success and false on error -// -// This version will not delete any files. -//////////////////////////////////////////////////////////////////// +/** + * Patches the entire file in one call returns true on success and false on + * error + * + * This version will not delete any files. + */ bool Patchfile:: apply(Filename &patch_file, Filename &orig_file, const Filename &target_file) { int ret = initiate(patch_file, orig_file, target_file); @@ -561,11 +513,9 @@ apply(Filename &patch_file, Filename &orig_file, const Filename &target_file) { } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::internal_read_header -// Access: Private -// Description: Reads the header and leaves the patch file open. -//////////////////////////////////////////////////////////////////// +/** + * Reads the header and leaves the patch file open. + */ int Patchfile:: internal_read_header(const Filename &patch_file) { // Open the patch file for read @@ -623,66 +573,56 @@ internal_read_header(const Filename &patch_file) { return EU_success; } -//////////////////////////////////////////////////////////////////// -///// PATCH FILE BUILDING MEMBER FUNCTIONS -//////////////////////////////////////////////////////////////////// +// PATCH FILE BUILDING MEMBER FUNCTIONS -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::calc_hash -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_uint32 Patchfile:: calc_hash(const char *buffer) { #ifdef USE_MD5_FOR_HASHTABLE_INDEX_VALUES HashVal hash; hash.hash_buffer(buffer, _footprint_length); - //cout << PN_uint16(hash.get_value(0)) << " "; + // cout << PN_uint16(hash.get_value(0)) << " "; return PN_uint16(hash.get_value(0)); #else PN_uint32 hash_value = 0; for(int i = 0; i < (int)_footprint_length; i++) { - // this is probably not such a good hash. to be replaced - /// --> TRIED MD5, was not worth it for the execution-time hit on 800Mhz PC + // this is probably not such a good hash. to be replaced --> TRIED MD5, + // was not worth it for the execution-time hit on 800Mhz PC hash_value ^= PN_uint32(*buffer) << ((i * 2) % Patchfile::_HASH_BITS); buffer++; } - // use the bits that overflowed past the end of the hash bit range - // (this is intended for _HASH_BITS == 24) + // use the bits that overflowed past the end of the hash bit range (this is + // intended for _HASH_BITS == 24) hash_value ^= (hash_value >> Patchfile::_HASH_BITS); - //cout << hash_value << " "; + // cout << hash_value << " "; return hash_value & _HASH_MASK; #endif } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::build_hash_link_tables -// Access: Private -// Description: -// The hash and link tables allow for a quick, linear -// search of all locations in the file that begin with -// a particular sequence of bytes, or "footprint." -// -// The hash table is a table of offsets into the file, -// with one entry for every possible footprint hash -// value. For a hash of a footprint, the entry at the -// offset of the hash value provides an initial location -// in the file that has a matching footprint. -// -// The link table is a large linked list of file offsets, -// with one entry for every byte in the file. Each offset -// in the link table will point to another offset that -// has the same footprint at the corresponding offset in the -// actual file. Starting with an offset taken from the hash -// table, one can rapidly produce a list of offsets that -// all have the same footprint. -//////////////////////////////////////////////////////////////////// +/** + * + * The hash and link tables allow for a quick, linear search of all locations + * in the file that begin with a particular sequence of bytes, or "footprint." + * + * The hash table is a table of offsets into the file, with one entry for + * every possible footprint hash value. For a hash of a footprint, the entry + * at the offset of the hash value provides an initial location in the file + * that has a matching footprint. + * + * The link table is a large linked list of file offsets, with one entry for + * every byte in the file. Each offset in the link table will point to + * another offset that has the same footprint at the corresponding offset in + * the actual file. Starting with an offset taken from the hash table, one + * can rapidly produce a list of offsets that all have the same footprint. + */ void Patchfile:: build_hash_link_tables(const char *buffer_orig, PN_uint32 length_orig, PN_uint32 *hash_table, PN_uint32 *link_table) { @@ -706,23 +646,21 @@ build_hash_link_tables(const char *buffer_orig, PN_uint32 length_orig, PN_uint32 hash_value = calc_hash(&buffer_orig[i]); - // we must now store this file index in the hash table - // at the offset of the hash value + // we must now store this file index in the hash table at the offset of + // the hash value - // to account for multiple file offsets with identical - // hash values, there is a link table with an entry for - // every footprint in the file. We create linked lists - // of offsets in the link table. + // to account for multiple file offsets with identical hash values, there + // is a link table with an entry for every footprint in the file. We + // create linked lists of offsets in the link table. - // first, set the value in the link table for the current - // offset to whatever the current list head is (the - // value in the hash table) (note that this only works - // because the hash and link tables both use + // first, set the value in the link table for the current offset to + // whatever the current list head is (the value in the hash table) (note + // that this only works because the hash and link tables both use // _NULL_VALUE to indicate a null index) link_table[i] = hash_table[hash_value]; - // set the new list head; store the current offset in the - // hash table at the offset of the footprint's hash value + // set the new list head; store the current offset in the hash table at + // the offset of the footprint's hash value hash_table[hash_value] = i; /* @@ -742,13 +680,10 @@ build_hash_link_tables(const char *buffer_orig, PN_uint32 length_orig, } } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::calc_match_length -// Access: Private -// Description: -// This function calculates the length of a match between -// two strings of bytes -//////////////////////////////////////////////////////////////////// +/** + * + * This function calculates the length of a match between two strings of bytes + */ PN_uint32 Patchfile:: calc_match_length(const char* buf1, const char* buf2, PN_uint32 max_length, PN_uint32 min_length) { @@ -770,13 +705,11 @@ calc_match_length(const char* buf1, const char* buf2, PN_uint32 max_length, return length; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::find_longest_match -// Access: Private -// Description: -// This function will find the longest string in the -// original file that matches a string in the new file. -//////////////////////////////////////////////////////////////////// +/** + * + * This function will find the longest string in the original file that + * matches a string in the new file. + */ void Patchfile:: find_longest_match(PN_uint32 new_pos, PN_uint32 ©_pos, PN_uint16 ©_length, PN_uint32 *hash_table, PN_uint32 *link_table, const char* buffer_orig, @@ -826,11 +759,9 @@ find_longest_match(PN_uint32 new_pos, PN_uint32 ©_pos, PN_uint16 ©_lengt } } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::emit_ADD -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Patchfile:: emit_ADD(ostream &write_stream, PN_uint32 length, const char* buffer) { nassertv(length == (PN_uint16)length); //we only write a uint16 @@ -852,11 +783,9 @@ emit_ADD(ostream &write_stream, PN_uint32 length, const char* buffer) { _add_pos += length; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::emit_COPY -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Patchfile:: emit_COPY(ostream &write_stream, PN_uint32 length, PN_uint32 copy_pos) { nassertv(length == (PN_uint16)length); //we only write a uint16 @@ -881,13 +810,10 @@ emit_COPY(ostream &write_stream, PN_uint32 length, PN_uint32 copy_pos) { _add_pos += length; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::emit_add_and_copy -// Access: Private -// Description: Emits an add/copy pair. If necessary, repeats the -// pair as needed to work around the 16-bit chunk size -// limit. -//////////////////////////////////////////////////////////////////// +/** + * Emits an add/copy pair. If necessary, repeats the pair as needed to work + * around the 16-bit chunk size limit. + */ void Patchfile:: emit_add_and_copy(ostream &write_stream, PN_uint32 add_length, const char *add_buffer, @@ -899,8 +825,8 @@ emit_add_and_copy(ostream &write_stream, static const PN_uint16 max_write = 65535; while (add_length > max_write) { - // Overflow. This chunk is too large to fit into a single - // ADD block, so we have to write it as multiple ADDs. + // Overflow. This chunk is too large to fit into a single ADD block, so + // we have to write it as multiple ADDs. emit_ADD(write_stream, max_write, add_buffer); add_buffer += max_write; add_length -= max_write; @@ -920,13 +846,10 @@ emit_add_and_copy(ostream &write_stream, emit_COPY(write_stream, copy_length, copy_pos); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::cache_add_and_copy -// Access: Private -// Description: Potentially emits one or more add/copy pairs. The -// current state is saved, so as to minimize wasted -// emits from consecutive adds or copies. -//////////////////////////////////////////////////////////////////// +/** + * Potentially emits one or more add/copy pairs. The current state is saved, + * so as to minimize wasted emits from consecutive adds or copies. + */ void Patchfile:: cache_add_and_copy(ostream &write_stream, PN_uint32 add_length, const char *add_buffer, @@ -959,12 +882,10 @@ cache_add_and_copy(ostream &write_stream, } } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::cache_flush -// Access: Private -// Description: Closes any copy or add phases that are still open -// after a previous call to cache_add_and_copy(). -//////////////////////////////////////////////////////////////////// +/** + * Closes any copy or add phases that are still open after a previous call to + * cache_add_and_copy(). + */ void Patchfile:: cache_flush(ostream &write_stream) { emit_add_and_copy(write_stream, @@ -975,12 +896,10 @@ cache_flush(ostream &write_stream) { } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::write_header -// Access: Private -// Description: -// Writes the patchfile header. -//////////////////////////////////////////////////////////////////// +/** + * + * Writes the patchfile header. + */ void Patchfile:: write_header(ostream &write_stream, istream &stream_orig, istream &stream_new) { @@ -1020,11 +939,9 @@ write_header(ostream &write_stream, } } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::write_terminator -// Access: Private -// Description: Writes the patchfile terminator. -//////////////////////////////////////////////////////////////////// +/** + * Writes the patchfile terminator. + */ void Patchfile:: write_terminator(ostream &write_stream) { cache_flush(write_stream); @@ -1033,14 +950,12 @@ write_terminator(ostream &write_stream) { emit_COPY(write_stream, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::compute_file_patches -// Access: Private -// Description: Computes the patches for the entire file (if it is -// not a multifile) or for a single subfile (if it is) -// -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Computes the patches for the entire file (if it is not a multifile) or for + * a single subfile (if it is) + * + * Returns true if successful, false on error. + */ bool Patchfile:: compute_file_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, @@ -1071,7 +986,7 @@ compute_file_patches(ostream &write_stream, stream_new.seekg(0, ios::beg); stream_new.read(buffer_new, result_file_length); - // allocate hash/link tables + // allocate hashlink tables if (_hash_table == (PN_uint32 *)NULL) { if (express_cat.is_debug()) { express_cat.debug() @@ -1106,7 +1021,8 @@ compute_file_patches(ostream &write_stream, find_longest_match(new_pos, COPY_pos, COPY_length, _hash_table, link_table, buffer_orig, source_file_length, buffer_new, result_file_length); - // if no match or match not longer than footprint length, skip to next byte + // if no match or match not longer than footprint length, skip to next + // byte if (COPY_length < _footprint_length) { // go to next byte new_pos++; @@ -1151,15 +1067,12 @@ compute_file_patches(ostream &write_stream, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::compute_mf_patches -// Access: Private -// Description: Computes patches for the files, knowing that they are -// both Panda Multifiles. This will build patches one -// subfile at a time, which can potentially be much, -// much faster for large Multifiles that contain many -// small subfiles. -//////////////////////////////////////////////////////////////////// +/** + * Computes patches for the files, knowing that they are both Panda + * Multifiles. This will build patches one subfile at a time, which can + * potentially be much, much faster for large Multifiles that contain many + * small subfiles. + */ bool Patchfile:: compute_mf_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, @@ -1180,7 +1093,7 @@ compute_mf_patches(ostream &write_stream, return false; } - // First, compute the patch for the header / index. + // First, compute the patch for the header index. { ISubStream index_orig(&stream_origw, 0, mf_orig.get_index_end()); @@ -1193,11 +1106,10 @@ compute_mf_patches(ostream &write_stream, nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_index_end(), false); } - // Now walk through each subfile in the new multifile. If a - // particular subfile exists in both source files, we compute the - // patches for the subfile; for a new subfile, we trivially add it. - // If a subfile has been removed, we simply don't add it (we'll - // never even notice this case). + // Now walk through each subfile in the new multifile. If a particular + // subfile exists in both source files, we compute the patches for the + // subfile; for a new subfile, we trivially add it. If a subfile has been + // removed, we simply don't add it (we'll never even notice this case). int new_num_subfiles = mf_new.get_num_subfiles(); for (int ni = 0; ni < new_num_subfiles; ++ni) { nassertr(_add_pos + _cache_add_data.size() + _cache_copy_length == offset_new + mf_new.get_subfile_internal_start(ni), false); @@ -1218,8 +1130,8 @@ compute_mf_patches(ostream &write_stream, PANDA_FREE_ARRAY(buffer_new); } else { - // This subfile exists in both the original and the new files. - // Patch it. + // This subfile exists in both the original and the new files. Patch + // it. streampos orig_start = mf_orig.get_subfile_internal_start(oi); size_t orig_size = mf_orig.get_subfile_internal_length(oi); @@ -1239,14 +1151,11 @@ compute_mf_patches(ostream &write_stream, } #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::read_tar -// Access: Private -// Description: Uses libtar to extract the location within the tar -// file of each of the subfiles. Returns true if the -// tar file is read successfully, false if there is an -// error (e.g. it is not a tar file). -//////////////////////////////////////////////////////////////////// +/** + * Uses libtar to extract the location within the tar file of each of the + * subfiles. Returns true if the tar file is read successfully, false if + * there is an error (e.g. it is not a tar file). + */ bool Patchfile:: read_tar(TarDef &tar, istream &stream) { TAR *tfile; @@ -1264,9 +1173,9 @@ read_tar(TarDef &tar, istream &stream) { return false; } - // Walk through the tar file, noting the current file position as we - // reach each subfile. Use this information to infer the start and - // end of each subfile within the stream. + // Walk through the tar file, noting the current file position as we reach + // each subfile. Use this information to infer the start and end of each + // subfile within the stream. streampos last_pos = 0; int flag = th_read(tfile); @@ -1284,8 +1193,8 @@ read_tar(TarDef &tar, istream &stream) { flag = th_read(tfile); } - // Create one more "subfile" for the bytes at the tail of the file. - // This subfile has no name. + // Create one more "subfile" for the bytes at the tail of the file. This + // subfile has no name. TarSubfile subfile; subfile._header_start = last_pos; stream.clear(); @@ -1302,34 +1211,29 @@ read_tar(TarDef &tar, istream &stream) { #endif // HAVE_TAR #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::compute_tar_patches -// Access: Private -// Description: Computes patches for the files, knowing that they are -// both tar files. This is similar to -// compute_mf_patches(). -// -// The tar indexes should have been built up by a -// previous call to read_tar(). -//////////////////////////////////////////////////////////////////// +/** + * Computes patches for the files, knowing that they are both tar files. This + * is similar to compute_mf_patches(). + * + * The tar indexes should have been built up by a previous call to read_tar(). + */ bool Patchfile:: compute_tar_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, istream &stream_orig, istream &stream_new, TarDef &tar_orig, TarDef &tar_new) { - // Sort the orig list by filename, so we can quickly look up files - // from the new list. + // Sort the orig list by filename, so we can quickly look up files from the + // new list. tar_orig.sort(); - // However, it is important to keep the new list in its original, - // on-disk order. + // However, it is important to keep the new list in its original, on-disk + // order. - // Walk through each subfile in the new tar file. If a particular - // subfile exists in both source files, we compute the patches for - // the subfile; for a new subfile, we trivially add it. If a - // subfile has been removed, we simply don't add it (we'll never - // even notice this case). + // Walk through each subfile in the new tar file. If a particular subfile + // exists in both source files, we compute the patches for the subfile; for + // a new subfile, we trivially add it. If a subfile has been removed, we + // simply don't add it (we'll never even notice this case). IStreamWrapper stream_origw(stream_orig); IStreamWrapper stream_neww(stream_new); @@ -1356,14 +1260,14 @@ compute_tar_patches(ostream &write_stream, PANDA_FREE_ARRAY(buffer_new); } else { - // This subfile exists in both the original and the new files. - // Patch it. + // This subfile exists in both the original and the new files. Patch + // it. const TarSubfile &sf_orig =(*oi); - // We patch the header and data of the file separately, so we - // can accurately detect nested multifiles. The extra data at - // the end of the file (possibly introduced by a tar file's - // blocking) is the footer, which is also patched separately. + // We patch the header and data of the file separately, so we can + // accurately detect nested multifiles. The extra data at the end of + // the file (possibly introduced by a tar file's blocking) is the + // footer, which is also patched separately. if (!patch_subfile(write_stream, offset_orig, offset_new, "", stream_origw, sf_orig._header_start, sf_orig._data_start, stream_neww, sf_new._header_start, sf_new._data_start)) { @@ -1391,27 +1295,23 @@ compute_tar_patches(ostream &write_stream, #endif // HAVE_TAR #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::tar_openfunc -// Access: Private, Static -// Description: A callback function to redirect libtar to read from -// our istream instead of using low-level Unix I/O. -//////////////////////////////////////////////////////////////////// +/** + * A callback function to redirect libtar to read from our istream instead of + * using low-level Unix I/O. + */ int Patchfile:: tar_openfunc(const char *, int, ...) { - // Since we don't actually open a file--the stream is already - // open--we do nothing here. + // Since we don't actually open a file--the stream is already open--we do + // nothing here. return 0; } #endif // HAVE_TAR #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::tar_closefunc -// Access: Private, Static -// Description: A callback function to redirect libtar to read from -// our istream instead of using low-level Unix I/O. -//////////////////////////////////////////////////////////////////// +/** + * A callback function to redirect libtar to read from our istream instead of + * using low-level Unix I/O. + */ int Patchfile:: tar_closefunc(int) { // Since we don't actually open a file, no need to close it either. @@ -1420,12 +1320,10 @@ tar_closefunc(int) { #endif // HAVE_TAR #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::tar_readfunc -// Access: Private, Static -// Description: A callback function to redirect libtar to read from -// our istream instead of using low-level Unix I/O. -//////////////////////////////////////////////////////////////////// +/** + * A callback function to redirect libtar to read from our istream instead of + * using low-level Unix I/O. + */ ssize_t Patchfile:: tar_readfunc(int, void *buffer, size_t nbytes) { nassertr(_tar_istream != NULL, 0); @@ -1435,34 +1333,27 @@ tar_readfunc(int, void *buffer, size_t nbytes) { #endif // HAVE_TAR #ifdef HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::tar_writefunc -// Access: Private, Static -// Description: A callback function to redirect libtar to read from -// our istream instead of using low-level Unix I/O. -//////////////////////////////////////////////////////////////////// +/** + * A callback function to redirect libtar to read from our istream instead of + * using low-level Unix I/O. + */ ssize_t Patchfile:: tar_writefunc(int, const void *, size_t) { - // Since we use libtar only for reading, it is an error if this - // method gets called. + // Since we use libtar only for reading, it is an error if this method gets + // called. nassertr(false, -1); return -1; } #endif // HAVE_TAR -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::build -// Access: Public -// Description: -// This implementation uses the "greedy differencing -// algorithm" described in the masters thesis -// "Differential Compression: A Generalized Solution -// for Binary Files" by Randal C. Burns (p.13). -// For an original file of size M and a new file of -// size N, this algorithm is O(M) in space and -// O(M*N) (worst-case) in time. -// return false on error -//////////////////////////////////////////////////////////////////// +/** + * + * This implementation uses the "greedy differencing algorithm" described in + * the masters thesis "Differential Compression: A Generalized Solution for + * Binary Files" by Randal C. Burns (p.13). For an original file of size M and + * a new file of size N, this algorithm is O(M) in space and O(M*N) (worst- + * case) in time. return false on error + */ bool Patchfile:: build(Filename file_orig, Filename file_new, Filename patch_name) { patch_name.set_binary(); @@ -1526,13 +1417,10 @@ build(Filename file_orig, Filename file_new, Filename patch_name) { return (_last_copy_pos != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::do_compute_patches -// Access: Private -// Description: Computes the patches for the indicated A to B files, -// or subfiles. Checks for multifiles or tar files -// before falling back to whole-file patching. -//////////////////////////////////////////////////////////////////// +/** + * Computes the patches for the indicated A to B files, or subfiles. Checks + * for multifiles or tar files before falling back to whole-file patching. + */ bool Patchfile:: do_compute_patches(const Filename &file_orig, const Filename &file_new, ostream &write_stream, @@ -1550,8 +1438,7 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, if (_allow_multifile) { if (strstr(file_orig.get_basename().c_str(), ".mf") != NULL || strstr(file_new.get_basename().c_str(), ".mf") != NULL) { - // Read the first n bytes of both files for the Multifile magic - // number. + // Read the first n bytes of both files for the Multifile magic number. string magic_number = Multifile::get_magic_number(); char *buffer = (char *)PANDA_MALLOC_ARRAY(magic_number.size()); stream_orig.seekg(0, ios::beg); @@ -1613,12 +1500,9 @@ do_compute_patches(const Filename &file_orig, const Filename &file_new, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Patchfile::patch_subfile -// Access: Private -// Description: Generates patches for a nested subfile of a Panda -// Multifile or a tar file. -//////////////////////////////////////////////////////////////////// +/** + * Generates patches for a nested subfile of a Panda Multifile or a tar file. + */ bool Patchfile:: patch_subfile(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, diff --git a/panda/src/express/patchfile.h b/panda/src/express/patchfile.h index fc42b0a6c4..eee70c0f21 100644 --- a/panda/src/express/patchfile.h +++ b/panda/src/express/patchfile.h @@ -1,16 +1,15 @@ -// Filename: patchfile.h -// Created by: darren, mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file patchfile.h + * @author darren, mike + * @date 1997-01-09 + */ #ifndef PATCHFILE_H #define PATCHFILE_H @@ -34,10 +33,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : Patchfile -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAEXPRESS Patchfile { PUBLISHED: Patchfile(); @@ -53,7 +51,7 @@ PUBLISHED: int run(); bool apply(Filename &patch_file, Filename &file); - bool apply(Filename &patch_file, Filename &orig_file, + bool apply(Filename &patch_file, Filename &orig_file, const Filename &target_file); INLINE PN_stdfloat get_progress() const; @@ -92,22 +90,22 @@ private: void emit_ADD(ostream &write_stream, PN_uint32 length, const char* buffer); void emit_COPY(ostream &write_stream, PN_uint32 length, PN_uint32 COPY_pos); - void emit_add_and_copy(ostream &write_stream, + void emit_add_and_copy(ostream &write_stream, PN_uint32 add_length, const char *add_buffer, PN_uint32 copy_length, PN_uint32 copy_pos); - void cache_add_and_copy(ostream &write_stream, + void cache_add_and_copy(ostream &write_stream, PN_uint32 add_length, const char *add_buffer, PN_uint32 copy_length, PN_uint32 copy_pos); void cache_flush(ostream &write_stream); - void write_header(ostream &write_stream, + void write_header(ostream &write_stream, istream &stream_orig, istream &stream_new); void write_terminator(ostream &write_stream); - bool compute_file_patches(ostream &write_stream, + bool compute_file_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, istream &stream_orig, istream &stream_new); - bool compute_mf_patches(ostream &write_stream, + bool compute_mf_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, istream &stream_orig, istream &stream_new); #ifdef HAVE_TAR @@ -125,15 +123,15 @@ private: typedef ov_set TarDef; bool read_tar(TarDef &tar, istream &stream); - bool compute_tar_patches(ostream &write_stream, + bool compute_tar_patches(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, istream &stream_orig, istream &stream_new, TarDef &tar_orig, TarDef &tar_new); - // Because this is static, we can only call read_tar() one at a - // time--no threads, please. + // Because this is static, we can only call read_tar() one at a time--no + // threads, please. static istream *_tar_istream; - + static int tar_openfunc(const char *filename, int oflags, ...); static int tar_closefunc(int fd); static ssize_t tar_readfunc(int fd, void *buffer, size_t nbytes); @@ -141,11 +139,11 @@ private: #endif // HAVE_TAR bool do_compute_patches(const Filename &file_orig, const Filename &file_new, - ostream &write_stream, + ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, istream &stream_orig, istream &stream_new); - - bool patch_subfile(ostream &write_stream, + + bool patch_subfile(ostream &write_stream, PN_uint32 offset_orig, PN_uint32 offset_new, const Filename &filename, IStreamWrapper &stream_orig, streampos orig_start, streampos orig_end, @@ -178,9 +176,9 @@ private: PN_uint16 _version_number; - HashVal _MD5_ofSource; + HashVal _MD5_ofSource; - HashVal _MD5_ofResult; + HashVal _MD5_ofResult; PN_uint32 _total_bytes_to_process; PN_uint32 _total_bytes_processed; diff --git a/panda/src/express/pointerTo.I b/panda/src/express/pointerTo.I index bce23ad027..b44f4f4ded 100644 --- a/panda/src/express/pointerTo.I +++ b/panda/src/express/pointerTo.I @@ -1,33 +1,27 @@ -// Filename: pointerTo.I -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerTo.I + * @author drose + * @date 1999-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo:: PointerTo(To *ptr) : PointerToBase(ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo:: PointerTo(const PointerTo ©) : @@ -36,11 +30,9 @@ PointerTo(const PointerTo ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo:: PointerTo(PointerTo &&from) NOEXCEPT : @@ -48,11 +40,9 @@ PointerTo(PointerTo &&from) NOEXCEPT : { } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo &PointerTo:: operator = (PointerTo &&from) NOEXCEPT { @@ -61,88 +51,70 @@ operator = (PointerTo &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo:: ~PointerTo() { } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerTo::To &PointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerTo::To *PointerTo:: operator -> () const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert PointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert PointerTo's to + * the required kind of actual pointer. This introduces ambiguities which the + * compiler will resolve one way or the other, but we don't care which way it + * goes because either will be correct. + */ template INLINE PointerTo:: operator T * () const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::cheat -// Access: Public -// Description: Returns a reference to the underlying pointer. This -// is a very unsafe method. It's only used by some -// interrogate code. If you think this method might be -// useful to you, you're probably wrong. -// -// Promise me you won't use this, okay? -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the underlying pointer. This is a very unsafe + * method. It's only used by some interrogate code. If you think this method + * might be useful to you, you're probably wrong. + * + * Promise me you won't use this, okay? + */ template INLINE T *&PointerTo:: cheat() { return (To *&)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::p -// Access: Published -// Description: Returns an ordinary pointer instead of a PointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a PointerTo. Useful to work around + * compiler problems, particularly for implicit upcasts. + */ template INLINE TYPENAME PointerTo::To *PointerTo:: p() const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo &PointerTo:: operator = (To *ptr) { @@ -150,11 +122,9 @@ operator = (To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerTo &PointerTo:: operator = (const PointerTo ©) { @@ -162,11 +132,9 @@ operator = (const PointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) : @@ -174,11 +142,9 @@ ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ConstPointerTo(const PointerTo ©) : @@ -186,21 +152,17 @@ ConstPointerTo(const PointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ~ConstPointerTo() { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ConstPointerTo(const ConstPointerTo ©) : @@ -209,11 +171,9 @@ ConstPointerTo(const ConstPointerTo ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ConstPointerTo(PointerTo &&from) NOEXCEPT : @@ -221,11 +181,9 @@ ConstPointerTo(PointerTo &&from) NOEXCEPT : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo:: ConstPointerTo(ConstPointerTo &&from) NOEXCEPT : @@ -233,11 +191,9 @@ ConstPointerTo(ConstPointerTo &&from) NOEXCEPT : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (PointerTo &&from) NOEXCEPT { @@ -245,11 +201,9 @@ operator = (PointerTo &&from) NOEXCEPT { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (ConstPointerTo &&from) NOEXCEPT { @@ -258,78 +212,62 @@ operator = (ConstPointerTo &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME ConstPointerTo::To &ConstPointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: operator -> () const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert ConstPointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert + * ConstPointerTo's to the required kind of actual pointer. This introduces + * ambiguities which the compiler will resolve one way or the other, but we + * don't care which way it goes because either will be correct. + */ template INLINE ConstPointerTo:: operator const T * () const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::cheat -// Access: Public -// Description: Returns a reference to the underlying pointer. This -// is a very unsafe method. It's only used by some -// interrogate code. If you think this method might be -// useful to you, you're probably wrong. -// -// Promise me you won't use this, okay? -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the underlying pointer. This is a very unsafe + * method. It's only used by some interrogate code. If you think this method + * might be useful to you, you're probably wrong. + * + * Promise me you won't use this, okay? + */ template INLINE const T *&ConstPointerTo:: cheat() { return (const To *&)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::p -// Access: Published -// Description: Returns an ordinary pointer instead of a ConstPointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a ConstPointerTo. Useful to work + * around compiler problems, particularly for implicit upcasts. + */ template INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: p() const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const To *ptr) { @@ -337,11 +275,9 @@ operator = (const To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const PointerTo ©) { @@ -349,11 +285,9 @@ operator = (const PointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerTo &ConstPointerTo:: operator = (const ConstPointerTo ©) { diff --git a/panda/src/express/pointerTo.cxx b/panda/src/express/pointerTo.cxx index 4ad0a7859a..80e544e912 100644 --- a/panda/src/express/pointerTo.cxx +++ b/panda/src/express/pointerTo.cxx @@ -1,15 +1,14 @@ -// Filename: pointerTo.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerTo.cxx + * @author drose + * @date 2004-09-27 + */ #include "pointerTo.h" diff --git a/panda/src/express/pointerTo.h b/panda/src/express/pointerTo.h index e1775b6d8e..315cdaf2ca 100644 --- a/panda/src/express/pointerTo.h +++ b/panda/src/express/pointerTo.h @@ -1,80 +1,58 @@ -// Filename: pointerTo.h -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerTo.h + * @author drose + * @date 1998-10-23 + */ #ifndef POINTERTO_H #define POINTERTO_H -//////////////////////////////////////////////////////////////////// -// -// This file defines the classes PointerTo and ConstPointerTo (and -// their abbreviations, PT and CPT). These should be used in place of -// traditional C-style pointers wherever implicit reference counting -// is desired. -// -// The syntax is: instead of: -// -// PointerTo p; MyClass *p; -// PT(MyClass) p; -// -// ConstPointerTo p; const MyClass *p; -// CPT(MyClass) p; -// -// PointerTo and ConstPointerTo will automatically increment the -// object's reference count while the pointer is kept. When the -// PointerTo object is reassigned or goes out of scope, the reference -// count is automatically decremented. If the reference count reaches -// zero, the object is freed. -// -// Note that const PointerTo is different from -// ConstPointerTo. A const PointerTo may not reassign its -// pointer, but it may still modify the contents at that address. On -// the other hand, a ConstPointerTo may reassign its pointer at will, -// but may not modify the contents. It is like the difference between -// (MyClass * const) and (const MyClass *). -// -// In order to use PointerTo, it is necessary that the thing pointed -// to--MyClass in the above example--either inherits from -// ReferenceCount, or is a proxy built with RefCountProxy or -// RefCountObj (see referenceCount.h). However, also see -// PointerToArray, which does not have this restriction. -// -// It is crucial that the PointerTo object is only used to refer to -// objects allocated from the free store, for which delete is a -// sensible thing to do. If you assign a PointerTo to an automatic -// variable (allocated from the stack, for instance), bad things will -// certainly happen when the reference count reaches zero and it tries -// to delete it. -// -// It's also important to remember that, as always, a virtual -// destructor is required if you plan to support polymorphism. That -// is, if you define a PointerTo to some base type, and assign to it -// instances of a class derived from that base class, the base class -// must have a virtual destructor in order to properly destruct the -// derived object when it is deleted. -// -//////////////////////////////////////////////////////////////////// +/* + * This file defines the classes PointerTo and ConstPointerTo (and their + * abbreviations, PT and CPT). These should be used in place of traditional + * C-style pointers wherever implicit reference counting is desired. The + * syntax is: instead of: PointerTo p; + * MyClass *p; PT(MyClass) p; ConstPointerTo p; const MyClass + * *p; CPT(MyClass) p; PointerTo and ConstPointerTo will automatically + * increment the object's reference count while the pointer is kept. When the + * PointerTo object is reassigned or goes out of scope, the reference count is + * automatically decremented. If the reference count reaches zero, the object + * is freed. Note that const PointerTo is different from + * ConstPointerTo. A const PointerTo may not reassign its pointer, + * but it may still modify the contents at that address. On the other hand, a + * ConstPointerTo may reassign its pointer at will, but may not modify the + * contents. It is like the difference between (MyClass * const) and (const + * MyClass *). In order to use PointerTo, it is necessary that the thing + * pointed to--MyClass in the above example--either inherits from + * ReferenceCount, or is a proxy built with RefCountProxy or RefCountObj (see + * referenceCount.h). However, also see PointerToArray, which does not have + * this restriction. It is crucial that the PointerTo object is only used to + * refer to objects allocated from the free store, for which delete is a + * sensible thing to do. If you assign a PointerTo to an automatic variable + * (allocated from the stack, for instance), bad things will certainly happen + * when the reference count reaches zero and it tries to delete it. It's also + * important to remember that, as always, a virtual destructor is required if + * you plan to support polymorphism. That is, if you define a PointerTo to + * some base type, and assign to it instances of a class derived from that + * base class, the base class must have a virtual destructor in order to + * properly destruct the derived object when it is deleted. + */ #include "pandabase.h" #include "pointerToBase.h" #include "register_type.h" -//////////////////////////////////////////////////////////////////// -// Class : PointerTo -// Description : PointerTo is a template class which implements a -// smart pointer to an object derived from -// ReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * PointerTo is a template class which implements a smart pointer to an object + * derived from ReferenceCount. + */ template class PointerTo : public PointerToBase { public: @@ -98,48 +76,44 @@ public: INLINE T *&cheat(); PUBLISHED: - // When downcasting to a derived class from a PointerTo, - // C++ would normally require you to cast twice: once to an actual - // BaseClass pointer, and then again to your desired pointer. You - // can use the handy function p() to avoid this first cast and make - // your code look a bit cleaner. + // When downcasting to a derived class from a PointerTo, C++ + // would normally require you to cast twice: once to an actual BaseClass + // pointer, and then again to your desired pointer. You can use the handy + // function p() to avoid this first cast and make your code look a bit + // cleaner. - // e.g. instead of (MyType *)(BaseClass *)ptr, use (MyType *)ptr.p() + // e.g. instead of (MyType *)(BaseClass *)ptr, use (MyType *)ptr.p() - // If your base class is a derivative of TypedObject, you might want - // to use the DCAST macro defined in typedObject.h instead, - // e.g. DCAST(MyType, ptr). This provides a clean downcast that - // doesn't require .p() or any double-casting, and it can be - // run-time checked for correctness. + // If your base class is a derivative of TypedObject, you might want to use + // the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType, + // ptr). This provides a clean downcast that doesn't require .p() or any + // double-casting, and it can be run-time checked for correctness. INLINE To *p() const; INLINE PointerTo &operator = (To *ptr); INLINE PointerTo &operator = (const PointerTo ©); - // These functions normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the PointerToBase class). When - // this works again in interrogate, we can remove these. + // These functions normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the PointerToBase class). When this works again in + // interrogate, we can remove these. INLINE bool is_null() const { return PointerToBase::is_null(); } INLINE void clear() { PointerToBase::clear(); } }; -//////////////////////////////////////////////////////////////////// -// Class : ConstPointerTo -// Description : A ConstPointerTo is similar to a PointerTo, except it -// keeps a const pointer to the thing. -// -// (Actually, it keeps a non-const pointer, because it -// must be allowed to adjust the reference counts, and -// it must be able to delete it when the reference count -// goes to zero. But it presents only a const pointer -// to the outside world.) -// -// Notice that a PointerTo may be assigned to a -// ConstPointerTo, but a ConstPointerTo may not be -// assigned to a PointerTo. -//////////////////////////////////////////////////////////////////// +/** + * A ConstPointerTo is similar to a PointerTo, except it keeps a const pointer + * to the thing. + * + * (Actually, it keeps a non-const pointer, because it must be allowed to + * adjust the reference counts, and it must be able to delete it when the + * reference count goes to zero. But it presents only a const pointer to the + * outside world.) + * + * Notice that a PointerTo may be assigned to a ConstPointerTo, but a + * ConstPointerTo may not be assigned to a PointerTo. + */ template class ConstPointerTo : public PointerToBase { public: @@ -171,17 +145,17 @@ PUBLISHED: INLINE ConstPointerTo &operator = (const PointerTo ©); INLINE ConstPointerTo &operator = (const ConstPointerTo ©); - // This functions normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the PointerToBase class). When - // this works again in interrogate, we can remove this. + // This functions normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the PointerToBase class). When this works again in + // interrogate, we can remove this. INLINE void clear() { PointerToBase::clear(); } }; -// The existence of these functions makes it possible to sort vectors -// of PointerTo objects without incurring the cost of unnecessary -// reference count changes. The performance difference is dramatic! +// The existence of these functions makes it possible to sort vectors of +// PointerTo objects without incurring the cost of unnecessary reference count +// changes. The performance difference is dramatic! template void swap(PointerTo &one, PointerTo &two) NOEXCEPT { one.swap(two); @@ -193,14 +167,14 @@ void swap(ConstPointerTo &one, ConstPointerTo &two) NOEXCEPT { } -// Finally, we'll define a couple of handy abbreviations to save on -// all that wasted typing time. +// Finally, we'll define a couple of handy abbreviations to save on all that +// wasted typing time. #define PT(type) PointerTo< type > #define CPT(type) ConstPointerTo< type > -// Now that we have defined PointerTo, we can define what it means to -// take the TypeHandle of a PointerTo object. +// Now that we have defined PointerTo, we can define what it means to take the +// TypeHandle of a PointerTo object. template INLINE TypeHandle _get_type_handle(const PointerTo *) { diff --git a/panda/src/express/pointerToArray.I b/panda/src/express/pointerToArray.I index dbb5f9a0bf..568b379105 100644 --- a/panda/src/express/pointerToArray.I +++ b/panda/src/express/pointerToArray.I @@ -1,16 +1,15 @@ -// Filename: pointerToArray.I -// Created by: drose (07Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArray.I + * @author drose + * @date 2000-01-07 + */ #ifndef CPPPARSER @@ -20,11 +19,9 @@ pvector PointerToArray::_empty_array; template pvector ConstPointerToArray::_empty_array; -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray:: PointerToArray(TypeHandle type_handle) : @@ -33,11 +30,9 @@ PointerToArray(TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::empty_array -// Access: Public, Static -// Description: Return an empty array of size n -//////////////////////////////////////////////////////////////////// +/** + * Return an empty array of size n + */ template INLINE PointerToArray PointerToArray::empty_array(size_type n, TypeHandle type_handle) { @@ -49,11 +44,9 @@ PointerToArray::empty_array(size_type n, TypeHandle type_handle) { return temp; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray:: PointerToArray(size_type n, const Element &value, TypeHandle type_handle) : @@ -64,11 +57,9 @@ PointerToArray(size_type n, const Element &value, TypeHandle type_handle) : insert(begin(), n, value); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray:: PointerToArray(const PointerToArray ©) : @@ -78,11 +69,9 @@ PointerToArray(const PointerToArray ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray:: PointerToArray(PointerToArray &&from) NOEXCEPT : @@ -92,11 +81,9 @@ PointerToArray(PointerToArray &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::iterator PointerToArray:: begin() const { @@ -106,11 +93,9 @@ begin() const { return ((To *)(this->_void_ptr))->begin(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::iterator PointerToArray:: end() const { @@ -120,11 +105,9 @@ end() const { return ((To *)(this->_void_ptr))->end(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::rbegin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: rbegin() const { @@ -134,11 +117,9 @@ rbegin() const { return ((To *)(this->_void_ptr))->rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::rend -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reverse_iterator PointerToArray:: rend() const { @@ -148,22 +129,18 @@ rend() const { return ((To *)(this->_void_ptr))->rend(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::size_type PointerToArray:: size() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::max_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::size_type PointerToArray:: max_size() const { @@ -173,22 +150,18 @@ max_size() const { return ((To *)(this->_void_ptr))->max_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool PointerToArray:: empty() const { return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::reserve -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: reserve(TYPENAME PointerToArray::size_type n) { @@ -198,11 +171,9 @@ reserve(TYPENAME PointerToArray::size_type n) { ((To *)(this->_void_ptr))->reserve(n); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::resize -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: resize(TYPENAME PointerToArray::size_type n) { @@ -212,11 +183,9 @@ resize(TYPENAME PointerToArray::size_type n) { ((To *)(this->_void_ptr))->resize(n); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::capacity -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::size_type PointerToArray:: capacity() const { @@ -224,11 +193,9 @@ capacity() const { return ((To *)(this->_void_ptr))->capacity(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::front -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reference PointerToArray:: front() const { @@ -241,11 +208,9 @@ front() const { return ((To *)(this->_void_ptr))->front(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::back -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reference PointerToArray:: back() const { @@ -258,11 +223,9 @@ back() const { return ((To *)(this->_void_ptr))->back(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::iterator PointerToArray:: insert(iterator position, const Element &x) { @@ -275,11 +238,9 @@ insert(iterator position, const Element &x) { return ((To *)(this->_void_ptr))->insert(position, x); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: insert(iterator position, size_type n, const Element &x) { @@ -292,11 +253,9 @@ insert(iterator position, size_type n, const Element &x) { ((To *)(this->_void_ptr))->insert(position, n, x); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::erase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: erase(iterator position) { @@ -306,11 +265,9 @@ erase(iterator position) { ((To *)(this->_void_ptr))->erase(position); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::erase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: erase(iterator first, iterator last) { @@ -321,11 +278,9 @@ erase(iterator first, iterator last) { } #if !defined(WIN32_VC) && !defined(WIN64_VC) -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reference PointerToArray:: operator [](size_type n) const { @@ -339,11 +294,9 @@ operator [](size_type n) const { return ((To *)(this->_void_ptr))->operator[](n); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME PointerToArray::reference PointerToArray:: operator [](int n) const { @@ -351,11 +304,9 @@ operator [](int n) const { } #endif -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::push_back -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: push_back(const Element &x) { @@ -365,11 +316,9 @@ push_back(const Element &x) { ((To *)(this->_void_ptr))->push_back(x); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::pop_back -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToArray:: pop_back() { @@ -380,13 +329,10 @@ pop_back() { ((To *)(this->_void_ptr))->pop_back(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::make_empty -// Access: Public -// Description: Empties the array pointed to. This is different from -// clear(), which reassigns the pointer to a NULL -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Empties the array pointed to. This is different from clear(), which + * reassigns the pointer to a NULL pointer. + */ template INLINE void PointerToArray:: make_empty() { @@ -397,15 +343,12 @@ make_empty() { ((To *)(this->_void_ptr))->clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Typecast operator -// Access: Public -// Description: The pointer typecast operator is convenient for -// maintaining the fiction that we actually have a -// C-style array. It returns the address of the first -// element in the array, unless the pointer is -// unassigned, in which case it returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * The pointer typecast operator is convenient for maintaining the fiction + * that we actually have a C-style array. It returns the address of the first + * element in the array, unless the pointer is unassigned, in which case it + * returns NULL. + */ template INLINE PointerToArray:: operator Element *() const { @@ -413,13 +356,10 @@ operator Element *() const { return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::p -// Access: Public -// Description: Function p() is similar to the function from -// PointerTo. It does the same thing: it returns the -// same thing as the typecast operator, above. -//////////////////////////////////////////////////////////////////// +/** + * Function p() is similar to the function from PointerTo. It does the same + * thing: it returns the same thing as the typecast operator, above. + */ template INLINE Element *PointerToArray:: p() const { @@ -427,12 +367,10 @@ p() const { return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front()); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::v -// Access: Public -// Description: To access the vector itself, for more direct fiddling -// with some of the vector's esoteric functionality. -//////////////////////////////////////////////////////////////////// +/** + * To access the vector itself, for more direct fiddling with some of the + * vector's esoteric functionality. + */ template INLINE pvector &PointerToArray:: v() const { @@ -442,42 +380,34 @@ v() const { return *((To *)(this->_void_ptr)); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::v0 -// Access: Public -// Description: To access the internal ReferenceCountedVector object, -// for very low-level fiddling. Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * To access the internal ReferenceCountedVector object, for very low-level + * fiddling. Know what you are doing! + */ template INLINE ReferenceCountedVector *PointerToArray:: v0() const { return (To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get_element -// Access: Published -// Description: This method exists mainly to access the elements of -// the array easily from a high-level language such as -// Python, especially on Windows, where the above index -// element accessor methods can't be defined because of -// a confusion with the pointer typecast operator. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the elements of the array easily from a + * high-level language such as Python, especially on Windows, where the above + * index element accessor methods can't be defined because of a confusion with + * the pointer typecast operator. + */ template INLINE const Element &PointerToArray:: get_element(size_type n) const { return (*this)[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::set_element -// Access: Published -// Description: This method exists mainly to access the elements of -// the array easily from a high-level language such as -// Python, especially on Windows, where the above index -// element accessor methods can't be defined because of -// a confusion with the pointer typecast operator. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the elements of the array easily from a + * high-level language such as Python, especially on Windows, where the above + * index element accessor methods can't be defined because of a confusion with + * the pointer typecast operator. + */ template INLINE void PointerToArray:: set_element(size_type n, const Element &value) { @@ -485,49 +415,39 @@ set_element(size_type n, const Element &value) { (*this)[n] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get_data -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It returns the entire contents of the vector as a -// block of raw data in a string. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It returns the entire contents of the vector as a block of raw data in a + * string. + */ template INLINE string PointerToArray:: get_data() const { return get_subdata(0, size()); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::set_data -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It replaces the entire contents of the vector from a -// block of raw data in a string. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It replaces the entire contents of the vector from a block of raw data in a + * string. + */ template INLINE void PointerToArray:: set_data(const string &data) { set_subdata(0, size(), data); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get_subdata -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It returns the contents of a portion of the -// vector--from element (n) through element (n + count - -// 1)--as a block of raw data in a string. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It returns the contents of a portion of the vector--from element (n) + * through element (n + count - 1)--as a block of raw data in a string. + */ template INLINE string PointerToArray:: get_subdata(size_type n, size_type count) const { @@ -537,21 +457,16 @@ get_subdata(size_type n, size_type count) const { return string((const char *)(p() + n), sizeof(Element) * count); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::set_subdata -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It replaces the contents of a portion of the -// vector--from element (n) through element (n + count - -// 1)--as a block of raw data in a string. The length -// of the string must be an even multiple of Element -// size bytes. The array may be expanded or truncated -// if the length of the string does not correspond to -// exactly count elements. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It replaces the contents of a portion of the vector--from element (n) + * through element (n + count - 1)--as a block of raw data in a string. The + * length of the string must be an even multiple of Element size bytes. The + * array may be expanded or truncated if the length of the string does not + * correspond to exactly count elements. + */ template INLINE void PointerToArray:: set_subdata(size_type n, size_type count, const string &data) { @@ -569,51 +484,42 @@ set_subdata(size_type n, size_type count, const string &data) { insert(begin() + n + count, ncount - count, Element()); } - // Now boldly replace the data. Hope there aren't any constructors - // or destructors involved here. The user better know what she is - // doing. + // Now boldly replace the data. Hope there aren't any constructors or + // destructors involved here. The user better know what she is doing. memcpy(p() + n, data.data(), sizeof(Element) * ncount); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get(this->_void_ptr) -// Access: Public -// Description: Returns the reference to memory where the vector -// is stored. To be used only with set_void_ptr -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference to memory where the vector is stored. To be used + * only with set_void_ptr + */ template INLINE void *PointerToArray:: get_void_ptr() const { return (this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::set_void_ptr -// Access: Public -// Description: Sets this PTA to point to the pointer passed in -//////////////////////////////////////////////////////////////////// +/** + * Sets this PTA to point to the pointer passed in + */ template INLINE void PointerToArray:: set_void_ptr(void *p) { ((PointerToArray *)this)->reassign((To *)p); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get_ref_count -// Access: Public -// Description: Returns the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count of the underlying vector. + */ template INLINE int PointerToArray:: get_ref_count() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::ref -// Access: Public -// Description: Increments the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Increments the reference count of the underlying vector. + */ template INLINE void PointerToArray:: ref() const { @@ -623,11 +529,9 @@ ref() const { ((To *)(this->_void_ptr))->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::unref -// Access: Public -// Description: Decrements the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the reference count of the underlying vector. + */ template INLINE bool PointerToArray:: unref() const { @@ -635,22 +539,18 @@ unref() const { return ((To *)(this->_void_ptr))->unref(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::get_node_ref_count -// Access: Public -// Description: Returns the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node_ref of the underlying vector. + */ template INLINE int PointerToArray:: get_node_ref_count() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::node_ref -// Access: Public -// Description: Increments the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Increments the node_ref of the underlying vector. + */ template INLINE void PointerToArray:: node_ref() const { @@ -660,11 +560,9 @@ node_ref() const { ((To *)(this->_void_ptr))->node_ref(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::node_unref -// Access: Public -// Description: Decrements the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the node_ref of the underlying vector. + */ template INLINE bool PointerToArray:: node_unref() const { @@ -672,11 +570,9 @@ node_unref() const { return ((To *)(this->_void_ptr))->node_unref(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray &PointerToArray:: operator = (ReferenceCountedVector *ptr) { @@ -684,11 +580,9 @@ operator = (ReferenceCountedVector *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray &PointerToArray:: operator = (const PointerToArray ©) { @@ -698,11 +592,9 @@ operator = (const PointerToArray ©) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArray &PointerToArray:: operator = (PointerToArray &&from) NOEXCEPT { @@ -712,13 +604,10 @@ operator = (PointerToArray &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::clear -// Access: Public -// Description: To empty the PTA, use the clear() method, since -// assignment to NULL is problematic (given the -// ambiguity of the pointer type of NULL). -//////////////////////////////////////////////////////////////////// +/** + * To empty the PTA, use the clear() method, since assignment to NULL is + * problematic (given the ambiguity of the pointer type of NULL). + */ template INLINE void PointerToArray:: clear() { @@ -727,11 +616,9 @@ clear() { -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray:: ConstPointerToArray(TypeHandle type_handle) : @@ -740,11 +627,9 @@ ConstPointerToArray(TypeHandle type_handle) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray:: ConstPointerToArray(const PointerToArray ©) : @@ -753,11 +638,9 @@ ConstPointerToArray(const PointerToArray ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray:: ConstPointerToArray(const ConstPointerToArray ©) : @@ -767,11 +650,9 @@ ConstPointerToArray(const ConstPointerToArray ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray:: ConstPointerToArray(PointerToArray &&from) NOEXCEPT : @@ -782,11 +663,9 @@ ConstPointerToArray(PointerToArray &&from) NOEXCEPT : #endif // USE_MOVE_SEMANTICS #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray:: ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT : @@ -796,11 +675,9 @@ ConstPointerToArray(ConstPointerToArray &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::begin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: begin() const { @@ -810,11 +687,9 @@ begin() const { return ((To *)(this->_void_ptr))->begin(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::end -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::iterator ConstPointerToArray:: end() const { @@ -824,11 +699,9 @@ end() const { return ((To *)(this->_void_ptr))->end(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::rbegin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: rbegin() const { @@ -838,11 +711,9 @@ rbegin() const { return ((To *)(this->_void_ptr))->rbegin(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::rend -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reverse_iterator ConstPointerToArray:: rend() const { @@ -852,22 +723,18 @@ rend() const { return ((To *)(this->_void_ptr))->rend(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: size() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::max_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: max_size() const { @@ -877,22 +744,18 @@ max_size() const { return ((To *)(this->_void_ptr))->max_size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool ConstPointerToArray:: empty() const { return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::capacity -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::size_type ConstPointerToArray:: capacity() const { @@ -902,11 +765,9 @@ capacity() const { return ((To *)(this->_void_ptr))->capacity(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::front -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: front() const { @@ -919,11 +780,9 @@ front() const { return ((To *)(this->_void_ptr))->front(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::back -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: back() const { @@ -937,11 +796,9 @@ back() const { } #if !defined(WIN32_VC) && !defined(WIN64_VC) -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: operator [](size_type n) const { @@ -955,11 +812,9 @@ operator [](size_type n) const { return ((To *)(this->_void_ptr))->operator[](n); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ConstPointerToArray::reference ConstPointerToArray:: operator [](int n) const { @@ -967,15 +822,12 @@ operator [](int n) const { } #endif -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Typecast operator -// Access: Public -// Description: The pointer typecast operator is convenient for -// maintaining the fiction that we actually have a -// C-style array. It returns the address of the first -// element in the array, unless the pointer is -// unassigned, in which case it returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * The pointer typecast operator is convenient for maintaining the fiction + * that we actually have a C-style array. It returns the address of the first + * element in the array, unless the pointer is unassigned, in which case it + * returns NULL. + */ template INLINE ConstPointerToArray:: operator const Element *() const { @@ -983,13 +835,10 @@ operator const Element *() const { return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::p -// Access: Public -// Description: Function p() is similar to the function from -// ConstPointerTo. It does the same thing: it returns the -// same thing as the typecast operator, above. -//////////////////////////////////////////////////////////////////// +/** + * Function p() is similar to the function from ConstPointerTo. It does the + * same thing: it returns the same thing as the typecast operator, above. + */ template INLINE const Element *ConstPointerToArray:: p() const { @@ -997,12 +846,10 @@ p() const { return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front()); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::v -// Access: Public -// Description: To access the vector itself, for more direct fiddling -// with some of the vector's esoteric functionality. -//////////////////////////////////////////////////////////////////// +/** + * To access the vector itself, for more direct fiddling with some of the + * vector's esoteric functionality. + */ template INLINE const pvector &ConstPointerToArray:: v() const { @@ -1012,24 +859,20 @@ v() const { return *(const To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::v0 -// Access: Public -// Description: To access the internal ReferenceCountedVector object, -// for very low-level fiddling. Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * To access the internal ReferenceCountedVector object, for very low-level + * fiddling. Know what you are doing! + */ template INLINE const ReferenceCountedVector *ConstPointerToArray:: v0() const { return (const To *)(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::cast_non_const -// Access: Public -// Description: Casts away the constness of the CPTA(Element), and -// returns an equivalent PTA(Element). -//////////////////////////////////////////////////////////////////// +/** + * Casts away the constness of the CPTA(Element), and returns an equivalent + * PTA(Element). + */ template INLINE PointerToArray ConstPointerToArray:: cast_non_const() const { @@ -1038,48 +881,38 @@ cast_non_const() const { return non_const; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::get_element -// Access: Published -// Description: This method exists mainly to access the elements of -// the array easily from a high-level language such as -// Python, especially on Windows, where the above index -// element accessor methods can't be defined because of -// a confusion with the pointer typecast operator. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the elements of the array easily from a + * high-level language such as Python, especially on Windows, where the above + * index element accessor methods can't be defined because of a confusion with + * the pointer typecast operator. + */ template INLINE const Element &ConstPointerToArray:: get_element(size_type n) const { return (*this)[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::get_data -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It returns the entire contents of the vector as a -// block of raw data in a string. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It returns the entire contents of the vector as a block of raw data in a + * string. + */ template INLINE string ConstPointerToArray:: get_data() const { return get_subdata(0, size()); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::get_subdata -// Access: Published -// Description: This method exists mainly to access the data of -// the array easily from a high-level language such as -// Python. -// -// It returns the contents of a portion of the -// vector--from element (n) through element (n + count - -// 1)--as a block of raw data in a string. -//////////////////////////////////////////////////////////////////// +/** + * This method exists mainly to access the data of the array easily from a + * high-level language such as Python. + * + * It returns the contents of a portion of the vector--from element (n) + * through element (n + count - 1)--as a block of raw data in a string. + */ template INLINE string ConstPointerToArray:: get_subdata(size_type n, size_type count) const { @@ -1089,22 +922,18 @@ get_subdata(size_type n, size_type count) const { return string((const char *)(p() + n), sizeof(Element) * count); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::get_ref_count -// Access: Public -// Description: Returns the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count of the underlying vector. + */ template INLINE int ConstPointerToArray:: get_ref_count() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_ref_count(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::ref -// Access: Public -// Description: Increments the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Increments the reference count of the underlying vector. + */ template INLINE void ConstPointerToArray:: ref() const { @@ -1114,11 +943,9 @@ ref() const { ((To *)(this->_void_ptr))->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::unref -// Access: Public -// Description: Decrements the reference count of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the reference count of the underlying vector. + */ template INLINE bool ConstPointerToArray:: unref() const { @@ -1126,22 +953,18 @@ unref() const { return ((To *)(this->_void_ptr))->unref(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::get_node_ref_count -// Access: Public -// Description: Returns the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node_ref of the underlying vector. + */ template INLINE int ConstPointerToArray:: get_node_ref_count() const { return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->get_node_ref_count(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::node_ref -// Access: Public -// Description: Increments the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Increments the node_ref of the underlying vector. + */ template INLINE void ConstPointerToArray:: node_ref() const { @@ -1151,11 +974,9 @@ node_ref() const { ((To *)(this->_void_ptr))->node_ref(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::node_unref -// Access: Public -// Description: Decrements the node_ref of the underlying vector. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the node_ref of the underlying vector. + */ template INLINE bool ConstPointerToArray:: node_unref() const { @@ -1163,11 +984,9 @@ node_unref() const { return ((To *)(this->_void_ptr))->node_unref(); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (ReferenceCountedVector *ptr) { @@ -1175,11 +994,9 @@ operator = (ReferenceCountedVector *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (const PointerToArray ©) { @@ -1188,11 +1005,9 @@ operator = (const PointerToArray ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (const ConstPointerToArray ©) { @@ -1202,11 +1017,9 @@ operator = (const ConstPointerToArray ©) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (PointerToArray &&from) NOEXCEPT { @@ -1217,11 +1030,9 @@ operator = (PointerToArray &&from) NOEXCEPT { #endif // USE_MOVE_SEMANTICS #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ConstPointerToArray &ConstPointerToArray:: operator = (ConstPointerToArray &&from) NOEXCEPT { @@ -1231,13 +1042,10 @@ operator = (ConstPointerToArray &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::clear -// Access: Public -// Description: To empty the PTA, use the clear() method, since -// assignment to NULL is problematic (given the -// ambiguity of the pointer type of NULL). -//////////////////////////////////////////////////////////////////// +/** + * To empty the PTA, use the clear() method, since assignment to NULL is + * problematic (given the ambiguity of the pointer type of NULL). + */ template INLINE void ConstPointerToArray:: clear() { diff --git a/panda/src/express/pointerToArray.cxx b/panda/src/express/pointerToArray.cxx index a3e7bd8fd2..5b0940802b 100644 --- a/panda/src/express/pointerToArray.cxx +++ b/panda/src/express/pointerToArray.cxx @@ -1,15 +1,14 @@ -// Filename: pointerToArray.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArray.cxx + * @author drose + * @date 2004-09-27 + */ #include "pointerToArray.h" diff --git a/panda/src/express/pointerToArray.h b/panda/src/express/pointerToArray.h index 0f1d4cd5c8..5632a8246f 100644 --- a/panda/src/express/pointerToArray.h +++ b/panda/src/express/pointerToArray.h @@ -1,68 +1,50 @@ -// Filename: pointerToArray.h -// Created by: drose (14Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArray.h + * @author drose + * @date 1999-01-14 + */ #ifndef POINTERTOARRAY_H #define POINTERTOARRAY_H -//////////////////////////////////////////////////////////////////// -// -// This file defines the classes PointerToArray and -// ConstPointerToArray (and their abbreviations, PTA and CPTA), which -// are extensions to the PointerTo class that support -// reference-counted arrays. -// -// You may think of a PointerToArray as the same thing as a -// traditional C-style array. However, it actually stores a pointer -// to an STL vector, which is then reference-counted. Thus, most -// vector operations may be applied directly to a PointerToArray -// object, including dynamic resizing via push_back() and pop_back(). -// -// Unlike the PointerTo class, the PointerToArray may store pointers -// to any kind of object, not just those derived from ReferenceCount. -// -// Like PointerTo and ConstPointerTo, the macro abbreviations PTA and -// CPTA are defined for convenience. -// -// Some examples of syntax: instead of: -// -// PTA(int) array(10); int *array = new int[10]; -// memset(array, 0, sizeof(int) * 10); memset(array, 0, sizeof(int) * 10); -// array[i] = array[i+1]; array[i] = array[i+1]; -// num_elements = array.size(); (no equivalent) -// -// PTA(int) copy = array; int *copy = array; -// -// Note that in the above example, unlike an STL vector (but like a -// C-style array), assigning a PointerToArray object from another -// simply copies the pointer, and does not copy individual elements. -// (Of course, reference counts are adjusted appropriately7.) If you -// actually wanted an element-by-element copy of the array, you would -// do this: -// -// PTA(int) copy(0); // Create a pointer to an empty vector. -// copy.v() = array.v(); // v() is the STL vector itself. -// -// The (0) parameter to the constructor in the above example is -// crucial. When a numeric length parameter, such as zero, is given -// to the constructor, it means to define a new STL vector with that -// number of elements initially in it. If no parameter is given, on -// the other hand, it means the PointerToArray should point to -// nothing--no STL vector is created. This is equivalent to a C array -// that points to NULL. -// -//////////////////////////////////////////////////////////////////// +/* + * This file defines the classes PointerToArray and ConstPointerToArray (and + * their abbreviations, PTA and CPTA), which are extensions to the PointerTo + * class that support reference-counted arrays. You may think of a + * PointerToArray as the same thing as a traditional C-style array. However, + * it actually stores a pointer to an STL vector, which is then reference- + * counted. Thus, most vector operations may be applied directly to a + * PointerToArray object, including dynamic resizing via push_back() and + * pop_back(). Unlike the PointerTo class, the PointerToArray may store + * pointers to any kind of object, not just those derived from ReferenceCount. + * Like PointerTo and ConstPointerTo, the macro abbreviations PTA and CPTA are + * defined for convenience. Some examples of syntax: instead of: + * PTA(int) array(10); int *array = new int[10]; + * memset(array, 0, sizeof(int) * 10); memset(array, 0, sizeof(int) * 10); + * array[i] = array[i+1]; array[i] = array[i+1]; num_elements + * = array.size(); (no equivalent) PTA(int) copy = array; + * int *copy = array; Note that in the above example, unlike an STL vector + * (but like a C-style array), assigning a PointerToArray object from another + * simply copies the pointer, and does not copy individual elements. (Of + * course, reference counts are adjusted appropriately7.) If you actually + * wanted an element-by-element copy of the array, you would do this: PTA(int) + * copy(0); Create a pointer to an empty vector. copy.v() = + * array.v(); v() is the STL vector itself. The (0) parameter to + * the constructor in the above example is crucial. When a numeric length + * parameter, such as zero, is given to the constructor, it means to define a + * new STL vector with that number of elements initially in it. If no + * parameter is given, on the other hand, it means the PointerToArray should + * point to nothing--no STL vector is created. This is equivalent to a C + * array that points to NULL. + */ #include "pandabase.h" @@ -77,31 +59,25 @@ template class ConstPointerToArray; -//////////////////////////////////////////////////////////////////// -// Class : PointerToArray -// Description : A special kind of PointerTo that stores an array of -// the indicated element type, instead of a single -// element. This is actually implemented as an STL -// vector, using the RefCountObj class to wrap it up -// with a reference count. -// -// We actually inherit from NodeRefCountObj these days, -// which adds node_ref() and node_unref() to the -// standard ref() and unref(). This is particularly -// useful for GeomVertexArrayData; other classes may or -// may not find this additional counter useful, but -// since it adds relatively little overhead (compared -// with what is presumably a largish array), we go ahead -// and add it here, even though it is inherited by many -// different parts of the system that may not use it. -//////////////////////////////////////////////////////////////////// +/** + * A special kind of PointerTo that stores an array of the indicated element + * type, instead of a single element. This is actually implemented as an STL + * vector, using the RefCountObj class to wrap it up with a reference count. + * + * We actually inherit from NodeRefCountObj these days, which adds node_ref() + * and node_unref() to the standard ref() and unref(). This is particularly + * useful for GeomVertexArrayData; other classes may or may not find this + * additional counter useful, but since it adds relatively little overhead + * (compared with what is presumably a largish array), we go ahead and add it + * here, even though it is inherited by many different parts of the system + * that may not use it. + */ template class PointerToArray : public PointerToArrayBase { public: - // By hiding this template from interrogate, we would improve - // compile-time speed and memory utilization. However, we do want - // to export a minimal subset of this class. So we define just the - // exportable interface here. + // By hiding this template from interrogate, we would improve compile-time + // speed and memory utilization. However, we do want to export a minimal + // subset of this class. So we define just the exportable interface here. #ifdef CPPPARSER PUBLISHED: typedef TYPENAME pvector::size_type size_type; @@ -156,18 +132,17 @@ public: #endif public: - // Duplicating the interface of vector. The following member - // functions are all const, because they do not reassign the - // pointer--they operate only within the vector itself, which is - // non-const in this class. + // Duplicating the interface of vector. The following member functions are + // all const, because they do not reassign the pointer--they operate only + // within the vector itself, which is non-const in this class. INLINE iterator begin() const; INLINE iterator end() const; INLINE TYPENAME PointerToArray::reverse_iterator rbegin() const; INLINE TYPENAME PointerToArray::reverse_iterator rend() const; - // Equality and comparison operators are pointerwise for - // PointerToArrays, not elementwise as in vector. + // Equality and comparison operators are pointerwise for PointerToArrays, + // not elementwise as in vector. INLINE size_type size() const; INLINE size_type max_size() const; INLINE bool empty() const; @@ -181,11 +156,10 @@ public: INLINE iterator insert(iterator position, const Element &x); INLINE void insert(iterator position, size_type n, const Element &x); - // We don't define the insert() method that accepts a pair of - // iterators to copy from. That's problematic because of the whole - // member template thing. If you really need this, use - // pta.v().insert(...); if you're doing this on a vector that has to - // be exported from the DLL, you should use + // We don't define the insert() method that accepts a pair of iterators to + // copy from. That's problematic because of the whole member template + // thing. If you really need this, use pta.v().insert(...); if you're doing + // this on a vector that has to be exported from the DLL, you should use // insert_into_vector(pta.v(), ...). INLINE void erase(iterator position); @@ -213,12 +187,12 @@ public: INLINE string get_subdata(size_type n, size_type count) const; INLINE void set_subdata(size_type n, size_type count, const string &data); - //These functions are only to be used in Reading through BamReader. - //They are designed to work in pairs, so that you register what is - //returned by get_void_ptr with BamReader and when you are setting - //another PTA with what is returned by BamReader, you set it with - //set_void_ptr. If you used the provided macro of READ_PTA, this is - //done for you. So you should never call these functions directly + // These functions are only to be used in Reading through BamReader. They + // are designed to work in pairs, so that you register what is returned by + // get_void_ptr with BamReader and when you are setting another PTA with + // what is returned by BamReader, you set it with set_void_ptr. If you used + // the provided macro of READ_PTA, this is done for you. So you should + // never call these functions directly INLINE void *get_void_ptr() const; INLINE void set_void_ptr(void* p); @@ -247,29 +221,25 @@ private: TypeHandle _type_handle; private: - // This static empty array is kept around just so we can return - // something meaningful when begin() or end() is called and we have a - // NULL pointer. It might not be shared properly between different - // .so's, since it's a static member of a template class, but we - // don't really care. + // This static empty array is kept around just so we can return something + // meaningful when begin() or end() is called and we have a NULL pointer. + // It might not be shared properly between different .so's, since it's a + // static member of a template class, but we don't really care. static pvector _empty_array; #endif // CPPPARSER friend class ConstPointerToArray; }; -//////////////////////////////////////////////////////////////////// -// Class : ConstPointerToArray -// Description : Similar to PointerToArray, except that its contents -// may not be modified. -//////////////////////////////////////////////////////////////////// +/** + * Similar to PointerToArray, except that its contents may not be modified. + */ template class ConstPointerToArray : public PointerToArrayBase { public: - // By hiding this template from interrogate, we would improve - // compile-time speed and memory utilization. However, we do want - // to export a minimal subset of this class. So we define just the - // exportable interface here. + // By hiding this template from interrogate, we would improve compile-time + // speed and memory utilization. However, we do want to export a minimal + // subset of this class. So we define just the exportable interface here. #ifdef CPPPARSER PUBLISHED: INLINE ConstPointerToArray(const PointerToArray ©); @@ -327,8 +297,8 @@ PUBLISHED: INLINE TYPENAME ConstPointerToArray::reverse_iterator rbegin() const; INLINE TYPENAME ConstPointerToArray::reverse_iterator rend() const; - // Equality and comparison operators are pointerwise for - // PointerToArrays, not elementwise as in vector. + // Equality and comparison operators are pointerwise for PointerToArrays, + // not elementwise as in vector. INLINE size_type size() const; INLINE size_type max_size() const; @@ -384,11 +354,10 @@ private: TypeHandle _type_handle; private: - // This static empty array is kept around just so we can return - // something meangful when begin() or end() is called and we have a - // NULL pointer. It might not be shared properly between different - // .so's, since it's a static member of a template class, but we - // don't really care. + // This static empty array is kept around just so we can return something + // meangful when begin() or end() is called and we have a NULL pointer. It + // might not be shared properly between different .so's, since it's a static + // member of a template class, but we don't really care. static pvector _empty_array; #endif // CPPPARSER diff --git a/panda/src/express/pointerToArrayBase.I b/panda/src/express/pointerToArrayBase.I index 343fb7374d..885d759aed 100644 --- a/panda/src/express/pointerToArrayBase.I +++ b/panda/src/express/pointerToArrayBase.I @@ -1,33 +1,27 @@ -// Filename: pointerToArrayBase.I -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArrayBase.I + * @author drose + * @date 2006-10-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ReferenceCountedVector:: ReferenceCountedVector(TypeHandle type_handle) : pvector(type_handle) { } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ReferenceCountedVector:: ReferenceCountedVector(const ReferenceCountedVector ©) : @@ -36,11 +30,9 @@ ReferenceCountedVector(const ReferenceCountedVector ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::empty_array constructor -// Access: Public -// Description: Creates an array of initial_size elements. -//////////////////////////////////////////////////////////////////// +/** + * Creates an array of initial_size elements. + */ template INLINE ReferenceCountedVector:: ReferenceCountedVector(TYPENAME ReferenceCountedVector::size_type initial_size, TypeHandle type_handle) : @@ -48,98 +40,80 @@ ReferenceCountedVector(TYPENAME ReferenceCountedVector::size_type initi { } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ReferenceCountedVector:: ~ReferenceCountedVector() { } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ReferenceCountedVector::size_type ReferenceCountedVector:: size() const { return pvector::size(); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ReferenceCountedVector::iterator ReferenceCountedVector:: insert(iterator position, const Element &x) { return pvector::insert(position, x); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ReferenceCountedVector:: insert(iterator position, size_type n, const Element &x) { pvector::insert(position, n, x); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::erase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ReferenceCountedVector:: erase(iterator position) { pvector::erase(position); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::erase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ReferenceCountedVector:: erase(iterator first, iterator last) { pvector::erase(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::pop_back -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ReferenceCountedVector:: pop_back() { pvector::pop_back(); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCountedVector::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ReferenceCountedVector:: clear() { pvector::clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArrayBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArrayBase:: PointerToArrayBase(ReferenceCountedVector *ptr) : @@ -147,11 +121,9 @@ PointerToArrayBase(ReferenceCountedVector *ptr) : { } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArrayBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArrayBase:: PointerToArrayBase(const PointerToArrayBase ©) : @@ -160,11 +132,9 @@ PointerToArrayBase(const PointerToArrayBase ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArrayBase::Move Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArrayBase:: PointerToArrayBase(PointerToArrayBase &&from) NOEXCEPT : @@ -173,13 +143,10 @@ PointerToArrayBase(PointerToArrayBase &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToArrayBase::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToArrayBase:: ~PointerToArrayBase() { } - diff --git a/panda/src/express/pointerToArrayBase.cxx b/panda/src/express/pointerToArrayBase.cxx index 96cf77e02f..86366ae892 100644 --- a/panda/src/express/pointerToArrayBase.cxx +++ b/panda/src/express/pointerToArrayBase.cxx @@ -1,16 +1,15 @@ -// Filename: pointerToArrayBase.cxx -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArrayBase.cxx + * @author drose + * @date 2006-10-30 + */ #include "pointerToArrayBase.h" diff --git a/panda/src/express/pointerToArrayBase.h b/panda/src/express/pointerToArrayBase.h index fe481842be..291ffed656 100644 --- a/panda/src/express/pointerToArrayBase.h +++ b/panda/src/express/pointerToArrayBase.h @@ -1,16 +1,15 @@ -// Filename: pointerToArrayBase.h -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArrayBase.h + * @author drose + * @date 2006-10-30 + */ #ifndef POINTERTOARRAYBASE_H #define POINTERTOARRAYBASE_H @@ -22,23 +21,19 @@ #include "pvector.h" #include "memoryBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ReferenceCountedVector -// Description : This defines the object that is actually stored and -// reference-counted internally by a PointerToArray. It -// is basically a NodeReferenceCount-capable STL vector. -// -// We use NodeReferenceCount (instead of just -// ReferenceCount), which adds node_ref() and -// node_unref() to the standard ref() and unref(). This -// is particularly useful for GeomVertexArrayData; other -// classes may or may not find this additional counter -// useful, but since it adds relatively little overhead -// (compared with what is presumably a largish array), -// we go ahead and add it here, even though it is -// inherited by many different parts of the system that -// may not use it. -//////////////////////////////////////////////////////////////////// +/** + * This defines the object that is actually stored and reference-counted + * internally by a PointerToArray. It is basically a NodeReferenceCount- + * capable STL vector. + * + * We use NodeReferenceCount (instead of just ReferenceCount), which adds + * node_ref() and node_unref() to the standard ref() and unref(). This is + * particularly useful for GeomVertexArrayData; other classes may or may not + * find this additional counter useful, but since it adds relatively little + * overhead (compared with what is presumably a largish array), we go ahead + * and add it here, even though it is inherited by many different parts of the + * system that may not use it. + */ template class ReferenceCountedVector : public NodeReferenceCount, public pvector { public: @@ -63,16 +58,13 @@ public: INLINE void clear(); }; -//////////////////////////////////////////////////////////////////// -// Class : PointerToArrayBase -// Description : This is the base class for PointerToArray and -// ConstPointerToArray. Don't try to use it directly; -// use either derived class instead. -// -// This extends PointerToBase to be a pointer to a -// ReferenceCountedVector, above, which is essentially a -// reference-counted STL vector. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for PointerToArray and ConstPointerToArray. Don't + * try to use it directly; use either derived class instead. + * + * This extends PointerToBase to be a pointer to a ReferenceCountedVector, + * above, which is essentially a reference-counted STL vector. + */ template class PointerToArrayBase : public PointerToBase > { public: @@ -93,4 +85,3 @@ PUBLISHED: #include "pointerToArrayBase.I" #endif - diff --git a/panda/src/express/pointerToArray_ext.I b/panda/src/express/pointerToArray_ext.I index f8a1ffc600..82ba097d24 100644 --- a/panda/src/express/pointerToArray_ext.I +++ b/panda/src/express/pointerToArray_ext.I @@ -1,26 +1,21 @@ -// Filename: pointerToArray_ext.I -// Created by: rdb (08Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArray_ext.I + * @author rdb + * @date 2015-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__init__ -// Access: Published -// Description: This special constructor accepts a Python list of -// elements, or a Python string (or a bytes object, -// in Python 3), or any object that supports the -// Python buffer protocol. -//////////////////////////////////////////////////////////////////// +/** + * This special constructor accepts a Python list of elements, or a Python + * string (or a bytes object, in Python 3), or any object that supports the + * Python buffer protocol. + */ template INLINE void Extension >:: __init__(PyObject *self, PyObject *source) { @@ -64,10 +59,10 @@ __init__(PyObject *self, PyObject *source) { return; } - // If we were passed a Python string, then instead of storing it - // character-at-a-time, just load the whole string as a data - // buffer. Not sure if this case is still necessary - don't Python - // str/bytes objects export the buffer protocol, as above? + // If we were passed a Python string, then instead of storing it character- + // at-a-time, just load the whole string as a data buffer. Not sure if this + // case is still necessary - don't Python strbytes objects export the buffer + // protocol, as above? #if PY_MAJOR_VERSION >= 3 if (PyBytes_Check(source)) { int size = PyBytes_Size(source); @@ -81,8 +76,7 @@ __init__(PyObject *self, PyObject *source) { int num_elements = size / sizeof(Element); this->_this->insert(this->_this->begin(), num_elements, Element()); - // Hope there aren't any constructors or destructors involved - // here. + // Hope there aren't any constructors or destructors involved here. if (size != 0) { const char *data = PyBytes_AsString(source); memcpy(this->_this->p(), data, size); @@ -102,8 +96,7 @@ __init__(PyObject *self, PyObject *source) { int num_elements = size / sizeof(Element); this->_this->insert(this->_this->begin(), num_elements, Element()); - // Hope there aren't any constructors or destructors involved - // here. + // Hope there aren't any constructors or destructors involved here. if (size != 0) { const char *data = PyString_AsString(source); memcpy(this->_this->p(), data, size); @@ -112,8 +105,8 @@ __init__(PyObject *self, PyObject *source) { } #endif - // Now construct the internal list by copying the elements - // one-at-a-time from Python. + // Now construct the internal list by copying the elements one-at-a-time + // from Python. PyObject *push_back = PyObject_GetAttrString(self, "push_back"); if (push_back == NULL) { PyErr_BadArgument(); @@ -143,37 +136,28 @@ __init__(PyObject *self, PyObject *source) { } } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__getitem__ -// Access: Published -// Description: Same as get_element(), this returns the nth element -// of the array. -//////////////////////////////////////////////////////////////////// +/** + * Same as get_element(), this returns the nth element of the array. + */ template INLINE const Element &Extension >:: __getitem__(size_t n) const { return this->_this->get_element(n); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__setitem__ -// Access: Published -// Description: Same as set_element(), this replaces the nth element -// of the array. -//////////////////////////////////////////////////////////////////// +/** + * Same as set_element(), this replaces the nth element of the array. + */ template INLINE void Extension >:: __setitem__(size_t n, const Element &value) { this->_this->set_element(n, value); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__init__ -// Access: Public -// Description: This special constructor accepts a Python list of -// elements, or a Python string (or a bytes object, -// in Python 3). -//////////////////////////////////////////////////////////////////// +/** + * This special constructor accepts a Python list of elements, or a Python + * string (or a bytes object, in Python 3). + */ template INLINE void Extension >:: __init__(PyObject *self, PyObject *source) { @@ -182,12 +166,9 @@ __init__(PyObject *self, PyObject *source) { *(this->_this) = MOVE(array); } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__getitem__ -// Access: Published -// Description: Same as get_element(), this returns the nth element -// of the array. -//////////////////////////////////////////////////////////////////// +/** + * Same as get_element(), this returns the nth element of the array. + */ template INLINE const Element &Extension >:: __getitem__(size_t n) const { @@ -195,13 +176,10 @@ __getitem__(size_t n) const { } #if PY_VERSION_HEX >= 0x02060000 -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__getbuffer__ -// Access: Published -// Description: This is used to implement the buffer protocol, in -// order to allow efficient access to the array data -// through a Python multiview object. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement the buffer protocol, in order to allow efficient + * access to the array data through a Python multiview object. + */ template INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { @@ -227,9 +205,9 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { view->ndim = 1; view->shape = NULL; if ((flags & PyBUF_ND) == PyBUF_ND) { - // This leaks, which sucks, but __releasebuffer__ doesn't give us - // the same pointer, so we would need to store it elsewhere if we - // wanted to delete it there. Eh, it's just an int, who cares. + // This leaks, which sucks, but __releasebuffer__ doesn't give us the same + // pointer, so we would need to store it elsewhere if we wanted to delete + // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } view->strides = NULL; @@ -238,19 +216,17 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { } view->suboffsets = NULL; - // Store a reference to ourselves on the Py_buffer object - // as a reminder that we have increased our refcount. + // Store a reference to ourselves on the Py_buffer object as a reminder that + // we have increased our refcount. this->_this->ref(); view->internal = (void*) this->_this; return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToArray::__releasebuffer__ -// Access: Published -// Description: Releases the buffer allocated by __getbuffer__. -//////////////////////////////////////////////////////////////////// +/** + * Releases the buffer allocated by __getbuffer__. + */ template INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { @@ -263,13 +239,10 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__getbuffer__ -// Access: Published -// Description: This is used to implement the buffer protocol, in -// order to allow efficient access to the array data -// through a Python multiview object. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement the buffer protocol, in order to allow efficient + * access to the array data through a Python multiview object. + */ template INLINE int Extension >:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { @@ -301,9 +274,9 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { view->ndim = 1; view->shape = NULL; if ((flags & PyBUF_ND) == PyBUF_ND) { - // This leaks, which sucks, but __releasebuffer__ doesn't give us - // the same pointer, so we would need to store it elsewhere if we - // wanted to delete it there. Eh, it's just an int, who cares. + // This leaks, which sucks, but __releasebuffer__ doesn't give us the same + // pointer, so we would need to store it elsewhere if we wanted to delete + // it there. Eh, it's just an int, who cares. view->shape = new Py_ssize_t(this->_this->size()); } view->strides = NULL; @@ -312,19 +285,17 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { } view->suboffsets = NULL; - // Store a reference to ourselves on the Py_buffer object - // as a reminder that we have increased our refcount. + // Store a reference to ourselves on the Py_buffer object as a reminder that + // we have increased our refcount. this->_this->ref(); view->internal = (void*) this->_this; return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConstPointerToArray::__releasebuffer__ -// Access: Published -// Description: Releases the buffer allocated by __getbuffer__. -//////////////////////////////////////////////////////////////////// +/** + * Releases the buffer allocated by __getbuffer__. + */ template INLINE void Extension >:: __releasebuffer__(PyObject *self, Py_buffer *view) const { diff --git a/panda/src/express/pointerToArray_ext.h b/panda/src/express/pointerToArray_ext.h index c4f7afdfec..d5c3fd5824 100644 --- a/panda/src/express/pointerToArray_ext.h +++ b/panda/src/express/pointerToArray_ext.h @@ -1,16 +1,15 @@ -// Filename: pointerToArray_ext.h -// Created by: rdb (08Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToArray_ext.h + * @author rdb + * @date 2015-02-08 + */ #ifndef POINTERTOARRAY_EXT_H #define POINTERTOARRAY_EXT_H @@ -21,15 +20,13 @@ #include "py_panda.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// PointerToArray, which are called instead of -// any C++ methods with the same prototype. -// -// This is a little bit awkward because of the nested -// templating, but it does the job. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for PointerToArray, which are + * called instead of any C++ methods with the same prototype. + * + * This is a little bit awkward because of the nested templating, but it does + * the job. + */ template class Extension > : public ExtensionBase > { public: @@ -44,15 +41,13 @@ public: #endif }; -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// ConstPointerToArray, which are called instead of -// any C++ methods with the same prototype. -// -// This is a little bit awkward because of the nested -// templating, but it does the job. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for ConstPointerToArray, which are + * called instead of any C++ methods with the same prototype. + * + * This is a little bit awkward because of the nested templating, but it does + * the job. + */ template class Extension > : public ExtensionBase > { public: @@ -86,8 +81,8 @@ template class EXPORT_THIS Extension; template class EXPORT_THIS Extension; #endif -// This macro is used to map a data type to a format code -// as used in the Python 'struct' and 'array' modules. +// This macro is used to map a data type to a format code as used in the +// Python 'struct' and 'array' modules. #define get_format_code(type) _get_format_code((const type *)0) #define define_format_code(code, type) template<> \ INLINE const char *_get_format_code(const type *) { \ diff --git a/panda/src/express/pointerToBase.I b/panda/src/express/pointerToBase.I index 09b5f3c75b..20cac87718 100644 --- a/panda/src/express/pointerToBase.I +++ b/panda/src/express/pointerToBase.I @@ -1,45 +1,37 @@ -// Filename: pointerToBase.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToBase.I + * @author drose + * @date 2004-09-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToBase:: PointerToBase(To *ptr) { reassign(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToBase:: PointerToBase(const PointerToBase ©) { reassign(copy); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToBase:: ~PointerToBase() { @@ -47,11 +39,9 @@ INLINE PointerToBase:: } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::Move Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PointerToBase:: PointerToBase(PointerToBase &&from) NOEXCEPT { @@ -59,15 +49,12 @@ PointerToBase(PointerToBase &&from) NOEXCEPT { from._void_ptr = (void *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::reassign -// Access: Protected -// Description: This version of reassign is called when a PointerTo -// is assigned to this PointerTo as an rvalue. In -// this case, we can steal the reference count from -// the other PointerTo, without needing to call ref() -// and unref() unnecessarily. -//////////////////////////////////////////////////////////////////// +/** + * This version of reassign is called when a PointerTo is assigned to this + * PointerTo as an rvalue. In this case, we can steal the reference count + * from the other PointerTo, without needing to call ref() and unref() + * unnecessarily. + */ template INLINE void PointerToBase:: reassign(PointerToBase &&from) NOEXCEPT { @@ -86,22 +73,18 @@ reassign(PointerToBase &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::reassign -// Access: Protected -// Description: This is the main work of the PointerTo family. When -// the pointer is reassigned, decrement the old -// reference count and increment the new one. -//////////////////////////////////////////////////////////////////// +/** + * This is the main work of the PointerTo family. When the pointer is + * reassigned, decrement the old reference count and increment the new one. + */ template INLINE void PointerToBase:: reassign(To *ptr) { if (ptr != (To *)_void_ptr) { - // First save the old pointer; we won't delete it until we have - // assigned the new one. We do this just in case there are - // cascading effects from deleting this pointer that might - // inadvertently delete the new one. (Don't laugh--it's - // happened!) + // First save the old pointer; we won't delete it until we have assigned + // the new one. We do this just in case there are cascading effects from + // deleting this pointer that might inadvertently delete the new one. + // (Don't laugh--it's happened!) To *old_ptr = (To *)_void_ptr; _void_ptr = (void *)ptr; @@ -121,11 +104,9 @@ reassign(To *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::reassign -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PointerToBase:: reassign(const PointerToBase ©) { @@ -133,13 +114,10 @@ reassign(const PointerToBase ©) { } #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::update_type -// Access: Protected -// Description: Ensures that the MemoryUsage record for the pointer -// has the right type of object, if we know the type -// ourselves. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the MemoryUsage record for the pointer has the right type of + * object, if we know the type ourselves. + */ template void PointerToBase:: update_type(To *ptr) { @@ -155,24 +133,20 @@ update_type(To *ptr) { #endif // DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::clear -// Access: Published -// Description: A convenient way to set the PointerTo object to NULL. -// (Assignment to a NULL pointer also works, of course.) -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to set the PointerTo object to NULL. (Assignment to a NULL + * pointer also works, of course.) + */ template ALWAYS_INLINE void PointerToBase:: clear() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToBase::output -// Access: Published -// Description: A handy function to output PointerTo's as a hex -// pointer followed by a reference count. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to output PointerTo's as a hex pointer followed by a + * reference count. + */ template INLINE void PointerToBase:: output(ostream &out) const { diff --git a/panda/src/express/pointerToBase.cxx b/panda/src/express/pointerToBase.cxx index e67704e193..1c980515d7 100644 --- a/panda/src/express/pointerToBase.cxx +++ b/panda/src/express/pointerToBase.cxx @@ -1,15 +1,14 @@ -// Filename: pointerToBase.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToBase.cxx + * @author drose + * @date 2004-09-27 + */ #include "pointerToBase.h" diff --git a/panda/src/express/pointerToBase.h b/panda/src/express/pointerToBase.h index 7ed792d7d2..3380322e4a 100644 --- a/panda/src/express/pointerToBase.h +++ b/panda/src/express/pointerToBase.h @@ -1,16 +1,15 @@ -// Filename: pointerToBase.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToBase.h + * @author drose + * @date 2004-09-27 + */ #ifndef POINTERTOBASE_H #define POINTERTOBASE_H @@ -22,12 +21,10 @@ #include "memoryUsage.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Class : PointerToBase -// Description : This is the base class for PointerTo and -// ConstPointerTo. Don't try to use it directly; use -// either derived class instead. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for PointerTo and ConstPointerTo. Don't try to use + * it directly; use either derived class instead. + */ template class PointerToBase : public PointerToVoid { public: @@ -50,9 +47,8 @@ protected: void update_type(To *ptr); #endif // DO_MEMORY_USAGE - // No assignment or retrieval functions are declared in - // PointerToBase, because we will have to specialize on const - // vs. non-const later. + // No assignment or retrieval functions are declared in PointerToBase, + // because we will have to specialize on const vs. non-const later. PUBLISHED: ALWAYS_INLINE void clear(); diff --git a/panda/src/express/pointerToVoid.I b/panda/src/express/pointerToVoid.I index c462cb8266..6ae942b645 100644 --- a/panda/src/express/pointerToVoid.I +++ b/panda/src/express/pointerToVoid.I @@ -1,119 +1,95 @@ -// Filename: pointerToVoid.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToVoid.I + * @author drose + * @date 2004-09-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerToVoid:: PointerToVoid() { _void_ptr = (void *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointerToVoid:: ~PointerToVoid() { nassertv(_void_ptr == (void *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::Copy Constructor -// Access: Private -// Description: Don't use this constructor. -//////////////////////////////////////////////////////////////////// +/** + * Don't use this constructor. + */ INLINE PointerToVoid:: PointerToVoid(const PointerToVoid &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::is_null -// Access: Published -// Description: Returns true if the PointerTo is a NULL pointer, -// false otherwise. (Direct comparison to a NULL -// pointer also works.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PointerTo is a NULL pointer, false otherwise. (Direct + * comparison to a NULL pointer also works.) + */ ALWAYS_INLINE bool PointerToVoid:: is_null() const { return (_void_ptr == (void *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::get_hash -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t PointerToVoid:: get_hash() const { return (size_t)_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::Less-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerToVoid:: operator < (const void *other) const { return _void_ptr < other; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::Less-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerToVoid:: operator < (const PointerToVoid &other) const { return _void_ptr < other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerToVoid:: operator == (const PointerToVoid &other) const { return _void_ptr == other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PointerToVoid:: operator != (const PointerToVoid &other) const { return _void_ptr != other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PointerToVoid::swap -// Access: Public -// Description: Swaps the contents of this PointerTo with the other, -// without touching the reference counts. -// -// For internal use only. Use the global swap() -// function instead. -//////////////////////////////////////////////////////////////////// +/** + * Swaps the contents of this PointerTo with the other, without touching the + * reference counts. + * + * For internal use only. Use the global swap() function instead. + */ INLINE void PointerToVoid:: swap(PointerToVoid &other) NOEXCEPT { AtomicAdjust::Pointer temp = _void_ptr; diff --git a/panda/src/express/pointerToVoid.cxx b/panda/src/express/pointerToVoid.cxx index 9e5b717fb9..d018bac96a 100644 --- a/panda/src/express/pointerToVoid.cxx +++ b/panda/src/express/pointerToVoid.cxx @@ -1,15 +1,14 @@ -// Filename: pointerToVoid.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToVoid.cxx + * @author drose + * @date 2004-09-27 + */ #include "pointerToVoid.h" diff --git a/panda/src/express/pointerToVoid.h b/panda/src/express/pointerToVoid.h index 204cf7b7b6..25189a4e0a 100644 --- a/panda/src/express/pointerToVoid.h +++ b/panda/src/express/pointerToVoid.h @@ -1,16 +1,15 @@ -// Filename: pointerToVoid.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointerToVoid.h + * @author drose + * @date 2004-09-27 + */ #ifndef POINTERTOVOID_H #define POINTERTOVOID_H @@ -22,17 +21,15 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : PointerToVoid -// Description : This is the non-template part of the base class for -// PointerTo and ConstPointerTo. It is necessary so we -// can keep a pointer to a non-template class within the -// ReferenceCount object, to implement weak reference -// pointers--we need to have something to clean up when -// the ReferenceCount object destructs. -// -// This is the base class for PointerToBase. -//////////////////////////////////////////////////////////////////// +/** + * This is the non-template part of the base class for PointerTo and + * ConstPointerTo. It is necessary so we can keep a pointer to a non-template + * class within the ReferenceCount object, to implement weak reference + * pointers--we need to have something to clean up when the ReferenceCount + * object destructs. + * + * This is the base class for PointerToBase. + */ class EXPCL_PANDAEXPRESS PointerToVoid : public MemoryBase { protected: INLINE PointerToVoid(); @@ -46,8 +43,8 @@ PUBLISHED: INLINE size_t get_hash() const; public: - // These comparison functions are common to all things PointerTo, so - // they're defined up here. + // These comparison functions are common to all things PointerTo, so they're + // defined up here. INLINE bool operator < (const void *other) const; INLINE bool operator < (const PointerToVoid &other) const; @@ -57,16 +54,15 @@ public: INLINE void swap(PointerToVoid &other) NOEXCEPT; protected: - // Within the PointerToVoid class, we only store a void pointer. - // This is actually the (To *) pointer that is typecast to (void *) - // from the derived template classes. + // Within the PointerToVoid class, we only store a void pointer. This is + // actually the (To *) pointer that is typecast to (void *) from the derived + // template classes. - // It is tempting to try to store a (ReferenceCount *) pointer here, - // but this is not useful because it prohibits defining, say, - // PT(PandaNode), or a PointerTo any class that inherits virtually - // from ReferenceCount. (You can't downcast past a virtual - // inheritance level, but you can always cross-cast from a void - // pointer.) + // It is tempting to try to store a (ReferenceCount *) pointer here, but + // this is not useful because it prohibits defining, say, PT(PandaNode), or + // a PointerTo any class that inherits virtually from ReferenceCount. (You + // can't downcast past a virtual inheritance level, but you can always + // cross-cast from a void pointer.) AtomicAdjust::Pointer _void_ptr; }; diff --git a/panda/src/express/profileTimer.I b/panda/src/express/profileTimer.I index d2f57ad33d..107f86f6af 100644 --- a/panda/src/express/profileTimer.I +++ b/panda/src/express/profileTimer.I @@ -1,16 +1,13 @@ -// Filename: profileTimer.I -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file profileTimer.I + */ INLINE void ProfileTimer:: on() { @@ -62,9 +59,9 @@ off(const char* tag) { INLINE ProfileTimer::AutoTimer:: ~AutoTimer() { - // If the AutoTimer is the first auto ctor, then it will - // be the last auto dtor, for that block. Therefore, now - // is the time to mark the time for the block/function: + // If the AutoTimer is the first auto ctor, then it will be the last auto + // dtor, for that block. Therefore, now is the time to mark the time for + // the blockfunction: _profile.mark(_tag); --_profile._autoTimerCount; } diff --git a/panda/src/express/profileTimer.cxx b/panda/src/express/profileTimer.cxx index 1666747042..41d1ac8f89 100644 --- a/panda/src/express/profileTimer.cxx +++ b/panda/src/express/profileTimer.cxx @@ -1,16 +1,13 @@ -// Filename: profileTimer.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file profileTimer.cxx + */ #include "profileTimer.h" @@ -168,8 +165,8 @@ ProfileTimer::AutoTimer::AutoTimer(ProfileTimer& profile, const char* tag) : _profile(profile) { _tag=tag; if (_profile._autoTimerCount) { - // ...this is a nested call to another AutoTimer. - // Assign the time to the prior AutoTimer: + // ...this is a nested call to another AutoTimer. Assign the time to the + // prior AutoTimer: _profile.mark(_profile._entries[_profile._entryCount-1]._tag); } else { // ...this is not a nested call. @@ -179,6 +176,3 @@ ProfileTimer::AutoTimer::AutoTimer(ProfileTimer& profile, const char* tag) : ++_profile._autoTimerCount; _profile.mark(_tag); } - - - diff --git a/panda/src/express/profileTimer.h b/panda/src/express/profileTimer.h index b899787baa..48c9f16ad1 100644 --- a/panda/src/express/profileTimer.h +++ b/panda/src/express/profileTimer.h @@ -1,17 +1,16 @@ -// Filename: profileTimer.h -// Created by: skyler -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -#ifndef PROFILETIMER_H //[ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file profileTimer.h + * @author skyler + */ + +#ifndef PROFILETIMER_H #define PROFILETIMER_H #include "pandabase.h" @@ -52,8 +51,8 @@ PUBLISHED: void off(); void off(const char* tag); - // Don't call any of the following during timing: - // (Because they are slow, not because anything will break). + // Don't call any of the following during timing: (Because they are slow, + // not because anything will break). double getTotalTime() const; static void consolidateAllTo(ostream &out=cout); void consolidateTo(ostream &out=cout) const; diff --git a/panda/src/express/pta_double.cxx b/panda/src/express/pta_double.cxx index 951be4b584..efb3ec3086 100644 --- a/panda/src/express/pta_double.cxx +++ b/panda/src/express/pta_double.cxx @@ -1,16 +1,15 @@ -// Filename: pta_double.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_double.cxx + * @author drose + * @date 2000-05-10 + */ #include "pta_double.h" diff --git a/panda/src/express/pta_double.h b/panda/src/express/pta_double.h index 73c1d89e1b..2cb239513f 100644 --- a/panda/src/express/pta_double.h +++ b/panda/src/express/pta_double.h @@ -1,16 +1,15 @@ -// Filename: pta_double.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_double.h + * @author drose + * @date 2000-05-10 + */ #ifndef PTA_DOUBLE_H #define PTA_DOUBLE_H @@ -20,14 +19,12 @@ #include "pointerToArray.h" #include "vector_double.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_double -// Description : A pta of doubles. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of doubles. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArrayBase) diff --git a/panda/src/express/pta_float.cxx b/panda/src/express/pta_float.cxx index 1483711420..3d75ca4ac4 100644 --- a/panda/src/express/pta_float.cxx +++ b/panda/src/express/pta_float.cxx @@ -1,16 +1,15 @@ -// Filename: pta_float.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_float.cxx + * @author drose + * @date 2000-05-10 + */ #include "pta_float.h" diff --git a/panda/src/express/pta_float.h b/panda/src/express/pta_float.h index c0dab32949..b2f14953f9 100644 --- a/panda/src/express/pta_float.h +++ b/panda/src/express/pta_float.h @@ -1,16 +1,15 @@ -// Filename: pta_float.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_float.h + * @author drose + * @date 2000-05-10 + */ #ifndef PTA_FLOAT_H #define PTA_FLOAT_H @@ -20,14 +19,12 @@ #include "pointerToArray.h" #include "vector_float.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_float -// Description : A pta of floats. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of floats. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArrayBase) diff --git a/panda/src/express/pta_int.cxx b/panda/src/express/pta_int.cxx index 206e87c3db..417838605c 100644 --- a/panda/src/express/pta_int.cxx +++ b/panda/src/express/pta_int.cxx @@ -1,16 +1,15 @@ -// Filename: pta_int.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_int.cxx + * @author drose + * @date 2000-05-10 + */ #include "pta_int.h" diff --git a/panda/src/express/pta_int.h b/panda/src/express/pta_int.h index 5c1552b8ff..16a2c504e3 100644 --- a/panda/src/express/pta_int.h +++ b/panda/src/express/pta_int.h @@ -1,16 +1,15 @@ -// Filename: pta_int.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_int.h + * @author drose + * @date 2000-05-10 + */ #ifndef PTA_INT_H #define PTA_INT_H @@ -20,14 +19,12 @@ #include "pointerToArray.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_int -// Description : A pta of ints. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of ints. This class is defined once here, and exported to PANDA.DLL; + * other packages that want to use a pta of this type (whether they need to + * export it or not) should include this header file, rather than defining the + * pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS, PointerToArrayBase) diff --git a/panda/src/express/pta_stdfloat.h b/panda/src/express/pta_stdfloat.h index ca6c45dfc0..dbdfe30e70 100644 --- a/panda/src/express/pta_stdfloat.h +++ b/panda/src/express/pta_stdfloat.h @@ -1,16 +1,15 @@ -// Filename: pta_stdfloat.h -// Created by: drose (07Oct11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_stdfloat.h + * @author drose + * @date 2011-10-07 + */ #ifndef PTA_STDFLOAT_H #define PTA_STDFLOAT_H diff --git a/panda/src/express/pta_uchar.cxx b/panda/src/express/pta_uchar.cxx index 4abaad3fa5..58b4b508c0 100644 --- a/panda/src/express/pta_uchar.cxx +++ b/panda/src/express/pta_uchar.cxx @@ -1,16 +1,15 @@ -// Filename: pta_uchar.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_uchar.cxx + * @author drose + * @date 2000-05-10 + */ #include "pta_uchar.h" diff --git a/panda/src/express/pta_uchar.h b/panda/src/express/pta_uchar.h index 1ba4dd4497..5715480cd8 100644 --- a/panda/src/express/pta_uchar.h +++ b/panda/src/express/pta_uchar.h @@ -1,16 +1,15 @@ -// Filename: pta_uchar.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_uchar.h + * @author drose + * @date 2000-05-10 + */ #ifndef PTA_UCHAR_H #define PTA_UCHAR_H @@ -20,14 +19,12 @@ #include "pointerToArray.h" #include "vector_uchar.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_uchar -// Description : A pta of uchars. This class is defined once here, -// and exported to PANDAEXPRESS.DLL; other packages that -// want to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of uchars. This class is defined once here, and exported to + * PANDAEXPRESS.DLL; other packages that want to use a pta of this type + * (whether they need to export it or not) should include this header file, + * rather than defining the pta again. + */ #if !defined(__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 // GCC 4.6 has a weird bug related to this type. diff --git a/panda/src/express/ramfile.I b/panda/src/express/ramfile.I index df1d740669..797eab3c1b 100644 --- a/panda/src/express/ramfile.I +++ b/panda/src/express/ramfile.I @@ -1,76 +1,62 @@ -// Filename: ramfile.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ramfile.I + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Ramfile:: Ramfile() { _pos = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::seek -// Access: Published -// Description: Moves the data pointer to the indicated byte -// position. It is not an error to move the pointer -// past the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Moves the data pointer to the indicated byte position. It is not an error + * to move the pointer past the end of data. + */ INLINE void Ramfile:: seek(size_t pos) { _pos = pos; } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::tell -// Access: Published -// Description: Returns the current data pointer position as a byte -// offset from the beginning of the stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current data pointer position as a byte offset from the + * beginning of the stream. + */ INLINE size_t Ramfile:: tell() const { return _pos; } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::get_data -// Access: Published -// Description: Returns the entire buffer contents as a string, -// regardless of the current data pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire buffer contents as a string, regardless of the current + * data pointer. + */ INLINE const string &Ramfile:: get_data() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::get_data_size -// Access: Published -// Description: Returns the size of the entire buffer contents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the entire buffer contents. + */ INLINE size_t Ramfile:: get_data_size() const { return _data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::clear -// Access: Published -// Description: Empties the current buffer contents. -//////////////////////////////////////////////////////////////////// +/** + * Empties the current buffer contents. + */ INLINE void Ramfile:: clear() { _data.clear(); diff --git a/panda/src/express/ramfile.cxx b/panda/src/express/ramfile.cxx index ea95a0c07d..cc12e239c7 100644 --- a/panda/src/express/ramfile.cxx +++ b/panda/src/express/ramfile.cxx @@ -1,30 +1,26 @@ -// Filename: ramfile.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ramfile.cxx + * @author mike + * @date 1997-01-09 + */ #include "ramfile.h" -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::read -// Access: Published -// Description: Extracts and returns the indicated number of -// characters from the current data pointer, and -// advances the data pointer. If the data pointer -// exceeds the end of the buffer, returns empty string. -// -// The interface here is intentionally designed to be -// similar to that for Python's file.read() function. -//////////////////////////////////////////////////////////////////// +/** + * Extracts and returns the indicated number of characters from the current + * data pointer, and advances the data pointer. If the data pointer exceeds + * the end of the buffer, returns empty string. + * + * The interface here is intentionally designed to be similar to that for + * Python's file.read() function. + */ string Ramfile:: read(size_t length) { size_t orig_pos = _pos; @@ -32,18 +28,14 @@ read(size_t length) { return _data.substr(orig_pos, length); } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::readline -// Access: Published -// Description: Assumes the stream represents a text file, and -// extracts one line up to and including the trailing -// newline character. Returns empty string when the end -// of file is reached. -// -// The interface here is intentionally designed to be -// similar to that for Python's file.readline() -// function. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the stream represents a text file, and extracts one line up to and + * including the trailing newline character. Returns empty string when the + * end of file is reached. + * + * The interface here is intentionally designed to be similar to that for + * Python's file.readline() function. + */ string Ramfile:: readline() { size_t start = _pos; @@ -58,4 +50,3 @@ readline() { return _data.substr(start, _pos - start); } - diff --git a/panda/src/express/ramfile.h b/panda/src/express/ramfile.h index d09aaae98e..a4dbd17727 100644 --- a/panda/src/express/ramfile.h +++ b/panda/src/express/ramfile.h @@ -1,16 +1,15 @@ -// Filename: ramfile.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ramfile.h + * @author mike + * @date 1997-01-09 + */ #ifndef RAMFILE_H #define RAMFILE_H @@ -20,11 +19,9 @@ #include "referenceCount.h" #include "extension.h" -//////////////////////////////////////////////////////////////////// -// Class : Ramfile -// Description : An in-memory buffer specifically designed for -// downloading files to memory. -//////////////////////////////////////////////////////////////////// +/** + * An in-memory buffer specifically designed for downloading files to memory. + */ class EXPCL_PANDAEXPRESS Ramfile { PUBLISHED: INLINE Ramfile(); diff --git a/panda/src/express/ramfile_ext.cxx b/panda/src/express/ramfile_ext.cxx index e2082d4948..6de3e62bfd 100644 --- a/panda/src/express/ramfile_ext.cxx +++ b/panda/src/express/ramfile_ext.cxx @@ -1,28 +1,24 @@ -// Filename: ramfile_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ramfile_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "ramfile_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::read -// Access: Published -// Description: Extracts the indicated number of bytes in the -// stream and returns them as a string (or bytes, -// in Python 3). Returns empty string at end-of-file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the stream and returns them as a + * string (or bytes, in Python 3). Returns empty string at end-of-file. + */ PyObject *Extension:: read(size_t length) { size_t data_length = _this->get_data_size(); @@ -37,18 +33,14 @@ read(size_t length) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::readline -// Access: Published -// Description: Assumes the stream represents a text file, and -// extracts one line up to and including the trailing -// newline character. Returns empty string when the end -// of file is reached. -// -// The interface here is intentionally designed to be -// similar to that for Python's File.readline() -// function. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the stream represents a text file, and extracts one line up to and + * including the trailing newline character. Returns empty string when the + * end of file is reached. + * + * The interface here is intentionally designed to be similar to that for + * Python's File.readline() function. + */ PyObject *Extension:: readline() { string line = _this->readline(); @@ -59,12 +51,10 @@ readline() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::readlines -// Access: Published -// Description: Reads all the lines at once and returns a list. -// Also see the documentation for readline(). -//////////////////////////////////////////////////////////////////// +/** + * Reads all the lines at once and returns a list. Also see the documentation + * for readline(). + */ PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); @@ -87,12 +77,10 @@ readlines() { return lst; } -//////////////////////////////////////////////////////////////////// -// Function: Ramfile::get_data -// Access: Published -// Description: Returns the entire buffer contents as a string, -// regardless of the current data pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire buffer contents as a string, regardless of the current + * data pointer. + */ PyObject *Extension:: get_data() const { #if PY_MAJOR_VERSION >= 3 diff --git a/panda/src/express/ramfile_ext.h b/panda/src/express/ramfile_ext.h index 6ece9d3d7c..fd954d3663 100644 --- a/panda/src/express/ramfile_ext.h +++ b/panda/src/express/ramfile_ext.h @@ -1,16 +1,15 @@ -// Filename: ramfile_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ramfile_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef RAMFILE_EXT_H #define RAMFILE_EXT_H @@ -23,12 +22,10 @@ #include "ramfile.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// Ramfile, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for Ramfile, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/referenceCount.I b/panda/src/express/referenceCount.I index d1dac553c7..c1d54da5da 100644 --- a/panda/src/express/referenceCount.I +++ b/panda/src/express/referenceCount.I @@ -1,16 +1,15 @@ -// Filename: referenceCount.I -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file referenceCount.I + * @author drose + * @date 1998-10-23 + */ template TypeHandle RefCountProxy::_type_handle; @@ -18,19 +17,15 @@ TypeHandle RefCountProxy::_type_handle; template TypeHandle RefCountObj::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::Constructor -// Access: Protected -// Description: The ReferenceCount constructor is protected because -// you almost never want to create just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. -// -// ReferenceCount doesn't store any useful information -// in its own right; its only purpose is to add -// reference-counting to some other class via -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount constructor is protected because you almost never want + * to create just a ReferenceCount object by itself, and it's probably a + * mistake if you try. + * + * ReferenceCount doesn't store any useful information in its own right; its + * only purpose is to add reference-counting to some other class via + * inheritance. + */ INLINE ReferenceCount:: ReferenceCount() { _weak_list = (WeakReferenceList *)NULL; @@ -40,16 +35,14 @@ ReferenceCount() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::Copy Constructor -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy constructor is protected because you almost -// never want to create just a ReferenceCount object by -// itself, and it's probably a mistake if you try. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy constructor is protected because you almost never want to create + * just a ReferenceCount object by itself, and it's probably a mistake if you + * try. + */ INLINE ReferenceCount:: ReferenceCount(const ReferenceCount &) { _weak_list = (WeakReferenceList *)NULL; @@ -59,73 +52,63 @@ ReferenceCount(const ReferenceCount &) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::Copy Assignment Operator -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy assignment operator is protected because -// you almost never want to copy just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. Instead, this should only be called from a -// derived class that implements this operator and then -// calls up the inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy assignment operator is protected because you almost never want to + * copy just a ReferenceCount object by itself, and it's probably a mistake if + * you try. Instead, this should only be called from a derived class that + * implements this operator and then calls up the inheritance chain. + */ INLINE void ReferenceCount:: operator = (const ReferenceCount &) { nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. - // Possibly you used a real pointer instead of a PointerTo at some - // point, and the object was deleted when the PointerTo went out of - // scope. Maybe you tried to create an automatic (local variable) - // instance of a class that derives from ReferenceCount. Or maybe - // your headers are out of sync, and you need to make clean in - // direct or some higher tree. + // If this assertion fails, our own pointer was recently deleted. Possibly + // you used a real pointer instead of a PointerTo at some point, and the + // object was deleted when the PointerTo went out of scope. Maybe you tried + // to create an automatic (local variable) instance of a class that derives + // from ReferenceCount. Or maybe your headers are out of sync, and you need + // to make clean in direct or some higher tree. nassertv(_ref_count != deleted_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ReferenceCount:: ~ReferenceCount() { TAU_PROFILE("ReferenceCount::~ReferenceCount()", " ", TAU_USER); nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertv(_ref_count != deleted_ref_count); - // If this assertion fails, we're trying to delete a static object - // that still has an outstanding reference count. You should make - // sure that all references to your static objects are gone by the - // time the object itself destructs. + // If this assertion fails, we're trying to delete a static object that + // still has an outstanding reference count. You should make sure that all + // references to your static objects are gone by the time the object itself + // destructs. nassertv(_ref_count <= local_ref_count); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertv(_ref_count >= 0); - // If this assertion fails, someone tried to delete this object - // while its reference count was still positive. Maybe you tried - // to point a PointerTo at a static object (a local variable, - // instead of one allocated via new)? The test below against 0x7f - // is supposed to check for that, but it's a pretty hokey test. + // If this assertion fails, someone tried to delete this object while its + // reference count was still positive. Maybe you tried to point a PointerTo + // at a static object (a local variable, instead of one allocated via new)? + // The test below against 0x7f is supposed to check for that, but it's a + // pretty hokey test. - // Another possibility is you inadvertently omitted a copy - // constructor for a ReferenceCount object, and then bitwise - // copied a dynamically allocated value--reference count and - // all--onto a locally allocated one. + // Another possibility is you inadvertently omitted a copy constructor for a + // ReferenceCount object, and then bitwise copied a dynamically allocated + // value--reference count and all--onto a locally allocated one. nassertv(_ref_count == 0 || _ref_count == local_ref_count); // Tell our weak reference holders that we're going away now. @@ -136,8 +119,8 @@ ReferenceCount:: #ifndef NDEBUG // Ok, all clear to delete. Now set the reference count to - // deleted_ref_count, so we'll have a better chance of noticing if - // we happen to have a stray pointer to it still out there. + // deleted_ref_count, so we'll have a better chance of noticing if we happen + // to have a stray pointer to it still out there. _ref_count = deleted_ref_count; #endif @@ -146,11 +129,9 @@ ReferenceCount:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::get_ref_count -// Access: Published -// Description: Returns the current reference count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current reference count. + */ INLINE int ReferenceCount:: get_ref_count() const { #ifdef _DEBUG @@ -159,22 +140,17 @@ get_ref_count() const { return (int)AtomicAdjust::get(_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::ref -// Access: Published -// Description: Explicitly increments the reference count. User code -// should avoid using ref() and unref() directly, which -// can result in missed reference counts. Instead, let -// a PointerTo object manage the reference counting -// automatically. -// -// This function is const, even though it changes the -// object, because generally fiddling with an object's -// reference count isn't considered part of fiddling -// with the object. An object might be const in other -// ways, but we still need to accurately count the -// number of references to it. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly increments the reference count. User code should avoid using + * ref() and unref() directly, which can result in missed reference counts. + * Instead, let a PointerTo object manage the reference counting + * automatically. + * + * This function is const, even though it changes the object, because + * generally fiddling with an object's reference count isn't considered part + * of fiddling with the object. An object might be const in other ways, but + * we still need to accurately count the number of references to it. + */ INLINE void ReferenceCount:: ref() const { TAU_PROFILE("void ReferenceCount::ref()", " ", TAU_USER); @@ -185,52 +161,42 @@ ref() const { AtomicAdjust::inc(_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::unref -// Access: Published, Virtual -// Description: Explicitly decrements the reference count. Note that -// the object will not be implicitly deleted by unref() -// simply because the reference count drops to zero. -// (Having a member function delete itself is -// problematic.) However, see the helper function -// unref_delete(). -// -// User code should avoid using ref() and unref() -// directly, which can result in missed reference -// counts. Instead, let a PointerTo object manage the -// reference counting automatically. -// -// This function is const, even though it changes the -// object, because generally fiddling with an object's -// reference count isn't considered part of fiddling -// with the object. An object might be const in other -// ways, but we still need to accurately count the -// number of references to it. -// -// The return value is true if the new reference count -// is nonzero, false if it is zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the reference count. Note that the object will not + * be implicitly deleted by unref() simply because the reference count drops + * to zero. (Having a member function delete itself is problematic.) However, + * see the helper function unref_delete(). + * + * User code should avoid using ref() and unref() directly, which can result + * in missed reference counts. Instead, let a PointerTo object manage the + * reference counting automatically. + * + * This function is const, even though it changes the object, because + * generally fiddling with an object's reference count isn't considered part + * of fiddling with the object. An object might be const in other ways, but + * we still need to accurately count the number of references to it. + * + * The return value is true if the new reference count is nonzero, false if it + * is zero. + */ INLINE bool ReferenceCount:: unref() const { TAU_PROFILE("void ReferenceCount::unref()", " ", TAU_USER); #ifdef _DEBUG nassertr(test_ref_count_integrity(), 0); - // If this assertion fails, you tried to unref an object with a - // zero reference count. Are you using ref() and unref() - // directly? Are you sure you can't use PointerTo's? + // If this assertion fails, you tried to unref an object with a zero + // reference count. Are you using ref() and unref() directly? Are you sure + // you can't use PointerTo's? nassertr(_ref_count > 0, 0); #endif return AtomicAdjust::dec(_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::test_ref_count_integrity -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. Returns true if ok, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. Returns true if ok, false otherwise. + */ INLINE bool ReferenceCount:: test_ref_count_integrity() const { #ifndef NDEBUG @@ -240,13 +206,10 @@ test_ref_count_integrity() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::test_ref_count_nonzero -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't zero, or completely bogus. Returns true -// if ok, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't zero, or + * completely bogus. Returns true if ok, false otherwise. + */ INLINE bool ReferenceCount:: test_ref_count_nonzero() const { #ifndef NDEBUG @@ -256,52 +219,41 @@ test_ref_count_nonzero() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::local_object -// Access: Public -// Description: This function should be called, once, immediately -// after creating a new instance of some -// ReferenceCount-derived object on the stack. -// -// This allows the object to be passed to functions that -// will increment and decrement the object's reference -// count temporarily, and it will prevent the object -// from being deleted (inappropriately), when the -// reference count returns to zero. It actually -// achieves this by setting a large positive value in -// the reference count field. -//////////////////////////////////////////////////////////////////// +/** + * This function should be called, once, immediately after creating a new + * instance of some ReferenceCount-derived object on the stack. + * + * This allows the object to be passed to functions that will increment and + * decrement the object's reference count temporarily, and it will prevent the + * object from being deleted (inappropriately), when the reference count + * returns to zero. It actually achieves this by setting a large positive + * value in the reference count field. + */ INLINE void ReferenceCount:: local_object() { - // If this assertion fails, you didn't call this immediately after - // creating a local object. + // If this assertion fails, you didn't call this immediately after creating + // a local object. nassertv(_ref_count == 0); _ref_count = local_ref_count; } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::has_weak_list -// Access: Public -// Description: Returns true if this particular ReferenceCount object -// has a WeakReferenceList created, false otherwise. In -// general, this will be true if there was ever a -// WeakPointerTo created for this object (even if there -// is not any for it now). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular ReferenceCount object has a + * WeakReferenceList created, false otherwise. In general, this will be true + * if there was ever a WeakPointerTo created for this object (even if there is + * not any for it now). + */ INLINE bool ReferenceCount:: has_weak_list() const { return _weak_list != (WeakReferenceList *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::get_weak_list -// Access: Public -// Description: Returns the WeakReferenceList associated with this -// ReferenceCount object. If there has never been a -// WeakReferenceList associated with this object, -// creates one now. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WeakReferenceList associated with this ReferenceCount object. + * If there has never been a WeakReferenceList associated with this object, + * creates one now. + */ INLINE WeakReferenceList *ReferenceCount:: get_weak_list() const { if (AtomicAdjust::get_ptr(_weak_list) == (WeakReferenceList *)NULL) { @@ -310,12 +262,9 @@ get_weak_list() const { return (WeakReferenceList *)AtomicAdjust::get_ptr(_weak_list); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::weak_ref -// Access: Public -// Description: Adds the indicated PointerToVoid as a weak reference -// to this object. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated PointerToVoid as a weak reference to this object. + */ INLINE void ReferenceCount:: weak_ref(WeakPointerToVoid *ptv) { TAU_PROFILE("void ReferenceCount::weak_ref()", " ", TAU_USER); @@ -325,13 +274,10 @@ weak_ref(WeakPointerToVoid *ptv) { get_weak_list()->add_reference(ptv); } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::weak_unref -// Access: Public -// Description: Removes the indicated PointerToVoid as a weak reference -// to this object. It must have previously been added -// via a call to weak_ref(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PointerToVoid as a weak reference to this object. It + * must have previously been added via a call to weak_ref(). + */ INLINE void ReferenceCount:: weak_unref(WeakPointerToVoid *ptv) { TAU_PROFILE("void ReferenceCount::weak_unref()", " ", TAU_USER); @@ -342,25 +288,21 @@ weak_unref(WeakPointerToVoid *ptv) { ((WeakReferenceList *)_weak_list)->clear_reference(ptv); } -//////////////////////////////////////////////////////////////////// -// Function: unref_delete -// Description: This global helper function will unref the given -// ReferenceCount object, and if the reference count -// reaches zero, automatically delete it. It can't be a -// member function because it's usually a bad idea to -// delete an object from within its own member function. -// It's a template function so the destructor doesn't -// have to be virtual. -//////////////////////////////////////////////////////////////////// +/** + * This global helper function will unref the given ReferenceCount object, and + * if the reference count reaches zero, automatically delete it. It can't be + * a member function because it's usually a bad idea to delete an object from + * within its own member function. It's a template function so the destructor + * doesn't have to be virtual. + */ template INLINE void unref_delete(RefCountType *ptr) { TAU_PROFILE("void unref_delete(RefCountType *)", " ", TAU_USER); - // Although it may be tempting to try to upcast ptr to a - // ReferenceCount object (particularly to get around inheritance - // issues), resist that temptation, since some classes (in - // particular, TransformState and RenderState) rely on a non-virtual - // overloading of the unref() method. + // Although it may be tempting to try to upcast ptr to a ReferenceCount + // object (particularly to get around inheritance issues), resist that + // temptation, since some classes (in particular, TransformState and + // RenderState) rely on a non-virtual overloading of the unref() method. if (!ptr->unref()) { // If the reference count has gone to zero, delete the object. @@ -368,53 +310,43 @@ unref_delete(RefCountType *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: RefCountProxy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountProxy:: RefCountProxy() { } -//////////////////////////////////////////////////////////////////// -// Function: RefCountProxy::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountProxy:: RefCountProxy(const Base ©) : _base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: RefCountProxy::Base Typecast Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountProxy:: operator Base &() { return _base; } -//////////////////////////////////////////////////////////////////// -// Function: RefCountProxy::Base Typecast Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountProxy:: operator const Base &() const { return _base; } -//////////////////////////////////////////////////////////////////// -// Function: RefCountProxy::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void RefCountProxy:: init_type() { @@ -425,32 +357,26 @@ init_type() { } -//////////////////////////////////////////////////////////////////// -// Function: RefCountObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountObj:: RefCountObj() { } -//////////////////////////////////////////////////////////////////// -// Function: RefCountObj::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE RefCountObj:: RefCountObj(const Base ©) : Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: RefCountObj::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void RefCountObj:: init_type() { diff --git a/panda/src/express/referenceCount.cxx b/panda/src/express/referenceCount.cxx index e1d1da911c..f5d988cf8e 100644 --- a/panda/src/express/referenceCount.cxx +++ b/panda/src/express/referenceCount.cxx @@ -1,16 +1,15 @@ -// Filename: referenceCount.cxx -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file referenceCount.cxx + * @author drose + * @date 1998-10-23 + */ #include "referenceCount.h" #include "atomicAdjust.h" @@ -18,40 +17,32 @@ TypeHandle ReferenceCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::do_test_ref_count_integrity -// Access: Protected -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. Returns true if ok, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. Returns true if ok, false otherwise. + */ bool ReferenceCount:: do_test_ref_count_integrity() const { nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertr(_ref_count != deleted_ref_count, false); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertr(_ref_count >= 0, false); return true; } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::do_test_ref_count_nonzero -// Access: Protected -// Description: Returns true if the reference count is nonzero, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reference count is nonzero, false otherwise. + */ bool ReferenceCount:: do_test_ref_count_nonzero() const { nassertr(do_test_ref_count_integrity(), false); @@ -60,20 +51,16 @@ do_test_ref_count_nonzero() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ReferenceCount::create_weak_list -// Access: Private -// Description: Allocates a new WeakReferenceList structure and -// stores it on the object. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new WeakReferenceList structure and stores it on the object. + */ void ReferenceCount:: create_weak_list() { WeakReferenceList *weak_list = new WeakReferenceList; - void *orig = + void *orig = AtomicAdjust::compare_and_exchange_ptr(_weak_list, NULL, weak_list); if (orig != (void *)NULL) { // Someone else created it first. delete weak_list; } } - diff --git a/panda/src/express/referenceCount.h b/panda/src/express/referenceCount.h index 385e12b698..72425dcd8d 100644 --- a/panda/src/express/referenceCount.h +++ b/panda/src/express/referenceCount.h @@ -1,16 +1,15 @@ -// Filename: referenceCount.h -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file referenceCount.h + * @author drose + * @date 1998-10-23 + */ #ifndef REFERENCECOUNT_H #define REFERENCECOUNT_H @@ -31,13 +30,11 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Class : ReferenceCount -// Description : A base class for all things that want to be -// reference-counted. ReferenceCount works in -// conjunction with PointerTo to automatically delete -// objects when the last pointer to them goes away. -//////////////////////////////////////////////////////////////////// +/** + * A base class for all things that want to be reference-counted. + * ReferenceCount works in conjunction with PointerTo to automatically delete + * objects when the last pointer to them goes away. + */ class EXPCL_PANDAEXPRESS ReferenceCount : public MemoryBase { protected: INLINE ReferenceCount(); @@ -75,18 +72,17 @@ private: private: enum { - // We use this value as a flag to indicate an object has been - // indicated as a local object, and should not be deleted except - // by its own destructor. Really, any nonzero value would do, but - // having a large specific number makes the sanity checks easier. + // We use this value as a flag to indicate an object has been indicated as + // a local object, and should not be deleted except by its own destructor. + // Really, any nonzero value would do, but having a large specific number + // makes the sanity checks easier. local_ref_count = 10000000, - // This value is used as a flag to indicate that an object has - // just been deleted, and you're looking at deallocated memory. - // It's not guaranteed to stick around, of course (since the - // deleted memory might be repurposed for anything else, including - // a new object), but if you ever do encounter this value in a - // reference count field, you screwed up. + // This value is used as a flag to indicate that an object has just been + // deleted, and you're looking at deallocated memory. It's not guaranteed + // to stick around, of course (since the deleted memory might be + // repurposed for anything else, including a new object), but if you ever + // do encounter this value in a reference count field, you screwed up. deleted_ref_count = -100, }; @@ -108,21 +104,16 @@ private: template INLINE void unref_delete(RefCountType *ptr); -//////////////////////////////////////////////////////////////////// -// Class : RefCountProxy -// Description : A "proxy" to use to make a reference-countable object -// whenever the object cannot inherit from -// ReferenceCount for some reason. RefCountPr -// can be treated as an instance of MyClass directly, -// for the most part, except that it can be reference -// counted. -// -// If you want to declare a RefCountProxy to something -// that does not have get_class_type(), you will have to -// define a template specialization on -// _get_type_handle() and _do_init_type(), as in -// typedObject.h. -//////////////////////////////////////////////////////////////////// +/** + * A "proxy" to use to make a reference-countable object whenever the object + * cannot inherit from ReferenceCount for some reason. RefCountPr + * can be treated as an instance of MyClass directly, for the most part, + * except that it can be reference counted. + * + * If you want to declare a RefCountProxy to something that does not have + * get_class_type(), you will have to define a template specialization on + * _get_type_handle() and _do_init_type(), as in typedObject.h. + */ template class RefCountProxy : public ReferenceCount { public: @@ -143,14 +134,12 @@ private: }; -//////////////////////////////////////////////////////////////////// -// Class : RefCountObj -// Description : Another kind of proxy, similar to RefCountProxy. -// This one works by inheriting from the indicated base -// type, giving it an is-a relation instead of a has-a -// relation. As such, it's a little more robust, but -// only works when the base type is, in fact, a class. -//////////////////////////////////////////////////////////////////// +/** + * Another kind of proxy, similar to RefCountProxy. This one works by + * inheriting from the indicated base type, giving it an is-a relation instead + * of a has-a relation. As such, it's a little more robust, but only works + * when the base type is, in fact, a class. + */ template class RefCountObj : public ReferenceCount, public Base { public: diff --git a/panda/src/express/streamReader_ext.cxx b/panda/src/express/streamReader_ext.cxx index 8adb05556c..2876f82faa 100644 --- a/panda/src/express/streamReader_ext.cxx +++ b/panda/src/express/streamReader_ext.cxx @@ -1,28 +1,24 @@ -// Filename: streamReader_ext.cxx -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamReader_ext.cxx + * @author rdb + * @date 2013-12-09 + */ #include "streamReader_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::extract_bytes -// Access: Published -// Description: Extracts the indicated number of bytes in the -// stream and returns them as a string (or bytes, -// in Python 3). Returns empty string at end-of-file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the indicated number of bytes in the stream and returns them as a + * string (or bytes, in Python 3). Returns empty string at end-of-file. + */ PyObject *Extension:: extract_bytes(size_t size) { unsigned char *buffer = (unsigned char *)alloca(size); @@ -35,18 +31,14 @@ extract_bytes(size_t size) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Extension::readline -// Access: Published -// Description: Assumes the stream represents a text file, and -// extracts one line up to and including the trailing -// newline character. Returns empty string when the end -// of file is reached. -// -// The interface here is intentionally designed to be -// similar to that for Python's File.readline() -// function. -//////////////////////////////////////////////////////////////////// +/** + * Assumes the stream represents a text file, and extracts one line up to and + * including the trailing newline character. Returns empty string when the + * end of file is reached. + * + * The interface here is intentionally designed to be similar to that for + * Python's File.readline() function. + */ PyObject *Extension:: readline() { istream *in = _this->get_istream(); @@ -69,12 +61,10 @@ readline() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: StreamReader::readlines -// Access: Published -// Description: Reads all the lines at once and returns a list. -// Also see the documentation for readline(). -//////////////////////////////////////////////////////////////////// +/** + * Reads all the lines at once and returns a list. Also see the documentation + * for readline(). + */ PyObject *Extension:: readlines() { PyObject *lst = PyList_New(0); @@ -99,4 +89,3 @@ readlines() { } #endif - diff --git a/panda/src/express/streamReader_ext.h b/panda/src/express/streamReader_ext.h index 49edcd6426..fe74694f8b 100644 --- a/panda/src/express/streamReader_ext.h +++ b/panda/src/express/streamReader_ext.h @@ -1,16 +1,15 @@ -// Filename: streamReader_ext.h -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamReader_ext.h + * @author rdb + * @date 2013-12-09 + */ #ifndef STREAMREADER_EXT_H #define STREAMREADER_EXT_H @@ -23,12 +22,10 @@ #include "streamReader.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// StreamReader, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for StreamReader, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/streamWriter_ext.cxx b/panda/src/express/streamWriter_ext.cxx index 68d7d39bc0..158e34abba 100644 --- a/panda/src/express/streamWriter_ext.cxx +++ b/panda/src/express/streamWriter_ext.cxx @@ -1,27 +1,23 @@ -// Filename: streamWriter_ext.cxx -// Created by: rdb (19Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWriter_ext.cxx + * @author rdb + * @date 2015-09-19 + */ #include "streamWriter_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: StreamWriter::append_data -// Access: Published -// Description: Appends some more raw data to the end of the -// StreamWriter. -//////////////////////////////////////////////////////////////////// +/** + * Appends some more raw data to the end of the StreamWriter. + */ void Extension:: append_data(PyObject *data) { Py_buffer view; diff --git a/panda/src/express/streamWriter_ext.h b/panda/src/express/streamWriter_ext.h index e8e1b270cd..f715882679 100644 --- a/panda/src/express/streamWriter_ext.h +++ b/panda/src/express/streamWriter_ext.h @@ -1,16 +1,15 @@ -// Filename: streamWriter_ext.h -// Created by: rdb (19Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file streamWriter_ext.h + * @author rdb + * @date 2015-09-19 + */ #ifndef STREAMWRITER_EXT_H #define STREAMWRITER_EXT_H @@ -23,12 +22,10 @@ #include "streamWriter.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// StreamWriter, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for StreamWriter, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/subStream.I b/panda/src/express/subStream.I index cfa5009bcf..346b66d46a 100644 --- a/panda/src/express/subStream.I +++ b/panda/src/express/subStream.I @@ -1,50 +1,40 @@ -// Filename: subStream.I -// Created by: drose (02Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subStream.I + * @author drose + * @date 2002-08-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ISubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ISubStream:: ISubStream() : istream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: ISubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ISubStream:: ISubStream(IStreamWrapper *source, streampos start, streampos end) : istream(&_buf) { open(source, start, end); } -//////////////////////////////////////////////////////////////////// -// Function: ISubStream::open -// Access: Public -// Description: Starts the SubStream reading from the indicated -// source, with the first character being the character -// at position "start" within the source, for end - -// start total characters. The character at "end" -// within the source will never be read; this will -// appear to be EOF. -// -// If end is zero, it indicates that the ISubStream will -// continue until the end of the source stream. -//////////////////////////////////////////////////////////////////// +/** + * Starts the SubStream reading from the indicated source, with the first + * character being the character at position "start" within the source, for + * end - start total characters. The character at "end" within the source + * will never be read; this will appear to be EOF. + * + * If end is zero, it indicates that the ISubStream will continue until the + * end of the source stream. + */ INLINE ISubStream &ISubStream:: open(IStreamWrapper *source, streampos start, streampos end) { clear((ios_iostate)0); @@ -52,50 +42,40 @@ open(IStreamWrapper *source, streampos start, streampos end) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ISubStream::close -// Access: Public -// Description: Resets the SubStream to empty, but does not actually -// close the source istream. -//////////////////////////////////////////////////////////////////// +/** + * Resets the SubStream to empty, but does not actually close the source + * istream. + */ INLINE ISubStream &ISubStream:: close() { _buf.close(); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: OSubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OSubStream:: OSubStream() : ostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: OSubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OSubStream:: OSubStream(OStreamWrapper *dest, streampos start, streampos end, bool append) : ostream(&_buf) { open(dest, start, end, append); } -//////////////////////////////////////////////////////////////////// -// Function: OSubStream::open -// Access: Public -// Description: Starts the SubStream reading from the indicated -// dest, with the first character being the character -// at position "start" within the dest, for end - -// start total characters. The character at "end" -// within the dest will never be read; this will -// appear to be EOF. -// -// If end is zero, it indicates that the OSubStream will -// continue until the end of the dest stream. -//////////////////////////////////////////////////////////////////// +/** + * Starts the SubStream reading from the indicated dest, with the first + * character being the character at position "start" within the dest, for end + * - start total characters. The character at "end" within the dest will + * never be read; this will appear to be EOF. + * + * If end is zero, it indicates that the OSubStream will continue until the + * end of the dest stream. + */ INLINE OSubStream &OSubStream:: open(OStreamWrapper *dest, streampos start, streampos end, bool append) { clear((ios_iostate)0); @@ -103,47 +83,39 @@ open(OStreamWrapper *dest, streampos start, streampos end, bool append) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: OSubStream::close -// Access: Public -// Description: Resets the SubStream to empty, but does not actually -// close the dest ostream. -//////////////////////////////////////////////////////////////////// +/** + * Resets the SubStream to empty, but does not actually close the dest + * ostream. + */ INLINE OSubStream &OSubStream:: close() { _buf.close(); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: SubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubStream:: SubStream() : iostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: SubStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubStream:: SubStream(StreamWrapper *nested, streampos start, streampos end, bool append) : iostream(&_buf) { open(nested, start, end, append); } -//////////////////////////////////////////////////////////////////// -// Function: SubStream::open -// Access: Public -// Description: Starts the SubStream reading and writing from the -// indicated nested stream, within the indicated range. -// "end" is the first character outside of the range. -// -// If end is zero, it indicates that the SubStream will -// continue until the end of the nested stream. -//////////////////////////////////////////////////////////////////// +/** + * Starts the SubStream reading and writing from the indicated nested stream, + * within the indicated range. "end" is the first character outside of the + * range. + * + * If end is zero, it indicates that the SubStream will continue until the end + * of the nested stream. + */ INLINE SubStream &SubStream:: open(StreamWrapper *nested, streampos start, streampos end, bool append) { clear((ios_iostate)0); @@ -151,16 +123,12 @@ open(StreamWrapper *nested, streampos start, streampos end, bool append) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: SubStream::close -// Access: Public -// Description: Resets the SubStream to empty, but does not actually -// close the nested ostream. -//////////////////////////////////////////////////////////////////// +/** + * Resets the SubStream to empty, but does not actually close the nested + * ostream. + */ INLINE SubStream &SubStream:: close() { _buf.close(); return *this; } - - diff --git a/panda/src/express/subStream.cxx b/panda/src/express/subStream.cxx index 8ac7f1ccb0..a4f87656ce 100644 --- a/panda/src/express/subStream.cxx +++ b/panda/src/express/subStream.cxx @@ -1,15 +1,14 @@ -// Filename: subStream.cxx -// Created by: drose (02Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subStream.cxx + * @author drose + * @date 2002-08-02 + */ #include "subStream.h" diff --git a/panda/src/express/subStream.h b/panda/src/express/subStream.h index 7dbfab475f..b8a45aa4ac 100644 --- a/panda/src/express/subStream.h +++ b/panda/src/express/subStream.h @@ -1,16 +1,15 @@ -// Filename: subStream.h -// Created by: drose (02Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subStream.h + * @author drose + * @date 2002-08-02 + */ #ifndef SUBSTREAM_H #define SUBSTREAM_H @@ -19,18 +18,15 @@ #include "subStreamBuf.h" #include "streamWrapper.h" -//////////////////////////////////////////////////////////////////// -// Class : ISubStream -// Description : An istream object that presents a subwindow into -// another istream. The first character read from this -// stream will be the "start" character from the source -// istream; just before the file pointer reaches the -// "end" character, eof is returned. -// -// The source stream must be one that we can randomly -// seek within. The resulting ISubStream will also -// support arbitrary seeks. -//////////////////////////////////////////////////////////////////// +/** + * An istream object that presents a subwindow into another istream. The + * first character read from this stream will be the "start" character from + * the source istream; just before the file pointer reaches the "end" + * character, eof is returned. + * + * The source stream must be one that we can randomly seek within. The + * resulting ISubStream will also support arbitrary seeks. + */ class EXPCL_PANDAEXPRESS ISubStream : public istream { PUBLISHED: INLINE ISubStream(); @@ -47,18 +43,15 @@ private: SubStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : OSubStream -// Description : An ostream object that presents a subwindow into -// another ostream. The first character written to this -// stream will be the "start" character in the dest -// istream; no characters may be written to character -// "end" or later (unless end is zero). -// -// The dest stream must be one that we can randomly -// seek within. The resulting OSubStream will also -// support arbitrary seeks. -//////////////////////////////////////////////////////////////////// +/** + * An ostream object that presents a subwindow into another ostream. The + * first character written to this stream will be the "start" character in the + * dest istream; no characters may be written to character "end" or later + * (unless end is zero). + * + * The dest stream must be one that we can randomly seek within. The + * resulting OSubStream will also support arbitrary seeks. + */ class EXPCL_PANDAEXPRESS OSubStream : public ostream { PUBLISHED: INLINE OSubStream(); @@ -75,11 +68,9 @@ private: SubStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : SubStream -// Description : Combined ISubStream and OSubStream for bidirectional -// I/O. -//////////////////////////////////////////////////////////////////// +/** + * Combined ISubStream and OSubStream for bidirectional I/O. + */ class EXPCL_PANDAEXPRESS SubStream : public iostream { PUBLISHED: INLINE SubStream(); @@ -99,5 +90,3 @@ private: #include "subStream.I" #endif - - diff --git a/panda/src/express/subStreamBuf.cxx b/panda/src/express/subStreamBuf.cxx index 3f6c8b762a..61a349b215 100644 --- a/panda/src/express/subStreamBuf.cxx +++ b/panda/src/express/subStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: subStreamBuf.cxx -// Created by: drose (02Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subStreamBuf.cxx + * @author drose + * @date 2002-08-02 + */ #include "subStreamBuf.h" #include "pnotify.h" @@ -23,18 +22,16 @@ typedef int streamsize; static const size_t substream_buffer_size = 4096; -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SubStreamBuf:: SubStreamBuf() { _source = (IStreamWrapper *)NULL; _dest = (OStreamWrapper *)NULL; - // _start is the streampos of the first byte of the SubStream within - // its parent stream. + // _start is the streampos of the first byte of the SubStream within its + // parent stream. _start = 0; // _end is the streampos of the byte following the last byte of the @@ -42,10 +39,10 @@ SubStreamBuf() { // continues to the end of the parent stream, wherever that is. _end = 0; - // _gpos is the streampos of the end of the read buffer (that is, - // egptr()) within the parent stream. By comparing _gpos to gpos(), - // we can determine the actual current file position. _ppos is the - // similar pos, for the write pointer. + // _gpos is the streampos of the end of the read buffer (that is, egptr()) + // within the parent stream. By comparing _gpos to gpos(), we can determine + // the actual current file position. _ppos is the similar pos, for the + // write pointer. _gpos = 0; _ppos = 0; @@ -58,8 +55,8 @@ SubStreamBuf() { #else allocate(); - // Chop the buffer in half. The bottom half goes to the get buffer; - // the top half goes to the put buffer. + // Chop the buffer in half. The bottom half goes to the get buffer; the top + // half goes to the put buffer. char *b = base(); char *t = ebuf(); char *m = b + (t - b) / 2; @@ -68,11 +65,9 @@ SubStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SubStreamBuf:: ~SubStreamBuf() { close(); @@ -81,11 +76,9 @@ SubStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SubStreamBuf:: open(IStreamWrapper *source, OStreamWrapper *dest, streampos start, streampos end, bool append) { _source = source; @@ -97,11 +90,9 @@ open(IStreamWrapper *source, OStreamWrapper *dest, streampos start, streampos en _ppos = _start; } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::close -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SubStreamBuf:: close() { // Make sure the write buffer is flushed. @@ -119,11 +110,9 @@ close() { gbump(egptr() - gptr()); } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::seekoff -// Access: Public, Virtual -// Description: Implements seeking within the stream. -//////////////////////////////////////////////////////////////////// +/** + * Implements seeking within the stream. + */ streampos SubStreamBuf:: seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { streampos result = -1; @@ -139,28 +128,27 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { nassertr(_gpos >= 0, EOF); streampos cur_pos = _gpos; streampos new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (streampos)off + _start; break; - + case ios::cur: new_pos = (streampos)((streamoff)cur_pos + off); break; - + case ios::end: if (_end == (streampos)0) { - // If the end of the file is unspecified, we have to seek to - // find it. + // If the end of the file is unspecified, we have to seek to find it. new_pos = _source->seek_gpos_eof() + off; - + } else { new_pos = _end + off; } break; - + default: // Shouldn't get here. break; @@ -186,23 +174,22 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { size_t n = pptr() - pbase(); streampos cur_pos = _ppos + (streamoff)n; streampos new_pos = cur_pos; - + // Now adjust the data pointer appropriately. switch (dir) { case ios::beg: new_pos = (streampos)off + _start; break; - + case ios::cur: new_pos = (streampos)((streamoff)cur_pos + off); break; - + case ios::end: if (_end == (streampos)0) { - // If the end of the file is unspecified, we have to seek to - // find it. + // If the end of the file is unspecified, we have to seek to find it. new_pos = _dest->seek_ppos_eof() + off; - + } else { new_pos = _end + off; } @@ -231,31 +218,24 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::seekpos -// Access: Public, Virtual -// Description: A variant on seekoff() to implement seeking within a -// stream. -// -// The MSDN Library claims that it is only necessary to -// redefine seekoff(), and not seekpos() as well, as the -// default implementation of seekpos() is supposed to -// map to seekoff() exactly as I am doing here; but in -// fact it must do something else, because seeking -// didn't work on Windows until I redefined this -// function as well. -//////////////////////////////////////////////////////////////////// +/** + * A variant on seekoff() to implement seeking within a stream. + * + * The MSDN Library claims that it is only necessary to redefine seekoff(), + * and not seekpos() as well, as the default implementation of seekpos() is + * supposed to map to seekoff() exactly as I am doing here; but in fact it + * must do something else, because seeking didn't work on Windows until I + * redefined this function as well. + */ streampos SubStreamBuf:: seekpos(streampos pos, ios_openmode which) { return seekoff(pos, ios::beg, which); } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int SubStreamBuf:: overflow(int ch) { bool okflag = true; @@ -271,9 +251,9 @@ overflow(int ch) { } } - nassertr(_dest != NULL, EOF); + nassertr(_dest != NULL, EOF); bool fail = false; - if (_append) { + if (_append) { _dest->seek_eof_write(pbase(), n, fail); } else { _dest->seek_write(_ppos, pbase(), n, fail); @@ -302,27 +282,25 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int SubStreamBuf:: sync() { size_t n = pptr() - pbase(); if (n != 0) { - nassertr(_dest != NULL, EOF); + nassertr(_dest != NULL, EOF); bool fail = false; - if (_append) { + if (_append) { _dest->seek_eof_write(pbase(), n, fail); } else { _dest->seek_write(_ppos, pbase(), n, fail); } _ppos += n; pbump(-(int)n); - + if (fail) { return EOF; } @@ -331,12 +309,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: SubStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int SubStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -356,14 +332,14 @@ underflow() { return EOF; } - // We won't be filling the entire buffer. Fill in only at the - // end of the buffer. + // We won't be filling the entire buffer. Fill in only at the end of + // the buffer. size_t delta = num_bytes - new_num_bytes; gbump(delta); num_bytes = new_num_bytes; nassertr(egptr() - gptr() == num_bytes, EOF); } - + nassertr(_source != NULL, EOF); streamsize read_count; bool eof; diff --git a/panda/src/express/subStreamBuf.h b/panda/src/express/subStreamBuf.h index 817d224ab3..bfa94e2e6e 100644 --- a/panda/src/express/subStreamBuf.h +++ b/panda/src/express/subStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: subStreamBuf.h -// Created by: drose (02Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subStreamBuf.h + * @author drose + * @date 2002-08-02 + */ #ifndef SUBSTREAMBUF_H #define SUBSTREAMBUF_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "streamWrapper.h" -//////////////////////////////////////////////////////////////////// -// Class : SubStreamBuf -// Description : The streambuf object that implements ISubStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements ISubStream. + */ class EXPCL_PANDAEXPRESS SubStreamBuf : public streambuf { public: SubStreamBuf(); diff --git a/panda/src/express/subfileInfo.I b/panda/src/express/subfileInfo.I index f34791aaca..d34fe7af97 100644 --- a/panda/src/express/subfileInfo.I +++ b/panda/src/express/subfileInfo.I @@ -1,23 +1,19 @@ -// Filename: subfileInfo.I -// Created by: drose (20Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subfileInfo.I + * @author drose + * @date 2011-06-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::Default Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubfileInfo:: SubfileInfo() : _start(0), @@ -25,11 +21,9 @@ SubfileInfo() : { } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubfileInfo:: SubfileInfo(const FileReference *file, streampos start, streamsize size) : _file(file), @@ -38,11 +32,9 @@ SubfileInfo(const FileReference *file, streampos start, streamsize size) : { } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubfileInfo:: SubfileInfo(const Filename &filename, streampos start, streamsize size) : _file(new FileReference(filename)), @@ -51,11 +43,9 @@ SubfileInfo(const Filename &filename, streampos start, streamsize size) : { } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubfileInfo:: SubfileInfo(const SubfileInfo ©) : _file(copy._file), @@ -64,11 +54,9 @@ SubfileInfo(const SubfileInfo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void SubfileInfo:: operator = (const SubfileInfo ©) { _file = copy._file; @@ -76,32 +64,26 @@ operator = (const SubfileInfo ©) { _size = copy._size; } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::is_empty -// Access: Published -// Description: Returns true if this SubfileInfo doesn't define any -// file, false if it has real data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this SubfileInfo doesn't define any file, false if it has + * real data. + */ INLINE bool SubfileInfo:: is_empty() const { return _file == (FileReference *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::get_file -// Access: Published -// Description: Returns the FileReference that represents this file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that represents this file. + */ INLINE const FileReference *SubfileInfo:: get_file() const { return _file; } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::get_filename -// Access: Published -// Description: A shortcut to the filename. -//////////////////////////////////////////////////////////////////// +/** + * A shortcut to the filename. + */ INLINE const Filename &SubfileInfo:: get_filename() const { if (_file != (FileReference *)NULL) { @@ -111,23 +93,18 @@ get_filename() const { return empty_filename; } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::get_start -// Access: Published -// Description: Returns the offset within the file at which this file -// data begins. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset within the file at which this file data begins. + */ INLINE streampos SubfileInfo:: get_start() const { return _start; } -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::get_size -// Access: Published -// Description: Returns the number of consecutive bytes, beginning at -// get_start(), that correspond to this file data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of consecutive bytes, beginning at get_start(), that + * correspond to this file data. + */ INLINE streamsize SubfileInfo:: get_size() const { return _size; diff --git a/panda/src/express/subfileInfo.cxx b/panda/src/express/subfileInfo.cxx index 163cf2551b..07ab4fc7f8 100644 --- a/panda/src/express/subfileInfo.cxx +++ b/panda/src/express/subfileInfo.cxx @@ -1,24 +1,21 @@ -// Filename: subfileInfo.cxx -// Created by: drose (20Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subfileInfo.cxx + * @author drose + * @date 2011-06-20 + */ #include "subfileInfo.h" -//////////////////////////////////////////////////////////////////// -// Function: SubfileInfo::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SubfileInfo:: output(ostream &out) const { out << "SubfileInfo(" << get_filename() << ", " << _start << ", " << _size << ")"; diff --git a/panda/src/express/subfileInfo.h b/panda/src/express/subfileInfo.h index 43db37de8e..389263ab76 100644 --- a/panda/src/express/subfileInfo.h +++ b/panda/src/express/subfileInfo.h @@ -1,16 +1,15 @@ -// Filename: subfileInfo.h -// Created by: drose (20Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subfileInfo.h + * @author drose + * @date 2011-06-20 + */ #ifndef SUBFILEINFO_H #define SUBFILEINFO_H @@ -19,13 +18,11 @@ #include "fileReference.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : SubfileInfo -// Description : This class records a particular byte sub-range within -// an existing file on disk. Generally, the filename is -// understood as a physical file on disk, and not to be -// looked up via the vfs. -//////////////////////////////////////////////////////////////////// +/** + * This class records a particular byte sub-range within an existing file on + * disk. Generally, the filename is understood as a physical file on disk, + * and not to be looked up via the vfs. + */ class EXPCL_PANDAEXPRESS SubfileInfo { PUBLISHED: INLINE SubfileInfo(); diff --git a/panda/src/express/temporaryFile.I b/panda/src/express/temporaryFile.I index 759413b004..7cfc48c2cd 100644 --- a/panda/src/express/temporaryFile.I +++ b/panda/src/express/temporaryFile.I @@ -1,23 +1,19 @@ -// Filename: temporaryFile.I -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file temporaryFile.I + * @author drose + * @date 2011-06-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TemporaryFile::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TemporaryFile:: TemporaryFile(const Filename &filename) : FileReference(filename) { } diff --git a/panda/src/express/temporaryFile.cxx b/panda/src/express/temporaryFile.cxx index 7572ddc4c2..1bf4443dd0 100644 --- a/panda/src/express/temporaryFile.cxx +++ b/panda/src/express/temporaryFile.cxx @@ -1,27 +1,23 @@ -// Filename: temporaryFile.cxx -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file temporaryFile.cxx + * @author drose + * @date 2011-06-23 + */ #include "temporaryFile.h" TypeHandle TemporaryFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TemporaryFile::Destructor -// Access: Published, Virtual -// Description: The destructor is responsible for removing the file -// if it exists. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the file if it exists. + */ TemporaryFile:: ~TemporaryFile() { _filename.unlink(); diff --git a/panda/src/express/temporaryFile.h b/panda/src/express/temporaryFile.h index c603eda3ee..14874c9cca 100644 --- a/panda/src/express/temporaryFile.h +++ b/panda/src/express/temporaryFile.h @@ -1,16 +1,15 @@ -// Filename: temporaryFile.h -// Created by: drose (23Jun11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file temporaryFile.h + * @author drose + * @date 2011-06-23 + */ #ifndef TEMPORARYFILE_H #define TEMPORARYFILE_H @@ -19,13 +18,11 @@ #include "fileReference.h" -//////////////////////////////////////////////////////////////////// -// Class : TemporaryFile -// Description : This is a special kind of FileReference class that -// automatically deletes the file in question when it is -// deleted. It is not responsible for creating, -// opening, or closing the file, however. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of FileReference class that automatically deletes + * the file in question when it is deleted. It is not responsible for + * creating, opening, or closing the file, however. + */ class EXPCL_PANDAEXPRESS TemporaryFile : public FileReference { PUBLISHED: INLINE TemporaryFile(const Filename &filename); diff --git a/panda/src/express/test_ordered_vector.cxx b/panda/src/express/test_ordered_vector.cxx index be2370a431..1ed3ba9c96 100644 --- a/panda/src/express/test_ordered_vector.cxx +++ b/panda/src/express/test_ordered_vector.cxx @@ -1,16 +1,15 @@ -// Filename: test_ordered_vector.cxx -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_ordered_vector.cxx + * @author drose + * @date 2002-02-20 + */ #include "ordered_vector.h" @@ -19,11 +18,11 @@ typedef ov_multiset myvec; void search(myvec &v, int element) { pair result; - + result = v.equal_range(element); size_t count = v.count(element); - cerr << element << " bounded by " << result.first - v.begin() << " and " + cerr << element << " bounded by " << result.first - v.begin() << " and " << result.second - v.begin() << "; " << count << " total.\n"; } diff --git a/panda/src/express/test_types.cxx b/panda/src/express/test_types.cxx index 428f02b848..7cc5cf6e61 100644 --- a/panda/src/express/test_types.cxx +++ b/panda/src/express/test_types.cxx @@ -1,16 +1,15 @@ -// Filename: test_types.cxx -// Created by: drose (23Oct98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_types.cxx + * @author drose + * @date 1998-10-23 + */ #include "typedObject.h" #include "pointerTo.h" @@ -157,8 +156,7 @@ void show_derivation(TypeHandle type) { int main() { - // This initialization would normally be done by a ConfigureFn - // block. + // This initialization would normally be done by a ConfigureFn block. ThatThingie::init_type(); ThisThingie::init_type(); TheOtherThingie::init_type(); @@ -263,7 +261,7 @@ main() { ConstPointerToArray jarray = iarray; - // jarray[4] = jarray[6]; + // jarray[4] = jarray[6]; nout << "jarray[4] is " << jarray[4] << "\n"; diff --git a/panda/src/express/test_zstream.cxx b/panda/src/express/test_zstream.cxx index 6885cc2f86..34212eb2df 100644 --- a/panda/src/express/test_zstream.cxx +++ b/panda/src/express/test_zstream.cxx @@ -1,16 +1,15 @@ -// Filename: test_zstream.cxx -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_zstream.cxx + * @author drose + * @date 2002-08-05 + */ #include "pandabase.h" #include "zStream.h" @@ -58,7 +57,7 @@ zlib_decompress(istream &source) { char *dest = (char *)PANDA_MALLOC_ARRAY(dest_len); uLongf actual_dest_len = dest_len; - int result = uncompress((Bytef *)dest, &actual_dest_len, + int result = uncompress((Bytef *)dest, &actual_dest_len, (const Bytef *)data.data(), source_len); if (result != Z_OK) { cerr << "compress result == " << result << "\n"; @@ -70,7 +69,7 @@ zlib_decompress(istream &source) { dest = (char *)PANDA_REALLOC_ARRAY(dest, dest_len); actual_dest_len = dest_len; - result = uncompress((Bytef *)dest, &actual_dest_len, + result = uncompress((Bytef *)dest, &actual_dest_len, (const Bytef *)data.data(), source_len); if (result != Z_OK) { cerr << "compress result == " << result << "\n"; @@ -97,7 +96,7 @@ zlib_compress(istream &source) { char *dest = (char *)PANDA_MALLOC_ARRAY(dest_len); uLongf actual_dest_len = dest_len; - int result = compress((Bytef *)dest, &actual_dest_len, + int result = compress((Bytef *)dest, &actual_dest_len, (const Bytef *)data.data(), source_len); if (result != Z_OK) { @@ -116,7 +115,7 @@ main(int argc, char *argv[]) { argc--; argv++; } - + if (argc != 2) { cerr << "test_zstream [-z] file\n" << "compresses file to standard output, or decompresses it if the\n" diff --git a/panda/src/express/threadSafePointerTo.I b/panda/src/express/threadSafePointerTo.I index b6270a91cf..7525fd4e4c 100644 --- a/panda/src/express/threadSafePointerTo.I +++ b/panda/src/express/threadSafePointerTo.I @@ -1,33 +1,27 @@ -// Filename: threadSafePointerTo.I -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerTo.I + * @author drose + * @date 2006-04-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerTo:: ThreadSafePointerTo(To *ptr) : ThreadSafePointerToBase(ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerTo:: ThreadSafePointerTo(const ThreadSafePointerTo ©) : @@ -35,72 +29,57 @@ ThreadSafePointerTo(const ThreadSafePointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerTo:: ~ThreadSafePointerTo() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ThreadSafePointerTo::To &ThreadSafePointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert ThreadSafePointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert + * ThreadSafePointerTo's to the required kind of actual pointer. This + * introduces ambiguities which the compiler will resolve one way or the + * other, but we don't care which way it goes because either will be correct. + */ template INLINE ThreadSafePointerTo:: operator T * () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::p -// Access: Published -// Description: Returns an ordinary pointer instead of a ThreadSafePointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a ThreadSafePointerTo. Useful to + * work around compiler problems, particularly for implicit upcasts. + */ template INLINE TYPENAME ThreadSafePointerTo::To *ThreadSafePointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerTo &ThreadSafePointerTo:: operator = (To *ptr) { @@ -108,11 +87,9 @@ operator = (To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerTo &ThreadSafePointerTo:: operator = (const ThreadSafePointerTo ©) { @@ -120,11 +97,9 @@ operator = (const ThreadSafePointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo:: ThreadSafeConstPointerTo(const TYPENAME ThreadSafeConstPointerTo::To *ptr) : @@ -132,11 +107,9 @@ ThreadSafeConstPointerTo(const TYPENAME ThreadSafeConstPointerTo::To *ptr) : { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo:: ThreadSafeConstPointerTo(const ThreadSafePointerTo ©) : @@ -144,21 +117,17 @@ ThreadSafeConstPointerTo(const ThreadSafePointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo:: ~ThreadSafeConstPointerTo() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo:: ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©) : @@ -166,38 +135,30 @@ ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: operator *() const { return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: operator -> () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert ThreadSafeConstPointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert + * ThreadSafeConstPointerTo's to the required kind of actual pointer. This + * introduces ambiguities which the compiler will resolve one way or the + * other, but we don't care which way it goes because either will be correct. + */ template INLINE ThreadSafeConstPointerTo:: @@ -205,24 +166,19 @@ operator const T * () const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::p -// Access: Published -// Description: Returns an ordinary pointer instead of a ThreadSafeConstPointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a ThreadSafeConstPointerTo. Useful + * to work around compiler problems, particularly for implicit upcasts. + */ template INLINE const TYPENAME ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: p() const { return (To *)AtomicAdjust::get_ptr(this->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: operator = (const To *ptr) { @@ -230,11 +186,9 @@ operator = (const To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: operator = (const ThreadSafePointerTo ©) { @@ -242,11 +196,9 @@ operator = (const ThreadSafePointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafeConstPointerTo::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: operator = (const ThreadSafeConstPointerTo ©) { diff --git a/panda/src/express/threadSafePointerTo.cxx b/panda/src/express/threadSafePointerTo.cxx index 0742734b18..4c3692d32e 100644 --- a/panda/src/express/threadSafePointerTo.cxx +++ b/panda/src/express/threadSafePointerTo.cxx @@ -1,15 +1,14 @@ -// Filename: threadSafePointerTo.cxx -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerTo.cxx + * @author drose + * @date 2006-04-28 + */ #include "threadSafePointerTo.h" diff --git a/panda/src/express/threadSafePointerTo.h b/panda/src/express/threadSafePointerTo.h index c5c9cb9e12..56eeed1651 100644 --- a/panda/src/express/threadSafePointerTo.h +++ b/panda/src/express/threadSafePointerTo.h @@ -1,16 +1,15 @@ -// Filename: threadSafePointerTo.h -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerTo.h + * @author drose + * @date 2006-04-28 + */ #ifndef THREADSAFEPOINTERTO_H #define THREADSAFEPOINTERTO_H @@ -18,14 +17,12 @@ #include "pandabase.h" #include "threadSafePointerToBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ThreadSafePointerTo -// Description : This works exactly like PointerTo, except that the -// object is designed to be thread-safe: it is generally -// safe to make unprotected assignments to this pointer, -// in the sense that the last assignment will win and -// the reference counts will be properly maintained. -//////////////////////////////////////////////////////////////////// +/** + * This works exactly like PointerTo, except that the object is designed to be + * thread-safe: it is generally safe to make unprotected assignments to this + * pointer, in the sense that the last assignment will win and the reference + * counts will be properly maintained. + */ template class ThreadSafePointerTo : public ThreadSafePointerToBase { public: @@ -42,37 +39,35 @@ public: INLINE operator T *() const; PUBLISHED: - // When downcasting to a derived class from a ThreadSafePointerTo, - // C++ would normally require you to cast twice: once to an actual - // BaseClass pointer, and then again to your desired pointer. You - // can use the handy function p() to avoid this first cast and make - // your code look a bit cleaner. + // When downcasting to a derived class from a + // ThreadSafePointerTo, C++ would normally require you to cast + // twice: once to an actual BaseClass pointer, and then again to your + // desired pointer. You can use the handy function p() to avoid this first + // cast and make your code look a bit cleaner. - // e.g. instead of (MyType *)(BaseClass *)ptr, use (MyType *)ptr.p() + // e.g. instead of (MyType *)(BaseClass *)ptr, use (MyType *)ptr.p() - // If your base class is a derivative of TypedObject, you might want - // to use the DCAST macro defined in typedObject.h instead, - // e.g. DCAST(MyType, ptr). This provides a clean downcast that - // doesn't require .p() or any double-casting, and it can be - // run-time checked for correctness. + // If your base class is a derivative of TypedObject, you might want to use + // the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType, + // ptr). This provides a clean downcast that doesn't require .p() or any + // double-casting, and it can be run-time checked for correctness. INLINE To *p() const; INLINE ThreadSafePointerTo &operator = (To *ptr); INLINE ThreadSafePointerTo &operator = (const ThreadSafePointerTo ©); - // These functions normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the ThreadSafePointerToBase class). When - // this works again in interrogate, we can remove these. + // These functions normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the ThreadSafePointerToBase class). When this works + // again in interrogate, we can remove these. INLINE bool is_null() const { return ThreadSafePointerToBase::is_null(); } INLINE void clear() { ThreadSafePointerToBase::clear(); } }; -//////////////////////////////////////////////////////////////////// -// Class : ThreadSafeConstPointerTo -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ template class ThreadSafeConstPointerTo : public ThreadSafePointerToBase { public: @@ -95,10 +90,10 @@ PUBLISHED: INLINE ThreadSafeConstPointerTo &operator = (const ThreadSafePointerTo ©); INLINE ThreadSafeConstPointerTo &operator = (const ThreadSafeConstPointerTo ©); - // This functions normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the ThreadSafePointerToBase class). When - // this works again in interrogate, we can remove this. + // This functions normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the ThreadSafePointerToBase class). When this works + // again in interrogate, we can remove this. INLINE void clear() { ThreadSafePointerToBase::clear(); } }; diff --git a/panda/src/express/threadSafePointerToBase.I b/panda/src/express/threadSafePointerToBase.I index e22bc62af2..db8166b78a 100644 --- a/panda/src/express/threadSafePointerToBase.I +++ b/panda/src/express/threadSafePointerToBase.I @@ -1,58 +1,47 @@ -// Filename: threadSafePointerToBase.I -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerToBase.I + * @author drose + * @date 2006-04-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerToBase:: ThreadSafePointerToBase(To *ptr) { reassign(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerToBase:: ThreadSafePointerToBase(const ThreadSafePointerToBase ©) { reassign(copy); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ThreadSafePointerToBase:: ~ThreadSafePointerToBase() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::reassign -// Access: Protected -// Description: This is the main work of the ThreadSafePointerTo family. When -// the pointer is reassigned, decrement the old -// reference count and increment the new one. -//////////////////////////////////////////////////////////////////// +/** + * This is the main work of the ThreadSafePointerTo family. When the pointer + * is reassigned, decrement the old reference count and increment the new one. + */ template INLINE void ThreadSafePointerToBase:: reassign(To *ptr) { @@ -84,18 +73,16 @@ reassign(To *ptr) { } #endif } - + // Now delete the old pointer. if (old_ptr != (To *)NULL) { unref_delete(old_ptr); } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::reassign -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ThreadSafePointerToBase:: reassign(const ThreadSafePointerToBase ©) { @@ -103,13 +90,10 @@ reassign(const ThreadSafePointerToBase ©) { } #ifdef DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::update_type -// Access: Protected -// Description: Ensures that the MemoryUsage record for the pointer -// has the right type of object, if we know the type -// ourselves. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the MemoryUsage record for the pointer has the right type of + * object, if we know the type ourselves. + */ template void ThreadSafePointerToBase:: update_type(To *ptr) { @@ -125,24 +109,20 @@ update_type(To *ptr) { #endif // DO_MEMORY_USAGE -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::clear -// Access: Published -// Description: A convenient way to set the ThreadSafePointerTo object to NULL. -// (Assignment to a NULL pointer also works, of course.) -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to set the ThreadSafePointerTo object to NULL. (Assignment + * to a NULL pointer also works, of course.) + */ template INLINE void ThreadSafePointerToBase:: clear() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSafePointerToBase::output -// Access: Published -// Description: A handy function to output ThreadSafePointerTo's as a hex -// pointer followed by a reference count. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to output ThreadSafePointerTo's as a hex pointer followed + * by a reference count. + */ template INLINE void ThreadSafePointerToBase:: output(ostream &out) const { diff --git a/panda/src/express/threadSafePointerToBase.cxx b/panda/src/express/threadSafePointerToBase.cxx index f47a1b3e13..20d0230c86 100644 --- a/panda/src/express/threadSafePointerToBase.cxx +++ b/panda/src/express/threadSafePointerToBase.cxx @@ -1,15 +1,14 @@ -// Filename: threadSafePointerToBase.cxx -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerToBase.cxx + * @author drose + * @date 2006-04-28 + */ #include "threadSafePointerToBase.h" diff --git a/panda/src/express/threadSafePointerToBase.h b/panda/src/express/threadSafePointerToBase.h index 448e926bb4..dedcfd08ab 100644 --- a/panda/src/express/threadSafePointerToBase.h +++ b/panda/src/express/threadSafePointerToBase.h @@ -1,16 +1,15 @@ -// Filename: threadSafePointerToBase.h -// Created by: drose (28Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSafePointerToBase.h + * @author drose + * @date 2006-04-28 + */ #ifndef THREADSAFEPOINTERTOBASE_H #define THREADSAFEPOINTERTOBASE_H @@ -23,12 +22,11 @@ #include "config_express.h" #include "atomicAdjust.h" -//////////////////////////////////////////////////////////////////// -// Class : ThreadSafePointerToBase -// Description : This is the base class for ThreadSafePointerTo and -// ThreadSafeConstPointerTo. Don't try to use it -// directly; use either derived class instead. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for ThreadSafePointerTo and + * ThreadSafeConstPointerTo. Don't try to use it directly; use either derived + * class instead. + */ template class ThreadSafePointerToBase : public PointerToVoid { public: @@ -47,8 +45,8 @@ protected: #endif // DO_MEMORY_USAGE // No assignment or retrieval functions are declared in - // ThreadSafePointerToBase, because we will have to specialize on const - // vs. non-const later. + // ThreadSafePointerToBase, because we will have to specialize on const vs. + // non-const later. PUBLISHED: INLINE void clear(); diff --git a/panda/src/express/trueClock.I b/panda/src/express/trueClock.I index b0c4d861f3..da51e8628f 100644 --- a/panda/src/express/trueClock.I +++ b/panda/src/express/trueClock.I @@ -1,25 +1,21 @@ -// Filename: trueClock.I -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trueClock.I + * @author drose + * @date 2000-07-04 + */ #if defined(WIN32_VC) || defined(WIN64_VC) -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_short_time, Win32 implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double TrueClock:: get_short_time() { bool is_paranoid_clock = get_paranoid_clock(); @@ -31,8 +27,8 @@ get_short_time() { double time = get_short_raw_time(); if (is_paranoid_clock) { - // Check for rollforwards, rollbacks, and compensate for Speed - // Gear type programs by verifying against the time of day clock. + // Check for rollforwards, rollbacks, and compensate for Speed Gear type + // programs by verifying against the time of day clock. time = correct_time(time); _lock.release(); } @@ -42,11 +38,9 @@ get_short_time() { #else // WIN32_VC -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_short_time, Posix implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double TrueClock:: get_short_time() { return get_short_raw_time(); @@ -55,28 +49,21 @@ get_short_time() { #endif // WIN32_VC -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_error_count -// Access: Published -// Description: Returns the number of clock errors that have -// been detected. Each time a clock error is detected, -// in which the value returned by either of the above -// methods is suspect, the value returned by this method -// will be incremented. Applications can monitor this -// value and react, for instance, by resynchronizing -// their clocks each time this value changes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of clock errors that have been detected. Each time a + * clock error is detected, in which the value returned by either of the above + * methods is suspect, the value returned by this method will be incremented. + * Applications can monitor this value and react, for instance, by + * resynchronizing their clocks each time this value changes. + */ INLINE int TrueClock:: get_error_count() const { return _error_count; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the one TrueClock object in -// the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the one TrueClock object in the world. + */ INLINE TrueClock *TrueClock:: get_global_ptr() { if (_global_ptr == (TrueClock *)NULL) { @@ -85,12 +72,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::Destructor -// Access: Protected -// Description: A protected destructor because no one should try to -// delete the global TrueClock. -//////////////////////////////////////////////////////////////////// +/** + * A protected destructor because no one should try to delete the global + * TrueClock. + */ INLINE TrueClock:: ~TrueClock() { } diff --git a/panda/src/express/trueClock.cxx b/panda/src/express/trueClock.cxx index 9e55659a16..c3db68bbd9 100644 --- a/panda/src/express/trueClock.cxx +++ b/panda/src/express/trueClock.cxx @@ -1,17 +1,15 @@ -// Filename: trueClock.cxx -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trueClock.cxx + * @author drose + * @date 2000-07-04 + */ #include "trueClock.h" #include "config_express.h" @@ -23,11 +21,7 @@ TrueClock *TrueClock::_global_ptr = NULL; #if defined(WIN32_VC) || defined(WIN64_VC) -//////////////////////////////////////////////////////////////////// -// // The Win32 implementation. -// -//////////////////////////////////////////////////////////////////// #include #ifndef WIN32_LEAN_AND_MEAN @@ -38,17 +32,16 @@ TrueClock *TrueClock::_global_ptr = NULL; static const double _0001 = 1.0 / 1000.0; static const double _00000001 = 1.0 / 10000000.0; -// This is the interval of time, in seconds, over which to measure the -// high-precision clock rate vs. the time-of-day rate, when -// paranoid-clock is in effect. Reducing it makes the clock respond -// more quickly to changes in rate, but setting it too small may -// introduce erratic behavior, especially if the user has ntp -// configured. +// This is the interval of time, in seconds, over which to measure the high- +// precision clock rate vs. the time-of-day rate, when paranoid-clock is in +// effect. Reducing it makes the clock respond more quickly to changes in +// rate, but setting it too small may introduce erratic behavior, especially +// if the user has ntp configured. static const double paranoid_clock_interval = 3.0; -// It will be considered a clock jump error if either the -// high-precision clock or the time-of-day clock change by this number -// of seconds without the other jumping by a similar amount. +// It will be considered a clock jump error if either the high-precision clock +// or the time-of-day clock change by this number of seconds without the other +// jumping by a similar amount. static const double paranoid_clock_jump_error = 2.0; // If the we detect a clock jump error but the corrected clock skew is @@ -56,63 +49,57 @@ static const double paranoid_clock_jump_error = 2.0; // compensate. static const double paranoid_clock_jump_error_max_delta = 1.0; -// If the measured time_scale appears to change by more than this -// factor, it will be reported to the log. Changes to time_scale less -// than this factor are assumed to be within the margin of error. +// If the measured time_scale appears to change by more than this factor, it +// will be reported to the log. Changes to time_scale less than this factor +// are assumed to be within the margin of error. static const double paranoid_clock_report_scale_factor = 0.1; -// If the high-precision clock, after applying time_scale correction, -// is still more than this number of seconds above or below the -// time-of-day clock, it will be sped up or slowed down slightly until -// it is back in sync. +// If the high-precision clock, after applying time_scale correction, is still +// more than this number of seconds above or below the time-of-day clock, it +// will be sped up or slowed down slightly until it is back in sync. static const double paranoid_clock_chase_threshold = 0.5; -// This is the minimum factor by which the high-precision clock will -// be sped up or slowed down when it gets out of sync by -// paranoid-clock-chase-threshold. +// This is the minimum factor by which the high-precision clock will be sped +// up or slowed down when it gets out of sync by paranoid-clock-chase- +// threshold. static const double paranoid_clock_chase_factor = 0.1; -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_long_time, Win32 implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double TrueClock:: get_long_time() { int tc = GetTickCount(); return (double)(tc - _init_tc) * _0001; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_short_raw_time, Win32 implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double TrueClock:: get_short_raw_time() { double time; if (_has_high_res) { - // Use the high-resolution clock. This is of questionable value, - // since (a) on some OS's and hardware, the low 24 bits can - // occasionally roll over without setting the carry bit, causing - // the time to jump backwards, and (b) reportedly it can set the - // carry bit incorrectly sometimes, causing the time to jump - // forwards, and (c) even when it doesn't do that, it's not very - // accurate and seems to lose seconds of time per hour, and (d) - // someone could be running a program such as Speed Gear which - // munges this value anyway. +/* + * Use the high-resolution clock. This is of questionable value, since (a) on + * some OS's and hardware, the low 24 bits can occasionally roll over without + * setting the carry bit, causing the time to jump backwards, and (b) + * reportedly it can set the carry bit incorrectly sometimes, causing the time + * to jump forwards, and (c) even when it doesn't do that, it's not very + * accurate and seems to lose seconds of time per hour, and (d) someone could + * be running a program such as Speed Gear which munges this value anyway. + */ PN_int64 count; QueryPerformanceCounter((LARGE_INTEGER *)&count); time = (double)(count - _init_count) * _recip_frequency; } else { - // No high-resolution clock; return the best information we have. - // This doesn't suffer from the rollover problems that - // QueryPerformanceCounter does, but it's not very precise--only - // precise to 50ms on Win98, and 10ms on XP-based systems--and - // Speed Gear still munges it. + // No high-resolution clock; return the best information we have. This + // doesn't suffer from the rollover problems that QueryPerformanceCounter + // does, but it's not very precise--only precise to 50ms on Win98, and + // 10ms on XP-based systems--and Speed Gear still munges it. int tc = GetTickCount(); time = (double)(tc - _init_tc) * _0001; } @@ -120,11 +107,9 @@ get_short_raw_time() { return time; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::set_cpu_affinity, Win32 implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ typedef BOOL (WINAPI * PFNSETPROCESSAFFINITYMASK)(HANDLE, DWORD_PTR); typedef BOOL (WINAPI * PFNGETPROCESSAFFINITYMASK)(HANDLE, DWORD_PTR*, DWORD_PTR*); @@ -151,11 +136,9 @@ set_cpu_affinity(PN_uint32 mask) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::Constructor, Win32 implementation -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TrueClock:: TrueClock() { _error_count = 0; @@ -178,10 +161,10 @@ TrueClock() { if (lock_to_one_cpu) { set_cpu_affinity(0x01); } - + if (get_use_high_res_clock()) { PN_int64 int_frequency; - _has_high_res = + _has_high_res = (QueryPerformanceFrequency((LARGE_INTEGER *)&int_frequency) != 0); if (_has_high_res) { if (int_frequency <= 0) { @@ -198,20 +181,19 @@ TrueClock() { } } - // Also store the initial tick count. We'll need this for - // get_long_time(), as well as for get_short_time() if we're not - // using the high resolution clock. + // Also store the initial tick count. We'll need this for get_long_time(), + // as well as for get_short_time() if we're not using the high resolution + // clock. _init_tc = GetTickCount(); - // And we will need the current time of day to cross-check either of - // the above clocks if paranoid-clock is enabled. + // And we will need the current time of day to cross-check either of the + // above clocks if paranoid-clock is enabled. GetSystemTimeAsFileTime((FILETIME *)&_init_tod); _chase_clock = CC_keep_even; - // In case we'll be cross-checking the clock, we'd better start out - // with at least one timestamp, so we'll know if the clock jumps - // just after startup. + // In case we'll be cross-checking the clock, we'd better start out with at + // least one timestamp, so we'll know if the clock jumps just after startup. _timestamps.push_back(Timestamp(0.0, 0.0)); if (!_has_high_res) { @@ -220,32 +202,24 @@ TrueClock() { } } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::correct_time, Win32 implementation -// Access: Protected -// Description: Ensures that the reported timestamp from the -// high-precision (or even the low-precision) clock is -// valid by verifying against the time-of-day clock. -// -// This attempts to detect sudden jumps in time that -// might be caused by a failure of the high-precision -// clock to roll over properly. -// -// It also corrects for long-term skew of the clock by -// measuring the timing discrepency against the wall -// clock and projecting that discrepency into the -// future. This also should defeat programs such as -// Speed Gear that work by munging the value returned by -// QueryPerformanceCounter() and GetTickCount(), but not -// the wall clock time. -// -// However, relying on wall clock time presents its own -// set of problems, since the time of day might be -// adjusted slightly forward or back from time to time -// in response to ntp messages, or it might even be -// suddenly reset at any time by the user. So we do the -// best we can. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the reported timestamp from the high-precision (or even the + * low-precision) clock is valid by verifying against the time-of-day clock. + * + * This attempts to detect sudden jumps in time that might be caused by a + * failure of the high-precision clock to roll over properly. + * + * It also corrects for long-term skew of the clock by measuring the timing + * discrepency against the wall clock and projecting that discrepency into the + * future. This also should defeat programs such as Speed Gear that work by + * munging the value returned by QueryPerformanceCounter() and GetTickCount(), + * but not the wall clock time. + * + * However, relying on wall clock time presents its own set of problems, since + * the time of day might be adjusted slightly forward or back from time to + * time in response to ntp messages, or it might even be suddenly reset at any + * time by the user. So we do the best we can. + */ double TrueClock:: correct_time(double time) { // First, get the current time of day measurement. @@ -255,27 +229,26 @@ correct_time(double time) { nassertr(!_timestamps.empty(), time); - // Make sure we didn't experience a sudden jump from the last - // measurement. + // Make sure we didn't experience a sudden jump from the last measurement. double time_delta = (time - _timestamps.back()._time) * _time_scale; double tod_delta = (tod - _timestamps.back()._tod); - + if (time_delta < -0.0001 || fabs(time_delta - tod_delta) > paranoid_clock_jump_error) { - // A step backward in the high-precision clock, or more than a - // small jump on only one of the clocks, is cause for alarm. We - // allow a trivial step backward in the high-precision clock, - // since this does appear to happen in a threaded environment. + // A step backward in the high-precision clock, or more than a small jump + // on only one of the clocks, is cause for alarm. We allow a trivial step + // backward in the high-precision clock, since this does appear to happen + // in a threaded environment. clock_cat.debug() << "Clock error detected; elapsed time " << time_delta << "s on high-resolution counter, and " << tod_delta << "s on time-of-day clock.\n"; ++_error_count; - - // If both are negative, we call it 0. If one is negative, we - // trust the other one (up to paranoid_clock_jump_error). If both - // are nonnegative, we trust the smaller of the two. + + // If both are negative, we call it 0. If one is negative, we trust the + // other one (up to paranoid_clock_jump_error). If both are nonnegative, + // we trust the smaller of the two. double time_adjust = 0.0; double tod_adjust = 0.0; @@ -283,13 +256,13 @@ correct_time(double time) { // Trust neither. time_adjust = -time_delta; tod_adjust = -tod_delta; - + } else if (time_delta < 0.0 || (tod_delta >= 0.0 && tod_delta < time_delta)) { // Trust tod, up to a point. double new_tod_delta = min(tod_delta, paranoid_clock_jump_error); time_adjust = new_tod_delta - time_delta; tod_adjust = new_tod_delta - tod_delta; - + } else { // Trust time, up to a point. double new_time_delta = min(time_delta, paranoid_clock_jump_error); @@ -301,31 +274,30 @@ correct_time(double time) { time_delta += time_adjust; _tod_offset += tod_adjust; tod_delta += tod_adjust; - - // Apply the adjustments to the timestamp queue. We could just - // completely empty the timestamp queue, but that makes it hard to - // catch up if we are getting lots of these "momentary" errors in - // a row. + + // Apply the adjustments to the timestamp queue. We could just completely + // empty the timestamp queue, but that makes it hard to catch up if we are + // getting lots of these "momentary" errors in a row. Timestamps::iterator ti; for (ti = _timestamps.begin(); ti != _timestamps.end(); ++ti) { (*ti)._time -= time_adjust / _time_scale; (*ti)._tod -= tod_adjust; } - // And now we can record this timestamp, which is now consistent - // with the previous timestamps in the queue. + // And now we can record this timestamp, which is now consistent with the + // previous timestamps in the queue. _timestamps.push_back(Timestamp(time, tod)); - // Detecting and filtering this kind of momentary error can help - // protect us from legitimate problems cause by OS or BIOS bugs - // (which might introduce errors into the high precision clock), - // or from sudden changes to the time-of-day by the user, but we - // have to be careful because if the user uses a Speed Gear-type - // program to speed up the clock by an extreme amount, it can look - // like a lot of such "momentary" errors in a row--and if we throw - // them all out, we won't compute _time_scale correctly. To avoid - // this, we hack _time_scale here if we seem to be getting out of - // sync. +/* + * Detecting and filtering this kind of momentary error can help protect us + * from legitimate problems cause by OS or BIOS bugs (which might introduce + * errors into the high precision clock), or from sudden changes to the time- + * of-day by the user, but we have to be careful because if the user uses a + * Speed Gear-type program to speed up the clock by an extreme amount, it can + * look like a lot of such "momentary" errors in a row--and if we throw them + * all out, we won't compute _time_scale correctly. To avoid this, we hack + * _time_scale here if we seem to be getting out of sync. + */ double corrected_time = time * _time_scale + _time_offset; double corrected_tod = tod + _tod_offset; if (corrected_time - corrected_tod > paranoid_clock_jump_error_max_delta && @@ -336,46 +308,44 @@ correct_time(double time) { } } else if (tod_delta < 0.0) { - // A small backwards jump on the time-of-day clock is not a - // concern, since this is technically allowed with ntp enabled. - // We simply ignore the event. - + // A small backwards jump on the time-of-day clock is not a concern, since + // this is technically allowed with ntp enabled. We simply ignore the + // event. + } else { // Ok, we don't think there was a sudden jump, so carry on. - // The timestamp queue here records the measured timestamps over - // the past _priority_interval seconds. Its main purpose is to - // keep a running observation of _time_scale, so we can detect - // runtime changes of the clock's scale, for instance if the user - // is using a program like Speed Gear and pulls the slider during - // runtime. - + // The timestamp queue here records the measured timestamps over the past + // _priority_interval seconds. Its main purpose is to keep a running + // observation of _time_scale, so we can detect runtime changes of the + // clock's scale, for instance if the user is using a program like Speed + // Gear and pulls the slider during runtime. + // Consider the oldest timestamp in our queue. Timestamp oldest = _timestamps.front(); double time_age = (time - oldest._time); double tod_age = (tod - oldest._tod); double keep_interval = paranoid_clock_interval; - + if (tod_age > keep_interval / 2.0 && time_age > 0.0) { - // Adjust the _time_scale value to match the ratio between the - // elapsed time on the high-resolution clock, and the - // time-of-day clock. + // Adjust the _time_scale value to match the ratio between the elapsed + // time on the high-resolution clock, and the time-of-day clock. double new_time_scale = tod_age / time_age; - + // When we adjust _time_scale, we have to be careful to adjust - // _time_offset at the same time, so we don't introduce a - // sudden jump in time. + // _time_offset at the same time, so we don't introduce a sudden jump in + // time. set_time_scale(time, new_time_scale); - - // Check to see if the time scale has changed significantly - // since we last reported it. + + // Check to see if the time scale has changed significantly since we + // last reported it. double ratio = _time_scale / _last_reported_time_scale; if (fabs(ratio - 1.0) > paranoid_clock_report_scale_factor) { _time_scale_changed = true; _last_reported_time_scale = _time_scale; - // Actually report it a little bit later, to give the time - // scale a chance to settle down. + // Actually report it a little bit later, to give the time scale a + // chance to settle down. _report_time_scale_time = tod + _tod_offset + keep_interval; if (clock_cat.is_debug()) { clock_cat.debug() @@ -385,15 +355,15 @@ correct_time(double time) { } } } - + // Clean out old entries in the timestamps queue. if (tod_age > keep_interval) { - while (!_timestamps.empty() && + while (!_timestamps.empty() && tod - _timestamps.front()._tod > keep_interval) { _timestamps.pop_front(); } } - + // Record this timestamp. _timestamps.push_back(Timestamp(time, tod)); } @@ -411,20 +381,18 @@ correct_time(double time) { _time_scale_changed = false; } - // By the time we get here, we have a corrected_time and a - // corrected_tod value, both of which should be advancing at about - // the same rate. However, there might be accumulated skew between - // them, since there is some lag in the above algorithm that - // corrects the _time_scale, and clock skew can accumulate while the - // algorithm is catching up. + // By the time we get here, we have a corrected_time and a corrected_tod + // value, both of which should be advancing at about the same rate. + // However, there might be accumulated skew between them, since there is + // some lag in the above algorithm that corrects the _time_scale, and clock + // skew can accumulate while the algorithm is catching up. - // Therefore, we have one more line of defense: we check at this - // point for skew, and correct for it by slowing the clock down or - // speeding it up a bit as needed, until we even out the clocks - // again. Rather than adjusting the clock speed with _time_scale - // here, we simply slide _time_offset forward and back as - // needed--that way we don't interfere with the above algorithm, - // which is trying to compute _time_scale accurately. + // Therefore, we have one more line of defense: we check at this point for + // skew, and correct for it by slowing the clock down or speeding it up a + // bit as needed, until we even out the clocks again. Rather than adjusting + // the clock speed with _time_scale here, we simply slide _time_offset + // forward and back as needed--that way we don't interfere with the above + // algorithm, which is trying to compute _time_scale accurately. switch (_chase_clock) { case CC_slow_down: @@ -434,8 +402,8 @@ correct_time(double time) { if (clock_cat.is_debug()) { clock_cat.debug() << "Clock back down to real time.\n"; - // Let's report the clock error now, so an app can resync now - // that we're at a good time. + // Let's report the clock error now, so an app can resync now that + // we're at a good time. ++_error_count; } @@ -477,8 +445,8 @@ correct_time(double time) { if (clock_cat.is_debug()) { clock_cat.debug() << "Clock back up to real time.\n"; - // Let's report the clock error now, so an app can resync now - // that we're at a good time. + // Let's report the clock error now, so an app can resync now that + // we're at a good time. ++_error_count; } @@ -491,7 +459,7 @@ correct_time(double time) { } break; } - + if (clock_cat.is_spam()) { clock_cat.spam() << "time " << time << " tod " << corrected_tod @@ -501,13 +469,10 @@ correct_time(double time) { return corrected_time; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::set_time_scale, Win32 implementation -// Access: Protected -// Description: Changes the _time_scale value, recomputing -// _time_offset at the same time so we don't introduce a -// sudden jump in time. -//////////////////////////////////////////////////////////////////// +/** + * Changes the _time_scale value, recomputing _time_offset at the same time so + * we don't introduce a sudden jump in time. + */ void TrueClock:: set_time_scale(double time, double new_time_scale) { nassertv(new_time_scale > 0.0); @@ -517,22 +482,16 @@ set_time_scale(double time, double new_time_scale) { #else // !WIN32_VC -//////////////////////////////////////////////////////////////////// -// // The Posix implementation. -// -//////////////////////////////////////////////////////////////////// #include #include // for perror static long _init_sec; -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_long_time, Posix implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double TrueClock:: get_long_time() { struct timeval tv; @@ -550,18 +509,15 @@ get_long_time() { return 0.0; } - // We subtract out the time at which the clock was initialized, - // because we don't care about the number of seconds all the way - // back to 1970, and we want to leave the double with as much - // precision as it can get. + // We subtract out the time at which the clock was initialized, because we + // don't care about the number of seconds all the way back to 1970, and we + // want to leave the double with as much precision as it can get. return (double)(tv.tv_sec - _init_sec) + (double)tv.tv_usec / 1000000.0; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_short_raw_time, Posix implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double TrueClock:: get_short_raw_time() { struct timeval tv; @@ -579,28 +535,23 @@ get_short_raw_time() { return 0.0; } - // We subtract out the time at which the clock was initialized, - // because we don't care about the number of seconds all the way - // back to 1970, and we want to leave the double with as much - // precision as it can get. + // We subtract out the time at which the clock was initialized, because we + // don't care about the number of seconds all the way back to 1970, and we + // want to leave the double with as much precision as it can get. return (double)(tv.tv_sec - _init_sec) + (double)tv.tv_usec / 1000000.0; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::set_cpu_affinity, Posix implementation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TrueClock:: set_cpu_affinity(PN_uint32 mask) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::Constructor, Posix implementation -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TrueClock:: TrueClock() { _error_count = 0; diff --git a/panda/src/express/trueClock.h b/panda/src/express/trueClock.h index 4598c9a03e..8b7699da96 100644 --- a/panda/src/express/trueClock.h +++ b/panda/src/express/trueClock.h @@ -1,16 +1,15 @@ -// Filename: trueClock.h -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trueClock.h + * @author drose + * @date 2000-07-04 + */ #ifndef TRUECLOCK_H #define TRUECLOCK_H @@ -21,39 +20,32 @@ #include "mutexImpl.h" #include "config_express.h" -//////////////////////////////////////////////////////////////////// -// Class : TrueClock -// Description : An interface to whatever real-time clock we might -// have available in the current environment. There is -// only one TrueClock in existence, and it constructs -// itself. -// -// The TrueClock returns elapsed real time in seconds -// since some undefined epoch. Since it is not defined -// at what time precisely the clock indicates zero, this -// value can only be meaningfully used to measure -// elapsed time, by sampling it at two different times -// and subtracting. -//////////////////////////////////////////////////////////////////// +/** + * An interface to whatever real-time clock we might have available in the + * current environment. There is only one TrueClock in existence, and it + * constructs itself. + * + * The TrueClock returns elapsed real time in seconds since some undefined + * epoch. Since it is not defined at what time precisely the clock indicates + * zero, this value can only be meaningfully used to measure elapsed time, by + * sampling it at two different times and subtracting. + */ class EXPCL_PANDAEXPRESS TrueClock { PUBLISHED: - // get_long_time() returns the most accurate timer we have over a - // long interval. It may not be very precise for measuring short - // intervals, but it should not drift substantially over the long - // haul. + // get_long_time() returns the most accurate timer we have over a long + // interval. It may not be very precise for measuring short intervals, but + // it should not drift substantially over the long haul. double get_long_time(); MAKE_PROPERTY(long_time, get_long_time); - // get_short_time() returns the most precise timer we have over a - // short interval. It may tend to drift over the long haul, but it - // should have lots of digits to measure short intervals very - // precisely. + // get_short_time() returns the most precise timer we have over a short + // interval. It may tend to drift over the long haul, but it should have + // lots of digits to measure short intervals very precisely. INLINE double get_short_time(); MAKE_PROPERTY(short_time, get_short_time); - // get_short_raw_time() is like get_short_time(), but does not apply - // any corrections (e.g. paranoid-clock) to the result returned by - // the OS. + // get_short_raw_time() is like get_short_time(), but does not apply any + // corrections (e.g. paranoid-clock) to the result returned by the OS. double get_short_raw_time(); MAKE_PROPERTY(short_raw_time, get_short_raw_time); @@ -83,9 +75,9 @@ protected: PN_uint64 _init_tod; // The rest of the data structures in this block are strictly for - // implementing paranoid_clock: they are designed to allow us to - // cross-check the high-resolution clock against the time-of-day - // clock, and smoothly correct for deviations. + // implementing paranoid_clock: they are designed to allow us to cross-check + // the high-resolution clock against the time-of-day clock, and smoothly + // correct for deviations. class Timestamp { public: Timestamp(double time, double tod) : _time(time), _tod(tod) { } diff --git a/panda/src/express/typeHandle_ext.cxx b/panda/src/express/typeHandle_ext.cxx index 14ca0fa402..2064e42844 100644 --- a/panda/src/express/typeHandle_ext.cxx +++ b/panda/src/express/typeHandle_ext.cxx @@ -1,29 +1,25 @@ -// Filename: typeHandle_ext.cxx -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeHandle_ext.cxx + * @author rdb + * @date 2014-09-17 + */ #include "typeHandle_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: TypeHandle::make -// Access: Published, Static -// Description: Constructs a TypeHandle from a Python class object. -// Useful for automatic coercion, to allow a class -// object to be passed wherever a TypeHandle is -// expected. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TypeHandle from a Python class object. Useful for automatic + * coercion, to allow a class object to be passed wherever a TypeHandle is + * expected. + */ TypeHandle Extension:: make(PyTypeObject *tp) { if (!PyType_IsSubtype(tp, &Dtool_DTOOL_SUPER_BASE._PyType)) { diff --git a/panda/src/express/typeHandle_ext.h b/panda/src/express/typeHandle_ext.h index edfae0efa0..1f70253409 100644 --- a/panda/src/express/typeHandle_ext.h +++ b/panda/src/express/typeHandle_ext.h @@ -1,16 +1,15 @@ -// Filename: typeHandle_ext.h -// Created by: rdb (17Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typeHandle_ext.h + * @author rdb + * @date 2014-09-17 + */ #ifndef TYPEHANDLE_EXT_H #define TYPEHANDLE_EXT_H @@ -23,12 +22,10 @@ #include "typeHandle.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// TypeHandle, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for TypeHandle, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/express/typedReferenceCount.I b/panda/src/express/typedReferenceCount.I index 51179aab63..df31fdd609 100644 --- a/panda/src/express/typedReferenceCount.I +++ b/panda/src/express/typedReferenceCount.I @@ -1,23 +1,19 @@ -// Filename: typedReferenceCount.I -// Created by: drose (25May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedReferenceCount.I + * @author drose + * @date 2000-05-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypedReferenceCount::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedReferenceCount:: TypedReferenceCount() { #ifdef DO_MEMORY_USAGE @@ -25,11 +21,9 @@ TypedReferenceCount() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: TypedReferenceCount::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedReferenceCount:: TypedReferenceCount(const TypedReferenceCount ©) : TypedObject(copy), @@ -40,11 +34,9 @@ TypedReferenceCount(const TypedReferenceCount ©) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: TypedReferenceCount::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypedReferenceCount:: operator = (const TypedReferenceCount ©) { TypedObject::operator = (copy); diff --git a/panda/src/express/typedReferenceCount.cxx b/panda/src/express/typedReferenceCount.cxx index a035f80de2..a93f9e81e9 100644 --- a/panda/src/express/typedReferenceCount.cxx +++ b/panda/src/express/typedReferenceCount.cxx @@ -1,17 +1,15 @@ -// Filename: typedReferenceCount.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedReferenceCount.cxx + * @author drose + * @date 1999-02-08 + */ #include "typedReferenceCount.h" diff --git a/panda/src/express/typedReferenceCount.h b/panda/src/express/typedReferenceCount.h index 66cd29ef63..3f2daaab61 100644 --- a/panda/src/express/typedReferenceCount.h +++ b/panda/src/express/typedReferenceCount.h @@ -1,16 +1,15 @@ -// Filename: typedReferenceCount.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedReferenceCount.h + * @author drose + * @date 1999-02-08 + */ #ifndef TYPEDREFERENCECOUNT_H #define TYPEDREFERENCECOUNT_H @@ -20,18 +19,15 @@ #include "typedObject.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : TypedReferenceCount -// Description : A base class for things which need to inherit from -// both TypedObject and from ReferenceCount. It's -// convenient to define this intermediate base class -// instead of multiply inheriting from the two classes -// each time they are needed, so that we can sensibly -// pass around pointers to things which are both -// TypedObjects and ReferenceCounters. -// -// See also TypedObject for detailed instructions. -//////////////////////////////////////////////////////////////////// +/** + * A base class for things which need to inherit from both TypedObject and + * from ReferenceCount. It's convenient to define this intermediate base + * class instead of multiply inheriting from the two classes each time they + * are needed, so that we can sensibly pass around pointers to things which + * are both TypedObjects and ReferenceCounters. + * + * See also TypedObject for detailed instructions. + */ class EXPCL_PANDAEXPRESS TypedReferenceCount : public TypedObject, public ReferenceCount { public: INLINE TypedReferenceCount(); @@ -65,4 +61,3 @@ private: #include "typedReferenceCount.I" #endif - diff --git a/panda/src/express/typedef.h b/panda/src/express/typedef.h index 747fba8331..32822ae52d 100644 --- a/panda/src/express/typedef.h +++ b/panda/src/express/typedef.h @@ -1,16 +1,16 @@ -// Filename: typedef.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedef.h + * @author mike + * @date 1997-01-09 + */ + #ifndef TYPEDEF_H #define TYPEDEF_H diff --git a/panda/src/express/vector_double.cxx b/panda/src/express/vector_double.cxx index d75298b0e2..165600e2a7 100644 --- a/panda/src/express/vector_double.cxx +++ b/panda/src/express/vector_double.cxx @@ -1,16 +1,15 @@ -// Filename: vector_double.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_double.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_double.h" diff --git a/panda/src/express/vector_double.h b/panda/src/express/vector_double.h index 35d739b3ac..1a36c1e425 100644 --- a/panda/src/express/vector_double.h +++ b/panda/src/express/vector_double.h @@ -1,16 +1,15 @@ -// Filename: vector_double.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_double.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_DOUBLE_H #define VECTOR_DOUBLE_H @@ -19,14 +18,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_double -// Description : A vector of doubles. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of doubles. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_PANDAEXPRESS #define EXPTP EXPTP_PANDAEXPRESS diff --git a/panda/src/express/vector_float.cxx b/panda/src/express/vector_float.cxx index 9f8b211f77..cc0df9289c 100644 --- a/panda/src/express/vector_float.cxx +++ b/panda/src/express/vector_float.cxx @@ -1,16 +1,15 @@ -// Filename: vector_float.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_float.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_float.h" diff --git a/panda/src/express/vector_float.h b/panda/src/express/vector_float.h index b88914eb5c..862980b15a 100644 --- a/panda/src/express/vector_float.h +++ b/panda/src/express/vector_float.h @@ -1,16 +1,15 @@ -// Filename: vector_float.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_float.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_FLOAT_H #define VECTOR_FLOAT_H @@ -19,14 +18,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_float -// Description : A vector of floats. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of floats. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_PANDAEXPRESS #define EXPTP EXPTP_PANDAEXPRESS diff --git a/panda/src/express/vector_stdfloat.h b/panda/src/express/vector_stdfloat.h index 9c9885fc0b..cecf6c18d8 100644 --- a/panda/src/express/vector_stdfloat.h +++ b/panda/src/express/vector_stdfloat.h @@ -1,16 +1,15 @@ -// Filename: vector_stdfloat.h -// Created by: drose (07Oct11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_stdfloat.h + * @author drose + * @date 2011-10-07 + */ #ifndef VECTOR_STDFLOAT_H #define VECTOR_STDFLOAT_H @@ -27,4 +26,3 @@ typedef vector_double vector_stdfloat; #endif // STDFLOAT_DOUBLE #endif - diff --git a/panda/src/express/vector_uchar.cxx b/panda/src/express/vector_uchar.cxx index de7ca45972..5463ef0724 100644 --- a/panda/src/express/vector_uchar.cxx +++ b/panda/src/express/vector_uchar.cxx @@ -1,16 +1,15 @@ -// Filename: vector_uchar.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_uchar.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_uchar.h" diff --git a/panda/src/express/vector_uchar.h b/panda/src/express/vector_uchar.h index f0bdefda73..ce6a1997bb 100644 --- a/panda/src/express/vector_uchar.h +++ b/panda/src/express/vector_uchar.h @@ -1,16 +1,15 @@ -// Filename: vector_uchar.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_uchar.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_UCHAR_H #define VECTOR_UCHAR_H @@ -19,14 +18,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_uchar -// Description : A vector of uchars. This class is defined once here, -// and exported to PANDAEXPRESS.DLL; other packages that -// want to use a vector of this type (whether they need -// to export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of uchars. This class is defined once here, and exported to + * PANDAEXPRESS.DLL; other packages that want to use a vector of this type + * (whether they need to export it or not) should include this header file, + * rather than defining the vector again. + */ #define EXPCL EXPCL_PANDAEXPRESS #define EXPTP EXPTP_PANDAEXPRESS diff --git a/panda/src/express/virtualFile.I b/panda/src/express/virtualFile.I index 8602a90bdf..f9fee3c999 100644 --- a/panda/src/express/virtualFile.I +++ b/panda/src/express/virtualFile.I @@ -1,44 +1,36 @@ -// Filename: virtualFile.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFile.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFile:: VirtualFile() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::get_original_filename -// Access: Published -// Description: Returns the original filename as it was used to -// locate this VirtualFile. This is usually, but not -// always, the same string returned by get_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the original filename as it was used to locate this VirtualFile. + * This is usually, but not always, the same string returned by + * get_filename(). + */ INLINE const Filename &VirtualFile:: get_original_filename() const { return _original_filename; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::read_file -// Access: Public -// Description: Returns the entire contents of the file as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire contents of the file as a string. + */ INLINE string VirtualFile:: read_file(bool auto_unwrap) const { string result; @@ -46,25 +38,19 @@ read_file(bool auto_unwrap) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::write_file -// Access: Public -// Description: Writes the entire contents of the file as a string, -// if it is writable. -//////////////////////////////////////////////////////////////////// +/** + * Writes the entire contents of the file as a string, if it is writable. + */ INLINE bool VirtualFile:: write_file(const string &data, bool auto_wrap) { return write_file((const unsigned char *)data.data(), data.size(), auto_wrap); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::set_original_filename -// Access: Public -// Description: Stores the original filename that was used to locate -// this VirtualFile. This is normally called only by -// the VirtualFileSystem, as it creates each -// VirtualFile. -//////////////////////////////////////////////////////////////////// +/** + * Stores the original filename that was used to locate this VirtualFile. + * This is normally called only by the VirtualFileSystem, as it creates each + * VirtualFile. + */ INLINE void VirtualFile:: set_original_filename(const Filename &filename) { _original_filename = filename; @@ -76,4 +62,3 @@ operator << (ostream &out, const VirtualFile &file) { file.output(out); return out; } - diff --git a/panda/src/express/virtualFile.cxx b/panda/src/express/virtualFile.cxx index 19900e82b6..1d12b7f250 100644 --- a/panda/src/express/virtualFile.cxx +++ b/panda/src/express/virtualFile.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFile.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFile.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFile.h" #include "virtualFileSystem.h" @@ -21,127 +20,103 @@ TypeHandle VirtualFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::has_file -// Access: Published, Virtual -// Description: Returns true if this file exists, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file exists, false otherwise. + */ bool VirtualFile:: has_file() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::is_directory -// Access: Published, Virtual -// Description: Returns true if this file represents a directory (and -// scan_directory() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a directory (and scan_directory() may + * be called), false otherwise. + */ bool VirtualFile:: is_directory() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::is_regular_file -// Access: Published, Virtual -// Description: Returns true if this file represents a regular file -// (and read_file() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a regular file (and read_file() may be + * called), false otherwise. + */ bool VirtualFile:: is_regular_file() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::is_writable -// Access: Published, Virtual -// Description: Returns true if this file may be written to, which -// implies write_file() may be called (unless it is a -// directory instead of a regular file). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file may be written to, which implies write_file() may + * be called (unless it is a directory instead of a regular file). + */ bool VirtualFile:: is_writable() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::delete_file -// Access: Public -// Description: Attempts to delete this file or directory. This can -// remove a single file or an empty directory. It will -// not remove a nonempty directory. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete this file or directory. This can remove a single file + * or an empty directory. It will not remove a nonempty directory. Returns + * true on success, false on failure. + */ bool VirtualFile:: delete_file() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::rename_file -// Access: Public -// Description: Attempts to move or rename this file or directory. -// If the original file is an ordinary file, it will -// quietly replace any already-existing file in the new -// filename (but not a directory). If the original file -// is a directory, the new filename must not already -// exist. -// -// If the file is a directory, the new filename must be -// within the same mount point. If the file is an -// ordinary file, the new filename may be anywhere; but -// if it is not within the same mount point then the -// rename operation is automatically performed as a -// two-step copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to move or rename this file or directory. If the original file is + * an ordinary file, it will quietly replace any already-existing file in the + * new filename (but not a directory). If the original file is a directory, + * the new filename must not already exist. + * + * If the file is a directory, the new filename must be within the same mount + * point. If the file is an ordinary file, the new filename may be anywhere; + * but if it is not within the same mount point then the rename operation is + * automatically performed as a two-step copy-and-delete operation. + */ bool VirtualFile:: rename_file(VirtualFile *new_file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::copy_file -// Access: Public -// Description: Attempts to copy the contents of this file to the -// indicated file. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of this file to the indicated file. Returns + * true on success, false on failure. + */ bool VirtualFile:: copy_file(VirtualFile *new_file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::scan_directory -// Access: Published -// Description: If the file represents a directory (that is, -// is_directory() returns true), this returns the list -// of files within the directory at the current time. -// Returns NULL if the file is not a directory or if the -// directory cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * If the file represents a directory (that is, is_directory() returns true), + * this returns the list of files within the directory at the current time. + * Returns NULL if the file is not a directory or if the directory cannot be + * read. + */ PT(VirtualFileList) VirtualFile:: scan_directory() const { - // First, we have to make sure there aren't any mount points attached - // under this directory. These will override any local filenames. + // First, we have to make sure there aren't any mount points attached under + // this directory. These will override any local filenames. VirtualFileSystem *file_system = get_file_system(); Filename this_filename = get_filename(); vector_string mount_points_flat; file_system->scan_mount_points(mount_points_flat, this_filename); - // Copy the set of nested mount points to a sorted list so we can - // search it quickly. + // Copy the set of nested mount points to a sorted list so we can search it + // quickly. ov_set mount_points; copy(mount_points_flat.begin(), mount_points_flat.end(), back_inserter(mount_points)); mount_points.sort(); - + PT(VirtualFileList) file_list = new VirtualFileList; - // Each of those mount points maps to a directory root or something - // from the file system. + // Each of those mount points maps to a directory root or something from the + // file system. ov_set::const_iterator mi; for (mi = mount_points.begin(); mi != mount_points.end(); ++mi) { const string &basename = (*mi); @@ -158,30 +133,25 @@ scan_directory() const { return NULL; } - // We couldn't read the physical directory, but we do have some - // mounted files to return. + // We couldn't read the physical directory, but we do have some mounted + // files to return. return file_list; } return file_list; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFile:: output(ostream &out) const { out << get_filename(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::ls -// Access: Published -// Description: If the file represents a directory, lists its -// contents. -//////////////////////////////////////////////////////////////////// +/** + * If the file represents a directory, lists its contents. + */ void VirtualFile:: ls(ostream &out) const { CPT(VirtualFileList) contents = scan_directory(); @@ -201,12 +171,10 @@ ls(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::ls_all -// Access: Published -// Description: If the file represents a directory, recursively lists -// its contents and those of all subdirectories. -//////////////////////////////////////////////////////////////////// +/** + * If the file represents a directory, recursively lists its contents and + * those of all subdirectories. + */ void VirtualFile:: ls_all(ostream &out) const { if (!is_directory()) { @@ -216,216 +184,169 @@ ls_all(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::open_read_file -// Access: Published, Virtual -// Description: Opens the file for reading. Returns a newly -// allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading. Returns a newly allocated istream on success + * (which you should eventually delete when you are done reading). Returns + * NULL on failure. + */ istream *VirtualFile:: open_read_file(bool auto_unwrap) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::close_read_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_read_file(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_file(). This really + * just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFile:: close_read_file(istream *stream) const { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::was_read_successful -// Access: Published, Virtual -// Description: Call this method after a reading the istream returned -// by open_read_file() to completion. If it returns -// true, the file was read completely and without error; -// if it returns false, there may have been some errors -// or a truncated file read. This is particularly -// likely if the stream is a VirtualFileHTTP. -//////////////////////////////////////////////////////////////////// +/** + * Call this method after a reading the istream returned by open_read_file() + * to completion. If it returns true, the file was read completely and + * without error; if it returns false, there may have been some errors or a + * truncated file read. This is particularly likely if the stream is a + * VirtualFileHTTP. + */ bool VirtualFile:: was_read_successful() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::open_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ ostream *VirtualFile:: open_write_file(bool auto_wrap, bool truncate) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::open_append_file -// Access: Published, Virtual -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFile:: open_append_file() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::close_write_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_write_file(). This really just deletes the -// ostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_write_file(). This really + * just deletes the ostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFile:: close_write_file(ostream *stream) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::open_read_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated iostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated iostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ iostream *VirtualFile:: open_read_write_file(bool truncate) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::open_read_append_file -// Access: Published, Virtual -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFile:: open_read_append_file() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::close_read_write_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_read_write_file(). This really just deletes the -// iostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_write_file(). This + * really just deletes the iostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFile:: close_read_write_file(iostream *stream) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFile:: get_file_size(istream *stream) const { return get_file_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFile:: get_file_size() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFile:: get_timestamp() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::get_system_info -// Access: Published, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it does not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it does + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFile:: get_system_info(SubfileInfo &info) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::atomic_compare_and_exchange_contents -// Access: Public, Virtual -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFile:: atomic_compare_and_exchange_contents(string &orig_contents, - const string &old_contents, + const string &old_contents, const string &new_contents) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::atomic_read_contents -// Access: Public, Virtual -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFile:: atomic_read_contents(string &contents) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::read_file -// Access: Public -// Description: Fills up the indicated string with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated string with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFile:: read_file(string &result, bool auto_unwrap) const { result = string(); @@ -442,37 +363,29 @@ read_file(string &result, bool auto_unwrap) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::read_file -// Access: Public, Virtual -// Description: Fills up the indicated pvector with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFile:: read_file(pvector &result, bool auto_unwrap) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::write_file -// Access: Public, Virtual -// Description: Writes the indicated data to the file, if it is -// writable. Returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated data to the file, if it is writable. Returns true on + * success, false otherwise. + */ bool VirtualFile:: write_file(const unsigned char *data, size_t data_size, bool auto_wrap) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::simple_read_file -// Access: Public, Static -// Description: Fills up the indicated pvector with the contents of -// the just-opened file. Returns true on success, false -// otherwise. If the pvector was not empty on entry, the -// data read from the file will be appended onto it. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the just-opened file. + * Returns true on success, false otherwise. If the pvector was not empty on + * entry, the data read from the file will be appended onto it. + */ bool VirtualFile:: simple_read_file(istream *in, pvector &result) { static const size_t buffer_size = 4096; @@ -490,12 +403,10 @@ simple_read_file(istream *in, pvector &result) { return (!in->fail() || in->eof()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::simple_read_file -// Access: Public -// Description: As in simple_read_file() with two parameters, above, -// but only reads up to max_bytes bytes from the file. -//////////////////////////////////////////////////////////////////// +/** + * As in simple_read_file() with two parameters, above, but only reads up to + * max_bytes bytes from the file. + */ bool VirtualFile:: simple_read_file(istream *in, pvector &result, size_t max_bytes) { static const size_t buffer_size = 4096; @@ -515,25 +426,20 @@ simple_read_file(istream *in, pvector &result, size_t max_bytes) return (!in->fail() || in->eof()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::scan_local_directory -// Access: Protected, Virtual -// Description: Fills file_list up with the list of files that are -// within this directory, excluding those whose -// basenames are listed in mount_points. Returns true -// if successful, false if the file is not a directory -// or the directory cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills file_list up with the list of files that are within this directory, + * excluding those whose basenames are listed in mount_points. Returns true + * if successful, false if the file is not a directory or the directory cannot + * be read. + */ bool VirtualFile:: scan_local_directory(VirtualFileList *, const ov_set &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::r_ls_all -// Access: Private -// Description: The recursive implementation of ls_all(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of ls_all(). + */ void VirtualFile:: r_ls_all(ostream &out, const Filename &root) const { CPT(VirtualFileList) contents = scan_directory(); diff --git a/panda/src/express/virtualFile.h b/panda/src/express/virtualFile.h index 3b773cd10b..0719f3f8d1 100644 --- a/panda/src/express/virtualFile.h +++ b/panda/src/express/virtualFile.h @@ -1,16 +1,15 @@ -// Filename: virtualFile.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFile.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILE_H #define VIRTUALFILE_H @@ -29,11 +28,10 @@ class VirtualFileList; class VirtualFileSystem; -//////////////////////////////////////////////////////////////////// -// Class : VirtualFile -// Description : The abstract base class for a file or directory -// within the VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for a file or directory within the + * VirtualFileSystem. + */ class EXPCL_PANDAEXPRESS VirtualFile : public TypedReferenceCount { public: INLINE VirtualFile(); @@ -94,7 +92,7 @@ public: static bool simple_read_file(istream *stream, pvector &result, size_t max_bytes); protected: - virtual bool scan_local_directory(VirtualFileList *file_list, + virtual bool scan_local_directory(VirtualFileList *file_list, const ov_set &mount_points) const; private: diff --git a/panda/src/express/virtualFileComposite.I b/panda/src/express/virtualFileComposite.I index 39bbba731b..911968874f 100644 --- a/panda/src/express/virtualFileComposite.I +++ b/panda/src/express/virtualFileComposite.I @@ -1,23 +1,19 @@ -// Filename: virtualFileComposite.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileComposite.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileComposite:: VirtualFileComposite(VirtualFileSystem *file_system, const Filename &filename) : _file_system(file_system), @@ -25,18 +21,15 @@ VirtualFileComposite(VirtualFileSystem *file_system, const Filename &filename) : { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::add_component -// Access: Public -// Description: Adds one more component to the composite directory. -// The component should be a directory and the file -// system and filename should match the composite. -//////////////////////////////////////////////////////////////////// +/** + * Adds one more component to the composite directory. The component should + * be a directory and the file system and filename should match the composite. + */ INLINE void VirtualFileComposite:: add_component(VirtualFile *file) { nassertv(file->is_directory()); nassertv(file->get_file_system() == _file_system); nassertv(file->get_filename() == _filename); - + _components.push_back(file); } diff --git a/panda/src/express/virtualFileComposite.cxx b/panda/src/express/virtualFileComposite.cxx index e36d414d01..30a5cbb0d9 100644 --- a/panda/src/express/virtualFileComposite.cxx +++ b/panda/src/express/virtualFileComposite.cxx @@ -1,76 +1,62 @@ -// Filename: virtualFileComposite.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileComposite.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileComposite.h" TypeHandle VirtualFileComposite::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::get_file_system -// Access: Published, Virtual -// Description: Returns the VirtualFileSystem this file is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFileSystem this file is associated with. + */ VirtualFileSystem *VirtualFileComposite:: get_file_system() const { return _file_system; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::get_filename -// Access: Published, Virtual -// Description: Returns the full pathname to this file within the -// virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to this file within the virtual file system. + */ Filename VirtualFileComposite:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::has_file -// Access: Published, Virtual -// Description: Returns true if this file exists, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file exists, false otherwise. + */ bool VirtualFileComposite:: has_file() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::is_directory -// Access: Published, Virtual -// Description: Returns true if this file represents a directory (and -// scan_directory() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a directory (and scan_directory() may + * be called), false otherwise. + */ bool VirtualFileComposite:: is_directory() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileComposite::scan_local_directory -// Access: Protected, Virtual -// Description: Fills file_list up with the list of files that are -// within this directory, excluding those whose -// basenames are listed in mount_points. Returns true -// if successful, false if the file is not a directory -// or the directory cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills file_list up with the list of files that are within this directory, + * excluding those whose basenames are listed in mount_points. Returns true + * if successful, false if the file is not a directory or the directory cannot + * be read. + */ bool VirtualFileComposite:: -scan_local_directory(VirtualFileList *file_list, +scan_local_directory(VirtualFileList *file_list, const ov_set &mount_points) const { bool any_ok = false; Components::const_iterator ci; @@ -79,6 +65,6 @@ scan_local_directory(VirtualFileList *file_list, any_ok = true; } } - + return any_ok; } diff --git a/panda/src/express/virtualFileComposite.h b/panda/src/express/virtualFileComposite.h index 91bfd06129..d7e39ed302 100644 --- a/panda/src/express/virtualFileComposite.h +++ b/panda/src/express/virtualFileComposite.h @@ -1,16 +1,15 @@ -// Filename: virtualFileComposite.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileComposite.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILECOMPOSITE_H #define VIRTUALFILECOMPOSITE_H @@ -19,13 +18,11 @@ #include "virtualFile.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileComposite -// Description : A composite directory within the VirtualFileSystem: -// this maps to more than one directory on different -// mount points. The resulting directory appears to be -// the union of all the individual simple directories. -//////////////////////////////////////////////////////////////////// +/** + * A composite directory within the VirtualFileSystem: this maps to more than + * one directory on different mount points. The resulting directory appears + * to be the union of all the individual simple directories. + */ class EXPCL_PANDAEXPRESS VirtualFileComposite : public VirtualFile { public: INLINE VirtualFileComposite(VirtualFileSystem *file_system, @@ -40,7 +37,7 @@ public: virtual bool is_directory() const; protected: - virtual bool scan_local_directory(VirtualFileList *file_list, + virtual bool scan_local_directory(VirtualFileList *file_list, const ov_set &mount_points) const; private: diff --git a/panda/src/express/virtualFileList.I b/panda/src/express/virtualFileList.I index 461cc9e433..efd87c2711 100644 --- a/panda/src/express/virtualFileList.I +++ b/panda/src/express/virtualFileList.I @@ -1,104 +1,83 @@ -// Filename: virtualFileList.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileList.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileList:: VirtualFileList() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileList:: ~VirtualFileList() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::add_file -// Access: Public -// Description: Adds a new file to the list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new file to the list. + */ INLINE void VirtualFileList:: add_file(VirtualFile *file) { _files.push_back(file); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::get_num_files -// Access: Published -// Description: Returns the number of files in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of files in the list. + */ INLINE size_t VirtualFileList:: get_num_files() const { return _files.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::get_file -// Access: Published -// Description: Returns the nth file in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth file in the list. + */ INLINE VirtualFile *VirtualFileList:: get_file(size_t n) const { nassertr(n < _files.size(), NULL); return _files[n]; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::operator [] -// Access: Published -// Description: Returns the nth file in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth file in the list. + */ INLINE VirtualFile *VirtualFileList:: operator [](size_t n) const { nassertr(n < _files.size(), NULL); return _files[n]; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::size -// Access: Published -// Description: Returns the number of files in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of files in the list. + */ INLINE size_t VirtualFileList:: size() const { return _files.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void VirtualFileList:: operator += (const VirtualFileList &other) { _files.insert(_files.end(), other._files.begin(), other._files.end()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileList::operator + -// Access: Published -// Description: Returns a VirtualFileList representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a VirtualFileList representing the concatenation of the two lists. + */ INLINE VirtualFileList VirtualFileList:: operator + (const VirtualFileList &other) const { VirtualFileList a(*this); diff --git a/panda/src/express/virtualFileList.cxx b/panda/src/express/virtualFileList.cxx index 7161ef076e..92b3127812 100644 --- a/panda/src/express/virtualFileList.cxx +++ b/panda/src/express/virtualFileList.cxx @@ -1,15 +1,14 @@ -// Filename: virtualFileList.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileList.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileList.h" diff --git a/panda/src/express/virtualFileList.h b/panda/src/express/virtualFileList.h index 12481c60cc..6f01172a7a 100644 --- a/panda/src/express/virtualFileList.h +++ b/panda/src/express/virtualFileList.h @@ -1,16 +1,15 @@ -// Filename: virtualFileList.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileList.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILELIST_H #define VIRTUALFILELIST_H @@ -20,11 +19,9 @@ #include "virtualFile.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileList -// Description : A list of VirtualFiles, as returned by -// VirtualFile::scan_directory(). -//////////////////////////////////////////////////////////////////// +/** + * A list of VirtualFiles, as returned by VirtualFile::scan_directory(). + */ class EXPCL_PANDAEXPRESS VirtualFileList : public ReferenceCount { public: INLINE VirtualFileList(); diff --git a/panda/src/express/virtualFileMount.I b/panda/src/express/virtualFileMount.I index 3ee8f7ca5d..81e22016bf 100644 --- a/panda/src/express/virtualFileMount.I +++ b/panda/src/express/virtualFileMount.I @@ -1,23 +1,19 @@ -// Filename: virtualFileMount.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMount.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMount:: VirtualFileMount() : _file_system(NULL), @@ -25,36 +21,28 @@ VirtualFileMount() : { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::get_file_system -// Access: Public -// Description: Returns the file system this mount object is attached -// to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the file system this mount object is attached to. + */ INLINE VirtualFileSystem *VirtualFileMount:: get_file_system() const { return _file_system; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::get_mount_point -// Access: Public -// Description: Returns the name of the directory within the virtual -// file system that this mount object is attached to. -// This directory name will end with a slash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the directory within the virtual file system that this + * mount object is attached to. This directory name will end with a slash. + */ INLINE const Filename &VirtualFileMount:: get_mount_point() const { return _mount_point; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::get_mount_flags -// Access: Public -// Description: Returns the set of flags passed by the user to the -// VirtualFileSystem::mount() command. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of flags passed by the user to the + * VirtualFileSystem::mount() command. + */ INLINE int VirtualFileMount:: get_mount_flags() const { return _mount_flags; diff --git a/panda/src/express/virtualFileMount.cxx b/panda/src/express/virtualFileMount.cxx index 4be532b8a7..89e8ddfc24 100644 --- a/panda/src/express/virtualFileMount.cxx +++ b/panda/src/express/virtualFileMount.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMount.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMount.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileMount.h" #include "virtualFileSimple.h" @@ -20,26 +19,20 @@ TypeHandle VirtualFileMount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMount:: ~VirtualFileMount() { nassertv(_file_system == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::make_virtual_file -// Access: Public, Virtual -// Description: Constructs and returns a new VirtualFile instance -// that corresponds to the indicated filename within -// this mount point. The returned VirtualFile object -// does not imply that the given file actually exists; -// but if the file does exist, then the handle can be -// used to read it. -//////////////////////////////////////////////////////////////////// +/** + * Constructs and returns a new VirtualFile instance that corresponds to the + * indicated filename within this mount point. The returned VirtualFile + * object does not imply that the given file actually exists; but if the file + * does exist, then the handle can be used to read it. + */ PT(VirtualFile) VirtualFileMount:: make_virtual_file(const Filename &local_filename, const Filename &original_filename, bool implicit_pz_file, @@ -63,93 +56,72 @@ make_virtual_file(const Filename &local_filename, return file.p(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::create_file -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success (or if the file already exists), or false if -// it cannot be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success (or if the file already exists), or + * false if it cannot be created. + */ bool VirtualFileMount:: create_file(const Filename &file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::delete_file -// Access: Public, Virtual -// Description: Attempts to delete the indicated file or directory -// within the mount. This can remove a single file or -// an empty directory. It will not remove a nonempty -// directory. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete the indicated file or directory within the mount. This + * can remove a single file or an empty directory. It will not remove a + * nonempty directory. Returns true on success, false on failure. + */ bool VirtualFileMount:: delete_file(const Filename &file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::rename_file -// Access: Public -// Description: Attempts to rename the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, this will be -// attempted again with a copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to rename the contents of the indicated file to the indicated + * file. Both filenames will be within the mount. Returns true on success, + * false on failure. If this returns false, this will be attempted again with + * a copy-and-delete operation. + */ bool VirtualFileMount:: rename_file(const Filename &orig_filename, const Filename &new_filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::copy_file -// Access: Public -// Description: Attempts to copy the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, the copy will be -// performed by explicit read-and-write operations. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of the indicated file to the indicated file. + * Both filenames will be within the mount. Returns true on success, false on + * failure. If this returns false, the copy will be performed by explicit + * read-and-write operations. + */ bool VirtualFileMount:: copy_file(const Filename &orig_filename, const Filename &new_filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::make_directory -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success, or false if it cannot be created. If the -// directory already existed prior to this call, may -// return either true or false. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success, or false if it cannot be created. + * If the directory already existed prior to this call, may return either true + * or false. + */ bool VirtualFileMount:: make_directory(const Filename &file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::is_writable -// Access: Public, Virtual -// Description: Returns true if the named file or directory may be -// written to, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named file or directory may be written to, false + * otherwise. + */ bool VirtualFileMount:: is_writable(const Filename &file) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::read_file -// Access: Public, Virtual -// Description: Fills up the indicated pvector with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFileMount:: read_file(const Filename &file, bool do_uncompress, pvector &result) const { @@ -178,13 +150,10 @@ read_file(const Filename &file, bool do_uncompress, return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::write_file -// Access: Public, Virtual -// Description: Writes the indicated data to the file, if it is a -// writable file. Returns true on success, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated data to the file, if it is a writable file. Returns + * true on success, false otherwise. + */ bool VirtualFileMount:: write_file(const Filename &file, bool do_compress, const unsigned char *data, size_t data_size) { @@ -206,17 +175,14 @@ write_file(const Filename &file, bool do_compress, return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_read_file -// Access: Published, Virtual -// Description: Opens the file for reading. Returns a newly -// allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -// -// If do_uncompress is true, the file is also -// decompressed on-the-fly using zlib. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading. Returns a newly allocated istream on success + * (which you should eventually delete when you are done reading). Returns + * NULL on failure. + * + * If do_uncompress is true, the file is also decompressed on-the-fly using + * zlib. + */ istream *VirtualFileMount:: open_read_file(const Filename &file, bool do_uncompress) const { istream *result = open_read_file(file); @@ -232,44 +198,34 @@ open_read_file(const Filename &file, bool do_uncompress) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::close_read_file -// Access: Public, Virtual -// Description: Closes a file opened by a previous call to -// open_read_file(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_file(). This really + * just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileMount:: close_read_file(istream *stream) const { VirtualFileSystem::close_read_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ ostream *VirtualFileMount:: open_write_file(const Filename &file, bool truncate) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_write_file -// Access: Published -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -// -// If do_compress is true, the file is also -// compressed on-the-fly using zlib. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + * + * If do_compress is true, the file is also compressed on-the-fly using zlib. + */ ostream *VirtualFileMount:: open_write_file(const Filename &file, bool do_compress, bool truncate) { ostream *result = open_write_file(file, truncate); @@ -285,125 +241,99 @@ open_write_file(const Filename &file, bool do_compress, bool truncate) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_append_file -// Access: Published, Virtual -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFileMount:: open_append_file(const Filename &file) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::close_write_file -// Access: Public, Virtual -// Description: Closes a file opened by a previous call to -// open_write_file(). This really just deletes the -// ostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_write_file(). This really + * just deletes the ostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileMount:: close_write_file(ostream *stream) { VirtualFileSystem::close_write_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_read_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated iostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated iostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ iostream *VirtualFileMount:: open_read_write_file(const Filename &file, bool truncate) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::open_read_append_file -// Access: Published, Virtual -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFileMount:: open_read_append_file(const Filename &file) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::close_read_write_file -// Access: Public, Virtual -// Description: Closes a file opened by a previous call to -// open_read_write_file(). This really just deletes the -// iostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_write_file(). This + * really just deletes the iostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileMount:: close_read_write_file(iostream *stream) { VirtualFileSystem::close_read_write_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::get_system_info -// Access: Public, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it does not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it does + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFileMount:: get_system_info(const Filename &file, SubfileInfo &info) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::atomic_compare_and_exchange_contents -// Access: Public, Virtual -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFileMount:: atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, - const string &old_contents, + const string &old_contents, const string &new_contents) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::atomic_read_contents -// Access: Public, Virtual -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFileMount:: atomic_read_contents(const Filename &file, string &contents) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMount:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMount::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMount:: write(ostream &out) const { out << *this << " on /" << get_mount_point() << "\n"; diff --git a/panda/src/express/virtualFileMount.h b/panda/src/express/virtualFileMount.h index 33c54d5ee4..47b36b52f1 100644 --- a/panda/src/express/virtualFileMount.h +++ b/panda/src/express/virtualFileMount.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMount.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMount.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILEMOUNT_H #define VIRTUALFILEMOUNT_H @@ -24,12 +23,11 @@ class VirtualFileSystem; -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMount -// Description : The abstract base class for a mount definition used -// within a VirtualFileSystem. Normally users don't -// need to monkey with this class directly. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for a mount definition used within a + * VirtualFileSystem. Normally users don't need to monkey with this class + * directly. + */ class EXPCL_PANDAEXPRESS VirtualFileMount : public TypedReferenceCount { PUBLISHED: INLINE VirtualFileMount(); @@ -78,7 +76,7 @@ public: virtual time_t get_timestamp(const Filename &file) const=0; virtual bool get_system_info(const Filename &file, SubfileInfo &info); - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const=0; virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); diff --git a/panda/src/express/virtualFileMountAndroidAsset.I b/panda/src/express/virtualFileMountAndroidAsset.I index ebc832a592..7a96300d99 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.I +++ b/panda/src/express/virtualFileMountAndroidAsset.I @@ -1,34 +1,28 @@ -// Filename: virtualFileMountAndroidAsset.I -// Created by: rdb (21Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountAndroidAsset.I + * @author rdb + * @date 2013-01-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountAndroidAsset:: VirtualFileMountAndroidAsset(AAssetManager *mgr, const string &apk_path) : _asset_mgr(mgr), _apk_path(apk_path) { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountAndroidAsset::AssetStream:: AssetStream(AAsset *asset) : istream(new VirtualFileMountAndroidAsset::AssetStreamBuf(asset)) { diff --git a/panda/src/express/virtualFileMountAndroidAsset.cxx b/panda/src/express/virtualFileMountAndroidAsset.cxx index a2519e541a..3c85aaebb7 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.cxx +++ b/panda/src/express/virtualFileMountAndroidAsset.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMountAndroidAsset.cxx -// Created by: rdb (21Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountAndroidAsset.cxx + * @author rdb + * @date 2013-01-21 + */ #ifdef ANDROID @@ -23,22 +22,17 @@ TypeHandle VirtualFileMountAndroidAsset::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountAndroidAsset:: ~VirtualFileMountAndroidAsset() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::get_fd -// Access: Public -// Description: Returns a file descriptor that can be used to read -// the asset if it was stored uncompressed and -// unencrypted. Returns a valid fd or -1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a file descriptor that can be used to read the asset if it was + * stored uncompressed and unencrypted. Returns a valid fd or -1. + */ int VirtualFileMountAndroidAsset:: get_fd(const Filename &file, off_t *start, off_t *length) const { AAsset* asset; @@ -49,45 +43,35 @@ get_fd(const Filename &file, off_t *start, off_t *length) const { return fd; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::has_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system. + */ bool VirtualFileMountAndroidAsset:: has_file(const Filename &file) const { return (file.empty() || /*is_directory(file) ||*/ is_regular_file(file)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::is_directory -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * directory. + */ bool VirtualFileMountAndroidAsset:: is_directory(const Filename &file) const { // This is the only way - AAssetManager_openDir also works for files. - //AAssetDir *dir = AAssetManager_openDir(_asset_mgr, file.c_str()); + // AAssetDir *dir = AAssetManager_openDir(_asset_mgr, file.c_str()); - //express_cat.error() << "is_directory " << file << " - " << dir << "\n"; + // express_cat.error() << "is_directory " << file << " - " << dir << "\n"; - //if (dir == NULL) { - // return false; - //} - //AAssetDir_close(dir); + // if (dir == NULL) { return false; } AAssetDir_close(dir); // openDir doesn't return NULL for ordinary files! return !is_regular_file(file); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::is_regular_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * regular file. + */ bool VirtualFileMountAndroidAsset:: is_regular_file(const Filename &file) const { // I'm afraid the only way to see if it exists is to try and open it. @@ -103,25 +87,22 @@ is_regular_file(const Filename &file) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::read_file -// Access: Public, Virtual -// Description: Fills up the indicated pvector with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFileMountAndroidAsset:: read_file(const Filename &file, bool do_uncompress, pvector &result) const { if (do_uncompress) { - // If the file is to be decompressed, we'd better just use the - // higher-level implementation, which includes support for - // on-the-fly decompression. + // If the file is to be decompressed, we'd better just use the higher- + // level implementation, which includes support for on-the-fly + // decompression. return VirtualFileMount::read_file(file, do_uncompress, result); } - // But if we're just reading a straight file, let's just read - // it here to avoid all of the streambuf nonsense. + // But if we're just reading a straight file, let's just read it here to + // avoid all of the streambuf nonsense. result.clear(); AAsset* asset; @@ -154,14 +135,11 @@ read_file(const Filename &file, bool do_uncompress, return (count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::open_read_file -// Access: Public, Virtual -// Description: Opens the file for reading, if it exists. Returns a -// newly allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading, if it exists. Returns a newly allocated + * istream on success (which you should eventually delete when you are done + * reading). Returns NULL on failure. + */ istream *VirtualFileMountAndroidAsset:: open_read_file(const Filename &file) const { AAsset* asset; @@ -174,15 +152,11 @@ open_read_file(const Filename &file) const { return (istream *) stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileMountAndroidAsset:: get_file_size(const Filename &file, istream *in) const { // If it's already open, get the AAsset pointer from the streambuf. @@ -191,12 +165,10 @@ get_file_size(const Filename &file, istream *in) const { return length; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileMountAndroidAsset:: get_file_size(const Filename &file) const { AAsset* asset = AAssetManager_open(_asset_mgr, file.c_str(), AASSET_MODE_UNKNOWN); @@ -205,36 +177,29 @@ get_file_size(const Filename &file) const { return length; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileMountAndroidAsset:: get_timestamp(const Filename &file) const { // There's no obvious way to get a timestamp from an Android asset. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::get_system_info -// Access: Public, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it might not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it might + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFileMountAndroidAsset:: get_system_info(const Filename &file, SubfileInfo &info) { off_t start, length; @@ -256,14 +221,11 @@ get_system_info(const Filename &file, SubfileInfo &info) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::scan_directory -// Access: Public, Virtual -// Description: Fills the given vector up with the list of filenames -// that are local to this directory, if the filename is -// a directory. Returns true if successful, or false if -// the file is not a directory or cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of filenames that are local to this + * directory, if the filename is a directory. Returns true if successful, or + * false if the file is not a directory or cannot be read. + */ bool VirtualFileMountAndroidAsset:: scan_directory(vector_string &contents, const Filename &dir) const { AAssetDir *asset_dir = AAssetManager_openDir(_asset_mgr, dir.c_str()); @@ -285,21 +247,17 @@ scan_directory(vector_string &contents, const Filename &dir) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStream::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountAndroidAsset::AssetStream:: ~AssetStream() { delete rdbuf(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountAndroidAsset::AssetStreamBuf:: AssetStreamBuf(AAsset *asset) : _asset(asset) { @@ -315,21 +273,17 @@ AssetStreamBuf(AAsset *asset) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountAndroidAsset::AssetStreamBuf:: ~AssetStreamBuf() { AAsset_close(_asset); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStreamBuf::seekoff -// Access: Public, Virtual -// Description: Implements seeking within the stream. -//////////////////////////////////////////////////////////////////// +/** + * Implements seeking within the stream. + */ streampos VirtualFileMountAndroidAsset::AssetStreamBuf:: seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { size_t n = egptr() - gptr(); @@ -341,8 +295,7 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { break; case ios_base::cur: if (off == 0) { - // Just requesting the current position, - // no need to void the buffer. + // Just requesting the current position, no need to void the buffer. return AAsset_seek(_asset, 0, SEEK_CUR) - n; } else if (gptr() + off >= eback() && gptr() + off < egptr()) { @@ -362,20 +315,15 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) { return AAsset_seek(_asset, off, whence); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStreamBuf::seekpos -// Access: Public, Virtual -// Description: A variant on seekoff() to implement seeking within a -// stream. -// -// The MSDN Library claims that it is only necessary to -// redefine seekoff(), and not seekpos() as well, as the -// default implementation of seekpos() is supposed to -// map to seekoff() exactly as I am doing here; but in -// fact it must do something else, because seeking -// didn't work on Windows until I redefined this -// function as well. -//////////////////////////////////////////////////////////////////// +/** + * A variant on seekoff() to implement seeking within a stream. + * + * The MSDN Library claims that it is only necessary to redefine seekoff(), + * and not seekpos() as well, as the default implementation of seekpos() is + * supposed to map to seekoff() exactly as I am doing here; but in fact it + * must do something else, because seeking didn't work on Windows until I + * redefined this function as well. + */ streampos VirtualFileMountAndroidAsset::AssetStreamBuf:: seekpos(streampos pos, ios_openmode which) { size_t n = egptr() - gptr(); @@ -383,12 +331,10 @@ seekpos(streampos pos, ios_openmode which) { return AAsset_seek(_asset, pos, SEEK_SET); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountAndroidAsset::AssetStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int VirtualFileMountAndroidAsset::AssetStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. diff --git a/panda/src/express/virtualFileMountAndroidAsset.h b/panda/src/express/virtualFileMountAndroidAsset.h index d6f17f3087..792db38ffc 100644 --- a/panda/src/express/virtualFileMountAndroidAsset.h +++ b/panda/src/express/virtualFileMountAndroidAsset.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMountAndroidAsset.h -// Created by: rdb (21Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountAndroidAsset.h + * @author rdb + * @date 2013-01-21 + */ #ifndef VIRTUALFILEMOUNTANDROIDASSET_H #define VIRTUALFILEMOUNTANDROIDASSET_H @@ -25,11 +24,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMountAndroidAsset -// Description : Maps a Multifile's contents into the -// VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Maps a Multifile's contents into the VirtualFileSystem. + */ class EXPCL_PANDAEXPRESS VirtualFileMountAndroidAsset : public VirtualFileMount { PUBLISHED: INLINE VirtualFileMountAndroidAsset(AAssetManager *mgr, const string &apk_path); @@ -51,7 +48,7 @@ public: virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const; private: diff --git a/panda/src/express/virtualFileMountMultifile.I b/panda/src/express/virtualFileMountMultifile.I index b94724d9f8..489403e4f9 100644 --- a/panda/src/express/virtualFileMountMultifile.I +++ b/panda/src/express/virtualFileMountMultifile.I @@ -1,35 +1,28 @@ -// Filename: virtualFileMountMultifile.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountMultifile.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountMultifile:: VirtualFileMountMultifile(Multifile *multifile) : _multifile(multifile) { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::get_multifile -// Access: Public -// Description: Returns the Multifile pointer that this mount object -// is based on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Multifile pointer that this mount object is based on. + */ INLINE Multifile *VirtualFileMountMultifile:: get_multifile() const { return _multifile; diff --git a/panda/src/express/virtualFileMountMultifile.cxx b/panda/src/express/virtualFileMountMultifile.cxx index 520649a0db..c871ea39a1 100644 --- a/panda/src/express/virtualFileMountMultifile.cxx +++ b/panda/src/express/virtualFileMountMultifile.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMountMultifile.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountMultifile.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileMountMultifile.h" #include "virtualFileSystem.h" @@ -18,22 +17,17 @@ TypeHandle VirtualFileMountMultifile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountMultifile:: ~VirtualFileMountMultifile() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::has_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system. + */ bool VirtualFileMountMultifile:: has_file(const Filename &file) const { return (file.empty() || @@ -41,47 +35,40 @@ has_file(const Filename &file) const { _multifile->has_directory(file)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::is_directory -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * directory. + */ bool VirtualFileMountMultifile:: is_directory(const Filename &file) const { return (file.empty() || _multifile->has_directory(file)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::is_regular_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * regular file. + */ bool VirtualFileMountMultifile:: is_regular_file(const Filename &file) const { return (_multifile->find_subfile(file) >= 0); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::read_file -// Access: Public, Virtual -// Description: Fills up the indicated pvector with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFileMountMultifile:: read_file(const Filename &file, bool do_uncompress, pvector &result) const { if (do_uncompress) { - // If the file is to be decompressed, we'd better just use the - // higher-level implementation, which includes support for - // on-the-fly decompression. + // If the file is to be decompressed, we'd better just use the higher- + // level implementation, which includes support for on-the-fly + // decompression. return VirtualFileMount::read_file(file, do_uncompress, result); } - // But if we're just reading a straight file, let the Multifile do - // the reading, which avoids a few levels of buffer copies. + // But if we're just reading a straight file, let the Multifile do the + // reading, which avoids a few levels of buffer copies. int subfile_index = _multifile->find_subfile(file); if (subfile_index < 0) { @@ -93,14 +80,11 @@ read_file(const Filename &file, bool do_uncompress, return _multifile->read_subfile(subfile_index, result); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::open_read_file -// Access: Public, Virtual -// Description: Opens the file for reading, if it exists. Returns a -// newly allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading, if it exists. Returns a newly allocated + * istream on success (which you should eventually delete when you are done + * reading). Returns NULL on failure. + */ istream *VirtualFileMountMultifile:: open_read_file(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); @@ -110,20 +94,16 @@ open_read_file(const Filename &file) const { // The caller will eventually pass this pointer to // VirtualFileSystem::close_read_file(), not to - // Multifile::close_read_subfile(). Fortunately, these two methods - // do the same thing, so that doesn't matter. + // Multifile::close_read_subfile(). Fortunately, these two methods do the + // same thing, so that doesn't matter. return _multifile->open_read_subfile(subfile_index); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileMountMultifile:: get_file_size(const Filename &file, istream *) const { int subfile_index = _multifile->find_subfile(file); @@ -133,12 +113,10 @@ get_file_size(const Filename &file, istream *) const { return _multifile->get_subfile_length(subfile_index); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileMountMultifile:: get_file_size(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); @@ -148,20 +126,16 @@ get_file_size(const Filename &file) const { return _multifile->get_subfile_length(subfile_index); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileMountMultifile:: get_timestamp(const Filename &file) const { int subfile_index = _multifile->find_subfile(file); @@ -171,16 +145,13 @@ get_timestamp(const Filename &file) const { return _multifile->get_subfile_timestamp(subfile_index); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::get_system_info -// Access: Public, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it might not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it might + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFileMountMultifile:: get_system_info(const Filename &file, SubfileInfo &info) { Filename multifile_name = _multifile->get_multifile_name(); @@ -199,29 +170,24 @@ get_system_info(const Filename &file, SubfileInfo &info) { streampos start = _multifile->get_subfile_internal_start(subfile_index); size_t length = _multifile->get_subfile_internal_length(subfile_index); - info = SubfileInfo(multifile_name, start, length); + info = SubfileInfo(multifile_name, start, length); return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::scan_directory -// Access: Public, Virtual -// Description: Fills the given vector up with the list of filenames -// that are local to this directory, if the filename is -// a directory. Returns true if successful, or false if -// the file is not a directory or cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of filenames that are local to this + * directory, if the filename is a directory. Returns true if successful, or + * false if the file is not a directory or cannot be read. + */ bool VirtualFileMountMultifile:: scan_directory(vector_string &contents, const Filename &dir) const { return _multifile->scan_directory(contents, dir); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountMultifile::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMountMultifile:: output(ostream &out) const { out << _multifile->get_multifile_name(); diff --git a/panda/src/express/virtualFileMountMultifile.h b/panda/src/express/virtualFileMountMultifile.h index f237193e41..d82b29af4d 100644 --- a/panda/src/express/virtualFileMountMultifile.h +++ b/panda/src/express/virtualFileMountMultifile.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMountMultifile.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountMultifile.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILEMOUNTMULTIFILE_H #define VIRTUALFILEMOUNTMULTIFILE_H @@ -21,11 +20,9 @@ #include "multifile.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMountMultifile -// Description : Maps a Multifile's contents into the -// VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Maps a Multifile's contents into the VirtualFileSystem. + */ class EXPCL_PANDAEXPRESS VirtualFileMountMultifile : public VirtualFileMount { PUBLISHED: INLINE VirtualFileMountMultifile(Multifile *multifile); @@ -47,7 +44,7 @@ public: virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const; virtual void output(ostream &out) const; diff --git a/panda/src/express/virtualFileMountRamdisk.I b/panda/src/express/virtualFileMountRamdisk.I index 8f64f5b510..37d89f9ce3 100644 --- a/panda/src/express/virtualFileMountRamdisk.I +++ b/panda/src/express/virtualFileMountRamdisk.I @@ -1,54 +1,44 @@ -// Filename: virtualFileMountRamdisk.I -// Created by: drose (19Sep11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountRamdisk.I + * @author drose + * @date 2011-09-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::FileBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountRamdisk::FileBase:: FileBase(const string &basename) : _basename(basename), _timestamp(time(NULL)) { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::FileBase::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool VirtualFileMountRamdisk::FileBase:: operator < (const FileBase &other) const { return _basename < other._basename; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::File::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountRamdisk::File:: -File(const string &basename) : +File(const string &basename) : FileBase(basename), _wrapper(&_data, false, true) { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountRamdisk::Directory:: Directory(const string &basename) : FileBase(basename) { } diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 09e103ae19..9f10931985 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMountRamdisk.cxx -// Created by: drose (19Sep11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountRamdisk.cxx + * @author drose + * @date 2011-09-19 + */ #include "virtualFileMountRamdisk.h" #include "subStream.h" @@ -21,21 +20,16 @@ TypeHandle VirtualFileMountRamdisk::FileBase::_type_handle; TypeHandle VirtualFileMountRamdisk::File::_type_handle; TypeHandle VirtualFileMountRamdisk::Directory::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountRamdisk:: VirtualFileMountRamdisk() : _root("") { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::has_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system. + */ bool VirtualFileMountRamdisk:: has_file(const Filename &file) const { _lock.acquire(); @@ -44,14 +38,11 @@ has_file(const Filename &file) const { return (f != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::create_file -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success (or if the file already exists), or false if -// it cannot be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success (or if the file already exists), or + * false if it cannot be created. + */ bool VirtualFileMountRamdisk:: create_file(const Filename &file) { _lock.acquire(); @@ -60,15 +51,11 @@ create_file(const Filename &file) { return (f != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::delete_file -// Access: Public, Virtual -// Description: Attempts to delete the indicated file or directory -// within the mount. This can remove a single file or -// an empty directory. It will not remove a nonempty -// directory. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete the indicated file or directory within the mount. This + * can remove a single file or an empty directory. It will not remove a + * nonempty directory. Returns true on success, false on failure. + */ bool VirtualFileMountRamdisk:: delete_file(const Filename &file) { _lock.acquire(); @@ -77,15 +64,12 @@ delete_file(const Filename &file) { return (f != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::rename_file -// Access: Public -// Description: Attempts to rename the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, this will be -// attempted again with a copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to rename the contents of the indicated file to the indicated + * file. Both filenames will be within the mount. Returns true on success, + * false on failure. If this returns false, this will be attempted again with + * a copy-and-delete operation. + */ bool VirtualFileMountRamdisk:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.acquire(); @@ -135,15 +119,12 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::copy_file -// Access: Public -// Description: Attempts to copy the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, the copy will be -// performed by explicit read-and-write operations. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of the indicated file to the indicated file. + * Both filenames will be within the mount. Returns true on success, false on + * failure. If this returns false, the copy will be performed by explicit + * read-and-write operations. + */ bool VirtualFileMountRamdisk:: copy_file(const Filename &orig_filename, const Filename &new_filename) { _lock.acquire(); @@ -172,15 +153,12 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::make_directory -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success, or false if it cannot be created. If the -// directory already existed prior to this call, may -// return either true or false. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success, or false if it cannot be created. + * If the directory already existed prior to this call, may return either true + * or false. + */ bool VirtualFileMountRamdisk:: make_directory(const Filename &file) { _lock.acquire(); @@ -189,12 +167,10 @@ make_directory(const Filename &file) { return (f != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::is_directory -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * directory. + */ bool VirtualFileMountRamdisk:: is_directory(const Filename &file) const { _lock.acquire(); @@ -203,12 +179,10 @@ is_directory(const Filename &file) const { return (f != NULL && f->is_directory()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::is_regular_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * regular file. + */ bool VirtualFileMountRamdisk:: is_regular_file(const Filename &file) const { _lock.acquire(); @@ -217,25 +191,20 @@ is_regular_file(const Filename &file) const { return (f != NULL && !f->is_directory()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::is_writable -// Access: Public, Virtual -// Description: Returns true if the named file or directory may be -// written to, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named file or directory may be written to, false + * otherwise. + */ bool VirtualFileMountRamdisk:: is_writable(const Filename &file) const { return has_file(file); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::open_read_file -// Access: Public, Virtual -// Description: Opens the file for reading, if it exists. Returns a -// newly allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading, if it exists. Returns a newly allocated + * istream on success (which you should eventually delete when you are done + * reading). Returns NULL on failure. + */ istream *VirtualFileMountRamdisk:: open_read_file(const Filename &file) const { _lock.acquire(); @@ -249,14 +218,11 @@ open_read_file(const Filename &file) const { return new ISubStream(&f2->_wrapper, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::open_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ ostream *VirtualFileMountRamdisk:: open_write_file(const Filename &file, bool truncate) { _lock.acquire(); @@ -275,14 +241,11 @@ open_write_file(const Filename &file, bool truncate) { return new OSubStream(&f->_wrapper, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::open_append_file -// Access: Published -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFileMountRamdisk:: open_append_file(const Filename &file) { _lock.acquire(); @@ -295,14 +258,11 @@ open_append_file(const Filename &file) { return new OSubStream(&f->_wrapper, 0, 0, true); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::open_read_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated iostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated iostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ iostream *VirtualFileMountRamdisk:: open_read_write_file(const Filename &file, bool truncate) { _lock.acquire(); @@ -321,14 +281,11 @@ open_read_write_file(const Filename &file, bool truncate) { return new SubStream(&f->_wrapper, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::open_read_append_file -// Access: Published, Virtual -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFileMountRamdisk:: open_read_append_file(const Filename &file) { _lock.acquire(); @@ -342,15 +299,11 @@ open_read_append_file(const Filename &file) { return new SubStream(&f2->_wrapper, 0, 0, true); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file, istream *stream) const { _lock.acquire(); @@ -364,12 +317,10 @@ get_file_size(const Filename &file, istream *stream) const { return f2->_data.str().length(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileMountRamdisk:: get_file_size(const Filename &file) const { _lock.acquire(); @@ -383,20 +334,16 @@ get_file_size(const Filename &file) const { return f2->_data.str().length(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileMountRamdisk:: get_timestamp(const Filename &file) const { _lock.acquire(); @@ -410,14 +357,11 @@ get_timestamp(const Filename &file) const { return timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::scan_directory -// Access: Public, Virtual -// Description: Fills the given vector up with the list of filenames -// that are local to this directory, if the filename is -// a directory. Returns true if successful, or false if -// the file is not a directory or cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of filenames that are local to this + * directory, if the filename is a directory. Returns true if successful, or + * false if the file is not a directory or cannot be read. + */ bool VirtualFileMountRamdisk:: scan_directory(vector_string &contents, const Filename &dir) const { _lock.acquire(); @@ -434,14 +378,12 @@ scan_directory(vector_string &contents, const Filename &dir) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::atomic_compare_and_exchange_contents -// Access: Public, Virtual -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFileMountRamdisk:: atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, - const string &old_contents, + const string &old_contents, const string &new_contents) { _lock.acquire(); PT(FileBase) f = _root.do_find_file(file); @@ -463,11 +405,9 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents return retval; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::atomic_read_contents -// Access: Public, Virtual -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFileMountRamdisk:: atomic_read_contents(const Filename &file, string &contents) const { _lock.acquire(); @@ -485,51 +425,41 @@ atomic_read_contents(const Filename &file, string &contents) const { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMountRamdisk:: output(ostream &out) const { out << "VirtualFileMountRamdisk"; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::FileBase::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileMountRamdisk::FileBase:: ~FileBase() { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::FileBase::is_directory -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool VirtualFileMountRamdisk::FileBase:: is_directory() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::is_directory -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool VirtualFileMountRamdisk::Directory:: is_directory() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::do_find_file -// Access: Public -// Description: Recursively search for the file with the indicated -// name in this directory hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Recursively search for the file with the indicated name in this directory + * hierarchy. + */ PT(VirtualFileMountRamdisk::FileBase) VirtualFileMountRamdisk::Directory:: do_find_file(const string &filename) const { size_t slash = filename.find('/'); @@ -560,13 +490,10 @@ do_find_file(const string &filename) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::do_create_file -// Access: Public -// Description: Recursively search for the file with the indicated -// name in this directory hierarchy. If not found, -// creates a new file. -//////////////////////////////////////////////////////////////////// +/** + * Recursively search for the file with the indicated name in this directory + * hierarchy. If not found, creates a new file. + */ PT(VirtualFileMountRamdisk::File) VirtualFileMountRamdisk::Directory:: do_create_file(const string &filename) { size_t slash = filename.find('/'); @@ -611,13 +538,10 @@ do_create_file(const string &filename) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::do_make_directory -// Access: Public -// Description: Recursively search for the file with the indicated -// name in this directory hierarchy. If not found, -// creates a new directory. -//////////////////////////////////////////////////////////////////// +/** + * Recursively search for the file with the indicated name in this directory + * hierarchy. If not found, creates a new directory. + */ PT(VirtualFileMountRamdisk::Directory) VirtualFileMountRamdisk::Directory:: do_make_directory(const string &filename) { size_t slash = filename.find('/'); @@ -662,13 +586,10 @@ do_make_directory(const string &filename) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::do_delete_file -// Access: Public -// Description: Recursively search for the file with the indicated -// name in this directory hierarchy, and removes it. -// Returns the removed FileBase object. -//////////////////////////////////////////////////////////////////// +/** + * Recursively search for the file with the indicated name in this directory + * hierarchy, and removes it. Returns the removed FileBase object. + */ PT(VirtualFileMountRamdisk::FileBase) VirtualFileMountRamdisk::Directory:: do_delete_file(const string &filename) { size_t slash = filename.find('/'); @@ -709,11 +630,9 @@ do_delete_file(const string &filename) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountRamdisk::Directory::do_scan_directory -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool VirtualFileMountRamdisk::Directory:: do_scan_directory(vector_string &contents) const { Files::const_iterator fi; diff --git a/panda/src/express/virtualFileMountRamdisk.h b/panda/src/express/virtualFileMountRamdisk.h index d4646ebde2..9812746534 100644 --- a/panda/src/express/virtualFileMountRamdisk.h +++ b/panda/src/express/virtualFileMountRamdisk.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMountRamdisk.h -// Created by: drose (19Sep11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountRamdisk.h + * @author drose + * @date 2011-09-19 + */ #ifndef VIRTUALFILEMOUNTRAMDISK_H #define VIRTUALFILEMOUNTRAMDISK_H @@ -21,16 +20,13 @@ #include "mutexImpl.h" #include "streamWrapper.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMountRamdisk -// Description : Simulates an actual directory on disk with in-memory -// storage. This is useful mainly for performing high -// level functions that expect disk I/O without actually -// writing files to disk. Naturally, there are -// significant limits to the size of the files that may -// be written with this system; and "files" written here -// are not automatically persistent between sessions. -//////////////////////////////////////////////////////////////////// +/** + * Simulates an actual directory on disk with in-memory storage. This is + * useful mainly for performing high level functions that expect disk I/O + * without actually writing files to disk. Naturally, there are significant + * limits to the size of the files that may be written with this system; and + * "files" written here are not automatically persistent between sessions. + */ class EXPCL_PANDAEXPRESS VirtualFileMountRamdisk : public VirtualFileMount { PUBLISHED: VirtualFileMountRamdisk(); @@ -56,7 +52,7 @@ public: virtual streamsize get_file_size(const Filename &file) const; virtual time_t get_timestamp(const Filename &file) const; - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const; virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); diff --git a/panda/src/express/virtualFileMountSystem.I b/panda/src/express/virtualFileMountSystem.I index 7ada742341..c89b6e978d 100644 --- a/panda/src/express/virtualFileMountSystem.I +++ b/panda/src/express/virtualFileMountSystem.I @@ -1,35 +1,29 @@ -// Filename: virtualFileMountSystem.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountSystem.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileMountSystem:: VirtualFileMountSystem(const Filename &physical_filename) : _physical_filename(physical_filename) { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::get_physical_filename -// Access: Public -// Description: Returns the name of the source file on the OS -// filesystem of the directory or file that is mounted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the source file on the OS filesystem of the directory + * or file that is mounted. + */ INLINE const Filename &VirtualFileMountSystem:: get_physical_filename() const { return _physical_filename; diff --git a/panda/src/express/virtualFileMountSystem.cxx b/panda/src/express/virtualFileMountSystem.cxx index 2ffe85b166..ce201712b2 100644 --- a/panda/src/express/virtualFileMountSystem.cxx +++ b/panda/src/express/virtualFileMountSystem.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileMountSystem.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountSystem.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileMountSystem.h" #include "virtualFileSystem.h" @@ -18,12 +17,9 @@ TypeHandle VirtualFileMountSystem::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::has_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system. + */ bool VirtualFileMountSystem:: has_file(const Filename &file) const { Filename pathname(_physical_filename, file); @@ -44,14 +40,11 @@ has_file(const Filename &file) const { return pathname.exists(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::create_file -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success (or if the file already exists), or false if -// it cannot be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success (or if the file already exists), or + * false if it cannot be created. + */ bool VirtualFileMountSystem:: create_file(const Filename &file) { Filename pathname(_physical_filename, file); @@ -60,30 +53,23 @@ create_file(const Filename &file) { return pathname.open_write(stream, false); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::delete_file -// Access: Public, Virtual -// Description: Attempts to delete the indicated file or directory -// within the mount. This can remove a single file or -// an empty directory. It will not remove a nonempty -// directory. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete the indicated file or directory within the mount. This + * can remove a single file or an empty directory. It will not remove a + * nonempty directory. Returns true on success, false on failure. + */ bool VirtualFileMountSystem:: delete_file(const Filename &file) { Filename pathname(_physical_filename, file); return pathname.unlink() || pathname.rmdir(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::rename_file -// Access: Public -// Description: Attempts to rename the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, this will be -// attempted again with a copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to rename the contents of the indicated file to the indicated + * file. Both filenames will be within the mount. Returns true on success, + * false on failure. If this returns false, this will be attempted again with + * a copy-and-delete operation. + */ bool VirtualFileMountSystem:: rename_file(const Filename &orig_filename, const Filename &new_filename) { Filename orig_pathname(_physical_filename, orig_filename); @@ -91,15 +77,12 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { return orig_pathname.rename_to(new_pathname); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::copy_file -// Access: Public -// Description: Attempts to copy the contents of the indicated file -// to the indicated file. Both filenames will be within -// the mount. Returns true on success, false on -// failure. If this returns false, the copy will be -// performed by explicit read-and-write operations. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of the indicated file to the indicated file. + * Both filenames will be within the mount. Returns true on success, false on + * failure. If this returns false, the copy will be performed by explicit + * read-and-write operations. + */ bool VirtualFileMountSystem:: copy_file(const Filename &orig_filename, const Filename &new_filename) { Filename orig_pathname(_physical_filename, orig_filename); @@ -107,27 +90,22 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { return orig_pathname.copy_to(new_pathname); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::make_directory -// Access: Public, Virtual -// Description: Attempts to create the indicated file within the -// mount, if it does not already exist. Returns true on -// success, or false if it cannot be created. If the -// directory already existed prior to this call, may -// return either true or false. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create the indicated file within the mount, if it does not + * already exist. Returns true on success, or false if it cannot be created. + * If the directory already existed prior to this call, may return either true + * or false. + */ bool VirtualFileMountSystem:: make_directory(const Filename &file) { Filename pathname(_physical_filename, file); return pathname.mkdir(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::is_directory -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * directory. + */ bool VirtualFileMountSystem:: is_directory(const Filename &file) const { #ifdef WIN32 @@ -142,12 +120,10 @@ is_directory(const Filename &file) const { return pathname.is_directory(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::is_regular_file -// Access: Public, Virtual -// Description: Returns true if the indicated file exists within the -// mount system and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated file exists within the mount system and is a + * regular file. + */ bool VirtualFileMountSystem:: is_regular_file(const Filename &file) const { #ifdef WIN32 @@ -162,12 +138,10 @@ is_regular_file(const Filename &file) const { return pathname.is_regular_file(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::is_writable -// Access: Public, Virtual -// Description: Returns true if the named file or directory may be -// written to, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named file or directory may be written to, false + * otherwise. + */ bool VirtualFileMountSystem:: is_writable(const Filename &file) const { #ifdef WIN32 @@ -182,14 +156,11 @@ is_writable(const Filename &file) const { return pathname.is_writable(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::open_read_file -// Access: Public, Virtual -// Description: Opens the file for reading, if it exists. Returns a -// newly allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading, if it exists. Returns a newly allocated + * istream on success (which you should eventually delete when you are done + * reading). Returns NULL on failure. + */ istream *VirtualFileMountSystem:: open_read_file(const Filename &file) const { #ifdef WIN32 @@ -211,14 +182,11 @@ open_read_file(const Filename &file) const { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::open_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ ostream *VirtualFileMountSystem:: open_write_file(const Filename &file, bool truncate) { #ifdef WIN32 @@ -240,14 +208,11 @@ open_write_file(const Filename &file, bool truncate) { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::open_append_file -// Access: Published -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFileMountSystem:: open_append_file(const Filename &file) { #ifdef WIN32 @@ -269,14 +234,11 @@ open_append_file(const Filename &file) { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::open_read_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated iostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated iostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ iostream *VirtualFileMountSystem:: open_read_write_file(const Filename &file, bool truncate) { #ifdef WIN32 @@ -298,14 +260,11 @@ open_read_write_file(const Filename &file, bool truncate) { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::open_read_append_file -// Access: Published, Virtual -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFileMountSystem:: open_read_append_file(const Filename &file) { #ifdef WIN32 @@ -327,15 +286,11 @@ open_read_append_file(const Filename &file) { return stream; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileMountSystem:: get_file_size(const Filename &file, istream *stream) const { // First, save the original stream position. @@ -359,48 +314,39 @@ get_file_size(const Filename &file, istream *stream) const { return size; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileMountSystem:: get_file_size(const Filename &file) const { Filename pathname(_physical_filename, file); return pathname.get_file_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileMountSystem:: get_timestamp(const Filename &file) const { Filename pathname(_physical_filename, file); return pathname.get_timestamp(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::get_system_info -// Access: Public, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it does not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it does + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFileMountSystem:: get_system_info(const Filename &file, SubfileInfo &info) { Filename pathname(_physical_filename, file); @@ -408,14 +354,11 @@ get_system_info(const Filename &file, SubfileInfo &info) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::scan_directory -// Access: Public, Virtual -// Description: Fills the given vector up with the list of filenames -// that are local to this directory, if the filename is -// a directory. Returns true if successful, or false if -// the file is not a directory or cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of filenames that are local to this + * directory, if the filename is a directory. Returns true if successful, or + * false if the file is not a directory or cannot be read. + */ bool VirtualFileMountSystem:: scan_directory(vector_string &contents, const Filename &dir) const { #ifdef WIN32 @@ -431,14 +374,12 @@ scan_directory(vector_string &contents, const Filename &dir) const { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::atomic_compare_and_exchange_contents -// Access: Public, Virtual -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFileMountSystem:: atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, - const string &old_contents, + const string &old_contents, const string &new_contents) { #ifdef WIN32 // First ensure that the file exists to validate its case. @@ -452,11 +393,9 @@ atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents return pathname.atomic_compare_and_exchange_contents(orig_contents, old_contents, new_contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::atomic_read_contents -// Access: Public, Virtual -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFileMountSystem:: atomic_read_contents(const Filename &file, string &contents) const { #ifdef WIN32 @@ -471,11 +410,9 @@ atomic_read_contents(const Filename &file, string &contents) const { return pathname.atomic_read_contents(contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileMountSystem::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VirtualFileMountSystem:: output(ostream &out) const { out << get_physical_filename(); diff --git a/panda/src/express/virtualFileMountSystem.h b/panda/src/express/virtualFileMountSystem.h index f6a8a0226d..2854c32ae0 100644 --- a/panda/src/express/virtualFileMountSystem.h +++ b/panda/src/express/virtualFileMountSystem.h @@ -1,16 +1,15 @@ -// Filename: virtualFileMountSystem.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileMountSystem.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILEMOUNTSYSTEM_H #define VIRTUALFILEMOUNTSYSTEM_H @@ -19,11 +18,9 @@ #include "virtualFileMount.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileMountSystem -// Description : Maps an actual OS directory into the -// VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Maps an actual OS directory into the VirtualFileSystem. + */ class EXPCL_PANDAEXPRESS VirtualFileMountSystem : public VirtualFileMount { PUBLISHED: INLINE VirtualFileMountSystem(const Filename &physical_filename); @@ -52,7 +49,7 @@ public: virtual time_t get_timestamp(const Filename &file) const; virtual bool get_system_info(const Filename &file, SubfileInfo &info); - virtual bool scan_directory(vector_string &contents, + virtual bool scan_directory(vector_string &contents, const Filename &dir) const; virtual bool atomic_compare_and_exchange_contents(const Filename &file, string &orig_contents, const string &old_contents, const string &new_contents); diff --git a/panda/src/express/virtualFileSimple.I b/panda/src/express/virtualFileSimple.I index 2bcef4ead3..dcdd7cec90 100644 --- a/panda/src/express/virtualFileSimple.I +++ b/panda/src/express/virtualFileSimple.I @@ -1,23 +1,19 @@ -// Filename: virtualFileSimple.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSimple.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VirtualFileSimple:: VirtualFileSimple(VirtualFileMount *mount, const Filename &local_filename, bool implicit_pz_file, int open_flags) : @@ -28,24 +24,19 @@ VirtualFileSimple(VirtualFileMount *mount, const Filename &local_filename, { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_mount -// Access: Published, Virtual -// Description: Returns the VirtualFileMount this file is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFileMount this file is associated with. + */ INLINE VirtualFileMount *VirtualFileSimple:: get_mount() const { return _mount; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::is_implicit_pz_file -// Access: Published -// Description: Returns true if this file is a .pz file that should -// be implicitly decompressed on load, or false if it is -// not a .pz file or if it should not be decompressed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file is a .pz file that should be implicitly + * decompressed on load, or false if it is not a .pz file or if it should not + * be decompressed. + */ INLINE bool VirtualFileSimple:: is_implicit_pz_file() const { return _implicit_pz_file; diff --git a/panda/src/express/virtualFileSimple.cxx b/panda/src/express/virtualFileSimple.cxx index 330b73e30f..a900dd514f 100644 --- a/panda/src/express/virtualFileSimple.cxx +++ b/panda/src/express/virtualFileSimple.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileSimple.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSimple.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileSimple.h" #include "virtualFileMount.h" @@ -20,23 +19,17 @@ TypeHandle VirtualFileSimple::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_file_system -// Access: Published, Virtual -// Description: Returns the VirtualFileSystem this file is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFileSystem this file is associated with. + */ VirtualFileSystem *VirtualFileSimple:: get_file_system() const { return _mount->get_file_system(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_filename -// Access: Published, Virtual -// Description: Returns the full pathname to this file within the -// virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to this file within the virtual file system. + */ Filename VirtualFileSimple:: get_filename() const { string mount_point = _mount->get_mount_point(); @@ -56,80 +49,62 @@ get_filename() const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::has_file -// Access: Published, Virtual -// Description: Returns true if this file exists, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file exists, false otherwise. + */ bool VirtualFileSimple:: has_file() const { return _mount->has_file(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::is_directory -// Access: Published, Virtual -// Description: Returns true if this file represents a directory (and -// scan_directory() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a directory (and scan_directory() may + * be called), false otherwise. + */ bool VirtualFileSimple:: is_directory() const { return _mount->is_directory(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::is_regular_file -// Access: Published, Virtual -// Description: Returns true if this file represents a regular file -// (and read_file() may be called), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a regular file (and read_file() may be + * called), false otherwise. + */ bool VirtualFileSimple:: is_regular_file() const { return _mount->is_regular_file(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::is_writable -// Access: Published, Virtual -// Description: Returns true if this file represents a writable -// regular file (and write_file() may be called), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file represents a writable regular file (and + * write_file() may be called), false otherwise. + */ bool VirtualFileSimple:: is_writable() const { return _mount->is_writable(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::delete_file -// Access: Public -// Description: Attempts to delete this file or directory. This can -// remove a single file or an empty directory. It will -// not remove a nonempty directory. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete this file or directory. This can remove a single file + * or an empty directory. It will not remove a nonempty directory. Returns + * true on success, false on failure. + */ bool VirtualFileSimple:: delete_file() { return _mount->delete_file(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::rename_file -// Access: Public -// Description: Attempts to move or rename this file or directory. -// If the original file is an ordinary file, it will -// quietly replace any already-existing file in the new -// filename (but not a directory). If the original file -// is a directory, the new filename must not already -// exist. -// -// If the file is a directory, the new filename must be -// within the same mount point. If the file is an -// ordinary file, the new filename may be anywhere; but -// if it is not within the same mount point then the -// rename operation is automatically performed as a -// two-step copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to move or rename this file or directory. If the original file is + * an ordinary file, it will quietly replace any already-existing file in the + * new filename (but not a directory). If the original file is a directory, + * the new filename must not already exist. + * + * If the file is a directory, the new filename must be within the same mount + * point. If the file is an ordinary file, the new filename may be anywhere; + * but if it is not within the same mount point then the rename operation is + * automatically performed as a two-step copy-and-delete operation. + */ bool VirtualFileSimple:: rename_file(VirtualFile *new_file) { if (new_file->is_of_type(VirtualFileSimple::get_class_type())) { @@ -142,8 +117,8 @@ rename_file(VirtualFile *new_file) { } } - // Different mount point, or the mount doesn't support renaming. Do - // it by hand. + // Different mount point, or the mount doesn't support renaming. Do it by + // hand. if (is_regular_file() && !new_file->is_directory()) { // copy-and-delete. new_file->delete_file(); @@ -156,13 +131,10 @@ rename_file(VirtualFile *new_file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::copy_file -// Access: Public -// Description: Attempts to copy the contents of this file to the -// indicated file. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of this file to the indicated file. Returns + * true on success, false on failure. + */ bool VirtualFileSimple:: copy_file(VirtualFile *new_file) { if (new_file->is_of_type(VirtualFileSimple::get_class_type())) { @@ -175,14 +147,14 @@ copy_file(VirtualFile *new_file) { } } - // Different mount point, or the mount doesn't support copying. Do - // it by hand. + // Different mount point, or the mount doesn't support copying. Do it by + // hand. ostream *out = new_file->open_write_file(false, true); istream *in = open_read_file(false); static const size_t buffer_size = 4096; char buffer[buffer_size]; - + in->read(buffer, buffer_size); size_t count = in->gcount(); while (count != 0) { @@ -209,20 +181,16 @@ copy_file(VirtualFile *new_file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::open_read_file -// Access: Published, Virtual -// Description: Opens the file for reading. Returns a newly -// allocated istream on success (which you should -// eventually delete when you are done reading). -// Returns NULL on failure. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for reading. Returns a newly allocated istream on success + * (which you should eventually delete when you are done reading). Returns + * NULL on failure. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ istream *VirtualFileSimple:: open_read_file(bool auto_unwrap) const { @@ -238,33 +206,26 @@ open_read_file(bool auto_unwrap) const { return _mount->open_read_file(local_filename, do_uncompress); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::close_read_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_read_file(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_file(). This really + * just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSimple:: close_read_file(istream *stream) const { _mount->close_read_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::open_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated ostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -// -// If auto_wrap is true, an explicitly-named .pz file is -// automatically compressed while writing. If truncate -// is true, the file is truncated to zero length before -// writing. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated ostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + * + * If auto_wrap is true, an explicitly-named .pz file is automatically + * compressed while writing. If truncate is true, the file is truncated to + * zero length before writing. + */ ostream *VirtualFileSimple:: open_write_file(bool auto_wrap, bool truncate) { // Will we be automatically wrapping a .pz file? @@ -279,161 +240,126 @@ open_write_file(bool auto_wrap, bool truncate) { return _mount->open_write_file(local_filename, do_compress, truncate); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::open_append_file -// Access: Published, Virtual -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFileSimple:: open_append_file() { return _mount->open_append_file(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::close_write_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_write_file(). This really just deletes the -// ostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_write_file(). This really + * just deletes the ostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSimple:: close_write_file(ostream *stream) { _mount->close_write_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::open_read_write_file -// Access: Published, Virtual -// Description: Opens the file for writing. Returns a newly -// allocated iostream on success (which you should -// eventually delete when you are done writing). -// Returns NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the file for writing. Returns a newly allocated iostream on success + * (which you should eventually delete when you are done writing). Returns + * NULL on failure. + */ iostream *VirtualFileSimple:: open_read_write_file(bool truncate) { return _mount->open_read_write_file(_local_filename, truncate); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::open_read_append_file -// Access: Published, Virtual -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFileSimple:: open_read_append_file() { return _mount->open_read_append_file(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::close_read_write_file -// Access: Published -// Description: Closes a file opened by a previous call to -// open_read_write_file(). This really just deletes the -// iostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_write_file(). This + * really just deletes the iostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSimple:: close_read_write_file(iostream *stream) { _mount->close_read_write_file(stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the already-open file. Pass in the stream that -// was returned by open_read_file(); some -// implementations may require this stream to determine -// the size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the already-open + * file. Pass in the stream that was returned by open_read_file(); some + * implementations may require this stream to determine the size. + */ streamsize VirtualFileSimple:: get_file_size(istream *stream) const { return _mount->get_file_size(_local_filename, stream); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_file_size -// Access: Published, Virtual -// Description: Returns the current size on disk (or wherever it is) -// of the file before it has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current size on disk (or wherever it is) of the file before it + * has been opened. + */ streamsize VirtualFileSimple:: get_file_size() const { return _mount->get_file_size(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_timestamp -// Access: Published, Virtual -// Description: Returns a time_t value that represents the time the -// file was last modified, to within whatever precision -// the operating system records this information (on a -// Windows95 system, for instance, this may only be -// accurate to within 2 seconds). -// -// If the timestamp cannot be determined, either because -// it is not supported by the operating system or -// because there is some error (such as file not found), -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a time_t value that represents the time the file was last modified, + * to within whatever precision the operating system records this information + * (on a Windows95 system, for instance, this may only be accurate to within 2 + * seconds). + * + * If the timestamp cannot be determined, either because it is not supported + * by the operating system or because there is some error (such as file not + * found), returns 0. + */ time_t VirtualFileSimple:: get_timestamp() const { return _mount->get_timestamp(_local_filename); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::get_system_info -// Access: Published, Virtual -// Description: Populates the SubfileInfo structure with the data -// representing where the file actually resides on disk, -// if this is knowable. Returns true if the file might -// reside on disk, and the info is populated, or false -// if it does not (or it is not known where the file -// resides), in which case the info is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Populates the SubfileInfo structure with the data representing where the + * file actually resides on disk, if this is knowable. Returns true if the + * file might reside on disk, and the info is populated, or false if it does + * not (or it is not known where the file resides), in which case the info is + * meaningless. + */ bool VirtualFileSimple:: get_system_info(SubfileInfo &info) { return _mount->get_system_info(_local_filename, info); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::atomic_compare_and_exchange_contents -// Access: Public, Virtual -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFileSimple:: atomic_compare_and_exchange_contents(string &orig_contents, - const string &old_contents, + const string &old_contents, const string &new_contents) { return _mount->atomic_compare_and_exchange_contents(_local_filename, orig_contents, old_contents, new_contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::atomic_read_contents -// Access: Public, Virtual -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFileSimple:: atomic_read_contents(string &contents) const { return _mount->atomic_read_contents(_local_filename, contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::read_file -// Access: Public, Virtual -// Description: Fills up the indicated pvector with the contents of -// the file, if it is a regular file. Returns true on -// success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated pvector with the contents of the file, if it is a + * regular file. Returns true on success, false otherwise. + */ bool VirtualFileSimple:: read_file(pvector &result, bool auto_unwrap) const { @@ -449,12 +375,10 @@ read_file(pvector &result, bool auto_unwrap) const { return _mount->read_file(local_filename, do_uncompress, result); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::write_file -// Access: Public, Virtual -// Description: Writes the indicated data to the file, if it is -// writable. Returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated data to the file, if it is writable. Returns true on + * success, false otherwise. + */ bool VirtualFileSimple:: write_file(const unsigned char *data, size_t data_size, bool auto_wrap) { // Will we be automatically wrapping a .pz file? @@ -469,29 +393,26 @@ write_file(const unsigned char *data, size_t data_size, bool auto_wrap) { return _mount->write_file(local_filename, do_compress, data, data_size); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSimple::scan_local_directory -// Access: Protected, Virtual -// Description: Fills file_list up with the list of files that are -// within this directory, excluding those whose -// basenames are listed in mount_points. Returns true -// if successful, false if the file is not a directory -// or the directory cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Fills file_list up with the list of files that are within this directory, + * excluding those whose basenames are listed in mount_points. Returns true + * if successful, false if the file is not a directory or the directory cannot + * be read. + */ bool VirtualFileSimple:: -scan_local_directory(VirtualFileList *file_list, +scan_local_directory(VirtualFileList *file_list, const ov_set &mount_points) const { vector_string names; if (!_mount->scan_directory(names, _local_filename)) { return false; } - // Now the scan above gave us a list of basenames. Turn these back - // into VirtualFile pointers. + // Now the scan above gave us a list of basenames. Turn these back into + // VirtualFile pointers. - // Each of the files returned by the mount will be just a simple - // file within the same mount tree, unless it is shadowed by a - // mount point listed in mount_points. + // Each of the files returned by the mount will be just a simple file within + // the same mount tree, unless it is shadowed by a mount point listed in + // mount_points. vector_string::const_iterator ni; for (ni = names.begin(); ni != names.end(); ++ni) { @@ -502,6 +423,6 @@ scan_local_directory(VirtualFileList *file_list, file_list->add_file(file); } } - + return true; } diff --git a/panda/src/express/virtualFileSimple.h b/panda/src/express/virtualFileSimple.h index 46fd6a7de9..917898791e 100644 --- a/panda/src/express/virtualFileSimple.h +++ b/panda/src/express/virtualFileSimple.h @@ -1,16 +1,15 @@ -// Filename: virtualFileSimple.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSimple.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILESIMPLE_H #define VIRTUALFILESIMPLE_H @@ -19,13 +18,11 @@ #include "virtualFile.h" -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileSimple -// Description : A simple file or directory within the -// VirtualFileSystem: this maps to exactly one file on -// one mount point. Most directories, and all regular -// files, are of this kind. -//////////////////////////////////////////////////////////////////// +/** + * A simple file or directory within the VirtualFileSystem: this maps to + * exactly one file on one mount point. Most directories, and all regular + * files, are of this kind. + */ class EXPCL_PANDAEXPRESS VirtualFileSimple : public VirtualFile { public: INLINE VirtualFileSimple(VirtualFileMount *mount, @@ -70,7 +67,7 @@ public: virtual bool write_file(const unsigned char *data, size_t data_size, bool auto_wrap); protected: - virtual bool scan_local_directory(VirtualFileList *file_list, + virtual bool scan_local_directory(VirtualFileList *file_list, const ov_set &mount_points) const; private: diff --git a/panda/src/express/virtualFileSystem.I b/panda/src/express/virtualFileSystem.I index 4ef2d94ca3..53b259c821 100644 --- a/panda/src/express/virtualFileSystem.I +++ b/panda/src/express/virtualFileSystem.I @@ -1,78 +1,63 @@ -// Filename: virtualFileSystem.I -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSystem.I + * @author drose + * @date 2002-08-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::exists -// Access: Published -// Description: Convenience function; returns true if the named file -// exists. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns true if the named file exists. + */ INLINE bool VirtualFileSystem:: exists(const Filename &filename) const { return get_file(filename, true) != (VirtualFile *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::is_directory -// Access: Published -// Description: Convenience function; returns true if the named file -// exists and is a directory. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns true if the named file exists and is a + * directory. + */ INLINE bool VirtualFileSystem:: is_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); return (file != (VirtualFile *)NULL && file->is_directory()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::is_regular_file -// Access: Published -// Description: Convenience function; returns true if the named file -// exists and is a regular file. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns true if the named file exists and is a + * regular file. + */ INLINE bool VirtualFileSystem:: is_regular_file(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); return (file != (VirtualFile *)NULL && file->is_regular_file()); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::scan_directory -// Access: Published -// Description: If the file represents a directory (that is, -// is_directory() returns true), this returns the list -// of files within the directory at the current time. -// Returns NULL if the file is not a directory or if the -// directory cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * If the file represents a directory (that is, is_directory() returns true), + * this returns the list of files within the directory at the current time. + * Returns NULL if the file is not a directory or if the directory cannot be + * read. + */ INLINE PT(VirtualFileList) VirtualFileSystem:: scan_directory(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); if (file == (VirtualFile *)NULL) { return NULL; } - + return file->scan_directory(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::ls -// Access: Published -// Description: Convenience function; lists the files within the -// indicated directory. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; lists the files within the indicated directory. + */ INLINE void VirtualFileSystem:: ls(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); @@ -84,13 +69,10 @@ ls(const Filename &filename) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::ls_all -// Access: Published -// Description: Convenience function; lists the files within the -// indicated directory, and all files below, -// recursively. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; lists the files within the indicated directory, and + * all files below, recursively. + */ INLINE void VirtualFileSystem:: ls_all(const Filename &filename) const { PT(VirtualFile) file = get_file(filename, true); @@ -102,18 +84,15 @@ ls_all(const Filename &filename) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::read_file -// Access: Published -// Description: Convenience function; returns the entire contents of -// the indicated file as a string. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns the entire contents of the indicated file as + * a string. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ INLINE string VirtualFileSystem:: read_file(const Filename &filename, bool auto_unwrap) const { string result; @@ -122,67 +101,57 @@ read_file(const Filename &filename, bool auto_unwrap) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::write_file -// Access: Published -// Description: Convenience function; writes the entire contents of -// the indicated file as a string. -// -// If auto_wrap is true, an explicitly-named .pz file -// is automatically compressed while writing. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; writes the entire contents of the indicated file as a + * string. + * + * If auto_wrap is true, an explicitly-named .pz file is automatically + * compressed while writing. + */ INLINE bool VirtualFileSystem:: write_file(const Filename &filename, const string &data, bool auto_wrap) { return write_file(filename, (const unsigned char *)data.data(), data.size(), auto_wrap); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::read_file -// Access: Public -// Description: Convenience function; fills the string up with the -// data from the indicated file, if it exists and can be -// read. Returns true on success, false otherwise. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; fills the string up with the data from the indicated + * file, if it exists and can be read. Returns true on success, false + * otherwise. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ INLINE bool VirtualFileSystem:: read_file(const Filename &filename, string &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::read_file -// Access: Public -// Description: Convenience function; fills the pvector up with the -// data from the indicated file, if it exists and can be -// read. Returns true on success, false otherwise. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; fills the pvector up with the data from the indicated + * file, if it exists and can be read. Returns true on success, false + * otherwise. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ INLINE bool VirtualFileSystem:: read_file(const Filename &filename, pvector &result, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); return (file != (VirtualFile *)NULL && file->read_file(result, auto_unwrap)); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::write_file -// Access: Public -// Description: Convenience function; writes the entire contents of -// the indicated file as a block of data. -// -// If auto_wrap is true, an explicitly-named .pz file -// is automatically compressed while writing. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; writes the entire contents of the indicated file as a + * block of data. + * + * If auto_wrap is true, an explicitly-named .pz file is automatically + * compressed while writing. + */ INLINE bool VirtualFileSystem:: write_file(const Filename &filename, const unsigned char *data, size_t data_size, bool auto_wrap) { PT(VirtualFile) file = create_file(filename); diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 746d2fd018..c331dd1055 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -1,16 +1,15 @@ -// Filename: virtualFileSystem.cxx -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSystem.cxx + * @author drose + * @date 2002-08-03 + */ #include "virtualFileSystem.h" #include "virtualFileSimple.h" @@ -29,11 +28,9 @@ VirtualFileSystem *VirtualFileSystem::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileSystem:: VirtualFileSystem() : vfs_case_sensitive @@ -71,22 +68,17 @@ VirtualFileSystem() : _mount_seq = 0; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VirtualFileSystem:: ~VirtualFileSystem() { unmount_all(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::mount -// Access: Published -// Description: Mounts the indicated Multifile at the given mount -// point. -//////////////////////////////////////////////////////////////////// +/** + * Mounts the indicated Multifile at the given mount point. + */ bool VirtualFileSystem:: mount(Multifile *multifile, const Filename &mount_point, int flags) { PT(VirtualFileMountMultifile) new_mount = @@ -94,33 +86,26 @@ mount(Multifile *multifile, const Filename &mount_point, int flags) { return mount(new_mount, mount_point, flags); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::mount -// Access: Published -// Description: Mounts the indicated system file or directory at the -// given mount point. If the named file is a directory, -// mounts the directory. If the named file is a -// Multifile, mounts it as a Multifile. Returns true on -// success, false on failure. -// -// A given system directory may be mounted to multiple -// different mount point, and the same mount point may -// share multiple system directories. In the case of -// ambiguities (that is, two different files with -// exactly the same full pathname), the most-recently -// mounted system wins. -// -// The filename specified as the first parameter must -// refer to a real, physical filename on disk; it cannot -// be a virtual file already appearing within the vfs -// filespace. However, it is possible to mount such a -// file; see mount_loop() for this. -// -// Note that a mounted VirtualFileSystem directory is -// fully case-sensitive, unlike the native Windows file -// system, so you must refer to files within the virtual -// file system with exactly the right case. -//////////////////////////////////////////////////////////////////// +/** + * Mounts the indicated system file or directory at the given mount point. If + * the named file is a directory, mounts the directory. If the named file is + * a Multifile, mounts it as a Multifile. Returns true on success, false on + * failure. + * + * A given system directory may be mounted to multiple different mount point, + * and the same mount point may share multiple system directories. In the + * case of ambiguities (that is, two different files with exactly the same + * full pathname), the most-recently mounted system wins. + * + * The filename specified as the first parameter must refer to a real, + * physical filename on disk; it cannot be a virtual file already appearing + * within the vfs filespace. However, it is possible to mount such a file; + * see mount_loop() for this. + * + * Note that a mounted VirtualFileSystem directory is fully case-sensitive, + * unlike the native Windows file system, so you must refer to files within + * the virtual file system with exactly the right case. + */ bool VirtualFileSystem:: mount(const Filename &physical_filename, const Filename &mount_point, int flags, const string &password) { @@ -139,8 +124,8 @@ mount(const Filename &physical_filename, const Filename &mount_point, PT(Multifile) multifile = new Multifile; multifile->set_encryption_password(password); - // For now these are always opened read only. Maybe later we'll - // support read-write on Multifiles. + // For now these are always opened read only. Maybe later we'll support + // read-write on Multifiles. flags |= MF_read_only; if (!multifile->open_read(physical_filename)) { return false; @@ -150,24 +135,18 @@ mount(const Filename &physical_filename, const Filename &mount_point, } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::mount_loop -// Access: Published -// Description: This is similar to mount(), but it receives the name -// of a Multifile that already appears within the -// virtual file system. It can be used to mount a -// Multifile that is itself hosted within a -// virtually-mounted Multifile. -// -// This interface can also be used to mount physical -// files (that appear within the virtual filespace), but -// it cannot be used to mount directories. Use mount() -// if you need to mount a directory. -// -// Note that there is additional overhead, in the form -// of additional buffer copies of the data, for -// recursively mounting a multifile like this. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to mount(), but it receives the name of a Multifile that + * already appears within the virtual file system. It can be used to mount a + * Multifile that is itself hosted within a virtually-mounted Multifile. + * + * This interface can also be used to mount physical files (that appear within + * the virtual filespace), but it cannot be used to mount directories. Use + * mount() if you need to mount a directory. + * + * Note that there is additional overhead, in the form of additional buffer + * copies of the data, for recursively mounting a multifile like this. + */ bool VirtualFileSystem:: mount_loop(const Filename &virtual_filename, const Filename &mount_point, int flags, const string &password) { @@ -188,8 +167,8 @@ mount_loop(const Filename &virtual_filename, const Filename &mount_point, PT(Multifile) multifile = new Multifile; multifile->set_encryption_password(password); - // For now these are always opened read only. Maybe later we'll - // support read-write on Multifiles. + // For now these are always opened read only. Maybe later we'll support + // read-write on Multifiles. flags |= MF_read_only; if (!multifile->open_read(virtual_filename)) { return false; @@ -199,14 +178,11 @@ mount_loop(const Filename &virtual_filename, const Filename &mount_point, } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::mount -// Access: Published -// Description: Adds the given VirtualFileMount object to the mount -// list. This is a lower-level function that the other -// flavors of mount(); it requires you to create a -// VirtualFileMount object specifically. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given VirtualFileMount object to the mount list. This is a lower- + * level function that the other flavors of mount(); it requires you to create + * a VirtualFileMount object specifically. + */ bool VirtualFileSystem:: mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { if (express_cat->is_debug()) { @@ -220,13 +196,10 @@ mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::unmount -// Access: Published -// Description: Unmounts all appearances of the indicated Multifile -// from the file system. Returns the number of -// appearances unmounted. -//////////////////////////////////////////////////////////////////// +/** + * Unmounts all appearances of the indicated Multifile from the file system. + * Returns the number of appearances unmounted. + */ int VirtualFileSystem:: unmount(Multifile *multifile) { _lock.acquire(); @@ -265,13 +238,10 @@ unmount(Multifile *multifile) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::unmount -// Access: Published -// Description: Unmounts all appearances of the indicated directory -// name or multifile name from the file system. Returns -// the number of appearances unmounted. -//////////////////////////////////////////////////////////////////// +/** + * Unmounts all appearances of the indicated directory name or multifile name + * from the file system. Returns the number of appearances unmounted. + */ int VirtualFileSystem:: unmount(const Filename &physical_filename) { _lock.acquire(); @@ -327,13 +297,10 @@ unmount(const Filename &physical_filename) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::unmount -// Access: Published -// Description: Unmounts the indicated VirtualFileMount object -// from the file system. Returns the number of -// appearances unmounted. -//////////////////////////////////////////////////////////////////// +/** + * Unmounts the indicated VirtualFileMount object from the file system. + * Returns the number of appearances unmounted. + */ int VirtualFileSystem:: unmount(VirtualFileMount *mount) { _lock.acquire(); @@ -363,13 +330,10 @@ unmount(VirtualFileMount *mount) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::unmount_point -// Access: Published -// Description: Unmounts all systems attached to the given mount -// point from the file system. Returns the number of -// appearances unmounted. -//////////////////////////////////////////////////////////////////// +/** + * Unmounts all systems attached to the given mount point from the file + * system. Returns the number of appearances unmounted. + */ int VirtualFileSystem:: unmount_point(const Filename &mount_point) { _lock.acquire(); @@ -402,12 +366,10 @@ unmount_point(const Filename &mount_point) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::unmount_all -// Access: Published -// Description: Unmounts all files from the file system. Returns the -// number of systems unmounted. -//////////////////////////////////////////////////////////////////// +/** + * Unmounts all files from the file system. Returns the number of systems + * unmounted. + */ int VirtualFileSystem:: unmount_all() { _lock.acquire(); @@ -428,12 +390,9 @@ unmount_all() { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::get_num_mounts -// Access: Published -// Description: Returns the number of individual mounts in the -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual mounts in the system. + */ int VirtualFileSystem:: get_num_mounts() const { ((VirtualFileSystem *)this)->_lock.acquire(); @@ -442,11 +401,9 @@ get_num_mounts() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::get_mount -// Access: Published -// Description: Returns the nth mount in the system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth mount in the system. + */ PT(VirtualFileMount) VirtualFileSystem:: get_mount(int n) const { ((VirtualFileSystem *)this)->_lock.acquire(); @@ -459,14 +416,11 @@ get_mount(int n) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::chdir -// Access: Published -// Description: Changes the current directory. This is used to -// resolve relative pathnames in get_file() and/or -// find_file(). Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the current directory. This is used to resolve relative pathnames + * in get_file() and/or find_file(). Returns true if successful, false + * otherwise. + */ bool VirtualFileSystem:: chdir(const Filename &new_directory) { _lock.acquire(); @@ -487,11 +441,9 @@ chdir(const Filename &new_directory) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::get_cwd -// Access: Published -// Description: Returns the current directory name. See chdir(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current directory name. See chdir(). + */ Filename VirtualFileSystem:: get_cwd() const { ((VirtualFileSystem *)this)->_lock.acquire(); @@ -500,15 +452,12 @@ get_cwd() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::make_directory -// Access: Published -// Description: Attempts to create a directory within the file -// system. Returns true on success, false on failure -// (for instance, because the parent directory does not -// exist, or is read-only). If the directory already -// existed prior to this call, returns true. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a directory within the file system. Returns true on + * success, false on failure (for instance, because the parent directory does + * not exist, or is read-only). If the directory already existed prior to + * this call, returns true. + */ bool VirtualFileSystem:: make_directory(const Filename &filename) { _lock.acquire(); @@ -518,20 +467,18 @@ make_directory(const Filename &filename) { return result->is_directory(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::make_directory_full -// Access: Published -// Description: Attempts to create a directory within the file -// system. Will also create any intervening directories -// needed. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a directory within the file system. Will also create + * any intervening directories needed. Returns true on success, false on + * failure. + */ bool VirtualFileSystem:: make_directory_full(const Filename &filename) { _lock.acquire(); - // First, make sure everything up to the last path is known. We - // don't care too much if any of these fail; maybe they failed - // because the directory was already there. + // First, make sure everything up to the last path is known. We don't care + // too much if any of these fail; maybe they failed because the directory + // was already there. string dirname = filename; size_t slash = dirname.find('/', 1); while (slash != string::npos) { @@ -547,22 +494,17 @@ make_directory_full(const Filename &filename) { return result->is_directory(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::get_file -// Access: Published -// Description: Looks up the file by the indicated name in the file -// system. Returns a VirtualFile pointer representing -// the file if it is found, or NULL if it is not. -// -// If status_only is true, the file will be checked for -// existence and length and so on, but the returned -// file's contents cannot be read. This is an -// optimization which is especially important for -// certain mount types, for instance HTTP, for which -// opening a file to determine its status is -// substantially less expensive than opening it to read -// its contents. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the file by the indicated name in the file system. Returns a + * VirtualFile pointer representing the file if it is found, or NULL if it is + * not. + * + * If status_only is true, the file will be checked for existence and length + * and so on, but the returned file's contents cannot be read. This is an + * optimization which is especially important for certain mount types, for + * instance HTTP, for which opening a file to determine its status is + * substantially less expensive than opening it to read its contents. + */ PT(VirtualFile) VirtualFileSystem:: get_file(const Filename &filename, bool status_only) const { int open_flags = status_only ? OF_status_only : 0; @@ -572,16 +514,12 @@ get_file(const Filename &filename, bool status_only) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::create_file -// Access: Published -// Description: Attempts to create a file by the indicated name in -// the filesystem, if possible, and returns it. If a -// file by this name already exists, returns the same -// thing as get_file(). If the filename is located -// within a read-only directory, or the directory -// doesn't exist, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a file by the indicated name in the filesystem, if + * possible, and returns it. If a file by this name already exists, returns + * the same thing as get_file(). If the filename is located within a read- + * only directory, or the directory doesn't exist, returns NULL. + */ PT(VirtualFile) VirtualFileSystem:: create_file(const Filename &filename) { ((VirtualFileSystem *)this)->_lock.acquire(); @@ -590,14 +528,11 @@ create_file(const Filename &filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::find_file -// Access: Published -// Description: Uses the indicated search path to find the file -// within the file system. Returns the first occurrence -// of the file found, or NULL if the file cannot be -// found. -//////////////////////////////////////////////////////////////////// +/** + * Uses the indicated search path to find the file within the file system. + * Returns the first occurrence of the file found, or NULL if the file cannot + * be found. + */ PT(VirtualFile) VirtualFileSystem:: find_file(const Filename &filename, const DSearchPath &searchpath, bool status_only) const { @@ -610,10 +545,10 @@ find_file(const Filename &filename, const DSearchPath &searchpath, Filename match(searchpath.get_directory(i), filename); if (searchpath.get_directory(i) == "." && filename.is_fully_qualified()) { - // A special case for the "." directory: to avoid prefixing an - // endless stream of ./ in front of files, if the filename - // already has a ./ prefixed (i.e. is_fully_qualified() is - // true), we don't prefix another one. + // A special case for the "." directory: to avoid prefixing an endless + // stream of . in front of files, if the filename already has a . + // prefixed (i.e. is_fully_qualified() is true), we don't prefix + // another one. match = filename; } PT(VirtualFile) found_file = get_file(match, status_only); @@ -625,14 +560,11 @@ find_file(const Filename &filename, const DSearchPath &searchpath, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::delete_file -// Access: Public -// Description: Attempts to delete the indicated file or directory. -// This can remove a single file or an empty directory. -// It will not remove a nonempty directory. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to delete the indicated file or directory. This can remove a + * single file or an empty directory. It will not remove a nonempty + * directory. Returns true on success, false on failure. + */ bool VirtualFileSystem:: delete_file(const Filename &filename) { PT(VirtualFile) file = get_file(filename, true); @@ -643,23 +575,17 @@ delete_file(const Filename &filename) { return file->delete_file(); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::rename_file -// Access: Public -// Description: Attempts to move or rename the indicated file or -// directory. If the original file is an ordinary file, -// it will quietly replace any already-existing file in -// the new filename (but not a directory). If the -// original file is a directory, the new filename must -// not already exist. -// -// If the file is a directory, the new filename must be -// within the same mount point. If the file is an -// ordinary file, the new filename may be anywhere; but -// if it is not within the same mount point then the -// rename operation is automatically performed as a -// two-step copy-and-delete operation. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to move or rename the indicated file or directory. If the + * original file is an ordinary file, it will quietly replace any already- + * existing file in the new filename (but not a directory). If the original + * file is a directory, the new filename must not already exist. + * + * If the file is a directory, the new filename must be within the same mount + * point. If the file is an ordinary file, the new filename may be anywhere; + * but if it is not within the same mount point then the rename operation is + * automatically performed as a two-step copy-and-delete operation. + */ bool VirtualFileSystem:: rename_file(const Filename &orig_filename, const Filename &new_filename) { _lock.acquire(); @@ -680,13 +606,10 @@ rename_file(const Filename &orig_filename, const Filename &new_filename) { return orig_file->rename_file(new_file); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::copy_file -// Access: Public -// Description: Attempts to copy the contents of the indicated file -// to the indicated file. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to copy the contents of the indicated file to the indicated file. + * Returns true on success, false on failure. + */ bool VirtualFileSystem:: copy_file(const Filename &orig_filename, const Filename &new_filename) { PT(VirtualFile) orig_file = get_file(orig_filename, true); @@ -702,14 +625,11 @@ copy_file(const Filename &orig_filename, const Filename &new_filename) { return orig_file->copy_file(new_file); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::resolve_filename -// Access: Public -// Description: Searches the given search path for the filename. If -// it is found, updates the filename to the full -// pathname found and returns true; otherwise, returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * Searches the given search path for the filename. If it is found, updates + * the filename to the full pathname found and returns true; otherwise, + * returns false. + */ bool VirtualFileSystem:: resolve_filename(Filename &filename, const DSearchPath &searchpath, @@ -720,8 +640,8 @@ resolve_filename(Filename &filename, found = find_file(filename, searchpath, true); if (found.is_null()) { - // We didn't find it with the given extension; can we try the - // default extension? + // We didn't find it with the given extension; can we try the default + // extension? if (filename.get_extension().empty() && !default_extension.empty()) { Filename try_ext = filename; try_ext.set_extension(default_extension); @@ -733,8 +653,8 @@ resolve_filename(Filename &filename, // The full pathname exists. Return true. return true; } else { - // The full pathname doesn't exist with the given extension; - // does it exist with the default extension? + // The full pathname doesn't exist with the given extension; does it + // exist with the default extension? if (filename.get_extension().empty() && !default_extension.empty()) { Filename try_ext = filename; try_ext.set_extension(default_extension); @@ -751,18 +671,14 @@ resolve_filename(Filename &filename, return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::find_all_files -// Access: Public -// Description: Searches all the directories in the search list for -// the indicated file, in order. Fills up the results -// list with *all* of the matching filenames found, if -// any. Returns the number of matches found. -// -// It is the responsibility of the the caller to clear -// the results list first; otherwise, the newly-found -// files will be appended to the list. -//////////////////////////////////////////////////////////////////// +/** + * Searches all the directories in the search list for the indicated file, in + * order. Fills up the results list with *all* of the matching filenames + * found, if any. Returns the number of matches found. + * + * It is the responsibility of the the caller to clear the results list first; + * otherwise, the newly-found files will be appended to the list. + */ int VirtualFileSystem:: find_all_files(const Filename &filename, const DSearchPath &searchpath, DSearchPath::Results &results) const { @@ -775,11 +691,10 @@ find_all_files(const Filename &filename, const DSearchPath &searchpath, if (exists(match)) { if (searchpath.get_directory(i) == "." && filename.is_fully_qualified()) { - // A special case for the "." directory: to avoid prefixing - // an endless stream of ./ in front of files, if the - // filename already has a ./ prefixed - // (i.e. is_fully_fully_qualified() is true), we don't - // prefix another one. + // A special case for the "." directory: to avoid prefixing an + // endless stream of . in front of files, if the filename already + // has a . prefixed (i.e. is_fully_fully_qualified() is true), we + // don't prefix another one. results.add_file(filename); } else { results.add_file(match); @@ -792,12 +707,9 @@ find_all_files(const Filename &filename, const DSearchPath &searchpath, return num_added; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::write -// Access: Published -// Description: Print debugging information. -// (e.g. from Python or gdb prompt). -//////////////////////////////////////////////////////////////////// +/** + * Print debugging information. (e.g. from Python or gdb prompt). + */ void VirtualFileSystem:: write(ostream &out) const { ((VirtualFileSystem *)this)->_lock.acquire(); @@ -810,20 +722,15 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::get_global_ptr -// Access: Published, Static -// Description: Returns the default global VirtualFileSystem. You -// may create your own personal VirtualFileSystem -// objects and use them for whatever you like, but Panda -// will attempt to load models and stuff from this -// default object. -// -// Initially, the global VirtualFileSystem is set up to -// mount the OS filesystem to root; i.e. it is -// equivalent to the OS filesystem. This may be -// subsequently adjusted by the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default global VirtualFileSystem. You may create your own + * personal VirtualFileSystem objects and use them for whatever you like, but + * Panda will attempt to load models and stuff from this default object. + * + * Initially, the global VirtualFileSystem is set up to mount the OS + * filesystem to root; i.e. it is equivalent to the OS filesystem. This may + * be subsequently adjusted by the user. + */ VirtualFileSystem *VirtualFileSystem:: get_global_ptr() { if (_global_ptr == (VirtualFileSystem *)NULL) { @@ -832,8 +739,7 @@ get_global_ptr() { _global_ptr = new VirtualFileSystem; - // Set up the default mounts. First, there is always the root - // mount. + // Set up the default mounts. First, there is always the root mount. _global_ptr->mount("/", "/", 0); // And our initial cwd comes from the environment. @@ -852,13 +758,12 @@ get_global_ptr() { // vfs-mount system-filename mount-point [options] - // The last two spaces mark the beginning of the mount point, - // and of the options, respectively. There might be multiple - // spaces in the system filename, which are part of the - // filename. + // The last two spaces mark the beginning of the mount point, and of the + // options, respectively. There might be multiple spaces in the system + // filename, which are part of the filename. - // The last space marks the beginning of the mount point. - // Spaces before that are part of the system filename. + // The last space marks the beginning of the mount point. Spaces before + // that are part of the system filename. size_t space = mount_desc.rfind(' '); if (space == string::npos) { express_cat.warning() @@ -922,19 +827,15 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_read_file -// Access: Published -// Description: Convenience function; returns a newly allocated -// istream if the file exists and can be read, or NULL -// otherwise. Does not return an invalid istream. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns a newly allocated istream if the file exists + * and can be read, or NULL otherwise. Does not return an invalid istream. + * + * If auto_unwrap is true, an explicitly-named .pz file is automatically + * decompressed and the decompressed contents are returned. This is different + * than vfs-implicit-pz, which will automatically decompress a file if the + * extension .pz is *not* given. + */ istream *VirtualFileSystem:: open_read_file(const Filename &filename, bool auto_unwrap) const { PT(VirtualFile) file = get_file(filename, false); @@ -949,22 +850,19 @@ open_read_file(const Filename &filename, bool auto_unwrap) const { return str; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::close_read_file -// Access: Published, Static -// Description: Closes a file opened by a previous call to -// open_read_file(). This really just deletes the -// istream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_file(). This really + * just deletes the istream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSystem:: close_read_file(istream *stream) { if (stream != (istream *)NULL) { - // For some reason--compiler bug in gcc 3.2?--explicitly deleting - // the stream pointer does not call the appropriate global delete - // function; instead apparently calling the system delete - // function. So we call the delete function by hand instead. + // For some reason--compiler bug in gcc 3.2?--explicitly deleting the + // stream pointer does not call the appropriate global delete function; + // instead apparently calling the system delete function. So we call the + // delete function by hand instead. #if (!defined(WIN32_VC) && !defined(WIN64_VC)) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~istream(); (*global_operator_delete)(stream); @@ -974,18 +872,14 @@ close_read_file(istream *stream) { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_write_file -// Access: Published -// Description: Convenience function; returns a newly allocated -// ostream if the file exists and can be written, or -// NULL otherwise. Does not return an invalid ostream. -// -// If auto_wrap is true, an explicitly-named .pz file is -// automatically compressed while writing. If truncate -// is true, the file is truncated to zero length before -// writing. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns a newly allocated ostream if the file exists + * and can be written, or NULL otherwise. Does not return an invalid ostream. + * + * If auto_wrap is true, an explicitly-named .pz file is automatically + * compressed while writing. If truncate is true, the file is truncated to + * zero length before writing. + */ ostream *VirtualFileSystem:: open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { PT(VirtualFile) file = create_file(filename); @@ -1000,14 +894,11 @@ open_write_file(const Filename &filename, bool auto_wrap, bool truncate) { return str; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_append_file -// Access: Published -// Description: Works like open_write_file(), but the file is opened -// in append mode. Like open_write_file, the returned -// pointer should eventually be passed to -// close_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_write_file(), but the file is opened in append mode. Like + * open_write_file, the returned pointer should eventually be passed to + * close_write_file(). + */ ostream *VirtualFileSystem:: open_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); @@ -1022,15 +913,12 @@ open_append_file(const Filename &filename) { return str; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::close_write_file -// Access: Published, Static -// Description: Closes a file opened by a previous call to -// open_write_file(). This really just deletes the -// ostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_write_file(). This really + * just deletes the ostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSystem:: close_write_file(ostream *stream) { if (stream != (ostream *)NULL) { @@ -1043,13 +931,11 @@ close_write_file(ostream *stream) { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_read_write_file -// Access: Published -// Description: Convenience function; returns a newly allocated -// iostream if the file exists and can be written, or -// NULL otherwise. Does not return an invalid iostream. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns a newly allocated iostream if the file exists + * and can be written, or NULL otherwise. Does not return an invalid + * iostream. + */ iostream *VirtualFileSystem:: open_read_write_file(const Filename &filename, bool truncate) { PT(VirtualFile) file = create_file(filename); @@ -1064,14 +950,11 @@ open_read_write_file(const Filename &filename, bool truncate) { return str; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_read_append_file -// Access: Published -// Description: Works like open_read_write_file(), but the file is opened -// in append mode. Like open_read_write_file, the returned -// pointer should eventually be passed to -// close_read_write_file(). -//////////////////////////////////////////////////////////////////// +/** + * Works like open_read_write_file(), but the file is opened in append mode. + * Like open_read_write_file, the returned pointer should eventually be passed + * to close_read_write_file(). + */ iostream *VirtualFileSystem:: open_read_append_file(const Filename &filename) { PT(VirtualFile) file = create_file(filename); @@ -1086,15 +969,12 @@ open_read_append_file(const Filename &filename) { return str; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::close_read_write_file -// Access: Published, Static -// Description: Closes a file opened by a previous call to -// open_read_write_file(). This really just deletes the -// iostream pointer, but it is recommended to use this -// interface instead of deleting it explicitly, to help -// work around compiler issues. -//////////////////////////////////////////////////////////////////// +/** + * Closes a file opened by a previous call to open_read_write_file(). This + * really just deletes the iostream pointer, but it is recommended to use this + * interface instead of deleting it explicitly, to help work around compiler + * issues. + */ void VirtualFileSystem:: close_read_write_file(iostream *stream) { if (stream != (iostream *)NULL) { @@ -1107,11 +987,9 @@ close_read_write_file(iostream *stream) { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::atomic_compare_and_exchange_contents -// Access: Public -// Description: See Filename::atomic_compare_and_exchange_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_compare_and_exchange_contents(). + */ bool VirtualFileSystem:: atomic_compare_and_exchange_contents(const Filename &filename, string &orig_contents, const string &old_contents, @@ -1124,11 +1002,9 @@ atomic_compare_and_exchange_contents(const Filename &filename, string &orig_cont return file->atomic_compare_and_exchange_contents(orig_contents, old_contents, new_contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::atomic_read_contents -// Access: Public -// Description: See Filename::atomic_read_contents(). -//////////////////////////////////////////////////////////////////// +/** + * See Filename::atomic_read_contents(). + */ bool VirtualFileSystem:: atomic_read_contents(const Filename &filename, string &contents) const { PT(VirtualFile) file = get_file(filename, false); @@ -1139,17 +1015,14 @@ atomic_read_contents(const Filename &filename, string &contents) const { return file->atomic_read_contents(contents); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::scan_mount_points -// Access: Public -// Description: Adds to names a list of all the mount points in use -// that are one directory below path, if any. That is, -// these are the external files or directories mounted -// directly to the indicated path. -// -// The names vector is filled with a set of basenames, -// the basename part of the mount point. -//////////////////////////////////////////////////////////////////// +/** + * Adds to names a list of all the mount points in use that are one directory + * below path, if any. That is, these are the external files or directories + * mounted directly to the indicated path. + * + * The names vector is filled with a set of basenames, the basename part of + * the mount point. + */ void VirtualFileSystem:: scan_mount_points(vector_string &names, const Filename &path) const { nassertv(!path.empty() && !path.is_local()); @@ -1160,11 +1033,10 @@ scan_mount_points(vector_string &names, const Filename &path) const { string mount_point = mount->get_mount_point(); if (prefix.empty()) { - // The indicated path is the root. Is the mount point on the - // root? + // The indicated path is the root. Is the mount point on the root? if (mount_point.find('/') == string::npos) { - // No embedded slashes, so the mount point is only one - // directory below the root. + // No embedded slashes, so the mount point is only one directory below + // the root. names.push_back(mount_point); } } else { @@ -1184,12 +1056,10 @@ scan_mount_points(vector_string &names, const Filename &path) const { } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::parse_options -// Access: Public, Static -// Description: Parses all of the option flags in the options list on -// the vfs-mount Config.prc line. -//////////////////////////////////////////////////////////////////// +/** + * Parses all of the option flags in the options list on the vfs-mount + * Config.prc line. + */ void VirtualFileSystem:: parse_options(const string &options, int &flags, string &password) { flags = 0; @@ -1207,12 +1077,10 @@ parse_options(const string &options, int &flags, string &password) { parse_option(options.substr(p), flags, password); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::parse_option -// Access: Public, Static -// Description: Parses one of the option flags in the options list on -// the vfs-mount Config.prc line. -//////////////////////////////////////////////////////////////////// +/** + * Parses one of the option flags in the options list on the vfs-mount + * Config.prc line. + */ void VirtualFileSystem:: parse_option(const string &option, int &flags, string &password) { if (option == "0" || option.empty()) { @@ -1227,16 +1095,13 @@ parse_option(const string &option, int &flags, string &password) { } } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::normalize_mount_point -// Access: Private -// Description: Converts the mount point string supplied by the user -// to standard form (relative to the current directory, -// with no double slashes, and not terminating with a -// slash). The initial slash is removed. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Converts the mount point string supplied by the user to standard form + * (relative to the current directory, with no double slashes, and not + * terminating with a slash). The initial slash is removed. + * + * Assumes the lock is already held. + */ Filename VirtualFileSystem:: normalize_mount_point(const Filename &mount_point) const { Filename nmp = mount_point; @@ -1248,12 +1113,9 @@ normalize_mount_point(const Filename &mount_point) const { return nmp.get_fullpath().substr(1); } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::do_mount -// Access: Private -// Description: The private implementation of mount(). Assumes the -// lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of mount(). Assumes the lock is already held. + */ bool VirtualFileSystem:: do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { nassertr(mount->_file_system == NULL, false); @@ -1265,13 +1127,10 @@ do_mount(VirtualFileMount *mount, const Filename &mount_point, int flags) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::do_get_file -// Access: Private -// Description: The private implementation of get_file(), -// create_file(), and make_directory(). Assumes the -// lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of get_file(), create_file(), and + * make_directory(). Assumes the lock is already held. + */ PT(VirtualFile) VirtualFileSystem:: do_get_file(const Filename &filename, int open_flags) const { if (filename.empty()) { @@ -1290,13 +1149,13 @@ do_get_file(const Filename &filename, int open_flags) const { // Also transparently look for a regular file suffixed .pz. Filename strpath_pz = strpath + ".pz"; - // Now scan all the mount points, from the back (since later mounts - // override more recent ones), until a match is found. + // Now scan all the mount points, from the back (since later mounts override + // more recent ones), until a match is found. PT(VirtualFile) found_file = NULL; VirtualFileComposite *composite_file = NULL; - // We use an index instead of an iterator, since the vector might - // change if implicit mounts are added during this loop. + // We use an index instead of an iterator, since the vector might change if + // implicit mounts are added during this loop. unsigned int start_seq = _mount_seq; size_t i = _mounts.size(); @@ -1305,8 +1164,8 @@ do_get_file(const Filename &filename, int open_flags) const { VirtualFileMount *mount = _mounts[i]; Filename mount_point = mount->get_mount_point(); if (strpath == mount_point) { - // Here's an exact match on the mount point. This filename is - // the root directory of this mount object. + // Here's an exact match on the mount point. This filename is the root + // directory of this mount object. if (consider_match(found_file, composite_file, mount, "", pathname, false, open_flags)) { return found_file; @@ -1347,9 +1206,8 @@ do_get_file(const Filename &filename, int open_flags) const { #endif // HAVE_ZLIB } - // If we discover that a file has been implicitly mounted during - // one of the above operations, start over from the beginning of - // the loop. + // If we discover that a file has been implicitly mounted during one of + // the above operations, start over from the beginning of the loop. if (start_seq != _mount_seq) { start_seq = _mount_seq; i = _mounts.size(); @@ -1357,13 +1215,13 @@ do_get_file(const Filename &filename, int open_flags) const { } if (found_file == (VirtualFile *)NULL && vfs_implicit_mf) { - // The file wasn't found, as-is. Does it appear to be an implicit - // .mf file reference? + // The file wasn't found, as-is. Does it appear to be an implicit .mf + // file reference? ((VirtualFileSystem *)this)->consider_mount_mf(filename); if (start_seq != _mount_seq) { - // Yes, it was, or some nested file was. Now that we've - // implicitly mounted the .mf file, go back and look again. + // Yes, it was, or some nested file was. Now that we've implicitly + // mounted the .mf file, go back and look again. return do_get_file(filename, open_flags); } } @@ -1371,19 +1229,15 @@ do_get_file(const Filename &filename, int open_flags) const { return found_file; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::consider_match -// Access: Private -// Description: Evaluates one possible filename match found during a -// get_file() operation. There may be multiple matches -// for a particular filename due to the ambiguities -// introduced by allowing multiple mount points, so we -// may have to keep searching even after the first match -// is found. -// -// Returns true if the search should terminate now, or -// false if it should keep iterating. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates one possible filename match found during a get_file() operation. + * There may be multiple matches for a particular filename due to the + * ambiguities introduced by allowing multiple mount points, so we may have to + * keep searching even after the first match is found. + * + * Returns true if the search should terminate now, or false if it should keep + * iterating. + */ bool VirtualFileSystem:: consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_file, VirtualFileMount *mount, const Filename &local_filename, @@ -1400,7 +1254,8 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil // This was our first match. Save it. found_file = vfile; if (!found_file->is_directory() || ((open_flags & OF_make_directory) != 0)) { - // If it's not a directory (or we wanted to make a directory), we're done. + // If it's not a directory (or we wanted to make a directory), we're + // done. return true; } // It is a directory, so save it for later. @@ -1410,16 +1265,16 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil } } else { - // This was our second match. The previous match(es) must - // have been directories. + // This was our second match. The previous match(es) must have been + // directories. if (!vfile->is_directory()) { // However, this one isn't a directory. We're done. return true; } if (!implicit_pz_file) { - // At least two directories matched to the same path. We - // need a composite directory. + // At least two directories matched to the same path. We need a + // composite directory. if (composite_file == (VirtualFileComposite *)NULL) { composite_file = new VirtualFileComposite((VirtualFileSystem *)this, found_file->get_original_filename()); @@ -1436,18 +1291,14 @@ consider_match(PT(VirtualFile) &found_file, VirtualFileComposite *&composite_fil return false; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::consider_mount_mf -// Access: Private -// Description: The indicated filename was not found. Check to see -// if it is using an implicit reference to a .mf file as -// a directory, that hasn't already been mounted. If it -// is, mount the .mf file in-place, and return true; if -// it is not, or if its .mf file is already mounted -// in-place, return false. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The indicated filename was not found. Check to see if it is using an + * implicit reference to a .mf file as a directory, that hasn't already been + * mounted. If it is, mount the .mf file in-place, and return true; if it is + * not, or if its .mf file is already mounted in-place, return false. + * + * Assumes the lock is already held. + */ bool VirtualFileSystem:: consider_mount_mf(const Filename &filename) { Filename dirname = filename.get_dirname(); @@ -1456,8 +1307,8 @@ consider_mount_mf(const Filename &filename) { return false; } if (is_directory(dirname)) { - // Reached a real (or already-mounted) directory; no unmounted .mf - // file references. + // Reached a real (or already-mounted) directory; no unmounted .mf file + // references. return false; } if (dirname.get_extension() == "mf") { @@ -1477,8 +1328,8 @@ consider_mount_mf(const Filename &filename) { return false; } - // Wrap a thread-safe wrapper around that stream, so multiple - // threads can safely read the multifile simultaneously. + // Wrap a thread-safe wrapper around that stream, so multiple threads can + // safely read the multifile simultaneously. IStreamWrapper *streamw = new IStreamWrapper(stream, true); if (!multifile->open_read(streamw, true)) { diff --git a/panda/src/express/virtualFileSystem.h b/panda/src/express/virtualFileSystem.h index c497aaa86d..ea37d9ebe3 100644 --- a/panda/src/express/virtualFileSystem.h +++ b/panda/src/express/virtualFileSystem.h @@ -1,16 +1,15 @@ -// Filename: virtualFileSystem.h -// Created by: drose (03Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSystem.h + * @author drose + * @date 2002-08-03 + */ #ifndef VIRTUALFILESYSTEM_H #define VIRTUALFILESYSTEM_H @@ -30,17 +29,14 @@ class Multifile; class VirtualFileComposite; -//////////////////////////////////////////////////////////////////// -// Class : VirtualFileSystem -// Description : A hierarchy of directories and files that appears to -// be one continuous file system, even though the files -// may originate from several different sources that may -// not be related to the actual OS's file system. -// -// For instance, a VirtualFileSystem can transparently -// mount one or more Multifiles as their own -// subdirectory hierarchies. -//////////////////////////////////////////////////////////////////// +/** + * A hierarchy of directories and files that appears to be one continuous file + * system, even though the files may originate from several different sources + * that may not be related to the actual OS's file system. + * + * For instance, a VirtualFileSystem can transparently mount one or more + * Multifiles as their own subdirectory hierarchies. + */ class EXPCL_PANDAEXPRESS VirtualFileSystem { PUBLISHED: VirtualFileSystem(); @@ -51,9 +47,9 @@ PUBLISHED: }; BLOCKING bool mount(Multifile *multifile, const Filename &mount_point, int flags); - BLOCKING bool mount(const Filename &physical_filename, const Filename &mount_point, + BLOCKING bool mount(const Filename &physical_filename, const Filename &mount_point, int flags, const string &password = ""); - BLOCKING bool mount_loop(const Filename &virtual_filename, const Filename &mount_point, + BLOCKING bool mount_loop(const Filename &virtual_filename, const Filename &mount_point, int flags, const string &password = ""); bool mount(VirtualFileMount *mount, const Filename &mount_point, int flags); BLOCKING int unmount(Multifile *multifile); @@ -73,7 +69,7 @@ PUBLISHED: BLOCKING PT(VirtualFile) get_file(const Filename &filename, bool status_only = false) const; BLOCKING PT(VirtualFile) create_file(const Filename &filename); - BLOCKING PT(VirtualFile) find_file(const Filename &filename, + BLOCKING PT(VirtualFile) find_file(const Filename &filename, const DSearchPath &searchpath, bool status_only = false) const; BLOCKING bool delete_file(const Filename &filename); @@ -112,7 +108,8 @@ PUBLISHED: BLOCKING static void close_read_write_file(iostream *stream); public: - // We provide Python versions of these as efficient extension methods, above. + // We provide Python versions of these as efficient extension methods, + // above. BLOCKING INLINE string read_file(const Filename &filename, bool auto_unwrap) const; BLOCKING INLINE bool write_file(const Filename &filename, const string &data, bool auto_wrap); @@ -124,7 +121,7 @@ public: INLINE bool write_file(const Filename &filename, const unsigned char *data, size_t data_size, bool auto_wrap); void scan_mount_points(vector_string &names, const Filename &path) const; - + static void parse_options(const string &options, int &flags, string &password); static void parse_option(const string &option, @@ -132,8 +129,8 @@ public: public: // These flags are passed to do_get_file() and - // VirtualFileMount::make_virtual_file() to quality the kind of - // VirtualFile pointer we want to get. + // VirtualFileMount::make_virtual_file() to quality the kind of VirtualFile + // pointer we want to get. enum OpenFlags { OF_status_only = 0x0001, OF_create_file = 0x0002, @@ -142,8 +139,8 @@ public: }; // These are declared as class instances, instead of as globals, to - // guarantee they will be initialized by the time the - // VirtualFileSystem's constructor runs. + // guarantee they will be initialized by the time the VirtualFileSystem's + // constructor runs. ConfigVariableBool vfs_case_sensitive; ConfigVariableBool vfs_implicit_pz; ConfigVariableBool vfs_implicit_mf; diff --git a/panda/src/express/virtualFileSystem_ext.cxx b/panda/src/express/virtualFileSystem_ext.cxx index 9de1786987..dc50751c52 100644 --- a/panda/src/express/virtualFileSystem_ext.cxx +++ b/panda/src/express/virtualFileSystem_ext.cxx @@ -1,34 +1,29 @@ -// Filename: virtualFileSystem_ext.cxx -// Created by: rdb (12Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSystem_ext.cxx + * @author rdb + * @date 2013-09-12 + */ #include "virtualFileSystem_ext.h" #include "vector_uchar.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::read_file -// Access: Published -// Description: Convenience function; returns the entire contents of -// the indicated file as a string (or as a bytes object, -// in Python 3). -// -// This variant on read_file() is implemented directly -// for Python, as a small optimization, to avoid the -// double-construction of a string object that would be -// otherwise required for the return value. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns the entire contents of the indicated file as + * a string (or as a bytes object, in Python 3). + * + * This variant on read_file() is implemented directly for Python, as a small + * optimization, to avoid the double-construction of a string object that + * would be otherwise required for the return value. + */ PyObject *Extension:: read_file(const Filename &filename, bool auto_unwrap) const { vector_uchar pv; @@ -50,17 +45,14 @@ read_file(const Filename &filename, bool auto_unwrap) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::write_file -// Access: Published -// Description: Convenience function; writes the entire contents of -// the indicated file as a string. -// -// This variant on write_file() is implemented directly -// for Python, as a small optimization, to avoid the -// double-construction of a string object that would be -// otherwise required. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; writes the entire contents of the indicated file as a + * string. + * + * This variant on write_file() is implemented directly for Python, as a small + * optimization, to avoid the double-construction of a string object that + * would be otherwise required. + */ PyObject *Extension:: write_file(const Filename &filename, PyObject *data, bool auto_wrap) { char *buffer; diff --git a/panda/src/express/virtualFileSystem_ext.h b/panda/src/express/virtualFileSystem_ext.h index b4b6322c3b..3a6ec7dda2 100644 --- a/panda/src/express/virtualFileSystem_ext.h +++ b/panda/src/express/virtualFileSystem_ext.h @@ -1,16 +1,15 @@ -// Filename: virtualFileSystem_ext.h -// Created by: rdb (12Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFileSystem_ext.h + * @author rdb + * @date 2013-09-12 + */ #ifndef VIRTUALFILESYSTEM_EXT_H #define VIRTUALFILESYSTEM_EXT_H @@ -23,12 +22,10 @@ #include "virtualFileSystem.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// VirtualFileSystem, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for VirtualFileSystem, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: @@ -39,4 +36,3 @@ public: #endif // HAVE_PYTHON #endif // VIRTUALFILESYSTEM_EXT_H - diff --git a/panda/src/express/virtualFile_ext.cxx b/panda/src/express/virtualFile_ext.cxx index 3d1c738e8e..d81672cc50 100644 --- a/panda/src/express/virtualFile_ext.cxx +++ b/panda/src/express/virtualFile_ext.cxx @@ -1,34 +1,29 @@ -// Filename: virtualFile_ext.cxx -// Created by: rdb (15Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFile_ext.cxx + * @author rdb + * @date 2015-09-15 + */ #include "virtualFile_ext.h" #include "vector_uchar.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::read_file -// Access: Published -// Description: Convenience function; returns the entire contents of -// the indicated file as a string (or as a bytes object, -// in Python 3). -// -// This variant on read_file() is implemented directly -// for Python, as a small optimization, to avoid the -// double-construction of a string object that would be -// otherwise required for the return value. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; returns the entire contents of the indicated file as + * a string (or as a bytes object, in Python 3). + * + * This variant on read_file() is implemented directly for Python, as a small + * optimization, to avoid the double-construction of a string object that + * would be otherwise required for the return value. + */ PyObject *Extension:: read_file(bool auto_unwrap) const { vector_uchar pv; @@ -50,17 +45,14 @@ read_file(bool auto_unwrap) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFile::write_file -// Access: Published -// Description: Convenience function; writes the entire contents of -// the indicated file as a string. -// -// This variant on write_file() is implemented directly -// for Python, as a small optimization, to avoid the -// double-construction of a string object that would be -// otherwise required. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function; writes the entire contents of the indicated file as a + * string. + * + * This variant on write_file() is implemented directly for Python, as a small + * optimization, to avoid the double-construction of a string object that + * would be otherwise required. + */ PyObject *Extension:: write_file(PyObject *data, bool auto_wrap) { char *buffer; diff --git a/panda/src/express/virtualFile_ext.h b/panda/src/express/virtualFile_ext.h index dd6262067b..565c1829e1 100644 --- a/panda/src/express/virtualFile_ext.h +++ b/panda/src/express/virtualFile_ext.h @@ -1,16 +1,15 @@ -// Filename: virtualFile_ext.h -// Created by: rdb (15Sep15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file virtualFile_ext.h + * @author rdb + * @date 2015-09-15 + */ #ifndef VIRTUALFILE_EXT_H #define VIRTUALFILE_EXT_H @@ -23,12 +22,10 @@ #include "virtualFile.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// VirtualFile, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for VirtualFile, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: @@ -39,4 +36,3 @@ public: #endif // HAVE_PYTHON #endif // VIRTUALFILE_EXT_H - diff --git a/panda/src/express/weakPointerCallback.I b/panda/src/express/weakPointerCallback.I index d48b5b36d5..ca1ff74ab6 100644 --- a/panda/src/express/weakPointerCallback.I +++ b/panda/src/express/weakPointerCallback.I @@ -1,14 +1,12 @@ -// Filename: weakPointerCallback.I -// Created by: drose (06Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerCallback.I + * @author drose + * @date 2006-10-06 + */ diff --git a/panda/src/express/weakPointerCallback.cxx b/panda/src/express/weakPointerCallback.cxx index 14de218946..f6cc49f745 100644 --- a/panda/src/express/weakPointerCallback.cxx +++ b/panda/src/express/weakPointerCallback.cxx @@ -1,24 +1,21 @@ -// Filename: weakPointerCallback.cxx -// Created by: drose (06Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerCallback.cxx + * @author drose + * @date 2006-10-06 + */ #include "weakPointerCallback.h" -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerCallback::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WeakPointerCallback:: ~WeakPointerCallback() { } diff --git a/panda/src/express/weakPointerCallback.h b/panda/src/express/weakPointerCallback.h index 0da98e0737..37b4ed2b9c 100644 --- a/panda/src/express/weakPointerCallback.h +++ b/panda/src/express/weakPointerCallback.h @@ -1,29 +1,26 @@ -// Filename: weakPointerCallback.h -// Created by: drose (06Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerCallback.h + * @author drose + * @date 2006-10-06 + */ #ifndef WEAKPOINTERCALLBACK_H #define WEAKPOINTERCALLBACK_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakPointerCallback -// Description : Derive from this class and override the callback() -// method if you want to get an immediate callback from -// a WeakPointerTo object when its referenced pointer is -// deleted. -//////////////////////////////////////////////////////////////////// +/** + * Derive from this class and override the callback() method if you want to + * get an immediate callback from a WeakPointerTo object when its referenced + * pointer is deleted. + */ class EXPCL_PANDAEXPRESS WeakPointerCallback { public: virtual ~WeakPointerCallback(); diff --git a/panda/src/express/weakPointerTo.I b/panda/src/express/weakPointerTo.I index 797d1cf000..aec710288f 100644 --- a/panda/src/express/weakPointerTo.I +++ b/panda/src/express/weakPointerTo.I @@ -1,33 +1,27 @@ -// Filename: weakPointerTo.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerTo.I + * @author drose + * @date 2004-09-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo:: WeakPointerTo(To *ptr) : WeakPointerToBase(ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo:: WeakPointerTo(const PointerTo ©) : @@ -35,11 +29,9 @@ WeakPointerTo(const PointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo:: WeakPointerTo(const WeakPointerTo ©) : @@ -47,11 +39,9 @@ WeakPointerTo(const WeakPointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME WeakPointerTo::To &WeakPointerTo:: operator *() const { @@ -59,11 +49,9 @@ operator *() const { return *((To *)WeakPointerToBase::_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: operator -> () const { @@ -71,16 +59,12 @@ operator -> () const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert WeakPointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert WeakPointerTo's + * to the required kind of actual pointer. This introduces ambiguities which + * the compiler will resolve one way or the other, but we don't care which way + * it goes because either will be correct. + */ template INLINE WeakPointerTo:: operator T * () const { @@ -88,13 +72,10 @@ operator T * () const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::p -// Access: Public -// Description: Returns an ordinary pointer instead of a WeakPointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a WeakPointerTo. Useful to work + * around compiler problems, particularly for implicit upcasts. + */ template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: p() const { @@ -102,23 +83,19 @@ p() const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::get_orig -// Access: Public -// Description: Returns the original pointer value, even if the -// object has since been deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the original pointer value, even if the object has since been + * deleted. + */ template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (To *ptr) { @@ -126,11 +103,9 @@ operator = (To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (const PointerTo ©) { @@ -138,11 +113,9 @@ operator = (const PointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (const WeakPointerTo ©) { @@ -150,11 +123,9 @@ operator = (const WeakPointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const To *ptr) : @@ -162,11 +133,9 @@ WeakConstPointerTo(const To *ptr) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const PointerTo ©) : @@ -174,11 +143,9 @@ WeakConstPointerTo(const PointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const ConstPointerTo ©) : @@ -186,11 +153,9 @@ WeakConstPointerTo(const ConstPointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakPointerTo ©) : @@ -198,11 +163,9 @@ WeakConstPointerTo(const WeakPointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakConstPointerTo ©) : @@ -210,11 +173,9 @@ WeakConstPointerTo(const WeakConstPointerTo ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Dereference operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { @@ -222,11 +183,9 @@ operator *() const { return *((To *)WeakPointerToBase::_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Member access operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { @@ -234,16 +193,12 @@ operator -> () const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Typecast operator -// Access: Public -// Description: We also have the typecast operator to automatically -// convert WeakConstPointerTo's to the required kind of actual -// pointer. This introduces ambiguities which the -// compiler will resolve one way or the other, but we -// don't care which way it goes because either will be -// correct. -//////////////////////////////////////////////////////////////////// +/** + * We also have the typecast operator to automatically convert + * WeakConstPointerTo's to the required kind of actual pointer. This + * introduces ambiguities which the compiler will resolve one way or the + * other, but we don't care which way it goes because either will be correct. + */ template INLINE WeakConstPointerTo:: @@ -252,13 +207,10 @@ operator const T * () const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::p -// Access: Public -// Description: Returns an ordinary pointer instead of a WeakConstPointerTo. -// Useful to work around compiler problems, particularly -// for implicit upcasts. -//////////////////////////////////////////////////////////////////// +/** + * Returns an ordinary pointer instead of a WeakConstPointerTo. Useful to + * work around compiler problems, particularly for implicit upcasts. + */ template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: p() const { @@ -266,23 +218,19 @@ p() const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::get_orig -// Access: Public -// Description: Returns the original pointer value, even if the -// object has since been deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the original pointer value, even if the object has since been + * deleted. + */ template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const To *ptr) { @@ -290,11 +238,9 @@ operator = (const To *ptr) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const PointerTo ©) { @@ -302,11 +248,9 @@ operator = (const PointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const ConstPointerTo ©) { @@ -314,11 +258,9 @@ operator = (const ConstPointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakPointerTo ©) { @@ -326,11 +268,9 @@ operator = (const WeakPointerTo ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: WeakConstPointerTo::Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakConstPointerTo ©) { diff --git a/panda/src/express/weakPointerTo.cxx b/panda/src/express/weakPointerTo.cxx index d21bab59e8..156f7cc74c 100644 --- a/panda/src/express/weakPointerTo.cxx +++ b/panda/src/express/weakPointerTo.cxx @@ -1,15 +1,14 @@ -// Filename: weakPointerTo.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerTo.cxx + * @author drose + * @date 2004-09-27 + */ #include "weakPointerTo.h" diff --git a/panda/src/express/weakPointerTo.h b/panda/src/express/weakPointerTo.h index 82d722cd7f..44d9561eb3 100644 --- a/panda/src/express/weakPointerTo.h +++ b/panda/src/express/weakPointerTo.h @@ -1,16 +1,15 @@ -// Filename: weakPointerTo.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerTo.h + * @author drose + * @date 2004-09-27 + */ #ifndef WEAKPOINTERTO_H #define WEAKPOINTERTO_H @@ -19,15 +18,13 @@ #include "weakPointerToBase.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakPointerTo -// Description : WeakPointerTo is similar to PointerTo, except that it -// does not actually prevent the referenced pointer from -// deleting. Instead, the referenced pointer is allowed -// to delete, but if this happens then was_deleted() -// will return true, and it will be an assertion error to -// dereference the pointer thereafter. -//////////////////////////////////////////////////////////////////// +/** + * WeakPointerTo is similar to PointerTo, except that it does not actually + * prevent the referenced pointer from deleting. Instead, the referenced + * pointer is allowed to delete, but if this happens then was_deleted() will + * return true, and it will be an assertion error to dereference the pointer + * thereafter. + */ template class WeakPointerTo : public WeakPointerToBase { public: @@ -51,20 +48,18 @@ PUBLISHED: INLINE WeakPointerTo &operator = (const PointerTo ©); INLINE WeakPointerTo &operator = (const WeakPointerTo ©); - // This function normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the WeakPointerToBase class). When - // this works again in interrogate, we can remove this. + // This function normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the WeakPointerToBase class). When this works again + // in interrogate, we can remove this. INLINE void clear() { WeakPointerToBase::clear(); } }; -//////////////////////////////////////////////////////////////////// -// Class : WeakConstPointerTo -// Description : A WeakConstPointerTo is similar to a WeakPointerTo, -// except it keeps a const pointer to the thing, that -// will be cleared to NULL when the thing deleted. -//////////////////////////////////////////////////////////////////// +/** + * A WeakConstPointerTo is similar to a WeakPointerTo, except it keeps a const + * pointer to the thing, that will be cleared to NULL when the thing deleted. + */ template class WeakConstPointerTo : public WeakPointerToBase { public: @@ -91,10 +86,10 @@ PUBLISHED: INLINE WeakConstPointerTo &operator = (const WeakPointerTo ©); INLINE WeakConstPointerTo &operator = (const WeakConstPointerTo ©); - // These functions normally wouldn't need to be redefined here, but - // we do so anyway just to help out interrogate (which doesn't seem - // to want to automatically export the WeakPointerToBase class). When - // this works again in interrogate, we can remove these. + // These functions normally wouldn't need to be redefined here, but we do so + // anyway just to help out interrogate (which doesn't seem to want to + // automatically export the WeakPointerToBase class). When this works again + // in interrogate, we can remove these. INLINE bool is_null() const { return WeakPointerToBase::is_null(); } INLINE void clear() { WeakPointerToBase::clear(); } }; diff --git a/panda/src/express/weakPointerToBase.I b/panda/src/express/weakPointerToBase.I index ead49a1424..cb60c43fc2 100644 --- a/panda/src/express/weakPointerToBase.I +++ b/panda/src/express/weakPointerToBase.I @@ -1,45 +1,37 @@ -// Filename: weakPointerToBase.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToBase.I + * @author drose + * @date 2004-09-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerToBase:: WeakPointerToBase(To *ptr) { reassign(ptr); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerToBase:: WeakPointerToBase(const PointerToBase ©) { reassign(copy); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerToBase:: WeakPointerToBase(const WeakPointerToBase ©) { @@ -52,24 +44,19 @@ WeakPointerToBase(const WeakPointerToBase ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakPointerToBase:: ~WeakPointerToBase() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::reassign -// Access: Protected -// Description: This is the main work of the PointerTo family. When -// the pointer is reassigned, decrement the old -// reference count and increment the new one. -//////////////////////////////////////////////////////////////////// +/** + * This is the main work of the PointerTo family. When the pointer is + * reassigned, decrement the old reference count and increment the new one. + */ template void WeakPointerToBase:: reassign(To *ptr) { @@ -81,8 +68,8 @@ reassign(To *ptr) { ptr->weak_ref(this); #ifdef DO_MEMORY_USAGE if (MemoryUsage::get_track_memory_usage()) { - // Make sure the MemoryUsage record knows what the TypeHandle - // is, if we know it ourselves. + // Make sure the MemoryUsage record knows what the TypeHandle is, if + // we know it ourselves. TypeHandle type = get_type_handle(To); if (type == TypeHandle::none()) { do_init_type(To); @@ -104,25 +91,20 @@ reassign(To *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::reassign -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void WeakPointerToBase:: reassign(const PointerToBase ©) { - // This double-casting is a bit of a cheat to get around the - // inheritance issue--it's difficult to declare a template class to - // be a friend. + // This double-casting is a bit of a cheat to get around the inheritance + // issue--it's difficult to declare a template class to be a friend. reassign((To *)((const WeakPointerToBase *)©)->_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::reassign -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void WeakPointerToBase:: reassign(const WeakPointerToBase ©) { @@ -132,219 +114,179 @@ reassign(const WeakPointerToBase ©) { #ifndef CPPPARSER #ifndef WIN32_VC -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Equivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator == (const To *other) const { return (To *)_void_ptr == other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Nonequivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator != (const To *other) const { return (To *)_void_ptr != other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator > (const To *other) const { return (To *)_void_ptr > other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator <= (const To *other) const { return (To *)_void_ptr <= other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator >= (const To *other) const { return (To *)_void_ptr >= other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Equivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator == (To *other) const { return (To *)_void_ptr == other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Nonequivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator != (To *other) const { return (To *)_void_ptr != other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator > (To *other) const { return (To *)_void_ptr > other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator <= (To *other) const { return (To *)_void_ptr <= other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator >= (To *other) const { return (To *)_void_ptr >= other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Equivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator == (const WeakPointerToBase &other) const { return (To *)_void_ptr == (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Nonequivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator != (const WeakPointerToBase &other) const { return (To *)_void_ptr != (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator > (const WeakPointerToBase &other) const { return (To *)_void_ptr > (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator <= (const WeakPointerToBase &other) const { return (To *)_void_ptr <= (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator >= (const WeakPointerToBase &other) const { return (To *)_void_ptr >= (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Equivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator == (const PointerToBase &other) const { return (To *)_void_ptr == (To *)((WeakPointerToBase *)&other)->_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Nonequivalence operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator != (const PointerToBase &other) const { return (To *)_void_ptr != (To *)((WeakPointerToBase *)&other)->_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator > (const PointerToBase &other) const { return (To *)_void_ptr > (To *)((WeakPointerToBase *)&other)->_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator <= (const PointerToBase &other) const { return (To *)_void_ptr <= (To *)((WeakPointerToBase *)&other)->_void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Greater-than-or-equal operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator >= (const PointerToBase &other) const { @@ -352,33 +294,27 @@ operator >= (const PointerToBase &other) const { } #endif // WIN32_VC -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator < (const To *other) const { return (To *)_void_ptr < other; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator < (const WeakPointerToBase &other) const { return (To *)_void_ptr < (To *)other._void_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::Less-than operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool WeakPointerToBase:: operator < (const PointerToBase &other) const { @@ -389,42 +325,34 @@ operator < (const PointerToBase &other) const { -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::clear -// Access: Published -// Description: A convenient way to set the PointerTo object to NULL. -// (Assignment to a NULL pointer also works, of course.) -//////////////////////////////////////////////////////////////////// +/** + * A convenient way to set the PointerTo object to NULL. (Assignment to a NULL + * pointer also works, of course.) + */ template INLINE void WeakPointerToBase:: clear() { reassign((To *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::refresh -// Access: Published -// Description: Informs the WeakPointerTo object that its pointer is -// no longer deleted. This may be used after a -// WeakPointerTo has deleted a deleted pointer, and then -// a new pointer has been reallocated. It's equivalent -// to simply reassigning the pointer to its new -// (i.e. original) value, but has the advantage that it -// is const, so can be used for WeakPointers used as -// keys in STL maps and sets. -//////////////////////////////////////////////////////////////////// +/** + * Informs the WeakPointerTo object that its pointer is no longer deleted. + * This may be used after a WeakPointerTo has deleted a deleted pointer, and + * then a new pointer has been reallocated. It's equivalent to simply + * reassigning the pointer to its new (i.e. original) value, but has the + * advantage that it is const, so can be used for WeakPointers used as keys in + * STL maps and sets. + */ template INLINE void WeakPointerToBase:: refresh() const { ((WeakPointerToBase *)this)->reassign((To *)_void_ptr); } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToBase::output -// Access: Published -// Description: A handy function to output PointerTo's as a hex -// pointer followed by a reference count. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to output PointerTo's as a hex pointer followed by a + * reference count. + */ template INLINE void WeakPointerToBase:: output(ostream &out) const { diff --git a/panda/src/express/weakPointerToBase.cxx b/panda/src/express/weakPointerToBase.cxx index c9bad7c42e..44dc499a55 100644 --- a/panda/src/express/weakPointerToBase.cxx +++ b/panda/src/express/weakPointerToBase.cxx @@ -1,15 +1,14 @@ -// Filename: weakPointerToBase.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToBase.cxx + * @author drose + * @date 2004-09-27 + */ #include "weakPointerToBase.h" diff --git a/panda/src/express/weakPointerToBase.h b/panda/src/express/weakPointerToBase.h index ddc01b8347..04d55b8b1d 100644 --- a/panda/src/express/weakPointerToBase.h +++ b/panda/src/express/weakPointerToBase.h @@ -1,16 +1,15 @@ -// Filename: weakPointerToBase.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToBase.h + * @author drose + * @date 2004-09-27 + */ #ifndef WEAKPOINTERTOBASE_H #define WEAKPOINTERTOBASE_H @@ -19,12 +18,10 @@ #include "pointerToBase.h" #include "weakPointerToVoid.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakPointerToBase -// Description : This is the base class for PointerTo and -// ConstPointerTo. Don't try to use it directly; use -// either derived class instead. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for PointerTo and ConstPointerTo. Don't try to use + * it directly; use either derived class instead. + */ template class WeakPointerToBase : public WeakPointerToVoid { public: @@ -40,13 +37,12 @@ protected: INLINE void reassign(const PointerToBase ©); INLINE void reassign(const WeakPointerToBase ©); - // No assignment or retrieval functions are declared in - // WeakPointerToBase, because we will have to specialize on const - // vs. non-const later. + // No assignment or retrieval functions are declared in WeakPointerToBase, + // because we will have to specialize on const vs. non-const later. public: - // These comparison functions are common to all things PointerTo, so - // they're defined up here. + // These comparison functions are common to all things PointerTo, so they're + // defined up here. #ifndef CPPPARSER #ifndef WIN32_VC INLINE bool operator == (const To *other) const; diff --git a/panda/src/express/weakPointerToVoid.I b/panda/src/express/weakPointerToVoid.I index 4557cf857c..f55cf499cc 100644 --- a/panda/src/express/weakPointerToVoid.I +++ b/panda/src/express/weakPointerToVoid.I @@ -1,46 +1,36 @@ -// Filename: weakPointerToVoid.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToVoid.I + * @author drose + * @date 2004-09-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WeakPointerToVoid:: WeakPointerToVoid() { _ptr_was_deleted = false; _callback = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WeakPointerToVoid:: ~WeakPointerToVoid() { } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::mark_deleted -// Access: Public -// Description: This is intended only to be called by the -// WeakPointerList destructor. It indicates that the -// object that we were pointing to has just been -// deleted. -//////////////////////////////////////////////////////////////////// +/** + * This is intended only to be called by the WeakPointerList destructor. It + * indicates that the object that we were pointing to has just been deleted. + */ INLINE void WeakPointerToVoid:: mark_deleted() { nassertv(!_ptr_was_deleted); @@ -50,16 +40,13 @@ mark_deleted() { } } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::set_callback -// Access: Public -// Description: Sets a callback that will be made when the pointer is -// deleted. If a previous callback has already been -// set, it will be replaced. -// -// If the pointer has already been deleted, the callback -// will be made immediately. -//////////////////////////////////////////////////////////////////// +/** + * Sets a callback that will be made when the pointer is deleted. If a + * previous callback has already been set, it will be replaced. + * + * If the pointer has already been deleted, the callback will be made + * immediately. + */ INLINE void WeakPointerToVoid:: set_callback(WeakPointerCallback *callback) { _callback = callback; @@ -68,35 +55,28 @@ set_callback(WeakPointerCallback *callback) { } } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::get_callback -// Access: Public -// Description: Returns the callback that will be made when the -// pointer is deleted, or NULL if no callback has been -// set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the callback that will be made when the pointer is deleted, or NULL + * if no callback has been set. + */ INLINE WeakPointerCallback *WeakPointerToVoid:: get_callback() const { return _callback; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::was_deleted -// Access: Published -// Description: Returns true if the object we are pointing to has -// been deleted, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the object we are pointing to has been deleted, false + * otherwise. + */ INLINE bool WeakPointerToVoid:: was_deleted() const { return _ptr_was_deleted; } -//////////////////////////////////////////////////////////////////// -// Function: WeakPointerToVoid::is_valid_pointer -// Access: Published -// Description: Returns true if the pointer is not null and the -// object has not been deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the pointer is not null and the object has not been + * deleted. + */ INLINE bool WeakPointerToVoid:: is_valid_pointer() const { return (_void_ptr != (void *)NULL) && !_ptr_was_deleted; diff --git a/panda/src/express/weakPointerToVoid.cxx b/panda/src/express/weakPointerToVoid.cxx index 5ac8fc8e7f..a0b1c9b6ee 100644 --- a/panda/src/express/weakPointerToVoid.cxx +++ b/panda/src/express/weakPointerToVoid.cxx @@ -1,15 +1,14 @@ -// Filename: weakPointerToVoid.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToVoid.cxx + * @author drose + * @date 2004-09-27 + */ #include "weakPointerToVoid.h" diff --git a/panda/src/express/weakPointerToVoid.h b/panda/src/express/weakPointerToVoid.h index dc35b0749d..e82ec63420 100644 --- a/panda/src/express/weakPointerToVoid.h +++ b/panda/src/express/weakPointerToVoid.h @@ -1,16 +1,15 @@ -// Filename: weakPointerToVoid.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakPointerToVoid.h + * @author drose + * @date 2004-09-27 + */ #ifndef WEAKPOINTERTOVOID_H #define WEAKPOINTERTOVOID_H @@ -19,12 +18,10 @@ #include "pointerToVoid.h" #include "weakPointerCallback.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakPointerToVoid -// Description : This is the specialization of PointerToVoid for weak -// pointers. It needs an additional flag to indicate -// that the pointer has been deleted. -//////////////////////////////////////////////////////////////////// +/** + * This is the specialization of PointerToVoid for weak pointers. It needs an + * additional flag to indicate that the pointer has been deleted. + */ class EXPCL_PANDAEXPRESS WeakPointerToVoid : public PointerToVoid { protected: INLINE WeakPointerToVoid(); diff --git a/panda/src/express/weakReferenceList.I b/panda/src/express/weakReferenceList.I index 920e1557c5..661c4c268f 100644 --- a/panda/src/express/weakReferenceList.I +++ b/panda/src/express/weakReferenceList.I @@ -1,14 +1,12 @@ -// Filename: weakReferenceList.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakReferenceList.I + * @author drose + * @date 2004-09-27 + */ diff --git a/panda/src/express/weakReferenceList.cxx b/panda/src/express/weakReferenceList.cxx index 045bf2d343..cd940b2ecf 100644 --- a/panda/src/express/weakReferenceList.cxx +++ b/panda/src/express/weakReferenceList.cxx @@ -1,36 +1,30 @@ -// Filename: weakReferenceList.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakReferenceList.cxx + * @author drose + * @date 2004-09-27 + */ #include "weakReferenceList.h" #include "weakPointerToVoid.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: WeakReferenceList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WeakReferenceList:: WeakReferenceList() { } -//////////////////////////////////////////////////////////////////// -// Function: WeakReferenceList::Destructor -// Access: Public -// Description: The destructor tells all of the owned references that -// we're gone. -//////////////////////////////////////////////////////////////////// +/** + * The destructor tells all of the owned references that we're gone. + */ WeakReferenceList:: ~WeakReferenceList() { _lock.acquire(); @@ -41,19 +35,16 @@ WeakReferenceList:: _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: WeakReferenceList::add_reference -// Access: Public -// Description: Intended to be called only by WeakPointerTo (or by -// any class implementing a weak reference-counting -// pointer), this adds the indicated PointerToVoid -// structure to the list of such structures that are -// maintaining a weak pointer to this object. -// -// When the WeakReferenceList destructs (presumably -// because its owning object destructs), the pointer -// within the PointerToVoid object will be set to NULL. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called only by WeakPointerTo (or by any class implementing a + * weak reference-counting pointer), this adds the indicated PointerToVoid + * structure to the list of such structures that are maintaining a weak + * pointer to this object. + * + * When the WeakReferenceList destructs (presumably because its owning object + * destructs), the pointer within the PointerToVoid object will be set to + * NULL. + */ void WeakReferenceList:: add_reference(WeakPointerToVoid *ptv) { _lock.acquire(); @@ -62,15 +53,12 @@ add_reference(WeakPointerToVoid *ptv) { nassertv(inserted); } -//////////////////////////////////////////////////////////////////// -// Function: WeakReferenceList::clear_reference -// Access: Public -// Description: Intended to be called only by WeakPointerTo (or by -// any class implementing a weak reference-counting -// pointer), this removes the indicated PointerToVoid -// structure from the list of such structures that are -// maintaining a weak pointer to this object. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called only by WeakPointerTo (or by any class implementing a + * weak reference-counting pointer), this removes the indicated PointerToVoid + * structure from the list of such structures that are maintaining a weak + * pointer to this object. + */ void WeakReferenceList:: clear_reference(WeakPointerToVoid *ptv) { _lock.acquire(); diff --git a/panda/src/express/weakReferenceList.h b/panda/src/express/weakReferenceList.h index a747310fa7..16651b7364 100644 --- a/panda/src/express/weakReferenceList.h +++ b/panda/src/express/weakReferenceList.h @@ -1,16 +1,15 @@ -// Filename: weakReferenceList.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakReferenceList.h + * @author drose + * @date 2004-09-27 + */ #ifndef WEAKREFERENCELIST_H #define WEAKREFERENCELIST_H @@ -21,16 +20,13 @@ class WeakPointerToVoid; -//////////////////////////////////////////////////////////////////// -// Class : WeakReferenceList -// Description : This is a list of WeakPointerTo's that share a -// reference to a given ReferenceCount object. It is -// stored in a separate class since it is assumed that -// most ReferenceCount objects do not need to store this -// list at all; this avoids bloating every -// ReferenceCount object in the world with the size of -// this object. -//////////////////////////////////////////////////////////////////// +/** + * This is a list of WeakPointerTo's that share a reference to a given + * ReferenceCount object. It is stored in a separate class since it is + * assumed that most ReferenceCount objects do not need to store this list at + * all; this avoids bloating every ReferenceCount object in the world with the + * size of this object. + */ class EXPCL_PANDAEXPRESS WeakReferenceList { public: WeakReferenceList(); @@ -39,7 +35,7 @@ public: void add_reference(WeakPointerToVoid *ptv); void clear_reference(WeakPointerToVoid *ptv); -private: +private: typedef pset Pointers; Pointers _pointers; MutexImpl _lock; diff --git a/panda/src/express/windowsRegistry.cxx b/panda/src/express/windowsRegistry.cxx index 60865ddfad..183a3a9c0d 100644 --- a/panda/src/express/windowsRegistry.cxx +++ b/panda/src/express/windowsRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: windowsRegistry.cxx -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowsRegistry.cxx + * @author drose + * @date 2001-08-06 + */ #include "windowsRegistry.h" #include "config_express.h" @@ -22,16 +21,12 @@ #endif #include -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::set_string_value -// Access: Published, Static -// Description: Sets the registry key to the indicated value as a -// string. The supplied string value is automatically -// converted from whatever encoding is set by -// TextEncoder::set_default_encoding() and written as a -// Unicode string. The registry key must already exist -// prior to calling this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the registry key to the indicated value as a string. The supplied + * string value is automatically converted from whatever encoding is set by + * TextEncoder::set_default_encoding() and written as a Unicode string. The + * registry key must already exist prior to calling this function. + */ bool WindowsRegistry:: set_string_value(const string &key, const string &name, const string &value, WindowsRegistry::RegLevel rl) @@ -42,11 +37,11 @@ set_string_value(const string &key, const string &name, const string &value, bool okflag = true; // Now convert the string to Windows' idea of the correct wide-char - // encoding, so we can store it in the registry. This might well be - // the same string we just decoded from, but it might not. + // encoding, so we can store it in the registry. This might well be the + // same string we just decoded from, but it might not. - // Windows likes to have a null character trailing the string (even - // though we also pass a length). + // Windows likes to have a null character trailing the string (even though + // we also pass a length). wvalue += (wchar_t)0; int mb_result_len = WideCharToMultiByte(CP_ACP, 0, @@ -75,13 +70,10 @@ set_string_value(const string &key, const string &name, const string &value, return do_set(key, name, REG_SZ, mb_result, mb_result_len, rl); } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::set_int_value -// Access: Published, Static -// Description: Sets the registry key to the indicated value as an -// integer. The registry key must already exist prior -// to calling this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the registry key to the indicated value as an integer. The registry + * key must already exist prior to calling this function. + */ bool WindowsRegistry:: set_int_value(const string &key, const string &name, int value, WindowsRegistry::RegLevel rl) @@ -90,12 +82,10 @@ set_int_value(const string &key, const string &name, int value, return do_set(key, name, REG_DWORD, &dw, sizeof(dw), rl); } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::get_key_type -// Access: Published, Static -// Description: Returns the type of the indicated key, or T_none if -// the key is not known or is some unsupported type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the indicated key, or T_none if the key is not known or + * is some unsupported type. + */ WindowsRegistry::Type WindowsRegistry:: get_key_type(const string &key, const string &name, WindowsRegistry::RegLevel rl) @@ -118,16 +108,12 @@ get_key_type(const string &key, const string &name, } } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::get_string_value -// Access: Published, Static -// Description: Returns the value associated with the indicated -// registry key, assuming it is a string value. The -// string value is automatically encoded using -// TextEncoder::get_default_encoding(). If the key is -// not defined or is not a string type value, -// default_value is returned instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the indicated registry key, assuming it + * is a string value. The string value is automatically encoded using + * TextEncoder::get_default_encoding(). If the key is not defined or is not a + * string type value, default_value is returned instead. + */ string WindowsRegistry:: get_string_value(const string &key, const string &name, const string &default_value, @@ -145,8 +131,8 @@ get_string_value(const string &key, const string &name, return default_value; } - // Now we have to decode the MultiByte string to Unicode, and re-encode - // it according to our own encoding. + // Now we have to decode the MultiByte string to Unicode, and re-encode it + // according to our own encoding. if (data.empty()) { return data; @@ -158,11 +144,11 @@ get_string_value(const string &key, const string &name, NULL, 0); if (wide_result_len == 0) { express_cat.error() - << "Unable to convert '" << data + << "Unable to convert '" << data << "' from MultiByte to Unicode form.\n"; return data; } - + wchar_t *wide_result = (wchar_t *)alloca(wide_result_len * sizeof(wchar_t)); MultiByteToWideChar(CP_ACP, 0, data.data(), data.length(), @@ -181,14 +167,11 @@ get_string_value(const string &key, const string &name, return result; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::get_int_value -// Access: Published, Static -// Description: Returns the value associated with the indicated -// registry key, assuming it is an integer value. If -// the key is not defined or is not an integer type -// value, default_value is returned instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value associated with the indicated registry key, assuming it + * is an integer value. If the key is not defined or is not an integer type + * value, default_value is returned instead. + */ int WindowsRegistry:: get_int_value(const string &key, const string &name, int default_value, WindowsRegistry::RegLevel rl) @@ -204,19 +187,17 @@ get_int_value(const string &key, const string &name, int default_value, << "Registry key " << key << " does not contain an integer value.\n"; return default_value; } - + // Now we have a DWORD encoded in a string. nassertr(data.length() == sizeof(DWORD), default_value); DWORD dw = *(DWORD *)data.data(); return dw; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::do_set -// Access: Private, Static -// Description: The internal function to actually make all of the -// appropriate windows calls to set the registry value. -//////////////////////////////////////////////////////////////////// +/** + * The internal function to actually make all of the appropriate windows calls + * to set the registry value. + */ bool WindowsRegistry:: do_set(const string &key, const string &name, int data_type, const void *data, int data_length, @@ -240,11 +221,11 @@ do_set(const string &key, const string &name, bool okflag = true; error = - RegSetValueEx(hkey, name.c_str(), 0, data_type, + RegSetValueEx(hkey, name.c_str(), 0, data_type, (CONST BYTE *)data, data_length); if (error != ERROR_SUCCESS) { express_cat.error() - << "Unable to set registry key " << key << " name " << name + << "Unable to set registry key " << key << " name " << name << ": " << format_message(error) << "\n"; okflag = false; } @@ -259,13 +240,10 @@ do_set(const string &key, const string &name, return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::do_get -// Access: Private, Static -// Description: The internal function to actually make all of the -// appropriate windows calls to retrieve the registry -// value. -//////////////////////////////////////////////////////////////////// +/** + * The internal function to actually make all of the appropriate windows calls + * to retrieve the registry value. + */ bool WindowsRegistry:: do_get(const string &key, const string &name, int &data_type, string &data, const WindowsRegistry::RegLevel rl) @@ -287,20 +265,20 @@ do_get(const string &key, const string &name, int &data_type, string &data, bool okflag = true; - // We start with a 1K buffer; presumably that will be big enough - // most of the time. + // We start with a 1K buffer; presumably that will be big enough most of the + // time. static const size_t init_buffer_size = 1024; char init_buffer[init_buffer_size]; DWORD buffer_size = init_buffer_size; DWORD dw_data_type; error = - RegQueryValueEx(hkey, name.c_str(), 0, &dw_data_type, + RegQueryValueEx(hkey, name.c_str(), 0, &dw_data_type, (BYTE *)init_buffer, &buffer_size); if (error == ERROR_SUCCESS) { data_type = dw_data_type; - if (data_type == REG_SZ || - data_type == REG_MULTI_SZ || + if (data_type == REG_SZ || + data_type == REG_MULTI_SZ || data_type == REG_EXPAND_SZ) { // Eliminate the trailing null character for non-zero lengths. if (buffer_size > 0) // if zero, leave it @@ -311,18 +289,17 @@ do_get(const string &key, const string &name, int &data_type, string &data, } else if (error == ERROR_MORE_DATA) { // Huh, 1K wasn't big enough. Ok, get a bigger buffer. - // If we were querying HKEY_PERFORMANCE_DATA, we'd have to keep - // guessing bigger and bigger until we got it. Since we're - // querying static data for now, we can just use the size Windows - // tells us. + // If we were querying HKEY_PERFORMANCE_DATA, we'd have to keep guessing + // bigger and bigger until we got it. Since we're querying static data + // for now, we can just use the size Windows tells us. char *new_buffer = (char *)PANDA_MALLOC_ARRAY(buffer_size); error = - RegQueryValueEx(hkey, name.c_str(), 0, &dw_data_type, + RegQueryValueEx(hkey, name.c_str(), 0, &dw_data_type, (BYTE *)new_buffer, &buffer_size); if (error == ERROR_SUCCESS) { data_type = dw_data_type; - if (data_type == REG_SZ || - data_type == REG_MULTI_SZ || + if (data_type == REG_SZ || + data_type == REG_MULTI_SZ || data_type == REG_EXPAND_SZ) { // Eliminate the trailing null character for non-zero lengths. if (buffer_size > 0) // if zero, leave it @@ -335,7 +312,7 @@ do_get(const string &key, const string &name, int &data_type, string &data, if (error != ERROR_SUCCESS) { express_cat.debug() - << "Unable to get registry value " << name + << "Unable to get registry value " << name << ": " << format_message(error) << "\n"; okflag = false; } @@ -362,16 +339,13 @@ do_get(const string &key, const string &name, int &data_type, string &data, return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsRegistry::format_message -// Access: Private, Static -// Description: Returns the Windows error message associated with the -// given error code. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows error message associated with the given error code. + */ string WindowsRegistry:: format_message(int error_code) { PVOID buffer; - DWORD length = + DWORD length = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, 0, (LPTSTR)&buffer, 0, NULL); if (length == 0) { @@ -381,7 +355,7 @@ format_message(int error_code) { const char *text = (const char *)buffer; // Strip off \n's and \r's trailing the string. - while (length > 0 && + while (length > 0 && (text[length - 1] == '\r' || text[length - 1] == '\n')) { length--; } @@ -392,6 +366,3 @@ format_message(int error_code) { } #endif - - - diff --git a/panda/src/express/windowsRegistry.h b/panda/src/express/windowsRegistry.h index 91a7144752..d8fa951234 100644 --- a/panda/src/express/windowsRegistry.h +++ b/panda/src/express/windowsRegistry.h @@ -1,16 +1,15 @@ -// Filename: windowsRegistry.h -// Created by: drose (06Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowsRegistry.h + * @author drose + * @date 2001-08-06 + */ #ifndef WINDOWSREGISTRY_H #define WINDOWSREGISTRY_H @@ -20,14 +19,12 @@ // This class is only defined on Windows builds. #ifdef WIN32_VC -//////////////////////////////////////////////////////////////////// -// Class : WindowsRegistry -// Description : This class provides a hook to Python to read and -// write strings and integers to the windows registry. -// It automatically converts strings from utf-8 encoding -// and stores them in Unicode (and conversely reconverts -// them on retrieval). -//////////////////////////////////////////////////////////////////// +/** + * This class provides a hook to Python to read and write strings and integers + * to the windows registry. It automatically converts strings from utf-8 + * encoding and stores them in Unicode (and conversely reconverts them on + * retrieval). + */ class EXPCL_PANDAEXPRESS WindowsRegistry { PUBLISHED: diff --git a/panda/src/express/zStream.I b/panda/src/express/zStream.I index 93f9215e97..6385b26e67 100644 --- a/panda/src/express/zStream.I +++ b/panda/src/express/zStream.I @@ -1,42 +1,34 @@ -// Filename: zStream.I -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zStream.I + * @author drose + * @date 2002-08-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IDecompressStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecompressStream:: IDecompressStream() : istream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: IDecompressStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecompressStream:: IDecompressStream(istream *source, bool owns_source) : istream(&_buf) { open(source, owns_source); } -//////////////////////////////////////////////////////////////////// -// Function: IDecompressStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IDecompressStream &IDecompressStream:: open(istream *source, bool owns_source) { clear((ios_iostate)0); @@ -44,12 +36,10 @@ open(istream *source, bool owns_source) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: IDecompressStream::close -// Access: Public -// Description: Resets the ZStream to empty, but does not actually -// close the source istream unless owns_source was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the ZStream to empty, but does not actually close the source istream + * unless owns_source was true. + */ INLINE IDecompressStream &IDecompressStream:: close() { _buf.close_read(); @@ -57,32 +47,26 @@ close() { } -//////////////////////////////////////////////////////////////////// -// Function: OCompressStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OCompressStream:: OCompressStream() : ostream(&_buf) { } -//////////////////////////////////////////////////////////////////// -// Function: OCompressStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OCompressStream:: OCompressStream(ostream *dest, bool owns_dest, int compression_level) : - ostream(&_buf) + ostream(&_buf) { open(dest, owns_dest, compression_level); } -//////////////////////////////////////////////////////////////////// -// Function: OCompressStream::open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OCompressStream &OCompressStream:: open(ostream *dest, bool owns_dest, int compression_level) { clear((ios_iostate)0); @@ -90,15 +74,12 @@ open(ostream *dest, bool owns_dest, int compression_level) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: OCompressStream::close -// Access: Public -// Description: Resets the ZStream to empty, but does not actually -// close the dest ostream unless owns_dest was true. -//////////////////////////////////////////////////////////////////// +/** + * Resets the ZStream to empty, but does not actually close the dest ostream + * unless owns_dest was true. + */ INLINE OCompressStream &OCompressStream:: close() { _buf.close_write(); return *this; } - diff --git a/panda/src/express/zStream.cxx b/panda/src/express/zStream.cxx index 58c244a876..3151292924 100644 --- a/panda/src/express/zStream.cxx +++ b/panda/src/express/zStream.cxx @@ -1,15 +1,14 @@ -// Filename: zStream.cxx -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zStream.cxx + * @author drose + * @date 2002-08-05 + */ #include "zStream.h" diff --git a/panda/src/express/zStream.h b/panda/src/express/zStream.h index 1f4289bc2a..d060edba6c 100644 --- a/panda/src/express/zStream.h +++ b/panda/src/express/zStream.h @@ -1,16 +1,15 @@ -// Filename: zStream.h -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zStream.h + * @author drose + * @date 2002-08-05 + */ #ifndef ZSTREAM_H #define ZSTREAM_H @@ -22,18 +21,16 @@ #include "zStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : IDecompressStream -// Description : An input stream object that uses zlib to decompress -// (inflate) the input from another source stream -// on-the-fly. -// -// Attach an IDecompressStream to an existing istream that -// provides compressed data, and read the corresponding -// uncompressed data from the IDecompressStream. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An input stream object that uses zlib to decompress (inflate) the input + * from another source stream on-the-fly. + * + * Attach an IDecompressStream to an existing istream that provides compressed + * data, and read the corresponding uncompressed data from the + * IDecompressStream. + * + * Seeking is not supported. + */ class EXPCL_PANDAEXPRESS IDecompressStream : public istream { PUBLISHED: INLINE IDecompressStream(); @@ -50,18 +47,16 @@ private: ZStreamBuf _buf; }; -//////////////////////////////////////////////////////////////////// -// Class : OCompressStream -// Description : An input stream object that uses zlib to compress -// (deflate) data to another destination stream -// on-the-fly. -// -// Attach an OCompressStream to an existing ostream that will -// accept compressed data, and write your uncompressed -// source data to the OCompressStream. -// -// Seeking is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An input stream object that uses zlib to compress (deflate) data to another + * destination stream on-the-fly. + * + * Attach an OCompressStream to an existing ostream that will accept + * compressed data, and write your uncompressed source data to the + * OCompressStream. + * + * Seeking is not supported. + */ class EXPCL_PANDAEXPRESS OCompressStream : public ostream { PUBLISHED: INLINE OCompressStream(); @@ -86,5 +81,3 @@ private: #endif - - diff --git a/panda/src/express/zStreamBuf.cxx b/panda/src/express/zStreamBuf.cxx index 1ea01fe889..aae6fd0484 100644 --- a/panda/src/express/zStreamBuf.cxx +++ b/panda/src/express/zStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: zStreamBuf.cxx -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zStreamBuf.cxx + * @author drose + * @date 2002-08-05 + */ #include "zStreamBuf.h" @@ -31,11 +30,9 @@ do_zlib_free(voidpf opaque, voidpf address) { } #endif // !USE_MEMORY_NOWRAPPERS -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ZStreamBuf:: ZStreamBuf() { _source = (istream *)NULL; @@ -56,11 +53,9 @@ ZStreamBuf() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ZStreamBuf:: ~ZStreamBuf() { close_read(); @@ -70,11 +65,9 @@ ZStreamBuf:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::open_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZStreamBuf:: open_read(istream *source, bool owns_source) { _source = source; @@ -102,11 +95,9 @@ open_read(istream *source, bool owns_source) { thread_consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::close_read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZStreamBuf:: close_read() { if (_source != (istream *)NULL) { @@ -125,11 +116,9 @@ close_read() { } } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::open_write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZStreamBuf:: open_write(ostream *dest, bool owns_dest, int compression_level) { _dest = dest; @@ -157,11 +146,9 @@ open_write(ostream *dest, bool owns_dest, int compression_level) { thread_consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::close_write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZStreamBuf:: close_write() { if (_dest != (ostream *)NULL) { @@ -183,12 +170,10 @@ close_write() { } } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::overflow -// Access: Protected, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int ZStreamBuf:: overflow(int ch) { size_t n = pptr() - pbase(); @@ -206,12 +191,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::sync -// Access: Protected, Virtual -// Description: Called by the system iostream implementation to -// implement a flush operation. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system iostream implementation to implement a flush + * operation. + */ int ZStreamBuf:: sync() { if (_source != (istream *)NULL) { @@ -229,12 +212,10 @@ sync() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::underflow -// Access: Protected, Virtual -// Description: Called by the system istream implementation when its -// internal buffer needs more characters. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system istream implementation when its internal buffer needs + * more characters. + */ int ZStreamBuf:: underflow() { // Sometimes underflow() is called even if the buffer is not empty. @@ -264,11 +245,9 @@ underflow() { } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::read_chars -// Access: Private -// Description: Gets some characters from the source stream. -//////////////////////////////////////////////////////////////////// +/** + * Gets some characters from the source stream. + */ size_t ZStreamBuf:: read_chars(char *start, size_t length) { _z_source.next_out = (Bytef *)start; @@ -282,7 +261,7 @@ read_chars(char *start, size_t length) { _source->read(decompress_buffer, decompress_buffer_size); size_t read_count = _source->gcount(); eof = (read_count == 0 || _source->eof() || _source->fail()); - + _z_source.next_in = (Bytef *)decompress_buffer; _z_source.avail_in = read_count; } @@ -295,9 +274,9 @@ read_chars(char *start, size_t length) { return bytes_read; } else if (result == Z_BUF_ERROR && flush == 0) { - // We might get this if no progress is possible, for instance if - // the input stream is truncated. In this case, tell zlib to - // dump everything it's got. + // We might get this if no progress is possible, for instance if the + // input stream is truncated. In this case, tell zlib to dump + // everything it's got. flush = Z_FINISH; } else if (result < 0) { @@ -309,12 +288,10 @@ read_chars(char *start, size_t length) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::write_chars -// Access: Private -// Description: Sends some characters to the dest stream. The flush -// parameter is passed to deflate(). -//////////////////////////////////////////////////////////////////// +/** + * Sends some characters to the dest stream. The flush parameter is passed to + * deflate(). + */ void ZStreamBuf:: write_chars(const char *start, size_t length, int flush) { static const size_t compress_buffer_size = 4096; @@ -357,11 +334,9 @@ write_chars(const char *start, size_t length, int flush) { } } -//////////////////////////////////////////////////////////////////// -// Function: ZStreamBuf::show_zlib_error -// Access: Private -// Description: Reports a recent error code returned by zlib. -//////////////////////////////////////////////////////////////////// +/** + * Reports a recent error code returned by zlib. + */ void ZStreamBuf:: show_zlib_error(const char *function, int error_code, z_stream &z) { stringstream error_line; diff --git a/panda/src/express/zStreamBuf.h b/panda/src/express/zStreamBuf.h index b6897395a7..4d0b1aa7d6 100644 --- a/panda/src/express/zStreamBuf.h +++ b/panda/src/express/zStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: zStreamBuf.h -// Created by: drose (05Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zStreamBuf.h + * @author drose + * @date 2002-08-05 + */ #ifndef ZSTREAMBUF_H #define ZSTREAMBUF_H @@ -22,11 +21,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : ZStreamBuf -// Description : The streambuf object that implements -// IDecompressStream and OCompressStream. -//////////////////////////////////////////////////////////////////// +/** + * The streambuf object that implements IDecompressStream and OCompressStream. + */ class EXPCL_PANDAEXPRESS ZStreamBuf : public streambuf { public: ZStreamBuf(); @@ -60,16 +57,14 @@ private: char *_buffer; - // We need to store the decompression buffer on the class object, - // because zlib might not consume all of the input characters at - // each call to inflate(). This isn't a problem on output because - // in that case we can afford to wait until it does consume all of - // the characters we give it. + // We need to store the decompression buffer on the class object, because + // zlib might not consume all of the input characters at each call to + // inflate(). This isn't a problem on output because in that case we can + // afford to wait until it does consume all of the characters we give it. enum { - // It's not clear how large or small this buffer ought to be. It - // doesn't seem to matter much, especially since this is just a - // temporary holding area before getting copied into zlib's own - // internal buffers. + // It's not clear how large or small this buffer ought to be. It doesn't + // seem to matter much, especially since this is just a temporary holding + // area before getting copied into zlib's own internal buffers. decompress_buffer_size = 128 }; char decompress_buffer[decompress_buffer_size]; diff --git a/panda/src/ffmpeg/config_ffmpeg.cxx b/panda/src/ffmpeg/config_ffmpeg.cxx index 26ce7c07ed..115b3c31c3 100644 --- a/panda/src/ffmpeg/config_ffmpeg.cxx +++ b/panda/src/ffmpeg/config_ffmpeg.cxx @@ -1,16 +1,15 @@ -// Filename: config_ffmpeg.cxx -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ffmpeg.cxx + * @author rdb + * @date 2013-08-23 + */ #include "config_ffmpeg.h" #include "dconfig.h" @@ -77,14 +76,12 @@ ConfigVariableInt ffmpeg_read_buffer_size "This is important for performance. A typical size is that of a " "cache page, e.g. 4kb.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libffmpeg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libffmpeg() { static bool initialized = false; @@ -103,7 +100,7 @@ init_libffmpeg() { FfmpegVideo::register_with_read_factory(); FfmpegVideoCursor::register_with_read_factory(); - // Register ffmpeg as catch-all audio/video type. + // Register ffmpeg as catch-all audiovideo type. MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr(); reg->register_audio_type(&FfmpegAudio::make, "*"); reg->register_video_type(&FfmpegVideo::make, "*"); diff --git a/panda/src/ffmpeg/config_ffmpeg.h b/panda/src/ffmpeg/config_ffmpeg.h index 85d0c28696..58f81af821 100644 --- a/panda/src/ffmpeg/config_ffmpeg.h +++ b/panda/src/ffmpeg/config_ffmpeg.h @@ -1,16 +1,15 @@ -// Filename: config_ffmpeg.h -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ffmpeg.h + * @author rdb + * @date 2013-08-23 + */ #ifndef CONFIG_FFMPEG_H #define CONFIG_FFMPEG_H diff --git a/panda/src/ffmpeg/ffmpegAudio.I b/panda/src/ffmpeg/ffmpegAudio.I index 9d9bee5140..851ddfebb7 100644 --- a/panda/src/ffmpeg/ffmpegAudio.I +++ b/panda/src/ffmpeg/ffmpegAudio.I @@ -1,14 +1,12 @@ -// Filename: ffmpegAudio.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudio.I + * @author jyelon + * @date 2007-08-01 + */ diff --git a/panda/src/ffmpeg/ffmpegAudio.cxx b/panda/src/ffmpeg/ffmpegAudio.cxx index 86a69622f9..ee7fee8669 100644 --- a/panda/src/ffmpeg/ffmpegAudio.cxx +++ b/panda/src/ffmpeg/ffmpegAudio.cxx @@ -1,16 +1,15 @@ -// Filename: ffmpegAudio.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudio.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "config_ffmpeg.h" #include "ffmpegAudio.h" @@ -19,11 +18,9 @@ TypeHandle FfmpegAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudio::Constructor -// Access: Protected -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ FfmpegAudio:: FfmpegAudio(const Filename &name) : MovieAudio(name) @@ -31,20 +28,16 @@ FfmpegAudio(const Filename &name) : _filename = name; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudio::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ FfmpegAudio:: ~FfmpegAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudio::open -// Access: Published, Virtual -// Description: Open this audio, returning a MovieAudioCursor -//////////////////////////////////////////////////////////////////// +/** + * Open this audio, returning a MovieAudioCursor + */ PT(MovieAudioCursor) FfmpegAudio:: open() { PT(FfmpegAudioCursor) result = new FfmpegAudioCursor(this); @@ -56,11 +49,9 @@ open() { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudio::make -// Access: Published, Static -// Description: Obtains a MovieAudio that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieAudio that references a file. + */ PT(MovieAudio) FfmpegAudio:: make(const Filename &name) { return DCAST(MovieAudio, new FfmpegAudio(name)); diff --git a/panda/src/ffmpeg/ffmpegAudio.h b/panda/src/ffmpeg/ffmpegAudio.h index 0650b85986..6559f59ff5 100644 --- a/panda/src/ffmpeg/ffmpegAudio.h +++ b/panda/src/ffmpeg/ffmpegAudio.h @@ -1,16 +1,15 @@ -// Filename: ffmpegAudio.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudio.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FFMPEGAUDIO_H #define FFMPEGAUDIO_H @@ -20,10 +19,9 @@ class FfmpegAudioCursor; -//////////////////////////////////////////////////////////////////// -// Class : FfmpegAudio -// Description : A stream that generates a sequence of audio samples. -//////////////////////////////////////////////////////////////////// +/** + * A stream that generates a sequence of audio samples. + */ class EXPCL_FFMPEG FfmpegAudio : public MovieAudio { PUBLISHED: FfmpegAudio(const Filename &name); @@ -34,7 +32,7 @@ PUBLISHED: private: friend class FfmpegAudioCursor; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.I b/panda/src/ffmpeg/ffmpegAudioCursor.I index f9ea6be35f..ddb62da52c 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.I +++ b/panda/src/ffmpeg/ffmpegAudioCursor.I @@ -1,14 +1,12 @@ -// Filename: ffmpegAudioCursor.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudioCursor.I + * @author jyelon + * @date 2007-08-01 + */ diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index a33db26b6f..14283fe19b 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -1,16 +1,15 @@ -// Filename: ffmpegAudioCursor.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudioCursor.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "config_ffmpeg.h" #include "ffmpegAudioCursor.h" @@ -40,11 +39,9 @@ TypeHandle FfmpegAudioCursor::_type_handle; #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 #endif -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::Constructor -// Access: Protected -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ FfmpegAudioCursor:: FfmpegAudioCursor(FfmpegAudio *src) : MovieAudioCursor(src), @@ -165,8 +162,8 @@ FfmpegAudioCursor(FfmpegAudio *src) : } memset(_packet, 0, sizeof(AVPacket)); - // Align the buffer to a 64-byte boundary - // The ffmpeg codec likes this, because it uses SSE/SSE2. + // Align the buffer to a 64-byte boundary The ffmpeg codec likes this, + // because it uses SSESSE2. _buffer = _buffer_alloc; while (((size_t)_buffer) & 31) { _buffer += 1; @@ -180,21 +177,17 @@ FfmpegAudioCursor(FfmpegAudio *src) : _buffer_tail = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ FfmpegAudioCursor:: ~FfmpegAudioCursor() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::cleanup -// Access: Public -// Description: Reset to a standard inactive state. -//////////////////////////////////////////////////////////////////// +/** + * Reset to a standard inactive state. + */ void FfmpegAudioCursor:: cleanup() { if (_frame) { @@ -242,12 +235,10 @@ cleanup() { _audio_index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::fetch_packet -// Access: Protected -// Description: Fetches an audio packet and stores it in the -// packet buffer. Also sets packet_size and packet_data. -//////////////////////////////////////////////////////////////////// +/** + * Fetches an audio packet and stores it in the packet buffer. Also sets + * packet_size and packet_data. + */ void FfmpegAudioCursor:: fetch_packet() { if (_packet->data) { @@ -266,14 +257,11 @@ fetch_packet() { _packet_data = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::reload_buffer -// Access: Protected -// Description: Reloads the audio buffer by decoding audio packets -// until one of those audio packets finally yields -// some samples. If we encounter the end of the -// stream, we synthesize silence. -//////////////////////////////////////////////////////////////////// +/** + * Reloads the audio buffer by decoding audio packets until one of those audio + * packets finally yields some samples. If we encounter the end of the + * stream, we synthesize silence. + */ bool FfmpegAudioCursor:: reload_buffer() { @@ -295,8 +283,8 @@ reload_buffer() { _packet_data, _packet_size); movies_debug("avcodec_decode_audio2 returned " << len); #elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 25, 0) - // We should technically also consider resampling in this case, - // but whatever. Just upgrade your ffmpeg version if you get garbage. + // We should technically also consider resampling in this case, but + // whatever. Just upgrade your ffmpeg version if you get garbage. AVPacket pkt; av_init_packet(&pkt); pkt.data = _packet_data; @@ -352,13 +340,10 @@ reload_buffer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::seek -// Access: Protected -// Description: Seeks to a target location. Afterward, the -// packet_time is guaranteed to be less than or -// equal to the specified time. -//////////////////////////////////////////////////////////////////// +/** + * Seeks to a target location. Afterward, the packet_time is guaranteed to be + * less than or equal to the specified time. + */ void FfmpegAudioCursor:: seek(double t) { PN_int64 target_ts = (PN_int64)(t / _audio_timebase); @@ -397,14 +382,11 @@ seek(double t) { _samples_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegAudioCursor::read_samples -// Access: Public, Virtual -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void FfmpegAudioCursor:: read_samples(int n, PN_int16 *data) { int desired = n * _audio_channels; diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.h b/panda/src/ffmpeg/ffmpegAudioCursor.h index bed23b2724..6d3ddcffb1 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.h +++ b/panda/src/ffmpeg/ffmpegAudioCursor.h @@ -1,16 +1,15 @@ -// Filename: ffmpegAudioCursor.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegAudioCursor.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FFMPEGAUDIOCURSOR_H #define FFMPEGAUDIOCURSOR_H @@ -37,10 +36,9 @@ struct AVPacket; struct SwrContext; #endif -//////////////////////////////////////////////////////////////////// -// Class : FfmpegAudioCursor -// Description : A stream that generates a sequence of audio samples. -//////////////////////////////////////////////////////////////////// +/** + * A stream that generates a sequence of audio samples. + */ class EXPCL_FFMPEG FfmpegAudioCursor : public MovieAudioCursor { friend class FfmpegAudio; @@ -48,10 +46,10 @@ PUBLISHED: FfmpegAudioCursor(FfmpegAudio *src); virtual ~FfmpegAudioCursor(); virtual void seek(double offset); - + public: virtual void read_samples(int n, PN_int16 *data); - + protected: void fetch_packet(); bool reload_buffer(); diff --git a/panda/src/ffmpeg/ffmpegVideo.I b/panda/src/ffmpeg/ffmpegVideo.I index 445852a252..6ff3fc5a91 100644 --- a/panda/src/ffmpeg/ffmpegVideo.I +++ b/panda/src/ffmpeg/ffmpegVideo.I @@ -1,14 +1,12 @@ -// Filename: ffmpegVideo.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideo.I + * @author jyelon + * @date 2007-08-01 + */ diff --git a/panda/src/ffmpeg/ffmpegVideo.cxx b/panda/src/ffmpeg/ffmpegVideo.cxx index c7756c435d..a16336260e 100644 --- a/panda/src/ffmpeg/ffmpegVideo.cxx +++ b/panda/src/ffmpeg/ffmpegVideo.cxx @@ -1,16 +1,15 @@ -// Filename: ffmpegVideo.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideo.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "ffmpegVideo.h" #include "ffmpegVideoCursor.h" @@ -20,13 +19,10 @@ TypeHandle FfmpegVideo::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::Constructor -// Access: Public -// Description: Constructs an ffmpeg video that reads its contents -// from the indicate filename, which may be a file in -// the VFS. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an ffmpeg video that reads its contents from the indicate + * filename, which may be a file in the VFS. + */ FfmpegVideo:: FfmpegVideo(const Filename &name) : MovieVideo(name) @@ -34,14 +30,11 @@ FfmpegVideo(const Filename &name) : _filename = name; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::Constructor -// Access: Public -// Description: Constructs an ffmpeg video that reads its contents -// from the indicated subfile information. This is -// normally used for low-level purposes only; you would -// normally use the constructor that takes a filename. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an ffmpeg video that reads its contents from the indicated + * subfile information. This is normally used for low-level purposes only; + * you would normally use the constructor that takes a filename. + */ FfmpegVideo:: FfmpegVideo(const SubfileInfo &info) : MovieVideo(info.get_filename()) @@ -50,20 +43,16 @@ FfmpegVideo(const SubfileInfo &info) : _subfile_info = info; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::Destructor -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ FfmpegVideo:: ~FfmpegVideo() { } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieVideoCursor) FfmpegVideo:: open() { PT(FfmpegVideoCursor) result = new FfmpegVideoCursor(this); @@ -75,46 +64,36 @@ open() { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::make -// Access: Published, Static -// Description: Obtains a MovieVideo that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieVideo that references a file. + */ PT(MovieVideo) FfmpegVideo:: make(const Filename &name) { return DCAST(MovieVideo, new FfmpegVideo(name)); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// FfmpegVideo. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type FfmpegVideo. + */ void FfmpegVideo:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void FfmpegVideo:: write_datagram(BamWriter *manager, Datagram &dg) { MovieVideo::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type FfmpegVideo is encountered -// in the Bam file. It should create the FfmpegVideo -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type FfmpegVideo is encountered in the Bam file. It should create the + * FfmpegVideo and extract its information from the file. + */ TypedWritable *FfmpegVideo:: make_from_bam(const FactoryParams ¶ms) { FfmpegVideo *video = new FfmpegVideo(""); @@ -127,13 +106,10 @@ make_from_bam(const FactoryParams ¶ms) { return video; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideo::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new FfmpegVideo. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new FfmpegVideo. + */ void FfmpegVideo:: fillin(DatagramIterator &scan, BamReader *manager) { MovieVideo::fillin(scan, manager); diff --git a/panda/src/ffmpeg/ffmpegVideo.h b/panda/src/ffmpeg/ffmpegVideo.h index b042674dcf..5b38efb998 100644 --- a/panda/src/ffmpeg/ffmpegVideo.h +++ b/panda/src/ffmpeg/ffmpegVideo.h @@ -1,16 +1,15 @@ -// Filename: ffmpegVideo.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideo.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FFMPEGVIDEO_H #define FFMPEGVIDEO_H @@ -24,10 +23,9 @@ class FactoryParams; class BamWriter; class BamReader; -//////////////////////////////////////////////////////////////////// -// Class : FfmpegVideo -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_FFMPEG FfmpegVideo : public MovieVideo { PUBLISHED: FfmpegVideo(const Filename &name); @@ -45,7 +43,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.I b/panda/src/ffmpeg/ffmpegVideoCursor.I index 9fe06028ae..925dd5d1af 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.I +++ b/panda/src/ffmpeg/ffmpegVideoCursor.I @@ -1,25 +1,21 @@ -// Filename: ffmpegVideoCursor.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideoCursor.I + * @author jyelon + * @date 2007-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::FfmpegBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FfmpegVideoCursor::FfmpegBuffer:: -FfmpegBuffer(size_t block_size, double video_timebase) : +FfmpegBuffer(size_t block_size, double video_timebase) : Buffer(block_size), _begin_frame(-1), _end_frame(0), diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 87b3b48395..ec79cd40b2 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -1,16 +1,15 @@ -// Filename: ffmpegVideoCursor.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideoCursor.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "ffmpegVideoCursor.h" #include "config_ffmpeg.h" @@ -41,12 +40,9 @@ PStatCollector FfmpegVideoCursor::_export_frame_pcollector("*:FFMPEG Convert Vid #define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO #endif -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::Default Constructor -// Access: Private -// Description: This constructor is only used when reading from a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only used when reading from a bam file. + */ FfmpegVideoCursor:: FfmpegVideoCursor() : _max_readahead_frames(0), @@ -66,13 +62,10 @@ FfmpegVideoCursor() : { } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::init_from -// Access: Private -// Description: Specifies the source of the video cursor. This is -// normally called only by the constructor or when -// reading from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the source of the video cursor. This is normally called only by + * the constructor or when reading from a bam file. + */ void FfmpegVideoCursor:: init_from(FfmpegVideo *source) { nassertv(_thread == NULL && _thread_status == TS_stopped); @@ -86,7 +79,7 @@ init_from(FfmpegVideo *source) { } ReMutexHolder av_holder(_av_lock); - + #ifdef HAVE_SWSCALE nassertv(_convert_ctx == NULL); _convert_ctx = sws_getContext(_size_x, _size_y, @@ -109,7 +102,7 @@ init_from(FfmpegVideo *source) { _packet = new AVPacket; memset(_packet, 0, sizeof(AVPacket)); - + fetch_packet(0); fetch_frame(-1); _initial_dts = _begin_frame; @@ -123,13 +116,11 @@ init_from(FfmpegVideo *source) { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FfmpegVideoCursor:: -FfmpegVideoCursor(FfmpegVideo *src) : +FfmpegVideoCursor(FfmpegVideo *src) : _max_readahead_frames(0), _thread_priority(ffmpeg_thread_priority), _lock("FfmpegVideoCursor::_lock"), @@ -148,33 +139,25 @@ FfmpegVideoCursor(FfmpegVideo *src) : init_from(src); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FfmpegVideoCursor:: ~FfmpegVideoCursor() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::set_max_readahead_frames -// Access: Published -// Description: Specifies the maximum number of frames that a -// sub-thread will attempt to read ahead of the current -// frame. Setting this to a nonzero allows the video -// decoding to take place in a sub-thread, which -// smoothes out the video decoding time by spreading it -// evenly over several frames. Set this number larger -// to increase the buffer between the currently visible -// frame and the first undecoded frame; set it smaller -// to reduce memory consumption. -// -// Setting this to zero forces the video to be decoded -// in the main thread. If threading is not available in -// the Panda build, this value is always zero. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum number of frames that a sub-thread will attempt to + * read ahead of the current frame. Setting this to a nonzero allows the + * video decoding to take place in a sub-thread, which smoothes out the video + * decoding time by spreading it evenly over several frames. Set this number + * larger to increase the buffer between the currently visible frame and the + * first undecoded frame; set it smaller to reduce memory consumption. + * + * Setting this to zero forces the video to be decoded in the main thread. If + * threading is not available in the Panda build, this value is always zero. + */ void FfmpegVideoCursor:: set_max_readahead_frames(int max_readahead_frames) { #ifndef HAVE_THREADS @@ -198,29 +181,22 @@ set_max_readahead_frames(int max_readahead_frames) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::get_max_readahead_frames -// Access: Published -// Description: Returns the maximum number of frames that a -// sub-thread will attempt to read ahead of the current -// frame. See set_max_readahead_frames(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of frames that a sub-thread will attempt to read + * ahead of the current frame. See set_max_readahead_frames(). + */ int FfmpegVideoCursor:: get_max_readahead_frames() const { return _max_readahead_frames; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::set_thread_priority -// Access: Published -// Description: Changes the thread priority of the thread that -// decodes the ffmpeg video stream (if -// max_readahead_frames is nonzero). Normally you -// shouldn't mess with this, but there may be special -// cases where a precise balance of CPU utilization -// between the main thread and the various ffmpeg -// service threads may be needed. -//////////////////////////////////////////////////////////////////// +/** + * Changes the thread priority of the thread that decodes the ffmpeg video + * stream (if max_readahead_frames is nonzero). Normally you shouldn't mess + * with this, but there may be special cases where a precise balance of CPU + * utilization between the main thread and the various ffmpeg service threads + * may be needed. + */ void FfmpegVideoCursor:: set_thread_priority(ThreadPriority thread_priority) { if (_thread_priority != thread_priority) { @@ -232,28 +208,22 @@ set_thread_priority(ThreadPriority thread_priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::get_thread_priority -// Access: Published -// Description: Returns the current thread priority of the thread that -// decodes the ffmpeg video stream (if -// max_readahead_frames is nonzero). See -// set_thread_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current thread priority of the thread that decodes the ffmpeg + * video stream (if max_readahead_frames is nonzero). See + * set_thread_priority(). + */ ThreadPriority FfmpegVideoCursor:: get_thread_priority() const { return _thread_priority; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::start_thread -// Access: Published -// Description: Explicitly starts the ffmpeg decoding thread after it -// has been stopped by a call to stop_thread(). The -// thread is normally started automatically, so there is -// no need to call this method unless you have -// previously called stop_thread() for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly starts the ffmpeg decoding thread after it has been stopped by a + * call to stop_thread(). The thread is normally started automatically, so + * there is no need to call this method unless you have previously called + * stop_thread() for some reason. + */ void FfmpegVideoCursor:: start_thread() { MutexHolder holder(_lock); @@ -275,17 +245,13 @@ start_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::stop_thread -// Access: Published -// Description: Explicitly stops the ffmpeg decoding thread. There -// is normally no reason to do this unless you want to -// maintain precise control over what threads are -// consuming CPU resources. Calling this method will -// make the video update in the main thread, regardless -// of the setting of max_readahead_frames, until you -// call start_thread() again. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly stops the ffmpeg decoding thread. There is normally no reason + * to do this unless you want to maintain precise control over what threads + * are consuming CPU resources. Calling this method will make the video + * update in the main thread, regardless of the setting of + * max_readahead_frames, until you call start_thread() again. + */ void FfmpegVideoCursor:: stop_thread() { if (_thread_status != TS_stopped) { @@ -303,32 +269,27 @@ stop_thread() { thread->join(); } - // This is a good time to clean up all of the allocated frame - // objects. It's not really necessary to be holding the lock, since - // the thread is gone, but we'll grab it anyway just in case someone - // else starts the thread up again. + // This is a good time to clean up all of the allocated frame objects. It's + // not really necessary to be holding the lock, since the thread is gone, + // but we'll grab it anyway just in case someone else starts the thread up + // again. MutexHolder holder(_lock); _readahead_frames.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::is_thread_started -// Access: Published -// Description: Returns true if the thread has been started, false if -// not. This will always return false if -// max_readahead_frames is 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the thread has been started, false if not. This will + * always return false if max_readahead_frames is 0. + */ bool FfmpegVideoCursor:: is_thread_started() const { return (_thread_status != TS_stopped); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::set_time -// Access: Published, Virtual -// Description: See MovieVideoCursor::set_time(). -//////////////////////////////////////////////////////////////////// +/** + * See MovieVideoCursor::set_time(). + */ bool FfmpegVideoCursor:: set_time(double timestamp, int loop_count) { int frame = (int)(timestamp / _video_timebase + 0.5); @@ -357,9 +318,9 @@ set_time(double timestamp, int loop_count) { _current_frame = frame; if (_current_frame_buffer != NULL) { - // If we've previously returned a frame, don't bother asking for a - // next one if that frame is still valid. - return (_current_frame >= _current_frame_buffer->_end_frame || + // If we've previously returned a frame, don't bother asking for a next + // one if that frame is still valid. + return (_current_frame >= _current_frame_buffer->_end_frame || _current_frame < _current_frame_buffer->_begin_frame); } @@ -367,15 +328,13 @@ set_time(double timestamp, int loop_count) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::fetch_buffer -// Access: Public, Virtual -// Description: See MovieVideoCursor::fetch_buffer. -//////////////////////////////////////////////////////////////////// +/** + * See MovieVideoCursor::fetch_buffer. + */ PT(MovieVideoCursor::Buffer) FfmpegVideoCursor:: fetch_buffer() { MutexHolder holder(_lock); - + // If there was an error at any point, just return NULL. if (_format_ctx == (AVFormatContext *)NULL) { return NULL; @@ -391,8 +350,7 @@ fetch_buffer() { } } else { - // Threaded case. Wait for the thread to serve up the required - // frames. + // Threaded case. Wait for the thread to serve up the required frames. if (!_readahead_frames.empty()) { frame = _readahead_frames.front(); _readahead_frames.pop_front(); @@ -462,36 +420,29 @@ fetch_buffer() { return frame.p(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::make_new_buffer -// Access: Protected, Virtual -// Description: May be called by a derived class to allocate a new -// Buffer object. -//////////////////////////////////////////////////////////////////// +/** + * May be called by a derived class to allocate a new Buffer object. + */ PT(MovieVideoCursor::Buffer) FfmpegVideoCursor:: make_new_buffer() { PT(FfmpegBuffer) frame = new FfmpegBuffer(size_x() * size_y() * get_num_components(), _video_timebase); return frame.p(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::open_stream -// Access: Private -// Description: Opens the stream for the first time, or when needed -// internally. -//////////////////////////////////////////////////////////////////// +/** + * Opens the stream for the first time, or when needed internally. + */ bool FfmpegVideoCursor:: open_stream() { nassertr(!_ffvfile.is_open(), false); - // Hold the global lock while we open the file and create avcodec - // objects. + // Hold the global lock while we open the file and create avcodec objects. ReMutexHolder av_holder(_av_lock); if (!_source->get_subfile_info().is_empty()) { // Read a subfile. if (!_ffvfile.open_subfile(_source->get_subfile_info())) { - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't open " << _source->get_subfile_info() << "\n"; close_stream(); return false; @@ -500,7 +451,7 @@ open_stream() { } else { // Read a filename. if (!_ffvfile.open_vfs(_filename)) { - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't open " << _filename << "\n"; close_stream(); return false; @@ -516,12 +467,12 @@ open_stream() { #else if (av_find_stream_info(_format_ctx) < 0) { #endif - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't find stream info\n"; close_stream(); return false; } - + // Find the video stream nassertr(_video_ctx == NULL, false); for (int i = 0; i < (int)_format_ctx->nb_streams; ++i) { @@ -532,9 +483,9 @@ open_stream() { _min_fseek = (int)(3.0 / _video_timebase); } } - + if (_video_ctx == NULL) { - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't find video_ctx\n"; close_stream(); return false; @@ -542,7 +493,7 @@ open_stream() { AVCodec *pVideoCodec = avcodec_find_decoder(_video_ctx->codec_id); if (pVideoCodec == NULL) { - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't find codec\n"; close_stream(); return false; @@ -552,12 +503,12 @@ open_stream() { #else if (avcodec_open(_video_ctx, pVideoCodec) < 0) { #endif - ffmpeg_cat.info() + ffmpeg_cat.info() << "Couldn't open codec\n"; close_stream(); return false; } - + _size_x = _video_ctx->width; _size_y = _video_ctx->height; _num_components = 3; // Don't know how to implement RGBA movies yet. @@ -568,33 +519,28 @@ open_stream() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::close_stream -// Access: Private -// Description: Closes the stream, during cleanup or when needed -// internally. -//////////////////////////////////////////////////////////////////// +/** + * Closes the stream, during cleanup or when needed internally. + */ void FfmpegVideoCursor:: close_stream() { // Hold the global lock while we free avcodec objects. ReMutexHolder av_holder(_av_lock); - + if ((_video_ctx)&&(_video_ctx->codec)) { avcodec_close(_video_ctx); } _video_ctx = NULL; - + _ffvfile.close(); _format_ctx = NULL; _video_index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::cleanup -// Access: Private -// Description: Reset to a standard inactive state. -//////////////////////////////////////////////////////////////////// +/** + * Reset to a standard inactive state. + */ void FfmpegVideoCursor:: cleanup() { stop_thread(); @@ -629,22 +575,17 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::st_thread_main -// Access: Private, Static -// Description: The thread main function, static version (for passing -// to GenericThread). -//////////////////////////////////////////////////////////////////// +/** + * The thread main function, static version (for passing to GenericThread). + */ void FfmpegVideoCursor:: st_thread_main(void *self) { ((FfmpegVideoCursor *)self)->thread_main(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::thread_main -// Access: Private -// Description: The thread main function. -//////////////////////////////////////////////////////////////////// +/** + * The thread main function. + */ void FfmpegVideoCursor:: thread_main() { if (ffmpeg_cat.is_spam()) { @@ -659,9 +600,9 @@ thread_main() { MutexHolder holder(_lock); _readahead_frames.push_back(frame); } - - // Now repeatedly wait for something interesting to do, until we're told - // to shut down. + + // Now repeatedly wait for something interesting to do, until we're told to + // shut down. MutexHolder holder(_lock); while (_thread_status != TS_shutdown) { nassertv(_thread_status != TS_stopped); @@ -683,14 +624,11 @@ thread_main() { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_poll -// Access: Private -// Description: Called within the sub-thread. Assumes the lock is -// already held. If there is something for the thread -// to do, does it and returns true. If there is nothing -// for the thread to do, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Assumes the lock is already held. If there + * is something for the thread to do, does it and returns true. If there is + * nothing for the thread to do, returns false. + */ bool FfmpegVideoCursor:: do_poll() { switch (_thread_status) { @@ -699,7 +637,7 @@ do_poll() { // This shouldn't be possible while the thread is running. nassertr(false, false); return false; - + case TS_wait: // The video hasn't started playing yet. return false; @@ -759,40 +697,30 @@ do_poll() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_alloc_frame -// Access: Private -// Description: Allocates a new Buffer object. Assumes the lock is -// held. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Buffer object. Assumes the lock is held. + */ PT(FfmpegVideoCursor::FfmpegBuffer) FfmpegVideoCursor:: do_alloc_frame() { PT(Buffer) buffer = make_new_buffer(); return (FfmpegBuffer *)buffer.p(); } - -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_clear_all_frames -// Access: Private -// Description: Empties the entire readahead_frames queue. -// Assumes the lock is held. -//////////////////////////////////////////////////////////////////// + +/** + * Empties the entire readahead_frames queue. Assumes the lock is held. + */ void FfmpegVideoCursor:: do_clear_all_frames() { _readahead_frames.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::fetch_packet -// Access: Private -// Description: Called within the sub-thread. Fetches a video packet -// and stores it in the packet0 buffer. Sets packet_frame -// to the packet's timestamp. If a packet could not be -// read, the packet is cleared and the packet_frame is -// set to the specified default value. Returns true on -// failure (such as the end of the video), or false on -// success. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Fetches a video packet and stores it in the + * packet0 buffer. Sets packet_frame to the packet's timestamp. If a packet + * could not be read, the packet is cleared and the packet_frame is set to the + * specified default value. Returns true on failure (such as the end of the + * video), or false on success. + */ bool FfmpegVideoCursor:: fetch_packet(int default_frame) { if (ffmpeg_global_lock) { @@ -803,12 +731,9 @@ fetch_packet(int default_frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_fetch_packet -// Access: Private -// Description: As above, with the ffmpeg global lock held (if -// configured on). -//////////////////////////////////////////////////////////////////// +/** + * As above, with the ffmpeg global lock held (if configured on). + */ bool FfmpegVideoCursor:: do_fetch_packet(int default_frame) { if (_packet->data) { @@ -841,17 +766,13 @@ do_fetch_packet(int default_frame) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::fetch_frame -// Access: Private -// Description: Called within the sub-thread. Slides forward until -// the indicated frame, then fetches a frame from the -// stream and stores it in the frame buffer. Sets -// _begin_frame and _end_frame to indicate the extents of -// the frame. Sets _frame_ready true to indicate a -// frame is now available, or false if it is not (for -// instance, because the end of the video was reached). -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Slides forward until the indicated frame, + * then fetches a frame from the stream and stores it in the frame buffer. + * Sets _begin_frame and _end_frame to indicate the extents of the frame. + * Sets _frame_ready true to indicate a frame is now available, or false if it + * is not (for instance, because the end of the video was reached). + */ void FfmpegVideoCursor:: fetch_frame(int frame) { PStatTimer timer(_fetch_buffer_pcollector); @@ -861,8 +782,8 @@ fetch_frame(int frame) { if (_packet_frame <= frame) { finished = 0; - // Get the next packet. The first packet beyond the frame we're - // looking for marks the point to stop. + // Get the next packet. The first packet beyond the frame we're looking + // for marks the point to stop. while (_packet_frame <= frame) { PStatTimer timer(_seek_pcollector); @@ -890,12 +811,10 @@ fetch_frame(int frame) { _frame_ready = true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::decode_frame -// Access: Private -// Description: Called within the sub-thread. Decodes the data in -// the specified packet into _frame. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Decodes the data in the specified packet + * into _frame. + */ void FfmpegVideoCursor:: decode_frame(int &finished) { if (ffmpeg_global_lock) { @@ -906,12 +825,9 @@ decode_frame(int &finished) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_decode_frame -// Access: Private -// Description: As above, with the ffmpeg global lock held (if -// configured on). -//////////////////////////////////////////////////////////////////// +/** + * As above, with the ffmpeg global lock held (if configured on). + */ void FfmpegVideoCursor:: do_decode_frame(int &finished) { #if LIBAVCODEC_VERSION_INT < 3414272 @@ -922,13 +838,10 @@ do_decode_frame(int &finished) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::seek -// Access: Private -// Description: Called within the sub-thread. Seeks to a target -// location. Afterward, the packet_frame is guaranteed -// to be less than or equal to the specified frame. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Seeks to a target location. Afterward, the + * packet_frame is guaranteed to be less than or equal to the specified frame. + */ void FfmpegVideoCursor:: seek(int frame, bool backward) { PStatTimer timer(_seek_pcollector); @@ -949,13 +862,10 @@ seek(int frame, bool backward) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::do_seek -// Access: Private -// Description: As above, with the ffmpeg global lock held (if -// configured on). Also only if ffmpeg-support-seek is -// on. -//////////////////////////////////////////////////////////////////// +/** + * As above, with the ffmpeg global lock held (if configured on). Also only + * if ffmpeg-support-seek is on. + */ void FfmpegVideoCursor:: do_seek(int frame, bool backward) { PN_int64 target_ts = (PN_int64)frame; @@ -967,20 +877,20 @@ do_seek(int frame, bool backward) { if (backward) { flags = AVSEEK_FLAG_BACKWARD; } - + if (av_seek_frame(_format_ctx, _video_index, target_ts, flags) < 0) { if (ffmpeg_cat.is_spam()) { ffmpeg_cat.spam() << "Seek failure.\n"; } - + if (backward) { // Now try to seek forward. reset_stream(); seek(frame, false); return; } - + // Try a binary search to get a little closer. if (binary_seek(_initial_dts, frame, frame, 1) < 0) { if (ffmpeg_cat.is_spam()) { @@ -996,19 +906,16 @@ do_seek(int frame, bool backward) { fetch_frame(-1); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::binary_seek -// Access: Private -// Description: Casts about within the stream for a reasonably-close -// frame to seek to. We're trying to get as close as -// possible to target_frame. -//////////////////////////////////////////////////////////////////// +/** + * Casts about within the stream for a reasonably-close frame to seek to. + * We're trying to get as close as possible to target_frame. + */ int FfmpegVideoCursor:: binary_seek(int min_frame, int max_frame, int target_frame, int num_iterations) { int try_frame = (min_frame + max_frame) / 2; if (num_iterations > 5 || try_frame >= max_frame) { // Success. - return 0; + return 0; } if (av_seek_frame(_format_ctx, _video_index, try_frame, AVSEEK_FLAG_BACKWARD) < 0) { @@ -1025,12 +932,10 @@ binary_seek(int min_frame, int max_frame, int target_frame, int num_iterations) return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::reset_stream -// Access: Private -// Description: Resets the stream to its initial, first-opened state -// by closing and re-opening it. -//////////////////////////////////////////////////////////////////// +/** + * Resets the stream to its initial, first-opened state by closing and re- + * opening it. + */ void FfmpegVideoCursor:: reset_stream() { if (ffmpeg_cat.is_spam()) { @@ -1050,12 +955,10 @@ reset_stream() { fetch_frame(-1); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::advance_to_frame -// Access: Private -// Description: Called within the sub-thread. Advance until the -// specified frame is in the export buffer. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Advance until the specified frame is in the + * export buffer. + */ void FfmpegVideoCursor:: advance_to_frame(int frame) { PStatTimer timer(_fetch_buffer_pcollector); @@ -1102,14 +1005,13 @@ advance_to_frame(int frame) { fetch_frame(frame); } else { - // Frame is in the far future. Seek forward, then read. - // There's a danger here: because keyframes are spaced - // unpredictably, trying to seek forward could actually - // move us backward in the stream! This must be avoided. - // So the rule is, try the seek. If it hurts us by moving - // us backward, we increase the minimum threshold distance - // for forward-seeking in the future. - + // Frame is in the far future. Seek forward, then read. There's a danger + // here: because keyframes are spaced unpredictably, trying to seek + // forward could actually move us backward in the stream! This must be + // avoided. So the rule is, try the seek. If it hurts us by moving us + // backward, we increase the minimum threshold distance for forward- + // seeking in the future. + if (ffmpeg_cat.is_spam()) { ffmpeg_cat.spam() << "Jumping forward to " << frame << " from " << _begin_frame << "\n"; @@ -1138,12 +1040,10 @@ advance_to_frame(int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::export_frame -// Access: Private -// Description: Called within the sub-thread. Exports the contents -// of the frame buffer into the indicated target buffer. -//////////////////////////////////////////////////////////////////// +/** + * Called within the sub-thread. Exports the contents of the frame buffer + * into the indicated target buffer. + */ void FfmpegVideoCursor:: export_frame(FfmpegBuffer *buffer) { PStatTimer timer(_export_frame_pcollector); @@ -1170,7 +1070,7 @@ export_frame(FfmpegBuffer *buffer) { nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else - img_convert((AVPicture *)_frame_out, PIX_FMT_BGR24, + img_convert((AVPicture *)_frame_out, PIX_FMT_BGR24, (AVPicture *)_frame, _video_ctx->pix_fmt, _size_x, _size_y); #endif } else { @@ -1178,45 +1078,37 @@ export_frame(FfmpegBuffer *buffer) { nassertv(_convert_ctx != NULL && _frame != NULL && _frame_out != NULL); sws_scale(_convert_ctx, _frame->data, _frame->linesize, 0, _size_y, _frame_out->data, _frame_out->linesize); #else - img_convert((AVPicture *)_frame_out, PIX_FMT_BGR24, + img_convert((AVPicture *)_frame_out, PIX_FMT_BGR24, (AVPicture *)_frame, _video_ctx->pix_fmt, _size_x, _size_y); #endif } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// FfmpegVideo. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type FfmpegVideo. + */ void FfmpegVideoCursor:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void FfmpegVideoCursor:: write_datagram(BamWriter *manager, Datagram &dg) { MovieVideoCursor::write_datagram(manager, dg); - // No need to write any additional data here--all of it comes - // implicitly from the underlying MovieVideo, which we process in - // finalize(). + // No need to write any additional data here--all of it comes implicitly + // from the underlying MovieVideo, which we process in finalize(). } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void FfmpegVideoCursor:: finalize(BamReader *) { if (_source != (MovieVideo *)NULL) { @@ -1226,14 +1118,11 @@ finalize(BamReader *) { } } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::make_from_bam -// Access: Private, Static -// Description: This function is called by the BamReader's factory -// when a new object of type FfmpegVideo is encountered -// in the Bam file. It should create the FfmpegVideo -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type FfmpegVideo is encountered in the Bam file. It should create the + * FfmpegVideo and extract its information from the file. + */ TypedWritable *FfmpegVideoCursor:: make_from_bam(const FactoryParams ¶ms) { FfmpegVideoCursor *video = new FfmpegVideoCursor; @@ -1246,35 +1135,28 @@ make_from_bam(const FactoryParams ¶ms) { return video; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::fillin -// Access: Private -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new FfmpegVideo. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new FfmpegVideo. + */ void FfmpegVideoCursor:: fillin(DatagramIterator &scan, BamReader *manager) { MovieVideoCursor::fillin(scan, manager); - - // The MovieVideoCursor gets the underlying MovieVideo pointer. We - // need a finalize callback so we can initialize ourselves once that - // has been read completely. + + // The MovieVideoCursor gets the underlying MovieVideo pointer. We need a + // finalize callback so we can initialize ourselves once that has been read + // completely. manager->register_finalize(this); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::FfmpegBuffer::compare_timestamp -// Access: Published, Virtual -// Description: Used to sort different buffers to ensure they -// correspond to the same source frame, particularly -// important when synchronizing the different pages of a -// multi-page texture. -// -// Returns 0 if the two buffers are of the same frame, -// <0 if this one comes earlier than the other one, and -// >0 if the other one comes earlier. -//////////////////////////////////////////////////////////////////// +/** + * Used to sort different buffers to ensure they correspond to the same source + * frame, particularly important when synchronizing the different pages of a + * multi-page texture. + * + * Returns 0 if the two buffers are of the same frame, <0 if this one comes + * earlier than the other one, and >0 if the other one comes earlier. + */ int FfmpegVideoCursor::FfmpegBuffer:: compare_timestamp(const Buffer *other) const { const FfmpegBuffer *fother; @@ -1287,15 +1169,11 @@ compare_timestamp(const Buffer *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVideoCursor::FfmpegBuffer::get_timestamp -// Access: Published, Virtual -// Description: Returns the nearest timestamp value of this -// particular buffer. Ideally, -// MovieVideoCursor::set_time() for this timestamp would -// return this buffer again. This need be defined only -// if compare_timestamp() is also defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nearest timestamp value of this particular buffer. Ideally, + * MovieVideoCursor::set_time() for this timestamp would return this buffer + * again. This need be defined only if compare_timestamp() is also defined. + */ double FfmpegVideoCursor::FfmpegBuffer:: get_timestamp() const { int mid_frame = (_begin_frame + _end_frame - 1) / 2; diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.h b/panda/src/ffmpeg/ffmpegVideoCursor.h index 4b5e881e3e..a44ec57490 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.h +++ b/panda/src/ffmpeg/ffmpegVideoCursor.h @@ -1,16 +1,15 @@ -// Filename: ffmpegVideoCursor.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVideoCursor.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FFMPEGVIDEOCURSOR_H #define FFMPEGVIDEOCURSOR_H @@ -35,10 +34,9 @@ struct AVPacket; struct AVFrame; struct SwsContext; -//////////////////////////////////////////////////////////////////// -// Class : FfmpegVideoCursor -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_FFMPEG FfmpegVideoCursor : public MovieVideoCursor { private: FfmpegVideoCursor(); @@ -57,7 +55,7 @@ PUBLISHED: void start_thread(); BLOCKING void stop_thread(); bool is_thread_started() const; - + public: virtual bool set_time(double timestamp, int loop_count); virtual PT(Buffer) fetch_buffer(); @@ -107,11 +105,10 @@ private: ThreadPriority _thread_priority; PT(GenericThread) _thread; - // This global Mutex protects calls to avcodec_open/close/etc. + // This global Mutex protects calls to avcodec_opencloseetc. static ReMutex _av_lock; - // Protects _readahead_frames and all the immediately following - // members. + // Protects _readahead_frames and all the immediately following members. Mutex _lock; // Condition: the thread has something to do. @@ -132,7 +129,7 @@ private: int _current_frame; PT(FfmpegBuffer) _current_frame_buffer; - + private: // The following functions will be called in the sub-thread. static void st_thread_main(void *self); @@ -178,7 +175,7 @@ private: static PStatCollector _fetch_buffer_pcollector; static PStatCollector _seek_pcollector; static PStatCollector _export_frame_pcollector; - + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); @@ -188,7 +185,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.I b/panda/src/ffmpeg/ffmpegVirtualFile.I index a66bb1a2a1..c7a65bef36 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.I +++ b/panda/src/ffmpeg/ffmpegVirtualFile.I @@ -1,35 +1,28 @@ -// Filename: ffmpegVirtualFile.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVirtualFile.I + * @author jyelon + * @date 2007-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::is_open -// Access: Public -// Description: Returns true if the stream is successfully opened, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the stream is successfully opened, false otherwise. + */ INLINE bool FfmpegVirtualFile:: is_open() const { return (_format_context != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::get_format_context -// Access: Public -// Description: Returns a pointer to the opened ffmpeg context, or -// NULL if the file was not successfully opened. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the opened ffmpeg context, or NULL if the file was not + * successfully opened. + */ INLINE AVFormatContext *FfmpegVirtualFile:: get_format_context() const { return _format_context; diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.cxx b/panda/src/ffmpeg/ffmpegVirtualFile.cxx index fd901a1ed3..df8f077406 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.cxx +++ b/panda/src/ffmpeg/ffmpegVirtualFile.cxx @@ -1,16 +1,15 @@ -// Filename: ffmpegVirtualFile.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVirtualFile.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "pandabase.h" @@ -27,11 +26,9 @@ extern "C" { #define AVSEEK_SIZE 0x10000 #endif -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FfmpegVirtualFile:: FfmpegVirtualFile() : _io_context(NULL), @@ -42,43 +39,35 @@ FfmpegVirtualFile() : { } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FfmpegVirtualFile:: ~FfmpegVirtualFile() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::Copy Constructor -// Access: Private -// Description: These objects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * These objects are not meant to be copied. + */ FfmpegVirtualFile:: FfmpegVirtualFile(const FfmpegVirtualFile ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::Copy Assignment Operator -// Access: Private -// Description: These objects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * These objects are not meant to be copied. + */ void FfmpegVirtualFile:: operator = (const FfmpegVirtualFile ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::open_vfs -// Access: Public -// Description: Opens the movie file via Panda's VFS. Returns true -// on success, false on failure. If successful, use -// get_format_context() to get the open file handle. -//////////////////////////////////////////////////////////////////// +/** + * Opens the movie file via Panda's VFS. Returns true on success, false on + * failure. If successful, use get_format_context() to get the open file + * handle. + */ bool FfmpegVirtualFile:: open_vfs(const Filename &filename) { close(); @@ -106,8 +95,9 @@ open_vfs(const Filename &filename) { _size = vfile->get_file_size(_in); // NOTE: The AVIO system owns the buffer after allocation and may realloc it - // internally. Therefore, when we're done with the buffer, we use - // _io_context->buffer to deallocate it rather than holding on to this pointer. + // internally. Therefore, when we're done with the buffer, we use + // _io_context->buffer to deallocate it rather than holding on to this + // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, &read_packet, 0, &seek); @@ -130,14 +120,11 @@ open_vfs(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::open_subfile -// Access: Public -// Description: Opens the movie file directly from a file on disk -// (does not go through the VFS). Returns true on -// success, false on failure. If successful, use -// get_format_context() to get the open file handle. -//////////////////////////////////////////////////////////////////// +/** + * Opens the movie file directly from a file on disk (does not go through the + * VFS). Returns true on success, false on failure. If successful, use + * get_format_context() to get the open file handle. + */ bool FfmpegVirtualFile:: open_subfile(const SubfileInfo &info) { close(); @@ -160,8 +147,9 @@ open_subfile(const SubfileInfo &info) { _in->seekg(_start); // NOTE: The AVIO system owns the buffer after allocation and may realloc it - // internally. Therefore, when we're done with the buffer, we use - // _io_context->buffer to deallocate it rather than holding on to this pointer. + // internally. Therefore, when we're done with the buffer, we use + // _io_context->buffer to deallocate it rather than holding on to this + // pointer. unsigned char *buffer = (unsigned char*) av_malloc(_buffer_size); _io_context = avio_alloc_context(buffer, _buffer_size, 0, (void*) this, &read_packet, 0, &seek); @@ -184,12 +172,10 @@ open_subfile(const SubfileInfo &info) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::close -// Access: Public -// Description: Explicitly closes the opened file. This is also -// called implicitly by the destructor if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly closes the opened file. This is also called implicitly by the + * destructor if necessary. + */ void FfmpegVirtualFile:: close() { if (_format_context != NULL) { @@ -217,12 +203,10 @@ close() { _in = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::register_protocol -// Access: Public, Static -// Description: Should be called at startup to attach the appropriate -// hooks between Panda and FFMpeg. -//////////////////////////////////////////////////////////////////// +/** + * Should be called at startup to attach the appropriate hooks between Panda + * and FFMpeg. + */ void FfmpegVirtualFile:: register_protocol() { static bool initialized = false; @@ -230,8 +214,7 @@ register_protocol() { return; } - // Here's a good place to call this global ffmpeg initialization - // function. + // Here's a good place to call this global ffmpeg initialization function. av_register_all(); // And this one. @@ -243,19 +226,17 @@ register_protocol() { av_log_set_callback(&log_callback); } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::read_packet -// Access: Private, Static -// Description: A callback to read a virtual file. -//////////////////////////////////////////////////////////////////// +/** + * A callback to read a virtual file. + */ int FfmpegVirtualFile:: read_packet(void *opaque, uint8_t *buf, int size) { streampos ssize = (streampos)size; FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; istream *in = self->_in; - // Since we may be simulating a subset of the opened stream, don't - // allow it to read past the "end". + // Since we may be simulating a subset of the opened stream, don't allow it + // to read past the "end". streampos remaining = self->_start + (streampos)self->_size - in->tellg(); if (remaining < ssize) { if (remaining <= 0) { @@ -272,11 +253,9 @@ read_packet(void *opaque, uint8_t *buf, int size) { return (int)gc; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::seek -// Access: Private, Static -// Description: A callback to change the read position on an istream. -//////////////////////////////////////////////////////////////////// +/** + * A callback to change the read position on an istream. + */ int64_t FfmpegVirtualFile:: seek(void *opaque, int64_t pos, int whence) { FfmpegVirtualFile *self = (FfmpegVirtualFile *) opaque; @@ -292,8 +271,8 @@ seek(void *opaque, int64_t pos, int whence) { break; case SEEK_END: - // For seeks relative to the end, we actually compute the end - // based on _start + _size, and then use ios::beg. + // For seeks relative to the end, we actually compute the end based on + // _start + _size, and then use ios::beg. in->seekg(self->_start + (streampos)self->_size + (streampos)pos, ios::beg); break; @@ -311,12 +290,10 @@ seek(void *opaque, int64_t pos, int whence) { return in->tellg() - self->_start; } -//////////////////////////////////////////////////////////////////// -// Function: FfmpegVirtualFile::log_callback -// Access: Private, Static -// Description: These callbacks are made when ffmpeg wants to write a -// log entry; it redirects into Panda's notify. -//////////////////////////////////////////////////////////////////// +/** + * These callbacks are made when ffmpeg wants to write a log entry; it + * redirects into Panda's notify. + */ void FfmpegVirtualFile:: log_callback(void *ptr, int level, const char *fmt, va_list v1) { NotifySeverity severity; diff --git a/panda/src/ffmpeg/ffmpegVirtualFile.h b/panda/src/ffmpeg/ffmpegVirtualFile.h index 083e28174f..746fec67a0 100644 --- a/panda/src/ffmpeg/ffmpegVirtualFile.h +++ b/panda/src/ffmpeg/ffmpegVirtualFile.h @@ -1,16 +1,15 @@ -// Filename: ffmpegVirtualFile.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ffmpegVirtualFile.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef FFMPEGVIRTUALFILE_H #define FFMPEGVIRTUALFILE_H @@ -28,12 +27,10 @@ extern "C" { struct URLContext; struct AVFormatContext; -//////////////////////////////////////////////////////////////////// -// Class : FfmpegVirtualFile -// Description : Enables ffmpeg to access panda's VFS. Create an -// instance of the FfmpegVirtualFile for each ffmpeg -// stream you wish to open. -//////////////////////////////////////////////////////////////////// +/** + * Enables ffmpeg to access panda's VFS. Create an instance of the + * FfmpegVirtualFile for each ffmpeg stream you wish to open. + */ class EXPCL_FFMPEG FfmpegVirtualFile { public: FfmpegVirtualFile(); diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index 7c49fa3113..aed06fa8ed 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -1,25 +1,24 @@ -// Filename: config_framework.cxx -// Created by: drose (06Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_framework.cxx + * @author drose + * @date 2000-09-06 + */ #include "config_framework.h" #include "dconfig.h" #include "windowFramework.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to load libframework.so/.dll will fail if they -// inadvertently link with the wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to +// load libframework.so.dll will fail if they inadvertently link with the +// wrong version of libdtool.so.dll. #include "checkPandaVersion.h" diff --git a/panda/src/framework/config_framework.h b/panda/src/framework/config_framework.h index 070bcfa721..28ac64f177 100644 --- a/panda/src/framework/config_framework.h +++ b/panda/src/framework/config_framework.h @@ -1,16 +1,15 @@ -// Filename: config_framework.h -// Created by: drose (06Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_framework.h + * @author drose + * @date 2000-09-06 + */ #ifndef CONFIG_FRAMEWORK_H #define CONFIG_FRAMEWORK_H diff --git a/panda/src/framework/pandaFramework.I b/panda/src/framework/pandaFramework.I index 2e1bd88ef5..552d5bc2f2 100644 --- a/panda/src/framework/pandaFramework.I +++ b/panda/src/framework/pandaFramework.I @@ -1,25 +1,20 @@ -// Filename: pandaFramework.I -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFramework.I + * @author drose + * @date 2002-04-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_graphics_engine -// Access: Public -// Description: Returns the GraphicsEngine that is used to render all -// the windows in the framework. Normally there's no -// reason for user code to mess with this. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsEngine that is used to render all the windows in the + * framework. Normally there's no reason for user code to mess with this. + */ INLINE GraphicsEngine *PandaFramework:: get_graphics_engine() { if (_engine == (GraphicsEngine *)NULL) { @@ -31,80 +26,61 @@ get_graphics_engine() { return _engine; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_data_root -// Access: Public -// Description: Returns the root of the data graph. This is the -// graph of nodes that is traversed to control the -// inputs from user devices like the mouse and keyboard. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the data graph. This is the graph of nodes that is + * traversed to control the inputs from user devices like the mouse and + * keyboard. + */ INLINE const NodePath &PandaFramework:: get_data_root() const { return _data_root; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_event_handler -// Access: Public -// Description: Returns the EventHandler object that serves events in -// the framework. This is primarily used to dispatch on -// keypresses and such. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EventHandler object that serves events in the framework. This + * is primarily used to dispatch on keypresses and such. + */ INLINE EventHandler &PandaFramework:: get_event_handler() { return _event_handler; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_task_mgr -// Access: Public -// Description: Returns the Task Manager object that manages tasks in -// the framework. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Task Manager object that manages tasks in the framework. + */ INLINE AsyncTaskManager &PandaFramework:: get_task_mgr() { return _task_mgr; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_window_title -// Access: Public -// Description: Specifies the title that is set for all subsequently -// created windows. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the title that is set for all subsequently created windows. + */ INLINE void PandaFramework:: set_window_title(const string &title) { _window_title = title; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_num_windows -// Access: Public -// Description: Returns the number of windows that are currently -// open. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of windows that are currently open. + */ INLINE int PandaFramework:: get_num_windows() const { return _windows.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_window -// Access: Public -// Description: Returns the nth window currently open. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth window currently open. + */ INLINE WindowFramework *PandaFramework:: get_window(int n) const { nassertr(n >= 0 && n < (int)_windows.size(), NULL); return _windows[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::close_window -// Access: Public -// Description: Closes the indicated WindowFramework window and -// removes it from the list. -//////////////////////////////////////////////////////////////////// +/** + * Closes the indicated WindowFramework window and removes it from the list. + */ INLINE void PandaFramework:: close_window(WindowFramework *wf) { int n = find_window(wf); @@ -113,141 +89,110 @@ close_window(WindowFramework *wf) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_wireframe -// Access: Public -// Description: Returns the current state of the wireframe flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the wireframe flag. + */ INLINE bool PandaFramework:: get_wireframe() const { return _wireframe_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_texture -// Access: Public -// Description: Returns the current state of the texture flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the texture flag. + */ INLINE bool PandaFramework:: get_texture() const { return _texture_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_two_sided -// Access: Public -// Description: Returns the current state of the two_sided flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the two_sided flag. + */ INLINE bool PandaFramework:: get_two_sided() const { return _two_sided_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_lighting -// Access: Public -// Description: Returns the current state of the lighting flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the lighting flag. + */ INLINE bool PandaFramework:: get_lighting() const { return _lighting_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_perpixel -// Access: Public -// Description: Returns the current state of the perpixel flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the perpixel flag. + */ INLINE bool PandaFramework:: get_perpixel() const { return _perpixel_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_background_type -// Access: Public -// Description: Returns the current background type setting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current background type setting. + */ INLINE WindowFramework::BackgroundType PandaFramework:: get_background_type() const { return _background_type; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::has_highlight -// Access: Public -// Description: Returns true if any node is highlighted, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any node is highlighted, false otherwise. + */ INLINE bool PandaFramework:: has_highlight() const { return !_highlight.is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_highlight -// Access: Public -// Description: Returns the currently highlighted node, if any, or an -// empty NodePath if no node is highlighted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the currently highlighted node, if any, or an empty NodePath if no + * node is highlighted. + */ INLINE const NodePath &PandaFramework:: get_highlight() const { return _highlight; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_recorder -// Access: Public -// Description: Returns the RecorderController that has been -// associated with the PandaFramework, if any, or NULL -// if none has (the normal case). -// -// If a RecorderController is associated, it will -// presumably be used for recording user input to a -// session file, or for playing back the user input from -// a previously-recorded session. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RecorderController that has been associated with the + * PandaFramework, if any, or NULL if none has (the normal case). + * + * If a RecorderController is associated, it will presumably be used for + * recording user input to a session file, or for playing back the user input + * from a previously-recorded session. + */ INLINE RecorderController *PandaFramework:: get_recorder() const { return _recorder; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_recorder -// Access: Public -// Description: Assigns a RecorderController with the PandaFramework. -// This should be called before any windows are opened. -// The subsequently opened windows will register their -// user inputs with the recorder. -// -// If a RecorderController is associated, it will -// presumably be used for recording user input to a -// session file, or for playing back the user input from -// a previously-recorded session. -//////////////////////////////////////////////////////////////////// +/** + * Assigns a RecorderController with the PandaFramework. This should be + * called before any windows are opened. The subsequently opened windows will + * register their user inputs with the recorder. + * + * If a RecorderController is associated, it will presumably be used for + * recording user input to a session file, or for playing back the user input + * from a previously-recorded session. + */ INLINE void PandaFramework:: set_recorder(RecorderController *recorder) { _recorder = recorder; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_exit_flag -// Access: Public -// Description: Sets the flag that indicates it is time for the -// application to exit. The application will actually -// exit at the end of the current frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates it is time for the application to exit. The + * application will actually exit at the end of the current frame. + */ INLINE void PandaFramework:: set_exit_flag() { _exit_flag = true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::clear_exit_flag -// Access: Public -// Description: Resets the exit flag after it has previously been -// set. -//////////////////////////////////////////////////////////////////// +/** + * Resets the exit flag after it has previously been set. + */ INLINE void PandaFramework:: clear_exit_flag() { _exit_flag = false; diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 2f886bae29..05d4a4edb9 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -1,16 +1,15 @@ -// Filename: pandaFramework.cxx -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFramework.cxx + * @author drose + * @date 2002-04-02 + */ #include "pandaFramework.h" #include "clockObject.h" @@ -34,11 +33,9 @@ LoaderOptions PandaFramework::_loader_options; -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaFramework:: PandaFramework() : _event_handler(*EventHandler::get_global_event_handler()), @@ -60,11 +57,9 @@ PandaFramework() : _exit_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaFramework:: ~PandaFramework() { if (_is_open) { @@ -72,15 +67,12 @@ PandaFramework:: } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::open_framework -// Access: Public -// Description: Should be called once at the beginning of the -// application to initialize Panda (and the framework) -// for use. The command-line arguments should be passed -// in so Panda can remove any arguments that it -// recognizes as special control parameters. -//////////////////////////////////////////////////////////////////// +/** + * Should be called once at the beginning of the application to initialize + * Panda (and the framework) for use. The command-line arguments should be + * passed in so Panda can remove any arguments that it recognizes as special + * control parameters. + */ void PandaFramework:: open_framework(int &argc, char **&argv) { if (_is_open) { @@ -90,8 +82,8 @@ open_framework(int &argc, char **&argv) { _is_open = true; #ifdef LINK_ALL_STATIC - // If we're statically linking, we need to explicitly link with - // at least one of the available renderers. + // If we're statically linking, we need to explicitly link with at least one + // of the available renderers. #if defined(HAVE_GL) extern EXPCL_PANDAGL void init_libpandagl(); init_libpandagl(); @@ -115,8 +107,8 @@ open_framework(int &argc, char **&argv) { #endif - // Let's explicitly make a call to the image type library to ensure - // it gets pulled in by the dynamic linker. + // Let's explicitly make a call to the image type library to ensure it gets + // pulled in by the dynamic linker. extern EXPCL_PANDA_PNMIMAGETYPES void init_libpnmimagetypes(); init_libpnmimagetypes(); @@ -164,13 +156,10 @@ open_framework(int &argc, char **&argv) { _event_handler.add_hook("window-event", event_window_event, this); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::close_framework -// Access: Public -// Description: Should be called at the end of an application to -// close Panda. This is optional, as the destructor -// will do the same thing. -//////////////////////////////////////////////////////////////////// +/** + * Should be called at the end of an application to close Panda. This is + * optional, as the destructor will do the same thing. + */ void PandaFramework:: close_framework() { if (!_is_open) { @@ -203,21 +192,16 @@ close_framework() { Thread::prepare_for_exit(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_default_pipe -// Access: Public -// Description: Returns the default pipe. This is the GraphicsPipe -// that all windows in the framework will be created on, -// unless otherwise specified in open_window(). It is -// usually the primary graphics interface on the local -// machine. -// -// If the default pipe has not yet been created, this -// creates it. -// -// The return value is the default pipe, or NULL if no -// default pipe could be created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default pipe. This is the GraphicsPipe that all windows in the + * framework will be created on, unless otherwise specified in open_window(). + * It is usually the primary graphics interface on the local machine. + * + * If the default pipe has not yet been created, this creates it. + * + * The return value is the default pipe, or NULL if no default pipe could be + * created. + */ GraphicsPipe *PandaFramework:: get_default_pipe() { nassertr(_is_open, NULL); @@ -228,18 +212,14 @@ get_default_pipe() { return _default_pipe; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_mouse -// Access: Public -// Description: Returns a NodePath to the MouseAndKeyboard associated -// with the indicated GraphicsWindow object. If there's -// not yet a mouse associated with the window, creates -// one. -// -// This allows multiple WindowFramework objects that -// represent different display regions of the same -// GraphicsWindow to share the same mouse. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NodePath to the MouseAndKeyboard associated with the indicated + * GraphicsWindow object. If there's not yet a mouse associated with the + * window, creates one. + * + * This allows multiple WindowFramework objects that represent different + * display regions of the same GraphicsWindow to share the same mouse. + */ NodePath PandaFramework:: get_mouse(GraphicsOutput *window) { Mouses::iterator mi = _mouses.find(window); @@ -269,12 +249,10 @@ get_mouse(GraphicsOutput *window) { return mouse; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::remove_mouse -// Access: Public -// Description: Removes the mouse that may have been created by an -// earlier call to get_mouse(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the mouse that may have been created by an earlier call to + * get_mouse(). + */ void PandaFramework:: remove_mouse(const GraphicsOutput *window) { Mouses::iterator mi = _mouses.find(window); @@ -284,22 +262,19 @@ remove_mouse(const GraphicsOutput *window) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::define_key -// Access: Public -// Description: Sets up a handler for the indicated key. When the -// key is pressed in a window, the given callback will -// be called. The description is a one-line description -// of the function of the key, for display to the user. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a handler for the indicated key. When the key is pressed in a + * window, the given callback will be called. The description is a one-line + * description of the function of the key, for display to the user. + */ void PandaFramework:: define_key(const string &event_name, const string &description, EventHandler::EventCallbackFunction *function, void *data) { if (_event_handler.has_hook(event_name)) { - // If there is already a hook for the indicated keyname, we're - // most likely replacing a previous definition of a key. Search - // for the old definition and remove it. + // If there is already a hook for the indicated keyname, we're most likely + // replacing a previous definition of a key. Search for the old + // definition and remove it. KeyDefinitions::iterator di; di = _key_definitions.begin(); while (di != _key_definitions.end() && (*di)._event_name != event_name) { @@ -310,8 +285,7 @@ define_key(const string &event_name, const string &description, } } - // Now add a new hook for the keyname, and also add the new - // description. + // Now add a new hook for the keyname, and also add the new description. _event_handler.add_hook(event_name, function, data); if (!description.empty()) { @@ -322,18 +296,14 @@ define_key(const string &event_name, const string &description, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_default_window_props -// Access: Public, Virtual -// Description: Fills in the indicated window properties structure -// according to the normal window properties for this -// application. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the indicated window properties structure according to the normal + * window properties for this application. + */ void PandaFramework:: get_default_window_props(WindowProperties &props) { - // This function is largely vestigial and will be removed soon. We - // have moved the default window properties into - // WindowProperties::get_default(). + // This function is largely vestigial and will be removed soon. We have + // moved the default window properties into WindowProperties::get_default(). props.add_properties(WindowProperties::get_default()); if (!_window_title.empty()) { @@ -341,16 +311,12 @@ get_default_window_props(WindowProperties &props) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::open_window -// Access: Public -// Description: Opens a window on the default graphics pipe. If the -// default graphics pipe can't open a window for some -// reason, automatically fails over to the next -// available graphics pipe, and updates _default_pipe -// accordingly. Returns NULL only if all graphics pipes -// fail. -//////////////////////////////////////////////////////////////////// +/** + * Opens a window on the default graphics pipe. If the default graphics pipe + * can't open a window for some reason, automatically fails over to the next + * available graphics pipe, and updates _default_pipe accordingly. Returns + * NULL only if all graphics pipes fail. + */ WindowFramework *PandaFramework:: open_window() { GraphicsPipe *pipe = get_default_pipe(); @@ -381,20 +347,17 @@ open_window() { } } - // Too bad; none of the pipes could open a window. Fall through - // and return NULL. + // Too bad; none of the pipes could open a window. Fall through and + // return NULL. } return wf; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::open_window -// Access: Public -// Description: Opens a new window on the indicated pipe, using the -// default parameters. Returns the new WindowFramework -// if successful, or NULL if not. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new window on the indicated pipe, using the default parameters. + * Returns the new WindowFramework if successful, or NULL if not. + */ WindowFramework *PandaFramework:: open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { nassertr(_is_open, NULL); @@ -410,16 +373,13 @@ open_window(GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { return open_window(props, flags, pipe, gsg); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::open_window -// Access: Public -// Description: Opens a new window using the indicated properties. -// (You may initialize the properties to their default -// values by calling get_default_window_props() first.) -// -// Returns the new WindowFramework if successful, or -// NULL if not. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new window using the indicated properties. (You may initialize the + * properties to their default values by calling get_default_window_props() + * first.) + * + * Returns the new WindowFramework if successful, or NULL if not. + */ WindowFramework *PandaFramework:: open_window(const WindowProperties &props, int flags, GraphicsPipe *pipe, GraphicsStateGuardian *gsg) { @@ -461,13 +421,10 @@ open_window(const WindowProperties &props, int flags, return wf; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::find_window -// Access: Public -// Description: Returns the index of the first WindowFramework object -// found that references the indicated GraphicsOutput -// pointer, or -1 if none do. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the first WindowFramework object found that references + * the indicated GraphicsOutput pointer, or -1 if none do. + */ int PandaFramework:: find_window(const GraphicsOutput *win) const { int n; @@ -480,13 +437,10 @@ find_window(const GraphicsOutput *win) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::find_window -// Access: Public -// Description: Returns the index of the given WindowFramework -// object, or -1 if the object does not represent a -// window opened with this PandaFramework. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the given WindowFramework object, or -1 if the object + * does not represent a window opened with this PandaFramework. + */ int PandaFramework:: find_window(const WindowFramework *wf) const { int n; @@ -500,11 +454,9 @@ find_window(const WindowFramework *wf) const { } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::close_window -// Access: Public -// Description: Closes the nth window and removes it from the list. -//////////////////////////////////////////////////////////////////// +/** + * Closes the nth window and removes it from the list. + */ void PandaFramework:: close_window(int n) { nassertv(n >= 0 && n < (int)_windows.size()); @@ -519,12 +471,9 @@ close_window(int n) { _windows.erase(_windows.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::close_all_windows -// Access: Public -// Description: Closes all currently open windows and empties the -// list of windows. -//////////////////////////////////////////////////////////////////// +/** + * Closes all currently open windows and empties the list of windows. + */ void PandaFramework:: close_all_windows() { Windows::iterator wi; @@ -548,12 +497,10 @@ close_all_windows() { _mouses.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::all_windows_closed -// Access: Public -// Description: Returns true if all of the opened windows have been -// closed by the user, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the opened windows have been closed by the user, + * false otherwise. + */ bool PandaFramework:: all_windows_closed() const { Windows::const_iterator wi; @@ -567,14 +514,11 @@ all_windows_closed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::get_models -// Access: Public -// Description: Returns the root of the scene graph normally reserved -// for parenting models and such. This scene graph may -// be instanced to each window's render tree as the -// window is created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the scene graph normally reserved for parenting models + * and such. This scene graph may be instanced to each window's render tree + * as the window is created. + */ NodePath &PandaFramework:: get_models() { if (_models.is_empty()) { @@ -583,12 +527,9 @@ get_models() { return _models; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::report_frame_rate -// Access: Public -// Description: Reports the currently measured average frame rate to -// the indicated ostream. -//////////////////////////////////////////////////////////////////// +/** + * Reports the currently measured average frame rate to the indicated ostream. + */ void PandaFramework:: report_frame_rate(ostream &out) const { double now = ClockObject::get_global_clock()->get_frame_time(); @@ -603,22 +544,18 @@ report_frame_rate(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::reset_frame_rate -// Access: Public -// Description: Resets the frame rate computation. -//////////////////////////////////////////////////////////////////// +/** + * Resets the frame rate computation. + */ void PandaFramework:: reset_frame_rate() { _start_time = ClockObject::get_global_clock()->get_frame_time(); _frame_count = ClockObject::get_global_clock()->get_frame_count(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_wireframe -// Access: Public -// Description: Sets the wireframe state on all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the wireframe state on all windows. + */ void PandaFramework:: set_wireframe(bool enable) { Windows::iterator wi; @@ -630,11 +567,9 @@ set_wireframe(bool enable) { _wireframe_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_texture -// Access: Public -// Description: Sets the texture state on all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture state on all windows. + */ void PandaFramework:: set_texture(bool enable) { Windows::iterator wi; @@ -646,11 +581,9 @@ set_texture(bool enable) { _texture_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_two_sided -// Access: Public -// Description: Sets the two_sided state on all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the two_sided state on all windows. + */ void PandaFramework:: set_two_sided(bool enable) { Windows::iterator wi; @@ -662,11 +595,9 @@ set_two_sided(bool enable) { _two_sided_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_lighting -// Access: Public -// Description: Sets the lighting state on all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the lighting state on all windows. + */ void PandaFramework:: set_lighting(bool enable) { Windows::iterator wi; @@ -678,11 +609,9 @@ set_lighting(bool enable) { _lighting_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_perpixel -// Access: Public -// Description: Sets the perpixel state on all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the perpixel state on all windows. + */ void PandaFramework:: set_perpixel(bool enable) { Windows::iterator wi; @@ -694,11 +623,9 @@ set_perpixel(bool enable) { _perpixel_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: BackgroundFramework::set_background_type -// Access: Public -// Description: Sets the background type of all windows. -//////////////////////////////////////////////////////////////////// +/** + * Sets the background type of all windows. + */ void PandaFramework:: set_background_type(WindowFramework::BackgroundType type) { Windows::iterator wi; @@ -710,13 +637,10 @@ set_background_type(WindowFramework::BackgroundType type) { _background_type = type; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::hide_collision_solids -// Access: Public -// Description: Hides any collision solids, or occluders, which are -// visible in the indicated scene graph. Returns the -// number of nodes hidden. -//////////////////////////////////////////////////////////////////// +/** + * Hides any collision solids, or occluders, which are visible in the + * indicated scene graph. Returns the number of nodes hidden. + */ int PandaFramework:: hide_collision_solids(NodePath node) { int num_changed = 0; @@ -737,13 +661,10 @@ hide_collision_solids(NodePath node) { return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::show_collision_solids -// Access: Public -// Description: Shows any collision solids, or occluders, which are -// directly hidden in the indicated scene graph. -// Returns the number of nodes shown. -//////////////////////////////////////////////////////////////////// +/** + * Shows any collision solids, or occluders, which are directly hidden in the + * indicated scene graph. Returns the number of nodes shown. + */ int PandaFramework:: show_collision_solids(NodePath node) { int num_changed = 0; @@ -764,13 +685,11 @@ show_collision_solids(NodePath node) { return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::set_highlight -// Access: Public -// Description: Sets the indicated node (normally a node within the -// get_models() tree) up as the highlighted node. -// Certain operations affect the highlighted node only. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated node (normally a node within the get_models() tree) up + * as the highlighted node. Certain operations affect the highlighted node + * only. + */ void PandaFramework:: set_highlight(const NodePath &node) { clear_highlight(); @@ -782,11 +701,9 @@ set_highlight(const NodePath &node) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::clear_highlight -// Access: Public -// Description: Unhighlights the currently highlighted node, if any. -//////////////////////////////////////////////////////////////////// +/** + * Unhighlights the currently highlighted node, if any. + */ void PandaFramework:: clear_highlight() { if (!_highlight.is_empty()) { @@ -796,13 +713,10 @@ clear_highlight() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::enable_default_keys -// Access: Public -// Description: Sets callbacks on the event handler to handle all of -// the normal viewer keys, like t to toggle texture, ESC -// or q to quit, etc. -//////////////////////////////////////////////////////////////////// +/** + * Sets callbacks on the event handler to handle all of the normal viewer + * keys, like t to toggle texture, ESC or q to quit, etc. + */ void PandaFramework:: enable_default_keys() { if (!_default_keys_enabled) { @@ -811,14 +725,11 @@ enable_default_keys() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::do_frame -// Access: Public, Virtual -// Description: Renders one frame and performs all associated -// processing. Returns true if we should continue -// rendering, false if we should exit. This is normally -// called only from main_loop(). -//////////////////////////////////////////////////////////////////// +/** + * Renders one frame and performs all associated processing. Returns true if + * we should continue rendering, false if we should exit. This is normally + * called only from main_loop(). + */ bool PandaFramework:: do_frame(Thread *current_thread) { nassertr(_is_open, false); @@ -828,13 +739,10 @@ do_frame(Thread *current_thread) { return !_exit_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::main_loop -// Access: Public -// Description: Called to yield control to the panda framework. This -// function does not return until set_exit_flag() has -// been called. -//////////////////////////////////////////////////////////////////// +/** + * Called to yield control to the panda framework. This function does not + * return until set_exit_flag() has been called. + */ void PandaFramework:: main_loop() { Thread *current_thread = Thread::get_current_thread(); @@ -842,29 +750,24 @@ main_loop() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::make_window_framework -// Access: Protected, Virtual -// Description: Creates a new WindowFramework object. This is -// provided as a hook so derived PandaFramework classes -// can create custom WindowFramework objects. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new WindowFramework object. This is provided as a hook so + * derived PandaFramework classes can create custom WindowFramework objects. + */ PT(WindowFramework) PandaFramework:: make_window_framework() { return new WindowFramework(this); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::make_default_pipe -// Access: Protected, Virtual -// Description: Creates the default GraphicsPipe that will contain -// all windows that are not opened on a specific pipe. -//////////////////////////////////////////////////////////////////// +/** + * Creates the default GraphicsPipe that will contain all windows that are not + * opened on a specific pipe. + */ void PandaFramework:: make_default_pipe() { - // This depends on the shared library or libraries (DLL's to you - // Windows folks) that have been loaded in at runtime from the - // load-display and/or aux-display Configrc variables. + // This depends on the shared library or libraries (DLL's to you Windows + // folks) that have been loaded in at runtime from the load-display andor + // aux-display Configrc variables. GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); selection->print_pipe_types(); _default_pipe = selection->make_default_pipe(); @@ -876,11 +779,9 @@ make_default_pipe() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::do_enable_default_keys -// Access: Protected, Virtual -// Description: The implementation of enable_default_keys(). -//////////////////////////////////////////////////////////////////// +/** + * The implementation of enable_default_keys(). + */ void PandaFramework:: do_enable_default_keys() { define_key("escape", "close window", event_esc, this); @@ -910,13 +811,10 @@ do_enable_default_keys() { define_key("shift-/", "", event_question, this); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::clear_text -// Access: Protected -// Description: Removes any onscreen text (like help text or -// screenshot filename). Returns true if there was any -// text in the first place, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes any onscreen text (like help text or screenshot filename). Returns + * true if there was any text in the first place, false otherwise. + */ bool PandaFramework:: clear_text() { bool any_text = false; @@ -933,13 +831,10 @@ clear_text() { return any_text; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_esc -// Access: Public, Static -// Description: Default handler for ESC or q key: close the current -// window (and exit the application if that was the last -// window). -//////////////////////////////////////////////////////////////////// +/** + * Default handler for ESC or q key: close the current window (and exit the + * application if that was the last window). + */ void PandaFramework:: event_esc(const Event *event, void *data) { if (event->get_num_parameters() == 1) { @@ -972,12 +867,9 @@ event_esc(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_f -// Access: Public, Static -// Description: Default handler for f key: report and reset frame -// rate. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for f key: report and reset frame rate. + */ void PandaFramework:: event_f(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -985,11 +877,9 @@ event_f(const Event *, void *data) { self->reset_frame_rate(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_w -// Access: Public, Static -// Description: Default handler for w key: toggle wireframe. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for w key: toggle wireframe. + */ void PandaFramework:: event_w(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1007,11 +897,9 @@ event_w(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_t -// Access: Public, Static -// Description: Default handler for t key: toggle texture. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for t key: toggle texture. + */ void PandaFramework:: event_t(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1023,12 +911,9 @@ event_t(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_b -// Access: Public, Static -// Description: Default handler for b key: toggle backface (two-sided -// rendering). -//////////////////////////////////////////////////////////////////// +/** + * Default handler for b key: toggle backface (two-sided rendering). + */ void PandaFramework:: event_b(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1040,11 +925,9 @@ event_b(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_i -// Access: Public, Static -// Description: Default handler for i key: invert one-sided faces. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for i key: invert one-sided faces. + */ void PandaFramework:: event_i(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1056,11 +939,9 @@ event_i(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_l -// Access: Public, Static -// Description: Default handler for l key: toggle lighting. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for l key: toggle lighting. + */ void PandaFramework:: event_l(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1072,11 +953,9 @@ event_l(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_p -// Access: Public, Static -// Description: Default handler for p key: toggle per-pixel lighting. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for p key: toggle per-pixel lighting. + */ void PandaFramework:: event_p(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1088,12 +967,10 @@ event_p(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_c -// Access: Public, Static -// Description: Default handler for c key: center the trackball over -// the scene, or over the highlighted part of the scene. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for c key: center the trackball over the scene, or over the + * highlighted part of the scene. + */ void PandaFramework:: event_c(const Event *event, void *data) { if (event->get_num_parameters() == 1) { @@ -1111,12 +988,9 @@ event_c(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_a -// Access: Public, Static -// Description: Default handler for a key: toggle the animation -// controls. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for a key: toggle the animation controls. + */ void PandaFramework:: event_a(const Event *event, void *data) { if (event->get_num_parameters() == 1) { @@ -1128,12 +1002,9 @@ event_a(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_C -// Access: Public, Static -// Description: Default handler for shift-C key: toggle the showing -// of collision solids. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for shift-C key: toggle the showing of collision solids. + */ void PandaFramework:: event_C(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1148,13 +1019,10 @@ event_C(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_B -// Access: Public, Static -// Description: Default handler for shift-B key: describe the -// bounding volume of the currently selected object, or -// the entire scene. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for shift-B key: describe the bounding volume of the + * currently selected object, or the entire scene. + */ void PandaFramework:: event_B(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1167,12 +1035,10 @@ event_B(const Event *, void *data) { node.get_bounds()->write(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_L -// Access: Public, Static -// Description: Default handler for shift-L key: list the contents of -// the scene graph, or the highlighted node. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for shift-L key: list the contents of the scene graph, or + * the highlighted node. + */ void PandaFramework:: event_L(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1185,12 +1051,10 @@ event_L(const Event *, void *data) { node.ls(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_A -// Access: Public, Static -// Description: Default handler for shift-A key: analyze the contents -// of the scene graph, or the highlighted node. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for shift-A key: analyze the contents of the scene graph, + * or the highlighted node. + */ void PandaFramework:: event_A(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1205,13 +1069,10 @@ event_A(const Event *, void *data) { sga.write(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_h -// Access: Public, Static -// Description: Default handler for h key: toggle highlight mode. In -// this mode, you can walk the scene graph with the -// arrow keys to highlight different nodes. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for h key: toggle highlight mode. In this mode, you can + * walk the scene graph with the arrow keys to highlight different nodes. + */ void PandaFramework:: event_h(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1223,12 +1084,10 @@ event_h(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_arrow_up -// Access: Public, Static -// Description: Default handler for up arrow key: in highlight mode, -// move the highlight to the node's parent. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for up arrow key: in highlight mode, move the highlight to + * the node's parent. + */ void PandaFramework:: event_arrow_up(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1241,12 +1100,10 @@ event_arrow_up(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_arrow_down -// Access: Public, Static -// Description: Default handler for up arrow key: in highlight mode, -// move the highlight to the node's first child. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for up arrow key: in highlight mode, move the highlight to + * the node's first child. + */ void PandaFramework:: event_arrow_down(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1259,13 +1116,10 @@ event_arrow_down(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_arrow_left -// Access: Public, Static -// Description: Default handler for up arrow key: in highlight mode, -// move the highlight to the node's nearest sibling on -// the left. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for up arrow key: in highlight mode, move the highlight to + * the node's nearest sibling on the left. + */ void PandaFramework:: event_arrow_left(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1284,13 +1138,10 @@ event_arrow_left(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_arrow_right -// Access: Public, Static -// Description: Default handler for up arrow key: in highlight mode, -// move the highlight to the node's nearest sibling on -// the right. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for up arrow key: in highlight mode, move the highlight to + * the node's nearest sibling on the right. + */ void PandaFramework:: event_arrow_right(const Event *, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1310,11 +1161,9 @@ event_arrow_right(const Event *, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_S -// Access: Public, Static -// Description: Default handler for shift-S key: activate stats. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for shift-S key: activate stats. + */ void PandaFramework:: event_S(const Event *, void *) { #ifdef DO_PSTATS @@ -1325,11 +1174,9 @@ event_S(const Event *, void *) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_f9 -// Access: Public, Static -// Description: Default handler for f9 key: take screenshot. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for f9 key: take screenshot. + */ void PandaFramework:: event_f9(const Event *event, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1374,11 +1221,9 @@ event_f9(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_comma -// Access: Public, Static -// Description: Default handler for comma key: rotate background color. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for comma key: rotate background color. + */ void PandaFramework:: event_comma(const Event *event, void *) { if (event->get_num_parameters() == 1) { @@ -1401,11 +1246,9 @@ event_comma(const Event *event, void *) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_question -// Access: Public, Static -// Description: Default handler for ? key: show the available keys. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for ? key: show the available keys. + */ void PandaFramework:: event_question(const Event *event, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1456,19 +1299,16 @@ event_question(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::event_window_event -// Access: Public, Static -// Description: Default handler for window events: window resized or -// closed, etc. -//////////////////////////////////////////////////////////////////// +/** + * Default handler for window events: window resized or closed, etc. + */ void PandaFramework:: event_window_event(const Event *event, void *data) { PandaFramework *self = (PandaFramework *)data; if (event->get_num_parameters() == 1) { - // The parameter of the window event is the window itself, rather - // than the window framework object (which is the parameter of all - // of the keyboard events). + // The parameter of the window event is the window itself, rather than the + // window framework object (which is the parameter of all of the keyboard + // events). EventParameter param = event->get_parameter(0); const GraphicsOutput *win; DCAST_INTO_V(win, param.get_ptr()); @@ -1509,12 +1349,10 @@ event_window_event(const Event *event, void *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_data_loop -// Access: Public, Static -// Description: Called once per frame to process the data graph (which -// handles user input via the mouse and keyboard, etc.) -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame to process the data graph (which handles user input + * via the mouse and keyboard, etc.) + */ AsyncTask::DoneStatus PandaFramework:: task_data_loop(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1525,11 +1363,9 @@ task_data_loop(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_event -// Access: Public, Static -// Description: Called once per frame to process the pending events. -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame to process the pending events. + */ AsyncTask::DoneStatus PandaFramework:: task_event(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1540,11 +1376,9 @@ task_event(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_igloop -// Access: Public, Static -// Description: Called once per frame to render the scene. -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame to render the scene. + */ AsyncTask::DoneStatus PandaFramework:: task_igloop(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1556,12 +1390,10 @@ task_igloop(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_record_frame -// Access: Public, Static -// Description: Called once per frame to ask the recorder to record -// the user input data, if enabled. -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame to ask the recorder to record the user input data, if + * enabled. + */ AsyncTask::DoneStatus PandaFramework:: task_record_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1573,12 +1405,10 @@ task_record_frame(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_play_frame -// Access: Public, Static -// Description: Called once per frame to ask the recorder to play back -// the user input data, if enabled. -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame to ask the recorder to play back the user input data, + * if enabled. + */ AsyncTask::DoneStatus PandaFramework:: task_play_frame(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1590,11 +1420,9 @@ task_play_frame(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_clear_text -// Access: Public, Static -// Description: Called once to remove the screenshot text from onscreen. -//////////////////////////////////////////////////////////////////// +/** + * Called once to remove the screenshot text from onscreen. + */ AsyncTask::DoneStatus PandaFramework:: task_clear_text(GenericAsyncTask *task, void *data) { PandaFramework *self = (PandaFramework *)data; @@ -1603,14 +1431,11 @@ task_clear_text(GenericAsyncTask *task, void *data) { return AsyncTask::DS_cont; } -//////////////////////////////////////////////////////////////////// -// Function: PandaFramework::task_garbage_collect -// Access: Public, Static -// Description: This task is created automatically if -// garbage_collect_states is true. It calls the needed -// TransformState::garbage_collect() and -// RenderState::garbage_collect() methods each frame. -//////////////////////////////////////////////////////////////////// +/** + * This task is created automatically if garbage_collect_states is true. It + * calls the needed TransformState::garbage_collect() and + * RenderState::garbage_collect() methods each frame. + */ AsyncTask::DoneStatus PandaFramework:: task_garbage_collect(GenericAsyncTask *task, void *data) { TransformState::garbage_collect(); diff --git a/panda/src/framework/pandaFramework.h b/panda/src/framework/pandaFramework.h index b675edd3dd..46df0f3bdd 100644 --- a/panda/src/framework/pandaFramework.h +++ b/panda/src/framework/pandaFramework.h @@ -1,16 +1,15 @@ -// Filename: pandaFramework.h -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaFramework.h + * @author drose + * @date 2002-04-02 + */ #ifndef PANDAFRAMEWORK_H #define PANDAFRAMEWORK_H @@ -32,12 +31,10 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : PandaFramework -// Description : This class serves to provide a high-level framework -// for basic applications that use Panda in simple ways -// (like opening a window to view models, etc.). -//////////////////////////////////////////////////////////////////// +/** + * This class serves to provide a high-level framework for basic applications + * that use Panda in simple ways (like opening a window to view models, etc.). + */ class EXPCL_FRAMEWORK PandaFramework { public: PandaFramework(); @@ -54,7 +51,7 @@ public: NodePath get_mouse(GraphicsOutput *window); void remove_mouse(const GraphicsOutput *window); - void define_key(const string &event_name, + void define_key(const string &event_name, const string &description, EventHandler::EventCallbackFunction *function, void *data); @@ -200,7 +197,7 @@ private: bool _default_keys_enabled; bool _exit_flag; - + class KeyDefinition { public: string _event_name; diff --git a/panda/src/framework/windowFramework.I b/panda/src/framework/windowFramework.I index d729cc0019..6cd1da7d64 100644 --- a/panda/src/framework/windowFramework.I +++ b/panda/src/framework/windowFramework.I @@ -1,36 +1,28 @@ -// Filename: windowFramework.I -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowFramework.I + * @author drose + * @date 2002-04-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_panda_framework -// Access: Public -// Description: Returns a pointer to the associated PandaFramework -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the associated PandaFramework object. + */ INLINE PandaFramework *WindowFramework:: get_panda_framework() const { return _panda_framework; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_graphics_window -// Access: Public -// Description: Returns a pointer to the underlying GraphicsWindow -// object, if it is in fact a window; or NULL if it is -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the underlying GraphicsWindow object, if it is in fact + * a window; or NULL if it is not. + */ INLINE GraphicsWindow *WindowFramework:: get_graphics_window() const { if (_window != (GraphicsOutput *)NULL && @@ -40,149 +32,116 @@ get_graphics_window() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_graphics_output -// Access: Public -// Description: Returns a pointer to the underlying GraphicsOutput -// object -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the underlying GraphicsOutput object + */ INLINE GraphicsOutput *WindowFramework:: get_graphics_output() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_num_cameras -// Access: Public -// Description: Returns the number of 3-d cameras associated with the -// window. A window usually has only one camera, but it -// may have multiple cameras if there are multiple -// display regions within the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of 3-d cameras associated with the window. A window + * usually has only one camera, but it may have multiple cameras if there are + * multiple display regions within the window. + */ INLINE int WindowFramework:: get_num_cameras() const { return _cameras.size(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_camera -// Access: Public -// Description: Returns the nth camera associated with the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth camera associated with the window. + */ INLINE Camera *WindowFramework:: get_camera(int n) const { nassertr(n >= 0 && n < (int)_cameras.size(), NULL); return _cameras[n]; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_display_region_2d -// Access: Public -// Description: Returns the default DisplayRegion created for the 2-d -// scene (render2d). -//////////////////////////////////////////////////////////////////// +/** + * Returns the default DisplayRegion created for the 2-d scene (render2d). + */ INLINE DisplayRegion *WindowFramework:: get_display_region_2d() const { return _display_region_2d; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_display_region_3d -// Access: Public -// Description: Returns the default DisplayRegion created for the 3-d -// scene (render). -//////////////////////////////////////////////////////////////////// +/** + * Returns the default DisplayRegion created for the 3-d scene (render). + */ INLINE DisplayRegion *WindowFramework:: get_display_region_3d() const { return _display_region_3d; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_anim_controls -// Access: Public -// Description: Returns the current state of the anim_controls flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the anim_controls flag. + */ INLINE bool WindowFramework:: get_anim_controls() const { return _anim_controls_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_wireframe -// Access: Public -// Description: Returns the current state of the wireframe flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the wireframe flag. + */ INLINE bool WindowFramework:: get_wireframe() const { return _wireframe_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_wireframe_filled -// Access: Public -// Description: Returns the current state of the wireframe_filled -// flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the wireframe_filled flag. + */ INLINE bool WindowFramework:: get_wireframe_filled() const { return _wireframe_filled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_texture -// Access: Public -// Description: Returns the current state of the texture flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the texture flag. + */ INLINE bool WindowFramework:: get_texture() const { return _texture_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_two_sided -// Access: Public -// Description: Returns the current state of the two_sided flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the two_sided flag. + */ INLINE bool WindowFramework:: get_two_sided() const { return _two_sided_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_one_sided_reverse -// Access: Public -// Description: Returns the current state of the one_sided_reverse flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the one_sided_reverse flag. + */ INLINE bool WindowFramework:: get_one_sided_reverse() const { return _one_sided_reverse_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_lighting -// Access: Public -// Description: Returns the current state of the lighting flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the lighting flag. + */ INLINE bool WindowFramework:: get_lighting() const { return _lighting_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_perpixel -// Access: Public -// Description: Returns the current state of the perpixel flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the perpixel flag. + */ INLINE bool WindowFramework:: get_perpixel() const { return _perpixel_enabled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_background_type -// Access: Public -// Description: Returns the current background type setting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current background type setting. + */ INLINE WindowFramework::BackgroundType WindowFramework:: get_background_type() const { return _background_type; diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 9f4ea1eecb..a66963ca06 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -1,16 +1,15 @@ -// Filename: windowFramework.cxx -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowFramework.cxx + * @author drose + * @date 2002-04-02 + */ #include "windowFramework.h" #include "pandaFramework.h" @@ -54,27 +53,24 @@ #include "staticTextFont.h" #include "mouseButton.h" -// This is generated data for the standard texture we apply to the -// blue triangle. +// This is generated data for the standard texture we apply to the blue +// triangle. #include "rock_floor.rgb_src.c" -// This is generated data for shuttle_controls.bam, a bamified version -// of shuttle_controls.egg (found in the models tree). It's -// compiled in shuttle_controls.bam_src.c. +// This is generated data for shuttle_controls.bam, a bamified version of +// shuttle_controls.egg (found in the models tree). It's compiled in +// shuttle_controls.bam_src.c. #include "shuttle_controls.bam_src.c" -// This number is chosen arbitrarily to override any settings in model -// files. +// This number is chosen arbitrarily to override any settings in model files. static const int override_priority = 100; PT(TextFont) WindowFramework::_shuttle_controls_font = NULL; TypeHandle WindowFramework::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowFramework:: WindowFramework(PandaFramework *panda_framework) : _panda_framework(panda_framework) @@ -94,11 +90,9 @@ WindowFramework(PandaFramework *panda_framework) : _background_type = BT_default; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowFramework:: WindowFramework(const WindowFramework ©, DisplayRegion *display_region) : _panda_framework(copy._panda_framework), @@ -124,22 +118,18 @@ WindowFramework(const WindowFramework ©, DisplayRegion *display_region) : _display_region_3d->set_camera(camera_np); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WindowFramework:: ~WindowFramework() { close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::open_window -// Access: Protected -// Description: Opens the actual window or buffer. This is normally -// called only from PandaFramework::open_window(). -//////////////////////////////////////////////////////////////////// +/** + * Opens the actual window or buffer. This is normally called only from + * PandaFramework::open_window(). + */ GraphicsOutput *WindowFramework:: open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, GraphicsPipe *pipe, GraphicsStateGuardian *gsg, @@ -158,13 +148,13 @@ open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, props, flags, gsg, NULL); if (winout != (GraphicsOutput *)NULL) { _window = winout; - // _window->request_properties(props); + // _window->request_properties(props); // Create a display region that covers the entire window. _display_region_3d = _window->make_display_region(); - // Make sure the DisplayRegion does the clearing, not the window, - // so we can have multiple DisplayRegions of different colors. + // Make sure the DisplayRegion does the clearing, not the window, so we + // can have multiple DisplayRegions of different colors. _window->set_clear_color_active(false); _window->set_clear_depth_active(false); _window->set_clear_stencil_active(false); @@ -188,12 +178,10 @@ open_window(const WindowProperties &props, int flags, GraphicsEngine *engine, return _window; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::close_window -// Access: Protected -// Description: Closes the window or buffer. This is normally called -// from PandaFramework::close_window(). -//////////////////////////////////////////////////////////////////// +/** + * Closes the window or buffer. This is normally called from + * PandaFramework::close_window(). + */ void WindowFramework:: close_window() { _window.clear(); @@ -225,13 +213,10 @@ close_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_camera_group -// Access: Public -// Description: Returns the node above the collection of 3-d cameras -// in the scene graph. This node may be moved around to -// represent the viewpoint. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node above the collection of 3-d cameras in the scene graph. + * This node may be moved around to represent the viewpoint. + */ NodePath WindowFramework:: get_camera_group() { if (_camera_group.is_empty()) { @@ -240,11 +225,9 @@ get_camera_group() { return _camera_group; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_render -// Access: Public -// Description: Returns the root of the 3-d scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the 3-d scene graph. + */ NodePath WindowFramework:: get_render() { if (_render.is_empty()) { @@ -259,11 +242,9 @@ get_render() { return _render; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_render_2d -// Access: Public -// Description: Returns the root of the 2-d scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the 2-d scene graph. + */ NodePath WindowFramework:: get_render_2d() { if (_render_2d.is_empty()) { @@ -278,8 +259,8 @@ get_render_2d() { // Now set up a 2-d camera to view render_2d. - // Create a display region that matches the size of the 3-d - // display region. + // Create a display region that matches the size of the 3-d display + // region. PN_stdfloat l, r, b, t; _display_region_3d->get_dimensions(l, r, b, t); _display_region_2d = _window->make_mono_display_region(l, r, b, t); @@ -306,20 +287,18 @@ get_render_2d() { return _render_2d; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_aspect_2d -// Access: Public -// Description: Returns the node under the 2-d scene graph that is -// scaled to suit the window's aspect ratio. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node under the 2-d scene graph that is scaled to suit the + * window's aspect ratio. + */ NodePath WindowFramework:: get_aspect_2d() { if (_aspect_2d.is_empty()) { PGTop *top = new PGTop("aspect_2d"); _aspect_2d = get_render_2d().attach_new_node(top); - // Tell the PGTop about our MouseWatcher object, so the PGui - // system can operate. + // Tell the PGTop about our MouseWatcher object, so the PGui system can + // operate. PandaNode *mouse_node = get_mouse().node(); if (mouse_node->is_of_type(MouseWatcher::get_class_type())) { top->set_mouse_watcher(DCAST(MouseWatcher, mouse_node)); @@ -345,14 +324,11 @@ get_aspect_2d() { return _aspect_2d; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_pixel_2d -// Access: Public -// Description: Returns a special root that uses units in pixels that -// are relative to the window. The upperleft corner of -// the window is (0, 0), the lowerleft corner is -// (xsize, -ysize), in this coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special root that uses units in pixels that are relative to the + * window. The upperleft corner of the window is (0, 0), the lowerleft corner + * is (xsize, -ysize), in this coordinate system. + */ NodePath WindowFramework:: get_pixel_2d() { if (_pixel_2d.is_empty()) { @@ -376,33 +352,30 @@ get_pixel_2d() { return _pixel_2d; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_mouse -// Access: Public -// Description: Returns the node in the data graph corresponding to -// the mouse associated with this window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node in the data graph corresponding to the mouse associated + * with this window. + */ NodePath WindowFramework:: get_mouse() { if (_mouse.is_empty()) { NodePath mouse = _panda_framework->get_mouse(_window); - // Create a MouseWatcher to filter the mouse input. We do this - // mainly so we can constrain the mouse input to our particular - // display region, if we have one. This means the node we return - // from get_mouse() is actually a MouseWatcher, but since it - // presents the same interface as a Mouse, no one should mind. + // Create a MouseWatcher to filter the mouse input. We do this mainly so + // we can constrain the mouse input to our particular display region, if + // we have one. This means the node we return from get_mouse() is + // actually a MouseWatcher, but since it presents the same interface as a + // Mouse, no one should mind. - // Another advantage to using a MouseWatcher is that the PGTop of - // aspect2d likes it better. + // Another advantage to using a MouseWatcher is that the PGTop of aspect2d + // likes it better. PT(MouseWatcher) mw = new MouseWatcher("watcher"); if (_window->get_side_by_side_stereo()) { - // If the window has side-by-side stereo enabled, then - // we should constrain the MouseWatcher to the window's - // DisplayRegion. This will enable the MouseWatcher to - // track the left and right halves of the screen - // individually. + // If the window has side-by-side stereo enabled, then we should + // constrain the MouseWatcher to the window's DisplayRegion. This will + // enable the MouseWatcher to track the left and right halves of the + // screen individually. mw->set_display_region(_window->get_overlay_display_region()); } @@ -411,23 +384,19 @@ get_mouse() { return _mouse; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_button_thrower -// Access: Public -// Description: Returns the node in the data graph corresponding to -// the ButtonThrower object associated with this window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node in the data graph corresponding to the ButtonThrower + * object associated with this window. + */ NodePath WindowFramework:: get_button_thrower() { return _button_thrower; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::enable_keyboard -// Access: Public -// Description: Creates a ButtonThrower to listen to button presses -// and throw them as events. -//////////////////////////////////////////////////////////////////// +/** + * Creates a ButtonThrower to listen to button presses and throw them as + * events. + */ void WindowFramework:: enable_keyboard() { if (_got_keyboard) { @@ -438,8 +407,8 @@ enable_keyboard() { DCAST(GraphicsWindow, _window)->get_num_input_devices() > 0) { NodePath mouse = get_mouse(); - // Create a button thrower to listen for our keyboard events and - // associate this WindowFramework pointer with each one. + // Create a button thrower to listen for our keyboard events and associate + // this WindowFramework pointer with each one. PT(ButtonThrower) bt = new ButtonThrower("kb-events"); bt->add_parameter(EventParameter(this)); ModifierButtons mods; @@ -454,11 +423,9 @@ enable_keyboard() { _got_keyboard = true; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::setup_trackball -// Access: Public -// Description: Sets up the mouse to trackball around the camera. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the mouse to trackball around the camera. + */ void WindowFramework:: setup_trackball() { if (_got_trackball) { @@ -482,12 +449,10 @@ setup_trackball() { _got_trackball = true; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::center_trackball -// Access: Public -// Description: Centers the trackball on the indicated object, and -// scales the trackball motion suitably. -//////////////////////////////////////////////////////////////////// +/** + * Centers the trackball on the indicated object, and scales the trackball + * motion suitably. + */ void WindowFramework:: center_trackball(const NodePath &object) { if (_trackball == (Trackball *)NULL) { @@ -520,8 +485,8 @@ center_trackball(const NodePath &object) { return; } - // The BoundingVolume might be a sphere (it's likely), but since it - // might not, we'll take no chances and make our own sphere. + // The BoundingVolume might be a sphere (it's likely), but since it might + // not, we'll take no chances and make our own sphere. PT(BoundingSphere) sphere = new BoundingSphere(gbv->get_approx_center(), 0.0f); if (!sphere->extend_by(gbv)) { framework_cat.warning() @@ -534,9 +499,9 @@ center_trackball(const NodePath &object) { PN_stdfloat distance = 50.0f; - // Choose a suitable distance to view the whole volume in our frame. - // This is based on the camera lens in use. Determine the lens - // based on the first camera; this will be the default camera. + // Choose a suitable distance to view the whole volume in our frame. This + // is based on the camera lens in use. Determine the lens based on the + // first camera; this will be the default camera. Lens *lens = (Lens *)NULL; if (!_cameras.empty()) { Cameras::const_iterator ci; @@ -563,21 +528,18 @@ center_trackball(const NodePath &object) { _trackball->set_origin(center); _trackball->set_pos(LVector3::forward() * distance); - // Also set the movement scale on the trackball to be consistent - // with the size of the model and the lens field-of-view. + // Also set the movement scale on the trackball to be consistent with the + // size of the model and the lens field-of-view. _trackball->set_forward_scale(distance * 0.006); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::load_models -// Access: Public -// Description: Loads up all the model files listed in the indicated -// argument list. If first_arg is supplied, it is the -// first argument in the list to consider. -// -// Returns true if all models loaded successfully, or -// false if at least one of them had an error. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all the model files listed in the indicated argument list. If + * first_arg is supplied, it is the first argument in the list to consider. + * + * Returns true if all models loaded successfully, or false if at least one of + * them had an error. + */ bool WindowFramework:: load_models(const NodePath &parent, int argc, char *argv[], int first_arg) { pvector files; @@ -589,15 +551,12 @@ load_models(const NodePath &parent, int argc, char *argv[], int first_arg) { return load_models(parent, files); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::load_models -// Access: Public -// Description: Loads up all the model files listed in the indicated -// argument list. -// -// Returns true if all models loaded successfully, or -// false if at least one of them had an error. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all the model files listed in the indicated argument list. + * + * Returns true if all models loaded successfully, or false if at least one of + * them had an error. + */ bool WindowFramework:: load_models(const NodePath &parent, const pvector &files) { bool all_ok = true; @@ -614,24 +573,21 @@ load_models(const NodePath &parent, const pvector &files) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::load_model -// Access: Public -// Description: Loads up the indicated model and returns the new -// NodePath, or the empty NodePath if the model could -// not be loaded. -//////////////////////////////////////////////////////////////////// +/** + * Loads up the indicated model and returns the new NodePath, or the empty + * NodePath if the model could not be loaded. + */ NodePath WindowFramework:: load_model(const NodePath &parent, Filename filename) { framework_cat.info() << "Loading " << filename << "\n"; - // If the filename already exists where it is, or if it is fully - // qualified, don't search along the model path for it. + // If the filename already exists where it is, or if it is fully qualified, + // don't search along the model path for it. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); bool search = !(filename.is_fully_qualified() || vfs->exists(filename)); - // We allow loading image files here. Check to see if it might be - // an image file, based on the filename extension. + // We allow loading image files here. Check to see if it might be an image + // file, based on the filename extension. bool is_image = false; string extension = filename.get_extension(); #ifdef HAVE_ZLIB @@ -644,11 +600,10 @@ load_model(const NodePath &parent, Filename filename) { LoaderFileType *model_type = reg->get_type_from_extension(extension); if (model_type == (LoaderFileType *)NULL) { - // The extension isn't a known model file type; is it a known - // image file extension? + // The extension isn't a known model file type; is it a known image file + // extension? if (extension == "txo" || downcase(extension) == "dds") { - // A texture object. Not exactly an image, but certainly a - // texture. + // A texture object. Not exactly an image, but certainly a texture. is_image = true; } else { @@ -684,22 +639,19 @@ load_model(const NodePath &parent, Filename filename) { return parent.attach_new_node(node); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::load_default_model -// Access: Public -// Description: Loads our favorite blue triangle. This is intended -// to provide some default geometry to have *something* -// to look at for testing, when no other models are -// provided. -//////////////////////////////////////////////////////////////////// +/** + * Loads our favorite blue triangle. This is intended to provide some default + * geometry to have *something* to look at for testing, when no other models + * are provided. + */ NodePath WindowFramework:: load_default_model(const NodePath &parent) { CPT(RenderState) state = RenderState::make_empty(); state = state->add_attrib(ColorAttrib::make_flat(LColor(0.5, 0.5, 1.0, 1.0))); - // Get the default texture to apply to the triangle; it's compiled - // into the code these days. + // Get the default texture to apply to the triangle; it's compiled into the + // code these days. string rock_floor_string((const char *)rock_floor, rock_floor_len); istringstream rock_floor_strm(rock_floor_string); PNMImage rock_floor_pnm; @@ -745,13 +697,10 @@ load_default_model(const NodePath &parent) { return parent.attach_new_node(geomnode); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::loop_animations -// Access: Public -// Description: Looks for characters and their matching animation -// files in the scene graph; binds and loops any -// matching animations found. -//////////////////////////////////////////////////////////////////// +/** + * Looks for characters and their matching animation files in the scene graph; + * binds and loops any matching animations found. + */ void WindowFramework:: loop_animations(int hierarchy_match_flags) { // If we happened to load up both a character file and its matching @@ -761,14 +710,11 @@ loop_animations(int hierarchy_match_flags) { _anim_controls.loop_all(true); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::stagger_animations -// Access: Public -// Description: Walks through all the animations that were bound by -// loop_animations() and staggers their play rate -// slightly so that they will not remain perfectly in -// sync. -//////////////////////////////////////////////////////////////////// +/** + * Walks through all the animations that were bound by loop_animations() and + * staggers their play rate slightly so that they will not remain perfectly in + * sync. + */ void WindowFramework:: stagger_animations() { for (int i = 0; i < _anim_controls.get_num_anims(); ++i) { @@ -779,16 +725,12 @@ stagger_animations() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::next_anim_control -// Access: Public -// Description: Rotates the animation controls through all of the -// available animations. If the animation controls are -// not already enabled, enables them at sets to the -// first animation; if they are already enabled, steps -// to the next animation; if that is the last animation, -// disables the animation controls. -//////////////////////////////////////////////////////////////////// +/** + * Rotates the animation controls through all of the available animations. If + * the animation controls are not already enabled, enables them at sets to the + * first animation; if they are already enabled, steps to the next animation; + * if that is the last animation, disables the animation controls. + */ void WindowFramework:: next_anim_control() { if (_anim_controls_enabled) { @@ -819,12 +761,10 @@ next_anim_control() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_anim_controls -// Access: Public -// Description: Creates an onscreen animation slider for -// frame-stepping through the animations. -//////////////////////////////////////////////////////////////////// +/** + * Creates an onscreen animation slider for frame-stepping through the + * animations. + */ void WindowFramework:: set_anim_controls(bool enable) { _anim_controls_enabled = enable; @@ -836,16 +776,12 @@ set_anim_controls(bool enable) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::adjust_dimensions -// Access: Public -// Description: Reevaluates the dimensions of the window, -// presumably after the window has been resized by the -// user or some other force. Adjusts the render film -// size, aspect2d scale (aspect ratio) and the -// dimensionsas of pixel_2d according to the -// new window shape, or new config setting. -//////////////////////////////////////////////////////////////////// +/** + * Reevaluates the dimensions of the window, presumably after the window has + * been resized by the user or some other force. Adjusts the render film + * size, aspect2d scale (aspect ratio) and the dimensionsas of pixel_2d + * according to the new window shape, or new config setting. + */ void WindowFramework:: adjust_dimensions() { PN_stdfloat this_aspect_ratio = aspect_ratio; @@ -892,16 +828,12 @@ adjust_dimensions() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::split_window -// Access: Public -// Description: Divides the window into two display regions, each of -// which gets its own trackball and keyboard events. -// The new window pointer is returned. -// -// There is not an interface for recombining divided -// windows. -//////////////////////////////////////////////////////////////////// +/** + * Divides the window into two display regions, each of which gets its own + * trackball and keyboard events. The new window pointer is returned. + * + * There is not an interface for recombining divided windows. + */ WindowFramework *WindowFramework:: split_window(SplitType split_type) { DisplayRegion *new_region = NULL; @@ -945,12 +877,9 @@ split_window(SplitType split_type) { return wf; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_wireframe -// Access: Public -// Description: Forces wireframe state (true) or restores default -// rendering (false). -//////////////////////////////////////////////////////////////////// +/** + * Forces wireframe state (true) or restores default rendering (false). + */ void WindowFramework:: set_wireframe(bool enable, bool filled) { if (enable == _wireframe_enabled && filled == _wireframe_filled) { @@ -969,8 +898,8 @@ set_wireframe(bool enable, bool filled) { RenderModeAttrib::M_filled_wireframe, 1.4f, false, LColor(1, 1, 1, .5f)), override_priority); - // Darken the scene so that the wireframe is clearly visible, - // even when the scene is completely white. + // Darken the scene so that the wireframe is clearly visible, even when + // the scene is completely white. render.set_color_scale(LColor(0.7f, 0.7f, 0.7f, 1), override_priority); } else { render.set_render_mode_wireframe(override_priority); @@ -990,12 +919,9 @@ set_wireframe(bool enable, bool filled) { _wireframe_filled = filled; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_texture -// Access: Public -// Description: Forces textures off (false) or restores default -// rendering (true). -//////////////////////////////////////////////////////////////////// +/** + * Forces textures off (false) or restores default rendering (true). + */ void WindowFramework:: set_texture(bool enable) { if (enable == _texture_enabled) { @@ -1013,12 +939,9 @@ set_texture(bool enable) { _texture_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_two_sided -// Access: Public -// Description: Forces two-sided rendering (true) or restores default -// rendering (false). -//////////////////////////////////////////////////////////////////// +/** + * Forces two-sided rendering (true) or restores default rendering (false). + */ void WindowFramework:: set_two_sided(bool enable) { if (enable == _two_sided_enabled) { @@ -1039,13 +962,10 @@ set_two_sided(bool enable) { _one_sided_reverse_enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_one_sided_reverse -// Access: Public -// Description: Toggles one-sided reverse mode. In this mode, the -// front sides of one-sided polygons are culled instead -// of the back side. -//////////////////////////////////////////////////////////////////// +/** + * Toggles one-sided reverse mode. In this mode, the front sides of one-sided + * polygons are culled instead of the back side. + */ void WindowFramework:: set_one_sided_reverse(bool enable) { if (enable == _one_sided_reverse_enabled) { @@ -1067,11 +987,9 @@ set_one_sided_reverse(bool enable) { _one_sided_reverse_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_lighting -// Access: Public -// Description: Turns lighting on (true) or off (false). -//////////////////////////////////////////////////////////////////// +/** + * Turns lighting on (true) or off (false). + */ void WindowFramework:: set_lighting(bool enable) { if (enable == _lighting_enabled) { @@ -1093,11 +1011,9 @@ set_lighting(bool enable) { _lighting_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_perpixel -// Access: Public -// Description: Turns per-pixel lighting on (true) or off (false). -//////////////////////////////////////////////////////////////////// +/** + * Turns per-pixel lighting on (true) or off (false). + */ void WindowFramework:: set_perpixel(bool enable) { if (enable == _perpixel_enabled) { @@ -1115,14 +1031,11 @@ set_perpixel(bool enable) { _perpixel_enabled = enable; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::set_background_type -// Access: Public -// Description: Sets the background of the window to one of the -// pre-canned background types (or to BT_other, which -// indicates the user intends to set up his own special -// background mode). -//////////////////////////////////////////////////////////////////// +/** + * Sets the background of the window to one of the pre-canned background types + * (or to BT_other, which indicates the user intends to set up his own special + * background mode). + */ void WindowFramework:: set_background_type(WindowFramework::BackgroundType type) { _background_type = type; @@ -1179,12 +1092,9 @@ set_background_type(WindowFramework::BackgroundType type) { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::get_shuttle_controls_font -// Access: Public, Static -// Description: Returns a font that contains the shuttle controls -// icons. -//////////////////////////////////////////////////////////////////// +/** + * Returns a font that contains the shuttle controls icons. + */ TextFont *WindowFramework:: get_shuttle_controls_font() { if (_shuttle_controls_font == (TextFont *)NULL) { @@ -1204,11 +1114,9 @@ get_shuttle_controls_font() { return _shuttle_controls_font; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::make_camera -// Access: Public -// Description: Makes a new 3-d camera for the window. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 3-d camera for the window. + */ NodePath WindowFramework:: make_camera() { // Finally, we need a camera to associate with the display region. @@ -1223,8 +1131,8 @@ make_camera() { lens->set_aspect_ratio(aspect_ratio); } else { - // Otherwise, infer the aspect ratio from the window size. This - // does assume we have square pixels on our output device. + // Otherwise, infer the aspect ratio from the window size. This does + // assume we have square pixels on our output device. if (_window->has_size()) { int x_size = _window->get_sbs_left_x_size(); int y_size = _window->get_sbs_left_y_size(); @@ -1239,12 +1147,9 @@ make_camera() { return camera_np; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::setup_lights -// Access: Protected -// Description: Makes light nodes and attaches them to the camera for -// viewing the scene. -//////////////////////////////////////////////////////////////////// +/** + * Makes light nodes and attaches them to the camera for viewing the scene. + */ void WindowFramework:: setup_lights() { if (_got_lights) { @@ -1266,13 +1171,10 @@ setup_lights() { _got_lights = true; } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::load_image_as_model -// Access: Private -// Description: Loads the indicated image file as a texture, and -// creates a polygon to render it. Returns the new -// model. -//////////////////////////////////////////////////////////////////// +/** + * Loads the indicated image file as a texture, and creates a polygon to + * render it. Returns the new model. + */ PT(PandaNode) WindowFramework:: load_image_as_model(const Filename &filename) { PT(Texture) tex = TexturePool::load_texture(filename); @@ -1291,8 +1193,8 @@ load_image_as_model(const Filename &filename) { bool has_alpha = true; LVecBase2 tex_scale = tex->get_tex_scale(); - // Get the size from the original image (the texture may have - // scaled it to make a power of 2). + // Get the size from the original image (the texture may have scaled it to + // make a power of 2). int x_size = tex->get_orig_file_x_size(); int y_size = tex->get_orig_file_y_size(); @@ -1427,12 +1329,10 @@ load_image_as_model(const Filename &filename) { return card_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::create_anim_controls -// Access: Private -// Description: Creates an onscreen animation slider for -// frame-stepping through the animations. -//////////////////////////////////////////////////////////////////// +/** + * Creates an onscreen animation slider for frame-stepping through the + * animations. + */ void WindowFramework:: create_anim_controls() { destroy_anim_controls(); @@ -1514,7 +1414,7 @@ create_anim_controls() { NodePath pnp = _anim_controls_group.attach_new_node(_play_rate_slider); pnp.set_pos(0.75f, 0.0f, 0.15f); - // Set up the jog/shuttle buttons. These use symbols from the + // Set up the jogshuttle buttons. These use symbols from the // shuttle_controls_font file. setup_shuttle_button("9", 0, st_back_button); setup_shuttle_button(";", 1, st_pause_button); @@ -1525,11 +1425,9 @@ create_anim_controls() { _panda_framework->get_task_mgr().add(_update_anim_controls_task); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::destroy_anim_controls -// Access: Private -// Description: Removes the previously-created anim controls, if any. -//////////////////////////////////////////////////////////////////// +/** + * Removes the previously-created anim controls, if any. + */ void WindowFramework:: destroy_anim_controls() { if (!_anim_controls_group.is_empty()) { @@ -1543,12 +1441,9 @@ destroy_anim_controls() { } } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::update_anim_controls -// Access: Private -// Description: A per-frame callback to update the anim slider for -// the current frame. -//////////////////////////////////////////////////////////////////// +/** + * A per-frame callback to update the anim slider for the current frame. + */ void WindowFramework:: update_anim_controls() { AnimControl *control = _anim_controls.get_anim(_anim_index); @@ -1569,12 +1464,10 @@ update_anim_controls() { control->set_play_rate(_play_rate_slider->get_value()); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::setup_shuttle_button -// Access: Private -// Description: Creates a PGButton to implement the indicated shuttle -// event (play, pause, etc.). -//////////////////////////////////////////////////////////////////// +/** + * Creates a PGButton to implement the indicated shuttle event (play, pause, + * etc.). + */ void WindowFramework:: setup_shuttle_button(const string &label, int index, EventHandler::EventCallbackFunction *func) { @@ -1618,11 +1511,9 @@ setup_shuttle_button(const string &label, int index, _panda_framework->get_event_handler().add_hook(button->get_click_event(MouseButton::one()), func, (void *)this); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::back_button -// Access: Private, Static -// Description: Handler for a shuttle button. -//////////////////////////////////////////////////////////////////// +/** + * Handler for a shuttle button. + */ void WindowFramework:: back_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); @@ -1630,11 +1521,9 @@ back_button() { control->pose(control->get_frame() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::pause_button -// Access: Private, Static -// Description: Handler for a shuttle button. -//////////////////////////////////////////////////////////////////// +/** + * Handler for a shuttle button. + */ void WindowFramework:: pause_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); @@ -1642,11 +1531,9 @@ pause_button() { control->stop(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::play_button -// Access: Private, Static -// Description: Handler for a shuttle button. -//////////////////////////////////////////////////////////////////// +/** + * Handler for a shuttle button. + */ void WindowFramework:: play_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); @@ -1654,11 +1541,9 @@ play_button() { control->loop(false); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::forward_button -// Access: Private, Static -// Description: Handler for a shuttle button. -//////////////////////////////////////////////////////////////////// +/** + * Handler for a shuttle button. + */ void WindowFramework:: forward_button() { AnimControl *control = _anim_controls.get_anim(_anim_index); @@ -1667,11 +1552,9 @@ forward_button() { } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::st_update_anim_controls -// Access: Private, Static -// Description: The static task function. -//////////////////////////////////////////////////////////////////// +/** + * The static task function. + */ AsyncTask::DoneStatus WindowFramework:: st_update_anim_controls(GenericAsyncTask *, void *data) { WindowFramework *self = (WindowFramework *)data; @@ -1680,44 +1563,36 @@ st_update_anim_controls(GenericAsyncTask *, void *data) { } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::st_back_button -// Access: Private, Static -// Description: The static event handler function. -//////////////////////////////////////////////////////////////////// +/** + * The static event handler function. + */ void WindowFramework:: st_back_button(const Event *, void *data) { WindowFramework *self = (WindowFramework *)data; self->back_button(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::st_pause_button -// Access: Private, Static -// Description: The static event handler function. -//////////////////////////////////////////////////////////////////// +/** + * The static event handler function. + */ void WindowFramework:: st_pause_button(const Event *, void *data) { WindowFramework *self = (WindowFramework *)data; self->pause_button(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::st_play_button -// Access: Private, Static -// Description: The static event handler function. -//////////////////////////////////////////////////////////////////// +/** + * The static event handler function. + */ void WindowFramework:: st_play_button(const Event *, void *data) { WindowFramework *self = (WindowFramework *)data; self->play_button(); } -//////////////////////////////////////////////////////////////////// -// Function: WindowFramework::st_forward_button -// Access: Private, Static -// Description: The static event handler function. -//////////////////////////////////////////////////////////////////// +/** + * The static event handler function. + */ void WindowFramework:: st_forward_button(const Event *, void *data) { WindowFramework *self = (WindowFramework *)data; diff --git a/panda/src/framework/windowFramework.h b/panda/src/framework/windowFramework.h index 2ad042ed56..c74310e197 100644 --- a/panda/src/framework/windowFramework.h +++ b/panda/src/framework/windowFramework.h @@ -1,16 +1,15 @@ -// Filename: windowFramework.h -// Created by: drose (02Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowFramework.h + * @author drose + * @date 2002-04-02 + */ #ifndef WINDOWFRAMEWORK_H #define WINDOWFRAMEWORK_H @@ -42,16 +41,13 @@ class GraphicsEngine; class GraphicsPipe; class DisplayRegion; -//////////////////////////////////////////////////////////////////// -// Class : WindowFramework -// Description : This encapsulates the data that is normally -// associated with a single window, or with a single -// display region within a window. (In the case where a -// window has been subdivided with split_window(), there -// may be multiple WindowFrameworks objects that share -// the same GraphicsOutput pointer, but reference -// different display regions within that window). -//////////////////////////////////////////////////////////////////// +/** + * This encapsulates the data that is normally associated with a single + * window, or with a single display region within a window. (In the case + * where a window has been subdivided with split_window(), there may be + * multiple WindowFrameworks objects that share the same GraphicsOutput + * pointer, but reference different display regions within that window). + */ class EXPCL_FRAMEWORK WindowFramework : public TypedWritableReferenceCount { protected: WindowFramework(PandaFramework *panda_framework); diff --git a/panda/src/gles2gsg/config_gles2gsg.cxx b/panda/src/gles2gsg/config_gles2gsg.cxx index 1c7f56a999..3935783653 100644 --- a/panda/src/gles2gsg/config_gles2gsg.cxx +++ b/panda/src/gles2gsg/config_gles2gsg.cxx @@ -1,16 +1,15 @@ -// Filename: config_gles2gsg.cxx -// Created by: pro-rsoft (14Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gles2gsg.cxx + * @author rdb + * @date 2009-06-14 + */ #include "config_gles2gsg.h" #include "gles2gsg.h" @@ -24,14 +23,12 @@ ConfigureFn(config_gles2gsg) { init_libgles2gsg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libgles2gsg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libgles2gsg() { static bool initialized = false; diff --git a/panda/src/gles2gsg/config_gles2gsg.h b/panda/src/gles2gsg/config_gles2gsg.h index 82594e23e7..f077ef644d 100644 --- a/panda/src/gles2gsg/config_gles2gsg.h +++ b/panda/src/gles2gsg/config_gles2gsg.h @@ -1,16 +1,15 @@ -// Filename: config_gles2gsg.h -// Created by: pro-rsoft (14Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gles2gsg.h + * @author rdb + * @date 2009-06-14 + */ #ifndef CONFIG_GLES2GSG_H #define CONFIG_GLES2GSG_H diff --git a/panda/src/gles2gsg/gles2gsg.cxx b/panda/src/gles2gsg/gles2gsg.cxx index de92358b2f..a07eba27ec 100644 --- a/panda/src/gles2gsg/gles2gsg.cxx +++ b/panda/src/gles2gsg/gles2gsg.cxx @@ -1,20 +1,19 @@ -// Filename: gles2gsg.cxx -// Created by: pro-rsoft (14Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gles2gsg.cxx + * @author rdb + * @date 2009-06-14 + */ -// This is the actual .cxx file to include if you want to pick up -// any or all of the header files in this directory as compiled to use -// the "true" GLES2 library. +// This is the actual .cxx file to include if you want to pick up any or all +// of the header files in this directory as compiled to use the "true" GLES2 +// library. #include "gles2gsg.h" #include "glstuff_src.cxx" diff --git a/panda/src/gles2gsg/gles2gsg.h b/panda/src/gles2gsg/gles2gsg.h index 2582a2d5ed..cd905832a1 100644 --- a/panda/src/gles2gsg/gles2gsg.h +++ b/panda/src/gles2gsg/gles2gsg.h @@ -1,22 +1,21 @@ -// Filename: gles2gsg.h -// Created by: pro-rsoft (14Jun09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gles2gsg.h + * @author rdb + * @date 2009-06-14 + */ #ifndef GLES2GSG_H #define GLES2GSG_H -// This header file compiles a GSG for the limited subset of OpenGL -// that is OpenGL ES 2. +// This header file compiles a GSG for the limited subset of OpenGL that is +// OpenGL ES 2. #include "pandabase.h" #include "config_gles2gsg.h" @@ -54,15 +53,15 @@ #ifdef IS_OSX #include -// #include +// #include #else #include -// #include +// #include #endif #include "panda_esgl2ext.h" -// This helps to keep the source clean of hundreds of #ifdefs. +// This helps to keep the source clean of hundreds of ifdefs. typedef char GLchar; #define GL_RENDERBUFFER_EXT GL_RENDERBUFFER #define GL_RENDERBUFFER_RED_SIZE_EXT GL_RENDERBUFFER_RED_SIZE diff --git a/panda/src/glesgsg/config_glesgsg.cxx b/panda/src/glesgsg/config_glesgsg.cxx index 329da03281..a1c0496cfc 100644 --- a/panda/src/glesgsg/config_glesgsg.cxx +++ b/panda/src/glesgsg/config_glesgsg.cxx @@ -1,16 +1,15 @@ -// Filename: config_glesgsg.cxx -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glesgsg.cxx + * @author rdb + * @date 2009-05-21 + */ #include "config_glesgsg.h" #include "glesgsg.h" @@ -24,14 +23,12 @@ ConfigureFn(config_glesgsg) { init_libglesgsg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libglesgsg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libglesgsg() { static bool initialized = false; diff --git a/panda/src/glesgsg/config_glesgsg.h b/panda/src/glesgsg/config_glesgsg.h index d20e48c242..902a544aa2 100644 --- a/panda/src/glesgsg/config_glesgsg.h +++ b/panda/src/glesgsg/config_glesgsg.h @@ -1,16 +1,15 @@ -// Filename: config_glesgsg.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glesgsg.h + * @author rdb + * @date 2009-05-21 + */ #ifndef CONFIG_GLESGSG_H #define CONFIG_GLESGSG_H diff --git a/panda/src/glesgsg/glesgsg.cxx b/panda/src/glesgsg/glesgsg.cxx index a1ae407512..10a312715b 100644 --- a/panda/src/glesgsg/glesgsg.cxx +++ b/panda/src/glesgsg/glesgsg.cxx @@ -1,20 +1,19 @@ -// Filename: glesgsg.cxx -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glesgsg.cxx + * @author rdb + * @date 2009-05-21 + */ -// This is the actual .cxx file to include if you want to pick up -// any or all of the header files in this directory as compiled to use -// the "true" GLES library. +// This is the actual .cxx file to include if you want to pick up any or all +// of the header files in this directory as compiled to use the "true" GLES +// library. #include "glesgsg.h" #include "glstuff_src.cxx" diff --git a/panda/src/glesgsg/glesgsg.h b/panda/src/glesgsg/glesgsg.h index 50dfaeab19..40b4722b22 100644 --- a/panda/src/glesgsg/glesgsg.h +++ b/panda/src/glesgsg/glesgsg.h @@ -1,22 +1,21 @@ -// Filename: glesgsg.h -// Created by: pro-rsoft (21May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glesgsg.h + * @author rdb + * @date 2009-05-21 + */ #ifndef GLESGSG_H #define GLESGSG_H -// This header file compiles a GSG for the limited subset of OpenGL -// that is OpenGL ES. +// This header file compiles a GSG for the limited subset of OpenGL that is +// OpenGL ES. #include "pandabase.h" #include "config_glesgsg.h" @@ -50,22 +49,22 @@ #define SUPPORT_FIXED_FUNCTION #endif -// This prevents glext.h from getting included by gl.h -// That way, we can provide our own, better version. +// This prevents glext.h from getting included by gl.h That way, we can +// provide our own, better version. #define __glext_h_ #define ES1_GLEXT_H_GUARD #ifdef IS_OSX #include -// #include +// #include #else #include -// #include +// #include #endif #include "panda_esglext.h" -// This helps to keep the source clean of hundreds of #ifdefs. +// This helps to keep the source clean of hundreds of ifdefs. #define GL_NONE GL_NONE_OES #define GL_RENDERBUFFER_EXT GL_RENDERBUFFER_OES #define GL_RENDERBUFFER_RED_SIZE_EXT GL_RENDERBUFFER_RED_SIZE_OES diff --git a/panda/src/glgsg/config_glgsg.cxx b/panda/src/glgsg/config_glgsg.cxx index 5332d6cca1..8f98e49717 100644 --- a/panda/src/glgsg/config_glgsg.cxx +++ b/panda/src/glgsg/config_glgsg.cxx @@ -1,16 +1,15 @@ -// Filename: config_glgsg.cxx -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glgsg.cxx + * @author drose + * @date 1999-10-06 + */ #include "config_glgsg.h" #include "glgsg.h" @@ -24,14 +23,12 @@ ConfigureFn(config_glgsg) { init_libglgsg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libglgsg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libglgsg() { static bool initialized = false; diff --git a/panda/src/glgsg/config_glgsg.h b/panda/src/glgsg/config_glgsg.h index b056a279df..87220333ed 100644 --- a/panda/src/glgsg/config_glgsg.h +++ b/panda/src/glgsg/config_glgsg.h @@ -1,16 +1,15 @@ -// Filename: config_glgsg.h -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glgsg.h + * @author drose + * @date 1999-10-06 + */ #ifndef CONFIG_GLGSG_H #define CONFIG_GLGSG_H diff --git a/panda/src/glgsg/glgsg.cxx b/panda/src/glgsg/glgsg.cxx index 9e2133c46b..5f1679f8b0 100644 --- a/panda/src/glgsg/glgsg.cxx +++ b/panda/src/glgsg/glgsg.cxx @@ -1,20 +1,19 @@ -// Filename: glgsg.cxx -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glgsg.cxx + * @author drose + * @date 2004-02-09 + */ -// This is the actual .cxx file to include if you want to pick up -// any or all of the header files in this directory as compiled to use -// the "true" GL library. +// This is the actual .cxx file to include if you want to pick up any or all +// of the header files in this directory as compiled to use the "true" GL +// library. #include "glgsg.h" #include "glstuff_src.cxx" diff --git a/panda/src/glgsg/glgsg.h b/panda/src/glgsg/glgsg.h index b0cb22eb1a..713ce9e862 100644 --- a/panda/src/glgsg/glgsg.h +++ b/panda/src/glgsg/glgsg.h @@ -1,23 +1,22 @@ -// Filename: glgsg.h -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glgsg.h + * @author drose + * @date 2004-02-09 + */ #ifndef GLGSG_H #define GLGSG_H -// This is the actual header file to include if you want to pick up -// any or all of the header files in this directory as compiled to use -// the "true" GL library. +// This is the actual header file to include if you want to pick up any or all +// of the header files in this directory as compiled to use the "true" GL +// library. #include "pandabase.h" #include "config_glgsg.h" @@ -73,8 +72,8 @@ #include #endif -// This prevents glext.h from getting included by gl.h -// That way, we can provide our own, better version. +// This prevents glext.h from getting included by gl.h That way, we can +// provide our own, better version. #define __glext_h_ #define GL_GLEXT_VERSION 0 diff --git a/panda/src/glstuff/glCgShaderContext_src.I b/panda/src/glstuff/glCgShaderContext_src.I index 308ca92e3a..b2c176f7d1 100644 --- a/panda/src/glstuff/glCgShaderContext_src.I +++ b/panda/src/glstuff/glCgShaderContext_src.I @@ -1,28 +1,24 @@ -// Filename: glCgShaderContext_src.I -// Created by: rdb (27Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glCgShaderContext_src.I + * @author rdb + * @date 2014-06-27 + */ #ifndef OPENGLES_1 -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::valid -// Access: Public -// Description: Returns true if the shader is "valid", ie, if the -// compilation was successful. The compilation could -// fail if there is a syntax error in the shader, or -// if the current video card isn't shader-capable, -// or if no shader languages are compiled into panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader is "valid", ie, if the compilation was + * successful. The compilation could fail if there is a syntax error in the + * shader, or if the current video card isn't shader-capable, or if no shader + * languages are compiled into panda. + */ INLINE bool CLP(CgShaderContext):: valid() { if (_shader->get_error_flag()) return false; @@ -30,27 +26,21 @@ valid() { return (_cg_program != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::uses_standard_vertex_arrays -// Access: Public -// Description: Returns true if the shader may need to access -// standard vertex attributes as passed by -// glVertexPointer and the like. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader may need to access standard vertex attributes as + * passed by glVertexPointer and the like. + */ INLINE bool CLP(CgShaderContext):: uses_standard_vertex_arrays() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::uses_custom_vertex_arrays -// Access: Public -// Description: Always true, for now. -//////////////////////////////////////////////////////////////////// +/** + * Always true, for now. + */ INLINE bool CLP(CgShaderContext):: uses_custom_vertex_arrays() { return true; } #endif // OPENGLES_1 - diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index bbc05960ac..c857948b97 100644 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -1,18 +1,18 @@ -// Filename: glCgShaderContext_src.cxx -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE (29Apr10) (updated CLP with note that some -// parameter types only supported under Cg) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glCgShaderContext_src.cxx + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-29 + * parameter types only supported under Cg) + */ #if defined(HAVE_CG) && !defined(OPENGLES) @@ -33,11 +33,9 @@ TypeHandle CLP(CgShaderContext)::_type_handle; #define cg_report_errors() #endif -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::Constructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(CgShaderContext):: CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext(s) { _glgsg = glgsg; @@ -65,8 +63,8 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte #endif } - // Ask the shader to compile itself for us and - // to give us the resulting Cg program objects. + // Ask the shader to compile itself for us and to give us the resulting Cg + // program objects. if (!s->cg_compile_for(_glgsg->_shader_caps, context, _cg_program, _cg_parameter_map)) { return; @@ -125,12 +123,12 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte } // We don't use cgGLSetParameterPointer to set the vertex attributes any - // longer, since it is buggy on non-NVIDIA hardware and doesn't allow explicit - // control over some parameters. Instead, we have to figure out ourselves how - // to map the input varyings to OpenGL vertex attributes. - // - // We use positive indices to indicate generic vertex attributes, and negative - // indices to indicate conventional vertex attributes (ie. glVertexPointer). + // longer, since it is buggy on non-NVIDIA hardware and doesn't allow + // explicit control over some parameters. Instead, we have to figure out + // ourselves how to map the input varyings to OpenGL vertex attributes. We + // use positive indices to indicate generic vertex attributes, and negative + // indices to indicate conventional vertex attributes (ie. + // glVertexPointer). size_t nvarying = _shader->_var_spec.size(); _attributes.resize(nvarying); @@ -148,10 +146,10 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte if (cgGetParameterBaseResource(p) == CG_ATTR0) { // The Cg toolkit claims that it is bound to a generic vertex attribute. if (_glsl_program != 0) { - // This is where the Cg glslv compiler lies, making the stupid assumption - // that we're using an NVIDIA card where generic attributes are aliased - // with conventional vertex attributes. Instead, it always uses - // conventional attributes in this case. Correct this. + // This is where the Cg glslv compiler lies, making the stupid + // assumption that we're using an NVIDIA card where generic attributes + // are aliased with conventional vertex attributes. Instead, it + // always uses conventional attributes in this case. Correct this. int index = cgGetParameterResourceIndex(p); switch (index) { case 0: // gl_Vertex @@ -194,9 +192,9 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte } else if (res == CG_GLSL_ATTRIB || _glsl_program != 0) { // With cg-glsl-version 130 and higher, no conventional attributes are - // used, but it instead uses specially named variables. - // A bit of guesswork is involved here; Cg seems to mostly use the - // semantics as attribute names in GLSL, with a few exceptions. + // used, but it instead uses specially named variables. A bit of + // guesswork is involved here; Cg seems to mostly use the semantics as + // attribute names in GLSL, with a few exceptions. const char *attribname = NULL; switch (res) { case CG_POSITION0: @@ -319,22 +317,18 @@ CLP(CgShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderConte _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::Destructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(CgShaderContext):: ~CLP(CgShaderContext)() { // Don't call release_resources; we may not have an active context. } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::release_resources -// Access: Public -// Description: Should deallocate all system resources (such as -// vertex program handles or Cg contexts). -//////////////////////////////////////////////////////////////////// +/** + * Should deallocate all system resources (such as vertex program handles or + * Cg contexts). + */ void CLP(CgShaderContext):: release_resources() { if (_cg_program != 0) { @@ -355,13 +349,10 @@ release_resources() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::bind -// Access: Public -// Description: This function is to be called to enable a new -// shader. It also initializes all of the shader's -// input parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function is to be called to enable a new shader. It also initializes + * all of the shader's input parameters. + */ void CLP(CgShaderContext):: bind() { if (_cg_program != 0) { @@ -374,11 +365,9 @@ bind() { } } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::unbind -// Access: Public -// Description: This function disables a currently-bound shader. -//////////////////////////////////////////////////////////////////// +/** + * This function disables a currently-bound shader. + */ void CLP(CgShaderContext):: unbind() { if (_cg_program != 0) { @@ -394,14 +383,11 @@ unbind() { } } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::set_state_and_transform -// Access: Public -// Description: This function gets called whenever the RenderState -// or TransformState has changed, but the Shader -// itself has not changed. It loads new values into the -// shader's parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function gets called whenever the RenderState or TransformState has + * changed, but the Shader itself has not changed. It loads new values into + * the shader's parameters. + */ void CLP(CgShaderContext):: set_state_and_transform(const RenderState *target_rs, const TransformState *modelview_transform, @@ -477,21 +463,16 @@ set_state_and_transform(const RenderState *target_rs, } } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::issue_parameters -// Access: Public -// Description: This function gets called whenever the RenderState -// or TransformState has changed, but the Shader -// itself has not changed. It loads new values into the -// shader's parameters. -// -// If "altered" is false, that means you promise that -// the parameters for this shader context have already -// been issued once, and that since the last time the -// parameters were issued, no part of the render -// state has changed except the external and internal -// transforms. -//////////////////////////////////////////////////////////////////// +/** + * This function gets called whenever the RenderState or TransformState has + * changed, but the Shader itself has not changed. It loads new values into + * the shader's parameters. + * + * If "altered" is false, that means you promise that the parameters for this + * shader context have already been issued once, and that since the last time + * the parameters were issued, no part of the render state has changed except + * the external and internal transforms. + */ void CLP(CgShaderContext):: issue_parameters(int altered) { PStatGPUTimer timer(_glgsg, _glgsg->_draw_set_state_shader_parameters_pcollector); @@ -502,8 +483,8 @@ issue_parameters(int altered) { << " (altered 0x" << hex << altered << dec << ")\n"; } - // We have no way to track modifications to PTAs, so we assume that - // they are modified every frame and when we switch ShaderAttribs. + // We have no way to track modifications to PTAs, so we assume that they are + // modified every frame and when we switch ShaderAttribs. if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) { // Iterate through _ptr parameters for (int i = 0; i < (int)_shader->_ptr_spec.size(); ++i) { @@ -515,10 +496,11 @@ issue_parameters(int altered) { return; } - //Check if the size of the shader input and ptr_data match + // Check if the size of the shader input and ptr_data match int input_size = spec._dim[0] * spec._dim[1] * spec._dim[2]; - // dimension is negative only if the parameter had the (deprecated)k_ prefix. + // dimension is negative only if the parameter had the (deprecated)k_ + // prefix. if ((input_size > ptr_data->_size) && (spec._dim[0] > 0)) { GLCAT.error() << spec._id._name << ": incorrect number of elements, expected " << input_size <<" got " << ptr_data->_size << "\n"; @@ -718,12 +700,9 @@ issue_parameters(int altered) { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: CgGLShaderContext::update_transform_table -// Access: Public -// Description: Changes the active transform table, used for hardware -// skinning. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active transform table, used for hardware skinning. + */ void CLP(CgShaderContext):: update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); @@ -749,12 +728,9 @@ update_transform_table(const TransformTable *table) { _transform_table_size, (float *)matrices); } -//////////////////////////////////////////////////////////////////// -// Function: CgGLShaderContext::update_slider_table -// Access: Public -// Description: Changes the active slider table, used for hardware -// skinning. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active slider table, used for hardware skinning. + */ void CLP(CgShaderContext):: update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); @@ -770,11 +746,9 @@ update_slider_table(const SliderTable *table) { cgGLSetParameterArray4f(_slider_table_param, 0, _slider_table_size, sliders); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::disable_shader_vertex_arrays -// Access: Public -// Description: Disable all the vertex arrays used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the vertex arrays used by this shader. + */ void CLP(CgShaderContext):: disable_shader_vertex_arrays() { if (!valid()) { @@ -816,17 +790,13 @@ disable_shader_vertex_arrays() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::update_shader_vertex_arrays -// Access: Public -// Description: Disables all vertex arrays used by the previous -// shader, then enables all the vertex arrays needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -// The current implementation is inefficient, because -// it may unnecessarily disable arrays then immediately -// reenable them. We may optimize this someday. -//////////////////////////////////////////////////////////////////// +/** + * Disables all vertex arrays used by the previous shader, then enables all + * the vertex arrays needed by this shader. Extracts the relevant vertex + * array data from the gsg. The current implementation is inefficient, + * because it may unnecessarily disable arrays then immediately reenable them. + * We may optimize this someday. + */ bool CLP(CgShaderContext):: update_shader_vertex_arrays(ShaderContext *prev, bool force) { if (!valid()) { @@ -944,13 +914,14 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { #endif // SUPPORT_FIXED_FUNCTION } } else { - // There is no vertex column with this name; disable the attribute array. + // There is no vertex column with this name; disable the attribute + // array. #ifdef SUPPORT_FIXED_FUNCTION if (p == 0) { - //NOTE: if we disable attribute 0 in compatibility profile, the object - // will disappear. In GLSL we fix this by forcing the vertex column - // to be at 0, but we don't have control over that with Cg. So, we - // work around this by just binding something silly to 0. + // NOTE: if we disable attribute 0 in compatibility profile, the + // object will disappear. In GLSL we fix this by forcing the vertex + // column to be at 0, but we don't have control over that with Cg. + // So, we work around this by just binding something silly to 0. // This breaks flat colors, but it's better than invisible objects? _glgsg->enable_vertex_attrib_array(0); if (bind._integer) { @@ -1026,11 +997,9 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::disable_shader_texture_bindings -// Access: Public -// Description: Disable all the texture bindings used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the texture bindings used by this shader. + */ void CLP(CgShaderContext):: disable_shader_texture_bindings() { if (!valid()) { @@ -1056,36 +1025,30 @@ disable_shader_texture_bindings() { glBindTexture(GL_TEXTURE_CUBE_MAP, 0); } // This is probably faster - but maybe not as safe? - //cgGLDisableTextureParameter(p); + // cgGLDisableTextureParameter(p); } cg_report_errors(); _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLCgShaderContext::update_shader_texture_bindings -// Access: Public -// Description: Disables all texture bindings used by the previous -// shader, then enables all the texture bindings needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -// The current implementation is inefficient, because -// it may unnecessarily disable textures then immediately -// reenable them. We may optimize this someday. -//////////////////////////////////////////////////////////////////// +/** + * Disables all texture bindings used by the previous shader, then enables all + * the texture bindings needed by this shader. Extracts the relevant vertex + * array data from the gsg. The current implementation is inefficient, + * because it may unnecessarily disable textures then immediately reenable + * them. We may optimize this someday. + */ void CLP(CgShaderContext):: update_shader_texture_bindings(ShaderContext *prev) { - //if (prev) { - // prev->disable_shader_texture_bindings(); - //} + // if (prev) { prev->disable_shader_texture_bindings(); } if (!valid()) { return; } - // We get the TextureAttrib directly from the _target_rs, not the - // filtered TextureAttrib in _target_texture. + // We get the TextureAttrib directly from the _target_rs, not the filtered + // TextureAttrib in _target_texture. const TextureAttrib *texattrib; _glgsg->_target_rs->get_attrib_def(texattrib); @@ -1103,15 +1066,15 @@ update_shader_texture_bindings(ShaderContext *prev) { PT(Texture) tex = _glgsg->fetch_specified_texture(spec, sampler, view); if (tex.is_null()) { - // Apply a white texture in order to make it easier to use a shader - // that takes a texture on a model that doesn't have a texture applied. + // Apply a white texture in order to make it easier to use a shader that + // takes a texture on a model that doesn't have a texture applied. _glgsg->set_active_texture_stage(i); _glgsg->apply_white_texture(); continue; } if (spec._suffix != 0) { - // The suffix feature is inefficient. It is a temporary hack. + // The suffix feature is inefficient. It is a temporary hack. if (tex == 0) { continue; } diff --git a/panda/src/glstuff/glCgShaderContext_src.h b/panda/src/glstuff/glCgShaderContext_src.h index 149772e28b..ae76989d77 100644 --- a/panda/src/glstuff/glCgShaderContext_src.h +++ b/panda/src/glstuff/glCgShaderContext_src.h @@ -1,16 +1,15 @@ -// Filename: glCgShaderContext_src.h -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glCgShaderContext_src.h + * @author jyelon + * @date 2005-09-01 + */ #if defined(HAVE_CG) && !defined(OPENGLES) @@ -23,10 +22,9 @@ class CLP(GraphicsStateGuardian); -//////////////////////////////////////////////////////////////////// -// Class : GLShaderContext -// Description : xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ class EXPCL_GL CLP(CgShaderContext) : public ShaderContext { public: friend class CLP(GraphicsStateGuardian); @@ -107,4 +105,3 @@ private: #include "glCgShaderContext_src.I" #endif // OPENGLES_1 - diff --git a/panda/src/glstuff/glGeomContext_src.I b/panda/src/glstuff/glGeomContext_src.I index 346e1df640..d9231e2cf5 100644 --- a/panda/src/glstuff/glGeomContext_src.I +++ b/panda/src/glstuff/glGeomContext_src.I @@ -1,23 +1,19 @@ -// Filename: glGeomContext_src.I -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomContext_src.I + * @author drose + * @date 2004-03-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(GeomContext):: CLP(GeomContext)(Geom *geom) : GeomContext(geom) @@ -27,11 +23,9 @@ CLP(GeomContext)(Geom *geom) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::DisplayList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(GeomContext)::DisplayList:: DisplayList() : _index(0) diff --git a/panda/src/glstuff/glGeomContext_src.cxx b/panda/src/glstuff/glGeomContext_src.cxx index 0ecac4afaa..11a9cf3f23 100644 --- a/panda/src/glstuff/glGeomContext_src.cxx +++ b/panda/src/glstuff/glGeomContext_src.cxx @@ -1,39 +1,32 @@ -// Filename: glGeomContext_src.cxx -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomContext_src.cxx + * @author drose + * @date 2004-03-19 + */ TypeHandle CLP(GeomContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GeomContext):: ~CLP(GeomContext)() { nassertv(_display_lists.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::get_display_list -// Access: Public -// Description: Looks up the display list index associated with the -// indicated munger, or creates a new one if the munger -// has not yet been used to render this context. Fills -// index with the display list index, and returns true -// if the display list is current (that is, it has the -// same modified stamp). -//////////////////////////////////////////////////////////////////// +/** + * Looks up the display list index associated with the indicated munger, or + * creates a new one if the munger has not yet been used to render this + * context. Fills index with the display list index, and returns true if the + * display list is current (that is, it has the same modified stamp). + */ bool CLP(GeomContext):: get_display_list(GLuint &index, const CLP(GeomMunger) *munger, UpdateSeq modified) { @@ -59,13 +52,11 @@ get_display_list(GLuint &index, const CLP(GeomMunger) *munger, #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::release_display_lists -// Access: Public -// Description: Called only from the draw thread by -// GLGraphicsStateGuardian::release_geom(), this should -// delete all of the queued display lists immediately. -//////////////////////////////////////////////////////////////////// +/** + * Called only from the draw thread by + * GLGraphicsStateGuardian::release_geom(), this should delete all of the + * queued display lists immediately. + */ void CLP(GeomContext):: release_display_lists() { #if defined(OPENGLES) || !defined(SUPPORT_FIXED_FUNCTION) @@ -94,13 +85,10 @@ release_display_lists() { #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomContext)::remove_munger -// Access: Public -// Description: Called when a glGeomMunger that we are pointing to -// destructs, this should remove the record of that -// munger (and mark the display list for deletion). -//////////////////////////////////////////////////////////////////// +/** + * Called when a glGeomMunger that we are pointing to destructs, this should + * remove the record of that munger (and mark the display list for deletion). + */ void CLP(GeomContext):: remove_munger(CLP(GeomMunger) *munger) { #if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) @@ -113,9 +101,9 @@ remove_munger(CLP(GeomMunger) *munger) { CLP(GraphicsStateGuardian) *glgsg; DCAST_INTO_V(glgsg, munger->get_gsg()); - // We can't delete the display list immediately, because we might be - // running in any thread. Instead, enqueue the display list index - // and let it get deleted at the end of the current or next frame. + // We can't delete the display list immediately, because we might be running + // in any thread. Instead, enqueue the display list index and let it get + // deleted at the end of the current or next frame. glgsg->record_deleted_display_list(index); #endif } diff --git a/panda/src/glstuff/glGeomContext_src.h b/panda/src/glstuff/glGeomContext_src.h index 6dede83f74..5a93fa9952 100644 --- a/panda/src/glstuff/glGeomContext_src.h +++ b/panda/src/glstuff/glGeomContext_src.h @@ -1,16 +1,15 @@ -// Filename: glGeomContext_src.h -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomContext_src.h + * @author drose + * @date 2004-03-19 + */ #include "pandabase.h" #include "geomContext.h" @@ -22,25 +21,24 @@ class CLP(GeomMunger); -//////////////////////////////////////////////////////////////////// -// Class : GLGeomContext -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_GL CLP(GeomContext) : public GeomContext { public: INLINE CLP(GeomContext)(Geom *geom); virtual ~CLP(GeomContext)(); ALLOC_DELETED_CHAIN(CLP(GeomContext)); - bool get_display_list(GLuint &index, const CLP(GeomMunger) *munger, + bool get_display_list(GLuint &index, const CLP(GeomMunger) *munger, UpdateSeq modified); void release_display_lists(); void remove_munger(CLP(GeomMunger) *munger); - // The different variants of the display list, for storing the - // different states the geom might have been rendered in (each using - // a different munger). + // The different variants of the display list, for storing the different + // states the geom might have been rendered in (each using a different + // munger). class DisplayList { public: INLINE DisplayList(); @@ -50,8 +48,7 @@ public: typedef pmap DisplayLists; DisplayLists _display_lists; - // The number of vertices encoded in the display list, for stats - // reporting. + // The number of vertices encoded in the display list, for stats reporting. #ifdef DO_PSTATS int _num_verts; #endif @@ -75,4 +72,3 @@ private: }; #include "glGeomContext_src.I" - diff --git a/panda/src/glstuff/glGeomMunger_src.I b/panda/src/glstuff/glGeomMunger_src.I index d1ed971b59..52f6415b7c 100644 --- a/panda/src/glstuff/glGeomMunger_src.I +++ b/panda/src/glstuff/glGeomMunger_src.I @@ -1,14 +1,12 @@ -// Filename: glGeomMunger_src.I -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomMunger_src.I + * @author drose + * @date 2005-03-10 + */ diff --git a/panda/src/glstuff/glGeomMunger_src.cxx b/panda/src/glstuff/glGeomMunger_src.cxx index 7be5a50d50..e9a98e82fc 100644 --- a/panda/src/glstuff/glGeomMunger_src.cxx +++ b/panda/src/glstuff/glGeomMunger_src.cxx @@ -1,16 +1,15 @@ -// Filename: glGeomMunger_src.cxx -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomMunger_src.cxx + * @author drose + * @date 2005-03-10 + */ #include "dcast.h" @@ -18,19 +17,17 @@ TypeHandle CLP(GeomMunger)::_type_handle; ALLOC_DELETED_CHAIN_DEF(CLP(GeomMunger)); -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GeomMunger):: CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) : StandardMunger(gsg, state, 4, NT_uint8, C_color), _texture((const TextureAttrib *)state->get_attrib(TextureAttrib::get_class_slot())), _tex_gen((const TexGenAttrib *)state->get_attrib(TexGenAttrib::get_class_slot())) { - // Set a callback to unregister ourselves when either the Texture or - // the TexGen object gets deleted. + // Set a callback to unregister ourselves when either the Texture or the + // TexGen object gets deleted. _texture.set_callback(this); _tex_gen.set_callback(this); @@ -43,11 +40,9 @@ CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state) : } } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GeomMunger):: ~CLP(GeomMunger)() { // We need to remove this pointer from all of the geom contexts that @@ -59,25 +54,20 @@ CLP(GeomMunger):: _geom_contexts.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::wp_callback -// Access: Public, Virtual -// Description: This callback is set to be made whenever the -// associated _texture or _tex_gen attributes are -// destructed, in which case the GeomMunger is invalid -// and should no longer be used. -//////////////////////////////////////////////////////////////////// +/** + * This callback is set to be made whenever the associated _texture or + * _tex_gen attributes are destructed, in which case the GeomMunger is invalid + * and should no longer be used. + */ void CLP(GeomMunger):: wp_callback(void *) { unregister_myself(); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::munge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) CLP(GeomMunger):: munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &animation) { @@ -88,8 +78,8 @@ munge_format_impl(const GeomVertexFormat *orig, DCAST_INTO_R(glgsg, get_gsg(), NULL); #ifndef OPENGLES - // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices - // and texture coordinates. + // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and + // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); if (vertex_type != (GeomVertexColumn *)NULL && (vertex_type->get_numeric_type() == NT_int8 || @@ -131,8 +121,8 @@ munge_format_impl(const GeomVertexFormat *orig, if (color_type != (GeomVertexColumn *)NULL && color_type->get_numeric_type() == NT_packed_dabc && !glgsg->_supports_packed_dabc) { - // We need to convert the color format; OpenGL doesn't support the - // byte order of DirectX's packed ARGB format. + // We need to convert the color format; OpenGL doesn't support the byte + // order of DirectX's packed ARGB format. int color_array = orig->get_array_with(InternalName::get_color()); PT(GeomVertexArrayFormat) new_array_format = new_format->modify_array(color_array); @@ -144,11 +134,10 @@ munge_format_impl(const GeomVertexFormat *orig, } if (animation.get_animation_type() == AT_hardware) { - // If we want hardware animation, we need to reserve space for the - // blend weights. + // If we want hardware animation, we need to reserve space for the blend + // weights. - // Make sure the old weights and indices are removed, just in - // case. + // Make sure the old weights and indices are removed, just in case. new_format->remove_column(InternalName::get_transform_weight()); new_format->remove_column(InternalName::get_transform_index()); @@ -162,14 +151,14 @@ munge_format_impl(const GeomVertexFormat *orig, NT_stdfloat, C_other); if (animation.get_indexed_transforms()) { - // Also, if we'll be indexing into the transform table, reserve - // space for the index. + // Also, if we'll be indexing into the transform table, reserve space + // for the index. - // TODO: We should examine the maximum palette index so we can - // decide whether we need 16-bit indices. That implies saving - // the maximum palette index, presumably in the AnimationSpec. - // At the moment, I don't think any existing hardware supports - // more than 255 indices anyway. + // TODO: We should examine the maximum palette index so we can decide + // whether we need 16-bit indices. That implies saving the maximum + // palette index, presumably in the AnimationSpec. At the moment, I + // don't think any existing hardware supports more than 255 indices + // anyway. new_array_format->add_column (InternalName::get_transform_index(), animation.get_num_transforms(), NT_uint8, C_index); @@ -226,8 +215,7 @@ munge_format_impl(const GeomVertexFormat *orig, new_format->remove_column(column->get_name()); } - // Put only the used texture coordinates into the interleaved - // array. + // Put only the used texture coordinates into the interleaved array. if (_texture != (TextureAttrib *)NULL) { typedef pset UsedStages; UsedStages used_stages; @@ -264,12 +252,10 @@ munge_format_impl(const GeomVertexFormat *orig, return format; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::premunge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) CLP(GeomMunger):: premunge_format_impl(const GeomVertexFormat *orig) { PT(GeomVertexFormat) new_format = new GeomVertexFormat(*orig); @@ -278,8 +264,8 @@ premunge_format_impl(const GeomVertexFormat *orig) { DCAST_INTO_R(glgsg, get_gsg(), NULL); #ifndef OPENGLES - // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices - // and texture coordinates. + // OpenGL ES 1 does, but regular OpenGL doesn't support GL_BYTE vertices and + // texture coordinates. const GeomVertexColumn *vertex_type = orig->get_vertex_column(); if (vertex_type != (GeomVertexColumn *)NULL && (vertex_type->get_numeric_type() == NT_int8 || @@ -333,12 +319,11 @@ premunge_format_impl(const GeomVertexFormat *orig) { format = GeomVertexFormat::register_format(new_format); } else { - // Combine the primary data columns into a single array. Unlike - // the munge case, above, in the premunge case, we do this even if - // F_interleaved_arrays is not set (unless F_parallel_arrays is - // set), since the presumption is that you're more willing to pay - // the overhead of doing this step at load time than you might be - // at run time. + // Combine the primary data columns into a single array. Unlike the munge + // case, above, in the premunge case, we do this even if + // F_interleaved_arrays is not set (unless F_parallel_arrays is set), + // since the presumption is that you're more willing to pay the overhead + // of doing this step at load time than you might be at run time. new_format = new GeomVertexFormat(*format); PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat; @@ -369,9 +354,8 @@ premunge_format_impl(const GeomVertexFormat *orig) { new_format->remove_column(column->get_name()); } - // Put only the used texture coordinates into the interleaved - // array. The others will be kept around, but in a parallel - // array. + // Put only the used texture coordinates into the interleaved array. The + // others will be kept around, but in a parallel array. if (_texture != (TextureAttrib *)NULL) { typedef pset UsedStages; UsedStages used_stages; @@ -401,9 +385,8 @@ premunge_format_impl(const GeomVertexFormat *orig) { } } - // Now go through the remaining arrays and make sure they are - // tightly packed (with the column alignment restrictions). If - // not, repack them. + // Now go through the remaining arrays and make sure they are tightly + // packed (with the column alignment restrictions). If not, repack them. for (int i = 0; i < new_format->get_num_arrays(); ++i) { CPT(GeomVertexArrayFormat) orig_a = new_format->get_array(i); if (orig_a->count_unused_space() != 0) { @@ -427,11 +410,9 @@ premunge_format_impl(const GeomVertexFormat *orig) { } #ifdef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::munge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void CLP(GeomMunger):: munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, Thread *current_thread) { @@ -446,11 +427,9 @@ munge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data, } } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::premunge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void CLP(GeomMunger):: premunge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) { StandardMunger::premunge_geom_impl(geom, vertex_data); @@ -465,14 +444,11 @@ premunge_geom_impl(CPT(Geom) &geom, CPT(GeomVertexData) &vertex_data) { } #endif // OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int CLP(GeomMunger):: compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; @@ -489,14 +465,11 @@ compare_to_impl(const GeomMunger *other) const { return StandardMunger::compare_to_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GeomMunger)::geom_compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int CLP(GeomMunger):: geom_compare_to_impl(const GeomMunger *other) const { const CLP(GeomMunger) *om = (CLP(GeomMunger) *)other; diff --git a/panda/src/glstuff/glGeomMunger_src.h b/panda/src/glstuff/glGeomMunger_src.h index 0c2eaabc8b..5122dda25f 100644 --- a/panda/src/glstuff/glGeomMunger_src.h +++ b/panda/src/glstuff/glGeomMunger_src.h @@ -1,16 +1,15 @@ -// Filename: glGeomMunger_src.h -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGeomMunger_src.h + * @author drose + * @date 2005-03-10 + */ #include "pandabase.h" #include "standardMunger.h" @@ -23,12 +22,11 @@ class CLP(GeomContext); -//////////////////////////////////////////////////////////////////// -// Class : GLGeomMunger -// Description : This specialization on GeomMunger finesses vertices -// for OpenGL rendering. In particular, it makes sure -// colors aren't stored in DirectX's packed_argb format. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on GeomMunger finesses vertices for OpenGL rendering. + * In particular, it makes sure colors aren't stored in DirectX's packed_argb + * format. + */ class EXPCL_GL CLP(GeomMunger) : public StandardMunger, public WeakPointerCallback { public: CLP(GeomMunger)(GraphicsStateGuardian *gsg, const RenderState *state); @@ -85,4 +83,3 @@ private: }; #include "glGeomMunger_src.I" - diff --git a/panda/src/glstuff/glGraphicsBuffer_src.I b/panda/src/glstuff/glGraphicsBuffer_src.I index aa362b5b16..021116b7ff 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.I +++ b/panda/src/glstuff/glGraphicsBuffer_src.I @@ -1,16 +1,15 @@ -// Filename: glGraphicsBuffer_src.I -// Created by: jyelon (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsBuffer_src.I + * @author jyelon + * @date 2006-01-15 + */ INLINE int CLP(GraphicsBuffer):: get_multisample_count() diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index a3b07a33f6..9d06e21348 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1,26 +1,23 @@ -// Filename: glGraphicsBuffer_src.cxx -// Created by: jyelon (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsBuffer_src.cxx + * @author jyelon + * @date 2006-01-15 + */ #include "depthWriteAttrib.h" TypeHandle CLP(GraphicsBuffer)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GraphicsBuffer):: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -59,11 +56,9 @@ CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, _bound_tex_page = -1; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GraphicsBuffer):: ~CLP(GraphicsBuffer)() { // unshare shared depth buffer if any @@ -87,16 +82,13 @@ CLP(GraphicsBuffer):: } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsBuffer::clear -// Access: Public, Virtual -// Description: Clears the entire framebuffer before rendering, -// according to the settings of get_color_clear_active() -// and get_depth_clear_active() (inherited from -// DrawableRegion). -// -// This function is called only within the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Clears the entire framebuffer before rendering, according to the settings + * of get_color_clear_active() and get_depth_clear_active() (inherited from + * DrawableRegion). + * + * This function is called only within the draw thread. + */ void CLP(GraphicsBuffer):: clear(Thread *current_thread) { if (!is_any_clear_active()) { @@ -107,8 +99,8 @@ clear(Thread *current_thread) { DCAST_INTO_V(glgsg, _gsg); if (glgsg->_glClearBufferfv == NULL) { - // We can't efficiently clear the buffer. Fall back to the - // inefficient default implementation for now. + // We can't efficiently clear the buffer. Fall back to the inefficient + // default implementation for now. GraphicsOutput::clear(current_thread); return; } @@ -201,15 +193,12 @@ clear(Thread *current_thread) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool CLP(GraphicsBuffer):: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -238,8 +227,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { clear_cube_map_selection(); { - // If the set of render-to-textures has recently changed, we - // need to rebuild bitplanes. + // If the set of render-to-textures has recently changed, we need to + // rebuild bitplanes. CDReader cdata(_cycler); if (cdata->_textures_seq != _last_textures_seq) { _last_textures_seq = cdata->_textures_seq; @@ -261,8 +250,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } - // In case of multisample rendering, we don't need to issue - // the barrier until we call glBlitFramebuffer. + // In case of multisample rendering, we don't need to issue the barrier + // until we call glBlitFramebuffer. #ifndef OPENGLES if (gl_enable_memory_barriers && _fbo_multisample == 0) { CLP(GraphicsStateGuardian) *glgsg; @@ -287,13 +276,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::check_fbo -// Access: Private -// Description: Calls 'glCheckFramebufferStatus'. On error, -// prints out an appropriate error message and unbinds -// the fbo. Returns true for OK or false for error. -//////////////////////////////////////////////////////////////////// +/** + * Calls 'glCheckFramebufferStatus'. On error, prints out an appropriate + * error message and unbinds the fbo. Returns true for OK or false for error. + */ bool CLP(GraphicsBuffer):: check_fbo() { CLP(GraphicsStateGuardian) *glgsg; @@ -340,13 +326,11 @@ check_fbo() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::rebuild_bitplanes -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// to allocate/reallocate the fbo and all the associated -// renderbuffers, just before rendering a frame. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread to allocate/reallocate + * the fbo and all the associated renderbuffers, just before rendering a + * frame. + */ void CLP(GraphicsBuffer):: rebuild_bitplanes() { check_host_valid(); @@ -406,8 +390,8 @@ rebuild_bitplanes() { { CDReader cdata(_cycler); - // Determine whether this will be a layered or a regular FBO. - // If layered, the number of _rb_size_z will be higher than 1. + // Determine whether this will be a layered or a regular FBO. If layered, + // the number of _rb_size_z will be higher than 1. for (size_t i = 0; i != cdata->_textures.size(); ++i) { const RenderTexture &rt = cdata->_textures[i]; RenderTextureMode rtm_mode = rt._rtm_mode; @@ -456,9 +440,8 @@ rebuild_bitplanes() { continue; } - // If I can't find an appropriate slot, or if there's - // already a texture bound to this slot, then punt - // this texture. + // If I can't find an appropriate slot, or if there's already a texture + // bound to this slot, then punt this texture. if (attach[plane]) { ((CData *)cdata.p())->_textures[i]._rtm_mode = RTM_copy_texture; continue; @@ -483,8 +466,8 @@ rebuild_bitplanes() { _use_depth_stencil = true; } else if (attach[RTP_depth]) { - // We won't use a depth stencil texture as the user - // explicitly bound something to RTP_depth. + // We won't use a depth stencil texture as the user explicitly bound + // something to RTP_depth. _use_depth_stencil = false; } else if (_fb_properties.get_stencil_bits() > 0) { @@ -498,8 +481,8 @@ rebuild_bitplanes() { _use_depth_stencil = false; } else if (_fb_properties.get_depth_bits() > 0) { - // Let's use a depth stencil buffer by default, if a depth - // buffer was requested. + // Let's use a depth stencil buffer by default, if a depth buffer was + // requested. _use_depth_stencil = true; } } else if (attach[RTP_depth_stencil] != NULL && attach[RTP_depth] == NULL) { @@ -516,9 +499,9 @@ rebuild_bitplanes() { _fb_properties.set_stencil_bits(0); } - // Having both a depth texture and a depth_stencil texture is - // invalid: depth_stencil implies depth, and we can't bind them - // both. Detect that case, normalize it, and complain. + // Having both a depth texture and a depth_stencil texture is invalid: + // depth_stencil implies depth, and we can't bind them both. Detect that + // case, normalize it, and complain. if (_use_depth_stencil && attach[RTP_depth] && attach[RTP_depth_stencil]) { attach[RTP_depth] = NULL; GLCAT.warning() << "Attempt to bind both RTP_depth and RTP_depth_stencil bitplanes.\n"; @@ -568,13 +551,15 @@ rebuild_bitplanes() { bind_slot(layer, rb_resize, attach, RTP_color, next++); if (_fb_properties.is_stereo()) { - // The second tex view has already been initialized, so bind it straight away. + // The second tex view has already been initialized, so bind it + // straight away. if (attach[RTP_color] != NULL) { attach_tex(layer, 1, attach[RTP_color], next++); } else { - //XXX hack: I needed a slot to use, and we don't currently use RTP_stencil - // and it's treated as a color attachment below, so this fits the bill. - // Eventually, we might want to add RTP_color_left and RTP_color_right. + // XXX hack: I needed a slot to use, and we don't currently use + // RTP_stencil and it's treated as a color attachment below, so this + // fits the bill. Eventually, we might want to add RTP_color_left + // and RTP_color_right. bind_slot(layer, rb_resize, attach, RTP_stencil, next++); } } @@ -596,7 +581,8 @@ rebuild_bitplanes() { } #endif // OPENGLES - // Clear if the fbo was just created, regardless of the clear settings per frame. + // Clear if the fbo was just created, regardless of the clear settings per + // frame. if (_initial_clear) { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -604,7 +590,8 @@ rebuild_bitplanes() { } #ifndef OPENGLES - // Setup any required multisample buffers. Does not work for layered buffers. + // Setup any required multisample buffers. Does not work for layered + // buffers. if (_requested_multisamples && _rb_size_z == 1) { if (_fbo_multisample == 0) { glgsg->_glGenFramebuffers(1, &_fbo_multisample); @@ -619,7 +606,8 @@ rebuild_bitplanes() { if (attach[RTP_color] || _fb_properties.get_color_bits() > 0) { bind_slot_multisample(rb_resize, attach, RTP_color, next++); if (_fb_properties.is_stereo()) { - //TODO: figure out how multisample is supposed to work with stereo buffers. + // TODO: figure out how multisample is supposed to work with stereo + // buffers. } } @@ -675,12 +663,9 @@ rebuild_bitplanes() { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::bind_slot -// Access: Private -// Description: Attaches either a texture or a renderbuffer to the -// specified bitplane. -//////////////////////////////////////////////////////////////////// +/** + * Attaches either a texture or a renderbuffer to the specified bitplane. + */ void CLP(GraphicsBuffer):: bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum attachpoint) { CLP(GraphicsStateGuardian) *glgsg; @@ -689,19 +674,21 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, Texture *tex = attach[slot]; if (tex && layer >= tex->get_z_size()) { - // If the requested layer index exceeds the number of layers - // in the texture, we will not bind this layer. + // If the requested layer index exceeds the number of layers in the + // texture, we will not bind this layer. tex = NULL; } if (!tex && _rb_size_z > 1) { - // Since there is no such thing as a layered renderbuffer (to my knowledge), - // we have to create a dummy texture to render to if no texture was provided. + // Since there is no such thing as a layered renderbuffer (to my + // knowledge), we have to create a dummy texture to render to if no + // texture was provided. tex = new Texture(); if (_rb_size_z > 1) { - // Apparently, it doesn't make a difference whether we use setup_cube_map - // or setup_2d_texture_array here, since it's the same internal storage. + // Apparently, it doesn't make a difference whether we use + // setup_cube_map or setup_2d_texture_array here, since it's the same + // internal storage. tex->setup_2d_texture_array(_rb_size_z); } else { tex->setup_2d_texture(); @@ -806,8 +793,8 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, report_my_gl_errors(); } else { - // No texture to bind. Instead, create a renderbuffer. - // Choose a suitable renderbuffer format based on the requirements. + // No texture to bind. Instead, create a renderbuffer. Choose a suitable + // renderbuffer format based on the requirements. #ifdef OPENGLES // OpenGL ES case. GLuint gl_format = GL_RGBA4; @@ -824,10 +811,8 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, gl_format = GL_DEPTH_COMPONENT16; } break; - //NB: we currently use RTP_stencil to store the right eye for stereo. - //case RTP_stencil: - // gl_format = GL_STENCIL_INDEX8; - // break + // NB: we currently use RTP_stencil to store the right eye for stereo. + // case RTP_stencil: gl_format = GL_STENCIL_INDEX8; break default: if (_fb_properties.get_alpha_bits() == 0) { if (_fb_properties.get_color_bits() <= 16) { @@ -1014,13 +999,10 @@ bind_slot(int layer, bool rb_resize, Texture **attach, RenderTexturePlane slot, } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::bind_slot_multisample -// Access: Private -// Description: Attaches incoming Texture or renderbuffer to the -// required bitplanes for the 2 FBOs comprising a -// multisample graphics buffer. -//////////////////////////////////////////////////////////////////// +/** + * Attaches incoming Texture or renderbuffer to the required bitplanes for the + * 2 FBOs comprising a multisample graphics buffer. + */ void CLP(GraphicsBuffer):: bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot, GLenum attachpoint) { CLP(GraphicsStateGuardian) *glgsg; @@ -1143,12 +1125,9 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot, glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::attach_tex -// Access: Private -// Description: This function attaches the given texture to the -// given attachment point. -//////////////////////////////////////////////////////////////////// +/** + * This function attaches the given texture to the given attachment point. + */ void CLP(GraphicsBuffer):: attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { CLP(GraphicsStateGuardian) *glgsg; @@ -1167,8 +1146,8 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { gtc->set_active(true); _texture_contexts.push_back(gtc); - // It seems that binding the texture is necessary before binding - // to a framebuffer attachment. + // It seems that binding the texture is necessary before binding to a + // framebuffer attachment. glgsg->apply_texture(gtc); #if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) @@ -1210,15 +1189,12 @@ attach_tex(int layer, int view, Texture *attach, GLenum attachpoint) { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::generate_mipmaps -// Access: Private -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. -// If we've just rendered into level zero of a mipmapped -// texture, then all subsequent mipmap levels will now -// be calculated. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. If we've just rendered into level zero of a + * mipmapped texture, then all subsequent mipmap levels will now be + * calculated. + */ void CLP(GraphicsBuffer):: generate_mipmaps() { if (gl_ignore_mipmaps && !gl_force_mipmaps) { @@ -1228,7 +1204,7 @@ generate_mipmaps() { CLP(GraphicsStateGuardian) *glgsg; DCAST_INTO_V(glgsg, _gsg); - //PStatGPUTimer timer(glgsg, _generate_mipmap_pcollector); + // PStatGPUTimer timer(glgsg, _generate_mipmap_pcollector); pvector::iterator it; for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { @@ -1242,13 +1218,11 @@ generate_mipmaps() { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void CLP(GraphicsBuffer):: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -1263,8 +1237,8 @@ end_frame(FrameMode mode, Thread *current_thread) { copy_to_textures(); } - // Unbind the FBO. TODO: calling bind_fbo is slow, so we should - // probably move this to begin_frame to prevent unnecessary calls. + // Unbind the FBO. TODO: calling bind_fbo is slow, so we should probably + // move this to begin_frame to prevent unnecessary calls. CLP(GraphicsStateGuardian) *glgsg; DCAST_INTO_V(glgsg, _gsg); glgsg->bind_fbo(0); @@ -1283,11 +1257,9 @@ end_frame(FrameMode mode, Thread *current_thread) { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::set_size -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsBuffer):: set_size(int x, int y) { if (_size.get_x() != x || _size.get_y() != y) { @@ -1297,15 +1269,12 @@ set_size(int x, int y) { set_size_and_recalc(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::select_target_tex_page -// Access: Public, Virtual -// Description: Called internally when the window is in -// render-to-a-texture mode and we are in the process of -// rendering the six faces of a cube map, or any other -// multi-page texture. This should do whatever needs -// to be done to switch the buffer to the indicated page. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the window is in render-to-a-texture mode and we are + * in the process of rendering the six faces of a cube map, or any other + * multi-page texture. This should do whatever needs to be done to switch the + * buffer to the indicated page. + */ void CLP(GraphicsBuffer):: select_target_tex_page(int page) { nassertv(page >= 0 && page < _fbo.size()); @@ -1334,13 +1303,10 @@ select_target_tex_page(int page) { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool CLP(GraphicsBuffer):: open_buffer() { report_my_gl_errors(); @@ -1366,20 +1332,19 @@ open_buffer() { _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency)); } - // Describe the framebuffer properties of the FBO. - // - // Unfortunately, we can't currently predict which formats - // the implementation will allow us to use at this point, so - // we'll just have to make some guesses and parrot the rest - // of the properties back to the user. - // When we actually attach the textures, we'll update the - // properties more appropriately. +/* + * Describe the framebuffer properties of the FBO. Unfortunately, we can't + * currently predict which formats the implementation will allow us to use at + * this point, so we'll just have to make some guesses and parrot the rest of + * the properties back to the user. When we actually attach the textures, + * we'll update the properties more appropriately. + */ - // Rounding the depth bits is not spectacular, but at least we're - // telling the user *something* about what we're going to get. + // Rounding the depth bits is not spectacular, but at least we're telling + // the user *something* about what we're going to get. - // A lot of code seems to depend on being able to get a - // color buffer by just setting the rgb_color bit. + // A lot of code seems to depend on being able to get a color buffer by just + // setting the rgb_color bit. if (_fb_properties.get_color_bits() == 0 && _fb_properties.get_rgb_color()) { _fb_properties.set_color_bits(1); @@ -1388,8 +1353,8 @@ open_buffer() { _fb_properties.set_blue_bits(1); } - // Actually, let's always get a colour buffer for now until we - // figure out why Intel HD Graphics cards complain otherwise. + // Actually, let's always get a colour buffer for now until we figure out + // why Intel HD Graphics cards complain otherwise. if (gl_force_fbo_color && _fb_properties.get_color_bits() == 0) { _fb_properties.set_color_bits(1); } @@ -1461,7 +1426,8 @@ open_buffer() { #ifndef OPENGLES if (glgsg->get_supports_framebuffer_multisample_coverage_nv() && glgsg->get_supports_framebuffer_blit()) { _requested_coverage_samples = _fb_properties.get_coverage_samples(); - // Note: Only 4 and 8 actual samples are supported by the extension, with 8 or 16 coverage samples. + // Note: Only 4 and 8 actual samples are supported by the extension, with + // 8 or 16 coverage samples. if ((_requested_coverage_samples <= 8) && (_requested_coverage_samples > 0)) { _requested_multisamples = 4; _requested_coverage_samples = 8; @@ -1485,8 +1451,8 @@ open_buffer() { _fb_properties.set_multisamples(_requested_multisamples); _fb_properties.set_coverage_samples(_requested_coverage_samples); - // Update aux settings to reflect the GL_MAX_DRAW_BUFFERS limit, - // if we exceed it, that is. + // Update aux settings to reflect the GL_MAX_DRAW_BUFFERS limit, if we + // exceed it, that is. int availcolor = glgsg->_max_color_targets; if (totalcolor > availcolor) { @@ -1529,12 +1495,9 @@ open_buffer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void CLP(GraphicsBuffer):: close_buffer() { _rb_data_size_bytes = 0; @@ -1588,13 +1551,10 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::share_depth_buffer -// Access: Published -// Description: Will attempt to use the depth buffer of the input -// graphics_output. The buffer sizes must be exactly -// the same. -//////////////////////////////////////////////////////////////////// +/** + * Will attempt to use the depth buffer of the input graphics_output. The + * buffer sizes must be exactly the same. + */ bool CLP(GraphicsBuffer):: share_depth_buffer(GraphicsOutput *graphics_output) { @@ -1637,8 +1597,8 @@ share_depth_buffer(GraphicsOutput *graphics_output) { } if (state) { - // let the input GraphicsOutput know that there is an object - // sharing its depth buffer + // let the input GraphicsOutput know that there is an object sharing its + // depth buffer input_graphics_output->register_shared_depth_buffer(this); _shared_depth_buffer = input_graphics_output; state = true; @@ -1649,41 +1609,34 @@ share_depth_buffer(GraphicsOutput *graphics_output) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::unshare_depth_buffer -// Access: Published -// Description: Discontinue sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Discontinue sharing the depth buffer. + */ void CLP(GraphicsBuffer):: unshare_depth_buffer() { if (_shared_depth_buffer) { - // let the GraphicsOutput know that this object is no longer - // sharing its depth buffer + // let the GraphicsOutput know that this object is no longer sharing its + // depth buffer _shared_depth_buffer->unregister_shared_depth_buffer(this); _shared_depth_buffer = 0; _needs_rebuild = true; } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::get_supports_render_texture -// Access: Published, Virtual -// Description: Returns true if this particular GraphicsOutput can -// render directly into a texture, or false if it must -// always copy-to-texture at the end of each frame to -// achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GraphicsOutput can render directly into a + * texture, or false if it must always copy-to-texture at the end of each + * frame to achieve this effect. + */ bool CLP(GraphicsBuffer):: get_supports_render_texture() const { // FBO-based buffers, by their nature, can always bind-to-texture. return true; } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::register_shared_depth_buffer -// Access: Public -// Description: Register/save who is sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Register/save who is sharing the depth buffer. + */ void CLP(GraphicsBuffer):: register_shared_depth_buffer(GraphicsOutput *graphics_output) { CLP(GraphicsBuffer) *input_graphics_output; @@ -1695,11 +1648,9 @@ register_shared_depth_buffer(GraphicsOutput *graphics_output) { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::unregister_shared_depth_buffer -// Access: Public -// Description: Unregister who is sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Unregister who is sharing the depth buffer. + */ void CLP(GraphicsBuffer):: unregister_shared_depth_buffer(GraphicsOutput *graphics_output) { CLP(GraphicsBuffer) *input_graphics_output; @@ -1711,11 +1662,9 @@ unregister_shared_depth_buffer(GraphicsOutput *graphics_output) { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::unregister_shared_depth_buffer -// Access: Public -// Description: Unregister who is sharing the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Unregister who is sharing the depth buffer. + */ void CLP(GraphicsBuffer):: report_my_errors(int line, const char *file) { if (_gsg == 0) { @@ -1730,20 +1679,16 @@ report_my_errors(int line, const char *file) { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::check_host_valid -// Access: Public -// Description: If the host window has been closed, then -// this buffer is dead too. -//////////////////////////////////////////////////////////////////// +/** + * If the host window has been closed, then this buffer is dead too. + */ void CLP(GraphicsBuffer):: check_host_valid() { if ((_host == 0)||(!_host->is_valid())) { _rb_data_size_bytes = 0; if (_rb_context != NULL) { - // We must delete this object first, because when the GSG - // destructs, so will the tracker that this context is - // attached to. + // We must delete this object first, because when the GSG destructs, so + // will the tracker that this context is attached to. _rb_context->update_data_size_bytes(0); delete _rb_context; _rb_context = NULL; @@ -1754,13 +1699,10 @@ check_host_valid() { } } -//////////////////////////////////////////////////////////////////// -// Function: glGraphicsBuffer::resolve_multisamples -// Access: Private -// Description: After the frame has been rendered into the -// multisample buffer, filters it down into the final -// render buffer. -//////////////////////////////////////////////////////////////////// +/** + * After the frame has been rendered into the multisample buffer, filters it + * down into the final render buffer. + */ void CLP(GraphicsBuffer):: resolve_multisamples() { nassertv(_fbo.size() > 0); @@ -1772,8 +1714,8 @@ resolve_multisamples() { #ifndef OPENGLES if (gl_enable_memory_barriers) { - // Issue memory barriers as necessary to make sure that the - // texture memory is synchronized before we blit to it. + // Issue memory barriers as necessary to make sure that the texture memory + // is synchronized before we blit to it. pvector::iterator it; for (it = _texture_contexts.begin(); it != _texture_contexts.end(); ++it) { CLP(TextureContext) *gtc = *it; diff --git a/panda/src/glstuff/glGraphicsBuffer_src.h b/panda/src/glstuff/glGraphicsBuffer_src.h index fe1d55ae92..9f99850a7f 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.h +++ b/panda/src/glstuff/glGraphicsBuffer_src.h @@ -1,62 +1,52 @@ -// Filename: glGraphicsBuffer_src.h -// Created by: jyelon (15Jan06) -// Modified by: kleonard (27Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsBuffer_src.h + * @author jyelon + * @date 2006-01-15 + * @author kleonard + * @date 2007-06-27 + */ #include "pandabase.h" #include "graphicsBuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : glGraphicsBuffer -// Description : An offscreen render buffer. -// -// The glGraphicsBuffer is based on the OpenGL -// EXT_framebuffer_object and ARB_draw_buffers extensions. -// This design has significant advantages over the -// older wglGraphicsBuffer and glxGraphicsBuffer: -// -// * Can export depth and stencil. -// * Supports auxiliary bitplanes. -// * Supports non-power-of-two padding. -// * Supports tracking of host window size. -// * Supports cumulative render-to-texture. -// * Faster than pbuffers. -// * Can render onto a texture without clearing it first. -// * Supports multisample antialiased rendering. -// -// Some of these deserve a little explanation. -// Auxiliary bitplanes are additional bitplanes above -// and beyond the normal depth,stencil,color. One can -// use them to render out multiple textures in a single -// pass. Cumulative render-to-texture means that if -// don't clear the buffer, then the contents of the -// buffer will be equal to the texture's previous -// contents. This alo means you can meaningfully -// share a bitplane between two buffers by binding -// the same texture to both buffers. -// -// If either of the necessary OpenGL extensions is not -// available, then the glGraphicsBuffer will not be -// available (although it may still be possible to -// create a wglGraphicsBuffer or glxGraphicsBuffer). -// -// This class now also uses the extensions -// EXT_framebuffer_multisample and EXT_framebuffer_blit -// to allow for multisample antialiasing these offscreen -// render targets. If these extensions are unavailable -// the buffer will render as if multisamples is 0. -// -//////////////////////////////////////////////////////////////////// +/** + * An offscreen render buffer. + * + * The glGraphicsBuffer is based on the OpenGL EXT_framebuffer_object and + * ARB_draw_buffers extensions. This design has significant advantages over + * the older wglGraphicsBuffer and glxGraphicsBuffer: + * + * * Can export depth and stencil. * Supports auxiliary bitplanes. * + * Supports non-power-of-two padding. * Supports tracking of host window + * size. * Supports cumulative render-to-texture. * Faster than pbuffers. * + * Can render onto a texture without clearing it first. * Supports + * multisample antialiased rendering. + * + * Some of these deserve a little explanation. Auxiliary bitplanes are + * additional bitplanes above and beyond the normal depth,stencil,color. One + * can use them to render out multiple textures in a single pass. Cumulative + * render-to-texture means that if don't clear the buffer, then the contents + * of the buffer will be equal to the texture's previous contents. This alo + * means you can meaningfully share a bitplane between two buffers by binding + * the same texture to both buffers. + * + * If either of the necessary OpenGL extensions is not available, then the + * glGraphicsBuffer will not be available (although it may still be possible + * to create a wglGraphicsBuffer or glxGraphicsBuffer). + * + * This class now also uses the extensions EXT_framebuffer_multisample and + * EXT_framebuffer_blit to allow for multisample antialiasing these offscreen + * render targets. If these extensions are unavailable the buffer will render + * as if multisamples is 0. + * + */ class EXPCL_GL CLP(GraphicsBuffer) : public GraphicsBuffer { public: CLP(GraphicsBuffer)(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -106,12 +96,12 @@ private: void rebuild_bitplanes(); void resolve_multisamples(); - // We create one FBO for each cube map face we'll be rendering to. - // If we aren't rendering to any cube maps, we use only _fbo[0]. + // We create one FBO for each cube map face we'll be rendering to. If we + // aren't rendering to any cube maps, we use only _fbo[0]. pvector _fbo; - // For multisample we render first to a multisample buffer, then - // filter it to _fbo[face] at the end of the frame. + // For multisample we render first to a multisample buffer, then filter it + // to _fbo[face] at the end of the frame. GLuint _fbo_multisample; int _requested_multisamples; int _requested_coverage_samples; @@ -122,8 +112,8 @@ private: int _rb_size_y; int _rb_size_z; - // Stores the render buffers for each plane. - // _rbm stores the multisample renderbuffers. + // Stores the render buffers for each plane. _rbm stores the multisample + // renderbuffers. GLuint _rb[RTP_COUNT]; GLuint _rbm[RTP_COUNT]; @@ -131,13 +121,13 @@ private: BufferContext *_rb_context; size_t _rb_data_size_bytes; - // List of textures for which we might have to generate mipmaps - // after rendering one frame. + // List of textures for which we might have to generate mipmaps after + // rendering one frame. typedef pvector TextureContexts; TextureContexts _texture_contexts; - // The cube map face we are currently drawing to or have just - // finished drawing to, or -1 if we are not drawing to a cube map. + // The cube map face we are currently drawing to or have just finished + // drawing to, or -1 if we are not drawing to a cube map. int _bound_tex_page; bool _initial_clear; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.I b/panda/src/glstuff/glGraphicsStateGuardian_src.I index 2055f56b6c..a1fa34dd4a 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.I +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.I @@ -1,29 +1,24 @@ -// Filename: glGraphicsStateGuardian_src.I -// Created by: drose (02Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsStateGuardian_src.I + * @author drose + * @date 1999-02-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::report_errors -// Access: Public, Static -// Description: Checks for any outstanding error codes and outputs -// them, if found. If NDEBUG is defined, this function -// does nothing. The return value is true if everything is -// ok, or false if we should shut down. -// -// This is a static method so it can be called when -// there's no gsg pointer around. -//////////////////////////////////////////////////////////////////// +/** + * Checks for any outstanding error codes and outputs them, if found. If + * NDEBUG is defined, this function does nothing. The return value is true if + * everything is ok, or false if we should shut down. + * + * This is a static method so it can be called when there's no gsg pointer + * around. + */ INLINE bool CLP(GraphicsStateGuardian):: report_errors(int line, const char *source_file) { #ifndef NDEBUG @@ -37,12 +32,10 @@ report_errors(int line, const char *source_file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::report_my_errors -// Access: Public -// Description: Like report_errors(), above, but non-static so we can -// throw an event on failure. -//////////////////////////////////////////////////////////////////// +/** + * Like report_errors(), above, but non-static so we can throw an event on + * failure. + */ INLINE void CLP(GraphicsStateGuardian):: report_my_errors(int line, const char *source_file) { #ifndef NDEBUG @@ -58,17 +51,14 @@ report_my_errors(int line, const char *source_file) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::clear_errors -// Access: Public, Static -// Description: This works like report_errors(), except that it -// always runs, even in the NDEBUG case. -// -// It is designed to be called when it is important to -// clear the error stack (for instance, because we want -// to be able to reliably check the result of some -// upcoming GL operation). -//////////////////////////////////////////////////////////////////// +/** + * This works like report_errors(), except that it always runs, even in the + * NDEBUG case. + * + * It is designed to be called when it is important to clear the error stack + * (for instance, because we want to be able to reliably check the result of + * some upcoming GL operation). + */ INLINE bool CLP(GraphicsStateGuardian):: clear_errors(int line, const char *source_file) { PStatTimer timer(_check_error_pcollector); @@ -81,17 +71,13 @@ clear_errors(int line, const char *source_file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::clear_my_errors -// Access: Public -// Description: This works like report_my_errors(), except that it -// always runs, even in the NDEBUG case (but not when -// _check_errors is false), and it never calls -// panic_deactivate(). It is designed to be called when -// it is important to clear the error stack (for -// instance, because we want to be able to reliably -// check the result of some upcoming GL operation). -//////////////////////////////////////////////////////////////////// +/** + * This works like report_my_errors(), except that it always runs, even in the + * NDEBUG case (but not when _check_errors is false), and it never calls + * panic_deactivate(). It is designed to be called when it is important to + * clear the error stack (for instance, because we want to be able to reliably + * check the result of some upcoming GL operation). + */ INLINE void CLP(GraphicsStateGuardian):: clear_my_errors(int line, const char *source_file) { if (_check_errors) { @@ -104,64 +90,49 @@ clear_my_errors(int line, const char *source_file) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_gl_vendor -// Access: Public -// Description: Returns the GL vendor string reported by the driver. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GL vendor string reported by the driver. + */ INLINE const string &CLP(GraphicsStateGuardian):: get_gl_vendor() const { return _gl_vendor; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_gl_renderer -// Access: Public -// Description: Returns the GL renderer string reported by the driver. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GL renderer string reported by the driver. + */ INLINE const string &CLP(GraphicsStateGuardian):: get_gl_renderer() const { return _gl_renderer; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_gl_version -// Access: Public -// Description: Returns the GL version string reported by the driver. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GL version string reported by the driver. + */ INLINE const string &CLP(GraphicsStateGuardian):: get_gl_version() const { return _gl_version; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_gl_version_major -// Access: Public -// Description: Returns the major part of the reported GL version -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major part of the reported GL version number. + */ INLINE int CLP(GraphicsStateGuardian):: get_gl_version_major() const { return _gl_version_major; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_gl_version_minor -// Access: Public -// Description: Returns the minor part of the reported GL version -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor part of the reported GL version number. + */ INLINE int CLP(GraphicsStateGuardian):: get_gl_version_minor() const { return _gl_version_minor; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::maybe_gl_finish -// Access: Protected -// Description: Calls glFinish() if the config variable gl-finish is -// set True. -//////////////////////////////////////////////////////////////////// +/** + * Calls glFinish() if the config variable gl-finish is set True. + */ INLINE void CLP(GraphicsStateGuardian):: maybe_gl_finish() const { #ifdef DO_PSTATS @@ -171,13 +142,10 @@ maybe_gl_finish() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::has_extension -// Access: Published, Final -// Description: Returns true if the indicated extension is reported -// by the GL system, false otherwise. The extension -// name is case-sensitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated extension is reported by the GL system, false + * otherwise. The extension name is case-sensitive. + */ INLINE bool CLP(GraphicsStateGuardian):: has_extension(const string &extension) const { bool has_ext = (_extensions.find(extension) != _extensions.end()); @@ -190,14 +158,11 @@ has_extension(const string &extension) const { return has_ext; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::is_at_least_gl_version -// Access: Public -// Description: Returns true if we are compiled for mainline OpenGL, -// and the runtime GL version number is at least the -// indicated value, false otherwise. Under OpenGL ES, -// this always returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we are compiled for mainline OpenGL, and the runtime GL + * version number is at least the indicated value, false otherwise. Under + * OpenGL ES, this always returns false. + */ INLINE bool CLP(GraphicsStateGuardian):: is_at_least_gl_version(int major_version, int minor_version) const { #ifdef OPENGLES @@ -215,14 +180,11 @@ is_at_least_gl_version(int major_version, int minor_version) const { #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::is_at_least_gles_version -// Access: Public -// Description: Returns true if we are compiled for OpenGL ES, -// and the runtime GL ES version number is at least the -// indicated value, false otherwise. Under mainline -// OpenGL, this always returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we are compiled for OpenGL ES, and the runtime GL ES + * version number is at least the indicated value, false otherwise. Under + * mainline OpenGL, this always returns false. + */ INLINE bool CLP(GraphicsStateGuardian):: is_at_least_gles_version(int major_version, int minor_version) const { #ifndef OPENGLES @@ -241,11 +203,9 @@ is_at_least_gles_version(int major_version, int minor_version) const { } #ifndef OPENGLES_1 -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_vertex_attrib_array -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_vertex_attrib_array(GLuint index) { if (!_enabled_vertex_attrib_arrays.get_bit(index)) { @@ -254,11 +214,9 @@ enable_vertex_attrib_array(GLuint index) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::disable_vertex_attrib_array -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: disable_vertex_attrib_array(GLuint index) { if (_enabled_vertex_attrib_arrays.get_bit(index)) { @@ -272,11 +230,9 @@ disable_vertex_attrib_array(GLuint index) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_vertex_attrib_divisor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: set_vertex_attrib_divisor(GLuint index, GLuint divisor) { if (_supports_vertex_attrib_divisor && @@ -288,11 +244,9 @@ set_vertex_attrib_divisor(GLuint index, GLuint divisor) { #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_active_texture_stage -// Access: Protected -// Description: Calls glActiveTexture. -//////////////////////////////////////////////////////////////////// +/** + * Calls glActiveTexture. + */ INLINE void CLP(GraphicsStateGuardian):: set_active_texture_stage(int i) { if (i != _active_texture_stage) { @@ -305,12 +259,9 @@ set_active_texture_stage(int i) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_multisample_antialias -// Access: Protected -// Description: Specifies whether multisample should be enabled for -// antialiasing purposes. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether multisample should be enabled for antialiasing purposes. + */ INLINE void CLP(GraphicsStateGuardian):: enable_multisample_antialias(bool val) { #ifndef OPENGLES_2 @@ -332,13 +283,10 @@ enable_multisample_antialias(bool val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_multisample_alpha_one -// Access: Protected -// Description: Specifies whether multisample should be enabled for -// transparency purposes, using the sample_alpha_to_one -// mode. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether multisample should be enabled for transparency purposes, + * using the sample_alpha_to_one mode. + */ INLINE void CLP(GraphicsStateGuardian):: enable_multisample_alpha_one(bool val) { #ifndef OPENGLES_2 @@ -362,13 +310,10 @@ enable_multisample_alpha_one(bool val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_multisample_alpha_mask -// Access: Protected -// Description: Specifies whether multisample should be enabled for -// transparency purposes, using the sample_alpha_to_mask -// mode. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether multisample should be enabled for transparency purposes, + * using the sample_alpha_to_mask mode. + */ INLINE void CLP(GraphicsStateGuardian):: enable_multisample_alpha_mask(bool val) { #ifndef OPENGLES_2 @@ -392,11 +337,9 @@ enable_multisample_alpha_mask(bool val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_line_smooth -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_line_smooth(bool val) { #ifndef OPENGLES_2 @@ -412,11 +355,9 @@ enable_line_smooth(bool val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_point_smooth -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_point_smooth(bool val) { #ifdef SUPPORT_FIXED_FUNCTION @@ -432,11 +373,9 @@ enable_point_smooth(bool val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_polygon_smooth -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_polygon_smooth(bool val) { #ifndef OPENGLES // GL_POLYGON_SMOOTH not supported in OpenGL ES. @@ -451,47 +390,38 @@ enable_polygon_smooth(bool val) { #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::setup_antialias_line -// Access: Protected -// Description: Sets the appropriate antialiasing modes to render a -// series of line primitives, according to -// _auto_antialias_mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the appropriate antialiasing modes to render a series of line + * primitives, according to _auto_antialias_mode. + */ INLINE void CLP(GraphicsStateGuardian):: setup_antialias_line() { if (_auto_antialias_mode) { - // Lines supposedly look better using line smoothing, even if we - // have multisample available. + // Lines supposedly look better using line smoothing, even if we have + // multisample available. enable_multisample_antialias(false); enable_line_smooth(true); } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::setup_antialias_point -// Access: Protected -// Description: Sets the appropriate antialiasing modes to render a -// series of point primitives, according to -// _auto_antialias_mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the appropriate antialiasing modes to render a series of point + * primitives, according to _auto_antialias_mode. + */ INLINE void CLP(GraphicsStateGuardian):: setup_antialias_point() { if (_auto_antialias_mode) { - // Points supposedly look better using point smoothing, even if we - // have multisample available. + // Points supposedly look better using point smoothing, even if we have + // multisample available. enable_multisample_antialias(false); enable_point_smooth(true); } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::setup_antialias_polygon -// Access: Protected -// Description: Sets the appropriate antialiasing modes to render a -// series of polygon primitives, according to -// _auto_antialias_mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the appropriate antialiasing modes to render a series of polygon + * primitives, according to _auto_antialias_mode. + */ INLINE void CLP(GraphicsStateGuardian):: setup_antialias_polygon() { if (_auto_antialias_mode) { @@ -522,11 +452,9 @@ setup_antialias_polygon() { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_stencil_test -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_stencil_test(bool val) { if (_stencil_test_enabled != val) { @@ -547,11 +475,9 @@ enable_stencil_test(bool val) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_blend -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_blend(bool val) { if (_blend_enabled != val) { @@ -572,11 +498,9 @@ enable_blend(bool val) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_depth_test -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_depth_test(bool val) { if (_depth_test_enabled != val) { @@ -598,11 +522,9 @@ enable_depth_test(bool val) { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_fog -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_fog(bool val) { if (_fog_enabled != val) { @@ -625,11 +547,9 @@ enable_fog(bool val) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_alpha_test -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_alpha_test(bool val) { if (_alpha_test_enabled != val) { @@ -651,11 +571,9 @@ enable_alpha_test(bool val) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_polygon_offset -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: enable_polygon_offset(bool val) { if (_polygon_offset_enabled != val) { @@ -666,25 +584,23 @@ enable_polygon_offset(bool val) { << "glEnable(GL_POLYGON_OFFSET_*)" << endl; #endif glEnable(GL_POLYGON_OFFSET_FILL); - //glEnable(GL_POLYGON_OFFSET_LINE); // not widely supported anyway - //glEnable(GL_POLYGON_OFFSET_POINT); + // glEnable(GL_POLYGON_OFFSET_LINE); not widely supported anyway + // glEnable(GL_POLYGON_OFFSET_POINT); } else { #ifdef GSG_VERBOSE GLCAT.spam() << "glDisable(GL_POLYGON_OFFSET_*)" << endl; #endif glDisable(GL_POLYGON_OFFSET_FILL); - //glDisable(GL_POLYGON_OFFSET_LINE); // not widely supported anyway - //glDisable(GL_POLYGON_OFFSET_POINT); + // glDisable(GL_POLYGON_OFFSET_LINE); not widely supported anyway + // glDisable(GL_POLYGON_OFFSET_POINT); } } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_color_write_mask -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: set_color_write_mask(int mask) { if (gl_color_mask && _active_color_write_mask != mask) { @@ -696,11 +612,9 @@ set_color_write_mask(int mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::clear_color_write_mask -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: clear_color_write_mask() { if (gl_color_mask && _active_color_write_mask != ColorWriteAttrib::C_all) { @@ -710,11 +624,9 @@ clear_color_write_mask() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glLoadMatrix -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CLP(GraphicsStateGuardian):: call_glLoadMatrix(const LMatrix4 &mat) { #if defined(OPENGLES) && defined(STDFLOAT_DOUBLE) @@ -729,12 +641,9 @@ call_glLoadMatrix(const LMatrix4 &mat) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glFogfv -// Access: Public -// Description: This method is necessary because there is no -// glFogdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glFogdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glFogfv(GLenum pname, const LColor &color) { #ifndef STDFLOAT_DOUBLE @@ -747,12 +656,9 @@ call_glFogfv(GLenum pname, const LColor &color) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glMaterialfv -// Access: Public -// Description: This method is necessary because there is no -// glMaterialdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glMaterialdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) { #ifndef STDFLOAT_DOUBLE @@ -765,12 +671,9 @@ call_glMaterialfv(GLenum face, GLenum pname, const LColor &color) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glLightfv -// Access: Public -// Description: This method is necessary because there is no -// glLightdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glLightdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) { #ifndef STDFLOAT_DOUBLE @@ -783,12 +686,9 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase4 &value) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glLightfv -// Access: Public -// Description: This method is necessary because there is no -// glLightdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glLightdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) { #ifndef STDFLOAT_DOUBLE @@ -801,12 +701,9 @@ call_glLightfv(GLenum light, GLenum pname, const LVecBase3 &value) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glLightModelfv -// Access: Public -// Description: This method is necessary because there is no -// glLightModeldv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glLightModeldv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glLightModelfv(GLenum pname, const LVecBase4 &value) { #ifndef STDFLOAT_DOUBLE @@ -819,12 +716,9 @@ call_glLightModelfv(GLenum pname, const LVecBase4 &value) { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glTexEnvfv -// Access: Public -// Description: This method is necessary because there is no -// glTexEnvdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glTexEnvdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value) { #ifndef STDFLOAT_DOUBLE @@ -836,12 +730,9 @@ call_glTexEnvfv(GLenum target, GLenum pname, const LVecBase4 &value) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::call_glTexParameterfv -// Access: Public -// Description: This method is necessary because there is no -// glTexParameterdv(). -//////////////////////////////////////////////////////////////////// +/** + * This method is necessary because there is no glTexParameterdv(). + */ INLINE void CLP(GraphicsStateGuardian):: call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) { #ifndef STDFLOAT_DOUBLE @@ -853,11 +744,9 @@ call_glTexParameterfv(GLenum target, GLenum pname, const LVecBase4 &value) { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_light_id -// Access: Public -// Description: Convert index to gl light id -//////////////////////////////////////////////////////////////////// +/** + * Convert index to gl light id + */ INLINE GLenum CLP(GraphicsStateGuardian):: get_light_id(int index) const { return GL_LIGHT0 + index; @@ -865,57 +754,47 @@ get_light_id(int index) const { #endif #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_clip_plane_id -// Access: Public -// Description: Convert index to gl clip plane id -//////////////////////////////////////////////////////////////////// +/** + * Convert index to gl clip plane id + */ INLINE GLenum CLP(GraphicsStateGuardian):: get_clip_plane_id(int index) const { return GL_CLIP_PLANE0 + index; } #endif -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::get_supports_framebuffer_multisample -// Access: Public -// Description: Returns if this glGsg supports multisample -// antialiasing for framebuffer objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns if this glGsg supports multisample antialiasing for framebuffer + * objects. + */ INLINE bool CLP(GraphicsStateGuardian):: get_supports_framebuffer_multisample() { return _supports_framebuffer_multisample; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::get_supports_framebuffer_multisample -// Access: Public -// Description: Returns if this glGsg supports multisample -// antialiasing for framebuffer objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns if this glGsg supports multisample antialiasing for framebuffer + * objects. + */ INLINE bool CLP(GraphicsStateGuardian):: get_supports_framebuffer_multisample_coverage_nv() { return _supports_framebuffer_multisample_coverage_nv; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(GraphicsStateGuardian)::get_supports_framebuffer_blit -// Access: Public -// Description: Returns if this glGsg supports multisample -// antialiasing for framebuffer objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns if this glGsg supports multisample antialiasing for framebuffer + * objects. + */ INLINE bool CLP(GraphicsStateGuardian):: get_supports_framebuffer_blit() { return _supports_framebuffer_blit; } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::UsageTextureKey::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(GraphicsStateGuardian)::UsageTextureKey:: UsageTextureKey(int x_size, int y_size) : _x_size(x_size), @@ -925,11 +804,9 @@ UsageTextureKey(int x_size, int y_size) : #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::UsageTextureKey::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CLP(GraphicsStateGuardian)::UsageTextureKey:: operator < (const CLP(GraphicsStateGuardian)::UsageTextureKey &other) const { if (_x_size != other._x_size) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 7c5fd7fc9f..84e32b4336 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1,18 +1,18 @@ -// Filename: glGraphicsStateGuardian_src.cxx -// Created by: drose (02Feb99) -// Updated by: fperazzi, PandaSE (05May10) (added -// get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsStateGuardian_src.cxx + * @author drose + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + * get_supports_cg_profile) + */ #include "config_util.h" #include "displayRegion.h" @@ -88,10 +88,9 @@ PStatCollector CLP(GraphicsStateGuardian)::_check_error_pcollector("Draw:Check e PT(Shader) CLP(GraphicsStateGuardian)::_default_shader = NULL; #endif -// The following noop functions are assigned to the corresponding -// glext function pointers in the class, in case the functions are not -// defined by the GL, just so it will always be safe to call the -// extension functions. +// The following noop functions are assigned to the corresponding glext +// function pointers in the class, in case the functions are not defined by +// the GL, just so it will always be safe to call the extension functions. static void APIENTRY null_glPointParameterfv(GLenum, const GLfloat *) { @@ -122,8 +121,8 @@ null_glVertexAttrib4dv(GLuint index, const GLdouble *v) { static void APIENTRY null_glActiveTexture(GLenum gl_texture_stage) { - // If we don't support multitexture, we'd better not try to request - // a texture beyond the first texture stage. + // If we don't support multitexture, we'd better not try to request a + // texture beyond the first texture stage. nassertv(gl_texture_stage == GL_TEXTURE0); } @@ -136,11 +135,11 @@ null_glBlendColor(GLclampf, GLclampf, GLclampf, GLclampf) { } #ifndef OPENGLES_1 -// We have a default shader that will be applied when there isn't any -// shader applied (e.g. if it failed to compile). We need this because -// OpenGL ES 2.x and OpenGL 3.2+ core don't have a fixed-function pipeline. -// This default shader just applies a single texture, which is good enough -// for drawing GUIs and such. +// We have a default shader that will be applied when there isn't any shader +// applied (e.g. if it failed to compile). We need this because OpenGL ES +// 2.x and OpenGL 3.2+ core don't have a fixed-function pipeline. This +// default shader just applies a single texture, which is good enough for +// drawing GUIs and such. static const string default_vshader = #ifndef OPENGLES "#version 130\n" @@ -194,11 +193,9 @@ static const string default_fshader = #endif -//////////////////////////////////////////////////////////////////// -// Function: uchar_bgr_to_rgb -// Description: Recopies the given array of pixels, converting from -// BGR to RGB arrangement. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the given array of pixels, converting from BGR to RGB arrangement. + */ static void uchar_bgr_to_rgb(unsigned char *dest, const unsigned char *source, int num_pixels) { @@ -211,11 +208,10 @@ uchar_bgr_to_rgb(unsigned char *dest, const unsigned char *source, } } -//////////////////////////////////////////////////////////////////// -// Function: uchar_bgra_to_rgba -// Description: Recopies the given array of pixels, converting from -// BGRA to RGBA arrangement. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the given array of pixels, converting from BGRA to RGBA + * arrangement. + */ static void uchar_bgra_to_rgba(unsigned char *dest, const unsigned char *source, int num_pixels) { @@ -229,11 +225,9 @@ uchar_bgra_to_rgba(unsigned char *dest, const unsigned char *source, } } -//////////////////////////////////////////////////////////////////// -// Function: ushort_bgr_to_rgb -// Description: Recopies the given array of pixels, converting from -// BGR to RGB arrangement. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the given array of pixels, converting from BGR to RGB arrangement. + */ static void ushort_bgr_to_rgb(unsigned short *dest, const unsigned short *source, int num_pixels) { @@ -246,11 +240,10 @@ ushort_bgr_to_rgb(unsigned short *dest, const unsigned short *source, } } -//////////////////////////////////////////////////////////////////// -// Function: ushort_bgra_to_rgba -// Description: Recopies the given array of pixels, converting from -// BGRA to RGBA arrangement. -//////////////////////////////////////////////////////////////////// +/** + * Recopies the given array of pixels, converting from BGRA to RGBA + * arrangement. + */ static void ushort_bgra_to_rgba(unsigned short *dest, const unsigned short *source, int num_pixels) { @@ -264,21 +257,17 @@ ushort_bgra_to_rgba(unsigned short *dest, const unsigned short *source, } } -//////////////////////////////////////////////////////////////////// -// Function: fix_component_ordering -// Description: Reverses the order of the components within the -// image, to convert (for instance) GL_BGR to GL_RGB. -// Returns the byte pointer representing the converted -// image, or the original image if it is unchanged. -// -// new_image must be supplied; it is the PTA_uchar that -// will be used to hold the converted image if required. -// It will be modified only if the conversion is -// necessary, in which case the data will be stored -// there, and this pointer will be returned. If the -// conversion is not necessary, this pointer will be -// left unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the order of the components within the image, to convert (for + * instance) GL_BGR to GL_RGB. Returns the byte pointer representing the + * converted image, or the original image if it is unchanged. + * + * new_image must be supplied; it is the PTA_uchar that will be used to hold + * the converted image if required. It will be modified only if the + * conversion is necessary, in which case the data will be stored there, and + * this pointer will be returned. If the conversion is not necessary, this + * pointer will be left unchanged. + */ static const unsigned char * fix_component_ordering(PTA_uchar &new_image, const unsigned char *orig_image, size_t orig_image_size, @@ -339,7 +328,7 @@ fix_component_ordering(PTA_uchar &new_image, return result; } -//#--- Zhao Nov/2011 +// #--- Zhao Nov2011 string CLP(GraphicsStateGuardian)::get_driver_vendor() { return _gl_vendor; } string CLP(GraphicsStateGuardian)::get_driver_renderer() { return _gl_renderer; } @@ -349,11 +338,9 @@ int CLP(GraphicsStateGuardian)::get_driver_version_minor() { return _gl_version_ int CLP(GraphicsStateGuardian)::get_driver_shader_version_major() { return _gl_shadlang_ver_major; } int CLP(GraphicsStateGuardian)::get_driver_shader_version_minor() { return _gl_shadlang_ver_minor; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GraphicsStateGuardian):: CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) : GraphicsStateGuardian(gl_coordinate_system, engine, pipe), @@ -369,13 +356,13 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) : _gl_shadlang_ver_major = 0; _gl_shadlang_ver_minor = 0; - // Hack. Turn on the flag that we turned off at a higher level, - // since we know this works properly in OpenGL, and we want the - // performance benefit it gives us. + // Hack. Turn on the flag that we turned off at a higher level, since we + // know this works properly in OpenGL, and we want the performance benefit + // it gives us. _prepared_objects->_support_released_buffer_cache = true; - // Assume that we will get a hardware-accelerated context, unless - // the window tells us otherwise. + // Assume that we will get a hardware-accelerated context, unless the window + // tells us otherwise. _is_hardware = true; _scissor_enabled = false; @@ -399,11 +386,9 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) : #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(GraphicsStateGuardian):: ~CLP(GraphicsStateGuardian)() { if (GLCAT.is_debug()) { @@ -414,13 +399,10 @@ CLP(GraphicsStateGuardian):: close_gsg(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::debug_callback -// Access: Public, Static -// Description: This is called by the GL if an error occurs, if -// gl_debug has been enabled (and the driver supports -// the GL_ARB_debug_output extension). -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GL if an error occurs, if gl_debug has been enabled + * (and the driver supports the GL_ARB_debug_output extension). + */ #ifndef OPENGLES_1 void CLP(GraphicsStateGuardian):: debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) { @@ -459,12 +441,9 @@ debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei l } #endif // OPENGLES_1 -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void CLP(GraphicsStateGuardian):: reset() { _last_error_check = -1.0; @@ -472,9 +451,9 @@ reset() { free_pointers(); GraphicsStateGuardian::reset(); - // Build _inv_state_mask as a mask of 1's where we don't care, and - // 0's where we do care, about the state. - //_inv_state_mask = RenderState::SlotMask::all_on(); + // Build _inv_state_mask as a mask of 1's where we don't care, and 0's where + // we do care, about the state. _inv_state_mask = + // RenderState::SlotMask::all_on(); _inv_state_mask.clear_bit(ShaderAttrib::get_class_slot()); _inv_state_mask.clear_bit(AlphaTestAttrib::get_class_slot()); _inv_state_mask.clear_bit(AntialiasAttrib::get_class_slot()); @@ -679,10 +658,9 @@ reset() { #endif if (_supports_point_sprite) { - // It appears that the point_sprite extension doesn't support - // texture transforms on the generated texture coordinates. How - // inconsistent. Because of this, we don't advertise - // GR_point_sprite_tex_matrix. + // It appears that the point_sprite extension doesn't support texture + // transforms on the generated texture coordinates. How inconsistent. + // Because of this, we don't advertise GR_point_sprite_tex_matrix. _supported_geom_rendering |= Geom::GR_point_sprite; } @@ -693,16 +671,16 @@ reset() { if (gl_support_primitive_restart_index) { if ((is_at_least_gl_version(4, 3) || has_extension("GL_ARB_ES3_compatibility")) && _gl_renderer.substr(0, 7) != "Gallium") { - // As long as we enable this, OpenGL will always use the highest possible index - // for a numeric type as strip cut index, which coincides with our convention. - // This saves us a call to glPrimitiveRestartIndex + // As long as we enable this, OpenGL will always use the highest + // possible index for a numeric type as strip cut index, which coincides + // with our convention. This saves us a call to glPrimitiveRestartIndex // ... of course, though, the Gallium driver bugs out here. See also: - // https://www.panda3d.org/forums/viewtopic.php?f=5&t=17512 + // https:www.panda3d.orgforumsviewtopic.php?f=5&t=17512 glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); _supported_geom_rendering |= Geom::GR_strip_cut_index; } else if (is_at_least_gl_version(3, 1)) { - // We have to use an explicit primitive restart enable/index. + // We have to use an explicit primitive restart enableindex. _explicit_primitive_restart = true; _supported_geom_rendering |= Geom::GR_strip_cut_index; @@ -1228,9 +1206,9 @@ reset() { _supports_shadow_filter = true; } #endif - // Actually, we can't keep forever disabling ARB_shadow on ATI cards, - // since they do work correctly now. Maybe there is some feature - // level we can check somewhere? + // Actually, we can't keep forever disabling ARB_shadow on ATI cards, since + // they do work correctly now. Maybe there is some feature level we can + // check somewhere? /*if (_gl_vendor.substr(0,3)=="ATI") { // ATI drivers have never provided correct shadow support. _supports_shadow_filter = false; @@ -1676,10 +1654,9 @@ reset() { } #endif - // We need to have a default shader to apply in case - // something didn't happen to have a shader applied, or - // if it failed to compile. This default shader just outputs - // a red color, indicating that something went wrong. + // We need to have a default shader to apply in case something didn't happen + // to have a shader applied, or if it failed to compile. This default + // shader just outputs a red color, indicating that something went wrong. #ifndef SUPPORT_FIXED_FUNCTION if (_default_shader == NULL) { _default_shader = Shader::make(Shader::SL_GLSL, default_vshader, default_fshader); @@ -1708,7 +1685,8 @@ reset() { } #endif - // Check whether we support geometry instancing and instanced vertex attribs. + // Check whether we support geometry instancing and instanced vertex + // attribs. #if defined(OPENGLES_1) _supports_vertex_attrib_divisor = false; _supports_geometry_instancing = false; @@ -1875,7 +1853,7 @@ reset() { // Make sure this is properly initialized. _glGenerateMipmap = NULL; - //TODO: add ARB/3.0 version + // TODO: add ARB3.0 version _supports_framebuffer_object = false; if (has_extension("GL_EXT_framebuffer_object")) { @@ -2255,12 +2233,11 @@ reset() { GLint sample_buffers = 0; glGetIntegerv(GL_SAMPLE_BUFFERS, &sample_buffers); if (sample_buffers != 1) { - // Even if the API supports multisample, we might have ended up - // with a framebuffer that doesn't have any multisample bits. - // (It's also possible the graphics card doesn't provide any - // framebuffers with multisample.) In this case, we don't - // really support the multisample API's, since they won't do - // anything. + // Even if the API supports multisample, we might have ended up with a + // framebuffer that doesn't have any multisample bits. (It's also + // possible the graphics card doesn't provide any framebuffers with + // multisample.) In this case, we don't really support the multisample + // API's, since they won't do anything. _supports_multisample = false; } } @@ -2392,7 +2369,7 @@ reset() { _supports_anisotropy = true; } - // Check availability of image read/write functionality in shaders. + // Check availability of image readwrite functionality in shaders. _max_image_units = 0; #ifndef OPENGLES if (is_at_least_gl_version(4, 2) || has_extension("GL_ARB_shader_image_load_store")) { @@ -2535,7 +2512,7 @@ reset() { report_my_gl_errors(); if (core_profile) { - //TODO: better detection mechanism? + // TODO: better detection mechanism? _supports_stencil = true; } #ifdef SUPPORT_FIXED_FUNCTION @@ -2561,10 +2538,10 @@ reset() { } #endif - // Ensure the initial state is what we say it should be (in some - // cases, we don't want the GL default settings; in others, we have - // to force the point with some drivers that aren't strictly - // compliant w.r.t. initial settings). + // Ensure the initial state is what we say it should be (in some cases, we + // don't want the GL default settings; in others, we have to force the point + // with some drivers that aren't strictly compliant w.r.t. initial + // settings). glFrontFace(GL_CCW); #ifndef OPENGLES_2 glDisable(GL_LINE_SMOOTH); @@ -2584,8 +2561,8 @@ reset() { } #endif - // Set up all the enabled/disabled flags to GL's known initial - // values: everything off. + // Set up all the enableddisabled flags to GL's known initial values: + // everything off. _multisample_mode = 0; _line_smooth_enabled = false; _point_smooth_enabled = false; @@ -2743,8 +2720,8 @@ reset() { _shader_model = SM_40; } else if (has_extension("GL_NV_fragment_program2")) { - // fp40 - OpenGL fragment profile for NV4x (GeForce 6xxx and 7xxx - // Series, NV4x-based Quadro FX, etc.) + // fp40 - OpenGL fragment profile for NV4x (GeForce 6xxx and 7xxx Series, + // NV4x-based Quadro FX, etc.) _shader_model = SM_30; } else if (has_extension("GL_NV_fragment_program")) { @@ -2753,13 +2730,13 @@ reset() { } else if (_gl_shadlang_ver_major >= 1 || has_extension("GL_ARB_fragment_program")) { - // This OpenGL profile corresponds to the per-fragment - // functionality introduced by GeForce FX and other DirectX 9 GPUs. + // This OpenGL profile corresponds to the per-fragment functionality + // introduced by GeForce FX and other DirectX 9 GPUs. _shader_model = SM_20; } else if (has_extension("GL_NV_texture_shader2")) { - // fp20 - OpenGL fragment profile for NV2x (GeForce3, GeForce4 Ti, - // Quadro DCC, etc.) + // fp20 - OpenGL fragment profile for NV2x (GeForce3, GeForce4 Ti, Quadro + // DCC, etc.) _shader_model = SM_11; } else { @@ -2848,39 +2825,31 @@ reset() { add_gsg(this); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::finish -// Access: Public, Virtual -// Description: Force the graphics card to finish drawing before -// returning. !!!!!HACK WARNING!!!! -// glfinish does not actually wait for the graphics card to finish drawing -// only for draw calls to finish. Thus flip may not happene -// immediately. Instead we read a single pixel from -// the framebuffer. This forces the graphics card to -// finish drawing the frame before returning. -//////////////////////////////////////////////////////////////////// +/** + * Force the graphics card to finish drawing before returning. !!!!!HACK + * WARNING!!!! glfinish does not actually wait for the graphics card to finish + * drawing only for draw calls to finish. Thus flip may not happene + * immediately. Instead we read a single pixel from the framebuffer. This + * forces the graphics card to finish drawing the frame before returning. + */ void CLP(GraphicsStateGuardian):: finish() { - // Rather than call glfinish which returns immediately if - // draw commands have been submitted, we will read a single pixel - // from the frame. That will force the graphics card to finish - // drawing before it is called + // Rather than call glfinish which returns immediately if draw commands have + // been submitted, we will read a single pixel from the frame. That will + // force the graphics card to finish drawing before it is called char data[4]; glReadPixels(0,0,1,1,GL_RGBA,GL_UNSIGNED_BYTE,&data); - //glFinish(); + // glFinish(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::clear -// Access: Public -// Description: Clears the framebuffer within the current -// DisplayRegion, according to the flags indicated by -// the given DrawableRegion object. -// -// This does not set the DisplayRegion first. You -// should call prepare_display_region() to specify the -// region you wish the clear operation to apply to. -//////////////////////////////////////////////////////////////////// +/** + * Clears the framebuffer within the current DisplayRegion, according to the + * flags indicated by the given DrawableRegion object. + * + * This does not set the DisplayRegion first. You should call + * prepare_display_region() to specify the region you wish the clear operation + * to apply to. + */ void CLP(GraphicsStateGuardian):: clear(DrawableRegion *clearable) { PStatGPUTimer timer(this, _clear_pcollector); @@ -2890,17 +2859,17 @@ clear(DrawableRegion *clearable) { return; } - //XXX rdb: Is this line really necessary? Could we perhaps just - // reset the color write mask and other relevant attributes? + // XXX rdb: Is this line really necessary? Could we perhaps just reset the + // color write mask and other relevant attributes? set_state_and_transform(RenderState::make_empty(), _internal_transform); int mask = 0; #ifndef OPENGLES if (_current_fbo != 0 && _glClearBufferfv != NULL) { - // We can use glClearBuffer to clear all the color attachments, - // which protects us from the overhead of having to call set_draw_buffer - // for every single attachment. + // We can use glClearBuffer to clear all the color attachments, which + // protects us from the overhead of having to call set_draw_buffer for + // every single attachment. int index = 0; if (_current_properties->get_color_bits() > 0) { @@ -2979,12 +2948,11 @@ clear(DrawableRegion *clearable) { } } - // In the past, it was possible to set the draw buffer - // once in prepare_display_region and then forget about it. - // Now, with aux layers, it is necessary to occasionally - // change the draw buffer. In time, I think there will need - // to be a draw buffer attrib. Until then, this little hack - // to put things back the way they were after + // In the past, it was possible to set the draw buffer once in + // prepare_display_region and then forget about it. Now, with aux + // layers, it is necessary to occasionally change the draw buffer. In + // time, I think there will need to be a draw buffer attrib. Until + // then, this little hack to put things back the way they were after // prepare_display_region will do. set_draw_buffer(_draw_buffer_type); @@ -3048,12 +3016,9 @@ clear(DrawableRegion *clearable) { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_display_region -// Access: Public, Virtual -// Description: Prepare a display region for rendering (set up -// scissor region and viewport) -//////////////////////////////////////////////////////////////////// +/** + * Prepare a display region for rendering (set up scissor region and viewport) + */ void CLP(GraphicsStateGuardian):: prepare_display_region(DisplayRegionPipelineReader *dr) { nassertv(dr != (DisplayRegionPipelineReader *)NULL); @@ -3101,8 +3066,8 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { GLfloat *viewports = (GLfloat *)alloca(sizeof(GLfloat) * 4 * count); - // We store the scissor regions in a vector since we may need - // to switch back to it in do_issue_scissor. + // We store the scissor regions in a vector since we may need to switch + // back to it in do_issue_scissor. for (int i = 0; i < count; ++i) { LVecBase4i sr; dr->get_region_pixels(i, sr[0], sr[1], sr[2], sr[3]); @@ -3163,15 +3128,12 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::clear_before_callback -// Access: Public, Virtual -// Description: Resets any non-standard graphics state that might -// give a callback apoplexy. Some drivers require that -// the graphics state be restored to neutral before -// performing certain operations. In OpenGL, for -// instance, this closes any open vertex buffers. -//////////////////////////////////////////////////////////////////// +/** + * Resets any non-standard graphics state that might give a callback apoplexy. + * Some drivers require that the graphics state be restored to neutral before + * performing certain operations. In OpenGL, for instance, this closes any + * open vertex buffers. + */ void CLP(GraphicsStateGuardian):: clear_before_callback() { #ifdef SUPPORT_FIXED_FUNCTION @@ -3186,16 +3148,15 @@ clear_before_callback() { #endif unbind_buffers(); - // Some callbacks may quite reasonably assume that the active - // texture stage is still set to stage 0. CEGUI, in particular, - // makes this assumption. + // Some callbacks may quite reasonably assume that the active texture stage + // is still set to stage 0. CEGUI, in particular, makes this assumption. set_active_texture_stage(0); #ifdef SUPPORT_FIXED_FUNCTION _glClientActiveTexture(GL_TEXTURE0); #endif - // Clear the bound sampler object, so that we do not inadvertently - // override the callback's desired sampler settings. + // Clear the bound sampler object, so that we do not inadvertently override + // the callback's desired sampler settings. #ifndef OPENGLES if (_supports_sampler_objects) { _glBindSampler(0, 0); @@ -3208,17 +3169,14 @@ clear_before_callback() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::calc_projection_mat -// Access: Public, Virtual -// Description: Given a lens, calculates the appropriate projection -// matrix for use with this gsg. Note that the -// projection matrix depends a lot upon the coordinate -// system of the rendering API. -// -// The return value is a TransformState if the lens is -// acceptable, NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Given a lens, calculates the appropriate projection matrix for use with + * this gsg. Note that the projection matrix depends a lot upon the + * coordinate system of the rendering API. + * + * The return value is a TransformState if the lens is acceptable, NULL if it + * is not. + */ CPT(TransformState) CLP(GraphicsStateGuardian):: calc_projection_mat(const Lens *lens) { if (lens == (Lens *)NULL) { @@ -3229,13 +3187,12 @@ calc_projection_mat(const Lens *lens) { return NULL; } - // The projection matrix must always be right-handed Y-up, even if - // our coordinate system of choice is otherwise, because certain GL - // calls (specifically glTexGen(GL_SPHERE_MAP)) assume this kind of - // a coordinate system. Sigh. In order to implement a Z-up (or - // other arbitrary) coordinate system, we'll use a Y-up projection - // matrix, and store the conversion to our coordinate system of - // choice in the modelview matrix. + // The projection matrix must always be right-handed Y-up, even if our + // coordinate system of choice is otherwise, because certain GL calls + // (specifically glTexGen(GL_SPHERE_MAP)) assume this kind of a coordinate + // system. Sigh. In order to implement a Z-up (or other arbitrary) + // coordinate system, we'll use a Y-up projection matrix, and store the + // conversion to our coordinate system of choice in the modelview matrix. LMatrix4 result = LMatrix4::convert_mat(_internal_coordinate_system, @@ -3243,26 +3200,22 @@ calc_projection_mat(const Lens *lens) { lens->get_projection_mat(_current_stereo_channel); if (_scene_setup->get_inverted()) { - // If the scene is supposed to be inverted, then invert the - // projection matrix. + // If the scene is supposed to be inverted, then invert the projection + // matrix. result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_lens -// Access: Public, Virtual -// Description: Makes the current lens (whichever lens was most -// recently specified with set_scene()) active, so -// that it will transform future rendered geometry. -// Normally this is only called from the draw process, -// and usually it is called by set_scene(). -// -// The return value is true if the lens is acceptable, -// false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Makes the current lens (whichever lens was most recently specified with + * set_scene()) active, so that it will transform future rendered geometry. + * Normally this is only called from the draw process, and usually it is + * called by set_scene(). + * + * The return value is true if the lens is acceptable, false if it is not. + */ bool CLP(GraphicsStateGuardian):: prepare_lens() { #ifdef SUPPORT_FIXED_FUNCTION @@ -3287,19 +3240,14 @@ prepare_lens() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_frame -// Access: Public, Virtual -// Description: Called before each frame is rendered, to allow the -// GSG a chance to do any internal cleanup before -// beginning the frame. -// -// The return value is true if successful (in which case -// the frame will be drawn and end_frame() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_frame() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called before each frame is rendered, to allow the GSG a chance to do any + * internal cleanup before beginning the frame. + * + * The return value is true if successful (in which case the frame will be + * drawn and end_frame() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_frame() will not be called). + */ bool CLP(GraphicsStateGuardian):: begin_frame(Thread *current_thread) { if (!GraphicsStateGuardian::begin_frame(current_thread)) { @@ -3318,8 +3266,8 @@ begin_frame(Thread *current_thread) { #ifndef NDEBUG _show_texture_usage = false; if (gl_show_texture_usage) { - // When this is true, then every other second, we show the usage - // textures instead of the real textures. + // When this is true, then every other second, we show the usage textures + // instead of the real textures. double now = ClockObject::get_global_clock()->get_frame_time(); int this_second = (int)floor(now); if (this_second & 1) { @@ -3328,8 +3276,7 @@ begin_frame(Thread *current_thread) { int max_size = gl_show_texture_usage_max_size; if (max_size != _show_texture_usage_max_size) { - // Remove the cache of usage textures; we've changed the max - // size. + // Remove the cache of usage textures; we've changed the max size. UsageTextures::iterator ui; for (ui = _usage_textures.begin(); ui != _usage_textures.end(); @@ -3346,8 +3293,7 @@ begin_frame(Thread *current_thread) { #ifdef DO_PSTATS /*if (_supports_timer_query) { - // Measure the difference between the OpenGL clock and the - // PStats clock. + // Measure the difference between the OpenGL clock and the PStats clock. GLint64 time_ns; _glGetInteger64v(GL_TIMESTAMP, &time_ns); _timer_delta = time_ns * -0.000000001; @@ -3365,35 +3311,27 @@ begin_frame(Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_scene -// Access: Public, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the beginning of drawing commands for a "scene" -// (usually a particular DisplayRegion) within a frame. -// All 3-D drawing commands, except the clear operation, -// must be enclosed within begin_scene() .. end_scene(). -// -// The return value is true if successful (in which case -// the scene will be drawn and end_scene() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_scene() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the beginning of + * drawing commands for a "scene" (usually a particular DisplayRegion) within + * a frame. All 3-D drawing commands, except the clear operation, must be + * enclosed within begin_scene() .. end_scene(). + * + * The return value is true if successful (in which case the scene will be + * drawn and end_scene() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_scene() will not be called). + */ bool CLP(GraphicsStateGuardian):: begin_scene() { return GraphicsStateGuardian::begin_scene(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_scene -// Access: Protected, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the end of drawing commands for a "scene" (usually a -// particular DisplayRegion) within a frame. All 3-D -// drawing commands, except the clear operation, must be -// enclosed within begin_scene() .. end_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the end of drawing + * commands for a "scene" (usually a particular DisplayRegion) within a frame. + * All 3-D drawing commands, except the clear operation, must be enclosed + * within begin_scene() .. end_scene(). + */ void CLP(GraphicsStateGuardian):: end_scene() { GraphicsStateGuardian::end_scene(); @@ -3402,13 +3340,10 @@ end_scene() { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_frame -// Access: Public, Virtual -// Description: Called after each frame is rendered, to allow the -// GSG a chance to do any internal cleanup after -// rendering the frame, and before the window flips. -//////////////////////////////////////////////////////////////////// +/** + * Called after each frame is rendered, to allow the GSG a chance to do any + * internal cleanup after rendering the frame, and before the window flips. + */ void CLP(GraphicsStateGuardian):: end_frame(Thread *current_thread) { report_my_gl_errors(); @@ -3420,20 +3355,19 @@ end_frame(Thread *current_thread) { #endif #ifdef DO_PSTATS - // Check for textures, etc., that are no longer resident. These - // calls might be measurably expensive, and they don't have any - // benefit unless we are actually viewing PStats, so don't do them - // unless we're connected. That will just mean that we'll count - // everything as resident until the user connects PStats, at which - // point it will then correct the assessment. No harm done. + // Check for textures, etc., that are no longer resident. These calls might + // be measurably expensive, and they don't have any benefit unless we are + // actually viewing PStats, so don't do them unless we're connected. That + // will just mean that we'll count everything as resident until the user + // connects PStats, at which point it will then correct the assessment. No + // harm done. if (PStatClient::is_connected()) { check_nonresident_texture(_prepared_objects->_texture_residency.get_inactive_resident()); check_nonresident_texture(_prepared_objects->_texture_residency.get_active_resident()); - // OpenGL provides no methods for querying whether a buffer object - // (vertex buffer) is resident. In fact, the API appears geared - // towards the assumption that such buffers are always resident. - // OK. + // OpenGL provides no methods for querying whether a buffer object (vertex + // buffer) is resident. In fact, the API appears geared towards the + // assumption that such buffers are always resident. OK. } #endif @@ -3459,13 +3393,11 @@ end_frame(Thread *current_thread) { // Respecify the active texture next frame, for good measure. _active_texture_stage = -1; - // Calling glFlush() at the end of the frame is particularly - // necessary if this is a single-buffered visual, so that the frame - // will be finished drawing before we return to the application. - // It's not clear what effect this has on our total frame time. - //if (_force_flush || _current_properties->is_single_buffered()) { - // gl_flush(); - //} + // Calling glFlush() at the end of the frame is particularly necessary if + // this is a single-buffered visual, so that the frame will be finished + // drawing before we return to the application. It's not clear what effect + // this has on our total frame time. if (_force_flush || + // _current_properties->is_single_buffered()) { gl_flush(); } maybe_gl_finish(); GraphicsStateGuardian::end_frame(current_thread); @@ -3498,8 +3430,8 @@ end_frame(Thread *current_thread) { } #endif - // And deleted queries, too, unless we're using query timers - // in which case we'll need to reuse lots of them. + // And deleted queries, too, unless we're using query timers in which case + // we'll need to reuse lots of them. if (_supports_occlusion_query && !get_timer_queries_active()) { LightMutexHolder holder(_lock); if (!_deleted_queries.empty()) { @@ -3522,8 +3454,8 @@ end_frame(Thread *current_thread) { if (_check_errors || (_supports_debug && gl_debug)) { report_my_gl_errors(); } else { - // If _check_errors is false, we still want to check for errors - // once every second, so that we know if anything went wrong at all. + // If _check_errors is false, we still want to check for errors once every + // second, so that we know if anything went wrong at all. double current = ClockObject::get_global_clock()->get_frame_time(); if (current - _last_error_check >= 1.0) { @@ -3573,14 +3505,11 @@ end_frame(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::begin_draw_primitives -// Access: Public, Virtual -// Description: Called before a sequence of draw_primitive() -// functions are called, this should prepare the vertex -// data for rendering. It returns true if the vertices -// are ok, false to abort this group of primitives. -//////////////////////////////////////////////////////////////////// +/** + * Called before a sequence of draw_primitive() functions are called, this + * should prepare the vertex data for rendering. It returns true if the + * vertices are ok, false to abort this group of primitives. + */ bool CLP(GraphicsStateGuardian):: begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, @@ -3639,8 +3568,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, #ifdef SUPPORT_FIXED_FUNCTION if (_data_reader->is_vertex_transformed()) { // If the vertex data claims to be already transformed into clip - // coordinates, wipe out the current projection and modelview - // matrix (so we don't attempt to transform it again). + // coordinates, wipe out the current projection and modelview matrix (so + // we don't attempt to transform it again). glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); @@ -3654,11 +3583,11 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (geom_reader->get_usage_hint() == Geom::UH_static && _data_reader->get_usage_hint() == Geom::UH_static && display_lists) { - // If the geom claims to be totally static, try to build it into - // a display list. + // If the geom claims to be totally static, try to build it into a display + // list. - // Before we compile or call a display list, make sure the current - // buffers are unbound, or the nVidia drivers may crash. + // Before we compile or call a display list, make sure the current buffers + // are unbound, or the nVidia drivers may crash. unbind_buffers(); GeomContext *gc = geom_reader->prepare_now(get_prepared_objects(), this); @@ -3686,8 +3615,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return false; } - // Since we start this collector explicitly, we have to be sure to - // stop it again. + // Since we start this collector explicitly, we have to be sure to stop it + // again. _load_display_list_pcollector.start(); if (GLCAT.is_debug()) { @@ -3695,8 +3624,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, << "compiling display list " << (int)_geom_display_list << "\n"; } - // If it has been modified, or this is the first time, then we - // need to build the display list up. + // If it has been modified, or this is the first time, then we need to + // build the display list up. if (gl_compile_and_execute) { glNewList(_geom_display_list, GL_COMPILE_AND_EXECUTE); } else { @@ -3704,8 +3633,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } #ifdef DO_PSTATS - // Count up the number of vertices used by primitives in the Geom, - // for PStats reporting. + // Count up the number of vertices used by primitives in the Geom, for + // PStats reporting. ggc->_num_verts = 0; for (int i = 0; i < geom_reader->get_num_primitives(); i++) { ggc->_num_verts += geom_reader->get_primitive(i)->get_num_vertices(); @@ -3714,8 +3643,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } #endif // OPENGLES - // Enable the appropriate vertex arrays, and disable any - // extra vertex arrays used by the previous rendering mode. + // Enable the appropriate vertex arrays, and disable any extra vertex arrays + // used by the previous rendering mode. #ifdef SUPPORT_IMMEDIATE_MODE _use_sender = !vertex_arrays; #endif @@ -3730,7 +3659,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, #endif { - //PStatGPUTimer timer(this, _vertex_array_update_pcollector); + // PStatGPUTimer timer(this, _vertex_array_update_pcollector); #ifdef OPENGLES_1 if (!update_standard_vertex_arrays(force)) { return false; @@ -3787,18 +3716,14 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_standard_vertex_arrays -// Access: Protected -// Description: Disables any unneeded vertex arrays that -// were previously enabled, and enables any vertex -// arrays that are needed that were not previously -// enabled (or, sets up an immediate-mode sender). -// Called only from begin_draw_primitives. -// Used only when the standard (non-shader) pipeline -// is about to be used - glShaderContexts are responsible -// for setting up their own vertex arrays. -//////////////////////////////////////////////////////////////////// +/** + * Disables any unneeded vertex arrays that were previously enabled, and + * enables any vertex arrays that are needed that were not previously enabled + * (or, sets up an immediate-mode sender). Called only from + * begin_draw_primitives. Used only when the standard (non-shader) pipeline + * is about to be used - glShaderContexts are responsible for setting up their + * own vertex arrays. + */ bool CLP(GraphicsStateGuardian):: update_standard_vertex_arrays(bool force) { #ifdef SUPPORT_IMMEDIATE_MODE @@ -3810,8 +3735,8 @@ update_standard_vertex_arrays(bool force) { NULL, NULL, GLPf(Normal3), NULL); #ifndef NDEBUG if (_show_texture_usage) { - // In show_texture_usage mode, all colors are white, so as not - // to contaminate the texture color. + // In show_texture_usage mode, all colors are white, so as not to + // contaminate the texture color. GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } else #endif // NDEBUG @@ -3821,20 +3746,19 @@ update_standard_vertex_arrays(bool force) { GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } - // Now set up each of the active texture coordinate stages--or at - // least those for which we're not generating texture coordinates - // automatically. + // Now set up each of the active texture coordinate stages--or at least + // those for which we're not generating texture coordinates automatically. int max_stage_index = _target_texture->get_num_on_ff_stages(); int stage_index = 0; while (stage_index < max_stage_index) { TextureStage *stage = _target_texture->get_on_ff_stage(stage_index); if (!_target_tex_gen->has_gen_texcoord_stage(stage)) { - // This stage is not one of the stages that doesn't need - // texcoords issued for it. + // This stage is not one of the stages that doesn't need texcoords + // issued for it. const InternalName *name = stage->get_texcoord_name(); if (stage_index == 0) { - // Use the original functions for stage 0, in case we don't - // support multitexture. + // Use the original functions for stage 0, in case we don't support + // multitexture. _sender.add_column(_data_reader, name, GLPf(TexCoord1), GLPf(TexCoord2), GLPf(TexCoord3), GLPf(TexCoord4)); @@ -3858,8 +3782,8 @@ update_standard_vertex_arrays(bool force) { } _last_max_stage_index = max_stage_index; - // We must add vertex last, because glVertex3f() is the key - // function call that actually issues the vertex. + // We must add vertex last, because glVertex3f() is the key function call + // that actually issues the vertex. _sender.add_column(_data_reader, InternalName::get_vertex(), NULL, GLPf(Vertex2), GLPf(Vertex3), GLPf(Vertex4)); @@ -3888,8 +3812,8 @@ update_standard_vertex_arrays(bool force) { #ifndef NDEBUG if (_show_texture_usage) { - // In show_texture_usage mode, all colors are white, so as not - // to contaminate the texture color. + // In show_texture_usage mode, all colors are white, so as not to + // contaminate the texture color. glDisableClientState(GL_COLOR_ARRAY); GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } else @@ -3910,22 +3834,20 @@ update_standard_vertex_arrays(bool force) { } else { glDisableClientState(GL_COLOR_ARRAY); - // Since we don't have per-vertex color, the implicit color is - // white. + // Since we don't have per-vertex color, the implicit color is white. GLPf(Color4)(1.0f, 1.0f, 1.0f, 1.0f); } - // Now set up each of the active texture coordinate stages--or at - // least those for which we're not generating texture coordinates - // automatically. + // Now set up each of the active texture coordinate stages--or at least + // those for which we're not generating texture coordinates automatically. int max_stage_index = _target_texture->get_num_on_ff_stages(); int stage_index = 0; while (stage_index < max_stage_index) { _glClientActiveTexture(GL_TEXTURE0 + stage_index); TextureStage *stage = _target_texture->get_on_ff_stage(stage_index); if (!_target_tex_gen->has_gen_texcoord_stage(stage)) { - // This stage is not one of the stages that doesn't need - // texcoords issued for it. + // This stage is not one of the stages that doesn't need texcoords + // issued for it. const InternalName *name = stage->get_texcoord_name(); if (_data_reader->get_array_info(name, array_reader, num_values, @@ -3959,8 +3881,7 @@ update_standard_vertex_arrays(bool force) { } _last_max_stage_index = max_stage_index; - // There's no requirement that we add vertices last, but we do - // anyway. + // There's no requirement that we add vertices last, but we do anyway. if (_data_reader->get_vertex_info(array_reader, num_values, numeric_type, start, stride)) { if (!setup_array_data(client_pointer, array_reader, force)) { @@ -3975,13 +3896,10 @@ update_standard_vertex_arrays(bool force) { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::unbind_buffers -// Access: Protected -// Description: Ensures the vertex and array buffers are no longer -// bound. Some graphics drivers crash if these are left -// bound indiscriminantly. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the vertex and array buffers are no longer bound. Some graphics + * drivers crash if these are left bound indiscriminantly. + */ void CLP(GraphicsStateGuardian):: unbind_buffers() { if (_current_vbuffer_index != 0) { @@ -4020,16 +3938,12 @@ unbind_buffers() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::disable_standard_vertex_arrays -// Access: Protected -// Description: Used to disable all the standard vertex arrays that -// are currently enabled. glShaderContexts are -// responsible for setting up their own vertex arrays, -// but before they can do so, the standard vertex -// arrays need to be disabled to get them "out of the -// way." Called only from begin_draw_primitives. -//////////////////////////////////////////////////////////////////// +/** + * Used to disable all the standard vertex arrays that are currently enabled. + * glShaderContexts are responsible for setting up their own vertex arrays, + * but before they can do so, the standard vertex arrays need to be disabled + * to get them "out of the way." Called only from begin_draw_primitives. + */ void CLP(GraphicsStateGuardian):: disable_standard_vertex_arrays() { #ifdef SUPPORT_IMMEDIATE_MODE @@ -4052,12 +3966,10 @@ disable_standard_vertex_arrays() { #endif // SUPPORT_FIXED_FUNCTION #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_shader_vertex_format -// Access: Protected -// Description: Updates the vertex format used by the shader. This -// is still an experimental feature. -//////////////////////////////////////////////////////////////////// +/** + * Updates the vertex format used by the shader. This is still an + * experimental feature. + */ void CLP(GraphicsStateGuardian):: update_shader_vertex_format(const GeomVertexFormat *format) { size_t num_columns = format->get_num_columns(); @@ -4097,8 +4009,8 @@ update_shader_vertex_format(const GeomVertexFormat *format) { GLint size = column->get_num_values(); if (column->get_numeric_type() == GeomEnums::NT_packed_dabc) { - // GL_BGRA is a special accepted value available since OpenGL 3.2. - // It requires us to pass GL_TRUE for normalized. + // GL_BGRA is a special accepted value available since OpenGL 3.2. It + // requires us to pass GL_TRUE for normalized. size = GL_BGRA; normalized = GL_TRUE; } @@ -4125,14 +4037,13 @@ update_shader_vertex_format(const GeomVertexFormat *format) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_triangles -// Access: Public, Virtual -// Description: Draws a series of disconnected triangles. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected triangles. + */ bool CLP(GraphicsStateGuardian):: draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4192,14 +4103,13 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_tristrips -// Access: Public, Virtual -// Description: Draws a series of triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle strips. + */ bool CLP(GraphicsStateGuardian):: draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); report_my_gl_errors(); @@ -4217,8 +4127,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { #endif // SUPPORT_IMMEDIATE_MODE { if (connect_triangle_strips && _render_mode != RenderModeAttrib::M_wireframe) { - // One long triangle strip, connected by the degenerate vertices - // that have already been set up within the primitive. + // One long triangle strip, connected by the degenerate vertices that + // have already been set up within the primitive. int num_vertices = reader->get_num_vertices(); _vertices_tristrip_pcollector.add_level(num_vertices); _primitive_batches_tristrip_pcollector.add_level(1); @@ -4258,8 +4168,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { } } else { - // Send the individual triangle strips, stepping over the - // degenerate vertices. + // Send the individual triangle strips, stepping over the degenerate + // vertices. CPTA_int ends = reader->get_ends(); _primitive_batches_tristrip_pcollector.add_level(ends.size()); @@ -4319,14 +4229,13 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_trifans -// Access: Public, Virtual -// Description: Draws a series of triangle fans. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle fans. + */ bool CLP(GraphicsStateGuardian):: draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4340,8 +4249,8 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { } else #endif // SUPPORT_IMMEDIATE_MODE { - // Send the individual triangle fans. There's no connecting fans - // with degenerate vertices, so no worries about that. + // Send the individual triangle fans. There's no connecting fans with + // degenerate vertices, so no worries about that. CPTA_int ends = reader->get_ends(); _primitive_batches_trifan_pcollector.add_level(ends.size()); @@ -4399,15 +4308,14 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_patches -// Access: Public, Virtual -// Description: Draws a series of "patches", which can only be -// processed by a tessellation shader. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of "patches", which can only be processed by a tessellation + * shader. + */ bool CLP(GraphicsStateGuardian):: draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4476,14 +4384,13 @@ draw_patches(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_lines -// Access: Public, Virtual -// Description: Draws a series of disconnected line segments. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected line segments. + */ bool CLP(GraphicsStateGuardian):: draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4541,14 +4448,13 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_linestrips -// Access: Public, Virtual -// Description: Draws a series of line strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of line strips. + */ bool CLP(GraphicsStateGuardian):: draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); report_my_gl_errors(); @@ -4605,8 +4511,7 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { } #endif // !OPENGLES } else { - // Send the individual line strips, stepping over the - // strip-cut indices. + // Send the individual line strips, stepping over the strip-cut indices. CPTA_int ends = reader->get_ends(); _primitive_batches_other_pcollector.add_level(ends.size()); @@ -4665,14 +4570,13 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_points -// Access: Public, Virtual -// Description: Draws a series of disconnected points. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected points. + */ bool CLP(GraphicsStateGuardian):: draw_points(const GeomPrimitivePipelineReader *reader, bool force) { - //PStatGPUTimer timer(this, _draw_primitive_pcollector, reader->get_current_thread()); + // PStatGPUTimer timer(this, _draw_primitive_pcollector, + // reader->get_current_thread()); #ifndef NDEBUG if (GLCAT.is_spam()) { @@ -4728,13 +4632,10 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_draw_primitives() -// Access: Public, Virtual -// Description: Called after a sequence of draw_primitive() -// functions are called, this should do whatever cleanup -// is appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Called after a sequence of draw_primitive() functions are called, this + * should do whatever cleanup is appropriate. + */ void CLP(GraphicsStateGuardian):: end_draw_primitives() { #if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES. @@ -4772,13 +4673,10 @@ end_draw_primitives() { } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::issue_memory_barrier -// Access: Public -// Description: Issues the given memory barriers, and clears the -// list of textures marked as incoherent for the given -// bits. -//////////////////////////////////////////////////////////////////// +/** + * Issues the given memory barriers, and clears the list of textures marked as + * incoherent for the given bits. + */ void CLP(GraphicsStateGuardian):: issue_memory_barrier(GLbitfield barriers) { if (!gl_enable_memory_barriers || _glMemoryBarrier == NULL) { @@ -4793,8 +4691,8 @@ issue_memory_barrier(GLbitfield barriers) { _glMemoryBarrier(barriers); - // Indicate that barriers no longer need to be issued for - // the relevant lists of textures. + // Indicate that barriers no longer need to be issued for the relevant lists + // of textures. if (barriers & GL_TEXTURE_FETCH_BARRIER_BIT) { _textures_needing_fetch_barrier.clear(); GLCAT.spam(false) << " texture_fetch"; @@ -4821,26 +4719,23 @@ issue_memory_barrier(GLbitfield barriers) { } #endif // OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_texture -// Access: Public, Virtual -// Description: Creates whatever structures the GSG requires to -// represent the texture internally, and returns a -// newly-allocated TextureContext object with this data. -// It is the responsibility of the calling function to -// later call release_texture() with this same pointer -// (which will also delete the pointer). -// -// This function should not be called directly to -// prepare a texture. Instead, call Texture::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates whatever structures the GSG requires to represent the texture + * internally, and returns a newly-allocated TextureContext object with this + * data. It is the responsibility of the calling function to later call + * release_texture() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a texture. Instead, + * call Texture::prepare(). + */ TextureContext *CLP(GraphicsStateGuardian):: prepare_texture(Texture *tex, int view) { PStatGPUTimer timer(this, _prepare_texture_pcollector); report_my_gl_errors(); - // Make sure we'll support this texture when it's rendered. Don't - // bother to prepare it if we won't. + // Make sure we'll support this texture when it's rendered. Don't bother to + // prepare it if we won't. switch (tex->get_texture_type()) { case Texture::TT_3d_texture: if (!_supports_3d_texture) { @@ -4892,22 +4787,16 @@ prepare_texture(Texture *tex, int view) { return gtc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_texture -// Access: Public, Virtual -// Description: Ensures that the current Texture data is refreshed -// onto the GSG. This means updating the texture -// properties and/or re-uploading the texture image, if -// necessary. This should only be called within the -// draw thread. -// -// If force is true, this function will not return until -// the texture has been fully uploaded. If force is -// false, the function may choose to upload a simple -// version of the texture instead, if the texture is not -// fully resident (and if get_incomplete_render() is -// true). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the current Texture data is refreshed onto the GSG. This + * means updating the texture properties and/or re-uploading the texture + * image, if necessary. This should only be called within the draw thread. + * + * If force is true, this function will not return until the texture has been + * fully uploaded. If force is false, the function may choose to upload a + * simple version of the texture instead, if the texture is not fully resident + * (and if get_incomplete_render() is true). + */ bool CLP(GraphicsStateGuardian):: update_texture(TextureContext *tc, bool force) { CLP(TextureContext) *gtc; @@ -4933,8 +4822,8 @@ update_texture(TextureContext *tc, bool force) { } else if (gtc->was_properties_modified()) { PStatGPUTimer timer(this, _texture_update_pcollector); - // If only the properties have been modified, we don't necessarily - // need to reload the texture. + // If only the properties have been modified, we don't necessarily need to + // reload the texture. apply_texture(gtc); Texture *tex = tc->get_texture(); @@ -4949,8 +4838,7 @@ update_texture(TextureContext *tc, bool force) { } } else { - // The texture didn't need reloading, but mark it fully updated - // now. + // The texture didn't need reloading, but mark it fully updated now. gtc->mark_loaded(); } } @@ -4961,14 +4849,11 @@ update_texture(TextureContext *tc, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_texture -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// texture. This function should never be called -// directly; instead, call Texture::release() (or simply -// let the Texture destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the texture. This function + * should never be called directly; instead, call Texture::release() (or + * simply let the Texture destruct). + */ void CLP(GraphicsStateGuardian):: release_texture(TextureContext *tc) { CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tc); @@ -4989,18 +4874,14 @@ release_texture(TextureContext *tc) { delete gtc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::extract_texture_data -// Access: Public, Virtual -// Description: This method should only be called by the -// GraphicsEngine. Do not call it directly; call -// GraphicsEngine::extract_texture_data() instead. -// -// This method will be called in the draw thread to -// download the texture memory's image into its -// ram_image value. It returns true on success, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This method should only be called by the GraphicsEngine. Do not call it + * directly; call GraphicsEngine::extract_texture_data() instead. + * + * This method will be called in the draw thread to download the texture + * memory's image into its ram_image value. It returns true on success, false + * otherwise. + */ bool CLP(GraphicsStateGuardian):: extract_texture_data(Texture *tex) { bool success = true; @@ -5022,20 +4903,16 @@ extract_texture_data(Texture *tex) { } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_sampler -// Access: Public, Virtual -// Description: Creates whatever structures the GSG requires to -// represent the sampler state internally, and returns a -// newly-allocated SamplerContext object with this data. -// It is the responsibility of the calling function to -// later call release_sampler() with this same pointer -// (which will also delete the pointer). -// -// This function should not be called directly to -// prepare a sampler object. Instead, call -// SamplerState::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates whatever structures the GSG requires to represent the sampler state + * internally, and returns a newly-allocated SamplerContext object with this + * data. It is the responsibility of the calling function to later call + * release_sampler() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a sampler object. + * Instead, call SamplerState::prepare(). + */ SamplerContext *CLP(GraphicsStateGuardian):: prepare_sampler(const SamplerState &sampler) { nassertr(_supports_sampler_objects, NULL); @@ -5044,8 +4921,8 @@ prepare_sampler(const SamplerState &sampler) { CLP(SamplerContext) *gsc = new CLP(SamplerContext)(this, sampler); GLuint index = gsc->_index; - // Sampler contexts are immutable in Panda, so might as well just - // initialize all the settings here. + // Sampler contexts are immutable in Panda, so might as well just initialize + // all the settings here. _glSamplerParameteri(index, GL_TEXTURE_WRAP_S, get_texture_wrap_mode(sampler.get_wrap_u())); _glSamplerParameteri(index, GL_TEXTURE_WRAP_T, @@ -5114,13 +4991,10 @@ prepare_sampler(const SamplerState &sampler) { #endif // !OPENGLES #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_sampler -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// sampler. This function should never be called -// directly; instead, call SamplerState::release(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the sampler. This function + * should never be called directly; instead, call SamplerState::release(). + */ void CLP(GraphicsStateGuardian):: release_sampler(SamplerContext *sc) { CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); @@ -5133,33 +5007,26 @@ release_sampler(SamplerContext *sc) { } #endif // !OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_geom -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given geom, and returns a newly-allocated -// GeomContext pointer to reference it. It is the -// responsibility of the calling function to later -// call release_geom() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a geom. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given geom, and returns a + * newly-allocated GeomContext pointer to reference it. It is the + * responsibility of the calling function to later call release_geom() with + * this same pointer (which will also delete the pointer). + * + * This function should not be called directly to prepare a geom. Instead, + * call Geom::prepare(). + */ GeomContext *CLP(GraphicsStateGuardian):: prepare_geom(Geom *geom) { PStatGPUTimer timer(this, _prepare_geom_pcollector); return new CLP(GeomContext)(geom); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_geom -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// geom. This function should never be called -// directly; instead, call Geom::release() (or simply -// let the Geom destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the geom. This function + * should never be called directly; instead, call Geom::release() (or simply + * let the Geom destruct). + */ void CLP(GraphicsStateGuardian):: release_geom(GeomContext *gc) { CLP(GeomContext) *ggc = DCAST(CLP(GeomContext), gc); @@ -5169,11 +5036,9 @@ release_geom(GeomContext *gc) { delete ggc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_shader -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShaderContext *CLP(GraphicsStateGuardian):: prepare_shader(Shader *se) { PStatGPUTimer timer(this, _prepare_shader_pcollector); @@ -5228,11 +5093,9 @@ prepare_shader(Shader *se) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_shader -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: release_shader(ShaderContext *sc) { #ifndef OPENGLES_1 @@ -5249,33 +5112,27 @@ release_shader(ShaderContext *sc) { delete sc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::record_deleted_display_list -// Access: Public -// Description: This is intended to be called only from the -// GLGeomContext destructor. It saves the indicated -// display list index in the list to be deleted at the -// end of the frame. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only from the GLGeomContext destructor. It + * saves the indicated display list index in the list to be deleted at the end + * of the frame. + */ void CLP(GraphicsStateGuardian):: record_deleted_display_list(GLuint index) { LightMutexHolder holder(_lock); _deleted_display_lists.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_vertex_buffer -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given data, and returns a newly-allocated -// VertexBufferContext pointer to reference it. It is the -// responsibility of the calling function to later -// call release_vertex_buffer() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a buffer. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given data, and returns a + * newly-allocated VertexBufferContext pointer to reference it. It is the + * responsibility of the calling function to later call + * release_vertex_buffer() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a buffer. Instead, + * call Geom::prepare(). + */ VertexBufferContext *CLP(GraphicsStateGuardian):: prepare_vertex_buffer(GeomVertexArrayData *data) { if (_supports_buffers) { @@ -5299,13 +5156,10 @@ prepare_vertex_buffer(GeomVertexArrayData *data) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_vertex_buffer -// Access: Public -// Description: Makes sure that the data in the vertex buffer is -// up-to-date. This may bind it to the GL_ARRAY_BUFFER -// binding point if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure that the data in the vertex buffer is up-to-date. This may bind + * it to the GL_ARRAY_BUFFER binding point if necessary. + */ bool CLP(GraphicsStateGuardian):: update_vertex_buffer(CLP(VertexBufferContext) *gvbc, const GeomVertexArrayDataHandle *reader, bool force) { @@ -5359,14 +5213,11 @@ update_vertex_buffer(CLP(VertexBufferContext) *gvbc, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_vertex_buffer -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// data. This function should never be called -// directly; instead, call Data::release() (or simply -// let the Data destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the data. This function + * should never be called directly; instead, call Data::release() (or simply + * let the Data destruct). + */ void CLP(GraphicsStateGuardian):: release_vertex_buffer(VertexBufferContext *vbc) { nassertv(_supports_buffers); @@ -5378,10 +5229,9 @@ release_vertex_buffer(VertexBufferContext *vbc) { << "deleting vertex buffer " << (int)gvbc->_index << "\n"; } - // Make sure the buffer is unbound before we delete it. Not - // strictly necessary according to the OpenGL spec, but it might - // help out a flaky driver, and we need to keep our internal state - // consistent anyway. + // Make sure the buffer is unbound before we delete it. Not strictly + // necessary according to the OpenGL spec, but it might help out a flaky + // driver, and we need to keep our internal state consistent anyway. if (_current_vbuffer_index == gvbc->_index) { if (GLCAT.is_spam() && gl_debug_buffers) { GLCAT.spam() @@ -5399,24 +5249,19 @@ release_vertex_buffer(VertexBufferContext *vbc) { delete gvbc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::setup_array_data -// Access: Public -// Description: Internal function to bind a buffer object for the -// indicated data array, if appropriate, or to unbind a -// buffer object if it should be rendered from client -// memory. -// -// If the buffer object is bound, this function sets -// client_pointer to NULL (representing the start of the -// buffer object in server memory); if the buffer object -// is not bound, this function sets client_pointer the -// pointer to the data array in client memory, that is, -// the data array passed in. -// -// If force is not true, the function may return false -// indicating the data is not currently available. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to bind a buffer object for the indicated data array, if + * appropriate, or to unbind a buffer object if it should be rendered from + * client memory. + * + * If the buffer object is bound, this function sets client_pointer to NULL + * (representing the start of the buffer object in server memory); if the + * buffer object is not bound, this function sets client_pointer the pointer + * to the data array in client memory, that is, the data array passed in. + * + * If force is not true, the function may return false indicating the data is + * not currently available. + */ bool CLP(GraphicsStateGuardian):: setup_array_data(const unsigned char *&client_pointer, const GeomVertexArrayDataHandle *array_reader, @@ -5428,8 +5273,8 @@ setup_array_data(const unsigned char *&client_pointer, } if (!vertex_buffers || _geom_display_list != 0 || array_reader->get_usage_hint() < gl_min_buffer_usage_hint) { - // The array specifies client rendering only, or buffer objects - // are configured off. + // The array specifies client rendering only, or buffer objects are + // configured off. if (_current_vbuffer_index != 0) { if (GLCAT.is_spam() && gl_debug_buffers) { GLCAT.spam() @@ -5465,19 +5310,15 @@ setup_array_data(const unsigned char *&client_pointer, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::prepare_index_buffer -// Access: Public, Virtual -// Description: Creates a new retained-mode representation of the -// given data, and returns a newly-allocated -// IndexBufferContext pointer to reference it. It is the -// responsibility of the calling function to later -// call release_index_buffer() with this same pointer (which -// will also delete the pointer). -// -// This function should not be called directly to -// prepare a buffer. Instead, call Geom::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new retained-mode representation of the given data, and returns a + * newly-allocated IndexBufferContext pointer to reference it. It is the + * responsibility of the calling function to later call release_index_buffer() + * with this same pointer (which will also delete the pointer). + * + * This function should not be called directly to prepare a buffer. Instead, + * call Geom::prepare(). + */ IndexBufferContext *CLP(GraphicsStateGuardian):: prepare_index_buffer(GeomPrimitive *data) { if (_supports_buffers) { @@ -5503,12 +5344,9 @@ prepare_index_buffer(GeomPrimitive *data) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::apply_index_buffer -// Access: Public -// Description: Makes the data the currently available data for -// rendering. -//////////////////////////////////////////////////////////////////// +/** + * Makes the data the currently available data for rendering. + */ bool CLP(GraphicsStateGuardian):: apply_index_buffer(IndexBufferContext *ibc, const GeomPrimitivePipelineReader *reader, @@ -5564,14 +5402,11 @@ apply_index_buffer(IndexBufferContext *ibc, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::release_index_buffer -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// data. This function should never be called -// directly; instead, call Data::release() (or simply -// let the Data destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the data. This function + * should never be called directly; instead, call Data::release() (or simply + * let the Data destruct). + */ void CLP(GraphicsStateGuardian):: release_index_buffer(IndexBufferContext *ibc) { nassertv(_supports_buffers); @@ -5583,10 +5418,9 @@ release_index_buffer(IndexBufferContext *ibc) { << "deleting index buffer " << (int)gibc->_index << "\n"; } - // Make sure the buffer is unbound before we delete it. Not - // strictly necessary according to the OpenGL spec, but it might - // help out a flaky driver, and we need to keep our internal state - // consistent anyway. + // Make sure the buffer is unbound before we delete it. Not strictly + // necessary according to the OpenGL spec, but it might help out a flaky + // driver, and we need to keep our internal state consistent anyway. if (_current_ibuffer_index == gibc->_index) { if (GLCAT.is_spam() && gl_debug_buffers) { GLCAT.spam() @@ -5604,24 +5438,19 @@ release_index_buffer(IndexBufferContext *ibc) { delete gibc; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::setup_primitive -// Access: Public -// Description: Internal function to bind a buffer object for the -// indicated primitive's index list, if appropriate, or -// to unbind a buffer object if it should be rendered -// from client memory. -// -// If the buffer object is bound, this function sets -// client_pointer to NULL (representing the start of the -// buffer object in server memory); if the buffer object -// is not bound, this function sets client_pointer to to -// the data array in client memory, that is, the data -// array passed in. -// -// If force is not true, the function may return false -// indicating the data is not currently available. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to bind a buffer object for the indicated primitive's + * index list, if appropriate, or to unbind a buffer object if it should be + * rendered from client memory. + * + * If the buffer object is bound, this function sets client_pointer to NULL + * (representing the start of the buffer object in server memory); if the + * buffer object is not bound, this function sets client_pointer to to the + * data array in client memory, that is, the data array passed in. + * + * If force is not true, the function may return false indicating the data is + * not currently available. + */ bool CLP(GraphicsStateGuardian):: setup_primitive(const unsigned char *&client_pointer, const GeomPrimitivePipelineReader *reader, @@ -5633,8 +5462,8 @@ setup_primitive(const unsigned char *&client_pointer, } if (!vertex_buffers || _geom_display_list != 0 || reader->get_usage_hint() == Geom::UH_client) { - // The array specifies client rendering only, or buffer objects - // are configured off. + // The array specifies client rendering only, or buffer objects are + // configured off. if (_current_ibuffer_index != 0) { if (GLCAT.is_spam() && gl_debug_buffers) { GLCAT.spam() @@ -5660,22 +5489,17 @@ setup_primitive(const unsigned char *&client_pointer, } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::begin_occlusion_query -// Access: Public, Virtual -// Description: Begins a new occlusion query. After this call, you -// may call begin_draw_primitives() and -// draw_triangles()/draw_whatever() repeatedly. -// Eventually, you should call end_occlusion_query() -// before the end of the frame; that will return a new -// OcclusionQueryContext object that will tell you how -// many pixels represented by the bracketed geometry -// passed the depth test. -// -// It is not valid to call begin_occlusion_query() -// between another begin_occlusion_query() -// .. end_occlusion_query() sequence. -//////////////////////////////////////////////////////////////////// +/** + * Begins a new occlusion query. After this call, you may call + * begin_draw_primitives() and draw_triangles()/draw_whatever() repeatedly. + * Eventually, you should call end_occlusion_query() before the end of the + * frame; that will return a new OcclusionQueryContext object that will tell + * you how many pixels represented by the bracketed geometry passed the depth + * test. + * + * It is not valid to call begin_occlusion_query() between another + * begin_occlusion_query() .. end_occlusion_query() sequence. + */ void CLP(GraphicsStateGuardian):: begin_occlusion_query() { nassertv(_supports_occlusion_query); @@ -5697,15 +5521,12 @@ begin_occlusion_query() { #endif // !OPENGLES #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_occlusion_query -// Access: Public, Virtual -// Description: Ends a previous call to begin_occlusion_query(). -// This call returns the OcclusionQueryContext object -// that will (eventually) report the number of pixels -// that passed the depth test between the call to -// begin_occlusion_query() and end_occlusion_query(). -//////////////////////////////////////////////////////////////////// +/** + * Ends a previous call to begin_occlusion_query(). This call returns the + * OcclusionQueryContext object that will (eventually) report the number of + * pixels that passed the depth test between the call to + * begin_occlusion_query() and end_occlusion_query(). + */ PT(OcclusionQueryContext) CLP(GraphicsStateGuardian):: end_occlusion_query() { nassertr(_current_occlusion_query != (OcclusionQueryContext *)NULL, NULL); @@ -5721,10 +5542,10 @@ end_occlusion_query() { _current_occlusion_query = NULL; _glEndQuery(GL_SAMPLES_PASSED); - // Temporary hack to try working around an apparent driver bug on - // iMacs. Occlusion queries sometimes incorrectly report 0 samples, - // unless we stall the pipe to keep fewer than a certain maximum - // number of queries pending at once. + // Temporary hack to try working around an apparent driver bug on iMacs. + // Occlusion queries sometimes incorrectly report 0 samples, unless we stall + // the pipe to keep fewer than a certain maximum number of queries pending + // at once. static ConfigVariableInt limit_occlusion_queries("limit-occlusion-queries", 0); if (limit_occlusion_queries > 0) { if (index > (unsigned int)limit_occlusion_queries) { @@ -5741,12 +5562,10 @@ end_occlusion_query() { } #endif // !OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::issue_timer_query -// Access: Public, Virtual -// Description: Adds a timer query to the command stream, associated -// with the given PStats collector index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a timer query to the command stream, associated with the given PStats + * collector index. + */ PT(TimerQueryContext) CLP(GraphicsStateGuardian):: issue_timer_query(int pstats_index) { #if defined(DO_PSTATS) && !defined(OPENGLES) @@ -5793,12 +5612,10 @@ issue_timer_query(int pstats_index) { } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::dispatch_compute -// Access: Public, Virtual -// Description: Dispatches a currently bound compute shader using -// the given work group counts. -//////////////////////////////////////////////////////////////////// +/** + * Dispatches a currently bound compute shader using the given work group + * counts. + */ void CLP(GraphicsStateGuardian):: dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { maybe_gl_finish(); @@ -5812,40 +5629,32 @@ dispatch_compute(int num_groups_x, int num_groups_y, int num_groups_z) { } #endif // !OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::make_geom_munger -// Access: Public, Virtual -// Description: Creates a new GeomMunger object to munge vertices -// appropriate to this GSG for the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GeomMunger object to munge vertices appropriate to this GSG + * for the indicated state. + */ PT(GeomMunger) CLP(GraphicsStateGuardian):: make_geom_munger(const RenderState *state, Thread *current_thread) { PT(CLP(GeomMunger)) munger = new CLP(GeomMunger)(this, state); return GeomMunger::register_munger(munger, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::compute_distance_to -// Access: Public, Virtual -// Description: This function will compute the distance to the -// indicated point, assumed to be in eye coordinates, -// from the camera plane. The point is assumed to be -// in the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * This function will compute the distance to the indicated point, assumed to + * be in eye coordinates, from the camera plane. The point is assumed to be + * in the GSG's internal coordinate system. + */ PN_stdfloat CLP(GraphicsStateGuardian):: compute_distance_to(const LPoint3 &point) const { return -point[2]; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::framebuffer_copy_to_texture -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display -// region from the framebuffer into texture memory. -// -// If z > -1, it is the cube map index or layer index -// into which to copy. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into texture memory. + * + * If z > -1, it is the cube map index or layer index into which to copy. + */ bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { @@ -5858,16 +5667,16 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, tex->set_size_padded(w, h, tex->get_z_size()); if (tex->get_compression() == Texture::CM_default) { - // Unless the user explicitly turned on texture compression, turn - // it off for the copy-to-texture case. + // Unless the user explicitly turned on texture compression, turn it off + // for the copy-to-texture case. tex->set_compression(Texture::CM_off); } // Sanity check everything. if (z >= 0) { if (z >= tex->get_z_size()) { - // This can happen, when textures with different layer counts - // are attached to a buffer. We simply ignore this if it happens. + // This can happen, when textures with different layer counts are + // attached to a buffer. We simply ignore this if it happens. return false; } @@ -5917,8 +5726,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, break; default: - // If the texture is a color format, we want to match the - // presence of sRGB and alpha according to the framebuffer. + // If the texture is a color format, we want to match the presence of + // sRGB and alpha according to the framebuffer. if (_current_properties->get_srgb_color()) { if (_current_properties->get_alpha_bits()) { tex->set_format(Texture::F_srgb_alpha); @@ -5984,8 +5793,7 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, width != gtc->_width || height != gtc->_height || depth != gtc->_depth) { - // If the texture properties have changed, we need to reload the - // image. + // If the texture properties have changed, we need to reload the image. new_image = true; } @@ -6009,8 +5817,8 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, if (z >= 0) { #ifndef OPENGLES_1 if (new_image) { - // These won't be used because we pass a NULL image, but we still - // have to specify them. Might as well use the actual values. + // These won't be used because we pass a NULL image, but we still have + // to specify them. Might as well use the actual values. GLint external_format = get_external_image_format(tex); GLint component_type = get_component_type(tex->get_component_type()); _glTexImage3D(target, 0, internal_format, width, height, depth, 0, external_format, component_type, NULL); @@ -6020,10 +5828,9 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, #endif } else { if (new_image) { - // We have to create a new image. - // It seems that OpenGL accepts a size higher than the framebuffer, - // but if we run into trouble we'll have to replace this with - // something smarter. + // We have to create a new image. It seems that OpenGL accepts a size + // higher than the framebuffer, but if we run into trouble we'll have to + // replace this with something smarter. glCopyTexImage2D(target, 0, internal_format, xo, yo, width, height, 0); } else { // We can overlay the existing image. @@ -6056,16 +5863,13 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::framebuffer_copy_to_ram -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display region -// from the framebuffer into system memory, not texture -// memory. Returns true on success, false on failure. -// -// This completely redefines the ram image of the -// indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into system memory, not texture memory. Returns true on success, false on + * failure. + * + * This completely redefines the ram image of the indicated texture. + */ bool CLP(GraphicsStateGuardian):: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb) { @@ -6074,10 +5878,9 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, glPixelStorei(GL_PACK_ALIGNMENT, 1); clear_color_write_mask(); - // Bug fix for RE, RE2, and VTX - need to disable texturing in order - // for glReadPixels() to work - // NOTE: reading the depth buffer is *much* slower than reading the - // color buffer + // Bug fix for RE, RE2, and VTX - need to disable texturing in order for + // glReadPixels() to work NOTE: reading the depth buffer is *much* slower + // than reading the color buffer set_state_and_transform(RenderState::make_empty(), _internal_transform); int xo, yo, w, h; @@ -6134,7 +5937,8 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, Texture::TextureType texture_type; int z_size; - //TODO: should be extended to support 3D textures, 2D arrays and cube map arrays. + // TODO: should be extended to support 3D textures, 2D arrays and cube map + // arrays. if (z >= 0) { texture_type = Texture::TT_cube_map; z_size = 6; @@ -6224,8 +6028,8 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, glReadPixels(xo, yo, w, h, external_format, get_component_type(component_type), image_ptr); - // We may have to reverse the byte ordering of the image if GL - // didn't do it for us. + // We may have to reverse the byte ordering of the image if GL didn't do it + // for us. if (color_mode && !_supports_bgr) { PTA_uchar new_image; const unsigned char *result = @@ -6241,11 +6045,9 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::apply_fog -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: apply_fog(Fog *fog) { Fog::Mode fmode = fog->get_mode(); @@ -6267,15 +6069,13 @@ apply_fog(Fog *fog) { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_transform -// Access: Protected -// Description: Sends the indicated transform matrix to the graphics -// API to be applied to future vertices. -// -// This transform is the internal_transform, already -// converted into the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Sends the indicated transform matrix to the graphics API to be applied to + * future vertices. + * + * This transform is the internal_transform, already converted into the GSG's + * internal coordinate system. + */ void CLP(GraphicsStateGuardian):: do_issue_transform() { #ifdef SUPPORT_FIXED_FUNCTION @@ -6297,11 +6097,9 @@ do_issue_transform() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_shade_model -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_shade_model() { const ShadeModelAttrib *target_shade_model; @@ -6322,11 +6120,9 @@ do_issue_shade_model() { #endif // SUPPORT_FIXED_FUNCTION #ifndef OPENGLES_1 -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_shader -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_shader() { ShaderContext *context = 0; @@ -6360,8 +6156,8 @@ do_issue_shader() { } } else { if (context != _current_shader_context) { - // Use a completely different shader than before. - // Unbind old shader, bind the new one. + // Use a completely different shader than before. Unbind old shader, + // bind the new one. if (_current_shader_context != NULL && _current_shader->get_language() != shader->get_language()) { _current_shader_context->unbind(); @@ -6389,11 +6185,9 @@ do_issue_shader() { } #endif // !OPENGLES_1 -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_render_mode -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_render_mode() { const RenderModeAttrib *target_render_mode; @@ -6442,27 +6236,24 @@ do_issue_render_mode() { do_point_size(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_antialias -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_antialias() { const AntialiasAttrib *target_antialias; _target_rs->get_attrib_def(target_antialias); if (target_antialias->get_mode_type() == AntialiasAttrib::M_auto) { - // In this special mode, we must enable antialiasing on a - // case-by-case basis, because we enable it differently for - // polygons and for points and lines. + // In this special mode, we must enable antialiasing on a case-by-case + // basis, because we enable it differently for polygons and for points and + // lines. _auto_antialias_mode = true; } else { - // Otherwise, explicitly enable or disable according to the bits - // that are set. But if multisample is requested and supported, - // don't use the other bits at all (they will be ignored by GL - // anyway). + // Otherwise, explicitly enable or disable according to the bits that are + // set. But if multisample is requested and supported, don't use the + // other bits at all (they will be ignored by GL anyway). _auto_antialias_mode = false; unsigned short mode = target_antialias->get_mode(); @@ -6511,11 +6302,9 @@ do_issue_antialias() { } #ifdef SUPPORT_FIXED_FUNCTION // OpenGL ES 2.0 doesn't support rescaling normals. -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_rescale_normal -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_rescale_normal() { RescaleNormalAttrib::Mode mode = RescaleNormalAttrib::M_none; @@ -6560,11 +6349,9 @@ do_issue_rescale_normal() { // PandaCompareFunc - 1 + 0x200 === GL_NEVER, etc. order is sequential #define PANDA_TO_GL_COMPAREFUNC(PANDACMPFUNC) (PANDACMPFUNC-1 +0x200) -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_depth_test -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_depth_test() { const DepthTestAttrib *target_depth_test; @@ -6581,11 +6368,9 @@ do_issue_depth_test() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_alpha_test -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_alpha_test() { #ifndef OPENGLES_1 @@ -6609,11 +6394,9 @@ do_issue_alpha_test() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_depth_write -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_depth_write() { const DepthWriteAttrib *target_depth_write; @@ -6636,11 +6419,9 @@ do_issue_depth_write() { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_cull_face -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_cull_face() { const CullFaceAttrib *target_cull_face; @@ -6669,11 +6450,9 @@ do_issue_cull_face() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_fog -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_fog() { const FogAttrib *target_fog; @@ -6691,11 +6470,9 @@ do_issue_fog() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_depth_offset -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_depth_offset() { const DepthOffsetAttrib *target_depth_offset = (const DepthOffsetAttrib *) @@ -6704,8 +6481,8 @@ do_issue_depth_offset() { int offset = target_depth_offset->get_offset(); if (offset != 0) { - // The relationship between these two parameters is a little - // unclear and poorly explained in the GL man pages. + // The relationship between these two parameters is a little unclear and + // poorly explained in the GL man pages. glPolygonOffset((GLfloat) -offset, (GLfloat) -offset); enable_polygon_offset(true); @@ -6731,11 +6508,9 @@ do_issue_depth_offset() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_material -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_material() { static Material empty; @@ -6755,9 +6530,9 @@ do_issue_material() { #ifndef NDEBUG if (_show_texture_usage) { - // In show_texture_usage mode, all colors are white, so as not - // to contaminate the texture color. This means we disable - // lighting materials too. + // In show_texture_usage mode, all colors are white, so as not to + // contaminate the texture color. This means we disable lighting + // materials too. material = ∅ has_material_force_color = false; } @@ -6774,15 +6549,15 @@ do_issue_material() { glMaterialf(face, GL_SHININESS, max(min(material->get_shininess(), (PN_stdfloat)128), (PN_stdfloat)0)); if (material->has_ambient() && material->has_diffuse()) { - // The material has both an ambient and diffuse specified. This - // means we do not need glMaterialColor(). + // The material has both an ambient and diffuse specified. This means we + // do not need glMaterialColor(). glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); } else if (material->has_ambient()) { - // The material specifies an ambient, but not a diffuse component. - // The diffuse component comes from the object's color. + // The material specifies an ambient, but not a diffuse component. The + // diffuse component comes from the object's color. call_glMaterialfv(face, GL_AMBIENT, material->get_ambient()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); @@ -6795,8 +6570,8 @@ do_issue_material() { } } else if (material->has_diffuse()) { - // The material specifies a diffuse, but not an ambient component. - // The ambient component comes from the object's color. + // The material specifies a diffuse, but not an ambient component. The + // ambient component comes from the object's color. call_glMaterialfv(face, GL_DIFFUSE, material->get_diffuse()); if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); @@ -6809,8 +6584,8 @@ do_issue_material() { } } else { - // The material specifies neither a diffuse nor an ambient - // component. Both components come from the object's color. + // The material specifies neither a diffuse nor an ambient component. + // Both components come from the object's color. if (has_material_force_color) { glDisable(GL_COLOR_MATERIAL); call_glMaterialfv(face, GL_AMBIENT, _material_force_color); @@ -6838,17 +6613,14 @@ do_issue_material() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_blending -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_blending() { - // Handle the color_write attrib. If color_write is off, then - // all the other blending-related stuff doesn't matter. If the - // device doesn't support color-write, we use blending tricks - // to effectively disable color write. + // Handle the color_write attrib. If color_write is off, then all the other + // blending-related stuff doesn't matter. If the device doesn't support + // color-write, we use blending tricks to effectively disable color write. const ColorWriteAttrib *target_color_write; _target_rs->get_attrib_def(target_color_write); @@ -6962,8 +6734,8 @@ do_issue_blending() { } if (_line_smooth_enabled || _point_smooth_enabled) { - // If we have either of these turned on, we also need to have - // blend mode enabled in order to see it. + // If we have either of these turned on, we also need to have blend mode + // enabled in order to see it. enable_multisample_alpha_one(false); enable_multisample_alpha_mask(false); enable_blend(true); @@ -6977,15 +6749,13 @@ do_issue_blending() { return; } - // For best polygon smoothing, we need: - // (1) a frame buffer that supports alpha - // (2) sort polygons front-to-back - // (3) glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); - // - // Since these modes have other implications for the application, we - // don't attempt to do this by default. If you really want good - // polygon smoothing (and you don't have multisample support), do - // all this yourself. +/* + * For best polygon smoothing, we need: (1) a frame buffer that supports alpha + * (2) sort polygons front-to-back (3) glBlendFunc(GL_SRC_ALPHA_SATURATE, + * GL_ONE); Since these modes have other implications for the application, we + * don't attempt to do this by default. If you really want good polygon + * smoothing (and you don't have multisample support), do all this yourself. + */ // Nothing's set, so disable blending. enable_multisample_alpha_one(false); @@ -6994,18 +6764,17 @@ do_issue_blending() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void CLP(GraphicsStateGuardian):: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { - // static PStatCollector _draw_set_state_light_bind_point_pcollector("Draw:Set State:Light:Bind:Point"); - // PStatGPUTimer timer(this, _draw_set_state_light_bind_point_pcollector); + // static PStatCollector + // _draw_set_state_light_bind_point_pcollector("Draw:Set + // State:Light:Bind:Point"); PStatGPUTimer timer(this, + // _draw_set_state_light_bind_point_pcollector); GLenum id = get_light_id(light_id); static const LColor black(0.0f, 0.0f, 0.0f, 1.0f); @@ -7013,8 +6782,8 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); - // Position needs to specify x, y, z, and w - // w == 1 implies non-infinite position + // Position needs to specify x, y, z, and w w == 1 implies non-infinite + // position CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); LPoint3 pos = light_obj->get_point() * transform->get_mat(); @@ -7039,18 +6808,17 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void CLP(GraphicsStateGuardian):: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { - // static PStatCollector _draw_set_state_light_bind_directional_pcollector("Draw:Set State:Light:Bind:Directional"); - // PStatGPUTimer timer(this, _draw_set_state_light_bind_directional_pcollector); + // static PStatCollector + // _draw_set_state_light_bind_directional_pcollector("Draw:Set + // State:Light:Bind:Directional"); PStatGPUTimer timer(this, + // _draw_set_state_light_bind_directional_pcollector); pair lookup = _dlights.insert(DirectionalLights::value_type(light, DirectionalLightFrameData())); DirectionalLightFrameData &fdata = (*lookup.first).second; @@ -7067,12 +6835,12 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); - // Position needs to specify x, y, z, and w. - // w == 0 implies light is at infinity + // Position needs to specify x, y, z, and w. w == 0 implies light is at + // infinity call_glLightfv(id, GL_POSITION, fdata._neg_dir); - // GL_SPOT_DIRECTION is not significant when cutoff == 180 - // In this case, position x, y, z specifies direction + // GL_SPOT_DIRECTION is not significant when cutoff == 180 In this case, + // position x, y, z specifies direction // Exponent == 0 implies uniform light distribution glLightf(id, GL_SPOT_EXPONENT, 0.0f); @@ -7080,8 +6848,8 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // Cutoff == 180 means uniform point light source glLightf(id, GL_SPOT_CUTOFF, 180.0f); - // Default attenuation values (only spotlight and point light can - // modify these) + // Default attenuation values (only spotlight and point light can modify + // these) glLightf(id, GL_CONSTANT_ATTENUATION, 1.0f); glLightf(id, GL_LINEAR_ATTENUATION, 0.0f); glLightf(id, GL_QUADRATIC_ATTENUATION, 0.0f); @@ -7091,18 +6859,17 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void CLP(GraphicsStateGuardian):: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { - // static PStatCollector _draw_set_state_light_bind_spotlight_pcollector("Draw:Set State:Light:Bind:Spotlight"); - // PStatGPUTimer timer(this, _draw_set_state_light_bind_spotlight_pcollector); + // static PStatCollector + // _draw_set_state_light_bind_spotlight_pcollector("Draw:Set + // State:Light:Bind:Spotlight"); PStatGPUTimer timer(this, + // _draw_set_state_light_bind_spotlight_pcollector); Lens *lens = light_obj->get_lens(); nassertv(lens != (Lens *)NULL); @@ -7113,8 +6880,8 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { call_glLightfv(id, GL_DIFFUSE, get_light_color(light_obj)); call_glLightfv(id, GL_SPECULAR, light_obj->get_specular_color()); - // Position needs to specify x, y, z, and w - // w == 1 implies non-infinite position + // Position needs to specify x, y, z, and w w == 1 implies non-infinite + // position CPT(TransformState) transform = light.get_transform(_scene_setup->get_scene_root().get_parent()); const LMatrix4 &light_mat = transform->get_mat(); LPoint3 pos = lens->get_nodal_point() * light_mat; @@ -7137,12 +6904,10 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_IMMEDIATE_MODE -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_immediate_simple_primitives -// Access: Protected -// Description: Uses the ImmediateModeSender to draw a series of -// primitives of the indicated type. -//////////////////////////////////////////////////////////////////// +/** + * Uses the ImmediateModeSender to draw a series of primitives of the + * indicated type. + */ void CLP(GraphicsStateGuardian):: draw_immediate_simple_primitives(const GeomPrimitivePipelineReader *reader, GLenum mode) { int num_vertices = reader->get_num_vertices(); @@ -7167,14 +6932,11 @@ draw_immediate_simple_primitives(const GeomPrimitivePipelineReader *reader, GLen #endif // SUPPORT_IMMEDIATE_MODE #ifdef SUPPORT_IMMEDIATE_MODE -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::draw_immediate_composite_primitives -// Access: Protected -// Description: Uses the ImmediateModeSender to draw a series of -// primitives of the indicated type. This form is for -// primitive types like tristrips which must involve -// several begin/end groups. -//////////////////////////////////////////////////////////////////// +/** + * Uses the ImmediateModeSender to draw a series of primitives of the + * indicated type. This form is for primitive types like tristrips which must + * involve several begin/end groups. + */ void CLP(GraphicsStateGuardian):: draw_immediate_composite_primitives(const GeomPrimitivePipelineReader *reader, GLenum mode) { int num_vertices = reader->get_num_vertices(); @@ -7217,22 +6979,18 @@ draw_immediate_composite_primitives(const GeomPrimitivePipelineReader *reader, G } #endif // SUPPORT_IMMEDIATE_MODE -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::gl_flush -// Access: Protected, Virtual -// Description: Calls glFlush(). -//////////////////////////////////////////////////////////////////// +/** + * Calls glFlush(). + */ void CLP(GraphicsStateGuardian):: gl_flush() const { PStatTimer timer(_flush_pcollector); glFlush(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::gl_get_error -// Access: Protected, Virtual -// Description: Returns the result of glGetError(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the result of glGetError(). + */ GLenum CLP(GraphicsStateGuardian):: gl_get_error() const { if (_check_errors) { @@ -7243,14 +7001,11 @@ gl_get_error() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::report_errors_loop -// Access: Protected, Static -// Description: The internal implementation of report_errors(). -// Don't call this function; use report_errors() -// instead. The return value is true if everything is -// ok, or false if we should shut down. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of report_errors(). Don't call this function; + * use report_errors() instead. The return value is true if everything is ok, + * or false if we should shut down. + */ bool CLP(GraphicsStateGuardian):: report_errors_loop(int line, const char *source_file, GLenum error_code, int &error_count) { @@ -7267,16 +7022,14 @@ report_errors_loop(int line, const char *source_file, GLenum error_code, return (error_code == GL_NO_ERROR); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_error_string -// Access: Protected, Static -// Description: Returns an error string for an OpenGL error code. -//////////////////////////////////////////////////////////////////// +/** + * Returns an error string for an OpenGL error code. + */ string CLP(GraphicsStateGuardian):: get_error_string(GLenum error_code) { - // We used to use gluErrorString here, but I (rdb) took it out - // because that was really the only function we used from GLU. - // The idea with the error table was taken from SGI's sample implementation. + // We used to use gluErrorString here, but I (rdb) took it out because that + // was really the only function we used from GLU. The idea with the error + // table was taken from SGI's sample implementation. static const char *error_strings[] = { "invalid enumerant", "invalid value", @@ -7305,12 +7058,10 @@ get_error_string(GLenum error_code) { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::show_gl_string -// Access: Protected -// Description: Outputs the result of glGetString() on the indicated -// tag. The output string is returned. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the result of glGetString() on the indicated tag. The output + * string is returned. + */ string CLP(GraphicsStateGuardian):: show_gl_string(const string &name, GLenum id) { string result; @@ -7332,11 +7083,9 @@ show_gl_string(const string &name, GLenum id) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::query_gl_version -// Access: Protected, Virtual -// Description: Queries the runtime version of OpenGL in use. -//////////////////////////////////////////////////////////////////// +/** + * Queries the runtime version of OpenGL in use. + */ void CLP(GraphicsStateGuardian):: query_gl_version() { _gl_vendor = show_gl_string("GL_VENDOR", GL_VENDOR); @@ -7371,8 +7120,8 @@ query_gl_version() { } } - // If we asked for a GL 3 context, let's first try and see if we - // can use the OpenGL 3 way to query version. + // If we asked for a GL 3 context, let's first try and see if we can use the + // OpenGL 3 way to query version. if (gl_version.get_num_words() > 0 && gl_version[0] >= 3) { glGetIntegerv(GL_MAJOR_VERSION, &_gl_version_major); glGetIntegerv(GL_MINOR_VERSION, &_gl_version_minor); @@ -7433,11 +7182,9 @@ query_gl_version() { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::query_glsl_version -// Access: Protected -// Description: Queries the supported GLSL version. -//////////////////////////////////////////////////////////////////// +/** + * Queries the supported GLSL version. + */ void CLP(GraphicsStateGuardian):: query_glsl_version() { _gl_shadlang_ver_major = 0; @@ -7480,13 +7227,10 @@ query_glsl_version() { #endif // !OPENGLES_1 } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::save_extensions -// Access: Protected -// Description: Separates the string returned by GL_EXTENSIONS (or -// glx or wgl extensions) into its individual tokens -// and saves them in the _extensions member. -//////////////////////////////////////////////////////////////////// +/** + * Separates the string returned by GL_EXTENSIONS (or glx or wgl extensions) + * into its individual tokens and saves them in the _extensions member. + */ void CLP(GraphicsStateGuardian):: save_extensions(const char *extensions) { if (extensions != (const char *)NULL) { @@ -7500,24 +7244,18 @@ save_extensions(const char *extensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_extra_extensions -// Access: Protected, Virtual -// Description: This may be redefined by a derived class (e.g. glx or -// wgl) to get whatever further extensions strings may -// be appropriate to that interface, in addition to the -// GL extension strings return by glGetString(). -//////////////////////////////////////////////////////////////////// +/** + * This may be redefined by a derived class (e.g. glx or wgl) to get whatever + * further extensions strings may be appropriate to that interface, in + * addition to the GL extension strings return by glGetString(). + */ void CLP(GraphicsStateGuardian):: get_extra_extensions() { } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::report_extensions -// Access: Protected -// Description: Outputs the list of GL extensions to notify, if debug -// mode is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the list of GL extensions to notify, if debug mode is enabled. + */ void CLP(GraphicsStateGuardian):: report_extensions() const { if (GLCAT.is_debug()) { @@ -7547,20 +7285,16 @@ report_extensions() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_extension_func -// Access: Public -// Description: Returns the pointer to the GL extension function with -// the indicated name, or NULL if the function is not -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name, + * or NULL if the function is not available. + */ void *CLP(GraphicsStateGuardian):: get_extension_func(const char *name) { - // First, look in the static-compiled namespace. If we were - // compiled to expect at least a certain minimum runtime version of - // OpenGL, then we can expect those extension functions to be - // available at compile time. Somewhat more reliable than poking - // around in the runtime pointers. + // First, look in the static-compiled namespace. If we were compiled to + // expect at least a certain minimum runtime version of OpenGL, then we can + // expect those extension functions to be available at compile time. + // Somewhat more reliable than poking around in the runtime pointers. static struct { const char *name; void *fptr; @@ -7627,34 +7361,27 @@ get_extension_func(const char *name) { ++i; } - // If the extension function wasn't compiled in, then go get it from - // the runtime. There's a different interface for each API. + // If the extension function wasn't compiled in, then go get it from the + // runtime. There's a different interface for each API. return do_get_extension_func(name); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: This is the virtual implementation of -// get_extension_func(). Each API-specific GL -// implementation will map this method to the -// appropriate API call to retrieve the extension -// function pointer. Returns NULL if the function is -// not available. -//////////////////////////////////////////////////////////////////// +/** + * This is the virtual implementation of get_extension_func(). Each API- + * specific GL implementation will map this method to the appropriate API call + * to retrieve the extension function pointer. Returns NULL if the function + * is not available. + */ void *CLP(GraphicsStateGuardian):: do_get_extension_func(const char *) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_draw_buffer -// Access: Protected -// Description: Sets up the glDrawBuffer to render into the buffer -// indicated by the RenderBuffer object. This only sets -// up the color and aux bits; it does not affect the depth, -// stencil, accum layers. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the glDrawBuffer to render into the buffer indicated by the + * RenderBuffer object. This only sets up the color and aux bits; it does not + * affect the depth, stencil, accum layers. + */ void CLP(GraphicsStateGuardian):: set_draw_buffer(int rbtype) { #ifndef OPENGLES // Draw buffers not supported by OpenGL ES. @@ -7744,14 +7471,11 @@ set_draw_buffer(int rbtype) { report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_read_buffer -// Access: Protected -// Description: Sets up the glReadBuffer to render into the buffer -// indicated by the RenderBuffer object. This only sets -// up the color bits; it does not affect the depth, -// stencil, accum layers. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the glReadBuffer to render into the buffer indicated by the + * RenderBuffer object. This only sets up the color bits; it does not affect + * the depth, stencil, accum layers. + */ void CLP(GraphicsStateGuardian):: set_read_buffer(int rbtype) { #ifndef OPENGLES // Draw buffers not supported by OpenGL ES. @@ -7833,12 +7557,9 @@ set_read_buffer(int rbtype) { #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_numeric_type -// Access: Protected, Static -// Description: Maps from the Geom's internal numeric type symbols -// to GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Geom's internal numeric type symbols to GL's. + */ GLenum CLP(GraphicsStateGuardian):: get_numeric_type(Geom::NumericType numeric_type) { switch (numeric_type) { @@ -7897,12 +7618,9 @@ get_numeric_type(Geom::NumericType numeric_type) { return GL_UNSIGNED_BYTE; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_target -// Access: Protected -// Description: Maps from the Texture's texture type symbols to -// GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's texture type symbols to GL's. + */ GLenum CLP(GraphicsStateGuardian):: get_texture_target(Texture::TextureType texture_type) const { switch (texture_type) { @@ -7959,12 +7677,9 @@ get_texture_target(Texture::TextureType texture_type) const { return GL_TEXTURE_2D; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_wrap_mode -// Access: Protected -// Description: Maps from the Texture's internal wrap mode symbols to -// GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's internal wrap mode symbols to GL's. + */ GLenum CLP(GraphicsStateGuardian):: get_texture_wrap_mode(SamplerState::WrapMode wm) const { if (gl_ignore_clamp) { @@ -7993,12 +7708,9 @@ get_texture_wrap_mode(SamplerState::WrapMode wm) const { return _edge_clamp; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_panda_wrap_mode -// Access: Protected, Static -// Description: Maps from the GL's internal wrap mode symbols to -// Panda's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the GL's internal wrap mode symbols to Panda's. + */ SamplerState::WrapMode CLP(GraphicsStateGuardian):: get_panda_wrap_mode(GLenum wm) { switch (wm) { @@ -8029,12 +7741,9 @@ get_panda_wrap_mode(GLenum wm) { return SamplerState::WM_clamp; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_filter_type -// Access: Protected, Static -// Description: Maps from the Texture's internal filter type symbols -// to GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's internal filter type symbols to GL's. + */ GLenum CLP(GraphicsStateGuardian):: get_texture_filter_type(SamplerState::FilterType ft, bool ignore_mipmaps) { if (gl_ignore_filters) { @@ -8082,12 +7791,9 @@ get_texture_filter_type(SamplerState::FilterType ft, bool ignore_mipmaps) { return GL_NEAREST; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_panda_filter_type -// Access: Protected, Static -// Description: Maps from the GL's internal filter type symbols -// to Panda's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the GL's internal filter type symbols to Panda's. + */ SamplerState::FilterType CLP(GraphicsStateGuardian):: get_panda_filter_type(GLenum ft) { switch (ft) { @@ -8108,12 +7814,9 @@ get_panda_filter_type(GLenum ft) { return SamplerState::FT_linear; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_component_type -// Access: Protected, Static -// Description: Maps from the Texture's internal ComponentType symbols -// to GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's internal ComponentType symbols to GL's. + */ GLenum CLP(GraphicsStateGuardian):: get_component_type(Texture::ComponentType component_type) { switch (component_type) { @@ -8149,12 +7852,9 @@ get_component_type(Texture::ComponentType component_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_external_image_format -// Access: Protected -// Description: Maps from the Texture's Format symbols -// to GL's. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's Format symbols to GL's. + */ GLint CLP(GraphicsStateGuardian):: get_external_image_format(Texture *tex) const { Texture::CompressionMode compression = tex->get_ram_image_compression(); @@ -8433,12 +8133,10 @@ get_external_image_format(Texture *tex) const { return GL_RGB; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_internal_image_format -// Access: Protected -// Description: Maps from the Texture's Format symbols to a -// suitable internal format for GL textures. -//////////////////////////////////////////////////////////////////// +/** + * Maps from the Texture's Format symbols to a suitable internal format for GL + * textures. + */ GLint CLP(GraphicsStateGuardian):: get_internal_image_format(Texture *tex, bool force_sized) const { Texture::CompressionMode compression = tex->get_compression(); @@ -8457,11 +8155,11 @@ get_internal_image_format(Texture *tex, bool force_sized) const { switch (compression) { case Texture::CM_on: // The user asked for just generic compression. OpenGL supports - // requesting just generic compression, but we'd like to go ahead - // and request a specific type (if we can figure out an - // appropriate choice), since that makes saving the result as a - // pre-compressed texture more dependable--this way, we will know - // which compression algorithm was applied. + // requesting just generic compression, but we'd like to go ahead and + // request a specific type (if we can figure out an appropriate choice), + // since that makes saving the result as a pre-compressed texture more + // dependable--this way, we will know which compression algorithm was + // applied. switch (format) { case Texture::F_color_index: case Texture::F_depth_component: @@ -9061,12 +8759,10 @@ get_internal_image_format(Texture *tex, bool force_sized) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::is_mipmap_filter -// Access: Protected, Static -// Description: Returns true if the indicated GL minfilter type -// represents a mipmap format, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated GL minfilter type represents a mipmap format, + * false otherwise. + */ bool CLP(GraphicsStateGuardian):: is_mipmap_filter(GLenum min_filter) { switch (min_filter) { @@ -9081,13 +8777,10 @@ is_mipmap_filter(GLenum min_filter) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::is_compressed_format -// Access: Protected, Static -// Description: Returns true if the indicated GL internal format -// represents a compressed texture format, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated GL internal format represents a compressed + * texture format, false otherwise. + */ bool CLP(GraphicsStateGuardian):: is_compressed_format(GLenum format) { switch (format) { @@ -9128,12 +8821,9 @@ is_compressed_format(GLenum format) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_apply_mode_type -// Access: Protected, Static -// Description: Maps from the texture stage's mode types -// to the corresponding OpenGL ids -//////////////////////////////////////////////////////////////////// +/** + * Maps from the texture stage's mode types to the corresponding OpenGL ids + */ GLint CLP(GraphicsStateGuardian):: get_texture_apply_mode_type(TextureStage::Mode am) { #ifdef SUPPORT_FIXED_FUNCTION @@ -9160,12 +8850,10 @@ get_texture_apply_mode_type(TextureStage::Mode am) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_combine_type -// Access: Protected, Static -// Description: Maps from the texture stage's CombineMode types -// to the corresponding OpenGL ids -//////////////////////////////////////////////////////////////////// +/** + * Maps from the texture stage's CombineMode types to the corresponding OpenGL + * ids + */ GLint CLP(GraphicsStateGuardian):: get_texture_combine_type(TextureStage::CombineMode cm) { #ifdef SUPPORT_FIXED_FUNCTION @@ -9186,12 +8874,10 @@ get_texture_combine_type(TextureStage::CombineMode cm) { return GL_REPLACE; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_src_type -// Access: Protected -// Description: Maps from the texture stage's CombineSource types -// to the corresponding OpenGL ids -//////////////////////////////////////////////////////////////////// +/** + * Maps from the texture stage's CombineSource types to the corresponding + * OpenGL ids + */ GLint CLP(GraphicsStateGuardian):: get_texture_src_type(TextureStage::CombineSource cs, int last_stage, int last_saved_result, @@ -9237,12 +8923,10 @@ get_texture_src_type(TextureStage::CombineSource cs, return GL_TEXTURE; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_operand_type -// Access: Protected, Static -// Description: Maps from the texture stage's CombineOperand types -// to the corresponding OpenGL ids -//////////////////////////////////////////////////////////////////// +/** + * Maps from the texture stage's CombineOperand types to the corresponding + * OpenGL ids + */ GLint CLP(GraphicsStateGuardian):: get_texture_operand_type(TextureStage::CombineOperand co) { switch (co) { @@ -9259,11 +8943,9 @@ get_texture_operand_type(TextureStage::CombineOperand co) { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_fog_mode_type -// Access: Protected, Static -// Description: Maps from the fog types to gl version -//////////////////////////////////////////////////////////////////// +/** + * Maps from the fog types to gl version + */ GLenum CLP(GraphicsStateGuardian):: get_fog_mode_type(Fog::Mode m) { switch(m) { @@ -9281,12 +8963,9 @@ get_fog_mode_type(Fog::Mode m) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_blend_equation_type -// Access: Protected, Static -// Description: Maps from ColorBlendAttrib::Mode to glBlendEquation -// value. -//////////////////////////////////////////////////////////////////// +/** + * Maps from ColorBlendAttrib::Mode to glBlendEquation value. + */ GLenum CLP(GraphicsStateGuardian):: get_blend_equation_type(ColorBlendAttrib::Mode mode) { switch (mode) { @@ -9320,12 +8999,9 @@ get_blend_equation_type(ColorBlendAttrib::Mode mode) { return GL_FUNC_ADD; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_blend_func -// Access: Protected, Static -// Description: Maps from ColorBlendAttrib::Operand to glBlendFunc -// value. -//////////////////////////////////////////////////////////////////// +/** + * Maps from ColorBlendAttrib::Operand to glBlendFunc value. + */ GLenum CLP(GraphicsStateGuardian):: get_blend_func(ColorBlendAttrib::Operand operand) { switch (operand) { @@ -9397,11 +9073,9 @@ get_blend_func(ColorBlendAttrib::Operand operand) { return GL_ZERO; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_usage -// Access: Public, Static -// Description: Maps from UsageHint to the GL symbol. -//////////////////////////////////////////////////////////////////// +/** + * Maps from UsageHint to the GL symbol. + */ GLenum CLP(GraphicsStateGuardian):: get_usage(Geom::UsageHint usage_hint) { switch (usage_hint) { @@ -9429,11 +9103,9 @@ get_usage(Geom::UsageHint usage_hint) { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_compressed_format_string -// Access: Public, Static -// Description: Returns a string describing an compression format. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string describing an compression format. + */ const char *CLP(GraphicsStateGuardian):: get_compressed_format_string(GLenum format) { switch (format) { @@ -9549,14 +9221,11 @@ get_compressed_format_string(GLenum format) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_light_color -// Access: Public -// Description: Returns the value that that should be issued as the -// light's color, as scaled by the current value of -// _light_color_scale, in the case of -// color_scale_via_lighting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value that that should be issued as the light's color, as + * scaled by the current value of _light_color_scale, in the case of + * color_scale_via_lighting. + */ LVecBase4 CLP(GraphicsStateGuardian):: get_light_color(Light *light) const { #ifndef NDEBUG @@ -9577,14 +9246,11 @@ get_light_color(Light *light) const { } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::reissue_transforms -// Access: Protected, Virtual -// Description: Called by clear_state_and_transform() to ensure that -// the current modelview and projection matrices are -// properly loaded in the graphics state, after a -// callback might have mucked them up. -//////////////////////////////////////////////////////////////////// +/** + * Called by clear_state_and_transform() to ensure that the current modelview + * and projection matrices are properly loaded in the graphics state, after a + * callback might have mucked them up. + */ void CLP(GraphicsStateGuardian):: reissue_transforms() { prepare_lens(); @@ -9600,18 +9266,17 @@ reissue_transforms() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_lighting -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable or disable the use of lighting overall. This -// is called by do_issue_light() according to whether any -// lights are in use or not. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable or disable the use + * of lighting overall. This is called by do_issue_light() according to + * whether any lights are in use or not. + */ void CLP(GraphicsStateGuardian):: enable_lighting(bool enable) { - // static PStatCollector _draw_set_state_light_enable_lighting_pcollector("Draw:Set State:Light:Enable lighting"); - // PStatGPUTimer timer(this, _draw_set_state_light_enable_lighting_pcollector); + // static PStatCollector + // _draw_set_state_light_enable_lighting_pcollector("Draw:Set + // State:Light:Enable lighting"); PStatGPUTimer timer(this, + // _draw_set_state_light_enable_lighting_pcollector); if (enable) { glEnable(GL_LIGHTING); @@ -9622,18 +9287,16 @@ enable_lighting(bool enable) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_ambient_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// indicate the color of the ambient light that should -// be in effect. This is called by do_issue_light() after -// all other lights have been enabled or disabled. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to indicate the color of the + * ambient light that should be in effect. This is called by do_issue_light() + * after all other lights have been enabled or disabled. + */ void CLP(GraphicsStateGuardian):: set_ambient_light(const LColor &color) { - // static PStatCollector _draw_set_state_light_ambient_pcollector("Draw:Set State:Light:Ambient"); - // PStatGPUTimer timer(this, _draw_set_state_light_ambient_pcollector); + // static PStatCollector _draw_set_state_light_ambient_pcollector("Draw:Set + // State:Light:Ambient"); PStatGPUTimer timer(this, + // _draw_set_state_light_ambient_pcollector); LColor c = color; c.set(c[0] * _light_color_scale[0], @@ -9645,17 +9308,17 @@ set_ambient_light(const LColor &color) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_light -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated light id. A specific Light will -// already have been bound to this id via bind_light(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated light + * id. A specific Light will already have been bound to this id via + * bind_light(). + */ void CLP(GraphicsStateGuardian):: enable_light(int light_id, bool enable) { - // static PStatCollector _draw_set_state_light_enable_light_pcollector("Draw:Set State:Light:Enable light"); - // PStatGPUTimer timer(this, _draw_set_state_light_enable_light_pcollector); + // static PStatCollector + // _draw_set_state_light_enable_light_pcollector("Draw:Set + // State:Light:Enable light"); PStatGPUTimer timer(this, + // _draw_set_state_light_enable_light_pcollector); if (enable) { glEnable(get_light_id(light_id)); @@ -9666,30 +9329,28 @@ enable_light(int light_id, bool enable) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::begin_bind_lights -// Access: Protected, Virtual -// Description: Called immediately before bind_light() is called, -// this is intended to provide the derived class a hook -// in which to set up some state (like transform) that -// might apply to several lights. -// -// The sequence is: begin_bind_lights() will be called, -// then one or more bind_light() calls, then -// end_bind_lights(). -//////////////////////////////////////////////////////////////////// +/** + * Called immediately before bind_light() is called, this is intended to + * provide the derived class a hook in which to set up some state (like + * transform) that might apply to several lights. + * + * The sequence is: begin_bind_lights() will be called, then one or more + * bind_light() calls, then end_bind_lights(). + */ void CLP(GraphicsStateGuardian):: begin_bind_lights() { - // static PStatCollector _draw_set_state_light_begin_bind_pcollector("Draw:Set State:Light:Begin bind"); - // PStatGPUTimer timer(this, _draw_set_state_light_begin_bind_pcollector); + // static PStatCollector + // _draw_set_state_light_begin_bind_pcollector("Draw:Set State:Light:Begin + // bind"); PStatGPUTimer timer(this, + // _draw_set_state_light_begin_bind_pcollector); - // We need to temporarily load a new matrix so we can define the - // light in a known coordinate system. We pick the transform of the - // root. (Alternatively, we could leave the current transform where - // it is and compute the light position relative to that transform - // instead of relative to the root, by composing with the matrix - // computed by _internal_transform->invert_compose(render_transform). - // But I think loading a completely new matrix is simpler.) + // We need to temporarily load a new matrix so we can define the light in a + // known coordinate system. We pick the transform of the root. + // (Alternatively, we could leave the current transform where it is and + // compute the light position relative to that transform instead of relative + // to the root, by composing with the matrix computed by + // _internal_transform->invert_compose(render_transform). But I think + // loading a completely new matrix is simpler.) CPT(TransformState) render_transform = _cs_transform->compose(_scene_setup->get_world_transform()); @@ -9700,19 +9361,17 @@ begin_bind_lights() { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_bind_lights -// Access: Protected, Virtual -// Description: Called after before bind_light() has been called one -// or more times (but before any geometry is issued or -// additional state is changed), this is intended to -// clean up any temporary changes to the state that may -// have been made by begin_bind_lights(). -//////////////////////////////////////////////////////////////////// +/** + * Called after before bind_light() has been called one or more times (but + * before any geometry is issued or additional state is changed), this is + * intended to clean up any temporary changes to the state that may have been + * made by begin_bind_lights(). + */ void CLP(GraphicsStateGuardian):: end_bind_lights() { - // static PStatCollector _draw_set_state_light_end_bind_pcollector("Draw:Set State:Light:End bind"); - // PStatGPUTimer timer(this, _draw_set_state_light_end_bind_pcollector); + // static PStatCollector _draw_set_state_light_end_bind_pcollector("Draw:Set + // State:Light:End bind"); PStatGPUTimer timer(this, + // _draw_set_state_light_end_bind_pcollector); glMatrixMode(GL_MODELVIEW); glPopMatrix(); @@ -9720,14 +9379,11 @@ end_bind_lights() { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::enable_clip_plane -// Access: Protected, Virtual -// Description: Intended to be overridden by a derived class to -// enable the indicated clip_plane id. A specific -// PlaneNode will already have been bound to this id via -// bind_clip_plane(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by a derived class to enable the indicated + * clip_plane id. A specific PlaneNode will already have been bound to this + * id via bind_clip_plane(). + */ void CLP(GraphicsStateGuardian):: enable_clip_plane(int plane_id, bool enable) { if (enable) { @@ -9739,27 +9395,23 @@ enable_clip_plane(int plane_id, bool enable) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::begin_bind_clip_planes -// Access: Protected, Virtual -// Description: Called immediately before bind_clip_plane() is called, -// this is intended to provide the derived class a hook -// in which to set up some state (like transform) that -// might apply to several clip_planes. -// -// The sequence is: begin_bind_clip_planes() will be called, -// then one or more bind_clip_plane() calls, then -// end_bind_clip_planes(). -//////////////////////////////////////////////////////////////////// +/** + * Called immediately before bind_clip_plane() is called, this is intended to + * provide the derived class a hook in which to set up some state (like + * transform) that might apply to several clip_planes. + * + * The sequence is: begin_bind_clip_planes() will be called, then one or more + * bind_clip_plane() calls, then end_bind_clip_planes(). + */ void CLP(GraphicsStateGuardian):: begin_bind_clip_planes() { - // We need to temporarily load a new matrix so we can define the - // clip_plane in a known coordinate system. We pick the transform of the - // root. (Alternatively, we could leave the current transform where - // it is and compute the clip_plane position relative to that transform - // instead of relative to the root, by composing with the matrix - // computed by _internal_transform->invert_compose(render_transform). - // But I think loading a completely new matrix is simpler.) + // We need to temporarily load a new matrix so we can define the clip_plane + // in a known coordinate system. We pick the transform of the root. + // (Alternatively, we could leave the current transform where it is and + // compute the clip_plane position relative to that transform instead of + // relative to the root, by composing with the matrix computed by + // _internal_transform->invert_compose(render_transform). But I think + // loading a completely new matrix is simpler.) CPT(TransformState) render_transform = _cs_transform->compose(_scene_setup->get_world_transform()); @@ -9770,14 +9422,11 @@ begin_bind_clip_planes() { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::bind_clip_plane -// Access: Protected, Virtual -// Description: Called the first time a particular clip_plane has been -// bound to a given id within a frame, this should set -// up the associated hardware clip_plane with the clip_plane's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular clip_plane has been bound to a given id + * within a frame, this should set up the associated hardware clip_plane with + * the clip_plane's properties. + */ void CLP(GraphicsStateGuardian):: bind_clip_plane(const NodePath &plane, int plane_id) { GLenum id = get_clip_plane_id(plane_id); @@ -9802,15 +9451,12 @@ bind_clip_plane(const NodePath &plane, int plane_id) { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::end_bind_clip_planes -// Access: Protected, Virtual -// Description: Called after before bind_clip_plane() has been called one -// or more times (but before any geometry is issued or -// additional state is changed), this is intended to -// clean up any temporary changes to the state that may -// have been made by begin_bind_clip_planes(). -//////////////////////////////////////////////////////////////////// +/** + * Called after before bind_clip_plane() has been called one or more times + * (but before any geometry is issued or additional state is changed), this is + * intended to clean up any temporary changes to the state that may have been + * made by begin_bind_clip_planes(). + */ void CLP(GraphicsStateGuardian):: end_bind_clip_planes() { glMatrixMode(GL_MODELVIEW); @@ -9818,23 +9464,18 @@ end_bind_clip_planes() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::set_state_and_transform -// Access: Public, Virtual -// Description: Simultaneously resets the render state and the -// transform state. -// -// This transform specified is the "internal" net -// transform, already converted into the GSG's internal -// coordinate space by composing it to -// get_cs_transform(). (Previously, this used to be the -// "external" net transform, with the assumption that -// that GSG would convert it internally, but that is no -// longer the case.) -// -// Special case: if (state==NULL), then the target -// state is already stored in _target. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously resets the render state and the transform state. + * + * This transform specified is the "internal" net transform, already converted + * into the GSG's internal coordinate space by composing it to + * get_cs_transform(). (Previously, this used to be the "external" net + * transform, with the assumption that that GSG would convert it internally, + * but that is no longer the case.) + * + * Special case: if (state==NULL), then the target state is already stored in + * _target. + */ void CLP(GraphicsStateGuardian):: set_state_and_transform(const RenderState *target, const TransformState *transform) { @@ -9850,7 +9491,7 @@ set_state_and_transform(const RenderState *target, PStatGPUTimer timer1(this, _draw_set_state_pcollector); if (transform != _internal_transform) { - //PStatGPUTimer timer(this, _draw_set_state_transform_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_transform_pcollector); _transform_state_pcollector.add_level(1); _internal_transform = transform; do_issue_transform(); @@ -9867,7 +9508,7 @@ set_state_and_transform(const RenderState *target, _instance_count = _target_shader->get_instance_count(); if (_target_shader != _state_shader) { - //PStatGPUTimer timer(this, _draw_set_state_shader_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_shader_pcollector); do_issue_shader(); _state_shader = _target_shader; _state_mask.clear_bit(TextureAttrib::get_class_slot()); @@ -9893,7 +9534,7 @@ set_state_and_transform(const RenderState *target, _state_shader->get_flag(ShaderAttrib::F_subsume_alpha_test)) #endif ) { - //PStatGPUTimer timer(this, _draw_set_state_alpha_test_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_alpha_test_pcollector); do_issue_alpha_test(); _state_mask.set_bit(alpha_test_slot); } @@ -9902,7 +9543,7 @@ set_state_and_transform(const RenderState *target, int antialias_slot = AntialiasAttrib::get_class_slot(); if (_target_rs->get_attrib(antialias_slot) != _state_rs->get_attrib(antialias_slot) || !_state_mask.get_bit(antialias_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_antialias_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_antialias_pcollector); do_issue_antialias(); _state_mask.set_bit(antialias_slot); } @@ -9910,7 +9551,7 @@ set_state_and_transform(const RenderState *target, int clip_plane_slot = ClipPlaneAttrib::get_class_slot(); if (_target_rs->get_attrib(clip_plane_slot) != _state_rs->get_attrib(clip_plane_slot) || !_state_mask.get_bit(clip_plane_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_clip_plane_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_clip_plane_pcollector); do_issue_clip_plane(); _state_mask.set_bit(clip_plane_slot); } @@ -9921,7 +9562,7 @@ set_state_and_transform(const RenderState *target, _target_rs->get_attrib(color_scale_slot) != _state_rs->get_attrib(color_scale_slot) || !_state_mask.get_bit(color_slot) || !_state_mask.get_bit(color_scale_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_color_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_color_pcollector); do_issue_color(); do_issue_color_scale(); _state_mask.set_bit(color_slot); @@ -9931,7 +9572,7 @@ set_state_and_transform(const RenderState *target, int cull_face_slot = CullFaceAttrib::get_class_slot(); if (_target_rs->get_attrib(cull_face_slot) != _state_rs->get_attrib(cull_face_slot) || !_state_mask.get_bit(cull_face_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_cull_face_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_cull_face_pcollector); do_issue_cull_face(); _state_mask.set_bit(cull_face_slot); } @@ -9939,7 +9580,7 @@ set_state_and_transform(const RenderState *target, int depth_offset_slot = DepthOffsetAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_offset_slot) != _state_rs->get_attrib(depth_offset_slot) || !_state_mask.get_bit(depth_offset_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_depth_offset_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_depth_offset_pcollector); do_issue_depth_offset(); _state_mask.set_bit(depth_offset_slot); } @@ -9947,7 +9588,7 @@ set_state_and_transform(const RenderState *target, int depth_test_slot = DepthTestAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_test_slot) != _state_rs->get_attrib(depth_test_slot) || !_state_mask.get_bit(depth_test_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_depth_test_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_depth_test_pcollector); do_issue_depth_test(); _state_mask.set_bit(depth_test_slot); } @@ -9955,7 +9596,7 @@ set_state_and_transform(const RenderState *target, int depth_write_slot = DepthWriteAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_write_slot) != _state_rs->get_attrib(depth_write_slot) || !_state_mask.get_bit(depth_write_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_depth_write_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_depth_write_pcollector); do_issue_depth_write(); _state_mask.set_bit(depth_write_slot); } @@ -9963,7 +9604,7 @@ set_state_and_transform(const RenderState *target, int render_mode_slot = RenderModeAttrib::get_class_slot(); if (_target_rs->get_attrib(render_mode_slot) != _state_rs->get_attrib(render_mode_slot) || !_state_mask.get_bit(render_mode_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_render_mode_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_render_mode_pcollector); do_issue_render_mode(); _state_mask.set_bit(render_mode_slot); } @@ -9972,7 +9613,7 @@ set_state_and_transform(const RenderState *target, int rescale_normal_slot = RescaleNormalAttrib::get_class_slot(); if (_target_rs->get_attrib(rescale_normal_slot) != _state_rs->get_attrib(rescale_normal_slot) || !_state_mask.get_bit(rescale_normal_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_rescale_normal_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_rescale_normal_pcollector); do_issue_rescale_normal(); _state_mask.set_bit(rescale_normal_slot); } @@ -9982,7 +9623,7 @@ set_state_and_transform(const RenderState *target, int shade_model_slot = ShadeModelAttrib::get_class_slot(); if (_target_rs->get_attrib(shade_model_slot) != _state_rs->get_attrib(shade_model_slot) || !_state_mask.get_bit(shade_model_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_shade_model_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_shade_model_pcollector); do_issue_shade_model(); _state_mask.set_bit(shade_model_slot); } @@ -10002,7 +9643,7 @@ set_state_and_transform(const RenderState *target, _state_shader->get_flag(ShaderAttrib::F_disable_alpha_write)) #endif ) { - //PStatGPUTimer timer(this, _draw_set_state_blending_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_blending_pcollector); do_issue_blending(); _state_mask.set_bit(transparency_slot); _state_mask.set_bit(color_write_slot); @@ -10012,14 +9653,14 @@ set_state_and_transform(const RenderState *target, int texture_slot = TextureAttrib::get_class_slot(); if (_target_rs->get_attrib(texture_slot) != _state_rs->get_attrib(texture_slot) || !_state_mask.get_bit(texture_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_texture_pcollector); determine_target_texture(); int prev_active = _num_active_texture_stages; do_issue_texture(); - // Since the TexGen and TexMatrix states depend partly on the - // particular set of textures in use, we should force both of - // those to be reissued every time we change the texture state. + // Since the TexGen and TexMatrix states depend partly on the particular + // set of textures in use, we should force both of those to be reissued + // every time we change the texture state. _state_mask.clear_bit(TexGenAttrib::get_class_slot()); _state_mask.clear_bit(TexMatrixAttrib::get_class_slot()); @@ -10027,9 +9668,8 @@ set_state_and_transform(const RenderState *target, _state_mask.set_bit(texture_slot); } - // If one of the previously-loaded TexGen modes modified the texture - // matrix, then if either state changed, we have to change both of - // them now. + // If one of the previously-loaded TexGen modes modified the texture matrix, + // then if either state changed, we have to change both of them now. if (_tex_gen_modifies_mat) { int tex_gen_slot = TexGenAttrib::get_class_slot(); int tex_matrix_slot = TexMatrixAttrib::get_class_slot(); @@ -10045,7 +9685,7 @@ set_state_and_transform(const RenderState *target, int tex_matrix_slot = TexMatrixAttrib::get_class_slot(); if (_target_rs->get_attrib(tex_matrix_slot) != _state_rs->get_attrib(tex_matrix_slot) || !_state_mask.get_bit(tex_matrix_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_tex_matrix_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_tex_matrix_pcollector); #ifdef SUPPORT_FIXED_FUNCTION do_issue_tex_matrix(); #endif @@ -10061,7 +9701,7 @@ set_state_and_transform(const RenderState *target, int tex_gen_slot = TexGenAttrib::get_class_slot(); if (_target_tex_gen != _state_tex_gen || !_state_mask.get_bit(tex_gen_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_tex_gen_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_tex_gen_pcollector); do_issue_tex_gen(); _state_tex_gen = _target_tex_gen; _state_mask.set_bit(tex_gen_slot); @@ -10071,7 +9711,7 @@ set_state_and_transform(const RenderState *target, int material_slot = MaterialAttrib::get_class_slot(); if (_target_rs->get_attrib(material_slot) != _state_rs->get_attrib(material_slot) || !_state_mask.get_bit(material_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_material_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_material_pcollector); #ifdef SUPPORT_FIXED_FUNCTION do_issue_material(); #endif @@ -10081,7 +9721,7 @@ set_state_and_transform(const RenderState *target, int light_slot = LightAttrib::get_class_slot(); if (_target_rs->get_attrib(light_slot) != _state_rs->get_attrib(light_slot) || !_state_mask.get_bit(light_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_light_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_light_pcollector); #ifdef SUPPORT_FIXED_FUNCTION do_issue_light(); #endif @@ -10091,7 +9731,7 @@ set_state_and_transform(const RenderState *target, int stencil_slot = StencilAttrib::get_class_slot(); if (_target_rs->get_attrib(stencil_slot) != _state_rs->get_attrib(stencil_slot) || !_state_mask.get_bit(stencil_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_stencil_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_stencil_pcollector); do_issue_stencil(); _state_mask.set_bit(stencil_slot); } @@ -10099,7 +9739,7 @@ set_state_and_transform(const RenderState *target, int fog_slot = FogAttrib::get_class_slot(); if (_target_rs->get_attrib(fog_slot) != _state_rs->get_attrib(fog_slot) || !_state_mask.get_bit(fog_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_fog_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_fog_pcollector); #ifdef SUPPORT_FIXED_FUNCTION do_issue_fog(); #endif @@ -10109,7 +9749,7 @@ set_state_and_transform(const RenderState *target, int scissor_slot = ScissorAttrib::get_class_slot(); if (_target_rs->get_attrib(scissor_slot) != _state_rs->get_attrib(scissor_slot) || !_state_mask.get_bit(scissor_slot)) { - //PStatGPUTimer timer(this, _draw_set_state_scissor_pcollector); + // PStatGPUTimer timer(this, _draw_set_state_scissor_pcollector); do_issue_scissor(); _state_mask.set_bit(scissor_slot); } @@ -10119,12 +9759,9 @@ set_state_and_transform(const RenderState *target, report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::free_pointers -// Access: Protected, Virtual -// Description: Frees some memory that was explicitly allocated -// within the glgsg. -//////////////////////////////////////////////////////////////////// +/** + * Frees some memory that was explicitly allocated within the glgsg. + */ void CLP(GraphicsStateGuardian):: free_pointers() { #if defined(HAVE_CG) && !defined(OPENGLES) @@ -10135,12 +9772,10 @@ free_pointers() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_texture -// Access: Protected, Virtual -// Description: This is called by set_state_and_transform() when -// the texture state has changed. -//////////////////////////////////////////////////////////////////// +/** + * This is called by set_state_and_transform() when the texture state has + * changed. + */ void CLP(GraphicsStateGuardian):: do_issue_texture() { DO_PSTATS_STUFF(_texture_state_pcollector.add_level(1)); @@ -10174,13 +9809,10 @@ do_issue_texture() { } #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_standard_texture_bindings -// Access: Private -// Description: Applies the appropriate set of textures for the -// current state, using the standard fixed-function -// pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Applies the appropriate set of textures for the current state, using the + * standard fixed-function pipeline. + */ void CLP(GraphicsStateGuardian):: update_standard_texture_bindings() { #ifndef NDEBUG @@ -10193,10 +9825,10 @@ update_standard_texture_bindings() { int num_stages = _target_texture->get_num_on_ff_stages(); #ifndef NDEBUG - // Also check the _flash_texture. If it is non-NULL, we need to - // check to see if our flash_texture is in the texture stack here. - // If so, then we need to call the special show_texture method - // instead of the normal texture stack. + // Also check the _flash_texture. If it is non-NULL, we need to check to + // see if our flash_texture is in the texture stack here. If so, then we + // need to call the special show_texture method instead of the normal + // texture stack. if (_flash_texture != (Texture *)NULL) { double now = ClockObject::get_global_clock()->get_frame_time(); int this_second = (int)floor(now); @@ -10291,9 +9923,9 @@ update_standard_texture_bindings() { if (stage->get_mode() == TextureStage::M_decal) { if (texture->get_num_components() < 3 && _supports_texture_combine) { - // Make a special case for 1- and 2-channel decal textures. - // OpenGL does not define their use with GL_DECAL for some - // reason, so implement them using the combiner instead. + // Make a special case for 1- and 2-channel decal textures. OpenGL + // does not define their use with GL_DECAL for some reason, so + // implement them using the combiner instead. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE, 1); @@ -10389,12 +10021,11 @@ update_standard_texture_bindings() { } if (stage->get_saved_result()) { - // This texture's result will be "saved" for a future stage's - // input. + // This texture's result will be "saved" for a future stage's input. last_saved_result = i; } else { - // This is a regular texture stage; it will be the "previous" - // input for the next stage. + // This is a regular texture stage; it will be the "previous" input for + // the next stage. last_stage = i; } } @@ -10421,12 +10052,10 @@ update_standard_texture_bindings() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::apply_white_texture -// Access: Private -// Description: Applies a white dummy texture. This is useful to -// bind to a texture slot when a texture is missing. -//////////////////////////////////////////////////////////////////// +/** + * Applies a white dummy texture. This is useful to bind to a texture slot + * when a texture is missing. + */ void CLP(GraphicsStateGuardian):: apply_white_texture() { if (_white_texture != 0) { @@ -10446,12 +10075,10 @@ apply_white_texture() { GL_RGBA, GL_UNSIGNED_BYTE, data); } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_white_texture -// Access: Private -// Description: Returns a white dummy texture. This is useful to -// bind to a texture slot when a texture is missing. -//////////////////////////////////////////////////////////////////// +/** + * Returns a white dummy texture. This is useful to bind to a texture slot + * when a texture is missing. + */ GLuint CLP(GraphicsStateGuardian):: get_white_texture() { if (_white_texture == 0) { @@ -10461,18 +10088,14 @@ get_white_texture() { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::update_show_usage_texture_bindings -// Access: Private -// Description: This is a special function that loads the usage -// textures in gl-show-texture-usage mode, instead of -// loading the actual used textures. -// -// If the indicated stage_index is >= 0, then it is the -// particular texture that is shown. Otherwise, the -// textures are rotated through based on -// show_texture_usage_index. -//////////////////////////////////////////////////////////////////// +/** + * This is a special function that loads the usage textures in gl-show- + * texture-usage mode, instead of loading the actual used textures. + * + * If the indicated stage_index is >= 0, then it is the particular texture + * that is shown. Otherwise, the textures are rotated through based on + * show_texture_usage_index. + */ void CLP(GraphicsStateGuardian):: update_show_usage_texture_bindings(int show_stage_index) { int num_stages = _target_texture->get_num_on_ff_stages(); @@ -10482,10 +10105,9 @@ update_show_usage_texture_bindings(int show_stage_index) { _texture_involves_color_scale = false; - // First, we walk through the list of textures and pretend to render - // them all, even though we don't actually render them, just so - // Panda will keep track of the list of "active" textures correctly - // during the flash. + // First, we walk through the list of textures and pretend to render them + // all, even though we don't actually render them, just so Panda will keep + // track of the list of "active" textures correctly during the flash. int i; for (i = 0; i < num_stages; i++) { TextureStage *stage = _target_texture->get_on_ff_stage(i); @@ -10548,8 +10170,8 @@ update_show_usage_texture_bindings(int show_stage_index) { // Need to create a new texture for this size. glGenTextures(1, &index); glBindTexture(GL_TEXTURE_2D, index); - //TODO: this could be a lot simpler with glTexStorage2D - // followed by a call to glClearTexImage. + // TODO: this could be a lot simpler with glTexStorage2D followed by a + // call to glClearTexImage. upload_usage_texture(texture->get_x_size(), texture->get_y_size()); _usage_textures[key] = index; @@ -10564,7 +10186,7 @@ update_show_usage_texture_bindings(int show_stage_index) { << "glBindTexture(GL_TEXTURE_2D, " << index << ")\n"; } - //TODO: glBindSampler(0) ? + // TODO: glBindSampler(0) ? } report_my_gl_errors(); @@ -10572,13 +10194,10 @@ update_show_usage_texture_bindings(int show_stage_index) { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::upload_usage_texture -// Access: Protected -// Description: Uploads a special "usage" texture intended to be -// applied only in gl-show-texture-usage mode, to reveal -// where texture memory is being spent. -//////////////////////////////////////////////////////////////////// +/** + * Uploads a special "usage" texture intended to be applied only in gl-show- + * texture-usage mode, to reveal where texture memory is being spent. + */ void CLP(GraphicsStateGuardian):: upload_usage_texture(int width, int height) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -10598,8 +10217,7 @@ upload_usage_texture(int width, int height) { }; - // Allocate a temporary array large enough to contain the toplevel - // mipmap. + // Allocate a temporary array large enough to contain the toplevel mipmap. PN_uint32 *buffer = (PN_uint32 *)PANDA_MALLOC_ARRAY(width * height * 4); int n = 0; @@ -10607,8 +10225,8 @@ upload_usage_texture(int width, int height) { // Choose the color for the nth mipmap. LColor c = colors[min(n, 2)]; - // A simple union to store the colors values bytewise, and get the - // answer wordwise, independently of machine byte-ordernig. + // A simple union to store the colors values bytewise, and get the answer + // wordwise, independently of machine byte-ordernig. union { struct { unsigned char r, g, b, a; @@ -10644,11 +10262,9 @@ upload_usage_texture(int width, int height) { #endif // NDEBUG #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::disable_standard_texture_bindings -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: disable_standard_texture_bindings() { // Disable the texture stages that are no longer used. @@ -10675,11 +10291,9 @@ disable_standard_texture_bindings() { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_tex_matrix -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_tex_matrix() { nassertv(_num_active_texture_stages <= _max_texture_stages); @@ -10698,12 +10312,11 @@ do_issue_tex_matrix() { } else { glLoadIdentity(); - // For some reason, the glLoadIdentity() call doesn't work on - // my Dell laptop's IBM OpenGL driver, when used in - // conjunction with glTexGen(), below. But explicitly loading - // an identity matrix does work. But this buggy-driver - // workaround might have other performance implications, so I - // leave it out. + // For some reason, the glLoadIdentity() call doesn't work on my Dell + // laptop's IBM OpenGL driver, when used in conjunction with glTexGen(), + // below. But explicitly loading an identity matrix does work. But + // this buggy-driver workaround might have other performance + // implications, so I leave it out. // call_glLoadMatrix(LMatrix4::ident_mat()); } } @@ -10712,22 +10325,19 @@ do_issue_tex_matrix() { #endif // SUPPORT_FIXED_FUNCTION #ifdef SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_tex_gen -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_tex_gen() { bool force_normal = false; nassertv(_num_active_texture_stages <= _max_texture_stages); - // These are passed in for the four OBJECT_PLANE or EYE_PLANE - // values; they effectively define an identity matrix that maps - // the spatial coordinates one-for-one to UV's. If you want a - // mapping other than identity, use a TexMatrixAttrib (or a - // TexProjectorEffect). + // These are passed in for the four OBJECT_PLANE or EYE_PLANE values; they + // effectively define an identity matrix that maps the spatial coordinates + // one-for-one to UV's. If you want a mapping other than identity, use a + // TexMatrixAttrib (or a TexProjectorEffect). static const PN_stdfloat s_data[4] = { 1, 0, 0, 0 }; static const PN_stdfloat t_data[4] = { 0, 1, 0, 0 }; static const PN_stdfloat r_data[4] = { 0, 0, 1, 0 }; @@ -10770,16 +10380,16 @@ do_issue_tex_gen() { case TexGenAttrib::M_eye_cube_map: if (_supports_cube_map) { - // We need to rotate the normals out of GL's coordinate - // system and into the user's coordinate system. We do this - // by composing a transform onto the texture matrix. + // We need to rotate the normals out of GL's coordinate system and + // into the user's coordinate system. We do this by composing a + // transform onto the texture matrix. LMatrix4 mat = _inv_cs_transform->get_mat(); mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); glMatrixMode(GL_TEXTURE); GLPf(MultMatrix)(mat.get_data()); - // Now we need to reset the texture matrix next time - // around to undo this. + // Now we need to reset the texture matrix next time around to undo + // this. _tex_gen_modifies_mat = true; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); @@ -10794,12 +10404,11 @@ do_issue_tex_gen() { case TexGenAttrib::M_world_cube_map: if (_supports_cube_map) { - // We dynamically transform normals from eye space to world - // space by applying the appropriate rotation transform to - // the current texture matrix. Unlike M_world_position, we - // can't achieve this effect by monkeying with the modelview - // transform, since the current modelview doesn't affect - // GL_REFLECTION_MAP. + // We dynamically transform normals from eye space to world space by + // applying the appropriate rotation transform to the current texture + // matrix. Unlike M_world_position, we can't achieve this effect by + // monkeying with the modelview transform, since the current modelview + // doesn't affect GL_REFLECTION_MAP. CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); LMatrix4 mat = camera_transform->get_mat(); @@ -10807,8 +10416,8 @@ do_issue_tex_gen() { glMatrixMode(GL_TEXTURE); GLPf(MultMatrix)(mat.get_data()); - // Now we need to reset the texture matrix next time - // around to undo this. + // Now we need to reset the texture matrix next time around to undo + // this. _tex_gen_modifies_mat = true; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP); @@ -10823,16 +10432,16 @@ do_issue_tex_gen() { case TexGenAttrib::M_eye_normal: if (_supports_cube_map) { - // We need to rotate the normals out of GL's coordinate - // system and into the user's coordinate system. We do this - // by composing a transform onto the texture matrix. + // We need to rotate the normals out of GL's coordinate system and + // into the user's coordinate system. We do this by composing a + // transform onto the texture matrix. LMatrix4 mat = _inv_cs_transform->get_mat(); mat.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); glMatrixMode(GL_TEXTURE); GLPf(MultMatrix)(mat.get_data()); - // Now we need to reset the texture matrix next time - // around to undo this. + // Now we need to reset the texture matrix next time around to undo + // this. _tex_gen_modifies_mat = true; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP); @@ -10847,12 +10456,11 @@ do_issue_tex_gen() { case TexGenAttrib::M_world_normal: if (_supports_cube_map) { - // We dynamically transform normals from eye space to world - // space by applying the appropriate rotation transform to - // the current texture matrix. Unlike M_world_position, we - // can't achieve this effect by monkeying with the modelview - // transform, since the current modelview doesn't affect - // GL_NORMAL_MAP. + // We dynamically transform normals from eye space to world space by + // applying the appropriate rotation transform to the current texture + // matrix. Unlike M_world_position, we can't achieve this effect by + // monkeying with the modelview transform, since the current modelview + // doesn't affect GL_NORMAL_MAP. CPT(TransformState) camera_transform = _scene_setup->get_camera_transform()->compose(_inv_cs_transform); LMatrix4 mat = camera_transform->get_mat(); @@ -10860,8 +10468,8 @@ do_issue_tex_gen() { glMatrixMode(GL_TEXTURE); GLPf(MultMatrix)(mat.get_data()); - // Now we need to reset the texture matrix next time - // around to undo this. + // Now we need to reset the texture matrix next time around to undo + // this. _tex_gen_modifies_mat = true; glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP); @@ -10875,8 +10483,8 @@ do_issue_tex_gen() { break; case TexGenAttrib::M_eye_position: - // To represent eye position correctly, we need to temporarily - // load the coordinate-system transform. + // To represent eye position correctly, we need to temporarily load the + // coordinate-system transform. glMatrixMode(GL_MODELVIEW); glPushMatrix(); call_glLoadMatrix(_cs_transform->get_mat()); @@ -10901,9 +10509,9 @@ do_issue_tex_gen() { break; case TexGenAttrib::M_world_position: - // We achieve world position coordinates by using the eye - // position mode, and loading the transform of the root - // node--thus putting the "eye" at the root. + // We achieve world position coordinates by using the eye position mode, + // and loading the transform of the root node--thus putting the "eye" at + // the root. { glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -10941,10 +10549,9 @@ do_issue_tex_gen() { break; case TexGenAttrib::M_constant: - // To generate a constant UV(w) coordinate everywhere, we use - // EYE_LINEAR mode, but we construct a special matrix that - // flattens the vertex position to zero and then adds our - // desired value. + // To generate a constant UV(w) coordinate everywhere, we use EYE_LINEAR + // mode, but we construct a special matrix that flattens the vertex + // position to zero and then adds our desired value. { const LTexCoord3 &v = _target_tex_gen->get_constant_value(stage); @@ -10996,13 +10603,11 @@ do_issue_tex_gen() { } #endif // SUPPORT_FIXED_FUNCTION -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::specify_texture -// Access: Protected -// Description: Specifies the texture parameters. Returns true if -// the texture may need to be reloaded. Pass non-NULL -// sampler argument to use different sampler settings. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the texture parameters. Returns true if the texture may need to + * be reloaded. Pass non-NULL sampler argument to use different sampler + * settings. + */ bool CLP(GraphicsStateGuardian):: specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { nassertr(gtc->_handle == 0 /* can't modify tex with active handle */, false); @@ -11011,7 +10616,7 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { GLenum target = get_texture_target(tex->get_texture_type()); if (target == GL_NONE) { - // Unsupported target (e.g. 3-d texturing on GL 1.1). + // Unsupported target (e.g. 3-d texturing on GL 1.1). return false; } #ifndef OPENGLES @@ -11061,12 +10666,12 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { #endif if (!tex->might_have_ram_image()) { - // If it's a dynamically generated texture (that is, the RAM image - // isn't available so it didn't pass through the CPU), we should - // enable GL-generated mipmaps if we can. + // If it's a dynamically generated texture (that is, the RAM image isn't + // available so it didn't pass through the CPU), we should enable GL- + // generated mipmaps if we can. if (!_supports_generate_mipmap) { - // However, if the GPU doesn't support mipmap generation, we - // have to turn it off. + // However, if the GPU doesn't support mipmap generation, we have to + // turn it off. uses_mipmaps = false; } } @@ -11128,13 +10733,10 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::apply_texture -// Access: Protected -// Description: Updates OpenGL with the current information for this -// texture, and makes it the current texture available -// for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Updates OpenGL with the current information for this texture, and makes it + * the current texture available for rendering. + */ bool CLP(GraphicsStateGuardian):: apply_texture(CLP(TextureContext) *gtc) { gtc->set_active(true); @@ -11144,8 +10746,8 @@ apply_texture(CLP(TextureContext) *gtc) { } if (gtc->_target != target) { - // The target has changed. That means we have to re-bind a new - // texture object. + // The target has changed. That means we have to re-bind a new texture + // object. gtc->reset_data(); gtc->_target = target; } @@ -11160,23 +10762,20 @@ apply_texture(CLP(TextureContext) *gtc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::apply_sampler -// Access: Protected -// Description: Updates OpenGL with the current information for this -// sampler, and makes it the current sampler available -// for rendering. Use NULL to unbind the sampler. -// -// If the GSG doesn't support sampler objects, the -// sampler settings are applied to the given texture -// context instead. -//////////////////////////////////////////////////////////////////// +/** + * Updates OpenGL with the current information for this sampler, and makes it + * the current sampler available for rendering. Use NULL to unbind the + * sampler. + * + * If the GSG doesn't support sampler objects, the sampler settings are + * applied to the given texture context instead. + */ bool CLP(GraphicsStateGuardian):: apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc) { #ifndef OPENGLES if (_supports_sampler_objects) { - // We support sampler objects. Prepare the sampler object and - // bind it to the indicated texture unit. + // We support sampler objects. Prepare the sampler object and bind it to + // the indicated texture unit. SamplerContext *sc = sampler.prepare_now(get_prepared_objects(), this); nassertr(sc != (SamplerContext *)NULL, false); CLP(SamplerContext) *gsc = DCAST(CLP(SamplerContext), sc); @@ -11193,8 +10792,8 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc } else #endif // OPENGLES { - // We don't support sampler objects. We'll have to bind the - // texture and change the texture parameters if they don't match. + // We don't support sampler objects. We'll have to bind the texture and + // change the texture parameters if they don't match. if (gtc->_active_sampler != sampler) { set_active_texture_stage(unit); apply_texture(gtc); @@ -11203,8 +10802,8 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc } if (sampler.uses_mipmaps() && !gtc->_uses_mipmaps && !gl_ignore_mipmaps) { - // The texture wasn't created with mipmaps, but we are trying - // to sample it with mipmaps. We will need to reload it. + // The texture wasn't created with mipmaps, but we are trying to sample it + // with mipmaps. We will need to reload it. GLCAT.info() << "reloading texture " << gtc->get_texture()->get_name() << " with mipmaps\n"; @@ -11223,15 +10822,12 @@ apply_sampler(GLuint unit, const SamplerState &sampler, CLP(TextureContext) *gtc return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::upload_texture -// Access: Protected -// Description: Uploads the entire texture image to OpenGL, including -// all pages. -// -// The return value is true if successful, or false if -// the texture has no image. -//////////////////////////////////////////////////////////////////// +/** + * Uploads the entire texture image to OpenGL, including all pages. + * + * The return value is true if successful, or false if the texture has no + * image. + */ bool CLP(GraphicsStateGuardian):: upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { PStatGPUTimer timer(this, _load_texture_pcollector); @@ -11243,8 +10839,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { if (!has_image && tex->might_have_ram_image() && tex->has_simple_ram_image() && !_loader.is_null()) { - // If we don't have the texture data right now, go get it, but in - // the meantime load a temporary simple image in its place. + // If we don't have the texture data right now, go get it, but in the + // meantime load a temporary simple image in its place. async_reload_texture(gtc); has_image = _supports_compressed_texture ? tex->has_ram_image() : tex->has_uncompressed_ram_image(); if (!has_image) { @@ -11274,8 +10870,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { image = tex->get_uncompressed_ram_image(); image_compression = Texture::CM_off; - // If this triggers, Panda cannot decompress the texture. Compile - // with libsquish support or precompress the texture. + // If this triggers, Panda cannot decompress the texture. Compile with + // libsquish support or precompress the texture. nassertr(!image.is_null(), false); } @@ -11285,8 +10881,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { int height = tex->get_y_size(); int depth = tex->get_z_size(); - // If we'll use immutable texture storage, we have to pick a sized - // image format. + // If we'll use immutable texture storage, we have to pick a sized image + // format. bool force_sized = (gl_immutable_texture_storage && _supports_tex_storage) || (tex->get_texture_type() == Texture::TT_buffer_texture); @@ -11311,8 +10907,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { GLCAT.debug(false) << " " << tex->get_name() << "\n"; } - // Ensure that the texture fits within the GL's specified limits. - // Need to split dimensions because of texture arrays + // Ensure that the texture fits within the GL's specified limits. Need to + // split dimensions because of texture arrays int max_dimension_x; int max_dimension_y; int max_dimension_z; @@ -11355,18 +10951,18 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } if (max_dimension_x == 0 || max_dimension_y == 0 || max_dimension_z == 0) { - // Guess this GL doesn't support cube mapping/3d textures/2d texture arrays. + // Guess this GL doesn't support cube mapping3d textures2d texture arrays. report_my_gl_errors(); return false; } - // If it doesn't fit, we have to reduce it on-the-fly. We do this - // by incrementing the mipmap_bias, so we're effectively loading a - // lower mipmap level. This requires generating the mipmaps on - // the CPU if they haven't already been generated. It would have - // been better if the user had specified max-texture-dimension to - // reduce the texture at load time instead; of course, the user - // doesn't always know ahead of time what the hardware limits are. + // If it doesn't fit, we have to reduce it on-the-fly. We do this by + // incrementing the mipmap_bias, so we're effectively loading a lower mipmap + // level. This requires generating the mipmaps on the CPU if they haven't + // already been generated. It would have been better if the user had + // specified max-texture-dimension to reduce the texture at load time + // instead; of course, the user doesn't always know ahead of time what the + // hardware limits are. if ((max_dimension_x > 0 && max_dimension_y > 0 && max_dimension_z > 0) && image_compression == Texture::CM_off) { @@ -11381,8 +10977,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { if (tex->has_ram_image()) { tex->generate_ram_mipmap_images(); if (mipmap_bias >= tex->get_num_ram_mipmap_images()) { - // It didn't work. Send the smallest we've got, and hope - // for the best. + // It didn't work. Send the smallest we've got, and hope for the + // best. mipmap_bias = tex->get_num_ram_mipmap_images() - 1; } } @@ -11481,8 +11077,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } else #endif // !OPENGLES if (needs_reload) { - // Figure out whether mipmaps will be generated by the GPU or by - // Panda (or not at all), and how many mipmap levels should be created. + // Figure out whether mipmaps will be generated by the GPU or by Panda (or + // not at all), and how many mipmap levels should be created. gtc->_generate_mipmaps = false; int num_levels = 1; CPTA_uchar image = tex->get_ram_mipmap_image(mipmap_bias); @@ -11509,18 +11105,17 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { // No RAM mipmap levels available. Should we generate some? if (!_supports_generate_mipmap || !driver_generate_mipmaps || image_compression != Texture::CM_off) { - // Yes, the GL can't or won't generate them, so we need to. - // Note that some drivers (nVidia) will *corrupt memory* if - // you ask them to generate mipmaps for a pre-compressed - // texture. + // Yes, the GL can't or won't generate them, so we need to. Note + // that some drivers (nVidia) will *corrupt memory* if you ask + // them to generate mipmaps for a pre-compressed texture. tex->generate_ram_mipmap_images(); num_levels = tex->get_num_ram_mipmap_images() - mipmap_bias; } } if (num_levels <= 1) { - // We don't have mipmap levels in RAM. Ask the GL to generate - // them if it can. + // We don't have mipmap levels in RAM. Ask the GL to generate them + // if it can. if (_supports_generate_mipmap) { num_levels = tex->get_expected_num_mipmap_levels() - mipmap_bias; gtc->_generate_mipmaps = true; @@ -11535,9 +11130,9 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { #ifndef OPENGLES // OpenGL ES doesn't have GL_TEXTURE_MAX_LEVEL. if (is_at_least_gl_version(1, 2)) { - // By the time we get here, we have a pretty good prediction for - // the number of mipmaps we're going to have, so tell the GL that's - // all it's going to get. + // By the time we get here, we have a pretty good prediction for the + // number of mipmaps we're going to have, so tell the GL that's all it's + // going to get. glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, num_levels - 1); } #endif @@ -11550,8 +11145,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { #endif #if !defined(SUPPORT_FIXED_FUNCTION) && !defined(OPENGLES) - // Do we need to apply a swizzle mask to emulate these deprecated - // texture formats? + // Do we need to apply a swizzle mask to emulate these deprecated texture + // formats? switch (tex->get_format()) { case Texture::F_alpha: glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, GL_ZERO); @@ -11579,10 +11174,11 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { } #endif - // Allocate immutable storage for the texture, after which we can subload it. - // Pre-allocating storage using glTexStorage is more efficient than using glTexImage - // to load all of the individual images one by one later, but we are not allowed to - // change the texture size or number of mipmap levels after this point. + // Allocate immutable storage for the texture, after which we can subload + // it. Pre-allocating storage using glTexStorage is more efficient than + // using glTexImage to load all of the individual images one by one later, + // but we are not allowed to change the texture size or number of mipmap + // levels after this point. if (gl_immutable_texture_storage && _supports_tex_storage && !gtc->_has_storage) { if (GLCAT.is_debug()) { GLCAT.debug() @@ -11626,10 +11222,9 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { // No RAM mipmap levels available. Should we generate some? if (!_supports_generate_mipmap || !driver_generate_mipmaps || image_compression != Texture::CM_off) { - // Yes, the GL can't or won't generate them, so we need to. - // Note that some drivers (nVidia) will *corrupt memory* if - // you ask them to generate mipmaps for a pre-compressed - // texture. + // Yes, the GL can't or won't generate them, so we need to. Note + // that some drivers (nVidia) will *corrupt memory* if you ask them + // to generate mipmaps for a pre-compressed texture. tex->generate_ram_mipmap_images(); } } @@ -11638,8 +11233,8 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { bool success = true; if (tex->get_texture_type() == Texture::TT_cube_map) { - // A cube map must load six different 2-d images (which are stored - // as the six pages of the system ram image). + // A cube map must load six different 2-d images (which are stored as the + // six pages of the system ram image). if (!_supports_cube_map) { report_my_gl_errors(); return false; @@ -11746,22 +11341,17 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::upload_texture_image -// Access: Protected -// Description: Loads a texture image, or one page of a cube map -// image, from system RAM to texture memory. -// -// texture_target is normally the same thing as -// page_target; both represent the GL target onto which -// the texture image is loaded, e.g. GL_TEXTURE_1D, -// GL_TEXTURE_2D, etc. The only time they may differ is -// in the case of cube mapping, in which case -// texture_target will be target for the overall -// texture, e.g. GL_TEXTURE_CUBE_MAP, and page_target -// will be the target for this particular page, -// e.g. GL_TEXTURE_CUBE_MAP_POSITIVE_X. -//////////////////////////////////////////////////////////////////// +/** + * Loads a texture image, or one page of a cube map image, from system RAM to + * texture memory. + * + * texture_target is normally the same thing as page_target; both represent + * the GL target onto which the texture image is loaded, e.g. GL_TEXTURE_1D, + * GL_TEXTURE_2D, etc. The only time they may differ is in the case of cube + * mapping, in which case texture_target will be target for the overall + * texture, e.g. GL_TEXTURE_CUBE_MAP, and page_target will be the target for + * this particular page, e.g. GL_TEXTURE_CUBE_MAP_POSITIVE_X. + */ bool CLP(GraphicsStateGuardian):: upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, bool uses_mipmaps, int mipmap_bias, @@ -11774,7 +11364,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, clear_my_gl_errors(); if (texture_target == GL_NONE) { - // Unsupported target (e.g. 3-d texturing on GL 1.1). + // Unsupported target (e.g. 3-d texturing on GL 1.1). return false; } if (image_compression != Texture::CM_off && !_supports_compressed_texture) { @@ -11814,8 +11404,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, #endif if (!needs_reload) { - // Try to subload the image over the existing GL Texture object, - // possibly saving on texture memory fragmentation. + // Try to subload the image over the existing GL Texture object, possibly + // saving on texture memory fragmentation. if (GLCAT.is_debug()) { if (num_ram_mipmap_levels == 0) { @@ -11841,16 +11431,16 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } for (int n = mipmap_bias; n < num_levels; ++n) { - // we grab the mipmap pointer first, if it is NULL we grab the - // normal mipmap image pointer which is a PTA_uchar + // we grab the mipmap pointer first, if it is NULL we grab the normal + // mipmap image pointer which is a PTA_uchar const unsigned char *image_ptr = (unsigned char*)tex->get_ram_mipmap_pointer(n); CPTA_uchar ptimage; if (image_ptr == (const unsigned char *)NULL) { ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { - // We were told we'd have this many RAM mipmap images, but - // we don't. Raise a warning. + // We were told we'd have this many RAM mipmap images, but we + // don't. Raise a warning. GLCAT.warning() << "No mipmap level " << n << " defined for " << tex->get_name() << "\n"; @@ -11863,7 +11453,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, #ifndef OPENGLES if (texture_target != GL_TEXTURE_BUFFER) { if (_supports_clear_texture) { - // We can do that with the convenient glClearTexImage function. + // We can do that with the convenient glClearTexImage + // function. string clear_data = tex->get_clear_data(); _glClearTexImage(gtc->_index, n - mipmap_bias, external_format, @@ -11872,7 +11463,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } } else { if (_supports_clear_buffer) { - // For buffer textures we need to clear the underlying storage. + // For buffer textures we need to clear the underlying + // storage. string clear_data = tex->get_clear_data(); _glClearBufferData(GL_TEXTURE_BUFFER, internal_format, external_format, @@ -11881,9 +11473,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } } #endif // OPENGLES - // Ask the Texture class to create the mipmap level in RAM. - // It'll fill it in with the correct clear color, which we - // can then upload. + // Ask the Texture class to create the mipmap level in RAM. It'll + // fill it in with the correct clear color, which we can then + // upload. ptimage = tex->make_ram_mipmap_image(n); } else { @@ -11982,8 +11574,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, default: if (image_compression == Texture::CM_off) { if (n==0) { - // It's unfortunate that we can't adjust the width, too, - // but TexSubImage2D doesn't accept a row-stride parameter. + // It's unfortunate that we can't adjust the width, too, but + // TexSubImage2D doesn't accept a row-stride parameter. height = tex->get_y_size() - tex->get_pad_y_size(); } glTexSubImage2D(page_target, n - mipmap_bias, 0, 0, width, height, @@ -11996,8 +11588,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } } - // Did that fail? If it did, we'll immediately try again, this - // time loading the texture from scratch. + // Did that fail? If it did, we'll immediately try again, this time + // loading the texture from scratch. GLenum error_code = gl_get_error(); if (error_code != GL_NO_ERROR) { if (GLCAT.is_debug()) { @@ -12010,8 +11602,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } if (needs_reload) { - // Load the image up from scratch, creating a new GL Texture - // object. + // Load the image up from scratch, creating a new GL Texture object. if (GLCAT.is_debug()) { GLCAT.debug() << "loading new texture object for " << tex->get_name() << ", " << width @@ -12045,8 +11636,8 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, ptimage = tex->get_ram_mipmap_image(n); if (ptimage.is_null()) { if (n < num_ram_mipmap_levels) { - // We were told we'd have this many RAM mipmap images, but - // we don't. Raise a warning. + // We were told we'd have this many RAM mipmap images, but we + // don't. Raise a warning. GLCAT.warning() << "No mipmap level " << n << " defined for " << tex->get_name() << "\n"; @@ -12060,9 +11651,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } if (tex->has_clear_color()) { - // Ask the Texture class to create the mipmap level in RAM. - // It'll fill it in with the correct clear color, which we - // can then upload. + // Ask the Texture class to create the mipmap level in RAM. It'll + // fill it in with the correct clear color, which we can then + // upload. ptimage = tex->make_ram_mipmap_image(n); } } @@ -12177,8 +11768,7 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, } } - // Report the error message explicitly if the GL texture creation - // failed. + // Report the error message explicitly if the GL texture creation failed. GLenum error_code = gl_get_error(); if (error_code != GL_NO_ERROR) { GLCAT.error() @@ -12195,12 +11785,9 @@ upload_texture_image(CLP(TextureContext) *gtc, bool needs_reload, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::generate_mipmaps -// Access: Protected -// Description: Causes mipmaps to be generated for an uploaded -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Causes mipmaps to be generated for an uploaded texture. + */ void CLP(GraphicsStateGuardian):: generate_mipmaps(CLP(TextureContext) *gtc) { #ifndef OPENGLES @@ -12220,16 +11807,12 @@ generate_mipmaps(CLP(TextureContext) *gtc) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::upload_simple_texture -// Access: Protected -// Description: This is used as a standin for upload_texture -// when the texture in question is unavailable (e.g. it -// hasn't yet been loaded from disk). Until the texture -// image itself becomes available, we will render the -// texture's "simple" image--a sharply reduced version -// of the same texture. -//////////////////////////////////////////////////////////////////// +/** + * This is used as a standin for upload_texture when the texture in question + * is unavailable (e.g. it hasn't yet been loaded from disk). Until the + * texture image itself becomes available, we will render the texture's + * "simple" image--a sharply reduced version of the same texture. + */ bool CLP(GraphicsStateGuardian):: upload_simple_texture(CLP(TextureContext) *gtc) { report_my_gl_errors(); @@ -12253,8 +11836,8 @@ upload_simple_texture(CLP(TextureContext) *gtc) { size_t image_size = tex->get_simple_ram_image_size(); PTA_uchar bgr_image; if (!_supports_bgr) { - // If the GL doesn't claim to support BGR, we may have to reverse - // the component ordering of the image. + // If the GL doesn't claim to support BGR, we may have to reverse the + // component ordering of the image. external_format = GL_RGBA; image_ptr = fix_component_ordering(bgr_image, image_ptr, image_size, external_format, tex); @@ -12290,13 +11873,10 @@ upload_simple_texture(CLP(TextureContext) *gtc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_texture_memory_size -// Access: Protected -// Description: Asks OpenGL how much texture memory is consumed by -// the indicated texture (which is also the -// currently-selected texture). -//////////////////////////////////////////////////////////////////// +/** + * Asks OpenGL how much texture memory is consumed by the indicated texture + * (which is also the currently-selected texture). + */ size_t CLP(GraphicsStateGuardian):: get_texture_memory_size(CLP(TextureContext) *gtc) { Texture *tex = gtc->get_texture(); @@ -12320,8 +11900,8 @@ get_texture_memory_size(CLP(TextureContext) *gtc) { scale = 6; } else if (target == GL_TEXTURE_BUFFER) { - // In the case of buffer textures, we provided the size to begin with, - // so no point in querying anything. Plus, glGetTexParameter is not even + // In the case of buffer textures, we provided the size to begin with, so + // no point in querying anything. Plus, glGetTexParameter is not even // supported for buffer textures. return tex->get_expected_ram_image_size(); } @@ -12392,12 +11972,10 @@ get_texture_memory_size(CLP(TextureContext) *gtc) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::check_nonresident_texture -// Access: Private -// Description: Checks the list of resident texture objects to see if -// any have recently been evicted. -//////////////////////////////////////////////////////////////////// +/** + * Checks the list of resident texture objects to see if any have recently + * been evicted. + */ void CLP(GraphicsStateGuardian):: check_nonresident_texture(BufferContextChain &chain) { #if defined(SUPPORT_FIXED_FUNCTION) && !defined(OPENGLES) // Residency queries not supported by OpenGL ES. @@ -12434,13 +12012,10 @@ check_nonresident_texture(BufferContextChain &chain) { #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_extract_texture_data -// Access: Protected -// Description: The internal implementation of -// extract_texture_data(), given an already-created -// TextureContext. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of extract_texture_data(), given an already- + * created TextureContext. + */ bool CLP(GraphicsStateGuardian):: do_extract_texture_data(CLP(TextureContext) *gtc) { report_my_gl_errors(); @@ -12941,8 +12516,8 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { return false; } - // We don't want to call setup_texture() again; that resets too - // much. Instead, we'll just set the individual components. + // We don't want to call setup_texture() again; that resets too much. + // Instead, we'll just set the individual components. tex->set_x_size(width); tex->set_y_size(height); tex->set_z_size(depth); @@ -12956,7 +12531,7 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { border_color[2], border_color[3])); tex->set_minfilter(get_panda_filter_type(minfilter)); - // tex->set_magfilter(get_panda_filter_type(magfilter)); + // tex->set_magfilter(get_panda_filter_type(magfilter)); PTA_uchar image; size_t page_size = 0; @@ -12990,13 +12565,10 @@ do_extract_texture_data(CLP(TextureContext) *gtc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::extract_texture_image -// Access: Protected -// Description: Called from extract_texture_data(), this gets just -// the image array for a particular mipmap level (or for -// the base image). -//////////////////////////////////////////////////////////////////// +/** + * Called from extract_texture_data(), this gets just the image array for a + * particular mipmap level (or for the base image). + */ bool CLP(GraphicsStateGuardian):: extract_texture_image(PTA_uchar &image, size_t &page_size, Texture *tex, GLenum target, GLenum page_target, @@ -13012,15 +12584,14 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, glPixelStorei(GL_PACK_ALIGNMENT, 1); if (target == GL_TEXTURE_CUBE_MAP) { - // A cube map, compressed or uncompressed. This we must extract - // one page at a time. + // A cube map, compressed or uncompressed. This we must extract one page + // at a time. - // If the cube map is compressed, we assume that all the - // compressed pages are exactly the same size. OpenGL doesn't - // make this assumption, but it happens to be true for all - // currently extant compression schemes, and it makes things - // simpler for us. (It also makes things much simpler for the - // graphics hardware, so it's likely to continue to be true for a + // If the cube map is compressed, we assume that all the compressed pages + // are exactly the same size. OpenGL doesn't make this assumption, but it + // happens to be true for all currently extant compression schemes, and it + // makes things simpler for us. (It also makes things much simpler for + // the graphics hardware, so it's likely to continue to be true for a // while at least.) GLenum external_format = get_external_image_format(tex); @@ -13062,14 +12633,14 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, page_size = image_size / tex->get_z_size(); image = PTA_uchar::empty_array(image_size); - // Some drivers (ATI!) seem to try to overstuff more bytes in the - // array than they asked us to allocate (that is, more bytes than - // GL_TEXTURE_COMPRESSED_IMAGE_SIZE), requiring us to overallocate - // and then copy the result into our final buffer. Sheesh. + // Some drivers (ATI!) seem to try to overstuff more bytes in the array + // than they asked us to allocate (that is, more bytes than + // GL_TEXTURE_COMPRESSED_IMAGE_SIZE), requiring us to overallocate and + // then copy the result into our final buffer. Sheesh. - // We'll only do this for small textures (the ATI bug doesn't - // *seem* to affect large textures), to save on the overhead of - // the double-copy, and reduce risk from an overly-large alloca(). + // We'll only do this for small textures (the ATI bug doesn't *seem* to + // affect large textures), to save on the overhead of the double-copy, and + // reduce risk from an overly-large alloca(). #ifndef NDEBUG static const int max_trouble_buffer = 102400; #else @@ -13079,8 +12650,8 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, static const int extra_space = 32; unsigned char *buffer = (unsigned char *)alloca(image_size + extra_space); #ifndef NDEBUG - // Tag the buffer with a specific byte so we can report on - // whether that driver bug is still active. + // Tag the buffer with a specific byte so we can report on whether that + // driver bug is still active. static unsigned char keep_token = 0x00; unsigned char token = ++keep_token; memset(buffer + image_size, token, extra_space); @@ -13099,9 +12670,9 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, << "-byte buffer provided to glGetCompressedTexImage()\n"; } - // This had better not equal the amount of buffer space we set - // aside. If it does, we assume the driver might have - // overfilled even our provided extra buffer. + // This had better not equal the amount of buffer space we set aside. + // If it does, we assume the driver might have overfilled even our + // provided extra buffer. nassertr(count != extra_space, true) #endif // NDEBUG } else { @@ -13123,36 +12694,31 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, #endif // OPENGLES } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_point_size -// Access: Protected -// Description: Internally sets the point size parameters after any -// of the properties have changed that might affect -// this. -//////////////////////////////////////////////////////////////////// +/** + * Internally sets the point size parameters after any of the properties have + * changed that might affect this. + */ void CLP(GraphicsStateGuardian):: do_point_size() { #ifndef OPENGLES_2 if (!_point_perspective) { - // Normal, constant-sized points. Here _point_size is a width in - // pixels. + // Normal, constant-sized points. Here _point_size is a width in pixels. static LVecBase3f constant(1.0f, 0.0f, 0.0f); _glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, constant.get_data()); } else { - // Perspective-sized points. Here _point_size is a width in 3-d - // units. To arrange that, we need to figure out the appropriate - // scaling factor based on the current viewport and projection - // matrix. + // Perspective-sized points. Here _point_size is a width in 3-d units. + // To arrange that, we need to figure out the appropriate scaling factor + // based on the current viewport and projection matrix. LVector3 height(0.0f, _point_size, 1.0f); height = height * _projection_mat->get_mat(); height = height * _internal_transform->get_scale()[1]; PN_stdfloat s = height[1] * _viewport_height / _point_size; if (_current_lens->is_orthographic()) { - // If we have an orthographic lens in effect, we don't actually - // apply a perspective transform: we just scale the points once, - // regardless of the distance from the camera. + // If we have an orthographic lens in effect, we don't actually apply a + // perspective transform: we just scale the points once, regardless of + // the distance from the camera. LVecBase3f constant(1.0f / (s * s), 0.0f, 0.0f); _glPointParameterfv(GL_POINT_DISTANCE_ATTENUATION, constant.get_data()); @@ -13167,12 +12733,10 @@ do_point_size() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::get_supports_cg_profile -// Access: Public, Virtual -// Description: Returns true if this particular GSG supports the -// specified Cg Shader Profile. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG supports the specified Cg Shader + * Profile. + */ bool CLP(GraphicsStateGuardian):: get_supports_cg_profile(const string &name) const { #if !defined(HAVE_CG) || defined(OPENGLES) @@ -13188,11 +12752,9 @@ get_supports_cg_profile(const string &name) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::bind_fbo -// Access: Protected -// Description: Binds a framebuffer object. -//////////////////////////////////////////////////////////////////// +/** + * Binds a framebuffer object. + */ void CLP(GraphicsStateGuardian):: bind_fbo(GLuint fbo) { if (_current_fbo == fbo) { @@ -13213,9 +12775,7 @@ bind_fbo(GLuint fbo) { _current_fbo = fbo; } -//////////////////////////////////////////////////////////////////// -// GL stencil code section -//////////////////////////////////////////////////////////////////// +// GL stencil code section static int gl_stencil_operations_array[] = { GL_KEEP, @@ -13234,11 +12794,9 @@ static int gl_stencil_operations_array[] = { GL_DECR, }; -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_stencil -// Access: Protected -// Description: Set stencil render states. -//////////////////////////////////////////////////////////////////// +/** + * Set stencil render states. + */ void CLP(GraphicsStateGuardian):: do_issue_stencil() { if (!_supports_stencil) { @@ -13266,7 +12824,7 @@ do_issue_stencil() { #ifndef OPENGLES if (_supports_two_sided_stencil) { - //TODO: add support for OpenGL 2.0-style glStencilFuncSeparate. + // TODO: add support for OpenGL 2.0-style glStencilFuncSeparate. unsigned int back_compare; back_compare = stencil->get_render_state(StencilAttrib::SRS_back_comparison_function); @@ -13329,19 +12887,17 @@ do_issue_stencil() { } } -//////////////////////////////////////////////////////////////////// -// Function: GLGraphicsStateGuardian::do_issue_scissor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(GraphicsStateGuardian):: do_issue_scissor() { const ScissorAttrib *target_scissor; _target_rs->get_attrib_def(target_scissor); if (!target_scissor->is_off()) { - // A non-off ScissorAttrib means to override the scissor setting - // that was specified by the DisplayRegion. + // A non-off ScissorAttrib means to override the scissor setting that was + // specified by the DisplayRegion. if (!_scissor_enabled) { if (GLCAT.is_spam()) { GLCAT.spam() @@ -13370,8 +12926,8 @@ do_issue_scissor() { _scissor_attrib_active = false; if (_scissor_array.size() > 0) { - // Scissoring is enabled on the display region. - // Revert to the scissor state specified in the DisplayRegion. + // Scissoring is enabled on the display region. Revert to the scissor + // state specified in the DisplayRegion. #ifndef OPENGLES if (_supports_viewport_arrays) { _glScissorArrayv(0, _scissor_array.size(), _scissor_array[0].get_data()); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 846fc482e5..c2909e3b3e 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -1,18 +1,18 @@ -// Filename: glGraphicsStateGuardian_src.h -// Created by: drose (02Feb99) -// Updated by: fperazzi, PandaSE (05May10) (added -// get_supports_cg_profile) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glGraphicsStateGuardian_src.h + * @author drose + * @date 1999-02-02 + * @author fperazzi, PandaSE + * @date 2010-05-05 + * get_supports_cg_profile) + */ #include "pandabase.h" @@ -44,18 +44,17 @@ class PlaneNode; class Light; #ifdef OPENGLES -// This is a cheesy hack to allow the following typedefs to compile -// for OpenGL ES. We won't actually be calling any of the "double" -// functions in this case (and they don't exist anyway), but we need -// to be able to get past their declarations. +// This is a cheesy hack to allow the following typedefs to compile for OpenGL +// ES. We won't actually be calling any of the "double" functions in this +// case (and they don't exist anyway), but we need to be able to get past +// their declarations. typedef double GLdouble; #endif // OPENGLES -// These typedefs are declared in glext.h, but we must repeat them -// here, mainly because they will not be included from glext.h if the -// system GL version matches or exceeds the GL version in which these -// functions are defined, and the system gl.h sometimes doesn't -// declare these typedefs. +// These typedefs are declared in glext.h, but we must repeat them here, +// mainly because they will not be included from glext.h if the system GL +// version matches or exceeds the GL version in which these functions are +// defined, and the system gl.h sometimes doesn't declare these typedefs. #if !defined( __EDG__ ) || defined( __INTEL_COMPILER ) // Protect the following from the Tau instrumentor and expose it for the intel compiler. typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); typedef void (APIENTRY *GLDEBUGPROC_P)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); @@ -73,7 +72,8 @@ typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -// There is some trivial disagreement between different gl.h headers about this one, so we use our own typename. +// There is some trivial disagreement between different gl.h headers about +// this one, so we use our own typename. typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC_P) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); @@ -227,18 +227,16 @@ typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); #endif // OPENGLES #endif // __EDG__ -//////////////////////////////////////////////////////////////////// -// Class : GLGraphicsStateGuardian -// Description : A GraphicsStateGuardian specialized for rendering -// into OpenGL contexts. There should be no GL calls -// outside of this object. -//////////////////////////////////////////////////////////////////// +/** + * A GraphicsStateGuardian specialized for rendering into OpenGL contexts. + * There should be no GL calls outside of this object. + */ class EXPCL_GL CLP(GraphicsStateGuardian) : public GraphicsStateGuardian { public: CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe); virtual ~CLP(GraphicsStateGuardian)(); - //#--- Zhao Nov/2011 + // #--- Zhao Nov2011 virtual string get_driver_vendor(); virtual string get_driver_renderer(); virtual string get_driver_version(); @@ -641,9 +639,9 @@ protected: bool _supports_vertex_attrib_divisor; - // Cache the data necessary to bind each particular light each - // frame, so if we bind a given light multiple times, we only have - // to compute its data once. + // Cache the data necessary to bind each particular light each frame, so if + // we bind a given light multiple times, we only have to compute its data + // once. class DirectionalLightFrameData { public: LVector4 _neg_dir; @@ -682,7 +680,7 @@ protected: string _gl_renderer; string _gl_version; int _gl_version_major, _gl_version_minor; - //#--- Zhao Nov/2011 + // #--- Zhao Nov2011 int _gl_shadlang_ver_major, _gl_shadlang_ver_minor; pset _extensions; @@ -983,7 +981,7 @@ public: TextureSet _textures_needing_framebuffer_barrier; #endif - //RenderState::SlotMask _inv_state_mask; + // RenderState::SlotMask _inv_state_mask; int _error_count; double _last_error_check; diff --git a/panda/src/glstuff/glImmediateModeSender_src.I b/panda/src/glstuff/glImmediateModeSender_src.I index f1d75efb4f..afc1398e78 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.I +++ b/panda/src/glstuff/glImmediateModeSender_src.I @@ -1,58 +1,46 @@ -// Filename: glImmediateModeSender_src.I -// Created by: drose (15Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glImmediateModeSender_src.I + * @author drose + * @date 2005-08-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender):: CLP(ImmediateModeSender)() { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender::Constructor -// Access: Public -// Description: The ComponentSender becomes the owner of the -// GeomVertexReader pointer, and will delete it when it -// is done. -//////////////////////////////////////////////////////////////////// +/** + * The ComponentSender becomes the owner of the GeomVertexReader pointer, and + * will delete it when it is done. + */ INLINE CLP(ImmediateModeSender)::ComponentSender:: ComponentSender(GeomVertexReader *reader) : _reader(reader) { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender::set_vertex -// Access: Public -// Description: Specifies the vertex index of the next vertex to -// send. If this is not called, the next consecutive -// vertex will be sent. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the vertex index of the next vertex to send. If this is not + * called, the next consecutive vertex will be sent. + */ INLINE void CLP(ImmediateModeSender)::ComponentSender:: set_vertex(int vertex_index) { _reader->set_row(vertex_index); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender1f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::ComponentSender1f:: ComponentSender1f(GeomVertexReader *reader, Func1f *func) : ComponentSender(reader), @@ -60,11 +48,9 @@ ComponentSender1f(GeomVertexReader *reader, Func1f *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender2f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::ComponentSender2f:: ComponentSender2f(GeomVertexReader *reader, Func2f *func) : ComponentSender(reader), @@ -72,11 +58,9 @@ ComponentSender2f(GeomVertexReader *reader, Func2f *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender3f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::ComponentSender3f:: ComponentSender3f(GeomVertexReader *reader, Func3f *func) : ComponentSender(reader), @@ -84,11 +68,9 @@ ComponentSender3f(GeomVertexReader *reader, Func3f *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender4f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::ComponentSender4f:: ComponentSender4f(GeomVertexReader *reader, Func4f *func) : ComponentSender(reader), @@ -96,13 +78,11 @@ ComponentSender4f(GeomVertexReader *reader, Func4f *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender1f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::TexcoordSender1f:: -TexcoordSender1f(GeomVertexReader *reader, TexcoordFunc1f *func, +TexcoordSender1f(GeomVertexReader *reader, TexcoordFunc1f *func, int stage_index) : ComponentSender(reader), _func(func), @@ -110,13 +90,11 @@ TexcoordSender1f(GeomVertexReader *reader, TexcoordFunc1f *func, { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender2f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::TexcoordSender2f:: -TexcoordSender2f(GeomVertexReader *reader, TexcoordFunc2f *func, +TexcoordSender2f(GeomVertexReader *reader, TexcoordFunc2f *func, int stage_index) : ComponentSender(reader), _func(func), @@ -124,13 +102,11 @@ TexcoordSender2f(GeomVertexReader *reader, TexcoordFunc2f *func, { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender3f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::TexcoordSender3f:: -TexcoordSender3f(GeomVertexReader *reader, TexcoordFunc3f *func, +TexcoordSender3f(GeomVertexReader *reader, TexcoordFunc3f *func, int stage_index) : ComponentSender(reader), _func(func), @@ -138,13 +114,11 @@ TexcoordSender3f(GeomVertexReader *reader, TexcoordFunc3f *func, { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender4f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::TexcoordSender4f:: -TexcoordSender4f(GeomVertexReader *reader, TexcoordFunc4f *func, +TexcoordSender4f(GeomVertexReader *reader, TexcoordFunc4f *func, int stage_index) : ComponentSender(reader), _func(func), @@ -152,11 +126,9 @@ TexcoordSender4f(GeomVertexReader *reader, TexcoordFunc4f *func, { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender1f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender1f:: VectorSender1f(GeomVertexReader *reader, VectorFunc *func) : ComponentSender(reader), @@ -164,11 +136,9 @@ VectorSender1f(GeomVertexReader *reader, VectorFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender2f:: VectorSender2f(GeomVertexReader *reader, VectorFunc *func) : ComponentSender(reader), @@ -176,11 +146,9 @@ VectorSender2f(GeomVertexReader *reader, VectorFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender3f:: VectorSender3f(GeomVertexReader *reader, VectorFunc *func) : ComponentSender(reader), @@ -188,11 +156,9 @@ VectorSender3f(GeomVertexReader *reader, VectorFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4f::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender4f:: VectorSender4f(GeomVertexReader *reader, VectorFunc *func) : ComponentSender(reader), @@ -200,11 +166,9 @@ VectorSender4f(GeomVertexReader *reader, VectorFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender1ui::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender1ui:: VectorSender1ui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), @@ -212,11 +176,9 @@ VectorSender1ui(GeomVertexReader *reader, VectorUintFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2fui::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender2fui:: VectorSender2fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), @@ -224,11 +186,9 @@ VectorSender2fui(GeomVertexReader *reader, VectorUintFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3fui::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender3fui:: VectorSender3fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), @@ -236,11 +196,9 @@ VectorSender3fui(GeomVertexReader *reader, VectorUintFunc *func) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4fui::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(ImmediateModeSender)::VectorSender4fui:: VectorSender4fui(GeomVertexReader *reader, VectorUintFunc *func) : ComponentSender(reader), diff --git a/panda/src/glstuff/glImmediateModeSender_src.cxx b/panda/src/glstuff/glImmediateModeSender_src.cxx index 347423cbb7..b832132a33 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.cxx +++ b/panda/src/glstuff/glImmediateModeSender_src.cxx @@ -1,35 +1,29 @@ -// Filename: glImmediateModeSender_src.cxx -// Created by: drose (15Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glImmediateModeSender_src.cxx + * @author drose + * @date 2005-08-15 + */ #ifdef SUPPORT_IMMEDIATE_MODE -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(ImmediateModeSender):: ~CLP(ImmediateModeSender)() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::clear -// Access: Public -// Description: Removes (and deletes) all of the senders from the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Removes (and deletes) all of the senders from the object. + */ void CLP(ImmediateModeSender):: clear() { ComponentSenders::iterator si; @@ -39,13 +33,10 @@ clear() { _senders.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::set_vertex -// Access: Public -// Description: Specifies the vertex index of the next vertex to -// send. If this is not called, the next consecutive -// vertex will be sent. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the vertex index of the next vertex to send. If this is not + * called, the next consecutive vertex will be sent. + */ void CLP(ImmediateModeSender):: set_vertex(int vertex_index) { ComponentSenders::iterator si; @@ -54,11 +45,9 @@ set_vertex(int vertex_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::issue_vertex -// Access: Public -// Description: Sends the next vertex to the OpenGL API. -//////////////////////////////////////////////////////////////////// +/** + * Sends the next vertex to the OpenGL API. + */ void CLP(ImmediateModeSender):: issue_vertex() { ComponentSenders::iterator si; @@ -67,23 +56,19 @@ issue_vertex() { } } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::add_column -// Access: Public -// Description: Creates a new ComponentSender for the named data -// column, if it exists in the vertex data, and adds it -// to the list of senders for this object. -// -// The four function pointers are the four variants on -// the function pointer for the possible number of -// components of the data column. The appropriate -// pointer will be used, depending on the number of -// components the data column actually uses. -// -// The return value is true if the column is added, -// false if it is not for some reason (for instance, the -// named column doesn't exist in the vertex data). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ComponentSender for the named data column, if it exists in + * the vertex data, and adds it to the list of senders for this object. + * + * The four function pointers are the four variants on the function pointer + * for the possible number of components of the data column. The appropriate + * pointer will be used, depending on the number of components the data column + * actually uses. + * + * The return value is true if the column is added, false if it is not for + * some reason (for instance, the named column doesn't exist in the vertex + * data). + */ bool CLP(ImmediateModeSender):: add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, Func1f *func1f, Func2f *func2, Func3f *func3, Func4f *func4) { @@ -131,25 +116,22 @@ add_column(const GeomVertexDataPipelineReader *data_reader, const InternalName * return false; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::add_texcoord_column -// Access: Public -// Description: Creates a new ComponentSender for the named data -// column, if it exists in the vertex data, and adds it -// to the list of senders for this object. -// -// This works like add_column(), but it specifically -// handles a texcoord-style column, which requires one -// additional parameter to OpenGL: the texture stage. -// -// The return value is true if the column is added, -// false if it is not for some reason (for instance, the -// named column doesn't exist in the vertex data). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ComponentSender for the named data column, if it exists in + * the vertex data, and adds it to the list of senders for this object. + * + * This works like add_column(), but it specifically handles a texcoord-style + * column, which requires one additional parameter to OpenGL: the texture + * stage. + * + * The return value is true if the column is added, false if it is not for + * some reason (for instance, the named column doesn't exist in the vertex + * data). + */ bool CLP(ImmediateModeSender):: -add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, +add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, int stage_index, - TexcoordFunc1f *func1f, TexcoordFunc2f *func2, + TexcoordFunc1f *func1f, TexcoordFunc2f *func2, TexcoordFunc3f *func3, TexcoordFunc4f *func4) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); @@ -187,23 +169,18 @@ add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, return false; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::add_vector_column -// Access: Public -// Description: Creates a new ComponentSender for the named data -// column, if it exists in the vertex data, and adds it -// to the list of senders for this object. -// -// This works like add_column(), but it specifically -// handles a function that accepts as its first -// parameter the size (number of components) of the -// floating-point vector, followed by the address of the -// vector. -// -// The return value is true if the column is added, -// false if it is not for some reason (for instance, the -// named column doesn't exist in the vertex data). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ComponentSender for the named data column, if it exists in + * the vertex data, and adds it to the list of senders for this object. + * + * This works like add_column(), but it specifically handles a function that + * accepts as its first parameter the size (number of components) of the + * floating-point vector, followed by the address of the vector. + * + * The return value is true if the column is added, false if it is not for + * some reason (for instance, the named column doesn't exist in the vertex + * data). + */ bool CLP(ImmediateModeSender):: add_vector_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorFunc *func) { @@ -243,22 +220,19 @@ add_vector_column(const GeomVertexDataPipelineReader *data_reader, const Interna return false; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::add_vector_uint_column -// Access: Public -// Description: Creates a new ComponentSender for the named data -// column, if it exists in the vertex data, and adds it -// to the list of senders for this object. -// -// This works like add_vector_column(), but handles a -// function that receives a vector of unsigned ints. -// -// The return value is true if the column is added, -// false if it is not for some reason (for instance, the -// named column doesn't exist in the vertex data). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ComponentSender for the named data column, if it exists in + * the vertex data, and adds it to the list of senders for this object. + * + * This works like add_vector_column(), but handles a function that receives a + * vector of unsigned ints. + * + * The return value is true if the column is added, false if it is not for + * some reason (for instance, the named column doesn't exist in the vertex + * data). + */ bool CLP(ImmediateModeSender):: -add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, +add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorUintFunc *func) { if (data_reader->has_column(name)) { GeomVertexReader *reader = new GeomVertexReader(data_reader, name); @@ -296,34 +270,27 @@ add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, return false; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::add_sender -// Access: Public -// Description: Adds a new ComponentSender to the list of senders for -// this object. The GLImmediateModeSender object -// becomes the owner of the ComponentSender pointer and -// will delete it when it is done. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new ComponentSender to the list of senders for this object. The + * GLImmediateModeSender object becomes the owner of the ComponentSender + * pointer and will delete it when it is done. + */ void CLP(ImmediateModeSender):: add_sender(ComponentSender *sender) { _senders.push_back(sender); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(ImmediateModeSender)::ComponentSender:: ~ComponentSender() { delete _reader; } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender1f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::ComponentSender1f:: issue_vertex() { PN_stdfloat d = _reader->get_data1f(); @@ -337,11 +304,9 @@ issue_vertex() { (*_func)(d); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender2f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::ComponentSender2f:: issue_vertex() { const LVecBase2 &d = _reader->get_data2(); @@ -355,11 +320,9 @@ issue_vertex() { (*_func)(d[0], d[1]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender3f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::ComponentSender3f:: issue_vertex() { const LVecBase3 &d = _reader->get_data3(); @@ -373,11 +336,9 @@ issue_vertex() { (*_func)(d[0], d[1], d[2]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::ComponentSender4f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::ComponentSender4f:: issue_vertex() { const LVecBase4 &d = _reader->get_data4(); @@ -391,11 +352,9 @@ issue_vertex() { (*_func)(d[0], d[1], d[2], d[3]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender1f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::TexcoordSender1f:: issue_vertex() { PN_stdfloat d = _reader->get_data1f(); @@ -410,11 +369,9 @@ issue_vertex() { (*_func)(GL_TEXTURE0 + _stage_index, d); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender2f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::TexcoordSender2f:: issue_vertex() { const LVecBase2 &d = _reader->get_data2(); @@ -429,11 +386,9 @@ issue_vertex() { (*_func)(GL_TEXTURE0 + _stage_index, d[0], d[1]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender3f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::TexcoordSender3f:: issue_vertex() { const LVecBase3 &d = _reader->get_data3(); @@ -448,11 +403,9 @@ issue_vertex() { (*_func)(GL_TEXTURE0 + _stage_index, d[0], d[1], d[2]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::TexcoordSender4f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::TexcoordSender4f:: issue_vertex() { const LVecBase4 &d = _reader->get_data4(); @@ -467,11 +420,9 @@ issue_vertex() { (*_func)(GL_TEXTURE0 + _stage_index, d[0], d[1], d[2], d[3]); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender1f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender1f:: issue_vertex() { PN_stdfloat d = _reader->get_data1f(); @@ -485,11 +436,9 @@ issue_vertex() { (*_func)(1, &d); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender2f:: issue_vertex() { const LVecBase2 &d = _reader->get_data2(); @@ -503,11 +452,9 @@ issue_vertex() { (*_func)(2, d.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender3f:: issue_vertex() { const LVecBase3 &d = _reader->get_data3(); @@ -521,11 +468,9 @@ issue_vertex() { (*_func)(3, d.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4f::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender4f:: issue_vertex() { const LVecBase4 &d = _reader->get_data4(); @@ -539,11 +484,9 @@ issue_vertex() { (*_func)(4, d.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender1ui::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender1ui:: issue_vertex() { int d = _reader->get_data1i(); @@ -557,18 +500,16 @@ issue_vertex() { (*_func)(1, (const GLuint *)&d); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender2fui::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender2fui:: issue_vertex() { const LVecBase2i &d = _reader->get_data2i(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() - << *_reader->get_column()->get_name() << ": " << d[0] << " " + << *_reader->get_column()->get_name() << ": " << d[0] << " " << d[1] << "\n"; } #endif // NDEBUG @@ -576,18 +517,16 @@ issue_vertex() { (*_func)(2, (const GLuint *)d.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender3fui::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender3fui:: issue_vertex() { const LVecBase3i &d = _reader->get_data3i(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() - << *_reader->get_column()->get_name() << ": " << d[0] << " " + << *_reader->get_column()->get_name() << ": " << d[0] << " " << d[1] << " " << d[2] << "\n"; } #endif // NDEBUG @@ -595,18 +534,16 @@ issue_vertex() { (*_func)(3, (const GLuint *)d.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(ImmediateModeSender)::VectorSender4fui::issue_vertex -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(ImmediateModeSender)::VectorSender4fui:: issue_vertex() { const LVecBase4i &d = _reader->get_data4i(); #ifndef NDEBUG if (GLCAT.is_spam()) { GLCAT.spam() - << *_reader->get_column()->get_name() << ": " << d[0] << " " + << *_reader->get_column()->get_name() << ": " << d[0] << " " << d[1] << " " << d[2] << " " << d[3] << "\n"; } #endif // NDEBUG diff --git a/panda/src/glstuff/glImmediateModeSender_src.h b/panda/src/glstuff/glImmediateModeSender_src.h index 1668c3eaed..202eb87923 100644 --- a/panda/src/glstuff/glImmediateModeSender_src.h +++ b/panda/src/glstuff/glImmediateModeSender_src.h @@ -1,44 +1,39 @@ -// Filename: glImmediateModeSender_src.h -// Created by: drose (15Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glImmediateModeSender_src.h + * @author drose + * @date 2005-08-15 + */ #include "pandabase.h" #include "geomVertexReader.h" #ifdef SUPPORT_IMMEDIATE_MODE -//////////////////////////////////////////////////////////////////// -// Class : GLImmediateModeSender -// Description : This class collects together a handful of objects -// that will issue immediate-mode commands like -// glVertex, glTexCoord, etc., for the purposes of -// sending an object's vertices using the immediate mode -// functions. -// -// Normally, this isn't used, since it's almost always -// better to use vertex arrays or vertex buffers -// instead. But OpenGL is a complicated API, and some -// drivers might have issues handling the vertex arrays; -// this code is provided as a last-ditch fallback in -// case you have such spectacularly buggy drivers. -//////////////////////////////////////////////////////////////////// +/** + * This class collects together a handful of objects that will issue + * immediate-mode commands like glVertex, glTexCoord, etc., for the purposes + * of sending an object's vertices using the immediate mode functions. + * + * Normally, this isn't used, since it's almost always better to use vertex + * arrays or vertex buffers instead. But OpenGL is a complicated API, and + * some drivers might have issues handling the vertex arrays; this code is + * provided as a last-ditch fallback in case you have such spectacularly buggy + * drivers. + */ class EXPCL_GL CLP(ImmediateModeSender) { public: INLINE CLP(ImmediateModeSender)(); ~CLP(ImmediateModeSender)(); void clear(); - + void set_vertex(int vertex_index); void issue_vertex(); @@ -67,17 +62,17 @@ public: #endif // STDFLOAT_DOUBLE typedef void APIENTRY VectorUintFunc(GLint, const GLuint *); - bool add_column(const GeomVertexDataPipelineReader *data_reader, - const InternalName *name, Func1f *func1f, + bool add_column(const GeomVertexDataPipelineReader *data_reader, + const InternalName *name, Func1f *func1f, Func2f *func2, Func3f *func3, Func4f *func4); - bool add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, + bool add_texcoord_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, int stage_index, - TexcoordFunc1f *func1f, TexcoordFunc2f *func2, + TexcoordFunc1f *func1f, TexcoordFunc2f *func2, TexcoordFunc3f *func3, TexcoordFunc4f *func4); - bool add_vector_column(const GeomVertexDataPipelineReader *data_reader, + bool add_vector_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorFunc *func); - bool add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, + bool add_vector_uint_column(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, VectorUintFunc *func); void add_sender(ComponentSender *sender); @@ -238,4 +233,3 @@ private: #include "glImmediateModeSender_src.I" #endif // SUPPORT_IMMEDIATE_MODE - diff --git a/panda/src/glstuff/glIndexBufferContext_src.I b/panda/src/glstuff/glIndexBufferContext_src.I index d962419ce6..39b6562d73 100644 --- a/panda/src/glstuff/glIndexBufferContext_src.I +++ b/panda/src/glstuff/glIndexBufferContext_src.I @@ -1,23 +1,19 @@ -// Filename: glIndexBufferContext_src.I -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glIndexBufferContext_src.I + * @author drose + * @date 2005-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(IndexBufferContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(IndexBufferContext):: CLP(IndexBufferContext)(CLP(GraphicsStateGuardian) *glgsg, PreparedGraphicsObjects *pgo, diff --git a/panda/src/glstuff/glIndexBufferContext_src.cxx b/panda/src/glstuff/glIndexBufferContext_src.cxx index 529d6cdad1..8b3e81b7ed 100644 --- a/panda/src/glstuff/glIndexBufferContext_src.cxx +++ b/panda/src/glstuff/glIndexBufferContext_src.cxx @@ -1,34 +1,28 @@ -// Filename: glIndexBufferContext_src.cxx -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glIndexBufferContext_src.cxx + * @author drose + * @date 2005-03-17 + */ TypeHandle CLP(IndexBufferContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLIndexBufferContext::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void CLP(IndexBufferContext):: evict_lru() { dequeue_lru(); @@ -46,8 +40,8 @@ evict_lru() { // Free the buffer. _glgsg->_glDeleteBuffers(1, &_index); - // We still need a valid index number, though, in case we want to - // re-load the buffer later. + // We still need a valid index number, though, in case we want to re-load + // the buffer later. _glgsg->_glGenBuffers(1, &_index); update_data_size_bytes(0); diff --git a/panda/src/glstuff/glIndexBufferContext_src.h b/panda/src/glstuff/glIndexBufferContext_src.h index 960ff05e9d..dfe011c4d0 100644 --- a/panda/src/glstuff/glIndexBufferContext_src.h +++ b/panda/src/glstuff/glIndexBufferContext_src.h @@ -1,30 +1,27 @@ -// Filename: glIndexBufferContext_src.h -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glIndexBufferContext_src.h + * @author drose + * @date 2005-03-17 + */ #include "pandabase.h" #include "indexBufferContext.h" #include "deletedChain.h" -//////////////////////////////////////////////////////////////////// -// Class : GLIndexBufferContext -// Description : Caches a GeomPrimitive on the GL as a buffer -// object. -//////////////////////////////////////////////////////////////////// +/** + * Caches a GeomPrimitive on the GL as a buffer object. + */ class EXPCL_GL CLP(IndexBufferContext) : public IndexBufferContext { public: INLINE CLP(IndexBufferContext)(CLP(GraphicsStateGuardian) *glgsg, - PreparedGraphicsObjects *pgo, + PreparedGraphicsObjects *pgo, GeomPrimitive *data); ALLOC_DELETED_CHAIN(CLP(IndexBufferContext)); @@ -54,4 +51,3 @@ private: }; #include "glIndexBufferContext_src.I" - diff --git a/panda/src/glstuff/glLatencyQueryContext_src.I b/panda/src/glstuff/glLatencyQueryContext_src.I index d87b0c6263..adc45cdf5e 100644 --- a/panda/src/glstuff/glLatencyQueryContext_src.I +++ b/panda/src/glstuff/glLatencyQueryContext_src.I @@ -1,14 +1,12 @@ -// Filename: glLatencyQueryContext_src.I -// Created by: rdb (24Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glLatencyQueryContext_src.I + * @author rdb + * @date 2014-09-24 + */ diff --git a/panda/src/glstuff/glLatencyQueryContext_src.cxx b/panda/src/glstuff/glLatencyQueryContext_src.cxx index b99217f282..a08ab74517 100644 --- a/panda/src/glstuff/glLatencyQueryContext_src.cxx +++ b/panda/src/glstuff/glLatencyQueryContext_src.cxx @@ -1,26 +1,23 @@ -// Filename: glLatencyQueryContext_src.cxx -// Created by: rdb (24Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glLatencyQueryContext_src.cxx + * @author rdb + * @date 2014-09-24 + */ #ifndef OPENGLES // Timer queries not supported by OpenGL ES. TypeHandle CLP(LatencyQueryContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLP(LatencyQueryContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(LatencyQueryContext):: CLP(LatencyQueryContext)(CLP(GraphicsStateGuardian) *glgsg, int pstats_index) : @@ -30,19 +27,15 @@ CLP(LatencyQueryContext)(CLP(GraphicsStateGuardian) *glgsg, glgsg->_glGetInteger64v(GL_TIMESTAMP, &_timestamp); } -//////////////////////////////////////////////////////////////////// -// Function: LatencyQueryContext::get_timestamp -// Access: Public, Virtual -// Description: Returns the timestamp that is the result of this -// timer query. There's no guarantee about which -// clock this uses, the only guarantee is that -// subtracting a start time from an end time should -// yield a time in seconds. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp that is the result of this timer query. There's no + * guarantee about which clock this uses, the only guarantee is that + * subtracting a start time from an end time should yield a time in seconds. + * If is_answer_ready() did not return true, this function may block before it + * returns. + * + * It is only valid to call this from the draw thread. + */ double CLP(LatencyQueryContext):: get_timestamp() const { GLint64 time_ns; diff --git a/panda/src/glstuff/glLatencyQueryContext_src.h b/panda/src/glstuff/glLatencyQueryContext_src.h index e2c5eae4e3..7c255cb5df 100644 --- a/panda/src/glstuff/glLatencyQueryContext_src.h +++ b/panda/src/glstuff/glLatencyQueryContext_src.h @@ -1,28 +1,25 @@ -// Filename: glLatencyQueryContext_src.h -// Created by: rdb (24Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glLatencyQueryContext_src.h + * @author rdb + * @date 2014-09-24 + */ class GraphicsStateGuardian; #ifndef OPENGLES // Timer queries not supported by OpenGL ES. -//////////////////////////////////////////////////////////////////// -// Class : GLLatencyQueryContext -// Description : This is a special variant of GLTimerQueryContext -// that measures the command latency, ie. the time -// it takes for the GPU to actually get to the commands -// we are issuing right now. -//////////////////////////////////////////////////////////////////// +/** + * This is a special variant of GLTimerQueryContext that measures the command + * latency, ie. the time it takes for the GPU to actually get to the commands + * we are issuing right now. + */ class EXPCL_GL CLP(LatencyQueryContext) : public CLP(TimerQueryContext) { public: CLP(LatencyQueryContext)(CLP(GraphicsStateGuardian) *glgsg, int pstats_index); @@ -54,4 +51,3 @@ private: #include "glLatencyQueryContext_src.I" #endif // OPENGLES - diff --git a/panda/src/glstuff/glOcclusionQueryContext_src.I b/panda/src/glstuff/glOcclusionQueryContext_src.I index 0203be2997..a6c899fd4c 100644 --- a/panda/src/glstuff/glOcclusionQueryContext_src.I +++ b/panda/src/glstuff/glOcclusionQueryContext_src.I @@ -1,23 +1,19 @@ -// Filename: glOcclusionQueryContext_src.I -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glOcclusionQueryContext_src.I + * @author drose + * @date 2006-03-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(OcclusionQueryContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(OcclusionQueryContext):: CLP(OcclusionQueryContext)(GraphicsStateGuardian *gsg) { _index = 0; diff --git a/panda/src/glstuff/glOcclusionQueryContext_src.cxx b/panda/src/glstuff/glOcclusionQueryContext_src.cxx index f3197ee68d..83e47e7b0c 100644 --- a/panda/src/glstuff/glOcclusionQueryContext_src.cxx +++ b/panda/src/glstuff/glOcclusionQueryContext_src.cxx @@ -1,16 +1,15 @@ -// Filename: glOcclusionQueryContext_src.cxx -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glOcclusionQueryContext_src.cxx + * @author drose + * @date 2006-03-27 + */ #include "pnotify.h" #include "dcast.h" @@ -21,11 +20,9 @@ TypeHandle CLP(OcclusionQueryContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(OcclusionQueryContext):: ~CLP(OcclusionQueryContext)() { if (_index != 0) { @@ -39,15 +36,12 @@ CLP(OcclusionQueryContext):: } } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::is_answer_ready -// Access: Public, Virtual -// Description: Returns true if the query's answer is ready, false -// otherwise. If this returns false, the application -// must continue to poll until it returns true. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the query's answer is ready, false otherwise. If this + * returns false, the application must continue to poll until it returns true. + * + * It is only valid to call this from the draw thread. + */ bool CLP(OcclusionQueryContext):: is_answer_ready() const { CLP(GraphicsStateGuardian) *glgsg; @@ -63,31 +57,25 @@ is_answer_ready() const { return (result != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::waiting_for_answer -// Access: Public, Virtual -// Description: Requests the graphics engine to expedite the pending -// answer--the application is now waiting until the -// answer is ready. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Requests the graphics engine to expedite the pending answer--the + * application is now waiting until the answer is ready. + * + * It is only valid to call this from the draw thread. + */ void CLP(OcclusionQueryContext):: waiting_for_answer() { PStatTimer timer(GraphicsStateGuardian::_wait_occlusion_pcollector); glFlush(); } -//////////////////////////////////////////////////////////////////// -// Function: GLOcclusionQueryContext::get_num_fragments -// Access: Public, Virtual -// Description: Returns the number of fragments (pixels) of the -// specified geometry that passed the depth test. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of fragments (pixels) of the specified geometry that + * passed the depth test. If is_answer_ready() did not return true, this + * function may block before it returns. + * + * It is only valid to call this from the draw thread. + */ int CLP(OcclusionQueryContext):: get_num_fragments() const { CLP(GraphicsStateGuardian) *glgsg; diff --git a/panda/src/glstuff/glOcclusionQueryContext_src.h b/panda/src/glstuff/glOcclusionQueryContext_src.h index e3468fb691..93a93fe1e4 100644 --- a/panda/src/glstuff/glOcclusionQueryContext_src.h +++ b/panda/src/glstuff/glOcclusionQueryContext_src.h @@ -1,16 +1,15 @@ -// Filename: glOcclusionQueryContext_src.h -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glOcclusionQueryContext_src.h + * @author drose + * @date 2006-03-27 + */ #include "pandabase.h" #include "occlusionQueryContext.h" @@ -20,10 +19,9 @@ class GraphicsStateGuardian; #ifndef OPENGLES // Occlusion queries not supported by OpenGL ES. -//////////////////////////////////////////////////////////////////// -// Class : GLOcclusionQueryContext -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_GL CLP(OcclusionQueryContext) : public OcclusionQueryContext { public: INLINE CLP(OcclusionQueryContext)(GraphicsStateGuardian *gsg); @@ -58,4 +56,3 @@ private: #include "glOcclusionQueryContext_src.I" #endif // OPENGLES - diff --git a/panda/src/glstuff/glSamplerContext_src.cxx b/panda/src/glstuff/glSamplerContext_src.cxx index c09655912d..fa5f4984ae 100644 --- a/panda/src/glstuff/glSamplerContext_src.cxx +++ b/panda/src/glstuff/glSamplerContext_src.cxx @@ -1,16 +1,15 @@ -// Filename: glSamplerContext_src.cxx -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glSamplerContext_src.cxx + * @author rdb + * @date 2014-12-11 + */ #include "pnotify.h" @@ -18,11 +17,9 @@ TypeHandle CLP(SamplerContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLP(SamplerContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(SamplerContext):: CLP(SamplerContext)(CLP(GraphicsStateGuardian) *glgsg, const SamplerState &sampler) : @@ -32,31 +29,24 @@ CLP(SamplerContext)(CLP(GraphicsStateGuardian) *glgsg, _glgsg->_glGenSamplers(1, &_index); } -//////////////////////////////////////////////////////////////////// -// Function: CLP(SamplerContext)::Denstructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(SamplerContext):: ~CLP(SamplerContext)() { // Don't call glDeleteSamplers; we may not have an active context. } -//////////////////////////////////////////////////////////////////// -// Function: GLSamplerContext::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void CLP(SamplerContext):: evict_lru() { dequeue_lru(); @@ -64,21 +54,18 @@ evict_lru() { reset_data(); } -//////////////////////////////////////////////////////////////////// -// Function: GLSamplerContext::reset_data -// Access: Public -// Description: Resets the texture object to a new one so a new GL -// texture object can be uploaded. -//////////////////////////////////////////////////////////////////// +/** + * Resets the texture object to a new one so a new GL texture object can be + * uploaded. + */ void CLP(SamplerContext):: reset_data() { // Free the sampler resource. _glgsg->_glDeleteSamplers(1, &_index); _index = 0; - // We still need a valid index number, though, in case we want to - // re-load the sampler later. - //glGenSamplers(1, &_index); + // We still need a valid index number, though, in case we want to re-load + // the sampler later. glGenSamplers(1, &_index); } #endif // OPENGLES diff --git a/panda/src/glstuff/glSamplerContext_src.h b/panda/src/glstuff/glSamplerContext_src.h index 12c2772987..369ab49ab6 100644 --- a/panda/src/glstuff/glSamplerContext_src.h +++ b/panda/src/glstuff/glSamplerContext_src.h @@ -1,16 +1,15 @@ -// Filename: glSamplerContext_src.h -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glSamplerContext_src.h + * @author rdb + * @date 2014-12-11 + */ #ifndef OPENGLES @@ -20,12 +19,10 @@ class CLP(GraphicsStateGuardian); -//////////////////////////////////////////////////////////////////// -// Class : GLSamplerContext -// Description : This class represents a sampler object, which -// contains a set of sampler parameters used when -// sampling a texture. -//////////////////////////////////////////////////////////////////// +/** + * This class represents a sampler object, which contains a set of sampler + * parameters used when sampling a texture. + */ class EXPCL_GL CLP(SamplerContext) : public SamplerContext { public: INLINE CLP(SamplerContext)(CLP(GraphicsStateGuardian) *glgsg, diff --git a/panda/src/glstuff/glShaderContext_src.I b/panda/src/glstuff/glShaderContext_src.I index 3f5bc7132c..00b8460ba8 100644 --- a/panda/src/glstuff/glShaderContext_src.I +++ b/panda/src/glstuff/glShaderContext_src.I @@ -1,27 +1,22 @@ -// Filename: glShaderContext_src.I -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glShaderContext_src.I + * @author jyelon + * @date 2005-09-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::valid -// Access: Public -// Description: Returns true if the shader is "valid", ie, if the -// compilation was successful. The compilation could -// fail if there is a syntax error in the shader, or -// if the current video card isn't shader-capable, -// or if no shader languages are compiled into panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader is "valid", ie, if the compilation was + * successful. The compilation could fail if there is a syntax error in the + * shader, or if the current video card isn't shader-capable, or if no shader + * languages are compiled into panda. + */ INLINE bool CLP(ShaderContext):: valid() { if (_shader->get_error_flag()) return false; @@ -34,23 +29,18 @@ valid() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::uses_standard_vertex_arrays -// Access: Public -// Description: Returns true if the shader may need to access -// standard vertex attributes as passed by -// glVertexPointer and the like. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader may need to access standard vertex attributes as + * passed by glVertexPointer and the like. + */ INLINE bool CLP(ShaderContext):: uses_standard_vertex_arrays() { return _uses_standard_vertex_arrays; } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::uses_custom_vertex_arrays -// Access: Public -// Description: Always true, for now. -//////////////////////////////////////////////////////////////////// +/** + * Always true, for now. + */ INLINE bool CLP(ShaderContext):: uses_custom_vertex_arrays() { return true; diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 6c26a31974..94cef280d7 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1,18 +1,18 @@ -// Filename: glShaderContext_src.cxx -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE (29Apr10) (updated CLP with note that some -// parameter types only supported under Cg) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glShaderContext_src.cxx + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-29 + * parameter types only supported under Cg) + */ #ifndef OPENGLES_1 @@ -29,26 +29,23 @@ TypeHandle CLP(ShaderContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::ParseAndSetShaderUniformVars -// Access: Public -// Description: The Panda CG shader syntax defines a useful set of shorthand notations for setting nodepath -// properties as shaderinputs. For example, float4 mspos_XXX refers to nodepath XXX's position -// in model space. This function is a rough attempt to reimplement some of the shorthand -// notations for GLSL. The code is ~99% composed of excerpts dealing with matrix shaderinputs -// from Shader::compile_parameter. -// -// Given a uniform variable name queried from the compiled shader passed in via arg_id, -// 1) parse the name -// 2a) if the name refers to a Panda shorthand notation -// push the appropriate matrix into shader._mat_spec -// returns True -// 2b) If the name doesn't refer to a Panda shorthand notation -// returns False -// -// The boolean return is used to notify down-river processing whether the shader var/parm was -// actually picked up and the appropriate ShaderMatSpec pushed onto _mat_spec. -//////////////////////////////////////////////////////////////////// +/** + * The Panda CG shader syntax defines a useful set of shorthand notations for + * setting nodepath properties as shaderinputs. For example, float4 mspos_XXX + * refers to nodepath XXX's position in model space. This function is a rough + * attempt to reimplement some of the shorthand notations for GLSL. The code + * is ~99% composed of excerpts dealing with matrix shaderinputs from + * Shader::compile_parameter. + * + * Given a uniform variable name queried from the compiled shader passed in + * via arg_id, 1) parse the name 2a) if the name refers to a Panda shorthand + * notation push the appropriate matrix into shader._mat_spec returns True 2b) + * If the name doesn't refer to a Panda shorthand notation returns False + * + * The boolean return is used to notify down-river processing whether the + * shader var/parm was actually picked up and the appropriate ShaderMatSpec + * pushed onto _mat_spec. + */ bool CLP(ShaderContext):: parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, GLenum param_type, GLint param_size, Shader *objShader) { Shader::ShaderArgInfo p; @@ -230,8 +227,8 @@ parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, GLenum param_t objShader->_mat_deps |= bind._dep[0] | bind._dep[1]; if (param_size > 1) { - // We support arrays of rows and arrays of columns, so we can - // run the GLSL shaders that cgc spits out. + // We support arrays of rows and arrays of columns, so we can run the + // GLSL shaders that cgc spits out. if (bind._piece == Shader::SMP_row0 || bind._piece == Shader::SMP_col0) { if (param_size > 4) { GLCAT.warning() << basename << "[" << param_size << "] is too large, only the first four elements will be defined\n"; @@ -252,11 +249,9 @@ parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, GLenum param_t return false; } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::Constructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(ShaderContext):: CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext(s) { _glgsg = glgsg; @@ -272,8 +267,8 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext nassertv(s->get_language() == Shader::SL_GLSL); - // We compile and analyze the shader here, instead of in shader.cxx, - // to avoid gobj getting a dependency on GL stuff. + // We compile and analyze the shader here, instead of in shader.cxx, to + // avoid gobj getting a dependency on GL stuff. if (!glsl_compile_and_link()) { release_resources(); s->_error_flag = true; @@ -298,8 +293,8 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext _glgsg->_glLinkProgram(_glsl_program); }*/ - // Create a buffer the size of the longest uniform name. Note - // that Intel HD drivers report values that are too low. + // Create a buffer the size of the longest uniform name. Note that Intel HD + // drivers report values that are too low. name_buflen = 0; _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &name_buflen); name_buflen = max(64, name_buflen); @@ -311,8 +306,8 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext GLint block_count = 0, block_maxlength = 0; _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_BLOCKS, &block_count); - // Intel HD drivers report GL_INVALID_ENUM here. They reportedly - // fixed it, but I don't know in which driver version the fix is. + // Intel HD drivers report GL_INVALID_ENUM here. They reportedly fixed + // it, but I don't know in which driver version the fix is. if (_glgsg->_gl_vendor != "Intel") { _glgsg->_glGetProgramiv(_glsl_program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &block_maxlength); block_maxlength = max(64, block_maxlength); @@ -355,12 +350,10 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext } } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::reflect_attribute -// Access: Public -// Description: Analyzes the vertex attribute and stores the -// information it needs to remember. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes the vertex attribute and stores the information it needs to + * remember. + */ void CLP(ShaderContext):: reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { GLint param_size; @@ -383,8 +376,8 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { if (p == -1 || strncmp(name_buffer, "gl_", 3) == 0) { // A gl_ attribute such as gl_Vertex requires us to pass the standard - // vertex arrays as we would do without shader. Not all drivers return - // -1 in glGetAttribLocation for gl_ prefixed attributes, so we check the + // vertex arrays as we would do without shader. Not all drivers return -1 + // in glGetAttribLocation for gl_ prefixed attributes, so we check the // prefix of the input ourselves, just to be sure. _uses_standard_vertex_arrays = true; return; @@ -505,7 +498,7 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { << "Vertex attrib '" << name_buffer << "' was bound to the wrong slot!\n"; return; } - //_glgsg->_glBindAttribLocation(_glsl_program, loc, name_buffer); + // _glgsg->_glBindAttribLocation(_glsl_program, loc, name_buffer); _enabled_attribs.set_range(loc, bind._elements); } @@ -513,14 +506,12 @@ reflect_attribute(int i, char *name_buffer, GLsizei name_buflen) { } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::reflect_uniform_block -// Access: Public -// Description: Analyzes the uniform block and stores its format. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes the uniform block and stores its format. + */ void CLP(ShaderContext):: reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_buflen) { - //GLint offset = 0; + // GLint offset = 0; GLint data_size = 0; GLint param_count = 0; @@ -533,8 +524,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b } // We use a GeomVertexArrayFormat to describe the uniform buffer layout. - //GeomVertexArrayFormat block_format; - //block_format.set_pad_to(data_size); + // GeomVertexArrayFormat block_format; block_format.set_pad_to(data_size); // Get an array containing the indices of all the uniforms in this block. GLuint *indices = (GLuint *)alloca(param_count * sizeof(GLint)); @@ -651,32 +641,26 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b break; } - //GeomVertexColumn column(InternalName::make(name_buffer), - // num_components, numeric_type, contents, - // offsets[ui], 4, param_size, astrides[ui]); - //block_format.add_column(column); + // GeomVertexColumn column(InternalName::make(name_buffer), + // num_components, numeric_type, contents, offsets[ui], 4, param_size, + // astrides[ui]); block_format.add_column(column); } - //if (GLCAT.is_debug()) { - // GLCAT.debug() << "Active uniform block " << name << " has format:\n"; - // block_format.write(GLCAT.debug(false), 2); - //} + // if (GLCAT.is_debug()) { GLCAT.debug() << "Active uniform block " << name + // << " has format:\n"; block_format.write(GLCAT.debug(false), 2); } - //UniformBlock block; - //block._name = InternalName::make(name); - //block._format = GeomVertexArrayFormat::register_format(&block_format); - //block._buffer = 0; + // UniformBlock block; block._name = InternalName::make(name); block._format + // = GeomVertexArrayFormat::register_format(&block_format); block._buffer = + // 0; - //_uniform_blocks.push_back(block); + // _uniform_blocks.push_back(block); } #endif // !OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::reflect_uniform -// Access: Public -// Description: Analyzes a single uniform variable and considers -// how it should be handled and bound. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes a single uniform variable and considers how it should be handled + * and bound. + */ void CLP(ShaderContext):: reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { GLint param_size; @@ -688,9 +672,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { GLint p = _glgsg->_glGetUniformLocation(_glsl_program, name_buffer); - // Some NVidia drivers (361.43 for example) (incorrectly) include "internal" uniforms in - // the list starting with "_main_" (for example, "_main_0_gp5fp[0]") - // we need to skip those, because we don't know anything about them + // Some NVidia drivers (361.43 for example) (incorrectly) include "internal" + // uniforms in the list starting with "_main_" (for example, + // "_main_0_gp5fp[0]") we need to skip those, because we don't know anything + // about them if (strncmp(name_buffer, "_main_", 6) == 0) { GLCAT.warning() << "Ignoring uniform " << name_buffer << " which may be generated by buggy Nvidia driver.\n"; return; @@ -743,8 +728,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } size = matrix_name.size(); - // Now if the suffix that is left over is "Matrix", - // we know that it is supposed to be a matrix input. + // Now if the suffix that is left over is "Matrix", we know that it is + // supposed to be a matrix input. if (size > 6 && matrix_name.compare(size - 6, 6, "Matrix") == 0) { Shader::ShaderMatSpec bind; bind._id = arg_id; @@ -791,7 +776,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._part[1] = Shader::SMO_identity; } else if (matrix_name == "NormalMatrix") { - // This is really the upper 3x3 of the ModelViewMatrixInverseTranspose. + // This is really the upper 3x3 of the + // ModelViewMatrixInverseTranspose. bind._func = Shader::SMF_first; bind._part[0] = inverse ? Shader::SMO_model_to_apiview : Shader::SMO_apiview_to_model; @@ -1219,8 +1205,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } else if (strncmp(name_buffer, "osg_", 4) == 0) { string noprefix(name_buffer + 4); - // These inputs are supported by OpenSceneGraph. We can support - // them as well, to increase compatibility. + // These inputs are supported by OpenSceneGraph. We can support them as + // well, to increase compatibility. Shader::ShaderMatSpec bind; bind._id = arg_id; @@ -1272,8 +1258,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { return; } else if (noprefix == "FrameNumber") { - // We don't currently support ints with this mechanism, - // so we special-case this one. + // We don't currently support ints with this mechanism, so we special- + // case this one. if (param_type != GL_INT) { GLCAT.error() << "osg_FrameNumber should be uniform int\n"; } else { @@ -1283,7 +1269,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } } else { - // Tries to parse shorthand notations like mspos_XXX and trans_model_to_clip_of_XXX + // Tries to parse shorthand notations like mspos_XXX and + // trans_model_to_clip_of_XXX if (parse_and_set_short_hand_shader_vars(arg_id, param_type, param_size, _shader)) { return; } @@ -1365,9 +1352,9 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; PT(InternalName) iname = InternalName::make(param_name); if (iname->get_parent() != InternalName::get_root()) { - // It might be something like an attribute of a shader - // input, like a light parameter. It might also just be - // a custom struct parameter. We can't know yet, sadly. + // It might be something like an attribute of a shader input, like a + // light parameter. It might also just be a custom struct + // parameter. We can't know yet, sadly. bind._part[0] = Shader::SMO_mat_constant_x_attrib; bind._arg[0] = InternalName::make(param_name); bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame | Shader::SSD_transform; @@ -1389,9 +1376,9 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_FLOAT_VEC4: { PT(InternalName) iname = InternalName::make(param_name); if (iname->get_parent() != InternalName::get_root()) { - // It might be something like an attribute of a shader - // input, like a light parameter. It might also just be - // a custom struct parameter. We can't know yet, sadly. + // It might be something like an attribute of a shader input, like a + // light parameter. It might also just be a custom struct + // parameter. We can't know yet, sadly. Shader::ShaderMatSpec bind; bind._id = arg_id; switch (param_type) { @@ -1410,8 +1397,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { bind._func = Shader::SMF_first; bind._part[0] = Shader::SMO_vec_constant_x_attrib; bind._arg[0] = iname; - // We need SSD_transform since some attributes (eg. light - // position) have to be transformed to view space. + // We need SSD_transform since some attributes (eg. light position) + // have to be transformed to view space. bind._dep[0] = Shader::SSD_general | Shader::SSD_shaderinputs | Shader::SSD_frame | Shader::SSD_transform; bind._part[1] = Shader::SMO_identity; bind._arg[1] = NULL; @@ -1493,8 +1480,8 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { case GL_UNSIGNED_INT_IMAGE_CUBE_EXT: case GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT: case GL_UNSIGNED_INT_IMAGE_BUFFER_EXT: - // This won't really change at runtime, so we might as well - // bind once and then forget about it. + // This won't really change at runtime, so we might as well bind once + // and then forget about it. _glgsg->_glUniform1i(p, _glsl_img_inputs.size()); { ImageInput input; @@ -1587,12 +1574,10 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::get_sampler_texture_type -// Access: Public -// Description: Returns the texture type required for the given -// GL sampler type. Returns false if unsupported. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture type required for the given GL sampler type. Returns + * false if unsupported. + */ bool CLP(ShaderContext):: get_sampler_texture_type(int &out, GLenum param_type) { switch (param_type) { @@ -1720,22 +1705,18 @@ get_sampler_texture_type(int &out, GLenum param_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::Destructor -// Access: Public -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CLP(ShaderContext):: ~CLP(ShaderContext)() { // Don't call release_resources; we may not have an active context. } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::release_resources -// Access: Public -// Description: Should deallocate all system resources (such as -// vertex program handles or Cg contexts). -//////////////////////////////////////////////////////////////////// +/** + * Should deallocate all system resources (such as vertex program handles or + * Cg contexts). + */ void CLP(ShaderContext):: release_resources() { if (!_glgsg) { @@ -1760,13 +1741,10 @@ release_resources() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::bind -// Access: Public -// Description: This function is to be called to enable a new -// shader. It also initializes all of the shader's -// input parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function is to be called to enable a new shader. It also initializes + * all of the shader's input parameters. + */ void CLP(ShaderContext):: bind() { if (!_validated) { @@ -1787,11 +1765,9 @@ bind() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::unbind -// Access: Public -// Description: This function disables a currently-bound shader. -//////////////////////////////////////////////////////////////////// +/** + * This function disables a currently-bound shader. + */ void CLP(ShaderContext):: unbind() { if (GLCAT.is_spam()) { @@ -1802,14 +1778,11 @@ unbind() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::set_state_and_transform -// Access: Public -// Description: This function gets called whenever the RenderState -// or TransformState has changed, but the Shader -// itself has not changed. It loads new values into the -// shader's parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function gets called whenever the RenderState or TransformState has + * changed, but the Shader itself has not changed. It loads new values into + * the shader's parameters. + */ void CLP(ShaderContext):: set_state_and_transform(const RenderState *target_rs, const TransformState *modelview_transform, @@ -1885,14 +1858,11 @@ set_state_and_transform(const RenderState *target_rs, } } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::issue_parameters -// Access: Public -// Description: This function gets called whenever the RenderState -// or TransformState has changed, but the Shader -// itself has not changed. It loads new values into the -// shader's parameters. -//////////////////////////////////////////////////////////////////// +/** + * This function gets called whenever the RenderState or TransformState has + * changed, but the Shader itself has not changed. It loads new values into + * the shader's parameters. + */ void CLP(ShaderContext):: issue_parameters(int altered) { PStatGPUTimer timer(_glgsg, _glgsg->_draw_set_state_shader_parameters_pcollector); @@ -1903,8 +1873,8 @@ issue_parameters(int altered) { << " (altered 0x" << hex << altered << dec << ")\n"; } - // We have no way to track modifications to PTAs, so we assume that - // they are modified every frame and when we switch ShaderAttribs. + // We have no way to track modifications to PTAs, so we assume that they are + // modified every frame and when we switch ShaderAttribs. if (altered & (Shader::SSD_shaderinputs | Shader::SSD_frame)) { // If we have an osg_FrameNumber input, set it now. @@ -1971,7 +1941,8 @@ issue_parameters(int altered) { GLCAT.error() << "Cannot pass floating-point data to integer shader input '" << spec._id._name << "'\n"; - // Deactivate it to make sure the user doesn't get flooded with this error. + // Deactivate it to make sure the user doesn't get flooded with this + // error. spec._dep[0] = 0; spec._dep[1] = 0; @@ -1989,7 +1960,8 @@ issue_parameters(int altered) { case Shader::SPT_double: GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n"; - // Deactivate it to make sure the user doesn't get flooded with this error. + // Deactivate it to make sure the user doesn't get flooded with this + // error. spec._dep[0] = 0; spec._dep[1] = 0; @@ -2069,12 +2041,9 @@ issue_parameters(int altered) { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::update_transform_table -// Access: Public -// Description: Changes the active transform table, used for hardware -// skinning. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active transform table, used for hardware skinning. + */ void CLP(ShaderContext):: update_transform_table(const TransformTable *table) { LMatrix4f *matrices = (LMatrix4f *)alloca(_transform_table_size * 64); @@ -2100,12 +2069,9 @@ update_transform_table(const TransformTable *table) { GL_FALSE, (float *)matrices); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::update_slider_table -// Access: Public -// Description: Changes the active slider table, used for hardware -// skinning. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active slider table, used for hardware skinning. + */ void CLP(ShaderContext):: update_slider_table(const SliderTable *table) { float *sliders = (float *)alloca(_slider_table_size * 4); @@ -2121,11 +2087,9 @@ update_slider_table(const SliderTable *table) { _glgsg->_glUniform1fv(_slider_table_index, _slider_table_size, sliders); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::disable_shader_vertex_arrays -// Access: Public -// Description: Disable all the vertex arrays used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the vertex arrays used by this shader. + */ void CLP(ShaderContext):: disable_shader_vertex_arrays() { if (!valid()) { @@ -2144,22 +2108,19 @@ disable_shader_vertex_arrays() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::update_shader_vertex_arrays -// Access: Public -// Description: Disables all vertex arrays used by the previous -// shader, then enables all the vertex arrays needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -//////////////////////////////////////////////////////////////////// +/** + * Disables all vertex arrays used by the previous shader, then enables all + * the vertex arrays needed by this shader. Extracts the relevant vertex + * array data from the gsg. + */ bool CLP(ShaderContext):: update_shader_vertex_arrays(ShaderContext *prev, bool force) { if (!valid()) { return true; } - // Get the active ColorAttrib. We'll need it to determine how to - // apply vertex colors. + // Get the active ColorAttrib. We'll need it to determine how to apply + // vertex colors. const ColorAttrib *color_attrib; _state_rs->get_attrib_def(color_attrib); @@ -2167,7 +2128,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { #ifndef OPENGLES if (_glgsg->_use_vertex_attrib_binding) { - // Use experimental new separated format/binding state. + // Use experimental new separated formatbinding state. const GeomVertexDataPipelineReader *data_reader = _glgsg->_data_reader; for (int ai = 0; ai < data_reader->get_num_arrays(); ++ai) { @@ -2327,11 +2288,9 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::disable_shader_texture_bindings -// Access: Public -// Description: Disable all the texture bindings used by this shader. -//////////////////////////////////////////////////////////////////// +/** + * Disable all the texture bindings used by this shader. + */ void CLP(ShaderContext):: disable_shader_texture_bindings() { if (!valid()) { @@ -2352,9 +2311,9 @@ disable_shader_texture_bindings() { } if (_glgsg->_supports_multi_bind) { - // There are non-bindless textures to unbind, and we're lazy, - // so let's go and unbind everything after this point using one - // multi-bind call, and then break out of the loop. + // There are non-bindless textures to unbind, and we're lazy, so let's + // go and unbind everything after this point using one multi-bind call, + // and then break out of the loop. _glgsg->_glBindTextures(i, _shader->_tex_spec.size() - i, NULL); break; } @@ -2425,22 +2384,16 @@ disable_shader_texture_bindings() { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: GLShaderContext::update_shader_texture_bindings -// Access: Public -// Description: Disables all texture bindings used by the previous -// shader, then enables all the texture bindings needed -// by this shader. Extracts the relevant vertex array -// data from the gsg. -// The current implementation is inefficient, because -// it may unnecessarily disable textures then immediately -// reenable them. We may optimize this someday. -//////////////////////////////////////////////////////////////////// +/** + * Disables all texture bindings used by the previous shader, then enables all + * the texture bindings needed by this shader. Extracts the relevant vertex + * array data from the gsg. The current implementation is inefficient, + * because it may unnecessarily disable textures then immediately reenable + * them. We may optimize this someday. + */ void CLP(ShaderContext):: update_shader_texture_bindings(ShaderContext *prev) { - //if (prev) { - // prev->disable_shader_texture_bindings(); - //} + // if (prev) { prev->disable_shader_texture_bindings(); } if (!valid()) { return; @@ -2449,7 +2402,8 @@ update_shader_texture_bindings(ShaderContext *prev) { #ifndef OPENGLES GLbitfield barriers = 0; - // First bind all the 'image units'; a bit of an esoteric OpenGL feature right now. + // First bind all the 'image units'; a bit of an esoteric OpenGL feature + // right now. int num_image_units = min(_glsl_img_inputs.size(), (size_t)_glgsg->_max_image_units); if (num_image_units > 0) { @@ -2464,7 +2418,8 @@ update_shader_texture_bindings(ShaderContext *prev) { tex = param->get_texture(); } else if (sinp->get_value_type() == ShaderInput::M_texture) { - // People find it convenient to be able to pass a texture without further ado. + // People find it convenient to be able to pass a texture without + // further ado. tex = sinp->get_texture(); } else { @@ -2497,7 +2452,7 @@ update_shader_texture_bindings(ShaderContext *prev) { _glgsg->_glBindImageTexture(i, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R8); } else { - //TODO: automatically convert to sized type instead of plain GL_RGBA + // TODO: automatically convert to sized type instead of plain GL_RGBA // If a base type is used, it will crash. GLenum internal_format = gtc->_internal_format; if (internal_format == GL_RGBA || internal_format == GL_RGB) { @@ -2569,8 +2524,8 @@ update_shader_texture_bindings(ShaderContext *prev) { PT(Texture) tex = _glgsg->fetch_specified_texture(spec, sampler, view); if (tex.is_null()) { - // Apply a white texture in order to make it easier to use a shader - // that takes a texture on a model that doesn't have a texture applied. + // Apply a white texture in order to make it easier to use a shader that + // takes a texture on a model that doesn't have a texture applied. if (multi_bind) { textures[i] = _glgsg->get_white_texture(); samplers[i] = 0; @@ -2591,7 +2546,8 @@ update_shader_texture_bindings(ShaderContext *prev) { << "Sampler type of GLSL shader input p3d_Texture" << spec._stage << " does not match type of texture " << *tex << ".\n"; } - //TODO: also check whether shadow sampler textures have shadow filter enabled. + // TODO: also check whether shadow sampler textures have shadow filter + // enabled. } CLP(TextureContext) *gtc = DCAST(CLP(TextureContext), tex->prepare_now(view, _glgsg->_prepared_objects, _glgsg)); @@ -2606,15 +2562,16 @@ update_shader_texture_bindings(ShaderContext *prev) { GLint p = spec._id._seqno; #ifndef OPENGLES - // If it was recently written to, we will have to issue a memory barrier soon. + // If it was recently written to, we will have to issue a memory barrier + // soon. if (gtc->needs_barrier(GL_TEXTURE_FETCH_BARRIER_BIT)) { barriers |= GL_TEXTURE_FETCH_BARRIER_BIT; } // Try bindless texturing first, if supported. if (gl_use_bindless_texture && _glgsg->_supports_bindless_texture) { - // We demand the real texture, since we won't be able - // to change the texture properties after this point. + // We demand the real texture, since we won't be able to change the + // texture properties after this point. if (multi_bind) { textures[i] = 0; samplers[i] = 0; @@ -2628,8 +2585,8 @@ update_shader_texture_bindings(ShaderContext *prev) { gtc->make_handle_resident(); gtc->set_active(true); - // Check if we have already specified this texture handle. - // If so, no need to call glUniformHandle again. + // Check if we have already specified this texture handle. If so, no + // need to call glUniformHandle again. pmap::const_iterator it; it = _glsl_uniform_handles.find(p); if (it != _glsl_uniform_handles.end() && it->second == handle) { @@ -2644,8 +2601,8 @@ update_shader_texture_bindings(ShaderContext *prev) { } #endif - // Bindless texturing wasn't supported or didn't work, so - // let's just bind the texture normally. + // Bindless texturing wasn't supported or didn't work, so let's just bind + // the texture normally. #ifndef OPENGLES if (multi_bind) { // Multi-bind case. @@ -2692,11 +2649,9 @@ update_shader_texture_bindings(ShaderContext *prev) { _glgsg->report_my_gl_errors(); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::glsl_report_shader_errors -// Access: Private -// Description: This subroutine prints the infolog for a shader. -//////////////////////////////////////////////////////////////////// +/** + * This subroutine prints the infolog for a shader. + */ void CLP(ShaderContext):: glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { char *info_log; @@ -2716,15 +2671,15 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { return; } - // Parse the errors so that we can substitute in actual file - // locations instead of source indices. + // Parse the errors so that we can substitute in actual file locations + // instead of source indices. istringstream log(info_log); string line; while (getline(log, line)) { int fileno, lineno; int prefixlen = 0; - // First is AMD/Intel driver syntax, second is NVIDIA syntax. + // First is AMDIntel driver syntax, second is NVIDIA syntax. if (sscanf(line.c_str(), "ERROR: %d:%d: %n", &fileno, &lineno, &prefixlen) == 2 && prefixlen > 0) { @@ -2756,11 +2711,9 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::glsl_report_program_errors -// Access: Private -// Description: This subroutine prints the infolog for a program. -//////////////////////////////////////////////////////////////////// +/** + * This subroutine prints the infolog for a program. + */ void CLP(ShaderContext):: glsl_report_program_errors(GLuint program, bool fatal) { char *info_log; @@ -2787,11 +2740,9 @@ glsl_report_program_errors(GLuint program, bool fatal) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::glsl_compile_shader -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CLP(ShaderContext):: glsl_compile_shader(Shader::ShaderType type) { static const char *types[] = {"", "vertex ", "fragment ", "geometry ", @@ -2874,11 +2825,9 @@ glsl_compile_shader(Shader::ShaderType type) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::glsl_compile_and_link -// Access: Private -// Description: This subroutine compiles a GLSL shader. -//////////////////////////////////////////////////////////////////// +/** + * This subroutine compiles a GLSL shader. + */ bool CLP(ShaderContext):: glsl_compile_and_link() { _glsl_shaders.clear(); @@ -2933,13 +2882,13 @@ glsl_compile_and_link() { if (!_shader->get_text(Shader::ST_geometry).empty()) { valid &= glsl_compile_shader(Shader::ST_geometry); - //XXX Actually, it turns out that this is unavailable in the core - // version of geometry shaders. Probably no need to bother with it. + // XXX Actually, it turns out that this is unavailable in the core version + // of geometry shaders. Probably no need to bother with it. - //nassertr(_glgsg->_glProgramParameteri != NULL, false); - //GLint max_vertices; - //glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &max_vertices); - //_glgsg->_glProgramParameteri(_glsl_program, GL_GEOMETRY_VERTICES_OUT_ARB, max_vertices); + // nassertr(_glgsg->_glProgramParameteri != NULL, false); GLint + // max_vertices; glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, + // &max_vertices); _glgsg->_glProgramParameteri(_glsl_program, + // GL_GEOMETRY_VERTICES_OUT_ARB, max_vertices); } #endif @@ -2955,11 +2904,9 @@ glsl_compile_and_link() { valid &= glsl_compile_shader(Shader::ST_compute); } - // There might be warnings, so report those. - //GLSLShaders::const_iterator it; - //for (it = _glsl_shaders.begin(); it != _glsl_shaders.end(); ++it) { - // glsl_report_shader_errors(*it); - //} + // There might be warnings, so report those. GLSLShaders::const_iterator + // it; for (it = _glsl_shaders.begin(); it != _glsl_shaders.end(); ++it) { + // glsl_report_shader_errors(*it); } // Under OpenGL's compatibility profile, we have to make sure that we bind // something to attribute 0. Make sure that this is the position array. @@ -2967,8 +2914,8 @@ glsl_compile_and_link() { _glgsg->_glBindAttribLocation(_glsl_program, 0, "vertex"); // While we're at it, let's also map these to fixed locations. These - // attributes were historically fixed to these locations, so it might - // help a buggy driver. + // attributes were historically fixed to these locations, so it might help a + // buggy driver. _glgsg->_glBindAttribLocation(_glsl_program, 2, "p3d_Normal"); _glgsg->_glBindAttribLocation(_glsl_program, 3, "p3d_Color"); @@ -2981,7 +2928,8 @@ glsl_compile_and_link() { _glgsg->_glBindAttribLocation(_glsl_program, 8, "texcoord"); } - // If we requested to retrieve the shader, we should indicate that before linking. + // If we requested to retrieve the shader, we should indicate that before + // linking. #ifndef OPENGLES bool retrieve_binary = false; if (_glgsg->_supports_get_program_binary) { diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 9f51dd5973..4209ec66fb 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -1,16 +1,15 @@ -// Filename: glShaderContext_src.h -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glShaderContext_src.h + * @author jyelon + * @date 2005-09-01 + */ #ifndef OPENGLES_1 @@ -24,10 +23,9 @@ class CLP(GraphicsStateGuardian); -//////////////////////////////////////////////////////////////////// -// Class : GLShaderContext -// Description : xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ class EXPCL_GL CLP(ShaderContext) : public ShaderContext { public: friend class CLP(GraphicsStateGuardian); @@ -73,15 +71,11 @@ private: CPT(TransformState) _modelview_transform; CPT(TransformState) _projection_transform; - //struct ParamContext { - // CPT(InternalName) _name; - // GLint _location; - // GLsizei _count; - // WPT(ParamValue) _value; - // UpdateSeq _updated; - //}; - //typedef pvector ParamContexts; - //ParamContexts _params; +/* + * struct ParamContext { CPT(InternalName) _name; GLint _location; GLsizei + * _count; WPT(ParamValue) _value; UpdateSeq _updated; }; typedef + * pvector ParamContexts; ParamContexts _params; + */ BitMask32 _enabled_attribs; GLint _color_attrib_index; diff --git a/panda/src/glstuff/glTextureContext_src.I b/panda/src/glstuff/glTextureContext_src.I index 37aa40d50c..d4b4232513 100644 --- a/panda/src/glstuff/glTextureContext_src.I +++ b/panda/src/glstuff/glTextureContext_src.I @@ -1,23 +1,19 @@ -// Filename: glTextureContext_src.I -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTextureContext_src.I + * @author drose + * @date 1999-10-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(TextureContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(TextureContext):: CLP(TextureContext)(CLP(GraphicsStateGuardian) *glgsg, PreparedGraphicsObjects *pgo, Texture *tex, int view) : diff --git a/panda/src/glstuff/glTextureContext_src.cxx b/panda/src/glstuff/glTextureContext_src.cxx index c41116e33b..8639b898a2 100644 --- a/panda/src/glstuff/glTextureContext_src.cxx +++ b/panda/src/glstuff/glTextureContext_src.cxx @@ -1,46 +1,38 @@ -// Filename: glTextureContext_src.cxx -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTextureContext_src.cxx + * @author drose + * @date 1999-10-07 + */ #include "pnotify.h" TypeHandle CLP(TextureContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CLP(TextureContext)::Denstructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(TextureContext):: ~CLP(TextureContext)() { // Don't call glDeleteTextures; we may not have an active context. } -//////////////////////////////////////////////////////////////////// -// Function: GLTextureContext::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void CLP(TextureContext):: evict_lru() { dequeue_lru(); @@ -61,12 +53,10 @@ evict_lru() { mark_unloaded(); } -//////////////////////////////////////////////////////////////////// -// Function: GLTextureContext::reset_data -// Access: Public -// Description: Resets the texture object to a new one so a new GL -// texture object can be uploaded. -//////////////////////////////////////////////////////////////////// +/** + * Resets the texture object to a new one so a new GL texture object can be + * uploaded. + */ void CLP(TextureContext):: reset_data() { #ifndef OPENGLES @@ -83,8 +73,8 @@ reset_data() { _buffer = 0; } - // We still need a valid index number, though, in case we want to - // re-load the texture later. + // We still need a valid index number, though, in case we want to re-load + // the texture later. glGenTextures(1, &_index); _handle = 0; @@ -103,11 +93,9 @@ reset_data() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GLTextureContext::make_handle_resident -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CLP(TextureContext):: make_handle_resident() { #ifndef OPENGLES @@ -121,13 +109,10 @@ make_handle_resident() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CLP(TextureContext)::get_handle -// Access: Public -// Description: Returns a handle for this texture. Once this has -// been created, the texture data may still be updated, -// but its properties may not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a handle for this texture. Once this has been created, the texture + * data may still be updated, but its properties may not. + */ INLINE GLuint64 CLP(TextureContext):: get_handle() { #ifdef OPENGLES @@ -147,11 +132,9 @@ get_handle() { } #ifndef OPENGLES -//////////////////////////////////////////////////////////////////// -// Function: GLTextureContext::needs_barrier -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool CLP(TextureContext):: needs_barrier(GLbitfield barrier) { if (!gl_enable_memory_barriers) { @@ -168,29 +151,26 @@ needs_barrier(GLbitfield barrier) { _glgsg->_textures_needing_framebuffer_barrier.count(this))); } -//////////////////////////////////////////////////////////////////// -// Function: GLTextureContext::mark_incoherent -// Access: Public -// Description: Mark a texture as needing a memory barrier, since -// a non-coherent read or write just happened to it. -// If 'wrote' is true, it was written to. -//////////////////////////////////////////////////////////////////// +/** + * Mark a texture as needing a memory barrier, since a non-coherent read or + * write just happened to it. If 'wrote' is true, it was written to. + */ void CLP(TextureContext):: mark_incoherent(bool wrote) { if (!gl_enable_memory_barriers) { return; } - // If we only read from it, the next read operation won't need - // another barrier, since it'll be reading the same data. + // If we only read from it, the next read operation won't need another + // barrier, since it'll be reading the same data. if (wrote) { _glgsg->_textures_needing_fetch_barrier.insert(this); } - // We could still write to it before we read from it, so we have - // to always insert these barriers. This could be slightly - // optimized so that we don't issue a barrier between consecutive - // image reads, but that may not be worth the trouble. + // We could still write to it before we read from it, so we have to always + // insert these barriers. This could be slightly optimized so that we don't + // issue a barrier between consecutive image reads, but that may not be + // worth the trouble. _glgsg->_textures_needing_image_access_barrier.insert(this); _glgsg->_textures_needing_update_barrier.insert(this); _glgsg->_textures_needing_framebuffer_barrier.insert(this); diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h index 57fd2fc790..8a36882f26 100644 --- a/panda/src/glstuff/glTextureContext_src.h +++ b/panda/src/glstuff/glTextureContext_src.h @@ -1,16 +1,15 @@ -// Filename: glTextureContext_src.h -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTextureContext_src.h + * @author drose + * @date 1999-10-07 + */ #include "pandabase.h" #include "textureContext.h" @@ -20,10 +19,9 @@ class CLP(GraphicsStateGuardian); class CLP(SamplerContext); -//////////////////////////////////////////////////////////////////// -// Class : GLTextureContext -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_GL CLP(TextureContext) : public TextureContext { public: INLINE CLP(TextureContext)(CLP(GraphicsStateGuardian) *glgsg, @@ -55,9 +53,9 @@ public: GLuint64 _handle; bool _handle_resident; - // These are the parameters that we specified with the last - // glTexImage2D() or glTexStorage2D() call. If none of these have - // changed, we can reload the texture image with a glTexSubImage2D(). + // These are the parameters that we specified with the last glTexImage2D() + // or glTexStorage2D() call. If none of these have changed, we can reload + // the texture image with a glTexSubImage2D(). bool _has_storage; bool _immutable; bool _uses_mipmaps; @@ -90,4 +88,3 @@ private: }; #include "glTextureContext_src.I" - diff --git a/panda/src/glstuff/glTimerQueryContext_src.I b/panda/src/glstuff/glTimerQueryContext_src.I index 594cf90eea..c898c30261 100644 --- a/panda/src/glstuff/glTimerQueryContext_src.I +++ b/panda/src/glstuff/glTimerQueryContext_src.I @@ -1,23 +1,19 @@ -// Filename: glTimerQueryContext_src.I -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTimerQueryContext_src.I + * @author rdb + * @date 2014-08-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(TimerQueryContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(TimerQueryContext):: CLP(TimerQueryContext)(CLP(GraphicsStateGuardian) *glgsg, int pstats_index) : diff --git a/panda/src/glstuff/glTimerQueryContext_src.cxx b/panda/src/glstuff/glTimerQueryContext_src.cxx index 29fbe53f5a..36cfefb91e 100644 --- a/panda/src/glstuff/glTimerQueryContext_src.cxx +++ b/panda/src/glstuff/glTimerQueryContext_src.cxx @@ -1,16 +1,15 @@ -// Filename: glTimerQueryContext_src.cxx -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTimerQueryContext_src.cxx + * @author rdb + * @date 2014-08-22 + */ #include "pnotify.h" #include "dcast.h" @@ -21,18 +20,16 @@ TypeHandle CLP(TimerQueryContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLTimerQueryContext::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLP(TimerQueryContext):: ~CLP(TimerQueryContext)() { if (_index != 0) { - // Tell the GSG to recycle this index when it gets around to it. - // If it has already shut down, though, too bad. This means we - // never get to free this index, but presumably the app is - // already shutting down anyway. + // Tell the GSG to recycle this index when it gets around to it. If it + // has already shut down, though, too bad. This means we never get to + // free this index, but presumably the app is already shutting down + // anyway. if (!_glgsg.was_deleted()) { LightMutexHolder holder(_glgsg->_lock); _glgsg->_deleted_queries.push_back(_index); @@ -41,15 +38,12 @@ CLP(TimerQueryContext):: } } -//////////////////////////////////////////////////////////////////// -// Function: GLTimerQueryContext::is_answer_ready -// Access: Public, Virtual -// Description: Returns true if the query's answer is ready, false -// otherwise. If this returns false, the application -// must continue to poll until it returns true. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the query's answer is ready, false otherwise. If this + * returns false, the application must continue to poll until it returns true. + * + * It is only valid to call this from the draw thread. + */ bool CLP(TimerQueryContext):: is_answer_ready() const { GLuint result; @@ -58,34 +52,27 @@ is_answer_ready() const { return (result != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GLTimerQueryContext::waiting_for_answer -// Access: Public, Virtual -// Description: Requests the graphics engine to expedite the pending -// answer--the application is now waiting until the -// answer is ready. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Requests the graphics engine to expedite the pending answer--the + * application is now waiting until the answer is ready. + * + * It is only valid to call this from the draw thread. + */ void CLP(TimerQueryContext):: waiting_for_answer() { PStatTimer timer(GraphicsStateGuardian::_wait_timer_pcollector); glFlush(); } -//////////////////////////////////////////////////////////////////// -// Function: TimerQueryContext::get_timestamp -// Access: Public, Virtual -// Description: Returns the timestamp that is the result of this -// timer query. There's no guarantee about which -// clock this uses, the only guarantee is that -// subtracting a start time from an end time should -// yield a time in seconds. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp that is the result of this timer query. There's no + * guarantee about which clock this uses, the only guarantee is that + * subtracting a start time from an end time should yield a time in seconds. + * If is_answer_ready() did not return true, this function may block before it + * returns. + * + * It is only valid to call this from the draw thread. + */ double CLP(TimerQueryContext):: get_timestamp() const { GLuint64 time_ns; diff --git a/panda/src/glstuff/glTimerQueryContext_src.h b/panda/src/glstuff/glTimerQueryContext_src.h index aeff8b1b50..07709bc7af 100644 --- a/panda/src/glstuff/glTimerQueryContext_src.h +++ b/panda/src/glstuff/glTimerQueryContext_src.h @@ -1,16 +1,15 @@ -// Filename: glTimerQueryContext_src.h -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glTimerQueryContext_src.h + * @author rdb + * @date 2014-08-22 + */ #include "pandabase.h" #include "timerQueryContext.h" @@ -21,14 +20,11 @@ class GraphicsStateGuardian; #ifndef OPENGLES // Timer queries not supported by OpenGL ES. -//////////////////////////////////////////////////////////////////// -// Class : GLTimerQueryContext -// Description : This class manages a timer query that can be used -// by a PStatGPUTimer to measure the time a task takes -// to execute on the GPU. -// This records the current timestamp; a pair of these -// is usually used to get the elapsed time. -//////////////////////////////////////////////////////////////////// +/** + * This class manages a timer query that can be used by a PStatGPUTimer to + * measure the time a task takes to execute on the GPU. This records the + * current timestamp; a pair of these is usually used to get the elapsed time. + */ class EXPCL_GL CLP(TimerQueryContext) : public TimerQueryContext { public: INLINE CLP(TimerQueryContext)(CLP(GraphicsStateGuardian) *glgsg, @@ -65,4 +61,3 @@ private: #include "glTimerQueryContext_src.I" #endif // OPENGLES - diff --git a/panda/src/glstuff/glVertexBufferContext_src.I b/panda/src/glstuff/glVertexBufferContext_src.I index 3cc7dd67a3..ea985d7bfd 100644 --- a/panda/src/glstuff/glVertexBufferContext_src.I +++ b/panda/src/glstuff/glVertexBufferContext_src.I @@ -1,26 +1,22 @@ -// Filename: glVertexBufferContext_src.I -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glVertexBufferContext_src.I + * @author drose + * @date 2005-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLP(VertexBufferContext)::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLP(VertexBufferContext):: CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *glgsg, - PreparedGraphicsObjects *pgo, + PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : VertexBufferContext(pgo, data), _glgsg(glgsg) diff --git a/panda/src/glstuff/glVertexBufferContext_src.cxx b/panda/src/glstuff/glVertexBufferContext_src.cxx index 73ef6ffa67..13889e111c 100644 --- a/panda/src/glstuff/glVertexBufferContext_src.cxx +++ b/panda/src/glstuff/glVertexBufferContext_src.cxx @@ -1,34 +1,28 @@ -// Filename: glVertexBufferContext_src.cxx -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glVertexBufferContext_src.cxx + * @author drose + * @date 2005-03-17 + */ TypeHandle CLP(VertexBufferContext)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GLVertexBufferContext::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void CLP(VertexBufferContext):: evict_lru() { dequeue_lru(); @@ -46,8 +40,8 @@ evict_lru() { // Free the buffer. _glgsg->_glDeleteBuffers(1, &_index); - // We still need a valid index number, though, in case we want to - // re-load the buffer later. + // We still need a valid index number, though, in case we want to re-load + // the buffer later. _glgsg->_glGenBuffers(1, &_index); update_data_size_bytes(0); diff --git a/panda/src/glstuff/glVertexBufferContext_src.h b/panda/src/glstuff/glVertexBufferContext_src.h index a9806fd154..6833ce4eec 100644 --- a/panda/src/glstuff/glVertexBufferContext_src.h +++ b/panda/src/glstuff/glVertexBufferContext_src.h @@ -1,16 +1,15 @@ -// Filename: glVertexBufferContext_src.h -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glVertexBufferContext_src.h + * @author drose + * @date 2005-03-17 + */ #include "pandabase.h" #include "vertexBufferContext.h" @@ -18,15 +17,13 @@ class CLP(GraphicsStateGuardian); -//////////////////////////////////////////////////////////////////// -// Class : GLVertexBufferContext -// Description : Caches a GeomVertexArrayData on the GL as a buffer -// object. -//////////////////////////////////////////////////////////////////// +/** + * Caches a GeomVertexArrayData on the GL as a buffer object. + */ class EXPCL_GL CLP(VertexBufferContext) : public VertexBufferContext { public: INLINE CLP(VertexBufferContext)(CLP(GraphicsStateGuardian) *glgsg, - PreparedGraphicsObjects *pgo, + PreparedGraphicsObjects *pgo, GeomVertexArrayData *data); ALLOC_DELETED_CHAIN(CLP(VertexBufferContext)); @@ -56,4 +53,3 @@ private: }; #include "glVertexBufferContext_src.I" - diff --git a/panda/src/glstuff/glmisc_src.cxx b/panda/src/glstuff/glmisc_src.cxx index a76c4b97ba..c44a36aaf6 100644 --- a/panda/src/glstuff/glmisc_src.cxx +++ b/panda/src/glstuff/glmisc_src.cxx @@ -1,16 +1,15 @@ -// Filename: glmisc_src.cxx -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glmisc_src.cxx + * @author drose + * @date 2004-02-09 + */ #include "pandaSystem.h" @@ -338,7 +337,7 @@ void CLP(init_classes)() { PandaSystem *ps = PandaSystem::get_global_ptr(); ps->add_system(GLSYSTEM_NAME); - // We can't add any tags defining the available OpenGL capabilities, - // since we won't know those until we create a graphics context (and - // the answer may be different for different contexts). + // We can't add any tags defining the available OpenGL capabilities, since + // we won't know those until we create a graphics context (and the answer + // may be different for different contexts). } diff --git a/panda/src/glstuff/glmisc_src.h b/panda/src/glstuff/glmisc_src.h index ec1db27cf1..b008aeb8d3 100644 --- a/panda/src/glstuff/glmisc_src.h +++ b/panda/src/glstuff/glmisc_src.h @@ -1,16 +1,15 @@ -// Filename: glmisc_src.h -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glmisc_src.h + * @author drose + * @date 2004-02-09 + */ #include "pandabase.h" #include "configVariableBool.h" @@ -19,8 +18,8 @@ #include "geomEnums.h" #include "coordinateSystem.h" -// Define some macros to transparently map to the double or float -// versions of the OpenGL function names. +// Define some macros to transparently map to the double or float versions of +// the OpenGL function names. #ifndef GLf #ifndef STDFLOAT_DOUBLE @@ -39,7 +38,7 @@ #endif // GLf -//#define GSG_VERBOSE 1 +// #define GSG_VERBOSE 1 extern ConfigVariableInt gl_version; extern EXPCL_PANDAGL ConfigVariableBool gl_support_fbo; diff --git a/panda/src/glstuff/glpure.cxx b/panda/src/glstuff/glpure.cxx index ab9268ba64..15d3c7c4aa 100644 --- a/panda/src/glstuff/glpure.cxx +++ b/panda/src/glstuff/glpure.cxx @@ -1,25 +1,22 @@ -// Filename: glpure.cxx -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glpure.cxx + * @author drose + * @date 2004-02-09 + */ #include "pandabase.h" -// This is the one file in this directory which is actually compiled. -// It exists just so we can have some symbols and make the compiler -// happy. +// This is the one file in this directory which is actually compiled. It +// exists just so we can have some symbols and make the compiler happy. #if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) __declspec(dllexport) #endif int glpure; - diff --git a/panda/src/glstuff/glstuff_src.cxx b/panda/src/glstuff/glstuff_src.cxx index 74a72c886a..af8bcc1df3 100644 --- a/panda/src/glstuff/glstuff_src.cxx +++ b/panda/src/glstuff/glstuff_src.cxx @@ -1,21 +1,20 @@ -// Filename: glstuff_src.cxx -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glstuff_src.cxx + * @author drose + * @date 2004-02-09 + */ -// This .cxx file includes all of the gl-related .cxx files in this -// directory. It works just like glstuff_src.h; see the comments in -// that file for an explanation for what you're supposed to declare in -// order to include this file. +// This .cxx file includes all of the gl-related .cxx files in this directory. +// It works just like glstuff_src.h; see the comments in that file for an +// explanation for what you're supposed to declare in order to include this +// file. #include "glmisc_src.cxx" #include "glTextureContext_src.cxx" diff --git a/panda/src/glstuff/glstuff_src.h b/panda/src/glstuff/glstuff_src.h index 280471ddca..46edb3ac83 100644 --- a/panda/src/glstuff/glstuff_src.h +++ b/panda/src/glstuff/glstuff_src.h @@ -1,35 +1,32 @@ -// Filename: glstuff_src.h -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glstuff_src.h + * @author drose + * @date 2004-02-09 + */ -// This header file includes all of the gl-related header files in -// this directory. To include a CLP(GraphicsStateGuardian)-like thing of -// some kind (e.g., "true" GL calls, or Mesa-prefixed GL calls, or -// some such), define the following symbols and #include this header -// file. +// This header file includes all of the gl-related header files in this +// directory. To include a CLP(GraphicsStateGuardian)-like thing of some kind +// (e.g., "true" GL calls, or Mesa-prefixed GL calls, or some such), define +// the following symbols and #include this header file. -// #define CLP(name): returns name prefixed by the class prefix, e.g. GL##name -// #define CLASSPREFIX_QUOTED: the quoted prefix of CLP, e.g. "GL" -// #define CONFIGOBJ: a Configrc object, e.g. config_glgsg -// #define GLCAT: a Notify category, e.g. glgsg_cat -// #define EXPCL_GL, EXPTP_GL: according to the DLL currently being compiled. +// #define CLP(name): returns name prefixed by the class prefix, e.g. +// GL##name #define CLASSPREFIX_QUOTED: the quoted prefix of CLP, e.g. "GL" +// #define CONFIGOBJ: a Configrc object, e.g. config_glgsg #define GLCAT: a +// Notify category, e.g. glgsg_cat #define EXPCL_GL, EXPTP_GL: according to +// the DLL currently being compiled. -// Also, be sure you include the appropriate gl.h header -// file to get all the standard GL symbols declared. GL extensions -// are included here via glext.h. +// Also, be sure you include the appropriate gl.h header file to get all the +// standard GL symbols declared. GL extensions are included here via glext.h. -// This file is not protected from multiple inclusion; it may need to -// be included multiple times. +// This file is not protected from multiple inclusion; it may need to be +// included multiple times. #include "glmisc_src.h" #include "glTextureContext_src.h" diff --git a/panda/src/glstuff/glstuff_undef_src.h b/panda/src/glstuff/glstuff_undef_src.h index 30907ee538..4e56cba47b 100644 --- a/panda/src/glstuff/glstuff_undef_src.h +++ b/panda/src/glstuff/glstuff_undef_src.h @@ -1,19 +1,18 @@ -// Filename: glstuff_undef_src.h -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glstuff_undef_src.h + * @author drose + * @date 2004-02-09 + */ -// This header file #undefs all the stuff you had to #define to -// include glstuff_src.h or glstuff_src.cxx. +// This header file #undefs all the stuff you had to #define to include +// glstuff_src.h or glstuff_src.cxx. #undef GLP #undef CLP @@ -22,4 +21,3 @@ #undef GLCAT #undef EXPCL #undef EXPTP - diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index d3b7d97a5b..b253c0abf9 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/panda/src/glxdisplay/config_glxdisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_glxdisplay.cxx -// Created by: cary (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glxdisplay.cxx + * @author cary + * @date 1999-10-07 + */ #include "config_glxdisplay.h" #include "glxGraphicsBuffer.h" @@ -65,14 +64,12 @@ ConfigVariableBool glx_support_pixmap "are usually slower than pbuffer-based buffers.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libglxdisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libglxdisplay() { static bool initialized = false; diff --git a/panda/src/glxdisplay/config_glxdisplay.h b/panda/src/glxdisplay/config_glxdisplay.h index d14001d31d..7c8aadc3b9 100644 --- a/panda/src/glxdisplay/config_glxdisplay.h +++ b/panda/src/glxdisplay/config_glxdisplay.h @@ -1,16 +1,15 @@ -// Filename: config_glxdisplay.h -// Created by: cary (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_glxdisplay.h + * @author cary + * @date 1999-10-07 + */ #ifndef __CONFIG_GLXDISPLAY_H__ #define __CONFIG_GLXDISPLAY_H__ diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.I b/panda/src/glxdisplay/glxGraphicsBuffer.I index 8e3f0e88f8..db94430ff0 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.I +++ b/panda/src/glxdisplay/glxGraphicsBuffer.I @@ -1,14 +1,12 @@ -// Filename: glxGraphicsBuffer.I -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsBuffer.I + * @author drose + * @date 2004-02-09 + */ diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.cxx b/panda/src/glxdisplay/glxGraphicsBuffer.cxx index 1e2ead3f44..fb70d352dc 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.cxx +++ b/panda/src/glxdisplay/glxGraphicsBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: glxGraphicsBuffer.cxx -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsBuffer.cxx + * @author drose + * @date 2004-02-09 + */ #include "glxGraphicsBuffer.h" #include "glxGraphicsStateGuardian.h" @@ -23,13 +22,11 @@ TypeHandle glxGraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsBuffer:: -glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, +glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -43,30 +40,25 @@ glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, _display = glx_pipe->get_display(); _pbuffer = None; - // Since the pbuffer never gets flipped, we get screenshots from the - // same buffer we draw into. + // Since the pbuffer never gets flipped, we get screenshots from the same + // buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsBuffer:: ~glxGraphicsBuffer() { nassertv(_pbuffer == None); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool glxGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -81,10 +73,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { DCAST_INTO_R(glxgsg, _gsg, false); glXMakeCurrent(_display, _pbuffer, glxgsg->_context); - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) glxgsg->reset_if_new(); if (mode == FM_render) { @@ -100,18 +92,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { } clear_cube_map_selection(); } - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void glxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -129,12 +119,9 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void glxGraphicsBuffer:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -146,7 +133,7 @@ close_buffer() { glxgsg->_glXDestroyPbuffer(_display, _pbuffer); _pbuffer = None; } - + _gsg.clear(); } @@ -154,19 +141,16 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the buffer right now. Called from the window -// thread. Returns true if the buffer is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the buffer right now. Called from the window thread. Returns true + * if the buffer is successfully opened, or false if there was a problem. + */ bool glxGraphicsBuffer:: open_buffer() { glxGraphicsPipe *glx_pipe; DCAST_INTO_R(glx_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -174,8 +158,8 @@ open_buffer() { glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), true, false); _gsg = glxgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(glxgsg, _gsg, false); if (!glxgsg->_context_has_pbuffer || @@ -188,8 +172,8 @@ open_buffer() { } if (glxgsg->_fbconfig == None || !glxgsg->_context_has_pbuffer) { - // If we didn't use an fbconfig to create the GSG, or it doesn't - // support buffers, we can't create a PBuffer. + // If we didn't use an fbconfig to create the GSG, or it doesn't support + // buffers, we can't create a PBuffer. return false; } @@ -206,8 +190,7 @@ open_buffer() { _pbuffer = glxgsg->_glXCreateGLXPbufferSGIX(glxgsg->_display, glxgsg->_fbconfig, get_x_size(), get_y_size(), attrib_list); } else { - // The official GLX 1.3 version passes in the size in the attrib - // list. + // The official GLX 1.3 version passes in the size in the attrib list. attrib_list[n++] = GLX_PBUFFER_WIDTH; attrib_list[n++] = get_x_size(); attrib_list[n++] = GLX_PBUFFER_HEIGHT; @@ -237,7 +220,7 @@ open_buffer() { return false; } _fb_properties = glxgsg->get_fb_properties(); - + _is_valid = true; return true; } diff --git a/panda/src/glxdisplay/glxGraphicsBuffer.h b/panda/src/glxdisplay/glxGraphicsBuffer.h index ae7f1dbcf2..e14a329db0 100644 --- a/panda/src/glxdisplay/glxGraphicsBuffer.h +++ b/panda/src/glxdisplay/glxGraphicsBuffer.h @@ -1,16 +1,15 @@ -// Filename: glxGraphicsBuffer.h -// Created by: drose (09Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsBuffer.h + * @author drose + * @date 2004-02-09 + */ #ifndef GLXGRAPHICSBUFFER_H #define GLXGRAPHICSBUFFER_H @@ -20,14 +19,12 @@ #include "glxGraphicsPipe.h" #include "graphicsBuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : glxGraphicsBuffer -// Description : An offscreen buffer in the GLX environment. This -// creates a GLXPbuffer. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen buffer in the GLX environment. This creates a GLXPbuffer. + */ class glxGraphicsBuffer : public GraphicsBuffer { public: - glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, + glxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/glxdisplay/glxGraphicsPipe.I b/panda/src/glxdisplay/glxGraphicsPipe.I index 8794673a18..383557f5b8 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.I +++ b/panda/src/glxdisplay/glxGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: glxGraphicsPipe.I -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPipe.I + * @author drose + * @date 2000-10-30 + */ diff --git a/panda/src/glxdisplay/glxGraphicsPipe.cxx b/panda/src/glxdisplay/glxGraphicsPipe.cxx index 508ca1a445..cd2f082c91 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.cxx +++ b/panda/src/glxdisplay/glxGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: glxGraphicsPipe.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPipe.cxx + * @author mike + * @date 1997-01-09 + */ #include "glxGraphicsPipe.h" #include "glxGraphicsWindow.h" @@ -23,11 +22,9 @@ TypeHandle glxGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsPipe:: glxGraphicsPipe(const string &display) : x11GraphicsPipe(display) { if (_display == None) { @@ -46,38 +43,29 @@ glxGraphicsPipe(const string &display) : x11GraphicsPipe(display) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string glxGraphicsPipe:: get_interface_name() const { return "OpenGL"; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// glxGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default glxGraphicsPipe. + */ PT(GraphicsPipe) glxGraphicsPipe:: pipe_constructor() { return new glxGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) glxGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -140,8 +128,8 @@ make_output(const string &name, (flags & (BF_require_parasite | BF_require_window)) != 0) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || @@ -154,8 +142,8 @@ make_output(const string &name, posixgsg->_glDrawBuffers == NULL) { return NULL; } else { - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we + // can precertify it. precertify = true; } } @@ -181,8 +169,8 @@ make_output(const string &name, if (!support_rtt) { if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - // If we require Render-to-Texture, but can't be sure we - // support it, bail. + // If we require Render-to-Texture, but can't be sure we support it, + // bail. return NULL; } } @@ -219,19 +207,16 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPipe::make_callback_gsg -// Access: Protected, Virtual -// Description: This is called when make_output() is used to create a -// CallbackGraphicsWindow. If the GraphicsPipe can -// construct a GSG that's not associated with any -// particular window object, do so now, assuming the -// correct graphics context has been set up externally. -//////////////////////////////////////////////////////////////////// +/** + * This is called when make_output() is used to create a + * CallbackGraphicsWindow. If the GraphicsPipe can construct a GSG that's not + * associated with any particular window object, do so now, assuming the + * correct graphics context has been set up externally. + */ PT(GraphicsStateGuardian) glxGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { // We create a PosixGraphicsStateGuardian instead of a - // glxGraphicsStateGuardian, because the externally-created context - // might not have anything to do with the glx interface. + // glxGraphicsStateGuardian, because the externally-created context might + // not have anything to do with the glx interface. return new PosixGraphicsStateGuardian(engine, this); } diff --git a/panda/src/glxdisplay/glxGraphicsPipe.h b/panda/src/glxdisplay/glxGraphicsPipe.h index f2657b40bc..25ff9a7fd1 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.h +++ b/panda/src/glxdisplay/glxGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: glxGraphicsPipe.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPipe.h + * @author mike + * @date 1997-01-09 + */ #ifndef GLXGRAPHICSPIPE_H #define GLXGRAPHICSPIPE_H @@ -34,15 +33,14 @@ class FrameBufferProperties; #include #include "post_x11_include.h" -// This must be included after we have included glgsg.h (which -// includes gl.h), and after we have checked GLX_VERSION_1_3. But we -// must also include it before we redefine the GLXFBConfig types, -// below. +// This must be included after we have included glgsg.h (which includes gl.h), +// and after we have checked GLX_VERSION_1_3. But we must also include it +// before we redefine the GLXFBConfig types, below. #include "panda_glxext.h" -// drose: the version of GL/glx.h that ships with Fedora Core 2 seems -// to define GLX_VERSION_1_4, but for some reason does not define -// GLX_SAMPLE_BUFFERS or GLX_SAMPLES. We work around that here. +// drose: the version of GLglx.h that ships with Fedora Core 2 seems to define +// GLX_VERSION_1_4, but for some reason does not define GLX_SAMPLE_BUFFERS or +// GLX_SAMPLES. We work around that here. #ifndef GLX_SAMPLE_BUFFERS #define GLX_SAMPLE_BUFFERS 100000 @@ -71,12 +69,10 @@ class FrameBufferProperties; #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Class : glxGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on an X-based -// (e.g. Unix) client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL graphics + * windows on an X-based (e.g. Unix) client. + */ class glxGraphicsPipe : public x11GraphicsPipe { public: glxGraphicsPipe(const string &display = string()); @@ -84,7 +80,7 @@ public: virtual string get_interface_name() const; static PT(GraphicsPipe) pipe_constructor(); - + protected: virtual PT(GraphicsOutput) make_output(const string &name, const FrameBufferProperties &fb_prop, diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.I b/panda/src/glxdisplay/glxGraphicsPixmap.I index 337f2d342c..a2e6d32b30 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.I +++ b/panda/src/glxdisplay/glxGraphicsPixmap.I @@ -1,14 +1,12 @@ -// Filename: glxGraphicsPixmap.I -// Created by: drose (10Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPixmap.I + * @author drose + * @date 2009-03-10 + */ diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.cxx b/panda/src/glxdisplay/glxGraphicsPixmap.cxx index e98e338df0..8c8c5a330d 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.cxx +++ b/panda/src/glxdisplay/glxGraphicsPixmap.cxx @@ -1,16 +1,15 @@ -// Filename: glxGraphicsPixmap.cxx -// Created by: drose (10Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPixmap.cxx + * @author drose + * @date 2009-03-10 + */ #include "glxGraphicsPixmap.h" #include "glxGraphicsWindow.h" @@ -24,13 +23,11 @@ TypeHandle glxGraphicsPixmap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsPixmap:: -glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, +glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -46,30 +43,25 @@ glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, _x_pixmap = None; _glx_pixmap = None; - // Since the pixmap never gets flipped, we get screenshots from the - // same pixmap we draw into. + // Since the pixmap never gets flipped, we get screenshots from the same + // pixmap we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsPixmap:: ~glxGraphicsPixmap() { nassertv(_x_pixmap == None && _glx_pixmap == None); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool glxGraphicsPixmap:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -84,10 +76,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { DCAST_INTO_R(glxgsg, _gsg, false); glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context); - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) glxgsg->reset_if_new(); if (mode == FM_render) { @@ -103,18 +95,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { } clear_cube_map_selection(); } - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void glxGraphicsPixmap:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -132,12 +122,9 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::close_buffer -// Access: Protected, Virtual -// Description: Closes the pixmap right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the pixmap right now. Called from the window thread. + */ void glxGraphicsPixmap:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -158,19 +145,16 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsPixmap::open_buffer -// Access: Protected, Virtual -// Description: Opens the pixmap right now. Called from the window -// thread. Returns true if the pixmap is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the pixmap right now. Called from the window thread. Returns true + * if the pixmap is successfully opened, or false if there was a problem. + */ bool glxGraphicsPixmap:: open_buffer() { glxGraphicsPipe *glx_pipe; DCAST_INTO_R(glx_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -178,10 +162,10 @@ open_buffer() { glxgsg->choose_pixel_format(_fb_properties, _display, glx_pipe->get_screen(), false, true); _gsg = glxgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(glxgsg, _gsg, false); - if (!glxgsg->_context_has_pixmap || + if (!glxgsg->_context_has_pixmap || !glxgsg->get_fb_properties().subsumes(_fb_properties)) { glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, glxgsg); glxgsg->choose_pixel_format(_fb_properties, _display, glx_pipe->get_screen(), false, true); @@ -240,8 +224,8 @@ open_buffer() { int error_count = x11GraphicsPipe::disable_x_error_messages(); glXMakeCurrent(_display, _glx_pixmap, glxgsg->_context); if (x11GraphicsPipe::enable_x_error_messages() != error_count) { - // An error was generated during the glXMakeCurrent() call. - // Assume the worst. + // An error was generated during the glXMakeCurrent() call. Assume the + // worst. close_buffer(); return false; } @@ -257,7 +241,7 @@ open_buffer() { return false; } _fb_properties = glxgsg->get_fb_properties(); - + _is_valid = true; return true; } diff --git a/panda/src/glxdisplay/glxGraphicsPixmap.h b/panda/src/glxdisplay/glxGraphicsPixmap.h index 806ed429ee..7c724d4d71 100644 --- a/panda/src/glxdisplay/glxGraphicsPixmap.h +++ b/panda/src/glxdisplay/glxGraphicsPixmap.h @@ -1,16 +1,15 @@ -// Filename: glxGraphicsPixmap.h -// Created by: drose (10Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsPixmap.h + * @author drose + * @date 2009-03-10 + */ #ifndef GLXGRAPHICSPIXMAP_H #define GLXGRAPHICSPIXMAP_H @@ -20,17 +19,15 @@ #include "glxGraphicsPipe.h" #include "graphicsBuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : glxGraphicsPixmap -// Description : Another offscreen buffer in the GLX environment. This -// creates a Pixmap object, which is probably less -// efficient than a GLXPBuffer, so this class is a -// second choice to glxGraphicsBuffer. However, this -// might be the only option for some graphics drivers. -//////////////////////////////////////////////////////////////////// +/** + * Another offscreen buffer in the GLX environment. This creates a Pixmap + * object, which is probably less efficient than a GLXPBuffer, so this class + * is a second choice to glxGraphicsBuffer. However, this might be the only + * option for some graphics drivers. + */ class glxGraphicsPixmap : public GraphicsBuffer { public: - glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, + glxGraphicsPixmap(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.I b/panda/src/glxdisplay/glxGraphicsStateGuardian.I index 726e90764e..0e3f61fa7f 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.I +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.I @@ -1,26 +1,21 @@ -// Filename: glxGraphicsStateGuardian.I -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsStateGuardian.I + * @author drose + * @date 2003-01-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::get_fb_properties -// Access: Private -// Description: Gets the FrameBufferProperties for all windows and -// buffers that use this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties for all windows and buffers that use this + * GSG. + */ INLINE const FrameBufferProperties &glxGraphicsStateGuardian:: get_fb_properties() const { return _fbprops; } - - diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 4964385912..e79f80be3e 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: glxGraphicsStateGuardian.cxx -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsStateGuardian.cxx + * @author drose + * @date 2003-01-27 + */ #include "glxGraphicsStateGuardian.h" #include "config_glxdisplay.h" @@ -22,11 +21,9 @@ TypeHandle glxGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsStateGuardian:: glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian *share_with) : @@ -60,11 +57,9 @@ glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _temp_colormap = (Colormap)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsStateGuardian:: ~glxGraphicsStateGuardian() { destroy_temp_xwindow(); @@ -77,12 +72,9 @@ glxGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::get_properties -// Access: Public -// Description: Gets the FrameBufferProperties to match the -// indicated visual. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated visual. + */ void glxGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, XVisualInfo *visual) { @@ -109,9 +101,9 @@ get_properties(FrameBufferProperties &properties, XVisualInfo *visual) { properties.clear(); if (use_gl == 0) { - // If we return a set of properties without setting either - // rgb_color or indexed_color, then this indicates a visual - // that's no good for any kind of rendering. + // If we return a set of properties without setting either rgb_color or + // indexed_color, then this indicates a visual that's no good for any kind + // of rendering. return; } @@ -137,12 +129,9 @@ get_properties(FrameBufferProperties &properties, XVisualInfo *visual) { properties.set_force_hardware(1); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::get_properties_advanced -// Access: Public -// Description: Gets the FrameBufferProperties to match the -// indicated GLXFBConfig -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated GLXFBConfig + */ void glxGraphicsStateGuardian:: get_properties_advanced(FrameBufferProperties &properties, bool &context_has_pbuffer, bool &context_has_pixmap, @@ -224,13 +213,10 @@ get_properties_advanced(FrameBufferProperties &properties, } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::choose_pixel_format -// Access: Public -// Description: Selects a visual or fbconfig for all the windows -// and buffers that use this gsg. Also creates the GL -// context and obtains the visual. -//////////////////////////////////////////////////////////////////// +/** + * Selects a visual or fbconfig for all the windows and buffers that use this + * gsg. Also creates the GL context and obtains the visual. + */ void glxGraphicsStateGuardian:: choose_pixel_format(const FrameBufferProperties &properties, X11_Display *display, @@ -248,10 +234,9 @@ choose_pixel_format(const FrameBufferProperties &properties, _fbprops.clear(); - // First, attempt to create a context using the XVisual interface. - // We need this before we can query the FBConfig interface, because - // we need an OpenGL context to get the required extension function - // pointers. + // First, attempt to create a context using the XVisual interface. We need + // this before we can query the FBConfig interface, because we need an + // OpenGL context to get the required extension function pointers. destroy_temp_xwindow(); choose_temp_visual(properties); if (_temp_context == NULL) { @@ -259,15 +244,14 @@ choose_pixel_format(const FrameBufferProperties &properties, return; } - // Now we have to initialize the context so we can query its - // capabilities and extensions. This also means creating a - // temporary window, so we have something to bind the context to and - // make it current. + // Now we have to initialize the context so we can query its capabilities + // and extensions. This also means creating a temporary window, so we have + // something to bind the context to and make it current. init_temp_context(); if (!_supports_fbconfig) { - // We have a good OpenGL context, but it doesn't support the - // FBConfig interface, so we'll stop there. + // We have a good OpenGL context, but it doesn't support the FBConfig + // interface, so we'll stop there. glxdisplay_cat.debug() <<" No FBConfig supported; using XVisual only.\n" << _fbprops << "\n"; @@ -275,9 +259,8 @@ choose_pixel_format(const FrameBufferProperties &properties, _context = _temp_context; _temp_context = (GLXContext)NULL; - // By convention, every indirect XVisual that can render to a - // window can also render to a GLXPixmap. Direct visuals we're - // not as sure about. + // By convention, every indirect XVisual that can render to a window can + // also render to a GLXPixmap. Direct visuals we're not as sure about. _context_has_pixmap = !glXIsDirect(_display, _context); // Pbuffers aren't supported at all with the XVisual interface. @@ -285,10 +268,10 @@ choose_pixel_format(const FrameBufferProperties &properties, return; } - // The OpenGL context supports the FBConfig interface, so we can use - // that more advanced interface to choose the actual window format - // we'll use. FBConfig provides for more options than the older - // XVisual interface, so we'd much rather use it if it's available. + // The OpenGL context supports the FBConfig interface, so we can use that + // more advanced interface to choose the actual window format we'll use. + // FBConfig provides for more options than the older XVisual interface, so + // we'd much rather use it if it's available. int best_quality = 0; int best_result = 0; @@ -350,8 +333,8 @@ choose_pixel_format(const FrameBufferProperties &properties, _fbconfig = configs[best_result]; if (_glXCreateContextAttribs != NULL) { - // NB. This is a wholly different type of attrib list - // than below, the same values are not used! + // NB. This is a wholly different type of attrib list than below, the + // same values are not used! n = 0; attrib_list[n++] = GLX_RENDER_TYPE; attrib_list[n++] = render_type; @@ -421,21 +404,18 @@ choose_pixel_format(const FrameBufferProperties &properties, _context = _temp_context; _temp_context = (GLXContext)NULL; - // By convention, every indirect XVisual that can render to a - // window can also render to a GLXPixmap. Direct visuals we're - // not as sure about. + // By convention, every indirect XVisual that can render to a window can + // also render to a GLXPixmap. Direct visuals we're not as sure about. _context_has_pixmap = !glXIsDirect(_display, _context); // Pbuffers aren't supported at all with the XVisual interface. _context_has_pbuffer = false; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::glx_is_at_least_version -// Access: Public -// Description: Returns true if the runtime GLX version number is at -// least the indicated value, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the runtime GLX version number is at least the indicated + * value, false otherwise. + */ bool glxGraphicsStateGuardian:: glx_is_at_least_version(int major_version, int minor_version) const { if (_glx_version_major < major_version) { @@ -450,11 +430,9 @@ glx_is_at_least_version(int major_version, int minor_version) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::gl_flush -// Access: Protected, Virtual -// Description: Calls glFlush(). -//////////////////////////////////////////////////////////////////// +/** + * Calls glFlush(). + */ void glxGraphicsStateGuardian:: gl_flush() const { // This call requires synchronization with X. @@ -462,11 +440,9 @@ gl_flush() const { PosixGraphicsStateGuardian::gl_flush(); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::gl_get_error -// Access: Protected, Virtual -// Description: Returns the result of glGetError(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the result of glGetError(). + */ GLenum glxGraphicsStateGuardian:: gl_get_error() const { // This call requires synchronization with X. @@ -474,11 +450,9 @@ gl_get_error() const { return PosixGraphicsStateGuardian::gl_get_error(); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::query_gl_version -// Access: Protected, Virtual -// Description: Queries the runtime version of OpenGL in use. -//////////////////////////////////////////////////////////////////// +/** + * Queries the runtime version of OpenGL in use. + */ void glxGraphicsStateGuardian:: query_gl_version() { PosixGraphicsStateGuardian::query_gl_version(); @@ -490,9 +464,9 @@ query_gl_version() { glXQueryVersion(_display, &_glx_version_major, &_glx_version_minor); - // We output to glgsg_cat instead of glxdisplay_cat, since this is - // where the GL version has been output, and it's nice to see the - // two of these together. + // We output to glgsg_cat instead of glxdisplay_cat, since this is where the + // GL version has been output, and it's nice to see the two of these + // together. if (glgsg_cat.is_debug()) { glgsg_cat.debug() << "GLX_VERSION = " << _glx_version_major << "." << _glx_version_minor @@ -500,48 +474,40 @@ query_gl_version() { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::get_extra_extensions -// Access: Protected, Virtual -// Description: This may be redefined by a derived class (e.g. glx or -// wgl) to get whatever further extensions strings may -// be appropriate to that interface, in addition to the -// GL extension strings return by glGetString(). -//////////////////////////////////////////////////////////////////// +/** + * This may be redefined by a derived class (e.g. glx or wgl) to get whatever + * further extensions strings may be appropriate to that interface, in + * addition to the GL extension strings return by glGetString(). + */ void glxGraphicsStateGuardian:: get_extra_extensions() { save_extensions(glXQueryExtensionsString(_display, _screen)); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *glxGraphicsStateGuardian:: do_get_extension_func(const char *name) { nassertr(name != NULL, NULL); if (glx_get_proc_address) { - // First, check if we have glXGetProcAddress available. This will - // be superior if we can get it. + // First, check if we have glXGetProcAddress available. This will be + // superior if we can get it. #if defined(LINK_IN_GLXGETPROCADDRESS) && defined(HAVE_GLXGETPROCADDRESS) - // If we are confident the system headers defined it, we can - // call it directly. This is more reliable than trying to - // determine its address dynamically, but it may make - // libpandagl.so fail to load if the symbol isn't in the runtime - // library. + // If we are confident the system headers defined it, we can call it + // directly. This is more reliable than trying to determine its address + // dynamically, but it may make libpandagl.so fail to load if the symbol + // isn't in the runtime library. return (void *)glXGetProcAddress((const GLubyte *)name); #elif defined(LINK_IN_GLXGETPROCADDRESS) && defined(HAVE_GLXGETPROCADDRESSARB) - // The ARB extension version is OK too. Sometimes the prototype - // isn't supplied for some reason. + // The ARB extension version is OK too. Sometimes the prototype isn't + // supplied for some reason. return (void *)glXGetProcAddressARB((const GLubyte *)name); #else @@ -580,11 +546,9 @@ do_get_extension_func(const char *name) { return PosixGraphicsStateGuardian::do_get_extension_func(name); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::query_glx_extensions -// Access: Private -// Description: Queries the GLX extension pointers. -//////////////////////////////////////////////////////////////////// +/** + * Queries the GLX extension pointers. + */ void glxGraphicsStateGuardian:: query_glx_extensions() { _supports_swap_control = has_extension("GLX_SGI_swap_control"); @@ -600,8 +564,8 @@ query_glx_extensions() { } if (_supports_swap_control) { - // Set the video-sync setting up front, if we have the extension - // that supports it. + // Set the video-sync setting up front, if we have the extension that + // supports it. _glXSwapIntervalSGI(sync_video ? 1 : 0); } @@ -631,9 +595,9 @@ query_glx_extensions() { _supports_fbconfig = false; } } else if (has_extension("GLX_SGIX_fbconfig")) { - // Or maybe we have the old SGIX extension for FBConfig. This is - // the same, but the function names are different--we just remap - // them to the same function pointers. + // Or maybe we have the old SGIX extension for FBConfig. This is the + // same, but the function names are different--we just remap them to the + // same function pointers. _supports_fbconfig = true; _glXChooseFBConfig = @@ -679,9 +643,9 @@ query_glx_extensions() { // Or maybe we have the old SGIX extension for PBuffers. _uses_sgix_pbuffer = true; - // CreatePbuffer has a different form between SGIX and 1.3, - // however, so we must treat it specially. But we can use the - // same function pointer for DestroyPbuffer. + // CreatePbuffer has a different form between SGIX and 1.3, however, so + // we must treat it specially. But we can use the same function pointer + // for DestroyPbuffer. _glXCreatePbuffer = NULL; _glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)get_extension_func("glXCreateGLXPbufferSGIX"); @@ -713,9 +677,8 @@ query_glx_extensions() { << " sgix = " << _uses_sgix_pbuffer << "\n"; } - // If "Mesa" is present, assume software. However, if "Mesa DRI" is - // found, it's actually a Mesa-based OpenGL layer running over a - // hardware driver. + // If "Mesa" is present, assume software. However, if "Mesa DRI" is found, + // it's actually a Mesa-based OpenGL layer running over a hardware driver. if (_gl_renderer.find("Mesa") != string::npos && _gl_renderer.find("Mesa DRI") == string::npos) { // It's Mesa, therefore probably a software context. @@ -727,12 +690,9 @@ query_glx_extensions() { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::show_glx_client_string -// Access: Protected -// Description: Outputs the result of glxGetClientString() on the -// indicated tag. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the result of glxGetClientString() on the indicated tag. + */ void glxGraphicsStateGuardian:: show_glx_client_string(const string &name, int id) { if (glgsg_cat.is_debug()) { @@ -747,12 +707,9 @@ show_glx_client_string(const string &name, int id) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::show_glx_server_string -// Access: Protected -// Description: Outputs the result of glxQueryServerString() on the -// indicated tag. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the result of glxQueryServerString() on the indicated tag. + */ void glxGraphicsStateGuardian:: show_glx_server_string(const string &name, int id) { if (glgsg_cat.is_debug()) { @@ -767,15 +724,12 @@ show_glx_server_string(const string &name, int id) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::choose_temp_visual -// Access: Private -// Description: Selects an XVisual for an initial OpenGL context. -// This may be called initially, to create the first -// context needed in order to create the fbconfig. On -// successful return, _visual and _temp_context will be -// filled in with a non-NULL value. -//////////////////////////////////////////////////////////////////// +/** + * Selects an XVisual for an initial OpenGL context. This may be called + * initially, to create the first context needed in order to create the + * fbconfig. On successful return, _visual and _temp_context will be filled + * in with a non-NULL value. + */ void glxGraphicsStateGuardian:: choose_temp_visual(const FrameBufferProperties &properties) { nassertv(_temp_context == (GLXContext)NULL); @@ -817,13 +771,10 @@ choose_temp_visual(const FrameBufferProperties &properties) { << "Could not find a usable pixel format.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::init_temp_context -// Access: Private -// Description: Initializes the context created in -// choose_temp_visual() by creating a temporary window -// and binding the context to that window. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the context created in choose_temp_visual() by creating a + * temporary window and binding the context to that window. + */ void glxGraphicsStateGuardian:: init_temp_context() { x11GraphicsPipe *x11_pipe; @@ -856,12 +807,9 @@ init_temp_context() { query_glx_extensions(); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsStateGuardian::destroy_temp_xwindow -// Access: Private -// Description: Destroys the temporary unmapped window created by -// init_temp_context(). -//////////////////////////////////////////////////////////////////// +/** + * Destroys the temporary unmapped window created by init_temp_context(). + */ void glxGraphicsStateGuardian:: destroy_temp_xwindow() { glXMakeCurrent(_display, None, NULL); diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.h b/panda/src/glxdisplay/glxGraphicsStateGuardian.h index 3a6431c865..7d31b6d8a9 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.h +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: glxGraphicsStateGuardian.h -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsStateGuardian.h + * @author drose + * @date 2003-01-27 + */ #ifndef GLXGRAPHICSSTATEGUARDIAN_H #define GLXGRAPHICSSTATEGUARDIAN_H @@ -22,27 +21,26 @@ #include "posixGraphicsStateGuardian.h" #if defined(GLX_VERSION_1_4) -// If the system header files give us version 1.4, we can assume it's -// safe to compile in a reference to glxGetProcAddress(). +// If the system header files give us version 1.4, we can assume it's safe to +// compile in a reference to glxGetProcAddress(). #define HAVE_GLXGETPROCADDRESS 1 #elif defined(GLX_ARB_get_proc_address) // Maybe the system header files give us the corresponding ARB call. #define HAVE_GLXGETPROCADDRESSARB 1 -// Sometimes the system header files don't define this prototype for -// some reason. +// Sometimes the system header files don't define this prototype for some +// reason. extern "C" void (*glXGetProcAddressARB(const GLubyte *procName))( void ); #endif -// This must be included after we have included glgsg.h (which -// includes gl.h). +// This must be included after we have included glgsg.h (which includes gl.h). #include "panda_glxext.h" -// drose: the version of GL/glx.h that ships with Fedora Core 2 seems -// to define GLX_VERSION_1_4, but for some reason does not define -// GLX_SAMPLE_BUFFERS or GLX_SAMPLES. We work around that here. +// drose: the version of GLglx.h that ships with Fedora Core 2 seems to define +// GLX_VERSION_1_4, but for some reason does not define GLX_SAMPLE_BUFFERS or +// GLX_SAMPLES. We work around that here. #ifndef GLX_SAMPLE_BUFFERS #define GLX_SAMPLE_BUFFERS 100000 @@ -51,11 +49,10 @@ extern "C" void (*glXGetProcAddressARB(const GLubyte *procName))( void ); #define GLX_SAMPLES 100001 #endif -// These typedefs are declared in glxext.h, but we must repeat them -// here, mainly because they will not be included from glxext.h if the -// system GLX version matches or exceeds the GLX version in which -// these functions are defined, and the system glx.h sometimes doesn't -// declare these typedefs. +// These typedefs are declared in glxext.h, but we must repeat them here, +// mainly because they will not be included from glxext.h if the system GLX +// version matches or exceeds the GLX version in which these functions are +// defined, and the system glx.h sometimes doesn't declare these typedefs. #ifndef __EDG__ // Protect the following from the Tau instrumentor. typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); typedef int (* PFNGLXSWAPINTERVALSGIPROC) (int interval); @@ -70,11 +67,10 @@ typedef void (* PFNGLXDESTROYPBUFFERPROC) (X11_Display *dpy, GLXPbuffer pbuf); typedef GLXContext ( *PFNGLXCREATECONTEXTATTRIBSARBPROC) (X11_Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); #endif // __EDG__ -//////////////////////////////////////////////////////////////////// -// Class : glxGraphicsStateGuardian -// Description : A tiny specialization on GLGraphicsStateGuardian to -// add some glx-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLGraphicsStateGuardian to add some glx-specific + * information. + */ class glxGraphicsStateGuardian : public PosixGraphicsStateGuardian { public: INLINE const FrameBufferProperties &get_fb_properties() const; @@ -82,11 +78,11 @@ public: void get_properties_advanced(FrameBufferProperties &properties, bool &context_has_pbuffer, bool &pixmap_supported, bool &slow, GLXFBConfig config); - void choose_pixel_format(const FrameBufferProperties &properties, + void choose_pixel_format(const FrameBufferProperties &properties, X11_Display *_display, int _screen, bool need_pbuffer, bool need_pixmap); - + glxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, glxGraphicsStateGuardian *share_with); diff --git a/panda/src/glxdisplay/glxGraphicsWindow.I b/panda/src/glxdisplay/glxGraphicsWindow.I index ba69d2f540..dab7086f73 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.I +++ b/panda/src/glxdisplay/glxGraphicsWindow.I @@ -1,23 +1,19 @@ -// Filename: glxGraphicsWindow.I -// Created by: mike (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsWindow.I + * @author mike + * @date 1999-03-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::get_xwindow -// Access: Public -// Description: Returns the X11 Window handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X11 Window handle. + */ INLINE X11_Window glxGraphicsWindow:: get_xwindow() const { return _xwindow; diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 9af6aca59f..2a8a44e819 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: glxGraphicsWindow.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsWindow.cxx + * @author mike + * @date 1997-01-09 + */ #include "glxGraphicsWindow.h" #include "glxGraphicsStateGuardian.h" @@ -32,13 +31,11 @@ TypeHandle glxGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ glxGraphicsWindow:: -glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, +glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -49,15 +46,12 @@ glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, { } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool glxGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -67,8 +61,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } if (_awaiting_configure) { - // Don't attempt to draw while we have just reconfigured the - // window and we haven't got the notification back yet. + // Don't attempt to draw while we have just reconfigured the window and we + // haven't got the notification back yet. return false; } @@ -80,48 +74,45 @@ begin_frame(FrameMode mode, Thread *current_thread) { if (glXGetCurrentDisplay() == _display && glXGetCurrentDrawable() == _xwindow && glXGetCurrentContext() == glxgsg->_context) { - // No need to make the context current again. Short-circuit - // this possibly-expensive call. + // No need to make the context current again. Short-circuit this + // possibly-expensive call. } else { // Need to set the context. glXMakeCurrent(_display, _xwindow, glxgsg->_context); } } - - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) glxgsg->reset_if_new(); - + if (mode == FM_render) { // begin_render_texture(); clear_cube_map_selection(); } - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void glxGraphicsWindow:: end_flip() { if (_gsg != (GraphicsStateGuardian *)NULL && _flip_ready) { - // It doesn't appear to be necessary to ensure the graphics - // context is current before flipping the windows, and insisting - // on doing so can be a significant performance hit. + // It doesn't appear to be necessary to ensure the graphics context is + // current before flipping the windows, and insisting on doing so can be a + // significant performance hit. - //make_current(); + // make_current(); LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); glXSwapBuffers(_display, _xwindow); @@ -129,35 +120,29 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void glxGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { glXMakeCurrent(_display, None, NULL); _gsg.clear(); } - + x11GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool glxGraphicsWindow:: open_window() { glxGraphicsPipe *glx_pipe; DCAST_INTO_R(glx_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization glxGraphicsStateGuardian *glxgsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -165,8 +150,8 @@ open_window() { glxgsg->choose_pixel_format(_fb_properties, glx_pipe->get_display(), glx_pipe->get_screen(), false, false); _gsg = glxgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(glxgsg, _gsg, false); if (!glxgsg->get_fb_properties().subsumes(_fb_properties)) { glxgsg = new glxGraphicsStateGuardian(_engine, _pipe, glxgsg); @@ -174,14 +159,14 @@ open_window() { _gsg = glxgsg; } } - + if (glxgsg->_context == NULL) { // We're supposed to have a context at this point. glxdisplay_cat.error() << "No GLX context: cannot open window.\n"; return false; } - + _visual_info = glxgsg->_visual; if (_visual_info == NULL) { // No X visual for this fbconfig; how can we open the window? @@ -190,7 +175,7 @@ open_window() { return false; } Visual *visual = _visual_info->visual; - + if (glxgsg->_fbconfig != None) { setup_colormap(glxgsg->_fbconfig); } else { @@ -217,12 +202,10 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::setup_colormap -// Access: Private -// Description: Allocates a colormap appropriate to the fbconfig and -// stores in in the _colormap method. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a colormap appropriate to the fbconfig and stores in in the + * _colormap method. + */ void glxGraphicsWindow:: setup_colormap(GLXFBConfig fbconfig) { glxGraphicsStateGuardian *glxgsg; @@ -277,12 +260,10 @@ setup_colormap(GLXFBConfig fbconfig) { } } -//////////////////////////////////////////////////////////////////// -// Function: glxGraphicsWindow::setup_colormap -// Access: Private, Virtual -// Description: Allocates a colormap appropriate to the visual and -// stores in in the _colormap method. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a colormap appropriate to the visual and stores in in the + * _colormap method. + */ void glxGraphicsWindow:: setup_colormap(XVisualInfo *visual) { glxGraphicsPipe *glx_pipe; diff --git a/panda/src/glxdisplay/glxGraphicsWindow.h b/panda/src/glxdisplay/glxGraphicsWindow.h index 61c7f4e297..d89ab1552b 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.h +++ b/panda/src/glxdisplay/glxGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: glxGraphicsWindow.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file glxGraphicsWindow.h + * @author mike + * @date 1997-01-09 + */ #ifndef GLXGRAPHICSWINDOW_H #define GLXGRAPHICSWINDOW_H @@ -22,14 +21,12 @@ #include "graphicsWindow.h" #include "buttonHandle.h" -//////////////////////////////////////////////////////////////////// -// Class : glxGraphicsWindow -// Description : An interface to the glx system for managing GL -// windows under X. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the glx system for managing GL windows under X. + */ class glxGraphicsWindow : public x11GraphicsWindow { public: - glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + glxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -48,7 +45,7 @@ protected: private: virtual void setup_colormap(GLXFBConfig fbconfig); virtual void setup_colormap(XVisualInfo *visual); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/glxdisplay/posixGraphicsStateGuardian.I b/panda/src/glxdisplay/posixGraphicsStateGuardian.I index 52682680f0..f3d717775e 100644 --- a/panda/src/glxdisplay/posixGraphicsStateGuardian.I +++ b/panda/src/glxdisplay/posixGraphicsStateGuardian.I @@ -1,13 +1,12 @@ -// Filename: posixGraphicsStateGuardian.I -// Created by: drose (14Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file posixGraphicsStateGuardian.I + * @author drose + * @date 2012-01-14 + */ diff --git a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx index 25ec38afac..8bf738b3c2 100644 --- a/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/posixGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: posixGraphicsStateGuardian.cxx -// Created by: drose (14Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file posixGraphicsStateGuardian.cxx + * @author drose + * @date 2012-01-14 + */ #include "posixGraphicsStateGuardian.h" #include "config_glxdisplay.h" @@ -18,11 +17,9 @@ TypeHandle PosixGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PosixGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PosixGraphicsStateGuardian:: PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : GLGraphicsStateGuardian(engine, pipe) @@ -30,11 +27,9 @@ PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe) : _libgl_handle = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PosixGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PosixGraphicsStateGuardian:: ~PosixGraphicsStateGuardian() { if (_libgl_handle != (void *)NULL) { @@ -42,16 +37,12 @@ PosixGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: PosixGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *PosixGraphicsStateGuardian:: do_get_extension_func(const char *name) { nassertr(name != NULL, NULL); @@ -63,27 +54,24 @@ do_get_extension_func(const char *name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PosixGraphicsStateGuardian::get_system_func -// Access: Protected -// Description: Support for get_extension_func(), above, that uses -// system calls to find a GL or GLX function (in the -// absence of a working glxGetProcAddress() function to -// call). -//////////////////////////////////////////////////////////////////// +/** + * Support for get_extension_func(), above, that uses system calls to find a + * GL or GLX function (in the absence of a working glxGetProcAddress() + * function to call). + */ void *PosixGraphicsStateGuardian:: get_system_func(const char *name) { if (_libgl_handle == (void *)NULL) { // We open the current executable, rather than naming a particular - // library. Presumably libGL.so (or whatever the library should - // be called) is already available in the current executable - // address space, so this is more portable than insisting on a - // particular shared library name. + // library. Presumably libGL.so (or whatever the library should be + // called) is already available in the current executable address space, + // so this is more portable than insisting on a particular shared library + // name. _libgl_handle = dlopen(NULL, RTLD_LAZY); nassertr(_libgl_handle != (void *)NULL, NULL); - // If that doesn't locate the symbol we expected, then fall back - // to loading the GL library by its usual name. + // If that doesn't locate the symbol we expected, then fall back to + // loading the GL library by its usual name. if (dlsym(_libgl_handle, name) == NULL) { dlclose(_libgl_handle); glxdisplay_cat.warning() diff --git a/panda/src/glxdisplay/posixGraphicsStateGuardian.h b/panda/src/glxdisplay/posixGraphicsStateGuardian.h index 04e4850ea2..c897998318 100644 --- a/panda/src/glxdisplay/posixGraphicsStateGuardian.h +++ b/panda/src/glxdisplay/posixGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: posixGraphicsStateGuardian.h -// Created by: drose (14Jan12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file posixGraphicsStateGuardian.h + * @author drose + * @date 2012-01-14 + */ #ifndef POSIXGRAPHICSSTATEGUARDIAN_H #define POSIXGRAPHICSSTATEGUARDIAN_H @@ -19,13 +18,11 @@ #include "glgsg.h" -//////////////////////////////////////////////////////////////////// -// Class : PosixGraphicsStateGuardian -// Description : This GSG is used only for CallbackGraphicsWindow -// (which might not be using the glx interfaces), to add -// the ability to peek in libGL.so to find the extension -// functions. -//////////////////////////////////////////////////////////////////// +/** + * This GSG is used only for CallbackGraphicsWindow (which might not be using + * the glx interfaces), to add the ability to peek in libGL.so to find the + * extension functions. + */ class PosixGraphicsStateGuardian : public GLGraphicsStateGuardian { public: PosixGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe); diff --git a/panda/src/gobj/adaptiveLru.I b/panda/src/gobj/adaptiveLru.I index 3c31c14bf2..77c3fcd5de 100644 --- a/panda/src/gobj/adaptiveLru.I +++ b/panda/src/gobj/adaptiveLru.I @@ -1,50 +1,41 @@ -// Filename: adaptiveLru.I -// Created by: drose (03Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file adaptiveLru.I + * @author drose + * @date 2008-09-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::get_total_size -// Access: Published -// Description: Returns the total size of all objects currently -// active on the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all objects currently active on the LRU. + */ INLINE size_t AdaptiveLru:: get_total_size() const { LightMutexHolder holder(_lock); return _total_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::get_max_size -// Access: Published -// Description: Returns the max size of all objects that are allowed -// to be active on the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the max size of all objects that are allowed to be active on the + * LRU. + */ INLINE size_t AdaptiveLru:: get_max_size() const { LightMutexHolder holder(_lock); return _max_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::set_max_size -// Access: Published -// Description: Changes the max size of all objects that are allowed -// to be active on the LRU. -// -// If the size is (size_t)-1, there is no limit. -//////////////////////////////////////////////////////////////////// +/** + * Changes the max size of all objects that are allowed to be active on the + * LRU. + * + * If the size is (size_t)-1, there is no limit. + */ INLINE void AdaptiveLru:: set_max_size(size_t max_size) { LightMutexHolder holder(_lock); @@ -54,11 +45,9 @@ set_max_size(size_t max_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::consider_evict -// Access: Published -// Description: Evicts a sequence of objects if the queue is full. -//////////////////////////////////////////////////////////////////// +/** + * Evicts a sequence of objects if the queue is full. + */ INLINE void AdaptiveLru:: consider_evict() { LightMutexHolder holder(_lock); @@ -67,13 +56,10 @@ consider_evict() { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::evict_to -// Access: Published -// Description: Evicts a sequence of objects until the queue fits -// within the indicated target size, regardless of its -// normal max size. -//////////////////////////////////////////////////////////////////// +/** + * Evicts a sequence of objects until the queue fits within the indicated + * target size, regardless of its normal max size. + */ INLINE void AdaptiveLru:: evict_to(size_t target_size) { LightMutexHolder holder(_lock); @@ -82,105 +68,82 @@ evict_to(size_t target_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::validate -// Access: Published -// Description: Checks that the LRU is internally self-consistent. -// Returns true if successful, false if there is some -// problem. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the LRU is internally self-consistent. Returns true if + * successful, false if there is some problem. + */ INLINE bool AdaptiveLru:: validate() { LightMutexHolder holder(_lock); return do_validate(); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::set_weight -// Access: Published -// Description: Specifies the weight value used to compute the -// exponential moving average. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the weight value used to compute the exponential moving average. + */ INLINE void AdaptiveLru:: set_weight(PN_stdfloat weight) { _weight = weight; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::get_weight -// Access: Published -// Description: Returns the weight value used to compute the -// exponential moving average. -//////////////////////////////////////////////////////////////////// +/** + * Returns the weight value used to compute the exponential moving average. + */ INLINE PN_stdfloat AdaptiveLru:: get_weight() const { return _weight; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::set_max_updates_per_frame -// Access: Published -// Description: Specifies the maximum number of pages the AdaptiveLru -// will update each frame. This is a performance -// optimization: keeping this number low limits the -// impact of the AdaptiveLru's adaptive algorithm. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum number of pages the AdaptiveLru will update each + * frame. This is a performance optimization: keeping this number low limits + * the impact of the AdaptiveLru's adaptive algorithm. + */ INLINE void AdaptiveLru:: set_max_updates_per_frame(int max_updates_per_frame) { _max_updates_per_frame = max_updates_per_frame; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::get_max_updates_per_frame -// Access: Published -// Description: Returns the maximum number of pages the AdaptiveLru -// will update each frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of pages the AdaptiveLru will update each frame. + */ INLINE int AdaptiveLru:: get_max_updates_per_frame() const { return _max_updates_per_frame; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::calculate_exponential_moving_average -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat AdaptiveLru:: calculate_exponential_moving_average(PN_stdfloat value, PN_stdfloat average) const { return ((value - average) * _weight) + average; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::enqueue_lru -// Access: Published -// Description: Returns the LRU that manages this page, or NULL if it -// is not currently managed by any LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LRU that manages this page, or NULL if it is not currently + * managed by any LRU. + */ INLINE AdaptiveLru *AdaptiveLruPage:: get_lru() const { return _lru; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::dequeue_lru -// Access: Published -// Description: Removes the page from its AdaptiveLru. -//////////////////////////////////////////////////////////////////// +/** + * Removes the page from its AdaptiveLru. + */ INLINE void AdaptiveLruPage:: dequeue_lru() { enqueue_lru(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::mark_used_lru -// Access: Published -// Description: To be called when the page is used; this will move it -// to the tail of the AdaptiveLru queue it is already on. -// -// This method is const because it's not technically -// modifying the contents of the page itself. -//////////////////////////////////////////////////////////////////// +/** + * To be called when the page is used; this will move it to the tail of the + * AdaptiveLru queue it is already on. + * + * This method is const because it's not technically modifying the contents of + * the page itself. + */ INLINE void AdaptiveLruPage:: mark_used_lru() const { if (_lru != (AdaptiveLru *)NULL) { @@ -188,34 +151,27 @@ mark_used_lru() const { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::mark_used_lru -// Access: Published -// Description: To be called when the page is used; this will move it -// to the tail of the specified AdaptiveLru queue. -//////////////////////////////////////////////////////////////////// +/** + * To be called when the page is used; this will move it to the tail of the + * specified AdaptiveLru queue. + */ INLINE void AdaptiveLruPage:: mark_used_lru(AdaptiveLru *lru) { enqueue_lru(lru); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::get_lru_size -// Access: Published -// Description: Returns the size of this page as reported to the LRU, -// presumably in bytes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of this page as reported to the LRU, presumably in bytes. + */ INLINE size_t AdaptiveLruPage:: get_lru_size() const { return _lru_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::set_lru_size -// Access: Published -// Description: Specifies the size of this page, presumably in bytes, -// although any unit is possible. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size of this page, presumably in bytes, although any unit is + * possible. + */ INLINE void AdaptiveLruPage:: set_lru_size(size_t lru_size) { if (_lru != (AdaptiveLru *)NULL) { diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 64dfaadde9..8b68f0e9b2 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -1,16 +1,15 @@ -// Filename: adaptiveLru.cxx -// Created by: drose (03Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file adaptiveLru.cxx + * @author drose + * @date 2008-09-03 + */ #include "adaptiveLru.h" #include "config_gobj.h" @@ -20,13 +19,11 @@ static const int HIGH_PRIORITY_SCALE = 4; static const int LOW_PRIORITY_RANGE = 25; -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AdaptiveLru:: -AdaptiveLru(const string &name, size_t max_size) : +AdaptiveLru(const string &name, size_t max_size) : Namable(name) { _total_size = 0; @@ -47,17 +44,15 @@ AdaptiveLru(const string &name, size_t max_size) : } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AdaptiveLru:: ~AdaptiveLru() { #ifndef NDEBUG - // We're shutting down. Force-remove everything remaining, but - // don't explicitly evict it (that would force vertex buffers to - // write themselves to disk unnecessarily). + // We're shutting down. Force-remove everything remaining, but don't + // explicitly evict it (that would force vertex buffers to write themselves + // to disk unnecessarily). while (_static_list._next != &_static_list) { nassertv(_static_list._next != (LinkedListNode *)NULL); @@ -70,18 +65,15 @@ AdaptiveLru:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_partial_lru_update -// Access: Private -// Description: This only updates a number of pages up to the -// specified maximum_updates. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * This only updates a number of pages up to the specified maximum_updates. + * Assumes the lock is held. + */ void AdaptiveLru:: do_partial_lru_update(int num_updates) { - // Iterate sequentially through the static list of pages. As we - // process each page, pop it and push it back on the tail. Stop - // when we have processed num_updates, or come back to the starting - // one. + // Iterate sequentially through the static list of pages. As we process + // each page, pop it and push it back on the tail. Stop when we have + // processed num_updates, or come back to the starting one. AdaptiveLruPageStaticList *start_node = (AdaptiveLruPageStaticList *)_static_list._next; if (start_node == &_static_list) { @@ -103,18 +95,15 @@ do_partial_lru_update(int num_updates) { } while (node != start_node && node != &_static_list); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::update_page -// Access: Private -// Description: This updates the page's average utilization. -// Priority LPP_New is considered to be average usage -// of 1.0 (which means the page is used once per frame -// on average). Priorities < LPP_New are for pages -// used more than once per frame and Priorities > -// LPP_New are for pages used less than once per frame. -// -// Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * This updates the page's average utilization. Priority LPP_New is + * considered to be average usage of 1.0 (which means the page is used once + * per frame on average). Priorities < LPP_New are for pages used more than + * once per frame and Priorities > LPP_New are for pages used less than once + * per frame. + * + * Assumes the lock is held. + */ void AdaptiveLru:: update_page(AdaptiveLruPage *page) { int target_priority = page->_priority; @@ -122,20 +111,20 @@ update_page(AdaptiveLruPage *page) { if (lifetime_frames > 0) { if (page->_update_frame_identifier) { unsigned int update_frames; - + update_frames = (_current_frame_identifier - page->_update_frame_identifier); if (update_frames > 0) { PN_stdfloat update_average_frame_utilization = (PN_stdfloat) (page->_update_total_usage) / (PN_stdfloat)update_frames; page->_average_frame_utilization = - calculate_exponential_moving_average(update_average_frame_utilization, + calculate_exponential_moving_average(update_average_frame_utilization, page->_average_frame_utilization); target_priority = page->_priority; if (page->_average_frame_utilization >= 1.0f) { int integer_average_frame_utilization; - + integer_average_frame_utilization = (int) ((page->_average_frame_utilization - 1.0f) * (PN_stdfloat) HIGH_PRIORITY_SCALE); @@ -147,7 +136,7 @@ update_page(AdaptiveLruPage *page) { target_priority = integer_average_frame_utilization; } else { int integer_average_frame_utilization; - + integer_average_frame_utilization = (int) (page->_average_frame_utilization * (PN_stdfloat) LOW_PRIORITY_RANGE); @@ -169,15 +158,12 @@ update_page(AdaptiveLruPage *page) { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::enqueue_lru -// Access: Published -// Description: Adds the page to the LRU for the first time, or marks -// it recently-accessed if it has already been added. -// -// If lru is NULL, it means to remove this page from its -// LRU. -//////////////////////////////////////////////////////////////////// +/** + * Adds the page to the LRU for the first time, or marks it recently-accessed + * if it has already been added. + * + * If lru is NULL, it means to remove this page from its LRU. + */ void AdaptiveLruPage:: enqueue_lru(AdaptiveLru *lru) { if (lru != _lru && _lru != (AdaptiveLru *)NULL) { @@ -203,12 +189,10 @@ enqueue_lru(AdaptiveLru *lru) { } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::count_active_size -// Access: Published -// Description: Returns the total size of the pages that were -// enqueued since the last call to begin_epoch(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of the pages that were enqueued since the last call + * to begin_epoch(). + */ size_t AdaptiveLru:: count_active_size() const { size_t counted_size = 0; @@ -225,14 +209,11 @@ count_active_size() const { return counted_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::begin_epoch -// Access: Published -// Description: Marks the end of the previous epoch and the beginning -// of the next one. This will evict any objects that -// are pending eviction, and also update any internal -// bookkeeping. -//////////////////////////////////////////////////////////////////// +/** + * Marks the end of the previous epoch and the beginning of the next one. + * This will evict any objects that are pending eviction, and also update any + * internal bookkeeping. + */ void AdaptiveLru:: begin_epoch() { LightMutexHolder holder(_lock); @@ -244,11 +225,9 @@ begin_epoch() { _current_frame_identifier = ClockObject::get_global_clock()->get_frame_count(); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AdaptiveLru:: output(ostream &out) const { LightMutexHolder holder(_lock); @@ -256,18 +235,16 @@ output(ostream &out) const { << ", " << _total_size << " of " << _max_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AdaptiveLru:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; - // We write out the list backwards. Things we write out first are - // the freshest in the LRU. Things at the end of the list will be - // the next to be evicted. + // We write out the list backwards. Things we write out first are the + // freshest in the LRU. Things at the end of the list will be the next to + // be evicted. LightMutexHolder holder(_lock); @@ -295,11 +272,9 @@ write(ostream &out, int indent_level) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_add_page -// Access: Private -// Description: Adds a new page the the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new page the the LRU. + */ void AdaptiveLru:: do_add_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); @@ -310,11 +285,9 @@ do_add_page(AdaptiveLruPage *page) { ((AdaptiveLruPageStaticList *)page)->insert_before(&_static_list); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_remove_page -// Access: Private -// Description: Removes a page from the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Removes a page from the LRU. + */ void AdaptiveLru:: do_remove_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); @@ -325,19 +298,16 @@ do_remove_page(AdaptiveLruPage *page) { ((AdaptiveLruPageStaticList *)page)->remove_from_list(); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_access_page -// Access: Private -// Description: Marks a page accessed. -//////////////////////////////////////////////////////////////////// +/** + * Marks a page accessed. + */ void AdaptiveLru:: do_access_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); LightMutexHolder holder(_lock); if (page->_current_frame_identifier == _current_frame_identifier) { - // This is the second or more time this page is accessed this - // frame. + // This is the second or more time this page is accessed this frame. ++(page->_current_frame_usage); } else { @@ -354,14 +324,11 @@ do_access_page(AdaptiveLruPage *page) { ++(page->_update_total_usage); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_evict_to -// Access: Private -// Description: Evicts pages until the LRU is within the indicated -// size. Assumes the lock is already held. If -// hard_evict is false, does not evict "active" pages -// that were added within this epoch. -//////////////////////////////////////////////////////////////////// +/** + * Evicts pages until the LRU is within the indicated size. Assumes the lock + * is already held. If hard_evict is false, does not evict "active" pages + * that were added within this epoch. + */ void AdaptiveLru:: do_evict_to(size_t target_size, bool hard_evict) { int attempts; @@ -372,9 +339,8 @@ do_evict_to(size_t target_size, bool hard_evict) { int index; for (index = LPP_TotalPriorities - 1; index >= 0; index--) { - // Store the current end of the list. If pages re-enqueue - // themselves during this traversal, we don't want to visit them - // twice. + // Store the current end of the list. If pages re-enqueue themselves + // during this traversal, we don't want to visit them twice. AdaptiveLruPageDynamicList *end = (AdaptiveLruPageDynamicList *)_page_array[index]._prev; AdaptiveLruPageDynamicList *node = (AdaptiveLruPageDynamicList *)_page_array[index]._next; @@ -383,10 +349,10 @@ do_evict_to(size_t target_size, bool hard_evict) { AdaptiveLruPageDynamicList *next = (AdaptiveLruPageDynamicList *)node->_next; AdaptiveLruPage *page = (AdaptiveLruPage *)node; - if (attempts == 0 && + if (attempts == 0 && (page->_current_frame_identifier + 1 >= _current_frame_identifier)) { - // avoid swapping out pages used in the current and last - // frame on the first attempt + // avoid swapping out pages used in the current and last frame on + // the first attempt } else { // We must release the lock while we call evict_lru(). @@ -400,8 +366,8 @@ do_evict_to(size_t target_size, bool hard_evict) { } } if (node == end) { - // We've reached the former end of the list. Stop here; - // everything after has been re-queued. + // We've reached the former end of the list. Stop here; everything + // after has been re-queued. break; } node = next; @@ -411,12 +377,10 @@ do_evict_to(size_t target_size, bool hard_evict) { } while (hard_evict && attempts < 2); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLru::do_validate -// Access: Private -// Description: Checks that the LRU is internally consistent. Assume -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the LRU is internally consistent. Assume the lock is already + * held. + */ bool AdaptiveLru:: do_validate() { bool okflag = true; @@ -456,7 +420,7 @@ do_validate() { while (node != &_static_list) { AdaptiveLruPage *page = (AdaptiveLruPage *)node; counted_size += page->_lru_size; - + if (pages.find(page) == pages.end()) { nout << "page " << page << " appears in dynamic index, but not in static index (or multiple times in static index)\n"; okflag = false; @@ -474,11 +438,9 @@ do_validate() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AdaptiveLruPage:: AdaptiveLruPage(size_t lru_size) : _lru(NULL), @@ -495,11 +457,9 @@ AdaptiveLruPage(size_t lru_size) : { } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AdaptiveLruPage:: AdaptiveLruPage(const AdaptiveLruPage ©) : _lru(NULL), @@ -516,21 +476,17 @@ AdaptiveLruPage(const AdaptiveLruPage ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::Copy Assignment Operator -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AdaptiveLruPage:: operator = (const AdaptiveLruPage ©) { set_lru_size(copy.get_lru_size()); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AdaptiveLruPage:: ~AdaptiveLruPage() { if (_lru != NULL) { @@ -538,53 +494,41 @@ AdaptiveLruPage:: } } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::evict_lru -// Access: Published, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void AdaptiveLruPage:: evict_lru() { dequeue_lru(); } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AdaptiveLruPage:: output(ostream &out) const { out << "page " << this << ", " << _lru_size; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AdaptiveLruPage:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::get_num_frames -// Access: Published -// Description: Returns the number of frames since the page was first -// added to its LRU. Returns 0 if it does not have an -// LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames since the page was first added to its LRU. + * Returns 0 if it does not have an LRU. + */ unsigned int AdaptiveLruPage:: get_num_frames() const { if (_lru == (AdaptiveLru *)NULL) { @@ -593,13 +537,10 @@ get_num_frames() const { return _lru->_current_frame_identifier - _first_frame_identifier; } -//////////////////////////////////////////////////////////////////// -// Function: AdaptiveLruPage::get_num_inactive_frames -// Access: Published -// Description: Returns the number of frames since the page was last -// accessed on its LRU. Returns 0 if it does not have -// an LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames since the page was last accessed on its LRU. + * Returns 0 if it does not have an LRU. + */ unsigned int AdaptiveLruPage:: get_num_inactive_frames() const { if (_lru == (AdaptiveLru *)NULL) { @@ -611,11 +552,9 @@ get_num_inactive_frames() const { #if 0 -//////////////////////////////////////////////////////////////////// -// Function: test_adaptive_lru -// Access: -// Description: Unit test function for Lru. -//////////////////////////////////////////////////////////////////// +/** + * Unit test function for Lru. + */ void test_adaptive_lru() { int maximum_memory = 3000000; @@ -627,27 +566,27 @@ test_adaptive_lru() { AdaptiveLruPage *lru_page_3; AdaptiveLruPage *lru_page_4; AdaptiveLruPage *lru_page_5; - + lru_page_0 = new AdaptiveLruPage(1000000); cerr << "created lru_page_0: " << lru_page_0 << "\n"; lru_page_0->enqueue_lru(lru); - + lru_page_1 = new AdaptiveLruPage(1000000); cerr << "created lru_page_1: " << lru_page_1 << "\n"; lru_page_1->enqueue_lru(lru); - + lru_page_2 = new AdaptiveLruPage(1000000); cerr << "created lru_page_2: " << lru_page_2 << "\n"; lru_page_2->enqueue_lru(lru); - + lru_page_3 = new AdaptiveLruPage(1000000); cerr << "created lru_page_3: " << lru_page_3 << "\n"; lru_page_3->enqueue_lru(lru); - + lru_page_4 = new AdaptiveLruPage(1000000); cerr << "created lru_page_4: " << lru_page_4 << "\n"; lru_page_4->enqueue_lru(lru); - + lru_page_5 = new AdaptiveLruPage(1000000); cerr << "created lru_page_5: " << lru_page_5 << "\n"; lru_page_5->enqueue_lru(lru); @@ -665,7 +604,7 @@ test_adaptive_lru() { lru_page_1->mark_used_lru(lru); lru_page_1->mark_used_lru(lru); - + if (index & 0x01) { lru_page_2->mark_used_lru(lru); } @@ -687,7 +626,7 @@ test_adaptive_lru() { break; } } - + delete lru; delete lru_page_0; delete lru_page_1; diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index c5a81f4a23..cc55b6e706 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -1,16 +1,15 @@ -// Filename: adaptiveLru.h -// Created by: drose (03Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file adaptiveLru.h + * @author drose + * @date 2008-09-03 + */ #ifndef ADAPTIVELRU_H #define ADAPTIVELRU_H @@ -23,8 +22,8 @@ class AdaptiveLruPage; -// See the comment in the head of AdaptiveLruPage, below, for an -// explanation of these two silly little classes. +// See the comment in the head of AdaptiveLruPage, below, for an explanation +// of these two silly little classes. class EXPCL_PANDA_GOBJ AdaptiveLruPageDynamicList : public LinkedListNode { public: friend class AdaptiveLru; @@ -35,17 +34,14 @@ public: friend class AdaptiveLru; }; -//////////////////////////////////////////////////////////////////// -// Class : AdaptiveLru -// Description : A basic LRU-type algorithm, except that it is -// adaptive and attempts to avoid evicting pages that -// have been used more frequently (even if less -// recently) than other pages. -// -// The interface is designed to be identical to that for -// SimpleLru, so that it may be used as a drop-in -// replacement. -//////////////////////////////////////////////////////////////////// +/** + * A basic LRU-type algorithm, except that it is adaptive and attempts to + * avoid evicting pages that have been used more frequently (even if less + * recently) than other pages. + * + * The interface is designed to be identical to that for SimpleLru, so that it + * may be used as a drop-in replacement. + */ class EXPCL_PANDA_GOBJ AdaptiveLru : public Namable { PUBLISHED: AdaptiveLru(const string &name, size_t max_size); @@ -65,10 +61,9 @@ PUBLISHED: void output(ostream &out) const; void write(ostream &out, int indent_level) const; - // The following methods are specific to AdaptiveLru, and do not - // exist in the SimpleLru implementation. In most cases, the - // defaults will be sufficient, so you do not need to mess with - // them. + // The following methods are specific to AdaptiveLru, and do not exist in + // the SimpleLru implementation. In most cases, the defaults will be + // sufficient, so you do not need to mess with them. INLINE void set_weight(PN_stdfloat weight); INLINE PN_stdfloat get_weight() const; @@ -108,40 +103,35 @@ private: PN_stdfloat _weight; int _max_updates_per_frame; - // This array of linked lists keeps all of the active pages, grouped - // by priority. We reshuffle pages among these lists as they are - // accessed and as they change priority in update_page(). + // This array of linked lists keeps all of the active pages, grouped by + // priority. We reshuffle pages among these lists as they are accessed and + // as they change priority in update_page(). AdaptiveLruPageDynamicList _page_array[LPP_TotalPriorities]; - // This linked list keeps all of the active pages, in arbitrary - // order. This list exists solely to allow us to incrementally - // update pages without having to iterate through the complex lists - // above and worry about losing our place. New pages are added to - // the tail. We also move pages from the head to the tail of this - // list in do_partial_lru_update() as we process each page with - // update_page(). Pages do not move within this list other that - // that. +/* + * This linked list keeps all of the active pages, in arbitrary order. This + * list exists solely to allow us to incrementally update pages without having + * to iterate through the complex lists above and worry about losing our + * place. New pages are added to the tail. We also move pages from the head + * to the tail of this list in do_partial_lru_update() as we process each page + * with update_page(). Pages do not move within this list other that that. + */ AdaptiveLruPageStaticList _static_list; friend class AdaptiveLruPage; }; -//////////////////////////////////////////////////////////////////// -// Class : AdaptiveLruPage -// Description : One atomic piece that may be managed by a AdaptiveLru -// chain. To use this class, inherit from it and -// override evict_lru(). -// -// This class multiply inherits from two classes which -// in turn both inherit from LinkedListNode. This is -// just a sneaky C++ trick to allow this class to -// inherit from LinkedListNode twice, so that pages can -// be stored on two different linked lists -// simultaneously. The AdaptiveLru class depends on -// this; it maintains its pages in two different lists, -// one grouped by priority, and one in order by next -// partial update needs. -//////////////////////////////////////////////////////////////////// +/** + * One atomic piece that may be managed by a AdaptiveLru chain. To use this + * class, inherit from it and override evict_lru(). + * + * This class multiply inherits from two classes which in turn both inherit + * from LinkedListNode. This is just a sneaky C++ trick to allow this class + * to inherit from LinkedListNode twice, so that pages can be stored on two + * different linked lists simultaneously. The AdaptiveLru class depends on + * this; it maintains its pages in two different lists, one grouped by + * priority, and one in order by next partial update needs. + */ class EXPCL_PANDA_GOBJ AdaptiveLruPage : public AdaptiveLruPageDynamicList, public AdaptiveLruPageStaticList { PUBLISHED: AdaptiveLruPage(size_t lru_size); diff --git a/panda/src/gobj/animateVerticesRequest.I b/panda/src/gobj/animateVerticesRequest.I index 638ef052e6..01226e4694 100644 --- a/panda/src/gobj/animateVerticesRequest.I +++ b/panda/src/gobj/animateVerticesRequest.I @@ -1,23 +1,19 @@ -// Filename: animateVerticesRequest.I -// Created by: pratt (20Nov07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animateVerticesRequest.I + * @author pratt + * @date 2007-11-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimateVerticesRequest::Constructor -// Access: Published -// Description: Create a new AnimateVerticesRequest. -//////////////////////////////////////////////////////////////////// +/** + * Create a new AnimateVerticesRequest. + */ INLINE AnimateVerticesRequest:: AnimateVerticesRequest(GeomVertexData *geom_vertex_data) : _geom_vertex_data(geom_vertex_data), @@ -25,12 +21,9 @@ AnimateVerticesRequest(GeomVertexData *geom_vertex_data) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimateVerticesRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + */ INLINE bool AnimateVerticesRequest:: is_ready() const { return _is_ready; diff --git a/panda/src/gobj/animateVerticesRequest.cxx b/panda/src/gobj/animateVerticesRequest.cxx index 36166bfd48..7c152406ed 100644 --- a/panda/src/gobj/animateVerticesRequest.cxx +++ b/panda/src/gobj/animateVerticesRequest.cxx @@ -1,28 +1,24 @@ -// Filename: animateVerticesRequest.cxx -// Created by: pratt (20Nov07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animateVerticesRequest.cxx + * @author pratt + * @date 2007-11-20 + */ #include "animateVerticesRequest.h" #include "geomVertexData.h" TypeHandle AnimateVerticesRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimateVerticesRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, calls animate vertices -// on _geom_vertex_data. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, calls animate vertices on _geom_vertex_data. + */ AsyncTask::DoneStatus AnimateVerticesRequest:: do_task() { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/gobj/animateVerticesRequest.h b/panda/src/gobj/animateVerticesRequest.h index 6c113916cc..27e9ba11b2 100644 --- a/panda/src/gobj/animateVerticesRequest.h +++ b/panda/src/gobj/animateVerticesRequest.h @@ -1,16 +1,15 @@ -// Filename: animateVerticesRequest.h -// Created by: pratt (20Nov07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animateVerticesRequest.h + * @author pratt + * @date 2007-11-20 + */ #ifndef ANIMATEVERTICESREQUEST #define ANIMATEVERTICESREQUEST @@ -21,37 +20,32 @@ #include "geomVertexData.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : AnimateVerticesRequest -// Description : This class object manages a single asynchronous -// request to animate vertices on a GeomVertexData -// object. animate_vertices will be called with -// force=true (i.e. blocking) in a sub-thread (if -// threading is available). No result is stored or -// returned from this object. It is expected that the -// result will be cached and available for immediate -// use later during rendering. Thus it is important -// that the main thread block while these requests -// are being run (presumably on multiple CPUs/cores), -// to ensure that the data has been computed by the -// time it's needed. -//////////////////////////////////////////////////////////////////// +/** + * This class object manages a single asynchronous request to animate vertices + * on a GeomVertexData object. animate_vertices will be called with + * force=true (i.e. blocking) in a sub-thread (if threading is available). + * No result is stored or returned from this object. It is expected that the + * result will be cached and available for immediate use later during + * rendering. Thus it is important that the main thread block while these + * requests are being run (presumably on multiple CPUs/cores), to ensure that + * the data has been computed by the time it's needed. + */ class EXPCL_PANDA_PGRAPH AnimateVerticesRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(AnimateVerticesRequest); PUBLISHED: INLINE AnimateVerticesRequest(GeomVertexData *geom_vertex_data); - + INLINE bool is_ready() const; - + protected: virtual AsyncTask::DoneStatus do_task(); - + private: PT(GeomVertexData) _geom_vertex_data; bool _is_ready; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -65,7 +59,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/gobj/bufferContext.I b/panda/src/gobj/bufferContext.I index 3f57557016..978e3b73da 100644 --- a/panda/src/gobj/bufferContext.I +++ b/panda/src/gobj/bufferContext.I @@ -1,80 +1,63 @@ -// Filename: bufferContext.I -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContext.I + * @author drose + * @date 2006-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::get_data_size_bytes -// Access: Public -// Description: Returns the number of bytes previously reported for -// the data object. This is used to track changes in -// the data object's allocated size; if it changes from -// this, we need to create a new buffer. This is also -// used to track memory utilization in PStats. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes previously reported for the data object. This + * is used to track changes in the data object's allocated size; if it changes + * from this, we need to create a new buffer. This is also used to track + * memory utilization in PStats. + */ INLINE size_t BufferContext:: get_data_size_bytes() const { return _data_size_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::get_modified -// Access: Public -// Description: Returns the UpdateSeq that was recorded the last time -// mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UpdateSeq that was recorded the last time mark_loaded() was + * called. + */ INLINE UpdateSeq BufferContext:: get_modified() const { return _modified; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::get_active -// Access: Public -// Description: Returns the active flag associated with this object. -// An object is considered "active" if it was rendered -// in the current frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag associated with this object. An object is + * considered "active" if it was rendered in the current frame. + */ INLINE bool BufferContext:: get_active() const { return (_residency_state & BufferResidencyTracker::S_active) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::get_resident -// Access: Public -// Description: Returns the resident flag associated with this -// object. An object is considered "resident" if it -// appears to be resident in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the resident flag associated with this object. An object is + * considered "resident" if it appears to be resident in texture memory. + */ INLINE bool BufferContext:: get_resident() const { return (_residency_state & BufferResidencyTracker::S_resident) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::set_active -// Access: Public -// Description: Changes the active flag associated with this object. -// An object is considered "active" if it was rendered -// in the current frame. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active flag associated with this object. An object is + * considered "active" if it was rendered in the current frame. + */ INLINE void BufferContext:: set_active(bool flag) { if (flag) { _residency_state |= BufferResidencyTracker::S_active; - // Assume that rendering the object automatically makes it - // resident. + // Assume that rendering the object automatically makes it resident. _residency_state |= BufferResidencyTracker::S_resident; } else { _residency_state &= ~BufferResidencyTracker::S_active; @@ -82,13 +65,10 @@ set_active(bool flag) { set_owning_chain(&_residency->_chains[_residency_state]); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::set_resident -// Access: Public -// Description: Changes the resident flag associated with this -// object. An object is considered "resident" if it -// appears to be resident in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Changes the resident flag associated with this object. An object is + * considered "resident" if it appears to be resident in texture memory. + */ INLINE void BufferContext:: set_resident(bool flag) { if (flag) { @@ -99,13 +79,10 @@ set_resident(bool flag) { set_owning_chain(&_residency->_chains[_residency_state]); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::get_next -// Access: Public -// Description: This can be used along with -// BufferContextChain::get_first() to walk through the -// list of objects stored on a tracker. -//////////////////////////////////////////////////////////////////// +/** + * This can be used along with BufferContextChain::get_first() to walk through + * the list of objects stored on a tracker. + */ INLINE BufferContext *BufferContext:: get_next() const { nassertr(_owning_chain != (BufferContextChain *)NULL, NULL); @@ -115,12 +92,10 @@ get_next() const { return (BufferContext *)_next; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::update_data_size_bytes -// Access: Public -// Description: Should be called (usually by a derived class) when -// the on-card size of this object has changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (usually by a derived class) when the on-card size of this + * object has changed. + */ INLINE void BufferContext:: update_data_size_bytes(size_t new_data_size_bytes) { if (_owning_chain != (BufferContextChain *)NULL) { @@ -129,12 +104,10 @@ update_data_size_bytes(size_t new_data_size_bytes) { _data_size_bytes = new_data_size_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::update_modified -// Access: Public -// Description: Should be called (usually by a derived class) when -// the modified counter for this object has changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (usually by a derived class) when the modified counter for + * this object has changed. + */ INLINE void BufferContext:: update_modified(UpdateSeq new_modified) { _modified = new_modified; diff --git a/panda/src/gobj/bufferContext.cxx b/panda/src/gobj/bufferContext.cxx index 43cabde793..b8d7ed4ba8 100644 --- a/panda/src/gobj/bufferContext.cxx +++ b/panda/src/gobj/bufferContext.cxx @@ -1,26 +1,23 @@ -// Filename: bufferContext.cxx -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContext.cxx + * @author drose + * @date 2006-03-16 + */ #include "bufferContext.h" TypeHandle BufferContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BufferContext:: BufferContext(BufferResidencyTracker *residency) : _residency(residency), @@ -31,25 +28,21 @@ BufferContext(BufferResidencyTracker *residency) : set_owning_chain(&residency->_chains[0]); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BufferContext:: ~BufferContext() { set_owning_chain(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContext::set_owning_chain -// Access: Private -// Description: Moves this object to a different BufferContextChain. -//////////////////////////////////////////////////////////////////// +/** + * Moves this object to a different BufferContextChain. + */ void BufferContext:: set_owning_chain(BufferContextChain *chain) { if (chain != _owning_chain) { - if (_owning_chain != (BufferContextChain *)NULL){ + if (_owning_chain != (BufferContextChain *)NULL){ --(_owning_chain->_count); _owning_chain->adjust_bytes(-(int)_data_size_bytes); remove_from_list(); diff --git a/panda/src/gobj/bufferContext.h b/panda/src/gobj/bufferContext.h index a449299486..dedf5411e9 100644 --- a/panda/src/gobj/bufferContext.h +++ b/panda/src/gobj/bufferContext.h @@ -1,16 +1,15 @@ -// Filename: bufferContext.h -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContext.h + * @author drose + * @date 2006-03-16 + */ #ifndef BUFFERCONTEXT_H #define BUFFERCONTEXT_H @@ -25,19 +24,16 @@ class PreparedGraphicsObjects; -//////////////////////////////////////////////////////////////////// -// Class : BufferContext -// Description : This is a base class for those kinds of SavedContexts -// that occupy an easily-measured (and substantial) -// number of bytes in the video card's frame buffer -// memory or AGP memory. At the present, this includes -// most of the SavedContext types: VertexBufferContext -// and IndexBufferContext, as well as TextureContext. -// -// This class provides methods for tracking the video -// memory utilization, as well as residency of each -// object, via PStats. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for those kinds of SavedContexts that occupy an + * easily-measured (and substantial) number of bytes in the video card's frame + * buffer memory or AGP memory. At the present, this includes most of the + * SavedContext types: VertexBufferContext and IndexBufferContext, as well as + * TextureContext. + * + * This class provides methods for tracking the video memory utilization, as + * well as residency of each object, via PStats. + */ class EXPCL_PANDA_GOBJ BufferContext : public SavedContext, private LinkedListNode { public: BufferContext(BufferResidencyTracker *residency); @@ -99,4 +95,3 @@ private: #include "bufferContext.I" #endif - diff --git a/panda/src/gobj/bufferContextChain.I b/panda/src/gobj/bufferContextChain.I index 1b60aae052..ff627967c0 100644 --- a/panda/src/gobj/bufferContextChain.I +++ b/panda/src/gobj/bufferContextChain.I @@ -1,23 +1,19 @@ -// Filename: bufferContextChain.I -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContextChain.I + * @author drose + * @date 2006-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain:: BufferContextChain() : LinkedListNode(true), // This object is the root of a list of BufferContexts. @@ -26,43 +22,35 @@ BufferContextChain() : { } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain:: ~BufferContextChain() { nassertv(_total_size == 0 && _count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::get_total_size -// Access: Public -// Description: Returns the total number of bytes represented by the -// BufferContexts currently assigned to this tracker. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes represented by the BufferContexts + * currently assigned to this tracker. + */ INLINE size_t BufferContextChain:: get_total_size() const { return _total_size; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::get_count -// Access: Public -// Description: Returns the total number of BufferContexts currently -// assigned to this tracker. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of BufferContexts currently assigned to this + * tracker. + */ INLINE int BufferContextChain:: get_count() const { return _count; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::adjust_bytes -// Access: Private -// Description: Adds or removes some from the total byte count. -//////////////////////////////////////////////////////////////////// +/** + * Adds or removes some from the total byte count. + */ INLINE void BufferContextChain:: adjust_bytes(int delta) { _total_size += delta; diff --git a/panda/src/gobj/bufferContextChain.cxx b/panda/src/gobj/bufferContextChain.cxx index 3fbccd7a04..a5f9d782b5 100644 --- a/panda/src/gobj/bufferContextChain.cxx +++ b/panda/src/gobj/bufferContextChain.cxx @@ -1,47 +1,38 @@ -// Filename: bufferContextChain.cxx -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContextChain.cxx + * @author drose + * @date 2006-03-16 + */ #include "bufferContextChain.h" #include "bufferContext.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::get_first -// Access: Public -// Description: Returns the first BufferContext object stored in the -// tracker. You can walk through the entire list of -// objects stored on the tracker by calling get_next() -// on each returned object, until the return value is -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first BufferContext object stored in the tracker. You can walk + * through the entire list of objects stored on the tracker by calling + * get_next() on each returned object, until the return value is NULL. + */ BufferContext *BufferContextChain:: get_first() { - // This method is declared non-inline so we can include - // bufferContext.h, which is necessary for proper downcasting of the - // _next pointer. + // This method is declared non-inline so we can include bufferContext.h, + // which is necessary for proper downcasting of the _next pointer. if (_next == this) { return NULL; } return (BufferContext *)_next; } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::take_from -// Access: Public -// Description: Moves all of the BufferContexts from the other -// tracker onto this one. -//////////////////////////////////////////////////////////////////// +/** + * Moves all of the BufferContexts from the other tracker onto this one. + */ void BufferContextChain:: take_from(BufferContextChain &other) { _total_size += other._total_size; @@ -59,11 +50,9 @@ take_from(BufferContextChain &other) { take_list_from(&other); } -//////////////////////////////////////////////////////////////////// -// Function: BufferContextChain::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BufferContextChain:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/panda/src/gobj/bufferContextChain.h b/panda/src/gobj/bufferContextChain.h index dab47947c3..a9943fddbf 100644 --- a/panda/src/gobj/bufferContextChain.h +++ b/panda/src/gobj/bufferContextChain.h @@ -1,16 +1,15 @@ -// Filename: bufferContextChain.h -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferContextChain.h + * @author drose + * @date 2006-03-16 + */ #ifndef BUFFERCONTEXTCHAIN_H #define BUFFERCONTEXTCHAIN_H @@ -20,17 +19,15 @@ class BufferContext; -//////////////////////////////////////////////////////////////////// -// Class : BufferContextChain -// Description : This class maintains a linked list of BufferContexts -// that might be allocated on the graphics card in some -// context. There is a different BufferContextChain for -// resident textures, active textures, evicted textures, -// etc. -// -// The primary purpose of this class is to facilitate -// PStats reporting of graphics memory usage. -//////////////////////////////////////////////////////////////////// +/** + * This class maintains a linked list of BufferContexts that might be + * allocated on the graphics card in some context. There is a different + * BufferContextChain for resident textures, active textures, evicted + * textures, etc. + * + * The primary purpose of this class is to facilitate PStats reporting of + * graphics memory usage. + */ class EXPCL_PANDA_GOBJ BufferContextChain : private LinkedListNode { public: INLINE BufferContextChain(); @@ -56,4 +53,3 @@ private: #include "bufferContextChain.I" #endif - diff --git a/panda/src/gobj/bufferResidencyTracker.I b/panda/src/gobj/bufferResidencyTracker.I index 37accaa7db..b490807363 100644 --- a/panda/src/gobj/bufferResidencyTracker.I +++ b/panda/src/gobj/bufferResidencyTracker.I @@ -1,53 +1,43 @@ -// Filename: bufferResidencyTracker.I -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferResidencyTracker.I + * @author drose + * @date 2006-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::get_inactive_nonresident -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain &BufferResidencyTracker:: get_inactive_nonresident() { return _chains[S_inactive_nonresident]; } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::get_active_nonresident -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain &BufferResidencyTracker:: get_active_nonresident() { return _chains[S_active_nonresident]; } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::get_inactive_resident -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain &BufferResidencyTracker:: get_inactive_resident() { return _chains[S_inactive_resident]; } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::get_active_resident -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BufferContextChain &BufferResidencyTracker:: get_active_resident() { return _chains[S_active_resident]; diff --git a/panda/src/gobj/bufferResidencyTracker.cxx b/panda/src/gobj/bufferResidencyTracker.cxx index 704c8f7703..00f0a4e5be 100644 --- a/panda/src/gobj/bufferResidencyTracker.cxx +++ b/panda/src/gobj/bufferResidencyTracker.cxx @@ -1,16 +1,15 @@ -// Filename: bufferResidencyTracker.cxx -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferResidencyTracker.cxx + * @author drose + * @date 2006-03-16 + */ #include "bufferResidencyTracker.h" #include "bufferContext.h" @@ -19,11 +18,9 @@ PStatCollector BufferResidencyTracker::_gmem_collector("Graphics memory"); -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BufferResidencyTracker:: BufferResidencyTracker(const string &pgo_name, const string &type_name) : _pgo_collector(_gmem_collector, pgo_name), @@ -35,11 +32,9 @@ BufferResidencyTracker(const string &pgo_name, const string &type_name) : { } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BufferResidencyTracker:: ~BufferResidencyTracker() { _inactive_nonresident_collector.set_level(0); @@ -48,20 +43,18 @@ BufferResidencyTracker:: _active_resident_collector.set_level(0); } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::begin_frame -// Access: Public -// Description: To be called at the beginning of a frame, this -// initializes the active/inactive status. -//////////////////////////////////////////////////////////////////// +/** + * To be called at the beginning of a frame, this initializes the + * active/inactive status. + */ void BufferResidencyTracker:: begin_frame(Thread *current_thread) { int this_frame = ClockObject::get_global_clock()->get_frame_count(current_thread); if (_active_frame != this_frame) { _active_frame = this_frame; - // Move all of the previously "active" objects into "inactive". - // They'll get re-added to "active" as they get rendered. + // Move all of the previously "active" objects into "inactive". They'll + // get re-added to "active" as they get rendered. move_inactive(_chains[S_inactive_nonresident], _chains[S_active_nonresident]); move_inactive(_chains[S_inactive_resident], @@ -69,12 +62,10 @@ begin_frame(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::end_frame -// Access: Public -// Description: To be called at the end of a frame, this -// updates the PStatCollectors appropriately. -//////////////////////////////////////////////////////////////////// +/** + * To be called at the end of a frame, this updates the PStatCollectors + * appropriately. + */ void BufferResidencyTracker:: end_frame(Thread *current_thread) { _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size()); @@ -83,12 +74,10 @@ end_frame(Thread *current_thread) { _active_resident_collector.set_level(_chains[S_active_resident].get_total_size()); } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::set_levels -// Access: Public -// Description: Resets the pstats levels to their appropriate values, -// possibly in the middle of a frame. -//////////////////////////////////////////////////////////////////// +/** + * Resets the pstats levels to their appropriate values, possibly in the + * middle of a frame. + */ void BufferResidencyTracker:: set_levels() { _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size()); @@ -97,11 +86,9 @@ set_levels() { _active_resident_collector.set_level(_chains[S_active_resident].get_total_size()); } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BufferResidencyTracker:: write(ostream &out, int indent_level) const { if (_chains[S_inactive_nonresident].get_count() != 0) { @@ -125,11 +112,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BufferResidencyTracker::move_inactive -// Access: Private -// Description: Moves all of the "active" objects into "inactive". -//////////////////////////////////////////////////////////////////// +/** + * Moves all of the "active" objects into "inactive". + */ void BufferResidencyTracker:: move_inactive(BufferContextChain &inactive, BufferContextChain &active) { BufferContext *node = active.get_first(); diff --git a/panda/src/gobj/bufferResidencyTracker.h b/panda/src/gobj/bufferResidencyTracker.h index 786d18bc14..973d249d41 100644 --- a/panda/src/gobj/bufferResidencyTracker.h +++ b/panda/src/gobj/bufferResidencyTracker.h @@ -1,16 +1,15 @@ -// Filename: bufferResidencyTracker.h -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bufferResidencyTracker.h + * @author drose + * @date 2006-03-16 + */ #ifndef BUFFERRESIDENCYTRACKER_H #define BUFFERRESIDENCYTRACKER_H @@ -21,18 +20,15 @@ class BufferContext; -//////////////////////////////////////////////////////////////////// -// Class : BufferResidencyTracker -// Description : This class is used to keep track of the current state -// of all the BufferContexts for a particular graphics -// context: whether each one is active (rendered this -// frame) or inactive (not rendered this frame), and -// whether it is resident or nonresident in video -// memory. -// -// The primary purpose of this class is to facilitate -// PStats reporting of video card memory usage. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to keep track of the current state of all the + * BufferContexts for a particular graphics context: whether each one is + * active (rendered this frame) or inactive (not rendered this frame), and + * whether it is resident or nonresident in video memory. + * + * The primary purpose of this class is to facilitate PStats reporting of + * video card memory usage. + */ class EXPCL_PANDA_GOBJ BufferResidencyTracker { public: BufferResidencyTracker(const string &pgo_name, const string &type_name); @@ -75,8 +71,8 @@ private: static PStatCollector _gmem_collector; PStatCollector _pgo_collector; - // One PStatCollector for each state. These are ordered in reverse - // order that we would like them to appear in the PStats graph. + // One PStatCollector for each state. These are ordered in reverse order + // that we would like them to appear in the PStats graph. PStatCollector _active_resident_collector; PStatCollector _active_nonresident_collector; PStatCollector _inactive_resident_collector; diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index 0481a63dc1..f753126f19 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -1,16 +1,15 @@ -// Filename: config_gobj.cxx -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gobj.cxx + * @author drose + * @date 1999-10-01 + */ #include "animateVerticesRequest.h" #include "bufferContext.h" @@ -604,8 +603,8 @@ ConfigureFn(config_gobj) { VertexTransform::init_type(); VideoTexture::init_type(); - //Registration of writeable object's creation - //functions with BamReader's factory + // Registration of writeable object's creation functions with BamReader's + // factory Geom::register_with_read_factory(); GeomLines::register_with_read_factory(); GeomLinestrips::register_with_read_factory(); diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index de9e14050d..e9780873ea 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -1,16 +1,15 @@ -// Filename: config_gobj.h -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gobj.h + * @author drose + * @date 1999-10-01 + */ #ifndef CONFIG_GOBJ_H #define CONFIG_GOBJ_H diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index b639041c85..05ddfd85ff 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -1,68 +1,53 @@ -// Filename: geom.I -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geom.I + * @author drose + * @date 2005-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_primitive_type -// Access: Published -// Description: Returns the fundamental primitive type that is common -// to all GeomPrimitives added within the Geom. All -// nested primitives within a particular Geom must be -// the same type (that is, you can mix triangles and -// tristrips, because they are both the same fundamental -// type PT_polygons, but you cannot mix triangles and -// points withn the same Geom). -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental primitive type that is common to all GeomPrimitives + * added within the Geom. All nested primitives within a particular Geom must + * be the same type (that is, you can mix triangles and tristrips, because + * they are both the same fundamental type PT_polygons, but you cannot mix + * triangles and points withn the same Geom). + */ INLINE Geom::PrimitiveType Geom:: get_primitive_type() const { CDReader cdata(_cycler); return cdata->_primitive_type; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_shade_model -// Access: Published -// Description: Returns the shade model common to all of the -// individual GeomPrimitives that have been added to the -// geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shade model common to all of the individual GeomPrimitives that + * have been added to the geom. + */ INLINE Geom::ShadeModel Geom:: get_shade_model() const { CDReader cdata(_cycler); return cdata->_shade_model; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_geom_rendering -// Access: Published -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this Geom. + */ INLINE int Geom:: get_geom_rendering() const { CDReader cdata(_cycler); return cdata->_geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_usage_hint -// Access: Published -// Description: Returns the minimum (i.e. most dynamic) usage_hint -// among all of the individual GeomPrimitives that have -// been added to the geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum (i.e. most dynamic) usage_hint among all of the + * individual GeomPrimitives that have been added to the geom. + */ INLINE Geom::UsageHint Geom:: get_usage_hint() const { CDLockedReader cdata(_cycler); @@ -74,52 +59,41 @@ get_usage_hint() const { return cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_vertex_data -// Access: Published -// Description: Returns a const pointer to the GeomVertexData, -// for application code to directly examine (but not -// modify) the geom's underlying data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the GeomVertexData, for application code to + * directly examine (but not modify) the geom's underlying data. + */ INLINE CPT(GeomVertexData) Geom:: get_vertex_data(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_data.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::is_empty -// Access: Published -// Description: Returns true if there appear to be no vertices to be -// rendered by this Geom, false if has some actual data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there appear to be no vertices to be rendered by this Geom, + * false if has some actual data. + */ INLINE bool Geom:: is_empty() const { CDReader cdata(_cycler); return cdata->_primitives.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_num_primitives -// Access: Published -// Description: Returns the number of GeomPrimitive objects stored -// within the Geom, each of which represents a number of -// primitives of a particular type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of GeomPrimitive objects stored within the Geom, each of + * which represents a number of primitives of a particular type. + */ INLINE int Geom:: get_num_primitives() const { CDReader cdata(_cycler); return cdata->_primitives.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_primitive -// Access: Published -// Description: Returns a const pointer to the ith GeomPrimitive -// object stored within the Geom. Use this call only to -// inspect the ith object; use modify_primitive() or -// set_primitive() if you want to modify it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the ith GeomPrimitive object stored within the + * Geom. Use this call only to inspect the ith object; use modify_primitive() + * or set_primitive() if you want to modify it. + */ INLINE CPT(GeomPrimitive) Geom:: get_primitive(int i) const { CDReader cdata(_cycler); @@ -127,18 +101,14 @@ get_primitive(int i) const { return cdata->_primitives[i].get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::modify_primitive -// Access: Published -// Description: Returns a modifiable pointer to the ith GeomPrimitive -// object stored within the Geom, so application code -// can directly manipulate the properties of this -// primitive. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the ith GeomPrimitive object stored within + * the Geom, so application code can directly manipulate the properties of + * this primitive. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE PT(GeomPrimitive) Geom:: modify_primitive(int i) { Thread *current_thread = Thread::get_current_thread(); @@ -150,13 +120,10 @@ modify_primitive(int i) { return cdata->_primitives[i].get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::decompose -// Access: Published -// Description: Decomposes all of the primitives within this Geom, -// returning the result. See -// GeomPrimitive::decompose(). -//////////////////////////////////////////////////////////////////// +/** + * Decomposes all of the primitives within this Geom, returning the result. + * See GeomPrimitive::decompose(). + */ INLINE PT(Geom) Geom:: decompose() const { PT(Geom) new_geom = make_copy(); @@ -164,13 +131,10 @@ decompose() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::doubleside -// Access: Published -// Description: Doublesides all of the primitives within this Geom, -// returning the result. See -// GeomPrimitive::doubleside(). -//////////////////////////////////////////////////////////////////// +/** + * Doublesides all of the primitives within this Geom, returning the result. + * See GeomPrimitive::doubleside(). + */ INLINE PT(Geom) Geom:: doubleside() const { PT(Geom) new_geom = make_copy(); @@ -178,13 +142,10 @@ doubleside() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::reverse -// Access: Published -// Description: Reverses all of the primitives within this Geom, -// returning the result. See -// GeomPrimitive::reverse(). -//////////////////////////////////////////////////////////////////// +/** + * Reverses all of the primitives within this Geom, returning the result. See + * GeomPrimitive::reverse(). + */ INLINE PT(Geom) Geom:: reverse() const { PT(Geom) new_geom = make_copy(); @@ -192,13 +153,10 @@ reverse() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::rotate -// Access: Published -// Description: Rotates all of the primitives within this Geom, -// returning the result. See -// GeomPrimitive::rotate(). -//////////////////////////////////////////////////////////////////// +/** + * Rotates all of the primitives within this Geom, returning the result. See + * GeomPrimitive::rotate(). + */ INLINE PT(Geom) Geom:: rotate() const { PT(Geom) new_geom = make_copy(); @@ -206,22 +164,17 @@ rotate() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::unify -// Access: Published -// Description: Unifies all of the primitives contained within this -// Geom into a single (or as few as possible, within the -// constraints of max_indices) primitive objects. This -// may require decomposing the primitives if, for -// instance, the Geom contains both triangle strips and -// triangle fans. -// -// max_indices represents the maximum number of indices -// that will be put in any one GeomPrimitive. If -// preserve_order is true, then the primitives will not -// be reordered during the operation, even if this -// results in a suboptimal result. -//////////////////////////////////////////////////////////////////// +/** + * Unifies all of the primitives contained within this Geom into a single (or + * as few as possible, within the constraints of max_indices) primitive + * objects. This may require decomposing the primitives if, for instance, the + * Geom contains both triangle strips and triangle fans. + * + * max_indices represents the maximum number of indices that will be put in + * any one GeomPrimitive. If preserve_order is true, then the primitives will + * not be reordered during the operation, even if this results in a suboptimal + * result. + */ INLINE PT(Geom) Geom:: unify(int max_indices, bool preserve_order) const { PT(Geom) new_geom = make_copy(); @@ -229,12 +182,10 @@ unify(int max_indices, bool preserve_order) const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_points -// Access: Published -// Description: Returns a new Geom with points at all the vertices. -// See GeomPrimitive::make_points(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Geom with points at all the vertices. See + * GeomPrimitive::make_points(). + */ INLINE PT(Geom) Geom:: make_points() const { PT(Geom) new_geom = make_copy(); @@ -242,12 +193,10 @@ make_points() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_lines -// Access: Published -// Description: Returns a new Geom with lines at all the edges. -// See GeomPrimitive::make_lines(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Geom with lines at all the edges. See + * GeomPrimitive::make_lines(). + */ INLINE PT(Geom) Geom:: make_lines() const { PT(Geom) new_geom = make_copy(); @@ -255,12 +204,10 @@ make_lines() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_patches -// Access: Published -// Description: Returns a new Geom with each primitive converted -// into a patch. Calls decompose() first. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Geom with each primitive converted into a patch. Calls + * decompose() first. + */ INLINE PT(Geom) Geom:: make_patches() const { PT(Geom) new_geom = make_copy(); @@ -268,53 +215,40 @@ make_patches() const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time any of the primitives in -// the Geom is modified, or the set of primitives is -// modified. However, this does not include -// modifications to the vertex data, which should be -// tested separately. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * any of the primitives in the Geom is modified, or the set of primitives is + * modified. However, this does not include modifications to the vertex data, + * which should be tested separately. + */ INLINE UpdateSeq Geom:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::mark_bounds_stale -// Access: Published -// Description: Marks the bounding volume of the Geom as stale so -// that it should be recomputed. Usually it is not -// necessary to call this explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Marks the bounding volume of the Geom as stale so that it should be + * recomputed. Usually it is not necessary to call this explicitly. + */ INLINE void Geom:: mark_bounds_stale() const { CDWriter cdata(((Geom *)this)->_cycler, false); ((Geom *)this)->mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::set_bounds_type -// Access: Published -// Description: Specifies the desired type of bounding volume that -// will be created for this Geom. This is normally -// BoundingVolume::BT_default, which means to set the -// type according to the config variable "bounds-type". -// -// If this is BT_sphere or BT_box, a BoundingSphere or -// BoundingBox is explicitly created. If it is BT_best, -// a BoundingBox is created. -// -// This affects the implicit bounding volume only. If -// an explicit bounding volume is set on the Geom with -// set_bounds(), that bounding volume type is used. -// (This is different behavior from the similar method -// on PandaNode.) -//////////////////////////////////////////////////////////////////// +/** + * Specifies the desired type of bounding volume that will be created for this + * Geom. This is normally BoundingVolume::BT_default, which means to set the + * type according to the config variable "bounds-type". + * + * If this is BT_sphere or BT_box, a BoundingSphere or BoundingBox is + * explicitly created. If it is BT_best, a BoundingBox is created. + * + * This affects the implicit bounding volume only. If an explicit bounding + * volume is set on the Geom with set_bounds(), that bounding volume type is + * used. (This is different behavior from the similar method on PandaNode.) + */ INLINE void Geom:: set_bounds_type(BoundingVolume::BoundsType bounds_type) { CDWriter cdata(_cycler, true); @@ -322,31 +256,24 @@ set_bounds_type(BoundingVolume::BoundsType bounds_type) { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_bounds_type -// Access: Published -// Description: Returns the bounding volume type set with -// set_bounds_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume type set with set_bounds_type(). + */ INLINE BoundingVolume::BoundsType Geom:: get_bounds_type() const { CDReader cdata(_cycler); return cdata->_bounds_type; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::set_bounds -// Access: Published -// Description: Resets the bounding volume so that it is the -// indicated volume. When it is explicitly set, the -// bounding volume will no longer be automatically -// computed; call clear_bounds() if you would like to -// return the bounding volume to its default behavior. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Resets the bounding volume so that it is the indicated volume. When it is + * explicitly set, the bounding volume will no longer be automatically + * computed; call clear_bounds() if you would like to return the bounding + * volume to its default behavior. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE void Geom:: set_bounds(const BoundingVolume *volume) { CDWriter cdata(_cycler, true); @@ -357,18 +284,14 @@ set_bounds(const BoundingVolume *volume) { } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::clear_bounds -// Access: Published -// Description: Reverses the effect of a previous call to -// set_bounds(), and allows the bounding volume to be -// automatically computed once more based on the -// vertices. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the effect of a previous call to set_bounds(), and allows the + * bounding volume to be automatically computed once more based on the + * vertices. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE void Geom:: clear_bounds() { CDWriter cdata(_cycler, true); @@ -376,21 +299,17 @@ clear_bounds() { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::calc_tight_bounds -// Access: Public -// Description: Expands min_point and max_point to include all of the -// vertices in the Geom, if any. found_any is set true -// if any points are found. It is the caller's -// responsibility to initialize min_point, max_point, -// and found_any before calling this function. -// -// This version of the method allows the Geom to specify -// an alternate vertex data table (for instance, if the -// vertex data has already been munged), and also allows -// the result to be computed in any coordinate space by -// specifying a transform matrix. -//////////////////////////////////////////////////////////////////// +/** + * Expands min_point and max_point to include all of the vertices in the Geom, + * if any. found_any is set true if any points are found. It is the caller's + * responsibility to initialize min_point, max_point, and found_any before + * calling this function. + * + * This version of the method allows the Geom to specify an alternate vertex + * data table (for instance, if the vertex data has already been munged), and + * also allows the result to be computed in any coordinate space by specifying + * a transform matrix. + */ INLINE void Geom:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, @@ -406,19 +325,15 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, cdata, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::calc_tight_bounds -// Access: Public, Virtual -// Description: Expands min_point and max_point to include all of the -// vertices in the Geom, if any. found_any is set true -// if any points are found. It is the caller's -// responsibility to initialize min_point, max_point, -// and found_any before calling this function. -// -// This version of the method assumes the Geom will use -// its own vertex data, and the results are computed in -// the Geom's own coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Expands min_point and max_point to include all of the vertices in the Geom, + * if any. found_any is set true if any points are found. It is the caller's + * responsibility to initialize min_point, max_point, and found_any before + * calling this function. + * + * This version of the method assumes the Geom will use its own vertex data, + * and the results are computed in the Geom's own coordinate space. + */ INLINE void Geom:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const { @@ -429,12 +344,9 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::calc_tight_bounds -// Access: Public -// Description: Similar to calc_tight_bounds(), for UV coordinates or -// other named columns. -//////////////////////////////////////////////////////////////////// +/** + * Similar to calc_tight_bounds(), for UV coordinates or other named columns. + */ INLINE void Geom:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, @@ -450,24 +362,19 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, column_name, cdata, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::mark_internal_bounds_stale -// Access: Private -// Description: Should be called to mark the internal bounding -// volume stale, so that recompute_internal_bounds() -// will be called when the bounding volume is next -// requested. -//////////////////////////////////////////////////////////////////// +/** + * Should be called to mark the internal bounding volume stale, so that + * recompute_internal_bounds() will be called when the bounding volume is next + * requested. + */ INLINE void Geom:: mark_internal_bounds_stale(CData *cdata) { cdata->_internal_bounds_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CDataCache::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CDataCache:: CDataCache() : _source(NULL), @@ -476,11 +383,9 @@ CDataCache() : { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CDataCache::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CDataCache:: CDataCache(const Geom::CDataCache ©) : _source(copy._source), @@ -492,13 +397,10 @@ CDataCache(const Geom::CDataCache ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CDataCache::set_result -// Access: Public -// Description: Stores the geom_result and data_result on the cache, -// upping and/or dropping the reference count -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Stores the geom_result and data_result on the cache, upping and/or dropping + * the reference count appropriately. + */ INLINE void Geom::CDataCache:: set_result(const Geom *geom_result, const GeomVertexData *data_result) { if (geom_result != _geom_result) { @@ -513,11 +415,9 @@ set_result(const Geom *geom_result, const GeomVertexData *data_result) { _data_result = data_result; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheKey::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheKey:: CacheKey(const GeomVertexData *source_data, const GeomMunger *modifier) : _source_data(source_data), @@ -525,11 +425,9 @@ CacheKey(const GeomVertexData *source_data, const GeomMunger *modifier) : { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheKey::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheKey:: CacheKey(const CacheKey ©) : _source_data(copy._source_data), @@ -538,11 +436,9 @@ CacheKey(const CacheKey ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheKey::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheKey:: CacheKey(CacheKey &&from) NOEXCEPT : _source_data(move(from._source_data)), @@ -551,11 +447,9 @@ CacheKey(CacheKey &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheKey::operator < -// Access: Public -// Description: Provides a unique ordering within the map. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering within the map. + */ INLINE bool Geom::CacheKey:: operator < (const CacheKey &other) const { if (_modifier != other._modifier) { @@ -570,11 +464,9 @@ operator < (const CacheKey &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheEntry:: CacheEntry(Geom *source, const GeomVertexData *source_data, const GeomMunger *modifier) : @@ -583,11 +475,9 @@ CacheEntry(Geom *source, const GeomVertexData *source_data, { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheEntry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheEntry:: CacheEntry(Geom *source, const Geom::CacheKey &key) : _source(source), @@ -596,11 +486,9 @@ CacheEntry(Geom *source, const Geom::CacheKey &key) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheEntry::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CacheEntry:: CacheEntry(Geom *source, Geom::CacheKey &&key) NOEXCEPT : _source(source), @@ -609,11 +497,9 @@ CacheEntry(Geom *source, Geom::CacheKey &&key) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CData:: CData() : _primitive_type(PT_none), @@ -627,11 +513,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom::CData:: CData(const Geom::CData ©) : _data(copy._data), @@ -650,11 +534,9 @@ CData(const Geom::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPipelineReader:: GeomPipelineReader(const Geom *object, Thread *current_thread) : _object(object), @@ -669,37 +551,31 @@ GeomPipelineReader(const Geom *object, Thread *current_thread) : #endif // DO_PIPELINING } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE GeomPipelineReader:: GeomPipelineReader(const GeomPipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void GeomPipelineReader:: operator = (const GeomPipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPipelineReader:: ~GeomPipelineReader() { #ifdef _DEBUG nassertv(_object->test_ref_count_nonzero()); #endif // _DEBUG - // _object->_cycler.release_read(_cdata); + // _object->_cycler.release_read(_cdata); #ifdef DO_PIPELINING unref_delete((CycleData *)_cdata); @@ -711,124 +587,99 @@ INLINE GeomPipelineReader:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const Geom *GeomPipelineReader:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *GeomPipelineReader:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_primitive_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPipelineReader::PrimitiveType GeomPipelineReader:: get_primitive_type() const { return _cdata->_primitive_type; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_shade_model -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPipelineReader::ShadeModel GeomPipelineReader:: get_shade_model() const { return _cdata->_shade_model; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_geom_rendering -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPipelineReader:: get_geom_rendering() const { return _cdata->_geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_usage_hint -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPipelineReader::UsageHint GeomPipelineReader:: get_usage_hint() const { nassertr(_cdata->_got_usage_hint, UH_static); return _cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_vertex_data -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(GeomVertexData) GeomPipelineReader:: get_vertex_data() const { return _cdata->_data.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_num_primitives -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPipelineReader:: get_num_primitives() const { return _cdata->_primitives.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_primitive -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(GeomPrimitive) GeomPipelineReader:: get_primitive(int i) const { nassertr(i >= 0 && i < (int)_cdata->_primitives.size(), NULL); return _cdata->_primitives[i].get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::get_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq GeomPipelineReader:: get_modified() const { return _cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::prepare_now -// Access: Public -// Description: Creates a context for the geom on the particular -// GSG, if it does not already exist. Returns the new -// (or old) GeomContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// geoms. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a geom does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the geom on the particular GSG, if it does not + * already exist. Returns the new (or old) GeomContext. This assumes that + * the GraphicsStateGuardian is the currently active rendering context and + * that it is ready to accept new geoms. If this is not necessarily the case, + * you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a geom does not need to be explicitly prepared by the user before it may be + * rendered. + */ INLINE GeomContext *GeomPipelineReader:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const { diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 08c1fdcf1d..2b7e914d86 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -1,16 +1,15 @@ -// Filename: geom.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geom.cxx + * @author drose + * @date 2005-03-06 + */ #include "geom.h" #include "geomPoints.h" @@ -35,21 +34,17 @@ TypeHandle Geom::CacheEntry::_type_handle; TypeHandle Geom::CData::_type_handle; TypeHandle GeomPipelineReader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) Geom:: make_cow_copy() { return make_copy(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Geom:: Geom(const GeomVertexData *data) { // Let's ensure the vertex data gets set on all stages at once. @@ -60,11 +55,9 @@ Geom(const GeomVertexData *data) { CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::Copy Constructor -// Access: Protected -// Description: Use make_copy() to duplicate a Geom. -//////////////////////////////////////////////////////////////////// +/** + * Use make_copy() to duplicate a Geom. + */ Geom:: Geom(const Geom ©) : CopyOnWriteObject(copy), @@ -72,14 +65,11 @@ Geom(const Geom ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::Copy Assignment Operator -// Access: Published -// Description: The copy assignment operator is not pipeline-safe. -// This will completely obliterate all stages of the -// pipeline, so don't do it for a Geom that is actively -// being used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * The copy assignment operator is not pipeline-safe. This will completely + * obliterate all stages of the pipeline, so don't do it for a Geom that is + * actively being used for rendering. + */ void Geom:: operator = (const Geom ©) { CopyOnWriteObject::operator = (copy); @@ -95,41 +85,32 @@ operator = (const Geom ©) { CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Geom:: ~Geom() { clear_cache(); release_all(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_copy -// Access: Protected, Virtual -// Description: Returns a newly-allocated Geom that is a shallow copy -// of this one. It will be a different Geom pointer, -// but its internal data may or may not be shared with -// that of the original Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Geom that is a shallow copy of this one. It will + * be a different Geom pointer, but its internal data may or may not be shared + * with that of the original Geom. + */ Geom *Geom:: make_copy() const { return new Geom(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::set_usage_hint -// Access: Published -// Description: Changes the UsageHint hint for all of the primitives -// on this Geom to the same value. See -// get_usage_hint(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the UsageHint hint for all of the primitives on this Geom to the + * same value. See get_usage_hint(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: set_usage_hint(Geom::UsageHint usage_hint) { Thread *current_thread = Thread::get_current_thread(); @@ -146,39 +127,32 @@ set_usage_hint(Geom::UsageHint usage_hint) { cdata->_modified = Geom::get_next_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::modify_vertex_data -// Access: Published -// Description: Returns a modifiable pointer to the GeomVertexData, -// so that application code may directly maniuplate the -// geom's underlying data. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the GeomVertexData, so that application + * code may directly maniuplate the geom's underlying data. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ PT(GeomVertexData) Geom:: modify_vertex_data() { Thread *current_thread = Thread::get_current_thread(); - // Perform copy-on-write: if the reference count on the vertex data - // is greater than 1, assume some other Geom has the same pointer, - // so make a copy of it first. + // Perform copy-on-write: if the reference count on the vertex data is + // greater than 1, assume some other Geom has the same pointer, so make a + // copy of it first. CDWriter cdata(_cycler, true, current_thread); clear_cache_stage(current_thread); mark_internal_bounds_stale(cdata); return cdata->_data.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::set_vertex_data -// Access: Published -// Description: Replaces the Geom's underlying vertex data table with -// a completely new table. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the Geom's underlying vertex data table with a completely new + * table. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: set_vertex_data(const GeomVertexData *data) { Thread *current_thread = Thread::get_current_thread(); @@ -190,21 +164,16 @@ set_vertex_data(const GeomVertexData *data) { reset_geom_rendering(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::offset_vertices -// Access: Published -// Description: Replaces a Geom's vertex table with a new table, and -// simultaneously adds the indicated offset to all -// vertex references within the Geom's primitives. This -// is intended to be used to combine multiple -// GeomVertexDatas from different Geoms into a single -// big buffer, with each Geom referencing a subset of -// the vertices in the buffer. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces a Geom's vertex table with a new table, and simultaneously adds + * the indicated offset to all vertex references within the Geom's primitives. + * This is intended to be used to combine multiple GeomVertexDatas from + * different Geoms into a single big buffer, with each Geom referencing a + * subset of the vertices in the buffer. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: offset_vertices(const GeomVertexData *data, int offset) { Thread *current_thread = Thread::get_current_thread(); @@ -235,19 +204,15 @@ offset_vertices(const GeomVertexData *data, int offset) { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_nonindexed -// Access: Published -// Description: Converts the geom from indexed to nonindexed by -// duplicating vertices as necessary. If composite_only -// is true, then only composite primitives such as -// trifans and tristrips are converted. Returns the -// number of GeomPrimitive objects converted. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Converts the geom from indexed to nonindexed by duplicating vertices as + * necessary. If composite_only is true, then only composite primitives such + * as trifans and tristrips are converted. Returns the number of + * GeomPrimitive objects converted. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ int Geom:: make_nonindexed(bool composite_only) { Thread *current_thread = Thread::get_current_thread(); @@ -268,10 +233,9 @@ make_nonindexed(bool composite_only) { PT(GeomPrimitive) primitive = (*pi).get_read_pointer()->make_copy(); new_prims.push_back(primitive.p()); - // GeomPoints are considered "composite" for the purposes of - // making nonindexed, since there's no particular advantage to - // having indexed points (as opposed to, say, indexed triangles or - // indexed lines). + // GeomPoints are considered "composite" for the purposes of making + // nonindexed, since there's no particular advantage to having indexed + // points (as opposed to, say, indexed triangles or indexed lines). if (primitive->is_indexed() && (primitive->is_composite() || primitive->is_exact_type(GeomPoints::get_class_type()) || @@ -279,8 +243,8 @@ make_nonindexed(bool composite_only) { primitive->make_nonindexed(new_data, orig_data); ++num_changed; } else { - // If it's a simple primitive, pack it anyway, so it can share - // the same GeomVertexData. + // If it's a simple primitive, pack it anyway, so it can share the same + // GeomVertexData. primitive->pack_vertices(new_data, orig_data); } @@ -294,9 +258,8 @@ make_nonindexed(bool composite_only) { nassertr(all_is_valid, 0); if (num_changed != 0) { - // If any at all were changed, then keep the result (otherwise, - // discard it, since we might have de-optimized the indexed - // geometry a bit). + // If any at all were changed, then keep the result (otherwise, discard + // it, since we might have de-optimized the indexed geometry a bit). cdata->_data = new_data; cdata->_primitives.swap(new_prims); cdata->_modified = Geom::get_next_modified(); @@ -306,16 +269,13 @@ make_nonindexed(bool composite_only) { return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::set_primitive -// Access: Published -// Description: Replaces the ith GeomPrimitive object stored within -// the Geom with the new object. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the ith GeomPrimitive object stored within the Geom with the new + * object. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: set_primitive(int i, const GeomPrimitive *primitive) { Thread *current_thread = Thread::get_current_thread(); @@ -323,8 +283,8 @@ set_primitive(int i, const GeomPrimitive *primitive) { nassertv(i >= 0 && i < (int)cdata->_primitives.size()); nassertv(primitive->check_valid(cdata->_data.get_read_pointer())); - // All primitives within a particular Geom must have the same - // fundamental primitive type (triangles, points, or lines). + // All primitives within a particular Geom must have the same fundamental + // primitive type (triangles, points, or lines). nassertv(cdata->_primitive_type == PT_none || cdata->_primitive_type == primitive->get_primitive_type()); @@ -350,18 +310,14 @@ set_primitive(int i, const GeomPrimitive *primitive) { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::add_primitive -// Access: Published -// Description: Adds a new GeomPrimitive structure to the Geom -// object. This specifies a particular subset of -// vertices that are used to define geometric primitives -// of the indicated type. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new GeomPrimitive structure to the Geom object. This specifies a + * particular subset of vertices that are used to define geometric primitives + * of the indicated type. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: add_primitive(const GeomPrimitive *primitive) { Thread *current_thread = Thread::get_current_thread(); @@ -369,8 +325,8 @@ add_primitive(const GeomPrimitive *primitive) { nassertv(primitive->check_valid(cdata->_data.get_read_pointer())); - // All primitives within a particular Geom must have the same - // fundamental primitive type (triangles, points, or lines). + // All primitives within a particular Geom must have the same fundamental + // primitive type (triangles, points, or lines). nassertv(cdata->_primitive_type == PT_none || cdata->_primitive_type == primitive->get_primitive_type()); @@ -396,15 +352,12 @@ add_primitive(const GeomPrimitive *primitive) { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::remove_primitive -// Access: Published -// Description: Removes the ith primitive from the list. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes the ith primitive from the list. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: remove_primitive(int i) { Thread *current_thread = Thread::get_current_thread(); @@ -422,18 +375,14 @@ remove_primitive(int i) { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::clear_primitives -// Access: Published -// Description: Removes all the primitives from the Geom object (but -// keeps the same table of vertices). You may then -// re-add primitives one at a time via calls to -// add_primitive(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the primitives from the Geom object (but keeps the same table + * of vertices). You may then re-add primitives one at a time via calls to + * add_primitive(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: clear_primitives() { Thread *current_thread = Thread::get_current_thread(); @@ -446,17 +395,13 @@ clear_primitives() { mark_internal_bounds_stale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::decompose_in_place -// Access: Published -// Description: Decomposes all of the primitives within this Geom, -// leaving the results in place. See -// GeomPrimitive::decompose(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes all of the primitives within this Geom, leaving the results in + * place. See GeomPrimitive::decompose(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: decompose_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -484,17 +429,13 @@ decompose_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::doubleside_in_place -// Access: Published -// Description: Doublesides all of the primitives within this Geom, -// leaving the results in place. See -// GeomPrimitive::doubleside(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Doublesides all of the primitives within this Geom, leaving the results in + * place. See GeomPrimitive::doubleside(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: doubleside_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -522,17 +463,13 @@ doubleside_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::reverse_in_place -// Access: Published -// Description: Reverses all of the primitives within this Geom, -// leaving the results in place. See -// GeomPrimitive::reverse(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Reverses all of the primitives within this Geom, leaving the results in + * place. See GeomPrimitive::reverse(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: reverse_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -560,17 +497,13 @@ reverse_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::rotate_in_place -// Access: Published -// Description: Rotates all of the primitives within this Geom, -// leaving the results in place. See -// GeomPrimitive::rotate(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Rotates all of the primitives within this Geom, leaving the results in + * place. See GeomPrimitive::rotate(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: rotate_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -610,26 +543,20 @@ rotate_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::unify_in_place -// Access: Published -// Description: Unifies all of the primitives contained within this -// Geom into a single (or as few as possible, within the -// constraints of max_indices) primitive objects. This -// may require decomposing the primitives if, for -// instance, the Geom contains both triangle strips and -// triangle fans. -// -// max_indices represents the maximum number of indices -// that will be put in any one GeomPrimitive. If -// preserve_order is true, then the primitives will not -// be reordered during the operation, even if this -// results in a suboptimal result. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Unifies all of the primitives contained within this Geom into a single (or + * as few as possible, within the constraints of max_indices) primitive + * objects. This may require decomposing the primitives if, for instance, the + * Geom contains both triangle strips and triangle fans. + * + * max_indices represents the maximum number of indices that will be put in + * any one GeomPrimitive. If preserve_order is true, then the primitives will + * not be reordered during the operation, even if this results in a suboptimal + * result. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: unify_in_place(int max_indices, bool preserve_order) { if (gobj_cat.is_debug()) { @@ -640,8 +567,8 @@ unify_in_place(int max_indices, bool preserve_order) { Thread *current_thread = Thread::get_current_thread(); if (get_num_primitives() <= 1) { - // If we don't have more than one primitive to start with, no need - // to do anything. + // If we don't have more than one primitive to start with, no need to do + // anything. return; } @@ -660,17 +587,15 @@ unify_in_place(int max_indices, bool preserve_order) { if (npi == new_prims.end()) { // This is the first primitive of this type. if (!keep_different_types && !new_prims.empty()) { - // Actually, since we aren't trying to keep the different - // types of primitives, we should try to combine this type and - // the other type by decomposing them both (into triangles, - // segments, or whatever). + // Actually, since we aren't trying to keep the different types of + // primitives, we should try to combine this type and the other type + // by decomposing them both (into triangles, segments, or whatever). // First, decompose the incoming one. primitive = primitive->decompose(); npi = new_prims.find(primitive->get_type()); if (npi == new_prims.end()) { - // That didn't help, so decompose the one already in the - // table. + // That didn't help, so decompose the one already in the table. nassertv(new_prims.size() == 1); npi = new_prims.begin(); CPT(GeomPrimitive) np = (*npi).second->decompose(); @@ -686,8 +611,8 @@ unify_in_place(int max_indices, bool preserve_order) { new_prims.insert(NewPrims::value_type(primitive->get_type(), primitive->make_copy())); } else { - // We have already encountered another primitive of this type. - // Combine them. + // We have already encountered another primitive of this type. Combine + // them. combine_primitives((*npi).second, primitive, current_thread); } } @@ -695,15 +620,15 @@ unify_in_place(int max_indices, bool preserve_order) { // Now, we have one or more primitives, but only one of each type. #ifndef NDEBUG if (!keep_different_types && new_prims.size() > 1) { - // This shouldn't be possible, because we decompose as we go, in - // the loop above. (We have to decompose as we go to preserve the - // ordering of the primitives.) + // This shouldn't be possible, because we decompose as we go, in the loop + // above. (We have to decompose as we go to preserve the ordering of the + // primitives.) nassertv(false); } #endif - // Finally, iterate through the remaining primitives, and copy them - // to the output list. + // Finally, iterate through the remaining primitives, and copy them to the + // output list. cdata->_primitives.clear(); NewPrims::iterator npi; for (npi = new_prims.begin(); npi != new_prims.end(); ++npi) { @@ -711,8 +636,7 @@ unify_in_place(int max_indices, bool preserve_order) { nassertv(prim->check_valid(cdata->_data.get_read_pointer())); - // Each new primitive, naturally, inherits the Geom's overall - // shade model. + // Each new primitive, naturally, inherits the Geom's overall shade model. prim->set_shade_model(cdata->_shade_model); // Should we split it up again to satisfy max_indices? @@ -750,17 +674,14 @@ unify_in_place(int max_indices, bool preserve_order) { reset_geom_rendering(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_lines_in_place -// Access: Published -// Description: Replaces the GeomPrimitives within this Geom with -// corresponding GeomLines, representing a wireframe -// of the primitives. See GeomPrimitive::make_lines(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the GeomPrimitives within this Geom with corresponding GeomLines, + * representing a wireframe of the primitives. See + * GeomPrimitive::make_lines(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: make_lines_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -788,17 +709,13 @@ make_lines_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_points_in_place -// Access: Published -// Description: Replaces the GeomPrimitives within this Geom with -// corresponding GeomPoints. See -// GeomPrimitive::make_points(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the GeomPrimitives within this Geom with corresponding GeomPoints. + * See GeomPrimitive::make_points(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: make_points_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -826,17 +743,13 @@ make_points_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_patches_in_place -// Access: Published -// Description: Replaces the GeomPrimitives within this Geom with -// corresponding GeomPatches. See -// GeomPrimitive::make_patches(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the GeomPrimitives within this Geom with corresponding + * GeomPatches. See GeomPrimitive::make_patches(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: make_patches_in_place() { Thread *current_thread = Thread::get_current_thread(); @@ -864,20 +777,16 @@ make_patches_in_place() { nassertv(all_is_valid); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::copy_primitives_from -// Access: Published, Virtual -// Description: Copies the primitives from the indicated Geom into -// this one. This does require that both Geoms contain -// the same fundamental type primitives, both have a -// compatible shade model, and both use the same -// GeomVertexData. Both Geoms must also be the same -// specific class type (i.e. if one is a GeomTextGlyph, -// they both must be.) -// -// Returns true if the copy is successful, or false -// otherwise (because the Geoms were mismatched). -//////////////////////////////////////////////////////////////////// +/** + * Copies the primitives from the indicated Geom into this one. This does + * require that both Geoms contain the same fundamental type primitives, both + * have a compatible shade model, and both use the same GeomVertexData. Both + * Geoms must also be the same specific class type (i.e. if one is a + * GeomTextGlyph, they both must be.) + * + * Returns true if the copy is successful, or false otherwise (because the + * Geoms were mismatched). + */ bool Geom:: copy_primitives_from(const Geom *other) { if (get_primitive_type() != PT_none && @@ -913,12 +822,10 @@ copy_primitives_from(const Geom *other) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_num_bytes -// Access: Published -// Description: Returns the number of bytes consumed by the geom and -// its primitives (but not including its vertex table). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes consumed by the geom and its primitives (but + * not including its vertex table). + */ int Geom:: get_num_bytes() const { CDReader cdata(_cycler); @@ -934,17 +841,14 @@ get_num_bytes() const { return num_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::request_resident -// Access: Published -// Description: Returns true if all the primitive arrays are -// currently resident in memory. If this returns false, -// the data will be brought back into memory shortly; -// try again later. -// -// This does not also test the Geom's associated -// GeomVertexData. That must be tested separately. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all the primitive arrays are currently resident in memory. + * If this returns false, the data will be brought back into memory shortly; + * try again later. + * + * This does not also test the Geom's associated GeomVertexData. That must be + * tested separately. + */ bool Geom:: request_resident() const { CDReader cdata(_cycler); @@ -963,19 +867,15 @@ request_resident() const { return resident; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::transform_vertices -// Access: Published -// Description: Applies the indicated transform to all of the -// vertices in the Geom. If the Geom happens to share a -// vertex table with another Geom, this operation will -// duplicate the vertex table instead of breaking the -// other Geom; however, if multiple Geoms with shared -// tables are transformed by the same matrix, they will -// no longer share tables after the operation. Consider -// using the GeomTransformer if you will be applying the -// same transform to multiple Geoms. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform to all of the vertices in the Geom. If the + * Geom happens to share a vertex table with another Geom, this operation will + * duplicate the vertex table instead of breaking the other Geom; however, if + * multiple Geoms with shared tables are transformed by the same matrix, they + * will no longer share tables after the operation. Consider using the + * GeomTransformer if you will be applying the same transform to multiple + * Geoms. + */ void Geom:: transform_vertices(const LMatrix4 &mat) { PT(GeomVertexData) new_data = modify_vertex_data(); @@ -1000,14 +900,11 @@ transform_vertices(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::check_valid -// Access: Published -// Description: Verifies that the all of the primitives within the -// geom reference vertices that actually exist within -// the geom's GeomVertexData. Returns true if the geom -// appears to be valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the all of the primitives within the geom reference vertices + * that actually exist within the geom's GeomVertexData. Returns true if the + * geom appears to be valid, false otherwise. + */ bool Geom:: check_valid() const { Thread *current_thread = Thread::get_current_thread(); @@ -1017,14 +914,11 @@ check_valid() const { return geom_reader.check_valid(&data_reader); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::check_valid -// Access: Published -// Description: Verifies that the all of the primitives within the -// geom reference vertices that actually exist within -// the indicated GeomVertexData. Returns true if the -// geom appears to be valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the all of the primitives within the geom reference vertices + * that actually exist within the indicated GeomVertexData. Returns true if + * the geom appears to be valid, false otherwise. + */ bool Geom:: check_valid(const GeomVertexData *vertex_data) const { Thread *current_thread = Thread::get_current_thread(); @@ -1034,11 +928,9 @@ check_valid(const GeomVertexData *vertex_data) const { return geom_reader.check_valid(&data_reader); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_bounds -// Access: Published -// Description: Returns the bounding volume for the Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume for the Geom. + */ CPT(BoundingVolume) Geom:: get_bounds(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); @@ -1054,12 +946,9 @@ get_bounds(Thread *current_thread) const { return cdata->_internal_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_nested_vertices -// Access: Published -// Description: Returns the number of vertices rendered by all -// primitives within the Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices rendered by all primitives within the Geom. + */ int Geom:: get_nested_vertices(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); @@ -1071,11 +960,9 @@ get_nested_vertices(Thread *current_thread) const { return cdata->_nested_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Geom:: output(ostream &out) const { CDReader cdata(_cycler); @@ -1100,11 +987,9 @@ output(ostream &out) const { out << " ], " << num_faces << " faces"; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Geom:: write(ostream &out, int indent_level) const { CDReader cdata(_cycler); @@ -1118,17 +1003,13 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::clear_cache -// Access: Published -// Description: Removes all of the previously-cached results of -// munge_geom(). -// -// This blows away the entire cache, upstream and -// downstream the pipeline. Use clear_cache_stage() -// instead if you only want to blow away the cache at -// the current stage and upstream. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-cached results of munge_geom(). + * + * This blows away the entire cache, upstream and downstream the pipeline. + * Use clear_cache_stage() instead if you only want to blow away the cache at + * the current stage and upstream. + */ void Geom:: clear_cache() { LightMutexHolder holder(_cache_lock); @@ -1141,17 +1022,13 @@ clear_cache() { _cache.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::clear_cache_stage -// Access: Published -// Description: Removes all of the previously-cached results of -// munge_geom(), at the current pipeline stage and -// upstream. Does not affect the downstream cache. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-cached results of munge_geom(), at the + * current pipeline stage and upstream. Does not affect the downstream cache. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void Geom:: clear_cache_stage(Thread *current_thread) { LightMutexHolder holder(_cache_lock); @@ -1164,30 +1041,24 @@ clear_cache_stage(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::prepare -// Access: Published -// Description: Indicates that the geom should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. This will ensure the -// geom is already loaded into geom memory if it -// is expected to be rendered soon. -// -// Use this function instead of prepare_now() to preload -// geoms from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the geom should be enqueued to be prepared in the indicated + * prepared_objects at the beginning of the next frame. This will ensure the + * geom is already loaded into geom memory if it is expected to be rendered + * soon. + * + * Use this function instead of prepare_now() to preload geoms from a user + * interface standpoint. + */ void Geom:: prepare(PreparedGraphicsObjects *prepared_objects) { prepared_objects->enqueue_geom(this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::is_prepared -// Access: Published -// Description: Returns true if the geom has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the geom has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool Geom:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { Contexts::const_iterator ci; @@ -1198,13 +1069,10 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_geom_queued(this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::release -// Access: Published -// Description: Frees the geom context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the geom context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ bool Geom:: release(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -1219,19 +1087,16 @@ release(PreparedGraphicsObjects *prepared_objects) { return prepared_objects->dequeue_geom(this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::release_all -// Access: Published -// Description: Frees the context allocated on all objects for which -// the geom has been declared. Returns the number of -// contexts which have been freed. -//////////////////////////////////////////////////////////////////// +/** + * Frees the context allocated on all objects for which the geom has been + * declared. Returns the number of contexts which have been freed. + */ int Geom:: release_all() { // We have to traverse a copy of the _contexts list, because the - // PreparedGraphicsObjects object will call clear_prepared() in response - // to each release_geom(), and we don't want to be modifying the - // _contexts list while we're traversing it. + // PreparedGraphicsObjects object will call clear_prepared() in response to + // each release_geom(), and we don't want to be modifying the _contexts list + // while we're traversing it. Contexts temp = _contexts; int num_freed = (int)_contexts.size(); @@ -1242,29 +1107,24 @@ release_all() { prepared_objects->release_geom(gc); } - // Now that we've called release_geom() on every known context, - // the _contexts list should have completely emptied itself. + // Now that we've called release_geom() on every known context, the + // _contexts list should have completely emptied itself. nassertr(_contexts.empty(), num_freed); return num_freed; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::prepare_now -// Access: Public -// Description: Creates a context for the geom on the particular -// GSG, if it does not already exist. Returns the new -// (or old) GeomContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// geoms. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a geom does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the geom on the particular GSG, if it does not + * already exist. Returns the new (or old) GeomContext. This assumes that + * the GraphicsStateGuardian is the currently active rendering context and + * that it is ready to accept new geoms. If this is not necessarily the case, + * you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a geom does not need to be explicitly prepared by the user before it may be + * rendered. + */ GeomContext *Geom:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { @@ -1281,19 +1141,14 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, return gc; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::draw -// Access: Public -// Description: Actually draws the Geom with the indicated GSG, using -// the indicated vertex data (which might have been -// pre-munged to support the GSG's needs). -// -// Returns true if all of the primitives were drawn -// normally, false if there was a problem (for instance, -// some of the data was nonresident). If force is -// passed true, it will wait for the data to become -// resident if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Actually draws the Geom with the indicated GSG, using the indicated vertex + * data (which might have been pre-munged to support the GSG's needs). + * + * Returns true if all of the primitives were drawn normally, false if there + * was a problem (for instance, some of the data was nonresident). If force + * is passed true, it will wait for the data to become resident if necessary. + */ bool Geom:: draw(GraphicsStateGuardianBase *gsg, const GeomMunger *munger, const GeomVertexData *vertex_data, bool force, @@ -1307,31 +1162,24 @@ draw(GraphicsStateGuardianBase *gsg, const GeomMunger *munger, return geom_reader.draw(gsg, munger, &data_reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::get_next_modified -// Access: Public, Static -// Description: Returns a monotonically increasing sequence. Each -// time this is called, a new sequence number is -// returned, higher than the previous value. -// -// This is used to ensure that -// GeomVertexArrayData::get_modified() and -// GeomPrimitive::get_modified() update from the same -// space, so that Geom::get_modified() returns a -// meaningful value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a monotonically increasing sequence. Each time this is called, a + * new sequence number is returned, higher than the previous value. + * + * This is used to ensure that GeomVertexArrayData::get_modified() and + * GeomPrimitive::get_modified() update from the same space, so that + * Geom::get_modified() returns a meaningful value. + */ UpdateSeq Geom:: get_next_modified() { ++_next_modified; return _next_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::compute_internal_bounds -// Access: Private -// Description: Recomputes the dynamic bounding volume for this Geom. -// This includes all of the vertices. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the dynamic bounding volume for this Geom. This includes all of + * the vertices. + */ void Geom:: compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { int num_vertices = 0; @@ -1363,9 +1211,9 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { case BoundingVolume::BT_fastest: case BoundingVolume::BT_default: { - // When considering a box, calculate (roughly) the average area - // of the sides. We will use this to determine whether a sphere - // or box is a better fit. + // When considering a box, calculate (roughly) the average area of the + // sides. We will use this to determine whether a sphere or box is a + // better fit. PN_stdfloat min_extent = min(pmax[0] - pmin[0], min(pmax[1] - pmin[1], pmax[2] - pmin[2])); @@ -1374,7 +1222,7 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { pmax[2] - pmin[2])); avg_box_area = ((min_extent * min_extent) + (max_extent * max_extent)) / 2; } - // Fall through + // Fall through case BoundingVolume::BT_sphere: { // Determine the best radius for a bounding sphere. @@ -1383,8 +1231,8 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { if (btype != BoundingVolume::BT_fastest && aabb_center.length_squared() / best_sq_radius >= (0.2f * 0.2f)) { - // Hmm, this is an off-center model. Maybe we can do a better - // job by calculating the bounding sphere from the AABB center. + // Hmm, this is an off-center model. Maybe we can do a better job + // by calculating the bounding sphere from the AABB center. PN_stdfloat better_sq_radius; bool found_any = false; @@ -1412,8 +1260,8 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { break; } else if (sq_center_dist <= best_sq_radius) { - // No, but a sphere centered on the origin is apparently - // still better than a sphere around the bounding box. + // No, but a sphere centered on the origin is apparently still + // better than a sphere around the bounding box. cdata->_internal_bounds = new BoundingSphere(LPoint3::origin(), csqrt(sq_center_dist)); break; @@ -1453,11 +1301,9 @@ compute_internal_bounds(Geom::CData *cdata, Thread *current_thread) const { cdata->_internal_bounds_stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::do_calc_tight_bounds -// Access: Private -// Description: The private implementation of calc_tight_bounds(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of calc_tight_bounds(). + */ void Geom:: do_calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, PN_stdfloat &sq_center_dist, bool &found_any, @@ -1476,11 +1322,9 @@ do_calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::do_calc_sphere_radius -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Geom:: do_calc_sphere_radius(const LPoint3 ¢er, PN_stdfloat &sq_radius, bool &found_any, const GeomVertexData *vertex_data, @@ -1495,15 +1339,12 @@ do_calc_sphere_radius(const LPoint3 ¢er, PN_stdfloat &sq_radius, } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::clear_prepared -// Access: Private -// Description: Removes the indicated PreparedGraphicsObjects table -// from the Geom's table, without actually releasing -// the geom. This is intended to be called only from -// PreparedGraphicsObjects::release_geom(); it should -// never be called by user code. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PreparedGraphicsObjects table from the Geom's table, + * without actually releasing the geom. This is intended to be called only + * from PreparedGraphicsObjects::release_geom(); it should never be called by + * user code. + */ void Geom:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -1511,22 +1352,18 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { if (ci != _contexts.end()) { _contexts.erase(ci); } else { - // If this assertion fails, clear_prepared() was given a - // prepared_objects that the geom didn't know about. + // If this assertion fails, clear_prepared() was given a prepared_objects + // that the geom didn't know about. nassertv(false); } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::check_will_be_valid -// Access: Private -// Description: Verifies that the all of the primitives within the -// geom reference vertices that actually exist within -// the indicated GeomVertexData (presumably in -// preparation for assigning the geom to use this data). -// Returns true if the data appears to be valid, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the all of the primitives within the geom reference vertices + * that actually exist within the indicated GeomVertexData (presumably in + * preparation for assigning the geom to use this data). Returns true if the + * data appears to be valid, false otherwise. + */ bool Geom:: check_will_be_valid(const GeomVertexData *vertex_data) const { CDReader cdata(_cycler); @@ -1543,11 +1380,9 @@ check_will_be_valid(const GeomVertexData *vertex_data) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::reset_usage_hint -// Access: Private -// Description: Recomputes the minimum usage_hint. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the minimum usage_hint. + */ void Geom:: reset_usage_hint(Geom::CData *cdata) { cdata->_usage_hint = UH_unspecified; @@ -1561,11 +1396,9 @@ reset_usage_hint(Geom::CData *cdata) { cdata->_got_usage_hint = true; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::reset_geom_rendering -// Access: Private -// Description: Rederives the _geom_rendering member. -//////////////////////////////////////////////////////////////////// +/** + * Rederives the _geom_rendering member. + */ void Geom:: reset_geom_rendering(Geom::CData *cdata) { cdata->_geom_rendering = 0; @@ -1603,13 +1436,10 @@ reset_geom_rendering(Geom::CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::combine_primitives -// Access: Private -// Description: Combines two primitives of the same type into a -// single primitive. a_prim is modified to append the -// vertices from b_prim, which is unmodified. -//////////////////////////////////////////////////////////////////// +/** + * Combines two primitives of the same type into a single primitive. a_prim + * is modified to append the vertices from b_prim, which is unmodified. + */ void Geom:: combine_primitives(GeomPrimitive *a_prim, const GeomPrimitive *b_prim, Thread *current_thread) { @@ -1661,23 +1491,18 @@ combine_primitives(GeomPrimitive *a_prim, const GeomPrimitive *b_prim, } } -//////////////////////////////////////////////////////////////////// -// Function: Geom::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void Geom:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Geom:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -1685,14 +1510,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *Geom:: make_from_bam(const FactoryParams ¶ms) { Geom *object = new Geom(NULL); @@ -1706,36 +1528,30 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void Geom:: finalize(BamReader *manager) { CDWriter cdata(_cycler, true); - // Make sure our GeomVertexData is finalized first. This may result - // in the data getting finalized multiple times, but it doesn't mind - // that. + // Make sure our GeomVertexData is finalized first. This may result in the + // data getting finalized multiple times, but it doesn't mind that. if (!cdata->_data.is_null()) { - // We shouldn't call get_write_pointer(), which might replicate - // the GeomVertexData unnecessarily. + // We shouldn't call get_write_pointer(), which might replicate the + // GeomVertexData unnecessarily. cdata->_data.get_unsafe_pointer()->finalize(manager); } reset_geom_rendering(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Geom. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Geom. + */ void Geom:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -1743,32 +1559,26 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CDataCache::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Geom::CDataCache:: ~CDataCache() { set_result(NULL, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CDataCache::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Geom::CDataCache:: make_copy() const { return new CDataCache(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheEntry::evict_callback -// Access: Public, Virtual -// Description: Called when the entry is evicted from the cache, this -// should clean up the owning object appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called when the entry is evicted from the cache, this should clean up the + * owning object appropriately. + */ void Geom::CacheEntry:: evict_callback() { LightMutexHolder holder(_source->_cache_lock); @@ -1778,11 +1588,9 @@ evict_callback() { _source->_cache.erase(ci); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CacheEntry::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Geom::CacheEntry:: output(ostream &out) const { out << "geom " << (void *)_source << ", " @@ -1790,22 +1598,18 @@ output(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Geom::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Geom::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { manager->write_pointer(dg, _data.get_read_pointer()); @@ -1819,20 +1623,17 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint8(_primitive_type); dg.add_uint8(_shade_model); - // Actually, we shouldn't bother writing out _geom_rendering; we'll - // just throw it away anyway. + // Actually, we shouldn't bother writing out _geom_rendering; we'll just + // throw it away anyway. dg.add_uint16(_geom_rendering); dg.add_uint8(_bounds_type); } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int Geom::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -1847,13 +1648,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: Geom::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Geom. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Geom. + */ void Geom::CData:: fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); @@ -1868,8 +1666,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { _primitive_type = (PrimitiveType)scan.get_uint8(); _shade_model = (ShadeModel)scan.get_uint8(); - // To be removed: we no longer read _geom_rendering from the bam - // file; instead, we rederive it in finalize(). + // To be removed: we no longer read _geom_rendering from the bam file; + // instead, we rederive it in finalize(). scan.get_uint16(); _got_usage_hint = false; @@ -1881,18 +1679,14 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::check_usage_hint -// Access: Public -// Description: Ensures that the Geom's usage_hint cache has been -// computed. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the Geom's usage_hint cache has been computed. + */ void GeomPipelineReader:: check_usage_hint() const { if (!_cdata->_got_usage_hint) { - // We'll need to get a fresh pointer, since another thread might - // already have modified the pointer on the object since we - // queried it. + // We'll need to get a fresh pointer, since another thread might already + // have modified the pointer on the object since we queried it. { #ifdef DO_PIPELINING unref_delete((CycleData *)_cdata); @@ -1904,26 +1698,23 @@ check_usage_hint() const { _cdata->ref(); #endif if (!fresh_cdata->_got_usage_hint) { - // The cache is still stale. We have to do the work of - // freshening it. + // The cache is still stale. We have to do the work of freshening it. ((Geom *)_object)->reset_usage_hint(fresh_cdata); nassertv(fresh_cdata->_got_usage_hint); } - // When fresh_cdata goes out of scope, its write lock is - // released, and _cdata reverts to our usual convention of an - // unlocked copy of the data. + // When fresh_cdata goes out of scope, its write lock is released, and + // _cdata reverts to our usual convention of an unlocked copy of the + // data. } } nassertv(_cdata->_got_usage_hint); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::check_valid -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomPipelineReader:: check_valid(const GeomVertexDataPipelineReader *data_reader) const { Geom::Primitives::const_iterator pi; @@ -1941,11 +1732,9 @@ check_valid(const GeomVertexDataPipelineReader *data_reader) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPipelineReader::draw -// Access: Public -// Description: The implementation of Geom::draw(). -//////////////////////////////////////////////////////////////////// +/** + * The implementation of Geom::draw(). + */ bool GeomPipelineReader:: draw(GraphicsStateGuardianBase *gsg, const GeomMunger *munger, const GeomVertexDataPipelineReader *data_reader, bool force) const { diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 4a29611419..3d6715b473 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -1,16 +1,15 @@ -// Filename: geom.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geom.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOM_H #define GEOM_H @@ -44,17 +43,14 @@ class GeomContext; class PreparedGraphicsObjects; -//////////////////////////////////////////////////////////////////// -// Class : Geom -// Description : A container for geometry primitives. This class -// associates one or more GeomPrimitive objects with a -// table of vertices defined by a GeomVertexData object. -// All of the primitives stored in a particular Geom are -// drawn from the same set of vertices (each primitive -// uses a subset of all of the vertices in the table), -// and all of them must be rendered at the same time, in -// the same graphics state. -//////////////////////////////////////////////////////////////////// +/** + * A container for geometry primitives. This class associates one or more + * GeomPrimitive objects with a table of vertices defined by a GeomVertexData + * object. All of the primitives stored in a particular Geom are drawn from + * the same set of vertices (each primitive uses a subset of all of the + * vertices in the table), and all of them must be rendered at the same time, + * in the same graphics state. + */ class EXPCL_PANDA_GOBJ Geom : public CopyOnWriteObject, public GeomEnums { protected: virtual PT(CopyOnWriteObject) make_cow_copy(); @@ -207,15 +203,14 @@ private: typedef pvector Primitives; // We have to use reference-counting pointers here instead of having - // explicit cleanup in the GeomVertexFormat destructor, because the - // cache needs to be stored in the CycleData, which makes accurate - // cleanup more difficult. We use the GeomCacheManager class to - // avoid cache bloat. + // explicit cleanup in the GeomVertexFormat destructor, because the cache + // needs to be stored in the CycleData, which makes accurate cleanup more + // difficult. We use the GeomCacheManager class to avoid cache bloat. - // Note: the above comment is no longer true. The cache is not - // stored in the CycleData, which just causes problems; instead, we - // cycle each individual CacheEntry as needed. Need to investigate - // if we could simplify the cache system now. + // Note: the above comment is no longer true. The cache is not stored in + // the CycleData, which just causes problems; instead, we cycle each + // individual CacheEntry as needed. Need to investigate if we could + // simplify the cache system now. // The pipelined data with each CacheEntry. class EXPCL_PANDA_GOBJ CDataCache : public CycleData { @@ -250,11 +245,10 @@ private: typedef CycleDataWriter CDCacheWriter; public: - // The CacheKey class separates out just the part of CacheEntry that - // is used to key the cache entry within the map. We have this as a - // separate class so we can easily look up a new entry in the map, - // without having to execute the relatively expensive CacheEntry - // constructor. + // The CacheKey class separates out just the part of CacheEntry that is used + // to key the cache entry within the map. We have this as a separate class + // so we can easily look up a new entry in the map, without having to + // execute the relatively expensive CacheEntry constructor. class CacheKey { public: INLINE CacheKey(const GeomVertexData *source_data, @@ -355,8 +349,8 @@ private: Cache _cache; LightMutex _cache_lock; - // This works just like the Texture contexts: each Geom keeps a - // record of all the PGO objects that hold the Geom, and vice-versa. + // This works just like the Texture contexts: each Geom keeps a record of + // all the PGO objects that hold the Geom, and vice-versa. typedef pmap Contexts; Contexts _contexts; @@ -400,15 +394,13 @@ private: friend class PreparedGraphicsObjects; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomPipelineReader -// Description : Encapsulates the data from a Geom, -// pre-fetched for one stage of the pipeline. -// -// Does not hold a reference to the Geom. The caller -// must ensure that the Geom persists for at least the -// lifetime of the GeomPipelineReader. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a Geom, pre-fetched for one stage of the + * pipeline. + * + * Does not hold a reference to the Geom. The caller must ensure that the + * Geom persists for at least the lifetime of the GeomPipelineReader. + */ class EXPCL_PANDA_GOBJ GeomPipelineReader : public GeomEnums { public: INLINE GeomPipelineReader(const Geom *object, Thread *current_thread); diff --git a/panda/src/gobj/geomCacheEntry.I b/panda/src/gobj/geomCacheEntry.I index 9f3c1f70c7..9c7987d855 100644 --- a/panda/src/gobj/geomCacheEntry.I +++ b/panda/src/gobj/geomCacheEntry.I @@ -1,23 +1,19 @@ -// Filename: geomCacheEntry.I -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheEntry.I + * @author drose + * @date 2005-03-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomCacheEntry:: GeomCacheEntry() { #ifndef NDEBUG @@ -26,12 +22,9 @@ GeomCacheEntry() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::remove_from_list -// Access: Private -// Description: Removes a GeomCacheEntry record from the -// doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Removes a GeomCacheEntry record from the doubly-linked list. + */ INLINE void GeomCacheEntry:: remove_from_list() { nassertv(_prev->_next == this && _next->_prev == this); @@ -43,12 +36,10 @@ remove_from_list() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::insert_before -// Access: Private -// Description: Adds a GeomCacheEntry record before the indicated -// node in the doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a GeomCacheEntry record before the indicated node in the doubly-linked + * list. + */ INLINE void GeomCacheEntry:: insert_before(GeomCacheEntry *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); @@ -65,4 +56,3 @@ operator << (ostream &out, const GeomCacheEntry &entry) { entry.output(out); return out; } - diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index 173388d9b4..27ab5a9e20 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -1,16 +1,15 @@ -// Filename: geomCacheEntry.cxx -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheEntry.cxx + * @author drose + * @date 2005-03-21 + */ #include "geomCacheEntry.h" #include "geomCacheManager.h" @@ -20,21 +19,16 @@ TypeHandle GeomCacheEntry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomCacheEntry:: ~GeomCacheEntry() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::record -// Access: Public -// Description: Records the entry in the global cache for the first -// time. -//////////////////////////////////////////////////////////////////// +/** + * Records the entry in the global cache for the first time. + */ PT(GeomCacheEntry) GeomCacheEntry:: record(Thread *current_thread) { nassertr(_next == (GeomCacheEntry *)NULL && _prev == (GeomCacheEntry *)NULL, NULL); @@ -59,25 +53,21 @@ record(Thread *current_thread) { GeomCacheManager::_geom_cache_active_pcollector.add_level(1); } - // Increment our own reference count while we're in the queue, just - // so we don't have to play games with it later--this is inner-loop - // stuff. + // Increment our own reference count while we're in the queue, just so we + // don't have to play games with it later--this is inner-loop stuff. ref(); - // Now remove any old entries if our cache is over the limit. This may - // also remove the entry we just added, especially if our cache size - // is set to 0. This may actually remove this very object. + // Now remove any old entries if our cache is over the limit. This may also + // remove the entry we just added, especially if our cache size is set to 0. + // This may actually remove this very object. cache_mgr->evict_old_entries(); return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::refresh -// Access: Public -// Description: Marks the cache entry recently used, so it will not -// be evicted for a while. -//////////////////////////////////////////////////////////////////// +/** + * Marks the cache entry recently used, so it will not be evicted for a while. + */ void GeomCacheEntry:: refresh(Thread *current_thread) { GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); @@ -97,12 +87,10 @@ refresh(Thread *current_thread) { _last_frame_used = current_frame; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::erase -// Access: Public -// Description: Removes the entry from the queue, returning a pointer -// to the entry. Does not call evict_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the entry from the queue, returning a pointer to the entry. Does + * not call evict_callback(). + */ PT(GeomCacheEntry) GeomCacheEntry:: erase() { nassertr(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL, NULL); @@ -133,21 +121,17 @@ erase() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::evict_callback -// Access: Public, Virtual -// Description: Called when the entry is evicted from the cache, this -// should clean up the owning object appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called when the entry is evicted from the cache, this should clean up the + * owning object appropriately. + */ void GeomCacheEntry:: evict_callback() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheEntry::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomCacheEntry:: output(ostream &out) const { out << "[ unknown ]"; diff --git a/panda/src/gobj/geomCacheEntry.h b/panda/src/gobj/geomCacheEntry.h index b4d742bf3b..85f1dfb106 100644 --- a/panda/src/gobj/geomCacheEntry.h +++ b/panda/src/gobj/geomCacheEntry.h @@ -1,16 +1,15 @@ -// Filename: geomCacheEntry.h -// Created by: drose (21Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheEntry.h + * @author drose + * @date 2005-03-21 + */ #ifndef GEOMCACHEENTRY_H #define GEOMCACHEENTRY_H @@ -25,12 +24,10 @@ class Geom; class GeomPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : GeomCacheEntry -// Description : This object contains a single cache entry in the -// GeomCacheManager. This is actually the base class of -// any number of individual cache types. -//////////////////////////////////////////////////////////////////// +/** + * This object contains a single cache entry in the GeomCacheManager. This is + * actually the base class of any number of individual cache types. + */ class EXPCL_PANDA_GOBJ GeomCacheEntry : public ReferenceCount { public: INLINE GeomCacheEntry(); @@ -49,7 +46,7 @@ private: INLINE void remove_from_list(); INLINE void insert_before(GeomCacheEntry *node); -private: +private: GeomCacheEntry *_prev, *_next; public: @@ -61,7 +58,7 @@ public: register_type(_type_handle, "GeomCacheEntry", ReferenceCount::get_class_type()); } - + private: static TypeHandle _type_handle; diff --git a/panda/src/gobj/geomCacheManager.I b/panda/src/gobj/geomCacheManager.I index 2448ff3b82..c37bd98661 100644 --- a/panda/src/gobj/geomCacheManager.I +++ b/panda/src/gobj/geomCacheManager.I @@ -1,78 +1,62 @@ -// Filename: geomCacheManager.I -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheManager.I + * @author drose + * @date 2005-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::set_max_size -// Access: Published -// Description: Specifies the maximum number of entries in the cache -// for storing pre-processed data for rendering -// vertices. This limit is flexible, and may be -// temporarily exceeded if many different Geoms are -// pre-processed during the space of a single frame. -// -// This is not a limit on the actual vertex data, which -// is what it is; it is also not a limit on the amount -// of memory used by the video driver or the system -// graphics interface, which Panda has no control over. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum number of entries in the cache for storing pre- + * processed data for rendering vertices. This limit is flexible, and may be + * temporarily exceeded if many different Geoms are pre-processed during the + * space of a single frame. + * + * This is not a limit on the actual vertex data, which is what it is; it is + * also not a limit on the amount of memory used by the video driver or the + * system graphics interface, which Panda has no control over. + */ INLINE void GeomCacheManager:: set_max_size(int max_size) const { // We directly change the config variable. geom_cache_size = max_size; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::get_max_size -// Access: Published -// Description: Returns the maximum number of entries in the cache -// for storing pre-processed data for rendering -// vertices. See set_max_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of entries in the cache for storing pre- + * processed data for rendering vertices. See set_max_size(). + */ INLINE int GeomCacheManager:: get_max_size() const { return geom_cache_size; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::get_total_size -// Access: Published -// Description: Returns the number of entries currently in the cache. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries currently in the cache. + */ INLINE int GeomCacheManager:: get_total_size() const { return _total_size; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::evict_old_entries -// Access: Public -// Description: Trims the cache size down to get_max_size() by -// evicting old cache entries as needed. It is assumed -// that you already hold the lock before calling this -// method. -//////////////////////////////////////////////////////////////////// +/** + * Trims the cache size down to get_max_size() by evicting old cache entries + * as needed. It is assumed that you already hold the lock before calling + * this method. + */ INLINE void GeomCacheManager:: evict_old_entries() { evict_old_entries(get_max_size(), true); } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void GeomCacheManager:: flush_level() { _geom_cache_size_pcollector.flush_level(); diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index 59596d1839..b0d2624a2d 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -1,16 +1,15 @@ -// Filename: geomCacheManager.cxx -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheManager.cxx + * @author drose + * @date 2005-03-11 + */ #include "geomCacheManager.h" #include "geomCacheEntry.h" @@ -25,11 +24,9 @@ PStatCollector GeomCacheManager::_geom_cache_record_pcollector("Geom cache opera PStatCollector GeomCacheManager::_geom_cache_erase_pcollector("Geom cache operations:erase"); PStatCollector GeomCacheManager::_geom_cache_evict_pcollector("Geom cache operations:evict"); -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomCacheManager:: GeomCacheManager() : _lock("GeomCacheManager"), @@ -42,33 +39,27 @@ GeomCacheManager() : _list->_prev = _list; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomCacheManager:: ~GeomCacheManager() { // Shouldn't be deleting this global object. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::flush -// Access: Published -// Description: Immediately empties all elements in the cache. -//////////////////////////////////////////////////////////////////// +/** + * Immediately empties all elements in the cache. + */ void GeomCacheManager:: flush() { LightMutexHolder holder(_lock); evict_old_entries(0, false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::get_global_ptr -// Access: Published, Static -// Description: Returns the global cache manager pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global cache manager pointer. + */ GeomCacheManager *GeomCacheManager:: get_global_ptr() { if (_global_ptr == (GeomCacheManager *)NULL) { @@ -77,14 +68,11 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: GeomCacheManager::evict_old_entries -// Access: Public -// Description: Trims the cache size down to the specified size by -// evicting old cache entries as needed. It is assumed -// that you already hold the lock before calling this -// method. -//////////////////////////////////////////////////////////////////// +/** + * Trims the cache size down to the specified size by evicting old cache + * entries as needed. It is assumed that you already hold the lock before + * calling this method. + */ void GeomCacheManager:: evict_old_entries(int max_size, bool keep_current) { int current_frame = ClockObject::get_global_clock()->get_frame_count(); diff --git a/panda/src/gobj/geomCacheManager.h b/panda/src/gobj/geomCacheManager.h index 34979b356c..5aeaeb4249 100644 --- a/panda/src/gobj/geomCacheManager.h +++ b/panda/src/gobj/geomCacheManager.h @@ -1,16 +1,15 @@ -// Filename: geomCacheManager.h -// Created by: drose (11Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomCacheManager.h + * @author drose + * @date 2005-03-11 + */ #ifndef GEOMCACHEMANAGER_H #define GEOMCACHEMANAGER_H @@ -22,24 +21,19 @@ class GeomCacheEntry; -//////////////////////////////////////////////////////////////////// -// Class : GeomCacheManager -// Description : This is used to keep track of, and limit the size of, -// the cache of munged vertices, which would otherwise -// be distributed through all of the GeomVertexData -// objects in the system. -// -// The actual data in the cache is not stored here, but -// rather it is distributed among the various -// GeomVertexData source objects. This allows the cache -// data to propagate through the multiprocess pipeline. -// -// This structure actually caches any of a number of -// different types of pointers, and mixes them all up in -// the same LRU cache list. Some of them (such as -// GeomMunger) are reference-counted here in the cache; -// most are not. -//////////////////////////////////////////////////////////////////// +/** + * This is used to keep track of, and limit the size of, the cache of munged + * vertices, which would otherwise be distributed through all of the + * GeomVertexData objects in the system. + * + * The actual data in the cache is not stored here, but rather it is + * distributed among the various GeomVertexData source objects. This allows + * the cache data to propagate through the multiprocess pipeline. + * + * This structure actually caches any of a number of different types of + * pointers, and mixes them all up in the same LRU cache list. Some of them + * (such as GeomMunger) are reference-counted here in the cache; most are not. + */ class EXPCL_PANDA_GOBJ GeomCacheManager { protected: GeomCacheManager(); @@ -61,24 +55,22 @@ public: INLINE static void flush_level(); private: - // This mutex protects all operations on this object, especially the - // linked-list operations. + // This mutex protects all operations on this object, especially the linked- + // list operations. LightMutex _lock; int _total_size; - // We maintain a doubly-linked list to keep the cache entries in - // least-recently-used order: the items at the head of the list are - // ready to be flushed. We use our own doubly-linked list instead - // of an STL list, just so we can avoid a tiny bit of overhead, - // especially in keeping the pointer directly into the list from the - // calling objects. + // We maintain a doubly-linked list to keep the cache entries in least- + // recently-used order: the items at the head of the list are ready to be + // flushed. We use our own doubly-linked list instead of an STL list, just + // so we can avoid a tiny bit of overhead, especially in keeping the pointer + // directly into the list from the calling objects. - // The tail and the head of the list are both kept by the _prev and - // _next pointers, respectively, within the following object, which - // always exists solely to keep a handle to the list. Keeping a - // token of the list this way avoids special cases for an empty - // list. + // The tail and the head of the list are both kept by the _prev and _next + // pointers, respectively, within the following object, which always exists + // solely to keep a handle to the list. Keeping a token of the list this + // way avoids special cases for an empty list. GeomCacheEntry *_list; static GeomCacheManager *_global_ptr; diff --git a/panda/src/gobj/geomContext.I b/panda/src/gobj/geomContext.I index 8e1cbbdb2d..4cd9e17b55 100644 --- a/panda/src/gobj/geomContext.I +++ b/panda/src/gobj/geomContext.I @@ -1,34 +1,28 @@ -// Filename: geomContext.I -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomContext.I + * @author drose + * @date 2004-03-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomContext:: GeomContext(Geom *geom) : _geom(geom) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomContext::get_geom -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Geom *GeomContext:: get_geom() const { return _geom; diff --git a/panda/src/gobj/geomContext.cxx b/panda/src/gobj/geomContext.cxx index e5da4899e3..30326b9c99 100644 --- a/panda/src/gobj/geomContext.cxx +++ b/panda/src/gobj/geomContext.cxx @@ -1,16 +1,15 @@ -// Filename: geomContext.cxx -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomContext.cxx + * @author drose + * @date 2004-03-19 + */ #include "geomContext.h" diff --git a/panda/src/gobj/geomContext.h b/panda/src/gobj/geomContext.h index f80b9ec4af..e34ef5e8ce 100644 --- a/panda/src/gobj/geomContext.h +++ b/panda/src/gobj/geomContext.h @@ -1,16 +1,15 @@ -// Filename: geomContext.h -// Created by: drose (19Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomContext.h + * @author drose + * @date 2004-03-19 + */ #ifndef GEOMCONTEXT_H #define GEOMCONTEXT_H @@ -20,22 +19,18 @@ #include "savedContext.h" #include "geom.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomContext -// Description : This is a special class object that holds all the -// information returned by a particular GSG to indicate -// the geom's internal context identifier. -// -// Geoms typically have an immediate-mode and a -// retained-mode operation. When using geoms in -// retained-mode (in response to Geom::prepare()), -// the GSG will create some internal handle for the -// geom and store it here. The geom stores all of -// these handles internally. -// -// In the case of OpenGL, for example, a GeomContext -// corresponds to a display list identifier. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class object that holds all the information returned by a + * particular GSG to indicate the geom's internal context identifier. + * + * Geoms typically have an immediate-mode and a retained-mode operation. When + * using geoms in retained-mode (in response to Geom::prepare()), the GSG will + * create some internal handle for the geom and store it here. The geom + * stores all of these handles internally. + * + * In the case of OpenGL, for example, a GeomContext corresponds to a display + * list identifier. + */ class EXPCL_PANDA_GOBJ GeomContext : public SavedContext { public: INLINE GeomContext(Geom *geom); @@ -45,9 +40,8 @@ PUBLISHED: MAKE_PROPERTY(geom, get_geom); public: - // This cannot be a PT(Geom), because the geom and the GSG - // both own their GeomContexts! That would create a circular - // reference count. + // This cannot be a PT(Geom), because the geom and the GSG both own their + // GeomContexts! That would create a circular reference count. Geom *_geom; public: @@ -71,4 +65,3 @@ private: #include "geomContext.I" #endif - diff --git a/panda/src/gobj/geomEnums.cxx b/panda/src/gobj/geomEnums.cxx index 839d468113..e63260a144 100644 --- a/panda/src/gobj/geomEnums.cxx +++ b/panda/src/gobj/geomEnums.cxx @@ -1,26 +1,24 @@ -// Filename: geomEnums.cxx -// Created by: drose (14Apr05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomEnums.cxx + * @author drose + * @date 2005-04-14 + */ #include "geomEnums.h" #include "string_utils.h" #include "config_gobj.h" -//////////////////////////////////////////////////////////////////// -// Function: GeomEnums::UsageHint output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, GeomEnums::UsageHint usage_hint) { switch (usage_hint) { @@ -43,10 +41,9 @@ operator << (ostream &out, GeomEnums::UsageHint usage_hint) { return out << "**invalid usage hint (" << (int)usage_hint << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomEnums::UsageHint input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, GeomEnums::UsageHint &usage_hint) { string word; @@ -71,10 +68,9 @@ operator >> (istream &in, GeomEnums::UsageHint &usage_hint) { return in; } -//////////////////////////////////////////////////////////////////// -// Function: GeomEnums::NumericType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, GeomEnums::NumericType numeric_type) { switch (numeric_type) { @@ -118,10 +114,9 @@ operator << (ostream &out, GeomEnums::NumericType numeric_type) { return out << "**invalid numeric type (" << (int)numeric_type << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomEnums::Contents output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, GeomEnums::Contents contents) { switch (contents) { diff --git a/panda/src/gobj/geomEnums.h b/panda/src/gobj/geomEnums.h index 97883733db..42af6bb0f1 100644 --- a/panda/src/gobj/geomEnums.h +++ b/panda/src/gobj/geomEnums.h @@ -1,79 +1,73 @@ -// Filename: geomEnums.h -// Created by: drose (14Apr05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomEnums.h + * @author drose + * @date 2005-04-14 + */ #ifndef GEOMENUMS_H #define GEOMENUMS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomEnums -// Description : This class exists just to provide scoping for the -// various enumerated types used by Geom, -// GeomVertexData, GeomVertexArrayData, GeomPrimitive, -// and other related classes. -//////////////////////////////////////////////////////////////////// +/** + * This class exists just to provide scoping for the various enumerated types + * used by Geom, GeomVertexData, GeomVertexArrayData, GeomPrimitive, and other + * related classes. + */ class EXPCL_PANDA_GOBJ GeomEnums { PUBLISHED: - // The usage hint describes to the rendering backend how often the - // data in question will be modified and/or rendered. It allows the - // backend to make appropriate choices about what part of memory the - // data should be stored in. + // The usage hint describes to the rendering backend how often the data in + // question will be modified andor rendered. It allows the backend to make + // appropriate choices about what part of memory the data should be stored + // in. - // The hint is provided as a performance optimization only, and does - // not constrain actual usage; although it may be an important - // optimization. + // The hint is provided as a performance optimization only, and does not + // constrain actual usage; although it may be an important optimization. enum UsageHint { - // The following are intentionally ordered from most dynamic to - // most static. In general, if usage_a < usage_b, then usage_a is - // more dynamic than usage_b. + // The following are intentionally ordered from most dynamic to most + // static. In general, if usage_a < usage_b, then usage_a is more dynamic + // than usage_b. - // UH_client: don't attempt to upload the data; always keep it on - // the client. + // UH_client: don't attempt to upload the data; always keep it on the + // client. UH_client, - // UH_stream: the data will be created once, used to render a few - // times, and then discarded. This should be used for short-lived - // temporary objects. + // UH_stream: the data will be created once, used to render a few times, + // and then discarded. This should be used for short-lived temporary + // objects. UH_stream, - // UH_dynamic: the data will be repeatedly modified and - // re-rendered. This is for data that will be modified at - // runtime, such as animated or soft-skinned vertices. + // UH_dynamic: the data will be repeatedly modified and re-rendered. This + // is for data that will be modified at runtime, such as animated or soft- + // skinned vertices. UH_dynamic, - // UH_static: the data will be created once, and used to render - // many times, without modification. This is the most common - // case, since typically vertex data is not directly animated - // (this is not related to scene graph animation, e.g. from - // adjusting transforms on a node). + // UH_static: the data will be created once, and used to render many + // times, without modification. This is the most common case, since + // typically vertex data is not directly animated (this is not related to + // scene graph animation, e.g. from adjusting transforms on a node). UH_static, - // UH_unspecified: the usage is unspecified. This is intended as - // a "don't care" option for abstract objects; it should not be - // applied to any actual geometry to be rendered. You take your - // chances if a geom actually gets into the scene graph with this - // set. + // UH_unspecified: the usage is unspecified. This is intended as a "don't + // care" option for abstract objects; it should not be applied to any + // actual geometry to be rendered. You take your chances if a geom + // actually gets into the scene graph with this set. UH_unspecified, }; - // This type specifies a number of bits that are used to represent - // the rendering requirements of a particular Geom, as well as the - // rendering capabilities of the GSG. The difference between the - // two indicates whether the Geom needs to be munged for the GSG. + // This type specifies a number of bits that are used to represent the + // rendering requirements of a particular Geom, as well as the rendering + // capabilities of the GSG. The difference between the two indicates + // whether the Geom needs to be munged for the GSG. enum GeomRendering { // If there are indexed points. GR_indexed_point = 0x00001, @@ -93,8 +87,8 @@ PUBLISHED: // If the points have a per-vertex size designation. GR_per_point_size = 0x00008, - // If the points' size is specified in camera units rather than - // screen pixels. + // If the points' size is specified in camera units rather than screen + // pixels. GR_point_perspective = 0x00010, // If the points have a non-square aspect ratio. @@ -106,12 +100,12 @@ PUBLISHED: // If the points are rotated off the orthonormal axis. GR_point_rotate = 0x00080, - // If the points require texture coordinates interpolated across - // their face, to render textures as sprites. + // If the points require texture coordinates interpolated across their + // face, to render textures as sprites. GR_point_sprite = 0x00100, - // If there is a texture matrix applied to the sprite's generated - // texture coordinates. + // If there is a texture matrix applied to the sprite's generated texture + // coordinates. GR_point_sprite_tex_matrix = 0x00200, // The union of all the above point attributes, except GR_indexed_point. @@ -136,34 +130,33 @@ PUBLISHED: GR_shade_model_bits = 0x06000, }; - // The shade model specifies whether the per-vertex colors and - // normals indexed by a given primitive truly represent per-vertex - // colors and normals, or whether they actually represent - // per-triangle flat-shaded colors and normals. + // The shade model specifies whether the per-vertex colors and normals + // indexed by a given primitive truly represent per-vertex colors and + // normals, or whether they actually represent per-triangle flat-shaded + // colors and normals. enum ShadeModel { - // SM_uniform: all vertices across all faces have the same colors - // and normals. It doesn't really matter which ShadeModelAttrib - // mode is used to render this primitive. + // SM_uniform: all vertices across all faces have the same colors and + // normals. It doesn't really matter which ShadeModelAttrib mode is used + // to render this primitive. SM_uniform, - // SM_smooth: vertices within a single face have different - // colors/normals that should be smoothed across the face. This - // primitive should be rendered with SmoothModelAttrib::M_smooth. + // SM_smooth: vertices within a single face have different colorsnormals + // that should be smoothed across the face. This primitive should be + // rendered with SmoothModelAttrib::M_smooth. SM_smooth, - // SM_flat_(first,last)_vertex: each face within the primitive - // might have a different color/normal than the other faces, but - // across a particular face there is only one color/normal. Each - // face's color/normal is taken from the (first, last) vertex of - // the face. This primitive should be rendered with - // SmoothModelAttrib::M_flat. + // SM_flat_(first,last)_vertex: each face within the primitive might have + // a different colornormal than the other faces, but across a particular + // face there is only one colornormal. Each face's colornormal is taken + // from the (first, last) vertex of the face. This primitive should be + // rendered with SmoothModelAttrib::M_flat. SM_flat_first_vertex, SM_flat_last_vertex, }; - // The primitive type represents the core primitive type of a - // particular GeomPrimitive. It's used for determining what kind of - // antialiasing should be enabled. + // The primitive type represents the core primitive type of a particular + // GeomPrimitive. It's used for determining what kind of antialiasing + // should be enabled. enum PrimitiveType { PT_none, PT_polygons, @@ -172,8 +165,8 @@ PUBLISHED: PT_patches }; - // The numeric type determines what physical representation is used - // to encode a numeric value within the vertex data. + // The numeric type determines what physical representation is used to + // encode a numeric value within the vertex data. enum NumericType { NT_uint8, // An integer 0..255 NT_uint16, // An integer 0..65535 @@ -189,9 +182,9 @@ PUBLISHED: NT_packed_ufloat,// Three 10/11-bit float components packed in a uint32 }; - // The contents determine the semantic meaning of a numeric value - // within the vertex data. This is also used to determine what - // automatic transforms might be applied to the various columns. + // The contents determine the semantic meaning of a numeric value within the + // vertex data. This is also used to determine what automatic transforms + // might be applied to the various columns. enum Contents { C_other, // Arbitrary meaning, leave it alone C_point, // A point in 3-space or 4-space @@ -202,12 +195,12 @@ PUBLISHED: C_index, // An index value into some other table C_morph_delta, // A delta from some base value, defining a blend shape - // A transformation matrix. This is typically three or four - // columns, but we pretend it's only one for convenience. + // A transformation matrix. This is typically three or four columns, but + // we pretend it's only one for convenience. C_matrix, - // A special version of C_vector that should be used for normal - // vectors, which are scaled differently from other vectors. + // A special version of C_vector that should be used for normal vectors, + // which are scaled differently from other vectors. C_normal, }; diff --git a/panda/src/gobj/geomLines.cxx b/panda/src/gobj/geomLines.cxx index 0bd9321069..1010c814be 100644 --- a/panda/src/gobj/geomLines.cxx +++ b/panda/src/gobj/geomLines.cxx @@ -1,16 +1,15 @@ -// Filename: geomLines.cxx -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLines.cxx + * @author drose + * @date 2005-03-22 + */ #include "geomLines.h" #include "pStatTimer.h" @@ -22,112 +21,90 @@ TypeHandle GeomLines::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomLines:: GeomLines(GeomLines::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomLines:: GeomLines(const GeomLines ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomLines:: ~GeomLines() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomLines:: make_copy() const { return new GeomLines(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomLines:: get_primitive_type() const { return PT_lines; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::get_num_vertices_per_primitive -// Access: Public, Virtual -// Description: If the primitive type is a simple type in which all -// primitives have the same number of vertices, like -// lines, returns the number of vertices per -// primitive. If the primitive type is a more complex -// type in which different primitives might have -// different numbers of vertices, for instance a -// line strip, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like lines, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a line + * strip, returns 0. + */ int GeomLines:: get_num_vertices_per_primitive() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::get_min_num_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the minimum number of vertices that must be -// added before close_primitive() may legally be called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ int GeomLines:: get_min_num_vertices_per_primitive() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomLines:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_lines(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of do_rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of do_rotate(). + */ CPT(GeomVertexArrayData) GeomLines:: rotate_impl() const { // To rotate lines, we just move reverse the pairs of vertices. int num_vertices = get_num_vertices(); - + PT(GeomVertexArrayData) new_vertices = make_index_data(); new_vertices->set_num_rows(num_vertices); @@ -142,7 +119,7 @@ rotate_impl() const { from.set_row_unsafe(begin); to.set_data1i(from.get_data1i()); } - + nassertr(to.is_at_end(), NULL); } else { @@ -154,32 +131,26 @@ rotate_impl() const { to.set_data1i(begin + 1 + first_vertex); to.set_data1i(begin + first_vertex); } - + nassertr(to.is_at_end(), NULL); } - + return new_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomLines:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLines::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomLines:: make_from_bam(const FactoryParams ¶ms) { GeomLines *object = new GeomLines(UH_unspecified); diff --git a/panda/src/gobj/geomLines.h b/panda/src/gobj/geomLines.h index 15ef7b8412..c6ecfe9c3e 100644 --- a/panda/src/gobj/geomLines.h +++ b/panda/src/gobj/geomLines.h @@ -1,16 +1,15 @@ -// Filename: geomLines.h -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLines.h + * @author drose + * @date 2005-03-22 + */ #ifndef GEOMLINES_H #define GEOMLINES_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomLines -// Description : Defines a series of disconnected line segments. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of disconnected line segments. + */ class EXPCL_PANDA_GOBJ GeomLines : public GeomPrimitive { PUBLISHED: GeomLines(UsageHint usage_hint); diff --git a/panda/src/gobj/geomLinestrips.cxx b/panda/src/gobj/geomLinestrips.cxx index 33c4d30814..734cf49c55 100644 --- a/panda/src/gobj/geomLinestrips.cxx +++ b/panda/src/gobj/geomLinestrips.cxx @@ -1,16 +1,15 @@ -// Filename: geomLinestrips.cxx -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinestrips.cxx + * @author drose + * @date 2005-03-22 + */ #include "geomLinestrips.h" #include "geomLines.h" @@ -22,75 +21,61 @@ TypeHandle GeomLinestrips::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomLinestrips:: GeomLinestrips(GeomLinestrips::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomLinestrips:: GeomLinestrips(const GeomLinestrips ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomLinestrips:: ~GeomLinestrips() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomLinestrips:: make_copy() const { return new GeomLinestrips(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomLinestrips:: get_primitive_type() const { return PT_lines; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::get_geom_rendering -// Access: Published, Virtual -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ int GeomLinestrips:: get_geom_rendering() const { if (is_indexed()) { if (get_num_primitives() > 1) { - return GR_line_strip | GR_indexed_other | GR_strip_cut_index; + return GR_line_strip | GR_indexed_other | GR_strip_cut_index; } else { return GR_line_strip | GR_indexed_other; } @@ -99,57 +84,45 @@ get_geom_rendering() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::get_min_num_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the minimum number of vertices that must be -// added before close_primitive() may legally be called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ int GeomLinestrips:: get_min_num_vertices_per_primitive() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::get_num_unused_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the number of vertices that are added between -// primitives that aren't, strictly speaking, part of -// the primitives themselves. This is used, for -// instance, to define degenerate triangles to connect -// otherwise disconnected triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices that are added between primitives that + * aren't, strictly speaking, part of the primitives themselves. This is + * used, for instance, to define degenerate triangles to connect otherwise + * disconnected triangle strips. + */ int GeomLinestrips:: get_num_unused_vertices_per_primitive() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomLinestrips:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_linestrips(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::decompose_impl -// Access: Protected, Virtual -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance line strips to -// lines, and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to iterate through the set of lines on the -// primitive without having to write handlers for each -// possible kind of primitive type. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance line strips to lines, and returns a pointer to the new primitive + * definition. If the decomposition cannot be performed, this might return + * the original object. + * + * This method is useful for application code that wants to iterate through + * the set of lines on the primitive without having to write handlers for each + * possible kind of primitive type. + */ CPT(GeomPrimitive) GeomLinestrips:: decompose_impl() const { PT(GeomLines) lines = new GeomLines(get_usage_hint()); @@ -182,11 +155,9 @@ decompose_impl() const { return lines.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of do_rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of do_rotate(). + */ CPT(GeomVertexArrayData) GeomLinestrips:: rotate_impl() const { // To rotate a line strip, we just reverse the vertices. @@ -198,7 +169,7 @@ rotate_impl() const { CPT(GeomVertexArrayData) vertices = get_vertices(); GeomVertexReader from(vertices, 0); GeomVertexWriter to(new_vertices, 0); - + int begin = 0; CPTA_int::const_iterator ei; for (ei = ends.begin(); ei != ends.end(); ++ei) { @@ -209,14 +180,14 @@ rotate_impl() const { } begin = end; } - + nassertr(to.is_at_end(), NULL); } else { // Nonindexed case. int first_vertex = get_first_vertex(); GeomVertexWriter to(new_vertices, 0); - + int begin = 0; CPTA_int::const_iterator ei; for (ei = ends.begin(); ei != ends.end(); ++ei) { @@ -226,32 +197,27 @@ rotate_impl() const { } begin = end; } - + nassertr(to.is_at_end(), NULL); } return new_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::requires_unused_vertices -// Access: Protected, Virtual -// Description: Should be redefined to return true in any primitive -// that implements append_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true in any primitive that implements + * append_unused_vertices(). + */ bool GeomLinestrips:: requires_unused_vertices() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::append_unused_vertices -// Access: Protected, Virtual -// Description: Called when a new primitive is begun (other than the -// first primitive), this should add some degenerate -// vertices between primitives, if the primitive type -// requires that. The second parameter is the first -// vertex that begins the new primitive. -//////////////////////////////////////////////////////////////////// +/** + * Called when a new primitive is begun (other than the first primitive), this + * should add some degenerate vertices between primitives, if the primitive + * type requires that. The second parameter is the first vertex that begins + * the new primitive. + */ void GeomLinestrips:: append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { GeomVertexWriter to(vertices, 0); @@ -259,25 +225,19 @@ append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { to.add_data1i(get_strip_cut_index()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomLinestrips:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomLinestrips::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomLinestrips:: make_from_bam(const FactoryParams ¶ms) { GeomLinestrips *object = new GeomLinestrips(UH_unspecified); diff --git a/panda/src/gobj/geomLinestrips.h b/panda/src/gobj/geomLinestrips.h index c7bfea935f..a97251c0d3 100644 --- a/panda/src/gobj/geomLinestrips.h +++ b/panda/src/gobj/geomLinestrips.h @@ -1,16 +1,15 @@ -// Filename: geomLinestrips.h -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomLinestrips.h + * @author drose + * @date 2005-03-22 + */ #ifndef GEOMLINESTRIPS_H #define GEOMLINESTRIPS_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomLinestrips -// Description : Defines a series of line strips. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of line strips. + */ class EXPCL_PANDA_GOBJ GeomLinestrips : public GeomPrimitive { PUBLISHED: GeomLinestrips(UsageHint usage_hint); @@ -45,7 +43,7 @@ protected: virtual CPT(GeomPrimitive) decompose_impl() const; virtual CPT(GeomVertexArrayData) rotate_impl() const; virtual bool requires_unused_vertices() const; - virtual void append_unused_vertices(GeomVertexArrayData *vertices, + virtual void append_unused_vertices(GeomVertexArrayData *vertices, int vertex); public: diff --git a/panda/src/gobj/geomMunger.I b/panda/src/gobj/geomMunger.I index 3133abe802..8cbd51aa91 100644 --- a/panda/src/gobj/geomMunger.I +++ b/panda/src/gobj/geomMunger.I @@ -1,167 +1,131 @@ -// Filename: geomMunger.I -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomMunger.I + * @author drose + * @date 2005-03-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::get_gsg -// Access: Public -// Description: Returns a pointer to the GSG that created this -// munger. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the GSG that created this munger. + */ INLINE GraphicsStateGuardianBase *GeomMunger:: get_gsg() const { return _gsg; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::is_registered -// Access: Public -// Description: Returns true if this munger has been registered, -// false if it has not. It may not be used for a Geom -// until it has been registered, but once registered, it -// may no longer be modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this munger has been registered, false if it has not. It + * may not be used for a Geom until it has been registered, but once + * registered, it may no longer be modified. + */ INLINE bool GeomMunger:: is_registered() const { return _is_registered; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::register_munger -// Access: Public, Static -// Description: Adds the indicated munger to the registry, if there -// is not an equivalent munger already there; in either -// case, returns the pointer to the equivalent munger -// now in the registry. -// -// This must be called before a munger may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated munger to the registry, if there is not an equivalent + * munger already there; in either case, returns the pointer to the equivalent + * munger now in the registry. + * + * This must be called before a munger may be used in a Geom. After this + * call, you should discard the original pointer you passed in (which may or + * may not now be invalid) and let its reference count decrement normally; you + * should use only the returned value from this point on. + */ INLINE PT(GeomMunger) GeomMunger:: register_munger(GeomMunger *munger, Thread *current_thread) { return get_registry()->register_munger(munger, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::unregister_mungers_for_gsg -// Access: Public, Static -// Description: Removes all the mungers from the registry that are -// associated with the indicated GSG. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the mungers from the registry that are associated with the + * indicated GSG. + */ INLINE void GeomMunger:: unregister_mungers_for_gsg(GraphicsStateGuardianBase *gsg) { get_registry()->unregister_mungers_for_gsg(gsg); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_format -// Access: Public -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -// -// If the GeomVertexAnimationSpec so indicates, then the -// format will be chosen to convert CPU-based animation -// tables to HW-based animation tables, reserving space -// for the specified number of transforms per vertex. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + * + * If the GeomVertexAnimationSpec so indicates, then the format will be chosen + * to convert CPU-based animation tables to HW-based animation tables, + * reserving space for the specified number of transforms per vertex. + */ INLINE CPT(GeomVertexFormat) GeomMunger:: munge_format(const GeomVertexFormat *format, const GeomVertexAnimationSpec &animation) const { - // We cast away the const pointer, because do_munge_format() needs - // to update caches and stuff, but we trust it not to change any - // user-definable parameters. + // We cast away the const pointer, because do_munge_format() needs to update + // caches and stuff, but we trust it not to change any user-definable + // parameters. return ((GeomMunger *)this)->do_munge_format(format, animation); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_data -// Access: Public -// Description: Given a source GeomVertexData, converts it if -// necessary to the appropriate data for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexData, converts it if necessary to the appropriate + * data for rendering. + */ INLINE CPT(GeomVertexData) GeomMunger:: munge_data(const GeomVertexData *data) const { - // We cast away the const pointer, because do_munge_data() needs to - // update caches and stuff, but we trust it not to change any - // user-definable parameters. + // We cast away the const pointer, because do_munge_data() needs to update + // caches and stuff, but we trust it not to change any user-definable + // parameters. return ((GeomMunger *)this)->munge_data_impl(data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_format -// Access: Public -// Description: This is similar to munge_format(), but it is done at -// load time, to optimize a model for eventual rendering -// on a particular GSG. At this point, we do not -// necessarily know the final render state that will be -// applied, so we cannot make any destructive changes to -// the geom, its data, or its format. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to munge_format(), but it is done at load time, to optimize + * a model for eventual rendering on a particular GSG. At this point, we do + * not necessarily know the final render state that will be applied, so we + * cannot make any destructive changes to the geom, its data, or its format. + */ INLINE CPT(GeomVertexFormat) GeomMunger:: premunge_format(const GeomVertexFormat *format) const { return ((GeomMunger *)this)->do_premunge_format(format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_data -// Access: Public -// Description: This is similar to munge_data(), but it is done at -// load time, to optimize a model for eventual rendering -// on a particular GSG. At this point, we do not -// necessarily know the final render state that will be -// applied, so we cannot make any destructive changes to -// the geom, its data, or its format. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to munge_data(), but it is done at load time, to optimize a + * model for eventual rendering on a particular GSG. At this point, we do not + * necessarily know the final render state that will be applied, so we cannot + * make any destructive changes to the geom, its data, or its format. + */ INLINE CPT(GeomVertexData) GeomMunger:: premunge_data(const GeomVertexData *data) const { return ((GeomMunger *)this)->premunge_data_impl(data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_geom -// Access: Public -// Description: This is similar to munge_geom(), but it is done at -// load time, to optimize a model for eventual rendering -// on a particular GSG. At this point, we do not -// necessarily know the final render state that will be -// applied, so we cannot make any destructive changes to -// the geom, its data, or its format. -// -// Unlike munge_geom(), this result is not cached, since -// the assumption is that this operation is performed at -// load time once for each model. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to munge_geom(), but it is done at load time, to optimize a + * model for eventual rendering on a particular GSG. At this point, we do not + * necessarily know the final render state that will be applied, so we cannot + * make any destructive changes to the geom, its data, or its format. + * + * Unlike munge_geom(), this result is not cached, since the assumption is + * that this operation is performed at load time once for each model. + */ INLINE void GeomMunger:: premunge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data) const { ((GeomMunger *)this)->premunge_geom_impl(geom, data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::compare_to -// Access: Public -// Description: Provides an arbitrary ordering among all unique -// GeomMungers, so we can store the essentially -// different ones in a big set and throw away the rest. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique GeomMungers, so we can + * store the essentially different ones in a big set and throw away the rest. + */ INLINE int GeomMunger:: compare_to(const GeomMunger &other) const { - // First, we compare the types; if they are of different types then - // they sort differently. + // First, we compare the types; if they are of different types then they + // sort differently. TypeHandle type = get_type(); TypeHandle other_type = other.get_type(); if (type != other_type) { @@ -172,20 +136,16 @@ compare_to(const GeomMunger &other) const { return compare_to_impl(&other); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::geom_compare_to -// Access: Public -// Description: Compares two GeomMungers, considering only whether -// they would produce a different answer to -// munge_format(), munge_data(), or munge_geom(). (They -// still might be different in other ways, but if they -// would produce the same answer, this function consider -// them to be the same.) -//////////////////////////////////////////////////////////////////// +/** + * Compares two GeomMungers, considering only whether they would produce a + * different answer to munge_format(), munge_data(), or munge_geom(). (They + * still might be different in other ways, but if they would produce the same + * answer, this function consider them to be the same.) + */ INLINE int GeomMunger:: geom_compare_to(const GeomMunger &other) const { - // First, we compare the types; if they are of different types then - // they sort differently. + // First, we compare the types; if they are of different types then they + // sort differently. TypeHandle type = get_type(); TypeHandle other_type = other.get_type(); if (type != other_type) { @@ -196,18 +156,15 @@ geom_compare_to(const GeomMunger &other) const { return geom_compare_to_impl(&other); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::unregister_myself -// Access: Protected -// Description: Unregisters the GeomMunger, for instance when it is -// being destructed, or whenever it has become invalid -// for some reason. This removes it from the registry -// so that it will no longer be available to be returned -// by register_munger(). -// -// It is not an error to call this if the munger has -// already been unregistered. -//////////////////////////////////////////////////////////////////// +/** + * Unregisters the GeomMunger, for instance when it is being destructed, or + * whenever it has become invalid for some reason. This removes it from the + * registry so that it will no longer be available to be returned by + * register_munger(). + * + * It is not an error to call this if the munger has already been + * unregistered. + */ INLINE void GeomMunger:: unregister_myself() { if (is_registered()) { @@ -215,11 +172,9 @@ unregister_myself() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::get_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ INLINE GeomMunger::Registry *GeomMunger:: get_registry() { if (_registry == (Registry *)NULL) { diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index 8ce1175c5d..fccbdab0b6 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -1,16 +1,15 @@ -// Filename: geomMunger.cxx -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomMunger.cxx + * @author drose + * @date 2005-03-10 + */ #include "geomMunger.h" #include "geom.h" @@ -24,11 +23,9 @@ TypeHandle GeomMunger::_type_handle; PStatCollector GeomMunger::_munge_pcollector("*:Munge"); -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomMunger:: GeomMunger(GraphicsStateGuardianBase *gsg) : _gsg(gsg), @@ -41,11 +38,9 @@ GeomMunger(GraphicsStateGuardianBase *gsg) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomMunger:: GeomMunger(const GeomMunger ©) : _is_registered(false) @@ -57,62 +52,50 @@ GeomMunger(const GeomMunger ©) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomMunger:: operator = (const GeomMunger ©) { nassertv(!_is_registered); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomMunger:: ~GeomMunger() { unregister_myself(); nassertv(_formats_by_animation.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::remove_data -// Access: Public -// Description: Removes a prepared GeomVertexData from the cache. -//////////////////////////////////////////////////////////////////// +/** + * Removes a prepared GeomVertexData from the cache. + */ void GeomMunger:: remove_data(const GeomVertexData *data) { // If this assertion is triggered, maybe we accidentally deleted a - // GeomVertexData while we were in the process of unregistering, - // causing a recursive re-entry. + // GeomVertexData while we were in the process of unregistering, causing a + // recursive re-entry. nassertv(_is_registered); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_geom -// Access: Public -// Description: Applies the indicated munger to the geom and its -// data, and returns a (possibly different) geom and -// data, according to the munger's whim. -// -// The assumption is that for a particular geom and a -// particular munger, the result will always be the -// same; so this result may be cached. -// -// If force is false, this may do nothing and return -// false if the vertex data is nonresident. If force is -// true, this will always return true, but it may have -// to block while the vertex data is paged in. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated munger to the geom and its data, and returns a + * (possibly different) geom and data, according to the munger's whim. + * + * The assumption is that for a particular geom and a particular munger, the + * result will always be the same; so this result may be cached. + * + * If force is false, this may do nothing and return false if the vertex data + * is nonresident. If force is true, this will always return true, but it may + * have to block while the vertex data is paged in. + */ bool GeomMunger:: munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, bool force, Thread *current_thread) { - // Look up the munger in the geom's cache--maybe we've recently - // applied it. + // Look up the munger in the geom's cache--maybe we've recently applied it. PT(Geom::CacheEntry) entry; Geom::CacheKey key(data, this); @@ -126,9 +109,8 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, geom->_cache_lock.release(); nassertr(entry->_source == geom, false); - // Here's an element in the cache for this computation. Record a - // cache hit, so this element will stay in the cache a while - // longer. + // Here's an element in the cache for this computation. Record a cache + // hit, so this element will stay in the cache a while longer. entry->refresh(current_thread); // Now check that it's fresh. @@ -144,10 +126,10 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, return true; } - // The cache entry is stale, but we'll recompute it below. Note - // that there's a small race condition here; another thread might - // recompute the cache at the same time. No big deal, since it'll - // compute the same result. + // The cache entry is stale, but we'll recompute it below. Note that + // there's a small race condition here; another thread might recompute the + // cache at the same time. No big deal, since it'll compute the same + // result. } if (!force && (!geom->request_resident() || !data->request_resident())) { @@ -175,15 +157,13 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, LightMutexHolder holder(orig_geom->_cache_lock); bool inserted = orig_geom->_cache.insert(Geom::Cache::value_type(&entry->_key, entry)).second; if (!inserted) { - // Some other thread must have beat us to the punch. Never - // mind. + // Some other thread must have beat us to the punch. Never mind. return true; } } - // And tell the cache manager about the new entry. (It might - // immediately request a delete from the cache of the thing we - // just added.) + // And tell the cache manager about the new entry. (It might immediately + // request a delete from the cache of the thing we just added.) entry->record(current_thread); } @@ -195,12 +175,10 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::do_munge_format -// Access: Protected -// Description: The protected implementation of munge_format(). This -// exists just to cast away the const pointer. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of munge_format(). This exists just to cast + * away the const pointer. + */ CPT(GeomVertexFormat) GeomMunger:: do_munge_format(const GeomVertexFormat *format, const GeomVertexAnimationSpec &animation) { @@ -214,8 +192,7 @@ do_munge_format(const GeomVertexFormat *format, Formats::iterator fi; fi = formats.find(format); if (fi != formats.end()) { - // This format was previously munged, so the answer will be the - // same. + // This format was previously munged, so the answer will be the same. return (*fi).second; } @@ -230,23 +207,18 @@ do_munge_format(const GeomVertexFormat *format, return derived_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) GeomMunger:: munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &) { return orig; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_data_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexData, converts it as -// necessary for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexData, converts it as necessary for rendering. + */ CPT(GeomVertexData) GeomMunger:: munge_data_impl(const GeomVertexData *data) { nassertr(_is_registered, NULL); @@ -263,23 +235,19 @@ munge_data_impl(const GeomVertexData *data) { return data->convert_to(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::munge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void GeomMunger:: munge_geom_impl(CPT(Geom) &, CPT(GeomVertexData) &, Thread *) { - // The default implementation does nothing (the work has already - // been done in munge_format_impl() and munge_data_impl()). + // The default implementation does nothing (the work has already been done + // in munge_format_impl() and munge_data_impl()). } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::do_premunge_format -// Access: Protected -// Description: The protected implementation of premunge_format(). This -// exists just to cast away the const pointer. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of premunge_format(). This exists just to + * cast away the const pointer. + */ CPT(GeomVertexFormat) GeomMunger:: do_premunge_format(const GeomVertexFormat *format) { nassertr(_is_registered, NULL); @@ -290,8 +258,7 @@ do_premunge_format(const GeomVertexFormat *format) { Formats::iterator fi; fi = _premunge_formats.find(format); if (fi != _premunge_formats.end()) { - // This format was previously munged, so the answer will be the - // same. + // This format was previously munged, so the answer will be the same. return (*fi).second; } @@ -306,23 +273,18 @@ do_premunge_format(const GeomVertexFormat *format) { return derived_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) GeomMunger:: premunge_format_impl(const GeomVertexFormat *orig) { return orig; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_data_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexData, converts it as -// necessary for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexData, converts it as necessary for rendering. + */ CPT(GeomVertexData) GeomMunger:: premunge_data_impl(const GeomVertexData *data) { nassertr(_is_registered, NULL); @@ -338,50 +300,39 @@ premunge_data_impl(const GeomVertexData *data) { return data->convert_to(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::premunge_geom_impl -// Access: Protected, Virtual -// Description: Converts a Geom and/or its data as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Geom and/or its data as necessary. + */ void GeomMunger:: premunge_geom_impl(CPT(Geom) &, CPT(GeomVertexData) &) { - // The default implementation does nothing (the work has already - // been done in premunge_format_impl() and premunge_data_impl()). + // The default implementation does nothing (the work has already been done + // in premunge_format_impl() and premunge_data_impl()). } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int GeomMunger:: compare_to_impl(const GeomMunger *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::geom_compare_to_impl -// Access: Protected, Virtual -// Description: Compares two GeomMungers, considering only whether -// they would produce a different answer to -// munge_format(), munge_data(), or munge_geom(). (They -// still might be different in other ways, but if they -// would produce the same answer, this function will -// consider them to be the same.) -//////////////////////////////////////////////////////////////////// +/** + * Compares two GeomMungers, considering only whether they would produce a + * different answer to munge_format(), munge_data(), or munge_geom(). (They + * still might be different in other ways, but if they would produce the same + * answer, this function will consider them to be the same.) + */ int GeomMunger:: geom_compare_to_impl(const GeomMunger *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::make_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ void GeomMunger:: make_registry() { if (_registry == (Registry *)NULL) { @@ -389,11 +340,9 @@ make_registry() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::do_register -// Access: Private -// Description: Called internally when the munger is registered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the munger is registered. + */ void GeomMunger:: do_register(Thread *current_thread) { if (gobj_cat.is_debug()) { @@ -403,9 +352,8 @@ do_register(Thread *current_thread) { nassertv(!_is_registered); nassertv(_formats_by_animation.empty()); - // Tell the cache manager to hang on to this new GeomMunger, so we - // don't waste our time re-registering the same GeomMunger over and - // over again. + // Tell the cache manager to hang on to this new GeomMunger, so we don't + // waste our time re-registering the same GeomMunger over and over again. CacheEntry *entry = new CacheEntry; entry->_munger = this; entry->record(current_thread); @@ -413,11 +361,9 @@ do_register(Thread *current_thread) { _is_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::do_unregister -// Access: Private -// Description: Called internally when the munger is unregistered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the munger is unregistered. + */ void GeomMunger:: do_unregister() { if (gobj_cat.is_debug()) { @@ -431,49 +377,40 @@ do_unregister() { _formats_by_animation.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::CacheEntry::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomMunger::CacheEntry:: output(ostream &out) const { out << "munger " << _munger; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Registry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomMunger::Registry:: Registry() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Registry::register_munger -// Access: Public -// Description: Adds the indicated munger to the registry, if there -// is not an equivalent munger already there; in either -// case, returns the pointer to the equivalent munger -// now in the registry. -// -// This must be called before a munger may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated munger to the registry, if there is not an equivalent + * munger already there; in either case, returns the pointer to the equivalent + * munger now in the registry. + * + * This must be called before a munger may be used in a Geom. After this + * call, you should discard the original pointer you passed in (which may or + * may not now be invalid) and let its reference count decrement normally; you + * should use only the returned value from this point on. + */ PT(GeomMunger) GeomMunger::Registry:: register_munger(GeomMunger *munger, Thread *current_thread) { if (munger->is_registered()) { return munger; } - // Save the incoming pointer in a local PointerTo, so that if it has - // a zero reference count and is not added into the map below, it - // will be automatically deleted when this function returns. + // Save the incoming pointer in a local PointerTo, so that if it has a zero + // reference count and is not added into the map below, it will be + // automatically deleted when this function returns. PT(GeomMunger) pt_munger = munger; LightReMutexHolder holder(_registry_lock); @@ -488,13 +425,10 @@ register_munger(GeomMunger *munger, Thread *current_thread) { return new_munger; } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Registry::unregister_munger -// Access: Public -// Description: Removes the indicated munger from the registry. -// Normally this should not be done until the munger is -// destructing. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated munger from the registry. Normally this should not + * be done until the munger is destructing. + */ void GeomMunger::Registry:: unregister_munger(GeomMunger *munger) { LightReMutexHolder holder(_registry_lock); @@ -506,12 +440,10 @@ unregister_munger(GeomMunger *munger) { munger->do_unregister(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomMunger::Registry::unregister_mungers_for_gsg -// Access: Public -// Description: Removes all the mungers from the registry that are -// associated with the indicated GSG. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the mungers from the registry that are associated with the + * indicated GSG. + */ void GeomMunger::Registry:: unregister_mungers_for_gsg(GraphicsStateGuardianBase *gsg) { LightReMutexHolder holder(_registry_lock); diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index c1e9b45b12..840057539d 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -1,16 +1,15 @@ -// Filename: geomMunger.h -// Created by: drose (10Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomMunger.h + * @author drose + * @date 2005-03-10 + */ #ifndef GEOMMUNGER_H #define GEOMMUNGER_H @@ -33,27 +32,21 @@ class GraphicsStateGuardianBase; class RenderState; class Geom; -//////////////////////////////////////////////////////////////////// -// Class : GeomMunger -// Description : Objects of this class are used to convert vertex data -// from a Geom into a format suitable for passing to the -// rendering backend. Typically, the rendering backend -// will create a specialization of this class to handle -// its particular needs (e.g. DXGeomMunger). This class -// is necessary because DirectX and OpenGL have somewhat -// different requirements for vertex format. -// -// This also performs runtime application of state -// changes to the vertex data; for instance, by scaling -// all of the color values in response to a -// ColorScaleAttrib. -// -// A GeomMunger must be registered before it can be -// used, and once registered, the object is constant and -// cannot be changed. All registered GeomMungers that -// perform the same operation will have the same -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Objects of this class are used to convert vertex data from a Geom into a + * format suitable for passing to the rendering backend. Typically, the + * rendering backend will create a specialization of this class to handle its + * particular needs (e.g. DXGeomMunger). This class is necessary because + * DirectX and OpenGL have somewhat different requirements for vertex format. + * + * This also performs runtime application of state changes to the vertex data; + * for instance, by scaling all of the color values in response to a + * ColorScaleAttrib. + * + * A GeomMunger must be registered before it can be used, and once registered, + * the object is constant and cannot be changed. All registered GeomMungers + * that perform the same operation will have the same pointer. + */ class EXPCL_PANDA_GOBJ GeomMunger : public TypedReferenceCount, public GeomEnums { public: GeomMunger(GraphicsStateGuardianBase *gsg); @@ -144,13 +137,12 @@ private: LightReMutex _registry_lock; }; - // We store the iterator into the above registry, while we are - // registered. This makes it easier to remove our own entry, - // especially when the destructor is called. Since it's a virtual - // destructor, we can't reliably look up our pointer in the map once - // we have reached the base class destructor (since the object has - // changed types by then, and the sorting in the map depends partly - // on type). + // We store the iterator into the above registry, while we are registered. + // This makes it easier to remove our own entry, especially when the + // destructor is called. Since it's a virtual destructor, we can't reliably + // look up our pointer in the map once we have reached the base class + // destructor (since the object has changed types by then, and the sorting + // in the map depends partly on type). Mungers::iterator _registered_key; static Registry *_registry; @@ -180,4 +172,3 @@ private: #include "geomMunger.I" #endif - diff --git a/panda/src/gobj/geomPatches.cxx b/panda/src/gobj/geomPatches.cxx index 11b114dc1d..f5fe9711d0 100644 --- a/panda/src/gobj/geomPatches.cxx +++ b/panda/src/gobj/geomPatches.cxx @@ -1,16 +1,15 @@ -// Filename: geomPatches.cxx -// Created by: drose (27Apr12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPatches.cxx + * @author drose + * @date 2012-04-27 + */ #include "geomPatches.h" #include "geomVertexRewriter.h" @@ -21,27 +20,22 @@ TypeHandle GeomPatches::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::Constructor -// Access: Published -// Description: The number of vertices per patch must be specified to -// the GeomPatches constructor, and it may not be -// changed during the lifetime of the GeomPatches -// object. Create a new GeomPatches if you need to have -// a different value. -//////////////////////////////////////////////////////////////////// +/** + * The number of vertices per patch must be specified to the GeomPatches + * constructor, and it may not be changed during the lifetime of the + * GeomPatches object. Create a new GeomPatches if you need to have a + * different value. + */ GeomPatches:: GeomPatches(int num_vertices_per_patch, GeomPatches::UsageHint usage_hint) : GeomPrimitive(usage_hint), _num_vertices_per_patch(num_vertices_per_patch) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomPatches:: GeomPatches(const GeomPatches ©) : GeomPrimitive(copy), @@ -49,116 +43,91 @@ GeomPatches(const GeomPatches ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPatches:: ~GeomPatches() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomPatches:: make_copy() const { return new GeomPatches(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomPatches:: get_primitive_type() const { return PT_patches; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::get_num_vertices_per_primitive -// Access: Public, Virtual -// Description: If the primitive type is a simple type in which all -// primitives have the same number of vertices, like -// patches, returns the number of vertices per -// primitive. If the primitive type is a more complex -// type in which different primitives might have -// different numbers of vertices, for instance a -// triangle strip, returns 0. -// -// In the case of GeomPatches, this returns the fixed -// number that was specified to the constructor. -//////////////////////////////////////////////////////////////////// +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like patches, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a + * triangle strip, returns 0. + * + * In the case of GeomPatches, this returns the fixed number that was + * specified to the constructor. + */ int GeomPatches:: get_num_vertices_per_primitive() const { return _num_vertices_per_patch; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomPatches:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_patches(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomPatches:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomPatches:: write_datagram(BamWriter *manager, Datagram &dg) { GeomPrimitive::write_datagram(manager, dg); dg.add_uint16(_num_vertices_per_patch); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomPatches. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomPatches. + */ void GeomPatches:: fillin(DatagramIterator &scan, BamReader *manager) { GeomPrimitive::fillin(scan, manager); _num_vertices_per_patch = scan.get_uint16(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPatches::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomPatches:: make_from_bam(const FactoryParams ¶ms) { GeomPatches *object = new GeomPatches(0, UH_unspecified); diff --git a/panda/src/gobj/geomPatches.h b/panda/src/gobj/geomPatches.h index c722690b30..a77b627a12 100644 --- a/panda/src/gobj/geomPatches.h +++ b/panda/src/gobj/geomPatches.h @@ -1,16 +1,15 @@ -// Filename: geomPatches.h -// Created by: drose (27Apr12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPatches.h + * @author drose + * @date 2012-04-27 + */ #ifndef GEOMPATCHES_H #define GEOMPATCHES_H @@ -18,12 +17,10 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomPatches -// Description : Defines a series of "patches", fixed-size groupings -// of vertices that must be processed by a tessellation -// shader. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of "patches", fixed-size groupings of vertices that must + * be processed by a tessellation shader. + */ class EXPCL_PANDA_GOBJ GeomPatches : public GeomPrimitive { PUBLISHED: GeomPatches(int num_vertices_per_patch, UsageHint usage_hint); diff --git a/panda/src/gobj/geomPoints.cxx b/panda/src/gobj/geomPoints.cxx index 56e29aa96a..415e0f9dcd 100644 --- a/panda/src/gobj/geomPoints.cxx +++ b/panda/src/gobj/geomPoints.cxx @@ -1,16 +1,15 @@ -// Filename: geomPoints.cxx -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPoints.cxx + * @author drose + * @date 2005-03-22 + */ #include "geomPoints.h" #include "pStatTimer.h" @@ -20,75 +19,61 @@ TypeHandle GeomPoints::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPoints:: GeomPoints(GeomPoints::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomPoints:: GeomPoints(const GeomPoints ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPoints:: ~GeomPoints() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomPoints:: make_copy() const { return new GeomPoints(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomPoints:: get_primitive_type() const { return PT_points; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::get_geom_rendering -// Access: Published, Virtual -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ int GeomPoints:: get_geom_rendering() const { - // Fancy point attributes, if any, are based on whether the - // appropriate columns are defined in the associated GeomVertexData; - // these bits will be added by Geom::get_geom_rendering(). + // Fancy point attributes, if any, are based on whether the appropriate + // columns are defined in the associated GeomVertexData; these bits will be + // added by Geom::get_geom_rendering(). if (is_indexed()) { return GR_point | GR_indexed_point; } else { @@ -96,64 +81,49 @@ get_geom_rendering() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::get_num_vertices_per_primitive -// Access: Public, Virtual -// Description: If the primitive type is a simple type in which all -// primitives have the same number of vertices, like -// points, returns the number of vertices per -// primitive. If the primitive type is a more complex -// type in which different primitives might have -// different numbers of vertices, for instance a -// point strip, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like points, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a point + * strip, returns 0. + */ int GeomPoints:: get_num_vertices_per_primitive() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::get_min_num_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the minimum number of vertices that must be -// added before close_primitive() may legally be called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ int GeomPoints:: get_min_num_vertices_per_primitive() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomPoints:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_points(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomPoints:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPoints::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomPoints:: make_from_bam(const FactoryParams ¶ms) { GeomPoints *object = new GeomPoints(UH_unspecified); diff --git a/panda/src/gobj/geomPoints.h b/panda/src/gobj/geomPoints.h index 4880a87c2c..0561e18fa6 100644 --- a/panda/src/gobj/geomPoints.h +++ b/panda/src/gobj/geomPoints.h @@ -1,16 +1,15 @@ -// Filename: geomPoints.h -// Created by: drose (22Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPoints.h + * @author drose + * @date 2005-03-22 + */ #ifndef GEOMPOINTS_H #define GEOMPOINTS_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomPoints -// Description : Defines a series of disconnected points. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of disconnected points. + */ class EXPCL_PANDA_GOBJ GeomPoints : public GeomPrimitive { PUBLISHED: GeomPoints(UsageHint usage_hint); diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index cbaede08be..029063f864 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -1,174 +1,137 @@ -// Filename: geomPrimitive.I -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPrimitive.I + * @author drose + * @date 2005-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_shade_model -// Access: Published -// Description: Returns the ShadeModel hint for this primitive. -// This is intended as a hint to the renderer to tell it -// how the per-vertex colors and normals are applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ShadeModel hint for this primitive. This is intended as a hint + * to the renderer to tell it how the per-vertex colors and normals are + * applied. + */ INLINE GeomPrimitive::ShadeModel GeomPrimitive:: get_shade_model() const { CDReader cdata(_cycler); return cdata->_shade_model; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_shade_model -// Access: Published -// Description: Changes the ShadeModel hint for this primitive. -// This is different from the ShadeModelAttrib that -// might also be applied from the scene graph. This -// does not affect the shade model that is in effect -// when rendering, but rather serves as a hint to the -// renderer to tell it how the per-vertex colors and -// normals on this primitive are applied. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the ShadeModel hint for this primitive. This is different from the + * ShadeModelAttrib that might also be applied from the scene graph. This + * does not affect the shade model that is in effect when rendering, but + * rather serves as a hint to the renderer to tell it how the per-vertex + * colors and normals on this primitive are applied. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE void GeomPrimitive:: set_shade_model(GeomPrimitive::ShadeModel shade_model) { CDWriter cdata(_cycler, true); cdata->_shade_model = shade_model; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_usage_hint -// Access: Published -// Description: Returns the usage hint for this primitive. See -// geomEnums.h. This has nothing to do with the usage -// hint associated with the primitive's vertices; this -// only specifies how often the vertex indices that -// define the primitive will be modified. -// -// It is perfectly legal (and, in fact, common) for a -// GeomPrimitive to have UH_static on itself, while -// referencing vertex data with UH_dynamic. This means -// that the vertices themselves will be animated, but -// the primitive will always reference the same set of -// vertices from the pool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the usage hint for this primitive. See geomEnums.h. This has + * nothing to do with the usage hint associated with the primitive's vertices; + * this only specifies how often the vertex indices that define the primitive + * will be modified. + * + * It is perfectly legal (and, in fact, common) for a GeomPrimitive to have + * UH_static on itself, while referencing vertex data with UH_dynamic. This + * means that the vertices themselves will be animated, but the primitive will + * always reference the same set of vertices from the pool. + */ INLINE GeomPrimitive::UsageHint GeomPrimitive:: get_usage_hint() const { CDReader cdata(_cycler); return cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_index_type -// Access: Public -// Description: Returns the numeric type of the index column. -// Normally, this will be either NT_uint16 or NT_uint32. -//////////////////////////////////////////////////////////////////// +/** + * Returns the numeric type of the index column. Normally, this will be + * either NT_uint16 or NT_uint32. + */ INLINE GeomPrimitive::NumericType GeomPrimitive:: get_index_type() const { CDReader cdata(_cycler); return cdata->_index_type; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::is_composite -// Access: Published -// Description: Returns true if the primitive is a composite -// primitive such as a tristrip or trifan, or false if -// it is a fundamental primitive such as a collection of -// triangles. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive is a composite primitive such as a tristrip + * or trifan, or false if it is a fundamental primitive such as a collection + * of triangles. + */ INLINE bool GeomPrimitive:: is_composite() const { return (get_num_vertices_per_primitive() == 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::is_indexed -// Access: Published -// Description: Returns true if the primitive is indexed, false -// otherwise. An indexed primitive stores a table of -// index numbers into its GeomVertexData, so that it can -// reference the vertices in any order. A nonindexed -// primitive, on the other hand, stores only the first -// vertex number and number of vertices used, so that it -// can only reference the vertices consecutively. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive is indexed, false otherwise. An indexed + * primitive stores a table of index numbers into its GeomVertexData, so that + * it can reference the vertices in any order. A nonindexed primitive, on the + * other hand, stores only the first vertex number and number of vertices + * used, so that it can only reference the vertices consecutively. + */ INLINE bool GeomPrimitive:: is_indexed() const { CDReader cdata(_cycler); return (!cdata->_vertices.is_null()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_first_vertex -// Access: Published -// Description: Returns the first vertex number referenced by the -// primitive. This is particularly important in the -// case of a nonindexed primitive, in which case -// get_first_vertex() and get_num_vertices() completely -// define the extent of the vertex range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first vertex number referenced by the primitive. This is + * particularly important in the case of a nonindexed primitive, in which case + * get_first_vertex() and get_num_vertices() completely define the extent of + * the vertex range. + */ INLINE int GeomPrimitive:: get_first_vertex() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); return reader.get_first_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_vertices -// Access: Published -// Description: Returns the number of indices used by all the -// primitives in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of indices used by all the primitives in this object. + */ INLINE int GeomPrimitive:: get_num_vertices() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); return reader.get_num_vertices(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_vertex -// Access: Published -// Description: Returns the ith vertex index in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith vertex index in the table. + */ INLINE int GeomPrimitive:: get_vertex(int i) const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); return reader.get_vertex(i); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_primitives -// Access: Published -// Description: Returns the number of individual primitives stored -// within this object. All primitives are the same -// type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual primitives stored within this object. All + * primitives are the same type. + */ INLINE int GeomPrimitive:: get_num_primitives() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); return reader.get_num_primitives(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_faces -// Access: Published -// Description: Returns the number of triangles or other fundamental -// type (such as line segments) represented by all the -// primitives in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of triangles or other fundamental type (such as line + * segments) represented by all the primitives in this object. + */ INLINE int GeomPrimitive:: get_num_faces() const { int num_vertices_per_primitive = get_num_vertices_per_primitive(); @@ -184,13 +147,10 @@ get_num_faces() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_num_faces -// Access: Published -// Description: Returns the number of triangles or other fundamental -// type (such as line segments) represented by the nth -// primitive in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of triangles or other fundamental type (such as line + * segments) represented by the nth primitive in this object. + */ INLINE int GeomPrimitive:: get_primitive_num_faces(int n) const { int num_vertices_per_primitive = get_num_vertices_per_primitive(); @@ -202,12 +162,10 @@ get_primitive_num_faces(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_min_vertex -// Access: Published -// Description: Returns the minimum vertex index number used by all -// the primitives in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum vertex index number used by all the primitives in this + * object. + */ INLINE int GeomPrimitive:: get_min_vertex() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); @@ -215,12 +173,10 @@ get_min_vertex() const { return reader.get_min_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_max_vertex -// Access: Published -// Description: Returns the maximum vertex index number used by all -// the primitives in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum vertex index number used by all the primitives in this + * object. + */ INLINE int GeomPrimitive:: get_max_vertex() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); @@ -228,12 +184,9 @@ get_max_vertex() const { return reader.get_max_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_data_size_bytes -// Access: Published -// Description: Returns the number of bytes stored in the vertices -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes stored in the vertices array. + */ INLINE int GeomPrimitive:: get_data_size_bytes() const { CDReader cdata(_cycler); @@ -241,27 +194,21 @@ get_data_size_bytes() const { return cdata->_vertices.get_read_pointer()->get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the vertex index array is -// modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the vertex index array is modified. + */ INLINE UpdateSeq GeomPrimitive:: get_modified() const { CDReader cdata(_cycler); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::check_valid -// Access: Published -// Description: Verifies that the primitive only references vertices -// that actually exist within the indicated -// GeomVertexData. Returns true if the primitive -// appears to be valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the primitive only references vertices that actually exist + * within the indicated GeomVertexData. Returns true if the primitive appears + * to be valid, false otherwise. + */ INLINE bool GeomPrimitive:: check_valid(const GeomVertexData *vertex_data) const { Thread *current_thread = Thread::get_current_thread(); @@ -272,97 +219,77 @@ check_valid(const GeomVertexData *vertex_data) const { return reader.check_valid(&data_reader); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_vertices -// Access: Published -// Description: Returns a const pointer to the vertex index array so -// application code can read it directly. This might -// return NULL if the primitive is nonindexed. Do not -// attempt to modify the returned array; use -// modify_vertices() or set_vertices() for this. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the vertex index array so application code can + * read it directly. This might return NULL if the primitive is nonindexed. + * Do not attempt to modify the returned array; use modify_vertices() or + * set_vertices() for this. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ INLINE CPT(GeomVertexArrayData) GeomPrimitive:: get_vertices() const { CDReader cdata(_cycler); return cdata->_vertices.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_index_stride -// Access: Published -// Description: A convenience function to return the gap between -// successive index numbers, in bytes, of the index -// data. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to return the gap between successive index numbers, + * in bytes, of the index data. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ INLINE int GeomPrimitive:: get_index_stride() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); return reader.get_index_stride(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_strip_cut_index -// Access: Published -// Description: If relevant, returns the index value that may be -// used in some cases to signify the end of a -// primitive. This is typically the highest value -// that the numeric type can store. -//////////////////////////////////////////////////////////////////// +/** + * If relevant, returns the index value that may be used in some cases to + * signify the end of a primitive. This is typically the highest value that + * the numeric type can store. + */ INLINE int GeomPrimitive:: get_strip_cut_index() const { CDReader cdata(_cycler); return get_strip_cut_index(cdata->_index_type); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_ends -// Access: Published -// Description: Returns a const pointer to the primitive ends -// array so application code can read it directly. Do -// not attempt to modify the returned array; use -// modify_ends() or set_ends() for this. -// -// Note that simple primitive types, like triangles, do -// not have a ends array: since all the primitives -// have the same number of vertices, it is not needed. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the primitive ends array so application code can + * read it directly. Do not attempt to modify the returned array; use + * modify_ends() or set_ends() for this. + * + * Note that simple primitive types, like triangles, do not have a ends array: + * since all the primitives have the same number of vertices, it is not + * needed. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ INLINE CPTA_int GeomPrimitive:: get_ends() const { CDReader cdata(_cycler); return cdata->_ends; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_mins -// Access: Published -// Description: Returns a const pointer to the primitive mins -// array so application code can read it directly. Do -// not attempt to modify the returned array; use -// set_minmax() for this. -// -// Note that simple primitive types, like triangles, do -// not have a mins array. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the primitive mins array so application code can + * read it directly. Do not attempt to modify the returned array; use + * set_minmax() for this. + * + * Note that simple primitive types, like triangles, do not have a mins array. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ INLINE CPT(GeomVertexArrayData) GeomPrimitive:: get_mins() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); @@ -370,22 +297,17 @@ get_mins() const { return reader.get_mins(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_maxs -// Access: Published -// Description: Returns a const pointer to the primitive maxs -// array so application code can read it directly. Do -// not attempt to modify the returned array; use -// set_minmax(). -// -// Note that simple primitive types, like triangles, do -// not have a maxs array. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the primitive maxs array so application code can + * read it directly. Do not attempt to modify the returned array; use + * set_minmax(). + * + * Note that simple primitive types, like triangles, do not have a maxs array. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ INLINE CPT(GeomVertexArrayData) GeomPrimitive:: get_maxs() const { GeomPrimitivePipelineReader reader(this, Thread::get_current_thread()); @@ -393,22 +315,18 @@ get_maxs() const { return reader.get_maxs(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_vertices -// Access: Public -// Description: Adds several vertices in a row. -//////////////////////////////////////////////////////////////////// +/** + * Adds several vertices in a row. + */ INLINE void GeomPrimitive:: add_vertices(int v1, int v2) { add_vertex(v1); add_vertex(v2); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_vertices -// Access: Public -// Description: Adds several vertices in a row. -//////////////////////////////////////////////////////////////////// +/** + * Adds several vertices in a row. + */ INLINE void GeomPrimitive:: add_vertices(int v1, int v2, int v3) { add_vertex(v1); @@ -416,11 +334,9 @@ add_vertices(int v1, int v2, int v3) { add_vertex(v3); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_vertices -// Access: Public -// Description: Adds several vertices in a row. -//////////////////////////////////////////////////////////////////// +/** + * Adds several vertices in a row. + */ INLINE void GeomPrimitive:: add_vertices(int v1, int v2, int v3, int v4) { add_vertex(v1); @@ -429,48 +345,38 @@ add_vertices(int v1, int v2, int v3, int v4) { add_vertex(v4); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_index_format -// Access: Public -// Description: Returns a registered format appropriate for using to -// store the index table. -//////////////////////////////////////////////////////////////////// +/** + * Returns a registered format appropriate for using to store the index table. + */ INLINE const GeomVertexArrayFormat *GeomPrimitive:: get_index_format() const { return get_index_format(get_index_type()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_index_data -// Access: Public -// Description: Creates and returns a new, empty index table. -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new, empty index table. + */ INLINE PT(GeomVertexArrayData) GeomPrimitive:: make_index_data() const { return new GeomVertexArrayData(get_index_format(), get_usage_hint()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_index_format -// Access: Private, Static -// Description: Returns a registered format appropriate for using to -// store the index table. -//////////////////////////////////////////////////////////////////// +/** + * Returns a registered format appropriate for using to store the index table. + */ INLINE CPT(GeomVertexArrayFormat) GeomPrimitive:: make_index_format(NumericType index_type) { PT(GeomVertexArrayFormat) format = new GeomVertexArrayFormat; - // It's important that the index format *not* respect the global - // setting of vertex-column-alignment. It needs to be tightly - // packed, so we specify an explict column_alignment of 1. + // It's important that the index format *not* respect the global setting of + // vertex-column-alignment. It needs to be tightly packed, so we specify an + // explict column_alignment of 1. format->add_column(InternalName::get_index(), 1, index_type, C_index, 0, 1); return GeomVertexArrayFormat::register_format(format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitive::CData:: CData() : _shade_model(SM_smooth), @@ -484,11 +390,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitive::CData:: CData(const GeomPrimitive::CData ©) : _shade_model(copy._shade_model), @@ -506,11 +410,9 @@ CData(const GeomPrimitive::CData ©) : _max_vertex(copy._max_vertex) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitivePipelineReader:: GeomPrimitivePipelineReader(const GeomPrimitive *object, Thread *current_thread) : @@ -528,37 +430,31 @@ GeomPrimitivePipelineReader(const GeomPrimitive *object, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE GeomPrimitivePipelineReader:: GeomPrimitivePipelineReader(const GeomPrimitivePipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void GeomPrimitivePipelineReader:: operator = (const GeomPrimitivePipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitivePipelineReader:: ~GeomPrimitivePipelineReader() { #ifdef _DEBUG nassertv(_object->test_ref_count_nonzero()); #endif // _DEBUG - // _object->_cycler.release_read(_cdata); + // _object->_cycler.release_read(_cdata); #ifdef DO_PIPELINING unref_delete((CycleData *)_cdata); @@ -571,71 +467,57 @@ INLINE GeomPrimitivePipelineReader:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomPrimitive *GeomPrimitivePipelineReader:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *GeomPrimitivePipelineReader:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_shade_model -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitivePipelineReader::ShadeModel GeomPrimitivePipelineReader:: get_shade_model() const { return _cdata->_shade_model; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_usage_hint -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitivePipelineReader::UsageHint GeomPrimitivePipelineReader:: get_usage_hint() const { return _cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_index_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomPrimitivePipelineReader::NumericType GeomPrimitivePipelineReader:: get_index_type() const { return _cdata->_index_type; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::is_indexed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomPrimitivePipelineReader:: is_indexed() const { return (!_cdata->_vertices.is_null()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_num_vertices -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPrimitivePipelineReader:: get_num_vertices() const { if (_cdata->_num_vertices != -1) { @@ -646,105 +528,84 @@ get_num_vertices() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_min_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPrimitivePipelineReader:: get_min_vertex() const { nassertr(_cdata->_got_minmax, 0); return _cdata->_min_vertex; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_max_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPrimitivePipelineReader:: get_max_vertex() const { nassertr(_cdata->_got_minmax, 0); return _cdata->_max_vertex; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_data_size_bytes -// Access: Published -// Description: Returns the number of bytes stored in the vertices -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes stored in the vertices array. + */ INLINE int GeomPrimitivePipelineReader:: get_data_size_bytes() const { return _vertices_reader->get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq GeomPrimitivePipelineReader:: get_modified() const { return _cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_index_stride -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPrimitivePipelineReader:: get_index_stride() const { nassertr(is_indexed(), 0); return _cdata->_vertices.get_read_pointer()->get_array_format()->get_stride(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_vertices_reader -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexArrayDataHandle *GeomPrimitivePipelineReader:: get_vertices_reader() const { return _vertices_reader; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_read_pointer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const unsigned char *GeomPrimitivePipelineReader:: get_read_pointer(bool force) const { return _vertices_reader->get_read_pointer(force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_strip_cut_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomPrimitivePipelineReader:: get_strip_cut_index() const { return GeomPrimitive::get_strip_cut_index(_cdata->_index_type); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_ends -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPTA_int GeomPrimitivePipelineReader:: get_ends() const { return _cdata->_ends; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_mins -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_mins() const { nassertr(is_indexed(), NULL); @@ -752,11 +613,9 @@ get_mins() const { return _cdata->_mins.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_maxs -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(GeomVertexArrayData) GeomPrimitivePipelineReader:: get_maxs() const { nassertr(is_indexed(), NULL); @@ -764,11 +623,9 @@ get_maxs() const { return _cdata->_maxs.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::prepare_now -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IndexBufferContext *GeomPrimitivePipelineReader:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const { diff --git a/panda/src/gobj/geomPrimitive.cxx b/panda/src/gobj/geomPrimitive.cxx index 797ea9e1c8..67b65689e1 100644 --- a/panda/src/gobj/geomPrimitive.cxx +++ b/panda/src/gobj/geomPrimitive.cxx @@ -1,16 +1,15 @@ -// Filename: geomPrimitive.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPrimitive.cxx + * @author drose + * @date 2005-03-06 + */ #include "geomPrimitive.h" #include "geom.h" @@ -41,42 +40,33 @@ PStatCollector GeomPrimitive::_doubleside_pcollector("*:Munge:Doubleside"); PStatCollector GeomPrimitive::_reverse_pcollector("*:Munge:Reverse"); PStatCollector GeomPrimitive::_rotate_pcollector("*:Munge:Rotate"); -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::Default Constructor -// Access: Protected -// Description: Constructs an invalid object. Only used when reading -// from bam. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid object. Only used when reading from bam. + */ GeomPrimitive:: GeomPrimitive() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) GeomPrimitive:: make_cow_copy() { return make_copy().p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPrimitive:: GeomPrimitive(GeomPrimitive::UsageHint usage_hint) { CDWriter cdata(_cycler, true); cdata->_usage_hint = usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPrimitive:: GeomPrimitive(const GeomPrimitive ©) : CopyOnWriteObject(copy), @@ -84,37 +74,29 @@ GeomPrimitive(const GeomPrimitive ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::Copy Assignment Operator -// Access: Published -// Description: The copy assignment operator is not pipeline-safe. -// This will completely obliterate all stages of the -// pipeline, so don't do it for a GeomPrimitive that is -// actively being used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * The copy assignment operator is not pipeline-safe. This will completely + * obliterate all stages of the pipeline, so don't do it for a GeomPrimitive + * that is actively being used for rendering. + */ void GeomPrimitive:: operator = (const GeomPrimitive ©) { CopyOnWriteObject::operator = (copy); _cycler = copy._cycler; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomPrimitive:: ~GeomPrimitive() { release_all(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_geom_rendering -// Access: Published, Virtual -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ int GeomPrimitive:: get_geom_rendering() const { if (is_indexed()) { @@ -124,16 +106,12 @@ get_geom_rendering() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_usage_hint -// Access: Published -// Description: Changes the UsageHint hint for this primitive. See -// get_usage_hint(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the UsageHint hint for this primitive. See get_usage_hint(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: set_usage_hint(GeomPrimitive::UsageHint usage_hint) { CDWriter cdata(_cycler, true); @@ -145,24 +123,18 @@ set_usage_hint(GeomPrimitive::UsageHint usage_hint) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_index_type -// Access: Published -// Description: Changes the numeric type of the index column. -// Normally, this should be either NT_uint16 or -// NT_uint32. -// -// The index type must be large enough to include all of -// the index values in the primitive. It may be -// automatically elevated, if necessary, to a larger -// index type, by a subsequent call to add_index() that -// names an index value that does not fit in the index -// type you specify. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the numeric type of the index column. Normally, this should be + * either NT_uint16 or NT_uint32. + * + * The index type must be large enough to include all of the index values in + * the primitive. It may be automatically elevated, if necessary, to a larger + * index type, by a subsequent call to add_index() that names an index value + * that does not fit in the index type you specify. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: set_index_type(GeomPrimitive::NumericType index_type) { nassertv(get_max_vertex() <= get_highest_index_value(index_type)); @@ -173,20 +145,15 @@ set_index_type(GeomPrimitive::NumericType index_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_vertex -// Access: Published -// Description: Adds the indicated vertex to the list of vertex -// indices used by the graphics primitive type. To -// define a primitive, you must call add_vertex() for -// each vertex of the new primitive, and then call -// close_primitive() after you have specified the last -// vertex of each primitive. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated vertex to the list of vertex indices used by the + * graphics primitive type. To define a primitive, you must call add_vertex() + * for each vertex of the new primitive, and then call close_primitive() after + * you have specified the last vertex of each primitive. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: add_vertex(int vertex) { CDWriter cdata(_cycler, true); @@ -202,8 +169,8 @@ add_vertex(int vertex) { if (num_primitives > 0 && requires_unused_vertices() && get_num_vertices() == get_primitive_end(num_primitives - 1)) { - // If we are beginning a new primitive, give the derived class a - // chance to insert some degenerate vertices. + // If we are beginning a new primitive, give the derived class a chance to + // insert some degenerate vertices. if (cdata->_vertices.is_null()) { do_make_indexed(cdata); } @@ -211,8 +178,8 @@ add_vertex(int vertex) { } if (cdata->_vertices.is_null()) { - // The nonindexed case. We can keep the primitive nonindexed only - // if the vertex number happens to be the next available vertex. + // The nonindexed case. We can keep the primitive nonindexed only if the + // vertex number happens to be the next available vertex. nassertv(cdata->_num_vertices != -1); if (cdata->_num_vertices == 0) { cdata->_first_vertex = vertex; @@ -242,16 +209,13 @@ add_vertex(int vertex) { cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_consecutive_vertices -// Access: Published -// Description: Adds a consecutive sequence of vertices, beginning at -// start, to the primitive. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds a consecutive sequence of vertices, beginning at start, to the + * primitive. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: add_consecutive_vertices(int start, int num_vertices) { if (num_vertices == 0) { @@ -266,8 +230,8 @@ add_consecutive_vertices(int start, int num_vertices) { int num_primitives = get_num_primitives(); if (num_primitives > 0 && get_num_vertices() == get_primitive_end(num_primitives - 1)) { - // If we are beginning a new primitive, give the derived class a - // chance to insert some degenerate vertices. + // If we are beginning a new primitive, give the derived class a chance to + // insert some degenerate vertices. if (cdata->_vertices.is_null()) { do_make_indexed(cdata); } @@ -275,8 +239,8 @@ add_consecutive_vertices(int start, int num_vertices) { } if (cdata->_vertices.is_null()) { - // The nonindexed case. We can keep the primitive nonindexed only - // if the vertex number happens to be the next available vertex. + // The nonindexed case. We can keep the primitive nonindexed only if the + // vertex number happens to be the next available vertex. nassertv(cdata->_num_vertices != -1); if (cdata->_num_vertices == 0) { cdata->_first_vertex = start; @@ -311,17 +275,14 @@ add_consecutive_vertices(int start, int num_vertices) { cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::add_next_vertices -// Access: Published -// Description: Adds the next n vertices in sequence, beginning from -// the last vertex added to the primitive + 1. -// -// This is most useful when you are building up a -// primitive and a GeomVertexData at the same time, and -// you just want the primitive to reference the first n -// vertices from the data, then the next n, and so on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the next n vertices in sequence, beginning from the last vertex added + * to the primitive + 1. + * + * This is most useful when you are building up a primitive and a + * GeomVertexData at the same time, and you just want the primitive to + * reference the first n vertices from the data, then the next n, and so on. + */ void GeomPrimitive:: add_next_vertices(int num_vertices) { if (get_num_vertices() == 0) { @@ -331,28 +292,22 @@ add_next_vertices(int num_vertices) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::reserve_num_vertices -// Access: Published -// Description: This ensures that enough memory space for n vertices -// is allocated, so that you may increase the number of -// vertices to n without causing a new memory -// allocation. This is a performance optimization only; -// it is especially useful when you know ahead of time -// that you will be adding n vertices to the primitive. -// -// Note that the total you specify here should also -// include implicit vertices which may be added at each -// close_primitive() call, according to -// get_num_unused_vertices_per_primitive(). -// -// Note also that making this call will implicitly make -// the primitive indexed if it is not already, which -// could result in a performance *penalty*. If you -// would prefer not to lose the nonindexed nature of -// your existing GeomPrimitives, check is_indexed() -// before making this call. -//////////////////////////////////////////////////////////////////// +/** + * This ensures that enough memory space for n vertices is allocated, so that + * you may increase the number of vertices to n without causing a new memory + * allocation. This is a performance optimization only; it is especially + * useful when you know ahead of time that you will be adding n vertices to + * the primitive. + * + * Note that the total you specify here should also include implicit vertices + * which may be added at each close_primitive() call, according to + * get_num_unused_vertices_per_primitive(). + * + * Note also that making this call will implicitly make the primitive indexed + * if it is not already, which could result in a performance *penalty*. If + * you would prefer not to lose the nonindexed nature of your existing + * GeomPrimitives, check is_indexed() before making this call. + */ void GeomPrimitive:: reserve_num_vertices(int num_vertices) { if (gobj_cat.is_debug()) { @@ -367,26 +322,22 @@ reserve_num_vertices(int num_vertices) { array_obj->reserve_num_rows(num_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::close_primitive -// Access: Published -// Description: Indicates that the previous n calls to add_vertex(), -// since the last call to close_primitive(), have fully -// defined a new primitive. Returns true if successful, -// false otherwise. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the previous n calls to add_vertex(), since the last call to + * close_primitive(), have fully defined a new primitive. Returns true if + * successful, false otherwise. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ bool GeomPrimitive:: close_primitive() { int num_vertices_per_primitive = get_num_vertices_per_primitive(); CDWriter cdata(_cycler, true); if (num_vertices_per_primitive == 0) { - // This is a complex primitive type like a triangle strip: each - // primitive uses a different number of vertices. + // This is a complex primitive type like a triangle strip: each primitive + // uses a different number of vertices. #ifndef NDEBUG int num_added; if (cdata->_ends.empty()) { @@ -406,9 +357,9 @@ close_primitive() { } else { #ifndef NDEBUG - // This is a simple primitive type like a triangle: each primitive - // uses the same number of vertices. Assert that we added the - // correct number of vertices. + // This is a simple primitive type like a triangle: each primitive uses + // the same number of vertices. Assert that we added the correct number + // of vertices. int num_vertices_per_primitive = get_num_vertices_per_primitive(); int num_unused_vertices_per_primitive = get_num_unused_vertices_per_primitive(); @@ -422,25 +373,22 @@ close_primitive() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::clear_vertices -// Access: Published -// Description: Removes all of the vertices and primitives from the -// object, so they can be re-added. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the vertices and primitives from the object, so they can be + * re-added. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: clear_vertices() { CDWriter cdata(_cycler, true); cdata->_first_vertex = 0; cdata->_num_vertices = 0; - // Since we might have automatically elevated the index type by - // adding vertices, we should automatically lower it again when we - // call clear_vertices(). + // Since we might have automatically elevated the index type by adding + // vertices, we should automatically lower it again when we call + // clear_vertices(). cdata->_index_type = NT_uint16; cdata->_vertices.clear(); @@ -451,16 +399,12 @@ clear_vertices() { cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::offset_vertices -// Access: Published -// Description: Adds the indicated offset to all vertices used by the -// primitive. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated offset to all vertices used by the primitive. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: offset_vertices(int offset) { if (offset == 0) { @@ -500,18 +444,14 @@ offset_vertices(int offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::offset_vertices -// Access: Published -// Description: Adds the indicated offset to the indicated segment -// of vertices used by the primitive. Unlike the -// other version of offset_vertices, this makes the -// geometry indexed if it isn't already. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated offset to the indicated segment of vertices used by the + * primitive. Unlike the other version of offset_vertices, this makes the + * geometry indexed if it isn't already. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: offset_vertices(int offset, int begin_row, int end_row) { if (offset == 0 || end_row <= begin_row) { @@ -556,8 +496,8 @@ offset_vertices(int offset, int begin_row, int end_row) { } } else { - // The supplied values cover all vertices, so we don't need - // to make it indexed. + // The supplied values cover all vertices, so we don't need to make it + // indexed. CDWriter cdata(_cycler, true); cdata->_first_vertex += offset; @@ -569,14 +509,11 @@ offset_vertices(int offset, int begin_row, int end_row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_nonindexed -// Access: Published -// Description: Converts the primitive from indexed to nonindexed by -// duplicating vertices as necessary into the indicated -// dest GeomVertexData. Note: does not support -// primitives with strip cut indices. -//////////////////////////////////////////////////////////////////// +/** + * Converts the primitive from indexed to nonindexed by duplicating vertices + * as necessary into the indicated dest GeomVertexData. Note: does not + * support primitives with strip cut indices. + */ void GeomPrimitive:: make_nonindexed(GeomVertexData *dest, const GeomVertexData *source) { Thread *current_thread = Thread::get_current_thread(); @@ -594,19 +531,16 @@ make_nonindexed(GeomVertexData *dest, const GeomVertexData *source) { set_nonindexed_vertices(dest_start, num_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::pack_vertices -// Access: Published -// Description: Packs the vertices used by the primitive from the -// indicated source array onto the end of the indicated -// destination array. -//////////////////////////////////////////////////////////////////// +/** + * Packs the vertices used by the primitive from the indicated source array + * onto the end of the indicated destination array. + */ void GeomPrimitive:: pack_vertices(GeomVertexData *dest, const GeomVertexData *source) { Thread *current_thread = Thread::get_current_thread(); if (!is_indexed()) { - // If the primitive is nonindexed, packing is the same as - // converting (again) to nonindexed. + // If the primitive is nonindexed, packing is the same as converting + // (again) to nonindexed. make_nonindexed(dest, source); } else { @@ -627,9 +561,8 @@ pack_vertices(GeomVertexData *dest, const GeomVertexData *source) { continue; } - // Try to add the relation { v : size() }. If that succeeds, - // great; if it doesn't, look up whatever we previously added - // for v. + // Try to add the relation { v : size() }. If that succeeds, great; if + // it doesn't, look up whatever we previously added for v. pair result = copied_indices.insert(CopiedIndices::value_type(v, (int)copied_indices.size())); int v2 = (*result.first).second + dest_start; @@ -645,49 +578,40 @@ pack_vertices(GeomVertexData *dest, const GeomVertexData *source) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_indexed -// Access: Published -// Description: Converts the primitive from nonindexed form to -// indexed form. This will simply create an index table -// that is numbered consecutively from -// get_first_vertex(); it does not automatically -// collapse together identical vertices that may have -// been split apart by a previous call to -// make_nonindexed(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Converts the primitive from nonindexed form to indexed form. This will + * simply create an index table that is numbered consecutively from + * get_first_vertex(); it does not automatically collapse together identical + * vertices that may have been split apart by a previous call to + * make_nonindexed(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomPrimitive:: make_indexed() { CDWriter cdata(_cycler, true); do_make_indexed(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_start -// Access: Published -// Description: Returns the element within the _vertices list at which -// the nth primitive starts. -// -// If i is one more than the highest valid primitive -// vertex, the return value will be one more than the -// last valid vertex. Thus, it is generally true that -// the vertices used by a particular primitive i are the -// set get_primitive_start(n) <= vi < -// get_primitive_start(n + 1) (although this range also -// includes the unused vertices between primitives). -//////////////////////////////////////////////////////////////////// +/** + * Returns the element within the _vertices list at which the nth primitive + * starts. + * + * If i is one more than the highest valid primitive vertex, the return value + * will be one more than the last valid vertex. Thus, it is generally true + * that the vertices used by a particular primitive i are the set + * get_primitive_start(n) <= vi < get_primitive_start(n + 1) (although this + * range also includes the unused vertices between primitives). + */ int GeomPrimitive:: get_primitive_start(int n) const { int num_vertices_per_primitive = get_num_vertices_per_primitive(); int num_unused_vertices_per_primitive = get_num_unused_vertices_per_primitive(); if (num_vertices_per_primitive == 0) { - // This is a complex primitive type like a triangle strip: each - // primitive uses a different number of vertices. + // This is a complex primitive type like a triangle strip: each primitive + // uses a different number of vertices. CDReader cdata(_cycler); nassertr(n >= 0 && n <= (int)cdata->_ends.size(), -1); if (n == 0) { @@ -697,52 +621,46 @@ get_primitive_start(int n) const { } } else { - // This is a simple primitive type like a triangle: each primitive - // uses the same number of vertices. + // This is a simple primitive type like a triangle: each primitive uses + // the same number of vertices. return n * (num_vertices_per_primitive + num_unused_vertices_per_primitive); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_end -// Access: Published -// Description: Returns the element within the _vertices list at which -// the nth primitive ends. This is one past the last -// valid element for the nth primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the element within the _vertices list at which the nth primitive + * ends. This is one past the last valid element for the nth primitive. + */ int GeomPrimitive:: get_primitive_end(int n) const { int num_vertices_per_primitive = get_num_vertices_per_primitive(); if (num_vertices_per_primitive == 0) { - // This is a complex primitive type like a triangle strip: each - // primitive uses a different number of vertices. + // This is a complex primitive type like a triangle strip: each primitive + // uses a different number of vertices. CDReader cdata(_cycler); nassertr(n >= 0 && n < (int)cdata->_ends.size(), -1); return cdata->_ends[n]; } else { - // This is a simple primitive type like a triangle: each primitive - // uses the same number of vertices. + // This is a simple primitive type like a triangle: each primitive uses + // the same number of vertices. int num_unused_vertices_per_primitive = get_num_unused_vertices_per_primitive(); return n * (num_vertices_per_primitive + num_unused_vertices_per_primitive) + num_vertices_per_primitive; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_num_vertices -// Access: Published -// Description: Returns the number of vertices used by the nth -// primitive. This is the same thing as -// get_primitive_end(n) - get_primitive_start(n). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices used by the nth primitive. This is the same + * thing as get_primitive_end(n) - get_primitive_start(n). + */ int GeomPrimitive:: get_primitive_num_vertices(int n) const { int num_vertices_per_primitive = get_num_vertices_per_primitive(); if (num_vertices_per_primitive == 0) { - // This is a complex primitive type like a triangle strip: each - // primitive uses a different number of vertices. + // This is a complex primitive type like a triangle strip: each primitive + // uses a different number of vertices. CDReader cdata(_cycler); nassertr(n >= 0 && n < (int)cdata->_ends.size(), 0); if (n == 0) { @@ -753,22 +671,18 @@ get_primitive_num_vertices(int n) const { } } else { - // This is a simple primitive type like a triangle: each primitive - // uses the same number of vertices. + // This is a simple primitive type like a triangle: each primitive uses + // the same number of vertices. return num_vertices_per_primitive; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_used_vertices -// Access: Published -// Description: Returns the number of vertices used by all of the -// primitives. This is the same as summing -// get_primitive_num_vertices(n) for n in -// get_num_primitives(). It is like get_num_vertices -// except that it excludes all of the degenerate -// vertices and strip-cut indices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices used by all of the primitives. This is the + * same as summing get_primitive_num_vertices(n) for n in + * get_num_primitives(). It is like get_num_vertices except that it excludes + * all of the degenerate vertices and strip-cut indices. + */ int GeomPrimitive:: get_num_used_vertices() const { int num_primitives = get_num_primitives(); @@ -781,12 +695,10 @@ get_num_used_vertices() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_min_vertex -// Access: Published -// Description: Returns the minimum vertex index number used by the -// nth primitive in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum vertex index number used by the nth primitive in this + * object. + */ int GeomPrimitive:: get_primitive_min_vertex(int n) const { if (is_indexed()) { @@ -801,12 +713,10 @@ get_primitive_min_vertex(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_primitive_max_vertex -// Access: Published -// Description: Returns the maximum vertex index number used by the -// nth primitive in this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum vertex index number used by the nth primitive in this + * object. + */ int GeomPrimitive:: get_primitive_max_vertex(int n) const { if (is_indexed()) { @@ -821,20 +731,16 @@ get_primitive_max_vertex(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::decompose -// Access: Published -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance triangle strips to -// triangles, and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to iterate through the set of triangles on the -// primitive without having to write handlers for each -// possible kind of primitive type. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance triangle strips to triangles, and returns a pointer to the new + * primitive definition. If the decomposition cannot be performed, this might + * return the original object. + * + * This method is useful for application code that wants to iterate through + * the set of triangles on the primitive without having to write handlers for + * each possible kind of primitive type. + */ CPT(GeomPrimitive) GeomPrimitive:: decompose() const { if (gobj_cat.is_debug()) { @@ -846,20 +752,15 @@ decompose() const { return decompose_impl(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::rotate -// Access: Published -// Description: Returns a new primitive with the shade_model reversed -// (if it is flat shaded), if possible. If the -// primitive type cannot be rotated, returns the -// original primitive, unrotated. -// -// If the current shade_model indicates -// flat_vertex_last, this should bring the last vertex -// to the first position; if it indicates -// flat_vertex_first, this should bring the first vertex -// to the last position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new primitive with the shade_model reversed (if it is flat + * shaded), if possible. If the primitive type cannot be rotated, returns the + * original primitive, unrotated. + * + * If the current shade_model indicates flat_vertex_last, this should bring + * the last vertex to the first position; if it indicates flat_vertex_first, + * this should bring the first vertex to the last position. + */ CPT(GeomPrimitive) GeomPrimitive:: rotate() const { if (gobj_cat.is_debug()) { @@ -894,21 +795,16 @@ rotate() const { return new_prim; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::doubleside -// Access: Published -// Description: Duplicates triangles in the primitive so that each -// triangle is back-to-back with another triangle facing -// in the opposite direction. Note that this doesn't -// affect vertex normals, so this operation alone won't -// work in the presence of lighting (but see -// SceneGraphReducer::doubleside()). -// -// Also see CullFaceAttrib, which can enable rendering -// of both sides of a triangle without having to -// duplicate it (but which doesn't necessarily work in -// the presence of lighting). -//////////////////////////////////////////////////////////////////// +/** + * Duplicates triangles in the primitive so that each triangle is back-to-back + * with another triangle facing in the opposite direction. Note that this + * doesn't affect vertex normals, so this operation alone won't work in the + * presence of lighting (but see SceneGraphReducer::doubleside()). + * + * Also see CullFaceAttrib, which can enable rendering of both sides of a + * triangle without having to duplicate it (but which doesn't necessarily work + * in the presence of lighting). + */ CPT(GeomPrimitive) GeomPrimitive:: doubleside() const { if (gobj_cat.is_debug()) { @@ -920,21 +816,16 @@ doubleside() const { return doubleside_impl(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::reverse -// Access: Published -// Description: Reverses the winding order in the primitive so that -// each triangle is facing in the opposite direction it -// was originally. Note that this doesn't affect vertex -// normals, so this operation alone won't work in the -// presence of lighting (but see -// SceneGraphReducer::reverse()). -// -// Also see CullFaceAttrib, which can change the visible -// direction of a triangle without having to duplicate -// it (but which doesn't necessarily work in the -// presence of lighting). -//////////////////////////////////////////////////////////////////// +/** + * Reverses the winding order in the primitive so that each triangle is facing + * in the opposite direction it was originally. Note that this doesn't affect + * vertex normals, so this operation alone won't work in the presence of + * lighting (but see SceneGraphReducer::reverse()). + * + * Also see CullFaceAttrib, which can change the visible direction of a + * triangle without having to duplicate it (but which doesn't necessarily work + * in the presence of lighting). + */ CPT(GeomPrimitive) GeomPrimitive:: reverse() const { if (gobj_cat.is_debug()) { @@ -946,19 +837,14 @@ reverse() const { return reverse_impl(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::match_shade_model -// Access: Published -// Description: Returns a new primitive that is compatible with the -// indicated shade model, if possible, or NULL if this -// is not possible. -// -// In most cases, this will return either NULL or the -// original primitive. In the case of a -// SM_flat_first_vertex vs. a SM_flat_last_vertex (or -// vice-versa), however, it will return a rotated -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new primitive that is compatible with the indicated shade model, + * if possible, or NULL if this is not possible. + * + * In most cases, this will return either NULL or the original primitive. In + * the case of a SM_flat_first_vertex vs. a SM_flat_last_vertex (or vice- + * versa), however, it will return a rotated primitive. + */ CPT(GeomPrimitive) GeomPrimitive:: match_shade_model(GeomPrimitive::ShadeModel shade_model) const { ShadeModel this_shade_model = get_shade_model(); @@ -987,23 +873,20 @@ match_shade_model(GeomPrimitive::ShadeModel shade_model) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_points -// Access: Published -// Description: Returns a new GeomPoints primitive that represents -// each of the vertices in the original primitive, -// rendered exactly once. If the original primitive is -// already a GeomPoints primitive, returns the original -// primitive unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomPoints primitive that represents each of the vertices in + * the original primitive, rendered exactly once. If the original primitive + * is already a GeomPoints primitive, returns the original primitive + * unchanged. + */ CPT(GeomPrimitive) GeomPrimitive:: make_points() const { if (is_exact_type(GeomPoints::get_class_type())) { return this; } - // First, get a list of all of the vertices referenced by the - // original primitive. + // First, get a list of all of the vertices referenced by the original + // primitive. BitArray bits; int num_vertices = get_num_vertices(); if (is_indexed()) { @@ -1046,15 +929,11 @@ make_points() const { return points; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_lines -// Access: Published -// Description: Returns a new GeomLines primitive that represents -// each of the edges in the original primitive rendered -// as a line. If the original primitive is already a -// GeomLines primitive, returns the original primitive -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomLines primitive that represents each of the edges in the + * original primitive rendered as a line. If the original primitive is + * already a GeomLines primitive, returns the original primitive unchanged. + */ CPT(GeomPrimitive) GeomPrimitive:: make_lines() const { if (is_exact_type(GeomLines::get_class_type())) { @@ -1072,8 +951,8 @@ make_lines() const { } if (prim_type == PT_polygons && !is_exact_type(GeomTriangles::get_class_type())) { - // Decompose tristrips. We could probably make this more efficient - // by making a specific implementation of make_lines for GeomTristrips. + // Decompose tristrips. We could probably make this more efficient by + // making a specific implementation of make_lines for GeomTristrips. return decompose()->make_lines(); } @@ -1106,19 +985,15 @@ make_lines() const { return lines; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::make_patches -// Access: Published -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance triangle strips to -// triangles, puts these in a new GeomPatches object -// and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to use tesselation shaders on arbitrary geometry. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance triangle strips to triangles, puts these in a new GeomPatches + * object and returns a pointer to the new primitive definition. If the + * decomposition cannot be performed, this might return the original object. + * + * This method is useful for application code that wants to use tesselation + * shaders on arbitrary geometry. + */ CPT(GeomPrimitive) GeomPrimitive:: make_patches() const { if (is_exact_type(GeomPatches::get_class_type())) { @@ -1140,12 +1015,10 @@ make_patches() const { return patches; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_bytes -// Access: Published -// Description: Returns the number of bytes consumed by the primitive -// and its index table(s). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes consumed by the primitive and its index + * table(s). + */ int GeomPrimitive:: get_num_bytes() const { CDReader cdata(_cycler); @@ -1157,14 +1030,11 @@ get_num_bytes() const { return num_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::request_resident -// Access: Published -// Description: Returns true if the primitive data is currently -// resident in memory. If this returns false, the -// primitive data will be brought back into memory -// shortly; try again later. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the primitive data is currently resident in memory. If + * this returns false, the primitive data will be brought back into memory + * shortly; try again later. + */ bool GeomPrimitive:: request_resident() const { CDReader cdata(_cycler); @@ -1190,22 +1060,18 @@ request_resident() const { return resident; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomPrimitive:: output(ostream &out) const { out << get_type() << ", " << get_num_primitives() << ", " << get_num_vertices(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomPrimitive:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -1241,31 +1107,25 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::modify_vertices -// Access: Published -// Description: Returns a modifiable pointer to the vertex index -// list, so application code can directly fiddle with -// this data. Use with caution, since there are no -// checks that the data will be left in a stable state. -// -// If this is called on a nonindexed primitive, it will -// implicitly be converted to an indexed primitive. -// -// If num_vertices is not -1, it specifies an artificial -// limit to the number of vertices in the array. -// Otherwise, all of the vertices in the array will be -// used. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the vertex index list, so application code + * can directly fiddle with this data. Use with caution, since there are no + * checks that the data will be left in a stable state. + * + * If this is called on a nonindexed primitive, it will implicitly be + * converted to an indexed primitive. + * + * If num_vertices is not -1, it specifies an artificial limit to the number + * of vertices in the array. Otherwise, all of the vertices in the array will + * be used. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ PT(GeomVertexArrayData) GeomPrimitive:: modify_vertices(int num_vertices) { CDWriter cdata(_cycler, true); @@ -1274,27 +1134,22 @@ modify_vertices(int num_vertices) { return vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_vertices -// Access: Published -// Description: Completely replaces the vertex index list with a new -// table. Chances are good that you should also replace -// the ends list with set_ends() at the same time. -// -// If num_vertices is not -1, it specifies an artificial -// limit to the number of vertices in the array. -// Otherwise, all of the vertices in the array will be -// used. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the vertex index list with a new table. Chances are + * good that you should also replace the ends list with set_ends() at the same + * time. + * + * If num_vertices is not -1, it specifies an artificial limit to the number + * of vertices in the array. Otherwise, all of the vertices in the array will + * be used. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ void GeomPrimitive:: set_vertices(const GeomVertexArrayData *vertices, int num_vertices) { CDWriter cdata(_cycler, true); @@ -1310,21 +1165,17 @@ set_vertices(const GeomVertexArrayData *vertices, int num_vertices) { cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_nonindexed_vertices -// Access: Published -// Description: Sets the primitive up as a nonindexed primitive, -// using the indicated vertex range. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Sets the primitive up as a nonindexed primitive, using the indicated vertex + * range. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ void GeomPrimitive:: set_nonindexed_vertices(int first_vertex, int num_vertices) { nassertv(num_vertices != -1); @@ -1340,27 +1191,22 @@ set_nonindexed_vertices(int first_vertex, int num_vertices) { recompute_minmax(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::modify_ends -// Access: Published -// Description: Returns a modifiable pointer to the primitive ends -// array, so application code can directly fiddle with -// this data. Use with caution, since there are no -// checks that the data will be left in a stable state. -// -// Note that simple primitive types, like triangles, do -// not have a ends array: since all the primitives -// have the same number of vertices, it is not needed. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the primitive ends array, so application + * code can directly fiddle with this data. Use with caution, since there are + * no checks that the data will be left in a stable state. + * + * Note that simple primitive types, like triangles, do not have a ends array: + * since all the primitives have the same number of vertices, it is not + * needed. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ PTA_int GeomPrimitive:: modify_ends() { CDWriter cdata(_cycler, true); @@ -1376,27 +1222,22 @@ modify_ends() { return cdata->_ends; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_ends -// Access: Published -// Description: Completely replaces the primitive ends array with -// a new table. Chances are good that you should also -// replace the vertices list with set_vertices() at the -// same time. -// -// Note that simple primitive types, like triangles, do -// not have a ends array: since all the primitives -// have the same number of vertices, it is not needed. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the primitive ends array with a new table. Chances are + * good that you should also replace the vertices list with set_vertices() at + * the same time. + * + * Note that simple primitive types, like triangles, do not have a ends array: + * since all the primitives have the same number of vertices, it is not + * needed. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ void GeomPrimitive:: set_ends(PTA_int ends) { CDWriter cdata(_cycler, true); @@ -1406,27 +1247,21 @@ set_ends(PTA_int ends) { cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::set_minmax -// Access: Published -// Description: Explicitly specifies the minimum and maximum -// vertices, as well as the lists of per-component min -// and max. -// -// Use this method with extreme caution. It's generally -// better to let the GeomPrimitive compute these -// explicitly, unless for some reason you can do it -// faster and you absolutely need the speed improvement. -// -// Note that any modification to the vertex array will -// normally cause this to be recomputed, unless you set -// it immediately again. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Explicitly specifies the minimum and maximum vertices, as well as the lists + * of per-component min and max. + * + * Use this method with extreme caution. It's generally better to let the + * GeomPrimitive compute these explicitly, unless for some reason you can do + * it faster and you absolutely need the speed improvement. + * + * Note that any modification to the vertex array will normally cause this to + * be recomputed, unless you set it immediately again. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ void GeomPrimitive:: set_minmax(int min_vertex, int max_vertex, GeomVertexArrayData *mins, GeomVertexArrayData *maxs) { @@ -1440,92 +1275,72 @@ set_minmax(int min_vertex, int max_vertex, cdata->_got_minmax = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::clear_minmax -// Access: Published -// Description: Undoes a previous call to set_minmax(), and allows -// the minimum and maximum values to be recomputed -// normally. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Undoes a previous call to set_minmax(), and allows the minimum and maximum + * values to be recomputed normally. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ void GeomPrimitive:: clear_minmax() { CDWriter cdata(_cycler, true); cdata->_got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_vertices_per_primitive -// Access: Published, Virtual -// Description: If the primitive type is a simple type in which all -// primitives have the same number of vertices, like -// triangles, returns the number of vertices per -// primitive. If the primitive type is a more complex -// type in which different primitives might have -// different numbers of vertices, for instance a -// triangle strip, returns 0. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like triangles, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a + * triangle strip, returns 0. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ int GeomPrimitive:: get_num_vertices_per_primitive() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_min_num_vertices_per_primitive -// Access: Published, Virtual -// Description: Returns the minimum number of vertices that must be -// added before close_primitive() may legally be called. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ int GeomPrimitive:: get_min_num_vertices_per_primitive() const { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_num_unused_vertices_per_primitive -// Access: Published, Virtual -// Description: Returns the number of vertices that are added between -// primitives that aren't, strictly speaking, part of -// the primitives themselves. This is used, for -// instance, to define degenerate triangles to connect -// otherwise disconnected triangle strips. -// -// This method is intended for low-level usage only. -// There are higher-level methods for more common usage. -// We recommend you do not use this method directly. If -// you do, be sure you know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices that are added between primitives that + * aren't, strictly speaking, part of the primitives themselves. This is + * used, for instance, to define degenerate triangles to connect otherwise + * disconnected triangle strips. + * + * This method is intended for low-level usage only. There are higher-level + * methods for more common usage. We recommend you do not use this method + * directly. If you do, be sure you know what you are doing! + */ int GeomPrimitive:: get_num_unused_vertices_per_primitive() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::prepare -// Access: Public -// Description: Indicates that the data should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. This will ensure the -// data is already loaded into the GSG if it is expected -// to be rendered soon. -// -// Use this function instead of prepare_now() to preload -// datas from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the data should be enqueued to be prepared in the indicated + * prepared_objects at the beginning of the next frame. This will ensure the + * data is already loaded into the GSG if it is expected to be rendered soon. + * + * Use this function instead of prepare_now() to preload datas from a user + * interface standpoint. + */ void GeomPrimitive:: prepare(PreparedGraphicsObjects *prepared_objects) { if (is_indexed()) { @@ -1533,13 +1348,10 @@ prepare(PreparedGraphicsObjects *prepared_objects) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::is_prepared -// Access: Published -// Description: Returns true if the data has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool GeomPrimitive:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { Contexts::const_iterator ci; @@ -1550,22 +1362,17 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_index_buffer_queued(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::prepare_now -// Access: Public -// Description: Creates a context for the data on the particular -// GSG, if it does not already exist. Returns the new -// (or old) IndexBufferContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// datas. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a data does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the data on the particular GSG, if it does not + * already exist. Returns the new (or old) IndexBufferContext. This assumes + * that the GraphicsStateGuardian is the currently active rendering context + * and that it is ready to accept new datas. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a data does not need to be explicitly prepared by the user before it may be + * rendered. + */ IndexBufferContext *GeomPrimitive:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { @@ -1584,13 +1391,10 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, return ibc; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::release -// Access: Public -// Description: Frees the data context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the data context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ bool GeomPrimitive:: release(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -1605,18 +1409,15 @@ release(PreparedGraphicsObjects *prepared_objects) { return prepared_objects->dequeue_index_buffer(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::release_all -// Access: Public -// Description: Frees the context allocated on all objects for which -// the data has been declared. Returns the number of -// contexts which have been freed. -//////////////////////////////////////////////////////////////////// +/** + * Frees the context allocated on all objects for which the data has been + * declared. Returns the number of contexts which have been freed. + */ int GeomPrimitive:: release_all() { // We have to traverse a copy of the _contexts list, because the - // PreparedGraphicsObjects object will call clear_prepared() in response - // to each release_index_buffer(), and we don't want to be modifying the + // PreparedGraphicsObjects object will call clear_prepared() in response to + // each release_index_buffer(), and we don't want to be modifying the // _contexts list while we're traversing it. Contexts temp = _contexts; int num_freed = (int)_contexts.size(); @@ -1628,20 +1429,17 @@ release_all() { prepared_objects->release_index_buffer(ibc); } - // Now that we've called release_index_buffer() on every known context, - // the _contexts list should have completely emptied itself. + // Now that we've called release_index_buffer() on every known context, the + // _contexts list should have completely emptied itself. nassertr(_contexts.empty(), num_freed); return num_freed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_index_format -// Access: Public, Static -// Description: Returns a registered GeomVertexArrayFormat of the -// indicated unsigned integer numeric type for storing -// index values. -//////////////////////////////////////////////////////////////////// +/** + * Returns a registered GeomVertexArrayFormat of the indicated unsigned + * integer numeric type for storing index values. + */ const GeomVertexArrayFormat *GeomPrimitive:: get_index_format(NumericType index_type) { switch (index_type) { @@ -1679,16 +1477,12 @@ get_index_format(NumericType index_type) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::clear_prepared -// Access: Private -// Description: Removes the indicated PreparedGraphicsObjects table -// from the data array's table, without actually -// releasing the data array. This is intended to be -// called only from -// PreparedGraphicsObjects::release_index_buffer(); it should -// never be called by user code. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PreparedGraphicsObjects table from the data array's + * table, without actually releasing the data array. This is intended to be + * called only from PreparedGraphicsObjects::release_index_buffer(); it should + * never be called by user code. + */ void GeomPrimitive:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -1696,23 +1490,20 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { if (ci != _contexts.end()) { _contexts.erase(ci); } else { - // If this assertion fails, clear_prepared() was given a - // prepared_objects which the data array didn't know about. + // If this assertion fails, clear_prepared() was given a prepared_objects + // which the data array didn't know about. nassertv(false); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_highest_index_value -// Access: Private, Static -// Description: Returns the largest index value that can be stored -// in an index of the indicated type, minus one (to -// leave room for a potential strip cut index) -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest index value that can be stored in an index of the + * indicated type, minus one (to leave room for a potential strip cut index) + */ int GeomPrimitive:: get_highest_index_value(NumericType index_type) { - // Reserve the highest possible index because implementations use - // this as a strip-cut index. + // Reserve the highest possible index because implementations use this as a + // strip-cut index. switch (index_type) { case NT_uint8: return 0xff - 1; @@ -1721,8 +1512,8 @@ get_highest_index_value(NumericType index_type) { return 0xffff - 1; case NT_uint32: - // We don't actually allow use of the sign bit, since all of our - // functions receive an "int" instead of an "unsigned int". + // We don't actually allow use of the sign bit, since all of our functions + // receive an "int" instead of an "unsigned int". return 0x7fffffff - 1; default: @@ -1730,19 +1521,16 @@ get_highest_index_value(NumericType index_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::get_strip_cut_index -// Access: Private, Static -// Description: Returns the index of the indicated type that is -// reserved for use as a strip cut index, if enabled -// for the primitive. When the renderer encounters -// this index, it will restart the primitive. This -// is guaranteed not to point to an actual vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated type that is reserved for use as a strip + * cut index, if enabled for the primitive. When the renderer encounters this + * index, it will restart the primitive. This is guaranteed not to point to + * an actual vertex. + */ int GeomPrimitive:: get_strip_cut_index(NumericType index_type) { - // Reserve the highest possible index because implementations use - // this as a strip-cut index. + // Reserve the highest possible index because implementations use this as a + // strip-cut index. switch (index_type) { case NT_uint8: return 0xff; @@ -1756,21 +1544,16 @@ get_strip_cut_index(NumericType index_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::calc_tight_bounds -// Access: Public, Virtual -// Description: Expands min_point and max_point to include all of the -// vertices in the Geom, if any (or the data of any -// point type, for instance, texture coordinates--based -// on the column name). found_any is set true if any -// points are found. It is the caller's responsibility -// to initialize min_point, max_point, and found_any -// before calling this function. -// It also sets sq_center_dist, which is the square of -// the maximum distance of the points to the center. -// This can be useful when deciding whether a sphere -// volume might be more appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Expands min_point and max_point to include all of the vertices in the Geom, + * if any (or the data of any point type, for instance, texture coordinates-- + * based on the column name). found_any is set true if any points are found. + * It is the caller's responsibility to initialize min_point, max_point, and + * found_any before calling this function. It also sets sq_center_dist, which + * is the square of the maximum distance of the points to the center. This + * can be useful when deciding whether a sphere volume might be more + * appropriate. + */ void GeomPrimitive:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, PN_stdfloat &sq_center_dist, bool &found_any, @@ -1911,15 +1694,13 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::calc_sphere_radius -// Access: Public, Virtual -// Description: Expands radius so that a sphere with the given -// center point fits all of the vertices. -// -// The center point is assumed to already have been -// transformed by the matrix, if one is given. -//////////////////////////////////////////////////////////////////// +/** + * Expands radius so that a sphere with the given center point fits all of the + * vertices. + * + * The center point is assumed to already have been transformed by the matrix, + * if one is given. + */ void GeomPrimitive:: calc_sphere_radius(const LPoint3 ¢er, PN_stdfloat &sq_radius, bool &found_any, const GeomVertexData *vertex_data, @@ -1974,30 +1755,24 @@ calc_sphere_radius(const LPoint3 ¢er, PN_stdfloat &sq_radius, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::decompose_impl -// Access: Protected, Virtual -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance triangle strips to -// triangles, and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to iterate through the set of triangles on the -// primitive without having to write handlers for each -// possible kind of primitive type. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance triangle strips to triangles, and returns a pointer to the new + * primitive definition. If the decomposition cannot be performed, this might + * return the original object. + * + * This method is useful for application code that wants to iterate through + * the set of triangles on the primitive without having to write handlers for + * each possible kind of primitive type. + */ CPT(GeomPrimitive) GeomPrimitive:: decompose_impl() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of rotate(). + */ CPT(GeomVertexArrayData) GeomPrimitive:: rotate_impl() const { // The default implementation doesn't even try to do anything. @@ -2005,64 +1780,52 @@ rotate_impl() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::doubleside_impl -// Access: Protected, Virtual -// Description: The virtual implementation of doubleside(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of doubleside(). + */ CPT(GeomPrimitive) GeomPrimitive:: doubleside_impl() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::reverse_impl -// Access: Protected, Virtual -// Description: The virtual implementation of reverse(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of reverse(). + */ CPT(GeomPrimitive) GeomPrimitive:: reverse_impl() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::requires_unused_vertices -// Access: Protected, Virtual -// Description: Should be redefined to return true in any primitive -// that implements append_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true in any primitive that implements + * append_unused_vertices(). + */ bool GeomPrimitive:: requires_unused_vertices() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::append_unused_vertices -// Access: Protected, Virtual -// Description: Called when a new primitive is begun (other than the -// first primitive), this should add some degenerate -// vertices between primitives, if the primitive type -// requires that. The second parameter is the first -// vertex that begins the new primitive. -// -// This method is only called if -// requires_unused_vertices(), above, returns true. -//////////////////////////////////////////////////////////////////// +/** + * Called when a new primitive is begun (other than the first primitive), this + * should add some degenerate vertices between primitives, if the primitive + * type requires that. The second parameter is the first vertex that begins + * the new primitive. + * + * This method is only called if requires_unused_vertices(), above, returns + * true. + */ void GeomPrimitive:: append_unused_vertices(GeomVertexArrayData *, int) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::recompute_minmax -// Access: Private -// Description: Recomputes the _min_vertex and _max_vertex values if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the _min_vertex and _max_vertex values if necessary. + */ void GeomPrimitive:: recompute_minmax(GeomPrimitive::CData *cdata) { if (cdata->_vertices.is_null()) { - // In the nonindexed case, we don't need to do much (the - // minmax is trivial). + // In the nonindexed case, we don't need to do much (the minmax is + // trivial). nassertv(cdata->_num_vertices != -1); cdata->_min_vertex = cdata->_first_vertex; cdata->_max_vertex = cdata->_first_vertex + cdata->_num_vertices - 1; @@ -2080,8 +1843,8 @@ recompute_minmax(GeomPrimitive::CData *cdata) { cdata->_maxs.clear(); } else if (get_num_vertices_per_primitive() == 0) { - // This is a complex primitive type like a triangle strip; compute - // the minmax of each primitive (as well as the overall minmax). + // This is a complex primitive type like a triangle strip; compute the + // minmax of each primitive (as well as the overall minmax). GeomVertexReader index(cdata->_vertices.get_read_pointer(), 0); cdata->_mins = make_index_data(); @@ -2113,8 +1876,8 @@ recompute_minmax(GeomPrimitive::CData *cdata) { unsigned int vertex; if (vi == cdata->_ends[pi]) { - // Skip unused vertices, since they won't be very relevant and - // may contain a strip-cut index, which would distort the result. + // Skip unused vertices, since they won't be very relevant and may + // contain a strip-cut index, which would distort the result. if (num_unused_vertices > 0) { vi += num_unused_vertices; index.set_row_unsafe(vi); @@ -2142,8 +1905,8 @@ recompute_minmax(GeomPrimitive::CData *cdata) { nassertv(mins.get_array_data()->get_num_rows() == (int)cdata->_ends.size()); } else { - // This is a simple primitive type like a triangle; just compute - // the overall minmax. + // This is a simple primitive type like a triangle; just compute the + // overall minmax. GeomVertexReader index(cdata->_vertices.get_read_pointer(), 0); cdata->_mins.clear(); @@ -2165,11 +1928,9 @@ recompute_minmax(GeomPrimitive::CData *cdata) { cdata->_got_minmax = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::do_make_indexed -// Access: Private -// Description: The private implementation of make_indexed(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of make_indexed(). + */ void GeomPrimitive:: do_make_indexed(CData *cdata) { if (cdata->_vertices.is_null()) { @@ -2192,18 +1953,15 @@ do_make_indexed(CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::consider_elevate_index_type -// Access: Private -// Description: If the indicated new vertex index won't fit in the -// specified index type, automatically elevates the -// index type to the next available size. -//////////////////////////////////////////////////////////////////// +/** + * If the indicated new vertex index won't fit in the specified index type, + * automatically elevates the index type to the next available size. + */ void GeomPrimitive:: consider_elevate_index_type(CData *cdata, int vertex) { - // Note that we reserve the highest possible index of a particular - // index type (ie. -1) because this is commonly used as a strip-cut - // (also known as primitive restart) index. + // Note that we reserve the highest possible index of a particular index + // type (ie. -1) because this is commonly used as a strip-cut (also known + // as primitive restart) index. switch (cdata->_index_type) { case NT_uint8: if (vertex >= 0xff) { @@ -2227,11 +1985,9 @@ consider_elevate_index_type(CData *cdata, int vertex) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::do_set_index_type -// Access: Private -// Description: The private implementation of set_index_type(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of set_index_type(). + */ void GeomPrimitive:: do_set_index_type(CData *cdata, GeomPrimitive::NumericType index_type) { int old_strip_cut_index = get_strip_cut_index(cdata->_index_type); @@ -2268,11 +2024,9 @@ do_set_index_type(CData *cdata, GeomPrimitive::NumericType index_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::do_modify_vertices -// Access: Private -// Description: The private implementation of modify_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of modify_vertices(). + */ PT(GeomVertexArrayData) GeomPrimitive:: do_modify_vertices(GeomPrimitive::CData *cdata) { if (cdata->_vertices.is_null()) { @@ -2286,12 +2040,10 @@ do_modify_vertices(GeomPrimitive::CData *cdata) { return vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomPrimitive:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -2299,13 +2051,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void GeomPrimitive:: finalize(BamReader *manager) { const GeomVertexArrayData *vertices = get_vertices(); @@ -2314,13 +2064,10 @@ finalize(BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomPrimitive. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomPrimitive. + */ void GeomPrimitive:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -2329,22 +2076,18 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->register_finalize(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GeomPrimitive::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomPrimitive::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint8(_shade_model); @@ -2357,13 +2100,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { WRITE_PTA(manager, dg, IPD_int::write_datagram, _ends); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomPrimitive::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -2371,22 +2111,19 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { _vertices = DCAST(GeomVertexArrayData, p_list[pi++]); if (manager->get_file_minor_ver() < 6 && !_vertices.is_null()) { - // Older bam files might have a meaningless number in - // _num_vertices if the primitive is indexed. Nowadays, this - // number is always considered meaningful unless it is -1. + // Older bam files might have a meaningless number in _num_vertices if the + // primitive is indexed. Nowadays, this number is always considered + // meaningful unless it is -1. _num_vertices = -1; } return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitive::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomPrimitive. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomPrimitive. + */ void GeomPrimitive::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _shade_model = (ShadeModel)scan.get_uint8(); @@ -2402,18 +2139,14 @@ fillin(DatagramIterator &scan, BamReader *manager) { _got_minmax = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::check_minmax -// Access: Public -// Description: Ensures that the primitive's minmax cache has been -// computed. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the primitive's minmax cache has been computed. + */ void GeomPrimitivePipelineReader:: check_minmax() const { if (!_cdata->_got_minmax) { - // We'll need to get a fresh pointer, since another thread might - // already have modified the pointer on the object since we - // queried it. + // We'll need to get a fresh pointer, since another thread might already + // have modified the pointer on the object since we queried it. { #ifdef DO_PIPELINING unref_delete((CycleData *)_cdata); @@ -2426,26 +2159,23 @@ check_minmax() const { #endif if (!fresh_cdata->_got_minmax) { - // The cache is still stale. We have to do the work of - // freshening it. + // The cache is still stale. We have to do the work of freshening it. ((GeomPrimitive *)_object.p())->recompute_minmax(fresh_cdata); nassertv(fresh_cdata->_got_minmax); } - // When fresh_cdata goes out of scope, its write lock is - // released, and _cdata reverts to our usual convention of an - // unlocked copy of the data. + // When fresh_cdata goes out of scope, its write lock is released, and + // _cdata reverts to our usual convention of an unlocked copy of the + // data. } } nassertv(_cdata->_got_minmax); } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_first_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomPrimitivePipelineReader:: get_first_vertex() const { if (_cdata->_vertices.is_null()) { @@ -2458,11 +2188,9 @@ get_first_vertex() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_vertex -// Access: Public -// Description: Returns the ith vertex index in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith vertex index in the table. + */ int GeomPrimitivePipelineReader:: get_vertex(int i) const { if (!_cdata->_vertices.is_null()) { @@ -2479,32 +2207,28 @@ get_vertex(int i) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::get_num_primitives -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomPrimitivePipelineReader:: get_num_primitives() const { int num_vertices_per_primitive = _object->get_num_vertices_per_primitive(); if (num_vertices_per_primitive == 0) { - // This is a complex primitive type like a triangle strip: each - // primitive uses a different number of vertices. + // This is a complex primitive type like a triangle strip: each primitive + // uses a different number of vertices. return _cdata->_ends.size(); } else { - // This is a simple primitive type like a triangle: each primitive - // uses the same number of vertices. + // This is a simple primitive type like a triangle: each primitive uses + // the same number of vertices. return (get_num_vertices() / num_vertices_per_primitive); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomPrimitivePipelineReader::check_valid -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomPrimitivePipelineReader:: check_valid(const GeomVertexDataPipelineReader *data_reader) const { if (get_num_vertices() != 0 && diff --git a/panda/src/gobj/geomPrimitive.h b/panda/src/gobj/geomPrimitive.h index 2cf5e67d0d..9c24af0c45 100644 --- a/panda/src/gobj/geomPrimitive.h +++ b/panda/src/gobj/geomPrimitive.h @@ -1,16 +1,15 @@ -// Filename: geomPrimitive.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomPrimitive.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOMPRIMITIVE_H #define GEOMPRIMITIVE_H @@ -39,27 +38,21 @@ class GraphicsStateGuardianBase; class FactoryParams; class GeomPrimitivePipelineReader; -//////////////////////////////////////////////////////////////////// -// Class : GeomPrimitive -// Description : This is an abstract base class for a family of -// classes that represent the fundamental geometry -// primitives that may be stored in a Geom. -// -// They all have in common the fact that they are -// defined by tables of vertex data stored in a -// GeomVertexData object. Each GeomPrimitive object -// contains an ordered list of integers, which index -// into the vertex array defined by the GeomVertexData -// and define the particular vertices of the -// GeomVertexData that are used for this primitive. -// -// The meaning of a given arrangement of vertices is -// defined by each individual primitive type; for -// instance, a GeomTriangle renders a triangle from each -// three consecutive vertices, while a GeomTriangleStrip -// renders a strip of (n - 2) connected triangles from -// each sequence of n vertices. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class for a family of classes that represent the + * fundamental geometry primitives that may be stored in a Geom. + * + * They all have in common the fact that they are defined by tables of vertex + * data stored in a GeomVertexData object. Each GeomPrimitive object contains + * an ordered list of integers, which index into the vertex array defined by + * the GeomVertexData and define the particular vertices of the GeomVertexData + * that are used for this primitive. + * + * The meaning of a given arrangement of vertices is defined by each + * individual primitive type; for instance, a GeomTriangle renders a triangle + * from each three consecutive vertices, while a GeomTriangleStrip renders a + * strip of (n - 2) connected triangles from each sequence of n vertices. + */ class EXPCL_PANDA_GOBJ GeomPrimitive : public CopyOnWriteObject, public GeomEnums { protected: GeomPrimitive(); @@ -93,10 +86,10 @@ PUBLISHED: // The following published methods are provided for safe, high-level // iteration through the vertices and sub-primitives within the - // GeomPrimitive class. These work correctly regardless of the - // primitive type and without depending on knowledge about the way - // primitives' lengths are encoded. You can also safely build up a - // composite primitive using these methods. + // GeomPrimitive class. These work correctly regardless of the primitive + // type and without depending on knowledge about the way primitives' lengths + // are encoded. You can also safely build up a composite primitive using + // these methods. INLINE bool is_composite() const; INLINE bool is_indexed() const; @@ -157,15 +150,16 @@ PUBLISHED: virtual void write(ostream &out, int indent_level) const; PUBLISHED: - // These public methods are not intended for high-level usage. They - // are public so that low-level code that absolutely needs fast - // access to the primitive data can get to it, but using them - // requires knowledge about how the component primitives are encoded - // within the GeomPrimitive class, and it's easy to screw something - // up. Also, if too many code samples depend on this internal - // knowledge, it may make it difficult to extend this class later. - // It is recommended that application-level code use the above - // interfaces instead. +/* + * These public methods are not intended for high-level usage. They are + * public so that low-level code that absolutely needs fast access to the + * primitive data can get to it, but using them requires knowledge about how + * the component primitives are encoded within the GeomPrimitive class, and + * it's easy to screw something up. Also, if too many code samples depend on + * this internal knowledge, it may make it difficult to extend this class + * later. It is recommended that application-level code use the above + * interfaces instead. + */ INLINE CPT(GeomVertexArrayData) get_vertices() const; PT(GeomVertexArrayData) modify_vertices(int num_vertices = -1); @@ -254,10 +248,9 @@ private: private: // A GeomPrimitive keeps a list (actually, a map) of all the - // PreparedGraphicsObjects tables that it has been prepared into. - // Each PGO conversely keeps a list (a set) of all the Geoms that - // have been prepared there. When either destructs, it removes - // itself from the other's list. + // PreparedGraphicsObjects tables that it has been prepared into. Each PGO + // conversely keeps a list (a set) of all the Geoms that have been prepared + // there. When either destructs, it removes itself from the other's list. typedef pmap Contexts; Contexts _contexts; @@ -348,11 +341,10 @@ private: friend class GeomPrimitivePipelineReader; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomPrimitivePipelineReader -// Description : Encapsulates the data from a GeomPrimitive, -// pre-fetched for one stage of the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of + * the pipeline. + */ class EXPCL_PANDA_GOBJ GeomPrimitivePipelineReader : public GeomEnums { public: INLINE GeomPrimitivePipelineReader(const GeomPrimitive *object, Thread *current_thread); diff --git a/panda/src/gobj/geomTriangles.cxx b/panda/src/gobj/geomTriangles.cxx index 8e31879e48..98074d63c1 100644 --- a/panda/src/gobj/geomTriangles.cxx +++ b/panda/src/gobj/geomTriangles.cxx @@ -1,16 +1,15 @@ -// Filename: geomTriangles.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTriangles.cxx + * @author drose + * @date 2005-03-06 + */ #include "geomTriangles.h" #include "geomVertexRewriter.h" @@ -21,96 +20,76 @@ TypeHandle GeomTriangles::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTriangles:: GeomTriangles(GeomTriangles::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomTriangles:: GeomTriangles(const GeomTriangles ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTriangles:: ~GeomTriangles() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomTriangles:: make_copy() const { return new GeomTriangles(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomTriangles:: get_primitive_type() const { return PT_polygons; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::get_num_vertices_per_primitive -// Access: Public, Virtual -// Description: If the primitive type is a simple type in which all -// primitives have the same number of vertices, like -// triangles, returns the number of vertices per -// primitive. If the primitive type is a more complex -// type in which different primitives might have -// different numbers of vertices, for instance a -// triangle strip, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * If the primitive type is a simple type in which all primitives have the + * same number of vertices, like triangles, returns the number of vertices per + * primitive. If the primitive type is a more complex type in which different + * primitives might have different numbers of vertices, for instance a + * triangle strip, returns 0. + */ int GeomTriangles:: get_num_vertices_per_primitive() const { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomTriangles:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_triangles(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::doubleside_impl -// Access: Protected, Virtual -// Description: The virtual implementation of doubleside(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of doubleside(). + */ CPT(GeomPrimitive) GeomTriangles:: doubleside_impl() const { Thread *current_thread = Thread::get_current_thread(); @@ -118,12 +97,11 @@ doubleside_impl() const { GeomPrimitivePipelineReader from(this, current_thread); - // This is like reverse(), except we don't clear the vertices first. - // That way we double the vertices up. + // This is like reverse(), except we don't clear the vertices first. That + // way we double the vertices up. - // First, rotate the original copy, if necessary, so the - // flat-first/flat-last nature of the vertices is consistent - // throughout the primitive. + // First, rotate the original copy, if necessary, so the flat-firstflat-last + // nature of the vertices is consistent throughout the primitive. bool needs_rotate = false; switch (from.get_shade_model()) { case SM_flat_first_vertex: @@ -140,8 +118,8 @@ doubleside_impl() const { reversed->add_vertex(from.get_vertex(i)); } - // Finally, re-rotate the whole thing to get back to the original - // shade model. + // Finally, re-rotate the whole thing to get back to the original shade + // model. if (needs_rotate) { reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate()); } @@ -149,11 +127,9 @@ doubleside_impl() const { return reversed.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::reverse_impl -// Access: Protected, Virtual -// Description: The virtual implementation of reverse(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of reverse(). + */ CPT(GeomPrimitive) GeomTriangles:: reverse_impl() const { Thread *current_thread = Thread::get_current_thread(); @@ -184,19 +160,16 @@ reverse_impl() const { return reversed.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of rotate(). + */ CPT(GeomVertexArrayData) GeomTriangles:: rotate_impl() const { - // To rotate triangles, we just move one vertex from the front to - // the back, or vice-versa; but we have to know what direction we're - // going. + // To rotate triangles, we just move one vertex from the front to the back, + // or vice-versa; but we have to know what direction we're going. ShadeModel shade_model = get_shade_model(); int num_vertices = get_num_vertices(); - + PT(GeomVertexArrayData) new_vertices = make_index_data(); new_vertices->set_num_rows(num_vertices); @@ -204,7 +177,7 @@ rotate_impl() const { CPT(GeomVertexArrayData) vertices = get_vertices(); GeomVertexReader from(vertices, 0); GeomVertexWriter to(new_vertices, 0); - + switch (shade_model) { case SM_flat_first_vertex: // Move the first vertex to the end. @@ -218,7 +191,7 @@ rotate_impl() const { } } break; - + case SM_flat_last_vertex: // Move the last vertex to the front. { @@ -231,19 +204,19 @@ rotate_impl() const { } } break; - + default: // This shouldn't get called with any other shade model. nassertr(false, vertices); } - + nassertr(to.is_at_end(), NULL); } else { // Nonindexed case. int first_vertex = get_first_vertex(); GeomVertexWriter to(new_vertices, 0); - + switch (shade_model) { case SM_flat_first_vertex: // Move the first vertex to the end. @@ -255,7 +228,7 @@ rotate_impl() const { } } break; - + case SM_flat_last_vertex: // Move the last vertex to the front. { @@ -266,37 +239,31 @@ rotate_impl() const { } } break; - + default: // This shouldn't get called with any other shade model. nassertr(false, NULL); } - + nassertr(to.is_at_end(), NULL); } return new_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomTriangles:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTriangles::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomTriangles:: make_from_bam(const FactoryParams ¶ms) { GeomTriangles *object = new GeomTriangles(UH_unspecified); diff --git a/panda/src/gobj/geomTriangles.h b/panda/src/gobj/geomTriangles.h index 7b1ab2d413..f2e4d4de73 100644 --- a/panda/src/gobj/geomTriangles.h +++ b/panda/src/gobj/geomTriangles.h @@ -1,16 +1,15 @@ -// Filename: geomTriangles.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTriangles.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOMTRIANGLES_H #define GEOMTRIANGLES_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomTriangles -// Description : Defines a series of disconnected triangles. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of disconnected triangles. + */ class EXPCL_PANDA_GOBJ GeomTriangles : public GeomPrimitive { PUBLISHED: GeomTriangles(UsageHint usage_hint); diff --git a/panda/src/gobj/geomTrifans.cxx b/panda/src/gobj/geomTrifans.cxx index de62c73056..3808da40bb 100644 --- a/panda/src/gobj/geomTrifans.cxx +++ b/panda/src/gobj/geomTrifans.cxx @@ -1,16 +1,15 @@ -// Filename: geomTrifans.cxx -// Created by: drose (08Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTrifans.cxx + * @author drose + * @date 2005-03-08 + */ #include "geomTrifans.h" #include "geomTriangles.h" @@ -21,70 +20,56 @@ TypeHandle GeomTrifans::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTrifans:: GeomTrifans(GeomTrifans::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomTrifans:: GeomTrifans(const GeomTrifans ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTrifans:: ~GeomTrifans() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomTrifans:: make_copy() const { return new GeomTrifans(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomTrifans:: get_primitive_type() const { return PT_polygons; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::get_geom_rendering -// Access: Published, Virtual -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ int GeomTrifans:: get_geom_rendering() const { if (is_indexed()) { @@ -94,32 +79,25 @@ get_geom_rendering() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomTrifans:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_trifans(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::decompose_impl -// Access: Protected, Virtual -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance triangle strips to -// triangles, and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to iterate through the set of triangles on the -// primitive without having to write handlers for each -// possible kind of primitive type. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance triangle strips to triangles, and returns a pointer to the new + * primitive definition. If the decomposition cannot be performed, this might + * return the original object. + * + * This method is useful for application code that wants to iterate through + * the set of triangles on the primitive without having to write handlers for + * each possible kind of primitive type. + */ CPT(GeomPrimitive) GeomTrifans:: decompose_impl() const { PT(GeomTriangles) triangles = new GeomTriangles(get_usage_hint()); @@ -154,38 +132,30 @@ decompose_impl() const { return triangles.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of do_rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of do_rotate(). + */ CPT(GeomVertexArrayData) GeomTrifans:: rotate_impl() const { - // Actually, we can't rotate fans without chaging the winding order. - // It's an error to define a flat shade model for a GeomTrifan. + // Actually, we can't rotate fans without chaging the winding order. It's + // an error to define a flat shade model for a GeomTrifan. nassertr(false, NULL); return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomTrifans:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTrifans::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomTrifans:: make_from_bam(const FactoryParams ¶ms) { GeomTrifans *object = new GeomTrifans(UH_unspecified); diff --git a/panda/src/gobj/geomTrifans.h b/panda/src/gobj/geomTrifans.h index 5880d18063..0a3380faa8 100644 --- a/panda/src/gobj/geomTrifans.h +++ b/panda/src/gobj/geomTrifans.h @@ -1,16 +1,15 @@ -// Filename: geomTrifans.h -// Created by: drose (08Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTrifans.h + * @author drose + * @date 2005-03-08 + */ #ifndef GEOMTRIFANS_H #define GEOMTRIFANS_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomTrifans -// Description : Defines a series of triangle fans. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of triangle fans. + */ class EXPCL_PANDA_GOBJ GeomTrifans : public GeomPrimitive { PUBLISHED: GeomTrifans(UsageHint usage_hint); diff --git a/panda/src/gobj/geomTristrips.cxx b/panda/src/gobj/geomTristrips.cxx index a8f20512d1..e6dea04359 100644 --- a/panda/src/gobj/geomTristrips.cxx +++ b/panda/src/gobj/geomTristrips.cxx @@ -1,16 +1,15 @@ -// Filename: geomTristrips.cxx -// Created by: drose (08Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTristrips.cxx + * @author drose + * @date 2005-03-08 + */ #include "geomTristrips.h" #include "geomTriangles.h" @@ -22,70 +21,56 @@ TypeHandle GeomTristrips::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTristrips:: GeomTristrips(GeomTristrips::UsageHint usage_hint) : GeomPrimitive(usage_hint) { } - -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomTristrips:: GeomTristrips(const GeomTristrips ©) : GeomPrimitive(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTristrips:: ~GeomTristrips() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomPrimitive) GeomTristrips:: make_copy() const { return new GeomTristrips(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::get_primitive_type -// Access: Public, Virtual -// Description: Returns the fundamental rendering type of this -// primitive: whether it is points, lines, or polygons. -// -// This is used to set up the appropriate antialiasing -// settings when AntialiasAttrib::M_auto is in effect; -// it also implies the type of primitive that will be -// produced when decompose() is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental rendering type of this primitive: whether it is + * points, lines, or polygons. + * + * This is used to set up the appropriate antialiasing settings when + * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive + * that will be produced when decompose() is called. + */ GeomPrimitive::PrimitiveType GeomTristrips:: get_primitive_type() const { return PT_polygons; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::get_geom_rendering -// Access: Published, Virtual -// Description: Returns the set of GeomRendering bits that represent -// the rendering properties required to properly render -// this primitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of GeomRendering bits that represent the rendering + * properties required to properly render this primitive. + */ int GeomTristrips:: get_geom_rendering() const { if (is_indexed()) { @@ -95,57 +80,45 @@ get_geom_rendering() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::get_min_num_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the minimum number of vertices that must be -// added before close_primitive() may legally be called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum number of vertices that must be added before + * close_primitive() may legally be called. + */ int GeomTristrips:: get_min_num_vertices_per_primitive() const { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::get_num_unused_vertices_per_primitive -// Access: Public, Virtual -// Description: Returns the number of vertices that are added between -// primitives that aren't, strictly speaking, part of -// the primitives themselves. This is used, for -// instance, to define degenerate triangles to connect -// otherwise disconnected triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices that are added between primitives that + * aren't, strictly speaking, part of the primitives themselves. This is + * used, for instance, to define degenerate triangles to connect otherwise + * disconnected triangle strips. + */ int GeomTristrips:: get_num_unused_vertices_per_primitive() const { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::draw -// Access: Public, Virtual -// Description: Calls the appropriate method on the GSG to draw the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate method on the GSG to draw the primitive. + */ bool GeomTristrips:: draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const { return gsg->draw_tristrips(reader, force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::decompose_impl -// Access: Protected, Virtual -// Description: Decomposes a complex primitive type into a simpler -// primitive type, for instance triangle strips to -// triangles, and returns a pointer to the new primitive -// definition. If the decomposition cannot be -// performed, this might return the original object. -// -// This method is useful for application code that wants -// to iterate through the set of triangles on the -// primitive without having to write handlers for each -// possible kind of primitive type. -//////////////////////////////////////////////////////////////////// +/** + * Decomposes a complex primitive type into a simpler primitive type, for + * instance triangle strips to triangles, and returns a pointer to the new + * primitive definition. If the decomposition cannot be performed, this might + * return the original object. + * + * This method is useful for application code that wants to iterate through + * the set of triangles on the primitive without having to write handlers for + * each possible kind of primitive type. + */ CPT(GeomPrimitive) GeomTristrips:: decompose_impl() const { PT(GeomTriangles) triangles = new GeomTriangles(get_usage_hint()); @@ -155,13 +128,12 @@ decompose_impl() const { int num_vertices = get_num_vertices(); int num_unused = get_num_unused_vertices_per_primitive(); - // We need a slightly different algorithm for SM_flat_first_vertex - // than for SM_flat_last_vertex, to preserve the key vertex in the - // right place. The remaining shade models can use either - // algorithm. + // We need a slightly different algorithm for SM_flat_first_vertex than for + // SM_flat_last_vertex, to preserve the key vertex in the right place. The + // remaining shade models can use either algorithm. if (get_shade_model() == SM_flat_first_vertex) { - // Preserve the first vertex of each component triangle as the - // first vertex of each generated triangle. + // Preserve the first vertex of each component triangle as the first + // vertex of each generated triangle. int vi = -num_unused; int li = 0; while (li < (int)ends.size()) { @@ -202,8 +174,8 @@ decompose_impl() const { nassertr(vi == num_vertices, NULL); } else { - // Preserve the last vertex of each component triangle as the - // last vertex of each generated triangle. + // Preserve the last vertex of each component triangle as the last vertex + // of each generated triangle. int vi = -num_unused; int li = 0; while (li < (int)ends.size()) { @@ -247,42 +219,36 @@ decompose_impl() const { return triangles.p(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::doubleside_impl -// Access: Protected, Virtual -// Description: The virtual implementation of doubleside(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of doubleside(). + */ CPT(GeomPrimitive) GeomTristrips:: doubleside_impl() const { - // TODO: implement this properly as triangle strips, without - // requiring a decompose operation first. + // TODO: implement this properly as triangle strips, without requiring a + // decompose operation first. return decompose_impl()->doubleside(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::reverse_impl -// Access: Protected, Virtual -// Description: The virtual implementation of reverse(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of reverse(). + */ CPT(GeomPrimitive) GeomTristrips:: reverse_impl() const { - // TODO: implement this properly as triangle strips, without - // requiring a decompose operation first. + // TODO: implement this properly as triangle strips, without requiring a + // decompose operation first. return decompose_impl()->reverse(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::rotate_impl -// Access: Protected, Virtual -// Description: The virtual implementation of do_rotate(). -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of do_rotate(). + */ CPT(GeomVertexArrayData) GeomTristrips:: rotate_impl() const { - // To rotate a triangle strip with an even number of vertices, we - // just reverse the vertices. But if we have an odd number of - // vertices, that doesn't work--in fact, nothing works (without also - // changing the winding order), so we don't allow an odd number of - // vertices in a flat-shaded tristrip. + // To rotate a triangle strip with an even number of vertices, we just + // reverse the vertices. But if we have an odd number of vertices, that + // doesn't work--in fact, nothing works (without also changing the winding + // order), so we don't allow an odd number of vertices in a flat-shaded + // tristrip. CPTA_int ends = get_ends(); PT(GeomVertexArrayData) new_vertices = make_index_data(); @@ -292,14 +258,14 @@ rotate_impl() const { CPT(GeomVertexArrayData) vertices = get_vertices(); GeomVertexReader from(vertices, 0); GeomVertexWriter to(new_vertices, 0); - + int begin = 0; int last_added = 0; CPTA_int::const_iterator ei; for (ei = ends.begin(); ei != ends.end(); ++ei) { int end = (*ei); int num_vertices = end - begin; - + if (begin != 0) { // Copy in the unused vertices between tristrips. to.set_data1i(last_added); @@ -307,16 +273,16 @@ rotate_impl() const { to.set_data1i(from.get_data1i()); begin += 2; } - - // If this assertion is triggered, there was a triangle strip with - // an odd number of vertices, which is not allowed. + + // If this assertion is triggered, there was a triangle strip with an + // odd number of vertices, which is not allowed. nassertr((num_vertices & 1) == 0, NULL); for (int vi = end - 1; vi >= begin; --vi) { from.set_row_unsafe(vi); last_added = from.get_data1i(); to.set_data1i(last_added); } - + begin = end; } @@ -326,29 +292,29 @@ rotate_impl() const { // Nonindexed case. int first_vertex = get_first_vertex(); GeomVertexWriter to(new_vertices, 0); - + int begin = 0; int last_added = 0; CPTA_int::const_iterator ei; for (ei = ends.begin(); ei != ends.end(); ++ei) { int end = (*ei); int num_vertices = end - begin; - + if (begin != 0) { // Copy in the unused vertices between tristrips. to.set_data1i(last_added); to.set_data1i(end - 1 + first_vertex); begin += 2; } - - // If this assertion is triggered, there was a triangle strip with - // an odd number of vertices, which is not allowed. + + // If this assertion is triggered, there was a triangle strip with an + // odd number of vertices, which is not allowed. nassertr((num_vertices & 1) == 0, NULL); for (int vi = end - 1; vi >= begin; --vi) { last_added = vi + first_vertex; to.set_data1i(last_added); } - + begin = end; } @@ -357,26 +323,21 @@ rotate_impl() const { return new_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::requires_unused_vertices -// Access: Protected, Virtual -// Description: Should be redefined to return true in any primitive -// that implements append_unused_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true in any primitive that implements + * append_unused_vertices(). + */ bool GeomTristrips:: requires_unused_vertices() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::append_unused_vertices -// Access: Protected, Virtual -// Description: Called when a new primitive is begun (other than the -// first primitive), this should add some degenerate -// vertices between primitives, if the primitive type -// requires that. The second parameter is the first -// vertex that begins the new primitive. -//////////////////////////////////////////////////////////////////// +/** + * Called when a new primitive is begun (other than the first primitive), this + * should add some degenerate vertices between primitives, if the primitive + * type requires that. The second parameter is the first vertex that begins + * the new primitive. + */ void GeomTristrips:: append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { GeomVertexReader from(vertices, 0); @@ -390,25 +351,19 @@ append_unused_vertices(GeomVertexArrayData *vertices, int vertex) { to.add_data1i(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Geom. + */ void GeomTristrips:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTristrips::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Geom is encountered -// in the Bam file. It should create the Geom -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Geom is encountered in the Bam file. It should create the Geom and + * extract its information from the file. + */ TypedWritable *GeomTristrips:: make_from_bam(const FactoryParams ¶ms) { GeomTristrips *object = new GeomTristrips(UH_unspecified); diff --git a/panda/src/gobj/geomTristrips.h b/panda/src/gobj/geomTristrips.h index 387d72485b..5bffb872d2 100644 --- a/panda/src/gobj/geomTristrips.h +++ b/panda/src/gobj/geomTristrips.h @@ -1,16 +1,15 @@ -// Filename: geomTristrips.h -// Created by: drose (08Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTristrips.h + * @author drose + * @date 2005-03-08 + */ #ifndef GEOMTRISTRIPS_H #define GEOMTRISTRIPS_H @@ -18,10 +17,9 @@ #include "pandabase.h" #include "geomPrimitive.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomTristrips -// Description : Defines a series of triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Defines a series of triangle strips. + */ class EXPCL_PANDA_GOBJ GeomTristrips : public GeomPrimitive { PUBLISHED: GeomTristrips(UsageHint usage_hint); @@ -47,7 +45,7 @@ protected: virtual CPT(GeomPrimitive) reverse_impl() const; virtual CPT(GeomVertexArrayData) rotate_impl() const; virtual bool requires_unused_vertices() const; - virtual void append_unused_vertices(GeomVertexArrayData *vertices, + virtual void append_unused_vertices(GeomVertexArrayData *vertices, int vertex); public: diff --git a/panda/src/gobj/geomVertexAnimationSpec.I b/panda/src/gobj/geomVertexAnimationSpec.I index ec719402a6..eb32efb5eb 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.I +++ b/panda/src/gobj/geomVertexAnimationSpec.I @@ -1,23 +1,19 @@ -// Filename: geomVertexAnimationSpec.I -// Created by: drose (29Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexAnimationSpec.I + * @author drose + * @date 2005-03-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexAnimationSpec:: GeomVertexAnimationSpec() : _animation_type(AT_none), @@ -26,11 +22,9 @@ GeomVertexAnimationSpec() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexAnimationSpec:: GeomVertexAnimationSpec(const GeomVertexAnimationSpec &other) : _animation_type(other._animation_type), @@ -39,11 +33,9 @@ GeomVertexAnimationSpec(const GeomVertexAnimationSpec &other) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexAnimationSpec:: operator = (const GeomVertexAnimationSpec &other) { _animation_type = other._animation_type; @@ -51,80 +43,61 @@ operator = (const GeomVertexAnimationSpec &other) { _indexed_transforms = other._indexed_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::get_animation_type -// Access: Published -// Description: Returns the type of animation represented by this -// spec. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of animation represented by this spec. + */ INLINE GeomVertexAnimationSpec::AnimationType GeomVertexAnimationSpec:: get_animation_type() const { return _animation_type; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::get_num_transforms -// Access: Published -// Description: This is only meaningful for animation_type -// AT_hardware. It specifies the maximum number of -// transforms that might be simultaneously applied to -// any one vertex by the data in this format. -//////////////////////////////////////////////////////////////////// +/** + * This is only meaningful for animation_type AT_hardware. It specifies the + * maximum number of transforms that might be simultaneously applied to any + * one vertex by the data in this format. + */ INLINE int GeomVertexAnimationSpec:: get_num_transforms() const { return _num_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::get_indexed_transforms -// Access: Published -// Description: This is only meaningful for animation_type -// AT_hardware. If true, it indicates that the format -// uses indexed animation tables. It is false if each -// vertex will reference the first _num_transforms -// table entries only. -//////////////////////////////////////////////////////////////////// +/** + * This is only meaningful for animation_type AT_hardware. If true, it + * indicates that the format uses indexed animation tables. It is false if + * each vertex will reference the first _num_transforms table entries only. + */ INLINE bool GeomVertexAnimationSpec:: get_indexed_transforms() const { return _indexed_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::set_none -// Access: Published -// Description: Specifies that no vertex animation is represented by -// this spec. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that no vertex animation is represented by this spec. + */ INLINE void GeomVertexAnimationSpec:: set_none() { _animation_type = AT_none; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::set_panda -// Access: Published -// Description: Specifies that vertex animation is to be performed by -// Panda. This is the most general setting and can -// handle any kind of vertex animation represented. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that vertex animation is to be performed by Panda. This is the + * most general setting and can handle any kind of vertex animation + * represented. + */ INLINE void GeomVertexAnimationSpec:: set_panda() { _animation_type = AT_panda; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::set_hardware -// Access: Published -// Description: Specifies that vertex animation is to be performed by -// the graphics hardware (or at least by the graphics -// backend API, which is actually still free to animate -// the vertices on the CPU). -// -// This is only legal if the graphics hardware can -// support the specified limits on number of transforms -// and/or indexed transforms. Also, no current graphics -// API's support morphing. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that vertex animation is to be performed by the graphics hardware + * (or at least by the graphics backend API, which is actually still free to + * animate the vertices on the CPU). + * + * This is only legal if the graphics hardware can support the specified + * limits on number of transforms and/or indexed transforms. Also, no current + * graphics API's support morphing. + */ INLINE void GeomVertexAnimationSpec:: set_hardware(int num_transforms, bool indexed_transforms) { _animation_type = AT_hardware; @@ -132,43 +105,33 @@ set_hardware(int num_transforms, bool indexed_transforms) { _indexed_transforms = indexed_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::operator < -// Access: Public -// Description: Provides an arbitrary ordering between different -// animation specs. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering between different animation specs. + */ INLINE bool GeomVertexAnimationSpec:: operator < (const GeomVertexAnimationSpec &other) const { return (compare_to(other) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexAnimationSpec:: operator == (const GeomVertexAnimationSpec &other) const { return (compare_to(other) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexAnimationSpec:: operator != (const GeomVertexAnimationSpec &other) const { return (compare_to(other) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::compare_to -// Access: Public -// Description: Provides an arbitrary ordering between different -// animation specs. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering between different animation specs. + */ INLINE int GeomVertexAnimationSpec:: compare_to(const GeomVertexAnimationSpec &other) const { if (_animation_type != other._animation_type) { @@ -183,7 +146,7 @@ compare_to(const GeomVertexAnimationSpec &other) const { return (int)_indexed_transforms - (int)other._indexed_transforms; } } - + return 0; } diff --git a/panda/src/gobj/geomVertexAnimationSpec.cxx b/panda/src/gobj/geomVertexAnimationSpec.cxx index 3fb72b8bec..be4dc6903a 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.cxx +++ b/panda/src/gobj/geomVertexAnimationSpec.cxx @@ -1,26 +1,23 @@ -// Filename: geomVertexAnimationSpec.cxx -// Created by: drose (29Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexAnimationSpec.cxx + * @author drose + * @date 2005-03-29 + */ #include "geomVertexAnimationSpec.h" #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexAnimationSpec:: output(ostream &out) const { switch (_animation_type) { @@ -33,18 +30,16 @@ output(ostream &out) const { break; case AT_hardware: - out << "hardware(" << _num_transforms << ", " + out << "hardware(" << _num_transforms << ", " << _indexed_transforms << ")"; break; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexAnimationSpec:: write_datagram(BamWriter *, Datagram &dg) { dg.add_uint8(_animation_type); @@ -52,13 +47,10 @@ write_datagram(BamWriter *, Datagram &dg) { dg.add_bool(_indexed_transforms); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexAnimationSpec::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexAnimationSpec. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexAnimationSpec. + */ void GeomVertexAnimationSpec:: fillin(DatagramIterator &scan, BamReader *) { _animation_type = (AnimationType)scan.get_uint8(); diff --git a/panda/src/gobj/geomVertexAnimationSpec.h b/panda/src/gobj/geomVertexAnimationSpec.h index ae265fee1d..ddd94866a5 100644 --- a/panda/src/gobj/geomVertexAnimationSpec.h +++ b/panda/src/gobj/geomVertexAnimationSpec.h @@ -1,16 +1,15 @@ -// Filename: geomVertexAnimationSpec.h -// Created by: drose (29Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexAnimationSpec.h + * @author drose + * @date 2005-03-29 + */ #ifndef GEOMVERTEXANIMATIONSPEC_H #define GEOMVERTEXANIMATIONSPEC_H @@ -23,22 +22,19 @@ class BamReader; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexAnimationSpec -// Description : This object describes how the vertex animation, if -// any, represented in a GeomVertexData is encoded. -// -// Vertex animation includes soft-skinned skeleton -// animation and morphs (blend shapes), and might be -// performed on the CPU by Panda, or passed down to the -// graphics backed to be performed on the hardware -// (depending on the hardware's advertised -// capabilities). -// -// Changing this setting doesn't by itself change the -// way the animation is actually performed; this just -// specifies how the vertices are set up to be animated. -//////////////////////////////////////////////////////////////////// +/** + * This object describes how the vertex animation, if any, represented in a + * GeomVertexData is encoded. + * + * Vertex animation includes soft-skinned skeleton animation and morphs (blend + * shapes), and might be performed on the CPU by Panda, or passed down to the + * graphics backed to be performed on the hardware (depending on the + * hardware's advertised capabilities). + * + * Changing this setting doesn't by itself change the way the animation is + * actually performed; this just specifies how the vertices are set up to be + * animated. + */ class EXPCL_PANDA_GOBJ GeomVertexAnimationSpec : public GeomEnums { PUBLISHED: INLINE GeomVertexAnimationSpec(); diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index 6091f465b7..3ee8d9311f 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -1,185 +1,146 @@ -// Filename: geomVertexArrayData.I -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayData.I + * @author drose + * @date 2005-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_array_format -// Access: Published -// Description: Returns the format object that describes this array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the format object that describes this array. + */ INLINE const GeomVertexArrayFormat *GeomVertexArrayData:: get_array_format() const { return _array_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_usage_hint -// Access: Published -// Description: Returns the usage hint that describes to the -// rendering backend how often the vertex data will be -// modified and/or rendered. See geomEnums.h. -//////////////////////////////////////////////////////////////////// +/** + * Returns the usage hint that describes to the rendering backend how often + * the vertex data will be modified and/or rendered. See geomEnums.h. + */ INLINE GeomVertexArrayData::UsageHint GeomVertexArrayData:: get_usage_hint() const { CDReader cdata(_cycler); return cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::has_column -// Access: Published -// Description: Returns true if the array has the named column, -// false otherwise. This is really just a shortcut for -// asking the same thing from the format. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the array has the named column, false otherwise. This is + * really just a shortcut for asking the same thing from the format. + */ INLINE bool GeomVertexArrayData:: has_column(const InternalName *name) const { return _array_format->has_column(name); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_num_rows -// Access: Published -// Description: Returns the number of rows stored in the array, -// based on the number of bytes and the stride. This -// should be the same for all arrays within a given -// GeomVertexData object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows stored in the array, based on the number of + * bytes and the stride. This should be the same for all arrays within a + * given GeomVertexData object. + */ INLINE int GeomVertexArrayData:: get_num_rows() const { return get_handle()->get_num_rows(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::set_num_rows -// Access: Published -// Description: Sets the length of the array to n rows. -// -// Normally, you would not call this directly, since all -// of the arrays in a particular GeomVertexData must -// have the same number of rows; instead, call -// GeomVertexData::set_num_rows(). -// -// The return value is true if the number of rows -// was changed, false if the object already contained n -// rows (or if there was some error). -// -// The new vertex data is initialized to 0, including -// the "color" column (but see -// GeomVertexData::set_num_rows()). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Sets the length of the array to n rows. + * + * Normally, you would not call this directly, since all of the arrays in a + * particular GeomVertexData must have the same number of rows; instead, call + * GeomVertexData::set_num_rows(). + * + * The return value is true if the number of rows was changed, false if the + * object already contained n rows (or if there was some error). + * + * The new vertex data is initialized to 0, including the "color" column (but + * see GeomVertexData::set_num_rows()). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE bool GeomVertexArrayData:: set_num_rows(int n) { return modify_handle()->set_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::unclean_set_num_rows -// Access: Published -// Description: This method behaves like set_num_rows(), except the -// new data is not initialized. Furthermore, after this -// call, *any* of the data in the GeomVertexArrayData -// may be uninitialized, including the earlier rows. -// -// Normally, you would not call this directly, since all -// of the arrays in a particular GeomVertexData must -// have the same number of rows; instead, call -// GeomVertexData::unclean_set_num_rows(). -//////////////////////////////////////////////////////////////////// +/** + * This method behaves like set_num_rows(), except the new data is not + * initialized. Furthermore, after this call, *any* of the data in the + * GeomVertexArrayData may be uninitialized, including the earlier rows. + * + * Normally, you would not call this directly, since all of the arrays in a + * particular GeomVertexData must have the same number of rows; instead, call + * GeomVertexData::unclean_set_num_rows(). + */ INLINE bool GeomVertexArrayData:: unclean_set_num_rows(int n) { return modify_handle()->unclean_set_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::reserve_num_rows -// Access: Published -// Description: This ensures that enough memory space for n rows is -// allocated, so that you may increase the number of -// rows to n without causing a new memory allocation. -// This is a performance optimization only; it is -// especially useful when you know ahead of time that -// you will be adding n rows to the data. -//////////////////////////////////////////////////////////////////// +/** + * This ensures that enough memory space for n rows is allocated, so that you + * may increase the number of rows to n without causing a new memory + * allocation. This is a performance optimization only; it is especially + * useful when you know ahead of time that you will be adding n rows to the + * data. + */ INLINE bool GeomVertexArrayData:: reserve_num_rows(int n) { return modify_handle()->reserve_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::clear_rows -// Access: Published -// Description: Removes all of the rows in the array. -// Functionally equivalent to set_num_rows(0). -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the rows in the array. Functionally equivalent to + * set_num_rows(0). + */ INLINE void GeomVertexArrayData:: clear_rows() { return modify_handle()->clear_rows(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_data_size_bytes -// Access: Published -// Description: Returns the number of bytes stored in the array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes stored in the array. + */ INLINE size_t GeomVertexArrayData:: get_data_size_bytes() const { CDReader cdata(_cycler); return cdata->_buffer.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the array vertex data is -// modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the array vertex data is modified. + */ INLINE UpdateSeq GeomVertexArrayData:: get_modified() const { CDReader cdata(_cycler); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::request_resident -// Access: Published -// Description: Returns true if the vertex data is currently resident -// in memory. If this returns true, the next call to -// get_handle()->get_read_pointer() will probably not -// block. If this returns false, the vertex data will -// be brought back into memory shortly; try again later. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex data is currently resident in memory. If this + * returns true, the next call to get_handle()->get_read_pointer() will + * probably not block. If this returns false, the vertex data will be brought + * back into memory shortly; try again later. + */ INLINE bool GeomVertexArrayData:: request_resident() const { CPT(GeomVertexArrayDataHandle) handle = get_handle(); return handle->request_resident(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_handle -// Access: Published -// Description: Returns an object that can be used to read the actual -// data bytes stored in the array. Calling this method -// locks the data, and will block any other threads -// attempting to read or write the data, until the -// returned object destructs. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to read the actual data bytes stored in + * the array. Calling this method locks the data, and will block any other + * threads attempting to read or write the data, until the returned object + * destructs. + */ INLINE CPT(GeomVertexArrayDataHandle) GeomVertexArrayData:: get_handle(Thread *current_thread) const { const CData *cdata = _cycler.read_unlocked(current_thread); @@ -187,15 +148,12 @@ get_handle(Thread *current_thread) const { cdata, false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::modify_handle -// Access: Published -// Description: Returns an object that can be used to read or write -// the actual data bytes stored in the array. Calling -// this method locks the data, and will block any other -// threads attempting to read or write the data, until -// the returned object destructs. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to read or write the actual data bytes + * stored in the array. Calling this method locks the data, and will block + * any other threads attempting to read or write the data, until the returned + * object destructs. + */ INLINE PT(GeomVertexArrayDataHandle) GeomVertexArrayData:: modify_handle(Thread *current_thread) { CData *cdata = _cycler.write_upstream(true, current_thread); @@ -203,46 +161,36 @@ modify_handle(Thread *current_thread) { cdata, true); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_independent_lru -// Access: Published, Static -// Description: Returns a pointer to the global LRU object that -// manages the GeomVertexArrayData's that have not (yet) -// been paged out. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global LRU object that manages the + * GeomVertexArrayData's that have not (yet) been paged out. + */ INLINE SimpleLru *GeomVertexArrayData:: get_independent_lru() { return &_independent_lru; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_small_lru -// Access: Published, Static -// Description: Returns a pointer to the global LRU object that -// manages the GeomVertexArrayData's that are deemed too -// small to be paged out. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global LRU object that manages the + * GeomVertexArrayData's that are deemed too small to be paged out. + */ INLINE SimpleLru *GeomVertexArrayData:: get_small_lru() { return &_small_lru; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::get_book -// Access: Published, Static -// Description: Returns the global VertexDataBook that will be -// used to allocate vertex data buffers. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global VertexDataBook that will be used to allocate vertex data + * buffers. + */ INLINE VertexDataBook &GeomVertexArrayData:: get_book() { return _book; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::set_lru_size -// Access: Private -// Description: Should be called when the size of the buffer changes. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the size of the buffer changes. + */ INLINE void GeomVertexArrayData:: set_lru_size(size_t lru_size) { SimpleLruPage::set_lru_size(lru_size); @@ -254,11 +202,9 @@ set_lru_size(size_t lru_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayData::CData:: CData() : _usage_hint(UH_unspecified), @@ -266,11 +212,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayData::CData:: CData(const GeomVertexArrayData::CData ©) : _usage_hint(copy._usage_hint), @@ -280,11 +224,9 @@ CData(const GeomVertexArrayData::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexArrayData::CData:: operator = (const GeomVertexArrayData::CData ©) { _usage_hint = copy._usage_hint; @@ -292,11 +234,9 @@ operator = (const GeomVertexArrayData::CData ©) { _modified = copy._modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayDataHandle:: GeomVertexArrayDataHandle(const GeomVertexArrayData *object, Thread *current_thread, @@ -313,39 +253,33 @@ GeomVertexArrayDataHandle(const GeomVertexArrayData *object, #ifdef DO_PIPELINING _cdata->ref(); #endif // DO_PIPELINING - // We must grab the lock *after* we have incremented the reference - // count, above. + // We must grab the lock *after* we have incremented the reference count, + // above. _cdata->_rw_lock.acquire(); #ifdef DO_MEMORY_USAGE MemoryUsage::update_type(this, get_class_type()); #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE GeomVertexArrayDataHandle:: GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void GeomVertexArrayDataHandle:: operator = (const GeomVertexArrayDataHandle &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayDataHandle:: ~GeomVertexArrayDataHandle() { #ifdef _DEBUG @@ -356,8 +290,8 @@ INLINE GeomVertexArrayDataHandle:: _object->_cycler.release_write(_cdata); } - // We must release the lock *before* we decrement the reference - // count, below. + // We must release the lock *before* we decrement the reference count, + // below. _cdata->_rw_lock.release(); #ifdef DO_PIPELINING @@ -370,173 +304,137 @@ INLINE GeomVertexArrayDataHandle:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *GeomVertexArrayDataHandle:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_read_pointer -// Access: Public -// Description: Returns a readable pointer to the beginning of the -// actual data stream, or NULL if the data is not -// currently resident. If the data is not currently -// resident, this will implicitly request it to become -// resident soon. -// -// If force is true, this method will never return NULL, -// but may block until the data is available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a readable pointer to the beginning of the actual data stream, or + * NULL if the data is not currently resident. If the data is not currently + * resident, this will implicitly request it to become resident soon. + * + * If force is true, this method will never return NULL, but may block until + * the data is available. + */ INLINE const unsigned char *GeomVertexArrayDataHandle:: get_read_pointer(bool force) const { mark_used(); return _cdata->_buffer.get_read_pointer(force); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_object -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexArrayData *GeomVertexArrayDataHandle:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_object -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayData *GeomVertexArrayDataHandle:: get_object() { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_array_format -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexArrayFormat *GeomVertexArrayDataHandle:: get_array_format() const { return _object->_array_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_usage_hint -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayDataHandle::UsageHint GeomVertexArrayDataHandle:: get_usage_hint() const { return _cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_num_rows -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomVertexArrayDataHandle:: get_num_rows() const { nassertr(_object->_array_format->get_stride() != 0, 0); return get_data_size_bytes() / _object->_array_format->get_stride(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::clear_rows -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexArrayDataHandle:: clear_rows() { set_num_rows(0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_data_size_bytes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t GeomVertexArrayDataHandle:: get_data_size_bytes() const { return _cdata->_buffer.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_modified -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq GeomVertexArrayDataHandle:: get_modified() const { return _cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::request_resident -// Access: Published -// Description: Returns true if the vertex data is currently resident -// in memory. If this returns true, the next call to -// get_handle()->get_read_pointer() will probably not -// block. If this returns false, the vertex data will -// be brought back into memory shortly; try again later. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex data is currently resident in memory. If this + * returns true, the next call to get_handle()->get_read_pointer() will + * probably not block. If this returns false, the vertex data will be brought + * back into memory shortly; try again later. + */ INLINE bool GeomVertexArrayDataHandle:: request_resident() const { return (get_read_pointer(false) != (const unsigned char *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::prepare_now -// Access: Public -// Description: Creates a context for the data on the particular -// GSG, if it does not already exist. Returns the new -// (or old) VertexBufferContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// datas. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a data does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the data on the particular GSG, if it does not + * already exist. Returns the new (or old) VertexBufferContext. This assumes + * that the GraphicsStateGuardian is the currently active rendering context + * and that it is ready to accept new datas. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a data does not need to be explicitly prepared by the user before it may be + * rendered. + */ INLINE VertexBufferContext *GeomVertexArrayDataHandle:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const { return _object->prepare_now(prepared_objects, gsg); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_data -// Access: Published -// Description: Returns the entire raw data of the -// GeomVertexArrayData object, formatted as a string. -// This is primarily for the benefit of high-level -// languages such as Python. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire raw data of the GeomVertexArrayData object, formatted as + * a string. This is primarily for the benefit of high-level languages such + * as Python. + */ INLINE string GeomVertexArrayDataHandle:: get_data() const { mark_used(); return string((const char *)_cdata->_buffer.get_read_pointer(true), _cdata->_buffer.get_size()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_subdata -// Access: Published -// Description: Returns a subset of the raw data of the -// GeomVertexArrayData object, formatted as a string. -// This is primarily for the benefit of high-level -// languages such as Python. -//////////////////////////////////////////////////////////////////// +/** + * Returns a subset of the raw data of the GeomVertexArrayData object, + * formatted as a string. This is primarily for the benefit of high-level + * languages such as Python. + */ INLINE string GeomVertexArrayDataHandle:: get_subdata(size_t start, size_t size) const { mark_used(); @@ -545,11 +443,9 @@ get_subdata(size_t start, size_t size) const { return string((const char *)_cdata->_buffer.get_read_pointer(true) + start, size); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::mark_used -// Access: Published -// Description: Marks the array data recently-used. -//////////////////////////////////////////////////////////////////// +/** + * Marks the array data recently-used. + */ void GeomVertexArrayDataHandle:: mark_used() const { _object->set_lru_size(_object->get_lru_size()); diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index c9c32d5483..2747e22395 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayData.cxx -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayData.cxx + * @author drose + * @date 2005-03-17 + */ #include "geomVertexArrayData.h" #include "geom.h" @@ -52,12 +51,10 @@ TypeHandle GeomVertexArrayDataHandle::_type_handle; ALLOC_DELETED_CHAIN_DEF(GeomVertexArrayDataHandle); -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::Default Constructor -// Access: Private -// Description: Constructs an invalid object. This is only used when -// reading from the bam file. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid object. This is only used when reading from the bam + * file. + */ GeomVertexArrayData:: GeomVertexArrayData() : SimpleLruPage(0) { _contexts = NULL; @@ -65,21 +62,17 @@ GeomVertexArrayData() : SimpleLruPage(0) { // Can't put it in the LRU until it has been read in and made valid. } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) GeomVertexArrayData:: make_cow_copy() { return new GeomVertexArrayData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayData:: GeomVertexArrayData(const GeomVertexArrayFormat *array_format, GeomVertexArrayData::UsageHint usage_hint) : @@ -97,12 +90,10 @@ GeomVertexArrayData(const GeomVertexArrayFormat *array_format, set_lru_size(0); nassertv(_array_format->is_registered()); } - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ GeomVertexArrayData:: GeomVertexArrayData(const GeomVertexArrayData ©) : CopyOnWriteObject(copy), @@ -118,14 +109,11 @@ GeomVertexArrayData(const GeomVertexArrayData ©) : nassertv(_array_format->is_registered()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::Copy Assignment Operator -// Access: Published -// Description: The copy assignment operator is not pipeline-safe. -// This will completely obliterate all stages of the -// pipeline, so don't do it for a GeomVertexArrayData -// that is actively being used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * The copy assignment operator is not pipeline-safe. This will completely + * obliterate all stages of the pipeline, so don't do it for a + * GeomVertexArrayData that is actively being used for rendering. + */ void GeomVertexArrayData:: operator = (const GeomVertexArrayData ©) { CopyOnWriteObject::operator = (copy); @@ -145,22 +133,18 @@ operator = (const GeomVertexArrayData ©) { nassertv(_array_format->is_registered()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayData:: ~GeomVertexArrayData() { release_all(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::compare_to -// Access: Published -// Description: Returns 0 if the two arrays are equivalent, even if -// they are not the same pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns 0 if the two arrays are equivalent, even if they are not the same + * pointer. + */ int GeomVertexArrayData:: compare_to(const GeomVertexArrayData &other) const { Thread *current_thread = Thread::get_current_thread(); @@ -177,21 +161,17 @@ compare_to(const GeomVertexArrayData &other) const { if (handle->get_data_size_bytes() != other_handle->get_data_size_bytes()) { return (int)handle->get_data_size_bytes() - (int)other_handle->get_data_size_bytes(); } - return memcmp(handle->get_read_pointer(true), + return memcmp(handle->get_read_pointer(true), other_handle->get_read_pointer(true), handle->get_data_size_bytes()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::set_usage_hint -// Access: Published -// Description: Changes the UsageHint hint for this array. See -// get_usage_hint(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the UsageHint hint for this array. See get_usage_hint(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexArrayData:: set_usage_hint(GeomVertexArrayData::UsageHint usage_hint) { CDWriter cdata(_cycler, true); @@ -199,50 +179,39 @@ set_usage_hint(GeomVertexArrayData::UsageHint usage_hint) { cdata->_modified = Geom::get_next_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayData:: output(ostream &out) const { out << get_num_rows() << " rows: " << *get_array_format(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayData:: write(ostream &out, int indent_level) const { _array_format->write_with_data(out, indent_level, this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::prepare -// Access: Public -// Description: Indicates that the data should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. This will ensure the -// data is already loaded into the GSG if it is expected -// to be rendered soon. -// -// Use this function instead of prepare_now() to preload -// datas from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the data should be enqueued to be prepared in the indicated + * prepared_objects at the beginning of the next frame. This will ensure the + * data is already loaded into the GSG if it is expected to be rendered soon. + * + * Use this function instead of prepare_now() to preload datas from a user + * interface standpoint. + */ void GeomVertexArrayData:: prepare(PreparedGraphicsObjects *prepared_objects) { prepared_objects->enqueue_vertex_buffer(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::is_prepared -// Access: Published -// Description: Returns true if the data has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool GeomVertexArrayData:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { if (_contexts == (Contexts *)NULL) { @@ -256,24 +225,19 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_vertex_buffer_queued(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::prepare_now -// Access: Public -// Description: Creates a context for the data on the particular -// GSG, if it does not already exist. Returns the new -// (or old) VertexBufferContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// datas. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a data does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the data on the particular GSG, if it does not + * already exist. Returns the new (or old) VertexBufferContext. This assumes + * that the GraphicsStateGuardian is the currently active rendering context + * and that it is ready to accept new datas. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a data does not need to be explicitly prepared by the user before it may be + * rendered. + */ VertexBufferContext *GeomVertexArrayData:: -prepare_now(PreparedGraphicsObjects *prepared_objects, +prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { if (_contexts == (Contexts *)NULL) { _contexts = new Contexts; @@ -291,13 +255,10 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, return vbc; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::release -// Access: Public -// Description: Frees the data context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the data context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ bool GeomVertexArrayData:: release(PreparedGraphicsObjects *prepared_objects) { if (_contexts != (Contexts *)NULL) { @@ -314,13 +275,10 @@ release(PreparedGraphicsObjects *prepared_objects) { return prepared_objects->dequeue_vertex_buffer(this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::release_all -// Access: Public -// Description: Frees the context allocated on all objects for which -// the data has been declared. Returns the number of -// contexts which have been freed. -//////////////////////////////////////////////////////////////////// +/** + * Frees the context allocated on all objects for which the data has been + * declared. Returns the number of contexts which have been freed. + */ int GeomVertexArrayData:: release_all() { int num_freed = 0; @@ -332,14 +290,14 @@ release_all() { // _contexts list while we're traversing it. Contexts temp = *_contexts; num_freed = (int)_contexts->size(); - + Contexts::const_iterator ci; for (ci = temp.begin(); ci != temp.end(); ++ci) { PreparedGraphicsObjects *prepared_objects = (*ci).first; VertexBufferContext *vbc = (*ci).second; prepared_objects->release_vertex_buffer(vbc); } - + // Now that we've called release_vertex_buffer() on every known context, // the _contexts list should have completely emptied itself. nassertr(_contexts == NULL, num_freed); @@ -348,13 +306,10 @@ release_all() { return num_freed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::lru_epoch -// Access: Published, Static -// Description: Marks that an epoch has passed in each LRU. Asks the -// LRU's to consider whether they should perform -// evictions. -//////////////////////////////////////////////////////////////////// +/** + * Marks that an epoch has passed in each LRU. Asks the LRU's to consider + * whether they should perform evictions. + */ void GeomVertexArrayData:: lru_epoch() { _independent_lru.begin_epoch(); @@ -362,21 +317,16 @@ lru_epoch() { VertexDataPage::get_global_lru(VertexDataPage::RC_compressed)->begin_epoch(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void GeomVertexArrayData:: evict_lru() { dequeue_lru(); @@ -384,16 +334,12 @@ evict_lru() { cdata->_buffer.page_out(_book); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::clear_prepared -// Access: Private -// Description: Removes the indicated PreparedGraphicsObjects table -// from the data array's table, without actually -// releasing the data array. This is intended to be -// called only from -// PreparedGraphicsObjects::release_vertex_buffer(); it should -// never be called by user code. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PreparedGraphicsObjects table from the data array's + * table, without actually releasing the data array. This is intended to be + * called only from PreparedGraphicsObjects::release_vertex_buffer(); it + * should never be called by user code. + */ void GeomVertexArrayData:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { nassertv(_contexts != (Contexts *)NULL); @@ -407,29 +353,26 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { _contexts = NULL; } } else { - // If this assertion fails, clear_prepared() was given a - // prepared_objects which the data array didn't know about. + // If this assertion fails, clear_prepared() was given a prepared_objects + // which the data array didn't know about. nassertv(false); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::reverse_data_endianness -// Access: Private -// Description: Fills a new data array with all numeric values -// expressed in the indicated array reversed, -// byte-for-byte, to convert littleendian to bigendian -// and vice-versa. -//////////////////////////////////////////////////////////////////// +/** + * Fills a new data array with all numeric values expressed in the indicated + * array reversed, byte-for-byte, to convert littleendian to bigendian and + * vice-versa. + */ void GeomVertexArrayData:: -reverse_data_endianness(unsigned char *dest, const unsigned char *source, +reverse_data_endianness(unsigned char *dest, const unsigned char *source, size_t size) { int num_columns = _array_format->get_num_columns(); // Walk through each row of the data. for (size_t pi = 0; pi < size; pi += _array_format->get_stride()) { - // For each row, visit all of the columns; and for each column, - // visit all of the components of that column. + // For each row, visit all of the columns; and for each column, visit all + // of the components of that column. for (int ci = 0; ci < num_columns; ++ci) { const GeomVertexColumn *col = _array_format->get_column(ci); int component_bytes = col->get_component_bytes(); @@ -449,23 +392,18 @@ reverse_data_endianness(unsigned char *dest, const unsigned char *source, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// GeomVertexArrayData. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type GeomVertexArrayData. + */ void GeomVertexArrayData:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexArrayData:: write_datagram(BamWriter *manager, Datagram &dg) { CopyOnWriteObject::write_datagram(manager, dg); @@ -474,17 +412,15 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler, this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::read_raw_data -// Access: Public -// Description: Called by CData::fillin to read the raw data -// of the array from the indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Called by CData::fillin to read the raw data of the array from the + * indicated datagram. + */ PTA_uchar GeomVertexArrayData:: read_raw_data(BamReader *manager, DatagramIterator &scan) { size_t size = scan.get_uint32(); PTA_uchar data = PTA_uchar::empty_array(size, get_class_type()); - const unsigned char *source_data = + const unsigned char *source_data = (const unsigned char *)scan.get_datagram().get_data(); memcpy(data, source_data + scan.get_current_index(), size); scan.skip_bytes(size); @@ -492,13 +428,10 @@ read_raw_data(BamReader *manager, DatagramIterator &scan) { return data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexArrayData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CopyOnWriteObject::complete_pointers(p_list, manager); @@ -508,25 +441,23 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void GeomVertexArrayData:: finalize(BamReader *manager) { - // Now we need to register the format that we have read from the bam - // file (since it doesn't come out of the bam file automatically - // registered). This may change the format's pointer, which we - // should then update our own data to reflect. But since this may - // cause the unregistered object to destruct, we have to also tell - // the BamReader to return the new object from now on. + // Now we need to register the format that we have read from the bam file + // (since it doesn't come out of the bam file automatically registered). + // This may change the format's pointer, which we should then update our own + // data to reflect. But since this may cause the unregistered object to + // destruct, we have to also tell the BamReader to return the new object + // from now on. CDWriter cdata(_cycler, true); - CPT(GeomVertexArrayFormat) new_array_format = + CPT(GeomVertexArrayFormat) new_array_format = GeomVertexArrayFormat::register_format(_array_format); manager->change_pointer(_array_format, new_array_format); @@ -545,14 +476,11 @@ finalize(BamReader *manager) { set_lru_size(cdata->_buffer.get_size()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type GeomVertexArrayData is encountered -// in the Bam file. It should create the GeomVertexArrayData -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type GeomVertexArrayData is encountered in the Bam file. It should create + * the GeomVertexArrayData and extract its information from the file. + */ TypedWritable *GeomVertexArrayData:: make_from_bam(const FactoryParams ¶ms) { GeomVertexArrayData *object = new GeomVertexArrayData; @@ -566,13 +494,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexArrayData. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexArrayData. + */ void GeomVertexArrayData:: fillin(DatagramIterator &scan, BamReader *manager) { CopyOnWriteObject::fillin(scan, manager); @@ -581,31 +506,25 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler, this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayData::CData:: ~CData() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GeomVertexArrayData::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexArrayData::CData:: write_datagram(BamWriter *manager, Datagram &dg, void *extra_data) const { GeomVertexArrayData *array_data = (GeomVertexArrayData *)extra_data; @@ -625,13 +544,10 @@ write_datagram(BamWriter *manager, Datagram &dg, void *extra_data) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexArrayData. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexArrayData. + */ void GeomVertexArrayData::CData:: fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { GeomVertexArrayData *array_data = (GeomVertexArrayData *)extra_data; @@ -651,7 +567,7 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { _buffer.unclean_realloc(size); _buffer.set_size(size); - const unsigned char *source_data = + const unsigned char *source_data = (const unsigned char *)scan.get_datagram().get_data(); memcpy(_buffer.get_write_pointer(), source_data + scan.get_current_index(), size); scan.skip_bytes(size); @@ -660,16 +576,15 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { bool endian_reversed = false; if (manager->get_file_endian() != BamReader::BE_native) { - // For non-native endian files, we have to convert the data. + // For non-native endian files, we have to convert the data. if (array_data->_array_format == (GeomVertexArrayFormat *)NULL) { - // But we can't do that until we've completed the _array_format - // pointer, which tells us how to convert it. + // But we can't do that until we've completed the _array_format pointer, + // which tells us how to convert it. endian_reversed = true; } else { - // Since we have the _array_format pointer now, we can reverse - // it immediately (and we should, to support threaded CData - // updates). + // Since we have the _array_format pointer now, we can reverse it + // immediately (and we should, to support threaded CData updates). VertexDataBuffer new_buffer(_buffer.get_size()); array_data->reverse_data_endianness(new_buffer.get_write_pointer(), _buffer.get_read_pointer(true), _buffer.get_size()); _buffer.swap(new_buffer); @@ -687,12 +602,9 @@ fillin(DatagramIterator &scan, BamReader *manager, void *extra_data) { _modified = Geom::get_next_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::get_write_pointer -// Access: Public -// Description: Returns a writable pointer to the beginning of the -// actual data stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns a writable pointer to the beginning of the actual data stream. + */ unsigned char *GeomVertexArrayDataHandle:: get_write_pointer() { nassertr(_writable, NULL); @@ -701,11 +613,9 @@ get_write_pointer() { return _cdata->_buffer.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::set_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexArrayDataHandle:: set_num_rows(int n) { nassertr(_writable, false); @@ -723,17 +633,17 @@ set_num_rows(int n) { if (new_size != orig_size) { size_t orig_reserved_size = _cdata->_buffer.get_reserved_size(); if (new_size > orig_reserved_size) { - // Add more rows. Go up to the next power of two bytes, mainly - // to reduce the number of allocs needed. + // Add more rows. Go up to the next power of two bytes, mainly to + // reduce the number of allocs needed. size_t new_reserved_size = (size_t)Texture::up_to_power_2((int)new_size); nassertr(new_reserved_size >= new_size, false); _cdata->_buffer.clean_realloc(new_reserved_size); } else if (new_size == 0) { - // If we set the number of rows to 0, go ahead and clear the - // buffer altogether, and let the user build it up again from - // nothing, to try to reduce frivolous memory waste. + // If we set the number of rows to 0, go ahead and clear the buffer + // altogether, and let the user build it up again from nothing, to try + // to reduce frivolous memory waste. _cdata->_buffer.clear(); } @@ -754,16 +664,14 @@ set_num_rows(int n) { nassertr(get_num_rows() == n, true); return true; } - + nassertr(get_num_rows() == n, false); return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::unclean_set_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexArrayDataHandle:: unclean_set_num_rows(int n) { nassertr(_writable, false); @@ -776,9 +684,9 @@ unclean_set_num_rows(int n) { if (new_size != orig_size || new_size != orig_reserved_size) { // Since this is unclean_set_num_rows(), we won't be using it to - // incrementally increase the array; instead, it will generally be - // used only to create an array initially. So it makes sense to - // set the reserved size to precisely the same as the target size. + // incrementally increase the array; instead, it will generally be used + // only to create an array initially. So it makes sense to set the + // reserved size to precisely the same as the target size. _cdata->_buffer.unclean_realloc(new_size); _cdata->_buffer.set_size(new_size); @@ -795,15 +703,13 @@ unclean_set_num_rows(int n) { } return true; } - + return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::reserve_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexArrayDataHandle:: reserve_num_rows(int n) { nassertr(_writable, false); @@ -820,10 +726,9 @@ reserve_num_rows(int n) { } if (new_reserved_size != orig_reserved_size) { - // We allow the user to set the alloc point smaller with this - // call, assuming the user knows what he's doing. This allows the - // user to reduce wasted memory after completely filling up a - // buffer. + // We allow the user to set the alloc point smaller with this call, + // assuming the user knows what he's doing. This allows the user to + // reduce wasted memory after completely filling up a buffer. _cdata->_buffer.clean_realloc(new_reserved_size); return true; } @@ -831,11 +736,9 @@ reserve_num_rows(int n) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_data_from -// Access: Public -// Description: Copies the entire data array from the other object. -//////////////////////////////////////////////////////////////////// +/** + * Copies the entire data array from the other object. + */ void GeomVertexArrayDataHandle:: copy_data_from(const GeomVertexArrayDataHandle *other) { nassertv(_writable); @@ -847,14 +750,11 @@ copy_data_from(const GeomVertexArrayDataHandle *other) { copy_data_from(source, size); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_subdata_from -// Access: Public -// Description: Copies a portion of the data array from the other -// object into a portion of the data array of this -// object. If to_size != from_size, the size of this -// data array is adjusted accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Copies a portion of the data array from the other object into a portion of + * the data array of this object. If to_size != from_size, the size of this + * data array is adjusted accordingly. + */ void GeomVertexArrayDataHandle:: copy_subdata_from(size_t to_start, size_t to_size, const GeomVertexArrayDataHandle *other, @@ -871,11 +771,9 @@ copy_subdata_from(size_t to_start, size_t to_size, from_start, from_size); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_data_from -// Access: Public -// Description: Copies the entire data array from the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Copies the entire data array from the buffer. + */ void GeomVertexArrayDataHandle:: copy_data_from(const unsigned char *source, size_t size) { nassertv(_writable); @@ -894,14 +792,11 @@ copy_data_from(const unsigned char *source, size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_subdata_from -// Access: Public -// Description: Copies a portion of the data array from the buffer -// into a portion of the data array of this object. -// If to_size != from_size, the size of this data -// array is adjusted accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Copies a portion of the data array from the buffer into a portion of the + * data array of this object. If to_size != from_size, the size of this data + * array is adjusted accordingly. + */ void GeomVertexArrayDataHandle:: copy_subdata_from(size_t to_start, size_t to_size, const unsigned char *source, @@ -917,7 +812,7 @@ copy_subdata_from(size_t to_start, size_t to_size, if (from_size < to_size) { // Reduce the array. unsigned char *pointer = to_buffer.get_write_pointer(); - memmove(pointer + to_start + to_size, + memmove(pointer + to_start + to_size, pointer + to_start + from_size, to_buffer_orig_size - (to_start + to_size)); to_buffer.set_size(to_buffer_orig_size + from_size - to_size); @@ -933,13 +828,13 @@ copy_subdata_from(size_t to_start, size_t to_size, to_buffer.set_size(needed_size); unsigned char *pointer = to_buffer.get_write_pointer(); - memmove(pointer + to_start + to_size, + memmove(pointer + to_start + to_size, pointer + to_start + from_size, to_buffer_orig_size - (to_start + to_size)); } // Now copy the data. - memcpy(to_buffer.get_write_pointer() + to_start, + memcpy(to_buffer.get_write_pointer() + to_start, source + from_start, from_size); _cdata->_modified = Geom::get_next_modified(); @@ -948,13 +843,11 @@ copy_subdata_from(size_t to_start, size_t to_size, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::set_data -// Access: Public -// Description: Replaces the entire raw data array with the contents -// of the indicated string. This is primarily for the -// benefit of high-level languages like Python. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the entire raw data array with the contents of the indicated + * string. This is primarily for the benefit of high-level languages like + * Python. + */ void GeomVertexArrayDataHandle:: set_data(const string &data) { nassertv(_writable); @@ -971,16 +864,12 @@ set_data(const string &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::set_subdata -// Access: Public -// Description: Replaces a portion of the data array from the -// indicated string. If size != data.size(), the size -// of this data array is adjusted accordingly. -// -// This is primarily for the benefit of high-level -// languages like Python. -//////////////////////////////////////////////////////////////////// +/** + * Replaces a portion of the data array from the indicated string. If size != + * data.size(), the size of this data array is adjusted accordingly. + * + * This is primarily for the benefit of high-level languages like Python. + */ void GeomVertexArrayDataHandle:: set_subdata(size_t start, size_t size, const string &data) { nassertv(_writable); @@ -990,13 +879,13 @@ set_subdata(size_t start, size_t size, const string &data) { size_t to_buffer_orig_size = to_buffer.get_size(); start = min(start, to_buffer_orig_size); size = min(size, to_buffer_orig_size - start); - + size_t from_size = data.size(); if (from_size < size) { // Reduce the array. unsigned char *pointer = to_buffer.get_write_pointer(); - memmove(pointer + start + from_size, + memmove(pointer + start + from_size, pointer + start + size, to_buffer_orig_size - (start + size)); to_buffer.set_size(to_buffer_orig_size + from_size - size); @@ -1012,7 +901,7 @@ set_subdata(size_t start, size_t size, const string &data) { to_buffer.set_size(needed_size); unsigned char *pointer = to_buffer.get_write_pointer(); - memmove(pointer + start + from_size, + memmove(pointer + start + from_size, pointer + start + size, to_buffer_orig_size - (start + size)); } diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 172c67b69b..8058409cea 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayData.h -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayData.h + * @author drose + * @date 2005-03-17 + */ #ifndef GEOMVERTEXARRAYDATA_H #define GEOMVERTEXARRAYDATA_H @@ -41,25 +40,21 @@ class GeomVertexArrayDataHandle; class VertexDataBook; class SimpleAllocatorBlock; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexArrayData -// Description : This is the data for one array of a GeomVertexData -// structure. Many GeomVertexData structures will only -// define one array, with all data elements interleaved -// (DirectX 8.0 and before insisted on this format); -// some will define multiple arrays. -// -// DirectX calls this concept of one array a "stream". -// It also closely correlates with the concept of a -// vertex buffer. -// -// This object is just a block of data. In general, you -// should not be directly messing with this object from -// application code. See GeomVertexData for the -// organizing structure, and see -// GeomVertexReader/Writer/Rewriter for high-level tools -// to manipulate the actual vertex data. -//////////////////////////////////////////////////////////////////// +/** + * This is the data for one array of a GeomVertexData structure. Many + * GeomVertexData structures will only define one array, with all data + * elements interleaved (DirectX 8.0 and before insisted on this format); some + * will define multiple arrays. + * + * DirectX calls this concept of one array a "stream". It also closely + * correlates with the concept of a vertex buffer. + * + * This object is just a block of data. In general, you should not be + * directly messing with this object from application code. See + * GeomVertexData for the organizing structure, and see + * GeomVertexReader/Writer/Rewriter for high-level tools to manipulate the + * actual vertex data. + */ class EXPCL_PANDA_GOBJ GeomVertexArrayData : public CopyOnWriteObject, public SimpleLruPage, public GeomEnums { private: GeomVertexArrayData(); @@ -138,18 +133,16 @@ private: CPT(GeomVertexArrayFormat) _array_format; // A GeomVertexArrayData keeps a list (actually, a map) of all the - // PreparedGraphicsObjects tables that it has been prepared into. - // Each PGO conversely keeps a list (a set) of all the Geoms that - // have been prepared there. When either destructs, it removes - // itself from the other's list. + // PreparedGraphicsObjects tables that it has been prepared into. Each PGO + // conversely keeps a list (a set) of all the Geoms that have been prepared + // there. When either destructs, it removes itself from the other's list. typedef pmap Contexts; Contexts *_contexts; // This data is only needed when reading from a bam file. class BamAuxData : public BamReader::AuxData { public: - // set true to indicate the data must be endian-reversed in - // finalize(). + // set true to indicate the data must be endian-reversed in finalize(). bool _endian_reversed; }; @@ -239,22 +232,18 @@ private: friend class GeomVertexArrayDataHandle; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexArrayDataHandle -// Description : This data object is returned by -// GeomVertexArrayData::get_handle() or modify_handle(). -// As long as it exists, the data is locked; when the -// last of these destructs, the data is unlocked. -// -// Only one thread at a time may lock the data; other -// threads attempting to lock the data will block. A -// given thread may simultaneously lock the data -// multiple times. -// -// This class serves in lieu of a pair of -// GeomVertexArrayDataPipelineReader and -// GeomVertexArrayDataPipelineWriter classes -//////////////////////////////////////////////////////////////////// +/** + * This data object is returned by GeomVertexArrayData::get_handle() or + * modify_handle(). As long as it exists, the data is locked; when the last of + * these destructs, the data is unlocked. + * + * Only one thread at a time may lock the data; other threads attempting to + * lock the data will block. A given thread may simultaneously lock the data + * multiple times. + * + * This class serves in lieu of a pair of GeomVertexArrayDataPipelineReader + * and GeomVertexArrayDataPipelineWriter classes + */ class EXPCL_PANDA_GOBJ GeomVertexArrayDataHandle : public ReferenceCount, public GeomEnums { private: INLINE GeomVertexArrayDataHandle(const GeomVertexArrayData *object, diff --git a/panda/src/gobj/geomVertexArrayData_ext.cxx b/panda/src/gobj/geomVertexArrayData_ext.cxx index bed312d86e..1ddf599dfd 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.cxx +++ b/panda/src/gobj/geomVertexArrayData_ext.cxx @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayData_ext.cxx -// Created by: rdb (05Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayData_ext.cxx + * @author rdb + * @date 2013-09-05 + */ #include "geomVertexArrayData_ext.h" @@ -24,13 +23,10 @@ struct InternalBufferData { }; #if PY_VERSION_HEX >= 0x02060000 -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::__getbuffer__ -// Access: Published -// Description: This is used to implement the buffer protocol, in -// order to allow efficient access to the array data -// through a Python multiview object. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement the buffer protocol, in order to allow efficient + * access to the array data through a Python multiview object. + */ int Extension:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) { @@ -45,8 +41,8 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { row_size = format->get_total_bytes(); pad_fmt = false; } else { - // The consumer expects a contiguous buffer. Give the - // stride as row size, and pad the format with extra bytes. + // The consumer expects a contiguous buffer. Give the stride as row size, + // and pad the format with extra bytes. row_size = format->get_stride(); pad_fmt = true; } @@ -85,12 +81,9 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::__getbuffer__ -// Access: Published -// Description: This is the const version of __getbuffer__, which -// does not support writing. -//////////////////////////////////////////////////////////////////// +/** + * This is the const version of __getbuffer__, which does not support writing. + */ int Extension:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { @@ -111,8 +104,8 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { row_size = format->get_total_bytes(); pad_fmt = false; } else { - // The consumer expects a contiguous buffer. Give the - // stride as row size, and pad the format with extra bytes. + // The consumer expects a contiguous buffer. Give the stride as row size, + // and pad the format with extra bytes. row_size = format->get_stride(); pad_fmt = true; } @@ -151,11 +144,9 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayData::__releasebuffer__ -// Access: Published -// Description: Releases the buffer allocated by __getbuffer__. -//////////////////////////////////////////////////////////////////// +/** + * Releases the buffer allocated by __getbuffer__. + */ void Extension:: __releasebuffer__(PyObject *self, Py_buffer *view) const { // Note: PyBuffer_Release automatically decrements view->obj. @@ -171,12 +162,10 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const { #endif // PY_VERSION_HEX >= 0x02060000 -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_data_from -// Access: Published -// Description: Copies all data from the given buffer object. -// The array is rescaled as necessary. -//////////////////////////////////////////////////////////////////// +/** + * Copies all data from the given buffer object. The array is rescaled as + * necessary. + */ void Extension:: copy_data_from(PyObject *buffer) { @@ -201,14 +190,11 @@ copy_data_from(PyObject *buffer) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_subdata_from -// Access: Public -// Description: Copies the entire data array from the buffer -// into a portion of the data array of this object. -// If to_size is not the size of the given buffer, -// the size of this dat array is adjusted accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Copies the entire data array from the buffer into a portion of the data + * array of this object. If to_size is not the size of the given buffer, the + * size of this dat array is adjusted accordingly. + */ void Extension:: copy_subdata_from(size_t to_start, size_t to_size, PyObject *buffer) { @@ -235,14 +221,11 @@ copy_subdata_from(size_t to_start, size_t to_size, PyObject *buffer) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayDataHandle::copy_subdata_from -// Access: Public -// Description: Copies a portion of the data array from the buffer -// into a portion of the data array of this object. -// If to_size != from_size, the size of this data -// array is adjusted accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Copies a portion of the data array from the buffer into a portion of the + * data array of this object. If to_size != from_size, the size of this data + * array is adjusted accordingly. + */ void Extension:: copy_subdata_from(size_t to_start, size_t to_size, PyObject *buffer, diff --git a/panda/src/gobj/geomVertexArrayData_ext.h b/panda/src/gobj/geomVertexArrayData_ext.h index 1814cc5599..d892ef5a2d 100644 --- a/panda/src/gobj/geomVertexArrayData_ext.h +++ b/panda/src/gobj/geomVertexArrayData_ext.h @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayData_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayData_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef GEOMVERTEXARRAYDATA_EXT_H #define GEOMVERTEXARRAYDATA_EXT_H @@ -23,12 +22,10 @@ #include "geomVertexArrayData.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// GeomVertexArrayData, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for GeomVertexArrayData, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: @@ -39,12 +36,10 @@ public: #endif }; -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// GeomVertexArrayDataHandle, which are called instead -// of any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for GeomVertexArrayDataHandle, + * which are called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/gobj/geomVertexArrayFormat.I b/panda/src/gobj/geomVertexArrayFormat.I index 10a5adf674..1765b0fcc4 100644 --- a/panda/src/gobj/geomVertexArrayFormat.I +++ b/panda/src/gobj/geomVertexArrayFormat.I @@ -1,69 +1,54 @@ -// Filename: geomVertexArrayFormat.I -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayFormat.I + * @author drose + * @date 2005-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::is_registered -// Access: Published -// Description: Returns true if this format has been registered, -// false if it has not. It may not be used for a Geom -// until it has been registered, but once registered, it -// may no longer be modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this format has been registered, false if it has not. It + * may not be used for a Geom until it has been registered, but once + * registered, it may no longer be modified. + */ INLINE bool GeomVertexArrayFormat:: is_registered() const { return _is_registered; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::register_format -// Access: Published, Static -// Description: Adds the indicated format to the registry, if there -// is not an equivalent format already there; in either -// case, returns the pointer to the equivalent format -// now in the registry. -// -// This is similar to -// GeomVertexFormat::register_format(), except that you -// generally need not call it explicitly. Calling -// GeomVertexFormat::register_format() automatically -// registers all of the nested array formats. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated format to the registry, if there is not an equivalent + * format already there; in either case, returns the pointer to the equivalent + * format now in the registry. + * + * This is similar to GeomVertexFormat::register_format(), except that you + * generally need not call it explicitly. Calling + * GeomVertexFormat::register_format() automatically registers all of the + * nested array formats. + */ INLINE CPT(GeomVertexArrayFormat) GeomVertexArrayFormat:: register_format(const GeomVertexArrayFormat *format) { return get_registry()->register_format((GeomVertexArrayFormat *)format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_stride -// Access: Published -// Description: Returns the total number of bytes reserved in the -// array for each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes reserved in the array for each vertex. + */ INLINE int GeomVertexArrayFormat:: get_stride() const { return _stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::set_stride -// Access: Published -// Description: Changes the total number of bytes reserved in the -// array for each vertex. You may not reduce this below -// get_total_bytes(), but you may increase it -// arbitrarily. -//////////////////////////////////////////////////////////////////// +/** + * Changes the total number of bytes reserved in the array for each vertex. + * You may not reduce this below get_total_bytes(), but you may increase it + * arbitrarily. + */ INLINE void GeomVertexArrayFormat:: set_stride(int stride) { nassertv(!_is_registered); @@ -71,33 +56,25 @@ set_stride(int stride) { _stride = stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_pad_to -// Access: Published -// Description: Returns the byte divisor to which the data record -// must be padded to meet hardware limitations. For -// instance, if this is 4, the stride will be -// automatically rounded up to the next multiple of 4 -// bytes. This value is automatically increased as -// needed to ensure the individual numeric components in -// the array are word-aligned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the byte divisor to which the data record must be padded to meet + * hardware limitations. For instance, if this is 4, the stride will be + * automatically rounded up to the next multiple of 4 bytes. This value is + * automatically increased as needed to ensure the individual numeric + * components in the array are word-aligned. + */ INLINE int GeomVertexArrayFormat:: get_pad_to() const { return _pad_to; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::set_pad_to -// Access: Published -// Description: Explicitly sets the byte divisor to which the data -// record must be padded to meet hardware limitations. -// See get_pad_to(). Normally it is not necessary to -// call this unless you have some specific requirements -// for row-to-row data alignment. Note that this value -// may be automatically increased at each subsequent -// call to add_column(). -//////////////////////////////////////////////////////////////////// +/** + * Explicitly sets the byte divisor to which the data record must be padded to + * meet hardware limitations. See get_pad_to(). Normally it is not necessary + * to call this unless you have some specific requirements for row-to-row data + * alignment. Note that this value may be automatically increased at each + * subsequent call to add_column(). + */ INLINE void GeomVertexArrayFormat:: set_pad_to(int pad_to) { nassertv(pad_to >= 1); @@ -106,61 +83,47 @@ set_pad_to(int pad_to) { _stride = ((_stride + _pad_to - 1) / _pad_to) * _pad_to; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_divisor -// Access: Published -// Description: Returns the divisor attribute for the data in this -// array. If 0, it contains per-vertex data. If 1, -// it contains per-instance data. If higher than 1, -// the read row is advanced for each n instances. -//////////////////////////////////////////////////////////////////// +/** + * Returns the divisor attribute for the data in this array. If 0, it + * contains per-vertex data. If 1, it contains per-instance data. If higher + * than 1, the read row is advanced for each n instances. + */ INLINE int GeomVertexArrayFormat:: get_divisor() const { return _divisor; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::set_divisor -// Access: Published -// Description: Set this to 0 to indicate that this array contains -// per-vertex data, or to 1 to indicate that it -// contains per-instance data. If higher than 1, -// the read row is advanced for each n instances. -//////////////////////////////////////////////////////////////////// +/** + * Set this to 0 to indicate that this array contains per-vertex data, or to 1 + * to indicate that it contains per-instance data. If higher than 1, the read + * row is advanced for each n instances. + */ INLINE void GeomVertexArrayFormat:: set_divisor(int divisor) { nassertv(divisor >= 0); _divisor = divisor; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_total_bytes -// Access: Published -// Description: Returns the total number of bytes used by the data -// types within the format, including gaps between -// elements. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes used by the data types within the format, + * including gaps between elements. + */ INLINE int GeomVertexArrayFormat:: get_total_bytes() const { return _total_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_num_columns -// Access: Published -// Description: Returns the number of different columns in the -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different columns in the array. + */ INLINE int GeomVertexArrayFormat:: get_num_columns() const { return (int)_columns.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_column -// Access: Published -// Description: Returns the ith column of the array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith column of the array. + */ INLINE const GeomVertexColumn *GeomVertexArrayFormat:: get_column(int i) const { nassertr(i >= 0 && i < (int)_columns.size(), NULL); @@ -168,22 +131,17 @@ get_column(int i) const { return _columns[(size_t)i]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::has_column -// Access: Published -// Description: Returns true if the array has the named column, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the array has the named column, false otherwise. + */ INLINE bool GeomVertexArrayFormat:: has_column(const InternalName *name) const { return (get_column(name) != (GeomVertexColumn *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ INLINE GeomVertexArrayFormat::Registry *GeomVertexArrayFormat:: get_registry() { if (_registry == (Registry *)NULL) { @@ -192,11 +150,9 @@ get_registry() { return _registry; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::consider_sort_columns -// Access: Private -// Description: Resorts the _columns vector if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Resorts the _columns vector if necessary. + */ INLINE void GeomVertexArrayFormat:: consider_sort_columns() const { if (_columns_unsorted) { diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index 4406d7f82c..30c961c33b 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayFormat.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayFormat.cxx + * @author drose + * @date 2005-03-06 + */ #include "geomVertexFormat.h" #include "geomVertexColumn.h" @@ -25,11 +24,9 @@ GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = NULL; TypeHandle GeomVertexArrayFormat::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat() : _is_registered(false), @@ -41,11 +38,9 @@ GeomVertexArrayFormat() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, GeomVertexArrayFormat::NumericType numeric_type0, @@ -60,11 +55,9 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, add_column(MOVE(name0), num_components0, numeric_type0, contents0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, GeomVertexArrayFormat::NumericType numeric_type0, @@ -83,11 +76,9 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, add_column(MOVE(name1), num_components1, numeric_type1, contents1); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, GeomVertexArrayFormat::NumericType numeric_type0, @@ -110,11 +101,9 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, add_column(MOVE(name2), num_components2, numeric_type2, contents2); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, GeomVertexArrayFormat::NumericType numeric_type0, @@ -141,11 +130,9 @@ GeomVertexArrayFormat(CPT_InternalName name0, int num_components0, add_column(MOVE(name3), num_components3, numeric_type3, contents3); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: GeomVertexArrayFormat(const GeomVertexArrayFormat ©) : _is_registered(false), @@ -161,11 +148,9 @@ GeomVertexArrayFormat(const GeomVertexArrayFormat ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayFormat:: operator = (const GeomVertexArrayFormat ©) { nassertv(!_is_registered); @@ -183,11 +168,9 @@ operator = (const GeomVertexArrayFormat ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat:: ~GeomVertexArrayFormat() { // unref() should have unregistered us. @@ -199,13 +182,10 @@ GeomVertexArrayFormat:: } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// unregister the object when its reference count goes -// to zero. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to unregister the object when + * its reference count goes to zero. + */ bool GeomVertexArrayFormat:: unref() const { Registry *registry = get_registry(); @@ -222,18 +202,14 @@ unref() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::add_column -// Access: Published -// Description: Adds a new column to the specification. This is a -// table of per-vertex floating-point numbers such as -// "vertex" or "normal"; you must specify where in each -// record the table starts, and how many components -// (dimensions) exist per vertex. -// -// The return value is the index number of the new data -// type. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new column to the specification. This is a table of per-vertex + * floating-point numbers such as "vertex" or "normal"; you must specify where + * in each record the table starts, and how many components (dimensions) exist + * per vertex. + * + * The return value is the index number of the new data type. + */ int GeomVertexArrayFormat:: add_column(CPT_InternalName name, int num_components, GeomVertexArrayFormat::NumericType numeric_type, @@ -247,22 +223,17 @@ add_column(CPT_InternalName name, int num_components, start, column_alignment)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::add_column -// Access: Published -// Description: Adds a new column to the specification. This is a -// table of per-vertex floating-point numbers such as -// "vertex" or "normal"; you must specify where in each -// record the table starts, and how many components -// (dimensions) exist per vertex. -// -// Adding a column with the same name as a previous -// type, or that overlaps with one or more previous -// types, quietly removes the previous type(s). -// -// The return value is the index number of the new data -// type. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new column to the specification. This is a table of per-vertex + * floating-point numbers such as "vertex" or "normal"; you must specify where + * in each record the table starts, and how many components (dimensions) exist + * per vertex. + * + * Adding a column with the same name as a previous type, or that overlaps + * with one or more previous types, quietly removes the previous type(s). + * + * The return value is the index number of the new data type. + */ int GeomVertexArrayFormat:: add_column(const GeomVertexColumn &column) { nassertr(!_is_registered, -1); @@ -270,8 +241,7 @@ add_column(const GeomVertexColumn &column) { // Make sure there isn't already a column with this name. remove_column(column.get_name()); - // Also make sure there aren't any columns that overlap with this - // one. + // Also make sure there aren't any columns that overlap with this one. const GeomVertexColumn *orig_column = get_column(column.get_start(), column.get_total_bytes()); while (orig_column != (const GeomVertexColumn *)NULL) { remove_column(orig_column->get_name()); @@ -298,12 +268,10 @@ add_column(const GeomVertexColumn &column) { return new_index; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::remove_column -// Access: Published -// Description: Removes the column with the indicated name, if -// any. This leaves a gap in the byte structure. -//////////////////////////////////////////////////////////////////// +/** + * Removes the column with the indicated name, if any. This leaves a gap in + * the byte structure. + */ void GeomVertexArrayFormat:: remove_column(const InternalName *name) { nassertv(!_is_registered); @@ -320,8 +288,8 @@ remove_column(const InternalName *name) { delete column; - // Maybe we just removed the tail column. If that's so, we - // should recompute _total_bytes to reflect the new tail. + // Maybe we just removed the tail column. If that's so, we should + // recompute _total_bytes to reflect the new tail. if (_columns.empty()) { _total_bytes = 0; } else { @@ -332,12 +300,10 @@ remove_column(const InternalName *name) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::clear_columns -// Access: Published -// Description: Removes all columns previously added, sets the -// stride to zero, and prepares to start over. -//////////////////////////////////////////////////////////////////// +/** + * Removes all columns previously added, sets the stride to zero, and prepares + * to start over. + */ void GeomVertexArrayFormat:: clear_columns() { nassertv(!_is_registered); @@ -350,11 +316,9 @@ clear_columns() { _pad_to = 1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::pack_columns -// Access: Published -// Description: Removes wasted space between columns. -//////////////////////////////////////////////////////////////////// +/** + * Removes wasted space between columns. + */ void GeomVertexArrayFormat:: pack_columns() { nassertv(!_is_registered); @@ -371,18 +335,14 @@ pack_columns() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::align_columns_for_animation -// Access: Published -// Description: Reprocesses the columns in the format to align the -// C_point and C_vector columns to 16-byte boundaries to -// allow for the more efficient SSE2 operations -// (assuming SSE2 is enabled in the build). -// -// The caller is responsible for testing -// vertex_animation_align_16 to decide whether to call -// this method. -//////////////////////////////////////////////////////////////////// +/** + * Reprocesses the columns in the format to align the C_point and C_vector + * columns to 16-byte boundaries to allow for the more efficient SSE2 + * operations (assuming SSE2 is enabled in the build). + * + * The caller is responsible for testing vertex_animation_align_16 to decide + * whether to call this method. + */ void GeomVertexArrayFormat:: align_columns_for_animation() { nassertv(!_is_registered); @@ -409,12 +369,10 @@ align_columns_for_animation() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_column -// Access: Published -// Description: Returns the specification with the indicated name, or -// NULL if the name is not used. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specification with the indicated name, or NULL if the name is + * not used. + */ const GeomVertexColumn *GeomVertexArrayFormat:: get_column(const InternalName *name) const { ColumnsByName::const_iterator ni; @@ -425,13 +383,10 @@ get_column(const InternalName *name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_column -// Access: Published -// Description: Returns the first specification that overlaps with -// any of the indicated bytes in the range, or NULL if -// none do. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first specification that overlaps with any of the indicated + * bytes in the range, or NULL if none do. + */ const GeomVertexColumn *GeomVertexArrayFormat:: get_column(int start_byte, int num_bytes) const { consider_sort_columns(); @@ -446,16 +401,12 @@ get_column(int start_byte, int num_bytes) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::is_data_subset_of -// Access: Published -// Description: Returns true if all of the fields in this array -// format are also present and equivalent in the other -// array format, and in the same byte positions, and the -// stride is the same. That is, true if this format can -// share the same data pointer as the other format (with -// possibly some unused gaps). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the fields in this array format are also present and + * equivalent in the other array format, and in the same byte positions, and + * the stride is the same. That is, true if this format can share the same + * data pointer as the other format (with possibly some unused gaps). + */ bool GeomVertexArrayFormat:: is_data_subset_of(const GeomVertexArrayFormat &other) const { if (_columns.size() > other._columns.size() || @@ -478,12 +429,9 @@ is_data_subset_of(const GeomVertexArrayFormat &other) const { return (i == _columns.size()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::count_unused_space -// Access: Published -// Description: Returns the number of bytes per row that are not -// assigned to any column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes per row that are not assigned to any column. + */ int GeomVertexArrayFormat:: count_unused_space() const { consider_sort_columns(); @@ -507,11 +455,9 @@ count_unused_space() const { return unused_space; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayFormat:: output(ostream &out) const { Columns::const_iterator ci; @@ -533,11 +479,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayFormat:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -554,11 +498,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::write_with_data -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexArrayFormat:: write_with_data(ostream &out, int indent_level, const GeomVertexArrayData *array_data) const { @@ -588,15 +530,11 @@ write_with_data(ostream &out, int indent_level, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::get_format_string -// Access: Published -// Description: Returns a string with format codes representing the -// exact memory layout of the columns in memory, as -// understood by Python's struct module. -// If pad is true, extra padding bytes are added to -// the end as 'x' characters as needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string with format codes representing the exact memory layout of + * the columns in memory, as understood by Python's struct module. If pad is + * true, extra padding bytes are added to the end as 'x' characters as needed. + */ string GeomVertexArrayFormat:: get_format_string(bool pad) const { consider_sort_columns(); @@ -682,11 +620,9 @@ get_format_string(bool pad) const { return fmt_string; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexArrayFormat:: compare_to(const GeomVertexArrayFormat &other) const { if (_stride != other._stride) { @@ -716,23 +652,18 @@ compare_to(const GeomVertexArrayFormat &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::sort_columns -// Access: Private -// Description: Resorts the _columns vector so that the columns -// are listed in the same order they appear in the -// record. -//////////////////////////////////////////////////////////////////// +/** + * Resorts the _columns vector so that the columns are listed in the same + * order they appear in the record. + */ void GeomVertexArrayFormat:: sort_columns() { sort(_columns.begin(), _columns.end(), IndirectLess()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::make_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ void GeomVertexArrayFormat:: make_registry() { if (_registry == (Registry *)NULL) { @@ -740,45 +671,36 @@ make_registry() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::do_register -// Access: Private -// Description: Called internally when the format is registered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the format is registered. + */ void GeomVertexArrayFormat:: do_register() { nassertv(!_is_registered); _is_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::do_unregister -// Access: Private -// Description: Called internally when the format is unregistered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the format is unregistered. + */ void GeomVertexArrayFormat:: do_unregister() { nassertv(_is_registered); _is_registered = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// GeomVertexArrayFormat. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type GeomVertexArrayFormat. + */ void GeomVertexArrayFormat:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexArrayFormat:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); @@ -798,13 +720,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexArrayFormat:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -818,19 +737,17 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void GeomVertexArrayFormat:: finalize(BamReader *manager) { - // Now we can build up the _columns_by_name index. We have to wait - // until finalize(), since the index is based on the nested name - // pointer within each column, which might not be available at the - // time complete_pointers() is called. + // Now we can build up the _columns_by_name index. We have to wait until + // finalize(), since the index is based on the nested name pointer within + // each column, which might not be available at the time complete_pointers() + // is called. _columns_by_name.clear(); Columns::iterator ci; for (ci = _columns.begin(); ci != _columns.end(); ++ci) { @@ -839,15 +756,11 @@ finalize(BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type GeomVertexArrayFormat is -// encountered in the Bam file. It should create the -// GeomVertexArrayFormat and extract its information -// from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type GeomVertexArrayFormat is encountered in the Bam file. It should + * create the GeomVertexArrayFormat and extract its information from the file. + */ TypedWritable *GeomVertexArrayFormat:: make_from_bam(const FactoryParams ¶ms) { GeomVertexArrayFormat *object = new GeomVertexArrayFormat; @@ -861,13 +774,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexArrayFormat. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexArrayFormat. + */ void GeomVertexArrayFormat:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); @@ -892,39 +802,32 @@ fillin(DatagramIterator &scan, BamReader *manager) { _columns_unsorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Registry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexArrayFormat::Registry:: Registry() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Registry::register_format -// Access: Public -// Description: Adds the indicated format to the registry, if there -// is not an equivalent format already there; in either -// case, returns the pointer to the equivalent format -// now in the registry. -// -// This must be called before a format may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated format to the registry, if there is not an equivalent + * format already there; in either case, returns the pointer to the equivalent + * format now in the registry. + * + * This must be called before a format may be used in a Geom. After this + * call, you should discard the original pointer you passed in (which may or + * may not now be invalid) and let its reference count decrement normally; you + * should use only the returned value from this point on. + */ CPT(GeomVertexArrayFormat) GeomVertexArrayFormat::Registry:: register_format(GeomVertexArrayFormat *format) { if (format->is_registered()) { return format; } - // Save the incoming pointer in a local PointerTo, so that if it has - // a zero reference count and is not added into the map below, it - // will be automatically deleted when this function returns. + // Save the incoming pointer in a local PointerTo, so that if it has a zero + // reference count and is not added into the map below, it will be + // automatically deleted when this function returns. PT(GeomVertexArrayFormat) pt_format = format; GeomVertexArrayFormat *new_format; @@ -940,15 +843,12 @@ register_format(GeomVertexArrayFormat *format) { return new_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexArrayFormat::Registry::unregister_format -// Access: Public -// Description: Removes the indicated format from the registry. -// Normally this should not be done until the format is -// destructing. -// -// The lock should be held prior to calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated format from the registry. Normally this should not + * be done until the format is destructing. + * + * The lock should be held prior to calling this method. + */ void GeomVertexArrayFormat::Registry:: unregister_format(GeomVertexArrayFormat *format) { nassertv(format->is_registered()); diff --git a/panda/src/gobj/geomVertexArrayFormat.h b/panda/src/gobj/geomVertexArrayFormat.h index 29076c3ca8..6d252087f3 100644 --- a/panda/src/gobj/geomVertexArrayFormat.h +++ b/panda/src/gobj/geomVertexArrayFormat.h @@ -1,16 +1,15 @@ -// Filename: geomVertexArrayFormat.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexArrayFormat.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOMVERTEXARRAYFORMAT_H #define GEOMVERTEXARRAYFORMAT_H @@ -32,24 +31,19 @@ class FactoryParams; class BamWriter; class BamReader; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexArrayFormat -// Description : This describes the structure of a single array within -// a Geom data. See GeomVertexFormat for the parent -// class which collects together all of the individual -// GeomVertexArrayFormat objects. -// -// A particular array may include any number of standard -// or user-defined columns. All columns consist of a -// sequence of one or more numeric values, packed in any -// of a variety of formats; the semantic meaning of each -// column is defined in general with its contents -// member, and in particular by its name. The standard -// array types used most often are named "vertex", -// "normal", "texcoord", and "color"; other kinds of -// data may be piggybacked into the data record simply -// by choosing a unique name. -//////////////////////////////////////////////////////////////////// +/** + * This describes the structure of a single array within a Geom data. See + * GeomVertexFormat for the parent class which collects together all of the + * individual GeomVertexArrayFormat objects. + * + * A particular array may include any number of standard or user-defined + * columns. All columns consist of a sequence of one or more numeric values, + * packed in any of a variety of formats; the semantic meaning of each column + * is defined in general with its contents member, and in particular by its + * name. The standard array types used most often are named "vertex", + * "normal", "texcoord", and "color"; other kinds of data may be piggybacked + * into the data record simply by choosing a unique name. + */ class EXPCL_PANDA_GOBJ GeomVertexArrayFormat FINAL : public TypedWritableReferenceCount, public GeomEnums { PUBLISHED: GeomVertexArrayFormat(); diff --git a/panda/src/gobj/geomVertexColumn.I b/panda/src/gobj/geomVertexColumn.I index 50268cd3f2..4d6c5c3b68 100644 --- a/panda/src/gobj/geomVertexColumn.I +++ b/panda/src/gobj/geomVertexColumn.I @@ -1,35 +1,28 @@ -// Filename: geomVertexColumn.I -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexColumn.I + * @author drose + * @date 2005-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Default Constructor -// Access: Private -// Description: Creates an invalid column. Used only when constructing -// from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid column. Used only when constructing from a bam file. + */ INLINE GeomVertexColumn:: GeomVertexColumn() : _packer(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexColumn:: GeomVertexColumn(CPT_InternalName name, int num_components, NumericType numeric_type, Contents contents, @@ -48,11 +41,9 @@ GeomVertexColumn(CPT_InternalName name, int num_components, setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexColumn:: GeomVertexColumn(const GeomVertexColumn ©) : _name(copy._name), @@ -68,165 +59,126 @@ GeomVertexColumn(const GeomVertexColumn ©) : setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexColumn:: ~GeomVertexColumn() { delete _packer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_name -// Access: Published -// Description: Returns the name of this particular data field, -// e.g. "vertex" or "normal". The name may be a -// user-defined string, or it may be one of the standard -// system-defined field types. Only the system-defined -// field types are used for the actual rendering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this particular data field, e.g. "vertex" or "normal". + * The name may be a user-defined string, or it may be one of the standard + * system-defined field types. Only the system-defined field types are used + * for the actual rendering. + */ INLINE const InternalName *GeomVertexColumn:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_num_components -// Access: Published -// Description: Returns the number of components of the column: -// the number of instances of the NumericType in each -// element. This is usually, but not always, the same -// thing as get_num_values(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components of the column: the number of instances of + * the NumericType in each element. This is usually, but not always, the same + * thing as get_num_values(). + */ INLINE int GeomVertexColumn:: get_num_components() const { return _num_components; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_num_values -// Access: Published -// Description: Returns the number of numeric values of the column: -// the number of distinct numeric values that go into -// each element. This is usually, but not always, the -// same thing as get_num_components(); the difference is -// in the case of a composite numeric type like -// NT_packed_dcba, which has four numeric values per -// component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of numeric values of the column: the number of distinct + * numeric values that go into each element. This is usually, but not always, + * the same thing as get_num_components(); the difference is in the case of a + * composite numeric type like NT_packed_dcba, which has four numeric values + * per component. + */ INLINE int GeomVertexColumn:: get_num_values() const { return _num_values; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_num_elements -// Access: Published -// Description: Returns the number of times this column is repeated. -// This is usually 1, except for matrices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times this column is repeated. This is usually 1, + * except for matrices. + */ INLINE int GeomVertexColumn:: get_num_elements() const { return _num_elements; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_numeric_type -// Access: Published -// Description: Returns the token representing the numeric type of -// the data storage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the token representing the numeric type of the data storage. + */ INLINE GeomVertexColumn::NumericType GeomVertexColumn:: get_numeric_type() const { return _numeric_type; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_contents -// Access: Published -// Description: Returns the token representing the semantic meaning of -// the stored value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the token representing the semantic meaning of the stored value. + */ INLINE GeomVertexColumn::Contents GeomVertexColumn:: get_contents() const { return _contents; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_start -// Access: Published -// Description: Returns the byte within the array record at which -// this column starts. This can be set to non-zero -// to implement interleaved arrays. -//////////////////////////////////////////////////////////////////// +/** + * Returns the byte within the array record at which this column starts. This + * can be set to non-zero to implement interleaved arrays. + */ INLINE int GeomVertexColumn:: get_start() const { return _start; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_column_alignment -// Access: Published -// Description: Returns the alignment requirements for this column. -// If this is greater than 1, it restricts the column to -// appear only on memory addresses that are integer -// multiples of this value; this has implications for -// this column's start value, as well as the stride of -// the resulting array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alignment requirements for this column. If this is greater + * than 1, it restricts the column to appear only on memory addresses that are + * integer multiples of this value; this has implications for this column's + * start value, as well as the stride of the resulting array. + */ INLINE int GeomVertexColumn:: get_column_alignment() const { return _column_alignment; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_element_stride -// Access: Published -// Description: This value is only relevant for matrix types. -// Returns the number of bytes to add to access the -// next row of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * This value is only relevant for matrix types. Returns the number of bytes + * to add to access the next row of the matrix. + */ INLINE int GeomVertexColumn:: get_element_stride() const { return _element_stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_component_bytes -// Access: Published -// Description: Returns the number of bytes used by each component -// (that is, by one element of the numeric type). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by each component (that is, by one element + * of the numeric type). + */ INLINE int GeomVertexColumn:: get_component_bytes() const { return _component_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::get_total_bytes -// Access: Published -// Description: Returns the number of bytes used by each element of -// the column: component_bytes * num_components. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by each element of the column: + * component_bytes * num_components. + */ INLINE int GeomVertexColumn:: get_total_bytes() const { return _total_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::has_homogeneous_coord -// Access: Published -// Description: Returns true if this Contents type is one that -// includes a homogeneous coordinate in the fourth -// component, or false otherwise. If this is true, -// correct operation on the vertex data may require -// scaling by the homogeneous coordinate from time to -// time (but in general this is handled automatically if -// you use the 3-component or smaller forms of -// get_data() and set_data()). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this Contents type is one that includes a homogeneous + * coordinate in the fourth component, or false otherwise. If this is true, + * correct operation on the vertex data may require scaling by the homogeneous + * coordinate from time to time (but in general this is handled automatically + * if you use the 3-component or smaller forms of get_data() and set_data()). + */ INLINE bool GeomVertexColumn:: has_homogeneous_coord() const { switch (_contents) { @@ -239,42 +191,32 @@ has_homogeneous_coord() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::overlaps_with -// Access: Published -// Description: Returns true if this column overlaps with any of -// the bytes in the indicated range, false if it does -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this column overlaps with any of the bytes in the indicated + * range, false if it does not. + */ INLINE bool GeomVertexColumn:: overlaps_with(int start_byte, int num_bytes) const { return (_start < start_byte + num_bytes && _start + _total_bytes > start_byte); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::is_bytewise_equivalent -// Access: Published -// Description: Returns true if the data store of this column is -// exactly the same as that of the other, irrespective -// of name or start position within the record. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data store of this column is exactly the same as that + * of the other, irrespective of name or start position within the record. + */ INLINE bool GeomVertexColumn:: is_bytewise_equivalent(const GeomVertexColumn &other) const { - // Not sure if the contents are relevant, but let's say that they - // are. + // Not sure if the contents are relevant, but let's say that they are. return (_num_components == other._num_components && _numeric_type == other._numeric_type && _contents == other._contents); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::is_packed_argb -// Access: Public -// Description: Returns true if this column is the standard -// DirectX representation of 4-component color: C_color, -// in NT_packed_dabc, with 1 component (4 values). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this column is the standard DirectX representation of + * 4-component color: C_color, in NT_packed_dabc, with 1 component (4 values). + */ INLINE bool GeomVertexColumn:: is_packed_argb() const { return (_num_components == 1 && @@ -282,13 +224,10 @@ is_packed_argb() const { _contents == C_color); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::is_uint8_rgba -// Access: Public -// Description: Returns true if this column is the standard -// OpenGL representation of 4-component color: C_color, -// in NT_uint8, with 4 components. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this column is the standard OpenGL representation of + * 4-component color: C_color, in NT_uint8, with 4 components. + */ INLINE bool GeomVertexColumn:: is_uint8_rgba() const { return (_num_components == 4 && @@ -296,12 +235,10 @@ is_uint8_rgba() const { _contents == C_color); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::compare_to -// Access: Public -// Description: This is used to unquify columns, and hence -// formats, for the GeomVertexFormat registry. -//////////////////////////////////////////////////////////////////// +/** + * This is used to unquify columns, and hence formats, for the + * GeomVertexFormat registry. + */ INLINE int GeomVertexColumn:: compare_to(const GeomVertexColumn &other) const { if (_name != other._name) { @@ -331,35 +268,27 @@ compare_to(const GeomVertexColumn &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::operator == -// Access: Public -// Description: Returns true if the two columns are exactly -// equivalent, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two columns are exactly equivalent, false otherwise. + */ INLINE bool GeomVertexColumn:: operator == (const GeomVertexColumn &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexColumn:: operator != (const GeomVertexColumn &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::operator < -// Access: Public -// Description: This is used to put columns in order within a -// particular GeomVertexArrayFormat. Note that it is -// *not* in the same space as operator == and operator -// !=. -//////////////////////////////////////////////////////////////////// +/** + * This is used to put columns in order within a particular + * GeomVertexArrayFormat. Note that it is *not* in the same space as operator + * == and operator !=. + */ INLINE bool GeomVertexColumn:: operator < (const GeomVertexColumn &other) const { if (_start != other._start) { diff --git a/panda/src/gobj/geomVertexColumn.cxx b/panda/src/gobj/geomVertexColumn.cxx index fbec26d4d8..a49dda6274 100644 --- a/panda/src/gobj/geomVertexColumn.cxx +++ b/panda/src/gobj/geomVertexColumn.cxx @@ -1,27 +1,24 @@ -// Filename: geomVertexColumn.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexColumn.cxx + * @author drose + * @date 2005-03-06 + */ #include "geomVertexColumn.h" #include "geomVertexData.h" #include "bamReader.h" #include "bamWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn:: operator = (const GeomVertexColumn ©) { _name = copy._name; @@ -36,89 +33,69 @@ operator = (const GeomVertexColumn ©) { setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_name -// Access: Published -// Description: Replaces the name of an existing column. This is -// only legal on an unregistered format (i.e. when -// constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Replaces the name of an existing column. This is only legal on an + * unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_name(InternalName *name) { _name = name; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_num_components -// Access: Published -// Description: Changes the number of components of an existing -// column. This is only legal on an unregistered format -// (i.e. when constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of components of an existing column. This is only legal + * on an unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_num_components(int num_components) { _num_components = num_components; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_numeric_type -// Access: Published -// Description: Changes the numeric type an existing column. This is -// only legal on an unregistered format (i.e. when -// constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Changes the numeric type an existing column. This is only legal on an + * unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_numeric_type(NumericType numeric_type) { _numeric_type = numeric_type; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_contents -// Access: Published -// Description: Changes the semantic meaning of an existing column. -// This is only legal on an unregistered format -// (i.e. when constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Changes the semantic meaning of an existing column. This is only legal on + * an unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_contents(Contents contents) { _contents = contents; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_start -// Access: Published -// Description: Changes the start byte of an existing column. -// This is only legal on an unregistered format -// (i.e. when constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Changes the start byte of an existing column. This is only legal on an + * unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_start(int start) { _start = start; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::set_column_alignment -// Access: Published -// Description: Changes the column alignment of an existing column. -// This is only legal on an unregistered format -// (i.e. when constructing the format initially). -//////////////////////////////////////////////////////////////////// +/** + * Changes the column alignment of an existing column. This is only legal on + * an unregistered format (i.e. when constructing the format initially). + */ void GeomVertexColumn:: set_column_alignment(int column_alignment) { _column_alignment = column_alignment; setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn:: output(ostream &out) const { out << *get_name() << "(" << get_num_components(); @@ -167,12 +144,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::setup -// Access: Private -// Description: Called once at construction time (or at bam-reading -// time) to initialize the internal dependent values. -//////////////////////////////////////////////////////////////////// +/** + * Called once at construction time (or at bam-reading time) to initialize the + * internal dependent values. + */ void GeomVertexColumn:: setup() { nassertv(_num_components > 0 && _start >= 0); @@ -237,9 +212,8 @@ setup() { } if (_column_alignment < 1) { - // The default column alignment is to align to the individual - // numeric components, or to vertex_column_alignment, whichever is - // greater. + // The default column alignment is to align to the individual numeric + // components, or to vertex_column_alignment, whichever is greater. _column_alignment = max(_component_bytes, (int)vertex_column_alignment); } @@ -259,13 +233,10 @@ setup() { _packer->_column = this; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::make_packer -// Access: Private -// Description: Returns a newly-allocated Packer object suitable for -// packing and unpacking this column. The _column -// member of the packer is not filled in. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Packer object suitable for packing and unpacking + * this column. The _column member of the packer is not filled in. + */ GeomVertexColumn::Packer *GeomVertexColumn:: make_packer() const { switch (get_contents()) { @@ -276,8 +247,8 @@ make_packer() const { switch (get_numeric_type()) { case NT_float32: if (sizeof(float) == sizeof(PN_float32)) { - // Use the native float type implementation for a tiny bit - // more optimization. + // Use the native float type implementation for a tiny bit more + // optimization. switch (get_num_components()) { case 2: return new Packer_point_nativefloat_2; @@ -299,8 +270,8 @@ make_packer() const { break; case NT_float64: if (sizeof(double) == sizeof(PN_float64)) { - // Use the native float type implementation for a tiny bit - // more optimization. + // Use the native float type implementation for a tiny bit more + // optimization. switch (get_num_components()) { case 2: return new Packer_point_nativedouble_2; @@ -336,8 +307,8 @@ make_packer() const { case NT_float32: if (sizeof(float) == sizeof(PN_float32)) { - // Use the native float type implementation for a tiny bit - // more optimization. + // Use the native float type implementation for a tiny bit more + // optimization. return new Packer_rgba_nativefloat_4; } else { return new Packer_rgba_float32_4; @@ -365,8 +336,8 @@ make_packer() const { switch (get_num_components()) { case 3: if (sizeof(float) == sizeof(PN_float32)) { - // Use the native float type implementation for a tiny bit - // more optimization. + // Use the native float type implementation for a tiny bit more + // optimization. return new Packer_nativefloat_3; } else { return new Packer_float32_3; @@ -380,8 +351,8 @@ make_packer() const { switch (get_num_components()) { case 3: if (sizeof(double) == sizeof(PN_float64)) { - // Use the native float type implementation for a tiny bit - // more optimization. + // Use the native float type implementation for a tiny bit more + // optimization. return new Packer_nativedouble_3; } else { return new Packer_float64_3; @@ -398,12 +369,10 @@ make_packer() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexColumn:: write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _name); @@ -414,21 +383,18 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint8(_column_alignment); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::complete_pointers -// Access: Public -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexColumn:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = 0; _name = DCAST(InternalName, p_list[pi++]); - // Make sure that old .bam files are corrected to have C_normal - // normal columns rather than C_vector. + // Make sure that old .bam files are corrected to have C_normal normal + // columns rather than C_vector. if (manager->get_file_minor_ver() < 38 && _name == InternalName::get_normal() && _contents == C_vector) { _contents = C_normal; @@ -437,13 +403,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexColumn. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexColumn. + */ void GeomVertexColumn:: fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); @@ -464,20 +427,16 @@ fillin(DatagramIterator &scan, BamReader *manager) { setup(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexColumn::Packer:: ~Packer() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float GeomVertexColumn::Packer:: get_data1f(const unsigned char *pointer) { switch (_column->get_numeric_type()) { @@ -530,11 +489,9 @@ get_data1f(const unsigned char *pointer) { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2f &GeomVertexColumn::Packer:: get_data2f(const unsigned char *pointer) { if (_column->get_num_values() == 1) { @@ -628,11 +585,9 @@ get_data2f(const unsigned char *pointer) { return _v2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer:: get_data3f(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -741,11 +696,9 @@ get_data3f(const unsigned char *pointer) { return _v3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer:: get_data4f(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -858,11 +811,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double GeomVertexColumn::Packer:: get_data1d(const unsigned char *pointer) { switch (_column->get_numeric_type()) { @@ -916,11 +867,9 @@ get_data1d(const unsigned char *pointer) { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2d &GeomVertexColumn::Packer:: get_data2d(const unsigned char *pointer) { if (_column->get_num_values() == 1) { @@ -1014,11 +963,9 @@ get_data2d(const unsigned char *pointer) { return _v2d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer:: get_data3d(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -1127,11 +1074,9 @@ get_data3d(const unsigned char *pointer) { return _v3d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4d &GeomVertexColumn::Packer:: get_data4d(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -1244,11 +1189,9 @@ get_data4d(const unsigned char *pointer) { return _v4d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data1i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexColumn::Packer:: get_data1i(const unsigned char *pointer) { switch (_column->get_numeric_type()) { @@ -1302,11 +1245,9 @@ get_data1i(const unsigned char *pointer) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data2i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2i &GeomVertexColumn::Packer:: get_data2i(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -1398,11 +1339,9 @@ get_data2i(const unsigned char *pointer) { return _v2i; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data3i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3i &GeomVertexColumn::Packer:: get_data3i(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -1508,11 +1447,9 @@ get_data3i(const unsigned char *pointer) { return _v3i; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::get_data4i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4i &GeomVertexColumn::Packer:: get_data4i(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -1622,11 +1559,9 @@ get_data4i(const unsigned char *pointer) { return _v4i; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data1f(unsigned char *pointer, float data) { switch (_column->get_num_values()) { @@ -1693,11 +1628,9 @@ set_data1f(unsigned char *pointer, float data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data2f(unsigned char *pointer, const LVecBase2f &data) { switch (_column->get_num_values()) { @@ -1796,11 +1729,9 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data3f(unsigned char *pointer, const LVecBase3f &data) { switch (_column->get_num_values()) { @@ -1907,11 +1838,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { switch (_column->get_num_values()) { @@ -2029,11 +1958,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data1d(unsigned char *pointer, double data) { switch (_column->get_num_values()) { @@ -2100,11 +2027,9 @@ set_data1d(unsigned char *pointer, double data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data2d(unsigned char *pointer, const LVecBase2d &data) { switch (_column->get_num_values()) { @@ -2202,11 +2127,9 @@ set_data2d(unsigned char *pointer, const LVecBase2d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data3d(unsigned char *pointer, const LVecBase3d &data) { switch (_column->get_num_values()) { @@ -2313,11 +2236,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data4d(unsigned char *pointer, const LVecBase4d &data) { switch (_column->get_num_values()) { @@ -2435,11 +2356,9 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data1i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data1i(unsigned char *pointer, int data) { switch (_column->get_num_values()) { @@ -2510,11 +2429,9 @@ set_data1i(unsigned char *pointer, int data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data2i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data2i(unsigned char *pointer, const LVecBase2i &data) { switch (_column->get_num_values()) { @@ -2610,11 +2527,9 @@ set_data2i(unsigned char *pointer, const LVecBase2i &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data3i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data3i(unsigned char *pointer, const LVecBase3i &data) { switch (_column->get_num_values()) { @@ -2718,11 +2633,9 @@ set_data3i(unsigned char *pointer, const LVecBase3i &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer::set_data4i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer:: set_data4i(unsigned char *pointer, const LVecBase4i &data) { switch (_column->get_num_values()) { @@ -2837,11 +2750,9 @@ set_data4i(unsigned char *pointer, const LVecBase4i &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float GeomVertexColumn::Packer_point:: get_data1f(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -2852,11 +2763,9 @@ get_data1f(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2f &GeomVertexColumn::Packer_point:: get_data2f(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -2868,11 +2777,9 @@ get_data2f(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_point:: get_data3f(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -2884,11 +2791,9 @@ get_data3f(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_point:: get_data4f(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -3001,11 +2906,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double GeomVertexColumn::Packer_point:: get_data1d(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -3016,11 +2919,9 @@ get_data1d(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2d &GeomVertexColumn::Packer_point:: get_data2d(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -3032,11 +2933,9 @@ get_data2d(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_point:: get_data3d(const unsigned char *pointer) { if (_column->get_num_values() == 4) { @@ -3048,11 +2947,9 @@ get_data3d(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::get_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4d &GeomVertexColumn::Packer_point:: get_data4d(const unsigned char *pointer) { switch (_column->get_num_values()) { @@ -3165,11 +3062,9 @@ get_data4d(const unsigned char *pointer) { return _v4d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data1f(unsigned char *pointer, float data) { if (_column->get_num_values() == 4) { @@ -3179,11 +3074,9 @@ set_data1f(unsigned char *pointer, float data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data2f(unsigned char *pointer, const LVecBase2f &data) { if (_column->get_num_values() == 4) { @@ -3193,11 +3086,9 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data3f(unsigned char *pointer, const LVecBase3f &data) { if (_column->get_num_values() == 4) { @@ -3207,11 +3098,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { switch (_column->get_num_values()) { @@ -3329,11 +3218,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data1d(unsigned char *pointer, double data) { if (_column->get_num_values() == 4) { @@ -3343,11 +3230,9 @@ set_data1d(unsigned char *pointer, double data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data2d(unsigned char *pointer, const LVecBase2d &data) { if (_column->get_num_values() == 4) { @@ -3357,11 +3242,9 @@ set_data2d(unsigned char *pointer, const LVecBase2d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data3d(unsigned char *pointer, const LVecBase3d &data) { if (_column->get_num_values() == 4) { @@ -3371,11 +3254,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point::set_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point:: set_data4d(unsigned char *pointer, const LVecBase4d &data) { switch (_column->get_num_values()) { @@ -3493,11 +3374,9 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float GeomVertexColumn::Packer_color:: get_data1f(const unsigned char *pointer) { switch (_column->get_numeric_type()) { @@ -3535,11 +3414,9 @@ get_data1f(const unsigned char *pointer) { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2f &GeomVertexColumn::Packer_color:: get_data2f(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3553,11 +3430,9 @@ get_data2f(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_color:: get_data3f(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3630,11 +3505,9 @@ get_data3f(const unsigned char *pointer) { return _v3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_color:: get_data4f(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3716,11 +3589,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double GeomVertexColumn::Packer_color:: get_data1d(const unsigned char *pointer) { switch (_column->get_numeric_type()) { @@ -3758,11 +3629,9 @@ get_data1d(const unsigned char *pointer) { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2d &GeomVertexColumn::Packer_color:: get_data2d(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3776,11 +3645,9 @@ get_data2d(const unsigned char *pointer) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_color:: get_data3d(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3853,11 +3720,9 @@ get_data3d(const unsigned char *pointer) { return _v3d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::get_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4d &GeomVertexColumn::Packer_color:: get_data4d(const unsigned char *pointer) { if (_column->get_num_values() == 3) { @@ -3939,11 +3804,9 @@ get_data4d(const unsigned char *pointer) { return _v4d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data1f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data1f(unsigned char *pointer, float data) { if (_column->get_num_values() == 3) { @@ -3953,11 +3816,9 @@ set_data1f(unsigned char *pointer, float data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data2f(unsigned char *pointer, const LVecBase2f &data) { if (_column->get_num_values() == 3) { @@ -3967,11 +3828,9 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data3f(unsigned char *pointer, const LVecBase3f &data) { if (_column->get_num_values() == 3) { @@ -4056,11 +3915,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { if (_column->get_num_values() == 3) { @@ -4150,11 +4007,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data1d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data1d(unsigned char *pointer, double data) { if (_column->get_num_values() == 3) { @@ -4164,11 +4019,9 @@ set_data1d(unsigned char *pointer, double data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data2d(unsigned char *pointer, const LVecBase2d &data) { if (_column->get_num_values() == 3) { @@ -4178,11 +4031,9 @@ set_data2d(unsigned char *pointer, const LVecBase2d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data3d(unsigned char *pointer, const LVecBase3d &data) { if (_column->get_num_values() == 3) { @@ -4267,11 +4118,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_color::set_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_color:: set_data4d(unsigned char *pointer, const LVecBase4d &data) { if (_column->get_num_values() == 3) { @@ -4361,11 +4210,9 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_float32_3::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_float32_3:: get_data3f(const unsigned char *pointer) { const PN_float32 *pi = (const PN_float32 *)pointer; @@ -4373,11 +4220,9 @@ get_data3f(const unsigned char *pointer) { return _v3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_float32_3::set_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_float32_3:: set_data3f(unsigned char *pointer, const LVecBase3f &data) { PN_float32 *pi = (PN_float32 *)pointer; @@ -4386,11 +4231,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { pi[2] = data[2]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_2::get_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2f &GeomVertexColumn::Packer_point_float32_2:: get_data2f(const unsigned char *pointer) { const PN_float32 *pi = (const PN_float32 *)pointer; @@ -4398,11 +4241,9 @@ get_data2f(const unsigned char *pointer) { return _v2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_2::set_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float32_2:: set_data2f(unsigned char *pointer, const LVecBase2f &data) { PN_float32 *pi = (PN_float32 *)pointer; @@ -4410,11 +4251,9 @@ set_data2f(unsigned char *pointer, const LVecBase2f &data) { pi[1] = data[1]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_3::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_point_float32_3:: get_data3f(const unsigned char *pointer) { const PN_float32 *pi = (const PN_float32 *)pointer; @@ -4422,11 +4261,9 @@ get_data3f(const unsigned char *pointer) { return _v3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_3::set_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float32_3:: set_data3f(unsigned char *pointer, const LVecBase3f &data) { PN_float32 *pi = (PN_float32 *)pointer; @@ -4435,11 +4272,9 @@ set_data3f(unsigned char *pointer, const LVecBase3f &data) { pi[2] = data[2]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_4::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_point_float32_4:: get_data4f(const unsigned char *pointer) { const PN_float32 *pi = (const PN_float32 *)pointer; @@ -4447,11 +4282,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float32_4::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float32_4:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { PN_float32 *pi = (PN_float32 *)pointer; @@ -4461,51 +4294,41 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { pi[3] = data[3]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_nativefloat_3::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_nativefloat_3:: get_data3f(const unsigned char *pointer) { return *(const LVecBase3f *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativefloat_2::get_data2f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2f &GeomVertexColumn::Packer_point_nativefloat_2:: get_data2f(const unsigned char *pointer) { return *(const LVecBase2f *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativefloat_3::get_data3f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3f &GeomVertexColumn::Packer_point_nativefloat_3:: get_data3f(const unsigned char *pointer) { return *(const LVecBase3f *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativefloat_4::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_point_nativefloat_4:: get_data4f(const unsigned char *pointer) { return *(const LVecBase4f *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_float64_3::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_float64_3:: get_data3d(const unsigned char *pointer) { const PN_float64 *pi = (const PN_float64 *)pointer; @@ -4513,11 +4336,9 @@ get_data3d(const unsigned char *pointer) { return _v3d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_float64_3::set_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_float64_3:: set_data3d(unsigned char *pointer, const LVecBase3d &data) { PN_float64 *pi = (PN_float64 *)pointer; @@ -4526,11 +4347,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { pi[2] = data[2]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_2::get_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2d &GeomVertexColumn::Packer_point_float64_2:: get_data2d(const unsigned char *pointer) { const PN_float64 *pi = (const PN_float64 *)pointer; @@ -4538,11 +4357,9 @@ get_data2d(const unsigned char *pointer) { return _v2d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_2::set_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float64_2:: set_data2d(unsigned char *pointer, const LVecBase2d &data) { PN_float64 *pi = (PN_float64 *)pointer; @@ -4550,11 +4367,9 @@ set_data2d(unsigned char *pointer, const LVecBase2d &data) { pi[1] = data[1]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_3::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_point_float64_3:: get_data3d(const unsigned char *pointer) { const PN_float64 *pi = (const PN_float64 *)pointer; @@ -4562,11 +4377,9 @@ get_data3d(const unsigned char *pointer) { return _v3d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_3::set_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float64_3:: set_data3d(unsigned char *pointer, const LVecBase3d &data) { PN_float64 *pi = (PN_float64 *)pointer; @@ -4575,11 +4388,9 @@ set_data3d(unsigned char *pointer, const LVecBase3d &data) { pi[2] = data[2]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_4::get_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4d &GeomVertexColumn::Packer_point_float64_4:: get_data4d(const unsigned char *pointer) { const PN_float64 *pi = (const PN_float64 *)pointer; @@ -4587,11 +4398,9 @@ get_data4d(const unsigned char *pointer) { return _v4d; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_float64_4::set_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_point_float64_4:: set_data4d(unsigned char *pointer, const LVecBase4d &data) { PN_float64 *pi = (PN_float64 *)pointer; @@ -4601,51 +4410,41 @@ set_data4d(unsigned char *pointer, const LVecBase4d &data) { pi[3] = data[3]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_nativedouble_3::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_nativedouble_3:: get_data3d(const unsigned char *pointer) { return *(const LVecBase3d *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativedouble_2::get_data2d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2d &GeomVertexColumn::Packer_point_nativedouble_2:: get_data2d(const unsigned char *pointer) { return *(const LVecBase2d *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativedouble_3::get_data3d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3d &GeomVertexColumn::Packer_point_nativedouble_3:: get_data3d(const unsigned char *pointer) { return *(const LVecBase3d *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_point_nativedouble_4::get_data4d -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4d &GeomVertexColumn::Packer_point_nativedouble_4:: get_data4d(const unsigned char *pointer) { return *(const LVecBase4d *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_argb_packed::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_argb_packed:: get_data4f(const unsigned char *pointer) { PN_uint32 dword = *(const PN_uint32 *)pointer; @@ -4657,16 +4456,13 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_argb_packed::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_argb_packed:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { - // when packing an argb, we want to make sure we cap - // the input values at 1 since going above one will cause - // the value to be truncated. + // when packing an argb, we want to make sure we cap the input values at 1 + // since going above one will cause the value to be truncated. *(PN_uint32 *)pointer = GeomVertexData::pack_abcd ((unsigned int)(min(max(data[3], 0.0f), 1.0f) * 255.0f), (unsigned int)(min(max(data[0], 0.0f), 1.0f) * 255.0f), @@ -4674,11 +4470,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { (unsigned int)(min(max(data[2], 0.0f), 1.0f) * 255.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_rgba_uint8_4::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_rgba_uint8_4:: get_data4f(const unsigned char *pointer) { _v4.set((float)pointer[0], (float)pointer[1], @@ -4687,11 +4481,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_rgba_uint8_4::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_rgba_uint8_4:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { pointer[0] = (unsigned int)(min(max(data[0], 0.0f), 1.0f) * 255.0f); @@ -4700,11 +4492,9 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { pointer[3] = (unsigned int)(min(max(data[3], 0.0f), 1.0f) * 255.0f); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_rgba_float32_4::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_rgba_float32_4:: get_data4f(const unsigned char *pointer) { const PN_float32 *pi = (const PN_float32 *)pointer; @@ -4712,11 +4502,9 @@ get_data4f(const unsigned char *pointer) { return _v4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_rgba_float32_4::set_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_rgba_float32_4:: set_data4f(unsigned char *pointer, const LVecBase4f &data) { PN_float32 *pi = (PN_float32 *)pointer; @@ -4726,31 +4514,25 @@ set_data4f(unsigned char *pointer, const LVecBase4f &data) { pi[3] = data[3]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_rgba_nativefloat_4::get_data4f -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase4f &GeomVertexColumn::Packer_rgba_nativefloat_4:: get_data4f(const unsigned char *pointer) { return *(const LVecBase4f *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_uint16_1::get_data1i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexColumn::Packer_uint16_1:: get_data1i(const unsigned char *pointer) { return *(const PN_uint16 *)pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexColumn::Packer_uint16_1::set_data1i -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexColumn::Packer_uint16_1:: set_data1i(unsigned char *pointer, int data) { *(PN_uint16 *)pointer = data; diff --git a/panda/src/gobj/geomVertexColumn.h b/panda/src/gobj/geomVertexColumn.h index cd6f8b6efa..8fa91dadfe 100644 --- a/panda/src/gobj/geomVertexColumn.h +++ b/panda/src/gobj/geomVertexColumn.h @@ -1,16 +1,15 @@ -// Filename: geomVertexColumn.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexColumn.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOMVERTEXCOLUMN_H #define GEOMVERTEXCOLUMN_H @@ -30,13 +29,11 @@ class DatagramIterator; class GeomVertexReader; class GeomVertexWriter; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexColumn -// Description : This defines how a single column is interleaved -// within a vertex array stored within a Geom. The -// GeomVertexArrayFormat class maintains a list of these -// to completely define a particular array structure. -//////////////////////////////////////////////////////////////////// +/** + * This defines how a single column is interleaved within a vertex array + * stored within a Geom. The GeomVertexArrayFormat class maintains a list of + * these to completely define a particular array structure. + */ class EXPCL_PANDA_GOBJ GeomVertexColumn : public GeomEnums { private: INLINE GeomVertexColumn(); @@ -108,11 +105,10 @@ private: int _total_bytes; Packer *_packer; - // This nested class provides the implementation for packing and - // unpacking data in a very general way, but also provides the hooks - // for implementing the common, very direct code paths (for - // instance, 3-component float32 to LVecBase3f) as quickly as - // possible. + // This nested class provides the implementation for packing and unpacking + // data in a very general way, but also provides the hooks for implementing + // the common, very direct code paths (for instance, 3-component float32 to + // LVecBase3f) as quickly as possible. class Packer : public MemoryBase { public: virtual ~Packer(); @@ -165,11 +161,10 @@ private: }; - // This is a specialization on the generic Packer that handles - // points, which are special because the fourth component, if not - // present in the data, is implicitly 1.0; and if it is present, - // then any three-component or smaller return is implicitly divided - // by the fourth component. + // This is a specialization on the generic Packer that handles points, which + // are special because the fourth component, if not present in the data, is + // implicitly 1.0; and if it is present, then any three-component or smaller + // return is implicitly divided by the fourth component. class Packer_point : public Packer { public: virtual float get_data1f(const unsigned char *pointer); @@ -198,8 +193,8 @@ private: }; // This is similar to Packer_point, in that the fourth component is - // implicitly 1.0 if it is not present in the data, but we never - // divide by alpha. It also transforms integer colors to the 0-1 range. + // implicitly 1.0 if it is not present in the data, but we never divide by + // alpha. It also transforms integer colors to the 0-1 range. class Packer_color : public Packer { public: virtual float get_data1f(const unsigned char *pointer); @@ -228,8 +223,8 @@ private: }; - // These are the specializations on the generic Packer that handle - // the direct code paths. + // These are the specializations on the generic Packer that handle the + // direct code paths. class Packer_float32_3 : public Packer { public: diff --git a/panda/src/gobj/geomVertexData.I b/panda/src/gobj/geomVertexData.I index 908cb53118..0d32813912 100644 --- a/panda/src/gobj/geomVertexData.I +++ b/panda/src/gobj/geomVertexData.I @@ -1,82 +1,63 @@ -// Filename: geomVertexData.I -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexData.I + * @author drose + * @date 2005-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_name -// Access: Published -// Description: Returns the name passed to the constructor, if any. -// This name is reported on the PStats graph for vertex -// computations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name passed to the constructor, if any. This name is reported + * on the PStats graph for vertex computations. + */ INLINE const string &GeomVertexData:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_usage_hint -// Access: Published -// Description: Returns the usage hint that was passed to the -// constructor, and which will be passed to each array -// data object created initially, and arrays created as -// the result of a convert_to() operation. See -// geomEnums.h. -// -// However, each individual array may be replaced with a -// different array object with an independent usage hint -// specified, so there is no guarantee that the -// individual arrays all have the same usage_hint. -//////////////////////////////////////////////////////////////////// +/** + * Returns the usage hint that was passed to the constructor, and which will + * be passed to each array data object created initially, and arrays created + * as the result of a convert_to() operation. See geomEnums.h. + * + * However, each individual array may be replaced with a different array + * object with an independent usage hint specified, so there is no guarantee + * that the individual arrays all have the same usage_hint. + */ INLINE GeomVertexData::UsageHint GeomVertexData:: get_usage_hint() const { CDReader cdata(_cycler); return cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_format -// Access: Published -// Description: Returns a pointer to the GeomVertexFormat structure -// that defines this data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the GeomVertexFormat structure that defines this data. + */ INLINE const GeomVertexFormat *GeomVertexData:: get_format() const { CDReader cdata(_cycler); return cdata->_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::has_column -// Access: Published -// Description: Returns true if the data has the named column, -// false otherwise. This is really just a shortcut for -// asking the same thing from the format. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has the named column, false otherwise. This is + * really just a shortcut for asking the same thing from the format. + */ INLINE bool GeomVertexData:: has_column(const InternalName *name) const { CDReader cdata(_cycler); return cdata->_format->has_column(name); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_num_rows -// Access: Published -// Description: Returns the number of rows stored within all the -// arrays. All arrays store data for the same n -// rows. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows stored within all the arrays. All arrays store + * data for the same n rows. + */ INLINE int GeomVertexData:: get_num_rows() const { GeomVertexDataPipelineReader reader(this, Thread::get_current_thread()); @@ -84,29 +65,23 @@ get_num_rows() const { return reader.get_num_rows(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_num_rows -// Access: Published -// Description: Sets the length of the array to n rows in all of -// the various arrays (presumably by adding rows). -// -// The new vertex data is initialized to 0, except for -// the "color" column, which is initialized to (1, 1, 1, -// 1). -// -// The return value is true if the number of rows -// was changed, false if the object already contained n -// rows (or if there was some error). -// -// This can be used when you know exactly how many -// rows you will be needing. It is faster than -// reserve_num_rows(). Also see unclean_set_num_rows() -// if you are planning to fill in all the data yourself. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Sets the length of the array to n rows in all of the various arrays + * (presumably by adding rows). + * + * The new vertex data is initialized to 0, except for the "color" column, + * which is initialized to (1, 1, 1, 1). + * + * The return value is true if the number of rows was changed, false if the + * object already contained n rows (or if there was some error). + * + * This can be used when you know exactly how many rows you will be needing. + * It is faster than reserve_num_rows(). Also see unclean_set_num_rows() if + * you are planning to fill in all the data yourself. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE bool GeomVertexData:: set_num_rows(int n) { GeomVertexDataPipelineWriter writer(this, true, Thread::get_current_thread()); @@ -114,23 +89,18 @@ set_num_rows(int n) { return writer.set_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unclean_set_num_rows -// Access: Published -// Description: This method behaves like set_num_rows(), except the -// new data is not initialized. Furthermore, after this -// call, *any* of the data in the GeomVertexData may be -// uninitialized, including the earlier rows. -// -// This is intended for applications that are about to -// completely fill the GeomVertexData with new data -// anyway; it provides a tiny performance boost over -// set_num_rows(). -// -// This can be used when you know exactly how many -// rows you will be needing. It is faster than -// reserve_num_rows(). -//////////////////////////////////////////////////////////////////// +/** + * This method behaves like set_num_rows(), except the new data is not + * initialized. Furthermore, after this call, *any* of the data in the + * GeomVertexData may be uninitialized, including the earlier rows. + * + * This is intended for applications that are about to completely fill the + * GeomVertexData with new data anyway; it provides a tiny performance boost + * over set_num_rows(). + * + * This can be used when you know exactly how many rows you will be needing. + * It is faster than reserve_num_rows(). + */ INLINE bool GeomVertexData:: unclean_set_num_rows(int n) { GeomVertexDataPipelineWriter writer(this, true, Thread::get_current_thread()); @@ -138,20 +108,16 @@ unclean_set_num_rows(int n) { return writer.unclean_set_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::reserve_num_rows -// Access: Published -// Description: This ensures that enough memory space for n rows is -// allocated, so that you may increase the number of -// rows to n without causing a new memory allocation. -// This is a performance optimization only; it is -// especially useful when you know ahead of time that -// you will be adding n rows to the data. -// -// If you know exactly how many rows you will be -// needing, it is significantly faster to use -// set_num_rows() or unclean_set_num_rows() instead. -//////////////////////////////////////////////////////////////////// +/** + * This ensures that enough memory space for n rows is allocated, so that you + * may increase the number of rows to n without causing a new memory + * allocation. This is a performance optimization only; it is especially + * useful when you know ahead of time that you will be adding n rows to the + * data. + * + * If you know exactly how many rows you will be needing, it is significantly + * faster to use set_num_rows() or unclean_set_num_rows() instead. + */ INLINE bool GeomVertexData:: reserve_num_rows(int n) { GeomVertexDataPipelineWriter writer(this, true, Thread::get_current_thread()); @@ -159,26 +125,21 @@ reserve_num_rows(int n) { return writer.reserve_num_rows(n); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_num_arrays -// Access: Published -// Description: Returns the number of individual arrays stored within -// the data. This must match -// get_format()->get_num_arrays(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual arrays stored within the data. This must + * match get_format()->get_num_arrays(). + */ INLINE int GeomVertexData:: get_num_arrays() const { CDReader cdata(_cycler); return cdata->_arrays.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_array -// Access: Published -// Description: Returns a const pointer to the vertex data for the -// indicated array, for application code to directly -// examine (but not modify) the underlying vertex data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the vertex data for the indicated array, for + * application code to directly examine (but not modify) the underlying vertex + * data. + */ INLINE CPT(GeomVertexArrayData) GeomVertexData:: get_array(int i) const { CDReader cdata(_cycler); @@ -186,170 +147,132 @@ get_array(int i) const { return cdata->_arrays[i].get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::modify_array -// Access: Published -// Description: Returns a modifiable pointer to the indicated vertex -// array, so that application code may directly -// manipulate the data. You should avoid changing -// the length of this array, since all of the arrays -// should be kept in sync--use set_num_rows() -// instead. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the indicated vertex array, so that + * application code may directly manipulate the data. You should avoid + * changing the length of this array, since all of the arrays should be kept + * in sync--use set_num_rows() instead. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE PT(GeomVertexArrayData) GeomVertexData:: modify_array(int i) { GeomVertexDataPipelineWriter writer(this, true, Thread::get_current_thread()); return writer.modify_array(i); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_array -// Access: Published -// Description: Replaces the indicated vertex data array with -// a completely new array. You should be careful that -// the new array has the same length and format as the -// old one, unless you know what you are doing. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated vertex data array with a completely new array. You + * should be careful that the new array has the same length and format as the + * old one, unless you know what you are doing. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ INLINE void GeomVertexData:: set_array(int i, const GeomVertexArrayData *array) { GeomVertexDataPipelineWriter writer(this, true, Thread::get_current_thread()); writer.set_array(i, array); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_transform_table -// Access: Published -// Description: Returns a const pointer to the TransformTable -// assigned to this data. Vertices within the table -// will index into this table to indicate their -// dynamic skinning information; this table is used when -// the vertex animation is to be performed by the -// graphics hardware (but also see -// get_transform_blend_table()). -// -// This will return NULL if the vertex data does not -// have a TransformTable assigned (which implies the -// vertices will not be animated by the graphics -// hardware). -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the TransformTable assigned to this data. + * Vertices within the table will index into this table to indicate their + * dynamic skinning information; this table is used when the vertex animation + * is to be performed by the graphics hardware (but also see + * get_transform_blend_table()). + * + * This will return NULL if the vertex data does not have a TransformTable + * assigned (which implies the vertices will not be animated by the graphics + * hardware). + */ INLINE const TransformTable *GeomVertexData:: get_transform_table() const { CDReader cdata(_cycler); return cdata->_transform_table; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_transform_table -// Access: Published -// Description: Sets the TransformTable pointer to NULL, -// removing the table from the vertex data. This -// disables hardware-driven vertex animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the TransformTable pointer to NULL, removing the table from the vertex + * data. This disables hardware-driven vertex animation. + */ INLINE void GeomVertexData:: clear_transform_table() { set_transform_table(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_transform_blend_table -// Access: Published -// Description: Returns a const pointer to the TransformBlendTable -// assigned to this data. Vertices within the table -// will index into this table to indicate their -// dynamic skinning information; this table is used when -// the vertex animation is to be performed by the CPU -// (but also see get_transform_table()). -// -// This will return NULL if the vertex data does not -// have a TransformBlendTable assigned (which implies -// the vertices will not be animated by the CPU). -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the TransformBlendTable assigned to this data. + * Vertices within the table will index into this table to indicate their + * dynamic skinning information; this table is used when the vertex animation + * is to be performed by the CPU (but also see get_transform_table()). + * + * This will return NULL if the vertex data does not have a + * TransformBlendTable assigned (which implies the vertices will not be + * animated by the CPU). + */ INLINE CPT(TransformBlendTable) GeomVertexData:: get_transform_blend_table() const { CDReader cdata(_cycler); return cdata->_transform_blend_table.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_transform_blend_table -// Access: Published -// Description: Sets the TransformBlendTable pointer to NULL, -// removing the table from the vertex data. This -// disables CPU-driven vertex animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the TransformBlendTable pointer to NULL, removing the table from the + * vertex data. This disables CPU-driven vertex animation. + */ INLINE void GeomVertexData:: clear_transform_blend_table() { set_transform_blend_table(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_slider_table -// Access: Published -// Description: Returns a const pointer to the SliderTable -// assigned to this data. Vertices within the vertex -// data will look up their morph offsets, if any, within -// this table. -// -// This will return NULL if the vertex data does not -// have a SliderTable assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the SliderTable assigned to this data. Vertices + * within the vertex data will look up their morph offsets, if any, within + * this table. + * + * This will return NULL if the vertex data does not have a SliderTable + * assigned. + */ INLINE const SliderTable *GeomVertexData:: get_slider_table() const { CDReader cdata(_cycler); return cdata->_slider_table; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_slider_table -// Access: Published -// Description: Sets the SliderTable pointer to NULL, -// removing the table from the vertex data. This -// disables morph (blend shape) animation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the SliderTable pointer to NULL, removing the table from the vertex + * data. This disables morph (blend shape) animation. + */ INLINE void GeomVertexData:: clear_slider_table() { set_slider_table(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_num_bytes -// Access: Published -// Description: Returns the total number of bytes consumed by the -// different arrays of the vertex data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes consumed by the different arrays of the + * vertex data. + */ INLINE int GeomVertexData:: get_num_bytes() const { GeomVertexDataPipelineReader reader(this, Thread::get_current_thread()); return reader.get_num_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::get_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the vertex data is -// modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the vertex data is modified. + */ INLINE UpdateSeq GeomVertexData:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::pack_abcd -// Access: Public, Static -// Description: Packs four values in a DirectX-style NT_packed_abcd -// value. -//////////////////////////////////////////////////////////////////// +/** + * Packs four values in a DirectX-style NT_packed_abcd value. + */ INLINE PN_uint32 GeomVertexData:: pack_abcd(unsigned int a, unsigned int b, unsigned int c, unsigned int d) { @@ -359,59 +282,45 @@ pack_abcd(unsigned int a, unsigned int b, (d & 0xff)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_abcd_a -// Access: Public, Static -// Description: Returns the first packed value from a DirectX-style -// NT_packed_abcd. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first packed value from a DirectX-style NT_packed_abcd. + */ INLINE unsigned int GeomVertexData:: unpack_abcd_a(PN_uint32 data) { return (data >> 24) & 0xff; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_abcd_b -// Access: Public, Static -// Description: Returns the second packed value from a DirectX-style -// NT_packed_abcd. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second packed value from a DirectX-style NT_packed_abcd. + */ INLINE unsigned int GeomVertexData:: unpack_abcd_b(PN_uint32 data) { return (data >> 16) & 0xff; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_abcd_c -// Access: Public, Static -// Description: Returns the third packed value from a DirectX-style -// NT_packed_abcd. -//////////////////////////////////////////////////////////////////// +/** + * Returns the third packed value from a DirectX-style NT_packed_abcd. + */ INLINE unsigned int GeomVertexData:: unpack_abcd_c(PN_uint32 data) { return (data >> 8) & 0xff; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_abcd_d -// Access: Public, Static -// Description: Returns the fourth packed value from a DirectX-style -// NT_packed_abcd. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fourth packed value from a DirectX-style NT_packed_abcd. + */ INLINE unsigned int GeomVertexData:: unpack_abcd_d(PN_uint32 data) { return data & 0xff; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::pack_ufloat -// Access: Public, Static -// Description: Packs three float values in an unsigned 32-bit int. -//////////////////////////////////////////////////////////////////// +/** + * Packs three float values in an unsigned 32-bit int. + */ INLINE PN_uint32 GeomVertexData:: pack_ufloat(float a, float b, float c) { - // Since we have to clamp both low exponents and negative numbers to 0, - // it's easier to see a float as having a 9-bit signed exponent. + // Since we have to clamp both low exponents and negative numbers to 0, it's + // easier to see a float as having a 9-bit signed exponent. union { PN_int32 _packed; float _float; @@ -421,12 +330,10 @@ pack_ufloat(float a, float b, float c) { f1._float = b; f2._float = c; - // There are several cases here: - // 1. exponent 0xff: NaN or infinity (negative infinity excluded) - // 2. exponent too large: clamped to maximum value - // 3. normalized float - // 4. exponent 0: denormal float - // 5. zero or anything negative, clamped to 0 + // There are several cases here: 1. exponent 0xff: NaN or infinity (negative + // infinity excluded) 2. exponent too large: clamped to maximum value 3. + // normalized float 4. exponent 0: denormal float 5. zero or anything + // negative, clamped to 0 PN_uint32 packed = 0; @@ -463,11 +370,9 @@ pack_ufloat(float a, float b, float c) { return packed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_ufloat_a -// Access: Public, Static -// Description: Unpacks an unsigned float11 value from an uint32. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks an unsigned float11 value from an uint32. + */ INLINE float GeomVertexData:: unpack_ufloat_a(PN_uint32 data) { if ((data & 0x7c0) == 0) { @@ -482,7 +387,7 @@ unpack_ufloat_a(PN_uint32 data) { value._packed = ((data & 0x7ff) << 17); if ((data & 0x7c0) == 0x7c0) { - // Infinity / NaN + // Infinity NaN value._packed |= 0x7f800000; } else { value._packed += 0x38000000; @@ -491,11 +396,9 @@ unpack_ufloat_a(PN_uint32 data) { return value._float; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_ufloat_b -// Access: Public, Static -// Description: Unpacks an unsigned float11 value from an uint32. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks an unsigned float11 value from an uint32. + */ INLINE float GeomVertexData:: unpack_ufloat_b(PN_uint32 data) { if ((data & 0x3e0000) == 0) { @@ -510,7 +413,7 @@ unpack_ufloat_b(PN_uint32 data) { value._packed = ((data & 0x3ff800) << 6); if ((data & 0x3e0000) == 0x3e0000) { - // Infinity / NaN + // Infinity NaN value._packed |= 0x7f800000; } else { value._packed += 0x38000000; @@ -519,11 +422,9 @@ unpack_ufloat_b(PN_uint32 data) { return value._float; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unpack_ufloat_c -// Access: Public, Static -// Description: Unpacks an unsigned float10 value from an uint32. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks an unsigned float10 value from an uint32. + */ INLINE float GeomVertexData:: unpack_ufloat_c(PN_uint32 data) { if ((data & 0xf8000000u) == 0) { @@ -538,7 +439,7 @@ unpack_ufloat_c(PN_uint32 data) { value._packed = ((data & 0xffc00000u) >> 4); if ((data & 0xf8000000u) == 0xf8000000u) { - // Infinity / NaN + // Infinity NaN value._packed |= 0x7f800000; } else { value._packed += 0x38000000; @@ -547,12 +448,10 @@ unpack_ufloat_c(PN_uint32 data) { return value._float; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::add_transform -// Access: Private, Static -// Description: Adds the indicated transform to the table, if it is -// not already there, and returns its index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated transform to the table, if it is not already there, and + * returns its index number. + */ INLINE int GeomVertexData:: add_transform(TransformTable *table, const VertexTransform *transform, TransformMap &already_added) { @@ -565,42 +464,34 @@ add_transform(TransformTable *table, const VertexTransform *transform, return (*(result.first)).second; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CDataCache::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CDataCache:: CDataCache() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CDataCache::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CDataCache:: CDataCache(const GeomVertexData::CDataCache ©) : _result(copy._result) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheKey::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheKey:: CacheKey(const GeomVertexFormat *modifier) : _modifier(modifier) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheKey::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheKey:: CacheKey(const CacheKey ©) : _modifier(copy._modifier) @@ -608,11 +499,9 @@ CacheKey(const CacheKey ©) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheKey::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheKey:: CacheKey(CacheKey &&from) NOEXCEPT : _modifier(move(from._modifier)) @@ -620,21 +509,17 @@ CacheKey(CacheKey &&from) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheKey::operator < -// Access: Public -// Description: Provides a unique ordering within the set. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique ordering within the set. + */ INLINE bool GeomVertexData::CacheKey:: operator < (const CacheKey &other) const { return _modifier < other._modifier; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheEntry:: CacheEntry(GeomVertexData *source, const GeomVertexFormat *modifier) : _source(source), @@ -642,11 +527,9 @@ CacheEntry(GeomVertexData *source, const GeomVertexFormat *modifier) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheEntry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheEntry:: CacheEntry(GeomVertexData *source, const CacheKey &key) : _source(source), @@ -655,11 +538,9 @@ CacheEntry(GeomVertexData *source, const CacheKey &key) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheEntry::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CacheEntry:: CacheEntry(GeomVertexData *source, CacheKey &&key) NOEXCEPT : _source(source), @@ -668,22 +549,18 @@ CacheEntry(GeomVertexData *source, CacheKey &&key) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CData:: CData() : _usage_hint(UH_unspecified) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData::CData:: CData(const GeomVertexData::CData ©) : _usage_hint(copy._usage_hint), @@ -698,11 +575,9 @@ CData(const GeomVertexData::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineBase:: GeomVertexDataPipelineBase(GeomVertexData *object, Thread *current_thread, @@ -719,11 +594,9 @@ GeomVertexDataPipelineBase(GeomVertexData *object, #endif // DO_PIPELINING } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineBase:: ~GeomVertexDataPipelineBase() { #ifdef _DEBUG @@ -740,112 +613,90 @@ INLINE GeomVertexDataPipelineBase:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *GeomVertexDataPipelineBase:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_usage_hint -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineBase::UsageHint GeomVertexDataPipelineBase:: get_usage_hint() const { return _cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_format -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexFormat *GeomVertexDataPipelineBase:: get_format() const { return _cdata->_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::has_column -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexDataPipelineBase:: has_column(const InternalName *name) const { return _cdata->_format->has_column(name); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_num_arrays -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int GeomVertexDataPipelineBase:: get_num_arrays() const { return _cdata->_arrays.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_array -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(GeomVertexArrayData) GeomVertexDataPipelineBase:: get_array(int i) const { nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), NULL); return _cdata->_arrays[i].get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_transform_table -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const TransformTable *GeomVertexDataPipelineBase:: get_transform_table() const { return _cdata->_transform_table; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_transform_blend_table -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT(TransformBlendTable) GeomVertexDataPipelineBase:: get_transform_blend_table() const { return _cdata->_transform_blend_table.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_slider_table -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const SliderTable *GeomVertexDataPipelineBase:: get_slider_table() const { return _cdata->_slider_table; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq GeomVertexDataPipelineBase:: get_modified() const { return _cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineReader:: GeomVertexDataPipelineReader(const GeomVertexData *object, Thread *current_thread) : @@ -855,11 +706,9 @@ GeomVertexDataPipelineReader(const GeomVertexData *object, { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE GeomVertexDataPipelineReader:: GeomVertexDataPipelineReader(const GeomVertexDataPipelineReader ©) : GeomVertexDataPipelineBase(copy) @@ -867,44 +716,36 @@ GeomVertexDataPipelineReader(const GeomVertexDataPipelineReader ©) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void GeomVertexDataPipelineReader:: operator = (const GeomVertexDataPipelineReader &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineReader:: ~GeomVertexDataPipelineReader() { if (_got_array_readers) { delete_array_readers(); } - // _object->_cycler.release_read(_cdata); + // _object->_cycler.release_read(_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexData *GeomVertexDataPipelineReader:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::check_array_readers -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexDataPipelineReader:: check_array_readers() const { if (!_got_array_readers) { @@ -912,11 +753,9 @@ check_array_readers() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_array_reader -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const GeomVertexArrayDataHandle *GeomVertexDataPipelineReader:: get_array_reader(int i) const { nassertr(_got_array_readers, NULL); @@ -924,21 +763,17 @@ get_array_reader(int i) const { return _array_readers[i]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::has_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexDataPipelineReader:: has_vertex() const { return (_cdata->_format->get_vertex_column() != (GeomVertexColumn *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::is_vertex_transformed -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexDataPipelineReader:: is_vertex_transformed() const { const GeomVertexColumn *column = _cdata->_format->get_vertex_column(); @@ -949,31 +784,25 @@ is_vertex_transformed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::has_normal -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexDataPipelineReader:: has_normal() const { return (_cdata->_format->get_normal_column() != (GeomVertexColumn *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::has_color -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomVertexDataPipelineReader:: has_color() const { return (_cdata->_format->get_color_column() != (GeomVertexColumn *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineWriter:: GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0, Thread *current_thread) : @@ -990,11 +819,9 @@ GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0, #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::Copy Constructor -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE GeomVertexDataPipelineWriter:: GeomVertexDataPipelineWriter(const GeomVertexDataPipelineWriter ©) : GeomVertexDataPipelineBase(copy) @@ -1002,21 +829,17 @@ GeomVertexDataPipelineWriter(const GeomVertexDataPipelineWriter ©) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::Copy Assignment Operator -// Access: Private -// Description: Don't attempt to copy these objects. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy these objects. + */ INLINE void GeomVertexDataPipelineWriter:: operator = (const GeomVertexDataPipelineWriter &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexDataPipelineWriter:: ~GeomVertexDataPipelineWriter() { if (_got_array_writers) { @@ -1025,21 +848,17 @@ INLINE GeomVertexDataPipelineWriter:: _object->_cycler.release_write(_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::get_object -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexData *GeomVertexDataPipelineWriter:: get_object() const { return _object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::check_array_writers -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexDataPipelineWriter:: check_array_writers() const { if (!_got_array_writers) { @@ -1047,11 +866,9 @@ check_array_writers() const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::get_array_writer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexArrayDataHandle *GeomVertexDataPipelineWriter:: get_array_writer(int i) const { nassertr(_got_array_writers, NULL); diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 25ff1d463b..9b1aa50d84 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1,16 +1,15 @@ -// Filename: geomVertexData.cxx -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexData.cxx + * @author drose + * @date 2005-03-06 + */ #include "geomVertexData.h" #include "geom.h" @@ -36,12 +35,10 @@ PStatCollector GeomVertexData::_set_color_pcollector("*:Munge:Set color"); PStatCollector GeomVertexData::_animation_pcollector("*:Animation"); -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Default Constructor -// Access: Private -// Description: Constructs an invalid object. This is only used when -// reading from the bam file. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid object. This is only used when reading from the bam + * file. + */ GeomVertexData:: GeomVertexData() : _char_pcollector(_animation_pcollector, "unnamed"), @@ -51,21 +48,17 @@ GeomVertexData() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) GeomVertexData:: make_cow_copy() { return new GeomVertexData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexData:: GeomVertexData(const string &name, const GeomVertexFormat *format, @@ -78,8 +71,8 @@ GeomVertexData(const string &name, { nassertv(format->is_registered()); - // Create some empty arrays as required by the format. - // Let's ensure the vertex data gets set on all stages at once. + // Create some empty arrays as required by the format. Let's ensure the + // vertex data gets set on all stages at once. OPEN_ITERATE_ALL_STAGES(_cycler) { CDStageWriter cdata(_cycler, pipeline_stage); cdata->_format = format; @@ -94,11 +87,9 @@ GeomVertexData(const string &name, CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexData:: GeomVertexData(const GeomVertexData ©) : CopyOnWriteObject(copy), @@ -118,14 +109,11 @@ GeomVertexData(const GeomVertexData ©) : CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Constructor -// Access: Published -// Description: This constructor copies all of the basic properties -// of the source VertexData, like usage_hint and -// animation tables, but does not copy the actual data, -// and it allows you to specify a different format. -//////////////////////////////////////////////////////////////////// +/** + * This constructor copies all of the basic properties of the source + * VertexData, like usage_hint and animation tables, but does not copy the + * actual data, and it allows you to specify a different format. + */ GeomVertexData:: GeomVertexData(const GeomVertexData ©, const GeomVertexFormat *format) : @@ -160,14 +148,11 @@ GeomVertexData(const GeomVertexData ©, CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Copy Assignment Operator -// Access: Published -// Description: The copy assignment operator is not pipeline-safe. -// This will completely obliterate all stages of the -// pipeline, so don't do it for a GeomVertexData that is -// actively being used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * The copy assignment operator is not pipeline-safe. This will completely + * obliterate all stages of the pipeline, so don't do it for a GeomVertexData + * that is actively being used for rendering. + */ void GeomVertexData:: operator = (const GeomVertexData ©) { CopyOnWriteObject::operator = (copy); @@ -190,22 +175,18 @@ operator = (const GeomVertexData ©) { CLOSE_ITERATE_ALL_STAGES(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexData:: ~GeomVertexData() { clear_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::compare_to -// Access: Published -// Description: Returns 0 if the two objects are equivalent, even if -// they are not the same pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns 0 if the two objects are equivalent, even if they are not the same + * pointer. + */ int GeomVertexData:: compare_to(const GeomVertexData &other) const { CDReader cdata(_cycler); @@ -238,12 +219,10 @@ compare_to(const GeomVertexData &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_name -// Access: Published -// Description: Changes the name of the vertex data. This name is -// reported on the PStats graph for vertex computations. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the vertex data. This name is reported on the PStats + * graph for vertex computations. + */ void GeomVertexData:: set_name(const string &name) { _name = name; @@ -253,17 +232,13 @@ set_name(const string &name) { _blends_pcollector = PStatCollector(_char_pcollector, "Calc blends"); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_usage_hint -// Access: Published -// Description: Changes the UsageHint hint for this vertex data, and -// for all of the arrays that share this data. See -// get_usage_hint(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the UsageHint hint for this vertex data, and for all of the arrays + * that share this data. See get_usage_hint(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: set_usage_hint(GeomVertexData::UsageHint usage_hint) { CDWriter cdata(_cycler, true); @@ -281,17 +256,13 @@ set_usage_hint(GeomVertexData::UsageHint usage_hint) { cdata->_animated_vertices_modified = UpdateSeq(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_format -// Access: Published -// Description: Changes the format of the vertex data. If the data -// is not empty, this will implicitly change every row -// to match the new format. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Changes the format of the vertex data. If the data is not empty, this will + * implicitly change every row to match the new format. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: set_format(const GeomVertexFormat *format) { Thread *current_thread = Thread::get_current_thread(); @@ -309,8 +280,8 @@ set_format(const GeomVertexFormat *format) { // Put the current data aside, so we can copy it back in below. CPT(GeomVertexData) orig_data = new GeomVertexData(*this); - // Assign the new format. This means clearing out all of our - // current arrays and replacing them with new, empty arrays. + // Assign the new format. This means clearing out all of our current arrays + // and replacing them with new, empty arrays. cdataw->_format = format; UsageHint usage_hint = cdataw->_usage_hint; @@ -322,8 +293,8 @@ set_format(const GeomVertexFormat *format) { cdataw->_arrays.push_back(array.p()); } - // Now copy the original data back in. This will automatically - // convert it to the new format. + // Now copy the original data back in. This will automatically convert it + // to the new format. copy_from(orig_data, false, current_thread); clear_cache_stage(); @@ -331,19 +302,14 @@ set_format(const GeomVertexFormat *format) { cdataw->_animated_vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::unclean_set_format -// Access: Published -// Description: Changes the format of the vertex data, without -// reformatting the data to match. The data is exactly -// the same after this operation, but will be -// reinterpreted according to the new format. This -// assumes that the new format is fundamentally -// compatible with the old format; in particular, it -// must have the same number of arrays with the same -// stride in each one. No checking is performed that -// the data remains sensible. -//////////////////////////////////////////////////////////////////// +/** + * Changes the format of the vertex data, without reformatting the data to + * match. The data is exactly the same after this operation, but will be + * reinterpreted according to the new format. This assumes that the new + * format is fundamentally compatible with the old format; in particular, it + * must have the same number of arrays with the same stride in each one. No + * checking is performed that the data remains sensible. + */ void GeomVertexData:: unclean_set_format(const GeomVertexFormat *format) { Thread *current_thread = Thread::get_current_thread(); @@ -379,17 +345,13 @@ unclean_set_format(const GeomVertexFormat *format) { cdataw->_animated_vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_rows -// Access: Published -// Description: Removes all of the rows from the arrays; -// functionally equivalent to set_num_rows(0) (but -// faster). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the rows from the arrays; functionally equivalent to + * set_num_rows(0) (but faster). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: clear_rows() { Thread *current_thread = Thread::get_current_thread(); @@ -408,19 +370,14 @@ clear_rows() { cdata->_animated_vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_transform_table -// Access: Published -// Description: Replaces the TransformTable on this vertex -// data with the indicated table. The length of this -// table should be consistent with the maximum table -// index assigned to the vertices under the -// "transform_index" name. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the TransformTable on this vertex data with the indicated table. + * The length of this table should be consistent with the maximum table index + * assigned to the vertices under the "transform_index" name. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: set_transform_table(const TransformTable *table) { Thread *current_thread = Thread::get_current_thread(); @@ -433,18 +390,14 @@ set_transform_table(const TransformTable *table) { cdata->_animated_vertices_modified = UpdateSeq(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::modify_transform_blend_table -// Access: Published -// Description: Returns a modifiable pointer to the current -// TransformBlendTable on this vertex data, if any, or -// NULL if there is not a TransformBlendTable. See -// get_transform_blend_table(). -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the current TransformBlendTable on this + * vertex data, if any, or NULL if there is not a TransformBlendTable. See + * get_transform_blend_table(). + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ PT(TransformBlendTable) GeomVertexData:: modify_transform_blend_table() { CDWriter cdata(_cycler, true); @@ -456,19 +409,14 @@ modify_transform_blend_table() { return cdata->_transform_blend_table.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_transform_blend_table -// Access: Published -// Description: Replaces the TransformBlendTable on this vertex -// data with the indicated table. The length of this -// table should be consistent with the maximum table -// index assigned to the vertices under the -// "transform_blend" name. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the TransformBlendTable on this vertex data with the indicated + * table. The length of this table should be consistent with the maximum + * table index assigned to the vertices under the "transform_blend" name. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: set_transform_blend_table(const TransformBlendTable *table) { CDWriter cdata(_cycler, true); @@ -478,21 +426,17 @@ set_transform_blend_table(const TransformBlendTable *table) { cdata->_animated_vertices_modified = UpdateSeq(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_slider_table -// Access: Published -// Description: Replaces the SliderTable on this vertex -// data with the indicated table. There should be an -// entry in this table for each kind of morph offset -// defined in the vertex data. -// -// The SliderTable object must have been registered -// prior to setting it on the GeomVertexData. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the SliderTable on this vertex data with the indicated table. + * There should be an entry in this table for each kind of morph offset + * defined in the vertex data. + * + * The SliderTable object must have been registered prior to setting it on the + * GeomVertexData. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: set_slider_table(const SliderTable *table) { nassertv(table == (SliderTable *)NULL || table->is_registered()); @@ -504,13 +448,11 @@ set_slider_table(const SliderTable *table) { cdata->_animated_vertices_modified = UpdateSeq(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::request_resident -// Access: Published -// Description: Returns true if the vertex data is currently resident -// in memory. If this returns false, the vertex data will -// be brought back into memory shortly; try again later. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex data is currently resident in memory. If this + * returns false, the vertex data will be brought back into memory shortly; + * try again later. + */ bool GeomVertexData:: request_resident() const { CDReader cdata(_cycler); @@ -529,26 +471,20 @@ request_resident() const { return resident; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::copy_from -// Access: Published -// Description: Copies all the data from the other array into the -// corresponding data types in this array, by matching -// data types name-by-name. -// -// keep_data_objects specifies what to do when one or -// more of the arrays can be copied without the need to -// apply any conversion operation. If it is true, the -// original GeomVertexArrayData objects in this object -// are retained, and their data arrays are copied -// byte-by-byte from the source; if it is false, then the -// GeomVertexArrayData objects are copied pointerwise -// from the source. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Copies all the data from the other array into the corresponding data types + * in this array, by matching data types name-by-name. + * + * keep_data_objects specifies what to do when one or more of the arrays can + * be copied without the need to apply any conversion operation. If it is + * true, the original GeomVertexArrayData objects in this object are retained, + * and their data arrays are copied byte-by-byte from the source; if it is + * false, then the GeomVertexArrayData objects are copied pointerwise from the + * source. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: copy_from(const GeomVertexData *source, bool keep_data_objects, Thread *current_thread) { @@ -559,8 +495,8 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, int num_arrays = source_format->get_num_arrays(); int source_i; - // First, check to see if any arrays can be simply appropriated for - // the new format, without changing the data. + // First, check to see if any arrays can be simply appropriated for the new + // format, without changing the data. pset done_arrays; for (source_i = 0; source_i < num_arrays; ++source_i) { @@ -645,8 +581,7 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, } else if (dest_column->is_uint8_rgba() && source_column->is_packed_argb()) { - // Another common special case: DirectX color to OpenGL - // color. + // Another common special case: DirectX color to OpenGL color. PT(GeomVertexArrayData) dest_array_obj = modify_array(dest_i); PT(GeomVertexArrayDataHandle) dest_handle = dest_array_obj->modify_handle(); unsigned char *dest_array_data = dest_handle->get_write_pointer(); @@ -682,16 +617,16 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, const GeomVertexAnimationSpec &dest_animation = dest_format->get_animation(); if (source_animation != dest_animation) { if (dest_animation.get_animation_type() == AT_hardware) { - // Convert Panda-style animation tables to hardware-style - // animation tables. + // Convert Panda-style animation tables to hardware-style animation + // tables. CPT(TransformBlendTable) blend_table = source->get_transform_blend_table(); if (blend_table != (TransformBlendTable *)NULL) { PT(TransformTable) transform_table = new TransformTable; TransformMap already_added; if (dest_animation.get_indexed_transforms()) { - // Build an indexed transform array. This is easier; this - // means we can put the blends in any order. + // Build an indexed transform array. This is easier; this means we + // can put the blends in any order. GeomVertexWriter weight(this, InternalName::get_transform_weight()); GeomVertexWriter index(this, InternalName::get_transform_index()); GeomVertexReader from(source, InternalName::get_transform_blend()); @@ -713,8 +648,8 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, index.set_data4i(indices); } } else { - // Build a nonindexed transform array. This means we have to - // use the same n transforms, in the same order, for each vertex. + // Build a nonindexed transform array. This means we have to use + // the same n transforms, in the same order, for each vertex. GeomVertexWriter weight(this, InternalName::get_transform_weight()); GeomVertexReader from(source, InternalName::get_transform_blend()); @@ -741,18 +676,14 @@ copy_from(const GeomVertexData *source, bool keep_data_objects, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::copy_row_from -// Access: Published -// Description: Copies a single row of the data from the other array -// into the indicated row of this array. In this case, -// the source format must exactly match the destination -// format. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Copies a single row of the data from the other array into the indicated row + * of this array. In this case, the source format must exactly match the + * destination format. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: copy_row_from(int dest_row, const GeomVertexData *source, int source_row, Thread *current_thread) { @@ -786,13 +717,10 @@ copy_row_from(int dest_row, const GeomVertexData *source, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::convert_to -// Access: Published -// Description: Returns a new GeomVertexData that represents the same -// contents as this one, with all data types matched up -// name-by-name to the indicated new format. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData that represents the same contents as this one, + * with all data types matched up name-by-name to the indicated new format. + */ CPT(GeomVertexData) GeomVertexData:: convert_to(const GeomVertexFormat *new_format) const { Thread *current_thread = Thread::get_current_thread(); @@ -802,8 +730,7 @@ convert_to(const GeomVertexFormat *new_format) const { return this; } - // Look up the new format in our cache--maybe we've recently applied - // it. + // Look up the new format in our cache--maybe we've recently applied it. PT(CacheEntry) entry; CacheKey key(new_format); @@ -818,9 +745,8 @@ convert_to(const GeomVertexFormat *new_format) const { _cache_lock.release(); nassertr(entry->_source == this, NULL); - // Here's an element in the cache for this computation. Record a - // cache hit, so this element will stay in the cache a while - // longer. + // Here's an element in the cache for this computation. Record a cache + // hit, so this element will stay in the cache a while longer. entry->refresh(current_thread); CDCacheReader cdata(entry->_cycler); @@ -828,10 +754,10 @@ convert_to(const GeomVertexFormat *new_format) const { return cdata->_result; } - // The cache entry is stale, but we'll recompute it below. Note - // that there's a small race condition here; another thread might - // recompute the cache at the same time. No big deal, since it'll - // compute the same result. + // The cache entry is stale, but we'll recompute it below. Note that + // there's a small race condition here; another thread might recompute the + // cache at the same time. No big deal, since it'll compute the same + // result. } // Okay, convert the data to the new format. @@ -862,15 +788,13 @@ convert_to(const GeomVertexFormat *new_format) const { LightMutexHolder holder(_cache_lock); bool inserted = ((GeomVertexData *)this)->_cache.insert(Cache::value_type(&entry->_key, entry)).second; if (!inserted) { - // Some other thread must have beat us to the punch. Never - // mind. + // Some other thread must have beat us to the punch. Never mind. return new_data; } } - // And tell the cache manager about the new entry. (It might - // immediately request a delete from the cache of the thing we - // just added.) + // And tell the cache manager about the new entry. (It might immediately + // request a delete from the cache of the thing we just added.) entry->record(current_thread); } @@ -881,15 +805,13 @@ convert_to(const GeomVertexFormat *new_format) const { return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::scale_color -// Access: Published -// Description: Returns a new GeomVertexData object with the color -// table modified in-place to apply the indicated scale. -// -// If the vertex data does not include a color column, a -// new one will not be added. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object with the color table modified in-place + * to apply the indicated scale. + * + * If the vertex data does not include a color column, a new one will not be + * added. + */ CPT(GeomVertexData) GeomVertexData:: scale_color(const LVecBase4 &color_scale) const { const GeomVertexColumn *old_column = @@ -911,16 +833,12 @@ scale_color(const LVecBase4 &color_scale) const { return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::scale_color -// Access: Published -// Description: Returns a new GeomVertexData object with the color -// table replaced with a new color table that has been -// scaled by the indicated value. The new color table -// will be added as a new array; if the old color table -// was interleaved with a previous array, the previous -// array will not be repacked. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object with the color table replaced with a + * new color table that has been scaled by the indicated value. The new color + * table will be added as a new array; if the old color table was interleaved + * with a previous array, the previous array will not be repacked. + */ CPT(GeomVertexData) GeomVertexData:: scale_color(const LVecBase4 &color_scale, int num_components, GeomVertexData::NumericType numeric_type, @@ -958,15 +876,13 @@ scale_color(const LVecBase4 &color_scale, int num_components, return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_color -// Access: Published -// Description: Returns a new GeomVertexData object with the color -// data modified in-place with the new value. -// -// If the vertex data does not include a color column, a -// new one will not be added. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object with the color data modified in-place + * with the new value. + * + * If the vertex data does not include a color column, a new one will not be + * added. + */ CPT(GeomVertexData) GeomVertexData:: set_color(const LColor &color) const { const GeomVertexColumn *old_column = @@ -980,16 +896,12 @@ set_color(const LColor &color) const { return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::set_color -// Access: Published -// Description: Returns a new GeomVertexData object with the color -// table replaced with a new color table for which each -// vertex has the indicated value. The new color table -// will be added as a new array; if the old color table -// was interleaved with a previous array, the previous -// array will not be repacked. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object with the color table replaced with a + * new color table for which each vertex has the indicated value. The new + * color table will be added as a new array; if the old color table was + * interleaved with a previous array, the previous array will not be repacked. + */ CPT(GeomVertexData) GeomVertexData:: set_color(const LColor &color, int num_components, GeomVertexData::NumericType numeric_type, @@ -1008,17 +920,13 @@ set_color(const LColor &color, int num_components, return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::reverse_normals -// Access: Published -// Description: Returns a new GeomVertexData object with the normal -// data modified in-place, so that each lighting normal -// is now facing in the opposite direction. -// -// If the vertex data does not include a normal column, -// this returns the original GeomVertexData object, -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object with the normal data modified in-place, + * so that each lighting normal is now facing in the opposite direction. + * + * If the vertex data does not include a normal column, this returns the + * original GeomVertexData object, unchanged. + */ CPT(GeomVertexData) GeomVertexData:: reverse_normals() const { const GeomVertexColumn *old_column = @@ -1036,37 +944,29 @@ reverse_normals() const { return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::animate_vertices -// Access: Published -// Description: Returns a GeomVertexData that represents the results -// of computing the vertex animation on the CPU for this -// GeomVertexData. -// -// If there is no CPU-defined vertex animation on this -// object, this just returns the original object. -// -// If there is vertex animation, but the VertexTransform -// values have not changed since last time, this may -// return the same pointer it returned previously. Even -// if the VertexTransform values have changed, it may -// still return the same pointer, but with its contents -// modified (this is preferred, since it allows the -// graphics backend to update vertex buffers optimally). -// -// If force is false, this method may return immediately -// with stale data, if the vertex data is not completely -// resident. If force is true, this method will never -// return stale data, but may block until the data is -// available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomVertexData that represents the results of computing the + * vertex animation on the CPU for this GeomVertexData. + * + * If there is no CPU-defined vertex animation on this object, this just + * returns the original object. + * + * If there is vertex animation, but the VertexTransform values have not + * changed since last time, this may return the same pointer it returned + * previously. Even if the VertexTransform values have changed, it may still + * return the same pointer, but with its contents modified (this is preferred, + * since it allows the graphics backend to update vertex buffers optimally). + * + * If force is false, this method may return immediately with stale data, if + * the vertex data is not completely resident. If force is true, this method + * will never return stale data, but may block until the data is available. + */ CPT(GeomVertexData) GeomVertexData:: animate_vertices(bool force, Thread *current_thread) const { #ifdef DO_PIPELINING { - // In the pipelining case, we take a simple short-route - // optimization: if the vdata isn't animated, we don't need to - // grab any mutex first. + // In the pipelining case, we take a simple short-route optimization: if + // the vdata isn't animated, we don't need to grab any mutex first. CDReader cdata(_cycler, current_thread); if (cdata->_format->get_animation().get_animation_type() != AT_panda) { return this; @@ -1076,9 +976,9 @@ animate_vertices(bool force, Thread *current_thread) const { PStatTimer timer(((GeomVertexData *)this)->_char_pcollector, current_thread); - // Now that we've short-circuited the short route, we reasonably - // believe the vdata is animated. Grab the mutex and make sure it's - // still animated after we've acquired it. + // Now that we've short-circuited the short route, we reasonably believe the + // vdata is animated. Grab the mutex and make sure it's still animated + // after we've acquired it. CDLockedReader cdata(_cycler, current_thread); if (cdata->_format->get_animation().get_animation_type() != AT_panda) { return this; @@ -1100,8 +1000,7 @@ animate_vertices(bool force, Thread *current_thread) const { modified = cdata->_slider_table->get_modified(current_thread); } else { - // No transform blend table or slider table--ergo, no vertex - // animation. + // No transform blend table or slider table--ergo, no vertex animation. return this; } } @@ -1113,8 +1012,7 @@ animate_vertices(bool force, Thread *current_thread) const { } if (!force && !request_resident()) { - // The vertex data isn't resident. Return the best information - // we've got. + // The vertex data isn't resident. Return the best information we've got. if (cdata->_animated_vertices != (GeomVertexData *)NULL) { return cdata->_animated_vertices; } @@ -1128,15 +1026,12 @@ animate_vertices(bool force, Thread *current_thread) const { return cdataw->_animated_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_animated_vertices -// Access: Published -// Description: Removes the cache of animated vertices computed by a -// previous call to animate_vertices() within the same -// frame. This will force the next call to -// animate_vertices() to recompute these values from -// scratch. Normally it is not necessary to call this. -//////////////////////////////////////////////////////////////////// +/** + * Removes the cache of animated vertices computed by a previous call to + * animate_vertices() within the same frame. This will force the next call to + * animate_vertices() to recompute these values from scratch. Normally it is + * not necessary to call this. + */ void GeomVertexData:: clear_animated_vertices() { CDWriter cdata(_cycler, true); @@ -1145,27 +1040,21 @@ clear_animated_vertices() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::transform_vertices -// Access: Published -// Description: Applies the indicated transform matrix to all of the -// vertices in the GeomVertexData. The transform is -// applied to all "point" and "vector" type columns -// described in the format. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform matrix to all of the vertices in the + * GeomVertexData. The transform is applied to all "point" and "vector" type + * columns described in the format. + */ void GeomVertexData:: transform_vertices(const LMatrix4 &mat) { transform_vertices(mat, 0, get_num_rows()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::transform_vertices -// Access: Published -// Description: Applies the indicated transform matrix to all of the -// vertices from begin_row up to but not including -// end_row. The transform is applied to all "point" and -// "vector" type columns described in the format. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform matrix to all of the vertices from + * begin_row up to but not including end_row. The transform is applied to all + * "point" and "vector" type columns described in the format. + */ void GeomVertexData:: transform_vertices(const LMatrix4 &mat, int begin_row, int end_row) { if (end_row <= begin_row) { @@ -1187,14 +1076,11 @@ transform_vertices(const LMatrix4 &mat, int begin_row, int end_row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::transform_vertices -// Access: Published -// Description: Applies the indicated transform matrix to all of the -// vertices mentioned in the sparse array. The -// transform is applied to all "point" and "vector" -// type columns described in the format. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform matrix to all of the vertices mentioned in + * the sparse array. The transform is applied to all "point" and "vector" + * type columns described in the format. + */ void GeomVertexData:: transform_vertices(const LMatrix4 &mat, const SparseArray &rows) { if (rows.is_zero()) { @@ -1226,19 +1112,16 @@ transform_vertices(const LMatrix4 &mat, const SparseArray &rows) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::do_set_color -// Access: Private, Static -// Description: Fills in the color column of the given vertex data -// object with a constant color. Assumes that there -// is already a color column present. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the color column of the given vertex data object with a constant + * color. Assumes that there is already a color column present. + */ void GeomVertexData:: do_set_color(GeomVertexData *vdata, const LColor &color) { - // This function is used relatively often (by the SceneGraphReducer, - // when flattening colors, and by the munger, when munging colors), - // so I've written out a version that avoids the performance overhead - // of the packer and GeomVertexWriter. + // This function is used relatively often (by the SceneGraphReducer, when + // flattening colors, and by the munger, when munging colors), so I've + // written out a version that avoids the performance overhead of the packer + // and GeomVertexWriter. const GeomVertexFormat *format = vdata->get_format(); const GeomVertexColumn *column; @@ -1284,11 +1167,9 @@ do_set_color(GeomVertexData *vdata, const LColor &color) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::bytewise_copy -// Access: Private, Static -// Description: Quickly copies data without the need to convert it. -//////////////////////////////////////////////////////////////////// +/** + * Quickly copies data without the need to convert it. + */ void GeomVertexData:: bytewise_copy(unsigned char *to, int to_stride, const unsigned char *from, int from_stride, @@ -1302,13 +1183,13 @@ bytewise_copy(unsigned char *to, int to_stride, } if (to_stride == from_type->get_total_bytes() && from_stride == from_type->get_total_bytes()) { - // Fantastic! It's just a linear array of this one data type. - // Copy the whole thing all at once. + // Fantastic! It's just a linear array of this one data type. Copy the + // whole thing all at once. memcpy(to, from, num_records * from_type->get_total_bytes()); } else { - // Ok, it's interleaved in with other data. Copy them one record - // at a time. + // Ok, it's interleaved in with other data. Copy them one record at a + // time. while (num_records > 0) { memcpy(to, from, from_type->get_total_bytes()); to += to_stride; @@ -1318,20 +1199,15 @@ bytewise_copy(unsigned char *to, int to_stride, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::replace_column -// Access: Published -// Description: Returns a new GeomVertexData object, suitable for -// modification, with the indicated data type replaced -// with a new table filled with undefined values. The -// new table will be added as a new array; if the old -// table was interleaved with a previous array, the -// previous array will not be repacked. -// -// If num_components is 0, the indicated name is simply -// removed from the type, without replacing it with -// anything else. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexData object, suitable for modification, with the + * indicated data type replaced with a new table filled with undefined values. + * The new table will be added as a new array; if the old table was + * interleaved with a previous array, the previous array will not be repacked. + * + * If num_components is 0, the indicated name is simply removed from the type, + * without replacing it with anything else. + */ PT(GeomVertexData) GeomVertexData:: replace_column(InternalName *name, int num_components, GeomVertexData::NumericType numeric_type, @@ -1345,14 +1221,14 @@ replace_column(InternalName *name, int num_components, if (old_type_array != -1) { GeomVertexArrayFormat *array_format = new_format->modify_array(old_type_array); if (array_format->get_num_columns() == 1) { - // Actually, this array didn't have any other data types, so - // just drop the whole array. + // Actually, this array didn't have any other data types, so just drop + // the whole array. new_format->remove_array(old_type_array); removed_type_array = true; } else { - // Remove the description for the type, but don't bother to - // repack the array. + // Remove the description for the type, but don't bother to repack the + // array. array_format->remove_column(name); } } @@ -1382,8 +1258,8 @@ replace_column(InternalName *name, int num_components, for (int i = 0; i < num_arrays; ++i) { if (i == old_type_array) { if (!removed_type_array) { - // Pointer-copy the original array that includes the type - // (since it also includes other data). + // Pointer-copy the original array that includes the type (since it + // also includes other data). new_data->set_array(j, get_array(i)); ++j; } @@ -1398,8 +1274,8 @@ replace_column(InternalName *name, int num_components, if (new_type_array != -1) { nassertr(j == new_type_array, new_data); - // For the new type array, we set up a temporary array that has - // room for the right number of rows. + // For the new type array, we set up a temporary array that has room for + // the right number of rows. PT(GeomVertexArrayData) new_array = new GeomVertexArrayData (format->get_array(j), get_usage_hint()); new_array->set_num_rows(get_num_rows()); @@ -1409,11 +1285,9 @@ replace_column(InternalName *name, int num_components, return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexData:: output(ostream &out) const { if (!get_name().empty()) { @@ -1422,11 +1296,9 @@ output(ostream &out) const { out << get_num_rows() << " rows: " << *get_format(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexData:: write(ostream &out, int indent_level) const { if (!get_name().empty()) { @@ -1441,12 +1313,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::describe_vertex -// Access: Published -// Description: Writes a verbose, human-friendly description of the -// indicated vertex number. -//////////////////////////////////////////////////////////////////// +/** + * Writes a verbose, human-friendly description of the indicated vertex + * number. + */ void GeomVertexData:: describe_vertex(ostream &out, int row) const { nassertv_always(row >= 0 && row < get_num_rows()); @@ -1479,8 +1349,8 @@ describe_vertex(ostream &out, int row) const { if (column->get_name() == InternalName::get_transform_blend() && tb_table != NULL) { - // This is an index into the transform blend table. Look up the - // index and report the vertex weighting. + // This is an index into the transform blend table. Look up the index + // and report the vertex weighting. reader.set_column(ai, column); int bi = reader.get_data1i(); if (bi >= 0 && (size_t)bi < tb_table->get_num_blends()) { @@ -1511,17 +1381,13 @@ describe_vertex(ostream &out, int row) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_cache -// Access: Published -// Description: Removes all of the previously-cached results of -// convert_to(). -// -// This blows away the entire cache, upstream and -// downstream the pipeline. Use clear_cache_stage() -// instead if you only want to blow away the cache at -// the current stage and upstream. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-cached results of convert_to(). + * + * This blows away the entire cache, upstream and downstream the pipeline. + * Use clear_cache_stage() instead if you only want to blow away the cache at + * the current stage and upstream. + */ void GeomVertexData:: clear_cache() { LightMutexHolder holder(_cache_lock); @@ -1534,17 +1400,13 @@ clear_cache() { _cache.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::clear_cache_stage -// Access: Published -// Description: Removes all of the previously-cached results of -// convert_to(), at the current pipeline stage and -// upstream. Does not affect the downstream cache. -// -// Don't call this in a downstream thread unless you -// don't mind it blowing away other changes you might -// have recently made in an upstream thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-cached results of convert_to(), at the + * current pipeline stage and upstream. Does not affect the downstream cache. + * + * Don't call this in a downstream thread unless you don't mind it blowing + * away other changes you might have recently made in an upstream thread. + */ void GeomVertexData:: clear_cache_stage() { LightMutexHolder holder(_cache_lock); @@ -1557,12 +1419,9 @@ clear_cache_stage() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::packed_argb_to_uint8_rgba -// Access: Private, Static -// Description: Quickly converts DirectX-style color to OpenGL-style -// color. -//////////////////////////////////////////////////////////////////// +/** + * Quickly converts DirectX-style color to OpenGL-style color. + */ void GeomVertexData:: packed_argb_to_uint8_rgba(unsigned char *to, int to_stride, const unsigned char *from, int from_stride, @@ -1587,12 +1446,9 @@ packed_argb_to_uint8_rgba(unsigned char *to, int to_stride, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::uint8_rgba_to_packed_argb -// Access: Private, Static -// Description: Quickly converts OpenGL-style color to DirectX-style -// color. -//////////////////////////////////////////////////////////////////// +/** + * Quickly converts OpenGL-style color to DirectX-style color. + */ void GeomVertexData:: uint8_rgba_to_packed_argb(unsigned char *to, int to_stride, const unsigned char *from, int from_stride, @@ -1613,13 +1469,10 @@ uint8_rgba_to_packed_argb(unsigned char *to, int to_stride, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::update_animated_vertices -// Access: Private -// Description: Recomputes the results of computing the vertex -// animation on the CPU, and applies them to the -// existing animated_vertices object. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the results of computing the vertex animation on the CPU, and + * applies them to the existing animated_vertices object. + */ void GeomVertexData:: update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { PStatTimer timer(_char_pcollector, current_thread); @@ -1643,11 +1496,10 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { } PT(GeomVertexData) new_data = cdata->_animated_vertices; - // We have to make a complete copy of the data first so we can - // modify it. If we were clever, we could maybe just figure out the - // subset of the data that might have changed since last frame, but - // that's too much trouble (and isn't obviously faster than just - // copying the whole thing). + // We have to make a complete copy of the data first so we can modify it. + // If we were clever, we could maybe just figure out the subset of the data + // that might have changed since last frame, but that's too much trouble + // (and isn't obviously faster than just copying the whole thing). new_data->copy_from(this, true); // First, apply all of the morphs. @@ -1736,8 +1588,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // Then apply the transforms. CPT(TransformBlendTable) tb_table = cdata->_transform_blend_table.get_read_pointer(); if (tb_table != (TransformBlendTable *)NULL) { - // Recompute all the blends up front, so we don't have to test - // each one for staleness at each vertex. + // Recompute all the blends up front, so we don't have to test each one + // for staleness at each vertex. { PStatTimer timer4(_blends_pcollector); int num_blends = tb_table->get_num_blends(); @@ -1764,8 +1616,7 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { if (blend_array_format->get_stride() == 2 && blend_array_format->get_column(0)->get_component_bytes() == 2) { - // The blend indices are a table of ushorts. Optimize this - // common case. + // The blend indices are a table of ushorts. Optimize this common case. CPT(GeomVertexArrayDataHandle) blend_array_handle = cdata->_arrays[blend_array_index].get_read_pointer()->get_handle(current_thread); const unsigned short *blendt = (const unsigned short *)blend_array_handle->get_read_pointer(true); @@ -1785,8 +1636,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // At this point, first_vertex is the first of a series of // vertices that shares the blend index first_bi. - // Scan for the end of this series of vertices--we're - // looking for the next vertex with a different blend index. + // Scan for the end of this series of vertices--we're looking for + // the next vertex with a different blend index. int next_vertex = first_vertex; int next_bi = first_bi; ++next_vertex; @@ -1825,8 +1676,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // At this point, first_vertex is the first of a series of // vertices that shares the blend index first_bi. - // Scan for the end of this series of vertices--we're - // looking for the next vertex with a different blend index. + // Scan for the end of this series of vertices--we're looking for + // the next vertex with a different blend index. int next_vertex = first_vertex; int next_bi = first_bi; ++next_vertex; @@ -1851,8 +1702,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { } } else { - // The blend indices are anything else. Use the - // GeomVertexReader to iterate through them. + // The blend indices are anything else. Use the GeomVertexReader to + // iterate through them. GeomVertexReader blendi(this, InternalName::get_transform_blend()); nassertv(blendi.has_column()); @@ -1873,8 +1724,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // At this point, first_vertex is the first of a series of // vertices that shares the blend index first_bi. - // Scan for the end of this series of vertices--we're - // looking for the next vertex with a different blend index. + // Scan for the end of this series of vertices--we're looking for + // the next vertex with a different blend index. int next_vertex = first_vertex; int next_bi = first_bi; ++next_vertex; @@ -1914,8 +1765,8 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { // At this point, first_vertex is the first of a series of // vertices that shares the blend index first_bi. - // Scan for the end of this series of vertices--we're - // looking for the next vertex with a different blend index. + // Scan for the end of this series of vertices--we're looking for + // the next vertex with a different blend index. int next_vertex = first_vertex; int next_bi = first_bi; ++next_vertex; @@ -1943,12 +1794,9 @@ update_animated_vertices(GeomVertexData::CData *cdata, Thread *current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::do_transform_point_column -// Access: Private -// Description: Transforms a range of vertices for one particular -// column, as a point. -//////////////////////////////////////////////////////////////////// +/** + * Transforms a range of vertices for one particular column, as a point. + */ void GeomVertexData:: do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &data, const LMatrix4 &mat, int begin_row, int end_row) { @@ -1957,8 +1805,8 @@ do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &da if ((num_values == 3 || num_values == 4) && data_column->get_numeric_type() == NT_float32) { - // The table of points is a table of LPoint3f's or LPoint4f's. - // Optimize this common case. + // The table of points is a table of LPoint3f's or LPoint4f's. Optimize + // this common case. GeomVertexArrayDataHandle *data_handle = data.get_array_handle(); size_t stride = data.get_stride(); @@ -1974,8 +1822,7 @@ do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &da } } else if (num_values == 4) { - // Use the GeomVertexRewriter to adjust the 4-component - // points. + // Use the GeomVertexRewriter to adjust the 4-component points. data.set_row_unsafe(begin_row); for (int j = begin_row; j < end_row; ++j) { @@ -1984,8 +1831,7 @@ do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &da } } else { - // Use the GeomVertexRewriter to adjust the 3-component - // points. + // Use the GeomVertexRewriter to adjust the 3-component points. data.set_row_unsafe(begin_row); for (int j = begin_row; j < end_row; ++j) { @@ -1995,12 +1841,9 @@ do_transform_point_column(const GeomVertexFormat *format, GeomVertexRewriter &da } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::do_transform_vector_column -// Access: Private -// Description: Transforms a range of vertices for one particular -// column, as a vector. -//////////////////////////////////////////////////////////////////// +/** + * Transforms a range of vertices for one particular column, as a vector. + */ void GeomVertexData:: do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &data, const LMatrix4 &mat, int begin_row, int end_row) { @@ -2019,13 +1862,13 @@ do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &d // No scale to worry about. xform = mat; } else { - // Simply take the uniform scale out of the transformation. - // Not sure if it might be better to just normalize? + // Simply take the uniform scale out of the transformation. Not sure + // if it might be better to just normalize? compose_matrix(xform, LVecBase3(1, 1, 1), shear, hpr, LVecBase3::zero()); } } else { - // There is a non-uniform scale, so we need to do all this to - // preserve orthogonality to the surface. + // There is a non-uniform scale, so we need to do all this to preserve + // orthogonality to the surface. xform.invert_from(mat); xform.transpose_in_place(); normalize = true; @@ -2074,35 +1917,30 @@ do_transform_vector_column(const GeomVertexFormat *format, GeomVertexRewriter &d } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::table_xform_point3f -// Access: Private, Static -// Description: Transforms each of the LPoint3f objects in the -// indicated table by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms each of the LPoint3f objects in the indicated table by the + * indicated matrix. + */ void GeomVertexData:: table_xform_point3f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf) { - // We don't bother checking for the unaligned case here, because in - // practice it doesn't matter with a 3-component point. + // We don't bother checking for the unaligned case here, because in practice + // it doesn't matter with a 3-component point. for (size_t i = 0; i < num_rows; ++i) { LPoint3f &vertex = *(LPoint3f *)(&datat[i * stride]); vertex *= matf; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::table_xform_normal3f -// Access: Private, Static -// Description: Transforms each of the LVector3f objects in the -// indicated table by the indicated matrix, and also -// normalizes them. -//////////////////////////////////////////////////////////////////// +/** + * Transforms each of the LVector3f objects in the indicated table by the + * indicated matrix, and also normalizes them. + */ void GeomVertexData:: table_xform_normal3f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf) { - // We don't bother checking for the unaligned case here, because in - // practice it doesn't matter with a 3-component vector. + // We don't bother checking for the unaligned case here, because in practice + // it doesn't matter with a 3-component vector. for (size_t i = 0; i < num_rows; ++i) { LNormalf &vertex = *(LNormalf *)(&datat[i * stride]); vertex *= matf; @@ -2110,38 +1948,34 @@ table_xform_normal3f(unsigned char *datat, size_t num_rows, size_t stride, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::table_xform_vector3f -// Access: Private, Static -// Description: Transforms each of the LVector3f objects in the -// indicated table by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms each of the LVector3f objects in the indicated table by the + * indicated matrix. + */ void GeomVertexData:: table_xform_vector3f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf) { - // We don't bother checking for the unaligned case here, because in - // practice it doesn't matter with a 3-component vector. + // We don't bother checking for the unaligned case here, because in practice + // it doesn't matter with a 3-component vector. for (size_t i = 0; i < num_rows; ++i) { LVector3f &vertex = *(LVector3f *)(&datat[i * stride]); vertex *= matf; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::table_xform_vecbase4f -// Access: Private, Static -// Description: Transforms each of the LVecBase4f objects in the -// indicated table by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms each of the LVecBase4f objects in the indicated table by the + * indicated matrix. + */ void GeomVertexData:: table_xform_vecbase4f(unsigned char *datat, size_t num_rows, size_t stride, const LMatrix4f &matf) { #if defined(HAVE_EIGEN) && defined(LINMATH_ALIGN) - // Check if the table is unaligned. If it is, we can't use the - // LVecBase4f object directly, which assumes 16-byte alignment. + // Check if the table is unaligned. If it is, we can't use the LVecBase4f + // object directly, which assumes 16-byte alignment. if (((size_t)datat & 0xf) != 0 || (stride & 0xf) != 0) { - // Instead, we'll use low-level Eigen calls to multiply out the - // unaligned memory. + // Instead, we'll use low-level Eigen calls to multiply out the unaligned + // memory. Eigen::Map, Eigen::Unaligned, Eigen::OuterStride<> > table((float *)datat, num_rows, 4, Eigen::OuterStride<>(stride / sizeof(float))); for (size_t i = 0; i < num_rows; ++i) { table.row(i) *= matf._m; @@ -2150,32 +1984,27 @@ table_xform_vecbase4f(unsigned char *datat, size_t num_rows, size_t stride, } #endif // HAVE_EIGEN - // If the table is properly aligned (or we don't require alignment), - // we can directly use the high-level LVecBase4f object, which will - // do the right thing. + // If the table is properly aligned (or we don't require alignment), we can + // directly use the high-level LVecBase4f object, which will do the right + // thing. for (size_t i = 0; i < num_rows; ++i) { LVecBase4f &vertex = *(LVecBase4f *)(&datat[i * stride]); vertex *= matf; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// GeomVertexData. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type GeomVertexData. + */ void GeomVertexData:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexData:: write_datagram(BamWriter *manager, Datagram &dg) { CopyOnWriteObject::write_datagram(manager, dg); @@ -2184,14 +2013,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type GeomVertexData is encountered -// in the Bam file. It should create the GeomVertexData -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type GeomVertexData is encountered in the Bam file. It should create the + * GeomVertexData and extract its information from the file. + */ TypedWritable *GeomVertexData:: make_from_bam(const FactoryParams ¶ms) { GeomVertexData *object = new GeomVertexData; @@ -2205,56 +2031,47 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CopyOnWriteObject::complete_pointers(p_list, manager); return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool GeomVertexData:: require_fully_complete() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void GeomVertexData:: finalize(BamReader *manager) { // NOTE: This method may be called more than once, because the - // Geom::finalize() will call it explicitly. We have to be prepared - // to accept multiple finalize() calls. + // Geom::finalize() will call it explicitly. We have to be prepared to + // accept multiple finalize() calls. - // Now we need to register the format that we have read from the bam - // file (since it doesn't come out of the bam file automatically - // registered). This may change the format's pointer, which we - // should then update our own data to reflect. But since this may - // cause the unregistered object to destruct, we have to also tell - // the BamReader to return the new object from now on. + // Now we need to register the format that we have read from the bam file + // (since it doesn't come out of the bam file automatically registered). + // This may change the format's pointer, which we should then update our own + // data to reflect. But since this may cause the unregistered object to + // destruct, we have to also tell the BamReader to return the new object + // from now on. - // This extends to the nested array datas, as well as the transform - // table and slider tables, as well. + // This extends to the nested array datas, as well as the transform table + // and slider tables, as well. CDWriter cdata(_cycler, true); @@ -2287,13 +2104,10 @@ finalize(BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexData. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexData. + */ void GeomVertexData:: fillin(DatagramIterator &scan, BamReader *manager) { CopyOnWriteObject::fillin(scan, manager); @@ -2302,22 +2116,18 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CDataCache::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GeomVertexData::CDataCache:: make_copy() const { return new CDataCache(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheEntry::evict_callback -// Access: Public, Virtual -// Description: Called when the entry is evicted from the cache, this -// should clean up the owning object appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called when the entry is evicted from the cache, this should clean up the + * owning object appropriately. + */ void GeomVertexData::CacheEntry:: evict_callback() { LightMutexHolder holder(_source->_cache_lock); @@ -2327,33 +2137,27 @@ evict_callback() { _source->_cache.erase(ci); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CacheEntry::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexData::CacheEntry:: output(ostream &out) const { out << "vertex data " << (void *)_source << " to " << *_key._modifier; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GeomVertexData::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexData::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { manager->write_pointer(dg, _format); @@ -2370,13 +2174,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { manager->write_pointer(dg, _slider_table); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexData::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -2395,10 +2196,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { _modified = Geom::get_next_modified(); if (!_arrays.empty() && manager->get_file_minor_ver() < 7) { - // Bam files prior to 6.7 did not store a SparseArray in the - // SliderTable or TransformBlendTable entries. We need to make up - // a SparseArray for each of them that reflects the complete - // number of rows in the data. + // Bam files prior to 6.7 did not store a SparseArray in the SliderTable + // or TransformBlendTable entries. We need to make up a SparseArray for + // each of them that reflects the complete number of rows in the data. SparseArray all_rows; CPT(GeomVertexArrayData) adata = _arrays[0].get_read_pointer(); all_rows.set_range(0, adata->get_num_rows()); @@ -2417,13 +2217,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexData::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexData. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexData. + */ void GeomVertexData::CData:: fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); @@ -2441,11 +2238,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineBase::get_num_bytes -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexDataPipelineBase:: get_num_bytes() const { int num_bytes = sizeof(GeomVertexData); @@ -2458,11 +2253,9 @@ get_num_bytes() const { return num_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_num_rows -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexDataPipelineReader:: get_num_rows() const { nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); @@ -2478,11 +2271,9 @@ get_num_rows() const { return _array_readers[0]->get_data_size_bytes() / stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_array_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineReader:: get_array_info(const InternalName *name, const GeomVertexArrayDataHandle *&array_reader, @@ -2503,11 +2294,9 @@ get_array_info(const InternalName *name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_array_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineReader:: get_array_info(const InternalName *name, const GeomVertexArrayDataHandle *&array_reader, @@ -2533,11 +2322,9 @@ get_array_info(const InternalName *name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_vertex_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineReader:: get_vertex_info(const GeomVertexArrayDataHandle *&array_reader, int &num_values, @@ -2558,11 +2345,9 @@ get_vertex_info(const GeomVertexArrayDataHandle *&array_reader, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_normal_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineReader:: get_normal_info(const GeomVertexArrayDataHandle *&array_reader, GeomVertexDataPipelineReader::NumericType &numeric_type, @@ -2581,11 +2366,9 @@ get_normal_info(const GeomVertexArrayDataHandle *&array_reader, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::get_color_info -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineReader:: get_color_info(const GeomVertexArrayDataHandle *&array_reader, int &num_values, @@ -2606,11 +2389,9 @@ get_color_info(const GeomVertexArrayDataHandle *&array_reader, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::make_array_readers -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexDataPipelineReader:: make_array_readers() { nassertv(!_got_array_readers); @@ -2625,11 +2406,9 @@ make_array_readers() { _got_array_readers = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineReader::delete_array_readers -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexDataPipelineReader:: delete_array_readers() { nassertv(_got_array_readers); @@ -2638,11 +2417,9 @@ delete_array_readers() { _got_array_readers = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::get_num_rows -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexDataPipelineWriter:: get_num_rows() const { nassertr(_cdata->_format->get_num_arrays() == (int)_cdata->_arrays.size(), 0); @@ -2658,11 +2435,9 @@ get_num_rows() const { return _array_writers[0]->get_data_size_bytes() / stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::set_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineWriter:: set_num_rows(int n) { nassertr(_got_array_writers, false); @@ -2685,8 +2460,8 @@ set_num_rows(int n) { } if (color_array >= 0 && orig_color_rows < n) { - // We have just added some rows; fill the "color" column with - // (1, 1, 1, 1), for the programmer's convenience. + // We have just added some rows; fill the "color" column with (1, 1, 1, + // 1), for the programmer's convenience. GeomVertexArrayDataHandle *array_writer = _array_writers[color_array]; const GeomVertexArrayFormat *array_format = array_writer->get_array_format(); const GeomVertexColumn *column = @@ -2756,11 +2531,9 @@ set_num_rows(int n) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::unclean_set_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineWriter:: unclean_set_num_rows(int n) { nassertr(_got_array_writers, false); @@ -2785,11 +2558,9 @@ unclean_set_num_rows(int n) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::reserve_num_rows -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GeomVertexDataPipelineWriter:: reserve_num_rows(int n) { nassertr(_got_array_writers, false); @@ -2806,11 +2577,9 @@ reserve_num_rows(int n) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::modify_array -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(GeomVertexArrayData) GeomVertexDataPipelineWriter:: modify_array(int i) { nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), NULL); @@ -2829,11 +2598,9 @@ modify_array(int i) { return new_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::set_array -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexDataPipelineWriter:: set_array(int i, const GeomVertexArrayData *array) { nassertv(i >= 0 && i < (int)_cdata->_arrays.size()); @@ -2847,11 +2614,9 @@ set_array(int i, const GeomVertexArrayData *array) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::make_array_writers -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexDataPipelineWriter:: make_array_writers() { nassertv(!_got_array_writers); @@ -2870,11 +2635,9 @@ make_array_writers() { _got_array_writers = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexDataPipelineWriter::delete_array_writers -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexDataPipelineWriter:: delete_array_writers() { nassertv(_got_array_writers); diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 47dac76c28..d2bf71d957 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -1,16 +1,15 @@ -// Filename: geomVertexData.h -// Created by: drose (06Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexData.h + * @author drose + * @date 2005-03-06 + */ #ifndef GEOMVERTEXDATA_H #define GEOMVERTEXDATA_H @@ -44,35 +43,28 @@ class FactoryParams; class GeomVertexColumn; class GeomVertexRewriter; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexData -// Description : This defines the actual numeric vertex data stored in -// a Geom, in the structure defined by a particular -// GeomVertexFormat object. -// -// The data consists of one or more arrays, each of -// which in turn consists of a series of rows, one per -// vertex. All arrays should have the same number of -// rows; each vertex is defined by the column data from -// a particular row across all arrays. -// -// Often, there will be only one array per Geom, and the -// various columns defined in the GeomVertexFormat will -// be interleaved within that array. However, it is -// also possible to have multiple different arrays, with -// a certain subset of the total columns defined in each -// array. -// -// However the data is distributed, the effect is of a -// single table of vertices, where each vertex is -// represented by one row of the table. -// -// In general, application code should not attempt to -// directly manipulate the vertex data through this -// structure; instead, use the GeomVertexReader, -// GeomVertexWriter, and GeomVertexRewriter objects to -// read and write vertex data at a high level. -//////////////////////////////////////////////////////////////////// +/** + * This defines the actual numeric vertex data stored in a Geom, in the + * structure defined by a particular GeomVertexFormat object. + * + * The data consists of one or more arrays, each of which in turn consists of + * a series of rows, one per vertex. All arrays should have the same number + * of rows; each vertex is defined by the column data from a particular row + * across all arrays. + * + * Often, there will be only one array per Geom, and the various columns + * defined in the GeomVertexFormat will be interleaved within that array. + * However, it is also possible to have multiple different arrays, with a + * certain subset of the total columns defined in each array. + * + * However the data is distributed, the effect is of a single table of + * vertices, where each vertex is represented by one row of the table. + * + * In general, application code should not attempt to directly manipulate the + * vertex data through this structure; instead, use the GeomVertexReader, + * GeomVertexWriter, and GeomVertexRewriter objects to read and write vertex + * data at a high level. + */ class EXPCL_PANDA_GOBJ GeomVertexData : public CopyOnWriteObject, public GeomEnums { private: GeomVertexData(); @@ -243,11 +235,10 @@ private: typedef CycleDataWriter CDCacheWriter; public: - // The CacheKey class separates out just the part of CacheEntry that - // is used to key the cache entry within the map. We have this as a - // separate class so we can easily look up a new entry in the map, - // without having to execute the relatively expensive CacheEntry - // constructor. + // The CacheKey class separates out just the part of CacheEntry that is used + // to key the cache entry within the map. We have this as a separate class + // so we can easily look up a new entry in the map, without having to + // execute the relatively expensive CacheEntry constructor. class EXPCL_PANDA_GOBJ CacheKey { public: INLINE CacheKey(const GeomVertexFormat *modifier); @@ -404,12 +395,10 @@ private: friend class GeomVertexDataPipelineWriter; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexDataPipelineBase -// Description : The common code from -// GeomVertexDataPipelineReader and -// GeomVertexDataPipelineWriter. -//////////////////////////////////////////////////////////////////// +/** + * The common code from GeomVertexDataPipelineReader and + * GeomVertexDataPipelineWriter. + */ class EXPCL_PANDA_GOBJ GeomVertexDataPipelineBase : public GeomEnums { protected: INLINE GeomVertexDataPipelineBase(GeomVertexData *object, @@ -440,11 +429,10 @@ protected: GeomVertexData::CData *_cdata; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexDataPipelineReader -// Description : Encapsulates the data from a GeomVertexData, -// pre-fetched for one stage of the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a GeomVertexData, pre-fetched for one stage of + * the pipeline. + */ class EXPCL_PANDA_GOBJ GeomVertexDataPipelineReader : public GeomVertexDataPipelineBase { public: INLINE GeomVertexDataPipelineReader(const GeomVertexData *object, Thread *current_thread); @@ -509,11 +497,10 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexDataPipelineWriter -// Description : Encapsulates the data from a GeomVertexData, -// pre-fetched for one stage of the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a GeomVertexData, pre-fetched for one stage of + * the pipeline. + */ class EXPCL_PANDA_GOBJ GeomVertexDataPipelineWriter : public GeomVertexDataPipelineBase { public: INLINE GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0, diff --git a/panda/src/gobj/geomVertexFormat.I b/panda/src/gobj/geomVertexFormat.I index 974d83022c..e9d4110820 100644 --- a/panda/src/gobj/geomVertexFormat.I +++ b/panda/src/gobj/geomVertexFormat.I @@ -1,17 +1,15 @@ -// Filename: geomVertexFormat.I -// Created by: drose (07Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexFormat.I + * @author drose + * @date 2005-03-07 + */ INLINE ostream & operator << (ostream &out, const GeomVertexFormat &obj) { @@ -19,140 +17,107 @@ operator << (ostream &out, const GeomVertexFormat &obj) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::is_registered -// Access: Published -// Description: Returns true if this format has been registered, -// false if it has not. It may not be used for a Geom -// until it has been registered, but once registered, it -// may no longer be modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this format has been registered, false if it has not. It + * may not be used for a Geom until it has been registered, but once + * registered, it may no longer be modified. + */ INLINE bool GeomVertexFormat:: is_registered() const { return _is_registered; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::register_format -// Access: Published, Static -// Description: Adds the indicated format to the registry, if there -// is not an equivalent format already there; in either -// case, returns the pointer to the equivalent format -// now in the registry. -// -// This must be called before a format may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated format to the registry, if there is not an equivalent + * format already there; in either case, returns the pointer to the equivalent + * format now in the registry. + * + * This must be called before a format may be used in a Geom. After this + * call, you should discard the original pointer you passed in (which may or + * may not now be invalid) and let its reference count decrement normally; you + * should use only the returned value from this point on. + */ INLINE CPT(GeomVertexFormat) GeomVertexFormat:: register_format(const GeomVertexFormat *format) { return get_registry()->register_format((GeomVertexFormat *)format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::register_format -// Access: Published, Static -// Description: This flavor of register_format() implicitly creates a -// one-array vertex format from the array definition. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of register_format() implicitly creates a one-array vertex + * format from the array definition. + */ INLINE CPT(GeomVertexFormat) GeomVertexFormat:: register_format(const GeomVertexArrayFormat *format) { return register_format(new GeomVertexFormat(format)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_animation -// Access: Published -// Description: Returns the GeomVertexAnimationSpec that indicates -// how this format's vertices are set up for animation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GeomVertexAnimationSpec that indicates how this format's + * vertices are set up for animation. + */ INLINE const GeomVertexAnimationSpec &GeomVertexFormat:: get_animation() const { return _animation; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::set_animation -// Access: Published -// Description: Resets the GeomVertexAnimationSpec that indicates -// how this format's vertices are set up for animation. -// You should also, of course, change the columns in the -// tables accordingly. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Resets the GeomVertexAnimationSpec that indicates how this format's + * vertices are set up for animation. You should also, of course, change the + * columns in the tables accordingly. + * + * This may not be called once the format has been registered. + */ INLINE void GeomVertexFormat:: set_animation(const GeomVertexAnimationSpec &animation) { nassertv(!_is_registered); _animation = animation; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_arrays -// Access: Published -// Description: Returns the number of individual arrays required by -// the format. If the array data is completely -// interleaved, this will be 1; if it is completely -// parallel, this will be the same as the number of data -// types. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual arrays required by the format. If the + * array data is completely interleaved, this will be 1; if it is completely + * parallel, this will be the same as the number of data types. + */ INLINE size_t GeomVertexFormat:: get_num_arrays() const { return _arrays.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_array -// Access: Published -// Description: Returns the description of the nth array used by the -// format. -//////////////////////////////////////////////////////////////////// +/** + * Returns the description of the nth array used by the format. + */ INLINE const GeomVertexArrayFormat *GeomVertexFormat:: get_array(size_t array) const { nassertr(array < _arrays.size(), NULL); return _arrays[array]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::has_column -// Access: Published -// Description: Returns true if the format has the named column, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the format has the named column, false otherwise. + */ INLINE bool GeomVertexFormat:: has_column(const InternalName *name) const { return (get_column(name) != (GeomVertexColumn *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_points -// Access: Published -// Description: Returns the number of columns within the format -// that represent points in space. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of columns within the format that represent points in + * space. + * + * This may only be called after the format has been registered. + */ INLINE size_t GeomVertexFormat:: get_num_points() const { nassertr(_is_registered, 0); return _points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_point -// Access: Published -// Description: Returns the name of the nth point column. This -// represents a point in space, which should be -// transformed by any spatial transform matrix. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth point column. This represents a point in + * space, which should be transformed by any spatial transform matrix. + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_point(size_t n) const { nassertr(_is_registered, NULL); @@ -160,32 +125,25 @@ get_point(size_t n) const { return _points[n]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_vectors -// Access: Published -// Description: Returns the number of columns within the format -// that represent directional vectors. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of columns within the format that represent directional + * vectors. + * + * This may only be called after the format has been registered. + */ INLINE size_t GeomVertexFormat:: get_num_vectors() const { nassertr(_is_registered, 0); return _vectors.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_vector -// Access: Published -// Description: Returns the name of the nth vector column. This -// represents a directional vector, which should be -// transformed by any spatial transform matrix as a -// vector. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth vector column. This represents a directional + * vector, which should be transformed by any spatial transform matrix as a + * vector. + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_vector(size_t n) const { nassertr(_is_registered, NULL); @@ -193,30 +151,24 @@ get_vector(size_t n) const { return _vectors[n]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_texcoords -// Access: Published -// Description: Returns the number of columns within the format -// that represent texture coordinates. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of columns within the format that represent texture + * coordinates. + * + * This may only be called after the format has been registered. + */ INLINE size_t GeomVertexFormat:: get_num_texcoords() const { nassertr(_is_registered, 0); return _texcoords.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_texcoord -// Access: Published -// Description: Returns the name of the nth texcoord column. This -// represents a texture coordinate. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth texcoord column. This represents a texture + * coordinate. + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_texcoord(size_t n) const { nassertr(_is_registered, NULL); @@ -224,15 +176,12 @@ get_texcoord(size_t n) const { return _texcoords[n]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_morphs -// Access: Published -// Description: Returns the number of columns within the format -// that represent morph deltas. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of columns within the format that represent morph + * deltas. + * + * This may only be called after the format has been registered. + */ INLINE size_t GeomVertexFormat:: get_num_morphs() const { nassertr(_is_registered, 0); @@ -240,17 +189,13 @@ get_num_morphs() const { return _morphs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_morph_slider -// Access: Published -// Description: Returns the slider name associated with the nth morph -// column. This is the name of the slider that will -// control the morph, and should be defined within the -// SliderTable associated with the GeomVertexData. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the slider name associated with the nth morph column. This is the + * name of the slider that will control the morph, and should be defined + * within the SliderTable associated with the GeomVertexData. + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_morph_slider(size_t n) const { nassertr(_is_registered, NULL); @@ -259,17 +204,13 @@ get_morph_slider(size_t n) const { return _morphs[n]._slider; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_morph_base -// Access: Published -// Description: Returns the name of the base column that the nth -// morph modifies. This column will also be defined -// within the format, and can be retrieved via -// get_array_with() and/or get_column(). -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the base column that the nth morph modifies. This + * column will also be defined within the format, and can be retrieved via + * get_array_with() and/or get_column(). + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_morph_base(size_t n) const { nassertr(_is_registered, NULL); @@ -278,19 +219,14 @@ get_morph_base(size_t n) const { return _morphs[n]._base; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_morph_delta -// Access: Published -// Description: Returns the name of the column that defines the -// nth morph. This contains the delta offsets that are -// to be applied to the column defined by -// get_morph_base(). This column will be defined -// within the format, and can be retrieved via -// get_array_with() and/or get_column(). -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the column that defines the nth morph. This contains + * the delta offsets that are to be applied to the column defined by + * get_morph_base(). This column will be defined within the format, and can + * be retrieved via get_array_with() and/or get_column(). + * + * This may only be called after the format has been registered. + */ INLINE const InternalName *GeomVertexFormat:: get_morph_delta(size_t n) const { nassertr(_is_registered, NULL); @@ -299,243 +235,190 @@ get_morph_delta(size_t n) const { return _morphs[n]._delta; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3 -// Access: Published, Static -// Description: Returns a standard vertex format with just a -// 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with just a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3() { return get_registry()->_v3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3 -// Access: Published, Static -// Description: Returns a standard vertex format with a 3-component -// normal and a 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 3-component normal and a + * 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3() { return get_registry()->_v3n3; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3t2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair and a 3-component vertex -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate pair + * and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3t2() { return get_registry()->_v3t2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3t2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair, a 3-component normal, and a -// 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate + * pair, a 3-component normal, and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3t2() { return get_registry()->_v3n3t2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3cp -// Access: Published, Static -// Description: Returns a standard vertex format with a packed -// color and a 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a packed color and a 3-component + * vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3cp() { return get_registry()->_v3cp; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3cp -// Access: Published, Static -// Description: Returns a standard vertex format with a packed -// color, a 3-component normal, and a 3-component vertex -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a packed color, a 3-component normal, + * and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3cp() { return get_registry()->_v3n3cp; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3cpt2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair, a packed color, and a -// 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate + * pair, a packed color, and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3cpt2() { return get_registry()->_v3cpt2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3cpt2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair, a packed color, a -// 3-component normal, and a 3-component vertex -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate + * pair, a packed color, a 3-component normal, and a 3-component vertex + * position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3cpt2() { return get_registry()->_v3n3cpt2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3c4 -// Access: Published, Static -// Description: Returns a standard vertex format with a 4-component -// color and a 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 4-component color and a 3-component + * vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3c4() { return get_registry()->_v3c4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3c4 -// Access: Published, Static -// Description: Returns a standard vertex format with a 4-component -// color, a 3-component normal, and a 3-component vertex -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 4-component color, a 3-component + * normal, and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3c4() { return get_registry()->_v3n3c4; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3c4t2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair, a 4-component color, and a -// 3-component vertex position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate + * pair, a 4-component color, and a 3-component vertex position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3c4t2() { return get_registry()->_v3c4t2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_v3n3c4t2 -// Access: Published, Static -// Description: Returns a standard vertex format with a 2-component -// texture coordinate pair, a 4-component color, a -// 3-component normal, and a 3-component vertex -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard vertex format with a 2-component texture coordinate + * pair, a 4-component color, a 3-component normal, and a 3-component vertex + * position. + */ INLINE const GeomVertexFormat *GeomVertexFormat:: get_v3n3c4t2() { return get_registry()->_v3n3c4t2; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_vertex_array_index -// Access: Public -// Description: Returns the array index of the array including the -// "vertex" column, or -1 if there is no such array. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index of the array including the "vertex" column, or -1 + * if there is no such array. + * + * This may only be called after the format has been registered. + */ INLINE int GeomVertexFormat:: get_vertex_array_index() const { nassertr(_is_registered, -1); return _vertex_array_index; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_vertex_column -// Access: Public -// Description: Returns the column definition of the "vertex" column, -// or NULL if there is no such column. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the column definition of the "vertex" column, or NULL if there is + * no such column. + * + * This may only be called after the format has been registered. + */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_vertex_column() const { nassertr(_is_registered, NULL); return _vertex_column; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_normal_array_index -// Access: Public -// Description: Returns the array index of the array including the -// "normal" column, or -1 if there is no such array. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index of the array including the "normal" column, or -1 + * if there is no such array. + * + * This may only be called after the format has been registered. + */ INLINE int GeomVertexFormat:: get_normal_array_index() const { nassertr(_is_registered, -1); return _normal_array_index; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_normal_column -// Access: Public -// Description: Returns the column definition of the "normal" column, -// or NULL if there is no such column. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the column definition of the "normal" column, or NULL if there is + * no such column. + * + * This may only be called after the format has been registered. + */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_normal_column() const { nassertr(_is_registered, NULL); return _normal_column; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_color_array_index -// Access: Public -// Description: Returns the array index of the array including the -// "color" column, or -1 if there is no such array. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index of the array including the "color" column, or -1 if + * there is no such array. + * + * This may only be called after the format has been registered. + */ INLINE int GeomVertexFormat:: get_color_array_index() const { nassertr(_is_registered, -1); return _color_array_index; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_color_column -// Access: Public -// Description: Returns the column definition of the "color" column, -// or NULL if there is no such column. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the column definition of the "color" column, or NULL if there is no + * such column. + * + * This may only be called after the format has been registered. + */ INLINE const GeomVertexColumn *GeomVertexFormat:: get_color_column() const { nassertr(_is_registered, NULL); return _color_column; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ INLINE GeomVertexFormat::Registry *GeomVertexFormat:: get_registry() { if (_registry == (Registry *)NULL) { @@ -544,12 +427,10 @@ get_registry() { return _registry; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Registry::register_format -// Access: Public -// Description: This flavor of register_format() implicitly creates a -// one-array vertex format from the array definition. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of register_format() implicitly creates a one-array vertex + * format from the array definition. + */ INLINE CPT(GeomVertexFormat) GeomVertexFormat::Registry:: register_format(GeomVertexArrayFormat *format) { return register_format(new GeomVertexFormat(format)); diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index c26c075d49..99b0ecfcc7 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -1,16 +1,15 @@ -// Filename: geomVertexFormat.cxx -// Created by: drose (07Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexFormat.cxx + * @author drose + * @date 2005-03-07 + */ #include "geomVertexFormat.h" #include "geomVertexData.h" @@ -23,11 +22,9 @@ GeomVertexFormat::Registry *GeomVertexFormat::_registry = NULL; TypeHandle GeomVertexFormat::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexFormat:: GeomVertexFormat() : _is_registered(false), @@ -35,11 +32,9 @@ GeomVertexFormat() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexFormat:: GeomVertexFormat(const GeomVertexArrayFormat *array_format) : _is_registered(false), @@ -48,11 +43,9 @@ GeomVertexFormat(const GeomVertexArrayFormat *array_format) : add_array(array_format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexFormat:: GeomVertexFormat(const GeomVertexFormat ©) : _is_registered(false), @@ -62,11 +55,9 @@ GeomVertexFormat(const GeomVertexFormat ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexFormat:: operator = (const GeomVertexFormat ©) { nassertv(!is_registered()); @@ -75,24 +66,19 @@ operator = (const GeomVertexFormat ©) { _arrays = copy._arrays; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexFormat:: ~GeomVertexFormat() { // unref() should have unregistered us. nassertv(!is_registered()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// unregister the object when its reference count goes -// to zero. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to unregister the object when + * its reference count goes to zero. + */ bool GeomVertexFormat:: unref() const { Registry *registry = get_registry(); @@ -109,18 +95,14 @@ unref() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_post_animated_format -// Access: Published -// Description: Returns a suitable vertex format for sending the -// animated vertices to the graphics backend. This is -// the same format as the source format, with the -// CPU-animation data elements removed. -// -// This may only be called after the format has been -// registered. The return value will have been already -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable vertex format for sending the animated vertices to the + * graphics backend. This is the same format as the source format, with the + * CPU-animation data elements removed. + * + * This may only be called after the format has been registered. The return + * value will have been already registered. + */ CPT(GeomVertexFormat) GeomVertexFormat:: get_post_animated_format() const { nassertr(is_registered(), NULL); @@ -141,8 +123,8 @@ get_post_animated_format() const { GeomVertexFormat::register_format(new_format); ((GeomVertexFormat *)this)->_post_animated_format = registered; if (_post_animated_format != this) { - // We only keep the reference count if the new pointer is not - // the same as this, to avoid a circular dependency. + // We only keep the reference count if the new pointer is not the same + // as this, to avoid a circular dependency. _post_animated_format->ref(); } } @@ -152,29 +134,24 @@ get_post_animated_format() const { return _post_animated_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_union_format -// Access: Published -// Description: Returns a new GeomVertexFormat that includes all of -// the columns defined in either this GeomVertexFormat -// or the other one. If any column is defined in both -// formats with different sizes (for instance, texcoord2 -// vs. texcoord3), the new format will include the -// larger of the two definitions. -// -// This may only be called after both source formats -// have been registered. The return value will also -// have been already registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new GeomVertexFormat that includes all of the columns defined in + * either this GeomVertexFormat or the other one. If any column is defined in + * both formats with different sizes (for instance, texcoord2 vs. texcoord3), + * the new format will include the larger of the two definitions. + * + * This may only be called after both source formats have been registered. + * The return value will also have been already registered. + */ CPT(GeomVertexFormat) GeomVertexFormat:: get_union_format(const GeomVertexFormat *other) const { nassertr(is_registered() && other->is_registered(), NULL); PT(GeomVertexFormat) new_format = new GeomVertexFormat; - // Preserve whichever animation type is not AT_None. (If both - // animation types are not AT_None, but they are different, this - // whole operation is questionable.) + // Preserve whichever animation type is not AT_None. (If both animation + // types are not AT_None, but they are different, this whole operation is + // questionable.) if (_animation.get_animation_type() != AT_none) { new_format->set_animation(_animation); } else { @@ -185,18 +162,16 @@ get_union_format(const GeomVertexFormat *other) const { typedef pset< CPT(InternalName) > ColumnNames; ColumnNames column_names; - // We go through all the (0)-level arrays first, then all the - // (1)-level arrays, and so on. We do this to ensure that the new - // format gets written out with all the (0)-level columns appearing - // before all the (1)-level columns, which might lead to a small - // optimization at render time. + // We go through all the (0)-level arrays first, then all the (1)-level + // arrays, and so on. We do this to ensure that the new format gets written + // out with all the (0)-level columns appearing before all the (1)-level + // columns, which might lead to a small optimization at render time. - // We also try to keep the structure as similar as possible. If - // both source formats have columns (A, B) in array 0, and columns - // (C, D, E) in array 1, then the resulting union format will also - // have (A, B) in array 0 and (C, D, E) in array 1. In general, a - // column will appear in the result in the first array it appears in - // either of the inputs. + // We also try to keep the structure as similar as possible. If both source + // formats have columns (A, B) in array 0, and columns (C, D, E) in array 1, + // then the resulting union format will also have (A, B) in array 0 and (C, + // D, E) in array 1. In general, a column will appear in the result in the + // first array it appears in either of the inputs. size_t num_arrays = max(_arrays.size(), other->_arrays.size()); for (size_t ai = 0; ai < num_arrays; ++ai) { @@ -265,16 +240,12 @@ get_union_format(const GeomVertexFormat *other) const { return GeomVertexFormat::register_format(new_format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::modify_array -// Access: Published -// Description: Returns a modifiable pointer to the indicated array. -// This means duplicating it if it is shared or -// registered. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the indicated array. This means + * duplicating it if it is shared or registered. + * + * This may not be called once the format has been registered. + */ GeomVertexArrayFormat *GeomVertexFormat:: modify_array(size_t array) { nassertr(!is_registered(), NULL); @@ -288,14 +259,11 @@ modify_array(size_t array) { return _arrays[array]; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::set_array -// Access: Published -// Description: Replaces the definition of the indicated array. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the definition of the indicated array. + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: set_array(size_t array, const GeomVertexArrayFormat *format) { nassertv(!is_registered()); @@ -303,14 +271,11 @@ set_array(size_t array, const GeomVertexArrayFormat *format) { _arrays[array] = (GeomVertexArrayFormat *)format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::remove_array -// Access: Published -// Description: Removes the nth array from the format. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth array from the format. + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: remove_array(size_t array) { nassertv(!is_registered()); @@ -319,17 +284,13 @@ remove_array(size_t array) { _arrays.erase(_arrays.begin() + array); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::add_array -// Access: Published -// Description: Adds the indicated array definition to the list of -// arrays included within this vertex format definition. -// The return value is the index number of the new -// array. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated array definition to the list of arrays included within + * this vertex format definition. The return value is the index number of the + * new array. + * + * This may not be called once the format has been registered. + */ size_t GeomVertexFormat:: add_array(const GeomVertexArrayFormat *array_format) { nassertr(!is_registered(), 0); @@ -339,17 +300,13 @@ add_array(const GeomVertexArrayFormat *array_format) { return new_array; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::insert_array -// Access: Published -// Description: Adds the indicated array definition to the list of -// arrays at the indicated position. This works just -// like add_array(), except that you can specify which -// array index the new array should have. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated array definition to the list of arrays at the indicated + * position. This works just like add_array(), except that you can specify + * which array index the new array should have. + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: insert_array(size_t array, const GeomVertexArrayFormat *array_format) { nassertv(!is_registered()); @@ -358,15 +315,11 @@ insert_array(size_t array, const GeomVertexArrayFormat *array_format) { _arrays.insert(_arrays.begin() + array, (GeomVertexArrayFormat *)array_format); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::clear_arrays -// Access: Published -// Description: Removes all of the array definitions from the format -// and starts over. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the array definitions from the format and starts over. + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: clear_arrays() { nassertv(!is_registered()); @@ -374,14 +327,11 @@ clear_arrays() { _arrays.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::remove_empty_arrays -// Access: Published -// Description: Removes the arrays that define no columns. -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Removes the arrays that define no columns. + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: remove_empty_arrays() { nassertv(!is_registered()); @@ -397,12 +347,10 @@ remove_empty_arrays() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_num_columns -// Access: Published -// Description: Returns the total number of different columns in -// the specification, across all arrays. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of different columns in the specification, across + * all arrays. + */ size_t GeomVertexFormat:: get_num_columns() const { size_t num_columns = 0; @@ -413,12 +361,9 @@ get_num_columns() const { return num_columns; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_column -// Access: Published -// Description: Returns the ith column of the specification, -// across all arrays. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith column of the specification, across all arrays. + */ const GeomVertexColumn *GeomVertexFormat:: get_column(size_t i) const { Arrays::const_iterator ai; @@ -432,18 +377,13 @@ get_column(size_t i) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_array_with -// Access: Published -// Description: Returns the index number of the array with the -// ith column. -// -// The return value can be passed to get_array_format() -// to get the format of the array. It may also be -// passed to GeomVertexData::get_array_data() or -// get_data() or set_data() to manipulate the actual -// array data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the array with the ith column. + * + * The return value can be passed to get_array_format() to get the format of + * the array. It may also be passed to GeomVertexData::get_array_data() or + * get_data() or set_data() to manipulate the actual array data. + */ int GeomVertexFormat:: get_array_with(size_t i) const { int array_index = 0; @@ -457,22 +397,16 @@ get_array_with(size_t i) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_array_with -// Access: Published -// Description: Returns the index number of the array with the -// indicated column, or -1 if no arrays contained -// that name. -// -// The return value can be passed to get_array_format() -// to get the format of the array. It may also be -// passed to GeomVertexData::get_array_data() or -// get_data() or set_data() to manipulate the actual -// array data. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the array with the indicated column, or -1 if + * no arrays contained that name. + * + * The return value can be passed to get_array_format() to get the format of + * the array. It may also be passed to GeomVertexData::get_array_data() or + * get_data() or set_data() to manipulate the actual array data. + * + * This may only be called after the format has been registered. + */ int GeomVertexFormat:: get_array_with(const InternalName *name) const { nassertr(_is_registered, -1); @@ -485,19 +419,16 @@ get_array_with(const InternalName *name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_column -// Access: Published -// Description: Returns the specification with the indicated name, or -// NULL if the name is not used. Use get_array_with() -// to determine which array this column is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specification with the indicated name, or NULL if the name is + * not used. Use get_array_with() to determine which array this column is + * associated with. + */ const GeomVertexColumn *GeomVertexFormat:: get_column(const InternalName *name) const { if (!_is_registered) { - // If the format hasn't yet been registered, we have to search for - // the column the hard way. + // If the format hasn't yet been registered, we have to search for the + // column the hard way. Arrays::const_iterator ai; for (ai = _arrays.begin(); ai != _arrays.end(); ++ai) { const GeomVertexColumn *column = (*ai)->get_column(name); @@ -508,8 +439,8 @@ get_column(const InternalName *name) const { return NULL; } else { - // If the format has been registered, we can just check the - // toplevel index. + // If the format has been registered, we can just check the toplevel + // index. DataTypesByName::const_iterator ai; ai = _columns_by_name.find(name); @@ -524,26 +455,21 @@ get_column(const InternalName *name) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::remove_column -// Access: Published -// Description: Removes the named column from the format, from -// whichever array it exists in. If there are other -// columns remaining in the array, the array is left -// with a gap where the column used to be; if this -// was the only column in the array, the array is -// removed (unless keep_empty_array is true). -// -// This may not be called once the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named column from the format, from whichever array it exists + * in. If there are other columns remaining in the array, the array is left + * with a gap where the column used to be; if this was the only column in the + * array, the array is removed (unless keep_empty_array is true). + * + * This may not be called once the format has been registered. + */ void GeomVertexFormat:: remove_column(const InternalName *name, bool keep_empty_array) { nassertv(!_is_registered); - // Since the format's not registered, it doesn't yet have an index - // of columns--so we have to search all of the arrays, one at a - // time, until we find it. + // Since the format's not registered, it doesn't yet have an index of + // columns--so we have to search all of the arrays, one at a time, until we + // find it. for (int array = 0; array < (int)_arrays.size(); ++array) { GeomVertexArrayFormat *array_format = _arrays[array]; @@ -567,15 +493,13 @@ remove_column(const InternalName *name, bool keep_empty_array) { } } - // It appears that column wasn't part of the format anyway. No - // problem; quietly return. + // It appears that column wasn't part of the format anyway. No problem; + // quietly return. } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::pack_columns -// Access: Published -// Description: Removes wasted space between columns. -//////////////////////////////////////////////////////////////////// +/** + * Removes wasted space between columns. + */ void GeomVertexFormat:: pack_columns() { nassertv(!_is_registered); @@ -588,16 +512,13 @@ pack_columns() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::align_columns_for_animation -// Access: Published -// Description: Reprocesses the columns in the format to align the -// C_point and C_vector columns to 16-byte boundaries to -// allow for the more efficient SSE2 operations -// (assuming SSE2 is enabled in the build). -// -// Also see maybe_align_columns_for_animation(). -//////////////////////////////////////////////////////////////////// +/** + * Reprocesses the columns in the format to align the C_point and C_vector + * columns to 16-byte boundaries to allow for the more efficient SSE2 + * operations (assuming SSE2 is enabled in the build). + * + * Also see maybe_align_columns_for_animation(). + */ void GeomVertexFormat:: align_columns_for_animation() { nassertv(!_is_registered); @@ -610,13 +531,11 @@ align_columns_for_animation() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::maybe_align_columns_for_animation -// Access: Published -// Description: Calls align_columns_for_animation() if this format's -// AnimationSpec indicates that it contains animated -// vertices, and if vertex-animation-align-16 is true. -//////////////////////////////////////////////////////////////////// +/** + * Calls align_columns_for_animation() if this format's AnimationSpec + * indicates that it contains animated vertices, and if vertex-animation- + * align-16 is true. + */ void GeomVertexFormat:: maybe_align_columns_for_animation() { if (_animation.get_animation_type() == AT_panda && vertex_animation_align_16) { @@ -624,11 +543,9 @@ maybe_align_columns_for_animation() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexFormat:: output(ostream &out) const { if (_arrays.empty()) { @@ -650,11 +567,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexFormat:: write(ostream &out, int indent_level) const { for (size_t i = 0; i < _arrays.size(); i++) { @@ -669,11 +584,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::write_with_data -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexFormat:: write_with_data(ostream &out, int indent_level, const GeomVertexData *data) const { @@ -689,19 +602,14 @@ write_with_data(ostream &out, int indent_level, } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::get_array_info -// Access: Public -// Description: Quickly looks up the indicated column within all -// of the nested arrays and sets array_index and -// column appropriately. Returns true if the data -// type exists in this format, false if it does not. If -// it returns false, array_index is set to -1, and -// column is set to NULL. -// -// This may only be called after the format has been -// registered. -//////////////////////////////////////////////////////////////////// +/** + * Quickly looks up the indicated column within all of the nested arrays and + * sets array_index and column appropriately. Returns true if the data type + * exists in this format, false if it does not. If it returns false, + * array_index is set to -1, and column is set to NULL. + * + * This may only be called after the format has been registered. + */ bool GeomVertexFormat:: get_array_info(const InternalName *name, int &array_index, const GeomVertexColumn *&column) const { @@ -721,11 +629,9 @@ get_array_info(const InternalName *name, int &array_index, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int GeomVertexFormat:: compare_to(const GeomVertexFormat &other) const { int compare = _animation.compare_to(other._animation); @@ -747,11 +653,9 @@ compare_to(const GeomVertexFormat &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::make_registry -// Access: Private -// Description: Returns the global registry object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global registry object. + */ void GeomVertexFormat:: make_registry() { if (_registry == (Registry *)NULL) { @@ -760,11 +664,9 @@ make_registry() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::do_register -// Access: Private -// Description: Called internally when the format is registered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the format is registered. + */ void GeomVertexFormat:: do_register() { nassertv(!is_registered()); @@ -779,10 +681,10 @@ do_register() { array_format = GeomVertexArrayFormat::register_format(array_format); } - // Let's keep arrays with nonzero stride but no used columns; - // they're needed to preserve the isomorphic nature of matching - // formats. But we'll toss arrays with 0 stride, which add - // nothing of value and only cause problems later. + // Let's keep arrays with nonzero stride but no used columns; they're + // needed to preserve the isomorphic nature of matching formats. But + // we'll toss arrays with 0 stride, which add nothing of value and only + // cause problems later. if (array_format->get_stride() == 0) { gobj_cat.warning() << "Dropping empty array from GeomVertexFormat.\n"; @@ -809,8 +711,8 @@ do_register() { } } - // Go back through the index now and identify the points, vectors, - // and morph descriptions, so we can quickly look these up later. + // Go back through the index now and identify the points, vectors, and morph + // descriptions, so we can quickly look these up later. DataTypesByName::iterator ni; for (ni = _columns_by_name.begin(); ni != _columns_by_name.end(); @@ -864,8 +766,7 @@ do_register() { break; default: - // Some other type of value we don't care about caching a - // pointer to. + // Some other type of value we don't care about caching a pointer to. break; } } @@ -880,11 +781,9 @@ do_register() { _color_column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::do_unregister -// Access: Private -// Description: Called internally when the format is unregistered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the format is unregistered. + */ void GeomVertexFormat:: do_unregister() { nassertv(_is_registered); @@ -903,23 +802,18 @@ do_unregister() { _post_animated_format = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// GeomVertexFormat. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type GeomVertexFormat. + */ void GeomVertexFormat:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomVertexFormat:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); @@ -933,13 +827,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomVertexFormat:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -952,15 +843,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type GeomVertexFormat is -// encountered in the Bam file. It should create the -// GeomVertexFormat and extract its information -// from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type GeomVertexFormat is encountered in the Bam file. It should create the + * GeomVertexFormat and extract its information from the file. + */ TypedWritable *GeomVertexFormat:: make_from_bam(const FactoryParams ¶ms) { GeomVertexFormat *object = new GeomVertexFormat; @@ -973,13 +860,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomVertexFormat. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomVertexFormat. + */ void GeomVertexFormat:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); @@ -994,20 +878,16 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Registry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomVertexFormat::Registry:: Registry() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Registry::make_standard_formats -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexFormat::Registry:: make_standard_formats() { _v3 = register_format(new GeomVertexArrayFormat @@ -1067,9 +947,9 @@ make_standard_formats() { InternalName::get_texcoord(), 2, NT_stdfloat, C_texcoord)); - // Define the OpenGL-style per-byte color formats. This is not the - // same as a packed format, above, because the resulting byte order - // is endian-independent. + // Define the OpenGL-style per-byte color formats. This is not the same as + // a packed format, above, because the resulting byte order is endian- + // independent. _v3c4 = register_format(new GeomVertexArrayFormat (InternalName::get_vertex(), 3, NT_stdfloat, C_point, @@ -1103,30 +983,25 @@ make_standard_formats() { NT_stdfloat, C_texcoord)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Registry::register_format -// Access: Public -// Description: Adds the indicated format to the registry, if there -// is not an equivalent format already there; in either -// case, returns the pointer to the equivalent format -// now in the registry. -// -// This must be called before a format may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated format to the registry, if there is not an equivalent + * format already there; in either case, returns the pointer to the equivalent + * format now in the registry. + * + * This must be called before a format may be used in a Geom. After this + * call, you should discard the original pointer you passed in (which may or + * may not now be invalid) and let its reference count decrement normally; you + * should use only the returned value from this point on. + */ CPT(GeomVertexFormat) GeomVertexFormat::Registry:: register_format(GeomVertexFormat *format) { if (format->is_registered()) { return format; } - // Save the incoming pointer in a local PointerTo, so that if it has - // a zero reference count and is not added into the map below, it - // will be automatically deleted when this function returns. + // Save the incoming pointer in a local PointerTo, so that if it has a zero + // reference count and is not added into the map below, it will be + // automatically deleted when this function returns. PT(GeomVertexFormat) pt_format = format; GeomVertexFormat *new_format; @@ -1146,15 +1021,12 @@ register_format(GeomVertexFormat *format) { return new_format; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexFormat::Registry::unregister_format -// Access: Public -// Description: Removes the indicated format from the registry. -// Normally this should not be done until the format is -// destructing. -// -// The lock should be held prior to calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated format from the registry. Normally this should not + * be done until the format is destructing. + * + * The lock should be held prior to calling this method. + */ void GeomVertexFormat::Registry:: unregister_format(GeomVertexFormat *format) { nassertv(format->is_registered()); diff --git a/panda/src/gobj/geomVertexFormat.h b/panda/src/gobj/geomVertexFormat.h index 9b84da3534..68ce5dda8b 100644 --- a/panda/src/gobj/geomVertexFormat.h +++ b/panda/src/gobj/geomVertexFormat.h @@ -1,16 +1,15 @@ -// Filename: geomVertexFormat.h -// Created by: drose (07Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexFormat.h + * @author drose + * @date 2005-03-07 + */ #ifndef GEOMVERTEXFORMAT_H #define GEOMVERTEXFORMAT_H @@ -33,31 +32,26 @@ class FactoryParams; class GeomVertexData; class GeomMunger; -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexFormat -// Description : This class defines the physical layout of the vertex -// data stored within a Geom. The layout consists of a -// list of named columns, each of which has a numeric -// type and a size. -// -// The columns are typically interleaved within a single -// array, but they may also be distributed among -// multiple different arrays; at the extreme, each -// column may be alone within its own array (which -// amounts to a parallel-array definition). -// -// Thus, a GeomVertexFormat is really a list of -// GeomVertexArrayFormats, each of which contains a list -// of columns. However, a particular column name should -// not appear more than once in the format, even between -// different arrays. -// -// There are a handful of standard pre-defined -// GeomVertexFormat objects, or you may define your own -// as needed. You may record any combination of -// standard and/or user-defined columns in your custom -// GeomVertexFormat constructions. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the physical layout of the vertex data stored within a + * Geom. The layout consists of a list of named columns, each of which has a + * numeric type and a size. + * + * The columns are typically interleaved within a single array, but they may + * also be distributed among multiple different arrays; at the extreme, each + * column may be alone within its own array (which amounts to a parallel-array + * definition). + * + * Thus, a GeomVertexFormat is really a list of GeomVertexArrayFormats, each + * of which contains a list of columns. However, a particular column name + * should not appear more than once in the format, even between different + * arrays. + * + * There are a handful of standard pre-defined GeomVertexFormat objects, or + * you may define your own as needed. You may record any combination of + * standard and/or user-defined columns in your custom GeomVertexFormat + * constructions. + */ class EXPCL_PANDA_GOBJ GeomVertexFormat FINAL : public TypedWritableReferenceCount, public GeomEnums { PUBLISHED: GeomVertexFormat(); @@ -131,30 +125,28 @@ PUBLISHED: void write_with_data(ostream &out, int indent_level, const GeomVertexData *data) const; - // Some standard vertex formats. No particular requirement to use - // one of these, but the DirectX renderers can use these formats - // directly, whereas any other format will have to be converted - // first. + // Some standard vertex formats. No particular requirement to use one of + // these, but the DirectX renderers can use these formats directly, whereas + // any other format will have to be converted first. INLINE static const GeomVertexFormat *get_v3(); INLINE static const GeomVertexFormat *get_v3n3(); INLINE static const GeomVertexFormat *get_v3t2(); INLINE static const GeomVertexFormat *get_v3n3t2(); - // These formats, with the DirectX-style packed color, may not be - // supported directly by OpenGL. If you use them and the driver - // does not support them, the GLGraphicsStateGuardian will - // automatically convert to native OpenGL form (with a small - // runtime overhead). + // These formats, with the DirectX-style packed color, may not be supported + // directly by OpenGL. If you use them and the driver does not support + // them, the GLGraphicsStateGuardian will automatically convert to native + // OpenGL form (with a small runtime overhead). INLINE static const GeomVertexFormat *get_v3cp(); INLINE static const GeomVertexFormat *get_v3cpt2(); INLINE static const GeomVertexFormat *get_v3n3cp(); INLINE static const GeomVertexFormat *get_v3n3cpt2(); - // These formats, with an OpenGL-style four-byte color, are not - // supported directly by DirectX. If you use them, the - // DXGraphicsStateGuardian will automatically convert to DirectX - // form (with a larger runtime overhead, since DirectX8, and old - // DirectX9 drivers, require everything to be interleaved together). + // These formats, with an OpenGL-style four-byte color, are not supported + // directly by DirectX. If you use them, the DXGraphicsStateGuardian will + // automatically convert to DirectX form (with a larger runtime overhead, + // since DirectX8, and old DirectX9 drivers, require everything to be + // interleaved together). INLINE static const GeomVertexFormat *get_v3c4(); INLINE static const GeomVertexFormat *get_v3c4t2(); INLINE static const GeomVertexFormat *get_v3n3c4(); diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index cd64794139..810f7e8f33 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/panda/src/gobj/geomVertexReader.I @@ -1,26 +1,21 @@ -// Filename: geomVertexReader.I -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexReader.I + * @author drose + * @date 2005-03-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Default Constructor -// Access: Published -// Description: Constructs an invalid GeomVertexReader. You must use -// the assignment operator to assign a valid -// GeomVertexReader to this object before you can use -// it. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid GeomVertexReader. You must use the assignment + * operator to assign a valid GeomVertexReader to this object before you can + * use it. + */ INLINE GeomVertexReader:: GeomVertexReader(Thread *current_thread) : _vertex_data(NULL), @@ -29,12 +24,10 @@ GeomVertexReader(Thread *current_thread) : initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Constructor -// Access: Published -// Description: Constructs a new reader to process the vertices of -// the indicated data object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new reader to process the vertices of the indicated data + * object. + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexData *vertex_data, Thread *current_thread) : @@ -44,13 +37,11 @@ GeomVertexReader(const GeomVertexData *vertex_data, initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Constructor -// Access: Published -// Description: Constructs a new reader to process the vertices of -// the indicated data object. This flavor creates the -// reader specifically to process the named data type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new reader to process the vertices of the indicated data + * object. This flavor creates the reader specifically to process the named + * data type. + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexData *vertex_data, CPT_InternalName name, @@ -62,12 +53,10 @@ GeomVertexReader(const GeomVertexData *vertex_data, set_column(MOVE(name)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Constructor -// Access: Published -// Description: Constructs a new reader to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new reader to process the vertices of the indicated array + * only. + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexArrayData *array_data, Thread *current_thread) : @@ -77,12 +66,10 @@ GeomVertexReader(const GeomVertexArrayData *array_data, initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Constructor -// Access: Published -// Description: Constructs a new reader to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new reader to process the vertices of the indicated array + * only. + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexArrayData *array_data, int column, Thread *current_thread) : @@ -93,13 +80,11 @@ GeomVertexReader(const GeomVertexArrayData *array_data, int column, set_column(column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Constructor -// Access: Public -// Description: Constructs a new reader to process the vertices of -// the indicated data object. This flavor creates the -// reader specifically to process the named data type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new reader to process the vertices of the indicated data + * object. This flavor creates the reader specifically to process the named + * data type. + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexDataPipelineReader *data_reader, const InternalName *name, bool force) : @@ -114,11 +99,9 @@ GeomVertexReader(const GeomVertexDataPipelineReader *data_reader, data_reader); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexReader:: GeomVertexReader(const GeomVertexReader ©) : _vertex_data(copy._vertex_data), @@ -136,11 +119,9 @@ GeomVertexReader(const GeomVertexReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexReader:: operator = (const GeomVertexReader ©) { _vertex_data = copy._vertex_data; @@ -157,119 +138,93 @@ operator = (const GeomVertexReader ©) { _force = copy._force; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexReader:: ~GeomVertexReader() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_vertex_data -// Access: Published -// Description: Returns the vertex data object that the -// reader is processing. This may return NULL if the -// reader was constructed with just an array pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex data object that the reader is processing. This may + * return NULL if the reader was constructed with just an array pointer. + */ INLINE const GeomVertexData *GeomVertexReader:: get_vertex_data() const { return _vertex_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_array_data -// Access: Published -// Description: Returns the particular array object that the -// reader is currently processing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular array object that the reader is currently + * processing. + */ INLINE const GeomVertexArrayData *GeomVertexReader:: get_array_data() const { return _array_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_array_handle -// Access: Published -// Description: Returns the read handle to the array object that the -// read is currently processing. This low-level call -// should be used with caution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the read handle to the array object that the read is currently + * processing. This low-level call should be used with caution. + */ INLINE const GeomVertexArrayDataHandle *GeomVertexReader:: get_array_handle() const { return _handle; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_stride -// Access: Published -// Description: Returns the per-row stride (bytes between consecutive -// rows) of the underlying vertex array. This low-level -// information is normally not needed to use the -// GeomVertexReader directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the per-row stride (bytes between consecutive rows) of the + * underlying vertex array. This low-level information is normally not needed + * to use the GeomVertexReader directly. + */ INLINE size_t GeomVertexReader:: get_stride() const { return _stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_current_thread -// Access: Published -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ INLINE Thread *GeomVertexReader:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_force -// Access: Published -// Description: Sets the value of the force flag. When this is true -// (the default), vertex data will be paged in from disk -// if necessary. When this is false, the GeomVertexData -// will simply return a failure code when attempting to -// read vertex data that is not resident (but will put -// it on the queue to become resident later). -// -// Normally, vertex data is always resident, so this -// will not be an issue. It is only possible for vertex -// data to be nonresident if you have enabled vertex -// paging via the GeomVertexArrayData and VertexDataPage -// interfaces. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the force flag. When this is true (the default), vertex + * data will be paged in from disk if necessary. When this is false, the + * GeomVertexData will simply return a failure code when attempting to read + * vertex data that is not resident (but will put it on the queue to become + * resident later). + * + * Normally, vertex data is always resident, so this will not be an issue. It + * is only possible for vertex data to be nonresident if you have enabled + * vertex paging via the GeomVertexArrayData and VertexDataPage interfaces. + */ INLINE void GeomVertexReader:: set_force(bool force) { _force = force; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_force -// Access: Published -// Description: Returns the value of the force flag. See -// set_force(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the force flag. See set_force(). + */ INLINE bool GeomVertexReader:: get_force() const { return _force; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_column -// Access: Published -// Description: Sets up the reader to use the nth data type of the -// GeomVertexFormat, numbering from 0. -// -// This also resets the read row number to the start row -// (the same value passed to a previous call to -// set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the reader to use the nth data type of the GeomVertexFormat, + * numbering from 0. + * + * This also resets the read row number to the start row (the same value + * passed to a previous call to set_row(), or 0 if set_row() was never + * called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexReader:: set_column(int column) { if (_vertex_data != (const GeomVertexData *)NULL) { @@ -286,19 +241,15 @@ set_column(int column) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_column -// Access: Published -// Description: Sets up the reader to use the data type with the -// indicated name. -// -// This also resets the read row number to the start row -// (the same value passed to a previous call to -// set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the reader to use the data type with the indicated name. + * + * This also resets the read row number to the start row (the same value + * passed to a previous call to set_row(), or 0 if set_row() was never + * called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexReader:: set_column(CPT_InternalName name) { if (_vertex_data != (const GeomVertexData *)NULL) { @@ -316,46 +267,36 @@ set_column(CPT_InternalName name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::clear -// Access: Published -// Description: Resets the GeomVertexReader to the initial state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the GeomVertexReader to the initial state. + */ INLINE void GeomVertexReader:: clear() { (*this) = GeomVertexReader(_current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::has_column -// Access: Published -// Description: Returns true if a valid data type has been -// successfully set, or false if the data type does not -// exist (or if get_force() is false and the vertex data -// is nonresident). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a valid data type has been successfully set, or false if + * the data type does not exist (or if get_force() is false and the vertex + * data is nonresident). + */ INLINE bool GeomVertexReader:: has_column() const { return (_packer != (GeomVertexColumn::Packer *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_array -// Access: Published -// Description: Returns the array index containing the data type that -// the reader is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index containing the data type that the reader is working + * on. + */ INLINE int GeomVertexReader:: get_array() const { return _array; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_column -// Access: Published -// Description: Returns the description of the data type that the -// reader is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the description of the data type that the reader is working on. + */ INLINE const GeomVertexColumn *GeomVertexReader:: get_column() const { if (_packer != (GeomVertexColumn::Packer *)NULL) { @@ -364,17 +305,13 @@ get_column() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_row_unsafe -// Access: Published -// Description: Sets the start row to the indicated value, without -// internal checks. This is the same as set_row(), but -// it does not check for the possibility that the array -// has been reallocated internally for some reason; use -// only when you are confident that the array is -// unchanged and you really need every bit of available -// performance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start row to the indicated value, without internal checks. This + * is the same as set_row(), but it does not check for the possibility that + * the array has been reallocated internally for some reason; use only when + * you are confident that the array is unchanged and you really need every bit + * of available performance. + */ INLINE void GeomVertexReader:: set_row_unsafe(int row) { _start_row = row; @@ -383,15 +320,12 @@ set_row_unsafe(int row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_row -// Access: Published -// Description: Sets the start row to the indicated value. The -// reader will begin reading from the indicated row; -// each subsequent get_data*() call will return the data -// from the subsequent row. If set_column() is called, -// the reader will return to this row. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start row to the indicated value. The reader will begin reading + * from the indicated row; each subsequent get_data*() call will return the + * data from the subsequent row. If set_column() is called, the reader will + * return to this row. + */ INLINE void GeomVertexReader:: set_row(int row) { _start_row = row; @@ -401,102 +335,79 @@ set_row(int row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_start_row -// Access: Published -// Description: Returns the row index at which the reader started. -// It will return to this row if you reset the current -// column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the row index at which the reader started. It will return to this + * row if you reset the current column. + */ INLINE int GeomVertexReader:: get_start_row() const { return _start_row; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_read_row -// Access: Published -// Description: Returns the row index from which the data will be -// retrieved by the next call to get_data*(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the row index from which the data will be retrieved by the next + * call to get_data*(). + */ INLINE int GeomVertexReader:: get_read_row() const { return (int)(_pointer - _pointer_begin) / _stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::is_at_end -// Access: Published -// Description: Returns true if the reader is currently at the end of -// the list of vertices, false otherwise. If this is -// true, another call to get_data*() will result in a -// crash. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader is currently at the end of the list of vertices, + * false otherwise. If this is true, another call to get_data*() will result + * in a crash. + */ INLINE bool GeomVertexReader:: is_at_end() const { return _pointer >= _pointer_end; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data1f -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 1-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 1-component + * value, and advances the read row. + */ INLINE float GeomVertexReader:: get_data1f() { nassertr(has_column(), 0.0f); return _packer->get_data1f(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data2f -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 2-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 2-component + * value, and advances the read row. + */ INLINE const LVecBase2f &GeomVertexReader:: get_data2f() { nassertr(has_column(), LVecBase2f::zero()); return _packer->get_data2f(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data3f -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 3-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 3-component + * value, and advances the read row. + */ INLINE const LVecBase3f &GeomVertexReader:: get_data3f() { nassertr(has_column(), LVecBase3f::zero()); return _packer->get_data3f(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data4f -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 4-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 4-component + * value, and advances the read row. + */ INLINE const LVecBase4f &GeomVertexReader:: get_data4f() { nassertr(has_column(), LVecBase4f::zero()); return _packer->get_data4f(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix3f -// Access: Published -// Description: Returns the 3-by-3 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-by-3 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix3f GeomVertexReader:: get_matrix3f() { nassertr(has_column() && @@ -516,14 +427,11 @@ get_matrix3f() { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix4f -// Access: Published -// Description: Returns the 4-by-4 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 4-by-4 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix4f GeomVertexReader:: get_matrix4f() { nassertr(has_column() && @@ -545,66 +453,51 @@ get_matrix4f() { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data1d -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 1-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 1-component + * value, and advances the read row. + */ INLINE double GeomVertexReader:: get_data1d() { nassertr(has_column(), 0.0f); return _packer->get_data1d(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data2d -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 2-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 2-component + * value, and advances the read row. + */ INLINE const LVecBase2d &GeomVertexReader:: get_data2d() { nassertr(has_column(), LVecBase2d::zero()); return _packer->get_data2d(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data3d -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 3-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 3-component + * value, and advances the read row. + */ INLINE const LVecBase3d &GeomVertexReader:: get_data3d() { nassertr(has_column(), LVecBase3d::zero()); return _packer->get_data3d(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data4d -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 4-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 4-component + * value, and advances the read row. + */ INLINE const LVecBase4d &GeomVertexReader:: get_data4d() { nassertr(has_column(), LVecBase4d::zero()); return _packer->get_data4d(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix3d -// Access: Published -// Description: Returns the 3-by-3 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-by-3 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix3d GeomVertexReader:: get_matrix3d() { nassertr(has_column() && @@ -624,14 +517,11 @@ get_matrix3d() { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix4d -// Access: Published -// Description: Returns the 4-by-4 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 4-by-4 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix4d GeomVertexReader:: get_matrix4d() { nassertr(has_column() && @@ -653,13 +543,10 @@ get_matrix4d() { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data1 -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 1-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 1-component + * value, and advances the read row. + */ INLINE PN_stdfloat GeomVertexReader:: get_data1() { #ifndef STDFLOAT_DOUBLE @@ -669,13 +556,10 @@ get_data1() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data2 -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 2-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 2-component + * value, and advances the read row. + */ INLINE const LVecBase2 &GeomVertexReader:: get_data2() { #ifndef STDFLOAT_DOUBLE @@ -685,13 +569,10 @@ get_data2() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data3 -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 3-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 3-component + * value, and advances the read row. + */ INLINE const LVecBase3 &GeomVertexReader:: get_data3() { #ifndef STDFLOAT_DOUBLE @@ -701,13 +582,10 @@ get_data3() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data4 -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 4-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 4-component + * value, and advances the read row. + */ INLINE const LVecBase4 &GeomVertexReader:: get_data4() { #ifndef STDFLOAT_DOUBLE @@ -717,14 +595,11 @@ get_data4() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix3 -// Access: Published -// Description: Returns the 3-by-3 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-by-3 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix3 GeomVertexReader:: get_matrix3() { #ifndef STDFLOAT_DOUBLE @@ -734,14 +609,11 @@ get_matrix3() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_matrix4 -// Access: Published -// Description: Returns the 4-by-4 matrix associated with the read -// row and advances the read row. This is a special -// method that only works when the column in question -// contains a matrix of an appropriate size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 4-by-4 matrix associated with the read row and advances the + * read row. This is a special method that only works when the column in + * question contains a matrix of an appropriate size. + */ INLINE LMatrix4 GeomVertexReader:: get_matrix4() { #ifndef STDFLOAT_DOUBLE @@ -751,80 +623,63 @@ get_matrix4() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data1i -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 1-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 1-component + * value, and advances the read row. + */ INLINE int GeomVertexReader:: get_data1i() { nassertr(has_column(), 0); return _packer->get_data1i(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data2i -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 2-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 2-component + * value, and advances the read row. + */ INLINE const LVecBase2i &GeomVertexReader:: get_data2i() { nassertr(has_column(), LVecBase2i::zero()); return _packer->get_data2i(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data3i -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 3-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 3-component + * value, and advances the read row. + */ INLINE const LVecBase3i &GeomVertexReader:: get_data3i() { nassertr(has_column(), LVecBase3i::zero()); return _packer->get_data3i(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_data4i -// Access: Published -// Description: Returns the data associated with the read row, -// expressed as a 4-component value, and advances the -// read row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the read row, expressed as a 4-component + * value, and advances the read row. + */ INLINE const LVecBase4i &GeomVertexReader:: get_data4i() { nassertr(has_column(), LVecBase4i::zero()); return _packer->get_data4i(inc_pointer()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::get_packer -// Access: Protected -// Description: Returns the reader's Packer object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reader's Packer object. + */ INLINE GeomVertexColumn::Packer *GeomVertexReader:: get_packer() const { return _packer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_pointer -// Access: Private -// Description: Sets up the array pointers freshly from the source -// object (in case they have been reallocated recently), -// and sets the internal pointer to the indicated row. -// -// Returns true if successful, or false if the vertex -// data is not resident. If it returns false, the -// reader's internal column spec is cleared. It is only -// possible to return false if get_force() is false. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the array pointers freshly from the source object (in case they + * have been reallocated recently), and sets the internal pointer to the + * indicated row. + * + * Returns true if successful, or false if the vertex data is not resident. + * If it returns false, the reader's internal column spec is cleared. It is + * only possible to return false if get_force() is false. + */ INLINE bool GeomVertexReader:: set_pointer(int row) { _pointer_begin = _handle->get_read_pointer(_force); @@ -840,13 +695,10 @@ set_pointer(int row) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::quick_set_pointer -// Access: Private -// Description: Sets up the internal pointer to the indicated row, -// without first verifying that arrays haven't been -// reallocated. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the internal pointer to the indicated row, without first verifying + * that arrays haven't been reallocated. + */ INLINE void GeomVertexReader:: quick_set_pointer(int row) { nassertv(has_column() && (_pointer_begin != NULL || row == 0)); @@ -859,19 +711,17 @@ quick_set_pointer(int row) { _pointer = _pointer_begin + _packer->_column->get_start() + _stride * row; #if defined(_DEBUG) - // We have to allow the pointer to exceed the end by up to one row's - // width. This wouldn't be legal on a plain GeomVertexReader, but - // it *is* legal for a GeomVertexRewriter. + // We have to allow the pointer to exceed the end by up to one row's width. + // This wouldn't be legal on a plain GeomVertexReader, but it *is* legal for + // a GeomVertexRewriter. nassertv(_pointer_begin == _pointer_end || (_pointer - _packer->_column->get_start()) <= _pointer_end); #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::inc_pointer -// Access: Private -// Description: Increments to the next row, and returns the data -// pointer as it was before incrementing. -//////////////////////////////////////////////////////////////////// +/** + * Increments to the next row, and returns the data pointer as it was before + * incrementing. + */ INLINE const unsigned char *GeomVertexReader:: inc_pointer() { #if defined(_DEBUG) diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index 2920342ffd..054e7df942 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/panda/src/gobj/geomVertexReader.cxx @@ -1,39 +1,35 @@ -// Filename: geomVertexReader.cxx -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexReader.cxx + * @author drose + * @date 2005-03-25 + */ #include "geomVertexReader.h" #ifndef NDEBUG - // This is defined just for the benefit of having something non-NULL - // to return from a nassertr() call. + // This is defined just for the benefit of having something non-NULL to + // return from a nassertr() call. const unsigned char GeomVertexReader::empty_buffer[100] = { 0 }; #endif -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_column -// Access: Published -// Description: Sets up the reader to use the indicated column -// description on the given array. -// -// This also resets the current read row number to the -// start row (the same value passed to a previous call -// to set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the reader to use the indicated column description on the given + * array. + * + * This also resets the current read row number to the start row (the same + * value passed to a previous call to set_row(), or 0 if set_row() was never + * called.) + * + * The return value is true if the data type is valid, false otherwise. + */ bool GeomVertexReader:: set_column(int array, const GeomVertexColumn *column) { if (column == (const GeomVertexColumn *)NULL) { @@ -60,17 +56,15 @@ set_column(int array, const GeomVertexColumn *column) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexReader:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == (GeomVertexColumn *)NULL) { out << "GeomVertexReader()"; - + } else { out << "GeomVertexReader, array = " << get_array_data() << ", column = " << column->get_name() @@ -79,11 +73,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::initialize -// Access: Private -// Description: Called only by the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Called only by the constructor. + */ void GeomVertexReader:: initialize() { _array = 0; @@ -95,12 +87,10 @@ initialize() { _force = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_vertex_column -// Access: Private -// Description: Internal method to set the column to column from the -// indicated array, assuming we have a GeomVertexData -//////////////////////////////////////////////////////////////////// +/** + * Internal method to set the column to column from the indicated array, + * assuming we have a GeomVertexData + */ bool GeomVertexReader:: set_vertex_column(int array, const GeomVertexColumn *column, const GeomVertexDataPipelineReader *data_reader) { @@ -124,13 +114,10 @@ set_vertex_column(int array, const GeomVertexColumn *column, return set_pointer(_start_row); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexReader::set_array_column -// Access: Private -// Description: Internal method to set the column to column from the -// indicated array, assuming we have a -// GeomVertexArrayData. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to set the column to column from the indicated array, + * assuming we have a GeomVertexArrayData. + */ bool GeomVertexReader:: set_array_column(const GeomVertexColumn *column) { if (column == (const GeomVertexColumn *)NULL) { diff --git a/panda/src/gobj/geomVertexReader.h b/panda/src/gobj/geomVertexReader.h index 04f7a9a823..f657975a63 100644 --- a/panda/src/gobj/geomVertexReader.h +++ b/panda/src/gobj/geomVertexReader.h @@ -1,16 +1,15 @@ -// Filename: geomVertexReader.h -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexReader.h + * @author drose + * @date 2005-03-25 + */ #ifndef GEOMVERTEXREADER_H #define GEOMVERTEXREADER_H @@ -22,37 +21,29 @@ #include "luse.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexReader -// Description : This object provides a high-level interface for -// quickly reading a sequence of numeric values from a -// vertex table. -// -// It is particularly optimized for reading a single -// column of data values for a series of vertices, -// without changing columns between each number. -// Although you can also use one GeomVertexReader to -// read across the columns if it is convenient, by -// calling set_column() repeatedly at each vertex, it is -// faster to read down the columns, and to use a -// different GeomVertexReader for each column. -// -// Note that a GeomVertexReader does not keep a -// reference count to the actual vertex data buffer (it -// grabs the current data buffer from the GeomVertexData -// whenever set_column() is called). This means that it -// is important not to keep a GeomVertexReader object -// around over a long period of time in which the data -// buffer is likely to be deallocated; it is intended -// for making a quick pass over the data in one session. -// -// It also means that you should create any -// GeomVertexWriters *before* creating GeomVertexReaders -// on the same data, since the writer itself might cause -// the vertex buffer to be deallocated. Better yet, use -// a GeomVertexRewriter if you are going to create both -// of them anyway. -//////////////////////////////////////////////////////////////////// +/** + * This object provides a high-level interface for quickly reading a sequence + * of numeric values from a vertex table. + * + * It is particularly optimized for reading a single column of data values for + * a series of vertices, without changing columns between each number. + * Although you can also use one GeomVertexReader to read across the columns + * if it is convenient, by calling set_column() repeatedly at each vertex, it + * is faster to read down the columns, and to use a different GeomVertexReader + * for each column. + * + * Note that a GeomVertexReader does not keep a reference count to the actual + * vertex data buffer (it grabs the current data buffer from the + * GeomVertexData whenever set_column() is called). This means that it is + * important not to keep a GeomVertexReader object around over a long period + * of time in which the data buffer is likely to be deallocated; it is + * intended for making a quick pass over the data in one session. + * + * It also means that you should create any GeomVertexWriters *before* + * creating GeomVertexReaders on the same data, since the writer itself might + * cause the vertex buffer to be deallocated. Better yet, use a + * GeomVertexRewriter if you are going to create both of them anyway. + */ class EXPCL_PANDA_GOBJ GeomVertexReader : public GeomEnums { PUBLISHED: INLINE GeomVertexReader(Thread *current_thread = Thread::get_current_thread()); @@ -144,11 +135,10 @@ private: const GeomVertexDataPipelineReader *data_reader); bool set_array_column(const GeomVertexColumn *column); - // It is important that we only store *one* of the following two - // pointers. If we are storing a GeomVertexData/array index, we - // must not keep a pointer to the particular ArrayData we are - // working on (if we do, it may result in an extra copy of the data - // due to holding the reference count). + // It is important that we only store *one* of the following two pointers. + // If we are storing a GeomVertexDataarray index, we must not keep a pointer + // to the particular ArrayData we are working on (if we do, it may result in + // an extra copy of the data due to holding the reference count). CPT(GeomVertexData) _vertex_data; int _array; CPT(GeomVertexArrayData) _array_data; @@ -166,8 +156,8 @@ private: bool _force; #ifndef NDEBUG - // This is defined just for the benefit of having something non-NULL - // to return from a nassertr() call. + // This is defined just for the benefit of having something non-NULL to + // return from a nassertr() call. static const unsigned char empty_buffer[100]; #endif }; diff --git a/panda/src/gobj/geomVertexRewriter.I b/panda/src/gobj/geomVertexRewriter.I index 89f6a55743..933c545885 100644 --- a/panda/src/gobj/geomVertexRewriter.I +++ b/panda/src/gobj/geomVertexRewriter.I @@ -1,26 +1,21 @@ -// Filename: geomVertexRewriter.I -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexRewriter.I + * @author drose + * @date 2005-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Default Constructor -// Access: Published -// Description: Constructs an invalid GeomVertexRewriter. You must use -// the assignment operator to assign a valid -// GeomVertexRewriter to this object before you can use -// it. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid GeomVertexRewriter. You must use the assignment + * operator to assign a valid GeomVertexRewriter to this object before you can + * use it. + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(Thread *current_thread) : GeomVertexWriter(current_thread), @@ -28,12 +23,10 @@ GeomVertexRewriter(Thread *current_thread) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Constructor -// Access: Published -// Description: Constructs a new rewriter to process the vertices of -// the indicated data object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new rewriter to process the vertices of the indicated data + * object. + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) : GeomVertexWriter(vertex_data, current_thread), @@ -41,13 +34,11 @@ GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Constructor -// Access: Published -// Description: Constructs a new rewriter to process the vertices of -// the indicated data object. This flavor creates the -// rewriter specifically to process the named data type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new rewriter to process the vertices of the indicated data + * object. This flavor creates the rewriter specifically to process the named + * data type. + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(GeomVertexData *vertex_data, CPT_InternalName name, Thread *current_thread) : @@ -57,12 +48,10 @@ GeomVertexRewriter(GeomVertexData *vertex_data, CPT_InternalName name, set_column(MOVE(name)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Constructor -// Access: Published -// Description: Constructs a new rewriter to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new rewriter to process the vertices of the indicated array + * only. + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) : GeomVertexWriter(array_data, current_thread), @@ -70,12 +59,10 @@ GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Constructor -// Access: Published -// Description: Constructs a new rewriter to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new rewriter to process the vertices of the indicated array + * only. + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(GeomVertexArrayData *array_data, int column, Thread *current_thread) : @@ -85,11 +72,9 @@ GeomVertexRewriter(GeomVertexArrayData *array_data, int column, set_column(column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexRewriter:: GeomVertexRewriter(const GeomVertexRewriter ©) : GeomVertexWriter(copy), @@ -97,107 +82,86 @@ GeomVertexRewriter(const GeomVertexRewriter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexRewriter:: operator = (const GeomVertexRewriter ©) { GeomVertexWriter::operator = (copy); GeomVertexReader::operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexRewriter:: ~GeomVertexRewriter() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_vertex_data -// Access: Published -// Description: Returns the vertex data object that the -// rewriter is processing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex data object that the rewriter is processing. + */ INLINE GeomVertexData *GeomVertexRewriter:: get_vertex_data() const { - nassertr(GeomVertexWriter::get_vertex_data() == + nassertr(GeomVertexWriter::get_vertex_data() == GeomVertexReader::get_vertex_data(), NULL); return GeomVertexWriter::get_vertex_data(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_array_data -// Access: Published -// Description: Returns the particular array object that the -// rewriter is currently processing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular array object that the rewriter is currently + * processing. + */ INLINE GeomVertexArrayData *GeomVertexRewriter:: get_array_data() const { - nassertr(GeomVertexWriter::get_array_data() == + nassertr(GeomVertexWriter::get_array_data() == GeomVertexReader::get_array_data(), NULL); return GeomVertexWriter::get_array_data(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_array_handle -// Access: Published -// Description: Returns the write handle to the array object that the -// rewriter is currently processing. This low-level call -// should be used with caution; be careful with -// modifying the data in the handle out from under the -// GeomVertexRewriter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the write handle to the array object that the rewriter is currently + * processing. This low-level call should be used with caution; be careful + * with modifying the data in the handle out from under the + * GeomVertexRewriter. + */ INLINE GeomVertexArrayDataHandle *GeomVertexRewriter:: get_array_handle() const { return GeomVertexWriter::get_array_handle(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_stride -// Access: Published -// Description: Returns the per-row stride (bytes between consecutive -// rows) of the underlying vertex array. This low-level -// information is normally not needed to use the -// GeomVertexRewriter directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the per-row stride (bytes between consecutive rows) of the + * underlying vertex array. This low-level information is normally not needed + * to use the GeomVertexRewriter directly. + */ INLINE size_t GeomVertexRewriter:: get_stride() const { nassertr(GeomVertexWriter::get_stride() == GeomVertexReader::get_stride(), 0); return GeomVertexWriter::get_stride(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_current_thread -// Access: Published -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ INLINE Thread *GeomVertexRewriter:: get_current_thread() const { - nassertr(GeomVertexWriter::get_current_thread() == + nassertr(GeomVertexWriter::get_current_thread() == GeomVertexReader::get_current_thread(), NULL); return GeomVertexWriter::get_current_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::set_column -// Access: Published -// Description: Sets up the rewriter to use the nth data type of the -// GeomVertexFormat, numbering from 0. -// -// This also resets both the read and write row -// numbers to the start row (the same value passed to -// a previous call to set_row(), or 0 if set_row() -// was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the rewriter to use the nth data type of the GeomVertexFormat, + * numbering from 0. + * + * This also resets both the read and write row numbers to the start row (the + * same value passed to a previous call to set_row(), or 0 if set_row() was + * never called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexRewriter:: set_column(int column) { // It's important to invoke the writer first, then the reader. See @@ -206,20 +170,15 @@ set_column(int column) { return GeomVertexReader::set_column(column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::set_column -// Access: Published -// Description: Sets up the rewriter to use the data type with the -// indicated name. -// -// This also resets both the read and write row -// numbers to the start row (the same value passed to -// a previous call to set_row(), or 0 if set_row() -// was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the rewriter to use the data type with the indicated name. + * + * This also resets both the read and write row numbers to the start row (the + * same value passed to a previous call to set_row(), or 0 if set_row() was + * never called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexRewriter:: set_column(CPT_InternalName name) { // It's important to invoke the writer first, then the reader. See @@ -228,20 +187,16 @@ set_column(CPT_InternalName name) { return GeomVertexReader::set_column(MOVE(name)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::set_column -// Access: Published -// Description: Sets up the rewriter to use the indicated column -// description on the given array. -// -// This also resets both the read and write row -// numbers to the start row (the same value passed to -// a previous call to set_row(), or 0 if set_row() -// was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the rewriter to use the indicated column description on the given + * array. + * + * This also resets both the read and write row numbers to the start row (the + * same value passed to a previous call to set_row(), or 0 if set_row() was + * never called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexRewriter:: set_column(int array, const GeomVertexColumn *column) { // It's important to invoke the writer first, then the reader. See @@ -250,110 +205,88 @@ set_column(int array, const GeomVertexColumn *column) { return GeomVertexReader::set_column(array, column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::clear -// Access: Published -// Description: Resets the GeomVertexRewriter to the initial state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the GeomVertexRewriter to the initial state. + */ INLINE void GeomVertexRewriter:: clear() { GeomVertexWriter::clear(); GeomVertexReader::clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::has_column -// Access: Published -// Description: Returns true if a valid data type has been -// successfully set, or false if the data type does not -// exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a valid data type has been successfully set, or false if + * the data type does not exist. + */ INLINE bool GeomVertexRewriter:: has_column() const { - nassertr(GeomVertexWriter::get_column() == + nassertr(GeomVertexWriter::get_column() == GeomVertexReader::get_column(), false); return GeomVertexWriter::has_column(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_array -// Access: Published -// Description: Returns the array index containing the data type that -// the rewriter is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index containing the data type that the rewriter is + * working on. + */ INLINE int GeomVertexRewriter:: get_array() const { - nassertr(GeomVertexWriter::get_array() == + nassertr(GeomVertexWriter::get_array() == GeomVertexReader::get_array(), -1); return GeomVertexWriter::get_array(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_column -// Access: Published -// Description: Returns the description of the data type that the -// rewriter is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the description of the data type that the rewriter is working on. + */ INLINE const GeomVertexColumn *GeomVertexRewriter:: get_column() const { - nassertr(GeomVertexWriter::get_column() == + nassertr(GeomVertexWriter::get_column() == GeomVertexReader::get_column(), NULL); return GeomVertexWriter::get_column(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::set_row_unsafe -// Access: Published -// Description: Sets the start row to the indicated value, without -// internal checks. This is the same as set_row(), but -// it does not check for the possibility that the array -// has been reallocated internally for some reason; use -// only when you are confident that the array is -// unchanged and you really need every bit of available -// performance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start row to the indicated value, without internal checks. This + * is the same as set_row(), but it does not check for the possibility that + * the array has been reallocated internally for some reason; use only when + * you are confident that the array is unchanged and you really need every bit + * of available performance. + */ INLINE void GeomVertexRewriter:: set_row_unsafe(int row) { - // It's important to invoke the Writer first, since that might force - // a recopy of the array, which might invalidate the pointer already - // stored by the Reader if we invoked the Reader first. + // It's important to invoke the Writer first, since that might force a + // recopy of the array, which might invalidate the pointer already stored by + // the Reader if we invoked the Reader first. GeomVertexWriter::set_row_unsafe(row); GeomVertexReader::set_row_unsafe(row); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::set_row -// Access: Published -// Description: Sets the start, write, and write index to the -// indicated value. The rewriter will begin traversing -// from the given row. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start, write, and write index to the indicated value. The + * rewriter will begin traversing from the given row. + */ INLINE void GeomVertexRewriter:: set_row(int row) { GeomVertexWriter::set_row(row); GeomVertexReader::set_row(row); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::get_start_row -// Access: Published -// Description: Returns the row index at which the rewriter -// started. It will return to this row if you reset -// the current column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the row index at which the rewriter started. It will return to + * this row if you reset the current column. + */ INLINE int GeomVertexRewriter:: get_start_row() const { - nassertr(GeomVertexWriter::get_start_row() == + nassertr(GeomVertexWriter::get_start_row() == GeomVertexReader::get_start_row(), 0); return GeomVertexWriter::get_start_row(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::is_at_end -// Access: Published -// Description: Returns true if the reader or writer is currently at -// the end of the list of vertices, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader or writer is currently at the end of the list of + * vertices, false otherwise. + */ INLINE bool GeomVertexRewriter:: is_at_end() const { return GeomVertexWriter::is_at_end() || GeomVertexReader::is_at_end(); diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index cc329a56c2..304606a9c3 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/panda/src/gobj/geomVertexRewriter.cxx @@ -1,30 +1,27 @@ -// Filename: geomVertexRewriter.cxx -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexRewriter.cxx + * @author drose + * @date 2005-03-28 + */ #include "geomVertexRewriter.h" -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexRewriter::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexRewriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == (GeomVertexColumn *)NULL) { out << "GeomVertexRewriter()"; - + } else { out << "GeomVertexRewriter, array = " << get_array_data() << ", column = " << column->get_name() diff --git a/panda/src/gobj/geomVertexRewriter.h b/panda/src/gobj/geomVertexRewriter.h index 5e180b357e..d9291ea06a 100644 --- a/panda/src/gobj/geomVertexRewriter.h +++ b/panda/src/gobj/geomVertexRewriter.h @@ -1,16 +1,15 @@ -// Filename: geomVertexRewriter.h -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexRewriter.h + * @author drose + * @date 2005-03-28 + */ #ifndef GEOMVERTEXREWRITER_H #define GEOMVERTEXREWRITER_H @@ -19,23 +18,18 @@ #include "geomVertexReader.h" #include "geomVertexWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexRewriter -// Description : This object provides the functionality of both a -// GeomVertexReader and a GeomVertexWriter, combined -// together into one convenient package. It is designed -// for making a single pass over a GeomVertexData -// object, modifying rows as it goes. -// -// Although it doesn't provide any real performance -// benefit over using a separate reader and writer on -// the same data, it should probably be used in -// preference to a separate reader and writer, because -// it makes an effort to manage the reference counts -// properly between the reader and the writer to avoid -// accidentally dereferencing either array while -// recopying. -//////////////////////////////////////////////////////////////////// +/** + * This object provides the functionality of both a GeomVertexReader and a + * GeomVertexWriter, combined together into one convenient package. It is + * designed for making a single pass over a GeomVertexData object, modifying + * rows as it goes. + * + * Although it doesn't provide any real performance benefit over using a + * separate reader and writer on the same data, it should probably be used in + * preference to a separate reader and writer, because it makes an effort to + * manage the reference counts properly between the reader and the writer to + * avoid accidentally dereferencing either array while recopying. + */ class EXPCL_PANDA_GOBJ GeomVertexRewriter : public GeomVertexWriter, public GeomVertexReader { PUBLISHED: INLINE GeomVertexRewriter(Thread *current_thread = Thread::get_current_thread()); diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index 708ce474a1..d3e1da87a3 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/panda/src/gobj/geomVertexWriter.I @@ -1,26 +1,21 @@ -// Filename: geomVertexWriter.I -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexWriter.I + * @author drose + * @date 2005-03-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Default Constructor -// Access: Published -// Description: Constructs an invalid GeomVertexWriter. You must use -// the assignment operator to assign a valid -// GeomVertexWriter to this object before you can use -// it. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid GeomVertexWriter. You must use the assignment + * operator to assign a valid GeomVertexWriter to this object before you can + * use it. + */ INLINE GeomVertexWriter:: GeomVertexWriter(Thread *current_thread) : _vertex_data(NULL), @@ -29,12 +24,10 @@ GeomVertexWriter(Thread *current_thread) : initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Constructor -// Access: Published -// Description: Constructs a new writer to process the vertices of -// the indicated data object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new writer to process the vertices of the indicated data + * object. + */ INLINE GeomVertexWriter:: GeomVertexWriter(GeomVertexData *vertex_data, Thread *current_thread) : _vertex_data(vertex_data), @@ -43,13 +36,11 @@ GeomVertexWriter(GeomVertexData *vertex_data, Thread *current_thread) : initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Constructor -// Access: Published -// Description: Constructs a new writer to process the vertices of -// the indicated data object. This flavor creates the -// writer specifically to process the named data type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new writer to process the vertices of the indicated data + * object. This flavor creates the writer specifically to process the named + * data type. + */ INLINE GeomVertexWriter:: GeomVertexWriter(GeomVertexData *vertex_data, CPT_InternalName name, Thread *current_thread) : @@ -60,12 +51,10 @@ GeomVertexWriter(GeomVertexData *vertex_data, CPT_InternalName name, set_column(MOVE(name)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Constructor -// Access: Published -// Description: Constructs a new writer to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new writer to process the vertices of the indicated array + * only. + */ INLINE GeomVertexWriter:: GeomVertexWriter(GeomVertexArrayData *array_data, Thread *current_thread) : @@ -75,12 +64,10 @@ GeomVertexWriter(GeomVertexArrayData *array_data, initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Constructor -// Access: Published -// Description: Constructs a new writer to process the vertices of -// the indicated array only. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new writer to process the vertices of the indicated array + * only. + */ INLINE GeomVertexWriter:: GeomVertexWriter(GeomVertexArrayData *array_data, int column, Thread *current_thread) : @@ -91,13 +78,11 @@ GeomVertexWriter(GeomVertexArrayData *array_data, int column, set_column(column); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Constructor -// Access: Public -// Description: Constructs a new writer to process the vertices of -// the indicated data object. This flavor creates the -// writer specifically to process the named data type. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new writer to process the vertices of the indicated data + * object. This flavor creates the writer specifically to process the named + * data type. + */ INLINE GeomVertexWriter:: GeomVertexWriter(GeomVertexDataPipelineWriter *data_writer, const InternalName *name) : @@ -111,11 +96,9 @@ GeomVertexWriter(GeomVertexDataPipelineWriter *data_writer, data_writer); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexWriter:: GeomVertexWriter(const GeomVertexWriter ©) : _vertex_data(copy._vertex_data), @@ -132,11 +115,9 @@ GeomVertexWriter(const GeomVertexWriter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomVertexWriter:: operator = (const GeomVertexWriter ©) { _vertex_data = copy._vertex_data; @@ -152,89 +133,70 @@ operator = (const GeomVertexWriter ©) { _start_row = copy._start_row; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomVertexWriter:: ~GeomVertexWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_vertex_data -// Access: Published -// Description: Returns the vertex data object that the -// writer is processing. This may return NULL if the -// writer was constructed with just an array pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex data object that the writer is processing. This may + * return NULL if the writer was constructed with just an array pointer. + */ INLINE GeomVertexData *GeomVertexWriter:: get_vertex_data() const { return _vertex_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_array_data -// Access: Published -// Description: Returns the particular array object that the -// writer is currently processing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular array object that the writer is currently + * processing. + */ INLINE GeomVertexArrayData *GeomVertexWriter:: get_array_data() const { return _array_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_array_handle -// Access: Published -// Description: Returns the write handle to the array object that the -// writer is currently processing. This low-level call -// should be used with caution; be careful with -// modifying the data in the handle out from under the -// GeomVertexWriter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the write handle to the array object that the writer is currently + * processing. This low-level call should be used with caution; be careful + * with modifying the data in the handle out from under the GeomVertexWriter. + */ INLINE GeomVertexArrayDataHandle *GeomVertexWriter:: get_array_handle() const { return _handle; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_stride -// Access: Published -// Description: Returns the per-row stride (bytes between consecutive -// rows) of the underlying vertex array. This low-level -// information is normally not needed to use the -// GeomVertexWriter directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the per-row stride (bytes between consecutive rows) of the + * underlying vertex array. This low-level information is normally not needed + * to use the GeomVertexWriter directly. + */ INLINE size_t GeomVertexWriter:: get_stride() const { return _stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_current_thread -// Access: Published -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ INLINE Thread *GeomVertexWriter:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_column -// Access: Published -// Description: Sets up the writer to use the nth data type of the -// GeomVertexFormat, numbering from 0. -// -// This also resets the write row number to the start -// row (the same value passed to a previous call to -// set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the writer to use the nth data type of the GeomVertexFormat, + * numbering from 0. + * + * This also resets the write row number to the start row (the same value + * passed to a previous call to set_row(), or 0 if set_row() was never + * called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexWriter:: set_column(int column) { if (_vertex_data != (GeomVertexData *)NULL) { @@ -251,19 +213,14 @@ set_column(int column) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_column -// Access: Published -// Description: Sets up the writer to use the data type with the -// indicated name. -// -// This also resets the write number to the start row -// (the same value passed to a previous call to -// set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the writer to use the data type with the indicated name. + * + * This also resets the write number to the start row (the same value passed + * to a previous call to set_row(), or 0 if set_row() was never called.) + * + * The return value is true if the data type is valid, false otherwise. + */ INLINE bool GeomVertexWriter:: set_column(CPT_InternalName name) { if (_vertex_data != (GeomVertexData *)NULL) { @@ -280,45 +237,35 @@ set_column(CPT_InternalName name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::clear -// Access: Published -// Description: Resets the GeomVertexWriter to the initial state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the GeomVertexWriter to the initial state. + */ INLINE void GeomVertexWriter:: clear() { (*this) = GeomVertexWriter(_current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::has_column -// Access: Published -// Description: Returns true if a valid data type has been -// successfully set, or false if the data type does not -// exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a valid data type has been successfully set, or false if + * the data type does not exist. + */ INLINE bool GeomVertexWriter:: has_column() const { return (_packer != (GeomVertexColumn::Packer *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_array -// Access: Published -// Description: Returns the array index containing the data type that -// the writer is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the array index containing the data type that the writer is working + * on. + */ INLINE int GeomVertexWriter:: get_array() const { return _array; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_column -// Access: Published -// Description: Returns the description of the data type that the -// writer is working on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the description of the data type that the writer is working on. + */ INLINE const GeomVertexColumn *GeomVertexWriter:: get_column() const { if (_packer != (GeomVertexColumn::Packer *)NULL) { @@ -327,17 +274,13 @@ get_column() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_row_unsafe -// Access: Published -// Description: Sets the start row to the indicated value, without -// internal checks. This is the same as set_row(), but -// it does not check for the possibility that the array -// has been reallocated internally for some reason; use -// only when you are confident that the array is -// unchanged and you really need every bit of available -// performance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start row to the indicated value, without internal checks. This + * is the same as set_row(), but it does not check for the possibility that + * the array has been reallocated internally for some reason; use only when + * you are confident that the array is unchanged and you really need every bit + * of available performance. + */ INLINE void GeomVertexWriter:: set_row_unsafe(int row) { _start_row = row; @@ -346,15 +289,12 @@ set_row_unsafe(int row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_row -// Access: Published -// Description: Sets the start row to the indicated value. The -// writer will begin writing to the indicated row; -// each subsequent set_data*() call will store the data -// into the subsequent row. If set_column() is called, -// the writer will return to this row. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start row to the indicated value. The writer will begin writing + * to the indicated row; each subsequent set_data*() call will store the data + * into the subsequent row. If set_column() is called, the writer will return + * to this row. + */ INLINE void GeomVertexWriter:: set_row(int row) { _start_row = row; @@ -363,156 +303,121 @@ set_row(int row) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_start_row -// Access: Published -// Description: Returns the row index at which the writer -// started. It will return to this row if you reset -// the current column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the row index at which the writer started. It will return to this + * row if you reset the current column. + */ INLINE int GeomVertexWriter:: get_start_row() const { return _start_row; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_write_row -// Access: Published -// Description: Returns the row index to which the data will be -// written at the next call to set_data*() or -// add_data*(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the row index to which the data will be written at the next call to + * set_data*() or add_data*(). + */ INLINE int GeomVertexWriter:: get_write_row() const { return (int)(_pointer - _pointer_begin) / _stride; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::is_at_end -// Access: Published -// Description: Returns true if the writer is currently at the end of -// the list of vertices, false otherwise. If this is -// true, another call to set_data*() will result in a -// crash, but another call to add_data*() will add a new -// row. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the writer is currently at the end of the list of vertices, + * false otherwise. If this is true, another call to set_data*() will result + * in a crash, but another call to add_data*() will add a new row. + */ INLINE bool GeomVertexWriter:: is_at_end() const { return _pointer >= _pointer_end; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data1f -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data1f(float data) { nassertv(has_column()); _packer->set_data1f(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2f -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2f(float x, float y) { set_data2f(LVecBase2f(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2f -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2f(const LVecBase2f &data) { nassertv(has_column()); _packer->set_data2f(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3f -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3f(float x, float y, float z) { set_data3f(LVecBase3f(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3f -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3f(const LVecBase3f &data) { nassertv(has_column()); _packer->set_data3f(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4f -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4f(float x, float y, float z, float w) { set_data4f(LVecBase4f(x, y, z, w)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4f -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4f(const LVecBase4f &data) { nassertv(has_column()); _packer->set_data4f(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix3f -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix3f(const LMatrix3f &mat) { nassertv(has_column() && @@ -529,16 +434,12 @@ set_matrix3f(const LMatrix3f &mat) { _packer->set_data3f(pointer, mat.get_row(2)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix4f -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix4f(const LMatrix4f &mat) { nassertv(has_column() && @@ -557,118 +458,93 @@ set_matrix4f(const LMatrix4f &mat) { _packer->set_data4f(pointer, mat.get_row(3)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data1d -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data1d(double data) { nassertv(has_column()); _packer->set_data1d(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2d -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2d(double x, double y) { set_data2d(LVecBase2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2d -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2d(const LVecBase2d &data) { nassertv(has_column()); _packer->set_data2d(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3d -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3d(double x, double y, double z) { set_data3d(LVecBase3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3d -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3d(const LVecBase3d &data) { nassertv(has_column()); _packer->set_data3d(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4d -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4d(double x, double y, double z, double w) { set_data4d(LVecBase4d(x, y, z, w)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4d -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4d(const LVecBase4d &data) { nassertv(has_column()); _packer->set_data4d(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix3d -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix3d(const LMatrix3d &mat) { nassertv(has_column() && @@ -685,16 +561,12 @@ set_matrix3d(const LMatrix3d &mat) { _packer->set_data3d(pointer, mat.get_row(2)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix4d -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix4d(const LMatrix4d &mat) { nassertv(has_column() && @@ -713,15 +585,12 @@ set_matrix4d(const LMatrix4d &mat) { _packer->set_data4d(pointer, mat.get_row(3)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data1 -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data1(PN_stdfloat data) { #ifndef STDFLOAT_DOUBLE @@ -731,15 +600,12 @@ set_data1(PN_stdfloat data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2 -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2(PN_stdfloat x, PN_stdfloat y) { #ifndef STDFLOAT_DOUBLE @@ -749,15 +615,12 @@ set_data2(PN_stdfloat x, PN_stdfloat y) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2 -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2(const LVecBase2 &data) { #ifndef STDFLOAT_DOUBLE @@ -767,15 +630,12 @@ set_data2(const LVecBase2 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3 -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { #ifndef STDFLOAT_DOUBLE @@ -785,15 +645,12 @@ set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3 -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3(const LVecBase3 &data) { #ifndef STDFLOAT_DOUBLE @@ -803,15 +660,12 @@ set_data3(const LVecBase3 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4 -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { #ifndef STDFLOAT_DOUBLE @@ -821,15 +675,12 @@ set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4 -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4(const LVecBase4 &data) { #ifndef STDFLOAT_DOUBLE @@ -839,16 +690,12 @@ set_data4(const LVecBase4 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix3 -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix3(const LMatrix3 &mat) { #ifndef STDFLOAT_DOUBLE @@ -858,16 +705,12 @@ set_matrix3(const LMatrix3 &mat) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_matrix4 -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_matrix4(const LMatrix4 &mat) { #ifndef STDFLOAT_DOUBLE @@ -877,220 +720,182 @@ set_matrix4(const LMatrix4 &mat) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data1i -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data1i(int data) { nassertv(has_column()); _packer->set_data1i(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2i -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2i(int a, int b) { set_data2i(LVecBase2i(a, b)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data2i -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data2i(const LVecBase2i &data) { nassertv(has_column()); _packer->set_data2i(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3i -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3i(int a, int b, int c) { set_data3i(LVecBase3i(a, b, c)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data3i -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data3i(const LVecBase3i &data) { nassertv(has_column()); _packer->set_data3i(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4i -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4i(int a, int b, int c, int d) { set_data4i(LVecBase4i(a, b, c, d)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_data4i -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// It is an error for the write row to advance past -// the end of data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * It is an error for the write row to advance past the end of data. + */ INLINE void GeomVertexWriter:: set_data4i(const LVecBase4i &data) { nassertv(has_column()); _packer->set_data4i(inc_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data1f -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data1f(float data) { nassertv(has_column()); _packer->set_data1f(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2f -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2f(float x, float y) { add_data2f(LVecBase2f(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2f -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2f(const LVecBase2f &data) { nassertv(has_column()); _packer->set_data2f(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3f -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3f(float x, float y, float z) { add_data3f(LVecBase3f(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3f -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3f(const LVecBase3f &data) { nassertv(has_column()); _packer->set_data3f(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4f -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4f(float x, float y, float z, float w) { add_data4f(LVecBase4f(x, y, z, w)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4f -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4f(const LVecBase4f &data) { nassertv(has_column()); _packer->set_data4f(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix3f -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix3f(const LMatrix3f &mat) { nassertv(has_column() && @@ -1107,16 +912,13 @@ add_matrix3f(const LMatrix3f &mat) { _packer->set_data3f(pointer, mat.get_row(2)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix4f -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix4f(const LMatrix4f &mat) { nassertv(has_column() && @@ -1135,118 +937,101 @@ add_matrix4f(const LMatrix4f &mat) { _packer->set_data4f(pointer, mat.get_row(3)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data1d -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data1d(double data) { nassertv(has_column()); _packer->set_data1d(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2d -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2d(double x, double y) { add_data2d(LVecBase2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2d -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2d(const LVecBase2d &data) { nassertv(has_column()); _packer->set_data2d(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3d -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3d(double x, double y, double z) { add_data3d(LVecBase3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3d -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3d(const LVecBase3d &data) { nassertv(has_column()); _packer->set_data3d(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4d -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4d(double x, double y, double z, double w) { add_data4d(LVecBase4d(x, y, z, w)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4d -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4d(const LVecBase4d &data) { nassertv(has_column()); _packer->set_data4d(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix3d -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix3d(const LMatrix3d &mat) { nassertv(has_column() && @@ -1263,16 +1048,13 @@ add_matrix3d(const LMatrix3d &mat) { _packer->set_data3d(pointer, mat.get_row(2)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix4d -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix4d(const LMatrix4d &mat) { nassertv(has_column() && @@ -1291,15 +1073,13 @@ add_matrix4d(const LMatrix4d &mat) { _packer->set_data4d(pointer, mat.get_row(3)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data1 -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data1(PN_stdfloat data) { #ifndef STDFLOAT_DOUBLE @@ -1309,15 +1089,13 @@ add_data1(PN_stdfloat data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2 -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2(PN_stdfloat x, PN_stdfloat y) { #ifndef STDFLOAT_DOUBLE @@ -1327,15 +1105,13 @@ add_data2(PN_stdfloat x, PN_stdfloat y) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2 -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2(const LVecBase2 &data) { #ifndef STDFLOAT_DOUBLE @@ -1345,15 +1121,13 @@ add_data2(const LVecBase2 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3 -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { #ifndef STDFLOAT_DOUBLE @@ -1363,15 +1137,13 @@ add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3 -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3(const LVecBase3 &data) { #ifndef STDFLOAT_DOUBLE @@ -1381,15 +1153,13 @@ add_data3(const LVecBase3 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4 -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { #ifndef STDFLOAT_DOUBLE @@ -1399,15 +1169,13 @@ add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4 -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4(const LVecBase4 &data) { #ifndef STDFLOAT_DOUBLE @@ -1417,16 +1185,13 @@ add_data4(const LVecBase4 &data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix3 -// Access: Published -// Description: Sets the write row to a 3-by-3 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 3-by-3 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix3(const LMatrix3 &mat) { #ifndef STDFLOAT_DOUBLE @@ -1436,16 +1201,13 @@ add_matrix3(const LMatrix3 &mat) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_matrix4 -// Access: Published -// Description: Sets the write row to a 4-by-4 matrix, and advances -// the write row. This is a special method that can -// only be used on matrix columns. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a 4-by-4 matrix, and advances the write row. This is + * a special method that can only be used on matrix columns. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_matrix4(const LMatrix4 &mat) { #ifndef STDFLOAT_DOUBLE @@ -1455,125 +1217,107 @@ add_matrix4(const LMatrix4 &mat) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data1i -// Access: Published -// Description: Sets the write row to a particular 1-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 1-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data1i(int data) { nassertv(has_column()); _packer->set_data1i(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2i -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2i(int a, int b) { add_data2i(LVecBase2i(a, b)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data2i -// Access: Published -// Description: Sets the write row to a particular 2-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 2-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data2i(const LVecBase2i &data) { nassertv(has_column()); _packer->set_data2i(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3i -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3i(int a, int b, int c) { add_data3i(LVecBase3i(a, b, c)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data3i -// Access: Published -// Description: Sets the write row to a particular 3-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 3-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data3i(const LVecBase3i &data) { nassertv(has_column()); _packer->set_data3i(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4i -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4i(int a, int b, int c, int d) { add_data4i(LVecBase4i(a, b, c, d)); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::add_data4i -// Access: Published -// Description: Sets the write row to a particular 4-component -// value, and advances the write row. -// -// If the write row advances past the end of data, -// implicitly adds a new row to the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the write row to a particular 4-component value, and advances the + * write row. + * + * If the write row advances past the end of data, implicitly adds a new row + * to the data. + */ INLINE void GeomVertexWriter:: add_data4i(const LVecBase4i &data) { nassertv(has_column()); _packer->set_data4i(inc_add_pointer(), data); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::get_packer -// Access: Protected -// Description: Returns the writer's Packer object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the writer's Packer object. + */ INLINE GeomVertexColumn::Packer *GeomVertexWriter:: get_packer() const { return _packer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_pointer -// Access: Private -// Description: Sets up the array pointers freshly from the source -// object (in case they have been reallocated recently), -// and sets the internal pointer to the indicated row. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the array pointers freshly from the source object (in case they + * have been reallocated recently), and sets the internal pointer to the + * indicated row. + */ INLINE void GeomVertexWriter:: set_pointer(int row) { _pointer_begin = _handle->get_write_pointer(); @@ -1581,13 +1325,10 @@ set_pointer(int row) { quick_set_pointer(row); } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::quick_set_pointer -// Access: Private -// Description: Sets up the internal pointer to the indicated row, -// without first verifying that arrays haven't been -// reallocated. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the internal pointer to the indicated row, without first verifying + * that arrays haven't been reallocated. + */ INLINE void GeomVertexWriter:: quick_set_pointer(int row) { nassertv(has_column()); @@ -1600,18 +1341,16 @@ quick_set_pointer(int row) { _pointer = _pointer_begin + _packer->_column->get_start() + _stride * row; #if defined(_DEBUG) - // We have to allow the pointer to exceed the end by up to one row's - // width, because the next call might be to add_data_*(). + // We have to allow the pointer to exceed the end by up to one row's width, + // because the next call might be to add_data_*(). nassertv(_pointer_begin == _pointer_end || (_pointer - _packer->_column->get_start()) <= _pointer_end); #endif } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::inc_pointer -// Access: Private -// Description: Increments to the next row, and returns the data -// pointer as it was before incrementing. -//////////////////////////////////////////////////////////////////// +/** + * Increments to the next row, and returns the data pointer as it was before + * incrementing. + */ INLINE unsigned char *GeomVertexWriter:: inc_pointer() { #if defined(_DEBUG) @@ -1626,14 +1365,11 @@ inc_pointer() { return orig_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::inc_add_pointer -// Access: Private -// Description: Increments to the next row, and returns the data -// pointer as it was before incrementing. If we are at -// or past the end of data, implicitly adds more -// rows first. -//////////////////////////////////////////////////////////////////// +/** + * Increments to the next row, and returns the data pointer as it was before + * incrementing. If we are at or past the end of data, implicitly adds more + * rows first. + */ INLINE unsigned char *GeomVertexWriter:: inc_add_pointer() { if (_pointer >= _pointer_end) { @@ -1641,8 +1377,8 @@ inc_add_pointer() { int write_row = get_write_row(); if (_vertex_data != (GeomVertexData *)NULL) { - // If we have a whole GeomVertexData, we must set the length of - // all its arrays at once. + // If we have a whole GeomVertexData, we must set the length of all its + // arrays at once. _handle = NULL; GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); @@ -1650,8 +1386,8 @@ inc_add_pointer() { _handle = writer.get_array_writer(_array); } else { - // Otherwise, we can get away with modifying only the one array - // we're using. + // Otherwise, we can get away with modifying only the one array we're + // using. _handle->set_num_rows(max(write_row + 1, _handle->get_num_rows())); } @@ -1659,4 +1395,3 @@ inc_add_pointer() { } return inc_pointer(); } - diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index a534bac049..b80a30fe67 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/panda/src/gobj/geomVertexWriter.cxx @@ -1,39 +1,35 @@ -// Filename: geomVertexWriter.cxx -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexWriter.cxx + * @author drose + * @date 2005-03-25 + */ #include "geomVertexWriter.h" #ifndef NDEBUG - // This is defined just for the benefit of having something non-NULL - // to return from a nassertr() call. + // This is defined just for the benefit of having something non-NULL to + // return from a nassertr() call. unsigned char GeomVertexWriter::empty_buffer[100] = { 0 }; #endif -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_column -// Access: Published -// Description: Sets up the writer to use the indicated column -// description on the given array. -// -// This also resets the current write row number to the -// start row (the same value passed to a previous call -// to set_row(), or 0 if set_row() was never called.) -// -// The return value is true if the data type is valid, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the writer to use the indicated column description on the given + * array. + * + * This also resets the current write row number to the start row (the same + * value passed to a previous call to set_row(), or 0 if set_row() was never + * called.) + * + * The return value is true if the data type is valid, false otherwise. + */ bool GeomVertexWriter:: set_column(int array, const GeomVertexColumn *column) { if (_vertex_data == (GeomVertexData *)NULL && @@ -65,48 +61,42 @@ set_column(int array, const GeomVertexColumn *column) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::reserve_num_rows -// Access: Published -// Description: This ensures that enough memory space for num_rows is -// allocated, so that you may add up to num_rows rows -// without causing a new memory allocation. This is a -// performance optimization only; it is especially -// useful when you know the number of rows you will be -// adding ahead of time. -//////////////////////////////////////////////////////////////////// +/** + * This ensures that enough memory space for num_rows is allocated, so that + * you may add up to num_rows rows without causing a new memory allocation. + * This is a performance optimization only; it is especially useful when you + * know the number of rows you will be adding ahead of time. + */ bool GeomVertexWriter:: reserve_num_rows(int num_rows) { bool result; if (_vertex_data != (GeomVertexData *)NULL) { - // If we have a whole GeomVertexData, we must set the length of - // all its arrays at once. + // If we have a whole GeomVertexData, we must set the length of all its + // arrays at once. GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread); writer.check_array_writers(); result = writer.reserve_num_rows(num_rows); _handle = writer.get_array_writer(_array); - + } else { - // Otherwise, we can get away with modifying only the one array - // we're using. + // Otherwise, we can get away with modifying only the one array we're + // using. result = _handle->reserve_num_rows(num_rows); } return result; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomVertexWriter:: output(ostream &out) const { const GeomVertexColumn *column = get_column(); if (column == (GeomVertexColumn *)NULL) { out << "GeomVertexWriter()"; - + } else { out << "GeomVertexWriter, array = " << get_array_data() << ", column = " << column->get_name() @@ -115,11 +105,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::initialize -// Access: Private -// Description: Called only by the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Called only by the constructor. + */ void GeomVertexWriter:: initialize() { _array = 0; @@ -130,12 +118,10 @@ initialize() { _start_row = 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_vertex_column -// Access: Private -// Description: Internal method to set the column to column from the -// indicated array, assuming we have a GeomVertexData -//////////////////////////////////////////////////////////////////// +/** + * Internal method to set the column to column from the indicated array, + * assuming we have a GeomVertexData + */ bool GeomVertexWriter:: set_vertex_column(int array, const GeomVertexColumn *column, GeomVertexDataPipelineWriter *data_writer) { @@ -157,17 +143,14 @@ set_vertex_column(int array, const GeomVertexColumn *column, _packer = column->_packer; set_pointer(_start_row); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomVertexWriter::set_array_column -// Access: Private -// Description: Internal method to set the column to column from the -// indicated array, assuming we have a -// GeomVertexArrayData. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to set the column to column from the indicated array, + * assuming we have a GeomVertexArrayData. + */ bool GeomVertexWriter:: set_array_column(const GeomVertexColumn *column) { if (column == (const GeomVertexColumn *)NULL) { @@ -181,6 +164,6 @@ set_array_column(const GeomVertexColumn *column) { _packer = column->_packer; set_pointer(_start_row); - + return true; } diff --git a/panda/src/gobj/geomVertexWriter.h b/panda/src/gobj/geomVertexWriter.h index 7f49d81c54..815ca6435f 100644 --- a/panda/src/gobj/geomVertexWriter.h +++ b/panda/src/gobj/geomVertexWriter.h @@ -1,16 +1,15 @@ -// Filename: geomVertexWriter.h -// Created by: drose (25Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomVertexWriter.h + * @author drose + * @date 2005-03-25 + */ #ifndef GEOMVERTEXWRITER_H #define GEOMVERTEXWRITER_H @@ -22,50 +21,37 @@ #include "luse.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomVertexWriter -// Description : This object provides a high-level interface for -// quickly writing a sequence of numeric values from a -// vertex table. -// -// This object can be used both to replace existing -// vertices in the table, or to extend the table with -// new vertices. The set_data*() family of methods can -// only be used to replace existing data; it is an error -// to allow these to run past the end of the data. The -// add_data*() family of methods, on the other hand, can -// be used to replace existing data or add new data; if -// you call set_row() into the middle of existing -// data the add_data*() methods will behave like the -// corresponding set_data*(), but if they run past the -// end of existing data they will quietly add new -// vertices. -// -// Like GeomVertexReader, the writer is particularly -// optimized for writing a single column of data values -// for a series of vertices, without changing columns -// between each number. Although you can also use one -// GeomVertexWriter to write across the columns if it is -// convenient, by calling set_column() repeatedly at -// each vertex, it is faster to write down the columns, -// and to use a different GeomVertexWriter for each -// column. -// -// Note that, like a GeomVertexReader, a -// GeomVertexWriter does not keep a reference count to -// the actual vertex data buffer. This means that it is -// important not to keep a GeomVertexWriter object -// around over a long period of time in which the data -// buffer is likely to be deallocated; it is intended -// for making a quick pass over the data in one session. -// -// It also means that you should create any -// GeomVertexWriters *before* creating GeomVertexReaders -// on the same data, since the writer itself might cause -// the vertex buffer to be deallocated. Better yet, use -// a GeomVertexRewriter if you are going to create both -// of them anyway. -//////////////////////////////////////////////////////////////////// +/** + * This object provides a high-level interface for quickly writing a sequence + * of numeric values from a vertex table. + * + * This object can be used both to replace existing vertices in the table, or + * to extend the table with new vertices. The set_data*() family of methods + * can only be used to replace existing data; it is an error to allow these to + * run past the end of the data. The add_data*() family of methods, on the + * other hand, can be used to replace existing data or add new data; if you + * call set_row() into the middle of existing data the add_data*() methods + * will behave like the corresponding set_data*(), but if they run past the + * end of existing data they will quietly add new vertices. + * + * Like GeomVertexReader, the writer is particularly optimized for writing a + * single column of data values for a series of vertices, without changing + * columns between each number. Although you can also use one + * GeomVertexWriter to write across the columns if it is convenient, by + * calling set_column() repeatedly at each vertex, it is faster to write down + * the columns, and to use a different GeomVertexWriter for each column. + * + * Note that, like a GeomVertexReader, a GeomVertexWriter does not keep a + * reference count to the actual vertex data buffer. This means that it is + * important not to keep a GeomVertexWriter object around over a long period + * of time in which the data buffer is likely to be deallocated; it is + * intended for making a quick pass over the data in one session. + * + * It also means that you should create any GeomVertexWriters *before* + * creating GeomVertexReaders on the same data, since the writer itself might + * cause the vertex buffer to be deallocated. Better yet, use a + * GeomVertexRewriter if you are going to create both of them anyway. + */ class EXPCL_PANDA_GOBJ GeomVertexWriter : public GeomEnums { PUBLISHED: INLINE GeomVertexWriter(Thread *current_thread = Thread::get_current_thread()); @@ -207,11 +193,10 @@ private: GeomVertexDataPipelineWriter *data_writer); bool set_array_column(const GeomVertexColumn *column); - // It is important that we only store *one* of the following two - // pointers. If we are storing a GeomVertexData/array index, we - // must not keep a pointer to the particular ArrayData we are - // working on (if we do, it may result in an extra copy of the data - // due to holding the reference count). + // It is important that we only store *one* of the following two pointers. + // If we are storing a GeomVertexDataarray index, we must not keep a pointer + // to the particular ArrayData we are working on (if we do, it may result in + // an extra copy of the data due to holding the reference count). PT(GeomVertexData) _vertex_data; int _array; PT(GeomVertexArrayData) _array_data; @@ -228,8 +213,8 @@ private: int _start_row; #ifndef NDEBUG - // This is defined just for the benefit of having something non-NULL - // to return from a nassertr() call. + // This is defined just for the benefit of having something non-NULL to + // return from a nassertr() call. static unsigned char empty_buffer[100]; #endif }; diff --git a/panda/src/gobj/indexBufferContext.I b/panda/src/gobj/indexBufferContext.I index b6b86e6ffd..caf5e7f34a 100644 --- a/panda/src/gobj/indexBufferContext.I +++ b/panda/src/gobj/indexBufferContext.I @@ -1,23 +1,19 @@ -// Filename: indexBufferContext.I -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexBufferContext.I + * @author drose + * @date 2005-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IndexBufferContext:: IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : BufferContext(&pgo->_ibuffer_residency), @@ -26,72 +22,58 @@ IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : { } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::get_data -// Access: Public -// Description: Returns the pointer to the client-side array data -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the client-side array data object. + */ INLINE GeomPrimitive *IndexBufferContext:: get_data() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::changed_size -// Access: Public -// Description: Returns true if the data has changed size since the -// last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has changed size since the last time mark_loaded() + * was called. + */ INLINE bool IndexBufferContext:: changed_size(const GeomPrimitivePipelineReader *reader) const { nassertr(reader->get_object() == _data, false); return get_data_size_bytes() != (size_t)reader->get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::changed_usage_hint -// Access: Public -// Description: Returns true if the data has changed its usage hint -// since the last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has changed its usage hint since the last time + * mark_loaded() was called. + */ INLINE bool IndexBufferContext:: changed_usage_hint(const GeomPrimitivePipelineReader *reader) const { nassertr(reader->get_object() == _data, false); return _usage_hint != reader->get_usage_hint(); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::was_modified -// Access: Public -// Description: Returns true if the data has been modified since the -// last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has been modified since the last time + * mark_loaded() was called. + */ INLINE bool IndexBufferContext:: was_modified(const GeomPrimitivePipelineReader *reader) const { nassertr(reader->get_object() == _data, false); return get_modified() != reader->get_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::update_data_size_bytes -// Access: Public -// Description: Should be called (usually by a derived class) when -// the on-card size of this object has changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (usually by a derived class) when the on-card size of this + * object has changed. + */ INLINE void IndexBufferContext:: update_data_size_bytes(size_t new_data_size_bytes) { BufferContext::update_data_size_bytes(new_data_size_bytes); AdaptiveLruPage::set_lru_size(new_data_size_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::mark_loaded -// Access: Public -// Description: Should be called after the IndexBufferContext has been -// loaded into graphics memory, this updates the -// internal flags for changed_size() and modified(). -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the IndexBufferContext has been loaded into graphics + * memory, this updates the internal flags for changed_size() and modified(). + */ INLINE void IndexBufferContext:: mark_loaded(const GeomPrimitivePipelineReader *reader) { nassertv(reader->get_object() == _data); @@ -103,12 +85,9 @@ mark_loaded(const GeomPrimitivePipelineReader *reader) { set_resident(true); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::mark_unloaded -// Access: Public -// Description: Should be called after the buffer has been forced -// out of graphics memory. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the buffer has been forced out of graphics memory. + */ INLINE void IndexBufferContext:: mark_unloaded() { update_modified(UpdateSeq::old()); diff --git a/panda/src/gobj/indexBufferContext.cxx b/panda/src/gobj/indexBufferContext.cxx index d013d18ece..ebb65ea89f 100644 --- a/panda/src/gobj/indexBufferContext.cxx +++ b/panda/src/gobj/indexBufferContext.cxx @@ -1,36 +1,31 @@ -// Filename: indexBufferContext.cxx -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexBufferContext.cxx + * @author drose + * @date 2005-03-17 + */ #include "indexBufferContext.h" TypeHandle IndexBufferContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexBufferContext:: output(ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: IndexBufferContext::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexBufferContext:: write(ostream &out, int indent_level) const { SavedContext::write(out, indent_level); diff --git a/panda/src/gobj/indexBufferContext.h b/panda/src/gobj/indexBufferContext.h index 8c4e0764d3..4e3019c507 100644 --- a/panda/src/gobj/indexBufferContext.h +++ b/panda/src/gobj/indexBufferContext.h @@ -1,16 +1,15 @@ -// Filename: indexBufferContext.h -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexBufferContext.h + * @author drose + * @date 2005-03-17 + */ #ifndef INDEXBUFFERCONTEXT_H #define INDEXBUFFERCONTEXT_H @@ -22,17 +21,15 @@ #include "preparedGraphicsObjects.h" #include "adaptiveLru.h" -//////////////////////////////////////////////////////////////////// -// Class : IndexBufferContext -// Description : This is a special class object that holds all the -// information returned by a particular GSG to indicate -// the vertex data array's internal context identifier. -// -// This allows the GSG to cache the vertex data array in -// whatever way makes sense. For instance, DirectX can -// allocate a vertex buffer for the array. OpenGL can -// create a buffer object. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class object that holds all the information returned by a + * particular GSG to indicate the vertex data array's internal context + * identifier. + * + * This allows the GSG to cache the vertex data array in whatever way makes + * sense. For instance, DirectX can allocate a vertex buffer for the array. + * OpenGL can create a buffer object. + */ class EXPCL_PANDA_GOBJ IndexBufferContext : public BufferContext, public AdaptiveLruPage { public: INLINE IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data); @@ -53,9 +50,8 @@ public: virtual void write(ostream &out, int indent_level) const; private: - // This cannot be a PT(GeomPrimitive), because the data and - // the GSG both own their IndexBufferContexts! That would create a - // circular reference count. + // This cannot be a PT(GeomPrimitive), because the data and the GSG both own + // their IndexBufferContexts! That would create a circular reference count. GeomPrimitive *_data; GeomEnums::UsageHint _usage_hint; @@ -87,4 +83,3 @@ inline ostream &operator << (ostream &out, const IndexBufferContext &context) { #include "indexBufferContext.I" #endif - diff --git a/panda/src/gobj/internalName.I b/panda/src/gobj/internalName.I index 2b8669ff5a..69e88c4563 100644 --- a/panda/src/gobj/internalName.I +++ b/panda/src/gobj/internalName.I @@ -1,51 +1,40 @@ -// Filename: internalName.I -// Created by: masad (15Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalName.I + * @author masad + * @date 2004-07-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make -// Access: Public, Static -// Description: The public interface for constructing an InternalName -// pointer. This will return a new InternalName -// representing the indicated name, if this is the first -// time the particular name has been requested; if the -// name is already in use, it will return the existing -// pointer. -// -// If the string contains the '.' character, the string -// will be divided at the dots and the so-defined -// hierarchy of names will be registered. This is -// handled transparently. -//////////////////////////////////////////////////////////////////// +/** + * The public interface for constructing an InternalName pointer. This will + * return a new InternalName representing the indicated name, if this is the + * first time the particular name has been requested; if the name is already + * in use, it will return the existing pointer. + * + * If the string contains the '.' character, the string will be divided at the + * dots and the so-defined hierarchy of names will be registered. This is + * handled transparently. + */ INLINE PT(InternalName) InternalName:: make(const string &name) { return get_root()->append(name); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make -// Access: Public, Static -// Description: This version of make() is defined such as to accept -// mostly string literals, which may be string pooled -// by the compiler. This allows us to make an -// additional optimization. -// -// This constructor is also used for fixed-size arrays, -// since there is no neat way to catch string literals -// only. Presumably people aren't using InternalName -// in that way. -//////////////////////////////////////////////////////////////////// +/** + * This version of make() is defined such as to accept mostly string literals, + * which may be string pooled by the compiler. This allows us to make an + * additional optimization. + * + * This constructor is also used for fixed-size arrays, since there is no neat + * way to catch string literals only. Presumably people aren't using + * InternalName in that way. + */ template INLINE PT(InternalName) InternalName:: make(const char (&literal)[N]) { @@ -61,37 +50,29 @@ make(const char (&literal)[N]) { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_parent -// Access: Published -// Description: Return the parent of this InternalName. All names -// have a parent, except the root name. -//////////////////////////////////////////////////////////////////// +/** + * Return the parent of this InternalName. All names have a parent, except + * the root name. + */ INLINE InternalName *InternalName:: get_parent() const { return _parent; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_basename -// Access: Published -// Description: Return the name represented by just this particular -// InternalName object, ignoring its parents names. -// This is everything after the rightmost dot. -//////////////////////////////////////////////////////////////////// +/** + * Return the name represented by just this particular InternalName object, + * ignoring its parents names. This is everything after the rightmost dot. + */ INLINE const string &InternalName:: get_basename() const { return _basename; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_root -// Access: Published, Static -// Description: Returns the standard root InternalName. This is the -// root of all other InternalNames. It has no name -// itself, and it is the only InternalName with no -// parent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard root InternalName. This is the root of all other + * InternalNames. It has no name itself, and it is the only InternalName with + * no parent. + */ INLINE PT(InternalName) InternalName:: get_root() { if (_root == (InternalName *)NULL) { @@ -100,11 +81,9 @@ get_root() { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_error -// Access: Published, Static -// Description: Returns the standard InternalName "error". -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "error". + */ INLINE PT(InternalName) InternalName:: get_error() { if (_error == (InternalName *)NULL) { @@ -113,13 +92,10 @@ get_error() { return _error; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_vertex -// Access: Published, Static -// Description: Returns the standard InternalName "vertex". This is -// the column header for the 3-d or 4-d vertex position -// information for each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "vertex". This is the column header for + * the 3-d or 4-d vertex position information for each vertex. + */ INLINE PT(InternalName) InternalName:: get_vertex() { if (_vertex == (InternalName *)NULL) { @@ -128,13 +104,10 @@ get_vertex() { return _vertex; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_normal -// Access: Published, Static -// Description: Returns the standard InternalName "normal". This is -// the column header for the 3-d lighting normal for -// each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "normal". This is the column header for + * the 3-d lighting normal for each vertex. + */ INLINE PT(InternalName) InternalName:: get_normal() { if (_normal == (InternalName *)NULL) { @@ -143,16 +116,12 @@ get_normal() { return _normal; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_tangent -// Access: Published, Static -// Description: Returns the standard InternalName "tangent". This is -// the column header for the tangent vector associated -// with each vertex, which is a unit vector -// usually perpendicular to the normal and in the -// direction of the U texture coordinate change. It is -// used for deriving bump maps. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "tangent". This is the column header for + * the tangent vector associated with each vertex, which is a unit vector + * usually perpendicular to the normal and in the direction of the U texture + * coordinate change. It is used for deriving bump maps. + */ INLINE PT(InternalName) InternalName:: get_tangent() { if (_tangent == (InternalName *)NULL) { @@ -161,30 +130,23 @@ get_tangent() { return _tangent; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_tangent_name -// Access: Published, Static -// Description: Returns the InternalName "tangent.name", where name -// is the supplied string. This is the column header -// for the tangent associated with the named texture -// coordinate set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the InternalName "tangent.name", where name is the supplied string. + * This is the column header for the tangent associated with the named texture + * coordinate set. + */ INLINE PT(InternalName) InternalName:: get_tangent_name(const string &name) { return get_tangent()->append(name); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_binormal -// Access: Published, Static -// Description: Returns the standard InternalName "binormal". This is -// the column header for the tangent vector associated -// with each vertex, which is a unit vector -// usually perpendicular to both the normal and the -// tangent, and in the direction of the V texture -// coordinate change. It is used for deriving bump -// maps. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "binormal". This is the column header + * for the tangent vector associated with each vertex, which is a unit vector + * usually perpendicular to both the normal and the tangent, and in the + * direction of the V texture coordinate change. It is used for deriving bump + * maps. + */ INLINE PT(InternalName) InternalName:: get_binormal() { if (_binormal == (InternalName *)NULL) { @@ -193,28 +155,21 @@ get_binormal() { return _binormal; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_binormal_name -// Access: Published, Static -// Description: Returns the InternalName "binormal.name", where name -// is the supplied string. This is the column header -// for the binormal associated with the named texture -// coordinate set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the InternalName "binormal.name", where name is the supplied + * string. This is the column header for the binormal associated with the + * named texture coordinate set. + */ INLINE PT(InternalName) InternalName:: get_binormal_name(const string &name) { return get_binormal()->append(name); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_texcoord -// Access: Published, Static -// Description: Returns the standard InternalName "texcoord". This -// is the column header for the default texture -// coordinate set for each vertex. It is also used for -// identifying the default texture coordinate set in a -// TextureStage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "texcoord". This is the column header + * for the default texture coordinate set for each vertex. It is also used + * for identifying the default texture coordinate set in a TextureStage. + */ INLINE PT(InternalName) InternalName:: get_texcoord() { if (_texcoord == (InternalName *)NULL) { @@ -223,27 +178,21 @@ get_texcoord() { return _texcoord; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_texcoord_name -// Access: Published, Static -// Description: Returns the InternalName "texcoord.name", where name -// is the supplied string. This is the column header -// for the named texture coordinate set for each vertex. -// It is also used for identifying the named texture -// coordinate set in a TextureStage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the InternalName "texcoord.name", where name is the supplied + * string. This is the column header for the named texture coordinate set for + * each vertex. It is also used for identifying the named texture coordinate + * set in a TextureStage. + */ INLINE PT(InternalName) InternalName:: get_texcoord_name(const string &name) { return get_texcoord()->append(name); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_color -// Access: Published, Static -// Description: Returns the standard InternalName "color". This is -// the column header for the 4-component color value for -// each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "color". This is the column header for + * the 4-component color value for each vertex. + */ INLINE PT(InternalName) InternalName:: get_color() { if (_color == (InternalName *)NULL) { @@ -252,15 +201,11 @@ get_color() { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_rotate -// Access: Published, Static -// Description: Returns the standard InternalName "rotate". This is -// the column header for the floating-point rotate -// value, which represents a number of degrees -// counter-clockwise to rotate each point or point -// sprite. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "rotate". This is the column header for + * the floating-point rotate value, which represents a number of degrees + * counter-clockwise to rotate each point or point sprite. + */ INLINE PT(InternalName) InternalName:: get_rotate() { if (_rotate == (InternalName *)NULL) { @@ -269,15 +214,11 @@ get_rotate() { return _rotate; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_size -// Access: Published, Static -// Description: Returns the standard InternalName "size". This is -// the column header for the floating-point size value, -// which overrides the thickness parameter of the -// RenderModeAttrib on a per-vertex (e.g. per-point) -// basis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "size". This is the column header for + * the floating-point size value, which overrides the thickness parameter of + * the RenderModeAttrib on a per-vertex (e.g. per-point) basis. + */ INLINE PT(InternalName) InternalName:: get_size() { if (_size == (InternalName *)NULL) { @@ -286,15 +227,12 @@ get_size() { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_aspect_ratio -// Access: Published, Static -// Description: Returns the standard InternalName "aspect_ratio". -// This is the column header for the floating-point -// aspect ratio value, which is used to define -// non-square points. This number is the ratio x / y, -// where y is the point size (above). -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "aspect_ratio". This is the column header + * for the floating-point aspect ratio value, which is used to define non- + * square points. This number is the ratio x / y, where y is the point size + * (above). + */ INLINE PT(InternalName) InternalName:: get_aspect_ratio() { if (_aspect_ratio == (InternalName *)NULL) { @@ -303,15 +241,12 @@ get_aspect_ratio() { return _aspect_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_transform_blend -// Access: Published, Static -// Description: Returns the standard InternalName "transform_blend". -// This is the column header for the integer -// transform_blend index, which is used to define vertex -// animation on the CPU by indexing to a particular -// vertex weighting from the TransformBlendTable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "transform_blend". This is the column + * header for the integer transform_blend index, which is used to define + * vertex animation on the CPU by indexing to a particular vertex weighting + * from the TransformBlendTable. + */ INLINE PT(InternalName) InternalName:: get_transform_blend() { if (_transform_blend == (InternalName *)NULL) { @@ -320,19 +255,15 @@ get_transform_blend() { return _transform_blend; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_transform_weight -// Access: Published, Static -// Description: Returns the standard InternalName "transform_weight". -// This is the column header for the n-component -// transform_weight value, which is used in conjuntion -// with "transform_index" to define vertex animation on -// the graphics card. The transform_weight value -// specifies the weight of the nth transform. By -// convention, there are 1 fewer weight values than -// transforms, since the weights are assumed to sum to 1 -// (and the last value is therefore implicit). -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "transform_weight". This is the column + * header for the n-component transform_weight value, which is used in + * conjuntion with "transform_index" to define vertex animation on the + * graphics card. The transform_weight value specifies the weight of the nth + * transform. By convention, there are 1 fewer weight values than transforms, + * since the weights are assumed to sum to 1 (and the last value is therefore + * implicit). + */ INLINE PT(InternalName) InternalName:: get_transform_weight() { if (_transform_weight == (InternalName *)NULL) { @@ -341,19 +272,14 @@ get_transform_weight() { return _transform_weight; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_transform_index -// Access: Published, Static -// Description: Returns the standard InternalName "transform_index". -// This is the column header for the n-component -// transform_index value, which is used in conjuntion -// with "transform_weight" to define vertex animation on -// the graphics card. The transform_index value -// specifies the nth transform, by lookup in the -// TransformTable. The transform_index column may be -// omitted, in which case the nth transform is the nth -// entry in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "transform_index". This is the column + * header for the n-component transform_index value, which is used in + * conjuntion with "transform_weight" to define vertex animation on the + * graphics card. The transform_index value specifies the nth transform, by + * lookup in the TransformTable. The transform_index column may be omitted, + * in which case the nth transform is the nth entry in the table. + */ INLINE PT(InternalName) InternalName:: get_transform_index() { if (_transform_index == (InternalName *)NULL) { @@ -362,36 +288,28 @@ get_transform_index() { return _transform_index; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_morph -// Access: Published, Static -// Description: Returns an InternalName derived from the given base -// column name and the given slider name, which is the -// column header for the offset vector that should be -// applied to the base column name when the named morph -// slider is engaged. -// -// Each morph slider requires a set of n morph columns, -// one for each base column it applies to. -//////////////////////////////////////////////////////////////////// +/** + * Returns an InternalName derived from the given base column name and the + * given slider name, which is the column header for the offset vector that + * should be applied to the base column name when the named morph slider is + * engaged. + * + * Each morph slider requires a set of n morph columns, one for each base + * column it applies to. + */ INLINE PT(InternalName) InternalName:: get_morph(InternalName *column, const string &slider) { - // This actually returns "column.morph.slider", although that's just - // an implementation detail--as long as it returns a consistent, - // unique name for each combination of column and slider, everything - // is good. + // This actually returns "column.morph.slider", although that's just an + // implementation detail--as long as it returns a consistent, unique name + // for each combination of column and slider, everything is good. return column->append("morph")->append(slider); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_index -// Access: Published, Static -// Description: Returns the standard InternalName "index". This is -// the column header for the integer vertex index. It -// is not used in the vertex data itself, but is used in -// the GeomPrimitive structure to index into the vertex -// data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "index". This is the column header for + * the integer vertex index. It is not used in the vertex data itself, but is + * used in the GeomPrimitive structure to index into the vertex data. + */ INLINE PT(InternalName) InternalName:: get_index() { if (_index == (InternalName *)NULL) { @@ -400,12 +318,10 @@ get_index() { return _index; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_world -// Access: Published, Static -// Description: Returns the standard InternalName "world". This is -// used as a keyword in the shader subsystem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "world". This is used as a keyword in + * the shader subsystem. + */ INLINE PT(InternalName) InternalName:: get_world() { if (_world == (InternalName *)NULL) { @@ -414,12 +330,10 @@ get_world() { return _world; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_camera -// Access: Published, Static -// Description: Returns the standard InternalName "camera". This is -// used as a keyword in the shader subsystem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "camera". This is used as a keyword in + * the shader subsystem. + */ INLINE PT(InternalName) InternalName:: get_camera() { if (_camera == (InternalName *)NULL) { @@ -428,12 +342,10 @@ get_camera() { return _camera; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_model -// Access: Published, Static -// Description: Returns the standard InternalName "model". This is -// used as a keyword in the shader subsystem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "model". This is used as a keyword in + * the shader subsystem. + */ INLINE PT(InternalName) InternalName:: get_model() { if (_model == (InternalName *)NULL) { @@ -442,12 +354,10 @@ get_model() { return _model; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_view -// Access: Published, Static -// Description: Returns the standard InternalName "view". This is -// used as a keyword in the shader subsystem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard InternalName "view". This is used as a keyword in the + * shader subsystem. + */ INLINE PT(InternalName) InternalName:: get_view() { if (_view == (InternalName *)NULL) { @@ -456,11 +366,9 @@ get_view() { return _view; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::output operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream & operator << (ostream &out, const InternalName &tcn) { tcn.output(out); @@ -468,55 +376,45 @@ operator << (ostream &out, const InternalName &tcn) { } #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(const InternalName *ptr) : ConstPointerTo(ptr) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(const PointerTo ©) : ConstPointerTo(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(const ConstPointerTo ©) : ConstPointerTo(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Conversion Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(const string &name) : ConstPointerTo(InternalName::make(name)) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Conversion Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CPT_InternalName:: CPT_InternalName(const char (&literal)[N]) : @@ -525,44 +423,36 @@ CPT_InternalName(const char (&literal)[N]) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(PointerTo &&from) NOEXCEPT : ConstPointerTo(move(from)) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName:: CPT_InternalName(ConstPointerTo &&from) NOEXCEPT : ConstPointerTo(move(from)) { } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName &CPT_InternalName:: operator = (PointerTo &&from) NOEXCEPT { this->reassign(move(from)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName &CPT_InternalName:: operator = (ConstPointerTo &&from) NOEXCEPT { this->reassign(move(from)); @@ -570,33 +460,27 @@ operator = (ConstPointerTo &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName &CPT_InternalName:: operator = (const To *ptr) { this->reassign((To *)ptr); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName &CPT_InternalName:: operator = (const PointerTo ©) { this->reassign((const ConstPointerTo &)copy); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: CPT_InternalName::Assignment operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPT_InternalName &CPT_InternalName:: operator = (const ConstPointerTo ©) { this->reassign((const ConstPointerTo &)copy); diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index c6f57af3ac..dcebada06e 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -1,16 +1,15 @@ -// Filename: internalName.cxx -// Created by: masad (15Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalName.cxx + * @author masad + * @date 2004-07-15 + */ #include "pandabase.h" #include "internalName.h" @@ -50,11 +49,9 @@ InternalName::PyInternTable InternalName::_py_intern_table; InternalName::LiteralTable InternalName::_literal_table; LightMutex InternalName::_literal_table_lock; -//////////////////////////////////////////////////////////////////// -// Function: InternalName::Constructor -// Access: Private -// Description: Use make() to make a new InternalName instance. -//////////////////////////////////////////////////////////////////// +/** + * Use make() to make a new InternalName instance. + */ InternalName:: InternalName(InternalName *parent, const string &basename) : _parent(parent), @@ -62,11 +59,9 @@ InternalName(InternalName *parent, const string &basename) : { } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InternalName:: ~InternalName() { #ifndef NDEBUG @@ -79,19 +74,16 @@ InternalName:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// clear the pointer from its parent's table when -// its reference count goes to zero. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to clear the pointer from its + * parent's table when its reference count goes to zero. + */ bool InternalName:: unref() const { if (_parent == (const InternalName *)NULL) { - // No parent; no problem. This is the root InternalName. - // Actually, this probably shouldn't be destructing, but I guess - // it might at application shutdown. + // No parent; no problem. This is the root InternalName. Actually, this + // probably shouldn't be destructing, but I guess it might at application + // shutdown. return TypedWritableReferenceCount::unref(); } @@ -109,14 +101,11 @@ unref() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::append -// Access: Published -// Description: Constructs a new InternalName based on this name, -// with the indicated string following it. This is a -// cheaper way to construct a hierarchical name than -// InternalName::make(parent->get_name() + ".basename"). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new InternalName based on this name, with the indicated string + * following it. This is a cheaper way to construct a hierarchical name than + * InternalName::make(parent->get_name() + ".basename"). + */ PT(InternalName) InternalName:: append(const string &name) { test_ref_count_integrity(); @@ -142,12 +131,10 @@ append(const string &name) { return internal_name; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_name -// Access: Published -// Description: Returns the complete name represented by the -// InternalName and all of its parents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete name represented by the InternalName and all of its + * parents. + */ string InternalName:: get_name() const { if (_parent == get_root()) { @@ -161,12 +148,9 @@ get_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::join -// Access: Published -// Description: Like get_name, but uses a custom separator instead -// of ".". -//////////////////////////////////////////////////////////////////// +/** + * Like get_name, but uses a custom separator instead of ".". + */ string InternalName:: join(const string &sep) const { if (_parent == get_root()) { @@ -180,17 +164,13 @@ join(const string &sep) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::find_ancestor -// Access: Published -// Description: Returns the index of the ancestor with the indicated -// basename, or -1 if no ancestor has that basename. -// Returns 0 if this name has the basename. -// -// This index value may be passed to get_ancestor() or -// get_net_basename() to retrieve more information about -// the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the ancestor with the indicated basename, or -1 if no + * ancestor has that basename. Returns 0 if this name has the basename. + * + * This index value may be passed to get_ancestor() or get_net_basename() to + * retrieve more information about the indicated name. + */ int InternalName:: find_ancestor(const string &basename) const { test_ref_count_integrity(); @@ -208,14 +188,11 @@ find_ancestor(const string &basename) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_ancestor -// Access: Published -// Description: Returns the ancestor with the indicated index number. -// 0 is this name itself, 1 is the name's parent, 2 is -// the parent's parent, and so on. If there are not -// enough ancestors, returns the root InternalName. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ancestor with the indicated index number. 0 is this name + * itself, 1 is the name's parent, 2 is the parent's parent, and so on. If + * there are not enough ancestors, returns the root InternalName. + */ const InternalName *InternalName:: get_ancestor(int n) const { test_ref_count_integrity(); @@ -231,14 +208,11 @@ get_ancestor(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_top -// Access: Published -// Description: Returns the oldest ancestor in the InternalName's -// chain, not counting the root. This will be the first -// name in the string, e.g. "texcoord.foo.bar" will -// return the InternalName "texcoord". -//////////////////////////////////////////////////////////////////// +/** + * Returns the oldest ancestor in the InternalName's chain, not counting the + * root. This will be the first name in the string, e.g. "texcoord.foo.bar" + * will return the InternalName "texcoord". + */ const InternalName *InternalName:: get_top() const { test_ref_count_integrity(); @@ -249,14 +223,11 @@ get_top() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::get_net_basename -// Access: Published -// Description: Returns the basename of this name prefixed by the -// indicated number of ancestors. 0 is this name's -// basename, 1 is parent.basename, 2 is -// grandparent.parent.basename, and so on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basename of this name prefixed by the indicated number of + * ancestors. 0 is this name's basename, 1 is parent.basename, 2 is + * grandparent.parent.basename, and so on. + */ string InternalName:: get_net_basename(int n) const { if (n < 0) { @@ -273,11 +244,9 @@ get_net_basename(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InternalName:: output(ostream &out) const { if (_parent == get_root()) { @@ -292,43 +261,36 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a InternalName object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a InternalName object + */ void InternalName:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); BamReader::get_factory()->register_factory(_texcoord_type_handle, make_texcoord_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void InternalName:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in make_from_bam(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make -// Access: Published, Static -// Description: Make using a string and an integer. Concatenates -// the two. -//////////////////////////////////////////////////////////////////// +/** + * Make using a string and an integer. Concatenates the two. + */ PT(InternalName) InternalName:: make(const string &name, int index) { std::ostringstream full; @@ -336,20 +298,16 @@ make(const string &name, int index) { return make(full.str()); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type InternalName is encountered -// in the Bam file. It should create the InternalName -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type InternalName is encountered in the Bam file. It should create the + * InternalName and extract its information from the file. + */ TypedWritable *InternalName:: make_from_bam(const FactoryParams ¶ms) { - // The process of making a InternalName is slightly - // different than making other Writable objects. - // That is because all creation of InternalNames should - // be done through the make() constructor. + // The process of making a InternalName is slightly different than making + // other Writable objects. That is because all creation of InternalNames + // should be done through the make() constructor. DatagramIterator scan; BamReader *manager; @@ -358,28 +316,25 @@ make_from_bam(const FactoryParams ¶ms) { // The name is the only thing written to the data stream. string name = scan.get_string(); - // Make a new InternalName with that name (or get the previous one - // if there is one already). + // Make a new InternalName with that name (or get the previous one if there + // is one already). PT(InternalName) me = make(name); - // But now we have a problem, since we have to hold the reference - // count and there's no way to return a TypedWritable while still - // holding the reference count! We work around this by explicitly - // upping the count, and also setting a finalize() callback to down - // it later. + // But now we have a problem, since we have to hold the reference count and + // there's no way to return a TypedWritable while still holding the + // reference count! We work around this by explicitly upping the count, and + // also setting a finalize() callback to down it later. me->ref(); manager->register_finalize(me); return me.p(); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make_texcoord_from_bam -// Access: Protected, Static -// Description: This is a temporary method; it exists only to support -// old bam files (4.11 through 4.17) generated before we -// renamed this class from TexCoordName to InternalName. -//////////////////////////////////////////////////////////////////// +/** + * This is a temporary method; it exists only to support old bam files (4.11 + * through 4.17) generated before we renamed this class from TexCoordName to + * InternalName. + */ TypedWritable *InternalName:: make_texcoord_from_bam(const FactoryParams ¶ms) { DatagramIterator scan; @@ -400,14 +355,11 @@ make_texcoord_from_bam(const FactoryParams ¶ms) { return me.p(); } -//////////////////////////////////////////////////////////////////// -// Function: InternalName::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void InternalName:: write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); } - diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index d6b9912bb4..7485e6f758 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -1,16 +1,15 @@ -// Filename: internalName.h -// Created by: drose (15Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalName.h + * @author drose + * @date 2004-07-15 + */ #ifndef INTERNALNAME_H #define INTERNALNAME_H @@ -25,21 +24,17 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : InternalName -// Description : Encodes a string name in a hash table, mapping it to -// a pointer. This is used to tokenify names so they -// may be used efficiently in low-level Panda -// structures, for instance to differentiate the -// multiple sets of texture coordinates that might be -// stored on a Geom. -// -// InternalNames are hierarchical, with the '.' used by -// convention as a separator character. You can -// construct a single InternalName as a composition of -// one or more other names, or by giving it a source -// string directly. -//////////////////////////////////////////////////////////////////// +/** + * Encodes a string name in a hash table, mapping it to a pointer. This is + * used to tokenify names so they may be used efficiently in low-level Panda + * structures, for instance to differentiate the multiple sets of texture + * coordinates that might be stored on a Geom. + * + * InternalNames are hierarchical, with the '.' used by convention as a + * separator character. You can construct a single InternalName as a + * composition of one or more other names, or by giving it a source string + * directly. + */ class EXPCL_PANDA_GOBJ InternalName FINAL : public TypedWritableReferenceCount { private: InternalName(InternalName *parent, const string &basename); @@ -99,8 +94,8 @@ PUBLISHED: INLINE static PT(InternalName) get_view(); #ifdef HAVE_PYTHON - // These versions are exposed to Python, which have additional logic - // to map from Python interned strings. + // These versions are exposed to Python, which have additional logic to map + // from Python interned strings. #if PY_MAJOR_VERSION >= 3 EXTENSION(static PT(InternalName) make(PyUnicodeObject *str)); #else @@ -110,8 +105,8 @@ PUBLISHED: public: #ifdef HAVE_PYTHON - // It's OK for us to define it here since these are just pointers of - // which the reference is maintained indefinitely. + // It's OK for us to define it here since these are just pointers of which + // the reference is maintained indefinitely. typedef phash_map PyInternTable; static PyInternTable _py_intern_table; #endif @@ -168,8 +163,8 @@ public: TypedWritableReferenceCount::init_type(); register_type(_type_handle, "InternalName", TypedWritableReferenceCount::get_class_type()); - // The _texcoord_type_handle is defined only to support older bam - // files, generated before we renamed the type to InternalName. + // The _texcoord_type_handle is defined only to support older bam files, + // generated before we renamed the type to InternalName. register_type(_texcoord_type_handle, "TexCoordName", TypedWritableReferenceCount::get_class_type()); } @@ -185,15 +180,12 @@ private: INLINE ostream &operator << (ostream &out, const InternalName &tcn); -//////////////////////////////////////////////////////////////////// -// Class : CPT_InternalName -// Description : This is a const pointer to an InternalName, and -// should be used in lieu of a CPT(InternalName) in -// function arguments. The extra feature that it -// offers is that it has a constructor to automatically -// convert from a string, so that strings are coerced -// by the compiler when passed to such a function. -//////////////////////////////////////////////////////////////////// +/** + * This is a const pointer to an InternalName, and should be used in lieu of a + * CPT(InternalName) in function arguments. The extra feature that it offers + * is that it has a constructor to automatically convert from a string, so + * that strings are coerced by the compiler when passed to such a function. + */ #ifdef CPPPARSER // The construct below confuses interrogate, so we give it a typedef. typedef ConstPointerTo CPT_InternalName; diff --git a/panda/src/gobj/internalName_ext.cxx b/panda/src/gobj/internalName_ext.cxx index f81e78fe98..24c2852968 100644 --- a/panda/src/gobj/internalName_ext.cxx +++ b/panda/src/gobj/internalName_ext.cxx @@ -1,29 +1,25 @@ -// Filename: internalName_ext.cxx -// Created by: rdb (28Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalName_ext.cxx + * @author rdb + * @date 2014-09-28 + */ #include "internalName_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: InternalName::make -// Access: Published, Static -// Description: This extension method serves to allow coercion of -// Python interned strings to InternalName objects -// more efficiently by storing a mapping between -// Python and Panda interned strings. -//////////////////////////////////////////////////////////////////// +/** + * This extension method serves to allow coercion of Python interned strings + * to InternalName objects more efficiently by storing a mapping between + * Python and Panda interned strings. + */ #if PY_MAJOR_VERSION >= 3 PT(InternalName) Extension:: make(PyUnicodeObject *str) { @@ -72,9 +68,8 @@ make(PyStringObject *str) { PT(InternalName) iname = InternalName::make(name); - // We basically leak references to both the PyObject and the - // InternalName. We may want to change that in the future if it - // becomes a problem. + // We basically leak references to both the PyObject and the InternalName. + // We may want to change that in the future if it becomes a problem. Py_INCREF(str); iname->ref(); diff --git a/panda/src/gobj/internalName_ext.h b/panda/src/gobj/internalName_ext.h index 83b1510428..20016abd60 100644 --- a/panda/src/gobj/internalName_ext.h +++ b/panda/src/gobj/internalName_ext.h @@ -1,16 +1,15 @@ -// Filename: internalName_ext.h -// Created by: rdb (28Sep14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalName_ext.h + * @author rdb + * @date 2014-09-28 + */ #ifndef INTERNALNAME_EXT_H #define INTERNALNAME_EXT_H @@ -23,12 +22,10 @@ #include "internalName.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// InternalName, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for InternalName, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/gobj/lens.I b/panda/src/gobj/lens.I index 94fd617572..337b60ab0c 100644 --- a/panda/src/gobj/lens.I +++ b/panda/src/gobj/lens.I @@ -1,33 +1,25 @@ -// Filename: lens.I -// Created by: drose (29Nov01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lens.I + * @author drose + * @date 2001-11-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Lens::extrude -// Access: Published -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * Returns true if the vector is defined, or false otherwise. + */ INLINE bool Lens:: extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { CDReader cdata(_cycler); @@ -35,108 +27,83 @@ extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { near_point, far_point); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::extrude -// Access: Published -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ INLINE bool Lens:: extrude(const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { CDReader cdata(_cycler); return do_extrude(cdata, point2d, near_point, far_point); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::extrude_depth -// Access: Published -// Description: Uses the depth component of the 3-d result from -// project() to compute the original point in 3-d space -// corresponding to a particular point on the lens. -// This exactly reverses project(), assuming the point -// does fall legitimately within the lens. -//////////////////////////////////////////////////////////////////// +/** + * Uses the depth component of the 3-d result from project() to compute the + * original point in 3-d space corresponding to a particular point on the + * lens. This exactly reverses project(), assuming the point does fall + * legitimately within the lens. + */ INLINE bool Lens:: extrude_depth(const LPoint3 &point2d, LPoint3 &point3d) const { CDReader cdata(_cycler); return do_extrude_depth(cdata, point2d, point3d); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::extrude_vec -// Access: Published -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the vector that corresponds to the view -// direction. This will be parallel to the normal on -// the surface (the far plane) corresponding to the lens -// shape at this point. -// -// See the comment block on Lens::extrude_vec_impl() for -// a more in-depth comment on the meaning of this -// vector. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * vector that corresponds to the view direction. This will be parallel to + * the normal on the surface (the far plane) corresponding to the lens shape + * at this point. + * + * See the comment block on Lens::extrude_vec_impl() for a more in-depth + * comment on the meaning of this vector. + * + * Returns true if the vector is defined, or false otherwise. + */ INLINE bool Lens:: extrude_vec(const LPoint2 &point2d, LVector3 &vec) const { CDReader cdata(_cycler); return do_extrude_vec(cdata, LPoint3(point2d[0], point2d[1], 0.0f), vec); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::extrude_vec -// Access: Published -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the vector that corresponds to the view -// direction. This will be parallel to the normal on -// the surface (the far plane) corresponding to the lens -// shape at this point. -// -// See the comment block on Lens::extrude_vec_impl() for -// a more in-depth comment on the meaning of this -// vector. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * vector that corresponds to the view direction. This will be parallel to + * the normal on the surface (the far plane) corresponding to the lens shape + * at this point. + * + * See the comment block on Lens::extrude_vec_impl() for a more in-depth + * comment on the meaning of this vector. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ INLINE bool Lens:: extrude_vec(const LPoint3 &point2d, LVector3 &vec) const { CDReader cdata(_cycler); return do_extrude_vec(cdata, point2d, vec); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::project -// Access: Published -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise (in which case -// point2d will be filled in with something, which may -// or may not be meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise + * (in which case point2d will be filled in with something, which may or may + * not be meaningful). + */ INLINE bool Lens:: project(const LPoint3 &point3d, LPoint2 &point2d) const { CDReader cdata(_cycler); @@ -146,439 +113,347 @@ project(const LPoint3 &point3d, LPoint2 &point2d) const { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::project -// Access: Published -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// The z coordinate will also be set to a value in the -// range (-1, 1), where 1 represents a point on the near -// plane, and -1 represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise (in which case -// point2d will be filled in with something, which may -// or may not be meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * The z coordinate will also be set to a value in the range (-1, 1), where 1 + * represents a point on the near plane, and -1 represents a point on the far + * plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise + * (in which case point2d will be filled in with something, which may or may + * not be meaningful). + */ INLINE bool Lens:: project(const LPoint3 &point3d, LPoint3 &point2d) const { CDReader cdata(_cycler); return do_project(cdata, point3d, point2d); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_change_event -// Access: Published -// Description: Sets the name of the event that will be generated -// whenever any properties of the Lens have -// changed. If this is not set for a particular lens, -// no event will be generated. -// -// The event is thrown with one parameter, the lens -// itself. This can be used to automatically track -// changes to camera fov, etc. in the application. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the event that will be generated whenever any properties + * of the Lens have changed. If this is not set for a particular lens, no + * event will be generated. + * + * The event is thrown with one parameter, the lens itself. This can be used + * to automatically track changes to camera fov, etc. in the application. + */ INLINE void Lens:: set_change_event(const string &event) { CDWriter cdata(_cycler, true); cdata->_change_event = event; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_change_event -// Access: Published -// Description: Returns the name of the event that will be generated -// whenever any properties of this particular Lens have -// changed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the event that will be generated whenever any + * properties of this particular Lens have changed. + */ INLINE const string &Lens:: get_change_event() const { CDReader cdata(_cycler); return cdata->_change_event; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_coordinate_system -// Access: Published -// Description: Returns the coordinate system that all 3-d -// computations are performed within for this -// Lens. Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system that all 3-d computations are performed + * within for this Lens. Normally, this is CS_default. + */ INLINE CoordinateSystem Lens:: get_coordinate_system() const { CDReader cdata(_cycler); return cdata->_cs; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_film_size -// Access: Published -// Description: Sets the horizontal size of the film without changing -// its shape. The aspect ratio remains unchanged; this -// computes the vertical size of the film to -// automatically maintain the aspect ratio. -//////////////////////////////////////////////////////////////////// +/** + * Sets the horizontal size of the film without changing its shape. The + * aspect ratio remains unchanged; this computes the vertical size of the film + * to automatically maintain the aspect ratio. + */ INLINE void Lens:: set_film_size(PN_stdfloat width) { CDWriter cdata(_cycler, true); do_set_film_size(cdata, width); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_film_size -// Access: Published -// Description: Sets the size and shape of the "film" within the -// lens. This both establishes the units used by -// calls like set_focal_length(), and establishes the -// aspect ratio of the frame. -// -// In a physical camera, the field of view of a lens is -// determined by the lens' focal length and by the size -// of the film area exposed by the lens. For instance, -// a 35mm camera exposes a rectangle on the film about -// 24mm x 36mm, which means a 50mm lens gives about a -// 40-degree horizontal field of view. -// -// In the virtual camera, you may set the film size to -// any units here, and specify a focal length in the -// same units to simulate the same effect. Or, you may -// ignore this parameter, and specify the field of view -// and aspect ratio of the lens directly. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size and shape of the "film" within the lens. This both + * establishes the units used by calls like set_focal_length(), and + * establishes the aspect ratio of the frame. + * + * In a physical camera, the field of view of a lens is determined by the + * lens' focal length and by the size of the film area exposed by the lens. + * For instance, a 35mm camera exposes a rectangle on the film about 24mm x + * 36mm, which means a 50mm lens gives about a 40-degree horizontal field of + * view. + * + * In the virtual camera, you may set the film size to any units here, and + * specify a focal length in the same units to simulate the same effect. Or, + * you may ignore this parameter, and specify the field of view and aspect + * ratio of the lens directly. + */ INLINE void Lens:: set_film_size(PN_stdfloat width, PN_stdfloat height) { set_film_size(LVecBase2(width, height)); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_film_size -// Access: Published -// Description: Sets the size and shape of the "film" within the -// lens. This both establishes the units used by -// calls like set_focal_length(), and establishes the -// aspect ratio of the frame. -// -// In a physical camera, the field of view of a lens is -// determined by the lens' focal length and by the size -// of the film area exposed by the lens. For instance, -// a 35mm camera exposes a rectangle on the film about -// 24mm x 36mm, which means a 50mm lens gives about a -// 40-degree horizontal field of view. -// -// In the virtual camera, you may set the film size to -// any units here, and specify a focal length in the -// same units to simulate the same effect. Or, you may -// ignore this parameter, and specify the field of view -// and aspect ratio of the lens directly. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size and shape of the "film" within the lens. This both + * establishes the units used by calls like set_focal_length(), and + * establishes the aspect ratio of the frame. + * + * In a physical camera, the field of view of a lens is determined by the + * lens' focal length and by the size of the film area exposed by the lens. + * For instance, a 35mm camera exposes a rectangle on the film about 24mm x + * 36mm, which means a 50mm lens gives about a 40-degree horizontal field of + * view. + * + * In the virtual camera, you may set the film size to any units here, and + * specify a focal length in the same units to simulate the same effect. Or, + * you may ignore this parameter, and specify the field of view and aspect + * ratio of the lens directly. + */ INLINE void Lens:: set_film_size(const LVecBase2 &film_size) { CDWriter cdata(_cycler, true); do_set_film_size(cdata, film_size); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_film_size -// Access: Published -// Description: Returns the horizontal and vertical film size of -// the virtual film. See set_film_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the horizontal and vertical film size of the virtual film. See + * set_film_size(). + */ INLINE const LVecBase2 &Lens:: get_film_size() const { CDReader cdata(_cycler); return do_get_film_size(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_film_offset -// Access: Published -// Description: Sets the horizontal and vertical offset amounts of -// this Lens. These are both in the same units -// specified in set_film_size(). -// -// This can be used to establish an off-axis lens. -//////////////////////////////////////////////////////////////////// +/** + * Sets the horizontal and vertical offset amounts of this Lens. These are + * both in the same units specified in set_film_size(). + * + * This can be used to establish an off-axis lens. + */ INLINE void Lens:: set_film_offset(PN_stdfloat x, PN_stdfloat y) { set_film_offset(LVecBase2(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_film_offset -// Access: Published -// Description: Sets the horizontal and vertical offset amounts of -// this Lens. These are both in the same units -// specified in set_film_size(). -// -// This can be used to establish an off-axis lens. -//////////////////////////////////////////////////////////////////// +/** + * Sets the horizontal and vertical offset amounts of this Lens. These are + * both in the same units specified in set_film_size(). + * + * This can be used to establish an off-axis lens. + */ INLINE void Lens:: set_film_offset(const LVecBase2 &film_offset) { CDWriter cdata(_cycler, true); do_set_film_offset(cdata, film_offset); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_film_offset -// Access: Published -// Description: Returns the horizontal and vertical offset amounts of -// this Lens. See set_film_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the horizontal and vertical offset amounts of this Lens. See + * set_film_offset(). + */ INLINE const LVector2 &Lens:: get_film_offset() const { CDReader cdata(_cycler); return do_get_film_offset(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_focal_length -// Access: Published -// Description: Sets the focal length of the lens. This may adjust -// the field-of-view correspondingly, and is an -// alternate way to specify field of view. -// -// For certain kinds of lenses (e.g. OrthographicLens), -// the focal length has no meaning. -//////////////////////////////////////////////////////////////////// +/** + * Sets the focal length of the lens. This may adjust the field-of-view + * correspondingly, and is an alternate way to specify field of view. + * + * For certain kinds of lenses (e.g. OrthographicLens), the focal length has + * no meaning. + */ INLINE void Lens:: set_focal_length(PN_stdfloat focal_length) { CDWriter cdata(_cycler, true); do_set_focal_length(cdata, focal_length); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_focal_length -// Access: Published -// Description: Returns the focal length of the lens. This may have -// been set explicitly by a previous call to -// set_focal_length(), or it may be computed based on -// the lens' fov and film_size. For certain kinds of -// lenses, the focal length has no meaning. -//////////////////////////////////////////////////////////////////// +/** + * Returns the focal length of the lens. This may have been set explicitly by + * a previous call to set_focal_length(), or it may be computed based on the + * lens' fov and film_size. For certain kinds of lenses, the focal length has + * no meaning. + */ INLINE PN_stdfloat Lens:: get_focal_length() const { CDReader cdata(_cycler); return do_get_focal_length(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_fov -// Access: Published -// Description: Sets the horizontal field of view of the lens without -// changing the aspect ratio. The vertical field of -// view is adjusted to maintain the same aspect ratio. -//////////////////////////////////////////////////////////////////// +/** + * Sets the horizontal field of view of the lens without changing the aspect + * ratio. The vertical field of view is adjusted to maintain the same aspect + * ratio. + */ INLINE void Lens:: set_fov(PN_stdfloat hfov) { CDWriter cdata(_cycler, true); do_set_fov(cdata, hfov); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_fov -// Access: Published -// Description: Sets the field of view of the lens in both -// dimensions. This establishes both the field of view -// and the aspect ratio of the lens. This is one way to -// specify the field of view of a lens; -// set_focal_length() is another way. -// -// For certain kinds of lenses (like OrthoLens), -// the field of view has no meaning. -//////////////////////////////////////////////////////////////////// +/** + * Sets the field of view of the lens in both dimensions. This establishes + * both the field of view and the aspect ratio of the lens. This is one way + * to specify the field of view of a lens; set_focal_length() is another way. + * + * For certain kinds of lenses (like OrthoLens), the field of view has no + * meaning. + */ INLINE void Lens:: set_fov(PN_stdfloat hfov, PN_stdfloat vfov) { set_fov(LVecBase2(hfov, vfov)); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_fov -// Access: Published -// Description: Sets the field of view of the lens in both -// dimensions. This establishes both the field of view -// and the aspect ratio of the lens. This is one way to -// specify the field of view of a lens; -// set_focal_length() is another way. -// -// For certain kinds of lenses (like OrthographicLens), -// the field of view has no meaning. -//////////////////////////////////////////////////////////////////// +/** + * Sets the field of view of the lens in both dimensions. This establishes + * both the field of view and the aspect ratio of the lens. This is one way + * to specify the field of view of a lens; set_focal_length() is another way. + * + * For certain kinds of lenses (like OrthographicLens), the field of view has + * no meaning. + */ INLINE void Lens:: set_fov(const LVecBase2 &fov) { CDWriter cdata(_cycler, true); do_set_fov(cdata, fov); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_fov -// Access: Published -// Description: Returns the horizontal and vertical film size of -// the virtual film. See set_fov(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the horizontal and vertical film size of the virtual film. See + * set_fov(). + */ INLINE const LVecBase2 &Lens:: get_fov() const { CDReader cdata(_cycler); return do_get_fov(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_hfov -// Access: Published -// Description: Returns the horizontal component of fov only. See -// get_fov(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the horizontal component of fov only. See get_fov(). + */ INLINE PN_stdfloat Lens:: get_hfov() const { return get_fov()[0]; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_vfov -// Access: Published -// Description: Returns the vertical component of fov only. See -// get_fov(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertical component of fov only. See get_fov(). + */ INLINE PN_stdfloat Lens:: get_vfov() const { return get_fov()[1]; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_aspect_ratio -// Access: Published -// Description: Sets the aspect ratio of the lens. This is the ratio -// of the height to the width of the generated image. -// Setting this overrides the two-parameter fov or film -// size setting. -//////////////////////////////////////////////////////////////////// +/** + * Sets the aspect ratio of the lens. This is the ratio of the height to the + * width of the generated image. Setting this overrides the two-parameter fov + * or film size setting. + */ INLINE void Lens:: set_aspect_ratio(PN_stdfloat aspect_ratio) { CDWriter cdata(_cycler, true); do_set_aspect_ratio(cdata, aspect_ratio); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_aspect_ratio -// Access: Published -// Description: Returns the aspect ratio of the Lens. This is -// determined based on the indicated film size; see -// set_film_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the aspect ratio of the Lens. This is determined based on the + * indicated film size; see set_film_size(). + */ INLINE PN_stdfloat Lens:: get_aspect_ratio() const { CDReader cdata(_cycler); return do_get_aspect_ratio(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_near -// Access: Published -// Description: Defines the position of the near plane (or cylinder, -// sphere, whatever). Points closer to the lens than -// this may not be rendered. -//////////////////////////////////////////////////////////////////// +/** + * Defines the position of the near plane (or cylinder, sphere, whatever). + * Points closer to the lens than this may not be rendered. + */ INLINE void Lens:: set_near(PN_stdfloat near_distance) { CDWriter cdata(_cycler, true); do_set_near(cdata, near_distance); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_near -// Access: Published -// Description: Returns the position of the near plane (or cylinder, -// sphere, whatever). -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the near plane (or cylinder, sphere, whatever). + */ INLINE PN_stdfloat Lens:: get_near() const { CDReader cdata(_cycler); return do_get_near(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_far -// Access: Published -// Description: Defines the position of the far plane (or cylinder, -// sphere, whatever). Points farther from the lens than -// this may not be rendered. -//////////////////////////////////////////////////////////////////// +/** + * Defines the position of the far plane (or cylinder, sphere, whatever). + * Points farther from the lens than this may not be rendered. + */ INLINE void Lens:: set_far(PN_stdfloat far_distance) { CDWriter cdata(_cycler, true); do_set_far(cdata, far_distance); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_far -// Access: Published -// Description: Returns the position of the far plane (or cylinder, -// sphere, whatever). -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the far plane (or cylinder, sphere, whatever). + */ INLINE PN_stdfloat Lens:: get_far() const { CDReader cdata(_cycler); return do_get_far(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_near_far -// Access: Published -// Description: Simultaneously changes the near and far planes. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously changes the near and far planes. + */ INLINE void Lens:: set_near_far(PN_stdfloat near_distance, PN_stdfloat far_distance) { CDWriter cdata(_cycler, true); do_set_near_far(cdata, near_distance, far_distance); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_view_hpr -// Access: Published -// Description: Sets the direction in which the lens is facing. -// Normally, this is down the forward axis (usually the -// Y axis), but it may be rotated. This is only one way -// of specifying the rotation; you may also specify an -// explicit vector in which to look, or you may give a -// complete transformation matrix. -//////////////////////////////////////////////////////////////////// +/** + * Sets the direction in which the lens is facing. Normally, this is down the + * forward axis (usually the Y axis), but it may be rotated. This is only one + * way of specifying the rotation; you may also specify an explicit vector in + * which to look, or you may give a complete transformation matrix. + */ INLINE void Lens:: set_view_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_view_hpr(LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_view_vector -// Access: Published -// Description: Specifies the direction in which the lens is facing -// by giving an axis to look along, and a perpendicular -// (or at least non-parallel) up axis. -// -// See also set_view_hpr(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the direction in which the lens is facing by giving an axis to + * look along, and a perpendicular (or at least non-parallel) up axis. + * + * See also set_view_hpr(). + */ INLINE void Lens:: set_view_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat i, PN_stdfloat j, PN_stdfloat k) { set_view_vector(LVector3(x, y, z), LVector3(i, j, k)); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_interocular_distance -// Access: Published -// Description: Sets the distance between the left and right eyes of -// a stereo camera. This distance is used to apply a -// stereo effect when the lens is rendered on a stereo -// display region. It only has an effect on a -// PerspectiveLens. -// -// The left eye and the right eye are each offset along -// the X axis by half of this distance, so that this -// parameter specifies the total distance between them. -// -// Also see set_convergence_distance(), which relates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance between the left and right eyes of a stereo camera. This + * distance is used to apply a stereo effect when the lens is rendered on a + * stereo display region. It only has an effect on a PerspectiveLens. + * + * The left eye and the right eye are each offset along the X axis by half of + * this distance, so that this parameter specifies the total distance between + * them. + * + * Also see set_convergence_distance(), which relates. + */ INLINE void Lens:: set_interocular_distance(PN_stdfloat interocular_distance) { CDWriter cdata(_cycler, true); @@ -586,51 +461,40 @@ set_interocular_distance(PN_stdfloat interocular_distance) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_interocular_distance -// Access: Published -// Description: See set_interocular_distance(). -//////////////////////////////////////////////////////////////////// +/** + * See set_interocular_distance(). + */ INLINE PN_stdfloat Lens:: get_interocular_distance() const { CDReader cdata(_cycler); return cdata->_interocular_distance; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_convergence_distance -// Access: Published -// Description: Sets the distance between between the camera plane -// and the point in the distance that the left and right -// eyes are both looking at. This distance is used to -// apply a stereo effect when the lens is rendered on a -// stereo display region. It only has an effect on a -// PerspectiveLens. -// -// This parameter must be greater than 0, but may be as -// large as you like. It controls the distance at -// which the two stereo images will appear to converge, -// which is a normal property of stereo vision. Normally -// this should be set to the distance from the camera to -// the area of interest in your scene. Anything beyond -// this distance will appear to go into the screen, and -// anything closer will appear to come out of the screen. -// If you want to simulate parallel stereo, set this -// to infinity. -// -// Note that this creates an off-axis frustum, which -// means that the lenses are still pointing in the -// same direction, which is usually more desirable -// than the more naive toe-in approach, where the -// two lenses are simply tilted toward each other. -// -// Prior to Panda3D 1.9.0, the convergence was being -// calculated incorrectly. It has since been corrected. -// To restore the legacy behavior you can set the -// stereo-lens-old-convergence variable to true. -// -// Also see set_interocular_distance(), which relates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance between between the camera plane and the point in the + * distance that the left and right eyes are both looking at. This distance + * is used to apply a stereo effect when the lens is rendered on a stereo + * display region. It only has an effect on a PerspectiveLens. + * + * This parameter must be greater than 0, but may be as large as you like. It + * controls the distance at which the two stereo images will appear to + * converge, which is a normal property of stereo vision. Normally this + * should be set to the distance from the camera to the area of interest in + * your scene. Anything beyond this distance will appear to go into the + * screen, and anything closer will appear to come out of the screen. If you + * want to simulate parallel stereo, set this to infinity. + * + * Note that this creates an off-axis frustum, which means that the lenses are + * still pointing in the same direction, which is usually more desirable than + * the more naive toe-in approach, where the two lenses are simply tilted + * toward each other. + * + * Prior to Panda3D 1.9.0, the convergence was being calculated incorrectly. + * It has since been corrected. To restore the legacy behavior you can set + * the stereo-lens-old-convergence variable to true. + * + * Also see set_interocular_distance(), which relates. + */ INLINE void Lens:: set_convergence_distance(PN_stdfloat convergence_distance) { CDWriter cdata(_cycler, true); @@ -638,189 +502,151 @@ set_convergence_distance(PN_stdfloat convergence_distance) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_convergence_distance -// Access: Published -// Description: See set_convergence_distance(). -//////////////////////////////////////////////////////////////////// +/** + * See set_convergence_distance(). + */ INLINE PN_stdfloat Lens:: get_convergence_distance() const { CDReader cdata(_cycler); return cdata->_convergence_distance; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_view_mat -// Access: Published -// Description: Sets an arbitrary transformation on the lens. This -// replaces the individual transformation components -// like set_view_hpr(). -// -// Setting a transformation here will have a slightly -// different effect than putting one on the LensNode -// that contains this lens. In particular, lighting and -// other effects computations will still be performed on -// the lens in its untransformed (facing forward) -// position, but the actual projection matrix will be -// transformed by this matrix. -//////////////////////////////////////////////////////////////////// +/** + * Sets an arbitrary transformation on the lens. This replaces the individual + * transformation components like set_view_hpr(). + * + * Setting a transformation here will have a slightly different effect than + * putting one on the LensNode that contains this lens. In particular, + * lighting and other effects computations will still be performed on the lens + * in its untransformed (facing forward) position, but the actual projection + * matrix will be transformed by this matrix. + */ INLINE void Lens:: set_view_mat(const LMatrix4 &view_mat) { CDWriter cdata(_cycler, true); do_set_view_mat(cdata, view_mat); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_view_mat -// Access: Published -// Description: Returns the direction in which the lens is facing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction in which the lens is facing. + */ INLINE const LMatrix4 &Lens:: get_view_mat() const { CDReader cdata(_cycler); return do_get_view_mat(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_keystone -// Access: Published -// Description: Returns the keystone correction specified for the -// lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns the keystone correction specified for the lens. + */ INLINE const LVecBase2 &Lens:: get_keystone() const { CDReader cdata(_cycler); return cdata->_keystone; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_custom_film_mat -// Access: Published -// Description: Returns the custom_film_mat specified for the -// lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns the custom_film_mat specified for the lens. + */ INLINE const LMatrix4 &Lens:: get_custom_film_mat() const { CDReader cdata(_cycler); return cdata->_custom_film_mat; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_projection_mat -// Access: Published -// Description: Returns the complete transformation matrix from a 3-d -// point in space to a point on the film, if such a -// matrix exists, or the identity matrix if the lens is -// nonlinear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete transformation matrix from a 3-d point in space to a + * point on the film, if such a matrix exists, or the identity matrix if the + * lens is nonlinear. + */ INLINE const LMatrix4 &Lens:: get_projection_mat(StereoChannel channel) const { CDReader cdata(_cycler); return do_get_projection_mat(cdata, channel); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_projection_mat_inv -// Access: Published -// Description: Returns the matrix that transforms from a 2-d point -// on the film to a 3-d vector in space, if such a -// matrix exists. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that transforms from a 2-d point on the film to a 3-d + * vector in space, if such a matrix exists. + */ INLINE const LMatrix4 &Lens:: get_projection_mat_inv(StereoChannel stereo_channel) const { CDReader cdata(_cycler); return do_get_projection_mat_inv(cdata, stereo_channel); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_film_mat -// Access: Published -// Description: Returns the matrix that transforms from a point -// behind the lens to a point on the film. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that transforms from a point behind the lens to a point + * on the film. + */ INLINE const LMatrix4 &Lens:: get_film_mat() const { CDReader cdata(_cycler); return do_get_film_mat(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_film_mat_inv -// Access: Published -// Description: Returns the matrix that transforms from a point on -// the film to a point behind the lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that transforms from a point on the film to a point + * behind the lens. + */ INLINE const LMatrix4 &Lens:: get_film_mat_inv() const { CDReader cdata(_cycler); return do_get_film_mat_inv(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_lens_mat -// Access: Published -// Description: Returns the matrix that transforms from a point -// in front of the lens to a point in space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that transforms from a point in front of the lens to a + * point in space. + */ INLINE const LMatrix4 &Lens:: get_lens_mat() const { CDReader cdata(_cycler); return do_get_lens_mat(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_lens_mat_inv -// Access: Published -// Description: Returns the matrix that transforms from a point in -// space to a point in front of the lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that transforms from a point in space to a point in + * front of the lens. + */ INLINE const LMatrix4 &Lens:: get_lens_mat_inv() const { CDReader cdata(_cycler); return do_get_lens_mat_inv(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_last_change -// Access: Published -// Description: Returns the UpdateSeq that is incremented whenever -// the lens properties are changed. As long as this -// number remains the same, you may assume the lens -// properties are unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UpdateSeq that is incremented whenever the lens properties are + * changed. As long as this number remains the same, you may assume the lens + * properties are unchanged. + */ INLINE UpdateSeq Lens:: get_last_change() const { CDReader cdata(_cycler); return cdata->_last_change; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_adjust_user_flags -// Access: Protected -// Description: Clears from _user_flags the bits in the first -// parameter, and sets the bits in the second parameter. -//////////////////////////////////////////////////////////////////// +/** + * Clears from _user_flags the bits in the first parameter, and sets the bits + * in the second parameter. + */ INLINE void Lens:: do_adjust_user_flags(CData *cdata, int clear_flags, int set_flags) { cdata->_user_flags = (cdata->_user_flags & ~clear_flags) | (short)set_flags; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_adjust_comp_flags -// Access: Protected -// Description: Clears from _comp_flags the bits in the first -// parameter, and sets the bits in the second parameter. -//////////////////////////////////////////////////////////////////// +/** + * Clears from _comp_flags the bits in the first parameter, and sets the bits + * in the second parameter. + */ INLINE void Lens:: do_adjust_comp_flags(CData *cdata, int clear_flags, int set_flags) { cdata->_comp_flags = (cdata->_comp_flags & ~clear_flags) | (short)set_flags; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_film_offset -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Lens:: do_set_film_offset(CData *cdata, const LVecBase2 &film_offset) { cdata->_film_offset = film_offset; @@ -828,21 +654,17 @@ do_set_film_offset(CData *cdata, const LVecBase2 &film_offset) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_film_offset -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVector2 &Lens:: do_get_film_offset(const CData *cdata) const { return cdata->_film_offset; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_near -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Lens:: do_set_near(CData *cdata, PN_stdfloat near_distance) { cdata->_near_distance = near_distance; @@ -850,21 +672,17 @@ do_set_near(CData *cdata, PN_stdfloat near_distance) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_near -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat Lens:: do_get_near(const CData *cdata) const { return cdata->_near_distance; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_far -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Lens:: do_set_far(CData *cdata, PN_stdfloat far_distance) { cdata->_far_distance = far_distance; @@ -872,21 +690,17 @@ do_set_far(CData *cdata, PN_stdfloat far_distance) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_far -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat Lens:: do_get_far(const CData *cdata) const { return cdata->_far_distance; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_near_far -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Lens:: do_set_near_far(CData *cdata, PN_stdfloat near_distance, PN_stdfloat far_distance) { cdata->_near_distance = near_distance; @@ -900,4 +714,3 @@ operator << (ostream &out, const Lens &lens) { lens.output(out); return out; } - diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index b0e050a5e0..fc5c5222d8 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -1,16 +1,15 @@ -// Filename: lens.cxx -// Created by: drose (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lens.cxx + * @author drose + * @date 1999-02-18 + */ #include "lens.h" #include "throw_event.h" @@ -27,21 +26,17 @@ TypeHandle Lens::_type_handle; TypeHandle Lens::CData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Lens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Lens:: Lens() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Lens:: Lens(const Lens ©) : _cycler(copy._cycler) { // We don't copy the _geom_data. That's unique to each Lens. @@ -49,11 +44,9 @@ Lens(const Lens ©) : _cycler(copy._cycler) { cdata->_geom_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: operator = (const Lens ©) { _cycler = copy._cycler; @@ -63,13 +56,10 @@ operator = (const Lens ©) { cdata->_geom_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_coordinate_system -// Access: Published -// Description: Specifies the coordinate system that all 3-d -// computations are performed within for this -// Lens. Normally, this is CS_default. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the coordinate system that all 3-d computations are performed + * within for this Lens. Normally, this is CS_default. + */ void Lens:: set_coordinate_system(CoordinateSystem cs) { CDWriter cdata(_cycler, true); @@ -78,12 +68,9 @@ set_coordinate_system(CoordinateSystem cs) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::clear -// Access: Published -// Description: Resets all lens parameters to their initial default -// settings. -//////////////////////////////////////////////////////////////////// +/** + * Resets all lens parameters to their initial default settings. + */ void Lens:: clear() { CDWriter cdata(_cycler, true); @@ -94,29 +81,25 @@ clear() { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_min_fov -// Access: Published -// Description: Sets the field of view of the smallest dimension of -// the window. If the window is wider than it is tall, -// this specifies the vertical field of view; if it is -// taller than it is wide, this specifies the horizontal -// field of view. -// -// In many cases, this is preferable to setting either -// the horizontal or vertical field of view explicitly. -// Setting this parameter means that pulling the window -// wider will widen the field of view, which is usually -// what you expect to happen. -//////////////////////////////////////////////////////////////////// +/** + * Sets the field of view of the smallest dimension of the window. If the + * window is wider than it is tall, this specifies the vertical field of view; + * if it is taller than it is wide, this specifies the horizontal field of + * view. + * + * In many cases, this is preferable to setting either the horizontal or + * vertical field of view explicitly. Setting this parameter means that + * pulling the window wider will widen the field of view, which is usually + * what you expect to happen. + */ void Lens:: set_min_fov(PN_stdfloat min_fov) { nassertv(!cnan(min_fov)); CDWriter cdata(_cycler, true); cdata->_min_fov = min_fov; - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_fov_seq, cdata->_focal_length_seq, cdata->_film_size_seq); if (cdata->_focal_length_seq == 0) { @@ -140,12 +123,10 @@ set_min_fov(PN_stdfloat min_fov) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_min_fov -// Access: Published -// Description: Returns the field of view of the narrowest dimension -// of the window. See set_min_fov(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the field of view of the narrowest dimension of the window. See + * set_min_fov(). + */ PN_stdfloat Lens:: get_min_fov() const { CDReader cdata(_cycler); @@ -155,41 +136,31 @@ get_min_fov() const { } return cdata->_min_fov; } - -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_default_near -// Access: Published, Static -// Description: Returns the default near plane distance that will be -// assigned to each newly-created lens. This is read -// from the Configrc file. -//////////////////////////////////////////////////////////////////// + +/** + * Returns the default near plane distance that will be assigned to each + * newly-created lens. This is read from the Configrc file. + */ PN_stdfloat Lens:: get_default_near() { return default_near; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_default_far -// Access: Published, Static -// Description: Returns the default far plane distance that will be -// assigned to each newly-created lens. This is read -// from the Configrc file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default far plane distance that will be assigned to each newly- + * created lens. This is read from the Configrc file. + */ PN_stdfloat Lens:: get_default_far() { return default_far; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_view_hpr -// Access: Published -// Description: Sets the direction in which the lens is facing. -// Normally, this is down the forward axis (usually the -// Y axis), but it may be rotated. This is only one way -// of specifying the rotation; you may also specify an -// explicit vector in which to look, or you may give a -// complete transformation matrix. -//////////////////////////////////////////////////////////////////// +/** + * Sets the direction in which the lens is facing. Normally, this is down the + * forward axis (usually the Y axis), but it may be rotated. This is only one + * way of specifying the rotation; you may also specify an explicit vector in + * which to look, or you may give a complete transformation matrix. + */ void Lens:: set_view_hpr(const LVecBase3 &view_hpr) { nassertv(!view_hpr.is_nan()); @@ -202,11 +173,9 @@ set_view_hpr(const LVecBase3 &view_hpr) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_view_hpr -// Access: Published -// Description: Returns the direction in which the lens is facing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction in which the lens is facing. + */ const LVecBase3 &Lens:: get_view_hpr() const { CDReader cdata(_cycler); @@ -216,15 +185,12 @@ get_view_hpr() const { return cdata->_view_hpr; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_view_vector -// Access: Published -// Description: Specifies the direction in which the lens is facing -// by giving an axis to look along, and a perpendicular -// (or at least non-parallel) up axis. -// -// See also set_view_hpr(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the direction in which the lens is facing by giving an axis to + * look along, and a perpendicular (or at least non-parallel) up axis. + * + * See also set_view_hpr(). + */ void Lens:: set_view_vector(const LVector3 &view_vector, const LVector3 &up_vector) { nassertv(!view_vector.is_nan()); @@ -238,11 +204,9 @@ set_view_vector(const LVector3 &view_vector, const LVector3 &up_vector) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_view_vector -// Access: Published -// Description: Returns the axis along which the lens is facing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the axis along which the lens is facing. + */ const LVector3 &Lens:: get_view_vector() const { CDReader cdata(_cycler); @@ -252,12 +216,10 @@ get_view_vector() const { return cdata->_view_vector; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_up_vector -// Access: Published -// Description: Returns the axis perpendicular to the camera's view -// vector that indicates the "up" direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the axis perpendicular to the camera's view vector that indicates + * the "up" direction. + */ const LVector3 &Lens:: get_up_vector() const { CDReader cdata(_cycler); @@ -267,51 +229,42 @@ get_up_vector() const { return cdata->_up_vector; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::get_nodal_point -// Access: Published -// Description: Returns the center point of the lens: the point from -// which the lens is viewing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center point of the lens: the point from which the lens is + * viewing. + */ LPoint3 Lens:: get_nodal_point() const { return get_view_mat().get_row3(3); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::clear_view_mat -// Access: Published -// Description: Resets the lens transform to identity. -//////////////////////////////////////////////////////////////////// +/** + * Resets the lens transform to identity. + */ void Lens:: clear_view_mat() { CDWriter cdata(_cycler, true); cdata->_lens_mat = LMatrix4::ident_mat(); do_adjust_user_flags(cdata, 0, UF_view_vector | UF_view_hpr | UF_view_mat); - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_lens_mat_inv | CF_view_hpr | CF_view_vector, CF_lens_mat); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_keystone -// Access: Published -// Description: Indicates the ratio of keystone correction to perform -// on the lens, in each of three axes. This will build -// a special non-affine scale factor into the projection -// matrix that will compensate for keystoning of a -// projected image; this can be used to compensate for a -// projector that for physical reasons cannot be aimed -// directly at its screen. -// -// The default value is taken from the default-keystone -// Config variable. 0, 0 indicates no keystone -// correction; specify a small value (usually in the -// range -1 .. 1) in either the x or y position to -// generate a keystone correction in that axis. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the ratio of keystone correction to perform on the lens, in each + * of three axes. This will build a special non-affine scale factor into the + * projection matrix that will compensate for keystoning of a projected image; + * this can be used to compensate for a projector that for physical reasons + * cannot be aimed directly at its screen. + * + * The default value is taken from the default-keystone Config variable. 0, 0 + * indicates no keystone correction; specify a small value (usually in the + * range -1 .. 1) in either the x or y position to generate a keystone + * correction in that axis. + */ void Lens:: set_keystone(const LVecBase2 &keystone) { nassertv(!keystone.is_nan()); @@ -319,39 +272,33 @@ set_keystone(const LVecBase2 &keystone) { cdata->_keystone = keystone; do_adjust_user_flags(cdata, 0, UF_keystone); do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_film_mat | CF_film_mat_inv, 0); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::clear_keystone -// Access: Published -// Description: Disables the lens keystone correction. -//////////////////////////////////////////////////////////////////// +/** + * Disables the lens keystone correction. + */ void Lens:: clear_keystone() { CDWriter cdata(_cycler, true); cdata->_keystone.set(0.0f, 0.0f); do_adjust_user_flags(cdata, UF_keystone, 0); - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_film_mat | CF_film_mat_inv, 0); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_custom_film_mat -// Access: Published -// Description: Specifies a custom matrix to transform the points on -// the film after they have been converted into nominal -// film space (-1 .. 1 in U and V). This can be used to -// introduce arbitrary scales, rotations, or other -// linear transforms to the media plane. This is -// normally a 2-d matrix, but a full 4x4 matrix may be -// specified. This is applied on top of any film size, -// lens shift, and/or keystone correction. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a custom matrix to transform the points on the film after they + * have been converted into nominal film space (-1 .. 1 in U and V). This can + * be used to introduce arbitrary scales, rotations, or other linear + * transforms to the media plane. This is normally a 2-d matrix, but a full + * 4x4 matrix may be specified. This is applied on top of any film size, lens + * shift, and/or keystone correction. + */ void Lens:: set_custom_film_mat(const LMatrix4 &custom_film_mat) { nassertv(!custom_film_mat.is_nan()); @@ -359,86 +306,68 @@ set_custom_film_mat(const LMatrix4 &custom_film_mat) { cdata->_custom_film_mat = custom_film_mat; do_adjust_user_flags(cdata, 0, UF_custom_film_mat); do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_film_mat | CF_film_mat_inv, 0); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::clear_custom_film_mat -// Access: Published -// Description: Disables the lens custom_film_mat correction. -//////////////////////////////////////////////////////////////////// +/** + * Disables the lens custom_film_mat correction. + */ void Lens:: clear_custom_film_mat() { CDWriter cdata(_cycler, true); cdata->_custom_film_mat = LMatrix4::ident_mat(); do_adjust_user_flags(cdata, UF_custom_film_mat, 0); - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_film_mat | CF_film_mat_inv, 0); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::set_frustum_from_corners -// Access: Published -// Description: Sets up the lens to use the frustum defined by the -// four indicated points. This is most useful for a -// PerspectiveLens, but it may be called for other kinds -// of lenses as well. -// -// The frustum will be rooted at the origin (or by -// whatever translation might have been specified in a -// previous call to set_view_mat). -// -// It is legal for the four points not to be arranged in -// a rectangle; if this is the case, the frustum will be -// fitted as tightly as possible to cover all four -// points. -// -// The flags parameter contains the union of one or more -// of the following bits to control the behavior of this -// function: -// -// FC_roll - If this is included, the camera may be -// rotated so that its up vector is perpendicular to the -// top line. Otherwise, the standard up vector is used. -// -// FC_camera_plane - This allows the camera plane to be -// adjusted to be as nearly perpendicular to the center -// of the frustum as possible. Without this bit, the -// orientation camera plane is defined by position of -// the four points (which should all be coplanar). With -// this bit, the camera plane is arbitarary, and may be -// chosen so that the four points do not themselves lie -// in the camera plane (but the points will still be -// within the frustum). -// -// FC_off_axis - This allows the resulting frustum to be -// off-axis to get the tightest possible fit. Without -// this bit, the viewing axis will be centered within -// the frustum, but there may be more wasted space along -// the edges. -// -// FC_aspect_ratio - This allows the frustum to be -// scaled non-proportionately in the vertical and -// horizontal dimensions, if necessary, to get a tighter -// fit. Without this bit, the current aspect ratio will -// be preserved. -// -// FC_shear - This allows the frustum to be sheared, if -// necessary, to get the tightest possible fit. This -// may result in a parallelogram-based frustum, which -// will give a slanted appearance to the rendered image. -// Without this bit, the frustum will be -// rectangle-based. -// -// In general, if 0 is passed in as the value for flags, -// the generated frustum will be a loose fit but sane; -// if -1 is passed in, it will be a tighter fit and -// possibly screwy. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the lens to use the frustum defined by the four indicated points. + * This is most useful for a PerspectiveLens, but it may be called for other + * kinds of lenses as well. + * + * The frustum will be rooted at the origin (or by whatever translation might + * have been specified in a previous call to set_view_mat). + * + * It is legal for the four points not to be arranged in a rectangle; if this + * is the case, the frustum will be fitted as tightly as possible to cover all + * four points. + * + * The flags parameter contains the union of one or more of the following bits + * to control the behavior of this function: + * + * FC_roll - If this is included, the camera may be rotated so that its up + * vector is perpendicular to the top line. Otherwise, the standard up vector + * is used. + * + * FC_camera_plane - This allows the camera plane to be adjusted to be as + * nearly perpendicular to the center of the frustum as possible. Without + * this bit, the orientation camera plane is defined by position of the four + * points (which should all be coplanar). With this bit, the camera plane is + * arbitarary, and may be chosen so that the four points do not themselves lie + * in the camera plane (but the points will still be within the frustum). + * + * FC_off_axis - This allows the resulting frustum to be off-axis to get the + * tightest possible fit. Without this bit, the viewing axis will be centered + * within the frustum, but there may be more wasted space along the edges. + * + * FC_aspect_ratio - This allows the frustum to be scaled non-proportionately + * in the vertical and horizontal dimensions, if necessary, to get a tighter + * fit. Without this bit, the current aspect ratio will be preserved. + * + * FC_shear - This allows the frustum to be sheared, if necessary, to get the + * tightest possible fit. This may result in a parallelogram-based frustum, + * which will give a slanted appearance to the rendered image. Without this + * bit, the frustum will be rectangle-based. + * + * In general, if 0 is passed in as the value for flags, the generated frustum + * will be a loose fit but sane; if -1 is passed in, it will be a tighter fit + * and possibly screwy. + */ void Lens:: set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, const LVecBase3 &ll, const LVecBase3 &lr, @@ -446,17 +375,16 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, nassertv(!ul.is_nan() && !ur.is_nan() && !ll.is_nan() && !lr.is_nan()); CDWriter cdata(_cycler, true); - // We'll need to know the pre-existing eyepoint translation from the - // center, so we can preserve it in the new frustum. This is - // usually (0, 0, 0), but it could be an arbitrary vector. + // We'll need to know the pre-existing eyepoint translation from the center, + // so we can preserve it in the new frustum. This is usually (0, 0, 0), but + // it could be an arbitrary vector. const LMatrix4 &lens_mat_inv = do_get_lens_mat_inv(cdata); LVector3 eye_offset; lens_mat_inv.get_row3(eye_offset, 3); - // Now choose the viewing axis. If FC_camera_plane is specified, - // we'll pass it through the centroid for the best camera plane; - // otherwise, it's perpendicular to the plane in which the points - // lie. + // Now choose the viewing axis. If FC_camera_plane is specified, we'll pass + // it through the centroid for the best camera plane; otherwise, it's + // perpendicular to the plane in which the points lie. LVector3 view_vector; if ((flags & FC_camera_plane) != 0) { view_vector = (ul + ur + ll + lr) * 0.25; @@ -466,10 +394,9 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, nassertv(!view_vector.is_nan() && view_vector.length_squared() != 0.0f); } - // Now determine the up axis. If FC_roll is specified, or if our - // view vector is straight up, it is the vector perpendicular to - // both the viewing axis and the top line. Otherwise, it is the - // standard up axis. + // Now determine the up axis. If FC_roll is specified, or if our view + // vector is straight up, it is the vector perpendicular to both the viewing + // axis and the top line. Otherwise, it is the standard up axis. LVector3 up_vector = LVector3::up(cdata->_cs); if (view_vector == up_vector || ((flags & FC_roll) != 0)) { LVector3 top = ul - ur; @@ -485,15 +412,15 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, LMatrix4 inv_rot_mat; inv_rot_mat.invert_affine_from(rot_mat); - // Use that inverse matrix to convert the four corners to a local - // coordinate system, looking down the Y axis. + // Use that inverse matrix to convert the four corners to a local coordinate + // system, looking down the Y axis. LPoint3 cul = inv_rot_mat.xform_point(ul); LPoint3 cur = inv_rot_mat.xform_point(ur); LPoint3 cll = inv_rot_mat.xform_point(ll); LPoint3 clr = inv_rot_mat.xform_point(lr); - // Project all points into the Y == 1 plane, so we can do 2-d - // manipulation on them. + // Project all points into the Y == 1 plane, so we can do 2-d manipulation + // on them. nassertv(cul[1] != 0.0f && cur[1] != 0.0f && cll[1] != 0.0f && clr[1] != 0.0f); cul /= cul[1]; cur /= cur[1]; @@ -507,7 +434,7 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, if ((flags & FC_shear) != 0) { build_shear_mat(shear_mat, cul, cur, cll, clr); inv_shear_mat.invert_from(shear_mat); - } + } // Now build the complete view matrix. LMatrix4 inv_view_mat = @@ -543,8 +470,8 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, PN_stdfloat x_spread, x_center, z_spread, z_center; if ((flags & FC_off_axis) != 0) { - // If we're allowed to make an off-axis projection, then pick the - // best center. + // If we're allowed to make an off-axis projection, then pick the best + // center. x_center = (max_x + min_x) * 0.5f; z_center = (max_z + min_z) * 0.5f; x_spread = x_center - min_x; @@ -560,8 +487,8 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, PN_stdfloat aspect_ratio = do_get_aspect_ratio(cdata); nassertv(aspect_ratio != 0.0f); if ((flags & FC_aspect_ratio) == 0) { - // If we must preserve the aspect ratio, then the x and z spreads - // must be adjusted to match. + // If we must preserve the aspect ratio, then the x and z spreads must be + // adjusted to match. if (x_spread < z_spread * aspect_ratio) { // x_spread is too small. x_spread = z_spread * aspect_ratio; @@ -577,9 +504,9 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, do_set_fov(cdata, LVecBase2(hfov, vfov)); if ((flags & FC_aspect_ratio) == 0) { - // If we must preserve the aspect ratio, store it one more time. - // This is mainly in case we have a non-perspective lens with a - // funny relationship between fov and aspect ratio. + // If we must preserve the aspect ratio, store it one more time. This is + // mainly in case we have a non-perspective lens with a funny relationship + // between fov and aspect ratio. do_set_aspect_ratio(cdata, aspect_ratio); } @@ -590,88 +517,72 @@ set_frustum_from_corners(const LVecBase3 &ul, const LVecBase3 &ur, } -//////////////////////////////////////////////////////////////////// -// Function: Lens::recompute_all -// Access: Published -// Description: Forces all internal parameters of the Lens to be -// recomputed. Normally, this should never need to be -// called; it is provided only to assist in debugging. -//////////////////////////////////////////////////////////////////// +/** + * Forces all internal parameters of the Lens to be recomputed. Normally, + * this should never need to be called; it is provided only to assist in + * debugging. + */ void Lens:: recompute_all() { CDWriter cdata(_cycler); cdata->_comp_flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::is_linear -// Access: Published, Virtual -// Description: Returns true if the lens represents a linear -// projection (e.g. PerspectiveLens, OrthographicLens), -// and therefore there is a valid matrix returned by -// get_projection_mat(), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a linear projection (e.g. + * PerspectiveLens, OrthographicLens), and therefore there is a valid matrix + * returned by get_projection_mat(), or false otherwise. + */ bool Lens:: is_linear() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::is_perspective -// Access: Published, Virtual -// Description: Returns true if the lens represents a perspective -// projection (i.e. it is a PerspectiveLens), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a perspective projection (i.e. it is a + * PerspectiveLens), false otherwise. + */ bool Lens:: is_perspective() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::is_orthographic -// Access: Published, Virtual -// Description: Returns true if the lens represents a orthographic -// projection (i.e. it is a OrthographicLens), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a orthographic projection (i.e. it is + * a OrthographicLens), false otherwise. + */ bool Lens:: is_orthographic() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::make_geometry -// Access: Published, Virtual -// Description: Allocates and returns a new Geom that can be rendered -// to show a visible representation of the frustum used -// for this kind of lens, if it makes sense to do -// so. If a visible representation cannot be created, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new Geom that can be rendered to show a visible + * representation of the frustum used for this kind of lens, if it makes sense + * to do so. If a visible representation cannot be created, returns NULL. + */ PT(Geom) Lens:: make_geometry() { CDWriter cdata(_cycler, true); - // The default behavior for make_geometry() will be to draw a - // hexahedron around the eight vertices of the frustum. If the lens - // is non-linear, the hexahedron will be curved; in that case, we'll - // subdivide the lines into several segments to get an approximation - // of the curve. + // The default behavior for make_geometry() will be to draw a hexahedron + // around the eight vertices of the frustum. If the lens is non-linear, the + // hexahedron will be curved; in that case, we'll subdivide the lines into + // several segments to get an approximation of the curve. - // First, define all the points we'll use in this Geom. That's one - // point at each corner of the near and far planes (and possibly - // more points along the edges). + // First, define all the points we'll use in this Geom. That's one point at + // each corner of the near and far planes (and possibly more points along + // the edges). int num_segments = do_define_geom_data(cdata); if (num_segments == 0) { // Can't do a frustum. cdata->_geom_data.clear(); return (Geom *)NULL; } - + // Now string together the line segments. PT(GeomLinestrips) line = new GeomLinestrips(Geom::UH_static); - + // Draw a frame around the near plane. int i, si; for (i = 0; i < 4; ++i) { @@ -681,7 +592,7 @@ make_geometry() { } line->add_vertex(0); line->close_primitive(); - + // Draw a frame around the far plane. for (i = 0; i < 4; ++i) { for (si = 0; si < num_segments; ++si) { @@ -690,49 +601,46 @@ make_geometry() { } line->add_vertex(1); line->close_primitive(); - + // Draw connecting lines at the corners. line->add_vertex(0 * 2 + 0); line->add_vertex(0 * 2 + 1); line->close_primitive(); - + line->add_vertex(1 * 2 + 0); line->add_vertex(1 * 2 + 1); line->close_primitive(); - + line->add_vertex(2 * 2 + 0); line->add_vertex(2 * 2 + 1); line->close_primitive(); - + line->add_vertex(3 * 2 + 0); line->add_vertex(3 * 2 + 1); line->close_primitive(); - + // And one more line for the viewing axis. line->add_vertex(num_segments * (4 * 2) + 0); line->add_vertex(num_segments * (4 * 2) + 1); line->close_primitive(); - + PT(Geom) geom = new Geom(cdata->_geom_data); geom->add_primitive(line); - + return geom.p(); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::make_bounds -// Access: Published, Virtual -// Description: Allocates and returns a new BoundingVolume that -// encloses the frustum used for this kind of -// lens, if possible. If a suitable bounding -// volume cannot be created, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new BoundingVolume that encloses the frustum used + * for this kind of lens, if possible. If a suitable bounding volume cannot + * be created, returns NULL. + */ PT(BoundingVolume) Lens:: make_bounds() const { CDReader cdata(_cycler); - // The default bounding volume is a hexahedron based on the eight - // corners of the frustum. + // The default bounding volume is a hexahedron based on the eight corners of + // the frustum. LPoint3 fll, flr, ful, fur; LPoint3 nll, nlr, nul, nur; LPoint3 corner; @@ -764,38 +672,32 @@ make_bounds() const { return new BoundingHexahedron(fll, flr, fur, ful, nll, nlr, nur, nul); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " fov = " << get_fov() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_film_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_film_size(CData *cdata, PN_stdfloat width) { nassertv(!cnan(width)); cdata->_film_size.set(width, width / do_get_aspect_ratio(cdata)); - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_film_size_seq, cdata->_focal_length_seq, cdata->_fov_seq); if (cdata->_fov_seq == 0) { @@ -813,18 +715,16 @@ do_set_film_size(CData *cdata, PN_stdfloat width) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_film_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_film_size(CData *cdata, const LVecBase2 &film_size) { nassertv(!film_size.is_nan()); cdata->_film_size = film_size; - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_film_size_seq, cdata->_focal_length_seq, cdata->_fov_seq); if (cdata->_fov_seq == 0) { @@ -840,42 +740,38 @@ do_set_film_size(CData *cdata, const LVecBase2 &film_size) { do_adjust_comp_flags(cdata, CF_mat | CF_focal_length | CF_fov | CF_aspect_ratio, CF_film_size); - // Also, the user has implicitly specified an aspect ratio. Make it - // stick until the user tells us something different. + // Also, the user has implicitly specified an aspect ratio. Make it stick + // until the user tells us something different. do_compute_aspect_ratio(cdata); do_adjust_user_flags(cdata, 0, UF_aspect_ratio); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_film_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2 &Lens:: do_get_film_size(const CData *cdata) const { if ((cdata->_comp_flags & CF_film_size) == 0) { - // We pretend this is a const method, even though it may call a - // non-const method to recompute the internal values. We can do - // this because this is just compute-on-demand. + // We pretend this is a const method, even though it may call a non-const + // method to recompute the internal values. We can do this because this + // is just compute-on-demand. ((Lens *)this)->do_compute_film_size((CData *)cdata); } return cdata->_film_size; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_focal_length -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_focal_length(CData *cdata, PN_stdfloat focal_length) { nassertv(!cnan(focal_length)); cdata->_focal_length = focal_length; - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_focal_length_seq, cdata->_film_size_seq, cdata->_fov_seq); if (cdata->_film_size_seq == 0) { @@ -894,11 +790,9 @@ do_set_focal_length(CData *cdata, PN_stdfloat focal_length) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_focal_length -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat Lens:: do_get_focal_length(const CData *cdata) const { if ((cdata->_comp_flags & CF_focal_length) == 0) { @@ -907,18 +801,16 @@ do_get_focal_length(const CData *cdata) const { return cdata->_focal_length; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_fov -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_fov(CData *cdata, PN_stdfloat hfov) { nassertv(!cnan(hfov)); cdata->_fov[0] = hfov; - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_fov_seq, cdata->_focal_length_seq, cdata->_film_size_seq); if (cdata->_focal_length_seq == 0) { @@ -942,18 +834,16 @@ do_set_fov(CData *cdata, PN_stdfloat hfov) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_fov -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_fov(CData *cdata, const LVecBase2 &fov) { nassertv(!fov.is_nan()); cdata->_fov = fov; - // We can't specify all three of focal length, fov, and film size. - // Throw out the oldest one. + // We can't specify all three of focal length, fov, and film size. Throw + // out the oldest one. do_resequence_fov_triad(cdata, cdata->_fov_seq, cdata->_focal_length_seq, cdata->_film_size_seq); if (cdata->_focal_length_seq == 0) { @@ -969,19 +859,17 @@ do_set_fov(CData *cdata, const LVecBase2 &fov) { do_adjust_comp_flags(cdata, CF_mat | CF_focal_length | CF_film_size | CF_aspect_ratio, CF_fov); - // Also, the user has implicitly specified an aspect ratio. Make it - // stick until the user tells us something different. + // Also, the user has implicitly specified an aspect ratio. Make it stick + // until the user tells us something different. do_compute_aspect_ratio(cdata); do_adjust_user_flags(cdata, 0, UF_aspect_ratio); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_fov -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase2 &Lens:: do_get_fov(const CData *cdata) const { if ((cdata->_comp_flags & CF_fov) == 0) { @@ -990,11 +878,9 @@ do_get_fov(const CData *cdata) const { return cdata->_fov; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_aspect_ratio -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_aspect_ratio(CData *cdata, PN_stdfloat aspect_ratio) { nassertv(!cnan(aspect_ratio)); @@ -1006,11 +892,9 @@ do_set_aspect_ratio(CData *cdata, PN_stdfloat aspect_ratio) { do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_aspect_ratio -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat Lens:: do_get_aspect_ratio(const CData *cdata) const { if ((cdata->_comp_flags & CF_aspect_ratio) == 0) { @@ -1019,11 +903,9 @@ do_get_aspect_ratio(const CData *cdata) const { return cdata->_aspect_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_projection_mat -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_projection_mat(const CData *cdata, StereoChannel channel) const { if ((cdata->_comp_flags & CF_projection_mat) == 0) { @@ -1043,11 +925,9 @@ do_get_projection_mat(const CData *cdata, StereoChannel channel) const { return cdata->_projection_mat; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_projection_mat_inv -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_projection_mat_inv(const CData *cdata, StereoChannel stereo_channel) const { switch (stereo_channel) { @@ -1084,11 +964,9 @@ do_get_projection_mat_inv(const CData *cdata, StereoChannel stereo_channel) cons return cdata->_projection_mat_inv; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_film_mat -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_film_mat(const CData *cdata) const { if ((cdata->_comp_flags & CF_film_mat) == 0) { @@ -1097,11 +975,9 @@ do_get_film_mat(const CData *cdata) const { return cdata->_film_mat; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_film_mat_inv -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_film_mat_inv(const CData *cdata) const { if ((cdata->_comp_flags & CF_film_mat_inv) == 0) { @@ -1112,11 +988,9 @@ do_get_film_mat_inv(const CData *cdata) const { return cdata->_film_mat_inv; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_lens_mat -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_lens_mat(const CData *cdata) const { if ((cdata->_comp_flags & CF_lens_mat) == 0) { @@ -1125,11 +999,9 @@ do_get_lens_mat(const CData *cdata) const { return cdata->_lens_mat; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_lens_mat_inv -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_lens_mat_inv(const CData *cdata) const { if ((cdata->_comp_flags & CF_lens_mat_inv) == 0) { @@ -1140,11 +1012,9 @@ do_get_lens_mat_inv(const CData *cdata) const { return cdata->_lens_mat_inv; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_interocular_distance -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_interocular_distance(CData *cdata, PN_stdfloat interocular_distance) { nassertv(!cnan(interocular_distance)); @@ -1158,11 +1028,9 @@ do_set_interocular_distance(CData *cdata, PN_stdfloat interocular_distance) { do_adjust_comp_flags(cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_convergence_distance -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_convergence_distance(CData *cdata, PN_stdfloat convergence_distance) { nassertv(!cnan(convergence_distance)); @@ -1176,29 +1044,25 @@ do_set_convergence_distance(CData *cdata, PN_stdfloat convergence_distance) { do_adjust_comp_flags(cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_set_view_mat -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens:: do_set_view_mat(CData *cdata, const LMatrix4 &view_mat) { nassertv(!view_mat.is_nan()); cdata->_lens_mat = view_mat; do_adjust_user_flags(cdata, UF_view_vector | UF_view_hpr, UF_view_mat); - do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | - CF_projection_mat_left_inv | CF_projection_mat_right_inv | + do_adjust_comp_flags(cdata, CF_projection_mat | CF_projection_mat_inv | + CF_projection_mat_left_inv | CF_projection_mat_right_inv | CF_lens_mat_inv | CF_view_hpr | CF_view_vector, CF_lens_mat); do_throw_change_event(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_get_view_mat -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LMatrix4 &Lens:: do_get_view_mat(const CData *cdata) const { if ((cdata->_comp_flags & CF_lens_mat) == 0) { @@ -1207,12 +1071,9 @@ do_get_view_mat(const CData *cdata) const { return cdata->_lens_mat; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_throw_change_event -// Access: Protected -// Description: Throws the event associated with changing properties -// on this Lens, if any. -//////////////////////////////////////////////////////////////////// +/** + * Throws the event associated with changing properties on this Lens, if any. + */ void Lens:: do_throw_change_event(CData *cdata) { ++(cdata->_last_change); @@ -1223,35 +1084,27 @@ do_throw_change_event(CData *cdata) { if (!cdata->_geom_data.is_null()) { if (cdata->_geom_data->get_ref_count() == 1) { - // No one's using the data any more (there are no references to - // it other than this one), so don't bother to recompute it; - // just release it. + // No one's using the data any more (there are no references to it other + // than this one), so don't bother to recompute it; just release it. cdata->_geom_data.clear(); } else { - // Someone still has a handle to the data, so recompute it for - // them. + // Someone still has a handle to the data, so recompute it for them. do_define_geom_data(cdata); } } } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_extrude -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the corresponding vector in space that maps -// to this point, if such a vector can be determined. -// The vector is returned by indicating the points on -// the near plane and far plane that both map to the -// indicated 2-d point. -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * corresponding vector in space that maps to this point, if such a vector can + * be determined. The vector is returned by indicating the points on the near + * plane and far plane that both map to the indicated 2-d point. + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool Lens:: do_extrude(const CData *cdata, const LPoint3 &point2d, LPoint3 &near_point, LPoint3 &far_point) const { @@ -1261,54 +1114,48 @@ do_extrude(const CData *cdata, full = projection_mat_inv.xform(full); PN_stdfloat recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); - near_point.set(full[0] * recip_full3, - full[1] * recip_full3, + near_point.set(full[0] * recip_full3, + full[1] * recip_full3, full[2] * recip_full3); } { LVecBase4 full(point2d[0], point2d[1], 1.0f, 1.0f); full = projection_mat_inv.xform(full); - // We can truncate the weight factor at near 0. If it goes too - // close to zero, or becomes negative, the far plane moves out - // past infinity and comes back in behind the lens, which is just - // crazy. Truncating it to zero keeps the far plane from moving - // too far out. + // We can truncate the weight factor at near 0. If it goes too close to + // zero, or becomes negative, the far plane moves out past infinity and + // comes back in behind the lens, which is just crazy. Truncating it to + // zero keeps the far plane from moving too far out. PN_stdfloat recip_full3 = 1.0 / max((double)full[3], (double)lens_far_limit); - far_point.set(full[0] * recip_full3, - full[1] * recip_full3, + far_point.set(full[0] * recip_full3, + full[1] * recip_full3, full[2] * recip_full3); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_extrude_depth -// Access: Protected, Virtual -// Description: This is the generic implementation, which is based on -// do_extrude() and assumes a linear distribution of -// depth values between the near and far points. -//////////////////////////////////////////////////////////////////// +/** + * This is the generic implementation, which is based on do_extrude() and + * assumes a linear distribution of depth values between the near and far + * points. + */ bool Lens:: do_extrude_depth(const CData *cdata, const LPoint3 &point2d, LPoint3 &point3d) const { LPoint3 near_point, far_point; bool result = extrude(point2d, near_point, far_point); - // The depth point is, by convention, in the range -1 to 1. Scale - // this to 0 .. 1 for the linear interpolation. + // The depth point is, by convention, in the range -1 to 1. Scale this to 0 + // .. 1 for the linear interpolation. PN_stdfloat t = point2d[2] * 0.5 + 0.5; point3d = near_point + (far_point - near_point) * t; return result; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_extrude_depth_with_mat -// Access: Protected -// Description: Implements do_extrude_depth() by using the projection -// matrix. This is efficient, but works only for a -// linear (Perspective or Orthographic) lens. -//////////////////////////////////////////////////////////////////// +/** + * Implements do_extrude_depth() by using the projection matrix. This is + * efficient, but works only for a linear (Perspective or Orthographic) lens. + */ bool Lens:: do_extrude_depth_with_mat(const CData *cdata, const LPoint3 &point2d, LPoint3 &point3d) const { @@ -1317,59 +1164,47 @@ do_extrude_depth_with_mat(const CData *cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_extrude_vec -// Access: Protected, Virtual -// Description: Given a 2-d point in the range (-1,1) in both -// dimensions, where (0,0) is the center of the -// lens and (-1,-1) is the lower-left corner, -// compute the vector that corresponds to the view -// direction. This will be parallel to the normal on -// the surface (the far plane) corresponding to the lens -// shape at this point. -// -// Generally, for all rational lenses, the center of the -// film at (0,0) computes a vector that is in the same -// direction as the vector specified by -// set_view_vector(). -// -// For all linear lenses, including perspective and -// orthographic lenses, all points on the film compute -// this same vector (the far plane is a flat plane, so -// the normal is the same everywhere). For curved -// lenses like fisheye and cylindrical lenses, different -// points may compute different vectors (the far "plane" -// on these lenses is a curved surface). -// -// The z coordinate of the 2-d point is ignored. -// -// Returns true if the vector is defined, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is + * the center of the lens and (-1,-1) is the lower-left corner, compute the + * vector that corresponds to the view direction. This will be parallel to + * the normal on the surface (the far plane) corresponding to the lens shape + * at this point. + * + * Generally, for all rational lenses, the center of the film at (0,0) + * computes a vector that is in the same direction as the vector specified by + * set_view_vector(). + * + * For all linear lenses, including perspective and orthographic lenses, all + * points on the film compute this same vector (the far plane is a flat plane, + * so the normal is the same everywhere). For curved lenses like fisheye and + * cylindrical lenses, different points may compute different vectors (the far + * "plane" on these lenses is a curved surface). + * + * The z coordinate of the 2-d point is ignored. + * + * Returns true if the vector is defined, or false otherwise. + */ bool Lens:: do_extrude_vec(const CData *cdata, const LPoint3 &point2d, LVector3 &vec) const { vec = LVector3::forward(cdata->_cs) * do_get_lens_mat(cdata); return true; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_project -// Access: Protected, Virtual -// Description: Given a 3-d point in space, determine the 2-d point -// this maps to, in the range (-1,1) in both dimensions, -// where (0,0) is the center of the lens and -// (-1,-1) is the lower-left corner. -// -// The z coordinate will also be set to a value in the -// range (-1, 1), where -1 represents a point on the near -// plane, and 1 represents a point on the far plane. -// -// Returns true if the 3-d point is in front of the lens -// and within the viewing frustum (in which case point2d -// is filled in), or false otherwise (in which case -// point2d will be filled in with something, which may -// or may not be meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Given a 3-d point in space, determine the 2-d point this maps to, in the + * range (-1,1) in both dimensions, where (0,0) is the center of the lens and + * (-1,-1) is the lower-left corner. + * + * The z coordinate will also be set to a value in the range (-1, 1), where -1 + * represents a point on the near plane, and 1 represents a point on the far + * plane. + * + * Returns true if the 3-d point is in front of the lens and within the + * viewing frustum (in which case point2d is filled in), or false otherwise + * (in which case point2d will be filled in with something, which may or may + * not be meaningful). + */ bool Lens:: do_project(const CData *cdata, const LPoint3 &point3d, LPoint3 &point2d) const { const LMatrix4 &projection_mat = do_get_projection_mat(cdata); @@ -1383,22 +1218,20 @@ do_project(const CData *cdata, const LPoint3 &point3d, LPoint3 &point2d) const { point2d.set(full[0] * recip_full3, full[1] * recip_full3, full[2] * recip_full3); return (full[3] > 0.0f) && - (point2d[0] >= -1.0f) && (point2d[0] <= 1.0f) && + (point2d[0] >= -1.0f) && (point2d[0] <= 1.0f) && (point2d[1] >= -1.0f) && (point2d[1] <= 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_film_size -// Access: Protected, Virtual -// Description: Computes the size and shape of the film behind the -// camera, based on the aspect ratio and fov. -//////////////////////////////////////////////////////////////////// +/** + * Computes the size and shape of the film behind the camera, based on the + * aspect ratio and fov. + */ void Lens:: do_compute_film_size(CData *cdata) { if ((cdata->_user_flags & (UF_min_fov | UF_focal_length)) == (UF_min_fov | UF_focal_length)) { - // If we just have a min FOV and a focal length, that determines - // the smaller of the two film_sizes, and the larger is simply - // chosen according to the aspect ratio. + // If we just have a min FOV and a focal length, that determines the + // smaller of the two film_sizes, and the larger is simply chosen + // according to the aspect ratio. PN_stdfloat fs = fov_to_film(cdata->_min_fov, cdata->_focal_length, true); nassertv((cdata->_user_flags & UF_aspect_ratio) != 0 || (cdata->_comp_flags & CF_aspect_ratio) != 0); @@ -1420,25 +1253,25 @@ do_compute_film_size(CData *cdata) { cdata->_film_size[0] = 1.0f; } } - + if ((cdata->_user_flags & UF_film_height) == 0) { if ((cdata->_user_flags & (UF_vfov | UF_focal_length)) == (UF_vfov | UF_focal_length)) { cdata->_film_size[1] = fov_to_film(cdata->_fov[1], cdata->_focal_length, false); - + } else if ((cdata->_user_flags & (UF_hfov | UF_vfov)) == (UF_hfov | UF_vfov)) { - // If we don't have a focal length, but we have an explicit vfov - // and hfov, we can infer the focal length is whatever makes the - // film width, above, be what it is. + // If we don't have a focal length, but we have an explicit vfov and + // hfov, we can infer the focal length is whatever makes the film + // width, above, be what it is. if ((cdata->_comp_flags & CF_focal_length) == 0) { cdata->_focal_length = fov_to_focal_length(cdata->_fov[0], cdata->_film_size[0], true); do_adjust_comp_flags(cdata, 0, CF_focal_length); } cdata->_film_size[1] = fov_to_film(cdata->_fov[1], cdata->_focal_length, false); - + } else if ((cdata->_user_flags & UF_aspect_ratio) != 0 || (cdata->_comp_flags & CF_aspect_ratio) != 0) { cdata->_film_size[1] = cdata->_film_size[0] / cdata->_aspect_ratio; - + } else { // Default is an aspect ratio of 1. cdata->_film_size[1] = cdata->_film_size[0]; @@ -1449,13 +1282,10 @@ do_compute_film_size(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_film_size); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_focal_length -// Access: Protected, Virtual -// Description: Computes the focal length of the lens, based on the -// fov and film size. This is based on the horizontal -// dimension. -//////////////////////////////////////////////////////////////////// +/** + * Computes the focal length of the lens, based on the fov and film size. + * This is based on the horizontal dimension. + */ void Lens:: do_compute_focal_length(CData *cdata) { if ((cdata->_user_flags & UF_focal_length) == 0) { @@ -1467,12 +1297,10 @@ do_compute_focal_length(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_focal_length); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_fov -// Access: Protected, Virtual -// Description: Computes the field of view of the lens, based on the -// film size and focal length. -//////////////////////////////////////////////////////////////////// +/** + * Computes the field of view of the lens, based on the film size and focal + * length. + */ void Lens:: do_compute_fov(CData *cdata) { const LVecBase2 &film_size = do_get_film_size(cdata); @@ -1498,8 +1326,7 @@ do_compute_fov(CData *cdata) { } if (got_min_fov) { - // If we have just a min_fov, use it to derive whichever fov is - // smaller. + // If we have just a min_fov, use it to derive whichever fov is smaller. if (film_size[0] < film_size[1]) { cdata->_fov[0] = cdata->_min_fov; got_hfov = true; @@ -1513,8 +1340,8 @@ do_compute_fov(CData *cdata) { if (!got_hfov) { if ((cdata->_user_flags & UF_focal_length) == 0 && (cdata->_comp_flags & CF_focal_length) == 0) { - // If we don't have an explicit focal length, we can infer it - // from the above. + // If we don't have an explicit focal length, we can infer it from the + // above. nassertv(got_vfov); cdata->_focal_length = fov_to_focal_length(cdata->_fov[1], film_size[1], true); do_adjust_comp_flags(cdata, 0, CF_focal_length); @@ -1522,12 +1349,12 @@ do_compute_fov(CData *cdata) { cdata->_fov[0] = film_to_fov(film_size[0], cdata->_focal_length, false); got_hfov = true; } - + if (!got_vfov) { if ((cdata->_user_flags & UF_focal_length) == 0 && (cdata->_comp_flags & CF_focal_length) == 0) { - // If we don't have an explicit focal length, we can infer it - // from the above. + // If we don't have an explicit focal length, we can infer it from the + // above. nassertv(got_hfov); cdata->_focal_length = fov_to_focal_length(cdata->_fov[0], film_size[0], true); do_adjust_comp_flags(cdata, 0, CF_focal_length); @@ -1545,12 +1372,10 @@ do_compute_fov(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_fov); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_aspect_ratio -// Access: Protected, Virtual -// Description: Computes the aspect ratio of the film rectangle, as a -// ratio of width to height. -//////////////////////////////////////////////////////////////////// +/** + * Computes the aspect ratio of the film rectangle, as a ratio of width to + * height. + */ void Lens:: do_compute_aspect_ratio(CData *cdata) { if ((cdata->_user_flags & UF_aspect_ratio) == 0) { @@ -1564,12 +1389,9 @@ do_compute_aspect_ratio(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_aspect_ratio); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_view_hpr -// Access: Protected, Virtual -// Description: Computes the Euler angles representing the lens' -// rotation. -//////////////////////////////////////////////////////////////////// +/** + * Computes the Euler angles representing the lens' rotation. + */ void Lens:: do_compute_view_hpr(CData *cdata) { if ((cdata->_user_flags & UF_view_hpr) == 0) { @@ -1580,11 +1402,9 @@ do_compute_view_hpr(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_view_hpr); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_view_vector -// Access: Protected, Virtual -// Description: Computes the view vector and up vector for the lens. -//////////////////////////////////////////////////////////////////// +/** + * Computes the view vector and up vector for the lens. + */ void Lens:: do_compute_view_vector(CData *cdata) { if ((cdata->_user_flags & UF_view_vector) == 0) { @@ -1595,22 +1415,19 @@ do_compute_view_vector(CData *cdata) { do_adjust_comp_flags(cdata, 0, CF_view_vector); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_projection_mat -// Access: Protected, Virtual -// Description: Computes the complete transformation matrix from 3-d -// point to 2-d point, if the lens is linear. -//////////////////////////////////////////////////////////////////// +/** + * Computes the complete transformation matrix from 3-d point to 2-d point, if + * the lens is linear. + */ void Lens:: do_compute_projection_mat(CData *lens_cdata) { - // This is the implementation used by non-linear lenses. The linear - // lenses (PerspectiveLens and OrthographicLens) will customize this - // method appropriate for themselves. + // This is the implementation used by non-linear lenses. The linear lenses + // (PerspectiveLens and OrthographicLens) will customize this method + // appropriate for themselves. // By convention, the coordinate-system conversion is baked into the - // projection mat. Our non-linear lenses are implemented with code - // that assumes CS_zup_right, so we bake the appropriate rotation in - // here. + // projection mat. Our non-linear lenses are implemented with code that + // assumes CS_zup_right, so we bake the appropriate rotation in here. CoordinateSystem cs = lens_cdata->_cs; if (cs == CS_default) { cs = get_default_coordinate_system(); @@ -1618,8 +1435,8 @@ do_compute_projection_mat(CData *lens_cdata) { lens_cdata->_projection_mat = LMatrix4::convert_mat(cs, CS_zup_right); lens_cdata->_projection_mat_inv = LMatrix4::convert_mat(CS_zup_right, cs); - // We don't apply any left/right offsets for non-linear lenses by - // default, at least not here in the projection matrix. + // We don't apply any leftright offsets for non-linear lenses by default, at + // least not here in the projection matrix. lens_cdata->_projection_mat_left = lens_cdata->_projection_mat_right = lens_cdata->_projection_mat; lens_cdata->_projection_mat_left_inv = lens_cdata->_projection_mat_right_inv = lens_cdata->_projection_mat_inv; @@ -1627,20 +1444,17 @@ do_compute_projection_mat(CData *lens_cdata) { CF_projection_mat_left_inv | CF_projection_mat_right_inv); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_film_mat -// Access: Protected, Virtual -// Description: Computes the matrix that transforms from a point -// behind the lens to a point on the film. -//////////////////////////////////////////////////////////////////// +/** + * Computes the matrix that transforms from a point behind the lens to a point + * on the film. + */ void Lens:: do_compute_film_mat(CData *cdata) { - // The lens will return a point in the range [-film_size/2, - // film_size/2] in each dimension. Convert this to [-1, 1], and - // also apply the offset. + // The lens will return a point in the range [-film_size2, film_size2] in + // each dimension. Convert this to [-1, 1], and also apply the offset. - // We declare these two as local variables, instead of references, - // to work around a VC7 compiler bug. + // We declare these two as local variables, instead of references, to work + // around a VC7 compiler bug. LVecBase2 film_size = do_get_film_size(cdata); LVector2 film_offset = do_get_film_offset(cdata); @@ -1665,12 +1479,10 @@ do_compute_film_mat(CData *cdata) { do_adjust_comp_flags(cdata, CF_film_mat_inv, CF_film_mat); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_compute_lens_mat -// Access: Protected, Virtual -// Description: Computes the matrix that transforms from a point -// in front of the lens to a point in space. -//////////////////////////////////////////////////////////////////// +/** + * Computes the matrix that transforms from a point in front of the lens to a + * point in space. + */ void Lens:: do_compute_lens_mat(CData *cdata) { if ((cdata->_user_flags & UF_view_mat) == 0) { @@ -1691,62 +1503,49 @@ do_compute_lens_mat(CData *cdata) { do_adjust_comp_flags(cdata, CF_lens_mat_inv, CF_lens_mat); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the corresponding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * corresponding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat Lens:: fov_to_film(PN_stdfloat, PN_stdfloat, bool) const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat Lens:: fov_to_focal_length(PN_stdfloat, PN_stdfloat, bool) const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat Lens:: film_to_fov(PN_stdfloat, PN_stdfloat, bool) const { return default_fov; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_resequence_fov_triad -// Access: Private -// Description: Called whenever the user changes one of the three FOV -// parameters: fov, focal length, or film size. This -// rearranges the three sequence numbers so the newest -// parameter has value 2, and the older parameters are -// kept in sequence order. -// -// This is used to determine which two parameters of the -// three are the most recently changed, and conversely, -// which one the user has *not* changed recently. It is -// this third value which should be discarded. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the user changes one of the three FOV parameters: fov, + * focal length, or film size. This rearranges the three sequence numbers so + * the newest parameter has value 2, and the older parameters are kept in + * sequence order. + * + * This is used to determine which two parameters of the three are the most + * recently changed, and conversely, which one the user has *not* changed + * recently. It is this third value which should be discarded. + */ void Lens:: do_resequence_fov_triad(const CData *cdata, char &newest, char &older_a, char &older_b) const { nassertv(newest + older_a + older_b == 3); @@ -1801,16 +1600,12 @@ do_resequence_fov_triad(const CData *cdata, char &newest, char &older_a, char &o } } -//////////////////////////////////////////////////////////////////// -// Function: Lens::do_define_geom_data -// Access: Private -// Description: Adjusts (or defines for the first time) all the -// vertices in the _geom_data to match the properties of -// the lens. This will update the visual representation -// of the lens's frustum to match the changing -// parameters. Returns the number of line segments per -// edge. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts (or defines for the first time) all the vertices in the _geom_data + * to match the properties of the lens. This will update the visual + * representation of the lens's frustum to match the changing parameters. + * Returns the number of line segments per edge. + */ int Lens:: do_define_geom_data(CData *cdata) { int num_segments = 1; @@ -1868,8 +1663,8 @@ do_define_geom_data(CData *cdata) { } - // Finally, add one more pair for the viewing axis (or more specifically, the - // center of the lens). + // Finally, add one more pair for the viewing axis (or more specifically, + // the center of the lens). LPoint3 pc(0); if (!do_extrude(cdata, pc, near_point, far_point)) { vertex.set_data3(0.0f, 0.0f, 0.0f); @@ -1882,21 +1677,18 @@ do_define_geom_data(CData *cdata) { return num_segments; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::build_shear_mat -// Access: Private, Static -// Description: A support function for set_frustum_from_corners(), -// this computes a matrix that will shear the four -// indicated points to the most nearly rectangular. -//////////////////////////////////////////////////////////////////// +/** + * A support function for set_frustum_from_corners(), this computes a matrix + * that will shear the four indicated points to the most nearly rectangular. + */ void Lens:: build_shear_mat(LMatrix4 &shear_mat, const LPoint3 &cul, const LPoint3 &cur, const LPoint3 &cll, const LPoint3 &clr) { // Fit a parallelogram around these four points. - // Put the points in an array so we can rotate it around to find - // the longest edge. + // Put the points in an array so we can rotate it around to find the longest + // edge. LPoint3 points[4] = { cul, cur, clr, cll }; @@ -1917,8 +1709,8 @@ build_shear_mat(LMatrix4 &shear_mat, PN_stdfloat base_edge_length = csqrt(max_edge_length); - // The longest edge is the base of our parallelogram. The parallel - // edge must pass through the point furthest from this edge. + // The longest edge is the base of our parallelogram. The parallel edge + // must pass through the point furthest from this edge. int a = (base_edge + 2) % 4; int b = (base_edge + 3) % 4; @@ -1936,15 +1728,15 @@ build_shear_mat(LMatrix4 &shear_mat, dist = csqrt(b_dist); } - // Try to make the parallelogram as nearly rectangular as possible. - // How suitable is a true rectangle? + // Try to make the parallelogram as nearly rectangular as possible. How + // suitable is a true rectangle? LVector3 perpendic = base_vec.cross(LVector3(0.0f, -1.0f, 0.0f)); perpendic.normalize(); perpendic *= dist; LPoint3 parallel_origin = points[base_edge] + perpendic; - // It follows that far_point is on the line passing through the - // parallel edge. Is it within the endpoints? + // It follows that far_point is on the line passing through the parallel + // edge. Is it within the endpoints? LVector3 base_norm_vec = base_vec / base_edge_length; LVector3 far_point_delta = points[far_point] - parallel_origin; @@ -1955,8 +1747,7 @@ build_shear_mat(LMatrix4 &shear_mat, parallel_origin += base_norm_vec * far_point_pos; } else if (far_point_pos > base_edge_length) { - // We have to slide the parallel_origin forward to include - // far_point. + // We have to slide the parallel_origin forward to include far_point. parallel_origin += base_norm_vec * (far_point_pos - base_edge_length); } @@ -1986,27 +1777,25 @@ build_shear_mat(LMatrix4 &shear_mat, t = ((Ox - Ax) * By + (Ay - Oy) * Bx) / (Bx * Vy - By * Vx); if (t < 0.0f) { - // We need to slide the parallel_origin back to include - // the near point. + // We need to slide the parallel_origin back to include the near point. parallel_origin += base_vec * t; } else if (t > 1.0f) { - // We need to slide the parallel_origin forward to include the far - // point. + // We need to slide the parallel_origin forward to include the far point. parallel_origin += base_vec * (1.0f - t); } LVector3 adjacent_norm_vec = parallel_origin - base_origin; adjacent_norm_vec.normalize(); - // Now we've defined a parallelogram that includes all four points, - // and we're ready to build a shear transform. + // Now we've defined a parallelogram that includes all four points, and + // we're ready to build a shear transform. shear_mat = LMatrix4::ident_mat(); // The edges of the parallelogram become the axes. switch (base_edge) { case 0: - // The base_origin is the upper-left corner. X axis is base_norm_vec, - // Z axis is -adjacent_norm_vec. + // The base_origin is the upper-left corner. X axis is base_norm_vec, Z + // axis is -adjacent_norm_vec. shear_mat.set_row(0, base_norm_vec); shear_mat.set_row(2, -adjacent_norm_vec); break; @@ -2019,33 +1808,30 @@ build_shear_mat(LMatrix4 &shear_mat, break; case 2: - // The base_origin is the lower-right corner. X axis is - // -base_norm_vec, Z axis is adjacent_norm_vec. + // The base_origin is the lower-right corner. X axis is -base_norm_vec, Z + // axis is adjacent_norm_vec. shear_mat.set_row(0, -base_norm_vec); shear_mat.set_row(2, adjacent_norm_vec); break; case 3: - // The base_origin is the lower-left corner. X axis is - // adjacent_norm_vec, Z axis is base_norm_vec. + // The base_origin is the lower-left corner. X axis is adjacent_norm_vec, + // Z axis is base_norm_vec. shear_mat.set_row(0, adjacent_norm_vec); shear_mat.set_row(2, base_norm_vec); break; - + default: nassertv(false); } } -//////////////////////////////////////////////////////////////////// -// Function: Lens::sqr_dist_to_line -// Access: Private, Static -// Description: A support function for build_shear_mat(), this -// computes the minimum distance from a point to a line, -// and returns the distance squared. -//////////////////////////////////////////////////////////////////// +/** + * A support function for build_shear_mat(), this computes the minimum + * distance from a point to a line, and returns the distance squared. + */ PN_stdfloat Lens:: -sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, +sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, const LVector3 &vec) { LVector3 norm = vec; norm.normalize(); @@ -2055,46 +1841,37 @@ sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, return hyp_2 - leg * leg; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Lens:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Lens. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Lens. + */ void Lens:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Lens::CData:: CData() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Lens::CData:: CData(const Lens::CData ©) { _change_event = copy._change_event; @@ -2114,9 +1891,9 @@ CData(const Lens::CData ©) { _convergence_distance = copy._convergence_distance; _keystone = copy._keystone; - // This matrix might have been explicitly set by the user (if - // UF_view_mat is applied), so we must preserve it. Other matrices - // are implicitly computed. + // This matrix might have been explicitly set by the user (if UF_view_mat is + // applied), so we must preserve it. Other matrices are implicitly + // computed. _lens_mat = copy._lens_mat; _user_flags = copy._user_flags; @@ -2129,22 +1906,18 @@ CData(const Lens::CData ©) { _geom_data = copy._geom_data; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Lens::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Lens::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_string(_change_event); @@ -2159,13 +1932,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint16(_user_flags); } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Geom. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Geom. + */ void Lens::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _change_event = scan.get_string(); @@ -2182,11 +1952,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _comp_flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Lens::CData::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Lens::CData:: clear() { _change_event = ""; diff --git a/panda/src/gobj/lens.h b/panda/src/gobj/lens.h index c1b43e6d2e..f695d36558 100644 --- a/panda/src/gobj/lens.h +++ b/panda/src/gobj/lens.h @@ -1,16 +1,15 @@ -// Filename: lens.h -// Created by: drose (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lens.h + * @author drose + * @date 1999-02-18 + */ #ifndef LENS_H #define LENS_H @@ -30,18 +29,15 @@ class BoundingVolume; -//////////////////////////////////////////////////////////////////// -// Class : Lens -// Description : A base class for any number of different kinds of -// lenses, linear and otherwise. Presently, this -// includes perspective and orthographic lenses. -// -// A Lens object is the main part of a Camera node, -// which defines the fundamental interface to -// point-of-view for rendering. Lenses are also used in -// other contexts, however; for instance, a Spotlight is -// also defined using a lens. -//////////////////////////////////////////////////////////////////// +/** + * A base class for any number of different kinds of lenses, linear and + * otherwise. Presently, this includes perspective and orthographic lenses. + * + * A Lens object is the main part of a Camera node, which defines the + * fundamental interface to point-of-view for rendering. Lenses are also used + * in other contexts, however; for instance, a Spotlight is also defined using + * a lens. + */ class EXPCL_PANDA_GOBJ Lens : public TypedWritableReferenceCount { public: Lens(); @@ -153,9 +149,9 @@ PUBLISHED: INLINE const LMatrix4 &get_custom_film_mat() const; void clear_custom_film_mat(); - // These flags are passed in as the last parameter to control the - // behavior of set_frustum_from_corners(). See the documentation - // for that method for an explanation of each flag. + // These flags are passed in as the last parameter to control the behavior + // of set_frustum_from_corners(). See the documentation for that method for + // an explanation of each flag. enum FromCorners { FC_roll = 0x0001, FC_camera_plane = 0x0002, @@ -269,7 +265,7 @@ private: static void build_shear_mat(LMatrix4 &shear_mat, const LPoint3 &cul, const LPoint3 &cur, const LPoint3 &cll, const LPoint3 &clr); - static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, + static PN_stdfloat sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, const LVector3 &vec); protected: @@ -329,7 +325,7 @@ protected: string _change_event; UpdateSeq _last_change; CoordinateSystem _cs; - + LVecBase2 _film_size; LVector2 _film_offset; PN_stdfloat _focal_length; @@ -337,31 +333,31 @@ protected: PN_stdfloat _min_fov; PN_stdfloat _aspect_ratio; PN_stdfloat _near_distance, _far_distance; - + LVecBase3 _view_hpr; LVector3 _view_vector, _up_vector; PN_stdfloat _interocular_distance; PN_stdfloat _convergence_distance; LVecBase2 _keystone; LMatrix4 _custom_film_mat; - + LMatrix4 _film_mat, _film_mat_inv; LMatrix4 _lens_mat, _lens_mat_inv; LMatrix4 _projection_mat, _projection_mat_inv; LMatrix4 _projection_mat_left, _projection_mat_left_inv; LMatrix4 _projection_mat_right, _projection_mat_right_inv; - + short _user_flags; short _comp_flags; - // The user may only specify two of these three parameters. - // Specifying the third parameter wipes out the first one specified. - // We therefore need to remember the order in which the user has - // specified these three parameters. A bit of a mess. + // The user may only specify two of these three parameters. Specifying + // the third parameter wipes out the first one specified. We therefore + // need to remember the order in which the user has specified these three + // parameters. A bit of a mess. char _focal_length_seq, _fov_seq, _film_size_seq; - + PT(GeomVertexData) _geom_data; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -369,11 +365,11 @@ protected: static void init_type() { register_type(_type_handle, "Lens::CData"); } - + private: static TypeHandle _type_handle; }; - + PipelineCycler _cycler; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; @@ -408,4 +404,3 @@ EXPCL_PANDA_GOBJ INLINE ostream &operator << (ostream &out, const Lens &lens); #include "lens.I" #endif - diff --git a/panda/src/gobj/material.I b/panda/src/gobj/material.I index e41362a1d2..a408f2a0e4 100644 --- a/panda/src/gobj/material.I +++ b/panda/src/gobj/material.I @@ -1,23 +1,19 @@ -// Filename: material.I -// Created by: mike (05Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file material.I + * @author mike + * @date 1999-02-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Material::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Material:: Material(const string &name) : Namable(name) { _base_color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -32,30 +28,24 @@ Material(const string &name) : Namable(name) { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Material:: Material(const Material ©) : Namable(copy) { operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: Material::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Material:: ~Material() { } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_default -// Access: Published, Static -// Description: Returns the default material. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default material. + */ INLINE Material *Material:: get_default() { if (_default == 0) { @@ -64,24 +54,19 @@ get_default() { return _default; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_base_color -// Access: Published -// Description: Returns true if the base color has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the base color has been explicitly set for this material, + * false otherwise. + */ INLINE bool Material:: has_base_color() const { return (_flags & F_base_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_base_color -// Access: Published -// Description: Returns the base_color color setting, if it has been -// set. If neither the base color nor the metallic -// have been set, this returns the diffuse color. -//////////////////////////////////////////////////////////////////// +/** + * Returns the base_color color setting, if it has been set. If neither the + * base color nor the metallic have been set, this returns the diffuse color. + */ INLINE const LColor &Material:: get_base_color() const { if (!has_base_color() && !has_metallic()) { @@ -91,34 +76,27 @@ get_base_color() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_ambient -// Access: Published -// Description: Returns true if the ambient color has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ambient color has been explicitly set for this + * material, false otherwise. + */ INLINE bool Material:: has_ambient() const { return (_flags & F_ambient) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_ambient -// Access: Published -// Description: Returns the ambient color setting, if it has been -// set. Returns (0,0,0,0) if the ambient color has not -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ambient color setting, if it has been set. Returns (0,0,0,0) + * if the ambient color has not been set. + */ INLINE const LColor &Material:: get_ambient() const { return _ambient; } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_ambient -// Access: Published -// Description: Removes the explicit ambient color from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit ambient color from the material. + */ INLINE void Material:: clear_ambient() { if (enforce_attrib_lock) { @@ -128,34 +106,27 @@ clear_ambient() { _ambient = _base_color; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_diffuse -// Access: Published -// Description: Returns true if the diffuse color has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the diffuse color has been explicitly set for this + * material, false otherwise. + */ INLINE bool Material:: has_diffuse() const { return (_flags & F_diffuse) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_diffuse -// Access: Published -// Description: Returns the diffuse color setting, if it has been -// set. Returns (1,1,1,1) if the diffuse color has not -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the diffuse color setting, if it has been set. Returns (1,1,1,1) + * if the diffuse color has not been set. + */ INLINE const LColor &Material:: get_diffuse() const { return _diffuse; } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_diffuse -// Access: Published -// Description: Removes the explicit diffuse color from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit diffuse color from the material. + */ INLINE void Material:: clear_diffuse() { if (enforce_attrib_lock) { @@ -165,57 +136,45 @@ clear_diffuse() { _diffuse = _base_color * (1 - _metallic); } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_specular -// Access: Published -// Description: Returns true if the specular color has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the specular color has been explicitly set for this + * material, false otherwise. + */ INLINE bool Material:: has_specular() const { return (_flags & F_specular) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_specular -// Access: Published -// Description: Returns the specular color setting, if it has been -// set. Returns (0,0,0,0) if the specular color has not -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specular color setting, if it has been set. Returns (0,0,0,0) + * if the specular color has not been set. + */ INLINE const LColor &Material:: get_specular() const { return _specular; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_emission -// Access: Published -// Description: Returns true if the emission color has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the emission color has been explicitly set for this + * material, false otherwise. + */ INLINE bool Material:: has_emission() const { return (_flags & F_emission) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_emission -// Access: Published -// Description: Returns the emission color setting, if it has been -// set. Returns (0,0,0,0) if the emission color has not -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the emission color setting, if it has been set. Returns (0,0,0,0) + * if the emission color has not been set. + */ INLINE const LColor &Material:: get_emission() const { return _emission; } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_emission -// Access: Published -// Description: Removes the explicit emission color from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit emission color from the material. + */ INLINE void Material:: clear_emission() { if (enforce_attrib_lock) { @@ -225,90 +184,73 @@ clear_emission() { _emission.set(0.0f, 0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_shininess -// Access: Published -// Description: Returns the shininess exponent of the material. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shininess exponent of the material. + */ INLINE PN_stdfloat Material:: get_shininess() const { return _shininess; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_roughness -// Access: Published -// Description: Returns true if the roughness has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the roughness has been explicitly set for this material, + * false otherwise. + */ INLINE bool Material:: has_roughness() const { return (_flags & F_roughness) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_metallic -// Access: Published -// Description: Returns true if the metallic has been explicitly -// set for this material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the metallic has been explicitly set for this material, + * false otherwise. + */ INLINE bool Material:: has_metallic() const { return (_flags & F_metallic) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_metallic -// Access: Published -// Description: Returns the metallic setting, if it has been set. -// Returns 0 if it has not been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the metallic setting, if it has been set. Returns 0 if it has not + * been set. + */ INLINE PN_stdfloat Material:: get_metallic() const { return _metallic; } -//////////////////////////////////////////////////////////////////// -// Function: Material::has_refractive_index -// Access: Published -// Description: Returns true if a refractive index has explicitly -// been specified for this material. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a refractive index has explicitly been specified for this + * material. + */ INLINE bool Material:: has_refractive_index() const { return (_flags & F_refractive_index) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_refractive_index -// Access: Published -// Description: Returns the index of refraction, or 1 if none has -// been set for this material. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of refraction, or 1 if none has been set for this + * material. + */ INLINE PN_stdfloat Material:: get_refractive_index() const { return _refractive_index; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_local -// Access: Published -// Description: Returns the local viewer flag. Set set_local(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the local viewer flag. Set set_local(). + */ INLINE bool Material:: get_local() const { return (_flags & F_local) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_local -// Access: Published -// Description: Sets the local viewer flag. Set this true to enable -// camera-relative specular highlights, or false to use -// orthogonal specular highlights. The default value is -// true. Applications that use orthogonal projection -// should specify false. -//////////////////////////////////////////////////////////////////// +/** + * Sets the local viewer flag. Set this true to enable camera-relative + * specular highlights, or false to use orthogonal specular highlights. The + * default value is true. Applications that use orthogonal projection should + * specify false. + */ INLINE void Material:: set_local(bool local) { if (enforce_attrib_lock) { @@ -321,26 +263,19 @@ set_local(bool local) { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_twoside -// Access: Published -// Description: Returns the state of the two-sided lighting flag. -// See set_twoside(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the state of the two-sided lighting flag. See set_twoside(). + */ INLINE bool Material:: get_twoside() const { return (_flags & F_twoside) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_twoside -// Access: Published -// Description: Set this true to enable two-sided lighting. When -// two-sided lighting is on, both sides of a polygon -// will be lit by this material. The default is for -// two-sided lighting to be off, in which case only the -// front surface is lit. -//////////////////////////////////////////////////////////////////// +/** + * Set this true to enable two-sided lighting. When two-sided lighting is on, + * both sides of a polygon will be lit by this material. The default is for + * two-sided lighting to be off, in which case only the front surface is lit. + */ INLINE void Material:: set_twoside(bool twoside) { if (enforce_attrib_lock) { @@ -353,51 +288,41 @@ set_twoside(bool twoside) { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Material:: operator == (const Material &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Material:: operator != (const Material &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Material:: operator < (const Material &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::is_attrib_locked -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Material:: is_attrib_locked() const { return (_flags & F_attrib_lock) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_attrib_lock -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Material:: set_attrib_lock() { _flags |= F_attrib_lock; diff --git a/panda/src/gobj/material.cxx b/panda/src/gobj/material.cxx index d2acb632c9..2d7b25bf6c 100644 --- a/panda/src/gobj/material.cxx +++ b/panda/src/gobj/material.cxx @@ -1,16 +1,15 @@ -// Filename: material.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file material.cxx + * @author mike + * @date 1997-01-09 + */ #include "pandabase.h" #include "material.h" @@ -23,11 +22,9 @@ TypeHandle Material::_type_handle; PT(Material) Material::_default; -//////////////////////////////////////////////////////////////////// -// Function: Material::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Material:: operator = (const Material ©) { Namable::operator = (copy); @@ -43,21 +40,17 @@ operator = (const Material ©) { _flags = copy._flags & (~F_attrib_lock); } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_base_color -// Access: Published -// Description: Specifies the base color of the material. In -// conjunction with set_metallic, this is an alternate -// way to specify the color of a material. For -// dielectrics, this will determine the value of the -// diffuse color, and for metals, this will determine -// the value of the specular color. -// -// Setting this will clear an explicit specular, -// diffuse or ambient color assignment. -// -// If this is not set, the object color will be used. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the base color of the material. In conjunction with + * set_metallic, this is an alternate way to specify the color of a material. + * For dielectrics, this will determine the value of the diffuse color, and + * for metals, this will determine the value of the specular color. + * + * Setting this will clear an explicit specular, diffuse or ambient color + * assignment. + * + * If this is not set, the object color will be used. + */ void Material:: set_base_color(const LColor &color) { if (enforce_attrib_lock) { @@ -83,11 +76,9 @@ set_base_color(const LColor &color) { _specular += _base_color * _metallic; } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_base_color -// Access: Published -// Description: Removes the explicit base_color color from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit base_color color from the material. + */ void Material:: clear_base_color() { if (enforce_attrib_lock) { @@ -113,18 +104,16 @@ clear_base_color() { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_ambient -// Access: Published -// Description: Specifies the ambient color setting of the material. -// This will be the multiplied by any ambient lights in -// effect on the material to set its base color. -// -// This is the color of the object as it appears in the -// absence of direct light. -// -// If this is not set, the object color will be used. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the ambient color setting of the material. This will be the + * multiplied by any ambient lights in effect on the material to set its base + * color. + * + * This is the color of the object as it appears in the absence of direct + * light. + * + * If this is not set, the object color will be used. + */ void Material:: set_ambient(const LColor &color) { if (enforce_attrib_lock) { @@ -136,20 +125,16 @@ set_ambient(const LColor &color) { _flags |= F_ambient; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_diffuse -// Access: Published -// Description: Specifies the diffuse color setting of the material. -// This will be multiplied by any lights in effect on -// the material to get the color in the parts of the -// object illuminated by the lights. -// -// This is the primary color of an object; the color of -// the object as it appears in direct light, in the -// absence of highlights. -// -// If this is not set, the object color will be used. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the diffuse color setting of the material. This will be + * multiplied by any lights in effect on the material to get the color in the + * parts of the object illuminated by the lights. + * + * This is the primary color of an object; the color of the object as it + * appears in direct light, in the absence of highlights. + * + * If this is not set, the object color will be used. + */ void Material:: set_diffuse(const LColor &color) { if (enforce_attrib_lock) { @@ -161,21 +146,18 @@ set_diffuse(const LColor &color) { _flags |= F_diffuse; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_specular -// Access: Published -// Description: Specifies the specular color setting of the material. -// This will be multiplied by any lights in effect on -// the material to compute the color of specular -// highlights on the object. -// -// This is the highlight color of an object: the color -// of small highlight reflections. -// -// If this is not set, the specular color is taken from -// the index of refraction, which is 1 by default -// (meaning no specular reflections are generated). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the specular color setting of the material. This will be + * multiplied by any lights in effect on the material to compute the color of + * specular highlights on the object. + * + * This is the highlight color of an object: the color of small highlight + * reflections. + * + * If this is not set, the specular color is taken from the index of + * refraction, which is 1 by default (meaning no specular reflections are + * generated). + */ void Material:: set_specular(const LColor &color) { if (enforce_attrib_lock) { @@ -187,11 +169,9 @@ set_specular(const LColor &color) { _flags |= F_specular; } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_specular -// Access: Published -// Description: Removes the explicit specular color from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit specular color from the material. + */ void Material:: clear_specular() { if (enforce_attrib_lock) { @@ -210,20 +190,15 @@ clear_specular() { _specular += _base_color * _metallic; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_emission -// Access: Published -// Description: Specifies the emission color setting of the material. -// This is the color of the object as it appears in the -// absence of any light whatsover, including ambient -// light. It is as if the object is glowing by this -// color (although of course it will not illuminate -// neighboring objects). -// -// If this is not set, the object will not glow by its -// own light and will only appear visible in the -// presence of one or more lights. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the emission color setting of the material. This is the color of + * the object as it appears in the absence of any light whatsover, including + * ambient light. It is as if the object is glowing by this color (although + * of course it will not illuminate neighboring objects). + * + * If this is not set, the object will not glow by its own light and will only + * appear visible in the presence of one or more lights. + */ void Material:: set_emission(const LColor &color) { if (enforce_attrib_lock) { @@ -235,34 +210,26 @@ set_emission(const LColor &color) { _flags |= F_emission; } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_shininess -// Access: Published -// Description: Sets the shininess exponent of the material. This -// controls the size of the specular highlight spot. In -// general, larger number produce a smaller specular -// highlight, which makes the object appear shinier. -// Smaller numbers produce a larger highlight, which -// makes the object appear less shiny. -// -// This is usually in the range 0..128. -// -// Setting a shininess value removes any previous -// roughness assignment. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shininess exponent of the material. This controls the size of the + * specular highlight spot. In general, larger number produce a smaller + * specular highlight, which makes the object appear shinier. Smaller numbers + * produce a larger highlight, which makes the object appear less shiny. + * + * This is usually in the range 0..128. + * + * Setting a shininess value removes any previous roughness assignment. + */ void Material:: set_shininess(PN_stdfloat shininess) { _shininess = shininess; _flags &= ~F_roughness; } -//////////////////////////////////////////////////////////////////// -// Function: Material::get_roughness -// Access: Published -// Description: Returns the roughness previously specified by -// set_roughness. If none was previously set, this -// value is computed from the shininess value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the roughness previously specified by set_roughness. If none was + * previously set, this value is computed from the shininess value. + */ PN_stdfloat Material:: get_roughness() const { if ((_flags & F_roughness) == 0) { @@ -273,27 +240,24 @@ get_roughness() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_roughness -// Access: Published -// Description: Sets the roughness exponent of the material, where -// 0 is completely shiny (infinite shininess), and -// 1 is a completely dull object (0 shininess). This -// is a different, more perceptually intuitive way of -// controlling the size of the specular spot, and more -// commonly used in physically-based rendering. -// -// Setting a roughness recalculates the shininess value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the roughness exponent of the material, where 0 is completely shiny + * (infinite shininess), and 1 is a completely dull object (0 shininess). + * This is a different, more perceptually intuitive way of controlling the + * size of the specular spot, and more commonly used in physically-based + * rendering. + * + * Setting a roughness recalculates the shininess value. + */ void Material:: set_roughness(PN_stdfloat roughness) { _roughness = roughness; _flags |= F_roughness; - // Calculate the specular exponent from the roughness as it is used - // in Blinn-Phong shading model. We use the popular Disney method - // of squaring the roughness to get a more perceptually linear scale. - // From: http://graphicrants.blogspot.de/2013/08/specular-brdf-reference.html + // Calculate the specular exponent from the roughness as it is used in + // Blinn-Phong shading model. We use the popular Disney method of squaring + // the roughness to get a more perceptually linear scale. From: + // http:graphicrants.blogspot.de201308specular-brdf-reference.html if (roughness <= 0 || IS_NEARLY_ZERO(roughness)) { _shininess = make_inf((PN_stdfloat)0); } else { @@ -302,17 +266,13 @@ set_roughness(PN_stdfloat roughness) { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_metallic -// Access: Published -// Description: Sets the metallic setting of the material, which is -// is used for physically-based rendering models. -// This is usually 0 for dielectric materials and 1 -// for metals. It really does not make sense to set -// this to a value other than 0 or 1, but it is -// nonetheless a float for compatibility with tools -// that allow setting this to values other than 0 or 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the metallic setting of the material, which is is used for physically- + * based rendering models. This is usually 0 for dielectric materials and 1 + * for metals. It really does not make sense to set this to a value other + * than 0 or 1, but it is nonetheless a float for compatibility with tools + * that allow setting this to values other than 0 or 1. + */ void Material:: set_metallic(PN_stdfloat metallic) { if (enforce_attrib_lock) { @@ -340,11 +300,9 @@ set_metallic(PN_stdfloat metallic) { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::clear_metallic -// Access: Published -// Description: Removes the explicit metallic setting from the material. -//////////////////////////////////////////////////////////////////// +/** + * Removes the explicit metallic setting from the material. + */ void Material:: clear_metallic() { if (enforce_attrib_lock) { @@ -370,18 +328,14 @@ clear_metallic() { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::set_refractive_index -// Access: Published -// Description: Sets the index of refraction of the material, which -// is used to determine the specular color in absence -// of an explicit specular color assignment. -// This is usually 1.5 for dielectric materials. It -// is not very useful for metals, since they cannot -// be described as easily with a single number. -// -// Should be 1 or higher. The default is 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the index of refraction of the material, which is used to determine + * the specular color in absence of an explicit specular color assignment. + * This is usually 1.5 for dielectric materials. It is not very useful for + * metals, since they cannot be described as easily with a single number. + * + * Should be 1 or higher. The default is 1. + */ void Material:: set_refractive_index(PN_stdfloat refractive_index) { _refractive_index = refractive_index; @@ -398,15 +352,12 @@ set_refractive_index(PN_stdfloat refractive_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: Material::compare_to -// Access: Published -// Description: Returns a number less than zero if this material -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. The -// sorting order is arbitrary and largely meaningless, -// except to differentiate different materials. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this material sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * The sorting order is arbitrary and largely meaningless, except to + * differentiate different materials. + */ int Material:: compare_to(const Material &other) const { if (_flags != other._flags) { @@ -440,11 +391,9 @@ compare_to(const Material &other) const { return strcmp(get_name().c_str(), other.get_name().c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: Material::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Material:: output(ostream &out) const { out << "Material " << get_name(); @@ -479,11 +428,9 @@ output(ostream &out) const { << " t" << get_twoside(); } -//////////////////////////////////////////////////////////////////// -// Function: Material::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Material:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "Material " << get_name() << "\n"; @@ -518,22 +465,18 @@ write(ostream &out, int indent_level) const { -//////////////////////////////////////////////////////////////////// -// Function: Material::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a Material object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Material object + */ void Material:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_Material); } -//////////////////////////////////////////////////////////////////// -// Function: Material::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void Material:: write_datagram(BamWriter *manager, Datagram &me) { me.add_string(get_name()); @@ -560,11 +503,9 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_stdfloat(_refractive_index); } -//////////////////////////////////////////////////////////////////// -// Function: Material::make_Material -// Access: Protected -// Description: Factory method to generate a Material object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Material object + */ TypedWritable *Material:: make_Material(const FactoryParams ¶ms) { Material *me = new Material; @@ -576,14 +517,11 @@ make_Material(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: Material::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void Material:: fillin(DatagramIterator &scan, BamReader *manager) { set_name(scan.get_string()); diff --git a/panda/src/gobj/material.h b/panda/src/gobj/material.h index 85d15a04b2..1a37415294 100644 --- a/panda/src/gobj/material.h +++ b/panda/src/gobj/material.h @@ -1,16 +1,15 @@ -// Filename: material.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file material.h + * @author mike + * @date 1997-01-09 + */ #ifndef MATERIAL_H #define MATERIAL_H @@ -25,24 +24,21 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : Material -// Description : Defines the way an object appears in the presence of -// lighting. A material is only necessary if lighting -// is to be enabled; otherwise, the material isn't used. -// -// There are two workflows that are supported: the -// "classic" workflow of providing separate ambient, -// diffuse and specular colors, and the "metalness" -// workflow, in which a base color is specified along -// with a "metallic" value that indicates whether the -// material is a metal or a dielectric. -// -// The size of the specular highlight can be specified -// by either specifying the specular exponent (shininess) -// or by specifying a roughness value that in perceptually -// linear in the range of 0-1. -//////////////////////////////////////////////////////////////////// +/** + * Defines the way an object appears in the presence of lighting. A material + * is only necessary if lighting is to be enabled; otherwise, the material + * isn't used. + * + * There are two workflows that are supported: the "classic" workflow of + * providing separate ambient, diffuse and specular colors, and the + * "metalness" workflow, in which a base color is specified along with a + * "metallic" value that indicates whether the material is a metal or a + * dielectric. + * + * The size of the specular highlight can be specified by either specifying + * the specular exponent (shininess) or by specifying a roughness value that + * in perceptually linear in the range of 0-1. + */ class EXPCL_PANDA_GOBJ Material : public TypedWritableReferenceCount, public Namable { PUBLISHED: INLINE explicit Material(const string &name = ""); diff --git a/panda/src/gobj/materialPool.I b/panda/src/gobj/materialPool.I index 0fc4774f0f..6d6726bde6 100644 --- a/panda/src/gobj/materialPool.I +++ b/panda/src/gobj/materialPool.I @@ -1,95 +1,76 @@ -// Filename: materialPool.I -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialPool.I + * @author drose + * @date 2001-04-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::get_material -// Access: Public, Static -// Description: Returns a Material pointer that represents the -// same material described by temp, except that it is a -// shared pointer. -// -// Each call to get_material() passing an equivalent -// Material pointer will return the same shared pointer. -// -// If you modify the shared pointer, it will -// automatically disassociate it from the pool. -// -// Also, the return value may be a different pointer -// than that passed in, or it may be the same pointer. -// In either case, the passed in pointer has now been -// sacrificed to the greater good and should not be used -// again (like any other PointerTo, it will be freed -// when the last reference count is removed). -//////////////////////////////////////////////////////////////////// +/** + * Returns a Material pointer that represents the same material described by + * temp, except that it is a shared pointer. + * + * Each call to get_material() passing an equivalent Material pointer will + * return the same shared pointer. + * + * If you modify the shared pointer, it will automatically disassociate it + * from the pool. + * + * Also, the return value may be a different pointer than that passed in, or + * it may be the same pointer. In either case, the passed in pointer has now + * been sacrificed to the greater good and should not be used again (like any + * other PointerTo, it will be freed when the last reference count is + * removed). + */ INLINE Material *MaterialPool:: get_material(Material *temp) { return get_global_ptr()->ns_get_material(temp); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::release_material -// Access: Published, Static -// Description: Removes the indicated material from the pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated material from the pool. + */ INLINE void MaterialPool:: release_material(Material *material) { get_global_ptr()->ns_release_material(material); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::release_all_materials -// Access: Published, Static -// Description: Releases all materials in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all materials in the pool and restores the pool to the empty + * state. + */ INLINE void MaterialPool:: release_all_materials() { get_global_ptr()->ns_release_all_materials(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::garbage_collect -// Access: Public, Static -// Description: Releases only those materials in the pool that have a -// reference count of exactly 1; i.e. only those -// materials that are not being used outside of the pool. -// Returns the number of materials released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those materials in the pool that have a reference count of + * exactly 1; i.e. only those materials that are not being used outside of + * the pool. Returns the number of materials released. + */ INLINE int MaterialPool:: garbage_collect() { return get_global_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::list_contents -// Access: Public, Static -// Description: Lists the contents of the material pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the material pool to the indicated output stream. + */ INLINE void MaterialPool:: list_contents(ostream &out) { get_global_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one MaterialPool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one MaterialPool in the universe and it constructs itself. + */ INLINE MaterialPool:: MaterialPool() { } diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 464f3a73d2..22b8f9c5ee 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -1,16 +1,15 @@ -// Filename: materialPool.cxx -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialPool.cxx + * @author drose + * @date 2001-04-30 + */ #include "materialPool.h" #include "config_gobj.h" @@ -19,22 +18,17 @@ MaterialPool *MaterialPool::_global_ptr = (MaterialPool *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::write -// Access: Published, Static -// Description: Lists the contents of the material pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the material pool to the indicated output stream. + */ void MaterialPool:: write(ostream &out) { get_global_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::ns_get_material -// Access: Public -// Description: The nonstatic implementation of get_material(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of get_material(). + */ Material *MaterialPool:: ns_get_material(Material *temp) { LightMutexHolder holder(_lock); @@ -45,19 +39,16 @@ ns_get_material(Material *temp) { mi = _materials.insert(Materials::value_type(new Material(*temp), temp)).first; } else { if (*(*mi).first != *(*mi).second) { - // The pointer no longer matches its original value. Save a new - // one. + // The pointer no longer matches its original value. Save a new one. (*mi).second = temp; } } return (*mi).second; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::ns_release_material -// Access: Private -// Description: The nonstatic implementation of release_material(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_material(). + */ void MaterialPool:: ns_release_material(Material *temp) { LightMutexHolder holder(_lock); @@ -66,11 +57,9 @@ ns_release_material(Material *temp) { _materials.erase(cpttemp); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::ns_release_all_materials -// Access: Private -// Description: The nonstatic implementation of release_all_materials(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_materials(). + */ void MaterialPool:: ns_release_all_materials() { LightMutexHolder holder(_lock); @@ -78,11 +67,9 @@ ns_release_all_materials() { _materials.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int MaterialPool:: ns_garbage_collect() { LightMutexHolder holder(_lock); @@ -109,11 +96,9 @@ ns_garbage_collect() { return num_released; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void MaterialPool:: ns_list_contents(ostream &out) const { LightMutexHolder holder(_lock); @@ -128,12 +113,10 @@ ns_list_contents(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MaterialPool::get_global_ptr -// Access: Private, Static -// Description: Initializes and/or returns the global pointer to the -// one MaterialPool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one MaterialPool + * object in the system. + */ MaterialPool *MaterialPool:: get_global_ptr() { if (_global_ptr == (MaterialPool *)NULL) { diff --git a/panda/src/gobj/materialPool.h b/panda/src/gobj/materialPool.h index 8f879c3284..e5a0775b0b 100644 --- a/panda/src/gobj/materialPool.h +++ b/panda/src/gobj/materialPool.h @@ -1,16 +1,15 @@ -// Filename: materialPool.h -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialPool.h + * @author drose + * @date 2001-04-30 + */ #ifndef MATERIALPOOL_H #define MATERIALPOOL_H @@ -21,24 +20,19 @@ #include "lightMutex.h" #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : MaterialPool -// Description : The MaterialPool (there is only one in the universe) -// serves to unify different pointers to the same -// Material, so we do not (a) waste memory with many -// different Material objects that are all equivalent, -// and (b) waste time switching the graphics engine -// between different Material states that are really the -// same thing. -// -// The idea is to create a temporary Material -// representing the lighting state you want to apply, -// then call get_material(), passing in your temporary -// Material. The return value will either be a new -// Material object, or it may be the the same object you -// supplied; in either case, it will have the same -// value. -//////////////////////////////////////////////////////////////////// +/** + * The MaterialPool (there is only one in the universe) serves to unify + * different pointers to the same Material, so we do not (a) waste memory with + * many different Material objects that are all equivalent, and (b) waste time + * switching the graphics engine between different Material states that are + * really the same thing. + * + * The idea is to create a temporary Material representing the lighting state + * you want to apply, then call get_material(), passing in your temporary + * Material. The return value will either be a new Material object, or it may + * be the the same object you supplied; in either case, it will have the same + * value. + */ class EXPCL_PANDA_GOBJ MaterialPool { PUBLISHED: INLINE static Material *get_material(Material *temp); @@ -67,9 +61,9 @@ private: LightMutex _lock; // We store a map of CPT(Material) to PT(Material). These are two - // equivalent structures, but different pointers. The first pointer - // never leaves this class. If the second pointer changes value, - // we'll notice it and return a new one. + // equivalent structures, but different pointers. The first pointer never + // leaves this class. If the second pointer changes value, we'll notice it + // and return a new one. typedef pmap< CPT(Material), PT(Material), indirect_compare_to > Materials; Materials _materials; }; @@ -77,5 +71,3 @@ private: #include "materialPool.I" #endif - - diff --git a/panda/src/gobj/matrixLens.I b/panda/src/gobj/matrixLens.I index eef0806ad4..74cc9296cf 100644 --- a/panda/src/gobj/matrixLens.I +++ b/panda/src/gobj/matrixLens.I @@ -1,40 +1,35 @@ -// Filename: matrixLens.I -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file matrixLens.I + * @author drose + * @date 2001-12-12 + */ -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MatrixLens:: MatrixLens() : _user_mat(LMatrix4::ident_mat()), _ml_flags(0) { - // The default film size for a MatrixLens is 2, which makes the - // default range for both X and Y be [-1, 1]. This also, - // incidentally, makes the film_mat be identity. + // The default film size for a MatrixLens is 2, which makes the default + // range for both X and Y be [-1, 1]. This also, incidentally, makes the + // film_mat be identity. set_film_size(2.0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MatrixLens:: -MatrixLens(const MatrixLens ©) : +MatrixLens(const MatrixLens ©) : Lens(copy), _user_mat(copy._user_mat), _left_eye_mat(copy._left_eye_mat), @@ -43,11 +38,9 @@ MatrixLens(const MatrixLens ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MatrixLens:: operator = (const MatrixLens ©) { Lens::operator = (copy); @@ -57,23 +50,17 @@ operator = (const MatrixLens ©) { _ml_flags = copy._ml_flags; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::set_user_mat -// Access: Published -// Description: Explicitly specifies the projection matrix. This -// matrix should convert X and Y to the range -// [-film_size/2, film_size/2], where (-fs/2,-fs/2) is -// the lower left corner of the screen and (fs/2, fs/2) -// is the upper right. Z should go to the range [-1, -// 1], where -1 is the far plane and 1 is the near -// plane. Note that this is a left-handed Y-up -// coordinate system. -// -// The default film_size for a MatrixLens is 2, so the -// default range is [-1, 1] for both X and Y. This is -// consistent with the GL conventions for projection -// matrices. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly specifies the projection matrix. This matrix should convert X + * and Y to the range [-film_size/2, film_size/2], where (-fs/2,-fs/2) is the + * lower left corner of the screen and (fs/2, fs/2) is the upper right. Z + * should go to the range [-1, 1], where -1 is the far plane and 1 is the near + * plane. Note that this is a left-handed Y-up coordinate system. + * + * The default film_size for a MatrixLens is 2, so the default range is [-1, + * 1] for both X and Y. This is consistent with the GL conventions for + * projection matrices. + */ INLINE void MatrixLens:: set_user_mat(const LMatrix4 &user_mat) { Lens::CDWriter lens_cdata(Lens::_cycler, true); @@ -81,32 +68,24 @@ set_user_mat(const LMatrix4 &user_mat) { do_adjust_comp_flags(lens_cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::get_user_mat -// Access: Published -// Description: Returns the explicit projection matrix as set by the -// user. This does not include transforms on the lens -// or film (e.g. a film offset or view hpr). -//////////////////////////////////////////////////////////////////// +/** + * Returns the explicit projection matrix as set by the user. This does not + * include transforms on the lens or film (e.g. a film offset or view hpr). + */ INLINE const LMatrix4 &MatrixLens:: get_user_mat() const { return _user_mat; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::set_left_eye_mat -// Access: Published -// Description: Sets a custom projection matrix for the left eye. -// This is only used if the lens is attached to a stereo -// camera, in which case the left eye matrix will be -// used to draw the scene in the left eye (but the -// center matrix--the user_mat--will still be used to -// cull the scene). -// -// This matrix should not be too different from the -// center matrix (set by set_user_mat()) or culling -// errors may become obvious. -//////////////////////////////////////////////////////////////////// +/** + * Sets a custom projection matrix for the left eye. This is only used if the + * lens is attached to a stereo camera, in which case the left eye matrix will + * be used to draw the scene in the left eye (but the center matrix--the + * user_mat--will still be used to cull the scene). + * + * This matrix should not be too different from the center matrix (set by + * set_user_mat()) or culling errors may become obvious. + */ INLINE void MatrixLens:: set_left_eye_mat(const LMatrix4 &left_eye_mat) { Lens::CDWriter lens_cdata(Lens::_cycler, true); @@ -115,13 +94,10 @@ set_left_eye_mat(const LMatrix4 &left_eye_mat) { do_adjust_comp_flags(lens_cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::clear_left_eye_mat -// Access: Published -// Description: Removes the custom projection matrix set for the left -// eye, and uses the center matrix (set by set_user_mat) -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Removes the custom projection matrix set for the left eye, and uses the + * center matrix (set by set_user_mat) instead. + */ INLINE void MatrixLens:: clear_left_eye_mat() { Lens::CDWriter lens_cdata(Lens::_cycler, true); @@ -129,26 +105,20 @@ clear_left_eye_mat() { do_adjust_comp_flags(lens_cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::has_left_eye_mat -// Access: Published -// Description: Returns true if the camera has a custom projection -// matrix set for the left eye, or false if the center -// matrix (set by set_user_mat) will be used for the -// left eye. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the camera has a custom projection matrix set for the left + * eye, or false if the center matrix (set by set_user_mat) will be used for + * the left eye. + */ INLINE bool MatrixLens:: has_left_eye_mat() const { return (_ml_flags & MF_has_left_eye) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::get_left_eye_mat -// Access: Published -// Description: Returns the custom projection matrix for the left -// eye, if any, or the center matrix if there is no -// custom matrix set for the left eye. -//////////////////////////////////////////////////////////////////// +/** + * Returns the custom projection matrix for the left eye, if any, or the + * center matrix if there is no custom matrix set for the left eye. + */ INLINE const LMatrix4 &MatrixLens:: get_left_eye_mat() const { if ((_ml_flags & MF_has_left_eye) != 0) { @@ -157,20 +127,15 @@ get_left_eye_mat() const { return _user_mat; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::set_right_eye_mat -// Access: Published -// Description: Sets a custom projection matrix for the right eye. -// This is only used if the lens is attached to a stereo -// camera, in which case the right eye matrix will be -// used to draw the scene in the right eye (but the -// center matrix--the user_mat--will still be used to -// cull the scene). -// -// This matrix should not be too different from the -// center matrix (set by set_user_mat()) or culling -// errors may become obvious. -//////////////////////////////////////////////////////////////////// +/** + * Sets a custom projection matrix for the right eye. This is only used if + * the lens is attached to a stereo camera, in which case the right eye matrix + * will be used to draw the scene in the right eye (but the center matrix--the + * user_mat--will still be used to cull the scene). + * + * This matrix should not be too different from the center matrix (set by + * set_user_mat()) or culling errors may become obvious. + */ INLINE void MatrixLens:: set_right_eye_mat(const LMatrix4 &right_eye_mat) { Lens::CDWriter lens_cdata(Lens::_cycler, true); @@ -179,13 +144,10 @@ set_right_eye_mat(const LMatrix4 &right_eye_mat) { do_adjust_comp_flags(lens_cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::clear_right_eye_mat -// Access: Published -// Description: Removes the custom projection matrix set for the right -// eye, and uses the center matrix (set by set_user_mat) -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Removes the custom projection matrix set for the right eye, and uses the + * center matrix (set by set_user_mat) instead. + */ INLINE void MatrixLens:: clear_right_eye_mat() { Lens::CDWriter lens_cdata(Lens::_cycler, true); @@ -193,26 +155,20 @@ clear_right_eye_mat() { do_adjust_comp_flags(lens_cdata, CF_mat, 0); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::has_right_eye_mat -// Access: Published -// Description: Returns true if the camera has a custom projection -// matrix set for the right eye, or false if the center -// matrix (set by set_user_mat) will be used for the -// right eye. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the camera has a custom projection matrix set for the right + * eye, or false if the center matrix (set by set_user_mat) will be used for + * the right eye. + */ INLINE bool MatrixLens:: has_right_eye_mat() const { return (_ml_flags & MF_has_right_eye) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::get_right_eye_mat -// Access: Published -// Description: Returns the custom projection matrix for the right -// eye, if any, or the center matrix if there is no -// custom matrix set for the right eye. -//////////////////////////////////////////////////////////////////// +/** + * Returns the custom projection matrix for the right eye, if any, or the + * center matrix if there is no custom matrix set for the right eye. + */ INLINE const LMatrix4 &MatrixLens:: get_right_eye_mat() const { if ((_ml_flags & MF_has_right_eye) != 0) { diff --git a/panda/src/gobj/matrixLens.cxx b/panda/src/gobj/matrixLens.cxx index 5d50a32501..d2254f7175 100644 --- a/panda/src/gobj/matrixLens.cxx +++ b/panda/src/gobj/matrixLens.cxx @@ -1,16 +1,15 @@ -// Filename: matrixLens.cxx -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file matrixLens.cxx + * @author drose + * @date 2001-12-12 + */ #include "matrixLens.h" #include "indent.h" @@ -19,85 +18,70 @@ TypeHandle MatrixLens::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) MatrixLens:: make_copy() const { return new MatrixLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::is_linear -// Access: Published, Virtual -// Description: Returns true if the lens represents a linear -// projection (e.g. PerspectiveLens, MatrixLens), -// and therefore there is a valid matrix returned by -// get_projection_mat(), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a linear projection (e.g. + * PerspectiveLens, MatrixLens), and therefore there is a valid matrix + * returned by get_projection_mat(), or false otherwise. + */ bool MatrixLens:: is_linear() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MatrixLens:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":\n"; get_projection_mat().write(out, indent_level + 2); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::do_compute_projection_mat -// Access: Protected, Virtual -// Description: Computes the complete transformation matrix from 3-d -// point to 2-d point, if the lens is linear. -//////////////////////////////////////////////////////////////////// +/** + * Computes the complete transformation matrix from 3-d point to 2-d point, if + * the lens is linear. + */ void MatrixLens:: do_compute_projection_mat(Lens::CData *lens_cdata) { lens_cdata->_projection_mat = do_get_lens_mat_inv(lens_cdata) * _user_mat * do_get_film_mat(lens_cdata); - + if (_ml_flags & MF_has_left_eye) { lens_cdata->_projection_mat_left = do_get_lens_mat_inv(lens_cdata) * _left_eye_mat * do_get_film_mat(lens_cdata); } else { lens_cdata->_projection_mat_left = lens_cdata->_projection_mat; } - + if (_ml_flags & MF_has_right_eye) { lens_cdata->_projection_mat_right = do_get_lens_mat_inv(lens_cdata) * _right_eye_mat * do_get_film_mat(lens_cdata); } else { lens_cdata->_projection_mat_right = lens_cdata->_projection_mat; } - - do_adjust_comp_flags(lens_cdata, CF_projection_mat_inv, + + do_adjust_comp_flags(lens_cdata, CF_projection_mat_inv, CF_projection_mat); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void MatrixLens:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: MatrixLens::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *MatrixLens:: make_from_bam(const FactoryParams ¶ms) { MatrixLens *lens = new MatrixLens; diff --git a/panda/src/gobj/matrixLens.h b/panda/src/gobj/matrixLens.h index 3dda5b3058..812cd7b55a 100644 --- a/panda/src/gobj/matrixLens.h +++ b/panda/src/gobj/matrixLens.h @@ -1,16 +1,15 @@ -// Filename: matrixLens.h -// Created by: drose (12Dec01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file matrixLens.h + * @author drose + * @date 2001-12-12 + */ #ifndef MATRIXLENS_H #define MATRIXLENS_H @@ -20,14 +19,12 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : MatrixLens -// Description : A completely generic linear lens. This is provided -// for the benefit of low-level code that wants to -// specify a perspective or orthographic frustum via an -// explicit projection matrix, but not mess around with -// fov's or focal lengths or any of that nonsense. -//////////////////////////////////////////////////////////////////// +/** + * A completely generic linear lens. This is provided for the benefit of low- + * level code that wants to specify a perspective or orthographic frustum via + * an explicit projection matrix, but not mess around with fov's or focal + * lengths or any of that nonsense. + */ class EXPCL_PANDA_GOBJ MatrixLens : public Lens { PUBLISHED: INLINE MatrixLens(); diff --git a/panda/src/gobj/occlusionQueryContext.I b/panda/src/gobj/occlusionQueryContext.I index 6ef7c3acb9..1e7e42a06b 100644 --- a/panda/src/gobj/occlusionQueryContext.I +++ b/panda/src/gobj/occlusionQueryContext.I @@ -1,23 +1,19 @@ -// Filename: occlusionQueryContext.I -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occlusionQueryContext.I + * @author drose + * @date 2006-03-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OcclusionQueryContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OcclusionQueryContext:: OcclusionQueryContext() { } diff --git a/panda/src/gobj/occlusionQueryContext.cxx b/panda/src/gobj/occlusionQueryContext.cxx index 9957ef3f78..c813938483 100644 --- a/panda/src/gobj/occlusionQueryContext.cxx +++ b/panda/src/gobj/occlusionQueryContext.cxx @@ -1,31 +1,27 @@ -// Filename: occlusionQueryContext.cxx -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occlusionQueryContext.cxx + * @author drose + * @date 2006-03-27 + */ #include "occlusionQueryContext.h" TypeHandle OcclusionQueryContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OcclusionQueryContext::get_num_fragments -// Access: Public, Virtual -// Description: Returns the number of fragments (pixels) of the -// specified geometry that passed the depth test. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of fragments (pixels) of the specified geometry that + * passed the depth test. If is_answer_ready() did not return true, this + * function may block before it returns. + * + * It is only valid to call this from the draw thread. + */ int OcclusionQueryContext:: get_num_fragments() const { return 0; diff --git a/panda/src/gobj/occlusionQueryContext.h b/panda/src/gobj/occlusionQueryContext.h index 5d0b01dfce..288ef4897a 100644 --- a/panda/src/gobj/occlusionQueryContext.h +++ b/panda/src/gobj/occlusionQueryContext.h @@ -1,16 +1,15 @@ -// Filename: occlusionQueryContext.h -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occlusionQueryContext.h + * @author drose + * @date 2006-03-27 + */ #ifndef OCCLUSIONQUERYCONTEXT_H #define OCCLUSIONQUERYCONTEXT_H @@ -18,19 +17,17 @@ #include "pandabase.h" #include "queryContext.h" -//////////////////////////////////////////////////////////////////// -// Class : OcclusionQueryContext -// Description : Returned from a GSG in response to -// begin_occlusion_query() .. end_occlusion_query(), -// this records the number of fragments (pixels) that -// passed the depth test between the bracketing calls. -//////////////////////////////////////////////////////////////////// +/** + * Returned from a GSG in response to begin_occlusion_query() .. + * end_occlusion_query(), this records the number of fragments (pixels) that + * passed the depth test between the bracketing calls. + */ class EXPCL_PANDA_GOBJ OcclusionQueryContext : public QueryContext { public: INLINE OcclusionQueryContext(); virtual int get_num_fragments() const=0; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -54,4 +51,3 @@ private: #include "occlusionQueryContext.I" #endif - diff --git a/panda/src/gobj/orthographicLens.I b/panda/src/gobj/orthographicLens.I index 28ab3d8b90..87a0dd03ae 100644 --- a/panda/src/gobj/orthographicLens.I +++ b/panda/src/gobj/orthographicLens.I @@ -1,42 +1,34 @@ -// Filename: orthographicLens.I -// Created by: mike (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orthographicLens.I + * @author mike + * @date 1999-02-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OrthographicLens:: OrthographicLens() { } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OrthographicLens:: OrthographicLens(const OrthographicLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void OrthographicLens:: operator = (const OrthographicLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/gobj/orthographicLens.cxx b/panda/src/gobj/orthographicLens.cxx index 2dc775b370..86c8fe0ef5 100644 --- a/panda/src/gobj/orthographicLens.cxx +++ b/panda/src/gobj/orthographicLens.cxx @@ -1,16 +1,15 @@ -// Filename: orthographicLens.cxx -// Created by: mike (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orthographicLens.cxx + * @author mike + * @date 1999-02-18 + */ #include "orthographicLens.h" #include "indent.h" @@ -19,70 +18,56 @@ TypeHandle OrthographicLens::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) OrthographicLens:: make_copy() const { return new OrthographicLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::is_linear -// Access: Published, Virtual -// Description: Returns true if the lens represents a linear -// projection (e.g. PerspectiveLens, OrthographicLens), -// and therefore there is a valid matrix returned by -// get_projection_mat(), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a linear projection (e.g. + * PerspectiveLens, OrthographicLens), and therefore there is a valid matrix + * returned by get_projection_mat(), or false otherwise. + */ bool OrthographicLens:: is_linear() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::is_orthographic -// Access: Published, Virtual -// Description: Returns true if the lens represents a orthographic -// projection (i.e. it is a OrthographicLens), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a orthographic projection (i.e. it is + * a OrthographicLens), false otherwise. + */ bool OrthographicLens:: is_orthographic() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OrthographicLens:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << " film size = " << get_film_size() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::do_extrude_depth -// Access: Protected, Virtual -// Description: This is the generic implementation, which is based on -// do_extrude() and assumes a linear distribution of -// depth values between the near and far points. -//////////////////////////////////////////////////////////////////// +/** + * This is the generic implementation, which is based on do_extrude() and + * assumes a linear distribution of depth values between the near and far + * points. + */ bool OrthographicLens:: do_extrude_depth(const CData *cdata, const LPoint3 &point2d, LPoint3 &point3d) const { return do_extrude_depth_with_mat(cdata, point2d, point3d); } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::do_compute_projection_mat -// Access: Protected, Virtual -// Description: Computes the complete transformation matrix from 3-d -// point to 2-d point, if the lens is linear. -//////////////////////////////////////////////////////////////////// +/** + * Computes the complete transformation matrix from 3-d point to 2-d point, if + * the lens is linear. + */ void OrthographicLens:: do_compute_projection_mat(Lens::CData *lens_cdata) { CoordinateSystem cs = lens_cdata->_cs; @@ -132,30 +117,24 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { lens_cdata->_projection_mat = do_get_lens_mat_inv(lens_cdata) * canonical * do_get_film_mat(lens_cdata); lens_cdata->_projection_mat_left = lens_cdata->_projection_mat_right = lens_cdata->_projection_mat; - do_adjust_comp_flags(lens_cdata, + do_adjust_comp_flags(lens_cdata, CF_projection_mat_inv | CF_projection_mat_left_inv | CF_projection_mat_right_inv, CF_projection_mat); } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void OrthographicLens:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: OrthographicLens::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *OrthographicLens:: make_from_bam(const FactoryParams ¶ms) { OrthographicLens *lens = new OrthographicLens; diff --git a/panda/src/gobj/orthographicLens.h b/panda/src/gobj/orthographicLens.h index 3319177bf8..8798d4d8e7 100644 --- a/panda/src/gobj/orthographicLens.h +++ b/panda/src/gobj/orthographicLens.h @@ -1,16 +1,15 @@ -// Filename: orthographicLens.h -// Created by: mike (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orthographicLens.h + * @author mike + * @date 1999-02-18 + */ #ifndef ORTHOGRAPHICLENS_H #define ORTHOGRAPHICLENS_H @@ -20,17 +19,14 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : OrthographicLens -// Description : An orthographic lens. Although this kind of lens is -// linear, like a PerspectiveLens, it doesn't respect -// field-of-view or focal length parameters, and -// adjusting these will have no effect. Instead, its -// field of view is controlled by adjusting the -// film_size; the orthographic lens represents a planar -// projection onto its imaginary film of the specified -// size, hanging in space. -//////////////////////////////////////////////////////////////////// +/** + * An orthographic lens. Although this kind of lens is linear, like a + * PerspectiveLens, it doesn't respect field-of-view or focal length + * parameters, and adjusting these will have no effect. Instead, its field of + * view is controlled by adjusting the film_size; the orthographic lens + * represents a planar projection onto its imaginary film of the specified + * size, hanging in space. + */ class EXPCL_PANDA_GOBJ OrthographicLens : public Lens { PUBLISHED: INLINE OrthographicLens(); diff --git a/panda/src/gobj/paramTexture.I b/panda/src/gobj/paramTexture.I index 5362bacb35..c25c71ca28 100644 --- a/panda/src/gobj/paramTexture.I +++ b/panda/src/gobj/paramTexture.I @@ -1,24 +1,20 @@ -// Filename: paramTexture.I -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramTexture.I + * @author rdb + * @date 2014-12-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::Constructor -// Access: Published -// Description: Creates a new ParamTextureSampler storing the given -// texture and sampler objects. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ParamTextureSampler storing the given texture and sampler + * objects. + */ INLINE ParamTextureSampler:: ParamTextureSampler(Texture *tex, const SamplerState &sampler) : _texture(tex), @@ -26,43 +22,35 @@ ParamTextureSampler(Texture *tex, const SamplerState &sampler) : { } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::get_value_type -// Access: Published, Virtual -// Description: Returns Texture::get_class_type(), even though it -// technically stores more than just a Texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns Texture::get_class_type(), even though it technically stores more + * than just a Texture. + */ INLINE TypeHandle ParamTextureSampler:: get_value_type() const { return Texture::get_class_type(); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::get_texture -// Access: Published -// Description: Retrieves the texture stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the texture stored in the parameter. + */ INLINE Texture *ParamTextureSampler:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::get_sampler -// Access: Published -// Description: Retrieves the sampler state stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the sampler state stored in the parameter. + */ INLINE const SamplerState &ParamTextureSampler:: get_sampler() const { return _sampler; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::Constructor -// Access: Published -// Description: Creates a new ParamTextureImage storing the given -// texture and image binding parameters. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ParamTextureImage storing the given texture and image binding + * parameters. + */ INLINE ParamTextureImage:: ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) : _texture(tex), @@ -82,76 +70,59 @@ ParamTextureImage(Texture *tex, bool read, bool write, int z, int n) : } } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::get_value_type -// Access: Published, Virtual -// Description: Returns Texture::get_class_type(), even though it -// technically stores more than just a Texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns Texture::get_class_type(), even though it technically stores more + * than just a Texture. + */ INLINE TypeHandle ParamTextureImage:: get_value_type() const { return Texture::get_class_type(); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::get_texture -// Access: Published -// Description: Retrieves the texture stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the texture stored in the parameter. + */ INLINE Texture *ParamTextureImage:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::has_read_access -// Access: Published -// Description: Returns true if this image should be bound with -// read access enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this image should be bound with read access enabled. + */ INLINE bool ParamTextureImage:: has_read_access() const { return (_access & A_read) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::has_write_access -// Access: Published -// Description: Returns true if this image should be bound with -// write access enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this image should be bound with write access enabled. + */ INLINE bool ParamTextureImage:: has_write_access() const { return (_access & A_write) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::get_bind_layered -// Access: Published -// Description: Returns true if all layers of this image should be -// bound simultaneously. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all layers of this image should be bound simultaneously. + */ INLINE bool ParamTextureImage:: get_bind_layered() const { return (_access & A_layered) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::get_bind_level -// Access: Published -// Description: Returns the image level that should be bound. -//////////////////////////////////////////////////////////////////// +/** + * Returns the image level that should be bound. + */ INLINE int ParamTextureImage:: get_bind_level() const { return _bind_level; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::get_bind_layer -// Access: Published -// Description: Returns the image layer that should be bound. This -// is undefined if get_bind_layered() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the image layer that should be bound. This is undefined if + * get_bind_layered() returns false. + */ INLINE int ParamTextureImage:: get_bind_layer() const { return _bind_layer; diff --git a/panda/src/gobj/paramTexture.cxx b/panda/src/gobj/paramTexture.cxx index 828a7a0170..0710f506f2 100644 --- a/panda/src/gobj/paramTexture.cxx +++ b/panda/src/gobj/paramTexture.cxx @@ -1,16 +1,15 @@ -// Filename: paramTexture.cxx -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramTexture.cxx + * @author rdb + * @date 2014-12-11 + */ #include "paramTexture.h" #include "dcast.h" @@ -18,11 +17,9 @@ TypeHandle ParamTextureSampler::_type_handle; TypeHandle ParamTextureImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ParamTextureSampler:: output(ostream &out) const { out << "texture "; @@ -37,23 +34,18 @@ output(ostream &out) const { _sampler.output(out); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ParamValue. + */ void ParamTextureSampler:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ParamTextureSampler:: write_datagram(BamWriter *manager, Datagram &dg) { ParamValueBase::write_datagram(manager, dg); @@ -61,13 +53,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { _sampler.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int ParamTextureSampler:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = ParamValueBase::complete_pointers(p_list, manager); @@ -75,14 +64,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ParamValue is encountered -// in the Bam file. It should create the ParamValue -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ParamValue is encountered in the Bam file. It should create the + * ParamValue and extract its information from the file. + */ TypedWritable *ParamTextureSampler:: make_from_bam(const FactoryParams ¶ms) { ParamTextureSampler *param = new ParamTextureSampler; @@ -95,13 +81,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureSampler::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ParamValue. + */ void ParamTextureSampler:: fillin(DatagramIterator &scan, BamReader *manager) { ParamValueBase::fillin(scan, manager); @@ -109,11 +92,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _sampler.read_datagram(scan, manager); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ParamTextureImage:: output(ostream &out) const { out << "texture "; @@ -143,23 +124,18 @@ output(ostream &out) const { out << ", level " << _bind_level; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ParamValue. + */ void ParamTextureImage:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ParamTextureImage:: write_datagram(BamWriter *manager, Datagram &dg) { ParamValueBase::write_datagram(manager, dg); @@ -169,13 +145,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int32(_bind_layer); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int ParamTextureImage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = ParamValueBase::complete_pointers(p_list, manager); @@ -183,14 +156,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ParamValue is encountered -// in the Bam file. It should create the ParamValue -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ParamValue is encountered in the Bam file. It should create the + * ParamValue and extract its information from the file. + */ TypedWritable *ParamTextureImage:: make_from_bam(const FactoryParams ¶ms) { ParamTextureImage *param = new ParamTextureImage; @@ -203,13 +173,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: ParamTextureImage::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ParamValue. + */ void ParamTextureImage:: fillin(DatagramIterator &scan, BamReader *manager) { ParamValueBase::fillin(scan, manager); diff --git a/panda/src/gobj/paramTexture.h b/panda/src/gobj/paramTexture.h index 4e3ec91e90..d78ceb06b9 100644 --- a/panda/src/gobj/paramTexture.h +++ b/panda/src/gobj/paramTexture.h @@ -1,16 +1,15 @@ -// Filename: paramTexture.h -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramTexture.h + * @author rdb + * @date 2014-12-11 + */ #ifndef PARAMTEXTURE_H #define PARAMTEXTURE_H @@ -20,12 +19,10 @@ #include "samplerState.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : ParamTextureSampler -// Description : A class object for storing a pointer to a Texture -// along with a sampler state that indicates how to -// to sample the given texture. -//////////////////////////////////////////////////////////////////// +/** + * A class object for storing a pointer to a Texture along with a sampler + * state that indicates how to to sample the given texture. + */ class EXPCL_PANDA_GOBJ ParamTextureSampler : public ParamValueBase { protected: INLINE ParamTextureSampler() {}; @@ -74,15 +71,13 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ParamTextureImage -// Description : A class object for storing a pointer to a Texture -// along with a set of properties that indicates which -// image to bind to a shader input. -// -// This class is useful for binding texture images -// to a shader, which is a fairly esoteric feature. -//////////////////////////////////////////////////////////////////// +/** + * A class object for storing a pointer to a Texture along with a set of + * properties that indicates which image to bind to a shader input. + * + * This class is useful for binding texture images to a shader, which is a + * fairly esoteric feature. + */ class EXPCL_PANDA_GOBJ ParamTextureImage : public ParamValueBase { protected: INLINE ParamTextureImage() {}; diff --git a/panda/src/gobj/perspectiveLens.I b/panda/src/gobj/perspectiveLens.I index 8b3c08498f..28e0ed9d1c 100644 --- a/panda/src/gobj/perspectiveLens.I +++ b/panda/src/gobj/perspectiveLens.I @@ -1,53 +1,43 @@ -// Filename: perspectiveLens.I -// Created by: drose (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perspectiveLens.I + * @author drose + * @date 1999-02-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PerspectiveLens:: PerspectiveLens() { } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PerspectiveLens:: PerspectiveLens(PN_stdfloat hfov, PN_stdfloat vfov) { Lens::CDWriter lens_cdata(Lens::_cycler, true); lens_cdata->_fov.set(hfov, vfov); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PerspectiveLens:: PerspectiveLens(const PerspectiveLens ©) : Lens(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PerspectiveLens:: operator = (const PerspectiveLens ©) { Lens::operator = (copy); } - diff --git a/panda/src/gobj/perspectiveLens.cxx b/panda/src/gobj/perspectiveLens.cxx index fcc8868662..0fc83ec15b 100644 --- a/panda/src/gobj/perspectiveLens.cxx +++ b/panda/src/gobj/perspectiveLens.cxx @@ -1,16 +1,15 @@ -// Filename: perspectiveLens.cxx -// Created by: drose (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perspectiveLens.cxx + * @author drose + * @date 1999-02-18 + */ #include "perspectiveLens.h" #include "bamReader.h" @@ -18,60 +17,48 @@ TypeHandle PerspectiveLens::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::make_copy -// Access: Public, Virtual -// Description: Allocates a new Lens just like this one. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new Lens just like this one. + */ PT(Lens) PerspectiveLens:: make_copy() const { return new PerspectiveLens(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::is_linear -// Access: Published, Virtual -// Description: Returns true if the lens represents a linear -// projection (e.g. PerspectiveLens, OrthographicLens), -// and therefore there is a valid matrix returned by -// get_projection_mat(), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a linear projection (e.g. + * PerspectiveLens, OrthographicLens), and therefore there is a valid matrix + * returned by get_projection_mat(), or false otherwise. + */ bool PerspectiveLens:: is_linear() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::is_perspective -// Access: Published, Virtual -// Description: Returns true if the lens represents a perspective -// projection (i.e. it is a PerspectiveLens), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the lens represents a perspective projection (i.e. it is a + * PerspectiveLens), false otherwise. + */ bool PerspectiveLens:: is_perspective() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::do_extrude_depth -// Access: Protected, Virtual -// Description: This is the generic implementation, which is based on -// do_extrude() and assumes a linear distribution of -// depth values between the near and far points. -//////////////////////////////////////////////////////////////////// +/** + * This is the generic implementation, which is based on do_extrude() and + * assumes a linear distribution of depth values between the near and far + * points. + */ bool PerspectiveLens:: do_extrude_depth(const CData *cdata, const LPoint3 &point2d, LPoint3 &point3d) const { return do_extrude_depth_with_mat(cdata, point2d, point3d); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::do_compute_projection_mat -// Access: Protected, Virtual -// Description: Computes the complete transformation matrix from 3-d -// point to 2-d point, if the lens is linear. -//////////////////////////////////////////////////////////////////// +/** + * Computes the complete transformation matrix from 3-d point to 2-d point, if + * the lens is linear. + */ void PerspectiveLens:: do_compute_projection_mat(Lens::CData *lens_cdata) { CoordinateSystem cs = lens_cdata->_cs; @@ -137,8 +124,8 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { lens_cdata->_projection_mat_left = lens_cdata->_projection_mat_right = lens_cdata->_projection_mat; } else { - // Compute the left and right projection matrices in case this - // lens is assigned to a stereo DisplayRegion. + // Compute the left and right projection matrices in case this lens is + // assigned to a stereo DisplayRegion. LVector3 iod = lens_cdata->_interocular_distance * 0.5f * LVector3::left(lens_cdata->_cs); lens_cdata->_projection_mat_left = do_get_lens_mat_inv(lens_cdata) * LMatrix4::translate_mat(-iod) * canonical * do_get_film_mat(lens_cdata); @@ -164,67 +151,52 @@ do_compute_projection_mat(Lens::CData *lens_cdata) { CF_projection_mat); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::fov_to_film -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a focal length, -// compute the correspdonding width (or height) on the -// film. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a focal length, compute the + * correspdonding width (or height) on the film. If horiz is true, this is in + * the horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat PerspectiveLens:: fov_to_film(PN_stdfloat fov, PN_stdfloat focal_length, bool) const { return (ctan(deg_2_rad(fov * 0.5f)) * focal_length) * 2.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::fov_to_focal_length -// Access: Protected, Virtual -// Description: Given a field of view in degrees and a width (or -// height) on the film, compute the focal length of the -// lens. If horiz is true, this is in the horizontal -// direction; otherwise, it is in the vertical direction -// (some lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a field of view in degrees and a width (or height) on the film, + * compute the focal length of the lens. If horiz is true, this is in the + * horizontal direction; otherwise, it is in the vertical direction (some + * lenses behave differently in each direction). + */ PN_stdfloat PerspectiveLens:: fov_to_focal_length(PN_stdfloat fov, PN_stdfloat film_size, bool) const { return film_size * 0.5f / ctan(deg_2_rad(fov * 0.5f)); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::film_to_fov -// Access: Protected, Virtual -// Description: Given a width (or height) on the film and a focal -// length, compute the field of view in degrees. If -// horiz is true, this is in the horizontal direction; -// otherwise, it is in the vertical direction (some -// lenses behave differently in each direction). -//////////////////////////////////////////////////////////////////// +/** + * Given a width (or height) on the film and a focal length, compute the field + * of view in degrees. If horiz is true, this is in the horizontal direction; + * otherwise, it is in the vertical direction (some lenses behave differently + * in each direction). + */ PN_stdfloat PerspectiveLens:: film_to_fov(PN_stdfloat film_size, PN_stdfloat focal_length, bool) const { return rad_2_deg(catan(film_size * 0.5f / focal_length)) * 2.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void PerspectiveLens:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PerspectiveLens::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *PerspectiveLens:: make_from_bam(const FactoryParams ¶ms) { PerspectiveLens *lens = new PerspectiveLens; diff --git a/panda/src/gobj/perspectiveLens.h b/panda/src/gobj/perspectiveLens.h index 8e35c89e74..556b3b2fd0 100644 --- a/panda/src/gobj/perspectiveLens.h +++ b/panda/src/gobj/perspectiveLens.h @@ -1,16 +1,15 @@ -// Filename: perspectiveLens.h -// Created by: drose (18Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perspectiveLens.h + * @author drose + * @date 1999-02-18 + */ #ifndef PERSPECTIVELENS_H #define PERSPECTIVELENS_H @@ -20,10 +19,9 @@ #include "lens.h" -//////////////////////////////////////////////////////////////////// -// Class : PerspectiveLens -// Description : A perspective-type lens: a normal camera. -//////////////////////////////////////////////////////////////////// +/** + * A perspective-type lens: a normal camera. + */ class EXPCL_PANDA_GOBJ PerspectiveLens : public Lens { PUBLISHED: INLINE PerspectiveLens(); diff --git a/panda/src/gobj/preparedGraphicsObjects.I b/panda/src/gobj/preparedGraphicsObjects.I index e137f2f043..a9bd618ab5 100644 --- a/panda/src/gobj/preparedGraphicsObjects.I +++ b/panda/src/gobj/preparedGraphicsObjects.I @@ -1,47 +1,38 @@ -// Filename: preparedGraphicsObjects.I -// Created by: drose (23Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file preparedGraphicsObjects.I + * @author drose + * @date 2004-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_name -// Access: Public -// Description: Returns the name of the PreparedGraphicsObjects -// structure. This is an arbitrary name that serves -// mainly to uniquify the context for PStats reporting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the PreparedGraphicsObjects structure. This is an + * arbitrary name that serves mainly to uniquify the context for PStats + * reporting. + */ INLINE const string &PreparedGraphicsObjects:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_graphics_memory_limit -// Access: Public -// Description: Returns the artificial cap on graphics memory that -// will be imposed on this GSG. See -// set_graphics_memory_limit(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the artificial cap on graphics memory that will be imposed on this + * GSG. See set_graphics_memory_limit(). + */ INLINE size_t PreparedGraphicsObjects:: get_graphics_memory_limit() const { return _graphics_memory_lru.get_max_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all -// Access: Public -// Description: Releases all prepared objects of all kinds at once. -//////////////////////////////////////////////////////////////////// +/** + * Releases all prepared objects of all kinds at once. + */ INLINE void PreparedGraphicsObjects:: release_all() { release_all_textures(); @@ -56,12 +47,10 @@ release_all() { _ibuffer_residency.set_levels(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued -// Access: Public -// Description: Returns the number of objects of any kind that have -// been enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of objects of any kind that have been enqueued to be + * prepared on this GSG. + */ INLINE int PreparedGraphicsObjects:: get_num_queued() const { return (get_num_queued_textures() + @@ -72,12 +61,10 @@ get_num_queued() const { get_num_queued_index_buffers()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared -// Access: Public -// Description: Returns the number of objects of any kind that have -// already been prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of objects of any kind that have already been prepared + * on this GSG. + */ INLINE int PreparedGraphicsObjects:: get_num_prepared() const { return (get_num_prepared_textures() + @@ -88,11 +75,9 @@ get_num_prepared() const { get_num_prepared_index_buffers()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::BufferCacheKey::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PreparedGraphicsObjects::BufferCacheKey:: operator < (const PreparedGraphicsObjects::BufferCacheKey &other) const { if (_data_size_bytes != other._data_size_bytes) { @@ -101,22 +86,18 @@ operator < (const PreparedGraphicsObjects::BufferCacheKey &other) const { return (int)_usage_hint < (int)other._usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::BufferCacheKey::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PreparedGraphicsObjects::BufferCacheKey:: operator == (const PreparedGraphicsObjects::BufferCacheKey &other) const { return (_data_size_bytes == other._data_size_bytes && _usage_hint == other._usage_hint); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::BufferCacheKey::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PreparedGraphicsObjects::BufferCacheKey:: operator != (const PreparedGraphicsObjects::BufferCacheKey &other) const { return !operator == (other); diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 075ee719fd..7b2b5e08a9 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -1,16 +1,15 @@ -// Filename: preparedGraphicsObjects.cxx -// Created by: drose (19Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file preparedGraphicsObjects.cxx + * @author drose + * @date 2004-02-19 + */ #include "preparedGraphicsObjects.h" #include "textureContext.h" @@ -30,11 +29,9 @@ int PreparedGraphicsObjects::_name_index = 0; -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PreparedGraphicsObjects:: PreparedGraphicsObjects() : _lock("PreparedGraphicsObjects::_lock"), @@ -47,25 +44,22 @@ PreparedGraphicsObjects() : _graphics_memory_lru("graphics_memory_lru", graphics_memory_limit), _sampler_object_lru("sampler_object_lru", sampler_object_limit) { - // GLGSG will turn this flag on. This is a temporary hack to - // disable this feature for DX8/DX9 for now, until we work out the - // fine points of updating the fvf properly. + // GLGSG will turn this flag on. This is a temporary hack to disable this + // feature for DX8DX9 for now, until we work out the fine points of updating + // the fvf properly. _support_released_buffer_cache = false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PreparedGraphicsObjects:: ~PreparedGraphicsObjects() { - // There may be objects that are still prepared when we destruct. - // If this is so, then all of the GSG's that own them have already - // destructed, so we can assume their resources were internally - // cleaned up. Besides, we may not even be allowed to call the - // GSG release methods since some APIs (eg. OpenGL) require a - // context current. So we just call the destructors. + // There may be objects that are still prepared when we destruct. If this + // is so, then all of the GSG's that own them have already destructed, so we + // can assume their resources were internally cleaned up. Besides, we may + // not even be allowed to call the GSG release methods since some APIs (eg. + // OpenGL) require a context current. So we just call the destructors. ReMutexHolder holder(_lock); release_all_textures(); @@ -129,21 +123,16 @@ PreparedGraphicsObjects:: _released_index_buffers.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::set_graphics_memory_limit -// Access: Public -// Description: Sets an artificial cap on graphics memory that -// will be imposed on this GSG. -// -// This limits the total amount of graphics memory, -// including texture memory and vertex buffer memory, -// that will be consumed by the GSG, regardless of -// whether the hardware claims to provide more graphics -// memory than this. It is useful to put a ceiling on -// graphics memory consumed, since some drivers seem to -// allow the application to consume more memory than the -// hardware can realistically support. -//////////////////////////////////////////////////////////////////// +/** + * Sets an artificial cap on graphics memory that will be imposed on this GSG. + * + * This limits the total amount of graphics memory, including texture memory + * and vertex buffer memory, that will be consumed by the GSG, regardless of + * whether the hardware claims to provide more graphics memory than this. It + * is useful to put a ceiling on graphics memory consumed, since some drivers + * seem to allow the application to consume more memory than the hardware can + * realistically support. + */ void PreparedGraphicsObjects:: set_graphics_memory_limit(size_t limit) { if (limit != _graphics_memory_lru.get_max_size()) { @@ -155,25 +144,19 @@ set_graphics_memory_limit(size_t limit) { } } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::show_graphics_memory_lru -// Access: Public -// Description: Writes to the indicated ostream a report of how the -// various textures and vertex buffers are allocated in -// the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a report of how the various textures and + * vertex buffers are allocated in the LRU. + */ void PreparedGraphicsObjects:: show_graphics_memory_lru(ostream &out) const { _graphics_memory_lru.write(out, 0); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::show_residency_trackers -// Access: Public -// Description: Writes to the indicated ostream a report of how the -// various textures and vertex buffers are allocated in -// the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream a report of how the various textures and + * vertex buffers are allocated in the LRU. + */ void PreparedGraphicsObjects:: show_residency_trackers(ostream &out) const { out << "Textures:\n"; @@ -186,13 +169,10 @@ show_residency_trackers(ostream &out) const { _ibuffer_residency.write(out, 2); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_texture -// Access: Public -// Description: Indicates that a texture would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a texture would like to be put on the list to be prepared + * when the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_texture(Texture *tex) { ReMutexHolder holder(_lock); @@ -200,12 +180,9 @@ enqueue_texture(Texture *tex) { _enqueued_textures.insert(tex); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_texture_queued -// Access: Public -// Description: Returns true if the texture has been queued on this -// GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has been queued on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_texture_queued(const Texture *tex) const { ReMutexHolder holder(_lock); @@ -214,20 +191,15 @@ is_texture_queued(const Texture *tex) const { return (qi != _enqueued_textures.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_texture -// Access: Public -// Description: Removes a texture from the queued list of textures to -// be prepared. Normally it is not necessary to call -// this, unless you change your mind about preparing it -// at the last minute, since the texture will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the texture is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a texture from the queued list of textures to be prepared. + * Normally it is not necessary to call this, unless you change your mind + * about preparing it at the last minute, since the texture will automatically + * be dequeued and prepared at the next frame. + * + * The return value is true if the texture is successfully dequeued, false if + * it had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_texture(Texture *tex) { ReMutexHolder holder(_lock); @@ -240,39 +212,31 @@ dequeue_texture(Texture *tex) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_texture_prepared -// Access: Public -// Description: Returns true if the texture has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has been prepared on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_texture_prepared(const Texture *tex) const { return tex->is_prepared((PreparedGraphicsObjects *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_texture -// Access: Public -// Description: Indicates that a texture context, created by a -// previous call to prepare_texture(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release textures--this -// prevents conflicts from threading or multiple GSG's -// sharing textures (we have no way of knowing which -// graphics context is currently active, or what state -// it's in, at the time release_texture is called). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a texture context, created by a previous call to + * prepare_texture(), is no longer needed. The driver resources will not be + * freed until some GSG calls update(), indicating it is at a stage where it + * is ready to release textures--this prevents conflicts from threading or + * multiple GSG's sharing textures (we have no way of knowing which graphics + * context is currently active, or what state it's in, at the time + * release_texture is called). + */ void PreparedGraphicsObjects:: release_texture(TextureContext *tc) { ReMutexHolder holder(_lock); tc->_texture->clear_prepared(tc->get_view(), this); - // We have to set the Texture pointer to NULL at this point, since - // the Texture itself might destruct at any time after it has been - // released. + // We have to set the Texture pointer to NULL at this point, since the + // Texture itself might destruct at any time after it has been released. tc->_texture = (Texture *)NULL; bool removed = (_prepared_textures.erase(tc) != 0); @@ -281,25 +245,20 @@ release_texture(TextureContext *tc) { _released_textures.insert(tc); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_texture -// Access: Public -// Description: Releases a texture if it has already been prepared, -// or removes it from the preparation queue. -//////////////////////////////////////////////////////////////////// +/** + * Releases a texture if it has already been prepared, or removes it from the + * preparation queue. + */ void PreparedGraphicsObjects:: release_texture(Texture *tex) { tex->release(this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_textures -// Access: Public -// Description: Releases all textures at once. This will force them -// to be reloaded into texture memory for all GSG's that -// share this object. Returns the number of textures -// released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all textures at once. This will force them to be reloaded into + * texture memory for all GSG's that share this object. Returns the number of + * textures released. + */ int PreparedGraphicsObjects:: release_all_textures() { ReMutexHolder holder(_lock); @@ -323,58 +282,46 @@ release_all_textures() { return num_textures; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_textures -// Access: Public -// Description: Returns the number of textures that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of textures that have been enqueued to be prepared on + * this GSG. + */ int PreparedGraphicsObjects:: get_num_queued_textures() const { return _enqueued_textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_textures -// Access: Public -// Description: Returns the number of textures that have already been -// prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of textures that have already been prepared on this GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_textures() const { return _prepared_textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_texture_now -// Access: Public -// Description: Immediately creates a new TextureContext for the -// indicated texture and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// textures. If this is not necessarily the case, you -// should use enqueue_texture() instead. -// -// Normally, this function is not called directly. Call -// Texture::prepare_now() instead. -// -// The TextureContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular texture, and will exist as long as the -// texture is ready to be rendered. -// -// When either the Texture or the -// PreparedGraphicsObjects object destructs, the -// TextureContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new TextureContext for the indicated texture and + * returns it. This assumes that the GraphicsStateGuardian is the currently + * active rendering context and that it is ready to accept new textures. If + * this is not necessarily the case, you should use enqueue_texture() instead. + * + * Normally, this function is not called directly. Call + * Texture::prepare_now() instead. + * + * The TextureContext contains all of the pertinent information needed by the + * GSG to keep track of this one particular texture, and will exist as long as + * the texture is ready to be rendered. + * + * When either the Texture or the PreparedGraphicsObjects object destructs, + * the TextureContext will be deleted. + */ TextureContext *PreparedGraphicsObjects:: prepare_texture_now(Texture *tex, int view, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); - // Ask the GSG to create a brand new TextureContext. There might - // be several GSG's sharing the same set of textures; if so, it - // doesn't matter which of them creates the context (since they're - // all shared anyway). + // Ask the GSG to create a brand new TextureContext. There might be several + // GSG's sharing the same set of textures; if so, it doesn't matter which of + // them creates the context (since they're all shared anyway). TextureContext *tc = gsg->prepare_texture(tex, view); if (tc != (TextureContext *)NULL) { @@ -385,13 +332,10 @@ prepare_texture_now(Texture *tex, int view, GraphicsStateGuardianBase *gsg) { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_sampler -// Access: Public -// Description: Indicates that a sampler would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a sampler would like to be put on the list to be prepared + * when the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_sampler(const SamplerState &sampler) { ReMutexHolder holder(_lock); @@ -399,12 +343,9 @@ enqueue_sampler(const SamplerState &sampler) { _enqueued_samplers.insert(sampler); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_sampler_queued -// Access: Public -// Description: Returns true if the sampler has been queued on this -// GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the sampler has been queued on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_sampler_queued(const SamplerState &sampler) const { ReMutexHolder holder(_lock); @@ -413,20 +354,15 @@ is_sampler_queued(const SamplerState &sampler) const { return (qi != _enqueued_samplers.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_sampler -// Access: Public -// Description: Removes a sampler from the queued list of samplers to -// be prepared. Normally it is not necessary to call -// this, unless you change your mind about preparing it -// at the last minute, since the sampler will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the sampler is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a sampler from the queued list of samplers to be prepared. + * Normally it is not necessary to call this, unless you change your mind + * about preparing it at the last minute, since the sampler will automatically + * be dequeued and prepared at the next frame. + * + * The return value is true if the sampler is successfully dequeued, false if + * it had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_sampler(const SamplerState &sampler) { ReMutexHolder holder(_lock); @@ -439,12 +375,9 @@ dequeue_sampler(const SamplerState &sampler) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_sampler_prepared -// Access: Public -// Description: Returns true if the sampler has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the sampler has been prepared on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_sampler_prepared(const SamplerState &sampler) const { ReMutexHolder holder(_lock); @@ -453,15 +386,12 @@ is_sampler_prepared(const SamplerState &sampler) const { return (it != _prepared_samplers.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_sampler -// Access: Public -// Description: Indicates that a sampler context, created by a -// previous call to prepare_sampler(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release samplers. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a sampler context, created by a previous call to + * prepare_sampler(), is no longer needed. The driver resources will not be + * freed until some GSG calls update(), indicating it is at a stage where it + * is ready to release samplers. + */ void PreparedGraphicsObjects:: release_sampler(SamplerContext *sc) { ReMutexHolder holder(_lock); @@ -469,12 +399,10 @@ release_sampler(SamplerContext *sc) { _released_samplers.insert(sc); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_sampler -// Access: Public -// Description: Releases a sampler if it has already been prepared, -// or removes it from the preparation queue. -//////////////////////////////////////////////////////////////////// +/** + * Releases a sampler if it has already been prepared, or removes it from the + * preparation queue. + */ void PreparedGraphicsObjects:: release_sampler(const SamplerState &sampler) { ReMutexHolder holder(_lock); @@ -488,13 +416,10 @@ release_sampler(const SamplerState &sampler) { _enqueued_samplers.erase(sampler); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_samplers -// Access: Public -// Description: Releases all samplers at once. This will force them -// to be reloaded for all GSG's that share this object. -// Returns the number of samplers released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all samplers at once. This will force them to be reloaded for all + * GSG's that share this object. Returns the number of samplers released. + */ int PreparedGraphicsObjects:: release_all_samplers() { ReMutexHolder holder(_lock); @@ -514,50 +439,39 @@ release_all_samplers() { return num_samplers; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_samplers -// Access: Public -// Description: Returns the number of samplers that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of samplers that have been enqueued to be prepared on + * this GSG. + */ int PreparedGraphicsObjects:: get_num_queued_samplers() const { return _enqueued_samplers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_samplers -// Access: Public -// Description: Returns the number of samplers that have already been -// prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of samplers that have already been prepared on this GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_samplers() const { return _prepared_samplers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_sampler_now -// Access: Public -// Description: Immediately creates a new SamplerContext for the -// indicated sampler and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// samplers. If this is not necessarily the case, you -// should use enqueue_sampler() instead. -// -// Normally, this function is not called directly. -// Call Sampler::prepare_now() instead. -// -// The SamplerContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular sampler, and will exist as long as the -// sampler is ready to be rendered. -// -// When either the Sampler or the -// PreparedGraphicsObjects object destructs, the -// SamplerContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new SamplerContext for the indicated sampler and + * returns it. This assumes that the GraphicsStateGuardian is the currently + * active rendering context and that it is ready to accept new samplers. If + * this is not necessarily the case, you should use enqueue_sampler() instead. + * + * Normally, this function is not called directly. Call + * Sampler::prepare_now() instead. + * + * The SamplerContext contains all of the pertinent information needed by the + * GSG to keep track of this one particular sampler, and will exist as long as + * the sampler is ready to be rendered. + * + * When either the Sampler or the PreparedGraphicsObjects object destructs, + * the SamplerContext will be deleted. + */ SamplerContext *PreparedGraphicsObjects:: prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); @@ -577,13 +491,10 @@ prepare_sampler_now(const SamplerState &sampler, GraphicsStateGuardianBase *gsg) return sc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_geom -// Access: Public -// Description: Indicates that a geom would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a geom would like to be put on the list to be prepared when + * the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_geom(Geom *geom) { ReMutexHolder holder(_lock); @@ -591,12 +502,9 @@ enqueue_geom(Geom *geom) { _enqueued_geoms.insert(geom); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_geom_queued -// Access: Public -// Description: Returns true if the geom has been queued on this -// GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the geom has been queued on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_geom_queued(const Geom *geom) const { ReMutexHolder holder(_lock); @@ -605,20 +513,15 @@ is_geom_queued(const Geom *geom) const { return (qi != _enqueued_geoms.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_geom -// Access: Public -// Description: Removes a geom from the queued list of geoms to -// be prepared. Normally it is not necessary to call -// this, unless you change your mind about preparing it -// at the last minute, since the geom will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the geom is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a geom from the queued list of geoms to be prepared. Normally it + * is not necessary to call this, unless you change your mind about preparing + * it at the last minute, since the geom will automatically be dequeued and + * prepared at the next frame. + * + * The return value is true if the geom is successfully dequeued, false if it + * had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_geom(Geom *geom) { ReMutexHolder holder(_lock); @@ -631,39 +534,32 @@ dequeue_geom(Geom *geom) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_geom_prepared -// Access: Public -// Description: Returns true if the vertex buffer has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex buffer has been prepared on this GSG, false + * otherwise. + */ bool PreparedGraphicsObjects:: is_geom_prepared(const Geom *geom) const { return geom->is_prepared((PreparedGraphicsObjects *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_geom -// Access: Public -// Description: Indicates that a geom context, created by a -// previous call to prepare_geom(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release geoms--this -// prevents conflicts from threading or multiple GSG's -// sharing geoms (we have no way of knowing which -// graphics context is currently active, or what state -// it's in, at the time release_geom is called). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a geom context, created by a previous call to + * prepare_geom(), is no longer needed. The driver resources will not be + * freed until some GSG calls update(), indicating it is at a stage where it + * is ready to release geoms--this prevents conflicts from threading or + * multiple GSG's sharing geoms (we have no way of knowing which graphics + * context is currently active, or what state it's in, at the time + * release_geom is called). + */ void PreparedGraphicsObjects:: release_geom(GeomContext *gc) { ReMutexHolder holder(_lock); gc->_geom->clear_prepared(this); - // We have to set the Geom pointer to NULL at this point, since - // the Geom itself might destruct at any time after it has been - // released. + // We have to set the Geom pointer to NULL at this point, since the Geom + // itself might destruct at any time after it has been released. gc->_geom = (Geom *)NULL; bool removed = (_prepared_geoms.erase(gc) != 0); @@ -672,14 +568,11 @@ release_geom(GeomContext *gc) { _released_geoms.insert(gc); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_geoms -// Access: Public -// Description: Releases all geoms at once. This will force them -// to be reloaded into geom memory for all GSG's that -// share this object. Returns the number of geoms -// released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all geoms at once. This will force them to be reloaded into geom + * memory for all GSG's that share this object. Returns the number of geoms + * released. + */ int PreparedGraphicsObjects:: release_all_geoms() { ReMutexHolder holder(_lock); @@ -703,58 +596,46 @@ release_all_geoms() { return num_geoms; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_geoms -// Access: Public -// Description: Returns the number of geoms that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of geoms that have been enqueued to be prepared on this + * GSG. + */ int PreparedGraphicsObjects:: get_num_queued_geoms() const { return _enqueued_geoms.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_geoms -// Access: Public -// Description: Returns the number of geoms that have already been -// prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of geoms that have already been prepared on this GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_geoms() const { return _prepared_geoms.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_geom_now -// Access: Public -// Description: Immediately creates a new GeomContext for the -// indicated geom and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// geoms. If this is not necessarily the case, you -// should use enqueue_geom() instead. -// -// Normally, this function is not called directly. Call -// Geom::prepare_now() instead. -// -// The GeomContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular geom, and will exist as long as the -// geom is ready to be rendered. -// -// When either the Geom or the -// PreparedGraphicsObjects object destructs, the -// GeomContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new GeomContext for the indicated geom and returns + * it. This assumes that the GraphicsStateGuardian is the currently active + * rendering context and that it is ready to accept new geoms. If this is not + * necessarily the case, you should use enqueue_geom() instead. + * + * Normally, this function is not called directly. Call Geom::prepare_now() + * instead. + * + * The GeomContext contains all of the pertinent information needed by the GSG + * to keep track of this one particular geom, and will exist as long as the + * geom is ready to be rendered. + * + * When either the Geom or the PreparedGraphicsObjects object destructs, the + * GeomContext will be deleted. + */ GeomContext *PreparedGraphicsObjects:: prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); - // Ask the GSG to create a brand new GeomContext. There might - // be several GSG's sharing the same set of geoms; if so, it - // doesn't matter which of them creates the context (since they're - // all shared anyway). + // Ask the GSG to create a brand new GeomContext. There might be several + // GSG's sharing the same set of geoms; if so, it doesn't matter which of + // them creates the context (since they're all shared anyway). GeomContext *gc = gsg->prepare_geom(geom); if (gc != (GeomContext *)NULL) { @@ -765,13 +646,10 @@ prepare_geom_now(Geom *geom, GraphicsStateGuardianBase *gsg) { return gc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_shader -// Access: Public -// Description: Indicates that a shader would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a shader would like to be put on the list to be prepared + * when the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_shader(Shader *se) { ReMutexHolder holder(_lock); @@ -779,12 +657,9 @@ enqueue_shader(Shader *se) { _enqueued_shaders.insert(se); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_shader_queued -// Access: Public -// Description: Returns true if the shader has been queued on this -// GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader has been queued on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_shader_queued(const Shader *shader) const { ReMutexHolder holder(_lock); @@ -793,20 +668,15 @@ is_shader_queued(const Shader *shader) const { return (qi != _enqueued_shaders.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_shader -// Access: Public -// Description: Removes a shader from the queued list of shaders to -// be prepared. Normally it is not necessary to call -// this, unless you change your mind about preparing it -// at the last minute, since the shader will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the shader is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a shader from the queued list of shaders to be prepared. Normally + * it is not necessary to call this, unless you change your mind about + * preparing it at the last minute, since the shader will automatically be + * dequeued and prepared at the next frame. + * + * The return value is true if the shader is successfully dequeued, false if + * it had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_shader(Shader *se) { ReMutexHolder holder(_lock); @@ -819,39 +689,31 @@ dequeue_shader(Shader *se) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_shader_prepared -// Access: Public -// Description: Returns true if the shader has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader has been prepared on this GSG, false otherwise. + */ bool PreparedGraphicsObjects:: is_shader_prepared(const Shader *shader) const { return shader->is_prepared((PreparedGraphicsObjects *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_shader -// Access: Public -// Description: Indicates that a shader context, created by a -// previous call to prepare_shader(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release shaders--this -// prevents conflicts from threading or multiple GSG's -// sharing shaders (we have no way of knowing which -// graphics context is currently active, or what state -// it's in, at the time release_shader is called). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a shader context, created by a previous call to + * prepare_shader(), is no longer needed. The driver resources will not be + * freed until some GSG calls update(), indicating it is at a stage where it + * is ready to release shaders--this prevents conflicts from threading or + * multiple GSG's sharing shaders (we have no way of knowing which graphics + * context is currently active, or what state it's in, at the time + * release_shader is called). + */ void PreparedGraphicsObjects:: release_shader(ShaderContext *sc) { ReMutexHolder holder(_lock); sc->_shader->clear_prepared(this); - // We have to set the Shader pointer to NULL at this point, since - // the Shader itself might destruct at any time after it has been - // released. + // We have to set the Shader pointer to NULL at this point, since the Shader + // itself might destruct at any time after it has been released. sc->_shader = (Shader *)NULL; bool removed = (_prepared_shaders.erase(sc) != 0); @@ -860,14 +722,11 @@ release_shader(ShaderContext *sc) { _released_shaders.insert(sc); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_shaders -// Access: Public -// Description: Releases all shaders at once. This will force them -// to be reloaded into shader memory for all GSG's that -// share this object. Returns the number of shaders -// released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all shaders at once. This will force them to be reloaded into + * shader memory for all GSG's that share this object. Returns the number of + * shaders released. + */ int PreparedGraphicsObjects:: release_all_shaders() { ReMutexHolder holder(_lock); @@ -891,58 +750,46 @@ release_all_shaders() { return num_shaders; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_shaders -// Access: Public -// Description: Returns the number of shaders that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of shaders that have been enqueued to be prepared on + * this GSG. + */ int PreparedGraphicsObjects:: get_num_queued_shaders() const { return _enqueued_shaders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_shaders -// Access: Public -// Description: Returns the number of shaders that have already been -// prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of shaders that have already been prepared on this GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_shaders() const { return _prepared_shaders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_shader_now -// Access: Public -// Description: Immediately creates a new ShaderContext for the -// indicated shader and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// shaders. If this is not necessarily the case, you -// should use enqueue_shader() instead. -// -// Normally, this function is not called directly. Call -// Shader::prepare_now() instead. -// -// The ShaderContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular shader, and will exist as long as the -// shader is ready to be rendered. -// -// When either the Shader or the -// PreparedGraphicsObjects object destructs, the -// ShaderContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new ShaderContext for the indicated shader and + * returns it. This assumes that the GraphicsStateGuardian is the currently + * active rendering context and that it is ready to accept new shaders. If + * this is not necessarily the case, you should use enqueue_shader() instead. + * + * Normally, this function is not called directly. Call Shader::prepare_now() + * instead. + * + * The ShaderContext contains all of the pertinent information needed by the + * GSG to keep track of this one particular shader, and will exist as long as + * the shader is ready to be rendered. + * + * When either the Shader or the PreparedGraphicsObjects object destructs, the + * ShaderContext will be deleted. + */ ShaderContext *PreparedGraphicsObjects:: prepare_shader_now(Shader *se, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); - // Ask the GSG to create a brand new ShaderContext. There might - // be several GSG's sharing the same set of shaders; if so, it - // doesn't matter which of them creates the context (since they're - // all shared anyway). + // Ask the GSG to create a brand new ShaderContext. There might be several + // GSG's sharing the same set of shaders; if so, it doesn't matter which of + // them creates the context (since they're all shared anyway). ShaderContext *sc = gsg->prepare_shader(se); if (sc != (ShaderContext *)NULL) { @@ -953,13 +800,10 @@ prepare_shader_now(Shader *se, GraphicsStateGuardianBase *gsg) { return sc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_vertex_buffer -// Access: Public -// Description: Indicates that a buffer would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a buffer would like to be put on the list to be prepared + * when the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_vertex_buffer(GeomVertexArrayData *data) { ReMutexHolder holder(_lock); @@ -967,12 +811,10 @@ enqueue_vertex_buffer(GeomVertexArrayData *data) { _enqueued_vertex_buffers.insert(data); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_vertex_buffer_queued -// Access: Public -// Description: Returns true if the vertex buffer has been queued on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex buffer has been queued on this GSG, false + * otherwise. + */ bool PreparedGraphicsObjects:: is_vertex_buffer_queued(const GeomVertexArrayData *data) const { ReMutexHolder holder(_lock); @@ -981,20 +823,15 @@ is_vertex_buffer_queued(const GeomVertexArrayData *data) const { return (qi != _enqueued_vertex_buffers.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_vertex_buffer -// Access: Public -// Description: Removes a buffer from the queued list of data -// arrays to be prepared. Normally it is not necessary -// to call this, unless you change your mind about -// preparing it at the last minute, since the data will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the buffer is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a buffer from the queued list of data arrays to be prepared. + * Normally it is not necessary to call this, unless you change your mind + * about preparing it at the last minute, since the data will automatically be + * dequeued and prepared at the next frame. + * + * The return value is true if the buffer is successfully dequeued, false if + * it had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_vertex_buffer(GeomVertexArrayData *data) { ReMutexHolder holder(_lock); @@ -1007,30 +844,24 @@ dequeue_vertex_buffer(GeomVertexArrayData *data) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_vertex_buffer_prepared -// Access: Public -// Description: Returns true if the vertex buffer has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex buffer has been prepared on this GSG, false + * otherwise. + */ bool PreparedGraphicsObjects:: is_vertex_buffer_prepared(const GeomVertexArrayData *data) const { return data->is_prepared((PreparedGraphicsObjects *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_vertex_buffer -// Access: Public -// Description: Indicates that a data context, created by a -// previous call to prepare_vertex_buffer(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release datas--this -// prevents conflicts from threading or multiple GSG's -// sharing datas (we have no way of knowing which -// graphics context is currently active, or what state -// it's in, at the time release_vertex_buffer is called). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a data context, created by a previous call to + * prepare_vertex_buffer(), is no longer needed. The driver resources will + * not be freed until some GSG calls update(), indicating it is at a stage + * where it is ready to release datas--this prevents conflicts from threading + * or multiple GSG's sharing datas (we have no way of knowing which graphics + * context is currently active, or what state it's in, at the time + * release_vertex_buffer is called). + */ void PreparedGraphicsObjects:: release_vertex_buffer(VertexBufferContext *vbc) { ReMutexHolder holder(_lock); @@ -1040,9 +871,8 @@ release_vertex_buffer(VertexBufferContext *vbc) { size_t data_size_bytes = vbc->_data->get_data_size_bytes(); GeomEnums::UsageHint usage_hint = vbc->_data->get_usage_hint(); - // We have to set the Data pointer to NULL at this point, since - // the Data itself might destruct at any time after it has been - // released. + // We have to set the Data pointer to NULL at this point, since the Data + // itself might destruct at any time after it has been released. vbc->_data = (GeomVertexArrayData *)NULL; bool removed = (_prepared_vertex_buffers.erase(vbc) != 0); @@ -1059,14 +889,11 @@ release_vertex_buffer(VertexBufferContext *vbc) { } } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_vertex_buffers -// Access: Public -// Description: Releases all datas at once. This will force them -// to be reloaded into data memory for all GSG's that -// share this object. Returns the number of datas -// released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all datas at once. This will force them to be reloaded into data + * memory for all GSG's that share this object. Returns the number of datas + * released. + */ int PreparedGraphicsObjects:: release_all_vertex_buffers() { ReMutexHolder holder(_lock); @@ -1107,56 +934,46 @@ release_all_vertex_buffers() { return num_vertex_buffers; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_vertex_buffers -// Access: Public -// Description: Returns the number of vertex buffers that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertex buffers that have been enqueued to be prepared + * on this GSG. + */ int PreparedGraphicsObjects:: get_num_queued_vertex_buffers() const { return _enqueued_vertex_buffers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_vertex_buffers -// Access: Public -// Description: Returns the number of vertex buffers that have -// already been prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertex buffers that have already been prepared on + * this GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_vertex_buffers() const { return _prepared_vertex_buffers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_vertex_buffer_now -// Access: Public -// Description: Immediately creates a new VertexBufferContext for the -// indicated data and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// datas. If this is not necessarily the case, you -// should use enqueue_vertex_buffer() instead. -// -// Normally, this function is not called directly. Call -// Data::prepare_now() instead. -// -// The VertexBufferContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular data, and will exist as long as the -// data is ready to be rendered. -// -// When either the Data or the -// PreparedGraphicsObjects object destructs, the -// VertexBufferContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new VertexBufferContext for the indicated data and + * returns it. This assumes that the GraphicsStateGuardian is the currently + * active rendering context and that it is ready to accept new datas. If this + * is not necessarily the case, you should use enqueue_vertex_buffer() + * instead. + * + * Normally, this function is not called directly. Call Data::prepare_now() + * instead. + * + * The VertexBufferContext contains all of the pertinent information needed by + * the GSG to keep track of this one particular data, and will exist as long + * as the data is ready to be rendered. + * + * When either the Data or the PreparedGraphicsObjects object destructs, the + * VertexBufferContext will be deleted. + */ VertexBufferContext *PreparedGraphicsObjects:: prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); - // First, see if there might be a cached context of the appropriate - // size. + // First, see if there might be a cached context of the appropriate size. size_t data_size_bytes = data->get_data_size_bytes(); GeomEnums::UsageHint usage_hint = data->get_usage_hint(); VertexBufferContext *vbc = (VertexBufferContext *) @@ -1167,10 +984,9 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * vbc->_data = data; } else { - // Ask the GSG to create a brand new VertexBufferContext. There - // might be several GSG's sharing the same set of datas; if so, it - // doesn't matter which of them creates the context (since they're - // all shared anyway). + // Ask the GSG to create a brand new VertexBufferContext. There might be + // several GSG's sharing the same set of datas; if so, it doesn't matter + // which of them creates the context (since they're all shared anyway). vbc = gsg->prepare_vertex_buffer(data); } @@ -1182,13 +998,10 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * return vbc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::enqueue_index_buffer -// Access: Public -// Description: Indicates that a buffer would like to be put on the -// list to be prepared when the GSG is next ready to -// do this (presumably at the next frame). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a buffer would like to be put on the list to be prepared + * when the GSG is next ready to do this (presumably at the next frame). + */ void PreparedGraphicsObjects:: enqueue_index_buffer(GeomPrimitive *data) { ReMutexHolder holder(_lock); @@ -1196,12 +1009,10 @@ enqueue_index_buffer(GeomPrimitive *data) { _enqueued_index_buffers.insert(data); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_index_buffer_queued -// Access: Public -// Description: Returns true if the index buffer has been queued on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the index buffer has been queued on this GSG, false + * otherwise. + */ bool PreparedGraphicsObjects:: is_index_buffer_queued(const GeomPrimitive *data) const { ReMutexHolder holder(_lock); @@ -1210,20 +1021,15 @@ is_index_buffer_queued(const GeomPrimitive *data) const { return (qi != _enqueued_index_buffers.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::dequeue_index_buffer -// Access: Public -// Description: Removes a buffer from the queued list of data -// arrays to be prepared. Normally it is not necessary -// to call this, unless you change your mind about -// preparing it at the last minute, since the data will -// automatically be dequeued and prepared at the next -// frame. -// -// The return value is true if the buffer is -// successfully dequeued, false if it had not been -// queued. -//////////////////////////////////////////////////////////////////// +/** + * Removes a buffer from the queued list of data arrays to be prepared. + * Normally it is not necessary to call this, unless you change your mind + * about preparing it at the last minute, since the data will automatically be + * dequeued and prepared at the next frame. + * + * The return value is true if the buffer is successfully dequeued, false if + * it had not been queued. + */ bool PreparedGraphicsObjects:: dequeue_index_buffer(GeomPrimitive *data) { ReMutexHolder holder(_lock); @@ -1236,30 +1042,24 @@ dequeue_index_buffer(GeomPrimitive *data) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::is_index_buffer_prepared -// Access: Public -// Description: Returns true if the index buffer has been prepared on -// this GSG, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the index buffer has been prepared on this GSG, false + * otherwise. + */ bool PreparedGraphicsObjects:: is_index_buffer_prepared(const GeomPrimitive *data) const { return data->is_prepared((PreparedGraphicsObjects *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_index_buffer -// Access: Public -// Description: Indicates that a data context, created by a -// previous call to prepare_index_buffer(), is no longer -// needed. The driver resources will not be freed until -// some GSG calls update(), indicating it is at a -// stage where it is ready to release datas--this -// prevents conflicts from threading or multiple GSG's -// sharing datas (we have no way of knowing which -// graphics context is currently active, or what state -// it's in, at the time release_index_buffer is called). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that a data context, created by a previous call to + * prepare_index_buffer(), is no longer needed. The driver resources will not + * be freed until some GSG calls update(), indicating it is at a stage where + * it is ready to release datas--this prevents conflicts from threading or + * multiple GSG's sharing datas (we have no way of knowing which graphics + * context is currently active, or what state it's in, at the time + * release_index_buffer is called). + */ void PreparedGraphicsObjects:: release_index_buffer(IndexBufferContext *ibc) { ReMutexHolder holder(_lock); @@ -1269,9 +1069,8 @@ release_index_buffer(IndexBufferContext *ibc) { size_t data_size_bytes = ibc->_data->get_data_size_bytes(); GeomEnums::UsageHint usage_hint = ibc->_data->get_usage_hint(); - // We have to set the Data pointer to NULL at this point, since - // the Data itself might destruct at any time after it has been - // released. + // We have to set the Data pointer to NULL at this point, since the Data + // itself might destruct at any time after it has been released. ibc->_data = (GeomPrimitive *)NULL; bool removed = (_prepared_index_buffers.erase(ibc) != 0); @@ -1288,14 +1087,11 @@ release_index_buffer(IndexBufferContext *ibc) { } } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::release_all_index_buffers -// Access: Public -// Description: Releases all datas at once. This will force them -// to be reloaded into data memory for all GSG's that -// share this object. Returns the number of datas -// released. -//////////////////////////////////////////////////////////////////// +/** + * Releases all datas at once. This will force them to be reloaded into data + * memory for all GSG's that share this object. Returns the number of datas + * released. + */ int PreparedGraphicsObjects:: release_all_index_buffers() { ReMutexHolder holder(_lock); @@ -1336,56 +1132,45 @@ release_all_index_buffers() { return num_index_buffers; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_queued_index_buffers -// Access: Public -// Description: Returns the number of index buffers that have been -// enqueued to be prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of index buffers that have been enqueued to be prepared + * on this GSG. + */ int PreparedGraphicsObjects:: get_num_queued_index_buffers() const { return _enqueued_index_buffers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_num_prepared_index_buffers -// Access: Public -// Description: Returns the number of index buffers that have -// already been prepared on this GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of index buffers that have already been prepared on this + * GSG. + */ int PreparedGraphicsObjects:: get_num_prepared_index_buffers() const { return _prepared_index_buffers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::prepare_index_buffer_now -// Access: Public -// Description: Immediately creates a new IndexBufferContext for the -// indicated data and returns it. This assumes that -// the GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// datas. If this is not necessarily the case, you -// should use enqueue_index_buffer() instead. -// -// Normally, this function is not called directly. Call -// Data::prepare_now() instead. -// -// The IndexBufferContext contains all of the pertinent -// information needed by the GSG to keep track of this -// one particular data, and will exist as long as the -// data is ready to be rendered. -// -// When either the Data or the -// PreparedGraphicsObjects object destructs, the -// IndexBufferContext will be deleted. -//////////////////////////////////////////////////////////////////// +/** + * Immediately creates a new IndexBufferContext for the indicated data and + * returns it. This assumes that the GraphicsStateGuardian is the currently + * active rendering context and that it is ready to accept new datas. If this + * is not necessarily the case, you should use enqueue_index_buffer() instead. + * + * Normally, this function is not called directly. Call Data::prepare_now() + * instead. + * + * The IndexBufferContext contains all of the pertinent information needed by + * the GSG to keep track of this one particular data, and will exist as long + * as the data is ready to be rendered. + * + * When either the Data or the PreparedGraphicsObjects object destructs, the + * IndexBufferContext will be deleted. + */ IndexBufferContext *PreparedGraphicsObjects:: prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { ReMutexHolder holder(_lock); - // First, see if there might be a cached context of the appropriate - // size. + // First, see if there might be a cached context of the appropriate size. size_t data_size_bytes = data->get_data_size_bytes(); GeomEnums::UsageHint usage_hint = data->get_usage_hint(); IndexBufferContext *ibc = (IndexBufferContext *) @@ -1396,10 +1181,9 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { ibc->_data = data; } else { - // Ask the GSG to create a brand new IndexBufferContext. There - // might be several GSG's sharing the same set of datas; if so, it - // doesn't matter which of them creates the context (since they're - // all shared anyway). + // Ask the GSG to create a brand new IndexBufferContext. There might be + // several GSG's sharing the same set of datas; if so, it doesn't matter + // which of them creates the context (since they're all shared anyway). ibc = gsg->prepare_index_buffer(data); } @@ -1411,24 +1195,19 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { return ibc; } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::begin_frame -// Access: Public -// Description: This is called by the GraphicsStateGuardian to -// indicate that it is about to begin processing of the -// frame. -// -// Any texture contexts that were previously passed to -// release_texture() are actually passed to the GSG to -// be freed at this point; textures that were previously -// passed to prepare_texture are actually loaded. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsStateGuardian to indicate that it is about to + * begin processing of the frame. + * + * Any texture contexts that were previously passed to release_texture() are + * actually passed to the GSG to be freed at this point; textures that were + * previously passed to prepare_texture are actually loaded. + */ void PreparedGraphicsObjects:: begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { ReMutexHolder holder(_lock, current_thread); - // First, release all the textures, geoms, and buffers awaiting - // release. + // First, release all the textures, geoms, and buffers awaiting release. if (!_released_textures.empty()) { Textures::iterator tci; for (tci = _released_textures.begin(); @@ -1498,8 +1277,7 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { _vbuffer_residency.begin_frame(current_thread); _ibuffer_residency.begin_frame(current_thread); - // Now prepare all the textures, geoms, and buffers awaiting - // preparation. + // Now prepare all the textures, geoms, and buffers awaiting preparation. EnqueuedTextures::iterator qti; for (qti = _enqueued_textures.begin(); qti != _enqueued_textures.end(); @@ -1560,8 +1338,8 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { qibi != _enqueued_index_buffers.end(); ++qibi) { GeomPrimitive *data = (*qibi); - // We need this check because the actual index data may - // not actually have propagated to the draw thread yet. + // We need this check because the actual index data may not actually have + // propagated to the draw thread yet. if (data->is_indexed()) { data->prepare_now(this, gsg); } @@ -1570,13 +1348,10 @@ begin_frame(GraphicsStateGuardianBase *gsg, Thread *current_thread) { _enqueued_index_buffers.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::end_frame -// Access: Public -// Description: This is called by the GraphicsStateGuardian to -// indicate that it has finished processing of the -// frame. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the GraphicsStateGuardian to indicate that it has + * finished processing of the frame. + */ void PreparedGraphicsObjects:: end_frame(Thread *current_thread) { ReMutexHolder holder(_lock, current_thread); @@ -1586,12 +1361,9 @@ end_frame(Thread *current_thread) { _ibuffer_residency.end_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::init_name -// Access: Private, Static -// Description: Returns a new, unique name for a newly-constructed -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new, unique name for a newly-constructed object. + */ string PreparedGraphicsObjects:: init_name() { ++_name_index; @@ -1600,17 +1372,13 @@ init_name() { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::cache_unprepared_buffer -// Access: Private -// Description: Called when a vertex or index buffer is no longer -// officially "prepared". However, we still have the -// context on the graphics card, and we might be able to -// reuse that context if we're about to re-prepare a -// different buffer, especially one exactly the same -// size. So instead of immediately enqueuing the vertex -// buffer for release, we cache it. -//////////////////////////////////////////////////////////////////// +/** + * Called when a vertex or index buffer is no longer officially "prepared". + * However, we still have the context on the graphics card, and we might be + * able to reuse that context if we're about to re-prepare a different buffer, + * especially one exactly the same size. So instead of immediately enqueuing + * the vertex buffer for release, we cache it. + */ void PreparedGraphicsObjects:: cache_unprepared_buffer(BufferContext *buffer, size_t data_size_bytes, GeomEnums::UsageHint usage_hint, @@ -1634,8 +1402,8 @@ cache_unprepared_buffer(BufferContext *buffer, size_t data_size_bytes, } buffer_cache_lru.insert(buffer_cache_lru.begin(), key); - // Now release not-recently-used buffers until we fit within the - // constrained size. + // Now release not-recently-used buffers until we fit within the constrained + // size. while ((int)buffer_cache_size > released_buffer_cache_size) { nassertv(!buffer_cache_lru.empty()); const BufferCacheKey &release_key = *buffer_cache_lru.rbegin(); @@ -1655,12 +1423,10 @@ cache_unprepared_buffer(BufferContext *buffer, size_t data_size_bytes, } } -//////////////////////////////////////////////////////////////////// -// Function: PreparedGraphicsObjects::get_cached_buffer -// Access: Private -// Description: Returns a previously-cached buffer from the cache, or -// NULL if there is no such buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a previously-cached buffer from the cache, or NULL if there is no + * such buffer. + */ BufferContext *PreparedGraphicsObjects:: get_cached_buffer(size_t data_size_bytes, GeomEnums::UsageHint usage_hint, PreparedGraphicsObjects::BufferCache &buffer_cache, diff --git a/panda/src/gobj/preparedGraphicsObjects.h b/panda/src/gobj/preparedGraphicsObjects.h index a55bcdb4d9..cc138576de 100644 --- a/panda/src/gobj/preparedGraphicsObjects.h +++ b/panda/src/gobj/preparedGraphicsObjects.h @@ -1,16 +1,15 @@ -// Filename: preparedGraphicsObjects.h -// Created by: drose (19Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file preparedGraphicsObjects.h + * @author drose + * @date 2004-02-19 + */ #ifndef PREPAREDGRAPHICSOBJECTS_H #define PREPAREDGRAPHICSOBJECTS_H @@ -38,25 +37,20 @@ class VertexBufferContext; class IndexBufferContext; class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : PreparedGraphicsObjects -// Description : A table of objects that are saved within the graphics -// context for reference by handle later. Generally, -// this represents things like OpenGL texture objects or -// display lists (or their equivalent on other -// platforms). -// -// This object simply records the pointers to the -// context objects created by the individual GSG's; -// these context objects will contain enough information -// to reference or release the actual object stored -// within the graphics context. -// -// These tables may potentially be shared between -// related graphics contexts, hence their storage here -// in a separate object rather than as a part of the -// GraphicsStateGuardian. -//////////////////////////////////////////////////////////////////// +/** + * A table of objects that are saved within the graphics context for reference + * by handle later. Generally, this represents things like OpenGL texture + * objects or display lists (or their equivalent on other platforms). + * + * This object simply records the pointers to the context objects created by + * the individual GSG's; these context objects will contain enough information + * to reference or release the actual object stored within the graphics + * context. + * + * These tables may potentially be shared between related graphics contexts, + * hence their storage here in a separate object rather than as a part of the + * GraphicsStateGuardian. + */ class EXPCL_PANDA_GOBJ PreparedGraphicsObjects : public ReferenceCount { public: PreparedGraphicsObjects(); @@ -167,8 +161,8 @@ private: typedef phash_set< PT(GeomVertexArrayData) > EnqueuedVertexBuffers; typedef phash_set< PT(GeomPrimitive) > EnqueuedIndexBuffers; - // Sampler states are stored a little bit differently, as they are - // mapped by value and can't store the list of prepared samplers. + // Sampler states are stored a little bit differently, as they are mapped by + // value and can't store the list of prepared samplers. typedef pmap PreparedSamplers; typedef pset ReleasedSamplers; typedef pset EnqueuedSamplers; @@ -231,8 +225,8 @@ public: SimpleLru _sampler_object_lru; public: - // This is only public as a temporary hack. Don't mess with it - // unless you know what you're doing. + // This is only public as a temporary hack. Don't mess with it unless you + // know what you're doing. bool _support_released_buffer_cache; private: diff --git a/panda/src/gobj/queryContext.I b/panda/src/gobj/queryContext.I index c040e0cbf5..a152e7c65c 100644 --- a/panda/src/gobj/queryContext.I +++ b/panda/src/gobj/queryContext.I @@ -1,23 +1,19 @@ -// Filename: queryContext.I -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queryContext.I + * @author drose + * @date 2006-03-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: QueryContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE QueryContext:: QueryContext() { } diff --git a/panda/src/gobj/queryContext.cxx b/panda/src/gobj/queryContext.cxx index 70ccc5d31f..73cc54fac5 100644 --- a/panda/src/gobj/queryContext.cxx +++ b/panda/src/gobj/queryContext.cxx @@ -1,53 +1,44 @@ -// Filename: queryContext.cxx -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queryContext.cxx + * @author drose + * @date 2006-03-27 + */ #include "queryContext.h" TypeHandle QueryContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: QueryContext::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueryContext:: ~QueryContext() { } -//////////////////////////////////////////////////////////////////// -// Function: QueryContext::is_answer_ready -// Access: Public, Virtual -// Description: Returns true if the query's answer is ready, false -// otherwise. If this returns false, the application -// must continue to poll until it returns true. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the query's answer is ready, false otherwise. If this + * returns false, the application must continue to poll until it returns true. + * + * It is only valid to call this from the draw thread. + */ bool QueryContext:: is_answer_ready() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: QueryContext::waiting_for_answer -// Access: Public, Virtual -// Description: Requests the graphics engine to expedite the pending -// answer--the application is now waiting until the -// answer is ready. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Requests the graphics engine to expedite the pending answer--the + * application is now waiting until the answer is ready. + * + * It is only valid to call this from the draw thread. + */ void QueryContext:: waiting_for_answer() { } diff --git a/panda/src/gobj/queryContext.h b/panda/src/gobj/queryContext.h index 4cb65d63b9..9fbca8ce71 100644 --- a/panda/src/gobj/queryContext.h +++ b/panda/src/gobj/queryContext.h @@ -1,16 +1,15 @@ -// Filename: queryContext.h -// Created by: drose (27Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queryContext.h + * @author drose + * @date 2006-03-27 + */ #ifndef QUERYCONTEXT_H #define QUERYCONTEXT_H @@ -20,21 +19,17 @@ class PreparedGraphicsObjects; -//////////////////////////////////////////////////////////////////// -// Class : QueryContext -// Description : This is a base class for queries that might require a -// round-trip to the graphics engine. The idea is that -// when you ask the GSG to make a particular query, it -// returns a QueryContext, which does not necessarily -// have the answer right away (but it will eventually). -// -// Unlike SavedContext, QueryContext is -// reference-counted. It removes itself from the GSG -// when the last reference goes away. You're -// responsible for keeping the pointer to the -// QueryContext as long as you are interested in the -// answer. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for queries that might require a round-trip to the + * graphics engine. The idea is that when you ask the GSG to make a + * particular query, it returns a QueryContext, which does not necessarily + * have the answer right away (but it will eventually). + * + * Unlike SavedContext, QueryContext is reference-counted. It removes itself + * from the GSG when the last reference goes away. You're responsible for + * keeping the pointer to the QueryContext as long as you are interested in + * the answer. + */ class EXPCL_PANDA_GOBJ QueryContext : public TypedReferenceCount { public: INLINE QueryContext(); @@ -64,4 +59,3 @@ private: #include "queryContext.I" #endif - diff --git a/panda/src/gobj/samplerContext.I b/panda/src/gobj/samplerContext.I index ef2039a56f..70916d5723 100644 --- a/panda/src/gobj/samplerContext.I +++ b/panda/src/gobj/samplerContext.I @@ -1,23 +1,19 @@ -// Filename: samplerContext.I -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerContext.I + * @author rdb + * @date 2014-12-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SamplerContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SamplerContext:: SamplerContext(const SamplerState &sampler) : SimpleLruPage(1) diff --git a/panda/src/gobj/samplerContext.cxx b/panda/src/gobj/samplerContext.cxx index a0b022225c..aad143c2fc 100644 --- a/panda/src/gobj/samplerContext.cxx +++ b/panda/src/gobj/samplerContext.cxx @@ -1,38 +1,32 @@ -// Filename: samplerContext.cxx -// Created by: rdb (11Dec14)) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerContext.cxx + * @author rdb + * @date 2014-12-11 + */ #include "samplerContext.h" TypeHandle SamplerContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SamplerContext::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SamplerContext:: output(ostream &out) const { SavedContext::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerContext::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SamplerContext:: write(ostream &out, int indent_level) const { SavedContext::write(out, indent_level); } - diff --git a/panda/src/gobj/samplerContext.h b/panda/src/gobj/samplerContext.h index a51157ccc0..edb684c4b4 100644 --- a/panda/src/gobj/samplerContext.h +++ b/panda/src/gobj/samplerContext.h @@ -1,16 +1,15 @@ -// Filename: samplerContext.h -// Created by: rdb (11Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerContext.h + * @author rdb + * @date 2014-12-11 + */ #ifndef SAMPLERCONTEXT_H #define SAMPLERCONTEXT_H @@ -22,20 +21,16 @@ #include "samplerState.h" #include "savedContext.h" -//////////////////////////////////////////////////////////////////// -// Class : SamplerContext -// Description : This is a special class object that holds a handle -// to the sampler state object given by the graphics -// back-end for a particular combination of texture -// sampling settings. -// -// Some graphics back-ends (like OpenGL) use mutable -// sampler objects, whereas others (Direct3D 10+) use -// immutable ones. In Panda3D, each unique sampler -// state has its own SamplerContext, which simplifies -// the implementation and makes redundant sampler -// objects impossible. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class object that holds a handle to the sampler state + * object given by the graphics back-end for a particular combination of + * texture sampling settings. + * + * Some graphics back-ends (like OpenGL) use mutable sampler objects, whereas + * others (Direct3D 10+) use immutable ones. In Panda3D, each unique sampler + * state has its own SamplerContext, which simplifies the implementation and + * makes redundant sampler objects impossible. + */ class EXPCL_PANDA_GOBJ SamplerContext : public SavedContext, public SimpleLruPage { public: INLINE SamplerContext(const SamplerState &sampler); @@ -71,4 +66,3 @@ inline ostream &operator << (ostream &out, const SamplerContext &context) { #include "samplerContext.I" #endif - diff --git a/panda/src/gobj/samplerState.I b/panda/src/gobj/samplerState.I index f7096b0500..ae5f9c9e2c 100644 --- a/panda/src/gobj/samplerState.I +++ b/panda/src/gobj/samplerState.I @@ -1,24 +1,19 @@ -// Filename: samplerState.I -// Created by: rdb (09Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerState.I + * @author rdb + * @date 2014-12-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::Constructor -// Access: Published -// Description: Creates a new SamplerState initialized to the -// default values. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new SamplerState initialized to the default values. + */ INLINE SamplerState:: SamplerState() : _border_color(0, 0, 0, 1), @@ -34,225 +29,172 @@ SamplerState() : { } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_default -// Access: Published, Static -// Description: Returns a reference to the global default immutable -// SamplerState object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the global default immutable SamplerState object. + */ INLINE const SamplerState &SamplerState:: get_default() { return _default; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_wrap_u -// Access: Published -// Description: This setting determines what happens when the -// SamplerState is sampled with a U value outside the range -// 0.0-1.0. The default is WM_repeat, which indicates -// that the SamplerState should repeat indefinitely. -//////////////////////////////////////////////////////////////////// +/** + * This setting determines what happens when the SamplerState is sampled with + * a U value outside the range 0.0-1.0. The default is WM_repeat, which + * indicates that the SamplerState should repeat indefinitely. + */ INLINE void SamplerState:: set_wrap_u(SamplerState::WrapMode wrap) { _wrap_u = wrap; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_wrap_v -// Access: Published -// Description: This setting determines what happens when the -// SamplerState is sampled with a V value outside the range -// 0.0-1.0. The default is WM_repeat, which indicates -// that the SamplerState should repeat indefinitely. -//////////////////////////////////////////////////////////////////// +/** + * This setting determines what happens when the SamplerState is sampled with + * a V value outside the range 0.0-1.0. The default is WM_repeat, which + * indicates that the SamplerState should repeat indefinitely. + */ INLINE void SamplerState:: set_wrap_v(SamplerState::WrapMode wrap) { _wrap_v = wrap; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_wrap_w -// Access: Published -// Description: The W wrap direction is only used for 3-d SamplerStates. -//////////////////////////////////////////////////////////////////// +/** + * The W wrap direction is only used for 3-d SamplerStates. + */ INLINE void SamplerState:: set_wrap_w(SamplerState::WrapMode wrap) { _wrap_w = wrap; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_minfilter -// Access: Published -// Description: Sets the filtering method that should be used when -// viewing the SamplerState from a distance. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filtering method that should be used when viewing the SamplerState + * from a distance. + */ INLINE void SamplerState:: set_minfilter(SamplerState::FilterType filter) { _minfilter = filter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_magfilter -// Access: Published -// Description: Sets the filtering method that should be used when -// viewing the SamplerState up close. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filtering method that should be used when viewing the SamplerState + * up close. + */ INLINE void SamplerState:: set_magfilter(SamplerState::FilterType filter) { _magfilter = filter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_anisotropic_degree -// Access: Published -// Description: Specifies the level of anisotropic filtering to apply -// to the SamplerState. Set this 0 to indicate the default -// value, which is specified in the -// SamplerState-anisotropic-degree config variable. -// -// To explicitly disable anisotropic filtering, set this -// value to 1. To explicitly enable anisotropic -// filtering, set it to a value higher than 1; larger -// numbers indicate greater degrees of filtering. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the level of anisotropic filtering to apply to the SamplerState. + * Set this 0 to indicate the default value, which is specified in the + * SamplerState-anisotropic-degree config variable. + * + * To explicitly disable anisotropic filtering, set this value to 1. To + * explicitly enable anisotropic filtering, set it to a value higher than 1; + * larger numbers indicate greater degrees of filtering. + */ INLINE void SamplerState:: set_anisotropic_degree(int anisotropic_degree) { _anisotropic_degree = anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_border_color -// Access: Published -// Description: Specifies the solid color of the SamplerState's border. -// Some OpenGL implementations use a border for tiling -// SamplerStates; in Panda, it is only used for specifying -// the clamp color. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the solid color of the SamplerState's border. Some OpenGL + * implementations use a border for tiling SamplerStates; in Panda, it is only + * used for specifying the clamp color. + */ INLINE void SamplerState:: set_border_color(const LColor &color) { _border_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_min_lod -// Access: Published -// Description: Sets the minimum level of detail that will be used -// when sampling this texture. This may be a negative -// value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the minimum level of detail that will be used when sampling this + * texture. This may be a negative value. + */ INLINE void SamplerState:: set_min_lod(PN_stdfloat min_lod) { _min_lod = min_lod; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_max_lod -// Access: Published -// Description: Sets the maximum level of detail that will be used -// when sampling this texture. This may exceed the -// number of mipmap levels that the texture has. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum level of detail that will be used when sampling this + * texture. This may exceed the number of mipmap levels that the texture has. + */ INLINE void SamplerState:: set_max_lod(PN_stdfloat max_lod) { _max_lod = max_lod; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::set_lod_bias -// Access: Published -// Description: Sets the value that will be added to the level of -// detail when sampling the texture. This may be a -// negative value, although some graphics hardware may -// not support the use of negative LOD values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value that will be added to the level of detail when sampling the + * texture. This may be a negative value, although some graphics hardware may + * not support the use of negative LOD values. + */ INLINE void SamplerState:: set_lod_bias(PN_stdfloat lod_bias) { _lod_bias = lod_bias; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_wrap_u -// Access: Published -// Description: Returns the wrap mode of the texture in the U -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the U direction. + */ INLINE SamplerState::WrapMode SamplerState:: get_wrap_u() const { return _wrap_u; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_wrap_v -// Access: Published -// Description: Returns the wrap mode of the texture in the V -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the V direction. + */ INLINE SamplerState::WrapMode SamplerState:: get_wrap_v() const { return _wrap_v; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_wrap_w -// Access: Published -// Description: Returns the wrap mode of the texture in the W -// direction. This is the depth direction of 3-d -// textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the W direction. This is the depth + * direction of 3-d textures. + */ INLINE SamplerState::WrapMode SamplerState:: get_wrap_w() const { return _wrap_w; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_minfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// minification. If this is one of the mipmap -// constants, then the texture requires mipmaps. This -// may return FT_default; see also -// get_effective_minfilter(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for minification. If this is one of + * the mipmap constants, then the texture requires mipmaps. This may return + * FT_default; see also get_effective_minfilter(). + */ INLINE SamplerState::FilterType SamplerState:: get_minfilter() const { return _minfilter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_magfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// magnification. The mipmap constants are invalid -// here. This may return FT_default; see also -// get_effective_minfilter(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for magnification. The mipmap + * constants are invalid here. This may return FT_default; see also + * get_effective_minfilter(). + */ INLINE SamplerState::FilterType SamplerState:: get_magfilter() const { return _magfilter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_anisotropic_degree -// Access: Published -// Description: Returns the degree of anisotropic filtering that -// should be applied to the texture. This value may -// return 0, indicating the default value; see also -// get_effective_anisotropic_degree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of anisotropic filtering that should be applied to the + * texture. This value may return 0, indicating the default value; see also + * get_effective_anisotropic_degree. + */ INLINE int SamplerState:: get_anisotropic_degree() const { return _anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_effective_anisotropic_degree -// Access: Published -// Description: Returns the degree of anisotropic filtering that -// should be applied to the texture. This value will -// normally not return 0, unless there is an error in -// the config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of anisotropic filtering that should be applied to the + * texture. This value will normally not return 0, unless there is an error + * in the config file. + */ INLINE int SamplerState:: get_effective_anisotropic_degree() const { if (_anisotropic_degree != 0) { @@ -261,70 +203,56 @@ get_effective_anisotropic_degree() const { return texture_anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_border_color -// Access: Published -// Description: Returns the solid color of the texture's border. -// Some OpenGL implementations use a border for tiling -// textures; in Panda, it is only used for specifying -// the clamp color. -//////////////////////////////////////////////////////////////////// +/** + * Returns the solid color of the texture's border. Some OpenGL + * implementations use a border for tiling textures; in Panda, it is only used + * for specifying the clamp color. + */ INLINE const LColor &SamplerState:: get_border_color() const { return _border_color; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_min_lod -// Access: Published -// Description: Returns the minimum level of detail that will be -// observed when sampling this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum level of detail that will be observed when sampling + * this texture. + */ INLINE PN_stdfloat SamplerState:: get_min_lod() const { return _min_lod; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_max_lod -// Access: Published -// Description: Returns the maximum level of detail that will be -// observed when sampling this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum level of detail that will be observed when sampling + * this texture. + */ INLINE PN_stdfloat SamplerState:: get_max_lod() const { return _max_lod; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_lod_bias -// Access: Published -// Description: Returns the bias that will be added to the texture -// level of detail when sampling this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bias that will be added to the texture level of detail when + * sampling this texture. + */ INLINE PN_stdfloat SamplerState:: get_lod_bias() const { return _lod_bias; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::uses_mipmaps -// Access: Public -// Description: Returns true if the minfilter settings on this -// sampler indicate the use of mipmapping, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the minfilter settings on this sampler indicate the use of + * mipmapping, false otherwise. + */ INLINE bool SamplerState:: uses_mipmaps() const { return is_mipmap(get_effective_minfilter()); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::is_mipmap -// Access: Published, Static -// Description: Returns true if the indicated filter type requires -// the use of mipmaps, or false if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated filter type requires the use of mipmaps, or + * false if it does not. + */ INLINE bool SamplerState:: is_mipmap(FilterType filter_type) { switch (filter_type) { @@ -339,31 +267,25 @@ is_mipmap(FilterType filter_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SamplerState:: operator == (const SamplerState &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SamplerState:: operator != (const SamplerState &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SamplerState:: operator < (const SamplerState &other) const { return compare_to(other) < 0; diff --git a/panda/src/gobj/samplerState.cxx b/panda/src/gobj/samplerState.cxx index 1232aea7b7..be8bd7b23d 100644 --- a/panda/src/gobj/samplerState.cxx +++ b/panda/src/gobj/samplerState.cxx @@ -1,16 +1,15 @@ -// Filename: samplerState.cxx -// Created by: rdb (09Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerState.cxx + * @author rdb + * @date 2014-12-09 + */ #include "samplerState.h" #include "indent.h" @@ -54,14 +53,11 @@ ConfigVariableInt texture_anisotropic_degree "changed at runtime, you may need to reload textures explicitly " "in order to change their visible properties.")); -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_effective_minfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// minification, with special treatment for FT_default. -// This will normally not return FT_default, unless -// there is an error in the config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for minification, with special + * treatment for FT_default. This will normally not return FT_default, unless + * there is an error in the config file. + */ SamplerState::FilterType SamplerState:: get_effective_minfilter() const { if (_minfilter != FT_default) { @@ -70,14 +66,11 @@ get_effective_minfilter() const { return texture_minfilter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::get_effective_magfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// magnification, with special treatment for FT_default. -// This will normally not return FT_default, unless -// there is an error in the config file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for magnification, with special + * treatment for FT_default. This will normally not return FT_default, unless + * there is an error in the config file. + */ SamplerState::FilterType SamplerState:: get_effective_magfilter() const { if (_magfilter != FT_default) { @@ -86,12 +79,9 @@ get_effective_magfilter() const { return texture_magfilter; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::format_filter_type -// Access: Published, Static -// Description: Returns the indicated FilterType converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated FilterType converted to a string word. + */ string SamplerState:: format_filter_type(FilterType ft) { switch (ft) { @@ -121,13 +111,11 @@ format_filter_type(FilterType ft) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::string_filter_type -// Access: Public -// Description: Returns the FilterType value associated with the given -// string representation, or FT_invalid if the string -// does not match any known FilterType value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FilterType value associated with the given string + * representation, or FT_invalid if the string does not match any known + * FilterType value. + */ SamplerState::FilterType SamplerState:: string_filter_type(const string &string) { if (cmp_nocase_uh(string, "nearest") == 0) { @@ -153,12 +141,9 @@ string_filter_type(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::format_wrap_mode -// Access: Published, Static -// Description: Returns the indicated WrapMode converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated WrapMode converted to a string word. + */ string SamplerState:: format_wrap_mode(WrapMode wm) { switch (wm) { @@ -180,13 +165,10 @@ format_wrap_mode(WrapMode wm) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::string_wrap_mode -// Access: Public -// Description: Returns the WrapMode value associated with the given -// string representation, or WM_invalid if the string -// does not match any known WrapMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WrapMode value associated with the given string representation, + * or WM_invalid if the string does not match any known WrapMode value. + */ SamplerState::WrapMode SamplerState:: string_wrap_mode(const string &string) { if (cmp_nocase_uh(string, "repeat") == 0 || @@ -207,77 +189,60 @@ string_wrap_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::prepare -// Access: Published -// Description: Indicates that the sampler should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. -// -// Use this function instead of prepare_now() to preload -// samplers from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the sampler should be enqueued to be prepared in the + * indicated prepared_objects at the beginning of the next frame. + * + * Use this function instead of prepare_now() to preload samplers from a user + * interface standpoint. + */ void SamplerState:: prepare(PreparedGraphicsObjects *prepared_objects) const { prepared_objects->enqueue_sampler(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::is_prepared -// Access: Published -// Description: Returns true if the sampler has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the sampler has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool SamplerState:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_sampler_queued(*this) || prepared_objects->is_sampler_prepared(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::release -// Access: Published -// Description: Frees the texture context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the texture context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ void SamplerState:: release(PreparedGraphicsObjects *prepared_objects) const { prepared_objects->release_sampler(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::prepare_now -// Access: Published -// Description: Creates a context for the sampler on the particular -// GSG, if it does not already exist. Returns the new -// (or old) SamplerContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// textures. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a sampler does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the sampler on the particular GSG, if it does not + * already exist. Returns the new (or old) SamplerContext. This assumes that + * the GraphicsStateGuardian is the currently active rendering context and + * that it is ready to accept new textures. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a sampler does not need to be explicitly prepared by the user before it may + * be rendered. + */ SamplerContext *SamplerState:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) const { return prepared_objects->prepare_sampler_now(*this, gsg); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::compare_to -// Access: Public -// Description: Returns a number less than zero if this sampler -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. The -// sorting order is arbitrary and largely meaningless, -// except to differentiate different sampler states. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this sampler sorts before the other one, + * greater than zero if it sorts after, or zero if they are equivalent. The + * sorting order is arbitrary and largely meaningless, except to differentiate + * different sampler states. + */ int SamplerState:: compare_to(const SamplerState &other) const { if (_wrap_u != other._wrap_u) { @@ -314,11 +279,9 @@ compare_to(const SamplerState &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SamplerState:: output(ostream &out) const { out @@ -331,11 +294,9 @@ output(ostream &out) const { << ", bias=" << _lod_bias << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SamplerState:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "SamplerState\n"; @@ -351,11 +312,9 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << " lod_bias = " << _lod_bias << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::write_datagram -// Access: Public -// Description: Encodes the sampler state into a datagram. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the sampler state into a datagram. + */ void SamplerState:: write_datagram(Datagram &me) const { me.add_uint8(_wrap_u); @@ -370,12 +329,10 @@ write_datagram(Datagram &me) const { me.add_stdfloat(_lod_bias); } -//////////////////////////////////////////////////////////////////// -// Function: SamplerState::read_datagram -// Access: Protected -// Description: Reads the sampler state from the datagram that has -// been previously written using write_datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the sampler state from the datagram that has been previously written + * using write_datagram. + */ void SamplerState:: read_datagram(DatagramIterator &scan, BamReader *manager) { _wrap_u = (WrapMode)scan.get_uint8(); @@ -387,9 +344,9 @@ read_datagram(DatagramIterator &scan, BamReader *manager) { _border_color.read_datagram(scan); if (manager->get_file_minor_ver() >= 36) { - // These were added with the introduction of SamplerState. - // Since Texture::do_fillin_body calls this, we still have to - // preserve backward compatibility here. + // These were added with the introduction of SamplerState. Since + // Texture::do_fillin_body calls this, we still have to preserve backward + // compatibility here. _min_lod = scan.get_stdfloat(); _max_lod = scan.get_stdfloat(); _lod_bias = scan.get_stdfloat(); diff --git a/panda/src/gobj/samplerState.h b/panda/src/gobj/samplerState.h index ed785303d6..2236092b81 100644 --- a/panda/src/gobj/samplerState.h +++ b/panda/src/gobj/samplerState.h @@ -1,16 +1,15 @@ -// Filename: samplerState.h -// Created by: rdb (09Dec14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file samplerState.h + * @author rdb + * @date 2014-12-09 + */ #ifndef SAMPLERSTATE_H #define SAMPLERSTATE_H @@ -29,13 +28,11 @@ class GraphicsStateGuardianBase; class PreparedGraphicsObjects; class SamplerContext; -//////////////////////////////////////////////////////////////////// -// Class : SamplerState -// Description : Represents a set of settings that indicate how a -// texture is sampled. This can be used to sample the -// same texture using different settings in different -// places. -//////////////////////////////////////////////////////////////////// +/** + * Represents a set of settings that indicate how a texture is sampled. This + * can be used to sample the same texture using different settings in + * different places. + */ class EXPCL_PANDA_GOBJ SamplerState { PUBLISHED: enum FilterType { @@ -58,15 +55,16 @@ PUBLISHED: // Point sample the pixel from two mipmap levels, and linearly blend FT_nearest_mipmap_linear, - // A.k.a. trilinear filtering: Bilinear filter the pixel from - // two mipmap levels, and linearly blend the results. + // A.k.a. trilinear filtering: Bilinear filter the pixel from two mipmap + // levels, and linearly blend the results. FT_linear_mipmap_linear, - // The OpenGL ARB_shadow extension can be thought of as a kind of filtering. + // The OpenGL ARB_shadow extension can be thought of as a kind of + // filtering. FT_shadow, - // Default is usually linear, but it depends on format. - // This was added at the end of the list to avoid bumping TXO version #. + // Default is usually linear, but it depends on format. This was added at + // the end of the list to avoid bumping TXO version #. FT_default, // Returned by string_filter_type() for an invalid match. @@ -157,9 +155,9 @@ private: PN_stdfloat _max_lod; PN_stdfloat _lod_bias; - // These are packed in a way that this class conveniently fits in - // 32 bytes; feel free to change the packing as necessary when - // more enum values are added. + // These are packed in a way that this class conveniently fits in 32 bytes; + // feel free to change the packing as necessary when more enum values are + // added. FilterType _minfilter : 4; FilterType _magfilter : 4; WrapMode _wrap_u : 4; diff --git a/panda/src/gobj/savedContext.I b/panda/src/gobj/savedContext.I index 692ce17a99..70aa2175c2 100644 --- a/panda/src/gobj/savedContext.I +++ b/panda/src/gobj/savedContext.I @@ -1,22 +1,19 @@ -// Filename: savedContext.I -// Created by: drose (11Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file savedContext.I + * @author drose + * @date 2001-06-11 + */ -//////////////////////////////////////////////////////////////////// -// Function: SavedContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SavedContext:: SavedContext() { } diff --git a/panda/src/gobj/savedContext.cxx b/panda/src/gobj/savedContext.cxx index 674fa42bb9..2b93299121 100644 --- a/panda/src/gobj/savedContext.cxx +++ b/panda/src/gobj/savedContext.cxx @@ -1,37 +1,32 @@ -// Filename: savedContext.cxx -// Created by: drose (11Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file savedContext.cxx + * @author drose + * @date 2001-06-11 + */ #include "savedContext.h" #include "indent.h" TypeHandle SavedContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SavedContext::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SavedContext:: output(ostream &out) const { out << "SavedContext " << this; } -//////////////////////////////////////////////////////////////////// -// Function: SavedContext::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SavedContext:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; diff --git a/panda/src/gobj/savedContext.h b/panda/src/gobj/savedContext.h index 63a65dcdd8..1e5a28594e 100644 --- a/panda/src/gobj/savedContext.h +++ b/panda/src/gobj/savedContext.h @@ -1,16 +1,15 @@ -// Filename: savedContext.h -// Created by: drose (11Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file savedContext.h + * @author drose + * @date 2001-06-11 + */ #ifndef SAVEDCONTEXT_H #define SAVEDCONTEXT_H @@ -19,13 +18,11 @@ #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : SavedContext -// Description : This is the base class for all GSG-specific context -// objects, such as TextureContext and GeomContext. It -// exists mainly to provide some structural -// organization. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for all GSG-specific context objects, such as + * TextureContext and GeomContext. It exists mainly to provide some + * structural organization. + */ class EXPCL_PANDA_GOBJ SavedContext : public TypedObject { public: INLINE SavedContext(); @@ -60,4 +57,3 @@ inline ostream &operator << (ostream &out, const SavedContext &context) { #include "savedContext.I" #endif - diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index 20d7831f32..f1fb1dabf2 100644 --- a/panda/src/gobj/shader.I +++ b/panda/src/gobj/shader.I @@ -1,24 +1,21 @@ -// Filename: shader.I -// Heavily Modified: jyelon (Sep05) -// Updated by: fperazzi, PandaSE(06Apr10) -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shader.I + * @author jyelon + * @date 2005-09 + * @author fperazzi, PandaSE + * @date 2010-04-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_filename -// Access: Published -// Description: Return the Shader's filename for the given shader -// type. -//////////////////////////////////////////////////////////////////// +/** + * Return the Shader's filename for the given shader type. + */ INLINE Filename Shader:: get_filename(ShaderType type) const { if (_filename._separate && type != ST_none) { @@ -53,11 +50,9 @@ get_filename(ShaderType type) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_text -// Access: Published -// Description: Return the Shader's text for the given shader type. -//////////////////////////////////////////////////////////////////// +/** + * Return the Shader's text for the given shader type. + */ INLINE const string &Shader:: get_text(ShaderType type) const { if (_text._separate) { @@ -89,96 +84,75 @@ get_text(ShaderType type) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_error_flag -// Access: Public -// Description: Returns true if the shader contains a compile-time -// error. This doesn't tell you whether or not the -// shader is supported on the current video card. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader contains a compile-time error. This doesn't + * tell you whether or not the shader is supported on the current video card. + */ INLINE bool Shader:: get_error_flag() const { return _error_flag; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_language -// Access: Published -// Description: Returns the shader language in which this shader -// was written. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shader language in which this shader was written. + */ INLINE Shader::ShaderLanguage Shader:: get_language() const { return _language; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::has_fullpath -// Access: Published -// Description: Returns true if the fullpath has been set and -// is available. See set_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the fullpath has been set and is available. See + * set_fullpath(). + */ INLINE bool Shader:: has_fullpath() const { return !_fullpath.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_fullpath -// Access: Published -// Description: Returns the fullpath that has been set. This is -// the full path to the file as it was found along the -// model-path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fullpath that has been set. This is the full path to the file + * as it was found along the model-path. + */ INLINE const Filename &Shader:: get_fullpath() const { return _fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_cache_compiled_shader -// Access: Public -// Description: Returns the setting of the cache_compiled_shader -// flag. See set_cache_compiled_shader(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the setting of the cache_compiled_shader flag. See + * set_cache_compiled_shader(). + */ INLINE bool Shader:: get_cache_compiled_shader() const { return _cache_compiled_shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::set_cache_compiled_shader -// Access: Public -// Description: Sets the cache_compiled_shader flag. When this is -// set, the next time the Shader is loaded on a GSG, it -// will automatically extract the compiled shader from -// the GSG and save it to the global BamCache. -// -// This is used to store compiled shaders in the -// BamCache. This flag should not be set explicitly; it -// is set automatically by the ShaderPool when -// model-cache-compiled-shaders is set true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the cache_compiled_shader flag. When this is set, the next time the + * Shader is loaded on a GSG, it will automatically extract the compiled + * shader from the GSG and save it to the global BamCache. + * + * This is used to store compiled shaders in the BamCache. This flag should + * not be set explicitly; it is set automatically by the ShaderPool when + * model-cache-compiled-shaders is set true. + */ INLINE void Shader:: set_cache_compiled_shader(bool flag) { _cache_compiled_shader = flag; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderCapabilities Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderCaps:: ShaderCaps() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderCapabilities::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Shader::ShaderCaps:: operator == (const ShaderCaps &other) const { #ifdef HAVE_CG @@ -194,11 +168,9 @@ operator == (const ShaderCaps &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData() : _ptr(NULL), @@ -208,11 +180,9 @@ ShaderPtrData() : { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_float &ptr): _pta(ptr.v0()), @@ -223,11 +193,9 @@ ShaderPtrData(const PTA_float &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LMatrix4f &ptr): _pta(ptr.v0()), @@ -238,11 +206,9 @@ ShaderPtrData(const PTA_LMatrix4f &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LMatrix3f &ptr): _pta(ptr.v0()), @@ -253,11 +219,9 @@ ShaderPtrData(const PTA_LMatrix3f &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase4f &ptr): _pta(ptr.v0()), @@ -268,11 +232,9 @@ ShaderPtrData(const PTA_LVecBase4f &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase3f &ptr): _pta(ptr.v0()), @@ -283,11 +245,9 @@ ShaderPtrData(const PTA_LVecBase3f &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase2f &ptr): _pta(ptr.v0()), @@ -298,11 +258,9 @@ ShaderPtrData(const PTA_LVecBase2f &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase4f &vec) : _type(SPT_float), @@ -316,11 +274,9 @@ ShaderPtrData(const LVecBase4f &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase3f &vec) : _type(SPT_float), @@ -334,11 +290,9 @@ ShaderPtrData(const LVecBase3f &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase2f &vec) : _type(SPT_float), @@ -352,11 +306,9 @@ ShaderPtrData(const LVecBase2f &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LMatrix4f &mat) : _type(SPT_float), @@ -370,11 +322,9 @@ ShaderPtrData(const LMatrix4f &mat) : memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LMatrix3f &mat) : _type(SPT_float), @@ -388,11 +338,9 @@ ShaderPtrData(const LMatrix3f &mat) : memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_double &ptr): _pta(ptr.v0()), @@ -403,11 +351,9 @@ ShaderPtrData(const PTA_double &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LMatrix4d &ptr): _pta(ptr.v0()), @@ -418,11 +364,9 @@ ShaderPtrData(const PTA_LMatrix4d &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LMatrix3d &ptr): _pta(ptr.v0()), @@ -433,11 +377,9 @@ ShaderPtrData(const PTA_LMatrix3d &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase4d &ptr): _pta(ptr.v0()), @@ -448,11 +390,9 @@ ShaderPtrData(const PTA_LVecBase4d &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase3d &ptr): _pta(ptr.v0()), @@ -463,11 +403,9 @@ ShaderPtrData(const PTA_LVecBase3d &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase2d &ptr): _pta(ptr.v0()), @@ -478,11 +416,9 @@ ShaderPtrData(const PTA_LVecBase2d &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase4d &vec) : _type(SPT_double), @@ -496,11 +432,9 @@ ShaderPtrData(const LVecBase4d &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase3d &vec) : _type(SPT_double), @@ -514,11 +448,9 @@ ShaderPtrData(const LVecBase3d &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase2d &vec) : _type(SPT_double), @@ -532,11 +464,9 @@ ShaderPtrData(const LVecBase2d &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LMatrix4d &mat) : _type(SPT_double), @@ -550,11 +480,9 @@ ShaderPtrData(const LMatrix4d &mat) : memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LMatrix3d &mat) : _type(SPT_double), @@ -568,11 +496,9 @@ ShaderPtrData(const LMatrix3d &mat) : memcpy(_ptr, mat.get_data(), sizeof(mat(0, 0)) * mat.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_int &ptr): _pta(ptr.v0()), @@ -583,11 +509,9 @@ ShaderPtrData(const PTA_int &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase4i &ptr): _pta(ptr.v0()), @@ -598,11 +522,9 @@ ShaderPtrData(const PTA_LVecBase4i &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase3i &ptr): _pta(ptr.v0()), @@ -613,11 +535,9 @@ ShaderPtrData(const PTA_LVecBase3i &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const PTA_LVecBase2i &ptr): _pta(ptr.v0()), @@ -628,11 +548,9 @@ ShaderPtrData(const PTA_LVecBase2i &ptr): { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase4i &vec) : _type(SPT_int), @@ -646,11 +564,9 @@ ShaderPtrData(const LVecBase4i &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase3i &vec) : _type(SPT_int), @@ -664,11 +580,9 @@ ShaderPtrData(const LVecBase3i &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderPtrData:: ShaderPtrData(const LVecBase2i &vec) : _type(SPT_int), @@ -682,12 +596,10 @@ ShaderPtrData(const LVecBase2i &vec) : memcpy(_ptr, vec.get_data(), sizeof(vec[0]) * vec.get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ INLINE void Shader::ShaderPtrData:: write_datagram(Datagram &dg) const { dg.add_uint8(_type); @@ -712,11 +624,9 @@ write_datagram(Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderPtrData::write_datagram -// Access: Public -// Description: Reads the object from a Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the object from a Datagram. + */ INLINE void Shader::ShaderPtrData:: read_datagram(DatagramIterator &scan) { _type = (ShaderPtrType) scan.get_uint8(); @@ -748,11 +658,9 @@ read_datagram(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderFile:: ShaderFile(const string &shared) : _separate(false), @@ -760,11 +668,9 @@ ShaderFile(const string &shared) : { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader::ShaderFile:: ShaderFile(const string &vertex, const string &fragment, @@ -780,12 +686,10 @@ ShaderFile(const string &vertex, { } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderFile::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ INLINE void Shader::ShaderFile:: write_datagram(Datagram &dg) const { if (_separate) { @@ -802,11 +706,9 @@ write_datagram(Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderFile::write_datagram -// Access: Public -// Description: Reads the object from a Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the object from a Datagram. + */ INLINE void Shader::ShaderFile:: read_datagram(DatagramIterator &scan) { short count = scan.get_uint8(); @@ -827,11 +729,9 @@ read_datagram(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderFile::operator < -// Access: Public -// Description: Ordering operator -//////////////////////////////////////////////////////////////////// +/** + * Ordering operator + */ INLINE bool Shader::ShaderFile:: operator < (const Shader::ShaderFile &other) const { if (_separate != other._separate) { @@ -861,14 +761,11 @@ operator < (const Shader::ShaderFile &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_filename_from_index -// Access: Public -// Description: Returns the filename of the included shader with -// the given source file index (as recorded in the -// #line statement in r_preprocess_source). We use -// this to associate error messages with included files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename of the included shader with the given source file + * index (as recorded in the #line statement in r_preprocess_source). We use + * this to associate error messages with included files. + */ INLINE Filename Shader:: get_filename_from_index(int index, ShaderType type) const { if (index == 0) { diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index a43b5147c1..2905d54d7d 100644 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -1,17 +1,19 @@ -// Filename: shader.cxx -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE(06Apr10) -// Updated by: fperazzi, PandaSE(29Apr10) (added SAT_sampler2dArray) -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shader.cxx + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-06 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #include "pandabase.h" #include "shader.h" @@ -34,12 +36,10 @@ int Shader::_shaders_generated; CGcontext Shader::_cg_context = 0; #endif -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_report_error -// Access: Public -// Description: Generate an error message including a description -// of the specified parameter. -//////////////////////////////////////////////////////////////////// +/** + * Generate an error message including a description of the specified + * parameter. + */ void Shader:: cp_report_error(ShaderArgInfo &p, const string &msg) { @@ -107,13 +107,10 @@ cp_report_error(ShaderArgInfo &p, const string &msg) { p._id._name << ": " << msg << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_words -// Access: Public, Static -// Description: Make sure the provided parameter contains -// the specified number of words. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter contains the specified number of words. + * If not, print error message and return false. + */ bool Shader:: cp_errchk_parameter_words(ShaderArgInfo &p, int len) { @@ -126,13 +123,10 @@ cp_errchk_parameter_words(ShaderArgInfo &p, int len) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_in -// Access: Public, Static -// Description: Make sure the provided parameter has the -// 'in' direction. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter has the 'in' direction. If not, print + * error message and return false. + */ bool Shader:: cp_errchk_parameter_in(ShaderArgInfo &p) { @@ -143,13 +137,10 @@ cp_errchk_parameter_in(ShaderArgInfo &p) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_varying -// Access: Public, Static -// Description: Make sure the provided parameter has the -// correct variance. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter has the correct variance. If not, print + * error message and return false. + */ bool Shader:: cp_errchk_parameter_varying(ShaderArgInfo &p) { @@ -160,13 +151,10 @@ cp_errchk_parameter_varying(ShaderArgInfo &p) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_uniform -// Access: Public, Static -// Description: Make sure the provided parameter has the -// correct variance. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter has the correct variance. If not, print + * error message and return false. + */ bool Shader:: cp_errchk_parameter_uniform(ShaderArgInfo &p) { @@ -177,13 +165,10 @@ cp_errchk_parameter_uniform(ShaderArgInfo &p) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_float -// Access: Public, Static -// Description: Make sure the provided parameter has -// a floating point type. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter has a floating point type. If not, print + * error message and return false. + */ bool Shader:: cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi) { @@ -205,11 +190,9 @@ cp_errchk_parameter_float(ShaderArgInfo &p, int lo, int hi) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_ptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Shader:: cp_errchk_parameter_ptr(ShaderArgInfo &p) { switch (p._class) { @@ -233,13 +216,10 @@ cp_errchk_parameter_ptr(ShaderArgInfo &p) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_errchk_parameter_sampler -// Access: Public, Static -// Description: Make sure the provided parameter has -// a texture type. If not, print -// error message and return false. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the provided parameter has a texture type. If not, print error + * message and return false. + */ bool Shader:: cp_errchk_parameter_sampler(ShaderArgInfo &p) { @@ -256,11 +236,9 @@ cp_errchk_parameter_sampler(ShaderArgInfo &p) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_parse_eol -// Access: Public -// Description: Make sure the next thing on the word list is EOL -//////////////////////////////////////////////////////////////////// +/** + * Make sure the next thing on the word list is EOL + */ bool Shader:: cp_parse_eol(ShaderArgInfo &p, vector_string &words, int &next) { if (words[next] != "") { @@ -270,11 +248,9 @@ cp_parse_eol(ShaderArgInfo &p, vector_string &words, int &next) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_parse_delimiter -// Access: Public -// Description: Pop a delimiter ('to' or 'rel') from the word list. -//////////////////////////////////////////////////////////////////// +/** + * Pop a delimiter ('to' or 'rel') from the word list. + */ bool Shader:: cp_parse_delimiter(ShaderArgInfo &p, vector_string &words, int &next) { if ((words[next] != "to")&&(words[next] != "rel")) { @@ -285,12 +261,10 @@ cp_parse_delimiter(ShaderArgInfo &p, vector_string &words, int &next) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_parse_non_delimiter -// Access: Public -// Description: Pop a non-delimiter word from the word list. -// Delimiters are 'to' and 'rel.' -//////////////////////////////////////////////////////////////////// +/** + * Pop a non-delimiter word from the word list. Delimiters are 'to' and + * 'rel.' + */ string Shader:: cp_parse_non_delimiter(vector_string &words, int &next) { const string &nword = words[next]; @@ -301,12 +275,10 @@ cp_parse_non_delimiter(vector_string &words, int &next) { return nword; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_parse_coord_sys -// Access: Public -// Description: Convert a single-word coordinate system name into -// a PART/ARG of a ShaderMatSpec. -//////////////////////////////////////////////////////////////////// +/** + * Convert a single-word coordinate system name into a PART/ARG of a + * ShaderMatSpec. + */ bool Shader:: cp_parse_coord_sys(ShaderArgInfo &p, vector_string &pieces, int &next, @@ -390,13 +362,10 @@ cp_parse_coord_sys(ShaderArgInfo &p, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_dependency -// Access: Public -// Description: Given ShaderMatInput, returns an indication of what -// part or parts of the state_and_transform the -// ShaderMatInput depends upon. -//////////////////////////////////////////////////////////////////// +/** + * Given ShaderMatInput, returns an indication of what part or parts of the + * state_and_transform the ShaderMatInput depends upon. + */ int Shader:: cp_dependency(ShaderMatInput inp) { @@ -470,8 +439,8 @@ cp_dependency(ShaderMatInput inp) { (inp == SMO_view_to_clip_x) || (inp == SMO_apiclip_x_to_view) || (inp == SMO_view_to_apiclip_x)) { - // We can't track changes to these yet, so we have to assume that - // they are modified every frame. + // We can't track changes to these yet, so we have to assume that they + // are modified every frame. dep |= SSD_frame; } } @@ -516,15 +485,12 @@ cp_dependency(ShaderMatInput inp) { return dep; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cp_optimize_mat_spec -// Access: Public -// Description: Analyzes a ShaderMatSpec and decides what it should -// use its cache for. It can cache the results of any -// one opcode, or, it can cache the entire result. This -// routine needs to be smart enough to know which -// data items can be correctly cached, and which cannot. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes a ShaderMatSpec and decides what it should use its cache for. It + * can cache the results of any one opcode, or, it can cache the entire + * result. This routine needs to be smart enough to know which data items can + * be correctly cached, and which cannot. + */ void Shader:: cp_optimize_mat_spec(ShaderMatSpec &spec) { @@ -591,11 +557,9 @@ cp_optimize_mat_spec(ShaderMatSpec &spec) { } #ifdef HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_recurse_parameters -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Shader:: cg_recurse_parameters(CGparameter parameter, const ShaderType &type, bool &success) { @@ -662,24 +626,20 @@ cg_recurse_parameters(CGparameter parameter, const ShaderType &type, } #endif // HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: Shader::compile_parameter -// Access: Public -// Description: Analyzes a parameter and decides how to -// bind the parameter to some part of panda's -// internal state. Updates one of the bind -// arrays to cause the binding to occur. -// -// If there is an error, this routine will append -// an error message onto the error messages. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes a parameter and decides how to bind the parameter to some part of + * panda's internal state. Updates one of the bind arrays to cause the + * binding to occur. + * + * If there is an error, this routine will append an error message onto the + * error messages. + */ bool Shader:: compile_parameter(ShaderArgInfo &p, int *arg_dim) { if (p._id._name.size() == 0) return true; if (p._id._name[0] == '$') return true; - // It could be inside a struct, strip off - // everything before the last dot. + // It could be inside a struct, strip off everything before the last dot. size_t loc = p._id._name.find_last_of('.'); string basename (p._id._name); @@ -769,8 +729,8 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { return true; } - // Implement some macros. Macros work by altering the - // contents of the 'pieces' array, and then falling through. + // Implement some macros. Macros work by altering the contents of the + // 'pieces' array, and then falling through. if (pieces[0] == "mstrans") { pieces[0] = "trans"; @@ -1370,9 +1330,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { bind._arg = kinputname; bind._info = p; - // We specify SSD_frame because a PTA may be modified by the app - // from frame to frame, and we have no way to know. So, we must - // respecify a PTA at least once every frame. + // We specify SSD_frame because a PTA may be modified by the app from + // frame to frame, and we have no way to know. So, we must respecify a + // PTA at least once every frame. bind._dep[0] = SSD_general | SSD_shaderinputs | SSD_frame; bind._dep[1] = SSD_NONE; @@ -1463,11 +1423,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::clear_parameters -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Shader:: clear_parameters() { _mat_spec.clear(); @@ -1475,12 +1433,9 @@ clear_parameters() { _tex_spec.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::set_compiled -// Access: Private -// Description: Called by the back-end when the shader has compiled -// data available. -//////////////////////////////////////////////////////////////////// +/** + * Called by the back-end when the shader has compiled data available. + */ void Shader:: set_compiled(unsigned int format, const char *data, size_t length) { _compiled_format = format; @@ -1495,11 +1450,9 @@ set_compiled(unsigned int format, const char *data, size_t length) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::get_compiled -// Access: Private -// Description: Called by the back-end to retrieve compiled data. -//////////////////////////////////////////////////////////////////// +/** + * Called by the back-end to retrieve compiled data. + */ bool Shader:: get_compiled(unsigned int &format, string &binary) const { format = _compiled_format; @@ -1508,11 +1461,9 @@ get_compiled(unsigned int &format, string &binary) const { } #ifdef HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_parameter_type -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Shader::ShaderArgType Shader:: cg_parameter_type(CGparameter p) { switch (cgGetParameterClass(p)) { @@ -1581,11 +1532,9 @@ cg_parameter_type(CGparameter p) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_parameter_class -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Shader::ShaderArgClass Shader::cg_parameter_class(CGparameter p) { switch (cgGetParameterClass(p)) { case CG_PARAMETERCLASS_SCALAR: return Shader::SAC_scalar; @@ -1597,11 +1546,9 @@ Shader::ShaderArgClass Shader::cg_parameter_class(CGparameter p) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_parameter_dir -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Shader::ShaderArgDir Shader:: cg_parameter_dir(CGparameter p) { switch (cgGetParameterDirection(p)) { @@ -1612,11 +1559,9 @@ cg_parameter_dir(CGparameter p) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_release_resources -// Access: Private -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ void Shader:: cg_release_resources() { if (_cg_vprogram != 0) { @@ -1633,11 +1578,9 @@ cg_release_resources() { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_compile_entry_point -// Access: Private -// Description: xyz -//////////////////////////////////////////////////////////////////// +/** + * xyz + */ CGprogram Shader:: cg_compile_entry_point(const char *entry, const ShaderCaps &caps, CGcontext context, ShaderType type) { @@ -1779,13 +1722,11 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_compile_shader -// Access: Private -// Description: Compiles a Cg shader for a given set of capabilities. -// If successful, the shader is stored in the instance -// variables _cg_context, _cg_vprogram, _cg_fprogram. -//////////////////////////////////////////////////////////////////// +/** + * Compiles a Cg shader for a given set of capabilities. If successful, the + * shader is stored in the instance variables _cg_context, _cg_vprogram, + * _cg_fprogram. + */ bool Shader:: cg_compile_shader(const ShaderCaps &caps, CGcontext context) { _cg_last_caps = caps; @@ -1852,11 +1793,9 @@ cg_compile_shader(const ShaderCaps &caps, CGcontext context) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_analyze_entry_point -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Shader:: cg_analyze_entry_point(CGprogram prog, ShaderType type) { bool success = true; @@ -1865,38 +1804,30 @@ cg_analyze_entry_point(CGprogram prog, ShaderType type) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_analyze_shader -// Access: Private -// Description: This subroutine analyzes the parameters of a Cg -// shader. The output is stored in instance variables: -// _mat_spec, _var_spec, and _tex_spec. -// -// In order to do this, it is necessary to compile the -// shader. It would be a waste of CPU time to compile -// the shader, analyze the parameters, and then discard -// the compiled shader. This would force us to compile it -// again later, when we need to build the ShaderContext. -// Instead, we cache the compiled Cg program in instance -// variables. Later, a ShaderContext can pull the -// compiled shader from these instance vars. -// -// To compile a shader, you need to first choose a profile. -// There are two contradictory objectives: -// -// 1. If you don't use the gsg's active profile, -// then the cached compiled shader will not be useful to -// the ShaderContext. -// -// 2. If you use too weak a profile, then the shader may -// not compile. So to guarantee success, you should use -// the ultimate profile. -// -// To resolve this conflict, we try the active profile -// first, and if that doesn't work, we try the ultimate -// profile. -// -//////////////////////////////////////////////////////////////////// +/** + * This subroutine analyzes the parameters of a Cg shader. The output is + * stored in instance variables: _mat_spec, _var_spec, and _tex_spec. + * + * In order to do this, it is necessary to compile the shader. It would be a + * waste of CPU time to compile the shader, analyze the parameters, and then + * discard the compiled shader. This would force us to compile it again + * later, when we need to build the ShaderContext. Instead, we cache the + * compiled Cg program in instance variables. Later, a ShaderContext can pull + * the compiled shader from these instance vars. + * + * To compile a shader, you need to first choose a profile. There are two + * contradictory objectives: + * + * 1. If you don't use the gsg's active profile, then the cached compiled + * shader will not be useful to the ShaderContext. + * + * 2. If you use too weak a profile, then the shader may not compile. So to + * guarantee success, you should use the ultimate profile. + * + * To resolve this conflict, we try the active profile first, and if that + * doesn't work, we try the ultimate profile. + * + */ bool Shader:: cg_analyze_shader(const ShaderCaps &caps) { @@ -1946,8 +1877,8 @@ cg_analyze_shader(const ShaderCaps &caps) { } } - // Assign sequence numbers to all parameters. GLCgShaderContext relies - // on the fact that the varyings start at seqno 0. + // Assign sequence numbers to all parameters. GLCgShaderContext relies on + // the fact that the varyings start at seqno 0. int seqno = 0; for (int i=0; i<(int)_var_spec.size(); i++) { _var_spec[i]._id._seqno = seqno++; @@ -1964,89 +1895,52 @@ cg_analyze_shader(const ShaderCaps &caps) { _ptr_spec[i]._info._id = _ptr_spec[i]._id; } - // // The following code is present to work around a bug in the Cg compiler. - // // It does not generate correct code for shadow map lookups when using arbfp1. - // // This is a particularly onerous limitation, given that arbfp1 is the only - // // Cg target that works on radeons. I suspect this is an intentional - // // omission on nvidia's part. The following code fetches the output listing, - // // detects the error, repairs the code, and resumbits the repaired code to Cg. - // if ((_cg_fprofile == CG_PROFILE_ARBFP1) && (gsghint->_supports_shadow_filter)) { - // bool shadowunit[32]; - // bool anyshadow = false; - // memset(shadowunit, 0, sizeof(shadowunit)); - // vector_string lines; - // tokenize(cgGetProgramString(_cg_program[SHADER_type_frag], - // CG_COMPILED_PROGRAM), lines, "\n"); - // // figure out which texture units contain shadow maps. - // for (int lineno=0; lineno<(int)lines.size(); lineno++) { - // if (lines[lineno].compare(0,21,"#var sampler2DSHADOW ")) { - // continue; - // } - // vector_string fields; - // tokenize(lines[lineno], fields, ":"); - // if (fields.size()!=5) { - // continue; - // } - // vector_string words; - // tokenize(trim(fields[2]), words, " "); - // if (words.size()!=2) { - // continue; - // } - // int unit = atoi(words[1].c_str()); - // if ((unit < 0)||(unit >= 32)) { - // continue; - // } - // anyshadow = true; - // shadowunit[unit] = true; - // } - // // modify all TEX statements that use the relevant texture units. - // if (anyshadow) { - // for (int lineno=0; lineno<(int)lines.size(); lineno++) { - // if (lines[lineno].compare(0,4,"TEX ")) { - // continue; - // } - // vector_string fields; - // tokenize(lines[lineno], fields, ","); - // if ((fields.size()!=4)||(trim(fields[3]) != "2D;")) { - // continue; - // } - // vector_string texunitf; - // tokenize(trim(fields[2]), texunitf, "[]"); - // if ((texunitf.size()!=3)||(texunitf[0] != "texture")||(texunitf[2]!="")) { - // continue; - // } - // int unit = atoi(texunitf[1].c_str()); - // if ((unit < 0) || (unit >= 32) || (shadowunit[unit]==false)) { - // continue; - // } - // lines[lineno] = fields[0]+","+fields[1]+","+fields[2]+", SHADOW2D;"; - // } - // string result = "!!ARBfp1.0\nOPTION ARB_fragment_program_shadow;\n"; - // for (int lineno=1; lineno<(int)lines.size(); lineno++) { - // result += (lines[lineno] + "\n"); - // } - // _cg_program[2] = _cg_program[SHADER_type_frag]; - // _cg_program[SHADER_type_frag] = - // cgCreateProgram(_cg_context, CG_OBJECT, result.c_str(), - // _cg_profile[SHADER_type_frag], "fshader", (const char**)NULL); - // cg_report_errors(s->get_name(), _cg_context); - // if (_cg_program[SHADER_type_frag]==0) { - // release_resources(); - // return false; - // } - // } - // } +/* + * The following code is present to work around a bug in the Cg compiler. It + * does not generate correct code for shadow map lookups when using arbfp1. + * This is a particularly onerous limitation, given that arbfp1 is the only Cg + * target that works on radeons. I suspect this is an intentional omission on + * nvidia's part. The following code fetches the output listing, detects the + * error, repairs the code, and resumbits the repaired code to Cg. if + * ((_cg_fprofile == CG_PROFILE_ARBFP1) && (gsghint->_supports_shadow_filter)) + * { bool shadowunit[32]; bool anyshadow = false; memset(shadowunit, 0, + * sizeof(shadowunit)); vector_string lines; + * tokenize(cgGetProgramString(_cg_program[SHADER_type_frag], + * CG_COMPILED_PROGRAM), lines, "\n"); figure out which texture units contain + * shadow maps. for (int lineno=0; lineno<(int)lines.size(); lineno++) { if + * (lines[lineno].compare(0,21,"#var sampler2DSHADOW ")) { continue; } + * vector_string fields; tokenize(lines[lineno], fields, ":"); if + * (fields.size()!=5) { continue; } vector_string words; + * tokenize(trim(fields[2]), words, " "); if (words.size()!=2) { continue; } + * int unit = atoi(words[1].c_str()); if ((unit < 0)||(unit >= 32)) { + * continue; } anyshadow = true; shadowunit[unit] = true; } modify all TEX + * statements that use the relevant texture units. if (anyshadow) { for (int + * lineno=0; lineno<(int)lines.size(); lineno++) { if + * (lines[lineno].compare(0,4,"TEX ")) { continue; } vector_string fields; + * tokenize(lines[lineno], fields, ","); if + * ((fields.size()!=4)||(trim(fields[3]) != "2D;")) { continue; } + * vector_string texunitf; tokenize(trim(fields[2]), texunitf, "[]"); if + * ((texunitf.size()!=3)||(texunitf[0] != "texture")||(texunitf[2]!="")) { + * continue; } int unit = atoi(texunitf[1].c_str()); if ((unit < 0) || (unit + * >= 32) || (shadowunit[unit]==false)) { continue; } lines[lineno] = + * fields[0]+","+fields[1]+","+fields[2]+", SHADOW2D;"; } string result = + * "!!ARBfp1.0\nOPTION ARB_fragment_program_shadow;\n"; for (int lineno=1; + * lineno<(int)lines.size(); lineno++) { result += (lines[lineno] + "\n"); } + * _cg_program[2] = _cg_program[SHADER_type_frag]; + * _cg_program[SHADER_type_frag] = cgCreateProgram(_cg_context, CG_OBJECT, + * result.c_str(), _cg_profile[SHADER_type_frag], "fshader", (const + * char**)NULL); cg_report_errors(s->get_name(), _cg_context); if + * (_cg_program[SHADER_type_frag]==0) { release_resources(); return false; } } + * } + */ cg_release_resources(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_program_from_shadertype -// Access: Private -// Description: Returns the CGprogram of the given shadertype -// that belongs to this shader. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CGprogram of the given shadertype that belongs to this shader. + */ CGprogram Shader:: cg_program_from_shadertype(ShaderType type) { switch (type) { @@ -2064,14 +1958,11 @@ cg_program_from_shadertype(ShaderType type) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_compile_for -// Access: Public -// Description: This routine is used by the ShaderContext constructor -// to compile the shader. The CGprogram -// objects are turned over to the ShaderContext, we no -// longer own them. -//////////////////////////////////////////////////////////////////// +/** + * This routine is used by the ShaderContext constructor to compile the + * shader. The CGprogram objects are turned over to the ShaderContext, we no + * longer own them. + */ bool Shader:: cg_compile_for(const ShaderCaps &caps, CGcontext context, CGprogram &combined_program, pvector &map) { @@ -2080,17 +1971,16 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, combined_program = 0; map.clear(); - // Make sure the shader is compiled for the target caps. - // Most of the time, it will already be - this is usually a no-op. + // Make sure the shader is compiled for the target caps. Most of the time, + // it will already be - this is usually a no-op. _default_caps = caps; if (!cg_compile_shader(caps, context)) { return false; } - // If the compile routine used the ultimate profile instead of the - // active one, it means the active one isn't powerful enough to - // compile the shader. + // If the compile routine used the ultimate profile instead of the active + // one, it means the active one isn't powerful enough to compile the shader. if (_cg_vprogram != 0 && _cg_vprofile != caps._active_vprofile) { shader_cat.error() << "Cg vertex program not supported by profile " << cgGetProfileString((CGprofile) caps._active_vprofile) << ": " @@ -2123,8 +2013,8 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, } // Combine the programs. This can be more optimal than loading them - // individually, and it is even necessary for some profiles - // (particularly GLSL profiles on non-NVIDIA GPUs). + // individually, and it is even necessary for some profiles (particularly + // GLSL profiles on non-NVIDIA GPUs). combined_program = cgCombinePrograms(programs.size(), &programs[0]); // Build a parameter map. @@ -2135,8 +2025,8 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, map.resize(n_mat + n_tex + n_var + n_ptr); - // This is a bit awkward, we have to go in and seperate out the - // combined program, since all the parameter bindings have changed. + // This is a bit awkward, we have to go in and seperate out the combined + // program, since all the parameter bindings have changed. CGprogram programs_by_type[ST_COUNT]; for (int i = 0; i < cgGetNumProgramDomains(combined_program); ++i) { // Conveniently, the CGdomain enum overlaps with ShaderType. @@ -2225,12 +2115,9 @@ cg_compile_for(const ShaderCaps &caps, CGcontext context, } #endif // HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: Shader::Constructor -// Access: Private -// Description: Construct a Shader that will be filled in using -// fillin() or read() later. -//////////////////////////////////////////////////////////////////// +/** + * Construct a Shader that will be filled in using fillin() or read() later. + */ Shader:: Shader(ShaderLanguage lang) : _error_flag(false), @@ -2262,12 +2149,10 @@ Shader(ShaderLanguage lang) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: Shader::read -// Access: Private -// Description: Reads the shader from the given filename(s). -// Returns a boolean indicating success or failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the shader from the given filename(s). Returns a boolean indicating + * success or failure. + */ bool Shader:: read(const ShaderFile &sfile, BamCacheRecord *record) { _text._separate = sfile._separate; @@ -2355,15 +2240,12 @@ read(const ShaderFile &sfile, BamCacheRecord *record) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::do_read_source -// Access: Private -// Description: Reads the shader file from the given path into the -// given string. -// -// Returns false if there was an error with this shader -// bad enough to consider it 'invalid'. -//////////////////////////////////////////////////////////////////// +/** + * Reads the shader file from the given path into the given string. + * + * Returns false if there was an error with this shader bad enough to consider + * it 'invalid'. + */ bool Shader:: do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { if (_language == SL_GLSL && glsl_preprocess) { @@ -2401,15 +2283,13 @@ do_read_source(string &into, const Filename &fn, BamCacheRecord *record) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::r_preprocess_source -// Access: Private -// Description: Loads a given GLSL file line by line, and processes -// any #pragma include and once statements. -// -// The set keeps track of which files we have already -// included, for checking recursive includes. -//////////////////////////////////////////////////////////////////// +/** + * Loads a given GLSL file line by line, and processes any #pragma include and + * once statements. + * + * The set keeps track of which files we have already included, for checking + * recursive includes. + */ bool Shader:: r_preprocess_source(ostream &out, const Filename &fn, const Filename &source_dir, @@ -2454,19 +2334,17 @@ r_preprocess_source(ostream &out, const Filename &fn, _last_modified = max(_last_modified, vf->get_timestamp()); _source_files.push_back(full_fn); - // We give each file an unique index. This is so that we can identify - // a particular shader in the error output. We offset them by 2048 - // so that they are more recognizable. GLSL doesn't give us anything - // more useful than that, unfortunately. - // - // Don't do this for the top-level file, though. We don't want - // anything to get in before a potential #version directive. + // We give each file an unique index. This is so that we can identify a + // particular shader in the error output. We offset them by 2048 so that + // they are more recognizable. GLSL doesn't give us anything more useful + // than that, unfortunately. Don't do this for the top-level file, though. + // We don't want anything to get in before a potential #version directive. int fileno = 0; if (depth > 0) { fileno = 2048 + _included_files.size(); - // Write it into the vector so that we can substitute it later - // when we are parsing the GLSL error log. Don't store the full - // filename because it would just be too long to display. + // Write it into the vector so that we can substitute it later when we are + // parsing the GLSL error log. Don't store the full filename because it + // would just be too long to display. _included_files.push_back(fn); out << "#line 1 " << fileno << " // " << fn << "\n"; @@ -2484,8 +2362,8 @@ r_preprocess_source(ostream &out, const Filename &fn, bool had_include = false; int lineno = 0; while (getline(*source, line)) { - // We always forward the actual line - the GLSL compiler will - // silently ignore #pragma lines anyway. + // We always forward the actual line - the GLSL compiler will silently + // ignore #pragma lines anyway. ++lineno; out << line << "\n"; @@ -2494,9 +2372,9 @@ r_preprocess_source(ostream &out, const Filename &fn, if (line.size() < 8 || sscanf(line.c_str(), " # pragma %63s", pragma) != 1) { - // One exception: check for an #endif after an include. We have - // to restore the line number in case the include happened under - // an #if block. + // One exception: check for an #endif after an include. We have to + // restore the line number in case the include happened under an #if + // block. int nread = 0; if (had_include && sscanf(line.c_str(), " # endif %n", &nread) == 0 && nread >= 6) { out << "#line " << (lineno + 1) << " " << fileno << "\n"; @@ -2518,8 +2396,8 @@ r_preprocess_source(ostream &out, const Filename &fn, } else if (sscanf(line.c_str(), " # pragma%*[ \t]include <%2047[^\"]> %n", incfile, &nread) == 1 && nread == line.size()) { - // Angled includes are also OK, but we don't search in the - // directory of the source file. + // Angled includes are also OK, but we don't search in the directory + // of the source file. incfn = incfile; } else { @@ -2569,12 +2447,10 @@ r_preprocess_source(ostream &out, const Filename &fn, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::check_modified -// Access: Private -// Description: Checks whether the shader or any of its dependent -// files were modified on disk. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the shader or any of its dependent files were modified on + * disk. + */ bool Shader:: check_modified() const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -2593,22 +2469,20 @@ check_modified() const { } #ifdef HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: Shader::cg_get_profile_from_header -// Access: Private -// Description: Determines the appropriate active shader profile settings -// based on any profile directives stored within the shader header -//////////////////////////////////////////////////////////////////// +/** + * Determines the appropriate active shader profile settings based on any + * profile directives stored within the shader header + */ void Shader:: cg_get_profile_from_header(ShaderCaps& caps) { - // Note this forces profile based on what is specified in the shader - // header string. Should probably be relying on card caps eventually. + // Note this forces profile based on what is specified in the shader header + // string. Should probably be relying on card caps eventually. string buf; parse_init(); - // Assume that if parse doesn't extend after a parse line then - // we've reached the end of _text + // Assume that if parse doesn't extend after a parse line then we've reached + // the end of _text int lastParse; do { @@ -2723,17 +2597,15 @@ cg_get_profile_from_header(ShaderCaps& caps) { } #endif -//////////////////////////////////////////////////////////////////// -// Function: Shader::Destructor -// Access: Public -// Description: Delete the compiled code, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Delete the compiled code, if it exists. + */ Shader:: ~Shader() { release_all(); - // Note: don't try to erase ourselves from the table. It currently - // keeps a reference forever, and so the only place where this - // constructor is called is in the destructor of the table itself. + // Note: don't try to erase ourselves from the table. It currently keeps a + // reference forever, and so the only place where this constructor is called + // is in the destructor of the table itself. /*if (_loaded) { _load_table.erase(_filename); } else { @@ -2741,11 +2613,9 @@ Shader:: }*/ } -//////////////////////////////////////////////////////////////////// -// Function: Shader::load -// Access: Published, Static -// Description: Loads the shader with the given filename. -//////////////////////////////////////////////////////////////////// +/** + * Loads the shader with the given filename. + */ PT(Shader) Shader:: load(const Filename &file, ShaderLanguage lang) { ShaderFile sfile(file); @@ -2771,12 +2641,9 @@ load(const Filename &file, ShaderLanguage lang) { return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::load -// Access: Published, Static -// Description: This variant of Shader::load loads all shader -// programs separately. -//////////////////////////////////////////////////////////////////// +/** + * This variant of Shader::load loads all shader programs separately. + */ PT(Shader) Shader:: load(ShaderLanguage lang, const Filename &vertex, const Filename &fragment, const Filename &geometry, @@ -2804,11 +2671,9 @@ load(ShaderLanguage lang, const Filename &vertex, return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::load_compute -// Access: Published, Static -// Description: Loads a compute shader. -//////////////////////////////////////////////////////////////////// +/** + * Loads a compute shader. + */ PT(Shader) Shader:: load_compute(ShaderLanguage lang, const Filename &fn) { if (lang != SL_GLSL) { @@ -2859,8 +2724,8 @@ load_compute(ShaderLanguage lang, const Filename &fn) { return NULL; } - // It makes little sense to cache the shader before compilation, so - // we keep the record for when we have the compiled the shader. + // It makes little sense to cache the shader before compilation, so we keep + // the record for when we have the compiled the shader. swap(shader->_record, record); shader->_cache_compiled_shader = BamCache::get_global_ptr()->get_cache_compiled_shaders(); shader->_fullpath = shader->_source_files[0]; @@ -2869,11 +2734,9 @@ load_compute(ShaderLanguage lang, const Filename &fn) { return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::make -// Access: Published, Static -// Description: Loads the shader, using the string as shader body. -//////////////////////////////////////////////////////////////////// +/** + * Loads the shader, using the string as shader body. + */ PT(Shader) Shader:: make(const string &body, ShaderLanguage lang) { if (lang == SL_GLSL) { @@ -2937,11 +2800,9 @@ make(const string &body, ShaderLanguage lang) { return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::make -// Access: Published, Static -// Description: Loads the shader, using the strings as shader bodies. -//////////////////////////////////////////////////////////////////// +/** + * Loads the shader, using the strings as shader bodies. + */ PT(Shader) Shader:: make(ShaderLanguage lang, const string &vertex, const string &fragment, const string &geometry, const string &tess_control, @@ -2988,11 +2849,9 @@ make(ShaderLanguage lang, const string &vertex, const string &fragment, return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::make_compute -// Access: Published, Static -// Description: Loads the compute shader from the given string. -//////////////////////////////////////////////////////////////////// +/** + * Loads the compute shader from the given string. + */ PT(Shader) Shader:: make_compute(ShaderLanguage lang, const string &body) { if (lang != SL_GLSL) { @@ -3024,24 +2883,19 @@ make_compute(ShaderLanguage lang, const string &body) { return shader; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::parse_init -// Access: Public -// Description: Set a 'parse pointer' to the beginning of the shader. -//////////////////////////////////////////////////////////////////// +/** + * Set a 'parse pointer' to the beginning of the shader. + */ void Shader:: parse_init() { _parse = 0; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::parse_line -// Access: Public -// Description: Parse a line of text. If 'lt' is true, trim blanks -// from the left end of the line. If 'rt' is true, trim -// blanks from the right end (the newline is always -// trimmed). -//////////////////////////////////////////////////////////////////// +/** + * Parse a line of text. If 'lt' is true, trim blanks from the left end of + * the line. If 'rt' is true, trim blanks from the right end (the newline is + * always trimmed). + */ void Shader:: parse_line(string &result, bool lt, bool rt) { nassertv(!_text._separate); @@ -3063,14 +2917,11 @@ parse_line(string &result, bool lt, bool rt) { result = _text._shared.substr(head, tail-head); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::parse_upto -// Access: Public -// Description: Parse lines until you read a line that matches the -// specified pattern. Returns all the preceding lines, -// and if the include flag is set, returns the final -// line as well. -//////////////////////////////////////////////////////////////////// +/** + * Parse lines until you read a line that matches the specified pattern. + * Returns all the preceding lines, and if the include flag is set, returns + * the final line as well. + */ void Shader:: parse_upto(string &result, string pattern, bool include) { nassertv(!_text._separate); @@ -3090,53 +2941,41 @@ parse_upto(string &result, string pattern, bool include) { } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::parse_rest -// Access: Public -// Description: Returns the rest of the text from the current -// parse location. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rest of the text from the current parse location. + */ void Shader:: parse_rest(string &result) { nassertv(!_text._separate); result = _text._shared.substr(_parse, _text._shared.size() - _parse); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::parse_eof -// Access: Public -// Description: Returns true if the parse pointer is at the end of -// the shader. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the parse pointer is at the end of the shader. + */ bool Shader:: parse_eof() { return (int)_text._shared.size() == _parse; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::prepare -// Access: Published -// Description: Indicates that the shader should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. This will ensure the -// texture is already loaded into texture memory if it -// is expected to be rendered soon. -// -// Use this function instead of prepare_now() to preload -// textures from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the shader should be enqueued to be prepared in the + * indicated prepared_objects at the beginning of the next frame. This will + * ensure the texture is already loaded into texture memory if it is expected + * to be rendered soon. + * + * Use this function instead of prepare_now() to preload textures from a user + * interface standpoint. + */ void Shader:: prepare(PreparedGraphicsObjects *prepared_objects) { prepared_objects->enqueue_shader(this); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::is_prepared -// Access: Published -// Description: Returns true if the shader has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool Shader:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { Contexts::const_iterator ci; @@ -3147,13 +2986,10 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_shader_queued(this); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::release -// Access: Published -// Description: Frees the texture context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the texture context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ bool Shader:: release(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -3172,22 +3008,17 @@ release(PreparedGraphicsObjects *prepared_objects) { return prepared_objects->dequeue_shader(this); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::prepare_now -// Access: Published -// Description: Creates a context for the shader on the particular -// GSG, if it does not already exist. Returns the new -// (or old) ShaderContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// textures. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a shader does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the shader on the particular GSG, if it does not + * already exist. Returns the new (or old) ShaderContext. This assumes that + * the GraphicsStateGuardian is the currently active rendering context and + * that it is ready to accept new textures. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a shader does not need to be explicitly prepared by the user before it may + * be rendered. + */ ShaderContext *Shader:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { @@ -3203,15 +3034,12 @@ prepare_now(PreparedGraphicsObjects *prepared_objects, return tc; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::clear_prepared -// Access: Private -// Description: Removes the indicated PreparedGraphicsObjects table -// from the Shader's table, without actually releasing -// the texture. This is intended to be called only from -// PreparedGraphicsObjects::release_texture(); it should -// never be called by user code. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PreparedGraphicsObjects table from the Shader's + * table, without actually releasing the texture. This is intended to be + * called only from PreparedGraphicsObjects::release_texture(); it should + * never be called by user code. + */ void Shader:: clear_prepared(PreparedGraphicsObjects *prepared_objects) { Contexts::iterator ci; @@ -3219,25 +3047,22 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) { if (ci != _contexts.end()) { _contexts.erase(ci); } else { - // If this assertion fails, clear_prepared() was given a - // prepared_objects which the texture didn't know about. + // If this assertion fails, clear_prepared() was given a prepared_objects + // which the texture didn't know about. nassertv(false); } } -//////////////////////////////////////////////////////////////////// -// Function: Shader::release_all -// Access: Published -// Description: Frees the context allocated on all objects for which -// the texture has been declared. Returns the number of -// contexts which have been freed. -//////////////////////////////////////////////////////////////////// +/** + * Frees the context allocated on all objects for which the texture has been + * declared. Returns the number of contexts which have been freed. + */ int Shader:: release_all() { // We have to traverse a copy of the _contexts list, because the - // PreparedGraphicsObjects object will call clear_prepared() in response - // to each release_texture(), and we don't want to be modifying the - // _contexts list while we're traversing it. + // PreparedGraphicsObjects object will call clear_prepared() in response to + // each release_texture(), and we don't want to be modifying the _contexts + // list while we're traversing it. Contexts temp = _contexts; int num_freed = (int)_contexts.size(); @@ -3250,18 +3075,16 @@ release_all() { } } - // There might still be some outstanding contexts in the map, if - // there were any NULL pointers there. Eliminate them. + // There might still be some outstanding contexts in the map, if there were + // any NULL pointers there. Eliminate them. _contexts.clear(); return num_freed; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::ShaderCapabilities::clear() -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Shader::ShaderCaps:: clear() { _supports_glsl = false; @@ -3276,23 +3099,18 @@ clear() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Shader::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Shader. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Shader. + */ void Shader:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Shader:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint8(_language); @@ -3304,14 +3122,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_string(_compiled_binary); } -//////////////////////////////////////////////////////////////////// -// Function: Shader::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Shader is encountered -// in the Bam file. It should create the Shader -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Shader is encountered in the Bam file. It should create the Shader + * and extract its information from the file. + */ TypedWritable *Shader:: make_from_bam(const FactoryParams ¶ms) { Shader *attrib = new Shader(SL_none); @@ -3323,13 +3138,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: Shader::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Shader. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Shader. + */ void Shader:: fillin(DatagramIterator &scan, BamReader *manager) { _language = (ShaderLanguage) scan.get_uint8(); diff --git a/panda/src/gobj/shader.h b/panda/src/gobj/shader.h index 3ee510389c..dbdde6f5ba 100644 --- a/panda/src/gobj/shader.h +++ b/panda/src/gobj/shader.h @@ -1,16 +1,17 @@ -// Filename: shader.h -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE(29Apr10) (added SAT_sampler2dArray) -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shader.h + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #ifndef SHADER_H #define SHADER_H @@ -33,8 +34,8 @@ #include "epvector.h" #ifdef HAVE_CG -// I don't want to include the Cg header file into panda as a -// whole. Instead, I'll just excerpt some opaque declarations. +// I don't want to include the Cg header file into panda as a whole. Instead, +// I'll just excerpt some opaque declarations. typedef struct _CGcontext *CGcontext; typedef struct _CGprogram *CGprogram; typedef struct _CGparameter *CGparameter; @@ -42,13 +43,9 @@ typedef struct _CGparameter *CGparameter; class BamCacheRecord; -//////////////////////////////////////////////////////////////////// -// Class : Shader -// Summary: The Shader class is meant to select the Shader Language, -// select the available profile, compile the shader, and -// finally compile and store the shader parameters -// in the appropriate structure. -//////////////////////////////////////////////////////////////////// +/** + + */ class EXPCL_PANDA_GOBJ Shader : public TypedWritableReferenceCount { PUBLISHED: enum ShaderLanguage { @@ -477,9 +474,9 @@ public: }; public: - // These routines help split the shader into sections, - // for those shader implementations that need to do so. - // Don't use them when you use separate shader programs. + // These routines help split the shader into sections, for those shader + // implementations that need to do so. Don't use them when you use separate + // shader programs. void parse_init(); void parse_line(string &result, bool rt, bool lt); void parse_upto(string &result, string pattern, bool include); @@ -534,8 +531,9 @@ private: void cg_release_resources(); void cg_report_errors(); - // Determines the appropriate cg profile settings and stores them in the active shader caps - // based on any profile settings stored in the shader's header + // Determines the appropriate cg profile settings and stores them in the + // active shader caps based on any profile settings stored in the shader's + // header void cg_get_profile_from_header(ShaderCaps &caps); ShaderCaps _cg_last_caps; @@ -576,8 +574,8 @@ protected: typedef pvector Filenames; Filenames _included_files; - // Stores full paths, and includes the fullpaths of the shaders - // themselves as well as the includes. + // Stores full paths, and includes the fullpaths of the shaders themselves + // as well as the includes. Filenames _source_files; time_t _last_modified; diff --git a/panda/src/gobj/shaderContext.I b/panda/src/gobj/shaderContext.I index d0106632b9..5cd06d20bf 100644 --- a/panda/src/gobj/shaderContext.I +++ b/panda/src/gobj/shaderContext.I @@ -1,33 +1,28 @@ -// Filename: shaderContext.I -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderContext.I + * @author jyelon + * @date 2005-09-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: ShaderContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderContext:: ShaderContext(Shader *se) : _shader(se) { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderContext::get_expansion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Shader *ShaderContext:: get_shader() const { return _shader; diff --git a/panda/src/gobj/shaderContext.cxx b/panda/src/gobj/shaderContext.cxx index 493605d08d..2a824332bc 100644 --- a/panda/src/gobj/shaderContext.cxx +++ b/panda/src/gobj/shaderContext.cxx @@ -1,20 +1,18 @@ -// Filename: shaderContext.cxx -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderContext.cxx + * @author jyelon + * @date 2005-09-01 + */ #include "shaderContext.h" #include "texture.h" #include "string_utils.h" TypeHandle ShaderContext::_type_handle; - diff --git a/panda/src/gobj/shaderContext.h b/panda/src/gobj/shaderContext.h index 424d6df0e9..2b356cef8f 100644 --- a/panda/src/gobj/shaderContext.h +++ b/panda/src/gobj/shaderContext.h @@ -1,16 +1,15 @@ -// Filename: shaderContext.h -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderContext.h + * @author jyelon + * @date 2005-09-01 + */ #ifndef SHADERCONTEXT_H #define SHADERCONTEXT_H @@ -20,17 +19,14 @@ #include "savedContext.h" #include "shader.h" -//////////////////////////////////////////////////////////////////// -// Class : ShaderContext -// Description : The ShaderContext is meant to contain the compiled -// version of a shader string. ShaderContext is an -// abstract base class, there will be a subclass of it -// for each shader language and graphics API. -// Since the languages are so different and the -// graphics APIs have so little in common, the base -// class contains almost nothing. All the implementation -// details are in the subclasses. -//////////////////////////////////////////////////////////////////// +/** + * The ShaderContext is meant to contain the compiled version of a shader + * string. ShaderContext is an abstract base class, there will be a subclass + * of it for each shader language and graphics API. Since the languages are so + * different and the graphics APIs have so little in common, the base class + * contains almost nothing. All the implementation details are in the + * subclasses. + */ class EXPCL_PANDA_GOBJ ShaderContext: public SavedContext { public: diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index e42694f14a..e537526d8a 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -1,25 +1,21 @@ -// Filename: simpleAllocator.I -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleAllocator.I + * @author drose + * @date 2007-05-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SimpleAllocator:: -SimpleAllocator(size_t max_size, Mutex &lock) : +SimpleAllocator(size_t max_size, Mutex &lock) : LinkedListNode(true), _total_size(0), _max_size(max_size), @@ -28,118 +24,97 @@ SimpleAllocator(size_t max_size, Mutex &lock) : { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::alloc -// Access: Published -// Description: Allocates a new block. Returns NULL if a block of the -// requested size cannot be allocated. -// -// To free the allocated block, call block->free(), or -// simply delete the block pointer. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new block. Returns NULL if a block of the requested size + * cannot be allocated. + * + * To free the allocated block, call block->free(), or simply delete the block + * pointer. + */ SimpleAllocatorBlock *SimpleAllocator:: alloc(size_t size) { MutexHolder holder(_lock); return do_alloc(size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::is_empty -// Access: Published -// Description: Returns true if there are no blocks allocated on this -// page, or false if there is at least one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no blocks allocated on this page, or false if + * there is at least one. + */ INLINE bool SimpleAllocator:: is_empty() const { MutexHolder holder(_lock); return do_is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::get_total_size -// Access: Published -// Description: Returns the total size of allocated objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of allocated objects. + */ INLINE size_t SimpleAllocator:: get_total_size() const { MutexHolder holder(_lock); return _total_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::get_max_size -// Access: Published -// Description: Returns the available space for allocated objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the available space for allocated objects. + */ INLINE size_t SimpleAllocator:: get_max_size() const { MutexHolder holder(_lock); return _max_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::set_max_size -// Access: Published -// Description: Changes the available space for allocated objects. -// This will not affect any already-allocated objects, -// but will have an effect on future calls to alloc(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the available space for allocated objects. This will not affect + * any already-allocated objects, but will have an effect on future calls to + * alloc(). + */ INLINE void SimpleAllocator:: set_max_size(size_t max_size) { MutexHolder holder(_lock); _max_size = max_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::get_contiguous -// Access: Published -// Description: Returns an upper-bound estimate of the size of the -// largest contiguous block that may be allocated. It -// is guaranteed that an attempt to allocate a block -// larger than this will fail, though it is not -// guaranteed that an attempt to allocate a block this -// size or smaller will succeed. -//////////////////////////////////////////////////////////////////// +/** + * Returns an upper-bound estimate of the size of the largest contiguous block + * that may be allocated. It is guaranteed that an attempt to allocate a + * block larger than this will fail, though it is not guaranteed that an + * attempt to allocate a block this size or smaller will succeed. + */ INLINE size_t SimpleAllocator:: get_contiguous() const { MutexHolder holder(_lock); return _contiguous; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::get_first_block -// Access: Published -// Description: Returns a pointer to the first allocated block, or -// NULL if there are no allocated blocks. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the first allocated block, or NULL if there are no + * allocated blocks. + */ INLINE SimpleAllocatorBlock *SimpleAllocator:: get_first_block() const { MutexHolder holder(_lock); return (_next == this) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::do_is_empty -// Access: Protected -// Description: Returns true if there are no blocks allocated on this -// page, or false if there is at least one. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no blocks allocated on this page, or false if + * there is at least one. + * + * Assumes the lock is already held. + */ INLINE bool SimpleAllocator:: do_is_empty() const { return (_next == this); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::mark_contiguous -// Access: Protected -// Description: Some space has been made available following the -// indicated block. Increase the contiguous space -// accordingly. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Some space has been made available following the indicated block. Increase + * the contiguous space accordingly. + * + * Assumes the lock is already held. + */ INLINE void SimpleAllocator:: mark_contiguous(const LinkedListNode *block) { size_t space; @@ -160,12 +135,10 @@ mark_contiguous(const LinkedListNode *block) { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::Constructor -// Access: Private -// Description: A SimpleAllocatorBlock must be constructed via the -// SimpleAllocator::alloc() call. -//////////////////////////////////////////////////////////////////// +/** + * A SimpleAllocatorBlock must be constructed via the SimpleAllocator::alloc() + * call. + */ INLINE SimpleAllocatorBlock:: SimpleAllocatorBlock(SimpleAllocator *alloc, size_t start, size_t size) : @@ -175,22 +148,17 @@ SimpleAllocatorBlock(SimpleAllocator *alloc, { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::Destructor -// Access: Published -// Description: The block automatically frees itself when it -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * The block automatically frees itself when it destructs. + */ INLINE SimpleAllocatorBlock:: ~SimpleAllocatorBlock() { free(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::free -// Access: Published -// Description: Releases the allocated space. -//////////////////////////////////////////////////////////////////// +/** + * Releases the allocated space. + */ INLINE void SimpleAllocatorBlock:: free() { if (_allocator != (SimpleAllocator *)NULL) { @@ -199,58 +167,47 @@ free() { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::get_allocator -// Access: Published -// Description: Returns the SimpleAllocator object that owns this -// block. Returns NULL if the block has been freed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SimpleAllocator object that owns this block. Returns NULL if + * the block has been freed. + */ INLINE SimpleAllocator *SimpleAllocatorBlock:: get_allocator() const { return _allocator; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::get_start -// Access: Published -// Description: Returns the starting point of this block. It is an -// error to call this if the block has been freed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the starting point of this block. It is an error to call this if + * the block has been freed. + */ INLINE size_t SimpleAllocatorBlock:: get_start() const { nassertr(_allocator != (SimpleAllocator *)NULL, 0); return _start; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::get_size -// Access: Published -// Description: Returns the size of this block. It is an -// error to call this if the block has been freed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of this block. It is an error to call this if the block + * has been freed. + */ INLINE size_t SimpleAllocatorBlock:: get_size() const { nassertr(_allocator != (SimpleAllocator *)NULL, 0); return _size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::is_free -// Access: Published -// Description: Returns true if the block has been freed, false if it -// is still valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the block has been freed, false if it is still valid. + */ INLINE bool SimpleAllocatorBlock:: is_free() const { return (_allocator != (SimpleAllocator *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::get_max_size -// Access: Published -// Description: Returns the maximum size this block can be -// reallocated to, as limited by the following block. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size this block can be reallocated to, as limited by + * the following block. + */ INLINE size_t SimpleAllocatorBlock:: get_max_size() const { nassertr(_allocator != (SimpleAllocator *)NULL, 0); @@ -258,13 +215,10 @@ get_max_size() const { return do_get_max_size(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::realloc -// Access: Published -// Description: Changes the size of this block to the specified size. -// Returns true if the change is accepted, false if -// there was not enough room. -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of this block to the specified size. Returns true if the + * change is accepted, false if there was not enough room. + */ INLINE bool SimpleAllocatorBlock:: realloc(size_t size) { nassertr(_allocator != (SimpleAllocator *)NULL, false); @@ -272,12 +226,10 @@ realloc(size_t size) { return do_realloc(size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::get_next_block -// Access: Published -// Description: Returns a pointer to the next allocated block in the -// chain, or NULL if there are no more allocated blocks. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the next allocated block in the chain, or NULL if + * there are no more allocated blocks. + */ INLINE SimpleAllocatorBlock *SimpleAllocatorBlock:: get_next_block() const { nassertr(_allocator != (SimpleAllocator *)NULL, NULL); @@ -285,13 +237,11 @@ get_next_block() const { return (_next == _allocator) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::do_free -// Access: Protected -// Description: Releases the allocated space. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Releases the allocated space. + * + * Assumes the lock is already held. + */ INLINE void SimpleAllocatorBlock:: do_free() { nassertv(_allocator != (SimpleAllocator *)NULL); @@ -303,14 +253,12 @@ do_free() { _allocator = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::do_get_max_size -// Access: Protected -// Description: Returns the maximum size this block can be -// reallocated to, as limited by the following block. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size this block can be reallocated to, as limited by + * the following block. + * + * Assumes the lock is already held. + */ INLINE size_t SimpleAllocatorBlock:: do_get_max_size() const { size_t end; @@ -322,15 +270,12 @@ do_get_max_size() const { return end - _start; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::do_realloc -// Access: Protected -// Description: Changes the size of this block to the specified size. -// Returns true if the change is accepted, false if -// there was not enough room. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of this block to the specified size. Returns true if the + * change is accepted, false if there was not enough room. + * + * Assumes the lock is already held. + */ INLINE bool SimpleAllocatorBlock:: do_realloc(size_t size) { if (size > do_get_max_size()) { diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index 8b0bd2a1de..ddae004ee8 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -1,24 +1,21 @@ -// Filename: simpleAllocator.cxx -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleAllocator.cxx + * @author drose + * @date 2007-05-12 + */ #include "simpleAllocator.h" -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SimpleAllocator:: ~SimpleAllocator() { // We're shutting down. Force-free everything remaining. @@ -31,49 +28,43 @@ SimpleAllocator:: } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleAllocator:: output(ostream &out) const { MutexHolder holder(_lock); - out << "SimpleAllocator, " << _total_size << " of " << _max_size + out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleAllocator:: write(ostream &out) const { MutexHolder holder(_lock); - out << "SimpleAllocator, " << _total_size << " of " << _max_size + out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; SimpleAllocatorBlock *block = (SimpleAllocatorBlock *)_next; while (block->_next != this) { SimpleAllocatorBlock *next = (SimpleAllocatorBlock *)block->_next; - + out << " " << *block << "\n"; block = next; } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::do_alloc -// Access: Protected -// Description: Allocates a new block. Returns NULL if a block of the -// requested size cannot be allocated. -// -// To free the allocated block, call block->free(), or -// simply delete the block pointer. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new block. Returns NULL if a block of the requested size + * cannot be allocated. + * + * To free the allocated block, call block->free(), or simply delete the block + * pointer. + * + * Assumes the lock is already held. + */ SimpleAllocatorBlock *SimpleAllocator:: do_alloc(size_t size) { if (size > _contiguous) { @@ -81,8 +72,8 @@ do_alloc(size_t size) { return NULL; } - // First fit algorithm: walk through all the empty blocks until we - // find one that has enough room. + // First fit algorithm: walk through all the empty blocks until we find one + // that has enough room. SimpleAllocatorBlock *block = NULL; size_t end = 0; @@ -104,9 +95,9 @@ do_alloc(size_t size) { _total_size += size; if (_max_size - _total_size < _contiguous) { - // Since we only have (_max_size - _total_size) bytes - // remaining, it follows that our largest contiguous block - // must be no larger than this. + // Since we only have (_max_size - _total_size) bytes remaining, it + // follows that our largest contiguous block must be no larger than + // this. _contiguous = _max_size - _total_size; changed_contiguous(); } @@ -115,7 +106,7 @@ do_alloc(size_t size) { if (free_size > best) { best = free_size; } - + block = next; end = block->_start + block->_size; } @@ -131,9 +122,9 @@ do_alloc(size_t size) { _total_size += size; if (_max_size - _total_size < _contiguous) { - // Since we only have (_max_size - _total_size) bytes - // remaining, it follows that our largest contiguous block - // must be no larger than this. + // Since we only have (_max_size - _total_size) bytes remaining, it + // follows that our largest contiguous block must be no larger than + // this. _contiguous = _max_size - _total_size; changed_contiguous(); } @@ -144,8 +135,8 @@ do_alloc(size_t size) { best = free_size; } - // Now that we've walked through the entire list of blocks, we - // really do know accurately what the largest contiguous block is. + // Now that we've walked through the entire list of blocks, we really do + // know accurately what the largest contiguous block is. if (_contiguous != best) { _contiguous = best; changed_contiguous(); @@ -155,33 +146,27 @@ do_alloc(size_t size) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::make_block -// Access: Protected, Virtual -// Description: Creates a new SimpleAllocatorBlock object. Override -// this function to specialize the block type returned. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new SimpleAllocatorBlock object. Override this function to + * specialize the block type returned. + */ SimpleAllocatorBlock *SimpleAllocator:: make_block(size_t start, size_t size) { return new SimpleAllocatorBlock(this, start, size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocator::changed_contiguous -// Access: Protected, Virtual -// Description: This callback function is made whenever the estimate -// of contiguous available space changes, either through -// an alloc or free. The lock will be held. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is made whenever the estimate of contiguous + * available space changes, either through an alloc or free. The lock will be + * held. + */ void SimpleAllocator:: changed_contiguous() { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleAllocatorBlock::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleAllocatorBlock:: output(ostream &out) const { if (_allocator == (SimpleAllocator *)NULL) { diff --git a/panda/src/gobj/simpleAllocator.h b/panda/src/gobj/simpleAllocator.h index f494697bec..4bc417c39c 100644 --- a/panda/src/gobj/simpleAllocator.h +++ b/panda/src/gobj/simpleAllocator.h @@ -1,16 +1,15 @@ -// Filename: simpleAllocator.h -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleAllocator.h + * @author drose + * @date 2007-05-12 + */ #ifndef SIMPLEALLOCATOR_H #define SIMPLEALLOCATOR_H @@ -22,14 +21,11 @@ class SimpleAllocatorBlock; -//////////////////////////////////////////////////////////////////// -// Class : SimpleAllocator -// Description : An implementation of a very simple block allocator. -// This class can allocate ranges of nonnegative -// integers within a specified upper limit; it uses a -// simple first-fit algorithm to find the next available -// space. -//////////////////////////////////////////////////////////////////// +/** + * An implementation of a very simple block allocator. This class can + * allocate ranges of nonnegative integers within a specified upper limit; it + * uses a simple first-fit algorithm to find the next available space. + */ class EXPCL_PANDA_GOBJ SimpleAllocator : public LinkedListNode { PUBLISHED: INLINE SimpleAllocator(size_t max_size, Mutex &lock); @@ -57,41 +53,39 @@ protected: virtual void changed_contiguous(); protected: - // This is implemented as a linked-list chain of allocated blocks. - // Free blocks are implicit. Blocks are kept in sorted order from - // beginning to end. Allocating a block means creating a new entry - // in the chain wherever it may fit; freeing a block means simply - // removing the allocated block from the chain. With this simple - // approach, there is no need to merge adjacent free blocks to - // straighten out fragmentation, since free blocks are not stored. - // However, it does mean we have to walk through a list of adjacent - // allocated blocks in order to find the free blocks. +/* + * This is implemented as a linked-list chain of allocated blocks. Free + * blocks are implicit. Blocks are kept in sorted order from beginning to + * end. Allocating a block means creating a new entry in the chain wherever + * it may fit; freeing a block means simply removing the allocated block from + * the chain. With this simple approach, there is no need to merge adjacent + * free blocks to straighten out fragmentation, since free blocks are not + * stored. However, it does mean we have to walk through a list of adjacent + * allocated blocks in order to find the free blocks. + */ size_t _total_size; size_t _max_size; - // This is what we currently believe our max contiguous space to be. - // This guess might be larger than the actual available space, but - // it will not be smaller. + // This is what we currently believe our max contiguous space to be. This + // guess might be larger than the actual available space, but it will not be + // smaller. size_t _contiguous; - // This mutex protects all operations within this class. The caller - // must pass the reference to a mutex in to the constructor, and the - // caller remains responsible for owning the mutex. This allows the - // mutex to be shared where appropriate. + // This mutex protects all operations within this class. The caller must + // pass the reference to a mutex in to the constructor, and the caller + // remains responsible for owning the mutex. This allows the mutex to be + // shared where appropriate. - // A derived class may also use it to protect itself as well, but - // take care to call do_alloc() instead of alloc() etc. as - // necessary. + // A derived class may also use it to protect itself as well, but take care + // to call do_alloc() instead of alloc() etc. as necessary. Mutex &_lock; friend class SimpleAllocatorBlock; }; -//////////////////////////////////////////////////////////////////// -// Class : SimpleAllocatorBlock -// Description : A single block as returned from -// SimpleAllocator::alloc(). -//////////////////////////////////////////////////////////////////// +/** + * A single block as returned from SimpleAllocator::alloc(). + */ class EXPCL_PANDA_GOBJ SimpleAllocatorBlock : public LinkedListNode { protected: INLINE SimpleAllocatorBlock(SimpleAllocator *alloc, diff --git a/panda/src/gobj/simpleLru.I b/panda/src/gobj/simpleLru.I index 09fb9618ac..fa872c7829 100644 --- a/panda/src/gobj/simpleLru.I +++ b/panda/src/gobj/simpleLru.I @@ -1,50 +1,41 @@ -// Filename: simpleLru.I -// Created by: drose (11May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleLru.I + * @author drose + * @date 2007-05-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::get_total_size -// Access: Published -// Description: Returns the total size of all objects currently -// active on the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all objects currently active on the LRU. + */ INLINE size_t SimpleLru:: get_total_size() const { LightMutexHolder holder(_global_lock); return _total_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::get_max_size -// Access: Published -// Description: Returns the max size of all objects that are allowed -// to be active on the LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the max size of all objects that are allowed to be active on the + * LRU. + */ INLINE size_t SimpleLru:: get_max_size() const { LightMutexHolder holder(_global_lock); return _max_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::set_max_size -// Access: Published -// Description: Changes the max size of all objects that are allowed -// to be active on the LRU. -// -// If the size is (size_t)-1, there is no limit. -//////////////////////////////////////////////////////////////////// +/** + * Changes the max size of all objects that are allowed to be active on the + * LRU. + * + * If the size is (size_t)-1, there is no limit. + */ INLINE void SimpleLru:: set_max_size(size_t max_size) { LightMutexHolder holder(_global_lock); @@ -54,11 +45,9 @@ set_max_size(size_t max_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::consider_evict -// Access: Published -// Description: Evicts a sequence of objects if the queue is full. -//////////////////////////////////////////////////////////////////// +/** + * Evicts a sequence of objects if the queue is full. + */ INLINE void SimpleLru:: consider_evict() { LightMutexHolder holder(_global_lock); @@ -67,13 +56,10 @@ consider_evict() { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::evict_to -// Access: Published -// Description: Evicts a sequence of objects until the queue fits -// within the indicated target size, regardless of its -// normal max size. -//////////////////////////////////////////////////////////////////// +/** + * Evicts a sequence of objects until the queue fits within the indicated + * target size, regardless of its normal max size. + */ INLINE void SimpleLru:: evict_to(size_t target_size) { LightMutexHolder holder(_global_lock); @@ -82,38 +68,30 @@ evict_to(size_t target_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::begin_epoch -// Access: Published -// Description: Marks the end of the previous epoch and the beginning -// of the next one. This will evict any objects that -// are pending eviction, and also update any internal -// bookkeeping. -//////////////////////////////////////////////////////////////////// +/** + * Marks the end of the previous epoch and the beginning of the next one. + * This will evict any objects that are pending eviction, and also update any + * internal bookkeeping. + */ INLINE void SimpleLru:: begin_epoch() { consider_evict(); _active_marker->enqueue_lru(this); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::validate -// Access: Published -// Description: Checks that the LRU is internally self-consistent. -// Returns true if successful, false if there is some -// problem. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the LRU is internally self-consistent. Returns true if + * successful, false if there is some problem. + */ INLINE bool SimpleLru:: validate() { LightMutexHolder holder(_global_lock); return do_validate(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SimpleLruPage:: SimpleLruPage(size_t lru_size) : _lru(NULL), @@ -121,11 +99,9 @@ SimpleLruPage(size_t lru_size) : { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SimpleLruPage:: SimpleLruPage(const SimpleLruPage ©) : _lru(NULL), @@ -133,33 +109,27 @@ SimpleLruPage(const SimpleLruPage ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::Copy Assignment Operator -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void SimpleLruPage:: operator = (const SimpleLruPage ©) { set_lru_size(copy.get_lru_size()); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::get_lru -// Access: Published -// Description: Returns the LRU that manages this page, or NULL if it -// is not currently managed by any LRU. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LRU that manages this page, or NULL if it is not currently + * managed by any LRU. + */ INLINE SimpleLru *SimpleLruPage:: get_lru() const { LightMutexHolder holder(SimpleLru::_global_lock); return _lru; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::dequeue_lru -// Access: Published -// Description: Removes the page from its SimpleLru. -//////////////////////////////////////////////////////////////////// +/** + * Removes the page from its SimpleLru. + */ INLINE void SimpleLruPage:: dequeue_lru() { LightMutexHolder holder(SimpleLru::_global_lock); @@ -171,15 +141,13 @@ dequeue_lru() { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::mark_used_lru -// Access: Published -// Description: To be called when the page is used; this will move it -// to the tail of the SimpleLru queue it is already on. -// -// This method is const because it's not technically -// modifying the contents of the page itself. -//////////////////////////////////////////////////////////////////// +/** + * To be called when the page is used; this will move it to the tail of the + * SimpleLru queue it is already on. + * + * This method is const because it's not technically modifying the contents of + * the page itself. + */ INLINE void SimpleLruPage:: mark_used_lru() const { if (_lru != (SimpleLru *)NULL) { @@ -187,34 +155,27 @@ mark_used_lru() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::mark_used_lru -// Access: Published -// Description: To be called when the page is used; this will move it -// to the tail of the specified SimpleLru queue. -//////////////////////////////////////////////////////////////////// +/** + * To be called when the page is used; this will move it to the tail of the + * specified SimpleLru queue. + */ INLINE void SimpleLruPage:: mark_used_lru(SimpleLru *lru) { enqueue_lru(lru); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::get_lru_size -// Access: Published -// Description: Returns the size of this page as reported to the LRU, -// presumably in bytes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of this page as reported to the LRU, presumably in bytes. + */ INLINE size_t SimpleLruPage:: get_lru_size() const { return _lru_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::set_lru_size -// Access: Published -// Description: Specifies the size of this page, presumably in bytes, -// although any unit is possible. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size of this page, presumably in bytes, although any unit is + * possible. + */ INLINE void SimpleLruPage:: set_lru_size(size_t lru_size) { LightMutexHolder holder(SimpleLru::_global_lock); diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index a1d7b01ae7..97e979df63 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -1,34 +1,31 @@ -// Filename: simpleLru.cxx -// Created by: drose (11May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleLru.cxx + * @author drose + * @date 2007-05-11 + */ #include "simpleLru.h" #include "indent.h" -// We define this as a reference to an allocated object, instead of as -// a concrete object, so that it won't get destructed when the program -// exits. (If it did, there would be an ordering issue between it and -// the various concrete SimpleLru objects which reference it.) +// We define this as a reference to an allocated object, instead of as a +// concrete object, so that it won't get destructed when the program exits. +// (If it did, there would be an ordering issue between it and the various +// concrete SimpleLru objects which reference it.) LightMutex &SimpleLru::_global_lock = *new LightMutex; -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SimpleLru:: -SimpleLru(const string &name, size_t max_size) : - LinkedListNode(true), +SimpleLru(const string &name, size_t max_size) : + LinkedListNode(true), Namable(name) { _total_size = 0; @@ -36,19 +33,17 @@ SimpleLru(const string &name, size_t max_size) : _active_marker = new SimpleLruPage(0); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SimpleLru:: ~SimpleLru() { delete _active_marker; #ifndef NDEBUG - // We're shutting down. Force-remove everything remaining, but - // don't explicitly evict it (that would force vertex buffers to - // write themselves to disk unnecessarily). + // We're shutting down. Force-remove everything remaining, but don't + // explicitly evict it (that would force vertex buffers to write themselves + // to disk unnecessarily). while (_next != (LinkedListNode *)this) { nassertv(_next != (LinkedListNode *)NULL); ((SimpleLruPage *)_next)->_lru = NULL; @@ -57,15 +52,12 @@ SimpleLru:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::enqueue_lru -// Access: Published -// Description: Adds the page to the LRU for the first time, or marks -// it recently-accessed if it has already been added. -// -// If lru is NULL, it means to remove this page from its -// LRU. -//////////////////////////////////////////////////////////////////// +/** + * Adds the page to the LRU for the first time, or marks it recently-accessed + * if it has already been added. + * + * If lru is NULL, it means to remove this page from its LRU. + */ void SimpleLruPage:: enqueue_lru(SimpleLru *lru) { LightMutexHolder holder(SimpleLru::_global_lock); @@ -91,17 +83,14 @@ enqueue_lru(SimpleLru *lru) { insert_before(_lru); } - // Let's not automatically evict pages; instead, we'll evict only on - // an explicit epoch test. - // _lru->consider_evict(); + // Let's not automatically evict pages; instead, we'll evict only on an + // explicit epoch test. _lru->consider_evict(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::count_active_size -// Access: Published -// Description: Returns the total size of the pages that were -// enqueued since the last call to begin_epoch(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of the pages that were enqueued since the last call + * to begin_epoch(). + */ size_t SimpleLru:: count_active_size() const { LightMutexHolder holder(_global_lock); @@ -116,11 +105,9 @@ count_active_size() const { return total; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleLru:: output(ostream &out) const { LightMutexHolder holder(_global_lock); @@ -128,18 +115,16 @@ output(ostream &out) const { << ", " << _total_size << " of " << _max_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleLru:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; - // We write out the list backwards. Things we write out first are - // the freshest in the LRU. Things at the end of the list will be - // the next to be evicted. + // We write out the list backwards. Things we write out first are the + // freshest in the LRU. Things at the end of the list will be the next to + // be evicted. LightMutexHolder holder(_global_lock); LinkedListNode *node = _prev; @@ -162,14 +147,11 @@ write(ostream &out, int indent_level) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::do_evict_to -// Access: Private -// Description: Evicts pages until the LRU is within the indicated -// size. Assumes the lock is already held. If -// hard_evict is false, does not evict "active" pages -// that were added within this epoch. -//////////////////////////////////////////////////////////////////// +/** + * Evicts pages until the LRU is within the indicated size. Assumes the lock + * is already held. If hard_evict is false, does not evict "active" pages + * that were added within this epoch. + */ void SimpleLru:: do_evict_to(size_t target_size, bool hard_evict) { if (_next == this) { @@ -177,9 +159,8 @@ do_evict_to(size_t target_size, bool hard_evict) { return; } - // Store the current end of the list. If pages re-enqueue - // themselves during this traversal, we don't want to visit them - // twice. + // Store the current end of the list. If pages re-enqueue themselves during + // this traversal, we don't want to visit them twice. SimpleLruPage *end = (SimpleLruPage *)_prev; // Now walk through the list. @@ -197,20 +178,18 @@ do_evict_to(size_t target_size, bool hard_evict) { return; } if (!hard_evict && node == _active_marker) { - // Also stop if we reach the active marker. Nodes beyond this - // were added within this epoch. + // Also stop if we reach the active marker. Nodes beyond this were + // added within this epoch. return; } node = next; } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLru::do_validate -// Access: Private -// Description: Checks that the LRU is internally consistent. Assume -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the LRU is internally consistent. Assume the lock is already + * held. + */ bool SimpleLru:: do_validate() { size_t total = 0; @@ -224,11 +203,9 @@ do_validate() { return (total == _total_size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SimpleLruPage:: ~SimpleLruPage() { if (_lru != NULL) { @@ -236,41 +213,32 @@ SimpleLruPage:: } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::evict_lru -// Access: Published, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void SimpleLruPage:: evict_lru() { dequeue_lru(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleLruPage:: output(ostream &out) const { out << "page " << this << ", " << _lru_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleLruPage::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SimpleLruPage:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; diff --git a/panda/src/gobj/simpleLru.h b/panda/src/gobj/simpleLru.h index da7ad94b08..16669e5a12 100644 --- a/panda/src/gobj/simpleLru.h +++ b/panda/src/gobj/simpleLru.h @@ -1,16 +1,15 @@ -// Filename: simpleLru.h -// Created by: drose (11May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleLru.h + * @author drose + * @date 2007-05-11 + */ #ifndef SIMPLELRU_H #define SIMPLELRU_H @@ -23,11 +22,9 @@ class SimpleLruPage; -//////////////////////////////////////////////////////////////////// -// Class : SimpleLru -// Description : An implementation of a very simple LRU algorithm. -// Also see AdaptiveLru. -//////////////////////////////////////////////////////////////////// +/** + * An implementation of a very simple LRU algorithm. Also see AdaptiveLru. + */ class EXPCL_PANDA_GOBJ SimpleLru : public LinkedListNode, public Namable { PUBLISHED: SimpleLru(const string &name, size_t max_size); @@ -61,12 +58,10 @@ private: friend class SimpleLruPage; }; -//////////////////////////////////////////////////////////////////// -// Class : SimpleLruPage -// Description : One atomic piece that may be managed by a SimpleLru -// chain. To use this class, inherit from it and -// override evict_lru(). -//////////////////////////////////////////////////////////////////// +/** + * One atomic piece that may be managed by a SimpleLru chain. To use this + * class, inherit from it and override evict_lru(). + */ class EXPCL_PANDA_GOBJ SimpleLruPage : public LinkedListNode { PUBLISHED: INLINE SimpleLruPage(size_t lru_size); diff --git a/panda/src/gobj/sliderTable.I b/panda/src/gobj/sliderTable.I index 1d76df7b85..959c2e8651 100644 --- a/panda/src/gobj/sliderTable.I +++ b/panda/src/gobj/sliderTable.I @@ -1,54 +1,43 @@ -// Filename: sliderTable.I -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sliderTable.I + * @author drose + * @date 2005-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::is_registered -// Access: Published -// Description: Returns true if this table has been registered. -// Once it has been registered, the set of sliders in -// a SliderTable may not be further modified; but -// it must be registered before it can be assigned to a -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this table has been registered. Once it has been + * registered, the set of sliders in a SliderTable may not be further + * modified; but it must be registered before it can be assigned to a Geom. + */ INLINE bool SliderTable:: is_registered() const { return _is_registered; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::register_table -// Access: Published, Static -// Description: Registers a SliderTable for use. This is -// similar to GeomVertexFormat::register_format(). Once -// registered, a SliderTable may no longer be -// modified (although the individual VertexSlider -// objects may modify their reported sliders). -// -// This must be called before a table may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Registers a SliderTable for use. This is similar to + * GeomVertexFormat::register_format(). Once registered, a SliderTable may no + * longer be modified (although the individual VertexSlider objects may modify + * their reported sliders). + * + * This must be called before a table may be used in a Geom. After this call, + * you should discard the original pointer you passed in (which may or may not + * now be invalid) and let its reference count decrement normally; you should + * use only the returned value from this point on. + */ INLINE CPT(SliderTable) SliderTable:: register_table(const SliderTable *table) { - // We don't actually bother adding the table object to a registry. - // This means there may be multiple copies of identical registered - // SliderTables. Big deal. We can always go back and make a - // registry later if we really need it. + // We don't actually bother adding the table object to a registry. This + // means there may be multiple copies of identical registered SliderTables. + // Big deal. We can always go back and make a registry later if we really + // need it. if (table->is_registered()) { return table; } @@ -57,46 +46,37 @@ register_table(const SliderTable *table) { return table; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::get_num_sliders -// Access: Published -// Description: Returns the number of sliders in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sliders in the table. + */ INLINE size_t SliderTable:: get_num_sliders() const { return _sliders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::get_slider -// Access: Published -// Description: Returns the nth slider in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth slider in the table. + */ INLINE const VertexSlider *SliderTable:: get_slider(size_t n) const { nassertr(n < _sliders.size(), NULL); return _sliders[n]._slider; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::get_slider_rows -// Access: Published -// Description: Returns the set of rows (vertices) governed by the -// nth slider in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of rows (vertices) governed by the nth slider in the table. + */ INLINE const SparseArray &SliderTable:: get_slider_rows(size_t n) const { nassertr(n < _sliders.size(), _empty_array); return _sliders[n]._rows; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::find_sliders -// Access: Published -// Description: Returns a list of slider indices that represent the -// list of sliders with the indicated name, or an empty -// SparseArray if no slider in the table has that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of slider indices that represent the list of sliders with + * the indicated name, or an empty SparseArray if no slider in the table has + * that name. + */ INLINE const SparseArray &SliderTable:: find_sliders(const InternalName *name) const { SlidersByName::const_iterator sni; @@ -107,70 +87,55 @@ find_sliders(const InternalName *name) const { return _empty_array; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::has_slider -// Access: Published -// Description: Returns true if the table has at least one slider by -// the indicated name, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the table has at least one slider by the indicated name, + * false otherwise. + */ INLINE bool SliderTable:: has_slider(const InternalName *name) const { return (!find_sliders(name).is_zero()); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::is_empty -// Access: Published -// Description: Returns true if the table has no sliders, false if it -// has at least one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the table has no sliders, false if it has at least one. + */ INLINE bool SliderTable:: is_empty() const { return _sliders.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::get_modified -// Access: Published -// Description: Returns a sequence number that's guaranteed to change -// at least when any VertexSliders in the table -// change. (However, this is only true for a registered -// table. An unregistered table may or may not -// reflect an update here when a VertexSlider -// changes.) -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number that's guaranteed to change at least when any + * VertexSliders in the table change. (However, this is only true for a + * registered table. An unregistered table may or may not reflect an update + * here when a VertexSlider changes.) + */ INLINE UpdateSeq SliderTable:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::update_modified -// Access: Private -// Description: Called internally whenever a nested VertexSlider -// reports that it has been modified. -//////////////////////////////////////////////////////////////////// +/** + * Called internally whenever a nested VertexSlider reports that it has been + * modified. + */ INLINE void SliderTable:: update_modified(UpdateSeq modified, Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); cdata->_modified = modified; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SliderTable::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SliderTable::CData:: CData(const SliderTable::CData ©) : _modified(copy._modified) diff --git a/panda/src/gobj/sliderTable.cxx b/panda/src/gobj/sliderTable.cxx index 25ebeb6479..169f023e3f 100644 --- a/panda/src/gobj/sliderTable.cxx +++ b/panda/src/gobj/sliderTable.cxx @@ -1,16 +1,15 @@ -// Filename: sliderTable.cxx -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sliderTable.cxx + * @author drose + * @date 2005-03-28 + */ #include "sliderTable.h" #include "bamReader.h" @@ -20,22 +19,18 @@ SparseArray SliderTable::_empty_array; TypeHandle SliderTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SliderTable:: SliderTable() : _is_registered(false) { } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SliderTable:: SliderTable(const SliderTable ©) : _is_registered(false), @@ -44,11 +39,9 @@ SliderTable(const SliderTable ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SliderTable:: operator = (const SliderTable ©) { nassertv(!_is_registered); @@ -56,11 +49,9 @@ operator = (const SliderTable ©) { _sliders_by_name = copy._sliders_by_name; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SliderTable:: ~SliderTable() { if (_is_registered) { @@ -68,12 +59,9 @@ SliderTable:: } } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::set_slider -// Access: Published -// Description: Replaces the nth slider. Only valid for -// unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the nth slider. Only valid for unregistered tables. + */ void SliderTable:: set_slider(size_t n, const VertexSlider *slider) { nassertv(!_is_registered); @@ -87,29 +75,23 @@ set_slider(size_t n, const VertexSlider *slider) { _sliders[n]._slider = slider; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::set_slider_rows -// Access: Published -// Description: Replaces the rows affected by the nth slider. Only -// valid for unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the rows affected by the nth slider. Only valid for unregistered + * tables. + */ void SliderTable:: set_slider_rows(size_t n, const SparseArray &rows) { - // We don't actually enforce the registration requirement, since - // gee, it doesn't actually matter here; and the GeomVertexData - // needs to be able to change the SparseArrays in the bam reader. - // nassertv(!_is_registered); + // We don't actually enforce the registration requirement, since gee, it + // doesn't actually matter here; and the GeomVertexData needs to be able to + // change the SparseArrays in the bam reader. nassertv(!_is_registered); nassertv(n < _sliders.size()); _sliders[n]._rows = rows; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::remove_slider -// Access: Published -// Description: Removes the nth slider. Only valid for -// unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth slider. Only valid for unregistered tables. + */ void SliderTable:: remove_slider(size_t n) { nassertv(!_is_registered); @@ -119,13 +101,10 @@ remove_slider(size_t n) { _sliders.erase(_sliders.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::add_slider -// Access: Published -// Description: Adds a new slider to the table, and returns the -// index number of the new slider. Only valid for -// unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new slider to the table, and returns the index number of the new + * slider. Only valid for unregistered tables. + */ size_t SliderTable:: add_slider(const VertexSlider *slider, const SparseArray &rows) { nassertr(!_is_registered, 0); @@ -141,24 +120,20 @@ add_slider(const VertexSlider *slider, const SparseArray &rows) { return new_index; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SliderTable:: write(ostream &out) const { for (size_t i = 0; i < _sliders.size(); ++i) { - out << i << ". " << *_sliders[i]._slider << " " + out << i << ". " << *_sliders[i]._slider << " " << _sliders[i]._rows << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::do_register -// Access: Private -// Description: Called internally when the table is registered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the table is registered. + */ void SliderTable:: do_register() { nassertv(!_is_registered); @@ -172,12 +147,10 @@ do_register() { _is_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::do_unregister -// Access: Private -// Description: Called internally when the table is unregistered -// (i.e. right before destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the table is unregistered (i.e. right before + * destruction). + */ void SliderTable:: do_unregister() { nassertv(_is_registered); @@ -190,23 +163,18 @@ do_unregister() { _is_registered = false; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// SliderTable. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type SliderTable. + */ void SliderTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SliderTable:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -222,13 +190,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int SliderTable:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -244,14 +209,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type SliderTable is encountered -// in the Bam file. It should create the SliderTable -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type SliderTable is encountered in the Bam file. It should create the + * SliderTable and extract its information from the file. + */ TypedWritable *SliderTable:: make_from_bam(const FactoryParams ¶ms) { SliderTable *object = new SliderTable; @@ -264,13 +226,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SliderTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SliderTable. + */ void SliderTable:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -285,41 +244,34 @@ fillin(DatagramIterator &scan, BamReader *manager) { _sliders[i]._rows.read_datagram(scan, manager); } else { // In this case, for bam files prior to 6.7, we must define the - // SparseArray with the full number of vertices. This is done - // in GeomVertexData::complete_pointers(). + // SparseArray with the full number of vertices. This is done in + // GeomVertexData::complete_pointers(). } } manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *SliderTable::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SliderTable::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: SliderTable::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SliderTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SliderTable. + */ void SliderTable::CData:: fillin(DatagramIterator &scan, BamReader *manager) { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/gobj/sliderTable.h b/panda/src/gobj/sliderTable.h index b6f8920800..9cc939c678 100644 --- a/panda/src/gobj/sliderTable.h +++ b/panda/src/gobj/sliderTable.h @@ -1,16 +1,15 @@ -// Filename: sliderTable.h -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sliderTable.h + * @author drose + * @date 2005-03-28 + */ #ifndef SLIDERTABLE_H #define SLIDERTABLE_H @@ -26,19 +25,15 @@ #include "pipelineCycler.h" #include "sparseArray.h" -//////////////////////////////////////////////////////////////////// -// Class : SliderTable -// Description : Stores the total set of VertexSliders that the -// vertices in a particular GeomVertexData object might -// depend on. -// -// This is similar to a TransformTable, but it stores -// VertexSliders instead of VertexTransforms, and it -// stores them by name instead of by index number. -// Also, it is only used when animating vertices on the -// CPU, since GPU's don't support morphs at this point -// in time. -//////////////////////////////////////////////////////////////////// +/** + * Stores the total set of VertexSliders that the vertices in a particular + * GeomVertexData object might depend on. + * + * This is similar to a TransformTable, but it stores VertexSliders instead of + * VertexTransforms, and it stores them by name instead of by index number. + * Also, it is only used when animating vertices on the CPU, since GPU's don't + * support morphs at this point in time. + */ class EXPCL_PANDA_GOBJ SliderTable : public TypedWritableReferenceCount { PUBLISHED: SliderTable(); diff --git a/panda/src/gobj/test_gobj.cxx b/panda/src/gobj/test_gobj.cxx index c7840f9ac0..74b408ec97 100644 --- a/panda/src/gobj/test_gobj.cxx +++ b/panda/src/gobj/test_gobj.cxx @@ -1,16 +1,15 @@ -// Filename: test_gobj.cxx -// Created by: shochet (02Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_gobj.cxx + * @author shochet + * @date 2000-02-02 + */ #include "geom.h" #include "perspectiveProjection.h" diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 1888933dc7..eefbb090fe 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -1,32 +1,27 @@ -// Filename: texture.I -// Created by: drose (05Feb99) -// Updated by: fperazzi, PandaSE(29Apr10) (added setup_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texture.I + * @author drose + * @date 1999-02-05 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_copy -// Access: Published -// Description: Returns a new copy of the same Texture. This copy, -// if applied to geometry, will be copied into texture -// as a separate texture from the original, so it will -// be duplicated in texture memory (and may be -// independently modified if desired). -// -// If the Texture is a VideoTexture, the resulting -// duplicate may be animated independently of the -// original. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new copy of the same Texture. This copy, if applied to geometry, + * will be copied into texture as a separate texture from the original, so it + * will be duplicated in texture memory (and may be independently modified if + * desired). + * + * If the Texture is a VideoTexture, the resulting duplicate may be animated + * independently of the original. + */ INLINE PT(Texture) Texture:: make_copy() const { PT(Texture) tex = make_copy_impl(); @@ -37,27 +32,22 @@ make_copy() const { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear -// Access: Published, Virtual -// Description: Reinitializes the texture to its default, empty -// state (except for the name). -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes the texture to its default, empty state (except for the + * name). + */ INLINE void Texture:: clear() { CDWriter cdata(_cycler, true); do_clear(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_texture -// Access: Published -// Description: Sets the texture to the indicated type and -// dimensions, presumably in preparation for calling -// read() or load(), or set_ram_image() or -// modify_ram_image(), or use set_clear_color to let -// the texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture to the indicated type and dimensions, presumably in + * preparation for calling read() or load(), or set_ram_image() or + * modify_ram_image(), or use set_clear_color to let the texture be cleared to + * a solid color. + */ INLINE void Texture:: setup_texture(Texture::TextureType texture_type, int x_size, int y_size, int z_size, Texture::ComponentType component_type, @@ -67,198 +57,152 @@ setup_texture(Texture::TextureType texture_type, int x_size, int y_size, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_1d_texture -// Access: Published -// Description: Sets the texture as an empty 1-d texture with no -// dimensions. Follow up with read() or load() to fill -// the texture properties and image data, or use -// set_clear_color to let the texture be cleared to a -// solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 1-d texture with no dimensions. Follow up + * with read() or load() to fill the texture properties and image data, or use + * set_clear_color to let the texture be cleared to a solid color. + */ INLINE void Texture:: setup_1d_texture() { setup_1d_texture(0, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_1d_texture -// Access: Published -// Description: Sets the texture as an empty 1-d texture with the -// specified dimensions and properties. Follow up with -// set_ram_image() or modify_ram_image() to fill the -// image data, or use set_clear_color to let the -// texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 1-d texture with the specified dimensions and + * properties. Follow up with set_ram_image() or modify_ram_image() to fill + * the image data, or use set_clear_color to let the texture be cleared to a + * solid color. + */ INLINE void Texture:: setup_1d_texture(int x_size, ComponentType component_type, Format format) { setup_texture(TT_1d_texture, x_size, 1, 1, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_2d_texture -// Access: Published -// Description: Sets the texture as an empty 2-d texture with no -// dimensions. Follow up with read() or load() to fill -// the texture properties and image data, or use -// set_clear_color to let the texture be cleared to a -// solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 2-d texture with no dimensions. Follow up + * with read() or load() to fill the texture properties and image data, or use + * set_clear_color to let the texture be cleared to a solid color. + */ INLINE void Texture:: setup_2d_texture() { setup_2d_texture(0, 1, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_2d_texture -// Access: Published -// Description: Sets the texture as an empty 2-d texture with the -// specified dimensions and properties. Follow up with -// set_ram_image() or modify_ram_image() to fill the -// image data, or use set_clear_color to let the -// texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 2-d texture with the specified dimensions and + * properties. Follow up with set_ram_image() or modify_ram_image() to fill + * the image data, or use set_clear_color to let the texture be cleared to a + * solid color. + */ INLINE void Texture:: setup_2d_texture(int x_size, int y_size, ComponentType component_type, Format format) { setup_texture(TT_2d_texture, x_size, y_size, 1, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_3d_texture -// Access: Published -// Description: Sets the texture as an empty 3-d texture with no -// dimensions (though if you know the depth ahead -// of time, it saves a bit of reallocation later). -// Follow up with read() or load() to fill the texture -// properties and image data, or use set_clear_color -// to let the texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 3-d texture with no dimensions (though if you + * know the depth ahead of time, it saves a bit of reallocation later). Follow + * up with read() or load() to fill the texture properties and image data, or + * use set_clear_color to let the texture be cleared to a solid color. + */ INLINE void Texture:: setup_3d_texture(int z_size) { setup_3d_texture(0, 1, z_size, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_3d_texture -// Access: Published -// Description: Sets the texture as an empty 3-d texture with the -// specified dimensions and properties. Follow up with -// set_ram_image() or modify_ram_image() to fill the -// image data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 3-d texture with the specified dimensions and + * properties. Follow up with set_ram_image() or modify_ram_image() to fill + * the image data. + */ INLINE void Texture:: setup_3d_texture(int x_size, int y_size, int z_size, ComponentType component_type, Format format) { setup_texture(TT_3d_texture, x_size, y_size, z_size, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_2d_texture_array -// Access: Published -// Description: Sets the texture as an empty 2-d texture array with -// no dimensions (though if you know the depth ahead -// of time, it saves a bit of reallocation later). -// Follow up with read() or load() to fill the texture -// properties and image data, or use set_clear_color -// to let the texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 2-d texture array with no dimensions (though + * if you know the depth ahead of time, it saves a bit of reallocation later). + * Follow up with read() or load() to fill the texture properties and image + * data, or use set_clear_color to let the texture be cleared to a solid + * color. + */ INLINE void Texture:: setup_2d_texture_array(int z_size) { setup_2d_texture_array(0, 1, z_size, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_2d_texture_array -// Access: Published -// Description: Sets the texture as an empty 2-d texture array with the -// specified dimensions and properties. Follow up with -// set_ram_image() or modify_ram_image() to fill the -// image data, or use set_clear_color to let the -// texture be cleared to a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty 2-d texture array with the specified + * dimensions and properties. Follow up with set_ram_image() or + * modify_ram_image() to fill the image data, or use set_clear_color to let + * the texture be cleared to a solid color. + */ INLINE void Texture:: setup_2d_texture_array(int x_size, int y_size, int z_size, ComponentType component_type, Format format) { setup_texture(TT_2d_texture_array, x_size, y_size, z_size, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_cube_map -// Access: Published -// Description: Sets the texture as an empty cube map texture with no -// dimensions. Follow up with read() or load() to fill -// the texture properties and image data, or use -// set_clear_color to let the texture be cleared to a -// solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty cube map texture with no dimensions. Follow + * up with read() or load() to fill the texture properties and image data, or + * use set_clear_color to let the texture be cleared to a solid color. + */ INLINE void Texture:: setup_cube_map() { setup_cube_map(0, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_cube_map -// Access: Published -// Description: Sets the texture as an empty cube map texture with -// the specified dimensions and properties. Follow up -// with set_ram_image() or modify_ram_image() to fill -// the image data, or use set_clear_color to let the -// texture be cleared to a solid color. -// -// Note that a cube map should always consist of six -// square images, so x_size and y_size will be the same, -// and z_size is always 6. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty cube map texture with the specified dimensions + * and properties. Follow up with set_ram_image() or modify_ram_image() to + * fill the image data, or use set_clear_color to let the texture be cleared + * to a solid color. + * + * Note that a cube map should always consist of six square images, so x_size + * and y_size will be the same, and z_size is always 6. + */ INLINE void Texture:: setup_cube_map(int size, ComponentType component_type, Format format) { setup_texture(TT_cube_map, size, size, 6, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_cube_map_array -// Access: Published -// Description: Sets the texture as cube map array with N cube maps. -// Note that this number is not the same as the z_size. -// Follow up with read() or load() to fill -// the texture properties and image data, or use -// set_clear_color to let the texture be cleared to a -// solid color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as cube map array with N cube maps. Note that this number + * is not the same as the z_size. Follow up with read() or load() to fill the + * texture properties and image data, or use set_clear_color to let the + * texture be cleared to a solid color. + */ INLINE void Texture:: setup_cube_map_array(int num_cube_maps) { setup_cube_map_array(0, num_cube_maps, T_unsigned_byte, F_rgb); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_cube_map_array -// Access: Published -// Description: Sets the texture as cube map array with N cube maps -// with the specified dimensions and format. Follow up -// with set_ram_image() or modify_ram_image() to fill -// the image data, or use set_clear_color to let the -// texture be cleared to a solid color. -// -// The num_cube_maps given here is multiplied by six -// to become the z_size of the image. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as cube map array with N cube maps with the specified + * dimensions and format. Follow up with set_ram_image() or + * modify_ram_image() to fill the image data, or use set_clear_color to let + * the texture be cleared to a solid color. + * + * The num_cube_maps given here is multiplied by six to become the z_size of + * the image. + */ INLINE void Texture:: setup_cube_map_array(int size, int num_cube_maps, ComponentType component_type, Format format) { setup_texture(TT_cube_map_array, size, size, num_cube_maps * 6, component_type, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::setup_buffer_texture -// Access: Published -// Description: Sets the texture as an empty buffer texture with -// the specified size and properties. Follow up -// with set_ram_image() or modify_ram_image() to fill -// the image data, or use set_clear_color to let the -// texture be cleared to a solid color. -// -// Note that a buffer texture's format needs to match -// the component type. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture as an empty buffer texture with the specified size and + * properties. Follow up with set_ram_image() or modify_ram_image() to fill + * the image data, or use set_clear_color to let the texture be cleared to a + * solid color. + * + * Note that a buffer texture's format needs to match the component type. + */ INLINE void Texture:: setup_buffer_texture(int size, ComponentType component_type, Format format, GeomEnums::UsageHint usage) { @@ -267,21 +211,17 @@ setup_buffer_texture(int size, ComponentType component_type, Format format, cdata->_usage_hint = usage; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_image -// Access: Published -// Description: Clears the texture data without changing its format -// or resolution. The texture is cleared on both the -// graphics hardware and from RAM, unlike clear_ram_image, -// which only removes the data from RAM. -// -// If a clear color has been specified using -// set_clear_color, the texture will be cleared using -// a solid color. -// -// The texture data will be cleared the first time in -// which the texture is used after this method is called. -//////////////////////////////////////////////////////////////////// +/** + * Clears the texture data without changing its format or resolution. The + * texture is cleared on both the graphics hardware and from RAM, unlike + * clear_ram_image, which only removes the data from RAM. + * + * If a clear color has been specified using set_clear_color, the texture will + * be cleared using a solid color. + * + * The texture data will be cleared the first time in which the texture is + * used after this method is called. + */ INLINE void Texture:: clear_image() { CDWriter cdata(_cycler, true); @@ -291,42 +231,33 @@ clear_image() { cdata->inc_simple_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_clear_color -// Access: Published -// Description: Returns true if a color was previously set using -// set_clear_color. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a color was previously set using set_clear_color. + */ INLINE bool Texture:: has_clear_color() const { CDReader cdata(_cycler); return cdata->_has_clear_color; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_clear_color -// Access: Published -// Description: Returns the color that was previously set using -// set_clear_color. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color that was previously set using set_clear_color. + */ INLINE LColor Texture:: get_clear_color() const { CDReader cdata(_cycler); return cdata->_clear_color; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_clear_color -// Access: Published -// Description: Sets the color that will be used to fill the -// texture image in absence of any image data. It is -// used when any of the setup_texture functions or -// clear_image is called and image data is not -// provided using read() or modify_ram_image(). -// -// This does not affect a texture that has already -// been cleared; call clear_image to clear it again. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color that will be used to fill the texture image in absence of + * any image data. It is used when any of the setup_texture functions or + * clear_image is called and image data is not provided using read() or + * modify_ram_image(). + * + * This does not affect a texture that has already been cleared; call + * clear_image to clear it again. + */ INLINE void Texture:: set_clear_color(const LColor &color) { CDWriter cdata(_cycler, true); @@ -334,25 +265,20 @@ set_clear_color(const LColor &color) { cdata->_has_clear_color = true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_clear_color -// Access: Published -// Description: The opposite of set_clear_color. If the image is -// cleared after setting this, its contents may be -// undefined (or may in fact not be cleared at all). -//////////////////////////////////////////////////////////////////// +/** + * The opposite of set_clear_color. If the image is cleared after setting + * this, its contents may be undefined (or may in fact not be cleared at all). + */ INLINE void Texture:: clear_clear_color() { CDWriter cdata(_cycler, true); cdata->_has_clear_color = true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_clear_data -// Access: Published -// Description: Returns the raw image data for a single pixel if -// it were set to the clear color. -//////////////////////////////////////////////////////////////////// +/** + * Returns the raw image data for a single pixel if it were set to the clear + * color. + */ INLINE string Texture:: get_clear_data() const { CDReader cdata(_cycler); @@ -361,76 +287,58 @@ get_clear_data() const { return string((char *)data, size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::write -// Access: Published -// Description: Writes the texture to the named filename. -//////////////////////////////////////////////////////////////////// +/** + * Writes the texture to the named filename. + */ INLINE bool Texture:: write(const Filename &fullpath) { CDWriter cdata(_cycler); - // do_write() is non-const, because it might have to reload the ram - // image. + // do_write() is non-const, because it might have to reload the ram image. return do_write(cdata, fullpath, 0, 0, false, false); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::write -// Access: Published -// Description: Writes a single page or mipmap level to a single -// file, or automatically writes a series of pages -// and/or mipmap levels to a numbered series of files. -// -// If the filename ends in the extension .txo, this -// implicitly writes a Panda texture object (.txo) -// instead of an image file. In this case, the -// remaining parameters are ignored, and only one file -// is written, which will contain all of the pages and -// resident mipmap levels in the texture. -// -// If write_pages is false, then z indicates the page -// number to write. 3-D textures have one page number -// for each level of depth; cube maps have six pages -// number 0 through 5. Other kinds of textures have -// only one page, numbered 0. If there are multiple -// views, the range of z is increased; the total range -// is [0, get_num_pages()). -// -// If write_pages is true, then all pages of the texture -// will be written. In this case z is ignored, and the -// filename should contain a sequence of hash marks -// ("#") which will be filled in with the page index -// number. -// -// If write_mipmaps is false, then n indicates the -// mipmap level number to write. Normally, this is 0, -// for the base texture image. Normally, the mipmap -// levels of a texture are not available in RAM (they -// are generated automatically by the graphics card). -// However, if you have the mipmap levels available, for -// instance because you called -// generate_ram_mipmap_images() to generate them -// internally, or you called -// GraphicsEngine::extract_texture_data() to retrieve -// them from the graphics card, then you may write out -// each mipmap level with this parameter. -// -// If write_mipmaps is true, then all mipmap levels of -// the texture will be written. In this case n is -// ignored, and the filename should contain a sequence -// of hash marks ("#") which will be filled in with the -// mipmap level number. -// -// If both write_pages and write_mipmaps is true, then -// all pages and all mipmap levels will be written. In -// this case, the filename should contain two different -// sequences of hash marks, separated by a character -// such as a hyphen, underscore, or dot. The first hash -// mark sequence will be filled in with the mipmap -// level, while the second hash mark sequence will be -// the page index. -//////////////////////////////////////////////////////////////////// +/** + * Writes a single page or mipmap level to a single file, or automatically + * writes a series of pages and/or mipmap levels to a numbered series of + * files. + * + * If the filename ends in the extension .txo, this implicitly writes a Panda + * texture object (.txo) instead of an image file. In this case, the + * remaining parameters are ignored, and only one file is written, which will + * contain all of the pages and resident mipmap levels in the texture. + * + * If write_pages is false, then z indicates the page number to write. 3-D + * textures have one page number for each level of depth; cube maps have six + * pages number 0 through 5. Other kinds of textures have only one page, + * numbered 0. If there are multiple views, the range of z is increased; the + * total range is [0, get_num_pages()). + * + * If write_pages is true, then all pages of the texture will be written. In + * this case z is ignored, and the filename should contain a sequence of hash + * marks ("#") which will be filled in with the page index number. + * + * If write_mipmaps is false, then n indicates the mipmap level number to + * write. Normally, this is 0, for the base texture image. Normally, the + * mipmap levels of a texture are not available in RAM (they are generated + * automatically by the graphics card). However, if you have the mipmap levels + * available, for instance because you called generate_ram_mipmap_images() to + * generate them internally, or you called + * GraphicsEngine::extract_texture_data() to retrieve them from the graphics + * card, then you may write out each mipmap level with this parameter. + * + * If write_mipmaps is true, then all mipmap levels of the texture will be + * written. In this case n is ignored, and the filename should contain a + * sequence of hash marks ("#") which will be filled in with the mipmap level + * number. + * + * If both write_pages and write_mipmaps is true, then all pages and all + * mipmap levels will be written. In this case, the filename should contain + * two different sequences of hash marks, separated by a character such as a + * hyphen, underscore, or dot. The first hash mark sequence will be filled in + * with the mipmap level, while the second hash mark sequence will be the page + * index. + */ INLINE bool Texture:: write(const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps) { @@ -438,11 +346,9 @@ write(const Filename &fullpath, int z, int n, return do_write(cdata, fullpath, z, n, write_pages, write_mipmaps); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load -// Access: Published -// Description: Replaces the texture with the indicated image. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the texture with the indicated image. + */ INLINE bool Texture:: load(const PNMImage &pnmimage, const LoaderOptions &options) { CDWriter cdata(_cycler, true); @@ -457,12 +363,9 @@ load(const PNMImage &pnmimage, const LoaderOptions &options) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load -// Access: Published -// Description: Stores the indicated image in the given page and -// mipmap level. See read(). -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated image in the given page and mipmap level. See read(). + */ INLINE bool Texture:: load(const PNMImage &pnmimage, int z, int n, const LoaderOptions &options) { CDWriter cdata(_cycler, true); @@ -474,11 +377,9 @@ load(const PNMImage &pnmimage, int z, int n, const LoaderOptions &options) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load -// Access: Published -// Description: Replaces the texture with the indicated image. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the texture with the indicated image. + */ INLINE bool Texture:: load(const PfmFile &pfm, const LoaderOptions &options) { CDWriter cdata(_cycler, true); @@ -493,12 +394,9 @@ load(const PfmFile &pfm, const LoaderOptions &options) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load -// Access: Published -// Description: Stores the indicated image in the given page and -// mipmap level. See read(). -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated image in the given page and mipmap level. See read(). + */ INLINE bool Texture:: load(const PfmFile &pfm, int z, int n, const LoaderOptions &options) { CDWriter cdata(_cycler, true); @@ -510,183 +408,144 @@ load(const PfmFile &pfm, int z, int n, const LoaderOptions &options) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load_sub_image -// Access: Published -// Description: Stores the indicated image in a region of the -// texture. The texture properties remain unchanged. -// This can be more efficient than updating an entire -// texture, but has a few restrictions: for one, you -// must ensure that the texture is still in RAM (eg. -// using set_keep_ram_image) and it may not be -// compressed. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated image in a region of the texture. The texture + * properties remain unchanged. This can be more efficient than updating an + * entire texture, but has a few restrictions: for one, you must ensure that + * the texture is still in RAM (eg. using set_keep_ram_image) and it may not + * be compressed. + */ INLINE bool Texture:: load_sub_image(const PNMImage &image, int x, int y, int z, int n) { CDWriter cdata(_cycler, true); return do_load_sub_image(cdata, image, x, y, z, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store -// Access: Published -// Description: Saves the texture to the indicated PNMImage, but does -// not write it to disk. -//////////////////////////////////////////////////////////////////// +/** + * Saves the texture to the indicated PNMImage, but does not write it to disk. + */ INLINE bool Texture:: store(PNMImage &pnmimage) const { CDWriter cdata(((Texture *)this)->_cycler, false); return ((Texture *)this)->do_store_one(cdata, pnmimage, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store -// Access: Published -// Description: Saves the indicated page and mipmap level of the -// texture to the PNMImage. -//////////////////////////////////////////////////////////////////// +/** + * Saves the indicated page and mipmap level of the texture to the PNMImage. + */ INLINE bool Texture:: store(PNMImage &pnmimage, int z, int n) const { CDWriter cdata(((Texture *)this)->_cycler, false); return ((Texture *)this)->do_store_one(cdata, pnmimage, z, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store -// Access: Published -// Description: Saves the texture to the indicated PfmFile, but does -// not write it to disk. -//////////////////////////////////////////////////////////////////// +/** + * Saves the texture to the indicated PfmFile, but does not write it to disk. + */ INLINE bool Texture:: store(PfmFile &pfm) const { CDWriter cdata(((Texture *)this)->_cycler, false); return ((Texture *)this)->do_store_one(cdata, pfm, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store -// Access: Published -// Description: Saves the indicated page and mipmap level of the -// texture to the PfmFile. -//////////////////////////////////////////////////////////////////// +/** + * Saves the indicated page and mipmap level of the texture to the PfmFile. + */ INLINE bool Texture:: store(PfmFile &pfm, int z, int n) const { CDWriter cdata(((Texture *)this)->_cycler, false); return ((Texture *)this)->do_store_one(cdata, pfm, z, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::reload -// Access: Published -// Description: Re-reads the Texture from its disk file. Useful when -// you know the image on disk has recently changed, and -// you want to update the Texture image. -// -// Returns true on success, false on failure (in which -// case, the Texture may or may not still be valid). -//////////////////////////////////////////////////////////////////// +/** + * Re-reads the Texture from its disk file. Useful when you know the image on + * disk has recently changed, and you want to update the Texture image. + * + * Returns true on success, false on failure (in which case, the Texture may + * or may not still be valid). + */ bool Texture:: reload() { CDWriter cdata(_cycler, true); return do_reload(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_filename -// Access: Published -// Description: Returns true if the filename has been set and -// is available. See set_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename has been set and is available. See + * set_filename(). + */ INLINE bool Texture:: has_filename() const { CDReader cdata(_cycler); return !cdata->_filename.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_filename -// Access: Published -// Description: Returns the filename that has been set. This is the -// name of the file as it was requested. Also see -// get_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that has been set. This is the name of the file as it + * was requested. Also see get_fullpath(). + */ INLINE const Filename &Texture:: get_filename() const { CDReader cdata(_cycler); return cdata->_filename; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_alpha_filename -// Access: Published -// Description: Returns true if the alpha_filename has been set and -// is available. See set_alpha_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the alpha_filename has been set and is available. See + * set_alpha_filename(). + */ INLINE bool Texture:: has_alpha_filename() const { CDReader cdata(_cycler); return !cdata->_alpha_filename.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_alpha_filename -// Access: Published -// Description: Returns the alpha_filename that has been set. If -// this is set, it represents the name of the alpha -// component, which is stored in a separate file. See -// also get_filename(), and get_alpha_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha_filename that has been set. If this is set, it + * represents the name of the alpha component, which is stored in a separate + * file. See also get_filename(), and get_alpha_fullpath(). + */ INLINE const Filename &Texture:: get_alpha_filename() const { CDReader cdata(_cycler); return cdata->_alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_fullpath -// Access: Published -// Description: Returns true if the fullpath has been set and -// is available. See set_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the fullpath has been set and is available. See + * set_fullpath(). + */ INLINE bool Texture:: has_fullpath() const { CDReader cdata(_cycler); return !cdata->_fullpath.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_fullpath -// Access: Published -// Description: Returns the fullpath that has been set. This is the -// full path to the file as it was found along the -// texture search path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fullpath that has been set. This is the full path to the file + * as it was found along the texture search path. + */ INLINE const Filename &Texture:: get_fullpath() const { CDReader cdata(_cycler); return cdata->_fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_alpha_fullpath -// Access: Published -// Description: Returns true if the alpha_fullpath has been set and -// is available. See set_alpha_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the alpha_fullpath has been set and is available. See + * set_alpha_fullpath(). + */ INLINE bool Texture:: has_alpha_fullpath() const { CDReader cdata(_cycler); return !cdata->_alpha_fullpath.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_alpha_fullpath -// Access: Published -// Description: -// Returns the alpha_fullpath that has been set. This -// is the full path to the alpha part of the image file -// as it was found along the texture search path. -//////////////////////////////////////////////////////////////////// +/** + * + * Returns the alpha_fullpath that has been set. This is the full path to the + * alpha part of the image file as it was found along the texture search path. + */ INLINE const Filename &Texture:: get_alpha_fullpath() const { CDReader cdata(_cycler); @@ -694,125 +553,100 @@ get_alpha_fullpath() const { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_x_size -// Access: Published -// Description: Returns the width of the texture image in texels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the texture image in texels. + */ INLINE int Texture:: get_x_size() const { CDReader cdata(_cycler); return cdata->_x_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_y_size -// Access: Published -// Description: Returns the height of the texture image in texels. -// For a 1-d texture, this will be 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the texture image in texels. For a 1-d texture, this + * will be 1. + */ INLINE int Texture:: get_y_size() const { CDReader cdata(_cycler); return cdata->_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_z_size -// Access: Published -// Description: Returns the depth of the texture image in texels. -// For a 1-d texture or 2-d texture, this will be 1. -// For a cube map texture, this will be 6. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth of the texture image in texels. For a 1-d texture or 2-d + * texture, this will be 1. For a cube map texture, this will be 6. + */ INLINE int Texture:: get_z_size() const { CDReader cdata(_cycler); return cdata->_z_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_num_views -// Access: Published -// Description: Returns the number of "views" in the texture. A view -// is a completely separate image stored within the -// Texture object. Most textures have only one view, -// but a stereo texture, for instance, may have two -// views, a left and a right image. Other uses for -// multiple views are not yet defined. -// -// If this value is greater than one, the additional -// views are accessed as additional pages beyond -// get_z_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of "views" in the texture. A view is a completely + * separate image stored within the Texture object. Most textures have only + * one view, but a stereo texture, for instance, may have two views, a left + * and a right image. Other uses for multiple views are not yet defined. + * + * If this value is greater than one, the additional views are accessed as + * additional pages beyond get_z_size(). + */ INLINE int Texture:: get_num_views() const { CDReader cdata(_cycler); return cdata->_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_num_pages -// Access: Published -// Description: Returns the total number of pages in the texture. -// Each "page" is a 2-d texture image within the larger -// image--a face of a cube map, or a level of a 3-d -// texture. Normally, get_num_pages() is the same as -// get_z_size(). However, in a multiview texture, this -// returns get_z_size() * get_num_views(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of pages in the texture. Each "page" is a 2-d + * texture image within the larger image--a face of a cube map, or a level of + * a 3-d texture. Normally, get_num_pages() is the same as get_z_size(). + * However, in a multiview texture, this returns get_z_size() * + * get_num_views(). + */ INLINE int Texture:: get_num_pages() const { return get_z_size() * get_num_views(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_pad_x_size -// Access: Published -// Description: Returns size of the pad region. See set_pad_size. -//////////////////////////////////////////////////////////////////// +/** + * Returns size of the pad region. See set_pad_size. + */ INLINE int Texture:: get_pad_x_size() const { CDReader cdata(_cycler); return cdata->_pad_x_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_pad_y_size -// Access: Published -// Description: Returns size of the pad region. See set_pad_size. -//////////////////////////////////////////////////////////////////// +/** + * Returns size of the pad region. See set_pad_size. + */ INLINE int Texture:: get_pad_y_size() const { CDReader cdata(_cycler); return cdata->_pad_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_pad_z_size -// Access: Published -// Description: Returns size of the pad region. See set_pad_size. -//////////////////////////////////////////////////////////////////// +/** + * Returns size of the pad region. See set_pad_size. + */ INLINE int Texture:: get_pad_z_size() const { CDReader cdata(_cycler); return cdata->_pad_z_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_tex_scale -// Access: Published -// Description: Returns a scale pair that is suitable for applying to -// geometry via NodePath::set_tex_scale(), which will -// convert texture coordinates on the geometry from the -// range 0..1 into the appropriate range to render the -// video part of the texture. -// -// This is necessary only if a padding size has been set -// via set_pad_size() (or implicitly via something like -// "textures-power-2 pad" in the config.prc file). In -// this case, this is a convenient way to generate UV's -// that reflect the built-in padding size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a scale pair that is suitable for applying to geometry via + * NodePath::set_tex_scale(), which will convert texture coordinates on the + * geometry from the range 0..1 into the appropriate range to render the video + * part of the texture. + * + * This is necessary only if a padding size has been set via set_pad_size() + * (or implicitly via something like "textures-power-2 pad" in the config.prc + * file). In this case, this is a convenient way to generate UV's that + * reflect the built-in padding size. + */ INLINE LVecBase2 Texture:: get_tex_scale() const { CDReader cdata(_cycler); @@ -824,347 +658,276 @@ get_tex_scale() const { (PN_stdfloat)(cdata->_y_size - cdata->_pad_y_size) / (PN_stdfloat)cdata->_y_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_pad_size -// Access: Published -// Description: Sets the size of the pad region. -// -// Sometimes, when a video card demands power-of-two -// textures, it is necessary to create a big texture -// and then only use a portion of it. The pad region -// indicates which portion of the texture is not -// really in use. All operations use the texture -// as a whole, including the pad region, unless they -// explicitly state that they use only the non-pad -// region. -// -// Changing the texture's size clears the pad region. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the pad region. + * + * Sometimes, when a video card demands power-of-two textures, it is necessary + * to create a big texture and then only use a portion of it. The pad region + * indicates which portion of the texture is not really in use. All + * operations use the texture as a whole, including the pad region, unless + * they explicitly state that they use only the non-pad region. + * + * Changing the texture's size clears the pad region. + */ INLINE void Texture:: set_pad_size(int x, int y, int z) { CDWriter cdata(_cycler, true); do_set_pad_size(cdata, x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_orig_file_x_size -// Access: Published -// Description: Returns the X size of the original disk image that -// this Texture was loaded from (if it came from a disk -// file), before any automatic rescaling by Panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X size of the original disk image that this Texture was loaded + * from (if it came from a disk file), before any automatic rescaling by + * Panda. + */ INLINE int Texture:: get_orig_file_x_size() const { CDReader cdata(_cycler); return cdata->_orig_file_x_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_orig_file_y_size -// Access: Published -// Description: Returns the Y size of the original disk image that -// this Texture was loaded from (if it came from a disk -// file), before any automatic rescaling by Panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Y size of the original disk image that this Texture was loaded + * from (if it came from a disk file), before any automatic rescaling by + * Panda. + */ INLINE int Texture:: get_orig_file_y_size() const { CDReader cdata(_cycler); return cdata->_orig_file_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_orig_file_z_size -// Access: Published -// Description: Returns the Z size of the original disk image that -// this Texture was loaded from (if it came from a disk -// file), before any automatic rescaling by Panda. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Z size of the original disk image that this Texture was loaded + * from (if it came from a disk file), before any automatic rescaling by + * Panda. + */ INLINE int Texture:: get_orig_file_z_size() const { - // At the moment, we perform no automatic adjustment of Z size. So - // we can just return the current value, since it would be the same - // thing. + // At the moment, we perform no automatic adjustment of Z size. So we can + // just return the current value, since it would be the same thing. CDReader cdata(_cycler); return cdata->_z_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_num_components -// Access: Published -// Description: Returns the number of color components for each texel -// of the texture image. This is 3 for an rgb texture -// or 4 for an rgba texture; it may also be 1 or 2 for a -// grayscale texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of color components for each texel of the texture image. + * This is 3 for an rgb texture or 4 for an rgba texture; it may also be 1 or + * 2 for a grayscale texture. + */ INLINE int Texture:: get_num_components() const { CDReader cdata(_cycler); return cdata->_num_components; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_component_width -// Access: Published -// Description: Returns the number of bytes stored for each color -// component of a texel. Typically this is 1, but it -// may be 2 for 16-bit texels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes stored for each color component of a texel. + * Typically this is 1, but it may be 2 for 16-bit texels. + */ INLINE int Texture:: get_component_width() const { CDReader cdata(_cycler); return cdata->_component_width; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_texture_type -// Access: Published -// Description: Returns the overall interpretation of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall interpretation of the texture. + */ INLINE Texture::TextureType Texture:: get_texture_type() const { CDReader cdata(_cycler); return cdata->_texture_type; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_format -// Access: Published -// Description: Returns the format of the texture, which represents -// both the semantic meaning of the texels and, to some -// extent, their storage information. -//////////////////////////////////////////////////////////////////// +/** + * Returns the format of the texture, which represents both the semantic + * meaning of the texels and, to some extent, their storage information. + */ INLINE Texture::Format Texture:: get_format() const { CDReader cdata(_cycler); return cdata->_format; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_component_type -// Access: Published -// Description: Returns the numeric interpretation of each component -// of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the numeric interpretation of each component of the texture. + */ INLINE Texture::ComponentType Texture:: get_component_type() const { CDReader cdata(_cycler); return cdata->_component_type; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_usage_hint -// Access: Published -// Description: Returns the usage hint specified for buffer textures, -// or UH_unspecified for all other texture types. -//////////////////////////////////////////////////////////////////// +/** + * Returns the usage hint specified for buffer textures, or UH_unspecified for + * all other texture types. + */ INLINE GeomEnums::UsageHint Texture:: get_usage_hint() const { CDReader cdata(_cycler); return cdata->_usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_wrap_u -// Access: Published -// Description: This setting determines what happens when the -// texture is sampled with a U value outside the range -// 0.0-1.0. The default is WM_repeat, which indicates -// that the texture should repeat indefinitely. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * This setting determines what happens when the texture is sampled with a U + * value outside the range 0.0-1.0. The default is WM_repeat, which indicates + * that the texture should repeat indefinitely. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_wrap_u(SamplerState::WrapMode wrap) { CDWriter cdata(_cycler, true); do_set_wrap_u(cdata, wrap); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_wrap_v -// Access: Published -// Description: This setting determines what happens when the -// texture is sampled with a V value outside the range -// 0.0-1.0. The default is WM_repeat, which indicates -// that the texture should repeat indefinitely. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * This setting determines what happens when the texture is sampled with a V + * value outside the range 0.0-1.0. The default is WM_repeat, which indicates + * that the texture should repeat indefinitely. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_wrap_v(SamplerState::WrapMode wrap) { CDWriter cdata(_cycler, true); do_set_wrap_v(cdata, wrap); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_wrap_w -// Access: Published -// Description: The W wrap direction is only used for 3-d textures. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * The W wrap direction is only used for 3-d textures. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_wrap_w(SamplerState::WrapMode wrap) { CDWriter cdata(_cycler, true); do_set_wrap_w(cdata, wrap); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_minfilter -// Access: Published -// Description: Sets the filtering method that should be used when -// viewing the texture from a distance. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filtering method that should be used when viewing the texture from + * a distance. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_minfilter(SamplerState::FilterType filter) { CDWriter cdata(_cycler, true); do_set_minfilter(cdata, filter); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_magfilter -// Access: Published -// Description: Sets the filtering method that should be used when -// viewing the texture up close. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filtering method that should be used when viewing the texture up + * close. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_magfilter(SamplerState::FilterType filter) { CDWriter cdata(_cycler, true); do_set_magfilter(cdata, filter); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_anisotropic_degree -// Access: Published -// Description: Specifies the level of anisotropic filtering to apply -// to the texture. Set this 0 to indicate the default -// value, which is specified in the -// texture-anisotropic-degree config variable. -// -// To explicitly disable anisotropic filtering, set this -// value to 1. To explicitly enable anisotropic -// filtering, set it to a value higher than 1; larger -// numbers indicate greater degrees of filtering. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the level of anisotropic filtering to apply to the texture. Set + * this 0 to indicate the default value, which is specified in the texture- + * anisotropic-degree config variable. + * + * To explicitly disable anisotropic filtering, set this value to 1. To + * explicitly enable anisotropic filtering, set it to a value higher than 1; + * larger numbers indicate greater degrees of filtering. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_anisotropic_degree(int anisotropic_degree) { CDWriter cdata(_cycler, true); do_set_anisotropic_degree(cdata, anisotropic_degree); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_border_color -// Access: Published -// Description: Specifies the solid color of the texture's border. -// Some OpenGL implementations use a border for tiling -// textures; in Panda, it is only used for specifying -// the clamp color. -// -// This sets the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the solid color of the texture's border. Some OpenGL + * implementations use a border for tiling textures; in Panda, it is only used + * for specifying the clamp color. + * + * This sets the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE void Texture:: set_border_color(const LColor &color) { CDWriter cdata(_cycler, true); do_set_border_color(cdata, color); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_compression -// Access: Published -// Description: Requests that this particular Texture be compressed -// when it is loaded into texture memory. -// -// This refers to the internal compression of the -// texture image within texture memory; it is not -// related to jpeg or png compression, which are disk -// file compression formats. The actual disk file that -// generated this texture may be stored in a compressed -// or uncompressed format supported by Panda; it will be -// decompressed on load, and then recompressed by the -// graphics API if this parameter is not CM_off. -// -// If the GSG does not support this texture compression -// mode, the texture will silently be loaded -// uncompressed. -//////////////////////////////////////////////////////////////////// +/** + * Requests that this particular Texture be compressed when it is loaded into + * texture memory. + * + * This refers to the internal compression of the texture image within texture + * memory; it is not related to jpeg or png compression, which are disk file + * compression formats. The actual disk file that generated this texture may + * be stored in a compressed or uncompressed format supported by Panda; it + * will be decompressed on load, and then recompressed by the graphics API if + * this parameter is not CM_off. + * + * If the GSG does not support this texture compression mode, the texture will + * silently be loaded uncompressed. + */ INLINE void Texture:: set_compression(Texture::CompressionMode compression) { CDWriter cdata(_cycler, true); do_set_compression(cdata, compression); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_render_to_texture -// Access: Published -// Description: Sets a flag on the texture that indicates whether the -// texture is intended to be used as a direct-render -// target, by binding a framebuffer to a texture and -// rendering directly into the texture. -// -// This controls some low-level choices made about the -// texture object itself. For instance, compressed -// textures are disallowed when this flag is set true. -// -// Normally, a user should not need to set this flag -// directly; it is set automatically by the low-level -// display code when a texture is bound to a -// framebuffer. -//////////////////////////////////////////////////////////////////// +/** + * Sets a flag on the texture that indicates whether the texture is intended + * to be used as a direct-render target, by binding a framebuffer to a texture + * and rendering directly into the texture. + * + * This controls some low-level choices made about the texture object itself. + * For instance, compressed textures are disallowed when this flag is set + * true. + * + * Normally, a user should not need to set this flag directly; it is set + * automatically by the low-level display code when a texture is bound to a + * framebuffer. + */ INLINE void Texture:: set_render_to_texture(bool render_to_texture) { CDWriter cdata(_cycler, false); cdata->_render_to_texture = render_to_texture; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_default_sampler -// Access: Published -// Description: This returns the default sampler state for this -// texture, containing the wrap and filter properties -// specified on the texture level; it may still be -// overridden by a sampler state specified at a higher -// level. -//////////////////////////////////////////////////////////////////// +/** + * This returns the default sampler state for this texture, containing the + * wrap and filter properties specified on the texture level; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE const SamplerState &Texture:: get_default_sampler() const { CDReader cdata(_cycler); return cdata->_default_sampler; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_default_sampler -// Access: Published -// Description: This sets the default sampler state for this -// texture, containing the wrap and filter properties -// specified on the texture level; it may still be -// overridden by a sampler state specified at a higher -// level. This encompasses the settings for get_wrap_u, -// get_minfilter, get_anisotropic_degree, etc. -// -// This makes a copy of the SamplerState object, so -// future modifications of the same SamplerState will -// have no effect on this texture unless you call -// set_default_sampler again. -//////////////////////////////////////////////////////////////////// +/** + * This sets the default sampler state for this texture, containing the wrap + * and filter properties specified on the texture level; it may still be + * overridden by a sampler state specified at a higher level. This + * encompasses the settings for get_wrap_u, get_minfilter, + * get_anisotropic_degree, etc. + * + * This makes a copy of the SamplerState object, so future modifications of + * the same SamplerState will have no effect on this texture unless you call + * set_default_sampler again. + */ INLINE void Texture:: set_default_sampler(const SamplerState &sampler) { CDWriter cdata(_cycler, true); @@ -1172,290 +935,222 @@ set_default_sampler(const SamplerState &sampler) { cdata->inc_properties_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_wrap_u -// Access: Published -// Description: Returns the wrap mode of the texture in the U -// direction. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the U direction. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE SamplerState::WrapMode Texture:: get_wrap_u() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_wrap_u(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_wrap_v -// Access: Published -// Description: Returns the wrap mode of the texture in the V -// direction. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the V direction. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE SamplerState::WrapMode Texture:: get_wrap_v() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_wrap_v(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_wrap_w -// Access: Published -// Description: Returns the wrap mode of the texture in the W -// direction. This is the depth direction of 3-d -// textures. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode of the texture in the W direction. This is the depth + * direction of 3-d textures. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE SamplerState::WrapMode Texture:: get_wrap_w() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_wrap_w(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_minfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// minification. If this is one of the mipmap -// constants, then the texture requires mipmaps. This -// may return FT_default; see also -// get_effective_minfilter(). -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for minification. If this is one of + * the mipmap constants, then the texture requires mipmaps. This may return + * FT_default; see also get_effective_minfilter(). + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE SamplerState::FilterType Texture:: get_minfilter() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_minfilter(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_magfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// magnification. The mipmap constants are invalid -// here. This may return FT_default; see also -// get_effective_minfilter(). -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for magnification. The mipmap + * constants are invalid here. This may return FT_default; see also + * get_effective_minfilter(). + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE SamplerState::FilterType Texture:: get_magfilter() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_magfilter(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_effective_minfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// minification, with special treatment for FT_default. -// This will normally not return FT_default, unless -// there is an error in the config file. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for minification, with special + * treatment for FT_default. This will normally not return FT_default, unless + * there is an error in the config file. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ SamplerState::FilterType Texture:: get_effective_minfilter() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_effective_minfilter(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_effective_magfilter -// Access: Published -// Description: Returns the filter mode of the texture for -// magnification, with special treatment for FT_default. -// This will normally not return FT_default, unless -// there is an error in the config file. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter mode of the texture for magnification, with special + * treatment for FT_default. This will normally not return FT_default, unless + * there is an error in the config file. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ SamplerState::FilterType Texture:: get_effective_magfilter() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_effective_magfilter(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_anisotropic_degree -// Access: Published -// Description: Returns the degree of anisotropic filtering that -// should be applied to the texture. This value may -// return 0, indicating the default value; see also -// get_effective_anisotropic_degree. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of anisotropic filtering that should be applied to the + * texture. This value may return 0, indicating the default value; see also + * get_effective_anisotropic_degree. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE int Texture:: get_anisotropic_degree() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_anisotropic_degree(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_effective_anisotropic_degree -// Access: Published -// Description: Returns the degree of anisotropic filtering that -// should be applied to the texture. This value will -// normally not return 0, unless there is an error in -// the config file. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the degree of anisotropic filtering that should be applied to the + * texture. This value will normally not return 0, unless there is an error + * in the config file. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE int Texture:: get_effective_anisotropic_degree() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_effective_anisotropic_degree(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_border_color -// Access: Published -// Description: Returns the solid color of the texture's border. -// Some OpenGL implementations use a border for tiling -// textures; in Panda, it is only used for specifying -// the clamp color. -// -// This returns the default sampler state for this -// texture; it may still be overridden by a sampler -// state specified at a higher level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the solid color of the texture's border. Some OpenGL + * implementations use a border for tiling textures; in Panda, it is only used + * for specifying the clamp color. + * + * This returns the default sampler state for this texture; it may still be + * overridden by a sampler state specified at a higher level. + */ INLINE LColor Texture:: get_border_color() const { CDReader cdata(_cycler); return cdata->_default_sampler.get_border_color(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_compression -// Access: Published -// Description: Returns the compression mode requested for this -// particular texture, or CM_off if the texture is not -// to be compressed. -// -// If a value other than CM_off is returned, this is -// not a guarantee that the texture is actually -// successfully compressed on the GSG. It may be that -// the GSG does not support the requested compression -// mode, in which case the texture may actually be -// stored uncompressed in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compression mode requested for this particular texture, or + * CM_off if the texture is not to be compressed. + * + * If a value other than CM_off is returned, this is not a guarantee that the + * texture is actually successfully compressed on the GSG. It may be that the + * GSG does not support the requested compression mode, in which case the + * texture may actually be stored uncompressed in texture memory. + */ INLINE Texture::CompressionMode Texture:: get_compression() const { CDReader cdata(_cycler); return cdata->_compression; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_compression -// Access: Published -// Description: Returns true if the texture indicates it wants to be -// compressed, either with CM_on or higher, or -// CM_default and compressed-textures is true. -// -// If true returned, this is not a guarantee that the -// texture is actually successfully compressed on the -// GSG. It may be that the GSG does not support the -// requested compression mode, in which case the texture -// may actually be stored uncompressed in texture -// memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture indicates it wants to be compressed, either + * with CM_on or higher, or CM_default and compressed-textures is true. + * + * If true returned, this is not a guarantee that the texture is actually + * successfully compressed on the GSG. It may be that the GSG does not + * support the requested compression mode, in which case the texture may + * actually be stored uncompressed in texture memory. + */ INLINE bool Texture:: has_compression() const { CDReader cdata(_cycler); return do_has_compression(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_render_to_texture -// Access: Published -// Description: Returns a flag on the texture that indicates whether the -// texture is intended to be used as a direct-render -// target, by binding a framebuffer to a texture and -// rendering directly into the texture. -// -// Normally, a user should not need to set this flag -// directly; it is set automatically by the low-level -// display code when a texture is bound to a -// framebuffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a flag on the texture that indicates whether the texture is + * intended to be used as a direct-render target, by binding a framebuffer to + * a texture and rendering directly into the texture. + * + * Normally, a user should not need to set this flag directly; it is set + * automatically by the low-level display code when a texture is bound to a + * framebuffer. + */ INLINE bool Texture:: get_render_to_texture() const { CDReader cdata(_cycler); return cdata->_render_to_texture; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::uses_mipmaps -// Access: Public -// Description: Returns true if the minfilter settings on this -// texture indicate the use of mipmapping, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the minfilter settings on this texture indicate the use of + * mipmapping, false otherwise. + */ INLINE bool Texture:: uses_mipmaps() const { return SamplerState::is_mipmap(get_effective_minfilter()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_quality_level -// Access: Public -// Description: Sets a hint to the renderer about the desired -// performance / quality tradeoff for this particular -// texture. This is most useful for the tinydisplay -// software renderer; for normal, hardware-accelerated -// renderers, this may have little or no effect. -//////////////////////////////////////////////////////////////////// +/** + * Sets a hint to the renderer about the desired performance / quality + * tradeoff for this particular texture. This is most useful for the + * tinydisplay software renderer; for normal, hardware-accelerated renderers, + * this may have little or no effect. + */ INLINE void Texture:: set_quality_level(Texture::QualityLevel quality_level) { CDWriter cdata(_cycler, true); do_set_quality_level(cdata, quality_level); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_quality_level -// Access: Public -// Description: Returns the current quality_level hint. See -// set_quality_level(). This value may return -// QL_default; see get_effective_quality_level(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current quality_level hint. See set_quality_level(). This + * value may return QL_default; see get_effective_quality_level(). + */ INLINE Texture::QualityLevel Texture:: get_quality_level() const { CDReader cdata(_cycler); return cdata->_quality_level; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_effective_quality_level -// Access: Public -// Description: Returns the current quality_level hint, or the global -// default quality_level if this texture doesn't specify -// a quality level. This value will not normally return -// QL_default (unless there is an error in the config -// file) -//////////////////////////////////////////////////////////////////// +/** + * Returns the current quality_level hint, or the global default quality_level + * if this texture doesn't specify a quality level. This value will not + * normally return QL_default (unless there is an error in the config file) + */ INLINE Texture::QualityLevel Texture:: get_effective_quality_level() const { CDReader cdata(_cycler); @@ -1465,157 +1160,123 @@ get_effective_quality_level() const { return cdata->_quality_level; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_num_mipmap_levels -// Access: Published -// Description: Returns the number of mipmap levels that should be -// defined for this texture, given the texture's size. -// -// Note that this returns a number appropriate for -// mipmapping, even if the texture does not currently -// have mipmapping enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of mipmap levels that should be defined for this + * texture, given the texture's size. + * + * Note that this returns a number appropriate for mipmapping, even if the + * texture does not currently have mipmapping enabled. + */ INLINE int Texture:: get_expected_num_mipmap_levels() const { CDReader cdata(_cycler); return do_get_expected_num_mipmap_levels(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_mipmap_x_size -// Access: Published -// Description: Returns the x_size that the nth mipmap level should -// have, based on the texture's size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x_size that the nth mipmap level should have, based on the + * texture's size. + */ INLINE int Texture:: get_expected_mipmap_x_size(int n) const { CDReader cdata(_cycler); return do_get_expected_mipmap_x_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_mipmap_y_size -// Access: Published -// Description: Returns the y_size that the nth mipmap level should -// have, based on the texture's size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y_size that the nth mipmap level should have, based on the + * texture's size. + */ INLINE int Texture:: get_expected_mipmap_y_size(int n) const { CDReader cdata(_cycler); return do_get_expected_mipmap_y_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_mipmap_z_size -// Access: Published -// Description: Returns the z_size that the nth mipmap level should -// have, based on the texture's size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the z_size that the nth mipmap level should have, based on the + * texture's size. + */ INLINE int Texture:: get_expected_mipmap_z_size(int n) const { CDReader cdata(_cycler); return do_get_expected_mipmap_z_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_mipmap_num_pages -// Access: Published -// Description: Returns the total number of pages that the nth mipmap -// level should have, based on the texture's size. This -// is usually the same as get_expected_mipmap_z_size(), -// except for a multiview texture, in which case it is -// get_expected_mipmap_z_size() * get_num_views(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of pages that the nth mipmap level should have, + * based on the texture's size. This is usually the same as + * get_expected_mipmap_z_size(), except for a multiview texture, in which case + * it is get_expected_mipmap_z_size() * get_num_views(). + */ INLINE int Texture:: get_expected_mipmap_num_pages(int n) const { CDReader cdata(_cycler); return do_get_expected_mipmap_num_pages(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_ram_image -// Access: Published -// Description: Returns true if the Texture has its image contents -// available in main RAM, false if it exists only in -// texture memory or in the prepared GSG context. -// -// Note that this has nothing to do with whether -// get_ram_image() will fail or not. Even if -// has_ram_image() returns false, get_ram_image() may -// still return a valid RAM image, because -// get_ram_image() will automatically load the texture -// from disk if necessary. The only thing -// has_ram_image() tells you is whether the texture is -// available right now without hitting the disk first. -// -// Note also that if an application uses only one GSG, -// it may appear that has_ram_image() returns true if -// the texture has not yet been loaded by the GSG, but -// this correlation is not true in general and should -// not be depended on. Specifically, if an application -// ever uses multiple GSG's in its lifetime (for -// instance, by opening more than one window, or by -// closing its window and opening another one later), -// then has_ram_image() may well return false on -// textures that have never been loaded on the current -// GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Texture has its image contents available in main RAM, + * false if it exists only in texture memory or in the prepared GSG context. + * + * Note that this has nothing to do with whether get_ram_image() will fail or + * not. Even if has_ram_image() returns false, get_ram_image() may still + * return a valid RAM image, because get_ram_image() will automatically load + * the texture from disk if necessary. The only thing has_ram_image() tells + * you is whether the texture is available right now without hitting the disk + * first. + * + * Note also that if an application uses only one GSG, it may appear that + * has_ram_image() returns true if the texture has not yet been loaded by the + * GSG, but this correlation is not true in general and should not be depended + * on. Specifically, if an application ever uses multiple GSG's in its + * lifetime (for instance, by opening more than one window, or by closing its + * window and opening another one later), then has_ram_image() may well return + * false on textures that have never been loaded on the current GSG. + */ INLINE bool Texture:: has_ram_image() const { CDReader cdata(_cycler); return do_has_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_uncompressed_ram_image -// Access: Published -// Description: Returns true if the Texture has its image contents -// available in main RAM and is uncompressed, false -// otherwise. See has_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Texture has its image contents available in main RAM + * and is uncompressed, false otherwise. See has_ram_image(). + */ INLINE bool Texture:: has_uncompressed_ram_image() const { CDReader cdata(_cycler); return do_has_uncompressed_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::might_have_ram_image -// Access: Published -// Description: Returns true if the texture's image contents are -// currently available in main RAM, or there is reason -// to believe it can be loaded on demand. That is, this -// function returns a "best guess" as to whether -// get_ram_image() will succeed without actually calling -// it first. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture's image contents are currently available in + * main RAM, or there is reason to believe it can be loaded on demand. That + * is, this function returns a "best guess" as to whether get_ram_image() will + * succeed without actually calling it first. + */ INLINE bool Texture:: might_have_ram_image() const { CDReader cdata(_cycler); return (do_has_ram_image(cdata) || !cdata->_fullpath.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_image_size -// Access: Published -// Description: Returns the total number of bytes used by the -// in-memory image, across all pages and views, or 0 if -// there is no in-memory image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes used by the in-memory image, across all + * pages and views, or 0 if there is no in-memory image. + */ INLINE size_t Texture:: get_ram_image_size() const { CDReader cdata(_cycler); return do_get_ram_image_size(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_view_size -// Access: Published -// Description: Returns the number of bytes used by the in-memory -// image per view, or 0 if there is no in-memory image. -// Since each view is a stack of z_size pages, this is -// get_z_size() * get_ram_page_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the in-memory image per view, or 0 if + * there is no in-memory image. Since each view is a stack of z_size pages, + * this is get_z_size() * get_ram_page_size(). + */ INLINE size_t Texture:: get_ram_view_size() const { CDReader cdata(_cycler); @@ -1626,18 +1287,15 @@ get_ram_view_size() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_page_size -// Access: Published -// Description: Returns the number of bytes used by the in-memory -// image per page, or 0 if there is no in-memory image. -// -// For a non-compressed texture, this is the same as -// get_expected_ram_page_size(). For a compressed -// texture, this may be a smaller value. (We do assume -// that all pages will be the same size on a compressed -// texture). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the in-memory image per page, or 0 if + * there is no in-memory image. + * + * For a non-compressed texture, this is the same as + * get_expected_ram_page_size(). For a compressed texture, this may be a + * smaller value. (We do assume that all pages will be the same size on a + * compressed texture). + */ INLINE size_t Texture:: get_ram_page_size() const { CDReader cdata(_cycler); @@ -1648,93 +1306,74 @@ get_ram_page_size() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_ram_image_size -// Access: Published -// Description: Returns the number of bytes that *ought* to be used -// by the in-memory image, based on the texture -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that *ought* to be used by the in-memory image, + * based on the texture parameters. + */ INLINE size_t Texture:: get_expected_ram_image_size() const { CDReader cdata(_cycler); return do_get_expected_ram_image_size(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_ram_page_size -// Access: Published -// Description: Returns the number of bytes that should be used per -// each Z page of the 3-d texture. For a 2-d or 1-d -// texture, this is the same as -// get_expected_ram_image_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that should be used per each Z page of the 3-d + * texture. For a 2-d or 1-d texture, this is the same as + * get_expected_ram_image_size(). + */ INLINE size_t Texture:: get_expected_ram_page_size() const { CDReader cdata(_cycler); return do_get_expected_ram_page_size(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_image -// Access: Published -// Description: Returns the system-RAM image data associated with the -// texture. If the texture does not currently have an -// associated RAM image, and the texture was generated -// by loading an image from a disk file (the most common -// case), this forces the reload of the same texture. -// This can happen if keep_texture_ram is configured to -// false, and we have previously prepared this texture -// with a GSG. -// -// Note that it is not correct to call has_ram_image() -// first to test whether this function will fail. A -// false return value from has_ram_image() indicates -// only that get_ram_image() may need to reload the -// texture from disk, which it will do automatically. -// However, you can call might_have_ram_image(), which -// will return true if the ram image exists, or there is -// a reasonable reason to believe it can be loaded. -// -// On the other hand, it is possible that the texture -// cannot be found on disk or is otherwise unavailable. -// If that happens, this function will return NULL. -// There is no way to predict with 100% accuracy whether -// get_ram_image() will return NULL without calling it -// first; might_have_ram_image() is the closest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system-RAM image data associated with the texture. If the + * texture does not currently have an associated RAM image, and the texture + * was generated by loading an image from a disk file (the most common case), + * this forces the reload of the same texture. This can happen if + * keep_texture_ram is configured to false, and we have previously prepared + * this texture with a GSG. + * + * Note that it is not correct to call has_ram_image() first to test whether + * this function will fail. A false return value from has_ram_image() + * indicates only that get_ram_image() may need to reload the texture from + * disk, which it will do automatically. However, you can call + * might_have_ram_image(), which will return true if the ram image exists, or + * there is a reasonable reason to believe it can be loaded. + * + * On the other hand, it is possible that the texture cannot be found on disk + * or is otherwise unavailable. If that happens, this function will return + * NULL. There is no way to predict with 100% accuracy whether get_ram_image() + * will return NULL without calling it first; might_have_ram_image() is the + * closest. + */ INLINE CPTA_uchar Texture:: get_ram_image() { CDWriter cdata(_cycler, unlocked_ensure_ram_image(true)); return do_get_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_image_compression -// Access: Published -// Description: Returns the compression mode in which the ram image -// is already stored pre-compressed. If this is other -// than CM_off, you cannot rely on the contents of the -// ram image to be anything predicatable (it will not be -// an array of x by y pixels, and it probably won't have -// the same length as get_expected_ram_image_size()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the compression mode in which the ram image is already stored pre- + * compressed. If this is other than CM_off, you cannot rely on the contents + * of the ram image to be anything predicatable (it will not be an array of x + * by y pixels, and it probably won't have the same length as + * get_expected_ram_image_size()). + */ INLINE Texture::CompressionMode Texture:: get_ram_image_compression() const { CDReader cdata(_cycler); return cdata->_ram_image_compression; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::modify_ram_image -// Access: Published -// Description: Returns a modifiable pointer to the system-RAM image. -// This assumes the RAM image should be uncompressed. -// If the RAM image has been dumped, or is stored -// compressed, creates a new one. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the system-RAM image. This assumes the RAM + * image should be uncompressed. If the RAM image has been dumped, or is + * stored compressed, creates a new one. + * + * This does *not* affect keep_ram_image. + */ INLINE PTA_uchar Texture:: modify_ram_image() { CDWriter cdata(_cycler, true); @@ -1742,40 +1381,32 @@ modify_ram_image() { return do_modify_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_uncompressed_ram_image -// Access: Published -// Description: Returns the system-RAM image associated with the -// texture, in an uncompressed form if at all possible. -// -// If get_ram_image_compression() is CM_off, then the -// system-RAM image is already uncompressed, and this -// returns the same thing as get_ram_image(). -// -// If get_ram_image_compression() is anything else, then -// the system-RAM image is compressed. In this case, -// the image will be reloaded from the *original* file -// (not from the cache), in the hopes that an -// uncompressed image will be found there. -// -// If an uncompressed image cannot be found, returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system-RAM image associated with the texture, in an + * uncompressed form if at all possible. + * + * If get_ram_image_compression() is CM_off, then the system-RAM image is + * already uncompressed, and this returns the same thing as get_ram_image(). + * + * If get_ram_image_compression() is anything else, then the system-RAM image + * is compressed. In this case, the image will be reloaded from the + * *original* file (not from the cache), in the hopes that an uncompressed + * image will be found there. + * + * If an uncompressed image cannot be found, returns NULL. + */ INLINE CPTA_uchar Texture:: get_uncompressed_ram_image() { CDWriter cdata(_cycler, false); return do_get_uncompressed_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_ram_image -// Access: Published -// Description: Discards the current system-RAM image for the -// texture, if any, and allocates a new buffer of the -// appropriate size. Returns the new buffer. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Discards the current system-RAM image for the texture, if any, and + * allocates a new buffer of the appropriate size. Returns the new buffer. + * + * This does *not* affect keep_ram_image. + */ INLINE PTA_uchar Texture:: make_ram_image() { CDWriter cdata(_cycler, true); @@ -1783,16 +1414,13 @@ make_ram_image() { return do_make_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_ram_image -// Access: Published -// Description: Replaces the current system-RAM image with the new -// data. If compression is not CM_off, it indicates -// that the new data is already pre-compressed in the -// indicated format. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current system-RAM image with the new data. If compression is + * not CM_off, it indicates that the new data is already pre-compressed in the + * indicated format. + * + * This does *not* affect keep_ram_image. + */ INLINE void Texture:: set_ram_image(CPTA_uchar image, Texture::CompressionMode compression, size_t page_size) { @@ -1800,63 +1428,49 @@ set_ram_image(CPTA_uchar image, Texture::CompressionMode compression, do_set_ram_image(cdata, image, compression, page_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_ram_image -// Access: Published -// Description: Discards the current system-RAM image. -//////////////////////////////////////////////////////////////////// +/** + * Discards the current system-RAM image. + */ INLINE void Texture:: clear_ram_image() { CDWriter cdata(_cycler, false); do_clear_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_keep_ram_image -// Access: Published -// Description: Sets the flag that indicates whether this Texture is -// eligible to have its main RAM copy of the texture -// memory dumped when the texture is prepared for -// rendering. -// -// This will be false for most textures, which can -// reload their images if needed by rereading the input -// file. However, textures that were generated -// dynamically and cannot be easily reloaded will want -// to set this flag to true, so that the texture will -// always keep its image copy around. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether this Texture is eligible to have its + * main RAM copy of the texture memory dumped when the texture is prepared for + * rendering. + * + * This will be false for most textures, which can reload their images if + * needed by rereading the input file. However, textures that were generated + * dynamically and cannot be easily reloaded will want to set this flag to + * true, so that the texture will always keep its image copy around. + */ INLINE void Texture:: set_keep_ram_image(bool keep_ram_image) { CDWriter cdata(_cycler, true); cdata->_keep_ram_image = keep_ram_image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::compress_ram_image -// Access: Published -// Description: Attempts to compress the texture's RAM image -// internally, to a format supported by the indicated -// GSG. In order for this to work, the squish library -// must have been compiled into Panda. -// -// If compression is CM_on, then an appropriate -// compression method that is supported by the indicated -// GSG is automatically chosen. If the GSG pointer is -// NULL, any of the standard DXT1/3/5 compression -// methods will be used, regardless of whether it is -// supported. -// -// If compression is any specific compression method, -// that method is used regardless of whether the GSG -// supports it. -// -// quality_level determines the speed/quality tradeoff -// of the compression. If it is QL_default, the -// texture's own quality_level parameter is used. -// -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to compress the texture's RAM image internally, to a format + * supported by the indicated GSG. In order for this to work, the squish + * library must have been compiled into Panda. + * + * If compression is CM_on, then an appropriate compression method that is + * supported by the indicated GSG is automatically chosen. If the GSG pointer + * is NULL, any of the standard DXT1/3/5 compression methods will be used, + * regardless of whether it is supported. + * + * If compression is any specific compression method, that method is used + * regardless of whether the GSG supports it. + * + * quality_level determines the speed/quality tradeoff of the compression. If + * it is QL_default, the texture's own quality_level parameter is used. + * + * Returns true if successful, false otherwise. + */ INLINE bool Texture:: compress_ram_image(Texture::CompressionMode compression, Texture::QualityLevel quality_level, @@ -1869,17 +1483,13 @@ compress_ram_image(Texture::CompressionMode compression, return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::uncompress_ram_image -// Access: Published -// Description: Attempts to uncompress the texture's RAM image -// internally. In order for this to work, the squish -// library must have been compiled into Panda, and the -// ram image must be compressed in a format supported by -// squish. -// -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to uncompress the texture's RAM image internally. In order for + * this to work, the squish library must have been compiled into Panda, and + * the ram image must be compressed in a format supported by squish. + * + * Returns true if successful, false otherwise. + */ INLINE bool Texture:: uncompress_ram_image() { CDWriter cdata(_cycler, false); @@ -1890,59 +1500,46 @@ uncompress_ram_image() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_num_ram_mipmap_images -// Access: Published -// Description: Returns the maximum number of mipmap level images -// available in system memory. The actual number may be -// less than this (that is, there might be gaps in the -// sequence); use has_ram_mipmap_image() to verify each -// level. -// -// Also see get_num_loadable_ram_mipmap_images(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of mipmap level images available in system + * memory. The actual number may be less than this (that is, there might be + * gaps in the sequence); use has_ram_mipmap_image() to verify each level. + * + * Also see get_num_loadable_ram_mipmap_images(). + */ INLINE int Texture:: get_num_ram_mipmap_images() const { CDReader cdata(_cycler); return cdata->_ram_images.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_ram_mipmap_image -// Access: Published -// Description: Returns true if the Texture has the nth mipmap level -// available in system memory, false otherwise. If the -// texture's minfilter mode requires mipmapping (see -// uses_mipmaps()), and all the texture's mipmap levels -// are not available when the texture is rendered, they -// will be generated automatically. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Texture has the nth mipmap level available in system + * memory, false otherwise. If the texture's minfilter mode requires + * mipmapping (see uses_mipmaps()), and all the texture's mipmap levels are + * not available when the texture is rendered, they will be generated + * automatically. + */ INLINE bool Texture:: has_ram_mipmap_image(int n) const { CDReader cdata(_cycler); return do_has_ram_mipmap_image(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_all_ram_mipmap_images -// Access: Published -// Description: Returns true if all expected mipmap levels have been -// defined and exist in the system RAM, or false if even -// one mipmap level is missing. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all expected mipmap levels have been defined and exist in + * the system RAM, or false if even one mipmap level is missing. + */ INLINE bool Texture:: has_all_ram_mipmap_images() const { CDReader cdata(_cycler); return do_has_all_ram_mipmap_images(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_mipmap_image_size -// Access: Published -// Description: Returns the number of bytes used by the in-memory -// image for mipmap level n, or 0 if there is no -// in-memory image for this mipmap level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the in-memory image for mipmap level n, + * or 0 if there is no in-memory image for this mipmap level. + */ INLINE size_t Texture:: get_ram_mipmap_image_size(int n) const { CDReader cdata(_cycler); @@ -1952,100 +1549,79 @@ get_ram_mipmap_image_size(int n) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_mipmap_view_size -// Access: Published -// Description: Returns the number of bytes used by the in-memory -// image per view for mipmap level n, or 0 if there is -// no in-memory image for this mipmap level. -// -// A "view" is a collection of z_size pages for each -// mipmap level. Most textures have only one view, -// except for multiview or stereo textures. -// -// For a non-compressed texture, this is the same as -// get_expected_ram_mipmap_view_size(). For a compressed -// texture, this may be a smaller value. (We do assume -// that all pages will be the same size on a compressed -// texture). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the in-memory image per view for mipmap + * level n, or 0 if there is no in-memory image for this mipmap level. + * + * A "view" is a collection of z_size pages for each mipmap level. Most + * textures have only one view, except for multiview or stereo textures. + * + * For a non-compressed texture, this is the same as + * get_expected_ram_mipmap_view_size(). For a compressed texture, this may be + * a smaller value. (We do assume that all pages will be the same size on a + * compressed texture). + */ INLINE size_t Texture:: get_ram_mipmap_view_size(int n) const { CDReader cdata(_cycler); return do_get_ram_mipmap_page_size(cdata, n) * do_get_expected_mipmap_z_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_mipmap_page_size -// Access: Published -// Description: Returns the number of bytes used by the in-memory -// image per page for mipmap level n, or 0 if there is -// no in-memory image for this mipmap level. -// -// For a non-compressed texture, this is the same as -// get_expected_ram_mipmap_page_size(). For a compressed -// texture, this may be a smaller value. (We do assume -// that all pages will be the same size on a compressed -// texture). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the in-memory image per page for mipmap + * level n, or 0 if there is no in-memory image for this mipmap level. + * + * For a non-compressed texture, this is the same as + * get_expected_ram_mipmap_page_size(). For a compressed texture, this may be + * a smaller value. (We do assume that all pages will be the same size on a + * compressed texture). + */ INLINE size_t Texture:: get_ram_mipmap_page_size(int n) const { CDReader cdata(_cycler); return do_get_ram_mipmap_page_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_ram_mipmap_image_size -// Access: Published -// Description: Returns the number of bytes that *ought* to be used -// by the in-memory image for mipmap level n, based on -// the texture parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that *ought* to be used by the in-memory image + * for mipmap level n, based on the texture parameters. + */ INLINE size_t Texture:: get_expected_ram_mipmap_image_size(int n) const { CDReader cdata(_cycler); return do_get_expected_ram_mipmap_image_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_ram_mipmap_view_size -// Access: Published -// Description: Returns the number of bytes that *ought* to be used -// by each view of the in-memory image for mipmap level -// n, based on the texture parameters. For a normal, -// non-multiview texture, this is the same as -// get_expected_ram_mipmap_image_size(n). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that *ought* to be used by each view of the in- + * memory image for mipmap level n, based on the texture parameters. For a + * normal, non-multiview texture, this is the same as + * get_expected_ram_mipmap_image_size(n). + */ INLINE size_t Texture:: get_expected_ram_mipmap_view_size(int n) const { CDReader cdata(_cycler); return do_get_expected_ram_mipmap_view_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_expected_ram_mipmap_page_size -// Access: Published -// Description: Returns the number of bytes that should be used per -// each Z page of the 3-d texture, for mipmap level n. -// For a 2-d or 1-d texture, this is the same as -// get_expected_ram_mipmap_view_size(n). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes that should be used per each Z page of the 3-d + * texture, for mipmap level n. For a 2-d or 1-d texture, this is the same as + * get_expected_ram_mipmap_view_size(n). + */ INLINE size_t Texture:: get_expected_ram_mipmap_page_size(int n) const { CDReader cdata(_cycler); return do_get_expected_ram_mipmap_page_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::modify_ram_mipmap_image -// Access: Published -// Description: Returns a modifiable pointer to the system-RAM image -// for the nth mipmap level. This assumes the RAM image -// is uncompressed; if this is not the case, raises an -// assertion. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the system-RAM image for the nth mipmap + * level. This assumes the RAM image is uncompressed; if this is not the + * case, raises an assertion. + * + * This does *not* affect keep_ram_image. + */ INLINE PTA_uchar Texture:: modify_ram_mipmap_image(int n) { CDWriter cdata(_cycler, false); @@ -2053,15 +1629,12 @@ modify_ram_mipmap_image(int n) { return do_modify_ram_mipmap_image(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_ram_mipmap_image -// Access: Published -// Description: Discards the current system-RAM image for the -// nth mipmap level, if any, and allocates a new buffer -// of the appropriate size. Returns the new buffer. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Discards the current system-RAM image for the nth mipmap level, if any, and + * allocates a new buffer of the appropriate size. Returns the new buffer. + * + * This does *not* affect keep_ram_image. + */ INLINE PTA_uchar Texture:: make_ram_mipmap_image(int n) { CDWriter cdata(_cycler, false); @@ -2069,29 +1642,23 @@ make_ram_mipmap_image(int n) { return do_make_ram_mipmap_image(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_ram_mipmap_image -// Access: Published -// Description: Replaces the current system-RAM image for the -// indicated mipmap level with the new data. If -// compression is not CM_off, it indicates that the new -// data is already pre-compressed in the indicated -// format. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current system-RAM image for the indicated mipmap level with + * the new data. If compression is not CM_off, it indicates that the new data + * is already pre-compressed in the indicated format. + * + * This does *not* affect keep_ram_image. + */ INLINE void Texture:: set_ram_mipmap_image(int n, CPTA_uchar image, size_t page_size) { CDWriter cdata(_cycler, false); do_set_ram_mipmap_image(cdata, n, image, page_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_ram_mipmap_images -// Access: Published -// Description: Discards the current system-RAM image for all -// mipmap levels, except level 0 (the base image). -//////////////////////////////////////////////////////////////////// +/** + * Discards the current system-RAM image for all mipmap levels, except level 0 + * (the base image). + */ INLINE void Texture:: clear_ram_mipmap_images() { CDWriter cdata(_cycler, false); @@ -2099,20 +1666,16 @@ clear_ram_mipmap_images() { do_clear_ram_mipmap_images(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::generate_ram_mipmap_images -// Access: Published -// Description: Automatically fills in the n mipmap levels of the -// Texture, based on the texture's source image. This -// requires the texture's uncompressed ram image to be -// available in system memory. If it is not already, it -// will be fetched if possible. -// -// This call is not normally necessary, since the mipmap -// levels will be generated automatically if needed. -// But there may be certain cases in which you would -// like to call this explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Automatically fills in the n mipmap levels of the Texture, based on the + * texture's source image. This requires the texture's uncompressed ram image + * to be available in system memory. If it is not already, it will be fetched + * if possible. + * + * This call is not normally necessary, since the mipmap levels will be + * generated automatically if needed. But there may be certain cases in which + * you would like to call this explicitly. + */ INLINE void Texture:: generate_ram_mipmap_images() { CDWriter cdata(_cycler, unlocked_ensure_ram_image(false)); @@ -2120,213 +1683,168 @@ generate_ram_mipmap_images() { do_generate_ram_mipmap_images(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_simple_x_size -// Access: Published -// Description: Returns the width of the "simple" image in texels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the "simple" image in texels. + */ INLINE int Texture:: get_simple_x_size() const { CDReader cdata(_cycler); return cdata->_simple_x_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_simple_y_size -// Access: Published -// Description: Returns the height of the "simple" image in texels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the "simple" image in texels. + */ INLINE int Texture:: get_simple_y_size() const { CDReader cdata(_cycler); return cdata->_simple_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_simple_ram_image -// Access: Published, Virtual -// Description: Returns true if the Texture has a "simple" image -// available in main RAM. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Texture has a "simple" image available in main RAM. + */ INLINE bool Texture:: has_simple_ram_image() const { CDReader cdata(_cycler); return !cdata->_simple_ram_image._image.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_simple_ram_image_size -// Access: Published -// Description: Returns the number of bytes used by the "simple" -// image, or 0 if there is no simple image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes used by the "simple" image, or 0 if there is no + * simple image. + */ INLINE size_t Texture:: get_simple_ram_image_size() const { CDReader cdata(_cycler); return cdata->_simple_ram_image._image.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_simple_ram_image -// Access: Published -// Description: Returns the image data associated with the "simple" -// texture image. This is provided for some textures as -// an option to display while the main texture image is -// being loaded from disk. -// -// Unlike get_ram_image(), this function will always -// return immediately. Either the simple image is -// available, or it is not. -// -// The "simple" image is always 4 components, 1 byte -// each, regardless of the parameters of the full -// texture. The simple image is only supported for -// ordinary 2-d textures. -//////////////////////////////////////////////////////////////////// +/** + * Returns the image data associated with the "simple" texture image. This is + * provided for some textures as an option to display while the main texture + * image is being loaded from disk. + * + * Unlike get_ram_image(), this function will always return immediately. + * Either the simple image is available, or it is not. + * + * The "simple" image is always 4 components, 1 byte each, regardless of the + * parameters of the full texture. The simple image is only supported for + * ordinary 2-d textures. + */ INLINE CPTA_uchar Texture:: get_simple_ram_image() const { CDReader cdata(_cycler); return cdata->_simple_ram_image._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_simple_ram_image -// Access: Published -// Description: Replaces the internal "simple" texture image. This -// can be used as an option to display while the main -// texture image is being loaded from disk. It is -// normally a very small image, 16x16 or smaller (and -// maybe even 1x1), that is designed to give just enough -// sense of color to serve as a placeholder until the -// full texture is available. -// -// The "simple" image is always 4 components, 1 byte -// each, regardless of the parameters of the full -// texture. The simple image is only supported for -// ordinary 2-d textures. -// -// Also see generate_simple_ram_image(), -// modify_simple_ram_image(), and -// new_simple_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Replaces the internal "simple" texture image. This can be used as an + * option to display while the main texture image is being loaded from disk. + * It is normally a very small image, 16x16 or smaller (and maybe even 1x1), + * that is designed to give just enough sense of color to serve as a + * placeholder until the full texture is available. + * + * The "simple" image is always 4 components, 1 byte each, regardless of the + * parameters of the full texture. The simple image is only supported for + * ordinary 2-d textures. + * + * Also see generate_simple_ram_image(), modify_simple_ram_image(), and + * new_simple_ram_image(). + */ INLINE void Texture:: set_simple_ram_image(CPTA_uchar image, int x_size, int y_size) { CDWriter cdata(_cycler, true); do_set_simple_ram_image(cdata, image, x_size, y_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_simple_ram_image -// Access: Published -// Description: Discards the current "simple" image. -//////////////////////////////////////////////////////////////////// +/** + * Discards the current "simple" image. + */ INLINE void Texture:: clear_simple_ram_image() { CDWriter cdata(_cycler, true); do_clear_simple_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_properties_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture properties -// (unrelated to the image) are modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture properties (unrelated to the image) are modified. + */ INLINE UpdateSeq Texture:: get_properties_modified() const { CDReader cdata(_cycler); return cdata->_properties_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_image_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture image data -// (including mipmap levels) are modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture image data (including mipmap levels) are modified. + */ INLINE UpdateSeq Texture:: get_image_modified() const { CDReader cdata(_cycler); return cdata->_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_simple_image_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture's "simple" -// image data is modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture's "simple" image data is modified. + */ INLINE UpdateSeq Texture:: get_simple_image_modified() const { CDReader cdata(_cycler); return cdata->_simple_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_auto_texture_scale -// Access: Published -// Description: Specifies the power-of-2 texture-scaling mode that -// will be applied to this particular texture when it is -// next loaded from disk. See set_textures_power_2(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the power-of-2 texture-scaling mode that will be applied to this + * particular texture when it is next loaded from disk. See + * set_textures_power_2(). + */ INLINE void Texture:: set_auto_texture_scale(AutoTextureScale scale) { CDWriter cdata(_cycler, true); cdata->_auto_texture_scale = scale; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_auto_texture_scale -// Access: Published -// Description: Returns the power-of-2 texture-scaling mode that will -// be applied to this particular texture when it is next -// loaded from disk. See set_textures_power_2(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the power-of-2 texture-scaling mode that will be applied to this + * particular texture when it is next loaded from disk. See + * set_textures_power_2(). + */ INLINE AutoTextureScale Texture:: get_auto_texture_scale() const { CDReader cdata(_cycler); return do_get_auto_texture_scale(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_auto_texture_scale -// Access: Published -// Description: Returns true if set_auto_texture_scale() has been set -// to something other than ATS_unspecified for this -// particular texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_auto_texture_scale() has been set to something other + * than ATS_unspecified for this particular texture. + */ INLINE bool Texture:: has_auto_texture_scale() const { CDReader cdata(_cycler); return (cdata->_auto_texture_scale != ATS_unspecified); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_textures_power_2 -// Access: Published, Static -// Description: Set this flag to ATS_none, ATS_up, ATS_down, or -// ATS_pad to control the scaling of textures in -// general, if a particular texture does not override -// this. See also set_auto_texture_scale() for the -// per-texture override. -//////////////////////////////////////////////////////////////////// +/** + * Set this flag to ATS_none, ATS_up, ATS_down, or ATS_pad to control the + * scaling of textures in general, if a particular texture does not override + * this. See also set_auto_texture_scale() for the per-texture override. + */ INLINE void Texture:: set_textures_power_2(AutoTextureScale scale) { _textures_power_2 = scale; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_textures_power_2 -// Access: Published, Static -// Description: This flag returns ATS_none, ATS_up, or ATS_down -// and controls the scaling of textures in general. It -// is initialized from the config variable of the same -// name, but it can be subsequently adjusted. See also -// get_auto_texture_scale(). -//////////////////////////////////////////////////////////////////// +/** + * This flag returns ATS_none, ATS_up, or ATS_down and controls the scaling of + * textures in general. It is initialized from the config variable of the + * same name, but it can be subsequently adjusted. See also + * get_auto_texture_scale(). + */ INLINE AutoTextureScale Texture:: get_textures_power_2() { if (_textures_power_2 == ATS_unspecified) { @@ -2336,369 +1854,288 @@ get_textures_power_2() { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_textures_power_2 -// Access: Published, Static -// Description: If true, then get_textures_power_2 has been -// set using set_textures_power_2. -// If false, then get_textures_power_2 simply -// returns the config variable of the same name. -//////////////////////////////////////////////////////////////////// +/** + * If true, then get_textures_power_2 has been set using set_textures_power_2. + * If false, then get_textures_power_2 simply returns the config variable of + * the same name. + */ INLINE bool Texture:: has_textures_power_2() { return (_textures_power_2 != ATS_unspecified); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_filename -// Access: Published -// Description: Sets the name of the file that contains the image's -// contents. Normally, this is set automatically when -// the image is loaded, for instance via -// Texture::read(). -// -// The Texture's get_name() function used to return -// the filename, but now returns just the basename -// (without the extension), which is a more useful name -// for identifying an image in show code. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the file that contains the image's contents. Normally, + * this is set automatically when the image is loaded, for instance via + * Texture::read(). + * + * The Texture's get_name() function used to return the filename, but now + * returns just the basename (without the extension), which is a more useful + * name for identifying an image in show code. + */ INLINE void Texture:: set_filename(const Filename &filename) { CDWriter cdata(_cycler, true); cdata->_filename = filename; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_filename -// Access: Published -// Description: Removes the alpha filename, if it was previously set. -// See set_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the alpha filename, if it was previously set. See set_filename(). + */ INLINE void Texture:: clear_filename() { CDWriter cdata(_cycler, true); cdata->_filename = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_alpha_filename -// Access: Published -// Description: Sets the name of the file that contains the image's -// alpha channel contents. Normally, this is set -// automatically when the image is loaded, for instance -// via Texture::read(). -// -// The Texture's get_filename() function returns the -// name of the image file that was loaded into the -// buffer. In the case where a texture specified two -// separate files to load, a 1- or 3-channel color image -// and a 1-channel alpha image, this Filename is update -// to contain the name of the image file that was loaded -// into the buffer's alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the file that contains the image's alpha channel contents. + * Normally, this is set automatically when the image is loaded, for instance + * via Texture::read(). + * + * The Texture's get_filename() function returns the name of the image file + * that was loaded into the buffer. In the case where a texture specified two + * separate files to load, a 1- or 3-channel color image and a 1-channel alpha + * image, this Filename is update to contain the name of the image file that + * was loaded into the buffer's alpha channel. + */ INLINE void Texture:: set_alpha_filename(const Filename &alpha_filename) { CDWriter cdata(_cycler, true); cdata->_alpha_filename = alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_alpha_filename -// Access: Published -// Description: Removes the alpha filename, if it was previously set. -// See set_alpha_filename(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the alpha filename, if it was previously set. See + * set_alpha_filename(). + */ INLINE void Texture:: clear_alpha_filename() { CDWriter cdata(_cycler, true); cdata->_alpha_filename = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_fullpath -// Access: Published -// Description: Sets the full pathname to the file that contains the -// image's contents, as found along the search path. -// Normally, this is set automatically when the image is -// loaded, for instance via Texture::read(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the full pathname to the file that contains the image's contents, as + * found along the search path. Normally, this is set automatically when the + * image is loaded, for instance via Texture::read(). + */ INLINE void Texture:: set_fullpath(const Filename &fullpath) { CDWriter cdata(_cycler, true); cdata->_fullpath = fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_fullpath -// Access: Published -// Description: Removes the alpha fullpath, if it was previously set. -// See set_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the alpha fullpath, if it was previously set. See set_fullpath(). + */ INLINE void Texture:: clear_fullpath() { CDWriter cdata(_cycler, true); cdata->_fullpath = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_alpha_fullpath -// Access: Published -// Description: Sets the full pathname to the file that contains the -// image's alpha channel contents, as found along the -// search path. Normally, this is set automatically -// when the image is loaded, for instance via -// Texture::read(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the full pathname to the file that contains the image's alpha channel + * contents, as found along the search path. Normally, this is set + * automatically when the image is loaded, for instance via Texture::read(). + */ INLINE void Texture:: set_alpha_fullpath(const Filename &alpha_fullpath) { CDWriter cdata(_cycler, true); cdata->_alpha_fullpath = alpha_fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_alpha_fullpath -// Access: Published -// Description: Removes the alpha fullpath, if it was previously set. -// See set_alpha_fullpath(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the alpha fullpath, if it was previously set. See + * set_alpha_fullpath(). + */ INLINE void Texture:: clear_alpha_fullpath() { CDWriter cdata(_cycler, true); cdata->_alpha_fullpath = Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_x_size -// Access: Published -// Description: Changes the x size indicated for the texture. This -// also implicitly unloads the texture if it has already -// been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Changes the x size indicated for the texture. This also implicitly unloads + * the texture if it has already been loaded. + */ INLINE void Texture:: set_x_size(int x_size) { CDWriter cdata(_cycler, true); do_set_x_size(cdata, x_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_y_size -// Access: Published -// Description: Changes the y size indicated for the texture. This -// also implicitly unloads the texture if it has already -// been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Changes the y size indicated for the texture. This also implicitly unloads + * the texture if it has already been loaded. + */ INLINE void Texture:: set_y_size(int y_size) { CDWriter cdata(_cycler, true); do_set_y_size(cdata, y_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_z_size -// Access: Published -// Description: Changes the z size indicated for the texture. This -// also implicitly unloads the texture if it has already -// been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Changes the z size indicated for the texture. This also implicitly unloads + * the texture if it has already been loaded. + */ INLINE void Texture:: set_z_size(int z_size) { CDWriter cdata(_cycler, true); do_set_z_size(cdata, z_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_num_views -// Access: Published -// Description: Sets the number of "views" within a texture. A view -// is a completely separate image stored within the -// Texture object. Most textures have only one view, -// but a stereo texture, for instance, may have two -// views, a left and a right image. Other uses for -// multiple views are not yet defined. -// -// If this value is greater than one, the additional -// views are accessed as additional pages beyond -// get_z_size(). -// -// This also implicitly unloads the texture if it has -// already been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of "views" within a texture. A view is a completely + * separate image stored within the Texture object. Most textures have only + * one view, but a stereo texture, for instance, may have two views, a left + * and a right image. Other uses for multiple views are not yet defined. + * + * If this value is greater than one, the additional views are accessed as + * additional pages beyond get_z_size(). + * + * This also implicitly unloads the texture if it has already been loaded. + */ INLINE void Texture:: set_num_views(int num_views) { CDWriter cdata(_cycler, true); do_set_num_views(cdata, num_views); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_format -// Access: Published -// Description: Changes the format value for the texture components. -// This implicitly sets num_components as well. -//////////////////////////////////////////////////////////////////// +/** + * Changes the format value for the texture components. This implicitly sets + * num_components as well. + */ INLINE void Texture:: set_format(Texture::Format format) { CDWriter cdata(_cycler, true); do_set_format(cdata, format); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_component_type -// Access: Published -// Description: Changes the data value for the texture components. -// This implicitly sets component_width as well. -//////////////////////////////////////////////////////////////////// +/** + * Changes the data value for the texture components. This implicitly sets + * component_width as well. + */ INLINE void Texture:: set_component_type(Texture::ComponentType component_type) { CDWriter cdata(_cycler, true); do_set_component_type(cdata, component_type); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_loaded_from_image -// Access: Published -// Description: Sets the flag that indicates the texture has been -// loaded from a disk file or PNMImage. You should also -// ensure the filename has been set correctly. When -// this flag is true, the texture may be automatically -// reloaded when its ram image needs to be replaced. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates the texture has been loaded from a disk file + * or PNMImage. You should also ensure the filename has been set correctly. + * When this flag is true, the texture may be automatically reloaded when its + * ram image needs to be replaced. + */ INLINE void Texture:: set_loaded_from_image() { CDWriter cdata(_cycler, false); cdata->_loaded_from_image = true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_loaded_from_image -// Access: Published -// Description: Returns the flag that indicates the texture has been -// loaded from a disk file or PNMImage. See -// set_loaded_from_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates the texture has been loaded from a disk + * file or PNMImage. See set_loaded_from_image(). + */ INLINE bool Texture:: get_loaded_from_image() const { CDReader cdata(_cycler); return cdata->_loaded_from_image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_loaded_from_txo -// Access: Published -// Description: Sets the flag that indicates the texture has been -// loaded from a txo file. You probably shouldn't be -// setting this directly; it is set automatically when a -// Texture is loaded. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates the texture has been loaded from a txo file. + * You probably shouldn't be setting this directly; it is set automatically + * when a Texture is loaded. + */ INLINE void Texture:: set_loaded_from_txo() { CDWriter cdata(_cycler, false); cdata->_loaded_from_txo = true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_loaded_from_txo -// Access: Published -// Description: Returns the flag that indicates the texture has been -// loaded from a txo file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates the texture has been loaded from a txo + * file. + */ INLINE bool Texture:: get_loaded_from_txo() const { CDReader cdata(_cycler); return cdata->_loaded_from_txo; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_match_framebuffer_format -// Access: Public -// Description: Returns true if the special flag was set that -// indicates to the GSG that the Texture's format should -// be chosen to exactly match the framebuffer's format, -// presumably because the application intends to copy -// image data from the framebuffer into the Texture (or -// vice-versa). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the special flag was set that indicates to the GSG that the + * Texture's format should be chosen to exactly match the framebuffer's + * format, presumably because the application intends to copy image data from + * the framebuffer into the Texture (or vice-versa). + */ INLINE bool Texture:: get_match_framebuffer_format() const { CDReader cdata(_cycler); return cdata->_match_framebuffer_format; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_match_framebuffer_format -// Access: Public -// Description: Sets the special flag that, if true, indicates to the -// GSG that the Texture's format should be chosen to -// exactly match the framebuffer's format, presumably -// because the application intends to copy image data -// from the framebuffer into the Texture (or -// vice-versa). -// -// This sets only the graphics card's idea of the -// texture format; it is not related to the -// system-memory format. -//////////////////////////////////////////////////////////////////// +/** + * Sets the special flag that, if true, indicates to the GSG that the + * Texture's format should be chosen to exactly match the framebuffer's + * format, presumably because the application intends to copy image data from + * the framebuffer into the Texture (or vice-versa). + * + * This sets only the graphics card's idea of the texture format; it is not + * related to the system-memory format. + */ INLINE void Texture:: set_match_framebuffer_format(bool flag) { CDWriter cdata(_cycler, true); cdata->_match_framebuffer_format = flag; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_post_load_store_cache -// Access: Public -// Description: Returns the setting of the post_load_store_cache -// flag. See set_post_load_store_cache(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the setting of the post_load_store_cache flag. See + * set_post_load_store_cache(). + */ INLINE bool Texture:: get_post_load_store_cache() const { CDReader cdata(_cycler); return cdata->_post_load_store_cache; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_post_load_store_cache -// Access: Public -// Description: Sets the post_load_store_cache flag. When this is -// set, the next time the texture is loaded on a GSG, it -// will automatically extract its RAM image from the GSG -// and save it to the global BamCache. -// -// This is used to store compressed RAM images in the -// BamCache. This flag should not be set explicitly; it -// is set automatically by the TexturePool when -// model-cache-compressed-textures is set true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the post_load_store_cache flag. When this is set, the next time the + * texture is loaded on a GSG, it will automatically extract its RAM image + * from the GSG and save it to the global BamCache. + * + * This is used to store compressed RAM images in the BamCache. This flag + * should not be set explicitly; it is set automatically by the TexturePool + * when model-cache-compressed-textures is set true. + */ INLINE void Texture:: set_post_load_store_cache(bool flag) { CDWriter cdata(_cycler, true); cdata->_post_load_store_cache = flag; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::rescale_texture -// Access: Published -// Description: This method is similar to consider_rescale(), but -// instead of scaling a separate PNMImage, it will ask -// the Texture to rescale its own internal image to a -// power of 2, according to the config file -// requirements. This may be useful after loading a -// Texture image by hand, instead of reading it from a -// disk file. Returns true if the texture is changed, -// false if it was not. -//////////////////////////////////////////////////////////////////// +/** + * This method is similar to consider_rescale(), but instead of scaling a + * separate PNMImage, it will ask the Texture to rescale its own internal + * image to a power of 2, according to the config file requirements. This may + * be useful after loading a Texture image by hand, instead of reading it from + * a disk file. Returns true if the texture is changed, false if it was not. + */ INLINE bool Texture:: rescale_texture() { CDWriter cdata(_cycler, true); return do_rescale_texture(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::adjust_this_size -// Access: Public -// Description: Works like adjust_size, but also considers the -// texture class. Movie textures, for instance, always -// pad outwards, regardless of textures-power-2. -//////////////////////////////////////////////////////////////////// +/** + * Works like adjust_size, but also considers the texture class. Movie + * textures, for instance, always pad outwards, regardless of textures- + * power-2. + */ INLINE bool Texture:: adjust_this_size(int &x_size, int &y_size, const string &name, bool for_padding) const { @@ -2706,11 +2143,9 @@ adjust_this_size(int &x_size, int &y_size, const string &name, return do_adjust_this_size(cdata, x_size, y_size, name, for_padding); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_ram_image_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_ram_image_size(const CData *cdata) const { if (cdata->_ram_images.empty()) { @@ -2719,103 +2154,83 @@ do_get_ram_image_size(const CData *cdata) const { return cdata->_ram_images[0]._image.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_ram_mipmap_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Texture:: do_has_ram_mipmap_image(const CData *cdata, int n) const { return (n >= 0 && n < (int)cdata->_ram_images.size() && !cdata->_ram_images[n]._image.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_image_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_image_size(const CData *cdata) const { return do_get_expected_ram_view_size(cdata) * (size_t)cdata->_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_view_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_view_size(const CData *cdata) const { return do_get_expected_ram_page_size(cdata) * (size_t)cdata->_z_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_page_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_page_size(const CData *cdata) const { return (size_t)(cdata->_x_size * cdata->_y_size * cdata->_num_components * cdata->_component_width); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_mipmap_image_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_mipmap_image_size(const CData *cdata, int n) const { return do_get_expected_ram_mipmap_view_size(cdata, n) * (size_t)cdata->_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_mipmap_view_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_mipmap_view_size(const CData *cdata, int n) const { return do_get_expected_ram_mipmap_page_size(cdata, n) * (size_t)do_get_expected_mipmap_z_size(cdata, n); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_ram_mipmap_page_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE size_t Texture:: do_get_expected_ram_mipmap_page_size(const CData *cdata, int n) const { return (size_t)(do_get_expected_mipmap_x_size(cdata, n) * do_get_expected_mipmap_y_size(cdata, n) * cdata->_num_components * cdata->_component_width); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_mipmap_num_pages -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int Texture:: do_get_expected_mipmap_num_pages(const CData *cdata, int n) const { return do_get_expected_mipmap_z_size(cdata, n) * cdata->_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_clear_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Texture:: do_clear_ram_image(CData *cdata) { cdata->_ram_image_compression = CM_off; cdata->_ram_images.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_auto_texture_scale -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AutoTextureScale Texture:: do_get_auto_texture_scale(const CData *cdata) const { if (cdata->_auto_texture_scale == ATS_unspecified) { @@ -2825,29 +2240,21 @@ do_get_auto_texture_scale(const CData *cdata) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store_unscaled_byte -// Access: Private, Static -// Description: This is used by load() to store the next consecutive -// component value into the indicated element of the -// array, which is taken to be an array of unsigned -// bytes. The value is assumed to be in the range -// 0-255. -//////////////////////////////////////////////////////////////////// +/** + * This is used by load() to store the next consecutive component value into + * the indicated element of the array, which is taken to be an array of + * unsigned bytes. The value is assumed to be in the range 0-255. + */ INLINE void Texture:: store_unscaled_byte(unsigned char *&p, int value) { (*p++) = (uchar)value; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store_unscaled_short -// Access: Private, Static -// Description: This is used by load() to store the next consecutive -// component value into the indicated element of the -// array, which is taken to be an array of unsigned -// shorts. The value is assumed to be in the range -// 0-65535. -//////////////////////////////////////////////////////////////////// +/** + * This is used by load() to store the next consecutive component value into + * the indicated element of the array, which is taken to be an array of + * unsigned shorts. The value is assumed to be in the range 0-65535. + */ INLINE void Texture:: store_unscaled_short(unsigned char *&p, int value) { union { @@ -2859,55 +2266,43 @@ store_unscaled_short(unsigned char *&p, int value) { (*p++) = v.uc[1]; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store_scaled_byte -// Access: Private, Static -// Description: This is used by load() to store the next consecutive -// component value into the indicated element of the -// array, which is taken to be an array of unsigned -// bytes. The value will be scaled by the indicated -// factor before storing it. -//////////////////////////////////////////////////////////////////// +/** + * This is used by load() to store the next consecutive component value into + * the indicated element of the array, which is taken to be an array of + * unsigned bytes. The value will be scaled by the indicated factor before + * storing it. + */ INLINE void Texture:: store_scaled_byte(unsigned char *&p, int value, double scale) { store_unscaled_byte(p, (int)(value * scale)); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::store_scaled_short -// Access: Private, Static -// Description: This is used by load() to store the next consecutive -// component value into the indicated element of the -// array, which is taken to be an array of unsigned -// shorts. The value will be scaled by the indicated -// factor before storing it. -//////////////////////////////////////////////////////////////////// +/** + * This is used by load() to store the next consecutive component value into + * the indicated element of the array, which is taken to be an array of + * unsigned shorts. The value will be scaled by the indicated factor before + * storing it. + */ INLINE void Texture:: store_scaled_short(unsigned char *&p, int value, double scale) { store_unscaled_short(p, (int)(value * scale)); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_unsigned_byte -// Access: Private, Static -// Description: This is used by store() to retrieve the next -// consecutive component value from the indicated -// element of the array, which is taken to be an array -// of unsigned bytes. -//////////////////////////////////////////////////////////////////// +/** + * This is used by store() to retrieve the next consecutive component value + * from the indicated element of the array, which is taken to be an array of + * unsigned bytes. + */ INLINE double Texture:: get_unsigned_byte(const unsigned char *&p) { return (double)(*p++) / 255.0; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_unsigned_short -// Access: Private, Static -// Description: This is used by store() to retrieve the next -// consecutive component value from the indicated -// element of the array, which is taken to be an array -// of unsigned shorts. -//////////////////////////////////////////////////////////////////// +/** + * This is used by store() to retrieve the next consecutive component value + * from the indicated element of the array, which is taken to be an array of + * unsigned shorts. + */ INLINE double Texture:: get_unsigned_short(const unsigned char *&p) { union { @@ -2919,12 +2314,10 @@ get_unsigned_short(const unsigned char *&p) { return (double)v.us / 65535.0; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_txo_filename -// Access: Private, Static -// Description: Returns true if the indicated filename ends in .txo -// or .txo.pz, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated filename ends in .txo or .txo.pz, false + * otherwise. + */ INLINE bool Texture:: is_txo_filename(const Filename &fullpath) { string extension = fullpath.get_extension(); @@ -2936,12 +2329,10 @@ is_txo_filename(const Filename &fullpath) { return (extension == "txo"); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_dds_filename -// Access: Private, Static -// Description: Returns true if the indicated filename ends in .dds -// or .dds.pz, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated filename ends in .dds or .dds.pz, false + * otherwise. + */ INLINE bool Texture:: is_dds_filename(const Filename &fullpath) { string extension = fullpath.get_extension(); @@ -2953,41 +2344,33 @@ is_dds_filename(const Filename &fullpath) { return (downcase(extension) == "dds"); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::inc_properties_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Texture::CData:: inc_properties_modified() { ++_properties_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::inc_image_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Texture::CData:: inc_image_modified() { ++_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::inc_simple_image_modified -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Texture::CData:: inc_simple_image_modified() { ++_simple_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::RamImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Texture::RamImage:: RamImage() : _page_size(0), diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 46cfdee17d..1d46c1d900 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -1,17 +1,17 @@ -// Filename: texture.cxx -// Created by: mike (09Jan97) -// Updated by: fperazzi, PandaSE(29Apr10) (added TT_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texture.cxx + * @author mike + * @date 1997-01-09 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #include "pandabase.h" #include "texture.h" @@ -66,11 +66,11 @@ AutoTextureScale Texture::_textures_power_2 = ATS_unspecified; // Stuff to read and write DDS files. -// little-endian, of course +// little-endian, of course #define DDS_MAGIC 0x20534444 -// DDS_header.dwFlags +// DDS_header.dwFlags #define DDSD_CAPS 0x00000001 #define DDSD_HEIGHT 0x00000002 #define DDSD_WIDTH 0x00000004 @@ -80,18 +80,18 @@ AutoTextureScale Texture::_textures_power_2 = ATS_unspecified; #define DDSD_LINEARSIZE 0x00080000 #define DDSD_DEPTH 0x00800000 -// DDS_header.sPixelFormat.dwFlags +// DDS_header.sPixelFormat.dwFlags #define DDPF_ALPHAPIXELS 0x00000001 #define DDPF_FOURCC 0x00000004 #define DDPF_INDEXED 0x00000020 #define DDPF_RGB 0x00000040 -// DDS_header.sCaps.dwCaps1 +// DDS_header.sCaps.dwCaps1 #define DDSCAPS_COMPLEX 0x00000008 #define DDSCAPS_TEXTURE 0x00001000 #define DDSCAPS_MIPMAP 0x00400000 -// DDS_header.sCaps.dwCaps2 +// DDS_header.sCaps.dwCaps2 #define DDSCAPS2_CUBEMAP 0x00000200 #define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400 #define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800 @@ -132,14 +132,11 @@ struct DDSHeader { DDSCaps2 caps; }; -//////////////////////////////////////////////////////////////////// -// Function: Texture::Constructor -// Access: Published -// Description: Constructs an empty texture. The default is to set -// up the texture as an empty 2-d texture; follow up -// with one of the variants of setup_texture() if this -// is not what you want. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty texture. The default is to set up the texture as an + * empty 2-d texture; follow up with one of the variants of setup_texture() if + * this is not what you want. + */ Texture:: Texture(const string &name) : Namable(name), @@ -153,12 +150,9 @@ Texture(const string &name) : do_set_component_type(cdata, T_unsigned_byte); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::Copy Constructor -// Access: Protected -// Description: Use Texture::make_copy() to make a duplicate copy of -// an existing Texture. -//////////////////////////////////////////////////////////////////// +/** + * Use Texture::make_copy() to make a duplicate copy of an existing Texture. + */ Texture:: Texture(const Texture ©) : Namable(copy), @@ -169,39 +163,30 @@ Texture(const Texture ©) : _reloading = false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::Copy Assignment Operator -// Access: Protected -// Description: Use Texture::make_copy() to make a duplicate copy of -// an existing Texture. -//////////////////////////////////////////////////////////////////// +/** + * Use Texture::make_copy() to make a duplicate copy of an existing Texture. + */ void Texture:: operator = (const Texture ©) { Namable::operator = (copy); _cycler = copy._cycler; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture:: ~Texture() { release_all(); nassertv(!_reloading); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::generate_normalization_cube_map -// Access: Published -// Description: Generates a special cube map image in the texture -// that can be used to apply bump mapping effects: for -// each texel in the cube map that is indexed by the 3-d -// texture coordinates (x, y, z), the resulting value is -// the normalized vector (x, y, z) (compressed from -// -1..1 into 0..1). -//////////////////////////////////////////////////////////////////// +/** + * Generates a special cube map image in the texture that can be used to apply + * bump mapping effects: for each texel in the cube map that is indexed by the + * 3-d texture coordinates (x, y, z), the resulting value is the normalized + * vector (x, y, z) (compressed from -1..1 into 0..1). + */ void Texture:: generate_normalization_cube_map(int size) { CDWriter cdata(_cycler, true); @@ -298,15 +283,12 @@ generate_normalization_cube_map(int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::generate_alpha_scale_map -// Access: Published -// Description: Generates a special 256x1 1-d texture that can be -// used to apply an arbitrary alpha scale to objects by -// judicious use of texture matrix. The texture is a -// gradient, with an alpha of 0 on the left (U = 0), and -// 255 on the right (U = 1). -//////////////////////////////////////////////////////////////////// +/** + * Generates a special 256x1 1-d texture that can be used to apply an + * arbitrary alpha scale to objects by judicious use of texture matrix. The + * texture is a gradient, with an alpha of 0 on the left (U = 0), and 255 on + * the right (U = 1). + */ void Texture:: generate_alpha_scale_map() { CDWriter cdata(_cycler, true); @@ -329,11 +311,9 @@ generate_alpha_scale_map() { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read -// Access: Published -// Description: Reads the named filename into the texture. -//////////////////////////////////////////////////////////////////// +/** + * Reads the named filename into the texture. + */ bool Texture:: read(const Filename &fullpath, const LoaderOptions &options) { CDWriter cdata(_cycler, true); @@ -344,17 +324,13 @@ read(const Filename &fullpath, const LoaderOptions &options) { options, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read -// Access: Published -// Description: Combine a 3-component image with a grayscale image -// to get a 4-component image. -// -// See the description of the full-parameter read() -// method for the meaning of the -// primary_file_num_channels and alpha_file_channel -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Combine a 3-component image with a grayscale image to get a 4-component + * image. + * + * See the description of the full-parameter read() method for the meaning of + * the primary_file_num_channels and alpha_file_channel parameters. + */ bool Texture:: read(const Filename &fullpath, const Filename &alpha_fullpath, int primary_file_num_channels, int alpha_file_channel, @@ -368,16 +344,13 @@ read(const Filename &fullpath, const Filename &alpha_fullpath, options, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read -// Access: Published -// Description: Reads a single file into a single page or mipmap -// level, or automatically reads a series of files into -// a series of pages and/or mipmap levels. -// -// See the description of the full-parameter read() -// method for the meaning of the various parameters. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single file into a single page or mipmap level, or automatically + * reads a series of files into a series of pages and/or mipmap levels. + * + * See the description of the full-parameter read() method for the meaning of + * the various parameters. + */ bool Texture:: read(const Filename &fullpath, int z, int n, bool read_pages, bool read_mipmaps, @@ -389,75 +362,58 @@ read(const Filename &fullpath, int z, int n, options, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read -// Access: Published -// Description: Reads the texture from the indicated filename. If -// primary_file_num_channels is not 0, it specifies the -// number of components to downgrade the image to if it -// is greater than this number. -// -// If the filename has the extension .txo, this -// implicitly reads a texture object instead of a -// filename (which replaces all of the texture -// properties). In this case, all the rest of the -// parameters are ignored, and the filename should not -// contain any hash marks; just the one named file will -// be read, since a single .txo file can contain all -// pages and mipmaps necessary to define a texture. -// -// If alpha_fullpath is not empty, it specifies the name -// of a file from which to retrieve the alpha. In this -// case, alpha_file_channel represents the numeric -// channel of this image file to use as the resulting -// texture's alpha channel; usually, this is 0 to -// indicate the grayscale combination of r, g, b; or it -// may be a one-based channel number, e.g. 1 for the red -// channel, 2 for the green channel, and so on. -// -// If read pages is false, then z indicates the page -// number into which this image will be assigned. -// Normally this is 0 for the first (or only) page of -// the texture. 3-D textures have one page for each -// level of depth, and cube map textures always have six -// pages. -// -// If read_pages is true, multiple images will be read -// at once, one for each page of a cube map or a 3-D -// texture. In this case, the filename should contain a -// sequence of one or more hash marks ("#") which will -// be filled in with the z value of each page, -// zero-based. In this case, the z parameter indicates -// the maximum z value that will be loaded, or 0 to load -// all filenames that exist. -// -// If read_mipmaps is false, then n indicates the mipmap -// level to which this image will be assigned. Normally -// this is 0 for the base texture image, but it is -// possible to load custom mipmap levels into the later -// images. After the base texture image is loaded (thus -// defining the size of the texture), you can call -// get_expected_num_mipmap_levels() to determine the -// maximum sensible value for n. -// -// If read_mipmaps is true, multiple images will be read -// as above, but this time the images represent the -// different mipmap levels of the texture image. In -// this case, the n parameter indicates the maximum n -// value that will be loaded, or 0 to load all filenames -// that exist (up to the expected number of mipmap -// levels). -// -// If both read_pages and read_mipmaps is true, then -// both sequences will be read; the filename should -// contain two sequences of hash marks, separated by -// some character such as a hyphen, underscore, or dot. -// The first hash mark sequence will be filled in with -// the mipmap level, while the second hash mark sequence -// will be the page index. -// -// This method implicitly sets keep_ram_image to false. -//////////////////////////////////////////////////////////////////// +/** + * Reads the texture from the indicated filename. If + * primary_file_num_channels is not 0, it specifies the number of components + * to downgrade the image to if it is greater than this number. + * + * If the filename has the extension .txo, this implicitly reads a texture + * object instead of a filename (which replaces all of the texture + * properties). In this case, all the rest of the parameters are ignored, and + * the filename should not contain any hash marks; just the one named file + * will be read, since a single .txo file can contain all pages and mipmaps + * necessary to define a texture. + * + * If alpha_fullpath is not empty, it specifies the name of a file from which + * to retrieve the alpha. In this case, alpha_file_channel represents the + * numeric channel of this image file to use as the resulting texture's alpha + * channel; usually, this is 0 to indicate the grayscale combination of r, g, + * b; or it may be a one-based channel number, e.g. 1 for the red channel, 2 + * for the green channel, and so on. + * + * If read pages is false, then z indicates the page number into which this + * image will be assigned. Normally this is 0 for the first (or only) page of + * the texture. 3-D textures have one page for each level of depth, and cube + * map textures always have six pages. + * + * If read_pages is true, multiple images will be read at once, one for each + * page of a cube map or a 3-D texture. In this case, the filename should + * contain a sequence of one or more hash marks ("#") which will be filled in + * with the z value of each page, zero-based. In this case, the z parameter + * indicates the maximum z value that will be loaded, or 0 to load all + * filenames that exist. + * + * If read_mipmaps is false, then n indicates the mipmap level to which this + * image will be assigned. Normally this is 0 for the base texture image, but + * it is possible to load custom mipmap levels into the later images. After + * the base texture image is loaded (thus defining the size of the texture), + * you can call get_expected_num_mipmap_levels() to determine the maximum + * sensible value for n. + * + * If read_mipmaps is true, multiple images will be read as above, but this + * time the images represent the different mipmap levels of the texture image. + * In this case, the n parameter indicates the maximum n value that will be + * loaded, or 0 to load all filenames that exist (up to the expected number of + * mipmap levels). + * + * If both read_pages and read_mipmaps is true, then both sequences will be + * read; the filename should contain two sequences of hash marks, separated by + * some character such as a hyphen, underscore, or dot. The first hash mark + * sequence will be filled in with the mipmap level, while the second hash + * mark sequence will be the page index. + * + * This method implicitly sets keep_ram_image to false. + */ bool Texture:: read(const Filename &fullpath, const Filename &alpha_fullpath, int primary_file_num_channels, int alpha_file_channel, @@ -472,20 +428,16 @@ read(const Filename &fullpath, const Filename &alpha_fullpath, options, record); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::estimate_texture_memory -// Access: Published -// Description: Estimates the amount of texture memory that will be -// consumed by loading this texture. This returns a -// value that is not specific to any particular graphics -// card or driver; it tries to make a reasonable -// assumption about how a driver will load the texture. -// It does not account for texture compression or -// anything fancy. This is mainly useful for debugging -// and reporting purposes. -// -// Returns a value in bytes. -//////////////////////////////////////////////////////////////////// +/** + * Estimates the amount of texture memory that will be consumed by loading + * this texture. This returns a value that is not specific to any particular + * graphics card or driver; it tries to make a reasonable assumption about how + * a driver will load the texture. It does not account for texture + * compression or anything fancy. This is mainly useful for debugging and + * reporting purposes. + * + * Returns a value in bytes. + */ size_t Texture:: estimate_texture_memory() const { CDReader cdata(_cycler); @@ -521,8 +473,8 @@ estimate_texture_memory() const { case Texture::F_rgbm: case Texture::F_rgb: case Texture::F_srgb: - // Most of the above formats have only 3 bytes, but they are most likely to - // get padded by the driver + // Most of the above formats have only 3 bytes, but they are most likely + // to get padded by the driver bpp = 4; break; @@ -605,42 +557,32 @@ estimate_texture_memory() const { return bytes; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_aux_data -// Access: Published -// Description: Records an arbitrary object in the Texture, -// associated with a specified key. The object may -// later be retrieved by calling get_aux_data() with the -// same key. -// -// These data objects are not recorded to a bam or txo -// file. -//////////////////////////////////////////////////////////////////// +/** + * Records an arbitrary object in the Texture, associated with a specified + * key. The object may later be retrieved by calling get_aux_data() with the + * same key. + * + * These data objects are not recorded to a bam or txo file. + */ void Texture:: set_aux_data(const string &key, TypedReferenceCount *aux_data) { MutexHolder holder(_lock); _aux_data[key] = aux_data; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_aux_data -// Access: Published -// Description: Removes a record previously recorded via -// set_aux_data(). -//////////////////////////////////////////////////////////////////// +/** + * Removes a record previously recorded via set_aux_data(). + */ void Texture:: clear_aux_data(const string &key) { MutexHolder holder(_lock); _aux_data.erase(key); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_aux_data -// Access: Published -// Description: Returns a record previously recorded via -// set_aux_data(). Returns NULL if there was no record -// associated with the indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Returns a record previously recorded via set_aux_data(). Returns NULL if + * there was no record associated with the indicated key. + */ TypedReferenceCount *Texture:: get_aux_data(const string &key) const { MutexHolder holder(_lock); @@ -652,19 +594,14 @@ get_aux_data(const string &key) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_txo -// Access: Published -// Description: Reads the texture from a Panda texture object. This -// defines the complete Texture specification, including -// the image data as well as all texture properties. -// This only works if the txo file contains a static -// Texture image, as opposed to a subclass of Texture -// such as a movie texture. -// -// Pass a real filename if it is available, or empty -// string if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Reads the texture from a Panda texture object. This defines the complete + * Texture specification, including the image data as well as all texture + * properties. This only works if the txo file contains a static Texture + * image, as opposed to a subclass of Texture such as a movie texture. + * + * Pass a real filename if it is available, or empty string if it is not. + */ bool Texture:: read_txo(istream &in, const string &filename) { CDWriter cdata(_cycler, true); @@ -673,18 +610,13 @@ read_txo(istream &in, const string &filename) { return do_read_txo(cdata, in, filename); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_from_txo -// Access: Published, Static -// Description: Constructs a new Texture object from the txo file. -// This is similar to Texture::read_txo(), but it -// constructs and returns a new object, which allows it -// to return a subclass of Texture (for instance, a -// movie texture). -// -// Pass a real filename if it is available, or empty -// string if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new Texture object from the txo file. This is similar to + * Texture::read_txo(), but it constructs and returns a new object, which + * allows it to return a subclass of Texture (for instance, a movie texture). + * + * Pass a real filename if it is available, or empty string if it is not. + */ PT(Texture) Texture:: make_from_txo(istream &in, const string &filename) { DatagramInputFile din; @@ -718,9 +650,9 @@ make_from_txo(istream &in, const string &filename) { if (object != (TypedWritable *)NULL && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a - // BamCacheRecord, it's really a cache data file and not a true - // txo file; but skip over the cache data record and let the user - // treat it like an ordinary txo file. + // BamCacheRecord, it's really a cache data file and not a true txo file; + // but skip over the cache data record and let the user treat it like an + // ordinary txo file. object = reader.read_object(); } @@ -746,33 +678,28 @@ make_from_txo(istream &in, const string &filename) { return other; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::write_txo -// Access: Published -// Description: Writes the texture to a Panda texture object. This -// defines the complete Texture specification, including -// the image data as well as all texture properties. -// -// The filename is just for reference. -//////////////////////////////////////////////////////////////////// +/** + * Writes the texture to a Panda texture object. This defines the complete + * Texture specification, including the image data as well as all texture + * properties. + * + * The filename is just for reference. + */ bool Texture:: write_txo(ostream &out, const string &filename) const { CDReader cdata(_cycler); return do_write_txo(cdata, out, filename); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds -// Access: Published -// Description: Reads the texture from a DDS file object. This is a -// Microsoft-defined file format; it is similar in -// principle to a txo object, in that it is designed to -// contain the texture image in a form as similar as -// possible to its runtime image, and it can contain -// mipmaps, pre-compressed textures, and so on. -// -// As with read_txo, the filename is just for reference. -//////////////////////////////////////////////////////////////////// +/** + * Reads the texture from a DDS file object. This is a Microsoft-defined file + * format; it is similar in principle to a txo object, in that it is designed + * to contain the texture image in a form as similar as possible to its + * runtime image, and it can contain mipmaps, pre-compressed textures, and so + * on. + * + * As with read_txo, the filename is just for reference. + */ bool Texture:: read_dds(istream &in, const string &filename, bool header_only) { CDWriter cdata(_cycler, true); @@ -781,14 +708,11 @@ read_dds(istream &in, const string &filename, bool header_only) { return do_read_dds(cdata, in, filename, header_only); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::load_related -// Access: Published -// Description: Loads a texture whose filename is derived by -// concatenating a suffix to the filename of this -// texture. May return NULL, for example, if this -// texture doesn't have a filename. -//////////////////////////////////////////////////////////////////// +/** + * Loads a texture whose filename is derived by concatenating a suffix to the + * filename of this texture. May return NULL, for example, if this texture + * doesn't have a filename. + */ Texture *Texture:: load_related(const InternalName *suffix) const { MutexHolder holder(_lock); @@ -812,39 +736,35 @@ load_related(const InternalName *suffix) const { suffix->get_name()); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); if (vfs->exists(alph)) { - // The alpha variant of the filename, with the suffix, exists. - // Use it to load the texture. + // The alpha variant of the filename, with the suffix, exists. Use it + // to load the texture. res = TexturePool::load_texture(main, alph, cdata->_primary_file_num_channels, cdata->_alpha_file_channel, false); } else { - // If the alpha variant of the filename doesn't exist, just go - // ahead and load the related texture without alpha. + // If the alpha variant of the filename doesn't exist, just go ahead and + // load the related texture without alpha. res = TexturePool::load_texture(main); } } else { - // No alpha filename--just load the single file. It doesn't - // necessarily have the same number of channels as this one. + // No alpha filename--just load the single file. It doesn't necessarily + // have the same number of channels as this one. res = TexturePool::load_texture(main); } - // I'm casting away the const-ness of 'this' because this - // field is only a cache. + // I'm casting away the const-ness of 'this' because this field is only a + // cache. ((Texture *)this)->_related_textures.insert(RelatedTextures::value_type(suffix, res)); return res; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_ram_image_as -// Access: Published -// Description: Replaces the current system-RAM image with the new -// data, converting it first if necessary from the -// indicated component-order format. See -// get_ram_image_as() for specifications about the -// format. This method cannot support compressed image -// data or sub-pages; use set_ram_image() for that. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current system-RAM image with the new data, converting it + * first if necessary from the indicated component-order format. See + * get_ram_image_as() for specifications about the format. This method cannot + * support compressed image data or sub-pages; use set_ram_image() for that. + */ void Texture:: set_ram_image_as(CPTA_uchar image, const string &supplied_format) { CDWriter cdata(_cycler, true); @@ -961,52 +881,40 @@ set_ram_image_as(CPTA_uchar image, const string &supplied_format) { return; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_keep_ram_image -// Access: Published, Virtual -// Description: Returns the flag that indicates whether this Texture -// is eligible to have its main RAM copy of the texture -// memory dumped when the texture is prepared for -// rendering. See set_keep_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether this Texture is eligible to have + * its main RAM copy of the texture memory dumped when the texture is prepared + * for rendering. See set_keep_ram_image(). + */ bool Texture:: get_keep_ram_image() const { CDReader cdata(_cycler); return cdata->_keep_ram_image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_cacheable -// Access: Published, Virtual -// Description: Returns true if there is enough information in this -// Texture object to write it to the bam cache -// successfully, false otherwise. For most textures, -// this is the same as has_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is enough information in this Texture object to write + * it to the bam cache successfully, false otherwise. For most textures, this + * is the same as has_ram_image(). + */ bool Texture:: is_cacheable() const { CDReader cdata(_cycler); return do_has_bam_rawdata(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_num_loadable_ram_mipmap_images -// Access: Published -// Description: Returns the number of contiguous mipmap levels that -// exist in RAM, up until the first gap in the sequence. -// It is guaranteed that at least mipmap levels [0, -// get_num_ram_mipmap_images()) exist. -// -// The number returned will never exceed the number of -// required mipmap images based on the size of the -// texture and its filter mode. -// -// This method is different from -// get_num_ram_mipmap_images() in that it returns only -// the number of mipmap levels that can actually be -// usefully loaded, regardless of the actual number that -// may be stored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of contiguous mipmap levels that exist in RAM, up until + * the first gap in the sequence. It is guaranteed that at least mipmap + * levels [0, get_num_ram_mipmap_images()) exist. + * + * The number returned will never exceed the number of required mipmap images + * based on the size of the texture and its filter mode. + * + * This method is different from get_num_ram_mipmap_images() in that it + * returns only the number of mipmap levels that can actually be usefully + * loaded, regardless of the actual number that may be stored. + */ int Texture:: get_num_loadable_ram_mipmap_images() const { CDReader cdata(_cycler); @@ -1015,13 +923,11 @@ get_num_loadable_ram_mipmap_images() const { return 0; } if (!uses_mipmaps()) { - // If we have a base image and don't require mipmapping, the - // answer is 1. + // If we have a base image and don't require mipmapping, the answer is 1. return 1; } - // Check that we have enough mipmap levels to meet the size - // requirements. + // Check that we have enough mipmap levels to meet the size requirements. int size = max(cdata->_x_size, max(cdata->_y_size, cdata->_z_size)); int n = 0; int x = 1; @@ -1037,13 +943,10 @@ get_num_loadable_ram_mipmap_images() const { return n; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_mipmap_image -// Access: Published -// Description: Returns the system-RAM image data associated with the -// nth mipmap level, if present. Returns NULL if the -// nth mipmap level is not present. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system-RAM image data associated with the nth mipmap level, if + * present. Returns NULL if the nth mipmap level is not present. + */ CPTA_uchar Texture:: get_ram_mipmap_image(int n) const { CDReader cdata(_cycler); @@ -1053,14 +956,11 @@ get_ram_mipmap_image(int n) const { return CPTA_uchar(get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_mipmap_pointer -// Access: Published -// Description: Similiar to get_ram_mipmap_image(), however, in this -// case the void pointer for the given ram image is -// returned. This will be NULL unless it has been -// explicitly set. -//////////////////////////////////////////////////////////////////// +/** + * Similiar to get_ram_mipmap_image(), however, in this case the void pointer + * for the given ram image is returned. This will be NULL unless it has been + * explicitly set. + */ void *Texture:: get_ram_mipmap_pointer(int n) const { CDReader cdata(_cycler); @@ -1070,20 +970,16 @@ get_ram_mipmap_pointer(int n) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_ram_mipmap_pointer -// Access: Published -// Description: Sets an explicit void pointer as the texture's mipmap -// image for the indicated level. This is a special -// call to direct a texture to reference some external -// image location, for instance from a webcam input. -// -// The texture will henceforth reference this pointer -// directly, instead of its own internal storage; the -// user is responsible for ensuring the data at this -// address remains allocated and valid, and in the -// correct format, during the lifetime of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets an explicit void pointer as the texture's mipmap image for the + * indicated level. This is a special call to direct a texture to reference + * some external image location, for instance from a webcam input. + * + * The texture will henceforth reference this pointer directly, instead of its + * own internal storage; the user is responsible for ensuring the data at this + * address remains allocated and valid, and in the correct format, during the + * lifetime of the texture. + */ void Texture:: set_ram_mipmap_pointer(int n, void *image, size_t page_size) { CDWriter cdata(_cycler, true); @@ -1094,33 +990,26 @@ set_ram_mipmap_pointer(int n, void *image, size_t page_size) { } cdata->_ram_images[n]._page_size = page_size; - //_ram_images[n]._image.clear(); wtf is going on?! + // _ram_images[n]._image.clear(); wtf is going on?! cdata->_ram_images[n]._pointer_image = image; cdata->inc_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_ram_mipmap_pointer_from_int -// Access: Published -// Description: Accepts a raw pointer cast as an int, which is then -// passed to set_ram_mipmap_pointer(); see the -// documentation for that method. -// -// This variant is particularly useful to set an -// external pointer from a language like Python, which -// doesn't support void pointers directly. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a raw pointer cast as an int, which is then passed to + * set_ram_mipmap_pointer(); see the documentation for that method. + * + * This variant is particularly useful to set an external pointer from a + * language like Python, which doesn't support void pointers directly. + */ void Texture:: set_ram_mipmap_pointer_from_int(long long pointer, int n, int page_size) { set_ram_mipmap_pointer(n, (void*)pointer, (size_t)page_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_ram_mipmap_image -// Access: Published -// Description: Discards the current system-RAM image for the nth -// mipmap level. -//////////////////////////////////////////////////////////////////// +/** + * Discards the current system-RAM image for the nth mipmap level. + */ void Texture:: clear_ram_mipmap_image(int n) { CDWriter cdata(_cycler, true); @@ -1132,12 +1021,10 @@ clear_ram_mipmap_image(int n) { cdata->_ram_images[n]._pointer_image = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::modify_simple_ram_image -// Access: Published -// Description: Returns a modifiable pointer to the internal "simple" -// texture image. See set_simple_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the internal "simple" texture image. See + * set_simple_ram_image(). + */ PTA_uchar Texture:: modify_simple_ram_image() { CDWriter cdata(_cycler, true); @@ -1145,13 +1032,10 @@ modify_simple_ram_image() { return cdata->_simple_ram_image._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::new_simple_ram_image -// Access: Published -// Description: Creates an empty array for the simple ram image of -// the indicated size, and returns a modifiable pointer -// to the new array. See set_simple_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Creates an empty array for the simple ram image of the indicated size, and + * returns a modifiable pointer to the new array. See set_simple_ram_image(). + */ PTA_uchar Texture:: new_simple_ram_image(int x_size, int y_size) { CDWriter cdata(_cycler, true); @@ -1168,14 +1052,11 @@ new_simple_ram_image(int x_size, int y_size) { return cdata->_simple_ram_image._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::generate_simple_ram_image -// Access: Published -// Description: Computes the "simple" ram image by loading the main -// RAM image, if it is not already available, and -// reducing it to 16x16 or smaller. This may be an -// expensive operation. -//////////////////////////////////////////////////////////////////// +/** + * Computes the "simple" ram image by loading the main RAM image, if it is not + * already available, and reducing it to 16x16 or smaller. This may be an + * expensive operation. + */ void Texture:: generate_simple_ram_image() { CDWriter cdata(_cycler, true); @@ -1194,8 +1075,8 @@ generate_simple_ram_image() { int x_size = simple_image_size.get_word(0); int y_size = simple_image_size.get_word(1); - // Limit it to no larger than the source image, and also make it a - // power of two. + // Limit it to no larger than the source image, and also make it a power of + // two. x_size = down_to_power_2(min(x_size, cdata->_x_size)); y_size = down_to_power_2(min(y_size, cdata->_y_size)); @@ -1254,22 +1135,18 @@ generate_simple_ram_image() { cdata->_simple_image_date_generated = (PN_int32)time(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::peek -// Access: Published -// Description: Returns a TexturePeeker object that can be used to -// examine the individual texels stored within this -// Texture by (u, v) coordinate. -// -// If the texture has a ram image resident, that image -// is used. If it does not have a full ram image but -// does have a simple_ram_image resident, that image is -// used instead. If neither image is resident the full -// image is reloaded. -// -// Returns NULL if the texture cannot find an image to -// load, or the texture format is incompatible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a TexturePeeker object that can be used to examine the individual + * texels stored within this Texture by (u, v) coordinate. + * + * If the texture has a ram image resident, that image is used. If it does + * not have a full ram image but does have a simple_ram_image resident, that + * image is used instead. If neither image is resident the full image is + * reloaded. + * + * Returns NULL if the texture cannot find an image to load, or the texture + * format is incompatible. + */ PT(TexturePeeker) Texture:: peek() { CDWriter cdata(_cycler, unlocked_ensure_ram_image(true)); @@ -1282,30 +1159,24 @@ peek() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::prepare -// Access: Published -// Description: Indicates that the texture should be enqueued to be -// prepared in the indicated prepared_objects at the -// beginning of the next frame. This will ensure the -// texture is already loaded into texture memory if it -// is expected to be rendered soon. -// -// Use this function instead of prepare_now() to preload -// textures from a user interface standpoint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the texture should be enqueued to be prepared in the + * indicated prepared_objects at the beginning of the next frame. This will + * ensure the texture is already loaded into texture memory if it is expected + * to be rendered soon. + * + * Use this function instead of prepare_now() to preload textures from a user + * interface standpoint. + */ void Texture:: prepare(PreparedGraphicsObjects *prepared_objects) { prepared_objects->enqueue_texture(this); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_prepared -// Access: Published -// Description: Returns true if the texture has already been prepared -// or enqueued for preparation on the indicated GSG, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has already been prepared or enqueued for + * preparation on the indicated GSG, false otherwise. + */ bool Texture:: is_prepared(PreparedGraphicsObjects *prepared_objects) const { MutexHolder holder(_lock); @@ -1317,14 +1188,11 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { return prepared_objects->is_texture_queued(this); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::was_image_modified -// Access: Published -// Description: Returns true if the texture needs to be re-loaded -// onto the indicated GSG, either because its image data -// is out-of-date, or because it's not fully prepared -// now. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture needs to be re-loaded onto the indicated GSG, + * either because its image data is out-of-date, or because it's not fully + * prepared now. + */ bool Texture:: was_image_modified(PreparedGraphicsObjects *prepared_objects) const { MutexHolder holder(_lock); @@ -1350,17 +1218,13 @@ was_image_modified(PreparedGraphicsObjects *prepared_objects) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_data_size_bytes -// Access: Public -// Description: Returns the number of bytes which the texture is -// reported to consume within graphics memory, for the -// indicated GSG. This may return a nonzero value even -// if the texture is not currently resident; you should -// also check get_resident() if you want to know how -// much space the texture is actually consuming right -// now. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes which the texture is reported to consume within + * graphics memory, for the indicated GSG. This may return a nonzero value + * even if the texture is not currently resident; you should also check + * get_resident() if you want to know how much space the texture is actually + * consuming right now. + */ size_t Texture:: get_data_size_bytes(PreparedGraphicsObjects *prepared_objects) const { MutexHolder holder(_lock); @@ -1384,12 +1248,10 @@ get_data_size_bytes(PreparedGraphicsObjects *prepared_objects) const { return total_size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_active -// Access: Public -// Description: Returns true if this Texture was rendered in the most -// recent frame within the indicated GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this Texture was rendered in the most recent frame within + * the indicated GSG. + */ bool Texture:: get_active(PreparedGraphicsObjects *prepared_objects) const { MutexHolder holder(_lock); @@ -1413,13 +1275,10 @@ get_active(PreparedGraphicsObjects *prepared_objects) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_resident -// Access: Public -// Description: Returns true if this Texture is reported to be -// resident within graphics memory for the indicated -// GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this Texture is reported to be resident within graphics + * memory for the indicated GSG. + */ bool Texture:: get_resident(PreparedGraphicsObjects *prepared_objects) const { MutexHolder holder(_lock); @@ -1443,13 +1302,10 @@ get_resident(PreparedGraphicsObjects *prepared_objects) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::release -// Access: Published -// Description: Frees the texture context only on the indicated object, -// if it exists there. Returns true if it was released, -// false if it had not been prepared. -//////////////////////////////////////////////////////////////////// +/** + * Frees the texture context only on the indicated object, if it exists there. + * Returns true if it was released, false if it had not been prepared. + */ bool Texture:: release(PreparedGraphicsObjects *prepared_objects) { MutexHolder holder(_lock); @@ -1472,20 +1328,17 @@ release(PreparedGraphicsObjects *prepared_objects) { return prepared_objects->dequeue_texture(this); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::release_all -// Access: Published -// Description: Frees the context allocated on all objects for which -// the texture has been declared. Returns the number of -// contexts which have been freed. -//////////////////////////////////////////////////////////////////// +/** + * Frees the context allocated on all objects for which the texture has been + * declared. Returns the number of contexts which have been freed. + */ int Texture:: release_all() { MutexHolder holder(_lock); // We have to traverse a copy of the _prepared_views list, because the - // PreparedGraphicsObjects object will call clear_prepared() in response - // to each release_texture(), and we don't want to be modifying the + // PreparedGraphicsObjects object will call clear_prepared() in response to + // each release_texture(), and we don't want to be modifying the // _prepared_views list while we're traversing it. PreparedViews temp; temp.swap(_prepared_views); @@ -1508,12 +1361,10 @@ release_all() { return num_freed; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::write -// Access: Published -// Description: Not to be confused with write(Filename), this method -// simply describes the texture properties. -//////////////////////////////////////////////////////////////////// +/** + * Not to be confused with write(Filename), this method simply describes the + * texture properties. + */ void Texture:: write(ostream &out, int indent_level) const { CDReader cdata(_cycler); @@ -1782,13 +1633,10 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_size_padded -// Access: Published -// Description: Changes the size of the texture, padding -// if necessary, and setting the pad region -// as well. -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of the texture, padding if necessary, and setting the pad + * region as well. + */ void Texture:: set_size_padded(int x, int y, int z) { CDWriter cdata(_cycler, true); @@ -1797,8 +1645,8 @@ set_size_padded(int x, int y, int z) { do_set_y_size(cdata, up_to_power_2(y)); if (cdata->_texture_type == TT_3d_texture) { - // Only pad 3D textures. It does not make sense - // to do so for cube maps or 2D texture arrays. + // Only pad 3D textures. It does not make sense to do so for cube maps + // or 2D texture arrays. do_set_z_size(cdata, up_to_power_2(z)); } else { do_set_z_size(cdata, z); @@ -1814,12 +1662,10 @@ set_size_padded(int x, int y, int z) { cdata->_z_size - z); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::set_orig_file_size -// Access: Published -// Description: Specifies the size of the texture as it exists in its -// original disk file, before any Panda scaling. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size of the texture as it exists in its original disk file, + * before any Panda scaling. + */ void Texture:: set_orig_file_size(int x, int y, int z) { CDWriter cdata(_cycler, true); @@ -1829,22 +1675,17 @@ set_orig_file_size(int x, int y, int z) { nassertv(z == cdata->_z_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::prepare_now -// Access: Published -// Description: Creates a context for the texture on the particular -// GSG, if it does not already exist. Returns the new -// (or old) TextureContext. This assumes that the -// GraphicsStateGuardian is the currently active -// rendering context and that it is ready to accept new -// textures. If this is not necessarily the case, you -// should use prepare() instead. -// -// Normally, this is not called directly except by the -// GraphicsStateGuardian; a texture does not need to be -// explicitly prepared by the user before it may be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Creates a context for the texture on the particular GSG, if it does not + * already exist. Returns the new (or old) TextureContext. This assumes that + * the GraphicsStateGuardian is the currently active rendering context and + * that it is ready to accept new textures. If this is not necessarily the + * case, you should use prepare() instead. + * + * Normally, this is not called directly except by the GraphicsStateGuardian; + * a texture does not need to be explicitly prepared by the user before it may + * be rendered. + */ TextureContext *Texture:: prepare_now(int view, PreparedGraphicsObjects *prepared_objects, @@ -1869,12 +1710,9 @@ prepare_now(int view, return tc; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::up_to_power_2 -// Access: Published, Static -// Description: Returns the smallest power of 2 greater than or equal -// to value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest power of 2 greater than or equal to value. + */ int Texture:: up_to_power_2(int value) { if (value <= 1) { @@ -1884,12 +1722,9 @@ up_to_power_2(int value) { return (1 << bit); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::down_to_power_2 -// Access: Published, Static -// Description: Returns the largest power of 2 less than or equal -// to value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest power of 2 less than or equal to value. + */ int Texture:: down_to_power_2(int value) { if (value <= 1) { @@ -1899,39 +1734,31 @@ down_to_power_2(int value) { return (1 << bit); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::consider_rescale -// Access: Published -// Description: Asks the PNMImage to change its scale when it reads -// the image, according to the whims of the Config.prc -// file. -// -// For most efficient results, this method should be -// called after pnmimage.read_header() has been called, -// but before pnmimage.read(). This method may also be -// called after pnmimage.read(), i.e. when the pnmimage -// is already loaded; in this case it will rescale the -// image on the spot. Also see rescale_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Asks the PNMImage to change its scale when it reads the image, according to + * the whims of the Config.prc file. + * + * For most efficient results, this method should be called after + * pnmimage.read_header() has been called, but before pnmimage.read(). This + * method may also be called after pnmimage.read(), i.e. when the pnmimage is + * already loaded; in this case it will rescale the image on the spot. Also + * see rescale_texture(). + */ void Texture:: consider_rescale(PNMImage &pnmimage) { consider_rescale(pnmimage, get_name(), get_auto_texture_scale()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::consider_rescale -// Access: Published, Static -// Description: Asks the PNMImage to change its scale when it reads -// the image, according to the whims of the Config.prc -// file. -// -// For most efficient results, this method should be -// called after pnmimage.read_header() has been called, -// but before pnmimage.read(). This method may also be -// called after pnmimage.read(), i.e. when the pnmimage -// is already loaded; in this case it will rescale the -// image on the spot. Also see rescale_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Asks the PNMImage to change its scale when it reads the image, according to + * the whims of the Config.prc file. + * + * For most efficient results, this method should be called after + * pnmimage.read_header() has been called, but before pnmimage.read(). This + * method may also be called after pnmimage.read(), i.e. when the pnmimage is + * already loaded; in this case it will rescale the image on the spot. Also + * see rescale_texture(). + */ void Texture:: consider_rescale(PNMImage &pnmimage, const string &name, AutoTextureScale auto_texture_scale) { int new_x_size = pnmimage.get_x_size(); @@ -1945,19 +1772,16 @@ consider_rescale(PNMImage &pnmimage, const string &name, AutoTextureScale auto_t new_image.quick_filter_from(pnmimage); pnmimage.take_from(new_image); } else { - // Rescale while reading. Some image types (e.g. jpeg) can take + // Rescale while reading. Some image types (e.g. jpeg) can take // advantage of this. pnmimage.set_read_size(new_x_size, new_y_size); } } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::format_texture_type -// Access: Published, Static -// Description: Returns the indicated TextureType converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated TextureType converted to a string word. + */ string Texture:: format_texture_type(TextureType tt) { switch (tt) { @@ -1979,12 +1803,9 @@ format_texture_type(TextureType tt) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::string_texture_type -// Access: Published, Static -// Description: Returns the TextureType corresponding to the -// indicated string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextureType corresponding to the indicated string word. + */ Texture::TextureType Texture:: string_texture_type(const string &str) { if (cmp_nocase(str, "1d_texture") == 0) { @@ -2008,12 +1829,9 @@ string_texture_type(const string &str) { return TT_2d_texture; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::format_component_type -// Access: Published, Static -// Description: Returns the indicated ComponentType converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated ComponentType converted to a string word. + */ string Texture:: format_component_type(ComponentType ct) { switch (ct) { @@ -2038,12 +1856,9 @@ format_component_type(ComponentType ct) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::string_component_type -// Access: Published, Static -// Description: Returns the ComponentType corresponding to the -// indicated string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ComponentType corresponding to the indicated string word. + */ Texture::ComponentType Texture:: string_component_type(const string &str) { if (cmp_nocase(str, "unsigned_byte") == 0) { @@ -2069,12 +1884,9 @@ string_component_type(const string &str) { return T_unsigned_byte; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::format_format -// Access: Published, Static -// Description: Returns the indicated Format converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated Format converted to a string word. + */ string Texture:: format_format(Format format) { switch (format) { @@ -2172,12 +1984,9 @@ format_format(Format format) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::string_format -// Access: Published, Static -// Description: Returns the Format corresponding to the -// indicated string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Format corresponding to the indicated string word. + */ Texture::Format Texture:: string_format(const string &str) { if (cmp_nocase(str, "depth_stencil") == 0) { @@ -2269,12 +2078,9 @@ string_format(const string &str) { return F_rgba; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::format_compression_mode -// Access: Published, Static -// Description: Returns the indicated CompressionMode converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated CompressionMode converted to a string word. + */ string Texture:: format_compression_mode(CompressionMode cm) { switch (cm) { @@ -2307,12 +2113,10 @@ format_compression_mode(CompressionMode cm) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::string_compression_mode -// Access: Public -// Description: Returns the CompressionMode value associated with the -// given string representation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CompressionMode value associated with the given string + * representation. + */ Texture::CompressionMode Texture:: string_compression_mode(const string &str) { if (cmp_nocase_uh(str, "default") == 0) { @@ -2347,12 +2151,9 @@ string_compression_mode(const string &str) { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::format_quality_level -// Access: Published, Static -// Description: Returns the indicated QualityLevel converted to a -// string word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated QualityLevel converted to a string word. + */ string Texture:: format_quality_level(QualityLevel ql) { switch (ql) { @@ -2369,12 +2170,10 @@ format_quality_level(QualityLevel ql) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::string_quality_level -// Access: Public -// Description: Returns the QualityLevel value associated with the -// given string representation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the QualityLevel value associated with the given string + * representation. + */ Texture::QualityLevel Texture:: string_quality_level(const string &str) { if (cmp_nocase(str, "default") == 0) { @@ -2392,26 +2191,23 @@ string_quality_level(const string &str) { return QL_default; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::texture_uploaded -// Access: Public -// Description: This method is called by the GraphicsEngine at the -// beginning of the frame *after* a texture has been -// successfully uploaded to graphics memory. It is -// intended as a callback so the texture can release its -// RAM image, if _keep_ram_image is false. -// -// This is called indirectly when the GSG calls -// GraphicsEngine::texture_uploaded(). -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the GraphicsEngine at the beginning of the frame + * *after* a texture has been successfully uploaded to graphics memory. It is + * intended as a callback so the texture can release its RAM image, if + * _keep_ram_image is false. + * + * This is called indirectly when the GSG calls + * GraphicsEngine::texture_uploaded(). + */ void Texture:: texture_uploaded() { CDLockedReader cdata(_cycler); if (!keep_texture_ram && !cdata->_keep_ram_image) { - // Once we have prepared the texture, we can generally safely - // remove the pixels from main RAM. The GSG is now responsible - // for remembering what it looks like. + // Once we have prepared the texture, we can generally safely remove the + // pixels from main RAM. The GSG is now responsible for remembering what + // it looks like. CDWriter cdataw(_cycler, cdata, false); if (gobj_cat.is_debug()) { @@ -2422,55 +2218,41 @@ texture_uploaded() { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + */ bool Texture:: has_cull_callback() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. -// -// This is called each time the Texture is discovered -// applied to a Geom in the traversal. It should return -// true if the Geom is visible, false if it should be -// omitted. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. + * + * This is called each time the Texture is discovered applied to a Geom in the + * traversal. It should return true if the Geom is visible, false if it + * should be omitted. + */ bool Texture:: cull_callback(CullTraverser *, const CullTraverserData &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_texture -// Access: Public, Static -// Description: A factory function to make a new Texture, used to -// pass to the TexturePool. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new Texture, used to pass to the TexturePool. + */ PT(Texture) Texture:: make_texture() { return new Texture; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_unsigned -// Access: Public, Static -// Description: Returns true if the indicated component type is -// unsigned, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated component type is unsigned, false otherwise. + */ bool Texture:: is_unsigned(Texture::ComponentType ctype) { return (ctype == T_unsigned_byte || @@ -2478,12 +2260,10 @@ is_unsigned(Texture::ComponentType ctype) { ctype == T_unsigned_int_24_8); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_specific -// Access: Public, Static -// Description: Returns true if the indicated compression mode is one -// of the specific compression types, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated compression mode is one of the specific + * compression types, false otherwise. + */ bool Texture:: is_specific(Texture::CompressionMode compression) { switch (compression) { @@ -2497,12 +2277,9 @@ is_specific(Texture::CompressionMode compression) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_alpha -// Access: Public, Static -// Description: Returns true if the indicated format includes alpha, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated format includes alpha, false otherwise. + */ bool Texture:: has_alpha(Format format) { switch (format) { @@ -2528,12 +2305,10 @@ has_alpha(Format format) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::has_binary_alpha -// Access: Public, Static -// Description: Returns true if the indicated format includes a -// binary alpha only, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated format includes a binary alpha only, false + * otherwise. + */ bool Texture:: has_binary_alpha(Format format) { switch (format) { @@ -2545,12 +2320,10 @@ has_binary_alpha(Format format) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::is_srgb -// Access: Public, Static -// Description: Returns true if the indicated format is in the -// sRGB color space, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated format is in the sRGB color space, false + * otherwise. + */ bool Texture:: is_srgb(Format format) { switch (format) { @@ -2565,19 +2338,15 @@ is_srgb(Format format) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::adjust_size -// Access: Public, Static -// Description: Computes the proper size of the texture, based on the -// original size, the filename, and the resizing whims -// of the config file. -// -// x_size and y_size should be loaded with the texture -// image's original size on disk. On return, they will -// be loaded with the texture's in-memory target size. -// The return value is true if the size has been -// adjusted, or false if it is the same. -//////////////////////////////////////////////////////////////////// +/** + * Computes the proper size of the texture, based on the original size, the + * filename, and the resizing whims of the config file. + * + * x_size and y_size should be loaded with the texture image's original size + * on disk. On return, they will be loaded with the texture's in-memory + * target size. The return value is true if the size has been adjusted, or + * false if it is the same. + */ bool Texture:: adjust_size(int &x_size, int &y_size, const string &name, bool for_padding, AutoTextureScale auto_texture_scale) { @@ -2597,8 +2366,8 @@ adjust_size(int &x_size, int &y_size, const string &name, new_x_size = (int)cfloor(new_x_size * texture_scale + 0.5); new_y_size = (int)cfloor(new_y_size * texture_scale + 0.5); - // Don't auto-scale below 4 in either dimension. This causes - // problems for DirectX and texture compression. + // Don't auto-scale below 4 in either dimension. This causes problems for + // DirectX and texture compression. new_x_size = min(max(new_x_size, (int)texture_scale_limit), x_size); new_y_size = min(max(new_y_size, (int)texture_scale_limit), y_size); } @@ -2608,9 +2377,9 @@ adjust_size(int &x_size, int &y_size, const string &name, ats = get_textures_power_2(); } if (!for_padding && ats == ATS_pad) { - // If we're not calculating the padding size--that is, we're - // calculating the initial scaling size instead--then ignore - // ATS_pad, and treat it the same as ATS_none. + // If we're not calculating the padding size--that is, we're calculating + // the initial scaling size instead--then ignore ATS_pad, and treat it the + // same as ATS_none. ats = ATS_none; } @@ -2675,57 +2444,46 @@ adjust_size(int &x_size, int &y_size, const string &name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::ensure_loader_type -// Access: Public, Virtual -// Description: May be called prior to calling read_txo() or any -// bam-related Texture-creating callback, to ensure that -// the proper dynamic libraries for a Texture of the -// current class type, and the indicated filename, have -// been already loaded. -// -// This is a low-level function that should not normally -// need to be called directly by the user. -// -// Note that for best results you must first create a -// Texture object of the appropriate class type for your -// filename, for instance with -// TexturePool::make_texture(). -//////////////////////////////////////////////////////////////////// +/** + * May be called prior to calling read_txo() or any bam-related Texture- + * creating callback, to ensure that the proper dynamic libraries for a + * Texture of the current class type, and the indicated filename, have been + * already loaded. + * + * This is a low-level function that should not normally need to be called + * directly by the user. + * + * Note that for best results you must first create a Texture object of the + * appropriate class type for your filename, for instance with + * TexturePool::make_texture(). + */ void Texture:: ensure_loader_type(const Filename &filename) { // For a plain Texture type, this doesn't need to do anything. } -//////////////////////////////////////////////////////////////////// -// Function: Texture::reconsider_dirty -// Access: Protected, Virtual -// Description: Called by TextureContext to give the Texture a chance -// to mark itself dirty before rendering, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called by TextureContext to give the Texture a chance to mark itself dirty + * before rendering, if necessary. + */ void Texture:: reconsider_dirty() { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_adjust_this_size -// Access: Protected, Virtual -// Description: Works like adjust_size, but also considers the -// texture class. Movie textures, for instance, always -// pad outwards, regardless of textures-power-2. -//////////////////////////////////////////////////////////////////// +/** + * Works like adjust_size, but also considers the texture class. Movie + * textures, for instance, always pad outwards, regardless of textures- + * power-2. + */ bool Texture:: do_adjust_this_size(const CData *cdata, int &x_size, int &y_size, const string &name, bool for_padding) const { return adjust_size(x_size, y_size, name, for_padding, cdata->_auto_texture_scale); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read -// Access: Protected, Virtual -// Description: The internal implementation of the various read() -// methods. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of the various read() methods. + */ bool Texture:: do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, int primary_file_num_channels, int alpha_file_channel, @@ -2743,8 +2501,8 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } if ((z == 0 || read_pages) && (n == 0 || read_mipmaps)) { - // When we re-read the page 0 of the base image, we clear - // everything and start over. + // When we re-read the page 0 of the base image, we clear everything and + // start over. do_clear_ram_image(cdata); } @@ -2763,14 +2521,13 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } // If read_pages or read_mipmaps is specified, then z and n actually - // indicate z_size and n_size, respectively--the numerical limits on - // which to search for filenames. + // indicate z_size and n_size, respectively--the numerical limits on which + // to search for filenames. int z_size = z; int n_size = n; - // Certain texture types have an implicit z_size. If z_size is - // omitted, choose an appropriate default based on the texture - // type. + // Certain texture types have an implicit z_size. If z_size is omitted, + // choose an appropriate default based on the texture type. if (z_size == 0) { switch (cdata->_texture_type) { case TT_1d_texture: @@ -2808,9 +2565,9 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, n = 0; while (true) { - // For mipmap level 0, the total number of pages might be - // determined by the number of files we find. After mipmap - // level 0, though, the number of pages is predetermined. + // For mipmap level 0, the total number of pages might be determined by + // the number of files we find. After mipmap level 0, though, the + // number of pages is predetermined. if (n != 0) { z_size = do_get_expected_mipmap_z_size(cdata, n); } @@ -2853,9 +2610,8 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, } if (n == 0 && n_size == 0) { - // If n_size is not specified, it gets implicitly set after we - // read the base texture image (which determines the size of - // the texture). + // If n_size is not specified, it gets implicitly set after we read + // the base texture image (which determines the size of the texture). n_size = do_get_expected_num_mipmap_levels(cdata); } ++n; @@ -2919,8 +2675,8 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, ++n; if (n_size == 0 && n >= do_get_expected_num_mipmap_levels(cdata)) { - // Don't try to read more than the requisite number of mipmap - // levels (unless the user insisted on it for some reason). + // Don't try to read more than the requisite number of mipmap levels + // (unless the user insisted on it for some reason). break; } @@ -2944,14 +2700,13 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, cdata->_num_mipmap_levels_read = cdata->_ram_images.size(); if (header_only) { - // If we were only supposed to be checking the image header - // information, don't let the Texture think that it's got the - // image now. + // If we were only supposed to be checking the image header information, + // don't let the Texture think that it's got the image now. do_clear_ram_image(cdata); } else { if ((options.get_texture_flags() & LoaderOptions::TF_preload) != 0) { - // If we intend to keep the ram image around, consider - // compressing it etc. + // If we intend to keep the ram image around, consider compressing it + // etc. bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0); do_consider_auto_process_ram_image(cdata, generate_mipmaps || uses_mipmaps(), true); } @@ -2960,13 +2715,10 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read_one -// Access: Protected, Virtual -// Description: Called only from do_read(), this method reads a -// single image file, either one page or one mipmap -// level. -//////////////////////////////////////////////////////////////////// +/** + * Called only from do_read(), this method reads a single image file, either + * one page or one mipmap level. + */ bool Texture:: do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, int z, int n, int primary_file_num_channels, int alpha_file_channel, @@ -2988,8 +2740,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa AutoTextureScale auto_texture_scale = do_get_auto_texture_scale(cdata); - // If it's a floating-point image file, read it by default into a - // floating-point texture. + // If it's a floating-point image file, read it by default into a floating- + // point texture. bool read_floating_point; int texture_load_type = (options.get_texture_flags() & (LoaderOptions::TF_integer | LoaderOptions::TF_float)); switch (texture_load_type) { @@ -3002,8 +2754,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa break; default: - // Neither TF_integer nor TF_float was specified; determine which - // way the texture wants to be loaded. + // Neither TF_integer nor TF_float was specified; determine which way the + // texture wants to be loaded. read_floating_point = (image_reader->is_floating_point()); if (!alpha_fullpath.empty()) { read_floating_point = false; @@ -3019,8 +2771,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa } if (textures_header_only) { - // In this mode, we never intend to load the actual texture - // image anyway, so we don't even need to make the size right. + // In this mode, we never intend to load the actual texture image + // anyway, so we don't even need to make the size right. x_size = 1; y_size = 1; @@ -3135,9 +2887,9 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa cdata->_filename = fullpath; cdata->_alpha_filename = alpha_fullpath; - // The first time we set the filename via a read() operation, we - // clear keep_ram_image. The user can always set it again later - // if he needs to. + // The first time we set the filename via a read() operation, we clear + // keep_ram_image. The user can always set it again later if he needs + // to. cdata->_keep_ram_image = false; } @@ -3146,9 +2898,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa } if (!alpha_fullpath.empty()) { - // The grayscale (alpha channel) image must be the same size as - // the main image. This should really have been already - // guaranteed by the above. + // The grayscale (alpha channel) image must be the same size as the main + // image. This should really have been already guaranteed by the above. if (image.get_x_size() != alpha_image.get_x_size() || image.get_y_size() != alpha_image.get_y_size()) { gobj_cat.info() @@ -3174,8 +2925,8 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa } if (!alpha_fullpath.empty()) { - // Make the original image a 4-component image by taking the - // grayscale value from the second image. + // Make the original image a 4-component image by taking the grayscale + // value from the second image. image.add_alpha(); if (alpha_file_channel == 4 || @@ -3220,8 +2971,7 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa return false; } } else { - // Now see if we want to pad the image within a larger power-of-2 - // image. + // Now see if we want to pad the image within a larger power-of-2 image. int pad_x_size = 0; int pad_y_size = 0; if (do_get_auto_texture_scale(cdata) == ATS_pad) { @@ -3247,19 +2997,16 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_load_one -// Access: Protected, Virtual -// Description: Internal method to load a single page or mipmap -// level. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to load a single page or mipmap level. + */ bool Texture:: do_load_one(CData *cdata, const PNMImage &pnmimage, const string &name, int z, int n, const LoaderOptions &options) { if (cdata->_ram_images.size() <= 1 && n == 0) { - // A special case for mipmap level 0. When we load mipmap level - // 0, unless we already have mipmap levels, it determines the - // image properties like size and number of components. + // A special case for mipmap level 0. When we load mipmap level 0, unless + // we already have mipmap levels, it determines the image properties like + // size and number of components. if (!do_reconsider_z_size(cdata, z, options)) { return false; } @@ -3324,19 +3071,16 @@ do_load_one(CData *cdata, const PNMImage &pnmimage, const string &name, int z, i return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_load_one -// Access: Protected, Virtual -// Description: Internal method to load a single page or mipmap -// level. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to load a single page or mipmap level. + */ bool Texture:: do_load_one(CData *cdata, const PfmFile &pfm, const string &name, int z, int n, const LoaderOptions &options) { if (cdata->_ram_images.size() <= 1 && n == 0) { - // A special case for mipmap level 0. When we load mipmap level - // 0, unless we already have mipmap levels, it determines the - // image properties like size and number of components. + // A special case for mipmap level 0. When we load mipmap level 0, unless + // we already have mipmap levels, it determines the image properties like + // size and number of components. if (!do_reconsider_z_size(cdata, z, options)) { return false; } @@ -3392,12 +3136,10 @@ do_load_one(CData *cdata, const PfmFile &pfm, const string &name, int z, int n, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_load_sub_image -// Access: Protected, Virtual -// Description: Internal method to load an image into a section of -// a texture page or mipmap level. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to load an image into a section of a texture page or mipmap + * level. + */ bool Texture:: do_load_sub_image(CData *cdata, const PNMImage &image, int x, int y, int z, int n) { nassertr(n >= 0 && (size_t)n < cdata->_ram_images.size(), false); @@ -3426,12 +3168,10 @@ do_load_sub_image(CData *cdata, const PNMImage &image, int x, int y, int z, int return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read_txo_file -// Access: Protected -// Description: Called internally when read() detects a txo file. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when read() detects a txo file. Assumes the lock is + * already held. + */ bool Texture:: do_read_txo_file(CData *cdata, const Filename &fullpath) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -3461,11 +3201,9 @@ do_read_txo_file(CData *cdata, const Filename &fullpath) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read_txo -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_read_txo(CData *cdata, istream &in, const string &filename) { PT(Texture) other = make_from_txo(in, filename); @@ -3485,12 +3223,10 @@ do_read_txo(CData *cdata, istream &in, const string &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read_dds_file -// Access: Private -// Description: Called internally when read() detects a DDS file. -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when read() detects a DDS file. Assumes the lock is + * already held. + */ bool Texture:: do_read_dds_file(CData *cdata, const Filename &fullpath, bool header_only) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -3524,11 +3260,9 @@ do_read_dds_file(CData *cdata, const Filename &fullpath, bool header_only) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_read_dds -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) { StreamReader dds(in); @@ -3575,8 +3309,8 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) header.num_levels = 1; } else if (header.num_levels == 0) { - // Some files seem to have this set to 0 for some reason--existing - // readers assume 0 means 1. + // Some files seem to have this set to 0 for some reason--existing readers + // assume 0 means 1. header.num_levels = 1; } @@ -3931,8 +3665,8 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) switch (texture_type) { case TT_3d_texture: { - // 3-d textures store all the depth slices for mipmap level 0, - // then all the depth slices for mipmap level 1, and so on. + // 3-d textures store all the depth slices for mipmap level 0, then + // all the depth slices for mipmap level 1, and so on. for (int n = 0; n < (int)header.num_levels; ++n) { int z_size = do_get_expected_mipmap_z_size(cdata, n); pvector pages; @@ -3947,9 +3681,9 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) page_size = page.size(); pages.push_back(page); } - // Now reassemble the pages into one big image. Because - // this is a Microsoft format, the images are stacked in - // reverse order; re-reverse them. + // Now reassemble the pages into one big image. Because this is a + // Microsoft format, the images are stacked in reverse order; re- + // reverse them. PTA_uchar image = PTA_uchar::empty_array(page_size * z_size); unsigned char *imagep = (unsigned char *)image.p(); for (z = 0; z < z_size; ++z) { @@ -3964,8 +3698,8 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) case TT_cube_map: { - // Cube maps store all the mipmap levels for face 0, then all - // the mipmap levels for face 1, and so on. + // Cube maps store all the mipmap levels for face 0, then all the + // mipmap levels for face 1, and so on. pvector > pages; pages.reserve(6); int z, n; @@ -3983,9 +3717,9 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) } } - // Now, for each level, reassemble the pages into one big - // image. Because this is a Microsoft format, the levels are - // arranged in a rotated order. + // Now, for each level, reassemble the pages into one big image. + // Because this is a Microsoft format, the levels are arranged in a + // rotated order. static const int level_remap[6] = { 0, 1, 5, 4, 2, 3 }; @@ -4007,8 +3741,8 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) case TT_2d_texture_array: case TT_cube_map_array: //TODO: rearrange cube map array faces? { - // Texture arrays store all the mipmap levels for layer 0, then - // all the mipmap levels for layer 1, and so on. + // Texture arrays store all the mipmap levels for layer 0, then all + // the mipmap levels for layer 1, and so on. pvector > pages; pages.reserve(header.depth); int z, n; @@ -4026,8 +3760,7 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) } } - // Now, for each level, reassemble the pages into one big - // image. + // Now, for each level, reassemble the pages into one big image. for (n = 0; n < (int)header.num_levels; ++n) { size_t page_size = pages[0][n].size(); PTA_uchar image = PTA_uchar::empty_array(page_size * header.depth); @@ -4071,12 +3804,10 @@ do_read_dds(CData *cdata, istream &in, const string &filename, bool header_only) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write -// Access: Protected -// Description: Internal method to write a series of pages and/or -// mipmap levels to disk files. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to write a series of pages and/or mipmap levels to disk + * files. + */ bool Texture:: do_write(CData *cdata, const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps) { @@ -4163,12 +3894,10 @@ do_write(CData *cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_one -// Access: Protected -// Description: Internal method to write the indicated page and -// mipmap level to a disk image file. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to write the indicated page and mipmap level to a disk + * image file. + */ bool Texture:: do_write_one(CData *cdata, const Filename &fullpath, int z, int n) { if (!do_has_ram_mipmap_image(cdata, n)) { @@ -4203,12 +3932,9 @@ do_write_one(CData *cdata, const Filename &fullpath, int z, int n) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_store_one -// Access: Protected -// Description: Internal method to copy a page and/or mipmap level to -// a PNMImage. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to copy a page and/or mipmap level to a PNMImage. + */ bool Texture:: do_store_one(CData *cdata, PNMImage &pnmimage, int z, int n) { // First, reload the ram image if necessary. @@ -4244,12 +3970,9 @@ do_store_one(CData *cdata, PNMImage &pnmimage, int z, int n) { do_get_ram_mipmap_page_size(cdata, n), z); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_store_one -// Access: Protected -// Description: Internal method to copy a page and/or mipmap level to -// a PfmFile. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to copy a page and/or mipmap level to a PfmFile. + */ bool Texture:: do_store_one(CData *cdata, PfmFile &pfm, int z, int n) { // First, reload the ram image if necessary. @@ -4285,12 +4008,9 @@ do_store_one(CData *cdata, PfmFile &pfm, int z, int n) { do_get_ram_mipmap_page_size(cdata, n), z); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_txo_file -// Access: Private -// Description: Called internally when write() detects a txo -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when write() detects a txo filename. + */ bool Texture:: do_write_txo_file(const CData *cdata, const Filename &fullpath) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -4307,11 +4027,9 @@ do_write_txo_file(const CData *cdata, const Filename &fullpath) const { return success; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_txo -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_write_txo(const CData *cdata, ostream &out, const string &filename) const { DatagramOutputFile dout; @@ -4348,32 +4066,26 @@ do_write_txo(const CData *cdata, ostream &out, const string &filename) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::unlocked_ensure_ram_image -// Access: Protected, Virtual -// Description: If the texture has a ram image already, this acquires -// the CData write lock and returns it. -// -// If the texture lacks a ram image, this performs -// do_reload_ram_image(), but without holding the lock -// on this particular Texture object, to avoid holding -// the lock across what might be a slow operation. -// Instead, the reload is performed in a copy of the -// texture object, and then the lock is acquired and the -// data is copied in. -// -// In any case, the return value is a locked CData -// object, which must be released with an explicit call -// to release_write(). The CData object will have a ram -// image unless for some reason do_reload_ram_image() -// fails. -//////////////////////////////////////////////////////////////////// +/** + * If the texture has a ram image already, this acquires the CData write lock + * and returns it. + * + * If the texture lacks a ram image, this performs do_reload_ram_image(), but + * without holding the lock on this particular Texture object, to avoid + * holding the lock across what might be a slow operation. Instead, the + * reload is performed in a copy of the texture object, and then the lock is + * acquired and the data is copied in. + * + * In any case, the return value is a locked CData object, which must be + * released with an explicit call to release_write(). The CData object will + * have a ram image unless for some reason do_reload_ram_image() fails. + */ Texture::CData *Texture:: unlocked_ensure_ram_image(bool allow_compression) { Thread *current_thread = Thread::get_current_thread(); - // First, wait for any other threads that might be simultaneously - // performing the same operation. + // First, wait for any other threads that might be simultaneously performing + // the same operation. MutexHolder holder(_lock); while (_reloading) { _cvar.wait(); @@ -4383,13 +4095,13 @@ unlocked_ensure_ram_image(bool allow_compression) { const CData *cdata = _cycler.read(current_thread); bool has_ram_image = do_has_ram_image(cdata); if (has_ram_image && !allow_compression && cdata->_ram_image_compression != Texture::CM_off) { - // If we don't want compression, but the ram image we have is - // pre-compressed, we don't consider it. + // If we don't want compression, but the ram image we have is pre- + // compressed, we don't consider it. has_ram_image = false; } if (has_ram_image || !do_can_reload(cdata)) { - // We don't need to reload after all, or maybe we can't reload - // anyway. Return, but elevate the lock first, as we promised. + // We don't need to reload after all, or maybe we can't reload anyway. + // Return, but elevate the lock first, as we promised. return _cycler.elevate_read_upstream(cdata, false, current_thread); } @@ -4401,8 +4113,8 @@ unlocked_ensure_ram_image(bool allow_compression) { _cycler.release_read(cdata); _lock.release(); - // Perform the actual reload in a copy of the texture, while our - // own mutex is left unlocked. + // Perform the actual reload in a copy of the texture, while our own mutex + // is left unlocked. CDWriter cdata_tex(tex->_cycler, true); tex->do_reload_ram_image(cdata_tex, allow_compression); @@ -4410,17 +4122,16 @@ unlocked_ensure_ram_image(bool allow_compression) { CData *cdataw = _cycler.write_upstream(false, current_thread); - // Rather than calling do_assign(), which would copy *all* of the - // reloaded texture's properties over, we only copy in the ones - // which are relevant to the ram image. This way, if the - // properties have changed during the reload (for instance, - // because we reloaded a txo), it won't contaminate the original - // texture. + // Rather than calling do_assign(), which would copy *all* of the reloaded + // texture's properties over, we only copy in the ones which are relevant to + // the ram image. This way, if the properties have changed during the + // reload (for instance, because we reloaded a txo), it won't contaminate + // the original texture. cdataw->_orig_file_x_size = cdata_tex->_orig_file_x_size; cdataw->_orig_file_y_size = cdata_tex->_orig_file_y_size; - // If any of *these* properties have changed, the texture has - // changed in some fundamental way. Update it appropriately. + // If any of *these* properties have changed, the texture has changed in + // some fundamental way. Update it appropriately. if (cdata_tex->_x_size != cdataw->_x_size || cdata_tex->_y_size != cdataw->_y_size || cdata_tex->_z_size != cdataw->_z_size || @@ -4453,8 +4164,8 @@ unlocked_ensure_ram_image(bool allow_compression) { _reloading = false; // We don't generally increment the cdata->_image_modified semaphore, - // because this is just a reload, and presumably the image hasn't - // changed (unless we hit the if condition above). + // because this is just a reload, and presumably the image hasn't changed + // (unless we hit the if condition above). _cvar.notify_all(); @@ -4462,17 +4173,14 @@ unlocked_ensure_ram_image(bool allow_compression) { return cdataw; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_reload_ram_image -// Access: Protected, Virtual -// Description: Called when the Texture image is required but the ram -// image is not available, this will reload it from disk -// or otherwise do whatever is required to make it -// available, if possible. -// -// Assumes the lock is already held. The lock will be -// held during the duration of this operation. -//////////////////////////////////////////////////////////////////// +/** + * Called when the Texture image is required but the ram image is not + * available, this will reload it from disk or otherwise do whatever is + * required to make it available, if possible. + * + * Assumes the lock is already held. The lock will be held during the + * duration of this operation. + */ void Texture:: do_reload_ram_image(CData *cdata, bool allow_compression) { BamCache *cache = BamCache::get_global_ptr(); @@ -4483,16 +4191,15 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { } if ((cache->get_cache_textures() || (allow_compression && cache->get_cache_compressed_textures())) && !textures_header_only) { - // See if the texture can be found in the on-disk cache, if it is - // active. + // See if the texture can be found in the on-disk cache, if it is active. record = cache->lookup(cdata->_fullpath, "txo"); if (record != (BamCacheRecord *)NULL && record->has_data()) { PT(Texture) tex = DCAST(Texture, record->get_data()); - // But don't use the cache record if the config parameters have - // changed, and we want a different-sized texture now. + // But don't use the cache record if the config parameters have changed, + // and we want a different-sized texture now. int x_size = cdata->_orig_file_x_size; int y_size = cdata->_orig_file_y_size; do_adjust_this_size(cdata, x_size, y_size, cdata->_filename.get_basename(), true); @@ -4505,8 +4212,8 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { << "; ignoring cache.\n"; } } else { - // Also don't keep the cached version if it's compressed but - // we want uncompressed. + // Also don't keep the cached version if it's compressed but we want + // uncompressed. if (!allow_compression && tex->get_ram_image_compression() != Texture::CM_off) { if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -4517,9 +4224,9 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { gobj_cat.info() << "Texture " << get_name() << " reloaded from disk cache\n"; // We don't want to replace all the texture parameters--for - // instance, we don't want to change the filter type or the - // border color or anything--we just want to get the image and - // necessary associated parameters. + // instance, we don't want to change the filter type or the border + // color or anything--we just want to get the image and necessary + // associated parameters. CDReader cdata_tex(tex->_cycler); cdata->_x_size = cdata_tex->_x_size; cdata->_y_size = cdata_tex->_y_size; @@ -4539,8 +4246,8 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { if (!was_compressed && is_compressed && cache->get_cache_compressed_textures()) { // We've re-compressed the image after loading it from the - // cache. To keep the cache current, rewrite it to the - // cache now, in its newly compressed form. + // cache. To keep the cache current, rewrite it to the cache + // now, in its newly compressed form. record->set_data(this, this); cache->store(record); } @@ -4576,8 +4283,8 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, NULL); if (orig_num_components == cdata->_num_components) { - // Restore the original format, in case it was needlessly changed - // during the reload operation. + // Restore the original format, in case it was needlessly changed during + // the reload operation. cdata->_format = orig_format; } @@ -4593,12 +4300,10 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_modify_ram_image -// Access: Protected -// Description: This is called internally to uniquify the ram image -// pointer without updating cdata->_image_modified. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally to uniquify the ram image pointer without + * updating cdata->_image_modified. + */ PTA_uchar Texture:: do_modify_ram_image(CData *cdata) { if (cdata->_ram_images.empty() || cdata->_ram_images[0]._image.empty() || @@ -4610,12 +4315,10 @@ do_modify_ram_image(CData *cdata) { return cdata->_ram_images[0]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_make_ram_image -// Access: Protected -// Description: This is called internally to make a new ram image -// without updating cdata->_image_modified. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally to make a new ram image without updating + * cdata->_image_modified. + */ PTA_uchar Texture:: do_make_ram_image(CData *cdata) { int image_size = do_get_expected_ram_image_size(cdata); @@ -4641,16 +4344,13 @@ do_make_ram_image(CData *cdata) { return cdata->_ram_images[0]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_ram_image -// Access: Protected -// Description: Replaces the current system-RAM image with the new -// data. If compression is not CM_off, it indicates -// that the new data is already pre-compressed in the -// indicated format. -// -// This does *not* affect keep_ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the current system-RAM image with the new data. If compression is + * not CM_off, it indicates that the new data is already pre-compressed in the + * indicated format. + * + * This does *not* affect keep_ram_image. + */ void Texture:: do_set_ram_image(CData *cdata, CPTA_uchar image, Texture::CompressionMode compression, size_t page_size) { @@ -4675,12 +4375,10 @@ do_set_ram_image(CData *cdata, CPTA_uchar image, Texture::CompressionMode compre } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_modify_ram_mipmap_image -// Access: Protected -// Description: This is called internally to uniquify the nth mipmap -// image pointer without updating cdata->_image_modified. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally to uniquify the nth mipmap image pointer without + * updating cdata->_image_modified. + */ PTA_uchar Texture:: do_modify_ram_mipmap_image(CData *cdata, int n) { nassertr(cdata->_ram_image_compression == CM_off, PTA_uchar()); @@ -4692,11 +4390,9 @@ do_modify_ram_mipmap_image(CData *cdata, int n) { return cdata->_ram_images[n]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_make_ram_mipmap_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PTA_uchar Texture:: do_make_ram_mipmap_image(CData *cdata, int n) { nassertr(cdata->_ram_image_compression == CM_off, PTA_uchar(get_class_type())); @@ -4725,11 +4421,9 @@ do_make_ram_mipmap_image(CData *cdata, int n) { return cdata->_ram_images[n]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_ram_mipmap_image -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) { nassertv(cdata->_ram_image_compression != CM_off || image.size() == do_get_expected_ram_mipmap_image_size(cdata, n)); @@ -4750,24 +4444,19 @@ do_set_ram_mipmap_image(CData *cdata, int n, CPTA_uchar image, size_t page_size) } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_clear_color -// Access: Published -// Description: Returns a string with a single pixel representing -// the clear color of the texture in the format of -// this texture. -// -// In other words, to create an uncompressed RAM -// texture filled with the clear color, it should -// be initialized with this string repeated for -// every pixel. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string with a single pixel representing the clear color of the + * texture in the format of this texture. + * + * In other words, to create an uncompressed RAM texture filled with the clear + * color, it should be initialized with this string repeated for every pixel. + */ size_t Texture:: do_get_clear_data(const CData *cdata, unsigned char *into) const { nassertr(cdata->_has_clear_color, 0); nassertr(cdata->_num_components <= 4, 0); - //TODO: encode the color into the sRGB color space if used + // TODO: encode the color into the sRGB color space if used switch (cdata->_component_type) { case T_unsigned_byte: { @@ -4837,8 +4526,8 @@ do_get_clear_data(const CData *cdata, unsigned char *into) const { case T_int: { - // Note: there are no 32-bit UNORM textures. Therefore, we don't - // do any normalization here, either. + // Note: there are no 32-bit UNORM textures. Therefore, we don't do any + // normalization here, either. switch (cdata->_num_components) { case 2: ((int *)into)[1] = (int)cdata->_clear_color[1]; @@ -4902,32 +4591,26 @@ do_get_clear_data(const CData *cdata, unsigned char *into) const { return cdata->_num_components * cdata->_component_width; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::consider_auto_process_ram_image -// Access: Protected -// Description: Should be called after a texture has been loaded into -// RAM, this considers generating mipmaps and/or -// compressing the RAM image. -// -// Returns true if the image was modified by this -// operation, false if it wasn't. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after a texture has been loaded into RAM, this considers + * generating mipmaps and/or compressing the RAM image. + * + * Returns true if the image was modified by this operation, false if it + * wasn't. + */ bool Texture:: consider_auto_process_ram_image(bool generate_mipmaps, bool allow_compression) { CDWriter cdata(_cycler, false); return do_consider_auto_process_ram_image(cdata, generate_mipmaps, allow_compression); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_consider_auto_process_ram_image -// Access: Protected -// Description: Should be called after a texture has been loaded into -// RAM, this considers generating mipmaps and/or -// compressing the RAM image. -// -// Returns true if the image was modified by this -// operation, false if it wasn't. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after a texture has been loaded into RAM, this considers + * generating mipmaps and/or compressing the RAM image. + * + * Returns true if the image was modified by this operation, false if it + * wasn't. + */ bool Texture:: do_consider_auto_process_ram_image(CData *cdata, bool generate_mipmaps, bool allow_compression) { @@ -4960,11 +4643,9 @@ do_consider_auto_process_ram_image(CData *cdata, bool generate_mipmaps, return modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_compress_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, Texture::QualityLevel quality_level, @@ -5042,8 +4723,8 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, } if (!do_has_all_ram_mipmap_images(cdata)) { - // If we're about to compress the RAM image, we should ensure that - // we have all of the mipmap levels first. + // If we're about to compress the RAM image, we should ensure that we + // have all of the mipmap levels first. do_generate_ram_mipmap_images(cdata); } @@ -5057,9 +4738,9 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, int y_size = do_get_expected_mipmap_y_size(cdata, n); int num_pages = do_get_expected_mipmap_num_pages(cdata, n); - // It is important that we handle image sizes that aren't a multiple - // of the block size, since this method may be used to compress - // mipmaps, which go all the way to 1x1. Pad the image if necessary. + // It is important that we handle image sizes that aren't a multiple of + // the block size, since this method may be used to compress mipmaps, + // which go all the way to 1x1. Pad the image if necessary. RamImage temp_image; if ((x_size | y_size) & 0x3) { int virtual_x_size = x_size; @@ -5159,11 +4840,9 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_uncompress_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_uncompress_ram_image(CData *cdata) { nassertr(!cdata->_ram_images.empty(), false); @@ -5233,11 +4912,9 @@ do_uncompress_ram_image(CData *cdata) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_compress_ram_image_bc4 -// Access: Protected, Static -// Description: Compresses a RAM image using BC4 compression. -//////////////////////////////////////////////////////////////////// +/** + * Compresses a RAM image using BC4 compression. + */ void Texture:: do_compress_ram_image_bc4(const RamImage &uncompressed_image, RamImage &compressed_image, @@ -5245,9 +4922,9 @@ do_compress_ram_image_bc4(const RamImage &uncompressed_image, int x_blocks = (x_size >> 2); int y_blocks = (y_size >> 2); - //NB. This algorithm isn't fully optimal, since it doesn't try to make - // use of the secondary interpolation mode supported by BC4. This is - // not important for most textures, but it may be added in the future. + // NB. This algorithm isn't fully optimal, since it doesn't try to make use + // of the secondary interpolation mode supported by BC4. This is not + // important for most textures, but it may be added in the future. nassertv(x_blocks * y_blocks * 4 * 4 <= uncompressed_image._page_size); nassertv(x_size * y_size == uncompressed_image._page_size); @@ -5334,11 +5011,9 @@ do_compress_ram_image_bc4(const RamImage &uncompressed_image, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_compress_ram_image_bc5 -// Access: Protected, Static -// Description: Compresses a RAM image using BC5 compression. -//////////////////////////////////////////////////////////////////// +/** + * Compresses a RAM image using BC5 compression. + */ void Texture:: do_compress_ram_image_bc5(const RamImage &uncompressed_image, RamImage &compressed_image, @@ -5347,8 +5022,8 @@ do_compress_ram_image_bc5(const RamImage &uncompressed_image, int y_blocks = (y_size >> 2); int stride = x_size * 2; - // BC5 uses the same compression algorithm as BC4, except repeated - // for two channels. + // BC5 uses the same compression algorithm as BC4, except repeated for two + // channels. nassertv(x_blocks * y_blocks * 4 * 4 * 2 <= uncompressed_image._page_size); nassertv(stride * y_size == uncompressed_image._page_size); @@ -5495,11 +5170,9 @@ do_compress_ram_image_bc5(const RamImage &uncompressed_image, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_uncompress_ram_image_bc4 -// Access: Protected, Static -// Description: Decompresses a RAM image compressed using BC4. -//////////////////////////////////////////////////////////////////// +/** + * Decompresses a RAM image compressed using BC4. + */ void Texture:: do_uncompress_ram_image_bc4(const RamImage &compressed_image, RamImage &uncompressed_image, @@ -5563,11 +5236,9 @@ do_uncompress_ram_image_bc4(const RamImage &compressed_image, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_uncompress_ram_image_bc5 -// Access: Protected, Static -// Description: Decompresses a RAM image compressed using BC5. -//////////////////////////////////////////////////////////////////// +/** + * Decompresses a RAM image compressed using BC5. + */ void Texture:: do_uncompress_ram_image_bc5(const RamImage &compressed_image, RamImage &uncompressed_image, @@ -5668,11 +5339,9 @@ do_uncompress_ram_image_bc5(const RamImage &compressed_image, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_all_ram_mipmap_images -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_has_all_ram_mipmap_images(const CData *cdata) const { if (cdata->_ram_images.empty() || cdata->_ram_images[0]._image.empty()) { @@ -5680,13 +5349,12 @@ do_has_all_ram_mipmap_images(const CData *cdata) const { return false; } if (!uses_mipmaps()) { - // If we have a base image and don't require mipmapping, the - // answer is yes. + // If we have a base image and don't require mipmapping, the answer is + // yes. return true; } - // Check that we have enough mipmap levels to meet the size - // requirements. + // Check that we have enough mipmap levels to meet the size requirements. int size = max(cdata->_x_size, max(cdata->_y_size, cdata->_z_size)); int n = 0; int x = 1; @@ -5701,42 +5369,38 @@ do_has_all_ram_mipmap_images(const CData *cdata) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_reconsider_z_size -// Access: Protected -// Description: Considers whether the z_size (or num_views) should -// automatically be adjusted when the user loads a new -// page. Returns true if the z size is valid, false -// otherwise. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Considers whether the z_size (or num_views) should automatically be + * adjusted when the user loads a new page. Returns true if the z size is + * valid, false otherwise. + * + * Assumes the lock is already held. + */ bool Texture:: do_reconsider_z_size(CData *cdata, int z, const LoaderOptions &options) { if (z >= cdata->_z_size * cdata->_num_views) { bool num_views_specified = true; if (options.get_texture_flags() & LoaderOptions::TF_multiview) { - // This flag is false if is a multiview texture with a specified - // number of views. It is true if it is not a multiview - // texture, or if it is but the number of views is explicitly - // specified. + // This flag is false if is a multiview texture with a specified number + // of views. It is true if it is not a multiview texture, or if it is + // but the number of views is explicitly specified. num_views_specified = (options.get_texture_num_views() != 0); } if (num_views_specified && (cdata->_texture_type == Texture::TT_3d_texture || cdata->_texture_type == Texture::TT_2d_texture_array)) { - // If we're loading a page past _z_size, treat it as an implicit - // request to enlarge _z_size. However, this is only legal if - // this is, in fact, a 3-d texture or a 2d texture array (cube maps - // always have z_size 6, and other types have z_size 1). + // If we're loading a page past _z_size, treat it as an implicit request + // to enlarge _z_size. However, this is only legal if this is, in fact, + // a 3-d texture or a 2d texture array (cube maps always have z_size 6, + // and other types have z_size 1). nassertr(cdata->_num_views != 0, false); cdata->_z_size = (z / cdata->_num_views) + 1; } else if (cdata->_z_size != 0) { - // In the case of a 2-d texture or cube map, or a 3-d texture - // with an unspecified _num_views, assume we're loading views of - // a multiview texture. + // In the case of a 2-d texture or cube map, or a 3-d texture with an + // unspecified _num_views, assume we're loading views of a multiview + // texture. cdata->_num_views = (z / cdata->_z_size) + 1; } else { @@ -5744,23 +5408,20 @@ do_reconsider_z_size(CData *cdata, int z, const LoaderOptions &options) { cdata->_z_size = 1; } - // Increase the size of the data buffer to make room for the new - // texture level. + // Increase the size of the data buffer to make room for the new texture + // level. do_allocate_pages(cdata); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_allocate_pages -// Access: Protected, Virtual -// Description: Called internally by do_reconsider_z_size() to -// allocate new memory in _ram_images[0] for the new -// number of pages. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called internally by do_reconsider_z_size() to allocate new memory in + * _ram_images[0] for the new number of pages. + * + * Assumes the lock is already held. + */ void Texture:: do_allocate_pages(CData *cdata) { size_t new_size = do_get_expected_ram_image_size(cdata); @@ -5772,25 +5433,22 @@ do_allocate_pages(CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_reconsider_image_properties -// Access: Protected -// Description: Resets the internal Texture properties when a new -// image file is loaded. Returns true if the new image -// is valid, false otherwise. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Resets the internal Texture properties when a new image file is loaded. + * Returns true if the new image is valid, false otherwise. + * + * Assumes the lock is already held. + */ bool Texture:: do_reconsider_image_properties(CData *cdata, int x_size, int y_size, int num_components, Texture::ComponentType component_type, int z, const LoaderOptions &options) { if (!cdata->_loaded_from_image || num_components != cdata->_num_components || component_type != cdata->_component_type) { - // Come up with a default format based on the number of channels. - // But only do this the first time the file is loaded, or if the - // number of channels in the image changes on subsequent loads. + // Come up with a default format based on the number of channels. But + // only do this the first time the file is loaded, or if the number of + // channels in the image changes on subsequent loads. - //TODO: handle sRGB properly + // TODO: handle sRGB properly switch (num_components) { case 1: cdata->_format = F_luminance; @@ -5859,11 +5517,9 @@ do_reconsider_image_properties(CData *cdata, int x_size, int y_size, int num_com return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_rescale_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_rescale_texture(CData *cdata) { int new_x_size = cdata->_x_size; @@ -5938,22 +5594,18 @@ do_rescale_texture(CData *cdata) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_copy_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(Texture) Texture:: make_copy_impl() const { CDReader cdata(_cycler); return do_make_copy(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_make_copy -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(Texture) Texture:: do_make_copy(const CData *cdata) const { PT(Texture) tex = new Texture(get_name()); @@ -5962,23 +5614,18 @@ do_make_copy(const CData *cdata) const { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_assign -// Access: Protected -// Description: The internal implementation of operator =(). Assumes -// the lock is already held on both Textures. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of operator =(). Assumes the lock is already + * held on both Textures. + */ void Texture:: do_assign(CData *cdata, const Texture *copy, const CData *cdata_copy) { cdata->do_assign(cdata_copy); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_clear -// Access: Protected, Virtual -// Description: The protected implementation of clear(). Assumes the -// lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of clear(). Assumes the lock is already held. + */ void Texture:: do_clear(CData *cdata) { Texture tex; @@ -5991,11 +5638,9 @@ do_clear(CData *cdata) { cdata->inc_simple_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_setup_texture -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_setup_texture(CData *cdata, Texture::TextureType texture_type, int x_size, int y_size, int z_size, @@ -6020,8 +5665,8 @@ do_setup_texture(CData *cdata, Texture::TextureType texture_type, // Cube maps must always consist of six square images. nassertv(x_size == y_size && z_size == 6); - // In principle the wrap mode shouldn't mean anything to a cube - // map, but some drivers seem to misbehave if it's other than + // In principle the wrap mode shouldn't mean anything to a cube map, but + // some drivers seem to misbehave if it's other than // SamplerState::WM_clamp. cdata->_default_sampler.set_wrap_u(SamplerState::WM_clamp); cdata->_default_sampler.set_wrap_v(SamplerState::WM_clamp); @@ -6064,11 +5709,9 @@ do_setup_texture(CData *cdata, Texture::TextureType texture_type, cdata->_has_read_mipmaps = false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_format -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_format(CData *cdata, Texture::Format format) { if (format == cdata->_format) { @@ -6137,11 +5780,9 @@ do_set_format(CData *cdata, Texture::Format format) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_component_type -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_component_type(CData *cdata, Texture::ComponentType component_type) { cdata->_component_type = component_type; @@ -6172,11 +5813,9 @@ do_set_component_type(CData *cdata, Texture::ComponentType component_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_x_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_x_size(CData *cdata, int x_size) { if (cdata->_x_size != x_size) { @@ -6187,11 +5826,9 @@ do_set_x_size(CData *cdata, int x_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_y_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_y_size(CData *cdata, int y_size) { if (cdata->_y_size != y_size) { @@ -6204,13 +5841,10 @@ do_set_y_size(CData *cdata, int y_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_z_size -// Access: Protected -// Description: Changes the z size indicated for the texture. This -// also implicitly unloads the texture if it has already -// been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Changes the z size indicated for the texture. This also implicitly unloads + * the texture if it has already been loaded. + */ void Texture:: do_set_z_size(CData *cdata, int z_size) { if (cdata->_z_size != z_size) { @@ -6225,11 +5859,9 @@ do_set_z_size(CData *cdata, int z_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_num_views -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_num_views(CData *cdata, int num_views) { nassertv(num_views >= 1); @@ -6243,11 +5875,9 @@ do_set_num_views(CData *cdata, int num_views) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_wrap_u -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_wrap_u(CData *cdata, SamplerState::WrapMode wrap) { if (cdata->_default_sampler.get_wrap_u() != wrap) { @@ -6256,11 +5886,9 @@ do_set_wrap_u(CData *cdata, SamplerState::WrapMode wrap) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_wrap_v -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_wrap_v(CData *cdata, SamplerState::WrapMode wrap) { if (cdata->_default_sampler.get_wrap_v() != wrap) { @@ -6269,11 +5897,9 @@ do_set_wrap_v(CData *cdata, SamplerState::WrapMode wrap) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_wrap_w -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_wrap_w(CData *cdata, SamplerState::WrapMode wrap) { if (cdata->_default_sampler.get_wrap_w() != wrap) { @@ -6282,11 +5908,9 @@ do_set_wrap_w(CData *cdata, SamplerState::WrapMode wrap) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_minfilter -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_minfilter(CData *cdata, SamplerState::FilterType filter) { if (cdata->_default_sampler.get_minfilter() != filter) { @@ -6295,11 +5919,9 @@ do_set_minfilter(CData *cdata, SamplerState::FilterType filter) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_magfilter -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_magfilter(CData *cdata, SamplerState::FilterType filter) { if (cdata->_default_sampler.get_magfilter() != filter) { @@ -6308,11 +5930,9 @@ do_set_magfilter(CData *cdata, SamplerState::FilterType filter) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_anisotropic_degree -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_anisotropic_degree(CData *cdata, int anisotropic_degree) { if (cdata->_default_sampler.get_anisotropic_degree() != anisotropic_degree) { @@ -6321,11 +5941,9 @@ do_set_anisotropic_degree(CData *cdata, int anisotropic_degree) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_border_color -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_border_color(CData *cdata, const LColor &color) { if (cdata->_default_sampler.get_border_color() != color) { @@ -6334,11 +5952,9 @@ do_set_border_color(CData *cdata, const LColor &color) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_compression -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_compression(CData *cdata, Texture::CompressionMode compression) { if (cdata->_compression != compression) { @@ -6350,20 +5966,17 @@ do_set_compression(CData *cdata, Texture::CompressionMode compression) { bool has_ram_image_compression = (cdata->_ram_image_compression != CM_off); if (has_compression != has_ram_image_compression || has_compression) { - // Reload if we're turning compression on or off, or if we're - // changing the compression mode to a different kind of - // compression. + // Reload if we're turning compression on or off, or if we're changing + // the compression mode to a different kind of compression. do_reload(cdata); } } } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_quality_level -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_quality_level(CData *cdata, Texture::QualityLevel quality_level) { if (cdata->_quality_level != quality_level) { @@ -6372,11 +5985,9 @@ do_set_quality_level(CData *cdata, Texture::QualityLevel quality_level) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_compression -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_has_compression(const CData *cdata) const { if (cdata->_compression == CM_default) { @@ -6386,44 +5997,36 @@ do_has_compression(const CData *cdata) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_ram_image -// Access: Protected, Virtual -// Description: The protected implementation of has_ram_image(). -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of has_ram_image(). Assumes the lock is + * already held. + */ bool Texture:: do_has_ram_image(const CData *cdata) const { return !cdata->_ram_images.empty() && !cdata->_ram_images[0]._image.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_uncompressed_ram_image -// Access: Protected, Virtual -// Description: The protected implementation of -// has_uncompressed_ram_image(). Assumes the lock is -// already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of has_uncompressed_ram_image(). Assumes the + * lock is already held. + */ bool Texture:: do_has_uncompressed_ram_image(const CData *cdata) const { return !cdata->_ram_images.empty() && !cdata->_ram_images[0]._image.empty() && cdata->_ram_image_compression == CM_off; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPTA_uchar Texture:: do_get_ram_image(CData *cdata) { if (!do_has_ram_image(cdata) && do_can_reload(cdata)) { do_reload_ram_image(cdata, true); if (do_has_ram_image(cdata)) { - // Normally, we don't update the cdata->_modified semaphores in a do_blah - // method, but we'll make an exception in this case, because it's - // easiest to modify these here, and only when we know it's - // needed. + // Normally, we don't update the cdata->_modified semaphores in a + // do_blah method, but we'll make an exception in this case, because + // it's easiest to modify these here, and only when we know it's needed. cdata->inc_image_modified(); cdata->inc_properties_modified(); } @@ -6436,16 +6039,14 @@ do_get_ram_image(CData *cdata) { return cdata->_ram_images[0]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_uncompressed_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPTA_uchar Texture:: do_get_uncompressed_ram_image(CData *cdata) { if (!cdata->_ram_images.empty() && cdata->_ram_image_compression != CM_off) { - // We have an image in-ram, but it's compressed. Try to - // uncompress it first. + // We have an image in-ram, but it's compressed. Try to uncompress it + // first. if (do_uncompress_ram_image(cdata)) { if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -6476,34 +6077,24 @@ do_get_uncompressed_ram_image(CData *cdata) { return cdata->_ram_images[0]._image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::get_ram_image_as -// Access: Published -// Description: Returns the uncompressed system-RAM image data -// associated with the texture. Rather than -// just returning a pointer to the data, like -// get_uncompressed_ram_image, this function first -// processes the data and reorders the components -// using the specified format string, and places these -// into a new char array. The 'format' argument should -// specify in which order the components of the texture -// must be. For example, valid format strings are -// "RGBA", "GA", "ABRG" or "AAA". A component can -// also be written as "0" or "1", which means an -// empty/black or a full/white channel, respectively. -// This function is particularly useful to -// copy an image in-memory to a different library -// (for example, PIL or wxWidgets) that require -// a different component order than Panda's internal -// format, BGRA. Note, however, that this conversion -// can still be too slow if you want to do it every -// frame, and should thus be avoided for that purpose. -// The only requirement for the reordering is that -// an uncompressed image must be available. If the -// RAM image is compressed, it will attempt to re-load -// the texture from disk, if it doesn't find an -// uncompressed image there, it will return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the uncompressed system-RAM image data associated with the texture. + * Rather than just returning a pointer to the data, like + * get_uncompressed_ram_image, this function first processes the data and + * reorders the components using the specified format string, and places these + * into a new char array. The 'format' argument should specify in which order + * the components of the texture must be. For example, valid format strings + * are "RGBA", "GA", "ABRG" or "AAA". A component can also be written as "0" + * or "1", which means an empty/black or a full/white channel, respectively. + * This function is particularly useful to copy an image in-memory to a + * different library (for example, PIL or wxWidgets) that require a different + * component order than Panda's internal format, BGRA. Note, however, that + * this conversion can still be too slow if you want to do it every frame, and + * should thus be avoided for that purpose. The only requirement for the + * reordering is that an uncompressed image must be available. If the RAM + * image is compressed, it will attempt to re-load the texture from disk, if + * it doesn't find an uncompressed image there, it will return NULL. + */ CPTA_uchar Texture:: get_ram_image_as(const string &requested_format) { CDWriter cdata(_cycler, false); @@ -6619,11 +6210,9 @@ get_ram_image_as(const string &requested_format) { return newdata; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_simple_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_simple_ram_image(CData *cdata, CPTA_uchar image, int x_size, int y_size) { nassertv(cdata->_texture_type == TT_2d_texture); @@ -6638,11 +6227,9 @@ do_set_simple_ram_image(CData *cdata, CPTA_uchar image, int x_size, int y_size) cdata->inc_simple_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_num_mipmap_levels -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Texture:: do_get_expected_num_mipmap_levels(const CData *cdata) const { int size = max(cdata->_x_size, max(cdata->_y_size, cdata->_z_size)); @@ -6654,11 +6241,9 @@ do_get_expected_num_mipmap_levels(const CData *cdata) const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_ram_mipmap_page_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t Texture:: do_get_ram_mipmap_page_size(const CData *cdata, int n) const { if (cdata->_ram_image_compression != CM_off) { @@ -6671,11 +6256,9 @@ do_get_ram_mipmap_page_size(const CData *cdata, int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_mipmap_x_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Texture:: do_get_expected_mipmap_x_size(const CData *cdata, int n) const { int size = max(cdata->_x_size, 1); @@ -6686,11 +6269,9 @@ do_get_expected_mipmap_x_size(const CData *cdata, int n) const { return size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_mipmap_y_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Texture:: do_get_expected_mipmap_y_size(const CData *cdata, int n) const { int size = max(cdata->_y_size, 1); @@ -6701,16 +6282,14 @@ do_get_expected_mipmap_y_size(const CData *cdata, int n) const { return size; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_expected_mipmap_z_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int Texture:: do_get_expected_mipmap_z_size(const CData *cdata, int n) const { - // 3-D textures have a different number of pages per each mipmap - // level. Other kinds of textures--especially, cube map - // textures--always have the same. + // 3-D textures have a different number of pages per each mipmap level. + // Other kinds of textures--especially, cube map textures--always have the + // same. if (cdata->_texture_type == Texture::TT_3d_texture) { int size = max(cdata->_z_size, 1); while (n > 0 && size > 1) { @@ -6724,11 +6303,9 @@ do_get_expected_mipmap_z_size(const CData *cdata, int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_clear_simple_ram_image -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_clear_simple_ram_image(CData *cdata) { cdata->_simple_x_size = 0; @@ -6737,17 +6314,15 @@ do_clear_simple_ram_image(CData *cdata) { cdata->_simple_ram_image._page_size = 0; cdata->_simple_image_date_generated = 0; - // We allow this exception: we update the _simple_image_modified - // here, since no one really cares much about that anyway, and it's - // convenient to do it here. + // We allow this exception: we update the _simple_image_modified here, since + // no one really cares much about that anyway, and it's convenient to do it + // here. cdata->inc_simple_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_clear_ram_mipmap_images -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_clear_ram_mipmap_images(CData *cdata) { if (!cdata->_ram_images.empty()) { @@ -6755,11 +6330,9 @@ do_clear_ram_mipmap_images(CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_generate_ram_mipmap_images -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_generate_ram_mipmap_images(CData *cdata) { nassertv(do_has_ram_image(cdata)); @@ -6773,9 +6346,9 @@ do_generate_ram_mipmap_images(CData *cdata) { CompressionMode orig_compression_mode = CM_off; if (cdata->_ram_image_compression != CM_off) { - // The RAM image is compressed. This means we need to uncompress - // it in order to generate mipmap images. Save the original - // first, to avoid lossy recompression. + // The RAM image is compressed. This means we need to uncompress it in + // order to generate mipmap images. Save the original first, to avoid + // lossy recompression. orig_compressed_image = cdata->_ram_images[0]; orig_compression_mode = cdata->_ram_image_compression; @@ -6824,11 +6397,11 @@ do_generate_ram_mipmap_images(CData *cdata) { } if (orig_compression_mode != CM_off) { - // Now attempt to recompress the mipmap images according to the - // original compression mode. We don't need to bother compressing - // the first image (it was already compressed, after all), so - // temporarily remove it from the top of the mipmap stack, and - // compress all of the rest of them instead. + // Now attempt to recompress the mipmap images according to the original + // compression mode. We don't need to bother compressing the first image + // (it was already compressed, after all), so temporarily remove it from + // the top of the mipmap stack, and compress all of the rest of them + // instead. nassertv(cdata->_ram_images.size() > 1); int l0_x_size = cdata->_x_size; int l0_y_size = cdata->_y_size; @@ -6852,11 +6425,9 @@ do_generate_ram_mipmap_images(CData *cdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_set_pad_size -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture:: do_set_pad_size(CData *cdata, int x, int y, int z) { if (x > cdata->_x_size) { @@ -6874,25 +6445,19 @@ do_set_pad_size(CData *cdata, int x, int y, int z) { cdata->_pad_z_size = z; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_can_reload -// Access: Protected, Virtual -// Description: Returns true if we can safely call -// do_reload_ram_image() in order to make the image -// available, or false if we shouldn't do this (because -// we know from a priori knowledge that it wouldn't work -// anyway). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we can safely call do_reload_ram_image() in order to make + * the image available, or false if we shouldn't do this (because we know from + * a priori knowledge that it wouldn't work anyway). + */ bool Texture:: do_can_reload(const CData *cdata) const { return (cdata->_loaded_from_image && !cdata->_fullpath.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_reload -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool Texture:: do_reload(CData *cdata) { if (do_can_reload(cdata)) { @@ -6910,37 +6475,29 @@ do_reload(CData *cdata) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_has_bam_rawdata -// Access: Protected, Virtual -// Description: Returns true if there is a rawdata image that we have -// available to write to the bam stream. For a normal -// Texture, this is the same thing as -// do_has_ram_image(), but a movie texture might define -// it differently. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a rawdata image that we have available to write to + * the bam stream. For a normal Texture, this is the same thing as + * do_has_ram_image(), but a movie texture might define it differently. + */ bool Texture:: do_has_bam_rawdata(const CData *cdata) const { return do_has_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_get_bam_rawdata -// Access: Protected, Virtual -// Description: If do_has_bam_rawdata() returned false, this attempts -// to reload the rawdata image if possible. -//////////////////////////////////////////////////////////////////// +/** + * If do_has_bam_rawdata() returned false, this attempts to reload the rawdata + * image if possible. + */ void Texture:: do_get_bam_rawdata(CData *cdata) { do_get_ram_image(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::convert_from_pnmimage -// Access: Private, Static -// Description: Internal method to convert pixel data from the -// indicated PNMImage into the given ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to convert pixel data from the indicated PNMImage into the + * given ram_image. + */ void Texture:: convert_from_pnmimage(PTA_uchar &image, size_t page_size, int row_stride, int x, int y, int z, @@ -6972,8 +6529,8 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } if (maxval == 255 && component_width == 1) { - // Most common case: one byte per pixel, and the source image - // shows a maxval of 255. No scaling is necessary. + // Most common case: one byte per pixel, and the source image shows a + // maxval of 255. No scaling is necessary. for (int j = y_size-1; j >= 0; j--) { for (int i = 0; i < x_size; i++) { if (is_grayscale) { @@ -6995,8 +6552,8 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } else if (maxval == 65535 && component_width == 2) { - // Another possible case: two bytes per pixel, and the source - // image shows a maxval of 65535. Again, no scaling is necessary. + // Another possible case: two bytes per pixel, and the source image shows + // a maxval of 65535. Again, no scaling is necessary. for (int j = y_size-1; j >= 0; j--) { for (int i = 0; i < x_size; i++) { if (is_grayscale) { @@ -7018,9 +6575,9 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } else if (component_width == 1) { - // A less common case: one byte per pixel, but the maxval is - // something other than 255. In this case, we should scale the - // pixel values up to the appropriate amount. + // A less common case: one byte per pixel, but the maxval is something + // other than 255. In this case, we should scale the pixel values up to + // the appropriate amount. double scale = 255.0 / (double)maxval; for (int j = y_size-1; j >= 0; j--) { @@ -7044,9 +6601,8 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } else { // component_width == 2 - // Another uncommon case: two bytes per pixel, and the maxval is - // something other than 65535. Again, we must scale the pixel - // values. + // Another uncommon case: two bytes per pixel, and the maxval is something + // other than 65535. Again, we must scale the pixel values. double scale = 65535.0 / (double)maxval; for (int j = y_size-1; j >= 0; j--) { @@ -7071,12 +6627,10 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::convert_from_pfm -// Access: Private, Static -// Description: Internal method to convert pixel data from the -// indicated PfmFile into the given ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to convert pixel data from the indicated PfmFile into the + * given ram_image. + */ void Texture:: convert_from_pfm(PTA_uchar &image, size_t page_size, int z, const PfmFile &pfm, int num_components, int component_width) { @@ -7148,12 +6702,10 @@ convert_from_pfm(PTA_uchar &image, size_t page_size, int z, nassertv((unsigned char *)p == &image[idx] + page_size); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::convert_to_pnmimage -// Access: Private, Static -// Description: Internal method to convert pixel data to the -// indicated PNMImage from the given ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to convert pixel data to the indicated PNMImage from the + * given ram_image. + */ bool Texture:: convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, int num_components, int component_width, @@ -7210,12 +6762,10 @@ convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::convert_to_pfm -// Access: Private, Static -// Description: Internal method to convert pixel data to the -// indicated PfmFile from the given ram_image. -//////////////////////////////////////////////////////////////////// +/** + * Internal method to convert pixel data to the indicated PfmFile from the + * given ram_image. + */ bool Texture:: convert_to_pfm(PfmFile &pfm, int x_size, int y_size, int num_components, int component_width, @@ -7280,11 +6830,9 @@ convert_to_pfm(PfmFile &pfm, int x_size, int y_size, return true; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bgr8 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in BGR8 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in BGR8 format. + */ PTA_uchar Texture:: read_dds_level_bgr8(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is in order B, G, R. @@ -7303,11 +6851,9 @@ read_dds_level_bgr8(Texture *tex, CData *cdata, const DDSHeader &header, int n, return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_rgb8 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in RGB8 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in RGB8 format. + */ PTA_uchar Texture:: read_dds_level_rgb8(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is in order R, G, B. @@ -7335,11 +6881,9 @@ read_dds_level_rgb8(Texture *tex, CData *cdata, const DDSHeader &header, int n, return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_abgr8 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in ABGR8 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in ABGR8 format. + */ PTA_uchar Texture:: read_dds_level_abgr8(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is laid out in order R, G, B, A. @@ -7372,11 +6916,9 @@ read_dds_level_abgr8(Texture *tex, CData *cdata, const DDSHeader &header, int n, return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_rgba8 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in RGBA8 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in RGBA8 format. + */ PTA_uchar Texture:: read_dds_level_rgba8(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is actually laid out in order B, G, R, A. @@ -7395,11 +6937,9 @@ read_dds_level_rgba8(Texture *tex, CData *cdata, const DDSHeader &header, int n, return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_abgr16 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in ABGR16 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in ABGR16 format. + */ PTA_uchar Texture:: read_dds_level_abgr16(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is laid out in order R, G, B, A. @@ -7424,11 +6964,9 @@ read_dds_level_abgr16(Texture *tex, CData *cdata, const DDSHeader &header, int n return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_abgr32 -// Access: Private, Static -// Description: Called by read_dds for a DDS file in ABGR32 format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in ABGR32 format. + */ PTA_uchar Texture:: read_dds_level_abgr32(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { // This is laid out in order R, G, B, A. @@ -7453,12 +6991,10 @@ read_dds_level_abgr32(Texture *tex, CData *cdata, const DDSHeader &header, int n return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_generic_uncompressed -// Access: Private, Static -// Description: Called by read_dds for a DDS file whose format isn't -// one we've specifically optimized. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file whose format isn't one we've specifically + * optimized. + */ PTA_uchar Texture:: read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { @@ -7467,11 +7003,10 @@ read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader int pitch = (x_size * header.pf.rgb_bitcount) / 8; - // MS says the pitch can be supplied in the header file and must be - // DWORD aligned, but this appears to apply to level 0 mipmaps only - // (where it almost always will be anyway). Other mipmap levels - // seem to be tightly packed, but there isn't a separate pitch for - // each mipmap level. Weird. + // MS says the pitch can be supplied in the header file and must be DWORD + // aligned, but this appears to apply to level 0 mipmaps only (where it + // almost always will be anyway). Other mipmap levels seem to be tightly + // packed, but there isn't a separate pitch for each mipmap level. Weird. if (n == 0) { pitch = ((pitch + 3) / 4) * 4; if (header.dds_flags & DDSD_PITCH) { @@ -7488,15 +7023,15 @@ read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader unsigned int b_mask = header.pf.b_mask; unsigned int a_mask = header.pf.a_mask; - // Determine the number of bits to shift each mask to the right so - // that the lowest on bit is at bit 0. + // Determine the number of bits to shift each mask to the right so that the + // lowest on bit is at bit 0. int r_shift = get_lowest_on_bit(r_mask); int g_shift = get_lowest_on_bit(g_mask); int b_shift = get_lowest_on_bit(b_mask); int a_shift = get_lowest_on_bit(a_mask); - // Then determine the scale factor required to raise the highest - // color value to 0xff000000. + // Then determine the scale factor required to raise the highest color value + // to 0xff000000. unsigned int r_scale = 0; if (r_mask != 0) { r_scale = 0xff000000 / (r_mask >> r_shift); @@ -7532,8 +7067,7 @@ read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader shift += 8; } - // Then break apart that value into its R, G, B, and maybe A - // components. + // Then break apart that value into its R, G, B, and maybe A components. unsigned int r = (((pixel & r_mask) >> r_shift) * r_scale) >> 24; unsigned int g = (((pixel & g_mask) >> g_shift) * g_scale) >> 24; unsigned int b = (((pixel & b_mask) >> b_shift) * b_scale) >> 24; @@ -7556,12 +7090,10 @@ read_dds_level_generic_uncompressed(Texture *tex, CData *cdata, const DDSHeader return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_luminance_uncompressed -// Access: Private, Static -// Description: Called by read_dds for a DDS file in uncompressed -// luminance or luminance-alpha format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for a DDS file in uncompressed luminance or luminance- + * alpha format. + */ PTA_uchar Texture:: read_dds_level_luminance_uncompressed(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { @@ -7570,11 +7102,10 @@ read_dds_level_luminance_uncompressed(Texture *tex, CData *cdata, const DDSHeade int pitch = (x_size * header.pf.rgb_bitcount) / 8; - // MS says the pitch can be supplied in the header file and must be - // DWORD aligned, but this appears to apply to level 0 mipmaps only - // (where it almost always will be anyway). Other mipmap levels - // seem to be tightly packed, but there isn't a separate pitch for - // each mipmap level. Weird. + // MS says the pitch can be supplied in the header file and must be DWORD + // aligned, but this appears to apply to level 0 mipmaps only (where it + // almost always will be anyway). Other mipmap levels seem to be tightly + // packed, but there isn't a separate pitch for each mipmap level. Weird. if (n == 0) { pitch = ((pitch + 3) / 4) * 4; if (header.dds_flags & DDSD_PITCH) { @@ -7589,13 +7120,13 @@ read_dds_level_luminance_uncompressed(Texture *tex, CData *cdata, const DDSHeade unsigned int r_mask = header.pf.r_mask; unsigned int a_mask = header.pf.a_mask; - // Determine the number of bits to shift each mask to the right so - // that the lowest on bit is at bit 0. + // Determine the number of bits to shift each mask to the right so that the + // lowest on bit is at bit 0. int r_shift = get_lowest_on_bit(r_mask); int a_shift = get_lowest_on_bit(a_mask); - // Then determine the scale factor required to raise the highest - // color value to 0xff000000. + // Then determine the scale factor required to raise the highest color value + // to 0xff000000. unsigned int r_scale = 0; if (r_mask != 0) { r_scale = 0xff000000 / (r_mask >> r_shift); @@ -7641,11 +7172,9 @@ read_dds_level_luminance_uncompressed(Texture *tex, CData *cdata, const DDSHeade return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bc1 -// Access: Private, Static -// Description: Called by read_dds for DXT1 file format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for DXT1 file format. + */ PTA_uchar Texture:: read_dds_level_bc1(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { int x_size = tex->do_get_expected_mipmap_x_size(cdata, n); @@ -7654,8 +7183,8 @@ read_dds_level_bc1(Texture *tex, CData *cdata, const DDSHeader &header, int n, i static const int div = 4; static const int block_bytes = 8; - // The DXT1 image is divided into num_rows x num_cols blocks, where - // each block represents 4x4 pixels. + // The DXT1 image is divided into num_rows x num_cols blocks, where each + // block represents 4x4 pixels. int num_cols = max(div, x_size) / div; int num_rows = max(div, y_size) / div; int row_length = num_cols * block_bytes; @@ -7670,16 +7199,16 @@ read_dds_level_bc1(Texture *tex, CData *cdata, const DDSHeader &header, int n, i PTA_uchar image = PTA_uchar::empty_array(linear_size); if (y_size >= 4) { - // We have to flip the image as we read it, because of DirectX's - // inverted sense of up. That means we (a) reverse the order of the - // rows of blocks . . . + // We have to flip the image as we read it, because of DirectX's inverted + // sense of up. That means we (a) reverse the order of the rows of blocks + // . . . for (int ri = num_rows - 1; ri >= 0; --ri) { unsigned char *p = image.p() + row_length * ri; in.read((char *)p, row_length); for (int ci = 0; ci < num_cols; ++ci) { - // . . . and (b) within each block, we reverse the 4 individual - // rows of 4 pixels. + // . . . and (b) within each block, we reverse the 4 individual rows + // of 4 pixels. PN_uint32 *cells = (PN_uint32 *)p; PN_uint32 w = cells[1]; w = ((w & 0xff) << 24) | ((w & 0xff00) << 8) | ((w & 0xff0000) >> 8) | ((w & 0xff000000U) >> 24); @@ -7712,11 +7241,9 @@ read_dds_level_bc1(Texture *tex, CData *cdata, const DDSHeader &header, int n, i return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bc2 -// Access: Private, Static -// Description: Called by read_dds for DXT2 or DXT3 file format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for DXT2 or DXT3 file format. + */ PTA_uchar Texture:: read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { int x_size = tex->do_get_expected_mipmap_x_size(cdata, n); @@ -7725,10 +7252,9 @@ read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, int n, i static const int div = 4; static const int block_bytes = 16; - // The DXT3 image is divided into num_rows x num_cols blocks, where - // each block represents 4x4 pixels. Unlike DXT1, each block - // consists of two 8-byte chunks, representing the alpha and color - // separately. + // The DXT3 image is divided into num_rows x num_cols blocks, where each + // block represents 4x4 pixels. Unlike DXT1, each block consists of two + // 8-byte chunks, representing the alpha and color separately. int num_cols = max(div, x_size) / div; int num_rows = max(div, y_size) / div; int row_length = num_cols * block_bytes; @@ -7743,16 +7269,16 @@ read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, int n, i PTA_uchar image = PTA_uchar::empty_array(linear_size); if (y_size >= 4) { - // We have to flip the image as we read it, because of DirectX's - // inverted sense of up. That means we (a) reverse the order of the - // rows of blocks . . . + // We have to flip the image as we read it, because of DirectX's inverted + // sense of up. That means we (a) reverse the order of the rows of blocks + // . . . for (int ri = num_rows - 1; ri >= 0; --ri) { unsigned char *p = image.p() + row_length * ri; in.read((char *)p, row_length); for (int ci = 0; ci < num_cols; ++ci) { - // . . . and (b) within each block, we reverse the 4 individual - // rows of 4 pixels. + // . . . and (b) within each block, we reverse the 4 individual rows + // of 4 pixels. PN_uint32 *cells = (PN_uint32 *)p; // Alpha. The block is four 16-bit words of pixel data. @@ -7763,8 +7289,8 @@ read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, int n, i cells[0] = w1; cells[1] = w0; - // Color. Only the second 32-bit dword of the color block - // represents the pixel data. + // Color. Only the second 32-bit dword of the color block represents + // the pixel data. PN_uint32 w = cells[3]; w = ((w & 0xff) << 24) | ((w & 0xff00) << 8) | ((w & 0xff0000) >> 8) | ((w & 0xff000000U) >> 24); cells[3] = w; @@ -7801,11 +7327,9 @@ read_dds_level_bc2(Texture *tex, CData *cdata, const DDSHeader &header, int n, i return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bc3 -// Access: Private, Static -// Description: Called by read_dds for DXT4 or DXT5 file format. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for DXT4 or DXT5 file format. + */ PTA_uchar Texture:: read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { int x_size = tex->do_get_expected_mipmap_x_size(cdata, n); @@ -7814,9 +7338,9 @@ read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, int n, i static const int div = 4; static const int block_bytes = 16; - // The DXT5 image is similar to DXT3, in that there each 4x4 block - // of pixels consists of an alpha block and a color block, but the - // layout of the alpha block is different. + // The DXT5 image is similar to DXT3, in that there each 4x4 block of pixels + // consists of an alpha block and a color block, but the layout of the alpha + // block is different. int num_cols = max(div, x_size) / div; int num_rows = max(div, y_size) / div; int row_length = num_cols * block_bytes; @@ -7831,21 +7355,20 @@ read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, int n, i PTA_uchar image = PTA_uchar::empty_array(linear_size); if (y_size >= 4) { - // We have to flip the image as we read it, because of DirectX's - // inverted sense of up. That means we (a) reverse the order of the - // rows of blocks . . . + // We have to flip the image as we read it, because of DirectX's inverted + // sense of up. That means we (a) reverse the order of the rows of blocks + // . . . for (int ri = num_rows - 1; ri >= 0; --ri) { unsigned char *p = image.p() + row_length * ri; in.read((char *)p, row_length); for (int ci = 0; ci < num_cols; ++ci) { - // . . . and (b) within each block, we reverse the 4 individual - // rows of 4 pixels. + // . . . and (b) within each block, we reverse the 4 individual rows + // of 4 pixels. PN_uint32 *cells = (PN_uint32 *)p; - // Alpha. The block is one 16-bit word of reference values, - // followed by six words of pixel values, in 12-bit rows. - // Tricky to invert. + // Alpha. The block is one 16-bit word of reference values, followed + // by six words of pixel values, in 12-bit rows. Tricky to invert. unsigned char p2 = p[2]; unsigned char p3 = p[3]; unsigned char p4 = p[4]; @@ -7860,8 +7383,8 @@ read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, int n, i p[6] = ((p2 & 0xf) << 4) | ((p4 & 0xf0) >> 4); p[7] = ((p3 & 0xf) << 4) | ((p2 & 0xf0) >> 4); - // Color. Only the second 32-bit dword of the color block - // represents the pixel data. + // Color. Only the second 32-bit dword of the color block represents + // the pixel data. PN_uint32 w = cells[3]; w = ((w & 0xff) << 24) | ((w & 0xff00) << 8) | ((w & 0xff0000) >> 8) | ((w & 0xff000000U) >> 24); cells[3] = w; @@ -7906,11 +7429,9 @@ read_dds_level_bc3(Texture *tex, CData *cdata, const DDSHeader &header, int n, i return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bc4 -// Access: Private, Static -// Description: Called by read_dds for ATI1 compression. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for ATI1 compression. + */ PTA_uchar Texture:: read_dds_level_bc4(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { int x_size = tex->do_get_expected_mipmap_x_size(cdata, n); @@ -7919,8 +7440,8 @@ read_dds_level_bc4(Texture *tex, CData *cdata, const DDSHeader &header, int n, i static const int div = 4; static const int block_bytes = 8; - // The ATI1 (BC4) format uses the same compression mechanism as the - // alpha channel of DXT5. + // The ATI1 (BC4) format uses the same compression mechanism as the alpha + // channel of DXT5. int num_cols = max(div, x_size) / div; int num_rows = max(div, y_size) / div; int row_length = num_cols * block_bytes; @@ -7935,18 +7456,18 @@ read_dds_level_bc4(Texture *tex, CData *cdata, const DDSHeader &header, int n, i PTA_uchar image = PTA_uchar::empty_array(linear_size); if (y_size >= 4) { - // We have to flip the image as we read it, because of DirectX's - // inverted sense of up. That means we (a) reverse the order of the - // rows of blocks . . . + // We have to flip the image as we read it, because of DirectX's inverted + // sense of up. That means we (a) reverse the order of the rows of blocks + // . . . for (int ri = num_rows - 1; ri >= 0; --ri) { unsigned char *p = image.p() + row_length * ri; in.read((char *)p, row_length); for (int ci = 0; ci < num_cols; ++ci) { - // . . . and (b) within each block, we reverse the 4 individual - // rows of 4 pixels. - // The block is one 16-bit word of reference values, followed by - // six words of pixel values, in 12-bit rows. Tricky to invert. + // . . . and (b) within each block, we reverse the 4 individual rows + // of 4 pixels. The block is one 16-bit word of reference values, + // followed by six words of pixel values, in 12-bit rows. Tricky to + // invert. unsigned char p2 = p[2]; unsigned char p3 = p[3]; unsigned char p4 = p[4]; @@ -7991,18 +7512,16 @@ read_dds_level_bc4(Texture *tex, CData *cdata, const DDSHeader &header, int n, i return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::read_dds_level_bc5 -// Access: Private, Static -// Description: Called by read_dds for ATI2 compression. -//////////////////////////////////////////////////////////////////// +/** + * Called by read_dds for ATI2 compression. + */ PTA_uchar Texture:: read_dds_level_bc5(Texture *tex, CData *cdata, const DDSHeader &header, int n, istream &in) { int x_size = tex->do_get_expected_mipmap_x_size(cdata, n); int y_size = tex->do_get_expected_mipmap_y_size(cdata, n); - // The ATI2 (BC5) format uses the same compression mechanism as the - // ATI1 (BC4) format, but doubles the channels. + // The ATI2 (BC5) format uses the same compression mechanism as the ATI1 + // (BC4) format, but doubles the channels. int num_cols = max(4, x_size) / 2; int num_rows = max(4, y_size) / 4; int row_length = num_cols * 8; @@ -8017,18 +7536,18 @@ read_dds_level_bc5(Texture *tex, CData *cdata, const DDSHeader &header, int n, i PTA_uchar image = PTA_uchar::empty_array(linear_size); if (y_size >= 4) { - // We have to flip the image as we read it, because of DirectX's - // inverted sense of up. That means we (a) reverse the order of the - // rows of blocks . . . + // We have to flip the image as we read it, because of DirectX's inverted + // sense of up. That means we (a) reverse the order of the rows of blocks + // . . . for (int ri = num_rows - 1; ri >= 0; --ri) { unsigned char *p = image.p() + row_length * ri; in.read((char *)p, row_length); for (int ci = 0; ci < num_cols; ++ci) { - // . . . and (b) within each block, we reverse the 4 individual - // rows of 4 pixels. - // The block is one 16-bit word of reference values, followed by - // six words of pixel values, in 12-bit rows. Tricky to invert. + // . . . and (b) within each block, we reverse the 4 individual rows + // of 4 pixels. The block is one 16-bit word of reference values, + // followed by six words of pixel values, in 12-bit rows. Tricky to + // invert. unsigned char p2 = p[2]; unsigned char p3 = p[3]; unsigned char p4 = p[4]; @@ -8073,15 +7592,12 @@ read_dds_level_bc5(Texture *tex, CData *cdata, const DDSHeader &header, int n, i return image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::clear_prepared -// Access: Private -// Description: Removes the indicated PreparedGraphicsObjects table -// from the Texture's table, without actually releasing -// the texture. This is intended to be called only from -// PreparedGraphicsObjects::release_texture(); it should -// never be called by user code. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PreparedGraphicsObjects table from the Texture's + * table, without actually releasing the texture. This is intended to be + * called only from PreparedGraphicsObjects::release_texture(); it should + * never be called by user code. + */ void Texture:: clear_prepared(int view, PreparedGraphicsObjects *prepared_objects) { PreparedViews::iterator pvi; @@ -8100,17 +7616,15 @@ clear_prepared(int view, PreparedGraphicsObjects *prepared_objects) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::consider_downgrade -// Access: Private, Static -// Description: Reduces the number of channels in the texture, if -// necessary, according to num_channels. -//////////////////////////////////////////////////////////////////// +/** + * Reduces the number of channels in the texture, if necessary, according to + * num_channels. + */ void Texture:: consider_downgrade(PNMImage &pnmimage, int num_channels, const string &name) { if (num_channels != 0 && num_channels < pnmimage.get_num_channels()) { - // One special case: we can't reduce from 3 to 2 components, since - // that would require adding an alpha channel. + // One special case: we can't reduce from 3 to 2 components, since that + // would require adding an alpha channel. if (pnmimage.get_num_channels() == 3 && num_channels == 2) { return; } @@ -8123,13 +7637,11 @@ consider_downgrade(PNMImage &pnmimage, int num_channels, const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::compare_images -// Access: Private, Static -// Description: Called by generate_simple_ram_image(), this compares -// the two PNMImages pixel-by-pixel. If they're similar -// enough (within a given threshold), returns true. -//////////////////////////////////////////////////////////////////// +/** + * Called by generate_simple_ram_image(), this compares the two PNMImages + * pixel-by-pixel. If they're similar enough (within a given threshold), + * returns true. + */ bool Texture:: compare_images(const PNMImage &a, const PNMImage &b) { nassertr(a.get_maxval() == 255 && b.get_maxval() == 255, false); @@ -8151,19 +7663,15 @@ compare_images(const PNMImage &a, const PNMImage &b) { return (average_delta <= simple_image_threshold); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_filter_2d_mipmap_pages -// Access: Private -// Description: Generates the next mipmap level from the previous -// one. If there are multiple pages (e.g. a cube map), -// generates each page independently. -// -// x_size and y_size are the size of the previous level. -// They need not be a power of 2, or even a multiple of -// 2. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Generates the next mipmap level from the previous one. If there are + * multiple pages (e.g. a cube map), generates each page independently. + * + * x_size and y_size are the size of the previous level. They need not be a + * power of 2, or even a multiple of 2. + * + * Assumes the lock is already held. + */ void Texture:: do_filter_2d_mipmap_pages(const CData *cdata, Texture::RamImage &to, const Texture::RamImage &from, @@ -8172,8 +7680,8 @@ do_filter_2d_mipmap_pages(const CData *cdata, Filter2DComponent *filter_alpha; if (is_srgb(cdata->_format)) { - // We currently only support sRGB mipmap generation for - // unsigned byte textures, due to our use of a lookup table. + // We currently only support sRGB mipmap generation for unsigned byte + // textures, due to our use of a lookup table. nassertv(cdata->_component_type == T_unsigned_byte); if (has_sse2_sRGB_encode()) { @@ -8307,19 +7815,15 @@ do_filter_2d_mipmap_pages(const CData *cdata, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_filter_3d_mipmap_level -// Access: Private -// Description: Generates the next mipmap level from the previous -// one, treating all the pages of the level as a single -// 3-d block of pixels. -// -// x_size, y_size, and z_size are the size of the -// previous level. They need not be a power of 2, or -// even a multiple of 2. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Generates the next mipmap level from the previous one, treating all the + * pages of the level as a single 3-d block of pixels. + * + * x_size, y_size, and z_size are the size of the previous level. They need + * not be a power of 2, or even a multiple of 2. + * + * Assumes the lock is already held. + */ void Texture:: do_filter_3d_mipmap_level(const CData *cdata, Texture::RamImage &to, const Texture::RamImage &from, @@ -8328,8 +7832,8 @@ do_filter_3d_mipmap_level(const CData *cdata, Filter3DComponent *filter_alpha; if (is_srgb(cdata->_format)) { - // We currently only support sRGB mipmap generation for - // unsigned byte textures, due to our use of a lookup table. + // We currently only support sRGB mipmap generation for unsigned byte + // textures, due to our use of a lookup table. nassertv(cdata->_component_type == T_unsigned_byte); if (has_sse2_sRGB_encode()) { @@ -8553,13 +8057,10 @@ do_filter_3d_mipmap_level(const CData *cdata, } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_2d_unsigned_byte -// Access: Public, Static -// Description: Averages a 2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2 block of pixel components into a single pixel component, for + * producing the next mipmap level. Increments p and q to the next component. + */ void Texture:: filter_2d_unsigned_byte(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size) { @@ -8572,13 +8073,10 @@ filter_2d_unsigned_byte(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_2d_unsigned_byte_srgb -// Access: Public, Static -// Description: Averages a 2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2 block of pixel components into a single pixel component, for + * producing the next mipmap level. Increments p and q to the next component. + */ void Texture:: filter_2d_unsigned_byte_srgb(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size) { @@ -8592,13 +8090,10 @@ filter_2d_unsigned_byte_srgb(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_2d_unsigned_byte_srgb_sse2 -// Access: Public, Static -// Description: Averages a 2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2 block of pixel components into a single pixel component, for + * producing the next mipmap level. Increments p and q to the next component. + */ void Texture:: filter_2d_unsigned_byte_srgb_sse2(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size) { @@ -8612,13 +8107,10 @@ filter_2d_unsigned_byte_srgb_sse2(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_2d_unsigned_short -// Access: Public, Static -// Description: Averages a 2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2 block of pixel components into a single pixel component, for + * producing the next mipmap level. Increments p and q to the next component. + */ void Texture:: filter_2d_unsigned_short(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size) { @@ -8630,13 +8122,10 @@ filter_2d_unsigned_short(unsigned char *&p, const unsigned char *&q, q += 2; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_2d_float -// Access: Public, Static -// Description: Averages a 2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2 block of pixel components into a single pixel component, for + * producing the next mipmap level. Increments p and q to the next component. + */ void Texture:: filter_2d_float(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size) { @@ -8648,13 +8137,11 @@ filter_2d_float(unsigned char *&p, const unsigned char *&q, q += 4; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_3d_unsigned_byte -// Access: Public, Static -// Description: Averages a 2x2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2x2 block of pixel components into a single pixel component, + * for producing the next mipmap level. Increments p and q to the next + * component. + */ void Texture:: filter_3d_unsigned_byte(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size, size_t page_size) { @@ -8671,13 +8158,11 @@ filter_3d_unsigned_byte(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_3d_unsigned_byte_srgb -// Access: Public, Static -// Description: Averages a 2x2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2x2 block of pixel components into a single pixel component, + * for producing the next mipmap level. Increments p and q to the next + * component. + */ void Texture:: filter_3d_unsigned_byte_srgb(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size, size_t page_size) { @@ -8695,13 +8180,11 @@ filter_3d_unsigned_byte_srgb(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_3d_unsigned_byte_srgb_sse2 -// Access: Public, Static -// Description: Averages a 2x2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2x2 block of pixel components into a single pixel component, + * for producing the next mipmap level. Increments p and q to the next + * component. + */ void Texture:: filter_3d_unsigned_byte_srgb_sse2(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size, size_t page_size) { @@ -8719,13 +8202,11 @@ filter_3d_unsigned_byte_srgb_sse2(unsigned char *&p, const unsigned char *&q, ++q; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_3d_unsigned_short -// Access: Public, Static -// Description: Averages a 2x2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2x2 block of pixel components into a single pixel component, + * for producing the next mipmap level. Increments p and q to the next + * component. + */ void Texture:: filter_3d_unsigned_short(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size, @@ -8742,13 +8223,11 @@ filter_3d_unsigned_short(unsigned char *&p, const unsigned char *&q, q += 2; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::filter_3d_float -// Access: Public, Static -// Description: Averages a 2x2x2 block of pixel components into a -// single pixel component, for producing the next mipmap -// level. Increments p and q to the next component. -//////////////////////////////////////////////////////////////////// +/** + * Averages a 2x2x2 block of pixel components into a single pixel component, + * for producing the next mipmap level. Increments p and q to the next + * component. + */ void Texture:: filter_3d_float(unsigned char *&p, const unsigned char *&q, size_t pixel_size, size_t row_size, size_t page_size) { @@ -8764,18 +8243,15 @@ filter_3d_float(unsigned char *&p, const unsigned char *&q, q += 4; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_squish -// Access: Private -// Description: Invokes the squish library to compress the RAM -// image(s). -//////////////////////////////////////////////////////////////////// +/** + * Invokes the squish library to compress the RAM image(s). + */ bool Texture:: do_squish(CData *cdata, Texture::CompressionMode compression, int squish_flags) { #ifdef HAVE_SQUISH if (!do_has_all_ram_mipmap_images(cdata)) { - // If we're about to compress the RAM image, we should ensure that - // we have all of the mipmap levels first. + // If we're about to compress the RAM image, we should ensure that we have + // all of the mipmap levels first. do_generate_ram_mipmap_images(cdata); } @@ -8858,12 +8334,9 @@ do_squish(CData *cdata, Texture::CompressionMode compression, int squish_flags) #endif // HAVE_SQUISH } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_unsquish -// Access: Private -// Description: Invokes the squish library to uncompress the RAM -// image(s). -//////////////////////////////////////////////////////////////////// +/** + * Invokes the squish library to uncompress the RAM image(s). + */ bool Texture:: do_unsquish(CData *cdata, int squish_flags) { #ifdef HAVE_SQUISH @@ -8939,22 +8412,18 @@ do_unsquish(CData *cdata, int squish_flags) { #endif // HAVE_SQUISH } -//////////////////////////////////////////////////////////////////// -// Function: Texture::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a Texture object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Texture object + */ void Texture:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::write_datagram -// Access: Public, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void Texture:: write_datagram(BamWriter *manager, Datagram &me) { CDWriter cdata(_cycler, false); @@ -8963,64 +8432,54 @@ write_datagram(BamWriter *manager, Datagram &me) { do_write_datagram_header(cdata, manager, me, has_rawdata); do_write_datagram_body(cdata, manager, me); - // If we are also including the texture's image data, then stuff it - // in here. + // If we are also including the texture's image data, then stuff it in here. if (has_rawdata) { do_write_datagram_rawdata(cdata, manager, me); } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void Texture:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in make_from_bam(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_datagram_header -// Access: Protected -// Description: Writes the header part of the texture to the -// Datagram. This is the common part that is shared by -// all Texture subclasses, and contains the filename and -// rawdata flags. This method is not virtual because -// all Texture subclasses must write the same data at -// this step. -// -// This part must be read first before calling -// do_fillin_body() to determine whether to load the -// Texture from the TexturePool or directly from the bam -// stream. -// -// After this call, has_rawdata will be filled with -// either true or false, according to whether we expect -// to write the texture rawdata to the bam stream -// following the texture body. -//////////////////////////////////////////////////////////////////// +/** + * Writes the header part of the texture to the Datagram. This is the common + * part that is shared by all Texture subclasses, and contains the filename + * and rawdata flags. This method is not virtual because all Texture + * subclasses must write the same data at this step. + * + * This part must be read first before calling do_fillin_body() to determine + * whether to load the Texture from the TexturePool or directly from the bam + * stream. + * + * After this call, has_rawdata will be filled with either true or false, + * according to whether we expect to write the texture rawdata to the bam + * stream following the texture body. + */ void Texture:: do_write_datagram_header(CData *cdata, BamWriter *manager, Datagram &me, bool &has_rawdata) { - // Write out the texture's raw pixel data if (a) the current Bam - // Texture Mode requires that, or (b) there's no filename, so the - // file can't be loaded up from disk, but the raw pixel data is - // currently available in RAM. + // Write out the texture's raw pixel data if (a) the current Bam Texture + // Mode requires that, or (b) there's no filename, so the file can't be + // loaded up from disk, but the raw pixel data is currently available in + // RAM. - // Otherwise, we just write out the filename, and assume whoever - // loads the bam file later will have access to the image file on - // disk. + // Otherwise, we just write out the filename, and assume whoever loads the + // bam file later will have access to the image file on disk. BamWriter::BamTextureMode file_texture_mode = manager->get_file_texture_mode(); has_rawdata = (file_texture_mode == BamWriter::BTM_rawdata || (cdata->_filename.empty() && do_has_bam_rawdata(cdata))); @@ -9096,13 +8555,10 @@ do_write_datagram_header(CData *cdata, BamWriter *manager, Datagram &me, bool &h me.add_bool(cdata->_has_read_mipmaps); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_datagram_body -// Access: Protected, Virtual -// Description: Writes the body part of the texture to the -// Datagram. This is generally all of the texture -// parameters except for the header and the rawdata. -//////////////////////////////////////////////////////////////////// +/** + * Writes the body part of the texture to the Datagram. This is generally all + * of the texture parameters except for the header and the rawdata. + */ void Texture:: do_write_datagram_body(CData *cdata, BamWriter *manager, Datagram &me) { cdata->_default_sampler.write_datagram(me); @@ -9134,12 +8590,9 @@ do_write_datagram_body(CData *cdata, BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_write_datagram_rawdata -// Access: Protected, Virtual -// Description: Writes the rawdata part of the texture to the -// Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the rawdata part of the texture to the Datagram. + */ void Texture:: do_write_datagram_rawdata(CData *cdata, BamWriter *manager, Datagram &me) { me.add_uint32(cdata->_x_size); @@ -9162,42 +8615,35 @@ do_write_datagram_rawdata(CData *cdata, BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_from_bam -// Access: Protected, Static -// Description: Factory method to generate a Texture object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Texture object + */ TypedWritable *Texture:: make_from_bam(const FactoryParams ¶ms) { PT(Texture) dummy = new Texture; return dummy->make_this_from_bam(params); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::make_this_from_bam -// Access: Protected, Virtual -// Description: Called by make_from_bam() once the particular -// subclass of Texture is known. This is called on a -// newly-constructed Texture object of the appropriate -// subclass. It will return either the same Texture -// object (e.g. this), or a different Texture object -// loaded via the TexturePool, as appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Called by make_from_bam() once the particular subclass of Texture is known. + * This is called on a newly-constructed Texture object of the appropriate + * subclass. It will return either the same Texture object (e.g. this), or a + * different Texture object loaded via the TexturePool, as appropriate. + */ TypedWritable *Texture:: make_this_from_bam(const FactoryParams ¶ms) { - // The process of making a texture is slightly different than making - // other TypedWritable objects. That is because all creation of - // Textures should be done through calls to TexturePool, which - // ensures that any loads of the same filename refer to the same - // memory. + // The process of making a texture is slightly different than making other + // TypedWritable objects. That is because all creation of Textures should + // be done through calls to TexturePool, which ensures that any loads of the + // same filename refer to the same memory. DatagramIterator scan; BamReader *manager; parse_params(params, scan, manager); - // Get the header information--the filenames and texture type--so we - // can look up the file on disk first. + // Get the header information--the filenames and texture type--so we can + // look up the file on disk first. string name = scan.get_string(); Filename filename = scan.get_string(); Filename alpha_filename = scan.get_string(); @@ -9207,9 +8653,8 @@ make_this_from_bam(const FactoryParams ¶ms) { bool has_rawdata = scan.get_bool(); TextureType texture_type = (TextureType)scan.get_uint8(); if (manager->get_file_minor_ver() < 25) { - // Between Panda3D releases 1.7.2 and 1.8.0 (bam versions 6.24 and - // 6.25), we added TT_2d_texture_array, shifting the definition - // for TT_cube_map. + // Between Panda3D releases 1.7.2 and 1.8.0 (bam versions 6.24 and 6.25), + // we added TT_2d_texture_array, shifting the definition for TT_cube_map. if (texture_type == TT_2d_texture_array) { texture_type = TT_cube_map; } @@ -9221,10 +8666,10 @@ make_this_from_bam(const FactoryParams ¶ms) { Texture *me = NULL; if (has_rawdata) { - // If the raw image data is included, then just load the texture - // directly from the stream, and return it. In this case we - // return the "this" pointer, since it's a newly-created Texture - // object of the appropriate type. + // If the raw image data is included, then just load the texture directly + // from the stream, and return it. In this case we return the "this" + // pointer, since it's a newly-created Texture object of the appropriate + // type. me = this; me->set_name(name); CDWriter cdata_me(me->_cycler, true); @@ -9239,16 +8684,15 @@ make_this_from_bam(const FactoryParams ¶ms) { me->do_fillin_body(cdata_me, scan, manager); me->do_fillin_rawdata(cdata_me, scan, manager); - // To manage the reference count, explicitly ref it now, then - // unref it in the finalize callback. + // To manage the reference count, explicitly ref it now, then unref it in + // the finalize callback. me->ref(); manager->register_finalize(me); } else { - // The raw image data isn't included, so we'll be loading the - // Texture via the TexturePool. In this case we use the "this" - // pointer as a temporary object to read all of the attributes - // from the bam stream. + // The raw image data isn't included, so we'll be loading the Texture via + // the TexturePool. In this case we use the "this" pointer as a temporary + // object to read all of the attributes from the bam stream. Texture *dummy = this; AutoTextureScale auto_texture_scale = ATS_unspecified; { @@ -9258,8 +8702,8 @@ make_this_from_bam(const FactoryParams ¶ms) { } if (filename.empty()) { - // This texture has no filename; since we don't have an image to - // load, we can't actually create the texture. + // This texture has no filename; since we don't have an image to load, + // we can't actually create the texture. gobj_cat.info() << "Cannot create texture '" << name << "' with no filename.\n"; @@ -9267,8 +8711,8 @@ make_this_from_bam(const FactoryParams ¶ms) { // This texture does have a filename, so try to load it from disk. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); if (!manager->get_filename().empty()) { - // If texture filename was given relative to the bam filename, - // expand it now. + // If texture filename was given relative to the bam filename, expand + // it now. Filename bam_dir = manager->get_filename().get_dirname(); vfs->resolve_filename(filename, bam_dir); if (!alpha_filename.empty()) { @@ -9317,21 +8761,19 @@ make_this_from_bam(const FactoryParams ¶ms) { CDWriter cdata_me(me->_cycler, true); me->do_fillin_from(cdata_me, dummy); - // Since in this case me was loaded from the TexturePool, - // there's no need to explicitly manage the reference count. - // TexturePool will hold it safely. + // Since in this case me was loaded from the TexturePool, there's no + // need to explicitly manage the reference count. TexturePool will hold + // it safely. } } return me; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_fillin_body -// Access: Protected, Virtual -// Description: Reads in the part of the Texture that was written -// with do_write_datagram_body(). -//////////////////////////////////////////////////////////////////// +/** + * Reads in the part of the Texture that was written with + * do_write_datagram_body(). + */ void Texture:: do_fillin_body(CData *cdata, DatagramIterator &scan, BamReader *manager) { cdata->_default_sampler.read_datagram(scan, manager); @@ -9380,12 +8822,10 @@ do_fillin_body(CData *cdata, DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_fillin_rawdata -// Access: Protected, Virtual -// Description: Reads in the part of the Texture that was written -// with do_write_datagram_rawdata(). -//////////////////////////////////////////////////////////////////// +/** + * Reads in the part of the Texture that was written with + * do_write_datagram_rawdata(). + */ void Texture:: do_fillin_rawdata(CData *cdata, DatagramIterator &scan, BamReader *manager) { cdata->_x_size = scan.get_uint32(); @@ -9436,22 +8876,18 @@ do_fillin_rawdata(CData *cdata, DatagramIterator &scan, BamReader *manager) { cdata->inc_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::do_fillin_from -// Access: Protected, Virtual -// Description: Called in make_from_bam(), this method properly -// copies the attributes from the bam stream (as stored -// in dummy) into this texture, updating the modified -// flags appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Called in make_from_bam(), this method properly copies the attributes from + * the bam stream (as stored in dummy) into this texture, updating the + * modified flags appropriately. + */ void Texture:: do_fillin_from(CData *cdata, const Texture *dummy) { - // Use the setters instead of setting these directly, so we can - // correctly avoid incrementing cdata->_properties_modified if none of - // these actually change. (Otherwise, we'd have to reload the - // texture to the GSG every time we loaded a new bam file that - // reference the texture, since each bam file reference passes - // through this function.) + // Use the setters instead of setting these directly, so we can correctly + // avoid incrementing cdata->_properties_modified if none of these actually + // change. (Otherwise, we'd have to reload the texture to the GSG every + // time we loaded a new bam file that reference the texture, since each bam + // file reference passes through this function.) CDReader cdata_dummy(dummy->_cycler); @@ -9480,16 +8916,15 @@ do_fillin_from(CData *cdata, const Texture *dummy) { int num_components = cdata_dummy->_num_components; if (num_components == cdata->_num_components) { - // Only reset the format if the number of components hasn't - // changed, since if the number of components has changed our - // texture no longer matches what it was when the bam was - // written. + // Only reset the format if the number of components hasn't changed, since + // if the number of components has changed our texture no longer matches + // what it was when the bam was written. do_set_format(cdata, format); } if (!cdata_dummy->_simple_ram_image._image.empty()) { - // Only replace the simple ram image if it was generated more - // recently than the one we already have. + // Only replace the simple ram image if it was generated more recently + // than the one we already have. if (cdata->_simple_ram_image._image.empty() || cdata_dummy->_simple_image_date_generated > cdata->_simple_image_date_generated) { do_set_simple_ram_image(cdata, @@ -9501,11 +8936,9 @@ do_fillin_from(CData *cdata, const Texture *dummy) { } } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture::CData:: CData() { _primary_file_num_channels = 0; @@ -9525,9 +8958,9 @@ CData() { _z_size = 1; _num_views = 1; - // We will override the format in a moment (in the Texture - // constructor), but set it to something else first to avoid the - // check in do_set_format depending on an uninitialized value. + // We will override the format in a moment (in the Texture constructor), but + // set it to something else first to avoid the check in do_set_format + // depending on an uninitialized value. _format = F_rgba; // Only used for buffer textures. @@ -9553,11 +8986,9 @@ CData() { _has_clear_color = false; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture::CData:: CData(const Texture::CData ©) { _num_mipmap_levels_read = 0; @@ -9569,28 +9000,24 @@ CData(const Texture::CData ©) { _simple_image_modified = copy._simple_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Texture::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::do_assign -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Texture::CData:: do_assign(const Texture::CData *copy) { _filename = copy->_filename; _alpha_filename = copy->_alpha_filename; if (!copy->_fullpath.empty()) { - // Since the fullpath is often empty on a file loaded directly - // from a txo, we only assign the fullpath if it is not empty. + // Since the fullpath is often empty on a file loaded directly from a txo, + // we only assign the fullpath if it is not empty. _fullpath = copy->_fullpath; _alpha_fullpath = copy->_alpha_fullpath; } @@ -9628,88 +9055,74 @@ do_assign(const Texture::CData *copy) { _simple_ram_image = copy->_simple_ram_image; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Texture::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int Texture::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Geom. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Geom. + */ void Texture::CData:: fillin(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: Texture::TextureType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, Texture::TextureType tt) { return out << Texture::format_texture_type(tt); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::ComponentType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, Texture::ComponentType ct) { return out << Texture::format_component_type(ct); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::Format output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, Texture::Format f) { return out << Texture::format_format(f); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::CompressionMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, Texture::CompressionMode cm) { return out << Texture::format_compression_mode(cm); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::QualityLevel output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, Texture::QualityLevel tql) { return out << Texture::format_quality_level(tql); } -//////////////////////////////////////////////////////////////////// -// Function: Texture::QualityLevel input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, Texture::QualityLevel &tql) { string word; diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index a8a9afb1ba..fa64b0fa42 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -1,17 +1,17 @@ -// Filename: texture.h -// Created by: mike (09Jan97) -// Updated by: fperazzi, PandaSE(29Apr10) (added TT_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texture.h + * @author mike + * @date 1997-01-09 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #ifndef TEXTURE_H #define TEXTURE_H @@ -55,24 +55,19 @@ class CullTraverserData; class TexturePeeker; struct DDSHeader; -//////////////////////////////////////////////////////////////////// -// Class : Texture -// Description : Represents a texture object, which is typically a -// single 2-d image but may also represent a 1-d or 3-d -// texture image, or the six 2-d faces of a cube map -// texture. -// -// A texture's image data might be stored in system RAM -// (see get_ram_image()) or its image may be represented -// in texture memory on one or more -// GraphicsStateGuardians (see prepare()), or both. The -// typical usage pattern is that a texture is loaded -// from an image file on disk, which copies its image -// data into system RAM; then the first time the texture -// is rendered its image data is copied to texture -// memory (actually, to the graphics API), and the -// system RAM image is automatically freed. -//////////////////////////////////////////////////////////////////// +/** + * Represents a texture object, which is typically a single 2-d image but may + * also represent a 1-d or 3-d texture image, or the six 2-d faces of a cube + * map texture. + * + * A texture's image data might be stored in system RAM (see get_ram_image()) + * or its image may be represented in texture memory on one or more + * GraphicsStateGuardians (see prepare()), or both. The typical usage pattern + * is that a texture is loaded from an image file on disk, which copies its + * image data into system RAM; then the first time the texture is rendered its + * image data is copied to texture memory (actually, to the graphics API), and + * the system RAM image is automatically freed. + */ class EXPCL_PANDA_GOBJ Texture : public TypedWritableReferenceCount, public Namable { PUBLISHED: typedef PT(Texture) MakeTextureFunc(); @@ -108,10 +103,9 @@ PUBLISHED: F_rgb, // any suitable RGB mode, whatever the hardware prefers // The following request a particular number of bits for the GSG's - // internal_format (as stored in the framebuffer), but this - // request is not related to the pixel storage within the Texture - // object itself, which is always get_num_components() * - // get_component_width(). + // internal_format (as stored in the framebuffer), but this request is not + // related to the pixel storage within the Texture object itself, which is + // always get_num_components() * get_component_width(). F_rgb5, // 5 bits per R,G,B channel F_rgb8, // 8 bits per R,G,B channel F_rgb12, // 12 bits per R,G,B channel @@ -119,8 +113,8 @@ PUBLISHED: F_rgba, // any suitable RGBA mode, whatever the hardware prefers - // Again, the following bitdepth requests are only for the GSG; - // within the Texture object itself, these are all equivalent. + // Again, the following bitdepth requests are only for the GSG; within the + // Texture object itself, these are all equivalent. F_rgbm, // as above, but only requires 1 bit for alpha (i.e. mask) F_rgba4, // 4 bits per R,G,B,A channel F_rgba5, // 5 bits per R,G,B channel, 1 bit alpha @@ -143,8 +137,8 @@ PUBLISHED: F_rg16, F_rgb16, - // These formats are in the sRGB color space. - // RGB is 2.2 gamma corrected, alpha is always linear. + // These formats are in the sRGB color space. RGB is 2.2 gamma corrected, + // alpha is always linear. F_srgb, F_srgb_alpha, F_sluminance, @@ -193,17 +187,16 @@ PUBLISHED: typedef SamplerState::WrapMode WrapMode; enum CompressionMode { - // Generic compression modes. Usually, you should choose one of - // these. + // Generic compression modes. Usually, you should choose one of these. CM_default, // on or off, according to compressed-textures CM_off, // uncompressed image CM_on, // whatever compression the driver supports - // Specific compression modes. Use only when you really want to - // use a particular compression algorithm. Use with caution; not - // all drivers support all compression modes. You can use - // GSG::get_supports_compressed_texture_format() to query the - // available compression modes for a particular GSG. + // Specific compression modes. Use only when you really want to use a + // particular compression algorithm. Use with caution; not all drivers + // support all compression modes. You can use + // GSG::get_supports_compressed_texture_format() to query the available + // compression modes for a particular GSG. CM_fxt1, CM_dxt1, // BC1: RGB with optional binary alpha. CM_dxt2, // Like DXT3, but assumes premultiplied alpha @@ -477,9 +470,8 @@ PUBLISHED: INLINE static bool has_textures_power_2(); PUBLISHED: - // These are published, but in general, you shouldn't be mucking - // with these values; they are set automatically when a texture is - // loaded. + // These are published, but in general, you shouldn't be mucking with these + // values; they are set automatically when a texture is loaded. INLINE void set_filename(const Filename &filename); INLINE void clear_filename(); INLINE void set_alpha_filename(const Filename &alpha_filename); @@ -578,13 +570,12 @@ protected: virtual void reconsider_dirty(); // All of the functions in this class that begin "do_" are protected - // methods. Many of them are implementations of public-facing - // versions of the same methods. + // methods. Many of them are implementations of public-facing versions of + // the same methods. - // All of these assume the CData lock is already held (and receive a - // CData pointer representing that lock); generally, they also avoid - // adjusting the _properties_modified and _image_modified - // semaphores. + // All of these assume the CData lock is already held (and receive a CData + // pointer representing that lock); generally, they also avoid adjusting the + // _properties_modified and _image_modified semaphores. virtual bool do_adjust_this_size(const CData *cdata, int &x_size, int &y_size, const string &name, bool for_padding) const; @@ -724,8 +715,8 @@ protected: PTA_uchar _image; size_t _page_size; - // If _pointer_image is non-NULL, it represents an external block - // of memory that is used instead of the above PTA_uchar. + // If _pointer_image is non-NULL, it represents an external block of + // memory that is used instead of the above PTA_uchar. void *_pointer_image; }; @@ -879,10 +870,9 @@ protected: // The number of channels of the primary file we use. 1, 2, 3, or 4. int _primary_file_num_channels; - // If we have a separate alpha file, this designates which channel - // in the alpha file provides the alpha channel. 0 indicates the - // combined grayscale value of rgb; otherwise, 1, 2, 3, or 4 are - // valid. + // If we have a separate alpha file, this designates which channel in the + // alpha file provides the alpha channel. 0 indicates the combined + // grayscale value of rgb; otherwise, 1, 2, 3, or 4 are valid. int _alpha_file_channel; int _x_size; @@ -921,13 +911,13 @@ protected: AutoTextureScale _auto_texture_scale; CompressionMode _ram_image_compression; - // There is usually one RamImage for the mipmap level 0 (the base - // image). There may or may not also be additional images for the - // additional mipmap levels. + // There is usually one RamImage for the mipmap level 0 (the base image). + // There may or may not also be additional images for the additional + // mipmap levels. RamImages _ram_images; - // This is the simple image, which may be loaded before the texture - // is loaded from disk. It exists only for 2-d textures. + // This is the simple image, which may be loaded before the texture is + // loaded from disk. It exists only for 2-d textures. RamImage _simple_ram_image; int _simple_x_size; int _simple_y_size; @@ -968,19 +958,19 @@ protected: bool _reloading; // A Texture keeps a list (actually, a map) of all the - // PreparedGraphicsObjects tables that it has been prepared into. - // Each PGO conversely keeps a list (a set) of all the Textures that - // have been prepared there. When either destructs, it removes - // itself from the other's list. + // PreparedGraphicsObjects tables that it has been prepared into. Each PGO + // conversely keeps a list (a set) of all the Textures that have been + // prepared there. When either destructs, it removes itself from the + // other's list. typedef pmap Contexts; typedef pmap PreparedViews; PreparedViews _prepared_views; - // It is common, when using normal maps, specular maps, gloss maps, - // and such, to use a file naming convention where the filenames - // of the special maps are derived by concatenating a suffix to - // the name of the diffuse map. The following table enables - // lookup of the special maps given the diffuse map and the suffix. + // It is common, when using normal maps, specular maps, gloss maps, and + // such, to use a file naming convention where the filenames of the special + // maps are derived by concatenating a suffix to the name of the diffuse + // map. The following table enables lookup of the special maps given the + // diffuse map and the suffix. typedef pmap RelatedTextures; RelatedTextures _related_textures; diff --git a/panda/src/gobj/textureCollection.I b/panda/src/gobj/textureCollection.I index 9aacc5d573..14a06486f6 100644 --- a/panda/src/gobj/textureCollection.I +++ b/panda/src/gobj/textureCollection.I @@ -1,43 +1,35 @@ -// Filename: textureCollection.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureCollection.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextureCollection:: ~TextureCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void TextureCollection:: operator += (const TextureCollection &other) { add_textures_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::operator + -// Access: Published -// Description: Returns a TextureCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a TextureCollection representing the concatenation of the two + * lists. + */ INLINE TextureCollection TextureCollection:: operator + (const TextureCollection &other) const { TextureCollection a(*this); @@ -45,25 +37,19 @@ operator + (const TextureCollection &other) const { return a; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::append -// Access: Published -// Description: Adds a new Texture to the collection. This method -// duplicates the add_texture() method; it is provided to -// satisfy Python's naming convention. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Texture to the collection. This method duplicates the + * add_texture() method; it is provided to satisfy Python's naming convention. + */ void TextureCollection:: append(Texture *texture) { add_texture(texture); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::extend -// Access: Published -// Description: Appends the other list onto the end of this one. -// This method duplicates the += operator; it is -// provided to satisfy Python's naming convention. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. This method duplicates + * the += operator; it is provided to satisfy Python's naming convention. + */ INLINE void TextureCollection:: extend(const TextureCollection &other) { operator += (other); diff --git a/panda/src/gobj/textureCollection.cxx b/panda/src/gobj/textureCollection.cxx index 9a87c6260c..ce2eee4519 100644 --- a/panda/src/gobj/textureCollection.cxx +++ b/panda/src/gobj/textureCollection.cxx @@ -1,61 +1,51 @@ -// Filename: textureCollection.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureCollection.cxx + * @author drose + * @date 2002-03-16 + */ #include "textureCollection.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureCollection:: TextureCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureCollection:: TextureCollection(const TextureCollection ©) : _textures(copy._textures) { } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureCollection:: operator = (const TextureCollection ©) { _textures = copy._textures; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::add_texture -// Access: Published -// Description: Adds a new Texture to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Texture to the collection. + */ void TextureCollection:: add_texture(Texture *texture) { // If the pointer to our internal array is shared by any other // TextureCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren TextureCollection - // objects. + // inadvertently modify any of our brethren TextureCollection objects. if (_textures.get_ref_count() > 1) { Textures old_textures = _textures; @@ -66,13 +56,10 @@ add_texture(Texture *texture) { _textures.push_back(texture); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::remove_texture -// Access: Published -// Description: Removes the indicated Texture from the collection. -// Returns true if the texture was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated Texture from the collection. Returns true if the + * texture was removed, false if it was not a member of the collection. + */ bool TextureCollection:: remove_texture(Texture *texture) { int texture_index = -1; @@ -89,8 +76,7 @@ remove_texture(Texture *texture) { // If the pointer to our internal array is shared by any other // TextureCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren TextureCollection - // objects. + // inadvertently modify any of our brethren TextureCollection objects. if (_textures.get_ref_count() > 1) { Textures old_textures = _textures; @@ -102,14 +88,11 @@ remove_texture(Texture *texture) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::add_textures_from -// Access: Published -// Description: Adds all the Textures indicated in the other -// collection to this texture. The other textures are simply -// appended to the end of the textures in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the Textures indicated in the other collection to this texture. + * The other textures are simply appended to the end of the textures in this + * list; duplicates are not automatically removed. + */ void TextureCollection:: add_textures_from(const TextureCollection &other) { int other_num_textures = other.get_num_textures(); @@ -119,12 +102,10 @@ add_textures_from(const TextureCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::remove_textures_from -// Access: Published -// Description: Removes from this collection all of the Textures -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the Textures listed in the other + * collection. + */ void TextureCollection:: remove_textures_from(const TextureCollection &other) { Textures new_textures; @@ -138,14 +119,11 @@ remove_textures_from(const TextureCollection &other) { _textures = new_textures; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::remove_duplicate_textures -// Access: Published -// Description: Removes any duplicate entries of the same Textures -// on this collection. If a Texture appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same Textures on this collection. If + * a Texture appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void TextureCollection:: remove_duplicate_textures() { Textures new_textures; @@ -167,12 +145,10 @@ remove_duplicate_textures() { _textures = new_textures; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::has_texture -// Access: Published -// Description: Returns true if the indicated Texture appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated Texture appears in this collection, false + * otherwise. + */ bool TextureCollection:: has_texture(Texture *texture) const { for (int i = 0; i < get_num_textures(); i++) { @@ -183,35 +159,27 @@ has_texture(Texture *texture) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::clear -// Access: Published -// Description: Removes all Textures from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all Textures from the collection. + */ void TextureCollection:: clear() { _textures.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::reserve -// Access: Published -// Description: This is a hint to Panda to allocate enough memory -// to hold the given number of NodePaths, if you know -// ahead of time how many you will be adding. -//////////////////////////////////////////////////////////////////// +/** + * This is a hint to Panda to allocate enough memory to hold the given number + * of NodePaths, if you know ahead of time how many you will be adding. + */ void TextureCollection:: reserve(size_t num) { _textures.reserve(num); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::find_texture -// Access: Published -// Description: Returns the texture in the collection with the -// indicated name, if any, or NULL if no texture has -// that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture in the collection with the indicated name, if any, or + * NULL if no texture has that name. + */ Texture *TextureCollection:: find_texture(const string &name) const { int num_textures = get_num_textures(); @@ -224,21 +192,17 @@ find_texture(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::get_num_textures -// Access: Published -// Description: Returns the number of Textures in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of Textures in the collection. + */ int TextureCollection:: get_num_textures() const { return _textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::get_texture -// Access: Published -// Description: Returns the nth Texture in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Texture in the collection. + */ Texture *TextureCollection:: get_texture(int index) const { nassertr(index >= 0 && index < (int)_textures.size(), NULL); @@ -246,13 +210,10 @@ get_texture(int index) const { return _textures[index]; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::operator [] -// Access: Published -// Description: Returns the nth Texture in the collection. This is -// the same as get_texture(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Texture in the collection. This is the same as + * get_texture(), but it may be a more convenient way to access it. + */ Texture *TextureCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_textures.size(), NULL); @@ -260,23 +221,19 @@ operator [] (int index) const { return _textures[index]; } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::size -// Access: Published -// Description: Returns the number of textures in the collection. This -// is the same thing as get_num_textures(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of textures in the collection. This is the same thing + * as get_num_textures(). + */ int TextureCollection:: size() const { return _textures.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// TextureCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the TextureCollection to the + * indicated output stream. + */ void TextureCollection:: output(ostream &out) const { if (get_num_textures() == 1) { @@ -286,12 +243,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// TextureCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the TextureCollection to the + * indicated output stream. + */ void TextureCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_textures(); i++) { diff --git a/panda/src/gobj/textureCollection.h b/panda/src/gobj/textureCollection.h index 9be7b78f88..4cf0872708 100644 --- a/panda/src/gobj/textureCollection.h +++ b/panda/src/gobj/textureCollection.h @@ -1,16 +1,15 @@ -// Filename: textureCollection.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureCollection.h + * @author drose + * @date 2002-03-16 + */ #ifndef TEXTURECOLLECTION_H #define TEXTURECOLLECTION_H @@ -19,11 +18,10 @@ #include "pointerToArray.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureCollection -// Description : Manages a list of Texture objects, as returned by -// TexturePool::find_all_textures(). -//////////////////////////////////////////////////////////////////// +/** + * Manages a list of Texture objects, as returned by + * TexturePool::find_all_textures(). + */ class EXPCL_PANDA_GOBJ TextureCollection { PUBLISHED: TextureCollection(); diff --git a/panda/src/gobj/textureCollection_ext.cxx b/panda/src/gobj/textureCollection_ext.cxx index e90295430b..ea0fbf75c3 100644 --- a/panda/src/gobj/textureCollection_ext.cxx +++ b/panda/src/gobj/textureCollection_ext.cxx @@ -1,16 +1,15 @@ -// Filename: textureCollection_ext.cxx -// Created by: rdb (11Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureCollection_ext.cxx + * @author rdb + * @date 2015-02-11 + */ #include "textureCollection_ext.h" @@ -20,14 +19,11 @@ extern struct Dtool_PyTypedObject Dtool_Texture; #endif -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::__init__ -// Access: Published -// Description: This special constructor accepts a Python list of -// Textures. Since this constructor accepts a generic -// PyObject *, it should be the last constructor listed -// in the class record. -//////////////////////////////////////////////////////////////////// +/** + * This special constructor accepts a Python list of Textures. Since this + * constructor accepts a generic PyObject *, it should be the last constructor + * listed in the class record. + */ void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "TextureCollection constructor requires a sequence"); @@ -62,30 +58,26 @@ __init__(PyObject *self, PyObject *sequence) { Py_DECREF(fast); } -//////////////////////////////////////////////////////////////////// -// Function: TextureCollection::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ PyObject *Extension:: __reduce__(PyObject *self) const { - // Here we will return a 4-tuple: (Class, (args), None, iterator), - // where iterator is an iterator that will yield successive - // Textures. + // Here we will return a 4-tuple: (Class, (args), None, iterator), where + // iterator is an iterator that will yield successive Textures. - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; } - // Since a TextureCollection is itself an iterator, we can simply - // pass it as the fourth tuple component. + // Since a TextureCollection is itself an iterator, we can simply pass it as + // the fourth tuple component. PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self); Py_DECREF(this_class); return result; diff --git a/panda/src/gobj/textureCollection_ext.h b/panda/src/gobj/textureCollection_ext.h index 2818782e6a..cb8315e870 100644 --- a/panda/src/gobj/textureCollection_ext.h +++ b/panda/src/gobj/textureCollection_ext.h @@ -1,16 +1,15 @@ -// Filename: textureCollection_ext.h -// Created by: rdb (11Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureCollection_ext.h + * @author rdb + * @date 2015-02-11 + */ #ifndef TEXTURECOLLECTION_EXT_H #define TEXTURECOLLECTION_EXT_H @@ -23,12 +22,10 @@ #include "textureCollection.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// TextureCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for TextureCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/gobj/textureContext.I b/panda/src/gobj/textureContext.I index d3a857a9f6..b5d3712ad8 100644 --- a/panda/src/gobj/textureContext.I +++ b/panda/src/gobj/textureContext.I @@ -1,23 +1,19 @@ -// Filename: textureContext.I -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureContext.I + * @author drose + * @date 1999-10-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextureContext:: TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : BufferContext(&pgo->_texture_residency), @@ -27,135 +23,104 @@ TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::get_texture -// Access: Public -// Description: Returns the pointer to the associated Texture -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the associated Texture object. + */ INLINE Texture *TextureContext:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::get_view -// Access: Public -// Description: Returns the specific view of a multiview texture this -// context represents. In the usual case, with a -// non-multiview texture, this will be 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specific view of a multiview texture this context represents. + * In the usual case, with a non-multiview texture, this will be 0. + */ INLINE int TextureContext:: get_view() const { return _view; } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::was_modified -// Access: Public -// Description: Returns true if the texture properties or image have -// been modified since the last time mark_loaded() was -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture properties or image have been modified since + * the last time mark_loaded() was called. + */ INLINE bool TextureContext:: was_modified() const { return was_properties_modified() || was_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::was_properties_modified -// Access: Public -// Description: Returns true if the texture properties (unrelated to -// the image) have been modified since the last time -// mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture properties (unrelated to the image) have been + * modified since the last time mark_loaded() was called. + */ INLINE bool TextureContext:: was_properties_modified() const { return _properties_modified != _texture->get_properties_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::was_image_modified -// Access: Public -// Description: Returns true if the texture image has been modified -// since the last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture image has been modified since the last time + * mark_loaded() was called. + */ INLINE bool TextureContext:: was_image_modified() const { return _image_modified != _texture->get_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::was_simple_image_modified -// Access: Public -// Description: Returns true if the texture's "simple" image has been -// modified since the last time mark_simple_loaded() was -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture's "simple" image has been modified since the + * last time mark_simple_loaded() was called. + */ INLINE bool TextureContext:: was_simple_image_modified() const { return _simple_image_modified != _texture->get_simple_image_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::get_properties_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture properties -// (unrelated to the image) are modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture properties (unrelated to the image) are modified. + */ INLINE UpdateSeq TextureContext:: get_properties_modified() const { return _properties_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::get_image_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture image data -// (including mipmap levels) are modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture image data (including mipmap levels) are modified. + */ INLINE UpdateSeq TextureContext:: get_image_modified() const { return _image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::get_simple_image_modified -// Access: Published -// Description: Returns a sequence number which is guaranteed to -// change at least every time the texture's "simple" -// image data is modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number which is guaranteed to change at least every time + * the texture's "simple" image data is modified. + */ INLINE UpdateSeq TextureContext:: get_simple_image_modified() const { return _simple_image_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::update_data_size_bytes -// Access: Public -// Description: Should be called (usually by a derived class) when -// the on-card size of this object has changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (usually by a derived class) when the on-card size of this + * object has changed. + */ INLINE void TextureContext:: update_data_size_bytes(size_t new_data_size_bytes) { BufferContext::update_data_size_bytes(new_data_size_bytes); AdaptiveLruPage::set_lru_size(new_data_size_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::mark_loaded -// Access: Public -// Description: Should be called after the texture has been loaded -// into graphics memory, this updates the internal flags -// for changed_size() and modified(). -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the texture has been loaded into graphics memory, + * this updates the internal flags for changed_size() and modified(). + */ INLINE void TextureContext:: mark_loaded() { - // _data_size_bytes = _data->get_texture_size_bytes(); + // _data_size_bytes = _data->get_texture_size_bytes(); _properties_modified = _texture->get_properties_modified(); _image_modified = _texture->get_image_modified(); update_modified(max(_properties_modified, _image_modified)); @@ -164,12 +129,10 @@ mark_loaded() { set_resident(true); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::mark_simple_loaded -// Access: Public -// Description: Should be called after the texture's "simple" image -// has been loaded into graphics memory. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the texture's "simple" image has been loaded into + * graphics memory. + */ INLINE void TextureContext:: mark_simple_loaded() { _properties_modified = _texture->get_properties_modified(); @@ -180,12 +143,9 @@ mark_simple_loaded() { set_resident(true); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::mark_unloaded -// Access: Public -// Description: Should be called after the texture has been forced -// out of texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the texture has been forced out of texture memory. + */ INLINE void TextureContext:: mark_unloaded() { _properties_modified = UpdateSeq::old(); @@ -196,12 +156,10 @@ mark_unloaded() { set_resident(false); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::mark_needs_reload -// Access: Public -// Description: Should be called to indicate the texture should be -// reloaded at the nearest opportunity. -//////////////////////////////////////////////////////////////////// +/** + * Should be called to indicate the texture should be reloaded at the nearest + * opportunity. + */ INLINE void TextureContext:: mark_needs_reload() { _image_modified = UpdateSeq::old(); diff --git a/panda/src/gobj/textureContext.cxx b/panda/src/gobj/textureContext.cxx index 3efe8c6a7a..b0130bcf24 100644 --- a/panda/src/gobj/textureContext.cxx +++ b/panda/src/gobj/textureContext.cxx @@ -1,36 +1,31 @@ -// Filename: textureContext.cxx -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureContext.cxx + * @author drose + * @date 1999-10-07 + */ #include "textureContext.h" TypeHandle TextureContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureContext:: output(ostream &out) const { out << *get_texture() << ", " << get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureContext::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureContext:: write(ostream &out, int indent_level) const { SavedContext::write(out, indent_level); diff --git a/panda/src/gobj/textureContext.h b/panda/src/gobj/textureContext.h index 660edeff3e..7f5a514c81 100644 --- a/panda/src/gobj/textureContext.h +++ b/panda/src/gobj/textureContext.h @@ -1,16 +1,15 @@ -// Filename: textureContext.h -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureContext.h + * @author drose + * @date 1999-10-07 + */ #ifndef TEXTURECONTEXT_H #define TEXTURECONTEXT_H @@ -22,19 +21,15 @@ #include "preparedGraphicsObjects.h" #include "adaptiveLru.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureContext -// Description : This is a special class object that holds all the -// information returned by a particular GSG to indicate -// the texture's internal context identifier. -// -// Textures typically have an immediate-mode and a -// retained-mode operation. When using textures in -// retained-mode (in response to Texture::prepare()), -// the GSG will create some internal handle for the -// texture and store it here. The texture stores all of -// these handles internally. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class object that holds all the information returned by a + * particular GSG to indicate the texture's internal context identifier. + * + * Textures typically have an immediate-mode and a retained-mode operation. + * When using textures in retained-mode (in response to Texture::prepare()), + * the GSG will create some internal handle for the texture and store it here. + * The texture stores all of these handles internally. + */ class EXPCL_PANDA_GOBJ TextureContext : public BufferContext, public AdaptiveLruPage { public: INLINE TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view); @@ -63,15 +58,14 @@ public: virtual void write(ostream &out, int indent_level) const; private: - // This cannot be a PT(Texture), because the texture and the GSG - // both own their TextureContexts! That would create a circular - // reference count. + // This cannot be a PT(Texture), because the texture and the GSG both own + // their TextureContexts! That would create a circular reference count. Texture *_texture; int _view; UpdateSeq _properties_modified; UpdateSeq _image_modified; UpdateSeq _simple_image_modified; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -100,4 +94,3 @@ inline ostream &operator << (ostream &out, const TextureContext &context) { #include "textureContext.I" #endif - diff --git a/panda/src/gobj/texturePeeker.I b/panda/src/gobj/texturePeeker.I index 4e12e6a61d..39246f70f3 100644 --- a/panda/src/gobj/texturePeeker.I +++ b/panda/src/gobj/texturePeeker.I @@ -1,64 +1,50 @@ -// Filename: texturePeeker.I -// Created by: drose (26Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePeeker.I + * @author drose + * @date 2008-08-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::is_valid -// Access: Public -// Description: Returns true if the TexturePeeker was able to -// initialize itself and is ready to return texel -// colors. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TexturePeeker was able to initialize itself and is + * ready to return texel colors. + */ INLINE bool TexturePeeker:: is_valid() const { return !_image.is_null(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_x_size -// Access: Published -// Description: Returns the width of the texture image that is -// contributing to the TexturePeeker's information. -// This may be either the Texture's full width, or its -// simple ram image's width. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the texture image that is contributing to the + * TexturePeeker's information. This may be either the Texture's full width, + * or its simple ram image's width. + */ INLINE int TexturePeeker:: get_x_size() const { return _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_y_size -// Access: Published -// Description: Returns the height of the texture image that is -// contributing to the TexturePeeker's information. -// This may be either the Texture's full height, or its -// simple ram image's height. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the texture image that is contributing to the + * TexturePeeker's information. This may be either the Texture's full height, + * or its simple ram image's height. + */ INLINE int TexturePeeker:: get_y_size() const { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_z_size -// Access: Published -// Description: Returns the depth of the texture image that is -// contributing to the TexturePeeker's information. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth of the texture image that is contributing to the + * TexturePeeker's information. + */ INLINE int TexturePeeker:: get_z_size() const { return _z_size; } - diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index c27a1ba979..35d691bab0 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -1,41 +1,37 @@ -// Filename: texturePeeker.cxx -// Created by: drose (26Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePeeker.cxx + * @author drose + * @date 2008-08-26 + */ #include "texturePeeker.h" -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::Constructor -// Access: Private -// Description: Use Texture::peek() to construct a TexturePeeker. -// -// This constructor is called only by Texture::peek(), -// and assumes the texture's lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Use Texture::peek() to construct a TexturePeeker. + * + * This constructor is called only by Texture::peek(), and assumes the + * texture's lock is already held. + */ TexturePeeker:: TexturePeeker(Texture *tex, Texture::CData *cdata) { if (cdata->_texture_type == Texture::TT_cube_map) { - // Cube map texture. We'll need to map from (u, v, w) to (u, v) - // within the appropriate page, where w indicates the page. + // Cube map texture. We'll need to map from (u, v, w) to (u, v) within + // the appropriate page, where w indicates the page. // TODO: handle cube maps. return; } else { - // Regular 1-d, 2-d, or 3-d texture. The coordinates map - // directly. Simple ram images are possible if it is a 2-d - // texture. + // Regular 1-d, 2-d, or 3-d texture. The coordinates map directly. + // Simple ram images are possible if it is a 2-d texture. if (tex->do_has_ram_image(cdata) && cdata->_ram_image_compression == Texture::CM_off) { // Get the regular RAM image if it is available. _image = tex->do_get_ram_image(cdata); @@ -147,18 +143,14 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::lookup -// Access: Published -// Description: Fills "color" with the RGBA color of the texel at -// point (u, v). -// -// The texel color is determined via nearest-point -// sampling (no filtering of adjacent pixels), -// regardless of the filter type associated with the -// texture. u, v, and w will wrap around regardless of -// the texture's wrap mode. -//////////////////////////////////////////////////////////////////// +/** + * Fills "color" with the RGBA color of the texel at point (u, v). + * + * The texel color is determined via nearest-point sampling (no filtering of + * adjacent pixels), regardless of the filter type associated with the + * texture. u, v, and w will wrap around regardless of the texture's wrap + * mode. + */ void TexturePeeker:: lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const { int x = int((u - cfloor(u)) * (PN_stdfloat)_x_size) % _x_size; @@ -170,44 +162,36 @@ lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const { (*_get_texel)(color, p, _get_component); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::lookup -// Access: Published -// Description: Fills "color" with the RGBA color of the texel at -// point (u, v, w). -// -// The texel color is determined via nearest-point -// sampling (no filtering of adjacent pixels), -// regardless of the filter type associated with the -// texture. u, v, and w will wrap around regardless of -// the texture's wrap mode. -//////////////////////////////////////////////////////////////////// +/** + * Fills "color" with the RGBA color of the texel at point (u, v, w). + * + * The texel color is determined via nearest-point sampling (no filtering of + * adjacent pixels), regardless of the filter type associated with the + * texture. u, v, and w will wrap around regardless of the texture's wrap + * mode. + */ void TexturePeeker:: lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const { int x = int((u - cfloor(u)) * (PN_stdfloat)_x_size) % _x_size; int y = int((v - cfloor(v)) * (PN_stdfloat)_y_size) % _y_size; int z = int((w - cfloor(w)) * (PN_stdfloat)_z_size) % _z_size; - nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size && + nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size && z >= 0 && z < _z_size); const unsigned char *p = _image.p() + (z * _x_size * _y_size + y * _x_size + x) * _pixel_width; (*_get_texel)(color, p, _get_component); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::filter_rect -// Access: Published -// Description: Fills "color" with the average RGBA color of the -// texels within the rectangle defined by the specified -// coordinate range. -// -// The texel color is linearly filtered over the entire -// region. u, v, and w will wrap around regardless of -// the texture's wrap mode. -//////////////////////////////////////////////////////////////////// +/** + * Fills "color" with the average RGBA color of the texels within the + * rectangle defined by the specified coordinate range. + * + * The texel color is linearly filtered over the entire region. u, v, and w + * will wrap around regardless of the texture's wrap mode. + */ void TexturePeeker:: -filter_rect(LColor &color, +filter_rect(LColor &color, PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat max_u, PN_stdfloat max_v) const { int min_x, max_x; init_rect_minmax(min_x, max_x, min_u, max_u, _x_size); @@ -219,7 +203,7 @@ filter_rect(LColor &color, PN_stdfloat net = 0.0f; accum_filter_y(color, net, 0, min_x, max_x, min_u, max_u, - min_y, max_y, min_v, max_v, + min_y, max_y, min_v, max_v, 1.0f); if (net != 0.0f) { @@ -227,19 +211,15 @@ filter_rect(LColor &color, } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::filter_rect -// Access: Published -// Description: Fills "color" with the average RGBA color of the -// texels within the rectangle defined by the specified -// coordinate range. -// -// The texel color is linearly filtered over the entire -// region. u, v, and w will wrap around regardless of -// the texture's wrap mode. -//////////////////////////////////////////////////////////////////// +/** + * Fills "color" with the average RGBA color of the texels within the + * rectangle defined by the specified coordinate range. + * + * The texel color is linearly filtered over the entire region. u, v, and w + * will wrap around regardless of the texture's wrap mode. + */ void TexturePeeker:: -filter_rect(LColor &color, +filter_rect(LColor &color, PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat min_w, PN_stdfloat max_u, PN_stdfloat max_v, PN_stdfloat max_w) const { int min_x, max_x; @@ -263,12 +243,10 @@ filter_rect(LColor &color, } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::init_rect_minmax -// Access: Private, Static -// Description: Sanity-checks min_u, max_u and computes min_x and -// min_y based on them. Also works for y and z. -//////////////////////////////////////////////////////////////////// +/** + * Sanity-checks min_u, max_u and computes min_x and min_y based on them. + * Also works for y and z. + */ void TexturePeeker:: init_rect_minmax(int &min_x, int &max_x, PN_stdfloat &min_u, PN_stdfloat &max_u, int x_size) { @@ -286,23 +264,21 @@ init_rect_minmax(int &min_x, int &max_x, PN_stdfloat &min_u, PN_stdfloat &max_u, nassertv(min_x <= max_x); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::accum_filter_z -// Access: Private -// Description: Accumulates the range of pixels from min_z to max_z. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the range of pixels from min_z to max_z. + */ void TexturePeeker:: accum_filter_z(LColor &color, PN_stdfloat &net, int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, int min_z, int max_z, PN_stdfloat min_w, PN_stdfloat max_w) const { - nassertv(min_z >= 0 && min_z <= _z_size && + nassertv(min_z >= 0 && min_z <= _z_size && max_z >= 0 && max_z <= _z_size); int zi = min_z; if (min_z >= max_z - 1) { // Within a single texel. - accum_filter_y(color, net, zi % _z_size, + accum_filter_y(color, net, zi % _z_size, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, 1.0f); @@ -310,43 +286,41 @@ accum_filter_z(LColor &color, PN_stdfloat &net, } else { // First part-texel. PN_stdfloat w = (min_z + 1) - min_w * _z_size; - accum_filter_y(color, net, zi % _z_size, + accum_filter_y(color, net, zi % _z_size, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, w); int zs = max_z - 1; - + // Run of full texels. zi = min_z + 1; while (zi < zs) { - accum_filter_y(color, net, zi % _z_size, + accum_filter_y(color, net, zi % _z_size, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, 1.0f); ++zi; } - + // Last part-texel. w = max_w * _z_size - (max_z - 1); - accum_filter_y(color, net, zi % _z_size, + accum_filter_y(color, net, zi % _z_size, min_x, max_x, min_u, max_u, min_y, max_y, min_v, max_v, w); } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::accum_filter_y -// Access: Private -// Description: Accumulates the range of pixels from min_y to max_y. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the range of pixels from min_y to max_y. + */ void TexturePeeker:: accum_filter_y(LColor &color, PN_stdfloat &net, int zi, int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, int min_y, int max_y, PN_stdfloat min_v, PN_stdfloat max_v, PN_stdfloat weight) const { nassertv(zi >= 0 && zi < _z_size); - nassertv(min_y >= 0 && min_y <= _y_size && + nassertv(min_y >= 0 && min_y <= _y_size && max_y >= 0 && max_y <= _y_size); int yi = min_y; @@ -359,31 +333,29 @@ accum_filter_y(LColor &color, PN_stdfloat &net, int zi, PN_stdfloat w = (min_y + 1) - min_v * _y_size; accum_filter_x(color, net, yi % _y_size, zi, min_x, max_x, min_u, max_u, weight * w); int ys = max_y - 1; - + // Run of full texels. yi = min_y + 1; while (yi < ys) { accum_filter_x(color, net, yi % _y_size, zi, min_x, max_x, min_u, max_u, weight); ++yi; } - + // Last part-texel. w = max_v * _y_size - (max_y - 1); accum_filter_x(color, net, yi % _y_size, zi, min_x, max_x, min_u, max_u, weight * w); } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::accum_filter_x -// Access: Private -// Description: Accumulates the range of pixels from min_x to max_x. -//////////////////////////////////////////////////////////////////// +/** + * Accumulates the range of pixels from min_x to max_x. + */ void TexturePeeker:: accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, PN_stdfloat weight) const { nassertv(yi >= 0 && yi < _y_size && zi >= 0 && zi < _z_size); - nassertv(min_x >= 0 && min_x <= _x_size && + nassertv(min_x >= 0 && min_x <= _x_size && max_x >= 0 && max_x <= _x_size); // Compute the p corresponding to min_x. @@ -399,7 +371,7 @@ accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, PN_stdfloat w = (min_x + 1) - min_u * _x_size; accum_texel(color, net, p, weight * w); int xs = max_x - 1; - + // Run of full texels. xi = min_x + 1; while (xi < xs) { @@ -411,7 +383,7 @@ accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, accum_texel(color, net, p, weight); ++xi; } - + // Last part-texel. if (xi == _x_size) { xi = 0; @@ -422,12 +394,9 @@ accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::accum_texel -// Access: Private -// Description: Accumulates a single texel into the total computed by -// filter_rect(). -//////////////////////////////////////////////////////////////////// +/** + * Accumulates a single texel into the total computed by filter_rect(). + */ void TexturePeeker:: accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, PN_stdfloat weight) const { LColor c; @@ -436,12 +405,10 @@ accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, PN_stdfloa net += weight; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_r -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_red. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_red. + */ void TexturePeeker:: get_texel_r(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); @@ -450,12 +417,10 @@ get_texel_r(LColor &color, const unsigned char *&p, GetComponentFunc *get_compon color[3] = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_g -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_green. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_green. + */ void TexturePeeker:: get_texel_g(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; @@ -464,12 +429,10 @@ get_texel_g(LColor &color, const unsigned char *&p, GetComponentFunc *get_compon color[3] = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_b -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_blue. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_blue. + */ void TexturePeeker:: get_texel_b(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; @@ -478,12 +441,10 @@ get_texel_b(LColor &color, const unsigned char *&p, GetComponentFunc *get_compon color[3] = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_a -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_alpha. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_alpha. + */ void TexturePeeker:: get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = 0.0f; @@ -492,12 +453,10 @@ get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_compon color[3] = (*get_component)(p); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_l -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_luminance. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_luminance. + */ void TexturePeeker:: get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); @@ -506,12 +465,10 @@ get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_compon color[3] = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_la -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_luminance_alpha or similar. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_luminance_alpha or similar. + */ void TexturePeeker:: get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[0] = (*get_component)(p); @@ -520,12 +477,10 @@ get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_compo color[3] = (*get_component)(p); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_rgb -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_rgb or similar. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_rgb or similar. + */ void TexturePeeker:: get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[2] = (*get_component)(p); @@ -534,12 +489,10 @@ get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_comp color[3] = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePeeker::get_texel_rgba -// Access: Private, Static -// Description: Gets the color of the texel at byte p, given that the -// texture is in format F_rgba or similar. -//////////////////////////////////////////////////////////////////// +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_rgba or similar. + */ void TexturePeeker:: get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { color[2] = (*get_component)(p); diff --git a/panda/src/gobj/texturePeeker.h b/panda/src/gobj/texturePeeker.h index 909dc66a70..14eaf5f0e9 100644 --- a/panda/src/gobj/texturePeeker.h +++ b/panda/src/gobj/texturePeeker.h @@ -1,16 +1,15 @@ -// Filename: texturePeeker.h -// Created by: drose (26Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePeeker.h + * @author drose + * @date 2008-08-26 + */ #ifndef TEXTUREPEEKER_H #define TEXTUREPEEKER_H @@ -20,13 +19,11 @@ #include "referenceCount.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : TexturePeeker -// Description : An instance of this object is returned by -// Texture::peek(). This object allows quick and easy -// inspection of a texture's texels by (u, v) -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * An instance of this object is returned by Texture::peek(). This object + * allows quick and easy inspection of a texture's texels by (u, v) + * coordinates. + */ class EXPCL_PANDA_GOBJ TexturePeeker : public ReferenceCount { private: TexturePeeker(Texture *tex, Texture::CData *cdata); @@ -41,15 +38,15 @@ PUBLISHED: void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const; void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const; - void filter_rect(LColor &color, - PN_stdfloat min_u, PN_stdfloat min_v, + void filter_rect(LColor &color, + PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat max_u, PN_stdfloat max_v) const; - void filter_rect(LColor &color, + void filter_rect(LColor &color, PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat min_w, PN_stdfloat max_u, PN_stdfloat max_v, PN_stdfloat max_w) const; private: - static void init_rect_minmax(int &min_x, int &max_x, + static void init_rect_minmax(int &min_x, int &max_x, PN_stdfloat &min_u, PN_stdfloat &max_u, int x_size); @@ -64,7 +61,7 @@ private: void accum_filter_x(LColor &color, PN_stdfloat &net, int yi, int zi, int min_x, int max_x, PN_stdfloat min_u, PN_stdfloat max_u, PN_stdfloat weight) const; - void accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, + void accum_texel(LColor &color, PN_stdfloat &net, const unsigned char *&p, PN_stdfloat weight) const; typedef double GetComponentFunc(const unsigned char *&p); @@ -79,7 +76,7 @@ private: static void get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); - + int _x_size; int _y_size; int _z_size; @@ -99,4 +96,3 @@ private: #include "texturePeeker.I" #endif - diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index 0598886169..499ab04a83 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -1,59 +1,48 @@ -// Filename: texturePool.I -// Created by: drose (26Apr00) -// Updated by: fperazzi, PandaSE(29Apr10) (added load_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePool.I + * @author drose + * @date 2000-04-26 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::has_texture -// Access: Published, Static -// Description: Returns true if the texture has ever been loaded, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has ever been loaded, false otherwise. + */ INLINE bool TexturePool:: has_texture(const Filename &filename) { return get_global_ptr()->ns_has_texture(filename); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::verify_texture -// Access: Published, Static -// Description: Loads the given filename up into a texture, if it has -// not already been loaded, and returns true to indicate -// success, or false to indicate failure. If this -// returns true, it is guaranteed that a subsequent call -// to load_texture() with the same texture name will -// return a valid Texture pointer. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a texture, if it has not already been + * loaded, and returns true to indicate success, or false to indicate failure. + * If this returns true, it is guaranteed that a subsequent call to + * load_texture() with the same texture name will return a valid Texture + * pointer. + */ INLINE bool TexturePool:: verify_texture(const Filename &filename) { return load_texture(filename) != (Texture *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_texture -// Access: Published, Static -// Description: Loads the given filename up into a texture, if it has -// not already been loaded, and returns the new texture. -// If a texture with the same filename was previously -// loaded, returns that one instead. If the texture -// file cannot be found, returns NULL. -// -// If read_mipmaps is true, the filename should contain -// a hash mark ('#'), which will be filled in with the -// mipmap level number; and the texture will be defined -// with a series of images, one for each mipmap level. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a texture, if it has not already been + * loaded, and returns the new texture. If a texture with the same filename + * was previously loaded, returns that one instead. If the texture file + * cannot be found, returns NULL. + * + * If read_mipmaps is true, the filename should contain a hash mark ('#'), + * which will be filled in with the mipmap level number; and the texture will + * be defined with a series of images, one for each mipmap level. + */ INLINE Texture *TexturePool:: load_texture(const Filename &filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions &options) { @@ -61,292 +50,227 @@ load_texture(const Filename &filename, int primary_file_num_channels, read_mipmaps, options); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_texture -// Access: Published, Static -// Description: Loads the given filename up into a texture, if it has -// not already been loaded, and returns the new texture. -// If a texture with the same filename was previously -// loaded, returns that one instead. If the texture -// file cannot be found, returns NULL. -// -// If read_mipmaps is true, both filenames should -// contain a hash mark ('#'), which will be filled in -// with the mipmap level number; and the texture will be -// defined with a series of images, two for each mipmap -// level. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a texture, if it has not already been + * loaded, and returns the new texture. If a texture with the same filename + * was previously loaded, returns that one instead. If the texture file + * cannot be found, returns NULL. + * + * If read_mipmaps is true, both filenames should contain a hash mark ('#'), + * which will be filled in with the mipmap level number; and the texture will + * be defined with a series of images, two for each mipmap level. + */ INLINE Texture *TexturePool:: load_texture(const Filename &filename, const Filename &alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps, const LoaderOptions &options) { - return get_global_ptr()->ns_load_texture(filename, alpha_filename, + return get_global_ptr()->ns_load_texture(filename, alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_3d_texture -// Access: Published, Static -// Description: Loads a 3-D texture that is specified with a series -// of n pages, all numbered in sequence, and beginning -// with index 0. The filename should include a sequence -// of one or more hash characters ("#") which will be -// filled in with the index number of each level. -// -// If read_mipmaps is true, the filename should contain -// an additional hash mark. The first hash mark will be -// filled in with the mipmap level number, and the -// second with the index number of each 3-d level. -//////////////////////////////////////////////////////////////////// +/** + * Loads a 3-D texture that is specified with a series of n pages, all + * numbered in sequence, and beginning with index 0. The filename should + * include a sequence of one or more hash characters ("#") which will be + * filled in with the index number of each level. + * + * If read_mipmaps is true, the filename should contain an additional hash + * mark. The first hash mark will be filled in with the mipmap level number, + * and the second with the index number of each 3-d level. + */ INLINE Texture *TexturePool:: -load_3d_texture(const Filename &filename_pattern, bool read_mipmaps, +load_3d_texture(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { - return get_global_ptr()->ns_load_3d_texture(filename_pattern, read_mipmaps, + return get_global_ptr()->ns_load_3d_texture(filename_pattern, read_mipmaps, options); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_2d_texture_array -// Access: Published, Static -// Description: Loads a 2-D texture array that is specified with a series -// of n pages, all numbered in sequence, and beginning -// with index 0. The filename should include a sequence -// of one or more hash characters ("#") which will be -// filled in with the index number of each level. -// -// If read_mipmaps is true, the filename should contain -// an additional hash mark. The first hash mark will be -// filled in with the mipmap level number, and the -// second with the index number of each 2-d level. -//////////////////////////////////////////////////////////////////// +/** + * Loads a 2-D texture array that is specified with a series of n pages, all + * numbered in sequence, and beginning with index 0. The filename should + * include a sequence of one or more hash characters ("#") which will be + * filled in with the index number of each level. + * + * If read_mipmaps is true, the filename should contain an additional hash + * mark. The first hash mark will be filled in with the mipmap level number, + * and the second with the index number of each 2-d level. + */ INLINE Texture *TexturePool:: -load_2d_texture_array(const Filename &filename_pattern, bool read_mipmaps, +load_2d_texture_array(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { - return get_global_ptr()->ns_load_2d_texture_array(filename_pattern, read_mipmaps, + return get_global_ptr()->ns_load_2d_texture_array(filename_pattern, read_mipmaps, options); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_cube_map -// Access: Published, Static -// Description: Loads a cube map texture that is specified with a -// series of 6 pages, numbered 0 through 5. The -// filename should include a sequence of one or more -// hash characters ("#") which will be filled in with -// the index number of each pagee. -// -// If read_mipmaps is true, the filename should contain -// an additional hash mark. The first hash mark will be -// filled in with the mipmap level number, and the -// second with the face number, 0 through 5. -//////////////////////////////////////////////////////////////////// +/** + * Loads a cube map texture that is specified with a series of 6 pages, + * numbered 0 through 5. The filename should include a sequence of one or + * more hash characters ("#") which will be filled in with the index number of + * each pagee. + * + * If read_mipmaps is true, the filename should contain an additional hash + * mark. The first hash mark will be filled in with the mipmap level number, + * and the second with the face number, 0 through 5. + */ INLINE Texture *TexturePool:: -load_cube_map(const Filename &filename_pattern, bool read_mipmaps, +load_cube_map(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { - return get_global_ptr()->ns_load_cube_map(filename_pattern, read_mipmaps, + return get_global_ptr()->ns_load_cube_map(filename_pattern, read_mipmaps, options); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::get_normalization_cube_map -// Access: Published, Static -// Description: Returns a standard Texture object that has been -// created with -// Texture::generate_normalization_cube_map(). This -// Texture may be shared by any application code -// requiring a normalization cube map. It will be at -// least as large as the specified size, though it may -// be larger. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard Texture object that has been created with + * Texture::generate_normalization_cube_map(). This Texture may be shared by + * any application code requiring a normalization cube map. It will be at + * least as large as the specified size, though it may be larger. + */ INLINE Texture *TexturePool:: get_normalization_cube_map(int size) { return get_global_ptr()->ns_get_normalization_cube_map(size); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::get_alpha_scale_map -// Access: Published, Static -// Description: Returns a standard Texture object that has been -// created with Texture::generate_alpha_scale_map(). -// -// This Texture object is used internally by Panda to -// apply an alpha scale to an object (instead of munging -// its vertices) when gsg->get_alpha_scale_via_texture() -// returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns a standard Texture object that has been created with + * Texture::generate_alpha_scale_map(). + * + * This Texture object is used internally by Panda to apply an alpha scale to + * an object (instead of munging its vertices) when + * gsg->get_alpha_scale_via_texture() returns true. + */ INLINE Texture *TexturePool:: get_alpha_scale_map() { return get_global_ptr()->ns_get_alpha_scale_map(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::add_texture -// Access: Published, Static -// Description: Adds the indicated already-loaded texture to the -// pool. The texture must have a filename set for its -// name. The texture will always replace any -// previously-loaded texture in the pool that had the -// same filename. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated already-loaded texture to the pool. The texture must + * have a filename set for its name. The texture will always replace any + * previously-loaded texture in the pool that had the same filename. + */ INLINE void TexturePool:: add_texture(Texture *texture) { get_global_ptr()->ns_add_texture(texture); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::release_texture -// Access: Published, Static -// Description: Removes the indicated texture from the pool, -// indicating it will never be loaded again; the texture -// may then be freed. If this function is never called, -// a reference count will be maintained on every texture -// every loaded, and textures will never be freed. -// -// The texture's name should not have been changed -// during its lifetime, or this function may fail to -// locate it in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated texture from the pool, indicating it will never be + * loaded again; the texture may then be freed. If this function is never + * called, a reference count will be maintained on every texture every loaded, + * and textures will never be freed. + * + * The texture's name should not have been changed during its lifetime, or + * this function may fail to locate it in the pool. + */ INLINE void TexturePool:: release_texture(Texture *texture) { get_global_ptr()->ns_release_texture(texture); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::release_all_textures -// Access: Published, Static -// Description: Releases all textures in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all textures in the pool and restores the pool to the empty state. + */ INLINE void TexturePool:: release_all_textures() { get_global_ptr()->ns_release_all_textures(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::rehash -// Access: Published, Static -// Description: Should be called when the model-path changes, to blow -// away the cache of texture pathnames found along the -// model-path. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the model-path changes, to blow away the cache of + * texture pathnames found along the model-path. + */ INLINE void TexturePool:: rehash() { get_global_ptr()->_relpath_lookup.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::garbage_collect -// Access: Published, Static -// Description: Releases only those textures in the pool that have a -// reference count of exactly 1; i.e. only those -// textures that are not being used outside of the pool. -// Returns the number of textures released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those textures in the pool that have a reference count of + * exactly 1; i.e. only those textures that are not being used outside of the + * pool. Returns the number of textures released. + */ INLINE int TexturePool:: garbage_collect() { return get_global_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::list_contents -// Access: Published, Static -// Description: Lists the contents of the texture pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the texture pool to the indicated output stream. + */ INLINE void TexturePool:: list_contents(ostream &out) { get_global_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::list_contents -// Access: Published, Static -// Description: Lists the contents of the texture pool to cout -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the texture pool to cout + */ INLINE void TexturePool:: list_contents() { get_global_ptr()->ns_list_contents(cout); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::find_texture -// Access: Published, Static -// Description: Returns the first texture found in the pool that -// matches the indicated name (which may contain -// wildcards). Returns the texture if it is found, or -// NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first texture found in the pool that matches the indicated name + * (which may contain wildcards). Returns the texture if it is found, or NULL + * if it is not. + */ INLINE Texture *TexturePool:: find_texture(const string &name) { return get_global_ptr()->ns_find_texture(name); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::find_all_textures -// Access: Published, Static -// Description: Returns the set of all textures found in the pool -// that match the indicated name (which may contain -// wildcards). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of all textures found in the pool that match the indicated + * name (which may contain wildcards). + */ INLINE TextureCollection TexturePool:: find_all_textures(const string &name) { return get_global_ptr()->ns_find_all_textures(name); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::set_fake_texture_image -// Access: Published, Static -// Description: Sets a bogus filename that will be loaded in lieu of -// any textures requested from this point on. -//////////////////////////////////////////////////////////////////// +/** + * Sets a bogus filename that will be loaded in lieu of any textures requested + * from this point on. + */ INLINE void TexturePool:: set_fake_texture_image(const Filename &filename) { get_global_ptr()->_fake_texture_image = filename; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::clear_fake_texture_image -// Access: Published, Static -// Description: Restores normal behavior of loading the textures -// actually requested. -//////////////////////////////////////////////////////////////////// +/** + * Restores normal behavior of loading the textures actually requested. + */ INLINE void TexturePool:: clear_fake_texture_image() { set_fake_texture_image(string()); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::has_fake_texture_image -// Access: Published, Static -// Description: Returns true if fake_texture_image mode has been -// enabled, false if we are in the normal mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if fake_texture_image mode has been enabled, false if we are + * in the normal mode. + */ INLINE bool TexturePool:: has_fake_texture_image() { return !get_fake_texture_image().empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::get_fake_texture_image -// Access: Published, Static -// Description: Returns the filename that was specified with a -// previous call to set_fake_texture_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that was specified with a previous call to + * set_fake_texture_image(). + */ INLINE const Filename &TexturePool:: get_fake_texture_image() { return get_global_ptr()->_fake_texture_image; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::make_texture -// Access: Published, Static -// Description: Creates a new Texture object of the appropriate type -// for the indicated filename extension, according to -// the types that have been registered via -// register_texture_type(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Texture object of the appropriate type for the indicated + * filename extension, according to the types that have been registered via + * register_texture_type(). + */ PT(Texture) TexturePool:: make_texture(const string &extension) { return get_global_ptr()->ns_make_texture(extension); diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index ae9cf1bfd2..cf73364cde 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -1,17 +1,17 @@ -// Filename: texturePool.cxx -// Created by: drose (26Apr00) -// Updated by: fperazzi, PandaSE(29Apr10) (added ns_load_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePool.cxx + * @author drose + * @date 2000-04-26 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #include "texturePool.h" #include "config_gobj.h" @@ -30,27 +30,21 @@ TexturePool *TexturePool::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::write -// Access: Published, Static -// Description: Lists the contents of the texture pool to the -// indicated output stream. -// For debugging. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the texture pool to the indicated output stream. For + * debugging. + */ void TexturePool:: write(ostream &out) { get_global_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::register_texture_type -// Access: Public -// Description: Records a factory function that makes a Texture -// object of the appropriate type for one or more -// particular filename extensions. The string -// extensions may be a string that contains -// space-separated list of extensions, case-insensitive. -//////////////////////////////////////////////////////////////////// +/** + * Records a factory function that makes a Texture object of the appropriate + * type for one or more particular filename extensions. The string extensions + * may be a string that contains space-separated list of extensions, case- + * insensitive. + */ void TexturePool:: register_texture_type(MakeTextureFunc *func, const string &extensions) { MutexHolder holder(_lock); @@ -64,12 +58,10 @@ register_texture_type(MakeTextureFunc *func, const string &extensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::register_filter -// Access: Public -// Description: Records a TexturePoolFilter object that may operate -// on texture images as they are loaded from disk. -//////////////////////////////////////////////////////////////////// +/** + * Records a TexturePoolFilter object that may operate on texture images as + * they are loaded from disk. + */ void TexturePool:: register_filter(TexturePoolFilter *filter) { MutexHolder holder(_lock); @@ -79,14 +71,11 @@ register_filter(TexturePoolFilter *filter) { _filter_registry.push_back(filter); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::get_texture_type -// Access: Public -// Description: Returns the factory function to construct a new -// texture of the type appropriate for the indicated -// filename extension, if any, or NULL if the extension -// is not one of the extensions for a texture file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the factory function to construct a new texture of the type + * appropriate for the indicated filename extension, if any, or NULL if the + * extension is not one of the extensions for a texture file. + */ TexturePool::MakeTextureFunc *TexturePool:: get_texture_type(const string &extension) const { MutexHolder holder(_lock); @@ -111,14 +100,11 @@ get_texture_type(const string &extension) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::write_texture_types -// Access: Public -// Description: Outputs a list of the available texture types to the -// indicated output stream. This is mostly the list of -// available image types, with maybe a few additional -// ones for video textures. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of the available texture types to the indicated output + * stream. This is mostly the list of available image types, with maybe a few + * additional ones for video textures. + */ void TexturePool:: write_texture_types(ostream &out, int indent_level) const { MutexHolder holder(_lock); @@ -126,8 +112,8 @@ write_texture_types(ostream &out, int indent_level) const { PNMFileTypeRegistry *pnm_reg = PNMFileTypeRegistry::get_global_ptr(); pnm_reg->write(out, indent_level); - // Also output any of the additional texture types, that aren't - // strictly images (these are typically video textures). + // Also output any of the additional texture types, that aren't strictly + // images (these are typically video textures). TypeRegistry::const_iterator ti; for (ti = _type_registry.begin(); ti != _type_registry.end(); ++ti) { string extension = (*ti).first; @@ -143,32 +129,26 @@ write_texture_types(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::get_global_ptr -// Access: Public, Static -// Description: Initializes and/or returns the global pointer to the -// one TexturePool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one TexturePool object + * in the system. + */ TexturePool *TexturePool:: get_global_ptr() { if (_global_ptr == (TexturePool *)NULL) { _global_ptr = new TexturePool; // We have to call this here, not in the constructor, so that the - // _global_ptr is safely assigned by the time the filters begin to - // load. + // _global_ptr is safely assigned by the time the filters begin to load. _global_ptr->load_filters(); } return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one TexturePool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one TexturePool in the universe and it constructs itself. + */ TexturePool:: TexturePool() { ConfigVariableFilename fake_texture_image @@ -181,11 +161,9 @@ TexturePool() { _fake_texture_image = fake_texture_image; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_has_texture -// Access: Private -// Description: The nonstatic implementation of has_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of has_texture(). + */ bool TexturePool:: ns_has_texture(const Filename &orig_filename) { MutexHolder holder(_lock); @@ -203,11 +181,9 @@ ns_has_texture(const Filename &orig_filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_load_texture -// Access: Private -// Description: The nonstatic implementation of load_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_texture(). + */ Texture *TexturePool:: ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions &options) { @@ -241,16 +217,16 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, options); if (tex == (Texture *)NULL) { - // The texture was neither in the pool, nor found in the on-disk - // cache; it needs to be loaded from its source image(s). + // The texture was neither in the pool, nor found in the on-disk cache; it + // needs to be loaded from its source image(s). gobj_cat.info() << "Loading texture " << filename << "\n"; string ext = downcase(filename.get_extension()); if (ext == "txo" || ext == "bam") { - // Assume this is a txo file, which might conceivably contain a - // movie file or some other subclass of Texture. In that case, - // use make_from_txo() to load it instead of read(). + // Assume this is a txo file, which might conceivably contain a movie + // file or some other subclass of Texture. In that case, use + // make_from_txo() to load it instead of read(). VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); filename.set_binary(); @@ -277,7 +253,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex->set_fullpath(filename); tex->clear_alpha_fullpath(); tex->set_keep_ram_image(false); - + } else { // Read it the conventional way. tex = ns_make_texture(ext); @@ -325,8 +301,8 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, { MutexHolder holder(_lock); - // Now look again--someone may have just loaded this texture in - // another thread. + // Now look again--someone may have just loaded this texture in another + // thread. Textures::const_iterator ti; ti = _textures.find(filename); if (ti != _textures.end()) { @@ -358,13 +334,11 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_load_texture -// Access: Private -// Description: The nonstatic implementation of load_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_texture(). + */ Texture *TexturePool:: -ns_load_texture(const Filename &orig_filename, +ns_load_texture(const Filename &orig_filename, const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel, @@ -397,7 +371,7 @@ ns_load_texture(const Filename &orig_filename, bool store_record = false; // Can one of our texture filters supply the texture? - tex = pre_load(orig_filename, alpha_filename, primary_file_num_channels, + tex = pre_load(orig_filename, alpha_filename, primary_file_num_channels, alpha_file_channel, read_mipmaps, options); BamCache *cache = BamCache::get_global_ptr(); @@ -406,8 +380,8 @@ ns_load_texture(const Filename &orig_filename, options); if (tex == (Texture *)NULL) { - // The texture was neither in the pool, nor found in the on-disk - // cache; it needs to be loaded from its source image(s). + // The texture was neither in the pool, nor found in the on-disk cache; it + // needs to be loaded from its source image(s). gobj_cat.info() << "Loading texture " << filename << " and alpha component " << alpha_filename << endl; @@ -467,7 +441,7 @@ ns_load_texture(const Filename &orig_filename, nassertr(!tex->get_fullpath().empty(), tex); return tex; } - + _textures[filename] = tex; } @@ -490,11 +464,9 @@ ns_load_texture(const Filename &orig_filename, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_load_3d_texture -// Access: Private -// Description: The nonstatic implementation of load_3d_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_3d_texture(). + */ Texture *TexturePool:: ns_load_3d_texture(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { @@ -525,10 +497,10 @@ ns_load_3d_texture(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == (Texture *)NULL || tex->get_texture_type() != Texture::TT_3d_texture) { - // The texture was neither in the pool, nor found in the on-disk - // cache; it needs to be loaded from its source image(s). + // The texture was neither in the pool, nor found in the on-disk cache; it + // needs to be loaded from its source image(s). gobj_cat.info() << "Loading 3-d texture " << filename << "\n"; tex = ns_make_texture(filename.get_extension()); @@ -593,11 +565,9 @@ ns_load_3d_texture(const Filename &filename_pattern, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_load_2d_texture_array -// Access: Private -// Description: The nonstatic implementation of load_2d_texture_array(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_2d_texture_array(). + */ Texture *TexturePool:: ns_load_2d_texture_array(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { @@ -631,10 +601,10 @@ ns_load_2d_texture_array(const Filename &filename_pattern, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == (Texture *)NULL || tex->get_texture_type() != Texture::TT_2d_texture_array) { - // The texture was neither in the pool, nor found in the on-disk - // cache; it needs to be loaded from its source image(s). + // The texture was neither in the pool, nor found in the on-disk cache; it + // needs to be loaded from its source image(s). gobj_cat.info() << "Loading 2-d texture array " << filename << "\n"; tex = ns_make_texture(filename.get_extension()); @@ -699,13 +669,11 @@ ns_load_2d_texture_array(const Filename &filename_pattern, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_load_cube_map -// Access: Private -// Description: The nonstatic implementation of load_cube_map(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_cube_map(). + */ Texture *TexturePool:: -ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, +ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, const LoaderOptions &options) { Filename orig_filename(filename_pattern); orig_filename.set_pattern(true); @@ -732,10 +700,10 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, try_load_cache(tex, cache, filename, record, compressed_cache_record, options); - if (tex == (Texture *)NULL || + if (tex == (Texture *)NULL || tex->get_texture_type() != Texture::TT_cube_map) { - // The texture was neither in the pool, nor found in the on-disk - // cache; it needs to be loaded from its source image(s). + // The texture was neither in the pool, nor found in the on-disk cache; it + // needs to be loaded from its source image(s). gobj_cat.info() << "Loading cube map texture " << filename << "\n"; tex = ns_make_texture(filename.get_extension()); @@ -767,7 +735,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, // We don't want to save this texture. store_record = false; } - + // Set the original filename, before we searched along the path. nassertr(tex != (Texture *)NULL, NULL); tex->set_filename(filename_pattern); @@ -798,11 +766,9 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_get_normalization_cube_map -// Access: Private -// Description: The nonstatic implementation of get_normalization_cube_map(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of get_normalization_cube_map(). + */ Texture *TexturePool:: ns_get_normalization_cube_map(int size) { MutexHolder holder(_lock); @@ -818,11 +784,9 @@ ns_get_normalization_cube_map(int size) { return _normalization_cube_map; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_get_alpha_scale_map -// Access: Private -// Description: The nonstatic implementation of get_alpha_scale_map(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of get_alpha_scale_map(). + */ Texture *TexturePool:: ns_get_alpha_scale_map() { MutexHolder holder(_lock); @@ -835,11 +799,9 @@ ns_get_alpha_scale_map() { return _alpha_scale_map; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_add_texture -// Access: Private -// Description: The nonstatic implementation of add_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of add_texture(). + */ void TexturePool:: ns_add_texture(Texture *tex) { PT(Texture) keep = tex; @@ -859,11 +821,9 @@ ns_add_texture(Texture *tex) { nassertv(!tex->get_fullpath().empty()); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_release_texture -// Access: Private -// Description: The nonstatic implementation of release_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_texture(). + */ void TexturePool:: ns_release_texture(Texture *tex) { MutexHolder holder(_lock); @@ -881,11 +841,9 @@ ns_release_texture(Texture *tex) { _relpath_lookup.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_release_all_textures -// Access: Private -// Description: The nonstatic implementation of release_all_textures(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_textures(). + */ void TexturePool:: ns_release_all_textures() { MutexHolder holder(_lock); @@ -903,11 +861,9 @@ ns_release_all_textures() { _relpath_lookup.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int TexturePool:: ns_garbage_collect() { MutexHolder holder(_lock); @@ -945,11 +901,9 @@ ns_garbage_collect() { return num_released; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void TexturePool:: ns_list_contents(ostream &out) const { MutexHolder holder(_lock); @@ -959,34 +913,32 @@ ns_list_contents(ostream &out) const { Textures::const_iterator ti; out << "texture pool contents:\n"; - + total_size = 0; total_ram_size = 0; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { Texture *tex = (*ti).second; out << (*ti).first << "\n"; - out << " (count = " << tex->get_ref_count() - << ", ram = " << tex->get_ram_image_size() + out << " (count = " << tex->get_ref_count() + << ", ram = " << tex->get_ram_image_size() << ", size = " << tex->get_ram_page_size() - << ", w = " << tex->get_x_size() - << ", h = " << tex->get_y_size() + << ", w = " << tex->get_x_size() + << ", h = " << tex->get_y_size() << ")\n"; nassertv(tex->_texture_pool_key == (*ti).first); total_ram_size += tex->get_ram_image_size(); total_size += tex->get_ram_page_size(); } - + out << "total number of textures: " << _textures.size() << "\n"; out << "texture pool ram : " << total_ram_size << "\n"; out << "texture pool size: " << total_size << "\n"; out << "texture pool size - texture pool ram: " << total_size - total_ram_size << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_find_texture -// Access: Private -// Description: The nonstatic implementation of find_texture(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of find_texture(). + */ Texture *TexturePool:: ns_find_texture(const string &name) const { MutexHolder holder(_lock); @@ -1003,11 +955,9 @@ ns_find_texture(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_find_all_textures -// Access: Private -// Description: The nonstatic implementation of find_all_textures(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of find_all_textures(). + */ TextureCollection TexturePool:: ns_find_all_textures(const string &name) const { MutexHolder holder(_lock); @@ -1025,14 +975,11 @@ ns_find_all_textures(const string &name) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::ns_make_texture -// Access: Public -// Description: Creates a new Texture object of the appropriate type -// for the indicated filename extension, according to -// the types that have been registered via -// register_texture_type(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Texture object of the appropriate type for the indicated + * filename extension, according to the types that have been registered via + * register_texture_type(). + */ PT(Texture) TexturePool:: ns_make_texture(const string &extension) const { MakeTextureFunc *func = get_texture_type(extension); @@ -1040,19 +987,16 @@ ns_make_texture(const string &extension) const { return func(); } - // We don't know what kind of file type this is; return an ordinary - // Texture in case it's an image file with no extension. + // We don't know what kind of file type this is; return an ordinary Texture + // in case it's an image file with no extension. return new Texture; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::resolve_filename -// Access: Private -// Description: Searches for the indicated filename along the -// model path. If the filename was previously -// searched for, doesn't search again, as an -// optimization. Assumes _lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated filename along the model path. If the filename + * was previously searched for, doesn't search again, as an optimization. + * Assumes _lock is held. + */ void TexturePool:: resolve_filename(Filename &new_filename, const Filename &orig_filename, bool read_mipmaps, const LoaderOptions &options) { @@ -1078,25 +1022,22 @@ resolve_filename(Filename &new_filename, const Filename &orig_filename, _relpath_lookup[orig_filename] = new_filename; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::try_load_cache -// Access: Private -// Description: Attempts to load the texture from the cache record. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to load the texture from the cache record. + */ void TexturePool:: try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, PT(BamCacheRecord) &record, bool &compressed_cache_record, const LoaderOptions &options) { if (tex == (Texture *)NULL) { - // The texture was not supplied by a texture filter. See if it - // can be found in the on-disk cache, if it is active. + // The texture was not supplied by a texture filter. See if it can be + // found in the on-disk cache, if it is active. if ((cache->get_cache_textures() || cache->get_cache_compressed_textures()) && !textures_header_only) { - // Call ns_make_texture() on the file extension and create a - // dummy texture object we can call ensure_loaded_type() on. We - // don't need to keep this object around after this call, since - // we'll be creating a new one below. I know this is a bit - // hacky. + // Call ns_make_texture() on the file extension and create a dummy + // texture object we can call ensure_loaded_type() on. We don't need to + // keep this object around after this call, since we'll be creating a + // new one below. I know this is a bit hacky. string ext = downcase(filename.get_extension()); PT(Texture) dummy = ns_make_texture(ext); dummy->ensure_loader_type(filename); @@ -1122,10 +1063,10 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, } else if (x_size != tex->get_x_size() || y_size != tex->get_y_size()) { - // The cached texture no longer matches our expected size - // (the resizing config variables must have changed). - // We'll have to reload the texture from its original file - // so we can rebuild the cache. + // The cached texture no longer matches our expected size (the + // resizing config variables must have changed). We'll have to + // reload the texture from its original file so we can rebuild the + // cache. if (gobj_cat.is_debug()) { gobj_cat.debug() << "Cached texture " << *tex << " has size " @@ -1136,8 +1077,7 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, tex = NULL; } else if (!tex->has_compression() && tex->get_ram_image_compression() != Texture::CM_off) { - // This texture shouldn't be compressed, but it is. Go - // reload it. + // This texture shouldn't be compressed, but it is. Go reload it. if (gobj_cat.is_debug()) { gobj_cat.debug() << "Cached texture " << *tex @@ -1162,10 +1102,9 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, bool is_compressed = (tex->get_ram_image_compression() != Texture::CM_off); if (!was_compressed && is_compressed && cache->get_cache_compressed_textures()) { - // We've re-compressed the image after loading it - // from the cache. To keep the cache current, - // rewrite it to the cache now, in its newly - // compressed form. + // We've re-compressed the image after loading it from the + // cache. To keep the cache current, rewrite it to the + // cache now, in its newly compressed form. record->set_data(tex); cache->store(record); compressed_cache_record = true; @@ -1176,9 +1115,9 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, } } else { if (!cache->get_cache_textures()) { - // This texture has no actual record, and therefore no - // compressed record (yet). And we're not supposed to be - // caching uncompressed textures. + // This texture has no actual record, and therefore no compressed + // record (yet). And we're not supposed to be caching + // uncompressed textures. if (gobj_cat.is_debug()) { gobj_cat.debug() << "Not caching uncompressed texture\n"; @@ -1191,27 +1130,23 @@ try_load_cache(PT(Texture) &tex, BamCache *cache, const Filename &filename, } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::report_texture_unreadable -// Access: Private -// Description: Prints a suitable error message when a texture could -// not be loaded. -//////////////////////////////////////////////////////////////////// +/** + * Prints a suitable error message when a texture could not be loaded. + */ void TexturePool:: report_texture_unreadable(const Filename &filename) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); bool has_hash = (filename.get_fullpath().find('#') != string::npos); if (!has_hash && !vfs->exists(filename)) { if (filename.is_local()) { - // The file doesn't exist, and it wasn't - // fully-qualified--therefore, it wasn't found along either - // search path. + // The file doesn't exist, and it wasn't fully-qualified--therefore, it + // wasn't found along either search path. gobj_cat.error() << "Unable to find texture \"" << filename << "\"" << " on model-path " << get_model_path() <<"\n"; } else { - // A fully-specified filename is not searched along the path, so - // don't mislead the user with the error message. + // A fully-specified filename is not searched along the path, so don't + // mislead the user with the error message. gobj_cat.error() << "Texture \"" << filename << "\" does not exist.\n"; } @@ -1222,8 +1157,8 @@ report_texture_unreadable(const Filename &filename) const { gobj_cat.error() << "Texture \"" << filename << "\" exists but cannot be read.\n"; } else { - // If the filename contains a hash, we'll be noncommittal about - // whether it exists or not. + // If the filename contains a hash, we'll be noncommittal about whether + // it exists or not. gobj_cat.error() << "Texture \"" << filename << "\" cannot be read.\n"; } @@ -1232,21 +1167,18 @@ report_texture_unreadable(const Filename &filename) const { MakeTextureFunc *func = get_texture_type(filename.get_extension()); if (func == (MakeTextureFunc *)NULL) { gobj_cat.error() - << "Texture extension \"" << filename.get_extension() + << "Texture extension \"" << filename.get_extension() << "\" is unknown. Supported texture types:\n"; write_texture_types(gobj_cat.error(false), 2); } } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::pre_load -// Access: Private -// Description: Invokes pre_load() on all registered filters until -// one returns non-NULL; returns NULL if there are no -// registered filters or if all registered filters -// returned NULL. -//////////////////////////////////////////////////////////////////// +/** + * Invokes pre_load() on all registered filters until one returns non-NULL; + * returns NULL if there are no registered filters or if all registered + * filters returned NULL. + */ PT(Texture) TexturePool:: pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel, @@ -1270,11 +1202,9 @@ pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::post_load -// Access: Public, Virtual -// Description: Invokes post_load() on all registered filters. -//////////////////////////////////////////////////////////////////// +/** + * Invokes post_load() on all registered filters. + */ PT(Texture) TexturePool:: post_load(Texture *tex) { PT(Texture) result = tex; @@ -1292,12 +1222,9 @@ post_load(Texture *tex) { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePool::load_filters -// Access: Private -// Description: Loads up all of the dll's named by the texture-filter -// Config.prc variable. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all of the dll's named by the texture-filter Config.prc variable. + */ void TexturePool:: load_filters() { ConfigVariableList texture_filter @@ -1306,11 +1233,11 @@ load_filters() { "purposes of performing texture filtering. This variable may be repeated several " "times. As in load-display, the actual library filename is derived by " "prefixing 'lib' to the specified name.")); - + int num_aux = texture_filter.get_num_unique_values(); for (int i = 0; i < num_aux; i++) { string name = texture_filter.get_unique_value(i); - + Filename dlname = Filename::dso_filename("lib" + name + ".so"); gobj_cat->info() << "loading texture filter: " << dlname.to_os_specific() << endl; diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index 995a705794..2f0866cf3f 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -1,17 +1,17 @@ -// Filename: texturePool.h -// Created by: drose (26Apr00) -// Updated by: fperazzi, PandaSE(29Apr10) (added load_2d_texture_array) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePool.h + * @author drose + * @date 2000-04-26 + * @author fperazzi, PandaSE + * @date 2010-04-29 + */ #ifndef TEXTUREPOOL_H #define TEXTUREPOOL_H @@ -29,24 +29,21 @@ class TexturePoolFilter; class BamCache; class BamCacheRecord; -//////////////////////////////////////////////////////////////////// -// Class : TexturePool -// Description : This is the preferred interface for loading textures -// from image files. It unifies all references to the -// same filename, so that multiple models that reference -// the same textures don't waste texture memory -// unnecessarily. -//////////////////////////////////////////////////////////////////// +/** + * This is the preferred interface for loading textures from image files. It + * unifies all references to the same filename, so that multiple models that + * reference the same textures don't waste texture memory unnecessarily. + */ class EXPCL_PANDA_GOBJ TexturePool { PUBLISHED: INLINE static bool has_texture(const Filename &filename); INLINE static bool verify_texture(const Filename &filename); - BLOCKING INLINE static Texture *load_texture(const Filename &filename, + BLOCKING INLINE static Texture *load_texture(const Filename &filename, int primary_file_num_channels = 0, bool read_mipmaps = false, const LoaderOptions &options = LoaderOptions()); BLOCKING INLINE static Texture *load_texture(const Filename &filename, - const Filename &alpha_filename, + const Filename &alpha_filename, int primary_file_num_channels = 0, int alpha_file_channel = 0, bool read_mipmaps = false, @@ -89,7 +86,7 @@ public: typedef Texture::MakeTextureFunc MakeTextureFunc; void register_texture_type(MakeTextureFunc *func, const string &extensions); void register_filter(TexturePoolFilter *filter); - + MakeTextureFunc *get_texture_type(const string &extension) const; void write_texture_types(ostream &out, int indent_level) const; @@ -99,12 +96,12 @@ private: TexturePool(); bool ns_has_texture(const Filename &orig_filename); - Texture *ns_load_texture(const Filename &orig_filename, + Texture *ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, bool read_mipmaps, const LoaderOptions &options); - Texture *ns_load_texture(const Filename &orig_filename, - const Filename &orig_alpha_filename, + Texture *ns_load_texture(const Filename &orig_filename, + const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel, bool read_mipmaps, @@ -133,14 +130,14 @@ private: void resolve_filename(Filename &new_filename, const Filename &orig_filename, bool read_mipmaps, const LoaderOptions &options); - void try_load_cache(PT(Texture) &tex, BamCache *cache, - const Filename &filename, PT(BamCacheRecord) &record, + void try_load_cache(PT(Texture) &tex, BamCache *cache, + const Filename &filename, PT(BamCacheRecord) &record, bool &compressed_cache_record, const LoaderOptions &options); void report_texture_unreadable(const Filename &filename) const; // Methods to invoke a TexturePoolFilter. - PT(Texture) pre_load(const Filename &orig_filename, + PT(Texture) pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel, @@ -172,5 +169,3 @@ private: #include "texturePool.I" #endif - - diff --git a/panda/src/gobj/texturePoolFilter.I b/panda/src/gobj/texturePoolFilter.I index 98d70477ca..1d4785da60 100644 --- a/panda/src/gobj/texturePoolFilter.I +++ b/panda/src/gobj/texturePoolFilter.I @@ -1,14 +1,12 @@ -// Filename: texturePoolFilter.I -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePoolFilter.I + * @author drose + * @date 2006-07-27 + */ diff --git a/panda/src/gobj/texturePoolFilter.cxx b/panda/src/gobj/texturePoolFilter.cxx index f3b0a69f30..6d752dd7c7 100644 --- a/panda/src/gobj/texturePoolFilter.cxx +++ b/panda/src/gobj/texturePoolFilter.cxx @@ -1,68 +1,55 @@ -// Filename: texturePoolFilter.cxx -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePoolFilter.cxx + * @author drose + * @date 2006-07-27 + */ #include "texturePoolFilter.h" TypeHandle TexturePoolFilter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TexturePoolFilter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexturePoolFilter:: ~TexturePoolFilter() { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePoolFilter::pre_load -// Access: Public, Virtual -// Description: This method is called before each texture is loaded -// from disk, via the TexturePool, for the first time. -// If this method returns NULL, then a new Texture will -// be allocated and loaded from disk normally by the -// TexturePool; otherwise, if it returns non-NULL, then -// that returned pointer will be used as the Texture for -// this filename. -//////////////////////////////////////////////////////////////////// +/** + * This method is called before each texture is loaded from disk, via the + * TexturePool, for the first time. If this method returns NULL, then a new + * Texture will be allocated and loaded from disk normally by the TexturePool; + * otherwise, if it returns non-NULL, then that returned pointer will be used + * as the Texture for this filename. + */ PT(Texture) TexturePoolFilter:: pre_load(const Filename &, const Filename &, int, int, bool, const LoaderOptions &) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePoolFilter::post_load -// Access: Public, Virtual -// Description: This method is called after each texture has been -// loaded from disk, via the TexturePool, for the first -// time. By the time this method is called, the Texture -// has already been fully read from disk. This method -// should return the Texture pointer that the -// TexturePool should actually return (usually it is the -// same as the pointer supplied). -//////////////////////////////////////////////////////////////////// +/** + * This method is called after each texture has been loaded from disk, via the + * TexturePool, for the first time. By the time this method is called, the + * Texture has already been fully read from disk. This method should return + * the Texture pointer that the TexturePool should actually return (usually it + * is the same as the pointer supplied). + */ PT(Texture) TexturePoolFilter:: post_load(Texture *tex) { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePoolFilter::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexturePoolFilter:: output(ostream &out) const { out << get_type(); diff --git a/panda/src/gobj/texturePoolFilter.h b/panda/src/gobj/texturePoolFilter.h index c82dace9e5..019b66fa9f 100644 --- a/panda/src/gobj/texturePoolFilter.h +++ b/panda/src/gobj/texturePoolFilter.h @@ -1,16 +1,15 @@ -// Filename: texturePoolFilter.h -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePoolFilter.h + * @author drose + * @date 2006-07-27 + */ #ifndef TEXTUREPOOLFILTER_H #define TEXTUREPOOLFILTER_H @@ -22,37 +21,33 @@ class LoaderOptions; -//////////////////////////////////////////////////////////////////// -// Class : TexturePoolFilter -// Description : This is an abstract base class, a placeholder for any -// number of different classes that may wish to -// implement an effect on every texture loaded from disk -// via the TexturePool. -// -// In practice, as of the time of this writing, only the -// TxaFileFilter (in pandatool) actually implements -// this. But other kinds of filters are possible. -// -// This filter, once registered, will get a callback and -// a chance to modify each texture as it is loaded from -// disk the first time. If more than one filter is -// registered, each will be called in sequence, in the -// order in which they were registered. -// -// The filter does not get called again if the texture -// is subsequently reloaded from disk. It is suggested -// that filters for which this might be a problem should -// call tex->set_keep_ram_image(true). -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class, a placeholder for any number of different + * classes that may wish to implement an effect on every texture loaded from + * disk via the TexturePool. + * + * In practice, as of the time of this writing, only the TxaFileFilter (in + * pandatool) actually implements this. But other kinds of filters are + * possible. + * + * This filter, once registered, will get a callback and a chance to modify + * each texture as it is loaded from disk the first time. If more than one + * filter is registered, each will be called in sequence, in the order in + * which they were registered. + * + * The filter does not get called again if the texture is subsequently + * reloaded from disk. It is suggested that filters for which this might be a + * problem should call tex->set_keep_ram_image(true). + */ class EXPCL_PANDA_GOBJ TexturePoolFilter : public TypedObject { public: virtual ~TexturePoolFilter(); - virtual PT(Texture) pre_load(const Filename &orig_filename, + virtual PT(Texture) pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, int primary_file_num_channels, int alpha_file_channel, - bool read_mipmaps, + bool read_mipmaps, const LoaderOptions &options); virtual PT(Texture) post_load(Texture *tex); diff --git a/panda/src/gobj/textureReloadRequest.I b/panda/src/gobj/textureReloadRequest.I index 5e18335b53..4cc22d6d9c 100644 --- a/panda/src/gobj/textureReloadRequest.I +++ b/panda/src/gobj/textureReloadRequest.I @@ -1,27 +1,23 @@ -// Filename: textureReloadRequest.I -// Created by: drose (12Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureReloadRequest.I + * @author drose + * @date 2008-08-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::Constructor -// Access: Published -// Description: Create a new TextureReloadRequest, and add it to the loader -// via load_async(), to begin an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * Create a new TextureReloadRequest, and add it to the loader via + * load_async(), to begin an asynchronous load. + */ INLINE TextureReloadRequest:: TextureReloadRequest(const string &name, - PreparedGraphicsObjects *pgo, Texture *texture, + PreparedGraphicsObjects *pgo, Texture *texture, bool allow_compressed) : AsyncTask(name), _pgo(pgo), @@ -33,45 +29,36 @@ TextureReloadRequest(const string &name, nassertv(_texture != (Texture *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::get_prepared_graphics_objects -// Access: Published -// Description: Returns the PreparedGraphicsObjects object associated with -// this asynchronous TextureReloadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PreparedGraphicsObjects object associated with this + * asynchronous TextureReloadRequest. + */ INLINE PreparedGraphicsObjects *TextureReloadRequest:: get_prepared_graphics_objects() const { return _pgo; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::get_texture -// Access: Published -// Description: Returns the Texture object associated with -// this asynchronous TextureReloadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Texture object associated with this asynchronous + * TextureReloadRequest. + */ INLINE Texture *TextureReloadRequest:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::get_allow_compressed -// Access: Published -// Description: Returns the "allow compressed" flag associated with -// this asynchronous TextureReloadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "allow compressed" flag associated with this asynchronous + * TextureReloadRequest. + */ INLINE bool TextureReloadRequest:: get_allow_compressed() const { return _allow_compressed; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + */ INLINE bool TextureReloadRequest:: is_ready() const { return _is_ready; diff --git a/panda/src/gobj/textureReloadRequest.cxx b/panda/src/gobj/textureReloadRequest.cxx index 05fd38e324..0b5964e2ef 100644 --- a/panda/src/gobj/textureReloadRequest.cxx +++ b/panda/src/gobj/textureReloadRequest.cxx @@ -1,27 +1,24 @@ -// Filename: textureReloadRequest.cxx -// Created by: drose (12Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureReloadRequest.cxx + * @author drose + * @date 2008-08-12 + */ #include "textureReloadRequest.h" #include "textureContext.h" TypeHandle TextureReloadRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureReloadRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, loads the one model. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, loads the one model. + */ AsyncTask::DoneStatus TextureReloadRequest:: do_task() { // Don't reload the texture if it doesn't need it. @@ -30,7 +27,7 @@ do_task() { if (delay != 0.0) { Thread::sleep(delay); } - + if (_texture->was_image_modified(_pgo)) { if (_allow_compressed) { _texture->get_ram_image(); @@ -38,12 +35,11 @@ do_task() { _texture->get_uncompressed_ram_image(); } - // Now that we've loaded the texture, we should ensure it - // actually gets prepared--even if it's no longer visible in the - // frame--or it may become a kind of a leak (if the texture is - // never rendered again on this GSG, we'll just end up carrying - // the texture memory in RAM forever, instead of dumping it as - // soon as it gets prepared). + // Now that we've loaded the texture, we should ensure it actually gets + // prepared--even if it's no longer visible in the frame--or it may + // become a kind of a leak (if the texture is never rendered again on + // this GSG, we'll just end up carrying the texture memory in RAM + // forever, instead of dumping it as soon as it gets prepared). _texture->prepare(_pgo); } } diff --git a/panda/src/gobj/textureReloadRequest.h b/panda/src/gobj/textureReloadRequest.h index 408800b3f6..92f0fdd1f8 100644 --- a/panda/src/gobj/textureReloadRequest.h +++ b/panda/src/gobj/textureReloadRequest.h @@ -1,16 +1,15 @@ -// Filename: textureReloadRequest.h -// Created by: drose (12Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureReloadRequest.h + * @author drose + * @date 2008-08-12 + */ #ifndef TEXTURERELOADREQUEST #define TEXTURERELOADREQUEST @@ -23,14 +22,12 @@ #include "pointerTo.h" #include "pmutex.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureReloadRequest -// Description : This loader request will call -// Texture::get_ram_image() in a sub-thread, to force -// the texture's image to be re-read from disk. It is -// used by GraphicsStateGuardian::async_reload_texture(), -// when get_incomplete_render() is true. -//////////////////////////////////////////////////////////////////// +/** + * This loader request will call Texture::get_ram_image() in a sub-thread, to + * force the texture's image to be re-read from disk. It is used by + * GraphicsStateGuardian::async_reload_texture(), when get_incomplete_render() + * is true. + */ class EXPCL_PANDA_GOBJ TextureReloadRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(TextureReloadRequest); @@ -39,21 +36,21 @@ PUBLISHED: INLINE TextureReloadRequest(const string &name, PreparedGraphicsObjects *pgo, Texture *texture, bool allow_compressed); - + INLINE PreparedGraphicsObjects *get_prepared_graphics_objects() const; INLINE Texture *get_texture() const; INLINE bool get_allow_compressed() const; INLINE bool is_ready() const; - + protected: virtual DoneStatus do_task(); - + private: PT(PreparedGraphicsObjects) _pgo; PT(Texture) _texture; bool _allow_compressed; bool _is_ready; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -67,7 +64,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/gobj/textureStage.I b/panda/src/gobj/textureStage.I index cb5c6c0504..b00d47d699 100644 --- a/panda/src/gobj/textureStage.I +++ b/panda/src/gobj/textureStage.I @@ -1,161 +1,128 @@ -// Filename: textureStage.I -// Created by: masad (15Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStage.I + * @author masad + * @date 2004-07-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::Copy Constructor -// Access: Published -// Description: Initialize the texture stage from other -//////////////////////////////////////////////////////////////////// +/** + * Initialize the texture stage from other + */ INLINE TextureStage:: TextureStage(TextureStage ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_name -// Access: Published -// Description: Returns the name of this texture stage -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this texture stage + */ INLINE const string &TextureStage:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_name -// Access: Published -// Description: Changes the name of this texture stage -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of this texture stage + */ INLINE void TextureStage:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_sort -// Access: Published -// Description: Changes the order in which the texture associated -// with this stage is rendered relative to the other -// texture stages. When geometry is rendered with -// multiple textures, the textures are rendered in order -// from the lowest sort number to the highest sort -// number. -// -// Also see set_priority(), which is used to select the -// most important textures for rendering when some must -// be omitted because of hardware limitations. -//////////////////////////////////////////////////////////////////// +/** + * Changes the order in which the texture associated with this stage is + * rendered relative to the other texture stages. When geometry is rendered + * with multiple textures, the textures are rendered in order from the lowest + * sort number to the highest sort number. + * + * Also see set_priority(), which is used to select the most important + * textures for rendering when some must be omitted because of hardware + * limitations. + */ INLINE void TextureStage:: set_sort(int sort) { _sort = sort; - // Update the global flag to indicate that all TextureAttribs in the - // world must now re-sort their lists. + // Update the global flag to indicate that all TextureAttribs in the world + // must now re-sort their lists. _sort_seq++; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_sort -// Access: Published -// Description: Returns the sort order of this texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort order of this texture stage. + */ INLINE int TextureStage:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_priority -// Access: Published -// Description: Changes the relative importance of the texture -// associated with this stage relative to the other -// texture stages that are applied simultaneously. -// -// This is unrelated to set_sort(), which controls the -// order in which multiple textures are applied. The -// priority number is used to decide which of the -// requested textures are to be selected for rendering -// when more textures are requested than the hardware -// will support. The highest-priority n textures are -// selected for rendering, and then rendered in order by -// their sort factor. -//////////////////////////////////////////////////////////////////// +/** + * Changes the relative importance of the texture associated with this stage + * relative to the other texture stages that are applied simultaneously. + * + * This is unrelated to set_sort(), which controls the order in which multiple + * textures are applied. The priority number is used to decide which of the + * requested textures are to be selected for rendering when more textures are + * requested than the hardware will support. The highest-priority n textures + * are selected for rendering, and then rendered in order by their sort + * factor. + */ INLINE void TextureStage:: set_priority(int priority) { _priority = priority; - // Update the global flag to indicate that all TextureAttribs in the - // world must now re-sort their lists. + // Update the global flag to indicate that all TextureAttribs in the world + // must now re-sort their lists. _sort_seq++; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_priority -// Access: Published -// Description: Returns the priority associated with this stage. -// -// This is specially helpful for cards that do not -// support more than n stages of multi-texturing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the priority associated with this stage. + * + * This is specially helpful for cards that do not support more than n stages + * of multi-texturing. + */ INLINE int TextureStage:: get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_texcoord_name -// Access: Published -// Description: Indicate which set of UV's this texture stage will -// use. Geometry may have any number of associated UV -// sets, each of which must have a unique name. -//////////////////////////////////////////////////////////////////// +/** + * Indicate which set of UV's this texture stage will use. Geometry may have + * any number of associated UV sets, each of which must have a unique name. + */ INLINE void TextureStage:: set_texcoord_name(InternalName *name) { _texcoord_name = name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_texcoord_name -// Access: Published -// Description: Indicate which set of UV's this texture stage will -// use. Geometry may have any number of associated UV -// sets, each of which must have a unique name. -//////////////////////////////////////////////////////////////////// +/** + * Indicate which set of UV's this texture stage will use. Geometry may have + * any number of associated UV sets, each of which must have a unique name. + */ INLINE void TextureStage:: set_texcoord_name(const string &name) { _texcoord_name = InternalName::get_texcoord_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_texcoord_name -// Access: Published -// Description: See set_texcoord_name. The default is -// InternalName::get_texcoord(). -//////////////////////////////////////////////////////////////////// +/** + * See set_texcoord_name. The default is InternalName::get_texcoord(). + */ INLINE InternalName *TextureStage:: get_texcoord_name() const { return _texcoord_name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_tangent_name -// Access: Published -// Description: Returns the set of tangents this texture stage will -// use. This is the same as get_texcoord_name(), -// except that the first part is "tangent". -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of tangents this texture stage will use. This is the same + * as get_texcoord_name(), except that the first part is "tangent". + */ INLINE InternalName *TextureStage:: get_tangent_name() const { if (_texcoord_name->get_parent() == NULL) { @@ -165,13 +132,10 @@ get_tangent_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_binormal_name -// Access: Published -// Description: Returns the set of binormals this texture stage will -// use. This is the same as get_binormal_name(), -// except that the first part is "binormal". -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of binormals this texture stage will use. This is the same + * as get_binormal_name(), except that the first part is "binormal". + */ INLINE InternalName *TextureStage:: get_binormal_name() const { if (_texcoord_name->get_parent() == NULL) { @@ -181,11 +145,9 @@ get_binormal_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_mode -// Access: Published -// Description: Set the mode of this texture stage -//////////////////////////////////////////////////////////////////// +/** + * Set the mode of this texture stage + */ INLINE void TextureStage:: set_mode(TextureStage::Mode mode) { _mode = mode; @@ -197,168 +159,134 @@ set_mode(TextureStage::Mode mode) { update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_mode -// Access: Published -// Description: Return the mode of this stage -//////////////////////////////////////////////////////////////////// +/** + * Return the mode of this stage + */ INLINE TextureStage::Mode TextureStage:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::is_fixed_function -// Access: Published -// Description: Returns true if the TextureStage is relevant to -// the classic fixed function pipeline. This excludes -// texture stages such as normal mapping and the like. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureStage is relevant to the classic fixed function + * pipeline. This excludes texture stages such as normal mapping and the + * like. + */ INLINE bool TextureStage:: is_fixed_function() const { return (_mode < M_normal); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_color -// Access: Published -// Description: Set the color for this stage -//////////////////////////////////////////////////////////////////// +/** + * Set the color for this stage + */ INLINE void TextureStage:: set_color(const LColor &color) { _color = color; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_color -// Access: Published -// Description: return the color for this stage -//////////////////////////////////////////////////////////////////// +/** + * return the color for this stage + */ INLINE LColor TextureStage:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_rgb_scale -// Access: Published -// Description: Sets an additional factor that will scale all three -// r, g, b components after the texture has been -// applied. This is used only when the mode is -// CM_combine. -// -// The only legal values are 1, 2, or 4. -//////////////////////////////////////////////////////////////////// +/** + * Sets an additional factor that will scale all three r, g, b components + * after the texture has been applied. This is used only when the mode is + * CM_combine. + * + * The only legal values are 1, 2, or 4. + */ INLINE void TextureStage:: set_rgb_scale(int rgb_scale) { nassertv(rgb_scale == 1 || rgb_scale == 2 || rgb_scale == 4); _rgb_scale = rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_rgb_scale -// Access: Published -// Description: See set_rgb_scale(). -//////////////////////////////////////////////////////////////////// +/** + * See set_rgb_scale(). + */ INLINE int TextureStage:: get_rgb_scale() const { return _rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_alpha_scale -// Access: Published -// Description: Sets an additional factor that will scale the -// alpha component after the texture has been applied. -// This is used only when the mode is CM_combine. -// -// The only legal values are 1, 2, or 4. -//////////////////////////////////////////////////////////////////// +/** + * Sets an additional factor that will scale the alpha component after the + * texture has been applied. This is used only when the mode is CM_combine. + * + * The only legal values are 1, 2, or 4. + */ INLINE void TextureStage:: set_alpha_scale(int alpha_scale) { nassertv(alpha_scale == 1 || alpha_scale == 2 || alpha_scale == 4); _alpha_scale = alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_alpha_scale -// Access: Published -// Description: See set_alpha_scale(). -//////////////////////////////////////////////////////////////////// +/** + * See set_alpha_scale(). + */ INLINE int TextureStage:: get_alpha_scale() const { return _alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_saved_result -// Access: Published -// Description: Sets the saved_result flag. When this is true, the -// output of this stage will be supplied as the -// "last_saved_result" source for any future stages, -// until the next TextureStage with a saved_result set -// true is encountered. -// -// This can be used to reuse the results of this texture -// stage as input to more than one stage later in the -// pipeline. -// -// The last texture in the pipeline (the one with the -// highest sort value) should not have this flag set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the saved_result flag. When this is true, the output of this stage + * will be supplied as the "last_saved_result" source for any future stages, + * until the next TextureStage with a saved_result set true is encountered. + * + * This can be used to reuse the results of this texture stage as input to + * more than one stage later in the pipeline. + * + * The last texture in the pipeline (the one with the highest sort value) + * should not have this flag set. + */ INLINE void TextureStage:: set_saved_result(bool saved_result) { _saved_result = saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_saved_result -// Access: Published -// Description: Returns the current setting of the saved_result flag. -// See set_saved_result(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the saved_result flag. See + * set_saved_result(). + */ INLINE bool TextureStage:: get_saved_result() const { return _saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_tex_view_offset -// Access: Published -// Description: Sets the tex_view_offset value. This is used only -// when a special multiview texture is bound to the -// TextureStage, and it selects the particular view of -// the texture that is to be used. -// -// This value is added to the similar parameter on -// DisplayRegion to derive the final texture view index -// that is selected for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Sets the tex_view_offset value. This is used only when a special multiview + * texture is bound to the TextureStage, and it selects the particular view of + * the texture that is to be used. + * + * This value is added to the similar parameter on DisplayRegion to derive the + * final texture view index that is selected for rendering. + */ INLINE void TextureStage:: set_tex_view_offset(int tex_view_offset) { _tex_view_offset = tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_tex_view_offset -// Access: Published -// Description: Returns the current setting of the tex_view_offset. -// See set_tex_view_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the tex_view_offset. See + * set_tex_view_offset(). + */ INLINE int TextureStage:: get_tex_view_offset() const { return _tex_view_offset; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_rgb -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a one-parameter operation. Specifically, -// this is CM_replace only. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a one-parameter + * operation. Specifically, this is CM_replace only. + */ INLINE void TextureStage:: -set_combine_rgb(CombineMode mode, +set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0) { nassertv(get_expected_num_combine_operands(mode) == 1); nassertv(operand_valid_for_rgb(operand0)); @@ -375,16 +303,13 @@ set_combine_rgb(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_rgb -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a two-parameter operation. Specifically, -// this is everything except for CM_replace and -// CM_interpolate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a two-parameter + * operation. Specifically, this is everything except for CM_replace and + * CM_interpolate. + */ INLINE void TextureStage:: -set_combine_rgb(CombineMode mode, +set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1) { nassertv(get_expected_num_combine_operands(mode) == 2); @@ -403,15 +328,12 @@ set_combine_rgb(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_rgb -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a one-parameter operation. Specifically, -// this is CM_interpolate only. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a one-parameter + * operation. Specifically, this is CM_interpolate only. + */ INLINE void TextureStage:: -set_combine_rgb(CombineMode mode, +set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2) { @@ -432,97 +354,77 @@ set_combine_rgb(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_mode -// Access: Published -// Description: Get the combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get the combine_rgb_mode + */ INLINE TextureStage::CombineMode TextureStage:: get_combine_rgb_mode() const { return _combine_rgb_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_num_combine_rgb_operands -// Access: Published -// Description: Returns the number of meaningful operands that may be -// retrieved via get_combine_rgb_sourceN() and -// get_combine_rgb_operandN(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of meaningful operands that may be retrieved via + * get_combine_rgb_sourceN() and get_combine_rgb_operandN(). + */ INLINE int TextureStage:: get_num_combine_rgb_operands() const { return _num_combine_rgb_operands; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_source0 -// Access: Published -// Description: Get source0 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source0 of combine_rgb_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_rgb_source0() const { return _combine_rgb_source0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_operand0 -// Access: Published -// Description: Get operand0 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand0 of combine_rgb_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_rgb_operand0() const { return _combine_rgb_operand0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_source1 -// Access: Published -// Description: Get source1 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source1 of combine_rgb_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_rgb_source1() const { return _combine_rgb_source1; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_operand1 -// Access: Published -// Description: Get operand1 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand1 of combine_rgb_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_rgb_operand1() const { return _combine_rgb_operand1; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_source2 -// Access: Published -// Description: Get source2 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source2 of combine_rgb_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_rgb_source2() const { return _combine_rgb_source2; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_rgb_operand2 -// Access: Published -// Description: Get operand2 of combine_rgb_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand2 of combine_rgb_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_rgb_operand2() const { return _combine_rgb_operand2; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_alpha -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a one-parameter operation. Specifically, -// this is CM_replace only. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a one-parameter + * operation. Specifically, this is CM_replace only. + */ INLINE void TextureStage:: -set_combine_alpha(CombineMode mode, +set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0) { nassertv(get_expected_num_combine_operands(mode) == 1); nassertv(operand_valid_for_alpha(operand0)); @@ -539,16 +441,13 @@ set_combine_alpha(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_alpha -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a two-parameter operation. Specifically, -// this is everything except for CM_replace and -// CM_interpolate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a two-parameter + * operation. Specifically, this is everything except for CM_replace and + * CM_interpolate. + */ INLINE void TextureStage:: -set_combine_alpha(CombineMode mode, +set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1) { nassertv(get_expected_num_combine_operands(mode) == 2); @@ -567,15 +466,12 @@ set_combine_alpha(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::set_combine_alpha -// Access: Published -// Description: Specifies any of the CombineMode values that -// represent a one-parameter operation. Specifically, -// this is CM_interpolate only. -//////////////////////////////////////////////////////////////////// +/** + * Specifies any of the CombineMode values that represent a one-parameter + * operation. Specifically, this is CM_interpolate only. + */ INLINE void TextureStage:: -set_combine_alpha(CombineMode mode, +set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2) { @@ -596,172 +492,136 @@ set_combine_alpha(CombineMode mode, update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha -// Access: Published -// Description: Get combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get combine_alpha_mode + */ INLINE TextureStage::CombineMode TextureStage:: get_combine_alpha_mode() const { return _combine_alpha_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_num_combine_alpha_operands -// Access: Published -// Description: Returns the number of meaningful operands that may be -// retrieved via get_combine_alpha_sourceN() and -// get_combine_alpha_operandN(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of meaningful operands that may be retrieved via + * get_combine_alpha_sourceN() and get_combine_alpha_operandN(). + */ INLINE int TextureStage:: get_num_combine_alpha_operands() const { return _num_combine_alpha_operands; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_source0 -// Access: Published -// Description: Get source0 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source0 of combine_alpha_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_alpha_source0() const { return _combine_alpha_source0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_operand0 -// Access: Published -// Description: Get operand0 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand0 of combine_alpha_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_alpha_operand0() const { return _combine_alpha_operand0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_source1 -// Access: Published -// Description: Get source1 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source1 of combine_alpha_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_alpha_source1() const { return _combine_alpha_source1; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_operand1 -// Access: Published -// Description: Get operand1 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand1 of combine_alpha_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_alpha_operand1() const { return _combine_alpha_operand1; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_source2 -// Access: Published -// Description: Get source2 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get source2 of combine_alpha_mode + */ INLINE TextureStage::CombineSource TextureStage:: get_combine_alpha_source2() const { return _combine_alpha_source2; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_combine_alpha_operand2 -// Access: Published -// Description: Get operand2 of combine_alpha_mode -//////////////////////////////////////////////////////////////////// +/** + * Get operand2 of combine_alpha_mode + */ INLINE TextureStage::CombineOperand TextureStage:: get_combine_alpha_operand2() const { return _combine_alpha_operand2; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::involves_color_scale -// Access: Published -// Description: Returns true if the TextureStage is affected by the -// setting of the current ColorScaleAttrib, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureStage is affected by the setting of the current + * ColorScaleAttrib, false otherwise. + */ INLINE bool TextureStage:: involves_color_scale() const { return _involves_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::uses_color -// Access: Published -// Description: Returns true if the TextureStage makes use of -// whatever color is specified in set_color(), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureStage makes use of whatever color is specified + * in set_color(), false otherwise. + */ INLINE bool TextureStage:: uses_color() const { return _uses_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::uses_primary_color -// Access: Published -// Description: Returns true if the TextureStage makes use of -// the CS_primary_color combine source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureStage makes use of the CS_primary_color combine + * source. + */ INLINE bool TextureStage:: uses_primary_color() const { return _uses_primary_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::uses_last_saved_result -// Access: Published -// Description: Returns true if the TextureStage makes use of -// the CS_primary_color combine source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureStage makes use of the CS_primary_color combine + * source. + */ INLINE bool TextureStage:: uses_last_saved_result() const { return _uses_last_saved_result; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextureStage:: operator == (const TextureStage &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextureStage:: operator != (const TextureStage &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextureStage:: operator < (const TextureStage &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_default -// Access: Published, Static -// Description: Returns the default TextureStage that will be used -// for all texturing that does not name a particular -// stage. This generally handles the normal -// single-texture case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default TextureStage that will be used for all texturing that + * does not name a particular stage. This generally handles the normal + * single-texture case. + */ INLINE TextureStage *TextureStage:: get_default() { if (_default_stage == (TextureStage *)NULL) { @@ -770,30 +630,24 @@ get_default() { return _default_stage; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_sort_seq -// Access: Public, Static -// Description: Returns a global sequence number that is incremented -// any time any TextureStage in the world changes sort -// or priority. This is used by TextureAttrib to -// determine when it is necessary to re-sort its -// internal array of stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns a global sequence number that is incremented any time any + * TextureStage in the world changes sort or priority. This is used by + * TextureAttrib to determine when it is necessary to re-sort its internal + * array of stages. + */ INLINE UpdateSeq TextureStage:: get_sort_seq() { return _sort_seq; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::update_color_flags -// Access: Private -// Description: Updates _uses_color, _involves_color_scale, -// _uses_primary_color and _uses_last_saved_result -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Updates _uses_color, _involves_color_scale, _uses_primary_color and + * _uses_last_saved_result appropriately. + */ INLINE void TextureStage:: update_color_flags() { - _involves_color_scale = + _involves_color_scale = (_mode == M_blend_color_scale || (_mode == M_combine && (_combine_rgb_source0 == CS_constant_color_scale || @@ -802,9 +656,9 @@ update_color_flags() { _combine_alpha_source0 == CS_constant_color_scale || _combine_alpha_source1 == CS_constant_color_scale || _combine_alpha_source2 == CS_constant_color_scale))); - - _uses_color = - (_involves_color_scale || + + _uses_color = + (_involves_color_scale || _mode == M_blend || (_mode == M_combine && (_combine_rgb_source0 == CS_constant || @@ -814,7 +668,7 @@ update_color_flags() { _combine_alpha_source1 == CS_constant || _combine_alpha_source2 == CS_constant))); - _uses_primary_color = + _uses_primary_color = (_mode == M_combine && (_combine_rgb_source0 == CS_primary_color || _combine_rgb_source1 == CS_primary_color || @@ -823,7 +677,7 @@ update_color_flags() { _combine_alpha_source1 == CS_primary_color || _combine_alpha_source2 == CS_primary_color)); - _uses_last_saved_result = + _uses_last_saved_result = (_mode == M_combine && (_combine_rgb_source0 == CS_last_saved_result || _combine_rgb_source1 == CS_last_saved_result || diff --git a/panda/src/gobj/textureStage.cxx b/panda/src/gobj/textureStage.cxx index f235c4e5e5..96edb74e6d 100644 --- a/panda/src/gobj/textureStage.cxx +++ b/panda/src/gobj/textureStage.cxx @@ -1,16 +1,15 @@ -// Filename: textureStage.cxx -// Created by: MAsaduzz (16Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStage.cxx + * @author MAsaduzz + * @date 2004-07-16 + */ #include "textureStage.h" #include "internalName.h" @@ -22,11 +21,9 @@ UpdateSeq TextureStage::_sort_seq; TypeHandle TextureStage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::Constructor -// Access: Published -// Description: Initialize the texture stage at construction -//////////////////////////////////////////////////////////////////// +/** + * Initialize the texture stage at construction + */ TextureStage:: TextureStage(const string &name) { _name = name; @@ -60,11 +57,9 @@ TextureStage(const string &name) { _involves_color_scale = false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operator = -// Access: Published -// Description: just copy the members of other to this -//////////////////////////////////////////////////////////////////// +/** + * just copy the members of other to this + */ void TextureStage:: operator = (const TextureStage &other) { _name = other._name; @@ -97,37 +92,32 @@ operator = (const TextureStage &other) { _involves_color_scale = other._involves_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureStage:: ~TextureStage() { } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::compare_to -// Access: Published -// Description: Returns a number less than zero if this TextureStage -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. The -// sorting order is arbitrary and largely meaningless, -// except to differentiate different stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this TextureStage sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * The sorting order is arbitrary and largely meaningless, except to + * differentiate different stages. + */ int TextureStage:: compare_to(const TextureStage &other) const { // We put the sort parameter first, so that we sorting a list of - // TextureStages will happen to put them in sorted order, even - // though we don't promise to do that. But there's no reason not to - // do so, and it might be more convenient for the developer. + // TextureStages will happen to put them in sorted order, even though we + // don't promise to do that. But there's no reason not to do so, and it + // might be more convenient for the developer. if (get_sort() != other.get_sort()) { return get_sort() < other.get_sort() ? -1 : 1; } - // The remaining parameters are arbitrary. We start with the name, - // because that's most likely to be consistent between similar - // TextureStages, and different between different TextureStages. + // The remaining parameters are arbitrary. We start with the name, because + // that's most likely to be consistent between similar TextureStages, and + // different between different TextureStages. int compare = strcmp(get_name().c_str(), other.get_name().c_str()); if (compare != 0) { return compare; @@ -158,7 +148,7 @@ compare_to(const TextureStage &other) const { if (get_combine_rgb_mode() != other.get_combine_rgb_mode()) { return get_combine_rgb_mode() < other.get_combine_rgb_mode() ? -1 : 1; } - + if (get_num_combine_rgb_operands() != other.get_num_combine_rgb_operands()) { return get_num_combine_rgb_operands() < other.get_num_combine_rgb_operands() ? -1 : 1; } @@ -189,7 +179,7 @@ compare_to(const TextureStage &other) const { if (get_combine_alpha_mode() != other.get_combine_alpha_mode()) { return get_combine_alpha_mode() < other.get_combine_alpha_mode() ? -1 : 1; } - + if (get_num_combine_alpha_operands() != other.get_num_combine_alpha_operands()) { return get_num_combine_alpha_operands() < other.get_num_combine_alpha_operands() ? -1 : 1; } @@ -222,18 +212,16 @@ compare_to(const TextureStage &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::Destructor -// Access: Published -// Description: Writes the details of this stage -//////////////////////////////////////////////////////////////////// +/** + * Writes the details of this stage + */ void TextureStage:: write(ostream &out) const { out << "TextureStage " << get_name() << ", sort = " << get_sort() << ", priority = " << get_priority() << "\n" << " texcoords = " << get_texcoord_name()->get_name() << ", mode = " << get_mode() << ", color = " << get_color() << ", scale = " << get_rgb_scale() << ", " << get_alpha_scale() - << ", saved_result = " << get_saved_result() + << ", saved_result = " << get_saved_result() << ", tex_view_offset = " << get_tex_view_offset() << "\n"; if (get_mode() == M_combine) { @@ -266,22 +254,18 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::Destructor -// Access: Published -// Description: Just a single line output -//////////////////////////////////////////////////////////////////// +/** + * Just a single line output + */ void TextureStage:: output(ostream &out) const { out << "TextureStage " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::get_expected_num_combine_operands -// Access: Private, Static -// Description: Returns the number of combine operands expected with -// the indicated combine mode (0, 1, 2, or 3). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of combine operands expected with the indicated combine + * mode (0, 1, 2, or 3). + */ int TextureStage:: get_expected_num_combine_operands(TextureStage::CombineMode cm) { switch (cm) { @@ -306,12 +290,10 @@ get_expected_num_combine_operands(TextureStage::CombineMode cm) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operand_valid_for_rgb -// Access: Private, Static -// Description: Returns true if the indicated CombineOperand is valid -// for one of the RGB modes, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated CombineOperand is valid for one of the RGB + * modes, false otherwise. + */ bool TextureStage:: operand_valid_for_rgb(TextureStage::CombineOperand co) { switch (co) { @@ -328,12 +310,10 @@ operand_valid_for_rgb(TextureStage::CombineOperand co) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::operand_valid_for_alpha -// Access: Private, Static -// Description: Returns true if the indicated CombineOperand is valid -// for one of the alpha modes, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated CombineOperand is valid for one of the alpha + * modes, false otherwise. + */ bool TextureStage:: operand_valid_for_alpha(TextureStage::CombineOperand co) { switch (co) { @@ -350,21 +330,17 @@ operand_valid_for_alpha(TextureStage::CombineOperand co) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a TextureStage object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a TextureStage object + */ void TextureStage:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_TextureStage); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::make_TextureStage -// Access: Protected -// Description: Factory method to generate a TextureStage object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a TextureStage object + */ TypedWritable* TextureStage:: make_TextureStage(const FactoryParams ¶ms) { DatagramIterator scan; @@ -382,14 +358,11 @@ make_TextureStage(const FactoryParams ¶ms) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void TextureStage:: fillin(DatagramIterator &scan, BamReader *manager) { _name = scan.get_string(); @@ -430,13 +403,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { update_color_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TextureStage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -446,12 +416,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStage::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void TextureStage:: write_datagram(BamWriter *manager, Datagram &me) { // These properties are read in again by fillin(), above. @@ -464,14 +432,14 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_int32(_priority); manager->write_pointer(me, _texcoord_name); - + me.add_uint8(_mode); _color.write_datagram(me); me.add_uint8(_rgb_scale); me.add_uint8(_alpha_scale); me.add_bool(_saved_result); me.add_int32(_tex_view_offset); - + me.add_uint8(_combine_rgb_mode); me.add_uint8(_num_combine_rgb_operands); me.add_uint8(_combine_rgb_source0); @@ -480,7 +448,7 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_uint8(_combine_rgb_operand1); me.add_uint8(_combine_rgb_source2); me.add_uint8(_combine_rgb_operand2); - + me.add_uint8(_combine_alpha_mode); me.add_uint8(_num_combine_alpha_operands); me.add_uint8(_combine_alpha_source0); @@ -518,10 +486,10 @@ operator << (ostream &out, TextureStage::Mode mode) { case TextureStage::M_modulate_glow: return out << "modulate_glow"; - + case TextureStage::M_modulate_gloss: return out << "modulate_gloss"; - + case TextureStage::M_normal: return out << "normal"; @@ -530,13 +498,13 @@ operator << (ostream &out, TextureStage::Mode mode) { case TextureStage::M_glow: return out << "glow"; - + case TextureStage::M_gloss: return out << "gloss"; case TextureStage::M_height: return out << "height"; - + case TextureStage::M_selector: return out << "selector"; diff --git a/panda/src/gobj/textureStage.h b/panda/src/gobj/textureStage.h index 518ee14dfa..4ba5835910 100644 --- a/panda/src/gobj/textureStage.h +++ b/panda/src/gobj/textureStage.h @@ -1,16 +1,15 @@ -// Filename: textureStage.h -// Created by: drose (14Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStage.h + * @author drose + * @date 2004-07-14 + */ #ifndef TEXTURESTAGE_H #define TEXTURESTAGE_H @@ -25,16 +24,13 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TextureStage -// Description : Defines the properties of a named stage of the -// multitexture pipeline. The TextureAttrib will -// associated a number of these stages with Texture -// objects, and the GSG will render geometry by sorting -// all of the currently active TextureStages in order -// and then issuing the appropriate rendering calls to -// activate them. -//////////////////////////////////////////////////////////////////// +/** + * Defines the properties of a named stage of the multitexture pipeline. The + * TextureAttrib will associated a number of these stages with Texture + * objects, and the GSG will render geometry by sorting all of the currently + * active TextureStages in order and then issuing the appropriate rendering + * calls to activate them. + */ class EXPCL_PANDA_GOBJ TextureStage : public TypedWritableReferenceCount { PUBLISHED: explicit TextureStage(const string &name); @@ -77,8 +73,7 @@ PUBLISHED: CM_interpolate, CM_subtract, - // The following are valid only for combine_rgb, not - // combine_alpha. + // The following are valid only for combine_rgb, not combine_alpha. CM_dot3_rgb, CM_dot3_rgba, }; @@ -136,12 +131,12 @@ PUBLISHED: INLINE void set_tex_view_offset(int tex_view_offset); INLINE int get_tex_view_offset() const; - INLINE void set_combine_rgb(CombineMode mode, + INLINE void set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0); - INLINE void set_combine_rgb(CombineMode mode, + INLINE void set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1); - INLINE void set_combine_rgb(CombineMode mode, + INLINE void set_combine_rgb(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2); @@ -154,12 +149,12 @@ PUBLISHED: INLINE CombineSource get_combine_rgb_source2() const; INLINE CombineOperand get_combine_rgb_operand2() const; - INLINE void set_combine_alpha(CombineMode mode, + INLINE void set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0); - INLINE void set_combine_alpha(CombineMode mode, + INLINE void set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1); - INLINE void set_combine_alpha(CombineMode mode, + INLINE void set_combine_alpha(CombineMode mode, CombineSource source0, CombineOperand operand0, CombineSource source1, CombineOperand operand1, CombineSource source2, CombineOperand operand2); diff --git a/panda/src/gobj/textureStagePool.I b/panda/src/gobj/textureStagePool.I index f3de30f915..a88d5e1561 100644 --- a/panda/src/gobj/textureStagePool.I +++ b/panda/src/gobj/textureStagePool.I @@ -1,114 +1,91 @@ -// Filename: textureStagePool.I -// Created by: drose (03May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStagePool.I + * @author drose + * @date 2010-05-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::get_stage -// Access: Public, Static -// Description: Returns a TextureStage pointer that represents the -// same TextureStage described by temp, except that it is a -// shared pointer. -// -// Each call to get_stage() passing an equivalent -// TextureStage pointer will return the same shared pointer. -// -// If you modify the shared pointer, it will -// automatically disassociate it from the pool. -// -// Also, the return value may be a different pointer -// than that passed in, or it may be the same pointer. -// In either case, the passed in pointer has now been -// sacrificed to the greater good and should not be used -// again (like any other PointerTo, it will be freed -// when the last reference count is removed). -//////////////////////////////////////////////////////////////////// +/** + * Returns a TextureStage pointer that represents the same TextureStage + * described by temp, except that it is a shared pointer. + * + * Each call to get_stage() passing an equivalent TextureStage pointer will + * return the same shared pointer. + * + * If you modify the shared pointer, it will automatically disassociate it + * from the pool. + * + * Also, the return value may be a different pointer than that passed in, or + * it may be the same pointer. In either case, the passed in pointer has now + * been sacrificed to the greater good and should not be used again (like any + * other PointerTo, it will be freed when the last reference count is + * removed). + */ INLINE TextureStage *TextureStagePool:: get_stage(TextureStage *temp) { return get_global_ptr()->ns_get_stage(temp); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::release_stage -// Access: Published, Static -// Description: Removes the indicated TextureStage from the pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated TextureStage from the pool. + */ INLINE void TextureStagePool:: release_stage(TextureStage *stage) { get_global_ptr()->ns_release_stage(stage); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::release_all_stages -// Access: Published, Static -// Description: Releases all TextureStages in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all TextureStages in the pool and restores the pool to the empty + * state. + */ INLINE void TextureStagePool:: release_all_stages() { get_global_ptr()->ns_release_all_stages(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::set_mode -// Access: Published, Static -// Description: Specifies the fundamental operating mode of the -// TextureStagePool. -// -// If this is M_none, each call to get_stage() returns -// the same TextureStage pointer that was passed in (the -// pool is effectively disabled). If this is M_name, -// each call to get_stage() returns the last -// TextureStage passed in with the same name, whether it -// has different properties or not. If this is -// M_unique, then each call to get_stage() returns only -// TextureStages with identical properties. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the fundamental operating mode of the TextureStagePool. + * + * If this is M_none, each call to get_stage() returns the same TextureStage + * pointer that was passed in (the pool is effectively disabled). If this is + * M_name, each call to get_stage() returns the last TextureStage passed in + * with the same name, whether it has different properties or not. If this is + * M_unique, then each call to get_stage() returns only TextureStages with + * identical properties. + */ INLINE void TextureStagePool:: set_mode(TextureStagePool::Mode mode) { get_global_ptr()->ns_set_mode(mode); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::get_mode -// Access: Published, Static -// Description: Returns the fundamental operating mode of the -// TextureStagePool. See set_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the fundamental operating mode of the TextureStagePool. See + * set_mode(). + */ INLINE TextureStagePool::Mode TextureStagePool:: get_mode() { return get_global_ptr()->ns_get_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::garbage_collect -// Access: Public, Static -// Description: Releases only those TextureStages in the pool that have a -// reference count of exactly 1; i.e. only those -// TextureStages that are not being used outside of the pool. -// Returns the number of TextureStages released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those TextureStages in the pool that have a reference count + * of exactly 1; i.e. only those TextureStages that are not being used + * outside of the pool. Returns the number of TextureStages released. + */ INLINE int TextureStagePool:: garbage_collect() { return get_global_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::list_contents -// Access: Public, Static -// Description: Lists the contents of the TextureStage pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the TextureStage pool to the indicated output stream. + */ INLINE void TextureStagePool:: list_contents(ostream &out) { get_global_ptr()->ns_list_contents(out); diff --git a/panda/src/gobj/textureStagePool.cxx b/panda/src/gobj/textureStagePool.cxx index 413abe19a8..2d9b33a036 100644 --- a/panda/src/gobj/textureStagePool.cxx +++ b/panda/src/gobj/textureStagePool.cxx @@ -1,17 +1,15 @@ -// Filename: textureStagePool.cxx -// Created by: drose (03May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStagePool.cxx + * @author drose + * @date 2010-05-03 + */ #include "textureStagePool.h" #include "config_gobj.h" @@ -22,24 +20,19 @@ TextureStagePool *TextureStagePool::_global_ptr = (TextureStagePool *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::write -// Access: Published, Static -// Description: Lists the contents of the TextureStage pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the TextureStage pool to the indicated output stream. + */ void TextureStagePool:: write(ostream &out) { get_global_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one TextureStagePool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one TextureStagePool in the universe and it constructs + * itself. + */ TextureStagePool:: TextureStagePool() { ConfigVariableEnum texture_stage_pool_mode @@ -51,11 +44,9 @@ TextureStagePool() { _mode = texture_stage_pool_mode.get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_get_stage -// Access: Public -// Description: The nonstatic implementation of get_stage(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of get_stage(). + */ TextureStage *TextureStagePool:: ns_get_stage(TextureStage *temp) { MutexHolder holder(_lock); @@ -71,8 +62,7 @@ ns_get_stage(TextureStage *temp) { ni = _stages_by_name.insert(StagesByName::value_type(temp->get_name(), temp)).first; } else { if ((*ni).first != (*ni).second->get_name()) { - // The pointer no longer matches the original name. Save a - // new one. + // The pointer no longer matches the original name. Save a new one. (*ni).second = temp; } } @@ -99,11 +89,9 @@ ns_get_stage(TextureStage *temp) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_release_stage -// Access: Private -// Description: The nonstatic implementation of release_stage(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_stage(). + */ void TextureStagePool:: ns_release_stage(TextureStage *temp) { MutexHolder holder(_lock); @@ -125,11 +113,9 @@ ns_release_stage(TextureStage *temp) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_release_all_stages -// Access: Private -// Description: The nonstatic implementation of release_all_stages(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_stages(). + */ void TextureStagePool:: ns_release_all_stages() { MutexHolder holder(_lock); @@ -138,11 +124,9 @@ ns_release_all_stages() { _stages_by_properties.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_set_mode -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureStagePool:: ns_set_mode(TextureStagePool::Mode mode) { MutexHolder holder(_lock); @@ -154,11 +138,9 @@ ns_set_mode(TextureStagePool::Mode mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_get_mode -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureStagePool::Mode TextureStagePool:: ns_get_mode() { MutexHolder holder(_lock); @@ -166,11 +148,9 @@ ns_get_mode() { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int TextureStagePool:: ns_garbage_collect() { MutexHolder holder(_lock); @@ -183,7 +163,7 @@ ns_garbage_collect() { { int num_released = 0; StagesByName new_set; - + StagesByName::iterator ni; for (ni = _stages_by_name.begin(); ni != _stages_by_name.end(); ++ni) { const string &name = (*ni).first; @@ -198,7 +178,7 @@ ns_garbage_collect() { new_set.insert(new_set.end(), *ni); } } - + _stages_by_name.swap(new_set); return num_released; } @@ -207,7 +187,7 @@ ns_garbage_collect() { { int num_released = 0; StagesByProperties new_set; - + StagesByProperties::iterator si; for (si = _stages_by_properties.begin(); si != _stages_by_properties.end(); ++si) { const TextureStage *ts1 = (*si).first; @@ -222,7 +202,7 @@ ns_garbage_collect() { new_set.insert(new_set.end(), *si); } } - + _stages_by_properties.swap(new_set); return num_released; } @@ -231,11 +211,9 @@ ns_garbage_collect() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void TextureStagePool:: ns_list_contents(ostream &out) const { MutexHolder holder(_lock); @@ -274,12 +252,10 @@ ns_list_contents(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::get_global_ptr -// Access: Private, Static -// Description: Initializes and/or returns the global pointer to the -// one TextureStagePool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one TextureStagePool + * object in the system. + */ TextureStagePool *TextureStagePool:: get_global_ptr() { if (_global_ptr == (TextureStagePool *)NULL) { @@ -288,10 +264,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::Mode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, TextureStagePool::Mode mode) { switch (mode) { @@ -308,10 +283,9 @@ operator << (ostream &out, TextureStagePool::Mode mode) { return out << "**invalid mode (" << (int)mode << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStagePool::Mode input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, TextureStagePool::Mode &mode) { string word; diff --git a/panda/src/gobj/textureStagePool.h b/panda/src/gobj/textureStagePool.h index f34f10af70..5dc9012ea9 100644 --- a/panda/src/gobj/textureStagePool.h +++ b/panda/src/gobj/textureStagePool.h @@ -1,16 +1,15 @@ -// Filename: textureStagePool.h -// Created by: drose (03May10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStagePool.h + * @author drose + * @date 2010-05-03 + */ #ifndef TEXTURESTAGEPOOL_H #define TEXTURESTAGEPOOL_H @@ -21,17 +20,15 @@ #include "pmutex.h" #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureStagePool -// Description : The TextureStagePool (there is only one in the universe) -// serves to unify different pointers to the same -// TextureStage, mainly to help developers use a common -// pointer to access things that are loaded from -// different model files. -// -// It runs in one of three different modes, according to -// set_mode(). See that method for more information. -//////////////////////////////////////////////////////////////////// +/** + * The TextureStagePool (there is only one in the universe) serves to unify + * different pointers to the same TextureStage, mainly to help developers use + * a common pointer to access things that are loaded from different model + * files. + * + * It runs in one of three different modes, according to set_mode(). See that + * method for more information. + */ class EXPCL_PANDA_GOBJ TextureStagePool { PUBLISHED: enum Mode { @@ -71,9 +68,9 @@ private: Mutex _lock; // We store a map of CPT(TextureStage) to PT(TextureStage). These are two - // equivalent structures, but different pointers. The first pointer - // never leaves this class. If the second pointer changes value, - // we'll notice it and return a new one. + // equivalent structures, but different pointers. The first pointer never + // leaves this class. If the second pointer changes value, we'll notice it + // and return a new one. typedef pmap > StagesByProperties; StagesByProperties _stages_by_properties; @@ -89,5 +86,3 @@ EXPCL_PANDA_GOBJ istream &operator >> (istream &in, TextureStagePool::Mode &mode #include "textureStagePool.I" #endif - - diff --git a/panda/src/gobj/timerQueryContext.I b/panda/src/gobj/timerQueryContext.I index 72b79b58e9..a542e96855 100644 --- a/panda/src/gobj/timerQueryContext.I +++ b/panda/src/gobj/timerQueryContext.I @@ -1,23 +1,19 @@ -// Filename: timerQueryContext.I -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timerQueryContext.I + * @author rdb + * @date 2014-08-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TimerQueryContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TimerQueryContext:: TimerQueryContext(int pstats_index) : _pstats_index(pstats_index), diff --git a/panda/src/gobj/timerQueryContext.cxx b/panda/src/gobj/timerQueryContext.cxx index c19131f5fc..af69030ff4 100644 --- a/panda/src/gobj/timerQueryContext.cxx +++ b/panda/src/gobj/timerQueryContext.cxx @@ -1,34 +1,29 @@ -// Filename: timerQueryContext.cxx -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timerQueryContext.cxx + * @author rdb + * @date 2014-08-22 + */ #include "timerQueryContext.h" TypeHandle TimerQueryContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TimerQueryContext::get_timestamp -// Access: Public, Virtual -// Description: Returns the timestamp that is the result of this -// timer query. There's no guarantee about which -// clock this uses, the only guarantee is that -// subtracting a start time from an end time should -// yield a time in seconds. -// If is_answer_ready() did not return true, this -// function may block before it returns. -// -// It is only valid to call this from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp that is the result of this timer query. There's no + * guarantee about which clock this uses, the only guarantee is that + * subtracting a start time from an end time should yield a time in seconds. + * If is_answer_ready() did not return true, this function may block before it + * returns. + * + * It is only valid to call this from the draw thread. + */ double TimerQueryContext:: get_timestamp() const { return 0.0; diff --git a/panda/src/gobj/timerQueryContext.h b/panda/src/gobj/timerQueryContext.h index 429dc65917..26fd32efbd 100644 --- a/panda/src/gobj/timerQueryContext.h +++ b/panda/src/gobj/timerQueryContext.h @@ -1,16 +1,15 @@ -// Filename: timerQueryContext.h -// Created by: rdb (22Aug14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timerQueryContext.h + * @author rdb + * @date 2014-08-22 + */ #ifndef TIMERQUERYCONTEXT_H #define TIMERQUERYCONTEXT_H @@ -20,10 +19,9 @@ #include "clockObject.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : TimerQueryContext -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_GOBJ TimerQueryContext : public QueryContext { public: INLINE TimerQueryContext(int pstats_index); diff --git a/panda/src/gobj/transformBlend.I b/panda/src/gobj/transformBlend.I index 37e501ab35..2d1f3624c2 100644 --- a/panda/src/gobj/transformBlend.I +++ b/panda/src/gobj/transformBlend.I @@ -1,42 +1,34 @@ -// Filename: transformBlend.I -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlend.I + * @author drose + * @date 2005-03-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend(const VertexTransform *transform0, PN_stdfloat) { add_transform(transform0, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1) { @@ -45,11 +37,9 @@ TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, normalize_weights(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1, @@ -60,11 +50,9 @@ TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, normalize_weights(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, const VertexTransform *transform1, PN_stdfloat weight1, @@ -77,22 +65,18 @@ TransformBlend(const VertexTransform *transform0, PN_stdfloat weight0, normalize_weights(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: TransformBlend(const TransformBlend ©) : _entries(copy._entries) { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TransformBlend:: operator = (const TransformBlend ©) { _entries = copy._entries; @@ -100,111 +84,87 @@ operator = (const TransformBlend ©) { clear_result(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend:: ~TransformBlend() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TransformBlend:: operator < (const TransformBlend &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TransformBlend:: operator == (const TransformBlend &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TransformBlend:: operator != (const TransformBlend &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_num_transforms -// Access: Published -// Description: Returns the number of transforms stored in the blend -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of transforms stored in the blend object. + */ INLINE size_t TransformBlend:: get_num_transforms() const { return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_transform -// Access: Published -// Description: Returns the nth transform stored in the blend -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth transform stored in the blend object. + */ INLINE const VertexTransform *TransformBlend:: get_transform(size_t n) const { nassertr(n < _entries.size(), NULL); return _entries[n]._transform; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_weight -// Access: Published -// Description: Returns the weight associated with the nth transform -// stored in the blend object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the weight associated with the nth transform stored in the blend + * object. + */ INLINE PN_stdfloat TransformBlend:: get_weight(size_t n) const { nassertr(n < _entries.size(), 0.0f); return _entries[n]._weight; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::set_transform -// Access: Published -// Description: Replaces the nth transform stored in the blend -// object. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the nth transform stored in the blend object. + */ INLINE void TransformBlend:: set_transform(size_t n, const VertexTransform *transform) { nassertv(n < _entries.size()); _entries[n]._transform = transform; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::set_weight -// Access: Published -// Description: Replaces the weight associated with the nth transform -// stored in the blend object. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the weight associated with the nth transform stored in the blend + * object. + */ INLINE void TransformBlend:: set_weight(size_t n, PN_stdfloat weight) { nassertv(n < _entries.size()); _entries[n]._weight = weight; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::update_blend -// Access: Published -// Description: Recomputes the internal representation of the blend -// value, if necessary. You should call this before -// calling get_blend() or transform_point(). -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the internal representation of the blend value, if necessary. + * You should call this before calling get_blend() or transform_point(). + */ INLINE void TransformBlend:: update_blend(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); @@ -214,30 +174,25 @@ update_blend(Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_blend -// Access: Published -// Description: Returns the current value of the blend, based on the -// current value of all of the nested transform objects -// and their associated weights. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current value of the blend, based on the current value of all + * of the nested transform objects and their associated weights. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: get_blend(LMatrix4 &result, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); result = cdata->_result; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint4 &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -246,14 +201,12 @@ transform_point(LPoint4 &point, Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint3 &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -262,14 +215,12 @@ transform_point(LPoint3 &point, Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_vector -// Access: Published -// Description: Transforms the indicated vector by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated vector by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_vector(LVector3 &vector, Thread *current_thread) const { if (!_entries.empty()) { @@ -279,14 +230,12 @@ transform_vector(LVector3 &vector, Thread *current_thread) const { } #ifndef STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point (double) -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint4d &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -295,14 +244,12 @@ transform_point(LPoint4d &point, Thread *current_thread) const { } } #else // STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point (float) -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint4f &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -313,14 +260,12 @@ transform_point(LPoint4f &point, Thread *current_thread) const { #endif // STDFLOAT_DOUBLE #ifndef STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point (double) -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint3d &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -329,14 +274,12 @@ transform_point(LPoint3d &point, Thread *current_thread) const { } } #else // STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_point (float) -// Access: Published -// Description: Transforms the indicated point by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_point(LPoint3f &point, Thread *current_thread) const { if (!_entries.empty()) { @@ -347,14 +290,12 @@ transform_point(LPoint3f &point, Thread *current_thread) const { #endif // STDFLOAT_DOUBLE #ifndef STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_vector (double) -// Access: Published -// Description: Transforms the indicated vector by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated vector by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_vector(LVector3d &vector, Thread *current_thread) const { if (!_entries.empty()) { @@ -363,14 +304,12 @@ transform_vector(LVector3d &vector, Thread *current_thread) const { } } #else // STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::transform_vector (float) -// Access: Published -// Description: Transforms the indicated vector by the blend matrix. -// -// You should call update_blend() to ensure that the -// cache is up-to-date before calling this. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated vector by the blend matrix. + * + * You should call update_blend() to ensure that the cache is up-to-date + * before calling this. + */ INLINE void TransformBlend:: transform_vector(LVector3f &vector, Thread *current_thread) const { if (!_entries.empty()) { @@ -380,12 +319,10 @@ transform_vector(LVector3f &vector, Thread *current_thread) const { } #endif // STDFLOAT_DOUBLE -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_modified -// Access: Published -// Description: Returns a counter which is guaranteed to increment at -// least as often as the result of get_blend() changes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a counter which is guaranteed to increment at least as often as the + * result of get_blend() changes. + */ INLINE UpdateSeq TransformBlend:: get_modified(Thread *current_thread) const { CDLockedReader cdata(_cycler, current_thread); @@ -398,35 +335,28 @@ get_modified(Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::TransformEntry::operator < -// Access: Public -// Description: Provides an ordering of TransformEntries by the -// VertexTransform pointer only, so we can easily look -// up in the set to see if a particular transform -// exists. -//////////////////////////////////////////////////////////////////// +/** + * Provides an ordering of TransformEntries by the VertexTransform pointer + * only, so we can easily look up in the set to see if a particular transform + * exists. + */ INLINE bool TransformBlend::TransformEntry:: operator < (const TransformBlend::TransformEntry &other) const { return _transform < other._transform; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend::CData:: CData() : _result(LMatrix4::ident_mat()) { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlend::CData:: CData(const TransformBlend::CData ©) : _result(copy._result), diff --git a/panda/src/gobj/transformBlend.cxx b/panda/src/gobj/transformBlend.cxx index d26c43c24f..656a691a95 100644 --- a/panda/src/gobj/transformBlend.cxx +++ b/panda/src/gobj/transformBlend.cxx @@ -1,16 +1,15 @@ -// Filename: transformBlend.cxx -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlend.cxx + * @author drose + * @date 2005-03-24 + */ #include "transformBlend.h" #include "indent.h" @@ -19,12 +18,9 @@ TypeHandle TransformBlend::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::compare_to -// Access: Published -// Description: Defines an arbitrary ordering for TransformBlend -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Defines an arbitrary ordering for TransformBlend objects. + */ int TransformBlend:: compare_to(const TransformBlend &other) const { if (_entries.size() != other._entries.size()) { @@ -48,12 +44,10 @@ compare_to(const TransformBlend &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::add_transform -// Access: Published -// Description: Adds a new transform to the blend. If the transform -// already existed, increases its weight factor. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new transform to the blend. If the transform already existed, + * increases its weight factor. + */ void TransformBlend:: add_transform(const VertexTransform *transform, PN_stdfloat weight) { if (!IS_NEARLY_ZERO(weight)) { @@ -62,8 +56,8 @@ add_transform(const VertexTransform *transform, PN_stdfloat weight) { entry._weight = weight; pair result = _entries.insert(entry); if (!result.second) { - // If the new value was not inserted, it was already there; - // increment the existing weight factor. + // If the new value was not inserted, it was already there; increment + // the existing weight factor. Entries::iterator ei = result.first; (*ei)._weight += weight; if (IS_NEARLY_ZERO((*ei)._weight)) { @@ -76,11 +70,9 @@ add_transform(const VertexTransform *transform, PN_stdfloat weight) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::remove_transform -// Access: Published -// Description: Removes the indicated transform from the blend. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated transform from the blend. + */ void TransformBlend:: remove_transform(const VertexTransform *transform) { TransformEntry entry; @@ -94,14 +86,11 @@ remove_transform(const VertexTransform *transform) { clear_result(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::limit_transforms -// Access: Published -// Description: If the total number of transforms in the blend -// exceeds max_transforms, removes the n least-important -// transforms as needed to reduce the number of -// transforms to max_transforms. -//////////////////////////////////////////////////////////////////// +/** + * If the total number of transforms in the blend exceeds max_transforms, + * removes the n least-important transforms as needed to reduce the number of + * transforms to max_transforms. + */ void TransformBlend:: limit_transforms(int max_transforms) { if (max_transforms <= 0) { @@ -126,14 +115,11 @@ limit_transforms(int max_transforms) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::normalize_weights -// Access: Published -// Description: Rescales all of the weights on the various transforms -// so that they sum to 1.0. It is generally a good idea -// to call this after adding or removing transforms from -// the blend. -//////////////////////////////////////////////////////////////////// +/** + * Rescales all of the weights on the various transforms so that they sum to + * 1.0. It is generally a good idea to call this after adding or removing + * transforms from the blend. + */ void TransformBlend:: normalize_weights() { PN_stdfloat net_weight = 0.0f; @@ -150,12 +136,9 @@ normalize_weights() { clear_result(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::has_transform -// Access: Published -// Description: Returns true if the blend has the indicated -// transform, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the blend has the indicated transform, false otherwise. + */ bool TransformBlend:: has_transform(const VertexTransform *transform) const { TransformEntry entry; @@ -165,13 +148,10 @@ has_transform(const VertexTransform *transform) const { return (ei != _entries.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::get_weight -// Access: Published -// Description: Returns the weight associated with the indicated -// transform, or 0 if there is no entry for the -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the weight associated with the indicated transform, or 0 if there + * is no entry for the transform. + */ PN_stdfloat TransformBlend:: get_weight(const VertexTransform *transform) const { TransformEntry entry; @@ -184,11 +164,9 @@ get_weight(const VertexTransform *transform) const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformBlend:: output(ostream &out) const { if (_entries.empty()) { @@ -204,11 +182,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformBlend:: write(ostream &out, int indent_level) const { Thread *current_thread = Thread::get_current_thread(); @@ -228,12 +204,10 @@ write(ostream &out, int indent_level) const { blend.write(out, indent_level + 2); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::recompute_result -// Access: Private -// Description: Recomputes the blend result from the various -// VertexTransform objects, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the blend result from the various VertexTransform objects, if + * necessary. + */ void TransformBlend:: recompute_result(CData *cdata, Thread *current_thread) { // Update the global_modified sequence number first, to prevent race @@ -255,15 +229,12 @@ recompute_result(CData *cdata, Thread *current_thread) { for (ei = _entries.begin(); ei != _entries.end(); ++ei) { (*ei)._transform->accumulate_matrix(cdata->_result, (*ei)._weight); } - } + } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::clear_result -// Access: Private -// Description: Removes the computed result to force it to be -// recomputed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the computed result to force it to be recomputed. + */ void TransformBlend:: clear_result(Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); @@ -274,12 +245,10 @@ clear_result(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformBlend:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint16(_entries.size()); @@ -291,13 +260,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::complete_pointers -// Access: Public -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TransformBlend:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = 0; @@ -307,20 +273,16 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { (*ei)._transform = DCAST(VertexTransform, p_list[pi++]); } - // Now that we have actual pointers, we can sort the list of - // entries. + // Now that we have actual pointers, we can sort the list of entries. _entries.sort(); return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::fillin -// Access: Public -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PandaNode. + */ void TransformBlend:: fillin(DatagramIterator &scan, BamReader *manager) { size_t num_entries = scan.get_uint16(); @@ -333,11 +295,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlend::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *TransformBlend::CData:: make_copy() const { return new CData(*this); diff --git a/panda/src/gobj/transformBlend.h b/panda/src/gobj/transformBlend.h index d9e2a40c2e..02f39f05d1 100644 --- a/panda/src/gobj/transformBlend.h +++ b/panda/src/gobj/transformBlend.h @@ -1,16 +1,15 @@ -// Filename: transformBlend.h -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlend.h + * @author drose + * @date 2005-03-24 + */ #ifndef TRANSFORMBLEND_H #define TRANSFORMBLEND_H @@ -26,13 +25,10 @@ #include "cycleDataWriter.h" #include "pipelineCycler.h" -//////////////////////////////////////////////////////////////////// -// Class : TransformBlend -// Description : This defines a single entry in a -// TransformBlendTable. It represents a unique -// combination of VertexTransform pointers and blend -// amounts. -//////////////////////////////////////////////////////////////////// +/** + * This defines a single entry in a TransformBlendTable. It represents a + * unique combination of VertexTransform pointers and blend amounts. + */ class EXPCL_PANDA_GOBJ TransformBlend { PUBLISHED: INLINE TransformBlend(); @@ -103,8 +99,8 @@ private: typedef ov_set Entries; Entries _entries; - // This is the data that must be cycled between pipeline stages; it - // is just a local cache. + // This is the data that must be cycled between pipeline stages; it is just + // a local cache. class EXPCL_PANDA_GOBJ CData : public CycleData { public: INLINE CData(); diff --git a/panda/src/gobj/transformBlendTable.I b/panda/src/gobj/transformBlendTable.I index 1c2eecb65c..49f8fa25de 100644 --- a/panda/src/gobj/transformBlendTable.I +++ b/panda/src/gobj/transformBlendTable.I @@ -1,47 +1,37 @@ -// Filename: transformBlendTable.I -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlendTable.I + * @author drose + * @date 2005-03-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_num_blends -// Access: Published -// Description: Returns the total number of different blend -// combinations in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of different blend combinations in the table. + */ INLINE size_t TransformBlendTable:: get_num_blends() const { return _blends.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_blend -// Access: Published -// Description: Returns the nth blend in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth blend in the table. + */ INLINE const TransformBlend &TransformBlendTable:: get_blend(size_t n) const { nassertr(n < _blends.size(), _blends[0]); return _blends[n]; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_modified -// Access: Published -// Description: Returns a counter which is guaranteed to increment at -// least when any TransformBlends within the table -// have changed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a counter which is guaranteed to increment at least when any + * TransformBlends within the table have changed. + */ INLINE UpdateSeq TransformBlendTable:: get_modified(Thread *current_thread) const { CDLockedReader cdata(_cycler); @@ -54,87 +44,68 @@ get_modified(Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_num_transforms -// Access: Published -// Description: Returns the number of unique VertexTransform objects -// represented in the table. This will correspond to -// the size of the TransformTable object that would -// represent the same table. This is also the same -// limit reflected by -// GraphicsStateGuardian::get_max_vertex_transform_indices(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique VertexTransform objects represented in the + * table. This will correspond to the size of the TransformTable object that + * would represent the same table. This is also the same limit reflected by + * GraphicsStateGuardian::get_max_vertex_transform_indices(). + */ INLINE int TransformBlendTable:: get_num_transforms() const { consider_rebuild_index(); if (_num_transforms < 0) { - // Even if our index is otherwise accurate, we might have recently - // added a blend or two, which would necessitate recomputing this - // value--which means we need to rebuild the index. + // Even if our index is otherwise accurate, we might have recently added a + // blend or two, which would necessitate recomputing this value--which + // means we need to rebuild the index. ((TransformBlendTable *)this)->rebuild_index(); } return _num_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_max_simultaneous_transforms -// Access: Published -// Description: Returns the maximum number of unique VertexTransform -// objects that are applied to any one vertex -// simultaneously. This is the same limit reflected by -// GraphicsStateGuardian::get_max_vertex_transforms(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of unique VertexTransform objects that are + * applied to any one vertex simultaneously. This is the same limit reflected + * by GraphicsStateGuardian::get_max_vertex_transforms(). + */ INLINE int TransformBlendTable:: get_max_simultaneous_transforms() const { consider_rebuild_index(); return _max_simultaneous_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::set_rows -// Access: Published -// Description: Specifies the subset of rows (vertices) in the -// associated GeomVertexData that this -// TransformBlendTable actually affects. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the subset of rows (vertices) in the associated GeomVertexData + * that this TransformBlendTable actually affects. + */ INLINE void TransformBlendTable:: set_rows(const SparseArray &rows) { _rows = rows; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::get_rows -// Access: Published -// Description: Returns the subset of rows (vertices) in the -// associated GeomVertexData that this -// TransformBlendTable actually affects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of rows (vertices) in the associated GeomVertexData that + * this TransformBlendTable actually affects. + */ INLINE const SparseArray &TransformBlendTable:: get_rows() const { return _rows; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::modify_rows -// Access: Published -// Description: Returns a modifiable reference to the SparseArray -// that specifies the subset of rows (vertices) in the -// associated GeomVertexData that this -// TransformBlendTable actually affects. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the SparseArray that specifies the subset + * of rows (vertices) in the associated GeomVertexData that this + * TransformBlendTable actually affects. + */ INLINE SparseArray &TransformBlendTable:: modify_rows() { return _rows; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::consider_rebuild_index -// Access: Private -// Description: Calls rebuild_index() if the index needs to be -// rebuilt. -//////////////////////////////////////////////////////////////////// +/** + * Calls rebuild_index() if the index needs to be rebuilt. + */ INLINE void TransformBlendTable:: consider_rebuild_index() const { if (_blend_index.empty()) { @@ -142,20 +113,16 @@ consider_rebuild_index() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlendTable::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformBlendTable::CData:: CData(const TransformBlendTable::CData ©) : _modified(copy._modified), diff --git a/panda/src/gobj/transformBlendTable.cxx b/panda/src/gobj/transformBlendTable.cxx index 1efffb1fec..da76d38626 100644 --- a/panda/src/gobj/transformBlendTable.cxx +++ b/panda/src/gobj/transformBlendTable.cxx @@ -1,16 +1,15 @@ -// Filename: transformBlendTable.cxx -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlendTable.cxx + * @author drose + * @date 2005-03-24 + */ #include "transformBlendTable.h" #include "indent.h" @@ -19,30 +18,24 @@ TypeHandle TransformBlendTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::make_cow_copy -// Access: Protected, Virtual -// Description: Required to implement CopyOnWriteObject. -//////////////////////////////////////////////////////////////////// +/** + * Required to implement CopyOnWriteObject. + */ PT(CopyOnWriteObject) TransformBlendTable:: make_cow_copy() { return new TransformBlendTable(*this); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformBlendTable:: TransformBlendTable() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformBlendTable:: TransformBlendTable(const TransformBlendTable ©) : _blends(copy._blends), @@ -50,11 +43,9 @@ TransformBlendTable(const TransformBlendTable ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformBlendTable:: operator = (const TransformBlendTable ©) { _blends = copy._blends; @@ -62,45 +53,36 @@ operator = (const TransformBlendTable ©) { clear_index(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformBlendTable:: ~TransformBlendTable() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::set_blend -// Access: Published -// Description: Replaces the blend at the nth position with the -// indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the blend at the nth position with the indicated value. + */ void TransformBlendTable:: set_blend(size_t n, const TransformBlend &blend) { nassertv(n < _blends.size()); _blends[n] = blend; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::remove_blend -// Access: Published -// Description: Removes the blend at the nth position. -//////////////////////////////////////////////////////////////////// +/** + * Removes the blend at the nth position. + */ void TransformBlendTable:: remove_blend(size_t n) { nassertv(n < _blends.size()); _blends.erase(_blends.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::add_blend -// Access: Published -// Description: Adds a new blend to the table, and returns its -// index number. If there is already an identical blend -// in the table, simply returns that number instead. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new blend to the table, and returns its index number. If there is + * already an identical blend in the table, simply returns that number + * instead. + */ size_t TransformBlendTable:: add_blend(const TransformBlend &blend) { consider_rebuild_index(); @@ -117,31 +99,28 @@ add_blend(const TransformBlend &blend) { _blends.push_back(blend); if (needs_realloc) { - // We just reallocated the blends vector, so we must rebuild the - // index. + // We just reallocated the blends vector, so we must rebuild the index. clear_index(); } else { - // Since we didn't realloc the blends vector, just update it with - // the latest. + // Since we didn't realloc the blends vector, just update it with the + // latest. const TransformBlend &added_blend = _blends[new_position]; _blend_index[&added_blend] = new_position; _max_simultaneous_transforms = max(_max_simultaneous_transforms, (int)blend.get_num_transforms()); - // We can't compute this one as we go, so set it to a special - // value to indicate it needs to be recomputed. + // We can't compute this one as we go, so set it to a special value to + // indicate it needs to be recomputed. _num_transforms = -1; } return new_position; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformBlendTable:: write(ostream &out, int indent_level) const { for (size_t i = 0; i < _blends.size(); ++i) { @@ -150,30 +129,23 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::clear_index -// Access: Private -// Description: Resets the index so that it will be rebuilt next time -// it is needed. -//////////////////////////////////////////////////////////////////// +/** + * Resets the index so that it will be rebuilt next time it is needed. + */ void TransformBlendTable:: clear_index() { _blend_index.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::rebuild_index -// Access: Private -// Description: Rebuilds the index so that we can easily determine -// what blend combinations are already present in the -// table. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the index so that we can easily determine what blend combinations + * are already present in the table. + */ void TransformBlendTable:: rebuild_index() { _blend_index.clear(); - // We'll also count up these two statistics while we rebuild the - // index. + // We'll also count up these two statistics while we rebuild the index. _num_transforms = 0; _max_simultaneous_transforms = 0; @@ -193,12 +165,10 @@ rebuild_index() { _num_transforms = transforms.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::recompute_modified -// Access: Private -// Description: Recomputes the modified stamp from the various -// TransformBlend objects, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the modified stamp from the various TransformBlend objects, if + * necessary. + */ void TransformBlendTable:: recompute_modified(TransformBlendTable::CData *cdata, Thread *current_thread) { // Update the global_modified sequence number first, to prevent race @@ -215,12 +185,9 @@ recompute_modified(TransformBlendTable::CData *cdata, Thread *current_thread) { cdata->_modified = seq; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::clear_modified -// Access: Private -// Description: Clears the modified stamp to force it to be -// recomputed. -//////////////////////////////////////////////////////////////////// +/** + * Clears the modified stamp to force it to be recomputed. + */ void TransformBlendTable:: clear_modified(Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); @@ -228,23 +195,18 @@ clear_modified(Thread *current_thread) { cdata->_modified = UpdateSeq(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TransformBlendTable. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TransformBlendTable. + */ void TransformBlendTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformBlendTable:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -260,13 +222,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TransformBlendTable:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -279,14 +238,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TransformBlendTable is encountered -// in the Bam file. It should create the TransformBlendTable -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TransformBlendTable is encountered in the Bam file. It should create + * the TransformBlendTable and extract its information from the file. + */ TypedWritable *TransformBlendTable:: make_from_bam(const FactoryParams ¶ms) { TransformBlendTable *object = new TransformBlendTable; @@ -299,13 +255,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransformBlendTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransformBlendTable. + */ void TransformBlendTable:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -323,40 +276,33 @@ fillin(DatagramIterator &scan, BamReader *manager) { _rows.read_datagram(scan, manager); } else { // In this case, for bam files prior to 6.7, we must define the - // SparseArray with the full number of vertices. This is done - // in GeomVertexData::complete_pointers(). + // SparseArray with the full number of vertices. This is done in + // GeomVertexData::complete_pointers(). } manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *TransformBlendTable::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformBlendTable::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: TransformBlendTable::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransformBlendTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransformBlendTable. + */ void TransformBlendTable::CData:: fillin(DatagramIterator &scan, BamReader *manager) { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/gobj/transformBlendTable.h b/panda/src/gobj/transformBlendTable.h index aa7ef3387d..3981278b04 100644 --- a/panda/src/gobj/transformBlendTable.h +++ b/panda/src/gobj/transformBlendTable.h @@ -1,16 +1,15 @@ -// Filename: transformBlendTable.h -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformBlendTable.h + * @author drose + * @date 2005-03-24 + */ #ifndef TRANSFORMBLENDTABLE_H #define TRANSFORMBLENDTABLE_H @@ -32,21 +31,17 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TransformBlendTable -// Description : This structure collects together the different -// combinations of transforms and blend amounts used by -// a GeomVertexData, to facilitate computing dynamic -// vertices on the CPU at runtime. Each vertex has a -// pointer to exactly one of the entries in this table, -// and each entry defines a number of transform/blend -// combinations. -// -// This structure is used for a GeomVertexData set up to -// compute its dynamic vertices on the CPU. See -// TransformTable for one set up to compute its -// dynamic vertices on the graphics card. -//////////////////////////////////////////////////////////////////// +/** + * This structure collects together the different combinations of transforms + * and blend amounts used by a GeomVertexData, to facilitate computing dynamic + * vertices on the CPU at runtime. Each vertex has a pointer to exactly one + * of the entries in this table, and each entry defines a number of + * transform/blend combinations. + * + * This structure is used for a GeomVertexData set up to compute its dynamic + * vertices on the CPU. See TransformTable for one set up to compute its + * dynamic vertices on the graphics card. + */ class EXPCL_PANDA_GOBJ TransformBlendTable : public CopyOnWriteObject { protected: virtual PT(CopyOnWriteObject) make_cow_copy(); @@ -86,27 +81,26 @@ private: void clear_modified(Thread *current_thread); private: - // We don't bother with registering the table, or protecting its - // data in a CycleData structure--the interface on GeomVertexData - // guarantees that the pointer will be copied if we modify the - // table. + // We don't bother with registering the table, or protecting its data in a + // CycleData structure--the interface on GeomVertexData guarantees that the + // pointer will be copied if we modify the table. typedef pvector Blends; Blends _blends; SparseArray _rows; - // This map indexes directly into the above vector. That means any - // time we add or remove anything from the vector, we must - // completely rebuild the index (since the vector might reallocate, - // invalidating all the pointers into it). + // This map indexes directly into the above vector. That means any time we + // add or remove anything from the vector, we must completely rebuild the + // index (since the vector might reallocate, invalidating all the pointers + // into it). typedef pmap > BlendIndex; BlendIndex _blend_index; int _num_transforms; int _max_simultaneous_transforms; - // Even though we don't store the actual blend table data in a - // CycleData structure, we do need to keep a local cache of the - // relevant modified stamps there, so it can be updated per-thread. + // Even though we don't store the actual blend table data in a CycleData + // structure, we do need to keep a local cache of the relevant modified + // stamps there, so it can be updated per-thread. class EXPCL_PANDA_GOBJ CData : public CycleData { public: INLINE CData(); diff --git a/panda/src/gobj/transformTable.I b/panda/src/gobj/transformTable.I index 25423a7465..ce8fe2d196 100644 --- a/panda/src/gobj/transformTable.I +++ b/panda/src/gobj/transformTable.I @@ -1,54 +1,43 @@ -// Filename: transformTable.I -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformTable.I + * @author drose + * @date 2005-03-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::is_registered -// Access: Published -// Description: Returns true if this table has been registered. -// Once it has been registered, the set of transforms in -// a TransformTable may not be further modified; but -// it must be registered before it can be assigned to a -// Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this table has been registered. Once it has been + * registered, the set of transforms in a TransformTable may not be further + * modified; but it must be registered before it can be assigned to a Geom. + */ INLINE bool TransformTable:: is_registered() const { return _is_registered; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::register_table -// Access: Published, Static -// Description: Registers a TransformTable for use. This is -// similar to GeomVertexFormat::register_format(). Once -// registered, a TransformTable may no longer be -// modified (although the individual VertexTransform -// objects may modify their reported transforms). -// -// This must be called before a table may be used in a -// Geom. After this call, you should discard the -// original pointer you passed in (which may or may not -// now be invalid) and let its reference count decrement -// normally; you should use only the returned value from -// this point on. -//////////////////////////////////////////////////////////////////// +/** + * Registers a TransformTable for use. This is similar to + * GeomVertexFormat::register_format(). Once registered, a TransformTable may + * no longer be modified (although the individual VertexTransform objects may + * modify their reported transforms). + * + * This must be called before a table may be used in a Geom. After this call, + * you should discard the original pointer you passed in (which may or may not + * now be invalid) and let its reference count decrement normally; you should + * use only the returned value from this point on. + */ INLINE CPT(TransformTable) TransformTable:: register_table(const TransformTable *table) { - // We don't actually bother adding the table object to a registry. - // This means there may be multiple copies of identical registered - // TransformTables. Big deal. We can always go back and make a - // registry later if we really need it. + // We don't actually bother adding the table object to a registry. This + // means there may be multiple copies of identical registered + // TransformTables. Big deal. We can always go back and make a registry + // later if we really need it. if (table->is_registered()) { return table; } @@ -57,69 +46,55 @@ register_table(const TransformTable *table) { return table; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::get_num_transforms -// Access: Published -// Description: Returns the number of transforms in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of transforms in the table. + */ INLINE size_t TransformTable:: get_num_transforms() const { return _transforms.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::get_transform -// Access: Published -// Description: Returns the nth transform in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth transform in the table. + */ INLINE const VertexTransform *TransformTable:: get_transform(size_t n) const { nassertr(n < _transforms.size(), NULL); return _transforms[n]; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::get_modified -// Access: Published -// Description: Returns a sequence number that's guaranteed to change -// at least when any VertexTransforms in the table -// change. (However, this is only true for a registered -// table. An unregistered table may or may not -// reflect an update here when a VertexTransform -// changes.) -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number that's guaranteed to change at least when any + * VertexTransforms in the table change. (However, this is only true for a + * registered table. An unregistered table may or may not reflect an update + * here when a VertexTransform changes.) + */ INLINE UpdateSeq TransformTable:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::update_modified -// Access: Private -// Description: Called internally whenever a nested VertexTransform -// reports that it has been modified. -//////////////////////////////////////////////////////////////////// +/** + * Called internally whenever a nested VertexTransform reports that it has + * been modified. + */ INLINE void TransformTable:: update_modified(UpdateSeq modified, Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); cdata->_modified = modified; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformTable::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformTable::CData:: CData(const TransformTable::CData ©) : _modified(copy._modified) diff --git a/panda/src/gobj/transformTable.cxx b/panda/src/gobj/transformTable.cxx index 466f30f226..258299fafc 100644 --- a/panda/src/gobj/transformTable.cxx +++ b/panda/src/gobj/transformTable.cxx @@ -1,16 +1,15 @@ -// Filename: transformTable.cxx -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformTable.cxx + * @author drose + * @date 2005-03-23 + */ #include "transformTable.h" #include "bamReader.h" @@ -18,22 +17,18 @@ TypeHandle TransformTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformTable:: TransformTable() : _is_registered(false) { } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformTable:: TransformTable(const TransformTable ©) : _is_registered(false), @@ -41,22 +36,18 @@ TransformTable(const TransformTable ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformTable:: operator = (const TransformTable ©) { nassertv(!_is_registered); _transforms = copy._transforms; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TransformTable:: ~TransformTable() { if (_is_registered) { @@ -64,12 +55,9 @@ TransformTable:: } } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::set_transform -// Access: Published -// Description: Replaces the nth transform. Only valid for -// unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the nth transform. Only valid for unregistered tables. + */ void TransformTable:: set_transform(size_t n, const VertexTransform *transform) { nassertv(!_is_registered); @@ -77,12 +65,9 @@ set_transform(size_t n, const VertexTransform *transform) { _transforms[n] = transform; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::remove_transform -// Access: Published -// Description: Removes the nth transform. Only valid for -// unregistered tables. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth transform. Only valid for unregistered tables. + */ void TransformTable:: remove_transform(size_t n) { nassertv(!_is_registered); @@ -90,17 +75,13 @@ remove_transform(size_t n) { _transforms.erase(_transforms.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::add_transform -// Access: Published -// Description: Adds a new transform to the table and returns the -// index number of the new transform. Only valid for -// unregistered tables. -// -// This does not automatically uniquify the pointer; if -// the transform is already present in the table, it -// will be added twice. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new transform to the table and returns the index number of the new + * transform. Only valid for unregistered tables. + * + * This does not automatically uniquify the pointer; if the transform is + * already present in the table, it will be added twice. + */ size_t TransformTable:: add_transform(const VertexTransform *transform) { nassertr(!_is_registered, -1); @@ -109,11 +90,9 @@ add_transform(const VertexTransform *transform) { return new_index; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformTable:: write(ostream &out) const { for (size_t i = 0; i < _transforms.size(); ++i) { @@ -121,11 +100,9 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::do_register -// Access: Private -// Description: Called internally when the table is registered. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the table is registered. + */ void TransformTable:: do_register() { nassertv(!_is_registered); @@ -139,12 +116,10 @@ do_register() { _is_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::do_unregister -// Access: Private -// Description: Called internally when the table is unregistered -// (i.e. right before destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the table is unregistered (i.e. right before + * destruction). + */ void TransformTable:: do_unregister() { nassertv(_is_registered); @@ -157,23 +132,18 @@ do_unregister() { _is_registered = false; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TransformTable. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TransformTable. + */ void TransformTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformTable:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); @@ -188,13 +158,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TransformTable:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -208,14 +175,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TransformTable is encountered -// in the Bam file. It should create the TransformTable -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TransformTable is encountered in the Bam file. It should create the + * TransformTable and extract its information from the file. + */ TypedWritable *TransformTable:: make_from_bam(const FactoryParams ¶ms) { TransformTable *object = new TransformTable; @@ -228,13 +192,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransformTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransformTable. + */ void TransformTable:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); @@ -249,33 +210,26 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *TransformTable::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformTable::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: TransformTable::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransformTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransformTable. + */ void TransformTable::CData:: fillin(DatagramIterator &scan, BamReader *manager) { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/gobj/transformTable.h b/panda/src/gobj/transformTable.h index 0db7146af0..48fa0abb7e 100644 --- a/panda/src/gobj/transformTable.h +++ b/panda/src/gobj/transformTable.h @@ -1,16 +1,15 @@ -// Filename: transformTable.h -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformTable.h + * @author drose + * @date 2005-03-23 + */ #ifndef TRANSFORMTABLE_H #define TRANSFORMTABLE_H @@ -28,17 +27,14 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TransformTable -// Description : Stores the total set of VertexTransforms that the -// vertices in a particular GeomVertexData object might -// depend on. -// -// This structure is used for a GeomVertexData set up to -// compute its dynamic vertices on the graphics card. -// See TransformBlendTable for one set up to compute -// its dynamic vertices on the CPU. -//////////////////////////////////////////////////////////////////// +/** + * Stores the total set of VertexTransforms that the vertices in a particular + * GeomVertexData object might depend on. + * + * This structure is used for a GeomVertexData set up to compute its dynamic + * vertices on the graphics card. See TransformBlendTable for one set up to + * compute its dynamic vertices on the CPU. + */ class EXPCL_PANDA_GOBJ TransformTable : public TypedWritableReferenceCount { PUBLISHED: TransformTable(); diff --git a/panda/src/gobj/userVertexSlider.I b/panda/src/gobj/userVertexSlider.I index 9feaa42793..f24fd8f250 100644 --- a/panda/src/gobj/userVertexSlider.I +++ b/panda/src/gobj/userVertexSlider.I @@ -1,23 +1,19 @@ -// Filename: userVertexSlider.I -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexSlider.I + * @author drose + * @date 2005-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::set_slider -// Access: Published -// Description: Stores the indicated slider value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated slider value. + */ INLINE void UserVertexSlider:: set_slider(PN_stdfloat slider) { Thread *current_thread = Thread::get_current_thread(); @@ -26,22 +22,18 @@ set_slider(PN_stdfloat slider) { mark_modified(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UserVertexSlider::CData:: CData() : _slider(0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UserVertexSlider::CData:: CData(const UserVertexSlider::CData ©) : _slider(copy._slider) diff --git a/panda/src/gobj/userVertexSlider.cxx b/panda/src/gobj/userVertexSlider.cxx index 4bf212e20e..d6363082a8 100644 --- a/panda/src/gobj/userVertexSlider.cxx +++ b/panda/src/gobj/userVertexSlider.cxx @@ -1,16 +1,15 @@ -// Filename: userVertexSlider.cxx -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexSlider.cxx + * @author drose + * @date 2005-03-28 + */ #include "userVertexSlider.h" #include "bamReader.h" @@ -18,66 +17,53 @@ TypeHandle UserVertexSlider::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserVertexSlider:: UserVertexSlider(const string &name) : VertexSlider(InternalName::make(name)) { } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserVertexSlider:: UserVertexSlider(const InternalName *name) : VertexSlider(name) { } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::get_slider -// Access: Published, Virtual -// Description: Returns the current slider value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current slider value. + */ PN_stdfloat UserVertexSlider:: get_slider() const { CDReader cdata(_cycler); return cdata->_slider; } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *UserVertexSlider::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// UserVertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type UserVertexSlider. + */ void UserVertexSlider:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void UserVertexSlider:: write_datagram(BamWriter *manager, Datagram &dg) { VertexSlider::write_datagram(manager, dg); @@ -85,14 +71,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type UserVertexSlider is encountered -// in the Bam file. It should create the UserVertexSlider -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type UserVertexSlider is encountered in the Bam file. It should create the + * UserVertexSlider and extract its information from the file. + */ TypedWritable *UserVertexSlider:: make_from_bam(const FactoryParams ¶ms) { UserVertexSlider *object = new UserVertexSlider(""); @@ -105,13 +88,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new UserVertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new UserVertexSlider. + */ void UserVertexSlider:: fillin(DatagramIterator &scan, BamReader *manager) { VertexSlider::fillin(scan, manager); @@ -119,24 +99,19 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void UserVertexSlider::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_stdfloat(_slider); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexSlider::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new UserVertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new UserVertexSlider. + */ void UserVertexSlider::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _slider = scan.get_stdfloat(); diff --git a/panda/src/gobj/userVertexSlider.h b/panda/src/gobj/userVertexSlider.h index e2817e5add..b4db1ed6a2 100644 --- a/panda/src/gobj/userVertexSlider.h +++ b/panda/src/gobj/userVertexSlider.h @@ -1,16 +1,15 @@ -// Filename: userVertexSlider.h -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexSlider.h + * @author drose + * @date 2005-03-28 + */ #ifndef USERVERTEXSLIDER_H #define USERVERTEXSLIDER_H @@ -24,13 +23,11 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : UserVertexSlider -// Description : This is a specialization on VertexSlider that -// allows the user to specify any arbitrary slider -// valie he likes. This is rarely used except for -// testing. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on VertexSlider that allows the user to specify + * any arbitrary slider valie he likes. This is rarely used except for + * testing. + */ class EXPCL_PANDA_GOBJ UserVertexSlider : public VertexSlider { PUBLISHED: UserVertexSlider(const string &name); diff --git a/panda/src/gobj/userVertexTransform.I b/panda/src/gobj/userVertexTransform.I index ce6937ba54..3b6d7b046a 100644 --- a/panda/src/gobj/userVertexTransform.I +++ b/panda/src/gobj/userVertexTransform.I @@ -1,34 +1,27 @@ -// Filename: userVertexTransform.I -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexTransform.I + * @author drose + * @date 2005-03-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::get_name -// Access: Published -// Description: Returns the name passed to the constructor. -// Completely arbitrary. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name passed to the constructor. Completely arbitrary. + */ INLINE const string &UserVertexTransform:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::set_matrix -// Access: Published -// Description: Stores the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated matrix. + */ INLINE void UserVertexTransform:: set_matrix(const LMatrix4 &matrix) { Thread *current_thread = Thread::get_current_thread(); @@ -37,22 +30,18 @@ set_matrix(const LMatrix4 &matrix) { mark_modified(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UserVertexTransform::CData:: CData() : _matrix(LMatrix4::ident_mat()) { } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UserVertexTransform::CData:: CData(const UserVertexTransform::CData ©) : _matrix(copy._matrix) diff --git a/panda/src/gobj/userVertexTransform.cxx b/panda/src/gobj/userVertexTransform.cxx index d1875fadf8..d83aeb4c8a 100644 --- a/panda/src/gobj/userVertexTransform.cxx +++ b/panda/src/gobj/userVertexTransform.cxx @@ -1,16 +1,15 @@ -// Filename: userVertexTransform.cxx -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexTransform.cxx + * @author drose + * @date 2005-03-24 + */ #include "userVertexTransform.h" #include "bamReader.h" @@ -18,65 +17,52 @@ TypeHandle UserVertexTransform::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserVertexTransform:: UserVertexTransform(const string &name) : _name(name) { } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::get_matrix -// Access: Published, Virtual -// Description: Returns the transform's matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform's matrix. + */ void UserVertexTransform:: get_matrix(LMatrix4 &matrix) const { CDReader cdata(_cycler); matrix = cdata->_matrix; } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void UserVertexTransform:: output(ostream &out) const { out << get_type() << " " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *UserVertexTransform::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// UserVertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type UserVertexTransform. + */ void UserVertexTransform:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void UserVertexTransform:: write_datagram(BamWriter *manager, Datagram &dg) { VertexTransform::write_datagram(manager, dg); @@ -84,14 +70,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type UserVertexTransform is encountered -// in the Bam file. It should create the UserVertexTransform -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type UserVertexTransform is encountered in the Bam file. It should create + * the UserVertexTransform and extract its information from the file. + */ TypedWritable *UserVertexTransform:: make_from_bam(const FactoryParams ¶ms) { UserVertexTransform *object = new UserVertexTransform(""); @@ -104,13 +87,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new UserVertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new UserVertexTransform. + */ void UserVertexTransform:: fillin(DatagramIterator &scan, BamReader *manager) { VertexTransform::fillin(scan, manager); @@ -118,24 +98,19 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void UserVertexTransform::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { _matrix.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: UserVertexTransform::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new UserVertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new UserVertexTransform. + */ void UserVertexTransform::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _matrix.read_datagram(scan); diff --git a/panda/src/gobj/userVertexTransform.h b/panda/src/gobj/userVertexTransform.h index 1869858858..53b95c05f0 100644 --- a/panda/src/gobj/userVertexTransform.h +++ b/panda/src/gobj/userVertexTransform.h @@ -1,16 +1,15 @@ -// Filename: userVertexTransform.h -// Created by: drose (24Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userVertexTransform.h + * @author drose + * @date 2005-03-24 + */ #ifndef USERVERTEXTRANSFORM_H #define USERVERTEXTRANSFORM_H @@ -24,13 +23,11 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : UserVertexTransform -// Description : This is a specialization on VertexTransform that -// allows the user to specify any arbitrary transform -// matrix he likes. This is rarely used except for -// testing. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on VertexTransform that allows the user to specify + * any arbitrary transform matrix he likes. This is rarely used except for + * testing. + */ class EXPCL_PANDA_GOBJ UserVertexTransform : public VertexTransform { PUBLISHED: UserVertexTransform(const string &name); diff --git a/panda/src/gobj/vertexBufferContext.I b/panda/src/gobj/vertexBufferContext.I index 5e86268205..b57739cf09 100644 --- a/panda/src/gobj/vertexBufferContext.I +++ b/panda/src/gobj/vertexBufferContext.I @@ -1,23 +1,19 @@ -// Filename: vertexBufferContext.I -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexBufferContext.I + * @author drose + * @date 2005-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexBufferContext:: VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : BufferContext(&pgo->_vbuffer_residency), @@ -26,72 +22,59 @@ VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : { } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::get_data -// Access: Public -// Description: Returns the pointer to the client-side array data -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the client-side array data object. + */ INLINE GeomVertexArrayData *VertexBufferContext:: get_data() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::changed_size -// Access: Public -// Description: Returns true if the data has changed size since the -// last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has changed size since the last time mark_loaded() + * was called. + */ INLINE bool VertexBufferContext:: changed_size(const GeomVertexArrayDataHandle *reader) const { nassertr(reader->get_object() == _data, false); return get_data_size_bytes() != (size_t)reader->get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::changed_usage_hint -// Access: Public -// Description: Returns true if the data has changed its usage hint -// since the last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has changed its usage hint since the last time + * mark_loaded() was called. + */ INLINE bool VertexBufferContext:: changed_usage_hint(const GeomVertexArrayDataHandle *reader) const { nassertr(reader->get_object() == _data, false); return _usage_hint != reader->get_usage_hint(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::was_modified -// Access: Public -// Description: Returns true if the data has been modified since the -// last time mark_loaded() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data has been modified since the last time + * mark_loaded() was called. + */ INLINE bool VertexBufferContext:: was_modified(const GeomVertexArrayDataHandle *reader) const { nassertr(reader->get_object() == _data, false); return get_modified() != reader->get_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::update_data_size_bytes -// Access: Public -// Description: Should be called (usually by a derived class) when -// the on-card size of this object has changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called (usually by a derived class) when the on-card size of this + * object has changed. + */ INLINE void VertexBufferContext:: update_data_size_bytes(size_t new_data_size_bytes) { BufferContext::update_data_size_bytes(new_data_size_bytes); AdaptiveLruPage::set_lru_size(new_data_size_bytes); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::mark_loaded -// Access: Public -// Description: Should be called after the VertexBufferContext has been -// loaded into graphics memory, this updates the -// internal flags for changed_size() and modified(). -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the VertexBufferContext has been loaded into + * graphics memory, this updates the internal flags for changed_size() and + * modified(). + */ INLINE void VertexBufferContext:: mark_loaded(const GeomVertexArrayDataHandle *reader) { nassertv(reader->get_object() == _data); @@ -103,12 +86,9 @@ mark_loaded(const GeomVertexArrayDataHandle *reader) { set_resident(true); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::mark_unloaded -// Access: Public -// Description: Should be called after the buffer has been forced -// out of graphics memory. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the buffer has been forced out of graphics memory. + */ INLINE void VertexBufferContext:: mark_unloaded() { update_modified(UpdateSeq::old()); diff --git a/panda/src/gobj/vertexBufferContext.cxx b/panda/src/gobj/vertexBufferContext.cxx index ca1751bffe..cde6ec023a 100644 --- a/panda/src/gobj/vertexBufferContext.cxx +++ b/panda/src/gobj/vertexBufferContext.cxx @@ -1,37 +1,32 @@ -// Filename: vertexBufferContext.cxx -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexBufferContext.cxx + * @author drose + * @date 2005-03-17 + */ #include "vertexBufferContext.h" #include "config_gobj.h" TypeHandle VertexBufferContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexBufferContext:: output(ostream &out) const { out << *get_data() << ", " << get_data_size_bytes(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexBufferContext::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexBufferContext:: write(ostream &out, int indent_level) const { SavedContext::write(out, indent_level); diff --git a/panda/src/gobj/vertexBufferContext.h b/panda/src/gobj/vertexBufferContext.h index d8b986ca73..76956aa8d2 100644 --- a/panda/src/gobj/vertexBufferContext.h +++ b/panda/src/gobj/vertexBufferContext.h @@ -1,16 +1,15 @@ -// Filename: vertexBufferContext.h -// Created by: drose (17Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexBufferContext.h + * @author drose + * @date 2005-03-17 + */ #ifndef VERTEXBUFFERCONTEXT_H #define VERTEXBUFFERCONTEXT_H @@ -22,17 +21,15 @@ #include "preparedGraphicsObjects.h" #include "adaptiveLru.h" -//////////////////////////////////////////////////////////////////// -// Class : VertexBufferContext -// Description : This is a special class object that holds all the -// information returned by a particular GSG to indicate -// the vertex data array's internal context identifier. -// -// This allows the GSG to cache the vertex data array in -// whatever way makes sense. For instance, DirectX can -// allocate a vertex buffer for the array. OpenGL can -// create a buffer object. -//////////////////////////////////////////////////////////////////// +/** + * This is a special class object that holds all the information returned by a + * particular GSG to indicate the vertex data array's internal context + * identifier. + * + * This allows the GSG to cache the vertex data array in whatever way makes + * sense. For instance, DirectX can allocate a vertex buffer for the array. + * OpenGL can create a buffer object. + */ class EXPCL_PANDA_GOBJ VertexBufferContext : public BufferContext, public AdaptiveLruPage { public: INLINE VertexBufferContext(PreparedGraphicsObjects *pgo, @@ -54,9 +51,9 @@ public: virtual void write(ostream &out, int indent_level) const; private: - // This cannot be a PT(GeomVertexArrayData), because the data and - // the GSG both own their VertexBufferContexts! That would create a - // circular reference count. + // This cannot be a PT(GeomVertexArrayData), because the data and the GSG + // both own their VertexBufferContexts! That would create a circular + // reference count. GeomVertexArrayData *_data; GeomEnums::UsageHint _usage_hint; @@ -88,4 +85,3 @@ inline ostream &operator << (ostream &out, const VertexBufferContext &context) { #include "vertexBufferContext.I" #endif - diff --git a/panda/src/gobj/vertexDataBlock.I b/panda/src/gobj/vertexDataBlock.I index d2652e671e..61aa8e3a14 100644 --- a/panda/src/gobj/vertexDataBlock.I +++ b/panda/src/gobj/vertexDataBlock.I @@ -1,52 +1,41 @@ -// Filename: vertexDataBlock.I -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBlock.I + * @author drose + * @date 2007-06-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBlock::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataBlock:: VertexDataBlock(VertexDataPage *page, size_t start, size_t size) : SimpleAllocatorBlock(page, start, size) { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBlock::get_page -// Access: Published -// Description: Returns the page from which this buffer was -// allocated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the page from which this buffer was allocated. + */ INLINE VertexDataPage *VertexDataBlock:: get_page() const { return (VertexDataPage *)get_allocator(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBlock::get_pointer -// Access: Public -// Description: Returns a pointer to the start of the allocated -// memory for this buffer, or NULL if the data is not -// currently resident. If the data is not currently -// resident, this will implicitly request it to become -// resident soon. -// -// If force is true, this method will never return NULL, -// but may block until the data is available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the start of the allocated memory for this buffer, or + * NULL if the data is not currently resident. If the data is not currently + * resident, this will implicitly request it to become resident soon. + * + * If force is true, this method will never return NULL, but may block until + * the data is available. + */ INLINE unsigned char *VertexDataBlock:: get_pointer(bool force) const { nassertr(get_page() != (VertexDataPage *)NULL, NULL); @@ -58,12 +47,10 @@ get_pointer(bool force) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBlock::get_next_block -// Access: Published -// Description: Returns a pointer to the next allocated block in the -// chain, or NULL if there are no more allocated blocks. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the next allocated block in the chain, or NULL if + * there are no more allocated blocks. + */ INLINE VertexDataBlock *VertexDataBlock:: get_next_block() const { return (VertexDataBlock *)SimpleAllocatorBlock::get_next_block(); diff --git a/panda/src/gobj/vertexDataBlock.cxx b/panda/src/gobj/vertexDataBlock.cxx index 33be47ed3a..89c41390d5 100644 --- a/panda/src/gobj/vertexDataBlock.cxx +++ b/panda/src/gobj/vertexDataBlock.cxx @@ -1,15 +1,14 @@ -// Filename: vertexDataBlock.cxx -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBlock.cxx + * @author drose + * @date 2007-06-04 + */ #include "vertexDataBlock.h" diff --git a/panda/src/gobj/vertexDataBlock.h b/panda/src/gobj/vertexDataBlock.h index 715c0a0153..d6ffae25ad 100644 --- a/panda/src/gobj/vertexDataBlock.h +++ b/panda/src/gobj/vertexDataBlock.h @@ -1,16 +1,15 @@ -// Filename: vertexDataBlock.h -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBlock.h + * @author drose + * @date 2007-06-04 + */ #ifndef VERTEXDATABLOCK_H #define VERTEXDATABLOCK_H @@ -23,11 +22,10 @@ class VertexDataPage; class VertexDataBlock; -//////////////////////////////////////////////////////////////////// -// Class : VertexDataBlock -// Description : A block of bytes that stores the actual raw vertex -// data referenced by a GeomVertexArrayData object. -//////////////////////////////////////////////////////////////////// +/** + * A block of bytes that stores the actual raw vertex data referenced by a + * GeomVertexArrayData object. + */ class EXPCL_PANDA_GOBJ VertexDataBlock : public SimpleAllocatorBlock, public ReferenceCount { protected: INLINE VertexDataBlock(VertexDataPage *page, diff --git a/panda/src/gobj/vertexDataBook.I b/panda/src/gobj/vertexDataBook.I index 0099c7c86e..fc335fadf1 100644 --- a/panda/src/gobj/vertexDataBook.I +++ b/panda/src/gobj/vertexDataBook.I @@ -1,47 +1,37 @@ -// Filename: vertexDataBook.I -// Created by: drose (16May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBook.I + * @author drose + * @date 2007-05-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::alloc -// Access: Published -// Description: Allocates and returns a new VertexDataBuffer of the -// requested size. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new VertexDataBuffer of the requested size. + */ INLINE VertexDataBlock *VertexDataBook:: alloc(size_t size) { MutexHolder holder(_lock); return do_alloc(size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::get_num_pages -// Access: Published -// Description: Returns the number of pages created for the book. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pages created for the book. + */ INLINE size_t VertexDataBook:: get_num_pages() const { return _pages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::create_new_page -// Access: Private -// Description: Creates a new page of sufficient size to hold the -// requested block. The page is not added to the _pages -// list. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new page of sufficient size to hold the requested block. The + * page is not added to the _pages list. + */ INLINE VertexDataPage *VertexDataBook:: create_new_page(size_t size) { size_t page_size = ((size + _block_size - 1) / _block_size) * _block_size; diff --git a/panda/src/gobj/vertexDataBook.cxx b/panda/src/gobj/vertexDataBook.cxx index 6b0aa07ff0..5be3a0718a 100644 --- a/panda/src/gobj/vertexDataBook.cxx +++ b/panda/src/gobj/vertexDataBook.cxx @@ -1,47 +1,39 @@ -// Filename: vertexDataBook.cxx -// Created by: drose (16May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBook.cxx + * @author drose + * @date 2007-05-16 + */ #include "vertexDataBook.h" #include "mutexHolder.h" -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataBook:: VertexDataBook(size_t block_size) { - // Make sure the block_size is an integer multiple of the system's - // page size. + // Make sure the block_size is an integer multiple of the system's page + // size. _block_size = memory_hook->round_up_to_page_size(block_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataBook:: ~VertexDataBook() { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::count_total_page_size -// Access: Published -// Description: Returns the total size of all bytes owned by all -// pages owned by this book. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all bytes owned by all pages owned by this book. + */ size_t VertexDataBook:: count_total_page_size() const { MutexHolder holder(_lock); @@ -54,13 +46,10 @@ count_total_page_size() const { return total; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::count_total_page_size -// Access: Published -// Description: Returns the total size of all bytes owned by all -// pages owned by this book that have the indicated ram -// class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all bytes owned by all pages owned by this book + * that have the indicated ram class. + */ size_t VertexDataBook:: count_total_page_size(VertexDataPage::RamClass ram_class) const { MutexHolder holder(_lock); @@ -75,12 +64,10 @@ count_total_page_size(VertexDataPage::RamClass ram_class) const { return total; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::count_allocated_size -// Access: Published -// Description: Returns the total size of all bytes allocated within -// pages owned by this book. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all bytes allocated within pages owned by this + * book. + */ size_t VertexDataBook:: count_allocated_size() const { MutexHolder holder(_lock); @@ -93,13 +80,10 @@ count_allocated_size() const { return total; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::count_allocated_size -// Access: Published -// Description: Returns the total size of all bytes allocated within -// pages owned by this book that have the indicated ram -// class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total size of all bytes allocated within pages owned by this + * book that have the indicated ram class. + */ size_t VertexDataBook:: count_allocated_size(VertexDataPage::RamClass ram_class) const { MutexHolder holder(_lock); @@ -114,14 +98,11 @@ count_allocated_size(VertexDataPage::RamClass ram_class) const { return total; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::save_to_disk -// Access: Published -// Description: Writes all pages to disk immediately, just in case -// they get evicted later. It makes sense to make this -// call just before taking down a loading screen, to -// minimize chugs from saving pages inadvertently later. -//////////////////////////////////////////////////////////////////// +/** + * Writes all pages to disk immediately, just in case they get evicted later. + * It makes sense to make this call just before taking down a loading screen, + * to minimize chugs from saving pages inadvertently later. + */ void VertexDataBook:: save_to_disk() { MutexHolder holder(_lock); @@ -133,36 +114,31 @@ save_to_disk() { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBook::do_alloc -// Access: Private -// Description: Allocates and returns a new VertexDataBuffer of the -// requested size. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new VertexDataBuffer of the requested size. + * + * Assumes the lock is already held. + */ VertexDataBlock *VertexDataBook:: do_alloc(size_t size) { - // Look for an empty page of the appropriate size. The _pages set - // is sorted so that the pages with the smallest available blocks - // are at the front. - + // Look for an empty page of the appropriate size. The _pages set is sorted + // so that the pages with the smallest available blocks are at the front. + // Create a dummy page to use to search the set. VertexDataPage size_page(size); Pages::iterator pi = _pages.lower_bound(&size_page); - // Now we can start from the first element of the set that is - // possibly large enough to contain this block, and work up from - // there. + // Now we can start from the first element of the set that is possibly large + // enough to contain this block, and work up from there. while (pi != _pages.end()) { Pages::iterator pnext = pi; ++pnext; VertexDataPage *page = (*pi); - // Allocating a block may change the page's available contiguous - // size, and thereby change its position in the set, invalidating - // the iterator pi. This is why we've already computed pnext. + // Allocating a block may change the page's available contiguous size, and + // thereby change its position in the set, invalidating the iterator pi. + // This is why we've already computed pnext. VertexDataBlock *block = page->do_alloc(size); if (block != (VertexDataBlock *)NULL) { @@ -174,8 +150,8 @@ do_alloc(size_t size) { pi = pnext; } - // No page was good enough. Create a new page. Make it at least - // large enough to hold this requested block. + // No page was good enough. Create a new page. Make it at least large + // enough to hold this requested block. VertexDataPage *page = create_new_page(size); _pages.insert(page); diff --git a/panda/src/gobj/vertexDataBook.h b/panda/src/gobj/vertexDataBook.h index 953e0be0e9..dfbf649a54 100644 --- a/panda/src/gobj/vertexDataBook.h +++ b/panda/src/gobj/vertexDataBook.h @@ -1,16 +1,15 @@ -// Filename: vertexDataBook.h -// Created by: drose (16May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBook.h + * @author drose + * @date 2007-05-16 + */ #ifndef VERTEXDATABOOK_H #define VERTEXDATABOOK_H @@ -24,11 +23,10 @@ class VertexDataBlock; -//////////////////////////////////////////////////////////////////// -// Class : VertexDataBook -// Description : A collection of VertexDataPages, which can be used to -// allocate new VertexDataBlock objects. -//////////////////////////////////////////////////////////////////// +/** + * A collection of VertexDataPages, which can be used to allocate new + * VertexDataBlock objects. + */ class EXPCL_PANDA_GOBJ VertexDataBook { PUBLISHED: VertexDataBook(size_t block_size); diff --git a/panda/src/gobj/vertexDataBuffer.I b/panda/src/gobj/vertexDataBuffer.I index 18ca0c5eef..3652bae864 100644 --- a/panda/src/gobj/vertexDataBuffer.I +++ b/panda/src/gobj/vertexDataBuffer.I @@ -1,23 +1,19 @@ -// Filename: vertexDataBuffer.I -// Created by: drose (14May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBuffer.I + * @author drose + * @date 2007-05-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataBuffer:: VertexDataBuffer() : _resident_data(NULL), @@ -26,11 +22,9 @@ VertexDataBuffer() : { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataBuffer:: VertexDataBuffer(size_t size) : _resident_data(NULL), @@ -41,11 +35,9 @@ VertexDataBuffer(size_t size) : _size = size; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataBuffer:: VertexDataBuffer(const VertexDataBuffer ©) : _resident_data(NULL), @@ -55,28 +47,22 @@ VertexDataBuffer(const VertexDataBuffer ©) : (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataBuffer:: ~VertexDataBuffer() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::get_read_pointer -// Access: Public -// Description: Returns a read-only pointer to the raw data, or NULL -// if the data is not currently resident. If the data -// is not currently resident, this will implicitly -// request it to become resident soon. -// -// If force is true, this method will never return NULL -// (unless the data is actually empty), but may block -// until the data is available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the raw data, or NULL if the data is not + * currently resident. If the data is not currently resident, this will + * implicitly request it to become resident soon. + * + * If force is true, this method will never return NULL (unless the data is + * actually empty), but may block until the data is available. + */ INLINE const unsigned char *VertexDataBuffer:: get_read_pointer(bool force) const { LightMutexHolder holder(_lock); @@ -88,19 +74,17 @@ get_read_pointer(bool force) const { nassertr(_block != (VertexDataBlock *)NULL, NULL); nassertr(_reserved_size >= _size, NULL); - // We don't necessarily need to page the buffer all the way into - // independent status; it's sufficient just to return the block's - // pointer, which will force its page to resident status. + // We don't necessarily need to page the buffer all the way into independent + // status; it's sufficient just to return the block's pointer, which will + // force its page to resident status. return _block->get_pointer(force); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::get_write_pointer -// Access: Public -// Description: Returns a writable pointer to the raw data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a writable pointer to the raw data. + */ INLINE unsigned char *VertexDataBuffer:: -get_write_pointer() { +get_write_pointer() { LightMutexHolder holder(_lock); if (_resident_data == (unsigned char *)NULL && _reserved_size != 0) { @@ -110,40 +94,31 @@ get_write_pointer() { return _resident_data; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::get_size -// Access: Public -// Description: Returns the number of bytes in the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes in the buffer. + */ INLINE size_t VertexDataBuffer:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::get_reserved_size -// Access: Public -// Description: Returns the total number of bytes "reserved" in the -// buffer. This may be greater than or equal to -// get_size(). If it is greater, the additional bytes -// are extra unused bytes in the buffer, and this -// indicates the maximum value that may be passed to -// set_size() without first calling one of the realloc -// methods. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of bytes "reserved" in the buffer. This may be + * greater than or equal to get_size(). If it is greater, the additional + * bytes are extra unused bytes in the buffer, and this indicates the maximum + * value that may be passed to set_size() without first calling one of the + * realloc methods. + */ INLINE size_t VertexDataBuffer:: get_reserved_size() const { return _reserved_size; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::set_size -// Access: Public -// Description: Changes the size of the buffer. The new size must be -// less than or equal to the "reserved" size, which can -// only be changed via clean_realloc() or -// unclean_realloc(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of the buffer. The new size must be less than or equal to + * the "reserved" size, which can only be changed via clean_realloc() or + * unclean_realloc(). + */ INLINE void VertexDataBuffer:: set_size(size_t size) { LightMutexHolder holder(_lock); @@ -158,44 +133,36 @@ set_size(size_t size) { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::clean_realloc -// Access: Public -// Description: Changes the "reserved" size of the buffer, preserving -// its data (except for any data beyond the new end of -// the buffer, if the buffer is being reduced). If the -// buffer is expanded, the new data is uninitialized. -// -// It is an error to set the reserved size smaller than -// the size specified with set_size(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the "reserved" size of the buffer, preserving its data (except for + * any data beyond the new end of the buffer, if the buffer is being reduced). + * If the buffer is expanded, the new data is uninitialized. + * + * It is an error to set the reserved size smaller than the size specified + * with set_size(). + */ INLINE void VertexDataBuffer:: clean_realloc(size_t reserved_size) { LightMutexHolder holder(_lock); do_clean_realloc(reserved_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::unclean_realloc -// Access: Public -// Description: Changes the size of the buffer, without regard to -// preserving its data. The buffer may contain random -// data after this call. -// -// It is an error to set the reserved size smaller than -// the size specified with set_size(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of the buffer, without regard to preserving its data. The + * buffer may contain random data after this call. + * + * It is an error to set the reserved size smaller than the size specified + * with set_size(). + */ INLINE void VertexDataBuffer:: unclean_realloc(size_t reserved_size) { LightMutexHolder holder(_lock); do_unclean_realloc(reserved_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::clear -// Access: Public -// Description: Empties the buffer and sets its size to 0. -//////////////////////////////////////////////////////////////////// +/** + * Empties the buffer and sets its size to 0. + */ INLINE void VertexDataBuffer:: clear() { LightMutexHolder holder(_lock); @@ -203,16 +170,12 @@ clear() { do_unclean_realloc(0); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::page_out -// Access: Public -// Description: Moves the buffer out of independent memory and puts -// it on a page in the indicated book. The buffer may -// still be directly accessible as long as its page -// remains resident. Any subsequent attempt to rewrite -// the buffer will implicitly move it off of the page -// and back into independent memory. -//////////////////////////////////////////////////////////////////// +/** + * Moves the buffer out of independent memory and puts it on a page in the + * indicated book. The buffer may still be directly accessible as long as its + * page remains resident. Any subsequent attempt to rewrite the buffer will + * implicitly move it off of the page and back into independent memory. + */ INLINE void VertexDataBuffer:: page_out(VertexDataBook &book) { LightMutexHolder holder(_lock); diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index 11bd743b2c..1e3b884893 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: vertexDataBuffer.cxx -// Created by: drose (14May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBuffer.cxx + * @author drose + * @date 2007-05-14 + */ #include "vertexDataBuffer.h" #include "config_gobj.h" @@ -18,11 +17,9 @@ TypeHandle VertexDataBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexDataBuffer:: operator = (const VertexDataBuffer ©) { LightMutexHolder holder(_lock); @@ -35,8 +32,8 @@ operator = (const VertexDataBuffer ©) { _resident_data = NULL; } if (copy._resident_data != (unsigned char *)NULL && copy._size != 0) { - // We only allocate _size bytes, not the full _reserved_size - // allocated by the original copy. + // We only allocate _size bytes, not the full _reserved_size allocated by + // the original copy. get_class_type().inc_memory_usage(TypeHandle::MC_array, (int)copy._size); _resident_data = (unsigned char *)PANDA_MALLOC_ARRAY(copy._size); memcpy(_resident_data, copy._resident_data, copy._size); @@ -47,12 +44,9 @@ operator = (const VertexDataBuffer ©) { nassertv(_reserved_size >= _size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::swap -// Access: Public -// Description: Swaps the data buffers between this one and the other -// one. -//////////////////////////////////////////////////////////////////// +/** + * Swaps the data buffers between this one and the other one. + */ void VertexDataBuffer:: swap(VertexDataBuffer &other) { LightMutexHolder holder(_lock); @@ -75,23 +69,20 @@ swap(VertexDataBuffer &other) { nassertv(_reserved_size >= _size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::do_clean_realloc -// Access: Private -// Description: Changes the reserved size of the buffer, preserving -// its data (except for any data beyond the new end of -// the buffer, if the buffer is being reduced). If the -// buffer is expanded, the new data is uninitialized. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Changes the reserved size of the buffer, preserving its data (except for + * any data beyond the new end of the buffer, if the buffer is being reduced). + * If the buffer is expanded, the new data is uninitialized. + * + * Assumes the lock is already held. + */ void VertexDataBuffer:: do_clean_realloc(size_t reserved_size) { if (reserved_size != _reserved_size) { if (reserved_size == 0 || _size == 0) { do_unclean_realloc(reserved_size); return; - } + } if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -102,7 +93,7 @@ do_clean_realloc(size_t reserved_size) { if (_reserved_size != 0 && _resident_data == (unsigned char *)NULL) { do_page_in(); } - + get_class_type().inc_memory_usage(TypeHandle::MC_array, (int)reserved_size - (int)_reserved_size); if (_reserved_size == 0) { nassertv(_resident_data == (unsigned char *)NULL); @@ -118,15 +109,12 @@ do_clean_realloc(size_t reserved_size) { _size = min(_size, _reserved_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::do_unclean_realloc -// Access: Private -// Description: Changes the reserved size of the buffer, without -// regard to preserving its data. This implicitly -// resets the size to 0. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Changes the reserved size of the buffer, without regard to preserving its + * data. This implicitly resets the size to 0. + * + * Assumes the lock is already held. + */ void VertexDataBuffer:: do_unclean_realloc(size_t reserved_size) { if (reserved_size != _reserved_size || _resident_data == (unsigned char *)NULL) { @@ -137,7 +125,7 @@ do_unclean_realloc(size_t reserved_size) { // If we're paged out, discard the page. _block = NULL; - + if (_resident_data != (unsigned char *)NULL) { nassertv(_reserved_size != 0); @@ -159,18 +147,14 @@ do_unclean_realloc(size_t reserved_size) { _size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::do_page_out -// Access: Private -// Description: Moves the buffer out of independent memory and puts -// it on a page in the indicated book. The buffer may -// still be directly accessible as long as its page -// remains resident. Any subsequent attempt to rewrite -// the buffer will implicitly move it off of the page -// and back into independent memory. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Moves the buffer out of independent memory and puts it on a page in the + * indicated book. The buffer may still be directly accessible as long as its + * page remains resident. Any subsequent attempt to rewrite the buffer will + * implicitly move it off of the page and back into independent memory. + * + * Assumes the lock is already held. + */ void VertexDataBuffer:: do_page_out(VertexDataBook &book) { if (_block != (VertexDataBlock *)NULL || _reserved_size == 0) { @@ -180,8 +164,8 @@ do_page_out(VertexDataBook &book) { nassertv(_resident_data != (unsigned char *)NULL); if (_size == 0) { - // It's an empty buffer. Just deallocate it; don't bother to - // create a block. + // It's an empty buffer. Just deallocate it; don't bother to create a + // block. get_class_type().dec_memory_usage(TypeHandle::MC_array, (int)_reserved_size); PANDA_FREE_ARRAY(_resident_data); _resident_data = NULL; @@ -195,7 +179,7 @@ do_page_out(VertexDataBook &book) { unsigned char *pointer = _block->get_pointer(true); nassertv(pointer != (unsigned char *)NULL); memcpy(pointer, _resident_data, _size); - + get_class_type().dec_memory_usage(TypeHandle::MC_array, (int)_reserved_size); PANDA_FREE_ARRAY(_resident_data); _resident_data = NULL; @@ -205,15 +189,12 @@ do_page_out(VertexDataBook &book) { nassertv(_reserved_size >= _size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataBuffer::do_page_in -// Access: Private -// Description: Moves the buffer off of its current page and into -// independent memory. If the page is not already -// resident, it is forced resident first. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Moves the buffer off of its current page and into independent memory. If + * the page is not already resident, it is forced resident first. + * + * Assumes the lock is already held. + */ void VertexDataBuffer:: do_page_in() { if (_resident_data != (unsigned char *)NULL || _reserved_size == 0) { @@ -227,6 +208,6 @@ do_page_in() { get_class_type().inc_memory_usage(TypeHandle::MC_array, (int)_size); _resident_data = (unsigned char *)PANDA_MALLOC_ARRAY(_size); nassertv(_resident_data != (unsigned char *)NULL); - + memcpy(_resident_data, _block->get_pointer(true), _size); } diff --git a/panda/src/gobj/vertexDataBuffer.h b/panda/src/gobj/vertexDataBuffer.h index 3f810d9378..2a18aeda45 100644 --- a/panda/src/gobj/vertexDataBuffer.h +++ b/panda/src/gobj/vertexDataBuffer.h @@ -1,16 +1,15 @@ -// Filename: vertexDataBuffer.h -// Created by: drose (14May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataBuffer.h + * @author drose + * @date 2007-05-14 + */ #ifndef VERTEXDATABUFFER_H #define VERTEXDATABUFFER_H @@ -24,40 +23,32 @@ #include "lightMutex.h" #include "lightMutexHolder.h" -//////////////////////////////////////////////////////////////////// -// Class : VertexDataBuffer -// Description : A block of bytes that stores the actual raw vertex -// data referenced by a GeomVertexArrayData object. -// -// At any point, a buffer may be in any of two states: -// -// independent - the buffer's memory is resident, and -// owned by the VertexDataBuffer object itself (in -// _resident_data). In this state, _reserved_size might -// be greater than or equal to _size. -// -// paged - the buffer's memory is owned by a -// VertexDataBlock. That block might itself be -// resident, compressed, or paged to disk. If it is -// resident, the memory may still be accessed directly -// from the block. However, this memory is considered -// read-only. In this state, _reserved_size will always -// equal _size. -// -// VertexDataBuffers start out in independent state. -// They get moved to paged state when their owning -// GeomVertexArrayData objects get evicted from the -// _independent_lru. They can get moved back to -// independent state if they are modified -// (e.g. get_write_pointer() or realloc() is called). -// -// The idea is to keep the highly dynamic and -// frequently-modified VertexDataBuffers resident in -// easy-to-access memory, while collecting the static -// and rarely accessed VertexDataBuffers together onto -// pages, where they may be written to disk as a block -// when necessary. -//////////////////////////////////////////////////////////////////// +/** + * A block of bytes that stores the actual raw vertex data referenced by a + * GeomVertexArrayData object. + * + * At any point, a buffer may be in any of two states: + * + * independent - the buffer's memory is resident, and owned by the + * VertexDataBuffer object itself (in _resident_data). In this state, + * _reserved_size might be greater than or equal to _size. + * + * paged - the buffer's memory is owned by a VertexDataBlock. That block + * might itself be resident, compressed, or paged to disk. If it is resident, + * the memory may still be accessed directly from the block. However, this + * memory is considered read-only. In this state, _reserved_size will always + * equal _size. + * + * VertexDataBuffers start out in independent state. They get moved to paged + * state when their owning GeomVertexArrayData objects get evicted from the + * _independent_lru. They can get moved back to independent state if they are + * modified (e.g. get_write_pointer() or realloc() is called). + * + * The idea is to keep the highly dynamic and frequently-modified + * VertexDataBuffers resident in easy-to-access memory, while collecting the + * static and rarely accessed VertexDataBuffers together onto pages, where + * they may be written to disk as a block when necessary. + */ class EXPCL_PANDA_GOBJ VertexDataBuffer { public: INLINE VertexDataBuffer(); diff --git a/panda/src/gobj/vertexDataPage.I b/panda/src/gobj/vertexDataPage.I index 947efbd278..0dd8109adb 100644 --- a/panda/src/gobj/vertexDataPage.I +++ b/panda/src/gobj/vertexDataPage.I @@ -1,52 +1,41 @@ -// Filename: vertexDataPage.I -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataPage.I + * @author drose + * @date 2007-06-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_ram_class -// Access: Published -// Description: Returns the current ram class of the array. If this -// is other than RC_resident, the array data is not -// resident in memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current ram class of the array. If this is other than + * RC_resident, the array data is not resident in memory. + */ INLINE VertexDataPage::RamClass VertexDataPage:: get_ram_class() const { MutexHolder holder(_lock); return _ram_class; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_pending_ram_class -// Access: Published -// Description: Returns the pending ram class of the array. If this -// is different from get_ram_class(), this page has been -// queued to be processed by the thread. Eventually the -// page will be set to this ram class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pending ram class of the array. If this is different from + * get_ram_class(), this page has been queued to be processed by the thread. + * Eventually the page will be set to this ram class. + */ INLINE VertexDataPage::RamClass VertexDataPage:: get_pending_ram_class() const { MutexHolder holder(_lock); return _pending_ram_class; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::request_resident -// Access: Published -// Description: Ensures that the page will become resident soon. -// Future calls to get_page_data() will eventually -// return non-NULL. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the page will become resident soon. Future calls to + * get_page_data() will eventually return non-NULL. + */ INLINE void VertexDataPage:: request_resident() { MutexHolder holder(_lock); @@ -55,75 +44,60 @@ request_resident() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::alloc -// Access: Published -// Description: Allocates a new block. Returns NULL if a block of the -// requested size cannot be allocated. -// -// To free the allocated block, call block->free(), or -// simply delete the block pointer. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new block. Returns NULL if a block of the requested size + * cannot be allocated. + * + * To free the allocated block, call block->free(), or simply delete the block + * pointer. + */ INLINE VertexDataBlock *VertexDataPage:: alloc(size_t size) { MutexHolder holder(_lock); return do_alloc(size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_first_block -// Access: Published -// Description: Returns a pointer to the first allocated block, or -// NULL if there are no allocated blocks. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the first allocated block, or NULL if there are no + * allocated blocks. + */ INLINE VertexDataBlock *VertexDataPage:: get_first_block() const { MutexHolder holder(_lock); return (VertexDataBlock *)SimpleAllocator::get_first_block(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_book -// Access: Published -// Description: Returns a pointer to the book that owns this page. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the book that owns this page. + */ INLINE VertexDataBook *VertexDataPage:: get_book() const { return _book; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_global_lru -// Access: Published, Static -// Description: Returns a pointer to the global LRU object that -// manages the VertexDataPage's with the indicated -// RamClass. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global LRU object that manages the + * VertexDataPage's with the indicated RamClass. + */ INLINE SimpleLru *VertexDataPage:: get_global_lru(RamClass rclass) { nassertr(rclass >= 0 && rclass < RC_end_of_list, NULL); return _global_lru[rclass]; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_pending_lru -// Access: Published, Static -// Description: Returns a pointer to the global LRU object that -// manages the VertexDataPage's that are pending -// processing by the thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global LRU object that manages the + * VertexDataPage's that are pending processing by the thread. + */ INLINE SimpleLru *VertexDataPage:: get_pending_lru() { return &_pending_lru; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_save_file -// Access: Published, Static -// Description: Returns the global VertexDataSaveFile that will be -// used to save vertex data buffers to disk when -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global VertexDataSaveFile that will be used to save vertex data + * buffers to disk when necessary. + */ INLINE VertexDataSaveFile *VertexDataPage:: get_save_file() { if (_save_file == (VertexDataSaveFile *)NULL) { @@ -132,30 +106,23 @@ get_save_file() { return _save_file; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::save_to_disk -// Access: Published -// Description: Writes the page to disk, but does not evict it from -// memory or affect its LRU status. If it gets evicted -// later without having been modified, it will not need -// to write itself to disk again. -//////////////////////////////////////////////////////////////////// +/** + * Writes the page to disk, but does not evict it from memory or affect its + * LRU status. If it gets evicted later without having been modified, it will + * not need to write itself to disk again. + */ INLINE bool VertexDataPage:: save_to_disk() { MutexHolder holder(_lock); return do_save_to_disk(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_num_threads -// Access: Published, Static -// Description: Returns the number of threads that have been spawned -// to service vertex paging requests, or 0 if no threads -// have been spawned (which may mean either that all -// paging requests will be handled by the main thread, -// or simply that no paging requests have yet been -// issued). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads that have been spawned to service vertex + * paging requests, or 0 if no threads have been spawned (which may mean + * either that all paging requests will be handled by the main thread, or + * simply that no paging requests have yet been issued). + */ INLINE int VertexDataPage:: get_num_threads() { MutexHolder holder(_tlock); @@ -165,12 +132,10 @@ get_num_threads() { return _thread_mgr->get_num_threads(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_num_pending_reads -// Access: Published, Static -// Description: Returns the number of read requests that are waiting -// to be serviced by a thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of read requests that are waiting to be serviced by a + * thread. + */ INLINE int VertexDataPage:: get_num_pending_reads() { MutexHolder holder(_tlock); @@ -180,12 +145,10 @@ get_num_pending_reads() { return _thread_mgr->get_num_pending_reads(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_num_pending_writes -// Access: Published, Static -// Description: Returns the number of write requests that are waiting -// to be serviced by a thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of write requests that are waiting to be serviced by a + * thread. + */ INLINE int VertexDataPage:: get_num_pending_writes() { MutexHolder holder(_tlock); @@ -195,17 +158,14 @@ get_num_pending_writes() { return _thread_mgr->get_num_pending_writes(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::get_page_data -// Access: Public -// Description: Returns a pointer to the page's data area, or NULL if -// the page is not currently resident. If the page is -// not currently resident, this will implicitly request -// it to become resident soon. -// -// If force is true, this method will never return NULL, -// but may block until the page is available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the page's data area, or NULL if the page is not + * currently resident. If the page is not currently resident, this will + * implicitly request it to become resident soon. + * + * If force is true, this method will never return NULL, but may block until + * the page is available. + */ INLINE unsigned char *VertexDataPage:: get_page_data(bool force) { MutexHolder holder(_lock); @@ -225,48 +185,39 @@ get_page_data(bool force) { return _page_data; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::operator -// Access: Public -// Description: This comparison method is used to order pages within -// a book. -//////////////////////////////////////////////////////////////////// +/** + * This comparison method is used to order pages within a book. + */ INLINE bool VertexDataPage:: operator < (const VertexDataPage &other) const { - // We sort pages so that the pages with the smallest number of - // available contiguous bytes come up first. We store our best - // estimate of continguous bytes here. + // We sort pages so that the pages with the smallest number of available + // contiguous bytes come up first. We store our best estimate of + // continguous bytes here. if (_book_size != other._book_size) { return _book_size < other._book_size; } - // For pages of equal size, we sort based on pointers, to make it - // easy to quickly find a specific page. + // For pages of equal size, we sort based on pointers, to make it easy to + // quickly find a specific page. return this < &other; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::set_ram_class -// Access: Private -// Description: Puts the data in a new ram class. Assumes the page -// lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Puts the data in a new ram class. Assumes the page lock is already held. + */ INLINE void VertexDataPage:: set_ram_class(RamClass rclass) { _ram_class = rclass; mark_used_lru(_global_lru[rclass]); - // Changing the ram class might make our effective available space 0 - // and thereby change the placement within the book. + // Changing the ram class might make our effective available space 0 and + // thereby change the placement within the book. adjust_book_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::round_up -// Access: Private -// Description: Round page_size up to the next multiple of -// _block_size. -//////////////////////////////////////////////////////////////////// +/** + * Round page_size up to the next multiple of _block_size. + */ INLINE size_t VertexDataPage:: round_up(size_t page_size) const { return ((page_size + _block_size - 1) / _block_size) * _block_size; diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index 7fd13208cd..ada598b9df 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -1,16 +1,15 @@ -// Filename: vertexDataPage.cxx -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataPage.cxx + * @author drose + * @date 2007-06-04 + */ #include "vertexDataPage.h" #include "configVariableInt.h" @@ -56,9 +55,8 @@ ConfigVariableInt max_disk_vertex_data PT(VertexDataPage::PageThreadManager) VertexDataPage::_thread_mgr; -// This is a reference to an allocated Mutex, instead of just a static -// Mutex, to protect against ordering issues when the application -// shuts down. +// This is a reference to an allocated Mutex, instead of just a static Mutex, +// to protect against ordering issues when the application shuts down. Mutex &VertexDataPage::_tlock = *(new Mutex("VertexDataPage::_tlock")); SimpleLru VertexDataPage::_resident_lru("resident", max_resident_vertex_data); @@ -74,8 +72,8 @@ SimpleLru *VertexDataPage::_global_lru[RC_end_of_list] = { VertexDataSaveFile *VertexDataPage::_save_file; -// This mutex is (mostly) unused. We just need a Mutex to pass -// to the Book Constructor, below. +// This mutex is (mostly) unused. We just need a Mutex to pass to the Book +// Constructor, below. Mutex VertexDataPage::_unused_mutex; PStatCollector VertexDataPage::_vdata_compress_pcollector("*:Vertex Data:Compress"); @@ -94,23 +92,20 @@ static void * do_zlib_alloc(voidpf opaque, uInt items, uInt size) { return PANDA_MALLOC_ARRAY(items * size); } -static void +static void do_zlib_free(voidpf opaque, voidpf address) { PANDA_FREE_ARRAY(address); } #endif // HAVE_ZLIB && !USE_MEMORY_NOWRAPPERS -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::Book Constructor -// Access: Private -// Description: This constructor is used only by VertexDataBook, to -// create a mostly-empty object that can be used to -// search for a particular page size in the set. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is used only by VertexDataBook, to create a mostly-empty + * object that can be used to search for a particular page size in the set. + */ VertexDataPage:: -VertexDataPage(size_t book_size) : - SimpleAllocator(book_size, _unused_mutex), +VertexDataPage(size_t book_size) : + SimpleAllocator(book_size, _unused_mutex), SimpleLruPage(book_size), _book_size(book_size), _block_size(0), @@ -123,14 +118,12 @@ VertexDataPage(size_t book_size) : _pending_ram_class = RC_resident; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataPage:: -VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size) : - SimpleAllocator(page_size, book->_lock), +VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size) : + SimpleAllocator(page_size, book->_lock), SimpleLruPage(page_size), _book_size(page_size), _block_size(block_size), @@ -145,17 +138,14 @@ VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size) : set_ram_class(RC_resident); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::Destructor -// Access: Private, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataPage:: ~VertexDataPage() { - // Since the only way to delete a page is via the - // changed_contiguous() method, the lock will already be held. - // MutexHolder holder(_lock); + // Since the only way to delete a page is via the changed_contiguous() + // method, the lock will already be held. MutexHolder holder(_lock); { MutexHolder holder2(_tlock); @@ -173,13 +163,10 @@ VertexDataPage:: nassertv(_book == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::stop_threads -// Access: Published, Static -// Description: Call this to stop the paging threads, if they were -// started. This may block until all of the pending -// tasks have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Call this to stop the paging threads, if they were started. This may block + * until all of the pending tasks have been completed. + */ void VertexDataPage:: stop_threads() { PT(PageThreadManager) thread_mgr; @@ -196,12 +183,9 @@ stop_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::flush_threads -// Access: Published, Static -// Description: Waits for all of the pending thread tasks to finish -// before returning. -//////////////////////////////////////////////////////////////////// +/** + * Waits for all of the pending thread tasks to finish before returning. + */ void VertexDataPage:: flush_threads() { int num_threads = vertex_data_page_threads; @@ -223,44 +207,36 @@ flush_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexDataPage:: output(ostream &out) const { SimpleAllocator::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexDataPage:: write(ostream &out, int indent_level) const { SimpleAllocator::write(out); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_block -// Access: Protected, Virtual -// Description: Creates a new SimpleAllocatorBlock object. Override -// this function to specialize the block type returned. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new SimpleAllocatorBlock object. Override this function to + * specialize the block type returned. + */ SimpleAllocatorBlock *VertexDataPage:: make_block(size_t start, size_t size) { return new VertexDataBlock(this, start, size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::changed_contiguous -// Access: Protected, Virtual -// Description: This callback function is made whenever the estimate -// of contiguous available space changes, either through -// an alloc or free. The lock will be held. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is made whenever the estimate of contiguous + * available space changes, either through an alloc or free. The lock will be + * held. + */ void VertexDataPage:: changed_contiguous() { if (do_is_empty()) { @@ -276,21 +252,16 @@ changed_contiguous() { adjust_book_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void VertexDataPage:: evict_lru() { MutexHolder holder(_lock); @@ -317,39 +288,35 @@ evict_lru() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::do_alloc -// Access: Private -// Description: Allocates a new block. Returns NULL if a block of the -// requested size cannot be allocated. -// -// To free the allocated block, call block->free(), or -// simply delete the block pointer. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new block. Returns NULL if a block of the requested size + * cannot be allocated. + * + * To free the allocated block, call block->free(), or simply delete the block + * pointer. + * + * Assumes the lock is already held. + */ VertexDataBlock *VertexDataPage:: do_alloc(size_t size) { VertexDataBlock *block = (VertexDataBlock *)SimpleAllocator::do_alloc(size); if (block != (VertexDataBlock *)NULL && _ram_class != RC_disk) { - // When we allocate a new block within a resident page, we have to - // clear the disk cache (since we have just invalidated it). + // When we allocate a new block within a resident page, we have to clear + // the disk cache (since we have just invalidated it). _saved_block.clear(); } return block; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_resident_now -// Access: Private -// Description: Short-circuits the thread and forces the page into -// resident status immediately. -// -// Intended to be called from the main thread. Assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Short-circuits the thread and forces the page into resident status + * immediately. + * + * Intended to be called from the main thread. Assumes the lock is already + * held. + */ void VertexDataPage:: make_resident_now() { MutexHolder holder(_tlock); @@ -362,15 +329,13 @@ make_resident_now() { _pending_ram_class = RC_resident; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_resident -// Access: Private -// Description: Moves the page to fully resident status by -// expanding it or reading it from disk as necessary. -// -// Intended to be called from the sub-thread. Assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Moves the page to fully resident status by expanding it or reading it from + * disk as necessary. + * + * Intended to be called from the sub-thread. Assumes the lock is already + * held. + */ void VertexDataPage:: make_resident() { if (_ram_class == RC_resident) { @@ -459,14 +424,12 @@ make_resident() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_compressed -// Access: Private -// Description: Moves the page to compressed status by -// compressing it or reading it from disk as necessary. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Moves the page to compressed status by compressing it or reading it from + * disk as necessary. + * + * Assumes the lock is already held. + */ void VertexDataPage:: make_compressed() { if (_ram_class == RC_compressed) { @@ -499,7 +462,7 @@ make_compressed() { z_dest.opaque = Z_NULL; z_dest.msg = (char *) "no error message"; - + int result = deflateInit(&z_dest, vertex_data_compression_level); if (result < 0) { nassert_raise("zlib error"); @@ -511,10 +474,9 @@ make_compressed() { z_dest.avail_in = _uncompressed_size; size_t output_size = 0; - // Compress the data into one or more individual pages. We have - // to compress it page-at-a-time, since we're not really sure how - // big the result will be (so we can't easily pre-allocate a - // buffer). + // Compress the data into one or more individual pages. We have to + // compress it page-at-a-time, since we're not really sure how big the + // result will be (so we can't easily pre-allocate a buffer). int flush = 0; result = 0; while (result != Z_STREAM_END) { @@ -551,8 +513,8 @@ make_compressed() { result = deflateEnd(&z_dest); nassertv(result == Z_OK); - // Now we know how big the result will be. Allocate a buffer, and - // copy the data from the various pages. + // Now we know how big the result will be. Allocate a buffer, and copy + // the data from the various pages. size_t new_allocated_size = round_up(output_size); unsigned char *new_data = alloc_page_data(new_allocated_size); @@ -569,9 +531,9 @@ make_compressed() { page = next; } nassertv(copied_size == output_size); - - // Now free the original, uncompressed data, and put this new - // compressed buffer in its place. + + // Now free the original, uncompressed data, and put this new compressed + // buffer in its place. free_page_data(_page_data, _allocated_size); _page_data = new_data; _size = output_size; @@ -588,14 +550,11 @@ make_compressed() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_disk -// Access: Private -// Description: Moves the page to disk status by writing it to disk -// as necessary. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Moves the page to disk status by writing it to disk as necessary. + * + * Assumes the lock is already held. + */ void VertexDataPage:: make_disk() { if (_ram_class == RC_disk) { @@ -607,7 +566,7 @@ make_disk() { if (_ram_class == RC_resident || _ram_class == RC_compressed) { if (!do_save_to_disk()) { // Can't save it to disk for some reason. - gobj_cat.warning() + gobj_cat.warning() << "Couldn't save page " << this << " to disk.\n"; mark_used_lru(); return; @@ -616,22 +575,19 @@ make_disk() { free_page_data(_page_data, _allocated_size); _page_data = NULL; _size = 0; - + set_ram_class(RC_disk); } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::do_save_to_disk -// Access: Private -// Description: Writes the page to disk, but does not evict it from -// memory or affect its LRU status. If it gets evicted -// later without having been modified, it will not need -// to write itself to disk again. -// -// Returns true on success, false on failure. Assumes -// the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Writes the page to disk, but does not evict it from memory or affect its + * LRU status. If it gets evicted later without having been modified, it will + * not need to write itself to disk again. + * + * Returns true on success, false on failure. Assumes the lock is already + * held. + */ bool VertexDataPage:: do_save_to_disk() { if (_ram_class == RC_resident || _ram_class == RC_compressed) { @@ -644,7 +600,7 @@ do_save_to_disk() { } bool compressed = (_ram_class == RC_compressed); - + _saved_block = get_save_file()->write_data(_page_data, _allocated_size, compressed); if (_saved_block == (VertexDataSaveBlock *)NULL) { // Can't write it to disk. Too bad. @@ -657,19 +613,16 @@ do_save_to_disk() { } } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::do_restore_from_disk -// Access: Private -// Description: Restores the page from disk and makes it -// either compressed or resident (according to whether -// it was stored compressed on disk). -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Restores the page from disk and makes it either compressed or resident + * (according to whether it was stored compressed on disk). + * + * Assumes the lock is already held. + */ void VertexDataPage:: do_restore_from_disk() { if (_ram_class == RC_disk) { @@ -704,19 +657,15 @@ do_restore_from_disk() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::adjust_book_size -// Access: Private -// Description: Called when the "book size"--the size of the page as -// recorded in its book's table--has changed for some -// reason. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Called when the "book size"--the size of the page as recorded in its book's + * table--has changed for some reason. Assumes the lock is held. + */ void VertexDataPage:: adjust_book_size() { size_t new_size = _contiguous; if (_ram_class != RC_resident) { - // Let's not attempt to allocate new buffers from non-resident - // pages. + // Let's not attempt to allocate new buffers from non-resident pages. new_size = 0; } @@ -731,16 +680,13 @@ adjust_book_size() { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::request_ram_class -// Access: Private -// Description: Requests the thread set the page to the indicated ram -// class (if we are using threading). The page will be -// enqueued in the thread, which will eventually be -// responsible for setting the requested ram class. -// -// Assumes the page's lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Requests the thread set the page to the indicated ram class (if we are + * using threading). The page will be enqueued in the thread, which will + * eventually be responsible for setting the requested ram class. + * + * Assumes the page's lock is already held. + */ void VertexDataPage:: request_ram_class(RamClass ram_class) { int num_threads = vertex_data_page_threads; @@ -777,13 +723,10 @@ request_ram_class(RamClass ram_class) { _thread_mgr->add_page(this, ram_class); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::make_save_file -// Access: Private, Static -// Description: Creates the global VertexDataSaveFile that will be -// used to save vertex data buffers to disk when -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Creates the global VertexDataSaveFile that will be used to save vertex data + * buffers to disk when necessary. + */ void VertexDataPage:: make_save_file() { size_t max_size = (size_t)max_disk_vertex_data; @@ -792,34 +735,28 @@ make_save_file() { vertex_save_file_prefix, max_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::alloc_page_data -// Access: Private -// Description: Allocates and returns a freshly-allocated buffer of -// at least the indicated size for holding vertex data. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a freshly-allocated buffer of at least the indicated + * size for holding vertex data. + */ unsigned char *VertexDataPage:: alloc_page_data(size_t page_size) const { _alloc_pages_pcollector.add_level_now(page_size); return (unsigned char *)memory_hook->mmap_alloc(page_size, false); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::free_page_data -// Access: Private -// Description: Releases a buffer allocated via alloc_page_data(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a buffer allocated via alloc_page_data(). + */ void VertexDataPage:: free_page_data(unsigned char *page_data, size_t page_size) const { _alloc_pages_pcollector.sub_level_now(page_size); memory_hook->mmap_free(page_data, page_size); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::Constructor -// Access: Public -// Description: Assumes _tlock is held. -//////////////////////////////////////////////////////////////////// +/** + * Assumes _tlock is held. + */ VertexDataPage::PageThreadManager:: PageThreadManager(int num_threads) : _shutdown(false), @@ -827,16 +764,14 @@ PageThreadManager(int num_threads) : { start_threads(num_threads); } - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::add_page -// Access: Public -// Description: Enqueues the indicated page on the thread queue to -// convert it to the specified ram class. -// -// It is assumed the page's lock is already held, and -// that _tlock is already held. -//////////////////////////////////////////////////////////////////// + +/** + * Enqueues the indicated page on the thread queue to convert it to the + * specified ram class. + * + * It is assumed the page's lock is already held, and that _tlock is already + * held. + */ void VertexDataPage::PageThreadManager:: add_page(VertexDataPage *page, RamClass ram_class) { nassertv(!_shutdown); @@ -846,17 +781,17 @@ add_page(VertexDataPage *page, RamClass ram_class) { nassertv(page->get_lru() == &_pending_lru); return; } - + if (page->_pending_ram_class != page->_ram_class) { - // It's already queued, but for a different ram class. Dequeue it - // so we can requeue it. + // It's already queued, but for a different ram class. Dequeue it so we + // can requeue it. remove_page(page); } if (page->_pending_ram_class != ram_class) { - // First, move the page to the "pending" LRU. When it eventually - // gets its requested ram class set, it will be requeued on the - // appropriate live LRU. + // First, move the page to the "pending" LRU. When it eventually gets its + // requested ram class set, it will be requeued on the appropriate live + // LRU. page->mark_used_lru(&_pending_lru); page->_pending_ram_class = ram_class; @@ -869,15 +804,12 @@ add_page(VertexDataPage *page, RamClass ram_class) { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::remove_page -// Access: Public -// Description: Dequeues the indicated page and removes it from the -// pending task list. -// -// It is assumed the page's lock is already held, and -// that _tlock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Dequeues the indicated page and removes it from the pending task list. + * + * It is assumed the page's lock is already held, and that _tlock is already + * held. + */ void VertexDataPage::PageThreadManager:: remove_page(VertexDataPage *page) { nassertv(page != (VertexDataPage *)NULL); @@ -886,8 +818,8 @@ remove_page(VertexDataPage *page) { for (ti = _threads.begin(); ti != _threads.end(); ++ti) { PageThread *thread = (*ti); if (page == thread->_working_page) { - // Oops, this thread is currently working on this one. We'll have - // to wait for the thread to finish. + // Oops, this thread is currently working on this one. We'll have to + // wait for the thread to finish. page->_lock.release(); while (page == thread->_working_page) { thread->_working_cvar.wait(); @@ -898,62 +830,54 @@ remove_page(VertexDataPage *page) { } if (page->_pending_ram_class == RC_resident) { - PendingPages::iterator pi = + PendingPages::iterator pi = find(_pending_reads.begin(), _pending_reads.end(), page); nassertv(pi != _pending_reads.end()); _pending_reads.erase(pi); } else { - PendingPages::iterator pi = + PendingPages::iterator pi = find(_pending_writes.begin(), _pending_writes.end(), page); nassertv(pi != _pending_writes.end()); _pending_writes.erase(pi); } page->_pending_ram_class = page->_ram_class; - + // Put the page back on its proper LRU. page->mark_used_lru(_global_lru[page->_ram_class]); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::get_num_threads -// Access: Public -// Description: Returns the number of threads active on the thread -// manager. Assumes _tlock is held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads active on the thread manager. Assumes _tlock + * is held. + */ int VertexDataPage::PageThreadManager:: get_num_threads() const { return (int)_threads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::get_num_pending_reads -// Access: Public -// Description: Returns the number of read requests waiting on the -// queue. Assumes _tlock is held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of read requests waiting on the queue. Assumes _tlock + * is held. + */ int VertexDataPage::PageThreadManager:: get_num_pending_reads() const { return (int)_pending_reads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::get_num_pending_writes -// Access: Public -// Description: Returns the number of write requests waiting on the -// queue. Assumes _tlock is held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of write requests waiting on the queue. Assumes _tlock + * is held. + */ int VertexDataPage::PageThreadManager:: get_num_pending_writes() const { return (int)_pending_writes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::start_threads -// Access: Public -// Description: Adds the indicated of threads to the list of active -// threads. Assumes _tlock is held. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated of threads to the list of active threads. Assumes + * _tlock is held. + */ void VertexDataPage::PageThreadManager:: start_threads(int num_threads) { _shutdown = false; @@ -968,13 +892,10 @@ start_threads(int num_threads) { } } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThreadManager::stop_threads -// Access: Public -// Description: Signals all the threads to stop and waits for them. -// Does not return until the threads have finished. -// Assumes _tlock is *not* held. -//////////////////////////////////////////////////////////////////// +/** + * Signals all the threads to stop and waits for them. Does not return until + * the threads have finished. Assumes _tlock is *not* held. + */ void VertexDataPage::PageThreadManager:: stop_threads() { PageThreads threads; @@ -994,24 +915,20 @@ stop_threads() { nassertv(_pending_reads.empty() && _pending_writes.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataPage::PageThread:: -PageThread(PageThreadManager *manager, const string &name) : +PageThread(PageThreadManager *manager, const string &name) : Thread(name, name), _manager(manager), _working_cvar(_tlock) { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataPage::PageThread::thread_main -// Access: Protected, Virtual -// Description: The main processing loop for each sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * The main processing loop for each sub-thread. + */ void VertexDataPage::PageThread:: thread_main() { _tlock.acquire(); @@ -1019,7 +936,7 @@ thread_main() { while (true) { PStatClient::thread_tick(get_sync_name()); - while (_manager->_pending_reads.empty() && + while (_manager->_pending_reads.empty() && _manager->_pending_writes.empty()) { if (_manager->_shutdown) { _tlock.release(); @@ -1047,11 +964,11 @@ thread_main() { case RC_resident: _working_page->make_resident(); break; - + case RC_compressed: _working_page->make_compressed(); break; - + case RC_disk: _working_page->make_disk(); break; @@ -1060,7 +977,7 @@ thread_main() { break; } } - + _tlock.acquire(); _working_page = NULL; diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 7553cdd9f1..5149663e6b 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -1,16 +1,15 @@ -// Filename: vertexDataPage.h -// Created by: drose (04Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataPage.h + * @author drose + * @date 2007-06-04 + */ #ifndef VERTEXDATAPAGE_H #define VERTEXDATAPAGE_H @@ -30,13 +29,11 @@ class VertexDataBook; class VertexDataBlock; -//////////////////////////////////////////////////////////////////// -// Class : VertexDataPage -// Description : A block of bytes that holds one or more -// VertexDataBlocks. The entire page may be paged out, -// in the form of in-memory compression or to an on-disk -// cache file, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * A block of bytes that holds one or more VertexDataBlocks. The entire page + * may be paged out, in the form of in-memory compression or to an on-disk + * cache file, if necessary. + */ class EXPCL_PANDA_GOBJ VertexDataPage : public SimpleAllocator, public SimpleLruPage { private: VertexDataPage(size_t book_size); @@ -44,9 +41,9 @@ private: virtual ~VertexDataPage(); PUBLISHED: - // These are used to indicate the current residency state of the - // page, which may or may not have been temporarily evicted to - // satisfy memory requirements. + // These are used to indicate the current residency state of the page, which + // may or may not have been temporarily evicted to satisfy memory + // requirements. enum RamClass { RC_resident, RC_compressed, @@ -124,9 +121,8 @@ private: private: PageThreadManager *_manager; VertexDataPage *_working_page; - - // Signaled when _working_page is set to NULL after finishing a - // task. + + // Signaled when _working_page is set to NULL after finishing a task. ConditionVar _working_cvar; friend class PageThreadManager; }; @@ -148,9 +144,8 @@ private: PendingPages _pending_reads; bool _shutdown; - // Signaled when anything new is added to either of the above - // queues, or when _shutdown is set true. This wakes up any - // pending thread. + // Signaled when anything new is added to either of the above queues, or + // when _shutdown is set true. This wakes up any pending thread. ConditionVarFull _pending_cvar; PageThreads _threads; @@ -167,7 +162,7 @@ private: size_t _book_size; size_t _block_size; - //Mutex _lock; // Inherited from SimpleAllocator. Protects above members. + // Mutex _lock; Inherited from SimpleAllocator. Protects above members. RamClass _pending_ram_class; // Protected by _tlock. VertexDataBook *_book; // never changes. @@ -187,7 +182,7 @@ private: unsigned char _buffer[deflate_page_size]; size_t _used_size; DeflatePage *_next; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -195,7 +190,7 @@ private: static void init_type() { register_type(_type_handle, "VertexDataPage::DeflatePage"); } - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/gobj/vertexDataSaveFile.I b/panda/src/gobj/vertexDataSaveFile.I index 412212cf8d..b5ff1794dc 100644 --- a/panda/src/gobj/vertexDataSaveFile.I +++ b/panda/src/gobj/vertexDataSaveFile.I @@ -1,85 +1,67 @@ -// Filename: vertexDataSaveFile.I -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataSaveFile.I + * @author drose + * @date 2007-05-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::is_valid -// Access: Public -// Description: Returns true if the save file was successfully -// created and is ready for use, false if there was an -// error. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the save file was successfully created and is ready for + * use, false if there was an error. + */ INLINE bool VertexDataSaveFile:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::get_total_file_size -// Access: Public -// Description: Returns the amount of space consumed by the save -// file, including unused portions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of space consumed by the save file, including unused + * portions. + */ INLINE size_t VertexDataSaveFile:: get_total_file_size() const { return _total_file_size; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::get_used_file_size -// Access: Public -// Description: Returns the amount of space within the save file that -// is currently in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of space within the save file that is currently in use. + */ INLINE size_t VertexDataSaveFile:: get_used_file_size() const { return SimpleAllocator::get_total_size(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveBlock::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexDataSaveBlock:: VertexDataSaveBlock(VertexDataSaveFile *file, size_t start, size_t size) : SimpleAllocatorBlock(file, start, size) { } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveBlock::set_compressed -// Access: Public -// Description: Sets the compressed flag. This is true to indicate -// the data is written in zlib-compressed form to the -// save file; false to indicate the data is -// uncompressed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the compressed flag. This is true to indicate the data is written in + * zlib-compressed form to the save file; false to indicate the data is + * uncompressed. + */ INLINE void VertexDataSaveBlock:: set_compressed(bool compressed) { _compressed = compressed; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveBlock::get_compressed -// Access: Public -// Description: Returns the compressed flag. This is true to -// indicate the data is written in zlib-compressed form -// to the save file; false to indicate the data is -// uncompressed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the compressed flag. This is true to indicate the data is written + * in zlib-compressed form to the save file; false to indicate the data is + * uncompressed. + */ INLINE bool VertexDataSaveBlock:: get_compressed() const { return _compressed; diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index 22deb2de5d..0aa8abff56 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -1,16 +1,15 @@ -// Filename: vertexDataSaveFile.cxx -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataSaveFile.cxx + * @author drose + * @date 2007-05-12 + */ #include "vertexDataSaveFile.h" #include "mutexHolder.h" @@ -24,11 +23,9 @@ #include #endif // _WIN32 -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataSaveFile:: VertexDataSaveFile(const Filename &directory, const string &prefix, size_t max_size) : @@ -57,14 +54,14 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, if (gobj_cat.is_debug()) { gobj_cat.debug() - << "Creating vertex data save file " << os_specific << "\n"; + << "Creating vertex data save file " << os_specific << "\n"; } #ifdef _WIN32 // Windows case. DWORD flags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_RANDOM_ACCESS; #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In SIMPLE_THREADS mode, we use "overlapped" I/O. + // In SIMPLE_THREADS mode, we use "overlapped" IO. flags |= FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; #endif _handle = CreateFile(os_specific.c_str(), GENERIC_READ | GENERIC_WRITE, @@ -74,8 +71,8 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, break; } else { - // Couldn't open the file. Either the directory was bad, or the - // file was already locked by another. + // Couldn't open the file. Either the directory was bad, or the file + // was already locked by another. DWORD err = GetLastError(); if (err != ERROR_SHARING_VIOLATION) { @@ -97,7 +94,7 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, // Posix case. int flags = O_RDWR | O_CREAT; #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In SIMPLE_THREADS mode, we use non-blocking I/O. + // In SIMPLE_THREADS mode, we use non-blocking IO. flags |= O_NONBLOCK; #endif @@ -121,32 +118,31 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, } } - // If it's a permissions problem, it might be a user-level - // permissions issue. Continue to the next. + // If it's a permissions problem, it might be a user-level permissions + // issue. Continue to the next. continue; } - - // Now try to lock the file, so we can be sure that no other - // process is simultaneously writing to the same save file. + + // Now try to lock the file, so we can be sure that no other process is + // simultaneously writing to the same save file. #ifdef HAVE_LOCKF int result = lockf(_fd, F_TLOCK, 0); #else int result = flock(_fd, LOCK_EX | LOCK_NB); #endif if (result == 0) { - // We've got the file. Truncate it first, for good measure, in - // case there's an old version of the file we picked up. + // We've got the file. Truncate it first, for good measure, in case + // there's an old version of the file we picked up. if (ftruncate(_fd, 0) < 0) { gobj_cat.warning() << "Couldn't truncate vertex data save file.\n"; } - // On Unix, it's safe to unlink (delete) the temporary file - // after it's been opened. The file remains open, but - // disappears from the directory. This is kind of like - // DELETE_ON_CLOSE, to ensure the temporary file won't - // accidentally get left behind, except it's a little more - // proactive. + // On Unix, it's safe to unlink (delete) the temporary file after it's + // been opened. The file remains open, but disappears from the + // directory. This is kind of like DELETE_ON_CLOSE, to ensure the + // temporary file won't accidentally get left behind, except it's a + // little more proactive. unlink(os_specific.c_str()); _filename = Filename(); break; @@ -160,11 +156,9 @@ VertexDataSaveFile(const Filename &directory, const string &prefix, _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexDataSaveFile:: ~VertexDataSaveFile() { #ifdef _WIN32 @@ -177,9 +171,9 @@ VertexDataSaveFile:: } #endif // _WIN32 - // No need to remove the file, since in both above cases we have - // already removed it. And removing it now, after we have closed - // and unlocked it, might accidentally remove someone else's copy. + // No need to remove the file, since in both above cases we have already + // removed it. And removing it now, after we have closed and unlocked it, + // might accidentally remove someone else's copy. /* if (!_filename.empty()) { _filename.unlink(); @@ -187,14 +181,11 @@ VertexDataSaveFile:: */ } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::write_data -// Access: Public -// Description: Writes a block of data to the file, and returns a -// handle to the block handle. Returns NULL if the data -// cannot be written (e.g. no remaining space on the -// file). -//////////////////////////////////////////////////////////////////// +/** + * Writes a block of data to the file, and returns a handle to the block + * handle. Returns NULL if the data cannot be written (e.g. no remaining + * space on the file). + */ PT(VertexDataSaveBlock) VertexDataSaveFile:: write_data(const unsigned char *data, size_t size, bool compressed) { MutexHolder holder(_lock); @@ -269,12 +260,10 @@ write_data(const unsigned char *data, size_t size, bool compressed) { return block; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::read_data -// Access: Public -// Description: Reads a block of data from the file, and returns true -// on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads a block of data from the file, and returns true on success, false on + * failure. + */ bool VertexDataSaveFile:: read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { MutexHolder holder(_lock); @@ -351,14 +340,11 @@ read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VertexDataSaveFile::make_block -// Access: Protected, Virtual -// Description: Creates a new SimpleAllocatorBlock object. Override -// this function to specialize the block type returned. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new SimpleAllocatorBlock object. Override this function to + * specialize the block type returned. + */ SimpleAllocatorBlock *VertexDataSaveFile:: make_block(size_t start, size_t size) { return new VertexDataSaveBlock(this, start, size); } - diff --git a/panda/src/gobj/vertexDataSaveFile.h b/panda/src/gobj/vertexDataSaveFile.h index be943ff179..d71708227a 100644 --- a/panda/src/gobj/vertexDataSaveFile.h +++ b/panda/src/gobj/vertexDataSaveFile.h @@ -1,16 +1,15 @@ -// Filename: vertexDataSaveFile.h -// Created by: drose (12May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexDataSaveFile.h + * @author drose + * @date 2007-05-12 + */ #ifndef VERTEXDATASAVEFILE_H #define VERTEXDATASAVEFILE_H @@ -29,13 +28,11 @@ class VertexDataSaveBlock; -//////////////////////////////////////////////////////////////////// -// Class : VertexDataSaveFile -// Description : A temporary file to hold the vertex data that has -// been evicted from memory and written to disk. All -// vertex data arrays are written into one large flat -// file. -//////////////////////////////////////////////////////////////////// +/** + * A temporary file to hold the vertex data that has been evicted from memory + * and written to disk. All vertex data arrays are written into one large + * flat file. + */ class EXPCL_PANDA_GOBJ VertexDataSaveFile : public SimpleAllocator { public: VertexDataSaveFile(const Filename &directory, const string &prefix, @@ -48,7 +45,7 @@ PUBLISHED: INLINE size_t get_total_file_size() const; INLINE size_t get_used_file_size() const; -public: +public: PT(VertexDataSaveBlock) write_data(const unsigned char *data, size_t size, bool compressed); bool read_data(unsigned char *data, size_t size, @@ -70,10 +67,9 @@ private: #endif // _WIN32 }; -//////////////////////////////////////////////////////////////////// -// Class : VertexDataSaveBlock -// Description : A block of bytes on the save file. -//////////////////////////////////////////////////////////////////// +/** + * A block of bytes on the save file. + */ class EXPCL_PANDA_GOBJ VertexDataSaveBlock : public SimpleAllocatorBlock, public ReferenceCount { protected: INLINE VertexDataSaveBlock(VertexDataSaveFile *file, diff --git a/panda/src/gobj/vertexSlider.I b/panda/src/gobj/vertexSlider.I index 38e587affc..2d48a56e29 100644 --- a/panda/src/gobj/vertexSlider.I +++ b/panda/src/gobj/vertexSlider.I @@ -1,58 +1,46 @@ -// Filename: vertexSlider.I -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexSlider.I + * @author drose + * @date 2005-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::get_name -// Access: Published -// Description: Returns the name of this particular slider. Every -// unique blend shape within a particular Geom must be -// identified with a different name, which is shared by -// the slider that controls it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this particular slider. Every unique blend shape + * within a particular Geom must be identified with a different name, which is + * shared by the slider that controls it. + */ INLINE const InternalName *VertexSlider:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::get_modified -// Access: Published -// Description: Returns a sequence number that's guaranteed to change -// at least every time the value reported by -// get_slider() changes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number that's guaranteed to change at least every time + * the value reported by get_slider() changes. + */ INLINE UpdateSeq VertexSlider:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexSlider::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexSlider::CData:: CData(const VertexSlider::CData ©) : _modified(copy._modified) diff --git a/panda/src/gobj/vertexSlider.cxx b/panda/src/gobj/vertexSlider.cxx index 6897d335da..86d841ad53 100644 --- a/panda/src/gobj/vertexSlider.cxx +++ b/panda/src/gobj/vertexSlider.cxx @@ -1,16 +1,15 @@ -// Filename: vertexSlider.cxx -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexSlider.cxx + * @author drose + * @date 2005-03-28 + */ #include "vertexSlider.h" #include "vertexTransform.h" @@ -21,117 +20,93 @@ TypeHandle VertexSlider::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexSlider:: VertexSlider(const InternalName *name) : _name(name) { } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexSlider:: ~VertexSlider() { - // We shouldn't destruct while any SliderTables are holding our - // pointer. + // We shouldn't destruct while any SliderTables are holding our pointer. nassertv(_tables.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexSlider:: output(ostream &out) const { out << get_type() << " " << *get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexSlider:: write(ostream &out, int indent_level) const { - indent(out, indent_level) + indent(out, indent_level) << *this << " = " << get_slider() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::mark_modified -// Access: Protected -// Description: Intended to be called by a derived class whenever the -// reported transform might have changed. Without -// calling this method, changes to get_slider() may not -// be propagated through the system. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by a derived class whenever the reported transform + * might have changed. Without calling this method, changes to get_slider() + * may not be propagated through the system. + */ void VertexSlider:: mark_modified(Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); cdata->_modified = VertexTransform::get_next_modified(current_thread); - + Tables::iterator ti; for (ti = _tables.begin(); ti != _tables.end(); ++ti) { (*ti)->update_modified(cdata->_modified, current_thread); } } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void VertexSlider:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new VertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new VertexSlider. + */ void VertexSlider:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *VertexSlider::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void VertexSlider::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int VertexSlider::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -139,13 +114,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: VertexSlider::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new VertexSlider. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new VertexSlider. + */ void VertexSlider::CData:: fillin(DatagramIterator &scan, BamReader *manager) { } diff --git a/panda/src/gobj/vertexSlider.h b/panda/src/gobj/vertexSlider.h index f8c25244a7..1c4274b437 100644 --- a/panda/src/gobj/vertexSlider.h +++ b/panda/src/gobj/vertexSlider.h @@ -1,16 +1,15 @@ -// Filename: vertexSlider.h -// Created by: drose (28Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexSlider.h + * @author drose + * @date 2005-03-28 + */ #ifndef VERTEXSLIDER_H #define VERTEXSLIDER_H @@ -27,17 +26,14 @@ class SliderTable; -//////////////////////////////////////////////////////////////////// -// Class : VertexSlider -// Description : This is an abstract base class that retains some -// slider value, which is a linear value that typically -// ranges from 0.0 to 1.0, and is used to control the -// animation of morphs (blend shapes). -// -// It is similar to VertexTransform, which keeps a full -// 4x4 transform matrix, but the VertexSlider only keeps -// a single float value. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class that retains some slider value, which is a + * linear value that typically ranges from 0.0 to 1.0, and is used to control + * the animation of morphs (blend shapes). + * + * It is similar to VertexTransform, which keeps a full 4x4 transform matrix, + * but the VertexSlider only keeps a single float value. + */ class EXPCL_PANDA_GOBJ VertexSlider : public TypedWritableReferenceCount { PUBLISHED: VertexSlider(const InternalName *name); diff --git a/panda/src/gobj/vertexTransform.I b/panda/src/gobj/vertexTransform.I index b2a40c279a..cf7830c296 100644 --- a/panda/src/gobj/vertexTransform.I +++ b/panda/src/gobj/vertexTransform.I @@ -1,59 +1,47 @@ -// Filename: vertexTransform.I -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexTransform.I + * @author drose + * @date 2005-03-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::get_modified -// Access: Published -// Description: Returns a sequence number that's guaranteed to change -// at least every time the value reported by -// get_matrix() changes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sequence number that's guaranteed to change at least every time + * the value reported by get_matrix() changes. + */ INLINE UpdateSeq VertexTransform:: get_modified(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::get_global_modified -// Access: Published, Static -// Description: Returns the currently highest -// VertexTransform::get_modified() value in the world. -// This can be used as a quick way to determine if any -// VertexTransforms have changed value recently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the currently highest VertexTransform::get_modified() value in the + * world. This can be used as a quick way to determine if any + * VertexTransforms have changed value recently. + */ INLINE UpdateSeq VertexTransform:: get_global_modified(Thread *current_thread) { CDReader cdata(_global_cycler, current_thread); return cdata->_modified; } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexTransform::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexTransform::CData:: CData(const VertexTransform::CData ©) : _modified(copy._modified) diff --git a/panda/src/gobj/vertexTransform.cxx b/panda/src/gobj/vertexTransform.cxx index 63a61dd975..35a60bd25a 100644 --- a/panda/src/gobj/vertexTransform.cxx +++ b/panda/src/gobj/vertexTransform.cxx @@ -1,16 +1,15 @@ -// Filename: vertexTransform.cxx -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexTransform.cxx + * @author drose + * @date 2005-03-23 + */ #include "vertexTransform.h" #include "bamReader.h" @@ -23,37 +22,28 @@ UpdateSeq VertexTransform::_next_modified; TypeHandle VertexTransform::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexTransform:: VertexTransform() { } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VertexTransform:: ~VertexTransform() { - // We shouldn't destruct while any TransformTables are holding our - // pointer. + // We shouldn't destruct while any TransformTables are holding our pointer. nassertv(_tables.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::mult_matrix -// Access: Published, Virtual -// Description: Premultiplies this transform's matrix with the -// indicated previous matrix, so that the result is the -// net composition of the given transform with this -// transform. The result is stored in the parameter -// "result", which should not be the same matrix as -// previous. -//////////////////////////////////////////////////////////////////// +/** + * Premultiplies this transform's matrix with the indicated previous matrix, + * so that the result is the net composition of the given transform with this + * transform. The result is stored in the parameter "result", which should + * not be the same matrix as previous. + */ void VertexTransform:: mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { nassertv(&result != &previous); @@ -62,14 +52,11 @@ mult_matrix(LMatrix4 &result, const LMatrix4 &previous) const { result.multiply(me, previous); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::accumulate_matrix -// Access: Published, Virtual -// Description: Adds the value of this transform's matrix, modified -// by the indicated weight, into the indicated -// accumulation matrix. This is used to compute the -// result of several blended transforms. -//////////////////////////////////////////////////////////////////// +/** + * Adds the value of this transform's matrix, modified by the indicated + * weight, into the indicated accumulation matrix. This is used to compute + * the result of several blended transforms. + */ void VertexTransform:: accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { LMatrix4 me; @@ -77,44 +64,35 @@ accumulate_matrix(LMatrix4 &accum, PN_stdfloat weight) const { accum.accumulate(me, weight); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexTransform:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VertexTransform:: write(ostream &out, int indent_level) const { - indent(out, indent_level) + indent(out, indent_level) << *this << ":\n"; LMatrix4 mat; get_matrix(mat); mat.write(out, indent_level + 2); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::get_next_modified -// Access: Public, Static -// Description: Returns a monotonically increasing sequence. Each -// time this is called, a new sequence number is -// returned, higher than the previous value. -// -// This is used to ensure that all -// VertexTransform::get_modified() calls return an -// increasing number in the same space, so that -// TransformBlend::get_modified() is easy to determine. -// It is similar to Geom::get_modified(), but it is in a -// different space. -//////////////////////////////////////////////////////////////////// +/** + * Returns a monotonically increasing sequence. Each time this is called, a + * new sequence number is returned, higher than the previous value. + * + * This is used to ensure that all VertexTransform::get_modified() calls + * return an increasing number in the same space, so that + * TransformBlend::get_modified() is easy to determine. It is similar to + * Geom::get_modified(), but it is in a different space. + */ UpdateSeq VertexTransform:: get_next_modified(Thread *current_thread) { CDWriter cdatag(_global_cycler, true, current_thread); @@ -124,75 +102,60 @@ get_next_modified(Thread *current_thread) { return _next_modified; } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::mark_modified -// Access: Protected -// Description: Intended to be called by a derived class whenever the -// reported transform might have changed. Without -// calling this method, changes to get_matrix() may not -// be propagated through the system. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by a derived class whenever the reported transform + * might have changed. Without calling this method, changes to get_matrix() + * may not be propagated through the system. + */ void VertexTransform:: mark_modified(Thread *current_thread) { CDWriter cdata(_cycler, true, current_thread); cdata->_modified = get_next_modified(current_thread); - + Palettes::iterator pi; for (pi = _tables.begin(); pi != _tables.end(); ++pi) { (*pi)->update_modified(cdata->_modified, current_thread); } } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void VertexTransform:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new VertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new VertexTransform. + */ void VertexTransform:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *VertexTransform::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void VertexTransform::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int VertexTransform::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -200,13 +163,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: VertexTransform::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new VertexTransform. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new VertexTransform. + */ void VertexTransform::CData:: fillin(DatagramIterator &scan, BamReader *manager) { } diff --git a/panda/src/gobj/vertexTransform.h b/panda/src/gobj/vertexTransform.h index ae002a1c32..51e84c9edb 100644 --- a/panda/src/gobj/vertexTransform.h +++ b/panda/src/gobj/vertexTransform.h @@ -1,16 +1,15 @@ -// Filename: vertexTransform.h -// Created by: drose (23Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexTransform.h + * @author drose + * @date 2005-03-23 + */ #ifndef VERTEXTRANSFORM_H #define VERTEXTRANSFORM_H @@ -27,15 +26,12 @@ class TransformTable; -//////////////////////////////////////////////////////////////////// -// Class : VertexTransform -// Description : This is an abstract base class that holds a pointer -// to some transform, computed in some arbitrary way, -// that is to be applied to vertices during rendering. -// This is used to implement soft-skinned and animated -// vertices. Derived classes will define how the -// transform is actually computed. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class that holds a pointer to some transform, + * computed in some arbitrary way, that is to be applied to vertices during + * rendering. This is used to implement soft-skinned and animated vertices. + * Derived classes will define how the transform is actually computed. + */ class EXPCL_PANDA_GOBJ VertexTransform : public TypedWritableReferenceCount { PUBLISHED: VertexTransform(); diff --git a/panda/src/gobj/videoTexture.I b/panda/src/gobj/videoTexture.I index 46dd2a9e75..367c1617e2 100644 --- a/panda/src/gobj/videoTexture.I +++ b/panda/src/gobj/videoTexture.I @@ -1,51 +1,40 @@ -// Filename: videoTexture.I -// Created by: drose (21Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file videoTexture.I + * @author drose + * @date 2005-09-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::get_video_width -// Access: Published -// Description: Returns the width in texels of the source video -// stream. This is not necessarily the width of the -// actual texture, since the texture may have been -// expanded to raise it to a power of 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width in texels of the source video stream. This is not + * necessarily the width of the actual texture, since the texture may have + * been expanded to raise it to a power of 2. + */ INLINE int VideoTexture:: get_video_width() const { return _video_width; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::get_video_height -// Access: Published -// Description: Returns the height in texels of the source video -// stream. This is not necessarily the height of the -// actual texture, since the texture may have been -// expanded to raise it to a power of 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height in texels of the source video stream. This is not + * necessarily the height of the actual texture, since the texture may have + * been expanded to raise it to a power of 2. + */ INLINE int VideoTexture:: get_video_height() const { return _video_height; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::clear_current_frame -// Access: Protected -// Description: Resets the record of the current frame so that it -// will be forced to reload the next time it is -// requested. -//////////////////////////////////////////////////////////////////// +/** + * Resets the record of the current frame so that it will be forced to reload + * the next time it is requested. + */ INLINE void VideoTexture:: clear_current_frame() { _last_frame_update = 0; diff --git a/panda/src/gobj/videoTexture.cxx b/panda/src/gobj/videoTexture.cxx index 796661b0cb..0cde2d98f6 100644 --- a/panda/src/gobj/videoTexture.cxx +++ b/panda/src/gobj/videoTexture.cxx @@ -1,16 +1,15 @@ -// Filename: videoTexture.cxx -// Created by: drose (21Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file videoTexture.cxx + * @author drose + * @date 2005-09-21 + */ #include "pandabase.h" @@ -20,14 +19,12 @@ TypeHandle VideoTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VideoTexture:: -VideoTexture(const string &name) : - Texture(name) +VideoTexture(const string &name) : + Texture(name) { // We don't want to try to compress each frame as it's loaded. Texture::CDWriter cdata(Texture::_cycler, true); @@ -40,13 +37,11 @@ VideoTexture(const string &name) : _current_frame = -1; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VideoTexture:: -VideoTexture(const VideoTexture ©) : +VideoTexture(const VideoTexture ©) : Texture(copy), AnimInterface(copy), _video_width(copy._video_width), @@ -56,65 +51,51 @@ VideoTexture(const VideoTexture ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::get_keep_ram_image -// Access: Published, Virtual -// Description: Returns the flag that indicates whether this Texture -// is eligible to have its main RAM copy of the texture -// memory dumped when the texture is prepared for -// rendering. See set_keep_ram_image(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether this Texture is eligible to have + * its main RAM copy of the texture memory dumped when the texture is prepared + * for rendering. See set_keep_ram_image(). + */ bool VideoTexture:: get_keep_ram_image() const { // A VideoTexture should never dump its RAM image. return true; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + */ bool VideoTexture:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. -// -// This is called each time the Texture is discovered -// applied to a Geom in the traversal. It should return -// true if the Geom is visible, false if it should be -// omitted. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. + * + * This is called each time the Texture is discovered applied to a Geom in the + * traversal. It should return true if the Geom is visible, false if it + * should be omitted. + */ bool VideoTexture:: cull_callback(CullTraverser *, const CullTraverserData &) const { // Strictly speaking, the cull_callback() method isn't necessary for - // VideoTexture, since the get_ram_image() function is already - // overloaded to update itself if necessary. However, we define it - // anyway, to move the update calculation into the cull traversal - // rather than the draw traversal. + // VideoTexture, since the get_ram_image() function is already overloaded to + // update itself if necessary. However, we define it anyway, to move the + // update calculation into the cull traversal rather than the draw + // traversal. ((VideoTexture *)this)->reconsider_dirty(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::set_video_size -// Access: Protected -// Description: Should be called by a derived class to set the size -// of the video when it is loaded. Assumes the lock is -// held. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to set the size of the video when it is + * loaded. Assumes the lock is held. + */ void VideoTexture:: set_video_size(int video_width, int video_height) { _video_width = video_width; @@ -123,18 +104,15 @@ set_video_size(int video_width, int video_height) { Texture::CDWriter cdata(Texture::_cycler, true); do_set_pad_size(cdata, - max(cdata->_x_size - _video_width, 0), + max(cdata->_x_size - _video_width, 0), max(cdata->_y_size - _video_height, 0), 0); } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::do_has_ram_image -// Access: Protected, Virtual -// Description: Returns true if the Texture has its image contents -// available in main RAM, false if it exists only in -// texture memory or in the prepared GSG context. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Texture has its image contents available in main RAM, + * false if it exists only in texture memory or in the prepared GSG context. + */ bool VideoTexture:: do_has_ram_image(const Texture::CData *cdata) const { int this_frame = ClockObject::get_global_clock()->get_frame_count(); @@ -144,38 +122,30 @@ do_has_ram_image(const Texture::CData *cdata) const { return !cdata->_ram_images.empty() && !cdata->_ram_images[0]._image.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::reconsider_dirty -// Access: Protected, Virtual -// Description: Called by TextureContext to give the Texture a chance -// to mark itself dirty before rendering, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called by TextureContext to give the Texture a chance to mark itself dirty + * before rendering, if necessary. + */ void VideoTexture:: reconsider_dirty() { consider_update(); } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::unlocked_ensure_ram_image -// Access: Protected, Virtual -// Description: If the texture has a ram image already, this acquires -// the CData write lock and returns it. -// -// If the texture lacks a ram image, this performs -// do_reload_ram_image(), but without holding the lock -// on this particular Texture object, to avoid holding -// the lock across what might be a slow operation. -// Instead, the reload is performed in a copy of the -// texture object, and then the lock is acquired and the -// data is copied in. -// -// In any case, the return value is a locked CData -// object, which must be released with an explicit call -// to release_write(). The CData object will have a ram -// image unless for some reason do_reload_ram_image() -// fails. -//////////////////////////////////////////////////////////////////// +/** + * If the texture has a ram image already, this acquires the CData write lock + * and returns it. + * + * If the texture lacks a ram image, this performs do_reload_ram_image(), but + * without holding the lock on this particular Texture object, to avoid + * holding the lock across what might be a slow operation. Instead, the + * reload is performed in a copy of the texture object, and then the lock is + * acquired and the data is copied in. + * + * In any case, the return value is a locked CData object, which must be + * released with an explicit call to release_write(). The CData object will + * have a ram image unless for some reason do_reload_ram_image() fails. + */ Texture::CData *VideoTexture:: unlocked_ensure_ram_image(bool allow_compression) { consider_update(); @@ -185,40 +155,30 @@ unlocked_ensure_ram_image(bool allow_compression) { return cdata; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::do_reload_ram_image -// Access: Protected, Virtual -// Description: Called when the Texture image is required but the ram -// image is not available, this will reload it from disk -// or otherwise do whatever is required to make it -// available, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Called when the Texture image is required but the ram image is not + * available, this will reload it from disk or otherwise do whatever is + * required to make it available, if possible. + */ void VideoTexture:: do_reload_ram_image(Texture::CData *cdata, bool) { consider_update(); } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::do_can_reload -// Access: Protected, Virtual -// Description: Returns true if we can safely call -// do_unlock_and_reload_ram_image() in order to make the -// image available, or false if we shouldn't do this -// (because we know from a priori knowledge that it -// wouldn't work anyway). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we can safely call do_unlock_and_reload_ram_image() in + * order to make the image available, or false if we shouldn't do this + * (because we know from a priori knowledge that it wouldn't work anyway). + */ bool VideoTexture:: do_can_reload(const Texture::CData *cdata) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::do_adjust_this_size -// Access: Protected, Virtual -// Description: Works like adjust_size, but also considers the -// texture class. Movie textures, for instance, always -// pad outwards, never scale down. -//////////////////////////////////////////////////////////////////// +/** + * Works like adjust_size, but also considers the texture class. Movie + * textures, for instance, always pad outwards, never scale down. + */ bool VideoTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, int &x_size, int &y_size, const string &name, @@ -231,12 +191,9 @@ do_adjust_this_size(const Texture::CData *cdata_tex, return adjust_size(x_size, y_size, name, for_padding, ats); } -//////////////////////////////////////////////////////////////////// -// Function: VideoTexture::consider_update -// Access: Protected, Virtual -// Description: Calls update_frame() if the current frame has -// changed. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_frame() if the current frame has changed. + */ void VideoTexture:: consider_update() { int this_frame = ClockObject::get_global_clock()->get_frame_count(); diff --git a/panda/src/gobj/videoTexture.h b/panda/src/gobj/videoTexture.h index dcdc483183..755bc763c1 100644 --- a/panda/src/gobj/videoTexture.h +++ b/panda/src/gobj/videoTexture.h @@ -1,16 +1,15 @@ -// Filename: videoTexture.h -// Created by: drose (21Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file videoTexture.h + * @author drose + * @date 2005-09-21 + */ #ifndef VIDEOTEXTURE_H #define VIDEOTEXTURE_H @@ -20,14 +19,12 @@ #include "animInterface.h" #include "clockObject.h" -//////////////////////////////////////////////////////////////////// -// Class : VideoTexture -// Description : The base class for a family of animated Textures that -// take their input from a video source, such as a movie -// file. These Textures may be stopped, started, -// etc. using the AnimInterface controls, similar to an -// animated character. -//////////////////////////////////////////////////////////////////// +/** + * The base class for a family of animated Textures that take their input from + * a video source, such as a movie file. These Textures may be stopped, + * started, etc. using the AnimInterface controls, similar to an animated + * character. + */ class EXPCL_PANDA_GOBJ VideoTexture : public Texture, public AnimInterface { protected: VideoTexture(const string &name); @@ -55,8 +52,8 @@ protected: virtual void do_reload_ram_image(Texture::CData *cdata, bool allow_compression); virtual bool do_can_reload(const Texture::CData *cdata) const; - virtual bool do_adjust_this_size(const Texture::CData *cdata, - int &x_size, int &y_size, const string &name, + virtual bool do_adjust_this_size(const Texture::CData *cdata, + int &x_size, int &y_size, const string &name, bool for_padding) const; virtual void consider_update(); diff --git a/panda/src/grutil/cardMaker.I b/panda/src/grutil/cardMaker.I index b9768c805c..8d051a72bc 100644 --- a/panda/src/grutil/cardMaker.I +++ b/panda/src/grutil/cardMaker.I @@ -1,89 +1,72 @@ -// Filename: cardMaker.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cardMaker.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CardMaker:: CardMaker(const string &name) : Namable(name) { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CardMaker:: ~CardMaker() { } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_has_uvs -// Access: Public -// Description: Sets the flag indicating whether vertices will be -// generated with UV's or not. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether vertices will be generated with UV's or + * not. + */ INLINE void CardMaker:: set_has_uvs(bool flag) { _has_uvs = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_has_3d_uvs -// Access: Public -// Description: Sets the flag indicating whether vertices will be -// generated with 3-component UVW's (true) or -// 2-component UV's (the default, false). Normally, -// this will be implicitly set by setting the uv_range. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether vertices will be generated with + * 3-component UVW's (true) or 2-component UV's (the default, false). + * Normally, this will be implicitly set by setting the uv_range. + */ INLINE void CardMaker:: set_has_3d_uvs(bool flag) { _has_3d_uvs = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_frame -// Access: Public -// Description: Sets the size of the card. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the card. + */ INLINE void CardMaker:: set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _ll_pos = LVector3::rfu(left, 0.0f, bottom); _lr_pos = LVector3::rfu(right, 0.0f, bottom); _ur_pos = LVector3::rfu(right, 0.0f, top); _ul_pos = LVector3::rfu(left, 0.0f, top); -} +} -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_frame -// Access: Public -// Description: Sets the size of the card. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the card. + */ INLINE void CardMaker:: set_frame(const LVecBase4 &frame) { set_frame(frame[0], frame[1], frame[2], frame[3]); } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_frame -// Access: Public -// Description: Sets the size of the card. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the card. + */ INLINE void CardMaker:: set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex &ul) { _ll_pos = ll; @@ -92,82 +75,63 @@ set_frame(const LVertex &ll, const LVertex &lr, const LVertex &ur, const LVertex _ul_pos = ul; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_frame_fullscreen_quad -// Access: Public -// Description: Sets the card to (-1,1,-1,1), which is appropriate -// if you plan to parent it to render2d and use it -// as a fullscreen quad. -//////////////////////////////////////////////////////////////////// +/** + * Sets the card to (-1,1,-1,1), which is appropriate if you plan to parent it + * to render2d and use it as a fullscreen quad. + */ INLINE void CardMaker:: set_frame_fullscreen_quad() { set_frame(-1.0f, 1.0f, -1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_color -// Access: Public -// Description: Sets the color of the card. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the card. + */ INLINE void CardMaker:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_color(LVecBase4(r, g, b, a)); -} +} -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_color -// Access: Public -// Description: Sets the color of the card. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the card. + */ INLINE void CardMaker:: set_color(const LVecBase4 &color) { _color = color; _has_color = true; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_has_normals -// Access: Public -// Description: Sets the flag indicating whether vertices will be -// generated with normals or not. Normals are required -// if you intend to enable lighting on the card, but are -// just wasted space and bandwidth otherwise, so there -// is a (slight) optimization for disabling them. If -// enabled, the normals will be generated perpendicular -// to the card's face. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether vertices will be generated with normals or + * not. Normals are required if you intend to enable lighting on the card, + * but are just wasted space and bandwidth otherwise, so there is a (slight) + * optimization for disabling them. If enabled, the normals will be generated + * perpendicular to the card's face. + */ INLINE void CardMaker:: set_has_normals(bool flag) { _has_normals = flag; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_source_geometry -// Access: Published -// Description: Sets a node that will be copied (and scaled and -// translated) to generate the frame, instead of -// generating a new polygon. The node may contain -// arbitrary geometry that describes a flat polygon -// contained within the indicated left, right, bottom, -// top frame. -// -// When generate() is called, the geometry in this node -// will be scaled and translated appropriately to give -// it the size and aspect ratio specified by -// set_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Sets a node that will be copied (and scaled and translated) to generate the + * frame, instead of generating a new polygon. The node may contain arbitrary + * geometry that describes a flat polygon contained within the indicated left, + * right, bottom, top frame. + * + * When generate() is called, the geometry in this node will be scaled and + * translated appropriately to give it the size and aspect ratio specified by + * set_frame(). + */ INLINE void CardMaker:: set_source_geometry(PandaNode *node, const LVecBase4 &frame) { _source_geometry = node; _source_frame = frame; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::clear_source_geometry -// Access: Published -// Description: Removes the node specified by an earlier call to -// set_source_geometry(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the node specified by an earlier call to set_source_geometry(). + */ INLINE void CardMaker:: clear_source_geometry() { _source_geometry = (PandaNode *)NULL; diff --git a/panda/src/grutil/cardMaker.cxx b/panda/src/grutil/cardMaker.cxx index ae938e6aa4..ddfeae6947 100644 --- a/panda/src/grutil/cardMaker.cxx +++ b/panda/src/grutil/cardMaker.cxx @@ -1,16 +1,15 @@ -// Filename: cardMaker.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cardMaker.cxx + * @author drose + * @date 2002-03-16 + */ #include "cardMaker.h" #include "geomNode.h" @@ -22,11 +21,9 @@ #include "geomVertexWriter.h" #include "geomVertexFormat.h" -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::reset -// Access: Public -// Description: Resets all the parameters to their initial defaults. -//////////////////////////////////////////////////////////////////// +/** + * Resets all the parameters to their initial defaults. + */ void CardMaker:: reset() { set_frame(0.0f, 1.0f, 0.0f, 1.0f); @@ -41,12 +38,9 @@ reset() { } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::generate -// Access: Public -// Description: Generates a GeomNode that renders the specified -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Generates a GeomNode that renders the specified geometry. + */ PT(PandaNode) CardMaker:: generate() { if (_source_geometry != (PandaNode *)NULL) { @@ -89,16 +83,16 @@ generate() { format = GeomVertexFormat::get_v3(); } } - + PT(GeomVertexData) vdata = new GeomVertexData ("card", format, Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + vertex.add_data3(_ul_pos); vertex.add_data3(_ll_pos); vertex.add_data3(_ur_pos); vertex.add_data3(_lr_pos); - + if (_has_uvs) { GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); texcoord.add_data3(_ul_tex); @@ -106,7 +100,7 @@ generate() { texcoord.add_data3(_ur_tex); texcoord.add_data3(_lr_tex); } - + if (_has_normals) { GeomVertexWriter normal(vdata, InternalName::get_normal()); LVector3 n; @@ -123,12 +117,12 @@ generate() { n.normalize(); normal.add_data3(n); } - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); strip->set_shade_model(Geom::SM_uniform); strip->add_next_vertices(4); strip->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); @@ -136,21 +130,18 @@ generate() { if (_has_color) { state = RenderState::make(ColorAttrib::make_flat(_color)); } - + gnode->add_geom(geom, state); - + return gnode.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices. If set_has_uvs() is true (as it is by -// default), the vertices will be generated with the -// indicated range of UV's, which will be useful if a -// texture is applied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices. If + * set_has_uvs() is true (as it is by default), the vertices will be generated + * with the indicated range of UV's, which will be useful if a texture is + * applied. + */ void CardMaker:: set_uv_range(const LTexCoord3 &ll, const LTexCoord3 &lr, const LTexCoord3 &ur, const LTexCoord3 &ul) { _ll_tex = ll; @@ -161,15 +152,12 @@ set_uv_range(const LTexCoord3 &ll, const LTexCoord3 &lr, const LTexCoord3 &ur, c _has_3d_uvs = true; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices. If set_has_uvs() is true (as it is by -// default), the vertices will be generated with the -// indicated range of UV's, which will be useful if a -// texture is applied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices. If + * set_has_uvs() is true (as it is by default), the vertices will be generated + * with the indicated range of UV's, which will be useful if a texture is + * applied. + */ void CardMaker:: set_uv_range(const LTexCoord &ll, const LTexCoord &lr, const LTexCoord &ur, const LTexCoord &ul) { _ll_tex.set(ll[0], ll[1], 0.0f); @@ -180,15 +168,12 @@ set_uv_range(const LTexCoord &ll, const LTexCoord &lr, const LTexCoord &ur, cons _has_3d_uvs = false; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices. If set_has_uvs() is true (as it is by -// default), the vertices will be generated with the -// indicated range of UV's, which will be useful if a -// texture is applied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices. If + * set_has_uvs() is true (as it is by default), the vertices will be generated + * with the indicated range of UV's, which will be useful if a texture is + * applied. + */ void CardMaker:: set_uv_range(const LTexCoord &ll, const LTexCoord &ur) { _ll_tex.set(ll[0], ll[1], 0.0f); @@ -199,15 +184,12 @@ set_uv_range(const LTexCoord &ll, const LTexCoord &ur) { _has_3d_uvs = false; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices. If set_has_uvs() is true (as it is by -// default), the vertices will be generated with the -// indicated range of UV's, which will be useful if a -// texture is applied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices. If + * set_has_uvs() is true (as it is by default), the vertices will be generated + * with the indicated range of UV's, which will be useful if a texture is + * applied. + */ void CardMaker:: set_uv_range(const LVector4 &x, const LVector4 &y, const LVector4 &z) { _ll_tex.set(x[0], y[0], z[0]); @@ -218,12 +200,10 @@ set_uv_range(const LVector4 &x, const LVector4 &y, const LVector4 &z) { _has_3d_uvs = true; } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range_cube -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices appropriately for a cube-map face. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices appropriately + * for a cube-map face. + */ void CardMaker:: set_uv_range_cube(int face) { LVector4 varya(-1, 1, 1, -1); @@ -239,13 +219,10 @@ set_uv_range_cube(int face) { } } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::set_uv_range -// Access: Public -// Description: Sets the range of UV's that will be applied to the -// vertices appropriately to show the non-pad region -// of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the range of UV's that will be applied to the vertices appropriately + * to show the non-pad region of the texture. + */ void CardMaker:: set_uv_range(const Texture *tex) { nassertv(tex->get_texture_type() == Texture::TT_2d_texture); @@ -256,12 +233,9 @@ set_uv_range(const Texture *tex) { set_uv_range(LTexCoord(0.0,0.0), LTexCoord(maxu,maxv)); } -//////////////////////////////////////////////////////////////////// -// Function: CardMaker::rescale_source_geometry -// Access: Private -// Description: Generates the card by rescaling the source geometry -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Generates the card by rescaling the source geometry appropriately. + */ PT(PandaNode) CardMaker:: rescale_source_geometry() { PT(PandaNode) root = _source_geometry->copy_subgraph(); @@ -270,7 +244,7 @@ rescale_source_geometry() { LVector3 frame_max = _ll_pos.fmax(_lr_pos.fmax(_ur_pos.fmax(_ul_pos))); LVector3 frame_min = _ll_pos.fmin(_lr_pos.fmin(_ur_pos.fmax(_ul_pos))); LVector3 frame_ctr = (frame_max + frame_min) * 0.5f; - + LVector3 geom_center((_source_frame[0] + _source_frame[1]) * 0.5f, frame_ctr[1], (_source_frame[2] + _source_frame[3]) * 0.5f); @@ -278,10 +252,10 @@ rescale_source_geometry() { LVector3 scale((frame_max[0] - frame_min[0]) / (_source_frame[1] - _source_frame[0]), 0.0, (frame_max[2] - frame_min[2]) / (_source_frame[3] - _source_frame[2])); - + LVector3 trans = frame_ctr - geom_center; - CPT(TransformState) transform = + CPT(TransformState) transform = TransformState::make_pos_hpr_scale(trans, LPoint3(0.0f, 0.0f, 0.0f), scale); root->set_transform(transform); diff --git a/panda/src/grutil/cardMaker.h b/panda/src/grutil/cardMaker.h index 47778cb1d9..c9d28b8f09 100644 --- a/panda/src/grutil/cardMaker.h +++ b/panda/src/grutil/cardMaker.h @@ -1,16 +1,15 @@ -// Filename: cardMaker.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cardMaker.h + * @author drose + * @date 2002-03-16 + */ #ifndef CARDMAKER_H #define CARDMAKER_H @@ -23,12 +22,10 @@ #include "namable.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : CardMaker -// Description : This class generates 2-d "cards", that is, -// rectangular polygons, particularly useful for showing -// textures etc. in the 2-d scene graph. -//////////////////////////////////////////////////////////////////// +/** + * This class generates 2-d "cards", that is, rectangular polygons, + * particularly useful for showing textures etc. in the 2-d scene graph. + */ class EXPCL_PANDA_GRUTIL CardMaker : public Namable { PUBLISHED: INLINE CardMaker(const string &name); @@ -79,4 +76,3 @@ private: #include "cardMaker.I" #endif - diff --git a/panda/src/grutil/config_grutil.cxx b/panda/src/grutil/config_grutil.cxx index 2c8cc825c9..ea8aa7174d 100644 --- a/panda/src/grutil/config_grutil.cxx +++ b/panda/src/grutil/config_grutil.cxx @@ -1,16 +1,15 @@ -// Filename: config_grutil.cxx -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_grutil.cxx + * @author drose + * @date 2000-05-24 + */ #include "config_grutil.h" #include "frameRateMeter.h" @@ -102,14 +101,12 @@ ConfigVariableDouble ae_undershift_factor_32 "maximum pixel shift when applying a displacement map, in a 32-bit project file. This is used " "to control PfmVizzer::make_displacement().")); -//////////////////////////////////////////////////////////////////// -// Function: init_libgrutil -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libgrutil() { static bool initialized = false; diff --git a/panda/src/grutil/config_grutil.h b/panda/src/grutil/config_grutil.h index e20f4117f3..679d0b13db 100644 --- a/panda/src/grutil/config_grutil.h +++ b/panda/src/grutil/config_grutil.h @@ -1,16 +1,15 @@ -// Filename: config_grutil.h -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_grutil.h + * @author drose + * @date 2000-05-24 + */ #ifndef CONFIG_GRUTIL_H #define CONFIG_GRUTIL_H @@ -48,5 +47,3 @@ extern ConfigVariableDouble ae_undershift_factor_32; extern EXPCL_PANDA_GRUTIL void init_libgrutil(); #endif - - diff --git a/panda/src/grutil/fisheyeMaker.I b/panda/src/grutil/fisheyeMaker.I index 1a57b8167e..c567e9e43e 100644 --- a/panda/src/grutil/fisheyeMaker.I +++ b/panda/src/grutil/fisheyeMaker.I @@ -1,84 +1,66 @@ -// Filename: fisheyeMaker.I -// Created by: drose (3Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeMaker.I + * @author drose + * @date 2005-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FisheyeMaker:: FisheyeMaker(const string &name) : Namable(name) { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FisheyeMaker:: ~FisheyeMaker() { } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::set_num_vertices -// Access: Public -// Description: Specifies the approximate number of vertices to be -// used to generate the rose. This is the approximate -// number of vertices that will be located within the -// rose's unit circle, not counting the inscribing -// square (if any). The actual number of vertices used -// may be +/- 25% of this value. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the approximate number of vertices to be used to generate the + * rose. This is the approximate number of vertices that will be located + * within the rose's unit circle, not counting the inscribing square (if any). + * The actual number of vertices used may be +/- 25% of this value. + */ INLINE void FisheyeMaker:: set_num_vertices(int num_vertices) { _num_vertices = num_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::set_square_inscribed -// Access: Public -// Description: Sets the flag that indicates whether the rose should -// be inscribed within a square. When this is true, an -// additional square is generated to inscribed the -// circular rose, with the indicated "radius" (the sides -// of the square will be 2 * square_radius). The -// texture coordinates of the square will uniformly map -// to the back pole of the cube map. -// -// This is mainly useful to provide a good uniform -// background color for a sphere map so that it does not -// have a sharp circular edge that might produce -// artifacts due to numerical imprecision when mapping. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the rose should be inscribed within a + * square. When this is true, an additional square is generated to inscribed + * the circular rose, with the indicated "radius" (the sides of the square + * will be 2 * square_radius). The texture coordinates of the square will + * uniformly map to the back pole of the cube map. + * + * This is mainly useful to provide a good uniform background color for a + * sphere map so that it does not have a sharp circular edge that might + * produce artifacts due to numerical imprecision when mapping. + */ INLINE void FisheyeMaker:: set_square_inscribed(bool square_inscribed, PN_stdfloat square_radius) { _square_inscribed = square_inscribed; _square_radius = square_radius; } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::set_reflection -// Access: Public -// Description: Sets the flag indicating whether the texture image -// should be mirrored (true) or normal (false). When -// this is true, the 3-D texture coordinates will be -// reversed so that the image is appropriate for a -// reflection. This is the best choice for generating a -// sphere map from a cube map. The default is false. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether the texture image should be mirrored + * (true) or normal (false). When this is true, the 3-D texture coordinates + * will be reversed so that the image is appropriate for a reflection. This + * is the best choice for generating a sphere map from a cube map. The + * default is false. + */ INLINE void FisheyeMaker:: set_reflection(bool reflection) { _reflect = (reflection) ? -1.0 : 1.0; diff --git a/panda/src/grutil/fisheyeMaker.cxx b/panda/src/grutil/fisheyeMaker.cxx index 43b78d3035..f245242aec 100644 --- a/panda/src/grutil/fisheyeMaker.cxx +++ b/panda/src/grutil/fisheyeMaker.cxx @@ -1,16 +1,15 @@ -// Filename: fisheyeMaker.cxx -// Created by: drose (3Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeMaker.cxx + * @author drose + * @date 2005-10-03 + */ #include "fisheyeMaker.h" #include "geomNode.h" @@ -26,11 +25,9 @@ #include "graphicsStateGuardian.h" #include "displayRegion.h" -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::reset -// Access: Public -// Description: Resets all the parameters to their initial defaults. -//////////////////////////////////////////////////////////////////// +/** + * Resets all the parameters to their initial defaults. + */ void FisheyeMaker:: reset() { set_fov(360.0); @@ -40,13 +37,10 @@ reset() { set_reflection(false); } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::set_fov -// Access: Public -// Description: Specifies the field of view of the fisheye -// projection. A sphere map will have a 360-degree -// field of view (and this is the default). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the field of view of the fisheye projection. A sphere map will + * have a 360-degree field of view (and this is the default). + */ void FisheyeMaker:: set_fov(PN_stdfloat fov) { _fov = fov; @@ -54,12 +48,9 @@ set_fov(PN_stdfloat fov) { } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::generate -// Access: Public -// Description: Generates a GeomNode that renders the specified -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Generates a GeomNode that renders the specified geometry. + */ PT(PandaNode) FisheyeMaker:: generate() { // Get some system-imposed limits. @@ -76,29 +67,28 @@ generate() { } */ - // We will generate a rose of radius 1, with vertices approximately - // evenly distributed throughout. + // We will generate a rose of radius 1, with vertices approximately evenly + // distributed throughout. - // Since we will have _num_vertices filling the circle, and the area - // of a circle of radius 1 is A = pi*r^2 = pi, it follows that the - // number of vertices per square unit is (_num_vertices / pi), and - // thus the number of vertices per linear unit is the square root of - // that. + // Since we will have _num_vertices filling the circle, and the area of a + // circle of radius 1 is A = pi*r^2 = pi, it follows that the number of + // vertices per square unit is (_num_vertices pi), and thus the number of + // vertices per linear unit is the square root of that. PN_stdfloat vertices_per_unit = csqrt(_num_vertices / MathNumbers::pi_f); PN_stdfloat two_pi = 2.0f * MathNumbers::pi_f; - // The rose will be made up of concentric rings, originating from - // the center, to a radius of 1.0. + // The rose will be made up of concentric rings, originating from the + // center, to a radius of 1.0. int num_rings = (int)floor(vertices_per_unit + 0.5f); CPT(GeomVertexFormat) format = GeomVertexFormat::register_format (new GeomVertexArrayFormat - (InternalName::get_vertex(), 3, + (InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point, InternalName::get_texcoord(), 3, Geom::NT_stdfloat, Geom::C_texcoord)); - PT(GeomVertexData) vdata = + PT(GeomVertexData) vdata = new GeomVertexData(get_name(), format, Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); @@ -113,29 +103,28 @@ generate() { int last_ring_vertex = 0; PN_stdfloat last_r = 1.0f / (PN_stdfloat)num_rings; - // Make the first triangle. We actually make a one-triangle strip, - // but that seems more sensible than making a single isolated - // triangle. + // Make the first triangle. We actually make a one-triangle strip, but that + // seems more sensible than making a single isolated triangle. for (int vi = 0; vi < last_ring_size; ++vi) { - add_vertex(vertex, texcoord, last_r, + add_vertex(vertex, texcoord, last_r, two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); tristrips->add_vertex(vi); } - // Actually, we need to add one more degenerate triangle to make it - // an even-length tristrip. + // Actually, we need to add one more degenerate triangle to make it an even- + // length tristrip. tristrips->add_vertex(2); tristrips->close_primitive(); // Now make all of the rings. for (int ri = 1; ri < num_rings; ++ri) { PN_stdfloat r = (PN_stdfloat)(ri + 1) / (PN_stdfloat)num_rings; - + // The circumference of a ring of radius r is 2*pi*r. PN_stdfloat c = two_pi * r; int ring_size = (int)floor(c * vertices_per_unit + 0.5f); - - // Each ring must either have exactly the same number of vertices - // as the previous ring, or exactly double. + + // Each ring must either have exactly the same number of vertices as the + // previous ring, or exactly double. if (ring_size < last_ring_size * 2) { // This one will be the same. ring_size = last_ring_size; @@ -167,7 +156,7 @@ generate() { // Now we need to re-make the previous ring in this VertexData. last_ring_vertex = 0; for (int vi = 0; vi < last_ring_size; ++vi) { - add_vertex(vertex, texcoord, last_r, + add_vertex(vertex, texcoord, last_r, two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); } } @@ -175,7 +164,7 @@ generate() { // Now make this ring. int ring_vertex = vdata->get_num_rows(); for (int vi = 0; vi < ring_size; ++vi) { - add_vertex(vertex, texcoord, r, + add_vertex(vertex, texcoord, r, two_pi * (PN_stdfloat)vi / (PN_stdfloat)ring_size); } @@ -183,8 +172,8 @@ generate() { if (ring_size == last_ring_size) { // Exactly the same size ring. This one is easy. if ((ring_size + 1) * 2 > max_vertices_per_primitive) { - // Actually, we need to subdivide the ring to fit within the - // GSG's advertised limits. + // Actually, we need to subdivide the ring to fit within the GSG's + // advertised limits. int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { @@ -215,10 +204,10 @@ generate() { } } else { - // Exactly double size ring. This is harder; we can't make a - // single tristrip that goes all the way around the ring. - // Instead, we'll make an alternating series of four-triangle - // strips and two-triangle strips around the ring. + // Exactly double size ring. This is harder; we can't make a single + // tristrip that goes all the way around the ring. Instead, we'll make + // an alternating series of four-triangle strips and two-triangle strips + // around the ring. int vi = 0; while (vi < last_ring_size) { if (tristrips->get_num_vertices() + 10 > max_vertices_per_primitive) { @@ -272,11 +261,11 @@ generate() { geom = new Geom(vdata); tristrips = new GeomTristrips(Geom::UH_static); tristrips->set_shade_model(Geom::SM_uniform); - + // Now we need to re-make the previous ring in this VertexData. last_ring_vertex = 0; for (int vi = 0; vi < last_ring_size; ++vi) { - add_vertex(vertex, texcoord, last_r, + add_vertex(vertex, texcoord, last_r, two_pi * (PN_stdfloat)vi / (PN_stdfloat)last_ring_size); } } @@ -290,8 +279,8 @@ generate() { // Now draw the triangle strip to connect the rings. if ((ring_size + 1) * 2 > max_vertices_per_primitive) { - // Actually, we need to subdivide the ring to fit within the - // GSG's advertised limits. + // Actually, we need to subdivide the ring to fit within the GSG's + // advertised limits. int piece_size = max_vertices_per_primitive / 2 - 1; int vi = 0; while (vi < ring_size) { @@ -303,7 +292,7 @@ generate() { tristrips->close_primitive(); vi += piece_size; } - + } else { // We can fit the entire ring. if (tristrips->get_num_vertices() > 0 && @@ -336,31 +325,26 @@ generate() { return geom_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::add_vertex -// Access: Private -// Description: Given a point defined by a radius and an angle in -// radians, compute the 2-d coordinates for the vertex -// as well as the 3-d texture coordinates, and add both -// to the VertexData. -//////////////////////////////////////////////////////////////////// +/** + * Given a point defined by a radius and an angle in radians, compute the 2-d + * coordinates for the vertex as well as the 3-d texture coordinates, and add + * both to the VertexData. + */ void FisheyeMaker:: add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, PN_stdfloat r, PN_stdfloat a) { PN_stdfloat sina, cosa; csincos(a, &sina, &cosa); - - // The 2-d point is just a point r units from the center of the - // circle. + + // The 2-d point is just a point r units from the center of the circle. LPoint3 point(r * cosa, 0.0f, r * sina); vertex.add_data3(point); - // The 3-d point is the same thing, bent through the third dimension - // around the surface of a sphere to the point in the back. + // The 3-d point is the same thing, bent through the third dimension around + // the surface of a sphere to the point in the back. PN_stdfloat b = r * _half_fov_rad; if (b >= MathNumbers::pi_f) { - // Special case: we want to stop at the back pole, not continue - // around it. + // Special case: we want to stop at the back pole, not continue around it. texcoord.add_data3(0, _reflect, 0); } else { @@ -370,26 +354,21 @@ add_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, texcoord.add_data3(tc); } } - -//////////////////////////////////////////////////////////////////// -// Function: FisheyeMaker::add_square_vertex -// Access: Private -// Description: Similar to add_vertex(), but it draws the vertex all -// the way out to the edge of the square we are -// inscribed within, and the texture coordinate is -// always the back pole. -// -// This is just for the purpose of drawing the -// inscribing square. -//////////////////////////////////////////////////////////////////// + +/** + * Similar to add_vertex(), but it draws the vertex all the way out to the + * edge of the square we are inscribed within, and the texture coordinate is + * always the back pole. + * + * This is just for the purpose of drawing the inscribing square. + */ void FisheyeMaker:: add_square_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, PN_stdfloat a) { PN_stdfloat sina, cosa; csincos(a, &sina, &cosa); - - // Extend the 2-d point to the edge of the square of the indicated - // size. + + // Extend the 2-d point to the edge of the square of the indicated size. if (cabs(sina) > cabs(cosa)) { PN_stdfloat y = (sina > 0.0f) ? _square_radius : -_square_radius; PN_stdfloat x = y * cosa / sina; @@ -405,4 +384,3 @@ add_square_vertex(GeomVertexWriter &vertex, GeomVertexWriter &texcoord, texcoord.add_data3(0, _reflect, 0); } - diff --git a/panda/src/grutil/fisheyeMaker.h b/panda/src/grutil/fisheyeMaker.h index 2d8d8f6694..f3ce45fe96 100644 --- a/panda/src/grutil/fisheyeMaker.h +++ b/panda/src/grutil/fisheyeMaker.h @@ -1,16 +1,15 @@ -// Filename: fisheyeMaker.h -// Created by: drose (3Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fisheyeMaker.h + * @author drose + * @date 2005-10-03 + */ #ifndef FISHEYEMAKER_H #define FISHEYEMAKER_H @@ -23,19 +22,15 @@ class GeomVertexWriter; -//////////////////////////////////////////////////////////////////// -// Class : FisheyeMaker -// Description : This class is similar to CardMaker, but instead of -// generating ordinary cards, it generates a circular -// rose that represents the projection of a 3-D scene -// through a fisheye lens. The texture coordinates of -// the rose are defined so that each 2-D vertex has a -// 3-D UVW that reflects the corresponding position in -// 3-D space of that particular vertex. -// -// This class is particularly suited for converting cube -// maps to sphere maps. -//////////////////////////////////////////////////////////////////// +/** + * This class is similar to CardMaker, but instead of generating ordinary + * cards, it generates a circular rose that represents the projection of a 3-D + * scene through a fisheye lens. The texture coordinates of the rose are + * defined so that each 2-D vertex has a 3-D UVW that reflects the + * corresponding position in 3-D space of that particular vertex. + * + * This class is particularly suited for converting cube maps to sphere maps. + */ class EXPCL_PANDA_GRUTIL FisheyeMaker : public Namable { PUBLISHED: INLINE FisheyeMaker(const string &name); @@ -67,4 +62,3 @@ private: #include "fisheyeMaker.I" #endif - diff --git a/panda/src/grutil/frameRateMeter.I b/panda/src/grutil/frameRateMeter.I index 991d7c8ac0..744ed17d49 100644 --- a/panda/src/grutil/frameRateMeter.I +++ b/panda/src/grutil/frameRateMeter.I @@ -1,75 +1,60 @@ -// Filename: frameRateMeter.I -// Created by: drose (23Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameRateMeter.I + * @author drose + * @date 2003-12-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_window -// Access: Published -// Description: Returns the GraphicsOutput that was passed to -// setup_window(), or NULL if setup_window() has not -// been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsOutput that was passed to setup_window(), or NULL if + * setup_window() has not been called. + */ INLINE GraphicsOutput *FrameRateMeter:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_display_region -// Access: Published -// Description: Returns the DisplayRegion that the meter has created -// to render itself into the window to setup_window(), -// or NULL if setup_window() has not been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DisplayRegion that the meter has created to render itself into + * the window to setup_window(), or NULL if setup_window() has not been + * called. + */ INLINE DisplayRegion *FrameRateMeter:: get_display_region() const { return _display_region; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::set_update_interval -// Access: Published -// Description: Specifies the number of seconds that should elapse -// between updates to the frame rate indication. This -// should be reasonably slow (e.g. 0.2 to 1.0) so that -// the calculation of the frame rate text does not -// itself dominate the frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of seconds that should elapse between updates to the + * frame rate indication. This should be reasonably slow (e.g. 0.2 to 1.0) + * so that the calculation of the frame rate text does not itself dominate the + * frame rate. + */ INLINE void FrameRateMeter:: set_update_interval(double update_interval) { _update_interval = update_interval; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_update_interval -// Access: Published -// Description: Returns the number of seconds that will elapse -// between updates to the frame rate indication. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of seconds that will elapse between updates to the frame + * rate indication. + */ INLINE double FrameRateMeter:: get_update_interval() const { return _update_interval; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::set_text_pattern -// Access: Published -// Description: Sets the sprintf() pattern that is used to format the -// text. The string "%f" or some variant will be -// replaced with the current frame rate in frames per -// second. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sprintf() pattern that is used to format the text. The string + * "%f" or some variant will be replaced with the current frame rate in frames + * per second. + */ INLINE void FrameRateMeter:: set_text_pattern(const string &text_pattern) { _text_pattern = text_pattern; @@ -77,49 +62,37 @@ set_text_pattern(const string &text_pattern) { do_update(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_text_pattern -// Access: Published -// Description: Returns the sprintf() pattern that is used to format the -// text. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sprintf() pattern that is used to format the text. + */ INLINE const string &FrameRateMeter:: get_text_pattern() const { return _text_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::set_clock_object -// Access: Published -// Description: Sets the clock that is used to determine the frame -// rate. The default is the application's global clock -// (ClockObject::get_global_clock()). -//////////////////////////////////////////////////////////////////// +/** + * Sets the clock that is used to determine the frame rate. The default is + * the application's global clock (ClockObject::get_global_clock()). + */ INLINE void FrameRateMeter:: set_clock_object(ClockObject *clock_object) { _clock_object = clock_object; _last_update = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_clock_object -// Access: Published -// Description: Returns the clock that is used to determine the frame -// rate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the clock that is used to determine the frame rate. + */ INLINE ClockObject *FrameRateMeter:: get_clock_object() const { return _clock_object; } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::update -// Access: Published -// Description: You can call this to explicitly force the -// FrameRateMeter to update itself with the latest frame -// rate information. Normally, it is not necessary to -// call this explicitly. -//////////////////////////////////////////////////////////////////// +/** + * You can call this to explicitly force the FrameRateMeter to update itself + * with the latest frame rate information. Normally, it is not necessary to + * call this explicitly. + */ INLINE void FrameRateMeter:: update() { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index cbd0beb187..044a87a9a9 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -1,16 +1,15 @@ -// Filename: frameRateMeter.cxx -// Created by: drose (23Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameRateMeter.cxx + * @author drose + * @date 2003-12-23 + */ #include "frameRateMeter.h" #include "camera.h" @@ -28,11 +27,9 @@ PStatCollector FrameRateMeter::_show_fps_pcollector("*:Show fps"); TypeHandle FrameRateMeter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FrameRateMeter:: FrameRateMeter(const string &name) : TextNode(name), @@ -57,8 +54,8 @@ FrameRateMeter(const string &name) : _last_update = 0.0f; _clock_object = ClockObject::get_global_clock(); - // The top of the visible frame is 80% of the line height, based on - // the calculation within TextAssembler. + // The top of the visible frame is 80% of the line height, based on the + // calculation within TextAssembler. PN_stdfloat height = 1.0f; TextFont *font = get_font(); if (font != NULL){ @@ -70,28 +67,23 @@ FrameRateMeter(const string &name) : LMatrix4::translate_mat(LVector3::rfu(-frame_rate_meter_side_margins * frame_rate_meter_scale, 0.0f, -frame_rate_meter_scale * height))); set_card_color(0.0f, 0.0f, 0.0f, 0.4); set_card_as_margin(frame_rate_meter_side_margins, frame_rate_meter_side_margins, 0.1f, 0.0f); - // set_usage_hint(Geom::UH_client); + // set_usage_hint(Geom::UH_client); do_update(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FrameRateMeter:: ~FrameRateMeter() { clear_window(); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::setup_window -// Access: Published -// Description: Sets up the frame rate meter to create a -// DisplayRegion to render itself into the indicated -// window. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the frame rate meter to create a DisplayRegion to render itself + * into the indicated window. + */ void FrameRateMeter:: setup_window(GraphicsOutput *window) { clear_window(); @@ -108,9 +100,9 @@ setup_window(GraphicsOutput *window) { _root.set_material_off(1); _root.set_two_sided(1, 1); - // If we don't set this explicitly, Panda will cause it to be rendered - // in a back-to-front cull bin, which will cause the bounding volume - // to be computed unnecessarily. Saves a little bit of overhead. + // If we don't set this explicitly, Panda will cause it to be rendered in a + // back-to-front cull bin, which will cause the bounding volume to be + // computed unnecessarily. Saves a little bit of overhead. _root.set_bin("unsorted", 0); // Create a display region that covers the entire window. @@ -137,12 +129,9 @@ setup_window(GraphicsOutput *window) { _display_region->set_camera(camera_np); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::clear_window -// Access: Published -// Description: Undoes the effect of a previous call to -// setup_window(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to setup_window(). + */ void FrameRateMeter:: clear_window() { if (_window != (GraphicsOutput *)NULL) { @@ -153,35 +142,28 @@ clear_window() { _root = NodePath(); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool FrameRateMeter:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // This triggers when you try to parent a frame rate meter into - // the scene graph yourself. Instead, use setup_window(). + // This triggers when you try to parent a frame rate meter into the scene + // graph yourself. Instead, use setup_window(). nassertr(_display_region != NULL, false); Thread *current_thread = trav->get_current_thread(); @@ -189,8 +171,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Statistics PStatTimer timer(_show_fps_pcollector, current_thread); - // This is probably a good time to check if the aspect ratio on - // the window has changed. + // This is probably a good time to check if the aspect ratio on the window + // has changed. int width = _display_region->get_pixel_width(); int height = _display_region->get_pixel_height(); PN_stdfloat aspect_ratio = 1; @@ -215,11 +197,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return TextNode::cull_callback(trav, data); } -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::do_update -// Access: Private -// Description: Resets the text according to the current frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Resets the text according to the current frame rate. + */ void FrameRateMeter:: do_update(Thread *current_thread) { _last_update = _clock_object->get_frame_time(current_thread); diff --git a/panda/src/grutil/frameRateMeter.h b/panda/src/grutil/frameRateMeter.h index e688b6da86..1f0c0f29a8 100644 --- a/panda/src/grutil/frameRateMeter.h +++ b/panda/src/grutil/frameRateMeter.h @@ -1,16 +1,15 @@ -// Filename: frameRateMeter.h -// Created by: drose (23Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frameRateMeter.h + * @author drose + * @date 2003-12-23 + */ #ifndef FRAMERATEMETER_H #define FRAMERATEMETER_H @@ -26,18 +25,15 @@ class GraphicsChannel; class ClockObject; -//////////////////////////////////////////////////////////////////// -// Class : FrameRateMeter -// Description : This is a special TextNode that automatically updates -// itself with the current frame rate. It can be placed -// anywhere in the world where you'd like to see the -// frame rate. -// -// It also has a special mode in which it may be -// attached directly to a channel or window. If this is -// done, it creates a DisplayRegion for itself and renders -// itself in the upper-right-hand corner. -//////////////////////////////////////////////////////////////////// +/** + * This is a special TextNode that automatically updates itself with the + * current frame rate. It can be placed anywhere in the world where you'd + * like to see the frame rate. + * + * It also has a special mode in which it may be attached directly to a + * channel or window. If this is done, it creates a DisplayRegion for itself + * and renders itself in the upper-right-hand corner. + */ class EXPCL_PANDA_GRUTIL FrameRateMeter : public TextNode { PUBLISHED: FrameRateMeter(const string &name); diff --git a/panda/src/grutil/geoMipTerrain.I b/panda/src/grutil/geoMipTerrain.I index a80703c9e3..eb41d492fc 100644 --- a/panda/src/grutil/geoMipTerrain.I +++ b/panda/src/grutil/geoMipTerrain.I @@ -1,24 +1,21 @@ -// Filename: geoMipTerrain.I -// Created by: rdb (29Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geoMipTerrain.I + * @author rdb + * @date 2007-06-29 + */ #include "config_grutil.h" -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeoMipTerrain:: GeoMipTerrain(const string &name) { _root = NodePath(name); @@ -42,50 +39,37 @@ GeoMipTerrain(const string &name) { _stitching = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::Destructor -// Access: Published -// Description: This will not remove the terrain node itself. -// To have the terrain itself also deleted, please -// call remove_node() prior to destruction. -//////////////////////////////////////////////////////////////////// +/** + * This will not remove the terrain node itself. To have the terrain itself + * also deleted, please call remove_node() prior to destruction. + */ INLINE GeoMipTerrain:: ~GeoMipTerrain() { } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::heightfield -// Access: Published -// Description: Returns a reference to the heightfield (a PNMImage) -// contained inside GeoMipTerrain. You can use -// the reference to alter the heightfield. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the heightfield (a PNMImage) contained inside + * GeoMipTerrain. You can use the reference to alter the heightfield. + */ INLINE PNMImage &GeoMipTerrain:: heightfield() { return _heightfield; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::color_map -// Access: Published -// Description: Returns a reference to the color map (a PNMImage) -// contained inside GeoMipTerrain. You can use -// the reference to alter the color map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the color map (a PNMImage) contained inside + * GeoMipTerrain. You can use the reference to alter the color map. + */ INLINE PNMImage &GeoMipTerrain:: color_map() { return _color_map; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_bruteforce -// Access: Published -// Description: Sets a boolean specifying whether the terrain will -// be rendered bruteforce. If the terrain is rendered -// bruteforce, there will be no Level of Detail, and -// the update() call will only update the -// terrain if it is marked dirty. -//////////////////////////////////////////////////////////////////// +/** + * Sets a boolean specifying whether the terrain will be rendered bruteforce. + * If the terrain is rendered bruteforce, there will be no Level of Detail, + * and the update() call will only update the terrain if it is marked dirty. + */ INLINE void GeoMipTerrain:: set_bruteforce(bool bf) { if (bf == true && _bruteforce == false) { @@ -94,42 +78,32 @@ set_bruteforce(bool bf) { _bruteforce = bf; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_bruteforce -// Access: Published -// Description: Returns a boolean whether the terrain is rendered -// bruteforce or not. See set_bruteforce for more -// information. -//////////////////////////////////////////////////////////////////// +/** + * Returns a boolean whether the terrain is rendered bruteforce or not. See + * set_bruteforce for more information. + */ INLINE bool GeoMipTerrain:: get_bruteforce() { return _bruteforce; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_auto_flatten -// Access: Private -// Description: The terrain can be automatically flattened (using -// flatten_light, flatten_medium, or flatten_strong) -// after each update. This only affects future -// updates, it doesn't flatten the current terrain. -//////////////////////////////////////////////////////////////////// +/** + * The terrain can be automatically flattened (using flatten_light, + * flatten_medium, or flatten_strong) after each update. This only affects + * future updates, it doesn't flatten the current terrain. + */ INLINE void GeoMipTerrain:: set_auto_flatten(int mode) { _auto_flatten = mode; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_focal_point -// Access: Published -// Description: Sets the focal point. GeoMipTerrain generates -// high-resolution terrain around the focal point, and -// progressively lower and lower resolution terrain -// as you get farther away. If a point is supplied -// and not a NodePath, make sure it's relative to -// the terrain. Only the x and y coordinates of -// the focal point are taken in respect. -//////////////////////////////////////////////////////////////////// +/** + * Sets the focal point. GeoMipTerrain generates high-resolution terrain + * around the focal point, and progressively lower and lower resolution + * terrain as you get farther away. If a point is supplied and not a + * NodePath, make sure it's relative to the terrain. Only the x and y + * coordinates of the focal point are taken in respect. + */ INLINE void GeoMipTerrain:: set_focal_point(double x, double y) { if (!_focal_is_temporary) { @@ -164,88 +138,68 @@ set_focal_point(NodePath fp) { _focal_is_temporary = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_focal_point -// Access: Published -// Description: Returns the focal point, as a NodePath. -// If you have set it to be just a point, it will -// return an empty node at the focal position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the focal point, as a NodePath. If you have set it to be just a + * point, it will return an empty node at the focal position. + */ INLINE NodePath GeoMipTerrain:: get_focal_point() const { return _focal_point; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_root -// Access: Published -// Description: Returns the root of the terrain. This is a -// single PandaNode to which all the rest of the -// terrain is parented. The generate and update -// operations replace the nodes which are parented -// to this root, but they don't replace this root -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the terrain. This is a single PandaNode to which all + * the rest of the terrain is parented. The generate and update operations + * replace the nodes which are parented to this root, but they don't replace + * this root itself. + */ INLINE NodePath GeoMipTerrain:: get_root() const { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_min_level -// Access: Published -// Description: Sets the minimum level of detail at which blocks -// may be generated by generate() or update(). -// The default value is 0, which is the highest -// quality. This value is also taken in respect when -// generating the terrain bruteforce. -//////////////////////////////////////////////////////////////////// +/** + * Sets the minimum level of detail at which blocks may be generated by + * generate() or update(). The default value is 0, which is the highest + * quality. This value is also taken in respect when generating the terrain + * bruteforce. + */ INLINE void GeoMipTerrain:: set_min_level(unsigned short minlevel) { _min_level = minlevel; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_min_level -// Access: Published -// Description: Gets the minimum level of detail at which blocks -// may be generated by generate() or update(). -// The default value is 0, which is the highest -// quality. -//////////////////////////////////////////////////////////////////// +/** + * Gets the minimum level of detail at which blocks may be generated by + * generate() or update(). The default value is 0, which is the highest + * quality. + */ INLINE unsigned short GeoMipTerrain:: get_min_level() { return _min_level; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_max_level -// Access: Published -// Description: Returns the highest level possible for this block -// size. When a block is at this level, it will be -// the worst quality possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the highest level possible for this block size. When a block is at + * this level, it will be the worst quality possible. + */ INLINE unsigned short GeoMipTerrain:: get_max_level() { return _max_level; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_block_size -// Access: Published -// Description: Gets the block size. -//////////////////////////////////////////////////////////////////// +/** + * Gets the block size. + */ INLINE unsigned short GeoMipTerrain:: get_block_size() { return _block_size; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_block_size -// Access: Published -// Description: Sets the block size. If it is not a power of two, -// the closest power of two is used. -//////////////////////////////////////////////////////////////////// +/** + * Sets the block size. If it is not a power of two, the closest power of two + * is used. + */ INLINE void GeoMipTerrain:: set_block_size(unsigned short newbs) { if (is_power_of_two(newbs)) { @@ -266,32 +220,24 @@ set_block_size(unsigned short newbs) { _is_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::is_dirty -// Access: Published -// Description: Returns a bool indicating whether the terrain is -// marked 'dirty', that means the terrain has to be -// regenerated on the next update() call, because -// for instance the heightfield has changed. -// Once the terrain has been regenerated, the dirty -// flag automatically gets reset internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a bool indicating whether the terrain is marked 'dirty', that means + * the terrain has to be regenerated on the next update() call, because for + * instance the heightfield has changed. Once the terrain has been + * regenerated, the dirty flag automatically gets reset internally. + */ INLINE bool GeoMipTerrain:: is_dirty() { return _is_dirty; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_factor -// Access: Published -// Description: DEPRECATED method. Use set_near/far instead. -// Sets the quality factor at which blocks must be -// generated. The higher this level, the better -// quality 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 method. Use set_near/far instead. Sets the quality factor at + * which blocks must be generated. The higher this level, the better quality + * 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. + */ INLINE void GeoMipTerrain:: set_factor(PN_stdfloat factor) { grutil_cat.debug() << "Using deprecated method set_factor, use set_near and set_far instead!\n"; @@ -299,11 +245,9 @@ set_factor(PN_stdfloat factor) { _factor = factor; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_near_far -// Access: Published -// Description: Sets the near and far LOD distances in one call. -//////////////////////////////////////////////////////////////////// +/** + * Sets the near and far LOD distances in one call. + */ INLINE void GeoMipTerrain:: set_near_far(double input_near, double input_far) { _use_near_far = true; @@ -311,78 +255,58 @@ set_near_far(double input_near, double input_far) { _far = input_far; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_near -// Access: Published -// Description: Sets the near LOD distance, at which the terrain -// will be rendered at highest quality. -// This distance is in the terrain's coordinate space! -//////////////////////////////////////////////////////////////////// +/** + * Sets the near LOD distance, at which the terrain will be rendered at + * highest quality. This distance is in the terrain's coordinate space! + */ INLINE void GeoMipTerrain:: set_near(double input_near) { _use_near_far = true; _near = input_near; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_far -// Access: Published -// Description: Sets the far LOD distance, at which the terrain -// will be rendered at lowest quality. -// This distance is in the terrain's coordinate space! -//////////////////////////////////////////////////////////////////// +/** + * Sets the far LOD distance, at which the terrain will be rendered at lowest + * quality. This distance is in the terrain's coordinate space! + */ INLINE void GeoMipTerrain:: set_far(double input_far) { _use_near_far = true; _far = input_far; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_far -// Access: Published -// Description: Returns the far LOD distance in the terrain coordinate -// space -//////////////////////////////////////////////////////////////////// +/** + * Returns the far LOD distance in the terrain coordinate space + */ INLINE double GeoMipTerrain:: get_far() { return _far; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_near -// Access: Published -// Description: Returns the near LOD distance in the terrain coordinate -// space -//////////////////////////////////////////////////////////////////// +/** + * Returns the near LOD distance in the terrain coordinate space + */ INLINE double GeoMipTerrain:: get_near() { return _near; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_flatten_mode -// Access: Published -// Description: Returns the automatic-flatten mode (e.g., off, -// flatten_light, flatten_medium, or flatten_strong) -//////////////////////////////////////////////////////////////////// +/** + * Returns the automatic-flatten mode (e.g., off, flatten_light, + * flatten_medium, or flatten_strong) + */ INLINE int GeoMipTerrain:: get_flatten_mode() { return _auto_flatten; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_block_node_path -// Access: Published -// Description: Returns the NodePath of the specified block. -// If auto-flatten is enabled and the node is -// getting removed during the flattening process, -// it will still return a NodePath with the -// appropriate terrain chunk, but it will be in -// a temporary scenegraph. -// Please note that this returns a const object and -// you can not modify the node. Modify the heightfield -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath of the specified block. If auto-flatten is enabled + * and the node is getting removed during the flattening process, it will + * still return a NodePath with the appropriate terrain chunk, but it will be + * in a temporary scenegraph. Please note that this returns a const object + * and you can not modify the node. Modify the heightfield instead. + */ INLINE const NodePath GeoMipTerrain:: get_block_node_path(unsigned short mx, unsigned short my) { nassertr(mx < _blocks.size(), NodePath::fail()); @@ -390,20 +314,15 @@ get_block_node_path(unsigned short mx, unsigned short my) { return _blocks[mx][my]; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_block_from_pos -// Access: Published -// Description: Gets the coordinates of the block at the specified -// position. This position must be relative to the -// terrain, not to render. Returns an array containing -// two values: the block x and the block y coords. -// If the positions are out of range, the closest -// block is taken. -// Note that the VecBase returned does not represent -// a vector, position, or rotation, but it contains -// the block index of the block which you can use -// in GeoMipTerrain::get_block_node_path. -//////////////////////////////////////////////////////////////////// +/** + * Gets the coordinates of the block at the specified position. This position + * must be relative to the terrain, not to render. Returns an array + * containing two values: the block x and the block y coords. If the + * positions are out of range, the closest block is taken. Note that the + * VecBase returned does not represent a vector, position, or rotation, but it + * contains the block index of the block which you can use in + * GeoMipTerrain::get_block_node_path. + */ INLINE LVecBase2 GeoMipTerrain:: get_block_from_pos(double x, double y) { if (x < 0) x = 0; @@ -414,11 +333,9 @@ get_block_from_pos(double x, double y) { y = floor(y / _block_size); return LVecBase2(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::lod_decide -// Access: Private -// Description: Calculates the level for the given mipmap. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the level for the given mipmap. + */ INLINE unsigned short GeoMipTerrain:: lod_decide(unsigned short mx, unsigned short my) { PN_stdfloat cx = mx; @@ -447,15 +364,11 @@ lod_decide(unsigned short mx, unsigned short my) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_heightfield -// Access: Published -// Description: Loads the specified heightmap image file into -// the heightfield. Returns true if succeeded, or -// false if an error has occured. -// If the heightmap is not a power of two plus one, -// it is scaled up using a gaussian filter. -//////////////////////////////////////////////////////////////////// +/** + * Loads the specified heightmap image file into the heightfield. Returns + * true if succeeded, or false if an error has occured. If the heightmap is + * not a power of two plus one, it is scaled up using a gaussian filter. + */ INLINE bool GeoMipTerrain:: set_heightfield(const PNMImage &image) { if (image.get_color_space() == CS_sRGB) { @@ -481,15 +394,11 @@ set_heightfield(const PNMImage &image) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_color_map -// Access: Published -// Description: Loads the specified image as color map. The next -// time generate() is called, the terrain is painted -// with this color map using the vertex color column. -// Returns a boolean indicating whether the operation -// has succeeded. -//////////////////////////////////////////////////////////////////// +/** + * Loads the specified image as color map. The next time generate() is + * called, the terrain is painted with this color map using the vertex color + * column. Returns a boolean indicating whether the operation has succeeded. + */ INLINE bool GeoMipTerrain:: set_color_map(const Filename &filename, PNMFileType *ftype) { if (_color_map.read(filename, ftype)) { @@ -520,21 +429,17 @@ set_color_map(const string &path) { return set_color_map(Filename(path)); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::has_color_map -// Access: Published -// Description: Returns whether a color map has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether a color map has been set. + */ INLINE bool GeoMipTerrain:: has_color_map() const { return _has_color_map; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::clear_color_map -// Access: Published -// Description: Clears the color map. -//////////////////////////////////////////////////////////////////// +/** + * Clears the color map. + */ INLINE void GeoMipTerrain:: clear_color_map() { if (_has_color_map) { @@ -543,18 +448,13 @@ clear_color_map() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_border_stitching -// Access: Published -// Description: If this value is true, the LOD level at the -// borders of the terrain will be 0. This is useful -// if you have multiple terrains attached and you -// want to stitch them together, to fix seams. -// This setting also has effect when bruteforce is -// enabled, although in that case you are probably -// better off with setting the minlevels to the same -// value. -//////////////////////////////////////////////////////////////////// +/** + * If this value is true, the LOD level at the borders of the terrain will be + * 0. This is useful if you have multiple terrains attached and you want to + * stitch them together, to fix seams. This setting also has effect when + * bruteforce is enabled, although in that case you are probably better off + * with setting the minlevels to the same value. + */ INLINE void GeoMipTerrain:: set_border_stitching(bool stitching) { if (stitching && !_stitching) { @@ -563,24 +463,20 @@ set_border_stitching(bool stitching) { _stitching = stitching; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_stitching -// Access: Published -// Description: Returns the current stitching setting. False by -// default, unless set_stitching has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current stitching setting. False by default, unless + * set_stitching has been set. + */ INLINE bool GeoMipTerrain:: get_border_stitching() { return _stitching; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_pixel_value -// Access: Private -// Description: Get the elevation at a certain pixel of the image. -// This function does NOT linearly interpolate. -// For that, use GeoMipTerrain::get_elevation() instead. -//////////////////////////////////////////////////////////////////// +/** + * Get the elevation at a certain pixel of the image. This function does NOT + * linearly interpolate. For that, use GeoMipTerrain::get_elevation() + * instead. + */ INLINE double GeoMipTerrain:: get_pixel_value(int x, int y) { x = max(min(x,int(_xsize-1)),0); @@ -601,17 +497,13 @@ get_pixel_value(unsigned short mx, unsigned short my, int x, int y) { (my * _block_size + y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_normal -// Access: Published -// Description: Fetches the terrain normal at (x,y), where the input -// coordinate is specified in pixels. This ignores the -// current LOD level and instead provides an -// accurate number. -// Terrain scale is NOT taken into account! To get -// accurate normals, please divide it by the -// terrain scale and normalize it again! -//////////////////////////////////////////////////////////////////// +/** + * Fetches the terrain normal at (x,y), where the input coordinate is + * specified in pixels. This ignores the current LOD level and instead + * provides an accurate number. Terrain scale is NOT taken into account! To + * get accurate normals, please divide it by the terrain scale and normalize + * it again! + */ INLINE LVector3 GeoMipTerrain:: get_normal(unsigned short mx, unsigned short my, int x, int y) { nassertr_always(mx < (_xsize - 1) / _block_size, false); @@ -620,23 +512,17 @@ get_normal(unsigned short mx, unsigned short my, int x, int y) { (my * _block_size + y)); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::is_power_of_two -// Access: Private -// Description: Returns a bool whether the given int i is a -// power of two or not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a bool whether the given int i is a power of two or not. + */ INLINE bool GeoMipTerrain:: is_power_of_two(unsigned int i) { return !((i - 1) & i); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::f_part -// Access: Private -// Description: Returns the part of the number right of the -// floating-point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the part of the number right of the floating-point. + */ INLINE float GeoMipTerrain:: f_part(float i) { return i - floor(i); @@ -646,12 +532,9 @@ f_part(double i) { return i - floor(i); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::sfav -// Access: Private -// Description: Used to calculate vertex numbers. Only to -// be used internally. -//////////////////////////////////////////////////////////////////// +/** + * Used to calculate vertex numbers. Only to be used internally. + */ INLINE int GeoMipTerrain:: sfav(int n, int powlevel, int mypowlevel) { double t = n - 1; @@ -660,4 +543,3 @@ sfav(int n, int powlevel, int mypowlevel) { t *= pow(2.0, powlevel - mypowlevel); return int(t); } - diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 6d60525569..0df3787086 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -1,16 +1,15 @@ -// Filename: geoMipTerrain.cxx -// Created by: rdb (29Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geoMipTerrain.cxx + * @author rdb + * @date 2007-06-29 + */ #include "geoMipTerrain.h" @@ -40,15 +39,12 @@ static ConfigVariableBool geomipterrain_incorrect_normals TypeHandle GeoMipTerrain::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::generate_block -// Access: Private -// Description: Generates a chunk of terrain based on the level -// specified. As arguments it takes the x and y coords -// of the mipmap to be generated, and the level of -// detail. T-Junctions for neighbor-mipmaps with -// different levels are also taken into account. -//////////////////////////////////////////////////////////////////// +/** + * Generates a chunk of terrain based on the level specified. As arguments it + * takes the x and y coords of the mipmap to be generated, and the level of + * detail. T-Junctions for neighbor-mipmaps with different levels are also + * taken into account. + */ PT(GeomNode) GeoMipTerrain:: generate_block(unsigned short mx, unsigned short my, @@ -90,8 +86,8 @@ generate_block(unsigned short mx, PT(GeomTriangles) prim = new GeomTriangles(Geom::UH_stream); if (_bruteforce) { - // LOD Level when rendering bruteforce is always 0 (no lod) - // Unless a minlevel is set- this is handled later. + // LOD Level when rendering bruteforce is always 0 (no lod) Unless a + // minlevel is set- this is handled later. level = 0; } @@ -110,10 +106,9 @@ generate_block(unsigned short mx, bool bjunction = (bnlevel != reallevel); bool tjunction = (tnlevel != reallevel); - // Confusing note: - // the variable level contains not the actual level as described - // in the GeoMipMapping paper. That is stored in reallevel, - // while the variable level contains 2^reallevel. + // Confusing note: the variable level contains not the actual level as + // described in the GeoMipMapping paper. That is stored in reallevel, while + // the variable level contains 2^reallevel. // This is the number of vertices at the certain level. unsigned short lowblocksize = _block_size / level + 1; @@ -271,20 +266,15 @@ generate_block(unsigned short mx, return node; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_elevation -// Access: Published -// Description: Fetches the elevation at (x, y), where the input -// coordinate is specified in pixels. This ignores -// the current LOD level and instead provides an -// accurate number. Linear blending is used for -// non-integral coordinates. -// Terrain scale is NOT taken into account! To get -// accurate normals, please multiply this with the -// terrain Z scale! -// -// trueElev = terr.get_elevation(x,y) * terr.get_sz(); -//////////////////////////////////////////////////////////////////// +/** + * Fetches the elevation at (x, y), where the input coordinate is specified in + * pixels. This ignores the current LOD level and instead provides an + * accurate number. Linear blending is used for non-integral coordinates. + * Terrain scale is NOT taken into account! To get accurate normals, please + * multiply this with the terrain Z scale! + * + * trueElev = terr.get_elevation(x,y) * terr.get_sz(); + */ double GeoMipTerrain:: get_elevation(double x, double y) { y = (_ysize - 1) - y; @@ -309,23 +299,17 @@ get_elevation(double x, double y) { return lerpyh * yoffs + lerpyl * (1.0 - yoffs); } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_normal -// Access: Published -// Description: Fetches the terrain normal at (x, y), where the -// input coordinate is specified in pixels. This -// ignores the current LOD level and instead provides -// an accurate number. -// Terrain scale is NOT taken into account! To get -// accurate normals, please divide it by the -// terrain scale and normalize it again, like this: -// -// LVector3 normal (terr.get_normal(x, y)); -// normal.set(normal.get_x() / root.get_sx(), -// normal.get_y() / root.get_sy(), -// normal.get_z() / root.get_sz()); -// normal.normalize(); -//////////////////////////////////////////////////////////////////// +/** + * Fetches the terrain normal at (x, y), where the input coordinate is + * specified in pixels. This ignores the current LOD level and instead + * provides an accurate number. Terrain scale is NOT taken into account! To + * get accurate normals, please divide it by the terrain scale and normalize + * it again, like this: + * + * LVector3 normal (terr.get_normal(x, y)); normal.set(normal.get_x() / + * root.get_sx(), normal.get_y() / root.get_sy(), normal.get_z() / + * root.get_sz()); normal.normalize(); + */ LVector3 GeoMipTerrain:: get_normal(int x, int y) { int nx = x - 1; @@ -348,21 +332,15 @@ get_normal(int x, int y) { return normal; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::make_slope_image -// Access: Published -// Description: Returns a new grayscale image containing the slope -// angles. A white pixel value means a vertical slope, -// while a black pixel will mean that the terrain is -// entirely flat at that pixel. -// You can translate it to degrees by mapping the -// greyscale values from 0 to 90 degrees. -// The resulting image will have the same size as the -// heightfield image. -// The scale will be taken into respect -- meaning, -// if you change the terrain scale, the slope image -// will need to be regenerated in order to be correct. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new grayscale image containing the slope angles. A white pixel + * value means a vertical slope, while a black pixel will mean that the + * terrain is entirely flat at that pixel. You can translate it to degrees by + * mapping the greyscale values from 0 to 90 degrees. The resulting image + * will have the same size as the heightfield image. The scale will be taken + * into respect -- meaning, if you change the terrain scale, the slope image + * will need to be regenerated in order to be correct. + */ PNMImage GeoMipTerrain:: make_slope_image() { PNMImage result (_xsize, _ysize); @@ -380,15 +358,12 @@ make_slope_image() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::calc_ambient_occlusion -// Access: Published -// Description: Calculates an approximate for the ambient occlusion -// and stores it in the color map, so that it will be -// written to the vertex colors. Any existing color -// map will be discarded. -// You need to call this before generating the geometry. -//////////////////////////////////////////////////////////////////// +/** + * Calculates an approximate for the ambient occlusion and stores it in the + * color map, so that it will be written to the vertex colors. Any existing + * color map will be discarded. You need to call this before generating the + * geometry. + */ void GeoMipTerrain:: calc_ambient_occlusion(PN_stdfloat radius, PN_stdfloat contrast, PN_stdfloat brightness) { _color_map = PNMImage(_xsize, _ysize); @@ -401,8 +376,8 @@ calc_ambient_occlusion(PN_stdfloat radius, PN_stdfloat contrast, PN_stdfloat bri } } - // We use the cheap old method of subtracting a blurred version - // of the heightmap from the heightmap, and using that as lightmap. + // We use the cheap old method of subtracting a blurred version of the + // heightmap from the heightmap, and using that as lightmap. _color_map.gaussian_filter(radius); for (unsigned int x = 0; x < _xsize; ++x) { @@ -414,15 +389,11 @@ calc_ambient_occlusion(PN_stdfloat radius, PN_stdfloat contrast, PN_stdfloat bri _has_color_map = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::generate -// Access: Published -// Description: (Re)generates the entire terrain, erasing the -// current. -// This call un-flattens the terrain, so make sure -// you have set auto-flatten if you want to keep -// your terrain flattened. -//////////////////////////////////////////////////////////////////// +/** + * (Re)generates the entire terrain, erasing the current. This call un- + * flattens the terrain, so make sure you have set auto-flatten if you want to + * keep your terrain flattened. + */ void GeoMipTerrain:: generate() { if (_xsize < 3 || _ysize < 3) { @@ -453,20 +424,14 @@ generate() { _is_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::update -// Access: Published -// Description: Loops through all of the terrain blocks, and -// checks whether they need to be updated. -// If that is indeed the case, it regenerates the -// mipmap. Returns a true when the terrain has -// changed. Returns false when the terrain isn't -// updated at all. If there is no terrain yet, -// it generates the entire terrain. -// This call un-flattens the terrain, so make sure -// you have set auto-flatten if you want to keep -// your terrain flattened. -//////////////////////////////////////////////////////////////////// +/** + * Loops through all of the terrain blocks, and checks whether they need to be + * updated. If that is indeed the case, it regenerates the mipmap. Returns a + * true when the terrain has changed. Returns false when the terrain isn't + * updated at all. If there is no terrain yet, it generates the entire + * terrain. This call un-flattens the terrain, so make sure you have set + * auto-flatten if you want to keep your terrain flattened. + */ bool GeoMipTerrain:: update() { if (_xsize < 3 || _ysize < 3) { @@ -526,26 +491,22 @@ update() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::root_flattened -// Access: Private -// Description: Normally, the root's children are the terrain blocks. -// However, if we call flatten_strong on the root, -// then the root will contain unpredictable stuff. -// This function returns true if the root has been -// flattened, and therefore, does not contain the -// terrain blocks. -//////////////////////////////////////////////////////////////////// +/** + * Normally, the root's children are the terrain blocks. However, if we call + * flatten_strong on the root, then the root will contain unpredictable stuff. + * This function returns true if the root has been flattened, and therefore, + * does not contain the terrain blocks. + */ bool GeoMipTerrain:: root_flattened() { if (_root_flattened) { return true; } - // The following code is error-checking code. It actually verifies - // that the terrain blocks are underneath the root, and that nothing - // else is underneath the root. It is not very efficient, and should - // eventually be removed once we're sure everything works. + // The following code is error-checking code. It actually verifies that the + // terrain blocks are underneath the root, and that nothing else is + // underneath the root. It is not very efficient, and should eventually be + // removed once we're sure everything works. int total = 0; unsigned int xsize = _blocks.size(); @@ -568,20 +529,18 @@ root_flattened() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::auto_flatten -// Access: Private -// Description: Flattens the geometry under the root. -//////////////////////////////////////////////////////////////////// +/** + * Flattens the geometry under the root. + */ void GeoMipTerrain:: auto_flatten() { if (_auto_flatten == AFM_off) { return; } - // Creating a backup node causes the SceneGraphReducer - // to operate in a nondestructive manner. This protects - // the terrain blocks themselves from the flattener. + // Creating a backup node causes the SceneGraphReducer to operate in a + // nondestructive manner. This protects the terrain blocks themselves from + // the flattener. NodePath np("Backup Node"); np.node()->copy_children(_root.node()); @@ -596,12 +555,10 @@ auto_flatten() { _root_flattened = true; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::calc_levels -// Access: Private -// Description: Loops through all of the terrain blocks, and -// calculates on what level they should be generated. -//////////////////////////////////////////////////////////////////// +/** + * Loops through all of the terrain blocks, and calculates on what level they + * should be generated. + */ void GeoMipTerrain:: calc_levels() { nassertv(_xsize >= 3 && _ysize >= 3); @@ -621,23 +578,17 @@ calc_levels() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::update_block -// Access: Private -// Description: Checks whether the specified mipmap at (mx,my) -// needs to be updated, if so, it regenerates the -// mipmap. Returns a true when it has generated -// a mipmap. Returns false when the mipmap is already -// at the desired level, or when there is no terrain -// to update. Note: This does not affect neighboring -// blocks, so does NOT fix t-junctions. You will have -// to fix that by forced updating the neighboring -// chunks as well, with the same levels. -// NOTE: do NOT call this when the terrain is marked -// dirty. If the terrain is dirty, you will need to -// call update() or generate() first. -// You can check this by calling GeoMipTerrain::is_dirty(). -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the specified mipmap at (mx,my) needs to be updated, if so, + * it regenerates the mipmap. Returns a true when it has generated a mipmap. + * Returns false when the mipmap is already at the desired level, or when + * there is no terrain to update. Note: This does not affect neighboring + * blocks, so does NOT fix t-junctions. You will have to fix that by forced + * updating the neighboring chunks as well, with the same levels. NOTE: do + * NOT call this when the terrain is marked dirty. If the terrain is dirty, + * you will need to call update() or generate() first. You can check this by + * calling GeoMipTerrain::is_dirty(). + */ bool GeoMipTerrain:: update_block(unsigned short mx, unsigned short my, signed short level, bool forced) { @@ -656,15 +607,11 @@ update_block(unsigned short mx, unsigned short my, return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::set_heightfield -// Access: Published -// Description: Loads the specified heightmap image file into -// the heightfield. Returns true if succeeded, or -// false if an error has occured. -// If the heightmap is not a power of two plus one, -// it is scaled up using a gaussian filter. -//////////////////////////////////////////////////////////////////// +/** + * Loads the specified heightmap image file into the heightfield. Returns + * true if succeeded, or false if an error has occured. If the heightmap is + * not a power of two plus one, it is scaled up using a gaussian filter. + */ bool GeoMipTerrain:: set_heightfield(const Filename &filename, PNMFileType *ftype) { // First, we need to load the header to determine the size and format. @@ -716,15 +663,13 @@ set_heightfield(const Filename &filename, PNMFileType *ftype) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeoMipTerrain::get_neighbor_level -// Access: Private -// Description: Helper function for generate(). -//////////////////////////////////////////////////////////////////// +/** + * Helper function for generate(). + */ unsigned short GeoMipTerrain:: get_neighbor_level(unsigned short mx, unsigned short my, short dmx, short dmy) { - // If we're across the terrain border, check if we want stitching. - // If not, return the same level as this one - it won't have to make junctions. + // If we're across the terrain border, check if we want stitching. If not, + // return the same level as this one - it won't have to make junctions. if ((int)mx + (int)dmx < 0 || (int)mx + (int)dmx >= ((int)_xsize - 1) / (int)_block_size || (int)my + (int)dmy < 0 || (int)my + (int)dmy >= ((int)_ysize - 1) / (int)_block_size) { return (_stitching) ? _max_level : min(max(_min_level, _levels[mx][my]), _max_level); @@ -733,12 +678,11 @@ get_neighbor_level(unsigned short mx, unsigned short my, short dmx, short dmy) { if (_bruteforce) { return min(max(_min_level, _levels[mx][my]), _max_level); } - // Only if the level is higher than the current. - // Otherwise, the junctions will be made for the other chunk. + // Only if the level is higher than the current. Otherwise, the junctions + // will be made for the other chunk. if (_levels[mx + dmx][my + dmy] > _levels[mx][my]) { return min(max(_min_level, _levels[mx + dmx][my + dmy]), _max_level); } else { return min(max(_min_level, _levels[mx][my]), _max_level); } } - diff --git a/panda/src/grutil/geoMipTerrain.h b/panda/src/grutil/geoMipTerrain.h index 3719f50283..87115496d0 100644 --- a/panda/src/grutil/geoMipTerrain.h +++ b/panda/src/grutil/geoMipTerrain.h @@ -1,16 +1,15 @@ -// Filename: geoMipTerrain.h -// Created by: rdb (29Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geoMipTerrain.h + * @author rdb + * @date 2007-06-29 + */ #ifndef GEOMIPTERRAIN_H #define GEOMIPTERRAIN_H @@ -26,17 +25,14 @@ #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : GeoMipTerrain -// Description : GeoMipTerrain, meaning Panda3D GeoMipMapping, can convert -// a heightfield image into a 3D terrain, consisting -// of several GeomNodes. It uses the GeoMipMapping -// algorithm, or Geometrical MipMapping, based on -// the LOD (Level of Detail) algorithm. For more -// information about the GeoMipMapping algoritm, see -// this paper, written by Willem H. de Boer: -// http://flipcode.com/articles/article_geomipmaps.pdf -//////////////////////////////////////////////////////////////////// +/** + * GeoMipTerrain, meaning Panda3D GeoMipMapping, can convert a heightfield + * image into a 3D terrain, consisting of several GeomNodes. It uses the + * GeoMipMapping algorithm, or Geometrical MipMapping, based on the LOD (Level + * of Detail) algorithm. For more information about the GeoMipMapping + * algoritm, see this paper, written by Willem H. de Boer: + * http://flipcode.com/articles/article_geomipmaps.pdf + */ class EXPCL_PANDA_GRUTIL GeoMipTerrain : public TypedObject { PUBLISHED: INLINE GeoMipTerrain(const string &name); @@ -76,10 +72,10 @@ PUBLISHED: INLINE void set_auto_flatten(int mode); - // The focal point is the point at which the terrain will have the - // highest quality (lowest level of detail). Parts farther away from - // the focal point will have a lower quality (higher level of detail). - // The focal point is not taken in respect if bruteforce is set true. + // The focal point is the point at which the terrain will have the highest + // quality (lowest level of detail). Parts farther away from the focal point + // will have a lower quality (higher level of detail). The focal point is + // not taken in respect if bruteforce is set true. INLINE void set_focal_point(const LPoint2d &fp); INLINE void set_focal_point(const LPoint2f &fp); INLINE void set_focal_point(const LPoint3d &fp); @@ -176,4 +172,3 @@ private: #include "geoMipTerrain.I" #endif /*GEOMIPTERRAIN_H*/ - diff --git a/panda/src/grutil/heightfieldTesselator.I b/panda/src/grutil/heightfieldTesselator.I index 3663f19000..dee41354a1 100644 --- a/panda/src/grutil/heightfieldTesselator.I +++ b/panda/src/grutil/heightfieldTesselator.I @@ -1,23 +1,19 @@ -// Filename: heightfieldTesselator.I -// Created by: jyelon (17jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file heightfieldTesselator.I + * @author jyelon + * @date 2006-07-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HeightfieldTesselator:: HeightfieldTesselator(const string &name) : Namable(name) { _poly_count = 10000; @@ -30,63 +26,48 @@ HeightfieldTesselator(const string &name) : Namable(name) { _radii_calculated = false; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE HeightfieldTesselator:: ~HeightfieldTesselator() { } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::heightfield -// Access: Published -// Description: Returns a reference to the heightfield (a PNMImage) -// contained inside the HeightfieldTesselator. You -// can use the reference to alter the heightfield. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the heightfield (a PNMImage) contained inside the + * HeightfieldTesselator. You can use the reference to alter the heightfield. + */ INLINE PNMImage &HeightfieldTesselator:: heightfield() { return _heightfield; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_heightfield -// Access: Published -// Description: Loads the specified greyscale image file into -// the heightfield. -//////////////////////////////////////////////////////////////////// +/** + * Loads the specified greyscale image file into the heightfield. + */ INLINE bool HeightfieldTesselator:: set_heightfield(const Filename &filename, PNMFileType *ftype) { _radii_calculated = false; return _heightfield.read(filename, ftype); } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_poly_count -// Access: Public -// Description: Sets the polygon-count target. The tesselator -// usually manages to come within about 20% of the -// target, plus or minus. -//////////////////////////////////////////////////////////////////// +/** + * Sets the polygon-count target. The tesselator usually manages to come + * within about 20% of the target, plus or minus. + */ INLINE void HeightfieldTesselator:: set_poly_count(int n) { _radii_calculated = false; _poly_count = n; -} +} -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_visibility_radius -// Access: Published -// Description: Sets the visibility radius. Polygons that -// are completely outside the radius (relative to -// the focal point) are cropped away. The cropping -// is imperfect (all approximations are conservative), -// so this should be used in conjunction with a far -// clipping plane, fog, or some other visibility -// limiting mechanism. The units are in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Sets the visibility radius. Polygons that are completely outside the + * radius (relative to the focal point) are cropped away. The cropping is + * imperfect (all approximations are conservative), so this should be used in + * conjunction with a far clipping plane, fog, or some other visibility + * limiting mechanism. The units are in pixels. + */ INLINE void HeightfieldTesselator:: set_visibility_radius(int radius) { _radii_calculated = false; @@ -95,68 +76,53 @@ set_visibility_radius(int radius) { _visibility_radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_focal_point -// Access: Published -// Description: Sets the focal point. The tesselator generates -// high-resolution terrain around the focal point, and -// progressively lower and lower resolution terrain -// as you get farther away. The units are in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Sets the focal point. The tesselator generates high-resolution terrain + * around the focal point, and progressively lower and lower resolution + * terrain as you get farther away. The units are in pixels. + */ INLINE void HeightfieldTesselator:: set_focal_point(int x, int y) { _focal_x = x; _focal_y = y; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_horizontal_scale -// Access: Published -// Description: Sets the horizontal scale. The default scale is 1.0, -// meaning that each pixel in the heightfield is -// 1x1 panda units wide. -//////////////////////////////////////////////////////////////////// +/** + * Sets the horizontal scale. The default scale is 1.0, meaning that each + * pixel in the heightfield is 1x1 panda units wide. + */ INLINE void HeightfieldTesselator:: set_horizontal_scale(double h) { _horizontal_scale = h; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_vertical_scale -// Access: Published -// Description: Sets the vertical scale. The default scale is 255.0, -// meaning that each as the gray value ranges from (0-1), -// the elevation ranges from (0-255) feet. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertical scale. The default scale is 255.0, meaning that each as + * the gray value ranges from (0-1), the elevation ranges from (0-255) feet. + */ INLINE void HeightfieldTesselator:: set_vertical_scale(double v) { _vertical_scale = v; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::set_max_triangles -// Access: Published -// Description: Sets the max triangles per geom. -//////////////////////////////////////////////////////////////////// +/** + * Sets the max triangles per geom. + */ INLINE void HeightfieldTesselator:: set_max_triangles(int n) { _max_triangles = n; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::subdivide -// Access: Private -// Description: Returns true if the given square should be subdivided. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given square should be subdivided. + */ INLINE bool HeightfieldTesselator:: subdivide(int scale, int x, int y) { if (scale == 0) { return false; } - // int size = 1<> 1; - // int xcenter = x+hsize; - // int ycenter = y+hsize; + // int size = 1<> 1; int xcenter = x+hsize; int + // ycenter = y+hsize; int deltax = x - _focal_x; int deltay = y - _focal_y; if (deltax < 0) deltax = -deltax; @@ -167,5 +133,3 @@ subdivide(int scale, int x, int y) { } return false; } - - diff --git a/panda/src/grutil/heightfieldTesselator.cxx b/panda/src/grutil/heightfieldTesselator.cxx index 4bc32174f0..8106071ed7 100644 --- a/panda/src/grutil/heightfieldTesselator.cxx +++ b/panda/src/grutil/heightfieldTesselator.cxx @@ -1,16 +1,15 @@ -// Filename: heightfieldTesselator.cxx -// Created by: jyelon (17jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file heightfieldTesselator.cxx + * @author jyelon + * @date 2006-07-17 + */ #include "heightfieldTesselator.h" #include "geomNode.h" @@ -18,18 +17,14 @@ #include "sceneGraphReducer.h" #include "lvector3.h" -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::fix_heightfield -// Access: Published -// Description: Makes sure that the heightfield is a grayscale -// image of valid dimensions. If necessary, adds a -// band of zeros onto two sides of the heightfield, -// so as to make the size of the heightfield a multiple -// of the given size plus one. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure that the heightfield is a grayscale image of valid dimensions. + * If necessary, adds a band of zeros onto two sides of the heightfield, so as + * to make the size of the heightfield a multiple of the given size plus one. + */ void HeightfieldTesselator:: fix_heightfield(int size) { - + // Calculate the padded size of the heightfield. int xsize = _heightfield.get_x_size(); int ysize = _heightfield.get_y_size(); @@ -48,7 +43,7 @@ fix_heightfield(int size) { // Pad the heightfield, and convert to grey. PNMImage unfixed(_heightfield); _heightfield.clear(xpadded, ypadded, 1, - unfixed.get_maxval(), + unfixed.get_maxval(), unfixed.get_type()); for (int y = 0; y < ysize; y++) { for (int x = 0; x < xsize; x++) { @@ -62,15 +57,11 @@ fix_heightfield(int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::get_elevation -// Access: Private -// Description: Fetches the elevation at (x,y), where the input -// coordinate is specified in pixels. This ignores the -// current tesselation level and instead provides an -// accurate number. Linear blending is used for -// non-integral coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Fetches the elevation at (x,y), where the input coordinate is specified in + * pixels. This ignores the current tesselation level and instead provides an + * accurate number. Linear blending is used for non-integral coordinates. + */ double HeightfieldTesselator:: get_elevation(double x, double y) { int scale = 7; @@ -97,12 +88,9 @@ get_elevation(double x, double y) { return lerpyh * yoffs + lerpyl * (1.0 - yoffs); } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::get_vertex -// Access: Private -// Description: Fetches the vertex at (x,y), or if the vertex -// does not exist, creates it. -//////////////////////////////////////////////////////////////////// +/** + * Fetches the vertex at (x,y), or if the vertex does not exist, creates it. + */ int HeightfieldTesselator:: get_vertex(int x, int y) { int xsize = _heightfield.get_x_size(); @@ -132,12 +120,10 @@ get_vertex(int x, int y) { } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::generate -// Access: Published -// Description: Generates a tree of nodes that represents the -// heightfield. This can be reparented into the scene. -//////////////////////////////////////////////////////////////////// +/** + * Generates a tree of nodes that represents the heightfield. This can be + * reparented into the scene. + */ NodePath HeightfieldTesselator:: generate() { int scale = 7; @@ -156,22 +142,22 @@ generate() { _vertex_index[y*xsize+x] = -1; } } - + if (!_radii_calculated) { int saved_focal_x = _focal_x; int saved_focal_y = _focal_y; _focal_x = _heightfield.get_x_size() >> 1; _focal_y = _heightfield.get_y_size() >> 1; - + calculate_radii(scale); - + _focal_x = saved_focal_x; _focal_y = saved_focal_y; - + _radii_calculated = true; } - + PT(PandaNode) result = new PandaNode(get_name()); NodePath root(result); @@ -196,13 +182,10 @@ generate() { return root; } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::calculate_radii -// Access: Private -// Description: Sets the radii appropriately to achieve the -// desired polygon count. This is achieved by binary -// search. -//////////////////////////////////////////////////////////////////// +/** + * Sets the radii appropriately to achieve the desired polygon count. This is + * achieved by binary search. + */ void HeightfieldTesselator:: calculate_radii(int scale) { int size = 1 << scale; @@ -210,7 +193,7 @@ calculate_radii(int scale) { int ysize = _heightfield.get_y_size(); int xcells = (xsize + size - 2) / size; int ycells = (ysize + size - 2) / size; - + double lo = 5.0; double hi = _heightfield.get_x_size() + _heightfield.get_y_size(); while (1) { @@ -239,36 +222,27 @@ calculate_radii(int scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::generate_square -// Access: Private -// Description: Adds a square region to the current geom. -// This relies on the following preconditions: -// -// 1. A square of scale N can be adjacent to -// a square of scale N or scale N-1, but not -// scale N-2 or smaller. -// -// 2. A square of scale N can be adjacent to -// at most one square of scale N-1. -// -// Precondition 1 is assured by spacing out the -// detail radii sufficiently. Precondition 2 is -// assured by using rectangular detail radii. -// -// I may someday rewrite this code to eliminate -// precondition 2, to allow circular detail radii. -//////////////////////////////////////////////////////////////////// +/** + * Adds a square region to the current geom. This relies on the following + * preconditions: + * + * 1. A square of scale N can be adjacent to a square of scale N or scale N-1, + * but not scale N-2 or smaller. + * + * 2. A square of scale N can be adjacent to at most one square of scale N-1. + * + * Precondition 1 is assured by spacing out the detail radii sufficiently. + * Precondition 2 is assured by using rectangular detail radii. + * + * I may someday rewrite this code to eliminate precondition 2, to allow + * circular detail radii. + */ void HeightfieldTesselator:: generate_square(NodePath root, int scale, int x, int y, bool forceclose) { - // There are nine possible vertices in the square, - // which are labeled as follows: - // - // G--H--I - // | | - // D E F - // | | - // A--B--C +/* + * There are nine possible vertices in the square, which are labeled as + * follows: G--H--I | | D E F | | A--B--C + */ int size = 1<>1; @@ -322,14 +296,10 @@ generate_square(NodePath root, int scale, int x, int y, bool forceclose) { } } -//////////////////////////////////////////////////////////////////// -// Function: HeightfieldTesselator::count_triangles -// Access: Private -// Description: Calculates how many triangles are inside -// the given region. The result is stored in -// the _poly_totals array, in the center of the -// square. -//////////////////////////////////////////////////////////////////// +/** + * Calculates how many triangles are inside the given region. The result is + * stored in the _poly_totals array, in the center of the square. + */ int HeightfieldTesselator:: count_triangles(int scale, int x, int y) { int size = 1<get_num_rows(); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::set_vertex -// Access: Public -// Description: Moves the nth point or vertex of the line segment -// sequence generated by the last call to create(). The -// first move_to() generates vertex 0; subsequent -// move_to() and draw_to() calls generate consecutively -// higher vertex numbers. -//////////////////////////////////////////////////////////////////// +/** + * Moves the nth point or vertex of the line segment sequence generated by the + * last call to create(). The first move_to() generates vertex 0; subsequent + * move_to() and draw_to() calls generate consecutively higher vertex numbers. + */ INLINE void LineSegs:: set_vertex(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_vertex(n, LVertex(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::set_vertex_color -// Access: Public -// Description: Changes the vertex color of the nth point or vertex. -// See set_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the vertex color of the nth point or vertex. See set_vertex(). + */ INLINE void LineSegs:: set_vertex_color(int n, PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_vertex_color(n, LColor(r, g, b, a)); diff --git a/panda/src/grutil/lineSegs.cxx b/panda/src/grutil/lineSegs.cxx index 5c09d8e79f..9bb54f40ab 100644 --- a/panda/src/grutil/lineSegs.cxx +++ b/panda/src/grutil/lineSegs.cxx @@ -1,16 +1,15 @@ -// Filename: lineSegs.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineSegs.cxx + * @author drose + * @date 2002-03-16 + */ #include "lineSegs.h" #include "renderState.h" @@ -22,17 +21,13 @@ #include "geomVertexWriter.h" #include "colorAttrib.h" -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::Constructor -// Access: Public -// Description: Constructs a LineSegs object, which can be used to -// create any number of disconnected lines or points of -// various thicknesses and colors through the visible -// scene. After creating the object, call move_to() and -// draw_to() repeatedly to describe the path, then call -// create() to create a GeomNode which will render the -// described path. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a LineSegs object, which can be used to create any number of + * disconnected lines or points of various thicknesses and colors through the + * visible scene. After creating the object, call move_to() and draw_to() + * repeatedly to describe the path, then call create() to create a GeomNode + * which will render the described path. + */ LineSegs:: LineSegs(const string &name) : Namable(name) { _color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -40,35 +35,28 @@ LineSegs(const string &name) : Namable(name) { } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::Destructor -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ LineSegs:: ~LineSegs() { } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::reset -// Access: Public -// Description: Removes any lines in progress and resets to the -// initial empty state. -//////////////////////////////////////////////////////////////////// +/** + * Removes any lines in progress and resets to the initial empty state. + */ void LineSegs:: reset() { _list.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::move_to -// Access: Public -// Description: Moves the pen to the given point without drawing a -// line. When followed by draw_to(), this marks the -// first point of a line segment; when followed by -// move_to() or create(), this creates a single point. -//////////////////////////////////////////////////////////////////// +/** + * Moves the pen to the given point without drawing a line. When followed by + * draw_to(), this marks the first point of a line segment; when followed by + * move_to() or create(), this creates a single point. + */ void LineSegs:: move_to(const LVecBase3 &v) { // We create a new SegmentList with the initial point in it. @@ -79,15 +67,11 @@ move_to(const LVecBase3 &v) { _list.push_back(segs); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::draw_to -// Access: Public -// Description: Draws a line segment from the pen's last position -// (the last call to move_to or draw_to) to the -// indicated point. move_to() and draw_to() only update -// tables; the actual drawing is performed when create() -// is called. -//////////////////////////////////////////////////////////////////// +/** + * Draws a line segment from the pen's last position (the last call to move_to + * or draw_to) to the indicated point. move_to() and draw_to() only update + * tables; the actual drawing is performed when create() is called. + */ void LineSegs:: draw_to(const LVecBase3 &v) { if (_list.empty()) { @@ -95,8 +79,8 @@ draw_to(const LVecBase3 &v) { move_to(v); } else { - // Get the current SegmentList, which was the last one we added to - // the LineList. + // Get the current SegmentList, which was the last one we added to the + // LineList. SegmentList &segs = _list.back(); // Add the new point. @@ -104,27 +88,21 @@ draw_to(const LVecBase3 &v) { } } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::empty -// Access: Public -// Description: Returns true if move_to() or draw_to() have not been -// called since the last reset() or create(), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if move_to() or draw_to() have not been called since the last + * reset() or create(), false otherwise. + */ bool LineSegs:: is_empty() { return _list.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::get_vertex -// Access: Public -// Description: Returns the nth point or vertex of the line segment -// sequence generated by the last call to create(). The -// first move_to() generates vertex 0; subsequent -// move_to() and draw_to() calls generate consecutively -// higher vertex numbers. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth point or vertex of the line segment sequence generated by + * the last call to create(). The first move_to() generates vertex 0; + * subsequent move_to() and draw_to() calls generate consecutively higher + * vertex numbers. + */ LVertex LineSegs:: get_vertex(int n) const { nassertr(_created_data != (GeomVertexData *)NULL, LVertex::zero()); @@ -133,15 +111,11 @@ get_vertex(int n) const { return vertex.get_data3(); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::set_vertex -// Access: Public -// Description: Moves the nth point or vertex of the line segment -// sequence generated by the last call to create(). The -// first move_to() generates vertex 0; subsequent -// move_to() and draw_to() calls generate consecutively -// higher vertex numbers. -//////////////////////////////////////////////////////////////////// +/** + * Moves the nth point or vertex of the line segment sequence generated by the + * last call to create(). The first move_to() generates vertex 0; subsequent + * move_to() and draw_to() calls generate consecutively higher vertex numbers. + */ void LineSegs:: set_vertex(int n, const LVertex &vert) { nassertv(_created_data != (GeomVertexData *)NULL); @@ -150,11 +124,9 @@ set_vertex(int n, const LVertex &vert) { vertex.set_data3(vert); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::get_vertex_color -// Access: Public -// Description: Returns the color of the nth point or vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of the nth point or vertex. + */ LColor LineSegs:: get_vertex_color(int n) const { nassertr(_created_data != (GeomVertexData *)NULL, LColor::zero()); @@ -163,12 +135,9 @@ get_vertex_color(int n) const { return color.get_data4(); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::set_vertex_color -// Access: Public -// Description: Changes the vertex color of the nth point or vertex. -// See set_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the vertex color of the nth point or vertex. See set_vertex(). + */ void LineSegs:: set_vertex_color(int n, const LColor &c) { nassertv(_created_data != (GeomVertexData *)NULL); @@ -177,12 +146,10 @@ set_vertex_color(int n, const LColor &c) { color.set_data4(c); } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::get_current_position -// Access: Public -// Description: Returns the pen's current position. The next call to -// draw_to() will draw a line segment from this point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pen's current position. The next call to draw_to() will draw a + * line segment from this point. + */ const LVertex &LineSegs:: get_current_position() { if (_list.empty()) { @@ -193,20 +160,15 @@ get_current_position() { return _list.back().back()._point; } -//////////////////////////////////////////////////////////////////// -// Function: LineSegs::create -// Access: Public -// Description: Appends to an existing GeomNode a new Geom that -// will render the series of line segments and points -// described via calls to move_to() and draw_to(). The -// lines and points are created with the color and -// thickness established by calls to set_color() and -// set_thick(). -// -// If dynamic is true, the line segments will be created -// with the dynamic Geom setting, optimizing them for -// runtime vertex animation. -//////////////////////////////////////////////////////////////////// +/** + * Appends to an existing GeomNode a new Geom that will render the series of + * line segments and points described via calls to move_to() and draw_to(). + * The lines and points are created with the color and thickness established + * by calls to set_color() and set_thick(). + * + * If dynamic is true, the line segments will be created with the dynamic Geom + * setting, optimizing them for runtime vertex animation. + */ GeomNode *LineSegs:: create(GeomNode *previous, bool dynamic) { if (!_list.empty()) { @@ -219,17 +181,17 @@ create(GeomNode *previous, bool dynamic) { dynamic ? Geom::UH_dynamic : Geom::UH_static); GeomVertexWriter vertex(_created_data, InternalName::get_vertex()); GeomVertexWriter color(_created_data, InternalName::get_color()); - + PT(GeomLinestrips) lines = new GeomLinestrips(Geom::UH_static); PT(GeomPoints) points = new GeomPoints(Geom::UH_static); - + int v = 0; LineList::const_iterator ll; SegmentList::const_iterator sl; - + for (ll = _list.begin(); ll != _list.end(); ll++) { const SegmentList &segs = (*ll); - + if (segs.size() < 2) { // A segment of length 1 is just a point. for (sl = segs.begin(); sl != segs.end(); sl++) { @@ -239,10 +201,9 @@ create(GeomNode *previous, bool dynamic) { v++; } points->close_primitive(); - + } else { - // A segment of length 2 or more is a line segment or - // segments. + // A segment of length 2 or more is a line segment or segments. for (sl = segs.begin(); sl != segs.end(); sl++) { lines->add_vertex(v); vertex.add_data3((*sl)._point); @@ -263,7 +224,7 @@ create(GeomNode *previous, bool dynamic) { geom->add_primitive(points); previous->add_geom(geom, state); } - + // And reset for next time. reset(); } diff --git a/panda/src/grutil/lineSegs.h b/panda/src/grutil/lineSegs.h index adc3d3cd35..c740b524ae 100644 --- a/panda/src/grutil/lineSegs.h +++ b/panda/src/grutil/lineSegs.h @@ -1,16 +1,15 @@ -// Filename: lineSegs.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineSegs.h + * @author drose + * @date 2002-03-16 + */ #ifndef LINESEGS_H #define LINESEGS_H @@ -25,14 +24,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : LineSegs -// Description : Encapsulates creation of a series of connected or -// disconnected line segments or points, for drawing -// paths or rays. This class doesn't attempt to be the -// smartest it could possibly be; it's intended -// primarily as a visualization and editing tool. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates creation of a series of connected or disconnected line + * segments or points, for drawing paths or rays. This class doesn't attempt + * to be the smartest it could possibly be; it's intended primarily as a + * visualization and editing tool. + */ class EXPCL_PANDA_GRUTIL LineSegs : public Namable { PUBLISHED: LineSegs(const string &name = "lines"); diff --git a/panda/src/grutil/meshDrawer.I b/panda/src/grutil/meshDrawer.I index e1aeace6e8..72a21bd504 100644 --- a/panda/src/grutil/meshDrawer.I +++ b/panda/src/grutil/meshDrawer.I @@ -1,24 +1,21 @@ -// Filename: meshDrawer.I -// Created by: treeform (19dec08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer.I + * @author treeform + * @date 2008-12-19 + */ #include "lpoint2.h" -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::Constructor -// Access: Published -// Description: Creates the MeshDrawer low level system. -//////////////////////////////////////////////////////////////////// +/** + * Creates the MeshDrawer low level system. + */ INLINE MeshDrawer:: MeshDrawer() { _root = NodePath("MeshDrawer"); @@ -32,11 +29,9 @@ MeshDrawer() { _vdata = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::Destructor -// Access: Published -// Description: Destroys the MeshDrawer low level system. -//////////////////////////////////////////////////////////////////// +/** + * Destroys the MeshDrawer low level system. + */ INLINE MeshDrawer:: ~MeshDrawer() { _root.remove_node(); @@ -46,47 +41,37 @@ INLINE MeshDrawer:: if (_color != NULL) delete _color; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::get_root -// Access: Published -// Description: Returns the root NodePath. You should use this node -// to reparent mesh drawer onto the scene -// might also want to disable depth draw or enable -// transparency. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root NodePath. You should use this node to reparent mesh + * drawer onto the scene might also want to disable depth draw or enable + * transparency. + */ INLINE NodePath MeshDrawer:: get_root() { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::set_budget -// Access: Published -// Description: Sets the total triangle budget of the drawer. -// This will not be exceeded. Don't set some thing too -// large because it will be slow -//////////////////////////////////////////////////////////////////// +/** + * Sets the total triangle budget of the drawer. This will not be exceeded. + * Don't set some thing too large because it will be slow + */ INLINE void MeshDrawer:: set_budget(int total_budget) { _budget = total_budget; generator(_budget); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::get_budget() -// Access: Published -// Description: Gets the total triangle budget of the drawer -//////////////////////////////////////////////////////////////////// +/** + * Gets the total triangle budget of the drawer + */ INLINE int MeshDrawer:: get_budget() { return _budget; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::tri -// Access: Published -// Description: Draws a triangle with the given parameters. -//////////////////////////////////////////////////////////////////// +/** + * Draws a triangle with the given parameters. + */ INLINE void MeshDrawer::tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1, const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2, const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3) { diff --git a/panda/src/grutil/meshDrawer.cxx b/panda/src/grutil/meshDrawer.cxx index 631a6a8e79..02b63e938a 100644 --- a/panda/src/grutil/meshDrawer.cxx +++ b/panda/src/grutil/meshDrawer.cxx @@ -1,16 +1,15 @@ -// Filename: meshDrawer.cxx -// Created by: treeform (19dec08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer.cxx + * @author treeform + * @date 2008-12-19 + */ #include "meshDrawer.h" @@ -37,11 +36,9 @@ PN_stdfloat randFloat() { return ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::generator -// Access: Private -// Description: Creates a system with a given budget. -//////////////////////////////////////////////////////////////////// +/** + * Creates a system with a given budget. + */ void MeshDrawer::generator(int budget) { // create enough triangles for budget: _vdata = new GeomVertexData(_root.get_name(), GeomVertexFormat::get_v3n3c4t2(), Geom::UH_static);//UH_dynamic); @@ -51,8 +48,8 @@ void MeshDrawer::generator(int budget) { GeomVertexWriter *tcolor = new GeomVertexWriter(_vdata, "color"); _prim = new GeomTriangles(Geom::UH_static); - // iterate and fill _up a geom with random data so that it will - // not be optimized out by panda3d system + // iterate and fill _up a geom with random data so that it will not be + // optimized out by panda3d system for(int i = 0; i < budget; i++) { for( int vert = 0; vert < 3; vert++) { LVector3 vec3 = LVector3(randFloat()+1000,randFloat(),randFloat())*.001; @@ -80,13 +77,10 @@ void MeshDrawer::generator(int budget) { delete tcolor; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::begin -// Access: Published -// Description: Pass the current camera node and the root node. -// Passing the camera is required to generate -// bill boards that face it. -//////////////////////////////////////////////////////////////////// +/** + * Pass the current camera node and the root node. Passing the camera is + * required to generate bill boards that face it. + */ void MeshDrawer::begin(NodePath camera, NodePath render) { // sanity check assert(render.get_error_type() == NodePath::ET_ok); @@ -128,12 +122,9 @@ void MeshDrawer::begin(NodePath camera, NodePath render) { } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::end -// Access: Published -// Description: Finish the drawing and clearing off the remaining -// vertexes. -//////////////////////////////////////////////////////////////////// +/** + * Finish the drawing and clearing off the remaining vertexes. + */ void MeshDrawer::end() { // clear the unused triangles at the end of the buffer @@ -153,14 +144,11 @@ void MeshDrawer::end() { } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::particle -// Access: Published -// Description: Draws a particle that is sort of like a bill board -// but has an extra rotation component. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// -void MeshDrawer::particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, +/** + * Draws a particle that is sort of like a bill board but has an extra + * rotation component. Frame contains u,v,u-size,v-size quadruple. + */ +void MeshDrawer::particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation) { rotation = rotation / 57.29578; @@ -185,14 +173,11 @@ void MeshDrawer::particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloa v1, color, LVector2(u,v)); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::blended_particle -// Access: Published -// Description: Works just like particle but accepts 2 frames and -// a blend (from 0 to 1) component between them -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// -void MeshDrawer::blended_particle(const LVector3 &pos, const LVector4 &frame1, +/** + * Works just like particle but accepts 2 frames and a blend (from 0 to 1) + * component between them Frame contains u,v,u-size,v-size quadruple. + */ +void MeshDrawer::blended_particle(const LVector3 &pos, const LVector4 &frame1, const LVector4 &frame2, PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation) { LVector4 c2 = color; @@ -204,14 +189,11 @@ void MeshDrawer::blended_particle(const LVector3 &pos, const LVector4 &frame1, } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::billboard -// Access: Published -// Description: Draws a billboard - particle with no rotation. -// Billboards always face the camera. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// -void MeshDrawer::billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, +/** + * Draws a billboard - particle with no rotation. Billboards always face the + * camera. Frame contains u,v,u-size,v-size quadruple. + */ +void MeshDrawer::billboard(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &_color) { LVector3 v1 = pos + _b1*size; @@ -223,7 +205,7 @@ void MeshDrawer::billboard(const LVector3 &pos, const LVector4 &frame, PN_stdflo PN_stdfloat v = frame.get_y(); PN_stdfloat us = frame.get_z(); PN_stdfloat vs = frame.get_w(); - + tri( v1, _color, LVector2(u,v), v2, _color, LVector2(u+us,v), @@ -235,31 +217,24 @@ void MeshDrawer::billboard(const LVector3 &pos, const LVector4 &frame, PN_stdflo } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::segment -// Access: Published -// Description: Draws a segment a line with a thickness. That has -// billboarding effect. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Draws a segment a line with a thickness. That has billboarding effect. + * Frame contains u,v,u-size,v-size quadruple. + */ void MeshDrawer::segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color) { link_segment(start, frame, thickness, color); link_segment(stop, frame, thickness, color); link_segment_end(frame, color); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::cross_segment -// Access: Published -// Description: Draws a segment a line with a thickness. This -// segment does not use the bill boarding behavior -// and instead draws 2 planes in a cross. -// Stars at start and ends at stop. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Draws a segment a line with a thickness. This segment does not use the + * bill boarding behavior and instead draws 2 planes in a cross. Stars at + * start and ends at stop. Frame contains u,v,u-size,v-size quadruple. + */ void MeshDrawer::cross_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color) { - + PN_stdfloat u = frame.get_x(); PN_stdfloat v = frame.get_y(); PN_stdfloat us = frame.get_z(); @@ -294,14 +269,11 @@ void MeshDrawer::cross_segment(const LVector3 &start, const LVector3 &stop, cons -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::uneven_segment -// Access: Published -// Description: Draws a segment a line with different thickness -// and color on both sides. -// Stars at start and ends at stop. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Draws a segment a line with different thickness and color on both sides. + * Stars at start and ends at stop. Frame contains u,v,u-size,v-size + * quadruple. + */ void MeshDrawer::uneven_segment(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat thickness_start, const LVector4 &color_start, PN_stdfloat thickness_stop, const LVector4 &color_stop) { @@ -310,24 +282,24 @@ void MeshDrawer::uneven_segment(const LVector3 &start, const LVector3 &stop, PN_stdfloat v = frame.get_y(); PN_stdfloat us = frame.get_z(); PN_stdfloat vs = frame.get_w(); - + LVector3 v1 = start - _up*thickness_start; LVector3 v2 = stop - _up*thickness_stop; LVector3 v3 = stop + _up*thickness_stop; LVector3 v4 = start + _up*thickness_start; - + tri(v1, color_start, LVector2(u,v), v2, color_stop, LVector2(u+us,v), v3, color_stop, LVector2(u+us,v+vs)); tri(v3, color_stop, LVector2(u+us,v+vs), v4, color_start, LVector2(u,v+vs), v1, color_start, LVector2(u,v)); - + v1 = start - _right*thickness_start; v2 = stop - _right*thickness_stop; v3 = stop + _right*thickness_stop; v4 = start + _right*thickness_start; - + tri(v1, color_start, LVector2(u,v), v2, color_stop, LVector2(u+us,v), v3, color_stop, LVector2(u+us,v+vs)); @@ -336,12 +308,10 @@ void MeshDrawer::uneven_segment(const LVector3 &start, const LVector3 &stop, v1, color_start, LVector2(u,v)); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::explosion -// Access: Published -// Description: Draws number of particles in a sphere like emitter. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Draws number of particles in a sphere like emitter. Frame contains + * u,v,u-size,v-size quadruple. + */ void MeshDrawer::explosion( const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &_color, int seed, int number, PN_stdfloat distance) { @@ -355,13 +325,10 @@ void MeshDrawer::explosion( } } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::stream -// Access: Published -// Description: Draws a number of particles in a big line with a -// shift dictated by the offset. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Draws a number of particles in a big line with a shift dictated by the + * offset. Frame contains u,v,u-size,v-size quadruple. + */ void MeshDrawer::stream(const LVector3 &start, const LVector3 &stop, const LVector4 &frame, PN_stdfloat size, const LVector4 &_color, int number, PN_stdfloat offset) { @@ -378,16 +345,12 @@ void MeshDrawer::stream(const LVector3 &start, const LVector3 &stop, const LVect -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::geometry -// Access: Published -// Description: Draws the geometry that is inside this node path into -// the MeshDrawer object. This performs a similar -// functions as RigidBodyCombiner but for very -// dynamic situations that share the same texture -// like physcal chunks of explosions. -// It can be a little slow -//////////////////////////////////////////////////////////////////// +/** + * Draws the geometry that is inside this node path into the MeshDrawer + * object. This performs a similar functions as RigidBodyCombiner but for + * very dynamic situations that share the same texture like physcal chunks of + * explosions. It can be a little slow + */ void MeshDrawer::geometry(NodePath draw_node) { assert(_render.get_error_type() == NodePath::ET_ok); @@ -446,14 +409,10 @@ void MeshDrawer::geometry(NodePath draw_node) { -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::link_segment -// Access: Published -// Description: Stars or continues linked segment. -// Control position, frame, thickness and color with -// parameters. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Stars or continues linked segment. Control position, frame, thickness and + * color with parameters. Frame contains u,v,u-size,v-size quadruple. + */ void MeshDrawer:: link_segment(const LVector3 &pos, const LVector4 &frame, PN_stdfloat thickness, const LVector4 &color) { @@ -506,9 +465,8 @@ link_segment(const LVector3 &pos, const LVector4 &frame, LVector3 now_v2 = stop + _b2*(PN_stdfloat)(thickness*sin(rotation)) + _b3*(PN_stdfloat)(thickness*cos(rotation)); LVector3 now_v3 = stop + _b3*(PN_stdfloat)(thickness*sin(rotation)) + _b4*(PN_stdfloat)(thickness*cos(rotation)); - // mark the segment we going to draw - // we need to draw it when we know what the next segment looks like - // because it can bend it a little + // mark the segment we going to draw we need to draw it when we know what + // the next segment looks like because it can bend it a little if(_at_start==1) { _last_v1 = now_v1; _last_v2 = now_v2; @@ -549,14 +507,11 @@ link_segment(const LVector3 &pos, const LVector4 &frame, _last_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer::link_segment_end -// Access: Published -// Description: Finish drawing linked segments, needs at least -// two calls to link_segment before it can end -// the linked segment. -// Frame contains u,v,u-size,v-size quadruple. -//////////////////////////////////////////////////////////////////// +/** + * Finish drawing linked segments, needs at least two calls to link_segment + * before it can end the linked segment. Frame contains u,v,u-size,v-size + * quadruple. + */ void MeshDrawer::link_segment_end(const LVector4 &frame, const LVector4 &color) { PN_stdfloat u = frame.get_x(); diff --git a/panda/src/grutil/meshDrawer.h b/panda/src/grutil/meshDrawer.h index 8d87e4e795..1b391210f6 100644 --- a/panda/src/grutil/meshDrawer.h +++ b/panda/src/grutil/meshDrawer.h @@ -1,17 +1,17 @@ -// Filename: meshDrawer.h -// Created by: treeform (19dec08) -// Changes by: treeform (12jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer.h + * @author treeform + * @date 2008-12-19 + * @author treeform + * @date 2010-01-12 + */ #ifndef MESHDRAWER_H #define MESHDRAWER_H @@ -40,21 +40,17 @@ #include "geomNode.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : MeshDrawer -// Description : Mesh drawer creates a single geom object that can be -// shaped with different draw commands. This is an -// efficient way to render bunch of billboards, particles, -// fast changing triangles. Its implemented by recycling -// same geom over and over again. Max budget specifies -// how many triangles are allowed. Some uses of this -// class can be : particle system, radar icons, health -// bars, 2d icons, 2d ui, bullets, missile trails. Any -// that can be drawn with triangles can be drawn with -// this class. At the low level this uses the -// GeomVertexRewriter's. The internal geom consists of -// vertex, normal, uv and color channels. -//////////////////////////////////////////////////////////////////// +/** + * Mesh drawer creates a single geom object that can be shaped with different + * draw commands. This is an efficient way to render bunch of billboards, + * particles, fast changing triangles. Its implemented by recycling same geom + * over and over again. Max budget specifies how many triangles are allowed. + * Some uses of this class can be : particle system, radar icons, health bars, + * 2d icons, 2d ui, bullets, missile trails. Any that can be drawn with + * triangles can be drawn with this class. At the low level this uses the + * GeomVertexRewriter's. The internal geom consists of vertex, normal, uv and + * color channels. + */ class EXPCL_PANDA_GRUTIL MeshDrawer : public TypedObject { PUBLISHED: INLINE MeshDrawer(); @@ -69,7 +65,7 @@ PUBLISHED: INLINE void tri(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1, const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2, const LVector3 &v3, const LVector4 &c3, const LVector2 &uv3); - + void particle(const LVector3 &pos, const LVector4 &frame, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation); void blended_particle(const LVector3 &pos, const LVector4 &frame1, const LVector4 &frame2, PN_stdfloat blend, PN_stdfloat size, const LVector4 &color, PN_stdfloat rotation); diff --git a/panda/src/grutil/meshDrawer2D.I b/panda/src/grutil/meshDrawer2D.I index 742d87a2a1..9846eda7ee 100644 --- a/panda/src/grutil/meshDrawer2D.I +++ b/panda/src/grutil/meshDrawer2D.I @@ -1,24 +1,21 @@ -// Filename: meshDrawer2D.I -// Created by: treeform (19dec08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer2D.I + * @author treeform + * @date 2008-12-19 + */ #include "lpoint2.h" -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::Constructor -// Access: Published -// Description: Creates the MeshDrawer2D low level system. -//////////////////////////////////////////////////////////////////// +/** + * Creates the MeshDrawer2D low level system. + */ INLINE MeshDrawer2D:: MeshDrawer2D() { _root = NodePath("MeshDrawer"); @@ -34,11 +31,9 @@ MeshDrawer2D() { _clip_h = 1000000; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::Destructor -// Access: Published -// Description: Destroys the MeshDrawer2D low level system. -//////////////////////////////////////////////////////////////////// +/** + * Destroys the MeshDrawer2D low level system. + */ INLINE MeshDrawer2D:: ~MeshDrawer2D() { _root.remove_node(); @@ -47,42 +42,34 @@ INLINE MeshDrawer2D:: if (_color != NULL) delete _color; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::get_root -// Access: Published -// Description: Returns the root NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root NodePath. + */ INLINE NodePath MeshDrawer2D:: get_root() { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::set_budget -// Access: Published -// Description: Sets the total triangle budget of the drawer. -//////////////////////////////////////////////////////////////////// +/** + * Sets the total triangle budget of the drawer. + */ INLINE void MeshDrawer2D:: set_budget(int total_budget) { _budget = total_budget; generator(_budget); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::get_budget() -// Access: Published -// Description: Gets the total triangle budget of the drawer -//////////////////////////////////////////////////////////////////// +/** + * Gets the total triangle budget of the drawer + */ INLINE int MeshDrawer2D:: get_budget() { return _budget; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::set_budget -// Access: Published -// Description: Sets clipping rectangle -//////////////////////////////////////////////////////////////////// +/** + * Sets clipping rectangle + */ INLINE void MeshDrawer2D:: set_clip(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h) { _clip_x = x; @@ -91,12 +78,9 @@ set_clip(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h) { _clip_h = h; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::quad -// Access: Published -// Description: Draws a 2d rectangle. -// Ignores the cliping rectangle -//////////////////////////////////////////////////////////////////// +/** + * Draws a 2d rectangle. Ignores the cliping rectangle + */ INLINE void MeshDrawer2D:: quad_raw(const LVector3 &v1, const LVector4 &c1, const LVector2 &uv1, const LVector3 &v2, const LVector4 &c2, const LVector2 &uv2, @@ -140,11 +124,9 @@ rectangle_raw(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, ); } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::quad -// Access: Published -// Description: Draws a 2d rectangle, that can be cliped -//////////////////////////////////////////////////////////////////// +/** + * Draws a 2d rectangle, that can be cliped + */ INLINE void MeshDrawer2D:: rectangle(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, @@ -199,4 +181,3 @@ rectangle(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, rectangle_raw(x,y,w,h,u,v,us,vs,color); } - diff --git a/panda/src/grutil/meshDrawer2D.cxx b/panda/src/grutil/meshDrawer2D.cxx index d6058f962e..fbf99a2778 100644 --- a/panda/src/grutil/meshDrawer2D.cxx +++ b/panda/src/grutil/meshDrawer2D.cxx @@ -1,16 +1,15 @@ -// Filename: meshDrawer2D.cxx -// Created by: treeform (19dec08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer2D.cxx + * @author treeform + * @date 2008-12-19 + */ #include "meshDrawer2D.h" @@ -37,11 +36,9 @@ TypeHandle MeshDrawer2D::_type_handle; #define RANDF ((PN_stdfloat) rand() / (PN_stdfloat) 0x7fffffff) -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::generator -// Access: Private -// Description: Creates a system with a given budget. -//////////////////////////////////////////////////////////////////// +/** + * Creates a system with a given budget. + */ void MeshDrawer2D::generator(int budget) { // create enough triangles for budget: _vdata = new GeomVertexData(_root.get_name(), GeomVertexFormat::get_v3c4t2(), Geom::UH_static);//UH_dynamic); @@ -50,8 +47,8 @@ void MeshDrawer2D::generator(int budget) { GeomVertexWriter *tcolor = new GeomVertexWriter(_vdata, "color"); _prim = new GeomTriangles(Geom::UH_static); - // iterate and fill _up a geom with random data so that it will - // not be optimized out by panda3d system + // iterate and fill _up a geom with random data so that it will not be + // optimized out by panda3d system for(int i = 0; i < budget; i++) { for( int vert = 0; vert < 4; vert++) { @@ -85,12 +82,9 @@ void MeshDrawer2D::generator(int budget) { delete tcolor; } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::begin -// Access: Published -// Description: Opens up the geom for drawing, don't forget to call -// MeshDrawer2D::end() -//////////////////////////////////////////////////////////////////// +/** + * Opens up the geom for drawing, don't forget to call MeshDrawer2D::end() + */ void MeshDrawer2D::begin() { // recreate our rewriters @@ -110,12 +104,9 @@ void MeshDrawer2D::begin() { } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::end -// Access: Published -// Description: Finish the drawing and clearing off the remaining -// vertexes. -//////////////////////////////////////////////////////////////////// +/** + * Finish the drawing and clearing off the remaining vertexes. + */ void MeshDrawer2D::end() { // clear the unused triangles at the end of the buffer @@ -137,12 +128,9 @@ void MeshDrawer2D::end() { -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::quad -// Access: Published -// Description: Draws a tiled rectangle, size of tiles is in -// us and vs -//////////////////////////////////////////////////////////////////// +/** + * Draws a tiled rectangle, size of tiles is in us and vs + */ void MeshDrawer2D:: rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, PN_stdfloat u, PN_stdfloat v, PN_stdfloat us, PN_stdfloat vs, @@ -190,12 +178,10 @@ rectangle_tiled(PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::quad -// Access: Published -// Description: Draws a 2d rectangle, with borders and corders, -// taken from the surrounding texture -//////////////////////////////////////////////////////////////////// +/** + * Draws a 2d rectangle, with borders and corders, taken from the surrounding + * texture + */ void MeshDrawer2D:: rectangle_border( PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, @@ -206,7 +192,7 @@ rectangle_border( rectangle(x,y,w,h,u,v,us,vs,color); // center - // -------------- ----------------- ------ + // -------------- ----------------- ------ rectangle(x, y+h, w, t, u, v+vs, us, tt, color); // N rectangle(x, y-b, w, b, u, v-tb, us, tb, color); // S @@ -222,12 +208,10 @@ rectangle_border( */ } -//////////////////////////////////////////////////////////////////// -// Function: MeshDrawer2D::quad -// Access: Published -// Description: Draws a 2d rectangle, with borders and corders, -// taken from the surrounding texture -//////////////////////////////////////////////////////////////////// +/** + * Draws a 2d rectangle, with borders and corders, taken from the surrounding + * texture + */ void MeshDrawer2D:: rectangle_border_tiled( PN_stdfloat x, PN_stdfloat y, PN_stdfloat w, PN_stdfloat h, diff --git a/panda/src/grutil/meshDrawer2D.h b/panda/src/grutil/meshDrawer2D.h index 5fd6350d3c..6b686b8b10 100644 --- a/panda/src/grutil/meshDrawer2D.h +++ b/panda/src/grutil/meshDrawer2D.h @@ -1,16 +1,15 @@ -// Filename: meshDrawer2D.h -// Created by: treeform (6Jan10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file meshDrawer2D.h + * @author treeform + * @date 2010-01-06 + */ #ifndef MESHDRAWER2D_H #define MESHDRAWER2D_H @@ -39,13 +38,10 @@ #include "geomNode.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : MeshDrawer2D -// Description : This class allows the drawing of 2d objects - -// mainly based on quads and rectangles. -// Allows clipping and serverl high level UI theme -// functions. -//////////////////////////////////////////////////////////////////// +/** + * This class allows the drawing of 2d objects - mainly based on quads and + * rectangles. Allows clipping and serverl high level UI theme functions. + */ class EXPCL_PANDA_GRUTIL MeshDrawer2D : public TypedObject { PUBLISHED: INLINE MeshDrawer2D(); diff --git a/panda/src/grutil/movieTexture.I b/panda/src/grutil/movieTexture.I index 023e63d325..d52220695e 100644 --- a/panda/src/grutil/movieTexture.I +++ b/panda/src/grutil/movieTexture.I @@ -1,64 +1,51 @@ -// Filename: movieTexture.I -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTexture.I + * @author jyelon + * @date 2007-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_video_length -// Access: Published -// Description: Returns the length of the video. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the video. + */ INLINE double MovieTexture:: get_video_length() const { CDReader cdata(_cycler); return cdata->_video_length; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_video_width -// Access: Published -// Description: Returns the width in texels of the source video -// stream. This is not necessarily the width of the -// actual texture, since the texture may have been -// expanded to raise it to a power of 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width in texels of the source video stream. This is not + * necessarily the width of the actual texture, since the texture may have + * been expanded to raise it to a power of 2. + */ INLINE int MovieTexture:: get_video_width() const { CDReader cdata(_cycler); return cdata->_video_width; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_video_height -// Access: Published -// Description: Returns the height in texels of the source video -// stream. This is not necessarily the height of the -// actual texture, since the texture may have been -// expanded to raise it to a power of 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height in texels of the source video stream. This is not + * necessarily the height of the actual texture, since the texture may have + * been expanded to raise it to a power of 2. + */ INLINE int MovieTexture:: get_video_height() const { CDReader cdata(_cycler); return cdata->_video_height; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_color_cursor -// Access: Published -// Description: Returns the MovieVideoCursor that is feeding the -// color channels for the indicated page, where 0 <= -// page < get_num_pages(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the MovieVideoCursor that is feeding the color channels for the + * indicated page, where 0 <= page < get_num_pages(). + */ INLINE MovieVideoCursor *MovieTexture:: get_color_cursor(int page) { CDReader cdata(_cycler); @@ -66,17 +53,13 @@ get_color_cursor(int page) { return cdata->_pages[page]._color; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_alpha_cursor -// Access: Published -// Description: Returns the MovieVideoCursor that is feeding the -// alpha channel for the indicated page, where 0 <= -// page < get_num_pages(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the MovieVideoCursor that is feeding the alpha channel for the + * indicated page, where 0 <= page < get_num_pages(). + */ INLINE MovieVideoCursor *MovieTexture:: get_alpha_cursor(int page) { CDReader cdata(_cycler); nassertr(page >= 0 && page < (int)cdata->_pages.size(), NULL); return cdata->_pages[page]._alpha; } - diff --git a/panda/src/grutil/movieTexture.cxx b/panda/src/grutil/movieTexture.cxx index edfbe59065..aac04d4b0b 100644 --- a/panda/src/grutil/movieTexture.cxx +++ b/panda/src/grutil/movieTexture.cxx @@ -1,16 +1,15 @@ -// Filename: movieTexture.cxx -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTexture.cxx + * @author jyelon + * @date 2007-08-01 + */ #include "pandabase.h" @@ -31,23 +30,19 @@ TypeHandle MovieTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::Constructor -// Access: Published -// Description: Creates a blank movie texture. Movies must be -// added using do_read_one or do_load_one. -//////////////////////////////////////////////////////////////////// +/** + * Creates a blank movie texture. Movies must be added using do_read_one or + * do_load_one. + */ MovieTexture:: MovieTexture(const string &name) : Texture(name) { } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::Constructor -// Access: Published -// Description: Creates a texture playing the specified movie. -//////////////////////////////////////////////////////////////////// +/** + * Creates a texture playing the specified movie. + */ MovieTexture:: MovieTexture(MovieVideo *video) : Texture(video->get_name()) @@ -56,11 +51,9 @@ MovieTexture(MovieVideo *video) : do_load_one(cdata_tex, video->open(), NULL, 0, LoaderOptions()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::CData::Constructor -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ MovieTexture::CData:: CData() : _video_width(1), @@ -74,11 +67,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::CData::Copy Constructor -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ MovieTexture::CData:: CData(const CData ©) : _pages(copy._pages), @@ -93,22 +84,18 @@ CData(const CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::CData::make_copy -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ CycleData *MovieTexture::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::Copy Constructor -// Access: Protected -// Description: Use MovieTexture::make_copy() to make a duplicate copy of -// an existing MovieTexture. -//////////////////////////////////////////////////////////////////// +/** + * Use MovieTexture::make_copy() to make a duplicate copy of an existing + * MovieTexture. + */ MovieTexture:: MovieTexture(const MovieTexture ©) : Texture(copy) @@ -116,62 +103,51 @@ MovieTexture(const MovieTexture ©) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::Destructor -// Access: Published, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ MovieTexture:: ~MovieTexture() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::ensure_loader_type -// Access: Public, Virtual -// Description: May be called prior to calling read_txo() or any -// bam-related Texture-creating callback, to ensure that -// the proper dynamic libraries for a Texture of the -// current class type, and the indicated filename, have -// been already loaded. -// -// This is a low-level function that should not normally -// need to be called directly by the user. -// -// Note that for best results you must first create a -// Texture object of the appropriate class type for your -// filename, for instance with -// TexturePool::make_texture(). -//////////////////////////////////////////////////////////////////// +/** + * May be called prior to calling read_txo() or any bam-related Texture- + * creating callback, to ensure that the proper dynamic libraries for a + * Texture of the current class type, and the indicated filename, have been + * already loaded. + * + * This is a low-level function that should not normally need to be called + * directly by the user. + * + * Note that for best results you must first create a Texture object of the + * appropriate class type for your filename, for instance with + * TexturePool::make_texture(). + */ void MovieTexture:: ensure_loader_type(const Filename &filename) { - // Creating a MovieVideo of the appropriate type is a slightly hacky - // way to ensure the appropriate libraries are loaded. We can let - // the MovieVideo we create immediately destruct. + // Creating a MovieVideo of the appropriate type is a slightly hacky way to + // ensure the appropriate libraries are loaded. We can let the MovieVideo + // we create immediately destruct. MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr(); PT(MovieVideo) video = reg->make_video(filename); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::make_texture -// Access: Public, Static -// Description: A factory function to make a new MovieTexture, used -// to pass to the TexturePool. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new MovieTexture, used to pass to the + * TexturePool. + */ PT(Texture) MovieTexture:: make_texture() { return new MovieTexture(""); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_recalculate_image_properties -// Access: Protected -// Description: Resizes the texture, and adjusts the format, -// based on the source movies. The resulting texture -// will be large enough to hold all the videos. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Resizes the texture, and adjusts the format, based on the source movies. + * The resulting texture will be large enough to hold all the videos. + * + * Assumes the lock is already held. + */ void MovieTexture:: do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const LoaderOptions &options) { int x_max = 1; @@ -214,13 +190,10 @@ do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const L 0); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_adjust_this_size -// Access: Protected, Virtual -// Description: Works like adjust_size, but also considers the -// texture class. Movie textures, for instance, always -// pad outwards, never scale down. -//////////////////////////////////////////////////////////////////// +/** + * Works like adjust_size, but also considers the texture class. Movie + * textures, for instance, always pad outwards, never scale down. + */ bool MovieTexture:: do_adjust_this_size(const Texture::CData *cdata_tex, int &x_size, int &y_size, const string &name, @@ -233,13 +206,10 @@ do_adjust_this_size(const Texture::CData *cdata_tex, return adjust_size(x_size, y_size, name, for_padding, ats); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_read_one -// Access: Protected, Virtual -// Description: Combines a color and alpha video image from the two -// indicated filenames. Both must be the same kind of -// video with similar properties. -//////////////////////////////////////////////////////////////////// +/** + * Combines a color and alpha video image from the two indicated filenames. + * Both must be the same kind of video with similar properties. + */ bool MovieTexture:: do_read_one(Texture::CData *cdata_tex, const Filename &fullpath, const Filename &alpha_fullpath, @@ -297,11 +267,9 @@ do_read_one(Texture::CData *cdata_tex, return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_load_one -// Access: Protected, Virtual -// Description: Loads movie objects into the texture. -//////////////////////////////////////////////////////////////////// +/** + * Loads movie objects into the texture. + */ bool MovieTexture:: do_load_one(Texture::CData *cdata_tex, PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, int z, @@ -312,20 +280,17 @@ do_load_one(Texture::CData *cdata_tex, cdata->_pages[z]._alpha = alpha; do_recalculate_image_properties(cdata, cdata_tex, options); - // Make sure the image data is initially black, which is nice for - // padded textures. + // Make sure the image data is initially black, which is nice for padded + // textures. PTA_uchar image = make_ram_image(); memset(image.p(), 0, image.size()); return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_load_one -// Access: Protected, Virtual -// Description: Loading a static image into a MovieTexture is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * Loading a static image into a MovieTexture is an error. + */ bool MovieTexture:: do_load_one(Texture::CData *cdata_tex, const PNMImage &pnmimage, const string &name, int z, int n, @@ -334,52 +299,42 @@ do_load_one(Texture::CData *cdata_tex, return false; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_allocate_pages -// Access: Protected, Virtual -// Description: Called internally by do_reconsider_z_size() to -// allocate new memory in _ram_images[0] for the new -// number of pages. -// -// Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Called internally by do_reconsider_z_size() to allocate new memory in + * _ram_images[0] for the new number of pages. + * + * Assumes the lock is already held. + */ void MovieTexture:: do_allocate_pages(Texture::CData *cdata_tex) { // We don't actually do anything here; the allocation is made in // do_load_one(), above. } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + */ bool MovieTexture:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to update the MovieTexture. This update -// consists of fetching the next video frame from the -// underlying MovieVideo sources. The MovieVideo -// object belongs to the cull thread. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to update the + * MovieTexture. This update consists of fetching the next video frame from + * the underlying MovieVideo sources. The MovieVideo object belongs to the + * cull thread. + */ bool MovieTexture:: cull_callback(CullTraverser *, const CullTraverserData &) const { Texture::CDReader cdata_tex(Texture::_cycler); CDReader cdata(_cycler); if (!cdata->_has_offset) { - // If we don't have a previously-computed timestamp (offset) - // cached, then compute a new one. + // If we don't have a previously-computed timestamp (offset) cached, then + // compute a new one. double offset; int true_loop_count = 1; if (cdata->_synchronize != 0) { @@ -400,8 +355,8 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { bool in_sync = do_update_frames(cdata); if (!in_sync) { - // If it didn't successfully sync, try again--once. The second - // time it might be able to fill in some more recent frames. + // If it didn't successfully sync, try again--once. The second time it + // might be able to fill in some more recent frames. in_sync = do_update_frames(cdata); } @@ -433,19 +388,15 @@ cull_callback(CullTraverser *, const CullTraverserData &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::make_copy_impl -// Access: Protected, Virtual -// Description: Returns a new copy of the same Texture. This copy, -// if applied to geometry, will be copied into texture -// as a separate texture from the original, so it will -// be duplicated in texture memory (and may be -// independently modified if desired). -// -// If the Texture is a MovieTexture, the resulting -// duplicate may be animated independently of the -// original. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new copy of the same Texture. This copy, if applied to geometry, + * will be copied into texture as a separate texture from the original, so it + * will be duplicated in texture memory (and may be independently modified if + * desired). + * + * If the Texture is a MovieTexture, the resulting duplicate may be animated + * independently of the original. + */ PT(Texture) MovieTexture:: make_copy_impl() { Texture::CDReader cdata_tex(Texture::_cycler); @@ -458,11 +409,9 @@ make_copy_impl() { return copy.p(); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_assign -// Access: Protected -// Description: Implements make_copy(). -//////////////////////////////////////////////////////////////////// +/** + * Implements make_copy(). + */ void MovieTexture:: do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, const CData *cdata_copy, const Texture::CData *cdata_copy_tex) { @@ -489,77 +438,58 @@ do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, do_recalculate_image_properties(cdata, cdata_tex, LoaderOptions()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::reload_ram_image -// Access: Protected, Virtual -// Description: A MovieTexture must always keep its ram image, -// since there is no way to reload it from the -// source MovieVideo. -//////////////////////////////////////////////////////////////////// +/** + * A MovieTexture must always keep its ram image, since there is no way to + * reload it from the source MovieVideo. + */ void MovieTexture:: do_reload_ram_image(Texture::CData *cdata, bool allow_compression) { - // A MovieTexture should never dump its RAM image. - // Therefore, this is not needed. + // A MovieTexture should never dump its RAM image. Therefore, this is not + // needed. } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_keep_ram_image -// Access: Published, Virtual -// Description: A MovieTexture must always keep its ram image, -// since there is no way to reload it from the -// source MovieVideo. -//////////////////////////////////////////////////////////////////// +/** + * A MovieTexture must always keep its ram image, since there is no way to + * reload it from the source MovieVideo. + */ bool MovieTexture:: get_keep_ram_image() const { // A MovieTexture should never dump its RAM image. return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_has_bam_rawdata -// Access: Protected, Virtual -// Description: Returns true if there is a rawdata image that we have -// available to write to the bam stream. For a normal -// Texture, this is the same thing as -// do_has_ram_image(), but a movie texture might define -// it differently. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a rawdata image that we have available to write to + * the bam stream. For a normal Texture, this is the same thing as + * do_has_ram_image(), but a movie texture might define it differently. + */ bool MovieTexture:: do_has_bam_rawdata(const Texture::CData *cdata) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_get_bam_rawdata -// Access: Protected, Virtual -// Description: If do_has_bam_rawdata() returned false, this attempts -// to reload the rawdata image if possible. -//////////////////////////////////////////////////////////////////// +/** + * If do_has_bam_rawdata() returned false, this attempts to reload the rawdata + * image if possible. + */ void MovieTexture:: do_get_bam_rawdata(Texture::CData *cdata) { } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_can_reload -// Access: Protected, Virtual -// Description: Returns true if we can safely call -// do_unlock_and_reload_ram_image() in order to make the -// image available, or false if we shouldn't do this -// (because we know from a priori knowledge that it -// wouldn't work anyway). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we can safely call do_unlock_and_reload_ram_image() in + * order to make the image available, or false if we shouldn't do this + * (because we know from a priori knowledge that it wouldn't work anyway). + */ bool MovieTexture:: do_can_reload(const Texture::CData *cdata) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::restart -// Access: Published -// Description: Start playing the movie from where it was last -// paused. Has no effect if the movie is not paused, -// or if the movie's cursor is already at the end. -//////////////////////////////////////////////////////////////////// +/** + * Start playing the movie from where it was last paused. Has no effect if + * the movie is not paused, or if the movie's cursor is already at the end. + */ void MovieTexture:: restart() { CDWriter cdata(_cycler); @@ -570,13 +500,10 @@ restart() { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::stop -// Access: Published -// Description: Stops a currently playing or looping movie right -// where it is. The movie's cursor remains frozen at -// the point where it was stopped. -//////////////////////////////////////////////////////////////////// +/** + * Stops a currently playing or looping movie right where it is. The movie's + * cursor remains frozen at the point where it was stopped. + */ void MovieTexture:: stop() { CDWriter cdata(_cycler); @@ -587,11 +514,9 @@ stop() { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::play -// Access: Published -// Description: Plays the movie from the beginning. -//////////////////////////////////////////////////////////////////// +/** + * Plays the movie from the beginning. + */ void MovieTexture:: play() { CDWriter cdata(_cycler); @@ -600,11 +525,9 @@ play() { cdata->_playing = true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::set_time -// Access: Published -// Description: Sets the movie's cursor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the movie's cursor. + */ void MovieTexture:: set_time(double t) { CDWriter cdata(_cycler); @@ -617,16 +540,12 @@ set_time(double t) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_time -// Access: Published -// Description: Returns the current value of the movie's cursor. -// If the movie's loop count is greater than one, then -// its length is effectively multiplied for the -// purposes of this function. In other words, -// the return value will be in the range 0.0 -// to (length * loopcount). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current value of the movie's cursor. If the movie's loop count + * is greater than one, then its length is effectively multiplied for the + * purposes of this function. In other words, the return value will be in the + * range 0.0 to (length * loopcount). + */ double MovieTexture:: get_time() const { CDReader cdata(_cycler); @@ -638,58 +557,47 @@ get_time() const { return clock; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::set_loop -// Access: Published -// Description: If true, sets the movie's loop count to 1 billion. -// If false, sets the movie's loop count to one. -//////////////////////////////////////////////////////////////////// +/** + * If true, sets the movie's loop count to 1 billion. If false, sets the + * movie's loop count to one. + */ void MovieTexture:: set_loop(bool loop) { set_loop_count(loop ? 0:1); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_loop -// Access: Published -// Description: Returns true if the movie's loop count is not equal -// to one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the movie's loop count is not equal to one. + */ bool MovieTexture:: get_loop() const { CDReader cdata(_cycler); return (cdata->_loop_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::set_loop_count -// Access: Published -// Description: Sets the movie's loop count to the desired value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the movie's loop count to the desired value. + */ void MovieTexture:: set_loop_count(int n) { CDWriter cdata(_cycler); cdata->_loop_count = n; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_loop_count -// Access: Published -// Description: Returns the movie's loop count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the movie's loop count. + */ int MovieTexture:: get_loop_count() const { CDReader cdata(_cycler); return cdata->_loop_count; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::set_play_rate -// Access: Published -// Description: Sets the movie's play-rate. This is the speed at -// which the movie's cursor advances. The default is -// to advance 1.0 movie-seconds per real-time second. -//////////////////////////////////////////////////////////////////// +/** + * Sets the movie's play-rate. This is the speed at which the movie's cursor + * advances. The default is to advance 1.0 movie-seconds per real-time + * second. + */ void MovieTexture:: set_play_rate(double rate) { CDWriter cdata(_cycler); @@ -703,46 +611,37 @@ set_play_rate(double rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::get_play_rate -// Access: Published -// Description: Gets the movie's play-rate. -//////////////////////////////////////////////////////////////////// +/** + * Gets the movie's play-rate. + */ double MovieTexture:: get_play_rate() const { CDReader cdata(_cycler); return cdata->_play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::is_playing -// Access: Published -// Description: Returns true if the movie's cursor is advancing. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the movie's cursor is advancing. + */ bool MovieTexture:: is_playing() const { CDReader cdata(_cycler); return cdata->_playing; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::synchronize_to -// Access: Published -// Description: Synchronize this texture to a sound. Typically, -// you would load the texture and the sound from the -// same AVI file. -//////////////////////////////////////////////////////////////////// +/** + * Synchronize this texture to a sound. Typically, you would load the texture + * and the sound from the same AVI file. + */ void MovieTexture:: synchronize_to(AudioSound *s) { CDWriter cdata(_cycler); cdata->_synchronize = s; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::unsynchronize -// Access: Published -// Description: Stop synchronizing with a sound. -//////////////////////////////////////////////////////////////////// +/** + * Stop synchronizing with a sound. + */ void MovieTexture:: unsynchronize() { CDWriter cdata(_cycler); @@ -750,19 +649,16 @@ unsynchronize() { } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_update_frames -// Access: Private -// Description: Called internally to sync all of the frames to the -// current time. Returns true if successful, or false -// of some of the frames are out-of-date with each -// other. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to sync all of the frames to the current time. Returns + * true if successful, or false of some of the frames are out-of-date with + * each other. + */ bool MovieTexture:: do_update_frames(const CData *cdata) const { - // Throughout this method, we cast the VideoPage to non-const to - // update the _cbuffer or _abuffer member. We can do this safely - // because this is only a transparent cache value. + // Throughout this method, we cast the VideoPage to non-const to update the + // _cbuffer or _abuffer member. We can do this safely because this is only + // a transparent cache value. nassertr(cdata->_has_offset, false); // First, go through and get all of the current frames. @@ -785,9 +681,8 @@ do_update_frames(const CData *cdata) const { } if (!movies_sync_pages) { - // If movies-sync-pages is configured off, we don't care about - // syncing the pages, and we always return true here to render the - // pages we've got. + // If movies-sync-pages is configured off, we don't care about syncing the + // pages, and we always return true here to render the pages we've got. return true; } @@ -848,8 +743,8 @@ do_update_frames(const CData *cdata) const { } if (!in_sync) { - // If we're not in sync, throw away pages that are older than the - // newest available frame. + // If we're not in sync, throw away pages that are older than the newest + // available frame. if (newest != NULL) { Pages::const_iterator pi; for (pi = cdata->_pages.begin(); pi != cdata->_pages.end(); ++pi) { @@ -865,10 +760,10 @@ do_update_frames(const CData *cdata) const { } if (any_dropped) { - // If we dropped one or more frames for being out-of-sync, - // implying that compare_timestamp() is implemented, then we - // also want to update our internal offset value so that - // future frames will get the same value. + // If we dropped one or more frames for being out-of-sync, implying + // that compare_timestamp() is implemented, then we also want to + // update our internal offset value so that future frames will get the + // same value. ((CData *)cdata)->_offset = newest->get_timestamp(); } } @@ -877,34 +772,27 @@ do_update_frames(const CData *cdata) const { return in_sync; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a Texture object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Texture object + */ void MovieTexture:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::make_from_bam -// Access: Protected, Static -// Description: Factory method to generate a MovieTexture object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a MovieTexture object + */ TypedWritable *MovieTexture:: make_from_bam(const FactoryParams ¶ms) { PT(MovieTexture) dummy = new MovieTexture(""); return dummy->make_this_from_bam(params); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int MovieTexture:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = Texture::complete_pointers(p_list, manager); @@ -920,12 +808,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_write_datagram_rawdata -// Access: Protected, Virtual -// Description: Writes the rawdata part of the texture to the -// Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the rawdata part of the texture to the Datagram. + */ void MovieTexture:: do_write_datagram_rawdata(Texture::CData *cdata_tex, BamWriter *manager, Datagram &dg) { CDReader cdata(_cycler); @@ -940,12 +825,10 @@ do_write_datagram_rawdata(Texture::CData *cdata_tex, BamWriter *manager, Datagra } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::do_fillin_rawdata -// Access: Protected, Virtual -// Description: Reads in the part of the Texture that was written -// with do_write_datagram_rawdata(). -//////////////////////////////////////////////////////////////////// +/** + * Reads in the part of the Texture that was written with + * do_write_datagram_rawdata(). + */ void MovieTexture:: do_fillin_rawdata(Texture::CData *cdata_tex, DatagramIterator &scan, BamReader *manager) { CDWriter cdata(_cycler); @@ -964,19 +847,17 @@ do_fillin_rawdata(Texture::CData *cdata_tex, DatagramIterator &scan, BamReader * manager->read_pointer(scan); // page._alpha } - // We load one or more MovieVideoCursors during the above loop. We - // need a finalize callback so we can initialize ourselves once - // those cursors have been read completely. + // We load one or more MovieVideoCursors during the above loop. We need a + // finalize callback so we can initialize ourselves once those cursors have + // been read completely. manager->register_finalize(this); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTexture::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void MovieTexture:: finalize(BamReader *manager) { Texture::CDWriter cdata_tex(Texture::_cycler); diff --git a/panda/src/grutil/movieTexture.h b/panda/src/grutil/movieTexture.h index 1a3680cde5..a02b6bf3d3 100644 --- a/panda/src/grutil/movieTexture.h +++ b/panda/src/grutil/movieTexture.h @@ -1,16 +1,15 @@ -// Filename: movieTexture.h -// Created by: jyelon (01Aug2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTexture.h + * @author jyelon + * @date 2007-08-01 + */ #ifndef MOVIETEXTURE_H #define MOVIETEXTURE_H @@ -27,11 +26,10 @@ #include "cycleDataWriter.h" #include "cycleDataReader.h" -//////////////////////////////////////////////////////////////////// -// Class : MovieTexture -// Description : A texture that fetches video frames from an -// underlying object of class Movie. -//////////////////////////////////////////////////////////////////// +/** + * A texture that fetches video frames from an underlying object of class + * Movie. + */ class EXPCL_PANDA_GRUTIL MovieTexture : public Texture { PUBLISHED: MovieTexture(const string &name); @@ -47,7 +45,7 @@ PUBLISHED: INLINE MovieVideoCursor *get_color_cursor(int page); INLINE MovieVideoCursor *get_alpha_cursor(int page); - + void restart(); void stop(); void play(); @@ -80,12 +78,12 @@ public: static PT(Texture) make_texture(); virtual bool has_cull_callback() const; virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const; - + protected: class CData; virtual PT(Texture) make_copy_impl(); - void do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, + void do_assign(CData *cdata, Texture::CData *cdata_tex, const MovieTexture *copy, const CData *cdata_copy, const Texture::CData *cdata_copy_tex); virtual void do_reload_ram_image(Texture::CData *cdata, bool allow_compression); @@ -94,8 +92,8 @@ protected: virtual void do_get_bam_rawdata(Texture::CData *cdata); virtual bool do_can_reload(const Texture::CData *cdata) const; - virtual bool do_adjust_this_size(const Texture::CData *cdata, - int &x_size, int &y_size, const string &name, + virtual bool do_adjust_this_size(const Texture::CData *cdata, + int &x_size, int &y_size, const string &name, bool for_padding) const; virtual bool do_read_one(Texture::CData *cdata, @@ -107,7 +105,7 @@ protected: const PNMImage &pnmimage, const string &name, int z, int n, const LoaderOptions &options); bool do_load_one(Texture::CData *cdata, - PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, + PT(MovieVideoCursor) color, PT(MovieVideoCursor) alpha, int z, const LoaderOptions &options); virtual void do_allocate_pages(Texture::CData *cdata); @@ -120,7 +118,7 @@ protected: PT(MovieVideoCursor::Buffer) _cbuffer; PT(MovieVideoCursor::Buffer) _abuffer; }; - + typedef pvector Pages; class EXPCL_PANDA_GRUTIL CData : public CycleData { @@ -131,7 +129,7 @@ protected: virtual TypeHandle get_parent_type() const { return MovieTexture::get_class_type(); } - + Pages _pages; int _video_width; int _video_height; @@ -143,8 +141,8 @@ protected: double _play_rate; PT(AudioSound) _synchronize; - // The remaining values represent a local cache only; it is not - // preserved through the pipeline. + // The remaining values represent a local cache only; it is not preserved + // through the pipeline. bool _has_offset; double _offset; int _true_loop_count; @@ -153,8 +151,8 @@ protected: PipelineCycler _cycler; typedef CycleDataReader CDReader; typedef CycleDataWriter CDWriter; - - void do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, + + void do_recalculate_image_properties(CData *cdata, Texture::CData *cdata_tex, const LoaderOptions &options); private: diff --git a/panda/src/grutil/multitexReducer.I b/panda/src/grutil/multitexReducer.I index f1becbcd1e..11ae210475 100644 --- a/panda/src/grutil/multitexReducer.I +++ b/panda/src/grutil/multitexReducer.I @@ -1,71 +1,55 @@ -// Filename: multitexReducer.I -// Created by: drose (30Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multitexReducer.I + * @author drose + * @date 2004-11-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan -// Access: Published -// Description: Starts scanning the hierarchy beginning at the -// indicated node. Any GeomNodes discovered in the -// hierarchy with multitexture will be added to internal -// structures in the MultitexReducer so that a future -// call to flatten() will operate on all of these at -// once. -// -// This version of this method does not accumulate state -// from the parents of the indicated node; thus, only -// multitexture effects that have been applied at node -// and below will be considered. -//////////////////////////////////////////////////////////////////// +/** + * Starts scanning the hierarchy beginning at the indicated node. Any + * GeomNodes discovered in the hierarchy with multitexture will be added to + * internal structures in the MultitexReducer so that a future call to + * flatten() will operate on all of these at once. + * + * This version of this method does not accumulate state from the parents of + * the indicated node; thus, only multitexture effects that have been applied + * at node and below will be considered. + */ INLINE void MultitexReducer:: scan(const NodePath &node) { scan(node.node(), RenderState::make_empty(), TransformState::make_identity()); } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan -// Access: Published -// Description: Starts scanning the hierarchy beginning at the -// indicated node. Any GeomNodes discovered in the -// hierarchy with multitexture will be added to internal -// structures in the MultitexReducer so that a future -// call to flatten() will operate on all of these at -// once. -// -// The second parameter represents the NodePath from -// which to accumulate the state that is considered for -// the multitexture. Pass an empty NodePath to -// accumulate all the state from the root of the graph, -// or you may specify some other node here in order to -// not consider nodes above that as contributing to the -// state to be flattened. This is particularly useful -// if you have some texture stage which is applied -// globally to a scene (for instance, a caustics -// effect), which you don't want to be considered for -// flattening by the MultitexReducer. -//////////////////////////////////////////////////////////////////// +/** + * Starts scanning the hierarchy beginning at the indicated node. Any + * GeomNodes discovered in the hierarchy with multitexture will be added to + * internal structures in the MultitexReducer so that a future call to + * flatten() will operate on all of these at once. + * + * The second parameter represents the NodePath from which to accumulate the + * state that is considered for the multitexture. Pass an empty NodePath to + * accumulate all the state from the root of the graph, or you may specify + * some other node here in order to not consider nodes above that as + * contributing to the state to be flattened. This is particularly useful if + * you have some texture stage which is applied globally to a scene (for + * instance, a caustics effect), which you don't want to be considered for + * flattening by the MultitexReducer. + */ INLINE void MultitexReducer:: scan(const NodePath &node, const NodePath &state_from) { - scan(node.node(), node.get_parent().get_state(state_from), + scan(node.node(), node.get_parent().get_state(state_from), node.get_parent().get_transform(state_from)); } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::StageInfo::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MultitexReducer::StageInfo:: operator < (const MultitexReducer::StageInfo &other) const { if (_stage != other._stage) { @@ -81,11 +65,9 @@ operator < (const MultitexReducer::StageInfo &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::GeomInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MultitexReducer::GeomInfo:: GeomInfo(const RenderState *state, const RenderState *geom_net_state, GeomNode *geom_node, int index) : @@ -96,11 +78,9 @@ GeomInfo(const RenderState *state, const RenderState *geom_net_state, { } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::GeomNodeInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MultitexReducer::GeomNodeInfo:: GeomNodeInfo(const RenderState *state, GeomNode *geom_node) : _state(state), diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index ed65e88311..ea300e7902 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -1,16 +1,15 @@ -// Filename: multitexReducer.cxx -// Created by: drose (30Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multitexReducer.cxx + * @author drose + * @date 2004-11-30 + */ #include "multitexReducer.h" #include "pandaNode.h" @@ -38,11 +37,9 @@ #include "geomVertexWriter.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MultitexReducer:: MultitexReducer() { _target_stage = TextureStage::get_default(); @@ -50,42 +47,32 @@ MultitexReducer() { _allow_tex_mat = false; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MultitexReducer:: ~MultitexReducer() { } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::clear -// Access: Published -// Description: Removes the record of nodes that were previously -// discovered by scan(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the record of nodes that were previously discovered by scan(). + */ void MultitexReducer:: clear() { _stages.clear(); _geom_node_list.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan -// Access: Published -// Description: Starts scanning the hierarchy beginning at the -// indicated node. Any GeomNodes discovered in the -// hierarchy with multitexture will be added to internal -// structures in the MultitexReducer so that a future -// call to flatten() will operate on all of these at -// once. -// -// The indicated transform and state are the state -// inherited from the node's ancestors; any multitexture -// operations will be accumulated from the indicated -// starting state. -//////////////////////////////////////////////////////////////////// +/** + * Starts scanning the hierarchy beginning at the indicated node. Any + * GeomNodes discovered in the hierarchy with multitexture will be added to + * internal structures in the MultitexReducer so that a future call to + * flatten() will operate on all of these at once. + * + * The indicated transform and state are the state inherited from the node's + * ancestors; any multitexture operations will be accumulated from the + * indicated starting state. + */ void MultitexReducer:: scan(PandaNode *node, const RenderState *state, const TransformState *transform) { if (grutil_cat.is_debug()) { @@ -96,10 +83,10 @@ scan(PandaNode *node, const RenderState *state, const TransformState *transform) CPT(RenderState) next_state = state->compose(node->get_state()); CPT(TransformState) next_transform = transform->compose(node->get_transform()); - // We must turn off any textures we come across in the scan() - // operation, since the flattened texture will be applied to the - // Geoms after the flatten() operation, and we don't want to still - // have a multitexture specified. + // We must turn off any textures we come across in the scan() operation, + // since the flattened texture will be applied to the Geoms after the + // flatten() operation, and we don't want to still have a multitexture + // specified. node->set_state(node->get_state()->remove_attrib(TextureAttrib::get_class_slot())); if (node->is_geom_node()) { @@ -113,84 +100,64 @@ scan(PandaNode *node, const RenderState *state, const TransformState *transform) } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::set_target -// Access: Published -// Description: Specifies the target TextureStage (and InternalName) -// that will be left on each multitexture node after the -// flatten operation has completed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the target TextureStage (and InternalName) that will be left on + * each multitexture node after the flatten operation has completed. + */ void MultitexReducer:: set_target(TextureStage *stage) { _target_stage = stage; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::set_use_geom -// Access: Published -// Description: Indicates whether the actual geometry will be used to -// generate the textures. -// -// If this is set to true, the geometry discovered by -// scan() will be used to generate the textures, which -// allows for the vertex and polygon colors to be made -// part of the texture itself (and makes the M_decal -// multitexture mode more reliable). However, this only -// works if the geometry does not contain multiple -// different polygons that map to the same UV range. -// -// If this is set to false (the default), a plain flat -// card will be used to generate the textures, which is -// more robust in general, but the resulting texture -// will not include vertex colors and M_decal won't work -// properly. -// -// Note that in case multiple sets of texture -// coordinates are in effect, then the additional sets -// will always use the geometry anyway regardless of the -// setting of this flag (but this will not affect vertex -// color). -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the actual geometry will be used to generate the + * textures. + * + * If this is set to true, the geometry discovered by scan() will be used to + * generate the textures, which allows for the vertex and polygon colors to be + * made part of the texture itself (and makes the M_decal multitexture mode + * more reliable). However, this only works if the geometry does not contain + * multiple different polygons that map to the same UV range. + * + * If this is set to false (the default), a plain flat card will be used to + * generate the textures, which is more robust in general, but the resulting + * texture will not include vertex colors and M_decal won't work properly. + * + * Note that in case multiple sets of texture coordinates are in effect, then + * the additional sets will always use the geometry anyway regardless of the + * setting of this flag (but this will not affect vertex color). + */ void MultitexReducer:: set_use_geom(bool use_geom) { _use_geom = use_geom; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::set_allow_tex_mat -// Access: Published -// Description: Indicates whether the resulting texture should be -// expected to be animated beyond its current range via -// a texture matrix (true), or whether the current range -// of texture coordinates will be sufficient forever -// (false). -// -// If this is set to true, then the entire texture image -// must be generated, in the assumption that the user -// may animate the texture around on the surface after -// it has been composed. -// -// If this is set to false (the default), then only the -// portion of the texture image which is actually in use -// must be generated, which may be a significant savings -// in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the resulting texture should be expected to be animated + * beyond its current range via a texture matrix (true), or whether the + * current range of texture coordinates will be sufficient forever (false). + * + * If this is set to true, then the entire texture image must be generated, in + * the assumption that the user may animate the texture around on the surface + * after it has been composed. + * + * If this is set to false (the default), then only the portion of the texture + * image which is actually in use must be generated, which may be a + * significant savings in texture memory. + */ void MultitexReducer:: set_allow_tex_mat(bool allow_tex_mat) { _allow_tex_mat = allow_tex_mat; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::flatten -// Access: Published -// Description: Actually performs the reducing operations on the -// nodes that were previously scanned. -// -// A window that can be used to create texture buffers -// suitable for rendering this geometry must be -// supplied. This specifies the particular GSG that -// will be used to composite the textures. -//////////////////////////////////////////////////////////////////// +/** + * Actually performs the reducing operations on the nodes that were previously + * scanned. + * + * A window that can be used to create texture buffers suitable for rendering + * this geometry must be supplied. This specifies the particular GSG that + * will be used to composite the textures. + */ void MultitexReducer:: flatten(GraphicsOutput *window) { if (grutil_cat.is_debug()) { @@ -203,11 +170,11 @@ flatten(GraphicsOutput *window) { grutil_cat.debug(false) << "stage_list for:"; for (GeomList::const_iterator gi = geom_list.begin(); - gi != geom_list.end(); + gi != geom_list.end(); ++gi) { const GeomInfo &geom_info = (*gi); grutil_cat.debug(false) - << " (" << geom_info._geom_node->get_name() << " g" + << " (" << geom_info._geom_node->get_name() << " g" << geom_info._index << ")"; } grutil_cat.debug(false) << ":\n"; @@ -226,7 +193,7 @@ flatten(GraphicsOutput *window) { const StageList &stage_list = (*mi).first; const GeomList &geom_list = (*mi).second; - //determine whether this texture needs a white or transparent background + // determine whether this texture needs a white or transparent background bool use_transparent_bg = false; if(stage_list.size() > 0) { if(stage_list[0]._stage->get_mode() == TextureStage::M_decal) @@ -240,8 +207,8 @@ flatten(GraphicsOutput *window) { // Create an offscreen buffer in which to render the new texture. - // Start by choosing a model TextureStage to determine the new - // texture's properties. + // Start by choosing a model TextureStage to determine the new texture's + // properties. const StageInfo &model_stage = stage_list[choose_model_stage(stage_list)]; Texture *model_tex = model_stage._tex; @@ -253,17 +220,16 @@ flatten(GraphicsOutput *window) { LTexCoord min_uv, max_uv; determine_uv_range(min_uv, max_uv, model_stage, geom_list); - // Maybe we only use a small portion of the texture, or maybe we - // need to repeat the texture several times. + // Maybe we only use a small portion of the texture, or maybe we need to + // repeat the texture several times. LVecBase2 uv_scale; LVecBase2 uv_trans; get_uv_scale(uv_scale, uv_trans, min_uv, max_uv); - // Also, if there is now a scale on the UV's (in conjunction with - // whatever texture matrix might be applied on the model stage), - // we may be able to adjust the image size accordingly, to keep - // the pixels at about the same scale--but we have to keep it to a - // power of 2. + // Also, if there is now a scale on the UV's (in conjunction with whatever + // texture matrix might be applied on the model stage), we may be able to + // adjust the image size accordingly, to keep the pixels at about the same + // scale--but we have to keep it to a power of 2. int x_size; int y_size; choose_texture_size(x_size, y_size, model_stage, uv_scale, @@ -277,8 +243,8 @@ flatten(GraphicsOutput *window) { GraphicsOutput *buffer = window->make_texture_buffer (multitex_name_strm.str(), x_size, y_size, NULL, false); - // TODO: this no longer automatically deletes the buffer. We need - // to take care of this explicitly now. + // TODO: this no longer automatically deletes the buffer. We need to take + // care of this explicitly now. buffer->set_one_shot(true); Texture *tex = buffer->get_texture(); @@ -286,8 +252,8 @@ flatten(GraphicsOutput *window) { tex->set_minfilter(minfilter); tex->set_magfilter(magfilter); - // Set up the offscreen buffer to render 0,0 to 1,1. This will be - // the whole texture, but nothing outside the texture. + // Set up the offscreen buffer to render 0,0 to 1,1. This will be the + // whole texture, but nothing outside the texture. DisplayRegion *dr = buffer->make_display_region(); PT(Camera) cam_node = new Camera("multitexCam"); PT(Lens) lens = new OrthographicLens(); @@ -300,8 +266,8 @@ flatten(GraphicsOutput *window) { uv_trans[0], 0.0f, uv_trans[1], 1.0f)); cam_node->set_lens(lens); - // Create a root node for the buffer's scene graph, and set up - // some appropriate properties for it. + // Create a root node for the buffer's scene graph, and set up some + // appropriate properties for it. NodePath render("buffer"); render.set_bin("unsorted", 0); render.set_depth_test(false); @@ -311,40 +277,40 @@ flatten(GraphicsOutput *window) { NodePath cam = render.attach_new_node(cam_node); dr->set_camera(cam); - // If the geometry has vertex color and M_decal is in use, we must - // render with use_geom in effect. Otherwise we need not (and we - // might prefer not to). + // If the geometry has vertex color and M_decal is in use, we must render + // with use_geom in effect. Otherwise we need not (and we might prefer + // not to). bool force_use_geom = _use_geom; bool bake_in_color = _use_geom; LColor geom_color(1.0f, 1.0f, 1.0f, 1.0f); - - //override the base color in the transparent pass down case. + + // override the base color in the transparent pass down case. if(use_transparent_bg) geom_color = LColor(0.0f,0.0f,0.0f,0.0f); if (!force_use_geom) { bool uses_decal = scan_decal(stage_list); if (uses_decal) { - // If we have M_decal, we need to bake in the flat color - // even if there is no vertex color. + // If we have M_decal, we need to bake in the flat color even if there + // is no vertex color. bake_in_color = true; - + /* int num_colors = 0; scan_color(geom_list, geom_color, num_colors); if (num_colors > 1) { - // But if there is also vertex color, then we need to render - // with the geometry. + // But if there is also vertex color, then we need to render with + // the geometry. force_use_geom = true; }*/ } } if (!force_use_geom) { - // Put one plain white (or flat-colored) card in the background - // for the first texture layer to apply onto. - + // Put one plain white (or flat-colored) card in the background for the + // first texture layer to apply onto. + CardMaker cm("background"); cm.set_frame(min_uv[0], max_uv[0], min_uv[1], max_uv[1]); if (bake_in_color) { @@ -353,12 +319,12 @@ flatten(GraphicsOutput *window) { render.attach_new_node(cm.generate()); } else { - // Put a vertex-colored model of the geometry in the background - // for the first texture layer to apply only. + // Put a vertex-colored model of the geometry in the background for the + // first texture layer to apply only. nassertv(bake_in_color); PT(GeomNode) geom_node = new GeomNode("background"); transfer_geom(geom_node, NULL, geom_list, true); - + render.attach_new_node(geom_node); } @@ -366,34 +332,34 @@ flatten(GraphicsOutput *window) { for (si = stage_list.begin(); si != stage_list.end(); ++si) { const StageInfo &stage_info = (*si); - make_texture_layer(render, stage_info, geom_list, + make_texture_layer(render, stage_info, geom_list, min_uv, max_uv, force_use_geom, use_transparent_bg); } - // Now modify the geometry to apply the new texture, instead of - // the old multitexture. + // Now modify the geometry to apply the new texture, instead of the old + // multitexture. CPT(RenderAttrib) new_ta = DCAST(TextureAttrib, TextureAttrib::make())-> add_on_stage(_target_stage, tex); GeomList::const_iterator gi; for (gi = geom_list.begin(); gi != geom_list.end(); ++gi) { const GeomInfo &geom_info = (*gi); - - CPT(RenderState) geom_state = + + CPT(RenderState) geom_state = geom_info._geom_node->get_geom_state(geom_info._index); int override = geom_info._geom_net_state->get_override(TextureAttrib::get_class_slot()); geom_state = geom_state->add_attrib(new_ta, override); if (bake_in_color) { - // If we have baked the color into the texture, we have to be - // sure to disable coloring on the new fragment. + // If we have baked the color into the texture, we have to be sure to + // disable coloring on the new fragment. geom_state = geom_state->add_attrib(ColorAttrib::make_flat(LColor(1.0f, 1.0f, 1.0f, 1.0f))); - // And we invent a ColorScaleAttrib to undo the effect of any - // color scale we're getting from above. This is not the same - // thing as a ColorScaleAttrib::make_off(), since that would - // prohibit any future changes to the color scale. - const RenderAttrib *attrib = + // And we invent a ColorScaleAttrib to undo the effect of any color + // scale we're getting from above. This is not the same thing as a + // ColorScaleAttrib::make_off(), since that would prohibit any future + // changes to the color scale. + const RenderAttrib *attrib = geom_info._geom_net_state->get_attrib(ColorScaleAttrib::get_class_slot()); if (attrib != (const RenderAttrib *)NULL) { @@ -407,8 +373,8 @@ flatten(GraphicsOutput *window) { const RenderAttrib *ra = geom_info._state->get_attrib(TexMatrixAttrib::get_class_slot()); if (ra != (const RenderAttrib *)NULL) { - // There is a texture matrix inherited from above; put an - // inverse matrix on the Geom to compensate. + // There is a texture matrix inherited from above; put an inverse + // matrix on the Geom to compensate. const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, ra); CPT(TransformState) tex_mat = tma->get_transform(_target_stage); } @@ -433,29 +399,27 @@ flatten(GraphicsOutput *window) { } } - // Now that we've copied all of the geometry and applied texture - // matrices, flatten out those texture matrices where possible. + // Now that we've copied all of the geometry and applied texture matrices, + // flatten out those texture matrices where possible. GeomTransformer transformer; GeomNodeList::const_iterator gni; for (gni = _geom_node_list.begin(); gni != _geom_node_list.end(); ++gni) { const GeomNodeInfo &geom_node_info = (*gni); AccumulatedAttribs attribs; - attribs._texture = + attribs._texture = geom_node_info._state->get_attrib(TextureAttrib::get_class_slot()); geom_node_info._geom_node->apply_attribs_to_vertices (attribs, SceneGraphReducer::TT_tex_matrix, transformer); } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan_geom_node -// Access: Private -// Description: Adds the Geoms in the indicated GeomNode to the -// internal database of multitexture elements. -//////////////////////////////////////////////////////////////////// +/** + * Adds the Geoms in the indicated GeomNode to the internal database of + * multitexture elements. + */ void MultitexReducer:: -scan_geom_node(GeomNode *node, const RenderState *state, +scan_geom_node(GeomNode *node, const RenderState *state, const TransformState *transform) { if (grutil_cat.is_debug()) { grutil_cat.debug() @@ -467,7 +431,7 @@ scan_geom_node(GeomNode *node, const RenderState *state, int num_geoms = node->get_num_geoms(); for (int gi = 0; gi < num_geoms; gi++) { - CPT(RenderState) geom_net_state = + CPT(RenderState) geom_net_state = state->compose(node->get_geom_state(gi)); if (grutil_cat.is_debug()) { @@ -493,8 +457,8 @@ scan_geom_node(GeomNode *node, const RenderState *state, } else if (ta->get_num_on_stages() < 2) { // Just a single texture on the Geom; we don't really need to do - // anything to flatten the textures, then. But we should ensure - // that the correct TextureAttrib is applied to the Geom. + // anything to flatten the textures, then. But we should ensure that + // the correct TextureAttrib is applied to the Geom. int override = geom_net_state->get_override(TextureAttrib::get_class_slot()); CPT(RenderState) geom_state = node->get_geom_state(gi); geom_state = geom_state->add_attrib(ta, override); @@ -507,22 +471,22 @@ scan_geom_node(GeomNode *node, const RenderState *state, if (attrib != (const RenderAttrib *)NULL) { tma = DCAST(TexMatrixAttrib, attrib); } - + StageList stage_list; - + int num_stages = ta->get_num_on_stages(); for (int si = 0; si < num_stages; si++) { TextureStage *stage = ta->get_on_stage(si); Texture *tex = ta->get_on_texture(stage); if (tex->get_x_size() != 0 && tex->get_y_size() != 0) { stage_list.push_back(StageInfo(stage, ta, tma)); - + } else { grutil_cat.info() << "Ignoring invalid texture stage " << stage->get_name() << "\n"; } } - + if (stage_list.size() >= 2) { record_stage_list(stage_list, GeomInfo(state, geom_net_state, node, gi)); } @@ -530,18 +494,15 @@ scan_geom_node(GeomNode *node, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::record_stage_list -// Access: Private -// Description: Adds the record of this one Geom and its associated -// StageList. -//////////////////////////////////////////////////////////////////// +/** + * Adds the record of this one Geom and its associated StageList. + */ void MultitexReducer:: -record_stage_list(const MultitexReducer::StageList &stage_list, +record_stage_list(const MultitexReducer::StageList &stage_list, const MultitexReducer::GeomInfo &geom_info) { if (grutil_cat.is_debug()) { grutil_cat.debug() - << "record_stage_list for " << geom_info._geom_node->get_name() << " g" + << "record_stage_list for " << geom_info._geom_node->get_name() << " g" << geom_info._index << ":\n"; StageList::const_iterator si; for (si = stage_list.begin(); si != stage_list.end(); ++si) { @@ -555,13 +516,10 @@ record_stage_list(const MultitexReducer::StageList &stage_list, _stages[stage_list].push_back(geom_info); } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::choose_model_stage -// Access: Private -// Description: Chooses one of the TextureStages in the stage_list to -// serve as the model to determine the size and -// properties of the resulting texture. -//////////////////////////////////////////////////////////////////// +/** + * Chooses one of the TextureStages in the stage_list to serve as the model to + * determine the size and properties of the resulting texture. + */ size_t MultitexReducer:: choose_model_stage(const MultitexReducer::StageList &stage_list) const { for (size_t si = 0; si < stage_list.size(); si++) { @@ -576,13 +534,10 @@ choose_model_stage(const MultitexReducer::StageList &stage_list) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::determine_uv_range -// Access: Private -// Description: Determines what the effective UV range for the -// indicated texture is across its geoms. Returns true -// if any UV's are found, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Determines what the effective UV range for the indicated texture is across + * its geoms. Returns true if any UV's are found, false otherwise. + */ bool MultitexReducer:: determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, const MultitexReducer::StageInfo &model_stage, @@ -593,8 +548,8 @@ determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, GeomList::const_iterator gi; for (gi = geom_list.begin(); gi != geom_list.end(); ++gi) { const GeomInfo &geom_info = (*gi); - - PT(Geom) geom = + + PT(Geom) geom = geom_info._geom_node->get_geom(geom_info._index)->make_copy(); CPT(GeomVertexData) vdata = geom->get_vertex_data(); @@ -607,7 +562,7 @@ determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, if (!got_any) { min_uv = max_uv = uv; got_any = true; - + } else { min_uv.set(min(min_uv[0], uv[0]), min(min_uv[1], uv[1])); max_uv.set(max(max_uv[0], uv[0]), max(max_uv[1], uv[1])); @@ -630,17 +585,13 @@ determine_uv_range(LTexCoord &min_uv, LTexCoord &max_uv, return got_any; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::get_uv_scale -// Access: Private -// Description: Chooses an appropriate transform to apply to all of -// the UV's on the generated texture, based on the -// coverage of the model stage. If only a portion of -// the model stage is used, we scale the UV's up to zoom -// into that one portion; on the other hand, if the -// texture repeats many times, we scale the UV's down to -// to include all of the repeating image. -//////////////////////////////////////////////////////////////////// +/** + * Chooses an appropriate transform to apply to all of the UV's on the + * generated texture, based on the coverage of the model stage. If only a + * portion of the model stage is used, we scale the UV's up to zoom into that + * one portion; on the other hand, if the texture repeats many times, we scale + * the UV's down to to include all of the repeating image. + */ void MultitexReducer:: get_uv_scale(LVecBase2 &uv_scale, LVecBase2 &uv_trans, const LTexCoord &min_uv, const LTexCoord &max_uv) const { @@ -660,31 +611,27 @@ get_uv_scale(LVecBase2 &uv_scale, LVecBase2 &uv_trans, uv_trans[1] = (min_uv[1] + max_uv[1]) / 2.0f - uv_scale[1] * 0.5f; } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::choose_texture_size -// Access: Private -// Description: Chooses an appropriate size to make the new texture, -// based on the size of the original model stage's -// texture, and the scale applied to the UV's. -//////////////////////////////////////////////////////////////////// +/** + * Chooses an appropriate size to make the new texture, based on the size of + * the original model stage's texture, and the scale applied to the UV's. + */ void MultitexReducer:: -choose_texture_size(int &x_size, int &y_size, - const MultitexReducer::StageInfo &model_stage, +choose_texture_size(int &x_size, int &y_size, + const MultitexReducer::StageInfo &model_stage, const LVecBase2 &uv_scale, GraphicsOutput *window) const { Texture *model_tex = model_stage._tex; - + // Start with the same size as the model texture. x_size = model_tex->get_x_size(); y_size = model_tex->get_y_size(); - // But we might be looking at just a subset of that texture (|scale| < - // 1) or a superset of the texture (|scale| > 1). In this case, we - // should adjust the pixel size accordingly, although we have to - // keep it to a power of 2. + // But we might be looking at just a subset of that texture (|scale| < 1) or + // a superset of the texture (|scale| > 1). In this case, we should adjust + // the pixel size accordingly, although we have to keep it to a power of 2. LVecBase3 inherited_scale = model_stage._tex_mat->get_scale(); - + PN_stdfloat u_scale = cabs(inherited_scale[0]) * uv_scale[0]; if (u_scale != 0.0f) { while (u_scale >= 2.0f) { @@ -711,8 +658,8 @@ choose_texture_size(int &x_size, int &y_size, if (x_size == 0 || y_size == 0) { grutil_cat.warning() - << "Texture size " << model_tex->get_x_size() << " " - << model_tex->get_y_size() << " with scale " + << "Texture size " << model_tex->get_x_size() << " " + << model_tex->get_y_size() << " with scale " << model_stage._tex_mat->get_scale() << ", reduced to size " << x_size << " " << y_size << "; constraining to 1 1.\n"; x_size = 1; @@ -725,8 +672,8 @@ choose_texture_size(int &x_size, int &y_size, y_size = min(y_size, (int)max_texture_dimension); } - // Finally, make sure the new sizes fit within the window, so we can - // use a parasite buffer. + // Finally, make sure the new sizes fit within the window, so we can use a + // parasite buffer. int win_x_size = window->get_x_size(); if (win_x_size != 0 && x_size > win_x_size) { x_size /= 2; @@ -744,16 +691,13 @@ choose_texture_size(int &x_size, int &y_size, } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::make_texture_layer -// Access: Private -// Description: Creates geometry to render the texture into the -// offscreen buffer using the same effects that were -// requested by its multitexture specification. -//////////////////////////////////////////////////////////////////// +/** + * Creates geometry to render the texture into the offscreen buffer using the + * same effects that were requested by its multitexture specification. + */ void MultitexReducer:: -make_texture_layer(const NodePath &render, - const MultitexReducer::StageInfo &stage_info, +make_texture_layer(const NodePath &render, + const MultitexReducer::StageInfo &stage_info, const MultitexReducer::GeomList &geom_list, const LTexCoord &min_uv, const LTexCoord &max_uv, bool force_use_geom, bool transparent_base) { @@ -767,9 +711,8 @@ make_texture_layer(const NodePath &render, case TextureStage::M_height: case TextureStage::M_selector: case TextureStage::M_normal_gloss: - // Don't know what to do with these funny modes. We should - // probably raise an exception or something. Fall through for - // now. + // Don't know what to do with these funny modes. We should probably raise + // an exception or something. Fall through for now. case TextureStage::M_modulate_glow: case TextureStage::M_modulate_gloss: @@ -786,7 +729,7 @@ make_texture_layer(const NodePath &render, } else { cba = ColorBlendAttrib::make (ColorBlendAttrib::M_add, ColorBlendAttrib::O_incoming_alpha, - ColorBlendAttrib::O_one_minus_incoming_alpha); + ColorBlendAttrib::O_one_minus_incoming_alpha); } break; @@ -816,37 +759,37 @@ make_texture_layer(const NodePath &render, TextureStage::CombineOperand operand0 = stage_info._stage->get_combine_rgb_operand0(); TextureStage::CombineSource source1 = stage_info._stage->get_combine_rgb_source1(); TextureStage::CombineOperand operand1 = stage_info._stage->get_combine_rgb_operand1(); - // Since modulate doesn't care about order, let's establish - // the convention that the lowest-numbered source - // operand is in slot 0 (just for purposes of comparison). + // Since modulate doesn't care about order, let's establish the + // convention that the lowest-numbered source operand is in slot 0 + // (just for purposes of comparison). if (source1 < source0) { source0 = stage_info._stage->get_combine_rgb_source1(); operand0 = stage_info._stage->get_combine_rgb_operand1(); source1 = stage_info._stage->get_combine_rgb_source0(); operand1 = stage_info._stage->get_combine_rgb_operand0(); } - + if (source0 == TextureStage::CS_primary_color && source1 == TextureStage::CS_previous) { - // This is just a trick to re-apply the vertex (lighting) - // color on the top of the texture stack. We can ignore it, - // since the flattened texture will do this anyway. + // This is just a trick to re-apply the vertex (lighting) color on + // the top of the texture stack. We can ignore it, since the + // flattened texture will do this anyway. return; - + } else if (source0 == TextureStage::CS_texture && source1 == TextureStage::CS_constant) { // Scaling the texture by a flat color. cba = ColorBlendAttrib::make (ColorBlendAttrib::M_add, ColorBlendAttrib::O_constant_color, ColorBlendAttrib::O_zero, stage_info._stage->get_color()); - + } else if (source0 == TextureStage::CS_texture && source1 == TextureStage::CS_previous) { // Just an ordinary modulate. cba = ColorBlendAttrib::make (ColorBlendAttrib::M_add, ColorBlendAttrib::O_fbuffer_color, ColorBlendAttrib::O_zero); - + } else { // Some other kind of modulate; we don't support it. return; @@ -872,25 +815,24 @@ make_texture_layer(const NodePath &render, NodePath geom; if (!force_use_geom && stage_info._stage->get_texcoord_name() == _target_stage->get_texcoord_name()) { - // If this TextureStage uses the target texcoords, we can just - // generate a simple card the fills the entire buffer. + // If this TextureStage uses the target texcoords, we can just generate a + // simple card the fills the entire buffer. CardMaker cm(stage_info._tex->get_name()); cm.set_uv_range(min_uv, max_uv); cm.set_has_uvs(true); cm.set_frame(min_uv[0], max_uv[0], min_uv[1], max_uv[1]); - + geom = render.attach_new_node(cm.generate()); } else { - // If this TextureStage uses some other texcoords (or if use_geom - // is true), we have to generate geometry that maps the texcoords - // to the target space. This will work only for very simple cases - // where the geometry is not too extensive and doesn't repeat over - // the same UV's. + // If this TextureStage uses some other texcoords (or if use_geom is + // true), we have to generate geometry that maps the texcoords to the + // target space. This will work only for very simple cases where the + // geometry is not too extensive and doesn't repeat over the same UV's. PT(GeomNode) geom_node = new GeomNode(stage_info._tex->get_name()); - transfer_geom(geom_node, stage_info._stage->get_texcoord_name(), + transfer_geom(geom_node, stage_info._stage->get_texcoord_name(), geom_list, false); - + geom = render.attach_new_node(geom_node); geom.set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); @@ -904,15 +846,12 @@ make_texture_layer(const NodePath &render, geom.node()->set_attrib(cba); } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::transfer_geom -// Access: Private -// Description: Copy the vertices from the indicated geom_list, -// mapping the vertex coordinates so that the geometry -// will render the appropriate distortion on the texture -// to map UV's from the specified set of texture -// coordinates to the target set. -//////////////////////////////////////////////////////////////////// +/** + * Copy the vertices from the indicated geom_list, mapping the vertex + * coordinates so that the geometry will render the appropriate distortion on + * the texture to map UV's from the specified set of texture coordinates to + * the target set. + */ void MultitexReducer:: transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, const MultitexReducer::GeomList &geom_list, @@ -923,41 +862,40 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, const GeomInfo &geom_info = (*gi); const Geom *orig_geom = geom_info._geom_node->get_geom(geom_info._index); - // Copy the Geom. This actually performs just a pointer copy of - // the original GeomVertexData and other associated structures. + // Copy the Geom. This actually performs just a pointer copy of the + // original GeomVertexData and other associated structures. PT(Geom) geom = orig_geom->make_copy(); // Ensure that any vertex animation has been applied. geom->set_vertex_data(geom->get_vertex_data(current_thread)->animate_vertices(true, current_thread)); - // Now get a modifiable pointer to the vertex data in the new - // Geom. This will actually perform a deep copy of the vertex - // data. + // Now get a modifiable pointer to the vertex data in the new Geom. This + // will actually perform a deep copy of the vertex data. PT(GeomVertexData) vdata = geom->modify_vertex_data(); vdata->set_usage_hint(Geom::UH_stream); - + if (vdata->has_column(_target_stage->get_texcoord_name())) { GeomVertexWriter vertex(vdata, InternalName::get_vertex(), current_thread); GeomVertexReader texcoord(vdata, _target_stage->get_texcoord_name(), current_thread); - + while (!texcoord.is_at_end()) { const LVecBase2 &tc = texcoord.get_data2(); vertex.set_data3(tc[0], 0.0f, tc[1]); } } - + if (texcoord_name != (const InternalName *)NULL && texcoord_name != InternalName::get_texcoord()) { - // Copy the texture coordinates from the indicated name over - // to the default name. - const GeomVertexColumn *column = + // Copy the texture coordinates from the indicated name over to the + // default name. + const GeomVertexColumn *column = vdata->get_format()->get_column(texcoord_name); if (column != (const GeomVertexColumn *)NULL) { vdata = vdata->replace_column (InternalName::get_texcoord(), column->get_num_components(), column->get_numeric_type(), column->get_contents()); geom->set_vertex_data(vdata); - + GeomVertexReader from(vdata, texcoord_name, current_thread); GeomVertexWriter to(vdata, InternalName::get_texcoord(), current_thread); while (!from.is_at_end()) { @@ -965,7 +903,7 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, } } } - + CPT(RenderState) geom_state = RenderState::make_empty(); if (preserve_color) { // Be sure to preserve whatever colors are on the geom. @@ -978,31 +916,26 @@ transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, geom_state = geom_state->add_attrib(csa); } } - + geom_node->add_geom(geom, geom_state); } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan_color -// Access: Private -// Description: Checks all the geoms in the list to see if they all -// use flat color, or if there is per-vertex color in -// use. -// -// Assumption: num_colors = 0 on entry. On exit, -// num_colors = 1 if there is exactly one color in use, -// or 2 if there is more than one color in use. If -// num_colors = 1, then geom_color is filled in with the -// color in use. -//////////////////////////////////////////////////////////////////// +/** + * Checks all the geoms in the list to see if they all use flat color, or if + * there is per-vertex color in use. + * + * Assumption: num_colors = 0 on entry. On exit, num_colors = 1 if there is + * exactly one color in use, or 2 if there is more than one color in use. If + * num_colors = 1, then geom_color is filled in with the color in use. + */ void MultitexReducer:: -scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, +scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, int &num_colors) const { GeomList::const_iterator gi; for (gi = geom_list.begin(); gi != geom_list.end() && num_colors < 2; ++gi) { const GeomInfo &geom_info = (*gi); - + LColor flat_color; bool has_flat_color = false; bool has_vertex_color = false; @@ -1031,8 +964,8 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, // This geom gets its color from its vertices. const Geom *geom = geom_info._geom_node->get_geom(geom_info._index); if (geom->get_vertex_data()->has_column(InternalName::get_color())) { - // This geom has per-vertex color. Assume the colors in the - // table are actually different from each other. + // This geom has per-vertex color. Assume the colors in the table are + // actually different from each other. has_vertex_color = true; } } @@ -1058,13 +991,10 @@ scan_color(const MultitexReducer::GeomList &geom_list, LColor &geom_color, } } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::scan_decal -// Access: Private -// Description: Checks all the stages in the list to see if any of -// them apply a texture via M_decal. Returns true if -// so, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Checks all the stages in the list to see if any of them apply a texture via + * M_decal. Returns true if so, false otherwise. + */ bool MultitexReducer:: scan_decal(const MultitexReducer::StageList &stage_list) const { StageList::const_iterator si; @@ -1080,13 +1010,11 @@ scan_decal(const MultitexReducer::StageList &stage_list) const { } -//////////////////////////////////////////////////////////////////// -// Function: MultitexReducer::StageInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MultitexReducer::StageInfo:: -StageInfo(TextureStage *stage, const TextureAttrib *ta, +StageInfo(TextureStage *stage, const TextureAttrib *ta, const TexMatrixAttrib *tma) : _stage(stage), _tex_mat(TransformState::make_identity()) @@ -1096,4 +1024,3 @@ StageInfo(TextureStage *stage, const TextureAttrib *ta, _tex_mat = tma->get_transform(stage); } } - diff --git a/panda/src/grutil/multitexReducer.h b/panda/src/grutil/multitexReducer.h index f5d054abd9..c6c811ffbd 100644 --- a/panda/src/grutil/multitexReducer.h +++ b/panda/src/grutil/multitexReducer.h @@ -1,16 +1,15 @@ -// Filename: multitexReducer.h -// Created by: drose (30Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file multitexReducer.h + * @author drose + * @date 2004-11-30 + */ #ifndef MULTITEXREDUCER_H #define MULTITEXREDUCER_H @@ -33,22 +32,18 @@ class PandaNode; class RenderState; class TransformState; -//////////////////////////////////////////////////////////////////// -// Class : MultitexReducer -// Description : This object presents an interface for generating new -// texture images that represent the combined images -// from one or more individual textures, reproducing -// certain kinds of multitexture effects without -// depending on multitexture support in the hardware. -// -// This also flattens out texture matrices and removes -// extra texture coordinates from the Geoms. It is thus -// not a complete substitute for true multitexturing, -// because it does not lend itself well to dynamic -// animation of the textures once they have been -// flattened. It is, however, useful for "baking in" a -// particular multitexture effect. -//////////////////////////////////////////////////////////////////// +/** + * This object presents an interface for generating new texture images that + * represent the combined images from one or more individual textures, + * reproducing certain kinds of multitexture effects without depending on + * multitexture support in the hardware. + * + * This also flattens out texture matrices and removes extra texture + * coordinates from the Geoms. It is thus not a complete substitute for true + * multitexturing, because it does not lend itself well to dynamic animation + * of the textures once they have been flattened. It is, however, useful for + * "baking in" a particular multitexture effect. + */ class EXPCL_PANDA_GRUTIL MultitexReducer { PUBLISHED: MultitexReducer(); @@ -57,7 +52,7 @@ PUBLISHED: void clear(); INLINE void scan(const NodePath &node); INLINE void scan(const NodePath &node, const NodePath &state_from); - void scan(PandaNode *node, const RenderState *state, + void scan(PandaNode *node, const RenderState *state, const TransformState *transform); void set_target(TextureStage *stage); @@ -69,7 +64,7 @@ PUBLISHED: private: class StageInfo { public: - StageInfo(TextureStage *stage, const TextureAttrib *ta, + StageInfo(TextureStage *stage, const TextureAttrib *ta, const TexMatrixAttrib *tma); INLINE bool operator < (const StageInfo &other) const; @@ -112,10 +107,10 @@ private: bool _allow_tex_mat; private: - void scan_geom_node(GeomNode *node, const RenderState *state, + void scan_geom_node(GeomNode *node, const RenderState *state, const TransformState *transform); - void record_stage_list(const StageList &stage_list, + void record_stage_list(const StageList &stage_list, const GeomInfo &geom_info); size_t choose_model_stage(const StageList &stage_list) const; @@ -131,15 +126,15 @@ private: const LVecBase2 &uv_scale, GraphicsOutput *window) const; - void make_texture_layer(const NodePath &render, - const StageInfo &stage_info, + void make_texture_layer(const NodePath &render, + const StageInfo &stage_info, const GeomList &geom_list, const LTexCoord &min_uv, const LTexCoord &max_uv, bool force_use_geom, bool transparent_base); void transfer_geom(GeomNode *geom_node, const InternalName *texcoord_name, const GeomList &geom_list, bool preserve_color); - void scan_color(const GeomList &geom_list, LColor &geom_color, + void scan_color(const GeomList &geom_list, LColor &geom_color, int &num_colors) const; bool scan_decal(const StageList &stage_list) const; diff --git a/panda/src/grutil/nodeVertexTransform.I b/panda/src/grutil/nodeVertexTransform.I index 97e4da32b8..8b6f0f6a03 100644 --- a/panda/src/grutil/nodeVertexTransform.I +++ b/panda/src/grutil/nodeVertexTransform.I @@ -1,35 +1,28 @@ -// Filename: nodeVertexTransform.I -// Created by: drose (22eb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeVertexTransform.I + * @author drose + * @date 2007-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodeVertexTransform::get_node -// Access: Published -// Description: Returns the PandaNode whose transform supplies this -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PandaNode whose transform supplies this object. + */ INLINE const PandaNode *NodeVertexTransform:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: NodeVertexTransform::get_prev -// Access: Published -// Description: Returns the VertexTransform object whose matrix will -// be composed with the result of this node's transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VertexTransform object whose matrix will be composed with the + * result of this node's transform. + */ INLINE const VertexTransform *NodeVertexTransform:: get_prev() const { return _prev; diff --git a/panda/src/grutil/nodeVertexTransform.cxx b/panda/src/grutil/nodeVertexTransform.cxx index decfc95fb3..de5b14d0f0 100644 --- a/panda/src/grutil/nodeVertexTransform.cxx +++ b/panda/src/grutil/nodeVertexTransform.cxx @@ -1,41 +1,35 @@ -// Filename: nodeVertexTransform.cxx -// Created by: drose (22eb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeVertexTransform.cxx + * @author drose + * @date 2007-02-22 + */ #include "nodeVertexTransform.h" TypeHandle NodeVertexTransform::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodeVertexTransform::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NodeVertexTransform:: -NodeVertexTransform(const PandaNode *node, +NodeVertexTransform(const PandaNode *node, const VertexTransform *prev) : _node(node), _prev(prev) { } -//////////////////////////////////////////////////////////////////// -// Function: NodeVertexTransform::get_matrix -// Access: Published, Virtual -// Description: Returns the transform of the associated node, -// composed with the previous VertexTransform if any, -// expressed as a matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform of the associated node, composed with the previous + * VertexTransform if any, expressed as a matrix. + */ void NodeVertexTransform:: get_matrix(LMatrix4 &matrix) const { if (_prev != (const VertexTransform *)NULL) { @@ -48,11 +42,9 @@ get_matrix(LMatrix4 &matrix) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodeVertexTransform::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodeVertexTransform:: output(ostream &out) const { if (_prev != (const VertexTransform *)NULL) { diff --git a/panda/src/grutil/nodeVertexTransform.h b/panda/src/grutil/nodeVertexTransform.h index c7e31f4f8c..9f1d891615 100644 --- a/panda/src/grutil/nodeVertexTransform.h +++ b/panda/src/grutil/nodeVertexTransform.h @@ -1,16 +1,15 @@ -// Filename: nodeVertexTransform.h -// Created by: drose (22eb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeVertexTransform.h + * @author drose + * @date 2007-02-22 + */ #ifndef NODEVERTEXTRANSFORM_H #define NODEVERTEXTRANSFORM_H @@ -21,18 +20,15 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : NodeVertexTransform -// Description : This VertexTransform gets its matrix from the -// Transform stored on a node. It can also compose its -// node's transform with another VertexTransform, -// allowing you to build up a chain of -// NodeVertexTransforms that represent a list of -// composed matrices. -//////////////////////////////////////////////////////////////////// +/** + * This VertexTransform gets its matrix from the Transform stored on a node. + * It can also compose its node's transform with another VertexTransform, + * allowing you to build up a chain of NodeVertexTransforms that represent a + * list of composed matrices. + */ class EXPCL_PANDA_GRUTIL NodeVertexTransform : public VertexTransform { PUBLISHED: - NodeVertexTransform(const PandaNode *node, + NodeVertexTransform(const PandaNode *node, const VertexTransform *prev = NULL); INLINE const PandaNode *get_node() const; diff --git a/panda/src/grutil/pfmVizzer.I b/panda/src/grutil/pfmVizzer.I index d392379ecb..6a0a5a23bc 100644 --- a/panda/src/grutil/pfmVizzer.I +++ b/panda/src/grutil/pfmVizzer.I @@ -1,224 +1,170 @@ -// Filename: pfmVizzer.I -// Created by: drose (30Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmVizzer.I + * @author drose + * @date 2012-09-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_pfm -// Access: Published -// Description: Returns the reference to the PfmFile manipulated by -// this PfmVizzer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference to the PfmFile manipulated by this PfmVizzer. + */ INLINE PfmFile &PfmVizzer:: get_pfm() { return _pfm; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_pfm -// Access: Published -// Description: Returns the reference to the PfmFile manipulated by -// this PfmVizzer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference to the PfmFile manipulated by this PfmVizzer. + */ INLINE const PfmFile &PfmVizzer:: get_pfm() const { return _pfm; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_vis_inverse -// Access: Published -// Description: Sets the vis_inverse flag. When this flag is true, -// vis meshes and point clouds are generated with the -// 3-d depth value in the texture coordinates, and the -// 2-d index value in the vertex position. When it is -// false, meshes are generated normally, with the 3-d -// depth value in the vertex position and the 2-d index -// value in the texture coordinates. -// -// This may be used in lieu of the lower-level -// add_vis_column(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the vis_inverse flag. When this flag is true, vis meshes and point + * clouds are generated with the 3-d depth value in the texture coordinates, + * and the 2-d index value in the vertex position. When it is false, meshes + * are generated normally, with the 3-d depth value in the vertex position and + * the 2-d index value in the texture coordinates. + * + * This may be used in lieu of the lower-level add_vis_column(). + */ INLINE void PfmVizzer:: set_vis_inverse(bool vis_inverse) { _vis_inverse = vis_inverse; clear_vis_columns(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_vis_inverse -// Access: Published -// Description: Returns the vis_inverse flag. See set_vis_inverse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vis_inverse flag. See set_vis_inverse(). + */ INLINE bool PfmVizzer:: get_vis_inverse() const { return _vis_inverse; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_flat_texcoord_name -// Access: Published -// Description: If the flat_texcoord_name is specified, it is the -// name of an additional vertex column that will be -// created for the "flat" texture coordinates, i.e. the -// original 0..1 values that correspond to the 2-D index -// position of each point in the original pfm file. -// -// These are the same values that will be assigned to -// the default texture coordinates if the vis_inverse -// flag is *not* true. -// -// This may be used in lieu of the lower-level -// add_vis_column(). -//////////////////////////////////////////////////////////////////// +/** + * If the flat_texcoord_name is specified, it is the name of an additional + * vertex column that will be created for the "flat" texture coordinates, i.e. + * the original 0..1 values that correspond to the 2-D index position of each + * point in the original pfm file. + * + * These are the same values that will be assigned to the default texture + * coordinates if the vis_inverse flag is *not* true. + * + * This may be used in lieu of the lower-level add_vis_column(). + */ INLINE void PfmVizzer:: set_flat_texcoord_name(InternalName *flat_texcoord_name) { _flat_texcoord_name = flat_texcoord_name; clear_vis_columns(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::clear_flat_texcoord_name -// Access: Published -// Description: Resets the flat_texcoord_name to empty, so that -// additional texture coordinates are not created. -// -// This may be used in lieu of the lower-level -// add_vis_column(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the flat_texcoord_name to empty, so that additional texture + * coordinates are not created. + * + * This may be used in lieu of the lower-level add_vis_column(). + */ INLINE void PfmVizzer:: clear_flat_texcoord_name() { _flat_texcoord_name = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_flat_texcoord_name -// Access: Published -// Description: Returns the flat_texcoord_name. See set_flat_texcoord_name(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flat_texcoord_name. See set_flat_texcoord_name(). + */ INLINE InternalName *PfmVizzer:: get_flat_texcoord_name() const { return _flat_texcoord_name; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_vis_2d -// Access: Published -// Description: Sets the vis_2d flag. When this flag is true, -// only the first two (x, y) value of each depth point -// is considered meaningful; the z component is ignored. -// This is only relevant for generating visualizations. -// -// This may be used in lieu of the lower-level -// add_vis_column(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the vis_2d flag. When this flag is true, only the first two (x, y) + * value of each depth point is considered meaningful; the z component is + * ignored. This is only relevant for generating visualizations. + * + * This may be used in lieu of the lower-level add_vis_column(). + */ INLINE void PfmVizzer:: set_vis_2d(bool vis_2d) { _vis_2d = vis_2d; clear_vis_columns(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_vis_2d -// Access: Published -// Description: Returns the vis_2d flag. See set_vis_2d(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vis_2d flag. See set_vis_2d(). + */ INLINE bool PfmVizzer:: get_vis_2d() const { return _vis_2d; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_keep_beyond_lens -// Access: Published -// Description: Sets the keep_beyond_lens flag. When this flag is -// true, points that fall outside of the normal lens -// range in project() or in add_vis_column() will be -// retained anyway; when it is false, these points will -// be discarded. -//////////////////////////////////////////////////////////////////// +/** + * Sets the keep_beyond_lens flag. When this flag is true, points that fall + * outside of the normal lens range in project() or in add_vis_column() will + * be retained anyway; when it is false, these points will be discarded. + */ INLINE void PfmVizzer:: set_keep_beyond_lens(bool keep_beyond_lens) { _keep_beyond_lens = keep_beyond_lens; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_keep_beyond_lens -// Access: Published -// Description: Returns the keep_beyond_lens flag. See -// set_keep_beyond_lens(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the keep_beyond_lens flag. See set_keep_beyond_lens(). + */ INLINE bool PfmVizzer:: get_keep_beyond_lens() const { return _keep_beyond_lens; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_vis_blend -// Access: Published -// Description: Specifies a blending map--a grayscale image--that -// will be applied to the vertex color during -// generate_vis_mesh() and generate_vis_points(). The -// image size must exactly match the mesh size of the -// PfmVizzer. -// -// Ownership of the pointer is not kept by the PfmVizzer; -// it is your responsibility to ensure it does not -// destruct during the lifetime of the PfmVizzer (or at -// least not before your subsequent call to -// generate_vis_mesh()). -//////////////////////////////////////////////////////////////////// +/** + * Specifies a blending map--a grayscale image--that will be applied to the + * vertex color during generate_vis_mesh() and generate_vis_points(). The + * image size must exactly match the mesh size of the PfmVizzer. + * + * Ownership of the pointer is not kept by the PfmVizzer; it is your + * responsibility to ensure it does not destruct during the lifetime of the + * PfmVizzer (or at least not before your subsequent call to + * generate_vis_mesh()). + */ INLINE void PfmVizzer:: set_vis_blend(const PNMImage *vis_blend) { _vis_blend = vis_blend; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_vis_blend -// Access: Published -// Description: Removes the blending map set by a prior call to -// set_vis_blend(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the blending map set by a prior call to set_vis_blend(). + */ INLINE void PfmVizzer:: clear_vis_blend() { _vis_blend = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_vis_blend -// Access: Published -// Description: Returns the blending map set by the most recent call -// to set_vis_blend(), or NULL if there is no blending -// map in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blending map set by the most recent call to set_vis_blend(), or + * NULL if there is no blending map in effect. + */ INLINE const PNMImage *PfmVizzer:: get_vis_blend() const { return _vis_blend; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::set_aux_pfm -// Access: Published -// Description: Assigns an auxiliary PfmFile to this PfmVizzer. This -// file will be queried by column types -// CT_aux_vertex1/2/3, but has no other meaning to the -// vizzer. This size of this PfmFile should exactly -// match the base PfmFile. No reference count is held -// and no copy is made; the caller is responsible for -// ensuring that the auxiliary PfmFile will persist -// throughout the lifetime of the PfmVizzer it is -// assigned to. -//////////////////////////////////////////////////////////////////// +/** + * Assigns an auxiliary PfmFile to this PfmVizzer. This file will be queried + * by column types CT_aux_vertex1/2/3, but has no other meaning to the vizzer. + * This size of this PfmFile should exactly match the base PfmFile. No + * reference count is held and no copy is made; the caller is responsible for + * ensuring that the auxiliary PfmFile will persist throughout the lifetime of + * the PfmVizzer it is assigned to. + */ INLINE void PfmVizzer:: set_aux_pfm(const PfmFile *pfm) { assert(pfm == NULL || (pfm->get_x_size() == _pfm.get_x_size() && @@ -226,34 +172,27 @@ set_aux_pfm(const PfmFile *pfm) { _aux_pfm = pfm; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::clear_aux_pfm -// Access: Published -// Description: Removes the auxiliary PfmFile from this PfmVizzer. -//////////////////////////////////////////////////////////////////// +/** + * Removes the auxiliary PfmFile from this PfmVizzer. + */ INLINE void PfmVizzer:: clear_aux_pfm() { _aux_pfm = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::get_aux_pfm -// Access: Published -// Description: Returns the reference to the auxiliary PfmFile -// queried by this PfmVizzer. This contains the values -// that will be reflected in CT_aux_vertex3 etc. See -// set_aux_pfm(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference to the auxiliary PfmFile queried by this PfmVizzer. + * This contains the values that will be reflected in CT_aux_vertex3 etc. See + * set_aux_pfm(). + */ INLINE const PfmFile *PfmVizzer:: get_aux_pfm() const { return _aux_pfm; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::VisColumn::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PfmVizzer::VisColumn:: VisColumn() { _undist_lut = NULL; diff --git a/panda/src/grutil/pfmVizzer.cxx b/panda/src/grutil/pfmVizzer.cxx index 1d84cd6331..9bd440a0c3 100644 --- a/panda/src/grutil/pfmVizzer.cxx +++ b/panda/src/grutil/pfmVizzer.cxx @@ -1,16 +1,15 @@ -// Filename: pfmVizzer.cxx -// Created by: drose (30Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmVizzer.cxx + * @author drose + * @date 2012-09-30 + */ #include "pfmVizzer.h" #include "geomNode.h" @@ -24,15 +23,12 @@ #include "pnmImage.h" #include "config_grutil.h" -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::Constructor -// Access: Published -// Description: The PfmVizzer constructor receives a reference to a -// PfmFile which it will operate on. It does not keep -// ownership of this reference; it is your -// responsibility to ensure the PfmFile does not -// destruct during the lifetime of the PfmVizzer. -//////////////////////////////////////////////////////////////////// +/** + * The PfmVizzer constructor receives a reference to a PfmFile which it will + * operate on. It does not keep ownership of this reference; it is your + * responsibility to ensure the PfmFile does not destruct during the lifetime + * of the PfmVizzer. + */ PfmVizzer:: PfmVizzer(PfmFile &pfm) : _pfm(pfm) { _vis_inverse = false; @@ -42,17 +38,13 @@ PfmVizzer(PfmFile &pfm) : _pfm(pfm) { _aux_pfm = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::project -// Access: Published -// Description: Adjusts each (x, y, z) point of the Pfm file by -// projecting it through the indicated lens, converting -// each point to a (u, v, w) texture coordinate. The -// resulting file can be generated to a mesh (with -// set_vis_inverse(true) and generate_vis_mesh()) -// that will apply the lens distortion to an arbitrary -// texture image. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each (x, y, z) point of the Pfm file by projecting it through the + * indicated lens, converting each point to a (u, v, w) texture coordinate. + * The resulting file can be generated to a mesh (with set_vis_inverse(true) + * and generate_vis_mesh()) that will apply the lens distortion to an + * arbitrary texture image. + */ void PfmVizzer:: project(const Lens *lens, const PfmFile *undist_lut) { nassertv(_pfm.is_valid()); @@ -77,8 +69,8 @@ project(const Lens *lens, const PfmFile *undist_lut) { _pfm.set_point4(xi, yi, LVecBase4f(0, 0, 0, 0)); } } else { - // Now the lens gives us coordinates in the range [-1, 1]. - // Rescale these to [0, 1]. + // Now the lens gives us coordinates in the range [-1, 1]. Rescale + // these to [0, 1]. LPoint3f uvw = LCAST(float, film * to_uv); if (undist_lut != NULL) { @@ -95,19 +87,15 @@ project(const Lens *lens, const PfmFile *undist_lut) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::extrude -// Access: Published -// Description: Converts each (u, v, depth) point of the Pfm file to -// an (x, y, z) point, by reversing project(). If the -// original file is only a 1-d file, assumes that it is -// a depth map with implicit (u, v) coordinates. -// -// This method is only valid for a linear lens (e.g. a -// PerspectiveLens or OrthographicLens). Non-linear -// lenses don't necessarily compute a sensible depth -// coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Converts each (u, v, depth) point of the Pfm file to an (x, y, z) point, by + * reversing project(). If the original file is only a 1-d file, assumes that + * it is a depth map with implicit (u, v) coordinates. + * + * This method is only valid for a linear lens (e.g. a PerspectiveLens or + * OrthographicLens). Non-linear lenses don't necessarily compute a sensible + * depth coordinate. + */ void PfmVizzer:: extrude(const Lens *lens) { nassertv(_pfm.is_valid()); @@ -124,9 +112,9 @@ extrude(const Lens *lens) { } if (lens->is_linear()) { - // If the lens is linear (Perspective or Orthographic), we can - // take the slightly faster approach of extruding all the points - // via a transform matrix. + // If the lens is linear (Perspective or Orthographic), we can take the + // slightly faster approach of extruding all the points via a transform + // matrix. const LMatrix4 &proj_mat_inv = lens->get_projection_mat_inv(); if (_pfm.get_num_channels() == 1) { @@ -147,7 +135,7 @@ extrude(const Lens *lens) { p.set(((PN_stdfloat)xi + 0.5) * uv_scale[0], ((PN_stdfloat)yi + 0.5) * uv_scale[1], (PN_stdfloat)_pfm.get_point1(xi, yi)); - + from_uv.xform_point_in_place(p); rp = proj_mat_inv.xform_point_general(p); result.set_point(xi, yi, rp); @@ -162,7 +150,7 @@ extrude(const Lens *lens) { } LPoint3 p, rp; p = LCAST(PN_stdfloat, _pfm.get_point(xi, yi)); - + from_uv.xform_point_in_place(p); rp = proj_mat_inv.xform_point_general(p); result.set_point(xi, yi, rp); @@ -190,7 +178,7 @@ extrude(const Lens *lens) { p.set(((PN_stdfloat)xi + 0.5) * uv_scale[0], ((PN_stdfloat)yi + 0.5) * uv_scale[1], (PN_stdfloat)_pfm.get_point1(xi, yi)); - + from_uv.xform_point_in_place(p); lens->extrude_depth(p, rp); result.set_point(xi, yi, rp); @@ -205,7 +193,7 @@ extrude(const Lens *lens) { } LPoint3 p, rp; p = LCAST(PN_stdfloat, _pfm.get_point(xi, yi)); - + from_uv.xform_point_in_place(p); lens->extrude_depth(p, rp); result.set_point(xi, yi, rp); @@ -217,37 +205,28 @@ extrude(const Lens *lens) { _pfm = result; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::clear_vis_columns -// Access: Published -// Description: Removes all of the previously-added vis columns in -// preparation for building a new list. See -// add_vis_column(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the previously-added vis columns in preparation for building + * a new list. See add_vis_column(). + */ void PfmVizzer:: clear_vis_columns() { _vis_columns.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::add_vis_column -// Access: Published -// Description: Adds a new vis column specification to the list of -// vertex data columns that will be generated at the -// next call to generate_vis_points() or -// generate_vis_mesh(). This advanced interface -// supercedes the higher-level set_vis_inverse(), -// set_flat_texcoord_name(), and set_vis_2d(). -// -// If you use this advanced interface, you must specify -// explicitly the complete list of data columns to be -// created in the resulting GeomVertexData, by calling -// add_vis_column() each time. For each column, you -// specify the source of the column in the PFMFile, the -// target column and name in the GeomVertexData, and an -// optional transform matrix and/or lens to transform -// and project the point before generating it. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vis column specification to the list of vertex data columns that + * will be generated at the next call to generate_vis_points() or + * generate_vis_mesh(). This advanced interface supercedes the higher-level + * set_vis_inverse(), set_flat_texcoord_name(), and set_vis_2d(). + * + * If you use this advanced interface, you must specify explicitly the + * complete list of data columns to be created in the resulting + * GeomVertexData, by calling add_vis_column() each time. For each column, + * you specify the source of the column in the PFMFile, the target column and + * name in the GeomVertexData, and an optional transform matrix and/or lens to + * transform and project the point before generating it. + */ void PfmVizzer:: add_vis_column(ColumnType source, ColumnType target, InternalName *name, const TransformState *transform, @@ -255,14 +234,11 @@ add_vis_column(ColumnType source, ColumnType target, add_vis_column(_vis_columns, source, target, name, transform, lens, undist_lut); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::generate_vis_points -// Access: Published -// Description: Creates a point cloud with the points of the pfm as -// 3-d coordinates in space, and texture coordinates -// ranging from 0 .. 1 based on the position within the -// pfm grid. -//////////////////////////////////////////////////////////////////// +/** + * Creates a point cloud with the points of the pfm as 3-d coordinates in + * space, and texture coordinates ranging from 0 .. 1 based on the position + * within the pfm grid. + */ NodePath PfmVizzer:: generate_vis_points() const { nassertr(_pfm.is_valid(), NodePath()); @@ -275,12 +251,12 @@ generate_vis_points() const { if (_vis_2d) { format = GeomVertexFormat::get_v3t2(); } else { - // We need a 3-d texture coordinate if we're inverting the vis - // and it's 3-d. + // We need a 3-d texture coordinate if we're inverting the vis and it's + // 3-d. GeomVertexArrayFormat *v3t3 = new GeomVertexArrayFormat - (InternalName::get_vertex(), 3, + (InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point, - InternalName::get_texcoord(), 3, + InternalName::get_texcoord(), 3, Geom::NT_stdfloat, Geom::C_texcoord); format = GeomVertexFormat::register_format(v3t3); } @@ -328,25 +304,22 @@ generate_vis_points() const { ++num_points; } } - + PT(Geom) geom = new Geom(vdata); PT(GeomPoints) points = new GeomPoints(Geom::UH_static); points->add_next_vertices(num_points); geom->add_primitive(points); - + PT(GeomNode) gnode = new GeomNode(""); gnode->add_geom(geom); return NodePath(gnode); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::generate_vis_mesh -// Access: Published -// Description: Creates a triangle mesh with the points of the pfm as -// 3-d coordinates in space, and texture coordinates -// ranging from 0 .. 1 based on the position within the -// pfm grid. -//////////////////////////////////////////////////////////////////// +/** + * Creates a triangle mesh with the points of the pfm as 3-d coordinates in + * space, and texture coordinates ranging from 0 .. 1 based on the position + * within the pfm grid. + */ NodePath PfmVizzer:: generate_vis_mesh(MeshFace face) const { nassertr(_pfm.is_valid(), NodePath()); @@ -355,21 +328,20 @@ generate_vis_mesh(MeshFace face) const { nassertr(face != 0, NodePath()); if (_pfm.get_num_channels() == 1 && _vis_columns.empty()) { - // If we're generating a default mesh from a one-channel pfm file, - // expand it to a three-channel pfm file to make the visualization - // useful. + // If we're generating a default mesh from a one-channel pfm file, expand + // it to a three-channel pfm file to make the visualization useful. PfmFile expanded; expanded.clear_to_texcoords(_pfm.get_x_size(), _pfm.get_y_size()); expanded.copy_channel(2, _pfm, 0); PfmVizzer exvizzer(expanded); return exvizzer.generate_vis_mesh(face); } - + if (_pfm.get_x_size() == 1 || _pfm.get_y_size() == 1) { // Can't generate a 1-d mesh, so generate points in this case. return generate_vis_points(); } - + PT(GeomNode) gnode = new GeomNode(""); if (face & MF_front) { @@ -384,14 +356,11 @@ generate_vis_mesh(MeshFace face) const { } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::calc_max_u_displacement -// Access: Published -// Description: Computes the maximum amount of shift, in pixels -// either left or right, of any pixel in the distortion -// map. This can be passed to make_displacement(); see -// that function for more information. -//////////////////////////////////////////////////////////////////// +/** + * Computes the maximum amount of shift, in pixels either left or right, of + * any pixel in the distortion map. This can be passed to + * make_displacement(); see that function for more information. + */ double PfmVizzer:: calc_max_u_displacement() const { int x_size = _pfm.get_x_size(); @@ -415,14 +384,11 @@ calc_max_u_displacement() const { return max_u; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::calc_max_v_displacement -// Access: Published -// Description: Computes the maximum amount of shift, in pixels -// either up or down, of any pixel in the distortion -// map. This can be passed to make_displacement(); see -// that function for more information. -//////////////////////////////////////////////////////////////////// +/** + * Computes the maximum amount of shift, in pixels either up or down, of any + * pixel in the distortion map. This can be passed to make_displacement(); + * see that function for more information. + */ double PfmVizzer:: calc_max_v_displacement() const { int x_size = _pfm.get_x_size(); @@ -446,32 +412,24 @@ calc_max_v_displacement() const { return max_v; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::make_displacement -// Access: Published -// Description: Assuming the underlying PfmFile is a 2-d distortion -// mesh, with the U and V in the first two components -// and the third component unused, this computes an -// AfterEffects-style displacement map that represents -// the same distortion. The indicated PNMImage will be -// filled in with a displacement map image, with -// horizontal shift in the red channel and vertical -// shift in the green channel, where a fully bright (or -// fully black) pixel indicates a shift of max_u or -// max_v pixels. -// -// Use calc_max_u_displacement() and -// calc_max_v_displacement() to compute suitable values -// for max_u and max_v. -// -// This generates an integer 16-bit displacement image. -// It is a good idea, though not necessarily essential, -// to check "Preserve RGB" in the interpret footage -// section for each displacement image. Set -// for_32bit true if this is meant to be used in a -// 32-bit project file, and false if it is meant to be -// used in a 16-bit project file. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the underlying PfmFile is a 2-d distortion mesh, with the U and V + * in the first two components and the third component unused, this computes + * an AfterEffects-style displacement map that represents the same distortion. + * The indicated PNMImage will be filled in with a displacement map image, + * with horizontal shift in the red channel and vertical shift in the green + * channel, where a fully bright (or fully black) pixel indicates a shift of + * max_u or max_v pixels. + * + * Use calc_max_u_displacement() and calc_max_v_displacement() to compute + * suitable values for max_u and max_v. + * + * This generates an integer 16-bit displacement image. It is a good idea, + * though not necessarily essential, to check "Preserve RGB" in the interpret + * footage section for each displacement image. Set for_32bit true if this is + * meant to be used in a 32-bit project file, and false if it is meant to be + * used in a 16-bit project file. + */ void PfmVizzer:: make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) const { int x_size = _pfm.get_x_size(); @@ -479,21 +437,19 @@ make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) result.clear(x_size, y_size, 3, PNM_MAXMAXVAL); result.fill_val(0, 0, PNM_MAXMAXVAL); - // After Effects defines this as the zero (no-change) value. It's - // not exactly 0.5, because they round up. + // After Effects defines this as the zero (no-change) value. It's not + // exactly 0.5, because they round up. static const int midval = (PNM_MAXMAXVAL + 1) / 2; double scale_factor; if (for_32bit) { - // There doesn't appear to be an undershift needed on 32-bit - // projects, but we have the factor here anyway in case it - // develops. + // There doesn't appear to be an undershift needed on 32-bit projects, but + // we have the factor here anyway in case it develops. scale_factor = ae_undershift_factor_32; } else { - // Empirically, After Effects seems to undershift by precisely - // this amount (but only in a 16-bit project, not in a 32-bit - // project). Curiously, this value is very close to, but not - // exactly, 256 / 255. + // Empirically, After Effects seems to undershift by precisely this amount + // (but only in a 16-bit project, not in a 32-bit project). Curiously, + // this value is very close to, but not exactly, 256 255. scale_factor = ae_undershift_factor_16; } @@ -516,11 +472,10 @@ make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) int u_val = midval + (int)cfloor(x_shift * u_scale + 0.5); int v_val = midval + (int)cfloor(y_shift * v_scale + 0.5); - // We use the blue channel to mark holes, so we can fill them in - // later. - result.set_xel_val(xi, yi, - min(max(u_val, 0), PNM_MAXMAXVAL), - min(max(v_val, 0), PNM_MAXMAXVAL), + // We use the blue channel to mark holes, so we can fill them in later. + result.set_xel_val(xi, yi, + min(max(u_val, 0), PNM_MAXMAXVAL), + min(max(v_val, 0), PNM_MAXMAXVAL), 0); } } @@ -551,31 +506,24 @@ make_displacement(PNMImage &result, double max_u, double max_v, bool for_32bit) } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::make_displacement -// Access: Published -// Description: Assuming the underlying PfmFile is a 2-d distortion -// mesh, with the U and V in the first two components -// and the third component unused, this computes an -// AfterEffects-style displacement map that represents -// the same distortion. The indicated PNMImage will be -// filled in with a displacement map image, with -// horizontal shift in the red channel and vertical -// shift in the green channel, where a fully bright (or -// fully black) pixel indicates a shift of max_u or -// max_v pixels. -// -// Use calc_max_u_displacement() and -// calc_max_v_displacement() to compute suitable values -// for max_u and max_v. -// -// This generates a 32-bit floating-point displacement -// image. It is essential to check "Preserve RGB" in -// the interpret footage section for each displacement -// image. Set for_32bit true if this is meant to -// be used in a 32-bit project file, and false if it is -// meant to be used in a 16-bit project file. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the underlying PfmFile is a 2-d distortion mesh, with the U and V + * in the first two components and the third component unused, this computes + * an AfterEffects-style displacement map that represents the same distortion. + * The indicated PNMImage will be filled in with a displacement map image, + * with horizontal shift in the red channel and vertical shift in the green + * channel, where a fully bright (or fully black) pixel indicates a shift of + * max_u or max_v pixels. + * + * Use calc_max_u_displacement() and calc_max_v_displacement() to compute + * suitable values for max_u and max_v. + * + * This generates a 32-bit floating-point displacement image. It is essential + * to check "Preserve RGB" in the interpret footage section for each + * displacement image. Set for_32bit true if this is meant to be used in a + * 32-bit project file, and false if it is meant to be used in a 16-bit + * project file. + */ void PfmVizzer:: make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) const { int x_size = _pfm.get_x_size(); @@ -584,15 +532,13 @@ make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) c double scale_factor; if (for_32bit) { - // There doesn't appear to be an undershift needed on 32-bit - // projects, but we have the factor here anyway in case it - // develops. + // There doesn't appear to be an undershift needed on 32-bit projects, but + // we have the factor here anyway in case it develops. scale_factor = ae_undershift_factor_32; } else { - // Empirically, After Effects seems to undershift by precisely - // this amount (but only in a 16-bit project, not in a 32-bit - // project). Curiously, this value is very close to, but not - // exactly, 256 / 255. + // Empirically, After Effects seems to undershift by precisely this amount + // (but only in a 16-bit project, not in a 32-bit project). Curiously, + // this value is very close to, but not exactly, 256 255. scale_factor = ae_undershift_factor_16; } @@ -615,8 +561,7 @@ make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) c float u_val = 0.5 + (float)(x_shift * u_scale); float v_val = 0.5 + (float)(y_shift * v_scale); - // We use the blue channel to mark holes, so we can fill them in - // later. + // We use the blue channel to mark holes, so we can fill them in later. result.set_point3(xi, yi, LVecBase3f(u_val, v_val, 0)); } } @@ -647,12 +592,10 @@ make_displacement(PfmFile &result, double max_u, double max_v, bool for_32bit) c } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::uses_aux_pfm -// Access: Private -// Description: Returns true if any of the vis_column tokens -// reference the aux_pfm file, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the vis_column tokens reference the aux_pfm file, + * false otherwise. + */ bool PfmVizzer:: uses_aux_pfm() const { for (VisColumns::const_iterator vci = _vis_columns.begin(); @@ -672,16 +615,13 @@ uses_aux_pfm() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::r_fill_displacement -// Access: Private -// Description: Recursively fills in holes with the color of their -// nearest neighbor after processing the image. This -// avoids sudden discontinuities in the displacement map -// at the edge of the screen geometry. -//////////////////////////////////////////////////////////////////// +/** + * Recursively fills in holes with the color of their nearest neighbor after + * processing the image. This avoids sudden discontinuities in the + * displacement map at the edge of the screen geometry. + */ void PfmVizzer:: -r_fill_displacement(PNMImage &result, int xi, int yi, +r_fill_displacement(PNMImage &result, int xi, int yi, double nxi, double nyi, double u_scale, double v_scale, int distance) const { if (xi < 0 || yi < 0 || @@ -704,9 +644,9 @@ r_fill_displacement(PNMImage &result, int xi, int yi, double y_shift = (nyi - (double)yi); int u_val = midval + (int)cfloor(x_shift * u_scale + 0.5); int v_val = midval + (int)cfloor(y_shift * v_scale + 0.5); - result.set_xel_val(xi, yi, - min(max(u_val, 0), PNM_MAXMAXVAL), - min(max(v_val, 0), PNM_MAXMAXVAL), + result.set_xel_val(xi, yi, + min(max(u_val, 0), PNM_MAXMAXVAL), + min(max(v_val, 0), PNM_MAXMAXVAL), min(distance, PNM_MAXMAXVAL)); r_fill_displacement(result, xi - 1, yi, nxi, nyi, u_scale, v_scale, distance + 1); @@ -716,16 +656,13 @@ r_fill_displacement(PNMImage &result, int xi, int yi, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::r_fill_displacement -// Access: Private -// Description: Recursively fills in holes with the color of their -// nearest neighbor after processing the image. This -// avoids sudden discontinuities in the displacement map -// at the edge of the screen geometry. -//////////////////////////////////////////////////////////////////// +/** + * Recursively fills in holes with the color of their nearest neighbor after + * processing the image. This avoids sudden discontinuities in the + * displacement map at the edge of the screen geometry. + */ void PfmVizzer:: -r_fill_displacement(PfmFile &result, int xi, int yi, +r_fill_displacement(PfmFile &result, int xi, int yi, double nxi, double nyi, double u_scale, double v_scale, int distance) const { if (xi < 0 || yi < 0 || @@ -755,12 +692,10 @@ r_fill_displacement(PfmFile &result, int xi, int yi, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::make_vis_mesh_geom -// Access: Private -// Description: Returns a triangle mesh for the pfm. If inverted is -// true, the mesh is facing the opposite direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns a triangle mesh for the pfm. If inverted is true, the mesh is + * facing the opposite direction. + */ void PfmVizzer:: make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { static const bool keep_beyond_lens = true; @@ -784,13 +719,12 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { } // This is the max number of vertex indices we might add to the - // GeomTriangles. (We might actually add fewer than this due to - // omitting the occasional missing data point.) + // GeomTriangles. (We might actually add fewer than this due to omitting + // the occasional missing data point.) int max_indices = (x_size - 1) * (y_size - 1) * 6; while (num_vertices > pfm_vis_max_vertices || max_indices > pfm_vis_max_indices) { - // Too many vertices in one mesh. Subdivide the mesh into smaller - // pieces. + // Too many vertices in one mesh. Subdivide the mesh into smaller pieces. if (num_x_cells > num_y_cells) { ++num_y_cells; } else { @@ -823,8 +757,8 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { int y_begin = (yci * _pfm.get_y_size()) / num_y_cells; int y_end = ((yci + 1) * _pfm.get_y_size()) / num_y_cells; - // Include the first vertex from the next strip in this strip's - // vertices, so we are connected. + // Include the first vertex from the next strip in this strip's vertices, + // so we are connected. y_end = min(y_end + 1, _pfm.get_y_size()); y_size = y_end - y_begin; @@ -870,7 +804,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { } } } - + PT(Geom) geom = new Geom(vdata); PT(GeomTriangles) tris = new GeomTriangles(Geom::UH_static); @@ -891,7 +825,7 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { !_aux_pfm->has_point(xi + 1, yi))) { continue; } - + if (!keep_beyond_lens && (skip_points[(yi - y_begin) * x_size + (xi - x_begin)] || skip_points[(yi - y_begin + 1) * x_size + (xi - x_begin)] || @@ -907,17 +841,17 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { int vi1 = ((xi0) + (yi0 + 1) * x_size); int vi2 = ((xi0 + 1) + (yi0 + 1) * x_size); int vi3 = ((xi0 + 1) + (yi0) * x_size); - + if (reverse_faces) { tris->add_vertices(vi2, vi0, vi1); tris->close_primitive(); - + tris->add_vertices(vi3, vi0, vi2); tris->close_primitive(); } else { tris->add_vertices(vi2, vi1, vi0); tris->close_primitive(); - + tris->add_vertices(vi3, vi2, vi0); tris->close_primitive(); } @@ -931,13 +865,10 @@ make_vis_mesh_geom(GeomNode *gnode, bool inverted) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::add_vis_column -// Access: Private, Static -// Description: The private implementation of the public -// add_vis_column(), this adds the column to the -// indicated specific vector. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of the public add_vis_column(), this adds the + * column to the indicated specific vector. + */ void PfmVizzer:: add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, InternalName *name, const TransformState *transform, @@ -957,15 +888,12 @@ add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, vis_columns.push_back(column); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::build_auto_vis_columns -// Access: Private -// Description: This function is called internally to construct the -// list of vis_columns automatically from the high-level -// interfaces such as set_vis_inverse(), -// set_flat_texcoord_name(), and set_vis_2d(). It's not -// called if the list has been build explicitly. -//////////////////////////////////////////////////////////////////// +/** + * This function is called internally to construct the list of vis_columns + * automatically from the high-level interfaces such as set_vis_inverse(), + * set_flat_texcoord_name(), and set_vis_2d(). It's not called if the list + * has been build explicitly. + */ void PfmVizzer:: build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const { vis_columns.clear(); @@ -982,13 +910,13 @@ build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const { } else { if (_vis_inverse) { - // We need a 3-d texture coordinate if we're inverting the vis - // and it's 3-d. But we still don't need normals in that case. + // We need a 3-d texture coordinate if we're inverting the vis and it's + // 3-d. But we still don't need normals in that case. add_vis_column(vis_columns, CT_texcoord3, CT_vertex3, InternalName::get_vertex()); add_vis_column(vis_columns, CT_vertex3, CT_texcoord3, InternalName::get_texcoord()); } else { - // Otherwise, we only need a 2-d texture coordinate, and we do - // want normals. + // Otherwise, we only need a 2-d texture coordinate, and we do want + // normals. add_vis_column(vis_columns, CT_vertex3, CT_vertex3, InternalName::get_vertex()); add_vis_column(vis_columns, CT_normal3, CT_normal3, InternalName::get_normal()); add_vis_column(vis_columns, CT_texcoord2, CT_texcoord2, InternalName::get_texcoord()); @@ -1006,12 +934,9 @@ build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::make_array_format -// Access: Private -// Description: Constructs a GeomVertexFormat that corresponds to the -// vis_columns list. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a GeomVertexFormat that corresponds to the vis_columns list. + */ CPT(GeomVertexFormat) PfmVizzer:: make_array_format(const VisColumns &vis_columns) const { PT(GeomVertexArrayFormat) array_format = new GeomVertexArrayFormat; @@ -1079,13 +1004,10 @@ make_array_format(const VisColumns &vis_columns) const { return GeomVertexFormat::register_format(array_format); } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::VisColumn::add_data -// Access: Public -// Description: Adds the data for this column to the appropriate -// column of the GeomVertexWriter. Returns true if the -// point is valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Adds the data for this column to the appropriate column of the + * GeomVertexWriter. Returns true if the point is valid, false otherwise. + */ bool PfmVizzer::VisColumn:: add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, bool reverse_normals) const { const PfmFile &pfm = vizzer.get_pfm(); @@ -1093,7 +1015,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo switch (_source) { case CT_texcoord2: - { + { LPoint2f uv((PN_float32(xi) + 0.5) / PN_float32(pfm.get_x_size()), (PN_float32(yi) + 0.5) / PN_float32(pfm.get_y_size())); if (!transform_point(uv)) { @@ -1106,7 +1028,7 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo case CT_texcoord3: { LPoint3f uv((PN_float32(xi) + 0.5) / PN_float32(pfm.get_x_size()), - (PN_float32(yi) + 0.5) / PN_float32(pfm.get_y_size()), + (PN_float32(yi) + 0.5) / PN_float32(pfm.get_y_size()), 0.0f); if (!transform_point(uv)) { success = false; @@ -1194,14 +1116,14 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo v[1] = pfm.get_point(xi - 1, yi); flip = !flip; } - + if (pfm.has_point(xi, yi + 1)) { v[2] = pfm.get_point(xi, yi + 1); } else if (pfm.has_point(xi, yi - 1)) { v[2] = pfm.get_point(xi, yi - 1); flip = !flip; } - + LVector3f n = LVector3f::zero(); for (int i = 0; i < 3; ++i) { const LPoint3f &v0 = v[i]; @@ -1245,12 +1167,9 @@ add_data(const PfmVizzer &vizzer, GeomVertexWriter &vwriter, int xi, int yi, boo return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::VisColumn::transform_point -// Access: Public -// Description: Transforms the indicated point as specified by the -// VisColumn. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point as specified by the VisColumn. + */ bool PfmVizzer::VisColumn:: transform_point(LPoint2f &point) const { bool success = true; @@ -1261,12 +1180,9 @@ transform_point(LPoint2f &point) const { return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::VisColumn::transform_point -// Access: Public -// Description: Transforms the indicated point as specified by the -// VisColumn. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated point as specified by the VisColumn. + */ bool PfmVizzer::VisColumn:: transform_point(LPoint3f &point) const { bool success = true; @@ -1275,8 +1191,8 @@ transform_point(LPoint3f &point) const { } if (_lens != (Lens *)NULL) { static LMatrix4f to_uv(0.5, 0.0, 0.0, 0.0, - 0.0, 0.5, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, + 0.0, 0.5, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, 0.5, 0.5, 0.0, 1.0); LPoint3 film; if (!_lens->project(LCAST(PN_stdfloat, point), film)) { @@ -1300,12 +1216,9 @@ transform_point(LPoint3f &point) const { return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmVizzer::VisColumn::transform_vector -// Access: Public -// Description: Transforms the indicated vector as specified by the -// VisColumn. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated vector as specified by the VisColumn. + */ bool PfmVizzer::VisColumn:: transform_vector(LVector3f &vec) const { if (!_transform->is_identity()) { diff --git a/panda/src/grutil/pfmVizzer.h b/panda/src/grutil/pfmVizzer.h index e19c72091d..7b466f0ee3 100644 --- a/panda/src/grutil/pfmVizzer.h +++ b/panda/src/grutil/pfmVizzer.h @@ -1,16 +1,15 @@ -// Filename: pfmVizzer.h -// Created by: drose (30Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmVizzer.h + * @author drose + * @date 2012-09-30 + */ #ifndef PFMVIZZER_H #define PFMVIZZER_H @@ -25,11 +24,9 @@ class GeomNode; class Lens; class GeomVertexWriter; -//////////////////////////////////////////////////////////////////// -// Class : PfmVizzer -// Description : This class aids in the visualization and manipulation -// of PfmFile objects. -//////////////////////////////////////////////////////////////////// +/** + * This class aids in the visualization and manipulation of PfmFile objects. + */ class EXPCL_PANDA_GRUTIL PfmVizzer { PUBLISHED: PfmVizzer(PfmFile &pfm); @@ -71,7 +68,7 @@ PUBLISHED: }; void clear_vis_columns(); void add_vis_column(ColumnType source, ColumnType target, - InternalName *name, + InternalName *name, const TransformState *transform = NULL, const Lens *lens = NULL, const PfmFile *undist_lut = NULL); @@ -91,10 +88,10 @@ PUBLISHED: private: bool uses_aux_pfm() const; - void r_fill_displacement(PNMImage &result, int xi, int yi, + void r_fill_displacement(PNMImage &result, int xi, int yi, double nxi, double nyi, double u_scale, double v_scale, int distance) const; - void r_fill_displacement(PfmFile &result, int xi, int yi, + void r_fill_displacement(PfmFile &result, int xi, int yi, double nxi, double nyi, double u_scale, double v_scale, int distance) const; @@ -119,9 +116,9 @@ private: }; typedef pvector VisColumns; - static void add_vis_column(VisColumns &vis_columns, + static void add_vis_column(VisColumns &vis_columns, ColumnType source, ColumnType target, - InternalName *name, + InternalName *name, const TransformState *transform = NULL, const Lens *lens = NULL, const PfmFile *undist_lut = NULL); void build_auto_vis_columns(VisColumns &vis_columns, bool for_points) const; @@ -145,4 +142,3 @@ private: #include "pfmVizzer.I" #endif - diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.I b/panda/src/grutil/pipeOcclusionCullTraverser.I index 67e575714a..d5e8685afd 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.I +++ b/panda/src/grutil/pipeOcclusionCullTraverser.I @@ -1,72 +1,57 @@ -// Filename: pipeOcclusionCullTraverser.I -// Created by: drose (29May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeOcclusionCullTraverser.I + * @author drose + * @date 2007-05-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::get_buffer -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GraphicsOutput *PipeOcclusionCullTraverser:: get_buffer() const { return _buffer; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::set_occlusion_mask -// Access: Public -// Description: Specifies the DrawMask that should be set on -// occlusion polygons for this scene. This identifies -// the polygons that are to be treated as occluders. -// Polygons that do not have this draw mask set will not -// be considered occluders. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the DrawMask that should be set on occlusion polygons for this + * scene. This identifies the polygons that are to be treated as occluders. + * Polygons that do not have this draw mask set will not be considered + * occluders. + */ INLINE void PipeOcclusionCullTraverser:: set_occlusion_mask(const DrawMask &occlusion_mask) { _occlusion_mask = occlusion_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::get_occlusion_mask -// Access: Public -// Description: Returns the DrawMask for occlusion polygons. See -// set_occlusion_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the DrawMask for occlusion polygons. See set_occlusion_mask(). + */ INLINE const DrawMask &PipeOcclusionCullTraverser:: get_occlusion_mask() const { return _occlusion_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::PendingObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipeOcclusionCullTraverser::PendingObject:: PendingObject(CullableObject *object) : _object(object) { } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::PendingObject::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipeOcclusionCullTraverser::PendingObject:: ~PendingObject() { // Tempting as it is, we shouldn't delete the CullableObject in the - // destructor, since it has already been deleted. - // delete _object; + // destructor, since it has already been deleted. delete _object; } diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.cxx b/panda/src/grutil/pipeOcclusionCullTraverser.cxx index 3ade43d8f0..ca4316c5cc 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.cxx +++ b/panda/src/grutil/pipeOcclusionCullTraverser.cxx @@ -1,16 +1,15 @@ -// Filename: pipeOcclusionCullTraverser.cxx -// Created by: drose (29May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeOcclusionCullTraverser.cxx + * @author drose + * @date 2007-05-29 + */ #include "pipeOcclusionCullTraverser.h" #include "graphicsEngine.h" @@ -73,11 +72,9 @@ static ConfigVariableInt occlusion_depth_bits PRC_DESC("The minimum number of depth bits requested for the occlusion " "buffer.")); -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PipeOcclusionCullTraverser:: PipeOcclusionCullTraverser(GraphicsOutput *host) { _live = false; @@ -108,8 +105,8 @@ PipeOcclusionCullTraverser(GraphicsOutput *host) { gsg, host->get_host()); nassertv(_buffer != (GraphicsOutput *)NULL); - // This buffer isn't really active--we render it by hand; we don't - // want the GraphicsEngine to render it. + // This buffer isn't really active--we render it by hand; we don't want the + // GraphicsEngine to render it. _buffer->set_active(0); _display_region = _buffer->make_display_region(); @@ -122,11 +119,9 @@ PipeOcclusionCullTraverser(GraphicsOutput *host) { _live = true; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PipeOcclusionCullTraverser:: PipeOcclusionCullTraverser(const PipeOcclusionCullTraverser ©) : CullTraverser(copy) @@ -134,11 +129,9 @@ PipeOcclusionCullTraverser(const PipeOcclusionCullTraverser ©) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::set_scene -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PipeOcclusionCullTraverser:: set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, bool dr_incomplete_render) { @@ -171,8 +164,8 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, if (_scene->get_cull_center() != _scene->get_camera_path()) { // This camera has a special cull center set. For the purposes of - // occlusion culling, we want to render the scene from the cull - // center, not from the camera root. + // occlusion culling, we want to render the scene from the cull center, + // not from the camera root. NodePath cull_center = _scene->get_cull_center(); NodePath scene_parent = _scene->get_scene_root().get_parent(current_thread); CPT(TransformState) camera_transform = cull_center.get_transform(scene_parent, current_thread); @@ -196,9 +189,9 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, return; } - // Hijack the default cull handler so we can perform all of the - // occlusion tests on a per-object basis, and then query the results - // at the end of the traversal. + // Hijack the default cull handler so we can perform all of the occlusion + // tests on a per-object basis, and then query the results at the end of the + // traversal. _true_cull_handler = get_cull_handler(); set_cull_handler(this); @@ -217,13 +210,10 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsgbase, _internal_trav->traverse(_scene->get_scene_root()); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::end_traverse -// Access: Public, Virtual -// Description: Should be called when the traverser has finished -// traversing its scene, this gives it a chance to do -// any necessary finalization. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the traverser has finished traversing its scene, this + * gives it a chance to do any necessary finalization. + */ void PipeOcclusionCullTraverser:: end_traverse() { if (!_live) { @@ -278,12 +268,10 @@ end_traverse() { _occlusion_tests_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::get_texture -// Access: Published -// Description: Returns a Texture that can be used to visualize the -// efforts of the occlusion cull. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Texture that can be used to visualize the efforts of the + * occlusion cull. + */ Texture *PipeOcclusionCullTraverser:: get_texture() { if (_texture != (Texture *)NULL) { @@ -305,11 +293,9 @@ get_texture() { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::is_in_view -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PipeOcclusionCullTraverser:: is_in_view(CullTraverserData &data) { _next_query = NULL; @@ -322,8 +308,8 @@ is_in_view(CullTraverserData &data) { } if (_current_query != (OcclusionQueryContext *)NULL) { - // We've already performed an occlusion test for some ancestor of - // this node; no need to perform another. + // We've already performed an occlusion test for some ancestor of this + // node; no need to perform another. return true; } @@ -356,17 +342,14 @@ is_in_view(CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::traverse_below -// Access: Public, Virtual -// Description: Traverses all the children of the indicated node, -// with the given data, which has been converted into -// the node's space. -//////////////////////////////////////////////////////////////////// +/** + * Traverses all the children of the indicated node, with the given data, + * which has been converted into the node's space. + */ void PipeOcclusionCullTraverser:: traverse_below(CullTraverserData &data) { - // Save and restore _current_query, and clear _next_query, for - // traversing the children of this node. + // Save and restore _current_query, and clear _next_query, for traversing + // the children of this node. PT(OcclusionQueryContext) prev_query = _current_query; if (_next_query != (OcclusionQueryContext *)NULL) { _current_query = _next_query; @@ -379,21 +362,16 @@ traverse_below(CullTraverserData &data) { _next_query = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::record_object -// Access: Protected, Virtual -// Description: This callback function is intended to be overridden -// by a derived class. This is called as each Geom is -// discovered by the CullTraverser. -// -// We do a sneaky trick in making -// PipeOcclusionCullTraverser inherit from both -// CullTraverser and CullHandler--the traverser is its -// own handler! This is the normal callback into the -// traverser for rendering objects. We respond to this -// by firing off an occlusion test, and queuing up the -// object until the end of the scene. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is intended to be overridden by a derived class. + * This is called as each Geom is discovered by the CullTraverser. + * + * We do a sneaky trick in making PipeOcclusionCullTraverser inherit from both + * CullTraverser and CullHandler--the traverser is its own handler! This is + * the normal callback into the traverser for rendering objects. We respond + * to this by firing off an occlusion test, and queuing up the object until + * the end of the scene. + */ void PipeOcclusionCullTraverser:: record_object(CullableObject *object, const CullTraverser *traverser) { nassertv(traverser == this); @@ -402,13 +380,13 @@ record_object(CullableObject *object, const CullTraverser *traverser) { Thread *current_thread = get_current_thread(); if (_next_query != (OcclusionQueryContext *)NULL) { - // We have just performed an occlusion query for this node. Don't - // perform another one. + // We have just performed an occlusion query for this node. Don't perform + // another one. pobj._query = _next_query; } else if (_current_query != (OcclusionQueryContext *)NULL) { - // We have previously performed an occlusion query for this node - // or some ancestor. Don't perform another one. + // We have previously performed an occlusion query for this node or some + // ancestor. Don't perform another one. pobj._query = _current_query; } else if (object->_geom->get_nested_vertices(current_thread) < min_occlusion_vertices) { @@ -429,19 +407,15 @@ record_object(CullableObject *object, const CullTraverser *traverser) { _pending_objects.push_back(pobj); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::make_sphere -// Access: Private -// Description: Constructs a unit sphere for testing visibility of -// bounding spheres. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a unit sphere for testing visibility of bounding spheres. + */ void PipeOcclusionCullTraverser:: make_sphere() { ConfigVariableInt num_slices("num-slices", 16); ConfigVariableInt num_stacks("num-stacks", 8); - // static const int num_slices = 16; - // static const int num_stacks = 8; + // static const int num_slices = 16; static const int num_stacks = 8; PT(GeomVertexData) vdata = new GeomVertexData ("occlusion_sphere", GeomVertexFormat::get_v3(), Geom::UH_static); @@ -467,12 +441,10 @@ make_sphere() { _sphere_geom->add_primitive(strip); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::compute_sphere_point -// Access: Private, Static -// Description: Returns a point on the surface of the unit sphere. -// latitude and longitude range from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a point on the surface of the unit sphere. latitude and longitude + * range from 0.0 to 1.0. + */ LVertex PipeOcclusionCullTraverser:: compute_sphere_point(PN_stdfloat latitude, PN_stdfloat longitude) { PN_stdfloat s1, c1; @@ -485,12 +457,9 @@ compute_sphere_point(PN_stdfloat latitude, PN_stdfloat longitude) { return p; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::make_box -// Access: Private -// Description: Constructs a unit box for testing visibility of -// bounding boxes. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a unit box for testing visibility of bounding boxes. + */ void PipeOcclusionCullTraverser:: make_box() { PT(GeomVertexData) vdata = new GeomVertexData @@ -536,12 +505,10 @@ make_box() { _box_geom->add_primitive(tris); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::make_solid_test_state -// Access: Private -// Description: Creates the RenderState appropriate to rendering the -// occlusion test geometry invisibly. -//////////////////////////////////////////////////////////////////// +/** + * Creates the RenderState appropriate to rendering the occlusion test + * geometry invisibly. + */ void PipeOcclusionCullTraverser:: make_solid_test_state() { _solid_test_state = RenderState::make @@ -550,22 +517,17 @@ make_solid_test_state() { ColorWriteAttrib::make(ColorWriteAttrib::C_off)); } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::get_volume_viz -// Access: Private -// Description: Chooses a suitable Geom to render the indicated -// bounding volume, and fills geom and local_transform -// with the appropriate values. Returns true if the -// bounding volume can be rendered, false if there is no -// suitable visualization for it. -// -// On entry, net_transform should be filled with the net -// transform to the bounding volume. On exit (when -// return value is true), it will be composed with a -// suitable local transform to render the bounding -// volume properly, and internal_transform will also be -// filled with the appropriate transform. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a suitable Geom to render the indicated bounding volume, and fills + * geom and local_transform with the appropriate values. Returns true if the + * bounding volume can be rendered, false if there is no suitable + * visualization for it. + * + * On entry, net_transform should be filled with the net transform to the + * bounding volume. On exit (when return value is true), it will be composed + * with a suitable local transform to render the bounding volume properly, and + * internal_transform will also be filled with the appropriate transform. + */ bool PipeOcclusionCullTraverser:: get_volume_viz(const BoundingVolume *vol, CPT(Geom) &geom, // OUT @@ -587,10 +549,10 @@ get_volume_viz(const BoundingVolume *vol, CPT(TransformState) modelview_transform = _internal_trav->get_world_transform()->compose(net_transform); - // See if the bounding sphere is clipped by the near plane. If it - // is, the occlusion test may fail, so we won't bother performing - // it for this object. Anyway, it's not occluded by anything, - // since it's intersecting the near plane. + // See if the bounding sphere is clipped by the near plane. If it is, the + // occlusion test may fail, so we won't bother performing it for this + // object. Anyway, it's not occluded by anything, since it's intersecting + // the near plane. const LPoint3 ¢er = modelview_transform->get_pos(); const LVecBase3 &radius = modelview_transform->get_scale(); if (center[1] - radius[1] < 0.0f) { @@ -616,10 +578,10 @@ get_volume_viz(const BoundingVolume *vol, CPT(TransformState) modelview_transform = _internal_trav->get_world_transform()->compose(net_transform); - // See if the bounding box is clipped by the near plane. If it - // is, the occlusion test may fail, so we won't bother performing - // it for this object. Anyway, it's not occluded by anything, - // since it's intersecting the near plane. + // See if the bounding box is clipped by the near plane. If it is, the + // occlusion test may fail, so we won't bother performing it for this + // object. Anyway, it's not occluded by anything, since it's intersecting + // the near plane. static const LPoint3 points[8] = { LPoint3(0.0f, 0.0f, 0.0f), LPoint3(0.0f, 0.0f, 1.0f), @@ -651,12 +613,10 @@ get_volume_viz(const BoundingVolume *vol, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::perform_occlusion_test -// Access: Private -// Description: Renders the indicated geometry in the internal scene -// to test its visibility. -//////////////////////////////////////////////////////////////////// +/** + * Renders the indicated geometry in the internal scene to test its + * visibility. + */ PT(OcclusionQueryContext) PipeOcclusionCullTraverser:: perform_occlusion_test(const Geom *geom, const TransformState *net_transform, const TransformState *internal_transform) { @@ -680,10 +640,9 @@ perform_occlusion_test(const Geom *geom, const TransformState *net_transform, PT(OcclusionQueryContext) query = gsg->end_occlusion_query(); if (show_occlusion) { - // Show the results of the occlusion. To do this, we need to get - // the results of the query immediately. This will stall the - // pipe, but we're rendering a debug effect, so we don't mind too - // much. + // Show the results of the occlusion. To do this, we need to get the + // results of the query immediately. This will stall the pipe, but we're + // rendering a debug effect, so we don't mind too much. int num_fragments = query->get_num_fragments(); show_results(num_fragments, geom, net_transform, internal_transform); } @@ -691,12 +650,10 @@ perform_occlusion_test(const Geom *geom, const TransformState *net_transform, return query; } -//////////////////////////////////////////////////////////////////// -// Function: PipeOcclusionCullTraverser::show_results -// Access: Private -// Description: Draws a visualization of the results of occlusion -// test for a particular bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Draws a visualization of the results of occlusion test for a particular + * bounding volume. + */ void PipeOcclusionCullTraverser:: show_results(int num_fragments, const Geom *geom, const TransformState *net_transform, diff --git a/panda/src/grutil/pipeOcclusionCullTraverser.h b/panda/src/grutil/pipeOcclusionCullTraverser.h index 35bd72159f..7283f5501f 100644 --- a/panda/src/grutil/pipeOcclusionCullTraverser.h +++ b/panda/src/grutil/pipeOcclusionCullTraverser.h @@ -1,16 +1,15 @@ -// Filename: pipeOcclusionCullTraverser.h -// Created by: drose (29May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeOcclusionCullTraverser.h + * @author drose + * @date 2007-05-29 + */ #ifndef PIPEOCCLUSIONCULLTRAVERSER_H #define PIPEOCCLUSIONCULLTRAVERSER_H @@ -26,24 +25,19 @@ class GraphicsEngine; class GraphicsPipe; class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : PipeOcclusionCullTraverser -// Description : This specialization of CullTraverser uses the -// graphics pipe itself to perform occlusion culling. -// As such, it's likely to be inefficient (since it -// interferes with the pipe's normal mode of rendering), -// and is mainly useful to test other, CPU-based -// occlusion algorithms. -// -// This cannot be used in a multithreaded pipeline -// environment where cull and draw are operating -// simultaneously. -// -// It can't be defined in the cull subdirectory, because -// it needs access to GraphicsPipe and DisplayRegion and -// other classes in display. So we put it in grutil -// instead, for lack of any better ideas. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of CullTraverser uses the graphics pipe itself to + * perform occlusion culling. As such, it's likely to be inefficient (since + * it interferes with the pipe's normal mode of rendering), and is mainly + * useful to test other, CPU-based occlusion algorithms. + * + * This cannot be used in a multithreaded pipeline environment where cull and + * draw are operating simultaneously. + * + * It can't be defined in the cull subdirectory, because it needs access to + * GraphicsPipe and DisplayRegion and other classes in display. So we put it + * in grutil instead, for lack of any better ideas. + */ class EXPCL_PANDA_GRUTIL PipeOcclusionCullTraverser : public CullTraverser, public CullHandler { PUBLISHED: @@ -103,8 +97,8 @@ private: CullHandler *_internal_cull_handler; CullHandler *_true_cull_handler; - // This is the query that has already been performed on the current - // node or a parent. + // This is the query that has already been performed on the current node or + // a parent. PT(OcclusionQueryContext) _current_query; // This is the query that has been performed for any children. @@ -156,6 +150,3 @@ private: #include "pipeOcclusionCullTraverser.I" #endif - - - diff --git a/panda/src/grutil/rigidBodyCombiner.I b/panda/src/grutil/rigidBodyCombiner.I index 5dd54b6717..f876f23d04 100644 --- a/panda/src/grutil/rigidBodyCombiner.I +++ b/panda/src/grutil/rigidBodyCombiner.I @@ -1,23 +1,19 @@ -// Filename: rigidBodyCombiner.I -// Created by: drose (22Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rigidBodyCombiner.I + * @author drose + * @date 2007-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::VDUnifier::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RigidBodyCombiner::VDUnifier:: VDUnifier(const VertexTransform *transform, const GeomVertexData *orig) : _transform(transform), @@ -25,11 +21,9 @@ VDUnifier(const VertexTransform *transform, const GeomVertexData *orig) : { } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::VDUnifier::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool RigidBodyCombiner::VDUnifier:: operator < (const RigidBodyCombiner::VDUnifier &other) const { if (_transform != other._transform) { diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index 1ae3a0b1a4..696e81a13f 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/panda/src/grutil/rigidBodyCombiner.cxx @@ -1,16 +1,15 @@ -// Filename: rigidBodyCombiner.cxx -// Created by: drose (22Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rigidBodyCombiner.cxx + * @author drose + * @date 2007-02-22 + */ #include "rigidBodyCombiner.h" #include "nodePath.h" @@ -27,31 +26,26 @@ TypeHandle RigidBodyCombiner::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RigidBodyCombiner:: RigidBodyCombiner(const string &name) : PandaNode(name) { set_cull_callback(); _internal_root = new PandaNode(name); - // We don't want to perform any additional culling once we get - // within the RigidBodyCombiner. The internal Geom's bounding - // volume is not updated and might not be accurate. However, the - // bounding volume of the RigidBodyCombiner itself should be - // accurate, and this is sufficient. + // We don't want to perform any additional culling once we get within the + // RigidBodyCombiner. The internal Geom's bounding volume is not updated + // and might not be accurate. However, the bounding volume of the + // RigidBodyCombiner itself should be accurate, and this is sufficient. _internal_root->set_bounds(new OmniBoundingVolume); _internal_root->set_final(true); } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RigidBodyCombiner:: RigidBodyCombiner(const RigidBodyCombiner ©) : PandaNode(copy) { set_cull_callback(); @@ -60,44 +54,33 @@ RigidBodyCombiner(const RigidBodyCombiner ©) : PandaNode(copy) { _internal_transforms = copy._internal_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *RigidBodyCombiner:: make_copy() const { return new RigidBodyCombiner(*this); } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::collect -// Access: Published -// Description: Walks through the entire subgraph of nodes rooted at -// this node, accumulates all of the RenderAttribs and -// Geoms below this node, flattening them into just one -// Geom (or as few as possible, if there are multiple -// different states). -// -// Nodes that have transforms on them at the time of -// collect(), or any ModelNodes with the -// preserve_transform flag, will be identified as -// "moving" nodes, and their transforms will be -// monitored as they change in future frames and each -// new transform directly applied to the vertices. -// -// This call must be made after adding any nodes to or -// removing any nodes from the subgraph rooted at this -// node. It should not be made too often, as it is a -// relatively expensive call. If you need to hide -// children of this node, consider scaling them to zero -// (or very near zero), or moving them behind the -// camera, instead. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the entire subgraph of nodes rooted at this node, accumulates + * all of the RenderAttribs and Geoms below this node, flattening them into + * just one Geom (or as few as possible, if there are multiple different + * states). + * + * Nodes that have transforms on them at the time of collect(), or any + * ModelNodes with the preserve_transform flag, will be identified as "moving" + * nodes, and their transforms will be monitored as they change in future + * frames and each new transform directly applied to the vertices. + * + * This call must be made after adding any nodes to or removing any nodes from + * the subgraph rooted at this node. It should not be made too often, as it + * is a relatively expensive call. If you need to hide children of this node, + * consider scaling them to zero (or very near zero), or moving them behind + * the camera, instead. + */ void RigidBodyCombiner:: collect() { _internal_root = new GeomNode(get_name()); @@ -118,55 +101,45 @@ collect() { gr.unify(_internal_root, false); } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::get_internal_scene -// Access: Published -// Description: Returns a special NodePath that represents the -// internal node of this object. This is the node that -// is actually sent to the graphics card for rendering; -// it contains the collection of the children of this -// node into as few Geoms as possible. -// -// This node is filled up by the last call to collect(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a special NodePath that represents the internal node of this + * object. This is the node that is actually sent to the graphics card for + * rendering; it contains the collection of the children of this node into as + * few Geoms as possible. + * + * This node is filled up by the last call to collect(). + */ NodePath RigidBodyCombiner:: get_internal_scene() { return NodePath(_internal_root); } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool RigidBodyCombiner:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // Pretend that all of our transforms have been modified (since we - // don't really know which ones have). + // Pretend that all of our transforms have been modified (since we don't + // really know which ones have). Thread *current_thread = Thread::get_current_thread(); Transforms::iterator ti; - for (ti = _internal_transforms.begin(); - ti != _internal_transforms.end(); + for (ti = _internal_transforms.begin(); + ti != _internal_transforms.end(); ++ti) { (*ti)->mark_modified(current_thread); } @@ -179,16 +152,13 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::r_collect -// Access: Private -// Description: Recursively visits each child or descedant of this -// node, accumulating state and transform as we go. -// When GeomNodes are encountered, their Geoms are -// extracted and added to the _internal_root node. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each child or descedant of this node, accumulating state + * and transform as we go. When GeomNodes are encountered, their Geoms are + * extracted and added to the _internal_root node. + */ void RigidBodyCombiner:: -r_collect(PandaNode *node, const RenderState *state, +r_collect(PandaNode *node, const RenderState *state, const VertexTransform *transform) { CPT(RenderState) next_state = state->compose(node->get_state()); CPT(VertexTransform) next_transform = transform; @@ -199,7 +169,7 @@ r_collect(PandaNode *node, const RenderState *state, PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform); _internal_transforms.push_back(new_transform); next_transform = new_transform.p(); - + } if (node->is_geom_node()) { @@ -224,19 +194,15 @@ r_collect(PandaNode *node, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: RigidBodyCombiner::convert_vd -// Access: Private -// Description: Converts a GeomVertexData to a new form in which all -// of the vertices are transformed by the node's -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Converts a GeomVertexData to a new form in which all of the vertices are + * transformed by the node's transform. + */ PT(GeomVertexData) RigidBodyCombiner:: convert_vd(const VertexTransform *transform, const GeomVertexData *orig) { - // First, unify this operation for unique transform/data - // combinations. If we encounter a given GeomVertexData more than - // once under the same transform, we should return exactly the same - // GeomVertexData. + // First, unify this operation for unique transformdata combinations. If we + // encounter a given GeomVertexData more than once under the same transform, + // we should return exactly the same GeomVertexData. VDTable::iterator vdti = _vd_table.find(VDUnifier(transform, orig)); if (vdti != _vd_table.end()) { return (*vdti).second; @@ -244,8 +210,8 @@ convert_vd(const VertexTransform *transform, const GeomVertexData *orig) { PT(GeomVertexFormat) format = new GeomVertexFormat(*orig->get_format()); if (!orig->get_format()->has_column(InternalName::get_transform_blend())) { - PT(GeomVertexArrayFormat) af = - new GeomVertexArrayFormat(InternalName::get_transform_blend(), 1, + PT(GeomVertexArrayFormat) af = + new GeomVertexArrayFormat(InternalName::get_transform_blend(), 1, Geom::NT_uint16, Geom::C_index); format->add_array(af); } @@ -258,17 +224,17 @@ convert_vd(const VertexTransform *transform, const GeomVertexData *orig) { CPT(GeomVertexFormat) new_format = GeomVertexFormat::register_format(format); CPT(GeomVertexData) converted = orig->convert_to(new_format); PT(GeomVertexData) new_data = new GeomVertexData(*converted); - + if (new_data->get_transform_blend_table() == (TransformBlendTable *)NULL) { - // Create a new table that has just the one blend: all vertices - // hard-assigned to the indicated transform. + // Create a new table that has just the one blend: all vertices hard- + // assigned to the indicated transform. PT(TransformBlendTable) new_table = new TransformBlendTable; new_table->add_blend(TransformBlend(transform, 1.0f)); new_table->set_rows(SparseArray::range(0, new_data->get_num_rows())); new_data->set_transform_blend_table(new_table); } else { - // The GeomVertexData already has a TransformBlendTable. In this - // case, we'll have to adjust it. TODO. + // The GeomVertexData already has a TransformBlendTable. In this case, + // we'll have to adjust it. TODO. } // Store the result for the next time. diff --git a/panda/src/grutil/rigidBodyCombiner.h b/panda/src/grutil/rigidBodyCombiner.h index 2f821b263d..1f92cda3cb 100644 --- a/panda/src/grutil/rigidBodyCombiner.h +++ b/panda/src/grutil/rigidBodyCombiner.h @@ -1,16 +1,15 @@ -// Filename: rigidBodyCombiner.h -// Created by: drose (22Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rigidBodyCombiner.h + * @author drose + * @date 2007-02-22 + */ #ifndef RIGIDBODYCOMBINER_H #define RIGIDBODYCOMBINER_H @@ -23,32 +22,25 @@ class NodePath; -//////////////////////////////////////////////////////////////////// -// Class : RigidBodyCombiner -// Description : This is a special node that combines multiple -// independently-moving rigid nodes into one Geom -// internally (or as few Geoms as possible), for the -// purposes of improving rendering performance. -// -// To use it, parent a number of moving objects to this -// node and call collect(). A child node is identified -// as "moving" if (a) it has a non-identity transform -// initially, or (b) it is a ModelNode with the -// preserve_transform flag set. Any other nodes will be -// considered static, and later transforms applied to -// them will not be identified. -// -// You should call collect() only at startup or if you -// change the set of children; it is a relatively -// expensive call. -// -// Once you call collect(), you may change the -// transforms on the child nodes freely without having -// to call collect() again. -// -// RenderEffects such as Billboards are not supported -// below this node. -//////////////////////////////////////////////////////////////////// +/** + * This is a special node that combines multiple independently-moving rigid + * nodes into one Geom internally (or as few Geoms as possible), for the + * purposes of improving rendering performance. + * + * To use it, parent a number of moving objects to this node and call + * collect(). A child node is identified as "moving" if (a) it has a non- + * identity transform initially, or (b) it is a ModelNode with the + * preserve_transform flag set. Any other nodes will be considered static, + * and later transforms applied to them will not be identified. + * + * You should call collect() only at startup or if you change the set of + * children; it is a relatively expensive call. + * + * Once you call collect(), you may change the transforms on the child nodes + * freely without having to call collect() again. + * + * RenderEffects such as Billboards are not supported below this node. + */ class EXPCL_PANDA_GRUTIL RigidBodyCombiner : public PandaNode { PUBLISHED: RigidBodyCombiner(const string &name); @@ -67,9 +59,9 @@ public: virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); private: - void r_collect(PandaNode *node, const RenderState *state, + void r_collect(PandaNode *node, const RenderState *state, const VertexTransform *transform); - PT(GeomVertexData) convert_vd(const VertexTransform *transform, + PT(GeomVertexData) convert_vd(const VertexTransform *transform, const GeomVertexData *orig); PT(PandaNode) _internal_root; @@ -79,7 +71,7 @@ private: class VDUnifier { public: - INLINE VDUnifier(const VertexTransform *transform, + INLINE VDUnifier(const VertexTransform *transform, const GeomVertexData *orig); INLINE bool operator < (const VDUnifier &other) const; diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.I b/panda/src/grutil/sceneGraphAnalyzerMeter.I index 9f1814c15a..2774e397de 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.I +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.I @@ -1,95 +1,76 @@ -// Filename: sceneGraphAnalyzerMeter.I -// Created by: pratt (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzerMeter.I + * @author pratt + * @date 2007-02-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::get_window -// Access: Published -// Description: Returns the GraphicsOutput that was passed to -// setup_window(), or NULL if setup_window() has not -// been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsOutput that was passed to setup_window(), or NULL if + * setup_window() has not been called. + */ INLINE GraphicsOutput *SceneGraphAnalyzerMeter:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::get_display_region -// Access: Published -// Description: Returns the DisplayRegion that the meter has created -// to render itself into the window to setup_window(), -// or NULL if setup_window() has not been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DisplayRegion that the meter has created to render itself into + * the window to setup_window(), or NULL if setup_window() has not been + * called. + */ INLINE DisplayRegion *SceneGraphAnalyzerMeter:: get_display_region() const { return _display_region; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::set_update_interval -// Access: Published -// Description: Specifies the number of seconds that should elapse -// between updates to the meter. This should be -// reasonably slow (e.g. 0.5 to 2.0) so that the -// calculation of the scene graph analysis does not -// itself dominate the frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of seconds that should elapse between updates to the + * meter. This should be reasonably slow (e.g. 0.5 to 2.0) so that the + * calculation of the scene graph analysis does not itself dominate the frame + * rate. + */ INLINE void SceneGraphAnalyzerMeter:: set_update_interval(double update_interval) { _update_interval = update_interval; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::get_update_interval -// Access: Published -// Description: Returns the number of seconds that will elapse -// between updates to the frame rate indication. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of seconds that will elapse between updates to the frame + * rate indication. + */ INLINE double SceneGraphAnalyzerMeter:: get_update_interval() const { return _update_interval; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::set_node -// Access: Published -// Description: Sets the node to be analyzed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the node to be analyzed. + */ INLINE void SceneGraphAnalyzerMeter:: set_node(PandaNode *node) { _node = node; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::get_node -// Access: Published -// Description: Returns the node to be analyzed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node to be analyzed. + */ INLINE PandaNode *SceneGraphAnalyzerMeter:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::update -// Access: Published -// Description: You can call this to explicitly force the -// SceneGraphAnalyzerMeter to update itself with the -// latest scene graph analysis information. -// Normally, it is not necessary to call this explicitly. -//////////////////////////////////////////////////////////////////// +/** + * You can call this to explicitly force the SceneGraphAnalyzerMeter to update + * itself with the latest scene graph analysis information. Normally, it is + * not necessary to call this explicitly. + */ INLINE void SceneGraphAnalyzerMeter:: update() { Thread *current_thread = Thread::get_current_thread(); diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx index d59e9e347a..f5a14caed3 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.cxx +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.cxx @@ -1,16 +1,15 @@ -// Filename: sceneGraphAnalyzerMeter.cxx -// Created by: pratt (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzerMeter.cxx + * @author pratt + * @date 2007-02-14 + */ #include "sceneGraphAnalyzerMeter.h" #include "camera.h" @@ -26,11 +25,9 @@ PStatCollector SceneGraphAnalyzerMeter::_show_analyzer_pcollector("*:Show scene TypeHandle SceneGraphAnalyzerMeter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SceneGraphAnalyzerMeter:: SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { set_cull_callback(); @@ -43,7 +40,7 @@ SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { _clock_object = ClockObject::get_global_clock(); set_align(A_left); - set_transform(LMatrix4::scale_mat(scene_graph_analyzer_meter_scale) * + set_transform(LMatrix4::scale_mat(scene_graph_analyzer_meter_scale) * LMatrix4::translate_mat(LVector3::rfu(-1.0f + scene_graph_analyzer_meter_side_margins * scene_graph_analyzer_meter_scale, 0.0f, 1.0f - scene_graph_analyzer_meter_scale))); set_card_color(0.0f, 0.0f, 0.0f, 0.4); set_card_as_margin(scene_graph_analyzer_meter_side_margins, scene_graph_analyzer_meter_side_margins, 0.1f, 0.0f); @@ -52,23 +49,18 @@ SceneGraphAnalyzerMeter(const string &name, PandaNode *node) : TextNode(name) { do_update(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SceneGraphAnalyzerMeter:: ~SceneGraphAnalyzerMeter() { clear_window(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::setup_window -// Access: Published -// Description: Sets up the frame rate meter to create a -// DisplayRegion to render itself into the indicated -// window. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the frame rate meter to create a DisplayRegion to render itself + * into the indicated window. + */ void SceneGraphAnalyzerMeter:: setup_window(GraphicsOutput *window) { clear_window(); @@ -94,7 +86,7 @@ setup_window(GraphicsOutput *window) { NodePath camera_np = _root.attach_new_node(camera); PT(Lens) lens = new OrthographicLens; - + static const PN_stdfloat left = -1.0f; static const PN_stdfloat right = 1.0f; static const PN_stdfloat bottom = -1.0f; @@ -102,18 +94,15 @@ setup_window(GraphicsOutput *window) { lens->set_film_size(right - left, top - bottom); lens->set_film_offset((right + left) * 0.5, (top + bottom) * 0.5); lens->set_near_far(-1000, 1000); - + camera->set_lens(lens); camera->set_scene(_root); _display_region->set_camera(camera_np); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::clear_window -// Access: Published -// Description: Undoes the effect of a previous call to -// setup_window(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to setup_window(). + */ void SceneGraphAnalyzerMeter:: clear_window() { if (_window != (GraphicsOutput *)NULL) { @@ -124,38 +113,31 @@ clear_window() { _root = NodePath(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool SceneGraphAnalyzerMeter:: cull_callback(CullTraverser *trav, CullTraverserData &data) { Thread *current_thread = trav->get_current_thread(); // Statistics PStatTimer timer(_show_analyzer_pcollector, current_thread); - + // Check to see if it's time to update. double now = _clock_object->get_frame_time(current_thread); double elapsed = now - _last_update; @@ -166,11 +148,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return TextNode::cull_callback(trav, data); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzerMeter::do_update -// Access: Private -// Description: Resets the text according to the current frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Resets the text according to the current frame rate. + */ void SceneGraphAnalyzerMeter:: do_update(Thread *current_thread) { _last_update = _clock_object->get_frame_time(current_thread); diff --git a/panda/src/grutil/sceneGraphAnalyzerMeter.h b/panda/src/grutil/sceneGraphAnalyzerMeter.h index 50e0c67105..c6046255e3 100644 --- a/panda/src/grutil/sceneGraphAnalyzerMeter.h +++ b/panda/src/grutil/sceneGraphAnalyzerMeter.h @@ -1,16 +1,15 @@ -// Filename: sceneGraphAnalyzerMeter.h -// Created by: pratt (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzerMeter.h + * @author pratt + * @date 2007-02-14 + */ #ifndef SCENEGRAPHANALYZERMETER_H #define SCENEGRAPHANALYZERMETER_H @@ -28,18 +27,15 @@ class PandaNode; class GraphicsChannel; class ClockObject; -//////////////////////////////////////////////////////////////////// -// Class : SceneGraphAnalyzerMeter -// Description : This is a special TextNode that automatically updates -// itself with output from a SceneGraphAnalyzer instance. -// It can be placed anywhere in the world where you'd like -// to see the output from SceneGraphAnalyzer. -// -// It also has a special mode in which it may be -// attached directly to a channel or window. If this is -// done, it creates a DisplayRegion for itself and renders -// itself in the upper-right-hand corner. -//////////////////////////////////////////////////////////////////// +/** + * This is a special TextNode that automatically updates itself with output + * from a SceneGraphAnalyzer instance. It can be placed anywhere in the world + * where you'd like to see the output from SceneGraphAnalyzer. + * + * It also has a special mode in which it may be attached directly to a + * channel or window. If this is done, it creates a DisplayRegion for itself + * and renders itself in the upper-right-hand corner. + */ class EXPCL_PANDA SceneGraphAnalyzerMeter : public TextNode { PUBLISHED: SceneGraphAnalyzerMeter(const string &name, PandaNode *node); diff --git a/panda/src/gsgbase/config_gsgbase.cxx b/panda/src/gsgbase/config_gsgbase.cxx index 1f87e8558d..b4d6dc90c1 100644 --- a/panda/src/gsgbase/config_gsgbase.cxx +++ b/panda/src/gsgbase/config_gsgbase.cxx @@ -1,16 +1,15 @@ -// Filename: config_gsgbase.cxx -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gsgbase.cxx + * @author drose + * @date 1999-10-06 + */ #include "config_gsgbase.h" #include "displayRegionBase.h" diff --git a/panda/src/gsgbase/config_gsgbase.h b/panda/src/gsgbase/config_gsgbase.h index 560a61e5b3..20407ea6c4 100644 --- a/panda/src/gsgbase/config_gsgbase.h +++ b/panda/src/gsgbase/config_gsgbase.h @@ -1,16 +1,15 @@ -// Filename: config_gsgbase.h -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_gsgbase.h + * @author drose + * @date 1999-10-06 + */ #ifndef CONFIG_GSGBASE_H #define CONFIG_GSGBASE_H diff --git a/panda/src/gsgbase/displayRegionBase.I b/panda/src/gsgbase/displayRegionBase.I index 9b3746fb8e..a945da7eb3 100644 --- a/panda/src/gsgbase/displayRegionBase.I +++ b/panda/src/gsgbase/displayRegionBase.I @@ -1,23 +1,19 @@ -// Filename: displayRegionBase.I -// Created by: drose (20Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionBase.I + * @author drose + * @date 2009-02-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DisplayRegionBase:: DisplayRegionBase() { } diff --git a/panda/src/gsgbase/displayRegionBase.cxx b/panda/src/gsgbase/displayRegionBase.cxx index 287c8b3328..b3573b9e68 100644 --- a/panda/src/gsgbase/displayRegionBase.cxx +++ b/panda/src/gsgbase/displayRegionBase.cxx @@ -1,27 +1,24 @@ -// Filename: displayRegionBase.cxx -// Created by: drose (20Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionBase.cxx + * @author drose + * @date 2009-02-20 + */ #include "displayRegionBase.h" TypeHandle DisplayRegionBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegionBase::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DisplayRegionBase:: ~DisplayRegionBase() { } diff --git a/panda/src/gsgbase/displayRegionBase.h b/panda/src/gsgbase/displayRegionBase.h index 1b7f1fab52..71302281f8 100644 --- a/panda/src/gsgbase/displayRegionBase.h +++ b/panda/src/gsgbase/displayRegionBase.h @@ -1,16 +1,15 @@ -// Filename: displayRegionBase.h -// Created by: drose (20Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file displayRegionBase.h + * @author drose + * @date 2009-02-20 + */ #ifndef DISPLAYREGIONBASE_H #define DISPLAYREGIONBASE_H @@ -19,11 +18,10 @@ #include "typedReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : DisplayRegionBase -// Description : An abstract base class for DisplayRegion, mainly so -// we can store DisplayRegion pointers in a Camera. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for DisplayRegion, mainly so we can store + * DisplayRegion pointers in a Camera. + */ class EXPCL_PANDA_GSGBASE DisplayRegionBase : public TypedReferenceCount { protected: INLINE DisplayRegionBase(); diff --git a/panda/src/gsgbase/graphicsOutputBase.I b/panda/src/gsgbase/graphicsOutputBase.I index 9d3dce114d..b605c13ccb 100644 --- a/panda/src/gsgbase/graphicsOutputBase.I +++ b/panda/src/gsgbase/graphicsOutputBase.I @@ -1,14 +1,12 @@ -// Filename: graphicsOutputBase.I -// Created by: drose (27May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutputBase.I + * @author drose + * @date 2009-05-27 + */ diff --git a/panda/src/gsgbase/graphicsOutputBase.cxx b/panda/src/gsgbase/graphicsOutputBase.cxx index 0506295730..f400b0b161 100644 --- a/panda/src/gsgbase/graphicsOutputBase.cxx +++ b/panda/src/gsgbase/graphicsOutputBase.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsOutputBase.cxx -// Created by: drose (27May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutputBase.cxx + * @author drose + * @date 2009-05-27 + */ #include "graphicsOutputBase.h" diff --git a/panda/src/gsgbase/graphicsOutputBase.h b/panda/src/gsgbase/graphicsOutputBase.h index 968b17d5a6..210077c3f1 100644 --- a/panda/src/gsgbase/graphicsOutputBase.h +++ b/panda/src/gsgbase/graphicsOutputBase.h @@ -1,16 +1,15 @@ -// Filename: graphicsOutputBase.h -// Created by: drose (27May09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsOutputBase.h + * @author drose + * @date 2009-05-27 + */ #ifndef GRAPHICSOUTPUTBASE_H #define GRAPHICSOUTPUTBASE_H @@ -20,16 +19,14 @@ class Texture; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsOutputBase -// Description : An abstract base class for GraphicsOutput, for all -// the usual reasons. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for GraphicsOutput, for all the usual reasons. + */ class EXPCL_PANDA_GSGBASE GraphicsOutputBase : public TypedWritableReferenceCount { PUBLISHED: virtual void set_sort(int sort)=0; virtual Texture *get_texture(int i=0) const=0; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.cxx b/panda/src/gsgbase/graphicsStateGuardianBase.cxx index 541bdb43cc..30d5d20871 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.cxx +++ b/panda/src/gsgbase/graphicsStateGuardianBase.cxx @@ -1,16 +1,15 @@ -// Filename: graphicsStateGuardianBase.cxx -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardianBase.cxx + * @author drose + * @date 1999-10-06 + */ #include "graphicsStateGuardianBase.h" #include "lightMutexHolder.h" @@ -21,30 +20,24 @@ GraphicsStateGuardianBase *GraphicsStateGuardianBase::_default_gsg; LightMutex GraphicsStateGuardianBase::_lock; TypeHandle GraphicsStateGuardianBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::get_default_gsg -// Access: Published, Static -// Description: Returns a pointer to the "default" GSG. This is -// typically the first GSG created in an application; in -// a single-window application, it will be the only GSG. -// This GSG is used to determine default optimization -// choices for loaded geometry. -// -// The return value may be NULL if a GSG has not been -// created. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the "default" GSG. This is typically the first GSG + * created in an application; in a single-window application, it will be the + * only GSG. This GSG is used to determine default optimization choices for + * loaded geometry. + * + * The return value may be NULL if a GSG has not been created. + */ GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_default_gsg() { LightMutexHolder holder(_lock); return _default_gsg; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::set_default_gsg -// Access: Published, Static -// Description: Specifies a particular GSG to use as the "default" -// GSG. See get_default_gsg(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies a particular GSG to use as the "default" GSG. See + * get_default_gsg(). + */ void GraphicsStateGuardianBase:: set_default_gsg(GraphicsStateGuardianBase *default_gsg) { LightMutexHolder holder(_lock); @@ -57,35 +50,28 @@ set_default_gsg(GraphicsStateGuardianBase *default_gsg) { _default_gsg = default_gsg; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::get_num_gsgs -// Access: Published, Static -// Description: Returns the total number of GSG's in the universe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of GSG's in the universe. + */ int GraphicsStateGuardianBase:: get_num_gsgs() { return _gsgs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::get_gsg -// Access: Published, Static -// Description: Returns the nth GSG in the universe. GSG's -// automatically add themselves and remove themselves -// from this list as they are created and destroyed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth GSG in the universe. GSG's automatically add themselves + * and remove themselves from this list as they are created and destroyed. + */ GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_gsg(int n) { nassertr(n >= 0 && n < (int)_gsgs.size(), NULL); return _gsgs[n]; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::add_gsg -// Access: Public, Static -// Description: Called by a GSG after it has been initialized, to add -// a new GSG to the available list. -//////////////////////////////////////////////////////////////////// +/** + * Called by a GSG after it has been initialized, to add a new GSG to the + * available list. + */ void GraphicsStateGuardianBase:: add_gsg(GraphicsStateGuardianBase *gsg) { LightMutexHolder holder(_lock); @@ -102,12 +88,9 @@ add_gsg(GraphicsStateGuardianBase *gsg) { } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardianBase::remove_gsg -// Access: Public, Static -// Description: Called by a GSG destructor to remove a GSG from the -// available list. -//////////////////////////////////////////////////////////////////// +/** + * Called by a GSG destructor to remove a GSG from the available list. + */ void GraphicsStateGuardianBase:: remove_gsg(GraphicsStateGuardianBase *gsg) { LightMutexHolder holder(_lock); diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index 96d5ed310b..2fecf301a8 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -1,16 +1,15 @@ -// Filename: graphicsStateGuardianBase.h -// Created by: drose (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file graphicsStateGuardianBase.h + * @author drose + * @date 1999-10-06 + */ #ifndef GRAPHICSSTATEGUARDIANBASE_H #define GRAPHICSSTATEGUARDIANBASE_H @@ -94,22 +93,18 @@ class LightLensNode; class DisplayRegion; class Lens; -//////////////////////////////////////////////////////////////////// -// Class : GraphicsStateGuardianBase -// Description : This is a base class for the GraphicsStateGuardian -// class, which is itself a base class for the various -// GSG's for different platforms. This class contains -// all the function prototypes to support the -// double-dispatch of GSG to geoms, transitions, etc. It -// lives in a separate class in its own package so we -// can avoid circular build dependency problems. -// -// GraphicsStateGuardians are not actually writable to -// bam files, of course, but they may be passed as event -// parameters, so they inherit from -// TypedWritableReferenceCount instead of -// TypedReferenceCount for that convenience. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for the GraphicsStateGuardian class, which is itself a + * base class for the various GSG's for different platforms. This class + * contains all the function prototypes to support the double-dispatch of GSG + * to geoms, transitions, etc. It lives in a separate class in its own + * package so we can avoid circular build dependency problems. + * + * GraphicsStateGuardians are not actually writable to bam files, of course, + * but they may be passed as event parameters, so they inherit from + * TypedWritableReferenceCount instead of TypedReferenceCount for that + * convenience. + */ class EXPCL_PANDA_GSGBASE GraphicsStateGuardianBase : public TypedWritableReferenceCount { PUBLISHED: virtual bool get_incomplete_render() const=0; @@ -131,9 +126,9 @@ PUBLISHED: virtual bool get_supports_hlsl() const=0; public: - // These are some general interface functions; they're defined here - // mainly to make it easy to call these from code in some directory - // that display depends on. + // These are some general interface functions; they're defined here mainly + // to make it easy to call these from code in some directory that display + // depends on. virtual SceneSetup *get_scene() const=0; virtual void clear_before_callback()=0; @@ -142,8 +137,8 @@ public: virtual void remove_window(GraphicsOutputBase *window)=0; #ifndef CPPPARSER - // We hide this from interrogate, so that it will be properly - // exported from the GraphicsStateGuardian class, later. + // We hide this from interrogate, so that it will be properly exported from + // the GraphicsStateGuardian class, later. virtual PreparedGraphicsObjects *get_prepared_objects()=0; #endif @@ -175,17 +170,15 @@ public: virtual void set_state_and_transform(const RenderState *state, const TransformState *transform)=0; - // This function may only be called during a render traversal; it - // will compute the distance to the indicated point, assumed to be - // in eye coordinates, from the camera plane. This is a virtual - // function because different GSG's may define the eye coordinate - // space differently. + // This function may only be called during a render traversal; it will + // compute the distance to the indicated point, assumed to be in eye + // coordinates, from the camera plane. This is a virtual function because + // different GSG's may define the eye coordinate space differently. virtual PN_stdfloat compute_distance_to(const LPoint3 &point) const=0; - // These are used to implement decals. If depth_offset_decals() - // returns true, none of the remaining functions will be called, - // since depth offsets can be used to implement decals fully (and - // usually faster). + // These are used to implement decals. If depth_offset_decals() returns + // true, none of the remaining functions will be called, since depth offsets + // can be used to implement decals fully (and usually faster). virtual bool depth_offset_decals()=0; virtual CPT(RenderState) begin_decal_base_first()=0; virtual CPT(RenderState) begin_decal_nested()=0; @@ -193,12 +186,11 @@ public: virtual void finish_decal()=0; // Defined here are some internal interface functions for the - // GraphicsStateGuardian. These are here to support - // double-dispatching from Geoms and NodeTransitions, and are - // intended to be invoked only directly by the appropriate Geom and - // NodeTransition types. They're public only because it would be too - // inconvenient to declare each of those types to be friends of this - // class. + // GraphicsStateGuardian. These are here to support double-dispatching from + // Geoms and NodeTransitions, and are intended to be invoked only directly + // by the appropriate Geom and NodeTransition types. They're public only + // because it would be too inconvenient to declare each of those types to be + // friends of this class. virtual bool begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, diff --git a/panda/src/gsgbase/test_gsgbase.cxx b/panda/src/gsgbase/test_gsgbase.cxx index a33bfc5d81..4c16694e72 100644 --- a/panda/src/gsgbase/test_gsgbase.cxx +++ b/panda/src/gsgbase/test_gsgbase.cxx @@ -1,16 +1,15 @@ -// Filename: test_gsgbase.cxx -// Created by: shochet (02Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_gsgbase.cxx + * @author shochet + * @date 2000-02-02 + */ #include "graphicsStateGuardianBase.h" diff --git a/panda/src/iphone/config_iphone.h b/panda/src/iphone/config_iphone.h index 2d780baa7f..ef25fb8f00 100644 --- a/panda/src/iphone/config_iphone.h +++ b/panda/src/iphone/config_iphone.h @@ -1,16 +1,15 @@ -// Filename: config_iphone.h -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_iphone.h + * @author drose + * @date 2009-04-08 + */ #ifndef CONFIG_IPHONE_H #define CONFIG_IPHONE_H diff --git a/panda/src/iphone/config_iphone.mm b/panda/src/iphone/config_iphone.mm index a059e1a1b2..f8aabc4c53 100644 --- a/panda/src/iphone/config_iphone.mm +++ b/panda/src/iphone/config_iphone.mm @@ -1,16 +1,15 @@ -// Filename: config_iphone.mm -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_iphone.mm + * @author drose + * @date 2009-04-08 + */ #include "config_iphone.h" #include "dconfig.h" @@ -23,14 +22,12 @@ ConfigureFn(config_iphone) { init_libiphone(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libiphone -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libiphone() { static bool initialized = false; diff --git a/panda/src/iphone/iphone_runappmf_src.mm b/panda/src/iphone/iphone_runappmf_src.mm index a191b85a9b..40479f894f 100644 --- a/panda/src/iphone/iphone_runappmf_src.mm +++ b/panda/src/iphone/iphone_runappmf_src.mm @@ -1,25 +1,24 @@ -// Filename: iphone_runappmf_src.mm -// Created by: drose (26Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iphone_runappmf_src.mm + * @author drose + * @date 2009-04-26 + */ -#import +#import #include #include #include using namespace std; #include "pnotify.h" - + #ifdef LINK_ALL_STATIC extern "C" void initlibpandaexpress(); extern "C" void initlibpanda(); @@ -28,12 +27,12 @@ extern "C" void initlibpandafx(); extern "C" void initlibdirect(); #endif // LINK_ALL_STATIC -//@class AppMFViewController; -@interface AppMFAppDelegate : NSObject { +// @class AppMFViewController; +@interface AppMFAppDelegate : NSObject { NSString *app_directory; NSTimer *animationTimer; NSTimeInterval animationInterval; -} +} @property (nonatomic, assign) NSString *app_directory; @property (nonatomic, assign) NSTimer *animationTimer; @property NSTimeInterval animationInterval; @@ -42,9 +41,9 @@ extern "C" void initlibdirect(); - (void)stopAnimation; - (void)drawView; -@end +@end -@implementation AppMFAppDelegate +@implementation AppMFAppDelegate @synthesize app_directory; @synthesize animationTimer; @@ -52,15 +51,15 @@ extern "C" void initlibdirect(); int startup = 0; -- (void)applicationDidFinishLaunching: (UIApplication *)application { +- (void)applicationDidFinishLaunching: (UIApplication *)application { // Get the App bundle directory. NSBundle *bundle = [NSBundle mainBundle]; if (bundle != nil) { app_directory = [bundle bundlePath]; } - // Set this as the current directory. Not only is this convenient, - // but it also makes shared-library linking work. + // Set this as the current directory. Not only is this convenient, but it + // also makes shared-library linking work. const char *app_directory_cstr = [app_directory cStringUsingEncoding: NSASCIIStringEncoding]; int cd = chdir(app_directory_cstr); if (cd < 0) { @@ -79,9 +78,9 @@ int startup = 0; animationInterval = 1.0 / 60.0; [self startAnimation]; -} +} -- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application { +- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application { cerr << "applicationDidReceiveMemoryWarning\n"; } @@ -102,7 +101,7 @@ int startup = 0; - (void)setAnimationInterval:(NSTimeInterval)interval { - + animationInterval = interval; if (animationTimer) { [self stopAnimation]; @@ -112,10 +111,10 @@ int startup = 0; - (void)drawView { if (startup == 0) { - // We are still just initializing the app. Initialize Python now. - // We have this funny deferred-window technique, so SpringBoard - // will see that the app has fully initialized and won't kill us - // if we take a while starting up. + // We are still just initializing the app. Initialize Python now. We + // have this funny deferred-window technique, so SpringBoard will see that + // the app has fully initialized and won't kill us if we take a while + // starting up. Py_FrozenFlag = 1; /* Suppress errors from getpath.c */ NSString *app_pathname = [app_directory stringByAppendingString: @"/iphone_runappmf" ]; @@ -133,8 +132,8 @@ int startup = 0; Py_SetPythonHome((char *)app_directory_cstr); #ifdef LINK_ALL_STATIC - // Construct the Python modules for the interrogate-generated data - // we know we've already linked in. + // Construct the Python modules for the interrogate-generated data we know + // we've already linked in. initlibpandaexpress(); initlibpanda(); initlibpandaphysics(); @@ -195,8 +194,8 @@ int startup = 0; startup = 2; } else { - // We are fully initialized and running. Run taskMgr.step() once - // each frame. + // We are fully initialized and running. Run taskMgr.step() once each + // frame. PyObject *module = PyImport_ImportModule("direct.p3d.runp3d"); if (module != (PyObject *)NULL) { PyObject *taskMgr = PyObject_GetAttrString(module, "taskMgr"); @@ -223,16 +222,16 @@ int startup = 0; Py_Finalize(); } -- (void)dealloc { - [super dealloc]; -} +- (void)dealloc { + [super dealloc]; +} -@end +@end extern "C" int main(int argc, char *argv[]); int -main(int argc, char *argv[]) { +main(int argc, char *argv[]) { /* int logfile_fd = open("/tmp/foo.txt", O_WRONLY | O_CREAT | O_TRUNC, 0666); if (logfile_fd >= 0) { @@ -243,11 +242,11 @@ main(int argc, char *argv[]) { */ PyImport_FrozenModules = _PyImport_FrozenModules; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - /* Call with the name of our application delegate class */ - int retVal = UIApplicationMain(argc, argv, nil, @"AppMFAppDelegate"); + /* Call with the name of our application delegate class */ + int retVal = UIApplicationMain(argc, argv, nil, @"AppMFAppDelegate"); - [pool release]; - return retVal; -} + [pool release]; + return retVal; +} diff --git a/panda/src/iphone/pview_delegate.h b/panda/src/iphone/pview_delegate.h index a300127da4..a1f07047aa 100644 --- a/panda/src/iphone/pview_delegate.h +++ b/panda/src/iphone/pview_delegate.h @@ -1,24 +1,23 @@ -// Filename: pview_delegate.h -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pview_delegate.h + * @author drose + * @date 2009-04-10 + */ -#import +#import -@class PviewViewController; -@interface PviewAppDelegate : NSObject { +@class PviewViewController; +@interface PviewAppDelegate : NSObject { NSTimer *animationTimer; NSTimeInterval animationInterval; -} +} @property (nonatomic, assign) NSTimer *animationTimer; @property NSTimeInterval animationInterval; @@ -26,4 +25,4 @@ - (void)stopAnimation; - (void)drawView; -@end +@end diff --git a/panda/src/iphone/pview_delegate.mm b/panda/src/iphone/pview_delegate.mm index 9f5a4c1ad5..6327402778 100644 --- a/panda/src/iphone/pview_delegate.mm +++ b/panda/src/iphone/pview_delegate.mm @@ -1,24 +1,23 @@ -// Filename: pview_delegate.mm -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - -#import "pview_delegate.h" +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pview_delegate.mm + * @author drose + * @date 2009-04-10 + */ + +#import "pview_delegate.h" #import "viewController.h" #include "dcast.h" #include "pandaFramework.h" #include "config_iphonedisplay.h" -@implementation PviewAppDelegate +@implementation PviewAppDelegate @synthesize animationTimer; @synthesize animationInterval; @@ -30,17 +29,17 @@ PandaFramework framework; int argc = 0; char **argv = NULL; -void +void signal_handler(int i) { nout << "Caught signal " << i << "\n"; exit(1); } -- (void)applicationDidFinishLaunching: (UIApplication *)application { +- (void)applicationDidFinishLaunching: (UIApplication *)application { ConfigVariableBool pview_trap_signals("pview-trap-signals", false); if (pview_trap_signals) { - // Set up a signal handler on every signal, so we can report this to - // the log. + // Set up a signal handler on every signal, so we can report this to the + // log. struct sigaction sa; sa.sa_handler = signal_handler; sigemptyset(&sa.sa_mask); @@ -67,16 +66,16 @@ signal_handler(int i) { // Ensure the IPhoneDisplay is available. init_libiphonedisplay(); - + framework.open_framework(argc, argv); startup = 0; ConfigVariableDouble timer_fps("timer-fps", 60.0); animationInterval = 1.0 / timer_fps; [self startAnimation]; -} +} -- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application { +- (void)applicationDidReceiveMemoryWarning: (UIApplication *)application { nout << "applicationDidReceiveMemoryWarning\n"; } @@ -97,7 +96,7 @@ signal_handler(int i) { - (void)setAnimationInterval:(NSTimeInterval)interval { - + animationInterval = interval; if (animationTimer) { [self stopAnimation]; @@ -107,10 +106,10 @@ signal_handler(int i) { - (void)drawView { if (startup == 0) { - // We are still just initializing the app. Open the window and - // load the models. We have this funny deferred-window technique, - // so SpringBoard will see that the app has fully initialized and - // won't kill us if we take a while loading models. + // We are still just initializing the app. Open the window and load the + // models. We have this funny deferred-window technique, so SpringBoard + // will see that the app has fully initialized and won't kill us if we + // take a while loading models. WindowFramework *window = framework.open_window(); if (window == (WindowFramework *)NULL) { // Couldn't get a window. @@ -125,7 +124,7 @@ signal_handler(int i) { window->enable_keyboard(); window->setup_trackball(); framework.get_models().instance_to(window->get_render()); - + if (argc < 2) { window->load_default_model(framework.get_models()); } else { @@ -134,14 +133,14 @@ signal_handler(int i) { int hierarchy_match_flags = PartGroup::HMF_ok_part_extra | PartGroup::HMF_ok_anim_extra; window->loop_animations(hierarchy_match_flags); - + window->center_trackball(framework.get_models()); - + ConfigVariableBool pview_lighting("pview-lighting", false); if (pview_lighting) { window->set_lighting(true); } - + ConfigVariableBool want_pstats("want-pstats", false); if (want_pstats) { PStatClient::connect(); @@ -163,8 +162,8 @@ signal_handler(int i) { framework.close_framework(); } -- (void)dealloc { - [super dealloc]; -} +- (void)dealloc { + [super dealloc]; +} -@end +@end diff --git a/panda/src/iphone/pview_main.mm b/panda/src/iphone/pview_main.mm index f37e05ebb3..6bf83250ce 100644 --- a/panda/src/iphone/pview_main.mm +++ b/panda/src/iphone/pview_main.mm @@ -1,27 +1,26 @@ -// Filename: pview_main.mm -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pview_main.mm + * @author drose + * @date 2009-04-10 + */ #import extern "C" int main(int argc, char *argv[]); int -main(int argc, char *argv[]) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; +main(int argc, char *argv[]) { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - /* Call with the name of our application delegate class */ - int retVal = UIApplicationMain(argc, argv, nil, @"PviewAppDelegate"); - [pool release]; - return retVal; -} + /* Call with the name of our application delegate class */ + int retVal = UIApplicationMain(argc, argv, nil, @"PviewAppDelegate"); + [pool release]; + return retVal; +} diff --git a/panda/src/iphonedisplay/config_iphonedisplay.h b/panda/src/iphonedisplay/config_iphonedisplay.h index f520ec0682..705deadcba 100644 --- a/panda/src/iphonedisplay/config_iphonedisplay.h +++ b/panda/src/iphonedisplay/config_iphonedisplay.h @@ -1,16 +1,15 @@ -// Filename: config_iphonedisplay.h -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_iphonedisplay.h + * @author drose + * @date 2009-04-08 + */ #ifndef CONFIG_IPHONEDISPLAY_H #define CONFIG_IPHONEDISPLAY_H diff --git a/panda/src/iphonedisplay/config_iphonedisplay.mm b/panda/src/iphonedisplay/config_iphonedisplay.mm index 973f540a7d..6179be2875 100644 --- a/panda/src/iphonedisplay/config_iphonedisplay.mm +++ b/panda/src/iphonedisplay/config_iphonedisplay.mm @@ -1,16 +1,15 @@ -// Filename: config_iphonedisplay.mm -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_iphonedisplay.mm + * @author drose + * @date 2009-04-08 + */ #include "config_iphonedisplay.h" #include "iPhoneGraphicsPipe.h" @@ -36,14 +35,12 @@ ConfigVariableBool iphone_autorotate_view "view automatically according to the phone's orientation, or " "false for its view to remain fixed.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libiphonedisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libiphonedisplay() { static bool initialized = false; @@ -66,11 +63,10 @@ init_libiphonedisplay() { GLESinit_classes(); } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_iphonedisplay -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_iphonedisplay() { return IPhoneGraphicsPipe::get_class_type().get_index(); diff --git a/panda/src/iphonedisplay/eaglView.h b/panda/src/iphonedisplay/eaglView.h index 0ffcd73db0..92f2b4cc75 100644 --- a/panda/src/iphonedisplay/eaglView.h +++ b/panda/src/iphonedisplay/eaglView.h @@ -1,16 +1,15 @@ -// Filename: eaglView.h -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eaglView.h + * @author drose + * @date 2009-04-10 + */ #include "pandabase.h" #import @@ -34,12 +33,12 @@ Note that setting the view non-opaque will only work if the EAGL surface has an /* The pixel dimensions of the backbuffer */ GLint backingWidth; GLint backingHeight; - + EAGLContext *context; - + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ GLuint viewRenderbuffer, viewFramebuffer; - + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ GLuint depthRenderbuffer; } diff --git a/panda/src/iphonedisplay/eaglView.mm b/panda/src/iphonedisplay/eaglView.mm index fad49aa1de..5b523eecd1 100644 --- a/panda/src/iphonedisplay/eaglView.mm +++ b/panda/src/iphonedisplay/eaglView.mm @@ -1,16 +1,15 @@ -// Filename: eaglView.mm -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eaglView.mm + * @author drose + * @date 2009-04-10 + */ #import "EAGLView.h" @@ -49,13 +48,13 @@ if ((self = [super initWithFrame:frame])) { // Get the layer CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - + eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - + context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - + if (!context || ![EAGLContext setCurrentContext:context]) { [self release]; return nil; @@ -75,7 +74,7 @@ [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } -- (void)touchesBegan: (NSSet *)touches +- (void)touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event { // Pass the multi-touch input to the _window for processing. @@ -83,21 +82,21 @@ [super touchesBegan: touches withEvent: event]; } -- (void)touchesMoved: (NSSet *)touches +- (void)touchesMoved: (NSSet *)touches withEvent: (UIEvent *)event { _window->touches_moved(touches, event); [super touchesMoved: touches withEvent: event]; } -- (void)touchesEnded: (NSSet *)touches +- (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event { _window->touches_ended(touches, event); [super touchesEnded: touches withEvent: event]; } -- (void)touchesCancelled: (NSSet *)touches +- (void)touchesCancelled: (NSSet *)touches withEvent: (UIEvent *)event { _window->touches_cancelled(touches, event); @@ -105,9 +104,9 @@ } /* -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event; */ @@ -125,15 +124,15 @@ - (BOOL)createFramebuffer { glGenFramebuffersOES(1, &viewFramebuffer); glGenRenderbuffersOES(1, &viewRenderbuffer); - + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); - + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - + if (USE_DEPTH_BUFFER) { glGenRenderbuffersOES(1, &depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); @@ -141,18 +140,18 @@ glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); } - + if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return NO; } - - // Make sure the buffer is initially cleared, so we don't look at - // whatever happened to be in the framebuffer. + + // Make sure the buffer is initially cleared, so we don't look at whatever + // happened to be in the framebuffer. glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; - + return YES; } @@ -167,7 +166,7 @@ glDeleteRenderbuffersOES(1, &viewRenderbuffer); viewRenderbuffer = 0; } - + if (depthRenderbuffer) { glDeleteRenderbuffersOES(1, &depthRenderbuffer); depthRenderbuffer = 0; @@ -175,12 +174,12 @@ } - (void)dealloc { - + if ([EAGLContext currentContext] == context) { [EAGLContext setCurrentContext:nil]; } - - [context release]; + + [context release]; [super dealloc]; } diff --git a/panda/src/iphonedisplay/iPhoneGraphicsPipe.h b/panda/src/iphonedisplay/iPhoneGraphicsPipe.h index 26ac7d0eaf..24418bda12 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsPipe.h +++ b/panda/src/iphonedisplay/iPhoneGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: iPhoneGraphicsPipe.h -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsPipe.h + * @author drose + * @date 2009-04-08 + */ #ifndef IPHONEGRAPHICSPIPE_H #define IPHONEGRAPHICSPIPE_H @@ -25,12 +24,10 @@ class IPhoneGraphicsStateGuardian; class IPhoneGraphicsWindow; class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : IPhoneGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on the various -// IPHONE's. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL graphics + * windows on the various IPHONE's. + */ class EXPCL_MISC IPhoneGraphicsPipe : public GraphicsPipe { public: IPhoneGraphicsPipe(); @@ -54,7 +51,7 @@ protected: bool &precertify); public: - UIWindow *_window; + UIWindow *_window; ControllerDemoViewController *_view_controller; typedef pset GraphicsWindows; diff --git a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm index 510eaa74a6..dba09cbcc9 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsPipe.mm @@ -1,16 +1,15 @@ -// Filename: iPhoneGraphicsPipe.mm -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsPipe.mm + * @author drose + * @date 2009-04-08 + */ #include "iPhoneGraphicsPipe.h" #include "config_iphonedisplay.h" @@ -22,61 +21,50 @@ IPhoneGraphicsPipe *IPhoneGraphicsPipe::_global_ptr; TypeHandle IPhoneGraphicsPipe::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ IPhoneGraphicsPipe:: IPhoneGraphicsPipe() { - CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ]; + CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ]; _window = [ [ UIWindow alloc ] initWithFrame: screenBounds ]; - _view_controller = [ [ ControllerDemoViewController alloc ] initWithPipe: this ]; + _view_controller = [ [ ControllerDemoViewController alloc ] initWithPipe: this ]; - [ _window addSubview:_view_controller.view ]; + [ _window addSubview:_view_controller.view ]; [ _window makeKeyAndVisible ]; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IPhoneGraphicsPipe:: ~IPhoneGraphicsPipe() { - [_view_controller release]; - [_window release]; + [_view_controller release]; + [_window release]; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string IPhoneGraphicsPipe:: get_interface_name() const { return "OpenGL ES"; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// IPhoneGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default IPhoneGraphicsPipe. + */ PT(GraphicsPipe) IPhoneGraphicsPipe:: pipe_constructor() { - // There is only one IPhoneGraphicsPipe in the universe for any - // given application. Even if you ask for a new one, you just get - // the same one you had before. + // There is only one IPhoneGraphicsPipe in the universe for any given + // application. Even if you ask for a new one, you just get the same one + // you had before. if (_global_ptr == (IPhoneGraphicsPipe *)NULL) { _global_ptr = new IPhoneGraphicsPipe; _global_ptr->ref(); @@ -84,26 +72,21 @@ pipe_constructor() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// -GraphicsPipe::PreferredWindowThread +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ +GraphicsPipe::PreferredWindowThread IPhoneGraphicsPipe::get_preferred_window_thread() const { return PWT_app; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::rotate_windows -// Access: Public, Virtual -// Description: Called in response to an orientation change event, -// this tells all of the windows created on the pipe to -// resize themselves according to the new orientation. -//////////////////////////////////////////////////////////////////// +/** + * Called in response to an orientation change event, this tells all of the + * windows created on the pipe to resize themselves according to the new + * orientation. + */ void IPhoneGraphicsPipe:: rotate_windows() { GraphicsWindows::iterator gwi; @@ -114,11 +97,9 @@ rotate_windows() { } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) IPhoneGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -137,7 +118,7 @@ make_output(const string &name, if (gsg != 0) { DCAST_INTO_R(iphonegsg, gsg, NULL); } - + // First thing to try: an IPhoneGraphicsWindow if (retry == 0) { diff --git a/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.h b/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.h index 663fe3573c..60707685c2 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.h +++ b/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.h @@ -1,20 +1,19 @@ -// Filename: iPhoneGraphicsStateGuardian.h -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsStateGuardian.h + * @author drose + * @date 2009-04-08 + */ #ifndef IPHONEGRAPHICSSTATEGUARDIAN_H #define IPHONEGRAPHICSSTATEGUARDIAN_H - + #include "pandabase.h" #include "glesgsg.h" @@ -22,10 +21,9 @@ class IPhoneGraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : IPhoneGraphicsStateGuardian -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class IPhoneGraphicsStateGuardian : public GLESGraphicsStateGuardian { public: IPhoneGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -35,13 +33,12 @@ public: protected: virtual void *get_extension_func(const char *prefix, const char *name); - + private: void describe_pixel_format(FrameBufferProperties &fb_props); - // We have to save a pointer to the GSG we intend to share texture - // context with, since we don't create our own context in the - // constructor. + // We have to save a pointer to the GSG we intend to share texture context + // with, since we don't create our own context in the constructor. PT(IPhoneGraphicsStateGuardian) _share_with; public: diff --git a/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.mm b/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.mm index 0db10a4ac5..79a70247a2 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsStateGuardian.mm @@ -1,16 +1,15 @@ -// Filename: iPhoneGraphicsStateGuardian.mm -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsStateGuardian.mm + * @author drose + * @date 2009-04-08 + */ #include "iPhoneGraphicsStateGuardian.h" #include "string_utils.h" @@ -23,26 +22,20 @@ TypeHandle IPhoneGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsStateGuardian::get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *IPhoneGraphicsStateGuardian:: get_extension_func(const char *prefix, const char *name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IPhoneGraphicsStateGuardian:: IPhoneGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, IPhoneGraphicsStateGuardian *share_with) : @@ -52,32 +45,25 @@ IPhoneGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _shared_buffer = 1011; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IPhoneGraphicsStateGuardian:: ~IPhoneGraphicsStateGuardian() { } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void IPhoneGraphicsStateGuardian:: reset() { GLESGraphicsStateGuardian::reset(); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsStateGuardian::describe_pixel_format -// Access: Private -// Description: Fills in the fb_props member with the appropriate -// values according to the chosen pixel format. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the fb_props member with the appropriate values according to the + * chosen pixel format. + */ void IPhoneGraphicsStateGuardian:: describe_pixel_format(FrameBufferProperties &fb_props) { } diff --git a/panda/src/iphonedisplay/iPhoneGraphicsWindow.I b/panda/src/iphonedisplay/iPhoneGraphicsWindow.I index 5652892788..7cacffd357 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsWindow.I +++ b/panda/src/iphonedisplay/iPhoneGraphicsWindow.I @@ -1,14 +1,12 @@ -// Filename: iPhoneGraphicsWindow.I -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsWindow.I + * @author drose + * @date 2009-04-08 + */ diff --git a/panda/src/iphonedisplay/iPhoneGraphicsWindow.h b/panda/src/iphonedisplay/iPhoneGraphicsWindow.h index 4dde1572ce..7a73a70302 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsWindow.h +++ b/panda/src/iphonedisplay/iPhoneGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: iPhoneGraphicsWindow.h -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsWindow.h + * @author drose + * @date 2009-04-08 + */ #ifndef IPHONEGRAPHICSWINDOW_H #define IPHONEGRAPHICSWINDOW_H @@ -23,14 +22,12 @@ #import -//////////////////////////////////////////////////////////////////// -// Class : IPhoneGraphicsWindow -// Description : An interface to the osx/ system for managing GL -// windows under X. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the osx/ system for managing GL windows under X. + */ class IPhoneGraphicsWindow : public GraphicsWindow { public: - IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -67,7 +64,7 @@ private: void handle_button_delta(int num_touches); private: - EAGLView *_gl_view; + EAGLView *_gl_view; int _last_buttons; public: diff --git a/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm b/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm index 1f2cbbd824..cae0463e6b 100644 --- a/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm +++ b/panda/src/iphonedisplay/iPhoneGraphicsWindow.mm @@ -1,21 +1,20 @@ -// Filename: iPhoneGraphicsWindow.mm -// Created by: drose (08Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iPhoneGraphicsWindow.mm + * @author drose + * @date 2009-04-08 + */ -// We include these system header files first, because there is a -// namescope conflict between them and some other header file that -// gets included later (in particular, TCP_NODELAY must not be a -// #define symbol for these headers to be included properly). +// We include these system header files first, because there is a namescope +// conflict between them and some other header file that gets included later +// (in particular, TCP_NODELAY must not be a #define symbol for these headers +// to be included properly). #include @@ -38,13 +37,11 @@ TypeHandle IPhoneGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IPhoneGraphicsWindow:: -IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, +IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -64,11 +61,9 @@ IPhoneGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _input_devices.push_back(device); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IPhoneGraphicsWindow:: ~IPhoneGraphicsWindow() { if (_gl_view != nil) { @@ -76,19 +71,16 @@ IPhoneGraphicsWindow:: } } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool IPhoneGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); - + begin_frame_spam(mode); if (_gsg == (GraphicsStateGuardian *)NULL) { // not powered up .. just abort.. @@ -101,22 +93,20 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void IPhoneGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); - + if (mode == FM_render) { nassertv(_gsg != (GraphicsStateGuardian *)NULL); copy_to_textures(); - + _gsg->end_frame(current_thread); if (_gl_view != nil) { @@ -125,20 +115,17 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void IPhoneGraphicsWindow:: end_flip() { } @@ -147,36 +134,29 @@ void IPhoneGraphicsWindow:: begin_flip() { } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::process_events -// Access: Protected, Virtual -// Description: Required event upcall, used to dispatch window and -// application events back into panda. -//////////////////////////////////////////////////////////////////// +/** + * Required event upcall, used to dispatch window and application events back + * into panda. + */ void IPhoneGraphicsWindow:: process_events() { GraphicsWindow::process_events(); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void IPhoneGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (iphonedisplay_cat.is_debug()) { @@ -185,17 +165,14 @@ set_properties_now(WindowProperties &properties) { iphonedisplay_cat.debug() << "set_properties_now " << properties << "\n"; } - + GraphicsWindow::set_properties_now(properties); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::clear_pipe -// Access: Protected, Virtual -// Description: Sets the window's _pipe pointer to NULL; this is -// generally called only as a precursor to deleting the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Sets the window's _pipe pointer to NULL; this is generally called only as a + * precursor to deleting the window. + */ void IPhoneGraphicsWindow:: clear_pipe() { IPhoneGraphicsPipe *ipipe; @@ -205,13 +182,10 @@ clear_pipe() { GraphicsWindow::clear_pipe(); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::rotate_window -// Access: Public -// Description: Called in response to an orientation change event, -// this tells the window to resize itself according to -// the new orientation. -//////////////////////////////////////////////////////////////////// +/** + * Called in response to an orientation change event, this tells the window to + * resize itself according to the new orientation. + */ void IPhoneGraphicsWindow:: rotate_window() { CGRect bounds = [_gl_view bounds]; @@ -221,11 +195,9 @@ rotate_window() { system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::touches_began -// Access: Public -// Description: Beginning a single- or multi-touch gesture. -//////////////////////////////////////////////////////////////////// +/** + * Beginning a single- or multi-touch gesture. + */ void IPhoneGraphicsWindow:: touches_began(NSSet *touches, UIEvent *event) { // Average the position of all of the touches. @@ -235,11 +207,9 @@ touches_began(NSSet *touches, UIEvent *event) { handle_button_delta([touches count]); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::touches_moved -// Access: Public -// Description: Continuing a single- or multi-touch gesture. -//////////////////////////////////////////////////////////////////// +/** + * Continuing a single- or multi-touch gesture. + */ void IPhoneGraphicsWindow:: touches_moved(NSSet *touches, UIEvent *event) { // Average the position of all of the touches. @@ -249,37 +219,30 @@ touches_moved(NSSet *touches, UIEvent *event) { handle_button_delta([touches count]); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::touches_ended -// Access: Public -// Description: Finishing a single- or multi-touch gesture. -//////////////////////////////////////////////////////////////////// +/** + * Finishing a single- or multi-touch gesture. + */ void IPhoneGraphicsWindow:: touches_ended(NSSet *touches, UIEvent *event) { set_pointer_out_of_window(); handle_button_delta(0); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::touches_cancelled -// Access: Public -// Description: Cancelling a single- or multi-touch gesture. -//////////////////////////////////////////////////////////////////// +/** + * Cancelling a single- or multi-touch gesture. + */ void IPhoneGraphicsWindow:: touches_cancelled(NSSet *touches, UIEvent *event) { set_pointer_out_of_window(); handle_button_delta(0); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::get_average_location -// Access: Public -// Description: Returns the average location of all of the indicated -// touches. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average location of all of the indicated touches. + */ CGPoint IPhoneGraphicsWindow:: get_average_location(NSSet *touches) { - NSEnumerator *enumerator = [ touches objectEnumerator ]; + NSEnumerator *enumerator = [ touches objectEnumerator ]; CGPoint sum; sum.x = 0.0; sum.y = 0.0; @@ -297,42 +260,36 @@ get_average_location(NSSet *touches) { return sum; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void IPhoneGraphicsWindow:: close_window() { - // system_close_window(); + // system_close_window(); WindowProperties properties; properties.set_open(false); system_changed_properties(properties); -// release_system_resources(false); +// release_system_resources(false); _gsg.clear(); _active = false; GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool IPhoneGraphicsWindow:: open_window() { nassertr(_gsg == (GraphicsStateGuardian *)NULL, false); - _gl_view = [ [ EAGLView alloc ] initWithFrame: - [ [ UIScreen mainScreen ] applicationFrame ] - ]; + _gl_view = [ [ EAGLView alloc ] initWithFrame: + [ [ UIScreen mainScreen ] applicationFrame ] + ]; _gl_view->_window = this; - + IPhoneGraphicsPipe *iphonepipe = DCAST(IPhoneGraphicsPipe, _pipe); nassertr(iphonepipe != NULL, false); @@ -352,45 +309,36 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::set_pointer_in_window -// Access: Private -// Description: Indicates the mouse pointer is seen within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is seen within the window. + */ void IPhoneGraphicsWindow:: set_pointer_in_window(int x, int y) { _input_devices[0].set_pointer_in_window(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::set_pointer_out_of_window -// Access: Private -// Description: Indicates the mouse pointer is no longer within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is no longer within the window. + */ void IPhoneGraphicsWindow:: set_pointer_out_of_window() { _input_devices[0].set_pointer_out_of_window(); } -//////////////////////////////////////////////////////////////////// -// Function: IPhoneGraphicsWindow::handle_button_delta -// Access: Private -// Description: Used to emulate button events -//////////////////////////////////////////////////////////////////// +/** + * Used to emulate button events + */ void IPhoneGraphicsWindow:: handle_button_delta(int num_touches) { - // For now, we'll just map the number of touches to the mouse button - // number. 1 touch is button 1, 2 touches is button 3 (because this - // is the normal secondary button), and 3 touches is button 2. + // For now, we'll just map the number of touches to the mouse button number. + // 1 touch is button 1, 2 touches is button 3 (because this is the normal + // secondary button), and 3 touches is button 2. - // This is just a cheesy remapping that will assist migrating - // applications from standard PC's to iPhone. It also works well - // enough within the existing Panda mouse-input framework. We - // should expose the full multitouch functionality eventually, but - // really, the whole mouse-input framework needs a bit of a - // redesign. + // This is just a cheesy remapping that will assist migrating applications + // from standard PC's to iPhone. It also works well enough within the + // existing Panda mouse-input framework. We should expose the full + // multitouch functionality eventually, but really, the whole mouse-input + // framework needs a bit of a redesign. int new_buttons; switch (num_touches) { diff --git a/panda/src/iphonedisplay/viewController.h b/panda/src/iphonedisplay/viewController.h index 4922bb1c39..9784ee728a 100644 --- a/panda/src/iphonedisplay/viewController.h +++ b/panda/src/iphonedisplay/viewController.h @@ -1,29 +1,28 @@ -// Filename: viewController.h -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file viewController.h + * @author drose + * @date 2009-04-10 + */ #include "pandabase.h" -#import -#import +#import +#import class IPhoneGraphicsPipe; -@interface ControllerDemoViewController : UIViewController { +@interface ControllerDemoViewController : UIViewController { @private IPhoneGraphicsPipe *_pipe; -} +} - (id)initWithPipe: (IPhoneGraphicsPipe *)pipe; -@end +@end diff --git a/panda/src/iphonedisplay/viewController.mm b/panda/src/iphonedisplay/viewController.mm index 359b598ad0..efe8867119 100644 --- a/panda/src/iphonedisplay/viewController.mm +++ b/panda/src/iphonedisplay/viewController.mm @@ -1,57 +1,56 @@ -// Filename: viewController.mm -// Created by: drose (10Apr09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file viewController.mm + * @author drose + * @date 2009-04-10 + */ -#import "viewController.h" +#import "viewController.h" #include "pnotify.h" #include "iPhoneGraphicsPipe.h" #include "config_iphonedisplay.h" -@implementation ControllerDemoViewController +@implementation ControllerDemoViewController - (id)initWithPipe: (IPhoneGraphicsPipe *)pipe -{ - self = [ super init ]; +{ + self = [ super init ]; _pipe = pipe; - return self; -} + return self; +} - (BOOL)shouldAutorotateToInterfaceOrientation: - (UIInterfaceOrientation)interfaceOrientation -{ + (UIInterfaceOrientation)interfaceOrientation +{ return iphone_autorotate_view; -} +} -- (void)didRotateFromInterfaceOrientation: - (UIInterfaceOrientation)fromInterfaceOrientation -{ +- (void)didRotateFromInterfaceOrientation: + (UIInterfaceOrientation)fromInterfaceOrientation +{ _pipe->rotate_windows(); -} +} -- (void)viewDidLoad { - [ super viewDidLoad ]; - /* Add custom post-load code here */ -} +- (void)viewDidLoad { + [ super viewDidLoad ]; + /* Add custom post-load code here */ +} -- (void)didReceiveMemoryWarning { - [ super didReceiveMemoryWarning ]; - /* Add custom low-memory code here */ +- (void)didReceiveMemoryWarning { + [ super didReceiveMemoryWarning ]; + /* Add custom low-memory code here */ nout << "low-memory handler in view controller\n"; -} +} -- (void)dealloc { - [ super dealloc ]; -} +- (void)dealloc { + [ super dealloc ]; +} -@end +@end diff --git a/panda/src/linmath/aa_luse.h b/panda/src/linmath/aa_luse.h index 4c809fba0e..8be2dbddaa 100644 --- a/panda/src/linmath/aa_luse.h +++ b/panda/src/linmath/aa_luse.h @@ -1,25 +1,23 @@ -// Filename: aa_luse.h -// Created by: drose (13Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file aa_luse.h + * @author drose + * @date 1999-01-13 + */ #ifndef AA_LUSE_H #define AA_LUSE_H -// This file is include by luse.h to do all the work required by that -// header file. It is in a separate header file to avoid cyclic -// header dependencies, and because interrogate wants to sort header -// files in alphabetical order and this one should pretty much be -// included first. +// This file is include by luse.h to do all the work required by that header +// file. It is in a separate header file to avoid cyclic header dependencies, +// and because interrogate wants to sort header files in alphabetical order +// and this one should pretty much be included first. #include "pandabase.h" @@ -35,13 +33,12 @@ #include "lorientation.h" #include "lcast_to.h" -//ensure FLOATTYPE is set to float for macros are used outside of LINMATH +// ensure FLOATTYPE is set to float for macros are used outside of LINMATH #include "fltnames.h" -// This macro defines the cast-to-another-numeric-type operator for -// all of the things defined in this package. It works by virtue of -// there being an appropriate lcast_to() template function defined for -// each class. +// This macro defines the cast-to-another-numeric-type operator for all of the +// things defined in this package. It works by virtue of there being an +// appropriate lcast_to() template function defined for each class. #define LCAST(numeric_type, object) lcast_to((numeric_type *)0, object) @@ -62,8 +59,8 @@ typedef LPoint3d LTexCoord3d; typedef LVecBase4d LColord; typedef LVecBase3d LRGBColord; -// The following names are only for legacy Python code. These aren't -// real typedefs; they're just commands to interrogate. +// The following names are only for legacy Python code. These aren't real +// typedefs; they're just commands to interrogate. #ifdef CPPPARSER typedef LMatrix4f Mat4F; typedef LMatrix3f Mat3F; @@ -91,11 +88,10 @@ typedef LPoint2d Point2D; typedef LQuaterniond QuatD; #endif // CPPPARSER -// And finally, we define the unqualified "standard" float type, which -// is based on the setting of STDFLOAT_DOUBLE. This is the type that -// is used for graphics-specific operations such as vertex and pos -// value. The default is single-precision floats, which is almost -// always what you really want. +// And finally, we define the unqualified "standard" float type, which is +// based on the setting of STDFLOAT_DOUBLE. This is the type that is used for +// graphics-specific operations such as vertex and pos value. The default is +// single-precision floats, which is almost always what you really want. #ifndef STDFLOAT_DOUBLE // The default setting--single-precision floats. diff --git a/panda/src/linmath/cast_to_double.I b/panda/src/linmath/cast_to_double.I index c71ea66218..e29e6a0c33 100644 --- a/panda/src/linmath/cast_to_double.I +++ b/panda/src/linmath/cast_to_double.I @@ -1,16 +1,15 @@ -// Filename: cast_to_double.I -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cast_to_double.I + * @author drose + * @date 2000-05-24 + */ INLINE_LINMATH LVecBase2d cast_to_double(const LVecBase2f &source) { return LCAST(double, source); @@ -55,4 +54,3 @@ INLINE_LINMATH LMatrix3d cast_to_double(const LMatrix3f &source) { INLINE_LINMATH LMatrix4d cast_to_double(const LMatrix4f &source) { return LCAST(double, source); } - diff --git a/panda/src/linmath/cast_to_double.h b/panda/src/linmath/cast_to_double.h index 3574054cc6..600ea639d2 100644 --- a/panda/src/linmath/cast_to_double.h +++ b/panda/src/linmath/cast_to_double.h @@ -1,26 +1,25 @@ -// Filename: cast_to_double.h -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cast_to_double.h + * @author drose + * @date 2000-05-24 + */ #ifndef CAST_TO_DOUBLE_H #define CAST_TO_DOUBLE_H #include "luse.h" -// The functions in this file are primarily for the benefit of a -// higher-level language that can't take advantage of the LCAST macro. -// These are a number of functions that convert our various math -// objects between floats and doubles. +// The functions in this file are primarily for the benefit of a higher-level +// language that can't take advantage of the LCAST macro. These are a number +// of functions that convert our various math objects between floats and +// doubles. INLINE_LINMATH LVecBase2d cast_to_double(const LVecBase2f &source); INLINE_LINMATH LVecBase3d cast_to_double(const LVecBase3f &source); @@ -37,5 +36,3 @@ INLINE_LINMATH LMatrix4d cast_to_double(const LMatrix4f &source); #include "cast_to_double.I" #endif - - diff --git a/panda/src/linmath/cast_to_float.I b/panda/src/linmath/cast_to_float.I index ab83526492..355abbe5f1 100644 --- a/panda/src/linmath/cast_to_float.I +++ b/panda/src/linmath/cast_to_float.I @@ -1,16 +1,15 @@ -// Filename: cast_to_float.I -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cast_to_float.I + * @author drose + * @date 2000-05-24 + */ INLINE_LINMATH LVecBase2f cast_to_float(const LVecBase2d &source) { return LCAST(float, source); @@ -55,4 +54,3 @@ INLINE_LINMATH LMatrix3f cast_to_float(const LMatrix3d &source) { INLINE_LINMATH LMatrix4f cast_to_float(const LMatrix4d &source) { return LCAST(float, source); } - diff --git a/panda/src/linmath/cast_to_float.h b/panda/src/linmath/cast_to_float.h index b30216ff8c..9b285b6568 100644 --- a/panda/src/linmath/cast_to_float.h +++ b/panda/src/linmath/cast_to_float.h @@ -1,26 +1,25 @@ -// Filename: cast_to_float.h -// Created by: drose (24May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cast_to_float.h + * @author drose + * @date 2000-05-24 + */ #ifndef CAST_TO_FLOAT_H #define CAST_TO_FLOAT_H #include "luse.h" -// The functions in this file are primarily for the benefit of a -// higher-level language that can't take advantage of the LCAST macro. -// These are a number of functions that convert our various math -// objects between floats and doubles. +// The functions in this file are primarily for the benefit of a higher-level +// language that can't take advantage of the LCAST macro. These are a number +// of functions that convert our various math objects between floats and +// doubles. INLINE_LINMATH LVecBase2f cast_to_float(const LVecBase2d &source); INLINE_LINMATH LVecBase3f cast_to_float(const LVecBase3d &source); @@ -37,5 +36,3 @@ INLINE_LINMATH LMatrix4f cast_to_float(const LMatrix4d &source); #include "cast_to_float.I" #endif - - diff --git a/panda/src/linmath/compose_matrix.cxx b/panda/src/linmath/compose_matrix.cxx index 636c8b69ff..65fa47d0b3 100644 --- a/panda/src/linmath/compose_matrix.cxx +++ b/panda/src/linmath/compose_matrix.cxx @@ -1,16 +1,15 @@ -// Filename: compose_matrix.cxx -// Created by: drose (27Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compose_matrix.cxx + * @author drose + * @date 1999-01-27 + */ #include "deg_2_rad.h" #include "config_linmath.h" diff --git a/panda/src/linmath/compose_matrix.h b/panda/src/linmath/compose_matrix.h index 842e7200e8..36a78ea64e 100644 --- a/panda/src/linmath/compose_matrix.h +++ b/panda/src/linmath/compose_matrix.h @@ -1,32 +1,26 @@ -// Filename: compose_matrix.h -// Created by: drose (27Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compose_matrix.h + * @author drose + * @date 1999-01-27 + */ #ifndef COMPOSE_MATRIX_H #define COMPOSE_MATRIX_H -//////////////////////////////////////////////////////////////////// -// -// compose_matrix(), decompose_matrix() -// -// These two functions build and/or extract an affine matrix into -// its constituent parts: scale, hpr, and translate. -// -// There are also two additional flavors for 3x3 matrices. These are -// treated as the upper 3x3 part of a general 4x4 matrix, and so can -// only represent rotations and scales. -// -//////////////////////////////////////////////////////////////////// +/* + * compose_matrix(), decompose_matrix() These two functions build andor + * extract an affine matrix into its constituent parts: scale, hpr, and + * translate. There are also two additional flavors for 3x3 matrices. These + * are treated as the upper 3x3 part of a general 4x4 matrix, and so can only + * represent rotations and scales. + */ #include "pandabase.h" #include @@ -40,9 +34,8 @@ #include "lvec2_ops.h" #include "lvec3_ops.h" -// These define the standard one-letter names for the components in -// the array-accepting forms of compose_matrix() and -// decompose_matrix(). +// These define the standard one-letter names for the components in the array- +// accepting forms of compose_matrix() and decompose_matrix(). static const int num_matrix_components = 12; EXPCL_PANDA_LINMATH extern const char * const matrix_component_letters; EXPCL_PANDA_LINMATH extern const double matrix_component_defaults[num_matrix_components]; @@ -54,4 +47,3 @@ EXPCL_PANDA_LINMATH extern const double matrix_component_defaults[num_matrix_com #include "compose_matrix_src.h" #endif - diff --git a/panda/src/linmath/compose_matrix_src.I b/panda/src/linmath/compose_matrix_src.I index 54cbc2956d..eaae286af4 100644 --- a/panda/src/linmath/compose_matrix_src.I +++ b/panda/src/linmath/compose_matrix_src.I @@ -1,23 +1,20 @@ -// Filename: compose_matrix_src.I -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compose_matrix_src.I + * @author drose + * @date 1999-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: compose_matrix -// Description: Computes the 4x4 matrix according to scale, shear, -// rotation, and translation. -//////////////////////////////////////////////////////////////////// +/** + * Computes the 4x4 matrix according to scale, shear, rotation, and + * translation. + */ INLINE_LINMATH void compose_matrix(FLOATNAME(LMatrix4) &mat, const FLOATNAME(LVecBase3) &scale, @@ -30,11 +27,10 @@ compose_matrix(FLOATNAME(LMatrix4) &mat, mat = FLOATNAME(LMatrix4)(upper3, translate); } -//////////////////////////////////////////////////////////////////// -// Function: compose_matrix -// Description: Computes the 4x4 matrix according to scale, shear, -// rotation, and translation. -//////////////////////////////////////////////////////////////////// +/** + * Computes the 4x4 matrix according to scale, shear, rotation, and + * translation. + */ INLINE_LINMATH void compose_matrix(FLOATNAME(LMatrix4) &mat, const FLOATTYPE components[num_matrix_components], @@ -54,13 +50,11 @@ compose_matrix(FLOATNAME(LMatrix4) &mat, compose_matrix(mat, scale, shear, hpr, translate, cs); } -//////////////////////////////////////////////////////////////////// -// Function: decompose_matrix -// Description: Extracts out the components of an affine matrix. -// Returns true if the scale, shear, hpr, and translate -// completely describe the matrix, or false if the -// matrix is not affine. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out the components of an affine matrix. Returns true if the + * scale, shear, hpr, and translate completely describe the matrix, or false + * if the matrix is not affine. + */ INLINE_LINMATH bool decompose_matrix(const FLOATNAME(LMatrix4) &mat, FLOATNAME(LVecBase3) &scale, @@ -80,13 +74,11 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat, #endif } -//////////////////////////////////////////////////////////////////// -// Function: decompose_matrix -// Description: Extracts out the components of an affine matrix. -// Returns true if the scale, shear, hpr, and translate -// completely describe the matrix, or false if the -// matrix is not affine. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out the components of an affine matrix. Returns true if the + * scale, shear, hpr, and translate completely describe the matrix, or false + * if the matrix is not affine. + */ INLINE_LINMATH bool decompose_matrix(const FLOATNAME(LMatrix4) &mat, FLOATTYPE components[num_matrix_components], @@ -108,8 +100,8 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat, return result; } -// The following functions are deprecated; they have been replaced -// with new versions, above, that accept a shear component as well. +// The following functions are deprecated; they have been replaced with new +// versions, above, that accept a shear component as well. // Deprecated function. diff --git a/panda/src/linmath/compose_matrix_src.cxx b/panda/src/linmath/compose_matrix_src.cxx index 2378221485..180f498e84 100644 --- a/panda/src/linmath/compose_matrix_src.cxx +++ b/panda/src/linmath/compose_matrix_src.cxx @@ -1,27 +1,23 @@ -// Filename: compose_matrix_src.cxx -// Created by: drose (27Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compose_matrix_src.cxx + * @author drose + * @date 1999-01-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: unwind_yup_rotation_old_hpr -// Description: Extracts the rotation about the x, y, and z axes from -// the given hpr & scale matrix. Adjusts the matrix -// to eliminate the rotation. -// -// This function assumes the matrix is stored in a -// right-handed Y-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the rotation about the x, y, and z axes from the given hpr & scale + * matrix. Adjusts the matrix to eliminate the rotation. + * + * This function assumes the matrix is stored in a right-handed Y-up + * coordinate system. + */ static void unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { TAU_PROFILE("void unwind_yup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); @@ -31,76 +27,73 @@ unwind_yup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) mat.get_row(x,0); mat.get_row(y,1); mat.get_row(z,2); - + // Project X onto the XY plane. FLOATNAME(LVector2) xy(x[0], x[1]); xy = normalize(xy); - + // Compute the rotation about the +Z (back) axis. This is roll. FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0]))); - + // Unwind the roll from the axes, and continue. FLOATNAME(LMatrix3) rot_z; rot_z.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f), CS_yup_right); - + x = x * rot_z; y = y * rot_z; z = z * rot_z; - + // Project the rotated X into the XZ plane. FLOATNAME(LVector2) xz(x[0], x[2]); xz = normalize(xz); - - // Compute the rotation about the +Y (up) axis. This is yaw, or - // "heading". + + // Compute the rotation about the +Y (up) axis. This is yaw, or "heading". FLOATTYPE heading = rad_2_deg(((FLOATTYPE)-catan2(xz[1], xz[0]))); - + // Unwind the heading, and continue. FLOATNAME(LMatrix3) rot_y; rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f), CS_yup_right); - + x = x * rot_y; y = y * rot_y; z = z * rot_y; - + // Project the rotated Z into the YZ plane. FLOATNAME(LVector2) yz(z[1], z[2]); yz = normalize(yz); - + // Compute the rotation about the +X (right) axis. This is pitch. FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)-catan2(yz[0], yz[1]))); - + // Unwind the pitch. FLOATNAME(LMatrix3) rot_x; rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f), CS_yup_right); - + x = x * rot_x; y = y * rot_x; z = z * rot_x; - + // Reset the matrix to reflect the unwinding. mat.set_row(0, x); mat.set_row(1, y); mat.set_row(2, z); - + // Return the three rotation components. hpr[0] = heading; hpr[1] = pitch; hpr[2] = roll; } -//////////////////////////////////////////////////////////////////// -// Function: unwind_zup_rotation_old_hpr -// Description: Extracts the rotation about the x, y, and z axes from -// the given hpr & scale matrix. Adjusts the matrix -// to eliminate the rotation. -// -// This function assumes the matrix is stored in a -// right-handed Z-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the rotation about the x, y, and z axes from the given hpr & scale + * matrix. Adjusts the matrix to eliminate the rotation. + * + * This function assumes the matrix is stored in a right-handed Z-up + * coordinate system. + */ static void unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { TAU_PROFILE("void unwind_zup_rotation_old_hpr(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); @@ -109,15 +102,15 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) mat.get_row(x,0); mat.get_row(y,1); mat.get_row(z,2); - - + + // Project X into the XZ plane. FLOATNAME(LVector2) xz(x[0], x[2]); xz = normalize(xz); - + // Compute the rotation about the -Y (back) axis. This is roll. FLOATTYPE roll = rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0]))); - + if (y[1] < 0.0f) { if (roll < 0.0f) { roll += 180.0; @@ -125,68 +118,65 @@ unwind_zup_rotation_old_hpr(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) roll -= 180.0; } } - + // Unwind the roll from the axes, and continue. FLOATNAME(LMatrix3) rot_y; rot_y.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f), CS_zup_right); - + x = x * rot_y; y = y * rot_y; z = z * rot_y; - + // Project the rotated X into the XY plane. FLOATNAME(LVector2) xy(x[0], x[1]); xy = normalize(xy); - - // Compute the rotation about the +Z (up) axis. This is yaw, or - // "heading". + + // Compute the rotation about the +Z (up) axis. This is yaw, or "heading". FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0]))); - + // Unwind the heading, and continue. FLOATNAME(LMatrix3) rot_z; rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f), CS_zup_right); - + x = x * rot_z; y = y * rot_z; z = z * rot_z; - + // Project the rotated Y into the YZ plane. FLOATNAME(LVector2) yz(y[1], y[2]); yz = normalize(yz); - + // Compute the rotation about the +X (right) axis. This is pitch. FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0]))); - + // Unwind the pitch. FLOATNAME(LMatrix3) rot_x; rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f), CS_zup_right); - + x = x * rot_x; y = y * rot_x; z = z * rot_x; - + // Reset the matrix to reflect the unwinding. mat.set_row(0, x); mat.set_row(1, y); mat.set_row(2, z); - + // Return the three rotation components. hpr[0] = heading; hpr[1] = pitch; hpr[2] = roll; } -//////////////////////////////////////////////////////////////////// -// Function: decompose_matrix_old_hpr -// Description: Extracts out the components of a 3x3 rotation matrix. -// Returns true if successful, or false if there was an -// error. Since a 3x3 matrix always contains an affine -// transform, this should succeed in the normal case; -// singular transforms are not treated as an error. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out the components of a 3x3 rotation matrix. Returns true if + * successful, or false if there was an error. Since a 3x3 matrix always + * contains an affine transform, this should succeed in the normal case; + * singular transforms are not treated as an error. + */ bool decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &scale, @@ -203,8 +193,8 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, << "decomposing " << mat << " via cs " << cs << "\n"; } - // Extract the rotation and scale, according to the coordinate - // system of choice. + // Extract the rotation and scale, according to the coordinate system of + // choice. FLOATNAME(LMatrix3) new_mat(mat); @@ -258,7 +248,7 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, << "Unexpected coordinate system: " << (int)cs << "\n"; return false; } - + if (linmath_cat.is_debug()) { linmath_cat.debug() << "after unwind, mat is " << new_mat << "\n"; @@ -266,8 +256,7 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, scale.set(new_mat(0, 0), new_mat(1, 1), new_mat(2, 2)); - // Normalize the scale out of the shear components, and return the - // shear. + // Normalize the scale out of the shear components, and return the shear. if (scale[0] != 0.0) { new_mat(0, 1) /= scale[0]; new_mat(0, 2) /= scale[0]; @@ -284,15 +273,13 @@ decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, shear.set(new_mat(0, 1) + new_mat(1, 0), new_mat(2, 0) + new_mat(0, 2), new_mat(2, 1) + new_mat(1, 2)); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: compose_matrix -// Description: Computes the 3x3 matrix from scale, shear, and -// rotation. -//////////////////////////////////////////////////////////////////// +/** + * Computes the 3x3 matrix from scale, shear, and rotation. + */ void compose_matrix(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVecBase3) &scale, @@ -318,15 +305,13 @@ compose_matrix(FLOATNAME(LMatrix3) &mat, } } -//////////////////////////////////////////////////////////////////// -// Function: unwind_yup_rotation -// Description: Extracts the rotation about the x, y, and z axes from -// the given hpr & scale matrix. Adjusts the matrix -// to eliminate the rotation. -// -// This function assumes the matrix is stored in a -// right-handed Y-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the rotation about the x, y, and z axes from the given hpr & scale + * matrix. Adjusts the matrix to eliminate the rotation. + * + * This function assumes the matrix is stored in a right-handed Y-up + * coordinate system. + */ static void unwind_yup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { TAU_PROFILE("void unwind_yup_rotation(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); @@ -336,76 +321,73 @@ unwind_yup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { mat.get_row(x,0); mat.get_row(y,1); mat.get_row(z,2); - + // Project Z into the XZ plane. FLOATNAME(LVector2) xz(z[0], z[2]); xz = normalize(xz); - - // Compute the rotation about the +Y (up) axis. This is yaw, or - // "heading". + + // Compute the rotation about the +Y (up) axis. This is yaw, or "heading". FLOATTYPE heading = rad_2_deg(((FLOATTYPE)catan2(xz[0], xz[1]))); - + // Unwind the heading, and continue. FLOATNAME(LMatrix3) rot_y; rot_y.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f), CS_yup_right); - + x = x * rot_y; y = y * rot_y; z = z * rot_y; - + // Project the rotated Z into the YZ plane. FLOATNAME(LVector2) yz(z[1], z[2]); yz = normalize(yz); - + // Compute the rotation about the +X (right) axis. This is pitch. FLOATTYPE pitch = rad_2_deg((FLOATTYPE)(-catan2(yz[0], yz[1]))); - + // Unwind the pitch. FLOATNAME(LMatrix3) rot_x; rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f), CS_yup_right); - + x = x * rot_x; y = y * rot_x; z = z * rot_x; - + // Project the rotated X onto the XY plane. FLOATNAME(LVector2) xy(x[0], x[1]); xy = normalize(xy); - + // Compute the rotation about the +Z (back) axis. This is roll. FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xy[1], xy[0]))); - + // Unwind the roll from the axes, and continue. FLOATNAME(LMatrix3) rot_z; rot_z.set_rotate_mat_normaxis(roll, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f), CS_yup_right); - + x = x * rot_z; y = y * rot_z; z = z * rot_z; - + // Reset the matrix to reflect the unwinding. mat.set_row(0, x); mat.set_row(1, y); mat.set_row(2, z); - + // Return the three rotation components. hpr[0] = heading; hpr[1] = pitch; hpr[2] = roll; } -//////////////////////////////////////////////////////////////////// -// Function: unwind_zup_rotation -// Description: Extracts the rotation about the x, y, and z axes from -// the given hpr & scale matrix. Adjusts the matrix -// to eliminate the rotation. -// -// This function assumes the matrix is stored in a -// right-handed Z-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the rotation about the x, y, and z axes from the given hpr & scale + * matrix. Adjusts the matrix to eliminate the rotation. + * + * This function assumes the matrix is stored in a right-handed Z-up + * coordinate system. + */ static void unwind_zup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { TAU_PROFILE("void unwind_zup_rotation(LMatrix3 &, LVecBase3 &)", " ", TAU_USER); @@ -414,75 +396,72 @@ unwind_zup_rotation(FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &hpr) { mat.get_row(x,0); mat.get_row(y,1); mat.get_row(z,2); - + // Project Y into the XY plane. FLOATNAME(LVector2) xy(y[0], y[1]); xy = normalize(xy); - - // Compute the rotation about the +Z (up) axis. This is yaw, or - // "heading". + + // Compute the rotation about the +Z (up) axis. This is yaw, or "heading". FLOATTYPE heading = -rad_2_deg(((FLOATTYPE)catan2(xy[0], xy[1]))); - + // Unwind the heading, and continue. FLOATNAME(LMatrix3) rot_z; rot_z.set_rotate_mat_normaxis(-heading, FLOATNAME(LVector3)(0.0f, 0.0f, 1.0f), CS_zup_right); - + x = x * rot_z; y = y * rot_z; z = z * rot_z; - + // Project the rotated Y into the YZ plane. FLOATNAME(LVector2) yz(y[1], y[2]); yz = normalize(yz); - + // Compute the rotation about the +X (right) axis. This is pitch. FLOATTYPE pitch = rad_2_deg(((FLOATTYPE)catan2(yz[1], yz[0]))); - + // Unwind the pitch. FLOATNAME(LMatrix3) rot_x; rot_x.set_rotate_mat_normaxis(-pitch, FLOATNAME(LVector3)(1.0f, 0.0f, 0.0f), CS_zup_right); - + x = x * rot_x; y = y * rot_x; z = z * rot_x; - + // Project X into the XZ plane. FLOATNAME(LVector2) xz(x[0], x[2]); xz = normalize(xz); - + // Compute the rotation about the -Y (back) axis. This is roll. FLOATTYPE roll = -rad_2_deg(((FLOATTYPE)catan2(xz[1], xz[0]))); - + // Unwind the roll from the axes, and continue. FLOATNAME(LMatrix3) rot_y; rot_y.set_rotate_mat_normaxis(-roll, FLOATNAME(LVector3)(0.0f, 1.0f, 0.0f), CS_zup_right); - + x = x * rot_y; y = y * rot_y; z = z * rot_y; - + // Reset the matrix to reflect the unwinding. mat.set_row(0, x); mat.set_row(1, y); mat.set_row(2, z); - + // Return the three rotation components. hpr[0] = heading; hpr[1] = pitch; hpr[2] = roll; } -//////////////////////////////////////////////////////////////////// -// Function: decompose_matrix -// Description: Extracts out the components of a 3x3 rotation matrix. -// Returns true if successful, or false if there was an -// error. Since a 3x3 matrix always contains an affine -// transform, this should succeed in the normal case; -// singular transforms are not treated as an error. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out the components of a 3x3 rotation matrix. Returns true if + * successful, or false if there was an error. Since a 3x3 matrix always + * contains an affine transform, this should succeed in the normal case; + * singular transforms are not treated as an error. + */ bool decompose_matrix(const FLOATNAME(LMatrix3) &mat, FLOATNAME(LVecBase3) &scale, @@ -499,8 +478,8 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat, << "decomposing " << mat << " via cs " << cs << "\n"; } - // Extract the rotation and scale, according to the coordinate - // system of choice. + // Extract the rotation and scale, according to the coordinate system of + // choice. FLOATNAME(LMatrix3) new_mat(mat); @@ -554,7 +533,7 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat, << "Unexpected coordinate system: " << (int)cs << "\n"; return false; } - + if (linmath_cat.is_debug()) { linmath_cat.debug() << "after unwind, mat is " << new_mat << "\n"; @@ -562,8 +541,7 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat, scale.set(new_mat(0, 0), new_mat(1, 1), new_mat(2, 2)); - // Normalize the scale out of the shear components, and return the - // shear. + // Normalize the scale out of the shear components, and return the shear. if (scale[0] != 0.0) { new_mat(0, 1) /= scale[0]; new_mat(0, 2) /= scale[0]; @@ -580,20 +558,17 @@ decompose_matrix(const FLOATNAME(LMatrix3) &mat, shear.set(new_mat(0, 1) + new_mat(1, 0), new_mat(2, 0) + new_mat(0, 2), new_mat(2, 1) + new_mat(1, 2)); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: old_to_new_hpr -// Description: Converts the HPR as represented in the old, broken -// way to the new, correct representation. Returns the -// new HPR. -// -// This function is provided to ease transition from old -// systems that relied on Panda's original broken HPR -// calculation. -//////////////////////////////////////////////////////////////////// +/** + * Converts the HPR as represented in the old, broken way to the new, correct + * representation. Returns the new HPR. + * + * This function is provided to ease transition from old systems that relied + * on Panda's original broken HPR calculation. + */ FLOATNAME(LVecBase3) old_to_new_hpr(const FLOATNAME(LVecBase3) &old_hpr) { TAU_PROFILE("LVecBase3 old_to_new_hpr(const LVecBase3 &)", " ", TAU_USER); diff --git a/panda/src/linmath/compose_matrix_src.h b/panda/src/linmath/compose_matrix_src.h index 9aaa182789..7320716ea3 100644 --- a/panda/src/linmath/compose_matrix_src.h +++ b/panda/src/linmath/compose_matrix_src.h @@ -1,16 +1,15 @@ -// Filename: compose_matrix_src.h -// Created by: drose (21Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compose_matrix_src.h + * @author drose + * @date 1999-02-21 + */ BEGIN_PUBLISH @@ -56,8 +55,8 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat, -// The following functions are deprecated; they have been replaced -// with new versions, above, that accept a shear component as well. +// The following functions are deprecated; they have been replaced with new +// versions, above, that accept a shear component as well. INLINE_LINMATH void compose_matrix(FLOATNAME(LMatrix3) &mat, @@ -86,10 +85,10 @@ decompose_matrix(const FLOATNAME(LMatrix4) &mat, CoordinateSystem cs = CS_default); -// The following functions are transitional and serve only to migrate -// code from the old, incorrect hpr calculations that Panda used to -// use. New code should not call these functions directly; use the -// unqualified functions, above, instead. +// The following functions are transitional and serve only to migrate code +// from the old, incorrect hpr calculations that Panda used to use. New code +// should not call these functions directly; use the unqualified functions, +// above, instead. EXPCL_PANDA_LINMATH bool decompose_matrix_old_hpr(const FLOATNAME(LMatrix3) &mat, diff --git a/panda/src/linmath/configVariableColor.I b/panda/src/linmath/configVariableColor.I index 1c5031bfb3..21a0af8660 100644 --- a/panda/src/linmath/configVariableColor.I +++ b/panda/src/linmath/configVariableColor.I @@ -1,23 +1,19 @@ -// Filename: configVariableColor.I -// Created by: rdb (02Feb14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableColor.I + * @author rdb + * @date 2014-02-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableColor:: ConfigVariableColor(const string &name) : ConfigVariable(name, VT_color), @@ -27,11 +23,9 @@ ConfigVariableColor(const string &name) : _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableColor:: ConfigVariableColor(const string &name, const LColor &default_value, const string &description, int flags) : @@ -47,11 +41,9 @@ ConfigVariableColor(const string &name, const LColor &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConfigVariableColor:: ConfigVariableColor(const string &name, const string &default_value, const string &description, int flags) : @@ -67,43 +59,34 @@ ConfigVariableColor(const string &name, const string &default_value, _core->set_used(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::operator = -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableColor:: operator = (const LColor &value) { set_value(value); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::typecast operator -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE ConfigVariableColor:: operator const LColor & () const { return get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::operator [] -// Access: Published -// Description: Returns the value of the color's nth component -// (which is not necessarily the same thing as the -// variable's nth word). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the color's nth component (which is not necessarily + * the same thing as the variable's nth word). + */ INLINE PN_stdfloat ConfigVariableColor:: operator [] (int n) const { return get_value()[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::set_value -// Access: Published -// Description: Reassigns the variable's local value. -//////////////////////////////////////////////////////////////////// +/** + * Reassigns the variable's local value. + */ INLINE void ConfigVariableColor:: set_value(const LColor &color) { set_string_value(""); @@ -113,11 +96,9 @@ set_value(const LColor &color) { set_double_word(3, color[3]); } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::get_value -// Access: Published -// Description: Returns the variable's value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's value. + */ INLINE const LColor &ConfigVariableColor:: get_value() const { TAU_PROFILE("const LColor &ConfigVariableColor::get_value() const", " ", TAU_USER); @@ -154,11 +135,9 @@ get_value() const { return _cache; } -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::get_default_value -// Access: Published -// Description: Returns the variable's default value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variable's default value. + */ INLINE LColor ConfigVariableColor:: get_default_value() const { const ConfigDeclaration *decl = ConfigVariable::get_default_value(); diff --git a/panda/src/linmath/configVariableColor.cxx b/panda/src/linmath/configVariableColor.cxx index 27282c36e7..097effb54c 100644 --- a/panda/src/linmath/configVariableColor.cxx +++ b/panda/src/linmath/configVariableColor.cxx @@ -1,25 +1,22 @@ -// Filename: configVariableColor.cxx -// Created by: rdb (02Feb14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableColor.cxx + * @author rdb + * @date 2014-02-02 + */ #include "configVariableColor.h" #include "pdtoa.h" -//////////////////////////////////////////////////////////////////// -// Function: ConfigVariableColor::set_default_value -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConfigVariableColor:: set_default_value(const LColor &default_value) { char buffer[128]; diff --git a/panda/src/linmath/configVariableColor.h b/panda/src/linmath/configVariableColor.h index 76b8adf6b3..380644a57a 100644 --- a/panda/src/linmath/configVariableColor.h +++ b/panda/src/linmath/configVariableColor.h @@ -1,16 +1,15 @@ -// Filename: configVariableColor.h -// Created by: rdb (02Feb14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configVariableColor.h + * @author rdb + * @date 2014-02-02 + */ #ifndef CONFIGVARIABLECOLOR_H #define CONFIGVARIABLECOLOR_H @@ -21,22 +20,18 @@ #include "configVariable.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : ConfigVariableColor -// Description : This is a convenience class to specialize -// ConfigVariable as a set of floating-point types -// representing a color value. -// -// It interprets the color differently depending on -// how many words were specified: if only one, it -// is interpreted as a shade of gray with alpha 1. -// If two values were specified, a grayscale and -// alpha pair. If three, a set of R, G, B values -// with alpha 1, and if four, a complete RGBA color. -// -// This isn't defined in dtool because it relies on -// the LColor class, which is defined in linmath. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience class to specialize ConfigVariable as a set of + * floating-point types representing a color value. + * + * It interprets the color differently depending on how many words were + * specified: if only one, it is interpreted as a shade of gray with alpha 1. + * If two values were specified, a grayscale and alpha pair. If three, a set + * of R, G, B values with alpha 1, and if four, a complete RGBA color. + * + * This isn't defined in dtool because it relies on the LColor class, which is + * defined in linmath. + */ class EXPCL_PANDA_LINMATH ConfigVariableColor : public ConfigVariable { PUBLISHED: INLINE ConfigVariableColor(const string &name); diff --git a/panda/src/linmath/config_linmath.cxx b/panda/src/linmath/config_linmath.cxx index 51910a7746..93cf571c40 100644 --- a/panda/src/linmath/config_linmath.cxx +++ b/panda/src/linmath/config_linmath.cxx @@ -1,16 +1,15 @@ -// Filename: config_linmath.cxx -// Created by: drose (23Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_linmath.cxx + * @author drose + * @date 2000-02-23 + */ #include "config_linmath.h" #include "luse.h" @@ -37,14 +36,12 @@ ConfigVariableBool no_singular_invert "assertion failure instead of just a warning (which can then be " "trapped with assert-abort).")); -//////////////////////////////////////////////////////////////////// -// Function: init_liblinmath -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_liblinmath() { static bool initialized = false; diff --git a/panda/src/linmath/config_linmath.h b/panda/src/linmath/config_linmath.h index bb3367d661..88deb58435 100644 --- a/panda/src/linmath/config_linmath.h +++ b/panda/src/linmath/config_linmath.h @@ -1,16 +1,15 @@ -// Filename: config_linmath.h -// Created by: drose (23Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_linmath.h + * @author drose + * @date 2000-02-23 + */ #ifndef CONFIG_LINMATH_H #define CONFIG_LINMATH_H diff --git a/panda/src/linmath/coordinateSystem.cxx b/panda/src/linmath/coordinateSystem.cxx index 372768724c..6eb81077ca 100644 --- a/panda/src/linmath/coordinateSystem.cxx +++ b/panda/src/linmath/coordinateSystem.cxx @@ -1,16 +1,15 @@ -// Filename: coordinateSystem.cxx -// Created by: drose (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file coordinateSystem.cxx + * @author drose + * @date 1999-09-24 + */ #include "coordinateSystem.h" #include "config_linmath.h" @@ -41,23 +40,23 @@ parse_coordinate_system_string(const string &str) { if (cmp_nocase_uh(str, "default") == 0) { return CS_default; - } else if (cmp_nocase_uh(str, "zup") == 0 || + } else if (cmp_nocase_uh(str, "zup") == 0 || cmp_nocase_uh(str, "zup-right") == 0 || - cmp_nocase_uh(str, "z-up") == 0 || + cmp_nocase_uh(str, "z-up") == 0 || cmp_nocase_uh(str, "z-up-right") == 0) { return CS_zup_right; - } else if (cmp_nocase_uh(str, "yup") == 0 || + } else if (cmp_nocase_uh(str, "yup") == 0 || cmp_nocase_uh(str, "yup-right") == 0 || - cmp_nocase_uh(str, "y-up") == 0 || + cmp_nocase_uh(str, "y-up") == 0 || cmp_nocase_uh(str, "y-up-right") == 0) { return CS_yup_right; - } else if (cmp_nocase_uh(str, "z-up-left") == 0 || + } else if (cmp_nocase_uh(str, "z-up-left") == 0 || cmp_nocase_uh(str, "zup-left") == 0) { return CS_zup_left; - } else if (cmp_nocase_uh(str, "y-up-left") == 0 || + } else if (cmp_nocase_uh(str, "y-up-left") == 0 || cmp_nocase_uh(str, "yup-left") == 0) { return CS_yup_left; } @@ -133,4 +132,3 @@ operator >> (istream &in, CoordinateSystem &cs) { } return in; } - diff --git a/panda/src/linmath/coordinateSystem.h b/panda/src/linmath/coordinateSystem.h index f1f0edc98d..ba40f3d2b0 100644 --- a/panda/src/linmath/coordinateSystem.h +++ b/panda/src/linmath/coordinateSystem.h @@ -1,16 +1,15 @@ -// Filename: coordinateSystem.h -// Created by: drose (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file coordinateSystem.h + * @author drose + * @date 1999-09-24 + */ #ifndef COORDINATESYSTEM_H #define COORDINATESYSTEM_H @@ -22,10 +21,9 @@ BEGIN_PUBLISH enum CoordinateSystem { - // The CS_default entry does not refer to a particular coordinate - // system, but rather to the value stored in - // default_coordinate_system, which in turn is loaded from the - // config variable "coordinate-system". + // The CS_default entry does not refer to a particular coordinate system, + // but rather to the value stored in default_coordinate_system, which in + // turn is loaded from the config variable "coordinate-system". CS_default, CS_zup_right, @@ -33,9 +31,9 @@ enum CoordinateSystem { CS_zup_left, CS_yup_left, - // CS_invalid is not a coordinate system at all. It can be used in - // user-input processing code to indicate a contradictory coordinate - // system request. + // CS_invalid is not a coordinate system at all. It can be used in user- + // input processing code to indicate a contradictory coordinate system + // request. CS_invalid, }; @@ -53,4 +51,3 @@ EXPCL_PANDA_LINMATH istream &operator >> (istream &in, CoordinateSystem &cs); #endif - diff --git a/panda/src/linmath/dbl2fltnames.h b/panda/src/linmath/dbl2fltnames.h index 0bb7987b69..7604fe51b0 100644 --- a/panda/src/linmath/dbl2fltnames.h +++ b/panda/src/linmath/dbl2fltnames.h @@ -1,24 +1,18 @@ -// Filename: dbl2fltnames.h -// Created by: drose (04Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dbl2fltnames.h + * @author drose + * @date 2001-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// -// This file is used particularly by lcast_to.h and lcast_to.cxx to -// define functions that convert from type double to type float. -// -//////////////////////////////////////////////////////////////////// +// This file is used particularly by lcast_to.h and lcast_to.cxx to define +// functions that convert from type double to type float. #include "fltnames.h" diff --git a/panda/src/linmath/dblnames.h b/panda/src/linmath/dblnames.h index d0df9e8039..c2c646b750 100644 --- a/panda/src/linmath/dblnames.h +++ b/panda/src/linmath/dblnames.h @@ -1,36 +1,29 @@ -// Filename: dblnames.h -// Created by: cxgeorge (04Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dblnames.h + * @author cxgeorge + * @date 2001-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// -// This file is used throughout this directory, in conjunction with -// dblnames.h, to implement a poor man's template of the linmath -// objects on numeric type. The idea is to #include either fltnames.h -// or dblnames.h (or, in theory, intnames.h or any other numeric type -// we wanted to implement) and then to include the various *_src.h -// and/or *_src.cxx files that actually define the linmath objects. -// -// We do this instead of using actual templates to avoid some of the -// inherent problems with templates: compiler complexity and -// distributed code bloat, for instance; plus it allows us to -// implement #if-based specialization on numeric type for compilers -// (like VC++) that don't completely support template specialization. -// That and the fact that VC++ seems to have a particularly bad time -// with templates in general. -// -//////////////////////////////////////////////////////////////////// +/* + * This file is used throughout this directory, in conjunction with + * dblnames.h, to implement a poor man's template of the linmath objects on + * numeric type. The idea is to #include either fltnames.h or dblnames.h (or, + * in theory, intnames.h or any other numeric type we wanted to implement) and + * then to include the various *_src.h andor *_src.cxx files that actually + * define the linmath objects. We do this instead of using actual templates + * to avoid some of the inherent problems with templates: compiler complexity + * and distributed code bloat, for instance; plus it allows us to implement + * if-based specialization on numeric type for compilers (like VC++) that + * don't completely support template specialization. That and the fact that + * VC++ seems to have a particularly bad time with templates in general. + */ #undef FLOATTYPE diff --git a/panda/src/linmath/deg_2_rad.I b/panda/src/linmath/deg_2_rad.I index cfbb2357e7..0fabb9b3af 100644 --- a/panda/src/linmath/deg_2_rad.I +++ b/panda/src/linmath/deg_2_rad.I @@ -1,29 +1,28 @@ -// Filename: deg_2_rad.I -// Created by: drose (14Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deg_2_rad.I + * @author drose + * @date 2011-12-14 + */ -INLINE_LINMATH double deg_2_rad(double f) { - return f * MathNumbers::deg_2_rad_d; +INLINE_LINMATH double deg_2_rad(double f) { + return f * MathNumbers::deg_2_rad_d; } -INLINE_LINMATH double rad_2_deg(double f) { - return f * MathNumbers::rad_2_deg_d; +INLINE_LINMATH double rad_2_deg(double f) { + return f * MathNumbers::rad_2_deg_d; } -INLINE_LINMATH float deg_2_rad(float f) { - return f * MathNumbers::deg_2_rad_f; +INLINE_LINMATH float deg_2_rad(float f) { + return f * MathNumbers::deg_2_rad_f; } -INLINE_LINMATH float rad_2_deg(float f) { - return f * MathNumbers::rad_2_deg_f; +INLINE_LINMATH float rad_2_deg(float f) { + return f * MathNumbers::rad_2_deg_f; } diff --git a/panda/src/linmath/deg_2_rad.h b/panda/src/linmath/deg_2_rad.h index c563ffb58e..c3170bc7cd 100644 --- a/panda/src/linmath/deg_2_rad.h +++ b/panda/src/linmath/deg_2_rad.h @@ -1,16 +1,15 @@ -// Filename: deg_2_rad.h -// Created by: drose (29Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file deg_2_rad.h + * @author drose + * @date 1999-09-29 + */ #ifndef DEG_2_RAD_H #define DEG_2_RAD_H @@ -30,4 +29,3 @@ END_PUBLISH #include "deg_2_rad.I" #endif - diff --git a/panda/src/linmath/flt2dblnames.h b/panda/src/linmath/flt2dblnames.h index d56335fb4f..0b26e07b2e 100644 --- a/panda/src/linmath/flt2dblnames.h +++ b/panda/src/linmath/flt2dblnames.h @@ -1,24 +1,18 @@ -// Filename: flt2dblnames.h -// Created by: drose (04Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file flt2dblnames.h + * @author drose + * @date 2001-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// -// This file is used particularly by lcast_to.h and lcast_to.cxx to -// define functions that convert from type float to type double. -// -//////////////////////////////////////////////////////////////////// +// This file is used particularly by lcast_to.h and lcast_to.cxx to define +// functions that convert from type float to type double. #include "dblnames.h" diff --git a/panda/src/linmath/fltnames.h b/panda/src/linmath/fltnames.h index 75affd8fa7..d8d4762ddb 100644 --- a/panda/src/linmath/fltnames.h +++ b/panda/src/linmath/fltnames.h @@ -1,36 +1,29 @@ -// Filename: fltnames.h -// Created by: cxgeorge (04Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltnames.h + * @author cxgeorge + * @date 2001-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// -// This file is used throughout this directory, in conjunction with -// dblnames.h, to implement a poor man's template of the linmath -// objects on numeric type. The idea is to #include either fltnames.h -// or dblnames.h (or, in theory, intnames.h or any other numeric type -// we wanted to implement) and then to include the various *_src.h -// and/or *_src.cxx files that actually define the linmath objects. -// -// We do this instead of using actual templates to avoid some of the -// inherent problems with templates: compiler complexity and -// distributed code bloat, for instance; plus it allows us to -// implement #if-based specialization on numeric type for compilers -// (like VC++) that don't completely support template specialization. -// That and the fact that VC++ seems to have a particularly bad time -// with templates in general. -// -//////////////////////////////////////////////////////////////////// +/* + * This file is used throughout this directory, in conjunction with + * dblnames.h, to implement a poor man's template of the linmath objects on + * numeric type. The idea is to #include either fltnames.h or dblnames.h (or, + * in theory, intnames.h or any other numeric type we wanted to implement) and + * then to include the various *_src.h andor *_src.cxx files that actually + * define the linmath objects. We do this instead of using actual templates + * to avoid some of the inherent problems with templates: compiler complexity + * and distributed code bloat, for instance; plus it allows us to implement + * if-based specialization on numeric type for compilers (like VC++) that + * don't completely support template specialization. That and the fact that + * VC++ seems to have a particularly bad time with templates in general. + */ #undef FLOATTYPE diff --git a/panda/src/linmath/intnames.h b/panda/src/linmath/intnames.h index 2a63cbeec7..2a01d71e05 100644 --- a/panda/src/linmath/intnames.h +++ b/panda/src/linmath/intnames.h @@ -1,36 +1,29 @@ -// Filename: intnames.h -// Created by: rdb (07Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file intnames.h + * @author rdb + * @date 2014-06-07 + */ - -//////////////////////////////////////////////////////////////////// -// -// This file is used throughout this directory, in conjunction with -// dblnames.h, to implement a poor man's template of the linmath -// objects on numeric type. The idea is to #include either fltnames.h -// or dblnames.h (or, in theory, intnames.h or any other numeric type -// we wanted to implement) and then to include the various *_src.h -// and/or *_src.cxx files that actually define the linmath objects. -// -// We do this instead of using actual templates to avoid some of the -// inherent problems with templates: compiler complexity and -// distributed code bloat, for instance; plus it allows us to -// implement #if-based specialization on numeric type for compilers -// (like VC++) that don't completely support template specialization. -// That and the fact that VC++ seems to have a particularly bad time -// with templates in general. -// -//////////////////////////////////////////////////////////////////// +/* + * This file is used throughout this directory, in conjunction with + * dblnames.h, to implement a poor man's template of the linmath objects on + * numeric type. The idea is to #include either fltnames.h or dblnames.h (or, + * in theory, intnames.h or any other numeric type we wanted to implement) and + * then to include the various *_src.h andor *_src.cxx files that actually + * define the linmath objects. We do this instead of using actual templates + * to avoid some of the inherent problems with templates: compiler complexity + * and distributed code bloat, for instance; plus it allows us to implement + * if-based specialization on numeric type for compilers (like VC++) that + * don't completely support template specialization. That and the fact that + * VC++ seems to have a particularly bad time with templates in general. + */ #undef FLOATTYPE diff --git a/panda/src/linmath/lcast_to.h b/panda/src/linmath/lcast_to.h index 3af352920a..f28c8a8eeb 100644 --- a/panda/src/linmath/lcast_to.h +++ b/panda/src/linmath/lcast_to.h @@ -1,30 +1,25 @@ -// Filename: lcast_to.h -// Created by: drose (03Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lcast_to.h + * @author drose + * @date 2001-04-03 + */ #ifndef LCAST_TO_H #define LCAST_TO_H -//////////////////////////////////////////////////////////////////// -// -// This file defines the various lcast_to() functions on the types -// defined within this module. It is assumed that all the types have -// already been defined. -// -// The lcast_to() functions are invoked by the LCAST macro to convert -// a linmath object from one numeric type to another. -// -//////////////////////////////////////////////////////////////////// +/* + * This file defines the various lcast_to() functions on the types defined + * within this module. It is assumed that all the types have already been + * defined. The lcast_to() functions are invoked by the LCAST macro to + * convert a linmath object from one numeric type to another. + */ #include "dbl2fltnames.h" #include "lcast_to_src.h" @@ -33,4 +28,3 @@ #include "lcast_to_src.h" #endif - diff --git a/panda/src/linmath/lcast_to_src.I b/panda/src/linmath/lcast_to_src.I index e4c7b586d3..2d07e946bf 100644 --- a/panda/src/linmath/lcast_to_src.I +++ b/panda/src/linmath/lcast_to_src.I @@ -1,16 +1,13 @@ -// Filename: lcast_to_src.I -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lcast_to_src.I + */ INLINE_LINMATH const FLOATNAME(LVecBase2) & lcast_to(FLOATTYPE *, const FLOATNAME(LVecBase2) &source) { diff --git a/panda/src/linmath/lcast_to_src.h b/panda/src/linmath/lcast_to_src.h index c61044d2da..7adfe550ad 100644 --- a/panda/src/linmath/lcast_to_src.h +++ b/panda/src/linmath/lcast_to_src.h @@ -1,16 +1,15 @@ -// Filename: lcast_to_src.h -// Created by: drose (03Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lcast_to_src.h + * @author drose + * @date 2001-04-03 + */ #ifndef CPPPARSER diff --git a/panda/src/linmath/lmat_ops.h b/panda/src/linmath/lmat_ops.h index 86f34a7f2c..cca58849a4 100644 --- a/panda/src/linmath/lmat_ops.h +++ b/panda/src/linmath/lmat_ops.h @@ -1,16 +1,15 @@ -// Filename: lmat_ops.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmat_ops.h + * @author drose + * @date 2000-03-08 + */ #ifndef LMAT_OPS_H #define LMAT_OPS_H diff --git a/panda/src/linmath/lmat_ops_src.I b/panda/src/linmath/lmat_ops_src.I index 4572a68c49..1b3760dd6c 100644 --- a/panda/src/linmath/lmat_ops_src.I +++ b/panda/src/linmath/lmat_ops_src.I @@ -1,22 +1,19 @@ -// Filename: lmat_ops_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmat_ops_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3 times LMatrix3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) operator * (const FLOATNAME(LVecBase3) &v, const FLOATNAME(LMatrix3) &m) { @@ -45,10 +42,9 @@ operator *= (FLOATNAME(LPoint3) &v, const FLOATNAME(LMatrix3) &m) { m.xform_in_place(v); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2 times LMatrix3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) operator * (const FLOATNAME(LVector2) &v, const FLOATNAME(LMatrix3) &m) { @@ -59,10 +55,9 @@ operator *= (FLOATNAME(LVector2) &v, const FLOATNAME(LMatrix3) &m) { m.xform_vec_in_place(v); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2 times LMatrix3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) operator * (const FLOATNAME(LPoint2) &v, const FLOATNAME(LMatrix3) &m) { @@ -74,10 +69,9 @@ operator *= (FLOATNAME(LPoint2) &v, const FLOATNAME(LMatrix3) &m) { } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4 times LMatrix4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) operator * (const FLOATNAME(LVecBase4) &v, const FLOATNAME(LMatrix4) &m) { @@ -98,10 +92,9 @@ operator * (const FLOATNAME(LPoint4) &v, const FLOATNAME(LMatrix4) &m) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector3 times LMatrix4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) operator * (const FLOATNAME(LVector3) &v, const FLOATNAME(LMatrix4) &m) { @@ -112,10 +105,9 @@ operator *= (FLOATNAME(LVector3) &v, const FLOATNAME(LMatrix4) &m) { m.xform_vec_in_place(v); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3 times LMatrix4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) operator * (const FLOATNAME(LPoint3) &v, const FLOATNAME(LMatrix4) &m) { @@ -127,37 +119,33 @@ operator *= (FLOATNAME(LPoint3) &v, const FLOATNAME(LMatrix4) &m) { } -//////////////////////////////////////////////////////////////////// -// Function: generic_write_datagram -// Description: Writes the value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the value to the datagram. + */ INLINE_LINMATH void generic_write_datagram(Datagram &dest, const FLOATNAME(LMatrix3) &value) { value.write_datagram(dest); } -//////////////////////////////////////////////////////////////////// -// Function: generic_read_datagram -// Description: Reads the value from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the value from the datagram. + */ INLINE_LINMATH void generic_read_datagram(FLOATNAME(LMatrix3) &result, DatagramIterator &source) { result.read_datagram(source); } -//////////////////////////////////////////////////////////////////// -// Function: generic_write_datagram -// Description: Writes the value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the value to the datagram. + */ INLINE_LINMATH void generic_write_datagram(Datagram &dest, const FLOATNAME(LMatrix4) &value) { value.write_datagram(dest); } -//////////////////////////////////////////////////////////////////// -// Function: generic_read_datagram -// Description: Reads the value from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the value from the datagram. + */ INLINE_LINMATH void generic_read_datagram(FLOATNAME(LMatrix4) &result, DatagramIterator &source) { result.read_datagram(source); diff --git a/panda/src/linmath/lmat_ops_src.h b/panda/src/linmath/lmat_ops_src.h index 6cd9573e3e..19ff55d646 100644 --- a/panda/src/linmath/lmat_ops_src.h +++ b/panda/src/linmath/lmat_ops_src.h @@ -1,16 +1,15 @@ -// Filename: lmat_ops_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmat_ops_src.h + * @author drose + * @date 2000-03-08 + */ BEGIN_PUBLISH diff --git a/panda/src/linmath/lmatrix.cxx b/panda/src/linmath/lmatrix.cxx index f32e5863b1..a930980c52 100644 --- a/panda/src/linmath/lmatrix.cxx +++ b/panda/src/linmath/lmatrix.cxx @@ -1,16 +1,15 @@ -// Filename: lmatrix.cxx -// Created by: drose (22Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix.cxx + * @author drose + * @date 1999-02-22 + */ #include "lmatrix.h" diff --git a/panda/src/linmath/lmatrix.h b/panda/src/linmath/lmatrix.h index 7d82849c2b..bfdcfa9dce 100644 --- a/panda/src/linmath/lmatrix.h +++ b/panda/src/linmath/lmatrix.h @@ -1,16 +1,15 @@ -// Filename: lmatrix.h -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix.h + * @author drose + * @date 1999-01-15 + */ #ifndef LMATRIX_H #define LMATRIX_H diff --git a/panda/src/linmath/lmatrix3_ext_src.I b/panda/src/linmath/lmatrix3_ext_src.I index f6aa52a247..b1997ec746 100644 --- a/panda/src/linmath/lmatrix3_ext_src.I +++ b/panda/src/linmath/lmatrix3_ext_src.I @@ -1,30 +1,25 @@ -// Filename: lmatrix3_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix3_ext_src.I + * @author rdb + * @date 2011-01-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ INLINE_LINMATH PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; @@ -39,11 +34,9 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; diff --git a/panda/src/linmath/lmatrix3_ext_src.h b/panda/src/linmath/lmatrix3_ext_src.h index 99583af4bb..34828c9133 100644 --- a/panda/src/linmath/lmatrix3_ext_src.h +++ b/panda/src/linmath/lmatrix3_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lmatrix3_ext_src.h -// Created by: rdb (12Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix3_ext_src.h + * @author rdb + * @date 2013-09-12 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LMatrix3, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LMatrix3, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lmatrix3_src.I b/panda/src/linmath/lmatrix3_src.I index 31be16b095..8bfb3909ce 100644 --- a/panda/src/linmath/lmatrix3_src.I +++ b/panda/src/linmath/lmatrix3_src.I @@ -1,125 +1,101 @@ -// Filename: lmatrix3_src.I -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix3_src.I + * @author drose + * @date 1999-01-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Row::Constructor -// Access: Private -// Description: Defines a row-level index accessor to the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Defines a row-level index accessor to the matrix. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::Row:: Row(FLOATTYPE *row) : _row(row) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Row::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::Row:: operator [](int i) const { nassertr(i >= 0 && i < 3, 0.0); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Row::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix3)::Row:: operator [](int i) { nassertr(i >= 0 && i < 3, _row[0]); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Row::size -// Access: Published, Static -// Description: Returns 3: the number of columns of a LMatrix3. -//////////////////////////////////////////////////////////////////// +/** + * Returns 3: the number of columns of a LMatrix3. + */ INLINE_LINMATH int FLOATNAME(LMatrix3)::Row:: size() { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::CRow::Constructor -// Access: Private -// Description: Defines a row-level constant accessor to the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Defines a row-level constant accessor to the matrix. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::CRow:: CRow(const FLOATTYPE *row) : _row(row) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::CRow::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3)::CRow:: operator [](int i) const { nassertr(i >= 0 && i < 3, 0.0); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::CRow::size -// Access: Published, Static -// Description: Returns 3: the number of columns of a LMatrix3. -//////////////////////////////////////////////////////////////////// +/** + * Returns 3: the number of columns of a LMatrix3. + */ INLINE_LINMATH int FLOATNAME(LMatrix3)::CRow:: size() { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::ident_mat -// Access: Published, Static -// Description: Returns an identity matrix. -// -// This function definition must appear first, since -// some inline functions below take advantage of it. -//////////////////////////////////////////////////////////////////// +/** + * Returns an identity matrix. + * + * This function definition must appear first, since some inline functions + * below take advantage of it. + */ INLINE_LINMATH const FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: ident_mat() { return _ident_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Default Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3):: FLOATNAME(LMatrix3)() { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3):: FLOATNAME(LMatrix3)(const FLOATNAME(LMatrix3) ©) : _m(copy._m) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator = (const FLOATNAME(LMatrix3) ©) { TAU_PROFILE("void LMatrix3::operator = (const LMatrix3 &)", " ", TAU_USER); @@ -128,22 +104,18 @@ operator = (const FLOATNAME(LMatrix3) ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Fill Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator = (FLOATTYPE fill_value) { fill(fill_value); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3):: FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, @@ -160,11 +132,9 @@ FLOATNAME(LMatrix3)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, _m(2, 2) = e22; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, @@ -181,12 +151,9 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, _m(2, 2) = e22; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set_row -// Access: Published -// Description: Replaces the indicated row of the matrix from a -// three-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated row of the matrix from a three-component vector. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_row(int row, const FLOATNAME(LVecBase3) &v) { #ifdef HAVE_EIGEN @@ -198,12 +165,9 @@ set_row(int row, const FLOATNAME(LVecBase3) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set_column -// Access: Published -// Description: Replaces the indicated column of the matrix from a -// three-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated column of the matrix from a three-component vector. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_col(int col, const FLOATNAME(LVecBase3) &v) { #ifdef HAVE_EIGEN @@ -215,12 +179,10 @@ set_col(int col, const FLOATNAME(LVecBase3) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set_row -// Access: Published -// Description: Replaces the indicated row of the matrix from a -// two-component vector, ignoring the last column. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated row of the matrix from a two-component vector, + * ignoring the last column. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_row(int row, const FLOATNAME(LVecBase2) &v) { #ifdef HAVE_EIGEN @@ -231,12 +193,10 @@ set_row(int row, const FLOATNAME(LVecBase2) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set_column -// Access: Published -// Description: Replaces the indicated column of the matrix from a -// two-component vector, ignoring the last row. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated column of the matrix from a two-component vector, + * ignoring the last row. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_col(int col, const FLOATNAME(LVecBase2) &v) { #ifdef HAVE_EIGEN @@ -247,12 +207,9 @@ set_col(int col, const FLOATNAME(LVecBase2) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_row -// Access: Published -// Description: Returns the indicated row of the matrix as a -// three-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated row of the matrix as a three-component vector. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: get_row(int row) const { #ifdef HAVE_EIGEN @@ -262,12 +219,9 @@ get_row(int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_row -// Access: Published -// Description: Stores the indicated row of the matrix as a -// three-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated row of the matrix as a three-component vector. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: get_row(FLOATNAME(LVecBase3) &result_vec,int row) const { #ifdef HAVE_EIGEN @@ -279,12 +233,9 @@ get_row(FLOATNAME(LVecBase3) &result_vec,int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_col -// Access: Published -// Description: Returns the indicated column of the matrix as a -// three-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated column of the matrix as a three-component vector. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: get_col(int col) const { #ifdef HAVE_EIGEN @@ -294,88 +245,72 @@ get_col(int col) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_row2 -// Access: Published -// Description: Returns the indicated row of the matrix as a -// two-component vector, ignoring the last column. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated row of the matrix as a two-component vector, ignoring + * the last column. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: get_row2(int row) const { return FLOATNAME(LVecBase2)((*this)(row, 0), (*this)(row, 1)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_col2 -// Access: Published -// Description: Returns the indicated column of the matrix as a -// two-component vector, ignoring the last row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated column of the matrix as a two-component vector, + * ignoring the last row. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: get_col2(int col) const { return FLOATNAME(LVecBase2)((*this)(0, col), (*this)(1, col)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Indexing operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix3):: operator () (int row, int col) { nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, _m(0, 0)); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Indexing operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: operator () (int row, int col) const { nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3)::CRow FLOATNAME(LMatrix3):: operator [](int i) const { nassertr(i >= 0 && i < 3, CRow(&_m(0, 0))); return CRow(&_m(i, 0)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3)::Row FLOATNAME(LMatrix3):: operator [](int i) { nassertr(i >= 0 && i < 3, Row(&_m(0, 0))); return Row(&_m(i, 0)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::size -// Access: Published, Static -// Description: Returns 3: the number of rows of a LMatrix3. -//////////////////////////////////////////////////////////////////// +/** + * Returns 3: the number of rows of a LMatrix3. + */ INLINE_LINMATH int FLOATNAME(LMatrix3):: size() { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::is_nan -// Access: Published -// Description: Returns true if any component of the matrix is -// not-a-number, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any component of the matrix is not-a-number, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: is_nan() const { TAU_PROFILE("bool LMatrix3::is_nan()", " ", TAU_USER); @@ -385,185 +320,148 @@ is_nan() const { cnan(_m(2, 0)) || cnan(_m(2, 1)) || cnan(_m(2, 2)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::is_identity -// Access: Public -// Description: Returns true if this is (close enough to) the -// identity matrix, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is (close enough to) the identity matrix, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: is_identity() const { return almost_equal(ident_mat(), NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_cell -// Access: Published -// Description: Returns a particular element of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a particular element of the matrix. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: get_cell(int row, int col) const { nassertr(row >= 0 && row < 3 && col >= 0 && col < 3, 0.0); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::set_cell -// Access: Published -// Description: Changes a particular element of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Changes a particular element of the matrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_cell(int row, int col, FLOATTYPE value) { nassertv(row >= 0 && row < 3 && col >= 0 && col < 3); _m(row, col) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_data -// Access: Published -// Description: Returns the address of the first of the nine data -// elements in the matrix. The remaining elements -// occupy the next eight positions in row-major order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the nine data elements in the matrix. + * The remaining elements occupy the next eight positions in row-major order. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(LMatrix3):: get_data() const { return &_m(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_num_components -// Access: Published -// Description: Returns the number of elements in the matrix, nine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the matrix, nine. + */ INLINE_LINMATH int FLOATNAME(LMatrix3):: get_num_components() const { return 9; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::iterator FLOATNAME(LMatrix3):: begin() { return &_m(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::iterator FLOATNAME(LMatrix3):: end() { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::const_iterator FLOATNAME(LMatrix3):: begin() const { return &_m(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix3)::const_iterator FLOATNAME(LMatrix3):: end() const { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Ordering Operator -// Access: Published -// Description: This performs a lexicographical comparison. It's of -// questionable mathematical meaning, but sometimes has -// a practical purpose for sorting unique vectors, -// especially in an STL container. Also see -// compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This performs a lexicographical comparison. It's of questionable + * mathematical meaning, but sometimes has a practical purpose for sorting + * unique vectors, especially in an STL container. Also see compare_to(). + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: operator < (const FLOATNAME(LMatrix3) &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Equality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: operator == (const FLOATNAME(LMatrix3) &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::Inequality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: operator != (const FLOATNAME(LMatrix3) &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::compare_to -// Access: Published -// Description: This flavor of compare_to uses a default threshold -// value based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of compare_to uses a default threshold value based on the + * numeric type. + */ INLINE_LINMATH int FLOATNAME(LMatrix3):: compare_to(const FLOATNAME(LMatrix3) &other) const { return compare_to(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix3):: get_hash() const { return add_hash(0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix3):: get_hash(FLOATTYPE threshold) const { return add_hash(0, threshold); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix3):: add_hash(size_t hash) const { return add_hash(hash, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix3):: add_hash(size_t hash, FLOATTYPE threshold) const { TAU_PROFILE("size_t LMatrix3::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); @@ -589,11 +487,9 @@ v_res._v(0) = v._v(0)*mat._m(0, 0) + v._v(1)*mat._m(1, 0) + v._v(2)*mat._m(2, 0) v_res._v(1) = v._v(0)*mat._m(0, 1) + v._v(1)*mat._m(1, 1) + v._v(2)*mat._m(2, 1); \ v_res._v(2) = v._v(0)*mat._m(0, 2) + v._v(1)*mat._m(1, 2) + v._v(2)*mat._m(2, 2); -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform -// Access: Published -// Description: 3-component vector or point times matrix. -//////////////////////////////////////////////////////////////////// +/** + * 3-component vector or point times matrix. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: xform(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix3::xform(const LVecBase3 &)", " ", TAU_USER); @@ -609,13 +505,10 @@ xform(const FLOATNAME(LVecBase3) &v) const { #undef VECTOR3_MATRIX3_PRODUCT -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_point -// Access: Published -// Description: The matrix transforms a 2-component point (including -// translation component) and returns the result. This -// assumes the matrix is an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 2-component point (including translation component) + * and returns the result. This assumes the matrix is an affine transform. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: xform_point(const FLOATNAME(LVecBase2) &v) const { TAU_PROFILE("LVecBase3 LMatrix3::xform_point(const LVecBase3 &)", " ", TAU_USER); @@ -633,13 +526,10 @@ xform_point(const FLOATNAME(LVecBase2) &v) const { return v_res; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec -// Access: Published -// Description: The matrix transforms a 2-component vector (without -// translation component) and returns the result. This -// assumes the matrix is an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 2-component vector (without translation component) + * and returns the result. This assumes the matrix is an affine transform. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LMatrix3):: xform_vec(const FLOATNAME(LVecBase2) &v) const { TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER); @@ -658,28 +548,22 @@ xform_vec(const FLOATNAME(LVecBase2) &v) const { return v_res; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec -// Access: Published -// Description: The matrix transforms a 3-component vector and -// returns the result. This assumes the matrix is an -// orthonormal transform. -// -// In practice, this is the same computation as xform(). -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector and returns the result. This + * assumes the matrix is an orthonormal transform. + * + * In practice, this is the same computation as xform(). + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: xform_vec(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix3::xform_vec(const LVecBase3 &)", " ", TAU_USER); return xform(v); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec_general -// Access: Published -// Description: The matrix transforms a 3-component vector (without -// translation component) and returns the result, as a -// fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component) + * and returns the result, as a fully general operation. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix3):: xform_vec_general(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix3::xform_vec_general(const LVecBase3 &)", " ", TAU_USER); @@ -693,11 +577,9 @@ xform_vec_general(const FLOATNAME(LVecBase3) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_in_place -// Access: Published -// Description: 3-component vector or point times matrix. -//////////////////////////////////////////////////////////////////// +/** + * 3-component vector or point times matrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: xform_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix3::xform_in_place(LVecBase3 &)", " ", TAU_USER); @@ -708,13 +590,10 @@ xform_in_place(FLOATNAME(LVecBase3) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_point_in_place -// Access: Published -// Description: The matrix transforms a 2-component point (including -// translation component). This assumes the matrix is -// an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 2-component point (including translation + * component). This assumes the matrix is an affine transform. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: xform_point_in_place(FLOATNAME(LVecBase2) &v) const { TAU_PROFILE("void LMatrix3::xform_point_in_place(LVecBase3 &)", " ", TAU_USER); @@ -727,13 +606,10 @@ xform_point_in_place(FLOATNAME(LVecBase2) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec_in_place -// Access: Published -// Description: The matrix transforms a 2-component vector (without -// translation component). This assumes the matrix is -// an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 2-component vector (without translation component). + * This assumes the matrix is an affine transform. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: xform_vec_in_place(FLOATNAME(LVecBase2) &v) const { TAU_PROFILE("void LMatrix3::xform_vec_in_place(LVecBase3 &)", " ", TAU_USER); @@ -746,26 +622,22 @@ xform_vec_in_place(FLOATNAME(LVecBase2) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec_in_place -// Access: Published -// Description: The matrix transforms a 3-component vector. This -// assumes the matrix is an orthonormal transform. -// -// In practice, this is the same computation as xform(). -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector. This assumes the matrix is an + * orthonormal transform. + * + * In practice, this is the same computation as xform(). + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: xform_vec_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix3::xform_vec_in_place(LVecBase3 &)", " ", TAU_USER); xform_in_place(v); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::xform_vec_general_in_place -// Access: Published -// Description: The matrix transforms a 3-component vector (without -// translation component), as a fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component), + * as a fully general operation. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: xform_vec_general_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix3::xform_vec_general_in_place(LVecBase3 &)", " ", TAU_USER); @@ -788,11 +660,9 @@ res._m(2, 1) = a._m(2, 0)*b._m(0, 1) + a._m(2, 1)*b._m(1, 1) + a._m(2, 2)*b._m(2 res._m(2, 2) = a._m(2, 0)*b._m(0, 2) + a._m(2, 1)*b._m(1, 2) + a._m(2, 2)*b._m(2, 2); -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix * matrix -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: operator * (const FLOATNAME(LMatrix3) &other) const { TAU_PROFILE("LMatrix3 LMatrix3::operator *(const LMatrix3 &)", " ", TAU_USER); @@ -805,8 +675,8 @@ operator * (const FLOATNAME(LMatrix3) &other) const { INLINE_LINMATH void FLOATNAME(LMatrix3):: multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2) { TAU_PROFILE("LMatrix3 multiply(const LMatrix3 &, const LMatrix3 &)", " ", TAU_USER); - // faster than operator * since it writes result in place, avoiding extra copying - // this will fail if you try to mat.multiply(mat,other_mat) + // faster than operator * since it writes result in place, avoiding extra + // copying this will fail if you try to mat.multiply(mat,other_mat) nassertv((&other1 != this) && (&other2 != this)); @@ -815,11 +685,9 @@ multiply(const FLOATNAME(LMatrix3) &other1, const FLOATNAME(LMatrix3) &other2) { #undef MATRIX3_PRODUCT -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix * scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: operator * (FLOATTYPE scalar) const { TAU_PROFILE("LMatrix3 operator *(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); @@ -840,22 +708,18 @@ operator * (FLOATTYPE scalar) const { return t; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix / scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: operator / (FLOATTYPE scalar) const { FLOATTYPE recip_scalar = 1.0f/scalar; return (*this) * recip_scalar; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix += matrix -// Access: Published -// Description: Performs a memberwise addition between two matrices. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise addition between two matrices. + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator += (const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("LMatrix3 LMatrix3::operator +=(const LMatrix3 &)", " ", TAU_USER); @@ -874,11 +738,9 @@ operator += (const FLOATNAME(LMatrix3) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix -= matrix -// Access: Published -// Description: Performs a memberwise subtraction between two matrices. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise subtraction between two matrices. + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator -= (const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("LMatrix3 LMatrix3::operator -=(const LMatrix3 &)", " ", TAU_USER); @@ -897,11 +759,9 @@ operator -= (const FLOATNAME(LMatrix3) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix *= matrix -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator *= (const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("LMatrix3 LMatrix3::operator *=(const LMatrix3 &)", " ", TAU_USER); @@ -911,11 +771,9 @@ operator *= (const FLOATNAME(LMatrix3) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix *= scalar -// Access: Published -// Description: Performs a memberwise scale. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise scale. + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator *= (FLOATTYPE scalar) { TAU_PROFILE("LMatrix3 LMatrix3::operator *=(FLOATTYPE)", " ", TAU_USER); @@ -934,11 +792,9 @@ operator *= (FLOATTYPE scalar) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::matrix /= scalar -// Access: Published -// Description: Performs a memberwise scale. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise scale. + */ INLINE_LINMATH FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: operator /= (FLOATTYPE scalar) { TAU_PROFILE("LMatrix3 LMatrix3::operator /=(FLOATTYPE)", " ", TAU_USER); @@ -958,11 +814,9 @@ operator /= (FLOATTYPE scalar) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::componentwise_mult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: componentwise_mult(const FLOATNAME(LMatrix3) &other) { #ifdef HAVE_EIGEN @@ -982,11 +836,9 @@ componentwise_mult(const FLOATNAME(LMatrix3) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::transpose_from -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: transpose_from(const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("LMatrix3 LMatrix3::transpose_from(const LMatrix3 &other)", " ", TAU_USER); @@ -1004,11 +856,9 @@ transpose_from(const FLOATNAME(LMatrix3) &other) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::transpose_in_place -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: transpose_in_place() { TAU_PROFILE("void LMatrix3::transpose_in_place()", " ", TAU_USER); @@ -1027,11 +877,9 @@ transpose_in_place() { -(mat)(0, 1) * DET2((mat)(1, 0),(mat)(1, 2),(mat)(2, 0),(mat)(2, 2)) \ +(mat)(0, 2) * DET2((mat)(1, 0),(mat)(1, 1),(mat)(2, 0),(mat)(2, 1))) -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::determinant -// Access: Published -// Description: Returns the determinant of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the determinant of the matrix. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix3):: determinant() const { TAU_PROFILE("FLOATTYPE LMatrix3::determinant()", " ", TAU_USER); @@ -1043,29 +891,23 @@ determinant() const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::invert_from -// Access: Published -// Description: Computes the inverse of the other matrix, and stores -// the result in this matrix. This is a fully general -// operation and makes no assumptions about the type of -// transform represented by the matrix. -// -// The other matrix must be a different object than this -// matrix. However, if you need to invert a matrix in -// place, see invert_in_place. -// -// The return value is true if the matrix was -// successfully inverted, false if there was a -// singularity. -//////////////////////////////////////////////////////////////////// +/** + * Computes the inverse of the other matrix, and stores the result in this + * matrix. This is a fully general operation and makes no assumptions about + * the type of transform represented by the matrix. + * + * The other matrix must be a different object than this matrix. However, if + * you need to invert a matrix in place, see invert_in_place. + * + * The return value is true if the matrix was successfully inverted, false if + * there was a singularity. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_from(const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("bool LMatrix3::invert_from(const LMatrix3 &)", " ", TAU_USER); - // We throw the value out only if it's smaller than our "small" - // threshold squared. This helps reduce overly-sensitive - // rejections. + // We throw the value out only if it's smaller than our "small" threshold + // squared. This helps reduce overly-sensitive rejections. #ifdef HAVE_EIGEN bool invertible; other._m.computeInverseWithCheck(_m, invertible, @@ -1111,13 +953,10 @@ invert_from(const FLOATNAME(LMatrix3) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::invert_in_place -// Access: Published -// Description: Inverts the current matrix. Returns true if the -// inverse is successful, false if the matrix was -// singular. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the current matrix. Returns true if the inverse is successful, + * false if the matrix was singular. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_in_place() { TAU_PROFILE("bool LMatrix3::invert_in_place()", " ", TAU_USER); @@ -1125,12 +964,10 @@ invert_in_place() { return invert_from(temp); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::invert_transpose_from -// Access: Published -// Description: Simultaneously computes the inverse of the indicated -// matrix, and then the transpose of that inverse. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously computes the inverse of the indicated matrix, and then the + * transpose of that inverse. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_transpose_from(const FLOATNAME(LMatrix3) &other) { TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix3 &)", " ", TAU_USER); @@ -1182,12 +1019,10 @@ invert_transpose_from(const FLOATNAME(LMatrix3) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::invert_transpose_from -// Access: Published -// Description: Simultaneously computes the inverse of the indicated -// matrix, and then the transpose of that inverse. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously computes the inverse of the indicated matrix, and then the + * transpose of that inverse. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: invert_transpose_from(const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("bool LMatrix3::invert_transpose_from(const LMatrix4 &)", " ", TAU_USER); @@ -1242,12 +1077,9 @@ invert_transpose_from(const FLOATNAME(LMatrix4) &other) { #undef MATRIX3_DETERMINANT #undef DET2 -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_translate_mat -// Access: Published -// Description: Fills mat with a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated translation. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_translate_mat(const FLOATNAME(LVecBase2) &trans) { set(1.0f, 0.0f, 0.0f, @@ -1255,12 +1087,10 @@ set_translate_mat(const FLOATNAME(LVecBase2) &trans) { trans._v(0), trans._v(1), 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_rotate_mat -// Access: Published -// Description: Fills mat with a matrix that rotates by the given -// angle in degrees counterclockwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that rotates by the given angle in degrees + * counterclockwise. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_rotate_mat(FLOATTYPE angle) { TAU_PROFILE("void LMatrix3::rotate_mat(LMatrix3, FLOATTYPE)", " ", TAU_USER); @@ -1272,12 +1102,10 @@ set_rotate_mat(FLOATTYPE angle) { 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_scale_mat -// Access: Published -// Description: Fills mat with a matrix that applies the indicated -// scale in each of the two axes. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated scale in each of the two + * axes. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_scale_mat(const FLOATNAME(LVecBase2) &scale) { set(scale._v(0), 0.0f, 0.0f, @@ -1285,12 +1113,9 @@ set_scale_mat(const FLOATNAME(LVecBase2) &scale) { 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::translate_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated translation. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: translate_mat(const FLOATNAME(LVecBase2) &trans) { return FLOATNAME(LMatrix3)(1.0f, 0.0f, 0.0f, @@ -1298,12 +1123,9 @@ translate_mat(const FLOATNAME(LVecBase2) &trans) { trans._v(0), trans._v(1), 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::translate_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated translation. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: translate_mat(FLOATTYPE tx, FLOATTYPE ty) { return FLOATNAME(LMatrix3)(1.0f, 0.0f, 0.0f, @@ -1311,12 +1133,10 @@ translate_mat(FLOATTYPE tx, FLOATTYPE ty) { tx, ty, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::rotate_mat -// Access: Published, Static -// Description: Returns a matrix that rotates by the given angle in -// degrees counterclockwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that rotates by the given angle in degrees + * counterclockwise. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat(FLOATTYPE angle) { FLOATNAME(LMatrix3) mat; @@ -1324,12 +1144,9 @@ rotate_mat(FLOATTYPE angle) { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the two axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the two axes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_mat(const FLOATNAME(LVecBase2) &scale) { return FLOATNAME(LMatrix3)(scale._v(0), 0.0f, 0.0f, @@ -1337,12 +1154,9 @@ scale_mat(const FLOATNAME(LVecBase2) &scale) { 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the two axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the two axes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_mat(FLOATTYPE sx, FLOATTYPE sy) { return FLOATNAME(LMatrix3)(sx, 0.0f, 0.0f, @@ -1350,12 +1164,10 @@ scale_mat(FLOATTYPE sx, FLOATTYPE sy) { 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::rotate_mat -// Access: Published, Static -// Description: Returns a matrix that rotates by the given angle in -// degrees counterclockwise about the indicated vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -1364,13 +1176,11 @@ rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::rotate_mat_normaxis -// Access: Published, Static -// Description: Returns a matrix that rotates by the given angle in -// degrees counterclockwise about the indicated vector. -// Assumes axis has been normalized. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. Assumes axis has been + * normalized. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -1379,12 +1189,10 @@ rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_scale_mat -// Access: Published -// Description: Fills mat with a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated scale in each of the + * three axes. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_scale_mat(const FLOATNAME(LVecBase3) &scale) { set(scale._v(0), 0.0f, 0.0f, @@ -1392,12 +1200,10 @@ set_scale_mat(const FLOATNAME(LVecBase3) &scale) { 0.0f, 0.0f, scale._v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the three + * axes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_mat(const FLOATNAME(LVecBase3) &scale) { return FLOATNAME(LMatrix3)(scale._v(0), 0.0f, 0.0f, @@ -1405,12 +1211,10 @@ scale_mat(const FLOATNAME(LVecBase3) &scale) { 0.0f, 0.0f, scale._v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the three + * axes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz) { return FLOATNAME(LMatrix3)(sx, 0.0f, 0.0f, @@ -1418,24 +1222,20 @@ scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz) { 0.0f, 0.0f, sz); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_shear_mat -// Access: Published -// Description: Fills mat with a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated shear in each of the + * three planes. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: set_shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { set_scale_shear_mat(FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f), shear, cs); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::shear_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated shear in each of the three + * planes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { FLOATNAME(LMatrix3) mat; @@ -1443,12 +1243,10 @@ shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::shear_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated shear in each of the three + * planes. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, CoordinateSystem cs) { FLOATNAME(LMatrix3) mat; @@ -1456,12 +1254,9 @@ shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, CoordinateSystem cs) { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_shear_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale and shear. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_shear_mat(const FLOATNAME(LVecBase3) &scale, const FLOATNAME(LVecBase3) &shear, @@ -1471,12 +1266,9 @@ scale_shear_mat(const FLOATNAME(LVecBase3) &scale, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_shear_mat -// Access: Published, Static -// Description: Returns a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale and shear. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix3):: scale_shear_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz, FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, @@ -1487,32 +1279,27 @@ scale_shear_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::almost_equal -// Access: Published -// Description: Returns true if two matrices are memberwise equal -// within a default tolerance based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two matrices are memberwise equal within a default + * tolerance based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LMatrix3):: almost_equal(const FLOATNAME(LMatrix3) &other) const { return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LMatrix3):: generate_hash(ChecksumHashGenerator &hashgen) const { generate_hash(hashgen, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: transpose -// Description: Transposes the given matrix and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Transposes the given matrix and returns it. + */ INLINE_LINMATH FLOATNAME(LMatrix3) transpose(const FLOATNAME(LMatrix3) &a) { FLOATNAME(LMatrix3) result; @@ -1520,10 +1307,9 @@ transpose(const FLOATNAME(LMatrix3) &a) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: invert -// Description: Inverts the given matrix and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the given matrix and returns it. + */ INLINE_LINMATH FLOATNAME(LMatrix3) invert(const FLOATNAME(LMatrix3) &a) { TAU_PROFILE("LMatrix3 invert(const LMatrix3 &)", " ", TAU_USER); diff --git a/panda/src/linmath/lmatrix3_src.cxx b/panda/src/linmath/lmatrix3_src.cxx index fab3993275..e21160b2fd 100644 --- a/panda/src/linmath/lmatrix3_src.cxx +++ b/panda/src/linmath/lmatrix3_src.cxx @@ -1,16 +1,15 @@ -// Filename: lmatrix3_src.cxx -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix3_src.cxx + * @author drose + * @date 1999-01-29 + */ TypeHandle FLOATNAME(LMatrix3)::_type_handle; @@ -45,12 +44,9 @@ const FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_lz_to_ry_mat = const FLOATNAME(LMatrix3) FLOATNAME(LMatrix3)::_ly_to_rz_mat = FLOATNAME(LMatrix3)::_flip_z_mat * FLOATNAME(LMatrix3)::_y_to_z_up_mat; -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_scale_shear_mat -// Access: Published -// Description: Fills mat with a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated scale and shear. + */ void FLOATNAME(LMatrix3):: set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale, const FLOATNAME(LVecBase3) &shear, @@ -60,10 +56,9 @@ set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale, cs = get_default_coordinate_system(); } - // We have to match the placement of the shear components in the - // matrix to the way we extract out the rotation in - // decompose_matrix(). Therefore, the shear is sensitive to the - // coordinate system. + // We have to match the placement of the shear components in the matrix to + // the way we extract out the rotation in decompose_matrix(). Therefore, + // the shear is sensitive to the coordinate system. switch (cs) { case CS_zup_right: @@ -100,12 +95,10 @@ set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale, } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::convert_mat -// Access: Published, Static -// Description: Returns a matrix that transforms from the indicated -// coordinate system to the indicated coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that transforms from the indicated coordinate system to + * the indicated coordinate system. + */ const FLOATNAME(LMatrix3) &FLOATNAME(LMatrix3):: convert_mat(CoordinateSystem from, CoordinateSystem to) { TAU_PROFILE("LMatrix3 LMatrix3::convert_mat(CoordinateSystem, CoordinateSystem)", " ", TAU_USER); @@ -165,13 +158,10 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) { return _ident_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::fill -// Access: Published -// Description: Sets each element of the matrix to the indicated -// fill_value. This is of questionable value, but is -// sometimes useful when initializing to zero. -//////////////////////////////////////////////////////////////////// +/** + * Sets each element of the matrix to the indicated fill_value. This is of + * questionable value, but is sometimes useful when initializing to zero. + */ void FLOATNAME(LMatrix3):: fill(FLOATTYPE fill_value) { TAU_PROFILE("void LMatrix3::fill(FLOATTYPE)", " ", TAU_USER); @@ -184,15 +174,11 @@ fill(FLOATTYPE fill_value) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::compare_to -// Access: Published -// Description: Sorts matrices lexicographically, componentwise. -// Returns a number less than 0 if this matrix sorts -// before the other one, greater than zero if it sorts -// after, 0 if they are equivalent (within the indicated -// tolerance). -//////////////////////////////////////////////////////////////////// +/** + * Sorts matrices lexicographically, componentwise. Returns a number less + * than 0 if this matrix sorts before the other one, greater than zero if it + * sorts after, 0 if they are equivalent (within the indicated tolerance). + */ int FLOATNAME(LMatrix3):: compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { TAU_PROFILE("int LMatrix3::compare_to(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); @@ -206,13 +192,10 @@ compare_to(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_rotate_mat -// Access: Published -// Description: Fills mat with a matrix that rotates by the given -// angle in degrees counterclockwise about the indicated -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. + */ void FLOATNAME(LMatrix3):: set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -222,8 +205,8 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, } if (IS_LEFT_HANDED_COORDSYSTEM(cs)) { - // In a left-handed coordinate system, counterclockwise is the - // other direction. + // In a left-handed coordinate system, counterclockwise is the other + // direction. angle = -angle; } @@ -267,13 +250,11 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, _m(2, 2) = t2 * axis_2 + c; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_rotate_mat_normaxis -// Access: Published -// Description: Fills mat with a matrix that rotates by the given -// angle in degrees counterclockwise about the indicated -// vector. Assumes axis has been normalized. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. Assumes axis has been + * normalized. + */ void FLOATNAME(LMatrix3):: set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -283,8 +264,8 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, } if (IS_LEFT_HANDED_COORDSYSTEM(cs)) { - // In a left-handed coordinate system, counterclockwise is the - // other direction. + // In a left-handed coordinate system, counterclockwise is the other + // direction. angle = -angle; } @@ -319,12 +300,10 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, _m(2, 2) = t2 * axis_2 + c; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::almost_equal -// Access: Published -// Description: Returns true if two matrices are memberwise equal -// within a specified tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two matrices are memberwise equal within a specified + * tolerance. + */ bool FLOATNAME(LMatrix3):: almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { TAU_PROFILE("bool LMatrix3::almost_equal(const LMatrix3 &, FLOATTYPE)", " ", TAU_USER); @@ -343,11 +322,9 @@ almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix3):: output(ostream &out) const { out << "[ " @@ -365,11 +342,9 @@ output(ostream &out) const { << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix3):: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -389,11 +364,9 @@ write(ostream &out, int indent_level) const { << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ void FLOATNAME(LMatrix3):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { TAU_PROFILE("void LMatrix3::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); @@ -404,17 +377,13 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::write_datagram_fixed -// Access: Published -// Description: Writes the matrix to the Datagram using add_float32() -// or add_float64(), depending on the type of floats in -// the matrix, regardless of the setting of -// Datagram::set_stdfloat_double(). This is appropriate -// when you want to write a fixed-width value to the -// datagram, especially when you are not writing a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the matrix to the Datagram using add_float32() or add_float64(), + * depending on the type of floats in the matrix, regardless of the setting of + * Datagram::set_stdfloat_double(). This is appropriate when you want to + * write a fixed-width value to the datagram, especially when you are not + * writing a bam file. + */ void FLOATNAME(LMatrix3):: write_datagram_fixed(Datagram &destination) const { for (int i = 0; i < 3; ++i) { @@ -428,12 +397,10 @@ write_datagram_fixed(Datagram &destination) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::read_datagram_fixed -// Access: Published -// Description: Reads the matrix from the Datagram using get_float32() -// or get_float64(). See write_datagram_fixed(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the matrix from the Datagram using get_float32() or get_float64(). + * See write_datagram_fixed(). + */ void FLOATNAME(LMatrix3):: read_datagram_fixed(DatagramIterator &scan) { for (int i = 0; i < 3; ++i) { @@ -447,14 +414,11 @@ read_datagram_fixed(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::write_datagram -// Access: Published -// Description: Writes the matrix to the Datagram using -// add_stdfloat(). This is appropriate when you want to -// write the matrix using the standard width setting, -// especially when you are writing a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the matrix to the Datagram using add_stdfloat(). This is + * appropriate when you want to write the matrix using the standard width + * setting, especially when you are writing a bam file. + */ void FLOATNAME(LMatrix3):: write_datagram(Datagram &destination) const { for (int i = 0; i < 3; ++i) { @@ -464,11 +428,9 @@ write_datagram(Datagram &destination) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::read_datagram -// Access: Published -// Description: Reads the matrix from the Datagram using get_stdfloat(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the matrix from the Datagram using get_stdfloat(). + */ void FLOATNAME(LMatrix3):: read_datagram(DatagramIterator &scan) { for (int i = 0; i < 3; ++i) { @@ -479,11 +441,9 @@ read_datagram(DatagramIterator &scan) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix3::init_type -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix3):: init_type() { if (_type_handle == TypeHandle::none()) { diff --git a/panda/src/linmath/lmatrix3_src.h b/panda/src/linmath/lmatrix3_src.h index 934cd5e53c..1960e586e7 100644 --- a/panda/src/linmath/lmatrix3_src.h +++ b/panda/src/linmath/lmatrix3_src.h @@ -1,27 +1,23 @@ -// Filename: lmatrix3_src.h -// Created by: drose (29Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix3_src.h + * @author drose + * @date 1999-01-29 + */ class FLOATNAME(LMatrix4); -//////////////////////////////////////////////////////////////////// -// Class : LMatrix3 -// Description : This is a 3-by-3 transform matrix. It typically will -// represent either a rotation-and-scale (no -// translation) matrix in 3-d, or a full affine matrix -// (rotation, scale, translation) in 2-d, e.g. for a -// texture matrix. -//////////////////////////////////////////////////////////////////// +/** + * This is a 3-by-3 transform matrix. It typically will represent either a + * rotation-and-scale (no translation) matrix in 3-d, or a full affine matrix + * (rotation, scale, translation) in 2-d, e.g. for a texture matrix. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LMatrix3) { public: typedef FLOATTYPE numeric_type; @@ -196,15 +192,14 @@ PUBLISHED: static INLINE_LINMATH const FLOATNAME(LMatrix3) &ident_mat(); - // A 3x3 matrix is likely to be used for one of two purposes. In - // 2-d coordinate space (e.g. texture or surface coordinates), it - // can contain a full affine transform, with scale, rotate, - // translate. In 3-d coordinate space, it can contain only scale - // and/or rotate; e.g., the upper 3x3 rectangle of a full 4x4 - // matrix. + // A 3x3 matrix is likely to be used for one of two purposes. In 2-d + // coordinate space (e.g. texture or surface coordinates), it can contain a + // full affine transform, with scale, rotate, translate. In 3-d coordinate + // space, it can contain only scale andor rotate; e.g., the upper 3x3 + // rectangle of a full 4x4 matrix. - // The following named constructors return 3x3 matrices suitable for - // affine transforms in 2-d coordinate space. + // The following named constructors return 3x3 matrices suitable for affine + // transforms in 2-d coordinate space. INLINE_LINMATH void set_translate_mat(const FLOATNAME(LVecBase2) &trans); @@ -225,7 +220,7 @@ PUBLISHED: scale_mat(FLOATTYPE sx, FLOATTYPE sy); // The following named constructors return 3x3 matrices suitable for - // scale/rotate transforms in 3-d coordinate space. + // scalerotate transforms in 3-d coordinate space. void set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, @@ -280,9 +275,8 @@ PUBLISHED: static const FLOATNAME(LMatrix3) &convert_mat(CoordinateSystem from, CoordinateSystem to); - // We don't have a scale_mat() that takes a single uniform scale - // parameter, because it would be ambiguous whether we mean a 2-d or - // a 3-d scale. + // We don't have a scale_mat() that takes a single uniform scale parameter, + // because it would be ambiguous whether we mean a 2-d or a 3-d scale. bool almost_equal(const FLOATNAME(LMatrix3) &other, FLOATTYPE threshold) const; @@ -305,8 +299,8 @@ PUBLISHED: public: // The underlying implementation is via the Eigen library, if available. - // We don't bother to align LMatrix3, since it won't benefit from - // SSE2 optimizations anyway (it's an add number of floats). + // We don't bother to align LMatrix3, since it won't benefit from SSE2 + // optimizations anyway (it's an add number of floats). typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 3, 3) EMatrix3; EMatrix3 _m; diff --git a/panda/src/linmath/lmatrix4_ext_src.I b/panda/src/linmath/lmatrix4_ext_src.I index 4cc50e89a8..23a4a26518 100644 --- a/panda/src/linmath/lmatrix4_ext_src.I +++ b/panda/src/linmath/lmatrix4_ext_src.I @@ -1,36 +1,31 @@ -// Filename: lmatrix4_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix4_ext_src.I + * @author rdb + * @date 2011-01-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ INLINE_LINMATH PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; } - PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, + PyObject *result = Py_BuildValue("(O(ffffffffffffffff))", this_class, _this->_m(0, 0), _this->_m(0, 1), _this->_m(0, 2), _this->_m(0, 3), _this->_m(1, 0), _this->_m(1, 1), _this->_m(1, 2), _this->_m(1, 3), _this->_m(2, 0), _this->_m(2, 1), _this->_m(2, 2), _this->_m(2, 3), @@ -40,11 +35,9 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; diff --git a/panda/src/linmath/lmatrix4_ext_src.h b/panda/src/linmath/lmatrix4_ext_src.h index 268d9b615e..65dfe8bb20 100644 --- a/panda/src/linmath/lmatrix4_ext_src.h +++ b/panda/src/linmath/lmatrix4_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lmatrix4_ext_src.h -// Created by: rdb (12Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix4_ext_src.h + * @author rdb + * @date 2013-09-12 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LMatrix4, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LMatrix4, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lmatrix4_src.I b/panda/src/linmath/lmatrix4_src.I index c162bd868a..32250339c3 100644 --- a/panda/src/linmath/lmatrix4_src.I +++ b/panda/src/linmath/lmatrix4_src.I @@ -1,155 +1,125 @@ -// Filename: lmatrix4_src.I -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix4_src.I + * @author drose + * @date 1999-01-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Row::Constructor -// Access: Private -// Description: Defines a row-level index accessor to the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Defines a row-level index accessor to the matrix. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::Row:: Row(FLOATTYPE *row) : _row(row) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Row::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4)::Row:: operator [](int i) const { nassertr(i >= 0 && i < 4, 0.0); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Row::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix4)::Row:: operator [](int i) { nassertr(i >= 0 && i < 4, _row[0]); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Row::size -// Access: Public, Static -// Description: Returns 4: the number of columns of a LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4: the number of columns of a LMatrix4. + */ INLINE_LINMATH int FLOATNAME(LMatrix4)::Row:: size() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::CRow::Constructor -// Access: Private -// Description: Defines a row-level constant accessor to the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Defines a row-level constant accessor to the matrix. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::CRow:: CRow(const FLOATTYPE *row) : _row(row) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::CRow::operator [] -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4)::CRow:: operator [](int i) const { nassertr(i >= 0 && i < 4, 0.0); return _row[i]; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::CRow::size -// Access: Public, Static -// Description: Returns 4: the number of columns of a LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4: the number of columns of a LMatrix4. + */ INLINE_LINMATH int FLOATNAME(LMatrix4)::CRow:: size() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::ident_mat -// Access: Public, Static -// Description: Returns an identity matrix. -// -// This function definition must appear first, since -// some inline functions below take advantage of it. -//////////////////////////////////////////////////////////////////// +/** + * Returns an identity matrix. + * + * This function definition must appear first, since some inline functions + * below take advantage of it. + */ INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: ident_mat() { return _ident_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::ones_mat -// Access: Public, Static -// Description: Returns an matrix filled with ones. -//////////////////////////////////////////////////////////////////// +/** + * Returns an matrix filled with ones. + */ INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: ones_mat() { return _ones_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::zeros_mat -// Access: Public, Static -// Description: Returns an matrix filled with zeros. -//////////////////////////////////////////////////////////////////// +/** + * Returns an matrix filled with zeros. + */ INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: zeros_mat() { return _zeros_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)() { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix4) ©) : _m(copy._m) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(UnalignedLMatrix4) ©) { operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator = (const FLOATNAME(LMatrix4) ©) { TAU_PROFILE("void LMatrix4::operator = (const LMatrix4 &)", " ", TAU_USER); @@ -157,11 +127,9 @@ operator = (const FLOATNAME(LMatrix4) ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator = (const FLOATNAME(UnalignedLMatrix4) ©) { TAU_PROFILE("void LMatrix4::operator = (const UnalignedLMatrix4 &)", " ", TAU_USER); @@ -170,22 +138,18 @@ operator = (const FLOATNAME(UnalignedLMatrix4) ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Fill Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator = (FLOATTYPE fill_value) { fill(fill_value); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, @@ -214,11 +178,9 @@ FLOATNAME(LMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, _m(3, 3) = e33; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Constructor, upper 3x3 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3) { TAU_PROFILE("void LMatrix4::LMatrix4(const LMatrix3 &)", " ", TAU_USER); @@ -244,11 +206,9 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3) { _m(3, 3) = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Constructor, upper 3x3 plus translation -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4):: FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3, const FLOATNAME(LVecBase3) &trans) { @@ -275,13 +235,10 @@ FLOATNAME(LMatrix4)(const FLOATNAME(LMatrix3) &upper3, _m(3, 3) = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::fill -// Access: Public -// Description: Sets each element of the matrix to the indicated -// fill_value. This is of questionable value, but is -// sometimes useful when initializing to zero. -//////////////////////////////////////////////////////////////////// +/** + * Sets each element of the matrix to the indicated fill_value. This is of + * questionable value, but is sometimes useful when initializing to zero. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: fill(FLOATTYPE fill_value) { TAU_PROFILE("void LMatrix4::fill(FLOATTYPE)", " ", TAU_USER); @@ -295,11 +252,9 @@ fill(FLOATTYPE fill_value) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, @@ -328,11 +283,9 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, _m(3, 3) = e33; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_upper_3 -// Access: Public -// Description: Sets the upper 3x3 submatrix. -//////////////////////////////////////////////////////////////////// +/** + * Sets the upper 3x3 submatrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_upper_3(const FLOATNAME(LMatrix3) &upper3) { TAU_PROFILE("void LMatrix4::set_upper_3(const LMatrix3 &)", " ", TAU_USER); @@ -353,11 +306,9 @@ set_upper_3(const FLOATNAME(LMatrix3) &upper3) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_upper_3 -// Access: Public -// Description: Retrieves the upper 3x3 submatrix. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the upper 3x3 submatrix. + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LMatrix4):: get_upper_3() const { TAU_PROFILE("LMatrix3 LMatrix4::get_upper_3()", " ", TAU_USER); @@ -371,11 +322,9 @@ get_upper_3() const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_row -// Access: Public -// Description: Replaces the indicated row of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated row of the matrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_row(int row, const FLOATNAME(LVecBase4) &v) { #ifdef HAVE_EIGEN @@ -388,11 +337,9 @@ set_row(int row, const FLOATNAME(LVecBase4) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_col -// Access: Public -// Description: Replaces the indicated column of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated column of the matrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_col(int col, const FLOATNAME(LVecBase4) &v) { #ifdef HAVE_EIGEN @@ -405,13 +352,10 @@ set_col(int col, const FLOATNAME(LVecBase4) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_row -// Access: Public -// Description: Replaces the indicated row of the matrix with the -// indicated 3-component vector, ignoring the last -// column. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated row of the matrix with the indicated 3-component + * vector, ignoring the last column. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_row(int row, const FLOATNAME(LVecBase3) &v) { #ifdef HAVE_EIGEN @@ -423,13 +367,10 @@ set_row(int row, const FLOATNAME(LVecBase3) &v) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_col -// Access: Public -// Description: Replaces the indicated column of the matrix with the -// indicated 3-component vector, ignoring the last -// row. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the indicated column of the matrix with the indicated 3-component + * vector, ignoring the last row. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_col(int col, const FLOATNAME(LVecBase3) &v) { #ifdef HAVE_EIGEN @@ -441,12 +382,9 @@ set_col(int col, const FLOATNAME(LVecBase3) &v) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_row -// Access: Public -// Description: Retrieves the indicated row of the matrix as a -// 4-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the indicated row of the matrix as a 4-component vector. + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LMatrix4):: get_row(int row) const { #ifdef HAVE_EIGEN @@ -459,12 +397,9 @@ get_row(int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_row -// Access: Public -// Description: Stores the indicated row of the matrix as a -// 4-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated row of the matrix as a 4-component vector. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: get_row(FLOATNAME(LVecBase4) &result_vec, int row) const { #ifdef HAVE_EIGEN @@ -477,12 +412,9 @@ get_row(FLOATNAME(LVecBase4) &result_vec, int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_col -// Access: Public -// Description: Retrieves the indicated column of the matrix as a -// 4-component vector. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the indicated column of the matrix as a 4-component vector. + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LMatrix4):: get_col(int col) const { #ifdef HAVE_EIGEN @@ -495,12 +427,10 @@ get_col(int col) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_row3 -// Access: Public -// Description: Retrieves the row column of the matrix as a -// 3-component vector, ignoring the last column. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the row column of the matrix as a 3-component vector, ignoring + * the last column. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: get_row3(int row) const { #ifdef HAVE_EIGEN @@ -512,12 +442,10 @@ get_row3(int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_row3 -// Access: Public -// Description: Stores the row column of the matrix as a -// 3-component vector, ignoring the last column. -//////////////////////////////////////////////////////////////////// +/** + * Stores the row column of the matrix as a 3-component vector, ignoring the + * last column. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: get_row3(FLOATNAME(LVecBase3) &result_vec,int row) const { #ifdef HAVE_EIGEN @@ -529,12 +457,10 @@ get_row3(FLOATNAME(LVecBase3) &result_vec,int row) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_col3 -// Access: Public -// Description: Retrieves the indicated column of the matrix as a -// 3-component vector, ignoring the last row. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the indicated column of the matrix as a 3-component vector, + * ignoring the last row. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: get_col3(int col) const { #ifdef HAVE_EIGEN @@ -546,66 +472,54 @@ get_col3(int col) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LMatrix4):: operator () (int row, int col) { nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, _m(0, 0)); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Indexing operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4):: operator () (int row, int col) const { nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, _m(0, 0)); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4)::CRow FLOATNAME(LMatrix4):: operator [](int i) const { nassertr(i >= 0 && i < 4, CRow(&_m(0, 0))); return CRow(&_m(i, 0)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4)::Row FLOATNAME(LMatrix4):: operator [](int i) { nassertr(i >= 0 && i < 4, Row(&_m(0, 0))); return Row(&_m(i, 0)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::size -// Access: Public, Static -// Description: Returns 4: the number of rows of a LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4: the number of rows of a LMatrix4. + */ INLINE_LINMATH int FLOATNAME(LMatrix4):: size() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::is_nan -// Access: Public -// Description: Returns true if any component of the matrix is -// not-a-number, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any component of the matrix is not-a-number, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: is_nan() const { TAU_PROFILE("bool LMatrix4::is_nan()", " ", TAU_USER); @@ -616,186 +530,149 @@ is_nan() const { cnan(_m(3, 0)) || cnan(_m(3, 1)) || cnan(_m(3, 2)) || cnan(_m(3, 3)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::is_identity -// Access: Public -// Description: Returns true if this is (close enough to) the -// identity matrix, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is (close enough to) the identity matrix, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: is_identity() const { // Eigen has isIdentity, but it seems to be twice as slow as this. return almost_equal(ident_mat(), NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_cell -// Access: Public -// Description: Returns a particular element of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a particular element of the matrix. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LMatrix4):: get_cell(int row, int col) const { nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, 0.0f); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::set_cell -// Access: Public -// Description: Changes a particular element of the matrix. -//////////////////////////////////////////////////////////////////// +/** + * Changes a particular element of the matrix. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_cell(int row, int col, FLOATTYPE value) { nassertv(row >= 0 && row < 4 && col >= 0 && col < 4); _m(row, col) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_data -// Access: Public -// Description: Returns the address of the first of the nine data -// elements in the matrix. The remaining elements -// occupy the next eight positions in row-major order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the nine data elements in the matrix. + * The remaining elements occupy the next eight positions in row-major order. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(LMatrix4):: get_data() const { return &_m(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_num_components -// Access: Public -// Description: Returns the number of elements in the matrix, 16. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the matrix, 16. + */ INLINE_LINMATH int FLOATNAME(LMatrix4):: get_num_components() const { return 16; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::begin -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::iterator FLOATNAME(LMatrix4):: begin() { return &_m(0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::end -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::iterator FLOATNAME(LMatrix4):: end() { return begin() + 16; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::begin -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::const_iterator FLOATNAME(LMatrix4):: begin() const { return &_m(0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::end -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LMatrix4)::const_iterator FLOATNAME(LMatrix4):: end() const { return begin() + 16; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Ordering Operator -// Access: Public -// Description: This performs a lexicographical comparison. It's of -// questionable mathematical meaning, but sometimes has -// a practical purpose for sorting unique vectors, -// especially in an STL container. Also see -// compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This performs a lexicographical comparison. It's of questionable + * mathematical meaning, but sometimes has a practical purpose for sorting + * unique vectors, especially in an STL container. Also see compare_to(). + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: operator < (const FLOATNAME(LMatrix4) &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Equality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: operator == (const FLOATNAME(LMatrix4) &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::Inequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: operator != (const FLOATNAME(LMatrix4) &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::compare_to -// Access: Public -// Description: This flavor of compare_to uses a default threshold -// value based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of compare_to uses a default threshold value based on the + * numeric type. + */ INLINE_LINMATH int FLOATNAME(LMatrix4):: compare_to(const FLOATNAME(LMatrix4) &other) const { return compare_to(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_hash -// Access: Public -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix4):: get_hash() const { return add_hash(0); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::get_hash -// Access: Public -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix4):: get_hash(FLOATTYPE threshold) const { return add_hash(0, threshold); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::add_hash -// Access: Public -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix4):: add_hash(size_t hash) const { return add_hash(hash, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::add_hash -// Access: Public -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LMatrix4):: add_hash(size_t hash, FLOATTYPE threshold) const { TAU_PROFILE("size_t LMatrix4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); @@ -830,12 +707,10 @@ v_res._v(1) = v._v(0)*mat._m(0, 1) + v._v(1)*mat._m(1, 1) + v._v(2)*mat._m(2, 1) v_res._v(2) = v._v(0)*mat._m(0, 2) + v._v(1)*mat._m(1, 2) + v._v(2)*mat._m(2, 2) + v._v(3)*mat._m(3, 2); \ v_res._v(3) = v._v(0)*mat._m(0, 3) + v._v(1)*mat._m(1, 3) + v._v(2)*mat._m(2, 3) + v._v(3)*mat._m(3, 3); -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform -// Access: Public -// Description: 4-component vector or point times matrix. This is a -// fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * 4-component vector or point times matrix. This is a fully general + * operation. + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LMatrix4):: xform(const FLOATNAME(LVecBase4) &v) const { TAU_PROFILE("LVecBase3 LMatrix4::xform(const LVecBase3 &)", " ", TAU_USER); @@ -851,13 +726,10 @@ xform(const FLOATNAME(LVecBase4) &v) const { #undef VECTOR4_MATRIX4_PRODUCT -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_point -// Access: Public -// Description: The matrix transforms a 3-component point (including -// translation component) and returns the result. This -// assumes the matrix is an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component point (including translation component) + * and returns the result. This assumes the matrix is an affine transform. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_point(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix4::xform_point(const LVecBase3 &)", " ", TAU_USER); @@ -876,13 +748,10 @@ xform_point(const FLOATNAME(LVecBase3) &v) const { return v_res; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_point_general -// Access: Public -// Description: The matrix transforms a 3-component point (including -// translation component) and returns the result, as a -// fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component point (including translation component) + * and returns the result, as a fully general operation. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_point_general(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix4::xform_point_general(const LVecBase3 &)", " ", TAU_USER); @@ -891,13 +760,11 @@ xform_point_general(const FLOATNAME(LVecBase3) &v) const { return FLOATNAME(LVecBase3)(v4[0] / v4[3], v4[1] / v4[3], v4[2] / v4[3]); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_vec -// Access: Public -// Description: The matrix transforms a 3-component vector (without -// translation component) and returns the result. This -// assumes the matrix is an orthonormal transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component) + * and returns the result. This assumes the matrix is an orthonormal + * transform. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_vec(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix4::xform_vec(const LVecBase3 &)", " ", TAU_USER); @@ -916,13 +783,10 @@ xform_vec(const FLOATNAME(LVecBase3) &v) const { return v_res; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_vec_general -// Access: Public -// Description: The matrix transforms a 3-component vector (without -// translation component) and returns the result, as a -// fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component) + * and returns the result, as a fully general operation. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LMatrix4):: xform_vec_general(const FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("LVecBase3 LMatrix4::xform_vec_general(const LVecBase3 &)", " ", TAU_USER); @@ -936,12 +800,10 @@ xform_vec_general(const FLOATNAME(LVecBase3) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_in_place -// Access: Public -// Description: 4-component vector or point times matrix. This is a -// fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * 4-component vector or point times matrix. This is a fully general + * operation. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: xform_in_place(FLOATNAME(LVecBase4) &v) const { TAU_PROFILE("void LMatrix4::xform_in_place(LVecBase3 &)", " ", TAU_USER); @@ -953,13 +815,10 @@ xform_in_place(FLOATNAME(LVecBase4) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_point_in_place -// Access: Public -// Description: The matrix transforms a 3-component point (including -// translation component). This assumes the matrix is -// an affine transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component point (including translation + * component). This assumes the matrix is an affine transform. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: xform_point_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix4::xform_point_in_place(LVecBase3 &)", " ", TAU_USER); @@ -972,25 +831,20 @@ xform_point_in_place(FLOATNAME(LVecBase3) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_point_general_in_place -// Access: Public -// Description: The matrix transforms a 3-component point (including -// translation component), as a fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component point (including translation + * component), as a fully general operation. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: xform_point_general_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix4::xform_point_general_in_place(LVecBase3 &)", " ", TAU_USER); v = xform_point_general(v); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_vec_in_place -// Access: Public -// Description: The matrix transforms a 3-component vector (without -// translation component). This assumes the matrix is -// an orthonormal transform. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component). + * This assumes the matrix is an orthonormal transform. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: xform_vec_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix4::xform_vec_in_place(LVecBase3 &)", " ", TAU_USER); @@ -1003,12 +857,10 @@ xform_vec_in_place(FLOATNAME(LVecBase3) &v) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::xform_vec_general_in_place -// Access: Public -// Description: The matrix transforms a 3-component vector (without -// translation component), as a fully general operation. -//////////////////////////////////////////////////////////////////// +/** + * The matrix transforms a 3-component vector (without translation component), + * as a fully general operation. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: xform_vec_general_in_place(FLOATNAME(LVecBase3) &v) const { TAU_PROFILE("void LMatrix4::xform_vec_general_in_place(LVecBase3 &)", " ", TAU_USER); @@ -1040,11 +892,9 @@ res._m(3, 1) = a._m(3, 0)*b._m(0, 1) + a._m(3, 1)*b._m(1, 1) + a._m(3, 2)*b._m(2 res._m(3, 2) = a._m(3, 0)*b._m(0, 2) + a._m(3, 1)*b._m(1, 2) + a._m(3, 2)*b._m(2, 2) + a._m(3, 3)*b._m(3, 2); \ res._m(3, 3) = a._m(3, 0)*b._m(0, 3) + a._m(3, 1)*b._m(1, 3) + a._m(3, 2)*b._m(2, 3) + a._m(3, 3)*b._m(3, 3); -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix * matrix -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator * (const FLOATNAME(LMatrix4) &other) const { TAU_PROFILE("LMatrix4 LMatrix4::operator *(const LMatrix4 &)", " ", TAU_USER); @@ -1057,8 +907,8 @@ operator * (const FLOATNAME(LMatrix4) &other) const { INLINE_LINMATH void FLOATNAME(LMatrix4):: multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2) { TAU_PROFILE("LMatrix4 multiply(const LMatrix4 &, const LMatrix4 &)", " ", TAU_USER); - // faster than operator * since it writes result in place, avoiding extra copying - // this will fail if you try to mat.multiply(mat,other_mat) + // faster than operator * since it writes result in place, avoiding extra + // copying this will fail if you try to mat.multiply(mat,other_mat) nassertv((&other1 != this) && (&other2 != this)); @@ -1072,11 +922,9 @@ multiply(const FLOATNAME(LMatrix4) &other1, const FLOATNAME(LMatrix4) &other2) { #undef MATRIX4_PRODUCT -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator * (FLOATTYPE scalar) const { TAU_PROFILE("LMatrix4 operator *(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); @@ -1110,22 +958,18 @@ operator * (FLOATTYPE scalar) const { return t; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: operator / (FLOATTYPE scalar) const { FLOATTYPE recip_scalar = 1.0f/scalar; return (*this) * recip_scalar; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix += matrix -// Access: Public -// Description: Performs a memberwise addition between two matrices. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise addition between two matrices. + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator += (const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("LMatrix4 LMatrix4::operator +=(const LMatrix4 &)", " ", TAU_USER); @@ -1157,11 +1001,9 @@ operator += (const FLOATNAME(LMatrix4) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix -= matrix -// Access: Public -// Description: Performs a memberwise addition between two matrices. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise addition between two matrices. + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator -= (const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("LMatrix4 LMatrix4::operator -=(const LMatrix4 &)", " ", TAU_USER); @@ -1194,11 +1036,9 @@ operator -= (const FLOATNAME(LMatrix4) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix *= matrix -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator *= (const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("LMatrix4 LMatrix4::operator *=(const LMatrix4 &)", " ", TAU_USER); @@ -1213,11 +1053,9 @@ operator *= (const FLOATNAME(LMatrix4) &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix *= scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator *= (FLOATTYPE scalar) { TAU_PROFILE("LMatrix4 LMatrix4::operator *=(FLOATTYPE)", " ", TAU_USER); @@ -1249,11 +1087,9 @@ operator *= (FLOATTYPE scalar) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::matrix /= scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: operator /= (FLOATTYPE scalar) { TAU_PROFILE("LMatrix4 LMatrix4::operator /=(FLOATTYPE)", " ", TAU_USER); @@ -1261,11 +1097,9 @@ operator /= (FLOATTYPE scalar) { return operator *= (recip_scalar); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::componentwise_mult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: componentwise_mult(const FLOATNAME(LMatrix4) &other) { #ifdef HAVE_EIGEN @@ -1294,11 +1128,9 @@ componentwise_mult(const FLOATNAME(LMatrix4) &other) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::transpose_from -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: transpose_from(const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("LMatrix4 LMatrix4::transpose_from(const LMatrix4 &other)", " ", TAU_USER); @@ -1328,11 +1160,9 @@ transpose_from(const FLOATNAME(LMatrix4) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::transpose_in_place -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: transpose_in_place() { TAU_PROFILE("void LMatrix4::transpose_in_place()", " ", TAU_USER); @@ -1350,30 +1180,25 @@ transpose_in_place() { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::invert_from -// Access: Public -// Description: Computes the inverse of the other matrix, and stores -// the result in this matrix. This is a fully general -// operation and makes no assumptions about the type of -// transform represented by the matrix. -// -// The other matrix must be a different object than this -// matrix. However, if you need to invert a matrix in -// place, see invert_in_place. -// -// The return value is true if the matrix was -// successfully inverted, false if the was a -// singularity. -//////////////////////////////////////////////////////////////////// +/** + * Computes the inverse of the other matrix, and stores the result in this + * matrix. This is a fully general operation and makes no assumptions about + * the type of transform represented by the matrix. + * + * The other matrix must be a different object than this matrix. However, if + * you need to invert a matrix in place, see invert_in_place. + * + * The return value is true if the matrix was successfully inverted, false if + * the was a singularity. + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_from(const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("bool LMatrix4::invert_from(const LMatrix4 &)", " ", TAU_USER); #ifdef HAVE_EIGEN - // We use the squared nearly_zero value as determinant threshold - // for checking whether a matrix is singular, since that's the - // same constant we use in the non-Eigen case (see lmatrix3_src.I) - // and also because we otherwise run into issues very quickly. + // We use the squared nearly_zero value as determinant threshold for + // checking whether a matrix is singular, since that's the same constant we + // use in the non-Eigen case (see lmatrix3_src.I) and also because we + // otherwise run into issues very quickly. bool invertible; other._m.computeInverseWithCheck(_m, invertible, NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)); @@ -1423,25 +1248,20 @@ invert_from(const FLOATNAME(LMatrix4) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::invert_affine_from -// Access: Public -// Description: Performs an invert of the indicated matrix, storing -// the result in this matrix. The calculation is only -// correct of the other matrix represents an affine -// transform. -// -// The other matrix must be a different object than this -// matrix. However, if you need to invert a matrix in -// place, see invert_in_place. -// -// The return value is true if the matrix was -// successfully inverted, false if there was a -// singularity. -//////////////////////////////////////////////////////////////////// +/** + * Performs an invert of the indicated matrix, storing the result in this + * matrix. The calculation is only correct of the other matrix represents an + * affine transform. + * + * The other matrix must be a different object than this matrix. However, if + * you need to invert a matrix in place, see invert_in_place. + * + * The return value is true if the matrix was successfully inverted, false if + * there was a singularity. + */ -// bugbug: we could optimize this for rotation/scale/translation matrices -// (transpose upper 3x3 and take negative of translation component) +// bugbug: we could optimize this for rotationscaletranslation matrices +// (transpose upper 3x3 and take negative of translation component) INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_affine_from(const FLOATNAME(LMatrix4) &other) { TAU_PROFILE("bool LMatrix4::invert_affine_from(const LMatrix4 &)", " ", TAU_USER); @@ -1474,13 +1294,10 @@ invert_affine_from(const FLOATNAME(LMatrix4) &other) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::invert_in_place -// Access: Public -// Description: Inverts the current matrix. Returns true if the -// inverse is successful, false if the matrix was -// singular. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the current matrix. Returns true if the inverse is successful, + * false if the matrix was singular. + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: invert_in_place() { TAU_PROFILE("bool LMatrix4::invert_in_place()", " ", TAU_USER); @@ -1488,11 +1305,9 @@ invert_in_place() { return invert_from(temp); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::accumulate -// Access: Public -// Description: Computes (*this) += other * weight. -//////////////////////////////////////////////////////////////////// +/** + * Computes (*this) += other * weight. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: accumulate(const FLOATNAME(LMatrix4) &other, FLOATTYPE weight) { #ifdef HAVE_EIGEN @@ -1520,12 +1335,9 @@ accumulate(const FLOATNAME(LMatrix4) &other, FLOATTYPE weight) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_translate_mat -// Access: Public -// Description: Fills mat with a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated translation. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_translate_mat(const FLOATNAME(LVecBase3) &trans) { set(1.0f, 0.0f, 0.0f, 0.0f, @@ -1534,12 +1346,10 @@ set_translate_mat(const FLOATNAME(LVecBase3) &trans) { trans._v(0), trans._v(1), trans._v(2), 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_scale_mat -// Access: Public -// Description: Fills mat with a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated scale in each of the + * three axes. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_scale_mat(const FLOATNAME(LVecBase3) &scale) { set(scale._v(0), 0.0f, 0.0f, 0.0f, @@ -1548,24 +1358,19 @@ set_scale_mat(const FLOATNAME(LVecBase3) &scale) { 0.0f, 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_shear_mat -// Access: Public -// Description: Fills mat with a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated shear in each of the + * three planes. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { set_scale_shear_mat(FLOATNAME(LVecBase3)(1.0f, 1.0f, 1.0f), shear, cs); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_scale_shear_mat -// Access: Public, Static -// Description: Fills mat with a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that applies the indicated scale and shear. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale, const FLOATNAME(LVecBase3) &shear, @@ -1584,12 +1389,9 @@ set_scale_shear_mat(const FLOATNAME(LVecBase3) &scale, _m(3, 2) = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::translate_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated translation. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: translate_mat(const FLOATNAME(LVecBase3) &trans) { return FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f, @@ -1598,12 +1400,9 @@ translate_mat(const FLOATNAME(LVecBase3) &trans) { trans._v(0), trans._v(1), trans._v(2), 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::translate_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated translation. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz) { return FLOATNAME(LMatrix4)(1.0f, 0.0f, 0.0f, 0.0f, @@ -1612,12 +1411,10 @@ translate_mat(FLOATTYPE tx, FLOATTYPE ty, FLOATTYPE tz) { tx, ty, tz, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::rotate_mat -// Access: Public, Static -// Description: Returns a matrix that rotates by the given angle in -// degrees counterclockwise about the indicated vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -1626,13 +1423,11 @@ rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::rotate_mat_normaxis -// Access: Public, Static -// Description: Returns a matrix that rotates by the given angle in -// degrees counterclockwise about the indicated vector. -// Assumes axis has been prenormalized. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. Assumes axis has been + * prenormalized. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -1643,12 +1438,10 @@ rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the three + * axes. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: scale_mat(const FLOATNAME(LVecBase3) &scale) { return FLOATNAME(LMatrix4)(scale._v(0), 0.0f, 0.0f, 0.0f, @@ -1658,12 +1451,10 @@ scale_mat(const FLOATNAME(LVecBase3) &scale) { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// scale in each of the three axes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale in each of the three + * axes. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz) { return FLOATNAME(LMatrix4)(sx, 0.0f, 0.0f, 0.0f, @@ -1672,12 +1463,9 @@ scale_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz) { 0.0f, 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// uniform scale. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated uniform scale. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: scale_mat(FLOATTYPE scale) { return FLOATNAME(LMatrix4)(scale, 0.0f, 0.0f, 0.0f, @@ -1686,12 +1474,10 @@ scale_mat(FLOATTYPE scale) { 0.0f, 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::shear_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated shear in each of the three + * planes. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { FLOATNAME(LMatrix4) mat; @@ -1699,12 +1485,10 @@ shear_mat(const FLOATNAME(LVecBase3) &shear, CoordinateSystem cs) { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::shear_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// shear in each of the three planes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated shear in each of the three + * planes. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, CoordinateSystem cs) { @@ -1713,12 +1497,9 @@ shear_mat(FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_shear_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale and shear. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: scale_shear_mat(const FLOATNAME(LVecBase3) &scale, const FLOATNAME(LVecBase3) &shear, @@ -1728,12 +1509,9 @@ scale_shear_mat(const FLOATNAME(LVecBase3) &scale, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::scale_shear_mat -// Access: Public, Static -// Description: Returns a matrix that applies the indicated -// scale and shear. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that applies the indicated scale and shear. + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LMatrix4):: scale_shear_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz, FLOATTYPE shxy, FLOATTYPE shxz, FLOATTYPE shyz, @@ -1744,53 +1522,44 @@ scale_shear_mat(FLOATTYPE sx, FLOATTYPE sy, FLOATTYPE sz, return mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::y_to_z_up_mat -// Access: Public, Static -// Description: Returns a matrix that transforms from the Y-up -// coordinate system to the Z-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that transforms from the Y-up coordinate system to the + * Z-up coordinate system. + */ INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: y_to_z_up_mat() { return _y_to_z_up_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::z_to_y_up_mat -// Access: Public, Static -// Description: Returns a matrix that transforms from the Y-up -// coordinate system to the Z-up coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that transforms from the Y-up coordinate system to the + * Z-up coordinate system. + */ INLINE_LINMATH const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: z_to_y_up_mat() { return _z_to_y_up_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::almost_equal -// Access: Public -// Description: Returns true if two matrices are memberwise equal -// within a default tolerance based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two matrices are memberwise equal within a default + * tolerance based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LMatrix4):: almost_equal(const FLOATNAME(LMatrix4) &other) const { return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::generate_hash -// Access: Public -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LMatrix4):: generate_hash(ChecksumHashGenerator &hashgen) const { generate_hash(hashgen, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: transpose -// Description: Transposes the given matrix and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Transposes the given matrix and returns it. + */ INLINE_LINMATH FLOATNAME(LMatrix4) transpose(const FLOATNAME(LMatrix4) &a) { FLOATNAME(LMatrix4) result; @@ -1798,10 +1567,9 @@ transpose(const FLOATNAME(LMatrix4) &a) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: invert -// Description: Inverts the given matrix and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the given matrix and returns it. + */ INLINE_LINMATH FLOATNAME(LMatrix4) invert(const FLOATNAME(LMatrix4) &a) { TAU_PROFILE("LMatrix4 invert(const LMatrix4 &)", " ", TAU_USER); @@ -1817,50 +1585,40 @@ invert(const FLOATNAME(LMatrix4) &a) { } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4):: FLOATNAME(UnalignedLMatrix4)() { } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4):: FLOATNAME(UnalignedLMatrix4)(const FLOATNAME(LMatrix4) ©) { operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4):: FLOATNAME(UnalignedLMatrix4)(const FLOATNAME(UnalignedLMatrix4) ©) : _m(copy._m) { } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4) &FLOATNAME(UnalignedLMatrix4):: operator = (const FLOATNAME(LMatrix4) ©) { memcpy(&_m(0, 0), copy.get_data(), sizeof(FLOATTYPE) * num_components); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4) &FLOATNAME(UnalignedLMatrix4):: operator = (const FLOATNAME(UnalignedLMatrix4) ©) { TAU_PROFILE("void UnalignedLMatrix4::operator =(UnalignedLMatrix4 &)", " ", TAU_USER); @@ -1868,11 +1626,9 @@ operator = (const FLOATNAME(UnalignedLMatrix4) ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLMatrix4):: FLOATNAME(UnalignedLMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, @@ -1885,11 +1641,9 @@ FLOATNAME(UnalignedLMatrix4)(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATT e30, e31, e32, e33); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(UnalignedLMatrix4):: set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, FLOATTYPE e10, FLOATTYPE e11, FLOATTYPE e12, FLOATTYPE e13, @@ -1918,45 +1672,36 @@ set(FLOATTYPE e00, FLOATTYPE e01, FLOATTYPE e02, FLOATTYPE e03, _m(3, 3) = e33; } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Indexing operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLMatrix4):: operator () (int row, int col) { nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, _m(0, 0)); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::Indexing operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLMatrix4):: operator () (int row, int col) const { nassertr(row >= 0 && row < 4 && col >= 0 && col < 4, 0.0); return _m(row, col); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::get_data -// Access: Published -// Description: Returns the address of the first of the nine data -// elements in the matrix. The remaining elements -// occupy the next eight positions in row-major order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the nine data elements in the matrix. + * The remaining elements occupy the next eight positions in row-major order. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(UnalignedLMatrix4):: get_data() const { return &_m(0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::get_num_components -// Access: Published -// Description: Returns the number of elements in the matrix, sixteen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the matrix, sixteen. + */ INLINE_LINMATH int FLOATNAME(UnalignedLMatrix4):: get_num_components() const { return 16; diff --git a/panda/src/linmath/lmatrix4_src.cxx b/panda/src/linmath/lmatrix4_src.cxx index f5406757b5..427841965f 100644 --- a/panda/src/linmath/lmatrix4_src.cxx +++ b/panda/src/linmath/lmatrix4_src.cxx @@ -1,16 +1,15 @@ -// Filename: lmatrix4_src.cxx -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix4_src.cxx + * @author drose + * @date 1999-01-15 + */ TypeHandle FLOATNAME(LMatrix4)::_type_handle; TypeHandle FLOATNAME(UnalignedLMatrix4)::_type_handle; @@ -63,12 +62,10 @@ const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_lz_to_ry_mat = const FLOATNAME(LMatrix4) FLOATNAME(LMatrix4)::_ly_to_rz_mat = FLOATNAME(LMatrix4)::_flip_z_mat * FLOATNAME(LMatrix4)::_y_to_z_up_mat; -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::convert_mat -// Access: Public, Static -// Description: Returns a matrix that transforms from the indicated -// coordinate system to the indicated coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a matrix that transforms from the indicated coordinate system to + * the indicated coordinate system. + */ const FLOATNAME(LMatrix4) &FLOATNAME(LMatrix4):: convert_mat(CoordinateSystem from, CoordinateSystem to) { TAU_PROFILE("LMatrix4 LMatrix4::convert_mat(CoordinateSystem, CoordinateSystem)", " ", TAU_USER); @@ -128,20 +125,16 @@ convert_mat(CoordinateSystem from, CoordinateSystem to) { return _ident_mat; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::compare_to -// Access: Public -// Description: Sorts matrices lexicographically, componentwise. -// Returns a number less than 0 if this matrix sorts -// before the other one, greater than zero if it sorts -// after, 0 if they are equivalent (within the indicated -// tolerance). -//////////////////////////////////////////////////////////////////// +/** + * Sorts matrices lexicographically, componentwise. Returns a number less + * than 0 if this matrix sorts before the other one, greater than zero if it + * sorts after, 0 if they are equivalent (within the indicated tolerance). + */ int FLOATNAME(LMatrix4):: compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { TAU_PROFILE("int LMatrix4::compare_to(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); - // We compare values in reverse order, since the last row of the - // matrix is most likely to be different between different matrices. + // We compare values in reverse order, since the last row of the matrix is + // most likely to be different between different matrices. for (int r = 3; r >= 0; --r) { for (int c = 0; c < 4; ++c) { if (!IS_THRESHOLD_COMPEQ(_m(r, c), other._m(r, c), threshold)) { @@ -152,13 +145,10 @@ compare_to(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_rotate_mat -// Access: Public -// Description: Sets mat to a matrix that rotates by the given angle -// in degrees counterclockwise about the indicated -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Sets mat to a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. + */ void FLOATNAME(LMatrix4):: set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -169,8 +159,8 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, } if (IS_LEFT_HANDED_COORDSYSTEM(cs)) { - // In a left-handed coordinate system, counterclockwise is the - // other direction. + // In a left-handed coordinate system, counterclockwise is the other + // direction. angle = -angle; } @@ -223,13 +213,11 @@ set_rotate_mat(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, _m(3, 3) = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix::set_rotate_mat_normaxis -// Access: Public -// Description: Fills mat with a matrix that rotates by the given -// angle in degrees counterclockwise about the indicated -// vector. Assumes axis has been prenormalized. -//////////////////////////////////////////////////////////////////// +/** + * Fills mat with a matrix that rotates by the given angle in degrees + * counterclockwise about the indicated vector. Assumes axis has been + * prenormalized. + */ void FLOATNAME(LMatrix4):: set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, CoordinateSystem cs) { @@ -239,8 +227,8 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, } if (IS_LEFT_HANDED_COORDSYSTEM(cs)) { - // In a left-handed coordinate system, counterclockwise is the - // other direction. + // In a left-handed coordinate system, counterclockwise is the other + // direction. angle = -angle; } @@ -284,14 +272,11 @@ set_rotate_mat_normaxis(FLOATTYPE angle, const FLOATNAME(LVecBase3) &axis, _m(3, 3) = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::almost_equal -// Access: Public -// Description: Returns true if two matrices are memberwise equal -// within a specified tolerance. This is faster than -// the equivalence operator as this doesn't have to -// guarantee that it is transitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two matrices are memberwise equal within a specified + * tolerance. This is faster than the equivalence operator as this doesn't + * have to guarantee that it is transitive. + */ bool FLOATNAME(LMatrix4):: almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { TAU_PROFILE("bool LMatrix4::almost_equal(const LMatrix4 &, FLOATTYPE)", " ", TAU_USER); @@ -317,11 +302,9 @@ almost_equal(const FLOATNAME(LMatrix4) &other, FLOATTYPE threshold) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix4):: output(ostream &out) const { out << "[ " @@ -347,11 +330,9 @@ output(ostream &out) const { << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix4):: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -381,11 +362,9 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::generate_hash -// Access: Public -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ void FLOATNAME(LMatrix4):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { TAU_PROFILE("void LMatrix4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); @@ -396,11 +375,9 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::decompose_mat -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FLOATNAME(LMatrix4):: decompose_mat(int index[4]) { TAU_PROFILE("bool LMatrix4::decompose_mat(int[4])", " ", TAU_USER); @@ -415,11 +392,10 @@ decompose_mat(int index[4]) { } } - // We throw the value out only if it's smaller than our "small" - // threshold squared. This helps reduce overly-sensitive - // rejections. + // We throw the value out only if it's smaller than our "small" threshold + // squared. This helps reduce overly-sensitive rejections. if (IS_THRESHOLD_ZERO(big, (NEARLY_ZERO(FLOATTYPE) * NEARLY_ZERO(FLOATTYPE)))) { - // if (IS_NEARLY_ZERO(big)) { + // if (IS_NEARLY_ZERO(big)) { return false; } vv[i] = 1.0f / big; @@ -474,11 +450,9 @@ decompose_mat(int index[4]) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::back_sub_mat -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FLOATNAME(LMatrix4):: back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const { TAU_PROFILE("bool LMatrix4::back_sub_mat(int[4], LMatrix4 &, int)", " ", TAU_USER); @@ -510,17 +484,13 @@ back_sub_mat(int index[4], FLOATNAME(LMatrix4) &inv, int row) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::write_datagram_fixed -// Access: Published -// Description: Writes the matrix to the Datagram using add_float32() -// or add_float64(), depending on the type of floats in -// the matrix, regardless of the setting of -// Datagram::set_stdfloat_double(). This is appropriate -// when you want to write a fixed-width value to the -// datagram, especially when you are not writing a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the matrix to the Datagram using add_float32() or add_float64(), + * depending on the type of floats in the matrix, regardless of the setting of + * Datagram::set_stdfloat_double(). This is appropriate when you want to + * write a fixed-width value to the datagram, especially when you are not + * writing a bam file. + */ void FLOATNAME(LMatrix4):: write_datagram_fixed(Datagram &destination) const { for (int i = 0; i < 4; ++i) { @@ -534,12 +504,10 @@ write_datagram_fixed(Datagram &destination) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::read_datagram_fixed -// Access: Published -// Description: Reads the matrix from the Datagram using get_float32() -// or get_float64(). See write_datagram_fixed(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the matrix from the Datagram using get_float32() or get_float64(). + * See write_datagram_fixed(). + */ void FLOATNAME(LMatrix4):: read_datagram_fixed(DatagramIterator &scan) { for (int i = 0; i < 4; ++i) { @@ -553,14 +521,11 @@ read_datagram_fixed(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::write_datagram -// Access: Published -// Description: Writes the matrix to the Datagram using -// add_stdfloat(). This is appropriate when you want to -// write the matrix using the standard width setting, -// especially when you are writing a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the matrix to the Datagram using add_stdfloat(). This is + * appropriate when you want to write the matrix using the standard width + * setting, especially when you are writing a bam file. + */ void FLOATNAME(LMatrix4):: write_datagram(Datagram &destination) const { for (int i = 0; i < 4; ++i) { @@ -570,11 +535,9 @@ write_datagram(Datagram &destination) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::read_datagram -// Access: Published -// Description: Reads the matrix from the Datagram using get_stdfloat(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the matrix from the Datagram using get_stdfloat(). + */ void FLOATNAME(LMatrix4):: read_datagram(DatagramIterator &scan) { for (int i = 0; i < 4; ++i) { @@ -584,11 +547,9 @@ read_datagram(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: LMatrix4::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LMatrix4):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -597,11 +558,9 @@ init_type() { } } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLMatrix4::init_type -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(UnalignedLMatrix4):: init_type() { if (_type_handle == TypeHandle::none()) { diff --git a/panda/src/linmath/lmatrix4_src.h b/panda/src/linmath/lmatrix4_src.h index 61a0d45018..eac09f85e9 100644 --- a/panda/src/linmath/lmatrix4_src.h +++ b/panda/src/linmath/lmatrix4_src.h @@ -1,23 +1,21 @@ -// Filename: lmatrix4_src.h -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix4_src.h + * @author drose + * @date 1999-01-15 + */ class FLOATNAME(UnalignedLMatrix4); -//////////////////////////////////////////////////////////////////// -// Class : LMatrix4 -// Description : This is a 4-by-4 transform matrix. -//////////////////////////////////////////////////////////////////// +/** + * This is a 4-by-4 transform matrix. + */ class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LMatrix4) { public: typedef FLOATTYPE numeric_type; @@ -278,10 +276,9 @@ PUBLISHED: public: // The underlying implementation is via the Eigen library, if available. - // Unlike LMatrix3, we fully align LMatrix4 to 16-byte boundaries, - // to take advantage of SSE2 optimizations when available. - // Sometimes this alignment requirement is inconvenient, so we also - // provide UnalignedLMatrix4, below. + // Unlike LMatrix3, we fully align LMatrix4 to 16-byte boundaries, to take + // advantage of SSE2 optimizations when available. Sometimes this alignment + // requirement is inconvenient, so we also provide UnalignedLMatrix4, below. typedef LINMATH_MATRIX(FLOATTYPE, 4, 4) EMatrix4; EMatrix4 _m; @@ -311,18 +308,14 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : UnalignedLMatrix4 -// Description : This is an "unaligned" LMatrix4. It has no -// functionality other than to store numbers, and it -// will pack them in as tightly as possible, avoiding -// any SSE2 alignment requirements shared by the primary -// LMatrix4 class. -// -// Use it only when you need to pack numbers tightly -// without respect to alignment, and then copy it to a -// proper LMatrix4 to get actual use from it. -//////////////////////////////////////////////////////////////////// +/** + * This is an "unaligned" LMatrix4. It has no functionality other than to + * store numbers, and it will pack them in as tightly as possible, avoiding + * any SSE2 alignment requirements shared by the primary LMatrix4 class. + * + * Use it only when you need to pack numbers tightly without respect to + * alignment, and then copy it to a proper LMatrix4 to get actual use from it. + */ class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLMatrix4) { PUBLISHED: enum { diff --git a/panda/src/linmath/lmatrix_ext.h b/panda/src/linmath/lmatrix_ext.h index e6012fa14f..3638c378bb 100644 --- a/panda/src/linmath/lmatrix_ext.h +++ b/panda/src/linmath/lmatrix_ext.h @@ -1,16 +1,15 @@ -// Filename: lmatrix_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lmatrix_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LMATRIX_EXT_H #define LMATRIX_EXT_H diff --git a/panda/src/linmath/lorientation.cxx b/panda/src/linmath/lorientation.cxx index 5538a1605f..b97fb2cb2f 100644 --- a/panda/src/linmath/lorientation.cxx +++ b/panda/src/linmath/lorientation.cxx @@ -1,16 +1,15 @@ -// Filename: lorientation.cxx -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lorientation.cxx + * @author frang, charles + * @date 2000-06-23 + */ #include "lorientation.h" @@ -19,4 +18,3 @@ #include "dblnames.h" #include "lorientation_src.cxx" - diff --git a/panda/src/linmath/lorientation.h b/panda/src/linmath/lorientation.h index f44b1c0528..045528a2df 100644 --- a/panda/src/linmath/lorientation.h +++ b/panda/src/linmath/lorientation.h @@ -1,16 +1,15 @@ -// Filename: lorientation.h -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lorientation.h + * @author frang, charles + * @date 2000-06-23 + */ #ifndef __LORIENTATION_H__ #define __LORIENTATION_H__ diff --git a/panda/src/linmath/lorientation_src.I b/panda/src/linmath/lorientation_src.I index 4dd6044d90..8cc56aa235 100644 --- a/panda/src/linmath/lorientation_src.I +++ b/panda/src/linmath/lorientation_src.I @@ -1,51 +1,42 @@ -// Filename: lorientation_src.I -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lorientation_src.I + * @author frang, charles + * @date 2000-06-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)() { } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)(const FLOATNAME(LQuaternion)& c) : FLOATNAME(LQuaternion)(c) { } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)(FLOATTYPE r, FLOATTYPE i, FLOATTYPE j, FLOATTYPE k) : FLOATNAME(LQuaternion)(r, i, j, k) { } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Constructor -// Access: Public -// Description: vector + twist -//////////////////////////////////////////////////////////////////// +/** + * vector + twist + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)(const FLOATNAME(LVector3) &point_at, FLOATTYPE twist) { FLOATTYPE radians = deg_2_rad(twist); @@ -58,44 +49,34 @@ FLOATNAME(LOrientation)(const FLOATNAME(LVector3) &point_at, FLOATTYPE twist) { set_k(point_at[2] * sin_to2); } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Constructor -// Access: Public -// Description: matrix3 -//////////////////////////////////////////////////////////////////// +/** + * matrix3 + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)(const FLOATNAME(LMatrix3) &m) { set_from_matrix(m); } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::Constructor -// Access: Public -// Description: matrix4 -//////////////////////////////////////////////////////////////////// +/** + * matrix4 + */ INLINE_LINMATH FLOATNAME(LOrientation):: FLOATNAME(LOrientation)(const FLOATNAME(LMatrix4) &m) { set_from_matrix(m); } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::operator * -// Access: Public -// Description: Orientation * rotation = Orientation -// Applies a rotation to an orientation. -//////////////////////////////////////////////////////////////////// +/** + * Orientation * rotation = Orientation Applies a rotation to an orientation. + */ INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation):: operator * (const FLOATNAME(LRotation) &other) const { return multiply((FLOATNAME(LOrientation) &)other); } -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::operator * -// Access: Public -// Description: Orientation * Orientation -// This is a meaningless operation, and will always -// simply return the rhs. -//////////////////////////////////////////////////////////////////// +/** + * Orientation * Orientation This is a meaningless operation, and will always + * simply return the rhs. + */ INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation):: operator * (const FLOATNAME(LQuaternion) &other) const { nassert_raise("LOrientation * LQuaternion is undefined; use LOrientation * LRotation or LQuaternion * LQuaternion"); diff --git a/panda/src/linmath/lorientation_src.cxx b/panda/src/linmath/lorientation_src.cxx index 26f694d572..9fad918fa0 100644 --- a/panda/src/linmath/lorientation_src.cxx +++ b/panda/src/linmath/lorientation_src.cxx @@ -1,24 +1,21 @@ -// Filename: lorientation_src.cxx -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lorientation_src.cxx + * @author frang, charles + * @date 2000-06-23 + */ TypeHandle FLOATNAME(LOrientation)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LOrientation::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LOrientation):: init_type() { if (_type_handle == TypeHandle::none()) { diff --git a/panda/src/linmath/lorientation_src.h b/panda/src/linmath/lorientation_src.h index 238398f2f1..88921b8552 100644 --- a/panda/src/linmath/lorientation_src.h +++ b/panda/src/linmath/lorientation_src.h @@ -1,23 +1,21 @@ -// Filename: lorientation_src.h -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lorientation_src.h + * @author frang, charles + * @date 2000-06-23 + */ class FLOATNAME(LRotation); -//////////////////////////////////////////////////////////////////// -// Class : LOrientation -// Description : This is a unit quaternion representing an orientation. -//////////////////////////////////////////////////////////////////// +/** + * This is a unit quaternion representing an orientation. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LOrientation) : public FLOATNAME(LQuaternion) { PUBLISHED: INLINE_LINMATH FLOATNAME(LOrientation)(); diff --git a/panda/src/linmath/lpoint2.cxx b/panda/src/linmath/lpoint2.cxx index f28a903549..ee5862714c 100644 --- a/panda/src/linmath/lpoint2.cxx +++ b/panda/src/linmath/lpoint2.cxx @@ -1,16 +1,15 @@ -// Filename: lpoint2.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2.cxx + * @author drose + * @date 2000-03-08 + */ #include "lpoint2.h" diff --git a/panda/src/linmath/lpoint2.h b/panda/src/linmath/lpoint2.h index 9384bc99de..39fc4ed548 100644 --- a/panda/src/linmath/lpoint2.h +++ b/panda/src/linmath/lpoint2.h @@ -1,16 +1,15 @@ -// Filename: lpoint2.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2.h + * @author drose + * @date 2000-03-08 + */ #ifndef LPOINT2_H #define LPOINT2_H diff --git a/panda/src/linmath/lpoint2_ext.h b/panda/src/linmath/lpoint2_ext.h index 58a6e17429..344d506fcf 100644 --- a/panda/src/linmath/lpoint2_ext.h +++ b/panda/src/linmath/lpoint2_ext.h @@ -1,16 +1,15 @@ -// Filename: lpoint2_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LPOINT2_EXT_H #define LPOINT2_EXT_H diff --git a/panda/src/linmath/lpoint2_ext_src.I b/panda/src/linmath/lpoint2_ext_src.I index aa7f88c281..88e146e462 100644 --- a/panda/src/linmath/lpoint2_ext_src.I +++ b/panda/src/linmath/lpoint2_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lpoint2_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -36,11 +33,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -86,11 +81,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. diff --git a/panda/src/linmath/lpoint2_ext_src.h b/panda/src/linmath/lpoint2_ext_src.h index 0a9c790324..78fa18cfa9 100644 --- a/panda/src/linmath/lpoint2_ext_src.h +++ b/panda/src/linmath/lpoint2_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lpoint2_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LPoint2, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LPoint2, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lpoint2_src.I b/panda/src/linmath/lpoint2_src.I index 4c94dab00d..b500f23d9b 100644 --- a/panda/src/linmath/lpoint2_src.I +++ b/panda/src/linmath/lpoint2_src.I @@ -1,182 +1,145 @@ -// Filename: lpoint2_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::Constructor -// Access: Public -// Description: Constructs a new LPoint2 from a LVecBase2 -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LPoint2 from a LVecBase2 + */ INLINE_LINMATH FLOATNAME(LPoint2):: FLOATNAME(LPoint2)(const FLOATNAME(LVecBase2)& copy) : FLOATNAME(LVecBase2)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::Constructor -// Access: Public -// Description: Constructs a new LPoint2 all components set to the -// fill value. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LPoint2 all components set to the fill value. + */ INLINE_LINMATH FLOATNAME(LPoint2):: FLOATNAME(LPoint2)(FLOATTYPE fill_value) : FLOATNAME(LVecBase2)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::Constructor -// Access: Public -// Description: Constructs a new LPoint2 with the given components -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LPoint2 with the given components + */ INLINE_LINMATH FLOATNAME(LPoint2):: FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y) : FLOATNAME(LVecBase2)(x, y) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::zero Named Constructor -// Access: Public -// Description: Returns a zero-length point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length point. + */ INLINE_LINMATH const FLOATNAME(LPoint2) &FLOATNAME(LPoint2):: zero() { return (const FLOATNAME(LPoint2) &)FLOATNAME(LVecBase2)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X point. + */ INLINE_LINMATH const FLOATNAME(LPoint2) &FLOATNAME(LPoint2):: unit_x() { return (const FLOATNAME(LPoint2) &)FLOATNAME(LVecBase2)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y point. + */ INLINE_LINMATH const FLOATNAME(LPoint2) &FLOATNAME(LPoint2):: unit_y() { return (const FLOATNAME(LPoint2) &)FLOATNAME(LVecBase2)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: operator - () const { return FLOATNAME(LVecBase2)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::point + vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LPoint2):: operator + (const FLOATNAME(LVecBase2) &other) const { return FLOATNAME(LVecBase2)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::point + vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: operator + (const FLOATNAME(LVector2) &other) const { return FLOATNAME(LVecBase2)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::point - vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LPoint2):: operator - (const FLOATNAME(LVecBase2) &other) const { return FLOATNAME(LVecBase2)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::point - point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LPoint2):: operator - (const FLOATNAME(LPoint2) &other) const { return FLOATNAME(LVecBase2)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::point - vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: operator - (const FLOATNAME(LVector2) &other) const { return FLOATNAME(LVecBase2)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::operator * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LPoint2)(FLOATNAME(LVecBase2)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::operator / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LPoint2)(FLOATNAME(LVecBase2)::operator / (scalar)); } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: normalized() const { return FLOATNAME(LVecBase2)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint2):: project(const FLOATNAME(LVecBase2) &onto) const { return FLOATNAME(LVecBase2)::project(onto); diff --git a/panda/src/linmath/lpoint2_src.cxx b/panda/src/linmath/lpoint2_src.cxx index f25fe04b0d..ec0359127b 100644 --- a/panda/src/linmath/lpoint2_src.cxx +++ b/panda/src/linmath/lpoint2_src.cxx @@ -1,24 +1,21 @@ -// Filename: lpoint2_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LPoint2)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LPoint2::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LPoint2):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,5 +24,3 @@ init_type() { FLOATNAME(LVecBase2)::get_class_type()); } } - - diff --git a/panda/src/linmath/lpoint2_src.h b/panda/src/linmath/lpoint2_src.h index cdac92e106..090b49d4b9 100644 --- a/panda/src/linmath/lpoint2_src.h +++ b/panda/src/linmath/lpoint2_src.h @@ -1,22 +1,19 @@ -// Filename: lpoint2_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint2_src.h + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Class : LPoint2 -// Description : This is a two-component point in space. -//////////////////////////////////////////////////////////////////// +/** + * This is a two-component point in space. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint2) : public FLOATNAME(LVecBase2) { PUBLISHED: diff --git a/panda/src/linmath/lpoint3.cxx b/panda/src/linmath/lpoint3.cxx index 8caa5a8b0f..2c6da05a49 100644 --- a/panda/src/linmath/lpoint3.cxx +++ b/panda/src/linmath/lpoint3.cxx @@ -1,16 +1,15 @@ -// Filename: lpoint3.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3.cxx + * @author drose + * @date 2000-03-08 + */ #include "lpoint3.h" diff --git a/panda/src/linmath/lpoint3.h b/panda/src/linmath/lpoint3.h index a458777bd8..4059ef416c 100644 --- a/panda/src/linmath/lpoint3.h +++ b/panda/src/linmath/lpoint3.h @@ -1,16 +1,15 @@ -// Filename: lpoint3.h -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3.h + * @author drose + * @date 1999-09-25 + */ #ifndef LPOINT3_H #define LPOINT3_H diff --git a/panda/src/linmath/lpoint3_ext.h b/panda/src/linmath/lpoint3_ext.h index c526c01da6..2c65564f1f 100644 --- a/panda/src/linmath/lpoint3_ext.h +++ b/panda/src/linmath/lpoint3_ext.h @@ -1,16 +1,15 @@ -// Filename: lpoint3_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LPOINT3_EXT_H #define LPOINT3_EXT_H diff --git a/panda/src/linmath/lpoint3_ext_src.I b/panda/src/linmath/lpoint3_ext_src.I index 2e758bfa01..dc0d68240d 100644 --- a/panda/src/linmath/lpoint3_ext_src.I +++ b/panda/src/linmath/lpoint3_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lpoint3_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -37,11 +34,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -87,11 +82,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. diff --git a/panda/src/linmath/lpoint3_ext_src.h b/panda/src/linmath/lpoint3_ext_src.h index 8e8339fc40..f5aa413ec8 100644 --- a/panda/src/linmath/lpoint3_ext_src.h +++ b/panda/src/linmath/lpoint3_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lpoint3_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LPoint3, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LPoint3, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lpoint3_src.I b/panda/src/linmath/lpoint3_src.I index 71eb2f0b4d..de8891a397 100644 --- a/panda/src/linmath/lpoint3_src.I +++ b/panda/src/linmath/lpoint3_src.I @@ -1,273 +1,218 @@ -// Filename: lpoint3_src.I -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_src.I + * @author drose + * @date 1999-09-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3):: FLOATNAME(LPoint3)(const FLOATNAME(LVecBase3) ©) : FLOATNAME(LVecBase3)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3):: FLOATNAME(LPoint3)(FLOATTYPE fill_value) : FLOATNAME(LVecBase3)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3):: FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) : FLOATNAME(LVecBase3)(x, y, z) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3):: FLOATNAME(LPoint3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z) : FLOATNAME(LVecBase3)(copy, z) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::zero Named Constructor -// Access: Public -// Description: Returns a zero-length point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length point. + */ INLINE_LINMATH const FLOATNAME(LPoint3) &FLOATNAME(LPoint3):: zero() { return (const FLOATNAME(LPoint3) &)FLOATNAME(LVecBase3)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X point. + */ INLINE_LINMATH const FLOATNAME(LPoint3) &FLOATNAME(LPoint3):: unit_x() { return (const FLOATNAME(LPoint3) &)FLOATNAME(LVecBase3)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y point. + */ INLINE_LINMATH const FLOATNAME(LPoint3) &FLOATNAME(LPoint3):: unit_y() { return (const FLOATNAME(LPoint3) &)FLOATNAME(LVecBase3)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::unit_z Named Constructor -// Access: Public -// Description: Returns a unit Z point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z point. + */ INLINE_LINMATH const FLOATNAME(LPoint3) &FLOATNAME(LPoint3):: unit_z() { return (const FLOATNAME(LPoint3) &)FLOATNAME(LVecBase3)::unit_z(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::get_xy -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3):: get_xy() const { return FLOATNAME(LPoint2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::get_xz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first and last components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first and last components + * of this vector. + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3):: get_xz() const { return FLOATNAME(LPoint2)(_v(0), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::get_yz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// last two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the last two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint3):: get_yz() const { return FLOATNAME(LPoint2)(_v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: operator - () const { return FLOATNAME(LVecBase3)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::point + vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LPoint3):: operator + (const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::point + vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: operator + (const FLOATNAME(LVector3) &other) const { return FLOATNAME(LVecBase3)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::point - vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LPoint3):: operator - (const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::point - point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LPoint3):: operator - (const FLOATNAME(LPoint3) &other) const { return FLOATNAME(LVecBase3)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::point - vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: operator - (const FLOATNAME(LVector3) &other) const { return FLOATNAME(LVecBase3)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::cross -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: cross(const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::cross(other); } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: normalized() const { return FLOATNAME(LVecBase3)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: project(const FLOATNAME(LVecBase3) &onto) const { return FLOATNAME(LVecBase3)::project(onto); } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::operator * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LPoint3)(FLOATNAME(LVecBase3)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::operator / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LPoint3)(FLOATNAME(LVecBase3)::operator / (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::origin -// Access: Public, Static -// Description: Returns the origin of the indicated coordinate -// system. This is always 0, 0, 0 with all of our -// existing coordinate systems; it's hard to imagine it -// ever being different. -//////////////////////////////////////////////////////////////////// +/** + * Returns the origin of the indicated coordinate system. This is always 0, + * 0, 0 with all of our existing coordinate systems; it's hard to imagine it + * ever being different. + */ INLINE_LINMATH const FLOATNAME(LPoint3) &FLOATNAME(LPoint3):: origin(CoordinateSystem) { return FLOATNAME(LPoint3)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::rfu -// Access: Public, Static -// Description: Returns a point described by right, forward, up -// displacements from the origin, wherever that maps to -// in the given coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns a point described by right, forward, up displacements from the + * origin, wherever that maps to in the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint3):: rfu(FLOATTYPE right_v, FLOATTYPE fwd_v, FLOATTYPE up_v, CoordinateSystem cs) { return origin(cs) + FLOATNAME(LVector3)::rfu(right_v, fwd_v, up_v, cs); } - diff --git a/panda/src/linmath/lpoint3_src.cxx b/panda/src/linmath/lpoint3_src.cxx index 185935aeee..8905e03f7f 100644 --- a/panda/src/linmath/lpoint3_src.cxx +++ b/panda/src/linmath/lpoint3_src.cxx @@ -1,24 +1,21 @@ -// Filename: lpoint3_src.cxx -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_src.cxx + * @author drose + * @date 1999-09-25 + */ TypeHandle FLOATNAME(LPoint3)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LPoint3::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LPoint3):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,4 +24,3 @@ init_type() { FLOATNAME(LVecBase3)::get_class_type()); } } - diff --git a/panda/src/linmath/lpoint3_src.h b/panda/src/linmath/lpoint3_src.h index 37b92266d6..3465fc37d1 100644 --- a/panda/src/linmath/lpoint3_src.h +++ b/panda/src/linmath/lpoint3_src.h @@ -1,27 +1,23 @@ -// Filename: lpoint3_src.h -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint3_src.h + * @author drose + * @date 1999-09-25 + */ -//////////////////////////////////////////////////////////////////// -// Class : LPoint3 -// Description : This is a three-component point in space (as opposed -// to a three-component vector, which represents a -// direction and a distance). Some of the methods are -// slightly different between LPoint3 and LVector3; in -// particular, subtraction of two points yields a -// vector, while addition of a vector and a point yields -// a point. -//////////////////////////////////////////////////////////////////// +/** + * This is a three-component point in space (as opposed to a three-component + * vector, which represents a direction and a distance). Some of the methods + * are slightly different between LPoint3 and LVector3; in particular, + * subtraction of two points yields a vector, while addition of a vector and a + * point yields a point. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint3) : public FLOATNAME(LVecBase3) { PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint3)() DEFAULT_CTOR; diff --git a/panda/src/linmath/lpoint4.cxx b/panda/src/linmath/lpoint4.cxx index 373cf273d3..63f5c60d65 100644 --- a/panda/src/linmath/lpoint4.cxx +++ b/panda/src/linmath/lpoint4.cxx @@ -1,16 +1,15 @@ -// Filename: lpoint4.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4.cxx + * @author drose + * @date 2000-03-08 + */ #include "lpoint4.h" diff --git a/panda/src/linmath/lpoint4.h b/panda/src/linmath/lpoint4.h index f7b69f02ec..7aafa1e476 100644 --- a/panda/src/linmath/lpoint4.h +++ b/panda/src/linmath/lpoint4.h @@ -1,16 +1,15 @@ -// Filename: lpoint4.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4.h + * @author drose + * @date 2000-03-08 + */ #ifndef LPOINT4_H #define LPOINT4_H diff --git a/panda/src/linmath/lpoint4_ext.h b/panda/src/linmath/lpoint4_ext.h index d0aa4b3036..741684672a 100644 --- a/panda/src/linmath/lpoint4_ext.h +++ b/panda/src/linmath/lpoint4_ext.h @@ -1,16 +1,15 @@ -// Filename: lpoint4_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LPOINT4_EXT_H #define LPOINT4_EXT_H diff --git a/panda/src/linmath/lpoint4_ext_src.I b/panda/src/linmath/lpoint4_ext_src.I index 48c40e3dc5..4a17134496 100644 --- a/panda/src/linmath/lpoint4_ext_src.I +++ b/panda/src/linmath/lpoint4_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lpoint4_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -38,11 +35,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -92,11 +87,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase4. diff --git a/panda/src/linmath/lpoint4_ext_src.h b/panda/src/linmath/lpoint4_ext_src.h index 1c5fe49779..88ae845ed4 100644 --- a/panda/src/linmath/lpoint4_ext_src.h +++ b/panda/src/linmath/lpoint4_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lpoint4_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LPoint4, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LPoint4, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lpoint4_src.I b/panda/src/linmath/lpoint4_src.I index d52b2eafa8..07ca475d4b 100644 --- a/panda/src/linmath/lpoint4_src.I +++ b/panda/src/linmath/lpoint4_src.I @@ -1,207 +1,167 @@ -// Filename: lpoint4_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4):: FLOATNAME(LPoint4)(const FLOATNAME(LVecBase4) ©) : FLOATNAME(LVecBase4)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4):: FLOATNAME(LPoint4)(FLOATTYPE fill_value) : FLOATNAME(LVecBase4)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4):: FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) : FLOATNAME(LVecBase4)(x, y, z, w) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4):: FLOATNAME(LPoint4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w) : FLOATNAME(LVecBase4)(copy, w) { } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::zero Named Constructor -// Access: Public -// Description: Returns a zero-length point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length point. + */ INLINE_LINMATH const FLOATNAME(LPoint4) &FLOATNAME(LPoint4):: zero() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X point. + */ INLINE_LINMATH const FLOATNAME(LPoint4) &FLOATNAME(LPoint4):: unit_x() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y point. + */ INLINE_LINMATH const FLOATNAME(LPoint4) &FLOATNAME(LPoint4):: unit_y() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::unit_z Named Constructor -// Access: Public -// Description: Returns a unit Z point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z point. + */ INLINE_LINMATH const FLOATNAME(LPoint4) &FLOATNAME(LPoint4):: unit_z() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::unit_z(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::unit_w Named Constructor -// Access: Public -// Description: Returns a unit W point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit W point. + */ INLINE_LINMATH const FLOATNAME(LPoint4) &FLOATNAME(LPoint4):: unit_w() { return (const FLOATNAME(LPoint4) &)FLOATNAME(LVecBase4)::unit_w(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::get_xyz -// Access: Published -// Description: Returns the x, y and z component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y and z component of this vector + */ INLINE_LINMATH FLOATNAME(LPoint3) FLOATNAME(LPoint4):: get_xyz() const { return FLOATNAME(LPoint3)(_v(0), _v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::get_xy -// Access: Published -// Description: Returns the x and y component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x and y component of this vector + */ INLINE_LINMATH FLOATNAME(LPoint2) FLOATNAME(LPoint4):: get_xy() const { return FLOATNAME(LPoint2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: operator - () const { return FLOATNAME(LVecBase4)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::point + vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LPoint4):: operator + (const FLOATNAME(LVecBase4) &other) const { return FLOATNAME(LVecBase4)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::point + vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: operator + (const FLOATNAME(LVector4) &other) const { return FLOATNAME(LVecBase4)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::point - vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LPoint4):: operator - (const FLOATNAME(LVecBase4) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::point - point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LPoint4):: operator - (const FLOATNAME(LPoint4) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::point - vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: operator - (const FLOATNAME(LVector4) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::operator * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LPoint4)(FLOATNAME(LVecBase4)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::operator / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LPoint4)(FLOATNAME(LVecBase4)::operator / (scalar)); @@ -209,25 +169,19 @@ operator / (FLOATTYPE scalar) const { #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: normalized() const { return FLOATNAME(LVecBase4)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LPoint4) FLOATNAME(LPoint4):: project(const FLOATNAME(LVecBase4) &onto) const { return FLOATNAME(LVecBase4)::project(onto); diff --git a/panda/src/linmath/lpoint4_src.cxx b/panda/src/linmath/lpoint4_src.cxx index 112d5a804a..791acc7a87 100644 --- a/panda/src/linmath/lpoint4_src.cxx +++ b/panda/src/linmath/lpoint4_src.cxx @@ -1,24 +1,21 @@ -// Filename: lpoint4_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LPoint4)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LPoint4::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LPoint4):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,4 +24,3 @@ init_type() { FLOATNAME(LVecBase4)::get_class_type()); } } - diff --git a/panda/src/linmath/lpoint4_src.h b/panda/src/linmath/lpoint4_src.h index d0702b2202..103c018738 100644 --- a/panda/src/linmath/lpoint4_src.h +++ b/panda/src/linmath/lpoint4_src.h @@ -1,21 +1,19 @@ -// Filename: lpoint4_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lpoint4_src.h + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Class : LPoint4 -// Description : This is a four-component point in space. -//////////////////////////////////////////////////////////////////// +/** + * This is a four-component point in space. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LPoint4) : public FLOATNAME(LVecBase4) { PUBLISHED: INLINE_LINMATH FLOATNAME(LPoint4)() DEFAULT_CTOR; diff --git a/panda/src/linmath/lquaternion.cxx b/panda/src/linmath/lquaternion.cxx index d216cdd148..e9be29c3ab 100644 --- a/panda/src/linmath/lquaternion.cxx +++ b/panda/src/linmath/lquaternion.cxx @@ -1,16 +1,15 @@ -// Filename: lquaternion.cxx -// Created by: frang (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lquaternion.cxx + * @author frang + * @date 2000-06-06 + */ #include "lquaternion.h" @@ -21,4 +20,3 @@ #include "dblnames.h" #include "lquaternion_src.cxx" - diff --git a/panda/src/linmath/lquaternion.h b/panda/src/linmath/lquaternion.h index fcb123c257..227210bb59 100644 --- a/panda/src/linmath/lquaternion.h +++ b/panda/src/linmath/lquaternion.h @@ -1,16 +1,15 @@ -// Filename: lquaternion.h -// Created by: frang (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lquaternion.h + * @author frang + * @date 2000-06-06 + */ #ifndef LQUATERNION_H #define LQUATERNION_H diff --git a/panda/src/linmath/lquaternion_src.I b/panda/src/linmath/lquaternion_src.I index 09bb734248..05f1d46bec 100644 --- a/panda/src/linmath/lquaternion_src.I +++ b/panda/src/linmath/lquaternion_src.I @@ -1,62 +1,51 @@ -// Filename: lquaternion_src.I -// Created by: frang (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lquaternion_src.I + * @author frang + * @date 2000-06-06 + */ -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion):: FLOATNAME(LQuaternion)() { } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion):: FLOATNAME(LQuaternion)(const FLOATNAME(LVecBase4) ©) : FLOATNAME(LVecBase4)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion):: FLOATNAME(LQuaternion)(FLOATTYPE r, const FLOATNAME(LVecBase3) ©) { set(r, copy[0], copy[1], copy[2]); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion):: FLOATNAME(LQuaternion)(FLOATTYPE r, FLOATTYPE i, FLOATTYPE j, FLOATTYPE k) { set(r, i, j, k); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::xform -// Access: Published -// Description: Transforms a 3-d vector by the indicated rotation -//////////////////////////////////////////////////////////////////// +/** + * Transforms a 3-d vector by the indicated rotation + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LQuaternion):: xform(const FLOATNAME(LVecBase3) &v) const { FLOATNAME(LQuaternion) v_quat(0.0f, v[0], v[1], v[2]); @@ -68,11 +57,9 @@ xform(const FLOATNAME(LVecBase3) &v) const { return FLOATNAME(LVecBase3)(v_quat[1], v_quat[2], v_quat[3]); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::xform -// Access: Published -// Description: Transforms a 4-d vector by the indicated rotation -//////////////////////////////////////////////////////////////////// +/** + * Transforms a 4-d vector by the indicated rotation + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LQuaternion):: xform(const FLOATNAME(LVecBase4) &v) const { FLOATNAME(LQuaternion) v_quat(v[0], v[1], v[2], v[3]); @@ -84,11 +71,9 @@ xform(const FLOATNAME(LVecBase4) &v) const { return FLOATNAME(LVecBase4)(v_quat); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::multiply -// Access: Published -// Description: actual multiply call (non virtual) -//////////////////////////////////////////////////////////////////// +/** + * actual multiply call (non virtual) + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: multiply(const FLOATNAME(LQuaternion) &rhs) const { FLOATTYPE r = (rhs._v(0) * _v(0)) - (rhs._v(1) * _v(1)) - (rhs._v(2) * _v(2)) - (rhs._v(3) * _v(3)); @@ -99,106 +84,84 @@ multiply(const FLOATNAME(LQuaternion) &rhs) const { return FLOATNAME(LQuaternion)(r, i, j, k); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator - () const { return FLOATNAME(LVecBase4)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::quaternion + quaternion -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator + (const FLOATNAME(LQuaternion) &other) const { return FLOATNAME(LVecBase4)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::quaternion - quaternion -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator - (const FLOATNAME(LQuaternion) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::angle_rad -// Access: Published -// Description: Returns the angle between the orientation represented -// by this quaternion and the other one, expressed in -// radians. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle between the orientation represented by this quaternion + * and the other one, expressed in radians. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: angle_rad(const FLOATNAME(LQuaternion) &other) const { return get_forward().angle_rad(other.get_forward()); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::angle_deg -// Access: Published -// Description: Returns the angle between the orientation represented -// by this quaternion and the other one, expressed in -// degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle between the orientation represented by this quaternion + * and the other one, expressed in degrees. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: angle_deg(const FLOATNAME(LQuaternion) &other) const { return rad_2_deg(angle_rad(other)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::quaternion * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LVecBase4)::operator * (scalar); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::quaternion / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LVecBase4)::operator / (scalar); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Multiply Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: operator *(const FLOATNAME(LQuaternion)& c) const { return multiply(c); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Multiply Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LQuaternion)& FLOATNAME(LQuaternion):: operator *=(const FLOATNAME(LQuaternion)& c) { (*this) = operator*(c); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Multiply Operator -// Access: Public -// Description: Quat * Matrix = matrix -//////////////////////////////////////////////////////////////////// +/** + * Quat * Matrix = matrix + */ INLINE_LINMATH FLOATNAME(LMatrix3) FLOATNAME(LQuaternion):: operator *(const FLOATNAME(LMatrix3) &m) { FLOATNAME(LMatrix3) result; @@ -206,11 +169,9 @@ operator *(const FLOATNAME(LMatrix3) &m) { return result * m; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::Multiply Operator -// Access: Public -// Description: Quat * Matrix = matrix -//////////////////////////////////////////////////////////////////// +/** + * Quat * Matrix = matrix + */ INLINE_LINMATH FLOATNAME(LMatrix4) FLOATNAME(LQuaternion):: operator *(const FLOATNAME(LMatrix4) &m) { FLOATNAME(LMatrix3) m_upper_3 = m.get_upper_3(); @@ -225,23 +186,19 @@ operator *(const FLOATNAME(LMatrix4) &m) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::almost_equal -// Access: Public -// Description: Returns true if two quaternions are memberwise equal -// within a default tolerance based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two quaternions are memberwise equal within a default + * tolerance based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: almost_equal(const FLOATNAME(LQuaternion) &other) const { return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::almost_equal -// Access: Public -// Description: Returns true if two quaternions are memberwise equal -// within a specified tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two quaternions are memberwise equal within a specified + * tolerance. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: almost_equal(const FLOATNAME(LQuaternion) &other, FLOATTYPE threshold) const { @@ -251,35 +208,28 @@ almost_equal(const FLOATNAME(LQuaternion) &other, IS_THRESHOLD_EQUAL(_v(3), other._v(3), threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::is_same_direction -// Access: Public -// Description: Returns true if two quaternions represent the same -// rotation within a default tolerance based on the -// numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two quaternions represent the same rotation within a + * default tolerance based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: is_same_direction(const FLOATNAME(LQuaternion) &other) const { return almost_same_direction(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::almost_same_direction -// Access: Public -// Description: Returns true if two quaternions represent the same -// rotation within a specified tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two quaternions represent the same rotation within a + * specified tolerance. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: almost_same_direction(const FLOATNAME(LQuaternion) &other, FLOATTYPE threshold) const { return ((*this) * invert(other)).is_almost_identity(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: output(ostream& os) const { os << MAYBE_ZERO(_v(0)) << " + " @@ -288,36 +238,29 @@ output(ostream& os) const { << MAYBE_ZERO(_v(3)) << "k"; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_from_matrix -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_from_matrix(const FLOATNAME(LMatrix4) &m) { set_from_matrix(m.get_upper_3()); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_axis -// Access: Public -// Description: This, along with get_angle(), returns the rotation -// represented by the quaternion as an angle about an -// arbitrary axis. This returns the axis; it is not -// normalized. -//////////////////////////////////////////////////////////////////// +/** + * This, along with get_angle(), returns the rotation represented by the + * quaternion as an angle about an arbitrary axis. This returns the axis; it + * is not normalized. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion):: get_axis() const { return FLOATNAME(LVector3)(_v(1), _v(2), _v(3)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_axis_normalized -// Access: Public -// Description: This, along with get_angle(), returns the rotation -// represented by the quaternion as an angle about an -// arbitrary axis. This returns the normalized axis. -//////////////////////////////////////////////////////////////////// +/** + * This, along with get_angle(), returns the rotation represented by the + * quaternion as an angle about an arbitrary axis. This returns the + * normalized axis. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion):: get_axis_normalized() const { FLOATNAME(LVector3) axis = get_axis(); @@ -325,46 +268,35 @@ get_axis_normalized() const { return axis; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_angle_rad -// Access: Public -// Description: This, along with get_axis(), returns the rotation -// represented by the quaternion as an angle about an -// arbitrary axis. This returns the angle, in radians -// counterclockwise about the axis. -// -// It is necessary to ensure the quaternion has been -// normalized (for instance, with a call to normalize()) -// before calling this method. -//////////////////////////////////////////////////////////////////// +/** + * This, along with get_axis(), returns the rotation represented by the + * quaternion as an angle about an arbitrary axis. This returns the angle, in + * radians counterclockwise about the axis. + * + * It is necessary to ensure the quaternion has been normalized (for instance, + * with a call to normalize()) before calling this method. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_angle_rad() const { return acos(_v(0)) * FLOATCONST(2.0); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_angle -// Access: Public -// Description: This, along with get_axis(), returns the rotation -// represented by the quaternion as an angle about an -// arbitrary axis. This returns the angle, in degrees -// counterclockwise about the axis. -// -// It is necessary to ensure the quaternion has been -// normalized (for instance, with a call to normalize()) -// before calling this method. -//////////////////////////////////////////////////////////////////// +/** + * This, along with get_axis(), returns the rotation represented by the + * quaternion as an angle about an arbitrary axis. This returns the angle, in + * degrees counterclockwise about the axis. + * + * It is necessary to ensure the quaternion has been normalized (for instance, + * with a call to normalize()) before calling this method. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_angle() const { return rad_2_deg(get_angle_rad()); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_from_axis_angle_rad -// Access: Public -// Description: angle_rad is the angle about the axis in radians. -// axis must be normalized. -//////////////////////////////////////////////////////////////////// +/** + * angle_rad is the angle about the axis in radians. axis must be normalized. + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_from_axis_angle_rad(FLOATTYPE angle_rad, const FLOATNAME(LVector3) &axis) { nassertv(IS_THRESHOLD_EQUAL(axis.length(), 1.0f, 0.001f)); @@ -375,136 +307,109 @@ set_from_axis_angle_rad(FLOATTYPE angle_rad, const FLOATNAME(LVector3) &axis) { _v(3) = axis[2] * sinHalfAngle; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_from_axis_angle_deg -// Access: Public -// Description: angle_deg is the angle about the axis in degrees. -// axis must be normalized. -//////////////////////////////////////////////////////////////////// +/** + * angle_deg is the angle about the axis in degrees. axis must be normalized. + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_from_axis_angle(FLOATTYPE angle_deg, const FLOATNAME(LVector3) &axis) { set_from_axis_angle_rad(deg_2_rad(angle_deg), axis); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_up -// Access: Public -// Description: Returns the orientation represented by this -// quaternion, expressed as an up vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the orientation represented by this quaternion, expressed as an up + * vector. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion):: get_up(CoordinateSystem cs) const { return xform(FLOATNAME(LVector3)::up(cs)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_right -// Access: Public -// Description: Returns the orientation represented by this -// quaternion, expressed as a right vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the orientation represented by this quaternion, expressed as a + * right vector. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion):: get_right(CoordinateSystem cs) const { return xform(FLOATNAME(LVector3)::right(cs)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_forward -// Access: Public -// Description: Returns the orientation represented by this -// quaternion, expressed as a forward vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the orientation represented by this quaternion, expressed as a + * forward vector. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LQuaternion):: get_forward(CoordinateSystem cs) const { return xform(FLOATNAME(LVector3)::forward(cs)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_r -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_r() const { return _v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_i -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_i() const { return _v(1); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_j -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_j() const { return _v(2); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_k -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LQuaternion):: get_k() const { return _v(3); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_r -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_r(FLOATTYPE r) { _v(0) = r; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_i -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_i(FLOATTYPE i) { _v(1) = i; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_j -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_j(FLOATTYPE j) { _v(2) = j; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_k -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LQuaternion):: set_k(FLOATTYPE k) { _v(3) = k; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::normalize -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: normalize() { FLOATTYPE length_squared = (*this).dot(*this); @@ -517,45 +422,35 @@ normalize() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::conjugate -// Access: Published -// Description: Returns the complex conjugate of this quat. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complex conjugate of this quat. + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: conjugate() const { return FLOATNAME(LQuaternion)(_v(0), -_v(1), -_v(2), -_v(3)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::conjugate_from -// Access: Published -// Description: Computes the conjugate of the other quat, and stores -// the result in this quat. This is a fully general -// operation and makes no assumptions about the type of -// transform represented by the quat. -// -// The other quat must be a different object than this -// quat. However, if you need to get a conjugate of a -// quat in place, see conjugate_in_place. -// -// The return value is true if the quat was -// successfully inverted, false if there was a -// singularity. -//////////////////////////////////////////////////////////////////// +/** + * Computes the conjugate of the other quat, and stores the result in this + * quat. This is a fully general operation and makes no assumptions about the + * type of transform represented by the quat. + * + * The other quat must be a different object than this quat. However, if you + * need to get a conjugate of a quat in place, see conjugate_in_place. + * + * The return value is true if the quat was successfully inverted, false if + * there was a singularity. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: conjugate_from(const FLOATNAME(LQuaternion) &other) { set(other._v(0), -other._v(1), -other._v(2), -other._v(3)); return true; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::conjugate_in_place -// Access: Published -// Description: Sets this to be the conjugate of the current quat. -// Returns true if the successful, false if the quat -// was singular. -//////////////////////////////////////////////////////////////////// +/** + * Sets this to be the conjugate of the current quat. Returns true if the + * successful, false if the quat was singular. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: conjugate_in_place() { // _v(0) = _v(0); @@ -565,78 +460,63 @@ conjugate_in_place() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::invert_from -// Access: Public -// Description: Computes the inverse of the other quat, and stores -// the result in this quat. This is a fully general -// operation and makes no assumptions about the type of -// transform represented by the quat. -// -// The other quat must be a different object than this -// quat. However, if you need to invert a quat in -// place, see invert_in_place. -// -// The return value is true if the quat was -// successfully inverted, false if there was a -// singularity. -//////////////////////////////////////////////////////////////////// +/** + * Computes the inverse of the other quat, and stores the result in this quat. + * This is a fully general operation and makes no assumptions about the type + * of transform represented by the quat. + * + * The other quat must be a different object than this quat. However, if you + * need to invert a quat in place, see invert_in_place. + * + * The return value is true if the quat was successfully inverted, false if + * there was a singularity. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: invert_from(const FLOATNAME(LQuaternion) &other) { set(-other._v(0), other._v(1), other._v(2), other._v(3)); return true; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::invert_in_place -// Access: Public -// Description: Inverts the current quat. Returns true if the -// inverse is successful, false if the quat was -// singular. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the current quat. Returns true if the inverse is successful, false + * if the quat was singular. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: invert_in_place() { _v(0) = -_v(0); return true; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::is_identity -// Access: Public -// Description: Returns true if this quaternion represents the -// identity transformation: no rotation. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this quaternion represents the identity transformation: no + * rotation. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: is_identity() const { return is_almost_identity(NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::is_almost_identity -// Access: Public -// Description: Returns true if this quaternion represents the -// identity transformation within a given tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this quaternion represents the identity transformation + * within a given tolerance. + */ INLINE_LINMATH bool FLOATNAME(LQuaternion):: is_almost_identity(FLOATTYPE tolerance) const { return (IS_THRESHOLD_EQUAL(_v(0), -1.0f, tolerance) || IS_THRESHOLD_EQUAL(_v(0), 1.0f, tolerance)); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::ident_quat -// Access: Public, Static -// Description: Returns an identity quaternion. -//////////////////////////////////////////////////////////////////// +/** + * Returns an identity quaternion. + */ INLINE_LINMATH const FLOATNAME(LQuaternion) &FLOATNAME(LQuaternion):: ident_quat() { return _ident_quat; } -//////////////////////////////////////////////////////////////////// -// Function: invert -// Description: Inverts the given quat and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Inverts the given quat and returns it. + */ INLINE_LINMATH FLOATNAME(LQuaternion) invert(const FLOATNAME(LQuaternion) &a) { FLOATNAME(LQuaternion) result; @@ -650,11 +530,9 @@ invert(const FLOATNAME(LQuaternion) &a) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: operator *(Matrix3, Quat) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix3) operator *(const FLOATNAME(LMatrix3) &m, const FLOATNAME(LQuaternion) &q) { FLOATNAME(LMatrix3) q_matrix; @@ -663,11 +541,9 @@ INLINE_LINMATH FLOATNAME(LMatrix3) operator *(const FLOATNAME(LMatrix3) &m, return m * q_matrix; } -//////////////////////////////////////////////////////////////////// -// Function: operator *(Matrix4, Quat) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LMatrix4) operator *(const FLOATNAME(LMatrix4) &m, const FLOATNAME(LQuaternion) &q) { FLOATNAME(LMatrix4) q_matrix; diff --git a/panda/src/linmath/lquaternion_src.cxx b/panda/src/linmath/lquaternion_src.cxx index 22ccabd65f..7ffb7766a3 100644 --- a/panda/src/linmath/lquaternion_src.cxx +++ b/panda/src/linmath/lquaternion_src.cxx @@ -1,16 +1,13 @@ -// Filename: lquaternion_src.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lquaternion_src.cxx + */ #include "config_linmath.h" #include "lmatrix.h" @@ -21,21 +18,17 @@ TypeHandle FLOATNAME(LQuaternion)::_type_handle; const FLOATNAME(LQuaternion) FLOATNAME(LQuaternion)::_ident_quat = FLOATNAME(LQuaternion)(1.0f, 0.0f, 0.0f, 0.0f); -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::pure_imaginary_quat -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FLOATNAME(LQuaternion) FLOATNAME(LQuaternion):: pure_imaginary(const FLOATNAME(LVector3) &v) { return FLOATNAME(LQuaternion)(0, v[0], v[1], v[2]); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::extract_to_matrix (LMatrix3) -// Access: Public -// Description: Based on the quat lib from VRPN. -//////////////////////////////////////////////////////////////////// +/** + * Based on the quat lib from VRPN. + */ void FLOATNAME(LQuaternion):: extract_to_matrix(FLOATNAME(LMatrix3) &m) const { FLOATTYPE N = this->dot(*this); @@ -52,11 +45,9 @@ extract_to_matrix(FLOATNAME(LMatrix3) &m) const { (xz + wy), (yz - wx), (1.0f - (xx + yy))); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::extract_to_matrix (LMatrix4) -// Access: Public -// Description: Based on the quat lib from VRPN. -//////////////////////////////////////////////////////////////////// +/** + * Based on the quat lib from VRPN. + */ void FLOATNAME(LQuaternion):: extract_to_matrix(FLOATNAME(LMatrix4) &m) const { FLOATTYPE N = this->dot(*this); @@ -74,13 +65,10 @@ extract_to_matrix(FLOATNAME(LMatrix4) &m) const { 0.0f, 0.0f, 0.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_hpr -// Access: Public -// Description: Sets the quaternion as the unit quaternion that -// is equivalent to these Euler angles. -// (from Real-time Rendering, p.49) -//////////////////////////////////////////////////////////////////// +/** + * Sets the quaternion as the unit quaternion that is equivalent to these + * Euler angles. (from Real-time Rendering, p.49) + */ void FLOATNAME(LQuaternion):: set_hpr(const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { FLOATNAME(LQuaternion) quat_h, quat_p, quat_r; @@ -124,12 +112,9 @@ set_hpr(const FLOATNAME(LVecBase3) &hpr, CoordinateSystem cs) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::get_hpr -// Access: Public -// Description: Extracts the equivalent Euler angles from the unit -// quaternion. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the equivalent Euler angles from the unit quaternion. + */ FLOATNAME(LVecBase3) FLOATNAME(LQuaternion):: get_hpr(CoordinateSystem cs) const { if (cs == CS_default) { @@ -170,7 +155,8 @@ get_hpr(CoordinateSystem cs) const { cp = -c2; } } else { - // this should work all the time, but the above saves some trig operations + // this should work all the time, but the above saves some trig + // operations FLOATTYPE roll = catan2(-c1, c2); csincos(roll, &sr, &cr); hpr[2] = rad_2_deg(roll); @@ -183,9 +169,9 @@ get_hpr(CoordinateSystem cs) const { hpr[1] = rad_2_deg(catan2(sp, cp)); } else { - // The code above implements quat-to-hpr for CS_zup_right only. - // For other coordinate systems, someone is welcome to extend the - // implementation; I'm going to choose the lazy path till then. + // The code above implements quat-to-hpr for CS_zup_right only. For other + // coordinate systems, someone is welcome to extend the implementation; + // I'm going to choose the lazy path till then. FLOATNAME(LMatrix3) mat; extract_to_matrix(mat); FLOATNAME(LVecBase3) scale; @@ -212,15 +198,11 @@ get_hpr(CoordinateSystem cs) const { return hpr; } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::set_from_matrix -// Access: Public -// Description: Sets the quaternion according to the rotation -// represented by the matrix. Originally we tried an -// algorithm presented by Do-While Jones, but that -// turned out to be broken. This is based on the quat -// lib from UNC. -//////////////////////////////////////////////////////////////////// +/** + * Sets the quaternion according to the rotation represented by the matrix. + * Originally we tried an algorithm presented by Do-While Jones, but that + * turned out to be broken. This is based on the quat lib from UNC. + */ void FLOATNAME(LQuaternion):: set_from_matrix(const FLOATNAME(LMatrix3) &m) { FLOATTYPE m00, m01, m02, m10, m11, m12, m20, m21, m22; @@ -247,18 +229,17 @@ set_from_matrix(const FLOATNAME(LMatrix3) &m) { _v(3) = (m01 - m10) * S; } else { - // The harder case. First, figure out which column to take as - // root. This will be the column with the largest value. + // The harder case. First, figure out which column to take as root. This + // will be the column with the largest value. - // It is tempting to try to compare the absolute values of the - // diagonal values in the code below, instead of their normal, - // signed values. Don't do it. We are actually maximizing the - // value of S, which must always be positive, and is therefore - // based on the diagonal whose actual value--not absolute - // value--is greater than those of the other two. + // It is tempting to try to compare the absolute values of the diagonal + // values in the code below, instead of their normal, signed values. + // Don't do it. We are actually maximizing the value of S, which must + // always be positive, and is therefore based on the diagonal whose actual + // value--not absolute value--is greater than those of the other two. - // We already know that m00 + m11 + m22 <= 0 (because we are here - // in the harder case). + // We already know that m00 + m11 + m22 <= 0 (because we are here in the + // harder case). if (m00 > m11 && m00 > m22) { // m00 is larger than m11 and m22. @@ -296,11 +277,9 @@ set_from_matrix(const FLOATNAME(LMatrix3) &m) { } } -//////////////////////////////////////////////////////////////////// -// Function: LQuaternion::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LQuaternion):: init_type() { if (_type_handle == TypeHandle::none()) { diff --git a/panda/src/linmath/lquaternion_src.h b/panda/src/linmath/lquaternion_src.h index 22b3f0bffe..429b86a0cc 100644 --- a/panda/src/linmath/lquaternion_src.h +++ b/panda/src/linmath/lquaternion_src.h @@ -1,21 +1,19 @@ -// Filename: lquaternion_src.h -// Created by: frang (06Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lquaternion_src.h + * @author frang + * @date 2000-06-06 + */ -//////////////////////////////////////////////////////////////////// -// Class : FLOATNAME(LQuaternion) -// Description : This is the base quaternion class -//////////////////////////////////////////////////////////////////// +/** + * This is the base quaternion class + */ class EXPCL_PANDA_LINMATH FLOATNAME(LQuaternion) : public FLOATNAME(LVecBase4) { PUBLISHED: INLINE_LINMATH FLOATNAME(LQuaternion)(); diff --git a/panda/src/linmath/lrotation.cxx b/panda/src/linmath/lrotation.cxx index 200e90a45f..111acdbe9c 100644 --- a/panda/src/linmath/lrotation.cxx +++ b/panda/src/linmath/lrotation.cxx @@ -1,16 +1,15 @@ -// Filename: lrotation.cxx -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lrotation.cxx + * @author frang, charles + * @date 2000-06-23 + */ #include "lrotation.h" @@ -19,4 +18,3 @@ #include "dblnames.h" #include "lrotation_src.cxx" - diff --git a/panda/src/linmath/lrotation.h b/panda/src/linmath/lrotation.h index 32b6bd8293..f3fea5a87c 100644 --- a/panda/src/linmath/lrotation.h +++ b/panda/src/linmath/lrotation.h @@ -1,16 +1,15 @@ -// Filename: lrotation.h -// Created by: frang, charles (07Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lrotation.h + * @author frang, charles + * @date 2000-06-07 + */ #ifndef __LROTATION_H__ #define __LROTATION_H__ diff --git a/panda/src/linmath/lrotation_src.I b/panda/src/linmath/lrotation_src.I index 2ff93ccda5..3c9d5a076e 100644 --- a/panda/src/linmath/lrotation_src.I +++ b/panda/src/linmath/lrotation_src.I @@ -1,81 +1,66 @@ -// Filename: lrotation_src.I -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lrotation_src.I + * @author frang, charles + * @date 2000-06-23 + */ -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)() { } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(const FLOATNAME(LQuaternion) &c) : FLOATNAME(LQuaternion)(c) { } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(const FLOATNAME(LVecBase4) ©) : FLOATNAME(LQuaternion)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(FLOATTYPE r, FLOATTYPE i, FLOATTYPE j, FLOATTYPE k) : FLOATNAME(LQuaternion)(r, i, j, k) { } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Constructor -// Access: Public -// Description: lmatrix3 -//////////////////////////////////////////////////////////////////// +/** + * lmatrix3 + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(const FLOATNAME(LMatrix3) &m) { set_from_matrix(m); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Constructor -// Access: Public -// Description: lmatrix4 -//////////////////////////////////////////////////////////////////// +/** + * lmatrix4 + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(const FLOATNAME(LMatrix4) &m) { set_from_matrix(m); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Constructor -// Access: Public -// Description: axis + angle (in degrees) -//////////////////////////////////////////////////////////////////// +/** + * axis + angle (in degrees) + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(const FLOATNAME(LVector3) &axis, FLOATTYPE angle) { FLOATTYPE radians = deg_2_rad(angle); @@ -88,57 +73,44 @@ FLOATNAME(LRotation)(const FLOATNAME(LVector3) &axis, FLOATTYPE angle) { set_k(axis[2] * sin_to2); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::Constructor -// Access: Public -// Description: Sets the rotation from the given Euler angles. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation from the given Euler angles. + */ INLINE_LINMATH FLOATNAME(LRotation):: FLOATNAME(LRotation)(FLOATTYPE h, FLOATTYPE p, FLOATTYPE r) { set_hpr(FLOATNAME(LVecBase3)(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::rotation * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LRotation)(FLOATNAME(LVecBase4)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::rotation / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LRotation)(FLOATNAME(LVecBase4)::operator / (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::operator * -// Access: Public -// Description: Rotation * Rotation = Rotation -//////////////////////////////////////////////////////////////////// +/** + * Rotation * Rotation = Rotation + */ INLINE_LINMATH FLOATNAME(LRotation) FLOATNAME(LRotation):: operator * (const FLOATNAME(LRotation) &other) const { return multiply(other); } -//////////////////////////////////////////////////////////////////// -// Function: LRotation::operator * -// Access: Public -// Description: Rotation * Orientation = Orientation -// This is another meaningless operation, attempting -// to apply an orientation to a rotation. -//////////////////////////////////////////////////////////////////// +/** + * Rotation * Orientation = Orientation This is another meaningless operation, + * attempting to apply an orientation to a rotation. + */ INLINE_LINMATH FLOATNAME(LQuaternion) FLOATNAME(LRotation):: operator * (const FLOATNAME(LQuaternion) &other) const { nassert_raise("LRotation * LQuaternion is undefined; use LRotation * LRotation or LQuaternion * LQuaternion"); return multiply(other); } - - diff --git a/panda/src/linmath/lrotation_src.cxx b/panda/src/linmath/lrotation_src.cxx index 31d41cdbe0..52dbcf9a81 100644 --- a/panda/src/linmath/lrotation_src.cxx +++ b/panda/src/linmath/lrotation_src.cxx @@ -1,24 +1,21 @@ -// Filename: lrotation_src.cxx -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lrotation_src.cxx + * @author frang, charles + * @date 2000-06-23 + */ TypeHandle FLOATNAME(LRotation)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LRotation::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LRotation):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -28,4 +25,3 @@ init_type() { FLOATNAME(LQuaternion)::get_class_type()); } } - diff --git a/panda/src/linmath/lrotation_src.h b/panda/src/linmath/lrotation_src.h index 3c21cc767e..4c844b98a1 100644 --- a/panda/src/linmath/lrotation_src.h +++ b/panda/src/linmath/lrotation_src.h @@ -1,21 +1,19 @@ -// Filename: lrotation_src.h -// Created by: frang, charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lrotation_src.h + * @author frang, charles + * @date 2000-06-23 + */ -//////////////////////////////////////////////////////////////////// -// Class : LRotation -// Description : This is a unit quaternion representing a rotation. -//////////////////////////////////////////////////////////////////// +/** + * This is a unit quaternion representing a rotation. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LRotation) : public FLOATNAME(LQuaternion) { PUBLISHED: INLINE_LINMATH FLOATNAME(LRotation)(); diff --git a/panda/src/linmath/lsimpleMatrix.I b/panda/src/linmath/lsimpleMatrix.I index 82642693e3..7ce8b4ed69 100644 --- a/panda/src/linmath/lsimpleMatrix.I +++ b/panda/src/linmath/lsimpleMatrix.I @@ -1,89 +1,73 @@ -// Filename: lsimpleMatrix.I -// Created by: drose (15Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lsimpleMatrix.I + * @author drose + * @date 2011-12-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE LSimpleMatrix:: LSimpleMatrix() { // No default initialization. } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE LSimpleMatrix:: LSimpleMatrix(const LSimpleMatrix ©) { memcpy(_array, copy._array, sizeof(_array)); } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void LSimpleMatrix:: operator = (const LSimpleMatrix ©) { memcpy(_array, copy._array, sizeof(_array)); } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::operator () -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const FloatType &LSimpleMatrix:: operator () (int row, int col) const { return _array[row][col]; } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::operator () -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE FloatType &LSimpleMatrix:: operator () (int row, int col) { return _array[row][col]; } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::operator () -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE const FloatType &LSimpleMatrix:: operator () (int col) const { return _array[0][col]; } -//////////////////////////////////////////////////////////////////// -// Function: LSimpleMatrix::operator () -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE FloatType &LSimpleMatrix:: operator () (int col) { diff --git a/panda/src/linmath/lsimpleMatrix.h b/panda/src/linmath/lsimpleMatrix.h index 310dd23d03..0ba2dc1196 100644 --- a/panda/src/linmath/lsimpleMatrix.h +++ b/panda/src/linmath/lsimpleMatrix.h @@ -1,16 +1,15 @@ -// Filename: lsimpleMatrix.h -// Created by: drose (15Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lsimpleMatrix.h + * @author drose + * @date 2011-12-15 + */ #ifndef LSIMPLEMATRIX_H #define LSIMPLEMATRIX_H @@ -21,13 +20,11 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Class : LSimpleMatrix -// Description : This class provides an underlying storage of the -// various linear-algebra classes (e.g. LVecBase3, -// LMatrix4) in the absence of the Eigen linear algebra -// library. -//////////////////////////////////////////////////////////////////// +/** + * This class provides an underlying storage of the various linear-algebra + * classes (e.g. LVecBase3, LMatrix4) in the absence of the Eigen linear + * algebra library. + */ template class LSimpleMatrix { public: @@ -52,21 +49,19 @@ private: #ifdef LINMATH_ALIGN #define LINMATH_MATRIX(FloatType, NumRows, NumCols) Eigen::Matrix #else // LINMATH_ALIGN -#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) +#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) #endif // LINMATH_ALIGN #else // HAVE_EIGEN #define UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) LSimpleMatrix -#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) +#define LINMATH_MATRIX(FloatType, NumRows, NumCols) UNALIGNED_LINMATH_MATRIX(FloatType, NumRows, NumCols) #endif // HAVE_EIGEN // This is as good a place as any to define this alignment macro. #ifdef LINMATH_ALIGN #define ALIGN_LINMATH ALIGN_16BYTE #else -#define ALIGN_LINMATH +#define ALIGN_LINMATH #endif // LINMATH_ALIGN #endif - - diff --git a/panda/src/linmath/luse.I b/panda/src/linmath/luse.I index 2d1d55c0e8..c60cc72c43 100644 --- a/panda/src/linmath/luse.I +++ b/panda/src/linmath/luse.I @@ -1,13 +1,12 @@ -// Filename: luse.I -// Created by: drose (13Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file luse.I + * @author drose + * @date 1999-01-13 + */ diff --git a/panda/src/linmath/luse.cxx b/panda/src/linmath/luse.cxx index b799761a7b..6135ca85d7 100644 --- a/panda/src/linmath/luse.cxx +++ b/panda/src/linmath/luse.cxx @@ -1,15 +1,14 @@ -// Filename: luse.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file luse.cxx + * @author drose + * @date 2000-03-08 + */ #include "luse.h" diff --git a/panda/src/linmath/luse.h b/panda/src/linmath/luse.h index acd9b98d2a..2630ed8338 100644 --- a/panda/src/linmath/luse.h +++ b/panda/src/linmath/luse.h @@ -1,66 +1,43 @@ -// Filename: luse.h -// Created by: drose (13Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file luse.h + * @author drose + * @date 1999-01-13 + */ #ifndef LUSE_H #define LUSE_H -//////////////////////////////////////////////////////////////////// -// -// This file defines a number of vector-based classes that are -// designed for specific uses. These all inherit from -// LVecBase[234][fd], which is the base of all linear algebra vectors. -// -// LPoint[234][fd] -// -// This should be used to represent a specific point in space. It -// inherits most properties from LVecBase. -// -// LVector[234][fd] -// -// This should be used to represent a vector, or a distance between -// two points in space. -// -// The distinction between LPoint and LVector is worth emphasizing. -// They differ in some subtle typing behavior (vector - vector = -// vector, point + vector = point, point - point = vector) and also in -// the way they are transformed when multiplied by a matrix (a point -// gets the translation component of the matrix, while the vector does -// not). Also, vector has length() and normalize() functions defined -// for it, while point does not. -// -// LPoint and LVector should be used whenever the concept of "point" -// or "vector" applies. If neither applies--for instance, if you are -// storing a plane equation or some such nonsense--use the base class, -// LVecBase. -// -// This file also typedefs the following: -// -// Vertex[fd] -// Normal[fd] -// TexCoord[fd] -// Color[fd] -// RGBColor[fd] -// -// These classes are typedefs of LPoint or LVector, as appropriate, -// and are intended to store a specific kind of rendering attribute. -// (Color is a four-component color; RGBColor is three-component.) -// -//////////////////////////////////////////////////////////////////// +/* + * This file defines a number of vector-based classes that are designed for + * specific uses. These all inherit from LVecBase[234][fd], which is the base + * of all linear algebra vectors. LPoint[234][fd] This should be used to + * represent a specific point in space. It inherits most properties from + * LVecBase. LVector[234][fd] This should be used to represent a vector, or a + * distance between two points in space. The distinction between LPoint and + * LVector is worth emphasizing. They differ in some subtle typing behavior + * (vector - vector = vector, point + vector = point, point - point = vector) + * and also in the way they are transformed when multiplied by a matrix (a + * point gets the translation component of the matrix, while the vector does + * not). Also, vector has length() and normalize() functions defined for it, + * while point does not. LPoint and LVector should be used whenever the + * concept of "point" or "vector" applies. If neither applies--for instance, + * if you are storing a plane equation or some such nonsense--use the base + * class, LVecBase. This file also typedefs the following: Vertex[fd] + * Normal[fd] TexCoord[fd] Color[fd] RGBColor[fd] These classes are typedefs + * of LPoint or LVector, as appropriate, and are intended to store a specific + * kind of rendering attribute. (Color is a four-component color; RGBColor is + * three-component.) + */ -// All of the guts is actually defined in this other header file, -// which is not intended to be included directly by the user. +// All of the guts is actually defined in this other header file, which is not +// intended to be included directly by the user. #include "aa_luse.h" #endif - diff --git a/panda/src/linmath/lvec2_ops.h b/panda/src/linmath/lvec2_ops.h index 819bc7bf59..2e7c1700ea 100644 --- a/panda/src/linmath/lvec2_ops.h +++ b/panda/src/linmath/lvec2_ops.h @@ -1,16 +1,15 @@ -// Filename: lvec2_ops.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec2_ops.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVEC2_OPS_H #define LVEC2_OPS_H diff --git a/panda/src/linmath/lvec2_ops_src.I b/panda/src/linmath/lvec2_ops_src.I index de3e19cab3..9ad08e5fcd 100644 --- a/panda/src/linmath/lvec2_ops_src.I +++ b/panda/src/linmath/lvec2_ops_src.I @@ -1,67 +1,60 @@ -// Filename: lvec2_ops_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec2_ops_src.I + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVecBase2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) operator * (FLOATTYPE scalar, const FLOATNAME(LVecBase2) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LPoint2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint2) operator * (FLOATTYPE scalar, const FLOATNAME(LPoint2) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVector2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) operator * (FLOATTYPE scalar, const FLOATNAME(LVector2) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: dot product of LVecBase2 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE dot(const FLOATNAME(LVecBase2) &a, const FLOATNAME(LVecBase2) &b) { return a.dot(b); } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: length of a vector -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE length(const FLOATNAME(LVector2) &a) { return a.length(); } -//////////////////////////////////////////////////////////////////// -// Function: normalize -// Description: Returns a normalized vector from the given vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a normalized vector from the given vector. + */ INLINE_LINMATH FLOATNAME(LVector2) normalize(const FLOATNAME(LVector2) &v) { FLOATNAME(LVector2) v1 = v; @@ -70,19 +63,17 @@ normalize(const FLOATNAME(LVector2) &v) { } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: generic_write_datagram -// Description: Writes the value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the value to the datagram. + */ INLINE_LINMATH void generic_write_datagram(Datagram &dest, const FLOATNAME(LVecBase2) &value) { value.write_datagram(dest); } -//////////////////////////////////////////////////////////////////// -// Function: generic_read_datagram -// Description: Reads the value from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the value from the datagram. + */ INLINE_LINMATH void generic_read_datagram(FLOATNAME(LVecBase2) &result, DatagramIterator &source) { result.read_datagram(source); diff --git a/panda/src/linmath/lvec2_ops_src.h b/panda/src/linmath/lvec2_ops_src.h index fe65dd8862..240416cafa 100644 --- a/panda/src/linmath/lvec2_ops_src.h +++ b/panda/src/linmath/lvec2_ops_src.h @@ -1,21 +1,20 @@ -// Filename: lvec2_ops_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec2_ops_src.h + * @author drose + * @date 2000-03-08 + */ -// When possible, operators have been defined within the classes. -// This file defines operator functions outside of classes where -// necessary. It also defines some convenient out-of-class wrappers -// around in-class functions (like dot, length, normalize). +// When possible, operators have been defined within the classes. This file +// defines operator functions outside of classes where necessary. It also +// defines some convenient out-of-class wrappers around in-class functions +// (like dot, length, normalize). // scalar * vec (vec * scalar is defined in class) @@ -50,6 +49,3 @@ generic_read_datagram(FLOATNAME(LVecBase2) &result, DatagramIterator &source); #include "lvec2_ops_src.I" - - - diff --git a/panda/src/linmath/lvec3_ops.h b/panda/src/linmath/lvec3_ops.h index e6b394e297..df24767be2 100644 --- a/panda/src/linmath/lvec3_ops.h +++ b/panda/src/linmath/lvec3_ops.h @@ -1,16 +1,15 @@ -// Filename: lvec3_ops.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec3_ops.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVEC3_OPS_H #define LVEC3_OPS_H diff --git a/panda/src/linmath/lvec3_ops_src.I b/panda/src/linmath/lvec3_ops_src.I index b68b8064d4..f9aab43423 100644 --- a/panda/src/linmath/lvec3_ops_src.I +++ b/panda/src/linmath/lvec3_ops_src.I @@ -1,69 +1,61 @@ -// Filename: lvec3_ops_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec3_ops_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVecBase3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) operator * (FLOATTYPE scalar, const FLOATNAME(LVecBase3) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LPoint3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint3) operator * (FLOATTYPE scalar, const FLOATNAME(LPoint3) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVector3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) operator * (FLOATTYPE scalar, const FLOATNAME(LVector3) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: dot product of LVecBase3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE dot(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b) { return a.dot(b); } -//////////////////////////////////////////////////////////////////// -// Function: cross product of LVecBase3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) cross(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b) { return a.cross(b); } -//////////////////////////////////////////////////////////////////// -// Function: cross product of LVector3 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) cross(const FLOATNAME(LVector3) &a, const FLOATNAME(LVector3) &b) { @@ -71,20 +63,18 @@ cross(const FLOATNAME(LVector3) &a, const FLOATNAME(LVector3) &b) { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: length of a vector -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE length(const FLOATNAME(LVecBase3) &a) { return a.length(); } -//////////////////////////////////////////////////////////////////// -// Function: normalize -// Description: Returns a normalized vector from the given vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a normalized vector from the given vector. + */ INLINE_LINMATH FLOATNAME(LVector3) normalize(const FLOATNAME(LVecBase3) &v) { @@ -94,19 +84,17 @@ normalize(const FLOATNAME(LVecBase3) &v) { } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: generic_write_datagram -// Description: Writes the value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the value to the datagram. + */ INLINE_LINMATH void generic_write_datagram(Datagram &dest, const FLOATNAME(LVecBase3) &value) { value.write_datagram(dest); } -//////////////////////////////////////////////////////////////////// -// Function: generic_read_datagram -// Description: Reads the value from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the value from the datagram. + */ INLINE_LINMATH void generic_read_datagram(FLOATNAME(LVecBase3) &result, DatagramIterator &source) { result.read_datagram(source); diff --git a/panda/src/linmath/lvec3_ops_src.h b/panda/src/linmath/lvec3_ops_src.h index e3cdb4b0b7..63579d8919 100644 --- a/panda/src/linmath/lvec3_ops_src.h +++ b/panda/src/linmath/lvec3_ops_src.h @@ -1,21 +1,20 @@ -// Filename: lvec3_ops_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec3_ops_src.h + * @author drose + * @date 2000-03-08 + */ -// When possible, operators have been defined within the classes. -// This file defines operator functions outside of classes where -// necessary. It also defines some convenient out-of-class wrappers -// around in-class functions (like dot, length, normalize). +// When possible, operators have been defined within the classes. This file +// defines operator functions outside of classes where necessary. It also +// defines some convenient out-of-class wrappers around in-class functions +// (like dot, length, normalize). // scalar * vec (vec * scalar is defined in class) diff --git a/panda/src/linmath/lvec4_ops.h b/panda/src/linmath/lvec4_ops.h index b020bd5df9..97d5f42718 100644 --- a/panda/src/linmath/lvec4_ops.h +++ b/panda/src/linmath/lvec4_ops.h @@ -1,16 +1,15 @@ -// Filename: lvec4_ops.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec4_ops.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVEC4_OPS_H #define LVEC4_OPS_H diff --git a/panda/src/linmath/lvec4_ops_src.I b/panda/src/linmath/lvec4_ops_src.I index 2e4c72da51..7e76e96aed 100644 --- a/panda/src/linmath/lvec4_ops_src.I +++ b/panda/src/linmath/lvec4_ops_src.I @@ -1,48 +1,43 @@ -// Filename: lvec4_ops_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec4_ops_src.I + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVecBase4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) operator * (FLOATTYPE scalar, const FLOATNAME(LVecBase4) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LPoint4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LPoint4) operator * (FLOATTYPE scalar, const FLOATNAME(LPoint4) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: scalar * LVector4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) operator * (FLOATTYPE scalar, const FLOATNAME(LVector4) &a) { return a * scalar; } -//////////////////////////////////////////////////////////////////// -// Function: dot product of LVecBase4 -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE dot(const FLOATNAME(LVecBase4) &a, const FLOATNAME(LVecBase4) &b) { @@ -50,20 +45,18 @@ dot(const FLOATNAME(LVecBase4) &a, const FLOATNAME(LVecBase4) &b) { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: length of a vector -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE length(const FLOATNAME(LVector4) &a) { return a.length(); } -//////////////////////////////////////////////////////////////////// -// Function: normalize -// Description: Returns a normalized vector from the given vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a normalized vector from the given vector. + */ INLINE_LINMATH FLOATNAME(LVector4) normalize(const FLOATNAME(LVector4) &v) { @@ -73,19 +66,17 @@ normalize(const FLOATNAME(LVector4) &v) { } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: generic_write_datagram -// Description: Writes the value to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the value to the datagram. + */ INLINE_LINMATH void generic_write_datagram(Datagram &dest, const FLOATNAME(LVecBase4) &value) { value.write_datagram(dest); } -//////////////////////////////////////////////////////////////////// -// Function: generic_read_datagram -// Description: Reads the value from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads the value from the datagram. + */ INLINE_LINMATH void generic_read_datagram(FLOATNAME(LVecBase4) &result, DatagramIterator &source) { result.read_datagram(source); diff --git a/panda/src/linmath/lvec4_ops_src.h b/panda/src/linmath/lvec4_ops_src.h index 86ef7350aa..c30b022df0 100644 --- a/panda/src/linmath/lvec4_ops_src.h +++ b/panda/src/linmath/lvec4_ops_src.h @@ -1,21 +1,20 @@ -// Filename: lvec4_ops_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvec4_ops_src.h + * @author drose + * @date 2000-03-08 + */ -// When possible, operators have been defined within the classes. -// This file defines operator functions outside of classes where -// necessary. It also defines some convenient out-of-class wrappers -// around in-class functions (like dot, length, normalize). +// When possible, operators have been defined within the classes. This file +// defines operator functions outside of classes where necessary. It also +// defines some convenient out-of-class wrappers around in-class functions +// (like dot, length, normalize). // scalar * vec (vec * scalar is defined in class) diff --git a/panda/src/linmath/lvecBase2.cxx b/panda/src/linmath/lvecBase2.cxx index ad14be3a47..373d1921ca 100644 --- a/panda/src/linmath/lvecBase2.cxx +++ b/panda/src/linmath/lvecBase2.cxx @@ -1,16 +1,15 @@ -// Filename: lvecBase2.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2.cxx + * @author drose + * @date 2000-03-08 + */ #include "lvecBase2.h" diff --git a/panda/src/linmath/lvecBase2.h b/panda/src/linmath/lvecBase2.h index e5c150ceaf..95f10b07da 100644 --- a/panda/src/linmath/lvecBase2.h +++ b/panda/src/linmath/lvecBase2.h @@ -1,16 +1,15 @@ -// Filename: lvecBase2.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVECBASE2_H #define LVECBASE2_H diff --git a/panda/src/linmath/lvecBase2_ext.h b/panda/src/linmath/lvecBase2_ext.h index c9e91d876a..a770d8ab73 100644 --- a/panda/src/linmath/lvecBase2_ext.h +++ b/panda/src/linmath/lvecBase2_ext.h @@ -1,16 +1,15 @@ -// Filename: lvecBase2_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LVECBASE2_EXT_H #define LVECBASE2_EXT_H diff --git a/panda/src/linmath/lvecBase2_ext_src.I b/panda/src/linmath/lvecBase2_ext_src.I index ba5daf54bf..7355fd5e61 100644 --- a/panda/src/linmath/lvecBase2_ext_src.I +++ b/panda/src/linmath/lvecBase2_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lvecBase2_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -28,11 +27,9 @@ #define PY_AS_FLOATTYPE (FLOATTYPE)PyFloat_AsDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -42,18 +39,15 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ INLINE_LINMATH PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; @@ -74,11 +68,9 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -124,11 +116,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { #ifndef NDEBUG @@ -155,8 +145,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return -1; } - // Get a pointer to the items, iterate over it and - // perform our magic assignment. Fast fast. Oh yeah. + // Get a pointer to the items, iterate over it and perform our magic + // assignment. Fast fast. Oh yeah. PyObject** items = PySequence_Fast_ITEMS(fast); for (size_t i = 0; i < attr_name.size(); ++i) { @@ -183,8 +173,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); if (fl == NULL) { - // It's not a floating-point value either? - // Sheesh, I don't know what to do with it then. + // It's not a floating-point value either? Sheesh, I don't know what to + // do with it then. if (attr_name.size() == 1) { #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "an integer is required"); @@ -200,8 +190,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { FLOATTYPE value = PY_AS_FLOATTYPE(fl); Py_DECREF(fl); - // Loop through the components in the attribute name, - // and assign the floating-point value to every one of them. + // Loop through the components in the attribute name, and assign the + // floating-point value to every one of them. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v((*it) - 'x') = value; } @@ -210,11 +200,9 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__pow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) Extension:: __pow__(FLOATTYPE exponent) const { return FLOATNAME(LVecBase2)( @@ -222,11 +210,9 @@ __pow__(FLOATTYPE exponent) const { cpow(_this->_v(1), exponent)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::__ipow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH PyObject *Extension:: __ipow__(PyObject *self, FLOATTYPE exponent) { _this->_v(0) = cpow(_this->_v(0), exponent); diff --git a/panda/src/linmath/lvecBase2_ext_src.h b/panda/src/linmath/lvecBase2_ext_src.h index d72a6da3e2..3d6efe4831 100644 --- a/panda/src/linmath/lvecBase2_ext_src.h +++ b/panda/src/linmath/lvecBase2_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvecBase2_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVecBase2, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVecBase2, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvecBase2_src.I b/panda/src/linmath/lvecBase2_src.I index c6745112ae..7a8cddc5a0 100644 --- a/panda/src/linmath/lvecBase2_src.I +++ b/panda/src/linmath/lvecBase2_src.I @@ -1,108 +1,89 @@ -// Filename: lvecBase2_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_src.I + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2):: FLOATNAME(LVecBase2)(FLOATTYPE fill_value) { fill(fill_value); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2):: FLOATNAME(LVecBase2)(FLOATTYPE x, FLOATTYPE y) { TAU_PROFILE("LVecBase2::LVecBase2(FLOATTYPE, ...)", " ", TAU_USER); _v(0) = x; _v(1) = y; -// set(x, y); +// set(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::zero Named Constructor -// Access: Published -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2):: zero() { return _zero; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::unit_x Named Constructor -// Access: Published -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2):: unit_x() { return _unit_x; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::unit_y Named Constructor -// Access: Published -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase2) &FLOATNAME(LVecBase2):: unit_y() { return _unit_y; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: operator [](int i) const { nassertr(i >= 0 && i < 2, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase2):: operator [](int i) { nassertr(i >= 0 && i < 2, _v(0)); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::size -// Access: Published, Static -// Description: Returns 2: the number of components of a LVecBase2. -//////////////////////////////////////////////////////////////////// +/** + * Returns 2: the number of components of a LVecBase2. + */ CONSTEXPR int FLOATNAME(LVecBase2):: size() { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::is_nan -// Access: Published -// Description: Returns true if any component of the vector is -// not-a-number, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any component of the vector is not-a-number, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: is_nan() const { #ifdef FLOATTYPE_IS_INT @@ -113,172 +94,138 @@ is_nan() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: get_cell(int i) const { nassertr(i >= 0 && i < 2, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: get_x() const { return _v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: get_y() const { return _v(1); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::set_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: set_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 2); _v(i) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::set_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: set_x(FLOATTYPE value) { _v(0) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::set_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: set_y(FLOATTYPE value) { _v(1) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::add_to_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: add_to_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 2); _v(i) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::add_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: add_x(FLOATTYPE value) { _v(0) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::add_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: add_y(FLOATTYPE value) { _v(1) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_data -// Access: Published -// Description: Returns the address of the first of the two data -// elements in the vector. The next element -// occupies the next position consecutively in memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the two data elements in the vector. + * The next element occupies the next position consecutively in memory. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase2):: get_data() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_num_components -// Access: Published -// Description: Returns the number of elements in the vector, two. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the vector, two. + */ CONSTEXPR int FLOATNAME(LVecBase2):: get_num_components() { return 2; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase2)::iterator FLOATNAME(LVecBase2):: begin() { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase2)::iterator FLOATNAME(LVecBase2):: end() { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase2)::const_iterator FLOATNAME(LVecBase2):: begin() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase2)::const_iterator FLOATNAME(LVecBase2):: end() const { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::fill -// Access: Published -// Description: Sets each element of the vector to the indicated -// fill_value. This is particularly useful for -// initializing to zero. -//////////////////////////////////////////////////////////////////// +/** + * Sets each element of the vector to the indicated fill_value. This is + * particularly useful for initializing to zero. + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: fill(FLOATTYPE fill_value) { TAU_PROFILE("void LVecBase2::fill()", " ", TAU_USER); @@ -286,11 +233,9 @@ fill(FLOATTYPE fill_value) { _v(1) = fill_value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: set(FLOATTYPE x, FLOATTYPE y) { TAU_PROFILE("void LVecBase2::set()", " ", TAU_USER); @@ -298,11 +243,9 @@ set(FLOATTYPE x, FLOATTYPE y) { _v(1) = y; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::dot -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: dot(const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("FLOATTYPE LVecBase2::dot()", " ", TAU_USER); @@ -313,12 +256,9 @@ dot(const FLOATNAME(LVecBase2) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::length_squared -// Access: Published -// Description: Returns the square of the vector's length, cheap and -// easy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the square of the vector's length, cheap and easy. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: length_squared() const { TAU_PROFILE("FLOATTYPE LVecBase2::length_squared()", " ", TAU_USER); @@ -330,12 +270,9 @@ length_squared() const { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::length -// Access: Published -// Description: Returns the length of the vector, by the Pythagorean -// theorem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the vector, by the Pythagorean theorem. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase2):: length() const { TAU_PROFILE("FLOATTYPE LVecBase2::length()", " ", TAU_USER); @@ -346,13 +283,10 @@ length() const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::normalize -// Access: Published -// Description: Normalizes the vector in place. Returns true if the -// vector was normalized, false if it was a zero-length -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector in place. Returns true if the vector was normalized, + * false if it was a zero-length vector. + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: normalize() { FLOATTYPE l2 = length_squared(); @@ -367,13 +301,10 @@ normalize() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: normalized() const { FLOATTYPE l2 = length_squared(); @@ -383,39 +314,30 @@ normalized() const { return (*this) / csqrt(l2); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: project(const FLOATNAME(LVecBase2) &onto) const { return onto * (dot(onto) / onto.length_squared()); } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator < -// Access: Published -// Description: This performs a lexicographical comparison. It's of -// questionable mathematical meaning, but sometimes has -// a practical purpose for sorting unique vectors, -// especially in an STL container. Also see -// compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This performs a lexicographical comparison. It's of questionable + * mathematical meaning, but sometimes has a practical purpose for sorting + * unique vectors, especially in an STL container. Also see compare_to(). + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: operator < (const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("bool LVecBase2::operator <(const LVecBase2 &)", " ", TAU_USER); return (compare_to(other) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: operator == (const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("bool LVecBase2::operator ==(const LVecBase2 &)", " ", TAU_USER); @@ -427,22 +349,18 @@ operator == (const FLOATNAME(LVecBase2) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: operator != (const FLOATNAME(LVecBase2) &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::compare_to -// Access: Published -// Description: This flavor of compare_to uses a default threshold -// value based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of compare_to uses a default threshold value based on the + * numeric type. + */ INLINE_LINMATH int FLOATNAME(LVecBase2):: compare_to(const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &)", " ", TAU_USER); @@ -459,22 +377,18 @@ compare_to(const FLOATNAME(LVecBase2) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase2):: get_hash() const { TAU_PROFILE("size_t LVecBase2::get_hash()", " ", TAU_USER); return add_hash(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase2):: add_hash(size_t hash) const { TAU_PROFILE("size_t LVecBase2::add_hash(size_t)", " ", TAU_USER); @@ -488,11 +402,9 @@ add_hash(size_t hash) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: generate_hash(ChecksumHashGenerator &hashgen) const { #ifdef FLOATTYPE_IS_INT @@ -504,15 +416,11 @@ generate_hash(ChecksumHashGenerator &hashgen) const { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::compare_to -// Access: Published -// Description: Sorts vectors lexicographically, componentwise. -// Returns a number less than 0 if this vector sorts -// before the other one, greater than zero if it sorts -// after, 0 if they are equivalent (within the indicated -// tolerance). -//////////////////////////////////////////////////////////////////// +/** + * Sorts vectors lexicographically, componentwise. Returns a number less than + * 0 if this vector sorts before the other one, greater than zero if it sorts + * after, 0 if they are equivalent (within the indicated tolerance). + */ INLINE_LINMATH int FLOATNAME(LVecBase2):: compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { TAU_PROFILE("int LVecBase2::compare_to(const LVecBase2 &, FLOATTYPE)", " ", TAU_USER); @@ -525,22 +433,18 @@ compare_to(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase2):: get_hash(FLOATTYPE threshold) const { TAU_PROFILE("size_t LVecBase2::get_hash(FLOATTYPE)", " ", TAU_USER); return add_hash(0, threshold); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase2):: add_hash(size_t hash, FLOATTYPE threshold) const { TAU_PROFILE("LVecBase2::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); @@ -550,11 +454,9 @@ add_hash(size_t hash, FLOATTYPE threshold) const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { hashgen.add_fp(_v(0), threshold); @@ -562,11 +464,9 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::unary - -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: operator - () const { #ifdef HAVE_EIGEN @@ -576,11 +476,9 @@ operator - () const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::vector + vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: operator + (const FLOATNAME(LVecBase2) &other) const { #ifdef HAVE_EIGEN @@ -591,11 +489,9 @@ operator + (const FLOATNAME(LVecBase2) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::vector - vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: operator - (const FLOATNAME(LVecBase2) &other) const { #ifdef HAVE_EIGEN @@ -606,11 +502,9 @@ operator - (const FLOATNAME(LVecBase2) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::vector * scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: operator * (FLOATTYPE scalar) const { #ifdef HAVE_EIGEN @@ -621,11 +515,9 @@ operator * (FLOATTYPE scalar) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::vector / scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: operator / (FLOATTYPE scalar) const { #ifdef FLOATTYPE_IS_INT @@ -637,11 +529,9 @@ operator / (FLOATTYPE scalar) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator += -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: operator += (const FLOATNAME(LVecBase2) &other) { #ifdef HAVE_EIGEN @@ -652,11 +542,9 @@ operator += (const FLOATNAME(LVecBase2) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator -= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: operator -= (const FLOATNAME(LVecBase2) &other) { #ifdef HAVE_EIGEN @@ -667,11 +555,9 @@ operator -= (const FLOATNAME(LVecBase2) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator *= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: operator *= (FLOATTYPE scalar) { #ifdef HAVE_EIGEN @@ -682,11 +568,9 @@ operator *= (FLOATTYPE scalar) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::operator /= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: operator /= (FLOATTYPE scalar) { #ifdef FLOATTYPE_IS_INT @@ -698,11 +582,9 @@ operator /= (FLOATTYPE scalar) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::componentwise_mult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: componentwise_mult(const FLOATNAME(LVecBase2) &other) { #ifdef HAVE_EIGEN @@ -713,11 +595,9 @@ componentwise_mult(const FLOATNAME(LVecBase2) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::fmax -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: fmax(const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("LVecBase2::fmax()", " ", TAU_USER); @@ -729,11 +609,9 @@ fmax(const FLOATNAME(LVecBase2) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::fmin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase2):: fmin(const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("LVecBase2::fmin()", " ", TAU_USER); @@ -745,12 +623,10 @@ fmin(const FLOATNAME(LVecBase2) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::almost_equal -// Access: Published -// Description: Returns true if two vectors are memberwise equal -// within a specified tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two vectors are memberwise equal within a specified + * tolerance. + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &, FLOATTYPE)", " ", TAU_USER); @@ -758,40 +634,32 @@ almost_equal(const FLOATNAME(LVecBase2) &other, FLOATTYPE threshold) const { IS_THRESHOLD_EQUAL(_v(1), other._v(1), threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::almost_equal -// Access: Published -// Description: Returns true if two vectors are memberwise equal -// within a default tolerance based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two vectors are memberwise equal within a default tolerance + * based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LVecBase2):: almost_equal(const FLOATNAME(LVecBase2) &other) const { TAU_PROFILE("bool LVecBase2::almost_equal(LVecBase2 &)", " ", TAU_USER); return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: output(ostream &out) const { out << MAYBE_ZERO(_v(0)) << " " << MAYBE_ZERO(_v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::write_datagram_fixed -// Access: Published -// Description: Writes the vector to the Datagram using add_float32() -// or add_float64(), depending on the type of floats in -// the vector, regardless of the setting of -// Datagram::set_stdfloat_double(). This is appropriate -// when you want to write a fixed-width value to the -// datagram, especially when you are not writing a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vector to the Datagram using add_float32() or add_float64(), + * depending on the type of floats in the vector, regardless of the setting of + * Datagram::set_stdfloat_double(). This is appropriate when you want to + * write a fixed-width value to the datagram, especially when you are not + * writing a bam file. + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: write_datagram_fixed(Datagram &destination) const { #if FLOATTOKEN == 'i' @@ -806,12 +674,10 @@ write_datagram_fixed(Datagram &destination) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::read_datagram_fixed -// Access: Published -// Description: Reads the vector from the Datagram using get_float32() -// or get_float64(). See write_datagram_fixed(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the vector from the Datagram using get_float32() or get_float64(). + * See write_datagram_fixed(). + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: read_datagram_fixed(DatagramIterator &source) { #if FLOATTOKEN == 'i' @@ -826,14 +692,11 @@ read_datagram_fixed(DatagramIterator &source) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::write_datagram -// Access: Published -// Description: Writes the vector to the Datagram using -// add_stdfloat(). This is appropriate when you want to -// write the vector using the standard width setting, -// especially when you are writing a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vector to the Datagram using add_stdfloat(). This is + * appropriate when you want to write the vector using the standard width + * setting, especially when you are writing a bam file. + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: write_datagram(Datagram &destination) const { #if FLOATTOKEN == 'i' @@ -845,11 +708,9 @@ write_datagram(Datagram &destination) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::read_datagram -// Access: Published -// Description: Reads the vector from the Datagram using get_stdfloat(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the vector from the Datagram using get_stdfloat(). + */ INLINE_LINMATH void FLOATNAME(LVecBase2):: read_datagram(DatagramIterator &source) { #if FLOATTOKEN == 'i' diff --git a/panda/src/linmath/lvecBase2_src.cxx b/panda/src/linmath/lvecBase2_src.cxx index 03cd74b05f..dfd091267e 100644 --- a/panda/src/linmath/lvecBase2_src.cxx +++ b/panda/src/linmath/lvecBase2_src.cxx @@ -1,16 +1,15 @@ -// Filename: lvecBase2_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LVecBase2)::_type_handle; @@ -21,11 +20,9 @@ const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_x = const FLOATNAME(LVecBase2) FLOATNAME(LVecBase2)::_unit_y = FLOATNAME(LVecBase2)(0, 1); -//////////////////////////////////////////////////////////////////// -// Function: LVecBase2::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LVecBase2):: init_type() { if (_type_handle == TypeHandle::none()) { diff --git a/panda/src/linmath/lvecBase2_src.h b/panda/src/linmath/lvecBase2_src.h index 1094b03617..e4c1c8a905 100644 --- a/panda/src/linmath/lvecBase2_src.h +++ b/panda/src/linmath/lvecBase2_src.h @@ -1,23 +1,19 @@ -// Filename: lvecBase2_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase2_src.h + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Class : LVecBase2 -// Description : This is the base class for all two-component -// vectors and points. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for all two-component vectors and points. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LVecBase2) { PUBLISHED: typedef FLOATTYPE numeric_type; @@ -66,10 +62,9 @@ PUBLISHED: MAKE_PROPERTY(x, get_x, set_x); MAKE_PROPERTY(y, get_y, set_y); - // These next functions add to an existing value. - // i.e. foo.set_x(foo.get_x() + value) - // These are useful to reduce overhead in scripting - // languages: + // These next functions add to an existing value. i.e. + // foo.set_x(foo.get_x() + value) These are useful to reduce overhead in + // scripting languages: INLINE_LINMATH void add_to_cell(int i, FLOATTYPE value); INLINE_LINMATH void add_x(FLOATTYPE value); INLINE_LINMATH void add_y(FLOATTYPE value); @@ -155,13 +150,12 @@ PUBLISHED: public: // The underlying implementation is via the Eigen library, if available. - // We don't bother to align LVecBase2. The float version is too - // small to benefit from SSE2 optimizations. The double version - // *would* benefit, but we use this class infrequently throughout - // the Panda codebase, and the nuisance value of maintaining aligned - // and unaligned versions of this class outweighs the benefits of - // having SSE2 optimizations in the stdfloat-double compilation - // mode. + // We don't bother to align LVecBase2. The float version is too small to + // benefit from SSE2 optimizations. The double version *would* benefit, but + // we use this class infrequently throughout the Panda codebase, and the + // nuisance value of maintaining aligned and unaligned versions of this + // class outweighs the benefits of having SSE2 optimizations in the + // stdfloat-double compilation mode. typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 2) EVector2; EVector2 _v; diff --git a/panda/src/linmath/lvecBase3.cxx b/panda/src/linmath/lvecBase3.cxx index 79e0405525..2ab05ab87e 100644 --- a/panda/src/linmath/lvecBase3.cxx +++ b/panda/src/linmath/lvecBase3.cxx @@ -1,16 +1,15 @@ -// Filename: lvecBase3.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3.cxx + * @author drose + * @date 2000-03-08 + */ #include "lvecBase3.h" diff --git a/panda/src/linmath/lvecBase3.h b/panda/src/linmath/lvecBase3.h index 3152b72e8f..eed52aed53 100644 --- a/panda/src/linmath/lvecBase3.h +++ b/panda/src/linmath/lvecBase3.h @@ -1,16 +1,15 @@ -// Filename: lvecBase3.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVECBASE3_H #define LVECBASE3_H diff --git a/panda/src/linmath/lvecBase3_ext.h b/panda/src/linmath/lvecBase3_ext.h index 8fa47de8ee..a880fbe14c 100644 --- a/panda/src/linmath/lvecBase3_ext.h +++ b/panda/src/linmath/lvecBase3_ext.h @@ -1,16 +1,15 @@ -// Filename: lvecBase3_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LVECBASE3_EXT_H #define LVECBASE3_EXT_H diff --git a/panda/src/linmath/lvecBase3_ext_src.I b/panda/src/linmath/lvecBase3_ext_src.I index d343b99303..4450a3ac30 100644 --- a/panda/src/linmath/lvecBase3_ext_src.I +++ b/panda/src/linmath/lvecBase3_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lvecBase3_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -28,11 +27,9 @@ #define PY_AS_FLOATTYPE (FLOATTYPE)PyFloat_AsDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -43,18 +40,15 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ INLINE_LINMATH PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; @@ -75,11 +69,9 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -125,11 +117,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { #ifndef NDEBUG @@ -156,8 +146,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return -1; } - // Get a pointer to the items, iterate over it and - // perform our magic assignment. Fast fast. Oh yeah. + // Get a pointer to the items, iterate over it and perform our magic + // assignment. Fast fast. Oh yeah. PyObject** items = PySequence_Fast_ITEMS(fast); for (size_t i = 0; i < attr_name.size(); ++i) { @@ -184,8 +174,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Maybe it's a single floating-point value. PyObject* fl = PYNUMBER_FLOATTYPE(assign); if (fl == NULL) { - // It's not a floating-point value either? - // Sheesh, I don't know what to do with it then. + // It's not a floating-point value either? Sheesh, I don't know what to + // do with it then. if (attr_name.size() == 1) { #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "an integer is required"); @@ -201,8 +191,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { FLOATTYPE value = PY_AS_FLOATTYPE(fl); Py_DECREF(fl); - // Loop through the components in the attribute name, - // and assign the floating-point value to every one of them. + // Loop through the components in the attribute name, and assign the + // floating-point value to every one of them. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v((*it) - 'x') = value; } @@ -211,11 +201,9 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__pow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) Extension:: __pow__(FLOATTYPE exponent) const { return FLOATNAME(LVecBase3)( @@ -224,11 +212,9 @@ __pow__(FLOATTYPE exponent) const { cpow(_this->_v(2), exponent)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::__ipow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH PyObject *Extension:: __ipow__(PyObject *self, FLOATTYPE exponent) { _this->_v(0) = cpow(_this->_v(0), exponent); diff --git a/panda/src/linmath/lvecBase3_ext_src.h b/panda/src/linmath/lvecBase3_ext_src.h index 6b12ac69f3..e88a28790b 100644 --- a/panda/src/linmath/lvecBase3_ext_src.h +++ b/panda/src/linmath/lvecBase3_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvecBase3_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVecBase3, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVecBase3, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvecBase3_src.I b/panda/src/linmath/lvecBase3_src.I index b63fdd6f21..ec9cc7be39 100644 --- a/panda/src/linmath/lvecBase3_src.I +++ b/panda/src/linmath/lvecBase3_src.I @@ -1,130 +1,106 @@ -// Filename: lvecBase3_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase3_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3):: FLOATNAME(LVecBase3)(FLOATTYPE fill_value) { fill(fill_value); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3):: FLOATNAME(LVecBase3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { TAU_PROFILE("LVecBase3::LVecBase3(FLOATTYPE, ...)", " ", TAU_USER); _v(0) = x; _v(1) = y; _v(2) = z; -// set(x, y, z); +// set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3):: FLOATNAME(LVecBase3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z) { set(copy[0], copy[1], z); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::zero Named Constructor -// Access: Public -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3):: zero() { return _zero; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3):: unit_x() { return _unit_x; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3):: unit_y() { return _unit_y; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::unit_z Named Constructor -// Access: Public -// Description: Returns a unit Z vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase3) &FLOATNAME(LVecBase3):: unit_z() { return _unit_z; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: operator [](int i) const { nassertr(i >= 0 && i < 3, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase3):: operator [](int i) { nassertr(i >= 0 && i < 3, _v(0)); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::size -// Access: Public, Static -// Description: Returns 3: the number of components of a LVecBase3. -//////////////////////////////////////////////////////////////////// +/** + * Returns 3: the number of components of a LVecBase3. + */ CONSTEXPR int FLOATNAME(LVecBase3):: size() { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::is_nan -// Access: Public -// Description: Returns true if any component of the vector is -// not-a-number, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any component of the vector is not-a-number, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LVecBase3):: is_nan() const { #ifdef FLOATTYPE_IS_INT @@ -135,235 +111,189 @@ is_nan() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_cell -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: get_cell(int i) const { nassertr(i >= 0 && i < 3, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_x -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: get_x() const { return _v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_y -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: get_y() const { return _v(1); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_z -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: get_z() const { return _v(2); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::set_cell -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: set_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 3); _v(i) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::set_x -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: set_x(FLOATTYPE value) { _v(0) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::set_y -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: set_y(FLOATTYPE value) { _v(1) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::set_z -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: set_z(FLOATTYPE value) { _v(2) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_xy -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3):: get_xy() const { return FLOATNAME(LVecBase2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_xz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first and last components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first and last components + * of this vector. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3):: get_xz() const { return FLOATNAME(LVecBase2)(_v(0), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_yz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// last two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the last two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase3):: get_yz() const { return FLOATNAME(LVecBase2)(_v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::add_to_cell -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: add_to_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 3); _v(i) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::add_x -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: add_x(FLOATTYPE value) { _v(0) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::add_y -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: add_y(FLOATTYPE value) { _v(1) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::add_z -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: add_z(FLOATTYPE value) { _v(2) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_data -// Access: Public -// Description: Returns the address of the first of the three data -// elements in the vector. The remaining elements -// occupy the next positions consecutively in memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the three data elements in the vector. + * The remaining elements occupy the next positions consecutively in memory. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase3):: get_data() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::get_num_components -// Access: Public -// Description: Returns the number of elements in the vector, three. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the vector, three. + */ CONSTEXPR int FLOATNAME(LVecBase3):: get_num_components() { return 3; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::begin -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase3)::iterator FLOATNAME(LVecBase3):: begin() { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::end -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase3)::iterator FLOATNAME(LVecBase3):: end() { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::begin -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase3)::const_iterator FLOATNAME(LVecBase3):: begin() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::end -// Access: Public -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase3)::const_iterator FLOATNAME(LVecBase3):: end() const { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::fill -// Access: Published -// Description: Sets each element of the vector to the indicated -// fill_value. This is particularly useful for -// initializing to zero. -//////////////////////////////////////////////////////////////////// +/** + * Sets each element of the vector to the indicated fill_value. This is + * particularly useful for initializing to zero. + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: fill(FLOATTYPE fill_value) { TAU_PROFILE("void LVecBase3::fill()", " ", TAU_USER); @@ -376,11 +306,9 @@ fill(FLOATTYPE fill_value) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase3):: set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { TAU_PROFILE("void LVecBase3::set()", " ", TAU_USER); @@ -389,11 +317,9 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) { _v(2) = z; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::dot -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: dot(const FLOATNAME(LVecBase3) &other) const { TAU_PROFILE("FLOATTYPE LVecBase3::dot()", " ", TAU_USER); @@ -404,12 +330,9 @@ dot(const FLOATNAME(LVecBase3) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::length_squared -// Access: Published -// Description: Returns the square of the vector's length, cheap and -// easy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the square of the vector's length, cheap and easy. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: length_squared() const { TAU_PROFILE("FLOATTYPE LVecBase3::length_squared()", " ", TAU_USER); @@ -421,12 +344,9 @@ length_squared() const { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::length -// Access: Published -// Description: Returns the length of the vector, by the Pythagorean -// theorem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the vector, by the Pythagorean theorem. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase3):: length() const { TAU_PROFILE("FLOATTYPE LVecBase3::length()", " ", TAU_USER); @@ -437,13 +357,10 @@ length() const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::normalize -// Access: Published -// Description: Normalizes the vector in place. Returns true if the -// vector was normalized, false if it was a zero-length -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector in place. Returns true if the vector was normalized, + * false if it was a zero-length vector. + */ INLINE_LINMATH bool FLOATNAME(LVecBase3):: normalize() { TAU_PROFILE("bool LVecBase3::normalize()", " ", TAU_USER); @@ -459,13 +376,10 @@ normalize() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: normalized() const { FLOATTYPE l2 = length_squared(); @@ -475,24 +389,19 @@ normalized() const { return (*this) / csqrt(l2); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: project(const FLOATNAME(LVecBase3) &onto) const { return onto * (dot(onto) / onto.length_squared()); } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::cross -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase3):: cross(const FLOATNAME(LVecBase3) &other) const { TAU_PROFILE("LVecBase3 LVecBase3::cross()", " ", TAU_USER); @@ -505,26 +414,20 @@ cross(const FLOATNAME(LVecBase3) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::operator < -// Access: Published -// Description: This performs a lexicographical comparison. It's of -// questionable mathematical meaning, but sometimes has -// a practical purpose for sorting unique vectors, -// especially in an STL container. Also see -// compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This performs a lexicographical comparison. It's of questionable + * mathematical meaning, but sometimes has a practical purpose for sorting + * unique vectors, especially in an STL container. Also see compare_to(). + */ INLINE_LINMATH bool FLOATNAME(LVecBase3):: operator < (const FLOATNAME(LVecBase3) &other) const { TAU_PROFILE("bool LVecBase3::operator <(const LVecBase3 &)", " ", TAU_USER); return (compare_to(other) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase3):: operator == (const FLOATNAME(LVecBase3) &other) const { TAU_PROFILE("bool LVecBase3::operator ==(const LVecBase3 &)", " ", TAU_USER); @@ -537,23 +440,19 @@ operator == (const FLOATNAME(LVecBase3) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase3::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase3):: operator != (const FLOATNAME(LVecBase3) &other) const { return !operator == (other); } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: get_standardized_rotation -// Access: file -// Description: return value in the range -180.0 to 179.99999. -// See Also: get_standardized_hpr -//////////////////////////////////////////////////////////////////// +/** + * return value in the range -180.0 to 179.99999. See Also: + * get_standardized_hpr + */ static INLINE_LINMATH FLOATTYPE get_standardized_rotation(FLOATTYPE angle_in_degrees) { if (angle_in_degrees<0.0) { @@ -561,33 +460,26 @@ get_standardized_rotation(FLOATTYPE angle_in_degrees) { } else { angle_in_degrees = fmod(angle_in_degrees, FLOATCONST(360.0)); } - // This can be changed to return values in the range 0.0 to 359.99999 - // by skipping this next part and returning now. - + // This can be changed to return values in the range 0.0 to 359.99999 by + // skipping this next part and returning now. + return (angle_in_degrees= 3 @@ -28,11 +27,9 @@ #define PY_AS_FLOATTYPE (FLOATTYPE)PyFloat_AsDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -44,18 +41,15 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ INLINE_LINMATH PyObject *Extension:: __reduce__(PyObject *self) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; @@ -76,11 +70,9 @@ __reduce__(PyObject *self) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -130,11 +122,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { #ifndef NDEBUG @@ -161,8 +151,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return -1; } - // Get a pointer to the items, iterate over it and - // perform our magic assignment. Fast fast. Oh yeah. + // Get a pointer to the items, iterate over it and perform our magic + // assignment. Fast fast. Oh yeah. PyObject** items = PySequence_Fast_ITEMS(fast); for (size_t i = 0; i < attr_name.size(); ++i) { @@ -190,8 +180,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { PyObject* fl = PYNUMBER_FLOATTYPE(assign); if (fl == NULL) { - // It's not a floating-point value either? - // Sheesh, I don't know what to do with it then. + // It's not a floating-point value either? Sheesh, I don't know what to + // do with it then. if (attr_name.size() == 1) { #ifdef FLOATTYPE_IS_INT PyErr_SetString(PyExc_ValueError, "an integer is required"); @@ -207,8 +197,8 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { FLOATTYPE value = PY_AS_FLOATTYPE(fl); Py_DECREF(fl); - // Loop through the components in the attribute name, - // and assign the floating-point value to every one of them. + // Loop through the components in the attribute name, and assign the + // floating-point value to every one of them. for (string::const_iterator it = attr_name.begin(); it < attr_name.end(); it++) { _this->_v(((*it) == 'w') ? 3 : (*it) - 'x') = value; } @@ -217,11 +207,9 @@ __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__pow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) Extension:: __pow__(FLOATTYPE exponent) const { return FLOATNAME(LVecBase4)( @@ -231,11 +219,9 @@ __pow__(FLOATTYPE exponent) const { cpow(_this->_v(3), exponent)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::__ipow__ -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH PyObject *Extension:: __ipow__(PyObject *self, FLOATTYPE exponent) { _this->_v(0) = cpow(_this->_v(0), exponent); diff --git a/panda/src/linmath/lvecBase4_ext_src.h b/panda/src/linmath/lvecBase4_ext_src.h index 5d582bbe64..b7a916fd60 100644 --- a/panda/src/linmath/lvecBase4_ext_src.h +++ b/panda/src/linmath/lvecBase4_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvecBase4_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase4_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVecBase4, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVecBase4, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvecBase4_src.I b/panda/src/linmath/lvecBase4_src.I index 6ed6bbd009..6771e563ff 100644 --- a/panda/src/linmath/lvecBase4_src.I +++ b/panda/src/linmath/lvecBase4_src.I @@ -1,169 +1,135 @@ -// Filename: lvecBase4_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase4_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(const FLOATNAME(UnalignedLVecBase4) ©) { set(copy[0], copy[1], copy[2], copy[3]); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(FLOATTYPE fill_value) { fill(fill_value); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { TAU_PROFILE("LVecBase4::LVecBase4(FLOATTYPE, ...)", " ", TAU_USER); set(x, y, z, w); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w) { set(copy[0], copy[1], copy[2], w); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Constructor -// Access: Published -// Description: Constructs an LVecBase4 from an LPoint3. The w -// coordinate is set to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an LVecBase4 from an LPoint3. The w coordinate is set to 1.0. + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(const FLOATNAME(LPoint3) &point) { set(point[0], point[1], point[2], 1); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Constructor -// Access: Published -// Description: Constructs an LVecBase4 from an LVector3. The w -// coordinate is set to 0.0. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an LVecBase4 from an LVector3. The w coordinate is set to 0.0. + */ INLINE_LINMATH FLOATNAME(LVecBase4):: FLOATNAME(LVecBase4)(const FLOATNAME(LVector3) &vector) { set(vector[0], vector[1], vector[2], 0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::zero Named Constructor -// Access: Published -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: zero() { return _zero; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::unit_x Named Constructor -// Access: Published -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: unit_x() { return _unit_x; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::unit_y Named Constructor -// Access: Published -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: unit_y() { return _unit_y; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::unit_z Named Constructor -// Access: Published -// Description: Returns a unit Z vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: unit_z() { return _unit_z; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::unit_w Named Constructor -// Access: Published -// Description: Returns a unit W vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit W vector. + */ INLINE_LINMATH const FLOATNAME(LVecBase4) &FLOATNAME(LVecBase4):: unit_w() { return _unit_w; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: operator [](int i) const { nassertr(i >= 0 && i < 4, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::Indexing Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(LVecBase4):: operator [](int i) { nassertr(i >= 0 && i < 4, _v(0)); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::size -// Access: Published, Static -// Description: Returns 4: the number of components of a LVecBase4. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4: the number of components of a LVecBase4. + */ CONSTEXPR int FLOATNAME(LVecBase4):: size() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::is_nan -// Access: Published -// Description: Returns true if any component of the vector is -// not-a-number, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any component of the vector is not-a-number, false + * otherwise. + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: is_nan() const { #ifdef FLOATTYPE_IS_INT @@ -174,252 +140,202 @@ is_nan() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: get_cell(int i) const { nassertr(i >= 0 && i < 4, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: get_x() const { return _v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: get_y() const { return _v(1); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_z -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: get_z() const { return _v(2); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_w -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: get_w() const { return _v(3); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_xyz -// Access: Published -// Description: Returns the x, y and z component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y and z component of this vector + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVecBase4):: get_xyz() const { return FLOATNAME(LVecBase3)(_v(0), _v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_xy -// Access: Published -// Description: Returns the x and y component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x and y component of this vector + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVecBase4):: get_xy() const { return FLOATNAME(LVecBase2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 4); _v(i) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set_x(FLOATTYPE value) { _v(0) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set_y(FLOATTYPE value) { _v(1) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set_z -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set_z(FLOATTYPE value) { _v(2) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set_w -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set_w(FLOATTYPE value) { _v(3) = value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_to_cell -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: add_to_cell(int i, FLOATTYPE value) { nassertv(i >= 0 && i < 4); _v(i) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: add_x(FLOATTYPE value) { _v(0) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: add_y(FLOATTYPE value) { _v(1) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_z -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: add_z(FLOATTYPE value) { _v(2) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_w -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: add_w(FLOATTYPE value) { _v(3) += value; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_data -// Access: Published -// Description: Returns the address of the first of the four data -// elements in the vector. The remaining elements -// occupy the next positions consecutively in memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the four data elements in the vector. + * The remaining elements occupy the next positions consecutively in memory. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(LVecBase4):: get_data() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_num_components -// Access: Published -// Description: Returns the number of elements in the vector, four. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the vector, four. + */ CONSTEXPR int FLOATNAME(LVecBase4):: get_num_components() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4):: begin() { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase4)::iterator FLOATNAME(LVecBase4):: end() { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::begin -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4):: begin() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::end -// Access: Published -// Description: Returns an iterator that may be used to traverse the -// elements of the matrix, STL-style. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator that may be used to traverse the elements of the + * matrix, STL-style. + */ INLINE_LINMATH FLOATNAME(LVecBase4)::const_iterator FLOATNAME(LVecBase4):: end() const { return begin() + num_components; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::fill -// Access: Published -// Description: Sets each element of the vector to the indicated -// fill_value. This is particularly useful for -// initializing to zero. -//////////////////////////////////////////////////////////////////// +/** + * Sets each element of the vector to the indicated fill_value. This is + * particularly useful for initializing to zero. + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: fill(FLOATTYPE fill_value) { TAU_PROFILE("void LVecBase4::fill()", " ", TAU_USER); @@ -433,11 +349,9 @@ fill(FLOATTYPE fill_value) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { TAU_PROFILE("void LVecBase4::set()", " ", TAU_USER); @@ -447,11 +361,9 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { _v(3) = w; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::dot -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: dot(const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("FLOATTYPE LVecBase4::dot()", " ", TAU_USER); @@ -464,12 +376,9 @@ dot(const FLOATNAME(LVecBase4) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::length_squared -// Access: Published -// Description: Returns the square of the vector's length, cheap and -// easy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the square of the vector's length, cheap and easy. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: length_squared() const { TAU_PROFILE("FLOATTYPE LVecBase4::length_squared()", " ", TAU_USER); @@ -481,12 +390,9 @@ length_squared() const { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::length -// Access: Published -// Description: Returns the length of the vector, by the Pythagorean -// theorem. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the vector, by the Pythagorean theorem. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVecBase4):: length() const { TAU_PROFILE("FLOATTYPE LVecBase4::length()", " ", TAU_USER); @@ -497,13 +403,10 @@ length() const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::normalize -// Access: Published -// Description: Normalizes the vector in place. Returns true if the -// vector was normalized, false if it was a zero-length -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector in place. Returns true if the vector was normalized, + * false if it was a zero-length vector. + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: normalize() { FLOATTYPE l2 = length_squared(); @@ -518,13 +421,10 @@ normalize() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: normalized() const { FLOATTYPE l2 = length_squared(); @@ -534,39 +434,30 @@ normalized() const { return (*this) / csqrt(l2); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: project(const FLOATNAME(LVecBase4) &onto) const { return onto * (dot(onto) / onto.length_squared()); } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator < -// Access: Published -// Description: This performs a lexicographical comparison. It's of -// questionable mathematical meaning, but sometimes has -// a practical purpose for sorting unique vectors, -// especially in an STL container. Also see -// compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This performs a lexicographical comparison. It's of questionable + * mathematical meaning, but sometimes has a practical purpose for sorting + * unique vectors, especially in an STL container. Also see compare_to(). + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: operator < (const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("bool LVecBase4::operator <(const LVecBase4 &)", " ", TAU_USER); return (compare_to(other) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: operator == (const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("bool LVecBase4::operator ==(const LVecBase4 &)", " ", TAU_USER); @@ -580,22 +471,18 @@ operator == (const FLOATNAME(LVecBase4) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: operator != (const FLOATNAME(LVecBase4) &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::compare_to -// Access: Published -// Description: This flavor of compare_to uses a default threshold -// value based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of compare_to uses a default threshold value based on the + * numeric type. + */ INLINE_LINMATH int FLOATNAME(LVecBase4):: compare_to(const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &)", " ", TAU_USER); @@ -618,22 +505,18 @@ compare_to(const FLOATNAME(LVecBase4) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase4):: get_hash() const { TAU_PROFILE("size_t LVecBase4::get_hash()", " ", TAU_USER); return add_hash(0); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase4):: add_hash(size_t hash) const { TAU_PROFILE("size_t LVecBase4::add_hash(size_t)", " ", TAU_USER); @@ -649,11 +532,9 @@ add_hash(size_t hash) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: generate_hash(ChecksumHashGenerator &hashgen) const { TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &)", " ", TAU_USER); @@ -668,15 +549,11 @@ generate_hash(ChecksumHashGenerator &hashgen) const { } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::compare_to -// Access: Published -// Description: Sorts vectors lexicographically, componentwise. -// Returns a number less than 0 if this vector sorts -// before the other one, greater than zero if it sorts -// after, 0 if they are equivalent (within the indicated -// tolerance). -//////////////////////////////////////////////////////////////////// +/** + * Sorts vectors lexicographically, componentwise. Returns a number less than + * 0 if this vector sorts before the other one, greater than zero if it sorts + * after, 0 if they are equivalent (within the indicated tolerance). + */ INLINE_LINMATH int FLOATNAME(LVecBase4):: compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { TAU_PROFILE("int LVecBase4::compare_to(const LVecBase4 &, FLOATTYPE)", " ", TAU_USER); @@ -695,22 +572,18 @@ compare_to(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::get_hash -// Access: Published -// Description: Returns a suitable hash for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash for phash_map. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase4):: get_hash(FLOATTYPE threshold) const { TAU_PROFILE("size_t LVecBase4::get_hash(FLOATTYPE)", " ", TAU_USER); return add_hash(0, threshold); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::add_hash -// Access: Published -// Description: Adds the vector into the running hash. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector into the running hash. + */ INLINE_LINMATH size_t FLOATNAME(LVecBase4):: add_hash(size_t hash, FLOATTYPE threshold) const { TAU_PROFILE("LVecBase4::add_hash(size_t, FLOATTYPE)", " ", TAU_USER); @@ -722,11 +595,9 @@ add_hash(size_t hash, FLOATTYPE threshold) const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::generate_hash -// Access: Published -// Description: Adds the vector to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the vector to the indicated hash generator. + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { TAU_PROFILE("LVecBase4::generate_hash(ChecksumHashGenerator &, FLOATTYPE)", " ", TAU_USER); @@ -737,11 +608,9 @@ generate_hash(ChecksumHashGenerator &hashgen, FLOATTYPE threshold) const { } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::unary - -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: operator - () const { #ifdef HAVE_EIGEN @@ -751,11 +620,9 @@ operator - () const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::vector + vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: operator + (const FLOATNAME(LVecBase4) &other) const { #ifdef HAVE_EIGEN @@ -768,11 +635,9 @@ operator + (const FLOATNAME(LVecBase4) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::vector - vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: operator - (const FLOATNAME(LVecBase4) &other) const { #ifdef HAVE_EIGEN @@ -785,11 +650,9 @@ operator - (const FLOATNAME(LVecBase4) &other) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::vector * scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: operator * (FLOATTYPE scalar) const { #ifdef HAVE_EIGEN @@ -802,11 +665,9 @@ operator * (FLOATTYPE scalar) const { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::vector / scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: operator / (FLOATTYPE scalar) const { #ifdef FLOATTYPE_IS_INT @@ -820,11 +681,9 @@ operator / (FLOATTYPE scalar) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator += -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: operator += (const FLOATNAME(LVecBase4) &other) { #ifdef HAVE_EIGEN @@ -837,11 +696,9 @@ operator += (const FLOATNAME(LVecBase4) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator -= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: operator -= (const FLOATNAME(LVecBase4) &other) { #ifdef HAVE_EIGEN @@ -854,11 +711,9 @@ operator -= (const FLOATNAME(LVecBase4) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator *= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: operator *= (FLOATTYPE scalar) { #ifdef HAVE_EIGEN @@ -871,11 +726,9 @@ operator *= (FLOATTYPE scalar) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::operator /= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: operator /= (FLOATTYPE scalar) { #ifdef FLOATTYPE_IS_INT @@ -889,11 +742,9 @@ operator /= (FLOATTYPE scalar) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::componentwise_mult -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: componentwise_mult(const FLOATNAME(LVecBase4) &other) { #ifdef HAVE_EIGEN @@ -906,11 +757,9 @@ componentwise_mult(const FLOATNAME(LVecBase4) &other) { #endif // HAVE_EIGEN } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::fmax -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: fmax(const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("LVecBase4::fmax()", " ", TAU_USER); @@ -924,11 +773,9 @@ fmax(const FLOATNAME(LVecBase4) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::fmin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVecBase4):: fmin(const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("LVecBase4::fmin()", " ", TAU_USER); @@ -942,12 +789,10 @@ fmin(const FLOATNAME(LVecBase4) &other) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::almost_equal -// Access: Published -// Description: Returns true if two vectors are memberwise equal -// within a specified tolerance. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two vectors are memberwise equal within a specified + * tolerance. + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &, FLOATTYPE)", " ", TAU_USER); @@ -957,23 +802,19 @@ almost_equal(const FLOATNAME(LVecBase4) &other, FLOATTYPE threshold) const { IS_THRESHOLD_EQUAL(_v(3), other._v(3), threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::almost_equal -// Access: Published -// Description: Returns true if two vectors are memberwise equal -// within a default tolerance based on the numeric type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two vectors are memberwise equal within a default tolerance + * based on the numeric type. + */ INLINE_LINMATH bool FLOATNAME(LVecBase4):: almost_equal(const FLOATNAME(LVecBase4) &other) const { TAU_PROFILE("bool LVecBase4::almost_equal(LVecBase4 &)", " ", TAU_USER); return almost_equal(other, NEARLY_ZERO(FLOATTYPE)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: output(ostream &out) const { out << MAYBE_ZERO(_v(0)) << " " @@ -982,17 +823,13 @@ output(ostream &out) const { << MAYBE_ZERO(_v(3)); } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::write_datagram_fixed -// Access: Published -// Description: Writes the vector to the Datagram using add_float32() -// or add_float64(), depending on the type of floats in -// the vector, regardless of the setting of -// Datagram::set_stdfloat_double(). This is appropriate -// when you want to write a fixed-width value to the -// datagram, especially when you are not writing a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vector to the Datagram using add_float32() or add_float64(), + * depending on the type of floats in the vector, regardless of the setting of + * Datagram::set_stdfloat_double(). This is appropriate when you want to + * write a fixed-width value to the datagram, especially when you are not + * writing a bam file. + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: write_datagram_fixed(Datagram &destination) const { #if FLOATTOKEN == 'i' @@ -1013,12 +850,10 @@ write_datagram_fixed(Datagram &destination) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::read_datagram_fixed -// Access: Published -// Description: Reads the vector from the Datagram using get_float32() -// or get_float64(). See write_datagram_fixed(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the vector from the Datagram using get_float32() or get_float64(). + * See write_datagram_fixed(). + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: read_datagram_fixed(DatagramIterator &source) { #if FLOATTOKEN == 'i' @@ -1039,14 +874,11 @@ read_datagram_fixed(DatagramIterator &source) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::write_datagram -// Access: Published -// Description: Writes the vector to the Datagram using -// add_stdfloat(). This is appropriate when you want to -// write the vector using the standard width setting, -// especially when you are writing a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the vector to the Datagram using add_stdfloat(). This is + * appropriate when you want to write the vector using the standard width + * setting, especially when you are writing a bam file. + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: write_datagram(Datagram &destination) const { #if FLOATTOKEN == 'i' @@ -1062,11 +894,9 @@ write_datagram(Datagram &destination) const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::read_datagram -// Access: Published -// Description: Reads the vector from the Datagram using get_stdfloat(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the vector from the Datagram using get_stdfloat(). + */ INLINE_LINMATH void FLOATNAME(LVecBase4):: read_datagram(DatagramIterator &source) { #if FLOATTOKEN == 'i' @@ -1082,32 +912,26 @@ read_datagram(DatagramIterator &source) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLVecBase4):: FLOATNAME(UnalignedLVecBase4)(const FLOATNAME(LVecBase4) ©) { set(copy[0], copy[1], copy[2], copy[3]); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(UnalignedLVecBase4):: FLOATNAME(UnalignedLVecBase4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { TAU_PROFILE("UnalignedLVecBase4::UnalignedLVecBase4(FLOATTYPE, ...)", " ", TAU_USER); set(x, y, z, w); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH void FLOATNAME(UnalignedLVecBase4):: set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { TAU_PROFILE("void UnalignedLVecBase4::set()", " ", TAU_USER); @@ -1117,55 +941,44 @@ set(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) { _v(3) = w; } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE FLOATNAME(UnalignedLVecBase4):: operator [](int i) const { nassertr(i >= 0 && i < 4, 0); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::Indexing Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATTYPE &FLOATNAME(UnalignedLVecBase4):: operator [](int i) { nassertr(i >= 0 && i < 4, _v(0)); return _v(i); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::size -// Access: Public, Static -// Description: Returns 4: the number of components of a LVecBase4. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4: the number of components of a LVecBase4. + */ CONSTEXPR int FLOATNAME(UnalignedLVecBase4):: size() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::get_data -// Access: Public -// Description: Returns the address of the first of the three data -// elements in the vector. The remaining elements -// occupy the next positions consecutively in memory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address of the first of the three data elements in the vector. + * The remaining elements occupy the next positions consecutively in memory. + */ INLINE_LINMATH const FLOATTYPE *FLOATNAME(UnalignedLVecBase4):: get_data() const { return &_v(0); } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::get_num_components -// Access: Public -// Description: Returns the number of elements in the vector, 4. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the vector, 4. + */ CONSTEXPR int FLOATNAME(UnalignedLVecBase4):: get_num_components() { return 4; diff --git a/panda/src/linmath/lvecBase4_src.cxx b/panda/src/linmath/lvecBase4_src.cxx index b5465bce6b..bbf591b51b 100644 --- a/panda/src/linmath/lvecBase4_src.cxx +++ b/panda/src/linmath/lvecBase4_src.cxx @@ -1,16 +1,15 @@ -// Filename: lvecBase4_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase4_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LVecBase4)::_type_handle; TypeHandle FLOATNAME(UnalignedLVecBase4)::_type_handle; @@ -26,11 +25,9 @@ const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_unit_z = const FLOATNAME(LVecBase4) FLOATNAME(LVecBase4)::_unit_w = FLOATNAME(LVecBase4)(0, 0, 0, 1); -//////////////////////////////////////////////////////////////////// -// Function: LVecBase4::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LVecBase4):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -40,11 +37,9 @@ init_type() { } -//////////////////////////////////////////////////////////////////// -// Function: UnalignedLVecBase4::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(UnalignedLVecBase4):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -52,4 +47,3 @@ init_type() { register_type(_type_handle, FLOATNAME_STR(UnalignedLVecBase4)); } } - diff --git a/panda/src/linmath/lvecBase4_src.h b/panda/src/linmath/lvecBase4_src.h index 3f43170eae..21afc8b182 100644 --- a/panda/src/linmath/lvecBase4_src.h +++ b/panda/src/linmath/lvecBase4_src.h @@ -1,16 +1,15 @@ -// Filename: lvecBase4_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvecBase4_src.h + * @author drose + * @date 2000-03-08 + */ class FLOATNAME(LVecBase2); class FLOATNAME(LVecBase3); @@ -18,11 +17,9 @@ class FLOATNAME(LPoint3); class FLOATNAME(LVector3); class FLOATNAME(UnalignedLVecBase4); -//////////////////////////////////////////////////////////////////// -// Class : LVecBase4 -// Description : This is the base class for all three-component -// vectors and points. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for all three-component vectors and points. + */ class EXPCL_PANDA_LINMATH ALIGN_LINMATH FLOATNAME(LVecBase4) { PUBLISHED: typedef FLOATTYPE numeric_type; @@ -88,10 +85,9 @@ PUBLISHED: MAKE_PROPERTY(xyz, get_xyz); MAKE_PROPERTY(xy, get_xy); - // These next functions add to an existing value. - // i.e. foo.set_x(foo.get_x() + value) - // These are useful to reduce overhead in scripting - // languages: + // These next functions add to an existing value. i.e. + // foo.set_x(foo.get_x() + value) These are useful to reduce overhead in + // scripting languages: INLINE_LINMATH void add_to_cell(int i, FLOATTYPE value); INLINE_LINMATH void add_x(FLOATTYPE value); INLINE_LINMATH void add_y(FLOATTYPE value); @@ -180,10 +176,10 @@ PUBLISHED: public: // The underlying implementation is via the Eigen library, if available. - // Unlike LVecBase2 and LVecBase3, we fully align LVecBase4 to - // 16-byte boundaries, to take advantage of SSE2 optimizations when - // available. Sometimes this alignment requirement is inconvenient, - // so we also provide UnalignedLVecBase4, below. + // Unlike LVecBase2 and LVecBase3, we fully align LVecBase4 to 16-byte + // boundaries, to take advantage of SSE2 optimizations when available. + // Sometimes this alignment requirement is inconvenient, so we also provide + // UnalignedLVecBase4, below. typedef LINMATH_MATRIX(FLOATTYPE, 1, 4) EVector4; EVector4 _v; @@ -206,18 +202,15 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : UnalignedLVecBase4 -// Description : This is an "unaligned" LVecBase4. It has no -// functionality other than to store numbers, and it -// will pack them in as tightly as possible, avoiding -// any SSE2 alignment requirements shared by the primary -// LVecBase4 class. -// -// Use it only when you need to pack numbers tightly -// without respect to alignment, and then copy it to a -// proper LVecBase4 to get actual use from it. -//////////////////////////////////////////////////////////////////// +/** + * This is an "unaligned" LVecBase4. It has no functionality other than to + * store numbers, and it will pack them in as tightly as possible, avoiding + * any SSE2 alignment requirements shared by the primary LVecBase4 class. + * + * Use it only when you need to pack numbers tightly without respect to + * alignment, and then copy it to a proper LVecBase4 to get actual use from + * it. + */ class EXPCL_PANDA_LINMATH FLOATNAME(UnalignedLVecBase4) { PUBLISHED: enum { diff --git a/panda/src/linmath/lvector2.cxx b/panda/src/linmath/lvector2.cxx index ac3193eebd..dffde351d6 100644 --- a/panda/src/linmath/lvector2.cxx +++ b/panda/src/linmath/lvector2.cxx @@ -1,16 +1,15 @@ -// Filename: lvector2.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2.cxx + * @author drose + * @date 2000-03-08 + */ #include "lvector2.h" diff --git a/panda/src/linmath/lvector2.h b/panda/src/linmath/lvector2.h index 61cc423310..7daa9489da 100644 --- a/panda/src/linmath/lvector2.h +++ b/panda/src/linmath/lvector2.h @@ -1,16 +1,15 @@ -// Filename: lvector2.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVECTOR2_H #define LVECTOR2_H diff --git a/panda/src/linmath/lvector2_ext.h b/panda/src/linmath/lvector2_ext.h index bed698e8f1..03765ddccf 100644 --- a/panda/src/linmath/lvector2_ext.h +++ b/panda/src/linmath/lvector2_ext.h @@ -1,16 +1,15 @@ -// Filename: lvector2_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LVECTOR2_EXT_H #define LVECTOR2_EXT_H diff --git a/panda/src/linmath/lvector2_ext_src.I b/panda/src/linmath/lvector2_ext_src.I index 4e52774d3c..b08f96f217 100644 --- a/panda/src/linmath/lvector2_ext_src.I +++ b/panda/src/linmath/lvector2_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lvector2_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVector2::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -36,11 +33,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -86,11 +81,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase2. diff --git a/panda/src/linmath/lvector2_ext_src.h b/panda/src/linmath/lvector2_ext_src.h index 4a2888e7d4..fb16cbda9d 100644 --- a/panda/src/linmath/lvector2_ext_src.h +++ b/panda/src/linmath/lvector2_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvector2_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVector2, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVector2, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvector2_src.I b/panda/src/linmath/lvector2_src.I index 19095a6a46..68648cf93a 100644 --- a/panda/src/linmath/lvector2_src.I +++ b/panda/src/linmath/lvector2_src.I @@ -1,194 +1,155 @@ -// Filename: lvector2_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVector2::Constructor -// Access: Public -// Description: Constructs a new LVector2 from a LVecBase2 -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LVector2 from a LVecBase2 + */ INLINE_LINMATH FLOATNAME(LVector2):: FLOATNAME(LVector2)(const FLOATNAME(LVecBase2)& copy) : FLOATNAME(LVecBase2)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::Constructor -// Access: Public -// Description: Constructs a new LVector2 with all components set -// to the fill value. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LVector2 with all components set to the fill value. + */ INLINE_LINMATH FLOATNAME(LVector2):: FLOATNAME(LVector2)(FLOATTYPE fill_value) : FLOATNAME(LVecBase2)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2):: FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y) : FLOATNAME(LVecBase2)(x, y) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::zero Named Constructor -// Access: Public -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVector2) &FLOATNAME(LVector2):: zero() { return (const FLOATNAME(LVector2) &)FLOATNAME(LVecBase2)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVector2) &FLOATNAME(LVector2):: unit_x() { return (const FLOATNAME(LVector2) &)FLOATNAME(LVecBase2)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVector2) &FLOATNAME(LVector2):: unit_y() { return (const FLOATNAME(LVector2) &)FLOATNAME(LVecBase2)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: operator - () const { return FLOATNAME(LVecBase2)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::vector + vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVector2):: operator + (const FLOATNAME(LVecBase2) &other) const { return FLOATNAME(LVecBase2)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::vector + vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: operator + (const FLOATNAME(LVector2) &other) const { return FLOATNAME(LVecBase2)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::vector - vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase2) FLOATNAME(LVector2):: operator - (const FLOATNAME(LVecBase2) &other) const { return FLOATNAME(LVecBase2)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::vector - vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: operator - (const FLOATNAME(LVector2) &other) const { return FLOATNAME(LVecBase2)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::operator * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LVector2)(FLOATNAME(LVecBase2)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::operator / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LVector2)(FLOATNAME(LVecBase2)::operator / (scalar)); } #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVector2::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: normalized() const { return FLOATNAME(LVecBase2)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector2):: project(const FLOATNAME(LVecBase2) &onto) const { return FLOATNAME(LVecBase2)::project(onto); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::signed_angle_rad -// Access: Published -// Description: returns the signed angled between two vectors. -// normalization is NOT necessary -//////////////////////////////////////////////////////////////////// +/** + * returns the signed angled between two vectors. normalization is NOT + * necessary + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector2):: signed_angle_rad(const FLOATNAME(LVector2) &other) const { return catan2((_v(0)*other._v(1))-(_v(1)*other._v(0)), dot(other)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector2::signed_angle_deg -// Access: Published -// Description: returns the signed angled between two vectors. -// normalization is NOT necessary -//////////////////////////////////////////////////////////////////// +/** + * returns the signed angled between two vectors. normalization is NOT + * necessary + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector2):: signed_angle_deg(const FLOATNAME(LVector2) &other) const { return rad_2_deg(signed_angle_rad(other)); diff --git a/panda/src/linmath/lvector2_src.cxx b/panda/src/linmath/lvector2_src.cxx index 9627c0f396..5b6d60096b 100644 --- a/panda/src/linmath/lvector2_src.cxx +++ b/panda/src/linmath/lvector2_src.cxx @@ -1,24 +1,21 @@ -// Filename: lvector2_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LVector2)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LVector2::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LVector2):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,5 +24,3 @@ init_type() { FLOATNAME(LVecBase2)::get_class_type()); } } - - diff --git a/panda/src/linmath/lvector2_src.h b/panda/src/linmath/lvector2_src.h index 3866be0269..4a78cc7519 100644 --- a/panda/src/linmath/lvector2_src.h +++ b/panda/src/linmath/lvector2_src.h @@ -1,21 +1,19 @@ -// Filename: lvector2_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector2_src.h + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Class : LVector2 -// Description : This is a two-component vector offset. -//////////////////////////////////////////////////////////////////// +/** + * This is a two-component vector offset. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LVector2) : public FLOATNAME(LVecBase2) { PUBLISHED: diff --git a/panda/src/linmath/lvector3.cxx b/panda/src/linmath/lvector3.cxx index ad4857ebff..a93357f99b 100644 --- a/panda/src/linmath/lvector3.cxx +++ b/panda/src/linmath/lvector3.cxx @@ -1,16 +1,15 @@ -// Filename: lvector3.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3.cxx + * @author drose + * @date 2000-03-08 + */ #include "lvector3.h" diff --git a/panda/src/linmath/lvector3.h b/panda/src/linmath/lvector3.h index bf6e7659b2..f8740f29a7 100644 --- a/panda/src/linmath/lvector3.h +++ b/panda/src/linmath/lvector3.h @@ -1,16 +1,15 @@ -// Filename: lvector3.h -// Created by: drose (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3.h + * @author drose + * @date 1999-09-24 + */ #ifndef LVECTOR3_H #define LVECTOR3_H diff --git a/panda/src/linmath/lvector3_ext.h b/panda/src/linmath/lvector3_ext.h index 3f135e1844..5a0113c8e2 100644 --- a/panda/src/linmath/lvector3_ext.h +++ b/panda/src/linmath/lvector3_ext.h @@ -1,16 +1,15 @@ -// Filename: lvector3_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LVECTOR3_EXT_H #define LVECTOR3_EXT_H diff --git a/panda/src/linmath/lvector3_ext_src.I b/panda/src/linmath/lvector3_ext_src.I index f7fc436f55..36012e7917 100644 --- a/panda/src/linmath/lvector3_ext_src.I +++ b/panda/src/linmath/lvector3_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lvector3_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVector3::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -37,11 +34,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -87,11 +82,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase3. diff --git a/panda/src/linmath/lvector3_ext_src.h b/panda/src/linmath/lvector3_ext_src.h index a4c45fbe9a..4283e61d36 100644 --- a/panda/src/linmath/lvector3_ext_src.h +++ b/panda/src/linmath/lvector3_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvector3_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVector3, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVector3, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvector3_src.I b/panda/src/linmath/lvector3_src.I index ff047ff63e..3e2404f272 100644 --- a/panda/src/linmath/lvector3_src.I +++ b/panda/src/linmath/lvector3_src.I @@ -1,189 +1,153 @@ -// Filename: lvector3_src.I -// Created by: drose (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_src.I + * @author drose + * @date 1999-09-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVector3::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3):: FLOATNAME(LVector3)(const FLOATNAME(LVecBase3) ©) : FLOATNAME(LVecBase3)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3):: FLOATNAME(LVector3)(FLOATTYPE fill_value) : FLOATNAME(LVecBase3)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3):: FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) : FLOATNAME(LVecBase3)(x, y, z) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3):: FLOATNAME(LVector3)(const FLOATNAME(LVecBase2) ©, FLOATTYPE z) : FLOATNAME(LVecBase3)(copy, z) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::zero Named Constructor -// Access: Published -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVector3) &FLOATNAME(LVector3):: zero() { return (const FLOATNAME(LVector3) &)FLOATNAME(LVecBase3)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::unit_x Named Constructor -// Access: Published -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVector3) &FLOATNAME(LVector3):: unit_x() { return (const FLOATNAME(LVector3) &)FLOATNAME(LVecBase3)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::unit_y Named Constructor -// Access: Published -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVector3) &FLOATNAME(LVector3):: unit_y() { return (const FLOATNAME(LVector3) &)FLOATNAME(LVecBase3)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::unit_z Named Constructor -// Access: Published -// Description: Returns a unit Z vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z vector. + */ INLINE_LINMATH const FLOATNAME(LVector3) &FLOATNAME(LVector3):: unit_z() { return (const FLOATNAME(LVector3) &)FLOATNAME(LVecBase3)::unit_z(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::get_xy -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3):: get_xy() const { return FLOATNAME(LVector2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::get_xz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// first and last components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the first and last components + * of this vector. + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3):: get_xz() const { return FLOATNAME(LVector2)(_v(0), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::get_yz -// Access: Public -// Description: Returns a 2-component vector that shares just the -// last two components of this vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a 2-component vector that shares just the last two components of + * this vector. + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector3):: get_yz() const { return FLOATNAME(LVector2)(_v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::unary - -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: operator - () const { return FLOATNAME(LVecBase3)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::vector + vecbase -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVector3):: operator + (const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::vector + vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: operator + (const FLOATNAME(LVector3) &other) const { return FLOATNAME(LVecBase3)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::vector - vecbase -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase3) FLOATNAME(LVector3):: operator - (const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::vector - vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: operator - (const FLOATNAME(LVector3) &other) const { return FLOATNAME(LVecBase3)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::cross -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: cross(const FLOATNAME(LVecBase3) &other) const { return FLOATNAME(LVecBase3)::cross(other); @@ -191,41 +155,32 @@ cross(const FLOATNAME(LVecBase3) &other) const { #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVector3::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: normalized() const { return FLOATNAME(LVecBase3)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: project(const FLOATNAME(LVecBase3) &onto) const { return FLOATNAME(LVecBase3)::project(onto); } -//////////////////////////////////////////////////////////////////// -// Function: LVector::angle_rad -// Access: Published -// Description: Returns the unsigned angle between this vector and -// the other one, expressed in radians. Both vectors -// should be initially normalized. -//////////////////////////////////////////////////////////////////// +/** + * Returns the unsigned angle between this vector and the other one, expressed + * in radians. Both vectors should be initially normalized. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: angle_rad(const FLOATNAME(LVector3) &other) const { - // This algorithm yields better results than acos(dot(other)), which - // behaves poorly as dot(other) approaches 1.0. + // This algorithm yields better results than acos(dot(other)), which behaves + // poorly as dot(other) approaches 1.0. if (dot(other) < 0.0f) { FLOATTYPE a = ((*this)+other).length() / 2.0f; return MathNumbers::cpi((FLOATTYPE)0.0f) - 2.0f * casin(min(a, (FLOATTYPE)1.0)); @@ -235,29 +190,22 @@ angle_rad(const FLOATNAME(LVector3) &other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LVector::angle_deg -// Access: Published -// Description: Returns the angle between this vector and the other -// one, expressed in degrees. Both vectors should be -// initially normalized. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle between this vector and the other one, expressed in + * degrees. Both vectors should be initially normalized. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: angle_deg(const FLOATNAME(LVector3) &other) const { return rad_2_deg(angle_rad(other)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector::signed_angle_rad -// Access: Published -// Description: returns the signed angle between two vectors. -// The angle is positive if the rotation from this -// vector to other is clockwise when looking in the -// direction of the ref vector. -// -// Vectors (except the ref vector) should be initially -// normalized. -//////////////////////////////////////////////////////////////////// +/** + * returns the signed angle between two vectors. The angle is positive if the + * rotation from this vector to other is clockwise when looking in the + * direction of the ref vector. + * + * Vectors (except the ref vector) should be initially normalized. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: signed_angle_rad(const FLOATNAME(LVector3) &other, const FLOATNAME(LVector3) &ref) const { @@ -268,70 +216,55 @@ signed_angle_rad(const FLOATNAME(LVector3) &other, return angle; } -//////////////////////////////////////////////////////////////////// -// Function: LVector::signed_angle_deg -// Access: Published -// Description: Returns the signed angle between two vectors. -// The angle is positive if the rotation from this -// vector to other is clockwise when looking in the -// direction of the ref vector. -// -// Vectors (except the ref vector) should be initially -// normalized. -//////////////////////////////////////////////////////////////////// +/** + * Returns the signed angle between two vectors. The angle is positive if the + * rotation from this vector to other is clockwise when looking in the + * direction of the ref vector. + * + * Vectors (except the ref vector) should be initially normalized. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: signed_angle_deg(const FLOATNAME(LVector3) &other, const FLOATNAME(LVector3) &ref) const { return rad_2_deg(signed_angle_rad(other, ref)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector::relative_angle_rad -// Access: Published -// Description: This method is deprecated. Do not use. -//////////////////////////////////////////////////////////////////// +/** + * This method is deprecated. Do not use. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: relative_angle_rad(const FLOATNAME(LVector3) &other) const { return atan2((_v(0)*other._v(1))-(_v(1)*other._v(0)), dot(other)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector::relative_angle_deg -// Access: Published -// Description: This method is deprecated. Do not use. -//////////////////////////////////////////////////////////////////// +/** + * This method is deprecated. Do not use. + */ INLINE_LINMATH FLOATTYPE FLOATNAME(LVector3):: relative_angle_deg(const FLOATNAME(LVector3) &other) const { return relative_angle_rad(other) * FLOATCONST(180.0) / FLOATCONST(3.1415926535); } #endif // FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVector3::operator * scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LVector3)(FLOATNAME(LVecBase3)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::operator / scalar -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LVector3)(FLOATNAME(LVecBase3)::operator / (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::up -// Access: Published, Static -// Description: Returns the up vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the up vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: up(CoordinateSystem cs) { if (cs == CS_default) { @@ -353,23 +286,17 @@ up(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::right -// Access: Published, Static -// Description: Returns the right vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the right vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: right(CoordinateSystem) { return FLOATNAME(LVector3)(1, 0, 0); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::forward -// Access: Published, Static -// Description: Returns the forward vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the forward vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: forward(CoordinateSystem cs) { if (cs == CS_default) { @@ -395,46 +322,34 @@ forward(CoordinateSystem cs) { } } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::down -// Access: Published, Static -// Description: Returns the down vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the down vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: down(CoordinateSystem cs) { return -up(cs); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::left -// Access: Published, Static -// Description: Returns the left vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the left vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: left(CoordinateSystem cs) { return -right(cs); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::back -// Access: Published, Static -// Description: Returns the back vector for the given coordinate -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the back vector for the given coordinate system. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: back(CoordinateSystem cs) { return -forward(cs); } -//////////////////////////////////////////////////////////////////// -// Function: LVector3::rfu -// Access: Published, Static -// Description: Returns a vector that is described by its right, -// forward, and up components, in whatever way the -// coordinate system represents that vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a vector that is described by its right, forward, and up + * components, in whatever way the coordinate system represents that vector. + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector3):: rfu(FLOATTYPE right_v, FLOATTYPE fwd_v, FLOATTYPE up_v, CoordinateSystem cs) { diff --git a/panda/src/linmath/lvector3_src.cxx b/panda/src/linmath/lvector3_src.cxx index d0c382289f..d2f087cfb6 100644 --- a/panda/src/linmath/lvector3_src.cxx +++ b/panda/src/linmath/lvector3_src.cxx @@ -1,24 +1,21 @@ -// Filename: lvector3_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LVector3)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LVector3::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LVector3):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,5 +24,3 @@ init_type() { FLOATNAME(LVecBase3)::get_class_type()); } } - - diff --git a/panda/src/linmath/lvector3_src.h b/panda/src/linmath/lvector3_src.h index 47ea8a0661..e8f010cec7 100644 --- a/panda/src/linmath/lvector3_src.h +++ b/panda/src/linmath/lvector3_src.h @@ -1,27 +1,23 @@ -// Filename: lvector3_src.h -// Created by: drose (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector3_src.h + * @author drose + * @date 1999-09-24 + */ -//////////////////////////////////////////////////////////////////// -// Class : LVector3 -// Description : This is a three-component vector distance (as opposed -// to a three-component point, which represents a -// particular point in space). Some of the methods are -// slightly different between LPoint3 and LVector3; in -// particular, subtraction of two points yields a -// vector, while addition of a vector and a point yields -// a point. -//////////////////////////////////////////////////////////////////// +/** + * This is a three-component vector distance (as opposed to a three-component + * point, which represents a particular point in space). Some of the methods + * are slightly different between LPoint3 and LVector3; in particular, + * subtraction of two points yields a vector, while addition of a vector and a + * point yields a point. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LVector3) : public FLOATNAME(LVecBase3) { PUBLISHED: INLINE_LINMATH FLOATNAME(LVector3)() DEFAULT_CTOR; @@ -85,7 +81,7 @@ PUBLISHED: INLINE_LINMATH static FLOATNAME(LVector3) left(CoordinateSystem cs = CS_default); INLINE_LINMATH static FLOATNAME(LVector3) back(CoordinateSystem cs = CS_default); -// INLINE_LINMATH static FLOATNAME(LVector3) & rfu(FLOATTYPE right, +// INLINE_LINMATH static FLOATNAME(LVector3) & rfu(FLOATTYPE right, INLINE_LINMATH static FLOATNAME(LVector3) rfu(FLOATTYPE right, FLOATTYPE fwd,FLOATTYPE up, CoordinateSystem cs = CS_default); diff --git a/panda/src/linmath/lvector4.cxx b/panda/src/linmath/lvector4.cxx index 68f8940dc1..2487ee46b0 100644 --- a/panda/src/linmath/lvector4.cxx +++ b/panda/src/linmath/lvector4.cxx @@ -1,16 +1,15 @@ -// Filename: lvector4.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4.cxx + * @author drose + * @date 2000-03-08 + */ #include "lvector4.h" diff --git a/panda/src/linmath/lvector4.h b/panda/src/linmath/lvector4.h index 3e36792309..a470536085 100644 --- a/panda/src/linmath/lvector4.h +++ b/panda/src/linmath/lvector4.h @@ -1,16 +1,15 @@ -// Filename: lvector4.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4.h + * @author drose + * @date 2000-03-08 + */ #ifndef LVECTOR4_H #define LVECTOR4_H diff --git a/panda/src/linmath/lvector4_ext.h b/panda/src/linmath/lvector4_ext.h index 0580432f6f..0def006813 100644 --- a/panda/src/linmath/lvector4_ext.h +++ b/panda/src/linmath/lvector4_ext.h @@ -1,16 +1,15 @@ -// Filename: lvector4_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef LVECTOR4_EXT_H #define LVECTOR4_EXT_H diff --git a/panda/src/linmath/lvector4_ext_src.I b/panda/src/linmath/lvector4_ext_src.I index 78a651a99e..4964a1fc68 100644 --- a/panda/src/linmath/lvector4_ext_src.I +++ b/panda/src/linmath/lvector4_ext_src.I @@ -1,16 +1,15 @@ -// Filename: lvector4_ext_src.I -// Created by: rdb (02Jan11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_ext_src.I + * @author rdb + * @date 2011-01-02 + */ #ifdef FLOATTYPE_IS_INT #if PY_MAJOR_VERSION >= 3 @@ -22,11 +21,9 @@ #define PY_FROM_FLOATTYPE PyFloat_FromDouble #endif -//////////////////////////////////////////////////////////////////// -// Function: LVector4::__repr__ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH string Extension:: __repr__() const { ostringstream out; @@ -38,11 +35,9 @@ __repr__() const { return out.str(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::__getattr__ -// Access: Published -// Description: This is used to implement swizzle masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement swizzle masks. + */ INLINE_LINMATH PyObject *Extension:: __getattr__(PyObject *self, const string &attr_name) const { #ifndef CPPPARSER @@ -92,11 +87,9 @@ __getattr__(PyObject *self, const string &attr_name) const { return Dtool_Raise_AttributeError(self, attr_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::__setattr__ -// Access: Published -// Description: This is used to implement write masks. -//////////////////////////////////////////////////////////////////// +/** + * This is used to implement write masks. + */ INLINE_LINMATH int Extension:: __setattr__(PyObject *self, const string &attr_name, PyObject *assign) { // Upcall to LVecBase4. diff --git a/panda/src/linmath/lvector4_ext_src.h b/panda/src/linmath/lvector4_ext_src.h index c313e89848..0cc68bca17 100644 --- a/panda/src/linmath/lvector4_ext_src.h +++ b/panda/src/linmath/lvector4_ext_src.h @@ -1,24 +1,20 @@ -// Filename: lvector4_ext_src.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_ext_src.h + * @author rdb + * @date 2013-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// LVector4, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for LVector4, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/linmath/lvector4_src.I b/panda/src/linmath/lvector4_src.I index 25751638f2..a86142cb12 100644 --- a/panda/src/linmath/lvector4_src.I +++ b/panda/src/linmath/lvector4_src.I @@ -1,195 +1,157 @@ -// Filename: lvector4_src.I -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_src.I + * @author drose + * @date 2000-03-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LVector4::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4):: FLOATNAME(LVector4)(const FLOATNAME(LVecBase4) ©) : FLOATNAME(LVecBase4)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4):: FLOATNAME(LVector4)(FLOATTYPE fill_value) : FLOATNAME(LVecBase4)(fill_value) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4):: FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w) : FLOATNAME(LVecBase4)(x, y, z, w) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4):: FLOATNAME(LVector4)(const FLOATNAME(LVecBase3) ©, FLOATTYPE w) : FLOATNAME(LVecBase4)(copy, w) { } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::zero Named Constructor -// Access: Public -// Description: Returns a zero-length vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a zero-length vector. + */ INLINE_LINMATH const FLOATNAME(LVector4) &FLOATNAME(LVector4):: zero() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::unit_x Named Constructor -// Access: Public -// Description: Returns a unit X vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit X vector. + */ INLINE_LINMATH const FLOATNAME(LVector4) &FLOATNAME(LVector4):: unit_x() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::unit_x(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::unit_y Named Constructor -// Access: Public -// Description: Returns a unit Y vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Y vector. + */ INLINE_LINMATH const FLOATNAME(LVector4) &FLOATNAME(LVector4):: unit_y() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::unit_y(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::unit_z Named Constructor -// Access: Public -// Description: Returns a unit Z vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit Z vector. + */ INLINE_LINMATH const FLOATNAME(LVector4) &FLOATNAME(LVector4):: unit_z() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::unit_z(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::unit_w Named Constructor -// Access: Public -// Description: Returns a unit W vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns a unit W vector. + */ INLINE_LINMATH const FLOATNAME(LVector4) &FLOATNAME(LVector4):: unit_w() { return (const FLOATNAME(LVector4) &)FLOATNAME(LVecBase4)::unit_w(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::get_xyz -// Access: Published -// Description: Returns the x, y and z component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x, y and z component of this vector + */ INLINE_LINMATH FLOATNAME(LVector3) FLOATNAME(LVector4):: get_xyz() const { return FLOATNAME(LVector3)(_v(0), _v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::get_xy -// Access: Published -// Description: Returns the x and y component of this vector -//////////////////////////////////////////////////////////////////// +/** + * Returns the x and y component of this vector + */ INLINE_LINMATH FLOATNAME(LVector2) FLOATNAME(LVector4):: get_xy() const { return FLOATNAME(LVector2)(_v(0), _v(1)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::unary - -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: operator - () const { return FLOATNAME(LVecBase4)::operator - (); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::vector + vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVector4):: operator + (const FLOATNAME(LVecBase4) &other) const { return FLOATNAME(LVecBase4)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::vector + vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: operator + (const FLOATNAME(LVector4) &other) const { return FLOATNAME(LVecBase4)::operator + (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::vector - vecbase -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVecBase4) FLOATNAME(LVector4):: operator - (const FLOATNAME(LVecBase4) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::vector - vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: operator - (const FLOATNAME(LVector4) &other) const { return FLOATNAME(LVecBase4)::operator - (other); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::operator * scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: operator * (FLOATTYPE scalar) const { return FLOATNAME(LVector4)(FLOATNAME(LVecBase4)::operator * (scalar)); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::operator / scalar -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: operator / (FLOATTYPE scalar) const { return FLOATNAME(LVector4)(FLOATNAME(LVecBase4)::operator / (scalar)); @@ -197,25 +159,19 @@ operator / (FLOATTYPE scalar) const { #ifndef FLOATTYPE_IS_INT -//////////////////////////////////////////////////////////////////// -// Function: LVector4::normalized -// Access: Published -// Description: Normalizes the vector and returns the normalized -// vector as a copy. If the vector was a zero-length -// vector, a zero length vector will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the vector and returns the normalized vector as a copy. If the + * vector was a zero-length vector, a zero length vector will be returned. + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: normalized() const { return FLOATNAME(LVecBase4)::normalized(); } -//////////////////////////////////////////////////////////////////// -// Function: LVector4::project -// Access: Published -// Description: Returns a new vector representing the projection of -// this vector onto another one. The resulting vector -// will be a scalar multiple of onto. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new vector representing the projection of this vector onto + * another one. The resulting vector will be a scalar multiple of onto. + */ INLINE_LINMATH FLOATNAME(LVector4) FLOATNAME(LVector4):: project(const FLOATNAME(LVecBase4) &onto) const { return FLOATNAME(LVecBase4)::project(onto); diff --git a/panda/src/linmath/lvector4_src.cxx b/panda/src/linmath/lvector4_src.cxx index 615f8eb059..2a8c6e1c13 100644 --- a/panda/src/linmath/lvector4_src.cxx +++ b/panda/src/linmath/lvector4_src.cxx @@ -1,24 +1,21 @@ -// Filename: lvector4_src.cxx -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_src.cxx + * @author drose + * @date 2000-03-08 + */ TypeHandle FLOATNAME(LVector4)::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LVector2::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LVector4):: init_type() { if (_type_handle == TypeHandle::none()) { @@ -27,4 +24,3 @@ init_type() { FLOATNAME(LVecBase4)::get_class_type()); } } - diff --git a/panda/src/linmath/lvector4_src.h b/panda/src/linmath/lvector4_src.h index 722d60d708..4c576e8406 100644 --- a/panda/src/linmath/lvector4_src.h +++ b/panda/src/linmath/lvector4_src.h @@ -1,21 +1,19 @@ -// Filename: lvector4_src.h -// Created by: drose (08Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lvector4_src.h + * @author drose + * @date 2000-03-08 + */ -//////////////////////////////////////////////////////////////////// -// Class : LVector4 -// Description : This is a four-component vector distance. -//////////////////////////////////////////////////////////////////// +/** + * This is a four-component vector distance. + */ class EXPCL_PANDA_LINMATH FLOATNAME(LVector4) : public FLOATNAME(LVecBase4) { PUBLISHED: INLINE_LINMATH FLOATNAME(LVector4)() DEFAULT_CTOR; diff --git a/panda/src/linmath/mathNumbers.I b/panda/src/linmath/mathNumbers.I index 47ad04bb8e..6c2c769ba7 100644 --- a/panda/src/linmath/mathNumbers.I +++ b/panda/src/linmath/mathNumbers.I @@ -1,57 +1,47 @@ -// Filename: mathNumbers.I -// Created by: drose (22Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mathNumbers.I + * @author drose + * @date 2005-01-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MathNumbers::cpi -// Access: Public, Static -// Description: Returns pi as a single-precision or double-precision -// number, according to the type of the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns pi as a single-precision or double-precision number, according to + * the type of the parameter. + */ INLINE float MathNumbers:: cpi(float) { return pi_f; } -//////////////////////////////////////////////////////////////////// -// Function: MathNumbers::cln2 -// Access: Public, Static -// Description: Returns ln(2) as a single-precision or double-precision -// number, according to the type of the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns ln(2) as a single-precision or double-precision number, according + * to the type of the parameter. + */ INLINE float MathNumbers:: cln2(float) { return ln2_f; } -//////////////////////////////////////////////////////////////////// -// Function: MathNumbers::cpi -// Access: Public, Static -// Description: Returns pi as a single-precision or double-precision -// number, according to the type of the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns pi as a single-precision or double-precision number, according to + * the type of the parameter. + */ INLINE double MathNumbers:: cpi(double) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: MathNumbers::cln2 -// Access: Public, Static -// Description: Returns ln(2) as a single-precision or double-precision -// number, according to the type of the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns ln(2) as a single-precision or double-precision number, according + * to the type of the parameter. + */ INLINE double MathNumbers:: cln2(double) { return ln2; diff --git a/panda/src/linmath/mathNumbers.cxx b/panda/src/linmath/mathNumbers.cxx index bf1adb23a7..ff1dcfde06 100644 --- a/panda/src/linmath/mathNumbers.cxx +++ b/panda/src/linmath/mathNumbers.cxx @@ -1,16 +1,15 @@ -// Filename: mathNumbers.cxx -// Created by: mike (24Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mathNumbers.cxx + * @author mike + * @date 1999-09-24 + */ #include "mathNumbers.h" #include @@ -29,4 +28,3 @@ const PN_stdfloat MathNumbers::pi = 4.0 * atan(1.0); const PN_stdfloat MathNumbers::ln2 = log(2.0); const PN_stdfloat MathNumbers::rad_2_deg = 180.0 / MathNumbers::pi_d; const PN_stdfloat MathNumbers::deg_2_rad = MathNumbers::pi_d / 180.0; - diff --git a/panda/src/linmath/mathNumbers.h b/panda/src/linmath/mathNumbers.h index a481f65302..de8dcd9ad9 100644 --- a/panda/src/linmath/mathNumbers.h +++ b/panda/src/linmath/mathNumbers.h @@ -1,16 +1,16 @@ -// Filename: mathNumbers.h -// Created by: mike (23Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mathNumbers.h + * @author mike + * @date 1999-01-23 + */ + #ifndef MATHNUMBERS_H #define MATHNUMBERS_H diff --git a/panda/src/linmath/test_math.cxx b/panda/src/linmath/test_math.cxx index ebc8b4f3a2..41d1d15431 100644 --- a/panda/src/linmath/test_math.cxx +++ b/panda/src/linmath/test_math.cxx @@ -1,16 +1,15 @@ -// Filename: test_math.cxx -// Created by: drose (14Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_math.cxx + * @author drose + * @date 1999-01-14 + */ #include "luse.h" #include "lmatrix.h" @@ -164,4 +163,3 @@ int main(int argc, char *argv[]) { return(0); } - diff --git a/panda/src/mathutil/boundingBox.I b/panda/src/mathutil/boundingBox.I index 9887d75860..2bb67a500e 100644 --- a/panda/src/mathutil/boundingBox.I +++ b/panda/src/mathutil/boundingBox.I @@ -1,32 +1,26 @@ -// Filename: boundingBox.I -// Created by: drose (31May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingBox.I + * @author drose + * @date 2007-05-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::Constructor -// Access: Published -// Description: Constructs an empty box object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty box object. + */ INLINE_MATHUTIL BoundingBox:: BoundingBox() { } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::Constructor -// Access: Published -// Description: Constructs a specific box object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a specific box object. + */ INLINE_MATHUTIL BoundingBox:: BoundingBox(const LPoint3 &min, const LPoint3 &max) : _min(min), _max(max) @@ -39,13 +33,10 @@ BoundingBox(const LPoint3 &min, const LPoint3 &max) : _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_minq -// Access: Public -// Description: An inline accessor for the minimum value. get_min() -// would also work, but it is a virtual non-inline -// method. -//////////////////////////////////////////////////////////////////// +/** + * An inline accessor for the minimum value. get_min() would also work, but + * it is a virtual non-inline method. + */ INLINE_MATHUTIL const LPoint3 &BoundingBox:: get_minq() const { nassertr(!is_empty(), _min); @@ -53,13 +44,10 @@ get_minq() const { return _min; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_maxq -// Access: Public -// Description: An inline accessor for the maximum value. get_max() -// would also work, but it is a virtual non-inline -// method. -//////////////////////////////////////////////////////////////////// +/** + * An inline accessor for the maximum value. get_max() would also work, but + * it is a virtual non-inline method. + */ INLINE_MATHUTIL const LPoint3 &BoundingBox:: get_maxq() const { nassertr(!is_empty(), _max); @@ -67,46 +55,38 @@ get_maxq() const { return _max; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_num_points -// Access: Published -// Description: Returns 8: the number of vertices of a rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns 8: the number of vertices of a rectangular solid. + */ INLINE_MATHUTIL int BoundingBox:: get_num_points() const { return 8; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_point -// Access: Published -// Description: Returns the nth vertex of the rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the rectangular solid. + */ INLINE_MATHUTIL LPoint3 BoundingBox:: get_point(int n) const { nassertr(n >= 0 && n < 8, LPoint3::zero()); - - // We do some trickery assuming that _min and _max are consecutive - // in memory. + + // We do some trickery assuming that _min and _max are consecutive in + // memory. const LPoint3 *a = &_min; return LPoint3(a[(n>>2)&1][0], a[(n>>1)&1][1], a[(n)&1][2]); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_num_planes -// Access: Published -// Description: Returns 6: the number of faces of a rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns 6: the number of faces of a rectangular solid. + */ INLINE_MATHUTIL int BoundingBox:: get_num_planes() const { return 6; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_plane -// Access: Published -// Description: Returns the nth face of the rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth face of the rectangular solid. + */ INLINE_MATHUTIL LPlane BoundingBox:: get_plane(int n) const { nassertr(n >= 0 && n < 6, LPlane()); @@ -115,11 +95,9 @@ get_plane(int n) const { get_point(plane_def[n][2])); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::set_min_max -// Access: Published -// Description: Sets the min and max point of the rectangular solid. -//////////////////////////////////////////////////////////////////// +/** + * Sets the min and max point of the rectangular solid. + */ INLINE_MATHUTIL void BoundingBox:: set_min_max(const LPoint3 &min, const LPoint3 &max) { nassertv(!min.is_nan() && !max.is_nan()); diff --git a/panda/src/mathutil/boundingBox.cxx b/panda/src/mathutil/boundingBox.cxx index 7f1ceba25f..e2ce9c6c6a 100644 --- a/panda/src/mathutil/boundingBox.cxx +++ b/panda/src/mathutil/boundingBox.cxx @@ -1,16 +1,15 @@ -// Filename: boundingBox.cxx -// Created by: drose (31May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingBox.cxx + * @author drose + * @date 2007-05-31 + */ #include "boundingBox.h" #include "boundingSphere.h" @@ -34,21 +33,17 @@ const int BoundingBox::plane_def[6][3] = { TypeHandle BoundingBox::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *BoundingBox:: make_copy() const { return new BoundingBox(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_min -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingBox:: get_min() const { nassertr(!is_empty(), _min); @@ -56,11 +51,9 @@ get_min() const { return _min; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_max -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingBox:: get_max() const { nassertr(!is_empty(), _max); @@ -68,11 +61,9 @@ get_max() const { return _max; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BoundingBox:: get_volume() const { nassertr(!is_infinite(), 0.0f); @@ -84,11 +75,9 @@ get_volume() const { return (_max[0] - _min[0]) * (_max[1] - _min[1]) * (_max[2] - _min[2]); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingBox:: get_approx_center() const { nassertr(!is_empty(), LPoint3::zero()); @@ -96,18 +85,16 @@ get_approx_center() const { return (_min + _max) * 0.5f; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingBox:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { - // We need to transform the eight corners of the cube, and then - // determine the new box. + // We need to transform the eight corners of the cube, and then determine + // the new box. LPoint3 x = get_point(0) * mat; LPoint3 n = x; for (int i = 1; i < 8; ++i) { @@ -120,11 +107,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingBox:: output(ostream &out) const { if (is_empty()) { @@ -136,33 +121,26 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::as_bounding_box -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingBox *BoundingBox:: as_bounding_box() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: extend_other(BoundingVolume *other) const { return other->extend_by_box(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -170,22 +148,18 @@ around_other(BoundingVolume *other, return other->around_boxes(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingBox:: contains_other(const BoundingVolume *other) const { return other->contains_box(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::extend_by_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: extend_by_point(const LPoint3 &point) { nassertr(!point.is_nan(), false); @@ -203,11 +177,9 @@ extend_by_point(const LPoint3 &point) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::extend_by_box -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: extend_by_box(const BoundingBox *box) { nassertr(!box->is_empty() && !box->is_infinite(), false); @@ -219,21 +191,19 @@ extend_by_box(const BoundingBox *box) { _flags = 0; } else { - _min.set(min(_min[0], box->_min[0]), - min(_min[1], box->_min[1]), + _min.set(min(_min[0], box->_min[0]), + min(_min[1], box->_min[1]), min(_min[2], box->_min[2])); - _max.set(max(_max[0], box->_max[0]), - max(_max[1], box->_max[1]), + _max.set(max(_max[0], box->_max[0]), + max(_max[1], box->_max[1]), max(_max[2], box->_max[2])); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::extend_by_finite -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: extend_by_finite(const FiniteBoundingVolume *volume) { nassertr(!volume->is_empty() && !volume->is_infinite(), false); @@ -247,22 +217,20 @@ extend_by_finite(const FiniteBoundingVolume *volume) { _flags = 0; } else { - _min.set(min(_min[0], min1[0]), - min(_min[1], min1[1]), + _min.set(min(_min[0], min1[0]), + min(_min[1], min1[1]), min(_min[2], min1[2])); - _max.set(max(_max[0], max1[0]), - max(_max[1], max1[1]), + _max.set(max(_max[0], max1[0]), + max(_max[1], max1[1]), max(_max[2], max1[2])); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::around_points -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: around_points(const LPoint3 *first, const LPoint3 *last) { nassertr(first != last, false); @@ -327,28 +295,24 @@ around_points(const LPoint3 *first, const LPoint3 *last) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::around_finite -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingBox:: around_finite(const BoundingVolume **first, const BoundingVolume **last) { nassertr(first != last, false); - // We're given a set of bounding volumes, at least the first one of - // which is guaranteed to be finite and nonempty. Some others may - // not be. + // We're given a set of bounding volumes, at least the first one of which is + // guaranteed to be finite and nonempty. Some others may not be. - // First, get the box of all the points to construct a bounding - // box. + // First, get the box of all the points to construct a bounding box. const BoundingVolume **p = first; nassertr(!(*p)->is_empty() && !(*p)->is_infinite(), false); const FiniteBoundingVolume *vol = DCAST(FiniteBoundingVolume, *p); _min = vol->get_min(); _max = vol->get_max(); - + for (++p; p != last; ++p) { nassertr(!(*p)->is_infinite(), false); if (!(*p)->is_empty()) { @@ -368,11 +332,9 @@ around_finite(const BoundingVolume **first, return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingBox:: contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); @@ -394,11 +356,9 @@ contains_point(const LPoint3 &point) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_lineseg -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingBox:: contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); @@ -455,26 +415,24 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { } if ((a_bits & b_bits) != 0) { - // If there are any bits in common, the segment is wholly - // outside the box (both points are on the wrong side of the - // same plane). + // If there are any bits in common, the segment is wholly outside the + // box (both points are on the wrong side of the same plane). return IF_no_intersection; } else if ((a_bits | b_bits) == 0) { - // If there are no bits at all, the segment is wholly within the - // box. + // If there are no bits at all, the segment is wholly within the box. return IF_possible | IF_some | IF_all; } else if (a_bits == 0 || b_bits == 0) { - // If either point is within the box, the segment is partially - // within the box. + // If either point is within the box, the segment is partially within + // the box. return IF_possible | IF_some; } else { unsigned int differ = (a_bits ^ b_bits); if (differ == 0x03 || differ == 0x0c || differ == 0x30) { - // If the line segment stretches straight across the box, the - // segment is partially within. + // If the line segment stretches straight across the box, the segment + // is partially within. return IF_possible | IF_some; } else { @@ -485,13 +443,10 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a box. + */ int BoundingBox:: contains_box(const BoundingBox *box) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -499,7 +454,7 @@ contains_box(const BoundingBox *box) const { const LPoint3 &min1 = box->get_minq(); const LPoint3 &max1 = box->get_maxq(); - + if (min1[0] >= _min[0] && max1[0] <= _max[0] && min1[1] >= _min[1] && max1[1] <= _max[1] && min1[2] >= _min[2] && max1[2] <= _max[2]) { @@ -518,56 +473,45 @@ contains_box(const BoundingBox *box) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int BoundingBox:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { - // First, try the quick bounding-box test. If that's decisive, - // we'll accept it. + // First, try the quick bounding-box test. If that's decisive, we'll accept + // it. int result = contains_finite(hexahedron); if (result == IF_no_intersection || ((result & IF_all) != 0)) { return result; } - // If that was inconclusive, we'll look more closely with the - // somewhat more expensive reverse answer. + // If that was inconclusive, we'll look more closely with the somewhat more + // expensive reverse answer. return hexahedron->contains_box(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a line. + */ int BoundingBox:: contains_line(const BoundingLine *line) const { return line->contains_box(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a plane. + */ int BoundingBox:: contains_plane(const BoundingPlane *plane) const { return plane->contains_box(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingBox::contains_finite -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingBox:: contains_finite(const FiniteBoundingVolume *volume) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -575,7 +519,7 @@ contains_finite(const FiniteBoundingVolume *volume) const { LPoint3 min1 = volume->get_min(); LPoint3 max1 = volume->get_max(); - + if (min1[0] >= _min[0] && max1[0] <= _max[0] && min1[1] >= _min[1] && max1[1] <= _max[1] && min1[2] >= _min[2] && max1[2] <= _max[2]) { diff --git a/panda/src/mathutil/boundingBox.h b/panda/src/mathutil/boundingBox.h index 8d76955e8e..d65aa80dc4 100644 --- a/panda/src/mathutil/boundingBox.h +++ b/panda/src/mathutil/boundingBox.h @@ -1,16 +1,15 @@ -// Filename: boundingBox.h -// Created by: drose (31May07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingBox.h + * @author drose + * @date 2007-05-31 + */ #ifndef BOUNDINGBOX_H #define BOUNDINGBOX_H @@ -20,14 +19,13 @@ #include "finiteBoundingVolume.h" #include "plane.h" -//////////////////////////////////////////////////////////////////// -// Class : BoundingBox -// Description : An axis-aligned bounding box; that is, a minimum and -// maximum coordinate triple. -// -// This box is always axis-aligned. If you need a more -// general bounding box, try BoundingHexahedron. -//////////////////////////////////////////////////////////////////// +/** + * An axis-aligned bounding box; that is, a minimum and maximum coordinate + * triple. + * + * This box is always axis-aligned. If you need a more general bounding box, + * try BoundingHexahedron. + */ class EXPCL_PANDA_MATHUTIL BoundingBox : public FiniteBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingBox(); diff --git a/panda/src/mathutil/boundingHexahedron.I b/panda/src/mathutil/boundingHexahedron.I index 4c0f17f441..0664466ced 100644 --- a/panda/src/mathutil/boundingHexahedron.I +++ b/panda/src/mathutil/boundingHexahedron.I @@ -1,63 +1,51 @@ -// Filename: boundingHexahedron.I -// Created by: drose (03Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingHexahedron.I + * @author drose + * @date 1999-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL BoundingHexahedron:: BoundingHexahedron() { } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_num_points -// Access: Published -// Description: Returns 8: the number of vertices of a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Returns 8: the number of vertices of a hexahedron. + */ INLINE_MATHUTIL int BoundingHexahedron:: get_num_points() const { return num_points; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_point -// Access: Published -// Description: Returns the nth vertex of the hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the hexahedron. + */ INLINE_MATHUTIL LPoint3 BoundingHexahedron:: get_point(int n) const { nassertr(n >= 0 && n < num_points, LPoint3::zero()); return _points[n]; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_num_planes -// Access: Published -// Description: Returns 6: the number of faces of a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Returns 6: the number of faces of a hexahedron. + */ INLINE_MATHUTIL int BoundingHexahedron:: get_num_planes() const { return num_planes; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_plane -// Access: Published -// Description: Returns the nth face of the hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth face of the hexahedron. + */ INLINE_MATHUTIL LPlane BoundingHexahedron:: get_plane(int n) const { nassertr(n >= 0 && n < num_planes, LPlane()); diff --git a/panda/src/mathutil/boundingHexahedron.cxx b/panda/src/mathutil/boundingHexahedron.cxx index 3a8ab4e086..b765f043b0 100644 --- a/panda/src/mathutil/boundingHexahedron.cxx +++ b/panda/src/mathutil/boundingHexahedron.cxx @@ -1,16 +1,15 @@ -// Filename: boundingHexahedron.cxx -// Created by: drose (03Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingHexahedron.cxx + * @author drose + * @date 1999-10-03 + */ #include "boundingHexahedron.h" #include "boundingSphere.h" @@ -22,11 +21,9 @@ TypeHandle BoundingHexahedron::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingHexahedron:: BoundingHexahedron(const LFrustum &frustum, bool is_ortho, CoordinateSystem cs) { @@ -40,8 +37,8 @@ BoundingHexahedron(const LFrustum &frustum, bool is_ortho, } // We build the points based on a Z-up right-handed frustum. If the - // requested coordinate system is otherwise, we'll convert it in a - // second pass. + // requested coordinate system is otherwise, we'll convert it in a second + // pass. _points[0].set(frustum._l * fs, frustum._ffar, frustum._b * fs); _points[1].set(frustum._r * fs, frustum._ffar, frustum._b * fs); _points[2].set(frustum._r * fs, frustum._ffar, frustum._t * fs); @@ -62,11 +59,9 @@ BoundingHexahedron(const LFrustum &frustum, bool is_ortho, } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingHexahedron:: BoundingHexahedron(const LPoint3 &fll, const LPoint3 &flr, const LPoint3 &fur, const LPoint3 &ful, @@ -86,21 +81,17 @@ BoundingHexahedron(const LPoint3 &fll, const LPoint3 &flr, set_planes(); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *BoundingHexahedron:: make_copy() const { return new BoundingHexahedron(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_min -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingHexahedron:: get_min() const { nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -115,11 +106,9 @@ get_min() const { return m; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_max -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingHexahedron:: get_max() const { nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -134,11 +123,9 @@ get_max() const { return m; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingHexahedron:: get_approx_center() const { nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -146,11 +133,9 @@ get_approx_center() const { return _centroid; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingHexahedron:: xform(const LMatrix4 &mat) { if (!is_empty() && !is_infinite()) { @@ -162,11 +147,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingHexahedron:: output(ostream &out) const { if (is_empty()) { @@ -178,11 +161,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingHexahedron:: write(ostream &out, int indent_level) const { if (is_empty()) { @@ -200,33 +181,26 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::as_bounding_hexahedron -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingHexahedron *BoundingHexahedron:: as_bounding_hexahedron() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingHexahedron:: extend_other(BoundingVolume *other) const { return other->extend_by_hexahedron(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingHexahedron:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -234,21 +208,17 @@ around_other(BoundingVolume *other, return other->around_hexahedrons(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_other(const BoundingVolume *other) const { return other->contains_hexahedron(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_point(const LPoint3 &point) const { if (is_empty()) { @@ -258,8 +228,8 @@ contains_point(const LPoint3 &point) const { return IF_possible | IF_some | IF_all; } else { - // The hexahedron contains the point iff the point is behind all of - // the planes. + // The hexahedron contains the point iff the point is behind all of the + // planes. for (int i = 0; i < num_planes; i++) { const LPlane &p = _planes[i]; if (p.dist_to_plane(point) > 0.0f) { @@ -270,11 +240,9 @@ contains_point(const LPoint3 &point) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_lineseg -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { if (is_empty()) { @@ -284,8 +252,8 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { return IF_possible | IF_some | IF_all; } else { - // The hexahedron does not contains the line segment if both points - // are in front of any one plane. + // The hexahedron does not contains the line segment if both points are in + // front of any one plane. for (int i = 0; i < num_planes; i++) { const LPlane &p = _planes[i]; if (p.dist_to_plane(a) > 0.0f || @@ -294,24 +262,22 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { } } - // If there is no plane that both points are in front of, the - // hexahedron may or may not contain the line segment. For the - // moment, we won't bother to check that more thoroughly, though. + // If there is no plane that both points are in front of, the hexahedron + // may or may not contain the line segment. For the moment, we won't + // bother to check that more thoroughly, though. return IF_possible; } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_sphere -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty(), 0); - // The hexahedron contains the sphere iff the sphere is at least - // partly behind all of the planes. + // The hexahedron contains the sphere iff the sphere is at least partly + // behind all of the planes. const LPoint3 ¢er = sphere->get_center(); PN_stdfloat radius = sphere->get_radius(); @@ -322,13 +288,12 @@ contains_sphere(const BoundingSphere *sphere) const { PN_stdfloat dist = p.dist_to_plane(center); if (dist > radius) { - // The sphere is completely in front of this plane; it's thus - // completely outside of the hexahedron. + // The sphere is completely in front of this plane; it's thus completely + // outside of the hexahedron. return IF_no_intersection; } else if (dist > -radius) { - // The sphere is not completely behind this plane, but some of - // it is. + // The sphere is not completely behind this plane, but some of it is. result &= ~IF_all; } } @@ -336,11 +301,9 @@ contains_sphere(const BoundingSphere *sphere) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_box -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_box(const BoundingBox *box) const { nassertr(!is_empty(), 0); @@ -360,9 +323,8 @@ contains_box(const BoundingBox *box) const { PN_stdfloat dist2 = dist * dist; if (dist2 <= radius2) { - // The sphere is not completely behind this plane, but some of - // it is. - + // The sphere is not completely behind this plane, but some of it is. + // Look a little closer. bool all_in = true; bool all_out = true; @@ -391,11 +353,9 @@ contains_box(const BoundingBox *box) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::contains_hexahedron -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingHexahedron:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { nassertr(!is_empty(), 0); @@ -415,13 +375,12 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { PN_stdfloat dist2 = dist * dist; if (dist >= 0.0f && dist2 > radius2) { - // The sphere is completely in front of this plane; it's thus - // completely outside of the hexahedron. + // The sphere is completely in front of this plane; it's thus completely + // outside of the hexahedron. return IF_no_intersection; } else {/*if (dist < 0.0f && dist2 < radius2) {*/ - // The sphere is not completely behind this plane, but some of - // it is. + // The sphere is not completely behind this plane, but some of it is. // Look a little closer. unsigned points_out = 0; @@ -444,22 +403,19 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::set_planes -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingHexahedron:: set_planes() { _planes[0] = LPlane(_points[0], _points[3], _points[2]); - // Test to see if we have accidentally inverted our frustum by - // transforming it with a -1 matrix. We do this by ensuring that - // the centroid is in front of all of the planes (actually, we only - // need to test the first plane). + // Test to see if we have accidentally inverted our frustum by transforming + // it with a -1 matrix. We do this by ensuring that the centroid is in + // front of all of the planes (actually, we only need to test the first + // plane). if (_planes[0].dist_to_plane(_centroid) > 0) { - // Oops! We're flipped! Rebuild the planes in the opposite - // direction. + // Oops! We're flipped! Rebuild the planes in the opposite direction. _planes[0] = LPlane(_points[0], _points[2], _points[3]); _planes[1] = LPlane(_points[0], _points[5], _points[1]); _planes[2] = LPlane(_points[1], _points[6], _points[2]); @@ -476,8 +432,8 @@ set_planes() { _planes[5] = LPlane(_points[4], _points[6], _points[7]); } - // Still not entirely sure why some code keeps triggering these, but - // I'm taking them out of the normal build for now. + // Still not entirely sure why some code keeps triggering these, but I'm + // taking them out of the normal build for now. #ifdef _DEBUG nassertv(_planes[0].dist_to_plane(_centroid) <= 0.001); nassertv(_planes[1].dist_to_plane(_centroid) <= 0.001); @@ -488,11 +444,9 @@ set_planes() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: BoundingHexahedron::set_centroid -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingHexahedron:: set_centroid() { LPoint3 net = _points[0]; diff --git a/panda/src/mathutil/boundingHexahedron.h b/panda/src/mathutil/boundingHexahedron.h index ebb5cceeca..a7d55b8643 100644 --- a/panda/src/mathutil/boundingHexahedron.h +++ b/panda/src/mathutil/boundingHexahedron.h @@ -1,16 +1,15 @@ -// Filename: boundingHexahedron.h -// Created by: drose (03Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingHexahedron.h + * @author drose + * @date 1999-10-03 + */ #ifndef BOUNDINGHEXAHEDRON_H #define BOUNDINGHEXAHEDRON_H @@ -24,15 +23,12 @@ #include "coordinateSystem.h" -//////////////////////////////////////////////////////////////////// -// Class : BoundingHexahedron -// Description : This defines a bounding convex hexahedron. It is -// typically used to represent a frustum, but may -// represent any enclosing convex hexahedron, including -// simple boxes. However, if all you want is an -// axis-aligned bounding box, you may be better off with -// the simpler BoundingBox class. -//////////////////////////////////////////////////////////////////// +/** + * This defines a bounding convex hexahedron. It is typically used to + * represent a frustum, but may represent any enclosing convex hexahedron, + * including simple boxes. However, if all you want is an axis-aligned + * bounding box, you may be better off with the simpler BoundingBox class. + */ class EXPCL_PANDA_MATHUTIL BoundingHexahedron : public FiniteBoundingVolume { public: INLINE_MATHUTIL BoundingHexahedron(); diff --git a/panda/src/mathutil/boundingLine.I b/panda/src/mathutil/boundingLine.I index 4623088a0a..65969d06a6 100644 --- a/panda/src/mathutil/boundingLine.I +++ b/panda/src/mathutil/boundingLine.I @@ -1,32 +1,26 @@ -// Filename: boundingLine.I -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingLine.I + * @author drose + * @date 2000-07-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL BoundingLine:: BoundingLine() { } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL BoundingLine:: BoundingLine(const LPoint3 &a, const LPoint3 &b) : _origin(a), _vector(b - a) @@ -38,11 +32,9 @@ BoundingLine(const LPoint3 &a, const LPoint3 &b) : } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::get_point_a -// Access: Published -// Description: Returns the first point that defines the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first point that defines the line. + */ INLINE_MATHUTIL const LPoint3 &BoundingLine:: get_point_a() const { nassertr(!is_empty(), _origin); @@ -50,11 +42,9 @@ get_point_a() const { return _origin; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::get_point_b -// Access: Published -// Description: Returns the second point that defines the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second point that defines the line. + */ INLINE_MATHUTIL LPoint3 BoundingLine:: get_point_b() const { nassertr(!is_empty(), _origin); diff --git a/panda/src/mathutil/boundingLine.cxx b/panda/src/mathutil/boundingLine.cxx index 9878668322..38dd4704a5 100644 --- a/panda/src/mathutil/boundingLine.cxx +++ b/panda/src/mathutil/boundingLine.cxx @@ -1,16 +1,15 @@ -// Filename: boundingLine.cxx -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingLine.cxx + * @author drose + * @date 2000-07-04 + */ #include "boundingLine.h" #include "boundingSphere.h" @@ -21,21 +20,17 @@ TypeHandle BoundingLine::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *BoundingLine:: make_copy() const { return new BoundingLine(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingLine:: get_approx_center() const { nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -43,11 +38,9 @@ get_approx_center() const { return (get_point_a() + get_point_b()) / 2.0; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingLine:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -56,18 +49,16 @@ xform(const LMatrix4 &mat) { _origin = _origin * mat; _vector = _vector * mat; if (!_vector.normalize()) { - // If we just scaled the line down to nothing, it becomes an - // empty volume. + // If we just scaled the line down to nothing, it becomes an empty + // volume. _flags |= F_empty; } } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingLine:: output(ostream &out) const { if (is_empty()) { @@ -79,33 +70,26 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::as_bounding_line -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingLine *BoundingLine:: as_bounding_line() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingLine:: extend_other(BoundingVolume *other) const { return other->extend_by_line(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingLine:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -113,21 +97,17 @@ around_other(BoundingVolume *other, return other->around_lines(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingLine:: contains_other(const BoundingVolume *other) const { return other->contains_line(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::extend_by_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingLine:: extend_by_line(const BoundingLine *line) { nassertr(!line->is_empty() && !line->is_infinite(), false); @@ -143,11 +123,9 @@ extend_by_line(const BoundingLine *line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::contains_sphere -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingLine:: contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -162,11 +140,9 @@ contains_sphere(const BoundingSphere *sphere) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::contains_box -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingLine:: contains_box(const BoundingBox *box) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -182,19 +158,17 @@ contains_box(const BoundingBox *box) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingLine::sqr_dist_to_line -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BoundingLine:: sqr_dist_to_line(const LPoint3 &point) const { nassertr(!point.is_nan(), 0.0f); nassertr(!is_empty() && !is_infinite(), 0.0f); nassertr(!_vector.almost_equal(LVector3(0.0f, 0.0f, 0.0f)), 0.0f); - // The formula for the distance from a point to the line based on - // the quadratic equation. + // The formula for the distance from a point to the line based on the + // quadratic equation. PN_stdfloat A = dot(_vector, _vector); nassertr(A != 0.0f, 0.0f); diff --git a/panda/src/mathutil/boundingLine.h b/panda/src/mathutil/boundingLine.h index a9bb26ea46..c3a089cfc2 100644 --- a/panda/src/mathutil/boundingLine.h +++ b/panda/src/mathutil/boundingLine.h @@ -1,16 +1,15 @@ -// Filename: boundingLine.h -// Created by: drose (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingLine.h + * @author drose + * @date 2000-07-04 + */ #ifndef BOUNDINGLINE_H #define BOUNDINGLINE_H @@ -19,17 +18,14 @@ #include "geometricBoundingVolume.h" -//////////////////////////////////////////////////////////////////// -// Class : BoundingLine -// Description : This funny bounding volume is an infinite line with -// no thickness and extending to infinity in both -// directions. -// -// Note that it *always* extends in both directions, -// despite the fact that you specify two points to the -// constructor. These are not endpoints, they are two -// arbitrary points on the line. -//////////////////////////////////////////////////////////////////// +/** + * This funny bounding volume is an infinite line with no thickness and + * extending to infinity in both directions. + * + * Note that it *always* extends in both directions, despite the fact that you + * specify two points to the constructor. These are not endpoints, they are + * two arbitrary points on the line. + */ class EXPCL_PANDA_MATHUTIL BoundingLine : public GeometricBoundingVolume { public: INLINE_MATHUTIL BoundingLine(); diff --git a/panda/src/mathutil/boundingPlane.I b/panda/src/mathutil/boundingPlane.I index 57f23826f3..b6f20c2a11 100644 --- a/panda/src/mathutil/boundingPlane.I +++ b/panda/src/mathutil/boundingPlane.I @@ -1,33 +1,26 @@ -// Filename: boundingPlane.I -// Created by: drose (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingPlane.I + * @author drose + * @date 2005-08-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::Default Constructor -// Access: Published -// Description: Constructs an empty "plane" that has no -// intersections. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty "plane" that has no intersections. + */ INLINE_MATHUTIL BoundingPlane:: BoundingPlane() { } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL BoundingPlane:: BoundingPlane(const LPlane &plane) : _plane(plane) @@ -35,11 +28,9 @@ BoundingPlane(const LPlane &plane) : _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::get_plane -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL const LPlane &BoundingPlane:: get_plane() const { nassertr(!is_empty(), _plane); diff --git a/panda/src/mathutil/boundingPlane.cxx b/panda/src/mathutil/boundingPlane.cxx index d5a3316d7c..b0a36ab3e3 100644 --- a/panda/src/mathutil/boundingPlane.cxx +++ b/panda/src/mathutil/boundingPlane.cxx @@ -1,16 +1,15 @@ -// Filename: boundingPlane.cxx -// Created by: drose (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingPlane.cxx + * @author drose + * @date 2005-08-19 + */ #include "boundingPlane.h" #include "boundingSphere.h" @@ -20,21 +19,17 @@ TypeHandle BoundingPlane::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *BoundingPlane:: make_copy() const { return new BoundingPlane(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingPlane:: get_approx_center() const { nassertr(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); @@ -42,11 +37,9 @@ get_approx_center() const { return _plane.get_point(); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingPlane:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -56,11 +49,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingPlane:: output(ostream &out) const { if (is_empty()) { @@ -72,33 +63,26 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::as_bounding_plane -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingPlane *BoundingPlane:: as_bounding_plane() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::extend_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingPlane:: extend_other(BoundingVolume *other) const { return other->extend_by_plane(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::around_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingPlane:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -106,21 +90,17 @@ around_other(BoundingVolume *other, return other->around_planes(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingPlane:: contains_other(const BoundingVolume *other) const { return other->contains_plane(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::extend_by_plane -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingPlane:: extend_by_plane(const BoundingPlane *plane) { nassertr(!plane->is_empty() && !plane->is_infinite(), false); @@ -135,11 +115,9 @@ extend_by_plane(const BoundingPlane *plane) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingPlane:: contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -162,11 +140,9 @@ contains_sphere(const BoundingSphere *sphere) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_box -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingPlane:: contains_box(const BoundingBox *box) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -184,9 +160,8 @@ contains_box(const BoundingBox *box) const { PN_stdfloat dist2 = dist * dist; if (dist2 <= radius2) { - // The sphere is not completely behind this plane, but some of - // it is. - + // The sphere is not completely behind this plane, but some of it is. + // Look a little closer. bool all_in = true; bool all_out = true; @@ -199,13 +174,13 @@ contains_box(const BoundingBox *box) const { all_in = false; } } - + if (all_out) { return IF_no_intersection; } else if (!all_in) { result &= ~IF_all; } - + } else if (dist >= 0.0f) { // The sphere is completely in front of this plane. return IF_no_intersection; @@ -214,33 +189,26 @@ contains_box(const BoundingBox *box) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_line -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingPlane:: contains_line(const BoundingLine *line) const { return IF_possible; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_plane -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingPlane:: contains_plane(const BoundingPlane *plane) const { return IF_possible; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingPlane::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int BoundingPlane:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -259,7 +227,7 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { all_in = false; } } - + if (all_out) { return IF_no_intersection; } else if (!all_in) { diff --git a/panda/src/mathutil/boundingPlane.h b/panda/src/mathutil/boundingPlane.h index 0ee5821f83..aff1ebe36b 100644 --- a/panda/src/mathutil/boundingPlane.h +++ b/panda/src/mathutil/boundingPlane.h @@ -1,16 +1,15 @@ -// Filename: boundingPlane.h -// Created by: drose (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingPlane.h + * @author drose + * @date 2005-08-19 + */ #ifndef BOUNDINGPLANE_H #define BOUNDINGPLANE_H @@ -20,14 +19,12 @@ #include "geometricBoundingVolume.h" #include "plane.h" -//////////////////////////////////////////////////////////////////// -// Class : BoundingPlane -// Description : This funny bounding volume is an infinite plane that -// divides space into two regions: the part behind the -// normal, which is "inside" the bounding volume, and -// the part in front of the normal, which is "outside" -// the bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * This funny bounding volume is an infinite plane that divides space into two + * regions: the part behind the normal, which is "inside" the bounding volume, + * and the part in front of the normal, which is "outside" the bounding + * volume. + */ class EXPCL_PANDA_MATHUTIL BoundingPlane : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingPlane(); diff --git a/panda/src/mathutil/boundingSphere.I b/panda/src/mathutil/boundingSphere.I index 708753ec3d..11a19918b6 100644 --- a/panda/src/mathutil/boundingSphere.I +++ b/panda/src/mathutil/boundingSphere.I @@ -1,32 +1,26 @@ -// Filename: boundingSphere.I -// Created by: drose (02Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingSphere.I + * @author drose + * @date 1999-10-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::Constructor -// Access: Published -// Description: Constructs an empty sphere. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty sphere. + */ INLINE_MATHUTIL BoundingSphere:: BoundingSphere() : _center(0) { } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::Constructor -// Access: Published -// Description: Constructs a specific sphere. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a specific sphere. + */ INLINE_MATHUTIL BoundingSphere:: BoundingSphere(const LPoint3 ¢er, PN_stdfloat radius) : _center(center), _radius(radius) @@ -37,22 +31,18 @@ BoundingSphere(const LPoint3 ¢er, PN_stdfloat radius) : } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_center -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL LPoint3 BoundingSphere:: get_center() const { nassertr(!is_infinite(), LPoint3::zero()); return _center; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL PN_stdfloat BoundingSphere:: get_radius() const { nassertr(!is_empty(), 0.0f); @@ -60,22 +50,18 @@ get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::set_center -// Access: Published -// Description: Sets the center point of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Sets the center point of the sphere. + */ INLINE_MATHUTIL void BoundingSphere:: set_center(const LPoint3 ¢er) { nassertv(!center.is_nan()); _center = center; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::set_radius -// Access: Published -// Description: Sets the radius of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Sets the radius of the sphere. + */ INLINE_MATHUTIL void BoundingSphere:: set_radius(PN_stdfloat radius) { nassertv(!cnan(radius)); diff --git a/panda/src/mathutil/boundingSphere.cxx b/panda/src/mathutil/boundingSphere.cxx index 9373c8a21b..5ea6661aa7 100644 --- a/panda/src/mathutil/boundingSphere.cxx +++ b/panda/src/mathutil/boundingSphere.cxx @@ -1,16 +1,15 @@ -// Filename: boundingSphere.cxx -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingSphere.cxx + * @author drose + * @date 1999-10-01 + */ #include "boundingSphere.h" #include "boundingBox.h" @@ -25,21 +24,17 @@ TypeHandle BoundingSphere::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *BoundingSphere:: make_copy() const { return new BoundingSphere(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_min -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingSphere:: get_min() const { nassertr(!is_empty(), LPoint3::zero()); @@ -49,11 +44,9 @@ get_min() const { _center[2] - _radius); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_max -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingSphere:: get_max() const { nassertr(!is_empty(), LPoint3::zero()); @@ -63,11 +56,9 @@ get_max() const { _center[2] + _radius); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat BoundingSphere:: get_volume() const { nassertr(!is_infinite(), 0.0f); @@ -79,11 +70,9 @@ get_volume() const { return 4.0f / 3.0f * MathNumbers::pi_f * _radius * _radius * _radius; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 BoundingSphere:: get_approx_center() const { nassertr(!is_empty(), LPoint3::zero()); @@ -91,18 +80,16 @@ get_approx_center() const { return get_center(); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingSphere:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); if (!is_empty() && !is_infinite()) { - // First, determine the longest axis of the matrix, in case it - // contains a non-uniform scale. + // First, determine the longest axis of the matrix, in case it contains a + // non-uniform scale. LVecBase3 x, y, z; mat.get_row3(x, 0); @@ -125,11 +112,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingSphere:: output(ostream &out) const { if (is_empty()) { @@ -141,33 +126,26 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::as_bounding_sphere -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingSphere *BoundingSphere:: as_bounding_sphere() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_other(BoundingVolume *other) const { return other->extend_by_sphere(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -175,22 +153,18 @@ around_other(BoundingVolume *other, return other->around_spheres(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingSphere:: contains_other(const BoundingVolume *other) const { return other->contains_sphere(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_by_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_by_point(const LPoint3 &point) { nassertr(!point.is_nan(), false); @@ -209,11 +183,9 @@ extend_by_point(const LPoint3 &point) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_by_sphere -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_by_sphere(const BoundingSphere *sphere) { nassertr(!sphere->is_empty() && !sphere->is_infinite(), false); @@ -231,11 +203,9 @@ extend_by_sphere(const BoundingSphere *sphere) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_by_box -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_by_box(const BoundingBox *box) { const LVector3 &min1 = box->get_minq(); @@ -263,11 +233,9 @@ extend_by_box(const BoundingBox *box) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_by_hexahedron -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_by_hexahedron(const BoundingHexahedron *hexahedron) { nassertr(!hexahedron->is_empty(), false); @@ -277,11 +245,9 @@ extend_by_hexahedron(const BoundingHexahedron *hexahedron) { return extend_by_box(&box); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::extend_by_finite -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: extend_by_finite(const FiniteBoundingVolume *volume) { nassertr(!volume->is_empty(), false); @@ -291,17 +257,14 @@ extend_by_finite(const FiniteBoundingVolume *volume) { return extend_by_box(&box); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::around_points -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: around_points(const LPoint3 *first, const LPoint3 *last) { nassertr(first != last, false); - // First, get the box of all the points to construct a bounding - // box. + // First, get the box of all the points to construct a bounding box. const LPoint3 *p = first; #ifndef NDEBUG @@ -331,9 +294,9 @@ around_points(const LPoint3 *first, const LPoint3 *last) { #endif if (p == last) { - // Only one point; we have a radius of zero. This is not the same - // thing as an empty sphere, because our volume contains one - // point; an empty sphere contains no points. + // Only one point; we have a radius of zero. This is not the same thing + // as an empty sphere, because our volume contains one point; an empty + // sphere contains no points. _center = min_box; _radius = 0.0f; @@ -384,22 +347,19 @@ around_points(const LPoint3 *first, const LPoint3 *last) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::around_finite -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BoundingSphere:: around_finite(const BoundingVolume **first, const BoundingVolume **last) { nassertr(first != last, false); - // We're given a set of bounding volumes, all of which are finite, - // and at least the first one of which is guaranteed to be nonempty. - // Some others may not be. + // We're given a set of bounding volumes, all of which are finite, and at + // least the first one of which is guaranteed to be nonempty. Some others + // may not be. - // First, get the box of all the points to construct a bounding - // box. + // First, get the box of all the points to construct a bounding box. const BoundingVolume **p = first; nassertr(!(*p)->is_empty() && !(*p)->is_infinite(), false); const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); @@ -436,13 +396,13 @@ around_finite(const BoundingVolume **first, _center = (min_box + max_box) * 0.5f; if (!any_spheres) { - // Since there are no spheres in the list, we have to make this - // sphere fully enclose all of the bounding boxes. + // Since there are no spheres in the list, we have to make this sphere + // fully enclose all of the bounding boxes. _radius = length(max_box - _center); } else { - // We might be able to go tighter, by lopping off the corners of - // the spheres. + // We might be able to go tighter, by lopping off the corners of the + // spheres. _radius = 0.0f; for (p = first; p != last; ++p) { if (!(*p)->is_empty()) { @@ -451,7 +411,7 @@ around_finite(const BoundingVolume **first, // This is a sphere; consider its corner. PN_stdfloat dist = length(sphere->_center - _center); _radius = max(_radius, dist + sphere->_radius); - + } else { // This is a nonsphere. We fit around it. const FiniteBoundingVolume *vol = (*p)->as_finite_bounding_volume(); @@ -459,7 +419,7 @@ around_finite(const BoundingVolume **first, BoundingBox box(vol->get_min(), vol->get_max()); box.local_object(); - + // Find the minimum radius necessary to reach the corner. PN_stdfloat max_dist2 = -1.0; for (int i = 0; i < 8; ++i) { @@ -478,11 +438,9 @@ around_finite(const BoundingVolume **first, return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingSphere:: contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); @@ -501,11 +459,9 @@ contains_point(const LPoint3 &point) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_lineseg -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int BoundingSphere:: contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); @@ -524,8 +480,8 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { LVector3 delta = b - a; PN_stdfloat t1, t2; - // Solve the equation for the intersection of a line with a sphere - // using the quadratic equation. + // Solve the equation for the intersection of a line with a sphere using + // the quadratic equation. PN_stdfloat A = dot(delta, delta); nassertr(A != 0.0f, 0); // Trivial line segment. @@ -564,13 +520,10 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_sphere -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a sphere. + */ int BoundingSphere:: contains_sphere(const BoundingSphere *sphere) const { nassertr(!is_empty() && !is_infinite(), 0); @@ -594,49 +547,37 @@ contains_sphere(const BoundingSphere *sphere) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a box. + */ int BoundingSphere:: contains_box(const BoundingBox *box) const { return box->contains_sphere(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int BoundingSphere:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { return hexahedron->contains_sphere(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a line. + */ int BoundingSphere:: contains_line(const BoundingLine *line) const { return line->contains_sphere(this) & ~IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingSphere::contains_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a plane. + */ int BoundingSphere:: contains_plane(const BoundingPlane *plane) const { return plane->contains_sphere(this) & ~IF_all; diff --git a/panda/src/mathutil/boundingSphere.h b/panda/src/mathutil/boundingSphere.h index 26e78209cb..9a51a015ac 100644 --- a/panda/src/mathutil/boundingSphere.h +++ b/panda/src/mathutil/boundingSphere.h @@ -1,16 +1,15 @@ -// Filename: boundingSphere.h -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingSphere.h + * @author drose + * @date 1999-10-01 + */ #ifndef BOUNDINGSPHERE_H #define BOUNDINGSPHERE_H @@ -19,12 +18,10 @@ #include "finiteBoundingVolume.h" -//////////////////////////////////////////////////////////////////// -// Class : BoundingSphere -// Description : This defines a bounding sphere, consisting of a -// center and a radius. It is always a sphere, and -// never an ellipsoid or other quadric. -//////////////////////////////////////////////////////////////////// +/** + * This defines a bounding sphere, consisting of a center and a radius. It is + * always a sphere, and never an ellipsoid or other quadric. + */ class EXPCL_PANDA_MATHUTIL BoundingSphere : public FiniteBoundingVolume { PUBLISHED: INLINE_MATHUTIL BoundingSphere(); diff --git a/panda/src/mathutil/boundingVolume.I b/panda/src/mathutil/boundingVolume.I index e88719f498..2778e886ba 100644 --- a/panda/src/mathutil/boundingVolume.I +++ b/panda/src/mathutil/boundingVolume.I @@ -1,102 +1,81 @@ -// Filename: boundingVolume.I -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingVolume.I + * @author drose + * @date 1999-10-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL BoundingVolume:: BoundingVolume() { _flags = F_empty; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::is_empty -// Access: Published -// Description: Any kind of volume might be empty. This is a -// degenerate volume that contains no points; it's not -// the same as, for instance, a sphere with radius zero, -// since that contains one point (the center). It -// intersects with no other volumes. -//////////////////////////////////////////////////////////////////// +/** + * Any kind of volume might be empty. This is a degenerate volume that + * contains no points; it's not the same as, for instance, a sphere with + * radius zero, since that contains one point (the center). It intersects + * with no other volumes. + */ INLINE_MATHUTIL bool BoundingVolume:: is_empty() const { return (_flags & F_empty) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::is_infinite -// Access: Published -// Description: The other side of the empty coin is an infinite -// volume. This is a degenerate state of a normally -// finite volume that contains all points. (Note that -// some kinds of infinite bounding volumes, like binary -// separating planes, do not contain all points and thus -// correctly return is_infinite() == false, even though -// they are technically infinite. This is a special -// case of the word 'infinite' meaning the volume covers -// all points in space.) -// -// It completely intersects with all other volumes -// except empty volumes. -//////////////////////////////////////////////////////////////////// +/** + * The other side of the empty coin is an infinite volume. This is a + * degenerate state of a normally finite volume that contains all points. + * (Note that some kinds of infinite bounding volumes, like binary separating + * planes, do not contain all points and thus correctly return is_infinite() + * == false, even though they are technically infinite. This is a special + * case of the word 'infinite' meaning the volume covers all points in space.) + * + * It completely intersects with all other volumes except empty volumes. + */ INLINE_MATHUTIL bool BoundingVolume:: is_infinite() const { return (_flags & F_infinite) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::set_infinite -// Access: Published -// Description: Marks the volume as infinite, even if it is normally -// finite. You can think of this as an infinite -// extend_by() operation. -//////////////////////////////////////////////////////////////////// +/** + * Marks the volume as infinite, even if it is normally finite. You can think + * of this as an infinite extend_by() operation. + */ INLINE_MATHUTIL void BoundingVolume:: set_infinite() { _flags = F_infinite; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by -// Access: Published -// Description: Increases the size of the volume to include the given -// volume. -//////////////////////////////////////////////////////////////////// +/** + * Increases the size of the volume to include the given volume. + */ INLINE_MATHUTIL bool BoundingVolume:: extend_by(const BoundingVolume *vol) { if (vol->is_infinite()) { set_infinite(); } else if (!vol->is_empty()) { - // This is a double-dispatch. We call this virtual function on the - // volume we were given, which will in turn call the appropriate - // virtual function in our own class to perform the operation. + // This is a double-dispatch. We call this virtual function on the volume + // we were given, which will in turn call the appropriate virtual function + // in our own class to perform the operation. return vol->extend_other(this); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains -// Access: Published -// Description: Returns the appropriate set of IntersectionFlags to -// indicate the amount of intersection with the -// indicated volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate set of IntersectionFlags to indicate the amount of + * intersection with the indicated volume. + */ INLINE_MATHUTIL int BoundingVolume:: contains(const BoundingVolume *vol) const { if (is_empty() || vol->is_empty()) { @@ -109,9 +88,9 @@ contains(const BoundingVolume *vol) const { return IF_possible | IF_some; } - // This is a double-dispatch. We call this virtual function on the - // volume we were given, which will in turn call the appropriate - // virtual function in our own class to perform the operation. + // This is a double-dispatch. We call this virtual function on the volume + // we were given, which will in turn call the appropriate virtual function + // in our own class to perform the operation. return vol->contains_other(this); } diff --git a/panda/src/mathutil/boundingVolume.cxx b/panda/src/mathutil/boundingVolume.cxx index de223c05bf..3a2bee0577 100644 --- a/panda/src/mathutil/boundingVolume.cxx +++ b/panda/src/mathutil/boundingVolume.cxx @@ -1,16 +1,15 @@ -// Filename: boundingVolume.cxx -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingVolume.cxx + * @author drose + * @date 1999-10-01 + */ #include "boundingVolume.h" #include "finiteBoundingVolume.h" @@ -28,19 +27,17 @@ TypeHandle BoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around -// Access: Published -// Description: Resets the volume to enclose only the volumes -// indicated. Returns true if successful, false if the -// volume doesn't know how to do that or can't do that. -//////////////////////////////////////////////////////////////////// +/** + * Resets the volume to enclose only the volumes indicated. Returns true if + * successful, false if the volume doesn't know how to do that or can't do + * that. + */ bool BoundingVolume:: around(const BoundingVolume **first, const BoundingVolume **last) { _flags = F_empty; - // Skip any empty volumes at the beginning of the list. We want to - // get to the first real volume. + // Skip any empty volumes at the beginning of the list. We want to get to + // the first real volume. while (first != last && (*first)->is_empty()) { if ((*first)->is_infinite()) { // If we go around an infinite volume, we're infinite too. @@ -62,10 +59,9 @@ around(const BoundingVolume **first, const BoundingVolume **last) { } } - // This is a double-dispatch. We call this virtual function on - // the volume we were given, which will in turn call the - // appropriate virtual function in our own class to perform the - // operation. + // This is a double-dispatch. We call this virtual function on the volume + // we were given, which will in turn call the appropriate virtual function + // in our own class to perform the operation. if (!(*first)->around_other(this, first, last)) { okflag = false; } @@ -74,118 +70,89 @@ around(const BoundingVolume **first, const BoundingVolume **last) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BoundingVolume:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_geometric_bounding_volume -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_geometric_bounding_volume -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const GeometricBoundingVolume *BoundingVolume:: as_geometric_bounding_volume() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_finite_bounding_volume -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const FiniteBoundingVolume *BoundingVolume:: as_finite_bounding_volume() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_bounding_sphere -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingSphere *BoundingVolume:: as_bounding_sphere() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_bounding_box -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingBox *BoundingVolume:: as_bounding_box() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_bounding_hexahedron -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingHexahedron *BoundingVolume:: as_bounding_hexahedron() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_bounding_line -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingLine *BoundingVolume:: as_bounding_line() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::as_bounding_plane -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const BoundingPlane *BoundingVolume:: as_bounding_plane() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::string_bounds_type -// Access: Public, Static -// Description: Returns the BoundsType corresponding to the indicated -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BoundsType corresponding to the indicated string. + */ BoundingVolume::BoundsType BoundingVolume:: string_bounds_type(const string &str) { if (strcmp(str.c_str(), "default") == 0) { @@ -207,105 +174,80 @@ string_bounds_type(const string &str) { return BT_default; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_sphere -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a sphere. + */ bool BoundingVolume:: extend_by_sphere(const BoundingSphere *sphere) { return extend_by_finite(sphere); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a box. + */ bool BoundingVolume:: extend_by_box(const BoundingBox *box) { return extend_by_finite(box); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a hexahedron. + */ bool BoundingVolume:: extend_by_hexahedron(const BoundingHexahedron *hexahedron) { return extend_by_finite(hexahedron); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a line. + */ bool BoundingVolume:: extend_by_line(const BoundingLine *line) { return extend_by_geometric(line); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a plane. + */ bool BoundingVolume:: extend_by_plane(const BoundingPlane *plane) { return extend_by_geometric(plane); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_union -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// union. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a union. + */ bool BoundingVolume:: extend_by_union(const UnionBoundingVolume *unionv) { return extend_by_geometric(unionv); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_intersection -// Access: Protected, Virtual -// Description: Double-dispatch support: called by extend_other() -// when the type we're extending by is known to be a -// intersection. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by extend_other() when the type we're + * extending by is known to be a intersection. + */ bool BoundingVolume:: extend_by_intersection(const IntersectionBoundingVolume *intersection) { return extend_by_geometric(intersection); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_finite -// Access: Protected, Virtual -// Description: Generic handler for a FiniteBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a FiniteBoundingVolume. + */ bool BoundingVolume:: extend_by_finite(const FiniteBoundingVolume *volume) { return extend_by_geometric(volume); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::extend_by_geometric -// Access: Protected, Virtual -// Description: Generic handler for a GeometricBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a GeometricBoundingVolume. + */ bool BoundingVolume:: extend_by_geometric(const GeometricBoundingVolume *volume) { mathutil_cat.warning() @@ -314,105 +256,80 @@ extend_by_geometric(const GeometricBoundingVolume *volume) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_spheres -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty sphere. + */ bool BoundingVolume:: around_spheres(const BoundingVolume **first, const BoundingVolume **last) { return around_finite(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_boxes -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty box. + */ bool BoundingVolume:: around_boxes(const BoundingVolume **first, const BoundingVolume **last) { return around_finite(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_hexahedrons -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty hexahedron. + */ bool BoundingVolume:: around_hexahedrons(const BoundingVolume **first, const BoundingVolume **last) { return around_finite(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_lines -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty line. + */ bool BoundingVolume:: around_lines(const BoundingVolume **first, const BoundingVolume **last) { return around_geometric(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_planes -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty plane. + */ bool BoundingVolume:: around_planes(const BoundingVolume **first, const BoundingVolume **last) { return around_geometric(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_unions -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a union object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a union object. + */ bool BoundingVolume:: around_unions(const BoundingVolume **first, const BoundingVolume **last) { return around_geometric(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_intersections -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be an intersection object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be an intersection object. + */ bool BoundingVolume:: around_intersections(const BoundingVolume **first, const BoundingVolume **last) { return around_geometric(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_finite -// Access: Protected, Virtual -// Description: Generic handler for a FiniteBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a FiniteBoundingVolume. + */ bool BoundingVolume:: around_finite(const BoundingVolume **first, const BoundingVolume **last) { return around_geometric(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::around_geometric -// Access: Protected, Virtual -// Description: Generic handler for a GeometricBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a GeometricBoundingVolume. + */ bool BoundingVolume:: around_geometric(const BoundingVolume **first, const BoundingVolume **last) { mathutil_cat.warning() @@ -421,105 +338,80 @@ around_geometric(const BoundingVolume **first, const BoundingVolume **last) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_sphere -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a sphere. + */ int BoundingVolume:: contains_sphere(const BoundingSphere *sphere) const { return contains_finite(sphere); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a box. + */ int BoundingVolume:: contains_box(const BoundingBox *box) const { return contains_finite(box); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int BoundingVolume:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { return contains_finite(hexahedron); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a line. + */ int BoundingVolume:: contains_line(const BoundingLine *line) const { return contains_geometric(line); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a plane. + */ int BoundingVolume:: contains_plane(const BoundingPlane *plane) const { return contains_geometric(plane); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_union -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a union object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a union object. + */ int BoundingVolume:: contains_union(const UnionBoundingVolume *unionv) const { return unionv->other_contains_union(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_intersection -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be an intersection object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be an intersection object. + */ int BoundingVolume:: contains_intersection(const IntersectionBoundingVolume *intersection) const { return intersection->other_contains_intersection(this); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_finite -// Access: Protected, Virtual -// Description: Generic handler for a FiniteBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a FiniteBoundingVolume. + */ int BoundingVolume:: contains_finite(const FiniteBoundingVolume *volume) const { return contains_geometric(volume); } -//////////////////////////////////////////////////////////////////// -// Function: BoundingVolume::contains_geometric -// Access: Protected, Virtual -// Description: Generic handler for a GeometricBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a GeometricBoundingVolume. + */ int BoundingVolume:: contains_geometric(const GeometricBoundingVolume *volume) const { mathutil_cat.warning() @@ -563,4 +455,3 @@ operator >> (istream &in, BoundingVolume::BoundsType &type) { } return in; } - diff --git a/panda/src/mathutil/boundingVolume.h b/panda/src/mathutil/boundingVolume.h index ab6f02578f..df904145ad 100644 --- a/panda/src/mathutil/boundingVolume.h +++ b/panda/src/mathutil/boundingVolume.h @@ -1,16 +1,15 @@ -// Filename: boundingVolume.h -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boundingVolume.h + * @author drose + * @date 1999-10-01 + */ #ifndef BOUNDINGVOLUME_H #define BOUNDINGVOLUME_H @@ -32,16 +31,13 @@ class UnionBoundingVolume; class IntersectionBoundingVolume; -//////////////////////////////////////////////////////////////////// -// Class : BoundingVolume -// Description : This is an abstract class for any volume in any sense -// which can be said to define the locality of reference -// of a node in a graph, along with all of its -// descendants. It is not necessarily a geometric -// volume (although see GeometricBoundingVolume); this -// is simply an abstract interface for bounds of any -// sort. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class for any volume in any sense which can be said to + * define the locality of reference of a node in a graph, along with all of + * its descendants. It is not necessarily a geometric volume (although see + * GeometricBoundingVolume); this is simply an abstract interface for bounds + * of any sort. + */ class EXPCL_PANDA_MATHUTIL BoundingVolume : public TypedReferenceCount { public: INLINE_MATHUTIL BoundingVolume(); @@ -57,15 +53,14 @@ PUBLISHED: INLINE_MATHUTIL bool extend_by(const BoundingVolume *vol); public: - // It might be nice to make these template member functions so we - // could have true STL-style first/last iterators, but that's - // impossible for virtual functions. + // It might be nice to make these template member functions so we could have + // true STL-style firstlast iterators, but that's impossible for virtual + // functions. bool around(const BoundingVolume **first, const BoundingVolume **last); PUBLISHED: - // The contains() functions return the union of one or more of these - // bits. + // The contains() functions return the union of one or more of these bits. enum IntersectionFlags { // If no bits are set, it is known that there is no intersection. IF_no_intersection = 0, @@ -73,26 +68,25 @@ PUBLISHED: // IF_possible is set if there might be an intersection. IF_possible = 0x01, - // IF_some is set if there is definitely an intersection. In this - // case, IF_possible will also be set. + // IF_some is set if there is definitely an intersection. In this case, + // IF_possible will also be set. IF_some = 0x02, - // IF_all is set if the other bounding volume is known to be - // completely within this bounding volume: that is, there is no - // part of the other bounding volume that does not intersect this - // one. It does *not* indicate the inverse; it is possible that - // some part of this bounding volume does not intersect the other. + // IF_all is set if the other bounding volume is known to be completely + // within this bounding volume: that is, there is no part of the other + // bounding volume that does not intersect this one. It does *not* + // indicate the inverse; it is possible that some part of this bounding + // volume does not intersect the other. - // Also, the converse is not implied: if IF_all is not set, you - // simply don't know whether the other volume is completely - // contained within this one or not. + // Also, the converse is not implied: if IF_all is not set, you simply + // don't know whether the other volume is completely contained within this + // one or not. - // When IF_all is set, both IF_possible and IF_some will also be - // set. + // When IF_all is set, both IF_possible and IF_some will also be set. IF_all = 0x04, - // IF_dont_understand is set if the particular volume/volume - // intersection test has not been implemented. + // IF_dont_understand is set if the particular volumevolume intersection + // test has not been implemented. IF_dont_understand = 0x08 }; @@ -131,9 +125,8 @@ protected: int _flags; protected: - // The following functions support double-dispatch of virtual - // methods, so we can easily extend_by() various types of bounding - // volumes. + // The following functions support double-dispatch of virtual methods, so we + // can easily extend_by() various types of bounding volumes. // These functions are the first dispatch point. virtual bool extend_other(BoundingVolume *other) const=0; @@ -142,8 +135,8 @@ protected: const BoundingVolume **last) const=0; virtual int contains_other(const BoundingVolume *other) const=0; - // These functions are the second dispatch point. They actually do - // the work. + // These functions are the second dispatch point. They actually do the + // work. virtual bool extend_by_sphere(const BoundingSphere *sphere); virtual bool extend_by_box(const BoundingBox *box); virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron); diff --git a/panda/src/mathutil/config_mathutil.cxx b/panda/src/mathutil/config_mathutil.cxx index 28c916d3bd..2226b67946 100644 --- a/panda/src/mathutil/config_mathutil.cxx +++ b/panda/src/mathutil/config_mathutil.cxx @@ -1,16 +1,15 @@ -// Filename: config_mathutil.cxx -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_mathutil.cxx + * @author drose + * @date 1999-10-01 + */ #include "config_mathutil.h" #include "boundingVolume.h" @@ -54,14 +53,12 @@ ConfigVariableEnum bounds_type "also use 'fastest' if you don't want Panda to waste much time " "computing the most optimal bounding volume.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libmathutil -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmathutil() { static bool initialized = false; diff --git a/panda/src/mathutil/config_mathutil.h b/panda/src/mathutil/config_mathutil.h index 9bbc35cc9a..10e59f721b 100644 --- a/panda/src/mathutil/config_mathutil.h +++ b/panda/src/mathutil/config_mathutil.h @@ -1,16 +1,15 @@ -// Filename: config_mathutil.h -// Created by: drose (01Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_mathutil.h + * @author drose + * @date 1999-10-01 + */ #ifndef CONFIG_MATHUTIL_H #define CONFIG_MATHUTIL_H @@ -32,5 +31,3 @@ extern EXPCL_PANDA_MATHUTIL ConfigVariableEnum bound extern EXPCL_PANDA_MATHUTIL void init_libmathutil(); #endif - - diff --git a/panda/src/mathutil/fftCompressor.cxx b/panda/src/mathutil/fftCompressor.cxx index e8932d1ec5..47193445b9 100644 --- a/panda/src/mathutil/fftCompressor.cxx +++ b/panda/src/mathutil/fftCompressor.cxx @@ -1,16 +1,15 @@ -// Filename: fftCompressor.cxx -// Created by: drose (11Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fftCompressor.cxx + * @author drose + * @date 2000-12-11 + */ #include "fftCompressor.h" #include "config_mathutil.h" @@ -24,10 +23,8 @@ #ifdef HAVE_FFTW -// hack..... -// this is a hack to help interrogate sort out a macro -// in the system poll and select definitions -// +// hack..... this is a hack to help interrogate sort out a macro in the system +// poll and select definitions #ifdef howmany #undef howmany #endif @@ -38,8 +35,8 @@ #include "rfftw.h" #endif -// These FFTW support objects can only be defined if we actually have -// the FFTW library available. +// These FFTW support objects can only be defined if we actually have the FFTW +// library available. static rfftw_plan get_real_compress_plan(int length); static rfftw_plan get_real_decompress_plan(int length); @@ -49,12 +46,9 @@ static RealPlans _real_decompress_plans; #endif -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::Constructor -// Access: Public -// Description: Constructs a new compressor object with default -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new compressor object with default parameters. + */ FFTCompressor:: FFTCompressor() { _bam_minor_version = 0; @@ -63,17 +57,13 @@ FFTCompressor() { _transpose_quats = false; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::is_compression_available -// Access: Public, Static -// Description: Returns true if the FFTW library is compiled in, so -// that this class is actually capable of doing useful -// compression/decompression work. Returns false -// otherwise, in which case any attempt to write a -// compressed stream will actually write an uncompressed -// stream, and any attempt to read a compressed stream -// will fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the FFTW library is compiled in, so that this class is + * actually capable of doing useful compression/decompression work. Returns + * false otherwise, in which case any attempt to write a compressed stream + * will actually write an uncompressed stream, and any attempt to read a + * compressed stream will fail. + */ bool FFTCompressor:: is_compression_available() { #ifndef HAVE_FFTW @@ -83,29 +73,22 @@ is_compression_available() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::set_quality -// Access: Public -// Description: Sets the quality factor for the compression. This is -// an integer in the range 0 - 100 that roughly controls -// how aggressively the reals are compressed; lower -// numbers mean smaller output, and more data loss. -// -// There are a few special cases. Quality -1 means to -// use whatever individual parameters are set in the -// user's Configrc file, rather than the single quality -// dial. Quality 101 or higher means to generate -// lossless output (this is the default if libfftw is -// not available). -// -// Quality 102 writes all four components of quaternions -// to the output file, rather than just three, quality -// 103 converts hpr to matrix (instead of quat) and -// writes a 9-component matrix, and quality 104 just -// writes out hpr directly. Quality levels 102 and -// greater are strictly for debugging purposes, and are -// only available if NDEBUG is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Sets the quality factor for the compression. This is an integer in the + * range 0 - 100 that roughly controls how aggressively the reals are + * compressed; lower numbers mean smaller output, and more data loss. + * + * There are a few special cases. Quality -1 means to use whatever individual + * parameters are set in the user's Configrc file, rather than the single + * quality dial. Quality 101 or higher means to generate lossless output + * (this is the default if libfftw is not available). + * + * Quality 102 writes all four components of quaternions to the output file, + * rather than just three, quality 103 converts hpr to matrix (instead of + * quat) and writes a 9-component matrix, and quality 104 just writes out hpr + * directly. Quality levels 102 and greater are strictly for debugging + * purposes, and are only available if NDEBUG is not defined. + */ void FFTCompressor:: set_quality(int quality) { #ifndef HAVE_FFTW @@ -120,17 +103,14 @@ set_quality(int quality) { _quality = quality; if (_quality < 0) { - // A negative quality indicates we should read the various - // parameters from individual config variables. + // A negative quality indicates we should read the various parameters from + // individual config variables. _fft_offset = fft_offset; _fft_factor = fft_factor; _fft_exponent = fft_exponent; } else if (_quality < 40) { - // 0 - 40 : - // fft-offset 1.0 - 0.001 - // fft-factor 1.0 - // fft-exponent 4.0 + // 0 - 40 : fft-offset 1.0 - 0.001 fft-factor 1.0 fft-exponent 4.0 double t = (double)_quality / 40.0; _fft_offset = interpolate(t, 1.0, 0.001); @@ -138,10 +118,7 @@ set_quality(int quality) { _fft_exponent = 4.0; } else if (_quality < 95) { - // 40 - 95: - // fft-offset 0.001 - // fft-factor 1.0 - 0.1 - // fft-exponent 4.0 + // 40 - 95: fft-offset 0.001 fft-factor 1.0 - 0.1 fft-exponent 4.0 double t = (double)(_quality - 40) / 55.0; _fft_offset = 0.001; @@ -149,10 +126,7 @@ set_quality(int quality) { _fft_exponent = 4.0; } else { - // 95 - 100: - // fft-offset 0.001 - // fft-factor 0.1 - 0.0 - // fft-exponent 4.0 + // 95 - 100: fft-offset 0.001 fft-factor 0.1 - 0.0 fft-exponent 4.0 double t = (double)(_quality - 95) / 5.0; _fft_offset = 0.001; @@ -162,78 +136,59 @@ set_quality(int quality) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::get_quality -// Access: Public -// Description: Returns the quality number that was previously set -// via set_quality(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the quality number that was previously set via set_quality(). + */ int FFTCompressor:: get_quality() const { return _quality; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::set_use_error_threshold -// Access: Public -// Description: Enables or disables the use of the error threshold -// measurement to put a cap on the amount of damage done -// by lossy compression. When this is enabled, the -// potential results of the compression are analyzed -// before the data is written; if it is determined that -// the compression will damage a particular string of -// reals too much, that particular string of reals is -// written uncompressed. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables the use of the error threshold measurement to put a cap + * on the amount of damage done by lossy compression. When this is enabled, + * the potential results of the compression are analyzed before the data is + * written; if it is determined that the compression will damage a particular + * string of reals too much, that particular string of reals is written + * uncompressed. + */ void FFTCompressor:: set_use_error_threshold(bool use_error_threshold) { _use_error_threshold = use_error_threshold; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::get_use_error_threshold -// Access: Public -// Description: Returns whether the error threshold measurement is -// enabled. See set_use_error_threshold(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the error threshold measurement is enabled. See + * set_use_error_threshold(). + */ bool FFTCompressor:: get_use_error_threshold() const { return _use_error_threshold; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::set_transpose_quats -// Access: Public -// Description: Sets the transpose_quats flag. This is provided -// mainly for backward compatibility with old bam files -// that were written out with the quaternions -// inadvertently transposed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transpose_quats flag. This is provided mainly for backward + * compatibility with old bam files that were written out with the quaternions + * inadvertently transposed. + */ void FFTCompressor:: set_transpose_quats(bool flag) { _transpose_quats = flag; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::get_transpose_quats -// Access: Public -// Description: Returns the transpose_quats flag. See -// set_transpose_quats(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the transpose_quats flag. See set_transpose_quats(). + */ bool FFTCompressor:: get_transpose_quats() const { return _transpose_quats; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::write_header -// Access: Public -// Description: Writes the compression parameters to the indicated -// datagram. It is necessary to call this before -// writing anything else to the datagram, since these -// parameters will be necessary to correctly decompress -// the data later. -//////////////////////////////////////////////////////////////////// +/** + * Writes the compression parameters to the indicated datagram. It is + * necessary to call this before writing anything else to the datagram, since + * these parameters will be necessary to correctly decompress the data later. + */ void FFTCompressor:: write_header(Datagram &datagram) { datagram.add_int8(_quality); @@ -244,12 +199,9 @@ write_header(Datagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::write_reals -// Access: Public -// Description: Writes an array of floating-point numbers to the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes an array of floating-point numbers to the indicated datagram. + */ void FFTCompressor:: write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { datagram.add_int32(length); @@ -284,15 +236,14 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { // First, check the compressability. bool reject_compression = false; - // This logic needs a closer examination. Not sure it's useful - // as-is. + // This logic needs a closer examination. Not sure it's useful as-is. /* if (_use_error_threshold) { // Don't encode the data if it moves too erratically. PN_stdfloat error = get_compressability(array, length); if (error > fft_error_threshold) { - // No good: the data probably won't compress well. Just write - // out lossless data. + // No good: the data probably won't compress well. Just write out + // lossless data. reject_compression = true; } } @@ -323,8 +274,8 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { rfftw_one(plan, data, half_complex); - // Now encode the numbers, run-length encoded by size, so we only - // write out the number of bits we need for each number. + // Now encode the numbers, run-length encoded by size, so we only write out + // the number of bits we need for each number. vector_double run; RunWidth run_width = RW_invalid; @@ -358,9 +309,9 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { num_width = RW_double; } - // A special case: if we're writing a string of one-byters and we - // come across a single intervening zero, don't interrupt the run - // just for that. + // A special case: if we're writing a string of one-byters and we come + // across a single intervening zero, don't interrupt the run just for + // that. if (run_width == RW_8 && num_width == RW_0) { if (i + 1 >= length || half_complex[i + 1] != 0.0) { num_width = RW_8; @@ -382,18 +333,15 @@ write_reals(Datagram &datagram, const PN_stdfloat *array, int length) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::write_hprs -// Access: Public -// Description: Writes an array of HPR angles to the indicated -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes an array of HPR angles to the indicated datagram. + */ void FFTCompressor:: write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { #ifndef NDEBUG if (_quality >= 104) { - // If quality level is at least 104, we don't even convert hpr at - // all. This is just for debugging. + // If quality level is at least 104, we don't even convert hpr at all. + // This is just for debugging. vector_stdfloat h, p, r; h.reserve(length); @@ -418,8 +366,8 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { return; } if (_quality >= 103) { - // If quality level is 103, we convert hpr to a table of matrices. - // This is just for debugging. + // If quality level is 103, we convert hpr to a table of matrices. This + // is just for debugging. vector_stdfloat m00, m01, m02, m10, m11, m12, @@ -464,13 +412,13 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } #endif - // First, convert the HPR's to quats. We expect quats to have - // better FFT consistency, and therefore compress better, even - // though they have an extra component. + // First, convert the HPR's to quats. We expect quats to have better FFT + // consistency, and therefore compress better, even though they have an + // extra component. - // However, because the quaternion will be normalized, we don't even - // have to write out all three components; any three can be used to - // determine the fourth (provided we ensure consistency of sign). + // However, because the quaternion will be normalized, we don't even have to + // write out all three components; any three can be used to determine the + // fourth (provided we ensure consistency of sign). vector_stdfloat qr, qi, qj, qk; @@ -481,7 +429,7 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { for (int i = 0; i < length; i++) { LMatrix3 mat; - compose_matrix(mat, LVecBase3(1.0, 1.0, 1.0), LVecBase3(0.0, 0.0, 0.0), + compose_matrix(mat, LVecBase3(1.0, 1.0, 1.0), LVecBase3(0.0, 0.0, 0.0), array[i]); if (_transpose_quats) { mat.transpose_in_place(); @@ -491,16 +439,15 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { rot.normalize(); // This may not be necessary, but let's not take chances. if (rot.get_r() < 0) { - // Since rot == -rot, we can flip the quarternion if need be to - // keep the r component positive. This has two advantages. - // One, it makes it possible to infer r completely given i, j, - // and k (since we know it must be >= 0), and two, it helps - // protect against poor continuity caused by inadvertent - // flipping of the quarternion's sign between frames. + // Since rot == -rot, we can flip the quarternion if need be to keep the + // r component positive. This has two advantages. One, it makes it + // possible to infer r completely given i, j, and k (since we know it + // must be >= 0), and two, it helps protect against poor continuity + // caused by inadvertent flipping of the quarternion's sign between + // frames. - // The choice of leaving r implicit rather than any of the other - // three seems to work the best in terms of guaranteeing - // continuity. + // The choice of leaving r implicit rather than any of the other three + // seems to work the best in terms of guaranteeing continuity. rot.set(-rot.get_r(), -rot.get_i(), -rot.get_j(), -rot.get_k()); } @@ -530,8 +477,8 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { qk.push_back(rot.get_k()); } - // If quality is at least 102, we write all four quat components, - // instead of just the three. This is just for debugging. + // If quality is at least 102, we write all four quat components, instead of + // just the three. This is just for debugging. #ifndef NDEBUG if (_quality >= 102) { if (length == 0) { @@ -552,16 +499,13 @@ write_hprs(Datagram &datagram, const LVecBase3 *array, int length) { } } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::read_header -// Access: Public -// Description: Reads the compression header that was written -// previously. This fills in the compression parameters -// necessary to correctly decompress the following data. -// -// Returns true if the header is read successfully, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the compression header that was written previously. This fills in + * the compression parameters necessary to correctly decompress the following + * data. + * + * Returns true if the header is read successfully, false otherwise. + */ bool FFTCompressor:: read_header(DatagramIterator &di, int bam_minor_version) { _bam_minor_version = bam_minor_version; @@ -591,16 +535,12 @@ read_header(DatagramIterator &di, int bam_minor_version) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::read_reals -// Access: Public -// Description: Reads an array of floating-point numbers. The result -// is pushed onto the end of the indicated vector, which -// is not cleared first; it is the user's responsibility -// to ensure that the array is initially empty. Returns -// true if the data is read correctly, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * Reads an array of floating-point numbers. The result is pushed onto the + * end of the indicated vector, which is not cleared first; it is the user's + * responsibility to ensure that the array is initially empty. Returns true + * if the data is read correctly, false if there is an error. + */ bool FFTCompressor:: read_reals(DatagramIterator &di, vector_stdfloat &array) { int length = di.get_int32(); @@ -632,11 +572,11 @@ read_reals(DatagramIterator &di, vector_stdfloat &array) { return true; } - // Normal case: read in the FFT array, and convert it back to - // (nearly) the original numbers. + // Normal case: read in the FFT array, and convert it back to (nearly) the + // original numbers. - // First, check the reject_compression flag. If it's set, we - // decided to just write out the stream uncompressed. + // First, check the reject_compression flag. If it's set, we decided to + // just write out the stream uncompressed. bool reject_compression = di.get_bool(); if (reject_compression) { array.reserve(array.size() + length); @@ -674,26 +614,22 @@ read_reals(DatagramIterator &di, vector_stdfloat &array) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::read_hprs -// Access: Public -// Description: Reads an array of HPR angles. The result is pushed -// onto the end of the indicated vector, which is not -// cleared first; it is the user's responsibility to -// ensure that the array is initially empty. -// -// new_hpr is a temporary, transitional parameter. If -// it is set false, the hprs are decompressed according -// to the old, broken hpr calculation; if true, the hprs -// are decompressed according to the new, correct hpr -// calculation. -//////////////////////////////////////////////////////////////////// +/** + * Reads an array of HPR angles. The result is pushed onto the end of the + * indicated vector, which is not cleared first; it is the user's + * responsibility to ensure that the array is initially empty. + * + * new_hpr is a temporary, transitional parameter. If it is set false, the + * hprs are decompressed according to the old, broken hpr calculation; if + * true, the hprs are decompressed according to the new, correct hpr + * calculation. + */ bool FFTCompressor:: read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { #ifndef NDEBUG if (_quality >= 104) { - // If quality level is at least 104, we don't even convert hpr to - // quat. This is just for debugging. + // If quality level is at least 104, we don't even convert hpr to quat. + // This is just for debugging. vector_stdfloat h, p, r; bool okflag = true; okflag = @@ -711,8 +647,8 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { return okflag; } if (_quality >= 103) { - // If quality level is 103, we read in a table of 3x3 rotation - // matrices. This is just for debugging. + // If quality level is 103, we read in a table of 3x3 rotation matrices. + // This is just for debugging. vector_stdfloat m00, m01, m02, m10, m11, m12, @@ -810,29 +746,23 @@ read_hprs(DatagramIterator &di, pvector &array, bool new_hpr) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::read_hprs -// Access: Public -// Description: Reads an array of HPR angles. The result is pushed -// onto the end of the indicated vector, which is not -// cleared first; it is the user's responsibility to -// ensure that the array is initially empty. -//////////////////////////////////////////////////////////////////// +/** + * Reads an array of HPR angles. The result is pushed onto the end of the + * indicated vector, which is not cleared first; it is the user's + * responsibility to ensure that the array is initially empty. + */ bool FFTCompressor:: read_hprs(DatagramIterator &di, pvector &array) { return read_hprs(di, array, true); } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::free_storage -// Access: Public, Static -// Description: Frees memory that has been allocated during past runs -// of the FFTCompressor. This is an optional call, but -// it may be made from time to time to empty the global -// cache that the compressor objects keep to facilitate -// fast compression/decompression. -//////////////////////////////////////////////////////////////////// +/** + * Frees memory that has been allocated during past runs of the FFTCompressor. + * This is an optional call, but it may be made from time to time to empty the + * global cache that the compressor objects keep to facilitate fast + * compression/decompression. + */ void FFTCompressor:: free_storage() { #ifdef HAVE_FFTW @@ -853,13 +783,10 @@ free_storage() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::write_run -// Access: Private -// Description: Writes a sequence of integers that all require the -// same number of bits. Returns the number of integers -// written, i.e. run.size(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a sequence of integers that all require the same number of bits. + * Returns the number of integers written, i.e. run.size(). + */ int FFTCompressor:: write_run(Datagram &datagram, FFTCompressor::RunWidth run_width, const vector_double &run) { @@ -869,21 +796,19 @@ write_run(Datagram &datagram, FFTCompressor::RunWidth run_width, nassertr(run_width != RW_invalid, 0); if (run_width != RW_double) { - // If the width is anything other than RW_double, we write a - // single byte indicating the width and length of the upcoming - // run. + // If the width is anything other than RW_double, we write a single byte + // indicating the width and length of the upcoming run. if (run.size() <= RW_length_mask && ((int)run_width | run.size()) != RW_double) { - // If there are enough bits remaining in the byte, use them to - // indicate the length of the run. We have to be a little - // careful, however, not to accidentally write a byte that looks - // like an RW_double flag. + // If there are enough bits remaining in the byte, use them to indicate + // the length of the run. We have to be a little careful, however, not + // to accidentally write a byte that looks like an RW_double flag. datagram.add_uint8((int)run_width | run.size()); } else { - // Otherwise, write zero as the length, to indicate that we'll - // write the actual length in the following 16-bit word. + // Otherwise, write zero as the length, to indicate that we'll write the + // actual length in the following 16-bit word. datagram.add_uint8(run_width); // Assuming, of course, that the length fits within 16 bits. @@ -921,9 +846,9 @@ write_run(Datagram &datagram, FFTCompressor::RunWidth run_width, case RW_double: for (ri = run.begin(); ri != run.end(); ++ri) { - // In the case of RW_double, we only write the numbers one at a - // time, each time preceded by the RW_double flag. Hopefully - // this will happen only rarely. + // In the case of RW_double, we only write the numbers one at a time, + // each time preceded by the RW_double flag. Hopefully this will happen + // only rarely. datagram.add_int8((PN_int8)RW_double); datagram.add_float64(*ri); } @@ -936,15 +861,12 @@ write_run(Datagram &datagram, FFTCompressor::RunWidth run_width, return run.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::read_run -// Access: Private -// Description: Reads a sequence of integers that all require the -// same number of bits. Returns the number of integers -// read. It is the responsibility of the user to clear -// the vector before calling this function, or the -// numbers read will be appended to the end. -//////////////////////////////////////////////////////////////////// +/** + * Reads a sequence of integers that all require the same number of bits. + * Returns the number of integers read. It is the responsibility of the user + * to clear the vector before calling this function, or the numbers read will + * be appended to the end. + */ int FFTCompressor:: read_run(DatagramIterator &di, vector_double &run) { PN_uint8 start = di.get_uint8(); @@ -952,8 +874,8 @@ read_run(DatagramIterator &di, vector_double &run) { int length; if ((start & 0xff) == RW_double) { - // RW_double is a special case, and requires the whole byte. In - // this case, we don't encode a length, but assume it's only one. + // RW_double is a special case, and requires the whole byte. In this + // case, we don't encode a length, but assume it's only one. run_width = RW_double; length = 1; @@ -963,8 +885,8 @@ read_run(DatagramIterator &di, vector_double &run) { } if (length == 0) { - // If the length was zero, it means the actual length follows as a - // 16-bit word. + // If the length was zero, it means the actual length follows as a 16-bit + // word. length = di.get_uint16(); } nassertr(length != 0, 0); @@ -1010,12 +932,10 @@ read_run(DatagramIterator &di, vector_double &run) { return length; } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::get_scale_factor -// Access: Private -// Description: Returns the appropriate scaling for the given -// position within the halfcomplex array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate scaling for the given position within the + * halfcomplex array. + */ double FFTCompressor:: get_scale_factor(int i, int length) const { int m = (length / 2) + 1; @@ -1026,31 +946,25 @@ get_scale_factor(int i, int length) const { _fft_factor * pow((double)(m-1 - k) / (double)(m-1), _fft_exponent); } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::interpolate -// Access: Private, Static -// Description: Returns a number between a and b, inclusive, -// according to the value of t between 0 and 1, -// inclusive. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number between a and b, inclusive, according to the value of t + * between 0 and 1, inclusive. + */ double FFTCompressor:: interpolate(double t, double a, double b) { return a + t * (b - a); } -//////////////////////////////////////////////////////////////////// -// Function: FFTCompressor::get_compressability -// Access: Private -// Description: Returns a factor that indicates how erratically the -// values are changing. The lower the result, the -// calmer the numbers, and the greater its likelihood of -// being successfully compressed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a factor that indicates how erratically the values are changing. + * The lower the result, the calmer the numbers, and the greater its + * likelihood of being successfully compressed. + */ PN_stdfloat FFTCompressor:: get_compressability(const PN_stdfloat *data, int length) const { - // The result returned is actually the standard deviation of the - // table of deltas between consecutive frames. This number is - // larger if the frames have wildly different values. + // The result returned is actually the standard deviation of the table of + // deltas between consecutive frames. This number is larger if the frames + // have wildly different values. if (length <= 2) { return 0.0; @@ -1079,11 +993,10 @@ get_compressability(const PN_stdfloat *data, int length) const { #ifdef HAVE_FFTW -//////////////////////////////////////////////////////////////////// -// Function: get_real_compress_plan -// Description: Returns a FFTW plan suitable for compressing a float -// array of the indicated length. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FFTW plan suitable for compressing a float array of the indicated + * length. + */ static rfftw_plan get_real_compress_plan(int length) { RealPlans::iterator pi; @@ -1099,11 +1012,10 @@ get_real_compress_plan(int length) { return plan; } -//////////////////////////////////////////////////////////////////// -// Function: get_real_decompress_plan -// Description: Returns a FFTW plan suitable for decompressing a float -// array of the indicated length. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FFTW plan suitable for decompressing a float array of the + * indicated length. + */ static rfftw_plan get_real_decompress_plan(int length) { RealPlans::iterator pi; diff --git a/panda/src/mathutil/fftCompressor.h b/panda/src/mathutil/fftCompressor.h index ccc693501a..c7082a6f41 100644 --- a/panda/src/mathutil/fftCompressor.h +++ b/panda/src/mathutil/fftCompressor.h @@ -1,16 +1,15 @@ -// Filename: fftCompressor.h -// Created by: drose (11Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fftCompressor.h + * @author drose + * @date 2000-12-11 + */ #ifndef FFTCOMPRESSOR_H #define FFTCOMPRESSOR_H @@ -26,22 +25,18 @@ class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : FFTCompressor -// Description : This class manages a lossy compression and -// decompression of a stream of floating-point numbers -// to a datagram, based a fourier transform algorithm -// (similar in principle to JPEG compression). -// -// Actually, it doesn't do any real compression on its -// own; it just outputs a stream of integers that should -// compress much tighter via gzip than the original -// stream of floats would have. -// -// This class depends on the external FFTW library; -// without it, it will fall back on lossless output of -// the original data. -//////////////////////////////////////////////////////////////////// +/** + * This class manages a lossy compression and decompression of a stream of + * floating-point numbers to a datagram, based a fourier transform algorithm + * (similar in principle to JPEG compression). + * + * Actually, it doesn't do any real compression on its own; it just outputs a + * stream of integers that should compress much tighter via gzip than the + * original stream of floats would have. + * + * This class depends on the external FFTW library; without it, it will fall + * back on lossless output of the original data. + */ class EXPCL_PANDA_MATHUTIL FFTCompressor { public: FFTCompressor(); @@ -71,10 +66,10 @@ public: private: enum RunWidth { - // We write a byte to the datagram at the beginning of each run to - // encode the width and length of the run. The width is indicated - // by the top two bits, while the length fits in the lower six, - // except RW_double, which is a special case. + // We write a byte to the datagram at the beginning of each run to encode + // the width and length of the run. The width is indicated by the top two + // bits, while the length fits in the lower six, except RW_double, which + // is a special case. RW_width_mask = 0xc0, RW_length_mask = 0x3f, RW_0 = 0x00, @@ -103,4 +98,3 @@ private: }; #endif - diff --git a/panda/src/mathutil/finiteBoundingVolume.cxx b/panda/src/mathutil/finiteBoundingVolume.cxx index b0ff3f47dc..8ee734688b 100644 --- a/panda/src/mathutil/finiteBoundingVolume.cxx +++ b/panda/src/mathutil/finiteBoundingVolume.cxx @@ -1,16 +1,15 @@ -// Filename: finiteBoundingVolume.cxx -// Created by: drose (02Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file finiteBoundingVolume.cxx + * @author drose + * @date 1999-10-02 + */ #include "finiteBoundingVolume.h" #include "boundingBox.h" @@ -18,11 +17,9 @@ TypeHandle FiniteBoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FiniteBoundingVolume::get_volume -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat FiniteBoundingVolume:: get_volume() const { nassertr(!is_infinite(), 0.0f); @@ -33,53 +30,44 @@ get_volume() const { mathutil_cat.warning() << get_type() << "::get_volume() called\n"; - // We don't know how to compute the volume of this shape correctly; - // just calculate the volume of its containing box. + // We don't know how to compute the volume of this shape correctly; just + // calculate the volume of its containing box. BoundingBox box(get_min(), get_max()); box.local_object(); return box.get_volume(); } -//////////////////////////////////////////////////////////////////// -// Function: FiniteBoundingVolume::as_finite_bounding_volume -// Access: Public, Virtual -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const FiniteBoundingVolume *FiniteBoundingVolume:: as_finite_bounding_volume() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: FiniteBoundingVolume::around_lines -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty line. + */ bool FiniteBoundingVolume:: around_lines(const BoundingVolume **, const BoundingVolume **) { _flags = F_infinite; - // Since it's a FiniteBoundingVolume, we can't do any better than - // making it infinite. So we return true. + // Since it's a FiniteBoundingVolume, we can't do any better than making it + // infinite. So we return true. return true; } -//////////////////////////////////////////////////////////////////// -// Function: FiniteBoundingVolume::around_planes -// Access: Protected, Virtual -// Description: Double-dispatch support: called by around_other() -// when the type of the first element in the list is -// known to be a nonempty plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by around_other() when the type of the + * first element in the list is known to be a nonempty plane. + */ bool FiniteBoundingVolume:: around_planes(const BoundingVolume **, const BoundingVolume **) { _flags = F_infinite; - // Since it's a FiniteBoundingVolume, we can't do any better than - // making it infinite. So we return true. + // Since it's a FiniteBoundingVolume, we can't do any better than making it + // infinite. So we return true. return true; } diff --git a/panda/src/mathutil/finiteBoundingVolume.h b/panda/src/mathutil/finiteBoundingVolume.h index 32e1d513e2..e344151685 100644 --- a/panda/src/mathutil/finiteBoundingVolume.h +++ b/panda/src/mathutil/finiteBoundingVolume.h @@ -1,16 +1,15 @@ -// Filename: finiteBoundingVolume.h -// Created by: drose (02Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file finiteBoundingVolume.h + * @author drose + * @date 1999-10-02 + */ #ifndef FINITEBOUNDINGVOLUME_H #define FINITEBOUNDINGVOLUME_H @@ -20,12 +19,11 @@ #include "geometricBoundingVolume.h" -//////////////////////////////////////////////////////////////////// -// Class : FiniteBoundingVolume -// Description : A special kind of GeometricBoundingVolume that is -// known to be finite. It is possible to query this -// kind of volume for its minimum and maximum extents. -//////////////////////////////////////////////////////////////////// +/** + * A special kind of GeometricBoundingVolume that is known to be finite. It + * is possible to query this kind of volume for its minimum and maximum + * extents. + */ class EXPCL_PANDA_MATHUTIL FiniteBoundingVolume : public GeometricBoundingVolume { PUBLISHED: virtual LPoint3 get_min() const=0; @@ -60,22 +58,3 @@ private: }; #endif - - - - - - - - - - - - - - - - - - - diff --git a/panda/src/mathutil/frustum.h b/panda/src/mathutil/frustum.h index 7e0051ced2..f490df1152 100644 --- a/panda/src/mathutil/frustum.h +++ b/panda/src/mathutil/frustum.h @@ -1,22 +1,20 @@ -// Filename: frustum.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frustum.h + * @author mike + * @date 1997-01-09 + */ + #ifndef FRUSTUM_H #define FRUSTUM_H -// -//////////////////////////////////////////////////////////////////// + // Includes -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include #include "luse.h" diff --git a/panda/src/mathutil/frustum_src.I b/panda/src/mathutil/frustum_src.I index ce1e72eebc..f76d5bec53 100644 --- a/panda/src/mathutil/frustum_src.I +++ b/panda/src/mathutil/frustum_src.I @@ -1,22 +1,19 @@ -// Filename: frustum_src.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frustum_src.I + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: Constructor -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL FLOATNAME(LFrustum):: FLOATNAME(LFrustum)() { _fnear = FLOATCONST(1.4142); @@ -27,30 +24,24 @@ FLOATNAME(LFrustum)() { _b = -1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: make_ortho_2D -// Access: -// Description: Sets up a two-dimensional orthographic frustum -//////////////////////////////////////////////////////////////////// +/** + * Sets up a two-dimensional orthographic frustum + */ INLINE_MATHUTIL void FLOATNAME(LFrustum)::make_ortho_2D() { make_ortho(-1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: make_ortho_2D -// Access: -// Description: Sets up a two-dimensional orthographic frustum -//////////////////////////////////////////////////////////////////// +/** + * Sets up a two-dimensional orthographic frustum + */ INLINE_MATHUTIL void FLOATNAME(LFrustum):: make_ortho_2D(FLOATTYPE l, FLOATTYPE r, FLOATTYPE t, FLOATTYPE b) { make_ortho(-1.0f, 1.0f, l, r, t, b); } -//////////////////////////////////////////////////////////////////// -// Function: make_ortho_2D -// Access: -// Description: Behaves like gluOrtho -//////////////////////////////////////////////////////////////////// +/** + * Behaves like gluOrtho + */ INLINE_MATHUTIL void FLOATNAME(LFrustum)::make_ortho(FLOATTYPE fnear, FLOATTYPE ffar) { _fnear = fnear; _ffar = ffar; @@ -60,11 +51,9 @@ INLINE_MATHUTIL void FLOATNAME(LFrustum)::make_ortho(FLOATTYPE fnear, FLOATTYPE _b = -1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: make_ortho_2D -// Access: -// Description: Behaves like gluOrtho -//////////////////////////////////////////////////////////////////// +/** + * Behaves like gluOrtho + */ INLINE_MATHUTIL void FLOATNAME(LFrustum):: make_ortho(FLOATTYPE fnear, FLOATTYPE ffar, FLOATTYPE l, FLOATTYPE r, FLOATTYPE t, FLOATTYPE b) { @@ -76,28 +65,14 @@ make_ortho(FLOATTYPE fnear, FLOATTYPE ffar, FLOATTYPE l, FLOATTYPE r, _b = b; } -//////////////////////////////////////////////////////////////////// -// Function: make_perspective -// Access: -// Description: Behaves like gluPerspective (Aspect = width/height, -// Yfov in degrees) -// aspect -// +------------+ -// | | -// 1 | | yfov -// | | -// +------------+ -// -// -------+------ -// \ | / -// \ | / -// \ | / -// \ | / -// \ | / -// \|/ -// W yfov -// -//////////////////////////////////////////////////////////////////// +/** + * Behaves like gluPerspective (Aspect = width/height, Yfov in degrees) aspect + * +------------+ | | 1 | | yfov | | + * +------------+ + * + * -------+------ \ | \ | \ | \ | \ | \| W yfov + * + */ INLINE_MATHUTIL void FLOATNAME(LFrustum):: make_perspective_hfov(FLOATTYPE hfov, FLOATTYPE aspect, FLOATTYPE fnear, FLOATTYPE ffar) { @@ -133,11 +108,9 @@ make_perspective(FLOATTYPE xfov, FLOATTYPE yfov, FLOATTYPE fnear, _l = -_r; } -//////////////////////////////////////////////////////////////////// -// Function: get_perspective_params -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL void FLOATNAME(LFrustum):: get_perspective_params(FLOATTYPE& yfov, FLOATTYPE& aspect, FLOATTYPE& fnear, FLOATTYPE& ffar) const { @@ -147,11 +120,9 @@ get_perspective_params(FLOATTYPE& yfov, FLOATTYPE& aspect, ffar = _ffar; } -//////////////////////////////////////////////////////////////////// -// Function: get_perspective_params -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL void FLOATNAME(LFrustum):: get_perspective_params(FLOATTYPE& xfov, FLOATTYPE& yfov, FLOATTYPE& aspect, FLOATTYPE& fnear, FLOATTYPE& ffar) const { @@ -159,13 +130,10 @@ get_perspective_params(FLOATTYPE& xfov, FLOATTYPE& yfov, FLOATTYPE& aspect, get_perspective_params(yfov, aspect, fnear, ffar); } -//////////////////////////////////////////////////////////////////// -// Function: get_perspective_projection_mat -// Access: Public -// Description: This computes a transform matrix that performs the -// perspective transform defined by the frustum, -// accordinate to the indicated coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * This computes a transform matrix that performs the perspective transform + * defined by the frustum, accordinate to the indicated coordinate system. + */ INLINE_MATHUTIL FLOATNAME(LMatrix4) FLOATNAME(LFrustum):: get_perspective_projection_mat(CoordinateSystem cs) const { if (cs == CS_default) { @@ -225,13 +193,10 @@ get_perspective_projection_mat(CoordinateSystem cs) const { } } -//////////////////////////////////////////////////////////////////// -// Function: get_ortho_projection_mat -// Access: Public -// Description: This computes a transform matrix that performs the -// orthographic transform defined by the frustum, -// accordinate to the indicated coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * This computes a transform matrix that performs the orthographic transform + * defined by the frustum, accordinate to the indicated coordinate system. + */ INLINE_MATHUTIL FLOATNAME(LMatrix4) FLOATNAME(LFrustum):: get_ortho_projection_mat(CoordinateSystem cs) const { if (cs == CS_default) { diff --git a/panda/src/mathutil/frustum_src.h b/panda/src/mathutil/frustum_src.h index a8b12eceb8..737053b213 100644 --- a/panda/src/mathutil/frustum_src.h +++ b/panda/src/mathutil/frustum_src.h @@ -1,21 +1,19 @@ -// Filename: frustum_src.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file frustum_src.h + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Class : LFrustum -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_MATHUTIL FLOATNAME(LFrustum) { PUBLISHED: INLINE_MATHUTIL FLOATNAME(LFrustum)(); diff --git a/panda/src/mathutil/geometricBoundingVolume.I b/panda/src/mathutil/geometricBoundingVolume.I index 3bce5116be..21a32c4b48 100644 --- a/panda/src/mathutil/geometricBoundingVolume.I +++ b/panda/src/mathutil/geometricBoundingVolume.I @@ -1,54 +1,42 @@ -// Filename: geometricBoundingVolume.I -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geometricBoundingVolume.I + * @author drose + * @date 1999-10-07 + */ -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL GeometricBoundingVolume:: GeometricBoundingVolume() { } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::extend_by -// Access: Public -// Description: Increases the size of the volume to include the given -// volume. -//////////////////////////////////////////////////////////////////// +/** + * Increases the size of the volume to include the given volume. + */ INLINE_MATHUTIL bool GeometricBoundingVolume:: extend_by(const GeometricBoundingVolume *vol) { return BoundingVolume::extend_by(vol); } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::extend_by -// Access: Public -// Description: Increases the size of the volume to include the given -// point. -//////////////////////////////////////////////////////////////////// +/** + * Increases the size of the volume to include the given point. + */ INLINE_MATHUTIL bool GeometricBoundingVolume:: extend_by(const LPoint3 &point) { return extend_by_point(point); } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::around -// Access: Public -// Description: Resets the volume to enclose only the volumes -// indicated. -//////////////////////////////////////////////////////////////////// +/** + * Resets the volume to enclose only the volumes indicated. + */ INLINE_MATHUTIL bool GeometricBoundingVolume:: around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last) { @@ -56,12 +44,9 @@ around(const GeometricBoundingVolume **first, (const BoundingVolume **)last); } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::around -// Access: Public -// Description: Resets the volume to enclose only the points -// indicated. -//////////////////////////////////////////////////////////////////// +/** + * Resets the volume to enclose only the points indicated. + */ INLINE_MATHUTIL bool GeometricBoundingVolume:: around(const LPoint3 *first, const LPoint3 *last) { _flags = F_empty; @@ -72,25 +57,19 @@ around(const LPoint3 *first, const LPoint3 *last) { } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::contains -// Access: Public -// Description: Returns the appropriate set of IntersectionFlags to -// indicate the amount of intersection with the -// indicated volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate set of IntersectionFlags to indicate the amount of + * intersection with the indicated volume. + */ INLINE_MATHUTIL int GeometricBoundingVolume:: contains(const GeometricBoundingVolume *vol) const { return BoundingVolume::contains(vol); } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::contains -// Access: Public -// Description: Returns the appropriate set of IntersectionFlags to -// indicate the amount of intersection with the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate set of IntersectionFlags to indicate the amount of + * intersection with the indicated point. + */ INLINE_MATHUTIL int GeometricBoundingVolume:: contains(const LPoint3 &point) const { if (is_empty()) { @@ -100,13 +79,10 @@ contains(const LPoint3 &point) const { return contains_point(point); } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::contains -// Access: Public -// Description: Returns the appropriate set of IntersectionFlags to -// indicate the amount of intersection with the -// indicated line segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate set of IntersectionFlags to indicate the amount of + * intersection with the indicated line segment. + */ INLINE_MATHUTIL int GeometricBoundingVolume:: contains(const LPoint3 &a, const LPoint3 &b) const { if (is_empty()) { diff --git a/panda/src/mathutil/geometricBoundingVolume.cxx b/panda/src/mathutil/geometricBoundingVolume.cxx index 829c705d85..485b43d9f3 100644 --- a/panda/src/mathutil/geometricBoundingVolume.cxx +++ b/panda/src/mathutil/geometricBoundingVolume.cxx @@ -1,86 +1,69 @@ -// Filename: geometricBoundingVolume.cxx -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geometricBoundingVolume.cxx + * @author drose + * @date 1999-10-07 + */ #include "geometricBoundingVolume.h" TypeHandle GeometricBoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::as_geometric_bounding_volume -// Access: Public, Virtual, Final -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ GeometricBoundingVolume *GeometricBoundingVolume:: as_geometric_bounding_volume() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::as_geometric_bounding_volume -// Access: Public, Virtual, Final -// Description: Virtual downcast method. Returns this object as a -// pointer of the indicated type, if it is in fact that -// type. Returns NULL if it is not that type. -//////////////////////////////////////////////////////////////////// +/** + * Virtual downcast method. Returns this object as a pointer of the indicated + * type, if it is in fact that type. Returns NULL if it is not that type. + */ const GeometricBoundingVolume *GeometricBoundingVolume:: as_geometric_bounding_volume() const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::extend_by_point -// Access: Protected, Virtual -// Description: Extends the volume to include the indicated point. -// Returns true if possible, false if not. -//////////////////////////////////////////////////////////////////// +/** + * Extends the volume to include the indicated point. Returns true if + * possible, false if not. + */ bool GeometricBoundingVolume:: extend_by_point(const LPoint3 &) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::around_points -// Access: Protected, Virtual -// Description: Puts the volume around the indicated list of points, -// identified by an STL-style begin/end list. -//////////////////////////////////////////////////////////////////// +/** + * Puts the volume around the indicated list of points, identified by an STL- + * style begin/end list. + */ bool GeometricBoundingVolume:: around_points(const LPoint3 *, const LPoint3 *) { _flags = F_empty; return false; } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::contains_point -// Access: Protected, Virtual -// Description: Tests whether the volume contains the indicated -// point. -//////////////////////////////////////////////////////////////////// +/** + * Tests whether the volume contains the indicated point. + */ int GeometricBoundingVolume:: contains_point(const LPoint3 &) const { return IF_dont_understand; } -//////////////////////////////////////////////////////////////////// -// Function: GeometricBoundingVolume::contains_lineseg -// Access: Protected, Virtual -// Description: Tests whether the volume contains the indicated line -// segment. -//////////////////////////////////////////////////////////////////// +/** + * Tests whether the volume contains the indicated line segment. + */ int GeometricBoundingVolume:: contains_lineseg(const LPoint3 &, const LPoint3 &) const { return IF_dont_understand; diff --git a/panda/src/mathutil/geometricBoundingVolume.h b/panda/src/mathutil/geometricBoundingVolume.h index a1e191285c..90c794d832 100644 --- a/panda/src/mathutil/geometricBoundingVolume.h +++ b/panda/src/mathutil/geometricBoundingVolume.h @@ -1,16 +1,15 @@ -// Filename: geometricBoundingVolume.h -// Created by: drose (07Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geometricBoundingVolume.h + * @author drose + * @date 1999-10-07 + */ #ifndef GEOMETRICBOUNDINGVOLUME_H #define GEOMETRICBOUNDINGVOLUME_H @@ -22,12 +21,11 @@ #include "luse.h" #include "lmatrix.h" -//////////////////////////////////////////////////////////////////// -// Class : GeometricBoundingVolume -// Description : This is another abstract class, for a general class -// of bounding volumes that actually enclose points in -// 3-d space, such as BSP's and bounding spheres. -//////////////////////////////////////////////////////////////////// +/** + * This is another abstract class, for a general class of bounding volumes + * that actually enclose points in 3-d space, such as BSP's and bounding + * spheres. + */ class EXPCL_PANDA_MATHUTIL GeometricBoundingVolume : public BoundingVolume { public: INLINE_MATHUTIL GeometricBoundingVolume(); @@ -37,9 +35,9 @@ PUBLISHED: INLINE_MATHUTIL bool extend_by(const LPoint3 &point); public: - // It might be nice to make these template member functions so we - // could have true STL-style first/last iterators, but that's - // impossible for virtual functions. + // It might be nice to make these template member functions so we could have + // true STL-style firstlast iterators, but that's impossible for virtual + // functions. INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first, const GeometricBoundingVolume **last); INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last); @@ -57,8 +55,8 @@ public: virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const FINAL; protected: - // Some virtual functions to implement fundamental bounding - // operations on points in 3-d space. + // Some virtual functions to implement fundamental bounding operations on + // points in 3-d space. virtual bool extend_by_point(const LPoint3 &point); virtual bool around_points(const LPoint3 *first, diff --git a/panda/src/mathutil/intersectionBoundingVolume.I b/panda/src/mathutil/intersectionBoundingVolume.I index a7c2c138da..514c692333 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.I +++ b/panda/src/mathutil/intersectionBoundingVolume.I @@ -1,44 +1,35 @@ -// Filename: intersectionBoundingVolume.I -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file intersectionBoundingVolume.I + * @author drose + * @date 2012-02-08 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::Constructor -// Access: Published -// Description: Constructs an empty intersection. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty intersection. + */ INLINE_MATHUTIL IntersectionBoundingVolume:: IntersectionBoundingVolume() { _flags = F_infinite; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::get_num_components -// Access: Published -// Description: Returns the number of components in the intersection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components in the intersection. + */ INLINE_MATHUTIL int IntersectionBoundingVolume:: get_num_components() const { return (int)_components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::get_component -// Access: Published -// Description: Returns the nth component in the intersection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth component in the intersection. + */ INLINE_MATHUTIL const GeometricBoundingVolume *IntersectionBoundingVolume:: get_component(int n) const { nassertr(n >= 0 && n < (int)_components.size(), NULL); diff --git a/panda/src/mathutil/intersectionBoundingVolume.cxx b/panda/src/mathutil/intersectionBoundingVolume.cxx index c1a5e2dc35..a8af2d2b97 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.cxx +++ b/panda/src/mathutil/intersectionBoundingVolume.cxx @@ -1,16 +1,15 @@ -// Filename: intersectionBoundingVolume.cxx -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file intersectionBoundingVolume.cxx + * @author drose + * @date 2012-02-08 + */ #include "intersectionBoundingVolume.h" #include "unionBoundingVolume.h" @@ -19,11 +18,9 @@ TypeHandle IntersectionBoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IntersectionBoundingVolume:: IntersectionBoundingVolume(const IntersectionBoundingVolume ©) : GeometricBoundingVolume(copy), @@ -31,21 +28,17 @@ IntersectionBoundingVolume(const IntersectionBoundingVolume ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *IntersectionBoundingVolume:: make_copy() const { return new IntersectionBoundingVolume(*this); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 IntersectionBoundingVolume:: get_approx_center() const { nassertr(!is_empty(), LPoint3::zero()); @@ -61,11 +54,9 @@ get_approx_center() const { return center / (PN_stdfloat)_components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IntersectionBoundingVolume:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -79,11 +70,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IntersectionBoundingVolume:: output(ostream &out) const { if (is_empty()) { @@ -101,11 +90,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IntersectionBoundingVolume:: write(ostream &out, int indent_level) const { if (is_empty()) { @@ -123,37 +110,31 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::clear_components -// Access: Published -// Description: Removes all components from the volume. -//////////////////////////////////////////////////////////////////// +/** + * Removes all components from the volume. + */ void IntersectionBoundingVolume:: clear_components() { _components.clear(); _flags = F_infinite; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::add_component -// Access: Published -// Description: Adds a new component to the volume. This does not -// necessarily increase the total number of components -// by one, and you may or may not be able to find this -// component in the volume by a subsequent call to -// get_component(); certain optimizations may prevent -// the component from being added, or have other -// unexpected effects on the total set of components. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new component to the volume. This does not necessarily increase the + * total number of components by one, and you may or may not be able to find + * this component in the volume by a subsequent call to get_component(); + * certain optimizations may prevent the component from being added, or have + * other unexpected effects on the total set of components. + */ void IntersectionBoundingVolume:: add_component(const GeometricBoundingVolume *component) { CPT(GeometricBoundingVolume) gbv; if (component->is_exact_type(UnionBoundingVolume::get_class_type())) { - // Here's a special case. We'll construct a new union that - // includes only those components that have some intersection with - // our existing components. (No need to include the components - // that have no intersection.) + // Here's a special case. We'll construct a new union that includes only + // those components that have some intersection with our existing + // components. (No need to include the components that have no + // intersection.) PT(UnionBoundingVolume) unionv = DCAST(UnionBoundingVolume, component->make_copy()); unionv->filter_intersection(this); @@ -183,7 +164,7 @@ add_component(const GeometricBoundingVolume *component) { ++ci) { add_component(*ci); } - + } else { // The general case. size_t i = 0; @@ -193,8 +174,8 @@ add_component(const GeometricBoundingVolume *component) { int result = component->contains(existing); if ((result & IF_all) != 0) { - // The existing component is entirely within this one; no need - // to do anything with it. + // The existing component is entirely within this one; no need to do + // anything with it. return; } else if (result == 0) { @@ -206,8 +187,8 @@ add_component(const GeometricBoundingVolume *component) { result = existing->contains(component); if ((result & IF_all) != 0) { - // This new component is entirely within an existing - // component; no need to keep the existing one. + // This new component is entirely within an existing component; no + // need to keep the existing one. --i; _components.erase(_components.begin() + i); @@ -224,21 +205,17 @@ add_component(const GeometricBoundingVolume *component) { } } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool IntersectionBoundingVolume:: extend_other(BoundingVolume *other) const { return other->extend_by_intersection(this); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool IntersectionBoundingVolume:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -246,21 +223,17 @@ around_other(BoundingVolume *other, return other->around_intersections(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int IntersectionBoundingVolume:: contains_other(const BoundingVolume *other) const { return other->contains_intersection(this); } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int IntersectionBoundingVolume:: contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); @@ -284,11 +257,9 @@ contains_point(const LPoint3 &point) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_lineseg -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int IntersectionBoundingVolume:: contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); @@ -312,13 +283,10 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_sphere -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a sphere. + */ int IntersectionBoundingVolume:: contains_sphere(const BoundingSphere *sphere) const { int result = IF_possible | IF_some | IF_all; @@ -340,13 +308,10 @@ contains_sphere(const BoundingSphere *sphere) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a box. + */ int IntersectionBoundingVolume:: contains_box(const BoundingBox *box) const { int result = IF_possible | IF_some | IF_all; @@ -368,13 +333,10 @@ contains_box(const BoundingBox *box) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int IntersectionBoundingVolume:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { int result = IF_possible | IF_some | IF_all; @@ -396,13 +358,10 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a line. + */ int IntersectionBoundingVolume:: contains_line(const BoundingLine *line) const { int result = IF_possible | IF_some | IF_all; @@ -424,13 +383,10 @@ contains_line(const BoundingLine *line) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a plane. + */ int IntersectionBoundingVolume:: contains_plane(const BoundingPlane *plane) const { int result = IF_possible | IF_some | IF_all; @@ -452,13 +408,10 @@ contains_plane(const BoundingPlane *plane) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_union -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a union object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a union object. + */ int IntersectionBoundingVolume:: contains_union(const UnionBoundingVolume *unionv) const { int result = IF_possible | IF_some | IF_all; @@ -480,13 +433,10 @@ contains_union(const UnionBoundingVolume *unionv) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_intersection -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be an intersection object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be an intersection object. + */ int IntersectionBoundingVolume:: contains_intersection(const IntersectionBoundingVolume *intersection) const { int result = IF_possible | IF_some | IF_all; @@ -508,11 +458,9 @@ contains_intersection(const IntersectionBoundingVolume *intersection) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_finite -// Access: Protected, Virtual -// Description: Generic handler for a FiniteBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a FiniteBoundingVolume. + */ int IntersectionBoundingVolume:: contains_finite(const FiniteBoundingVolume *volume) const { int result = IF_possible | IF_some | IF_all; @@ -534,11 +482,9 @@ contains_finite(const FiniteBoundingVolume *volume) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::contains_geometric -// Access: Protected, Virtual -// Description: Generic handler for a GeometricBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a GeometricBoundingVolume. + */ int IntersectionBoundingVolume:: contains_geometric(const GeometricBoundingVolume *volume) const { int result = IF_possible | IF_some | IF_all; @@ -561,14 +507,11 @@ contains_geometric(const GeometricBoundingVolume *volume) const { } -//////////////////////////////////////////////////////////////////// -// Function: IntersectionBoundingVolume::other_contains_intersection -// Access: Protected, Virtual -// Description: Generic reverse-direction comparison. Called by -// BoundingVolumes that do not implement -// contains_intersection() explicitly. This returns the test -// of whether the other volume contains this volume. -//////////////////////////////////////////////////////////////////// +/** + * Generic reverse-direction comparison. Called by BoundingVolumes that do + * not implement contains_intersection() explicitly. This returns the test of + * whether the other volume contains this volume. + */ int IntersectionBoundingVolume:: other_contains_intersection(const BoundingVolume *volume) const { int result = IF_possible | IF_some | IF_all; @@ -589,4 +532,3 @@ other_contains_intersection(const BoundingVolume *volume) const { return result; } - diff --git a/panda/src/mathutil/intersectionBoundingVolume.h b/panda/src/mathutil/intersectionBoundingVolume.h index 3d43494d33..38759e0d29 100644 --- a/panda/src/mathutil/intersectionBoundingVolume.h +++ b/panda/src/mathutil/intersectionBoundingVolume.h @@ -1,16 +1,15 @@ -// Filename: intersectionBoundingVolume.h -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file intersectionBoundingVolume.h + * @author drose + * @date 2012-02-08 + */ #ifndef INTERSECTIONBOUNDINGVOLUME_H #define INTERSECTIONBOUNDINGVOLUME_H @@ -20,15 +19,13 @@ #include "geometricBoundingVolume.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : IntersectionBoundingVolume -// Description : This special bounding volume is the intersection of all of -// its constituent bounding volumes. -// -// A point is defined to be within an -// IntersectionBoundingVolume if it is within all of its -// component bounding volumes. -//////////////////////////////////////////////////////////////////// +/** + * This special bounding volume is the intersection of all of its constituent + * bounding volumes. + * + * A point is defined to be within an IntersectionBoundingVolume if it is + * within all of its component bounding volumes. + */ class EXPCL_PANDA_MATHUTIL IntersectionBoundingVolume : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL IntersectionBoundingVolume(); @@ -101,4 +98,3 @@ private: #include "intersectionBoundingVolume.I" #endif - diff --git a/panda/src/mathutil/linmath_events.cxx b/panda/src/mathutil/linmath_events.cxx index bb16544191..a116cc696a 100644 --- a/panda/src/mathutil/linmath_events.cxx +++ b/panda/src/mathutil/linmath_events.cxx @@ -1,16 +1,15 @@ -// Filename: linmath_events.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linmath_events.cxx + * @author drose + * @date 2002-03-12 + */ #include "linmath_events.h" diff --git a/panda/src/mathutil/linmath_events.h b/panda/src/mathutil/linmath_events.h index fbb38dfa46..d5d3cea907 100644 --- a/panda/src/mathutil/linmath_events.h +++ b/panda/src/mathutil/linmath_events.h @@ -1,16 +1,15 @@ -// Filename: linmath_events.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linmath_events.h + * @author drose + * @date 2002-03-12 + */ #ifndef LINMATH_EVENTS_H #define LINMATH_EVENTS_H @@ -20,15 +19,9 @@ #include "paramValue.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// -// This file defines a few more EventStore classes for storing linmath -// objects in an EventParameter. These are just for backward -// compatibility; they are defined as typedefs to ParamVecBase types. -// -// See paramValue.h. -// -//////////////////////////////////////////////////////////////////// +// This file defines a few more EventStore classes for storing linmath objects +// in an EventParameter. These are just for backward compatibility; they are +// defined as typedefs to ParamVecBase types. See paramValue.h. typedef ParamVecBase2 EventStoreVec2; typedef ParamVecBase3 EventStoreVec3; diff --git a/panda/src/mathutil/look_at.cxx b/panda/src/mathutil/look_at.cxx index 650a1f72a6..0777727cfc 100644 --- a/panda/src/mathutil/look_at.cxx +++ b/panda/src/mathutil/look_at.cxx @@ -1,16 +1,15 @@ -// Filename: look_at.cxx -// Created by: drose (25Apr97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file look_at.cxx + * @author drose + * @date 1997-04-25 + */ #include "look_at.h" diff --git a/panda/src/mathutil/look_at.h b/panda/src/mathutil/look_at.h index 96cb3db6ea..6d38a33864 100644 --- a/panda/src/mathutil/look_at.h +++ b/panda/src/mathutil/look_at.h @@ -1,23 +1,20 @@ -// Filename: look_at.h -// Created by: drose (25Apr97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file look_at.h + * @author drose + * @date 1997-04-25 + */ #ifndef LOOKAT_H #define LOOKAT_H -//////////////////////////////////////////////////////////////////// // Includes -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include "cmath.h" #include "coordinateSystem.h" diff --git a/panda/src/mathutil/look_at_src.I b/panda/src/mathutil/look_at_src.I index 2d2179772d..d2a7d4af43 100644 --- a/panda/src/mathutil/look_at_src.I +++ b/panda/src/mathutil/look_at_src.I @@ -1,16 +1,15 @@ -// Filename: look_at_src.I -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file look_at_src.I + * @author drose + * @date 1999-09-25 + */ INLINE_MATHUTIL void heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, @@ -79,4 +78,3 @@ look_at(FLOATNAME(LQuaternion) &quat, const FLOATNAME(LVector3) &fwd, CoordinateSystem cs) { look_at(quat, fwd, FLOATNAME(LVector3)::up(cs), cs); } - diff --git a/panda/src/mathutil/look_at_src.cxx b/panda/src/mathutil/look_at_src.cxx index 5f32a3eee8..28bef739ea 100644 --- a/panda/src/mathutil/look_at_src.cxx +++ b/panda/src/mathutil/look_at_src.cxx @@ -1,16 +1,15 @@ -// Filename: look_at_src.cxx -// Created by: drose (25Apr97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file look_at_src.cxx + * @author drose + * @date 1997-04-25 + */ INLINE_MATHUTIL FLOATNAME(LMatrix3) make_xi_mat(const FLOATNAME(LVector2) &x) { @@ -43,17 +42,14 @@ make_z_mat(const FLOATNAME(LVector2) &z) { 0, 0, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: heads_up -// Description: Given two vectors defining a forward direction and an -// up vector, constructs the matrix that rotates things -// from the defined coordinate system to y-forward and -// z-up. The up vector will be rotated to z-up first, -// then the forward vector will be rotated as nearly to -// y-forward as possible. This will only have a -// different effect from look_at() if the forward and up -// vectors are not perpendicular. -//////////////////////////////////////////////////////////////////// +/** + * Given two vectors defining a forward direction and an up vector, constructs + * the matrix that rotates things from the defined coordinate system to + * y-forward and z-up. The up vector will be rotated to z-up first, then the + * forward vector will be rotated as nearly to y-forward as possible. This + * will only have a different effect from look_at() if the forward and up + * vectors are not perpendicular. + */ void heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, const FLOATNAME(LVector3) &up, CoordinateSystem cs) { @@ -64,9 +60,9 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, if (cs == CS_zup_right || cs == CS_zup_left) { // Z-up. - // y is the projection of the up vector into the XZ plane. Its - // angle to the Z axis is the amount to rotate about the Y axis to - // bring the up vector into the YZ plane. + // y is the projection of the up vector into the XZ plane. Its angle to + // the Z axis is the amount to rotate about the Y axis to bring the up + // vector into the YZ plane. FLOATNAME(LVector2) y(up[0], up[2]); FLOATTYPE d = dot(y, y); @@ -76,9 +72,9 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, y /= csqrt(d); } - // x is the up vector rotated into the YZ plane. Its angle to the Z - // axis is the amount to rotate about the X axis to bring the up - // vector to the Z axis. + // x is the up vector rotated into the YZ plane. Its angle to the Z axis + // is the amount to rotate about the X axis to bring the up vector to the + // Z axis. FLOATNAME(LVector2) x(-up[1], up[0]*y[0]+up[2]*y[1]); d = dot(x, x); @@ -88,15 +84,14 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, x /= csqrt(d); } - // Now apply both rotations to the forward vector. This will rotate - // the forward vector by the same amount we would have had to rotate - // the up vector to bring it to the Z axis. If the vectors were - // perpendicular, this will put the forward vector somewhere in the - // XY plane. + // Now apply both rotations to the forward vector. This will rotate the + // forward vector by the same amount we would have had to rotate the up + // vector to bring it to the Z axis. If the vectors were perpendicular, + // this will put the forward vector somewhere in the XY plane. - // z is the projection of the newly rotated fwd vector into the XY - // plane. Its angle to the Y axis is the amount to rotate about the - // Z axis in order to bring the fwd vector to the Y axis. + // z is the projection of the newly rotated fwd vector into the XY plane. + // Its angle to the Y axis is the amount to rotate about the Z axis in + // order to bring the fwd vector to the Y axis. FLOATNAME(LVector2) z(fwd[0]*y[1] - fwd[2]*y[0], -fwd[0]*y[0]*x[0] + fwd[1]*x[1] - fwd[2]*y[1]*x[0]); d = dot(z, z); @@ -121,9 +116,9 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, } else { // Y-up. - // z is the projection of the forward vector into the XY plane. Its - // angle to the Y axis is the amount to rotate about the Z axis to - // bring the forward vector into the YZ plane. + // z is the projection of the forward vector into the XY plane. Its angle + // to the Y axis is the amount to rotate about the Z axis to bring the + // forward vector into the YZ plane. FLOATNAME(LVector2) z(up[0], up[1]); FLOATTYPE d = dot(z, z); @@ -133,9 +128,9 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, z /= csqrt(d); } - // x is the forward vector rotated into the YZ plane. Its angle to - // the Y axis is the amount to rotate about the X axis to bring the - // forward vector to the Y axis. + // x is the forward vector rotated into the YZ plane. Its angle to the Y + // axis is the amount to rotate about the X axis to bring the forward + // vector to the Y axis. FLOATNAME(LVector2) x(up[0]*z[0] + up[1]*z[1], up[2]); d = dot(x, x); @@ -145,15 +140,14 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, x /= csqrt(d); } - // Now apply both rotations to the up vector. This will rotate - // the up vector by the same amount we would have had to rotate - // the forward vector to bring it to the Y axis. If the vectors were - // perpendicular, this will put the up vector somewhere in the - // XZ plane. + // Now apply both rotations to the up vector. This will rotate the up + // vector by the same amount we would have had to rotate the forward + // vector to bring it to the Y axis. If the vectors were perpendicular, + // this will put the up vector somewhere in the XZ plane. - // y is the projection of the newly rotated up vector into the XZ - // plane. Its angle to the Z axis is the amount to rotate about the - // Y axis in order to bring the up vector to the Z axis. + // y is the projection of the newly rotated up vector into the XZ plane. + // Its angle to the Z axis is the amount to rotate about the Y axis in + // order to bring the up vector to the Z axis. FLOATNAME(LVector2) y(fwd[0]*z[1] - fwd[1]*z[0], -fwd[0]*x[1]*z[0] - fwd[1]*x[1]*z[1] + fwd[2]*x[0]); d = dot(y, y); @@ -179,17 +173,14 @@ heads_up(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, } -//////////////////////////////////////////////////////////////////// -// Function: look_at -// Description: Given two vectors defining a forward direction and an -// up vector, constructs the matrix that rotates things -// from the defined coordinate system to y-forward and -// z-up. The forward vector will be rotated to -// y-forward first, then the up vector will be rotated -// as nearly to z-up as possible. This will only have a -// different effect from heads_up() if the forward and -// up vectors are not perpendicular. -//////////////////////////////////////////////////////////////////// +/** + * Given two vectors defining a forward direction and an up vector, constructs + * the matrix that rotates things from the defined coordinate system to + * y-forward and z-up. The forward vector will be rotated to y-forward first, + * then the up vector will be rotated as nearly to z-up as possible. This + * will only have a different effect from heads_up() if the forward and up + * vectors are not perpendicular. + */ void look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, const FLOATNAME(LVector3) &up, CoordinateSystem cs) { @@ -200,9 +191,9 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, if (cs == CS_zup_right || cs == CS_zup_left) { // Z-up. - // z is the projection of the forward vector into the XY plane. Its - // angle to the Y axis is the amount to rotate about the Z axis to - // bring the forward vector into the YZ plane. + // z is the projection of the forward vector into the XY plane. Its angle + // to the Y axis is the amount to rotate about the Z axis to bring the + // forward vector into the YZ plane. FLOATNAME(LVector2) z(fwd[0], fwd[1]); FLOATTYPE d = dot(z, z); @@ -212,9 +203,9 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, z /= csqrt(d); } - // x is the forward vector rotated into the YZ plane. Its angle to - // the Y axis is the amount to rotate about the X axis to bring the - // forward vector to the Y axis. + // x is the forward vector rotated into the YZ plane. Its angle to the Y + // axis is the amount to rotate about the X axis to bring the forward + // vector to the Y axis. FLOATNAME(LVector2) x(fwd[0]*z[0] + fwd[1]*z[1], fwd[2]); d = dot(x, x); @@ -224,15 +215,14 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, x /= csqrt(d); } - // Now apply both rotations to the up vector. This will rotate - // the up vector by the same amount we would have had to rotate - // the forward vector to bring it to the Y axis. If the vectors were - // perpendicular, this will put the up vector somewhere in the - // XZ plane. + // Now apply both rotations to the up vector. This will rotate the up + // vector by the same amount we would have had to rotate the forward + // vector to bring it to the Y axis. If the vectors were perpendicular, + // this will put the up vector somewhere in the XZ plane. - // y is the projection of the newly rotated up vector into the XZ - // plane. Its angle to the Z axis is the amount to rotate about the - // Y axis in order to bring the up vector to the Z axis. + // y is the projection of the newly rotated up vector into the XZ plane. + // Its angle to the Z axis is the amount to rotate about the Y axis in + // order to bring the up vector to the Z axis. FLOATNAME(LVector2) y(up[0]*z[1] - up[1]*z[0], -up[0]*x[1]*z[0] - up[1]*x[1]*z[1] + up[2]*x[0]); d = dot(y, y); @@ -257,9 +247,9 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, } else { // Y-up. - // y is the projection of the up vector into the XZ plane. Its - // angle to the Z axis is the amount to rotate about the Y axis to - // bring the up vector into the YZ plane. + // y is the projection of the up vector into the XZ plane. Its angle to + // the Z axis is the amount to rotate about the Y axis to bring the up + // vector into the YZ plane. FLOATNAME(LVector2) y(fwd[0], fwd[2]); FLOATTYPE d = dot(y, y); @@ -269,9 +259,9 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, y /= csqrt(d); } - // x is the up vector rotated into the YZ plane. Its angle to the Z - // axis is the amount to rotate about the X axis to bring the up - // vector to the Z axis. + // x is the up vector rotated into the YZ plane. Its angle to the Z axis + // is the amount to rotate about the X axis to bring the up vector to the + // Z axis. FLOATNAME(LVector2) x(fwd[1], fwd[0]*y[0]+fwd[2]*y[1]); d = dot(x, x); @@ -281,15 +271,14 @@ look_at(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &fwd, x /= csqrt(d); } - // Now apply both rotations to the forward vector. This will rotate - // the forward vector by the same amount we would have had to rotate - // the up vector to bring it to the Z axis. If the vectors were - // perpendicular, this will put the forward vector somewhere in the - // XY plane. + // Now apply both rotations to the forward vector. This will rotate the + // forward vector by the same amount we would have had to rotate the up + // vector to bring it to the Z axis. If the vectors were perpendicular, + // this will put the forward vector somewhere in the XY plane. - // z is the projection of the newly rotated fwd vector into the XY - // plane. Its angle to the Y axis is the amount to rotate about the - // Z axis in order to bring the fwd vector to the Y axis. + // z is the projection of the newly rotated fwd vector into the XY plane. + // Its angle to the Y axis is the amount to rotate about the Z axis in + // order to bring the fwd vector to the Y axis. FLOATNAME(LVector2) z(up[0]*y[1] - up[2]*y[0], -up[0]*y[0]*x[0] + up[1]*x[1] - up[2]*y[1]*x[0]); d = dot(z, z); diff --git a/panda/src/mathutil/look_at_src.h b/panda/src/mathutil/look_at_src.h index f71d6531fc..34b1d7aa96 100644 --- a/panda/src/mathutil/look_at_src.h +++ b/panda/src/mathutil/look_at_src.h @@ -1,29 +1,27 @@ -// Filename: look_at_src.h -// Created by: drose (25Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file look_at_src.h + * @author drose + * @date 1999-09-25 + */ -// These functions return a matrix that rotates between a coordinate -// system defined with the given forward and up vectors, and the -// standard coordinate system with y-forward and z-up. They differ -// only in their behavior when the supplied forward and up vectors are -// not perpendicular; in this case, look_at will match the forward -// vector precisely, while heads_up will match the up vector -// precisely. +// These functions return a matrix that rotates between a coordinate system +// defined with the given forward and up vectors, and the standard coordinate +// system with y-forward and z-up. They differ only in their behavior when +// the supplied forward and up vectors are not perpendicular; in this case, +// look_at will match the forward vector precisely, while heads_up will match +// the up vector precisely. -// Since these functions only return a rotation matrix, the -// translation component is always zero. There are flavors of these -// functions that simply return the upper 3x3 part of the matrix, and -// flavors that return the whole 4x4 matrix with a zero bottom row. +// Since these functions only return a rotation matrix, the translation +// component is always zero. There are flavors of these functions that simply +// return the upper 3x3 part of the matrix, and flavors that return the whole +// 4x4 matrix with a zero bottom row. BEGIN_PUBLISH diff --git a/panda/src/mathutil/mersenne.h b/panda/src/mathutil/mersenne.h index 1307a7b394..6422c827d7 100644 --- a/panda/src/mathutil/mersenne.h +++ b/panda/src/mathutil/mersenne.h @@ -1,29 +1,28 @@ -// Filename: mersenne.h -// Created by: darren (18Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mersenne.h + * @author darren + * @date 2002-07-18 + */ #ifndef MERSENNE_H #define MERSENNE_H -/* +/* A C-program for MT19937, with initialization improved 2002/1/26. Coded by Takuji Nishimura and Makoto Matsumoto. - Before using, initialize the state by using init_genrand(seed) + Before using, initialize the state by using init_genrand(seed) or init_by_array(init_key, key_length). Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, - All rights reserved. + All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -36,8 +35,8 @@ notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. The names of its contributors may not be used to endorse or promote - products derived from this software without specific prior written + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS @@ -65,7 +64,7 @@ PUBLISHED: Mersenne(unsigned long seed); unsigned long get_uint31(); - enum { + enum { max_value = 0x7fffffff }; diff --git a/panda/src/mathutil/omniBoundingVolume.I b/panda/src/mathutil/omniBoundingVolume.I index 3b057f926c..41c5e66791 100644 --- a/panda/src/mathutil/omniBoundingVolume.I +++ b/panda/src/mathutil/omniBoundingVolume.I @@ -1,22 +1,19 @@ -// Filename: omniBoundingVolume.I -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file omniBoundingVolume.I + * @author drose + * @date 2000-06-22 + */ -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL OmniBoundingVolume:: OmniBoundingVolume() { _flags = F_infinite; diff --git a/panda/src/mathutil/omniBoundingVolume.cxx b/panda/src/mathutil/omniBoundingVolume.cxx index 9a406909e8..65e556b767 100644 --- a/panda/src/mathutil/omniBoundingVolume.cxx +++ b/panda/src/mathutil/omniBoundingVolume.cxx @@ -1,16 +1,15 @@ -// Filename: omniBoundingVolume.cxx -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file omniBoundingVolume.cxx + * @author drose + * @date 2000-06-22 + */ #include "omniBoundingVolume.h" #include "boundingHexahedron.h" @@ -20,61 +19,49 @@ TypeHandle OmniBoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *OmniBoundingVolume:: make_copy() const { return new OmniBoundingVolume(*this); } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 OmniBoundingVolume:: get_approx_center() const { return LPoint3(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OmniBoundingVolume:: xform(const LMatrix4 &) { } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OmniBoundingVolume:: output(ostream &out) const { out << "omni"; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::extend_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: extend_other(BoundingVolume *other) const { other->set_infinite(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::around_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: around_other(BoundingVolume *other, const BoundingVolume **, @@ -83,144 +70,116 @@ around_other(BoundingVolume *other, return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_other -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_other(const BoundingVolume *) const { return IF_possible | IF_some | IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::extend_by_point -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: extend_by_point(const LPoint3 &) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::extend_by_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: extend_by_sphere(const BoundingSphere *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::extend_by_box -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: extend_by_box(const BoundingBox *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::extend_by_hexahedron -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: extend_by_hexahedron(const BoundingHexahedron *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::around_points -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: around_points(const LPoint3 *, const LPoint3 *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::around_spheres -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: around_spheres(const BoundingVolume **, const BoundingVolume **) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::around_boxes -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: around_boxes(const BoundingVolume **, const BoundingVolume **) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::around_hexahedrons -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool OmniBoundingVolume:: around_hexahedrons(const BoundingVolume **, const BoundingVolume **) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_point -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_point(const LPoint3 &) const { return IF_possible | IF_some | IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_lineseg -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_lineseg(const LPoint3 &, const LPoint3 &) const { return IF_possible | IF_some | IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_sphere -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_sphere(const BoundingSphere *) const { return IF_possible | IF_some | IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_box -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_box(const BoundingBox *) const { return IF_possible | IF_some | IF_all; } -//////////////////////////////////////////////////////////////////// -// Function: OmniBoundingVolume::contains_hexahedron -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int OmniBoundingVolume:: contains_hexahedron(const BoundingHexahedron *) const { return IF_possible | IF_some | IF_all; diff --git a/panda/src/mathutil/omniBoundingVolume.h b/panda/src/mathutil/omniBoundingVolume.h index e6d1e69e06..b124de5767 100644 --- a/panda/src/mathutil/omniBoundingVolume.h +++ b/panda/src/mathutil/omniBoundingVolume.h @@ -1,16 +1,15 @@ -// Filename: omniBoundingVolume.h -// Created by: drose (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file omniBoundingVolume.h + * @author drose + * @date 2000-06-22 + */ #ifndef OMNIBOUNDINGVOLUME_H #define OMNIBOUNDINGVOLUME_H @@ -19,11 +18,9 @@ #include "geometricBoundingVolume.h" -//////////////////////////////////////////////////////////////////// -// Class : OmniBoundingVolume -// Description : This is a special kind of GeometricBoundingVolume -// that fills all of space. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of GeometricBoundingVolume that fills all of space. + */ class EXPCL_PANDA_MATHUTIL OmniBoundingVolume : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL OmniBoundingVolume(); diff --git a/panda/src/mathutil/parabola.cxx b/panda/src/mathutil/parabola.cxx index 66e828aac4..f657bc9ca2 100644 --- a/panda/src/mathutil/parabola.cxx +++ b/panda/src/mathutil/parabola.cxx @@ -1,16 +1,15 @@ -// Filename: parabola.cxx -// Created by: drose (10Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parabola.cxx + * @author drose + * @date 2007-10-10 + */ #include "parabola.h" diff --git a/panda/src/mathutil/parabola.h b/panda/src/mathutil/parabola.h index 60b8d379a7..080a188b89 100644 --- a/panda/src/mathutil/parabola.h +++ b/panda/src/mathutil/parabola.h @@ -1,16 +1,15 @@ -// Filename: parabola.h -// Created by: drose (10Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parabola.h + * @author drose + * @date 2007-10-10 + */ #ifndef PARABOLA_H #define PARABOLA_H diff --git a/panda/src/mathutil/parabola_src.I b/panda/src/mathutil/parabola_src.I index 7d2902f579..b1bc8fe70b 100644 --- a/panda/src/mathutil/parabola_src.I +++ b/panda/src/mathutil/parabola_src.I @@ -1,38 +1,31 @@ -// Filename: parabola_src.I -// Created by: drose (10Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parabola_src.I + * @author drose + * @date 2007-10-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LParabola::Default Constructor -// Access: Published -// Description: Constructs a meaningless degenerate parabola. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a meaningless degenerate parabola. + */ INLINE_MATHUTIL FLOATNAME(LParabola):: FLOATNAME(LParabola)() : - _a(FLOATNAME(LVecBase3)::zero()), - _b(FLOATNAME(LVecBase3)::zero()), + _a(FLOATNAME(LVecBase3)::zero()), + _b(FLOATNAME(LVecBase3)::zero()), _c(FLOATNAME(LVecBase3)::zero()) { } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::Constructor -// Access: Published -// Description: Constructs a parabola given the three points of the -// parametric equation: the acceleration, initial -// velocity, and start point. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a parabola given the three points of the parametric equation: + * the acceleration, initial velocity, and start point. + */ INLINE_MATHUTIL FLOATNAME(LParabola):: FLOATNAME(LParabola)(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b, @@ -41,11 +34,9 @@ FLOATNAME(LParabola)(const FLOATNAME(LVecBase3) &a, { } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL FLOATNAME(LParabola):: FLOATNAME(LParabola)(const FLOATNAME(LParabola) ©) : _a(copy._a), @@ -54,11 +45,9 @@ FLOATNAME(LParabola)(const FLOATNAME(LParabola) ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL void FLOATNAME(LParabola):: operator = (const FLOATNAME(LParabola) ©) { _a = copy._a; @@ -66,53 +55,43 @@ operator = (const FLOATNAME(LParabola) ©) { _c = copy._c; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL FLOATNAME(LParabola):: ~FLOATNAME(LParabola)() { } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::get_a -// Access: Published -// Description: Returns the first point of the parabola's parametric -// equation: the acceleration. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first point of the parabola's parametric equation: the + * acceleration. + */ INLINE_MATHUTIL const FLOATNAME(LVecBase3) &FLOATNAME(LParabola):: get_a() const { return _a; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::get_b -// Access: Published -// Description: Returns the second point of the parabola's parametric -// equation: the initial velocity. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second point of the parabola's parametric equation: the initial + * velocity. + */ INLINE_MATHUTIL const FLOATNAME(LVecBase3) &FLOATNAME(LParabola):: get_b() const { return _b; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::get_c -// Access: Published -// Description: Returns the third point of the parabola's parametric -// equation: the start point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the third point of the parabola's parametric equation: the start + * point. + */ INLINE_MATHUTIL const FLOATNAME(LVecBase3) &FLOATNAME(LParabola):: get_c() const { return _c; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::calc_point -// Access: Published -// Description: Computes the point on the parabola at time t. -//////////////////////////////////////////////////////////////////// +/** + * Computes the point on the parabola at time t. + */ INLINE_MATHUTIL FLOATNAME(LPoint3) FLOATNAME(LParabola):: calc_point(FLOATTYPE t) const { return _a * t * t + _b * t + _c; diff --git a/panda/src/mathutil/parabola_src.cxx b/panda/src/mathutil/parabola_src.cxx index 51546827ed..a695a89c31 100644 --- a/panda/src/mathutil/parabola_src.cxx +++ b/panda/src/mathutil/parabola_src.cxx @@ -1,23 +1,19 @@ -// Filename: parabola_src.cxx -// Created by: drose (10Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parabola_src.cxx + * @author drose + * @date 2007-10-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LParabola::xform -// Access: Published -// Description: Transforms the parabola by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the parabola by the indicated matrix. + */ void FLOATNAME(LParabola):: xform(const FLOATNAME(LMatrix4) &mat) { // Note that xform_vec() is the correct operation here, while @@ -27,37 +23,29 @@ xform(const FLOATNAME(LMatrix4) &mat) { _c = mat.xform_point(_c); } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LParabola):: output(ostream &out) const { out << "LParabola(" << _a << ", " << _b << ", " << _c << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LParabola):: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::write_datagram_fixed -// Access: Public -// Description: Writes the parabola to the Datagram using add_float32() -// or add_float64(), depending on the type of floats in -// the parabola, regardless of the setting of -// Datagram::set_stdfloat_double(). This is appropriate -// when you want to write a fixed-width value to the -// datagram, especially when you are not writing a bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the parabola to the Datagram using add_float32() or add_float64(), + * depending on the type of floats in the parabola, regardless of the setting + * of Datagram::set_stdfloat_double(). This is appropriate when you want to + * write a fixed-width value to the datagram, especially when you are not + * writing a bam file. + */ void FLOATNAME(LParabola):: write_datagram_fixed(Datagram &destination) const { _a.write_datagram_fixed(destination); @@ -65,12 +53,10 @@ write_datagram_fixed(Datagram &destination) const { _c.write_datagram_fixed(destination); } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::read_datagram_fixed -// Access: Public -// Description: Reads the parabola from the Datagram using get_float32() -// or get_float64(). See write_datagram_fixed(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the parabola from the Datagram using get_float32() or get_float64(). + * See write_datagram_fixed(). + */ void FLOATNAME(LParabola):: read_datagram_fixed(DatagramIterator &source) { _a.read_datagram_fixed(source); @@ -78,14 +64,11 @@ read_datagram_fixed(DatagramIterator &source) { _c.read_datagram_fixed(source); } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::write_datagram -// Access: Public -// Description: Writes the parabola to the Datagram using -// add_stdfloat(). This is appropriate when you want to -// write the vector using the standard width setting, -// especially when you are writing a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the parabola to the Datagram using add_stdfloat(). This is + * appropriate when you want to write the vector using the standard width + * setting, especially when you are writing a bam file. + */ void FLOATNAME(LParabola):: write_datagram(Datagram &destination) const { _a.write_datagram(destination); @@ -93,11 +76,9 @@ write_datagram(Datagram &destination) const { _c.write_datagram(destination); } -//////////////////////////////////////////////////////////////////// -// Function: LParabola::read_datagram -// Access: Public -// Description: Reads the parabola from the Datagram using get_stdfloat(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the parabola from the Datagram using get_stdfloat(). + */ void FLOATNAME(LParabola):: read_datagram(DatagramIterator &source) { _a.read_datagram(source); diff --git a/panda/src/mathutil/parabola_src.h b/panda/src/mathutil/parabola_src.h index 27cd550dc9..742f0c5450 100644 --- a/panda/src/mathutil/parabola_src.h +++ b/panda/src/mathutil/parabola_src.h @@ -1,30 +1,26 @@ -// Filename: parabola_src.h -// Created by: drose (10Oct07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parabola_src.h + * @author drose + * @date 2007-10-10 + */ -//////////////////////////////////////////////////////////////////// -// Class : LParabola -// Description : An abstract mathematical description of a parabola, -// particularly useful for describing arcs of -// projectiles. -// -// The parabolic equation, given parametrically here, is -// P = At^2 + Bt + C. -//////////////////////////////////////////////////////////////////// +/** + * An abstract mathematical description of a parabola, particularly useful for + * describing arcs of projectiles. + * + * The parabolic equation, given parametrically here, is P = At^2 + Bt + C. + */ class EXPCL_PANDA_MATHUTIL FLOATNAME(LParabola) { PUBLISHED: INLINE_MATHUTIL FLOATNAME(LParabola)(); - INLINE_MATHUTIL FLOATNAME(LParabola)(const FLOATNAME(LVecBase3) &a, + INLINE_MATHUTIL FLOATNAME(LParabola)(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b, const FLOATNAME(LVecBase3) &c); INLINE_MATHUTIL FLOATNAME(LParabola)(const FLOATNAME(LParabola) ©); diff --git a/panda/src/mathutil/perlinNoise.I b/panda/src/mathutil/perlinNoise.I index a67b0a5717..51100b9ed3 100644 --- a/panda/src/mathutil/perlinNoise.I +++ b/panda/src/mathutil/perlinNoise.I @@ -1,47 +1,37 @@ -// Filename: perlinNoise.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::fade -// Access: Protected, Static -// Description: Returns a smooth interpolation spline from 0 .. 1 -// for t. -//////////////////////////////////////////////////////////////////// +/** + * Returns a smooth interpolation spline from 0 .. 1 for t. + */ INLINE double PerlinNoise:: -fade(double t) { - // return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); +fade(double t) { + // return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); return (3.0 - 2.0 * t) * t * t; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::lerp -// Access: Protected, Static -// Description: Returns the smoothly lerped value from a to b. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smoothly lerped value from a to b. + */ INLINE double PerlinNoise:: -lerp(double t, double a, double b) { - return a + t * (b - a); +lerp(double t, double a, double b) { + return a + t * (b - a); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::get_seed -// Access: Published -// Description: Returns a unique seed value based on the seed value -// passed to this PerlinNoise object (and on its current -// state). -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique seed value based on the seed value passed to this + * PerlinNoise object (and on its current state). + */ INLINE unsigned long PerlinNoise:: get_seed() { return _randomizer.get_seed(); diff --git a/panda/src/mathutil/perlinNoise.cxx b/panda/src/mathutil/perlinNoise.cxx index f2d5e17583..5b5f52b8b5 100644 --- a/panda/src/mathutil/perlinNoise.cxx +++ b/panda/src/mathutil/perlinNoise.cxx @@ -1,28 +1,24 @@ -// Filename: perlinNoise.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise.cxx + * @author drose + * @date 2005-10-05 + */ #include "perlinNoise.h" -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::Constructor -// Access: Protected -// Description: Randomizes the tables to make a unique noise -// function. -// -// If seed is nonzero, it is used to define the tables; -// if it is zero a random seed is generated. -//////////////////////////////////////////////////////////////////// +/** + * Randomizes the tables to make a unique noise function. + * + * If seed is nonzero, it is used to define the tables; if it is zero a random + * seed is generated. + */ PerlinNoise:: PerlinNoise(int table_size, unsigned long seed) : _table_size(table_size), @@ -40,8 +36,7 @@ PerlinNoise(int table_size, unsigned long seed) : } #endif // NDEBUG - // The _index table is just a randomly shuffled index - // table. + // The _index table is just a randomly shuffled index table. _index.reserve(_table_size * 2); int i; for (i = 0; i < _table_size; ++i) { @@ -55,19 +50,16 @@ PerlinNoise(int table_size, unsigned long seed) : _index[j] = t; } - // We double up _index so we don't need to perform modulo - // arithmetic. + // We double up _index so we don't need to perform modulo arithmetic. for (i = 0; i < _table_size; ++i) { _index.push_back(_index[i]); } } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::Copy Constructor -// Access: Protected -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ PerlinNoise:: PerlinNoise(const PerlinNoise ©) : _table_size(copy._table_size), @@ -77,12 +69,10 @@ PerlinNoise(const PerlinNoise ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise::Copy Assignment Operator -// Access: Protected -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ void PerlinNoise:: operator = (const PerlinNoise ©) { _table_size = copy._table_size; diff --git a/panda/src/mathutil/perlinNoise.h b/panda/src/mathutil/perlinNoise.h index 346273d3c4..a109c43d56 100644 --- a/panda/src/mathutil/perlinNoise.h +++ b/panda/src/mathutil/perlinNoise.h @@ -1,16 +1,15 @@ -// Filename: perlinNoise.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise.h + * @author drose + * @date 2005-10-05 + */ #ifndef PERLINNOISE_H #define PERLINNOISE_H @@ -21,13 +20,11 @@ #include "luse.h" #include "randomizer.h" -//////////////////////////////////////////////////////////////////// -// Class : PerlinNoise -// Description : This is the base class for PerlinNoise2 and -// PerlinNoise3, different dimensions of Perlin noise -// implementation. The base class just collects the -// common functionality. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for PerlinNoise2 and PerlinNoise3, different + * dimensions of Perlin noise implementation. The base class just collects + * the common functionality. + */ class EXPCL_PANDA_MATHUTIL PerlinNoise { protected: PerlinNoise(int table_size, unsigned long seed); diff --git a/panda/src/mathutil/perlinNoise2.I b/panda/src/mathutil/perlinNoise2.I index 31d17bbd83..4615b4bddd 100644 --- a/panda/src/mathutil/perlinNoise2.I +++ b/panda/src/mathutil/perlinNoise2.I @@ -1,25 +1,20 @@ -// Filename: perlinNoise2.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise2.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::Default Constructor -// Access: Published -// Description: Randomizes the tables to make a unique noise -// function. Uses a default scale (noise frequency), -// table size, and seed. -//////////////////////////////////////////////////////////////////// +/** + * Randomizes the tables to make a unique noise function. Uses a default + * scale (noise frequency), table size, and seed. + */ INLINE PerlinNoise2:: PerlinNoise2() : PerlinNoise(256, 0) @@ -28,15 +23,12 @@ PerlinNoise2() : _input_xform = _unscaled_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::Constructor -// Access: Published -// Description: Randomizes the tables to make a unique noise -// function. -// -// If seed is nonzero, it is used to define the tables; -// if it is zero a random seed is generated. -//////////////////////////////////////////////////////////////////// +/** + * Randomizes the tables to make a unique noise function. + * + * If seed is nonzero, it is used to define the tables; if it is zero a random + * seed is generated. + */ INLINE PerlinNoise2:: PerlinNoise2(double sx, double sy, int table_size, unsigned long seed) : @@ -46,12 +38,10 @@ PerlinNoise2(double sx, double sy, set_scale(sx, sy); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::Copy Constructor -// Access: Published -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ INLINE PerlinNoise2:: PerlinNoise2(const PerlinNoise2 ©) : PerlinNoise(copy), @@ -60,12 +50,10 @@ PerlinNoise2(const PerlinNoise2 ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::Copy Assignment Operator -// Access: Published -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ INLINE void PerlinNoise2:: operator = (const PerlinNoise2 ©) { PerlinNoise::operator = (copy); @@ -73,103 +61,82 @@ operator = (const PerlinNoise2 ©) { _input_xform = copy._input_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise2:: set_scale(double scale) { set_scale(scale, scale); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise2:: set_scale(double x, double y) { set_scale(LVecBase2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise2:: set_scale(const LVecBase2f &value) { set_scale(value[0], value[1]); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise2:: set_scale(const LVecBase2d &value) { _input_xform = LMatrix3d::scale_mat(1.0f / value[0], 1.0f / value[1]) * _unscaled_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double PerlinNoise2:: noise(double x, double y) const { return noise(LVecBase2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float PerlinNoise2:: noise(const LVecBase2f &value) const { return (float)noise(value[0], value[1]); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::operator () -// Access: Published -// Description: Returns the noise function of the two inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the two inputs. + */ INLINE double PerlinNoise2:: operator ()(double x, double y) const { return noise(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the two inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the two inputs. + */ INLINE float PerlinNoise2:: operator ()(const LVecBase2f &value) const { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the two inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the two inputs. + */ INLINE double PerlinNoise2:: operator ()(const LVecBase2d &value) const { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::grad -// Access: Private, Static -// Description: Returns the dot product of a random gradient vector -// (determined by the hash code) with the indicated -// offset vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dot product of a random gradient vector (determined by the hash + * code) with the indicated offset vector. + */ INLINE double PerlinNoise2:: grad(int hash, double x, double y) { // Convert low 3 bits of hash code into 8 gradient directions. diff --git a/panda/src/mathutil/perlinNoise2.cxx b/panda/src/mathutil/perlinNoise2.cxx index c7896211a9..ef187beb9c 100644 --- a/panda/src/mathutil/perlinNoise2.cxx +++ b/panda/src/mathutil/perlinNoise2.cxx @@ -1,25 +1,22 @@ -// Filename: perlinNoise2.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise2.cxx + * @author drose + * @date 2005-10-05 + */ #include "perlinNoise2.h" #include "cmath.h" -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ double PerlinNoise2:: noise(const LVecBase2d &value) const { // Convert the vector to our local coordinate space. @@ -37,7 +34,7 @@ noise(const LVecBase2d &value) const { // Find relative x,y of point in square. x -= xf; - y -= yf; + y -= yf; // Compute fade curves for each of x,y. double u = fade(x); @@ -46,32 +43,29 @@ noise(const LVecBase2d &value) const { // Hash coordinates of the 4 square corners (A, B, A + 1, and B + 1) int A = _index[X] + Y; int B = _index[X + 1] + Y; - + // and add blended results from 4 corners of square. double result = - lerp(v, lerp(u, grad(_index[A], x, y), - grad(_index[B], x - 1, y)), - lerp(u, grad(_index[A + 1], x, y - 1), + lerp(v, lerp(u, grad(_index[A], x, y), + grad(_index[B], x - 1, y)), + lerp(u, grad(_index[A + 1], x, y - 1), grad(_index[B + 1], x - 1, y - 1))); return result; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise2::init_unscaled_xform -// Access: Private -// Description: Come up with a random rotation to apply to the input -// coordinates. This will reduce the problem of the -// singularities on the axes, by sending the axes in -// some crazy direction. -//////////////////////////////////////////////////////////////////// +/** + * Come up with a random rotation to apply to the input coordinates. This + * will reduce the problem of the singularities on the axes, by sending the + * axes in some crazy direction. + */ void PerlinNoise2:: init_unscaled_xform() { double rot = _randomizer.random_real(360.0f); _unscaled_xform = LMatrix3d::rotate_mat(rot); - // And come up with a random translation too, just so the - // singularity at (0, 0) is also unpredicatable. + // And come up with a random translation too, just so the singularity at (0, + // 0) is also unpredicatable. _unscaled_xform.set_row(2, LVecBase2d(_randomizer.random_real_unit(), _randomizer.random_real_unit())); } diff --git a/panda/src/mathutil/perlinNoise2.h b/panda/src/mathutil/perlinNoise2.h index 1959185541..11d82aa064 100644 --- a/panda/src/mathutil/perlinNoise2.h +++ b/panda/src/mathutil/perlinNoise2.h @@ -1,16 +1,15 @@ -// Filename: perlinNoise2.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise2.h + * @author drose + * @date 2005-10-05 + */ #ifndef PERLINNOISE2_H #define PERLINNOISE2_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "perlinNoise.h" -//////////////////////////////////////////////////////////////////// -// Class : PerlinNoise2 -// Description : This class provides an implementation of Perlin noise -// for 2 variables. This code is loosely based on the -// reference implementation at -// http://mrl.nyu.edu/~perlin/noise/ . -//////////////////////////////////////////////////////////////////// +/** + * This class provides an implementation of Perlin noise for 2 variables. + * This code is loosely based on the reference implementation at + * http://mrl.nyu.edu/~perlin/noise/ . + */ class EXPCL_PANDA_MATHUTIL PerlinNoise2 : public PerlinNoise { PUBLISHED: INLINE PerlinNoise2(); @@ -46,7 +43,7 @@ PUBLISHED: INLINE double operator ()(double x, double y) const; INLINE float operator ()(const LVecBase2f &value) const; INLINE double operator ()(const LVecBase2d &value) const; - + private: void init_unscaled_xform(); INLINE static double grad(int hash, double x, double y); @@ -59,4 +56,3 @@ private: #include "perlinNoise2.I" #endif - diff --git a/panda/src/mathutil/perlinNoise3.I b/panda/src/mathutil/perlinNoise3.I index e5a8561db8..3a6ebe3001 100644 --- a/panda/src/mathutil/perlinNoise3.I +++ b/panda/src/mathutil/perlinNoise3.I @@ -1,25 +1,20 @@ -// Filename: perlinNoise3.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise3.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::Default Constructor -// Access: Published -// Description: Randomizes the tables to make a unique noise -// function. Uses a default scale (noise frequency), -// table size, and seed. -//////////////////////////////////////////////////////////////////// +/** + * Randomizes the tables to make a unique noise function. Uses a default + * scale (noise frequency), table size, and seed. + */ INLINE PerlinNoise3:: PerlinNoise3() : PerlinNoise(256, 0) @@ -28,15 +23,12 @@ PerlinNoise3() : _input_xform = _unscaled_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::Constructor -// Access: Published -// Description: Randomizes the tables to make a unique noise -// function. -// -// If seed is nonzero, it is used to define the tables; -// if it is zero a random seed is generated. -//////////////////////////////////////////////////////////////////// +/** + * Randomizes the tables to make a unique noise function. + * + * If seed is nonzero, it is used to define the tables; if it is zero a random + * seed is generated. + */ INLINE PerlinNoise3:: PerlinNoise3(double sx, double sy, double sz, int table_size, unsigned long seed) : @@ -46,12 +38,10 @@ PerlinNoise3(double sx, double sy, double sz, set_scale(sx, sy, sz); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::Copy Constructor -// Access: Published -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ INLINE PerlinNoise3:: PerlinNoise3(const PerlinNoise3 ©) : PerlinNoise(copy), @@ -60,12 +50,10 @@ PerlinNoise3(const PerlinNoise3 ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::Copy Assignment Operator -// Access: Published -// Description: Makes an exact copy of the existing PerlinNoise -// object, including its random seed. -//////////////////////////////////////////////////////////////////// +/** + * Makes an exact copy of the existing PerlinNoise object, including its + * random seed. + */ INLINE void PerlinNoise3:: operator = (const PerlinNoise3 ©) { PerlinNoise::operator = (copy); @@ -73,103 +61,82 @@ operator = (const PerlinNoise3 ©) { _input_xform = copy._input_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise3:: set_scale(double scale) { set_scale(scale, scale, scale); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise3:: set_scale(double x, double y, double z) { set_scale(LVecBase3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise3:: set_scale(const LVecBase3f &value) { set_scale(value[0], value[1], value[2]); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::set_scale -// Access: Published -// Description: Changes the scale (frequency) of the noise. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale (frequency) of the noise. + */ INLINE void PerlinNoise3:: set_scale(const LVecBase3d &value) { _input_xform = LMatrix4d::scale_mat(1.0f / value[0], 1.0f / value[1], 1.0f / value[2]) * _unscaled_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double PerlinNoise3:: noise(double x, double y, double z) const { return noise(LVecBase3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float PerlinNoise3:: noise(const LVecBase3f &value) const { return (float)noise(value[0], value[1], value[2]); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::operator () -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double PerlinNoise3:: operator ()(double x, double y, double z) const { return noise(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float PerlinNoise3:: operator ()(const LVecBase3f &value) const { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double PerlinNoise3:: operator ()(const LVecBase3d &value) const { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::grad -// Access: Private, Static -// Description: Returns the dot product of a random gradient vector -// (determined by the hash code) with the indicated -// offset vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dot product of a random gradient vector (determined by the hash + * code) with the indicated offset vector. + */ INLINE double PerlinNoise3:: grad(int hash, double x, double y, double z) { // Convert low 4 bits of hash code into 12 gradient directions. diff --git a/panda/src/mathutil/perlinNoise3.cxx b/panda/src/mathutil/perlinNoise3.cxx index d6ddd8cd35..7d2aff668a 100644 --- a/panda/src/mathutil/perlinNoise3.cxx +++ b/panda/src/mathutil/perlinNoise3.cxx @@ -1,25 +1,22 @@ -// Filename: perlinNoise3.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise3.cxx + * @author drose + * @date 2005-10-05 + */ #include "perlinNoise3.h" #include "cmath.h" -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ double PerlinNoise3:: noise(const LVecBase3d &value) const { // Convert the vector to our local coordinate space. @@ -40,7 +37,7 @@ noise(const LVecBase3d &value) const { // Find relative x,y,z of point in cube. x -= xf; - y -= yf; + y -= yf; z -= zf; // Compute fade curves for each of x,y,z. @@ -48,37 +45,34 @@ noise(const LVecBase3d &value) const { double v = fade(y); double w = fade(z); - // Hash coordinates of the 8 cube corners. The 8 corners correspond - // to AA, BA, AB, BB, AA + 1, BA + 1, AB + 1, and BB + 1. + // Hash coordinates of the 8 cube corners. The 8 corners correspond to AA, + // BA, AB, BB, AA + 1, BA + 1, AB + 1, and BB + 1. int A = _index[X] + Y; int AA = _index[A] + Z; int AB = _index[A + 1] + Z; int B = _index[X + 1] + Y; int BA = _index[B] + Z; - int BB = _index[B + 1] + Z; - + int BB = _index[B + 1] + Z; + // and add blended results from 8 corners of cube. double result = - lerp(w, lerp(v, lerp(u, grad(_index[AA], x, y, z), - grad(_index[BA], x - 1, y, z)), - lerp(u, grad(_index[AB], x, y - 1, z), - grad(_index[BB], x - 1, y - 1, z))), - lerp(v, lerp(u, grad(_index[AA + 1], x, y, z - 1), - grad(_index[BA + 1], x - 1, y, z - 1)), - lerp(u, grad(_index[AB + 1], x, y - 1, z - 1), + lerp(w, lerp(v, lerp(u, grad(_index[AA], x, y, z), + grad(_index[BA], x - 1, y, z)), + lerp(u, grad(_index[AB], x, y - 1, z), + grad(_index[BB], x - 1, y - 1, z))), + lerp(v, lerp(u, grad(_index[AA + 1], x, y, z - 1), + grad(_index[BA + 1], x - 1, y, z - 1)), + lerp(u, grad(_index[AB + 1], x, y - 1, z - 1), grad(_index[BB + 1], x - 1, y - 1, z - 1)))); return result; } -//////////////////////////////////////////////////////////////////// -// Function: PerlinNoise3::init_unscaled_xform -// Access: Private -// Description: Come up with a random rotation to apply to the input -// coordinates. This will reduce the problem of the -// singularities on the axes, by sending the axes in -// some crazy direction. -//////////////////////////////////////////////////////////////////// +/** + * Come up with a random rotation to apply to the input coordinates. This + * will reduce the problem of the singularities on the axes, by sending the + * axes in some crazy direction. + */ void PerlinNoise3:: init_unscaled_xform() { LRotationd rot(_randomizer.random_real_unit(), @@ -88,8 +82,8 @@ init_unscaled_xform() { rot.normalize(); rot.extract_to_matrix(_unscaled_xform); - // And come up with a random translation too, just so the - // singularity at (0, 0, 0) is also unpredicatable. + // And come up with a random translation too, just so the singularity at (0, + // 0, 0) is also unpredicatable. _unscaled_xform.set_row(3, LVecBase3d(_randomizer.random_real_unit(), _randomizer.random_real_unit(), _randomizer.random_real_unit())); diff --git a/panda/src/mathutil/perlinNoise3.h b/panda/src/mathutil/perlinNoise3.h index 91fa4eefae..092091ef2f 100644 --- a/panda/src/mathutil/perlinNoise3.h +++ b/panda/src/mathutil/perlinNoise3.h @@ -1,16 +1,15 @@ -// Filename: perlinNoise3.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file perlinNoise3.h + * @author drose + * @date 2005-10-05 + */ #ifndef PERLINNOISE3_H #define PERLINNOISE3_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "perlinNoise.h" -//////////////////////////////////////////////////////////////////// -// Class : PerlinNoise3 -// Description : This class provides an implementation of Perlin noise -// for 3 variables. This code is loosely based on the -// reference implementation at -// http://mrl.nyu.edu/~perlin/noise/ . -//////////////////////////////////////////////////////////////////// +/** + * This class provides an implementation of Perlin noise for 3 variables. + * This code is loosely based on the reference implementation at + * http://mrl.nyu.edu/~perlin/noise/ . + */ class EXPCL_PANDA_MATHUTIL PerlinNoise3 : public PerlinNoise { PUBLISHED: INLINE PerlinNoise3(); @@ -45,7 +42,7 @@ PUBLISHED: INLINE double operator ()(double x, double y, double z) const; INLINE float operator ()(const LVecBase3f &value) const; INLINE double operator ()(const LVecBase3d &value) const; - + private: void init_unscaled_xform(); INLINE static double grad(int hash, double x, double y, double z); @@ -58,4 +55,3 @@ private: #include "perlinNoise3.I" #endif - diff --git a/panda/src/mathutil/plane.cxx b/panda/src/mathutil/plane.cxx index 65fcbd1ce2..524c7db61f 100644 --- a/panda/src/mathutil/plane.cxx +++ b/panda/src/mathutil/plane.cxx @@ -1,16 +1,15 @@ -// Filename: plane.cxx -// Created by: drose (19May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plane.cxx + * @author drose + * @date 2000-05-19 + */ #include "plane.h" diff --git a/panda/src/mathutil/plane.h b/panda/src/mathutil/plane.h index 1bac38e238..7fb473efed 100644 --- a/panda/src/mathutil/plane.h +++ b/panda/src/mathutil/plane.h @@ -1,16 +1,15 @@ -// Filename: plane.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plane.h + * @author mike + * @date 1997-01-09 + */ #ifndef PLANE_H #define PLANE_H diff --git a/panda/src/mathutil/plane_src.I b/panda/src/mathutil/plane_src.I index 489dda5375..373d256e31 100644 --- a/panda/src/mathutil/plane_src.I +++ b/panda/src/mathutil/plane_src.I @@ -1,24 +1,20 @@ -// Filename: plane_src.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plane_src.I + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Constructor -// Access: Published -// Description: Creates a default plane. This plane happens to -// intersect the origin, perpendicular to the Z axis. -// It's not clear how useful a default plane is. -//////////////////////////////////////////////////////////////////// +/** + * Creates a default plane. This plane happens to intersect the origin, + * perpendicular to the Z axis. It's not clear how useful a default plane is. + */ INLINE_MATHUTIL FLOATNAME(LPlane):: FLOATNAME(LPlane)() { _v(0) = 0.0f; @@ -27,25 +23,20 @@ FLOATNAME(LPlane)() { _v(3) = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE_MATHUTIL FLOATNAME(LPlane):: FLOATNAME(LPlane)(const FLOATNAME(LVecBase4) ©) : FLOATNAME(LVecBase4)(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Constructor -// Access: Published -// Description: Constructs a plane given three counter-clockwise -// points, as seen from the front of the plane (that is, -// viewed from the end of the normal vector, looking -// down). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a plane given three counter-clockwise points, as seen from the + * front of the plane (that is, viewed from the end of the normal vector, + * looking down). + */ INLINE_MATHUTIL FLOATNAME(LPlane):: FLOATNAME(LPlane)(const FLOATNAME(LPoint3) &a, const FLOATNAME(LPoint3) &b, const FLOATNAME(LPoint3) &c) { @@ -59,12 +50,10 @@ FLOATNAME(LPlane)(const FLOATNAME(LPoint3) &a, const FLOATNAME(LPoint3) &b, _v(3) = -::dot(p, a); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Constructor -// Access: Published -// Description: Constructs a plane given a surface normal vector and -// a point within the plane. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a plane given a surface normal vector and a point within the + * plane. + */ INLINE_MATHUTIL FLOATNAME(LPlane):: FLOATNAME(LPlane)(const FLOATNAME(LVector3) &normal, const FLOATNAME(LPoint3) &point) { @@ -76,34 +65,27 @@ FLOATNAME(LPlane)(const FLOATNAME(LVector3) &normal, _v(3) = -::dot(p, point); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Constructor -// Access: Published -// Description: Constructs a plane given the four terms of the plane -// equation. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a plane given the four terms of the plane equation. + */ INLINE_MATHUTIL FLOATNAME(LPlane):: FLOATNAME(LPlane)(FLOATTYPE a, FLOATTYPE b, FLOATTYPE c, FLOATTYPE d) : FLOATNAME(LVecBase4)(a, b, c, d) { } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Operator * LMatrix3 -// Access: Published -// Description: Transforms the plane by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the plane by the indicated matrix. + */ INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane):: operator * (const FLOATNAME(LMatrix3) &mat) const { FLOATNAME(LVector3) new_normal = mat.xform(get_normal()); return FLOATNAME(LPlane)(new_normal, get_point()); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Operator * LMatrix4 -// Access: Published -// Description: Transforms the plane by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the plane by the indicated matrix. + */ INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane):: operator * (const FLOATNAME(LMatrix4) &mat) const { FLOATNAME(LVector3) new_normal = mat.xform_vec_general(get_normal()); @@ -111,78 +93,62 @@ operator * (const FLOATNAME(LMatrix4) &mat) const { return FLOATNAME(LPlane)(new_normal, new_point); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Operator *= LMatrix4 -// Access: Published -// Description: Transforms the plane by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the plane by the indicated matrix. + */ INLINE_MATHUTIL void FLOATNAME(LPlane):: operator *= (const FLOATNAME(LMatrix4) &mat) { (*this) = (*this) * mat; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::xform -// Access: Published -// Description: Transforms the plane by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the plane by the indicated matrix. + */ INLINE_MATHUTIL void FLOATNAME(LPlane):: xform(const FLOATNAME(LMatrix4) &mat) { (*this) = (*this) * mat; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::Unary - -// Access: Published -// Description: Returns the same plane facing the opposite direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the same plane facing the opposite direction. + */ INLINE_MATHUTIL FLOATNAME(LPlane) FLOATNAME(LPlane):: operator - () const { return FLOATNAME(LPlane)(-_v(0), -_v(1), -_v(2), -_v(3)); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::get_normal -// Access: Published -// Description: Returns the surface normal of the plane. -//////////////////////////////////////////////////////////////////// +/** + * Returns the surface normal of the plane. + */ INLINE_MATHUTIL FLOATNAME(LVector3) FLOATNAME(LPlane):: get_normal() const { return FLOATNAME(LVector3)(_v(0), _v(1), _v(2)); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::dist_to_plane -// Access: Published -// Description: Returns the straight-line shortest distance from the -// point to the plane. The returned value is positive -// if the point is in front of the plane (on the side -// with the normal), or negative in the point is behind -// the plane (on the opposite side from the normal). -// It's zero if the point is exactly in the plane. -//////////////////////////////////////////////////////////////////// +/** + * Returns the straight-line shortest distance from the point to the plane. + * The returned value is positive if the point is in front of the plane (on + * the side with the normal), or negative in the point is behind the plane (on + * the opposite side from the normal). It's zero if the point is exactly in + * the plane. + */ INLINE_MATHUTIL FLOATTYPE FLOATNAME(LPlane):: dist_to_plane(const FLOATNAME(LPoint3) &point) const { return (_v(0) * point[0] + _v(1) * point[1] + _v(2) * point[2] + _v(3)); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::project -// Access: Published -// Description: Returns the point within the plane nearest to the -// indicated point in space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point within the plane nearest to the indicated point in space. + */ INLINE_MATHUTIL FLOATNAME(LPoint3) FLOATNAME(LPlane):: project(const FLOATNAME(LPoint3) &point) const { return point - get_normal() * dist_to_plane(point); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::flip -// Access: Published -// Description: Convenience method that flips the plane in-place. -// This is done by simply flipping the normal vector. -//////////////////////////////////////////////////////////////////// +/** + * Convenience method that flips the plane in-place. This is done by simply + * flipping the normal vector. + */ INLINE_MATHUTIL void FLOATNAME(LPlane):: flip() { _v(0) = -_v(0); @@ -191,16 +157,13 @@ flip() { _v(3) = -_v(3); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::intersects_line -// Access: Published -// Description: Returns true if the plane intersects the infinite -// line passing through points p1 and p2, false if the -// line is parallel. The points p1 and p2 are used only -// to define the Euclidean line; they have no other -// bearing on the intersection test. If true, sets -// intersection_point to the point of intersection. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the plane intersects the infinite line passing through + * points p1 and p2, false if the line is parallel. The points p1 and p2 are + * used only to define the Euclidean line; they have no other bearing on the + * intersection test. If true, sets intersection_point to the point of + * intersection. + */ INLINE_MATHUTIL bool FLOATNAME(LPlane):: intersects_line(FLOATNAME(LPoint3) &intersection_point, const FLOATNAME(LPoint3) &p1, @@ -213,23 +176,18 @@ intersects_line(FLOATNAME(LPoint3) &intersection_point, return true; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::intersects_line -// Access: Published -// Description: This flavor of intersects_line() returns a bit more -// information about the nature of the intersecting -// point. The line is defined via the parametric -// equation from + t * delta for all real values of t. -// -// If there is no intersection with the plane, the -// function returns false and leaves t undefined. If -// there is an intersection with the plane, the function -// returns true and sets t to the parametric value that -// defines the point of intersection. That is, t == 0.0f -// implies that the intersection occurred exactly at -// point from, and t == 1.0f implies at point from + -// delta, with other values of t accordingly. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of intersects_line() returns a bit more information about the + * nature of the intersecting point. The line is defined via the parametric + * equation from + t * delta for all real values of t. + * + * If there is no intersection with the plane, the function returns false and + * leaves t undefined. If there is an intersection with the plane, the + * function returns true and sets t to the parametric value that defines the + * point of intersection. That is, t == 0.0f implies that the intersection + * occurred exactly at point from, and t == 1.0f implies at point from + + * delta, with other values of t accordingly. + */ INLINE_MATHUTIL bool FLOATNAME(LPlane):: intersects_line(FLOATTYPE &t, const FLOATNAME(LPoint3) &from, diff --git a/panda/src/mathutil/plane_src.cxx b/panda/src/mathutil/plane_src.cxx index d89b6d8c8c..3a3baff375 100644 --- a/panda/src/mathutil/plane_src.cxx +++ b/panda/src/mathutil/plane_src.cxx @@ -1,28 +1,23 @@ -// Filename: plane_src.cxx -// Created by: drose (03Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plane_src.cxx + * @author drose + * @date 2001-04-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LPlane::get_reflection_mat -// Access: Published -// Description: This computes a transform matrix that reflects the -// universe to the other side of the plane, as in a -// mirror. -//////////////////////////////////////////////////////////////////// +/** + * This computes a transform matrix that reflects the universe to the other + * side of the plane, as in a mirror. + */ FLOATNAME(LMatrix4) FLOATNAME(LPlane):: get_reflection_mat() const { - FLOATTYPE aa = _v(0) * _v(0); + FLOATTYPE aa = _v(0) * _v(0); FLOATTYPE ab = _v(0) * _v(1); FLOATTYPE ac = _v(0) * _v(2); FLOATTYPE ad = _v(0) * _v(3); @@ -38,13 +33,10 @@ get_reflection_mat() const { -2*ad, -2*bd, -2*cd, 1 ); } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::get_point -// Access: Published -// Description: Returns an arbitrary point in the plane. This can be -// used along with the normal returned by get_normal() -// to reconstruct the plane. -//////////////////////////////////////////////////////////////////// +/** + * Returns an arbitrary point in the plane. This can be used along with the + * normal returned by get_normal() to reconstruct the plane. + */ FLOATNAME(LPoint3) FLOATNAME(LPlane):: get_point() const { // Choose the denominator based on the largest axis in the normal. @@ -61,16 +53,12 @@ get_point() const { } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::intersects_plane -// Access: Published -// Description: Returns true if the two planes intersect, false if -// they do not. If they do intersect, then from and -// delta are filled in with the parametric -// representation of the line of intersection: that is, -// from is a point on that line, and delta is a vector -// showing the direction of the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two planes intersect, false if they do not. If they do + * intersect, then from and delta are filled in with the parametric + * representation of the line of intersection: that is, from is a point on + * that line, and delta is a vector showing the direction of the line. + */ bool FLOATNAME(LPlane):: intersects_plane(FLOATNAME(LPoint3) &from, FLOATNAME(LVector3) &delta, @@ -81,8 +69,8 @@ intersects_plane(FLOATNAME(LPoint3) &from, // The delta will be the cross product of the planes' normals. delta = cross(n1, n2); - // If the delta came out to zero, the planes were parallel and do - // not intersect. + // If the delta came out to zero, the planes were parallel and do not + // intersect. if (delta.almost_equal(FLOATNAME(LVector3)::zero())) { return false; } @@ -90,7 +78,7 @@ intersects_plane(FLOATNAME(LPoint3) &from, FLOATTYPE n1n1 = ::dot(n1, n1); FLOATTYPE n2n2 = ::dot(n2, n2); FLOATTYPE n1n2 = ::dot(n1, n2); - + FLOATTYPE determinant_inv = 1.0f / (n1n1 * n2n2 - n1n2 * n1n2); FLOATTYPE c1 = (other._v(3) * n1n2 - _v(3) * n2n2) * determinant_inv; FLOATTYPE c2 = (_v(3) * n1n2 - other._v(3) * n1n1) * determinant_inv; @@ -99,32 +87,24 @@ intersects_plane(FLOATNAME(LPoint3) &from, return true; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::intersects_parabola -// Access: Published -// Description: Determines whether and where the indicated parabola -// intersects with the plane. -// -// If there is no intersection with the plane, the -// function returns false and leaves t1 and t2 -// undefined. If there is an intersection with the -// plane, the function returns true and sets t1 and t2 -// to the parametric value that defines the two points -// of intersection. If the parabola is exactly tangent -// to the plane, then t1 == t2. -//////////////////////////////////////////////////////////////////// +/** + * Determines whether and where the indicated parabola intersects with the + * plane. + * + * If there is no intersection with the plane, the function returns false and + * leaves t1 and t2 undefined. If there is an intersection with the plane, + * the function returns true and sets t1 and t2 to the parametric value that + * defines the two points of intersection. If the parabola is exactly tangent + * to the plane, then t1 == t2. + */ bool FLOATNAME(LPlane):: intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, const FLOATNAME(LParabola) ¶bola) const { - // - // The parabola intersects the plane wherever: - // - // a * t^2 + b * t + c == 0 - // - // where a = normal dot parabola.get_a(), - // b = normal dot parabola.get_b(), - // c = normal dot parabola.get_c() + d. - // +/* + * The parabola intersects the plane wherever: a * t^2 + b * t + c == 0 where + * a = normal dot parabola.get_a(), b = normal dot parabola.get_b(), c = + * normal dot parabola.get_c() + d. + */ FLOATNAME(LVector3) normal = get_normal(); FLOATTYPE a = normal.dot(parabola.get_a()); @@ -132,15 +112,13 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, FLOATTYPE c = normal.dot(parabola.get_c()) + _v(3); if (IS_NEARLY_ZERO(a)) { - // It's not quadratic. The equation is actually: - // b * t + c == 0. - // Which means: - // t = -c / b. + // It's not quadratic. The equation is actually: b * t + c == 0. Which + // means: t = -c b. if (IS_NEARLY_ZERO(b)) { - // It's not even linear. The parabola must be completely - // parallel to the plane, or if c == 0, it's completely within - // the plane. In both cases, we'll call it no intersection. + // It's not even linear. The parabola must be completely parallel to + // the plane, or if c == 0, it's completely within the plane. In both + // cases, we'll call it no intersection. return false; } @@ -163,11 +141,9 @@ intersects_parabola(FLOATTYPE &t1, FLOATTYPE &t2, return true; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LPlane):: output(ostream &out) const { out << "LPlane("; @@ -175,11 +151,9 @@ output(ostream &out) const { out << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: LPlane::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FLOATNAME(LPlane):: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; diff --git a/panda/src/mathutil/plane_src.h b/panda/src/mathutil/plane_src.h index 290b3745a2..2e0d7aa0f6 100644 --- a/panda/src/mathutil/plane_src.h +++ b/panda/src/mathutil/plane_src.h @@ -1,22 +1,20 @@ -// Filename: plane_src.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file plane_src.h + * @author mike + * @date 1997-01-09 + */ -//////////////////////////////////////////////////////////////////// -// Class : LPlane -// Description : An abstract mathematical description of a plane. A -// plane is defined by the equation Ax + By + Cz + D = 0. -//////////////////////////////////////////////////////////////////// +/** + * An abstract mathematical description of a plane. A plane is defined by the + * equation Ax + By + Cz + D = 0. + */ class EXPCL_PANDA_MATHUTIL FLOATNAME(LPlane) : public FLOATNAME(LVecBase4) { PUBLISHED: INLINE_MATHUTIL FLOATNAME(LPlane)(); diff --git a/panda/src/mathutil/pta_LMatrix3.cxx b/panda/src/mathutil/pta_LMatrix3.cxx index 42382e1295..e6a273a9fb 100644 --- a/panda/src/mathutil/pta_LMatrix3.cxx +++ b/panda/src/mathutil/pta_LMatrix3.cxx @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix3.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix3.cxx + * @author drose + * @date 2010-02-27 + */ #include "pta_LMatrix3.h" diff --git a/panda/src/mathutil/pta_LMatrix3.h b/panda/src/mathutil/pta_LMatrix3.h index 004e058fd7..ccd88e156c 100644 --- a/panda/src/mathutil/pta_LMatrix3.h +++ b/panda/src/mathutil/pta_LMatrix3.h @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix3.h -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix3.h + * @author drose + * @date 2010-02-27 + */ #ifndef PTA_LMATRIX3_H #define PTA_LMATRIX3_H @@ -19,14 +18,12 @@ #include "luse.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_LMatrix3f -// Description : A pta of LMatrix3fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LMatrix3fs. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -36,14 +33,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LMatrix3f; typedef ConstPointerToArray CPTA_LMatrix3f; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LMatrix3d -// Description : A pta of LMatrix3ds. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LMatrix3ds. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) diff --git a/panda/src/mathutil/pta_LMatrix3_ext.h b/panda/src/mathutil/pta_LMatrix3_ext.h index 4cda107aef..aa3755ba2e 100644 --- a/panda/src/mathutil/pta_LMatrix3_ext.h +++ b/panda/src/mathutil/pta_LMatrix3_ext.h @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix3_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix3_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PTA_LMATRIX3_EXT_H #define PTA_LMATRIX3_EXT_H diff --git a/panda/src/mathutil/pta_LMatrix4.cxx b/panda/src/mathutil/pta_LMatrix4.cxx index 5ba0c1b9a8..02ba4d48da 100644 --- a/panda/src/mathutil/pta_LMatrix4.cxx +++ b/panda/src/mathutil/pta_LMatrix4.cxx @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix4.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix4.cxx + * @author drose + * @date 2010-02-27 + */ #include "pta_LMatrix4.h" diff --git a/panda/src/mathutil/pta_LMatrix4.h b/panda/src/mathutil/pta_LMatrix4.h index 7d5d3e62fd..ef5888b465 100644 --- a/panda/src/mathutil/pta_LMatrix4.h +++ b/panda/src/mathutil/pta_LMatrix4.h @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix4.h -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix4.h + * @author drose + * @date 2010-02-27 + */ #ifndef PTA_LMATRIX4_H #define PTA_LMATRIX4_H @@ -19,18 +18,15 @@ #include "luse.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_LMatrix4f -// Description : A pta of LMatrix4fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -// -// We actually wrap UnalignedLMatrix4f, in case we are -// building with SSE2 and LMatrix4f requires strict -// alignment. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LMatrix4fs. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + * + * We actually wrap UnalignedLMatrix4f, in case we are building with SSE2 and + * LMatrix4f requires strict alignment. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -40,18 +36,15 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LMatrix4f; typedef ConstPointerToArray CPTA_LMatrix4f; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LMatrix4d -// Description : A pta of LMatrix4ds. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -// -// We actually wrap UnalignedLMatrix4d, in case we are -// building with SSE2 and LMatrix4d requires strict -// alignment. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LMatrix4ds. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + * + * We actually wrap UnalignedLMatrix4d, in case we are building with SSE2 and + * LMatrix4d requires strict alignment. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) diff --git a/panda/src/mathutil/pta_LMatrix4_ext.h b/panda/src/mathutil/pta_LMatrix4_ext.h index 02a1e86dd8..2f1077b2f4 100644 --- a/panda/src/mathutil/pta_LMatrix4_ext.h +++ b/panda/src/mathutil/pta_LMatrix4_ext.h @@ -1,16 +1,15 @@ -// Filename: pta_LMatrix4_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LMatrix4_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PTA_LMATRIX4_EXT_H #define PTA_LMATRIX4_EXT_H diff --git a/panda/src/mathutil/pta_LVecBase2.cxx b/panda/src/mathutil/pta_LVecBase2.cxx index cbf9ace24f..6c232034df 100644 --- a/panda/src/mathutil/pta_LVecBase2.cxx +++ b/panda/src/mathutil/pta_LVecBase2.cxx @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase2.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase2.cxx + * @author drose + * @date 2010-02-27 + */ #include "pta_LVecBase2.h" diff --git a/panda/src/mathutil/pta_LVecBase2.h b/panda/src/mathutil/pta_LVecBase2.h index 8a89d075b6..b4296df5da 100644 --- a/panda/src/mathutil/pta_LVecBase2.h +++ b/panda/src/mathutil/pta_LVecBase2.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase2.h -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 2D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase2.h + * @author drose + * @date 2010-02-27 + */ #ifndef PTA_LVECBASE2_H #define PTA_LVECBASE2_H @@ -19,14 +18,12 @@ #include "luse.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase2f -// Description : A pta of LVecBase2fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase2fs. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -36,14 +33,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase2f; typedef ConstPointerToArray CPTA_LVecBase2f; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase2d -// Description : A pta of LVecBase2ds. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase2ds. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -53,14 +48,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase2d; typedef ConstPointerToArray CPTA_LVecBase2d; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase2i -// Description : A pta of LVecBase2is. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase2is. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) diff --git a/panda/src/mathutil/pta_LVecBase2_ext.h b/panda/src/mathutil/pta_LVecBase2_ext.h index 4624ec604f..48b901de66 100644 --- a/panda/src/mathutil/pta_LVecBase2_ext.h +++ b/panda/src/mathutil/pta_LVecBase2_ext.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase2_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase2_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PTA_LVECBASE2_EXT_H #define PTA_LVECBASE2_EXT_H diff --git a/panda/src/mathutil/pta_LVecBase3.cxx b/panda/src/mathutil/pta_LVecBase3.cxx index d851708d2c..7248c2638c 100644 --- a/panda/src/mathutil/pta_LVecBase3.cxx +++ b/panda/src/mathutil/pta_LVecBase3.cxx @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase3.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase3.cxx + * @author drose + * @date 2010-02-27 + */ #include "pta_LVecBase3.h" diff --git a/panda/src/mathutil/pta_LVecBase3.h b/panda/src/mathutil/pta_LVecBase3.h index f2805a938e..f883e1acbb 100644 --- a/panda/src/mathutil/pta_LVecBase3.h +++ b/panda/src/mathutil/pta_LVecBase3.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase3.h -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase3.h + * @author drose + * @date 2010-02-27 + */ #ifndef PTA_LVECBASE3_H #define PTA_LVECBASE3_H @@ -19,14 +18,12 @@ #include "luse.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase3f -// Description : A pta of LVecBase3fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase3fs. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -36,14 +33,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase3f; typedef ConstPointerToArray CPTA_LVecBase3f; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase3d -// Description : A pta of LVecBase3ds. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase3ds. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -53,14 +48,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase3d; typedef ConstPointerToArray CPTA_LVecBase3d; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase3i -// Description : A pta of LVecBase3is. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase3is. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) diff --git a/panda/src/mathutil/pta_LVecBase3_ext.h b/panda/src/mathutil/pta_LVecBase3_ext.h index 2ae87f518f..6cbdfd68c1 100644 --- a/panda/src/mathutil/pta_LVecBase3_ext.h +++ b/panda/src/mathutil/pta_LVecBase3_ext.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase3_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase3_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PTA_LVECBASE3_EXT_H #define PTA_LVECBASE3_EXT_H diff --git a/panda/src/mathutil/pta_LVecBase4.cxx b/panda/src/mathutil/pta_LVecBase4.cxx index dc8de69ebe..b06d7340a4 100644 --- a/panda/src/mathutil/pta_LVecBase4.cxx +++ b/panda/src/mathutil/pta_LVecBase4.cxx @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase4.cxx -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase4.cxx + * @author drose + * @date 2010-02-27 + */ #include "pta_LVecBase4.h" diff --git a/panda/src/mathutil/pta_LVecBase4.h b/panda/src/mathutil/pta_LVecBase4.h index 555d4252b1..0d966002c0 100644 --- a/panda/src/mathutil/pta_LVecBase4.h +++ b/panda/src/mathutil/pta_LVecBase4.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase4.h -// Created by: drose (27Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 4D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase4.h + * @author drose + * @date 2010-02-27 + */ #ifndef PTA_LVECBASE4_H #define PTA_LVECBASE4_H @@ -19,18 +18,15 @@ #include "luse.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase4f -// Description : A pta of LVecBase4fs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -// -// We actually wrap UnalignedLVecBase4f, in case we are -// building with SSE2 and LVecBase4f requires strict -// alignment. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase4fs. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + * + * We actually wrap UnalignedLVecBase4f, in case we are building with SSE2 and + * LVecBase4f requires strict alignment. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -40,18 +36,15 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase4f; typedef ConstPointerToArray CPTA_LVecBase4f; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase4d -// Description : A pta of LVecBase4ds. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -// -// We actually wrap UnalignedLVecBase4d, in case we are -// building with SSE2 and LVecBase4d requires strict -// alignment. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase4ds. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + * + * We actually wrap UnalignedLVecBase4d, in case we are building with SSE2 and + * LVecBase4d requires strict alignment. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) @@ -61,18 +54,15 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, ConstPointerTo typedef PointerToArray PTA_LVecBase4d; typedef ConstPointerToArray CPTA_LVecBase4d; -//////////////////////////////////////////////////////////////////// -// Class : PTA_LVecBase4i -// Description : A pta of LVecBase4is. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -// -// We actually wrap UnalignedLVecBase4i, in case we are -// building with SSE2 and LVecBase4i requires strict -// alignment. -//////////////////////////////////////////////////////////////////// +/** + * A pta of LVecBase4is. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + * + * We actually wrap UnalignedLVecBase4i, in case we are building with SSE2 and + * LVecBase4i requires strict alignment. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_MATHUTIL, EXPTP_PANDA_MATHUTIL, PointerToArrayBase) diff --git a/panda/src/mathutil/pta_LVecBase4_ext.h b/panda/src/mathutil/pta_LVecBase4_ext.h index 29eee6530a..37ee2e6603 100644 --- a/panda/src/mathutil/pta_LVecBase4_ext.h +++ b/panda/src/mathutil/pta_LVecBase4_ext.h @@ -1,16 +1,15 @@ -// Filename: pta_LVecBase4_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_LVecBase4_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PTA_LVECBASE4_EXT_H #define PTA_LVECBASE4_EXT_H diff --git a/panda/src/mathutil/randomizer.I b/panda/src/mathutil/randomizer.I index d85fd715d7..3cb30939b9 100644 --- a/panda/src/mathutil/randomizer.I +++ b/panda/src/mathutil/randomizer.I @@ -1,87 +1,70 @@ -// Filename: randomizer.I -// Created by: drose (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file randomizer.I + * @author drose + * @date 2007-01-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::Constructor -// Access: Public -// Description: If seed is nonzero, it is used to define the tables; -// if it is zero a random seed is generated. -//////////////////////////////////////////////////////////////////// +/** + * If seed is nonzero, it is used to define the tables; if it is zero a random + * seed is generated. + */ Randomizer:: Randomizer(unsigned long seed) : _mersenne(seed != 0 ? seed : get_next_seed()) { } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Randomizer:: Randomizer(const Randomizer ©) : _mersenne(copy._mersenne) { } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Randomizer:: operator = (const Randomizer ©) { _mersenne = copy._mersenne; } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::random_int -// Access: Public -// Description: Returns a random integer in the range [0, range). -//////////////////////////////////////////////////////////////////// +/** + * Returns a random integer in the range [0, range). + */ INLINE int Randomizer:: random_int(int range) { return (int)floor(random_real((double)range)); } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::random_real -// Access: Public -// Description: Returns a random double in the range [0, range). -//////////////////////////////////////////////////////////////////// +/** + * Returns a random double in the range [0, range). + */ INLINE double Randomizer:: random_real(double range) { return (range * _mersenne.get_uint31()) / ((double)0x80000000); } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::random_real_unit -// Access: Public -// Description: Returns a random double in the range [-0.5, 0.5). -//////////////////////////////////////////////////////////////////// +/** + * Returns a random double in the range [-0.5, 0.5). + */ INLINE double Randomizer:: random_real_unit() { return random_real(1.0f) - 0.5f; } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::get_next_seed -// Access: Public, Static -// Description: Returns a random seed value for the next global -// Randomizer object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a random seed value for the next global Randomizer object. + */ INLINE unsigned long Randomizer:: get_next_seed() { if (!_got_first_seed) { @@ -91,13 +74,10 @@ get_next_seed() { return _next_seed.get_uint31(); } -//////////////////////////////////////////////////////////////////// -// Function: Randomizer::get_seed -// Access: Public -// Description: Returns a unique seed value based on the seed value -// passed to this Randomizer object (and on its current -// state). -//////////////////////////////////////////////////////////////////// +/** + * Returns a unique seed value based on the seed value passed to this + * Randomizer object (and on its current state). + */ INLINE unsigned long Randomizer:: get_seed() { return _mersenne.get_uint31(); diff --git a/panda/src/mathutil/randomizer.cxx b/panda/src/mathutil/randomizer.cxx index a88909a68f..301cb4e54d 100644 --- a/panda/src/mathutil/randomizer.cxx +++ b/panda/src/mathutil/randomizer.cxx @@ -1,19 +1,17 @@ -// Filename: randomizer.cxx -// Created by: drose (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file randomizer.cxx + * @author drose + * @date 2007-01-18 + */ #include "randomizer.h" Mersenne Randomizer::_next_seed(0); bool Randomizer::_got_first_seed = false; - diff --git a/panda/src/mathutil/randomizer.h b/panda/src/mathutil/randomizer.h index 1e7f1f5bc6..4f0dd0e736 100644 --- a/panda/src/mathutil/randomizer.h +++ b/panda/src/mathutil/randomizer.h @@ -1,16 +1,15 @@ -// Filename: randomizer.h -// Created by: drose (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file randomizer.h + * @author drose + * @date 2007-01-18 + */ #ifndef RANDOMIZER_H #define RANDOMIZER_H @@ -21,10 +20,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : Randomizer -// Description : A handy class to return random numbers. -//////////////////////////////////////////////////////////////////// +/** + * A handy class to return random numbers. + */ class EXPCL_PANDA_MATHUTIL Randomizer { PUBLISHED: INLINE Randomizer(unsigned long seed = 0); diff --git a/panda/src/mathutil/rotate_to.cxx b/panda/src/mathutil/rotate_to.cxx index ed1fe53337..87e4483c03 100644 --- a/panda/src/mathutil/rotate_to.cxx +++ b/panda/src/mathutil/rotate_to.cxx @@ -1,16 +1,15 @@ -// Filename: rotate_to.cxx -// Created by: drose (04Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rotate_to.cxx + * @author drose + * @date 1999-11-04 + */ #include "pandabase.h" #include diff --git a/panda/src/mathutil/rotate_to.h b/panda/src/mathutil/rotate_to.h index eeecfe791b..afa3f0d737 100644 --- a/panda/src/mathutil/rotate_to.h +++ b/panda/src/mathutil/rotate_to.h @@ -1,30 +1,24 @@ -// Filename: rotate_to.h -// Created by: drose (04Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rotate_to.h + * @author drose + * @date 1999-11-04 + */ #ifndef ROTATE_TO_H #define ROTATE_TO_H -//////////////////////////////////////////////////////////////////// -// -// rotate_to() -// -// This function computes a suitable rotation matrix to rotate vector -// a onto vector b. That is, it computes mat so that a * mat = b. -// The rotation axis is chosen to give the smallest possible rotation -// angle. -// -//////////////////////////////////////////////////////////////////// +/* + * rotate_to() This function computes a suitable rotation matrix to rotate + * vector a onto vector b. That is, it computes mat so that a * mat = b. The + * rotation axis is chosen to give the smallest possible rotation angle. + */ #include #include "pandabase.h" diff --git a/panda/src/mathutil/rotate_to_src.cxx b/panda/src/mathutil/rotate_to_src.cxx index ed0a3e7457..699ec77029 100644 --- a/panda/src/mathutil/rotate_to_src.cxx +++ b/panda/src/mathutil/rotate_to_src.cxx @@ -1,23 +1,20 @@ -// Filename: rotate_to_src.cxx -// Created by: drose (04Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rotate_to_src.cxx + * @author drose + * @date 1999-11-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: _rotate_to -// Description: Computes the matrix necessary to rotate vector a onto -// vector b. It is assumed that both vectors are -// normalized. -//////////////////////////////////////////////////////////////////// +/** + * Computes the matrix necessary to rotate vector a onto vector b. It is + * assumed that both vectors are normalized. + */ static void _rotate_to(FLOATNAME(LMatrix3) &mat, const FLOATNAME(LVector3) &a, const FLOATNAME(LVector3) &b) { @@ -31,8 +28,8 @@ _rotate_to(FLOATNAME(LMatrix3) &mat, // The vectors are collinear. if (cos_theta < 0.0f) { - // The vectors are opposite; choose an arbitrary axis - // perpendicular to a. + // The vectors are opposite; choose an arbitrary axis perpendicular to + // a. FLOATNAME(LVector3) absa(fabs(a[0]), fabs(a[1]), fabs(a[2])); FLOATNAME(LVector3) lca(0., 0., 0.); lca[absa[0]<=absa[1] ? absa[0]<=absa[2] ? 0 : 2 @@ -80,4 +77,3 @@ rotate_to(FLOATNAME(LMatrix4) &mat, const FLOATNAME(LVector3) &a, const FLOATNAM _rotate_to(m3, a, b); mat = FLOATNAME(LMatrix4)(m3); } - diff --git a/panda/src/mathutil/stackedPerlinNoise2.I b/panda/src/mathutil/stackedPerlinNoise2.I index 5daf2aa30c..31da0c29fd 100644 --- a/panda/src/mathutil/stackedPerlinNoise2.I +++ b/panda/src/mathutil/stackedPerlinNoise2.I @@ -1,74 +1,59 @@ -// Filename: stackedPerlinNoise2.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise2.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::Default Constructor -// Access: Published -// Description: Creates a StackedPerlinNoise2 object with no levels. -// You should call add_level() to add each level by -// hand. -//////////////////////////////////////////////////////////////////// +/** + * Creates a StackedPerlinNoise2 object with no levels. You should call + * add_level() to add each level by hand. + */ INLINE StackedPerlinNoise2:: StackedPerlinNoise2() { } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise2:: noise(double x, double y) { return noise(LVecBase2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float StackedPerlinNoise2:: noise(const LVecBase2f &value) { return (float)noise(value[0], value[1]); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::operator () -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise2:: operator ()(double x, double y) { return noise(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float StackedPerlinNoise2:: operator ()(const LVecBase2f &value) { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise2:: operator ()(const LVecBase2d &value) { return noise(value); diff --git a/panda/src/mathutil/stackedPerlinNoise2.cxx b/panda/src/mathutil/stackedPerlinNoise2.cxx index b391dcdb53..156a848306 100644 --- a/panda/src/mathutil/stackedPerlinNoise2.cxx +++ b/panda/src/mathutil/stackedPerlinNoise2.cxx @@ -1,29 +1,24 @@ -// Filename: stackedPerlinNoise2.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise2.cxx + * @author drose + * @date 2005-10-05 + */ #include "stackedPerlinNoise2.h" -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::Constructor -// Access: Published -// Description: Creates num_levels nested PerlinNoise2 objects. Each -// stacked Perlin object will have a scale of 1 / -// scale_factor times the previous object (so that it is -// higher-frequency, if scale_factor > 1), and an -// amplitude of amp_scale times the previous object (so -// that it is less important, if amp_scale < 1). -//////////////////////////////////////////////////////////////////// +/** + * Creates num_levels nested PerlinNoise2 objects. Each stacked Perlin object + * will have a scale of 1 scale_factor times the previous object (so that it + * is higher-frequency, if scale_factor > 1), and an amplitude of amp_scale + * times the previous object (so that it is less important, if amp_scale < 1). + */ StackedPerlinNoise2:: StackedPerlinNoise2(double sx, double sy, int num_levels, double scale_factor, double amp_scale, @@ -41,37 +36,29 @@ StackedPerlinNoise2(double sx, double sy, int num_levels, } } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::Copy Constructor -// Access: Published -// Description: Creates an exact duplicate of the existing -// StackedPerlinNoise2 object, including the random -// seed. -//////////////////////////////////////////////////////////////////// +/** + * Creates an exact duplicate of the existing StackedPerlinNoise2 object, + * including the random seed. + */ StackedPerlinNoise2:: StackedPerlinNoise2(const StackedPerlinNoise2 ©) : _noises(copy._noises) { } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::Copy Assignment Operator -// Access: Published -// Description: Creates an exact duplicate of the existing -// StackedPerlinNoise2 object, including the random -// seed. -//////////////////////////////////////////////////////////////////// +/** + * Creates an exact duplicate of the existing StackedPerlinNoise2 object, + * including the random seed. + */ void StackedPerlinNoise2:: operator = (const StackedPerlinNoise2 ©) { _noises = copy._noises; } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::add_level -// Access: Published -// Description: Adds an arbitrary PerlinNoise2 object, and an -// associated amplitude, to the stack. -//////////////////////////////////////////////////////////////////// +/** + * Adds an arbitrary PerlinNoise2 object, and an associated amplitude, to the + * stack. + */ void StackedPerlinNoise2:: add_level(const PerlinNoise2 &level, double amp) { _noises.push_back(Noise()); @@ -80,22 +67,18 @@ add_level(const PerlinNoise2 &level, double amp) { n._amp = amp; } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::clear -// Access: Published -// Description: Removes all levels from the stack. You must call -// add_level() again to restore them. -//////////////////////////////////////////////////////////////////// +/** + * Removes all levels from the stack. You must call add_level() again to + * restore them. + */ void StackedPerlinNoise2:: clear() { _noises.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise2::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ double StackedPerlinNoise2:: noise(const LVecBase2d &value) { double result = 0.0; diff --git a/panda/src/mathutil/stackedPerlinNoise2.h b/panda/src/mathutil/stackedPerlinNoise2.h index fcbf2c1e49..e292e21fe6 100644 --- a/panda/src/mathutil/stackedPerlinNoise2.h +++ b/panda/src/mathutil/stackedPerlinNoise2.h @@ -1,16 +1,15 @@ -// Filename: stackedPerlinNoise2.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise2.h + * @author drose + * @date 2005-10-05 + */ #ifndef STACKEDPERLINNOISE2_H #define STACKEDPERLINNOISE2_H @@ -19,12 +18,10 @@ #include "perlinNoise2.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : StackedPerlinNoise2 -// Description : Implements a multi-layer PerlinNoise, with one or -// more high-frequency noise functions added to a -// lower-frequency base noise function. -//////////////////////////////////////////////////////////////////// +/** + * Implements a multi-layer PerlinNoise, with one or more high-frequency noise + * functions added to a lower-frequency base noise function. + */ class EXPCL_PANDA_MATHUTIL StackedPerlinNoise2 { PUBLISHED: INLINE StackedPerlinNoise2(); @@ -59,4 +56,3 @@ private: #include "stackedPerlinNoise2.I" #endif - diff --git a/panda/src/mathutil/stackedPerlinNoise3.I b/panda/src/mathutil/stackedPerlinNoise3.I index 1f730e5804..62c7e08c81 100644 --- a/panda/src/mathutil/stackedPerlinNoise3.I +++ b/panda/src/mathutil/stackedPerlinNoise3.I @@ -1,74 +1,59 @@ -// Filename: stackedPerlinNoise3.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise3.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::Default Constructor -// Access: Published -// Description: Creates a StackedPerlinNoise3 object with no levels. -// You should call add_level() to add each level by -// hand. -//////////////////////////////////////////////////////////////////// +/** + * Creates a StackedPerlinNoise3 object with no levels. You should call + * add_level() to add each level by hand. + */ INLINE StackedPerlinNoise3:: StackedPerlinNoise3() { } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise3:: noise(double x, double y, double z) { return noise(LVecBase3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float StackedPerlinNoise3:: noise(const LVecBase3f &value) { return (float)noise(value[0], value[1], value[2]); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::operator () -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise3:: operator ()(double x, double y, double z) { return noise(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE float StackedPerlinNoise3:: operator ()(const LVecBase3f &value) { return noise(value); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ INLINE double StackedPerlinNoise3:: operator ()(const LVecBase3d &value) { return noise(value); diff --git a/panda/src/mathutil/stackedPerlinNoise3.cxx b/panda/src/mathutil/stackedPerlinNoise3.cxx index e0137d77d9..19917c265e 100644 --- a/panda/src/mathutil/stackedPerlinNoise3.cxx +++ b/panda/src/mathutil/stackedPerlinNoise3.cxx @@ -1,29 +1,24 @@ -// Filename: stackedPerlinNoise3.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise3.cxx + * @author drose + * @date 2005-10-05 + */ #include "stackedPerlinNoise3.h" -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::Constructor -// Access: Published -// Description: Creates num_levels nested PerlinNoise3 objects. Each -// stacked Perlin object will have a scale of 1 / -// scale_factor times the previous object (so that it is -// higher-frequency, if scale_factor > 1), and an -// amplitude of amp_scale times the previous object (so -// that it is less important, if amp_scale < 1). -//////////////////////////////////////////////////////////////////// +/** + * Creates num_levels nested PerlinNoise3 objects. Each stacked Perlin object + * will have a scale of 1 scale_factor times the previous object (so that it + * is higher-frequency, if scale_factor > 1), and an amplitude of amp_scale + * times the previous object (so that it is less important, if amp_scale < 1). + */ StackedPerlinNoise3:: StackedPerlinNoise3(double sx, double sy, double sz, int num_levels, double scale_factor, double amp_scale, @@ -42,37 +37,29 @@ StackedPerlinNoise3(double sx, double sy, double sz, int num_levels, } } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::Copy Constructor -// Access: Published -// Description: Creates an exact duplicate of the existing -// StackedPerlinNoise3 object, including the random -// seed. -//////////////////////////////////////////////////////////////////// +/** + * Creates an exact duplicate of the existing StackedPerlinNoise3 object, + * including the random seed. + */ StackedPerlinNoise3:: StackedPerlinNoise3(const StackedPerlinNoise3 ©) : _noises(copy._noises) { } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::Copy Assignment Operator -// Access: Published -// Description: Creates an exact duplicate of the existing -// StackedPerlinNoise3 object, including the random -// seed. -//////////////////////////////////////////////////////////////////// +/** + * Creates an exact duplicate of the existing StackedPerlinNoise3 object, + * including the random seed. + */ void StackedPerlinNoise3:: operator = (const StackedPerlinNoise3 ©) { _noises = copy._noises; } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::add_level -// Access: Published -// Description: Adds an arbitrary PerlinNoise3 object, and an -// associated amplitude, to the stack. -//////////////////////////////////////////////////////////////////// +/** + * Adds an arbitrary PerlinNoise3 object, and an associated amplitude, to the + * stack. + */ void StackedPerlinNoise3:: add_level(const PerlinNoise3 &level, double amp) { _noises.push_back(Noise()); @@ -81,22 +68,18 @@ add_level(const PerlinNoise3 &level, double amp) { n._amp = amp; } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::clear -// Access: Published -// Description: Removes all levels from the stack. You must call -// add_level() again to restore them. -//////////////////////////////////////////////////////////////////// +/** + * Removes all levels from the stack. You must call add_level() again to + * restore them. + */ void StackedPerlinNoise3:: clear() { _noises.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: StackedPerlinNoise3::noise -// Access: Published -// Description: Returns the noise function of the three inputs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise function of the three inputs. + */ double StackedPerlinNoise3:: noise(const LVecBase3d &value) { double result = 0.0; diff --git a/panda/src/mathutil/stackedPerlinNoise3.h b/panda/src/mathutil/stackedPerlinNoise3.h index e5c54e86db..eb3b0da1e0 100644 --- a/panda/src/mathutil/stackedPerlinNoise3.h +++ b/panda/src/mathutil/stackedPerlinNoise3.h @@ -1,16 +1,15 @@ -// Filename: stackedPerlinNoise3.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stackedPerlinNoise3.h + * @author drose + * @date 2005-10-05 + */ #ifndef STACKEDPERLINNOISE3_H #define STACKEDPERLINNOISE3_H @@ -19,12 +18,10 @@ #include "perlinNoise3.h" #include "epvector.h" -//////////////////////////////////////////////////////////////////// -// Class : StackedPerlinNoise3 -// Description : Implements a multi-layer PerlinNoise, with one or -// more high-frequency noise functions added to a -// lower-frequency base noise function. -//////////////////////////////////////////////////////////////////// +/** + * Implements a multi-layer PerlinNoise, with one or more high-frequency noise + * functions added to a lower-frequency base noise function. + */ class EXPCL_PANDA_MATHUTIL StackedPerlinNoise3 { PUBLISHED: INLINE StackedPerlinNoise3(); @@ -59,4 +56,3 @@ private: #include "stackedPerlinNoise3.I" #endif - diff --git a/panda/src/mathutil/test_mathutil.cxx b/panda/src/mathutil/test_mathutil.cxx index 86c3ed92fa..9962bb8e1d 100644 --- a/panda/src/mathutil/test_mathutil.cxx +++ b/panda/src/mathutil/test_mathutil.cxx @@ -1,16 +1,15 @@ -// Filename: test_mathutil.cxx -// Created by: drose (16Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_mathutil.cxx + * @author drose + * @date 2000-03-16 + */ #include "luse.h" #include "rotate_to.h" diff --git a/panda/src/mathutil/test_tri.cxx b/panda/src/mathutil/test_tri.cxx index 958bd4f039..57852b3773 100644 --- a/panda/src/mathutil/test_tri.cxx +++ b/panda/src/mathutil/test_tri.cxx @@ -1,16 +1,15 @@ -// Filename: test_tri.cxx -// Created by: drose (19Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_tri.cxx + * @author drose + * @date 2007-01-19 + */ #include "pandabase.h" @@ -39,11 +38,11 @@ int main(int argc, char *argv[]) { t.add_hole_vertex(6); t.add_hole_vertex(5); t.add_hole_vertex(4); - + t.triangulate(); for (int i = 0; i < t.get_num_triangles(); ++i) { - cerr << "tri: " << t.get_triangle_v0(i) << " " + cerr << "tri: " << t.get_triangle_v0(i) << " " << t.get_triangle_v1(i) << " " << t.get_triangle_v2(i) << "\n"; } diff --git a/panda/src/mathutil/triangulator.I b/panda/src/mathutil/triangulator.I index 21cd1de49a..95d18e934c 100644 --- a/panda/src/mathutil/triangulator.I +++ b/panda/src/mathutil/triangulator.I @@ -1,93 +1,74 @@ -// Filename: triangulator.I -// Created by: drose (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator.I + * @author drose + * @date 2007-01-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::add_vertex -// Access: Published -// Description: Adds a new vertex to the vertex pool. Returns the -// vertex index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the vertex pool. Returns the vertex index number. + */ INLINE int Triangulator:: add_vertex(double x, double y) { return add_vertex(LPoint2d(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_num_vertices -// Access: Published -// Description: Returns the number of vertices in the pool. Note -// that the Triangulator might append new vertices, in -// addition to those added by the user, if any of the -// polygon is self-intersecting, or if any of the holes -// intersect some part of the polygon edges. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the pool. Note that the Triangulator + * might append new vertices, in addition to those added by the user, if any + * of the polygon is self-intersecting, or if any of the holes intersect some + * part of the polygon edges. + */ INLINE int Triangulator:: get_num_vertices() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_vertex -// Access: Published -// Description: Returns the nth vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex. + */ INLINE const LPoint2d &Triangulator:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices.size(), LPoint2d::zero()); return _vertices[n]; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::is_left_winding -// Access: Published -// Description: Returns true if the polygon vertices are listed in -// counterclockwise order, or false if they appear to be -// listed in clockwise order. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the polygon vertices are listed in counterclockwise order, + * or false if they appear to be listed in clockwise order. + */ INLINE bool Triangulator:: is_left_winding() const { return check_left_winding(_polygon); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::Triangle::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Triangulator::Triangle:: Triangle(Triangulator *t, int v0, int v1, int v2) : - _v0(t->vert[v0].user_i), + _v0(t->vert[v0].user_i), _v1(t->vert[v1].user_i), _v2(t->vert[v2].user_i) { } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::segment_t::Default Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Triangulator::segment_t:: segment_t() { } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::segment_t::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Triangulator::segment_t:: segment_t(Triangulator *t, int v0_i, int v1_i, int prev, int next) : is_inserted(false), diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index 74fb752708..a0c1ad9ad5 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/panda/src/mathutil/triangulator.cxx @@ -1,47 +1,39 @@ -// Filename: triangulator.cxx -// Created by: drose (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator.cxx + * @author drose + * @date 2007-01-18 + */ #include "triangulator.h" #include "randomizer.h" -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Triangulator:: Triangulator() { } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::clear -// Access: Published -// Description: Removes all vertices and polygon specifications from -// the Triangulator, and prepares it to start over. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices and polygon specifications from the Triangulator, and + * prepares it to start over. + */ void Triangulator:: clear() { _vertices.clear(); clear_polygon(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::add_vertex -// Access: Published -// Description: Adds a new vertex to the vertex pool. Returns the -// vertex index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the vertex pool. Returns the vertex index number. + */ int Triangulator:: add_vertex(const LPoint2d &point) { int index = (int)_vertices.size(); @@ -49,71 +41,55 @@ add_vertex(const LPoint2d &point) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::clear_polygon -// Access: Published -// Description: Removes the current polygon definition (and its set -// of holes), but does not clear the vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the current polygon definition (and its set of holes), but does not + * clear the vertex pool. + */ void Triangulator:: clear_polygon() { _polygon.clear(); _holes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::add_polygon_vertex -// Access: Published -// Description: Adds the next consecutive vertex of the polygon. -// This vertex should index into the vertex pool -// established by repeated calls to add_vertex(). -// -// The vertices may be listed in either clockwise or -// counterclockwise order. Vertices should not be -// repeated. In particular, do not repeat the first -// vertex at the end. -//////////////////////////////////////////////////////////////////// +/** + * Adds the next consecutive vertex of the polygon. This vertex should index + * into the vertex pool established by repeated calls to add_vertex(). + * + * The vertices may be listed in either clockwise or counterclockwise order. + * Vertices should not be repeated. In particular, do not repeat the first + * vertex at the end. + */ void Triangulator:: add_polygon_vertex(int index) { _polygon.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::begin_hole -// Access: Published -// Description: Finishes the previous hole, if any, and prepares to -// add a new hole. -//////////////////////////////////////////////////////////////////// +/** + * Finishes the previous hole, if any, and prepares to add a new hole. + */ void Triangulator:: begin_hole() { _holes.push_back(vector_int()); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::add_hole_vertex -// Access: Published -// Description: Adds the next consecutive vertex of the current hole. -// This vertex should index into the vertex pool -// established by repeated calls to add_vertex(). -// -// The vertices may be listed in either clockwise or -// counterclockwise order. Vertices should not be -// repeated. -//////////////////////////////////////////////////////////////////// +/** + * Adds the next consecutive vertex of the current hole. This vertex should + * index into the vertex pool established by repeated calls to add_vertex(). + * + * The vertices may be listed in either clockwise or counterclockwise order. + * Vertices should not be repeated. + */ void Triangulator:: add_hole_vertex(int index) { nassertv(!_holes.empty()); _holes.back().push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::triangulate -// Access: Published -// Description: Does the work of triangulating the specified polygon. -// After this call, you may retrieve the new triangles -// one at a time by iterating through -// get_triangle_v0/1/2(). -//////////////////////////////////////////////////////////////////// +/** + * Does the work of triangulating the specified polygon. After this call, you + * may retrieve the new triangles one at a time by iterating through + * get_triangle_v0/1/2(). + */ void Triangulator:: triangulate() { _result.clear(); @@ -149,9 +125,9 @@ triangulate() { permute.push_back(i + 1); } - // Actually, I'm not sure why we should shuffle the index. That - // makes the result non-deterministic, and isn't one order--for - // instance, the initial order--as good as any other? + // Actually, I'm not sure why we should shuffle the index. That makes the + // result non-deterministic, and isn't one order--for instance, the initial + // order--as good as any other? /* Randomizer randomizer; for (i = 0; i < num_segments; ++i) { @@ -165,7 +141,7 @@ triangulate() { choose_idx = 0; /* - //cerr << "got " << num_segments << " segments\n"; + // cerr << "got " << num_segments << " segments\n"; for (i = 1; i < (int)seg.size(); ++i) { segment_t &s = seg[i]; printf(" %d. (%g %g), (%g %g)\n", i, s.v0.x, s.v0.y, s.v1.x, s.v1.y); @@ -187,7 +163,7 @@ triangulate() { choose_idx = 0; /* - //cerr << "got " << num_segments << " segments\n"; + // cerr << "got " << num_segments << " segments\n"; for (i = 1; i < (int)seg.size(); ++i) { segment_t &s = seg[i]; printf(" %d. (%g %g), (%g %g)\n", i, s.v0.x, s.v0.y, s.v1.x, s.v1.y); @@ -198,90 +174,81 @@ triangulate() { } /* - //cerr << "got " << tr.size() - 1 << " trapezoids\n"; + // cerr << "got " << tr.size() - 1 << " trapezoids\n"; for (i = 1; i < (int)tr.size(); ++i) { trap_t &t = tr[i]; - //cerr << " " << i << ". state = " << t.state << "\n"; - //cerr << " lseg = " << t.lseg << " rseg = " << t.rseg << "\n"; - //cerr << " hi = " << t.hi.x << " " << t.hi.y << " lo = " << t.lo.x << " " << t.lo.y << "\n"; + // cerr << " " << i << ". state = " << t.state << "\n"; cerr << " lseg + // = " << t.lseg << " rseg = " << t.rseg << "\n"; cerr << " hi = " << + // t.hi.x << " " << t.hi.y << " lo = " << t.lo.x << " " << t.lo.y << "\n"; } */ int nmonpoly = monotonate_trapezoids(num_segments); - //cerr << "got " << nmonpoly << " monotone polygons\n"; + // cerr << "got " << nmonpoly << " monotone polygons\n"; triangulate_monotone_polygons(num_segments, nmonpoly); /* Result::iterator ri; for (ri = _result.begin(); ri != _result.end(); ++ri) { - //cerr << "tri: " << (*ri)._v0 << " " << (*ri)._v1 << " " << (*ri)._v2 << "\n"; + // cerr << "tri: " << (*ri)._v0 << " " << (*ri)._v1 << " " << (*ri)._v2 << + // "\n"; } */ } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_num_triangles -// Access: Published -// Description: Returns the number of triangles generated by the -// previous call to triangulate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of triangles generated by the previous call to + * triangulate(). + */ int Triangulator:: get_num_triangles() const { return _result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_triangle_v0 -// Access: Published -// Description: Returns vertex 0 of the nth triangle generated by the -// previous call to triangulate(). -// -// This is a zero-based index into the vertices added by -// repeated calls to add_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Returns vertex 0 of the nth triangle generated by the previous call to + * triangulate(). + * + * This is a zero-based index into the vertices added by repeated calls to + * add_vertex(). + */ int Triangulator:: get_triangle_v0(int n) const { nassertr(n >= 0 && n < (int)_result.size(), -1); return _result[n]._v0; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_triangle_v1 -// Access: Published -// Description: Returns vertex 1 of the nth triangle generated by the -// previous call to triangulate(). -// -// This is a zero-based index into the vertices added by -// repeated calls to add_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Returns vertex 1 of the nth triangle generated by the previous call to + * triangulate(). + * + * This is a zero-based index into the vertices added by repeated calls to + * add_vertex(). + */ int Triangulator:: get_triangle_v1(int n) const { nassertr(n >= 0 && n < (int)_result.size(), -1); return _result[n]._v1; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::get_triangle_v2 -// Access: Published -// Description: Returns vertex 2 of the nth triangle generated by the -// previous call to triangulate(). -// -// This is a zero-based index into the vertices added by -// repeated calls to add_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Returns vertex 2 of the nth triangle generated by the previous call to + * triangulate(). + * + * This is a zero-based index into the vertices added by repeated calls to + * add_vertex(). + */ int Triangulator:: get_triangle_v2(int n) const { nassertr(n >= 0 && n < (int)_result.size(), -1); return _result[n]._v2; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::cleanup_polygon_indices -// Access: Protected -// Description: Removes any invalid index numbers from the list. -//////////////////////////////////////////////////////////////////// +/** + * Removes any invalid index numbers from the list. + */ void Triangulator:: cleanup_polygon_indices(vector_int &polygon) { // First, check for index bounds. @@ -315,15 +282,15 @@ cleanup_polygon_indices(vector_int &polygon) { } -// The remainder of the code in this file is adapted more or less from -// the C code published with the referenced paper. +// The remainder of the code in this file is adapted more or less from the C +// code published with the referenced paper. #define T_X 1 #define T_Y 2 #define T_SINK 3 -#define FIRSTPT 1 /* checking whether pt. is inserted */ +#define FIRSTPT 1 /* checking whether pt. is inserted */ #define LASTPT 2 @@ -371,16 +338,14 @@ cleanup_polygon_indices(vector_int &polygon) { #define LENGTH(v0) (sqrt((v0).x * (v0).x + (v0).y * (v0).y)) -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::check_left_winding -// Access: Private -// Description: Returns true if the list of vertices is -// counter-clockwise, false if it is clockwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the list of vertices is counter-clockwise, false if it is + * clockwise. + */ bool Triangulator:: check_left_winding(const vector_int &range) const { - // We do this by computing the polygon's signed area. If it comes - // out negative, the polygon is right-winding. + // We do this by computing the polygon's signed area. If it comes out + // negative, the polygon is right-winding. double area = 0.0; size_t j = range.size() - 1; @@ -394,14 +359,11 @@ check_left_winding(const vector_int &range) const { return area >= 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator::make_segment -// Access: Private -// Description: Converts a linear list of integer vertices to a list -// of segment_t. If want_left_winding is true, the list -// is reversed if necessary to make it left-winding; -// otherwise, it is reversed to make it right-winding. -//////////////////////////////////////////////////////////////////// +/** + * Converts a linear list of integer vertices to a list of segment_t. If + * want_left_winding is true, the list is reversed if necessary to make it + * left-winding; otherwise, it is reversed to make it right-winding. + */ void Triangulator:: make_segment(const vector_int &range, bool want_left_winding) { int num_points = (int)range.size(); @@ -414,15 +376,15 @@ make_segment(const vector_int &range, bool want_left_winding) { // Keep it in its natural order. int first = (int)seg.size(); int last = first + num_points - 1; - + seg.push_back(segment_t(this, range[0], range[1], last, first + 1)); - + for (int i = 1; i < num_points - 1; ++i) { seg.push_back(segment_t(this, range[i], range[i + 1], first + i - 1, first + i + 1)); } - + seg.push_back(segment_t(this, range[num_points - 1], range[0], last - 1, first)); @@ -430,25 +392,26 @@ make_segment(const vector_int &range, bool want_left_winding) { // Reverse it. seg.push_back(segment_t(this, range[0], range[num_points - 1], last, first + 1)); - + for (int i = 1; i < num_points - 1; ++i) { seg.push_back(segment_t(this, range[num_points - i], range[num_points - i - 1], first + i - 1, first + i + 1)); } - + seg.push_back(segment_t(this, range[1], range[0], last - 1, first)); } } - + /* Return the next segment in the generated random ordering of all the */ /* segments in S */ int Triangulator:: choose_segment() { nassertr(choose_idx < (int)permute.size(), 0); - // segment_t &s = seg[permute[choose_idx]]; - // cerr << "choose_segment " << permute[choose_idx] << ": " << s.v0.x << ", " << s.v0.y << " to " << s.v1.x << ", " << s.v1.y << "\n"; + // segment_t &s = seg[permute[choose_idx]]; cerr << "choose_segment " << + // permute[choose_idx] << ": " << s.v0.x << ", " << s.v0.y << " to " << + // s.v1.x << ", " << s.v1.y << "\n"; return permute[choose_idx++]; } @@ -463,13 +426,13 @@ int Triangulator:: math_logstar_n(int n) { int i; double v; - + for (i = 0, v = (double) n; v >= 1; i++) v = math_log2(v); - + return (i - 1); } - + int Triangulator:: math_N(int n, int h) { @@ -478,7 +441,7 @@ math_N(int n, int h) { for (i = 0, v = (int) n; i < h; i++) v = math_log2(v); - + return (int) ceil((double) 1.0*n/v); } @@ -487,7 +450,7 @@ math_N(int n, int h) { int Triangulator::newnode() { int index = (int)qs.size(); qs.push_back(node_t()); - // cerr << "creating new node " << index << "\n"; + // cerr << "creating new node " << index << "\n"; return index; } @@ -498,7 +461,7 @@ int Triangulator::newtrap() { tr[tr_idx].lseg = -1; tr[tr_idx].rseg = -1; tr[tr_idx].state = ST_VALID; - // cerr << "creating new trapezoid " << tr_idx << "\n"; + // cerr << "creating new trapezoid " << tr_idx << "\n"; return tr_idx; } @@ -516,7 +479,7 @@ int Triangulator::_max(point_t *yval, point_t *v0, point_t *v1) { } else *yval = *v1; - + return 0; } @@ -534,7 +497,7 @@ int Triangulator::_min(point_t *yval, point_t *v0, point_t *v1) { } else *yval = *v1; - + return 0; } @@ -576,10 +539,10 @@ _less_than(point_t *v0, point_t *v1) { } -/* Initilialise the query structure (Q) and the trapezoid table (T) +/* Initilialise the query structure (Q) and the trapezoid table (T) * when the first segment is added to start the trapezoidation. The * query-tree starts out with 4 trapezoids, one S-node and 2 Y-nodes - * + * * 4 * ----------------------------------- * \ @@ -618,18 +581,18 @@ init_query_structure(int segnum) { qs[i3].nodetype = T_Y; _min(&qs[i3].yval, &s->v0, &s->v1); /* root */ qs[i3].parent = i1; - + i4 = newnode(); qs[i3].left = i4; qs[i4].nodetype = T_SINK; qs[i4].parent = i3; - + i5 = newnode(); qs[i3].right = i5; qs[i5].nodetype = T_X; qs[i5].segnum = segnum; qs[i5].parent = i3; - + i6 = newnode(); qs[i5].left = i6; qs[i6].nodetype = T_SINK; @@ -665,7 +628,7 @@ init_query_structure(int segnum) { tr[t4].d0 = t1; tr[t3].u1 = t2; tr[t4].d1 = t2; - + tr[t1].sink = i6; tr[t2].sink = i7; tr[t3].sink = i4; @@ -695,7 +658,7 @@ int Triangulator:: is_left_of(int segnum, point_t *v) { segment_t *s = &seg[segnum]; double area; - + if (_greater_than(&s->v1, &s->v0)) /* seg. going upwards */ { if (FP_EQUAL(s->v1.y, v->y)) @@ -734,10 +697,10 @@ is_left_of(int segnum, point_t *v) { else area = CROSS(s->v1, s->v0, (*v)); } - + if (area > 0.0) return true; - else + else return false; } @@ -755,20 +718,21 @@ inserted(int segnum, int whichpt) { return seg[seg[segnum].next].is_inserted; } -/* This is query routine which determines which trapezoid does the - * point v lie in. The return value is the trapezoid number. +/* This is query routine which determines which trapezoid does the + * point v lie in. The return value is the trapezoid number. */ int Triangulator:: locate_endpoint(point_t *v, point_t *vo, int r) { - // cerr << "locate_endpoint(" << v->x << " " << v->y << ", " << vo->x << " " << vo->y << ", " << r << ")\n"; + // cerr << "locate_endpoint(" << v->x << " " << v->y << ", " << vo->x << " " + // << vo->y << ", " << r << ")\n"; node_t *rptr = &qs[r]; - + switch (rptr->nodetype) { case T_SINK: return rptr->trnum; - + case T_Y: if (_greater_than(v, &rptr->yval)) /* above */ return locate_endpoint(v, vo, rptr->right); @@ -776,14 +740,14 @@ locate_endpoint(point_t *v, point_t *vo, int r) { { /* inserted. */ if (_greater_than(vo, &rptr->yval)) /* above */ return locate_endpoint(v, vo, rptr->right); - else + else return locate_endpoint(v, vo, rptr->left); /* below */ } else return locate_endpoint(v, vo, rptr->left); /* below */ case T_X: - if (_equal_to(v, &seg[rptr->segnum].v0) || + if (_equal_to(v, &seg[rptr->segnum].v0) || _equal_to(v, &seg[rptr->segnum].v1)) { if (FP_EQUAL(v->y, vo->y)) /* horizontal segment */ @@ -812,7 +776,7 @@ locate_endpoint(point_t *v, point_t *vo, int r) { } -/* Thread in the segment into the existing trapezoidation. The +/* Thread in the segment into the existing trapezoidation. The * limiting trapezoids are given by tfirst and tlast (which are the * trapezoids containing the two endpoints of the segment. Merges all * possible trapezoids which flank this segment and have been recently @@ -824,7 +788,8 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) { int t, tnext, cond; int ptnext; - // cerr << "merge_trapezoids(" << segnum << ", " << tfirst << ", " << tlast << ", " << side << ")\n"; + // cerr << "merge_trapezoids(" << segnum << ", " << tfirst << ", " << tlast + // << ", " << side << ")\n"; /* First merge polys on the LHS */ t = tfirst; @@ -836,7 +801,7 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) { else cond = ((((tnext = tr[t].d0) > 0) && (tr[tnext].lseg == segnum)) || (((tnext = tr[t].d1) > 0) && (tr[tnext].lseg == segnum))); - + if (cond) { if ((tr[t].lseg == tr[tnext].lseg) && @@ -879,9 +844,9 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) { } else /* do not satisfy the outer if */ t = tnext; - + } /* end-while */ - + return 0; } @@ -894,10 +859,10 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) { int Triangulator:: add_segment(int segnum) { - //cerr << "add_segment(" << segnum << ")\n"; + // cerr << "add_segment(" << segnum << ")\n"; segment_t s; - // segment_t *so = &seg[segnum]; + // segment_t *so = &seg[segnum]; int tu, tl, sk, tfirst, tlast; //, tnext; int tfirstr = 0, tlastr = 0, tfirstl = 0, tlastl = 0; int i1, i2, t, tn; // t1, t2, @@ -931,7 +896,7 @@ add_segment(int segnum) { tr[tu].lo.y = s.v0.y; tr[tl].hi.x = s.v0.x; tr[tu].lo.x = s.v0.x; - tr[tu].d0 = tl; + tr[tu].d0 = tl; tr[tu].d1 = 0; tr[tl].u0 = tu; tr[tl].u1 = 0; @@ -947,12 +912,12 @@ add_segment(int segnum) { tr[tmp_d].u1 = tl; /* Now update the query structure and obtain the sinks for the */ - /* two trapezoids */ - + /* two trapezoids */ + i1 = newnode(); /* Upper trapezoid sink */ i2 = newnode(); /* Lower trapezoid sink */ sk = tr[tu].sink; - + qs[sk].nodetype = T_Y; qs[sk].yval = s.v0; qs[sk].segnum = segnum; /* not really reqd ... maybe later */ @@ -992,7 +957,7 @@ add_segment(int segnum) { tr[tu].lo.y = s.v1.y; tr[tl].hi.x = s.v1.x; tr[tu].lo.x = s.v1.x; - tr[tu].d0 = tl; + tr[tu].d0 = tl; tr[tu].d1 = 0; tr[tl].u0 = tu; tr[tl].u1 = 0; @@ -1006,14 +971,14 @@ add_segment(int segnum) { tr[tmp_d].u0 = tl; if (((tmp_d = tr[tl].d1) > 0) && (tr[tmp_d].u1 == tu)) tr[tmp_d].u1 = tl; - + /* Now update the query structure and obtain the sinks for the */ - /* two trapezoids */ - + /* two trapezoids */ + i1 = newnode(); /* Upper trapezoid sink */ i2 = newnode(); /* Lower trapezoid sink */ sk = tr[tu].sink; - + qs[sk].nodetype = T_Y; qs[sk].yval = s.v1; qs[sk].segnum = segnum; /* not really reqd ... maybe later */ @@ -1037,14 +1002,14 @@ add_segment(int segnum) { tlast = locate_endpoint(&s.v1, &s.v0, s.root1); tribot = 1; } - + /* Thread the segment into the query tree creating a new X-node */ /* First, split all the trapezoids which are intersected by s into */ /* two */ t = tfirst; /* topmost trapezoid */ - - while ((t > 0) && + + while ((t > 0) && _greater_than_equal_to(&tr[t].lo, &tr[tlast].lo)) /* traverse from top to bot */ { @@ -1052,7 +1017,7 @@ add_segment(int segnum) { sk = tr[t].sink; i1 = newnode(); /* left trapezoid sink */ i2 = newnode(); /* right trapezoid sink */ - + qs[sk].nodetype = T_X; qs[sk].segnum = segnum; qs[sk].left = i1; @@ -1087,11 +1052,11 @@ add_segment(int segnum) { fprintf(stderr, "add_segment: error\n"); return 1; } - + /* only one trapezoid below. partition t into two and make the */ /* two resulting trapezoids t and tn as the upper neighbours of */ /* the sole lower trapezoid */ - + else if ((tr[t].d0 > 0) && (tr[t].d1 <= 0)) { /* Only one trapezoid below */ if ((tr[t].u0 > 0) && (tr[t].u1 > 0)) @@ -1130,11 +1095,11 @@ add_segment(int segnum) { tr[tr[tn].u0].d0 = tn; } } - else + else { /* fresh seg. or upward cusp */ int tmp_u = tr[t].u0; int td0, td1; - if (((td0 = tr[tmp_u].d0) > 0) && + if (((td0 = tr[tmp_u].d0) > 0) && ((td1 = tr[tmp_u].d1) > 0)) { /* upward cusp */ if ((tr[td0].rseg > 0) && @@ -1146,7 +1111,7 @@ add_segment(int segnum) { tr[tr[tn].u0].d1 = tn; } else /* cusp going leftwards */ - { + { tr[t].u1 = -1; tr[tn].u1 = -1; tr[tn].u0 = -1; @@ -1160,7 +1125,7 @@ add_segment(int segnum) { } } - if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && + if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && FP_EQUAL(tr[t].lo.x, tr[tlast].lo.x) && tribot) { /* bottom forms a triangle */ @@ -1246,11 +1211,11 @@ add_segment(int segnum) { tr[tr[tn].u0].d0 = tn; } } - else + else { /* fresh seg. or upward cusp */ int tmp_u = tr[t].u0; int td0, td1; - if (((td0 = tr[tmp_u].d0) > 0) && + if (((td0 = tr[tmp_u].d0) > 0) && ((td1 = tr[tmp_u].d1) > 0)) { /* upward cusp */ if ((tr[td0].rseg > 0) && @@ -1261,7 +1226,7 @@ add_segment(int segnum) { tr[t].u0 = -1; tr[tr[tn].u0].d1 = tn; } - else + else { tr[t].u1 = -1; tr[tn].u1 = -1; @@ -1276,7 +1241,7 @@ add_segment(int segnum) { } } - if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && + if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && FP_EQUAL(tr[t].lo.x, tr[tlast].lo.x) && tribot) { /* bottom forms a triangle */ if (is_swapped) @@ -1323,10 +1288,10 @@ add_segment(int segnum) { /* two trapezoids below. Find out which one is intersected by */ /* this segment and proceed down that one */ - + else { - // int tmpseg = tr[tr[t].d0].rseg; + // int tmpseg = tr[tr[t].d0].rseg; double y0, yt; point_t tmppt; int tnext, i_d0, i_d1; @@ -1393,11 +1358,11 @@ add_segment(int segnum) { tr[tr[tn].u0].d0 = tn; } } - else + else { /* fresh seg. or upward cusp */ int tmp_u = tr[t].u0; int td0, td1; - if (((td0 = tr[tmp_u].d0) > 0) && + if (((td0 = tr[tmp_u].d0) > 0) && ((td1 = tr[tmp_u].d1) > 0)) { /* upward cusp */ if ((tr[td0].rseg > 0) && @@ -1408,7 +1373,7 @@ add_segment(int segnum) { tr[t].u0 = -1; tr[tr[tn].u0].d1 = tn; } - else + else { tr[t].u1 = -1; tr[tn].u1 = -1; @@ -1423,7 +1388,7 @@ add_segment(int segnum) { } } - if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && + if (FP_EQUAL(tr[t].lo.y, tr[tlast].lo.y) && FP_EQUAL(tr[t].lo.x, tr[tlast].lo.x) && tribot) { /* this case arises only at the lowest trapezoid.. i.e. @@ -1474,17 +1439,17 @@ add_segment(int segnum) { t = tnext; } - + tr[tn_sav].lseg = segnum; tr[t_sav].rseg = segnum; } /* end-while */ - + /* Now combine those trapezoids which share common segments. We can */ /* use the pointers to the parent to connect these together. This */ /* works only because all these new trapezoids have been formed */ /* due to splitting by the segment, and hence have only one parent */ - tfirstl = tfirst; + tfirstl = tfirst; tlastl = tlast; merge_trapezoids(segnum, tfirstl, tlastl, S_LEFT); merge_trapezoids(segnum, tfirstr, tlastr, S_RIGHT); @@ -1500,9 +1465,9 @@ add_segment(int segnum) { */ int Triangulator:: find_new_roots(int segnum) { - // cerr << "find_new_roots(" << segnum << ")\n"; + // cerr << "find_new_roots(" << segnum << ")\n"; segment_t *s = &seg[segnum]; - + if (s->is_inserted) return 0; @@ -1510,7 +1475,7 @@ find_new_roots(int segnum) { s->root0 = tr[s->root0].sink; s->root1 = locate_endpoint(&s->v1, &s->v0, s->root1); - s->root1 = tr[s->root1].sink; + s->root1 = tr[s->root1].sink; return 0; } @@ -1518,10 +1483,10 @@ find_new_roots(int segnum) { /* Main routine to perform trapezoidation */ int Triangulator:: construct_trapezoids(int nseg) { - //cerr << "construct_trapezoids(" << nseg << ")\n"; + // cerr << "construct_trapezoids(" << nseg << ")\n"; int i; int root, h; - + /* Add the first segment and get the query structure and trapezoid */ /* list initialised */ @@ -1531,7 +1496,7 @@ construct_trapezoids(int nseg) { seg[i].root1 = root; seg[i].root0 = root; } - + for (h = 1; h <= math_logstar_n(nseg); h++) { for (i = math_N(nseg, h -1) + 1; i <= math_N(nseg, h); i++) { @@ -1540,12 +1505,12 @@ construct_trapezoids(int nseg) { return 1; } } - + /* Find a new root for each of the segment endpoints */ for (i = 1; i <= nseg; i++) find_new_roots(i); } - + for (i = math_N(nseg, math_logstar_n(nseg)) + 1; i <= nseg; i++) add_segment(choose_segment()); @@ -1564,11 +1529,11 @@ inside_polygon(trap_t *t) { if ((t->lseg <= 0) || (t->rseg <= 0)) return 0; - - if (((t->u0 <= 0) && (t->u1 <= 0)) || + + if (((t->u0 <= 0) && (t->u1 <= 0)) || ((t->d0 <= 0) && (t->d1 <= 0))) /* triangle */ return (_greater_than(&seg[rseg].v1, &seg[rseg].v0)); - + return 0; } @@ -1578,7 +1543,7 @@ int Triangulator:: newmon() { int index = (int)mon.size(); mon.push_back(0); - // cerr << "newmon " << index << "\n"; + // cerr << "newmon " << index << "\n"; return index; } @@ -1588,7 +1553,7 @@ int Triangulator:: new_chain_element() { int index = (int)mchain.size(); mchain.push_back(monchain_t()); - // cerr << "new_chain_element " << index << "\n"; + // cerr << "new_chain_element " << index << "\n"; return index; } @@ -1596,7 +1561,7 @@ new_chain_element() { double Triangulator:: get_angle(point_t *vp0, point_t *vpnext, point_t *vp1) { point_t v0, v1; - + v0.x = vpnext->x - vp0->x; v0.y = vpnext->y - vp0->y; @@ -1611,7 +1576,7 @@ get_angle(point_t *vp0, point_t *vpnext, point_t *vp1) { /* (v0, v1) is the new diagonal to be added to the polygon. Find which */ -/* chain to use and return the positions of v0 and v1 in p and q */ +/* chain to use and return the positions of v0 and v1 in p and q */ int Triangulator:: get_vertex_positions(int v0, int v1, int *ip, int *iq) { vertexchain_t *vp0, *vp1; @@ -1621,17 +1586,17 @@ get_vertex_positions(int v0, int v1, int *ip, int *iq) { vp0 = &vert[v0]; vp1 = &vert[v1]; - + /* p is identified as follows. Scan from (v0, v1) rightwards till */ /* you hit the first segment starting from v0. That chain is the */ /* chain of our interest */ - + angle = -4.0; for (i = 0; i < 4; i++) { if (vp0->vnext[i] <= 0) continue; - if ((temp = get_angle(&vp0->pt, &(vert[vp0->vnext[i]].pt), + if ((temp = get_angle(&vp0->pt, &(vert[vp0->vnext[i]].pt), &vp1->pt)) > angle) { angle = temp; @@ -1647,8 +1612,8 @@ get_vertex_positions(int v0, int v1, int *ip, int *iq) { for (i = 0; i < 4; i++) { if (vp1->vnext[i] <= 0) - continue; - if ((temp = get_angle(&vp1->pt, &(vert[vp1->vnext[i]].pt), + continue; + if ((temp = get_angle(&vp1->pt, &(vert[vp1->vnext[i]].pt), &vp0->pt)) > angle) { angle = temp; @@ -1661,10 +1626,10 @@ get_vertex_positions(int v0, int v1, int *ip, int *iq) { return 0; } - -/* v0 and v1 are specified in anti-clockwise order with respect to - * the current monotone polygon mcur. Split the current polygon into - * two polygons using the diagonal (v0, v1) + +/* v0 and v1 are specified in anti-clockwise order with respect to + * the current monotone polygon mcur. Split the current polygon into + * two polygons using the diagonal (v0, v1) */ int Triangulator:: make_new_monotone_poly(int mcur, int v0, int v1) { @@ -1676,7 +1641,7 @@ make_new_monotone_poly(int mcur, int v0, int v1) { if (v0 <= 0 || v1 <= 0) { return -1; } - + vp0 = &vert[v0]; vp1 = &vert[v1]; @@ -1718,7 +1683,7 @@ make_new_monotone_poly(int mcur, int v0, int v1) { vp1->nextfree++; #ifdef DEBUG - fprintf(stderr, "make_poly: mcur = %d, (v0, v1) = (%d, %d)\n", + fprintf(stderr, "make_poly: mcur = %d, (v0, v1) = (%d, %d)\n", mcur, v0, v1); fprintf(stderr, "next posns = (p, q) = (%d, %d)\n", p, q); #endif @@ -1728,7 +1693,7 @@ make_new_monotone_poly(int mcur, int v0, int v1) { return mnew; } -/* Main routine to get monotone polygons from the trapezoidation of +/* Main routine to get monotone polygons from the trapezoidation of * the polygon. */ @@ -1746,7 +1711,7 @@ monotonate_trapezoids(int n) { mchain.insert(mchain.begin(), n + 1, monchain_t()); visited.insert(visited.begin(), tr.size(), 0); - + /* First locate a trapezoid which lies inside the polygon */ /* and which is triangular */ for (i = 1; i < (int)tr.size(); i++) @@ -1756,9 +1721,9 @@ monotonate_trapezoids(int n) { // No valid trapezoids. return 0; } - // printf("start = %d\n", i); + // printf("start = %d\n", i); tr_start = i; - + /* Initialise the mon data-structure and start spanning all the */ /* trapezoids within the polygon */ @@ -1799,13 +1764,13 @@ monotonate_trapezoids(int n) { /* chain */ #endif - + /* traverse the polygon */ if (tr[tr_start].u0 > 0) traverse_polygon(0, tr_start, tr[tr_start].u0, TR_FROM_UP); else if (tr[tr_start].d0 > 0) traverse_polygon(0, tr_start, tr[tr_start].d0, TR_FROM_DN); - + /* return the number of polygons created */ return newmon(); } @@ -1814,7 +1779,7 @@ monotonate_trapezoids(int n) { /* recursively visit all the trapezoids */ int Triangulator:: traverse_polygon(int mcur, int trnum, int from, int dir) { - // printf("traverse_polygon(%d, %d, %d, %d)\n", mcur, trnum, from, dir); + // printf("traverse_polygon(%d, %d, %d, %d)\n", mcur, trnum, from, dir); if (mcur < 0 || trnum <= 0) return 0; @@ -1823,16 +1788,17 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { return 0; trap_t *t = &tr[trnum]; - // int howsplit; + // int howsplit; int mnew; int v0, v1; //, v0next, v1next; int retval = 0; //, tmp; int do_switch = false; - // printf("visited size = %d, visited[trnum] = %d\n", visited.size(), visited[trnum]); + // printf("visited size = %d, visited[trnum] = %d\n", visited.size(), + // visited[trnum]); visited[trnum] = true; - + /* We have much more information available here. */ /* rseg: goes upwards */ /* lseg: goes downwards */ @@ -1872,7 +1838,7 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); } } - + else if ((t->d0 <= 0) && (t->d1 <= 0)) { if ((t->u0 > 0) && (t->u1 > 0)) /* upward opening triangle */ @@ -1902,8 +1868,8 @@ traverse_polygon(int mcur, int trnum, int from, int dir) { traverse_polygon(mcur, t->d1, trnum, TR_FROM_UP); } } - - else if ((t->u0 > 0) && (t->u1 > 0)) + + else if ((t->u0 > 0) && (t->u1 > 0)) { if ((t->d0 > 0) && (t->d1 > 0)) /* downward + upward cusps */ { @@ -2156,7 +2122,7 @@ triangulate_monotone_polygons(int nvert, int nmonpoly) { } else mchain[p].marked = true; - + if (_greater_than(&vert[v].pt, &ymax)) { ymax = vert[v].pt; @@ -2173,7 +2139,7 @@ triangulate_monotone_polygons(int nvert, int nmonpoly) { if (processed) /* Go to next polygon */ continue; - + if (vcount == 3) /* already a triangle */ { _result.push_back(Triangle(this, mchain[p].vnum, @@ -2194,7 +2160,7 @@ triangulate_monotone_polygons(int nvert, int nmonpoly) { } -/* A greedy corner-cutting algorithm to triangulate a y-monotone +/* A greedy corner-cutting algorithm to triangulate a y-monotone * polygon in O(n) time. * Joseph O-Rourke, Computational Geometry in C. */ @@ -2205,7 +2171,8 @@ triangulate_single_polygon(int nvert, int posmax, int side) { int ri; int endv, tmp, vpos; - //cerr << "triangulate_single_polygon(" << nvert << ", " << posmax << ", " << side << ")\n"; + // cerr << "triangulate_single_polygon(" << nvert << ", " << posmax << ", " + // << side << ")\n"; if (side == TRI_RHS) /* RHS segment is a single segment */ { @@ -2213,10 +2180,10 @@ triangulate_single_polygon(int nvert, int posmax, int side) { tmp = mchain[posmax].next; rc.push_back(mchain[tmp].vnum); ri = 1; - + vpos = mchain[tmp].next; v = mchain[vpos].vnum; - + if ((endv = mchain[mchain[posmax].prev].vnum) == 0) endv = nvert; } @@ -2233,10 +2200,11 @@ triangulate_single_polygon(int nvert, int posmax, int side) { endv = mchain[posmax].vnum; } - + while ((v != endv) || (ri > 1)) { - //cerr << " v = " << v << " ri = " << ri << " rc = " << rc.size() << " _result = " << _result.size() << "\n"; + // cerr << " v = " << v << " ri = " << ri << " rc = " << rc.size() << " + // _result = " << _result.size() << "\n"; if (v <= 0) { // Something went wrong. return; @@ -2272,10 +2240,8 @@ triangulate_single_polygon(int nvert, int posmax, int side) { v = mchain[vpos].vnum; } } /* end-while */ - + /* reached the bottom vertex. Add in the triangle formed */ - _result.push_back(Triangle(this, rc[ri - 1], rc[ri], v)); + _result.push_back(Triangle(this, rc[ri - 1], rc[ri], v)); ri--; } - - diff --git a/panda/src/mathutil/triangulator.h b/panda/src/mathutil/triangulator.h index 5b443a7f70..8008cef8eb 100644 --- a/panda/src/mathutil/triangulator.h +++ b/panda/src/mathutil/triangulator.h @@ -1,16 +1,15 @@ -// Filename: triangulator.h -// Created by: drose (17Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator.h + * @author drose + * @date 2007-01-17 + */ #ifndef TRIANGULATOR_H #define TRIANGULATOR_H @@ -19,21 +18,17 @@ #include "luse.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : Triangulator -// Description : This class can triangulate a convex or concave -// polygon, even one with holes. It is adapted from an -// algorithm published as: -// -// Narkhede A. and Manocha D., Fast polygon -// triangulation algorithm based on Seidel's Algorithm, -// UNC-CH, 1994. -// -// http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html -// -// It works strictly on 2-d points. See Triangulator3 -// for 3-d points. -//////////////////////////////////////////////////////////////////// +/** + * This class can triangulate a convex or concave polygon, even one with + * holes. It is adapted from an algorithm published as: + * + * Narkhede A. and Manocha D., Fast polygon triangulation algorithm based on + * Seidel's Algorithm, UNC-CH, 1994. + * + * http://www.cs.unc.edu/~dm/CODE/GEM/chapter.html + * + * It works strictly on 2-d points. See Triangulator3 for 3-d points. + */ class EXPCL_PANDA_MATHUTIL Triangulator { PUBLISHED: Triangulator(); @@ -80,11 +75,11 @@ protected: typedef pvector Result; Result _result; - + typedef struct { double x, y; } point_t, vector_t; - + struct segment_t { INLINE segment_t(); @@ -114,10 +109,10 @@ protected: int usave, uside; /* I forgot what this means */ int state; } trap_t; - - + + /* Node attributes for every node in the query structure */ - + typedef struct { int nodetype; /* Y-node or S-node */ int segnum; @@ -134,8 +129,8 @@ protected: int prev; /* describing the monotone */ int marked; /* polygon */ } monchain_t; - - + + typedef struct { point_t pt; int vnext[4]; /* next vertices for the 4 chains */ @@ -143,13 +138,13 @@ protected: int nextfree; int user_i; // index to user's vertex number } vertexchain_t; - - + + typedef pvector QueryStructure; QueryStructure qs; typedef pvector TrapezoidStructure; TrapezoidStructure tr; - + /* Table to hold all the monotone */ /* polygons . Each monotone polygon */ /* is a circularly linked list */ @@ -212,4 +207,3 @@ protected: #include "triangulator.I" #endif - diff --git a/panda/src/mathutil/triangulator3.I b/panda/src/mathutil/triangulator3.I index 30584906ac..3d8bec2b37 100644 --- a/panda/src/mathutil/triangulator3.I +++ b/panda/src/mathutil/triangulator3.I @@ -1,60 +1,48 @@ -// Filename: triangulator3.I -// Created by: drose (03Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator3.I + * @author drose + * @date 2013-01-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::add_vertex -// Access: Published -// Description: Adds a new vertex to the vertex pool. Returns the -// vertex index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the vertex pool. Returns the vertex index number. + */ INLINE int Triangulator3:: add_vertex(double x, double y, double z) { return add_vertex(LPoint3d(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::get_num_vertices -// Access: Published -// Description: Returns the number of vertices in the pool. Note -// that the Triangulator might append new vertices, in -// addition to those added by the user, if any of the -// polygon is self-intersecting, or if any of the holes -// intersect some part of the polygon edges. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the pool. Note that the Triangulator + * might append new vertices, in addition to those added by the user, if any + * of the polygon is self-intersecting, or if any of the holes intersect some + * part of the polygon edges. + */ INLINE int Triangulator3:: get_num_vertices() const { return _vertices3.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::get_vertex -// Access: Published -// Description: Returns the nth vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex. + */ INLINE const LPoint3d &Triangulator3:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices3.size(), LPoint3d::zero()); return _vertices3[n]; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::get_plane -// Access: Published -// Description: Returns the plane of the polygon. This is only -// available after calling triangulate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the plane of the polygon. This is only available after calling + * triangulate(). + */ INLINE const LPlaned &Triangulator3:: get_plane() const { return _plane; diff --git a/panda/src/mathutil/triangulator3.cxx b/panda/src/mathutil/triangulator3.cxx index 77747c673c..f34e59af0e 100644 --- a/panda/src/mathutil/triangulator3.cxx +++ b/panda/src/mathutil/triangulator3.cxx @@ -1,35 +1,30 @@ -// Filename: triangulator3.cxx -// Created by: drose (03Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator3.cxx + * @author drose + * @date 2013-01-03 + */ #include "triangulator3.h" #include "look_at.h" -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Triangulator3:: Triangulator3() { } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::clear -// Access: Published -// Description: Removes all vertices and polygon specifications from -// the Triangulator, and prepares it to start over. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices and polygon specifications from the Triangulator, and + * prepares it to start over. + */ void Triangulator3:: clear() { _vertices3.clear(); @@ -37,12 +32,9 @@ clear() { Triangulator::clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::add_vertex -// Access: Published -// Description: Adds a new vertex to the vertex pool. Returns the -// vertex index number. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the vertex pool. Returns the vertex index number. + */ int Triangulator3:: add_vertex(const LPoint3d &point) { int index = (int)_vertices3.size(); @@ -50,14 +42,11 @@ add_vertex(const LPoint3d &point) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: Triangulator3::triangulate -// Access: Published -// Description: Does the work of triangulating the specified polygon. -// After this call, you may retrieve the new triangles -// one at a time by iterating through -// get_triangle_v0/1/2(). -//////////////////////////////////////////////////////////////////// +/** + * Does the work of triangulating the specified polygon. After this call, you + * may retrieve the new triangles one at a time by iterating through + * get_triangle_v0/1/2(). + */ void Triangulator3:: triangulate() { _result.clear(); @@ -70,11 +59,10 @@ triangulate() { // First, determine the polygon normal. LNormald normal = LNormald::zero(); - // Project the polygon into each of the three major planes and - // calculate the area of each 2-d projection. This becomes the - // polygon normal. This works because the ratio between these - // different areas corresponds to the angle at which the polygon is - // tilted toward each plane. + // Project the polygon into each of the three major planes and calculate the + // area of each 2-d projection. This becomes the polygon normal. This + // works because the ratio between these different areas corresponds to the + // angle at which the polygon is tilted toward each plane. size_t num_verts = _polygon.size(); for (size_t i = 0; i < num_verts; i++) { int i0 = _polygon[i]; @@ -89,16 +77,15 @@ triangulate() { } if (!normal.normalize()) { - // The polygon is degenerate: it has zero area in each plane. In - // this case, the triangulation result produces no triangles - // anyway. + // The polygon is degenerate: it has zero area in each plane. In this + // case, the triangulation result produces no triangles anyway. return; } _plane = LPlaned(normal, _vertices3[0]); - // Now determine the matrix to project each of the vertices into - // this 2-d plane. + // Now determine the matrix to project each of the vertices into this 2-d + // plane. LMatrix4d mat; heads_up(mat, _vertices3[1] - _vertices3[2], normal, CS_zup_right); mat.set_row(3, _vertices3[0]); diff --git a/panda/src/mathutil/triangulator3.h b/panda/src/mathutil/triangulator3.h index cb7e060458..786b2f581a 100644 --- a/panda/src/mathutil/triangulator3.h +++ b/panda/src/mathutil/triangulator3.h @@ -1,16 +1,15 @@ -// Filename: triangulator3.h -// Created by: drose (03Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file triangulator3.h + * @author drose + * @date 2013-01-03 + */ #ifndef TRIANGULATOR3_H #define TRIANGULATOR3_H @@ -20,14 +19,12 @@ #include "plane.h" -//////////////////////////////////////////////////////////////////// -// Class : Triangulator3 -// Description : This is an extension of Triangulator to handle -// polygons with three-dimensional points. It assumes -// all of the points lie in a single plane, and -// internally projects the supplied points into 2-D for -// passing to the underlying Triangulator object. -//////////////////////////////////////////////////////////////////// +/** + * This is an extension of Triangulator to handle polygons with three- + * dimensional points. It assumes all of the points lie in a single plane, + * and internally projects the supplied points into 2-D for passing to the + * underlying Triangulator object. + */ class EXPCL_PANDA_MATHUTIL Triangulator3 : public Triangulator { PUBLISHED: Triangulator3(); diff --git a/panda/src/mathutil/unionBoundingVolume.I b/panda/src/mathutil/unionBoundingVolume.I index 634e1ed2a4..6212b1f2b8 100644 --- a/panda/src/mathutil/unionBoundingVolume.I +++ b/panda/src/mathutil/unionBoundingVolume.I @@ -1,42 +1,34 @@ -// Filename: unionBoundingVolume.I -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file unionBoundingVolume.I + * @author drose + * @date 2012-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::Constructor -// Access: Published -// Description: Constructs an empty union. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty union. + */ INLINE_MATHUTIL UnionBoundingVolume:: UnionBoundingVolume() { } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::get_num_components -// Access: Published -// Description: Returns the number of components in the union. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components in the union. + */ INLINE_MATHUTIL int UnionBoundingVolume:: get_num_components() const { return (int)_components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::get_component -// Access: Published -// Description: Returns the nth component in the union. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth component in the union. + */ INLINE_MATHUTIL const GeometricBoundingVolume *UnionBoundingVolume:: get_component(int n) const { nassertr(n >= 0 && n < (int)_components.size(), NULL); diff --git a/panda/src/mathutil/unionBoundingVolume.cxx b/panda/src/mathutil/unionBoundingVolume.cxx index acfe9e1807..dfc96f8e92 100644 --- a/panda/src/mathutil/unionBoundingVolume.cxx +++ b/panda/src/mathutil/unionBoundingVolume.cxx @@ -1,16 +1,15 @@ -// Filename: unionBoundingVolume.cxx -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file unionBoundingVolume.cxx + * @author drose + * @date 2012-02-08 + */ #include "unionBoundingVolume.h" #include "config_mathutil.h" @@ -19,11 +18,9 @@ TypeHandle UnionBoundingVolume::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UnionBoundingVolume:: UnionBoundingVolume(const UnionBoundingVolume ©) : GeometricBoundingVolume(copy), @@ -31,21 +28,17 @@ UnionBoundingVolume(const UnionBoundingVolume ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BoundingVolume *UnionBoundingVolume:: make_copy() const { return new UnionBoundingVolume(*this); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::get_approx_center -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3 UnionBoundingVolume:: get_approx_center() const { nassertr(!is_empty(), LPoint3::zero()); @@ -61,11 +54,9 @@ get_approx_center() const { return center / (PN_stdfloat)_components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::xform -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void UnionBoundingVolume:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -79,11 +70,9 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void UnionBoundingVolume:: output(ostream &out) const { if (is_empty()) { @@ -101,11 +90,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void UnionBoundingVolume:: write(ostream &out, int indent_level) const { if (is_empty()) { @@ -123,28 +110,22 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::clear_components -// Access: Published -// Description: Removes all components from the volume. -//////////////////////////////////////////////////////////////////// +/** + * Removes all components from the volume. + */ void UnionBoundingVolume:: clear_components() { _components.clear(); _flags = F_empty; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::add_component -// Access: Published -// Description: Adds a new component to the volume. This does not -// necessarily increase the total number of components -// by one, and you may or may not be able to find this -// component in the volume by a subsequent call to -// get_component(); certain optimizations may prevent -// the component from being added, or have other -// unexpected effects on the total set of components. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new component to the volume. This does not necessarily increase the + * total number of components by one, and you may or may not be able to find + * this component in the volume by a subsequent call to get_component(); + * certain optimizations may prevent the component from being added, or have + * other unexpected effects on the total set of components. + */ void UnionBoundingVolume:: add_component(const GeometricBoundingVolume *component) { if (component->is_infinite()) { @@ -162,15 +143,15 @@ add_component(const GeometricBoundingVolume *component) { int result = existing->contains(component); if ((result & IF_all) != 0) { - // This new component is entirely within an existing - // component; no need to do anything with it. + // This new component is entirely within an existing component; no + // need to do anything with it. return; } result = component->contains(existing); if ((result & IF_all) != 0) { - // The existing component is entirely within this one; no need - // to keep the existing one. + // The existing component is entirely within this one; no need to keep + // the existing one. --i; _components.erase(_components.begin() + i); } @@ -181,12 +162,10 @@ add_component(const GeometricBoundingVolume *component) { } } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::filter_intersection -// Access: Published -// Description: Removes from the union any components that have no -// intersection with the indicated volume. -//////////////////////////////////////////////////////////////////// +/** + * Removes from the union any components that have no intersection with the + * indicated volume. + */ void UnionBoundingVolume:: filter_intersection(const BoundingVolume *volume) { size_t i = 0; @@ -207,21 +186,17 @@ filter_intersection(const BoundingVolume *volume) { } } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::extend_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool UnionBoundingVolume:: extend_other(BoundingVolume *other) const { return other->extend_by_union(this); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::around_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool UnionBoundingVolume:: around_other(BoundingVolume *other, const BoundingVolume **first, @@ -229,32 +204,26 @@ around_other(BoundingVolume *other, return other->around_unions(first, last); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_other -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int UnionBoundingVolume:: contains_other(const BoundingVolume *other) const { return other->contains_union(this); } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::extend_by_geometric -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool UnionBoundingVolume:: extend_by_geometric(const GeometricBoundingVolume *volume) { add_component(volume); return true; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::around_geometric -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool UnionBoundingVolume:: around_geometric(const BoundingVolume **first, const BoundingVolume **last) { @@ -280,11 +249,9 @@ around_geometric(const BoundingVolume **first, return true; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_point -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int UnionBoundingVolume:: contains_point(const LPoint3 &point) const { nassertr(!point.is_nan(), IF_no_intersection); @@ -303,11 +270,9 @@ contains_point(const LPoint3 &point) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_lineseg -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int UnionBoundingVolume:: contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { nassertr(!a.is_nan() && !b.is_nan(), IF_no_intersection); @@ -326,13 +291,10 @@ contains_lineseg(const LPoint3 &a, const LPoint3 &b) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_sphere -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a sphere. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a sphere. + */ int UnionBoundingVolume:: contains_sphere(const BoundingSphere *sphere) const { int result = 0; @@ -349,13 +311,10 @@ contains_sphere(const BoundingSphere *sphere) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_box -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a box. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a box. + */ int UnionBoundingVolume:: contains_box(const BoundingBox *box) const { int result = 0; @@ -372,13 +331,10 @@ contains_box(const BoundingBox *box) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_hexahedron -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a hexahedron. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a hexahedron. + */ int UnionBoundingVolume:: contains_hexahedron(const BoundingHexahedron *hexahedron) const { int result = 0; @@ -395,13 +351,10 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_line -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a line. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a line. + */ int UnionBoundingVolume:: contains_line(const BoundingLine *line) const { int result = 0; @@ -418,13 +371,10 @@ contains_line(const BoundingLine *line) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_plane -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a plane. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a plane. + */ int UnionBoundingVolume:: contains_plane(const BoundingPlane *plane) const { int result = 0; @@ -441,13 +391,10 @@ contains_plane(const BoundingPlane *plane) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_union -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be a union object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be a union object. + */ int UnionBoundingVolume:: contains_union(const UnionBoundingVolume *unionv) const { int result = 0; @@ -464,13 +411,10 @@ contains_union(const UnionBoundingVolume *unionv) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_intersection -// Access: Protected, Virtual -// Description: Double-dispatch support: called by contains_other() -// when the type we're testing for intersection is known -// to be an intersection object. -//////////////////////////////////////////////////////////////////// +/** + * Double-dispatch support: called by contains_other() when the type we're + * testing for intersection is known to be an intersection object. + */ int UnionBoundingVolume:: contains_intersection(const IntersectionBoundingVolume *intersection) const { int result = 0; @@ -487,11 +431,9 @@ contains_intersection(const IntersectionBoundingVolume *intersection) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_finite -// Access: Protected, Virtual -// Description: Generic handler for a FiniteBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a FiniteBoundingVolume. + */ int UnionBoundingVolume:: contains_finite(const FiniteBoundingVolume *volume) const { int result = 0; @@ -508,11 +450,9 @@ contains_finite(const FiniteBoundingVolume *volume) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::contains_geometric -// Access: Protected, Virtual -// Description: Generic handler for a GeometricBoundingVolume. -//////////////////////////////////////////////////////////////////// +/** + * Generic handler for a GeometricBoundingVolume. + */ int UnionBoundingVolume:: contains_geometric(const GeometricBoundingVolume *volume) const { int result = 0; @@ -529,14 +469,11 @@ contains_geometric(const GeometricBoundingVolume *volume) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: UnionBoundingVolume::other_contains_union -// Access: Protected, Virtual -// Description: Generic reverse-direction comparison. Called by -// BoundingVolumes that do not implement -// contains_union() explicitly. This returns the test -// of whether the other volume contains this volume. -//////////////////////////////////////////////////////////////////// +/** + * Generic reverse-direction comparison. Called by BoundingVolumes that do + * not implement contains_union() explicitly. This returns the test of + * whether the other volume contains this volume. + */ int UnionBoundingVolume:: other_contains_union(const BoundingVolume *volume) const { int all_result = IF_possible | IF_some | IF_all; @@ -556,4 +493,3 @@ other_contains_union(const BoundingVolume *volume) const { some_result &= ~IF_all; return some_result | all_result; } - diff --git a/panda/src/mathutil/unionBoundingVolume.h b/panda/src/mathutil/unionBoundingVolume.h index e3996b1b73..dd4366abfb 100644 --- a/panda/src/mathutil/unionBoundingVolume.h +++ b/panda/src/mathutil/unionBoundingVolume.h @@ -1,16 +1,15 @@ -// Filename: unionBoundingVolume.h -// Created by: drose (08Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file unionBoundingVolume.h + * @author drose + * @date 2012-02-08 + */ #ifndef UNIONBOUNDINGVOLUME_H #define UNIONBOUNDINGVOLUME_H @@ -20,15 +19,13 @@ #include "geometricBoundingVolume.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : UnionBoundingVolume -// Description : This special bounding volume is the union of all of -// its constituent bounding volumes. -// -// A point is defined to be within a UnionBoundingVolume -// if it is within any one or more of its component -// bounding volumes. -//////////////////////////////////////////////////////////////////// +/** + * This special bounding volume is the union of all of its constituent + * bounding volumes. + * + * A point is defined to be within a UnionBoundingVolume if it is within any + * one or more of its component bounding volumes. + */ class EXPCL_PANDA_MATHUTIL UnionBoundingVolume : public GeometricBoundingVolume { PUBLISHED: INLINE_MATHUTIL UnionBoundingVolume(); diff --git a/panda/src/movies/config_movies.cxx b/panda/src/movies/config_movies.cxx index dc4202c6f2..db5d6be074 100644 --- a/panda/src/movies/config_movies.cxx +++ b/panda/src/movies/config_movies.cxx @@ -1,16 +1,15 @@ -// Filename: config_movies.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_movies.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "config_movies.h" #include "dconfig.h" @@ -62,14 +61,12 @@ ConfigVariableBool vorbis_seek_lap "the new playback position when seeking in order to eliminate " "clicking and boundary discontinuities.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libmovies -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmovies() { static bool initialized = false; diff --git a/panda/src/movies/config_movies.h b/panda/src/movies/config_movies.h index fa09bc6e8f..cbfd09a440 100644 --- a/panda/src/movies/config_movies.h +++ b/panda/src/movies/config_movies.h @@ -1,16 +1,15 @@ -// Filename: config_movies.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_movies.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef CONFIG_MOVIES_H #define CONFIG_MOVIES_H diff --git a/panda/src/movies/inkblotVideo.I b/panda/src/movies/inkblotVideo.I index 6fe6c3dc52..0296d0c18f 100644 --- a/panda/src/movies/inkblotVideo.I +++ b/panda/src/movies/inkblotVideo.I @@ -1,14 +1,12 @@ -// Filename: inkblotVideo.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file inkblotVideo.I + * @author jyelon + * @date 2007-07-02 + */ diff --git a/panda/src/movies/inkblotVideo.cxx b/panda/src/movies/inkblotVideo.cxx index 656b410a27..dfc8043ddb 100644 --- a/panda/src/movies/inkblotVideo.cxx +++ b/panda/src/movies/inkblotVideo.cxx @@ -1,27 +1,24 @@ -// Filename: inkblotVideo.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file inkblotVideo.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "inkblotVideo.h" #include "inkblotVideoCursor.h" TypeHandle InkblotVideo::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideo::Constructor -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ InkblotVideo:: InkblotVideo(int x, int y, int fps) : _specified_x(x), @@ -30,20 +27,16 @@ InkblotVideo(int x, int y, int fps) : { } -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideo::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InkblotVideo:: ~InkblotVideo() { } -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideo::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieVideoCursor) InkblotVideo:: open() { return new InkblotVideoCursor(this); diff --git a/panda/src/movies/inkblotVideo.h b/panda/src/movies/inkblotVideo.h index b5982cde42..379d59a850 100644 --- a/panda/src/movies/inkblotVideo.h +++ b/panda/src/movies/inkblotVideo.h @@ -1,16 +1,15 @@ -// Filename: inkblotVideo.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file inkblotVideo.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef INKBLOTVIDEO_H #define INKBLOTVIDEO_H @@ -19,11 +18,9 @@ class InkblotVideoCursor; -//////////////////////////////////////////////////////////////////// -// Class : InkblotVideo -// Description : A cellular automaton that generates an amusing -// pattern of swirling colors. -//////////////////////////////////////////////////////////////////// +/** + * A cellular automaton that generates an amusing pattern of swirling colors. + */ class EXPCL_PANDA_MOVIES InkblotVideo : public MovieVideo { PUBLISHED: diff --git a/panda/src/movies/inkblotVideoCursor.I b/panda/src/movies/inkblotVideoCursor.I index 34dded9f9c..dab0849e83 100644 --- a/panda/src/movies/inkblotVideoCursor.I +++ b/panda/src/movies/inkblotVideoCursor.I @@ -1,14 +1,12 @@ -// Filename: inkblotVideoCursor.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file inkblotVideoCursor.I + * @author jyelon + * @date 2007-07-02 + */ diff --git a/panda/src/movies/inkblotVideoCursor.cxx b/panda/src/movies/inkblotVideoCursor.cxx index 8e5ffea333..a209e49f74 100644 --- a/panda/src/movies/inkblotVideoCursor.cxx +++ b/panda/src/movies/inkblotVideoCursor.cxx @@ -1,27 +1,22 @@ -// Filename: inkblotVideoCursor.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file inkblotVideoCursor.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "inkblotVideoCursor.h" #include "config_movies.h" TypeHandle InkblotVideoCursor::_type_handle; -//////////////////////////////////////////////////////////////////// -// // The Color-Map -// -//////////////////////////////////////////////////////////////////// struct color { int r,g,b; }; @@ -44,13 +39,11 @@ static color colormap[17] = { { 0,255,0 }, { 0,255,255 }, { 0,0,255 }, -}; +}; -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideoCursor::Constructor -// Access: Public -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ InkblotVideoCursor:: InkblotVideoCursor(InkblotVideo *src) : MovieVideoCursor(src) @@ -71,22 +64,18 @@ InkblotVideoCursor(InkblotVideo *src) : _last_frame = -1; } -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideoCursor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InkblotVideoCursor:: ~InkblotVideoCursor() { delete[] _cells; delete[] _cells2; } -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideoCursor::set_time -// Access: Published, Virtual -// Description: See MovieVideoCursor::set_time(). -//////////////////////////////////////////////////////////////////// +/** + * See MovieVideoCursor::set_time(). + */ bool InkblotVideoCursor:: set_time(double time, int loop_count) { int frame = (int)(time / _fps); @@ -98,25 +87,23 @@ set_time(double time, int loop_count) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InkblotVideoCursor::fetch_buffer -// Access: Published, Virtual -// Description: See MovieVideoCursor::fetch_buffer. -//////////////////////////////////////////////////////////////////// +/** + * See MovieVideoCursor::fetch_buffer. + */ PT(MovieVideoCursor::Buffer) InkblotVideoCursor:: fetch_buffer() { PT(Buffer) buffer = get_standard_buffer(); int padx = size_x() + 2; int pady = size_y() + 2; - + if (_current_frame < _last_frame) { // Rewind to beginning. memset(_cells, 255, padx * pady); memset(_cells2, 255, padx * pady); _last_frame = 0; } - + while (_last_frame <= _current_frame) { ++_last_frame; for (int y=1; y MicrophoneAudio::_all_microphones; TypeHandle MicrophoneAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudio::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MicrophoneAudio:: ~MicrophoneAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudio::find_all_microphones -// Access: Public -// Description: Scans the hardware for microphones, and pushes them -// onto the global list of all microphones. -// -// There are several implementations of MicrophoneAudio, -// including one based on DirectShow, one based on -// Linux ALSA, and so forth. These implementations -// are contained in one C++ file each, and they export -// nothing at all except a single "find_all" function. -// Otherwise, they can only be accessed through the -// virtual methods of the MicrophoneAudio objects they -// create. -//////////////////////////////////////////////////////////////////// +/** + * Scans the hardware for microphones, and pushes them onto the global list of + * all microphones. + * + * There are several implementations of MicrophoneAudio, including one based + * on DirectShow, one based on Linux ALSA, and so forth. These + * implementations are contained in one C++ file each, and they export nothing + * at all except a single "find_all" function. Otherwise, they can only be + * accessed through the virtual methods of the MicrophoneAudio objects they + * create. + */ void MicrophoneAudio:: find_all_microphones() { static bool initialized = false; @@ -59,25 +52,20 @@ find_all_microphones() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudio::get_num_options -// Access: Public -// Description: Returns the number of microphone options. An "option" -// consists of a device plus a set of configuration -// parameters. For example, "Soundblaster Audigy Line in -// at 44,100 samples/sec" would be an option. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of microphone options. An "option" consists of a device + * plus a set of configuration parameters. For example, "Soundblaster Audigy + * Line in at 44,100 samples/sec" would be an option. + */ int MicrophoneAudio:: get_num_options() { find_all_microphones(); return _all_microphones.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudio::get_option -// Access: Public -// Description: Returns the nth microphone option. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth microphone option. + */ PT(MicrophoneAudio) MicrophoneAudio:: get_option(int n) { find_all_microphones(); diff --git a/panda/src/movies/microphoneAudio.h b/panda/src/movies/microphoneAudio.h index 91f525f8f8..2b617ce141 100644 --- a/panda/src/movies/microphoneAudio.h +++ b/panda/src/movies/microphoneAudio.h @@ -1,16 +1,15 @@ -// Filename: microphoneAudio.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file microphoneAudio.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef MICROPHONEAUDIO_H #define MICROPHONEAUDIO_H @@ -19,11 +18,10 @@ class MovieAudio; class MovieAudioCursor; -//////////////////////////////////////////////////////////////////// -// Class : MicrophoneAudio -// Description : Class MicrophoneAudio provides the means to read -// raw audio samples from a microphone. -//////////////////////////////////////////////////////////////////// +/** + * Class MicrophoneAudio provides the means to read raw audio samples from a + * microphone. + */ class EXPCL_PANDA_MOVIES MicrophoneAudio : public MovieAudio { PUBLISHED: @@ -32,10 +30,10 @@ class EXPCL_PANDA_MOVIES MicrophoneAudio : public MovieAudio { static int get_num_options(); static PT(MicrophoneAudio) get_option(int n); MAKE_SEQ(get_options, get_num_options, get_option); - + INLINE int get_channels() const; INLINE int get_rate() const; - + virtual PT(MovieAudioCursor) open() = 0; public: diff --git a/panda/src/movies/microphoneAudioDS.cxx b/panda/src/movies/microphoneAudioDS.cxx index 7215e29365..6df15f1cfc 100644 --- a/panda/src/movies/microphoneAudioDS.cxx +++ b/panda/src/movies/microphoneAudioDS.cxx @@ -1,24 +1,21 @@ -// Filename: microphoneAudioDS.cxx -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// It goes against Panda3D coding style conventions to hide an -// entire class in a C++ file and not expose it through header -// files at all. However, in this case, these classes are so full -// of OS-specific junk that I feel it is better to hide them -// entirely. - Josh -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file microphoneAudioDS.cxx + * @author jyelon + * @date 2007-11-01 + * + * It goes against Panda3D coding style conventions to hide an + * entire class in a C++ file and not expose it through header + * files at all. However, in this case, these classes are so full + * of OS-specific junk that I feel it is better to hide them + * entirely. - Josh + */ #ifdef HAVE_DIRECTCAM @@ -31,10 +28,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : MicrophoneAudioDS -// Description : The directshow implementation of microphones. -//////////////////////////////////////////////////////////////////// +/** + * The directshow implementation of microphones. + */ class MicrophoneAudioDS : public MicrophoneAudio { public: static void find_all_microphones_ds(); @@ -79,10 +75,9 @@ private: TypeHandle MicrophoneAudioDS::_type_handle; -//////////////////////////////////////////////////////////////////// -// Class : MicrophoneAudioCursorDS -// Description : The directshow implementation of microphones. -//////////////////////////////////////////////////////////////////// +/** + * The directshow implementation of microphones. + */ class MicrophoneAudioCursorDS : public MovieAudioCursor { @@ -126,12 +121,10 @@ private: TypeHandle MicrophoneAudioCursorDS::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioDS::find_all_microphones_ds -// Access: Public, Static -// Description: Finds all DirectShow microphones and adds them to -// the global list _all_microphones. -//////////////////////////////////////////////////////////////////// +/** + * Finds all DirectShow microphones and adds them to the global list + * _all_microphones. + */ void MicrophoneAudioDS:: find_all_microphones_ds() { MMRESULT stat; @@ -173,15 +166,13 @@ find_all_microphones_ds() { void find_all_microphones_ds() { MicrophoneAudioDS::init_type(); - // MicrophoneAudioCursorDS::init_type(); + // MicrophoneAudioCursorDS::init_type(); MicrophoneAudioDS::find_all_microphones_ds(); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioDS::delete_buffers -// Access: Private, Static -// Description: Delete a set of audio buffers. -//////////////////////////////////////////////////////////////////// +/** + * Delete a set of audio buffers. + */ void MicrophoneAudioDS:: delete_buffers(AudioBuffers &buffers) { for (int i=0; i<(int)buffers.size(); i++) { @@ -198,15 +189,13 @@ delete_buffers(AudioBuffers &buffers) { buffers.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioDS::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieAudioCursor) MicrophoneAudioDS:: open() { - // Allocate the buffers. 64 buffers, not quite 1/20 sec each. + // Allocate the buffers. 64 buffers, not quite 120 sec each. int samples; switch (_rate) { case 11025: samples=512; break; @@ -289,11 +278,9 @@ open() { return new MicrophoneAudioCursorDS(this, buffers, hwav); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioCursorDS::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MicrophoneAudioCursorDS:: MicrophoneAudioCursorDS(MicrophoneAudioDS *src, AudioBuffers &bufs, HWAVEIN hwav) : MovieAudioCursor(src), @@ -311,11 +298,9 @@ MicrophoneAudioCursorDS(MicrophoneAudioDS *src, AudioBuffers &bufs, HWAVEIN hwav _samples_per_buffer = bufs[0]._header->dwBufferLength / (2 * _audio_channels); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioCursorDS::cleanup -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MicrophoneAudioCursorDS:: cleanup() { if (_handle) { @@ -327,21 +312,17 @@ cleanup() { _offset = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioCursorDS::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MicrophoneAudioCursorDS:: ~MicrophoneAudioCursorDS() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioCursorDS::read_samples -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MicrophoneAudioCursorDS:: read_samples(int n, PN_int16 *data) { int orign = n; @@ -394,11 +375,9 @@ read_samples(int n, PN_int16 *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: MicrophoneAudioCursorDS::ready -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int MicrophoneAudioCursorDS:: ready() const { if (_handle == 0) return 0; diff --git a/panda/src/movies/movieAudio.I b/panda/src/movies/movieAudio.I index a54025505d..d3d66cf871 100644 --- a/panda/src/movies/movieAudio.I +++ b/panda/src/movies/movieAudio.I @@ -1,26 +1,21 @@ -// Filename: movieAudio.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudio.I + * @author jyelon + * @date 2007-07-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: MovieAudio::get_filename -// Access: Published -// Description: Returns the movie's filename. A movie is not -// guaranteed to have a filename, if not, then this -// function returns a null filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the movie's filename. A movie is not guaranteed to have a + * filename, if not, then this function returns a null filename. + */ INLINE const Filename &MovieAudio:: get_filename() const { return _filename; } - diff --git a/panda/src/movies/movieAudio.cxx b/panda/src/movies/movieAudio.cxx index 6c84abb3eb..0dee90e805 100644 --- a/panda/src/movies/movieAudio.cxx +++ b/panda/src/movies/movieAudio.cxx @@ -1,16 +1,15 @@ -// Filename: movieAudio.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudio.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "movieAudio.h" #include "movieAudioCursor.h" @@ -19,45 +18,36 @@ TypeHandle MovieAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovieAudio::Constructor -// Access: Public -// Description: This constructor returns a null audio stream --- a -// stream of total silence, at 8000 samples per second. -// To get more interesting audio, you need to construct -// a subclass of this class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor returns a null audio stream --- a stream of total silence, + * at 8000 samples per second. To get more interesting audio, you need to + * construct a subclass of this class. + */ MovieAudio:: MovieAudio(const string &name) : Namable(name) { } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudio::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieAudio:: ~MovieAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudio::open -// Access: Published, Virtual -// Description: Open this audio, returning a MovieAudioCursor -//////////////////////////////////////////////////////////////////// +/** + * Open this audio, returning a MovieAudioCursor + */ PT(MovieAudioCursor) MovieAudio:: open() { return new MovieAudioCursor(this); } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudio::get -// Access: Published, Static -// Description: Obtains a MovieAudio that references a file. -// Just calls MovieTypeRegistry::make_audio(). -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieAudio that references a file. Just calls + * MovieTypeRegistry::make_audio(). + */ PT(MovieAudio) MovieAudio:: get(const Filename &name) { MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr(); diff --git a/panda/src/movies/movieAudio.h b/panda/src/movies/movieAudio.h index 514b0627ba..5e04f474eb 100644 --- a/panda/src/movies/movieAudio.h +++ b/panda/src/movies/movieAudio.h @@ -1,16 +1,15 @@ -// Filename: movieAudio.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudio.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef MOVIEAUDIO_H #define MOVIEAUDIO_H @@ -33,18 +32,15 @@ class MovieAudioCursor; #define movies_debug(msg) ((void)0); #endif //] -//////////////////////////////////////////////////////////////////// -// Class : MovieAudio -// Description : A MovieAudio is actually any source that provides -// a sequence of audio samples. That could include an -// AVI file, a microphone, or an internet TV station. -// -// The difference between a MovieAudio and a -// MovieAudioCursor is like the difference between a -// filename and a file handle. The MovieAudio just -// indicates a particular movie. The MovieAudioCursor -// is what allows access. -//////////////////////////////////////////////////////////////////// +/** + * A MovieAudio is actually any source that provides a sequence of audio + * samples. That could include an AVI file, a microphone, or an internet TV + * station. + * + * The difference between a MovieAudio and a MovieAudioCursor is like the + * difference between a filename and a file handle. The MovieAudio just + * indicates a particular movie. The MovieAudioCursor is what allows access. + */ class EXPCL_PANDA_MOVIES MovieAudio : public TypedWritableReferenceCount, public Namable { PUBLISHED: MovieAudio(const string &name = "Blank Audio"); diff --git a/panda/src/movies/movieAudioCursor.I b/panda/src/movies/movieAudioCursor.I index f53ddd9d6c..adbb4dd7ba 100644 --- a/panda/src/movies/movieAudioCursor.I +++ b/panda/src/movies/movieAudioCursor.I @@ -1,132 +1,104 @@ -// Filename: movieAudioCursor.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudioCursor.I + * @author jyelon + * @date 2007-07-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::get_source -// Access: Public -// Description: Returns the MovieAudio which this cursor references. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MovieAudio which this cursor references. + */ INLINE PT(MovieAudio) MovieAudioCursor:: get_source() const { return _source; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::audio_rate -// Access: Public -// Description: Returns the audio sample rate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the audio sample rate. + */ INLINE int MovieAudioCursor:: audio_rate() const { return _audio_rate; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::audio_channels -// Access: Public -// Description: Returns the number of audio channels (ie, two for -// stereo, one for mono). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of audio channels (ie, two for stereo, one for mono). + */ INLINE int MovieAudioCursor:: audio_channels() const { return _audio_channels; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::length -// Access: Public -// Description: Returns the length of the movie. Attempting to read -// audio samples beyond the specified length will produce -// silent samples. -// -// Some kinds of Movie, such as internet TV station, -// might not have a predictable length. In that case, -// the length will be set to a very large number: 1.0E10. -// -// Some AVI files have incorrect length values encoded -// into them - they may be a second or two long or -// short. When playing such an AVI using the Movie class, -// you may see a slightly truncated video, or a slightly -// elongated video (padded with black frames). There are -// utilities out there to fix the length values in AVI -// files. -// -// An audio consumer needs to check the length, the -// ready status, and the aborted flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the movie. Attempting to read audio samples beyond + * the specified length will produce silent samples. + * + * Some kinds of Movie, such as internet TV station, might not have a + * predictable length. In that case, the length will be set to a very large + * number: 1.0E10. + * + * Some AVI files have incorrect length values encoded into them - they may be + * a second or two long or short. When playing such an AVI using the Movie + * class, you may see a slightly truncated video, or a slightly elongated + * video (padded with black frames). There are utilities out there to fix the + * length values in AVI files. + * + * An audio consumer needs to check the length, the ready status, and the + * aborted flag. + */ INLINE double MovieAudioCursor:: length() const { return _length; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::can_seek -// Access: Public -// Description: Returns true if the movie can seek. If this is -// true, seeking is still not guaranteed to be fast: -// for some movies, seeking is implemented by rewinding -// to the beginning and then fast-forwarding to the -// desired location. Even if the movie cannot seek, -// the seek method can still advance to an arbitrary -// location by reading samples and discarding them. -// However, to move backward, can_seek must return true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the movie can seek. If this is true, seeking is still not + * guaranteed to be fast: for some movies, seeking is implemented by rewinding + * to the beginning and then fast-forwarding to the desired location. Even if + * the movie cannot seek, the seek method can still advance to an arbitrary + * location by reading samples and discarding them. However, to move + * backward, can_seek must return true. + */ INLINE bool MovieAudioCursor:: can_seek() const { return _can_seek; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::can_seek_fast -// Access: Public -// Description: Returns true if seek operations are constant time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if seek operations are constant time. + */ INLINE bool MovieAudioCursor:: can_seek_fast() const { return _can_seek_fast; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::aborted -// Access: Public -// Description: If aborted is true, it means that the "ready" samples -// are not being replenished. See the method "ready" -// for an explanation. -//////////////////////////////////////////////////////////////////// +/** + * If aborted is true, it means that the "ready" samples are not being + * replenished. See the method "ready" for an explanation. + */ INLINE bool MovieAudioCursor:: aborted() const { return _aborted; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::tell -// Access: Public -// Description: Returns the current offset within the file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current offset within the file. + */ INLINE double MovieAudioCursor:: tell() const { return _last_seek + ((_samples_read * 1.0) / _audio_rate); } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::skip_samples -// Access: Published -// Description: Skip audio samples from the stream. This is mostly -// for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Skip audio samples from the stream. This is mostly for debugging purposes. + */ INLINE void MovieAudioCursor:: skip_samples(int n) { read_samples(n, (PN_int16*)0); } - diff --git a/panda/src/movies/movieAudioCursor.cxx b/panda/src/movies/movieAudioCursor.cxx index 2620b3c239..2776dbe030 100644 --- a/panda/src/movies/movieAudioCursor.cxx +++ b/panda/src/movies/movieAudioCursor.cxx @@ -1,29 +1,25 @@ -// Filename: movieAudioCursor.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudioCursor.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "movieAudioCursor.h" TypeHandle MovieAudioCursor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::Constructor -// Access: Public -// Description: This constructor returns a null audio stream --- a -// stream of total silence, at 8000 samples per second. -// To get more interesting audio, you need to construct -// a subclass of this class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor returns a null audio stream --- a stream of total silence, + * at 8000 samples per second. To get more interesting audio, you need to + * construct a subclass of this class. + */ MovieAudioCursor:: MovieAudioCursor(MovieAudio *src) : _source(src), @@ -37,28 +33,23 @@ MovieAudioCursor(MovieAudio *src) : { } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieAudioCursor:: ~MovieAudioCursor() { } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::read_samples -// Access: Public, Virtual -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void MovieAudioCursor:: read_samples(int n, PN_int16 *data) { - // This is the null implementation, which generates pure silence. - // Normally, this method will be overridden by a subclass. + // This is the null implementation, which generates pure silence. Normally, + // this method will be overridden by a subclass. if (n <= 0) { return; @@ -71,16 +62,13 @@ read_samples(int n, PN_int16 *data) { _samples_read += n; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::read_samples -// Access: Published -// Description: Read audio samples from the stream into a -// Datagram. N is the number of samples you wish -// to read. Multiple-channel audio will be interleaved. -// -// This is not particularly efficient, but it may be -// a convenient way to manipulate samples in python. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream into a Datagram. N is the number of + * samples you wish to read. Multiple-channel audio will be interleaved. + * + * This is not particularly efficient, but it may be a convenient way to + * manipulate samples in python. + */ void MovieAudioCursor:: read_samples(int n, Datagram *dg) { PN_int16 tmp[4096]; @@ -96,17 +84,14 @@ read_samples(int n, Datagram *dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::read_samples -// Access: Published -// Description: Read audio samples from the stream and returns -// them as a string. The samples are stored little-endian -// in the string. N is the number of samples you wish -// to read. Multiple-channel audio will be interleaved. -// -// This is not particularly efficient, but it may be -// a convenient way to manipulate samples in python. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream and returns them as a string. The + * samples are stored little-endian in the string. N is the number of samples + * you wish to read. Multiple-channel audio will be interleaved. + * + * This is not particularly efficient, but it may be a convenient way to + * manipulate samples in python. + */ string MovieAudioCursor:: read_samples(int n) { ostringstream result; @@ -127,65 +112,52 @@ read_samples(int n) { } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::seek -// Access: Published, Virtual -// Description: Skips to the specified offset within the file. -// -// If the movie reports that it cannot seek, then -// this method can still advance by reading samples -// and discarding them. However, to move backward, -// can_seek must be true. -// -// If the movie reports that it can_seek, it doesn't -// mean that it can do so quickly. It may have to -// rewind the movie and then fast forward to the -// desired location. Only if can_seek_fast returns -// true can seek operations be done in constant time. -// -// Seeking may not be precise, because AVI files -// often have inaccurate indices. After -// seeking, tell will indicate that the cursor is -// at the target location. However, in truth, the data -// you read may come from a slightly offset location. -//////////////////////////////////////////////////////////////////// +/** + * Skips to the specified offset within the file. + * + * If the movie reports that it cannot seek, then this method can still + * advance by reading samples and discarding them. However, to move backward, + * can_seek must be true. + * + * If the movie reports that it can_seek, it doesn't mean that it can do so + * quickly. It may have to rewind the movie and then fast forward to the + * desired location. Only if can_seek_fast returns true can seek operations + * be done in constant time. + * + * Seeking may not be precise, because AVI files often have inaccurate + * indices. After seeking, tell will indicate that the cursor is at the + * target location. However, in truth, the data you read may come from a + * slightly offset location. + */ void MovieAudioCursor:: seek(double offset) { _last_seek = offset; _samples_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MovieAudioCursor::ready -// Access: Public -// Description: Returns the number of audio samples that are ready -// to read. This is primarily relevant for sources like -// microphones which produce samples at a fixed rate. -// If you try to read more samples than are ready, the -// result will be silent samples. -// -// Some audio streams do not have a limit on how fast -// they can produce samples. Such streams will always -// return 0x40000000 as the ready-count. This may well -// exceed the length of the audio stream. You therefore -// need to check length separately. -// -// If the aborted flag is set, that means the ready count -// is no longer being replenished. For example, a -// MovieAudioCursor might be reading from an internet -// radio station, and it might buffer data to avoid -// underruns. If it loses connection to the radio -// station, it will set the aborted flag to indicate that -// the buffer is no longer being replenished. But it is -// still ok to read the samples that are in the buffer, -// at least until they run out. Once those are gone, -// there will be no more. -// -// An audio consumer needs to check the length, the -// ready status, and the aborted flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of audio samples that are ready to read. This is + * primarily relevant for sources like microphones which produce samples at a + * fixed rate. If you try to read more samples than are ready, the result + * will be silent samples. + * + * Some audio streams do not have a limit on how fast they can produce + * samples. Such streams will always return 0x40000000 as the ready-count. + * This may well exceed the length of the audio stream. You therefore need to + * check length separately. + * + * If the aborted flag is set, that means the ready count is no longer being + * replenished. For example, a MovieAudioCursor might be reading from an + * internet radio station, and it might buffer data to avoid underruns. If it + * loses connection to the radio station, it will set the aborted flag to + * indicate that the buffer is no longer being replenished. But it is still + * ok to read the samples that are in the buffer, at least until they run out. + * Once those are gone, there will be no more. + * + * An audio consumer needs to check the length, the ready status, and the + * aborted flag. + */ int MovieAudioCursor:: ready() const { return 0x40000000; } - diff --git a/panda/src/movies/movieAudioCursor.h b/panda/src/movies/movieAudioCursor.h index 108643dc66..731bc28f98 100644 --- a/panda/src/movies/movieAudioCursor.h +++ b/panda/src/movies/movieAudioCursor.h @@ -1,16 +1,15 @@ -// Filename: movieAudioCursor.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieAudioCursor.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef MOVIEAUDIOCURSOR_H #define MOVIEAUDIOCURSOR_H @@ -21,20 +20,17 @@ #include "pointerTo.h" class MovieAudio; -//////////////////////////////////////////////////////////////////// -// Class : MovieAudioCursor -// Description : A MovieAudio is actually any source that provides -// a sequence of audio samples. That could include an -// AVI file, a microphone, or an internet TV station. -// A MovieAudioCursor is a handle that lets you read -// data sequentially from a MovieAudio. -// -// Thread safety: each individual MovieAudioCursor -// must be owned and accessed by a single thread. -// It is OK for two different threads to open -// the same file at the same time, as long as they -// use separate MovieAudioCursor objects. -//////////////////////////////////////////////////////////////////// +/** + * A MovieAudio is actually any source that provides a sequence of audio + * samples. That could include an AVI file, a microphone, or an internet TV + * station. A MovieAudioCursor is a handle that lets you read data + * sequentially from a MovieAudio. + * + * Thread safety: each individual MovieAudioCursor must be owned and accessed + * by a single thread. It is OK for two different threads to open the same + * file at the same time, as long as they use separate MovieAudioCursor + * objects. + */ class EXPCL_PANDA_MOVIES MovieAudioCursor : public TypedWritableReferenceCount { PUBLISHED: @@ -67,7 +63,7 @@ protected: bool _aborted; double _last_seek; PN_int64 _samples_read; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/movieTypeRegistry.I b/panda/src/movies/movieTypeRegistry.I index 5fdf04368c..a444d91d9b 100644 --- a/panda/src/movies/movieTypeRegistry.I +++ b/panda/src/movies/movieTypeRegistry.I @@ -1,28 +1,23 @@ -// Filename: movieTypeRegistry.I -// Created by: rdb (24Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTypeRegistry.I + * @author rdb + * @date 2013-08-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the global MovieTypeRegistry -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global MovieTypeRegistry instance. + */ INLINE MovieTypeRegistry *MovieTypeRegistry:: get_global_ptr() { if (_global_ptr == NULL) { - _global_ptr = new MovieTypeRegistry; + _global_ptr = new MovieTypeRegistry; } return _global_ptr; diff --git a/panda/src/movies/movieTypeRegistry.cxx b/panda/src/movies/movieTypeRegistry.cxx index f9efd97b88..bca56d3628 100644 --- a/panda/src/movies/movieTypeRegistry.cxx +++ b/panda/src/movies/movieTypeRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: movieTypeRegistry.cxx -// Created by: rdb (24Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTypeRegistry.cxx + * @author rdb + * @date 2013-08-24 + */ #include "movieTypeRegistry.h" #include "string_utils.h" @@ -20,11 +19,9 @@ MovieTypeRegistry *MovieTypeRegistry::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::make_audio -// Access: Published, Static -// Description: Obtains a MovieVideo that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieVideo that references a file. + */ PT(MovieAudio) MovieTypeRegistry:: make_audio(const Filename &name) { string ext = downcase(name.get_extension()); @@ -44,8 +41,8 @@ make_audio(const Filename &name) { return (*func)(name); } - // If we didn't find it, see if there was a type registered - // with '*' as extension. This is a catch-all loader. + // If we didn't find it, see if there was a type registered with '*' as + // extension. This is a catch-all loader. if (_deferred_audio_types.count("*")) { load_movie_library(_deferred_audio_types["*"]); _deferred_audio_types.erase("*"); @@ -62,13 +59,10 @@ make_audio(const Filename &name) { return new MovieAudio("Load-Failure Stub"); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::register_audio_type -// Access: Published, Static -// Description: Registers a MovieAudio type, so that files with -// any of the given extensions will be loaded as this -// type. You may use * as a catch-all extension. -//////////////////////////////////////////////////////////////////// +/** + * Registers a MovieAudio type, so that files with any of the given extensions + * will be loaded as this type. You may use * as a catch-all extension. + */ void MovieTypeRegistry:: register_audio_type(MakeAudioFunc func, const string &extensions) { vector_string words; @@ -87,12 +81,9 @@ register_audio_type(MakeAudioFunc func, const string &extensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::load_audio_types -// Access: Published, Static -// Description: Loads the list with audio types, if we haven't -// already. -//////////////////////////////////////////////////////////////////// +/** + * Loads the list with audio types, if we haven't already. + */ void MovieTypeRegistry:: load_audio_types() { static bool audio_types_loaded = false; @@ -123,9 +114,9 @@ load_audio_types() { } } else if (words.size() > 1) { - // Multiple words: the first n words are filename extensions, - // and the last word is the name of the library to load should - // any of those filename extensions be encountered. + // Multiple words: the first n words are filename extensions, and the + // last word is the name of the library to load should any of those + // filename extensions be encountered. size_t num_extensions = words.size() - 1; string library_name = words[num_extensions]; @@ -144,11 +135,9 @@ load_audio_types() { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::make_video -// Access: Published, Static -// Description: Obtains a MovieVideo that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieVideo that references a file. + */ PT(MovieVideo) MovieTypeRegistry:: make_video(const Filename &name) { string ext = downcase(name.get_extension()); @@ -168,8 +157,8 @@ make_video(const Filename &name) { return (*func)(name); } - // If we didn't find it, see if there was a type registered - // with '*' as extension. This is a catch-all loader. + // If we didn't find it, see if there was a type registered with '*' as + // extension. This is a catch-all loader. if (_deferred_video_types.count("*")) { load_movie_library(_deferred_video_types["*"]); _deferred_video_types.erase("*"); @@ -186,13 +175,10 @@ make_video(const Filename &name) { return new MovieVideo("Load-Failure Stub"); } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::register_video_type -// Access: Published, Static -// Description: Registers a MovieVideo type, so that files with -// any of the given extensions will be loaded as this -// type. You may use * as a catch-all extension. -//////////////////////////////////////////////////////////////////// +/** + * Registers a MovieVideo type, so that files with any of the given extensions + * will be loaded as this type. You may use * as a catch-all extension. + */ void MovieTypeRegistry:: register_video_type(MakeVideoFunc func, const string &extensions) { vector_string words; @@ -211,12 +197,9 @@ register_video_type(MakeVideoFunc func, const string &extensions) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::load_video_types -// Access: Published, Static -// Description: Loads the list with video types, if we haven't -// already. -//////////////////////////////////////////////////////////////////// +/** + * Loads the list with video types, if we haven't already. + */ void MovieTypeRegistry:: load_video_types() { static bool video_types_loaded = false; @@ -247,9 +230,9 @@ load_video_types() { } } else if (words.size() > 1) { - // Multiple words: the first n words are filename extensions, - // and the last word is the name of the library to load should - // any of those filename extensions be encountered. + // Multiple words: the first n words are filename extensions, and the + // last word is the name of the library to load should any of those + // filename extensions be encountered. size_t num_extensions = words.size() - 1; string library_name = words[num_extensions]; @@ -268,11 +251,9 @@ load_video_types() { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieTypeRegistry::load_library -// Access: Published, Static -// Description: Loads the module. -//////////////////////////////////////////////////////////////////// +/** + * Loads the module. + */ void MovieTypeRegistry:: load_movie_library(const string &name) { Filename dlname = Filename::dso_filename("lib" + name + ".so"); diff --git a/panda/src/movies/movieTypeRegistry.h b/panda/src/movies/movieTypeRegistry.h index cb2e03a495..0ebe467ffb 100644 --- a/panda/src/movies/movieTypeRegistry.h +++ b/panda/src/movies/movieTypeRegistry.h @@ -1,16 +1,15 @@ -// Filename: movieTypeRegistry.h -// Created by: rdb (24Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieTypeRegistry.h + * @author rdb + * @date 2013-08-24 + */ #ifndef MOVIETYPEREGISTRY_H #define MOVIETYPEREGISTRY_H @@ -21,11 +20,10 @@ #include "filename.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : MovieTypeRegistry -// Description : This class records the different types of MovieAudio -// and MovieVideo that are available for loading. -//////////////////////////////////////////////////////////////////// +/** + * This class records the different types of MovieAudio and MovieVideo that + * are available for loading. + */ class EXPCL_PANDA_MOVIES MovieTypeRegistry { public: typedef PT(MovieAudio) (*MakeAudioFunc)(const Filename&); @@ -41,7 +39,7 @@ public: void load_movie_library(const string &name); INLINE static MovieTypeRegistry *get_global_ptr(); - + private: static MovieTypeRegistry *_global_ptr; diff --git a/panda/src/movies/movieVideo.I b/panda/src/movies/movieVideo.I index 76cd3e3b32..5b4471f3e9 100644 --- a/panda/src/movies/movieVideo.I +++ b/panda/src/movies/movieVideo.I @@ -1,37 +1,29 @@ -// Filename: movieVideo.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideo.I + * @author jyelon + * @date 2007-07-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::get_filename -// Access: Published -// Description: Returns the movie's filename. A movie is not -// guaranteed to have a filename, if not, then this -// function returns an empty filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the movie's filename. A movie is not guaranteed to have a + * filename, if not, then this function returns an empty filename. + */ INLINE const Filename &MovieVideo:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::get_subfile_info -// Access: Published -// Description: If the movie is to be loaded from a subfile on disk, -// this returns the subfile info. Check info.is_empty() -// to see if this is valid data. -//////////////////////////////////////////////////////////////////// +/** + * If the movie is to be loaded from a subfile on disk, this returns the + * subfile info. Check info.is_empty() to see if this is valid data. + */ INLINE const SubfileInfo &MovieVideo:: get_subfile_info() const { return _subfile_info; diff --git a/panda/src/movies/movieVideo.cxx b/panda/src/movies/movieVideo.cxx index 2ab59bf4bd..9b6c970472 100644 --- a/panda/src/movies/movieVideo.cxx +++ b/panda/src/movies/movieVideo.cxx @@ -1,16 +1,15 @@ -// Filename: movieVideo.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideo.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "movieVideo.h" #include "movieVideoCursor.h" @@ -21,67 +20,55 @@ TypeHandle MovieVideo::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::Constructor -// Access: Public -// Description: This constructor returns a null video stream --- a -// stream of plain blue and white frames that last one -// second each. To get more interesting video, you need -// to construct a subclass of this class. -//////////////////////////////////////////////////////////////////// +/** + * This constructor returns a null video stream --- a stream of plain blue and + * white frames that last one second each. To get more interesting video, you + * need to construct a subclass of this class. + */ MovieVideo:: MovieVideo(const string &name) : Namable(name) { } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieVideo:: ~MovieVideo() { } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor of the -// appropriate type. Returns NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor of the appropriate type. + * Returns NULL on error. + */ PT(MovieVideoCursor) MovieVideo:: open() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::get -// Access: Published, Static -// Description: Obtains a MovieVideo that references a file. -// Just calls MovieTypeRegistry::make_video(). -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieVideo that references a file. Just calls + * MovieTypeRegistry::make_video(). + */ PT(MovieVideo) MovieVideo:: get(const Filename &name) { MovieTypeRegistry *reg = MovieTypeRegistry::get_global_ptr(); return reg->make_video(name); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void MovieVideo:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); dg.add_string(_filename); - - // Now we record the raw movie data directly into the bam stream. - // We always do this, regardless of bam-texture-mode; we generally - // won't get to this codepath if bam-texture-mode isn't rawdata - // anyway. + + // Now we record the raw movie data directly into the bam stream. We always + // do this, regardless of bam-texture-mode; we generally won't get to this + // codepath if bam-texture-mode isn't rawdata anyway. SubfileInfo result; if (!_subfile_info.is_empty()) { @@ -96,20 +83,17 @@ write_datagram(BamWriter *manager, Datagram &dg) { /* Not sure yet if this is a good idea. if (!result.is_empty()) { - // If we've just copied the data to a local file, read it from - // there in the future. + // If we've just copied the data to a local file, read it from there in + // the future. _subfile_info = result; } */ } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideo::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MovieVideo. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MovieVideo. + */ void MovieVideo:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); diff --git a/panda/src/movies/movieVideo.h b/panda/src/movies/movieVideo.h index 225e3e4fc8..4573495aa3 100644 --- a/panda/src/movies/movieVideo.h +++ b/panda/src/movies/movieVideo.h @@ -1,16 +1,15 @@ -// Filename: movieVideo.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideo.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef MOVIEVIDEO_H #define MOVIEVIDEO_H @@ -27,18 +26,15 @@ class FactoryParams; class BamWriter; class BamReader; -//////////////////////////////////////////////////////////////////// -// Class : MovieVideo -// Description : A MovieVideo is actually any source that provides -// a sequence of video frames. That could include an -// AVI file, a digital camera, or an internet TV station. -// -// The difference between a MovieVideo and a -// MovieVideoCursor is like the difference between a -// filename and a file handle. The MovieVideo just -// indicates a particular movie. The MovieVideoCursor -// is what allows access. -//////////////////////////////////////////////////////////////////// +/** + * A MovieVideo is actually any source that provides a sequence of video + * frames. That could include an AVI file, a digital camera, or an internet + * TV station. + * + * The difference between a MovieVideo and a MovieVideoCursor is like the + * difference between a filename and a file handle. The MovieVideo just + * indicates a particular movie. The MovieVideoCursor is what allows access. + */ class EXPCL_PANDA_MOVIES MovieVideo : public TypedWritableReferenceCount, public Namable { PUBLISHED: MovieVideo(const string &name = "Blank Video"); @@ -60,7 +56,7 @@ public: protected: void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/movieVideoCursor.I b/panda/src/movies/movieVideoCursor.I index 1f2ca679f0..22627e1711 100644 --- a/panda/src/movies/movieVideoCursor.I +++ b/panda/src/movies/movieVideoCursor.I @@ -1,165 +1,129 @@ -// Filename: movieVideoCursor.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideoCursor.I + * @author jyelon + * @date 2007-07-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::get_source -// Access: Published -// Description: Get the MovieVideo which this cursor references. -//////////////////////////////////////////////////////////////////// +/** + * Get the MovieVideo which this cursor references. + */ INLINE PT(MovieVideo) MovieVideoCursor:: get_source() const { return _source; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::size_x -// Access: Published -// Description: Get the horizontal size of the movie. -//////////////////////////////////////////////////////////////////// +/** + * Get the horizontal size of the movie. + */ INLINE int MovieVideoCursor:: size_x() const { return _size_x; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::size_y -// Access: Published -// Description: Get the vertical size of the movie. -//////////////////////////////////////////////////////////////////// +/** + * Get the vertical size of the movie. + */ INLINE int MovieVideoCursor:: size_y() const { return _size_y; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::get_num_components -// Access: Published -// Description: Returns 4 if the movie has an alpha -// channel, 3 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns 4 if the movie has an alpha channel, 3 otherwise. + */ INLINE int MovieVideoCursor:: get_num_components() const { return _num_components; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::length -// Access: Published -// Description: Returns the length of the movie. -// -// Some kinds of Movie, such as internet TV station, -// might not have a predictable length. In that case, -// the length will be set to a very large number: 1.0E10. -// If the internet TV station goes offline, the video -// or audio stream will set its abort flag. Reaching the -// end of the movie (ie, the specified length) normally -// does not cause the abort flag to be set. -// -// The video and audio streams produced by get_video and -// get_audio are always of unlimited duration - you can -// always read another video frame or another audio -// sample. This is true even if the specified length -// is reached, or an abort is flagged. If either stream -// runs out of data, it will synthesize blank video -// frames and silent audio samples as necessary to -// satisfy read requests. -// -// Some AVI files have incorrect length values encoded -// into them - usually, they're a second or two long or -// short. When playing such an AVI using the Movie class, -// you may see a slightly truncated video, or a slightly -// elongated video (padded with black frames). There are -// utilities out there to fix the length values in AVI -// files. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the movie. + * + * Some kinds of Movie, such as internet TV station, might not have a + * predictable length. In that case, the length will be set to a very large + * number: 1.0E10. If the internet TV station goes offline, the video or audio + * stream will set its abort flag. Reaching the end of the movie (ie, the + * specified length) normally does not cause the abort flag to be set. + * + * The video and audio streams produced by get_video and get_audio are always + * of unlimited duration - you can always read another video frame or another + * audio sample. This is true even if the specified length is reached, or an + * abort is flagged. If either stream runs out of data, it will synthesize + * blank video frames and silent audio samples as necessary to satisfy read + * requests. + * + * Some AVI files have incorrect length values encoded into them - usually, + * they're a second or two long or short. When playing such an AVI using the + * Movie class, you may see a slightly truncated video, or a slightly + * elongated video (padded with black frames). There are utilities out there + * to fix the length values in AVI files. + * + */ INLINE double MovieVideoCursor:: length() const { return _length; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::can_seek -// Access: Published -// Description: Returns true if the movie can seek. If this is -// true, seeking is still not guaranteed to be fast: -// for some movies, seeking is implemented by rewinding -// to the beginning and then fast-forwarding to the -// desired location. Even if the movie cannot seek, -// the fetch methods can still advance to an arbitrary -// location by reading frames and discarding them. -// However, to move backward, can_seek must return true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the movie can seek. If this is true, seeking is still not + * guaranteed to be fast: for some movies, seeking is implemented by rewinding + * to the beginning and then fast-forwarding to the desired location. Even if + * the movie cannot seek, the fetch methods can still advance to an arbitrary + * location by reading frames and discarding them. However, to move backward, + * can_seek must return true. + */ INLINE bool MovieVideoCursor:: can_seek() const { return _can_seek; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::can_seek_fast -// Access: Published -// Description: Returns true if seek operations are constant time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if seek operations are constant time. + */ INLINE bool MovieVideoCursor:: can_seek_fast() const { return _can_seek_fast; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::aborted -// Access: Published -// Description: Returns true if the video has aborted prematurely. -// For example, this could occur if the Movie was actually -// an internet TV station, and the connection was lost. -// Reaching the normal end of the video does not -// constitute an 'abort' condition. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the video has aborted prematurely. For example, this could + * occur if the Movie was actually an internet TV station, and the connection + * was lost. Reaching the normal end of the video does not constitute an + * 'abort' condition. + */ INLINE bool MovieVideoCursor:: aborted() const { return _aborted; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::streaming -// Access: Published -// Description: Returns true if the video frames are being "pushed" -// at us by something that operates at its own speed - -// for example, a webcam. In this case, the frames come -// when they're ready to come. Attempting to read too -// soon will produce nothing, reading too late will cause -// frames to be dropped. In this case, the ready flag -// can be used to determine whether or not a frame is -// ready for reading. -// -// When streaming, you should still pay attention to -// last_start, but the value of next_start is only a -// guess. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the video frames are being "pushed" at us by something that + * operates at its own speed - for example, a webcam. In this case, the + * frames come when they're ready to come. Attempting to read too soon will + * produce nothing, reading too late will cause frames to be dropped. In this + * case, the ready flag can be used to determine whether or not a frame is + * ready for reading. + * + * When streaming, you should still pay attention to last_start, but the value + * of next_start is only a guess. + */ INLINE bool MovieVideoCursor:: streaming() const { return _streaming; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::ready -// Access: Published -// Description: Returns true if the cursor is a streaming source, and -// if a video frame is ready to be read. For non- -// streaming sources, this is always false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cursor is a streaming source, and if a video frame is + * ready to be read. For non- streaming sources, this is always false. + */ INLINE bool MovieVideoCursor:: ready() const { return _ready; } - diff --git a/panda/src/movies/movieVideoCursor.cxx b/panda/src/movies/movieVideoCursor.cxx index 2b800b9e26..f1f531453a 100644 --- a/panda/src/movies/movieVideoCursor.cxx +++ b/panda/src/movies/movieVideoCursor.cxx @@ -1,16 +1,15 @@ -// Filename: movieVideoCursor.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideoCursor.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "movieVideoCursor.h" #include "config_movies.h" @@ -26,13 +25,10 @@ PStatCollector MovieVideoCursor::_copy_pcollector_copy("*:Copy Video into Textur TypeHandle MovieVideoCursor::_type_handle; TypeHandle MovieVideoCursor::Buffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Default Constructor -// Access: Protected -// Description: This is a virtual base class and should not be -// created directly. Instead, create a more specialized -// class. -//////////////////////////////////////////////////////////////////// +/** + * This is a virtual base class and should not be created directly. Instead, + * create a more specialized class. + */ MovieVideoCursor:: MovieVideoCursor(MovieVideo *src) : _source(src), @@ -48,22 +44,17 @@ MovieVideoCursor(MovieVideo *src) : { } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieVideoCursor:: ~MovieVideoCursor() { } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::setup_texture -// Access: Published -// Description: Set up the specified Texture object to contain -// content from this movie. This should be called -// once, not every frame. -//////////////////////////////////////////////////////////////////// +/** + * Set up the specified Texture object to contain content from this movie. + * This should be called once, not every frame. + */ void MovieVideoCursor:: setup_texture(Texture *tex) const { int fullx = size_x(); @@ -74,58 +65,44 @@ setup_texture(Texture *tex) const { tex->set_pad_size(fullx - size_x(), fully - size_y()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::set_time -// Access: Published, Virtual -// Description: Updates the cursor to the indicated time. If -// loop_count >= 1, the time is clamped to the movie's -// length * loop_count. If loop_count <= 0, the time is -// understood to be modulo the movie's length. -// -// Returns true if a new frame is now available, false -// otherwise. If this returns true, you should -// immediately follow this with exactly *one* call to -// fetch_buffer(). -// -// If the movie reports that it can_seek, you may also -// specify a time value less than the previous value you -// passed to set_time(). Otherwise, you may only -// specify a time value greater than or equal to -// the previous value. -// -// If the movie reports that it can_seek, it doesn't -// mean that it can do so quickly. It may have to -// rewind the movie and then fast forward to the -// desired location. Only if can_seek_fast returns -// true can it seek rapidly. -//////////////////////////////////////////////////////////////////// +/** + * Updates the cursor to the indicated time. If loop_count >= 1, the time is + * clamped to the movie's length * loop_count. If loop_count <= 0, the time + * is understood to be modulo the movie's length. + * + * Returns true if a new frame is now available, false otherwise. If this + * returns true, you should immediately follow this with exactly *one* call to + * fetch_buffer(). + * + * If the movie reports that it can_seek, you may also specify a time value + * less than the previous value you passed to set_time(). Otherwise, you may + * only specify a time value greater than or equal to the previous value. + * + * If the movie reports that it can_seek, it doesn't mean that it can do so + * quickly. It may have to rewind the movie and then fast forward to the + * desired location. Only if can_seek_fast returns true can it seek rapidly. + */ bool MovieVideoCursor:: set_time(double timestamp, int loop_count) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::fetch_buffer -// Access: Published, Virtual -// Description: Gets the current video frame (as specified by -// set_time()) from the movie and returns it in a -// pre-allocated buffer. You may simply let the buffer -// dereference and delete itself when you are done with -// it. -// -// This may return NULL (even if set_time() returned -// true) if the frame is not available for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Gets the current video frame (as specified by set_time()) from the movie + * and returns it in a pre-allocated buffer. You may simply let the buffer + * dereference and delete itself when you are done with it. + * + * This may return NULL (even if set_time() returned true) if the frame is not + * available for some reason. + */ PT(MovieVideoCursor::Buffer) MovieVideoCursor:: fetch_buffer() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::apply_to_texture -// Access: Published, Virtual -// Description: Stores this buffer's contents in the indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Stores this buffer's contents in the indicated texture. + */ void MovieVideoCursor:: apply_to_texture(const Buffer *buffer, Texture *t, int page) { if (buffer == NULL) { @@ -179,13 +156,10 @@ apply_to_texture(const Buffer *buffer, Texture *t, int page) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::apply_to_texture_alpha -// Access: Published, Virtual -// Description: Copies this buffer's contents into the alpha channel -// of the supplied texture. The RGB channels of the -// texture are not touched. -//////////////////////////////////////////////////////////////////// +/** + * Copies this buffer's contents into the alpha channel of the supplied + * texture. The RGB channels of the texture are not touched. + */ void MovieVideoCursor:: apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src) { if (buffer == NULL) { @@ -236,13 +210,10 @@ apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src } } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::apply_to_texture_rgb -// Access: Published, Virtual -// Description: Copies this buffer's contents into the RGB channels -// of the supplied texture. The alpha channel of the -// texture is not touched. -//////////////////////////////////////////////////////////////////// +/** + * Copies this buffer's contents into the RGB channels of the supplied + * texture. The alpha channel of the texture is not touched. + */ void MovieVideoCursor:: apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { if (buffer == NULL) { @@ -282,13 +253,10 @@ apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page) { } } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::get_standard_buffer -// Access: Protected -// Description: May be called by a derived class to return a single -// standard Buffer object to easily implement -// fetch_buffer(). -//////////////////////////////////////////////////////////////////// +/** + * May be called by a derived class to return a single standard Buffer object + * to easily implement fetch_buffer(). + */ MovieVideoCursor::Buffer *MovieVideoCursor:: get_standard_buffer() { if (_standard_buffer == NULL) { @@ -297,23 +265,18 @@ get_standard_buffer() { return _standard_buffer; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::make_new_buffer -// Access: Protected, Virtual -// Description: May be called by a derived class to allocate a new -// Buffer object. -//////////////////////////////////////////////////////////////////// +/** + * May be called by a derived class to allocate a new Buffer object. + */ PT(MovieVideoCursor::Buffer) MovieVideoCursor:: make_new_buffer() { return new Buffer(size_x() * size_y() * get_num_components()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void MovieVideoCursor:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); @@ -321,13 +284,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _source); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int MovieVideoCursor:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritableReferenceCount::complete_pointers(p_list, manager); @@ -337,13 +297,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MovieVideoCursor. + */ void MovieVideoCursor:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); @@ -351,11 +308,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); // _source } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Buffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieVideoCursor::Buffer:: Buffer(size_t block_size) : _block_size(block_size) @@ -364,42 +319,32 @@ Buffer(size_t block_size) : _block = (unsigned char *)_deleted_chain->allocate(_block_size, get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Buffer::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MovieVideoCursor::Buffer:: ~Buffer() { _deleted_chain->deallocate(_block, get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Buffer::compare_timestamp -// Access: Published, Virtual -// Description: Used to sort different buffers to ensure they -// correspond to the same source frame, particularly -// important when synchronizing the different pages of a -// multi-page texture. -// -// Returns 0 if the two buffers are of the same frame, -// <0 if this one comes earlier than the other one, and -// >0 if the other one comes earlier. -//////////////////////////////////////////////////////////////////// +/** + * Used to sort different buffers to ensure they correspond to the same source + * frame, particularly important when synchronizing the different pages of a + * multi-page texture. + * + * Returns 0 if the two buffers are of the same frame, <0 if this one comes + * earlier than the other one, and >0 if the other one comes earlier. + */ int MovieVideoCursor::Buffer:: compare_timestamp(const Buffer *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: MovieVideoCursor::Buffer::get_timestamp -// Access: Published, Virtual -// Description: Returns the nearest timestamp value of this -// particular buffer. Ideally, -// MovieVideoCursor::set_time() for this timestamp would -// return this buffer again. This need be defined only -// if compare_timestamp() is also defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nearest timestamp value of this particular buffer. Ideally, + * MovieVideoCursor::set_time() for this timestamp would return this buffer + * again. This need be defined only if compare_timestamp() is also defined. + */ double MovieVideoCursor::Buffer:: get_timestamp() const { return 0.0; diff --git a/panda/src/movies/movieVideoCursor.h b/panda/src/movies/movieVideoCursor.h index f8049e7647..0fb11fe04b 100644 --- a/panda/src/movies/movieVideoCursor.h +++ b/panda/src/movies/movieVideoCursor.h @@ -1,16 +1,15 @@ -// Filename: movieVideoCursor.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file movieVideoCursor.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef MOVIEVIDEOCURSOR_H #define MOVIEVIDEOCURSOR_H @@ -28,20 +27,17 @@ class FactoryParams; class BamWriter; class BamReader; -//////////////////////////////////////////////////////////////////// -// Class : MovieVideoCursor -// Description : A MovieVideo is actually any source that provides -// a sequence of video frames. That could include an -// AVI file, a digital camera, or an internet TV station. -// A MovieVideoCursor is a handle that lets you read -// data sequentially from a MovieVideo. -// -// Thread safety: each individual MovieVideoCursor -// must be owned and accessed by a single thread. -// It is OK for two different threads to open -// the same file at the same time, as long as they -// use separate MovieVideoCursor objects. -//////////////////////////////////////////////////////////////////// +/** + * A MovieVideo is actually any source that provides a sequence of video + * frames. That could include an AVI file, a digital camera, or an internet + * TV station. A MovieVideoCursor is a handle that lets you read data + * sequentially from a MovieVideo. + * + * Thread safety: each individual MovieVideoCursor must be owned and accessed + * by a single thread. It is OK for two different threads to open the same + * file at the same time, as long as they use separate MovieVideoCursor + * objects. + */ class EXPCL_PANDA_MOVIES MovieVideoCursor : public TypedWritableReferenceCount { protected: MovieVideoCursor(MovieVideo *src = NULL); @@ -103,11 +99,11 @@ PUBLISHED: virtual void apply_to_texture(const Buffer *buffer, Texture *t, int page); virtual void apply_to_texture_rgb(const Buffer *buffer, Texture *t, int page); virtual void apply_to_texture_alpha(const Buffer *buffer, Texture *t, int page, int alpha_src); - + protected: Buffer *get_standard_buffer(); virtual PT(Buffer) make_new_buffer(); - + protected: PT(MovieVideo) _source; int _size_x; @@ -132,7 +128,7 @@ public: protected: void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/userDataAudio.I b/panda/src/movies/userDataAudio.I index 68ae6bc20b..e6b36a3f2a 100644 --- a/panda/src/movies/userDataAudio.I +++ b/panda/src/movies/userDataAudio.I @@ -1,14 +1,12 @@ -// Filename: userDataAudio.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudio.I + * @author jyelon + * @date 2007-07-02 + */ diff --git a/panda/src/movies/userDataAudio.cxx b/panda/src/movies/userDataAudio.cxx index 49f1347da0..ca71806f31 100644 --- a/panda/src/movies/userDataAudio.cxx +++ b/panda/src/movies/userDataAudio.cxx @@ -1,28 +1,25 @@ -// Filename: userDataAudio.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudio.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "userDataAudio.h" #include "userDataAudioCursor.h" TypeHandle UserDataAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::Constructor -// Access: Public -// Description: This constructor returns a UserDataAudio --- -// a means to supply raw audio samples manually. -//////////////////////////////////////////////////////////////////// +/** + * This constructor returns a UserDataAudio --- a means to supply raw audio + * samples manually. + */ UserDataAudio:: UserDataAudio(int rate, int channels, bool remove_after_read) : MovieAudio("User Data Audio"), @@ -34,22 +31,17 @@ UserDataAudio(int rate, int channels, bool remove_after_read) : { } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserDataAudio:: ~UserDataAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::open -// Access: Published, Virtual -// Description: Open this audio, returning a UserDataAudioCursor. A -// UserDataAudio can only be opened by one consumer -// at a time. -//////////////////////////////////////////////////////////////////// +/** + * Open this audio, returning a UserDataAudioCursor. A UserDataAudio can only + * be opened by one consumer at a time. + */ PT(MovieAudioCursor) UserDataAudio:: open() { if (_cursor) { @@ -60,14 +52,11 @@ open() { return _cursor; } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::read_samples -// Access: Private -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void UserDataAudio:: read_samples(int n, PN_int16 *data) { int ready = (_data.size() / _desired_channels); @@ -85,11 +74,9 @@ read_samples(int n, PN_int16 *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::append -// Access: Public -// Description: Appends audio samples to the buffer. -//////////////////////////////////////////////////////////////////// +/** + * Appends audio samples to the buffer. + */ void UserDataAudio:: append(PN_int16 *data, int n) { nassertv(!_aborted); @@ -99,13 +86,10 @@ append(PN_int16 *data, int n) { } } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::append -// Access: Published -// Description: Appends audio samples to the buffer from a -// datagram. This is intended to make it easy to -// send streaming raw audio over a network. -//////////////////////////////////////////////////////////////////// +/** + * Appends audio samples to the buffer from a datagram. This is intended to + * make it easy to send streaming raw audio over a network. + */ void UserDataAudio:: append(DatagramIterator *src, int n) { nassertv(!_aborted); @@ -117,15 +101,11 @@ append(DatagramIterator *src, int n) { } } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::append -// Access: Published -// Description: Appends audio samples to the buffer from a -// string. The samples must be stored little-endian -// in the string. This is not particularly efficient, -// but it may be convenient to deal with samples in -// python. -//////////////////////////////////////////////////////////////////// +/** + * Appends audio samples to the buffer from a string. The samples must be + * stored little-endian in the string. This is not particularly efficient, + * but it may be convenient to deal with samples in python. + */ void UserDataAudio:: append(const string &str) { nassertv(!_aborted); @@ -139,12 +119,10 @@ append(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudio::done -// Access: Published -// Description: Promises not to append any more samples, ie, this -// marks the end of the audio stream. -//////////////////////////////////////////////////////////////////// +/** + * Promises not to append any more samples, ie, this marks the end of the + * audio stream. + */ void UserDataAudio:: done() { _aborted = true; diff --git a/panda/src/movies/userDataAudio.h b/panda/src/movies/userDataAudio.h index 1928ea1dfe..71f5a7eebb 100644 --- a/panda/src/movies/userDataAudio.h +++ b/panda/src/movies/userDataAudio.h @@ -1,16 +1,15 @@ -// Filename: userDataAudio.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudio.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef USERDATAAUDIO_H #define USERDATAAUDIO_H @@ -22,16 +21,13 @@ class MovieAudioCursor; class UserDataAudioCursor; -//////////////////////////////////////////////////////////////////// -// Class : UserDataAudio -// Description : A UserDataAudio is a way for the user to manually -// supply raw audio samples. remove_after_read means the -// data will be removed if read once. Else data will -// be stored (enable looping and seeking). -// Expects data as 16 bit signed (word); Example for stereo: -// 1.word = 1.channel,2.word = 2.channel, -// 3.word = 1.channel,4.word = 2.channel, etc. -//////////////////////////////////////////////////////////////////// +/** + * A UserDataAudio is a way for the user to manually supply raw audio samples. + * remove_after_read means the data will be removed if read once. Else data + * will be stored (enable looping and seeking). Expects data as 16 bit signed + * (word); Example for stereo: 1.word = 1.channel,2.word = 2.channel, 3.word = + * 1.channel,4.word = 2.channel, etc. + */ class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio { PUBLISHED: @@ -42,7 +38,7 @@ class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio { void append(PN_int16 *data, int n); void append(DatagramIterator *src, int len=0x40000000); void append(const string &str); - void done(); // A promise not to write any more samples. + void done(); // A promise not to write any more samples. private: void read_samples(int n, PN_int16 *data); @@ -54,7 +50,7 @@ class EXPCL_PANDA_MOVIES UserDataAudio : public MovieAudio { bool _aborted; bool _remove_after_read; friend class UserDataAudioCursor; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/userDataAudioCursor.I b/panda/src/movies/userDataAudioCursor.I index 4e41074e58..a4ed08ac5f 100644 --- a/panda/src/movies/userDataAudioCursor.I +++ b/panda/src/movies/userDataAudioCursor.I @@ -1,14 +1,12 @@ -// Filename: userDataAudioCursor.I -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudioCursor.I + * @author jyelon + * @date 2007-07-02 + */ diff --git a/panda/src/movies/userDataAudioCursor.cxx b/panda/src/movies/userDataAudioCursor.cxx index e9e23fe08b..d882195b2f 100644 --- a/panda/src/movies/userDataAudioCursor.cxx +++ b/panda/src/movies/userDataAudioCursor.cxx @@ -1,26 +1,23 @@ -// Filename: userDataAudioCursor.cxx -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudioCursor.cxx + * @author jyelon + * @date 2007-07-02 + */ #include "userDataAudioCursor.h" TypeHandle UserDataAudioCursor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudioCursor::Constructor -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserDataAudioCursor:: UserDataAudioCursor(UserDataAudio *src) : MovieAudioCursor(src) @@ -36,29 +33,24 @@ UserDataAudioCursor(UserDataAudio *src) : } } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudioCursor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UserDataAudioCursor:: ~UserDataAudioCursor() { UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; source->_cursor = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudioCursor::read_samples -// Access: Private -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void UserDataAudioCursor:: read_samples(int n, PN_int16 *data) { UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; - + if(source->_remove_after_read) { source->read_samples(n, data); } @@ -79,11 +71,9 @@ read_samples(int n, PN_int16 *data) { _samples_read += n; } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudioCursor::ready -// Access: Published -// Description: Set the offset if possible. -//////////////////////////////////////////////////////////////////// +/** + * Set the offset if possible. + */ void UserDataAudioCursor:: seek(double t) { if(_can_seek && 0 <= t && _length <= t) { @@ -95,12 +85,9 @@ seek(double t) { _last_seek = t; } -//////////////////////////////////////////////////////////////////// -// Function: UserDataAudioCursor::ready -// Access: Private -// Description: Returns the number of audio samples ready to be -// read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of audio samples ready to be read. + */ int UserDataAudioCursor:: ready() const { UserDataAudio *source = (UserDataAudio*)(MovieAudio*)_source; diff --git a/panda/src/movies/userDataAudioCursor.h b/panda/src/movies/userDataAudioCursor.h index d642462c4c..4c2ad96bb1 100644 --- a/panda/src/movies/userDataAudioCursor.h +++ b/panda/src/movies/userDataAudioCursor.h @@ -1,16 +1,15 @@ -// Filename: userDataAudioCursor.h -// Created by: jyelon (02Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file userDataAudioCursor.h + * @author jyelon + * @date 2007-07-02 + */ #ifndef USERDATAAUDIOCURSOR_H #define USERDATAAUDIOCURSOR_H @@ -23,17 +22,16 @@ class UserDataAudio; -//////////////////////////////////////////////////////////////////// -// Class : UserDataAudioCursor -// Description : A UserDataAudioCursor is a means to manually -// supply a sequence of raw audio samples. -//////////////////////////////////////////////////////////////////// +/** + * A UserDataAudioCursor is a means to manually supply a sequence of raw audio + * samples. + */ class EXPCL_PANDA_MOVIES UserDataAudioCursor : public MovieAudioCursor { PUBLISHED: UserDataAudioCursor(UserDataAudio *src); virtual ~UserDataAudioCursor(); - + public: virtual void read_samples(int n, PN_int16 *data); virtual int ready() const; diff --git a/panda/src/movies/vorbisAudio.I b/panda/src/movies/vorbisAudio.I index 36d22c0b7c..885f920e5b 100644 --- a/panda/src/movies/vorbisAudio.I +++ b/panda/src/movies/vorbisAudio.I @@ -1,14 +1,12 @@ -// Filename: vorbisAudio.I -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudio.I + * @author rdb + * @date 2013-08-23 + */ diff --git a/panda/src/movies/vorbisAudio.cxx b/panda/src/movies/vorbisAudio.cxx index 9dd3f90ee0..bd704e2bd1 100644 --- a/panda/src/movies/vorbisAudio.cxx +++ b/panda/src/movies/vorbisAudio.cxx @@ -1,16 +1,15 @@ -// Filename: vorbisAudio.cxx -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudio.cxx + * @author rdb + * @date 2013-08-23 + */ #include "vorbisAudio.h" #include "vorbisAudioCursor.h" @@ -21,11 +20,9 @@ TypeHandle VorbisAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudio::Constructor -// Access: Protected -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ VorbisAudio:: VorbisAudio(const Filename &name) : MovieAudio(name) @@ -33,20 +30,16 @@ VorbisAudio(const Filename &name) : _filename = name; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudio::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ VorbisAudio:: ~VorbisAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudio::open -// Access: Published, Virtual -// Description: Open this audio, returning a MovieAudioCursor -//////////////////////////////////////////////////////////////////// +/** + * Open this audio, returning a MovieAudioCursor + */ PT(MovieAudioCursor) VorbisAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -64,11 +57,9 @@ open() { } } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudio::make -// Access: Published, Static -// Description: Obtains a MovieAudio that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieAudio that references a file. + */ PT(MovieAudio) VorbisAudio:: make(const Filename &name) { return DCAST(MovieAudio, new VorbisAudio(name)); diff --git a/panda/src/movies/vorbisAudio.h b/panda/src/movies/vorbisAudio.h index 6dd7d23666..7be88620af 100644 --- a/panda/src/movies/vorbisAudio.h +++ b/panda/src/movies/vorbisAudio.h @@ -1,16 +1,15 @@ -// Filename: vorbisAudio.h -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudio.h + * @author rdb + * @date 2013-08-23 + */ #ifndef VORBISAUDIO_H #define VORBISAUDIO_H @@ -22,11 +21,10 @@ class VorbisAudioCursor; -//////////////////////////////////////////////////////////////////// -// Class : VorbisAudio -// Description : Interfaces with the libvorbisfile library to -// implement decoding of Ogg Vorbis audio files. -//////////////////////////////////////////////////////////////////// +/** + * Interfaces with the libvorbisfile library to implement decoding of Ogg + * Vorbis audio files. + */ class EXPCL_PANDA_MOVIES VorbisAudio : public MovieAudio { PUBLISHED: VorbisAudio(const Filename &name); @@ -37,7 +35,7 @@ PUBLISHED: private: friend class VorbisAudioCursor; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/vorbisAudioCursor.I b/panda/src/movies/vorbisAudioCursor.I index 45a77c7a57..c01b9a80fa 100644 --- a/panda/src/movies/vorbisAudioCursor.I +++ b/panda/src/movies/vorbisAudioCursor.I @@ -1,14 +1,12 @@ -// Filename: vorbisAudioCursor.I -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudioCursor.I + * @author rdb + * @date 2013-08-23 + */ diff --git a/panda/src/movies/vorbisAudioCursor.cxx b/panda/src/movies/vorbisAudioCursor.cxx index 2f206cbc39..d006c1878d 100644 --- a/panda/src/movies/vorbisAudioCursor.cxx +++ b/panda/src/movies/vorbisAudioCursor.cxx @@ -1,16 +1,15 @@ -// Filename: vorbisAudioCursor.cxx -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudioCursor.cxx + * @author rdb + * @date 2013-08-23 + */ #include "vorbisAudioCursor.h" #include "virtualFileSystem.h" @@ -19,13 +18,10 @@ TypeHandle VorbisAudioCursor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::Constructor -// Access: Protected -// Description: Reads the .wav header from the indicated stream. -// This leaves the read pointer positioned at the -// start of the data. -//////////////////////////////////////////////////////////////////// +/** + * Reads the .wav header from the indicated stream. This leaves the read + * pointer positioned at the start of the data. + */ VorbisAudioCursor:: VorbisAudioCursor(VorbisAudio *src, istream *stream) : MovieAudioCursor(src), @@ -68,23 +64,18 @@ VorbisAudioCursor(VorbisAudio *src, istream *stream) : _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ VorbisAudioCursor:: ~VorbisAudioCursor() { ov_clear(&_ov); } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::seek -// Access: Protected -// Description: Seeks to a target location. Afterward, the -// packet_time is guaranteed to be less than or -// equal to the specified time. -//////////////////////////////////////////////////////////////////// +/** + * Seeks to a target location. Afterward, the packet_time is guaranteed to be + * less than or equal to the specified time. + */ void VorbisAudioCursor:: seek(double t) { if (!vorbis_enable_seek) { @@ -112,14 +103,11 @@ seek(double t) { _samples_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::read_samples -// Access: Public, Virtual -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void VorbisAudioCursor:: read_samples(int n, PN_int16 *data) { int desired = n * _audio_channels; @@ -167,12 +155,10 @@ read_samples(int n, PN_int16 *data) { _samples_read += n; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::cb_read_func -// Access: Private, Static -// Description: Callback passed to libvorbisfile to implement -// file I/O via the VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Callback passed to libvorbisfile to implement file I/O via the + * VirtualFileSystem. + */ size_t VorbisAudioCursor:: cb_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) { istream *stream = (istream*) datasource; @@ -188,12 +174,10 @@ cb_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) { return stream->gcount(); } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::cb_seek_func -// Access: Private, Static -// Description: Callback passed to libvorbisfile to implement -// file I/O via the VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Callback passed to libvorbisfile to implement file I/O via the + * VirtualFileSystem. + */ int VorbisAudioCursor:: cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { if (!vorbis_enable_seek) { @@ -223,8 +207,7 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { } if (stream->fail()) { - // This is a fatal error and usually leads to - // a libvorbis crash. + // This is a fatal error and usually leads to a libvorbis crash. movies_cat.error() << "Failure to seek to byte " << offset; @@ -249,12 +232,10 @@ cb_seek_func(void *datasource, ogg_int64_t offset, int whence) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::cb_close_func -// Access: Private, Static -// Description: Callback passed to libvorbisfile to implement -// file I/O via the VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Callback passed to libvorbisfile to implement file I/O via the + * VirtualFileSystem. + */ int VorbisAudioCursor:: cb_close_func(void *datasource) { istream *stream = (istream*) datasource; @@ -267,12 +248,10 @@ cb_close_func(void *datasource) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: VorbisAudioCursor::cb_tell_func -// Access: Private, Static -// Description: Callback passed to libvorbisfile to implement -// file I/O via the VirtualFileSystem. -//////////////////////////////////////////////////////////////////// +/** + * Callback passed to libvorbisfile to implement file I/O via the + * VirtualFileSystem. + */ long VorbisAudioCursor:: cb_tell_func(void *datasource) { istream *stream = (istream*) datasource; diff --git a/panda/src/movies/vorbisAudioCursor.h b/panda/src/movies/vorbisAudioCursor.h index 2828b3d961..177b0a0fe4 100644 --- a/panda/src/movies/vorbisAudioCursor.h +++ b/panda/src/movies/vorbisAudioCursor.h @@ -1,16 +1,15 @@ -// Filename: vorbisAudioCursor.h -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vorbisAudioCursor.h + * @author rdb + * @date 2013-08-23 + */ #ifndef VORBISAUDIOCURSOR_H #define VORBISAUDIOCURSOR_H @@ -25,11 +24,10 @@ class VorbisAudio; -//////////////////////////////////////////////////////////////////// -// Class : VorbisAudioCursor -// Description : Interfaces with the libvorbisfile library to -// implement decoding of Ogg Vorbis audio files. -//////////////////////////////////////////////////////////////////// +/** + * Interfaces with the libvorbisfile library to implement decoding of Ogg + * Vorbis audio files. + */ class EXPCL_PANDA_MOVIES VorbisAudioCursor : public MovieAudioCursor { PUBLISHED: VorbisAudioCursor(VorbisAudio *src, istream *stream); diff --git a/panda/src/movies/wavAudio.I b/panda/src/movies/wavAudio.I index f03256aa47..4bdd999fe3 100644 --- a/panda/src/movies/wavAudio.I +++ b/panda/src/movies/wavAudio.I @@ -1,14 +1,12 @@ -// Filename: wavAudio.I -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudio.I + * @author rdb + * @date 2013-08-23 + */ diff --git a/panda/src/movies/wavAudio.cxx b/panda/src/movies/wavAudio.cxx index 7dd6f10e9b..0240c37a94 100644 --- a/panda/src/movies/wavAudio.cxx +++ b/panda/src/movies/wavAudio.cxx @@ -1,16 +1,15 @@ -// Filename: wavAudio.cxx -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudio.cxx + * @author rdb + * @date 2013-08-23 + */ #include "wavAudio.h" #include "wavAudioCursor.h" @@ -19,11 +18,9 @@ TypeHandle WavAudio::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WavAudio::Constructor -// Access: Protected -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ WavAudio:: WavAudio(const Filename &name) : MovieAudio(name) @@ -31,20 +28,16 @@ WavAudio(const Filename &name) : _filename = name; } -//////////////////////////////////////////////////////////////////// -// Function: WavAudio::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ WavAudio:: ~WavAudio() { } -//////////////////////////////////////////////////////////////////// -// Function: WavAudio::open -// Access: Published, Virtual -// Description: Open this audio, returning a MovieAudioCursor -//////////////////////////////////////////////////////////////////// +/** + * Open this audio, returning a MovieAudioCursor + */ PT(MovieAudioCursor) WavAudio:: open() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -62,11 +55,9 @@ open() { } } -//////////////////////////////////////////////////////////////////// -// Function: WavAudio::make -// Access: Published, Static -// Description: Obtains a MovieAudio that references a file. -//////////////////////////////////////////////////////////////////// +/** + * Obtains a MovieAudio that references a file. + */ PT(MovieAudio) WavAudio:: make(const Filename &name) { return DCAST(MovieAudio, new WavAudio(name)); diff --git a/panda/src/movies/wavAudio.h b/panda/src/movies/wavAudio.h index a5ea4fc513..dbef21c293 100644 --- a/panda/src/movies/wavAudio.h +++ b/panda/src/movies/wavAudio.h @@ -1,16 +1,15 @@ -// Filename: wavAudio.h -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudio.h + * @author rdb + * @date 2013-08-23 + */ #ifndef WAVAUDIO_H #define WAVAUDIO_H @@ -20,11 +19,10 @@ class WavAudioCursor; -//////////////////////////////////////////////////////////////////// -// Class : WavAudio -// Description : A native PCM .wav loader. Supported formats -// are linear PCM, IEEE float, A-law and mu-law. -//////////////////////////////////////////////////////////////////// +/** + * A native PCM .wav loader. Supported formats are linear PCM, IEEE float, + * A-law and mu-law. + */ class EXPCL_PANDA_MOVIES WavAudio : public MovieAudio { PUBLISHED: WavAudio(const Filename &name); @@ -35,7 +33,7 @@ PUBLISHED: private: friend class WavAudioCursor; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/movies/wavAudioCursor.I b/panda/src/movies/wavAudioCursor.I index 88afa719ff..e89d4d7e13 100644 --- a/panda/src/movies/wavAudioCursor.I +++ b/panda/src/movies/wavAudioCursor.I @@ -1,14 +1,12 @@ -// Filename: wavAudioCursor.I -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudioCursor.I + * @author rdb + * @date 2013-08-23 + */ diff --git a/panda/src/movies/wavAudioCursor.cxx b/panda/src/movies/wavAudioCursor.cxx index ec5dca3178..2742b41a9d 100644 --- a/panda/src/movies/wavAudioCursor.cxx +++ b/panda/src/movies/wavAudioCursor.cxx @@ -1,16 +1,15 @@ -// Filename: wavAudioCursor.cxx -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudioCursor.cxx + * @author rdb + * @date 2013-08-23 + */ #include "wavAudioCursor.h" #include "config_movies.h" @@ -90,13 +89,10 @@ static PN_int16 alaw_table[256] = { TypeHandle WavAudioCursor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WavAudioCursor::Constructor -// Access: Protected -// Description: Reads the .wav header from the indicated stream. -// This leaves the read pointer positioned at the -// start of the data. -//////////////////////////////////////////////////////////////////// +/** + * Reads the .wav header from the indicated stream. This leaves the read + * pointer positioned at the start of the data. + */ WavAudioCursor:: WavAudioCursor(WavAudio *src, istream *stream) : MovieAudioCursor(src), @@ -255,8 +251,8 @@ WavAudioCursor(WavAudio *src, istream *stream) : // We can always seek by skipping bytes, rereading if necessary. _can_seek = true; - // How to tell if a stream is seekable? We'll set it to true, and - // then change it to false as soon as we find out that we can't. + // How to tell if a stream is seekable? We'll set it to true, and then + // change it to false as soon as we find out that we can't. _can_seek_fast = true; if (_block_align != _audio_channels * _bytes_per_sample) { @@ -277,11 +273,9 @@ WavAudioCursor(WavAudio *src, istream *stream) : _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: WavAudioCursor::Destructor -// Access: Protected, Virtual -// Description: xxx -//////////////////////////////////////////////////////////////////// +/** + * xxx + */ WavAudioCursor:: ~WavAudioCursor() { if (_stream != NULL) { @@ -290,13 +284,10 @@ WavAudioCursor:: } } -//////////////////////////////////////////////////////////////////// -// Function: WavAudioCursor::seek -// Access: Protected -// Description: Seeks to a target location. Afterward, the -// packet_time is guaranteed to be less than or -// equal to the specified time. -//////////////////////////////////////////////////////////////////// +/** + * Seeks to a target location. Afterward, the packet_time is guaranteed to be + * less than or equal to the specified time. + */ void WavAudioCursor:: seek(double t) { t = max(t, 0.0); @@ -305,8 +296,7 @@ seek(double t) { if (_can_seek_fast) { _stream->seekg(pos); if (_stream->tellg() != pos) { - // Clearly, we can't seek fast. - // Fall back to the case below. + // Clearly, we can't seek fast. Fall back to the case below. _can_seek_fast = false; } } @@ -319,8 +309,7 @@ seek(double t) { _reader.skip_bytes(pos - current); } else if (pos < current) { - // We'll have to reopen the file. - //TODO + // We'll have to reopen the file. TODO } } @@ -329,14 +318,11 @@ seek(double t) { _samples_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: WavAudioCursor::read_samples -// Access: Public, Virtual -// Description: Read audio samples from the stream. N is the -// number of samples you wish to read. Your buffer -// must be equal in size to N * channels. -// Multiple-channel audio will be interleaved. -//////////////////////////////////////////////////////////////////// +/** + * Read audio samples from the stream. N is the number of samples you wish to + * read. Your buffer must be equal in size to N * channels. Multiple-channel + * audio will be interleaved. + */ void WavAudioCursor:: read_samples(int n, PN_int16 *data) { int desired = n * _audio_channels; @@ -363,8 +349,8 @@ read_samples(int n, PN_int16 *data) { break; case 3: { - // The scale factor happens to be 256 for 24-bit samples. - // That means we can just read the most significant bytes. + // The scale factor happens to be 256 for 24-bit samples. That means we + // can just read the most significant bytes. for (int i = 0; i < read_samples; ++i) { _reader.skip_bytes(1); data[i] = _reader.get_int16(); diff --git a/panda/src/movies/wavAudioCursor.h b/panda/src/movies/wavAudioCursor.h index f8d220160e..316dffedd9 100644 --- a/panda/src/movies/wavAudioCursor.h +++ b/panda/src/movies/wavAudioCursor.h @@ -1,16 +1,15 @@ -// Filename: wavAudioCursor.h -// Created by: rdb (23Aug13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wavAudioCursor.h + * @author rdb + * @date 2013-08-23 + */ #ifndef WAVAUDIOCURSOR_H #define WAVAUDIOCURSOR_H @@ -21,11 +20,10 @@ class WavAudio; -//////////////////////////////////////////////////////////////////// -// Class : WavAudioCursor -// Description : Used for reading PCM .wav files. Supported formats -// are linear PCM, IEEE float, A-law and mu-law. -//////////////////////////////////////////////////////////////////// +/** + * Used for reading PCM .wav files. Supported formats are linear PCM, IEEE + * float, A-law and mu-law. + */ class EXPCL_PANDA_MOVIES WavAudioCursor : public MovieAudioCursor { PUBLISHED: WavAudioCursor(WavAudio *src, istream *stream); diff --git a/panda/src/nativenet/buffered_datagramconnection.cxx b/panda/src/nativenet/buffered_datagramconnection.cxx index 27fbada1f4..22bfab5215 100644 --- a/panda/src/nativenet/buffered_datagramconnection.cxx +++ b/panda/src/nativenet/buffered_datagramconnection.cxx @@ -1,16 +1,15 @@ -// Filename: buffered_datagramconnection.cxx -// Created by: drose (05Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buffered_datagramconnection.cxx + * @author drose + * @date 2007-03-05 + */ #include "buffered_datagramconnection.h" @@ -20,14 +19,13 @@ TypeHandle Buffered_DatagramConnection::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::SendMessage -// Description: send the message -//////////////////////////////////////////////////////////////////// +/** + * send the message + */ bool Buffered_DatagramConnection:: SendMessage(const Datagram &msg) { if (IsConnected()) { - //printf(" DO SendMessage %d\n",msg.get_length()); + // printf(" DO SendMessage %d\n",msg.get_length()); int val = _Writer.AddData(msg.get_data(), msg.get_length(), *this); if (val >= 0) { diff --git a/panda/src/nativenet/buffered_datagramconnection.h b/panda/src/nativenet/buffered_datagramconnection.h index 3cfd6bff13..53b4b5d957 100644 --- a/panda/src/nativenet/buffered_datagramconnection.h +++ b/panda/src/nativenet/buffered_datagramconnection.h @@ -1,16 +1,25 @@ -#ifndef __NONECLOCKING_CONNECTTION_H_ -#define __NONECLOCKING_CONNECTTION_H_ -//////////////////////////////////////////////////////////////////// -// -// Ok here is the base behavior.. -// A message IO engin that is Smart enough to Do -// -// 1. Non Blocking Connect .. and Buffer the writes if needed -// 2. Handle 1 to N targets for the connection.. -// -// 3. Handle Framing and Unframing properly .. -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buffered_datagramconnection.h + * @author drose + * @date 2007-03-05 + */ + + +#ifndef __BUFFERED_DATAGRAM_CONNECTION_H__ +#define __BUFFERED_DATAGRAM_CONNECTION_H__ +/* + * Ok here is the base behavior.. A message IO engin that is Smart enough to + * Do 1. Non Blocking Connect .. and Buffer the writes if needed 2. Handle 1 + * to N targets for the connection.. 3. Handle Framing and Unframing properly + * .. + */ #include "pandabase.h" #include "socket_base.h" @@ -20,14 +29,9 @@ #include "buffered_datagramwriter.h" #include "config_nativenet.h" -//////////////////////////////////////////////////////////////////// -// there are 3 states -// -// 1. Socket not even assigned,,,, -// 2. Socket Assigned and trying to get a active connect open -// 3. Socket is open and writable.. ( Fully powered up )... -// -//////////////////////////////////////////////////////////////////// +// there are 3 states 1. Socket not even assigned,,,, 2. Socket Assigned and +// trying to get a active connect open 3. Socket is open and writable.. ( +// Fully powered up )... class EXPCL_PANDA_NATIVENET Buffered_DatagramConnection : public Socket_TCP { private: @@ -85,7 +89,8 @@ PUBLISHED: inline bool Flush(void); inline void Reset(void); - //int WaitFor_Read_Error(const Socket_fdset & fd, const Time_Span & timeout); + // int WaitFor_Read_Error(const Socket_fdset & fd, const Time_Span & + // timeout); inline void WaitForNetworkReadEvent(PN_stdfloat MaxTime) { @@ -127,10 +132,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::ClearAll -// Description: used to do a full reset of buffers -//////////////////////////////////////////////////////////////////// +/** + * used to do a full reset of buffers + */ inline void Buffered_DatagramConnection::ClearAll(void) { nativenet_cat.error() << "Buffered_DatagramConnection::ClearAll Starting Auto Reset\n"; Close(); @@ -153,11 +157,10 @@ inline bool Buffered_DatagramConnection::DoConnect(void) { } +/** + * This is the function that does the connection for us + */ /* -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::DoConnect -// Description: This is the function thah does the conection for us -//////////////////////////////////////////////////////////////////// inline bool Buffered_DatagramConnection::DoConnect(void) { if(Active() != true) { if(_LastConnectTry.Expired() != true) @@ -199,18 +202,16 @@ inline bool Buffered_DatagramConnection::DoConnect(void) { */ -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::~Buffered_DatagramConnection -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Buffered_DatagramConnection::~Buffered_DatagramConnection(void) { Close(); } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::Buffered_DatagramConnection -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Buffered_DatagramConnection::Buffered_DatagramConnection(int rbufsize, int wbufsize, int write_flush_point) : _Writer(wbufsize,write_flush_point) , _Reader(rbufsize) { @@ -229,10 +230,9 @@ inline bool Buffered_DatagramConnection::SendMessageBufferOnly(Datagram &msg) return false; } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::Init -// Description: must be called to set value to the server -//////////////////////////////////////////////////////////////////// +/** + * must be called to set value to the server + */ inline void Buffered_DatagramConnection::AddAddress(Socket_Address &inadr) { _Addresslist.push_back(inadr); @@ -242,10 +242,9 @@ inline void Buffered_DatagramConnection::ClearAddresses(void) { _Addresslist.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::GetMessage -// Description: Reads a message. Returns false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads a message. Returns false on failure. + */ inline bool Buffered_DatagramConnection::GetMessage(Datagram &val) { if(IsConnected()) @@ -265,10 +264,9 @@ inline bool Buffered_DatagramConnection::GetMessage(Datagram &val) -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::Flush -// Description: Flush all writes. -//////////////////////////////////////////////////////////////////// +/** + * Flush all writes. + */ bool Buffered_DatagramConnection::Flush(void) { if (IsConnected()) @@ -287,10 +285,9 @@ bool Buffered_DatagramConnection::Flush(void) return false; } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramConnection::Reset -// Description: Reset -//////////////////////////////////////////////////////////////////// +/** + * Reset + */ inline void Buffered_DatagramConnection::Reset() { nativenet_cat.error() << "Buffered_DatagramConnection::Reset()\n"; ClearAll(); @@ -300,4 +297,4 @@ inline bool Buffered_DatagramConnection::IsConnected(void) { return (Active() == true); } -#endif //__NONECLOCKING_CONNECTTION_H_ +#endif //__BUFFERED_DATAGRAM_CONNECTION_H__ diff --git a/panda/src/nativenet/buffered_datagramreader.I b/panda/src/nativenet/buffered_datagramreader.I index e8cb866c6d..135837ef53 100644 --- a/panda/src/nativenet/buffered_datagramreader.I +++ b/panda/src/nativenet/buffered_datagramreader.I @@ -1,43 +1,36 @@ -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramReader::GetMessageInplace -// Description: A function that will peal a core message of the input buffer -// -//////////////////////////////////////////////////////////////////// -inline bool Buffered_DatagramReader::GetMessageFromBuffer(Datagram &inmsg) -{ - bool answer = false; - size_t DataAvail = FastAmountBeffered(); - if(DataAvail >= sizeof(short)) - { - char *ff = FastGetMessageHead(); - unsigned short len=GetUnsignedShort(ff); - len += sizeof(unsigned short); - if(len <= DataAvail) - { - inmsg.assign(ff+2,len-2); - _StartPos += len; - answer = true; - } - } - return answer; -} -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramReader::Buffered_DatagramReader -// Description: constructore .. passes size up to ring buffer -// -//////////////////////////////////////////////////////////////////// -inline Buffered_DatagramReader::Buffered_DatagramReader(int in_size) : RingBuffer(in_size) -{ +/** + * A function that will peal a core message of the input buffer + */ +inline bool Buffered_DatagramReader:: +GetMessageFromBuffer(Datagram &inmsg) { + bool answer = false; + size_t DataAvail = FastAmountBeffered(); + if (DataAvail >= sizeof(short)) { + char *ff = FastGetMessageHead(); + unsigned short len=GetUnsignedShort(ff); + len += sizeof(unsigned short); + if (len <= DataAvail) { + inmsg.assign(ff + 2, len - 2); + _StartPos += len; + answer = true; + } + } + return answer; } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramReader::ReSet -// Description: Reaset all read content.. IE zero's out buffer... -// -// If you lose framing this will not help -// -//////////////////////////////////////////////////////////////////// -inline void Buffered_DatagramReader::ReSet(void) -{ - ResetContent(); +/** + * Constructor. Passes size up to ring buffer. + */ +inline Buffered_DatagramReader:: +Buffered_DatagramReader(int in_size) : RingBuffer(in_size) { +} + +/** + * Reset all read content, ie. zeroes out buffer. + * + * If you lose framing, this will not help. + */ +inline void Buffered_DatagramReader:: +ReSet(void) { + ResetContent(); } diff --git a/panda/src/nativenet/buffered_datagramreader.h b/panda/src/nativenet/buffered_datagramreader.h index 6627c78572..b500f4c290 100644 --- a/panda/src/nativenet/buffered_datagramreader.h +++ b/panda/src/nativenet/buffered_datagramreader.h @@ -19,10 +19,8 @@ class Buffered_DatagramReader : protected RingBuffer public: inline Buffered_DatagramReader(int in_size = 8192) ; inline void ReSet(void); - // - // SOCK_TYPE is used to allow for - // abstract socket type to be used .. - // see socket_tcp and socket_ssl + // SOCK_TYPE is used to allow for abstract socket type to be used .. see + // socket_tcp and socket_ssl template < class SOCK_TYPE> inline int PumpMessageReader(Datagram &inmsg, SOCK_TYPE &sck) @@ -59,7 +57,7 @@ public: int gotbytes = sck.RecvData(ff,(int)readsize); if(gotbytes < 0) // some error { - //int er = GETERROR(); + // int er = GETERROR(); if(!sck.ErrorIs_WouldBlocking(gotbytes) ) { answer = -3; // hard error ? @@ -94,4 +92,3 @@ public: #include "buffered_datagramreader.I" #endif //__BUFFEREDREADER_GM_H__ - diff --git a/panda/src/nativenet/buffered_datagramwriter.h b/panda/src/nativenet/buffered_datagramwriter.h index c33ef8e66d..516aa0dffd 100644 --- a/panda/src/nativenet/buffered_datagramwriter.h +++ b/panda/src/nativenet/buffered_datagramwriter.h @@ -2,20 +2,19 @@ #define __BufferedWriter_H__ #include "ringbuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : Buffered_DatagramWriter -// Description : This is the buffered writer.. it is used to buffer up -// Coremessages and arbitrary data.. -// -// GmCoreMessage -// -// -// You must commit all rights to a socket with flush and -// flush may be called internall if the buffersize is about -// to overrun.. This class does guaranty no partial message -// rights at least to the TCP layer.. -// -//////////////////////////////////////////////////////////////////// +/** + * This is the buffered writer.. it is used to buffer up Coremessages and + * arbitrary data.. + * + * GmCoreMessage + * + + * + * You must commit all rights to a socket with flush and flush may be called + * internall if the buffersize is about to overrun.. This class does guaranty + * no partial message rights at least to the TCP layer.. + * + */ class Buffered_DatagramWriter : public RingBuffer { int _flush_point; @@ -76,28 +75,21 @@ public: }; }; -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramWriter::ReSet -// Description: used to clear the buffrers ... -// use of this in mid stream is a very bad thing as -// you can not guarany network writes are message alligned -//////////////////////////////////////////////////////////////////// +/** + * used to clear the buffrers ... use of this in mid stream is a very bad + * thing as you can not guarany network writes are message alligned + */ inline void Buffered_DatagramWriter::ReSet(void) { ResetContent(); } -//////////////////////////////////////////////////////////////////// -// Buffered_DatagramWriter::Buffered_DatagramWriter -// -// -//////////////////////////////////////////////////////////////////// +// Buffered_DatagramWriter::Buffered_DatagramWriter inline Buffered_DatagramWriter::Buffered_DatagramWriter( size_t in_size , int in_flush_point) : RingBuffer(in_size) { _flush_point = in_flush_point; } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramWriter::AddData -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Buffered_DatagramWriter::AddData(const void * data, size_t len, Socket_TCP &sck) { int answer = 0; @@ -116,10 +108,9 @@ inline int Buffered_DatagramWriter::AddData(const void * data, size_t len, Socke return answer; } -//////////////////////////////////////////////////////////////////// -// Function: Buffered_DatagramWriter::AddData -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Buffered_DatagramWriter::AddData(const void * data, size_t len) { int answer = -1; @@ -136,4 +127,3 @@ inline int Buffered_DatagramWriter::AddData(const void * data, size_t len) return answer; } #endif //__BufferedWriter_H__ - diff --git a/panda/src/nativenet/config_nativenet.cxx b/panda/src/nativenet/config_nativenet.cxx index 2f21f2b087..c74a8ca6e2 100644 --- a/panda/src/nativenet/config_nativenet.cxx +++ b/panda/src/nativenet/config_nativenet.cxx @@ -1,16 +1,15 @@ -// Filename: config_nativenet.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_nativenet.cxx + * @author drose + * @date 2007-03-01 + */ #include "config_nativenet.h" @@ -35,14 +34,12 @@ ConfigureFn(config_nativenet) { } -//////////////////////////////////////////////////////////////////// -// Function: init_libnativenet -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libnativenet() { static bool initialized = false; @@ -67,4 +64,3 @@ init_libnativenet() { init_network(); } - diff --git a/panda/src/nativenet/config_nativenet.h b/panda/src/nativenet/config_nativenet.h index 1269323860..725d003289 100644 --- a/panda/src/nativenet/config_nativenet.h +++ b/panda/src/nativenet/config_nativenet.h @@ -1,16 +1,15 @@ -// Filename: config_nativenet.h -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_nativenet.h + * @author drose + * @date 2007-03-01 + */ #ifndef CONFIG_NATIVENET_H #define CONFIG_NATIVENET_H @@ -25,4 +24,3 @@ NotifyCategoryDecl(nativenet, EXPCL_PANDA_NATIVENET, EXPTP_PANDA_NATIVENET); extern EXPCL_PANDA_NATIVENET void init_libnativenet(); #endif - diff --git a/panda/src/nativenet/membuffer.I b/panda/src/nativenet/membuffer.I index e54d92d010..157df8301a 100644 --- a/panda/src/nativenet/membuffer.I +++ b/panda/src/nativenet/membuffer.I @@ -1,9 +1,8 @@ #define MEMBUF_THRASH_SIZE 25 -///////////////////////////////////////////////////////////// -// Function: MemBuffer::ClearBuffer -// Description: Releases all resources(Memory USed) is locally allocated -////////////////////////////////////////////////////////// +/** + * Releases all resources(Memory USed) is locally allocated + */ inline void MemBuffer:: ClearBuffer(void) { if (_BufferLocal == true) { @@ -15,10 +14,9 @@ ClearBuffer(void) { } } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::AllocBuffer -// Description: Locally allocate a new buffer -////////////////////////////////////////////////////////// +/** + * Locally allocate a new buffer + */ inline void MemBuffer:: AllocBuffer(size_t len) { _Buffer = new char[len]; @@ -26,10 +24,9 @@ AllocBuffer(size_t len) { _BufferLen = len; } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::MemBuffer -// Description: default constructor -////////////////////////////////////////////////////////// +/** + * default constructor + */ inline MemBuffer:: MemBuffer(void) { _Buffer = NULL; @@ -37,19 +34,17 @@ MemBuffer(void) { _BufferLen = 0; } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::MemBuffer -// Description: Constructure to locall allocate a buffer -////////////////////////////////////////////////////////// +/** + * Constructure to locall allocate a buffer + */ inline MemBuffer:: MemBuffer(size_t len) { AllocBuffer(len); } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::MemBuffer -// Description: Constructure to use an external buffer -////////////////////////////////////////////////////////// +/** + * Constructure to use an external buffer + */ inline MemBuffer:: MemBuffer(char *data, size_t len) { _BufferLocal = false; @@ -57,19 +52,17 @@ MemBuffer(char *data, size_t len) { _Buffer = data; } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::~MemBuffer -// Description: CLean UP a mess on Deletion -////////////////////////////////////////////////////////// +/** + * CLean UP a mess on Deletion + */ inline MemBuffer:: ~MemBuffer() { ClearBuffer(); } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::SetBuffer -// Description: Assigns a buffer -////////////////////////////////////////////////////////// +/** + * Assigns a buffer + */ inline void MemBuffer:: SetBuffer(char * data, size_t len) { if (_BufferLocal == true) { @@ -81,12 +74,11 @@ SetBuffer(char * data, size_t len) { _Buffer = data; } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::GrowBuffer -// Description: Grow a buffer is needed to get to a sertion size -// No care is made here to preserve convtent unlike a vector of chars -// -////////////////////////////////////////////////////////// +/** + * Grow a buffer is needed to get to a sertion size No care is made here to + * preserve convtent unlike a vector of chars + * + */ inline void MemBuffer:: GrowBuffer(size_t new_len) { if (new_len >= _BufferLen) { @@ -107,19 +99,17 @@ GrowBuffer(size_t new_len) { } } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::GetBufferSize -// Description: Access to the BUffer Size Information -////////////////////////////////////////////////////////// +/** + * Access to the BUffer Size Information + */ inline size_t MemBuffer:: GetBufferSize(void) const { return _BufferLen; } -///////////////////////////////////////////////////////////// -// Function: MemBuffer::GetBuffer -// Description: Access to the actual BUffer -////////////////////////////////////////////////////////// +/** + * Access to the actual BUffer + */ inline char *MemBuffer:: GetBuffer(void) { return _Buffer; @@ -130,10 +120,9 @@ GetBuffer(void) const { return _Buffer; } -//////////////////////////////////////////////////////////////////// -// Function: MemBuffer::InBufferRange -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool MemBuffer:: InBufferRange(char *inpos) { return (inpos >= _Buffer && inpos <= (_Buffer + _BufferLen)); diff --git a/panda/src/nativenet/membuffer.h b/panda/src/nativenet/membuffer.h index ffda6af026..429dc36ec1 100644 --- a/panda/src/nativenet/membuffer.h +++ b/panda/src/nativenet/membuffer.h @@ -1,20 +1,6 @@ #ifndef __MEMBUFFER_GM_H__ #define __MEMBUFFER_GM_H__ -// RHH -//////////////////////////////////////////////////////////////////// -// Class : GmMemBuf -// Description : This a base class designed to be used to for items -// that will share portions of a memory buffer and -// want to avoid copying the data. -// -// Use if the class wants to allow for reference in -// place of data arrays. -// ** be careful could be dangerous ** -// -// GmCoreMessage -// GmRingBuffer -//////////////////////////////////////////////////////////////////// class EXPCL_PANDA_NATIVENET MemBuffer { public: inline MemBuffer(void); diff --git a/panda/src/nativenet/ringbuffer.I b/panda/src/nativenet/ringbuffer.I index d5e06f5318..45b37b86ef 100644 --- a/panda/src/nativenet/ringbuffer.I +++ b/panda/src/nativenet/ringbuffer.I @@ -1,160 +1,148 @@ -///////////////////////////////////////////////////////////// -// Function: RingBuffer::GetMessageHead -// Description: This will get a pointer to the fist undelivered data in buffer -////////////////////////////////////////////////////////// -inline char * RingBuffer::GetMessageHead(void) +/** + * This will get a pointer to the fist undelivered data in buffer + */ +inline char * RingBuffer::GetMessageHead(void) { - return _Buffer+_StartPos; + return _Buffer+_StartPos; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::GetBufferOpen -// Description: This will get the first writabe section of the buffer space -////////////////////////////////////////////////////////// -inline char * RingBuffer::GetBufferOpen(void) +/** + * This will get the first writabe section of the buffer space + */ +inline char * RingBuffer::GetBufferOpen(void) { - return _Buffer+_EndPos; + return _Buffer+_EndPos; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::ForceWindowSlide -// Description: Will force a compression of data // shift left to start position -////////////////////////////////////////////////////////// +/** + * Will force a compression of data // shift left to start position + */ inline void RingBuffer::ForceWindowSlide(void) { - size_t len = AmountBuffered(); - if(len > 0 && _StartPos != 0) // basic flush left.. - { - memmove(_Buffer,GetMessageHead(),len); - _StartPos = 0; - _EndPos = len; - } + size_t len = AmountBuffered(); + if(len > 0 && _StartPos != 0) // basic flush left.. + { + memmove(_Buffer,GetMessageHead(),len); + _StartPos = 0; + _EndPos = len; + } } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::AmountBuffered -// Description: Will report the number of unread chars in buffer -////////////////////////////////////////////////////////// -inline size_t RingBuffer::AmountBuffered(void) +/** + * Will report the number of unread chars in buffer + */ +inline size_t RingBuffer::AmountBuffered(void) { - return _EndPos - _StartPos; + return _EndPos - _StartPos; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::BufferAvailabe -// Description: Will report amount of data that is contiguas that can be writen at -// the location returned by GetBufferOpen -////////////////////////////////////////////////////////// +/** + * Will report amount of data that is contiguas that can be writen at the + * location returned by GetBufferOpen + */ inline size_t RingBuffer::BufferAvailabe(void) { - return GetBufferSize() - _EndPos; + return GetBufferSize() - _EndPos; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::ResetContent -// Description: Throw away all inread information -////////////////////////////////////////////////////////// +/** + * Throw away all inread information + */ void RingBuffer::ResetContent(void) { - _StartPos = 0; - _EndPos = 0; + _StartPos = 0; + _EndPos = 0; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::RingBuffer -// Description: -////////////////////////////////////////////////////////// +/** + * + */ inline RingBuffer::RingBuffer(size_t in_size) : MemBuffer(in_size) { - _EndPos = 0; - _StartPos = 0; + _EndPos = 0; + _StartPos = 0; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::FullCompress -// Description: Force a compress of the data -////////////////////////////////////////////////////////// +/** + * Force a compress of the data + */ inline void RingBuffer::FullCompress(void) { - if(_StartPos == _EndPos) - { - _StartPos = 0; - _EndPos = 0; - } - else - { - ForceWindowSlide(); - } + if(_StartPos == _EndPos) + { + _StartPos = 0; + _EndPos = 0; + } + else + { + ForceWindowSlide(); + } } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::Compress -// Description: Try and do a intelegent compress of the data space -// the algorithem is really stupid right know.. just say if i have -// read past 1/2 my space do a compress...Im open for sugestions -// -// -////////////////////////////////////////////////////////// +/** + * Try and do a intelegent compress of the data space the algorithem is really + * stupid right know.. just say if i have read past 1/2 my space do a + * compress...Im open for sugestions + * + + * + */ inline void RingBuffer::Compress(void) { - if(_StartPos == _EndPos) - { - _StartPos = 0; - _EndPos = 0; - } - else if(_StartPos >= GetBufferSize() / 2) - { - ForceWindowSlide(); - } + if(_StartPos == _EndPos) + { + _StartPos = 0; + _EndPos = 0; + } + else if(_StartPos >= GetBufferSize() / 2) + { + ForceWindowSlide(); + } } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::Put -// Description: Adds Data to a ring Buffer -// Will do a compress if needed so pointers suplied by Get Call are no longer valide -// -////////////////////////////////////////////////////////// +/** + * Adds Data to a ring Buffer Will do a compress if needed so pointers suplied + * by Get Call are no longer valide + * + */ inline bool RingBuffer::Put(const char * data, size_t len) { - bool answer = false; + bool answer = false; - if(len > BufferAvailabe() ) - Compress(); + if(len > BufferAvailabe() ) + Compress(); - if(len <= BufferAvailabe() ) - { - memcpy(GetBufferOpen(),data,len); - _EndPos += len; - answer = true; - } - return answer; + if(len <= BufferAvailabe() ) + { + memcpy(GetBufferOpen(),data,len); + _EndPos += len; + answer = true; + } + return answer; } -//////////////////////////////////////////////////////////////////// -// Function: RingBuffer::PutFast -// Description: -// -//////////////////////////////////////////////////////////////////// +/** + * + + * + */ inline bool RingBuffer::PutFast(const char * data, size_t len) { - // no checking be carefull - memcpy(GetBufferOpen(),data,len); // should i be using memcopy.. - _EndPos += len; - return true; + // no checking be carefull + memcpy(GetBufferOpen(),data,len); // should i be using memcopy.. + _EndPos += len; + return true; } -///////////////////////////////////////////////////////////// -// Function: RingBuffer::Get -// Description: will copy the data .. -// false indicates not enogh data to read .. sorry... -// -////////////////////////////////////////////////////////// +/** + * will copy the data .. false indicates not enogh data to read .. sorry... + * + */ inline bool RingBuffer::Get(char * data, size_t len) { - bool answer = false; + bool answer = false; - if(len <= AmountBuffered() ) - { - memcpy(data,GetMessageHead(),len); - _StartPos += len; - Compress(); - answer = true; - } - return answer; + if(len <= AmountBuffered() ) + { + memcpy(data,GetMessageHead(),len); + _StartPos += len; + Compress(); + answer = true; + } + return answer; } - diff --git a/panda/src/nativenet/ringbuffer.h b/panda/src/nativenet/ringbuffer.h index c7f4331b6e..b821becd9e 100644 --- a/panda/src/nativenet/ringbuffer.h +++ b/panda/src/nativenet/ringbuffer.h @@ -3,17 +3,6 @@ #include "membuffer.h" -// RHH -//////////////////////////////////////////////////////////////////// -// Class : GmRingBuffer -// Description : This is an implemention of the membuffer with ring -// buffer interface on it. -// -// Main target right know is base class for network -// stream buffering both input and output -// -// See also BufferedReader_Gm and BufferedWriter_Gm. -//////////////////////////////////////////////////////////////////// class EXPCL_PANDA_NATIVENET RingBuffer : protected MemBuffer { protected: size_t _StartPos; @@ -42,4 +31,3 @@ public: #include "ringbuffer.I" #endif //__RINGBUFFER_GM_H__ - diff --git a/panda/src/nativenet/socket_address.I b/panda/src/nativenet/socket_address.I index 38d7222d45..6a20ced62c 100644 --- a/panda/src/nativenet/socket_address.I +++ b/panda/src/nativenet/socket_address.I @@ -1,33 +1,27 @@ -// Filename: socket_address.I -// Created by: rdb (19Oct14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_address.I + * @author rdb + * @date 2014-10-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::GetIPAdddressRaw -// Access: Public -// Description: Return a RAW sockaddr_in -//////////////////////////////////////////////////////////////////// +/** + * Return a RAW sockaddr_in + */ INLINE unsigned long Socket_Address:: GetIPAddressRaw() const { return _addr.sin_addr.s_addr; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address -// Access: Published -// Description: Constructor that lets us set a port value -//////////////////////////////////////////////////////////////////// +/** + * Constructor that lets us set a port value + */ INLINE Socket_Address:: Socket_Address(unsigned short port) { _addr.sin_family = AF_INET; @@ -35,11 +29,9 @@ Socket_Address(unsigned short port) { _addr.sin_port = htons(port); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::Copy constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Socket_Address:: Socket_Address(const Socket_Address &inaddr) { _addr.sin_family = inaddr._addr.sin_family; @@ -47,11 +39,9 @@ Socket_Address(const Socket_Address &inaddr) { _addr.sin_port = inaddr._addr.sin_port; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Socket_Address:: Socket_Address(const AddressType &inaddr) { _addr.sin_family = inaddr.sin_family; @@ -59,20 +49,16 @@ Socket_Address(const AddressType &inaddr) { _addr.sin_port = inaddr.sin_port; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::~Destructor -// Access: Published -// Description: Normal Destructor -//////////////////////////////////////////////////////////////////// +/** + * Normal Destructor + */ INLINE Socket_Address:: ~Socket_Address() { } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Socket_Address:: operator == (const Socket_Address &in) const { return ((_addr.sin_family == in._addr.sin_family) && @@ -80,11 +66,9 @@ operator == (const Socket_Address &in) const { (_addr.sin_port == in._addr.sin_port)); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Socket_Address:: operator != (const Socket_Address &in) const { return ((_addr.sin_family != in._addr.sin_family) || @@ -92,11 +76,9 @@ operator != (const Socket_Address &in) const { (_addr.sin_port != in._addr.sin_port)); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_broadcast -// Access: Published -// Description: Set to the broadcast address and a specified port -//////////////////////////////////////////////////////////////////// +/** + * Set to the broadcast address and a specified port + */ INLINE bool Socket_Address:: set_broadcast(unsigned short port) { _addr.sin_family = AF_INET; @@ -105,11 +87,9 @@ set_broadcast(unsigned short port) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_any_IP -// Access: Published -// Description: Set to any address and a specified port -//////////////////////////////////////////////////////////////////// +/** + * Set to any address and a specified port + */ INLINE bool Socket_Address:: set_any_IP(unsigned short port) { _addr.sin_family = AF_INET; @@ -118,22 +98,18 @@ set_any_IP(unsigned short port) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_port -// Access: Published -// Description: Set to a specified port -//////////////////////////////////////////////////////////////////// +/** + * Set to a specified port + */ INLINE bool Socket_Address:: set_port(unsigned short port) { _addr.sin_port = htons(port); return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::clear -// Access: Published -// Description: Set the internal values to a suitable known value -//////////////////////////////////////////////////////////////////// +/** + * Set the internal values to a suitable known value + */ INLINE void Socket_Address:: clear() { _addr.sin_family = AF_INET; @@ -141,31 +117,25 @@ clear() { _addr.sin_port = htons(0); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::get_port -// Access: Published -// Description: Get the port portion as an integer -//////////////////////////////////////////////////////////////////// +/** + * Get the port portion as an integer + */ INLINE unsigned short Socket_Address:: get_port() const { return ntohs(_addr.sin_port); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::get_ip -// Access: Published -// Description: Return the IP address portion in dot notation string -//////////////////////////////////////////////////////////////////// +/** + * Return the IP address portion in dot notation string + */ INLINE std::string Socket_Address:: get_ip() const { return std::string(inet_ntoa(_addr.sin_addr)); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::get_ip_port -// Access: Published -// Description: Return the ip address/port in dot notation string -//////////////////////////////////////////////////////////////////// +/** + * Return the ip address/port in dot notation string + */ INLINE std::string Socket_Address:: get_ip_port() const { char buf1[100]; // 100 is more than enough for any ip address:port combo.. @@ -173,27 +143,20 @@ get_ip_port() const { return std::string(buf1); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_host -// Access: Published -// Description: This function will take a port and string-based -// TCP address and initialize the address with this -// information. Returns true on success; on failure, -// it returns false and the address may be undefined. -//////////////////////////////////////////////////////////////////// +/** + * This function will take a port and string-based TCP address and initialize + * the address with this information. Returns true on success; on failure, it + * returns false and the address may be undefined. + */ INLINE bool Socket_Address:: set_host(const std::string &hostname, unsigned short port) { struct hostent *hp = NULL; - // - // hmm inet_addr does not resolve 255.255.255.255 on ME/98 ?? - // - // * HACK * ?? + // hmm inet_addr does not resolve 255.255.255.255 on ME98 ?? * HACK * ?? if (hostname == "255.255.255.255") { return set_broadcast(port); } - // - // + PN_uint32 addr = (PN_uint32)inet_addr(hostname.c_str()); if (addr == INADDR_NONE) { @@ -212,11 +175,9 @@ set_host(const std::string &hostname, unsigned short port) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_host -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Socket_Address:: set_host(const std::string &hostname) { std::string::size_type pos = hostname.find(':'); @@ -230,11 +191,9 @@ set_host(const std::string &hostname) { return set_host(host, port_dig); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Address::set_host -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Socket_Address:: set_host(PN_uint32 in_hostname, unsigned short port) { memcpy(&_addr.sin_addr, &in_hostname, sizeof(in_hostname)); @@ -243,11 +202,9 @@ set_host(PN_uint32 in_hostname, unsigned short port) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool Socket_Address:: operator < (const Socket_Address &in) const { if (_addr.sin_port < in._addr.sin_port) @@ -265,14 +222,12 @@ operator < (const Socket_Address &in) const { return (_addr.sin_family < in._addr.sin_family); } -//////////////////////////////////////////////////////////////////// -// Function: is_mcast_range -// Access: Published -// Description: True if the address is in the multicast range. -//////////////////////////////////////////////////////////////////// +/** + * True if the address is in the multicast range. + */ INLINE bool Socket_Address:: is_mcast_range(void) const { PN_uint32 address = ntohl(_addr.sin_addr.s_addr); - //224.0.0.0-239.255.255.255 .. e0,ef + // 224.0.0.0-239.255.255.255 .. e0,ef return (address >= 0xe0000000 && address < 0xefffffff); } diff --git a/panda/src/nativenet/socket_address.h b/panda/src/nativenet/socket_address.h index 45fe537918..a185238e1d 100644 --- a/panda/src/nativenet/socket_address.h +++ b/panda/src/nativenet/socket_address.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_address.h + * @author rdb + * @date 2014-10-19 + */ + + #ifndef SOCKET_ADDRESS_H #define SOCKET_ADDRESS_H @@ -5,11 +19,10 @@ #include "numeric_types.h" #include "socket_portable.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_Address -// Description : A simple place to store and munipulate tcp and port -// address for communication layer -//////////////////////////////////////////////////////////////////// +/** + * A simple place to store and munipulate tcp and port address for + * communication layer + */ class EXPCL_PANDA_NATIVENET Socket_Address { public: typedef struct sockaddr_in AddressType; diff --git a/panda/src/nativenet/socket_base.h b/panda/src/nativenet/socket_base.h index 12cc93be36..173118a942 100644 --- a/panda/src/nativenet/socket_base.h +++ b/panda/src/nativenet/socket_base.h @@ -1,9 +1,7 @@ #ifndef __SOCKET_BASE_H__ #define __SOCKET_BASE_H__ -//////////////////////////////////////////////////////////////////// // Quick way to get all the network code defined -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include "socket_portable.h" #include "socket_address.h" diff --git a/panda/src/nativenet/socket_fdset.h b/panda/src/nativenet/socket_fdset.h index 8ce80b4071..3f3edc711a 100644 --- a/panda/src/nativenet/socket_fdset.h +++ b/panda/src/nativenet/socket_fdset.h @@ -1,16 +1,13 @@ #ifndef __SOCKET_FDSET_H__ #define __SOCKET_FDSET_H__ -//////////////////////////////////////////////////////////////////// -// -//rhh -// This class needs to be broken into 2 classes: the gathering class and the processing functions. -// The functions should be set up as template functions -// -// Add a helper class socket_select. May want to totally separate the select and collect functionality -// fits more with the normal Berkeley mind set... ** Not ** Should think about using POLL() on BSD-based systems -// -//////////////////////////////////////////////////////////////////// +/* + * rhh This class needs to be broken into 2 classes: the gathering class and + * the processing functions. The functions should be set up as template + * functions Add a helper class socket_select. May want to totally separate + * the select and collect functionality fits more with the normal Berkeley + * mind set... ** Not ** Should think about using POLL() on BSD-based systems + */ #include "pandabase.h" #include "numeric_types.h" #include "time_base.h" @@ -41,18 +38,17 @@ private: #endif }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::Socket_fdset -// Description: The constructor -//////////////////////////////////////////////////////////////////// +/** + * The constructor + */ inline Socket_fdset::Socket_fdset() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::setForSocketNative -// Description: This does the physical manipulation of the set getting read for the base call -//////////////////////////////////////////////////////////////////// +/** + * This does the physical manipulation of the set getting read for the base + * call + */ inline void Socket_fdset::setForSocketNative(SOCKET inid) { assert( inid >= 0); @@ -65,12 +61,10 @@ inline void Socket_fdset::setForSocketNative(SOCKET inid) _maxid = inid; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::isSetForNative -// Description: Answer the question: was the socket marked for reading? -// there's a subtle difference in the NSPR version: it will respond if -// the socket had an error -//////////////////////////////////////////////////////////////////// +/** + * Answer the question: was the socket marked for reading? there's a subtle + * difference in the NSPR version: it will respond if the socket had an error + */ inline bool Socket_fdset::isSetForNative(SOCKET inid) const { assert( inid >= 0); @@ -81,19 +75,17 @@ inline bool Socket_fdset::isSetForNative(SOCKET inid) const return (FD_ISSET(inid, &_the_set) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::IsSetFor -// Description: check to see if a socket object has been marked for reading -//////////////////////////////////////////////////////////////////// +/** + * check to see if a socket object has been marked for reading + */ inline bool Socket_fdset::IsSetFor(const Socket_IP & incon) const { return isSetForNative(incon.GetSocket()); } -//////////////////////////////////////////////////////////////////// -// Function: WaitForRead -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Socket_fdset::WaitForRead(bool zeroFds, PN_uint32 sleep_time) { int retVal = 0; @@ -112,10 +104,9 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, PN_uint32 sleep_time) return retVal; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::WaitForRead -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Socket_fdset::WaitForRead(bool zeroFds, const Time_Span & timeout) { timeval localtv = timeout.GetTval(); @@ -127,30 +118,27 @@ inline int Socket_fdset::WaitForRead(bool zeroFds, const Time_Span & timeout) return retVal; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::zeroOut -// Description: Marks the content as empty -//////////////////////////////////////////////////////////////////// +/** + * Marks the content as empty + */ inline void Socket_fdset::clear() { _maxid = 0; FD_ZERO(&_the_set); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::setForSocket -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Socket_fdset::setForSocket(const Socket_IP &incon) { setForSocketNative(incon.GetSocket()); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::WaitForWrite -// Description: This is the function that will wait till -// one of the sockets is ready for writing -//////////////////////////////////////////////////////////////////// +/** + * This is the function that will wait till one of the sockets is ready for + * writing + */ inline int Socket_fdset::WaitForWrite(bool zeroFds, PN_uint32 sleep_time) { int retVal = 0; @@ -172,11 +160,10 @@ inline int Socket_fdset::WaitForWrite(bool zeroFds, PN_uint32 sleep_time) return retVal; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_fdset::WaitForError -// Description: This is the function that will wait till -// one of the sockets is in error state -//////////////////////////////////////////////////////////////////// +/** + * This is the function that will wait till one of the sockets is in error + * state + */ inline int Socket_fdset::WaitForError(bool zeroFds, PN_uint32 sleep_time) { int retVal = 0; diff --git a/panda/src/nativenet/socket_ip.cxx b/panda/src/nativenet/socket_ip.cxx index 6c90191f1d..f77b9a4c05 100644 --- a/panda/src/nativenet/socket_ip.cxx +++ b/panda/src/nativenet/socket_ip.cxx @@ -1,16 +1,15 @@ -// Filename: socket_ip.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_ip.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_ip.h" diff --git a/panda/src/nativenet/socket_ip.h b/panda/src/nativenet/socket_ip.h index 5fec7fd786..9094dac03b 100644 --- a/panda/src/nativenet/socket_ip.h +++ b/panda/src/nativenet/socket_ip.h @@ -13,19 +13,16 @@ class Socket_TCP_Listen; class Socket_UDP_Incoming; class Socket_UDP_Outgoing; -//////////////////////////////////////////////////////////////////// -// Class : Socket_IP -// Description : Base functionality for a INET domain Socket -// This call should be the starting point for all other -// unix domain sockets. -// -// SocketIP -// | -// ------------------------------------------------------------------- -// | | | | -// SocketTCP SocketTCP_Listen SocketUDP_Incoming SocketUDP_OutBound -// -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a INET domain Socket This call should be the + * starting point for all other unix domain sockets. + * + * SocketIP | + * ------------------------------------------------------------------- | + * | | | SocketTCP + * SocketTCP_Listen SocketUDP_Incoming SocketUDP_OutBound + * + */ class EXPCL_PANDA_NATIVENET Socket_IP : public TypedObject { public: PUBLISHED: @@ -78,10 +75,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::ErrorClose -// Description: Used by internal to force a close. Returns false. -//////////////////////////////////////////////////////////////////// +/** + * Used by internal to force a close. Returns false. + */ inline bool Socket_IP:: ErrorClose() { if (Active()) { @@ -92,46 +88,41 @@ ErrorClose() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::Active -// Description: Ask if the socket is open (allocated) -//////////////////////////////////////////////////////////////////// +/** + * Ask if the socket is open (allocated) + */ inline bool Socket_IP:: Active() { return (_socket != BAD_SOCKET); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::Socket_IP -// Description: Def Constructor -//////////////////////////////////////////////////////////////////// +/** + * Def Constructor + */ inline Socket_IP:: Socket_IP() { _socket = BAD_SOCKET; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::SetSocket -// Description: Assigns an existing socket to this class -//////////////////////////////////////////////////////////////////// +/** + * Assigns an existing socket to this class + */ inline Socket_IP:: Socket_IP(SOCKET ins) { _socket = ins; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::~Socket_IP -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ inline Socket_IP:: ~Socket_IP() { Close(); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::Close -// Description: Closes a socket if it is open (allocated). -//////////////////////////////////////////////////////////////////// +/** + * Closes a socket if it is open (allocated). + */ inline void Socket_IP:: Close() { if (Active()) { @@ -141,29 +132,26 @@ Close() { _socket = BAD_SOCKET; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::GetLastError -// Description: Gets the last errcode from a socket operation. -//////////////////////////////////////////////////////////////////// +/** + * Gets the last errcode from a socket operation. + */ inline int Socket_IP:: GetLastError() { return GETERROR(); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::SetSocket -// Description: Assigns an existing socket to this class -//////////////////////////////////////////////////////////////////// +/** + * Assigns an existing socket to this class + */ inline void Socket_IP:: SetSocket(SOCKET ins) { Close(); _socket = ins; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::SetRecvBufferSize -// Description: Ok it sets the recv buffer size for both tcp and UDP -//////////////////////////////////////////////////////////////////// +/** + * Ok it sets the recv buffer size for both tcp and UDP + */ int Socket_IP:: SetRecvBufferSize(int insize) { if (setsockopt(_socket, (int) SOL_SOCKET, (int) SO_RCVBUF, (char *) &insize, sizeof(int))) { @@ -173,10 +161,9 @@ SetRecvBufferSize(int insize) { return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: SetNonBlocking -// Description: this function will throw a socket into non-blocking mode -//////////////////////////////////////////////////////////////////// +/** + * this function will throw a socket into non-blocking mode + */ inline int Socket_IP:: SetNonBlocking() { #ifdef BSDBLOCK @@ -195,11 +182,10 @@ SetNonBlocking() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::SetBlocking -// Description: Set the socket to block on subsequent calls to -// socket functions that address this socket -//////////////////////////////////////////////////////////////////// +/** + * Set the socket to block on subsequent calls to socket functions that + * address this socket + */ inline int Socket_IP:: SetBlocking() { #ifdef BSDBLOCK @@ -218,10 +204,9 @@ SetBlocking() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: SetReuseAddress -// Description: Informs a socket to reuse IP address as needed -//////////////////////////////////////////////////////////////////// +/** + * Informs a socket to reuse IP address as needed + */ inline bool Socket_IP:: SetReuseAddress(bool flag) { int bOption = flag; @@ -231,28 +216,25 @@ SetReuseAddress(bool flag) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::GetSocket -// Description: Gets the base socket type -//////////////////////////////////////////////////////////////////// +/** + * Gets the base socket type + */ inline SOCKET Socket_IP:: GetSocket() { return _socket; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::GetSocket -// Description: Get The RAW file id of the socket -//////////////////////////////////////////////////////////////////// +/** + * Get The RAW file id of the socket + */ inline SOCKET Socket_IP:: GetSocket() const { return _socket; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_IP::GetPeerName -// Description: Wrapper on berkly getpeername... -//////////////////////////////////////////////////////////////////// +/** + * Wrapper on berkly getpeername... + */ inline Socket_Address Socket_IP:: GetPeerName(void) const { sockaddr_in name; diff --git a/panda/src/nativenet/socket_portable.h b/panda/src/nativenet/socket_portable.h index 010fcac17c..2a80c735f3 100644 --- a/panda/src/nativenet/socket_portable.h +++ b/panda/src/nativenet/socket_portable.h @@ -1,9 +1,7 @@ #ifndef __SOCKET_PORTABLE_H__ #define __SOCKET_PORTABLE_H__ -//////////////////////////////////////////////////////////////////// // Lots of stuff to make network socket-based io transparent across multiple -// platforms -//////////////////////////////////////////////////////////////////// +// platforms const int ALL_OK = 0; const int BASIC_ERROR = -1; @@ -164,9 +162,9 @@ const SOCKET BAD_SOCKET = (SOCKET)-1; typedef int SOCKET; const SOCKET BAD_SOCKET = 0xffffffff; -//#define DO_CONNECT(a,b) connect(a,(sockaddr *)b,sizeof(sockaddr)) -//#define DO_SOCKET_READ(a,b,c) recv(a,b,c,0) -//#define DO_SOCKET_WRITE(a,b,c) send(a,b,c,0) +// #define DO_CONNECT(a,b) connect(a,(sockaddr +// *)b,sizeof(sockaddr)) #define DO_SOCKET_READ(a,b,c) recv(a,b,c,0) +// #define DO_SOCKET_WRITE(a,b,c) send(a,b,c,0) inline int DO_CONNECT(const SOCKET a, const sockaddr_in *b) { @@ -181,11 +179,11 @@ inline int DO_SOCKET_WRITE(const SOCKET a, const char * buff, const int len) return send(a, buff, len, 0); } -//#define DO_SOCKET_WRITE_TO(a,b,c,d) sendto(a,b,c,0,(sockaddr *)d,sizeof(sockaddr)) -//#define DO_NEWUDP() socket(AF_INET, SOCK_DGRAM, 0) -//#define DO_NEWTCP() socket(AF_INET, SOCK_STREAM, 0) -//#define DO_BIND(a,b) ::bind(a,(sockaddr *)b,sizeof(sockaddr)) -//#/define DO_CLOSE(a) close(a) +// #define DO_SOCKET_WRITE_TO(a,b,c,d) sendto(a,b,c,0,(sockaddr +// *)d,sizeof(sockaddr)) #define DO_NEWUDP() socket(AF_INET, +// SOCK_DGRAM, 0) #define DO_NEWTCP() socket(AF_INET, SOCK_STREAM, 0) +// #define DO_BIND(a,b) ::bind(a,(sockaddr *)b,sizeof(sockaddr)) #define +// DO_CLOSE(a) close(a) inline int DO_SOCKET_WRITE_TO(const SOCKET a, const char * buffer, const int buf_len, const sockaddr_in * addr) { return sendto(a, buffer, buf_len, 0, reinterpret_cast(addr), sizeof(sockaddr)); @@ -262,9 +260,9 @@ const int LOCAL_CONNECT_BLOCKING = EINPROGRESS; #include #include #include -//#include +// #include #include -//#include +// #include #include #include #include @@ -290,7 +288,6 @@ inline int DO_SOCKET_WRITE(const SOCKET a, const char * buff, const int len) { return (int)send(a, buff, (size_t)len, 0); } -//////////////////////////////////////////////////////////////////// inline int DO_SOCKET_WRITE_TO(const SOCKET a, const char * buffer, const int buf_len, const sockaddr_in * addr) { return (int)sendto(a, buffer, (size_t)buf_len, 0, reinterpret_cast(addr), sizeof(sockaddr)); @@ -357,7 +354,7 @@ inline bool do_shutdown_send(SOCKET s) const long LOCAL_NONBLOCK = 1; // With BSDBLOCK defined, we don't need FIONBIO. Solaris doesn't provide it. -//const long LOCAL_FL_SET = FIONBIO ; +// const long LOCAL_FL_SET = FIONBIO ; const int LOCAL_BLOCKING_ERROR = EAGAIN; const int LOCAL_CONNECT_BLOCKING = EINPROGRESS; diff --git a/panda/src/nativenet/socket_selector.h b/panda/src/nativenet/socket_selector.h index 3b0aa8b7c0..3aedf9142b 100644 --- a/panda/src/nativenet/socket_selector.h +++ b/panda/src/nativenet/socket_selector.h @@ -1,10 +1,8 @@ #ifndef __SOCKET_SELECTOR_H__ #define __SOCKET_SELECTOR_H__ -//////////////////////////////////////////////////////////////////// -// This is a structure on purpose. only used as a helper class to save on typing -// -//////////////////////////////////////////////////////////////////// +// This is a structure on purpose. only used as a helper class to save on +// typing struct Socket_Selector { Socket_fdset _read; @@ -26,12 +24,10 @@ struct Socket_Selector int WaitFor_Write_Error(const Socket_fdset & fd, const Time_Span & timeout); }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_Selector::WaitFor -// Description: This function is the reason this call exists.. -// It will wait for a read, write or error condition -// on a socket or it will time out -//////////////////////////////////////////////////////////////////// +/** + * This function is the reason this call exists.. It will wait for a read, + * write or error condition on a socket or it will time out + */ inline int Socket_Selector::WaitFor(const Time_Span &timeout) { SOCKET local_max = 0; @@ -47,10 +43,9 @@ inline int Socket_Selector::WaitFor(const Time_Span &timeout) return _answer; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Selector::WaitFor_All -// Description: Helper function to utilize the WaitFor function -//////////////////////////////////////////////////////////////////// +/** + * Helper function to utilize the WaitFor function + */ inline int Socket_Selector::WaitFor_All(const Socket_fdset & fd, const Time_Span & timeout) { _read = fd; @@ -59,11 +54,9 @@ inline int Socket_Selector::WaitFor_All(const Socket_fdset & fd, const Time_Span return WaitFor(timeout); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Selector::WaitFor_Read_Error -// Description: Helper function for WaitFor -// Only looks for readability and errors -//////////////////////////////////////////////////////////////////// +/** + * Helper function for WaitFor Only looks for readability and errors + */ inline int Socket_Selector::WaitFor_Read_Error(const Socket_fdset & fd, const Time_Span & timeout) { _read = fd; @@ -72,11 +65,9 @@ inline int Socket_Selector::WaitFor_Read_Error(const Socket_fdset & fd, const Ti return WaitFor(timeout); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_Selector::WaitFor_Write_Error -// Description: Helper function for WaitFor -// Only looks for writability and errors -//////////////////////////////////////////////////////////////////// +/** + * Helper function for WaitFor Only looks for writability and errors + */ inline int Socket_Selector::WaitFor_Write_Error(const Socket_fdset & fd, const Time_Span & timeout) { _read.clear(); diff --git a/panda/src/nativenet/socket_tcp.cxx b/panda/src/nativenet/socket_tcp.cxx index 7c76052277..11e70afdce 100644 --- a/panda/src/nativenet/socket_tcp.cxx +++ b/panda/src/nativenet/socket_tcp.cxx @@ -1,16 +1,15 @@ -// Filename: socket_tcp.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_tcp.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_tcp.h" diff --git a/panda/src/nativenet/socket_tcp.h b/panda/src/nativenet/socket_tcp.h index e720aad2d3..d1d0051d6a 100644 --- a/panda/src/nativenet/socket_tcp.h +++ b/panda/src/nativenet/socket_tcp.h @@ -4,13 +4,12 @@ #include "pandabase.h" #include "socket_ip.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_TCP -// Description : Base functionality for a TCP connected socket -// This class is pretty useless by itself but it does hide some of the -// platform differences from machine to machine -// -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a TCP connected socket This class is pretty useless + * by itself but it does hide some of the platform differences from machine to + * machine + * + */ class EXPCL_PANDA_NATIVENET Socket_TCP : public Socket_IP { public: @@ -21,13 +20,13 @@ PUBLISHED: inline int SetLinger(int interval_seconds = 0); inline int DontLinger(); inline int SetSendBufferSize(int insize); - //inline bool ActiveOpen(const Socket_Address & theaddress); + // inline bool ActiveOpen(const Socket_Address & theaddress); inline bool ActiveOpen(const Socket_Address & theaddress, bool setdelay); inline bool ActiveOpenNonBlocking(const Socket_Address & theaddress); inline bool ErrorIs_WouldBlocking(int err); inline bool ShutdownSend(); inline int SendData(const std::string &str); -// inline int RecvData( std::string &str, int max_len); +// inline int RecvData( std::string &str, int max_len); std::string RecvData(int max_len); public: @@ -52,18 +51,16 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP::Socket_TCP -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Socket_TCP::Socket_TCP(SOCKET sck) : ::Socket_IP(sck) { } -//////////////////////////////////////////////////////////////////// -// Function: SetNoDelay -// Description: Disable Nagle algorithm. Don't delay send to coalesce packets -//////////////////////////////////////////////////////////////////// +/** + * Disable Nagle algorithm. Don't delay send to coalesce packets + */ inline int Socket_TCP::SetNoDelay(bool flag) { int nodel = flag; @@ -76,10 +73,9 @@ inline int Socket_TCP::SetNoDelay(bool flag) return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: SetLinger -// Description: will control the behavior of SO_LINGER for a TCP socket -//////////////////////////////////////////////////////////////////// +/** + * will control the behavior of SO_LINGER for a TCP socket + */ int Socket_TCP::SetLinger(int interval_seconds) { linger ll; @@ -91,13 +87,11 @@ int Socket_TCP::SetLinger(int interval_seconds) return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP::DontLinger -// Description: Turn off the linger flag. The socket will quickly release -// buffered items and free up OS resources. You may lose -// a stream if you use this flag and do not negotiate the close -// at the application layer. -//////////////////////////////////////////////////////////////////// +/** + * Turn off the linger flag. The socket will quickly release buffered items + * and free up OS resources. You may lose a stream if you use this flag and + * do not negotiate the close at the application layer. + */ int Socket_TCP::DontLinger() { linger ll; @@ -109,12 +103,10 @@ int Socket_TCP::DontLinger() return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: SetSendBufferSize -// Description: Just like it sounds. Sets a buffered socket recv buffer size. -// This function does not refuse ranges outside hard-coded OS -// limits -//////////////////////////////////////////////////////////////////// +/** + * Just like it sounds. Sets a buffered socket recv buffer size. This + * function does not refuse ranges outside hard-coded OS limits + */ int Socket_TCP::SetSendBufferSize(int insize) { if (setsockopt(_socket, (int) SOL_SOCKET, (int) SO_SNDBUF, (char *) &insize, sizeof(int))) @@ -122,11 +114,10 @@ int Socket_TCP::SetSendBufferSize(int insize) return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: ActiveOpen -// Description: This function will try and set the socket up for active open to a specified -// address and port provided by the input parameter -//////////////////////////////////////////////////////////////////// +/** + * This function will try and set the socket up for active open to a specified + * address and port provided by the input parameter + */ bool Socket_TCP::ActiveOpen(const Socket_Address & theaddress, bool setdelay) { _socket = DO_NEWTCP(); @@ -143,11 +134,10 @@ bool Socket_TCP::ActiveOpen(const Socket_Address & theaddress, bool setdelay) } -//////////////////////////////////////////////////////////////////// -// Function: ActiveOpenNonBlocking -// Description: This function will try and set the socket up for active open to a specified -// address and port provided by the input parameter (non-blocking version) -//////////////////////////////////////////////////////////////////// +/** + * This function will try and set the socket up for active open to a specified + * address and port provided by the input parameter (non-blocking version) + */ bool Socket_TCP::ActiveOpenNonBlocking(const Socket_Address & theaddress) { _socket = DO_NEWTCP(); @@ -168,38 +158,29 @@ bool Socket_TCP::ActiveOpenNonBlocking(const Socket_Address & theaddress) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP::SendData -// Description: Ok Lets Send the Data -// - if error -// 0 if socket closed for write or lengh is 0 -// + bytes writen ( May be smaller than requested) -//////////////////////////////////////////////////////////////////// +/** + * Ok Lets Send the Data - if error 0 if socket closed for write or lengh is 0 + * + bytes writen ( May be smaller than requested) + */ inline int Socket_TCP::SendData(const char * data, int size) { return DO_SOCKET_WRITE(_socket, data, size); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP::RecvData -// Description: Read the data from the connection -// - if error -// 0 if socket closed for read or length is 0 -// + bytes read ( May be smaller than requested) -//////////////////////////////////////////////////////////////////// +/** + * Read the data from the connection - if error 0 if socket closed for read or + * length is 0 + bytes read ( May be smaller than requested) + */ inline int Socket_TCP::RecvData(char * data, int len) { int ecode = DO_SOCKET_READ(_socket, data, len); return ecode; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP::RecvData -// Description: Read the data from the connection -// - if error -// 0 if socket closed for read or length is 0 -// + bytes read ( May be smaller than requested) -//////////////////////////////////////////////////////////////////// +/** + * Read the data from the connection - if error 0 if socket closed for read or + * length is 0 + bytes read ( May be smaller than requested) + */ inline std::string Socket_TCP::RecvData(int max_len) { std::string str; diff --git a/panda/src/nativenet/socket_tcp_listen.cxx b/panda/src/nativenet/socket_tcp_listen.cxx index 314f718141..13491d45b7 100644 --- a/panda/src/nativenet/socket_tcp_listen.cxx +++ b/panda/src/nativenet/socket_tcp_listen.cxx @@ -1,16 +1,15 @@ -// Filename: socket_tcp_listen.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_tcp_listen.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_tcp_listen.h" diff --git a/panda/src/nativenet/socket_tcp_listen.h b/panda/src/nativenet/socket_tcp_listen.h index 4e43864ad4..6091d5114d 100644 --- a/panda/src/nativenet/socket_tcp_listen.h +++ b/panda/src/nativenet/socket_tcp_listen.h @@ -5,10 +5,9 @@ #include "socket_ip.h" #include "socket_tcp.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_TCP_Listen -// Description : Base functionality for a TCP rendezvous socket -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a TCP rendezvous socket + */ class EXPCL_PANDA_NATIVENET Socket_TCP_Listen : public Socket_IP { public: @@ -38,10 +37,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: OpenForListen -// Description: This function will initialize a listening Socket -//////////////////////////////////////////////////////////////////// +/** + * This function will initialize a listening Socket + */ inline bool Socket_TCP_Listen::OpenForListen(const Socket_Address & Inaddess, int backlog_size ) { ErrorClose(); @@ -59,10 +57,9 @@ inline bool Socket_TCP_Listen::OpenForListen(const Socket_Address & Inaddess, in return true; } -//////////////////////////////////////////////////////////////////// -// Function: GetIncomingConnection -// Description: This function is used to accept new connections -//////////////////////////////////////////////////////////////////// +/** + * This function is used to accept new connections + */ inline bool Socket_TCP_Listen::GetIncomingConnection(SOCKET & newsession, Socket_Address &address) { newsession = DO_ACCEPT(_socket, &address.GetAddressInfo()); diff --git a/panda/src/nativenet/socket_tcp_ssl.cxx b/panda/src/nativenet/socket_tcp_ssl.cxx index 73d01fb2d8..0444d41802 100644 --- a/panda/src/nativenet/socket_tcp_ssl.cxx +++ b/panda/src/nativenet/socket_tcp_ssl.cxx @@ -1,16 +1,15 @@ -// Filename: socket_tcp_ssl.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_tcp_ssl.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_tcp_ssl.h" diff --git a/panda/src/nativenet/socket_tcp_ssl.h b/panda/src/nativenet/socket_tcp_ssl.h index 4af5dba8ac..e80e0d5647 100644 --- a/panda/src/nativenet/socket_tcp_ssl.h +++ b/panda/src/nativenet/socket_tcp_ssl.h @@ -15,11 +15,11 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : Socket_TCP_SSL -// Description : -// -//////////////////////////////////////////////////////////////////// +/** + * + + * + */ extern EXPCL_PANDA_NATIVENET SSL_CTX *global_ssl_ctx; @@ -30,7 +30,7 @@ struct SSlStartup { const SSL_METHOD *meth; SSLeay_add_ssl_algorithms(); - //meth = SSLv23_server_method(); + // meth = SSLv23_server_method(); meth = SSLv23_method(); SSL_load_error_strings(); // I hate this cast, but older versions of OpenSSL need it. @@ -104,14 +104,12 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP_SSL::Socket_TCP_SSL -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Socket_TCP_SSL:: Socket_TCP_SSL(SOCKET sck) : ::Socket_IP(sck) { - // right know this will only work for a - // accepted ie a server socket ?? + // right know this will only work for a accepted ie a server socket ?? SetNonBlocking(); // maybe should be blocking? _ssl = SSL_new(global_ssl_ctx); @@ -124,13 +122,12 @@ Socket_TCP_SSL(SOCKET sck) : ::Socket_IP(sck) { SSL_accept(_ssl); ERR_clear_error(); - //printf(" Ssl Accept = %d \n",err); + // printf(" Ssl Accept = %d \n",err); } -//////////////////////////////////////////////////////////////////// -// Function: SetNoDelay -// Description: Disable Nagle algorithm. Don't delay send to coalesce packets -//////////////////////////////////////////////////////////////////// +/** + * Disable Nagle algorithm. Don't delay send to coalesce packets + */ inline int Socket_TCP_SSL::SetNoDelay() { int nodel = 1; @@ -143,10 +140,9 @@ inline int Socket_TCP_SSL::SetNoDelay() return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: SetLinger -// Description: will control the behavior of SO_LINGER for a TCP socket -//////////////////////////////////////////////////////////////////// +/** + * will control the behavior of SO_LINGER for a TCP socket + */ int Socket_TCP_SSL::SetLinger(int interval_seconds) { linger ll; @@ -158,13 +154,11 @@ int Socket_TCP_SSL::SetLinger(int interval_seconds) return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP_SSL::DontLinger -// Description: Turn off the linger flag. The socket will quickly release -// buffered items and free up OS resources. You may lose -// a stream if you use this flag and do not negotiate the close -// at the application layer. -//////////////////////////////////////////////////////////////////// +/** + * Turn off the linger flag. The socket will quickly release buffered items + * and free up OS resources. You may lose a stream if you use this flag and + * do not negotiate the close at the application layer. + */ int Socket_TCP_SSL::DontLinger() { linger ll; @@ -176,12 +170,10 @@ int Socket_TCP_SSL::DontLinger() return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: SetSendBufferSize -// Description: Just like it sounds. Sets a buffered socket recv buffer size. -// This function does not refuse ranges outside hard-coded OS -// limits -//////////////////////////////////////////////////////////////////// +/** + * Just like it sounds. Sets a buffered socket recv buffer size. This + * function does not refuse ranges outside hard-coded OS limits + */ int Socket_TCP_SSL::SetSendBufferSize(int insize) { if (setsockopt(_socket, (int) SOL_SOCKET, (int) SO_SNDBUF, (char *) &insize, sizeof(int))) @@ -189,11 +181,10 @@ int Socket_TCP_SSL::SetSendBufferSize(int insize) return ALL_OK; } -//////////////////////////////////////////////////////////////////// -// Function: ActiveOpen -// Description: This function will try and set the socket up for active open to a specified -// address and port provided by the input parameter -//////////////////////////////////////////////////////////////////// +/** + * This function will try and set the socket up for active open to a specified + * address and port provided by the input parameter + */ bool Socket_TCP_SSL::ActiveOpen(const Socket_Address & theaddress) { _socket = DO_NEWTCP(); @@ -212,33 +203,27 @@ bool Socket_TCP_SSL::ActiveOpen(const Socket_Address & theaddress) return false; return true; - //return SetSslUp(); + // return SetSslUp(); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP_SSL::SendData -// Description: Ok Lets Send the Data -// - if error -// 0 if socket closed for write or lengh is 0 -// + bytes writen ( May be smaller than requested) -//////////////////////////////////////////////////////////////////// +/** + * Ok Lets Send the Data - if error 0 if socket closed for write or lengh is 0 + * + bytes writen ( May be smaller than requested) + */ inline int Socket_TCP_SSL::SendData(const char * data, int size) { if(_ssl == NULL) return -1; -// ERR_clear_error(); +// ERR_clear_error(); return SSL_write(_ssl, data, size); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_TCP_SSL::RecvData -// Description: Read the data from the connection -// - if error -// 0 if socket closed for read or length is 0 -// + bytes read ( May be smaller than requested) -//////////////////////////////////////////////////////////////////// +/** + * Read the data from the connection - if error 0 if socket closed for read or + * length is 0 + bytes read ( May be smaller than requested) + */ inline int Socket_TCP_SSL::RecvData(char * data, int len) { if(_ssl == NULL) @@ -249,11 +234,9 @@ inline int Socket_TCP_SSL::RecvData(char * data, int len) return SSL_read(_ssl, data, len); } -//////////////////////////////////////////////////////////////////// -// Function: ErrorIs_WouldBlocking -// Description: Is last error a blocking error ?? -// True is last error was a blocking error -//////////////////////////////////////////////////////////////////// +/** + * Is last error a blocking error ?? True is last error was a blocking error + */ inline bool Socket_TCP_SSL::ErrorIs_WouldBlocking(int err) { if(_ssl == NULL || err >= 0) @@ -272,7 +255,7 @@ inline bool Socket_TCP_SSL::ErrorIs_WouldBlocking(int err) case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_CONNECT: -// case SSL_ERROR_WANT_ACCEPT: +// case SSL_ERROR_WANT_ACCEPT: answer = true; break; // hmm not sure we need this .. hmmmm @@ -282,17 +265,19 @@ inline bool Socket_TCP_SSL::ErrorIs_WouldBlocking(int err) else { DetailErrorFormat(); -// LOGWARNING("Socket_TCP_SSL::ErrorIs_WouldBlocking-> Not A blocking Error1 SSl_CODe=[%d] OS=[%d]",ssl_error_code,GETERROR()); +// LOGWARNING("Socket_TCP_SSL::ErrorIs_WouldBlocking-> Not A blocking Error1 +// SSl_CODe=[%d] OS=[%d]",ssl_error_code,GETERROR()); } break; default: DetailErrorFormat(); -// LOGWARNING("Socket_TCP_SSL::ErrorIs_WouldBlocking-> Not A blocking Error2 SSl_CODe=[%d] OS=[%d]",ssl_error_code,GETERROR()); +// LOGWARNING("Socket_TCP_SSL::ErrorIs_WouldBlocking-> Not A blocking Error2 +// SSl_CODe=[%d] OS=[%d]",ssl_error_code,GETERROR()); answer = false; break; } -// ERR_clear_error(); +// ERR_clear_error(); return answer; } @@ -320,4 +305,3 @@ inline void Socket_TCP_SSL::DetailErrorFormat(void) #endif // HAVE_OPENSSL #endif //__SOCKET_TCP_SSL_H__ - diff --git a/panda/src/nativenet/socket_udp.cxx b/panda/src/nativenet/socket_udp.cxx index 3b8c427eb1..27532bbf70 100644 --- a/panda/src/nativenet/socket_udp.cxx +++ b/panda/src/nativenet/socket_udp.cxx @@ -1,16 +1,15 @@ -// Filename: socket_udp.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_udp.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_udp.h" diff --git a/panda/src/nativenet/socket_udp.h b/panda/src/nativenet/socket_udp.h index 07cce9f94a..aa271d336d 100644 --- a/panda/src/nativenet/socket_udp.h +++ b/panda/src/nativenet/socket_udp.h @@ -1,29 +1,26 @@ -// Filename: socket_udp.h -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_udp.h + * @author drose + * @date 2007-03-01 + */ #ifndef __SOCKET_UDP_H__ #define __SOCKET_UDP_H__ #include "socket_udp_incoming.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_UDP -// Description : Base functionality for a combination UDP Reader and -// Writer. This duplicates code from -// Socket_UDP_Outgoing, to avoid the problems of -// multiple inheritance. -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a combination UDP Reader and Writer. This + * duplicates code from Socket_UDP_Outgoing, to avoid the problems of multiple + * inheritance. + */ class EXPCL_PANDA_NATIVENET Socket_UDP : public Socket_UDP_Incoming { public: @@ -61,10 +58,9 @@ public: private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP:SetToBroadCast -// Description: Ask the OS to let us receive BROADCASt packets on this port.. -//////////////////////////////////////////////////////////////////// +/** + * Ask the OS to let us receive BROADCASt packets on this port.. + */ inline bool Socket_UDP::SetToBroadCast() { int optval = 1; @@ -73,10 +69,9 @@ inline bool Socket_UDP::SetToBroadCast() return false; return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::InitToAddress -// Description: Connects the Socket to a Specified address -//////////////////////////////////////////////////////////////////// +/** + * Connects the Socket to a Specified address + */ inline bool Socket_UDP::InitToAddress(const Socket_Address & address) { if (InitNoAddress() != true) @@ -87,10 +82,9 @@ inline bool Socket_UDP::InitToAddress(const Socket_Address & address) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::InitNoAddress -// Description: This will set a udp up for targeted sends.. -//////////////////////////////////////////////////////////////////// +/** + * This will set a udp up for targeted sends.. + */ inline bool Socket_UDP::InitNoAddress() { Close(); @@ -101,37 +95,33 @@ inline bool Socket_UDP::InitNoAddress() return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::Send -// Description: Send data to connected address -//////////////////////////////////////////////////////////////////// +/** + * Send data to connected address + */ inline bool Socket_UDP::Send(const char * data, int len) { return (DO_SOCKET_WRITE(_socket, data, len) == len); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::Send -// Description: Send data to connected address -//////////////////////////////////////////////////////////////////// +/** + * Send data to connected address + */ inline bool Socket_UDP::Send(const string &data) { return Send(data.data(), data.size()); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::SendTo -// Description: Send data to specified address -//////////////////////////////////////////////////////////////////// +/** + * Send data to specified address + */ inline bool Socket_UDP::SendTo(const char * data, int len, const Socket_Address & address) { return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP::SendTo -// Description: Send data to specified address -//////////////////////////////////////////////////////////////////// +/** + * Send data to specified address + */ inline bool Socket_UDP::SendTo(const string &data, const Socket_Address & address) { return SendTo(data.data(), data.size(), address); diff --git a/panda/src/nativenet/socket_udp_incoming.cxx b/panda/src/nativenet/socket_udp_incoming.cxx index 19443b0f0d..60bcb96367 100644 --- a/panda/src/nativenet/socket_udp_incoming.cxx +++ b/panda/src/nativenet/socket_udp_incoming.cxx @@ -1,16 +1,15 @@ -// Filename: socket_udp_incoming.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_udp_incoming.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_udp_incoming.h" diff --git a/panda/src/nativenet/socket_udp_incoming.h b/panda/src/nativenet/socket_udp_incoming.h index a75f0ed876..3fb83785d5 100644 --- a/panda/src/nativenet/socket_udp_incoming.h +++ b/panda/src/nativenet/socket_udp_incoming.h @@ -4,12 +4,12 @@ #include "pandabase.h" #include "socket_ip.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_UDP_Incoming -// Description : Base functionality for a UDP Reader -// -// -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a UDP Reader + * + + * + */ class EXPCL_PANDA_NATIVENET Socket_UDP_Incoming : public Socket_IP { PUBLISHED: @@ -40,12 +40,10 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Incoming::tToBroadCast -// Description: Flips the OS bits that allow for brodcast -// packets to com in on this port -// -//////////////////////////////////////////////////////////////////// +/** + * Flips the OS bits that allow for brodcast packets to com in on this port + * + */ inline bool Socket_UDP_Incoming::SetToBroadCast() { int optval = 1; @@ -54,10 +52,9 @@ inline bool Socket_UDP_Incoming::SetToBroadCast() return false; return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Incoming::InitNoAddress -// Description: Set this socket to work with out a bound external address.. -//////////////////////////////////////////////////////////////////// +/** + * Set this socket to work with out a bound external address.. + */ inline bool Socket_UDP_Incoming::InitNoAddress() { Close(); @@ -68,10 +65,9 @@ inline bool Socket_UDP_Incoming::InitNoAddress() return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Incoming::OpenForInput -// Description: Starts a UDP socket listening on a port -//////////////////////////////////////////////////////////////////// +/** + * Starts a UDP socket listening on a port + */ inline bool Socket_UDP_Incoming::OpenForInput(const Socket_Address & address) { Close(); @@ -85,10 +81,9 @@ inline bool Socket_UDP_Incoming::OpenForInput(const Socket_Address & address) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Incoming::OpenForInput -// Description: Starts a UDP socket listening on a port -//////////////////////////////////////////////////////////////////// +/** + * Starts a UDP socket listening on a port + */ inline bool Socket_UDP_Incoming::OpenForInputMCast(const Socket_Address & address) { Close(); @@ -113,12 +108,11 @@ inline bool Socket_UDP_Incoming::OpenForInputMCast(const Socket_Address & addres return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Incoming::GetPacket -// Description: Grabs a dataset off the listening UDP socket -// and fills in the source address information -// -//////////////////////////////////////////////////////////////////// +/** + * Grabs a dataset off the listening UDP socket and fills in the source + * address information + * + */ inline bool Socket_UDP_Incoming::GetPacket(char * data, int *max_len, Socket_Address & address) { int val = DO_RECV_FROM(_socket, data, *max_len, &address.GetAddressInfo()); @@ -134,10 +128,9 @@ inline bool Socket_UDP_Incoming::GetPacket(char * data, int *max_len, Socket_Add return true; } -//////////////////////////////////////////////////////////////////// -// Function: SocketUDP_Outgoing::SendTo -// Description: Send data to specified address -//////////////////////////////////////////////////////////////////// +/** + * Send data to specified address + */ inline bool Socket_UDP_Incoming::SendTo(const char * data, int len, const Socket_Address & address) { return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len); diff --git a/panda/src/nativenet/socket_udp_outgoing.cxx b/panda/src/nativenet/socket_udp_outgoing.cxx index ee0c9d3118..a5483fd7a3 100644 --- a/panda/src/nativenet/socket_udp_outgoing.cxx +++ b/panda/src/nativenet/socket_udp_outgoing.cxx @@ -1,16 +1,15 @@ -// Filename: socket_udp_outgoing.cxx -// Created by: drose (01Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socket_udp_outgoing.cxx + * @author drose + * @date 2007-03-01 + */ #include "socket_udp_outgoing.h" diff --git a/panda/src/nativenet/socket_udp_outgoing.h b/panda/src/nativenet/socket_udp_outgoing.h index 424bcd1d15..be7b2b9f8f 100644 --- a/panda/src/nativenet/socket_udp_outgoing.h +++ b/panda/src/nativenet/socket_udp_outgoing.h @@ -4,12 +4,12 @@ #include "config_nativenet.h" #include "socket_ip.h" -//////////////////////////////////////////////////////////////////// -// Class : Socket_UDP_Outgoing -// Description : Base functionality for a UDP Sending Socket -// -// -//////////////////////////////////////////////////////////////////// +/** + * Base functionality for a UDP Sending Socket + * + + * + */ class EXPCL_PANDA_NATIVENET Socket_UDP_Outgoing : public Socket_IP { public: @@ -47,10 +47,9 @@ public: private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing:SetToBroadCast -// Description: Ask the OS to let us receive BROADCASt packets on this port.. -//////////////////////////////////////////////////////////////////// +/** + * Ask the OS to let us receive BROADCASt packets on this port.. + */ inline bool Socket_UDP_Outgoing::SetToBroadCast() { int optval = 1; @@ -59,10 +58,9 @@ inline bool Socket_UDP_Outgoing::SetToBroadCast() return false; return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::InitToAddress -// Description: Connects the Socket to a Specified address -//////////////////////////////////////////////////////////////////// +/** + * Connects the Socket to a Specified address + */ inline bool Socket_UDP_Outgoing::InitToAddress(const Socket_Address & address) { if (InitNoAddress() != true) @@ -73,10 +71,9 @@ inline bool Socket_UDP_Outgoing::InitToAddress(const Socket_Address & address) return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::InitNoAddress -// Description: This will set a udp up for targeted sends.. -//////////////////////////////////////////////////////////////////// +/** + * This will set a udp up for targeted sends.. + */ inline bool Socket_UDP_Outgoing::InitNoAddress() { Close(); @@ -87,37 +84,33 @@ inline bool Socket_UDP_Outgoing::InitNoAddress() return true; } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::Send -// Description: Send data to connected address -//////////////////////////////////////////////////////////////////// +/** + * Send data to connected address + */ inline bool Socket_UDP_Outgoing::Send(const char * data, int len) { return (DO_SOCKET_WRITE(_socket, data, len) == len); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::Send -// Description: Send data to connected address -//////////////////////////////////////////////////////////////////// +/** + * Send data to connected address + */ inline bool Socket_UDP_Outgoing::Send(const string &data) { return Send(data.data(), data.size()); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::SendTo -// Description: Send data to specified address -//////////////////////////////////////////////////////////////////// +/** + * Send data to specified address + */ inline bool Socket_UDP_Outgoing::SendTo(const char * data, int len, const Socket_Address & address) { return (DO_SOCKET_WRITE_TO(_socket, data, len, &address.GetAddressInfo()) == len); } -//////////////////////////////////////////////////////////////////// -// Function: Socket_UDP_Outgoing::SendTo -// Description: Send data to specified address -//////////////////////////////////////////////////////////////////// +/** + * Send data to specified address + */ inline bool Socket_UDP_Outgoing::SendTo(const string &data, const Socket_Address & address) { return SendTo(data.data(), data.size(), address); diff --git a/panda/src/nativenet/time_accumulator.h b/panda/src/nativenet/time_accumulator.h index e8a4728b48..32d0747310 100644 --- a/panda/src/nativenet/time_accumulator.h +++ b/panda/src/nativenet/time_accumulator.h @@ -1,10 +1,6 @@ #ifndef __TIME_ACCUMULATOR_H__ #define __TIME_ACCUMULATOR_H__ -//////////////////////////////////////////////////////////////////// -// // Think of this as a stopwatch that can be restarted. -// -//////////////////////////////////////////////////////////////////// class Time_Accumulator { public: @@ -23,54 +19,44 @@ private: Time_Clock *_accum_start; // the time of day the clock started }; -//////////////////////////////////////////////////////////////////// // you can set the internal accumilator to a value.. -//////////////////////////////////////////////////////////////////// inline void Time_Accumulator::Set(const Time_Span & in) { _total_time = in; - // - // this seems to make the most since .. - // if you are running the clock right know... assume the timespane you - // are passing in is inclusive.. but keep clock running.. - // - // May need to rethink this... - // + // this seems to make the most since .. if you are running the clock right + // know... assume the timespane you are passing in is inclusive.. but keep + // clock running.. May need to rethink this... if(_accum_start != NULL) { Stop(); Start(); } } -//////////////////////////////////////////////////////////////////// -// Function: Time_Accumulator::Time_Accumulator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Accumulator::Time_Accumulator() : _total_time(0,0,0,0,0), _accum_start(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: Time_Accumulator::~Time_Accumulator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Accumulator::~Time_Accumulator() { if(_accum_start != NULL) delete _accum_start; } -//////////////////////////////////////////////////////////////////// -// Function: void Time_Accumulator::Start -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Accumulator::Start() { if(_accum_start == NULL) _accum_start = new Time_Clock(); } -//////////////////////////////////////////////////////////////////// -// Function: void Time_Accumulator::Stop -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Accumulator::Stop() { if(_accum_start != NULL) @@ -81,10 +67,9 @@ inline void Time_Accumulator::Stop() _accum_start = NULL; } } -//////////////////////////////////////////////////////////////////// -// Function: Time_Accumulator::Reset -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Time_Accumulator::Reset() { if(_accum_start != NULL) @@ -94,10 +79,9 @@ void Time_Accumulator::Reset() } _total_time.Set(0,0,0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Accumulator::Report -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span Time_Accumulator::Report() { Time_Span answer(_total_time); @@ -110,4 +94,3 @@ inline Time_Span Time_Accumulator::Report() } #endif //__TIME_ACCUMULATOR_H__ - diff --git a/panda/src/nativenet/time_base.h b/panda/src/nativenet/time_base.h index 1daccc125d..8b7ea108f7 100644 --- a/panda/src/nativenet/time_base.h +++ b/panda/src/nativenet/time_base.h @@ -1,30 +1,19 @@ #ifndef __TIME_BASE_H__ #define __TIME_BASE_H__ -//////////////////////////////////////////////////////////////////// -// Functions To support General Time Managment. And to allow for cross platform use. -// -// -// Today Really Two Base classes and one convience class -// -// Time_Clock = The clock time down to micro seconds.. -// -// Time_Span = Delta Time to the Mico Second.. -// -// Time_Out = Help timer ............count down a duration. -// -// I realize TimeClock is really an implied delta to EPOCH. I have chosen to implement it this way. -// it may be apropriate to convert it all to delta times with an EPOCk constant and -// functions that can handle the EPOCK to current time. -// All though this is probably the "right" implementation most coders do not -// think of clock time in this fashon. -// -// -// General Observation.. -// -// Windows 2k and Linux are really slow (~250k a sec) at returning the current system time ?? -// So use time functions that grab the current system time sparingly ?? -// -//////////////////////////////////////////////////////////////////// +/* + * Functions To support General Time Managment. And to allow for cross + * platform use. Today Really Two Base classes and one convience class + * Time_Clock = The clock time down to micro seconds.. Time_Span = Delta Time + * to the Mico Second.. Time_Out = Help timer ............count down a + * duration. I realize TimeClock is really an implied delta to EPOCH. I have + * chosen to implement it this way. it may be apropriate to convert it all to + * delta times with an EPOCk constant and functions that can handle the EPOCK + * to current time. All though this is probably the "right" implementation + * most coders do not think of clock time in this fashon. General + * Observation.. Windows 2k and Linux are really slow (~250k a sec) at + * returning the current system time ?? So use time functions that grab the + * current system time sparingly ?? + */ #ifdef WIN32 #include #include @@ -38,10 +27,9 @@ #include enum { USEC = 1000000 }; -//////////////////////////////////////////////////////////////////// -// Function: NormalizeTime -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void NormalizeTime(timeval &in) { while (in.tv_usec >= USEC) @@ -57,20 +45,18 @@ inline void NormalizeTime(timeval &in) } } -//////////////////////////////////////////////////////////////////// -// Function: TimeDif -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void TimeDif(const struct timeval &start, const struct timeval &fin, struct timeval &answer) { answer.tv_usec = fin.tv_usec - start.tv_usec; answer.tv_sec = fin.tv_sec - start.tv_sec; NormalizeTime(answer); } -//////////////////////////////////////////////////////////////////// -// Function: TimeAdd -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void TimeAdd(const struct timeval &start, const struct timeval &delta, struct timeval &answer) { answer.tv_usec = start.tv_usec + delta.tv_usec; @@ -81,10 +67,9 @@ inline void TimeAdd(const struct timeval &start, const struct timeval &delta, st #ifdef WIN32 // Lets make Windows think it is a unix machine :) -//////////////////////////////////////////////////////////////////// -// Function: gettimeofday -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int gettimeofday(struct timeval *tv, void * trash) { struct timeb timeb; diff --git a/panda/src/nativenet/time_clock.h b/panda/src/nativenet/time_clock.h index b84de8a50f..b02d4af01c 100644 --- a/panda/src/nativenet/time_clock.h +++ b/panda/src/nativenet/time_clock.h @@ -1,13 +1,12 @@ #ifndef __Time_H__ #define __Time_H__ -//////////////////////////////////////////////////////////////////// -// Class : Time_Clock -// Description : This class is to provide a consistant interface and -// storage to clock time .. Epoch based time to the second -// -// jan-2000 .. rhh changing all time to use sub second timing... -// -//////////////////////////////////////////////////////////////////// +/** + * This class is to provide a consistant interface and storage to clock time + * .. Epoch based time to the second + * + * jan-2000 .. rhh changing all time to use sub second timing... + * + */ #include @@ -51,8 +50,7 @@ public: void Set(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, long microseconds = 0, int nDST = -1); - // Operations - // time math + // Operations time math const Time_Clock& operator+=(const Time_Span &Time_Span); const Time_Clock& operator-=(const Time_Span &Time_Span); bool operator==(const Time_Clock &time) const; @@ -87,10 +85,9 @@ public: struct timeval _my_time; }; -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Time_Clock -// Description: Construction from parts -//////////////////////////////////////////////////////////////////// +/** + * Construction from parts + */ inline Time_Clock::Time_Clock(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, long microseconds , int nDST) { struct tm atm; @@ -109,10 +106,9 @@ inline Time_Clock::Time_Clock(int nYear, int nMonth, int nDay, int nHour, int nM _my_time.tv_usec = microseconds; assert(_my_time.tv_usec < 1000000); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Set -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Clock::Set(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, long microseconds , int nDST) { struct tm atm; @@ -131,36 +127,32 @@ inline void Time_Clock::Set(int nYear, int nMonth, int nDay, int nHour, int nMin _my_time.tv_usec = microseconds; assert(_my_time.tv_usec < 1000000); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetCurrentTime -// Description: The Default no param constructor.. Will set time to current system time -//////////////////////////////////////////////////////////////////// +/** + * The Default no param constructor.. Will set time to current system time + */ inline Time_Clock Time_Clock::GetCurrentTime() { return Time_Clock(); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Time_Clock -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Clock::Time_Clock() { gettimeofday(&_my_time, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::ToCurrentTime -// Description: Load this object with the current OS time -//////////////////////////////////////////////////////////////////// +/** + * Load this object with the current OS time + */ inline void Time_Clock::ToCurrentTime() { gettimeofday(&_my_time, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetGmtTm -// Description: Access the stored time and converts to a struct tm format -// If storage location is specified then it will stor information in the -// provided buffer else it will use the library's internal buffer space -//////////////////////////////////////////////////////////////////// +/** + * Access the stored time and converts to a struct tm format If storage + * location is specified then it will stor information in the provided buffer + * else it will use the library's internal buffer space + */ inline struct tm* Time_Clock::GetGmtTm(struct tm* ptm) const { if (ptm != NULL) @@ -171,10 +163,9 @@ inline struct tm* Time_Clock::GetGmtTm(struct tm* ptm) const return gmtime((const time_t *)&_my_time.tv_sec); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetLocalTm -// Description: Gets The local time in a tm structre from the internal time value -//////////////////////////////////////////////////////////////////// +/** + * Gets The local time in a tm structre from the internal time value + */ inline struct tm* Time_Clock::GetLocalTm(struct tm* ptm) const { if (ptm != NULL) @@ -187,14 +178,12 @@ inline struct tm* Time_Clock::GetLocalTm(struct tm* ptm) const } else return localtime((const time_t *)&_my_time.tv_sec); } -// String formatting -// Verifies will fail if the needed buffer size is too large +// String formatting Verifies will fail if the needed buffer size is too large #define maxTimeBufferSize 4096 -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Format -// Description: Used to allow access to the "C" library strftime functions.. -//////////////////////////////////////////////////////////////////// +/** + * Used to allow access to the "C" library strftime functions.. + */ inline std::string Time_Clock::Format(const char * pFormat) const { @@ -234,12 +223,11 @@ inline std::string Time_Clock::Format(const char * pFormat) const szBuffer1[0] = '\0'; return std::string(szBuffer1); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::FormatGmt -// Description: A Wraper to -// size_t strftime( char *strDest, size_t maxsize, const char *format, const struct tm *timeptr ); -// -//////////////////////////////////////////////////////////////////// +/** + * A Wraper to size_t strftime( char *strDest, size_t maxsize, const char + * *format, const struct tm *timeptr ); + * + */ inline std::string Time_Clock::FormatGmt(const char * pFormat) const { @@ -278,91 +266,81 @@ inline std::string Time_Clock::FormatGmt(const char * pFormat) const szBuffer1[0] = '\0'; return std::string(szBuffer1); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Time_Clock -// Description: The Constructor that take a time_t objext -//////////////////////////////////////////////////////////////////// +/** + * The Constructor that take a time_t objext + */ inline Time_Clock::Time_Clock(time_t time) { _my_time.tv_sec = (long)time; _my_time.tv_usec = 0; }; -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Time_Clock -// Description: Constructor that takes in sec and usecs.. -//////////////////////////////////////////////////////////////////// +/** + * Constructor that takes in sec and usecs.. + */ inline Time_Clock::Time_Clock(long secs, long usecs) { _my_time.tv_sec = secs; _my_time.tv_usec = usecs; NormalizeTime(_my_time); }; -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::Time_Clock -// Description: yet another constructor -//////////////////////////////////////////////////////////////////// +/** + * yet another constructor + */ inline Time_Clock::Time_Clock(const Time_Clock& timeSrc) { _my_time.tv_sec = timeSrc._my_time.tv_sec; _my_time.tv_usec = timeSrc._my_time.tv_usec; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator== -// Description: .. is time equal -//////////////////////////////////////////////////////////////////// +/** + * .. is time equal + */ inline bool Time_Clock::operator==(const Time_Clock &time) const { return ((_my_time.tv_sec == time._my_time.tv_sec) && (_my_time.tv_usec == time._my_time.tv_usec)); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator!= -// Description: .is time != -//////////////////////////////////////////////////////////////////// +/** + * .is time != + */ inline bool Time_Clock::operator!=(const Time_Clock &time) const { return ((_my_time.tv_sec != time._my_time.tv_sec) || (_my_time.tv_usec != time._my_time.tv_usec)); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator< -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Clock::operator<(const Time_Clock &time) const { return ((_my_time.tv_sec < time._my_time.tv_sec) || ((_my_time.tv_sec == time._my_time.tv_sec) && (_my_time.tv_usec < time._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator> -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Clock::operator>(const Time_Clock &time) const { return ((_my_time.tv_sec > time._my_time.tv_sec) || ((_my_time.tv_sec == time._my_time.tv_sec) && (_my_time.tv_usec > time._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator<= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Clock::operator<=(const Time_Clock &time) const { return ((_my_time.tv_sec < time._my_time.tv_sec) || ((_my_time.tv_sec == time._my_time.tv_sec) && (_my_time.tv_usec <= time._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::operator>= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Clock::operator>=(const Time_Clock &time) const { return ((_my_time.tv_sec > time._my_time.tv_sec) || ((_my_time.tv_sec == time._my_time.tv_sec) && (_my_time.tv_usec >= time._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock& Time_Clock::operator= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Clock& Time_Clock::operator=(const Time_Clock& timeSrc) { if (&timeSrc == this) @@ -371,76 +349,67 @@ inline const Time_Clock& Time_Clock::operator=(const Time_Clock& timeSrc) _my_time = timeSrc._my_time; return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock& Time_Clock::operator= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Clock& Time_Clock::operator=(time_t t) { _my_time.tv_sec = (long)t; _my_time.tv_usec = 0; return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetTime -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline time_t Time_Clock::GetTime() const { return _my_time.tv_sec; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetYear -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetYear() const { return (GetLocalTm(NULL)->tm_year) + 1900; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetMonth -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetMonth() const { return GetLocalTm(NULL)->tm_mon + 1; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetDay -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetDay() const { return GetLocalTm(NULL)->tm_mday; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetHour -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetHour() const { return GetLocalTm(NULL)->tm_hour; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetMinute -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetMinute() const { return GetLocalTm(NULL)->tm_min; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetSecond -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetSecond() const { return GetLocalTm(NULL)->tm_sec; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock::GetDayOfWeek -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Clock::GetDayOfWeek() const { return GetLocalTm(NULL)->tm_wday + 1; diff --git a/panda/src/nativenet/time_general.h b/panda/src/nativenet/time_general.h index 24bd9ea7ca..cb7a756ea9 100644 --- a/panda/src/nativenet/time_general.h +++ b/panda/src/nativenet/time_general.h @@ -14,40 +14,36 @@ Time_Clock operator-(const Time_Clock &tm, const Time_Span &ts); bool SetFromTimeStr(const char * str, Time_Clock & outtime); std::string GetTimeStr(const Time_Clock & intime); -//////////////////////////////////////////////////////////////////// -// Function: TimeDifference -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span TimeDifference(const Time_Clock &time1, const Time_Clock &time2) { timeval ans; TimeDif(time2.GetTval(), time1.GetTval(), ans); return Time_Span(ans); } -//////////////////////////////////////////////////////////////////// -// Function: TimeDifference -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Clock TimeDifference( const Time_Clock &time1, const Time_Span &Time_Span) { timeval ans; TimeDif(Time_Span.GetTval(), time1.GetTval(), ans); return Time_Clock(ans); } -//////////////////////////////////////////////////////////////////// -// Function: TimeAddition -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Clock TimeAddition(const Time_Clock &time1, Time_Span &Time_Span) { timeval ans; TimeAdd(time1.GetTval(), Time_Span.GetTval(), ans); return Time_Clock(ans); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock& Time_Clock::operator+= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Clock& Time_Clock::operator+=(const Time_Span &Time_Span) { _my_time.tv_usec += Time_Span._my_time.tv_usec; @@ -55,28 +51,25 @@ inline const Time_Clock& Time_Clock::operator+=(const Time_Span &Time_Span) NormalizeTime(_my_time); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: operator+ -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Clock operator+(const Time_Clock &tm, const Time_Span &ts) { Time_Clock work(tm); work += ts; return work; } -//////////////////////////////////////////////////////////////////// -// Function: operator- -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Clock operator-(const Time_Clock &tm, const Time_Span &ts) { return TimeDifference(tm, ts); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Clock& Time_Clock::operator-= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Clock& Time_Clock::operator-=(const Time_Span &Time_Span) { _my_time.tv_usec -= Time_Span._my_time.tv_usec; @@ -84,18 +77,16 @@ inline const Time_Clock& Time_Clock::operator-=(const Time_Span &Time_Span) NormalizeTime(_my_time); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: operator- -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span operator-(const Time_Clock &tm1, const Time_Clock &tm2) { return TimeDifference(tm1, tm2); } -//////////////////////////////////////////////////////////////////// -// Function: char * GetTimeStr -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline std::string GetTimeStr(const Time_Clock & intime) { static std::string ts; @@ -108,18 +99,16 @@ inline std::string GetTimeStr(const Time_Clock & intime) } return ts; } -//////////////////////////////////////////////////////////////////// -// Function: GetTimeStr -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline std::string GetTimeStr() { return GetTimeStr(Time_Clock::GetCurrentTime()); } -//////////////////////////////////////////////////////////////////// -// Function: SetFromTimeStr -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool SetFromTimeStr(const char * str, Time_Clock & outtime) { int year = 0; diff --git a/panda/src/nativenet/time_out.h b/panda/src/nativenet/time_out.h index 64350f722d..aceb133393 100644 --- a/panda/src/nativenet/time_out.h +++ b/panda/src/nativenet/time_out.h @@ -1,15 +1,10 @@ #ifndef __TIME_OUT_H__ #define __TIME_OUT_H__ -//////////////////////////////////////////////////////////////////// -// -// think of this class as a time based alarm.. -// -// would be nice to have a template implementation of this class .. could avoud some storage and some math .. -// -// I would do this but not sure how to represent the duration in the template ?? -// -//////////////////////////////////////////////////////////////////// +// think of this class as a time based alarm.. would be nice to have a +// template implementation of this class .. could avoud some storage and some +// math .. I would do this but not sure how to represent the duration in the +// template ?? class Time_Out { public: @@ -67,45 +62,40 @@ private: Time_Clock _alarm_time; Time_Span _duration; }; -//////////////////////////////////////////////////////////////////// -// Function: Time_Out::ReStart -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Out::ResetAll(const Time_Clock &tm, const Time_Span &sp) { _duration = sp; _alarm_time = tm + _duration; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::ReStart -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Out::SetTimeOutSec(int sec) { _duration.Set(0, 0, 0, sec, 0); ReStart(); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::ReStart -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Out::ReStart() { _alarm_time = Time_Clock::GetCurrentTime() + _duration; } -//////////////////////////////////////////////////////////////////// -// Function: ResetTime -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Out::ResetTime(const Time_Clock & tm) { _alarm_time = tm + _duration; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Expired -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Out::Expired(const Time_Clock &tm, bool reset) { bool answer = (_alarm_time <= tm) ; @@ -113,26 +103,23 @@ inline bool Time_Out::Expired(const Time_Clock &tm, bool reset) ResetTime(tm); return answer; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Expired -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Out::Expired(bool reset) { return Expired(Time_Clock::GetCurrentTime(), reset); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Remaining -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span Time_Out::Remaining(const Time_Clock & tm) const { return _alarm_time - tm; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Remaining -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span Time_Out::Remaining() const { return Remaining(Time_Clock::GetCurrentTime()); diff --git a/panda/src/nativenet/time_span.h b/panda/src/nativenet/time_span.h index 535cfe6de9..f27d7401ab 100644 --- a/panda/src/nativenet/time_span.h +++ b/panda/src/nativenet/time_span.h @@ -1,9 +1,8 @@ #ifndef __TIME_SPAN_H__ #define __TIME_SPAN_H__ -//////////////////////////////////////////////////////////////////// -// Class : Time_Span -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class Time_Span { public: @@ -24,12 +23,10 @@ public: Time_Span(const Time_Clock& Time_SpanSrc); Time_Span(PN_stdfloat Seconds); -//////////////////////////////////////////////////////////////////// const Time_Span& operator=(const Time_Span& Time_SpanSrc); - // Attributes - // extract parts + // Attributes extract parts long GetDays() const; // total # of days long GetTotalHours() const; int GetHours() const; @@ -41,8 +38,7 @@ public: long GetTotal100Seconds() const; long GetMSeconds() const; - // Operations - // time math + // Operations time math const Time_Span& operator+=(Time_Span &Time_Span); const Time_Span& operator-=(Time_Span &Time_Span); bool operator==(Time_Span &Time_Span) const; @@ -64,38 +60,34 @@ private: struct timeval _my_time; friend class Time_Clock; }; -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(long seconds, int usecs) { _my_time.tv_sec = seconds; _my_time.tv_usec = usecs; NormalizeTime(_my_time); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(time_t time) { _my_time.tv_usec = 0; _my_time.tv_sec = (long)time; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(PN_stdfloat Seconds) { _my_time.tv_sec = (long)Seconds; // this truncats .. desired result.. _my_time.tv_usec = (long)((Seconds - (double)_my_time.tv_sec) * (double)USEC); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(long lDays, int nHours, int nMins, int nSecs, int usecs) { _my_time.tv_sec = nSecs + 60 * (nMins + 60 * (nHours + 24 * lDays)); @@ -103,10 +95,9 @@ inline Time_Span::Time_Span(long lDays, int nHours, int nMins, int nSecs, int us } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Set -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void Time_Span::Set(long lDays, int nHours, int nMins, int nSecs, int usecs) { _my_time.tv_sec = nSecs + 60 * (nMins + 60 * (nHours + 24 * lDays)); @@ -114,28 +105,25 @@ inline void Time_Span::Set(long lDays, int nHours, int nMins, int nSecs, int use } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(const Time_Span& Time_SpanSrc) { _my_time = Time_SpanSrc._my_time; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Time_Span -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span::Time_Span(const Time_Clock& Time_SpanSrc) { _my_time = Time_SpanSrc._my_time; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span& Time_Span::operator= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Span& Time_Span::operator=(const Time_Span& Time_SpanSrc) { if (&Time_SpanSrc == this) @@ -143,64 +131,57 @@ inline const Time_Span& Time_Span::operator=(const Time_Span& Time_SpanSrc) _my_time = Time_SpanSrc._my_time; return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetDays -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetDays() const { return _my_time.tv_sec / (24*3600L); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetTotalHours -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetTotalHours() const { return _my_time.tv_sec / 3600; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetHours -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Span::GetHours() const { return (int)(GetTotalHours() - GetDays()*24); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetTotalMinutes -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetTotalMinutes() const { return _my_time.tv_sec / 60; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetMinutes -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Span::GetMinutes() const { return (int)(GetTotalMinutes() - GetTotalHours()*60); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetTotalSeconds -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetTotalSeconds() const { return _my_time.tv_sec; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetTotalMSeconds -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetTotalMSeconds() const { return (_my_time.tv_sec * 1000) + (_my_time.tv_usec / 1000); @@ -214,29 +195,26 @@ inline long Time_Span::GetTotal100Seconds() const -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetTotalMSeconds -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline long Time_Span::GetMSeconds() const { return (_my_time.tv_usec / 1000); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::GetSeconds -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline int Time_Span::GetSeconds() const { return (int)(GetTotalSeconds() - GetTotalMinutes()*60); } -//////////////////////////////////////////////////////////////////// -// Function: TimeDifference -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span TimeDifference(const Time_Span &Time_Span1, const Time_Span &Time_Span2) { timeval ans; @@ -244,10 +222,9 @@ inline Time_Span TimeDifference(const Time_Span &Time_Span1, const Time_Span &Ti return Time_Span(ans); } -//////////////////////////////////////////////////////////////////// -// Function: TimeAddition -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline Time_Span TimeAddition(const Time_Span &Time_Span1, const Time_Span &Time_Span2) { timeval ans; @@ -255,10 +232,9 @@ inline Time_Span TimeAddition(const Time_Span &Time_Span1, const Time_Span &Time return Time_Span(ans); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span& Time_Span::operator+= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Span& Time_Span::operator+=(Time_Span &Time_Span) { _my_time.tv_usec += Time_Span._my_time.tv_usec; @@ -267,10 +243,9 @@ inline const Time_Span& Time_Span::operator+=(Time_Span &Time_Span) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span& Time_Span::operator-= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline const Time_Span& Time_Span::operator-=(Time_Span &Time_Span) { _my_time.tv_usec -= Time_Span._my_time.tv_usec; @@ -279,80 +254,70 @@ inline const Time_Span& Time_Span::operator-=(Time_Span &Time_Span) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator== -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator==(Time_Span &Time_Span) const { return ((_my_time.tv_sec == Time_Span._my_time.tv_sec) && (_my_time.tv_usec == Time_Span._my_time.tv_usec)); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator!= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator!=(Time_Span &Time_Span) const { return ((_my_time.tv_sec != Time_Span._my_time.tv_sec) || (_my_time.tv_usec != Time_Span._my_time.tv_usec)); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator< -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator<(Time_Span &Time_Span) const { return ((_my_time.tv_sec < Time_Span._my_time.tv_sec) || ((_my_time.tv_sec == Time_Span._my_time.tv_sec) && (_my_time.tv_usec < Time_Span._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator> -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator>(Time_Span &Time_Span) const { return ((_my_time.tv_sec > Time_Span._my_time.tv_sec) || ((_my_time.tv_sec == Time_Span._my_time.tv_sec) && (_my_time.tv_usec > Time_Span._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator<= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator<=(Time_Span &Time_Span) const { return ((_my_time.tv_sec < Time_Span._my_time.tv_sec) || ((_my_time.tv_sec == Time_Span._my_time.tv_sec) && (_my_time.tv_usec <= Time_Span._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::operator>= -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline bool Time_Span::operator>=(Time_Span &Time_Span) const { return ((_my_time.tv_sec > Time_Span._my_time.tv_sec) || ((_my_time.tv_sec == Time_Span._my_time.tv_sec) && (_my_time.tv_usec >= Time_Span._my_time.tv_usec))); } -//////////////////////////////////////////////////////////////////// -// Function: Time_Span::Format -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline std::string Time_Span::Format(char * pFormat) const -// formatting Time_Spans is a little trickier than formatting -// * we are only interested in relative time formats, ie. it is illegal -// to format anything dealing with absolute time (i.e. years, months, -// day of week, day of year, timezones, ...) -// * the only valid formats: -// %D - # of days -- NEW !!! -// %H - hour in 24 hour format -// %M - minute (0-59) -// %S - seconds (0-59) -// %% - percent sign -// %N - nanosecs +/* + * formatting Time_Spans is a little trickier than formatting * we are only + * interested in relative time formats, ie. it is illegal to format anything + * dealing with absolute time (i.e. years, months, day of week, day of year, + * timezones, ...) * the only valid formats: %D - # of days -- NEW !!! %H - + * hour in 24 hour format %M - minute (0-59) %S - seconds (0-59) %% - percent + * sign %N - nanosecs + */ { char szBuffer[maxTimeBufferSize]; char ch; diff --git a/panda/src/net/config_net.cxx b/panda/src/net/config_net.cxx index 2f3fc62013..aafea6fc49 100644 --- a/panda/src/net/config_net.cxx +++ b/panda/src/net/config_net.cxx @@ -1,16 +1,15 @@ -// Filename: config_net.cxx -// Created by: drose (25Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_net.cxx + * @author drose + * @date 2000-02-25 + */ #include "config_net.h" @@ -29,11 +28,11 @@ ConfigureFn(config_net) { -// The following two maximum queue sizes are totally arbitrary and -// serve only to provide sanity caps on the various queues in the net -// package. You can set them to any sane values you like. Also see -// the set_max_queue_size() methods in the various classes, which you -// can change at runtime on a particular instance. +// The following two maximum queue sizes are totally arbitrary and serve only +// to provide sanity caps on the various queues in the net package. You can +// set them to any sane values you like. Also see the set_max_queue_size() +// methods in the various classes, which you can change at runtime on a +// particular instance. int get_net_max_write_queue() { @@ -108,14 +107,14 @@ get_net_max_block() { "and gives the net subsystem a chance to detect things " "like explicitly-closed connections in another thread; it " "does not affect the blocking behavior at the high " - "level.")); + "level.")); } return *net_max_block; } -// This function is used in the ReaderThread and WriterThread -// constructors to make a simple name for each thread. +// This function is used in the ReaderThread and WriterThread constructors to +// make a simple name for each thread. string make_thread_name(const string &thread_name, int thread_index) { ostringstream stream; @@ -144,14 +143,12 @@ ConfigVariableEnum net_thread_priority "or writers.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libnet -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libnet() { static bool initialized = false; diff --git a/panda/src/net/config_net.h b/panda/src/net/config_net.h index 01a6be1fe1..e039f6bd2a 100644 --- a/panda/src/net/config_net.h +++ b/panda/src/net/config_net.h @@ -1,16 +1,15 @@ -// Filename: config_net.h -// Created by: drose (25Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_net.h + * @author drose + * @date 2000-02-25 + */ #ifndef CONFIG_NET_H #define CONFIG_NET_H @@ -42,4 +41,3 @@ extern ConfigVariableEnum net_thread_priority; extern EXPCL_PANDA_NET void init_libnet(); #endif - diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 9debcc316f..4c42614f7c 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -1,16 +1,15 @@ -// Filename: connection.cxx -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connection.cxx + * @author jns + * @date 2000-02-07 + */ #include "connection.h" #include "connectionManager.h" @@ -28,14 +27,11 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: Connection::Constructor -// Access: Published -// Description: Creates a connection. Normally this constructor -// should not be used directly by user code; use one of -// the methods in ConnectionManager to make a new -// connection. -//////////////////////////////////////////////////////////////////// +/** + * Creates a connection. Normally this constructor should not be used + * directly by user code; use one of the methods in ConnectionManager to make + * a new connection. + */ Connection:: Connection(ConnectionManager *manager, Socket_IP *socket) : _manager(manager), @@ -47,8 +43,8 @@ Connection(ConnectionManager *manager, Socket_IP *socket) : _queued_count = 0; #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In the presence of SIMPLE_THREADS, we use non-blocking I/O. We - // simulate blocking by yielding the thread. + // In the presence of SIMPLE_THREADS, we use non-blocking IO. We simulate + // blocking by yielding the thread. if (_socket->SetNonBlocking() != ALL_OK) { net_cat.warning() << "Unable to set non-blocking status on socket\n"; @@ -56,11 +52,9 @@ Connection(ConnectionManager *manager, Socket_IP *socket) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: Connection::Destructor -// Access: Published -// Description: Closes a connection. -//////////////////////////////////////////////////////////////////// +/** + * Closes a connection. + */ Connection:: ~Connection() { net_cat.info() @@ -74,112 +68,83 @@ Connection:: } } -//////////////////////////////////////////////////////////////////// -// Function: Connection::get_address -// Access: Published -// Description: Returns the address bound to this connection, if it -// is a TCP connection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the address bound to this connection, if it is a TCP connection. + */ NetAddress Connection:: get_address() const { Socket_Address addr = _socket->GetPeerName(); return NetAddress(addr); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::get_manager -// Access: Published -// Description: Returns a pointer to the ConnectionManager object -// that serves this connection. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the ConnectionManager object that serves this + * connection. + */ ConnectionManager *Connection:: get_manager() const { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::get_socket -// Access: Published -// Description: Returns the internal Socket_IP that defines the -// connection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal Socket_IP that defines the connection. + */ Socket_IP *Connection:: get_socket() const { return _socket; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_collect_tcp -// Access: Published -// Description: Enables or disables "collect-tcp" mode. In this -// mode, individual TCP packets are not sent -// immediately, but rather they are collected together -// and accumulated to be sent periodically as one larger -// TCP packet. This cuts down on overhead from the -// TCP/IP protocol, especially if many small packets -// need to be sent on the same connection, but it -// introduces additional latency (since packets must be -// held before they can be sent). -// -// See set_collect_tcp_interval() to specify the -// interval of time for which to hold packets before -// sending them. -// -// If you enable this mode, you may also need to -// periodically call consider_flush() to flush the queue -// if no packets have been sent recently. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables "collect-tcp" mode. In this mode, individual TCP + * packets are not sent immediately, but rather they are collected together + * and accumulated to be sent periodically as one larger TCP packet. This + * cuts down on overhead from the TCP/IP protocol, especially if many small + * packets need to be sent on the same connection, but it introduces + * additional latency (since packets must be held before they can be sent). + * + * See set_collect_tcp_interval() to specify the interval of time for which to + * hold packets before sending them. + * + * If you enable this mode, you may also need to periodically call + * consider_flush() to flush the queue if no packets have been sent recently. + */ void Connection:: set_collect_tcp(bool collect_tcp) { _collect_tcp = collect_tcp; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::get_collect_tcp -// Access: Published -// Description: Returns the current setting of "collect-tcp" mode. -// See set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of "collect-tcp" mode. See set_collect_tcp(). + */ bool Connection:: get_collect_tcp() const { return _collect_tcp; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_collect_tcp_interval -// Access: Published -// Description: Specifies the interval in time, in seconds, for which -// to hold TCP packets before sending all of the -// recently received packets at once. This only has -// meaning if "collect-tcp" mode is enabled; see -// set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the interval in time, in seconds, for which to hold TCP packets + * before sending all of the recently received packets at once. This only has + * meaning if "collect-tcp" mode is enabled; see set_collect_tcp(). + */ void Connection:: set_collect_tcp_interval(double interval) { _collect_tcp_interval = interval; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::get_collect_tcp_interval -// Access: Published -// Description: Returns the interval in time, in seconds, for which -// to hold TCP packets before sending all of the -// recently received packets at once. This only has -// meaning if "collect-tcp" mode is enabled; see -// set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval in time, in seconds, for which to hold TCP packets + * before sending all of the recently received packets at once. This only has + * meaning if "collect-tcp" mode is enabled; see set_collect_tcp(). + */ double Connection:: get_collect_tcp_interval() const { return _collect_tcp_interval; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::consider_flush -// Access: Published -// Description: Sends the most recently queued TCP datagram(s) if -// enough time has elapsed. This only has meaning if -// set_collect_tcp() has been set to true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued TCP datagram(s) if enough time has elapsed. + * This only has meaning if set_collect_tcp() has been set to true. + */ bool Connection:: consider_flush() { LightReMutexHolder holder(_write_mutex); @@ -188,10 +153,10 @@ consider_flush() { return do_flush(); } else { - double elapsed = + double elapsed = TrueClock::get_global_ptr()->get_short_time() - _queued_data_start; - // If the elapsed time is negative, someone must have reset the - // clock back, so just go ahead and flush. + // If the elapsed time is negative, someone must have reset the clock + // back, so just go ahead and flush. if (elapsed < 0.0 || elapsed >= _collect_tcp_interval) { return do_flush(); } @@ -200,30 +165,25 @@ consider_flush() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::flush -// Access: Published -// Description: Sends the most recently queued TCP datagram(s) now. -// This only has meaning if set_collect_tcp() has been -// set to true. -//////////////////////////////////////////////////////////////////// +/** + * Sends the most recently queued TCP datagram(s) now. This only has meaning + * if set_collect_tcp() has been set to true. + */ bool Connection:: flush() { LightReMutexHolder holder(_write_mutex); return do_flush(); } + +/** + * Sets whether nonblocking I/O should be in effect. + */ /* This method is disabled. We don't provide enough interface to use non-blocking I/O effectively at this level, so we shouldn't provide this call. Specifically, we don't provide a way to query whether an operation failed because it would have blocked or not. - -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_nonblock -// Access: Published -// Description: Sets whether nonblocking I/O should be in effect. -//////////////////////////////////////////////////////////////////// void Connection:: set_nonblock(bool flag) { if (flag) { @@ -234,18 +194,14 @@ set_nonblock(bool flag) { } */ -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_linger -// Access: Published -// Description: Sets the time to linger on close if data is present. -// If flag is false, when you close a socket with data -// available the system attempts to deliver the data to -// the peer (the default behavior). If flag is false -// but time is zero, the system discards any undelivered -// data when you close the socket. If flag is false but -// time is nonzero, the system waits up to time seconds -// to deliver the data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the time to linger on close if data is present. If flag is false, + * when you close a socket with data available the system attempts to deliver + * the data to the peer (the default behavior). If flag is false but time is + * zero, the system discards any undelivered data when you close the socket. + * If flag is false but time is nonzero, the system waits up to time seconds + * to deliver the data. + */ void Connection:: set_linger(bool flag, double time) { Socket_TCP *tcp; @@ -258,42 +214,34 @@ set_linger(bool flag, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_reuse_addr -// Access: Published -// Description: Sets whether local address reuse is allowed. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether local address reuse is allowed. + */ void Connection:: set_reuse_addr(bool flag) { _socket->SetReuseAddress(flag); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_keep_alive -// Access: Published -// Description: Sets whether the connection is periodically tested to -// see if it is still alive. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the connection is periodically tested to see if it is still + * alive. + */ void Connection:: set_keep_alive(bool flag) { // TODO. } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_recv_buffer_size -// Access: Published -// Description: Sets the size of the receive buffer, in bytes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the receive buffer, in bytes. + */ void Connection:: set_recv_buffer_size(int size) { _socket->SetRecvBufferSize(size); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_send_buffer_size -// Access: Published -// Description: Sets the size of the send buffer, in bytes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the send buffer, in bytes. + */ void Connection:: set_send_buffer_size(int size) { Socket_TCP *tcp; @@ -302,32 +250,26 @@ set_send_buffer_size(int size) { tcp->SetSendBufferSize(size); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_ip_time_to_live -// Access: Published -// Description: Sets IP time-to-live. -//////////////////////////////////////////////////////////////////// +/** + * Sets IP time-to-live. + */ void Connection:: set_ip_time_to_live(int ttl) { // TODO. } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_ip_type_of_service -// Access: Published -// Description: Sets IP type-of-service and precedence. -//////////////////////////////////////////////////////////////////// +/** + * Sets IP type-of-service and precedence. + */ void Connection:: set_ip_type_of_service(int tos) { // TODO. } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_no_delay -// Access: Published -// Description: If flag is true, this disables the Nagle algorithm, -// and prevents delaying of send to coalesce packets. -//////////////////////////////////////////////////////////////////// +/** + * If flag is true, this disables the Nagle algorithm, and prevents delaying + * of send to coalesce packets. + */ void Connection:: set_no_delay(bool flag) { Socket_TCP *tcp; @@ -336,25 +278,20 @@ set_no_delay(bool flag) { tcp->SetNoDelay(flag); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::set_max_segment -// Access: Published -// Description: Sets the maximum segment size. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum segment size. + */ void Connection:: set_max_segment(int size) { // TODO. } -//////////////////////////////////////////////////////////////////// -// Function: Connection::send_datagram -// Access: Private -// Description: This method is intended only to be called by -// ConnectionWriter. It atomically writes the given -// datagram to the socket, returning true on success, -// false on failure. If the socket seems to be closed, -// it notifies the ConnectionManager. -//////////////////////////////////////////////////////////////////// +/** + * This method is intended only to be called by ConnectionWriter. It + * atomically writes the given datagram to the socket, returning true on + * success, false on failure. If the socket seems to be closed, it notifies + * the ConnectionManager. + */ bool Connection:: send_datagram(const NetDatagram &datagram, int tcp_header_size) { nassertr(_socket != (Socket_IP *)NULL, false); @@ -369,11 +306,11 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { string data; data += header.get_header(); data += datagram.get_message(); - + if (net_cat.is_debug()) { header.verify_datagram(datagram); } - + int bytes_to_send = data.length(); Socket_Address addr = datagram.get_address().get_addr(); @@ -384,14 +321,14 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { okflag = udp->SendTo(data, addr); } #endif // SIMPLE_THREADS - + if (net_cat.is_spam()) { net_cat.spam() - << "Sent UDP datagram with " - << bytes_to_send << " bytes to " << (void *)this + << "Sent UDP datagram with " + << bytes_to_send << " bytes to " << (void *)this << ", ok = " << okflag << "\n"; } - + return check_send_error(okflag); } @@ -410,12 +347,12 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { _queued_data += header.get_header(); _queued_data += datagram.get_message(); _queued_count++; - + if (net_cat.is_debug()) { header.verify_datagram(datagram, tcp_header_size); } - if (!_collect_tcp || + if (!_collect_tcp || TrueClock::get_global_ptr()->get_short_time() - _queued_data_start >= _collect_tcp_interval) { return do_flush(); } @@ -423,13 +360,11 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::send_raw_datagram -// Access: Private -// Description: This method is intended only to be called by -// ConnectionWriter. It atomically writes the given -// datagram to the socket, without the Datagram header. -//////////////////////////////////////////////////////////////////// +/** + * This method is intended only to be called by ConnectionWriter. It + * atomically writes the given datagram to the socket, without the Datagram + * header. + */ bool Connection:: send_raw_datagram(const NetDatagram &datagram) { nassertr(_socket != (Socket_IP *)NULL, false); @@ -450,11 +385,11 @@ send_raw_datagram(const NetDatagram &datagram) { okflag = udp->SendTo(data, addr); } #endif // SIMPLE_THREADS - + if (net_cat.is_spam()) { net_cat.spam() - << "Sent UDP datagram with " - << data.size() << " bytes to " << (void *)this + << "Sent UDP datagram with " + << data.size() << " bytes to " << (void *)this << ", ok = " << okflag << "\n"; } @@ -466,7 +401,7 @@ send_raw_datagram(const NetDatagram &datagram) { _queued_data += datagram.get_message(); _queued_count++; - if (!_collect_tcp || + if (!_collect_tcp || TrueClock::get_global_ptr()->get_short_time() - _queued_data_start >= _collect_tcp_interval) { return do_flush(); } @@ -474,12 +409,10 @@ send_raw_datagram(const NetDatagram &datagram) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Connection::do_flush -// Access: Private -// Description: The private implementation of flush(), this assumes -// the _write_mutex is already held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of flush(), this assumes the _write_mutex is + * already held. + */ bool Connection:: do_flush() { if (_queued_data.empty()) { @@ -490,7 +423,7 @@ do_flush() { if (net_cat.is_spam()) { net_cat.spam() - << "Sending " << _queued_count << " TCP datagram(s) with " + << "Sending " << _queued_count << " TCP datagram(s) with " << _queued_data.length() << " total bytes to " << (void *)this << "\n"; } @@ -537,12 +470,9 @@ do_flush() { return check_send_error(okflag); } -//////////////////////////////////////////////////////////////////// -// Function: Connection::check_send_error -// Access: Private -// Description: Checks the return value of a Send() or SendTo() -// call. -//////////////////////////////////////////////////////////////////// +/** + * Checks the return value of a Send() or SendTo() call. + */ bool Connection:: check_send_error(bool okflag) { if (!okflag) { @@ -551,8 +481,8 @@ check_send_error(bool okflag) { nassertr(false, false); } - // Assume any error means the connection has been reset; tell - // our manager about it and ignore it. + // Assume any error means the connection has been reset; tell our manager + // about it and ignore it. if (_manager != (ConnectionManager *)NULL) { _manager->flush_read_connection(this); _manager->connection_reset(this, okflag); diff --git a/panda/src/net/connection.h b/panda/src/net/connection.h index 9fe784196a..92cbf12166 100644 --- a/panda/src/net/connection.h +++ b/panda/src/net/connection.h @@ -1,16 +1,15 @@ -// Filename: connection.h -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connection.h + * @author jns + * @date 2000-02-07 + */ #ifndef CONNECTION_H #define CONNECTION_H @@ -24,11 +23,9 @@ class Socket_IP; class ConnectionManager; class NetDatagram; -//////////////////////////////////////////////////////////////////// -// Class : Connection -// Description : Represents a single TCP or UDP socket for input or -// output. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single TCP or UDP socket for input or output. + */ class EXPCL_PANDA_NET Connection : public ReferenceCount { PUBLISHED: Connection(ConnectionManager *manager, Socket_IP *socket); @@ -47,8 +44,7 @@ PUBLISHED: BLOCKING bool consider_flush(); BLOCKING bool flush(); - // Socket options. - // void set_nonblock(bool flag); + // Socket options. void set_nonblock(bool flag); void set_linger(bool flag, double time); void set_reuse_addr(bool flag); void set_keep_alive(bool flag); diff --git a/panda/src/net/connectionListener.cxx b/panda/src/net/connectionListener.cxx index 08ea7d4d17..a6e816683d 100644 --- a/panda/src/net/connectionListener.cxx +++ b/panda/src/net/connectionListener.cxx @@ -1,16 +1,15 @@ -// Filename: connectionListener.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionListener.cxx + * @author drose + * @date 2000-02-09 + */ #include "dcast.h" #include "connectionListener.h" @@ -20,7 +19,7 @@ #include "config_net.h" #include "socket_tcp_listen.h" -static string +static string listener_thread_name(const string &thread_name) { if (!thread_name.empty()) { return thread_name; @@ -28,11 +27,9 @@ listener_thread_name(const string &thread_name) { return "ListenerThread"; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListener::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionListener:: ConnectionListener(ConnectionManager *manager, int num_threads, const string &thread_name) : @@ -40,26 +37,20 @@ ConnectionListener(ConnectionManager *manager, int num_threads, { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListener::receive_datagram -// Access: Protected, Virtual -// Description: This function must be declared because it is pure -// virtual in the base class, but it isn't used in this -// class and doesn't do anything. -//////////////////////////////////////////////////////////////////// +/** + * This function must be declared because it is pure virtual in the base + * class, but it isn't used in this class and doesn't do anything. + */ void ConnectionListener:: receive_datagram(const NetDatagram &) { net_cat.error() << "ConnectionListener::receive_datagram called.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListener::process_incoming_data -// Access: Protected, Virtual -// Description: This is the function that is called when activity is -// detected on a rendezvous port. In this case, it -// performs the accept(). -//////////////////////////////////////////////////////////////////// +/** + * This is the function that is called when activity is detected on a + * rendezvous port. In this case, it performs the accept(). + */ bool ConnectionListener:: process_incoming_data(SocketInfo *sinfo) { Socket_TCP_Listen *socket; @@ -89,7 +80,7 @@ process_incoming_data(SocketInfo *sinfo) { << "Received TCP connection from client " << net_addr.get_ip_string() << " on port " << sinfo->_connection->get_address().get_port() << "\n"; - + PT(Connection) new_connection = new Connection(_manager, session); if (_manager != (ConnectionManager *)NULL) { _manager->new_connection(new_connection); diff --git a/panda/src/net/connectionListener.h b/panda/src/net/connectionListener.h index e2792834e1..9ec42ab456 100644 --- a/panda/src/net/connectionListener.h +++ b/panda/src/net/connectionListener.h @@ -1,16 +1,15 @@ -// Filename: connectionListener.h -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionListener.h + * @author drose + * @date 2000-02-09 + */ #ifndef CONNECTIONLISTENER_H #define CONNECTIONLISTENER_H @@ -21,17 +20,14 @@ class NetAddress; -//////////////////////////////////////////////////////////////////// -// Class : ConnectionListener -// Description : This is a special kind of ConnectionReader that waits -// for activity on a rendezvous port and accepts a TCP -// connection (instead of attempting to read a datagram -// from the rendezvous port). -// -// It is itself an abstract class, as it doesn't define -// what to do with the established connection. See -// QueuedConnectionListener. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of ConnectionReader that waits for activity on a + * rendezvous port and accepts a TCP connection (instead of attempting to read + * a datagram from the rendezvous port). + * + * It is itself an abstract class, as it doesn't define what to do with the + * established connection. See QueuedConnectionListener. + */ class EXPCL_PANDA_NET ConnectionListener : public ConnectionReader { PUBLISHED: ConnectionListener(ConnectionManager *manager, int num_threads, diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index a8e5405f9a..abfdc2f541 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -1,16 +1,15 @@ -// Filename: connectionManager.cxx -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionManager.cxx + * @author jns + * @date 2000-02-07 + */ #include "connectionManager.h" #include "connection.h" @@ -34,22 +33,18 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionManager:: -ConnectionManager() : _set_mutex("ConnectionManager::_set_mutex") +ConnectionManager() : _set_mutex("ConnectionManager::_set_mutex") { _interfaces_scanned = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionManager:: ~ConnectionManager() { // Notify all of our associated readers and writers that we're gone. @@ -64,44 +59,36 @@ ConnectionManager:: } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_UDP_connection -// Access: Published -// Description: Opens a socket for sending and/or receiving UDP -// packets. If the port number is greater than zero, -// the UDP connection will be opened for listening on -// the indicated port; otherwise, it will be useful only -// for sending. -// -// Use a ConnectionReader and ConnectionWriter to handle -// the actual communication. -//////////////////////////////////////////////////////////////////// +/** + * Opens a socket for sending and/or receiving UDP packets. If the port + * number is greater than zero, the UDP connection will be opened for + * listening on the indicated port; otherwise, it will be useful only for + * sending. + * + * Use a ConnectionReader and ConnectionWriter to handle the actual + * communication. + */ PT(Connection) ConnectionManager:: open_UDP_connection(int port) { return open_UDP_connection("", port); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_UDP_connection -// Access: Published -// Description: Opens a socket for sending and/or receiving UDP -// packets. If the port number is greater than zero, -// the UDP connection will be opened for listening on -// the indicated port; otherwise, it will be useful only -// for sending. -// -// This variant accepts both a hostname and port to -// listen on a particular interface; if the hostname is -// empty, all interfaces will be available. -// -// If for_broadcast is true, this UDP connection will be -// configured to send and/or receive messages on the -// broadcast address (255.255.255.255); otherwise, these -// messages may be automatically filtered by the OS. -// -// Use a ConnectionReader and ConnectionWriter to handle -// the actual communication. -//////////////////////////////////////////////////////////////////// +/** + * Opens a socket for sending and/or receiving UDP packets. If the port + * number is greater than zero, the UDP connection will be opened for + * listening on the indicated port; otherwise, it will be useful only for + * sending. + * + * This variant accepts both a hostname and port to listen on a particular + * interface; if the hostname is empty, all interfaces will be available. + * + * If for_broadcast is true, this UDP connection will be configured to send + * and/or receive messages on the broadcast address (255.255.255.255); + * otherwise, these messages may be automatically filtered by the OS. + * + * Use a ConnectionReader and ConnectionWriter to handle the actual + * communication. + */ PT(Connection) ConnectionManager:: open_UDP_connection(const string &hostname, int port, bool for_broadcast) { Socket_UDP *socket = new Socket_UDP; @@ -113,7 +100,7 @@ open_UDP_connection(const string &hostname, int port, bool for_broadcast) { } else { address.set_host(hostname, port); } - + if (!socket->OpenForInput(address.get_addr())) { if (hostname.empty()) { net_cat.error() @@ -121,7 +108,7 @@ open_UDP_connection(const string &hostname, int port, bool for_broadcast) { } else { net_cat.error() << "Unable to bind to " << hostname << ":" << port << " for UDP.\n"; - } + } delete socket; return PT(Connection)(); } @@ -165,22 +152,16 @@ open_UDP_connection(const string &hostname, int port, bool for_broadcast) { -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_TCP_server_rendezvous -// Access: Published -// Description: Creates a socket to be used as a rendezvous socket -// for a server to listen for TCP connections. The -// socket returned by this call should only be added to -// a ConnectionListener (not to a generic -// ConnectionReader). -// -// This variant of this method accepts a single port, -// and will listen to that port on all available -// interfaces. -// -// backlog is the maximum length of the queue of pending -// connections. -//////////////////////////////////////////////////////////////////// +/** + * Creates a socket to be used as a rendezvous socket for a server to listen + * for TCP connections. The socket returned by this call should only be added + * to a ConnectionListener (not to a generic ConnectionReader). + * + * This variant of this method accepts a single port, and will listen to that + * port on all available interfaces. + * + * backlog is the maximum length of the queue of pending connections. + */ PT(Connection) ConnectionManager:: open_TCP_server_rendezvous(int port, int backlog) { NetAddress address; @@ -188,25 +169,18 @@ open_TCP_server_rendezvous(int port, int backlog) { return open_TCP_server_rendezvous(address, backlog); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_TCP_server_rendezvous -// Access: Published -// Description: Creates a socket to be used as a rendezvous socket -// for a server to listen for TCP connections. The -// socket returned by this call should only be added to -// a ConnectionListener (not to a generic -// ConnectionReader). -// -// This variant of this method accepts a "hostname", -// which is usually just an IP address in dotted -// notation, and a port number. It will listen on the -// interface indicated by the IP address. If the IP -// address is empty string, it will listen on all -// interfaces. -// -// backlog is the maximum length of the queue of pending -// connections. -//////////////////////////////////////////////////////////////////// +/** + * Creates a socket to be used as a rendezvous socket for a server to listen + * for TCP connections. The socket returned by this call should only be added + * to a ConnectionListener (not to a generic ConnectionReader). + * + * This variant of this method accepts a "hostname", which is usually just an + * IP address in dotted notation, and a port number. It will listen on the + * interface indicated by the IP address. If the IP address is empty string, + * it will listen on all interfaces. + * + * backlog is the maximum length of the queue of pending connections. + */ PT(Connection) ConnectionManager:: open_TCP_server_rendezvous(const string &hostname, int port, int backlog) { NetAddress address; @@ -218,27 +192,21 @@ open_TCP_server_rendezvous(const string &hostname, int port, int backlog) { return open_TCP_server_rendezvous(address, backlog); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_TCP_server_rendezvous -// Access: Published -// Description: Creates a socket to be used as a rendezvous socket -// for a server to listen for TCP connections. The -// socket returned by this call should only be added to -// a ConnectionListener (not to a generic -// ConnectionReader). -// -// This variant of this method accepts a NetAddress, -// which allows you to specify a specific interface to -// listen to. -// -// backlog is the maximum length of the queue of pending -// connections. -//////////////////////////////////////////////////////////////////// +/** + * Creates a socket to be used as a rendezvous socket for a server to listen + * for TCP connections. The socket returned by this call should only be added + * to a ConnectionListener (not to a generic ConnectionReader). + * + * This variant of this method accepts a NetAddress, which allows you to + * specify a specific interface to listen to. + * + * backlog is the maximum length of the queue of pending connections. + */ PT(Connection) ConnectionManager:: open_TCP_server_rendezvous(const NetAddress &address, int backlog) { ostringstream strm; if (address.get_ip() == 0) { - strm << "port " << address.get_port(); + strm << "port " << address.get_port(); } else { strm << address.get_ip_string() << ":" << address.get_port(); } @@ -260,20 +228,17 @@ open_TCP_server_rendezvous(const NetAddress &address, int backlog) { return connection; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_TCP_client_connection -// Access: Published -// Description: Attempts to establish a TCP client connection to a -// server at the indicated address. If the connection -// is not established within timeout_ms milliseconds, a -// null connection is returned. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to establish a TCP client connection to a server at the indicated + * address. If the connection is not established within timeout_ms + * milliseconds, a null connection is returned. + */ PT(Connection) ConnectionManager:: open_TCP_client_connection(const NetAddress &address, int timeout_ms) { Socket_TCP *socket = new Socket_TCP; - // We always open the connection with non-blocking mode first, so we - // can implement the timeout. + // We always open the connection with non-blocking mode first, so we can + // implement the timeout. bool okflag = socket->ActiveOpenNonBlocking(address.get_addr()); if (okflag && socket->GetLastError() == LOCAL_CONNECT_BLOCKING) { // Now wait for the socket to connect. @@ -313,9 +278,9 @@ open_TCP_client_connection(const NetAddress &address, int timeout_ms) { } #if !defined(HAVE_THREADS) || !defined(SIMPLE_THREADS) - // Now we have opened the socket in nonblocking mode. Unless we're - // using SIMPLE_THREADS, though, we really want the socket in - // blocking mode (since that's what we support here). Change it. + // Now we have opened the socket in nonblocking mode. Unless we're using + // SIMPLE_THREADS, though, we really want the socket in blocking mode (since + // that's what we support here). Change it. socket->SetBlocking(); #endif // SIMPLE_THREADS @@ -329,13 +294,10 @@ open_TCP_client_connection(const NetAddress &address, int timeout_ms) { return connection; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::open_TCP_client_connection -// Access: Published -// Description: This is a shorthand version of the function to -// directly establish communications to a named host and -// port. -//////////////////////////////////////////////////////////////////// +/** + * This is a shorthand version of the function to directly establish + * communications to a named host and port. + */ PT(Connection) ConnectionManager:: open_TCP_client_connection(const string &hostname, int port, int timeout_ms) { @@ -347,25 +309,20 @@ open_TCP_client_connection(const string &hostname, int port, return open_TCP_client_connection(address, timeout_ms); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::close_connection -// Access: Published -// Description: Terminates a UDP or TCP socket previously opened. -// This also removes it from any associated -// ConnectionReader or ConnectionListeners. -// -// The socket itself may not be immediately closed--it -// will not be closed until all outstanding pointers to -// it are cleared, including any pointers remaining in -// NetDatagrams recently received from the socket. -// -// The return value is true if the connection was marked -// to be closed, or false if close_connection() had -// already been called (or the connection did not belong -// to this ConnectionManager). In neither case can you -// infer anything about whether the connection has -// *actually* been closed yet based on the return value. -//////////////////////////////////////////////////////////////////// +/** + * Terminates a UDP or TCP socket previously opened. This also removes it + * from any associated ConnectionReader or ConnectionListeners. + * + * The socket itself may not be immediately closed--it will not be closed + * until all outstanding pointers to it are cleared, including any pointers + * remaining in NetDatagrams recently received from the socket. + * + * The return value is true if the connection was marked to be closed, or + * false if close_connection() had already been called (or the connection did + * not belong to this ConnectionManager). In neither case can you infer + * anything about whether the connection has *actually* been closed yet based + * on the return value. + */ bool ConnectionManager:: close_connection(const PT(Connection) &connection) { if (connection != (Connection *)NULL) { @@ -380,7 +337,7 @@ close_connection(const PT(Connection) &connection) { return false; } _connections.erase(ci); - + Readers::iterator ri; for (ri = _readers.begin(); ri != _readers.end(); ++ri) { (*ri)->remove_connection(connection); @@ -389,11 +346,10 @@ close_connection(const PT(Connection) &connection) { Socket_IP *socket = connection->get_socket(); - // We can't *actually* close the connection right now, because - // there might be outstanding pointers to it. But we can at least - // shut it down. It will be eventually closed when all the - // pointers let go. - + // We can't *actually* close the connection right now, because there might + // be outstanding pointers to it. But we can at least shut it down. It + // will be eventually closed when all the pointers let go. + net_cat.info() << "Shutting down connection " << (void *)connection << " locally.\n"; @@ -403,26 +359,20 @@ close_connection(const PT(Connection) &connection) { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::wait_for_readers -// Access: Published -// Description: Blocks the process for timeout number of seconds, or -// until any data is available on any of the -// non-threaded ConnectionReaders or -// ConnectionListeners, whichever comes first. The -// return value is true if there is data available (but -// you have to iterate through all readers to find it), -// or false if the timeout occurred without any data. -// -// If the timeout value is negative, this will block -// forever or until data is available. -// -// This only works if all ConnectionReaders and -// ConnectionListeners are non-threaded. If any -// threaded ConnectionReaders are part of the -// ConnectionManager, the timeout value is implicitly -// treated as 0. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the process for timeout number of seconds, or until any data is + * available on any of the non-threaded ConnectionReaders or + * ConnectionListeners, whichever comes first. The return value is true if + * there is data available (but you have to iterate through all readers to + * find it), or false if the timeout occurred without any data. + * + * If the timeout value is negative, this will block forever or until data is + * available. + * + * This only works if all ConnectionReaders and ConnectionListeners are non- + * threaded. If any threaded ConnectionReaders are part of the + * ConnectionManager, the timeout value is implicitly treated as 0. + */ bool ConnectionManager:: wait_for_readers(double timeout) { bool block_forever = false; @@ -438,16 +388,16 @@ wait_for_readers(double timeout) { Socket_fdset fdset; fdset.clear(); bool any_threaded = false; - + { LightMutexHolder holder(_set_mutex); - + Readers::iterator ri; for (ri = _readers.begin(); ri != _readers.end(); ++ri) { ConnectionReader *reader = (*ri); if (reader->is_polling()) { - // If it's a polling reader, we can wait for its socket. - // (If it's a threaded reader, we can't do anything here.) + // If it's a polling reader, we can wait for its socket. (If it's a + // threaded reader, we can't do anything here.) reader->accumulate_fdset(fdset); } else { any_threaded = true; @@ -458,26 +408,25 @@ wait_for_readers(double timeout) { } double wait_timeout = get_net_max_block(); - if (!block_forever) { + if (!block_forever) { wait_timeout = min(wait_timeout, stop - now); } PN_uint32 wait_timeout_ms = (PN_uint32)(wait_timeout * 1000.0); if (any_threaded) { - // If there are any threaded ConnectionReaders, we can't block - // at all. + // If there are any threaded ConnectionReaders, we can't block at all. wait_timeout_ms = 0; } #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In the presence of SIMPLE_THREADS, we never wait at all, - // but rather we yield the thread if we come up empty (so that - // we won't block the entire process). + // In the presence of SIMPLE_THREADS, we never wait at all, but rather we + // yield the thread if we come up empty (so that we won't block the entire + // process). wait_timeout_ms = 0; #endif int num_results = fdset.WaitForRead(false, wait_timeout_ms); if (num_results != 0) { - // If we got an answer (or an error), return success. The - // caller can then figure out what happened. + // If we got an answer (or an error), return success. The caller can + // then figure out what happened. if (num_results < 0) { // Go ahead and yield the timeslice if we got an error. Thread::force_yield(); @@ -485,9 +434,9 @@ wait_for_readers(double timeout) { return true; } - // No answer yet, so yield and wait some more. We don't actually - // block forever, even in the threaded case, so we can detect - // ConnectionReaders being added and removed and such. + // No answer yet, so yield and wait some more. We don't actually block + // forever, even in the threaded case, so we can detect ConnectionReaders + // being added and removed and such. Thread::force_yield(); now = clock->get_short_time(); @@ -497,13 +446,10 @@ wait_for_readers(double timeout) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::get_host_name -// Access: Published, Static -// Description: Returns the name of this particular machine on the -// network, if available, or the empty string if the -// hostname cannot be determined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of this particular machine on the network, if available, + * or the empty string if the hostname cannot be determined. + */ string ConnectionManager:: get_host_name() { char temp_buff[1024]; @@ -514,15 +460,12 @@ get_host_name() { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::scan_interfaces -// Access: Published -// Description: Repopulates the list reported by -// get_num_interface()/get_interface(). It is not -// necessary to call this explicitly, unless you want to -// re-determine the connected interfaces (for instance, -// if you suspect the hardware has recently changed). -//////////////////////////////////////////////////////////////////// +/** + * Repopulates the list reported by get_num_interface()/get_interface(). It + * is not necessary to call this explicitly, unless you want to re-determine + * the connected interfaces (for instance, if you suspect the hardware has + * recently changed). + */ void ConnectionManager:: scan_interfaces() { LightMutexHolder holder(_set_mutex); @@ -539,9 +482,8 @@ scan_interfaces() { if (result == ERROR_SUCCESS) { IP_ADAPTER_ADDRESSES *p = addresses; while (p != NULL) { - // p->AdapterName appears to be a GUID. Not sure if this is - // actually useful to anyone; we'll store the "friendly name" - // instead. + // p->AdapterName appears to be a GUID. Not sure if this is actually + // useful to anyone; we'll store the "friendly name" instead. TextEncoder encoder; encoder.set_wtext(wstring(p->FriendlyName)); string friendly_name = encoder.get_text(); @@ -554,8 +496,8 @@ scan_interfaces() { } if (p->OperStatus == IfOperStatusUp) { - // Prefixes are a linked list, in the order Network IP, - // Adapter IP, Broadcast IP (plus more). + // Prefixes are a linked list, in the order Network IP, Adapter IP, + // Broadcast IP (plus more). NetAddress addresses[3]; IP_ADAPTER_PREFIX *m = p->FirstPrefix; int mc = 0; @@ -573,8 +515,8 @@ scan_interfaces() { iface.set_broadcast(addresses[2]); // Now, we can infer the netmask by the difference between the - // network address (the first address) and the broadcast - // address (the last address). + // network address (the first address) and the broadcast address + // (the last address). PN_uint32 netmask = addresses[0].get_ip() - addresses[2].get_ip() - 1; Socket_Address sa; sa.set_host(netmask, 0); @@ -628,14 +570,11 @@ scan_interfaces() { #endif // WIN32_VC } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::get_num_interfaces -// Access: Published -// Description: This returns the number of usable network interfaces -// detected on this machine. (Currently, only IPv4 -// interfaces are reported.) See scan_interfaces() to -// repopulate this list. -//////////////////////////////////////////////////////////////////// +/** + * This returns the number of usable network interfaces detected on this + * machine. (Currently, only IPv4 interfaces are reported.) See + * scan_interfaces() to repopulate this list. + */ int ConnectionManager:: get_num_interfaces() { if (!_interfaces_scanned) { @@ -645,14 +584,11 @@ get_num_interfaces() { return _interfaces.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::get_interface -// Access: Published -// Description: Returns the nth usable network interface detected on -// this machine. (Currently, only IPv4 interfaces are -// reported.) See scan_interfaces() to repopulate this -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth usable network interface detected on this machine. + * (Currently, only IPv4 interfaces are reported.) See scan_interfaces() to + * repopulate this list. + */ const ConnectionManager::Interface &ConnectionManager:: get_interface(int n) { if (!_interfaces_scanned) { @@ -663,29 +599,23 @@ get_interface(int n) { return _interfaces[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::new_connection -// Access: Protected -// Description: This internal function is called whenever a new -// connection is established. It allows the -// ConnectionManager to save all of the pointers to open -// connections so they can't be inadvertently deleted -// until close_connection() is called. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called whenever a new connection is established. + * It allows the ConnectionManager to save all of the pointers to open + * connections so they can't be inadvertently deleted until close_connection() + * is called. + */ void ConnectionManager:: new_connection(const PT(Connection) &connection) { LightMutexHolder holder(_set_mutex); _connections.insert(connection); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::flush_read_connection -// Access: Protected, Virtual -// Description: An internal function called by ConnectionWriter only -// when a write failure has occurred. This method -// ensures that all of the read data has been flushed -// from the pipe before the connection is fully removed. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionWriter only when a write failure + * has occurred. This method ensures that all of the read data has been + * flushed from the pipe before the connection is fully removed. + */ void ConnectionManager:: flush_read_connection(Connection *connection) { Readers readers; @@ -710,15 +640,11 @@ flush_read_connection(Connection *connection) { socket->Close(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::connection_reset -// Access: Protected, Virtual -// Description: An internal function called by the ConnectionReader, -// ConnectionWriter, or ConnectionListener when a -// connection has been externally reset. This adds the -// connection to the queue of those which have recently -// been reset. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by the ConnectionReader, ConnectionWriter, or + * ConnectionListener when a connection has been externally reset. This adds + * the connection to the queue of those which have recently been reset. + */ void ConnectionManager:: connection_reset(const PT(Connection) &connection, bool okflag) { if (net_cat.is_info()) { @@ -735,65 +661,53 @@ connection_reset(const PT(Connection) &connection, bool okflag) { } // Turns out we do need to explicitly mark the connection as closed - // immediately, rather than waiting for the user to do it, since - // otherwise we'll keep trying to listen for noise on the socket and - // we'll always hear a "yes" answer. + // immediately, rather than waiting for the user to do it, since otherwise + // we'll keep trying to listen for noise on the socket and we'll always hear + // a "yes" answer. close_connection(connection); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::add_reader -// Access: Protected -// Description: This internal function is called by ConnectionReader -// when it is constructed. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by ConnectionReader when it is + * constructed. + */ void ConnectionManager:: add_reader(ConnectionReader *reader) { LightMutexHolder holder(_set_mutex); _readers.insert(reader); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::remove_reader -// Access: Protected -// Description: This internal function is called by ConnectionReader -// when it is destructed. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by ConnectionReader when it is destructed. + */ void ConnectionManager:: remove_reader(ConnectionReader *reader) { LightMutexHolder holder(_set_mutex); _readers.erase(reader); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::add_writer -// Access: Protected -// Description: This internal function is called by ConnectionWriter -// when it is constructed. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by ConnectionWriter when it is + * constructed. + */ void ConnectionManager:: add_writer(ConnectionWriter *writer) { LightMutexHolder holder(_set_mutex); _writers.insert(writer); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::remove_writer -// Access: Protected -// Description: This internal function is called by ConnectionWriter -// when it is destructed. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by ConnectionWriter when it is destructed. + */ void ConnectionManager:: remove_writer(ConnectionWriter *writer) { LightMutexHolder holder(_set_mutex); _writers.erase(writer); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::format_mac_address -// Access: Protected -// Description: Formats a device's MAC address into a string. -//////////////////////////////////////////////////////////////////// +/** + * Formats a device's MAC address into a string. + */ string ConnectionManager:: format_mac_address(const unsigned char *data, int data_size) { stringstream strm; @@ -807,11 +721,9 @@ format_mac_address(const unsigned char *data, int data_size) { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionManager::Interface::Output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConnectionManager::Interface:: output(ostream &out) const { out << get_name() << " ["; diff --git a/panda/src/net/connectionManager.h b/panda/src/net/connectionManager.h index 8a9878a335..cf5772386c 100644 --- a/panda/src/net/connectionManager.h +++ b/panda/src/net/connectionManager.h @@ -1,16 +1,15 @@ -// Filename: connectionManager.h -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionManager.h + * @author jns + * @date 2000-02-07 + */ #ifndef CONNECTIONMANAGER_H #define CONNECTIONMANAGER_H @@ -28,22 +27,17 @@ class NetAddress; class ConnectionReader; class ConnectionWriter; -//////////////////////////////////////////////////////////////////// -// Class : ConnectionManager -// Description : The primary interface to the low-level networking -// layer in this package. A ConnectionManager is used -// to establish and destroy TCP and UDP connections. -// Communication on these connections, once established, -// is handled via ConnectionReader, ConnectionWriter, -// and ConnectionListener. -// -// You may use this class directly if you don't care -// about tracking which connections have been -// unexpectedly closed; otherwise, you should use -// QueuedConnectionManager to get reports about these -// events (or derive your own class to handle these -// events properly). -//////////////////////////////////////////////////////////////////// +/** + * The primary interface to the low-level networking layer in this package. A + * ConnectionManager is used to establish and destroy TCP and UDP connections. + * Communication on these connections, once established, is handled via + * ConnectionReader, ConnectionWriter, and ConnectionListener. + * + * You may use this class directly if you don't care about tracking which + * connections have been unexpectedly closed; otherwise, you should use + * QueuedConnectionManager to get reports about these events (or derive your + * own class to handle these events properly). + */ class EXPCL_PANDA_NET ConnectionManager { PUBLISHED: ConnectionManager(); @@ -53,9 +47,9 @@ PUBLISHED: PT(Connection) open_UDP_connection(const string &hostname, int port, bool for_broadcast = false); BLOCKING PT(Connection) open_TCP_server_rendezvous(int port, int backlog); - BLOCKING PT(Connection) open_TCP_server_rendezvous(const string &hostname, + BLOCKING PT(Connection) open_TCP_server_rendezvous(const string &hostname, int port, int backlog); - BLOCKING PT(Connection) open_TCP_server_rendezvous(const NetAddress &address, + BLOCKING PT(Connection) open_TCP_server_rendezvous(const NetAddress &address, int backlog); BLOCKING PT(Connection) open_TCP_client_connection(const NetAddress &address, int timeout_ms); @@ -117,7 +111,7 @@ PUBLISHED: protected: void new_connection(const PT(Connection) &connection); virtual void flush_read_connection(Connection *connection); - virtual void connection_reset(const PT(Connection) &connection, + virtual void connection_reset(const PT(Connection) &connection, bool okflag); void add_reader(ConnectionReader *reader); diff --git a/panda/src/net/connectionReader.I b/panda/src/net/connectionReader.I index e9ff4882fd..a22e2339c9 100644 --- a/panda/src/net/connectionReader.I +++ b/panda/src/net/connectionReader.I @@ -1,24 +1,19 @@ -// Filename: connectionReader.I -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionReader.I + * @author drose + * @date 2009-02-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::is_polling -// Access: Published -// Description: Returns true if the reader is a polling reader, -// i.e. it has no threads. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader is a polling reader, i.e. it has no threads. + */ INLINE bool ConnectionReader:: is_polling() const { return _polling; diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index e0a8b35fa7..7a63d90833 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -1,16 +1,15 @@ -// Filename: connectionReader.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionReader.cxx + * @author drose + * @date 2000-02-08 + */ #include "connectionReader.h" #include "dcast.h" @@ -30,11 +29,9 @@ static const int read_buffer_size = maximum_udp_datagram + datagram_udp_header_size; -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::SocketInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionReader::SocketInfo:: SocketInfo(const PT(Connection) &connection) : _connection(connection) @@ -43,60 +40,49 @@ SocketInfo(const PT(Connection) &connection) : _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::SocketInfo::is_udp -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ConnectionReader::SocketInfo:: is_udp() const { return (_connection->get_socket()->is_exact_type(Socket_UDP::get_class_type())); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::SocketInfo::get_socket -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Socket_IP *ConnectionReader::SocketInfo:: get_socket() const { return _connection->get_socket(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::ReaderThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionReader::ReaderThread:: -ReaderThread(ConnectionReader *reader, const string &thread_name, +ReaderThread(ConnectionReader *reader, const string &thread_name, int thread_index) : - Thread(make_thread_name(thread_name, thread_index), + Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), _reader(reader), _thread_index(thread_index) { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::ReaderThread::thread_main -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConnectionReader::ReaderThread:: thread_main() { _reader->thread_run(_thread_index); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::Constructor -// Access: Published -// Description: Creates a new ConnectionReader with the indicated -// number of threads to handle requests. If num_threads -// is 0, the sockets will only be read by polling, -// during an explicit poll() call. -// (QueuedConnectionReader will do this automatically.) -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ConnectionReader with the indicated number of threads to + * handle requests. If num_threads is 0, the sockets will only be read by + * polling, during an explicit poll() call. (QueuedConnectionReader will do + * this automatically.) + */ ConnectionReader:: ConnectionReader(ConnectionManager *manager, int num_threads, const string &thread_name) : @@ -141,11 +127,9 @@ ConnectionReader(ConnectionManager *manager, int num_threads, _manager->add_reader(this); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionReader:: ~ConnectionReader() { if (_manager != (ConnectionManager *)NULL) { @@ -174,23 +158,18 @@ ConnectionReader:: } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::add_connection -// Access: Published -// Description: Adds a new socket to the list of sockets the -// ConnectionReader will monitor. A datagram that comes -// in on any of the monitored sockets will be reported. -// In the case of a ConnectionListener, this adds a new -// rendezvous socket; any activity on any of the -// monitored sockets will cause a connection to be -// accepted. -// -// The return value is true if the connection was added, -// false if it was already there. -// -// add_connection() is thread-safe, and may be called at -// will by any thread. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new socket to the list of sockets the ConnectionReader will monitor. + * A datagram that comes in on any of the monitored sockets will be reported. + * In the case of a ConnectionListener, this adds a new rendezvous socket; any + * activity on any of the monitored sockets will cause a connection to be + * accepted. + * + * The return value is true if the connection was added, false if it was + * already there. + * + * add_connection() is thread-safe, and may be called at will by any thread. + */ bool ConnectionReader:: add_connection(Connection *connection) { nassertr(connection != (Connection *)NULL, false); @@ -211,17 +190,14 @@ add_connection(Connection *connection) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::remove_connection -// Access: Published -// Description: Removes a socket from the list of sockets being -// monitored. Returns true if the socket was correctly -// removed, false if it was not on the list in the first -// place. -// -// remove_connection() is thread-safe, and may be called -// at will by any thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes a socket from the list of sockets being monitored. Returns true if + * the socket was correctly removed, false if it was not on the list in the + * first place. + * + * remove_connection() is thread-safe, and may be called at will by any + * thread. + */ bool ConnectionReader:: remove_connection(Connection *connection) { LightMutexHolder holder(_sockets_mutex); @@ -242,23 +218,18 @@ remove_connection(Connection *connection) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::is_connection_ok -// Access: Published -// Description: Returns true if the indicated connection has been -// added to the ConnectionReader and is being monitored -// properly, false if it is not known, or if there was -// some error condition detected on the connection. (If -// there was an error condition, normally the -// ConnectionManager would have been informed and closed -// the connection.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated connection has been added to the + * ConnectionReader and is being monitored properly, false if it is not known, + * or if there was some error condition detected on the connection. (If there + * was an error condition, normally the ConnectionManager would have been + * informed and closed the connection.) + */ bool ConnectionReader:: is_connection_ok(Connection *connection) { LightMutexHolder holder(_sockets_mutex); - // Walk through the list of sockets to find the one we're asking - // about. + // Walk through the list of sockets to find the one we're asking about. Sockets::iterator si; si = _sockets.begin(); while (si != _sockets.end() && (*si)->_connection != connection) { @@ -275,18 +246,14 @@ is_connection_ok(Connection *connection) { return is_ok; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::poll -// Access: Published -// Description: Explicitly polls the available sockets to see if any -// of them have any noise. This function does nothing -// unless this is a polling-type ConnectionReader, -// i.e. it was created with zero threads (and -// is_polling() will return true). -// -// It is not necessary to call this explicitly for a -// QueuedConnectionReader. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly polls the available sockets to see if any of them have any + * noise. This function does nothing unless this is a polling-type + * ConnectionReader, i.e. it was created with zero threads (and is_polling() + * will return true). + * + * It is not necessary to call this explicitly for a QueuedConnectionReader. + */ void ConnectionReader:: poll() { if (!_polling) { @@ -319,95 +286,75 @@ poll() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::get_manager -// Access: Published -// Description: Returns a pointer to the ConnectionManager object -// that serves this ConnectionReader. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the ConnectionManager object that serves this + * ConnectionReader. + */ ConnectionManager *ConnectionReader:: get_manager() const { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::get_num_threads -// Access: Published -// Description: Returns the number of threads the ConnectionReader -// has been created with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads the ConnectionReader has been created with. + */ int ConnectionReader:: get_num_threads() const { return _threads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::set_raw_mode -// Access: Published -// Description: Sets the ConnectionReader into raw mode (or turns off -// raw mode). In raw mode, datagram headers are not -// expected; instead, all the data available on the pipe -// is treated as a single datagram. -// -// This is similar to set_tcp_header_size(0), except that it -// also turns off headers for UDP packets. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ConnectionReader into raw mode (or turns off raw mode). In raw + * mode, datagram headers are not expected; instead, all the data available on + * the pipe is treated as a single datagram. + * + * This is similar to set_tcp_header_size(0), except that it also turns off + * headers for UDP packets. + */ void ConnectionReader:: set_raw_mode(bool mode) { _raw_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::get_raw_mode -// Access: Published -// Description: Returns the current setting of the raw mode flag. -// See set_raw_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the raw mode flag. See set_raw_mode(). + */ bool ConnectionReader:: get_raw_mode() const { return _raw_mode; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::set_tcp_header_size -// Access: Published -// Description: Sets the header size of TCP packets. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size of TCP packets. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ void ConnectionReader:: set_tcp_header_size(int tcp_header_size) { _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::get_tcp_header_size -// Access: Published -// Description: Returns the current setting of TCP header size. -// See set_tcp_header_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of TCP header size. See set_tcp_header_size(). + */ int ConnectionReader:: get_tcp_header_size() const { return _tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::shutdown -// Access: Published -// Description: Terminates all threads cleanly. Normally this is -// only called by the destructor, but it may be called -// explicitly before destruction. -//////////////////////////////////////////////////////////////////// +/** + * Terminates all threads cleanly. Normally this is only called by the + * destructor, but it may be called explicitly before destruction. + */ void ConnectionReader:: shutdown() { if (_shutdown) { return; } - // First, begin the shutdown. This will tell our threads we want - // them to quit. + // First, begin the shutdown. This will tell our threads we want them to + // quit. _shutdown = true; // Now wait for all of our threads to terminate. @@ -417,15 +364,11 @@ shutdown() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::flush_read_connection -// Access: Protected, Virtual -// Description: Attempts to read all the possible data from the -// indicated connection, which has just delivered a -// write error (and has therefore already been closed). -// If the connection is not monitered by this reader, -// does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to read all the possible data from the indicated connection, which + * has just delivered a write error (and has therefore already been closed). + * If the connection is not monitered by this reader, does nothing. + */ void ConnectionReader:: flush_read_connection(Connection *connection) { // Ensure it doesn't get deleted. @@ -436,11 +379,10 @@ flush_read_connection(Connection *connection) { return; } - // The connection was previously in the reader, but has now been - // removed. Now we can flush it completely. We check if there is - // any read data available on just this one socket; we can do this - // right here in this thread, since we've already removed this - // connection from the reader. + // The connection was previously in the reader, but has now been removed. + // Now we can flush it completely. We check if there is any read data + // available on just this one socket; we can do this right here in this + // thread, since we've already removed this connection from the reader. Socket_fdset fdset; fdset.clear(); @@ -456,45 +398,34 @@ flush_read_connection(Connection *connection) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::clear_manager -// Access: Protected -// Description: This should normally only be called when the -// associated ConnectionManager destructs. It resets -// the ConnectionManager pointer to NULL so we don't -// have a floating pointer. This makes the -// ConnectionReader invalid; presumably it also will be -// destructed momentarily. -//////////////////////////////////////////////////////////////////// +/** + * This should normally only be called when the associated ConnectionManager + * destructs. It resets the ConnectionManager pointer to NULL so we don't + * have a floating pointer. This makes the ConnectionReader invalid; + * presumably it also will be destructed momentarily. + */ void ConnectionReader:: clear_manager() { _manager = (ConnectionManager *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::finish_socket -// Access: Protected -// Description: To be called when a socket has been fully read and is -// ready for polling for additional data. -//////////////////////////////////////////////////////////////////// +/** + * To be called when a socket has been fully read and is ready for polling for + * additional data. + */ void ConnectionReader:: finish_socket(SocketInfo *sinfo) { nassertv(sinfo->_busy); - // By marking the SocketInfo nonbusy, we make it available for - // future polls. + // By marking the SocketInfo nonbusy, we make it available for future polls. sinfo->_busy = false; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::process_incoming_data -// Access: Protected, Virtual -// Description: This is run within a thread when the call to -// select() indicates there is data available on a -// socket. Returns true if the data is read -// successfully, false on failure (for instance, because -// the connection is closed). -//////////////////////////////////////////////////////////////////// +/** + * This is run within a thread when the call to select() indicates there is + * data available on a socket. Returns true if the data is read successfully, + * false on failure (for instance, because the connection is closed). + */ bool ConnectionReader:: process_incoming_data(SocketInfo *sinfo) { if (_raw_mode) { @@ -512,11 +443,9 @@ process_incoming_data(SocketInfo *sinfo) { } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::process_incoming_udp_data -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ConnectionReader:: process_incoming_udp_data(SocketInfo *sinfo) { Socket_UDP *socket; @@ -543,31 +472,31 @@ process_incoming_udp_data(SocketInfo *sinfo) { return false; } - // Since we are not running in raw mode, we decode the header to - // determine how big the datagram is. This means we must have read - // at least a full header. + // Since we are not running in raw mode, we decode the header to determine + // how big the datagram is. This means we must have read at least a full + // header. if (bytes_read < datagram_udp_header_size) { net_cat.error() << "Did not read entire header, discarding UDP datagram.\n"; finish_socket(sinfo); return true; } - + DatagramUDPHeader header(buffer); - + char *dp = buffer + datagram_udp_header_size; bytes_read -= datagram_udp_header_size; - + NetDatagram datagram(dp, bytes_read); - - // Now that we've read all the data, it's time to finish the socket - // so another thread can read the next datagram. + + // Now that we've read all the data, it's time to finish the socket so + // another thread can read the next datagram. finish_socket(sinfo); - + if (_shutdown) { return false; } - + // And now do whatever we need to do to process the datagram. if (!header.verify_datagram(datagram)) { net_cat.error() @@ -578,8 +507,8 @@ process_incoming_udp_data(SocketInfo *sinfo) { if (net_cat.is_spam()) { net_cat.spam() - << "Received UDP datagram with " - << datagram_udp_header_size + datagram.get_length() + << "Received UDP datagram with " + << datagram_udp_header_size + datagram.get_length() << " bytes on " << (void *)datagram.get_connection() << " from " << datagram.get_address() << "\n"; } @@ -590,11 +519,9 @@ process_incoming_udp_data(SocketInfo *sinfo) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::process_incoming_tcp_data -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ConnectionReader:: process_incoming_tcp_data(SocketInfo *sinfo) { Socket_TCP *socket; @@ -631,11 +558,10 @@ process_incoming_tcp_data(SocketInfo *sinfo) { Thread::consider_yield(); } - // Now we must decode the header to determine how big the datagram - // is. This means we must have read at least a full header. + // Now we must decode the header to determine how big the datagram is. This + // means we must have read at least a full header. if (header_bytes_read != _tcp_header_size) { - // This should actually be impossible, by the read-loop logic - // above. + // This should actually be impossible, by the read-loop logic above. net_cat.error() << "Did not read entire header, discarding TCP datagram.\n"; finish_socket(sinfo); @@ -653,9 +579,8 @@ process_incoming_tcp_data(SocketInfo *sinfo) { int read_bytes = read_buffer_size; #ifdef SIMPLE_THREADS - // In the SIMPLE_THREADS case, we want to limit the number of - // bytes we read in a single epoch, to minimize the impact on the - // other threads. + // In the SIMPLE_THREADS case, we want to limit the number of bytes we + // read in a single epoch, to minimize the impact on the other threads. read_bytes = min(read_buffer_size, (int)net_max_read_per_epoch); #endif @@ -688,8 +613,8 @@ process_incoming_tcp_data(SocketInfo *sinfo) { datagram.append_data(dp, datagram_bytes); if (bytes_read > datagram_bytes) { - // There were some extra bytes at the end of the datagram. Maybe - // the beginning of the next datagram? Huh. + // There were some extra bytes at the end of the datagram. Maybe the + // beginning of the next datagram? Huh. net_cat.error() << "Discarding " << bytes_read - datagram_bytes << " bytes following TCP datagram.\n"; @@ -697,8 +622,8 @@ process_incoming_tcp_data(SocketInfo *sinfo) { Thread::consider_yield(); } - // Now that we've read all the data, it's time to finish the socket - // so another thread can read the next datagram. + // Now that we've read all the data, it's time to finish the socket so + // another thread can read the next datagram. finish_socket(sinfo); if (_shutdown) { @@ -715,23 +640,21 @@ process_incoming_tcp_data(SocketInfo *sinfo) { if (net_cat.is_spam()) { net_cat.spam() - << "Received TCP datagram with " - << _tcp_header_size + datagram.get_length() + << "Received TCP datagram with " + << _tcp_header_size + datagram.get_length() << " bytes on " << (void *)datagram.get_connection() << " from " << datagram.get_address() << "\n"; } - + receive_datagram(datagram); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::process_raw_incoming_udp_data -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ConnectionReader:: process_raw_incoming_udp_data(SocketInfo *sinfo) { Socket_UDP *socket; @@ -758,24 +681,23 @@ process_raw_incoming_udp_data(SocketInfo *sinfo) { return false; } - // In raw mode, we simply extract all the bytes and make that a - // datagram. + // In raw mode, we simply extract all the bytes and make that a datagram. NetDatagram datagram(buffer, bytes_read); - - // Now that we've read all the data, it's time to finish the socket - // so another thread can read the next datagram. + + // Now that we've read all the data, it's time to finish the socket so + // another thread can read the next datagram. finish_socket(sinfo); - + if (_shutdown) { return false; } - + datagram.set_connection(sinfo->_connection); datagram.set_address(NetAddress(addr)); if (net_cat.is_spam()) { net_cat.spam() - << "Received raw UDP datagram with " << datagram.get_length() + << "Received raw UDP datagram with " << datagram.get_length() << " bytes on " << (void *)datagram.get_connection() << " from " << datagram.get_address() << "\n"; } @@ -785,11 +707,9 @@ process_raw_incoming_udp_data(SocketInfo *sinfo) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::process_raw_incoming_tcp_data -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ConnectionReader:: process_raw_incoming_tcp_data(SocketInfo *sinfo) { Socket_TCP *socket; @@ -799,7 +719,7 @@ process_raw_incoming_tcp_data(SocketInfo *sinfo) { char buffer[read_buffer_size]; int bytes_read = socket->RecvData(buffer, read_buffer_size); #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - while (bytes_read < 0 && socket->GetLastError() == LOCAL_BLOCKING_ERROR && + while (bytes_read < 0 && socket->GetLastError() == LOCAL_BLOCKING_ERROR && socket->Active()) { Thread::force_yield(); bytes_read = socket->RecvData(buffer, read_buffer_size); @@ -815,24 +735,23 @@ process_raw_incoming_tcp_data(SocketInfo *sinfo) { return false; } - // In raw mode, we simply extract all the bytes and make that a - // datagram. + // In raw mode, we simply extract all the bytes and make that a datagram. NetDatagram datagram(buffer, bytes_read); - - // Now that we've read all the data, it's time to finish the socket - // so another thread can read the next datagram. + + // Now that we've read all the data, it's time to finish the socket so + // another thread can read the next datagram. finish_socket(sinfo); - + if (_shutdown) { return false; } - + datagram.set_connection(sinfo->_connection); datagram.set_address(NetAddress(socket->GetPeerName())); if (net_cat.is_spam()) { net_cat.spam() - << "Received raw TCP datagram with " << datagram.get_length() + << "Received raw TCP datagram with " << datagram.get_length() << " bytes on " << (void *)datagram.get_connection() << " from " << datagram.get_address() << "\n"; } @@ -842,12 +761,9 @@ process_raw_incoming_tcp_data(SocketInfo *sinfo) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::thread_run -// Access: Private -// Description: This is the actual executing function for each -// thread. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual executing function for each thread. + */ void ConnectionReader:: thread_run(int thread_index) { nassertv(!_polling); @@ -866,26 +782,24 @@ thread_run(int thread_index) { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::get_next_available_socket -// Access: Private -// Description: Polls the known connections for activity and returns -// the next one known to have activity, or NULL if no -// activity is detected within the timeout interval. -// -// This function may block indefinitely if it is being -// called by multiple threads; if there are no other -// threads, it may block only if allow_block is true. -//////////////////////////////////////////////////////////////////// +/** + * Polls the known connections for activity and returns the next one known to + * have activity, or NULL if no activity is detected within the timeout + * interval. + * + * This function may block indefinitely if it is being called by multiple + * threads; if there are no other threads, it may block only if allow_block is + * true. + */ ConnectionReader::SocketInfo *ConnectionReader:: get_next_available_socket(bool allow_block, int current_thread_index) { - // Go to sleep on the select() mutex. This guarantees that only one - // thread is in this function at a time. + // Go to sleep on the select() mutex. This guarantees that only one thread + // is in this function at a time. MutexHolder holder(_select_mutex); do { - // First, check the result from the previous select call. If - // there are any sockets remaining there, process them first. + // First, check the result from the previous select call. If there are + // any sockets remaining there, process them first. while (!_shutdown && _num_results > 0) { nassertr(_next_index < (int)_selecting_sockets.size(), NULL); int i = _next_index; @@ -905,14 +819,14 @@ get_next_available_socket(bool allow_block, int current_thread_index) { do { interrupted = false; - // Ok, no results from previous select calls. Prepare to set up - // for a new select. + // Ok, no results from previous select calls. Prepare to set up for a + // new select. - // First, report to anyone else who cares that we're the thread - // about to do the poll. That way, if any new sockets come - // available while we're polling, we can service them. + // First, report to anyone else who cares that we're the thread about to + // do the poll. That way, if any new sockets come available while we're + // polling, we can service them. AtomicAdjust::set(_currently_polling_thread, current_thread_index); - + rebuild_select_list(); // Now we can execute the select. @@ -925,9 +839,9 @@ get_next_available_socket(bool allow_block, int current_thread_index) { timeout = 0; } #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) - // In the presence of SIMPLE_THREADS, we never wait at all, - // but rather we yield the thread if we come up empty (so that - // we won't block the entire process). + // In the presence of SIMPLE_THREADS, we never wait at all, but rather + // we yield the thread if we come up empty (so that we won't block the + // entire process). timeout = 0; #endif @@ -935,15 +849,14 @@ get_next_available_socket(bool allow_block, int current_thread_index) { } if (_num_results == 0 && allow_block) { - // If we reached net_max_block, go back and reconsider. (We - // never timeout indefinitely, so we can check the shutdown - // flag every once in a while.) + // If we reached net_max_block, go back and reconsider. (We never + // timeout indefinitely, so we can check the shutdown flag every once + // in a while.) interrupted = true; Thread::force_yield(); } else if (_num_results < 0) { - // If we had an error, just return. But yield the timeslice - // first. + // If we had an error, just return. But yield the timeslice first. Thread::force_yield(); return (SocketInfo *)NULL; } @@ -951,21 +864,18 @@ get_next_available_socket(bool allow_block, int current_thread_index) { AtomicAdjust::set(_currently_polling_thread, current_thread_index); - // Repeat the above until we (a) find a socket with actual noise - // on it, or (b) return from PR_Poll() with no sockets available. + // Repeat the above until we (a) find a socket with actual noise on it, or + // (b) return from PR_Poll() with no sockets available. } while (!_shutdown && _num_results > 0); return (SocketInfo *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::rebuild_select_list -// Access: Private -// Description: Rebuilds the _fdset and _selecting_sockets arrays -// based on the sockets that are currently available for -// selecting. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the _fdset and _selecting_sockets arrays based on the sockets that + * are currently available for selecting. + */ void ConnectionReader:: rebuild_select_list() { _fdset.clear(); @@ -981,8 +891,8 @@ rebuild_select_list() { } } - // This is also a fine time to delete the contents of the - // _removed_sockets list. + // This is also a fine time to delete the contents of the _removed_sockets + // list. if (!_removed_sockets.empty()) { Sockets still_busy_sockets; for (si = _removed_sockets.begin(); si != _removed_sockets.end(); ++si) { @@ -997,14 +907,11 @@ rebuild_select_list() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionReader::accumulate_fdset -// Access: Private -// Description: Adds the sockets from this ConnectionReader (or -// ConnectionListener) to the indicated fdset. This is -// used by ConnectionManager::block() to build an fdset -// of all attached readers. -//////////////////////////////////////////////////////////////////// +/** + * Adds the sockets from this ConnectionReader (or ConnectionListener) to the + * indicated fdset. This is used by ConnectionManager::block() to build an + * fdset of all attached readers. + */ void ConnectionReader:: accumulate_fdset(Socket_fdset &fdset) { LightMutexHolder holder(_sockets_mutex); diff --git a/panda/src/net/connectionReader.h b/panda/src/net/connectionReader.h index 553813d5a8..3f00fa538b 100644 --- a/panda/src/net/connectionReader.h +++ b/panda/src/net/connectionReader.h @@ -1,16 +1,15 @@ -// Filename: connectionReader.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionReader.h + * @author drose + * @date 2000-02-08 + */ #ifndef CONNECTIONREADER_H #define CONNECTIONREADER_H @@ -32,40 +31,34 @@ class ConnectionManager; class Socket_Address; class Socket_IP; -//////////////////////////////////////////////////////////////////// -// Class : ConnectionReader -// Description : This is an abstract base class for a family of -// classes that listen for activity on a socket and -// respond to it, for instance by reading a datagram and -// serving it (or queueing it up for later service). -// -// A ConnectionReader may define an arbitrary number of -// threads (at least one) to process datagrams coming in -// from an arbitrary number of sockets that it is -// monitoring. The number of threads is specified at -// construction time and cannot be changed, but the set -// of sockets that is to be monitored may be constantly -// modified at will. -// -// This is an abstract class because it doesn't define -// how to process each received datagram. See -// QueuedConnectionReader. Also note that -// ConnectionListener derives from this class, extending -// it to accept connections on a rendezvous socket -// rather than read datagrams. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class for a family of classes that listen for + * activity on a socket and respond to it, for instance by reading a datagram + * and serving it (or queueing it up for later service). + * + * A ConnectionReader may define an arbitrary number of threads (at least one) + * to process datagrams coming in from an arbitrary number of sockets that it + * is monitoring. The number of threads is specified at construction time and + * cannot be changed, but the set of sockets that is to be monitored may be + * constantly modified at will. + * + * This is an abstract class because it doesn't define how to process each + * received datagram. See QueuedConnectionReader. Also note that + * ConnectionListener derives from this class, extending it to accept + * connections on a rendezvous socket rather than read datagrams. + */ class EXPCL_PANDA_NET ConnectionReader { PUBLISHED: - // The implementation here used to involve NSPR's multi-wait - // interface, but that got too complicated to manage. It turns out - // to be difficult to protect against memory leaks caused by race - // conditions in that interface, as designed. + // The implementation here used to involve NSPR's multi-wait interface, but + // that got too complicated to manage. It turns out to be difficult to + // protect against memory leaks caused by race conditions in that interface, + // as designed. - // Instead, we do our own multi-wait type stuff. Only one thread at - // a time can extract the next-available socket with activity on it. - // That thread will either (a) simply extract the next socket from - // the arrays returned by a previous call to PR_Poll(), or (b) - // execute (and possibly block on) a new call to PR_Poll(). + // Instead, we do our own multi-wait type stuff. Only one thread at a time + // can extract the next-available socket with activity on it. That thread + // will either (a) simply extract the next socket from the arrays returned + // by a previous call to PR_Poll(), or (b) execute (and possibly block on) a + // new call to PR_Poll(). ConnectionReader(ConnectionManager *manager, int num_threads, const string &thread_name = string()); @@ -117,11 +110,11 @@ protected: protected: ConnectionManager *_manager; - // These structures track the total set of sockets (connections) we - // know about. + // These structures track the total set of sockets (connections) we know + // about. Sockets _sockets; - // This is the list of recently-removed sockets. We can't actually - // delete them until they're no longer _busy. + // This is the list of recently-removed sockets. We can't actually delete + // them until they're no longer _busy. Sockets _removed_sockets; // Any operations on _sockets are protected by this mutex. LightMutex _sockets_mutex; @@ -129,7 +122,7 @@ protected: private: void thread_run(int thread_index); - SocketInfo *get_next_available_socket(bool allow_block, + SocketInfo *get_next_available_socket(bool allow_block, int current_thread_index); void rebuild_select_list(); @@ -142,7 +135,7 @@ private: class ReaderThread : public Thread { public: - ReaderThread(ConnectionReader *reader, const string &thread_name, + ReaderThread(ConnectionReader *reader, const string &thread_name, int thread_index); virtual void thread_main(); @@ -154,19 +147,19 @@ private: Threads _threads; bool _polling; - // These structures are used to manage selecting for noise on - // available sockets. + // These structures are used to manage selecting for noise on available + // sockets. Socket_fdset _fdset; Sockets _selecting_sockets; int _next_index; int _num_results; - // Threads go to sleep on this mutex waiting for their chance to - // read a socket. + // Threads go to sleep on this mutex waiting for their chance to read a + // socket. Mutex _select_mutex; - // This is atomically updated with the index (in _threads) of the - // thread that is currently waiting on the PR_Poll() call. It - // contains -1 if no thread is so waiting. + // This is atomically updated with the index (in _threads) of the thread + // that is currently waiting on the PR_Poll() call. It contains -1 if no + // thread is so waiting. AtomicAdjust::Integer _currently_polling_thread; friend class ConnectionManager; diff --git a/panda/src/net/connectionWriter.cxx b/panda/src/net/connectionWriter.cxx index 13a9be4ee8..a07b52fa63 100644 --- a/panda/src/net/connectionWriter.cxx +++ b/panda/src/net/connectionWriter.cxx @@ -1,16 +1,15 @@ -// Filename: connectionWriter.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionWriter.cxx + * @author drose + * @date 2000-02-08 + */ #include "connectionWriter.h" #include "connectionManager.h" @@ -21,41 +20,34 @@ #include "pnotify.h" #include "config_downloader.h" -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::WriterThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionWriter::WriterThread:: WriterThread(ConnectionWriter *writer, const string &thread_name, int thread_index) : - Thread(make_thread_name(thread_name, thread_index), + Thread(make_thread_name(thread_name, thread_index), make_thread_name(thread_name, thread_index)), _writer(writer), _thread_index(thread_index) { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::WriterThread::thread_main -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConnectionWriter::WriterThread:: thread_main() { _writer->thread_run(_thread_index); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::Constructor -// Access: Public -// Description: Creates a new ConnectionWriter with the indicated -// number of threads to handle output. -// -// If num_threads is 0, all datagrams will be sent -// immediately instead of queueing for later -// transmission by a thread. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ConnectionWriter with the indicated number of threads to + * handle output. + * + * If num_threads is 0, all datagrams will be sent immediately instead of + * queueing for later transmission by a thread. + */ ConnectionWriter:: ConnectionWriter(ConnectionManager *manager, int num_threads, const string &thread_name) : @@ -94,11 +86,9 @@ ConnectionWriter(ConnectionManager *manager, int num_threads, _manager->add_writer(this); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConnectionWriter:: ~ConnectionWriter() { if (_manager != (ConnectionManager *)NULL) { @@ -108,60 +98,47 @@ ConnectionWriter:: shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::set_max_queue_size -// Access: Public -// Description: Limits the number of packets that may be pending on -// the outbound queue. This only has an effect when -// using threads; if num_threads is 0, then all packets -// are sent immediately. -//////////////////////////////////////////////////////////////////// +/** + * Limits the number of packets that may be pending on the outbound queue. + * This only has an effect when using threads; if num_threads is 0, then all + * packets are sent immediately. + */ void ConnectionWriter:: set_max_queue_size(int max_size) { _queue.set_max_queue_size(max_size); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_max_queue_size -// Access: Public -// Description: Returns the maximum size the queue is allowed to grow -// to. See set_max_queue_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size the queue is allowed to grow to. See + * set_max_queue_size(). + */ int ConnectionWriter:: get_max_queue_size() const { return _queue.get_max_queue_size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_current_queue_size -// Access: Public -// Description: Returns the current number of things in the queue. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of things in the queue. + */ int ConnectionWriter:: get_current_queue_size() const { return _queue.get_current_queue_size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::send -// Access: Public -// Description: Enqueues a datagram for transmittal on the indicated -// socket. Since the host address is not specified with -// this form, this function should only be used for -// sending TCP packets. Use the other send() method for -// sending UDP packets. -// -// Returns true if successful, false if there was an -// error. In the normal, threaded case, this function -// only returns false if the send queue is filled; it's -// impossible to detect a transmission error at this -// point. -// -// If block is true, this will not return false if the -// send queue is filled; instead, it will wait until -// there is space available. -//////////////////////////////////////////////////////////////////// +/** + * Enqueues a datagram for transmittal on the indicated socket. Since the + * host address is not specified with this form, this function should only be + * used for sending TCP packets. Use the other send() method for sending UDP + * packets. + * + * Returns true if successful, false if there was an error. In the normal, + * threaded case, this function only returns false if the send queue is + * filled; it's impossible to detect a transmission error at this point. + * + * If block is true, this will not return false if the send queue is filled; + * instead, it will wait until there is space available. + */ bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, bool block) { nassertr(!_shutdown, false); @@ -183,25 +160,19 @@ send(const Datagram &datagram, const PT(Connection) &connection, bool block) { } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::send -// Access: Public -// Description: Enqueues a datagram for transmittal on the indicated -// socket. This form of the function allows the -// specification of a destination host address, and so -// is appropriate for UDP packets. Use the other send() -// method for sending TCP packets. -// -// Returns true if successful, false if there was an -// error. In the normal, threaded case, this function -// only returns false if the send queue is filled; it's -// impossible to detect a transmission error at this -// point. -// -// If block is true, this will not return false if the -// send queue is filled; instead, it will wait until -// there is space available. -//////////////////////////////////////////////////////////////////// +/** + * Enqueues a datagram for transmittal on the indicated socket. This form of + * the function allows the specification of a destination host address, and so + * is appropriate for UDP packets. Use the other send() method for sending + * TCP packets. + * + * Returns true if successful, false if there was an error. In the normal, + * threaded case, this function only returns false if the send queue is + * filled; it's impossible to detect a transmission error at this point. + * + * If block is true, this will not return false if the send queue is filled; + * instead, it will wait until there is space available. + */ bool ConnectionWriter:: send(const Datagram &datagram, const PT(Connection) &connection, const NetAddress &address, bool block) { @@ -232,112 +203,86 @@ send(const Datagram &datagram, const PT(Connection) &connection, } } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::is_valid_for_udp -// Access: Public -// Description: Returns true if the datagram is small enough to be -// sent over a UDP packet, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the datagram is small enough to be sent over a UDP packet, + * false otherwise. + */ bool ConnectionWriter:: is_valid_for_udp(const Datagram &datagram) const { return (int)datagram.get_length() <= maximum_udp_datagram; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_manager -// Access: Public -// Description: Returns a pointer to the ConnectionManager object -// that serves this ConnectionWriter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the ConnectionManager object that serves this + * ConnectionWriter. + */ ConnectionManager *ConnectionWriter:: get_manager() const { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::is_immediate -// Access: Public -// Description: Returns true if the writer is an immediate writer, -// i.e. it has no threads. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the writer is an immediate writer, i.e. it has no threads. + */ bool ConnectionWriter:: is_immediate() const { return _immediate; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_num_threads -// Access: Public -// Description: Returns the number of threads the ConnectionWriter -// has been created with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of threads the ConnectionWriter has been created with. + */ int ConnectionWriter:: get_num_threads() const { return _threads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::set_raw_mode -// Access: Public -// Description: Sets the ConnectionWriter into raw mode (or turns off -// raw mode). In raw mode, datagrams are not sent along -// with their headers; the bytes in the datagram are -// simply sent down the pipe. -// -// Setting the ConnectionWriter to raw mode must be done -// with care. This can only be done when the matching -// ConnectionReader is also set to raw mode, or when the -// ConnectionWriter is communicating to a process that -// does not expect datagrams. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ConnectionWriter into raw mode (or turns off raw mode). In raw + * mode, datagrams are not sent along with their headers; the bytes in the + * datagram are simply sent down the pipe. + * + * Setting the ConnectionWriter to raw mode must be done with care. This can + * only be done when the matching ConnectionReader is also set to raw mode, or + * when the ConnectionWriter is communicating to a process that does not + * expect datagrams. + */ void ConnectionWriter:: set_raw_mode(bool mode) { _raw_mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_raw_mode -// Access: Public -// Description: Returns the current setting of the raw mode flag. -// See set_raw_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the raw mode flag. See set_raw_mode(). + */ bool ConnectionWriter:: get_raw_mode() const { return _raw_mode; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::set_tcp_header_size -// Access: Public -// Description: Sets the header size of TCP packets. At the present, -// legal values for this are 0, 2, or 4; this specifies -// the number of bytes to use encode the datagram length -// at the start of each TCP datagram. Sender and -// receiver must independently agree on this. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header size of TCP packets. At the present, legal values for this + * are 0, 2, or 4; this specifies the number of bytes to use encode the + * datagram length at the start of each TCP datagram. Sender and receiver + * must independently agree on this. + */ void ConnectionWriter:: set_tcp_header_size(int tcp_header_size) { _tcp_header_size = tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::get_tcp_header_size -// Access: Public -// Description: Returns the current setting of TCP header size. -// See set_tcp_header_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of TCP header size. See set_tcp_header_size(). + */ int ConnectionWriter:: get_tcp_header_size() const { return _tcp_header_size; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::shutdown -// Access: Published -// Description: Stops all the threads and cleans them up. This is -// called automatically by the destructor, but it may be -// called explicitly before destruction. -//////////////////////////////////////////////////////////////////// +/** + * Stops all the threads and cleans them up. This is called automatically by + * the destructor, but it may be called explicitly before destruction. + */ void ConnectionWriter:: shutdown() { if (_shutdown) { @@ -345,8 +290,7 @@ shutdown() { } _shutdown = true; - // First, shutdown the queue. This will tell our threads they're - // done. + // First, shutdown the queue. This will tell our threads they're done. _queue.shutdown(); // Now wait for all threads to terminate. @@ -357,28 +301,21 @@ shutdown() { _threads.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::clear_manager -// Access: Protected -// Description: This should normally only be called when the -// associated ConnectionManager destructs. It resets -// the ConnectionManager pointer to NULL so we don't -// have a floating pointer. This makes the -// ConnectionWriter invalid; presumably it also will be -// destructed momentarily. -//////////////////////////////////////////////////////////////////// +/** + * This should normally only be called when the associated ConnectionManager + * destructs. It resets the ConnectionManager pointer to NULL so we don't + * have a floating pointer. This makes the ConnectionWriter invalid; + * presumably it also will be destructed momentarily. + */ void ConnectionWriter:: clear_manager() { _manager = (ConnectionManager *)NULL; shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionWriter::thread_run -// Access: Private -// Description: This is the actual executing function for each -// thread. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual executing function for each thread. + */ void ConnectionWriter:: thread_run(int thread_index) { nassertv(!_immediate); diff --git a/panda/src/net/connectionWriter.h b/panda/src/net/connectionWriter.h index 39f073bee0..71f74bb0a1 100644 --- a/panda/src/net/connectionWriter.h +++ b/panda/src/net/connectionWriter.h @@ -1,16 +1,15 @@ -// Filename: connectionWriter.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file connectionWriter.h + * @author drose + * @date 2000-02-08 + */ #ifndef CONNECTIONWRITER_H #define CONNECTIONWRITER_H @@ -25,16 +24,14 @@ class ConnectionManager; class NetAddress; -//////////////////////////////////////////////////////////////////// -// Class : ConnectionWriter -// Description : This class handles threaded delivery of datagrams to -// various TCP or UDP sockets. -// -// A ConnectionWriter may define an arbitrary number of -// threads (0 or more) to write its datagrams to -// sockets. The number of threads is specified at -// construction time and cannot be changed. -//////////////////////////////////////////////////////////////////// +/** + * This class handles threaded delivery of datagrams to various TCP or UDP + * sockets. + * + * A ConnectionWriter may define an arbitrary number of threads (0 or more) to + * write its datagrams to sockets. The number of threads is specified at + * construction time and cannot be changed. + */ class EXPCL_PANDA_NET ConnectionWriter { PUBLISHED: ConnectionWriter(ConnectionManager *manager, int num_threads, @@ -48,7 +45,7 @@ PUBLISHED: BLOCKING bool send(const Datagram &datagram, const PT(Connection) &connection, bool block = false); - + BLOCKING bool send(const Datagram &datagram, const PT(Connection) &connection, const NetAddress &address, @@ -104,5 +101,3 @@ private: }; #endif - - diff --git a/panda/src/net/datagramGeneratorNet.I b/panda/src/net/datagramGeneratorNet.I index eac8390c09..61d3e80487 100644 --- a/panda/src/net/datagramGeneratorNet.I +++ b/panda/src/net/datagramGeneratorNet.I @@ -1,14 +1,12 @@ -// Filename: datagramGeneratorNet.I -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGeneratorNet.I + * @author drose + * @date 2009-02-15 + */ diff --git a/panda/src/net/datagramGeneratorNet.cxx b/panda/src/net/datagramGeneratorNet.cxx index ebcd9ed5c0..344bb9ea9c 100644 --- a/panda/src/net/datagramGeneratorNet.cxx +++ b/panda/src/net/datagramGeneratorNet.cxx @@ -1,16 +1,15 @@ -// Filename: datagramGeneratorNet.cxx -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGeneratorNet.cxx + * @author drose + * @date 2009-02-15 + */ #include "pandabase.h" @@ -20,15 +19,11 @@ template class QueuedReturn; -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::Constructor -// Access: Published -// Description: Creates a new DatagramGeneratorNet with the indicated -// number of threads to handle requests. Normally -// num_threads should be either 0 or 1 to guarantee that -// datagrams are generated in the same order in which -// they were received. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DatagramGeneratorNet with the indicated number of threads to + * handle requests. Normally num_threads should be either 0 or 1 to guarantee + * that datagrams are generated in the same order in which they were received. + */ DatagramGeneratorNet:: DatagramGeneratorNet(ConnectionManager *manager, int num_threads) : ConnectionReader(manager, num_threads), @@ -37,22 +32,17 @@ DatagramGeneratorNet(ConnectionManager *manager, int num_threads) : { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DatagramGeneratorNet:: ~DatagramGeneratorNet() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::get_datagram -// Access: Published, Virtual -// Description: Reads the next datagram from the stream. Blocks -// until a datagram is available. Returns true on -// success, false on stream closed or error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the next datagram from the stream. Blocks until a datagram is + * available. Returns true on success, false on stream closed or error. + */ bool DatagramGeneratorNet:: get_datagram(Datagram &data) { if (is_polling()) { @@ -79,8 +69,7 @@ get_datagram(Datagram &data) { nassertr(got_dg, false); } else { - // Threaded case: no polling, we use mutexes and cvars to block - // instead. + // Threaded case: no polling, we use mutexes and cvars to block instead. MutexHolder holder(_dg_lock); while (!thing_available()) { if (is_eof()) { @@ -103,20 +92,17 @@ get_datagram(Datagram &data) { if (net_cat.is_spam()) { net_cat.spam() - << "DatagramGeneratorNet returning datagram of length " + << "DatagramGeneratorNet returning datagram of length " << data.get_length() << "\n"; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::is_eof -// Access: Published, Virtual -// Description: Returns true if the stream has been closed normally. -// This test may only be made after a call to -// get_datagram() has failed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the stream has been closed normally. This test may only be + * made after a call to get_datagram() has failed. + */ bool DatagramGeneratorNet:: is_eof() { // We're at eof if we have no more connected sockets. @@ -124,11 +110,9 @@ is_eof() { return _sockets.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::is_error -// Access: Published, Virtual -// Description: Returns true if the stream has an error condition. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the stream has an error condition. + */ bool DatagramGeneratorNet:: is_error() { // There's an error if any one of our connected sockets reports an error. @@ -144,13 +128,10 @@ is_error() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramGeneratorNet::receive_datagram -// Access: Protected, Virtual -// Description: An internal function called by ConnectionReader() -// when a new datagram has become available. This call -// may be received in a sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionReader() when a new datagram has + * become available. This call may be received in a sub-thread. + */ void DatagramGeneratorNet:: receive_datagram(const NetDatagram &datagram) { MutexHolder holder(_dg_lock); @@ -159,4 +140,3 @@ receive_datagram(const NetDatagram &datagram) { } _dg_received.notify(); } - diff --git a/panda/src/net/datagramGeneratorNet.h b/panda/src/net/datagramGeneratorNet.h index b26be45ff1..be255a5b10 100644 --- a/panda/src/net/datagramGeneratorNet.h +++ b/panda/src/net/datagramGeneratorNet.h @@ -1,16 +1,15 @@ -// Filename: datagramGeneratorNet.h -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramGeneratorNet.h + * @author drose + * @date 2009-02-15 + */ #ifndef DATAGRAMGENERATORNET_H #define DATAGRAMGENERATORNET_H @@ -26,13 +25,11 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn); -//////////////////////////////////////////////////////////////////// -// Class : DatagramGeneratorNet -// Description : This class provides datagrams one-at-a-time as read -// directly from the net, via a TCP connection. If a -// datagram is not available, get_datagram() will block -// until one is. -//////////////////////////////////////////////////////////////////// +/** + * This class provides datagrams one-at-a-time as read directly from the net, + * via a TCP connection. If a datagram is not available, get_datagram() will + * block until one is. + */ class EXPCL_PANDA_NET DatagramGeneratorNet : public DatagramGenerator, public ConnectionReader, public QueuedReturn { PUBLISHED: DatagramGeneratorNet(ConnectionManager *manager, int num_threads); @@ -55,4 +52,3 @@ protected: #include "datagramGeneratorNet.I" #endif - diff --git a/panda/src/net/datagramQueue.cxx b/panda/src/net/datagramQueue.cxx index a6b9abe2f9..ab2b96fa33 100644 --- a/panda/src/net/datagramQueue.cxx +++ b/panda/src/net/datagramQueue.cxx @@ -1,61 +1,52 @@ -// Filename: datagramQueue.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramQueue.cxx + * @author drose + * @date 2000-02-08 + */ #include "datagramQueue.h" #include "config_net.h" #include "mutexHolder.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DatagramQueue:: -DatagramQueue() : +DatagramQueue() : _cvlock("DatagramQueue::_cvlock"), - _cv(_cvlock) + _cv(_cvlock) { _shutdown = false; _max_queue_size = get_net_max_write_queue(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DatagramQueue:: ~DatagramQueue() { - // It's an error to delete a DatagramQueue without first shutting it - // down (and waiting for any associated threads to terminate). + // It's an error to delete a DatagramQueue without first shutting it down + // (and waiting for any associated threads to terminate). nassertv(_shutdown); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::shutdown -// Access: Public -// Description: Marks the queue as shutting down, which will -// eventually cause all threads blocking on extract() to -// return false. The normal way to delete a -// DatagramQueue will be to call first shutdown() and -// then wait for all known threads to terminate. Then -// it is safe to delete the queue. -//////////////////////////////////////////////////////////////////// +/** + * Marks the queue as shutting down, which will eventually cause all threads + * blocking on extract() to return false. The normal way to delete a + * DatagramQueue will be to call first shutdown() and then wait for all known + * threads to terminate. Then it is safe to delete the queue. + */ void DatagramQueue:: shutdown() { - // Notify all of our threads that we're shutting down. This will - // cause any thread blocking on extract() to return false. + // Notify all of our threads that we're shutting down. This will cause any + // thread blocking on extract() to return false. MutexHolder holder(_cvlock); _shutdown = true; @@ -63,19 +54,14 @@ shutdown() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::insert -// Access: Public -// Description: Inserts the indicated datagram onto the end of the -// queue, and returns. If the queue is empty and any -// threads are waiting on the queue, this will wake one -// of them up. Returns true if successful, false if the -// queue was full. -// -// If block is true, this will not return until -// successful, waiting until the queue has space -// available if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Inserts the indicated datagram onto the end of the queue, and returns. If + * the queue is empty and any threads are waiting on the queue, this will wake + * one of them up. Returns true if successful, false if the queue was full. + * + * If block is true, this will not return until successful, waiting until the + * queue has space available if necessary. + */ bool DatagramQueue:: insert(const NetDatagram &data, bool block) { MutexHolder holder(_cvlock); @@ -97,24 +83,18 @@ insert(const NetDatagram &data, bool block) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::extract -// Access: Public -// Description: Extracts a datagram from the head of the queue, if -// one is available. If a datagram is available, this -// will immediately return; otherwise, it will block -// until a datagram becomes available. Multiple threads -// may simultaneously block on extract(); when a -// datagram is subsequently inserted into the queue, one -// of the threads will return from extract() with the -// datagram. -// -// The return value is true if the datagram is -// successfully extracted, or false if the queue was -// destroyed while waiting. (In the case of a false -// return, the thread should not attempt to operate on -// the queue again.) -//////////////////////////////////////////////////////////////////// +/** + * Extracts a datagram from the head of the queue, if one is available. If a + * datagram is available, this will immediately return; otherwise, it will + * block until a datagram becomes available. Multiple threads may + * simultaneously block on extract(); when a datagram is subsequently inserted + * into the queue, one of the threads will return from extract() with the + * datagram. + * + * The return value is true if the datagram is successfully extracted, or + * false if the queue was destroyed while waiting. (In the case of a false + * return, the thread should not attempt to operate on the queue again.) + */ bool DatagramQueue:: extract(NetDatagram &result) { // First, clear the datagram result in case it's got an outstanding @@ -141,40 +121,32 @@ extract(NetDatagram &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::set_max_queue_size -// Access: Public -// Description: Sets the maximum size the queue is allowed to grow -// to. This is primarily for a sanity check; this is a -// limit beyond which we can assume something bad has -// happened. -// -// It's also a crude check against unfortunate seg -// faults due to the queue filling up and quietly -// consuming all available memory. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum size the queue is allowed to grow to. This is primarily + * for a sanity check; this is a limit beyond which we can assume something + * bad has happened. + * + * It's also a crude check against unfortunate seg faults due to the queue + * filling up and quietly consuming all available memory. + */ void DatagramQueue:: set_max_queue_size(int max_size) { MutexHolder holder(_cvlock); _max_queue_size = max_size; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::get_max_queue_size -// Access: Public -// Description: Returns the maximum size the queue is allowed to grow -// to. See set_max_queue_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size the queue is allowed to grow to. See + * set_max_queue_size(). + */ int DatagramQueue:: get_max_queue_size() const { return _max_queue_size; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramQueue::get_current_queue_size -// Access: Public -// Description: Returns the current number of things in the queue. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of things in the queue. + */ int DatagramQueue:: get_current_queue_size() const { MutexHolder holder(_cvlock); diff --git a/panda/src/net/datagramQueue.h b/panda/src/net/datagramQueue.h index 3db8f754e4..131de070cc 100644 --- a/panda/src/net/datagramQueue.h +++ b/panda/src/net/datagramQueue.h @@ -1,16 +1,15 @@ -// Filename: datagramQueue.h -// Created by: drose (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramQueue.h + * @author drose + * @date 2000-02-07 + */ #ifndef DATAGRAMQUEUE_H #define DATAGRAMQUEUE_H @@ -22,12 +21,11 @@ #include "conditionVarFull.h" #include "pdeque.h" -//////////////////////////////////////////////////////////////////// -// Class : DatagramQueue -// Description : A thread-safe, FIFO queue of NetDatagrams. This is used -// by ConnectionWriter for queuing up datagrams for -// its various threads to write to sockets. -//////////////////////////////////////////////////////////////////// +/** + * A thread-safe, FIFO queue of NetDatagrams. This is used by + * ConnectionWriter for queuing up datagrams for its various threads to write + * to sockets. + */ class EXPCL_PANDA_NET DatagramQueue { public: DatagramQueue(); @@ -52,4 +50,3 @@ private: }; #endif - diff --git a/panda/src/net/datagramSinkNet.I b/panda/src/net/datagramSinkNet.I index bfd80694c4..8ab0df708f 100644 --- a/panda/src/net/datagramSinkNet.I +++ b/panda/src/net/datagramSinkNet.I @@ -1,35 +1,28 @@ -// Filename: datagramSinkNet.I -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSinkNet.I + * @author drose + * @date 2009-02-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::set_target -// Access: Published -// Description: Specifies the Connection that will receive all future -// Datagrams sent. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the Connection that will receive all future Datagrams sent. + */ INLINE void DatagramSinkNet:: set_target(Connection *connection) { _target = connection; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::get_target -// Access: Published -// Description: Returns the current target Connection, or NULL if the -// target has not yet been set. See set_target(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current target Connection, or NULL if the target has not yet + * been set. See set_target(). + */ INLINE Connection *DatagramSinkNet:: get_target() const { return _target; diff --git a/panda/src/net/datagramSinkNet.cxx b/panda/src/net/datagramSinkNet.cxx index d0a4d82002..d09bc465ac 100644 --- a/panda/src/net/datagramSinkNet.cxx +++ b/panda/src/net/datagramSinkNet.cxx @@ -1,43 +1,35 @@ -// Filename: datagramSinkNet.cxx -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSinkNet.cxx + * @author drose + * @date 2009-02-15 + */ #include "pandabase.h" #include "datagramSinkNet.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::Constructor -// Access: Published -// Description: Creates a new DatagramSinkNet with the indicated -// number of threads to handle writing. Normally -// num_threads should be either 0 or 1 to guarantee that -// datagrams are delivered in the same order in which -// they were sent. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new DatagramSinkNet with the indicated number of threads to + * handle writing. Normally num_threads should be either 0 or 1 to guarantee + * that datagrams are delivered in the same order in which they were sent. + */ DatagramSinkNet:: DatagramSinkNet(ConnectionManager *manager, int num_threads) : ConnectionWriter(manager, num_threads) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::put_datagram -// Access: Published, Virtual -// Description: Sends the given datagram to the target. Returns true -// on success, false if there is an error. Blocks if -// necessary until the target is ready. -//////////////////////////////////////////////////////////////////// +/** + * Sends the given datagram to the target. Returns true on success, false if + * there is an error. Blocks if necessary until the target is ready. + */ bool DatagramSinkNet:: put_datagram(const Datagram &data) { if (_target == (Connection *)NULL) { @@ -46,23 +38,19 @@ put_datagram(const Datagram &data) { return send(data, _target, true); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::is_error -// Access: Published, Virtual -// Description: Returns true if there is an error on the target -// connection, or if the target has never been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an error on the target connection, or if the + * target has never been set. + */ bool DatagramSinkNet:: is_error() { return (_target == (Connection *)NULL || _target->get_socket() == (Socket_IP *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramSinkNet::flush -// Access: Public, Virtual -// Description: Ensures that all datagrams previously written will be -// visible on the stream. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that all datagrams previously written will be visible on the + * stream. + */ void DatagramSinkNet:: flush() { if (_target != (Connection *)NULL) { diff --git a/panda/src/net/datagramSinkNet.h b/panda/src/net/datagramSinkNet.h index 925703b914..b188fb6011 100644 --- a/panda/src/net/datagramSinkNet.h +++ b/panda/src/net/datagramSinkNet.h @@ -1,16 +1,15 @@ -// Filename: datagramSinkNet.h -// Created by: drose (15Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramSinkNet.h + * @author drose + * @date 2009-02-15 + */ #ifndef DATAGRAMSINKNET_H #define DATAGRAMSINKNET_H @@ -20,11 +19,10 @@ #include "datagramSink.h" #include "connectionWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : DatagramSinkNet -// Description : This class accepts datagrams one-at-a-time and sends -// them over the net, via a TCP connection. -//////////////////////////////////////////////////////////////////// +/** + * This class accepts datagrams one-at-a-time and sends them over the net, via + * a TCP connection. + */ class EXPCL_PANDA_NET DatagramSinkNet : public DatagramSink, public ConnectionWriter { PUBLISHED: DatagramSinkNet(ConnectionManager *manager, int num_threads); diff --git a/panda/src/net/datagramTCPHeader.I b/panda/src/net/datagramTCPHeader.I index 04922585ac..1aa2cf99c8 100644 --- a/panda/src/net/datagramTCPHeader.I +++ b/panda/src/net/datagramTCPHeader.I @@ -1,25 +1,20 @@ -// Filename: datagramTCPHeader.I -// Created by: drose (01Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramTCPHeader.I + * @author drose + * @date 2001-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramTCPHeader::get_header -// Access: Public -// Description: Returns a pointer to a block of data of length -// datagram_tcp_header_size, which can be written to the -// network as the header information. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a block of data of length datagram_tcp_header_size, + * which can be written to the network as the header information. + */ INLINE string DatagramTCPHeader:: get_header() const { return _header.get_message(); diff --git a/panda/src/net/datagramTCPHeader.cxx b/panda/src/net/datagramTCPHeader.cxx index 750fb982b0..3ad1d53f5b 100644 --- a/panda/src/net/datagramTCPHeader.cxx +++ b/panda/src/net/datagramTCPHeader.cxx @@ -1,16 +1,15 @@ -// Filename: datagramTCPHeader.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramTCPHeader.cxx + * @author drose + * @date 2000-02-08 + */ #include "datagramTCPHeader.h" #include "netDatagram.h" @@ -19,12 +18,10 @@ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramTCPHeader::Constructor -// Access: Public -// Description: This constructor creates a header based on an -// already-constructed NetDatagram. -//////////////////////////////////////////////////////////////////// +/** + * This constructor creates a header based on an already-constructed + * NetDatagram. + */ DatagramTCPHeader:: DatagramTCPHeader(const NetDatagram &datagram, int header_size) { const string &str = datagram.get_message(); @@ -55,25 +52,19 @@ DatagramTCPHeader(const NetDatagram &datagram, int header_size) { nassertv((int)_header.get_length() == header_size); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramTCPHeader::Constructor -// Access: Public -// Description: This constructor decodes a header from a block of -// data of length datagram_tcp_header_size, presumably -// just read from a socket. -//////////////////////////////////////////////////////////////////// +/** + * This constructor decodes a header from a block of data of length + * datagram_tcp_header_size, presumably just read from a socket. + */ DatagramTCPHeader:: -DatagramTCPHeader(const void *data, int header_size) : - _header(data, header_size) +DatagramTCPHeader(const void *data, int header_size) : + _header(data, header_size) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramTCPHeader::get_datagram_size -// Access: Public -// Description: Returns the number of bytes in the associated -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes in the associated datagram. + */ int DatagramTCPHeader:: get_datagram_size(int header_size) const { DatagramIterator di(_header); @@ -91,13 +82,10 @@ get_datagram_size(int header_size) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramTCPHeader::verify_datagram -// Access: Public -// Description: Verifies that the indicated datagram has the -// appropriate length. Returns true if it matches, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the indicated datagram has the appropriate length. Returns + * true if it matches, false otherwise. + */ bool DatagramTCPHeader:: verify_datagram(const NetDatagram &datagram, int header_size) const { if (header_size == 0) { @@ -117,8 +105,8 @@ verify_datagram(const NetDatagram &datagram, int header_size) const { << "Invalid datagram! Size is " << actual_size << " bytes, header reports " << expected_size << "\n"; - // We write the hex dump into a ostringstream first, to guarantee - // an atomic write to the output stream in case we're threaded. + // We write the hex dump into a ostringstream first, to guarantee an + // atomic write to the output stream in case we're threaded. ostringstream hex; datagram.dump_hex(hex); diff --git a/panda/src/net/datagramTCPHeader.h b/panda/src/net/datagramTCPHeader.h index a4867c6835..ac8119f4fa 100644 --- a/panda/src/net/datagramTCPHeader.h +++ b/panda/src/net/datagramTCPHeader.h @@ -1,16 +1,15 @@ -// Filename: datagramTCPHeader.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramTCPHeader.h + * @author drose + * @date 2000-02-08 + */ #ifndef DATAGRAMTCPHEADER_H #define DATAGRAMTCPHEADER_H @@ -27,14 +26,12 @@ static const int datagram_tcp32_header_size = sizeof(PN_uint32); class NetDatagram; -//////////////////////////////////////////////////////////////////// -// Class : DatagramTCPHeader -// Description : A class that encapsulates the extra bytes that are -// sent in front of each datagram to identify it when it -// is sent on TCP. This is similar to -// DatagramUDPHeader, except it does not include a -// checksum, since this is unnecessary on UDP. -//////////////////////////////////////////////////////////////////// +/** + * A class that encapsulates the extra bytes that are sent in front of each + * datagram to identify it when it is sent on TCP. This is similar to + * DatagramUDPHeader, except it does not include a checksum, since this is + * unnecessary on UDP. + */ class EXPCL_PANDA_NET DatagramTCPHeader { public: DatagramTCPHeader(const NetDatagram &datagram, int header_size); @@ -46,14 +43,12 @@ public: bool verify_datagram(const NetDatagram &datagram, int header_size) const; private: - // The actual data for the header is stored (somewhat recursively) - // in its own NetDatagram object. This is just for convenience of - // packing and unpacking the header. + // The actual data for the header is stored (somewhat recursively) in its + // own NetDatagram object. This is just for convenience of packing and + // unpacking the header. NetDatagram _header; }; #include "datagramTCPHeader.I" #endif - - diff --git a/panda/src/net/datagramUDPHeader.I b/panda/src/net/datagramUDPHeader.I index 3277963854..85ada55054 100644 --- a/panda/src/net/datagramUDPHeader.I +++ b/panda/src/net/datagramUDPHeader.I @@ -1,37 +1,29 @@ -// Filename: datagramUDPHeader.I -// Created by: drose (01Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramUDPHeader.I + * @author drose + * @date 2001-08-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramUDPHeader::get_datagram_checksum -// Access: Public -// Description: Returns the checksum appropriate for the indicated -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns the checksum appropriate for the indicated datagram. + */ INLINE int DatagramUDPHeader:: get_datagram_checksum() const { DatagramIterator di(_header); return di.get_uint16(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramUDPHeader::get_header -// Access: Public -// Description: Returns a pointer to a block of data of length -// datagram_udp_header_size, which can be written to the -// network as the header information. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a block of data of length datagram_udp_header_size, + * which can be written to the network as the header information. + */ INLINE string DatagramUDPHeader:: get_header() const { return _header.get_message(); diff --git a/panda/src/net/datagramUDPHeader.cxx b/panda/src/net/datagramUDPHeader.cxx index 1719a9c92f..b9b0938021 100644 --- a/panda/src/net/datagramUDPHeader.cxx +++ b/panda/src/net/datagramUDPHeader.cxx @@ -1,16 +1,15 @@ -// Filename: datagramUDPHeader.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramUDPHeader.cxx + * @author drose + * @date 2000-02-08 + */ #include "datagramUDPHeader.h" #include "netDatagram.h" @@ -19,12 +18,10 @@ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramUDPHeader::Constructor -// Access: Public -// Description: This constructor creates a header based on an -// already-constructed NetDatagram. -//////////////////////////////////////////////////////////////////// +/** + * This constructor creates a header based on an already-constructed + * NetDatagram. + */ DatagramUDPHeader:: DatagramUDPHeader(const NetDatagram &datagram) { const string &str = datagram.get_message(); @@ -38,24 +35,18 @@ DatagramUDPHeader(const NetDatagram &datagram) { nassertv((int)_header.get_length() == datagram_udp_header_size); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramUDPHeader::Constructor -// Access: Public -// Description: This constructor decodes a header from a block of -// data of length datagram_udp_header_size, presumably -// just read from a socket. -//////////////////////////////////////////////////////////////////// +/** + * This constructor decodes a header from a block of data of length + * datagram_udp_header_size, presumably just read from a socket. + */ DatagramUDPHeader:: DatagramUDPHeader(const void *data) : _header(data, datagram_udp_header_size) { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramUDPHeader::verify_datagram -// Access: Public -// Description: Verifies that the indicated datagram has the -// appropriate length and checksum. Returns true if it -// matches, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the indicated datagram has the appropriate length and + * checksum. Returns true if it matches, false otherwise. + */ bool DatagramUDPHeader:: verify_datagram(const NetDatagram &datagram) const { const string &str = datagram.get_message(); @@ -78,8 +69,8 @@ verify_datagram(const NetDatagram &datagram) const { << get_datagram_checksum() << "\n"; } - // We write the hex dump into a ostringstream first, to guarantee - // an atomic write to the output stream in case we're threaded. + // We write the hex dump into a ostringstream first, to guarantee an + // atomic write to the output stream in case we're threaded. ostringstream hex; datagram.dump_hex(hex); diff --git a/panda/src/net/datagramUDPHeader.h b/panda/src/net/datagramUDPHeader.h index 90610e6749..fd2abbaa47 100644 --- a/panda/src/net/datagramUDPHeader.h +++ b/panda/src/net/datagramUDPHeader.h @@ -1,16 +1,15 @@ -// Filename: datagramUDPHeader.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramUDPHeader.h + * @author drose + * @date 2000-02-08 + */ #ifndef DATAGRAMUDPHEADER_H #define DATAGRAMUDPHEADER_H @@ -26,14 +25,12 @@ static const int datagram_udp_header_size = sizeof(PN_uint16); class NetDatagram; -//////////////////////////////////////////////////////////////////// -// Class : DatagramUDPHeader -// Description : A class that encapsulates the extra bytes that are -// sent in front of each datagram to identify it when it -// is sent on UDP. Like NetDatagram, this class -// automatically handles converting its data to and from -// the network byte ordering. -//////////////////////////////////////////////////////////////////// +/** + * A class that encapsulates the extra bytes that are sent in front of each + * datagram to identify it when it is sent on UDP. Like NetDatagram, this + * class automatically handles converting its data to and from the network + * byte ordering. + */ class EXPCL_PANDA_NET DatagramUDPHeader { public: DatagramUDPHeader(const NetDatagram &datagram); @@ -45,14 +42,12 @@ public: bool verify_datagram(const NetDatagram &datagram) const; private: - // The actual data for the header is stored (somewhat recursively) - // in its own NetDatagram object. This is just for convenience of - // packing and unpacking the header. + // The actual data for the header is stored (somewhat recursively) in its + // own NetDatagram object. This is just for convenience of packing and + // unpacking the header. NetDatagram _header; }; #include "datagramUDPHeader.I" #endif - - diff --git a/panda/src/net/datagram_ui.cxx b/panda/src/net/datagram_ui.cxx index 9ca5bf3515..fb5fc1a958 100644 --- a/panda/src/net/datagram_ui.cxx +++ b/panda/src/net/datagram_ui.cxx @@ -1,16 +1,15 @@ -// Filename: datagram_ui.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagram_ui.cxx + * @author drose + * @date 2000-02-09 + */ #include "datagram_ui.h" #include "datagramIterator.h" diff --git a/panda/src/net/datagram_ui.h b/panda/src/net/datagram_ui.h index e3432f687f..6f0e6c4cba 100644 --- a/panda/src/net/datagram_ui.h +++ b/panda/src/net/datagram_ui.h @@ -1,31 +1,26 @@ -// Filename: datagram_ui.h -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagram_ui.h + * @author drose + * @date 2000-02-09 + */ #ifndef DATAGRAM_UI_H #define DATAGRAM_UI_H -//////////////////////////////////////////////////////////////////// -// -// The functions defined here are used for testing purposes only by -// some of the various test_* programs in this directory. They are -// not compiled into the package library, libnet.so. -// -// These functions are handy for getting and reporting a datagram from -// and to the user. They extend a datagram by encoding information -// about the types of values stored in it. -// -//////////////////////////////////////////////////////////////////// +/* + * The functions defined here are used for testing purposes only by some of + * the various test_* programs in this directory. They are not compiled into + * the package library, libnet.so. These functions are handy for getting and + * reporting a datagram from and to the user. They extend a datagram by + * encoding information about the types of values stored in it. + */ #include "pandabase.h" diff --git a/panda/src/net/fake_http_server.cxx b/panda/src/net/fake_http_server.cxx index 6c119386ea..718b6db824 100644 --- a/panda/src/net/fake_http_server.cxx +++ b/panda/src/net/fake_http_server.cxx @@ -1,16 +1,15 @@ -// Filename: fake_http_server.cxx -// Created by: drose (10Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fake_http_server.cxx + * @author drose + * @date 2002-12-10 + */ #include "pandabase.h" @@ -160,8 +159,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/netAddress.cxx b/panda/src/net/netAddress.cxx index a009f194f5..4ae75f3434 100644 --- a/panda/src/net/netAddress.cxx +++ b/panda/src/net/netAddress.cxx @@ -1,150 +1,118 @@ -// Filename: netAddress.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file netAddress.cxx + * @author drose + * @date 2000-02-08 + */ #include "netAddress.h" #include "config_net.h" -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::Constructor -// Access: Published -// Description: Constructs an unspecified address. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an unspecified address. + */ NetAddress:: NetAddress() { } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::Constructor -// Access: Published -// Description: Constructs an address from a given Socket_Address. -// Normally, this constructor should not be used by user -// code; instead, create a default NetAddress and use -// one of the set_*() functions to set up an address. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an address from a given Socket_Address. Normally, this + * constructor should not be used by user code; instead, create a default + * NetAddress and use one of the set_*() functions to set up an address. + */ NetAddress:: NetAddress(const Socket_Address &addr) : _addr(addr) { } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::set_any -// Access: Published -// Description: Sets the address up to refer to a particular port, -// but not to any particular IP. Returns true if -// successful, false otherwise (currently, this only -// returns true). -//////////////////////////////////////////////////////////////////// +/** + * Sets the address up to refer to a particular port, but not to any + * particular IP. Returns true if successful, false otherwise (currently, + * this only returns true). + */ bool NetAddress:: set_any(int port) { return _addr.set_any_IP(port); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::set_localhost -// Access: Published -// Description: Sets the address up to refer to a particular port, -// on this host. -//////////////////////////////////////////////////////////////////// +/** + * Sets the address up to refer to a particular port, on this host. + */ bool NetAddress:: set_localhost(int port) { return _addr.set_host("127.0.0.1", port); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::set_broadcast -// Access: Published -// Description: Sets the address to the broadcast address. -//////////////////////////////////////////////////////////////////// +/** + * Sets the address to the broadcast address. + */ bool NetAddress:: set_broadcast(int port) { return _addr.set_broadcast(port); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::set_host -// Access: Published -// Description: Sets the address up to refer to a particular port -// on a particular host. Returns true if the hostname -// is known, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the address up to refer to a particular port on a particular host. + * Returns true if the hostname is known, false otherwise. + */ bool NetAddress:: set_host(const string &hostname, int port) { return _addr.set_host(hostname, port); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::clear -// Access: Published -// Description: Resets the NetAddress to its initial state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the NetAddress to its initial state. + */ void NetAddress:: clear() { _addr.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_port -// Access: Published -// Description: Returns the port number to which this address refers. -//////////////////////////////////////////////////////////////////// +/** + * Returns the port number to which this address refers. + */ int NetAddress:: get_port() const { return _addr.get_port(); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::set_port -// Access: Published -// Description: Resets the port number without otherwise changing the -// address. -//////////////////////////////////////////////////////////////////// +/** + * Resets the port number without otherwise changing the address. + */ void NetAddress:: set_port(int port) { _addr.set_port(port); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_ip_string -// Access: Published -// Description: Returns the IP address to which this address refers, -// formatted as a string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the IP address to which this address refers, formatted as a string. + */ string NetAddress:: get_ip_string() const { return _addr.get_ip(); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_ip -// Access: Published -// Description: Returns the IP address to which this address refers, -// as a 32-bit integer, in host byte order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the IP address to which this address refers, as a 32-bit integer, + * in host byte order. + */ PN_uint32 NetAddress:: get_ip() const { return _addr.GetIPAddressRaw(); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_ip_component -// Access: Published -// Description: Returns the nth 8-bit component of the IP address. -// An IP address has four components; component 0 is the -// first (leftmost), and component 3 is the last -// (rightmost) in the dotted number convention. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth 8-bit component of the IP address. An IP address has four + * components; component 0 is the first (leftmost), and component 3 is the + * last (rightmost) in the dotted number convention. + */ PN_uint8 NetAddress:: get_ip_component(int n) const { nassertr(n >= 0 && n < 4, 0); @@ -154,51 +122,41 @@ get_ip_component(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_addr -// Access: Published -// Description: Returns the Socket_Address for this address. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Socket_Address for this address. + */ const Socket_Address &NetAddress:: get_addr() const { return _addr; } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NetAddress:: output(ostream &out) const { out << get_ip_string(); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::get_hash -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t NetAddress:: get_hash() const { return (size_t)(((int)get_ip()) ^ ((int)get_port() << 16)); } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool NetAddress:: operator == (const NetAddress &other) const { return _addr == other._addr; } -//////////////////////////////////////////////////////////////////// -// Function: NetAddress::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool NetAddress:: operator != (const NetAddress &other) const { return _addr != other._addr; diff --git a/panda/src/net/netAddress.h b/panda/src/net/netAddress.h index 79c99a4f82..e28a7d2443 100644 --- a/panda/src/net/netAddress.h +++ b/panda/src/net/netAddress.h @@ -1,16 +1,15 @@ -// Filename: netAddress.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file netAddress.h + * @author drose + * @date 2000-02-08 + */ #ifndef NETADDRESS_H #define NETADDRESS_H @@ -19,11 +18,10 @@ #include "numeric_types.h" #include "socket_address.h" -//////////////////////////////////////////////////////////////////// -// Class : NetAddress -// Description : Represents a network address to which UDP packets may -// be sent or to which a TCP socket may be bound. -//////////////////////////////////////////////////////////////////// +/** + * Represents a network address to which UDP packets may be sent or to which a + * TCP socket may be bound. + */ class EXPCL_PANDA_NET NetAddress { PUBLISHED: NetAddress(); @@ -60,4 +58,3 @@ INLINE ostream &operator << (ostream &out, const NetAddress &addr) { } #endif - diff --git a/panda/src/net/netDatagram.I b/panda/src/net/netDatagram.I index a67c1ee28c..16d352dce6 100644 --- a/panda/src/net/netDatagram.I +++ b/panda/src/net/netDatagram.I @@ -1,42 +1,35 @@ -// Filename: netDatagram.I -// Created by: drose (17May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file netDatagram.I + * @author drose + * @date 2000-05-17 + */ -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool NetDatagram:: operator == (const NetDatagram &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool NetDatagram:: operator != (const NetDatagram &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool NetDatagram:: operator < (const NetDatagram &) const { return false; diff --git a/panda/src/net/netDatagram.cxx b/panda/src/net/netDatagram.cxx index 69bc0d0751..ab48282a4c 100644 --- a/panda/src/net/netDatagram.cxx +++ b/panda/src/net/netDatagram.cxx @@ -1,56 +1,47 @@ -// Filename: netDatagram.cxx -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file netDatagram.cxx + * @author jns + * @date 2000-02-07 + */ #include "netDatagram.h" TypeHandle NetDatagram::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Constructor -// Access: Public -// Description: Constructs an empty datagram. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an empty datagram. + */ NetDatagram:: NetDatagram() { } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Constructor -// Access: Public -// Description: Constructs a datagram from an existing block of data. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a datagram from an existing block of data. + */ NetDatagram:: NetDatagram(const void *data, size_t size) : Datagram(data, size) { } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NetDatagram:: NetDatagram(const Datagram ©) : Datagram(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NetDatagram:: NetDatagram(const NetDatagram ©) : Datagram(copy), @@ -59,11 +50,9 @@ NetDatagram(const NetDatagram ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NetDatagram:: operator = (const Datagram ©) { Datagram::operator = (copy); @@ -71,11 +60,9 @@ operator = (const Datagram ©) { _address.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NetDatagram:: operator = (const NetDatagram ©) { Datagram::operator = (copy); @@ -83,12 +70,10 @@ operator = (const NetDatagram ©) { _address = copy._address; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::clear -// Access: Public, Virtual -// Description: Resets the datagram to empty, in preparation for -// building up a new datagram. -//////////////////////////////////////////////////////////////////// +/** + * Resets the datagram to empty, in preparation for building up a new + * datagram. + */ void NetDatagram:: clear() { Datagram::clear(); @@ -96,45 +81,35 @@ clear() { _address.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::set_connection -// Access: Public -// Description: Specifies the socket to which the datagram should be -// written. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the socket to which the datagram should be written. + */ void NetDatagram:: set_connection(const PT(Connection) &connection) { _connection = connection; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::set_connection -// Access: Public -// Description: Retrieves the socket from which the datagram was -// read, or to which it is scheduled to be written. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the socket from which the datagram was read, or to which it is + * scheduled to be written. + */ PT(Connection) NetDatagram:: get_connection() const { return _connection; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::set_address -// Access: Public -// Description: Specifies the host to which the datagram should be -// sent. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the host to which the datagram should be sent. + */ void NetDatagram:: set_address(const NetAddress &address) { _address = address; } -//////////////////////////////////////////////////////////////////// -// Function: NetDatagram::set_address -// Access: Public -// Description: Retrieves the host from which the datagram was -// read, or to which it is scheduled to be sent. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the host from which the datagram was read, or to which it is + * scheduled to be sent. + */ const NetAddress &NetDatagram:: get_address() const { return _address; diff --git a/panda/src/net/netDatagram.h b/panda/src/net/netDatagram.h index dc56da28fe..7019381a36 100644 --- a/panda/src/net/netDatagram.h +++ b/panda/src/net/netDatagram.h @@ -1,16 +1,15 @@ -// Filename: netDatagram.h -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file netDatagram.h + * @author jns + * @date 2000-02-07 + */ #ifndef NETDATAGRAM_H #define NETDATAGRAM_H @@ -25,21 +24,19 @@ #include -// This determines the size of the read buffer used to read UDP -// packets. It places a limit on the maximum receivable size of a UDP -// packet (although it doesn't limit TCP packets at all). However, -// there's no real reason this can't be set arbitrarily large, -// although there's not much point in making it larger than the system -// MTU, which also limits the maximum size of a UDP packet. +// This determines the size of the read buffer used to read UDP packets. It +// places a limit on the maximum receivable size of a UDP packet (although it +// doesn't limit TCP packets at all). However, there's no real reason this +// can't be set arbitrarily large, although there's not much point in making +// it larger than the system MTU, which also limits the maximum size of a UDP +// packet. static const int maximum_udp_datagram = 1500; -//////////////////////////////////////////////////////////////////// -// Class : NetDatagram -// Description : A specific kind of Datagram, especially for sending -// across or receiving from a network. It's different -// only in that it knows which Connection and/or -// NetAddress it is to be sent to or was received from. -//////////////////////////////////////////////////////////////////// +/** + * A specific kind of Datagram, especially for sending across or receiving + * from a network. It's different only in that it knows which Connection + * and/or NetAddress it is to be sent to or was received from. + */ class EXPCL_PANDA_NET NetDatagram : public Datagram { PUBLISHED: NetDatagram(); @@ -58,9 +55,8 @@ PUBLISHED: const NetAddress &get_address() const; public: - // We need these methods to make VC++ happy when we try to - // instantiate a QueuedReturn. They don't do anything - // useful. + // We need these methods to make VC++ happy when we try to instantiate a + // QueuedReturn. They don't do anything useful. INLINE bool operator == (const NetDatagram &other) const; INLINE bool operator != (const NetDatagram &other) const; INLINE bool operator < (const NetDatagram &other) const; diff --git a/panda/src/net/queuedConnectionListener.I b/panda/src/net/queuedConnectionListener.I index c93d788d51..3cd78c0228 100644 --- a/panda/src/net/queuedConnectionListener.I +++ b/panda/src/net/queuedConnectionListener.I @@ -1,42 +1,35 @@ -// Filename: queuedConnectionListener.I -// Created by: drose (17May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionListener.I + * @author drose + * @date 2000-05-17 + */ -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListenerData::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConnectionListenerData:: operator == (const ConnectionListenerData &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListenerData::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConnectionListenerData:: operator != (const ConnectionListenerData &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ConnectionListenerData::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ConnectionListenerData:: operator < (const ConnectionListenerData &) const { return false; diff --git a/panda/src/net/queuedConnectionListener.cxx b/panda/src/net/queuedConnectionListener.cxx index 49f05ff4b5..e6285451dd 100644 --- a/panda/src/net/queuedConnectionListener.cxx +++ b/panda/src/net/queuedConnectionListener.cxx @@ -1,79 +1,64 @@ -// Filename: queuedConnectionListener.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionListener.cxx + * @author drose + * @date 2000-02-09 + */ #include "queuedConnectionListener.h" #include "config_net.h" template class QueuedReturn; -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionListener:: QueuedConnectionListener(ConnectionManager *manager, int num_threads) : ConnectionListener(manager, num_threads) { } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionListener:: ~QueuedConnectionListener() { - // We call shutdown() here to guarantee that all threads are gone - // before the QueuedReturn destructs. + // We call shutdown() here to guarantee that all threads are gone before the + // QueuedReturn destructs. shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::new_connection_available -// Access: Public -// Description: Returns true if a new connection was recently -// established; the connection information may then be -// retrieved via get_new_connection(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a new connection was recently established; the connection + * information may then be retrieved via get_new_connection(). + */ bool QueuedConnectionListener:: new_connection_available() { poll(); return thing_available(); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::get_new_connection -// Access: Public -// Description: If a previous call to new_connection_available() -// returned true, this function will return information -// about the newly established connection. -// -// The rendezvous parameter is the particular rendezvous -// socket this new connection originally communicated -// with; it is provided in case the ConnectionListener -// was monitorind more than one and you care which one -// it was. The address parameter is the net address of -// the new client, and new_connection is the socket of -// the newly established connection. -// -// The return value is true if a connection was -// successfully returned, or false if there was, in -// fact, no new connection. (This may happen if there -// are multiple threads accessing the -// QueuedConnectionListener). -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to new_connection_available() returned true, this + * function will return information about the newly established connection. + * + * The rendezvous parameter is the particular rendezvous socket this new + * connection originally communicated with; it is provided in case the + * ConnectionListener was monitorind more than one and you care which one it + * was. The address parameter is the net address of the new client, and + * new_connection is the socket of the newly established connection. + * + * The return value is true if a connection was successfully returned, or + * false if there was, in fact, no new connection. (This may happen if there + * are multiple threads accessing the QueuedConnectionListener). + */ bool QueuedConnectionListener:: get_new_connection(PT(Connection) &rendezvous, NetAddress &address, @@ -89,14 +74,11 @@ get_new_connection(PT(Connection) &rendezvous, return true; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::get_new_connection -// Access: Public -// Description: This flavor of get_new_connection() simply returns a -// new connection, assuming the user doesn't care about -// the rendezvous socket that originated it or the -// address it came from. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_new_connection() simply returns a new connection, + * assuming the user doesn't care about the rendezvous socket that originated + * it or the address it came from. + */ bool QueuedConnectionListener:: get_new_connection(PT(Connection) &new_connection) { PT(Connection) rendezvous; @@ -105,14 +87,11 @@ get_new_connection(PT(Connection) &new_connection) { } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionListener::connection_opened -// Access: Protected, Virtual -// Description: An internal function called by ConnectionListener() -// when a new TCP connection has been established. The -// QueuedConnectionListener simply queues up this fact -// for later retrieval by get_new_connection(). -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionListener() when a new TCP + * connection has been established. The QueuedConnectionListener simply + * queues up this fact for later retrieval by get_new_connection(). + */ void QueuedConnectionListener:: connection_opened(const PT(Connection) &rendezvous, const NetAddress &address, diff --git a/panda/src/net/queuedConnectionListener.h b/panda/src/net/queuedConnectionListener.h index 8543945910..7aea32afc8 100644 --- a/panda/src/net/queuedConnectionListener.h +++ b/panda/src/net/queuedConnectionListener.h @@ -1,16 +1,15 @@ -// Filename: queuedConnectionListener.h -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionListener.h + * @author drose + * @date 2000-02-09 + */ #ifndef QUEUEDCONNECTIONLISTENER_H #define QUEUEDCONNECTIONLISTENER_H @@ -26,8 +25,8 @@ class EXPCL_PANDA_NET ConnectionListenerData { public: - // We need these methods to make VC++ happy when we try to - // instantiate the template, below. They don't do anything useful. + // We need these methods to make VC++ happy when we try to instantiate the + // template, below. They don't do anything useful. INLINE bool operator == (const ConnectionListenerData &other) const; INLINE bool operator != (const ConnectionListenerData &other) const; INLINE bool operator < (const ConnectionListenerData &other) const; @@ -39,12 +38,10 @@ public: EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn); -//////////////////////////////////////////////////////////////////// -// Class : QueuedConnectionListener -// Description : This flavor of ConnectionListener will queue up all -// of the TCP connections it established for later -// detection by the client code. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of ConnectionListener will queue up all of the TCP connections + * it established for later detection by the client code. + */ class EXPCL_PANDA_NET QueuedConnectionListener : public ConnectionListener, public QueuedReturn { PUBLISHED: @@ -66,4 +63,3 @@ protected: #include "queuedConnectionListener.I" #endif - diff --git a/panda/src/net/queuedConnectionManager.cxx b/panda/src/net/queuedConnectionManager.cxx index 2a7993dced..e68d0001b2 100644 --- a/panda/src/net/queuedConnectionManager.cxx +++ b/panda/src/net/queuedConnectionManager.cxx @@ -1,16 +1,15 @@ -// Filename: queuedConnectionManager.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionManager.cxx + * @author drose + * @date 2000-02-09 + */ #include "queuedConnectionManager.h" @@ -18,89 +17,68 @@ template class QueuedReturn< PT(Connection) >; -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionManager::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionManager:: QueuedConnectionManager() { } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionManager::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionManager:: ~QueuedConnectionManager() { } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionManager::reset_connection_available -// Access: Public -// Description: Returns true if one of the readers/writers/listeners -// reported a connection reset recently. If so, the -// particular connection that has been reset can be -// extracted via get_reset_connection(). -// -// Only connections which were externally reset are -// certain to appear in this list. Those which were -// explicitly closed via a call to close_connection() -// may or may not be reported. Furthermore, it is the -// responsibility of the caller to subsequently call -// close_connection() with any connection reported reset -// by this call. (There is no harm in calling -// close_connection() more than once on a given socket.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if one of the readers/writers/listeners reported a connection + * reset recently. If so, the particular connection that has been reset can + * be extracted via get_reset_connection(). + * + * Only connections which were externally reset are certain to appear in this + * list. Those which were explicitly closed via a call to close_connection() + * may or may not be reported. Furthermore, it is the responsibility of the + * caller to subsequently call close_connection() with any connection reported + * reset by this call. (There is no harm in calling close_connection() more + * than once on a given socket.) + */ bool QueuedConnectionManager:: reset_connection_available() const { return thing_available(); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionManager::get_reset_connection -// Access: Public -// Description: If a previous call to reset_connection_available() -// returned true, this function will return information -// about the newly reset connection. -// -// Only connections which were externally reset are -// certain to appear in this list. Those which were -// explicitly closed via a call to close_connection() -// may or may not be reported. Furthermore, it is the -// responsibility of the caller to subsequently call -// close_connection() with any connection reported reset -// by this call. (There is no harm in calling -// close_connection() more than once on a given socket.) -// -// The return value is true if a connection was -// successfully returned, or false if there was, in -// fact, no reset connection. (This may happen if -// there are multiple threads accessing the -// QueuedConnectionManager). -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to reset_connection_available() returned true, this + * function will return information about the newly reset connection. + * + * Only connections which were externally reset are certain to appear in this + * list. Those which were explicitly closed via a call to close_connection() + * may or may not be reported. Furthermore, it is the responsibility of the + * caller to subsequently call close_connection() with any connection reported + * reset by this call. (There is no harm in calling close_connection() more + * than once on a given socket.) + * + * The return value is true if a connection was successfully returned, or + * false if there was, in fact, no reset connection. (This may happen if + * there are multiple threads accessing the QueuedConnectionManager). + */ bool QueuedConnectionManager:: get_reset_connection(PT(Connection) &connection) { return get_thing(connection); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionManager::connection_reset -// Access: Protected, Virtual -// Description: An internal function called by the ConnectionReader, -// ConnectionWriter, or ConnectionListener when a -// connection has been externally reset. This adds the -// connection to the queue of those which have recently -// been reset. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by the ConnectionReader, ConnectionWriter, or + * ConnectionListener when a connection has been externally reset. This adds + * the connection to the queue of those which have recently been reset. + */ void QueuedConnectionManager:: connection_reset(const PT(Connection) &connection, bool okflag) { ConnectionManager::connection_reset(connection, okflag); - // Largely, we don't care if this particular queue fills up. If it - // does, it probably just means the user isn't bothering to track - // this. + // Largely, we don't care if this particular queue fills up. If it does, it + // probably just means the user isn't bothering to track this. enqueue_unique_thing(connection); } diff --git a/panda/src/net/queuedConnectionManager.h b/panda/src/net/queuedConnectionManager.h index 9e0323695d..6f387b5325 100644 --- a/panda/src/net/queuedConnectionManager.h +++ b/panda/src/net/queuedConnectionManager.h @@ -1,16 +1,15 @@ -// Filename: queuedConnectionManager.h -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionManager.h + * @author drose + * @date 2000-02-09 + */ #ifndef QUEUEDCONNECTIONMANAGER_H #define QUEUEDCONNECTIONMANAGER_H @@ -23,19 +22,16 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn< PT(Connection) >); -//////////////////////////////////////////////////////////////////// -// Class : QueuedConnectionManager -// Description : This flavor of ConnectionManager will queue up all of -// the reset-connection messages from the -// ConnectionReaders and ConnectionWriters and report -// them to the client on demand. -// -// When a reset connection has been discovered via -// reset_connection_available()/get_reset_connection(), -// it is still the responsibility of the client to call -// close_connection() on that connection to free up its -// resources. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of ConnectionManager will queue up all of the reset-connection + * messages from the ConnectionReaders and ConnectionWriters and report them + * to the client on demand. + * + * When a reset connection has been discovered via + * reset_connection_available()/get_reset_connection(), it is still the + * responsibility of the client to call close_connection() on that connection + * to free up its resources. + */ class EXPCL_PANDA_NET QueuedConnectionManager : public ConnectionManager, public QueuedReturn< PT(Connection) > { PUBLISHED: @@ -46,7 +42,7 @@ PUBLISHED: bool get_reset_connection(PT(Connection) &connection); protected: - virtual void connection_reset(const PT(Connection) &connection, + virtual void connection_reset(const PT(Connection) &connection, bool okflag); }; diff --git a/panda/src/net/queuedConnectionReader.cxx b/panda/src/net/queuedConnectionReader.cxx index 2baa90ad72..bdc562bd22 100644 --- a/panda/src/net/queuedConnectionReader.cxx +++ b/panda/src/net/queuedConnectionReader.cxx @@ -1,16 +1,15 @@ -// Filename: queuedConnectionReader.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionReader.cxx + * @author drose + * @date 2000-02-08 + */ #include "queuedConnectionReader.h" #include "config_net.h" @@ -19,11 +18,9 @@ template class QueuedReturn; -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionReader:: QueuedConnectionReader(ConnectionManager *manager, int num_threads) : ConnectionReader(manager, num_threads) @@ -35,61 +32,48 @@ QueuedConnectionReader(ConnectionManager *manager, int num_threads) : #endif // SIMULATE_NETWORK_DELAY } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QueuedConnectionReader:: ~QueuedConnectionReader() { - // We call shutdown() here to guarantee that all threads are gone - // before the QueuedReturn destructs. + // We call shutdown() here to guarantee that all threads are gone before the + // QueuedReturn destructs. shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::data_available -// Access: Published -// Description: Returns true if a datagram is available on the queue; -// call get_data() to extract the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a datagram is available on the queue; call get_data() to + * extract the datagram. + */ bool QueuedConnectionReader:: data_available() { poll(); #ifdef SIMULATE_NETWORK_DELAY - get_delayed(); + get_delayed(); #endif // SIMULATE_NETWORK_DELAY return thing_available(); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::get_data -// Access: Published -// Description: If a previous call to data_available() returned -// true, this function will return the datagram that has -// become available. -// -// The return value is true if a datagram was -// successfully returned, or false if there was, in -// fact, no datagram available. (This may happen if -// there are multiple threads accessing the -// QueuedConnectionReader). -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to data_available() returned true, this function will + * return the datagram that has become available. + * + * The return value is true if a datagram was successfully returned, or false + * if there was, in fact, no datagram available. (This may happen if there + * are multiple threads accessing the QueuedConnectionReader). + */ bool QueuedConnectionReader:: get_data(NetDatagram &result) { return get_thing(result); } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::get_data -// Access: Published -// Description: This flavor of QueuedConnectionReader::get_data(), -// works like the other, except that it only fills a -// Datagram object, not a NetDatagram object. This -// means that the Datagram cannot be queried for its -// source Connection and/or NetAddress, but it is useful -// in all other respects. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of QueuedConnectionReader::get_data(), works like the other, + * except that it only fills a Datagram object, not a NetDatagram object. + * This means that the Datagram cannot be queried for its source Connection + * and/or NetAddress, but it is useful in all other respects. + */ bool QueuedConnectionReader:: get_data(Datagram &result) { NetDatagram nd; @@ -100,14 +84,11 @@ get_data(Datagram &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::receive_datagram -// Access: Protected, Virtual -// Description: An internal function called by ConnectionReader() -// when a new datagram has become available. The -// QueuedConnectionReader simply queues it up for later -// retrieval by get_data(). -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionReader() when a new datagram has + * become available. The QueuedConnectionReader simply queues it up for later + * retrieval by get_data(). + */ void QueuedConnectionReader:: receive_datagram(const NetDatagram &datagram) { /* @@ -131,16 +112,13 @@ receive_datagram(const NetDatagram &datagram) { #ifdef SIMULATE_NETWORK_DELAY -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::start_delay -// Access: Published -// Description: Enables a simulated network latency. All packets -// received from this point on will be held for a random -// interval of least min_delay seconds, and no more than -// max_delay seconds, before being visible to the -// data_available()/get_data() interface. It is as if -// packets suddenly took much longer to arrive. -//////////////////////////////////////////////////////////////////// +/** + * Enables a simulated network latency. All packets received from this point + * on will be held for a random interval of least min_delay seconds, and no + * more than max_delay seconds, before being visible to the + * data_available()/get_data() interface. It is as if packets suddenly took + * much longer to arrive. + */ void QueuedConnectionReader:: start_delay(double min_delay, double max_delay) { LightMutexHolder holder(_dd_mutex); @@ -149,13 +127,11 @@ start_delay(double min_delay, double max_delay) { _delay_active = true; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::stop_delay -// Access: Published -// Description: Disables the simulated network latency started by a -// previous call to start_delay(). Packets will once -// again be visible as soon as they are received. -//////////////////////////////////////////////////////////////////// +/** + * Disables the simulated network latency started by a previous call to + * start_delay(). Packets will once again be visible as soon as they are + * received. + */ void QueuedConnectionReader:: stop_delay() { LightMutexHolder holder(_dd_mutex); @@ -172,13 +148,10 @@ stop_delay() { } } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::get_delayed -// Access: Private -// Description: Checks the delayed queue for any now available -// datagrams, and adds them to the normal queue if they -// are available. -//////////////////////////////////////////////////////////////////// +/** + * Checks the delayed queue for any now available datagrams, and adds them to + * the normal queue if they are available. + */ void QueuedConnectionReader:: get_delayed() { if (_delay_active) { @@ -199,12 +172,9 @@ get_delayed() { } } -//////////////////////////////////////////////////////////////////// -// Function: QueuedConnectionReader::delay_datagram -// Access: Private -// Description: Adds the datagram to the delay queue for a random -// time interval. -//////////////////////////////////////////////////////////////////// +/** + * Adds the datagram to the delay queue for a random time interval. + */ void QueuedConnectionReader:: delay_datagram(const NetDatagram &datagram) { if (!_delay_active) { @@ -214,8 +184,7 @@ delay_datagram(const NetDatagram &datagram) { } } else { LightMutexHolder holder(_dd_mutex); - // Check the delay_active flag again, now that we have grabbed the - // mutex. + // Check the delay_active flag again, now that we have grabbed the mutex. if (!_delay_active) { if (!enqueue_thing(datagram)) { net_cat.error() @@ -225,7 +194,7 @@ delay_datagram(const NetDatagram &datagram) { } else { double now = TrueClock::get_global_ptr()->get_short_time(); double reveal_time = now + _min_delay; - + if (_delay_variance > 0.0) { reveal_time += _delay_variance * ((double)rand() / (double)RAND_MAX); } diff --git a/panda/src/net/queuedConnectionReader.h b/panda/src/net/queuedConnectionReader.h index 644c32dd3d..3ce7461558 100644 --- a/panda/src/net/queuedConnectionReader.h +++ b/panda/src/net/queuedConnectionReader.h @@ -1,16 +1,15 @@ -// Filename: queuedConnectionReader.h -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedConnectionReader.h + * @author drose + * @date 2000-02-08 + */ #ifndef QUEUEDCONNECTIONREADER_H #define QUEUEDCONNECTIONREADER_H @@ -25,15 +24,12 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn); -//////////////////////////////////////////////////////////////////// -// Class : QueuedConnectionReader -// Description : This flavor of ConnectionReader will read from its -// sockets and queue up all of the datagrams read for -// later receipt by the client code. This class is -// useful for client code that doesn't want to deal with -// threading and is willing to poll for datagrams at its -// convenience. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of ConnectionReader will read from its sockets and queue up all + * of the datagrams read for later receipt by the client code. This class is + * useful for client code that doesn't want to deal with threading and is + * willing to poll for datagrams at its convenience. + */ class EXPCL_PANDA_NET QueuedConnectionReader : public ConnectionReader, public QueuedReturn { PUBLISHED: @@ -61,7 +57,7 @@ private: double _reveal_time; NetDatagram _datagram; }; - + LightMutex _dd_mutex; typedef pdeque Delayed; Delayed _delayed; @@ -72,4 +68,3 @@ private: }; #endif - diff --git a/panda/src/net/queuedReturn.I b/panda/src/net/queuedReturn.I index dd03916edd..988f849c6f 100644 --- a/panda/src/net/queuedReturn.I +++ b/panda/src/net/queuedReturn.I @@ -1,30 +1,24 @@ -// Filename: queuedReturn.I -// Created by: drose (25Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedReturn.I + * @author drose + * @date 2000-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::set_max_queue_size -// Access: Public -// Description: Sets the maximum size the queue is allowed to grow -// to. This is primarily for a sanity check; this is a -// limit beyond which we can assume something bad has -// happened. -// -// It's also a crude check against unfortunate seg -// faults due to the queue filling up and quietly -// consuming all available memory. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum size the queue is allowed to grow to. This is primarily + * for a sanity check; this is a limit beyond which we can assume something + * bad has happened. + * + * It's also a crude check against unfortunate seg faults due to the queue + * filling up and quietly consuming all available memory. + */ template void QueuedReturn:: set_max_queue_size(int max_size) { @@ -32,23 +26,19 @@ set_max_queue_size(int max_size) { _max_queue_size = max_size; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::get_max_queue_size -// Access: Public -// Description: Returns the maximum size the queue is allowed to grow -// to. See set_max_queue_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size the queue is allowed to grow to. See + * set_max_queue_size(). + */ template int QueuedReturn:: get_max_queue_size() const { return _max_queue_size; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::get_current_queue_size -// Access: Public -// Description: Returns the current number of things in the queue. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of things in the queue. + */ template int QueuedReturn:: get_current_queue_size() const { @@ -57,37 +47,30 @@ get_current_queue_size() const { return size; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::get_overflow_flag -// Access: Published -// Description: Returns true if the queue has overflowed since the -// last call to reset_overflow_flag() (implying that -// some elements have been dropped from the queue), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the queue has overflowed since the last call to + * reset_overflow_flag() (implying that some elements have been dropped from + * the queue), or false otherwise. + */ template bool QueuedReturn:: get_overflow_flag() const { return _overflow_flag; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::reset_overflow_flag -// Access: Published -// Description: Resets the overflow flag so that get_overflow_flag() -// will return false until a new overflow occurs. -//////////////////////////////////////////////////////////////////// +/** + * Resets the overflow flag so that get_overflow_flag() will return false + * until a new overflow occurs. + */ template void QueuedReturn:: reset_overflow_flag() { _overflow_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template QueuedReturn:: QueuedReturn() { @@ -96,41 +79,32 @@ QueuedReturn() { _overflow_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template QueuedReturn:: ~QueuedReturn() { } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::thing_available -// Access: Protected -// Description: Returns true if a thing is available on the queue; -// call get_thing() to extract the thing. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a thing is available on the queue; call get_thing() to + * extract the thing. + */ template INLINE bool QueuedReturn:: thing_available() const { return _available; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::get_thing -// Access: Protected -// Description: If a previous call to thing_available() returned -// true, this function will return the thing that has -// become available. -// -// The return value is true if a thing was -// successfully returned, or false if there was, in -// fact, no thing available. (This may happen if -// there are multiple threads accessing the -// QueuedReturn). -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to thing_available() returned true, this function will + * return the thing that has become available. + * + * The return value is true if a thing was successfully returned, or false if + * there was, in fact, no thing available. (This may happen if there are + * multiple threads accessing the QueuedReturn). + */ template bool QueuedReturn:: get_thing(Thing &result) { @@ -147,13 +121,10 @@ get_thing(Thing &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::enqueue_thing -// Access: Protected -// Description: Adds a new thing to the queue for later retrieval. -// Returns true if successful, false if the queue is -// full (i.e. has reached _max_queue_size). -//////////////////////////////////////////////////////////////////// +/** + * Adds a new thing to the queue for later retrieval. Returns true if + * successful, false if the queue is full (i.e. has reached _max_queue_size). + */ template bool QueuedReturn:: enqueue_thing(const Thing &thing) { @@ -169,15 +140,12 @@ enqueue_thing(const Thing &thing) { return enqueue_ok; } -//////////////////////////////////////////////////////////////////// -// Function: QueuedReturn::enqueue_unique_thing -// Access: Protected -// Description: The same as enqueue_thing(), except the queue is -// first checked that it doesn't already have something -// like thing. The return value is true if the enqueue -// operation was successful, false if the queue was full -// or the thing was already on the queue. -//////////////////////////////////////////////////////////////////// +/** + * The same as enqueue_thing(), except the queue is first checked that it + * doesn't already have something like thing. The return value is true if the + * enqueue operation was successful, false if the queue was full or the thing + * was already on the queue. + */ template bool QueuedReturn:: enqueue_unique_thing(const Thing &thing) { diff --git a/panda/src/net/queuedReturn.h b/panda/src/net/queuedReturn.h index e50cc7b0cb..4be9c1aec3 100644 --- a/panda/src/net/queuedReturn.h +++ b/panda/src/net/queuedReturn.h @@ -1,16 +1,15 @@ -// Filename: queuedReturn.h -// Created by: drose (25Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file queuedReturn.h + * @author drose + * @date 2000-02-25 + */ #ifndef QUEUEDRETURN_H #define QUEUEDRETURN_H @@ -27,13 +26,11 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : QueuedReturn -// Description : This is the implementation of a family of things that -// queue up their return values for later retrieval by -// client code, like QueuedConnectionReader, -// QueuedConnectionListener, QueuedConnectionManager. -//////////////////////////////////////////////////////////////////// +/** + * This is the implementation of a family of things that queue up their return + * values for later retrieval by client code, like QueuedConnectionReader, + * QueuedConnectionListener, QueuedConnectionManager. + */ template class QueuedReturn { PUBLISHED: @@ -65,4 +62,3 @@ private: #include "queuedReturn.I" #endif - diff --git a/panda/src/net/recentConnectionReader.cxx b/panda/src/net/recentConnectionReader.cxx index b544d258f2..c03f9c67ef 100644 --- a/panda/src/net/recentConnectionReader.cxx +++ b/panda/src/net/recentConnectionReader.cxx @@ -1,73 +1,61 @@ -// Filename: recentConnectionReader.cxx -// Created by: drose (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recentConnectionReader.cxx + * @author drose + * @date 2000-06-23 + */ #include "recentConnectionReader.h" #include "config_net.h" #include "lightMutexHolder.h" -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecentConnectionReader:: RecentConnectionReader(ConnectionManager *manager) : ConnectionReader(manager, 1) { - // We should not receive any datagrams before the constructor is - // done initializing, or our thread may get confused. Fortunately - // this should be impossible, because we can't receive datagrams - // before we call add_connection(). + // We should not receive any datagrams before the constructor is done + // initializing, or our thread may get confused. Fortunately this should be + // impossible, because we can't receive datagrams before we call + // add_connection(). _available = false; } -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecentConnectionReader:: ~RecentConnectionReader() { - // We call shutdown() here to guarantee that all threads are gone - // before the RecentConnectionReader destructs. + // We call shutdown() here to guarantee that all threads are gone before the + // RecentConnectionReader destructs. shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::data_available -// Access: Public -// Description: Returns true if a datagram is available on the queue; -// call get_data() to extract the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a datagram is available on the queue; call get_data() to + * extract the datagram. + */ bool RecentConnectionReader:: data_available() { return _available; } -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::get_data -// Access: Public -// Description: If a previous call to data_available() returned -// true, this function will return the datagram that has -// become available. -// -// The return value is true if a datagram was -// successfully returned, or false if there was, in -// fact, no datagram available. (This may happen if -// there are multiple threads accessing the -// RecentConnectionReader). -//////////////////////////////////////////////////////////////////// +/** + * If a previous call to data_available() returned true, this function will + * return the datagram that has become available. + * + * The return value is true if a datagram was successfully returned, or false + * if there was, in fact, no datagram available. (This may happen if there + * are multiple threads accessing the RecentConnectionReader). + */ bool RecentConnectionReader:: get_data(NetDatagram &result) { LightMutexHolder holder(_mutex); @@ -81,16 +69,12 @@ get_data(NetDatagram &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::get_data -// Access: Public -// Description: This flavor of RecentConnectionReader::get_data(), -// works like the other, except that it only fills a -// Datagram object, not a NetDatagram object. This -// means that the Datagram cannot be queried for its -// source Connection and/or NetAddress, but it is useful -// in all other respects. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of RecentConnectionReader::get_data(), works like the other, + * except that it only fills a Datagram object, not a NetDatagram object. + * This means that the Datagram cannot be queried for its source Connection + * and/or NetAddress, but it is useful in all other respects. + */ bool RecentConnectionReader:: get_data(Datagram &result) { NetDatagram nd; @@ -101,14 +85,11 @@ get_data(Datagram &result) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RecentConnectionReader::receive_datagram -// Access: Protected, Virtual -// Description: An internal function called by ConnectionReader() -// when a new datagram has become available. The -// RecentConnectionReader simply queues it up for later -// retrieval by get_data(). -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionReader() when a new datagram has + * become available. The RecentConnectionReader simply queues it up for later + * retrieval by get_data(). + */ void RecentConnectionReader:: receive_datagram(const NetDatagram &datagram) { if (net_cat.is_debug()) { diff --git a/panda/src/net/recentConnectionReader.h b/panda/src/net/recentConnectionReader.h index 99c35ea337..f31f20ac2e 100644 --- a/panda/src/net/recentConnectionReader.h +++ b/panda/src/net/recentConnectionReader.h @@ -1,16 +1,15 @@ -// Filename: recentConnectionReader.h -// Created by: drose (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recentConnectionReader.h + * @author drose + * @date 2000-06-23 + */ #ifndef RECENTCONNECTIONREADER_H #define RECENTCONNECTIONREADER_H @@ -21,18 +20,15 @@ #include "netDatagram.h" #include "lightMutex.h" -//////////////////////////////////////////////////////////////////// -// Class : RecentConnectionReader -// Description : This flavor of ConnectionReader will read from its -// sockets and retain only the single most recent -// datagram for inspection by client code. It's useful -// particularly for reading telemetry-type data from UDP -// sockets where you don't care about getting every last -// socket, and in fact if the sockets are coming too -// fast you'd prefer to skip some of them. -// -// This class will always create one thread for itself. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of ConnectionReader will read from its sockets and retain only + * the single most recent datagram for inspection by client code. It's useful + * particularly for reading telemetry-type data from UDP sockets where you + * don't care about getting every last socket, and in fact if the sockets are + * coming too fast you'd prefer to skip some of them. + * + * This class will always create one thread for itself. + */ class EXPCL_PANDA_NET RecentConnectionReader : public ConnectionReader { PUBLISHED: RecentConnectionReader(ConnectionManager *manager); @@ -52,4 +48,3 @@ private: }; #endif - diff --git a/panda/src/net/test_datagram.cxx b/panda/src/net/test_datagram.cxx index 2c56e25d2e..db2f3fd305 100644 --- a/panda/src/net/test_datagram.cxx +++ b/panda/src/net/test_datagram.cxx @@ -1,16 +1,15 @@ -// Filename: test_datagram.cxx -// Created by: jns (07Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_datagram.cxx + * @author jns + * @date 2000-02-07 + */ #include "netDatagram.h" #include "datagramIterator.h" diff --git a/panda/src/net/test_raw_server.cxx b/panda/src/net/test_raw_server.cxx index 6a82c3383f..7811fdd446 100644 --- a/panda/src/net/test_raw_server.cxx +++ b/panda/src/net/test_raw_server.cxx @@ -1,16 +1,15 @@ -// Filename: test_raw_server.cxx -// Created by: drose (20Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_raw_server.cxx + * @author drose + * @date 2004-01-20 + */ #include "pandabase.h" @@ -100,8 +99,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/test_spam_client.cxx b/panda/src/net/test_spam_client.cxx index abf8fbb85b..e76643e5c2 100644 --- a/panda/src/net/test_spam_client.cxx +++ b/panda/src/net/test_spam_client.cxx @@ -1,16 +1,15 @@ -// Filename: test_spam_client.cxx -// Created by: drose (24Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_spam_client.cxx + * @author drose + * @date 2000-02-24 + */ #include "queuedConnectionManager.h" #include "queuedConnectionReader.h" @@ -109,8 +108,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/test_spam_server.cxx b/panda/src/net/test_spam_server.cxx index 4d597da353..3b8940cf0c 100644 --- a/panda/src/net/test_spam_server.cxx +++ b/panda/src/net/test_spam_server.cxx @@ -1,16 +1,15 @@ -// Filename: test_spam_server.cxx -// Created by: drose (24Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_spam_server.cxx + * @author drose + * @date 2000-02-24 + */ #include "pandabase.h" @@ -118,8 +117,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/test_tcp_client.cxx b/panda/src/net/test_tcp_client.cxx index 138675947a..4c5b15fa17 100644 --- a/panda/src/net/test_tcp_client.cxx +++ b/panda/src/net/test_tcp_client.cxx @@ -1,16 +1,15 @@ -// Filename: test_tcp_client.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_tcp_client.cxx + * @author drose + * @date 2000-02-09 + */ #include "queuedConnectionManager.h" #include "queuedConnectionReader.h" @@ -94,8 +93,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/test_tcp_server.cxx b/panda/src/net/test_tcp_server.cxx index 65cfd2552b..3b393c8a0f 100644 --- a/panda/src/net/test_tcp_server.cxx +++ b/panda/src/net/test_tcp_server.cxx @@ -1,16 +1,15 @@ -// Filename: test_tcp_server.cxx -// Created by: drose (09Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_tcp_server.cxx + * @author drose + * @date 2000-02-09 + */ #include "pandabase.h" @@ -120,8 +119,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/net/test_udp.cxx b/panda/src/net/test_udp.cxx index da91af7e1f..f069523f48 100644 --- a/panda/src/net/test_udp.cxx +++ b/panda/src/net/test_udp.cxx @@ -1,16 +1,15 @@ -// Filename: test_udp.cxx -// Created by: drose (08Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_udp.cxx + * @author drose + * @date 2000-02-08 + */ #include "queuedConnectionManager.h" #include "recentConnectionReader.h" @@ -91,8 +90,3 @@ main(int argc, char *argv[]) { return (0); } - - - - - diff --git a/panda/src/ode/config_ode.cxx b/panda/src/ode/config_ode.cxx index 10a81b29bd..1994fe1254 100644 --- a/panda/src/ode/config_ode.cxx +++ b/panda/src/ode/config_ode.cxx @@ -1,16 +1,15 @@ -// Filename: config_ode.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ode.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeWorld.h" @@ -61,14 +60,12 @@ ConfigureFn(config_ode) { init_libode(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libode -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libode() { static bool initialized = false; @@ -76,9 +73,9 @@ init_libode() { return; } initialized = true; - + dInitODE(); - + OdeWorld::init_type(); OdeMass::init_type(); OdeBody::init_type(); diff --git a/panda/src/ode/config_ode.h b/panda/src/ode/config_ode.h index 71020e2bdc..aebe1b42fc 100644 --- a/panda/src/ode/config_ode.h +++ b/panda/src/ode/config_ode.h @@ -1,16 +1,15 @@ -// Filename: config_ode.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ode.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef CONFIG_ODE_H #define CONFIG_ODE_H diff --git a/panda/src/ode/odeAMotorJoint.I b/panda/src/ode/odeAMotorJoint.I index 37cfc81840..78c02356ea 100644 --- a/panda/src/ode/odeAMotorJoint.I +++ b/panda/src/ode/odeAMotorJoint.I @@ -1,16 +1,15 @@ -// Filename: odeAMotorJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeAMotorJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeAMotorJoint:: set_num_axes(int num) { @@ -316,4 +315,3 @@ get_param_stop_CFM(int axis) const { } return 0; } - diff --git a/panda/src/ode/odeAMotorJoint.cxx b/panda/src/ode/odeAMotorJoint.cxx index 69fb78e4ee..8b7a16d6bc 100644 --- a/panda/src/ode/odeAMotorJoint.cxx +++ b/panda/src/ode/odeAMotorJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeAMotorJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeAMotorJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeAMotorJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeAMotorJoint::_type_handle; OdeAMotorJoint:: -OdeAMotorJoint(dJointID id) : +OdeAMotorJoint(dJointID id) : OdeJoint(id) { } OdeAMotorJoint:: -OdeAMotorJoint(OdeWorld &world) : +OdeAMotorJoint(OdeWorld &world) : OdeJoint(dJointCreateAMotor(world.get_id(), 0)) { } OdeAMotorJoint:: -OdeAMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeAMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateAMotor(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeAMotorJoint.h b/panda/src/ode/odeAMotorJoint.h index c3b41a677d..c12b48524e 100644 --- a/panda/src/ode/odeAMotorJoint.h +++ b/panda/src/ode/odeAMotorJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeAMotorJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODEAMOTORJOINT_H #define ODEAMOTORJOINT_H @@ -9,10 +23,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeAMotorJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeAMotorJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeBallJoint.I b/panda/src/ode/odeBallJoint.I index d9935df699..c345a2a853 100644 --- a/panda/src/ode/odeBallJoint.I +++ b/panda/src/ode/odeBallJoint.I @@ -1,16 +1,15 @@ -// Filename: odeBallJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBallJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeBallJoint:: set_anchor(dReal x, dReal y, dReal z) { diff --git a/panda/src/ode/odeBallJoint.cxx b/panda/src/ode/odeBallJoint.cxx index 8bc65d7cfa..b578c72c6b 100644 --- a/panda/src/ode/odeBallJoint.cxx +++ b/panda/src/ode/odeBallJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeBallJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBallJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeBallJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeBallJoint::_type_handle; OdeBallJoint:: -OdeBallJoint(dJointID id) : +OdeBallJoint(dJointID id) : OdeJoint(id) { } OdeBallJoint:: -OdeBallJoint(OdeWorld &world) : +OdeBallJoint(OdeWorld &world) : OdeJoint(dJointCreateBall(world.get_id(), 0)) { } OdeBallJoint:: -OdeBallJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeBallJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateBall(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeBallJoint.h b/panda/src/ode/odeBallJoint.h index be6100bf76..480a815531 100644 --- a/panda/src/ode/odeBallJoint.h +++ b/panda/src/ode/odeBallJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBallJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODEBALLJOINT_H #define ODEBALLJOINT_H @@ -9,10 +23,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeBallJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeBallJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeBody.I b/panda/src/ode/odeBody.I index 1ae24323d7..ab241fb455 100644 --- a/panda/src/ode/odeBody.I +++ b/panda/src/ode/odeBody.I @@ -1,35 +1,29 @@ -// Filename: odeBody.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBody.I + * @author joswilso + * @date 2006-12-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeBody::is_empty -// Access: Published -// Description: Returns true if the ID is 0, meaning the OdeBody -// does not point to a valid body. It is an error to -// call a method on an empty body. -// Note that an empty OdeBody also evaluates to False. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ID is 0, meaning the OdeBody does not point to a valid + * body. It is an error to call a method on an empty body. Note that an + * empty OdeBody also evaluates to False. + */ INLINE bool OdeBody:: is_empty() const { return (_id == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeBody::get_id -// Access: Published -// Description: Returns the underlying dBodyID. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying dBodyID. + */ INLINE dBodyID OdeBody:: get_id() const { return _id; diff --git a/panda/src/ode/odeBody.cxx b/panda/src/ode/odeBody.cxx index 9de0334fb9..4f70faff08 100644 --- a/panda/src/ode/odeBody.cxx +++ b/panda/src/ode/odeBody.cxx @@ -1,16 +1,15 @@ -// Filename: odeBody.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBody.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeBody.h" @@ -65,7 +64,7 @@ get_data() const { OdeJoint OdeBody:: get_joint(int index) const { nassertr(_id != 0, OdeJoint(0)); - nassertr(index < get_num_joints(), OdeJoint(0)); + nassertr(index < get_num_joints(), OdeJoint(0)); return OdeJoint(dBodyGetJoint(_id, index)); } diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h index 6f10130896..dd68389abd 100644 --- a/panda/src/ode/odeBody.h +++ b/panda/src/ode/odeBody.h @@ -1,16 +1,15 @@ -// Filename: odeBody.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBody.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEBODY_H #define ODEBODY_H @@ -27,10 +26,9 @@ class OdeJoint; class OdeGeom; class OdeCollisionEntry; -//////////////////////////////////////////////////////////////////// -// Class : OdeBody -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeBody : public TypedObject { friend class OdeJoint; friend class OdeGeom; @@ -94,21 +92,21 @@ PUBLISHED: INLINE void add_rel_force(const LVecBase3f &f); INLINE void add_rel_torque(dReal fx, dReal fy, dReal fz); INLINE void add_rel_torque(const LVecBase3f &f); - INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz, + INLINE void add_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz); - INLINE void add_force_at_pos(const LVecBase3f &f, + INLINE void add_force_at_pos(const LVecBase3f &f, const LVecBase3f &pos); - INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz, + INLINE void add_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz); - INLINE void add_force_at_rel_pos(const LVecBase3f &f, + INLINE void add_force_at_rel_pos(const LVecBase3f &f, const LVecBase3f &pos); - INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz, + INLINE void add_rel_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz); - INLINE void add_rel_force_at_pos(const LVecBase3f &f, + INLINE void add_rel_force_at_pos(const LVecBase3f &f, const LVecBase3f &pos); - INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz, + INLINE void add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz); - INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f, + INLINE void add_rel_force_at_rel_pos(const LVecBase3f &f, const LVecBase3f &pos); INLINE void set_force(dReal x, dReal y, dReal z); INLINE void set_force(const LVecBase3f &f); diff --git a/panda/src/ode/odeBody_ext.I b/panda/src/ode/odeBody_ext.I index b3618ae4b1..a26eba5b41 100644 --- a/panda/src/ode/odeBody_ext.I +++ b/panda/src/ode/odeBody_ext.I @@ -1,24 +1,21 @@ -// Filename: odeBody_ext.I -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBody_ext.I + * @author rdb + * @date 2013-12-11 + */ #include "odeJoint_ext.h" -//////////////////////////////////////////////////////////////////// -// Function: OdeBody::get_converted_joint -// Access: Published -// Description: Equivalent to get_joint().convert() -//////////////////////////////////////////////////////////////////// +/** + * Equivalent to get_joint().convert() + */ INLINE PyObject *Extension:: get_converted_joint(int i) const { OdeJoint j = _this->get_joint(i); diff --git a/panda/src/ode/odeBody_ext.h b/panda/src/ode/odeBody_ext.h index 1331d47183..04c2244324 100644 --- a/panda/src/ode/odeBody_ext.h +++ b/panda/src/ode/odeBody_ext.h @@ -1,16 +1,15 @@ -// Filename: odeBody_ext.h -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBody_ext.h + * @author rdb + * @date 2013-12-11 + */ #ifndef ODEBODY_EXT_H #define ODEBODY_EXT_H @@ -24,12 +23,10 @@ #include "extension.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/ode/odeBoxGeom.I b/panda/src/ode/odeBoxGeom.I index 7574638600..569d2af7ce 100644 --- a/panda/src/ode/odeBoxGeom.I +++ b/panda/src/ode/odeBoxGeom.I @@ -1,16 +1,15 @@ -// Filename: odeBoxGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBoxGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeBoxGeom:: set_lengths(dReal lx, dReal ly, dReal lz) { @@ -38,4 +37,3 @@ INLINE dReal OdeBoxGeom:: get_point_depth(const LPoint3f &p) { return get_point_depth(p[0], p[1], p[2]); } - diff --git a/panda/src/ode/odeBoxGeom.cxx b/panda/src/ode/odeBoxGeom.cxx index c1e770ecbc..77a594b552 100644 --- a/panda/src/ode/odeBoxGeom.cxx +++ b/panda/src/ode/odeBoxGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeBoxGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBoxGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeBoxGeom.h" diff --git a/panda/src/ode/odeBoxGeom.h b/panda/src/ode/odeBoxGeom.h index 9991124a59..eadf84e534 100644 --- a/panda/src/ode/odeBoxGeom.h +++ b/panda/src/ode/odeBoxGeom.h @@ -1,16 +1,15 @@ -// Filename: odeBoxGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeBoxGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEBOXGEOM_H #define ODEBOXGEOM_H @@ -22,10 +21,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeBoxGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeBoxGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeCappedCylinderGeom.I b/panda/src/ode/odeCappedCylinderGeom.I index 1b264f1dd2..c66124bae2 100644 --- a/panda/src/ode/odeCappedCylinderGeom.I +++ b/panda/src/ode/odeCappedCylinderGeom.I @@ -1,16 +1,15 @@ -// Filename: odeCappedCylinderGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCappedCylinderGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeCappedCylinderGeom:: set_params(dReal radius, dReal length) { diff --git a/panda/src/ode/odeCappedCylinderGeom.cxx b/panda/src/ode/odeCappedCylinderGeom.cxx index 367c1813fd..5b1a3b5b40 100644 --- a/panda/src/ode/odeCappedCylinderGeom.cxx +++ b/panda/src/ode/odeCappedCylinderGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeCappedCylinderGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCappedCylinderGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeCappedCylinderGeom.h" diff --git a/panda/src/ode/odeCappedCylinderGeom.h b/panda/src/ode/odeCappedCylinderGeom.h index 2e48cb36c0..f48385ef7e 100644 --- a/panda/src/ode/odeCappedCylinderGeom.h +++ b/panda/src/ode/odeCappedCylinderGeom.h @@ -1,16 +1,15 @@ -// Filename: odeCappedCylinderGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCappedCylinderGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODECAPPEDCYLINDERGEOM_H #define ODECAPPEDCYLINDERGEOM_H @@ -22,10 +21,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeCappedCylinderGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeCappedCylinderGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeCollisionEntry.I b/panda/src/ode/odeCollisionEntry.I index 2b8e221d34..9337840cab 100644 --- a/panda/src/ode/odeCollisionEntry.I +++ b/panda/src/ode/odeCollisionEntry.I @@ -1,129 +1,103 @@ -// Filename: odeCollisionEntry.I -// Created by: pro-rsoft (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCollisionEntry.I + * @author rdb + * @date 2009-03-13 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OdeCollisionEntry:: OdeCollisionEntry() { } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_geom1 -// Access: Published -// Description: Returns the first geom in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first geom in the collision. + */ INLINE OdeGeom OdeCollisionEntry:: get_geom1() const { return OdeGeom(_geom1); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_geom2 -// Access: Published -// Description: Returns the second geom in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second geom in the collision. + */ INLINE OdeGeom OdeCollisionEntry:: get_geom2() const { return OdeGeom(_geom2); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_body1 -// Access: Published -// Description: Returns the first body in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first body in the collision. + */ INLINE OdeBody OdeCollisionEntry:: get_body1() const { return OdeBody(_body1); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_body2 -// Access: Published -// Description: Returns the second body in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second body in the collision. + */ INLINE OdeBody OdeCollisionEntry:: get_body2() const { return OdeBody(_body2); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_num_contacts -// Access: Published -// Description: Returns the number of contacts in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of contacts in the collision. + */ INLINE size_t OdeCollisionEntry:: get_num_contacts() const { return _num_contacts; } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_contact_geom -// Access: Published -// Description: Returns the nth contact geom in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth contact geom in the collision. + */ INLINE OdeContactGeom OdeCollisionEntry:: get_contact_geom(size_t n) const { nassertr(n >= 0 && n < _num_contacts, OdeContactGeom()); return _contact_geoms[n]; } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::operator [] -// Access: Published -// Description: Returns the nth contact geom in the collision. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth contact geom in the collision. + */ INLINE OdeContactGeom OdeCollisionEntry:: operator [] (size_t n) const { nassertr(n >= 0 && n < _num_contacts, OdeContactGeom()); return _contact_geoms[n]; } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_contact_point -// Access: Published -// Description: Returns the nth contact point in the collision. -// This does exactly the same as -// get_contact_geom(n).get_pos(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth contact point in the collision. This does exactly the same + * as get_contact_geom(n).get_pos(). + */ INLINE LPoint3f OdeCollisionEntry:: get_contact_point(size_t n) const { nassertr(n >= 0 && n < _num_contacts, LPoint3f::zero()); return _contact_geoms[n].get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::operator bool -// Access: Published -// Description: An OdeCollisionEntry evaluates to False if it -// holds no contacts. -//////////////////////////////////////////////////////////////////// +/** + * An OdeCollisionEntry evaluates to False if it holds no contacts. + */ INLINE OdeCollisionEntry:: operator bool () const { return (_num_contacts != 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::is_empty -// Access: Published -// Description: Returns true if the entry holds no contacts. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entry holds no contacts. + */ INLINE bool OdeCollisionEntry:: is_empty() const { return (_num_contacts == 0); } - diff --git a/panda/src/ode/odeCollisionEntry.cxx b/panda/src/ode/odeCollisionEntry.cxx index 85e782e161..b88e29b29e 100644 --- a/panda/src/ode/odeCollisionEntry.cxx +++ b/panda/src/ode/odeCollisionEntry.cxx @@ -1,28 +1,24 @@ -// Filename: odeCollisionEntry.cxx -// Created by: pro-rsoft (05Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCollisionEntry.cxx + * @author rdb + * @date 2009-03-05 + */ #include "odeCollisionEntry.h" TypeHandle OdeCollisionEntry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OdeCollisionEntry:: ~OdeCollisionEntry() { delete[] _contact_geoms; } - diff --git a/panda/src/ode/odeCollisionEntry.h b/panda/src/ode/odeCollisionEntry.h index 8b133bc0b9..f8b62ee38e 100644 --- a/panda/src/ode/odeCollisionEntry.h +++ b/panda/src/ode/odeCollisionEntry.h @@ -1,16 +1,15 @@ -// Filename: odeCollisionEntry.h -// Created by: pro-rsoft (05Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCollisionEntry.h + * @author rdb + * @date 2009-03-05 + */ #ifndef ODECOLLISIONENTRY_H #define ODECOLLISIONENTRY_H @@ -22,27 +21,25 @@ class OdeUtil; -//////////////////////////////////////////////////////////////////// -// Class : OdeCollisionEntry -// Description : A class used to hold information about a collision -// that has occurred. -//////////////////////////////////////////////////////////////////// +/** + * A class used to hold information about a collision that has occurred. + */ class EXPCL_PANDAODE OdeCollisionEntry : public TypedReferenceCount { PUBLISHED: virtual ~OdeCollisionEntry(); - + INLINE OdeGeom get_geom1() const; INLINE OdeGeom get_geom2() const; INLINE OdeBody get_body1() const; INLINE OdeBody get_body2() const; - + INLINE size_t get_num_contacts() const; INLINE LPoint3f get_contact_point(size_t n) const; INLINE OdeContactGeom get_contact_geom(size_t n) const; INLINE OdeContactGeom operator [] (size_t n) const; MAKE_SEQ(get_contact_points, get_num_contacts, get_contact_point); MAKE_SEQ(get_contact_geoms, get_num_contacts, get_contact_geom); - + INLINE operator bool () const; INLINE bool is_empty() const; @@ -78,4 +75,3 @@ private: #include "odeCollisionEntry.I" #endif - diff --git a/panda/src/ode/odeContact.I b/panda/src/ode/odeContact.I index 69cffbca94..6bc07c0a11 100644 --- a/panda/src/ode/odeContact.I +++ b/panda/src/ode/odeContact.I @@ -1,16 +1,15 @@ -// Filename: odeContact.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContact.I + * @author joswilso + * @date 2006-12-27 + */ INLINE OdeSurfaceParameters OdeContact:: get_surface() const { @@ -46,5 +45,3 @@ set_fdir1(const LVecBase3f &fdir1) { _contact.fdir1[1] = fdir1[1]; _contact.fdir1[2] = fdir1[2]; } - - diff --git a/panda/src/ode/odeContact.cxx b/panda/src/ode/odeContact.cxx index 4c169e0207..58ae51ea17 100644 --- a/panda/src/ode/odeContact.cxx +++ b/panda/src/ode/odeContact.cxx @@ -1,16 +1,15 @@ -// Filename: odeContact.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContact.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeContact.h" @@ -18,12 +17,12 @@ TypeHandle OdeContact::_type_handle; OdeContact:: -OdeContact() : +OdeContact() : _contact() { } OdeContact:: -OdeContact(const dContact &contact) : +OdeContact(const dContact &contact) : _contact(contact) { } diff --git a/panda/src/ode/odeContact.h b/panda/src/ode/odeContact.h index b64f473f8a..9e389c3bf0 100644 --- a/panda/src/ode/odeContact.h +++ b/panda/src/ode/odeContact.h @@ -1,16 +1,15 @@ -// Filename: odeContact.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContact.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODECONTACT_H #define ODECONTACT_H @@ -24,10 +23,9 @@ #include "odeContactGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeContact -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeContact : public TypedReferenceCount { PUBLISHED: OdeContact(); diff --git a/panda/src/ode/odeContactGeom.I b/panda/src/ode/odeContactGeom.I index d8e9174cbe..b035493589 100644 --- a/panda/src/ode/odeContactGeom.I +++ b/panda/src/ode/odeContactGeom.I @@ -1,16 +1,15 @@ -// Filename: odeContactGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE LVecBase3f OdeContactGeom:: get_pos() const { diff --git a/panda/src/ode/odeContactGeom.cxx b/panda/src/ode/odeContactGeom.cxx index e1f0e02402..e78d00b44d 100644 --- a/panda/src/ode/odeContactGeom.cxx +++ b/panda/src/ode/odeContactGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeContactGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeContactGeom.h" @@ -18,18 +17,18 @@ TypeHandle OdeContactGeom::_type_handle; OdeContactGeom:: -OdeContactGeom() : +OdeContactGeom() : _contact_geom() { } OdeContactGeom:: -OdeContactGeom(const OdeContactGeom ©) : +OdeContactGeom(const OdeContactGeom ©) : _contact_geom() { *this = copy._contact_geom; } OdeContactGeom:: -OdeContactGeom(const dContactGeom ©) : +OdeContactGeom(const dContactGeom ©) : _contact_geom() { *this = copy; } @@ -62,4 +61,3 @@ operator = (const dContactGeom &contact_geom) { _contact_geom.side1 = contact_geom.side1; _contact_geom.side2 = contact_geom.side2; } - diff --git a/panda/src/ode/odeContactGeom.h b/panda/src/ode/odeContactGeom.h index af6772690e..f028edfd45 100644 --- a/panda/src/ode/odeContactGeom.h +++ b/panda/src/ode/odeContactGeom.h @@ -1,16 +1,15 @@ -// Filename: odeContactGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODECONTACTGEOM_H #define ODECONTACTGEOM_H @@ -25,10 +24,9 @@ class OdeSpace; class OdeUtil; -//////////////////////////////////////////////////////////////////// -// Class : OdeContactGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeContactGeom : public TypedReferenceCount { friend class OdeContact; friend class OdeSpace; @@ -39,20 +37,20 @@ PUBLISHED: OdeContactGeom(const OdeContactGeom ©); virtual ~OdeContactGeom(); - INLINE LVecBase3f get_pos() const; + INLINE LVecBase3f get_pos() const; INLINE LVecBase3f get_normal() const; - INLINE dReal get_depth() const; + INLINE dReal get_depth() const; INLINE OdeGeom get_g1() const; INLINE OdeGeom get_g2() const; INLINE int get_side1() const; INLINE int get_side2() const; - INLINE void set_pos(const LVecBase3f &pos); + INLINE void set_pos(const LVecBase3f &pos); INLINE void set_normal(const LVecBase3f &normal); - INLINE void set_depth(const dReal depth); + INLINE void set_depth(const dReal depth); INLINE void set_g1(const OdeGeom &geom); INLINE void set_g2(const OdeGeom &geom); - + public: OdeContactGeom(const dContactGeom ©); const dContactGeom* get_contact_geom_ptr() const; diff --git a/panda/src/ode/odeContactJoint.I b/panda/src/ode/odeContactJoint.I index 4f68288064..be86d223d1 100644 --- a/panda/src/ode/odeContactJoint.I +++ b/panda/src/ode/odeContactJoint.I @@ -1,13 +1,12 @@ -// Filename: odeContactJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactJoint.I + * @author joswilso + * @date 2006-12-27 + */ diff --git a/panda/src/ode/odeContactJoint.cxx b/panda/src/ode/odeContactJoint.cxx index 712ea43872..b53694b1b3 100644 --- a/panda/src/ode/odeContactJoint.cxx +++ b/panda/src/ode/odeContactJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeContactJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeContactJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeContactJoint::_type_handle; OdeContactJoint:: -OdeContactJoint(dJointID id) : +OdeContactJoint(dJointID id) : OdeJoint(id) { } OdeContactJoint:: -OdeContactJoint(OdeWorld &world, const OdeContact &contact) : +OdeContactJoint(OdeWorld &world, const OdeContact &contact) : OdeJoint(dJointCreateContact(world.get_id(), 0, contact.get_contact_ptr())) { } OdeContactJoint:: -OdeContactJoint(OdeWorld &world, OdeJointGroup &joint_group, const OdeContact &contact) : +OdeContactJoint(OdeWorld &world, OdeJointGroup &joint_group, const OdeContact &contact) : OdeJoint(dJointCreateContact(world.get_id(), joint_group.get_id(), contact.get_contact_ptr())) { } diff --git a/panda/src/ode/odeContactJoint.h b/panda/src/ode/odeContactJoint.h index f2edc91de2..e31abb12ac 100644 --- a/panda/src/ode/odeContactJoint.h +++ b/panda/src/ode/odeContactJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeContactJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODECONTACTJOINT_H #define ODECONTACTJOINT_H @@ -10,10 +24,9 @@ #include "odeJoint.h" #include "odeContact.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeContactJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeContactJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeConvexGeom.I b/panda/src/ode/odeConvexGeom.I index 1c3980d174..9044d3f74c 100644 --- a/panda/src/ode/odeConvexGeom.I +++ b/panda/src/ode/odeConvexGeom.I @@ -1,19 +1,17 @@ -// Filename: odeConvexGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeConvexGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeGeom:: set_convex(dReal *_planes, unsigned int _count, dReal *_points, unsigned int _pointcount, unsigned int *_polygons) { dGeomSetConvex(_id, *_planes, _count, *_points, _pointcount, *_polygons); } - diff --git a/panda/src/ode/odeConvexGeom.cxx b/panda/src/ode/odeConvexGeom.cxx index 61f2d42f76..3160d343de 100644 --- a/panda/src/ode/odeConvexGeom.cxx +++ b/panda/src/ode/odeConvexGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeConvexGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeConvexGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeConvexGeom.h" diff --git a/panda/src/ode/odeConvexGeom.h b/panda/src/ode/odeConvexGeom.h index bc4104855a..8a7c259076 100644 --- a/panda/src/ode/odeConvexGeom.h +++ b/panda/src/ode/odeConvexGeom.h @@ -1,16 +1,15 @@ -// Filename: odeConvexGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeConvexGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODECONVEXGEOM_H #define ODECONVEXGEOM_H @@ -22,10 +21,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeConvexGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeConvexGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeCylinderGeom.I b/panda/src/ode/odeCylinderGeom.I index 5d8a9d1a97..f2b26e0d1d 100644 --- a/panda/src/ode/odeCylinderGeom.I +++ b/panda/src/ode/odeCylinderGeom.I @@ -1,16 +1,15 @@ -// Filename: odeCylinderGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCylinderGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeCylinderGeom:: set_params(dReal radius, dReal length) { diff --git a/panda/src/ode/odeCylinderGeom.cxx b/panda/src/ode/odeCylinderGeom.cxx index f0a5e5236f..7b7eccc49e 100644 --- a/panda/src/ode/odeCylinderGeom.cxx +++ b/panda/src/ode/odeCylinderGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeCylinderGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCylinderGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeCylinderGeom.h" diff --git a/panda/src/ode/odeCylinderGeom.h b/panda/src/ode/odeCylinderGeom.h index 1b847c908c..3c23a02336 100644 --- a/panda/src/ode/odeCylinderGeom.h +++ b/panda/src/ode/odeCylinderGeom.h @@ -1,16 +1,15 @@ -// Filename: odeCylinderGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeCylinderGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODECYLINDERGEOM_H #define ODECYLINDERGEOM_H @@ -22,10 +21,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeCylinderGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeCylinderGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeFixedJoint.I b/panda/src/ode/odeFixedJoint.I index 25a88069a4..feb85b5ff4 100644 --- a/panda/src/ode/odeFixedJoint.I +++ b/panda/src/ode/odeFixedJoint.I @@ -1,16 +1,15 @@ -// Filename: odeFixedJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeFixedJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeFixedJoint:: set() { diff --git a/panda/src/ode/odeFixedJoint.cxx b/panda/src/ode/odeFixedJoint.cxx index ff7601f604..346a1dbdaa 100644 --- a/panda/src/ode/odeFixedJoint.cxx +++ b/panda/src/ode/odeFixedJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeFixedJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeFixedJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeFixedJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeFixedJoint::_type_handle; OdeFixedJoint:: -OdeFixedJoint(dJointID id) : +OdeFixedJoint(dJointID id) : OdeJoint(id) { } OdeFixedJoint:: -OdeFixedJoint(OdeWorld &world) : +OdeFixedJoint(OdeWorld &world) : OdeJoint(dJointCreateFixed(world.get_id(), 0)) { } OdeFixedJoint:: -OdeFixedJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeFixedJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateFixed(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeFixedJoint.h b/panda/src/ode/odeFixedJoint.h index a1d8a6d59e..de4f8a90da 100644 --- a/panda/src/ode/odeFixedJoint.h +++ b/panda/src/ode/odeFixedJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeFixedJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODEFIXEDJOINT_H #define ODEFIXEDJOINT_H @@ -9,10 +23,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeFixedJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeFixedJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeGeom.I b/panda/src/ode/odeGeom.I index f275cd7be0..883e367e70 100644 --- a/panda/src/ode/odeGeom.I +++ b/panda/src/ode/odeGeom.I @@ -1,35 +1,29 @@ -// Filename: odeGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom.I + * @author joswilso + * @date 2006-12-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeGeom::is_empty -// Access: Published -// Description: Returns true if the ID is 0, meaning the OdeGeom -// does not point to a valid geom. It is an error to -// call a method on an empty geom. -// Note that an empty OdeGeom also evaluates to False. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ID is 0, meaning the OdeGeom does not point to a valid + * geom. It is an error to call a method on an empty geom. Note that an + * empty OdeGeom also evaluates to False. + */ INLINE bool OdeGeom:: is_empty() const { return (_id == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeGeom::get_id -// Access: Published -// Description: Returns the underlying dGeomID. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying dGeomID. + */ INLINE dGeomID OdeGeom:: get_id() const { return _id; diff --git a/panda/src/ode/odeGeom.cxx b/panda/src/ode/odeGeom.cxx index ea538178d2..c1d4d0866f 100644 --- a/panda/src/ode/odeGeom.cxx +++ b/panda/src/ode/odeGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeGeom.h" @@ -27,8 +26,8 @@ #include "odeRayGeom.h" #include "odeSphereGeom.h" -//OdeGeom::GeomSurfaceMap OdeGeom::_geom_surface_map; -//OdeGeom::GeomCollideIdMap OdeGeom::_geom_collide_id_map; +// OdeGeom::GeomSurfaceMap OdeGeom::_geom_surface_map; +// OdeGeom::GeomCollideIdMap OdeGeom::_geom_collide_id_map; TypeHandle OdeGeom::_type_handle; OdeGeom:: @@ -40,12 +39,12 @@ OdeGeom(dGeomID id) : OdeGeom:: ~OdeGeom() { odegeom_cat.debug() << "~" << get_type() << "(" << _id << ")\n"; - /* + /* GeomSurfaceMap::iterator iter = _geom_surface_map.find(this->get_id()); if (iter != _geom_surface_map.end()) { _geom_surface_map.erase(iter); } - + GeomCollideIdMap::iterator iter2 = _geom_collide_id_map.find(this->get_id()); if (iter2 != _geom_collide_id_map.end()) { _geom_collide_id_map.erase(iter2); @@ -55,34 +54,34 @@ OdeGeom:: /* int OdeGeom:: -get_surface_type() +get_surface_type() { return get_space().get_surface_type(this->get_id()); } int OdeGeom:: -get_collide_id() +get_collide_id() { return get_space().get_collide_id(this->get_id()); } void OdeGeom:: -set_surface_type(int surface_type) +set_surface_type(int surface_type) { get_space().set_surface_type(surface_type, this->get_id()); } int OdeGeom:: -set_collide_id(int collide_id) +set_collide_id(int collide_id) { return get_space().set_collide_id(collide_id, this->get_id()); } int OdeGeom:: -test_collide_id(int collide_id) +test_collide_id(int collide_id) { - + odegeom_cat.debug() << "test_collide_id start" << "\n"; int first = get_space().set_collide_id(collide_id, this->get_id()); odegeom_cat.debug() << "returns" << first << "\n"; @@ -109,7 +108,7 @@ get_space() const { void OdeGeom:: write(ostream &out, unsigned int indent) const { - out.width(indent); + out.width(indent); out << get_type() << "(id = " << _id << ")"; } @@ -205,4 +204,3 @@ OdeGeom:: operator bool () const { return (_id != NULL); } - diff --git a/panda/src/ode/odeGeom.h b/panda/src/ode/odeGeom.h index dff9eddeed..27d62965cb 100644 --- a/panda/src/ode/odeGeom.h +++ b/panda/src/ode/odeGeom.h @@ -1,16 +1,15 @@ -// Filename: odeGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEGEOM_H #define ODEGEOM_H @@ -40,10 +39,9 @@ class OdeQuadTreeSpace; class OdeUtil; class OdeCollisionEntry; -//////////////////////////////////////////////////////////////////// -// Class : OdeGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeGeom : public TypedObject { friend class OdeContactGeom; friend class OdeSpace; @@ -54,14 +52,13 @@ public: OdeGeom(dGeomID id); PUBLISHED: - enum GeomClass { GC_sphere = 0, + enum GeomClass { GC_sphere = 0, GC_box, GC_capped_cylinder, GC_cylinder, GC_plane, GC_ray, - // GC_convex, - // GC_geom_transform, + // GC_convex, GC_geom_transform, GC_tri_mesh = 8, // GC_heightfield, @@ -75,7 +72,7 @@ PUBLISHED: INLINE bool is_empty() const; INLINE dGeomID get_id() const; - //INLINE void set_data(void* data); + // INLINE void set_data(void* data); INLINE void set_body(OdeBody &body); INLINE bool has_body() const; INLINE OdeBody get_body() const; @@ -111,12 +108,10 @@ PUBLISHED: INLINE LMatrix3f get_offset_rotation() const; INLINE LQuaternionf get_offset_quaternion() const; - //int get_surface_type() ; - //int get_collide_id() ; - //int set_collide_id( int collide_id); - //void set_surface_type( int surface_type); + // int get_surface_type() ; int get_collide_id() ; int set_collide_id( int + // collide_id); void set_surface_type( int surface_type); - //int test_collide_id( int collide_id); + // int test_collide_id( int collide_id); OdeSpace get_space() const; EXTENSION(INLINE PyObject *get_converted_space() const); diff --git a/panda/src/ode/odeGeom_ext.I b/panda/src/ode/odeGeom_ext.I index e7508da018..d01e1b1220 100644 --- a/panda/src/ode/odeGeom_ext.I +++ b/panda/src/ode/odeGeom_ext.I @@ -1,25 +1,22 @@ -// Filename: odeGeom_ext.I -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom_ext.I + * @author rdb + * @date 2013-12-11 + */ #include "odeSpace_ext.h" #include "lpoint3.h" -//////////////////////////////////////////////////////////////////// -// Function: OdeGeom::get_AA_bounds -// Access: Published -// Description: A more Pythonic way of calling getAABB() -//////////////////////////////////////////////////////////////////// +/** + * A more Pythonic way of calling getAABB() + */ INLINE PyObject *Extension:: get_AA_bounds() const { LPoint3f *min_point = new LPoint3f; @@ -31,11 +28,9 @@ get_AA_bounds() const { return Py_BuildValue("NN", min_inst, max_inst); } -//////////////////////////////////////////////////////////////////// -// Function: OdeGeom::get_converted_space -// Access: Published -// Description: Equivalent to get_space().convert() -//////////////////////////////////////////////////////////////////// +/** + * Equivalent to get_space().convert() + */ INLINE PyObject *Extension:: get_converted_space() const { OdeSpace s = _this->get_space(); diff --git a/panda/src/ode/odeGeom_ext.cxx b/panda/src/ode/odeGeom_ext.cxx index 6e248f6404..a0bbf2f274 100644 --- a/panda/src/ode/odeGeom_ext.cxx +++ b/panda/src/ode/odeGeom_ext.cxx @@ -1,25 +1,24 @@ -// Filename: odeGeom_ext.cxx -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom_ext.cxx + * @author rdb + * @date 2013-12-11 + */ #include "odeGeom_ext.h" #include "odeBoxGeom.h" -//#include "odeConvexGeom.h" +// #include "odeConvexGeom.h" #include "odeGeom.h" #include "odeHashSpace.h" #include "odeCappedCylinderGeom.h" -//#include "odeHeightfieldGeom.h" +// #include "odeHeightfieldGeom.h" #include "odePlaneGeom.h" #include "odeQuadTreeSpace.h" #include "odeRayGeom.h" @@ -32,11 +31,11 @@ #ifndef CPPPARSER extern Dtool_PyTypedObject Dtool_OdeBoxGeom; -//extern Dtool_PyTypedObject Dtool_OdeConvexGeom; +// extern Dtool_PyTypedObject Dtool_OdeConvexGeom; extern Dtool_PyTypedObject Dtool_OdeGeom; extern Dtool_PyTypedObject Dtool_OdeHashSpace; extern Dtool_PyTypedObject Dtool_OdeCappedCylinderGeom; -//extern Dtool_PyTypedObject Dtool_OdeHeightfieldGeom; +// extern Dtool_PyTypedObject Dtool_OdeHeightfieldGeom; extern Dtool_PyTypedObject Dtool_OdePlaneGeom; extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; extern Dtool_PyTypedObject Dtool_OdeRayGeom; @@ -46,12 +45,10 @@ extern Dtool_PyTypedObject Dtool_OdeSphereGeom; extern Dtool_PyTypedObject Dtool_OdeTriMeshGeom; #endif -//////////////////////////////////////////////////////////////////// -// Function: OdeGeom::convert -// Access: Published -// Description: Do a sort of pseudo-downcast on this space in -// order to expose its specialized functions. -//////////////////////////////////////////////////////////////////// +/** + * Do a sort of pseudo-downcast on this space in order to expose its + * specialized functions. + */ PyObject *Extension:: convert() const { Dtool_PyTypedObject *class_type; @@ -83,20 +80,17 @@ convert() const { class_type = &Dtool_OdeRayGeom; break; - //case OdeGeom::GC_convex: - // geom = new OdeConvexGeom(_this->get_id()); - // class_type = &Dtool_OdeConvexGeom; - // break; + // case OdeGeom::GC_convex: geom = new OdeConvexGeom(_this->get_id()); + // class_type = &Dtool_OdeConvexGeom; break; case OdeGeom::GC_tri_mesh: geom = new OdeTriMeshGeom(_this->get_id()); class_type = &Dtool_OdeTriMeshGeom; break; - //case OdeGeom::GC_heightfield: - // geom = new OdeHeightfieldGeom(_this->get_id()); - // class_type = &Dtool_OdeHeightfieldGeom; - // break; + // case OdeGeom::GC_heightfield: geom = new + // OdeHeightfieldGeom(_this->get_id()); class_type = + // &Dtool_OdeHeightfieldGeom; break; case OdeGeom::GC_simple_space: geom = new OdeSimpleSpace((dSpaceID) _this->get_id()); @@ -114,8 +108,8 @@ convert() const { break; default: - // This shouldn't happen, but if it does, we - // should just return a regular OdeGeom or OdeSpace. + // This shouldn't happen, but if it does, we should just return a regular + // OdeGeom or OdeSpace. if (_this->is_space()) { geom = new OdeSpace((dSpaceID) _this->get_id()); class_type = &Dtool_OdeSpace; diff --git a/panda/src/ode/odeGeom_ext.h b/panda/src/ode/odeGeom_ext.h index 7a3d1120c2..a9d73ebf0b 100644 --- a/panda/src/ode/odeGeom_ext.h +++ b/panda/src/ode/odeGeom_ext.h @@ -1,16 +1,15 @@ -// Filename: odeGeom_ext.h -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeGeom_ext.h + * @author rdb + * @date 2013-12-11 + */ #ifndef ODEGEOM_EXT_H #define ODEGEOM_EXT_H @@ -24,12 +23,10 @@ #include "extension.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/ode/odeHashSpace.I b/panda/src/ode/odeHashSpace.I index d940f99bb2..558cce5d16 100644 --- a/panda/src/ode/odeHashSpace.I +++ b/panda/src/ode/odeHashSpace.I @@ -1,16 +1,15 @@ -// Filename: odeHashSpace.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHashSpace.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeHashSpace:: set_levels(int minlevel, int maxlevel) { diff --git a/panda/src/ode/odeHashSpace.cxx b/panda/src/ode/odeHashSpace.cxx index 67a732a1cf..af81c100a8 100644 --- a/panda/src/ode/odeHashSpace.cxx +++ b/panda/src/ode/odeHashSpace.cxx @@ -1,16 +1,15 @@ -// Filename: odeHashSpace.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHashSpace.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeHashSpace.h" @@ -35,4 +34,3 @@ OdeHashSpace(OdeSpace &space) : OdeHashSpace:: ~OdeHashSpace() { } - diff --git a/panda/src/ode/odeHashSpace.h b/panda/src/ode/odeHashSpace.h index e8cd4b17a0..a59a7cc4ff 100644 --- a/panda/src/ode/odeHashSpace.h +++ b/panda/src/ode/odeHashSpace.h @@ -1,16 +1,15 @@ -// Filename: odeHashSpace.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHashSpace.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEHASHSPACE_H #define ODEHASHSPACE_H @@ -23,10 +22,9 @@ #include "odeSpace.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeHashSpace -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeHashSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; @@ -64,4 +62,3 @@ private: #include "odeHashSpace.I" #endif - diff --git a/panda/src/ode/odeHeightFieldGeom.h b/panda/src/ode/odeHeightFieldGeom.h index d09d6e4b63..2093ebe55b 100644 --- a/panda/src/ode/odeHeightFieldGeom.h +++ b/panda/src/ode/odeHeightFieldGeom.h @@ -1,16 +1,15 @@ -// Filename: odeHeightFieldGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHeightFieldGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEHEIGHTFIELDGEOM_H #define ODEHEIGHTFIELDGEOM_H @@ -22,10 +21,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeHeightfieldGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeHeightfieldGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeHelperStructs.h b/panda/src/ode/odeHelperStructs.h index d0feaff616..2e425f0ffe 100644 --- a/panda/src/ode/odeHelperStructs.h +++ b/panda/src/ode/odeHelperStructs.h @@ -9,7 +9,7 @@ struct sSurfaceParams struct sBodyParams { -// int surfaceType; +// int surfaceType; dReal dampen; }; diff --git a/panda/src/ode/odeHinge2Joint.I b/panda/src/ode/odeHinge2Joint.I index 7b2c2cb956..28d08bd717 100644 --- a/panda/src/ode/odeHinge2Joint.I +++ b/panda/src/ode/odeHinge2Joint.I @@ -1,17 +1,15 @@ -// Filename: odeHinge2Joint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHinge2Joint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeHinge2Joint:: set_anchor(dReal x, dReal y, dReal z) { @@ -343,4 +341,3 @@ get_param_suspension_CFM(int axis) const { } return 0; } - diff --git a/panda/src/ode/odeHinge2Joint.cxx b/panda/src/ode/odeHinge2Joint.cxx index 0b7a16539c..157d642f2f 100644 --- a/panda/src/ode/odeHinge2Joint.cxx +++ b/panda/src/ode/odeHinge2Joint.cxx @@ -1,16 +1,15 @@ -// Filename: odeHinge2Joint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHinge2Joint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeHinge2Joint.h" @@ -18,17 +17,17 @@ TypeHandle OdeHinge2Joint::_type_handle; OdeHinge2Joint:: -OdeHinge2Joint(dJointID id) : +OdeHinge2Joint(dJointID id) : OdeJoint(id) { } OdeHinge2Joint:: -OdeHinge2Joint(OdeWorld &world) : +OdeHinge2Joint(OdeWorld &world) : OdeJoint(dJointCreateHinge2(world.get_id(), 0)) { } OdeHinge2Joint:: -OdeHinge2Joint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeHinge2Joint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateHinge2(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeHinge2Joint.h b/panda/src/ode/odeHinge2Joint.h index 2e6e5dd487..96606f9292 100644 --- a/panda/src/ode/odeHinge2Joint.h +++ b/panda/src/ode/odeHinge2Joint.h @@ -1,3 +1,16 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHinge2Joint.h + * @author joswilso + * @date 2006-12-27 + */ + #ifndef ODEHINGE2JOINT_H #define ODEHINGE2JOINT_H @@ -9,10 +22,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeHinge2Joint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeHinge2Joint : public OdeJoint { friend class OdeJoint; @@ -51,7 +63,7 @@ PUBLISHED: INLINE void set_param_stop_CFM(int axis, dReal val); INLINE void set_param_suspension_ERP(int axis, dReal val); INLINE void set_param_suspension_CFM(int axis, dReal val); - + INLINE dReal get_param_lo_stop(int axis) const; INLINE dReal get_param_hi_stop(int axis) const; INLINE dReal get_param_vel(int axis) const; diff --git a/panda/src/ode/odeHingeJoint.I b/panda/src/ode/odeHingeJoint.I index 85313d3823..aad47fd06d 100644 --- a/panda/src/ode/odeHingeJoint.I +++ b/panda/src/ode/odeHingeJoint.I @@ -1,16 +1,15 @@ -// Filename: odeHingeJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHingeJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeHingeJoint:: set_anchor(dReal x, dReal y, dReal z) { @@ -185,4 +184,3 @@ get_param_stop_CFM() const { nassertr( _id != 0, 0 ); return dJointGetHingeParam(_id, dParamStopCFM); } - diff --git a/panda/src/ode/odeHingeJoint.cxx b/panda/src/ode/odeHingeJoint.cxx index f87dd37ee8..352cf0ee32 100644 --- a/panda/src/ode/odeHingeJoint.cxx +++ b/panda/src/ode/odeHingeJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeHingeJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHingeJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeHingeJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeHingeJoint::_type_handle; OdeHingeJoint:: -OdeHingeJoint(dJointID id) : +OdeHingeJoint(dJointID id) : OdeJoint(id) { } OdeHingeJoint:: -OdeHingeJoint(OdeWorld &world) : +OdeHingeJoint(OdeWorld &world) : OdeJoint(dJointCreateHinge(world.get_id(), 0)) { } OdeHingeJoint:: -OdeHingeJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeHingeJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateHinge(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeHingeJoint.h b/panda/src/ode/odeHingeJoint.h index 0cc9fefadc..3c3c02b039 100644 --- a/panda/src/ode/odeHingeJoint.h +++ b/panda/src/ode/odeHingeJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeHingeJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODEHINGEJOINT_H #define ODEHINGEJOINT_H @@ -8,10 +22,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeHingeJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeHingeJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeJoint.I b/panda/src/ode/odeJoint.I index 93b30e8d06..a71fc8ac84 100644 --- a/panda/src/ode/odeJoint.I +++ b/panda/src/ode/odeJoint.I @@ -1,35 +1,29 @@ -// Filename: odeJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJoint.I + * @author joswilso + * @date 2006-12-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::is_empty -// Access: Published -// Description: Returns true if the ID is 0, meaning the OdeJoint -// does not point to a valid joint. It is an error to -// call a method on an empty joint. -// Note that an empty OdeJoint also evaluates to False. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ID is 0, meaning the OdeJoint does not point to a valid + * joint. It is an error to call a method on an empty joint. Note that an + * empty OdeJoint also evaluates to False. + */ INLINE bool OdeJoint:: is_empty() const { return (_id == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::get_id -// Access: Published -// Description: Returns the underlying dJointID. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying dJointID. + */ INLINE dJointID OdeJoint:: get_id() const { return _id; diff --git a/panda/src/ode/odeJoint.cxx b/panda/src/ode/odeJoint.cxx index 6d12fa3b13..cdaa12e95f 100644 --- a/panda/src/ode/odeJoint.cxx +++ b/panda/src/ode/odeJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeJoint.h" @@ -30,14 +29,14 @@ TypeHandle OdeJoint::_type_handle; OdeJoint:: -OdeJoint() : +OdeJoint() : _id(0) { ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; } OdeJoint:: -OdeJoint(dJointID id) : +OdeJoint(dJointID id) : _id(id) { ostream &out = odejoint_cat.debug(); out << get_type() << "(" << _id << ")\n"; @@ -53,14 +52,11 @@ destroy() { dJointDestroy(_id); } -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::attach_bodies -// Access: Published -// Description: Attaches two OdeBody objects to this joint. -// Order is important. -// Consider using the OdeJoint::attach extension -// function if you're using the Python interface. -//////////////////////////////////////////////////////////////////// +/** + * Attaches two OdeBody objects to this joint. Order is important. Consider + * using the OdeJoint::attach extension function if you're using the Python + * interface. + */ void OdeJoint:: attach_bodies(const OdeBody &body1, const OdeBody &body2) { nassertv(_id); @@ -68,15 +64,11 @@ attach_bodies(const OdeBody &body1, const OdeBody &body2) { dJointAttach(_id, body1.get_id(), body2.get_id()); } -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::attach_body -// Access: Published -// Description: Attaches a single OdeBody to this joint at the -// specified index (0 or 1). The other index will be -// set to the environment (null). -// Consider using the OdeJoint::attach extension -// function if you're using the Python interface. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a single OdeBody to this joint at the specified index (0 or 1). + * The other index will be set to the environment (null). Consider using the + * OdeJoint::attach extension function if you're using the Python interface. + */ void OdeJoint:: attach_body(const OdeBody &body, int index) { nassertv(_id); @@ -207,4 +199,3 @@ convert_to_plane2d() const { nassertr(get_joint_type() == JT_plane2d, OdePlane2dJoint(0)); return OdePlane2dJoint(_id); } - diff --git a/panda/src/ode/odeJoint.h b/panda/src/ode/odeJoint.h index 0eb44b61bf..ae9c23a2be 100644 --- a/panda/src/ode/odeJoint.h +++ b/panda/src/ode/odeJoint.h @@ -1,16 +1,15 @@ -// Filename: odeJoint.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJoint.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEJOINT_H #define ODEJOINT_H @@ -46,10 +45,9 @@ class OdeAMotorJoint; class OdeLMotorJoint; class OdePlane2dJoint; -//////////////////////////////////////////////////////////////////// -// Class : OdeJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeJoint : public TypedObject { friend class OdeBody; friend class OdeUtil; diff --git a/panda/src/ode/odeJointCollection.I b/panda/src/ode/odeJointCollection.I index 1150bbfd89..14c205fab5 100644 --- a/panda/src/ode/odeJointCollection.I +++ b/panda/src/ode/odeJointCollection.I @@ -1,43 +1,35 @@ -// Filename: odeJointCollection.I -// Created by: drose (10Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointCollection.I + * @author drose + * @date 2008-11-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OdeJointCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OdeJointCollection:: ~OdeJointCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: OdeJointCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void OdeJointCollection:: operator += (const OdeJointCollection &other) { add_joints_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: OdeJointCollection::operator + -// Access: Published -// Description: Returns a OdeJointCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a OdeJointCollection representing the concatenation of the two + * lists. + */ INLINE OdeJointCollection OdeJointCollection:: operator + (const OdeJointCollection &other) const { OdeJointCollection a(*this); diff --git a/panda/src/ode/odeJointCollection.cxx b/panda/src/ode/odeJointCollection.cxx index ba38456323..4ff1c3913c 100644 --- a/panda/src/ode/odeJointCollection.cxx +++ b/panda/src/ode/odeJointCollection.cxx @@ -1,16 +1,15 @@ -// Filename: odeJointCollection.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointCollection.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "odeJointCollection.h" @@ -32,8 +31,7 @@ void OdeJointCollection:: add_joint(const OdeJoint &joint) { // If the pointer to our internal array is shared by any other // OdeJointCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren OdeJointCollection - // objects. + // inadvertently modify any of our brethren OdeJointCollection objects. if (_joints.get_ref_count() > 1) { Joints old_joints = _joints; @@ -60,8 +58,7 @@ remove_joint(const OdeJoint &joint) { // If the pointer to our internal array is shared by any other // OdeJointCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren JointCollection - // objects. + // inadvertently modify any of our brethren JointCollection objects. if (_joints.get_ref_count() > 1) { Joints old_joints = _joints; @@ -151,12 +148,10 @@ operator [] (int index) const { return get_joint(index); } -//////////////////////////////////////////////////////////////////// -// Function: OdeJointCollection::size -// Access: Published -// Description: Returns the number of joints in the collection. This -// is the same thing as get_num_joints(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of joints in the collection. This is the same thing as + * get_num_joints(). + */ int OdeJointCollection:: size() const { return _joints.size(); diff --git a/panda/src/ode/odeJointCollection.h b/panda/src/ode/odeJointCollection.h index 3c39163384..0b1a1f3929 100644 --- a/panda/src/ode/odeJointCollection.h +++ b/panda/src/ode/odeJointCollection.h @@ -1,26 +1,24 @@ -// Filename: odeJointCollection.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointCollection.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEJOINTCOLLECTION_H #define ODEJOINTCOLLECTION_H #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeJointCollection -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeJointCollection { PUBLISHED: OdeJointCollection(); @@ -44,8 +42,8 @@ PUBLISHED: int size() const; INLINE void operator += (const OdeJointCollection &other); INLINE OdeJointCollection operator + (const OdeJointCollection &other) const; - -private: + +private: typedef PTA(OdeJoint) Joints; Joints _joints; }; diff --git a/panda/src/ode/odeJointGroup.I b/panda/src/ode/odeJointGroup.I index 3d8584fe4b..ff09a930d7 100644 --- a/panda/src/ode/odeJointGroup.I +++ b/panda/src/ode/odeJointGroup.I @@ -1,16 +1,15 @@ -// Filename: odeJointGroup.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointGroup.I + * @author joswilso + * @date 2006-12-27 + */ INLINE dJointGroupID OdeJointGroup:: get_id() const { diff --git a/panda/src/ode/odeJointGroup.cxx b/panda/src/ode/odeJointGroup.cxx index 3fc2965923..acf3562e50 100644 --- a/panda/src/ode/odeJointGroup.cxx +++ b/panda/src/ode/odeJointGroup.cxx @@ -1,16 +1,15 @@ -// Filename: odeJointGroup.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointGroup.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeJointGroup.h" diff --git a/panda/src/ode/odeJointGroup.h b/panda/src/ode/odeJointGroup.h index cd247bb611..7dd6abb9da 100644 --- a/panda/src/ode/odeJointGroup.h +++ b/panda/src/ode/odeJointGroup.h @@ -1,16 +1,15 @@ -// Filename: odeJointGroup.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJointGroup.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEJOINTGROUP_H #define ODEJOINTGROUP_H @@ -21,10 +20,9 @@ #include "ode_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeJointGroup -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeJointGroup : public TypedObject { PUBLISHED: OdeJointGroup(); @@ -61,4 +59,3 @@ private: #include "odeJointGroup.I" #endif - diff --git a/panda/src/ode/odeJoint_ext.cxx b/panda/src/ode/odeJoint_ext.cxx index 93253fec3e..6f284e1213 100644 --- a/panda/src/ode/odeJoint_ext.cxx +++ b/panda/src/ode/odeJoint_ext.cxx @@ -1,16 +1,15 @@ -// Filename: odeJoint_ext.cxx -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJoint_ext.cxx + * @author rdb + * @date 2013-12-11 + */ #include "odeJoint_ext.h" @@ -44,12 +43,10 @@ extern Dtool_PyTypedObject Dtool_OdeLMotorJoint; extern Dtool_PyTypedObject Dtool_OdePlane2dJoint; #endif -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::attach -// Access: Published -// Description: Attach two bodies together. If either body is None, -// the other will be attached to the environment. -//////////////////////////////////////////////////////////////////// +/** + * Attach two bodies together. If either body is None, the other will be + * attached to the environment. + */ void Extension:: attach(const OdeBody *body1, const OdeBody *body2) { if (body1 && body2) { @@ -63,12 +60,10 @@ attach(const OdeBody *body1, const OdeBody *body2) { } } -//////////////////////////////////////////////////////////////////// -// Function: OdeJoint::convert -// Access: Published -// Description: Do a sort of pseudo-downcast on this space in -// order to expose its specialized functions. -//////////////////////////////////////////////////////////////////// +/** + * Do a sort of pseudo-downcast on this space in order to expose its + * specialized functions. + */ PyObject *Extension:: convert() const { Dtool_PyTypedObject *class_type; @@ -131,8 +126,8 @@ convert() const { break; default: - // This shouldn't happen, but if it does, we - // should just return a regular OdeJoint. + // This shouldn't happen, but if it does, we should just return a regular + // OdeJoint. joint = new OdeJoint(_this->get_id()); class_type = &Dtool_OdeJoint; } diff --git a/panda/src/ode/odeJoint_ext.h b/panda/src/ode/odeJoint_ext.h index 48c5f20495..b61938506f 100644 --- a/panda/src/ode/odeJoint_ext.h +++ b/panda/src/ode/odeJoint_ext.h @@ -1,16 +1,15 @@ -// Filename: odeJoint_ext.h -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeJoint_ext.h + * @author rdb + * @date 2013-12-11 + */ #ifndef ODEJOINT_EXT_H #define ODEJOINT_EXT_H @@ -24,12 +23,10 @@ #include "extension.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/ode/odeLMotorJoint.I b/panda/src/ode/odeLMotorJoint.I index 7004f85cb5..b460c08c15 100644 --- a/panda/src/ode/odeLMotorJoint.I +++ b/panda/src/ode/odeLMotorJoint.I @@ -1,17 +1,15 @@ -// Filename: odeLMotorJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeLMotorJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeLMotorJoint:: set_num_axes(int num) { @@ -49,4 +47,3 @@ INLINE dReal OdeLMotorJoint:: get_param(int parameter) const { return dJointGetLMotorParam(_id, parameter); } - diff --git a/panda/src/ode/odeLMotorJoint.cxx b/panda/src/ode/odeLMotorJoint.cxx index 9905f1995b..6c8abd2ee2 100644 --- a/panda/src/ode/odeLMotorJoint.cxx +++ b/panda/src/ode/odeLMotorJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeLMotorJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeLMotorJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeLMotorJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeLMotorJoint::_type_handle; OdeLMotorJoint:: -OdeLMotorJoint(dJointID id) : +OdeLMotorJoint(dJointID id) : OdeJoint(id) { } OdeLMotorJoint:: -OdeLMotorJoint(OdeWorld &world ) : +OdeLMotorJoint(OdeWorld &world ) : OdeJoint(dJointCreateLMotor(world.get_id(), 0)) { } OdeLMotorJoint:: -OdeLMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeLMotorJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateLMotor(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeLMotorJoint.h b/panda/src/ode/odeLMotorJoint.h index 541afcd904..d79d20d34d 100644 --- a/panda/src/ode/odeLMotorJoint.h +++ b/panda/src/ode/odeLMotorJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeLMotorJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODELMOTORJOINT_H #define ODELMOTORJOINT_H @@ -8,10 +22,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeLMotorJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeLMotorJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeMass.I b/panda/src/ode/odeMass.I index 94d3a32118..1664cd6df6 100644 --- a/panda/src/ode/odeMass.I +++ b/panda/src/ode/odeMass.I @@ -1,16 +1,15 @@ -// Filename: odeMass.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeMass.I + * @author joswilso + * @date 2006-12-27 + */ INLINE int OdeMass:: check() { @@ -38,7 +37,7 @@ set_parameters(dReal themass, const LVecBase3f ¢er, const LMatrix3f &i) { set_parameters(themass, - center[0], center[1], center[2], + center[0], center[1], center[2], i(0, 0), i(1, 1), i(2, 2), i(0, 1), i(0, 2), i(1, 2)); } @@ -63,7 +62,7 @@ set_capsule(dReal density, int direction, INLINE void OdeMass:: set_capsule_total(dReal total_mass, int direction, dReal radius, dReal length) { - dMassSetCapsuleTotal(&_mass, + dMassSetCapsuleTotal(&_mass, total_mass, direction, radius, length); } @@ -71,7 +70,7 @@ set_capsule_total(dReal total_mass, int direction, INLINE void OdeMass:: set_cylinder(dReal density, int direction, dReal radius, dReal length) { - dMassSetCylinder(&_mass, + dMassSetCylinder(&_mass, density,direction, radius,length); } diff --git a/panda/src/ode/odeMass.cxx b/panda/src/ode/odeMass.cxx index 45cc9fc64e..de9d52567a 100644 --- a/panda/src/ode/odeMass.cxx +++ b/panda/src/ode/odeMass.cxx @@ -1,16 +1,15 @@ -// Filename: odeMass.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeMass.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeMass.h" @@ -18,15 +17,15 @@ TypeHandle OdeMass::_type_handle; OdeMass:: -OdeMass() : +OdeMass() : _mass() { dMassSetZero(&_mass); } OdeMass:: -OdeMass(const OdeMass ©) : +OdeMass(const OdeMass ©) : _mass() { - _mass.setParameters(copy._mass.mass, + _mass.setParameters(copy._mass.mass, copy._mass.c[0], copy._mass.c[1], copy._mass.c[2], copy._mass.I[0], copy._mass.I[5], copy._mass.I[10], copy._mass.I[1], copy._mass.I[2], copy._mass.I[4]); @@ -43,7 +42,7 @@ get_mass_ptr() { void OdeMass:: operator = (const OdeMass ©) { - _mass.setParameters(copy._mass.mass, + _mass.setParameters(copy._mass.mass, copy._mass.c[0], copy._mass.c[1], copy._mass.c[2], copy._mass.I[0], copy._mass.I[5], copy._mass.I[10], copy._mass.I[1], copy._mass.I[2], copy._mass.I[4]); @@ -53,7 +52,7 @@ operator = (const OdeMass ©) { void OdeMass:: write(ostream &out, unsigned int indent) const { - out.width(indent); + out.width(indent); out << get_type() \ << "(mag = " << get_magnitude() \ << ", center = " << get_center() \ diff --git a/panda/src/ode/odeMass.h b/panda/src/ode/odeMass.h index b941e3af8c..bd2ee5a167 100644 --- a/panda/src/ode/odeMass.h +++ b/panda/src/ode/odeMass.h @@ -1,16 +1,15 @@ -// Filename: odeMass.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeMass.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEMASS_H #define ODEMASS_H @@ -21,16 +20,15 @@ #include "ode_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeMass -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeMass : public TypedReferenceCount { PUBLISHED: OdeMass(); OdeMass(const OdeMass ©); virtual ~OdeMass(); - + INLINE int check(); INLINE void set_zero(); INLINE void set_parameters(dReal themass, diff --git a/panda/src/ode/odeNullJoint.I b/panda/src/ode/odeNullJoint.I index 300c4e4d52..615e969b3a 100644 --- a/panda/src/ode/odeNullJoint.I +++ b/panda/src/ode/odeNullJoint.I @@ -1,13 +1,12 @@ -// Filename: odeNullJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeNullJoint.I + * @author joswilso + * @date 2006-12-27 + */ diff --git a/panda/src/ode/odeNullJoint.cxx b/panda/src/ode/odeNullJoint.cxx index add29eb665..2cf348a6b2 100644 --- a/panda/src/ode/odeNullJoint.cxx +++ b/panda/src/ode/odeNullJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeNullJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeNullJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeNullJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeNullJoint::_type_handle; OdeNullJoint:: -OdeNullJoint(dJointID id) : +OdeNullJoint(dJointID id) : OdeJoint(id) { } OdeNullJoint:: -OdeNullJoint(OdeWorld &world) : +OdeNullJoint(OdeWorld &world) : OdeJoint(dJointCreateNull(world.get_id(), 0)) { } OdeNullJoint:: -OdeNullJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeNullJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateNull(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeNullJoint.h b/panda/src/ode/odeNullJoint.h index 61f3912866..1dbbf030c3 100644 --- a/panda/src/ode/odeNullJoint.h +++ b/panda/src/ode/odeNullJoint.h @@ -1,3 +1,18 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeNullJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + + #ifndef ODENULLJOINT_H #define ODENULLJOINT_H @@ -8,10 +23,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeNullJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeNullJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odePlane2dJoint.I b/panda/src/ode/odePlane2dJoint.I index c3b832056e..4f7e19788e 100644 --- a/panda/src/ode/odePlane2dJoint.I +++ b/panda/src/ode/odePlane2dJoint.I @@ -1,16 +1,15 @@ -// Filename: odePlane2dJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlane2dJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdePlane2dJoint:: set_x_param(int parameter, dReal value) { diff --git a/panda/src/ode/odePlane2dJoint.cxx b/panda/src/ode/odePlane2dJoint.cxx index e8e6e6f955..000f893ea6 100644 --- a/panda/src/ode/odePlane2dJoint.cxx +++ b/panda/src/ode/odePlane2dJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odePlane2dJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlane2dJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odePlane2dJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdePlane2dJoint::_type_handle; OdePlane2dJoint:: -OdePlane2dJoint(dJointID id) : +OdePlane2dJoint(dJointID id) : OdeJoint(id) { } OdePlane2dJoint:: -OdePlane2dJoint(OdeWorld &world) : +OdePlane2dJoint(OdeWorld &world) : OdeJoint(dJointCreatePlane2D(world.get_id(), 0)) { } OdePlane2dJoint:: -OdePlane2dJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdePlane2dJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreatePlane2D(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odePlane2dJoint.h b/panda/src/ode/odePlane2dJoint.h index cb9e7eb6de..a1b36588b3 100644 --- a/panda/src/ode/odePlane2dJoint.h +++ b/panda/src/ode/odePlane2dJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlane2dJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODEPLANE2DJOINT_H #define ODEPLANE2DJOINT_H @@ -8,10 +22,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdePlane2dJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdePlane2dJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odePlaneGeom.I b/panda/src/ode/odePlaneGeom.I index 4e167c5a58..1972904f67 100644 --- a/panda/src/ode/odePlaneGeom.I +++ b/panda/src/ode/odePlaneGeom.I @@ -1,16 +1,15 @@ -// Filename: odePlaneGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlaneGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdePlaneGeom:: set_params(dReal a, dReal b, dReal c, dReal d) { diff --git a/panda/src/ode/odePlaneGeom.cxx b/panda/src/ode/odePlaneGeom.cxx index 1873ab60cb..a23d4961bb 100644 --- a/panda/src/ode/odePlaneGeom.cxx +++ b/panda/src/ode/odePlaneGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odePlaneGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlaneGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odePlaneGeom.h" diff --git a/panda/src/ode/odePlaneGeom.h b/panda/src/ode/odePlaneGeom.h index 5131f55f78..9a3da02258 100644 --- a/panda/src/ode/odePlaneGeom.h +++ b/panda/src/ode/odePlaneGeom.h @@ -1,16 +1,15 @@ -// Filename: odePlaneGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odePlaneGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEPLANEGEOM_H #define ODEPLANEGEOM_H @@ -21,10 +20,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdePlaneGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdePlaneGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeQuadTreeSpace.I b/panda/src/ode/odeQuadTreeSpace.I index a0057fe434..d915d1ab6f 100644 --- a/panda/src/ode/odeQuadTreeSpace.I +++ b/panda/src/ode/odeQuadTreeSpace.I @@ -1,14 +1,12 @@ -// Filename: odeQuadTreeSpace.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeQuadTreeSpace.I + * @author joswilso + * @date 2006-12-27 + */ diff --git a/panda/src/ode/odeQuadTreeSpace.cxx b/panda/src/ode/odeQuadTreeSpace.cxx index 408bacce84..2ced39a003 100644 --- a/panda/src/ode/odeQuadTreeSpace.cxx +++ b/panda/src/ode/odeQuadTreeSpace.cxx @@ -1,16 +1,15 @@ -// Filename: odeQuadTreeSpace.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeQuadTreeSpace.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeQuadTreeSpace.h" @@ -59,4 +58,3 @@ OdeQuadTreeSpace(OdeSpace &space, OdeQuadTreeSpace:: ~OdeQuadTreeSpace() { } - diff --git a/panda/src/ode/odeQuadTreeSpace.h b/panda/src/ode/odeQuadTreeSpace.h index 70534122fd..d88e8a832b 100644 --- a/panda/src/ode/odeQuadTreeSpace.h +++ b/panda/src/ode/odeQuadTreeSpace.h @@ -1,16 +1,15 @@ -// Filename: odeQuadTreeSpace.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeQuadTreeSpace.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEQUADTREESPACE_H #define ODEQUADTREESPACE_H @@ -22,10 +21,9 @@ #include "odeSpace.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeQuadTreeSpace -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeQuadTreeSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; @@ -64,4 +62,3 @@ private: #include "odeQuadTreeSpace.I" #endif - diff --git a/panda/src/ode/odeRayGeom.I b/panda/src/ode/odeRayGeom.I index ef5ceb1760..94fdf2af15 100644 --- a/panda/src/ode/odeRayGeom.I +++ b/panda/src/ode/odeRayGeom.I @@ -1,17 +1,15 @@ -// Filename: odeRayGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeRayGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeRayGeom:: set_length(dReal length) { diff --git a/panda/src/ode/odeRayGeom.cxx b/panda/src/ode/odeRayGeom.cxx index 3531f7d3bc..10e727d76f 100644 --- a/panda/src/ode/odeRayGeom.cxx +++ b/panda/src/ode/odeRayGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeRayGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeRayGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeRayGeom.h" diff --git a/panda/src/ode/odeRayGeom.h b/panda/src/ode/odeRayGeom.h index d8c4f64d98..9f366320a7 100644 --- a/panda/src/ode/odeRayGeom.h +++ b/panda/src/ode/odeRayGeom.h @@ -1,16 +1,15 @@ -// Filename: odeRayGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeRayGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODERAYGEOM_H #define ODERAYGEOM_H @@ -21,10 +20,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeRayGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeRayGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeSimpleSpace.I b/panda/src/ode/odeSimpleSpace.I index 22f63d998e..e00b5783ba 100644 --- a/panda/src/ode/odeSimpleSpace.I +++ b/panda/src/ode/odeSimpleSpace.I @@ -1,13 +1,12 @@ -// Filename: odeSimpleSpace.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSimpleSpace.I + * @author joswilso + * @date 2006-12-27 + */ diff --git a/panda/src/ode/odeSimpleSpace.cxx b/panda/src/ode/odeSimpleSpace.cxx index 048bc6259e..a9e52d2015 100644 --- a/panda/src/ode/odeSimpleSpace.cxx +++ b/panda/src/ode/odeSimpleSpace.cxx @@ -1,16 +1,15 @@ -// Filename: odeSimpleSpace.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSimpleSpace.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeSimpleSpace.h" @@ -35,4 +34,3 @@ OdeSimpleSpace(OdeSpace &space) : OdeSimpleSpace:: ~OdeSimpleSpace() { } - diff --git a/panda/src/ode/odeSimpleSpace.h b/panda/src/ode/odeSimpleSpace.h index c40c5ae113..ebb7b46484 100644 --- a/panda/src/ode/odeSimpleSpace.h +++ b/panda/src/ode/odeSimpleSpace.h @@ -1,16 +1,15 @@ -// Filename: odeSimpleSpace.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSimpleSpace.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODESIMPLESPACE_H #define ODESIMPLESPACE_H @@ -22,10 +21,9 @@ #include "odeSpace.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeSimpleSpace -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeSimpleSpace : public OdeSpace { friend class OdeSpace; friend class OdeGeom; @@ -59,4 +57,3 @@ private: #include "odeSimpleSpace.I" #endif - diff --git a/panda/src/ode/odeSliderJoint.I b/panda/src/ode/odeSliderJoint.I index ae10a90760..ff7b722d3d 100644 --- a/panda/src/ode/odeSliderJoint.I +++ b/panda/src/ode/odeSliderJoint.I @@ -1,16 +1,15 @@ -// Filename: odeSliderJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSliderJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeSliderJoint:: set_axis(dReal x, dReal y, dReal z) { @@ -161,4 +160,3 @@ get_param_stop_CFM() const { nassertr( _id != 0, 0 ); return dJointGetSliderParam(_id, dParamStopCFM); } - diff --git a/panda/src/ode/odeSliderJoint.cxx b/panda/src/ode/odeSliderJoint.cxx index d2d1be52d6..2976cbe65e 100644 --- a/panda/src/ode/odeSliderJoint.cxx +++ b/panda/src/ode/odeSliderJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeSliderJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSliderJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeSliderJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeSliderJoint::_type_handle; OdeSliderJoint:: -OdeSliderJoint(dJointID id) : +OdeSliderJoint(dJointID id) : OdeJoint(id) { } OdeSliderJoint:: -OdeSliderJoint(OdeWorld &world) : +OdeSliderJoint(OdeWorld &world) : OdeJoint(dJointCreateSlider(world.get_id(), 0)) { } OdeSliderJoint:: -OdeSliderJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeSliderJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateSlider(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeSliderJoint.h b/panda/src/ode/odeSliderJoint.h index a4d8117525..981ec33a80 100644 --- a/panda/src/ode/odeSliderJoint.h +++ b/panda/src/ode/odeSliderJoint.h @@ -1,3 +1,17 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSliderJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + #ifndef ODESLIDERJOINT_H #define ODESLIDERJOINT_H @@ -8,10 +22,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeSliderJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeSliderJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeSpace.I b/panda/src/ode/odeSpace.I index a729798bb5..d4c60779d9 100644 --- a/panda/src/ode/odeSpace.I +++ b/panda/src/ode/odeSpace.I @@ -1,35 +1,29 @@ -// Filename: odeSpace.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace.I + * @author joswilso + * @date 2006-12-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::is_empty -// Access: Published -// Description: Returns true if the ID is 0, meaning the OdeSpace -// does not point to a valid space. It is an error to -// call a method on an empty space. -// Note that an empty OdeSpace also evaluates to False. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ID is 0, meaning the OdeSpace does not point to a valid + * space. It is an error to call a method on an empty space. Note that an + * empty OdeSpace also evaluates to False. + */ INLINE bool OdeSpace:: is_empty() const { return (_id == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::get_id -// Access: Published -// Description: Returns the underlying dSpaceID. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying dSpaceID. + */ INLINE dSpaceID OdeSpace:: get_id() const { return _id; @@ -117,4 +111,3 @@ INLINE string OdeSpace:: get_collision_event() { return _collision_event; } - diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index 1fd4d3fe25..6c4749f946 100644 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -1,16 +1,15 @@ -// Filename: odeSpace.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeSpace.h" @@ -24,13 +23,13 @@ TypeHandle OdeSpace::_type_handle; // this data is used in auto_collide -const int OdeSpace::MAX_CONTACTS = 16; -OdeWorld* OdeSpace::_static_auto_collide_world; -OdeSpace* OdeSpace::_static_auto_collide_space; -dJointGroupID OdeSpace::_static_auto_collide_joint_group; +const int OdeSpace::MAX_CONTACTS = 16; +OdeWorld* OdeSpace::_static_auto_collide_world; +OdeSpace* OdeSpace::_static_auto_collide_space; +dJointGroupID OdeSpace::_static_auto_collide_joint_group; OdeSpace:: -OdeSpace(dSpaceID id) : +OdeSpace(dSpaceID id) : _id(id) { _auto_collide_world = NULL; _auto_collide_joint_group = NULL; @@ -130,7 +129,8 @@ auto_collide() { void OdeSpace:: auto_callback(void *data, dGeomID o1, dGeomID o2) { -// uses data stored on the world to resolve collisions so you don't have to use near_callbacks in python +// uses data stored on the world to resolve collisions so you don't have to +// use near_callbacks in python int i; dBodyID b1 = dGeomGetBody(o1); dBodyID b2 = dGeomGetBody(o2); diff --git a/panda/src/ode/odeSpace.h b/panda/src/ode/odeSpace.h index 07b6c8f5d7..928defe8b6 100644 --- a/panda/src/ode/odeSpace.h +++ b/panda/src/ode/odeSpace.h @@ -1,16 +1,15 @@ -// Filename: odeSpace.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODESPACE_H #define ODESPACE_H @@ -20,7 +19,7 @@ #include "luse.h" #include "bitMask.h" -//included for collision tests +// included for collision tests #include "odeWorld.h" #include "odeJointGroup.h" @@ -32,10 +31,9 @@ class OdeSimpleSpace; class OdeHashSpace; class OdeQuadTreeSpace; -//////////////////////////////////////////////////////////////////// -// Class : OdeSpace -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeSpace : public TypedObject { friend class OdeGeom; static const int MAX_CONTACTS; @@ -73,7 +71,7 @@ PUBLISHED: void remove(OdeSpace& space); void clean(); OdeGeom get_geom(int i); // Not INLINE because of forward declaration - //static int get_surface_type(OdeSpace * self, dGeomID o1); + // static int get_surface_type(OdeSpace * self, dGeomID o1); INLINE OdeSpace get_space() const; diff --git a/panda/src/ode/odeSpace_ext.I b/panda/src/ode/odeSpace_ext.I index 8cbccc773e..0ae5ef36b0 100644 --- a/panda/src/ode/odeSpace_ext.I +++ b/panda/src/ode/odeSpace_ext.I @@ -1,25 +1,22 @@ -// Filename: odeSpace_ext.I -// Created by: rdb (11Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace_ext.I + * @author rdb + * @date 2013-12-11 + */ /* okcircular */ #include "odeGeom_ext.h" -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::get_AA_bounds -// Access: Published -// Description: A more Pythonic way of calling getAABB() -//////////////////////////////////////////////////////////////////// +/** + * A more Pythonic way of calling getAABB() + */ INLINE PyObject *Extension:: get_AA_bounds() const { LPoint3f *min_point = new LPoint3f; @@ -31,22 +28,18 @@ get_AA_bounds() const { return Py_BuildValue("NN", min_inst, max_inst); } -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::get_converted_geom -// Access: Published -// Description: Equivalent to get_geom(index).convert() -//////////////////////////////////////////////////////////////////// +/** + * Equivalent to get_geom(index).convert() + */ INLINE PyObject *Extension:: get_converted_geom(int index) const { OdeGeom g = _this->get_geom(index); return invoke_extension(&g).convert(); } -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::get_converted_space -// Access: Published -// Description: Equivalent to get_space().convert() -//////////////////////////////////////////////////////////////////// +/** + * Equivalent to get_space().convert() + */ INLINE PyObject *Extension:: get_converted_space() const { OdeSpace s = _this->get_space(); diff --git a/panda/src/ode/odeSpace_ext.cxx b/panda/src/ode/odeSpace_ext.cxx index 78c52a06bf..bed4a3e30b 100644 --- a/panda/src/ode/odeSpace_ext.cxx +++ b/panda/src/ode/odeSpace_ext.cxx @@ -1,16 +1,15 @@ -// Filename: odeSpace_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "odeSpace_ext.h" #include "config_ode.h" @@ -32,12 +31,10 @@ extern Dtool_PyTypedObject Dtool_OdeQuadTreeSpace; PyObject *Extension::_python_callback = NULL; -//////////////////////////////////////////////////////////////////// -// Function: OdeSpace::convert -// Access: Published -// Description: Do a sort of pseudo-downcast on this space in -// order to expose its specialized functions. -//////////////////////////////////////////////////////////////////// +/** + * Do a sort of pseudo-downcast on this space in order to expose its + * specialized functions. + */ PyObject *Extension:: convert() const { Dtool_PyTypedObject *class_type; @@ -60,8 +57,8 @@ convert() const { break; default: - // This shouldn't happen, but if it does, we - // should just return a regular OdeSpace. + // This shouldn't happen, but if it does, we should just return a regular + // OdeSpace. space = new OdeSpace(_this->get_id()); class_type = &Dtool_OdeSpace; } @@ -79,7 +76,8 @@ collide(PyObject* arg, PyObject* callback) { return -1; } else if (_this->get_id() == NULL) { - // Well, while we're in the mood of python exceptions, let's make this one too. + // Well, while we're in the mood of python exceptions, let's make this one + // too. PyErr_Format(PyExc_TypeError, "OdeSpace is not valid!"); return -1; diff --git a/panda/src/ode/odeSpace_ext.h b/panda/src/ode/odeSpace_ext.h index 4ad3be8bca..7500f2e9e5 100644 --- a/panda/src/ode/odeSpace_ext.h +++ b/panda/src/ode/odeSpace_ext.h @@ -1,16 +1,15 @@ -// Filename: odeSpace_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSpace_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef ODESPACE_EXT_H #define ODESPACE_EXT_H @@ -24,12 +23,10 @@ #include "extension.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/ode/odeSphereGeom.I b/panda/src/ode/odeSphereGeom.I index 3fd8c7a67c..8f6b5ec854 100644 --- a/panda/src/ode/odeSphereGeom.I +++ b/panda/src/ode/odeSphereGeom.I @@ -1,16 +1,15 @@ -// Filename: odeSphereGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSphereGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeSphereGeom:: set_radius(dReal radius) { @@ -31,4 +30,3 @@ INLINE dReal OdeSphereGeom:: get_point_depth(const LPoint3f &p) const { return get_point_depth(p[0], p[1], p[2]); } - diff --git a/panda/src/ode/odeSphereGeom.cxx b/panda/src/ode/odeSphereGeom.cxx index 2a6c20d4c2..96cb041495 100644 --- a/panda/src/ode/odeSphereGeom.cxx +++ b/panda/src/ode/odeSphereGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeSphereGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSphereGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeSphereGeom.h" diff --git a/panda/src/ode/odeSphereGeom.h b/panda/src/ode/odeSphereGeom.h index 2c7e3157b4..33ee3a8e3f 100644 --- a/panda/src/ode/odeSphereGeom.h +++ b/panda/src/ode/odeSphereGeom.h @@ -1,16 +1,15 @@ -// Filename: odeSphereGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSphereGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODESPHEREGEOM_H #define ODESPHEREGEOM_H @@ -21,10 +20,9 @@ #include "ode_includes.h" #include "odeGeom.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeSphereGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeSphereGeom : public OdeGeom { friend class OdeGeom; diff --git a/panda/src/ode/odeSurfaceParameters.I b/panda/src/ode/odeSurfaceParameters.I index fc1fd56d97..ac8a2d107e 100644 --- a/panda/src/ode/odeSurfaceParameters.I +++ b/panda/src/ode/odeSurfaceParameters.I @@ -1,16 +1,15 @@ -// Filename: odeSurfaceParameters.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSurfaceParameters.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeSurfaceParameters:: set_mode(int mode) { @@ -122,5 +121,3 @@ INLINE dReal OdeSurfaceParameters:: get_slip2() const { return _surface_parameters.slip2; } - - diff --git a/panda/src/ode/odeSurfaceParameters.cxx b/panda/src/ode/odeSurfaceParameters.cxx index 7533ead16d..febf53040e 100644 --- a/panda/src/ode/odeSurfaceParameters.cxx +++ b/panda/src/ode/odeSurfaceParameters.cxx @@ -1,16 +1,15 @@ -// Filename: odeSurfaceParameters.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSurfaceParameters.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeSurfaceParameters.h" @@ -18,7 +17,7 @@ TypeHandle OdeSurfaceParameters::_type_handle; OdeSurfaceParameters:: -OdeSurfaceParameters(int mode, dReal mu) : +OdeSurfaceParameters(int mode, dReal mu) : _surface_parameters() { if (mu < 0) { mu = 0; @@ -40,7 +39,7 @@ OdeSurfaceParameters(int mode, dReal mu) : } OdeSurfaceParameters:: -OdeSurfaceParameters(const dSurfaceParameters &surface_parameters) : +OdeSurfaceParameters(const dSurfaceParameters &surface_parameters) : _surface_parameters() { _surface_parameters.mode = surface_parameters.mode; _surface_parameters.mu = surface_parameters.mu; diff --git a/panda/src/ode/odeSurfaceParameters.h b/panda/src/ode/odeSurfaceParameters.h index 707dab2327..9d90469f31 100644 --- a/panda/src/ode/odeSurfaceParameters.h +++ b/panda/src/ode/odeSurfaceParameters.h @@ -1,16 +1,15 @@ -// Filename: odeSurfaceParameters.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeSurfaceParameters.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODESURFACEPARAMETERS_H #define ODESURFACEPARAMETERS_H @@ -23,10 +22,9 @@ class OdeContact; -//////////////////////////////////////////////////////////////////// -// Class : OdeSurfaceParameters -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeSurfaceParameters : public TypedObject { friend class OdeContact; @@ -48,7 +46,7 @@ PUBLISHED: MF_contactApprox1_1 = 0x1000, MF_contactApprox1_2 = 0x2000, MF_contactApprox1 = 0x3000 }; - + /* // Interrogate doesn't seem to handle this so well enum ModeFlags { MF_contact_mu2 = dContactMu2, diff --git a/panda/src/ode/odeTriMeshData.I b/panda/src/ode/odeTriMeshData.I index b2025814bd..e0cc754623 100644 --- a/panda/src/ode/odeTriMeshData.I +++ b/panda/src/ode/odeTriMeshData.I @@ -1,16 +1,15 @@ -// Filename: odeTriMeshData.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshData.I + * @author joswilso + * @date 2006-12-27 + */ INLINE OdeTriMeshData::TriMeshDataMap &OdeTriMeshData:: get_tri_mesh_data_map() { diff --git a/panda/src/ode/odeTriMeshData.cxx b/panda/src/ode/odeTriMeshData.cxx index 3badd9524f..c9debb3f2c 100644 --- a/panda/src/ode/odeTriMeshData.cxx +++ b/panda/src/ode/odeTriMeshData.cxx @@ -1,17 +1,16 @@ -// Filename: odeTriMeshData.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -#include "config_ode.h" +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshData.cxx + * @author joswilso + * @date 2006-12-27 + */ + #include "odeTriMeshData.h" TypeHandle OdeTriMeshData::_type_handle; @@ -126,8 +125,8 @@ OdeTriMeshData:: _faces = 0; } if (_normals != 0) { - // This is never allocated? Until we use _normals, assert that we - // don't accidentally free it here through some mistake. + // This is never allocated? Until we use _normals, assert that we don't + // accidentally free it here through some mistake. nassertv(false); PANDA_FREE_ARRAY(_normals); } @@ -210,7 +209,7 @@ process_primitive(const GeomPrimitive *primitive, GeomVertexReader vReader(vData, "vertex"); GeomVertexReader nReader(vData, "normal"); LVecBase3f vertex, normal; - //CPT(GeomPrimitive) dPrimitive = primitive->decompose(); + // CPT(GeomPrimitive) dPrimitive = primitive->decompose(); CPT(GeomPrimitive) dPrimitive = primitive; ostream &out = odetrimeshdata_cat.debug(); out.width(6); out << "" << "process_primitive(" << *dPrimitive << ")" << "\n"; @@ -226,7 +225,7 @@ process_primitive(const GeomPrimitive *primitive, vReader.set_row_unsafe(vRowIndex); nReader.set_row_unsafe(vRowIndex); vertex = vReader.get_data3f(); - //normal = nReader.get_data3f(); + // normal = nReader.get_data3f(); _faces[_num_faces].Indices[m] = _num_vertices; _vertices[_num_vertices].Vertex[0] = vertex[0]; @@ -247,7 +246,7 @@ process_primitive(const GeomPrimitive *primitive, vReader.set_row_unsafe(vRowIndex); nReader.set_row_unsafe(vRowIndex); vertex = vReader.get_data3f(); - //normal = nReader.get_data3f(); + // normal = nReader.get_data3f(); _vertices[_num_vertices].Vertex[0] = vertex[0]; _vertices[_num_vertices].Vertex[1] = vertex[1]; diff --git a/panda/src/ode/odeTriMeshData.h b/panda/src/ode/odeTriMeshData.h index 4b9e6e03eb..e8b46fad73 100644 --- a/panda/src/ode/odeTriMeshData.h +++ b/panda/src/ode/odeTriMeshData.h @@ -1,16 +1,15 @@ -// Filename: odeTriMeshData.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshData.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODETRIMESHDATA_H #define ODETRIMESHDATA_H @@ -30,10 +29,9 @@ #include "config_ode.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeTriMeshData -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeTriMeshData : public TypedReferenceCount { public: static void link_data(dGeomID id, PT(OdeTriMeshData) data); @@ -57,11 +55,9 @@ PUBLISHED: void destroy(); - // INLINE void set(int data_id, void* in_data); - // INLINE void* get(int data_id); - // INLINE void get_buffer(unsigned char** buf, int* buf_len) const; - // INLINE void set_buffer(unsigned char* buf); - // INLINE void update(); + // INLINE void set(int data_id, void* in_data); INLINE void* get(int + // data_id); INLINE void get_buffer(unsigned char** buf, int* buf_len) + // const; INLINE void set_buffer(unsigned char* buf); INLINE void update(); virtual void write(ostream &out = cout, unsigned int indent=0) const; void write_faces(ostream &out) const; @@ -78,11 +74,11 @@ public: const void* indices, int index_count, int tri_stride, \ const void* normals); - // Temporarily commenting these two out--ODE had an API change from - // (int *indices) to (dTriIndex *indices). But since there's no - // #define that indicates the ODE version, we don't have any way to - // automatically put the right symbol in here. However, we're not - // using these methods right now anyway. + // Temporarily commenting these two out--ODE had an API change from (int + // *indices) to (dTriIndex *indices). But since there's no #define that + // indicates the ODE version, we don't have any way to automatically put the + // right symbol in here. However, we're not using these methods right now + // anyway. /* INLINE void build_simple(const dReal* vertices, int vertex_count, \ diff --git a/panda/src/ode/odeTriMeshGeom.I b/panda/src/ode/odeTriMeshGeom.I index 9bd0ff6ac8..8bfd233bbf 100644 --- a/panda/src/ode/odeTriMeshGeom.I +++ b/panda/src/ode/odeTriMeshGeom.I @@ -1,16 +1,15 @@ -// Filename: odeTriMeshGeom.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshGeom.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeTriMeshGeom:: set_data(OdeTriMeshData &data) { @@ -62,7 +61,7 @@ get_triangle(int face_index, LPoint3f &v0, LPoint3f &v1, LPoint3f &v2) const { nassertv(_id != 0); dVector3 dv0, dv1, dv2; dGeomTriMeshGetTriangle(_id, face_index, &dv0, &dv1, &dv2); - + v0.set(dv0[0], dv0[1], dv0[2]); v1.set(dv1[0], dv1[1], dv1[2]); v2.set(dv2[0], dv2[1], dv2[2]); @@ -94,4 +93,3 @@ get_tri_mesh_data_id() const { nassertr(_id != 0, 0); return dGeomTriMeshGetTriMeshDataID(_id); } - diff --git a/panda/src/ode/odeTriMeshGeom.cxx b/panda/src/ode/odeTriMeshGeom.cxx index 0326a5be91..f3e596d72b 100644 --- a/panda/src/ode/odeTriMeshGeom.cxx +++ b/panda/src/ode/odeTriMeshGeom.cxx @@ -1,16 +1,15 @@ -// Filename: odeTriMeshGeom.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshGeom.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeTriMeshGeom.h" diff --git a/panda/src/ode/odeTriMeshGeom.h b/panda/src/ode/odeTriMeshGeom.h index ad1dfe665a..025e7e98fd 100644 --- a/panda/src/ode/odeTriMeshGeom.h +++ b/panda/src/ode/odeTriMeshGeom.h @@ -1,16 +1,15 @@ -// Filename: odeTriMeshGeom.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeTriMeshGeom.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODETRIMESHGEOM_H #define ODETRIMESHGEOM_H @@ -22,10 +21,9 @@ #include "odeGeom.h" #include "odeTriMeshData.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeTriMeshGeom -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeTriMeshGeom : public OdeGeom { friend class OdeGeom; @@ -38,7 +36,7 @@ PUBLISHED: OdeTriMeshGeom(OdeSpace &space, OdeTriMeshData &data); OdeTriMeshGeom(const OdeTriMeshGeom ©); virtual ~OdeTriMeshGeom(); - + void destroy(); INLINE void set_tri_mesh_data(OdeTriMeshData &data); INLINE PT(OdeTriMeshData) get_tri_mesh_data() const; diff --git a/panda/src/ode/odeUniversalJoint.I b/panda/src/ode/odeUniversalJoint.I index 33d8f6722b..a644a2c2c6 100644 --- a/panda/src/ode/odeUniversalJoint.I +++ b/panda/src/ode/odeUniversalJoint.I @@ -1,16 +1,15 @@ -// Filename: odeUniversalJoint.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUniversalJoint.I + * @author joswilso + * @date 2006-12-27 + */ INLINE void OdeUniversalJoint:: set_anchor(dReal x, dReal y, dReal z) { @@ -302,4 +301,3 @@ get_param_stop_CFM(int axis) const { } return 0; } - diff --git a/panda/src/ode/odeUniversalJoint.cxx b/panda/src/ode/odeUniversalJoint.cxx index a745a265d2..4e9780bf92 100644 --- a/panda/src/ode/odeUniversalJoint.cxx +++ b/panda/src/ode/odeUniversalJoint.cxx @@ -1,16 +1,15 @@ -// Filename: odeUniversalJoint.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUniversalJoint.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeUniversalJoint.h" @@ -18,17 +17,17 @@ TypeHandle OdeUniversalJoint::_type_handle; OdeUniversalJoint:: -OdeUniversalJoint(dJointID id) : +OdeUniversalJoint(dJointID id) : OdeJoint(id) { } OdeUniversalJoint:: -OdeUniversalJoint(OdeWorld &world) : +OdeUniversalJoint(OdeWorld &world) : OdeJoint(dJointCreateUniversal(world.get_id(), 0)) { } OdeUniversalJoint:: -OdeUniversalJoint(OdeWorld &world, OdeJointGroup &joint_group) : +OdeUniversalJoint(OdeWorld &world, OdeJointGroup &joint_group) : OdeJoint(dJointCreateUniversal(world.get_id(), joint_group.get_id())) { } diff --git a/panda/src/ode/odeUniversalJoint.h b/panda/src/ode/odeUniversalJoint.h index d4e3e4c185..00d2cd6c2a 100644 --- a/panda/src/ode/odeUniversalJoint.h +++ b/panda/src/ode/odeUniversalJoint.h @@ -1,3 +1,18 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUniversalJoint.h + * @author joswilso + * @date 2006-12-27 + */ + + + #ifndef ODEUNIVERSALJOINT_H #define ODEUNIVERSALJOINT_H @@ -9,10 +24,9 @@ #include "odeJoint.h" -//////////////////////////////////////////////////////////////////// -// Class : OdeUniversalJoint -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeUniversalJoint : public OdeJoint { friend class OdeJoint; diff --git a/panda/src/ode/odeUtil.cxx b/panda/src/ode/odeUtil.cxx index 4bb6471881..0e38b45558 100644 --- a/panda/src/ode/odeUtil.cxx +++ b/panda/src/ode/odeUtil.cxx @@ -1,37 +1,31 @@ -// Filename: odeUtil.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUtil.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "odeUtil.h" dReal OdeUtil::OC_infinity = dInfinity; -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::get_connecting_joint -// Access: Public, Static -// Description: Returns the joint that connects the given bodies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the joint that connects the given bodies. + */ OdeJoint OdeUtil:: get_connecting_joint(const OdeBody &body1, const OdeBody &body2) { return OdeJoint(dConnectingJoint(body1.get_id(),body2.get_id())); } -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::get_connecting_joint_list -// Access: Public, Static -// Description: Returns a collection of joints connecting the -// specified bodies. -//////////////////////////////////////////////////////////////////// +/** + * Returns a collection of joints connecting the specified bodies. + */ OdeJointCollection OdeUtil:: get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { const int max_possible_joints = min(body1.get_num_joints(), body1.get_num_joints()); @@ -48,29 +42,23 @@ get_connecting_joint_list(const OdeBody &body1, const OdeBody &body2) { return joints; } -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::are_connected -// Access: Public, Static -// Description: Returns 1 if the given bodies are connected -// by a joint, returns 0 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns 1 if the given bodies are connected by a joint, returns 0 + * otherwise. + */ int OdeUtil:: are_connected(const OdeBody &body1, const OdeBody &body2) { return dAreConnected(body1.get_id(),body2.get_id()); } -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::are_connected_excluding -// Access: Public, Static -// Description: Returns 1 if the given bodies are connected -// by a joint that does not match the given -// joint_type, returns 0 otherwise. This is useful -// for deciding whether to add contact joints between -// two bodies: if they are already connected by -// non-contact joints then it may not be appropriate -// to add contacts, however it is okay to add more -// contact between bodies that already have contacts. -//////////////////////////////////////////////////////////////////// +/** + * Returns 1 if the given bodies are connected by a joint that does not match + * the given joint_type, returns 0 otherwise. This is useful for deciding + * whether to add contact joints between two bodies: if they are already + * connected by non-contact joints then it may not be appropriate to add + * contacts, however it is okay to add more contact between bodies that + * already have contacts. + */ int OdeUtil:: are_connected_excluding(const OdeBody &body1, const OdeBody &body2, @@ -80,13 +68,10 @@ are_connected_excluding(const OdeBody &body1, joint_type); } -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::collide -// Access: Public, Static -// Description: Given two geometry objects that potentially touch -// (geom1 and geom2), generate contact information -// for them. Returns an OdeCollisionEntry. -//////////////////////////////////////////////////////////////////// +/** + * Given two geometry objects that potentially touch (geom1 and geom2), + * generate contact information for them. Returns an OdeCollisionEntry. + */ PT(OdeCollisionEntry) OdeUtil:: collide(const OdeGeom &geom1, const OdeGeom &geom2, const short int max_contacts) { dContactGeom *contact_list = (dContactGeom *)PANDA_MALLOC_ARRAY(max_contacts * sizeof(dContactGeom)); diff --git a/panda/src/ode/odeUtil.h b/panda/src/ode/odeUtil.h index d24844ac89..24c4d8f1b2 100644 --- a/panda/src/ode/odeUtil.h +++ b/panda/src/ode/odeUtil.h @@ -1,16 +1,15 @@ -// Filename: odeUtil.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUtil.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEUTIL_H #define ODEUTIL_H @@ -27,10 +26,9 @@ class OdeBody; class OdeJoint; class OdeGeom; -//////////////////////////////////////////////////////////////////// -// Class : OdeUtil -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeUtil { PUBLISHED: static OdeJoint get_connecting_joint(const OdeBody &body1, diff --git a/panda/src/ode/odeUtil_ext.cxx b/panda/src/ode/odeUtil_ext.cxx index e2910881bf..862e215eae 100644 --- a/panda/src/ode/odeUtil_ext.cxx +++ b/panda/src/ode/odeUtil_ext.cxx @@ -1,16 +1,15 @@ -// Filename: odeUtil_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUtil_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "odeUtil_ext.h" #include "config_ode.h" @@ -21,13 +20,10 @@ PyObject *Extension::_python_callback = NULL; -//////////////////////////////////////////////////////////////////// -// Function: OdeUtil::collide2 -// Access: Public, Static -// Description: Calls the callback for all potentially intersecting -// pairs that contain one geom from geom1 and one geom -// from geom2. -//////////////////////////////////////////////////////////////////// +/** + * Calls the callback for all potentially intersecting pairs that contain one + * geom from geom1 and one geom from geom2. + */ int Extension:: collide2(const OdeGeom &geom1, const OdeGeom &geom2, PyObject* arg, PyObject* callback) { nassertr(callback != NULL, -1); diff --git a/panda/src/ode/odeUtil_ext.h b/panda/src/ode/odeUtil_ext.h index ce78b6d098..5924666669 100644 --- a/panda/src/ode/odeUtil_ext.h +++ b/panda/src/ode/odeUtil_ext.h @@ -1,16 +1,15 @@ -// Filename: odeUtil_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeUtil_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef ODEUTIL_EXT_H #define ODEUTIL_EXT_H @@ -24,12 +23,10 @@ #include "extension.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/ode/odeWorld.I b/panda/src/ode/odeWorld.I index 930c70bcfe..dd10c59c2d 100644 --- a/panda/src/ode/odeWorld.I +++ b/panda/src/ode/odeWorld.I @@ -1,35 +1,29 @@ -// Filename: odeWorld.I -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeWorld.I + * @author joswilso + * @date 2006-12-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: OdeWorld::is_empty -// Access: Published -// Description: Returns true if the ID is 0, meaning the OdeWorld -// does not point to a valid world. It is an error to -// call a method on an empty world. -// Note that an empty OdeWorld also evaluates to False. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ID is 0, meaning the OdeWorld does not point to a valid + * world. It is an error to call a method on an empty world. Note that an + * empty OdeWorld also evaluates to False. + */ INLINE bool OdeWorld:: is_empty() const { return (_id == 0); } -//////////////////////////////////////////////////////////////////// -// Function: OdeWorld::get_id -// Access: Published -// Description: Returns the underlying dWorldID. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying dWorldID. + */ INLINE dWorldID OdeWorld:: get_id() const { return _id; diff --git a/panda/src/ode/odeWorld.cxx b/panda/src/ode/odeWorld.cxx index b7d76fd5b7..5e3986b6f5 100644 --- a/panda/src/ode/odeWorld.cxx +++ b/panda/src/ode/odeWorld.cxx @@ -1,16 +1,15 @@ -// Filename: odeWorld.cxx -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeWorld.cxx + * @author joswilso + * @date 2006-12-27 + */ #include "config_ode.h" #include "odeWorld.h" @@ -19,7 +18,7 @@ TypeHandle OdeWorld::_type_handle; OdeWorld:: -OdeWorld() : +OdeWorld() : _id(dWorldCreate()) { odeworld_cat.debug() << get_type() << "(" << _id << ")" << "\n"; _num_surfaces = 0; @@ -48,15 +47,16 @@ destroy() { } /* -void OdeWorld:: +void OdeWorld:: assign_surface_body(OdeBody& body, int surface) { - // odeworld_cat.debug() << "assign_surface_body body.Id =" << body.get_id() << " surface=" << surface << "\n"; + // odeworld_cat.debug() << "assign_surface_body body.Id =" << body.get_id() + // << " surface=" << surface << "\n"; _body_dampen_map[body.get_id()].surfaceType = surface; _body_dampen_map[body.get_id()].dampen = 0.0f; } */ -void OdeWorld:: +void OdeWorld:: add_body_dampening(OdeBody& body, int surface) { _body_dampen_map[body.get_id()].dampen = 0.0f; } @@ -65,7 +65,7 @@ add_body_dampening(OdeBody& body, int surface) { void OdeWorld:: init_surface_table(PN_uint8 num_surfaces) { _surface_table = new sSurfaceParams[num_surfaces * num_surfaces]; - //_dampen_table = new sSurfaceParams[num_surfaces * num_surfaces]; + // _dampen_table = new sSurfaceParams[num_surfaces * num_surfaces]; _num_surfaces = num_surfaces; } @@ -101,21 +101,22 @@ get_surface(PN_uint8 surface1, PN_uint8 surface2) { } if((_num_surfaces <= surface1) || (_num_surfaces <= surface2)) { odeworld_cat.error() << "surface position exceeds size of surface table, set num_surface in initSurfaceTable higher." << "\n"; - //nassertr_always((_num_surfaces > surface1 && _num_surfaces > surface2), _surface_table[true_pos]); + // nassertr_always((_num_surfaces > surface1 && _num_surfaces > surface2), + // _surface_table[true_pos]); } return _surface_table[true_pos]; } -void OdeWorld:: -set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, +void OdeWorld:: +set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, dReal mu, - dReal bounce, - dReal bounce_vel, - dReal soft_erp, + dReal bounce, + dReal bounce_vel, + dReal soft_erp, dReal soft_cfm, dReal slip, dReal dampen) { - //todo: add mode + // todo: add mode sSurfaceParams new_params; int someMode = 0; if (bounce > 0.0001) { @@ -142,9 +143,9 @@ set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, new_params.colparams.motion1 = 0.0; new_params.colparams.motion2 = 0.0; new_params.dampen = dampen; - //todo: a bit of wasted space here + // todo: a bit of wasted space here set_surface(pos1, pos2, new_params); - + if(pos1 >= pos2) { set_surface(pos1, pos2, new_params); } else { @@ -164,7 +165,7 @@ set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp) { } } -float OdeWorld:: +float OdeWorld:: apply_dampening(float dt, OdeBody& body) { dBodyID bodyId = body.get_id(); dReal damp = _body_dampen_map[bodyId].dampen; diff --git a/panda/src/ode/odeWorld.h b/panda/src/ode/odeWorld.h index 8d7f365cf4..4238700af9 100644 --- a/panda/src/ode/odeWorld.h +++ b/panda/src/ode/odeWorld.h @@ -1,16 +1,15 @@ -// Filename: odeWorld.h -// Created by: joswilso (27Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file odeWorld.h + * @author joswilso + * @date 2006-12-27 + */ #ifndef ODEWORLD_H #define ODEWORLD_H @@ -28,10 +27,9 @@ class OdeBody; class OdeJoint; -//////////////////////////////////////////////////////////////////// -// Class : OdeWorld -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAODE OdeWorld : public TypedObject { PUBLISHED: OdeWorld(); @@ -80,27 +78,27 @@ PUBLISHED: INLINE int compare_to(const OdeWorld &other) const; void init_surface_table(PN_uint8 num_surfaces); - //void assign_surface_body(OdeBody& body, int surface); + // void assign_surface_body(OdeBody& body, int surface); void add_body_dampening(OdeBody& body, int surface); - void set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, - dReal mu, - dReal bounce, - dReal bounce_vel, + void set_surface_entry(PN_uint8 pos1, PN_uint8 pos2, + dReal mu, + dReal bounce, + dReal bounce_vel, dReal soft_erp, dReal soft_cfm, dReal slip, dReal dampen); float apply_dampening(float dt, OdeBody& body); - + operator bool () const; - + public: sSurfaceParams& get_surface(PN_uint8 surface1, PN_uint8 surface2); void set_surface(int pos1, int pos2, sSurfaceParams& entry); sBodyParams get_surface_body(dBodyID id); void set_dampen_on_bodies(dBodyID id1, dBodyID id2,dReal damp); - + private: dWorldID _id; sSurfaceParams *_surface_table; diff --git a/panda/src/ode/ode_includes.h b/panda/src/ode/ode_includes.h index 53616729c9..3d3ec15132 100644 --- a/panda/src/ode/ode_includes.h +++ b/panda/src/ode/ode_includes.h @@ -1,22 +1,21 @@ -// Filename: ode_includes.h -// Created by: joswilso (30Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ode_includes.h + * @author joswilso + * @date 2007-01-30 + */ #ifndef _ODE_INCLUDES_H_ #define _ODE_INCLUDES_H_ #include "pandabase.h" - + #ifdef int8 #define temp_ode_int8 int8 #undef int8 @@ -38,8 +37,8 @@ #include "ode/ode.h" -// These are the ones that conflict with other defines in Panda. -// It may be necessary to add to this list at a later time. +// These are the ones that conflict with other defines in Panda. It may be +// necessary to add to this list at a later time. #undef int8 #undef int32 #undef uint32 diff --git a/panda/src/osxdisplay/config_osxdisplay.cxx b/panda/src/osxdisplay/config_osxdisplay.cxx index 60c5c7e93e..943fe57937 100644 --- a/panda/src/osxdisplay/config_osxdisplay.cxx +++ b/panda/src/osxdisplay/config_osxdisplay.cxx @@ -1,16 +1,13 @@ -// Filename: config_osxdisplay.cxx -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -#include +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_osxdisplay.cxx + */ #include "config_osxdisplay.h" #include "osxGraphicsBuffer.h" @@ -59,14 +56,12 @@ ConfigVariableInt osx_mouse_wheel_scale PRC_DESC("Specify the number of units to spin the Mac mouse wheel to " "represent a single wheel_up or wheel_down message.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libosxdisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libosxdisplay() { static bool initialized = false; diff --git a/panda/src/osxdisplay/config_osxdisplay.h b/panda/src/osxdisplay/config_osxdisplay.h index 552117cf32..cedaff1e3e 100644 --- a/panda/src/osxdisplay/config_osxdisplay.h +++ b/panda/src/osxdisplay/config_osxdisplay.h @@ -1,15 +1,13 @@ -// Filename: config_osxdisplay.h -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_osxdisplay.h + */ #ifndef __CONFIG_OSXDISPLAY_H__ #define __CONFIG_OSXDISPLAY_H__ diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index fffc18b7dd..7b1beb26f8 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -1,15 +1,13 @@ -// Filename: osxGraphicsBuffer.cxx -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsBuffer.cxx + */ #include "osxGraphicsBuffer.h" #include "osxGraphicsStateGuardian.h" @@ -22,11 +20,9 @@ TypeHandle osxGraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsBuffer:: osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -42,30 +38,25 @@ osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, _pbuffer = NULL; - // Since the pbuffer never gets flipped, we get screenshots from the - // same buffer we draw into. + // Since the pbuffer never gets flipped, we get screenshots from the same + // buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsBuffer:: ~osxGraphicsBuffer() { nassertv(_pbuffer == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool osxGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); @@ -107,13 +98,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void osxGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -131,16 +120,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void osxGraphicsBuffer:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { - // aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0); + // aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0); _gsg.clear(); } if (_pbuffer != NULL) { @@ -150,13 +136,10 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the buffer right now. Called from the window -// thread. Returns true if the buffer is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the buffer right now. Called from the window thread. Returns true + * if the buffer is successfully opened, or false if there was a problem. + */ bool osxGraphicsBuffer:: open_buffer() { if (_gsg == 0) { @@ -167,9 +150,8 @@ open_buffer() { GLenum target = GL_TEXTURE_RECTANGLE_ARB; if (_size[0] == Texture::up_to_power_2(_size[0]) && _size[1] == Texture::up_to_power_2(_size[1])) { - // It's a power-of-two size, so we can use GL_TEXTURE_2D as the - // target. Dunno, but maybe this will be more likely to work on - // some hardware. + // It's a power-of-two size, so we can use GL_TEXTURE_2D as the target. + // Dunno, but maybe this will be more likely to work on some hardware. target = GL_TEXTURE_2D; } if (!aglCreatePBuffer(_size.get_x(), _size.get_y(), target, GL_RGBA, 0, &_pbuffer)) { @@ -216,4 +198,3 @@ open_buffer() { _is_valid = true; return true; } - diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.h b/panda/src/osxdisplay/osxGraphicsBuffer.h index f807c1a70f..a2ff19f76a 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.h +++ b/panda/src/osxdisplay/osxGraphicsBuffer.h @@ -1,15 +1,13 @@ -// Filename: osxGraphicsBuffer.h -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsBuffer.h + */ #ifndef OSXGRAPHICSBUFFER_H #define OSXGRAPHICSBUFFER_H @@ -23,11 +21,9 @@ #include "graphicsBuffer.h" #include "glgsg.h" -//////////////////////////////////////////////////////////////////// -// Class : osxGraphicsBuffer -// Description : An offscreen buffer in the OSX environment. This -// creates an AGLPbuffer. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen buffer in the OSX environment. This creates an AGLPbuffer. + */ class osxGraphicsBuffer : public GraphicsBuffer { public: osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 54ec803b8e..721f54b585 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -1,15 +1,13 @@ -// Filename: osxGraphicsPipe.cxx -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsPipe.cxx + */ #include "osxGraphicsPipe.h" #include "config_osxdisplay.h" @@ -106,10 +104,9 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { // look at each mode in the available list CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, i); - // we are only interested in modes with the same bits per pixel as current. - // to allow for switching from fullscreen to windowed modes. - // that are safe for this hardward - // that are not stretched. + // we are only interested in modes with the same bits per pixel as + // current. to allow for switching from fullscreen to windowed modes. + // that are safe for this hardward that are not stretched. long bitsPerPixel = GetModeBitsPerPixel(mode); Boolean safeForHardware = GetModeSafeForHardware(mode); Boolean stretched = GetModeStretched(mode); @@ -124,8 +121,8 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { Boolean replaced = false; Boolean skipped = false; - // now check to see if we already added a mode like this one. - // we want the highest refresh rate for this width/height + // now check to see if we already added a mode like this one. we want the + // highest refresh rate for this widthheight unsigned int j; unsigned int currentNumberOfUsefulModes = CFArrayGetCount(usefulModes); for (j = 0; j < currentNumberOfUsefulModes; ++j) { @@ -162,11 +159,9 @@ CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) { TypeHandle osxGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsPipe:: osxGraphicsPipe() { CGRect display_bounds = CGDisplayBounds(kCGDirectMainDisplay); @@ -194,62 +189,47 @@ osxGraphicsPipe() { _display_information -> _display_mode_array = displays; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsPipe:: ~osxGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string osxGraphicsPipe:: get_interface_name() const { return "OpenGL"; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// osxGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default osxGraphicsPipe. + */ PT(GraphicsPipe) osxGraphicsPipe:: pipe_constructor() { return new osxGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ GraphicsPipe::PreferredWindowThread osxGraphicsPipe::get_preferred_window_thread() const { return PWT_app; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::create_cg_image -// Access: Public, Static -// Description: Creates a new Quartz bitmap image with the data in -// the indicated PNMImage. The caller should eventually -// free this image via CGImageRelease. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Quartz bitmap image with the data in the indicated PNMImage. + * The caller should eventually free this image via CGImageRelease. + */ CGImageRef osxGraphicsPipe:: create_cg_image(const PNMImage &pnm_image) { size_t width = pnm_image.get_x_size(); @@ -314,8 +294,7 @@ create_cg_image(const PNMImage &pnm_image) { bitmap_info |= kCGImageAlphaLast; } - // Now convert the pixel data to a format friendly to - // CGImageCreate(). + // Now convert the pixel data to a format friendly to CGImageCreate(). char *char_array = (char *)PANDA_MALLOC_ARRAY(num_bytes); xelval *dp = (xelval *)char_array; @@ -351,23 +330,19 @@ create_cg_image(const PNMImage &pnm_image) { return image; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::release_data -// Access: Private, Static -// Description: This callback is assigned to delete the data array -// allocated within create_cg_image(). -//////////////////////////////////////////////////////////////////// +/** + * This callback is assigned to delete the data array allocated within + * create_cg_image(). + */ void osxGraphicsPipe:: release_data(void *info, const void *data, size_t size) { char *char_array = (char *)data; PANDA_FREE_ARRAY(char_array); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) osxGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -423,8 +398,8 @@ make_output(const string &name, (flags & (BF_require_parasite | BF_require_window)) != 0) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || @@ -437,8 +412,8 @@ make_output(const string &name, osxgsg->_glDrawBuffers == NULL) { return NULL; } else if (fb_prop.is_basic()) { - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we + // can precertify it. precertify = true; } } @@ -464,15 +439,12 @@ make_output(const string &name, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::make_callback_gsg -// Access: Protected, Virtual -// Description: This is called when make_output() is used to create a -// CallbackGraphicsWindow. If the GraphicsPipe can -// construct a GSG that's not associated with any -// particular window object, do so now, assuming the -// correct graphics context has been set up externally. -//////////////////////////////////////////////////////////////////// +/** + * This is called when make_output() is used to create a + * CallbackGraphicsWindow. If the GraphicsPipe can construct a GSG that's not + * associated with any particular window object, do so now, assuming the + * correct graphics context has been set up externally. + */ PT(GraphicsStateGuardian) osxGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { return new osxGraphicsStateGuardian(engine, this, NULL); diff --git a/panda/src/osxdisplay/osxGraphicsPipe.h b/panda/src/osxdisplay/osxGraphicsPipe.h index 236241d70e..018d1bb0b7 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.h +++ b/panda/src/osxdisplay/osxGraphicsPipe.h @@ -1,15 +1,13 @@ -// Filename: osxGraphicsPipe.h -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsPipe.h + */ #ifndef OSXGRAPHICSPIPE_H #define OSXGRAPHICSPIPE_H @@ -22,12 +20,10 @@ class osxGraphicsStateGuardian; class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : osxGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on the various -// OSX's. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL graphics + * windows on the various OSX's. + */ class EXPCL_PANDAGL osxGraphicsPipe : public GraphicsPipe { public: osxGraphicsPipe(); diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx index e15e44419a..8099eb5547 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.cxx @@ -1,15 +1,13 @@ -// Filename: osxGraphicsStateGuardian.cxx -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsStateGuardian.cxx + */ #include "osxGraphicsStateGuardian.h" #include "osxGraphicsBuffer.h" @@ -23,22 +21,18 @@ #include #import -// This is generated data for the standard texture we use for drawing -// the resize box in the window corner. +// This is generated data for the standard texture we use for drawing the +// resize box in the window corner. #include "resize_box.rgb.c" TypeHandle osxGraphicsStateGuardian::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *osxGraphicsStateGuardian:: do_get_extension_func(const char *name) { string fullname = "_" + string(name); @@ -51,11 +45,9 @@ do_get_extension_func(const char *name) { return symbol ? NSAddressOfSymbol(symbol) : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsStateGuardian:: osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, osxGraphicsStateGuardian *share_with) : @@ -68,11 +60,9 @@ osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, get_gamma_table(); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsStateGuardian:: ~osxGraphicsStateGuardian() { if (_aglcontext != (AGLContext)NULL) { @@ -83,12 +73,9 @@ osxGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void osxGraphicsStateGuardian::reset() { /* @@ -109,16 +96,12 @@ void osxGraphicsStateGuardian::reset() } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::draw_resize_box -// Access: Public, Virtual -// Description: Draws an OSX-style resize icon in the bottom right -// corner of the current display region. This is -// normally done automatically at the end of each frame -// when the window is indicated as resizable, since the -// 3-D graphics overlay the normal, OS-drawn resize icon -// and the user won't be able see it. -//////////////////////////////////////////////////////////////////// +/** + * Draws an OSX-style resize icon in the bottom right corner of the current + * display region. This is normally done automatically at the end of each + * frame when the window is indicated as resizable, since the 3-D graphics + * overlay the normal, OS-drawn resize icon and the user won't be able see it. + */ void osxGraphicsStateGuardian:: draw_resize_box() { // This state is created, once, and never freed. @@ -128,8 +111,8 @@ draw_resize_box() { DepthWriteAttrib::make(DepthWriteAttrib::M_off), DepthTestAttrib::make(DepthTestAttrib::M_none)); - // Get the default texture to apply to the resize box; it's - // compiled into the code. + // Get the default texture to apply to the resize box; it's compiled into + // the code. string resize_box_string((const char *)resize_box, resize_box_len); istringstream resize_box_strm(resize_box_string); PNMImage resize_box_pnm; @@ -150,14 +133,13 @@ draw_resize_box() { // Set the state to our specific, known state for drawing the icon. set_state_and_transform(state, TransformState::make_identity()); - // Now determine the inner corner of the quad, choosing a 15x15 - // pixel square in the lower-right corner, computed from the - // viewport size. + // Now determine the inner corner of the quad, choosing a 15x15 pixel square + // in the lower-right corner, computed from the viewport size. PN_stdfloat inner_x = 1.0f - (15.0f * 2.0f / _viewport_width); PN_stdfloat inner_y = (15.0f * 2.0f / _viewport_height) - 1.0f; - // Draw the quad. We just use the slow, simple immediate mode calls - // here. It's just one quad, after all. + // Draw the quad. We just use the slow, simple immediate mode calls here. + // It's just one quad, after all. glBegin(GL_QUADS); glColor4f(1.0, 1.0, 1.0, 1.0); @@ -176,11 +158,9 @@ draw_resize_box() { glEnd(); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::build_gl -// Access: Public, Virtual -// Description: This function will build up a context for a gsg.. -//////////////////////////////////////////////////////////////////// +/** + * This function will build up a context for a gsg.. + */ OSStatus osxGraphicsStateGuardian:: build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { if (_aglcontext) { @@ -241,8 +221,8 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { attrib.push_back(AGL_NO_RECOVERY); } - // Allow the system to choose the largest buffers requested that - // meets all our selections. + // Allow the system to choose the largest buffers requested that meets all + // our selections. attrib.push_back(AGL_MAXIMUM_POLICY); // Terminate the list. @@ -296,12 +276,10 @@ build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) { } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::describe_pixel_format -// Access: Private -// Description: Fills in the fb_props member with the appropriate -// values according to the chosen pixel format. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the fb_props member with the appropriate values according to the + * chosen pixel format. + */ void osxGraphicsStateGuardian:: describe_pixel_format(FrameBufferProperties &fb_props) { fb_props.clear(); @@ -363,8 +341,8 @@ describe_pixel_format(FrameBufferProperties &fb_props) { fb_props.set_stereo(value); } - // Until we query the renderer, we don't know whether it's hardware - // or software based, so set both flags to indicate we don't know. + // Until we query the renderer, we don't know whether it's hardware or + // software based, so set both flags to indicate we don't know. fb_props.set_force_hardware(true); fb_props.set_force_software(true); @@ -390,23 +368,18 @@ describe_pixel_format(FrameBufferProperties &fb_props) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::get_gamma_table -// Access: Public, Static -// Description: Static function for getting the orig gamma tables -//////////////////////////////////////////////////////////////////// +/** + * Static function for getting the orig gamma tables + */ bool osxGraphicsStateGuardian:: get_gamma_table() { CGDisplayRestoreColorSyncSettings(); _cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::static_set_gamma -// Access: Public, Static -// Description: Static function for setting gamma which is needed -// for atexit. -//////////////////////////////////////////////////////////////////// +/** + * Static function for setting gamma which is needed for atexit. + */ bool osxGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; @@ -420,14 +393,13 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { } // CGDisplayRestoreColorSyncSettings(); - // CGGammaValue gOriginalRedTable[ 256 ]; - // CGGammaValue gOriginalGreenTable[ 256 ]; - // CGGammaValue gOriginalBlueTable[ 256 ]; + // CGGammaValue gOriginalRedTable[ 256 ]; CGGammaValue gOriginalGreenTable[ + // 256 ]; CGGammaValue gOriginalBlueTable[ 256 ]; - // CGTableCount sampleCount; - // CGDisplayErr cgErr; + // CGTableCount sampleCount; CGDisplayErr cgErr; - // cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount); + // cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, + // _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount); CGGammaValue redTable[ 256 ]; CGGammaValue greenTable[ 256 ]; @@ -458,12 +430,9 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::set_gamma -// Access: Published -// Description: Non static version of setting gamma. Returns true -// on success. -//////////////////////////////////////////////////////////////////// +/** + * Non static version of setting gamma. Returns true on success. + */ bool osxGraphicsStateGuardian:: set_gamma(PN_stdfloat gamma) { bool set; @@ -473,24 +442,18 @@ set_gamma(PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::restore_gamma -// Access: Published -// Description: Restore original gamma. -//////////////////////////////////////////////////////////////////// +/** + * Restore original gamma. + */ void osxGraphicsStateGuardian:: restore_gamma() { static_set_gamma(true, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsStateGuardian::atexit_function -// Access: Public, Static -// Description: This function is passed to the atexit function. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the atexit function. + */ void osxGraphicsStateGuardian:: atexit_function() { static_set_gamma(true, 1.0); } - - diff --git a/panda/src/osxdisplay/osxGraphicsStateGuardian.h b/panda/src/osxdisplay/osxGraphicsStateGuardian.h index 2dfd751154..038ba42055 100644 --- a/panda/src/osxdisplay/osxGraphicsStateGuardian.h +++ b/panda/src/osxdisplay/osxGraphicsStateGuardian.h @@ -1,15 +1,13 @@ -// Filename: osxGraphicsStateGuardian.h -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsStateGuardian.h + */ #ifndef OSXGRAPHICSSTATEGUARDIAN_H #define OSXGRAPHICSSTATEGUARDIAN_H @@ -27,11 +25,10 @@ class osxGraphicsWindow; -//////////////////////////////////////////////////////////////////// -// Class : wglGraphicsStateGuardian -// Description : A tiny specialization on GLGraphicsStateGuardian to -// add some wgl-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific + * information. + */ class osxGraphicsStateGuardian : public GLGraphicsStateGuardian { public: osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -59,9 +56,8 @@ public: private: void describe_pixel_format(FrameBufferProperties &fb_props); - // We have to save a pointer to the GSG we intend to share texture - // context with, since we don't create our own context in the - // constructor. + // We have to save a pointer to the GSG we intend to share texture context + // with, since we don't create our own context in the constructor. PT(osxGraphicsStateGuardian) _share_with; AGLPixelFormat _aglPixFmt; AGLContext _aglcontext; diff --git a/panda/src/osxdisplay/osxGraphicsWindow.I b/panda/src/osxdisplay/osxGraphicsWindow.I index 4abeb89bd2..a5a7661366 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.I +++ b/panda/src/osxdisplay/osxGraphicsWindow.I @@ -1,23 +1,19 @@ -// Filename: osxGraphicsWindow.I -// Created by: drose (13Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsWindow.I + * @author drose + * @date 2009-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::send_key_event -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ inline void osxGraphicsWindow:: send_key_event(ButtonHandle key, bool down) { if (down) { diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index 4fd6bfff24..431f366da1 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -1,15 +1,13 @@ -// Filename: osxGraphicsWindow.h -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsWindow.h + */ #ifndef OSXGRAPHICSWINDOW_H #define OSXGRAPHICSWINDOW_H @@ -27,11 +25,9 @@ #define HACK_SCREEN_HASH_CONTEXT true OSStatus report_agl_error(const string &comment); -//////////////////////////////////////////////////////////////////// -// Class : osxGraphicsWindow -// Description : An interface to the osx/ system for managing GL -// windows under X. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the osx/ system for managing GL windows under X. + */ class osxGraphicsWindow : public GraphicsWindow { public: osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -70,9 +66,8 @@ protected: private: bool os_open_window(WindowProperties &properties); - // - // a singleton .. for the events to find the right pipe to push the event into - // + // a singleton .. for the events to find the right pipe to push the event + // into public: // do not call direct .. OSStatus handle_key_input(EventHandlerCallRef myHandler, EventRef event, @@ -148,4 +143,3 @@ private: #include "osxGraphicsWindow.I" #endif - diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index de82a2716b..4fe2c45965 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -1,20 +1,18 @@ -// Filename: osxGraphicsWindow.mm -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file osxGraphicsWindow.mm + */ -// We include these system header files first, because there is a -// namescope conflict between them and some other header file that -// gets included later (in particular, TCP_NODELAY must not be a -// #define symbol for these headers to be included properly). +// We include these system header files first, because there is a namescope +// conflict between them and some other header file that gets included later +// (in particular, TCP_NODELAY must not be a #define symbol for these headers +// to be included properly). #include #include @@ -22,9 +20,9 @@ #include #include -// We have to include this before we include the system OpenGL/gl.h -// file, but after we include all of the above header files. Deal -// with this contradiction later. +// We have to include this before we include the system OpenGLgl.h file, but +// after we include all of the above header files. Deal with this +// contradiction later. #include "glgsg.h" #include "osxGraphicsWindow.h" @@ -83,12 +81,9 @@ check_my_window(WindowRef window) { -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::get_current_osx_window -// Access: Public, Static -// Description: Returns the active window for the purpose of -// recording events. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active window for the purpose of recording events. + */ osxGraphicsWindow *osxGraphicsWindow:: get_current_osx_window(WindowRef window) { if (full_screen_window != NULL) { @@ -98,9 +93,8 @@ get_current_osx_window(WindowRef window) { if (window == NULL) { // HID use this path - // Assume first we are a child window. If we cant find a window - // of that class, then we are standalone and can jsut grab the - // front window. + // Assume first we are a child window. If we cant find a window of that + // class, then we are standalone and can jsut grab the front window. window = GetFrontWindowOfClass(kSimpleWindowClass, TRUE); if (window == NULL) { window = FrontNonFloatingWindow(); @@ -114,11 +108,10 @@ get_current_osx_window(WindowRef window) { } } -//////////////////////////////////////////////////////////////////// -// Function: report_agl_error -// Description: Convenience function to report the current AGL error -// code as a formatted error message. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function to report the current AGL error code as a formatted + * error message. + */ OSStatus report_agl_error(const string &comment) { GLenum err = aglGetError(); @@ -134,10 +127,9 @@ report_agl_error(const string &comment) { } } -//////////////////////////////////////////////////////////////////// -// Function: invert_gl_image -// Description: Vertically inverts a rendered image. -//////////////////////////////////////////////////////////////////// +/** + * Vertically inverts a rendered image. + */ static void invert_gl_image(char *imageData, size_t imageSize, size_t rowBytes) { char *buffer = (char*)alloca(rowBytes); @@ -153,18 +145,17 @@ invert_gl_image(char *imageData, size_t imageSize, size_t rowBytes) { } } -//////////////////////////////////////////////////////////////////// -// Function: composite_gl_buffer_into_window -// Description: Drop a GL overlay onto a carbon window.. -//////////////////////////////////////////////////////////////////// +/** + * Drop a GL overlay onto a carbon window.. + */ static void composite_gl_buffer_into_window(AGLContext ctx, Rect *bufferRect, GrafPtr out_port) { GWorldPtr world; QDErr err; - // blit OpenGL content into window backing store - // allocate buffer to hold pane image + // blit OpenGL content into window backing store allocate buffer to hold + // pane image long width = (bufferRect->right - bufferRect->left); long height = (bufferRect->bottom - bufferRect->top); @@ -213,12 +204,9 @@ composite_gl_buffer_into_window(AGLContext ctx, Rect *bufferRect, DisposePtr(image); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::event_handler -// Access: Public -// Description: The standard window event handler for non-fullscreen -// windows. -//////////////////////////////////////////////////////////////////// +/** + * The standard window event handler for non-fullscreen windows. + */ OSStatus osxGraphicsWindow:: event_handler(EventHandlerCallRef myHandler, EventRef event) { OSStatus result = eventNotHandledErr; @@ -267,8 +255,8 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) { break; case kEventWindowClose: // called when window is being closed (close box) - // This is a message from the window manager indicating that - // the user has requested to close the window. + // This is a message from the window manager indicating that the user + // has requested to close the window. user_close_request(); result = noErr; break; @@ -324,31 +312,27 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::user_close_request -// Access: Private -// Description: The user has requested to close the window, for -// instance with Cmd-W, or by clicking on the close -// button. -//////////////////////////////////////////////////////////////////// +/** + * The user has requested to close the window, for instance with Cmd-W, or by + * clicking on the close button. + */ void osxGraphicsWindow:: user_close_request() { string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept the request and process it directly. + // In this case, the app has indicated a desire to intercept the request + // and process it directly. throw_event(close_request_event); } else { - // In this case, the default case, the app does not intend to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to service the + // request, so we do by closing the window. close_window(); } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::system_close_window -// Access: Private -// Description: The window has been closed by an OS resource, not by -// an internal request -//////////////////////////////////////////////////////////////////// +/** + * The window has been closed by an OS resource, not by an internal request + */ void osxGraphicsWindow:: system_close_window() { if (osxdisplay_cat.is_debug()) { @@ -358,13 +342,12 @@ system_close_window() { release_system_resources(false); } -//////////////////////////////////////////////////////////////////// -// Function: window_event_handler -// Description: The C callback for Window Events -// -// We only hook this up for non-fullscreen windows, so -// we only handle system window events. -//////////////////////////////////////////////////////////////////// +/** + * The C callback for Window Events + * + * We only hook this up for non-fullscreen windows, so we only handle system + * window events. + */ static pascal OSStatus window_event_handler(EventHandlerCallRef my_handler, EventRef event, void *) { // volatile().lock(); @@ -376,20 +359,18 @@ window_event_handler(EventHandlerCallRef my_handler, EventRef event, void *) { if (window != NULL) { osxGraphicsWindow *osx_win = osxGraphicsWindow::get_current_osx_window(window); if (osx_win != (osxGraphicsWindow *)NULL) { - //osx_global_mutex().release(); + // osx_global_mutex().release(); return osx_win->event_handler(my_handler, event); } } - //osx_global_mutex().release(); + // osx_global_mutex().release(); return eventNotHandledErr; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::do_resize -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void osxGraphicsWindow:: do_resize() { if (osxdisplay_cat.is_debug()) { @@ -439,18 +420,17 @@ do_resize() { } } -//////////////////////////////////////////////////////////////////// -// Function: app_event_handler -// Description: The C callback for Application events. -// -// Hooked once per application. -//////////////////////////////////////////////////////////////////// +/** + * The C callback for Application events. + * + * Hooked once per application. + */ static pascal OSStatus app_event_handler(EventHandlerCallRef my_handler, EventRef event, void *user_data) { OSStatus result = eventNotHandledErr; { - //osx_global_mutex().lock(); + // osx_global_mutex().lock(); osxGraphicsWindow *osx_win = NULL; WindowRef window = NULL; @@ -461,7 +441,7 @@ app_event_handler(EventHandlerCallRef my_handler, EventRef event, sizeof(WindowRef), NULL, (void*) &window); osx_win = osxGraphicsWindow::get_current_osx_window(window); if (osx_win == NULL) { - //osx_global_mutex().release(); + // osx_global_mutex().release(); return eventNotHandledErr; } @@ -470,11 +450,9 @@ app_event_handler(EventHandlerCallRef my_handler, EventRef event, if (kind == kEventTextInputUnicodeForKeyEvent) { osx_win->handle_text_input(my_handler, event); } - //result = noErr; - // - // can not report handled .. the os will not sent the raw key strokes then - // if(osx_win->handle_text_input(my_handler, event) == noErr) - // result = noErr; + // result = noErr; can not report handled .. the os will not sent the + // raw key strokes then if(osx_win->handle_text_input(my_handler, event) + // == noErr) result = noErr; break; case kEventClassKeyboard: @@ -502,24 +480,22 @@ app_event_handler(EventHandlerCallRef my_handler, EventRef event, break; case kEventClassMouse: - // osxdisplay_cat.info() << "Mouse movement handled by Application handler\n"; - //if(osxGraphicsWindow::full_screen_window != NULL) + // osxdisplay_cat.info() << "Mouse movement handled by Application + // handler\n"; if(osxGraphicsWindow::full_screen_window != NULL) result = osx_win->handle_window_mouse_events(my_handler, event); - //result = noErr; + // result = noErr; break; } - //osx_global_mutex().release(); + // osx_global_mutex().release(); } return result; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::handle_text_input -// Access: Public -// Description: Trap Unicode Input. -//////////////////////////////////////////////////////////////////// +/** + * Trap Unicode Input. + */ OSStatus osxGraphicsWindow:: handle_text_input(EventHandlerCallRef my_handler, EventRef text_event) { UniChar *text = NULL; @@ -547,11 +523,9 @@ handle_text_input(EventHandlerCallRef my_handler, EventRef text_event) { return ret; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::release_system_resources -// Access: Private -// Description: Clean up the OS level messes. -//////////////////////////////////////////////////////////////////// +/** + * Clean up the OS level messes. + */ void osxGraphicsWindow:: release_system_resources(bool destructing) { if (_is_fullscreen) { @@ -568,8 +542,7 @@ release_system_resources(bool destructing) { _originalMode = NULL; } - // if the gsg context is assigned to this window - // clear it.. + // if the gsg context is assigned to this window clear it.. if (_osx_window != NULL && GetWindowPort (_osx_window) == (GrafPtr)aglGetDrawable(get_gsg_context())) { aglSetDrawable(get_gsg_context(),NULL); } @@ -616,11 +589,9 @@ release_system_resources(bool destructing) { static int id_seed = 100; -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsWindow:: osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -658,11 +629,9 @@ osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ osxGraphicsWindow:: ~osxGraphicsWindow() { if (osxdisplay_cat.is_debug()) { @@ -670,8 +639,8 @@ osxGraphicsWindow:: << "osxGraphicsWindow::~osxGraphicsWindow() -" <<_ID << "\n"; } - // Make sure the window callback won't come back to this - // (destructed) object any more. + // Make sure the window callback won't come back to this (destructed) object + // any more. if (_osx_window) { SetWRefCon(_osx_window, (long) NULL); } @@ -679,11 +648,9 @@ osxGraphicsWindow:: release_system_resources(true); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::get_context -// Access: Private -// Description: Helper to decide whitch context to use if any -//////////////////////////////////////////////////////////////////// +/** + * Helper to decide whitch context to use if any + */ AGLContext osxGraphicsWindow:: get_context() { if (_holder_aglcontext != NULL) { @@ -693,11 +660,9 @@ get_context() { return get_gsg_context(); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::get_gsg_context -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AGLContext osxGraphicsWindow:: get_gsg_context() { if (_gsg != NULL) { @@ -708,12 +673,9 @@ get_gsg_context() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::build_gl -// Access: Private -// Description: Code of the class.. used to control the GL context -// Allocation. -//////////////////////////////////////////////////////////////////// +/** + * Code of the class.. used to control the GL context Allocation. + */ OSStatus osxGraphicsWindow:: build_gl(bool full_screen) { // make sure the gsg is up and runnig.. @@ -751,13 +713,10 @@ build_gl(bool full_screen) { return err; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::set_icon_filename -// Access: Private -// Description: Called internally to load up an icon file that should -// be applied to the window. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to load up an icon file that should be applied to the + * window. Returns true on success, false on failure. + */ bool osxGraphicsWindow:: set_icon_filename(const Filename &icon_filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -796,12 +755,9 @@ set_icon_filename(const Filename &icon_filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::set_pointer_in_window -// Access: Private -// Description: Indicates the mouse pointer is seen within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is seen within the window. + */ void osxGraphicsWindow:: set_pointer_in_window(int x, int y) { _input_devices[0].set_pointer_in_window(x, y); @@ -817,12 +773,9 @@ set_pointer_in_window(int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::set_pointer_out_of_window -// Access: Private -// Description: Indicates the mouse pointer is no longer within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is no longer within the window. + */ void osxGraphicsWindow:: set_pointer_out_of_window() { _input_devices[0].set_pointer_out_of_window(); @@ -834,15 +787,12 @@ set_pointer_out_of_window() { } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool osxGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); @@ -854,9 +804,9 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } - // Now is a good time to apply the icon change that may have - // recently been requested. By this point, we should be able to get - // a handle to the dock context. + // Now is a good time to apply the icon change that may have recently been + // requested. By this point, we should be able to get a handle to the dock + // context. if (_pending_icon != NULL) { CGContextRef context = BeginCGContextForApplicationDockTile(); if (context != NULL) { @@ -896,13 +846,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void osxGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -916,9 +864,8 @@ end_frame(FrameMode mode, Thread *current_thread) { !_properties.get_undecorated() && !_properties.get_fullscreen() && show_resize_box) { - // Draw a kludgey little resize box in the corner of the window, - // so the user knows he's supposed to be able to drag the window - // if he wants. + // Draw a kludgey little resize box in the corner of the window, so the + // user knows he's supposed to be able to drag the window if he wants. DisplayRegionPipelineReader dr_reader(_overlay_display_region, current_thread); _gsg->prepare_display_region(&dr_reader); DCAST(osxGraphicsStateGuardian, _gsg)->draw_resize_box(); @@ -929,20 +876,17 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void osxGraphicsWindow:: end_flip() { // cerr << " end_flip [" << _ID << "]\n"; @@ -950,8 +894,8 @@ end_flip() { void osxGraphicsWindow:: begin_flip() { - // this forces a rip to proper context - // cerr << " begin_flip [" << _ID << "]\n"; + // this forces a rip to proper context cerr << " begin_flip [" << _ID << + // "]\n"; return; if (_is_fullscreen) { @@ -977,12 +921,9 @@ begin_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void osxGraphicsWindow:: close_window() { system_close_window(); @@ -996,29 +937,21 @@ close_window() { GraphicsWindow::close_window(); } -// HACK ALLERT ************ Undocumented OSX calls... -// I can not find any other way to get the mouse focus to a window in OSX.. -// -//extern "C" { -// struct CPSProcessSerNum -// { -// UInt32 lo; -// UInt32 hi; -// }; +/* + * HACK ALLERT ************ Undocumented OSX calls... I can not find any other + * way to get the mouse focus to a window in OSX.. extern "C" { struct + * CPSProcessSerNum { UInt32 lo; UInt32 hi; }; + */ -//extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); -//extern OSErr CPSEnableForegroundOperation(struct CPSProcessSerNum *psn); -//extern OSErr CPSSetProcessName (struct CPSProcessSerNum *psn, char *processname); -//extern OSErr CPSSetFrontProcess(struct CPSProcessSerNum *psn); -//}; +// extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); extern OSErr +// CPSEnableForegroundOperation(struct CPSProcessSerNum *psn); extern OSErr +// CPSSetProcessName (struct CPSProcessSerNum *psn, char *processname); extern +// OSErr CPSSetFrontProcess(struct CPSProcessSerNum *psn); }; -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool osxGraphicsWindow:: open_window() { WindowProperties req_properties = _properties; @@ -1027,37 +960,35 @@ open_window() { _gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL); } - //osx_global_mutex().lock(); + // osx_global_mutex().lock(); bool answer = os_open_window(req_properties); - //osx_global_mutex().release(); + // osx_global_mutex().release(); return answer; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::os_open_window -// Access: Private -// Description: Actually makes the OS calls to open a window. -//////////////////////////////////////////////////////////////////// +/** + * Actually makes the OS calls to open a window. + */ bool osxGraphicsWindow:: os_open_window(WindowProperties &req_properties) { OSErr err = noErr; if (_current_icon != NULL && _pending_icon == NULL) { - // If we already have an icon specified, we'll need to reapply it - // when the window is successfully created. + // If we already have an icon specified, we'll need to reapply it when the + // window is successfully created. _pending_icon = _current_icon; _current_icon = NULL; } static bool GlobalInits = false; if (!GlobalInits) { - // - // one time aplication inits.. to get a window open from a standalone aplication.. + // one time aplication inits.. to get a window open from a standalone + // aplication.. EventHandlerRef application_event_ref_ref1; EventTypeSpec list1[] = { - //{ kEventClassCommand, kEventProcessCommand }, - //{ kEventClassCommand, kEventCommandUpdateStatus }, + // { kEventClassCommand, kEventProcessCommand }, { kEventClassCommand, + // kEventCommandUpdateStatus }, { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseMoved }, @@ -1079,22 +1010,19 @@ os_open_window(WindowProperties &req_properties) { // Determine if we're running from a bundle. CFDictionaryRef dref = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask); - // If the dictionary doesn't have "BundlePath" (or the BundlePath - // is the same as the executable path), then we're not running - // from a bundle, and we need to call TransformProcessType to make - // the process a "foreground" application, with its own icon in - // the dock and such. + // If the dictionary doesn't have "BundlePath" (or the BundlePath is the + // same as the executable path), then we're not running from a bundle, and + // we need to call TransformProcessType to make the process a "foreground" + // application, with its own icon in the dock and such. bool has_bundle = false; CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath")); if (bundle_path != NULL) { - // OK, we have a bundle path. We're probably running in a - // bundle . . . + // OK, we have a bundle path. We're probably running in a bundle . . . has_bundle = true; - // . . . unless it turns out it's the same as the executable - // path. + // . . . unless it turns out it's the same as the executable path. CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey); if (exe_path != NULL) { if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { @@ -1243,9 +1171,8 @@ os_open_window(WindowProperties &req_properties) { attributes |= kWindowNoTitleBarAttribute; CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window); } else { - // create a window with crome and sizing and sucj - // In this case, we want to constrain the window to the - // available size. + // create a window with crome and sizing and sucj In this case, we + // want to constrain the window to the available size. Rect bounds; GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds); @@ -1308,9 +1235,7 @@ os_open_window(WindowProperties &req_properties) { << "build_gl complete, set properties\n"; } - // // attach the holder context to the window.. - // if (!aglSetDrawable(_holder_aglcontext, GetWindowPort(_osx_window))) { err = report_agl_error("aglSetDrawable"); @@ -1337,8 +1262,8 @@ os_open_window(WindowProperties &req_properties) { } } - // Now measure the size and placement of the window we - // actually ended up with. + // Now measure the size and placement of the window we actually ended up + // with. Rect rectPort = {0,0,0,0}; GetWindowPortBounds (_osx_window, &rectPort); _properties.set_size((int)(rectPort.right - rectPort.left),(int) (rectPort.bottom - rectPort.top)); @@ -1376,12 +1301,10 @@ os_open_window(WindowProperties &req_properties) { return (err == noErr); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::process_events -// Access: Protected, Virtual -// Description: Required event upcall, used to dispatch window and -// application events back into panda. -//////////////////////////////////////////////////////////////////// +/** + * Required event upcall, used to dispatch window and application events back + * into panda. + */ void osxGraphicsWindow:: process_events() { GraphicsWindow::process_events(); @@ -1399,12 +1322,10 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::handle_key_input -// Access: Protected, Virtual -// Description: Required event upcall, used to dispatch window and -// application events back into panda. -//////////////////////////////////////////////////////////////////// +/** + * Required event upcall, used to dispatch window and application events back + * into panda. + */ OSStatus osxGraphicsWindow:: handle_key_input(EventHandlerCallRef my_handler, EventRef event, Boolean key_down) { @@ -1419,14 +1340,13 @@ handle_key_input(EventHandlerCallRef my_handler, EventRef event, << ", " << (int)key_down << "\n"; } - //CallNextEventHandler(my_handler, event); + // CallNextEventHandler(my_handler, event); - // We don't check the result of the above function. In principle, - // this should return eventNotHandledErr if the key event is not - // handled by the OS, but in practice, testing this just seems to - // eat the Escape keypress meaninglessly. Keypresses like F11 that - // are already mapped in the desktop seem to not even come into this - // function in the first place. + // We don't check the result of the above function. In principle, this + // should return eventNotHandledErr if the key event is not handled by the + // OS, but in practice, testing this just seems to eat the Escape keypress + // meaninglessly. Keypresses like F11 that are already mapped in the + // desktop seem to not even come into this function in the first place. UInt32 new_modifiers = 0; OSStatus error = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), @@ -1444,9 +1364,9 @@ handle_key_input(EventHandlerCallRef my_handler, EventRef event, if ((new_modifiers & cmdKey) != 0) { if (button == KeyboardButton::ascii_key("q") || button == KeyboardButton::ascii_key("w")) { - // Command-Q or Command-W: quit the application or close the - // window, respectively. For now, we treat them both the - // same: close the window. + // Command-Q or Command-W: quit the application or close the window, + // respectively. For now, we treat them both the same: close the + // window. user_close_request(); } } @@ -1459,11 +1379,9 @@ handle_key_input(EventHandlerCallRef my_handler, EventRef event, // return noErr; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::system_set_window_foreground -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void osxGraphicsWindow:: system_set_window_foreground(bool foreground) { WindowProperties properties; @@ -1471,11 +1389,9 @@ system_set_window_foreground(bool foreground) { system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::system_point_to_local_point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void osxGraphicsWindow:: system_point_to_local_point(Point &global_point) { if (_osx_window != NULL) { @@ -1490,11 +1406,9 @@ system_point_to_local_point(Point &global_point) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::handle_mouse_window_events -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OSStatus osxGraphicsWindow:: handle_window_mouse_events(EventHandlerCallRef my_handler, EventRef event) { WindowRef window = NULL; @@ -1509,8 +1423,7 @@ handle_window_mouse_events(EventHandlerCallRef my_handler, EventRef event) { // cerr <<" Start Mouse Event " << _ID << "\n"; - // Mac OS X v10.1 and later - // should this be front window??? + // Mac OS X v10.1 and later should this be front window??? GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); @@ -1523,13 +1436,12 @@ handle_window_mouse_events(EventHandlerCallRef my_handler, EventRef event) { GetWindowPortBounds(window, &rect_port); - // result = CallNextEventHandler(my_handler, event); - // if (eventNotHandledErr == result) + // result = CallNextEventHandler(my_handler, event); if (eventNotHandledErr + // == result) { // only handle events not already handled (prevents weird resize interaction) switch (kind) { - // Whenever mouse button state changes, generate the - // appropriate Panda down/up events to represent the - // change. + // Whenever mouse button state changes, generate the appropriate Panda + // downup events to represent the change. case kEventMouseDown: case kEventMouseUp: @@ -1626,11 +1538,9 @@ handle_window_mouse_events(EventHandlerCallRef my_handler, EventRef event) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::osx_translate_key -// Access: Private -// Description: MAC Key Codes to Panda Key Codes -//////////////////////////////////////////////////////////////////// +/** + * MAC Key Codes to Panda Key Codes + */ ButtonHandle osxGraphicsWindow:: osx_translate_key(UInt32 key, EventRef event) { ButtonHandle nk = ButtonHandle::none(); @@ -1686,7 +1596,7 @@ osx_translate_key(UInt32 key, EventRef event) { case 91: nk = KeyboardButton::ascii_key('8'); break; case 92: nk = KeyboardButton::ascii_key('9'); break; - // case 36: nk = KeyboardButton::ret(); break; // no return in panda ??? + // case 36: nk = KeyboardButton::ret(); break; no return in panda ??? case 49: nk = KeyboardButton::space(); break; case 51: nk = KeyboardButton::backspace(); break; case 48: nk = KeyboardButton::tab(); break; @@ -1745,8 +1655,8 @@ osx_translate_key(UInt32 key, EventRef event) { << " (0x" << hex << key << dec << ")\n"; } - // not sure this is right .. but no mapping for keypad and such - // this at least does a best gess.. + // not sure this is right .. but no mapping for keypad and such this at + // least does a best gess.. char charCode = 0; if (GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, nil, sizeof(charCode), nil, &charCode) == noErr) { @@ -1756,11 +1666,9 @@ osx_translate_key(UInt32 key, EventRef event) { return nk; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::handle_modifier_delta -// Access: Private -// Description: Used to emulate key events for the MAC key modifiers. -//////////////////////////////////////////////////////////////////// +/** + * Used to emulate key events for the MAC key modifiers. + */ void osxGraphicsWindow:: handle_modifier_delta(UInt32 new_modifiers) { UInt32 changed = _last_key_modifiers ^ new_modifiers; @@ -1789,11 +1697,9 @@ handle_modifier_delta(UInt32 new_modifiers) { _last_key_modifiers = new_modifiers; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::handle_button_delta -// Access: Private -// Description: Used to emulate button events -//////////////////////////////////////////////////////////////////// +/** + * Used to emulate button events + */ void osxGraphicsWindow:: handle_button_delta(UInt32 new_buttons) { UInt32 changed = _last_buttons ^ new_buttons; @@ -1825,16 +1731,14 @@ handle_button_delta(UInt32 new_buttons) { _last_buttons = new_buttons; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool osxGraphicsWindow:: move_pointer(int device, int x, int y) { if (_osx_window == NULL) { @@ -1864,11 +1768,9 @@ move_pointer(int device, int x, int y) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::do_reshape_request -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool osxGraphicsWindow:: do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size) { @@ -1909,8 +1811,8 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, } } else */ { - // We sometimes get a bogus origin of (0, 0). As a special hack, - // treat this as a special case, and ignore it. + // We sometimes get a bogus origin of (0, 0). As a special hack, treat + // this as a special case, and ignore it. if (has_origin) { if (x_origin != 0 || y_origin != 0) { MoveWindow(_osx_window, x_origin, y_origin, false); @@ -1933,25 +1835,20 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, return true; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void osxGraphicsWindow:: set_properties_now(WindowProperties &properties) { if (osxdisplay_cat.is_debug()) { @@ -1994,9 +1891,8 @@ set_properties_now(WindowProperties &properties) { } if (need_full_rebuild) { - // Logic here is .. take a union of the properties .. with the - // new allowed to overwrite the old states. and start a bootstrap - // of a new window .. + // Logic here is .. take a union of the properties .. with the new allowed + // to overwrite the old states. and start a bootstrap of a new window .. // get a copy of my properties.. WindowProperties req_properties(_properties); @@ -2020,9 +1916,9 @@ set_properties_now(WindowProperties &properties) { properties.clear_title(); } - // An icon filename means to load up the icon and save it. We can't - // necessarily apply it immediately; it will get applied later, in - // the window event handler. + // An icon filename means to load up the icon and save it. We can't + // necessarily apply it immediately; it will get applied later, in the + // window event handler. if (properties.has_icon_filename()) { if (set_icon_filename(properties.get_icon_filename())) { properties.clear_icon_filename(); @@ -2088,11 +1984,9 @@ set_properties_now(WindowProperties &properties) { return; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::local_point_to_system_point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void osxGraphicsWindow:: local_point_to_system_point(Point &local_point) { if (_osx_window != NULL) { @@ -2107,22 +2001,18 @@ local_point_to_system_point(Point &local_point) { } } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::mouse_mode_relative -// Access: Protected, Virtual -// Description: detaches mouse. Only mouse delta from now on. -//////////////////////////////////////////////////////////////////// +/** + * detaches mouse. Only mouse delta from now on. + */ void osxGraphicsWindow:: mouse_mode_relative() { CGAssociateMouseAndMouseCursorPosition(false); } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsWindow::mouse_mode_absolute -// Access: Protected, Virtual -// Description: reattaches mouse to location -//////////////////////////////////////////////////////////////////// +/** + * reattaches mouse to location + */ void osxGraphicsWindow:: mouse_mode_absolute() { CGAssociateMouseAndMouseCursorPosition(true); diff --git a/panda/src/pandabase/pandabase.cxx b/panda/src/pandabase/pandabase.cxx index 2a5caad8cb..7f48ed21b3 100644 --- a/panda/src/pandabase/pandabase.cxx +++ b/panda/src/pandabase/pandabase.cxx @@ -1,15 +1,14 @@ -// Filename: pandabase.cxx -// Created by: drose (15Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandabase.cxx + * @author drose + * @date 2000-09-15 + */ #include "pandabase.h" diff --git a/panda/src/pandabase/pandabase.h b/panda/src/pandabase/pandabase.h index 8e9008be2f..37a3273728 100644 --- a/panda/src/pandabase/pandabase.h +++ b/panda/src/pandabase/pandabase.h @@ -1,8 +1,4 @@ -/* Filename: pandabase.h - * Created by: drose (12Sep00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file pandabase.h + * @author drose + * @date 2000-09-12 + */ /* This file is included at the beginning of every header file and/or C or C++ file. It must be compilable for C as well as C++ files, @@ -23,4 +22,3 @@ #include "pandasymbols.h" #endif - diff --git a/panda/src/pandabase/pandasymbols.h b/panda/src/pandabase/pandasymbols.h index 235b8b95b5..4e7389dadc 100644 --- a/panda/src/pandabase/pandasymbols.h +++ b/panda/src/pandabase/pandasymbols.h @@ -1,8 +1,4 @@ -/* Filename: pandasymbols.h - * Created by: drose (18Feb00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file pandasymbols.h + * @author drose + * @date 2000-02-18 + */ #ifndef PANDASYMBOLS_H #define PANDASYMBOLS_H diff --git a/panda/src/parametrics/config_parametrics.cxx b/panda/src/parametrics/config_parametrics.cxx index b1b4aa838f..93a6e3841f 100644 --- a/panda/src/parametrics/config_parametrics.cxx +++ b/panda/src/parametrics/config_parametrics.cxx @@ -1,16 +1,15 @@ -// Filename: config_parametrics.cxx -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_parametrics.cxx + * @author drose + * @date 2000-03-19 + */ #include "nurbsCurve.h" #include "config_parametrics.h" diff --git a/panda/src/parametrics/config_parametrics.h b/panda/src/parametrics/config_parametrics.h index e78fb0a64b..d58a097c28 100644 --- a/panda/src/parametrics/config_parametrics.h +++ b/panda/src/parametrics/config_parametrics.h @@ -1,16 +1,15 @@ -// Filename: config_parametrics.h -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_parametrics.h + * @author drose + * @date 2000-03-19 + */ #ifndef CONFIG_PARAMETRICS_H #define CONFIG_PARAMETRICS_H diff --git a/panda/src/parametrics/cubicCurveseg.cxx b/panda/src/parametrics/cubicCurveseg.cxx index 3451277685..6bd2dcef6f 100644 --- a/panda/src/parametrics/cubicCurveseg.cxx +++ b/panda/src/parametrics/cubicCurveseg.cxx @@ -1,16 +1,15 @@ -// Filename: cubicCurveseg.cxx -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cubicCurveseg.cxx + * @author drose + * @date 2001-03-04 + */ #include "piecewiseCurve.h" @@ -24,21 +23,17 @@ TypeHandle CubicCurveseg::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CubicCurveseg:: CubicCurveseg() { } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::Constructor -// Access: Public -// Description: Creates the curveseg given the four basis vectors -// (the columns of the matrix) explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Creates the curveseg given the four basis vectors (the columns of the + * matrix) explicitly. + */ CubicCurveseg:: CubicCurveseg(const LMatrix4 &basis) { Bx = basis.get_col(0); @@ -49,45 +44,36 @@ CubicCurveseg(const LMatrix4 &basis) { } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::Constructor -// Access: Public -// Description: Creates the curveseg as a Bezier segment. -//////////////////////////////////////////////////////////////////// +/** + * Creates the curveseg as a Bezier segment. + */ CubicCurveseg:: CubicCurveseg(const BezierSeg &seg) { bezier_basis(seg); } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::Constructor -// Access: Public -// Description: Creates the curveseg as a NURBS segment. See -// nurbs_basis for a description of the parameters. -//////////////////////////////////////////////////////////////////// +/** + * Creates the curveseg as a NURBS segment. See nurbs_basis for a description + * of the parameters. + */ CubicCurveseg:: CubicCurveseg(int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) { nurbs_basis(order, knots, cvs); } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CubicCurveseg:: ~CubicCurveseg() { } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::get_point -// Access: Published, Virtual -// Description: Computes the surface point at a given parametric -// point t. -//////////////////////////////////////////////////////////////////// +/** + * Computes the surface point at a given parametric point t. + */ bool CubicCurveseg:: get_point(PN_stdfloat t, LVecBase3 &point) const { PN_stdfloat t_sqrd = t*t; @@ -95,24 +81,19 @@ get_point(PN_stdfloat t, LVecBase3 &point) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::get_tangent -// Access: Published, Virtual -// Description: Computes the surface tangent at a given parametric -// point t. -//////////////////////////////////////////////////////////////////// +/** + * Computes the surface tangent at a given parametric point t. + */ bool CubicCurveseg:: get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { evaluate_vector(LVecBase4(3.0f*t*t, 2.0f*t, 1.0f, 0.0f), tangent); return true; } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::get_pt -// Access: Published, Virtual -// Description: Simultaneously computes the point and the tangent at -// the given parametric point. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously computes the point and the tangent at the given parametric + * point. + */ bool CubicCurveseg:: get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { PN_stdfloat t_sqrd=t*t; @@ -121,12 +102,9 @@ get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::get_2ndtangent -// Access: Published, Virtual -// Description: Computes the surface 2nd-order tangent at a given -// parametric point t. -//////////////////////////////////////////////////////////////////// +/** + * Computes the surface 2nd-order tangent at a given parametric point t. + */ bool CubicCurveseg:: get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { evaluate_vector(LVecBase4(6.0f*t, 2.0f, 0.0f, 0.0f), tangent2); @@ -134,13 +112,11 @@ get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::hermite_basis -// Access: Public -// Description: Defines the curve segment as a Hermite. This only -// sets up the basis vectors, so the curve will be -// computed correctly; it does not retain the CV's. -//////////////////////////////////////////////////////////////////// +/** + * Defines the curve segment as a Hermite. This only sets up the basis + * vectors, so the curve will be computed correctly; it does not retain the + * CV's. + */ void CubicCurveseg:: hermite_basis(const HermiteCurveCV &cv0, const HermiteCurveCV &cv1, @@ -164,13 +140,11 @@ hermite_basis(const HermiteCurveCV &cv0, rational = false; } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::bezier_basis -// Access: Public -// Description: Defines the curve segment as a Bezier. This only -// sets up the basis vectors, so the curve will be -// computed correctly; it does not retain the CV's. -//////////////////////////////////////////////////////////////////// +/** + * Defines the curve segment as a Bezier. This only sets up the basis + * vectors, so the curve will be computed correctly; it does not retain the + * CV's. + */ void CubicCurveseg:: bezier_basis(const BezierSeg &seg) { static LMatrix4 @@ -286,14 +260,11 @@ compute_nurbs_basis(int order, -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::nurbs_basis -// Access: Public -// Description: Defines the curve segment as a NURBS. Order is one -// more than the degree, and must be 1, 2, 3, or 4; -// knots is an array of order*2 values, and cvs is an -// array of order values. -//////////////////////////////////////////////////////////////////// +/** + * Defines the curve segment as a NURBS. Order is one more than the degree, + * and must be 1, 2, 3, or 4; knots is an array of order*2 values, and cvs is + * an array of order values. + */ void CubicCurveseg:: nurbs_basis(int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) { assert(order>=1 && order<=4); @@ -301,8 +272,7 @@ nurbs_basis(int order, const PN_stdfloat knots[], const LVecBase4 cvs[]) { LMatrix4 B; compute_nurbs_basis(order, knots, B); - // Create a local copy of our CV's, so we can zero out the unused - // elements. + // Create a local copy of our CV's, so we can zero out the unused elements. LVecBase4 c[4]; for (int i = 0; i < 4; i++) { c[i] = (iregister_factory(get_class_type(), make_CubicCurveseg); } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::make_CubicCurveseg -// Access: Protected -// Description: Factory method to generate an object of this type. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an object of this type. + */ TypedWritable *CubicCurveseg:: make_CubicCurveseg(const FactoryParams ¶ms) { CubicCurveseg *me = new CubicCurveseg; @@ -586,12 +533,10 @@ make_CubicCurveseg(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::write_datagram -// Access: Protected, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void CubicCurveseg:: write_datagram(BamWriter *manager, Datagram &me) { ParametricCurve::write_datagram(manager, me); @@ -603,14 +548,11 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_bool(rational); } -//////////////////////////////////////////////////////////////////// -// Function: CubicCurveseg::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void CubicCurveseg:: fillin(DatagramIterator &scan, BamReader *manager) { ParametricCurve::fillin(scan, manager); diff --git a/panda/src/parametrics/cubicCurveseg.h b/panda/src/parametrics/cubicCurveseg.h index 2bbc21f2eb..16202ee732 100644 --- a/panda/src/parametrics/cubicCurveseg.h +++ b/panda/src/parametrics/cubicCurveseg.h @@ -1,16 +1,15 @@ -// Filename: cubicCurveseg.h -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cubicCurveseg.h + * @author drose + * @date 2001-03-04 + */ #ifndef CUBICCURVESEG_H #define CUBICCURVESEG_H @@ -31,30 +30,23 @@ #define RT_KEEP_ORIG 0x100 -//////////////////////////////////////////////////////////////////// -// Class : CubicCurveseg -// Description : A CubicCurveseg is any curve that can be completely -// described by four 4-valued basis vectors, one for -// each dimension in three-space, and one for the -// homogeneous coordinate. This includes Beziers, -// Hermites, and NURBS. -// -// This class encapsulates a single curve segment of the -// cubic curve. Normally, when we think of Bezier and -// Hermite curves, we think of a piecewise collection of -// such segments. -// -// Although this class includes methods such as -// hermite_basis() and nurbs_basis(), to generate a -// Hermite and NURBS curve segment, respectively, only -// the final basis vectors are stored: the product of -// the basis matrix of the corresponding curve type, and -// its geometry vectors. This is the minimum -// information needed to evaluate the curve. However, -// the individual CV's that were used to compute these -// basis vectors are not retained; this might be handled -// in a subclass (for instance, HermiteCurve). -//////////////////////////////////////////////////////////////////// +/** + * A CubicCurveseg is any curve that can be completely described by four + * 4-valued basis vectors, one for each dimension in three-space, and one for + * the homogeneous coordinate. This includes Beziers, Hermites, and NURBS. + * + * This class encapsulates a single curve segment of the cubic curve. + * Normally, when we think of Bezier and Hermite curves, we think of a + * piecewise collection of such segments. + * + * Although this class includes methods such as hermite_basis() and + * nurbs_basis(), to generate a Hermite and NURBS curve segment, respectively, + * only the final basis vectors are stored: the product of the basis matrix of + * the corresponding curve type, and its geometry vectors. This is the + * minimum information needed to evaluate the curve. However, the individual + * CV's that were used to compute these basis vectors are not retained; this + * might be handled in a subclass (for instance, HermiteCurve). + */ class EXPCL_PANDA_PARAMETRICS CubicCurveseg : public ParametricCurve { PUBLISHED: virtual bool get_point(PN_stdfloat t, LVecBase3 &point) const; @@ -76,16 +68,17 @@ public: void bezier_basis(const BezierSeg &seg); void nurbs_basis(int order, const PN_stdfloat knots[], const LVecBase4 cvs[]); - // evaluate_point() and evaluate_vector() both evaluate the curve at - // a given point by applying the basis vector against the vector - // [t3 t2 t 1] (or some derivative). The difference between the - // two is that evaluate_point() is called only with the vector - // [t3 t2 t 1] and computes a point in three-space and will scale by - // the homogeneous coordinate when the curve demands it (e.g. a - // NURBS), while evaluate_vector() is called with some derivative - // vector like [3t2 2t 1 0] and computes a vector difference between - // points, and will never scale by the homogeneous coordinate (which - // would be zero anyway). +/* + * evaluate_point() and evaluate_vector() both evaluate the curve at a given + * point by applying the basis vector against the vector [t3 t2 t 1] (or some + * derivative). The difference between the two is that evaluate_point() is + * called only with the vector [t3 t2 t 1] and computes a point in three-space + * and will scale by the homogeneous coordinate when the curve demands it + * (e.g. a NURBS), while evaluate_vector() is called with some derivative + * vector like [3t2 2t 1 0] and computes a vector difference between points, + * and will never scale by the homogeneous coordinate (which would be zero + * anyway). + */ void evaluate_point(const LVecBase4 &tv, LVecBase3 &result) const { PN_stdfloat recip_h = (rational) ? 1.0f/tv.dot(Bw) : 1.0f; @@ -141,8 +134,8 @@ private: static TypeHandle _type_handle; }; -// This function is used internally to build the NURBS basis matrix -// based on a given knot sequence. +// This function is used internally to build the NURBS basis matrix based on a +// given knot sequence. void compute_nurbs_basis(int order, const PN_stdfloat knots_in[], LMatrix4 &basis); diff --git a/panda/src/parametrics/curveFitter.I b/panda/src/parametrics/curveFitter.I index e5cf0dbdec..24c4874338 100644 --- a/panda/src/parametrics/curveFitter.I +++ b/panda/src/parametrics/curveFitter.I @@ -1,23 +1,19 @@ -// Filename: curveFitter.I -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file curveFitter.I + * @author drose + * @date 2001-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::DataPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CurveFitter::DataPoint:: DataPoint() : _t(0.0f), @@ -28,24 +24,19 @@ DataPoint() : { } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::DataPoint::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CurveFitter::DataPoint:: output(ostream &out) const { out << "Time " << _t << " xyz " << _xyz << " hpr " << _hpr << " tan " << _tangent; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::DataPoint::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CurveFitter::DataPoint:: operator < (const DataPoint &other) const { return _t < other._t; } - diff --git a/panda/src/parametrics/curveFitter.cxx b/panda/src/parametrics/curveFitter.cxx index 01cd28366c..0cc20c20fa 100644 --- a/panda/src/parametrics/curveFitter.cxx +++ b/panda/src/parametrics/curveFitter.cxx @@ -1,16 +1,15 @@ -// Filename: curveFitter.cxx -// Created by: drose (17Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file curveFitter.cxx + * @author drose + * @date 1998-09-17 + */ #include "pandabase.h" #include "pointerTo.h" @@ -24,42 +23,34 @@ TypeHandle CurveFitter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CurveFitter:: CurveFitter() { _got_xyz = false; _got_hpr = false; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CurveFitter:: ~CurveFitter() { } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::reset -// Access: Public -// Description: Removes all the data points previously added to the -// CurveFitter, and initializes it for a new curve. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the data points previously added to the CurveFitter, and + * initializes it for a new curve. + */ void CurveFitter:: reset() { _data.erase(_data.begin(), _data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::add_xyz -// Access: Public -// Description: Adds a single sample xyz. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single sample xyz. + */ void CurveFitter:: add_xyz(PN_stdfloat t, const LVecBase3 &xyz) { DataPoint dp; @@ -69,11 +60,9 @@ add_xyz(PN_stdfloat t, const LVecBase3 &xyz) { _got_xyz = true; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::add_hpr -// Access: Public -// Description: Adds a single sample hpr. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single sample hpr. + */ void CurveFitter:: add_hpr(PN_stdfloat t, const LVecBase3 &hpr) { DataPoint dp; @@ -83,11 +72,9 @@ add_hpr(PN_stdfloat t, const LVecBase3 &hpr) { _got_hpr = true; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::add_xyz_hpr -// Access: Public -// Description: Adds a single sample xyz & hpr simultaneously. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single sample xyz & hpr simultaneously. + */ void CurveFitter:: add_xyz_hpr(PN_stdfloat t, const LVecBase3 &xyz, const LVecBase3 &hpr) { DataPoint dp; @@ -99,69 +86,55 @@ add_xyz_hpr(PN_stdfloat t, const LVecBase3 &xyz, const LVecBase3 &hpr) { _got_hpr = true; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::get_num_samples -// Access: Public -// Description: Returns the number of sample points that have been -// added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sample points that have been added. + */ int CurveFitter:: get_num_samples() const { return _data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::get_sample_t -// Access: Public -// Description: Returns the parametric value of the nth sample added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parametric value of the nth sample added. + */ PN_stdfloat CurveFitter:: get_sample_t(int n) const { nassertr(n >= 0 && n < (int)_data.size(), 0.0f); return _data[n]._t; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::get_sample_xyz -// Access: Public -// Description: Returns the point in space of the nth sample added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space of the nth sample added. + */ LVecBase3 CurveFitter:: get_sample_xyz(int n) const { nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._xyz; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::get_sample_hpr -// Access: Public -// Description: Returns the orientation of the nth sample added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the orientation of the nth sample added. + */ LVecBase3 CurveFitter:: get_sample_hpr(int n) const { nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._hpr; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::get_sample_tangent -// Access: Public -// Description: Returns the tangent associated with the nth sample -// added. This is only meaningful if compute_tangents() -// has already been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tangent associated with the nth sample added. This is only + * meaningful if compute_tangents() has already been called. + */ LVecBase3 CurveFitter:: get_sample_tangent(int n) const { nassertr(n >= 0 && n < (int)_data.size(), LVecBase3::zero()); return _data[n]._tangent; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::remove_samples -// Access: Public -// Description: Eliminates all samples from index begin, up to but not -// including index end, from the database. -//////////////////////////////////////////////////////////////////// +/** + * Eliminates all samples from index begin, up to but not including index end, + * from the database. + */ void CurveFitter:: remove_samples(int begin, int end) { begin = max(0, min((int)_data.size(), begin)); @@ -172,14 +145,11 @@ remove_samples(int begin, int end) { _data.erase(_data.begin() + begin, _data.begin() + end); } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::sample -// Access: Public -// Description: Generates a series of data points by sampling the -// given curve (or xyz/hpr curves) the indicated number -// of times. The sampling is made evenly in parametric -// time, and then the timewarps, if any, are applied. -//////////////////////////////////////////////////////////////////// +/** + * Generates a series of data points by sampling the given curve (or xyz/hpr + * curves) the indicated number of times. The sampling is made evenly in + * parametric time, and then the timewarps, if any, are applied. + */ void CurveFitter:: sample(ParametricCurveCollection *curves, int count) { nassertv(curves != (ParametricCurveCollection *)NULL); @@ -208,13 +178,11 @@ sample(ParametricCurveCollection *curves, int count) { -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::wrap_hpr -// Access: Public -// Description: Resets each HPR data point so that the maximum delta -// between any two consecutive points is 180 degrees, -// which should prevent incorrect HPR wrapping. -//////////////////////////////////////////////////////////////////// +/** + * Resets each HPR data point so that the maximum delta between any two + * consecutive points is 180 degrees, which should prevent incorrect HPR + * wrapping. + */ void CurveFitter:: wrap_hpr() { Data::iterator di; @@ -241,25 +209,20 @@ wrap_hpr() { } } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::sort_points -// Access: Public -// Description: Sorts all the data points in order by parametric -// time, in case they were added in an incorrect order. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the data points in order by parametric time, in case they were + * added in an incorrect order. + */ void CurveFitter:: sort_points() { sort(_data.begin(), _data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::desample -// Access: Public -// Description: Removes sample points in order to reduce the -// complexity of a sampled curve. Keeps one out of -// every factor samples. Also keeps the first and the -// last samples. -//////////////////////////////////////////////////////////////////// +/** + * Removes sample points in order to reduce the complexity of a sampled curve. + * Keeps one out of every factor samples. Also keeps the first and the last + * samples. + */ void CurveFitter:: desample(PN_stdfloat factor) { int in, out; @@ -281,15 +244,11 @@ desample(PN_stdfloat factor) { _data.erase(_data.begin() + out, _data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::compute_tangents -// Access: Public -// Description: Once a set of points has been built, and prior to -// calling MakeHermite() or MakeNurbs(), -// ComputeTangents() must be called to set up the -// tangents correctly (unless the tangents were defined -// as the points were added). -//////////////////////////////////////////////////////////////////// +/** + * Once a set of points has been built, and prior to calling MakeHermite() or + * MakeNurbs(), ComputeTangents() must be called to set up the tangents + * correctly (unless the tangents were defined as the points were added). + */ void CurveFitter:: compute_tangents(PN_stdfloat scale) { // If the head and tail points match up, close the curve. @@ -307,9 +266,8 @@ compute_tangents(PN_stdfloat scale) { int i; int len = _data.size(); - // First, get all the points in the middle, excluding endpoints. - // These are handled the same whether we are closing the curve or - // not. + // First, get all the points in the middle, excluding endpoints. These are + // handled the same whether we are closing the curve or not. if (_got_xyz) { for (i = 1; i < len-1; i++) { _data[i]._tangent = @@ -358,12 +316,9 @@ compute_tangents(PN_stdfloat scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::make_hermite -// Access: Public -// Description: Converts the current set of data points into a -// Hermite curve. -//////////////////////////////////////////////////////////////////// +/** + * Converts the current set of data points into a Hermite curve. + */ PT(ParametricCurveCollection) CurveFitter:: make_hermite() const { PT(ParametricCurveCollection) result = new ParametricCurveCollection; @@ -401,17 +356,14 @@ make_hermite() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::make_nurbs -// Access: Public -// Description: Converts the current set of data points into a -// NURBS curve. This gives a smoother curve than -// produced by MakeHermite(). -//////////////////////////////////////////////////////////////////// +/** + * Converts the current set of data points into a NURBS curve. This gives a + * smoother curve than produced by MakeHermite(). + */ PT(ParametricCurveCollection) CurveFitter:: make_nurbs() const { - // We start with the HermiteCurves produced above, then convert them - // to NURBS form. + // We start with the HermiteCurves produced above, then convert them to + // NURBS form. PT(ParametricCurveCollection) hermites = make_hermite(); PT(ParametricCurveCollection) result = new ParametricCurveCollection; @@ -420,22 +372,22 @@ make_nurbs() const { NurbsCurve *nc = new NurbsCurve(*hermites->get_curve(c)); result->add_curve(nc); - // Now we even out the knots to smooth out the curve and make - // everything c2 continuous. + // Now we even out the knots to smooth out the curve and make everything + // c2 continuous. int num_knots = nc->get_num_knots(); - // We expect this to be a 4th order curve, since we just converted - // it from a Hermite. + // We expect this to be a 4th order curve, since we just converted it from + // a Hermite. assert(nc->get_order() == 4); assert(num_knots > 0); - // Now the knot sequence goes something like this: - // 0 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 4 + // Now the knot sequence goes something like this: 0 0 0 0 1 1 1 2 2 2 3 3 + // 3 4 4 4 4 - // We'll consider pairs of knot values beginning at position 3 and - // every third position thereafter. We just even out these values - // between their two neighbors. + // We'll consider pairs of knot values beginning at position 3 and every + // third position thereafter. We just even out these values between their + // two neighbors. int i; PN_stdfloat k1, k2 = nc->get_knot(num_knots-1); @@ -457,21 +409,17 @@ make_nurbs() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CurveFitter:: output(ostream &out) const { out << "CurveFitter, " << _data.size() << " samples.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: CurveFitter::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CurveFitter:: write(ostream &out) const { out << "CurveFitter, " << _data.size() << " samples:\n"; @@ -480,4 +428,3 @@ write(ostream &out) const { out << " " << (*di) << "\n"; } } - diff --git a/panda/src/parametrics/curveFitter.h b/panda/src/parametrics/curveFitter.h index bf6a21c43d..a83778951f 100644 --- a/panda/src/parametrics/curveFitter.h +++ b/panda/src/parametrics/curveFitter.h @@ -1,16 +1,15 @@ -// Filename: curveFitter.h -// Created by: drose (17Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file curveFitter.h + * @author drose + * @date 1998-09-17 + */ #ifndef CURVEFITTER_H #define CURVEFITTER_H @@ -28,10 +27,9 @@ class HermiteCurve; class ParametricCurve; class NurbsCurve; -//////////////////////////////////////////////////////////////////// -// Class : CurveFitter -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_GOBJ CurveFitter { PUBLISHED: CurveFitter(); diff --git a/panda/src/parametrics/hermiteCurve.cxx b/panda/src/parametrics/hermiteCurve.cxx index 447cdbfedc..73931ab001 100644 --- a/panda/src/parametrics/hermiteCurve.cxx +++ b/panda/src/parametrics/hermiteCurve.cxx @@ -1,16 +1,15 @@ -// Filename: hermiteCurve.cxx -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hermiteCurve.cxx + * @author drose + * @date 1998-02-27 + */ #include "pandabase.h" #include "hermiteCurve.h" @@ -28,15 +27,14 @@ TypeHandle HermiteCurve::_type_handle; static const LVecBase3 zerovec_3 = LVecBase3(0.0f, 0.0f, 0.0f); -// This is returned occasionally from some of the functions, and is -// used from time to time as an initializer. +// This is returned occasionally from some of the functions, and is used from +// time to time as an initializer. -//////////////////////////////////////////////////////////////////// -// Function: show_vec3 -// Description: This function writes a LVecBase3, with a specified -// number of significant dimensions. -//////////////////////////////////////////////////////////////////// +/** + * This function writes a LVecBase3, with a specified number of significant + * dimensions. + */ static ostream & show_vec3(ostream &out, int indent_level, const LVecBase3 &v, int num_dimensions) { @@ -47,21 +45,17 @@ show_vec3(ostream &out, int indent_level, const LVecBase3 &v, return out; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HermiteCurveCV:: HermiteCurveCV() { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::copy_constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HermiteCurveCV:: HermiteCurveCV(const HermiteCurveCV &c) : _p(c._p), _in(c._in), _out(c._out), @@ -70,22 +64,18 @@ HermiteCurveCV(const HermiteCurveCV &c) : } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HermiteCurveCV:: ~HermiteCurveCV() { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::set_in -// Access: Public -// Description: Sets the CV's in tangent. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CV's in tangent. + */ void HermiteCurveCV:: set_in(const LVecBase3 &in) { _in = in; @@ -107,11 +97,9 @@ set_in(const LVecBase3 &in) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::set_out -// Access: Public -// Description: Sets the CV's out tangent. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CV's out tangent. + */ void HermiteCurveCV:: set_out(const LVecBase3 &out) { _out = out; @@ -133,18 +121,14 @@ set_out(const LVecBase3 &out) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::set_type -// Access: Public -// Description: Sets the continuity type of the CV. Values may be -// HC_CUT, indicating a discontinous break in the curve, -// HC_FREE, for unconstrained in and out tangents, -// HC_G1, for in and out tangents constrained to be -// collinear, and HC_SMOOTH, for in and out tangents -// constrained to be equal. Other than HC_CUT, these -// are for documentation only; setting this has no -// direct effect on the tangents. -//////////////////////////////////////////////////////////////////// +/** + * Sets the continuity type of the CV. Values may be HC_CUT, indicating a + * discontinous break in the curve, HC_FREE, for unconstrained in and out + * tangents, HC_G1, for in and out tangents constrained to be collinear, and + * HC_SMOOTH, for in and out tangents constrained to be equal. Other than + * HC_CUT, these are for documentation only; setting this has no direct effect + * on the tangents. + */ void HermiteCurveCV:: set_type(int type) { _type = type; @@ -163,22 +147,18 @@ set_type(int type) { -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::set_name -// Access: Public -// Description: Sets the name associated with the CV. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name associated with the CV. + */ void HermiteCurveCV:: set_name(const string &name) { _name = name; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::format_egg -// Access: Public -// Description: Formats the CV for output to an egg file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the CV for output to an egg file. + */ void HermiteCurveCV:: format_egg(ostream &out, int indent_level, int num_dimensions, bool show_in, bool show_out, @@ -223,12 +203,10 @@ format_egg(ostream &out, int indent_level, int num_dimensions, } } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::write_datagram -// Access: Public -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void HermiteCurveCV:: write_datagram(BamWriter *, Datagram &me) const { _p.write_datagram(me); @@ -238,14 +216,11 @@ write_datagram(BamWriter *, Datagram &me) const { me.add_string(_name); } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurveCV::fillin -// Access: Public -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void HermiteCurveCV:: fillin(DatagramIterator &scan, BamReader *) { _p.read_datagram(scan); @@ -256,21 +231,16 @@ fillin(DatagramIterator &scan, BamReader *) { _name = scan.get_string(); } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HermiteCurve:: HermiteCurve() { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::Copy Constructor -// Access: Published -// Description: Constructs a Hermite from the indicated (possibly -// non-hermite) curve. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a Hermite from the indicated (possibly non-hermite) curve. + */ HermiteCurve:: HermiteCurve(const ParametricCurve &nc) { if (!nc.convert_to_hermite(this)) { @@ -281,11 +251,9 @@ HermiteCurve(const ParametricCurve &nc) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HermiteCurve:: ~HermiteCurve() { } @@ -295,33 +263,26 @@ HermiteCurve:: -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_num_cvs -// Access: Published -// Description: Returns the number of CV's in the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of CV's in the curve. + */ int HermiteCurve:: get_num_cvs() const { return _points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::insert_cv -// Access: Published -// Description: Inserts a new CV at the given parametric point along -// the curve. If this parametric point is already on -// the curve, the CV is assigned an index between its -// two neighbors and the indices of all following CV's -// are incremented by 1; its in and out tangents are -// chosen to keep the curve consistent. If the new -// parametric point is beyond the end of the existing -// curve, the curve is extended to meet it and the new -// CV's position, in tangent, and out tangent are set to -// zero. -// -// The index number of the new CV is returned. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a new CV at the given parametric point along the curve. If this + * parametric point is already on the curve, the CV is assigned an index + * between its two neighbors and the indices of all following CV's are + * incremented by 1; its in and out tangents are chosen to keep the curve + * consistent. If the new parametric point is beyond the end of the existing + * curve, the curve is extended to meet it and the new CV's position, in + * tangent, and out tangent are set to zero. + * + * The index number of the new CV is returned. + */ int HermiteCurve:: insert_cv(PN_stdfloat t) { if (!is_valid() || t >= get_max_t()) { @@ -353,13 +314,10 @@ insert_cv(PN_stdfloat t) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::append_cv -// Access: Published -// Description: Adds a new CV to the end of the curve. The new CV is -// given initial in/out tangents of 0. The return value -// is the index of the new CV. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new CV to the end of the curve. The new CV is given initial in/out + * tangents of 0. The return value is the index of the new CV. + */ int HermiteCurve:: append_cv(int type, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { HermiteCurveCV cv; @@ -381,12 +339,10 @@ append_cv(int type, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::remove_cv -// Access: Published -// Description: Removes the given CV from the curve. Returns true if -// the CV existed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the given CV from the curve. Returns true if the CV existed, false + * otherwise. + */ bool HermiteCurve:: remove_cv(int n) { if (n < 0 || n >= (int)_points.size()) { @@ -404,11 +360,9 @@ remove_cv(int n) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::remove_all_cvs -// Access: Published -// Description: Removes all CV's from the curve. -//////////////////////////////////////////////////////////////////// +/** + * Removes all CV's from the curve. + */ void HermiteCurve:: remove_all_cvs() { _points.erase(_points.begin(), _points.end()); @@ -420,23 +374,18 @@ remove_all_cvs() { -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_type -// Access: Published -// Description: Changes the given CV's continuity type. Legal values -// are HC_CUT, HC_FREE, HC_G1, or HC_SMOOTH. -// -// Other than HC_CUT, these have no effect on the actual -// curve; it remains up to user software to impose the -// constraints these imply. -// -// HC_CUT implies a disconnection of the curve; HC_FREE -// imposes no constraints on the tangents; HC_G1 -// forces the tangents to be collinear, and HC_SMOOTH -// forces the tangents to be identical. Setting type -// type to HC_G1 or HC_SMOOTH may adjust the out -// tangent to match the in tangent. -//////////////////////////////////////////////////////////////////// +/** + * Changes the given CV's continuity type. Legal values are HC_CUT, HC_FREE, + * HC_G1, or HC_SMOOTH. + * + * Other than HC_CUT, these have no effect on the actual curve; it remains up + * to user software to impose the constraints these imply. + * + * HC_CUT implies a disconnection of the curve; HC_FREE imposes no constraints + * on the tangents; HC_G1 forces the tangents to be collinear, and HC_SMOOTH + * forces the tangents to be identical. Setting type type to HC_G1 or + * HC_SMOOTH may adjust the out tangent to match the in tangent. + */ bool HermiteCurve:: set_cv_type(int n, int type) { if (n < 0 || n >= (int)_points.size()) { @@ -455,11 +404,9 @@ set_cv_type(int n, int type) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_point -// Access: Published -// Description: Changes the given CV's position. -//////////////////////////////////////////////////////////////////// +/** + * Changes the given CV's position. + */ bool HermiteCurve:: set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { @@ -470,13 +417,10 @@ set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_in -// Access: Published -// Description: Changes the given CV's in tangent. Depending on the -// continuity type, this may also adjust the out -// tangent. -//////////////////////////////////////////////////////////////////// +/** + * Changes the given CV's in tangent. Depending on the continuity type, this + * may also adjust the out tangent. + */ bool HermiteCurve:: set_cv_in(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { @@ -487,13 +431,10 @@ set_cv_in(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_out -// Access: Published -// Description: Changes the given CV's out tangent. Depending on the -// continuity type, this may also adjust the in -// tangent. -//////////////////////////////////////////////////////////////////// +/** + * Changes the given CV's out tangent. Depending on the continuity type, this + * may also adjust the in tangent. + */ bool HermiteCurve:: set_cv_out(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { if (n < 0 || n >= (int)_points.size()) { @@ -504,12 +445,10 @@ set_cv_out(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_tstart -// Access: Published -// Description: Changes the given CV's parametric starting time. -// This may affect the shape of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Changes the given CV's parametric starting time. This may affect the shape + * of the curve. + */ bool HermiteCurve:: set_cv_tstart(int n, PN_stdfloat tstart) { if (n <= 0 || n >= (int)_points.size()) { @@ -524,11 +463,9 @@ set_cv_tstart(int n, PN_stdfloat tstart) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::set_cv_name -// Access: Published -// Description: Changes the name associated with a particular CV. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name associated with a particular CV. + */ bool HermiteCurve:: set_cv_name(int n, const char *name) { if (n < 0 || n >= (int)_points.size()) { @@ -540,13 +477,10 @@ set_cv_name(int n, const char *name) { -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_type -// Access: Published -// Description: Returns the given CV's continuity type, HC_CUT, -// HC_FREE, HC_G1, or HC_SMOOTH, or 0 if there is -// no such CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the given CV's continuity type, HC_CUT, HC_FREE, HC_G1, or + * HC_SMOOTH, or 0 if there is no such CV. + */ int HermiteCurve:: get_cv_type(int n) const { if (n < 0 || n >= (int)_points.size()) { @@ -557,11 +491,9 @@ get_cv_type(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_point -// Access: Published -// Description: Returns the position of the given CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the given CV. + */ const LVecBase3 &HermiteCurve:: get_cv_point(int n) const { if (n < 0 || n >= (int)_points.size()) { @@ -576,11 +508,9 @@ get_cv_point(int n, LVecBase3 &v) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_in -// Access: Published -// Description: Returns the in tangent of the given CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the in tangent of the given CV. + */ const LVecBase3 &HermiteCurve:: get_cv_in(int n) const { if (n < 0 || n >= (int)_points.size() || _points[n-1]._type==HC_CUT) { @@ -595,11 +525,9 @@ get_cv_in(int n, LVecBase3 &v) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_out -// Access: Published -// Description: Returns the out tangent of the given CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the out tangent of the given CV. + */ const LVecBase3 &HermiteCurve:: get_cv_out(int n) const { if (n < 0 || n >= (int)_points.size() || _points[n]._type==HC_CUT) { @@ -614,12 +542,9 @@ get_cv_out(int n, LVecBase3 &v) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_tstart -// Access: Published -// Description: Returns the starting point in parametric space of the -// given CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the starting point in parametric space of the given CV. + */ PN_stdfloat HermiteCurve:: get_cv_tstart(int n) const { if (n<0) { @@ -631,11 +556,9 @@ get_cv_tstart(int n) const { return get_tstart(n); } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::get_cv_name -// Access: Published -// Description: Returns the name of the given CV, or NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the given CV, or NULL. + */ string HermiteCurve:: get_cv_name(int n) const { if (n < 0 || n >= (int)_points.size()) { @@ -646,11 +569,9 @@ get_cv_name(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void HermiteCurve:: output(ostream &out) const { PiecewiseCurve::output(out); @@ -676,11 +597,9 @@ output(ostream &out) const { out << get_num_cvs() << " CV's)"; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::write_cv -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void HermiteCurve:: write_cv(ostream &out, int n) const { out << "CV"; @@ -718,15 +637,12 @@ write_cv(ostream &out, int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::rebuild_curveseg -// Access: Public, Virtual -// Description: Rebuilds the current curve segment (as selected by -// the most recent call to find_curve()) according to -// the specified properties (see -// CubicCurveseg::compute_seg). Returns true if -// possible, false if something goes horribly wrong. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the current curve segment (as selected by the most recent call to + * find_curve()) according to the specified properties (see + * CubicCurveseg::compute_seg). Returns true if possible, false if something + * goes horribly wrong. + */ bool HermiteCurve:: rebuild_curveseg(int, PN_stdfloat, const LVecBase4 &, int, PN_stdfloat, const LVecBase4 &, @@ -736,11 +652,9 @@ rebuild_curveseg(int, PN_stdfloat, const LVecBase4 &, return false; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::format_egg -// Access: Public -// Description: Formats the Hermite curve for output to an Egg file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the Hermite curve for output to an Egg file. + */ bool HermiteCurve:: format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const { @@ -809,12 +723,9 @@ wrap_hpr(const LVecBase3 &hpr1, LVecBase3 &hpr2) { } } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::invalidate_cv -// Access: Protected -// Description: Recomputes the CV and its neighbors appropriately -// after a change. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the CV and its neighbors appropriately after a change. + */ void HermiteCurve:: invalidate_cv(int n, bool redo_all) { PN_stdfloat t1 = 0.0f, t2 = get_max_t(); @@ -855,12 +766,9 @@ invalidate_cv(int n, bool redo_all) { -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::find_cv -// Access: Protected -// Description: Finds the CV immediately preceding the given value of -// t. -//////////////////////////////////////////////////////////////////// +/** + * Finds the CV immediately preceding the given value of t. + */ int HermiteCurve:: find_cv(PN_stdfloat t) { nassertr(is_valid(), 0); @@ -876,14 +784,11 @@ find_cv(PN_stdfloat t) { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::recompute_basis -// Access: Protected -// Description: Recomputes the coefficients for all the CV's in the -// curve. This is intended to be called whenever the -// CV's have been changed in some drastic way, and it's -// safest just to recompute everything. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the coefficients for all the CV's in the curve. This is + * intended to be called whenever the CV's have been changed in some drastic + * way, and it's safest just to recompute everything. + */ void HermiteCurve:: recompute_basis() { int n; @@ -904,22 +809,17 @@ recompute_basis() { } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::register_with_factory -// Access: Public, Static -// Description: Initializes the factory for reading these things from -// Bam files. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the factory for reading these things from Bam files. + */ void HermiteCurve:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_HermiteCurve); } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::make_HermiteCurve -// Access: Protected -// Description: Factory method to generate an object of this type. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an object of this type. + */ TypedWritable *HermiteCurve:: make_HermiteCurve(const FactoryParams ¶ms) { HermiteCurve *me = new HermiteCurve; @@ -931,12 +831,10 @@ make_HermiteCurve(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::write_datagram -// Access: Protected, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void HermiteCurve:: write_datagram(BamWriter *manager, Datagram &me) { PiecewiseCurve::write_datagram(manager, me); @@ -948,14 +846,11 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: HermiteCurve::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void HermiteCurve:: fillin(DatagramIterator &scan, BamReader *manager) { PiecewiseCurve::fillin(scan, manager); diff --git a/panda/src/parametrics/hermiteCurve.h b/panda/src/parametrics/hermiteCurve.h index ea45316f87..806ab47ff1 100644 --- a/panda/src/parametrics/hermiteCurve.h +++ b/panda/src/parametrics/hermiteCurve.h @@ -1,16 +1,15 @@ -// Filename: hermiteCurve.h -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file hermiteCurve.h + * @author drose + * @date 1998-02-27 + */ #ifndef HERMITECURVE_H #define HERMITECURVE_H @@ -22,33 +21,32 @@ BEGIN_PUBLISH //[ // Hermite curve continuity types. #define HC_CUT 1 -// The curve is disconnected at this point. All points between -// this and the following CV are not part of the curve. +// The curve is disconnected at this point. All points between this and the +// following CV are not part of the curve. #define HC_FREE 2 // Tangents are unconstrained. The curve is continuous, but its first // derivative is not. This is G0 geometric continuity. #define HC_G1 3 -// Tangents are constrained to be collinear. The curve's derivative -// is not continuous in parametric space, but its geometric slope is. -// The distinction is mainly relevant in the context of animation -// along the curve--when crossing the join point, direction of motion -// will change continuously, but the speed of motion may change -// suddenly. This is G1 geometric continuity. +// Tangents are constrained to be collinear. The curve's derivative is not +// continuous in parametric space, but its geometric slope is. The +// distinction is mainly relevant in the context of animation along the curve +// --when crossing the join point, direction of motion will change +// continuously, but the speed of motion may change suddenly. This is G1 +// geometric continuity. #define HC_SMOOTH 4 // Tangents are constrained to be identical. The curve and its first -// derivative are continuous in parametric space. When animating -// motion across the join point, speed and direction of motion will -// change continuously. This is C1 parametric continuity. +// derivative are continuous in parametric space. When animating motion +// across the join point, speed and direction of motion will change +// continuously. This is C1 parametric continuity. END_PUBLISH //] -//////////////////////////////////////////////////////////////////// -// Class : HermiteCurveCV -// Description : A single CV of a Hermite curve. Hermite curve CV's -// include an in and out tangent, as well as a position. -//////////////////////////////////////////////////////////////////// +/** + * A single CV of a Hermite curve. Hermite curve CV's include an in and out + * tangent, as well as a position. + */ class EXPCL_PANDA_PARAMETRICS HermiteCurveCV { public: HermiteCurveCV(); @@ -73,18 +71,15 @@ public: string _name; }; -//////////////////////////////////////////////////////////////////// -// Class : HermiteCurve -// Description : A parametric curve defined by a sequence of control -// vertices, each with an in and out tangent. -// -// This class is actually implemented as a -// PiecewiseCurve made up of several CubicCurvesegs, -// each of which is created using the hermite_basis() -// method. The HermiteCurve class itself keeps its own -// list of the CV's that are used to define the curve -// (since the CubicCurveseg class doesn't retain these). -//////////////////////////////////////////////////////////////////// +/** + * A parametric curve defined by a sequence of control vertices, each with an + * in and out tangent. + * + * This class is actually implemented as a PiecewiseCurve made up of several + * CubicCurvesegs, each of which is created using the hermite_basis() method. + * The HermiteCurve class itself keeps its own list of the CV's that are used + * to define the curve (since the CubicCurveseg class doesn't retain these). + */ class EXPCL_PANDA_PARAMETRICS HermiteCurve : public PiecewiseCurve { PUBLISHED: HermiteCurve(); diff --git a/panda/src/parametrics/nurbsBasisVector.I b/panda/src/parametrics/nurbsBasisVector.I index 93873044c5..d7b207b38a 100644 --- a/panda/src/parametrics/nurbsBasisVector.I +++ b/panda/src/parametrics/nurbsBasisVector.I @@ -1,137 +1,109 @@ -// Filename: nurbsBasisVector.I -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsBasisVector.I + * @author drose + * @date 2002-12-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsBasisVector:: NurbsBasisVector() { _order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsBasisVector:: ~NurbsBasisVector() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_order -// Access: Public -// Description: Returns the order of the segments in the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the segments in the curve. + */ INLINE int NurbsBasisVector:: get_order() const { return _order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_num_segments -// Access: Public -// Description: Returns the number of piecewise continuous segments -// in the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments in the curve. + */ INLINE int NurbsBasisVector:: get_num_segments() const { return _segments.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_start_t -// Access: Public -// Description: Returns the first legal value of t on the curve. -// Usually this is 0.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first legal value of t on the curve. Usually this is 0.0. + */ INLINE PN_stdfloat NurbsBasisVector:: get_start_t() const { nassertr(!_segments.empty(), 0.0f); return _segments.front()._from; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_end_t -// Access: Public -// Description: Returns the last legal value of t on the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last legal value of t on the curve. + */ INLINE PN_stdfloat NurbsBasisVector:: get_end_t() const { nassertr(!_segments.empty(), 0.0f); return _segments.back()._to; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_vertex_index -// Access: Public -// Description: Returns the vertex index of the nth segment. This is -// the index number of the first associated control -// vertex within the source NurbsCurveEvaluator object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex index of the nth segment. This is the index number of + * the first associated control vertex within the source NurbsCurveEvaluator + * object. + */ INLINE int NurbsBasisVector:: get_vertex_index(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0); return _segments[segment]._vertex_index; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_from -// Access: Public -// Description: Returns the t value of the beginning of this segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the t value of the beginning of this segment. + */ INLINE PN_stdfloat NurbsBasisVector:: get_from(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); return _segments[segment]._from; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_to -// Access: Public -// Description: Returns the t value of the end of this segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the t value of the end of this segment. + */ INLINE PN_stdfloat NurbsBasisVector:: get_to(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); return _segments[segment]._to; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::get_basis -// Access: Public -// Description: Returns the basis matrix associated with the nth -// segment. This is the pure matrix based on the knot -// vector over the segment; it does not depend on the -// control vertices. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basis matrix associated with the nth segment. This is the pure + * matrix based on the knot vector over the segment; it does not depend on the + * control vertices. + */ INLINE const LMatrix4 &NurbsBasisVector:: get_basis(int segment) const { nassertr(segment >= 0 && segment < (int)_segments.size(), LMatrix4::ident_mat()); return _segments[segment]._basis; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::scale_t -// Access: Public -// Description: Scales the value of t into the range [0, 1] -// corresponding to [from, to]. Returns the scaled -// value. -//////////////////////////////////////////////////////////////////// +/** + * Scales the value of t into the range [0, 1] corresponding to [from, to]. + * Returns the scaled value. + */ INLINE PN_stdfloat NurbsBasisVector:: scale_t(int segment, PN_stdfloat t) const { nassertr(segment >= 0 && segment < (int)_segments.size(), 0.0f); diff --git a/panda/src/parametrics/nurbsBasisVector.cxx b/panda/src/parametrics/nurbsBasisVector.cxx index 294e89a09e..2bdb09b8b9 100644 --- a/panda/src/parametrics/nurbsBasisVector.cxx +++ b/panda/src/parametrics/nurbsBasisVector.cxx @@ -1,36 +1,31 @@ -// Filename: nurbsBasisVector.cxx -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsBasisVector.cxx + * @author drose + * @date 2002-12-03 + */ #include "nurbsBasisVector.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::clear -// Access: Public -// Description: Removes all the segments from the curve. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the segments from the curve. + */ void NurbsBasisVector:: clear(int order) { _order = order; _segments.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::append_segment -// Access: Public -// Description: Computes a NURBS basis for one segment of the curve -// and appends it to the set of basis matrices. -//////////////////////////////////////////////////////////////////// +/** + * Computes a NURBS basis for one segment of the curve and appends it to the + * set of basis matrices. + */ void NurbsBasisVector:: append_segment(int vertex_index, const PN_stdfloat knots[]) { int i; @@ -62,11 +57,9 @@ append_segment(int vertex_index, const PN_stdfloat knots[]) { _segments.push_back(segment); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::transpose -// Access: Public -// Description: Transposes the basis matrices stored in the vector. -//////////////////////////////////////////////////////////////////// +/** + * Transposes the basis matrices stored in the vector. + */ void NurbsBasisVector:: transpose() { Segments::iterator si; @@ -75,12 +68,10 @@ transpose() { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsBasisVector::nurbs_blending_function -// Access: Private, Static -// Description: Recursively computes the appropriate blending -// function for the indicated knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Recursively computes the appropriate blending function for the indicated + * knot vector. + */ LVecBase4 NurbsBasisVector:: nurbs_blending_function(int order, int i, int j, const PN_stdfloat knots[]) { // This is doubly recursive. Ick. diff --git a/panda/src/parametrics/nurbsBasisVector.h b/panda/src/parametrics/nurbsBasisVector.h index 9324f3c447..6e414fdcbd 100644 --- a/panda/src/parametrics/nurbsBasisVector.h +++ b/panda/src/parametrics/nurbsBasisVector.h @@ -1,16 +1,15 @@ -// Filename: nurbsBasisVector.h -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsBasisVector.h + * @author drose + * @date 2002-12-03 + */ #ifndef NURBSBASISVECTOR_H #define NURBSBASISVECTOR_H @@ -22,18 +21,15 @@ class NurbsVertex; -//////////////////////////////////////////////////////////////////// -// Class : NurbsBasisVector -// Description : This encapsulates a series of matrices that are used -// to represent the sequential segments of a -// NurbsCurveEvaluator. -// -// This is not related to NurbsCurve, CubicCurveseg or -// any of the ParametricCurve-derived objects in this -// module. It is a completely parallel implementation -// of NURBS curves, and will probably eventually replace -// the whole ParametricCurve class hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This encapsulates a series of matrices that are used to represent the + * sequential segments of a NurbsCurveEvaluator. + * + * This is not related to NurbsCurve, CubicCurveseg or any of the + * ParametricCurve-derived objects in this module. It is a completely + * parallel implementation of NURBS curves, and will probably eventually + * replace the whole ParametricCurve class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS NurbsBasisVector { public: INLINE NurbsBasisVector(); @@ -57,7 +53,7 @@ public: void transpose(); private: - static LVecBase4 nurbs_blending_function(int order, int i, int j, + static LVecBase4 nurbs_blending_function(int order, int i, int j, const PN_stdfloat knots[]); private: @@ -78,4 +74,3 @@ private: #include "nurbsBasisVector.I" #endif - diff --git a/panda/src/parametrics/nurbsCurve.I b/panda/src/parametrics/nurbsCurve.I index c424e9ac8c..19e65bc91f 100644 --- a/panda/src/parametrics/nurbsCurve.I +++ b/panda/src/parametrics/nurbsCurve.I @@ -1,23 +1,19 @@ -// Filename: nurbsCurve.I -// Created by: drose (02Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurve.I + * @author drose + * @date 2001-03-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_curveseg -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CubicCurveseg *NurbsCurve:: get_curveseg(int ti) { return (CubicCurveseg *)PiecewiseCurve::get_curveseg(ti); diff --git a/panda/src/parametrics/nurbsCurve.cxx b/panda/src/parametrics/nurbsCurve.cxx index 42f76e4bf7..060fe385d2 100644 --- a/panda/src/parametrics/nurbsCurve.cxx +++ b/panda/src/parametrics/nurbsCurve.cxx @@ -1,16 +1,15 @@ -// Filename: nurbsCurve.cxx -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurve.cxx + * @author drose + * @date 1998-02-27 + */ #include "nurbsCurve.h" #include "config_parametrics.h" @@ -24,22 +23,18 @@ TypeHandle NurbsCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsCurve:: NurbsCurve() { _order = 4; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::Copy Constructor -// Access: Published -// Description: Constructs a NURBS curve equivalent to the indicated -// (possibly non-NURBS) curve. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a NURBS curve equivalent to the indicated (possibly non-NURBS) + * curve. + */ NurbsCurve:: NurbsCurve(const ParametricCurve &pc) { _order = 4; @@ -50,12 +45,9 @@ NurbsCurve(const ParametricCurve &pc) { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::Constructor -// Access: Published -// Description: Constructs a NURBS curve according to the indicated -// NURBS parameters. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a NURBS curve according to the indicated NURBS parameters. + */ NurbsCurve:: NurbsCurve(int order, int num_cvs, const PN_stdfloat knots[], const LVecBase4 cvs[]) { @@ -75,35 +67,27 @@ NurbsCurve(int order, int num_cvs, recompute(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsCurve:: ~NurbsCurve() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *NurbsCurve:: make_copy() const { return new NurbsCurve(*this); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::set_order -// Access: Published, Virtual -// Description: Changes the order of the curve. Must be a value from -// 1 to 4. Can only be done when there are no cv's. -//////////////////////////////////////////////////////////////////// +/** + * Changes the order of the curve. Must be a value from 1 to 4. Can only be + * done when there are no cv's. + */ void NurbsCurve:: set_order(int order) { nassertv(order >= 1 && order <= 4); @@ -112,31 +96,25 @@ set_order(int order) { _order = order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_order -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int NurbsCurve:: get_order() const { return _order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_num_cvs -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int NurbsCurve:: get_num_cvs() const { return _cvs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_num_knots -// Access: Published, Virtual -// Description: Returns the number of knots on the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knots on the curve. + */ int NurbsCurve:: get_num_knots() const { return _cvs.size() + _order; @@ -144,16 +122,12 @@ get_num_knots() const { -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::insert_cv -// Access: Published, Virtual -// Description: Inserts a new CV into the middle of the curve at the -// indicated parametric value. This doesn't change the -// shape or timing of the curve; however, it is -// irreversible: if the new CV is immediately removed, -// the curve will be changed. Returns true if -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a new CV into the middle of the curve at the indicated parametric + * value. This doesn't change the shape or timing of the curve; however, it + * is irreversible: if the new CV is immediately removed, the curve will be + * changed. Returns true if successful, false otherwise. + */ bool NurbsCurve:: insert_cv(PN_stdfloat t) { if (_cvs.empty()) { @@ -171,11 +145,11 @@ insert_cv(PN_stdfloat t) { return true; } - // Now we are inserting a knot between k-1 and k. We'll adjust the - // CV's according to Bohm's rule. + // Now we are inserting a knot between k-1 and k. We'll adjust the CV's + // according to Bohm's rule. - // First, get the new values of all the CV's that will change. - // These are the CV's in the range [k - (_order-1), k-1]. + // First, get the new values of all the CV's that will change. These are + // the CV's in the range [k - (_order-1), k-1]. LVecBase4 new_cvs[3]; int i; @@ -206,12 +180,10 @@ insert_cv(PN_stdfloat t) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::remove_cv -// Access: Published, Virtual -// Description: Removes the indicated CV from the curve. Returns -// true if the CV index was valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated CV from the curve. Returns true if the CV index was + * valid, false otherwise. + */ bool NurbsCurve:: remove_cv(int n) { if (n < 0 || n >= (int)_cvs.size()) { @@ -222,23 +194,18 @@ remove_cv(int n) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::remove_all_cvs -// Access: Published, Virtual -// Description: Removes all CV's from the curve. -//////////////////////////////////////////////////////////////////// +/** + * Removes all CV's from the curve. + */ void NurbsCurve:: remove_all_cvs() { _cvs.erase(_cvs.begin(), _cvs.end()); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::set_cv -// Access: Published, Virtual -// Description: Repositions the indicated CV. Returns true if -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the indicated CV. Returns true if successful, false otherwise. + */ bool NurbsCurve:: set_cv(int n, const LVecBase4 &v) { nassertr(n >= 0 && n < get_num_cvs(), false); @@ -247,12 +214,9 @@ set_cv(int n, const LVecBase4 &v) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_cv -// Access: Published, Virtual -// Description: Returns the position in homogeneous space of the -// indicated CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position in homogeneous space of the indicated CV. + */ LVecBase4 NurbsCurve:: get_cv(int n) const { nassertr(n >= 0 && n < get_num_cvs(), LVecBase4::zero()); @@ -261,15 +225,12 @@ get_cv(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::set_knot -// Access: Published, Virtual -// Description: Sets the value of the indicated knot. There are -// get_num_cvs() + _order knot values, but the first -// _order - 1 and the last 1 knot values cannot be -// changed. It is also an error to set a knot value -// outside the range of its neighbors. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the indicated knot. There are get_num_cvs() + _order + * knot values, but the first _order - 1 and the last 1 knot values cannot be + * changed. It is also an error to set a knot value outside the range of its + * neighbors. + */ bool NurbsCurve:: set_knot(int n, PN_stdfloat t) { nassertr(n >= 0 && n < get_num_knots(), false); @@ -281,11 +242,9 @@ set_knot(int n, PN_stdfloat t) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_knot -// Access: Published, Virtual -// Description: Retrieves the value of the indicated knot. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value of the indicated knot. + */ PN_stdfloat NurbsCurve:: get_knot(int n) const { if (n < _order || _cvs.empty()) { @@ -298,16 +257,12 @@ get_knot(int n) const { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::recompute -// Access: Published, Virtual -// Description: Recalculates the curve basis according to the latest -// position of the CV's, knots, etc. Until this -// function is called, adjusting the NURBS parameters -// will have no visible effect on the curve. Returns -// true if the resulting curve is valid, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the curve basis according to the latest position of the CV's, + * knots, etc. Until this function is called, adjusting the NURBS parameters + * will have no visible effect on the curve. Returns true if the resulting + * curve is valid, false otherwise. + */ bool NurbsCurve:: recompute() { _segs.erase(_segs.begin(), _segs.end()); @@ -319,8 +274,8 @@ recompute() { for (int cv = 0; cv < (int)_cvs.size()-(_order-1); cv++) { if (get_knot(cv+_order-1) < get_knot(cv+_order)) { // There are _order consecutive CV's that define each segment, - // beginning at cv. Collect the CV's and knot values that define - // this segment. + // beginning at cv. Collect the CV's and knot values that define this + // segment. int c; for (c = 0; c < _order; c++) { cvs[c] = _cvs[c+cv]._p; @@ -338,15 +293,12 @@ recompute() { return !_segs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::rebuild_curveseg -// Access: Public, Virtual -// Description: Rebuilds the current curve segment (as selected by -// the most recent call to find_curve()) according to -// the specified properties (see -// CubicCurveseg::compute_seg). Returns true if -// possible, false if something goes horribly wrong. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the current curve segment (as selected by the most recent call to + * find_curve()) according to the specified properties (see + * CubicCurveseg::compute_seg). Returns true if possible, false if something + * goes horribly wrong. + */ bool NurbsCurve:: rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, int rtype1, PN_stdfloat t1, const LVecBase4 &v1, @@ -402,8 +354,8 @@ rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, return false; } - // Now extract the new CV's from the new G matrix, and restore them - // to the curve. + // Now extract the new CV's from the new G matrix, and restore them to the + // curve. for (c = 0; c < _order; c++) { _cvs[c+cv]._p = G.get_col(c); } @@ -411,21 +363,18 @@ rebuild_curveseg(int rtype0, PN_stdfloat t0, const LVecBase4 &v0, return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::stitch -// Access: Published, Virtual -// Description: Regenerates this curve as one long curve: the first -// curve connected end-to-end with the second one. -// Either a or b may be the same as 'this'. -// -// Returns true if successful, false on failure or if -// the curve type does not support stitching. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates this curve as one long curve: the first curve connected end-to- + * end with the second one. Either a or b may be the same as 'this'. + * + * Returns true if successful, false on failure or if the curve type does not + * support stitching. + */ bool NurbsCurve:: stitch(const ParametricCurve *a, const ParametricCurve *b) { - // First, make a copy of both of our curves. This ensures they are - // of the correct type, and also protects us in case one of them is - // the same as 'this'. + // First, make a copy of both of our curves. This ensures they are of the + // correct type, and also protects us in case one of them is the same as + // 'this'. PT(NurbsCurve) na = new NurbsCurve(*a); PT(NurbsCurve) nb = new NurbsCurve(*b); @@ -439,8 +388,7 @@ stitch(const ParametricCurve *a, const ParametricCurve *b) { return false; } - // First, translate curve B to move its first CV to curve A's last - // CV. + // First, translate curve B to move its first CV to curve A's last CV. LVecBase3 point_offset = na->get_cv_point(na->get_num_cvs() - 1) - nb->get_cv_point(0); int num_b_cvs = nb->get_num_cvs(); @@ -469,73 +417,57 @@ stitch(const ParametricCurve *a, const ParametricCurve *b) { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::get_nurbs_interface -// Access: Public, Virtual -// Description: Returns a pointer to the object as a -// NurbsCurveInterface object if it happens to be a -// NURBS-style curve; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the object as a NurbsCurveInterface object if it + * happens to be a NURBS-style curve; otherwise, returns NULL. + */ NurbsCurveInterface *NurbsCurve:: get_nurbs_interface() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::convert_to_nurbs -// Access: Public, Virtual -// Description: Stores in the indicated NurbsCurve a NURBS -// representation of an equivalent curve. Returns true -// if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Stores in the indicated NurbsCurve a NURBS representation of an equivalent + * curve. Returns true if successful, false otherwise. + */ bool NurbsCurve:: convert_to_nurbs(ParametricCurve *nc) const { nc->set_curve_type(_curve_type); return NurbsCurveInterface::convert_to_nurbs(nc); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NurbsCurve:: write(ostream &out, int indent_level) const { NurbsCurveInterface::write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::append_cv_impl -// Access: Protected, Virtual -// Description: Adds a new CV to the end of the curve. Creates a new -// knot value by adding 1 to the last knot value. -// Returns the index of the new CV. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new CV to the end of the curve. Creates a new knot value by adding + * 1 to the last knot value. Returns the index of the new CV. + */ int NurbsCurve:: append_cv_impl(const LVecBase4 &v) { _cvs.push_back(CV(v, get_knot(_cvs.size())+1.0f)); return _cvs.size()-1; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::format_egg -// Access: Protected, Virtual -// Description: Formats the curve as an egg structure to write to the -// indicated stream. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Formats the curve as an egg structure to write to the indicated stream. + * Returns true on success, false on failure. + */ bool NurbsCurve:: format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const { return NurbsCurveInterface::format_egg(out, name, curve_type, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::find_cv -// Access: Protected -// Description: Finds the first knot whose value is >= t, or -1 if t -// is beyond the end of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Finds the first knot whose value is >= t, or -1 if t is beyond the end of + * the curve. + */ int NurbsCurve:: find_cv(PN_stdfloat t) { int i; @@ -548,22 +480,17 @@ find_cv(PN_stdfloat t) { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::register_with_read_factory -// Access: Public, Static -// Description: Initializes the factory for reading these things from -// Bam files. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the factory for reading these things from Bam files. + */ void NurbsCurve:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_NurbsCurve); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::make_NurbsCurve -// Access: Protected -// Description: Factory method to generate an object of this type. -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate an object of this type. + */ TypedWritable *NurbsCurve:: make_NurbsCurve(const FactoryParams ¶ms) { NurbsCurve *me = new NurbsCurve; @@ -575,12 +502,10 @@ make_NurbsCurve(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::write_datagram -// Access: Protected, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void NurbsCurve:: write_datagram(BamWriter *manager, Datagram &me) { PiecewiseCurve::write_datagram(manager, me); @@ -596,14 +521,11 @@ write_datagram(BamWriter *manager, Datagram &me) { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurve::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void NurbsCurve:: fillin(DatagramIterator &scan, BamReader *manager) { PiecewiseCurve::fillin(scan, manager); diff --git a/panda/src/parametrics/nurbsCurve.h b/panda/src/parametrics/nurbsCurve.h index de1bccf396..689717e47a 100644 --- a/panda/src/parametrics/nurbsCurve.h +++ b/panda/src/parametrics/nurbsCurve.h @@ -1,16 +1,15 @@ -// Filename: nurbsCurve.h -// Created by: drose (27Feb98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurve.h + * @author drose + * @date 1998-02-27 + */ #ifndef NURBSCURVE_H #define NURBSCURVE_H @@ -22,29 +21,23 @@ #include "cubicCurveseg.h" #include "epvector.h" -//////////////////////////////////////////////////////////////////// -// Class : NurbsCurve -// Description : A Nonuniform Rational B-Spline. -// -// This class is actually implemented as a -// PiecewiseCurve made up of several CubicCurvesegs, -// each of which is created using the nurbs_basis() -// method. The list of CV's and knots is kept here, -// within the NurbsCurve class. -// -// This class is the original Panda-native -// implementation of a NURBS curve. It is typedeffed as -// "NurbsCurve" and performs all NURBS curve functions -// if we do not have the NURBS++ library available. -// -// However, if we *do* have the NURBS++ library, another -// class exists, the NurbsPPCurve, which is a wrapper -// around that library and provides some additional -// functionality. In that case, the other class is -// typedeffed to "NurbsCurve" instead of this one, and -// performs most of the NURBS curve functions. This -// class then becomes vestigial. -//////////////////////////////////////////////////////////////////// +/** + * A Nonuniform Rational B-Spline. + * + * This class is actually implemented as a PiecewiseCurve made up of several + * CubicCurvesegs, each of which is created using the nurbs_basis() method. + * The list of CV's and knots is kept here, within the NurbsCurve class. + * + * This class is the original Panda-native implementation of a NURBS curve. + * It is typedeffed as "NurbsCurve" and performs all NURBS curve functions if + * we do not have the NURBS++ library available. + * + * However, if we *do* have the NURBS++ library, another class exists, the + * NurbsPPCurve, which is a wrapper around that library and provides some + * additional functionality. In that case, the other class is typedeffed to + * "NurbsCurve" instead of this one, and performs most of the NURBS curve + * functions. This class then becomes vestigial. + */ class EXPCL_PANDA_PARAMETRICS NurbsCurve : public PiecewiseCurve, public NurbsCurveInterface { PUBLISHED: NurbsCurve(); @@ -58,8 +51,8 @@ PUBLISHED: public: virtual PandaNode *make_copy() const; - // We don't need to re-publish these, since they're all published - // from NurbsCurveInterface. + // We don't need to re-publish these, since they're all published from + // NurbsCurveInterface. virtual void set_order(int order); virtual int get_order() const; diff --git a/panda/src/parametrics/nurbsCurveEvaluator.I b/panda/src/parametrics/nurbsCurveEvaluator.I index 71fd9b1a48..a85ecaad69 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.I +++ b/panda/src/parametrics/nurbsCurveEvaluator.I @@ -1,28 +1,23 @@ -// Filename: nurbsCurveEvaluator.I -// Created by: drose (05Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveEvaluator.I + * @author drose + * @date 2002-12-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_order -// Access: Published -// Description: Sets the order of the curve. This resets the knot -// vector to the default knot vector for the number of -// vertices. -// -// The order must be 1, 2, 3, or 4, and the value is one -// more than the degree of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Sets the order of the curve. This resets the knot vector to the default + * knot vector for the number of vertices. + * + * The order must be 1, 2, 3, or 4, and the value is one more than the degree + * of the curve. + */ INLINE void NurbsCurveEvaluator:: set_order(int order) { _order = order; @@ -30,76 +25,60 @@ set_order(int order) { _basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_order -// Access: Published -// Description: Returns the order of the curve as set by a previous -// call to set_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the curve as set by a previous call to set_order(). + */ INLINE int NurbsCurveEvaluator:: get_order() const { return _order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_num_vertices -// Access: Published -// Description: Returns the number of control vertices in the curve. -// This is the number passed to the last call to -// reset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control vertices in the curve. This is the number + * passed to the last call to reset(). + */ INLINE int NurbsCurveEvaluator:: get_num_vertices() const { return (int)_vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_vertex -// Access: Published -// Description: Sets the nth control vertex of the curve, as a vertex -// in 4-d homogeneous space. In this form, the first -// three components of the vertex should already have -// been scaled by the fourth component, which is the -// homogeneous weight. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth control vertex of the curve, as a vertex in 4-d homogeneous + * space. In this form, the first three components of the vertex should + * already have been scaled by the fourth component, which is the homogeneous + * weight. + */ INLINE void NurbsCurveEvaluator:: set_vertex(int i, const LVecBase4 &vertex) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_vertex(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_vertex -// Access: Published -// Description: Sets the nth control vertex of the curve. This -// flavor sets the vertex as a 3-d coordinate and a -// weight; the 3-d coordinate values are implicitly -// scaled up by the weight factor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth control vertex of the curve. This flavor sets the vertex as a + * 3-d coordinate and a weight; the 3-d coordinate values are implicitly + * scaled up by the weight factor. + */ INLINE void NurbsCurveEvaluator:: set_vertex(int i, const LVecBase3 &vertex, PN_stdfloat weight) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_vertex(LVecBase4(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_vertex -// Access: Published -// Description: Returns the nth control vertex of the curve, relative -// to its indicated coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth control vertex of the curve, relative to its indicated + * coordinate space. + */ INLINE const LVecBase4 &NurbsCurveEvaluator:: get_vertex(int i) const { nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4::zero()); return _vertices[i].get_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_vertex -// Access: Published -// Description: Returns the nth control vertex of the curve, relative -// to the given coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth control vertex of the curve, relative to the given + * coordinate space. + */ INLINE LVecBase4 NurbsCurveEvaluator:: get_vertex(int i, const NodePath &rel_to) const { nassertr(i >= 0 && i < (int)_vertices.size(), LVecBase4::zero()); @@ -114,102 +93,80 @@ get_vertex(int i, const NodePath &rel_to) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_vertex_space -// Access: Published -// Description: Sets the coordinate space of the nth control vertex. -// If this is not specified, or is set to an empty -// NodePath, the nth control vertex is deemed to be in -// the coordinate space passed to evaluate(). -// -// This specifies the space as a fixed NodePath, which -// is always the same NodePath. Also see setting the -// space as a path string, which can specify a different -// NodePath for different instances of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coordinate space of the nth control vertex. If this is not + * specified, or is set to an empty NodePath, the nth control vertex is deemed + * to be in the coordinate space passed to evaluate(). + * + * This specifies the space as a fixed NodePath, which is always the same + * NodePath. Also see setting the space as a path string, which can specify a + * different NodePath for different instances of the curve. + */ INLINE void NurbsCurveEvaluator:: set_vertex_space(int i, const NodePath &space) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_space(space); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_vertex_space -// Access: Published -// Description: Sets the coordinate space of the nth control vertex. -// If this is not specified, or is set to an empty -// string, the nth control vertex is deemed to be in -// the coordinate space passed to evaluate(). -// -// This specifies the space as a string, which describes -// the path to find the node relative to the rel_to -// NodePath when the curve is evaluated. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coordinate space of the nth control vertex. If this is not + * specified, or is set to an empty string, the nth control vertex is deemed + * to be in the coordinate space passed to evaluate(). + * + * This specifies the space as a string, which describes the path to find the + * node relative to the rel_to NodePath when the curve is evaluated. + */ INLINE void NurbsCurveEvaluator:: set_vertex_space(int i, const string &space) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_space(space); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_extended_vertex -// Access: Public -// Description: Sets an n-dimensional vertex value. This allows -// definition of a NURBS surface or curve in a sparse -// n-dimensional space, typically used for associating -// additional properties (like color or joint -// membership) with each vertex of a surface. -// -// The value d is an arbitrary integer value and -// specifies the dimension of question for this -// particular vertex. Any number of dimensions may be -// specified, and they need not be consecutive. If a -// value for a given dimension is not specified, is it -// implicitly 0.0. -// -// The value is implicitly scaled by the homogenous -// weight value--that is, the fourth component of the -// value passed to set_vertex(). This means the -// ordinary vertex must be set first, before the -// extended vertices can be set. -//////////////////////////////////////////////////////////////////// +/** + * Sets an n-dimensional vertex value. This allows definition of a NURBS + * surface or curve in a sparse n-dimensional space, typically used for + * associating additional properties (like color or joint membership) with + * each vertex of a surface. + * + * The value d is an arbitrary integer value and specifies the dimension of + * question for this particular vertex. Any number of dimensions may be + * specified, and they need not be consecutive. If a value for a given + * dimension is not specified, is it implicitly 0.0. + * + * The value is implicitly scaled by the homogenous weight value--that is, the + * fourth component of the value passed to set_vertex(). This means the + * ordinary vertex must be set first, before the extended vertices can be set. + */ INLINE void NurbsCurveEvaluator:: set_extended_vertex(int i, int d, PN_stdfloat value) { nassertv(i >= 0 && i < (int)_vertices.size()); _vertices[i].set_extended_vertex(d, value); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_extended_vertex -// Access: Public -// Description: Returns an n-dimensional vertex value. See -// set_extended_vertex(). This returns the value set -// for the indicated dimension, or 0.0 if nothing has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an n-dimensional vertex value. See set_extended_vertex(). This + * returns the value set for the indicated dimension, or 0.0 if nothing has + * been set. + */ INLINE PN_stdfloat NurbsCurveEvaluator:: get_extended_vertex(int i, int d) const { nassertr(i >= 0 && i < (int)_vertices.size(), 0.0f); return _vertices[i].get_extended_vertex(d); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_num_knots -// Access: Published -// Description: Returns the number of knot values in the curve. This -// is based on the number of vertices and the order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knot values in the curve. This is based on the + * number of vertices and the order. + */ INLINE int NurbsCurveEvaluator:: get_num_knots() const { return (int)_vertices.size() + _order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_num_segments -// Access: Published -// Description: Returns the number of piecewise continuous segments -// in the curve. This is based on the knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments in the curve. This is + * based on the knot vector. + */ INLINE int NurbsCurveEvaluator:: get_num_segments() const { if (_basis_dirty) { diff --git a/panda/src/parametrics/nurbsCurveEvaluator.cxx b/panda/src/parametrics/nurbsCurveEvaluator.cxx index 62af13e595..d04df9ab9e 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.cxx +++ b/panda/src/parametrics/nurbsCurveEvaluator.cxx @@ -1,24 +1,21 @@ -// Filename: nurbsCurveEvaluator.cxx -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveEvaluator.cxx + * @author drose + * @date 2002-12-03 + */ #include "nurbsCurveEvaluator.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsCurveEvaluator:: NurbsCurveEvaluator() { _order = 4; @@ -26,24 +23,18 @@ NurbsCurveEvaluator() { _basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsCurveEvaluator:: ~NurbsCurveEvaluator() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::reset -// Access: Published -// Description: Resets all the vertices and knots to their default -// values, and sets the curve up with the indicated -// number of vertices. You must then call set_vertex() -// repeatedly to fill in all of the vertex values -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Resets all the vertices and knots to their default values, and sets the + * curve up with the indicated number of vertices. You must then call + * set_vertex() repeatedly to fill in all of the vertex values appropriately. + */ void NurbsCurveEvaluator:: reset(int num_vertices) { _vertices.clear(); @@ -56,12 +47,10 @@ reset(int num_vertices) { _basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_vertex_space -// Access: Published -// Description: Returns the coordinate space of the nth control -// vertex of the curve, expressed as a NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate space of the nth control vertex of the curve, + * expressed as a NodePath. + */ NodePath NurbsCurveEvaluator:: get_vertex_space(int i, const NodePath &rel_to) const { #ifndef NDEBUG @@ -71,15 +60,12 @@ get_vertex_space(int i, const NodePath &rel_to) const { return _vertices[i].get_space(rel_to); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_extended_vertices -// Access: Public -// Description: Simultaneously sets several extended values in the -// slots d through (d + num_values - 1) from the -// num_values elements of the indicated array. This is -// equivalent to calling set_extended_vertex() -// num_values times. See set_extended_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously sets several extended values in the slots d through (d + + * num_values - 1) from the num_values elements of the indicated array. This + * is equivalent to calling set_extended_vertex() num_values times. See + * set_extended_vertex(). + */ void NurbsCurveEvaluator:: set_extended_vertices(int i, int d, const PN_stdfloat values[], int num_values) { nassertv(i >= 0 && i < (int)_vertices.size()); @@ -90,14 +76,11 @@ set_extended_vertices(int i, int d, const PN_stdfloat values[], int num_values) } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::set_knot -// Access: Published -// Description: Sets the value of the nth knot. Each knot value -// should be greater than or equal to the preceding -// value. If no knot values are set, a default knot -// vector is supplied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the nth knot. Each knot value should be greater than or + * equal to the preceding value. If no knot values are set, a default knot + * vector is supplied. + */ void NurbsCurveEvaluator:: set_knot(int i, PN_stdfloat knot) { if (_knots_dirty) { @@ -107,11 +90,9 @@ set_knot(int i, PN_stdfloat knot) { _knots[i] = knot; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_knot -// Access: Published -// Description: Returns the value of the nth knot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the nth knot. + */ PN_stdfloat NurbsCurveEvaluator:: get_knot(int i) const { if (_knots_dirty) { @@ -121,12 +102,10 @@ get_knot(int i) const { return _knots[i]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::normalize_knots -// Access: Published -// Description: Normalizes the knot sequence so that the parametric -// range of the curve is 0 .. 1. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the knot sequence so that the parametric range of the curve is 0 + * .. 1. + */ void NurbsCurveEvaluator:: normalize_knots() { if (_knots_dirty) { @@ -145,14 +124,11 @@ normalize_knots() { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::evaluate -// Access: Published -// Description: Returns a NurbsCurveResult object that represents the -// result of applying the knots to all of the current -// values of the vertices, transformed into the -// indicated coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NurbsCurveResult object that represents the result of applying + * the knots to all of the current values of the vertices, transformed into + * the indicated coordinate space. + */ PT(NurbsCurveResult) NurbsCurveEvaluator:: evaluate(const NodePath &rel_to) const { if (_basis_dirty) { @@ -163,21 +139,18 @@ evaluate(const NodePath &rel_to) const { Vert4Array vecs; get_vertices(vecs, rel_to); - // And apply those transformed vertices to the basis matrices to - // derive the result. + // And apply those transformed vertices to the basis matrices to derive the + // result. return new NurbsCurveResult(_basis, &vecs[0], &_vertices[0], (int)_vertices.size()); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::evaluate -// Access: Published -// Description: Returns a NurbsCurveResult object that represents the -// result of applying the knots to all of the current -// values of the vertices, transformed into the -// indicated coordinate space, and then further -// transformed by the indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NurbsCurveResult object that represents the result of applying + * the knots to all of the current values of the vertices, transformed into + * the indicated coordinate space, and then further transformed by the + * indicated matrix. + */ PT(NurbsCurveResult) NurbsCurveEvaluator:: evaluate(const NodePath &rel_to, const LMatrix4 &mat) const { if (_basis_dirty) { @@ -194,31 +167,26 @@ evaluate(const NodePath &rel_to, const LMatrix4 &mat) const { (*vi) = (*vi) * mat; } - // And apply those transformed vertices to the basis matrices to - // derive the result. + // And apply those transformed vertices to the basis matrices to derive the + // result. return new NurbsCurveResult(_basis, &vecs[0], &_vertices[0], (int)_vertices.size()); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NurbsCurveEvaluator:: output(ostream &out) const { out << "NurbsCurve, " << get_num_knots() << " knots."; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_vertices -// Access: Public -// Description: Fills the indicated vector with the set of vertices -// in the curve, transformed to the given space. This -// flavor returns the vertices in 4-dimensional -// homogenous space. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated vector with the set of vertices in the curve, + * transformed to the given space. This flavor returns the vertices in + * 4-dimensional homogenous space. + */ void NurbsCurveEvaluator:: get_vertices(NurbsCurveEvaluator::Vert4Array &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); @@ -229,14 +197,11 @@ get_vertices(NurbsCurveEvaluator::Vert4Array &verts, const NodePath &rel_to) con } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::get_vertices -// Access: Public -// Description: Fills the indicated vector with the set of vertices -// in the curve, transformed to the given space. This -// flavor returns the vertices in 3-dimensional -// space. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated vector with the set of vertices in the curve, + * transformed to the given space. This flavor returns the vertices in + * 3-dimensional space. + */ void NurbsCurveEvaluator:: get_vertices(NurbsCurveEvaluator::Vert3Array &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); @@ -254,11 +219,9 @@ get_vertices(NurbsCurveEvaluator::Vert3Array &verts, const NodePath &rel_to) con } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::recompute_knots -// Access: Private -// Description: Creates a default knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Creates a default knot vector. + */ void NurbsCurveEvaluator:: recompute_knots() { _knots.clear(); @@ -286,12 +249,9 @@ recompute_knots() { _knots_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveEvaluator::recompute_basis -// Access: Private -// Description: Recomputes the basis matrices according to the knot -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the basis matrices according to the knot vector. + */ void NurbsCurveEvaluator:: recompute_basis() { if (_knots_dirty) { @@ -302,7 +262,7 @@ recompute_basis() { if ((int)_vertices.size() > _order - 1) { int min_knot = _order; int max_knot = (int)_vertices.size(); - + for (int i = min_knot; i <= max_knot; i++) { nassertv(i - 1 >= 0 && i < (int)_knots.size()); if (_knots[i - 1] < _knots[i]) { diff --git a/panda/src/parametrics/nurbsCurveEvaluator.h b/panda/src/parametrics/nurbsCurveEvaluator.h index 3d2299dc47..86e3a79996 100644 --- a/panda/src/parametrics/nurbsCurveEvaluator.h +++ b/panda/src/parametrics/nurbsCurveEvaluator.h @@ -1,16 +1,15 @@ -// Filename: nurbsCurveEvaluator.h -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveEvaluator.h + * @author drose + * @date 2002-12-03 + */ #ifndef NURBSCURVEEVALUATOR_H #define NURBSCURVEEVALUATOR_H @@ -27,20 +26,16 @@ #include "referenceCount.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : NurbsCurveEvaluator -// Description : This class is an abstraction for evaluating NURBS -// curves. It accepts an array of vertices, each of -// which may be in a different coordinate space (as -// defined by a NodePath), as well as an optional knot -// vector. -// -// This is not related to NurbsCurve, CubicCurveseg or -// any of the ParametricCurve-derived objects in this -// module. It is a completely parallel implementation -// of NURBS curves, and will probably eventually replace -// the whole ParametricCurve class hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This class is an abstraction for evaluating NURBS curves. It accepts an + * array of vertices, each of which may be in a different coordinate space (as + * defined by a NodePath), as well as an optional knot vector. + * + * This is not related to NurbsCurve, CubicCurveseg or any of the + * ParametricCurve-derived objects in this module. It is a completely + * parallel implementation of NURBS curves, and will probably eventually + * replace the whole ParametricCurve class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS NurbsCurveEvaluator : public ReferenceCount { PUBLISHED: NurbsCurveEvaluator(); @@ -109,4 +104,3 @@ INLINE ostream &operator << (ostream &out, const NurbsCurveEvaluator &n); #include "nurbsCurveEvaluator.I" #endif - diff --git a/panda/src/parametrics/nurbsCurveInterface.I b/panda/src/parametrics/nurbsCurveInterface.I index 00045d7e88..6b29894d33 100644 --- a/panda/src/parametrics/nurbsCurveInterface.I +++ b/panda/src/parametrics/nurbsCurveInterface.I @@ -1,76 +1,60 @@ -// Filename: nurbsCurveInterface.I -// Created by: drose (02Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveInterface.I + * @author drose + * @date 2001-03-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::append_cv -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int NurbsCurveInterface:: append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return append_cv(LVecBase3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::append_cv -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int NurbsCurveInterface:: append_cv(const LVecBase3 &v) { return append_cv(LVecBase4(v[0], v[1], v[2], 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::append_cv -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int NurbsCurveInterface:: append_cv(const LVecBase4 &v) { return append_cv_impl(v); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::set_cv_point -// Access: Public, Scheme -// Description: Repositions the indicated CV. Returns true if -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the indicated CV. Returns true if successful, false otherwise. + */ INLINE bool NurbsCurveInterface:: set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return set_cv_point(n, LVecBase3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::set_cv_point -// Access: Public, Scheme -// Description: Repositions the indicated CV. Returns true if -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the indicated CV. Returns true if successful, false otherwise. + */ INLINE bool NurbsCurveInterface:: set_cv_point(int n, const LVecBase3 &v) { nassertr(n >= 0 && n < get_num_cvs(), false); return set_cv(n, LVecBase4(v[0], v[1], v[2], 1.0f) * get_cv_weight(n)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::get_cv_point -// Access: Public, Scheme -// Description: Returns the position of the indicated CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the indicated CV. + */ INLINE LVecBase3 NurbsCurveInterface:: get_cv_point(int n) const { nassertr(n >= 0 && n < get_num_cvs(), LVecBase3::zero()); @@ -79,11 +63,9 @@ get_cv_point(int n) const { return LVecBase3(p[0], p[1], p[2]) / p[3]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::get_cv_weight -// Access: Published -// Description: Returns the weight of the indicated CV. -//////////////////////////////////////////////////////////////////// +/** + * Returns the weight of the indicated CV. + */ INLINE PN_stdfloat NurbsCurveInterface:: get_cv_weight(int n) const { return get_cv(n)[3]; diff --git a/panda/src/parametrics/nurbsCurveInterface.cxx b/panda/src/parametrics/nurbsCurveInterface.cxx index fd87c0a7b1..9c9affa03d 100644 --- a/panda/src/parametrics/nurbsCurveInterface.cxx +++ b/panda/src/parametrics/nurbsCurveInterface.cxx @@ -1,16 +1,15 @@ -// Filename: nurbsCurveInterface.cxx -// Created by: drose (02Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveInterface.cxx + * @author drose + * @date 2001-03-02 + */ #include "nurbsCurveInterface.h" #include "parametricCurve.h" @@ -18,21 +17,17 @@ TypeHandle NurbsCurveInterface::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsCurveInterface:: ~NurbsCurveInterface() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::set_cv_weight -// Access: Published -// Description: Sets the weight of the indicated CV without affecting -// its position in 3-d space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the weight of the indicated CV without affecting its position in 3-d + * space. + */ bool NurbsCurveInterface:: set_cv_weight(int n, PN_stdfloat w) { nassertr(n >= 0 && n < get_num_cvs(), false); @@ -45,11 +40,9 @@ set_cv_weight(int n, PN_stdfloat w) { return set_cv(n, cv); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::write_cv -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NurbsCurveInterface:: write_cv(ostream &out, int n) const { nassertv(n >= 0 && n < get_num_cvs()); @@ -58,11 +51,9 @@ write_cv(ostream &out, int n) const { << get_cv_weight(n) << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::write -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NurbsCurveInterface:: write(ostream &out, int indent_level) const { indent(out, indent_level); @@ -98,11 +89,9 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::format_egg -// Access: Protected -// Description: Formats the Nurbs curve for output to an Egg file. -//////////////////////////////////////////////////////////////////// +/** + * Formats the Nurbs curve for output to an Egg file. + */ bool NurbsCurveInterface:: format_egg(ostream &out, const string &name, const string &curve_type, int indent_level) const { @@ -160,13 +149,10 @@ format_egg(ostream &out, const string &name, const string &curve_type, return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveInterface::convert_to_nurbs -// Access: Protected -// Description: Stores in the indicated NurbsCurve a NURBS -// representation of an equivalent curve. Returns true -// if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Stores in the indicated NurbsCurve a NURBS representation of an equivalent + * curve. Returns true if successful, false otherwise. + */ bool NurbsCurveInterface:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); diff --git a/panda/src/parametrics/nurbsCurveInterface.h b/panda/src/parametrics/nurbsCurveInterface.h index 009026576e..ef09c78275 100644 --- a/panda/src/parametrics/nurbsCurveInterface.h +++ b/panda/src/parametrics/nurbsCurveInterface.h @@ -1,16 +1,15 @@ -// Filename: nurbsCurveInterface.h -// Created by: drose (02Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveInterface.h + * @author drose + * @date 2001-03-02 + */ #ifndef NURBSCURVEINTERFACE_H #define NURBSCURVEINTERFACE_H @@ -22,15 +21,12 @@ class ParametricCurve; -//////////////////////////////////////////////////////////////////// -// Class : NurbsCurveInterface -// Description : This abstract class defines the interface only for a -// Nurbs-style curve, with knots and coordinates in -// homogeneous space. -// -// The NurbsCurve class inherits both from this and from -// ParametricCurve. -//////////////////////////////////////////////////////////////////// +/** + * This abstract class defines the interface only for a Nurbs-style curve, + * with knots and coordinates in homogeneous space. + * + * The NurbsCurve class inherits both from this and from ParametricCurve. + */ class EXPCL_PANDA_PARAMETRICS NurbsCurveInterface { PUBLISHED: virtual ~NurbsCurveInterface(); diff --git a/panda/src/parametrics/nurbsCurveResult.I b/panda/src/parametrics/nurbsCurveResult.I index ebe4c848e6..e8828d6820 100644 --- a/panda/src/parametrics/nurbsCurveResult.I +++ b/panda/src/parametrics/nurbsCurveResult.I @@ -1,55 +1,43 @@ -// Filename: nurbsCurveResult.I -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveResult.I + * @author drose + * @date 2002-12-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsCurveResult:: ~NurbsCurveResult() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_start_t -// Access: Published -// Description: Returns the first legal value of t on the curve. -// Usually this is 0.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first legal value of t on the curve. Usually this is 0.0. + */ INLINE PN_stdfloat NurbsCurveResult:: get_start_t() const { return _basis.get_start_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_end_t -// Access: Published -// Description: Returns the last legal value of t on the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last legal value of t on the curve. + */ INLINE PN_stdfloat NurbsCurveResult:: get_end_t() const { return _basis.get_end_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_point -// Access: Published -// Description: Computes the point on the curve corresponding to the -// indicated value in parametric time. Returns true if -// the t value is valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Computes the point on the curve corresponding to the indicated value in + * parametric time. Returns true if the t value is valid, false otherwise. + */ INLINE bool NurbsCurveResult:: eval_point(PN_stdfloat t, LVecBase3 &point) { int segment = find_segment(t); @@ -61,14 +49,11 @@ eval_point(PN_stdfloat t, LVecBase3 &point) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_tangent -// Access: Published -// Description: Computes the tangent to the curve at the indicated -// point in parametric time. This tangent vector will -// not necessarily be normalized, and could be zero. -// See also eval_point(). -//////////////////////////////////////////////////////////////////// +/** + * Computes the tangent to the curve at the indicated point in parametric + * time. This tangent vector will not necessarily be normalized, and could be + * zero. See also eval_point(). + */ INLINE bool NurbsCurveResult:: eval_tangent(PN_stdfloat t, LVecBase3 &tangent) { int segment = find_segment(t); @@ -80,13 +65,10 @@ eval_tangent(PN_stdfloat t, LVecBase3 &tangent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_extended_point -// Access: Published -// Description: Evaluates the curve in n-dimensional space according -// to the extended vertices associated with the curve in -// the indicated dimension. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the curve in n-dimensional space according to the extended + * vertices associated with the curve in the indicated dimension. + */ INLINE PN_stdfloat NurbsCurveResult:: eval_extended_point(PN_stdfloat t, int d) { int segment = find_segment(t); @@ -97,15 +79,12 @@ eval_extended_point(PN_stdfloat t, int d) { return eval_segment_extended_point(segment, _basis.scale_t(segment, t), d); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_extended_points -// Access: Published -// Description: Simultaneously performs eval_extended_point on a -// contiguous sequence of dimensions. The dimensions -// evaluated are d through (d + num_values - 1); the -// results are filled into the num_values elements in -// the indicated result array. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously performs eval_extended_point on a contiguous sequence of + * dimensions. The dimensions evaluated are d through (d + num_values - 1); + * the results are filled into the num_values elements in the indicated result + * array. + */ INLINE bool NurbsCurveResult:: eval_extended_points(PN_stdfloat t, int d, PN_stdfloat result[], int num_values) { int segment = find_segment(t); @@ -118,84 +97,66 @@ eval_extended_points(PN_stdfloat t, int d, PN_stdfloat result[], int num_values) return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_num_segments -// Access: Published -// Description: Returns the number of piecewise continuous segments -// within the curve. This number is usually not -// important unless you plan to call -// eval_segment_point(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments within the curve. This + * number is usually not important unless you plan to call + * eval_segment_point(). + */ INLINE int NurbsCurveResult:: get_num_segments() const { return _basis.get_num_segments(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_segment_t -// Access: Published -// Description: Accepts a t value in the range [0, 1], and assumed to -// be relative to the indicated segment (as in -// eval_segment_point()), and returns the corresponding -// t value in the entire curve (as in eval_point()). -//////////////////////////////////////////////////////////////////// +/** + * Accepts a t value in the range [0, 1], and assumed to be relative to the + * indicated segment (as in eval_segment_point()), and returns the + * corresponding t value in the entire curve (as in eval_point()). + */ INLINE PN_stdfloat NurbsCurveResult:: get_segment_t(int segment, PN_stdfloat t) const { return t * (_basis.get_to(segment) - _basis.get_from(segment)) + _basis.get_from(segment); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_num_samples -// Access: Published -// Description: Returns the number of sample points generated by the -// previous call to adaptive_sample(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sample points generated by the previous call to + * adaptive_sample(). + */ INLINE int NurbsCurveResult:: get_num_samples() const { return (int)_adaptive_result.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_sample_t -// Access: Published -// Description: Returns the t value of the nth sample point generated -// by the previous call to adaptive_sample(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the t value of the nth sample point generated by the previous call + * to adaptive_sample(). + */ INLINE PN_stdfloat NurbsCurveResult:: get_sample_t(int n) const { nassertr(n >= 0 && n < (int)_adaptive_result.size(), 0.0f); return _adaptive_result[n]._t; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_sample_point -// Access: Published -// Description: Returns the point on the curve of the nth sample -// point generated by the previous call to -// adaptive_sample(). -// -// For tangents, or extended points, you should use -// get_sample_t() and pass it into eval_tangent() or -// eval_extended_point(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the point on the curve of the nth sample point generated by the + * previous call to adaptive_sample(). + * + * For tangents, or extended points, you should use get_sample_t() and pass it + * into eval_tangent() or eval_extended_point(). + */ INLINE const LPoint3 &NurbsCurveResult:: get_sample_point(int n) const { nassertr(n >= 0 && n < (int)_adaptive_result.size(), LPoint3::zero()); return _adaptive_result[n]._point; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::get_segment_t -// Access: Public -// Description: Accepts a t value in the range [0, 1], and assumed to -// be relative to the indicated segment (as in -// eval_segment_point()), and returns the corresponding -// t value in the entire curve (as in eval_point()). -//////////////////////////////////////////////////////////////////// +/** + * Accepts a t value in the range [0, 1], and assumed to be relative to the + * indicated segment (as in eval_segment_point()), and returns the + * corresponding t value in the entire curve (as in eval_point()). + */ INLINE NurbsCurveResult::AdaptiveSample:: AdaptiveSample(PN_stdfloat t, const LPoint3 &point) : _t(t), _point(point) { } - diff --git a/panda/src/parametrics/nurbsCurveResult.cxx b/panda/src/parametrics/nurbsCurveResult.cxx index 85b16a334b..7f669c862c 100644 --- a/panda/src/parametrics/nurbsCurveResult.cxx +++ b/panda/src/parametrics/nurbsCurveResult.cxx @@ -1,28 +1,25 @@ -// Filename: nurbsCurveResult.cxx -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveResult.cxx + * @author drose + * @date 2002-12-04 + */ #include "nurbsCurveResult.h" #include "nurbsVertex.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::Constructor -// Access: Public -// Description: The constructor automatically builds up the result as -// the product of the indicated set of basis matrices -// and the indicated table of control vertex positions. -//////////////////////////////////////////////////////////////////// +/** + * The constructor automatically builds up the result as the product of the + * indicated set of basis matrices and the indicated table of control vertex + * positions. + */ NurbsCurveResult:: NurbsCurveResult(const NurbsBasisVector &basis, const LVecBase4 vecs[], const NurbsVertex *verts, @@ -51,32 +48,26 @@ NurbsCurveResult(const NurbsBasisVector &basis, ci++; } - // And compose this geometry matrix with the basis matrix to - // produce a new matrix, which will be used to evaluate the curve. + // And compose this geometry matrix with the basis matrix to produce a new + // matrix, which will be used to evaluate the curve. LMatrix4 result; result.multiply(_basis.get_basis(i), geom); _composed.push_back(result); } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_segment_point -// Access: Published -// Description: Evaluates the point on the curve corresponding to the -// indicated value in parametric time within the -// indicated curve segment. t should be in the range -// [0, 1]. -// -// The curve is internally represented as a number of -// connected (or possibly unconnected) piecewise -// continuous segments. The exact number of segments -// for a particular curve depends on the knot vector, -// and is returned by get_num_segments(). Normally, -// eval_point() is used to evaluate a point along the -// continuous curve, but when you care more about local -// continuity, you can use eval_segment_point() to -// evaluate the points along each segment. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the point on the curve corresponding to the indicated value in + * parametric time within the indicated curve segment. t should be in the + * range [0, 1]. + * + * The curve is internally represented as a number of connected (or possibly + * unconnected) piecewise continuous segments. The exact number of segments + * for a particular curve depends on the knot vector, and is returned by + * get_num_segments(). Normally, eval_point() is used to evaluate a point + * along the continuous curve, but when you care more about local continuity, + * you can use eval_segment_point() to evaluate the points along each segment. + */ void NurbsCurveResult:: eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const { PN_stdfloat t2 = t*t; @@ -89,14 +80,11 @@ eval_segment_point(int segment, PN_stdfloat t, LVecBase3 &point) const { tvec.dot(_composed[segment].get_col(2)) / weight); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_segment_tangent -// Access: Published -// Description: As eval_segment_point, but computes the tangent to -// the curve at the indicated point. The tangent vector -// will not necessarily be normalized, and could be -// zero, particularly at the endpoints. -//////////////////////////////////////////////////////////////////// +/** + * As eval_segment_point, but computes the tangent to the curve at the + * indicated point. The tangent vector will not necessarily be normalized, + * and could be zero, particularly at the endpoints. + */ void NurbsCurveResult:: eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const { PN_stdfloat t2 = t*t; @@ -107,13 +95,10 @@ eval_segment_tangent(int segment, PN_stdfloat t, LVecBase3 &tangent) const { tvec.dot(_composed[segment].get_col(2))); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_segment_extended_point -// Access: Published -// Description: Evaluates the curve in n-dimensional space according -// to the extended vertices associated with the curve in -// the indicated dimension. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the curve in n-dimensional space according to the extended + * vertices associated with the curve in the indicated dimension. + */ PN_stdfloat NurbsCurveResult:: eval_segment_extended_point(int segment, PN_stdfloat t, int d) const { nassertr(segment >= 0 && segment < _basis.get_num_segments(), 0.0f); @@ -123,8 +108,8 @@ eval_segment_extended_point(int segment, PN_stdfloat t, int d) const { PN_stdfloat weight = tvec.dot(_composed[segment].get_col(3)); - // Calculate the composition of the basis matrix and the geometry - // matrix on-the-fly. + // Calculate the composition of the basis matrix and the geometry matrix on- + // the-fly. int order = _basis.get_order(); int vi = _basis.get_vertex_index(segment); @@ -149,15 +134,12 @@ eval_segment_extended_point(int segment, PN_stdfloat t, int d) const { return tvec.dot(composed_geom) / weight; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::eval_segment_extended_points -// Access: Published -// Description: Simultaneously performs eval_extended_point on a -// contiguous sequence of dimensions. The dimensions -// evaluated are d through (d + num_values - 1); the -// results are filled into the num_values elements in -// the indicated result array. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously performs eval_extended_point on a contiguous sequence of + * dimensions. The dimensions evaluated are d through (d + num_values - 1); + * the results are filled into the num_values elements in the indicated result + * array. + */ void NurbsCurveResult:: eval_segment_extended_points(int segment, PN_stdfloat t, int d, PN_stdfloat result[], int num_values) const { @@ -168,8 +150,8 @@ eval_segment_extended_points(int segment, PN_stdfloat t, int d, PN_stdfloat weight = tvec.dot(_composed[segment].get_col(3)); - // Calculate the composition of the basis matrix and the geometry - // matrix on-the-fly. + // Calculate the composition of the basis matrix and the geometry matrix on- + // the-fly. const LMatrix4 &basis = _basis.get_basis(segment); int order = _basis.get_order(); int vi = _basis.get_vertex_index(segment); @@ -195,18 +177,14 @@ eval_segment_extended_points(int segment, PN_stdfloat t, int d, } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::adaptive_sample -// Access: Published -// Description: Determines the set of subdivisions necessary to -// approximate the curve with a set of linear segments, -// no point of which is farther than tolerance units -// from the actual curve. -// -// After this call, you may walk through the resulting -// set of samples with get_num_samples(), -// get_sample_t(), and get_sample_point(). -//////////////////////////////////////////////////////////////////// +/** + * Determines the set of subdivisions necessary to approximate the curve with + * a set of linear segments, no point of which is farther than tolerance units + * from the actual curve. + * + * After this call, you may walk through the resulting set of samples with + * get_num_samples(), get_sample_t(), and get_sample_point(). + */ void NurbsCurveResult:: adaptive_sample(PN_stdfloat tolerance) { PN_stdfloat tolerance_2 = tolerance * tolerance; @@ -218,8 +196,8 @@ adaptive_sample(PN_stdfloat tolerance) { for (int segment = 0; segment < num_segments; ++segment) { eval_segment_point(segment, 0.0f, p0); if (segment == 0 || !p0.almost_equal(p1)) { - // We explicitly push the first point, and the boundary point - // anytime the segment boundary is discontinuous. + // We explicitly push the first point, and the boundary point anytime + // the segment boundary is discontinuous. _adaptive_result.push_back(AdaptiveSample(_basis.get_from(segment), p0)); } @@ -230,13 +208,10 @@ adaptive_sample(PN_stdfloat tolerance) { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::find_segment -// Access: Private -// Description: Returns the index of the segment that contains the -// indicated value of t, or -1 if no segment contains -// this value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the segment that contains the indicated value of t, or + * -1 if no segment contains this value. + */ int NurbsCurveResult:: find_segment(PN_stdfloat t) { // Trivially check the endpoints of the curve. @@ -246,8 +221,8 @@ find_segment(PN_stdfloat t) { return 0; } - // Check the last segment we searched for. Often, two consecutive - // requests are for the same segment. + // Check the last segment we searched for. Often, two consecutive requests + // are for the same segment. if (_last_segment != -1 && (t >= _last_from && t < _last_to)) { return _last_segment; } @@ -262,14 +237,11 @@ find_segment(PN_stdfloat t) { return segment; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::r_find_segment -// Access: Private -// Description: Recursively searches for the segment that contains -// the indicated value of t by performing a binary -// search. This assumes the segments are stored in -// increasing order of t, and they don't overlap. -//////////////////////////////////////////////////////////////////// +/** + * Recursively searches for the segment that contains the indicated value of t + * by performing a binary search. This assumes the segments are stored in + * increasing order of t, and they don't overlap. + */ int NurbsCurveResult:: r_find_segment(PN_stdfloat t, int top, int bot) const { if (bot < top) { @@ -295,16 +267,13 @@ r_find_segment(PN_stdfloat t, int top, int bot) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::r_adaptive_sample -// Access: Private -// Description: Recursively subdivides a potential evaluation of the -// segment until it is found to be within tolerance. -// This will add everything up to and including t1, but -// excluding t0. -//////////////////////////////////////////////////////////////////// +/** + * Recursively subdivides a potential evaluation of the segment until it is + * found to be within tolerance. This will add everything up to and including + * t1, but excluding t0. + */ void NurbsCurveResult:: -r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0, +r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0, PN_stdfloat t1, const LPoint3 &p1, PN_stdfloat tolerance_2) { PN_stdfloat tmid = (t0 + t1) * 0.5f; LPoint3 pmid; @@ -321,15 +290,12 @@ r_adaptive_sample(int segment, PN_stdfloat t0, const LPoint3 &p0, } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsCurveResult::sqr_dist_to_line -// Access: Private, Static -// Description: A support function for r_adaptive_sample(), this -// computes the minimum distance from a point to a line, -// and returns the distance squared. -//////////////////////////////////////////////////////////////////// +/** + * A support function for r_adaptive_sample(), this computes the minimum + * distance from a point to a line, and returns the distance squared. + */ PN_stdfloat NurbsCurveResult:: -sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, +sqr_dist_to_line(const LPoint3 &point, const LPoint3 &origin, const LVector3 &vec) { LVector3 norm = vec; norm.normalize(); diff --git a/panda/src/parametrics/nurbsCurveResult.h b/panda/src/parametrics/nurbsCurveResult.h index bbd890dd12..79c6b995aa 100644 --- a/panda/src/parametrics/nurbsCurveResult.h +++ b/panda/src/parametrics/nurbsCurveResult.h @@ -1,16 +1,15 @@ -// Filename: nurbsCurveResult.h -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsCurveResult.h + * @author drose + * @date 2002-12-03 + */ #ifndef NURBSCURVERESULT_H #define NURBSCURVERESULT_H @@ -23,22 +22,19 @@ class NurbsVertex; -//////////////////////////////////////////////////////////////////// -// Class : NurbsCurveResult -// Description : The result of a NurbsCurveEvaluator. This object -// represents a curve in a particular coordinate space. -// It can return the point and/or tangent to the curve -// at any point. -// -// This is not related to NurbsCurve, CubicCurveseg or -// any of the ParametricCurve-derived objects in this -// module. It is a completely parallel implementation -// of NURBS curves, and will probably eventually replace -// the whole ParametricCurve class hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * The result of a NurbsCurveEvaluator. This object represents a curve in a + * particular coordinate space. It can return the point and/or tangent to the + * curve at any point. + * + * This is not related to NurbsCurve, CubicCurveseg or any of the + * ParametricCurve-derived objects in this module. It is a completely + * parallel implementation of NURBS curves, and will probably eventually + * replace the whole ParametricCurve class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS NurbsCurveResult : public ReferenceCount { public: - NurbsCurveResult(const NurbsBasisVector &basis, + NurbsCurveResult(const NurbsBasisVector &basis, const LVecBase4 vecs[], const NurbsVertex *verts, int num_vertices); @@ -51,7 +47,7 @@ PUBLISHED: INLINE bool eval_point(PN_stdfloat t, LVecBase3 &point); INLINE bool eval_tangent(PN_stdfloat t, LVecBase3 &tangent); INLINE PN_stdfloat eval_extended_point(PN_stdfloat t, int d); - INLINE bool eval_extended_points(PN_stdfloat t, int d, + INLINE bool eval_extended_points(PN_stdfloat t, int d, PN_stdfloat result[], int num_values); INLINE int get_num_segments() const; @@ -81,9 +77,9 @@ private: NurbsBasisVector _basis; const NurbsVertex *_verts; - // We pre-compose the basis matrix and the geometry vectors, so we - // have these handy for evaluation. There is one entry in the - // _composed for each entry in basis._segments. + // We pre-compose the basis matrix and the geometry vectors, so we have + // these handy for evaluation. There is one entry in the _composed for each + // entry in basis._segments. typedef epvector ComposedGeom; ComposedGeom _composed; @@ -104,4 +100,3 @@ private: #include "nurbsCurveResult.I" #endif - diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.I b/panda/src/parametrics/nurbsSurfaceEvaluator.I index 7e2a6ac1b0..c00408dd5f 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.I +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.I @@ -1,28 +1,23 @@ -// Filename: nurbsSurfaceEvaluator.I -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceEvaluator.I + * @author drose + * @date 2003-10-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_u_order -// Access: Published -// Description: Sets the order of the surface in the U direction. -// This resets the knot vector to the default knot -// vector for the number of vertices. -// -// The order must be 1, 2, 3, or 4, and the value is one -// more than the degree of the surface. -//////////////////////////////////////////////////////////////////// +/** + * Sets the order of the surface in the U direction. This resets the knot + * vector to the default knot vector for the number of vertices. + * + * The order must be 1, 2, 3, or 4, and the value is one more than the degree + * of the surface. + */ INLINE void NurbsSurfaceEvaluator:: set_u_order(int u_order) { _u_order = u_order; @@ -30,27 +25,22 @@ set_u_order(int u_order) { _u_basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_u_order -// Access: Published -// Description: Returns the order of the surface in the U direction -// as set by a previous call to set_u_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the surface in the U direction as set by a previous + * call to set_u_order(). + */ INLINE int NurbsSurfaceEvaluator:: get_u_order() const { return _u_order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_v_order -// Access: Published -// Description: Sets the order of the surface in the V direction. -// This resets the knot vector to the default knot -// vector for the number of vertices. -// -// The order must be 1, 2, 3, or 4, and the value is one -// more than the degree of the surface. -//////////////////////////////////////////////////////////////////// +/** + * Sets the order of the surface in the V direction. This resets the knot + * vector to the default knot vector for the number of vertices. + * + * The order must be 1, 2, 3, or 4, and the value is one more than the degree + * of the surface. + */ INLINE void NurbsSurfaceEvaluator:: set_v_order(int v_order) { _v_order = v_order; @@ -58,50 +48,39 @@ set_v_order(int v_order) { _v_basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_v_order -// Access: Published -// Description: Returns the order of the surface in the V direction -// as set by a previous call to set_v_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the order of the surface in the V direction as set by a previous + * call to set_v_order(). + */ INLINE int NurbsSurfaceEvaluator:: get_v_order() const { return _v_order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_u_vertices -// Access: Published -// Description: Returns the number of control vertices in the U -// direction on the surface. This is the number passed -// to the last call to reset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control vertices in the U direction on the surface. + * This is the number passed to the last call to reset(). + */ INLINE int NurbsSurfaceEvaluator:: get_num_u_vertices() const { return _num_u_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_v_vertices -// Access: Published -// Description: Returns the number of control vertices in the V -// direction on the surface. This is the number passed -// to the last call to reset(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control vertices in the V direction on the surface. + * This is the number passed to the last call to reset(). + */ INLINE int NurbsSurfaceEvaluator:: get_num_v_vertices() const { return _num_v_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_vertex -// Access: Published -// Description: Sets the nth control vertex of the surface, as a vertex -// in 4-d homogeneous space. In this form, the first -// three components of the vertex should already have -// been scaled by the fourth component, which is the -// homogeneous weight. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth control vertex of the surface, as a vertex in 4-d homogeneous + * space. In this form, the first three components of the vertex should + * already have been scaled by the fourth component, which is the homogeneous + * weight. + */ INLINE void NurbsSurfaceEvaluator:: set_vertex(int ui, int vi, const LVecBase4 &vertex) { nassertv(ui >= 0 && ui < _num_u_vertices && @@ -109,14 +88,11 @@ set_vertex(int ui, int vi, const LVecBase4 &vertex) { vert(ui, vi).set_vertex(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_vertex -// Access: Published -// Description: Sets the nth control vertex of the surface. This -// flavor sets the vertex as a 3-d coordinate and a -// weight; the 3-d coordinate values are implicitly -// scaled up by the weight factor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth control vertex of the surface. This flavor sets the vertex as + * a 3-d coordinate and a weight; the 3-d coordinate values are implicitly + * scaled up by the weight factor. + */ INLINE void NurbsSurfaceEvaluator:: set_vertex(int ui, int vi, const LVecBase3 &vertex, PN_stdfloat weight) { nassertv(ui >= 0 && ui < _num_u_vertices && @@ -124,12 +100,10 @@ set_vertex(int ui, int vi, const LVecBase3 &vertex, PN_stdfloat weight) { vert(ui, vi).set_vertex(LVecBase4(vertex[0] * weight, vertex[1] * weight, vertex[2] * weight, weight)); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_vertex -// Access: Published -// Description: Returns the nth control vertex of the surface, relative -// to its indicated coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth control vertex of the surface, relative to its indicated + * coordinate space. + */ INLINE const LVecBase4 &NurbsSurfaceEvaluator:: get_vertex(int ui, int vi) const { nassertr(ui >= 0 && ui < _num_u_vertices && @@ -137,12 +111,10 @@ get_vertex(int ui, int vi) const { return vert(ui, vi).get_vertex(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_vertex -// Access: Published -// Description: Returns the nth control vertex of the surface, relative -// to the given coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth control vertex of the surface, relative to the given + * coordinate space. + */ INLINE LVecBase4 NurbsSurfaceEvaluator:: get_vertex(int ui, int vi, const NodePath &rel_to) const { nassertr(ui >= 0 && ui < _num_u_vertices && @@ -158,19 +130,15 @@ get_vertex(int ui, int vi, const NodePath &rel_to) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_vertex_space -// Access: Published -// Description: Sets the coordinate space of the nth control vertex. -// If this is not specified, or is set to an empty -// NodePath, the nth control vertex is deemed to be in -// the coordinate space passed to evaluate(). -// -// This specifies the space as a fixed NodePath, which -// is always the same NodePath. Also see setting the -// space as a path string, which can specify a different -// NodePath for different instances of the surface. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coordinate space of the nth control vertex. If this is not + * specified, or is set to an empty NodePath, the nth control vertex is deemed + * to be in the coordinate space passed to evaluate(). + * + * This specifies the space as a fixed NodePath, which is always the same + * NodePath. Also see setting the space as a path string, which can specify a + * different NodePath for different instances of the surface. + */ INLINE void NurbsSurfaceEvaluator:: set_vertex_space(int ui, int vi, const NodePath &space) { nassertv(ui >= 0 && ui < _num_u_vertices && @@ -178,18 +146,14 @@ set_vertex_space(int ui, int vi, const NodePath &space) { vert(ui, vi).set_space(space); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_vertex_space -// Access: Published -// Description: Sets the coordinate space of the nth control vertex. -// If this is not specified, or is set to an empty -// string, the nth control vertex is deemed to be in -// the coordinate space passed to evaluate(). -// -// This specifies the space as a string, which describes -// the path to find the node relative to the rel_to -// NodePath when the surface is evaluated. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coordinate space of the nth control vertex. If this is not + * specified, or is set to an empty string, the nth control vertex is deemed + * to be in the coordinate space passed to evaluate(). + * + * This specifies the space as a string, which describes the path to find the + * node relative to the rel_to NodePath when the surface is evaluated. + */ INLINE void NurbsSurfaceEvaluator:: set_vertex_space(int ui, int vi, const string &space) { nassertv(ui >= 0 && ui < _num_u_vertices && @@ -197,28 +161,21 @@ set_vertex_space(int ui, int vi, const string &space) { vert(ui, vi).set_space(space); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_extended_vertex -// Access: Public -// Description: Sets an n-dimensional vertex value. This allows -// definition of a NURBS surface or surface in a sparse -// n-dimensional space, typically used for associating -// additional properties (like color or joint -// membership) with each vertex of a surface. -// -// The value d is an arbitrary integer value and -// specifies the dimension of question for this -// particular vertex. Any number of dimensions may be -// specified, and they need not be consecutive. If a -// value for a given dimension is not specified, is it -// implicitly 0.0. -// -// The value is implicitly scaled by the homogenous -// weight value--that is, the fourth component of the -// value passed to set_vertex(). This means the -// ordinary vertex must be set first, before the -// extended vertices can be set. -//////////////////////////////////////////////////////////////////// +/** + * Sets an n-dimensional vertex value. This allows definition of a NURBS + * surface or surface in a sparse n-dimensional space, typically used for + * associating additional properties (like color or joint membership) with + * each vertex of a surface. + * + * The value d is an arbitrary integer value and specifies the dimension of + * question for this particular vertex. Any number of dimensions may be + * specified, and they need not be consecutive. If a value for a given + * dimension is not specified, is it implicitly 0.0. + * + * The value is implicitly scaled by the homogenous weight value--that is, the + * fourth component of the value passed to set_vertex(). This means the + * ordinary vertex must be set first, before the extended vertices can be set. + */ INLINE void NurbsSurfaceEvaluator:: set_extended_vertex(int ui, int vi, int d, PN_stdfloat value) { nassertv(ui >= 0 && ui < _num_u_vertices && @@ -226,14 +183,11 @@ set_extended_vertex(int ui, int vi, int d, PN_stdfloat value) { vert(ui, vi).set_extended_vertex(d, value); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_extended_vertex -// Access: Public -// Description: Returns an n-dimensional vertex value. See -// set_extended_vertex(). This returns the value set -// for the indicated dimension, or 0.0 if nothing has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an n-dimensional vertex value. See set_extended_vertex(). This + * returns the value set for the indicated dimension, or 0.0 if nothing has + * been set. + */ INLINE PN_stdfloat NurbsSurfaceEvaluator:: get_extended_vertex(int ui, int vi, int d) const { nassertr(ui >= 0 && ui < _num_u_vertices && @@ -241,37 +195,28 @@ get_extended_vertex(int ui, int vi, int d) const { return vert(ui, vi).get_extended_vertex(d); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_u_knots -// Access: Published -// Description: Returns the number of knot values in the surface in -// the U direction. This is based on the number of -// vertices and the order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knot values in the surface in the U direction. This + * is based on the number of vertices and the order. + */ INLINE int NurbsSurfaceEvaluator:: get_num_u_knots() const { return _num_u_vertices + _u_order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_v_knots -// Access: Published -// Description: Returns the number of knot values in the surface in -// the V direction. This is based on the number of -// vertices and the order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of knot values in the surface in the V direction. This + * is based on the number of vertices and the order. + */ INLINE int NurbsSurfaceEvaluator:: get_num_v_knots() const { return _num_v_vertices + _v_order; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_u_segments -// Access: Published -// Description: Returns the number of piecewise continuous segments -// in the surface in the U direction. This is based on -// the knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments in the surface in the U + * direction. This is based on the knot vector. + */ INLINE int NurbsSurfaceEvaluator:: get_num_u_segments() const { if (_u_basis_dirty) { @@ -280,13 +225,10 @@ get_num_u_segments() const { return _u_basis.get_num_segments(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_num_v_segments -// Access: Published -// Description: Returns the number of piecewise continuous segments -// in the surface in the V direction. This is based on -// the knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments in the surface in the V + * direction. This is based on the knot vector. + */ INLINE int NurbsSurfaceEvaluator:: get_num_v_segments() const { if (_v_basis_dirty) { @@ -295,23 +237,19 @@ get_num_v_segments() const { return _v_basis.get_num_segments(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::vert -// Access: Private -// Description: Internal accessor to dereference the 2-d vertex -// coordinate pair into a linear list of vertices. -//////////////////////////////////////////////////////////////////// +/** + * Internal accessor to dereference the 2-d vertex coordinate pair into a + * linear list of vertices. + */ INLINE NurbsVertex &NurbsSurfaceEvaluator:: vert(int ui, int vi) { return _vertices[ui * _num_v_vertices + vi]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::vert -// Access: Private -// Description: Internal accessor to dereference the 2-d vertex -// coordinate pair into a linear list of vertices. -//////////////////////////////////////////////////////////////////// +/** + * Internal accessor to dereference the 2-d vertex coordinate pair into a + * linear list of vertices. + */ INLINE const NurbsVertex &NurbsSurfaceEvaluator:: vert(int ui, int vi) const { return _vertices[ui * _num_v_vertices + vi]; diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx index 1f4ffb9f8f..12ed399a9d 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.cxx +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.cxx @@ -1,24 +1,21 @@ -// Filename: nurbsSurfaceEvaluator.cxx -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceEvaluator.cxx + * @author drose + * @date 2003-10-10 + */ #include "nurbsSurfaceEvaluator.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsSurfaceEvaluator:: NurbsSurfaceEvaluator() { _u_order = 4; @@ -29,24 +26,18 @@ NurbsSurfaceEvaluator() { _v_basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NurbsSurfaceEvaluator:: ~NurbsSurfaceEvaluator() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::reset -// Access: Published -// Description: Resets all the vertices and knots to their default -// values, and sets the surface up with the indicated -// number of vertices. You must then call set_vertex() -// repeatedly to fill in all of the vertex values -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Resets all the vertices and knots to their default values, and sets the + * surface up with the indicated number of vertices. You must then call + * set_vertex() repeatedly to fill in all of the vertex values appropriately. + */ void NurbsSurfaceEvaluator:: reset(int num_u_vertices, int num_v_vertices) { int num_vertices = num_u_vertices * num_v_vertices; @@ -64,12 +55,10 @@ reset(int num_u_vertices, int num_v_vertices) { _v_basis_dirty = true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_vertex_space -// Access: Published -// Description: Returns the coordinate space of the nth control -// vertex of the surface, expressed as a NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate space of the nth control vertex of the surface, + * expressed as a NodePath. + */ NodePath NurbsSurfaceEvaluator:: get_vertex_space(int ui, int vi, const NodePath &rel_to) const { #ifndef NDEBUG @@ -80,17 +69,14 @@ get_vertex_space(int ui, int vi, const NodePath &rel_to) const { return vert(ui, vi).get_space(rel_to); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_extended_vertices -// Access: Public -// Description: Simultaneously sets several extended values in the -// slots d through (d + num_values - 1) from the -// num_values elements of the indicated array. This is -// equivalent to calling set_extended_vertex() -// num_values times. See set_extended_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously sets several extended values in the slots d through (d + + * num_values - 1) from the num_values elements of the indicated array. This + * is equivalent to calling set_extended_vertex() num_values times. See + * set_extended_vertex(). + */ void NurbsSurfaceEvaluator:: -set_extended_vertices(int ui, int vi, int d, +set_extended_vertices(int ui, int vi, int d, const PN_stdfloat values[], int num_values) { nassertv(ui >= 0 && ui < _num_u_vertices && vi >= 0 && vi < _num_v_vertices); @@ -101,14 +87,11 @@ set_extended_vertices(int ui, int vi, int d, } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_u_knot -// Access: Published -// Description: Sets the value of the nth knot. Each knot value -// should be greater than or equal to the preceding -// value. If no knot values are set, a default knot -// vector is supplied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the nth knot. Each knot value should be greater than or + * equal to the preceding value. If no knot values are set, a default knot + * vector is supplied. + */ void NurbsSurfaceEvaluator:: set_u_knot(int i, PN_stdfloat knot) { if (_u_knots_dirty) { @@ -118,11 +101,9 @@ set_u_knot(int i, PN_stdfloat knot) { _u_knots[i] = knot; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_u_knot -// Access: Published -// Description: Returns the value of the nth knot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the nth knot. + */ PN_stdfloat NurbsSurfaceEvaluator:: get_u_knot(int i) const { if (_u_knots_dirty) { @@ -132,12 +113,10 @@ get_u_knot(int i) const { return _u_knots[i]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::normalize_u_knots -// Access: Published -// Description: Normalizes the knot sequence so that the parametric -// range of the surface in the U direction is 0 .. 1. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the knot sequence so that the parametric range of the surface in + * the U direction is 0 .. 1. + */ void NurbsSurfaceEvaluator:: normalize_u_knots() { if (_u_knots_dirty) { @@ -156,14 +135,11 @@ normalize_u_knots() { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::set_v_knot -// Access: Published -// Description: Sets the value of the nth knot. Each knot value -// should be greater than or equal to the preceding -// value. If no knot values are set, a default knot -// vector is supplied. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of the nth knot. Each knot value should be greater than or + * equal to the preceding value. If no knot values are set, a default knot + * vector is supplied. + */ void NurbsSurfaceEvaluator:: set_v_knot(int i, PN_stdfloat knot) { if (_v_knots_dirty) { @@ -173,11 +149,9 @@ set_v_knot(int i, PN_stdfloat knot) { _v_knots[i] = knot; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_v_knot -// Access: Published -// Description: Returns the value of the nth knot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the nth knot. + */ PN_stdfloat NurbsSurfaceEvaluator:: get_v_knot(int i) const { if (_v_knots_dirty) { @@ -187,12 +161,10 @@ get_v_knot(int i) const { return _v_knots[i]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::normalize_v_knots -// Access: Published -// Description: Normalizes the knot sequence so that the parametric -// range of the surface in the U direction is 0 .. 1. -//////////////////////////////////////////////////////////////////// +/** + * Normalizes the knot sequence so that the parametric range of the surface in + * the U direction is 0 .. 1. + */ void NurbsSurfaceEvaluator:: normalize_v_knots() { if (_v_knots_dirty) { @@ -211,14 +183,11 @@ normalize_v_knots() { } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::evaluate -// Access: Published -// Description: Returns a NurbsSurfaceResult object that represents the -// result of applying the knots to all of the current -// values of the vertices, transformed into the -// indicated coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NurbsSurfaceResult object that represents the result of applying + * the knots to all of the current values of the vertices, transformed into + * the indicated coordinate space. + */ PT(NurbsSurfaceResult) NurbsSurfaceEvaluator:: evaluate(const NodePath &rel_to) const { if (_u_basis_dirty) { @@ -232,35 +201,30 @@ evaluate(const NodePath &rel_to) const { Vert4Array vecs; get_vertices(vecs, rel_to); - // And apply those transformed vertices to the basis matrices to - // derive the result. + // And apply those transformed vertices to the basis matrices to derive the + // result. return new NurbsSurfaceResult(_u_basis, _v_basis, &vecs[0], &_vertices[0], _num_u_vertices, _num_v_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NurbsSurfaceEvaluator:: output(ostream &out) const { out << "NurbsSurface, (" << get_num_u_knots() << ", " << get_num_v_knots() << ") knots."; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_vertices -// Access: Public -// Description: Fills the indicated vector with the set of vertices -// in the surface, transformed to the given space. This -// flavor returns the vertices in 4-dimensional -// homogenous space. -// -// Vertices are arranged in linear sequence, with the v -// coordinate changing more rapidly. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated vector with the set of vertices in the surface, + * transformed to the given space. This flavor returns the vertices in + * 4-dimensional homogenous space. + * + * Vertices are arranged in linear sequence, with the v coordinate changing + * more rapidly. + */ void NurbsSurfaceEvaluator:: get_vertices(NurbsSurfaceEvaluator::Vert4Array &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); @@ -279,17 +243,14 @@ get_vertices(NurbsSurfaceEvaluator::Vert4Array &verts, const NodePath &rel_to) c } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::get_vertices -// Access: Public -// Description: Fills the indicated vector with the set of vertices -// in the surface, transformed to the given space. This -// flavor returns the vertices in 3-dimensional -// space. -// -// Vertices are arranged in linear sequence, with the v -// coordinate changing more rapidly. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated vector with the set of vertices in the surface, + * transformed to the given space. This flavor returns the vertices in + * 3-dimensional space. + * + * Vertices are arranged in linear sequence, with the v coordinate changing + * more rapidly. + */ void NurbsSurfaceEvaluator:: get_vertices(NurbsSurfaceEvaluator::Vert3Array &verts, const NodePath &rel_to) const { int num_vertices = (int)_vertices.size(); @@ -308,11 +269,9 @@ get_vertices(NurbsSurfaceEvaluator::Vert3Array &verts, const NodePath &rel_to) c } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::recompute_u_knots -// Access: Private -// Description: Creates a default knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Creates a default knot vector. + */ void NurbsSurfaceEvaluator:: recompute_u_knots() { _u_knots.clear(); @@ -340,11 +299,9 @@ recompute_u_knots() { _u_knots_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::recompute_v_knots -// Access: Private -// Description: Creates a default knot vector. -//////////////////////////////////////////////////////////////////// +/** + * Creates a default knot vector. + */ void NurbsSurfaceEvaluator:: recompute_v_knots() { _v_knots.clear(); @@ -372,12 +329,9 @@ recompute_v_knots() { _v_knots_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::recompute_u_basis -// Access: Private -// Description: Recomputes the basis matrices according to the knot -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the basis matrices according to the knot vector. + */ void NurbsSurfaceEvaluator:: recompute_u_basis() { if (_u_knots_dirty) { @@ -388,7 +342,7 @@ recompute_u_basis() { if (_num_u_vertices > _u_order - 1) { int min_knot = _u_order; int max_knot = _num_u_vertices; - + for (int i = min_knot; i <= max_knot; i++) { nassertv(i - 1 >= 0 && i < (int)_u_knots.size()); if (_u_knots[i - 1] < _u_knots[i]) { @@ -401,12 +355,9 @@ recompute_u_basis() { _u_basis_dirty = false; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceEvaluator::recompute_v_basis -// Access: Private -// Description: Recomputes the basis matrices according to the knot -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the basis matrices according to the knot vector. + */ void NurbsSurfaceEvaluator:: recompute_v_basis() { if (_v_knots_dirty) { @@ -417,7 +368,7 @@ recompute_v_basis() { if (_num_v_vertices > _v_order - 1) { int min_knot = _v_order; int max_knot = _num_v_vertices; - + for (int i = min_knot; i <= max_knot; i++) { nassertv(i - 1 >= 0 && i < (int)_v_knots.size()); if (_v_knots[i - 1] < _v_knots[i]) { diff --git a/panda/src/parametrics/nurbsSurfaceEvaluator.h b/panda/src/parametrics/nurbsSurfaceEvaluator.h index e02e4bc4ea..ebba47bbc5 100644 --- a/panda/src/parametrics/nurbsSurfaceEvaluator.h +++ b/panda/src/parametrics/nurbsSurfaceEvaluator.h @@ -1,16 +1,15 @@ -// Filename: nurbsSurfaceEvaluator.h -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceEvaluator.h + * @author drose + * @date 2003-10-10 + */ #ifndef NURBSSURFACEEVALUATOR_H #define NURBSSURFACEEVALUATOR_H @@ -27,14 +26,11 @@ #include "referenceCount.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : NurbsSurfaceEvaluator -// Description : This class is an abstraction for evaluating NURBS -// surfaces. It accepts an array of vertices, each of -// which may be in a different coordinate space (as -// defined by a NodePath), as well as an optional knot -// vector. -//////////////////////////////////////////////////////////////////// +/** + * This class is an abstraction for evaluating NURBS surfaces. It accepts an + * array of vertices, each of which may be in a different coordinate space (as + * defined by a NodePath), as well as an optional knot vector. + */ class EXPCL_PANDA_PARAMETRICS NurbsSurfaceEvaluator : public ReferenceCount { PUBLISHED: NurbsSurfaceEvaluator(); @@ -61,7 +57,7 @@ PUBLISHED: INLINE void set_extended_vertex(int ui, int vi, int d, PN_stdfloat value); INLINE PN_stdfloat get_extended_vertex(int ui, int vi, int d) const; - void set_extended_vertices(int ui, int vi, int d, + void set_extended_vertices(int ui, int vi, int d, const PN_stdfloat values[], int num_values); INLINE int get_num_u_knots() const; @@ -123,4 +119,3 @@ INLINE ostream &operator << (ostream &out, const NurbsSurfaceEvaluator &n); #include "nurbsSurfaceEvaluator.I" #endif - diff --git a/panda/src/parametrics/nurbsSurfaceResult.I b/panda/src/parametrics/nurbsSurfaceResult.I index 45e6302e97..15722e7a6b 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.I +++ b/panda/src/parametrics/nurbsSurfaceResult.I @@ -1,76 +1,60 @@ -// Filename: nurbsSurfaceResult.I -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceResult.I + * @author drose + * @date 2003-10-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsSurfaceResult:: ~NurbsSurfaceResult() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_start_u -// Access: Public -// Description: Returns the first legal value of u on the surface. -// Usually this is 0.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first legal value of u on the surface. Usually this is 0.0. + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_start_u() const { return _u_basis.get_start_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_end_u -// Access: Public -// Description: Returns the last legal value of u on the surface. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last legal value of u on the surface. + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_end_u() const { return _u_basis.get_end_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_start_v -// Access: Public -// Description: Returns the first legal value of v on the surface. -// Usually this is 0.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first legal value of v on the surface. Usually this is 0.0. + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_start_v() const { return _v_basis.get_start_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_end_v -// Access: Public -// Description: Returns the last legal value of v on the surface. -//////////////////////////////////////////////////////////////////// +/** + * Returns the last legal value of v on the surface. + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_end_v() const { return _v_basis.get_end_t(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_point -// Access: Published -// Description: Computes the point on the surface corresponding to the -// indicated value in parametric time. Returns true if -// the u, v values are valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Computes the point on the surface corresponding to the indicated value in + * parametric time. Returns true if the u, v values are valid, false + * otherwise. + */ INLINE bool NurbsSurfaceResult:: eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) { int ui = find_u_segment(u); @@ -84,14 +68,11 @@ eval_point(PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_normal -// Access: Published -// Description: Computes the normal to the surface at the indicated -// point in parametric time. This normal vector will -// not necessarily be normalized, and could be zero. -// See also eval_point(). -//////////////////////////////////////////////////////////////////// +/** + * Computes the normal to the surface at the indicated point in parametric + * time. This normal vector will not necessarily be normalized, and could be + * zero. See also eval_point(). + */ INLINE bool NurbsSurfaceResult:: eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) { int ui = find_u_segment(u); @@ -105,13 +86,10 @@ eval_normal(PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_extended_point -// Access: Published -// Description: Evaluates the surface in n-dimensional space according -// to the extended vertices associated with the surface in -// the indicated dimension. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the surface in n-dimensional space according to the extended + * vertices associated with the surface in the indicated dimension. + */ INLINE PN_stdfloat NurbsSurfaceResult:: eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d) { int ui = find_u_segment(u); @@ -120,19 +98,16 @@ eval_extended_point(PN_stdfloat u, PN_stdfloat v, int d) { return 0.0f; } - return eval_segment_extended_point(ui, vi, _u_basis.scale_t(ui, u), + return eval_segment_extended_point(ui, vi, _u_basis.scale_t(ui, u), _v_basis.scale_t(vi, v), d); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_extended_points -// Access: Published -// Description: Simultaneously performs eval_extended_point on a -// contiguous sequence of dimensions. The dimensions -// evaluated are d through (d + num_values - 1); the -// results are filled into the num_values elements in -// the indicated result array. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously performs eval_extended_point on a contiguous sequence of + * dimensions. The dimensions evaluated are d through (d + num_values - 1); + * the results are filled into the num_values elements in the indicated result + * array. + */ INLINE bool NurbsSurfaceResult:: eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d, PN_stdfloat result[], int num_values) { @@ -142,85 +117,67 @@ eval_extended_points(PN_stdfloat u, PN_stdfloat v, int d, PN_stdfloat result[], return false; } - eval_segment_extended_points(ui, vi, _u_basis.scale_t(ui, u), + eval_segment_extended_points(ui, vi, _u_basis.scale_t(ui, u), _v_basis.scale_t(vi, v), d, result, num_values); return true; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_num_u_segments -// Access: Public -// Description: Returns the number of piecewise continuous segments -// within the surface in the U direction. This number -// is usually not important unless you plan to call -// eval_segment_point(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments within the surface in + * the U direction. This number is usually not important unless you plan to + * call eval_segment_point(). + */ INLINE int NurbsSurfaceResult:: get_num_u_segments() const { return _u_basis.get_num_segments(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_num_v_segments -// Access: Public -// Description: Returns the number of piecewise continuous segments -// within the surface in the V direction. This number -// is usually not important unless you plan to call -// eval_segment_point(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of piecewise continuous segments within the surface in + * the V direction. This number is usually not important unless you plan to + * call eval_segment_point(). + */ INLINE int NurbsSurfaceResult:: get_num_v_segments() const { return _v_basis.get_num_segments(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_segment_u -// Access: Public -// Description: Accepts a u value in the range [0, 1], and assumed to -// be relative to the indicated segment (as in -// eval_segment_point()), and returns the corresponding -// u value in the entire surface (as in eval_point()). -//////////////////////////////////////////////////////////////////// +/** + * Accepts a u value in the range [0, 1], and assumed to be relative to the + * indicated segment (as in eval_segment_point()), and returns the + * corresponding u value in the entire surface (as in eval_point()). + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_segment_u(int ui, PN_stdfloat u) const { return u * (_u_basis.get_to(ui) - _u_basis.get_from(ui)) + _u_basis.get_from(ui); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::get_segment_v -// Access: Public -// Description: Accepts a v value in the range [0, 1], and assumed to -// be relative to the indicated segment (as in -// eval_segment_point()), and returns the corresponding -// v value in the entire surface (as in eval_point()). -//////////////////////////////////////////////////////////////////// +/** + * Accepts a v value in the range [0, 1], and assumed to be relative to the + * indicated segment (as in eval_segment_point()), and returns the + * corresponding v value in the entire surface (as in eval_point()). + */ INLINE PN_stdfloat NurbsSurfaceResult:: get_segment_v(int vi, PN_stdfloat v) const { return v * (_v_basis.get_to(vi) - _v_basis.get_from(vi)) + _v_basis.get_from(vi); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::verti -// Access: Private -// Description: An internal function to dereference a 2-d vertex -// coordinate pair into a linear list of vertices. This -// returns the linear index corresponding to the 2-d -// pair. -//////////////////////////////////////////////////////////////////// +/** + * An internal function to dereference a 2-d vertex coordinate pair into a + * linear list of vertices. This returns the linear index corresponding to + * the 2-d pair. + */ INLINE int NurbsSurfaceResult:: verti(int ui, int vi) const { return ui * _num_v_vertices + vi; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::segi -// Access: Private -// Description: An internal function to dereference a 2-d segment -// coordinate pair into a linear list of segments. This -// returns the linear index corresponding to the 2-d -// pair. -//////////////////////////////////////////////////////////////////// +/** + * An internal function to dereference a 2-d segment coordinate pair into a + * linear list of segments. This returns the linear index corresponding to + * the 2-d pair. + */ INLINE int NurbsSurfaceResult:: segi(int ui, int vi) const { return ui * _v_basis.get_num_segments() + vi; diff --git a/panda/src/parametrics/nurbsSurfaceResult.cxx b/panda/src/parametrics/nurbsSurfaceResult.cxx index 913ab8a410..e1bfccb168 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.cxx +++ b/panda/src/parametrics/nurbsSurfaceResult.cxx @@ -1,31 +1,28 @@ -// Filename: nurbsSurfaceResult.cxx -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceResult.cxx + * @author drose + * @date 2003-10-10 + */ #include "nurbsSurfaceResult.h" #include "nurbsVertex.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::Constructor -// Access: Public -// Description: The constructor automatically builds up the result as -// the product of the indicated set of basis matrices -// and the indicated table of control vertex positions. -//////////////////////////////////////////////////////////////////// +/** + * The constructor automatically builds up the result as the product of the + * indicated set of basis matrices and the indicated table of control vertex + * positions. + */ NurbsSurfaceResult:: -NurbsSurfaceResult(const NurbsBasisVector &u_basis, - const NurbsBasisVector &v_basis, +NurbsSurfaceResult(const NurbsBasisVector &u_basis, + const NurbsBasisVector &v_basis, const LVecBase4 vecs[], const NurbsVertex *verts, int num_u_vertices, int num_v_vertices) : _u_basis(u_basis), @@ -52,18 +49,18 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, for (int vi = 0; vi < num_v_segments; vi++) { const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); - + int vn = _v_basis.get_vertex_index(vi); nassertv(vn >= 0 && vn + v_order - 1 < _num_v_vertices); - + for (int ui = 0; ui < num_u_segments; ui++) { const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); - + int un = _u_basis.get_vertex_index(ui); nassertv(un >= 0 && un + u_order - 1 < _num_u_vertices); - - // Create four geometry matrices from our (up to) sixteen - // involved vertices. + + // Create four geometry matrices from our (up to) sixteen involved + // vertices. LMatrix4 geom_x, geom_y, geom_z, geom_w; memset(&geom_x, 0, sizeof(geom_x)); memset(&geom_y, 0, sizeof(geom_y)); @@ -82,9 +79,9 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, } } - // And compose these geometry matrices with the basis matrices - // to produce a new set of matrices, which will be used to - // evaluate the surface. + // And compose these geometry matrices with the basis matrices to + // produce a new set of matrices, which will be used to evaluate the + // surface. int i = segi(ui, vi); nassertv(i >= 0 && i < (int)_composed.size()); ComposedMats &result = _composed[i]; @@ -96,24 +93,19 @@ NurbsSurfaceResult(const NurbsBasisVector &u_basis, } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_segment_point -// Access: Published -// Description: Evaluates the point on the surface corresponding to the -// indicated value in parametric time within the -// indicated surface segment. u and v should be in the -// range [0, 1]. -// -// The surface is internally represented as a number of -// connected (or possibly unconnected) piecewise -// continuous segments. The exact number of segments -// for a particular surface depends on the knot vector, -// and is returned by get_num_segments(). Normally, -// eval_point() is used to evaluate a point along the -// continuous surface, but when you care more about local -// continuity, you can use eval_segment_point() to -// evaluate the points along each segment. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the point on the surface corresponding to the indicated value in + * parametric time within the indicated surface segment. u and v should be in + * the range [0, 1]. + * + * The surface is internally represented as a number of connected (or possibly + * unconnected) piecewise continuous segments. The exact number of segments + * for a particular surface depends on the knot vector, and is returned by + * get_num_segments(). Normally, eval_point() is used to evaluate a point + * along the continuous surface, but when you care more about local + * continuity, you can use eval_segment_point() to evaluate the points along + * each segment. + */ void NurbsSurfaceResult:: eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &point) const { int i = segi(ui, vi); @@ -131,14 +123,11 @@ eval_segment_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &poin vvec.dot(uvec * _composed[i]._z) / weight); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_segment_normal -// Access: Published -// Description: As eval_segment_point, but computes the normal to -// the surface at the indicated point. The normal vector -// will not necessarily be normalized, and could be -// zero. -//////////////////////////////////////////////////////////////////// +/** + * As eval_segment_point, but computes the normal to the surface at the + * indicated point. The normal vector will not necessarily be normalized, and + * could be zero. + */ void NurbsSurfaceResult:: eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &normal) const { int i = segi(ui, vi); @@ -162,13 +151,10 @@ eval_segment_normal(int ui, int vi, PN_stdfloat u, PN_stdfloat v, LVecBase3 &nor normal = utan.cross(vtan); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_segment_extended_point -// Access: Published -// Description: Evaluates the surface in n-dimensional space according -// to the extended vertices associated with the surface in -// the indicated dimension. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the surface in n-dimensional space according to the extended + * vertices associated with the surface in the indicated dimension. + */ PN_stdfloat NurbsSurfaceResult:: eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) const { int i = segi(ui, vi); @@ -181,8 +167,8 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) PN_stdfloat weight = vvec.dot(uvec * _composed[i]._w); - // Calculate the composition of the basis matrices and the geometry - // matrix on-the-fly. + // Calculate the composition of the basis matrices and the geometry matrix + // on-the-fly. const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); int u_order = _u_basis.get_order(); @@ -206,15 +192,12 @@ eval_segment_extended_point(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d) return vvec.dot(uvec * composed) / weight; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::eval_segment_extended_points -// Access: Published -// Description: Simultaneously performs eval_extended_point on a -// contiguous sequence of dimensions. The dimensions -// evaluated are d through (d + num_values - 1); the -// results are filled into the num_values elements in -// the indicated result array. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously performs eval_extended_point on a contiguous sequence of + * dimensions. The dimensions evaluated are d through (d + num_values - 1); + * the results are filled into the num_values elements in the indicated result + * array. + */ void NurbsSurfaceResult:: eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d, PN_stdfloat result[], int num_values) const { @@ -228,8 +211,8 @@ eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d PN_stdfloat weight = vvec.dot(uvec * _composed[i]._w); - // Calculate the composition of the basis matrices and the geometry - // matrix on-the-fly. + // Calculate the composition of the basis matrices and the geometry matrix + // on-the-fly. const LMatrix4 &v_basis_transpose = _v_basis.get_basis(vi); const LMatrix4 &u_basis_mat = _u_basis.get_basis(ui); int u_order = _u_basis.get_order(); @@ -241,28 +224,25 @@ eval_segment_extended_points(int ui, int vi, PN_stdfloat u, PN_stdfloat v, int d for (int n = 0; n < num_values; n++) { LMatrix4 geom; memset(&geom, 0, sizeof(geom)); - + for (int uni = 0; uni < 4; uni++) { for (int vni = 0; vni < 4; vni++) { if (uni < u_order && vni < v_order) { - geom(uni, vni) = + geom(uni, vni) = _verts[verti(un + uni, vn + vni)].get_extended_vertex(d + n); } } } - + LMatrix4 composed = u_basis_mat * geom * v_basis_transpose; result[n] = vvec.dot(uvec * composed) / weight; } } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::find_u_segment -// Access: Private -// Description: Returns the index of the segment that contains the -// indicated value of t, or -1 if no segment contains -// this value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the segment that contains the indicated value of t, or + * -1 if no segment contains this value. + */ int NurbsSurfaceResult:: find_u_segment(PN_stdfloat u) { // Trivially check the endpoints of the surface. @@ -272,8 +252,8 @@ find_u_segment(PN_stdfloat u) { return 0; } - // Check the last segment we searched for. Often, two consecutive - // requests are for the same segment. + // Check the last segment we searched for. Often, two consecutive requests + // are for the same segment. if (_last_u_segment != -1 && (u >= _last_u_from && u < _last_u_to)) { return _last_u_segment; } @@ -288,14 +268,11 @@ find_u_segment(PN_stdfloat u) { return segment; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::r_find_u_segment -// Access: Private -// Description: Recursively searches for the segment that contains -// the indicated value of t by performing a binary -// search. This assumes the segments are stored in -// increasing order of t, and they don't overlap. -//////////////////////////////////////////////////////////////////// +/** + * Recursively searches for the segment that contains the indicated value of t + * by performing a binary search. This assumes the segments are stored in + * increasing order of t, and they don't overlap. + */ int NurbsSurfaceResult:: r_find_u_segment(PN_stdfloat u, int top, int bot) const { if (bot < top) { @@ -322,13 +299,10 @@ r_find_u_segment(PN_stdfloat u, int top, int bot) const { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::find_v_segment -// Access: Private -// Description: Returns the index of the segment that contains the -// indicated value of t, or -1 if no segment contains -// this value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the segment that contains the indicated value of t, or + * -1 if no segment contains this value. + */ int NurbsSurfaceResult:: find_v_segment(PN_stdfloat v) { // Trivially check the endpoints of the surface. @@ -338,8 +312,8 @@ find_v_segment(PN_stdfloat v) { return 0; } - // Check the last segment we searched for. Often, two consecutive - // requests are for the same segment. + // Check the last segment we searched for. Often, two consecutive requests + // are for the same segment. if (_last_v_segment != -1 && (v >= _last_v_from && v < _last_v_to)) { return _last_v_segment; } @@ -354,14 +328,11 @@ find_v_segment(PN_stdfloat v) { return segment; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsSurfaceResult::r_find_v_segment -// Access: Private -// Description: Recursively searches for the segment that contains -// the indicated value of t by performing a binary -// search. This assumes the segments are stored in -// increasing order of t, and they don't overlap. -//////////////////////////////////////////////////////////////////// +/** + * Recursively searches for the segment that contains the indicated value of t + * by performing a binary search. This assumes the segments are stored in + * increasing order of t, and they don't overlap. + */ int NurbsSurfaceResult:: r_find_v_segment(PN_stdfloat v, int top, int bot) const { if (bot < top) { @@ -386,4 +357,3 @@ r_find_v_segment(PN_stdfloat v, int top, int bot) const { return mid; } } - diff --git a/panda/src/parametrics/nurbsSurfaceResult.h b/panda/src/parametrics/nurbsSurfaceResult.h index f5a055f44e..b4228be870 100644 --- a/panda/src/parametrics/nurbsSurfaceResult.h +++ b/panda/src/parametrics/nurbsSurfaceResult.h @@ -1,16 +1,15 @@ -// Filename: nurbsSurfaceResult.h -// Created by: drose (10Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsSurfaceResult.h + * @author drose + * @date 2003-10-10 + */ #ifndef NURBSSURFACERESULT_H #define NURBSSURFACERESULT_H @@ -22,13 +21,11 @@ class NurbsVertex; -//////////////////////////////////////////////////////////////////// -// Class : NurbsSurfaceResult -// Description : The result of a NurbsSurfaceEvaluator. This object -// represents a surface in a particular coordinate space. -// It can return the point and/or normal to the surface -// at any point. -//////////////////////////////////////////////////////////////////// +/** + * The result of a NurbsSurfaceEvaluator. This object represents a surface in + * a particular coordinate space. It can return the point and/or normal to + * the surface at any point. + */ class EXPCL_PANDA_PARAMETRICS NurbsSurfaceResult : public ReferenceCount { public: NurbsSurfaceResult(const NurbsBasisVector &u_basis, @@ -76,10 +73,9 @@ private: int _num_u_vertices; int _num_v_vertices; - // We pre-compose the basis matrix and the geometry vectors, so we - // have these handy for evaluation. There is one entry in the - // _composed for each entry in u_basis._segments * - // v_basis._segments. + // We pre-compose the basis matrix and the geometry vectors, so we have + // these handy for evaluation. There is one entry in the _composed for each + // entry in u_basis._segments * v_basis._segments. class ComposedMats { public: LMatrix4 _x, _y, _z, _w; @@ -99,4 +95,3 @@ private: #include "nurbsSurfaceResult.I" #endif - diff --git a/panda/src/parametrics/nurbsVertex.I b/panda/src/parametrics/nurbsVertex.I index a054d7623a..cd6c344ac9 100644 --- a/panda/src/parametrics/nurbsVertex.I +++ b/panda/src/parametrics/nurbsVertex.I @@ -1,33 +1,27 @@ -// Filename: nurbsVertex.I -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsVertex.I + * @author drose + * @date 2002-12-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsVertex:: NurbsVertex() { _vertex.set(0, 0, 0, 1); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsVertex:: NurbsVertex(const NurbsVertex ©) : _vertex(copy._vertex), @@ -36,11 +30,9 @@ NurbsVertex(const NurbsVertex ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NurbsVertex:: operator = (const NurbsVertex ©) { _vertex = copy._vertex; @@ -48,63 +40,50 @@ operator = (const NurbsVertex ©) { _space_path = copy._space_path; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NurbsVertex:: ~NurbsVertex() { } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::set_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NurbsVertex:: set_vertex(const LVecBase4 &vertex) { _vertex = vertex; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::get_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVecBase4 &NurbsVertex:: get_vertex() const { return _vertex; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::set_space -// Access: Public -// Description: Sets the space of this vertex as a fixed NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Sets the space of this vertex as a fixed NodePath. + */ INLINE void NurbsVertex:: set_space(const NodePath &space) { _space = space; _space_path = string(); } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::set_space -// Access: Public -// Description: Sets the space of this vertex as a relative path from -// the rel_to node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the space of this vertex as a relative path from the rel_to node. + */ INLINE void NurbsVertex:: set_space(const string &space) { _space = NodePath(); _space_path = space; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::get_space -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePath NurbsVertex:: get_space(const NodePath &rel_to) const { if (_space_path.empty()) { diff --git a/panda/src/parametrics/nurbsVertex.cxx b/panda/src/parametrics/nurbsVertex.cxx index 68483cc952..037295b652 100644 --- a/panda/src/parametrics/nurbsVertex.cxx +++ b/panda/src/parametrics/nurbsVertex.cxx @@ -1,55 +1,44 @@ -// Filename: nurbsVertex.cxx -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsVertex.cxx + * @author drose + * @date 2002-12-04 + */ #include "nurbsVertex.h" -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::set_extended_vertex -// Access: Public -// Description: Sets an n-dimensional vertex value. This allows -// definition of a NURBS surface or curve in a sparse -// n-dimensional space, typically used for associating -// additional properties (like color or joint -// membership) with each vertex of a surface. -// -// The value d is an arbitrary integer value and -// specifies the dimension of question for this -// particular vertex. Any number of dimensions may be -// specified, and they need not be consecutive. If a -// value for a given dimension is not specified, is it -// implicitly 0.0. -// -// The value is implicitly scaled by the homogenous -// weight value--that is, the fourth component of the -// value passed to set_vertex(). This means the -// ordinary vertex must be set first, before the -// extended vertices can be set. -//////////////////////////////////////////////////////////////////// +/** + * Sets an n-dimensional vertex value. This allows definition of a NURBS + * surface or curve in a sparse n-dimensional space, typically used for + * associating additional properties (like color or joint membership) with + * each vertex of a surface. + * + * The value d is an arbitrary integer value and specifies the dimension of + * question for this particular vertex. Any number of dimensions may be + * specified, and they need not be consecutive. If a value for a given + * dimension is not specified, is it implicitly 0.0. + * + * The value is implicitly scaled by the homogenous weight value--that is, the + * fourth component of the value passed to set_vertex(). This means the + * ordinary vertex must be set first, before the extended vertices can be set. + */ void NurbsVertex:: set_extended_vertex(int d, PN_stdfloat value) { _extended[d] = value * _vertex[3]; } -//////////////////////////////////////////////////////////////////// -// Function: NurbsVertex::get_extended_vertex -// Access: Public -// Description: Returns an n-dimensional vertex value. See -// set_extended_vertex(). This returns the value set -// for the indicated dimension, or 0.0 if nothing has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an n-dimensional vertex value. See set_extended_vertex(). This + * returns the value set for the indicated dimension, or 0.0 if nothing has + * been set. + */ PN_stdfloat NurbsVertex:: get_extended_vertex(int d) const { Extended::const_iterator ei; diff --git a/panda/src/parametrics/nurbsVertex.h b/panda/src/parametrics/nurbsVertex.h index 10948022c4..7369f3a1e6 100644 --- a/panda/src/parametrics/nurbsVertex.h +++ b/panda/src/parametrics/nurbsVertex.h @@ -1,16 +1,15 @@ -// Filename: nurbsVertex.h -// Created by: drose (03Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nurbsVertex.h + * @author drose + * @date 2002-12-03 + */ #ifndef NURBSVERTEX_H #define NURBSVERTEX_H @@ -20,19 +19,16 @@ #include "nodePath.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : NurbsVertex -// Description : This represents a single control vertex in a -// NurbsEvaluator. It may be relative to a particular -// coordinate space; or its coordinate space may be -// unspecified. -// -// This is not related to NurbsCurve, CubicCurveseg or -// any of the ParametricCurve-derived objects in this -// module. It is a completely parallel implementation -// of NURBS curves, and will probably eventually replace -// the whole ParametricCurve class hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single control vertex in a NurbsEvaluator. It may be + * relative to a particular coordinate space; or its coordinate space may be + * unspecified. + * + * This is not related to NurbsCurve, CubicCurveseg or any of the + * ParametricCurve-derived objects in this module. It is a completely + * parallel implementation of NURBS curves, and will probably eventually + * replace the whole ParametricCurve class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS NurbsVertex { public: INLINE NurbsVertex(); @@ -61,4 +57,3 @@ private: #include "nurbsVertex.I" #endif - diff --git a/panda/src/parametrics/parametricCurve.cxx b/panda/src/parametrics/parametricCurve.cxx index 149bd11c08..403f9e8c04 100644 --- a/panda/src/parametrics/parametricCurve.cxx +++ b/panda/src/parametrics/parametricCurve.cxx @@ -1,16 +1,15 @@ -// Filename: parametricCurve.cxx -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parametricCurve.cxx + * @author drose + * @date 2001-03-04 + */ #include "parametricCurve.h" #include "config_parametrics.h" @@ -28,102 +27,80 @@ static const PN_stdfloat tolerance_divisor = 100000.0f; TypeHandle ParametricCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::Constructor -// Access: Public -// Description: This is a virtual base class. Don't try to construct -// one from Scheme. -//////////////////////////////////////////////////////////////////// +/** + * This is a virtual base class. Don't try to construct one from Scheme. + */ ParametricCurve:: ParametricCurve() : PandaNode("curve") { _curve_type = PCT_NONE; _num_dimensions = 3; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParametricCurve:: ~ParametricCurve() { - // Our drawer list must be empty by the time we destruct, since our - // drawers all maintain reference-counting pointers to us! If this - // is not so, we have lost a reference count somewhere, or we have - // gotten confused about which drawers we're registered to. + // Our drawer list must be empty by the time we destruct, since our drawers + // all maintain reference-counting pointers to us! If this is not so, we + // have lost a reference count somewhere, or we have gotten confused about + // which drawers we're registered to. nassertv(_drawers.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of PandaNode by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * PandaNode by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool ParametricCurve:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of PandaNode by calling the -// xform() method, false otherwise. For instance, it's -// usually a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * PandaNode by calling the xform() method, false otherwise. For instance, + * it's usually a bad idea to attempt to xform a Character. + */ bool ParametricCurve:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::is_valid -// Access: Published, Virtual -// Description: Returns true if the curve is defined. This base -// class function always returns true; derived classes -// might override this to sometimes return false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the curve is defined. This base class function always + * returns true; derived classes might override this to sometimes return + * false. + */ bool ParametricCurve:: is_valid() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_max_t -// Access: Published, Virtual -// Description: Returns the upper bound of t for the entire curve. -// The curve is defined in the range 0.0f <= t <= -// get_max_t(). This base class function always returns -// 1.0f; derived classes might override this to return -// something else. -//////////////////////////////////////////////////////////////////// +/** + * Returns the upper bound of t for the entire curve. The curve is defined in + * the range 0.0f <= t <= get_max_t(). This base class function always + * returns 1.0f; derived classes might override this to return something else. + */ PN_stdfloat ParametricCurve:: get_max_t() const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::set_curve_type -// Access: Published -// Description: Sets the flag indicating the use to which the curve -// is intended to be put. This flag is optional and -// only serves to provide a hint to the egg reader and -// writer code; it has no effect on the curve's -// behavior. -// -// Setting the curve type also sets the num_dimensions -// to 3 or 1 according to the type. -// -// THis flag may have one of the values PCT_XYZ, -// PCT_HPR, or PCT_T. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating the use to which the curve is intended to be put. + * This flag is optional and only serves to provide a hint to the egg reader + * and writer code; it has no effect on the curve's behavior. + * + * Setting the curve type also sets the num_dimensions to 3 or 1 according to + * the type. + * + * THis flag may have one of the values PCT_XYZ, PCT_HPR, or PCT_T. + */ void ParametricCurve:: set_curve_type(int type) { _curve_type = type; @@ -143,71 +120,57 @@ set_curve_type(int type) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_curve_type -// Access: Published -// Description: Returns the flag indicating the use to which the curve -// is intended to be put. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag indicating the use to which the curve is intended to be + * put. + */ int ParametricCurve:: get_curve_type() const { return _curve_type; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::set_num_dimensions -// Access: Published -// Description: Specifies the number of significant dimensions in the -// curve's vertices. This should be one of 1, 2, or 3. -// Normally, XYZ and HPR curves have three dimensions; -// time curves should always have one dimension. This -// only serves as a hint to the mopath editor, and also -// controls how the curve is written out. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of significant dimensions in the curve's vertices. + * This should be one of 1, 2, or 3. Normally, XYZ and HPR curves have three + * dimensions; time curves should always have one dimension. This only serves + * as a hint to the mopath editor, and also controls how the curve is written + * out. + */ void ParametricCurve:: set_num_dimensions(int num) { _num_dimensions = num; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_num_dimensions -// Access: Published -// Description: Returns the number of significant dimensions in the -// curve's vertices, as set by a previous call to -// set_num_dimensions(). This is only a hint as to how -// the curve is intended to be used; the actual number -// of dimensions of any curve is always three. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of significant dimensions in the curve's vertices, as + * set by a previous call to set_num_dimensions(). This is only a hint as to + * how the curve is intended to be used; the actual number of dimensions of + * any curve is always three. + */ int ParametricCurve:: get_num_dimensions() const { return _num_dimensions; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::calc_length -// Access: Published -// Description: Approximates the length of the entire curve to within -// a few decimal places. -//////////////////////////////////////////////////////////////////// +/** + * Approximates the length of the entire curve to within a few decimal places. + */ PN_stdfloat ParametricCurve:: calc_length() const { return calc_length(0.0f, get_max_t()); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::calc_length -// Access: Published -// Description: Approximates the length of the curve segment from -// parametric time 'from' to time 'to'. -//////////////////////////////////////////////////////////////////// +/** + * Approximates the length of the curve segment from parametric time 'from' to + * time 'to'. + */ PN_stdfloat ParametricCurve:: calc_length(PN_stdfloat from, PN_stdfloat to) const { PN_stdfloat t1, t2; LPoint3 p1, p2; - // Normally we expect from < to. If they came in backwards, reverse - // them. + // Normally we expect from < to. If they came in backwards, reverse them. PN_stdfloat to_minus_from = to - from; if (to_minus_from < 0.0f) { @@ -235,20 +198,16 @@ calc_length(PN_stdfloat from, PN_stdfloat to) const { return net; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::find_length -// Access: Published -// Description: Returns the parametric value corresponding to the -// indicated distance along the curve from the starting -// parametric value. -// -// This is the inverse of calc_length(): rather than -// determining the length along the curve between two -// parametric points, it determines the position in -// parametric time of a point n units along the curve. -// -// The search distance must not be negative. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parametric value corresponding to the indicated distance along + * the curve from the starting parametric value. + * + * This is the inverse of calc_length(): rather than determining the length + * along the curve between two parametric points, it determines the position + * in parametric time of a point n units along the curve. + * + * The search distance must not be negative. + */ PN_stdfloat ParametricCurve:: find_length(PN_stdfloat start_t, PN_stdfloat length_offset) const { nassertr(length_offset >= 0.0f, start_t); @@ -289,63 +248,49 @@ find_length(PN_stdfloat start_t, PN_stdfloat length_offset) const { return max_t; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::adjust_point -// Access: Published, Virtual -// Description: Recomputes the curve such that it passes through the -// point (px, py, pz) at time t, but keeps the same -// tangent value at that point. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it passes through the point (px, py, pz) at + * time t, but keeps the same tangent value at that point. + */ bool ParametricCurve:: adjust_point(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::adjust_tangent -// Access: Published, Virtual -// Description: Recomputes the curve such that it has the tangent -// (tx, ty, tz) at time t, but keeps the same position -// at the point. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it has the tangent (tx, ty, tz) at time t, + * but keeps the same position at the point. + */ bool ParametricCurve:: adjust_tangent(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::adjust_pt -// Access: Published, Virtual -// Description: Recomputes the curve such that it passes through the -// point (px, py, pz) with the tangent (tx, ty, tz). -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it passes through the point (px, py, pz) + * with the tangent (tx, ty, tz). + */ bool ParametricCurve:: adjust_pt(PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat, PN_stdfloat) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::recompute -// Access: Published, Virtual -// Description: Recalculates the curve, if necessary. Returns -// true if the resulting curve is valid, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the curve, if necessary. Returns true if the resulting curve + * is valid, false otherwise. + */ bool ParametricCurve:: recompute() { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::stitch -// Access: Published, Virtual -// Description: Regenerates this curve as one long curve: the first -// curve connected end-to-end with the second one. -// Either a or b may be the same as 'this'. -// -// Returns true if successful, false on failure or if -// the curve type does not support stitching. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates this curve as one long curve: the first curve connected end-to- + * end with the second one. Either a or b may be the same as 'this'. + * + * Returns true if successful, false on failure or if the curve type does not + * support stitching. + */ bool ParametricCurve:: stitch(const ParametricCurve *, const ParametricCurve *) { parametrics_cat.error() @@ -354,13 +299,10 @@ stitch(const ParametricCurve *, const ParametricCurve *) { } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::write_egg -// Access: Published -// Description: Writes an egg description of the nurbs curve to the -// specified output file. Returns true if the file is -// successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Writes an egg description of the nurbs curve to the specified output file. + * Returns true if the file is successfully written. + */ bool ParametricCurve:: write_egg(Filename filename, CoordinateSystem cs) { pofstream out; @@ -374,13 +316,10 @@ write_egg(Filename filename, CoordinateSystem cs) { return write_egg(out, filename, cs); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::write_egg -// Access: Published -// Description: Writes an egg description of the nurbs curve to the -// specified output stream. Returns true if the file is -// successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Writes an egg description of the nurbs curve to the specified output + * stream. Returns true if the file is successfully written. + */ bool ParametricCurve:: write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { string curve_type; @@ -453,52 +392,39 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_bezier_segs -// Access: Public, Virtual -// Description: Fills up the indicated vector with a list of -// BezierSeg structs that describe the curve. This -// assumes the curve is a PiecewiseCurve of -// CubicCurvesegs. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated vector with a list of BezierSeg structs that + * describe the curve. This assumes the curve is a PiecewiseCurve of + * CubicCurvesegs. Returns true if successful, false otherwise. + */ bool ParametricCurve:: get_bezier_segs(ParametricCurve::BezierSegs &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_bezier_seg -// Access: Public, Virtual -// Description: Fills the BezierSeg structure with a description of -// the curve segment as a Bezier, if possible, but does -// not change the _t member of the structure. Returns -// true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills the BezierSeg structure with a description of the curve segment as a + * Bezier, if possible, but does not change the _t member of the structure. + * Returns true if successful, false otherwise. + */ bool ParametricCurve:: get_bezier_seg(ParametricCurve::BezierSeg &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::get_nurbs_interface -// Access: Public, Virtual -// Description: Returns a pointer to the object as a -// NurbsCurveInterface object if it happens to be a -// NURBS-style curve; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the object as a NurbsCurveInterface object if it + * happens to be a NURBS-style curve; otherwise, returns NULL. + */ NurbsCurveInterface *ParametricCurve:: get_nurbs_interface() { return (NurbsCurveInterface *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::convert_to_hermite -// Access: Public, Virtual -// Description: Stores an equivalent curve representation in the -// indicated Hermite curve, if possible. Returns true -// if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Stores an equivalent curve representation in the indicated Hermite curve, + * if possible. Returns true if successful, false otherwise. + */ bool ParametricCurve:: convert_to_hermite(HermiteCurve *hc) const { BezierSegs bz_segs; @@ -508,9 +434,8 @@ convert_to_hermite(HermiteCurve *hc) const { hc->set_curve_type(_curve_type); - // Now convert the Bezier segments to a Hermite. Normally, the - // Beziers will match up head-to-tail, but if they don't, that's a - // cut. + // Now convert the Bezier segments to a Hermite. Normally, the Beziers will + // match up head-to-tail, but if they don't, that's a cut. hc->remove_all_cvs(); int i, n; @@ -565,13 +490,10 @@ convert_to_hermite(HermiteCurve *hc) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::convert_to_nurbs -// Access: Public, Virtual -// Description: Stores in the indicated NurbsCurve a NURBS -// representation of an equivalent curve. Returns true -// if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Stores in the indicated NurbsCurve a NURBS representation of an equivalent + * curve. Returns true if successful, false otherwise. + */ bool ParametricCurve:: convert_to_nurbs(ParametricCurve *nc) const { NurbsCurveInterface *nurbs = nc->get_nurbs_interface(); @@ -624,30 +546,24 @@ convert_to_nurbs(ParametricCurve *nc) const { } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::register_drawer -// Access: Public -// Description: Registers a Drawer with this curve that will -// automatically be updated whenever the curve is -// modified, so that the visible representation of the -// curve is kept up to date. This is called -// automatically by the ParametricCurveDrawer. -// -// Any number of Drawers may be registered with a -// particular curve. -//////////////////////////////////////////////////////////////////// +/** + * Registers a Drawer with this curve that will automatically be updated + * whenever the curve is modified, so that the visible representation of the + * curve is kept up to date. This is called automatically by the + * ParametricCurveDrawer. + * + * Any number of Drawers may be registered with a particular curve. + */ void ParametricCurve:: register_drawer(ParametricCurveDrawer *drawer) { _drawers.push_back(drawer); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::unregister_drawer -// Access: Public -// Description: Removes a previously registered drawer from the list -// of automatically-refreshed drawers. This is called -// automatically by the ParametricCurveDrawer. -//////////////////////////////////////////////////////////////////// +/** + * Removes a previously registered drawer from the list of automatically- + * refreshed drawers. This is called automatically by the + * ParametricCurveDrawer. + */ void ParametricCurve:: unregister_drawer(ParametricCurveDrawer *drawer) { _drawers.remove(drawer); @@ -656,25 +572,19 @@ unregister_drawer(ParametricCurveDrawer *drawer) { -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::invalidate -// Access: Protected -// Description: Called from a base class to mark a section of the -// curve that has been modified and must be redrawn or -// recomputed in some way. -//////////////////////////////////////////////////////////////////// +/** + * Called from a base class to mark a section of the curve that has been + * modified and must be redrawn or recomputed in some way. + */ void ParametricCurve:: invalidate(PN_stdfloat, PN_stdfloat) { invalidate_all(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::invalidate_all -// Access: Protected -// Description: Called from a base class to indicate that the curve -// has changed in some substantial way and must be -// entirely redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Called from a base class to indicate that the curve has changed in some + * substantial way and must be entirely redrawn. + */ void ParametricCurve:: invalidate_all() { /* @@ -687,28 +597,22 @@ invalidate_all() { */ } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::format_egg -// Access: Protected, Virtual -// Description: Formats the curve as an egg structure to write to the -// indicated stream. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Formats the curve as an egg structure to write to the indicated stream. + * Returns true on success, false on failure. + */ bool ParametricCurve:: format_egg(ostream &, const string &, const string &, int) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::r_calc_length -// Access: Private -// Description: The recursive implementation of calc_length. This -// function calculates the length of a segment of the -// curve between points t1 and t2, which presumably -// evaluate to the endpoints p1 and p2, and the segment -// has the length seglength. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of calc_length. This function calculates the + * length of a segment of the curve between points t1 and t2, which presumably + * evaluate to the endpoints p1 and p2, and the segment has the length + * seglength. + */ PN_stdfloat ParametricCurve:: r_calc_length(PN_stdfloat t1, PN_stdfloat t2, const LPoint3 &p1, const LPoint3 &p2, PN_stdfloat seglength) const { @@ -716,8 +620,8 @@ r_calc_length(PN_stdfloat t1, PN_stdfloat t2, const LPoint3 &p1, const LPoint3 & static const PN_stdfloat t_tolerance = 0.000001f; if (t2 - t1 < t_tolerance) { - // Stop recursing--we've just walked off the limit for - // representing smaller values of t. + // Stop recursing--we've just walked off the limit for representing + // smaller values of t. return 0.0f; } @@ -725,8 +629,7 @@ r_calc_length(PN_stdfloat t1, PN_stdfloat t2, const LPoint3 &p1, const LPoint3 & LPoint3 pmid; PN_stdfloat left, right; - // Calculate the point on the curve midway between the two - // endpoints. + // Calculate the point on the curve midway between the two endpoints. tmid = (t1+t2)*0.5f; get_point(tmid, pmid); @@ -744,18 +647,14 @@ r_calc_length(PN_stdfloat t1, PN_stdfloat t2, const LPoint3 &p1, const LPoint3 & } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::r_find_length -// Access: Private -// Description: The recursive implementation of find_length. This is -// similar to r_calc_length, above. target_length is -// the length along the curve past t1 that we hope to -// find. If the indicated target_length falls within -// this segment, returns true and sets found_t to the -// point along the segment. Otherwise, updates -// seglength with the accurate calculated length of the -// segment and returns false. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_length. This is similar to + * r_calc_length, above. target_length is the length along the curve past t1 + * that we hope to find. If the indicated target_length falls within this + * segment, returns true and sets found_t to the point along the segment. + * Otherwise, updates seglength with the accurate calculated length of the + * segment and returns false. + */ bool ParametricCurve:: r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, PN_stdfloat t1, PN_stdfloat t2, @@ -765,8 +664,8 @@ r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, static const PN_stdfloat t_tolerance = 0.000001f; if (target_length < t_tolerance) { - // Stop recursing--we've just walked off the limit for - // representing smaller values of t. + // Stop recursing--we've just walked off the limit for representing + // smaller values of t. found_t = t1; return true; @@ -776,8 +675,7 @@ r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, LPoint3 pmid; PN_stdfloat left, right; - // Calculate the point on the curve midway between the two - // endpoints. + // Calculate the point on the curve midway between the two endpoints. tmid = (t1+t2)*0.5f; get_point(tmid, pmid); @@ -790,8 +688,8 @@ r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, return find_t_linear(target_length, found_t, t1, t2, p1, p2); /* if (target_length <= seglength) { - // Compute t value that corresponds to target_length - // Maybe the point is in the left half of the segment? + // Compute t value that corresponds to target_length Maybe the point is + // in the left half of the segment? if (r_find_t(target_length, found_t, t1, tmid, p1, pmid)) { return true; } @@ -823,17 +721,13 @@ r_find_length(PN_stdfloat target_length, PN_stdfloat &found_t, -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::r_find_t -// Access: Private -// Description: computes the t value in the parametric domain of a -// target point along a straight section of a curve. -// This is similar to r_calc_length, above. -// target_length is the length along the curve past t1 -// that we hope to find. If the indicated target_length -// falls within this segment, returns true and sets -// found_t to the point along the segment. -//////////////////////////////////////////////////////////////////// +/** + * computes the t value in the parametric domain of a target point along a + * straight section of a curve. This is similar to r_calc_length, above. + * target_length is the length along the curve past t1 that we hope to find. + * If the indicated target_length falls within this segment, returns true and + * sets found_t to the point along the segment. + */ bool ParametricCurve:: r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, PN_stdfloat t1, PN_stdfloat t2, @@ -850,7 +744,7 @@ r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, if (target_length < length_tolerance) { found_t = t1; return true; - } + } // No, compute distance between two endpoints PN_stdfloat point_dist; @@ -860,13 +754,13 @@ r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, if (point_dist < target_length) { return false; } - + // Is the target point close to far endpoint? if ( (point_dist - target_length ) < length_tolerance ) { found_t = t2; return true; } - + // are we running out of parametric precision? if ((t2 - t1) < t_tolerance) { found_t = t1; @@ -877,12 +771,11 @@ r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, PN_stdfloat tmid; LPoint3 pmid; PN_stdfloat left; - - // Calculate the point on the curve midway between the two - // endpoints. + + // Calculate the point on the curve midway between the two endpoints. tmid = (t1+t2)*0.5f; get_point(tmid, pmid); - + // Maybe the point is in the left half of the segment? if (r_find_t(target_length, found_t, t1, tmid, p1, pmid)) { return true; @@ -898,11 +791,9 @@ r_find_t(PN_stdfloat target_length, PN_stdfloat &found_t, } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::find_t_linear -// Access: Private -// Description: non-recursive version of r_find_t (see above) -//////////////////////////////////////////////////////////////////// +/** + * non-recursive version of r_find_t (see above) + */ bool ParametricCurve:: find_t_linear(PN_stdfloat target_length, PN_stdfloat &found_t, PN_stdfloat t1, PN_stdfloat t2, @@ -915,8 +806,8 @@ find_t_linear(PN_stdfloat target_length, PN_stdfloat &found_t, << "target_length " << target_length << " t1 " << t1 << " t2 " << t2 << "\n"; } - // first, check to make sure this segment contains the point - // we're looking for + // first, check to make sure this segment contains the point we're looking + // for if (target_length > (p1 - p2).length()) { // segment is too short return false; @@ -973,12 +864,10 @@ find_t_linear(PN_stdfloat target_length, PN_stdfloat &found_t, } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::write_datagram -// Access: Protected, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void ParametricCurve:: write_datagram(BamWriter *manager, Datagram &me) { PandaNode::write_datagram(manager, me); @@ -987,14 +876,11 @@ write_datagram(BamWriter *manager, Datagram &me) { me.add_int8(_num_dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurve::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void ParametricCurve:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/parametrics/parametricCurve.h b/panda/src/parametrics/parametricCurve.h index a90e79780c..aa4dfc8f2d 100644 --- a/panda/src/parametrics/parametricCurve.h +++ b/panda/src/parametrics/parametricCurve.h @@ -1,16 +1,15 @@ -// Filename: parametricCurve.h -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parametricCurve.h + * @author drose + * @date 2001-03-04 + */ #ifndef PARAMETRICCURVE_H #define PARAMETRICCURVE_H @@ -25,10 +24,9 @@ #include "pvector.h" -// Parametric curve semantic types. A parametric curve may have one -// of these types specified. These serve as hints to the egg reader -// and writer code about the intention of this curve, and have no -// other effect on the curve. +// Parametric curve semantic types. A parametric curve may have one of these +// types specified. These serve as hints to the egg reader and writer code +// about the intention of this curve, and have no other effect on the curve. BEGIN_PUBLISH //[ #define PCT_NONE 0 @@ -51,12 +49,10 @@ class NurbsCurve; class NurbsCurveInterface; -//////////////////////////////////////////////////////////////////// -// Class : ParametricCurve -// Description : A virtual base class for parametric curves. -// This encapsulates all curves in 3-d space defined -// for a single parameter t in the range [0,get_max_t()]. -//////////////////////////////////////////////////////////////////// +/** + * A virtual base class for parametric curves. This encapsulates all curves + * in 3-d space defined for a single parameter t in the range [0,get_max_t()]. + */ class EXPCL_PANDA_PARAMETRICS ParametricCurve : public PandaNode { PUBLISHED: ParametricCurve(); diff --git a/panda/src/parametrics/parametricCurveCollection.I b/panda/src/parametrics/parametricCurveCollection.I index fed97ba83f..c8549fa0b8 100644 --- a/panda/src/parametrics/parametricCurveCollection.I +++ b/panda/src/parametrics/parametricCurveCollection.I @@ -1,42 +1,34 @@ -// Filename: parametricCurveCollection.I -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parametricCurveCollection.I + * @author drose + * @date 2001-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ParametricCurveCollection:: ~ParametricCurveCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_num_curves -// Access: Published -// Description: Returns the number of ParametricCurves in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of ParametricCurves in the collection. + */ INLINE int ParametricCurveCollection:: get_num_curves() const { return _curves.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_curve -// Access: Published -// Description: Returns the nth ParametricCurve in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth ParametricCurve in the collection. + */ INLINE ParametricCurve *ParametricCurveCollection:: get_curve(int index) const { nassertr(index >= 0 && index < (int)_curves.size(), (ParametricCurve *)NULL); @@ -44,13 +36,11 @@ get_curve(int index) const { return _curves[index]; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_max_t -// Access: Published -// Description: Returns the maximum T value associated with the -// *last* curve in the collection. Normally, this will -// be either the XYZ or HPR curve, or a timewarp curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum T value associated with the *last* curve in the + * collection. Normally, this will be either the XYZ or HPR curve, or a + * timewarp curve. + */ INLINE PN_stdfloat ParametricCurveCollection:: get_max_t() const { if (_curves.empty()) { @@ -59,51 +49,39 @@ get_max_t() const { return _curves.back()->get_max_t(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::evaluate_xyz -// Access: Published -// Description: Computes only the XYZ part of the curves. See -// evaluate(). -//////////////////////////////////////////////////////////////////// +/** + * Computes only the XYZ part of the curves. See evaluate(). + */ INLINE bool ParametricCurveCollection:: evaluate_xyz(PN_stdfloat t, LVecBase3 &xyz) const { LVecBase3 hpr; return evaluate(t, xyz, hpr); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::evaluate_hpr -// Access: Published -// Description: Computes only the HPR part of the curves. See -// evaluate(). -//////////////////////////////////////////////////////////////////// +/** + * Computes only the HPR part of the curves. See evaluate(). + */ INLINE bool ParametricCurveCollection:: evaluate_hpr(PN_stdfloat t, LVecBase3 &hpr) const { LVecBase3 xyz; return evaluate(t, xyz, hpr); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::adjust_xyz -// Access: Published -// Description: Adjust the XYZ curve at the indicated time to the new -// value. The curve shape will change correspondingly. -// Returns true if successful, false if unable to make -// the adjustment for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Adjust the XYZ curve at the indicated time to the new value. The curve + * shape will change correspondingly. Returns true if successful, false if + * unable to make the adjustment for some reason. + */ INLINE bool ParametricCurveCollection:: adjust_xyz(PN_stdfloat t, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { return adjust_xyz(t, LVecBase3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::adjust_hpr -// Access: Published -// Description: Adjust the HPR curve at the indicated time to the new -// value. The curve shape will change correspondingly. -// Returns true if successful, false if unable to make -// the adjustment for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Adjust the HPR curve at the indicated time to the new value. The curve + * shape will change correspondingly. Returns true if successful, false if + * unable to make the adjustment for some reason. + */ INLINE bool ParametricCurveCollection:: adjust_hpr(PN_stdfloat t, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { return adjust_hpr(t, LVecBase3(h, p, r)); diff --git a/panda/src/parametrics/parametricCurveCollection.cxx b/panda/src/parametrics/parametricCurveCollection.cxx index 00701b2fb6..98e9a0459e 100644 --- a/panda/src/parametrics/parametricCurveCollection.cxx +++ b/panda/src/parametrics/parametricCurveCollection.cxx @@ -1,16 +1,15 @@ -// Filename: parametricCurveCollection.cxx -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parametricCurveCollection.cxx + * @author drose + * @date 2001-03-04 + */ #include "parametricCurveCollection.h" #include "config_parametrics.h" @@ -22,20 +21,16 @@ #include "string_utils.h" #include "look_at.h" -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParametricCurveCollection:: ParametricCurveCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::add_curve -// Access: Published -// Description: Adds a new ParametricCurve to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new ParametricCurve to the collection. + */ void ParametricCurveCollection:: add_curve(ParametricCurve *curve) { prepare_add_curve(curve); @@ -43,12 +38,9 @@ add_curve(ParametricCurve *curve) { redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::add_curve -// Access: Published -// Description: Adds a new ParametricCurve to the collection at the -// indicated index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new ParametricCurve to the collection at the indicated index. + */ void ParametricCurveCollection:: add_curve(ParametricCurve *curve, int index) { prepare_add_curve(curve); @@ -57,13 +49,10 @@ add_curve(ParametricCurve *curve, int index) { redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::add_curves -// Access: Published -// Description: Adds all the curves found in the scene graph rooted -// at the given node. Returns the number of curves -// found. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the curves found in the scene graph rooted at the given node. + * Returns the number of curves found. + */ int ParametricCurveCollection:: add_curves(PandaNode *node) { int num_curves = r_add_curves(node); @@ -75,13 +64,10 @@ add_curves(PandaNode *node) { return num_curves; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::remove_curve -// Access: Published -// Description: Removes the indicated ParametricCurve from the -// collection. Returns true if the curve was removed, -// false if it was not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated ParametricCurve from the collection. Returns true if + * the curve was removed, false if it was not a member of the collection. + */ bool ParametricCurveCollection:: remove_curve(ParametricCurve *curve) { int curve_index = -1; @@ -101,12 +87,10 @@ remove_curve(ParametricCurve *curve) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::remove_curve -// Access: Published -// Description: Removes the indicated ParametricCurve from the -// collection, by its index number. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated ParametricCurve from the collection, by its index + * number. + */ void ParametricCurveCollection:: remove_curve(int index) { nassertv(index >= 0 && index < (int)_curves.size()); @@ -116,12 +100,10 @@ remove_curve(int index) { redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::has_curve -// Access: Published -// Description: Returns true if the indicated ParametricCurve appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated ParametricCurve appears in this collection, + * false otherwise. + */ bool ParametricCurveCollection:: has_curve(ParametricCurve *curve) const { ParametricCurves::const_iterator ci; @@ -133,11 +115,9 @@ has_curve(ParametricCurve *curve) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::clear -// Access: Published -// Description: Removes all ParametricCurves from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all ParametricCurves from the collection. + */ void ParametricCurveCollection:: clear() { ParametricCurves::iterator ci; @@ -150,11 +130,9 @@ clear() { redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::clear_timewarps -// Access: Published -// Description: Removes all the timewarp curves from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the timewarp curves from the collection. + */ void ParametricCurveCollection:: clear_timewarps() { PT(ParametricCurve) xyz_curve = (ParametricCurve *)NULL; @@ -196,12 +174,10 @@ clear_timewarps() { redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_xyz_curve -// Access: Published -// Description: Returns the first XYZ curve in the collection, if -// any, or NULL if there are none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first XYZ curve in the collection, if any, or NULL if there are + * none. + */ ParametricCurve *ParametricCurveCollection:: get_xyz_curve() const { ParametricCurves::const_iterator ci; @@ -214,12 +190,10 @@ get_xyz_curve() const { return (ParametricCurve *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_hpr_curve -// Access: Published -// Description: Returns the first HPR curve in the collection, if -// any, or NULL if there are none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first HPR curve in the collection, if any, or NULL if there are + * none. + */ ParametricCurve *ParametricCurveCollection:: get_hpr_curve() const { ParametricCurves::const_iterator ci; @@ -232,14 +206,11 @@ get_hpr_curve() const { return (ParametricCurve *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_default_curve -// Access: Published -// Description: If there is an XYZ curve in the collection, returns -// it; otherwise, returns the first curve whose type is -// unspecified. Returns NULL if no curve meets the -// criteria. -//////////////////////////////////////////////////////////////////// +/** + * If there is an XYZ curve in the collection, returns it; otherwise, returns + * the first curve whose type is unspecified. Returns NULL if no curve meets + * the criteria. + */ ParametricCurve *ParametricCurveCollection:: get_default_curve() const { ParametricCurve *xyz_curve = get_xyz_curve(); @@ -257,12 +228,9 @@ get_default_curve() const { return (ParametricCurve *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_num_timewarps -// Access: Published -// Description: Returns the number of timewarp curves in the -// collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of timewarp curves in the collection. + */ int ParametricCurveCollection:: get_num_timewarps() const { int count = 0; @@ -278,11 +246,9 @@ get_num_timewarps() const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::get_timewarp_curve -// Access: Published -// Description: Returns the nth timewarp curve in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth timewarp curve in the collection. + */ ParametricCurve *ParametricCurveCollection:: get_timewarp_curve(int n) const { ParametricCurves::const_iterator ci; @@ -299,23 +265,18 @@ get_timewarp_curve(int n) const { return (ParametricCurve *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::make_even -// Access: Published -// Description: Discards all existing timewarp curves and recomputes -// a new timewarp curve that maps distance along the -// curve to parametric time, so that the distance -// between any two points in parametric time is -// proportional to the approximate distance of those -// same two points along the XYZ curve. -// -// segments_per_unit represents the number of segments to -// take per each unit of parametric time of the original -// XYZ curve. -// -// The new timewarp curve (and thus, the apparent range -// of the collection) will range from 0 to max_t. -//////////////////////////////////////////////////////////////////// +/** + * Discards all existing timewarp curves and recomputes a new timewarp curve + * that maps distance along the curve to parametric time, so that the distance + * between any two points in parametric time is proportional to the + * approximate distance of those same two points along the XYZ curve. + * + * segments_per_unit represents the number of segments to take per each unit + * of parametric time of the original XYZ curve. + * + * The new timewarp curve (and thus, the apparent range of the collection) + * will range from 0 to max_t. + */ void ParametricCurveCollection:: make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); @@ -327,8 +288,8 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { clear_timewarps(); - // Now divvy up the XYZ curve into num_segments sections, each - // approximately the same length as all the others. + // Now divvy up the XYZ curve into num_segments sections, each approximately + // the same length as all the others. CurveFitter fitter; int num_segments = max(1, (int)cfloor(segments_per_unit * xyz_curve->get_max_t() + 0.5f)); @@ -378,14 +339,11 @@ make_even(PN_stdfloat max_t, PN_stdfloat segments_per_unit) { add_curve(t_curve); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::face_forward -// Access: Published -// Description: Discards the existing HPR curve and generates a new -// one that looks in the direction of travel along the -// XYZ curve, based on the XYZ curve's tangent at each -// point. -//////////////////////////////////////////////////////////////////// +/** + * Discards the existing HPR curve and generates a new one that looks in the + * direction of travel along the XYZ curve, based on the XYZ curve's tangent + * at each point. + */ void ParametricCurveCollection:: face_forward(PN_stdfloat segments_per_unit) { ParametricCurve *xyz_curve = get_xyz_curve(); @@ -395,8 +353,8 @@ face_forward(PN_stdfloat segments_per_unit) { return; } - // Eliminate all the old hpr curves, and also take note of the index - // number of the first XYZ curve. + // Eliminate all the old hpr curves, and also take note of the index number + // of the first XYZ curve. int xyz_index = -1; ParametricCurves::const_iterator ci; ParametricCurves new_curves; @@ -414,8 +372,8 @@ face_forward(PN_stdfloat segments_per_unit) { } _curves.swap(new_curves); - // Now divvy up the XYZ curve into num_segments sections, of equal - // length in parametric time (based on the timewarp curves). + // Now divvy up the XYZ curve into num_segments sections, of equal length in + // parametric time (based on the timewarp curves). CurveFitter fitter; PN_stdfloat max_t = get_max_t(); @@ -423,9 +381,9 @@ face_forward(PN_stdfloat segments_per_unit) { LVecBase3 hpr(0.0f, 0.0f, 0.0f); - // We compute the first HPR point a little point into the beginning - // of the curve, instead of at 0.0f, because the tangent at 0.0f is - // likely to be zero. + // We compute the first HPR point a little point into the beginning of the + // curve, instead of at 0.0f, because the tangent at 0.0f is likely to be + // zero. determine_hpr(0.001, xyz_curve, hpr); fitter.add_hpr(0.0f, hpr); @@ -443,15 +401,12 @@ face_forward(PN_stdfloat segments_per_unit) { add_curve(hpr_curve, xyz_index + 1); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::reset_max_t -// Access: Published -// Description: Adjusts the apparent length of the curve by applying -// a new timewarp that maps the range [0..max_t] to the -// range [0..get_max_t()]. After this call, the curve -// collection will contain one more timewarp curve, and -// get_max_t() will return the given max_t value. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the apparent length of the curve by applying a new timewarp that + * maps the range [0..max_t] to the range [0..get_max_t()]. After this call, + * the curve collection will contain one more timewarp curve, and get_max_t() + * will return the given max_t value. + */ void ParametricCurveCollection:: reset_max_t(PN_stdfloat max_t) { // Define a linear NURBS curve. @@ -468,24 +423,20 @@ reset_max_t(PN_stdfloat max_t) { add_curve(nurbs); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::evaluate -// Access: Published -// Description: Computes the position and rotation represented by the -// first XYZ and HPR curves in the collection at the -// given point t, after t has been modified by all the -// timewarp curves in the collection applied in -// sequence, from back to front. -// -// Returns true if the point is valid (i.e. t is within -// the bounds indicated by all the timewarp curves and -// within the bounds of the curves themselves), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Computes the position and rotation represented by the first XYZ and HPR + * curves in the collection at the given point t, after t has been modified by + * all the timewarp curves in the collection applied in sequence, from back to + * front. + * + * Returns true if the point is valid (i.e. t is within the bounds indicated + * by all the timewarp curves and within the bounds of the curves themselves), + * or false otherwise. + */ bool ParametricCurveCollection:: evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { - // First, apply all the timewarps in sequence, from back to front. - // Also take note of the XYZ and HPR curves. + // First, apply all the timewarps in sequence, from back to front. Also + // take note of the XYZ and HPR curves. ParametricCurve *xyz_curve = (ParametricCurve *)NULL; ParametricCurve *hpr_curve = (ParametricCurve *)NULL; ParametricCurve *default_curve = (ParametricCurve *)NULL; @@ -538,22 +489,17 @@ evaluate(PN_stdfloat t, LVecBase3 &xyz, LVecBase3 &hpr) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::evaluate -// Access: Published -// Description: Computes the transform matrix representing -// translation to the position indicated by the first -// XYZ curve in the collection and the rotation -// indicated by the first HPR curve in the collection, -// after t has been modified by all the timewarp curves -// in the collection applied in sequence, from back to -// front. -// -// Returns true if the point is valid (i.e. t is within -// the bounds indicated by all the timewarp curves and -// within the bounds of the curves themselves), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Computes the transform matrix representing translation to the position + * indicated by the first XYZ curve in the collection and the rotation + * indicated by the first HPR curve in the collection, after t has been + * modified by all the timewarp curves in the collection applied in sequence, + * from back to front. + * + * Returns true if the point is valid (i.e. t is within the bounds indicated + * by all the timewarp curves and within the bounds of the curves themselves), + * or false otherwise. + */ bool ParametricCurveCollection:: evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs) const { LVecBase3 xyz(0.0f, 0.0f, 0.0f); @@ -563,21 +509,18 @@ evaluate(PN_stdfloat t, LMatrix4 &result, CoordinateSystem cs) const { return false; } - compose_matrix(result, - LVecBase3(1.0f, 1.0f, 1.0f), + compose_matrix(result, + LVecBase3(1.0f, 1.0f, 1.0f), LVecBase3(0.0f, 0.0f, 0.0f), hpr, xyz, cs); return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::evaluate_t -// Access: Published -// Description: Determines the value of t that should be passed to -// the XYZ and HPR curves, after applying the given -// value of t to all the timewarps. Return -1.0f if the -// value of t exceeds one of the timewarps' ranges. -//////////////////////////////////////////////////////////////////// +/** + * Determines the value of t that should be passed to the XYZ and HPR curves, + * after applying the given value of t to all the timewarps. Return -1.0f if + * the value of t exceeds one of the timewarps' ranges. + */ PN_stdfloat ParametricCurveCollection:: evaluate_t(PN_stdfloat t) const { PN_stdfloat t0 = t; @@ -598,14 +541,11 @@ evaluate_t(PN_stdfloat t) const { return t0; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::adjust_xyz -// Access: Published -// Description: Adjust the XYZ curve at the indicated time to the new -// value. The curve shape will change correspondingly. -// Returns true if successful, false if unable to make -// the adjustment for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Adjust the XYZ curve at the indicated time to the new value. The curve + * shape will change correspondingly. Returns true if successful, false if + * unable to make the adjustment for some reason. + */ bool ParametricCurveCollection:: adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { ParametricCurve *xyz_curve = get_xyz_curve(); @@ -620,14 +560,11 @@ adjust_xyz(PN_stdfloat t, const LVecBase3 &xyz) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::adjust_hpr -// Access: Published -// Description: Adjust the HPR curve at the indicated time to the new -// value. The curve shape will change correspondingly. -// Returns true if successful, false if unable to make -// the adjustment for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Adjust the HPR curve at the indicated time to the new value. The curve + * shape will change correspondingly. Returns true if successful, false if + * unable to make the adjustment for some reason. + */ bool ParametricCurveCollection:: adjust_hpr(PN_stdfloat t, const LVecBase3 &hpr) { ParametricCurve *hpr_curve = get_hpr_curve(); @@ -642,13 +579,10 @@ adjust_hpr(PN_stdfloat t, const LVecBase3 &hpr) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::recompute -// Access: Published -// Description: Ensures all the curves are freshly computed and -// up-to-date. Returns true if everything is valid, -// false if at least one curve is incorrect. -//////////////////////////////////////////////////////////////////// +/** + * Ensures all the curves are freshly computed and up-to-date. Returns true + * if everything is valid, false if at least one curve is incorrect. + */ bool ParametricCurveCollection:: recompute() { bool all_ok = true; @@ -664,16 +598,13 @@ recompute() { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::stitch -// Access: Published -// Description: Regenerates this curve as one long curve: the first -// curve connected end-to-end with the second one. -// Either a or b may be the same as 'this'. This will -// lose any timewarps on the input curves. -// -// Returns true if successful, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates this curve as one long curve: the first curve connected end-to- + * end with the second one. Either a or b may be the same as 'this'. This + * will lose any timewarps on the input curves. + * + * Returns true if successful, false on failure. + */ bool ParametricCurveCollection:: stitch(const ParametricCurveCollection *a, const ParametricCurveCollection *b) { @@ -706,12 +637,10 @@ stitch(const ParametricCurveCollection *a, return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// ParametricCurveCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the ParametricCurveCollection to the + * indicated output stream. + */ void ParametricCurveCollection:: output(ostream &out) const { if (get_num_curves() == 1) { @@ -721,12 +650,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// ParametricCurveCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the ParametricCurveCollection + * to the indicated output stream. + */ void ParametricCurveCollection:: write(ostream &out, int indent_level) const { ParametricCurves::const_iterator ci; @@ -736,13 +663,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::write_egg -// Access: Published -// Description: Writes an egg description of all the nurbs curves in -// the collection to the specified output file. Returns -// true if the file is successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Writes an egg description of all the nurbs curves in the collection to the + * specified output file. Returns true if the file is successfully written. + */ bool ParametricCurveCollection:: write_egg(Filename filename, CoordinateSystem cs) { pofstream out; @@ -756,13 +680,10 @@ write_egg(Filename filename, CoordinateSystem cs) { return write_egg(out, filename, cs); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::write_egg -// Access: Published -// Description: Writes an egg description of all the nurbs curves in -// the collection to the specified output stream. Returns -// true if the file is successfully written. -//////////////////////////////////////////////////////////////////// +/** + * Writes an egg description of all the nurbs curves in the collection to the + * specified output stream. Returns true if the file is successfully written. + */ bool ParametricCurveCollection:: write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { if (cs == CS_default) { @@ -843,11 +764,9 @@ write_egg(ostream &out, const Filename &filename, CoordinateSystem cs) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::r_add_curves -// Access: Private -// Description: The recursive implementation of add_curves(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of add_curves(). + */ int ParametricCurveCollection:: r_add_curves(PandaNode *node) { int num_curves = 0; @@ -868,18 +787,14 @@ r_add_curves(PandaNode *node) { return num_curves; } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::register_drawer -// Access: Public -// Description: Registers a Drawer with this curve collection that -// will automatically be updated whenever the collection -// is modified, so that the visible representation of -// the curve is kept up to date. This is called -// automatically by the ParametricCurveDrawer. -// -// Any number of Drawers may be registered with a -// particular curve collection. -//////////////////////////////////////////////////////////////////// +/** + * Registers a Drawer with this curve collection that will automatically be + * updated whenever the collection is modified, so that the visible + * representation of the curve is kept up to date. This is called + * automatically by the ParametricCurveDrawer. + * + * Any number of Drawers may be registered with a particular curve collection. + */ void ParametricCurveCollection:: register_drawer(ParametricCurveDrawer *drawer) { _drawers.push_back(drawer); @@ -891,13 +806,11 @@ register_drawer(ParametricCurveDrawer *drawer) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::unregister_drawer -// Access: Public -// Description: Removes a previously registered drawer from the list -// of automatically-refreshed drawers. This is called -// automatically by the ParametricCurveDrawer. -//////////////////////////////////////////////////////////////////// +/** + * Removes a previously registered drawer from the list of automatically- + * refreshed drawers. This is called automatically by the + * ParametricCurveDrawer. + */ void ParametricCurveCollection:: unregister_drawer(ParametricCurveDrawer *drawer) { _drawers.remove(drawer); @@ -909,14 +822,11 @@ unregister_drawer(ParametricCurveDrawer *drawer) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::determine_hpr -// Access: Private -// Description: Computes the orientation at the given point in time, -// based on the tangent of the XYZ curve. Returns true -// if the orientation can be determined, or false if it -// cannot (in which case hpr is left unchanged). -//////////////////////////////////////////////////////////////////// +/** + * Computes the orientation at the given point in time, based on the tangent + * of the XYZ curve. Returns true if the orientation can be determined, or + * false if it cannot (in which case hpr is left unchanged). + */ bool ParametricCurveCollection:: determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const { PN_stdfloat t0 = evaluate_t(t); @@ -937,13 +847,10 @@ determine_hpr(PN_stdfloat t, ParametricCurve *xyz_curve, LVecBase3 &hpr) const { return decompose_matrix(mat, scale, shear, hpr); } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::prepare_add_curve -// Access: Private -// Description: Registers the curve with the list of drawers that -// share this collection, in preparation for adding it -// to the _curves list. -//////////////////////////////////////////////////////////////////// +/** + * Registers the curve with the list of drawers that share this collection, in + * preparation for adding it to the _curves list. + */ void ParametricCurveCollection:: prepare_add_curve(ParametricCurve *curve) { DrawerList::iterator di; @@ -953,13 +860,10 @@ prepare_add_curve(ParametricCurve *curve) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::prepare_remove_curve -// Access: Private -// Description: Unregisters the curve with the list of drawers that -// share this collection, in preparation for removing it -// from the _curves list. -//////////////////////////////////////////////////////////////////// +/** + * Unregisters the curve with the list of drawers that share this collection, + * in preparation for removing it from the _curves list. + */ void ParametricCurveCollection:: prepare_remove_curve(ParametricCurve *curve) { DrawerList::iterator di; @@ -969,12 +873,9 @@ prepare_remove_curve(ParametricCurve *curve) { } } -//////////////////////////////////////////////////////////////////// -// Function: ParametricCurveCollection::redraw -// Access: Private -// Description: Calls redraw() on all drawers that share this -// collection. -//////////////////////////////////////////////////////////////////// +/** + * Calls redraw() on all drawers that share this collection. + */ void ParametricCurveCollection:: redraw() { /* diff --git a/panda/src/parametrics/parametricCurveCollection.h b/panda/src/parametrics/parametricCurveCollection.h index 01d505234b..446c0a4e8d 100644 --- a/panda/src/parametrics/parametricCurveCollection.h +++ b/panda/src/parametrics/parametricCurveCollection.h @@ -1,16 +1,15 @@ -// Filename: parametricCurveCollection.h -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parametricCurveCollection.h + * @author drose + * @date 2001-03-04 + */ #ifndef NODEPATHCOLLECTION_H #define NODEPATHCOLLECTION_H @@ -28,16 +27,13 @@ class ParametricCurveDrawer; -//////////////////////////////////////////////////////////////////// -// Class : ParametricCurveCollection -// Description : This is a set of zero or more ParametricCurves, which -// may or may not be related. If they are related, the -// set should contain no more than one XYZ curve, no -// more than one HPR curve, and zero or more Timewarp -// curves, which can then be evaluated as a unit to -// return a single transformation matrix for a given -// unit of time. -//////////////////////////////////////////////////////////////////// +/** + * This is a set of zero or more ParametricCurves, which may or may not be + * related. If they are related, the set should contain no more than one XYZ + * curve, no more than one HPR curve, and zero or more Timewarp curves, which + * can then be evaluated as a unit to return a single transformation matrix + * for a given unit of time. + */ class EXPCL_PANDA_PARAMETRICS ParametricCurveCollection : public ReferenceCount { PUBLISHED: ParametricCurveCollection(); @@ -119,5 +115,3 @@ operator << (ostream &out, const ParametricCurveCollection &col) { #include "parametricCurveCollection.I" #endif - - diff --git a/panda/src/parametrics/piecewiseCurve.cxx b/panda/src/parametrics/piecewiseCurve.cxx index 3e412ba8e3..cbaa7497f6 100644 --- a/panda/src/parametrics/piecewiseCurve.cxx +++ b/panda/src/parametrics/piecewiseCurve.cxx @@ -1,16 +1,15 @@ -// Filename: piecewiseCurve.cxx -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file piecewiseCurve.cxx + * @author drose + * @date 2001-03-04 + */ #include "piecewiseCurve.h" #include "cubicCurveseg.h" @@ -23,61 +22,48 @@ TypeHandle PiecewiseCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PiecewiseCurve:: PiecewiseCurve() { _last_ti = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PiecewiseCurve:: ~PiecewiseCurve() { remove_all_curvesegs(); } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::is_valid -// Access: Published, Virtual -// Description: Returns true if the curve is defined. In the case of -// a PiecewiseCurve, this means we have at least one -// segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the curve is defined. In the case of a PiecewiseCurve, + * this means we have at least one segment. + */ bool PiecewiseCurve:: is_valid() const { return !_segs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_max_t -// Access: Published, Virtual -// Description: Returns the upper bound of t for the entire curve. -// The curve is defined in the range 0.0f <= t <= -// get_max_t(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the upper bound of t for the entire curve. The curve is defined in + * the range 0.0f <= t <= get_max_t(). + */ PN_stdfloat PiecewiseCurve:: get_max_t() const { return _segs.empty() ? 0.0f : _segs.back()._tend; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_point -// Access: Published, Virtual -// Description: Returns the point of the curve at a given parametric -// point t. Returns true if t is in the valid range 0.0f -// <= t <= get_max_t(); if t is outside this range, sets -// point to the value of the curve at the beginning or -// end (whichever is nearer) and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point of the curve at a given parametric point t. Returns true + * if t is in the valid range 0.0f <= t <= get_max_t(); if t is outside this + * range, sets point to the value of the curve at the beginning or end + * (whichever is nearer) and returns false. + */ bool PiecewiseCurve:: get_point(PN_stdfloat t, LVecBase3 &point) const { const ParametricCurve *curve; @@ -90,12 +76,9 @@ get_point(PN_stdfloat t, LVecBase3 &point) const { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_tangent -// Access: Published, Virtual -// Description: Returns the tangent of the curve at a given parametric -// point t. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tangent of the curve at a given parametric point t. + */ bool PiecewiseCurve:: get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { const ParametricCurve *curve; @@ -106,12 +89,9 @@ get_tangent(PN_stdfloat t, LVecBase3 &tangent) const { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_2ndtangent -// Access: Published, Virtual -// Description: Returns the tangent of the first derivative of the -// curve at the point t. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tangent of the first derivative of the curve at the point t. + */ bool PiecewiseCurve:: get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { const ParametricCurve *curve; @@ -121,13 +101,10 @@ get_2ndtangent(PN_stdfloat t, LVecBase3 &tangent2) const { return result | curve->get_2ndtangent(t, tangent2); } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::adjust_point -// Access: Published, Virtual -// Description: Recomputes the curve such that it passes through the -// point (px, py, pz) at time t, but keeps the same -// tangent value at that point. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it passes through the point (px, py, pz) at + * time t, but keeps the same tangent value at that point. + */ bool PiecewiseCurve:: adjust_point(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz) { @@ -152,13 +129,10 @@ adjust_point(PN_stdfloat t, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::adjust_tangent -// Access: Published, Virtual -// Description: Recomputes the curve such that it has the tangent -// (tx, ty, tz) at time t, but keeps the same position -// at the point. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it has the tangent (tx, ty, tz) at time t, + * but keeps the same position at the point. + */ bool PiecewiseCurve:: adjust_tangent(PN_stdfloat t, PN_stdfloat tx, PN_stdfloat ty, PN_stdfloat tz) { @@ -177,12 +151,10 @@ adjust_tangent(PN_stdfloat t, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::adjust_pt -// Access: Published, Virtual -// Description: Recomputes the curve such that it passes through the -// point (px, py, pz) with the tangent (tx, ty, tz). -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the curve such that it passes through the point (px, py, pz) + * with the tangent (tx, ty, tz). + */ bool PiecewiseCurve:: adjust_pt(PN_stdfloat t, PN_stdfloat px, PN_stdfloat py, PN_stdfloat pz, @@ -203,12 +175,10 @@ adjust_pt(PN_stdfloat t, } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_pt -// Access: Published, Virtual -// Description: Simultaneously returns the point and tangent of the -// curve at a given parametric point t. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously returns the point and tangent of the curve at a given + * parametric point t. + */ bool PiecewiseCurve:: get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { const ParametricCurve *curve; @@ -219,23 +189,17 @@ get_pt(PN_stdfloat t, LVecBase3 &point, LVecBase3 &tangent) const { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_num_segs -// Access: Public -// Description: Returns the number of curve segments that make up the -// Piecewise curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of curve segments that make up the Piecewise curve. + */ int PiecewiseCurve:: get_num_segs() const { return _segs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_curveseg -// Access: Public -// Description: Returns the curve segment corresponding to the given -// index. -//////////////////////////////////////////////////////////////////// +/** + * Returns the curve segment corresponding to the given index. + */ ParametricCurve *PiecewiseCurve:: get_curveseg(int ti) { assert(ti >= 0 && ti < (int)_segs.size()); @@ -243,19 +207,15 @@ get_curveseg(int ti) { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::insert_curveseg -// Access: Public -// Description: Inserts a new curve segment at the indicated index. -// The curve segment must have been allocated via -// new; it will be freed using delete when it is removed -// or the PiecewiseCurve destructs. -// -// If the curve segment is not inserted at the end, its -// tlength is subtracted from that of the following -// segment, so that the overall length of the curve is -// not changed. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a new curve segment at the indicated index. The curve segment must + * have been allocated via new; it will be freed using delete when it is + * removed or the PiecewiseCurve destructs. + * + * If the curve segment is not inserted at the end, its tlength is subtracted + * from that of the following segment, so that the overall length of the curve + * is not changed. + */ bool PiecewiseCurve:: insert_curveseg(int ti, ParametricCurve *seg, PN_stdfloat tlength) { if (ti < 0 || ti > (int)_segs.size()) { @@ -278,13 +238,10 @@ insert_curveseg(int ti, ParametricCurve *seg, PN_stdfloat tlength) { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::remove_curveseg -// Access: Public -// Description: Removes the given curve segment from the curve and -// frees it. Returns true if the segment was defined, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the given curve segment from the curve and frees it. Returns true + * if the segment was defined, false otherwise. + */ bool PiecewiseCurve:: remove_curveseg(int ti) { if (ti < 0 || ti >= (int)_segs.size()) { @@ -294,8 +251,7 @@ remove_curveseg(int ti) { PN_stdfloat tlength = get_tlength(ti); _segs.erase(_segs.begin() + ti); - // Now update the _tend figures for everything after the one we - // removed. + // Now update the _tend figures for everything after the one we removed. while (ti < (int)_segs.size()) { _segs[ti]._tend -= tlength; ti++; @@ -305,47 +261,36 @@ remove_curveseg(int ti) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::remove_all_curvesegs -// Access: Public -// Description: Removes all curve segments from the curve. -//////////////////////////////////////////////////////////////////// +/** + * Removes all curve segments from the curve. + */ void PiecewiseCurve:: remove_all_curvesegs() { _segs.erase(_segs.begin(), _segs.end()); _last_ti = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_tlength -// Access: Public -// Description: Returns the parametric length of the given segment of -// the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parametric length of the given segment of the curve. + */ PN_stdfloat PiecewiseCurve:: get_tlength(int ti) const { assert(ti >= 0 && ti < (int)_segs.size()); return (ti==0) ? _segs[ti]._tend : _segs[ti]._tend - _segs[ti-1]._tend; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_tstart -// Access: Public -// Description: Returns the parametric start of the given segment of -// the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parametric start of the given segment of the curve. + */ PN_stdfloat PiecewiseCurve:: get_tstart(int ti) const { assert(ti >= 0 && ti <= (int)_segs.size()); return (ti==0) ? 0.0f : _segs[ti-1]._tend; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_tend -// Access: Public -// Description: Returns the parametric end of the given segment of -// the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parametric end of the given segment of the curve. + */ PN_stdfloat PiecewiseCurve:: get_tend(int ti) const { assert(ti >= 0 && ti < (int)_segs.size()); @@ -353,14 +298,11 @@ get_tend(int ti) const { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::set_tlength -// Access: Public -// Description: Sets the parametric length of the given segment of -// the curve. The length of the following segment is -// lengthened by the corresponding amount to keep the -// overall length of the curve the same. -//////////////////////////////////////////////////////////////////// +/** + * Sets the parametric length of the given segment of the curve. The length + * of the following segment is lengthened by the corresponding amount to keep + * the overall length of the curve the same. + */ bool PiecewiseCurve:: set_tlength(int ti, PN_stdfloat tlength) { if (ti < 0 || ti >= (int)_segs.size()) { @@ -373,20 +315,15 @@ set_tlength(int ti, PN_stdfloat tlength) { -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::make_nurbs -// Access: Public -// Description: Defines the curve as a general NURBS curve. The -// order is the degree plus one and must be 1, 2, 3, or -// 4; cvs is an array of num_cvs points each with a -// homogeneous coordinate; knots is an array of -// num_cvs+order knot values. -// -// This creates the individual curve segments and sets -// up the basis matrices, but does not store the CV's or -// knot values so the curve shape is not later -// modifiable. -//////////////////////////////////////////////////////////////////// +/** + * Defines the curve as a general NURBS curve. The order is the degree plus + * one and must be 1, 2, 3, or 4; cvs is an array of num_cvs points each with + * a homogeneous coordinate; knots is an array of num_cvs+order knot values. + * + * This creates the individual curve segments and sets up the basis matrices, + * but does not store the CV's or knot values so the curve shape is not later + * modifiable. + */ void PiecewiseCurve:: make_nurbs(int order, int num_cvs, const PN_stdfloat knots[], const LVecBase4 cvs[]) { @@ -404,15 +341,11 @@ make_nurbs(int order, int num_cvs, } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::get_bezier_segs -// Access: Public, Virtual -// Description: Fills up the indicated vector with a list of -// BezierSeg structs that describe the curve. This -// assumes the curve is a PiecewiseCurve of -// CubicCurvesegs. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated vector with a list of BezierSeg structs that + * describe the curve. This assumes the curve is a PiecewiseCurve of + * CubicCurvesegs. Returns true if successful, false otherwise. + */ bool PiecewiseCurve:: get_bezier_segs(BezierSegs &bz_segs) const { bz_segs.erase(bz_segs.begin(), bz_segs.end()); @@ -429,15 +362,12 @@ get_bezier_segs(BezierSegs &bz_segs) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::rebuild_curveseg -// Access: Public, Virtual -// Description: Rebuilds the current curve segment (as selected by -// the most recent call to find_curve()) according to -// the specified properties (see -// CubicCurveseg::compute_seg). Returns true if -// possible, false if something goes horribly wrong. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the current curve segment (as selected by the most recent call to + * find_curve()) according to the specified properties (see + * CubicCurveseg::compute_seg). Returns true if possible, false if something + * goes horribly wrong. + */ bool PiecewiseCurve:: rebuild_curveseg(int, PN_stdfloat, const LVecBase4 &, int, PN_stdfloat, const LVecBase4 &, @@ -447,34 +377,27 @@ rebuild_curveseg(int, PN_stdfloat, const LVecBase4 &, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::find_curve -// Access: Protected -// Description: Finds the curve corresponding to the given value of -// t. If t is inside the curve's defined range, sets -// curve to the appropriate segment, translates t to -// [0,1] to index into the segment's coordinate system, -// and returns true. If t is outside the curve's -// defined range, sets curve to the nearest segment and -// t to the nearest point on this segment, and returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * Finds the curve corresponding to the given value of t. If t is inside the + * curve's defined range, sets curve to the appropriate segment, translates t + * to [0,1] to index into the segment's coordinate system, and returns true. + * If t is outside the curve's defined range, sets curve to the nearest + * segment and t to the nearest point on this segment, and returns false. + */ bool PiecewiseCurve:: find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const { - // Check the index computed by the last call to find_curve(). If - // it's still a reasonable starting value, start searching from - // there. This way, we take advantage of locality of reference: the - // search is trivial it is the same segment as last time, or the - // next segment after the last one. + // Check the index computed by the last call to find_curve(). If it's still + // a reasonable starting value, start searching from there. This way, we + // take advantage of locality of reference: the search is trivial it is the + // same segment as last time, or the next segment after the last one. if (_last_ti>0 && _segs[_last_ti-1]._tend>=t) { - // However, if the new t value precedes that of last time, we'll - // have to start over. + // However, if the new t value precedes that of last time, we'll have to + // start over. - // We do some messy casting so we can get away with assigning a - // value to a member within a const function. This assignment - // doesn't really count as a const violation since we're just - // updating a cached value, not changing any real data of the - // class. + // We do some messy casting so we can get away with assigning a value to a + // member within a const function. This assignment doesn't really count + // as a const violation since we're just updating a cached value, not + // changing any real data of the class. ((PiecewiseCurve *)this)->_last_ti = 0; } @@ -529,8 +452,8 @@ find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const { } } - // Again, some messy casting so we can get away with updating the - // cached index value for next time. + // Again, some messy casting so we can get away with updating the cached + // index value for next time. ((PiecewiseCurve *)this)->_last_ti = ti; // Now scale t back into the curve's own valid range. @@ -540,20 +463,16 @@ find_curve(const ParametricCurve *&curve, PN_stdfloat &t) const { } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::current_seg_range -// Access: Protected -// Description: Returns a number in the range [0,1], representing the -// conversion of t into the current segment's coordinate -// system (the segment last returned by find_curve). -// This operation is already performed automatically on -// the t passed into find_seg; this function is useful -// only to adjust a different value into the same range. -// -// It is an error to call this function if find_curve() -// has not yet been called, or if find_curve() returned -// false from its previous call. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number in the range [0,1], representing the conversion of t into + * the current segment's coordinate system (the segment last returned by + * find_curve). This operation is already performed automatically on the t + * passed into find_seg; this function is useful only to adjust a different + * value into the same range. + * + * It is an error to call this function if find_curve() has not yet been + * called, or if find_curve() returned false from its previous call. + */ PN_stdfloat PiecewiseCurve:: current_seg_range(PN_stdfloat t) const { int ti = _last_ti; @@ -570,12 +489,10 @@ current_seg_range(PN_stdfloat t) const { return t; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::write_datagram -// Access: Protected, Virtual -// Description: Function to write the important information in -// the particular object to a Datagram -//////////////////////////////////////////////////////////////////// +/** + * Function to write the important information in the particular object to a + * Datagram + */ void PiecewiseCurve:: write_datagram(BamWriter *manager, Datagram &me) { ParametricCurve::write_datagram(manager, me); @@ -591,14 +508,11 @@ write_datagram(BamWriter *manager, Datagram &me) { _last_ti = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::fillin -// Access: Protected -// Description: Function that reads out of the datagram (or asks -// manager to read) all of the data that is needed to -// re-create this object and stores it in the appropiate -// place -//////////////////////////////////////////////////////////////////// +/** + * Function that reads out of the datagram (or asks manager to read) all of + * the data that is needed to re-create this object and stores it in the + * appropiate place + */ void PiecewiseCurve:: fillin(DatagramIterator &scan, BamReader *manager) { ParametricCurve::fillin(scan, manager); @@ -615,13 +529,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: PiecewiseCurve::complete_pointers -// Access: Protected, Virtual -// Description: Takes in a vector of pointes to TypedWritable -// objects that correspond to all the requests for -// pointers that this object made to BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Takes in a vector of pointes to TypedWritable objects that correspond to + * all the requests for pointers that this object made to BamReader. + */ int PiecewiseCurve:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int used = ParametricCurve::complete_pointers(p_list, manager); diff --git a/panda/src/parametrics/piecewiseCurve.h b/panda/src/parametrics/piecewiseCurve.h index 957aed2b88..df979a5031 100644 --- a/panda/src/parametrics/piecewiseCurve.h +++ b/panda/src/parametrics/piecewiseCurve.h @@ -1,16 +1,15 @@ -// Filename: piecewiseCurve.h -// Created by: drose (04Mar01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file piecewiseCurve.h + * @author drose + * @date 2001-03-04 + */ #ifndef PIECEWISECURVE_H #define PIECEWISECURVE_H @@ -20,21 +19,19 @@ #include "parametricCurve.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PiecewiseCurve -// Description : A PiecewiseCurve is a curve made up of several curve -// segments, connected in a head-to-tail fashion. The -// length of each curve segment in parametric space is -// definable. -//////////////////////////////////////////////////////////////////// +/** + * A PiecewiseCurve is a curve made up of several curve segments, connected in + * a head-to-tail fashion. The length of each curve segment in parametric + * space is definable. + */ class EXPCL_PANDA_PARAMETRICS PiecewiseCurve : public ParametricCurve { PUBLISHED: PiecewiseCurve(); ~PiecewiseCurve(); public: - // These functions are all inherited from ParametricCurve, and need - // not be re-published. + // These functions are all inherited from ParametricCurve, and need not be + // re-published. virtual bool is_valid() const; virtual PN_stdfloat get_max_t() const; diff --git a/panda/src/parametrics/ropeNode.I b/panda/src/parametrics/ropeNode.I index 3b0a97b309..56578e365b 100644 --- a/panda/src/parametrics/ropeNode.I +++ b/panda/src/parametrics/ropeNode.I @@ -1,23 +1,19 @@ -// Filename: ropeNode.I -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ropeNode.I + * @author drose + * @date 2002-12-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RopeNode::CData:: CData() { _curve = new NurbsCurveEvaluator; @@ -36,11 +32,9 @@ CData() { _thickness = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RopeNode::CData:: CData(const RopeNode::CData ©) : _curve(copy._curve), @@ -60,239 +54,183 @@ CData(const RopeNode::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: set_curve -// Access: Published -// Description: Sets the particular curve represented by the -// RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the particular curve represented by the RopeNode. + */ INLINE void RopeNode:: set_curve(NurbsCurveEvaluator *curve) { CDWriter cdata(_cycler); cdata->_curve = curve; } -//////////////////////////////////////////////////////////////////// -// Function: get_curve -// Access: Published -// Description: Returns the curve represented by the RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the curve represented by the RopeNode. + */ INLINE NurbsCurveEvaluator *RopeNode:: get_curve() const { CDReader cdata(_cycler); return cdata->_curve; } -//////////////////////////////////////////////////////////////////// -// Function: set_render_mode -// Access: Published -// Description: Specifies the method used to render the rope. The -// simplest is RM_thread, which just draws a one-pixel -// line segment. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the method used to render the rope. The simplest is RM_thread, + * which just draws a one-pixel line segment. + */ INLINE void RopeNode:: set_render_mode(RopeNode::RenderMode render_mode) { CDWriter cdata(_cycler); cdata->_render_mode = render_mode; } -//////////////////////////////////////////////////////////////////// -// Function: get_render_mode -// Access: Published -// Description: Returns the method used to render the rope. See -// set_render_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the method used to render the rope. See set_render_mode(). + */ INLINE RopeNode::RenderMode RopeNode:: get_render_mode() const { CDReader cdata(_cycler); return cdata->_render_mode; } -//////////////////////////////////////////////////////////////////// -// Function: set_uv_mode -// Access: Published -// Description: Specifies the algorithm to use to generate UV's for -// the rope. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the algorithm to use to generate UV's for the rope. + */ INLINE void RopeNode:: set_uv_mode(RopeNode::UVMode uv_mode) { CDWriter cdata(_cycler); cdata->_uv_mode = uv_mode; } -//////////////////////////////////////////////////////////////////// -// Function: get_uv_mode -// Access: Published -// Description: Returns the algorithm to use to generate UV's for the -// rope. -//////////////////////////////////////////////////////////////////// +/** + * Returns the algorithm to use to generate UV's for the rope. + */ INLINE RopeNode::UVMode RopeNode:: get_uv_mode() const { CDReader cdata(_cycler); return cdata->_uv_mode; } -//////////////////////////////////////////////////////////////////// -// Function: set_uv_direction -// Access: Published -// Description: Specify true to vary the U coordinate down the length -// of the rope, or false to vary the V coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Specify true to vary the U coordinate down the length of the rope, or false + * to vary the V coordinate. + */ INLINE void RopeNode:: set_uv_direction(bool u_dominant) { CDWriter cdata(_cycler); cdata->_u_dominant = u_dominant; } -//////////////////////////////////////////////////////////////////// -// Function: get_uv_direction -// Access: Published -// Description: Returns true if the rope runs down the U coordinate -// of the texture, or false if it runs down the V -// coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the rope runs down the U coordinate of the texture, or + * false if it runs down the V coordinate. + */ INLINE bool RopeNode:: get_uv_direction() const { CDReader cdata(_cycler); return cdata->_u_dominant; } -//////////////////////////////////////////////////////////////////// -// Function: set_uv_scale -// Access: Published -// Description: Specifies an additional scaling factor to apply to -// generated UV's along the rope. This scale factor is -// applied in whichever direction is along the rope, as -// specified by set_uv_direction(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies an additional scaling factor to apply to generated UV's along the + * rope. This scale factor is applied in whichever direction is along the + * rope, as specified by set_uv_direction(). + */ INLINE void RopeNode:: set_uv_scale(PN_stdfloat uv_scale) { CDWriter cdata(_cycler); cdata->_uv_scale = uv_scale; } -//////////////////////////////////////////////////////////////////// -// Function: get_uv_scale -// Access: Published -// Description: Returns the scaling factor to apply to generated UV's -// for the rope. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scaling factor to apply to generated UV's for the rope. + */ INLINE PN_stdfloat RopeNode:: get_uv_scale() const { CDReader cdata(_cycler); return cdata->_uv_scale; } -//////////////////////////////////////////////////////////////////// -// Function: set_normal_mode -// Access: Published -// Description: Specifies the kind of normals to generate for the -// rope. This is only applicable when the RenderMode is -// set to RM_tube; in the other render modes, normals -// are never generated. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the kind of normals to generate for the rope. This is only + * applicable when the RenderMode is set to RM_tube; in the other render + * modes, normals are never generated. + */ INLINE void RopeNode:: set_normal_mode(RopeNode::NormalMode normal_mode) { CDWriter cdata(_cycler); cdata->_normal_mode = normal_mode; } -//////////////////////////////////////////////////////////////////// -// Function: get_normal_mode -// Access: Published -// Description: Returns the kind of normals to generate for the rope. -// This is only applicable when the RenderMode is set to -// RM_tube. -//////////////////////////////////////////////////////////////////// +/** + * Returns the kind of normals to generate for the rope. This is only + * applicable when the RenderMode is set to RM_tube. + */ INLINE RopeNode::NormalMode RopeNode:: get_normal_mode() const { CDReader cdata(_cycler); return cdata->_normal_mode; } -//////////////////////////////////////////////////////////////////// -// Function: set_tube_up -// Access: Published -// Description: Specifies a normal vector, generally perpendicular to -// the main axis of the starting point of the curve, -// that controls the "top" of the curve, when RenderMode -// is RM_tube. This is used to orient the vertices that -// make up the tube. If this vector is too nearly -// parallel with the starting direction of the curve, -// there may be a tendency for the whole tube to -// gimble-lock around its primary axis. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a normal vector, generally perpendicular to the main axis of the + * starting point of the curve, that controls the "top" of the curve, when + * RenderMode is RM_tube. This is used to orient the vertices that make up + * the tube. If this vector is too nearly parallel with the starting + * direction of the curve, there may be a tendency for the whole tube to + * gimble-lock around its primary axis. + */ INLINE void RopeNode:: set_tube_up(const LVector3 &tube_up) { CDWriter cdata(_cycler); cdata->_tube_up = tube_up; } -//////////////////////////////////////////////////////////////////// -// Function: get_tube_up -// Access: Published -// Description: Returns the normal vector used to control the "top" -// of the curve, when RenderMode is RM_tube. See -// set_tube_up(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the normal vector used to control the "top" of the curve, when + * RenderMode is RM_tube. See set_tube_up(). + */ INLINE const LVector3 &RopeNode:: get_tube_up() const { CDReader cdata(_cycler); return cdata->_tube_up; } -//////////////////////////////////////////////////////////////////// -// Function: set_use_vertex_color -// Access: Published -// Description: Sets the "use vertex color" flag. When this is true, -// the R, G, B, A vertex color is assumed to be stored -// as the dimensions n + 0, n + 1, n + 2, n + 3, -// respectively, of the extended vertex values, where n -// is the value returned by -// get_vertex_color_dimension(). Use -// NurbsCurveEvaluator::set_extended_vertex() to set -// these values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "use vertex color" flag. When this is true, the R, G, B, A vertex + * color is assumed to be stored as the dimensions n + 0, n + 1, n + 2, n + 3, + * respectively, of the extended vertex values, where n is the value returned + * by get_vertex_color_dimension(). Use + * NurbsCurveEvaluator::set_extended_vertex() to set these values. + */ INLINE void RopeNode:: set_use_vertex_color(bool flag) { CDWriter cdata(_cycler); cdata->_use_vertex_color = flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_use_vertex_color -// Access: Published -// Description: Returns the "use vertex color" flag. See -// set_use_vertex_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "use vertex color" flag. See set_use_vertex_color(). + */ INLINE bool RopeNode:: get_use_vertex_color() const { CDReader cdata(_cycler); return cdata->_use_vertex_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_vertex_color_dimension -// Access: Published, Static -// Description: Returns the numeric extended dimension in which the -// color components should be found. See -// NurbsCurveEvaluator::set_extended_vertex(). -// -// The color components will be expected at (n, n + 1, n -// + 2, n + 3). -//////////////////////////////////////////////////////////////////// +/** + * Returns the numeric extended dimension in which the color components should + * be found. See NurbsCurveEvaluator::set_extended_vertex(). + * + * The color components will be expected at (n, n + 1, n + 2, n + 3). + */ INLINE int RopeNode:: get_vertex_color_dimension() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: set_num_subdiv -// Access: Published -// Description: Specifies the number of subdivisions per cubic -// segment (that is, per unique knot value) to draw in a -// fixed uniform tesselation of the curve. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of subdivisions per cubic segment (that is, per unique + * knot value) to draw in a fixed uniform tesselation of the curve. + */ INLINE void RopeNode:: set_num_subdiv(int num_subdiv) { nassertv(num_subdiv >= 0); @@ -300,31 +238,25 @@ set_num_subdiv(int num_subdiv) { cdata->_num_subdiv = num_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_subdiv -// Access: Published -// Description: Returns the number of subdivisions per cubic segment -// to draw. See set_num_subdiv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subdivisions per cubic segment to draw. See + * set_num_subdiv(). + */ INLINE int RopeNode:: get_num_subdiv() const { CDReader cdata(_cycler); return cdata->_num_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: set_num_slices -// Access: Published -// Description: Specifies the number of radial subdivisions to make -// if RenderMode is RM_tube. It is ignored in the other -// render modes. -// -// Increasing this number increases the roundness of a -// cross-section of the tube. The minimum value for a -// dimensional tube is 3; setting it to 2 will get you a -// thin piece of tape (which is similar to RM_billboard, -// except it won't rotate to face the camera). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of radial subdivisions to make if RenderMode is + * RM_tube. It is ignored in the other render modes. + * + * Increasing this number increases the roundness of a cross-section of the + * tube. The minimum value for a dimensional tube is 3; setting it to 2 will + * get you a thin piece of tape (which is similar to RM_billboard, except it + * won't rotate to face the camera). + */ INLINE void RopeNode:: set_num_slices(int num_slices) { nassertv(num_slices >= 0); @@ -332,73 +264,56 @@ set_num_slices(int num_slices) { cdata->_num_slices = num_slices; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_slices -// Access: Published -// Description: Returns the number of radial subdivisions to make if -// RenderMode is RM_tube. It is ignored in the other -// render modes. See set_num_slices(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of radial subdivisions to make if RenderMode is RM_tube. + * It is ignored in the other render modes. See set_num_slices(). + */ INLINE int RopeNode:: get_num_slices() const { CDReader cdata(_cycler); return cdata->_num_slices; } -//////////////////////////////////////////////////////////////////// -// Function: set_use_vertex_thickness -// Access: Published -// Description: Sets the "use vertex thickness" flag. When this is true, -// the vertex thickness is assumed to be stored as the -// dimension get_vertex_thickness_dimension(), of the -// extended vertex values. Use -// NurbsCurveEvaluator::set_extended_vertex() to set -// these values. -// -// In this mode, the overall thickness is also applied -// as a scale to the vertex thickness. Not all render -// modes support vertex thickness. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "use vertex thickness" flag. When this is true, the vertex + * thickness is assumed to be stored as the dimension + * get_vertex_thickness_dimension(), of the extended vertex values. Use + * NurbsCurveEvaluator::set_extended_vertex() to set these values. + * + * In this mode, the overall thickness is also applied as a scale to the + * vertex thickness. Not all render modes support vertex thickness. + */ INLINE void RopeNode:: set_use_vertex_thickness(bool flag) { CDWriter cdata(_cycler); cdata->_use_vertex_thickness = flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_use_vertex_thickness -// Access: Published -// Description: Returns the "use vertex thickness" flag. See -// set_use_vertex_thickness(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "use vertex thickness" flag. See set_use_vertex_thickness(). + */ INLINE bool RopeNode:: get_use_vertex_thickness() const { CDReader cdata(_cycler); return cdata->_use_vertex_thickness; } -//////////////////////////////////////////////////////////////////// -// Function: get_vertex_thickness_dimension -// Access: Published, Static -// Description: Returns the numeric extended dimension in which the -// thickness component should be found. See -// NurbsCurveEvaluator::set_extended_vertex(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the numeric extended dimension in which the thickness component + * should be found. See NurbsCurveEvaluator::set_extended_vertex(). + */ INLINE int RopeNode:: get_vertex_thickness_dimension() { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: set_thickness -// Access: Published -// Description: Specifies the thickness of the rope, in pixels or in -// spatial units, depending on the render mode. See -// set_render_mode(). -// -// The thickness may also be specified on a per-vertex -// basis. See set_use_vertex_thickness(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the thickness of the rope, in pixels or in spatial units, + * depending on the render mode. See set_render_mode(). + * + * The thickness may also be specified on a per-vertex basis. See + * set_use_vertex_thickness(). + */ INLINE void RopeNode:: set_thickness(PN_stdfloat thickness) { nassertv(thickness >= 0); @@ -406,26 +321,20 @@ set_thickness(PN_stdfloat thickness) { cdata->_thickness = thickness; } -//////////////////////////////////////////////////////////////////// -// Function: get_thickness -// Access: Published -// Description: Returns the thickness of the rope. See -// set_thickness(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the thickness of the rope. See set_thickness(). + */ INLINE PN_stdfloat RopeNode:: get_thickness() const { CDReader cdata(_cycler); return cdata->_thickness; } -//////////////////////////////////////////////////////////////////// -// Function: set_matrix -// Access: Published -// Description: Specifies an optional matrix which is used to -// transform each control vertex after it has been -// transformed into the RopeNode's coordinate space, but -// before the polygon vertices are generated. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an optional matrix which is used to transform each control vertex + * after it has been transformed into the RopeNode's coordinate space, but + * before the polygon vertices are generated. + */ INLINE void RopeNode:: set_matrix(const LMatrix4 &matrix) { CDWriter cdata(_cycler); @@ -433,12 +342,9 @@ set_matrix(const LMatrix4 &matrix) { cdata->_has_matrix = true; } -//////////////////////////////////////////////////////////////////// -// Function: clear_matrix -// Access: Published -// Description: Resets the node's matrix to identity. See -// set_matrix(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the node's matrix to identity. See set_matrix(). + */ INLINE void RopeNode:: clear_matrix() { CDWriter cdata(_cycler); @@ -446,26 +352,21 @@ clear_matrix() { cdata->_has_matrix = false; } -//////////////////////////////////////////////////////////////////// -// Function: has_matrix -// Access: Published -// Description: Returns true if the node has a matrix set, false -// otherwise. See set_matrix(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has a matrix set, false otherwise. See + * set_matrix(). + */ INLINE bool RopeNode:: has_matrix() const { CDReader cdata(_cycler); return cdata->_has_matrix; } -//////////////////////////////////////////////////////////////////// -// Function: get_matrix -// Access: Published -// Description: Returns the optional matrix which is used to -// transform each control vertex after it has been -// transformed into the RopeNode's coordinate space, but -// before the polygon vertices are generated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the optional matrix which is used to transform each control vertex + * after it has been transformed into the RopeNode's coordinate space, but + * before the polygon vertices are generated. + */ INLINE const LMatrix4 &RopeNode:: get_matrix() const { CDReader cdata(_cycler); diff --git a/panda/src/parametrics/ropeNode.cxx b/panda/src/parametrics/ropeNode.cxx index 7f59cf41e2..c799595888 100644 --- a/panda/src/parametrics/ropeNode.cxx +++ b/panda/src/parametrics/ropeNode.cxx @@ -1,16 +1,15 @@ -// Filename: ropeNode.cxx -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ropeNode.cxx + * @author drose + * @date 2002-12-04 + */ #include "ropeNode.h" #include "cullTraverser.h" @@ -35,47 +34,38 @@ TypeHandle RopeNode::_type_handle; PStatCollector RopeNode::_rope_node_pcollector("*:RopeNode"); -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *RopeNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RopeNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { - // For now, we write a NULL pointer. Eventually we will write out - // the NurbsCurveEvaluator pointer. + // For now, we write a NULL pointer. Eventually we will write out the + // NurbsCurveEvaluator pointer. writer->write_pointer(dg, (TypedWritable *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RopeNode. + */ void RopeNode::CData:: fillin(DatagramIterator &scan, BamReader *reader) { // For now, we skip over the NULL pointer that we wrote out. reader->skip_pointer(scan); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RopeNode:: RopeNode(const string &name) : PandaNode(name) @@ -83,11 +73,9 @@ RopeNode(const string &name) : set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RopeNode:: RopeNode(const RopeNode ©) : PandaNode(copy), @@ -95,57 +83,44 @@ RopeNode(const RopeNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *RopeNode:: make_copy() const { return new RopeNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a RopeNode. + */ bool RopeNode:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool RopeNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { // Statistics @@ -187,26 +162,20 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool RopeNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RopeNode:: output(ostream &out) const { PandaNode::output(out); @@ -218,25 +187,20 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RopeNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); indent(out, indent_level) << *get_curve() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::reset_bound -// Access: Published -// Description: Recomputes the bounding volume. This is normally -// called automatically, but it must occasionally be -// called explicitly when the curve has changed -// properties outside of this node's knowledge. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the bounding volume. This is normally called automatically, but + * it must occasionally be called explicitly when the curve has changed + * properties outside of this node's knowledge. + */ void RopeNode:: reset_bound(const NodePath &rel_to) { Thread *current_thread = Thread::get_current_thread(); @@ -245,14 +209,11 @@ reset_bound(const NodePath &rel_to) { mark_internal_bounds_stale(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void RopeNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -266,13 +227,10 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; // TODO--estimate this better. } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::get_format -// Access: Private -// Description: Returns the appropriate GeomVertexFormat for -// rendering, according to the user-specified -// requirements. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate GeomVertexFormat for rendering, according to the + * user-specified requirements. + */ CPT(GeomVertexFormat) RopeNode:: get_format(bool support_normals) const { PT(GeomVertexArrayFormat) array_format = new GeomVertexArrayFormat @@ -298,17 +256,15 @@ get_format(bool support_normals) const { return GeomVertexFormat::register_format(array_format); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::do_recompute_bounds -// Access: Private -// Description: Does the actual internal recompute. -//////////////////////////////////////////////////////////////////// +/** + * Does the actual internal recompute. + */ PT(BoundingVolume) RopeNode:: do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, Thread *current_thread) const { - // TODO: fix the bounds so that it properly reflects the indicated - // pipeline stage. At the moment, we cheat and get some of the - // properties from the current pipeline stage, the lazy way. + // TODO: fix the bounds so that it properly reflects the indicated pipeline + // stage. At the moment, we cheat and get some of the properties from the + // current pipeline stage, the lazy way. // First, get ourselves a fresh, empty bounding volume. PT(BoundingVolume) bound = new BoundingSphere; @@ -334,34 +290,30 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, return bound; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::render_thread -// Access: Private -// Description: Draws the rope in RM_thread mode. This uses a -// GeomLinestrip to draw the rope in the simplest -// possible method, generally resulting in a -// one-pixel-wide curve. -// -// In this mode, the thickness parameter represents a -// thickness in pixels, and is passed to the linestrip. -// However, you should be aware the DirectX does not -// support line thickness. This mode does not support -// per-vertex thickness. -//////////////////////////////////////////////////////////////////// +/** + * Draws the rope in RM_thread mode. This uses a GeomLinestrip to draw the + * rope in the simplest possible method, generally resulting in a one-pixel- + * wide curve. + * + * In this mode, the thickness parameter represents a thickness in pixels, and + * is passed to the linestrip. However, you should be aware the DirectX does + * not support line thickness. This mode does not support per-vertex + * thickness. + */ void RopeNode:: render_thread(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const { CurveSegments curve_segments; int num_curve_verts = get_connected_segments(curve_segments, result); - // Now we have stored one or more sequences of vertices down the - // thread. These map directly to primitive vertices. + // Now we have stored one or more sequences of vertices down the thread. + // These map directly to primitive vertices. PT(GeomVertexData) vdata = new GeomVertexData ("rope", get_format(false), Geom::UH_stream); compute_thread_vertices(vdata, curve_segments, num_curve_verts); - // We use GeomLines instead of GeomLinestrips, since that can more - // easily be rendered directly. + // We use GeomLines instead of GeomLinestrips, since that can more easily be + // rendered directly. PT(GeomLines) lines = new GeomLines(Geom::UH_stream); lines->reserve_num_vertices((num_curve_verts - 1) * 2); @@ -386,33 +338,29 @@ render_thread(CullTraverser *trav, CullTraverserData &data, trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::render_tape -// Access: Private -// Description: Draws the rope in RM_tape mode. This draws a -// series of triangle strips oriented to be -// perpendicular to the tube_up vector. -// -// In this mode, thickness is in spatial units, and -// determines the width of the triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws the rope in RM_tape mode. This draws a series of triangle strips + * oriented to be perpendicular to the tube_up vector. + * + * In this mode, thickness is in spatial units, and determines the width of + * the triangle strips. + */ void RopeNode:: render_tape(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const { CurveSegments curve_segments; int num_curve_verts = get_connected_segments(curve_segments, result); - // Now we have stored one or more sequences of vertices down the - // center strips. Go back through and calculate the vertices on - // either side. + // Now we have stored one or more sequences of vertices down the center + // strips. Go back through and calculate the vertices on either side. PT(GeomVertexData) vdata = new GeomVertexData ("rope", get_format(false), Geom::UH_stream); compute_billboard_vertices(vdata, -get_tube_up(), curve_segments, num_curve_verts, result); - // Since this will be a nonindexed primitive, no need to pre-reserve - // the number of vertices. + // Since this will be a nonindexed primitive, no need to pre-reserve the + // number of vertices. PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_stream); CurveSegments::const_iterator si; for (si = curve_segments.begin(); si != curve_segments.end(); ++si) { @@ -436,16 +384,13 @@ render_tape(CullTraverser *trav, CullTraverserData &data, trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::render_billboard -// Access: Private -// Description: Draws the rope in RM_billboard mode. This draws a -// series of triangle strips oriented to be -// perpendicular to the camera plane. -// -// In this mode, thickness is in spatial units, and -// determines the width of the triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws the rope in RM_billboard mode. This draws a series of triangle + * strips oriented to be perpendicular to the camera plane. + * + * In this mode, thickness is in spatial units, and determines the width of + * the triangle strips. + */ void RopeNode:: render_billboard(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const { @@ -459,17 +404,16 @@ render_billboard(CullTraverser *trav, CullTraverserData &data, CurveSegments curve_segments; int num_curve_verts = get_connected_segments(curve_segments, result); - // Now we have stored one or more sequences of vertices down the - // center strips. Go back through and calculate the vertices on - // either side. + // Now we have stored one or more sequences of vertices down the center + // strips. Go back through and calculate the vertices on either side. PT(GeomVertexData) vdata = new GeomVertexData ("rope", get_format(false), Geom::UH_stream); compute_billboard_vertices(vdata, camera_vec, curve_segments, num_curve_verts, result); - // Since this will be a nonindexed primitive, no need to pre-reserve - // the number of vertices. + // Since this will be a nonindexed primitive, no need to pre-reserve the + // number of vertices. PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_stream); CurveSegments::const_iterator si; for (si = curve_segments.begin(); si != curve_segments.end(); ++si) { @@ -493,23 +437,21 @@ render_billboard(CullTraverser *trav, CullTraverserData &data, trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::render_tube -// Access: Private -// Description: Draws the rope in RM_tube mode. This draws a hollow -// tube centered around the string. -// -// In this mode, thickness is in spatial units, and -// determines the diameter of the tube. -//////////////////////////////////////////////////////////////////// +/** + * Draws the rope in RM_tube mode. This draws a hollow tube centered around + * the string. + * + * In this mode, thickness is in spatial units, and determines the diameter of + * the tube. + */ void RopeNode:: render_tube(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const { CurveSegments curve_segments; int num_curve_verts = get_connected_segments(curve_segments, result); - // Now, we build up a table of vertices, in a series of rings - // around the circumference of the tube. + // Now, we build up a table of vertices, in a series of rings around the + // circumference of the tube. int num_slices = get_num_slices(); int num_verts_per_slice; @@ -520,10 +462,9 @@ render_tube(CullTraverser *trav, CullTraverserData &data, compute_tube_vertices(vdata, num_verts_per_slice, curve_segments, num_curve_verts, result); - // Finally, go through and build up the index array, to tie all the - // triangle strips together. This is difficult to pre-calculate the - // number of vertices we'll use, so we'll just let it dynamically - // allocate. + // Finally, go through and build up the index array, to tie all the triangle + // strips together. This is difficult to pre-calculate the number of + // vertices we'll use, so we'll just let it dynamically allocate. PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_stream); int vi = 0; CurveSegments::const_iterator si; @@ -557,22 +498,17 @@ render_tube(CullTraverser *trav, CullTraverserData &data, trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::get_connected_segments -// Access: Private -// Description: Evaluates the string of vertices along the curve, and -// also breaks them up into connected segments. -// -// Since the NurbsCurveEvaluator describes the curve as -// a sequence of possibly-connected piecewise continuous -// segments, this means joining together some adjacent -// segments from the NurbsCurveEvaluator into a single -// CurveSegment, if they happen to be connected (as most -// will be). -// -// The return value is the total number of points across -// all segments. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the string of vertices along the curve, and also breaks them up + * into connected segments. + * + * Since the NurbsCurveEvaluator describes the curve as a sequence of + * possibly-connected piecewise continuous segments, this means joining + * together some adjacent segments from the NurbsCurveEvaluator into a single + * CurveSegment, if they happen to be connected (as most will be). + * + * The return value is the total number of points across all segments. + */ int RopeNode:: get_connected_segments(RopeNode::CurveSegments &curve_segments, const NurbsCurveResult *result) const { @@ -592,9 +528,9 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, if (curve_segment == (CurveSegment *)NULL || !point.almost_equal(last_point)) { - // If the first point of this segment is different from the last - // point of the previous segment, end the previous segment and - // begin a new one. + // If the first point of this segment is different from the last point + // of the previous segment, end the previous segment and begin a new + // one. curve_segments.push_back(CurveSegment()); curve_segment = &curve_segments.back(); @@ -644,13 +580,10 @@ get_connected_segments(RopeNode::CurveSegments &curve_segments, return num_curve_verts; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_thread_vertices -// Access: Private -// Description: Calculates the vertices for a RM_thread render. This -// just copies the vertices more-or-less directly into -// the array. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the vertices for a RM_thread render. This just copies the + * vertices more-or-less directly into the array. + */ void RopeNode:: compute_thread_vertices(GeomVertexData *vdata, const RopeNode::CurveSegments &curve_segments, @@ -692,13 +625,10 @@ compute_thread_vertices(GeomVertexData *vdata, nassertv(vdata->get_num_rows() == num_curve_verts); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_billboard_vertices -// Access: Private -// Description: Calculates the vertices for a RM_billboard render. This -// puts a pair of vertices on either side of each -// computed point in curve_segments. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the vertices for a RM_billboard render. This puts a pair of + * vertices on either side of each computed point in curve_segments. + */ void RopeNode:: compute_billboard_vertices(GeomVertexData *vdata, const LVector3 &camera_vec, @@ -761,13 +691,10 @@ compute_billboard_vertices(GeomVertexData *vdata, nassertv(vdata->get_num_rows() == expected_num_verts); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_tube_vertices -// Access: Private -// Description: Calculates the vertices for a RM_tube render. This -// puts a ring of vertices around each computed point in -// curve_segments. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the vertices for a RM_tube render. This puts a ring of vertices + * around each computed point in curve_segments. + */ void RopeNode:: compute_tube_vertices(GeomVertexData *vdata, int &num_verts_per_slice, @@ -787,9 +714,9 @@ compute_tube_vertices(GeomVertexData *vdata, bool use_vertex_color = get_use_vertex_color(); bool use_vertex_thickness = get_use_vertex_thickness(); - // If we are generating UV's, we will need to duplicate the vertices - // along the seam so that the UV's go through the whole range of - // 0..1 instead of reflecting in the last polygon before the seam. + // If we are generating UV's, we will need to duplicate the vertices along + // the seam so that the UV's go through the whole range of 0..1 instead of + // reflecting in the last polygon before the seam. if (uv_mode != UV_none) { ++num_verts_per_slice; } @@ -814,8 +741,8 @@ compute_tube_vertices(GeomVertexData *vdata, LVector3 norm = cross(tangent, up); - // In case the tangent is linear dependent on the up vector, we might get invalid - // results, so check that + // In case the tangent is linear dependent on the up vector, we might + // get invalid results, so check that if (IS_NEARLY_ZERO(norm.length_squared())) { if (IS_NEARLY_ZERO(tangent.get_y()) && IS_NEARLY_ZERO(tangent.get_z())) { @@ -866,18 +793,15 @@ compute_tube_vertices(GeomVertexData *vdata, nassertv(vdata->get_num_rows() == expected_num_verts); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_tangent -// Access: Private, Static -// Description: Computes the tangent to the curve at the indicated -// point in the segment. -//////////////////////////////////////////////////////////////////// +/** + * Computes the tangent to the curve at the indicated point in the segment. + */ void RopeNode:: compute_tangent(LVector3 &tangent, const RopeNode::CurveSegment &segment, size_t j, NurbsCurveResult *result) { - // First, try to evaluate the tangent at the curve. This gives - // better results at the ends at the endpoints where the tangent - // does not go to zero. + // First, try to evaluate the tangent at the curve. This gives better + // results at the ends at the endpoints where the tangent does not go to + // zero. /* Actually, on second thought this looks terrible. @@ -889,8 +813,8 @@ compute_tangent(LVector3 &tangent, const RopeNode::CurveSegment &segment, } */ - // If that failed (or produced a zero tangent), then derive the - // tangent from the neighboring points instead. + // If that failed (or produced a zero tangent), then derive the tangent from + // the neighboring points instead. if (j == 0) { tangent = segment[j + 1]._p - segment[j]._p; } else if (j == segment.size() - 1) { @@ -899,7 +823,7 @@ compute_tangent(LVector3 &tangent, const RopeNode::CurveSegment &segment, tangent = segment[j + 1]._p - segment[j - 1]._p; } - // Avoid empty tangents, these lead to crashes. Instead, use an arbitrary + // Avoid empty tangents, these lead to crashes. Instead, use an arbitrary // tangent. if (IS_NEARLY_ZERO(tangent.length_squared())) { tangent.set(0, 0, 1); @@ -907,12 +831,10 @@ compute_tangent(LVector3 &tangent, const RopeNode::CurveSegment &segment, } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::compute_uv_t -// Access: Private, Static -// Description: Computes the texture coordinate along the curve for -// the indicated point in the segment. -//////////////////////////////////////////////////////////////////// +/** + * Computes the texture coordinate along the curve for the indicated point in + * the segment. + */ PN_stdfloat RopeNode:: compute_uv_t(PN_stdfloat &dist, const RopeNode::UVMode &uv_mode, PN_stdfloat uv_scale, const RopeNode::CurveSegment &segment, @@ -942,37 +864,29 @@ compute_uv_t(PN_stdfloat &dist, const RopeNode::UVMode &uv_mode, return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type RopeNode. + */ void RopeNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RopeNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type RopeNode is encountered -// in the Bam file. It should create the RopeNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type RopeNode is encountered in the Bam file. It should create the + * RopeNode and extract its information from the file. + */ TypedWritable *RopeNode:: make_from_bam(const FactoryParams ¶ms) { RopeNode *node = new RopeNode(""); @@ -985,13 +899,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: RopeNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RopeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RopeNode. + */ void RopeNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/parametrics/ropeNode.h b/panda/src/parametrics/ropeNode.h index aadb65b955..1469ec6174 100644 --- a/panda/src/parametrics/ropeNode.h +++ b/panda/src/parametrics/ropeNode.h @@ -1,16 +1,15 @@ -// Filename: ropeNode.h -// Created by: drose (04Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ropeNode.h + * @author drose + * @date 2002-12-04 + */ #ifndef ROPENODE_H #define ROPENODE_H @@ -23,18 +22,15 @@ class GeomVertexData; -//////////////////////////////////////////////////////////////////// -// Class : RopeNode -// Description : This class draws a visible representation of the -// NURBS curve stored in its NurbsCurveEvaluator. It -// automatically recomputes the curve every frame. -// -// This is not related to NurbsCurve, CubicCurveseg or -// any of the ParametricCurve-derived objects in this -// module. It is a completely parallel implementation -// of NURBS curves, and will probably eventually replace -// the whole ParametricCurve class hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This class draws a visible representation of the NURBS curve stored in its + * NurbsCurveEvaluator. It automatically recomputes the curve every frame. + * + * This is not related to NurbsCurve, CubicCurveseg or any of the + * ParametricCurve-derived objects in this module. It is a completely + * parallel implementation of NURBS curves, and will probably eventually + * replace the whole ParametricCurve class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS RopeNode : public PandaNode { PUBLISHED: RopeNode(const string &name); @@ -56,12 +52,12 @@ PUBLISHED: // Render the rope as a one-pixel thread using a linestrip. RM_thread, - // Render the rope as a triangle strip oriented to be - // perpendicular to the tube_up vector. + // Render the rope as a triangle strip oriented to be perpendicular to the + // tube_up vector. RM_tape, - // Render the rope as a triangle strip oriented to be - // perpendicular to the view vector. + // Render the rope as a triangle strip oriented to be perpendicular to the + // view vector. RM_billboard, // Render the rope as a hollow tube extruded along its length. @@ -72,20 +68,18 @@ PUBLISHED: // Don't generate UV's along the curve. UV_none, - // Generate UV's based on the parametric coordinates along the - // curve. + // Generate UV's based on the parametric coordinates along the curve. UV_parametric, - // Generate UV's in proportion to spatial distance along the - // curve, by using the distance function to compute the length of - // each segment. + // Generate UV's in proportion to spatial distance along the curve, by + // using the distance function to compute the length of each segment. UV_distance, - // As above, but don't bother to take the square root of each - // segment. The distance is then in proportion to the - // sum-of-squares of the segments along the rope. If the segments - // are similar in length, this approximates the proportion of - // UV_distance while avoiding hundreds of square root operations. + // As above, but don't bother to take the square root of each segment. + // The distance is then in proportion to the sum-of-squares of the + // segments along the rope. If the segments are similar in length, this + // approximates the proportion of UV_distance while avoiding hundreds of + // square root operations. UV_distance2, }; @@ -152,15 +146,15 @@ private: CPT(GeomVertexFormat) get_format(bool support_normals) const; PT(BoundingVolume) do_recompute_bounds(const NodePath &rel_to, - int pipeline_stage, + int pipeline_stage, Thread *current_thread) const; - void render_thread(CullTraverser *trav, CullTraverserData &data, + void render_thread(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const; - void render_tape(CullTraverser *trav, CullTraverserData &data, + void render_tape(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const; - void render_billboard(CullTraverser *trav, CullTraverserData &data, + void render_billboard(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const; - void render_tube(CullTraverser *trav, CullTraverserData &data, + void render_tube(CullTraverser *trav, CullTraverserData &data, NurbsCurveResult *result) const; class CurveVertex { diff --git a/panda/src/parametrics/sheetNode.I b/panda/src/parametrics/sheetNode.I index 3b10f743d3..b0875a3b11 100644 --- a/panda/src/parametrics/sheetNode.I +++ b/panda/src/parametrics/sheetNode.I @@ -1,23 +1,19 @@ -// Filename: sheetNode.I -// Created by: drose (11Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sheetNode.I + * @author drose + * @date 2003-10-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SheetNode::CData:: CData() { _surface = new NurbsSurfaceEvaluator; @@ -26,11 +22,9 @@ CData() { _num_v_subdiv = 2; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SheetNode::CData:: CData(const SheetNode::CData ©) : _surface(copy._surface), @@ -40,65 +34,50 @@ CData(const SheetNode::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: set_surface -// Access: Public -// Description: Sets the particular surface represented by the -// SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the particular surface represented by the SheetNode. + */ INLINE void SheetNode:: set_surface(NurbsSurfaceEvaluator *surface) { CDWriter cdata(_cycler); cdata->_surface = surface; } -//////////////////////////////////////////////////////////////////// -// Function: get_surface -// Access: Public -// Description: Returns the surface represented by the SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the surface represented by the SheetNode. + */ INLINE NurbsSurfaceEvaluator *SheetNode:: get_surface() const { CDReader cdata(_cycler); return cdata->_surface; } -//////////////////////////////////////////////////////////////////// -// Function: set_use_vertex_color -// Access: Public -// Description: Sets the "use vertex color" flag. When this is true, -// the R, G, B, A vertex color is assumed to be stored -// as the dimensions 0, 1, 2, 3, respectively, of the -// extended vertex values. Use -// NurbsCurveEvaluator::set_extended_vertex() to set -// these values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "use vertex color" flag. When this is true, the R, G, B, A vertex + * color is assumed to be stored as the dimensions 0, 1, 2, 3, respectively, + * of the extended vertex values. Use + * NurbsCurveEvaluator::set_extended_vertex() to set these values. + */ INLINE void SheetNode:: set_use_vertex_color(bool flag) { CDWriter cdata(_cycler); cdata->_use_vertex_color = flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_use_vertex_color -// Access: Public -// Description: Returns the "use vertex color" flag. See -// set_use_vertex_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "use vertex color" flag. See set_use_vertex_color(). + */ INLINE bool SheetNode:: get_use_vertex_color() const { CDReader cdata(_cycler); return cdata->_use_vertex_color; } -//////////////////////////////////////////////////////////////////// -// Function: set_num_u_subdiv -// Access: Public -// Description: Specifies the number of subdivisions per cubic -// segment (that is, per unique knot value) to draw in a -// fixed uniform tesselation of the surface in the U -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of subdivisions per cubic segment (that is, per unique + * knot value) to draw in a fixed uniform tesselation of the surface in the U + * direction. + */ INLINE void SheetNode:: set_num_u_subdiv(int num_u_subdiv) { nassertv(num_u_subdiv >= 0); @@ -106,26 +85,21 @@ set_num_u_subdiv(int num_u_subdiv) { cdata->_num_u_subdiv = num_u_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_u_subdiv -// Access: Public -// Description: Returns the number of subdivisions per cubic segment -// to draw in the U direction. See set_num_u_subdiv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subdivisions per cubic segment to draw in the U + * direction. See set_num_u_subdiv(). + */ INLINE int SheetNode:: get_num_u_subdiv() const { CDReader cdata(_cycler); return cdata->_num_u_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: set_num_v_subdiv -// Access: Public -// Description: Specifies the number of subdivisions per cubic -// segment (that is, per unique knot value) to draw in a -// fixed uniform tesselation of the surface in the V -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of subdivisions per cubic segment (that is, per unique + * knot value) to draw in a fixed uniform tesselation of the surface in the V + * direction. + */ INLINE void SheetNode:: set_num_v_subdiv(int num_v_subdiv) { nassertv(num_v_subdiv >= 0); @@ -133,12 +107,10 @@ set_num_v_subdiv(int num_v_subdiv) { cdata->_num_v_subdiv = num_v_subdiv; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_v_subdiv -// Access: Public -// Description: Returns the number of subdivisions per cubic segment -// to draw in the V direction. See set_num_v_subdiv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subdivisions per cubic segment to draw in the V + * direction. See set_num_v_subdiv(). + */ INLINE int SheetNode:: get_num_v_subdiv() const { CDReader cdata(_cycler); diff --git a/panda/src/parametrics/sheetNode.cxx b/panda/src/parametrics/sheetNode.cxx index dd2fc4199b..34496bca68 100644 --- a/panda/src/parametrics/sheetNode.cxx +++ b/panda/src/parametrics/sheetNode.cxx @@ -1,16 +1,15 @@ -// Filename: sheetNode.cxx -// Created by: drose (11Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sheetNode.cxx + * @author drose + * @date 2003-10-11 + */ #include "sheetNode.h" #include "cullTraverser.h" @@ -33,36 +32,29 @@ TypeHandle SheetNode::_type_handle; PStatCollector SheetNode::_sheet_node_pcollector("*:SheetNode"); -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *SheetNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SheetNode::CData:: write_datagram(BamWriter *writer, Datagram &dg) const { - // For now, we write a NULL pointer. Eventually we will write out - // the NurbsSurfaceEvaluator pointer. + // For now, we write a NULL pointer. Eventually we will write out the + // NurbsSurfaceEvaluator pointer. writer->write_pointer(dg, (TypedWritable *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SheetNode. + */ void SheetNode::CData:: fillin(DatagramIterator &scan, BamReader *reader) { // For now, we skip over the NULL pointer that we wrote out. @@ -70,11 +62,9 @@ fillin(DatagramIterator &scan, BamReader *reader) { _surface.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SheetNode:: SheetNode(const string &name) : PandaNode(name) @@ -82,11 +72,9 @@ SheetNode(const string &name) : set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SheetNode:: SheetNode(const SheetNode ©) : PandaNode(copy), @@ -94,57 +82,44 @@ SheetNode(const SheetNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *SheetNode:: make_copy() const { return new SheetNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a SheetNode. + */ bool SheetNode:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool SheetNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { // Statistics @@ -165,26 +140,20 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool SheetNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SheetNode:: output(ostream &out) const { PandaNode::output(out); @@ -196,11 +165,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SheetNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); @@ -212,14 +179,11 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::reset_bound -// Access: Published -// Description: Recomputes the bounding volume. This is normally -// called automatically, but it must occasionally be -// called explicitly when the surface has changed -// properties outside of this node's knowledge. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the bounding volume. This is normally called automatically, but + * it must occasionally be called explicitly when the surface has changed + * properties outside of this node's knowledge. + */ void SheetNode:: reset_bound(const NodePath &rel_to) { Thread *current_thread = Thread::get_current_thread(); @@ -228,14 +192,11 @@ reset_bound(const NodePath &rel_to) { mark_internal_bounds_stale(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void SheetNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -249,17 +210,15 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; // TODO--estimate this better. } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::do_recompute_bounds -// Access: Private -// Description: Does the actual internal recompute. -//////////////////////////////////////////////////////////////////// +/** + * Does the actual internal recompute. + */ PT(BoundingVolume) SheetNode:: do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, Thread *current_thread) const { - // TODO: fix the bounds so that it properly reflects the indicated - // pipeline stage. At the moment, we cheat and get some of the - // properties from the current pipeline stage, the lazy way. + // TODO: fix the bounds so that it properly reflects the indicated pipeline + // stage. At the moment, we cheat and get some of the properties from the + // current pipeline stage, the lazy way. // First, get ourselves a fresh, empty bounding volume. PT(BoundingVolume) bound = new BoundingSphere; @@ -276,12 +235,9 @@ do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, return bound; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::render_sheet -// Access: Private -// Description: Draws the sheet as a series of tristrips along its -// length. -//////////////////////////////////////////////////////////////////// +/** + * Draws the sheet as a series of tristrips along its length. + */ void SheetNode:: render_sheet(CullTraverser *trav, CullTraverserData &data, NurbsSurfaceResult *result) { @@ -379,37 +335,29 @@ render_sheet(CullTraverser *trav, CullTraverserData &data, trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type SheetNode. + */ void SheetNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SheetNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type SheetNode is encountered -// in the Bam file. It should create the SheetNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type SheetNode is encountered in the Bam file. It should create the + * SheetNode and extract its information from the file. + */ TypedWritable *SheetNode:: make_from_bam(const FactoryParams ¶ms) { SheetNode *node = new SheetNode(""); @@ -422,13 +370,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: SheetNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SheetNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SheetNode. + */ void SheetNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/parametrics/sheetNode.h b/panda/src/parametrics/sheetNode.h index 556d4431a4..fdf8467212 100644 --- a/panda/src/parametrics/sheetNode.h +++ b/panda/src/parametrics/sheetNode.h @@ -1,16 +1,15 @@ -// Filename: sheetNode.h -// Created by: drose (11Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sheetNode.h + * @author drose + * @date 2003-10-11 + */ #ifndef SHEETNODE_H #define SHEETNODE_H @@ -20,19 +19,16 @@ #include "pandaNode.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : SheetNode -// Description : This class draws a visible representation of the -// NURBS surface stored in its NurbsSurfaceEvaluator. It -// automatically recomputes the surface every frame. -// -// This is not related to NurbsSurface, CubicSurfaceseg -// or any of the ParametricSurface-derived objects in -// this module. It is a completely parallel -// implementation of NURBS surfaces, and will probably -// eventually replace the whole ParametricSurface class -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This class draws a visible representation of the NURBS surface stored in + * its NurbsSurfaceEvaluator. It automatically recomputes the surface every + * frame. + * + * This is not related to NurbsSurface, CubicSurfaceseg or any of the + * ParametricSurface-derived objects in this module. It is a completely + * parallel implementation of NURBS surfaces, and will probably eventually + * replace the whole ParametricSurface class hierarchy. + */ class EXPCL_PANDA_PARAMETRICS SheetNode : public PandaNode { PUBLISHED: SheetNode(const string &name); @@ -73,7 +69,7 @@ private: PT(BoundingVolume) do_recompute_bounds(const NodePath &rel_to, int pipeline_stage, Thread *current_thread) const; - void render_sheet(CullTraverser *trav, CullTraverserData &data, + void render_sheet(CullTraverser *trav, CullTraverserData &data, NurbsSurfaceResult *result); private: diff --git a/panda/src/parametrics/test_parametrics.cxx b/panda/src/parametrics/test_parametrics.cxx index 23c896d343..40a46a7a09 100644 --- a/panda/src/parametrics/test_parametrics.cxx +++ b/panda/src/parametrics/test_parametrics.cxx @@ -1,8 +1,4 @@ -/* Filename: test_parametrics.cxx - * Created by: - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,4 +6,5 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file test_parametrics.cxx + */ diff --git a/panda/src/particlesystem/arcEmitter.I b/panda/src/particlesystem/arcEmitter.I index 288fc27aba..972c954aa0 100644 --- a/panda/src/particlesystem/arcEmitter.I +++ b/panda/src/particlesystem/arcEmitter.I @@ -1,44 +1,37 @@ -// Filename: arcEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arcEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_start_angle -// Access: Public -// Description: start angle set -//////////////////////////////////////////////////////////////////// +/** + * start angle set + */ INLINE void ArcEmitter:: set_start_angle(PN_stdfloat angle) { _start_theta = deg_2_rad(angle); } -//////////////////////////////////////////////////////////////////// -// Function: set_end_angle -// Access: Public -// Description: end angle set -//////////////////////////////////////////////////////////////////// +/** + * end angle set + */ INLINE void ArcEmitter:: set_end_angle(PN_stdfloat angle) { _end_theta = deg_2_rad(angle); } -//////////////////////////////////////////////////////////////////// -// Function: set_arc -// Access: Public -// Description: arc sweep set -//////////////////////////////////////////////////////////////////// +/** + * arc sweep set + */ INLINE void ArcEmitter:: set_arc(PN_stdfloat startAngle, PN_stdfloat endAngle) { @@ -46,25 +39,20 @@ set_arc(PN_stdfloat startAngle, PN_stdfloat endAngle) { _end_theta = deg_2_rad(endAngle); } -//////////////////////////////////////////////////////////////////// -// Function: get_start_angle -// Access: Public -// Description: get start angle -//////////////////////////////////////////////////////////////////// +/** + * get start angle + */ INLINE PN_stdfloat ArcEmitter:: get_start_angle() { return rad_2_deg(_start_theta); } -//////////////////////////////////////////////////////////////////// -// Function: get_end_angle -// Access: Public -// Description: get end angle -//////////////////////////////////////////////////////////////////// +/** + * get end angle + */ INLINE PN_stdfloat ArcEmitter:: get_end_angle() { return rad_2_deg(_end_theta); } - diff --git a/panda/src/particlesystem/arcEmitter.cxx b/panda/src/particlesystem/arcEmitter.cxx index 527653e090..cc56b3130e 100644 --- a/panda/src/particlesystem/arcEmitter.cxx +++ b/panda/src/particlesystem/arcEmitter.cxx @@ -1,35 +1,30 @@ -// Filename: arcEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arcEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "arcEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: ArcEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ArcEmitter:: ArcEmitter() : RingEmitter(), _start_theta(0.0f), _end_theta(MathNumbers::pi_f) { } -//////////////////////////////////////////////////////////////////// -// Function: ArcEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ArcEmitter:: ArcEmitter(const ArcEmitter ©) : RingEmitter(copy) { @@ -37,30 +32,24 @@ ArcEmitter(const ArcEmitter ©) : _end_theta = copy._end_theta; } -//////////////////////////////////////////////////////////////////// -// Function: ~ArcEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ArcEmitter:: ~ArcEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *ArcEmitter:: make_copy() { return new ArcEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ArcEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void ArcEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat theta; @@ -81,12 +70,9 @@ assign_initial_position(LPoint3& pos) { pos.set(new_x, new_y, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a starc representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a starc representation of this instance to . + */ void ArcEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -94,12 +80,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a starc representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a starc representation of this instance to . + */ void ArcEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/arcEmitter.h b/panda/src/particlesystem/arcEmitter.h index eae87e1997..1d5a69b644 100644 --- a/panda/src/particlesystem/arcEmitter.h +++ b/panda/src/particlesystem/arcEmitter.h @@ -1,27 +1,24 @@ -// Filename: arcEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arcEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef ARCEMITTER_H #define ARCEMITTER_H #include "ringEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : ArcEmitter -// Description : Describes a planar ring region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar ring region in which particles are generated. + */ class EXPCL_PANDAPHYSICS ArcEmitter : public RingEmitter { PUBLISHED: ArcEmitter(); diff --git a/panda/src/particlesystem/baseParticle.I b/panda/src/particlesystem/baseParticle.I index fdd5060640..f06d40d4b7 100644 --- a/panda/src/particlesystem/baseParticle.I +++ b/panda/src/particlesystem/baseParticle.I @@ -1,16 +1,15 @@ -// Filename: baseParticle.I -// Created by: charles (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticle.I + * @author charles + * @date 2000-06-16 + */ INLINE void BaseParticle::set_age(PN_stdfloat age) { _age = age; diff --git a/panda/src/particlesystem/baseParticle.cxx b/panda/src/particlesystem/baseParticle.cxx index 63b7366dff..13738f9188 100644 --- a/panda/src/particlesystem/baseParticle.cxx +++ b/panda/src/particlesystem/baseParticle.cxx @@ -1,34 +1,29 @@ -// Filename: baseParticle.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticle.cxx + * @author charles + * @date 2000-06-14 + */ #include "baseParticle.h" -//////////////////////////////////////////////////////////////////// -// Function: BaseParticle -// Access: Public -// Description: Default Constructor -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor + */ BaseParticle:: BaseParticle(PN_stdfloat lifespan, bool alive) : _age(0.0f), _lifespan(lifespan), _alive(alive), _index(0){ } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticle -// Access: Public -// Description: Copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor + */ BaseParticle:: BaseParticle(const BaseParticle ©) : _age(copy._age), @@ -37,31 +32,24 @@ BaseParticle(const BaseParticle ©) : _index(copy._index) { } -//////////////////////////////////////////////////////////////////// -// Function: ~BaseParticle -// Access: Public -// Description: Default Destructor -//////////////////////////////////////////////////////////////////// +/** + * Default Destructor + */ BaseParticle:: ~BaseParticle() { } -//////////////////////////////////////////////////////////////////// -// Function: get_theta -// Access: Public -// Description: for spriteParticleRenderer -//////////////////////////////////////////////////////////////////// +/** + * for spriteParticleRenderer + */ PN_stdfloat BaseParticle:: get_theta() const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticle:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -69,12 +57,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticle:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -87,4 +72,3 @@ write(ostream &out, int indent) const { PhysicsObject::write(out, indent+2); #endif //] NDEBUG } - diff --git a/panda/src/particlesystem/baseParticle.h b/panda/src/particlesystem/baseParticle.h index 84fc240959..e152536269 100644 --- a/panda/src/particlesystem/baseParticle.h +++ b/panda/src/particlesystem/baseParticle.h @@ -1,16 +1,15 @@ -// Filename: baseParticle.h -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticle.h + * @author charles + * @date 2000-06-14 + */ #ifndef BASEPARTICLE_H #define BASEPARTICLE_H @@ -18,11 +17,9 @@ #include "pandabase.h" #include "physicsObject.h" -//////////////////////////////////////////////////////////////////// -// Class : BaseParticle -// Description : An individual, physically-modelable particle -// abstract base class. -//////////////////////////////////////////////////////////////////// +/** + * An individual, physically-modelable particle abstract base class. + */ class EXPCL_PANDAPHYSICS BaseParticle : public PhysicsObject { public: // local methods @@ -35,7 +32,7 @@ public: INLINE PN_stdfloat get_age() const; INLINE PN_stdfloat get_lifespan() const; INLINE bool get_alive() const; - INLINE int get_index() const; + INLINE int get_index() const; INLINE PN_stdfloat get_parameterized_age() const; INLINE PN_stdfloat get_parameterized_vel() const; diff --git a/panda/src/particlesystem/baseParticleEmitter.I b/panda/src/particlesystem/baseParticleEmitter.I index df0516d646..687bdb0137 100644 --- a/panda/src/particlesystem/baseParticleEmitter.I +++ b/panda/src/particlesystem/baseParticleEmitter.I @@ -1,132 +1,107 @@ -// Filename: baseParticleEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_emission_type -// Access: Public -// Description: emission type assignment -//////////////////////////////////////////////////////////////////// +/** + * emission type assignment + */ INLINE void BaseParticleEmitter:: set_emission_type(emissionType et) { _emission_type = et; } -//////////////////////////////////////////////////////////////////// -// Function: get_emission_type -// Access: Public -// Description: emission type query -//////////////////////////////////////////////////////////////////// +/** + * emission type query + */ INLINE BaseParticleEmitter::emissionType BaseParticleEmitter:: get_emission_type() const { return _emission_type; } -//////////////////////////////////////////////////////////////////// -// Function: set_explicit_launch_vector -// Access: Public -// Description: assignment of explicit emission launch vector -//////////////////////////////////////////////////////////////////// +/** + * assignment of explicit emission launch vector + */ INLINE void BaseParticleEmitter:: set_explicit_launch_vector(const LVector3& elv) { _explicit_launch_vector = elv; } -//////////////////////////////////////////////////////////////////// -// Function: get_explicit_launch_vector -// Access: Public -// Description: query for explicit emission launch vector -//////////////////////////////////////////////////////////////////// +/** + * query for explicit emission launch vector + */ INLINE LVector3 BaseParticleEmitter:: get_explicit_launch_vector() const { return _explicit_launch_vector; } -//////////////////////////////////////////////////////////////////// -// Function: set_radiate_origin -// Access: Public -// Description: assignment of radiate emission origin point -//////////////////////////////////////////////////////////////////// +/** + * assignment of radiate emission origin point + */ INLINE void BaseParticleEmitter:: set_radiate_origin(const LPoint3& ro) { _radiate_origin = ro; } -//////////////////////////////////////////////////////////////////// -// Function: get_radiate_origin -// Access: Public -// Description: query for explicit emission launch vector -//////////////////////////////////////////////////////////////////// +/** + * query for explicit emission launch vector + */ INLINE LPoint3 BaseParticleEmitter:: get_radiate_origin() const { return _radiate_origin; } -//////////////////////////////////////////////////////////////////// -// Function: set_amplitude -// Access: Public -// Description: amplitude assignment -//////////////////////////////////////////////////////////////////// +/** + * amplitude assignment + */ INLINE void BaseParticleEmitter:: set_amplitude(PN_stdfloat a) { _amplitude = a; } -//////////////////////////////////////////////////////////////////// -// Function: get_amplitude -// Access: Public -// Description: amplitude query -//////////////////////////////////////////////////////////////////// +/** + * amplitude query + */ INLINE PN_stdfloat BaseParticleEmitter:: get_amplitude() const { return _amplitude; } -//////////////////////////////////////////////////////////////////// -// Function: set_amplitude_spread -// Access: Public -// Description: amplitude spread assignment -//////////////////////////////////////////////////////////////////// +/** + * amplitude spread assignment + */ INLINE void BaseParticleEmitter:: set_amplitude_spread(PN_stdfloat as) { _amplitude_spread = as; } -//////////////////////////////////////////////////////////////////// -// Function: get_amplitude_spread -// Access: Public -// Description: amplitude spread query -//////////////////////////////////////////////////////////////////// +/** + * amplitude spread query + */ INLINE PN_stdfloat BaseParticleEmitter:: get_amplitude_spread() const { return _amplitude_spread; } -//////////////////////////////////////////////////////////////////// -// Function: set_offset_force -// Access: Public -// Description: user-defined force -//////////////////////////////////////////////////////////////////// +/** + * user-defined force + */ INLINE void BaseParticleEmitter:: set_offset_force(const LVector3& of) { _offset_force = of; } -//////////////////////////////////////////////////////////////////// -// Function: get_offset_force -// Access: Public -// Description: user-defined force -//////////////////////////////////////////////////////////////////// +/** + * user-defined force + */ INLINE LVector3 BaseParticleEmitter:: get_offset_force() const { return _offset_force; diff --git a/panda/src/particlesystem/baseParticleEmitter.cxx b/panda/src/particlesystem/baseParticleEmitter.cxx index 1787d4f418..20ef762aa9 100644 --- a/panda/src/particlesystem/baseParticleEmitter.cxx +++ b/panda/src/particlesystem/baseParticleEmitter.cxx @@ -1,26 +1,23 @@ -// Filename: baseParticleEmitter.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleEmitter.cxx + * @author charles + * @date 2000-06-14 + */ #include "baseParticleEmitter.h" #include -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleEmitter -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ BaseParticleEmitter:: BaseParticleEmitter() { _emission_type = ET_RADIATE; @@ -31,11 +28,9 @@ BaseParticleEmitter() { _offset_force.set(0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleEmitter -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ BaseParticleEmitter:: BaseParticleEmitter(const BaseParticleEmitter ©) { _emission_type = copy._emission_type; @@ -46,20 +41,16 @@ BaseParticleEmitter(const BaseParticleEmitter ©) { _offset_force = copy._offset_force; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleEmitter -// Access: Protected -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ BaseParticleEmitter:: ~BaseParticleEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: generate -// Access: Public -// Description: parent generation function -//////////////////////////////////////////////////////////////////// +/** + * parent generation function + */ void BaseParticleEmitter:: generate(LPoint3& pos, LVector3& vel) { assign_initial_position(pos); @@ -84,12 +75,9 @@ generate(LPoint3& pos, LVector3& vel) { vel += _offset_force; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -97,12 +85,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -111,6 +96,6 @@ write(ostream &out, int indent) const { out.width(indent+2); out<<""; out<<"_amplitude "<<_amplitude<<"\n"; out.width(indent+2); out<<""; out<<"_amplitude_spread "<<_amplitude_spread<<"\n"; out.width(indent+2); out<<""; out<<"_offset_force "<<_offset_force<<"\n"; - //ReferenceCount::write(out, indent+2); + // ReferenceCount::write(out, indent+2); #endif //] NDEBUG } diff --git a/panda/src/particlesystem/baseParticleEmitter.h b/panda/src/particlesystem/baseParticleEmitter.h index d8e8eac719..af16f43274 100644 --- a/panda/src/particlesystem/baseParticleEmitter.h +++ b/panda/src/particlesystem/baseParticleEmitter.h @@ -1,16 +1,15 @@ -// Filename: baseParticleEmitter.h -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleEmitter.h + * @author charles + * @date 2000-06-14 + */ #ifndef BASEPARTICLEEMITTER_H #define BASEPARTICLEEMITTER_H @@ -23,11 +22,6 @@ #include "mathNumbers.h" -////////////////////////////////////////////////////////////// ////// -// Class : BaseParticleEmitter -// Description : Describes a physical region in space in which -// particles are randomly generated. -//////////////////////////////////////////////////////////////////// class EXPCL_PANDAPHYSICS BaseParticleEmitter : public ReferenceCount { PUBLISHED: enum emissionType { diff --git a/panda/src/particlesystem/baseParticleFactory.I b/panda/src/particlesystem/baseParticleFactory.I index bc8dbbf94d..a5268a531b 100644 --- a/panda/src/particlesystem/baseParticleFactory.I +++ b/panda/src/particlesystem/baseParticleFactory.I @@ -1,124 +1,110 @@ -// Filename: baseParticleFactory.I -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleFactory.I + * @author charles + * @date 2000-07-05 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_lifespan_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_lifespan_base(PN_stdfloat lb) { _lifespan_base = lb; } -//////////////////////////////////////////////////////////////////// -// Function: set_lifespan_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_lifespan_spread(PN_stdfloat ld) { _lifespan_spread = ld; } -//////////////////////////////////////////////////////////////////// -// Function: set_mass_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_mass_base(PN_stdfloat mb) { nassertv(mb >= _mass_spread); _mass_base = mb; } -//////////////////////////////////////////////////////////////////// -// Function: set_mass_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_mass_spread(PN_stdfloat md) { nassertv(md < _mass_base); _mass_spread = md; } -//////////////////////////////////////////////////////////////////// -// Function: set_terminal_velocity_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_terminal_velocity_base(PN_stdfloat tvb) { _terminal_velocity_base = tvb; } -//////////////////////////////////////////////////////////////////// -// Function: set_terminal_velocity_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE void BaseParticleFactory:: set_terminal_velocity_spread(PN_stdfloat tvd) { _terminal_velocity_spread = tvd; } -//////////////////////////////////////////////////////////////////// -// Function: get_lifespan_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_lifespan_base() const { return _lifespan_base; } -//////////////////////////////////////////////////////////////////// -// Function: get_lifespan_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_lifespan_spread() const { return _lifespan_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_mass_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_mass_base() const { return _mass_base; } -//////////////////////////////////////////////////////////////////// -// Function: get_mass_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_mass_spread() const { return _mass_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_terminal_velocity_base -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_terminal_velocity_base() const { return _terminal_velocity_base; } -//////////////////////////////////////////////////////////////////// -// Function: get_terminal_velocity_spread -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ INLINE PN_stdfloat BaseParticleFactory:: get_terminal_velocity_spread() const { return _terminal_velocity_spread; } - diff --git a/panda/src/particlesystem/baseParticleFactory.cxx b/panda/src/particlesystem/baseParticleFactory.cxx index 646c6cdfd3..162b4df88e 100644 --- a/panda/src/particlesystem/baseParticleFactory.cxx +++ b/panda/src/particlesystem/baseParticleFactory.cxx @@ -1,24 +1,21 @@ -// Filename: baseParticleFactory.cxx -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleFactory.cxx + * @author charles + * @date 2000-07-05 + */ #include "baseParticleFactory.h" -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleFactory -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ BaseParticleFactory:: BaseParticleFactory() : _lifespan_base(1.0), @@ -30,11 +27,9 @@ BaseParticleFactory() : { } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleFactory -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ BaseParticleFactory:: BaseParticleFactory(const BaseParticleFactory ©) : _lifespan_base(copy._lifespan_base), @@ -46,19 +41,16 @@ BaseParticleFactory(const BaseParticleFactory ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ~BaseParticleFactory -// Access: Public Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ BaseParticleFactory:: ~BaseParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: make_particle -// Description: public -//////////////////////////////////////////////////////////////////// +/** + * public + */ void BaseParticleFactory:: populate_particle(BaseParticle *bp) { bp->set_lifespan(_lifespan_base + SPREAD(_lifespan_spread)); @@ -73,12 +65,9 @@ populate_particle(BaseParticle *bp) { populate_child_particle(bp); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleFactory:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -86,12 +75,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleFactory:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -102,6 +88,6 @@ write(ostream &out, int indent) const { out.width(indent+2); out<<""; out<<"_mass_spread "<<_mass_spread<<"\n"; out.width(indent+2); out<<""; out<<"_terminal_velocity_base "<<_terminal_velocity_base<<"\n"; out.width(indent+2); out<<""; out<<"_terminal_velocity_spread "<<_terminal_velocity_spread<<"\n"; - //ReferenceCount::write(out, indent+2); + // ReferenceCount::write(out, indent+2); #endif //] NDEBUG } diff --git a/panda/src/particlesystem/baseParticleFactory.h b/panda/src/particlesystem/baseParticleFactory.h index cafad15f6d..bdb7fd6a8c 100644 --- a/panda/src/particlesystem/baseParticleFactory.h +++ b/panda/src/particlesystem/baseParticleFactory.h @@ -1,16 +1,15 @@ -// Filename: baseParticleFactory.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleFactory.h + * @author charles + * @date 2000-07-05 + */ #ifndef BASEPARTICLEFACTORY_H #define BASEPARTICLEFACTORY_H @@ -23,10 +22,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : BaseParticleFactory -// Description : Pure Virtual base class for creating particles -//////////////////////////////////////////////////////////////////// +/** + * Pure Virtual base class for creating particles + */ class EXPCL_PANDAPHYSICS BaseParticleFactory : public ReferenceCount { PUBLISHED: virtual ~BaseParticleFactory(); diff --git a/panda/src/particlesystem/baseParticleRenderer.I b/panda/src/particlesystem/baseParticleRenderer.I index 1e21843f7c..38d8cf8bbb 100644 --- a/panda/src/particlesystem/baseParticleRenderer.I +++ b/panda/src/particlesystem/baseParticleRenderer.I @@ -1,81 +1,68 @@ -// Filename: baseParticleRenderer.I -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleRenderer.I + * @author charles + * @date 2000-06-20 + */ -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_render_node -// Access: Published -// Description: Query the geomnode pointer -//////////////////////////////////////////////////////////////////// +/** + * Query the geomnode pointer + */ INLINE GeomNode *BaseParticleRenderer:: get_render_node() const { return _render_node; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_render_node_path -// Access: Published -// Description: Query the geomnode pointer -//////////////////////////////////////////////////////////////////// +/** + * Query the geomnode pointer + */ INLINE NodePath BaseParticleRenderer:: get_render_node_path() const { return _render_node_path; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::set_alpha_mode -// Access: Published -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void BaseParticleRenderer:: set_alpha_mode(BaseParticleRenderer::ParticleRendererAlphaMode am) { update_alpha_mode(am); init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_alpha_mode -// Access: Published -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleRenderer::ParticleRendererAlphaMode BaseParticleRenderer:: get_alpha_mode() const { return _alpha_mode; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::set_user_alpha -// Access: Published -// Description: sets alpha for "user" alpha mode -//////////////////////////////////////////////////////////////////// +/** + * sets alpha for "user" alpha mode + */ INLINE void BaseParticleRenderer:: set_user_alpha(PN_stdfloat ua) { _user_alpha = ua; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_user_alpha -// Access: Published -// Description: gets alpha for "user" alpha mode -//////////////////////////////////////////////////////////////////// +/** + * gets alpha for "user" alpha mode + */ INLINE PN_stdfloat BaseParticleRenderer:: get_user_alpha() const { return _user_alpha; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::set_color_blend_mode -// Access: Published -// Description: sets the ColorBlendAttrib on the _render_node -//////////////////////////////////////////////////////////////////// +/** + * sets the ColorBlendAttrib on the _render_node + */ INLINE void BaseParticleRenderer:: set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa, ColorBlendAttrib::Operand ob) { CPT(RenderAttrib) ra; @@ -89,22 +76,17 @@ set_color_blend_mode(ColorBlendAttrib::Mode bm, ColorBlendAttrib::Operand oa, Co return; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_ignore_scale -// Access: Published -// Description: Returns the "ignore scale" flag. See -// set_ignore_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "ignore scale" flag. See set_ignore_scale(). + */ INLINE bool BaseParticleRenderer:: get_ignore_scale() const { return _ignore_scale; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::get_cur_alpha -// Access: Published -// Description: gets current alpha for a particle -//////////////////////////////////////////////////////////////////// +/** + * gets current alpha for a particle + */ INLINE PN_stdfloat BaseParticleRenderer:: get_cur_alpha(BaseParticle* bp) { switch(_alpha_mode) { diff --git a/panda/src/particlesystem/baseParticleRenderer.cxx b/panda/src/particlesystem/baseParticleRenderer.cxx index f34b8ab2e3..2a2072c2a1 100644 --- a/panda/src/particlesystem/baseParticleRenderer.cxx +++ b/panda/src/particlesystem/baseParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: baseParticleRenderer.cxx -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleRenderer.cxx + * @author charles + * @date 2000-06-20 + */ #include "pandabase.h" @@ -19,11 +18,9 @@ #include "colorAttrib.h" #include "compassEffect.h" -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::BaseParticleRenderer -// Access: Published -// Description: Default Constructor -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor + */ BaseParticleRenderer:: BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) : _alpha_mode(PR_NOT_INITIALIZED_YET) { @@ -36,11 +33,9 @@ BaseParticleRenderer(ParticleRendererAlphaMode alpha_mode) : update_alpha_mode(alpha_mode); } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::BaseParticleRenderer -// Access: Published -// Description: Copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor + */ BaseParticleRenderer:: BaseParticleRenderer(const BaseParticleRenderer& copy) : _alpha_mode(PR_ALPHA_NONE) { @@ -53,28 +48,22 @@ BaseParticleRenderer(const BaseParticleRenderer& copy) : update_alpha_mode(copy._alpha_mode); } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::~BaseParticleRenderer -// Access: Published -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ BaseParticleRenderer:: ~BaseParticleRenderer() { } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::set_ignore_scale -// Access: Published -// Description: Sets the "ignore scale" flag. When this is true, -// particles will be drawn as if they had no scale, -// regardless of whatever scale might be inherited from -// above the render node in the scene graph. -// -// This flag is mainly useful to support legacy code -// that was written for a very early version of Panda, -// whose sprite particle renderer had a bug that -// incorrectly ignored the inherited scale. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "ignore scale" flag. When this is true, particles will be drawn + * as if they had no scale, regardless of whatever scale might be inherited + * from above the render node in the scene graph. + * + * This flag is mainly useful to support legacy code that was written for a + * very early version of Panda, whose sprite particle renderer had a bug that + * incorrectly ignored the inherited scale. + */ void BaseParticleRenderer:: set_ignore_scale(bool ignore_scale) { _ignore_scale = ignore_scale; @@ -86,12 +75,9 @@ set_ignore_scale(bool ignore_scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::output -// Access: Published -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -99,27 +85,22 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::write -// Access: Published -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseParticleRenderer:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"BaseParticleRenderer:\n"; out.width(indent+2); out<<""; out<<"_render_node "<<_render_node_path<<"\n"; out.width(indent+2); out<<""; out<<"_user_alpha "<<_user_alpha<<"\n"; - //ReferenceCount::write(out, indent+2); + // ReferenceCount::write(out, indent+2); #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::update_alpha_state -// Access: Private -// Description: handles the base class part of alpha updating. -//////////////////////////////////////////////////////////////////// +/** + * handles the base class part of alpha updating. + */ void BaseParticleRenderer:: update_alpha_mode(ParticleRendererAlphaMode am) { if (_alpha_mode == am) @@ -133,23 +114,18 @@ update_alpha_mode(ParticleRendererAlphaMode am) { _alpha_mode = am; } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::enable_alpha -// Access: Private -// Description: Builds an intermediate node and transition that -// enables alpha channeling. -//////////////////////////////////////////////////////////////////// +/** + * Builds an intermediate node and transition that enables alpha channeling. + */ void BaseParticleRenderer:: enable_alpha() { _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha), ColorAttrib::make_vertex()); } -//////////////////////////////////////////////////////////////////// -// Function: BaseParticleRender::disable_alpha -// Access: Private -// Description: kills the intermediate alpha node/arc -//////////////////////////////////////////////////////////////////// +/** + * kills the intermediate alpha node/arc + */ void BaseParticleRenderer:: disable_alpha() { _render_state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_none), diff --git a/panda/src/particlesystem/baseParticleRenderer.h b/panda/src/particlesystem/baseParticleRenderer.h index 1bab12dc27..81926f3a74 100644 --- a/panda/src/particlesystem/baseParticleRenderer.h +++ b/panda/src/particlesystem/baseParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: baseParticleRenderer.h -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseParticleRenderer.h + * @author charles + * @date 2000-06-20 + */ #ifndef BASEPARTICLERENDERER_H #define BASEPARTICLERENDERER_H @@ -27,10 +26,9 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : BaseParticleRenderer -// Description : Pure virtual particle renderer base class -//////////////////////////////////////////////////////////////////// +/** + * Pure virtual particle renderer base class + */ class EXPCL_PANDAPHYSICS BaseParticleRenderer : public ReferenceCount { PUBLISHED: enum ParticleRendererAlphaMode { @@ -96,10 +94,9 @@ private: // birth and kill particle are for renderers that might do maintenance // faster if it was notified on a per-event basis. An example: - // geomParticleRenderer maintains an arc for every particle. Instead - // of visiting EVERY entry in the arc array, individual arcs are - // changed on birth and death. Brings it down a little from O(N) every - // update. + // geomParticleRenderer maintains an arc for every particle. Instead of + // visiting EVERY entry in the arc array, individual arcs are changed on + // birth and death. Brings it down a little from O(N) every update. virtual void birth_particle(int index) = 0; virtual void kill_particle(int index) = 0; @@ -115,4 +112,3 @@ private: #include "baseParticleRenderer.I" #endif // BASEPARTICLERENDERER_H - diff --git a/panda/src/particlesystem/boxEmitter.I b/panda/src/particlesystem/boxEmitter.I index d61f1f3bbf..20806672e5 100644 --- a/panda/src/particlesystem/boxEmitter.I +++ b/panda/src/particlesystem/boxEmitter.I @@ -1,52 +1,43 @@ -// Filename: boxEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boxEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_min_bound -// Access: Public -// Description: boundary assignment -//////////////////////////////////////////////////////////////////// +/** + * boundary assignment + */ INLINE void BoxEmitter:: set_min_bound(const LPoint3& vmin) { _vmin = vmin; } -//////////////////////////////////////////////////////////////////// -// Function: set_max_bound -// Access: Public -// Description: boundary assignment -//////////////////////////////////////////////////////////////////// +/** + * boundary assignment + */ INLINE void BoxEmitter:: set_max_bound(const LPoint3& vmax) { _vmax = vmax; } -//////////////////////////////////////////////////////////////////// -// Function: get_min_bound -// Access: Public -// Description: boundary accessor -//////////////////////////////////////////////////////////////////// +/** + * boundary accessor + */ INLINE LPoint3 BoxEmitter:: get_min_bound() const { return _vmin; } -//////////////////////////////////////////////////////////////////// -// Function: get_max_bound -// Access: Public -// Description: boundary accessor -//////////////////////////////////////////////////////////////////// +/** + * boundary accessor + */ INLINE LPoint3 BoxEmitter:: get_max_bound() const { return _vmax; diff --git a/panda/src/particlesystem/boxEmitter.cxx b/panda/src/particlesystem/boxEmitter.cxx index 5c67123af6..52035e62c7 100644 --- a/panda/src/particlesystem/boxEmitter.cxx +++ b/panda/src/particlesystem/boxEmitter.cxx @@ -1,24 +1,21 @@ -// Filename: boxEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boxEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "boxEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: BoxEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ BoxEmitter:: BoxEmitter() : BaseParticleEmitter() { @@ -26,11 +23,9 @@ BoxEmitter() : _vmax.set( 0.5f, 0.5f, 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: BoxEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ BoxEmitter:: BoxEmitter(const BoxEmitter ©) : BaseParticleEmitter(copy) { @@ -38,30 +33,24 @@ BoxEmitter(const BoxEmitter ©) : _vmax = copy._vmax; } -//////////////////////////////////////////////////////////////////// -// Function: ~BoxEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ BoxEmitter:: ~BoxEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *BoxEmitter:: make_copy() { return new BoxEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BoxEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void BoxEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat t_x = NORMALIZED_RAND(); @@ -77,22 +66,17 @@ assign_initial_position(LPoint3& pos) { pos.set(lerp_x, lerp_y, lerp_z); } -//////////////////////////////////////////////////////////////////// -// Function: BoxEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void BoxEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BoxEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -100,12 +84,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BoxEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/boxEmitter.h b/panda/src/particlesystem/boxEmitter.h index 7902414b44..e9ffbe070c 100644 --- a/panda/src/particlesystem/boxEmitter.h +++ b/panda/src/particlesystem/boxEmitter.h @@ -1,27 +1,24 @@ -// Filename: boxEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file boxEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef BOXEMITTER_H #define BOXEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : BoxEmitter -// Description : Describes a voluminous box region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a voluminous box region in which particles are generated. + */ class EXPCL_PANDAPHYSICS BoxEmitter : public BaseParticleEmitter { PUBLISHED: BoxEmitter(); @@ -43,8 +40,7 @@ private: LPoint3 _vmin; LPoint3 _vmax; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none virtual void assign_initial_position(LPoint3& pos); virtual void assign_initial_velocity(LVector3& vel); diff --git a/panda/src/particlesystem/colorInterpolationManager.I b/panda/src/particlesystem/colorInterpolationManager.I index bf18afa8f9..4a76521cea 100644 --- a/panda/src/particlesystem/colorInterpolationManager.I +++ b/panda/src/particlesystem/colorInterpolationManager.I @@ -1,101 +1,83 @@ -// Filename: colorInterpolationManager.I -// Created by: joswilso (02Jun05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorInterpolationManager.I + * @author joswilso + * @date 2005-06-02 + */ -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionConstant::get_color_a -// Access: Public -// Description: Returns the primary color of the function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primary color of the function. + */ INLINE LColor ColorInterpolationFunctionConstant:: get_color_a() const { return _c_a; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionConstant::set_color_a -// Access: Public -// Description: Sets the primary color of the function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the primary color of the function. + */ INLINE void ColorInterpolationFunctionConstant:: set_color_a(const LColor &c) { _c_a = c; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionLinear::get_color_b -// Access: Public -// Description: Returns the secondary color of the function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the secondary color of the function. + */ INLINE LColor ColorInterpolationFunctionLinear:: get_color_b() const { return _c_b; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionLinear::set_color_b -// Access: Public -// Description: Sets the secondary color of the function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the secondary color of the function. + */ INLINE void ColorInterpolationFunctionLinear:: set_color_b(const LColor &c) { _c_b = c; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::get_width_a -// Access: Public -// Description: Returns the primary width of the function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primary width of the function. + */ INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: get_width_a() const { return _w_a; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::get_width_b -// Access: Public -// Description: Returns the secondary width of the function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the secondary width of the function. + */ INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: get_width_b() const { return _w_b; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::set_width_a -// Access: Public -// Description: Sets the primary width of the function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the primary width of the function. + */ INLINE void ColorInterpolationFunctionStepwave:: set_width_a(const PN_stdfloat w) { _w_a = w; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::set_width_b -// Access: Public -// Description: Sets the secondary width of the function. -//////////////////////////////////////////////////////////////////// +/** + * Sets the secondary width of the function. + */ INLINE void ColorInterpolationFunctionStepwave:: set_width_b(const PN_stdfloat w) { @@ -103,121 +85,94 @@ set_width_b(const PN_stdfloat w) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionSinusoid::get_period -// Access: Public -// Description: Returns the time to transition from A to B then back -// to A again. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time to transition from A to B then back to A again. + */ INLINE PN_stdfloat ColorInterpolationFunctionSinusoid:: get_period() const { return _period; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionSinusoid::set_period -// Access: Public -// Description: Sets the time to transition from A to B then back -// to A again. -//////////////////////////////////////////////////////////////////// +/** + * Sets the time to transition from A to B then back to A again. + */ INLINE void ColorInterpolationFunctionSinusoid:: set_period(const PN_stdfloat p) { _period = p; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::get_function -// Access: Public -// Description: Returns a reference to the function object -// corresponding to this segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the function object corresponding to this segment. + */ INLINE TypedReferenceCount* ColorInterpolationSegment:: get_function() const { return _color_inter_func; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::get_time_begin -// Access: Public -// Description: Returns the point in the particle's lifetime at which -// this segment begins its effect. It is an interpolated -// value in the range [0,1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in the particle's lifetime at which this segment begins + * its effect. It is an interpolated value in the range [0,1]. + */ INLINE PN_stdfloat ColorInterpolationSegment:: get_time_begin() const { return _t_begin; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::get_time_end -// Access: Public -// Description: Returns the point in the particle's lifetime at which -// this segment's effect stops. It is an interpolated -// value in the range [0,1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in the particle's lifetime at which this segment's effect + * stops. It is an interpolated value in the range [0,1]. + */ INLINE PN_stdfloat ColorInterpolationSegment:: get_time_end() const { return _t_end; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::is_modulated -// Access: Public -// Description: Returns whether the function is additive or modulated. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the function is additive or modulated. + */ INLINE bool ColorInterpolationSegment:: is_modulated() const { return _is_modulated; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::is_enabled() -// Access: Public -// Description: Returns whether the segments effects are being applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the segments effects are being applied. + */ INLINE bool ColorInterpolationSegment:: is_enabled() const { return _enabled; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::get_id -// Access: Public -// Description: Returns the id assigned to this segment by the -// manager that created it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the id assigned to this segment by the manager that created it. + */ INLINE int ColorInterpolationSegment:: get_id() const { return _id; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::set_function -// Access: Public -// Description: Sets the function that the segment will use for -// its interpolation calculations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the function that the segment will use for its interpolation + * calculations. + */ INLINE void ColorInterpolationSegment:: set_function(ColorInterpolationFunction* function) { _color_inter_func = function; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::set_time_begin -// Access: Public -// Description: Sets the point in the particle's lifetime at which -// this segment begins its effect. It is an interpolated -// value in the range [0,1]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point in the particle's lifetime at which this segment begins its + * effect. It is an interpolated value in the range [0,1]. + */ INLINE void ColorInterpolationSegment:: set_time_begin(const PN_stdfloat time) { @@ -225,13 +180,10 @@ set_time_begin(const PN_stdfloat time) { _t_total = _t_end-_t_begin; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::set_time_end -// Access: Public -// Description: Sets the point in the particle's lifetime at which -// this segment's effect ends. It is an interpolated -// value in the range [0,1]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point in the particle's lifetime at which this segment's effect + * ends. It is an interpolated value in the range [0,1]. + */ INLINE void ColorInterpolationSegment:: set_time_end(const PN_stdfloat time) { @@ -239,46 +191,37 @@ set_time_end(const PN_stdfloat time) { _t_total = _t_end-_t_begin; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::set_is_modulated -// Access: Public -// Description: Sets how the function is applied to the final color. -// If true, the value is multiplied. If false, the value -// is simply added. Default is true. -//////////////////////////////////////////////////////////////////// +/** + * Sets how the function is applied to the final color. If true, the value is + * multiplied. If false, the value is simply added. Default is true. + */ INLINE void ColorInterpolationSegment:: set_is_modulated(const bool flag) { _is_modulated = flag; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::set_enabled() -// Access: Public -// Description: Sets whether the segments effects should be applied. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the segments effects should be applied. + */ INLINE void ColorInterpolationSegment:: set_enabled(const bool enabled) { _enabled = enabled; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::set_default_color -// Access: Public -// Description: Sets the color to used if no segments are present -//////////////////////////////////////////////////////////////////// +/** + * Sets the color to used if no segments are present + */ INLINE void ColorInterpolationManager:: set_default_color(const LColor &c) { _default_color = c; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::get_segment -// Access: Public -// Description: Returns the segment that corresponds to 'seg_id'. -//////////////////////////////////////////////////////////////////// +/** + * Returns the segment that corresponds to 'seg_id'. + */ INLINE ColorInterpolationSegment* ColorInterpolationManager:: get_segment(const int seg_id) { @@ -291,12 +234,10 @@ get_segment(const int seg_id) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::get_segment_id_list -// Access: Public -// Description: Returns a space delimited list of all of the ids -// in the manager at the time. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space delimited list of all of the ids in the manager at the + * time. + */ INLINE string ColorInterpolationManager:: get_segment_id_list() { diff --git a/panda/src/particlesystem/colorInterpolationManager.cxx b/panda/src/particlesystem/colorInterpolationManager.cxx index 90b49e0b06..90f30de6b2 100644 --- a/panda/src/particlesystem/colorInterpolationManager.cxx +++ b/panda/src/particlesystem/colorInterpolationManager.cxx @@ -1,17 +1,16 @@ -// Filename: colorInterpolationManager.cxx -// Created by: joswilso (02Jun05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -#include "colorInterpolationManager.h" +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorInterpolationManager.cxx + * @author joswilso + * @date 2005-06-02 + */ + #include "mathNumbers.h" TypeHandle ColorInterpolationFunction::_type_handle; @@ -20,75 +19,61 @@ TypeHandle ColorInterpolationFunctionLinear::_type_handle; TypeHandle ColorInterpolationFunctionStepwave::_type_handle; TypeHandle ColorInterpolationFunctionSinusoid::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunction::ColorInterpolationFunction -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationFunction:: ColorInterpolationFunction() { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunction::~ColorInterpolationFunction -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ColorInterpolationFunction:: ~ColorInterpolationFunction() { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionConstant::ColorInterpolationFunctionConstant -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ColorInterpolationFunctionConstant:: ColorInterpolationFunctionConstant() : _c_a(1.0f,1.0f,1.0f,1.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionConstant::ColorInterpolationFunctionConstant -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationFunctionConstant:: ColorInterpolationFunctionConstant(const LColor &color_a) : _c_a(color_a) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionConstant::interpolate -// Access: Protected -// Description: Returns the color associated with this instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color associated with this instance. + */ LColor ColorInterpolationFunctionConstant:: interpolate(const PN_stdfloat t) const { return _c_a; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionLinear::ColorInterpolationFunctionLinear -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ColorInterpolationFunctionLinear:: ColorInterpolationFunctionLinear() : _c_b(1.0f,1.0f,1.0f,1.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionLinear::ColorInterpolationFunctionLinear -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationFunctionLinear:: ColorInterpolationFunctionLinear(const LColor &color_a, @@ -97,22 +82,18 @@ ColorInterpolationFunctionLinear(const LColor &color_a, _c_b(color_b) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionLinear::interpolate -// Access: Protected -// Description: Returns the linear mixture of A and B according to 't'. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear mixture of A and B according to 't'. + */ LColor ColorInterpolationFunctionLinear:: interpolate(const PN_stdfloat t) const { return (1.0f-t)*_c_a + t*_c_b; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::ColorInterpolationFunctionStepwave -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ColorInterpolationFunctionStepwave:: ColorInterpolationFunctionStepwave() : @@ -120,11 +101,9 @@ ColorInterpolationFunctionStepwave() : _w_b(0.5f) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::ColorInterpolationFunctionStepwave -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationFunctionStepwave:: ColorInterpolationFunctionStepwave(const LColor &color_a, @@ -136,11 +115,9 @@ ColorInterpolationFunctionStepwave(const LColor &color_a, _w_b(width_b) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionStepwave::interpolate -// Access: Protected -// Description: Returns either A or B. -//////////////////////////////////////////////////////////////////// +/** + * Returns either A or B. + */ LColor ColorInterpolationFunctionStepwave:: interpolate(const PN_stdfloat t) const { @@ -150,22 +127,18 @@ interpolate(const PN_stdfloat t) const { return _c_b; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionSinusoid::ColorInterpolationFunctionSinusoid -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ColorInterpolationFunctionSinusoid:: ColorInterpolationFunctionSinusoid() : _period(1.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionSinusoid::ColorInterpolationFunctionSinusoid -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationFunctionSinusoid:: ColorInterpolationFunctionSinusoid(const LColor &color_a, @@ -175,13 +148,10 @@ ColorInterpolationFunctionSinusoid(const LColor &color_a, _period(period) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationFunctionSinusoid::interpolate -// Access: Protected -// Description: Returns a sinusoidal blended color between A and B. -// Period defines the time it will take to return to -// A. -//////////////////////////////////////////////////////////////////// +/** + * Returns a sinusoidal blended color between A and B. Period defines the time + * it will take to return to A. + */ LColor ColorInterpolationFunctionSinusoid:: interpolate(const PN_stdfloat t) const { @@ -189,11 +159,9 @@ interpolate(const PN_stdfloat t) const { return (weight_a*_c_a)+((1.0f-weight_a)*_c_b); } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::ColorInterpolationSegment -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationSegment:: ColorInterpolationSegment(ColorInterpolationFunction* function, @@ -210,11 +178,9 @@ ColorInterpolationSegment(ColorInterpolationFunction* function, _id(id) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::ColorInterpolationSegment -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ColorInterpolationSegment:: ColorInterpolationSegment(const ColorInterpolationSegment ©) : @@ -227,35 +193,28 @@ ColorInterpolationSegment(const ColorInterpolationSegment ©) : _id(copy._id) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::~ColorInterpolationSegment -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ColorInterpolationSegment:: ~ColorInterpolationSegment() { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationSegment::interpolateColor -// Access: Public -// Description: Returns the interpolated color according to the -// segment's function and start and end times. 't' is -// a value in [0-1] where corresponds to beginning of -// the segment and 1 corresponds to the end. -//////////////////////////////////////////////////////////////////// +/** + * Returns the interpolated color according to the segment's function and + * start and end times. 't' is a value in [0-1] where corresponds to + * beginning of the segment and 1 corresponds to the end. + */ LColor ColorInterpolationSegment:: interpolateColor(const PN_stdfloat t) const { return _color_inter_func->interpolate((t-_t_begin)/_t_total); } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::ColorInterpolationManager -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ColorInterpolationManager:: ColorInterpolationManager() : @@ -263,11 +222,9 @@ ColorInterpolationManager() : _id_generator(0) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::ColorInterpolationManager -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ColorInterpolationManager:: ColorInterpolationManager(const LColor &c) : @@ -275,11 +232,9 @@ ColorInterpolationManager(const LColor &c) : _id_generator(0) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::ColorInterpolationManager -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ColorInterpolationManager:: ColorInterpolationManager(const ColorInterpolationManager& copy) : @@ -288,23 +243,18 @@ ColorInterpolationManager(const ColorInterpolationManager& copy) : _id_generator(copy._id_generator) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::~ColorInterpolationManager -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ColorInterpolationManager:: ~ColorInterpolationManager() { } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::add_constant -// Access: Public -// Description: Adds a constant segment of the specified color to the -// manager and returns the segment's id as known -// by the manager. -//////////////////////////////////////////////////////////////////// +/** + * Adds a constant segment of the specified color to the manager and returns + * the segment's id as known by the manager. + */ int ColorInterpolationManager:: add_constant(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor &color, const bool is_modulated) { @@ -316,12 +266,10 @@ add_constant(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LCo return _id_generator++; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::add_linear -// Access: Public -// Description: Adds a linear segment between two colors to the manager -// and returns the segment's id as known by the manager. -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear segment between two colors to the manager and returns the + * segment's id as known by the manager. + */ int ColorInterpolationManager:: add_linear(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor &color_a, const LColor &color_b, const bool is_modulated) { @@ -333,12 +281,10 @@ add_linear(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColo return _id_generator++; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::add_stepwave -// Access: Public -// Description: Adds a stepwave segment of two colors to the manager -// and returns the segment's id as known by the manager. -//////////////////////////////////////////////////////////////////// +/** + * Adds a stepwave segment of two colors to the manager and returns the + * segment's id as known by the manager. + */ int ColorInterpolationManager:: add_stepwave(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor &color_a, const LColor &color_b, const PN_stdfloat width_a, const PN_stdfloat width_b,const bool is_modulated) { @@ -350,13 +296,10 @@ add_stepwave(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LCo return _id_generator++; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::add_sinusoid -// Access: Public -// Description: Adds a stepwave segment of two colors and a specified -// period to the manager and returns the segment's -// id as known by the manager. -//////////////////////////////////////////////////////////////////// +/** + * Adds a stepwave segment of two colors and a specified period to the manager + * and returns the segment's id as known by the manager. + */ int ColorInterpolationManager:: add_sinusoid(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LColor &color_a, const LColor &color_b, const PN_stdfloat period,const bool is_modulated) { @@ -368,11 +311,9 @@ add_sinusoid(const PN_stdfloat time_begin, const PN_stdfloat time_end, const LCo return _id_generator++; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::clear_segment -// Access: Public -// Description: Removes the segment of 'id' from the manager. -//////////////////////////////////////////////////////////////////// +/** + * Removes the segment of 'id' from the manager. + */ void ColorInterpolationManager:: clear_segment(const int seg_id) { @@ -386,11 +327,9 @@ clear_segment(const int seg_id) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager::clear_to_initial -// Access: Public -// Description: Removes all segments from the manager. -//////////////////////////////////////////////////////////////////// +/** + * Removes all segments from the manager. + */ void ColorInterpolationManager:: clear_to_initial() { @@ -398,14 +337,11 @@ clear_to_initial() { _id_generator = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ColorInterpolationManager:: -// Access: Public -// Description: For time 'interpolated_time', this returns the -// additive composite color of all segments that influence -// that instant in the particle's lifetime. If no segments -// cover that time, the manager's default color is returned. -//////////////////////////////////////////////////////////////////// +/** + * For time 'interpolated_time', this returns the additive composite color of + * all segments that influence that instant in the particle's lifetime. If no + * segments cover that time, the manager's default color is returned. + */ LColor ColorInterpolationManager:: generateColor(const PN_stdfloat interpolated_time) { diff --git a/panda/src/particlesystem/colorInterpolationManager.h b/panda/src/particlesystem/colorInterpolationManager.h index 41fb390f9a..db954e178d 100644 --- a/panda/src/particlesystem/colorInterpolationManager.h +++ b/panda/src/particlesystem/colorInterpolationManager.h @@ -1,16 +1,15 @@ -// Filename: colorInterpolationManager.h -// Created by: joswilso (02Jun05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorInterpolationManager.h + * @author joswilso + * @date 2005-06-02 + */ #ifndef COLORINTERPOLATIONMANAGER_H #define COLORINTERPOLATIONMANAGER_H @@ -20,17 +19,15 @@ #include "typedObject.h" #include "typedReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationFunction -// Description : Abstract class from which all other functions -// should inherit. Defines the virtual interpolate() -// function. -//////////////////////////////////////////////////////////////////// +/** + * Abstract class from which all other functions should inherit. Defines the + * virtual interpolate() function. + */ class EXPCL_PANDAPHYSICS ColorInterpolationFunction : public TypedReferenceCount { PUBLISHED: -// virtual string get_type(); - +// virtual string get_type(); + public: ColorInterpolationFunction(); virtual ~ColorInterpolationFunction(); @@ -41,13 +38,13 @@ public: static TypeHandle get_class_type() { return _type_handle; } - + static void init_type() { TypedReferenceCount::init_type(); register_type(_type_handle, "ColorInterpolationFunction", TypedReferenceCount::get_class_type()); } - + virtual TypeHandle get_type() const { return get_class_type(); } @@ -56,11 +53,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationFunctionConstant -// Description : Defines a constant color over the lifetime of -// the segment. -//////////////////////////////////////////////////////////////////// +/** + * Defines a constant color over the lifetime of the segment. + */ class EXPCL_PANDAPHYSICS ColorInterpolationFunctionConstant : public ColorInterpolationFunction { PUBLISHED: @@ -74,7 +69,7 @@ public: protected: virtual LColor interpolate(const PN_stdfloat t = 0) const; - // virtual string get_type(); + // virtual string get_type(); LColor _c_a; @@ -82,13 +77,13 @@ public: static TypeHandle get_class_type() { return _type_handle; } - + static void init_type() { ColorInterpolationFunction::init_type(); register_type(_type_handle, "ColorInterpolationFunctionConstant", ColorInterpolationFunction::get_class_type()); } - + virtual TypeHandle get_type() const { return get_class_type(); } @@ -97,11 +92,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationFunctionLinear -// Description : Defines a linear interpolation over the lifetime of -// the segment. -//////////////////////////////////////////////////////////////////// +/** + * Defines a linear interpolation over the lifetime of the segment. + */ class EXPCL_PANDAPHYSICS ColorInterpolationFunctionLinear : public ColorInterpolationFunctionConstant { PUBLISHED: @@ -115,7 +108,7 @@ public: protected: LColor interpolate(const PN_stdfloat t = 0) const; - // virtual string get_type(); + // virtual string get_type(); LColor _c_b; @@ -123,13 +116,13 @@ public: static TypeHandle get_class_type() { return _type_handle; } - + static void init_type() { ColorInterpolationFunctionConstant::init_type(); register_type(_type_handle, "ColorInterpolationFunctionLinear", ColorInterpolationFunctionConstant::get_class_type()); } - + virtual TypeHandle get_type() const { return get_class_type(); } @@ -138,14 +131,12 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationFunctionStepwave -// Description : Defines a discrete cyclical transition between two colors. -// The widths describe a portion of the segment's lifetime -// for which the corresponding color should be selected. If -// their sum is less than 1, the function repeats until -// the end of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Defines a discrete cyclical transition between two colors. The widths + * describe a portion of the segment's lifetime for which the corresponding + * color should be selected. If their sum is less than 1, the function + * repeats until the end of the segment. + */ class EXPCL_PANDAPHYSICS ColorInterpolationFunctionStepwave : public ColorInterpolationFunctionLinear { PUBLISHED: @@ -161,7 +152,7 @@ public: protected: LColor interpolate(const PN_stdfloat t = 0) const; - // virtual string get_type(); + // virtual string get_type(); PN_stdfloat _w_a; PN_stdfloat _w_b; @@ -170,13 +161,13 @@ public: static TypeHandle get_class_type() { return _type_handle; } - + static void init_type() { ColorInterpolationFunctionLinear::init_type(); register_type(_type_handle, "ColorInterpolationFunctionStepwave", ColorInterpolationFunctionLinear::get_class_type()); } - + virtual TypeHandle get_type() const { return get_class_type(); } @@ -185,15 +176,12 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationFunctionSinusoid -// Description : Defines a sinusoidal blending between two colors. -// A period of "1" corresponds to a single transition -// from color_a to color_b and then back to color_a -// over the course of the segment's lifetime. A -// shorter period will result in a higher frequency -// cycle. -//////////////////////////////////////////////////////////////////// +/** + * Defines a sinusoidal blending between two colors. A period of "1" + * corresponds to a single transition from color_a to color_b and then back to + * color_a over the course of the segment's lifetime. A shorter period will + * result in a higher frequency cycle. + */ class EXPCL_PANDAPHYSICS ColorInterpolationFunctionSinusoid : public ColorInterpolationFunctionLinear { PUBLISHED: @@ -207,7 +195,7 @@ public: protected: LColor interpolate(const PN_stdfloat t = 0) const; - // virtual string get_type(); + // virtual string get_type(); PN_stdfloat _period; @@ -215,13 +203,13 @@ public: static TypeHandle get_class_type() { return _type_handle; } - + static void init_type() { ColorInterpolationFunctionLinear::init_type(); register_type(_type_handle, "ColorInterpolationFunctionSinusoid", ColorInterpolationFunctionLinear::get_class_type()); } - + virtual TypeHandle get_type() const { return get_class_type(); } @@ -230,13 +218,11 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationSegment -// Description : A single unit of interpolation. The begin and end -// times are interpolated over the lifetime of the -// particle, thus have the range of [0,1]. Each segment -// also has a function associated with it. -//////////////////////////////////////////////////////////////////// +/** + * A single unit of interpolation. The begin and end times are interpolated + * over the lifetime of the particle, thus have the range of [0,1]. Each + * segment also has a function associated with it. + */ class EXPCL_PANDAPHYSICS ColorInterpolationSegment : public ReferenceCount { PUBLISHED: @@ -244,7 +230,7 @@ PUBLISHED: ColorInterpolationSegment(const ColorInterpolationSegment &s); virtual ~ColorInterpolationSegment(); - // INLINE ColorInterpolationFunction* get_function() const; + // INLINE ColorInterpolationFunction* get_function() const; INLINE TypedReferenceCount* get_function() const; INLINE PN_stdfloat get_time_begin() const; INLINE PN_stdfloat get_time_end() const; @@ -260,7 +246,7 @@ PUBLISHED: public: LColor interpolateColor(const PN_stdfloat t) const; - + protected: PT(ColorInterpolationFunction) _color_inter_func; PN_stdfloat _t_begin; @@ -271,20 +257,17 @@ protected: const int _id; }; -//////////////////////////////////////////////////////////////////// -// Class : ColorInterpolationManager -// Description : High level class for color interpolation. Segments -// must be added to the manager in order to achieve -// results using the "add_*****()" functions. Access -// to these segments is provided but not necessary -// general use. -//////////////////////////////////////////////////////////////////// +/** + * High level class for color interpolation. Segments must be added to the + * manager in order to achieve results using the "add_*****()" functions. + * Access to these segments is provided but not necessary general use. + */ class EXPCL_PANDAPHYSICS ColorInterpolationManager : public ReferenceCount { PUBLISHED: ColorInterpolationManager(); ColorInterpolationManager(const LColor &c); - ColorInterpolationManager(const ColorInterpolationManager& copy); + ColorInterpolationManager(const ColorInterpolationManager& copy); virtual ~ColorInterpolationManager(); int add_constant(const PN_stdfloat time_begin = 0.0f, const PN_stdfloat time_end = 1.0f, const LColor &color = LColor(1.0f,1.0f,1.0f,1.0f), const bool is_modulated = true); diff --git a/panda/src/particlesystem/config_particlesystem.cxx b/panda/src/particlesystem/config_particlesystem.cxx index 16915b5ef9..9c2d9e6a09 100644 --- a/panda/src/particlesystem/config_particlesystem.cxx +++ b/panda/src/particlesystem/config_particlesystem.cxx @@ -1,16 +1,15 @@ -// Filename: config_particlesystem.cxx -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_particlesystem.cxx + * @author charles + * @date 2000-07-05 + */ #include "config_particlesystem.h" #include "particleSystem.h" @@ -31,14 +30,12 @@ ConfigureFn(config_particlesystem) { init_libparticlesystem(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libparticlesystem -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libparticlesystem() { static bool initialized = false; @@ -49,4 +46,3 @@ init_libparticlesystem() { ParticleSystem::init_type(); } - diff --git a/panda/src/particlesystem/config_particlesystem.h b/panda/src/particlesystem/config_particlesystem.h index 5da4b0d8e8..16382b274c 100644 --- a/panda/src/particlesystem/config_particlesystem.h +++ b/panda/src/particlesystem/config_particlesystem.h @@ -1,16 +1,15 @@ -// Filename: config_particlesystem.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_particlesystem.h + * @author charles + * @date 2000-07-05 + */ #ifndef CONFIG_PARTICLESYSTEM_H #define CONFIG_PARTICLESYSTEM_H diff --git a/panda/src/particlesystem/discEmitter.I b/panda/src/particlesystem/discEmitter.I index 29fd59be2a..ed7f107e37 100644 --- a/panda/src/particlesystem/discEmitter.I +++ b/panda/src/particlesystem/discEmitter.I @@ -1,143 +1,118 @@ -// Filename: discEmitter.I -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file discEmitter.I + * @author charles + * @date 2000-06-22 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -// Description: radius assignment -//////////////////////////////////////////////////////////////////// +/** + * radius assignment + */ INLINE void DiscEmitter:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: set_outer_angle -// Access: Public -// Description: aoe assignement -//////////////////////////////////////////////////////////////////// +/** + * aoe assignement + */ INLINE void DiscEmitter:: set_outer_angle(PN_stdfloat o_angle) { _outer_aoe = o_angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_inner_angle -// Access: Public -// Description: aoe assignment -//////////////////////////////////////////////////////////////////// +/** + * aoe assignment + */ INLINE void DiscEmitter:: set_inner_angle(PN_stdfloat i_angle) { _inner_aoe = i_angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_outer_magnitude -// Access: Public -// Description: mag assignment -//////////////////////////////////////////////////////////////////// +/** + * mag assignment + */ INLINE void DiscEmitter:: set_outer_magnitude(PN_stdfloat o_mag) { _outer_magnitude = o_mag; } -//////////////////////////////////////////////////////////////////// -// Function: set_inner_magnitude -// Access: Public -// Description: mag assignment -//////////////////////////////////////////////////////////////////// +/** + * mag assignment + */ INLINE void DiscEmitter:: set_inner_magnitude(PN_stdfloat i_mag) { _inner_magnitude = i_mag; } -//////////////////////////////////////////////////////////////////// -// Function: set_cubic_lerping -// Access: Public -// Description: clerp flag -//////////////////////////////////////////////////////////////////// +/** + * clerp flag + */ INLINE void DiscEmitter:: set_cubic_lerping(bool clerp) { _cubic_lerping = clerp; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -// Description: radius accessor -//////////////////////////////////////////////////////////////////// +/** + * radius accessor + */ INLINE PN_stdfloat DiscEmitter:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_outer_angle -// Access: Public -// Description: aoe accessor -//////////////////////////////////////////////////////////////////// +/** + * aoe accessor + */ INLINE PN_stdfloat DiscEmitter:: get_outer_angle() const { return _outer_aoe; } -//////////////////////////////////////////////////////////////////// -// Function: get_inner_angle -// Access: Public -// Description: aoe accessor -//////////////////////////////////////////////////////////////////// +/** + * aoe accessor + */ INLINE PN_stdfloat DiscEmitter:: get_inner_angle() const { return _inner_aoe; } -//////////////////////////////////////////////////////////////////// -// Function: get_outer_magnitude -// Access: Public -// Description: mag accessor -//////////////////////////////////////////////////////////////////// +/** + * mag accessor + */ INLINE PN_stdfloat DiscEmitter:: get_outer_magnitude() const { return _outer_magnitude; } -//////////////////////////////////////////////////////////////////// -// Function: get_inner_magnitude -// Access: Public -// Description: mag accessor -//////////////////////////////////////////////////////////////////// +/** + * mag accessor + */ INLINE PN_stdfloat DiscEmitter:: get_inner_magnitude() const { return _inner_magnitude; } -//////////////////////////////////////////////////////////////////// -// Function: get_cubic_lerping -// Access: Public -// Description: clerp flag accessor -//////////////////////////////////////////////////////////////////// +/** + * clerp flag accessor + */ INLINE bool DiscEmitter:: get_cubic_lerping() const { diff --git a/panda/src/particlesystem/discEmitter.cxx b/panda/src/particlesystem/discEmitter.cxx index 3cd20a628c..3b018a2dfe 100644 --- a/panda/src/particlesystem/discEmitter.cxx +++ b/panda/src/particlesystem/discEmitter.cxx @@ -1,24 +1,21 @@ -// Filename: discEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file discEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "discEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: DiscEmitter::DiscEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ DiscEmitter:: DiscEmitter() { _radius = 1.0f; @@ -27,11 +24,9 @@ DiscEmitter() { _cubic_lerping = false; } -//////////////////////////////////////////////////////////////////// -// Function: DiscEmitter::DiscEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ DiscEmitter:: DiscEmitter(const DiscEmitter ©) : BaseParticleEmitter(copy) { @@ -47,30 +42,24 @@ DiscEmitter(const DiscEmitter ©) : _cosf_theta = copy._cosf_theta; } -//////////////////////////////////////////////////////////////////// -// Function: DiscEmitter::~DiscEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ DiscEmitter:: ~DiscEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *DiscEmitter:: make_copy() { return new DiscEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DiscEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void DiscEmitter:: assign_initial_position(LPoint3& pos) { // position @@ -88,11 +77,9 @@ assign_initial_position(LPoint3& pos) { pos.set(new_x, new_y, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: DiscEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void DiscEmitter:: assign_initial_velocity(LVector3& vel) { PN_stdfloat aoe, mag; @@ -124,12 +111,9 @@ assign_initial_velocity(LVector3& vel) { vel.set(vel_x, vel_y, vel_z); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DiscEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -137,12 +121,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void DiscEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/discEmitter.h b/panda/src/particlesystem/discEmitter.h index d4327ce049..2d5c8c1367 100644 --- a/panda/src/particlesystem/discEmitter.h +++ b/panda/src/particlesystem/discEmitter.h @@ -1,27 +1,24 @@ -// Filename: discEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file discEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef DISCEMITTER_H #define DISCEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : DiscEmitter -// Description : Describes a planar disc region from which particles -// are generated -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar disc region from which particles are generated + */ class EXPCL_PANDAPHYSICS DiscEmitter : public BaseParticleEmitter { PUBLISHED: DiscEmitter(); diff --git a/panda/src/particlesystem/emitters.h b/panda/src/particlesystem/emitters.h index d3ee1ab520..e363a0742b 100644 --- a/panda/src/particlesystem/emitters.h +++ b/panda/src/particlesystem/emitters.h @@ -1,16 +1,15 @@ -// Filename: emitters.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file emitters.h + * @author charles + * @date 2000-06-22 + */ #ifndef EMITTERS_H #define EMITTERS_H diff --git a/panda/src/particlesystem/geomParticleRenderer.I b/panda/src/particlesystem/geomParticleRenderer.I index fc193c4e17..25ce5035c3 100644 --- a/panda/src/particlesystem/geomParticleRenderer.I +++ b/panda/src/particlesystem/geomParticleRenderer.I @@ -1,26 +1,23 @@ -// Filename: geomParticleRenderer.I -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomParticleRenderer.I + * @author charles + * @date 2000-07-05 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_geom_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** -// we're forcing a pool resize to remove every node in the vector. -// this is because nodes are reference-counted, and we have to -// explicitly remove them from the node they were previously parented -// to. + */ + +// we're forcing a pool resize to remove every node in the vector. this is +// because nodes are reference-counted, and we have to explicitly remove them +// from the node they were previously parented to. INLINE void GeomParticleRenderer:: set_geom_node(PandaNode *node) { @@ -29,190 +26,170 @@ set_geom_node(PandaNode *node) { resize_pool(_pool_size); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_x_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_x_scale_flag(bool animate_x_ratio) { _animate_x_ratio = animate_x_ratio; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_y_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_y_scale_flag(bool animate_y_ratio) { _animate_y_ratio = animate_y_ratio; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_z_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_z_scale_flag(bool animate_z_ratio) { _animate_z_ratio = animate_z_ratio; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_initial_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_initial_x_scale(PN_stdfloat initial_x_scale) { _initial_x_scale = initial_x_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_final_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_final_x_scale(PN_stdfloat final_x_scale) { _final_x_scale = final_x_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_initial_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_initial_y_scale(PN_stdfloat initial_y_scale) { _initial_y_scale = initial_y_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_final_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_final_y_scale(PN_stdfloat final_y_scale) { _final_y_scale = final_y_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_initial_z_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_initial_z_scale(PN_stdfloat initial_z_scale) { _initial_z_scale = initial_z_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::set_final_z_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void GeomParticleRenderer:: set_final_z_scale(PN_stdfloat final_z_scale) { _final_z_scale = final_z_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: get_geom_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PandaNode *GeomParticleRenderer:: get_geom_node() { return _geom_node; } -//////////////////////////////////////////////////////////////////// -// Function: get_color_interpolation_manager -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE ColorInterpolationManager* GeomParticleRenderer:: get_color_interpolation_manager() const { return _color_interpolation_manager; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_x_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool GeomParticleRenderer:: get_x_scale_flag() const { return _animate_x_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_y_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool GeomParticleRenderer:: get_y_scale_flag() const { return _animate_y_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_z_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool GeomParticleRenderer:: get_z_scale_flag() const { return _animate_z_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_initial_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_initial_x_scale() const { return _initial_x_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_final_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_final_x_scale() const { return _final_x_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_initial_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_initial_y_scale() const { return _initial_y_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_final_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_final_y_scale() const { return _final_y_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_initial_z_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_initial_z_scale() const { return _initial_z_scale; } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer::get_final_z_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat GeomParticleRenderer:: get_final_z_scale() const { return _final_z_scale; diff --git a/panda/src/particlesystem/geomParticleRenderer.cxx b/panda/src/particlesystem/geomParticleRenderer.cxx index 3c536d5370..92ebc5a218 100644 --- a/panda/src/particlesystem/geomParticleRenderer.cxx +++ b/panda/src/particlesystem/geomParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: geomParticleRenderer.cxx -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomParticleRenderer.cxx + * @author charles + * @date 2000-07-05 + */ #include "geomParticleRenderer.h" #include "baseParticle.h" @@ -22,11 +21,9 @@ PStatCollector GeomParticleRenderer::_render_collector("App:Particles:Geom:Render"); -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ GeomParticleRenderer:: GeomParticleRenderer(ParticleRendererAlphaMode am, PandaNode *geom_node) : @@ -48,11 +45,9 @@ GeomParticleRenderer(ParticleRendererAlphaMode am, PandaNode *geom_node) : _geom_node = new PandaNode("empty"); } -//////////////////////////////////////////////////////////////////// -// Function: GeomParticleRenderer -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ GeomParticleRenderer:: GeomParticleRenderer(const GeomParticleRenderer& copy) : @@ -71,50 +66,42 @@ GeomParticleRenderer(const GeomParticleRenderer& copy) : _geom_node = copy._geom_node; } -//////////////////////////////////////////////////////////////////// -// Function: ~GeomParticleRenderer -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ GeomParticleRenderer:: ~GeomParticleRenderer() { kill_nodes(); } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: dynamic copying -//////////////////////////////////////////////////////////////////// +/** + * dynamic copying + */ BaseParticleRenderer *GeomParticleRenderer:: make_copy() { return new GeomParticleRenderer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: init_geoms -// Access: Private -// Description: links the child nodes to the parent stuff -//////////////////////////////////////////////////////////////////// +/** + * links the child nodes to the parent stuff + */ void GeomParticleRenderer:: init_geoms() { } -//////////////////////////////////////////////////////////////////// -// Function: resize_pool -// Access: Private -// Description: handles renderer-size resizing. -//////////////////////////////////////////////////////////////////// +/** + * handles renderer-size resizing. + */ void GeomParticleRenderer:: resize_pool(int new_size) { kill_nodes(); - // now repopulate the vector with a bunch of NULLS, representing - // potential instances of the _geom_node. + // now repopulate the vector with a bunch of NULLS, representing potential + // instances of the _geom_node. int i; for (i = 0; i < new_size; i++) { @@ -124,10 +111,9 @@ resize_pool(int new_size) { _pool_size = new_size; } -//////////////////////////////////////////////////////////////////// -// Function: kill_nodes -// Access: Private -//////////////////////////////////////////////////////////////////// +/** + + */ void GeomParticleRenderer:: kill_nodes() { @@ -144,11 +130,9 @@ kill_nodes() { _node_vector.erase(_node_vector.begin(), _node_vector.end()); } -//////////////////////////////////////////////////////////////////// -// Function: birth_particle -// Access: Private, Virtual -// Description: child birth -//////////////////////////////////////////////////////////////////// +/** + * child birth + */ void GeomParticleRenderer:: birth_particle(int index) { @@ -160,11 +144,9 @@ birth_particle(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: kill_particle -// Access: Private, Virtual -// Description: child kill -//////////////////////////////////////////////////////////////////// +/** + * child kill + */ void GeomParticleRenderer:: kill_particle(int index) { @@ -174,11 +156,9 @@ kill_particle(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: render -// Access: Private -// Description: sets the transitions on each arc -//////////////////////////////////////////////////////////////////// +/** + * sets the transitions on each arc + */ void GeomParticleRenderer:: render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { @@ -268,12 +248,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void GeomParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -281,12 +258,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_linear_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void GeomParticleRenderer:: write_linear_forces(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -300,12 +274,9 @@ write_linear_forces(ostream &out, int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void GeomParticleRenderer:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/geomParticleRenderer.h b/panda/src/particlesystem/geomParticleRenderer.h index 97ba7ec22f..4ef60906f0 100644 --- a/panda/src/particlesystem/geomParticleRenderer.h +++ b/panda/src/particlesystem/geomParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: geomParticleRenderer.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomParticleRenderer.h + * @author charles + * @date 2000-07-05 + */ #ifndef GEOMPARTICLERENDERER_H #define GEOMPARTICLERENDERER_H @@ -33,7 +32,7 @@ PUBLISHED: INLINE void set_geom_node(PandaNode *node); INLINE PandaNode *get_geom_node(); - INLINE ColorInterpolationManager* get_color_interpolation_manager() const; + INLINE ColorInterpolationManager* get_color_interpolation_manager() const; INLINE void set_x_scale_flag(bool animate_x_ratio); INLINE void set_y_scale_flag(bool animate_y_ratio); @@ -80,7 +79,7 @@ private: bool _animate_y_ratio; bool _animate_z_ratio; - // geomparticlerenderer takes advantage of the birth/death functions + // geomparticlerenderer takes advantage of the birthdeath functions virtual void birth_particle(int index); virtual void kill_particle(int index); diff --git a/panda/src/particlesystem/lineEmitter.I b/panda/src/particlesystem/lineEmitter.I index 56af4b0a45..4e0b118775 100644 --- a/panda/src/particlesystem/lineEmitter.I +++ b/panda/src/particlesystem/lineEmitter.I @@ -1,52 +1,43 @@ -// Filename: lineEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_endpoint1 -// Access: Public -// Description: endpoint assignment -//////////////////////////////////////////////////////////////////// +/** + * endpoint assignment + */ INLINE void LineEmitter:: set_endpoint1(const LPoint3& point) { _endpoint1 = point; } -//////////////////////////////////////////////////////////////////// -// Function: set_endpoint2 -// Access: Public -// Description: endpoint assignment -//////////////////////////////////////////////////////////////////// +/** + * endpoint assignment + */ INLINE void LineEmitter:: set_endpoint2(const LPoint3& point) { _endpoint2 = point; } -//////////////////////////////////////////////////////////////////// -// Function: get_endpoint1 -// Access: Public -// Description: endpoint accessor -//////////////////////////////////////////////////////////////////// +/** + * endpoint accessor + */ INLINE LPoint3 LineEmitter:: get_endpoint1() const { return _endpoint1; } -//////////////////////////////////////////////////////////////////// -// Function: get_endpoint2 -// Access: Public -// Description: endpoint accessor -//////////////////////////////////////////////////////////////////// +/** + * endpoint accessor + */ INLINE LPoint3 LineEmitter:: get_endpoint2() const { return _endpoint2; diff --git a/panda/src/particlesystem/lineEmitter.cxx b/panda/src/particlesystem/lineEmitter.cxx index 5ade869a34..5a236c03e1 100644 --- a/panda/src/particlesystem/lineEmitter.cxx +++ b/panda/src/particlesystem/lineEmitter.cxx @@ -1,24 +1,21 @@ -// Filename: lineEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "lineEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: LineEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LineEmitter:: LineEmitter() : BaseParticleEmitter() { @@ -26,11 +23,9 @@ LineEmitter() : _endpoint2.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: LineEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LineEmitter:: LineEmitter(const LineEmitter ©) : BaseParticleEmitter(copy) { @@ -38,30 +33,24 @@ LineEmitter(const LineEmitter ©) : _endpoint2 = copy._endpoint2; } -//////////////////////////////////////////////////////////////////// -// Function: ~LineEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LineEmitter:: ~LineEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *LineEmitter:: make_copy() { return new LineEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LineEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void LineEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat t = NORMALIZED_RAND(); @@ -75,22 +64,17 @@ assign_initial_position(LPoint3& pos) { pos.set(lerp_x, lerp_y, lerp_z); } -//////////////////////////////////////////////////////////////////// -// Function: LineEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void LineEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LineEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -98,12 +82,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LineEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/lineEmitter.h b/panda/src/particlesystem/lineEmitter.h index 2d6e70ebd5..8d1d5f9afa 100644 --- a/panda/src/particlesystem/lineEmitter.h +++ b/panda/src/particlesystem/lineEmitter.h @@ -1,27 +1,24 @@ -// Filename: lineEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef LINEEMITTER_H #define LINEEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : LineEmitter -// Description : Describes a linear region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a linear region in which particles are generated. + */ class EXPCL_PANDAPHYSICS LineEmitter : public BaseParticleEmitter { PUBLISHED: LineEmitter(); @@ -43,8 +40,7 @@ private: LPoint3 _endpoint1; LPoint3 _endpoint2; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none virtual void assign_initial_position(LPoint3& pos); virtual void assign_initial_velocity(LVector3& vel); diff --git a/panda/src/particlesystem/lineParticleRenderer.I b/panda/src/particlesystem/lineParticleRenderer.I index 5280a75629..231fc1bb71 100644 --- a/panda/src/particlesystem/lineParticleRenderer.I +++ b/panda/src/particlesystem/lineParticleRenderer.I @@ -1,68 +1,60 @@ -// Filename: lineParticleRenderer.I -// Created by: darren (06Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineParticleRenderer.I + * @author darren + * @date 2000-10-06 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_head_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LineParticleRenderer:: set_head_color(const LColor& c) { _head_color = c; } -//////////////////////////////////////////////////////////////////// -// Function: set_tail_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LineParticleRenderer:: set_tail_color(const LColor& c) { _tail_color = c; } -//////////////////////////////////////////////////////////////////// -// Function: get_head_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& LineParticleRenderer:: get_head_color() const { return _head_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_tail_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& LineParticleRenderer:: get_tail_color() const { return _tail_color; } -//////////////////////////////////////////////////////////////////// -// Function: set_line_scale_factor -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE void LineParticleRenderer:: set_line_scale_factor(PN_stdfloat sf) { _line_scale_factor = sf; } -//////////////////////////////////////////////////////////////////// -// Function: get_line_scale_factor -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE PN_stdfloat LineParticleRenderer:: get_line_scale_factor() const { return _line_scale_factor; } - diff --git a/panda/src/particlesystem/lineParticleRenderer.cxx b/panda/src/particlesystem/lineParticleRenderer.cxx index 615db00233..e139e6f2e8 100644 --- a/panda/src/particlesystem/lineParticleRenderer.cxx +++ b/panda/src/particlesystem/lineParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: lineParticleRenderer.cxx -// Created by: darren (06Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineParticleRenderer.cxx + * @author darren + * @date 2000-10-06 + */ #include "lineParticleRenderer.h" #include "boundingSphere.h" @@ -22,11 +21,9 @@ PStatCollector LineParticleRenderer::_render_collector("App:Particles:Line:Render"); -//////////////////////////////////////////////////////////////////// -// Function: LineParticleRenderer -// Access: Public -// Description: Default Constructor -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor + */ LineParticleRenderer:: LineParticleRenderer() : @@ -38,11 +35,9 @@ LineParticleRenderer() : resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: LineParticleRenderer -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ LineParticleRenderer:: LineParticleRenderer(const LColor& head, @@ -54,11 +49,9 @@ LineParticleRenderer(const LColor& head, resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: LineParticleRenderer -// Access: Public -// Description: Copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor + */ LineParticleRenderer:: LineParticleRenderer(const LineParticleRenderer& copy) : @@ -69,53 +62,42 @@ LineParticleRenderer(const LineParticleRenderer& copy) : resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: ~LineParticleRenderer -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ LineParticleRenderer:: ~LineParticleRenderer() { } -//////////////////////////////////////////////////////////////////// -// Function: make copy -// Access: Public -// Description: child virtual for spawning systems -//////////////////////////////////////////////////////////////////// +/** + * child virtual for spawning systems + */ BaseParticleRenderer *LineParticleRenderer:: make_copy() { return new LineParticleRenderer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: birth_particle -// Access: Private, Virtual -// Description: child birth -//////////////////////////////////////////////////////////////////// +/** + * child birth + */ void LineParticleRenderer:: birth_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: kill_particle -// Access: Private, Virtual -// Description: child kill -//////////////////////////////////////////////////////////////////// +/** + * child kill + */ void LineParticleRenderer:: kill_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: resize_pool -// Access: Private -// Description: resizes the render pool. Reference counting -// makes this easy. -//////////////////////////////////////////////////////////////////// +/** + * resizes the render pool. Reference counting makes this easy. + */ void LineParticleRenderer:: resize_pool(int new_size) { @@ -124,11 +106,9 @@ resize_pool(int new_size) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: init_geoms -// Access: Private -// Description: initializes the geomnodes -//////////////////////////////////////////////////////////////////// +/** + * initializes the geomnodes + */ void LineParticleRenderer:: init_geoms() { @@ -145,11 +125,9 @@ init_geoms() { render_node->add_geom(_line_primitive, _render_state); } -//////////////////////////////////////////////////////////////////// -// Function: render -// Access: Private -// Description: populates the GeomLine -//////////////////////////////////////////////////////////////////// +/** + * populates the GeomLine + */ void LineParticleRenderer:: render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { @@ -250,12 +228,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { get_render_node()->mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LineParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -263,12 +238,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LineParticleRenderer:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "LineParticleRenderer:\n"; diff --git a/panda/src/particlesystem/lineParticleRenderer.h b/panda/src/particlesystem/lineParticleRenderer.h index 77aa28e193..a07e04e9a8 100644 --- a/panda/src/particlesystem/lineParticleRenderer.h +++ b/panda/src/particlesystem/lineParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: lineParticleRenderer.h -// Created by: darren (06Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lineParticleRenderer.h + * @author darren + * @date 2000-10-06 + */ #ifndef LINEPARTICLERENDERER_H #define LINEPARTICLERENDERER_H @@ -24,11 +23,10 @@ #include "geomLines.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : LineParticleRenderer -// Description : renders a line from last position to current -// position -- good for rain, sparks, etc. -//////////////////////////////////////////////////////////////////// +/** + * renders a line from last position to current position -- good for rain, + * sparks, etc. + */ class EXPCL_PANDAPHYSICS LineParticleRenderer : public BaseParticleRenderer { PUBLISHED: @@ -49,7 +47,7 @@ PUBLISHED: INLINE const LColor& get_head_color() const; INLINE const LColor& get_tail_color() const; - + INLINE void set_line_scale_factor(PN_stdfloat sf); INLINE PN_stdfloat get_line_scale_factor() const; diff --git a/panda/src/particlesystem/orientedParticle.I b/panda/src/particlesystem/orientedParticle.I index 5051d95e75..72725cfb79 100644 --- a/panda/src/particlesystem/orientedParticle.I +++ b/panda/src/particlesystem/orientedParticle.I @@ -1,30 +1,27 @@ -// Filename: orientedParticle.I -// Created by: charles (04Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticle.I + * @author charles + * @date 2000-07-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_velocity -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void OrientedParticle:: set_velocity() { } -//////////////////////////////////////////////////////////////////// -// Function: set_orientation -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void OrientedParticle:: set_orientation() { diff --git a/panda/src/particlesystem/orientedParticle.cxx b/panda/src/particlesystem/orientedParticle.cxx index 0e39e2549f..bf828f165c 100644 --- a/panda/src/particlesystem/orientedParticle.cxx +++ b/panda/src/particlesystem/orientedParticle.cxx @@ -1,94 +1,75 @@ -// Filename: orientedParticle.cxx -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticle.cxx + * @author charles + * @date 2000-06-19 + */ #include "orientedParticle.h" -//////////////////////////////////////////////////////////////////// -// Function: OrientedParticle -// Access: Public -// Description: simple constructor -//////////////////////////////////////////////////////////////////// +/** + * simple constructor + */ OrientedParticle:: OrientedParticle(int lifespan, bool alive) : BaseParticle(lifespan, alive) { set_oriented(true); } -//////////////////////////////////////////////////////////////////// -// Function: OrientedParticle -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ OrientedParticle:: OrientedParticle(const OrientedParticle ©) : BaseParticle(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~OrientedParticle -// Access: Public -// Description: simple destructor -//////////////////////////////////////////////////////////////////// +/** + * simple destructor + */ OrientedParticle:: ~OrientedParticle() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: simple destructor -//////////////////////////////////////////////////////////////////// +/** + * simple destructor + */ PhysicsObject *OrientedParticle:: make_copy() const { return new OrientedParticle(*this); } -//////////////////////////////////////////////////////////////////// -// Function: init -// Access: Public -// Description: particle init routine -//////////////////////////////////////////////////////////////////// +/** + * particle init routine + */ void OrientedParticle:: init() { } -//////////////////////////////////////////////////////////////////// -// Function: die -// Access: Public -// Description: particle death routine -//////////////////////////////////////////////////////////////////// +/** + * particle death routine + */ void OrientedParticle:: die() { } -//////////////////////////////////////////////////////////////////// -// Function: update -// Access: Public -// Description: particle update routine. -// This NEEDS to be filled in with quaternion slerp -// stuff, or oriented particles will not rotate. -//////////////////////////////////////////////////////////////////// +/** + * particle update routine. This NEEDS to be filled in with quaternion slerp + * stuff, or oriented particles will not rotate. + */ void OrientedParticle:: update() { } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void OrientedParticle:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -96,12 +77,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void OrientedParticle:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/orientedParticle.h b/panda/src/particlesystem/orientedParticle.h index c5c9836889..5bdfd88351 100644 --- a/panda/src/particlesystem/orientedParticle.h +++ b/panda/src/particlesystem/orientedParticle.h @@ -1,27 +1,25 @@ -// Filename: orientedParticle.h -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticle.h + * @author charles + * @date 2000-06-19 + */ #ifndef ORIENTEDPARTICLE_H #define ORIENTEDPARTICLE_H #include "baseParticle.h" -//////////////////////////////////////////////////////////////////// -// Class : OrientedParticle -// Description : Describes a particle that has angular -// characteristics (velocity, orientation). -//////////////////////////////////////////////////////////////////// +/** + * Describes a particle that has angular characteristics (velocity, + * orientation). + */ class EXPCL_PANDAPHYSICS OrientedParticle : public BaseParticle { public: OrientedParticle(int lifespan = 0, bool alive = false); diff --git a/panda/src/particlesystem/orientedParticleFactory.I b/panda/src/particlesystem/orientedParticleFactory.I index b60193e0ff..c60a416ea4 100644 --- a/panda/src/particlesystem/orientedParticleFactory.I +++ b/panda/src/particlesystem/orientedParticleFactory.I @@ -1,48 +1,43 @@ -// Filename: orientedParticleFactory.I -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticleFactory.I + * @author charles + * @date 2000-08-16 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_initial_orientation -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ void OrientedParticleFactory:: set_initial_orientation(const LOrientation &o) { _initial_orientation = o; } -//////////////////////////////////////////////////////////////////// -// Function: set_final_orientation -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ void OrientedParticleFactory:: set_final_orientation(const LOrientation &o) { _final_orientation = o; } -//////////////////////////////////////////////////////////////////// -// Function: get_initial_orientation -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ LOrientation OrientedParticleFactory:: get_initial_orientation() const { return _initial_orientation; } -//////////////////////////////////////////////////////////////////// -// Function: get_final_orientation -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ LOrientation OrientedParticleFactory:: get_final_orientation() const { return _final_orientation; diff --git a/panda/src/particlesystem/orientedParticleFactory.cxx b/panda/src/particlesystem/orientedParticleFactory.cxx index 71dc3a6f68..2889a16727 100644 --- a/panda/src/particlesystem/orientedParticleFactory.cxx +++ b/panda/src/particlesystem/orientedParticleFactory.cxx @@ -1,35 +1,30 @@ -// Filename: orientedParticleFactory.cxx -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticleFactory.cxx + * @author charles + * @date 2000-07-05 + */ #include "orientedParticleFactory.h" #include "orientedParticle.h" -//////////////////////////////////////////////////////////////////// -// Function: OrientedParticleFactory -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ OrientedParticleFactory:: OrientedParticleFactory() : BaseParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: OrientedParticleFactory -// Access: Public -// Description: copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * copy Constructor + */ OrientedParticleFactory:: OrientedParticleFactory(const OrientedParticleFactory ©) : BaseParticleFactory(copy) { @@ -37,41 +32,32 @@ OrientedParticleFactory(const OrientedParticleFactory ©) : _final_orientation = copy._final_orientation; } -//////////////////////////////////////////////////////////////////// -// Function: ~OrientedParticleFactory -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ OrientedParticleFactory:: ~OrientedParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: populate_child_particle -// Access: Private -// Description: child spawn -//////////////////////////////////////////////////////////////////// +/** + * child spawn + */ void OrientedParticleFactory:: populate_child_particle(BaseParticle *bp) const { bp->set_orientation(_initial_orientation); } -//////////////////////////////////////////////////////////////////// -// Function: alloc_particle -// Access: Public -// Description: child particle generation function -//////////////////////////////////////////////////////////////////// +/** + * child particle generation function + */ BaseParticle *OrientedParticleFactory:: alloc_particle() const { return new OrientedParticle; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void OrientedParticleFactory:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -79,12 +65,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void OrientedParticleFactory:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/orientedParticleFactory.h b/panda/src/particlesystem/orientedParticleFactory.h index 85a8869f65..0df2326ed4 100644 --- a/panda/src/particlesystem/orientedParticleFactory.h +++ b/panda/src/particlesystem/orientedParticleFactory.h @@ -1,16 +1,15 @@ -// Filename: orientedParticleFactory.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file orientedParticleFactory.h + * @author charles + * @date 2000-07-05 + */ #ifndef ORIENTEDPARTICLEFACTORY_H #define ORIENTEDPARTICLEFACTORY_H @@ -19,11 +18,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : OrientedParticleFactory -// Description : Creates particles that are affected by angular -// forces. -//////////////////////////////////////////////////////////////////// +/** + * Creates particles that are affected by angular forces. + */ class EXPCL_PANDAPHYSICS OrientedParticleFactory : public BaseParticleFactory { PUBLISHED: OrientedParticleFactory(); diff --git a/panda/src/particlesystem/particleCommonFuncs.h b/panda/src/particlesystem/particleCommonFuncs.h index 00e12a0566..d3f8c9cff3 100644 --- a/panda/src/particlesystem/particleCommonFuncs.h +++ b/panda/src/particlesystem/particleCommonFuncs.h @@ -1,16 +1,15 @@ -// Filename: particleCommonFuncs.h -// Created by: darren (02Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleCommonFuncs.h + * @author darren + * @date 2000-10-02 + */ #ifndef PARTICLECOMMONFUNCS_H #define PARTICLECOMMONFUNCS_H @@ -18,28 +17,20 @@ // evaluates to a float in the range [0,1] #define NORMALIZED_RAND() ((PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX) -// linear interpolation -// t is in [0,1] -// result is in [X0,X1] +// linear interpolation t is in [0,1] result is in [X0,X1] #define LERP(t,X0,X1) ((X0) + ((t) * ((X1) - (X0)))) -// linear t -> cubic t -// t is in [0,1] -// result is in [0,1] +// linear t -> cubic t t is in [0,1] result is in [0,1] #define CUBIC_T(t) ((t)*(t)*(3-(2*(t)))) -// cubic interpolation -// t is in [0,1] -// result is in [X0,X1] +// cubic interpolation t is in [0,1] result is in [X0,X1] #define CLERP(t,X0,X1) LERP(CUBIC_T(t), (X0), (X1)) -// spread calculator -// spread is non-negative spread magnitude -// result is in [-spread,spread] +// spread calculator spread is non-negative spread magnitude result is in +// [-spread,spread] #define SPREAD(magnitude) ((magnitude) - (NORMALIZED_RAND() * 2.0f * (magnitude))) -// integer spread calculator -// spread is non-negative spread magnitude (integer) +// integer spread calculator spread is non-negative spread magnitude (integer) // result is in [-spread,spread] #define I_SPREAD(magnitude) ((magnitude) - ((int)rand() % ((2*(magnitude))+1))) diff --git a/panda/src/particlesystem/particleSystem.I b/panda/src/particlesystem/particleSystem.I index 689f2bc970..a96083f7e2 100644 --- a/panda/src/particlesystem/particleSystem.I +++ b/panda/src/particlesystem/particleSystem.I @@ -1,47 +1,38 @@ -// Filename: particleSystem.I -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystem.I + * @author charles + * @date 2000-06-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: render -// Access: Public -// Description: Populates an attached GeomNode structure with the -// particle geometry for rendering. This is a -// wrapper for accessability. -//////////////////////////////////////////////////////////////////// +/** + * Populates an attached GeomNode structure with the particle geometry for + * rendering. This is a wrapper for accessability. + */ INLINE void ParticleSystem:: render() { _renderer->render(_physics_objects, _living_particles); } -//////////////////////////////////////////////////////////////////// -// Function: induce_labor -// Access: Public -// Description: Forces the birth of a particle litter this frame -// by resetting _tics_since_birth -//////////////////////////////////////////////////////////////////// +/** + * Forces the birth of a particle litter this frame by resetting + * _tics_since_birth + */ INLINE void ParticleSystem:: induce_labor() { _tics_since_birth = _cur_birth_rate; } -//////////////////////////////////////////////////////////////////// -// Function: clear_to_initial -// Access: Public -// Description: Resets the system to its start state by resizing to 0, -// then resizing back to current size. -//////////////////////////////////////////////////////////////////// +/** + * Resets the system to its start state by resizing to 0, then resizing back + * to current size. + */ INLINE void ParticleSystem:: clear_to_initial() { BaseParticle *bp; @@ -56,11 +47,9 @@ clear_to_initial() { _tics_since_birth = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: soft_start -// Access: Public -// Description: Causes system to use birth rate set by set_birth_rate() -//////////////////////////////////////////////////////////////////// +/** + * Causes system to use birth rate set by set_birth_rate() + */ INLINE void ParticleSystem:: soft_start(PN_stdfloat br) { if (br > 0.0) @@ -69,12 +58,9 @@ soft_start(PN_stdfloat br) { _tics_since_birth = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: soft_stop -// Access: Public -// Description: Causes system to use birth rate set by -// set_soft_birth_rate() -//////////////////////////////////////////////////////////////////// +/** + * Causes system to use birth rate set by set_soft_birth_rate() + */ INLINE void ParticleSystem:: soft_stop(PN_stdfloat br) { if (br > 0.0) @@ -83,19 +69,17 @@ soft_stop(PN_stdfloat br) { _tics_since_birth = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: set_pool_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_pool_size(int size) { resize_pool(size); } -//////////////////////////////////////////////////////////////////// -// Function: set_birth_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_birth_rate(PN_stdfloat new_br) { _birth_rate = new_br; @@ -103,38 +87,34 @@ set_birth_rate(PN_stdfloat new_br) { if(IS_NEARLY_ZERO(_birth_rate)) _birth_rate = NEARLY_ZERO(PN_stdfloat); } -//////////////////////////////////////////////////////////////////// -// Function: set_soft_birth_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_soft_birth_rate(PN_stdfloat new_br) { _soft_birth_rate = new_br; if(IS_NEARLY_ZERO(_soft_birth_rate)) _soft_birth_rate = NEARLY_ZERO(PN_stdfloat); } -//////////////////////////////////////////////////////////////////// -// Function: set_litter_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_litter_size(int new_ls) { _litter_size = new_ls; } -//////////////////////////////////////////////////////////////////// -// Function: set_litter_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_litter_spread(int new_ls) { _litter_spread = new_ls; } -//////////////////////////////////////////////////////////////////// -// Function: set_renderer -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_renderer(BaseParticleRenderer *r) { _renderer = r; @@ -145,19 +125,17 @@ set_renderer(BaseParticleRenderer *r) { _render_node_path.reparent_to(_render_parent); } -//////////////////////////////////////////////////////////////////// -// Function: set_emitter -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_emitter(BaseParticleEmitter *e) { _emitter = e; } -//////////////////////////////////////////////////////////////////// -// Function: set_factory -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_factory(BaseParticleFactory *f) { int pool_size = _particle_pool_size; @@ -167,100 +145,89 @@ set_factory(BaseParticleFactory *f) { set_pool_size(pool_size); } -//////////////////////////////////////////////////////////////////// -// Function: set_floor_z -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_floor_z(PN_stdfloat z) { _floor_z = z; } -//////////////////////////////////////////////////////////////////// -// Function: set_active_state -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_active_system_flag(bool a) { _active_system_flag = a; } -//////////////////////////////////////////////////////////////////// -// Function: set_local_velocity_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_local_velocity_flag(bool lv) { _local_velocity_flag = lv; } -//////////////////////////////////////////////////////////////////// -// Function: set_spawn_on_death_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_spawn_on_death_flag(bool sod) { _spawn_on_death_flag = sod; } -//////////////////////////////////////////////////////////////////// -// Function: set_system_grows_older_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_system_grows_older_flag(bool sgo) { _system_grows_older_flag = sgo; } -//////////////////////////////////////////////////////////////////// -// Function: set_system_lifespan -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_system_lifespan(PN_stdfloat sl) { _system_lifespan = sl; } -//////////////////////////////////////////////////////////////////// -// Function: set_system_age -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_system_age(PN_stdfloat age) { _system_age = age; } -//////////////////////////////////////////////////////////////////// -// Function: set_spawn_render_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_spawn_render_node(PandaNode *node) { set_spawn_render_node_path(NodePath(node)); } -//////////////////////////////////////////////////////////////////// -// Function: set_spawn_render_node_path -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_spawn_render_node_path(const NodePath &node) { _spawn_render_node_path = node; } -//////////////////////////////////////////////////////////////////// -// Function: set_render_parent -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_render_parent(PandaNode *node) { set_render_parent(NodePath(node)); } -//////////////////////////////////////////////////////////////////// -// Function: set_render_parent -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_render_parent(const NodePath &node) { _render_node_path.remove_node(); @@ -270,218 +237,194 @@ set_render_parent(const NodePath &node) { _render_node_path.reparent_to(_render_parent); } -//////////////////////////////////////////////////////////////////// -// Function: set_template_system_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: set_template_system_flag(bool tsf) { _template_system_flag = tsf; } -//////////////////////////////////////////////////////////////////// -// Function: add_spawn_template -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: add_spawn_template(ParticleSystem *ps) { _spawn_templates.push_back(ps); } -//////////////////////////////////////////////////////////////////// -// Function: clear_spawn_templates -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: clear_spawn_templates() { _spawn_templates.erase(_spawn_templates.begin(), _spawn_templates.end()); } -//////////////////////////////////////////////////////////////////// -// Function: clear_floor_z -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystem:: clear_floor_z() { _floor_z = -HUGE_VAL; } -//////////////////////////////////////////////////////////////////// -// Function: get_pool_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ParticleSystem:: get_pool_size() const { return _particle_pool_size; } -//////////////////////////////////////////////////////////////////// -// Function: get_birth_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ParticleSystem:: get_birth_rate() const { return _birth_rate; } -//////////////////////////////////////////////////////////////////// -// Function: get_soft_birth_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ParticleSystem:: get_soft_birth_rate() const { return _soft_birth_rate; } -//////////////////////////////////////////////////////////////////// -// Function: get_litter_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ParticleSystem:: get_litter_size() const { return _litter_size; } -//////////////////////////////////////////////////////////////////// -// Function: get_litter_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ParticleSystem:: get_litter_spread() const { return _litter_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_renderer -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleRenderer *ParticleSystem:: get_renderer() const { return _renderer; } -//////////////////////////////////////////////////////////////////// -// Function: get_emitter -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleEmitter *ParticleSystem:: get_emitter() const { return _emitter; } -//////////////////////////////////////////////////////////////////// -// Function: get_factory -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleFactory *ParticleSystem:: get_factory() const { return _factory; } -//////////////////////////////////////////////////////////////////// -// Function: get_factory -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ParticleSystem:: get_floor_z() const { return _floor_z; } -//////////////////////////////////////////////////////////////////// -// Function: get_living_particles -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ParticleSystem:: get_living_particles() const { return _living_particles; } -//////////////////////////////////////////////////////////////////// -// Function: get_active_state -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool ParticleSystem:: get_active_system_flag() const { return _active_system_flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_local_velocity_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool ParticleSystem:: get_local_velocity_flag() const { return _local_velocity_flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_spawn_on_death_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool ParticleSystem:: get_spawn_on_death_flag() const { return _spawn_on_death_flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_system_grows_older_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool ParticleSystem:: get_system_grows_older_flag() const { return _system_grows_older_flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_system_lifespan -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ParticleSystem:: get_system_lifespan() const { return _system_lifespan; } -//////////////////////////////////////////////////////////////////// -// Function: get_system_age -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ParticleSystem:: get_system_age() const { return _system_age; } -//////////////////////////////////////////////////////////////////// -// Function: get_i_was_spawned_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool ParticleSystem:: get_i_was_spawned_flag() const { return _i_was_spawned_flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_spawn_render_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PandaNode *ParticleSystem:: get_spawn_render_node() const { return _spawn_render_node_path.node(); } -//////////////////////////////////////////////////////////////////// -// Function: get_spawn_render_node_path -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE NodePath ParticleSystem:: get_spawn_render_node_path() const { return _spawn_render_node_path; } -//////////////////////////////////////////////////////////////////// -// Function: get_render_parent -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE NodePath ParticleSystem:: get_render_parent() const { return _render_parent; diff --git a/panda/src/particlesystem/particleSystem.cxx b/panda/src/particlesystem/particleSystem.cxx index 3da5b2b223..7e22ac9180 100644 --- a/panda/src/particlesystem/particleSystem.cxx +++ b/panda/src/particlesystem/particleSystem.cxx @@ -1,16 +1,15 @@ -// Filename: particleSystem.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystem.cxx + * @author charles + * @date 2000-06-14 + */ #include @@ -35,11 +34,9 @@ TypeHandle ParticleSystem::_type_handle; PStatCollector ParticleSystem::_update_collector("App:Particles:Update"); -//////////////////////////////////////////////////////////////////// -// Function: ParticleSystem -// Access: Public -// Description: Default Constructor. -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor. + */ ParticleSystem:: ParticleSystem(int pool_size) : Physical(pool_size, false) @@ -60,11 +57,11 @@ ParticleSystem(int pool_size) : _particle_pool_size = 0; _floor_z = -HUGE_VAL; - // just in case someone tries to do something that requires the - // use of an emitter, renderer, or factory before they've actually - // assigned one. This is ok, because assigning them (set_renderer(), - // set_emitter(), etc...) forces them to set themselves up for the - // system, keeping the pool sizes consistent. + // just in case someone tries to do something that requires the use of an + // emitter, renderer, or factory before they've actually assigned one. This + // is ok, because assigning them (set_renderer(), set_emitter(), etc...) + // forces them to set themselves up for the system, keeping the pool sizes + // consistent. _render_node_path = NodePath(); _render_parent = NodePath("ParticleSystem default render parent"); @@ -73,18 +70,16 @@ ParticleSystem(int pool_size) : set_renderer(new PointParticleRenderer); - //set_factory(new PointParticleFactory); + // set_factory(new PointParticleFactory); _factory = new PointParticleFactory; clear_physics_objects(); set_pool_size(pool_size); } -//////////////////////////////////////////////////////////////////// -// Function: ParticleSystem -// Access: Public -// Description: Copy Constructor. -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor. + */ ParticleSystem:: ParticleSystem(const ParticleSystem& copy) : Physical(copy), @@ -115,11 +110,9 @@ ParticleSystem(const ParticleSystem& copy) : set_pool_size(copy._particle_pool_size); } -//////////////////////////////////////////////////////////////////// -// Function: ~ParticleSystem -// Access: Public -// Description: You get the ankles and I'll get the wrists. -//////////////////////////////////////////////////////////////////// +/** + * You get the ankles and I'll get the wrists. + */ ParticleSystem:: ~ParticleSystem() { set_pool_size(0); @@ -130,12 +123,10 @@ ParticleSystem:: } } -//////////////////////////////////////////////////////////////////// -// Function: birth_particle -// Access: Private -// Description: A new particle is born. This doesn't allocate, -// resets an element from the particle pool. -//////////////////////////////////////////////////////////////////// +/** + * A new particle is born. This doesn't allocate, resets an element from the + * particle pool. + */ bool ParticleSystem:: birth_particle() { int pool_index; @@ -184,7 +175,7 @@ birth_particle() { const LMatrix4 &birth_to_render_xform = transform->get_mat(); world_pos = new_pos * birth_to_render_xform; - // cout << "New particle at " << world_pos << endl; + // cout << "New particle at " << world_pos << endl; // possibly transform the initial velocity as well. if (_local_velocity_flag == false) @@ -201,11 +192,9 @@ birth_particle() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: birth_litter -// Access: Private -// Description: spawns a new batch of particles -//////////////////////////////////////////////////////////////////// +/** + * spawns a new batch of particles + */ void ParticleSystem:: birth_litter() { int litter_size, i; @@ -221,17 +210,14 @@ birth_litter() { } } -//////////////////////////////////////////////////////////////////// -// Function: spawn_child_system -// Access: Private -// Description: Creates a new particle system based on local -// template info and adds it to the ps and physics -// managers -//////////////////////////////////////////////////////////////////// +/** + * Creates a new particle system based on local template info and adds it to + * the ps and physics managers + */ void ParticleSystem:: spawn_child_system(BaseParticle *bp) { - // first, make sure that the system exists in the graph via a - // physicalnode reference. + // first, make sure that the system exists in the graph via a physicalnode + // reference. PhysicalNode *this_pn = get_physical_node(); if (!this_pn) { physics_cat.error() << "ParticleSystem::spawn_child_system: " @@ -275,9 +261,9 @@ spawn_child_system(BaseParticle *bp) { PT(PhysicalNode) new_pn = new PhysicalNode("new_pn"); new_pn->add_physical(new_ps); - // the transform on the new child has to represent the transform - // from the current system up to its parent, and then subsequently - // down to the new child. + // the transform on the new child has to represent the transform from the + // current system up to its parent, and then subsequently down to the new + // child. parent->add_child(new_pn); CPT(TransformState) transform = physical_np.get_transform(parent_np); @@ -293,12 +279,9 @@ spawn_child_system(BaseParticle *bp) { get_physics_manager()->attach_physical(new_ps); } -//////////////////////////////////////////////////////////////////// -// Function: kill_particle -// Access: Private -// Description: Kills a particle, returns its slot to the empty -// stack. -//////////////////////////////////////////////////////////////////// +/** + * Kills a particle, returns its slot to the empty stack. + */ void ParticleSystem:: kill_particle(int pool_index) { // get a handle on our particle @@ -322,11 +305,9 @@ kill_particle(int pool_index) { _living_particles--; } -//////////////////////////////////////////////////////////////////// -// Function: resize_pool -// Access: Private -// Description: Resizes the particle pool -//////////////////////////////////////////////////////////////////// +/** + * Resizes the particle pool + */ #ifdef PSDEBUG #define PARTICLE_SYSTEM_RESIZE_POOL_SENTRIES #endif @@ -360,7 +341,7 @@ resize_pool(int size) { if (po_delta > 0) { for (i = 0; i < po_delta; i++) { - // int free_index = _physics_objects.size(); + // int free_index = _physics_objects.size(); BaseParticle *new_particle = _factory->alloc_particle(); if (new_particle) { @@ -462,13 +443,11 @@ resize_pool(int size) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: update -// Access: Public -// Description: Updates the particle system. Call once per frame. -//////////////////////////////////////////////////////////////////// +/** + * Updates the particle system. Call once per frame. + */ #ifdef PSDEBUG -//#define PARTICLE_SYSTEM_UPDATE_SENTRIES +// #define PARTICLE_SYSTEM_UPDATE_SENTRIES #endif void ParticleSystem:: update(PN_stdfloat dt) { @@ -520,13 +499,14 @@ update(PN_stdfloat dt) { age = bp->get_age() + dt; bp->set_age(age); - //cerr<<"bp->get_position().get_z() returning "<get_position().get_z()<get_position().get_z() returning + // "<get_position().get_z()<= bp->get_lifespan()) { kill_particle(current_index); } else if (get_floor_z() != -HUGE_VAL && bp->get_position().get_z() <= get_floor_z()) { - // ...the particle is going under the floor. - // Maybe tell the particle to bounce: bp->bounce()? + // ...the particle is going under the floor. Maybe tell the particle to + // bounce: bp->bounce()? kill_particle(current_index); } else { bp->update(); @@ -552,12 +532,10 @@ update(PN_stdfloat dt) { } #ifdef PSSANITYCHECK -//////////////////////////////////////////////////////////////////// -// Function: sanity_check -// Access: Private -// Description: Checks consistency of live particle count, free -// particle list, etc. returns 0 if everything is normal -//////////////////////////////////////////////////////////////////// +/** + * Checks consistency of live particle count, free particle list, etc. + * returns 0 if everything is normal + */ #ifndef NDEBUG #define PSSCVERBOSE #endif @@ -690,12 +668,9 @@ sanity_check() { } #endif -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystem:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -703,12 +678,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_free_particle_fifo -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystem:: write_free_particle_fifo(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -722,12 +694,9 @@ write_free_particle_fifo(ostream &out, int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_spawn_templates -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystem:: write_spawn_templates(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -741,12 +710,9 @@ write_spawn_templates(ostream &out, int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystem:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/particleSystem.h b/panda/src/particlesystem/particleSystem.h index 6944f8f944..5411d8e35e 100644 --- a/panda/src/particlesystem/particleSystem.h +++ b/panda/src/particlesystem/particleSystem.h @@ -1,22 +1,21 @@ -// Filename: particleSystem.h -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystem.h + * @author charles + * @date 2000-06-14 + */ #ifndef NDEBUG -//#define PSDEBUG +// #define PSDEBUG #endif -//#define PSSANITYCHECK +// #define PSSANITYCHECK #ifndef PARTICLESYSTEM_H #define PARTICLESYSTEM_H @@ -35,19 +34,18 @@ class ParticleSystemManager; -//////////////////////////////////////////////////////////////////// -// Class : ParticleSystem -// Description : Contains and manages a particle system. -//////////////////////////////////////////////////////////////////// +/** + * Contains and manages a particle system. + */ class EXPCL_PANDAPHYSICS ParticleSystem : public Physical { PUBLISHED: - // constructor/destructor + // constructordestructor ParticleSystem(int pool_size = 0); ParticleSystem(const ParticleSystem& copy); ~ParticleSystem(); - // access/queries + // accessqueries INLINE void set_pool_size(int size); INLINE void set_birth_rate(PN_stdfloat new_br); INLINE void set_soft_birth_rate(PN_stdfloat new_br); @@ -68,7 +66,7 @@ PUBLISHED: INLINE void set_emitter(BaseParticleEmitter *e); INLINE void set_factory(BaseParticleFactory *f); INLINE void set_floor_z(PN_stdfloat z); - + INLINE void clear_floor_z(); INLINE int get_pool_size() const; @@ -142,8 +140,8 @@ private: bool _template_system_flag; - // _render_parent is the ALREADY ALLOC'D node under which this - // system will render its particles. + // _render_parent is the ALREADY ALLOC'D node under which this system will + // render its particles. NodePath _render_parent; NodePath _render_node_path; @@ -188,4 +186,3 @@ private: #include "particleSystem.I" #endif // PARTICLESYSTEM_H - diff --git a/panda/src/particlesystem/particleSystemManager.I b/panda/src/particlesystem/particleSystemManager.I index b4f3820f69..fe1b4cd018 100644 --- a/panda/src/particlesystem/particleSystemManager.I +++ b/panda/src/particlesystem/particleSystemManager.I @@ -1,41 +1,37 @@ -// Filename: particleSystemManager.I -// Created by: charles (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystemManager.I + * @author charles + * @date 2000-06-28 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_frame_stepping -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystemManager:: set_frame_stepping(int every_nth_frame) { _nth_frame = every_nth_frame; } -//////////////////////////////////////////////////////////////////// -// Function: get_frame_stepping -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ParticleSystemManager:: get_frame_stepping() const { return _nth_frame; } -//////////////////////////////////////////////////////////////////// -// Function: attach_particlesystem -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystemManager:: attach_particlesystem(ParticleSystem *ps) { @@ -47,10 +43,9 @@ attach_particlesystem(ParticleSystem *ps) { _ps_list.push_back(ps); } -//////////////////////////////////////////////////////////////////// -// Function: clear -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ParticleSystemManager:: clear() { diff --git a/panda/src/particlesystem/particleSystemManager.cxx b/panda/src/particlesystem/particleSystemManager.cxx index 56ad5022cb..e6dbf53fef 100644 --- a/panda/src/particlesystem/particleSystemManager.cxx +++ b/panda/src/particlesystem/particleSystemManager.cxx @@ -1,16 +1,15 @@ -// Filename: particleSystemManager.cxx -// Created by: charles (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystemManager.cxx + * @author charles + * @date 2000-06-28 + */ #include "particleSystemManager.h" #include "particleSystem.h" @@ -24,30 +23,24 @@ PStatCollector ParticleSystemManager::_do_particles_collector("App:Particles:Do Particles"); -//////////////////////////////////////////////////////////////////// -// Function: ParticleSystemManager -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ParticleSystemManager:: ParticleSystemManager(int every_nth_frame) : _nth_frame(every_nth_frame), _cur_frame(0) { } -//////////////////////////////////////////////////////////////////// -// Function: ParticleSystemManager -// Access: Public, Virtual -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ ParticleSystemManager:: ~ParticleSystemManager() { } -//////////////////////////////////////////////////////////////////// -// Function: remove_particlesystem -// Access: Public -// Description: removes a ps from the maintenance list -//////////////////////////////////////////////////////////////////// +/** + * removes a ps from the maintenance list + */ void ParticleSystemManager:: remove_particlesystem(ParticleSystem *ps) { plist< PT(ParticleSystem) >::iterator found; @@ -61,18 +54,15 @@ remove_particlesystem(ParticleSystem *ps) { _ps_list.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: do_particles -// Access: Public -// Description: does an update and render for each ps in the list. -// this is probably the one you want to use. Rendering -// is the expensive operation, and particles REALLY -// should at least be updated every frame, so nth_frame -// stepping applies only to rendering. -//////////////////////////////////////////////////////////////////// +/** + * does an update and render for each ps in the list. this is probably the + * one you want to use. Rendering is the expensive operation, and particles + * REALLY should at least be updated every frame, so nth_frame stepping + * applies only to rendering. + */ void ParticleSystemManager:: do_particles(PN_stdfloat dt) { - // cout << "ParticlesystemManager::doparticles entering." << endl; + // cout << "ParticlesystemManager::doparticles entering." << endl; PStatTimer t1(_do_particles_collector); plist< PT(ParticleSystem) >::iterator cur; @@ -88,16 +78,16 @@ do_particles(PN_stdfloat dt) { cur = _ps_list.begin(); - // cout << "PSM::do_particles on a vector of size " << _ps_list.size() << endl; - // int cs = 0; + // cout << "PSM::do_particles on a vector of size " << _ps_list.size() << + // endl; int cs = 0; while (cur != _ps_list.end()) { ParticleSystem *cur_ps = *cur; // update this system if (cur_ps->get_active_system_flag() == true) { - // cout << " system " << cs++ << endl; - // cout << " count is: " << cur_ps->get_render_parent()->get_ref_count() << endl; + // cout << " system " << cs++ << endl; cout << " count is: " << + // cur_ps->get_render_parent()->get_ref_count() << endl; cur_ps->update(dt); // Handle age: @@ -125,17 +115,15 @@ do_particles(PN_stdfloat dt) { ++cur; } } - // cout << "PSM::do_particles finished." << endl; - // cout << "ParticleSystemManager::doparticles exiting." << endl; + // cout << "PSM::do_particles finished." << endl; cout << + // "ParticleSystemManager::doparticles exiting." << endl; } -//////////////////////////////////////////////////////////////////// -// Function: do_particles -// Access: Public -// Description: does an update and an optional render for a specific -// ps. Since rendering is the expensive operation, multiple -// updates could be applied before calling the final render. -//////////////////////////////////////////////////////////////////// +/** + * does an update and an optional render for a specific ps. Since rendering + * is the expensive operation, multiple updates could be applied before + * calling the final render. + */ void ParticleSystemManager:: do_particles(PN_stdfloat dt, ParticleSystem *ps, bool do_render) { if (ps->get_active_system_flag() == true) { @@ -153,12 +141,9 @@ do_particles(PN_stdfloat dt, ParticleSystem *ps, bool do_render) { } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystemManager:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -166,12 +151,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_ps_list -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystemManager:: write_ps_list(ostream &out, int indent) const { #ifndef NDEBUG //[ @@ -185,12 +167,9 @@ write_ps_list(ostream &out, int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ParticleSystemManager:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/particleSystemManager.h b/panda/src/particlesystem/particleSystemManager.h index 0d1ad97a0f..5ad7bc710f 100644 --- a/panda/src/particlesystem/particleSystemManager.h +++ b/panda/src/particlesystem/particleSystemManager.h @@ -1,16 +1,15 @@ -// Filename: particleSystemManager.h -// Created by: charles (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particleSystemManager.h + * @author charles + * @date 2000-06-28 + */ #ifndef PARTICLESYSTEMMANAGER_H #define PARTICLESYSTEMMANAGER_H @@ -20,13 +19,11 @@ #include "particleSystem.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : ParticleSystemManager -// Description : Manages a set of individual ParticleSystem objects, -// so that each individual one doesn't have to be -// updated and rendered every frame -// See Also : particleSystemManager.cxx -//////////////////////////////////////////////////////////////////// +/** + * Manages a set of individual ParticleSystem objects, so that each individual + * one doesn't have to be updated and rendered every frame See Also : + * particleSystemManager.cxx + */ class EXPCL_PANDAPHYSICS ParticleSystemManager { PUBLISHED: ParticleSystemManager(int every_nth_frame = 1); diff --git a/panda/src/particlesystem/particlefactories.h b/panda/src/particlesystem/particlefactories.h index 98a1d2b93a..57f32cf9ae 100644 --- a/panda/src/particlesystem/particlefactories.h +++ b/panda/src/particlesystem/particlefactories.h @@ -1,16 +1,15 @@ -// Filename: particlefactories.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particlefactories.h + * @author charles + * @date 2000-07-05 + */ #ifndef PARTICLEFACTORIES_H #define PARTICLEFACTORIES_H diff --git a/panda/src/particlesystem/particles.h b/panda/src/particlesystem/particles.h index bedeca7cc0..4db9cc94ef 100644 --- a/panda/src/particlesystem/particles.h +++ b/panda/src/particlesystem/particles.h @@ -1,16 +1,15 @@ -// Filename: particles.h -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file particles.h + * @author charles + * @date 2000-06-20 + */ #ifndef PARTICLES_H #define PARTICLES_H diff --git a/panda/src/particlesystem/pointEmitter.I b/panda/src/particlesystem/pointEmitter.I index 7043aa019c..7deb878064 100644 --- a/panda/src/particlesystem/pointEmitter.I +++ b/panda/src/particlesystem/pointEmitter.I @@ -1,22 +1,19 @@ -// Filename: pointEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_point -// Access: Public -// Description: point setting -//////////////////////////////////////////////////////////////////// +/** + * point setting + */ INLINE void PointEmitter:: set_location(const LPoint3& p) { _location = p; diff --git a/panda/src/particlesystem/pointEmitter.cxx b/panda/src/particlesystem/pointEmitter.cxx index 70855982e4..9c3664e7c7 100644 --- a/panda/src/particlesystem/pointEmitter.cxx +++ b/panda/src/particlesystem/pointEmitter.cxx @@ -1,86 +1,70 @@ -// Filename: pointEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "pointEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: PointEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ PointEmitter:: PointEmitter() : BaseParticleEmitter() { _location.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: PointEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ PointEmitter:: PointEmitter(const PointEmitter ©) : BaseParticleEmitter(copy) { _location = copy._location; } -//////////////////////////////////////////////////////////////////// -// Function: ~PointEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ PointEmitter:: ~PointEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *PointEmitter:: make_copy() { return new PointEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PointEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void PointEmitter:: assign_initial_position(LPoint3& pos) { pos = _location; } -//////////////////////////////////////////////////////////////////// -// Function: PointEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void PointEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -88,12 +72,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/pointEmitter.h b/panda/src/particlesystem/pointEmitter.h index 7d68f79356..145dff2344 100644 --- a/panda/src/particlesystem/pointEmitter.h +++ b/panda/src/particlesystem/pointEmitter.h @@ -1,27 +1,24 @@ -// Filename: pointEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef POINTEMITTER_H #define POINTEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : PointEmitter -// Description : Describes a planar ring region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar ring region in which particles are generated. + */ class EXPCL_PANDAPHYSICS PointEmitter : public BaseParticleEmitter { PUBLISHED: PointEmitter(); @@ -39,8 +36,7 @@ PUBLISHED: private: LPoint3 _location; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none virtual void assign_initial_position(LPoint3& pos); virtual void assign_initial_velocity(LVector3& vel); diff --git a/panda/src/particlesystem/pointParticle.cxx b/panda/src/particlesystem/pointParticle.cxx index 32f2955cf1..32e1dbf0b2 100644 --- a/panda/src/particlesystem/pointParticle.cxx +++ b/panda/src/particlesystem/pointParticle.cxx @@ -1,93 +1,75 @@ -// Filename: pointParticle.cxx -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticle.cxx + * @author charles + * @date 2000-06-19 + */ #include "pointParticle.h" -//////////////////////////////////////////////////////////////////// -// Function: PointParticle -// Access: Public -// Description: simple constructor -//////////////////////////////////////////////////////////////////// +/** + * simple constructor + */ PointParticle:: PointParticle(PN_stdfloat lifespan, bool alive) : BaseParticle(lifespan, alive) { set_oriented(false); } -//////////////////////////////////////////////////////////////////// -// Function: PointParticle -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ PointParticle:: PointParticle(const PointParticle ©) : BaseParticle(copy) { set_oriented(false); } -//////////////////////////////////////////////////////////////////// -// Function: ~PointParticle -// Access: Public -// Description: simple destructor -//////////////////////////////////////////////////////////////////// +/** + * simple destructor + */ PointParticle:: ~PointParticle() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: dynamic copier -//////////////////////////////////////////////////////////////////// +/** + * dynamic copier + */ PhysicsObject *PointParticle:: make_copy() const { return new PointParticle(*this); } -//////////////////////////////////////////////////////////////////// -// Function: die -// Access: Public -// Description: particle death routine -//////////////////////////////////////////////////////////////////// +/** + * particle death routine + */ void PointParticle:: die() { } -//////////////////////////////////////////////////////////////////// -// Function: init -// Access: Public -// Description: particle init routine -//////////////////////////////////////////////////////////////////// +/** + * particle init routine + */ void PointParticle:: init() { } -//////////////////////////////////////////////////////////////////// -// Function: update -// Access: Public -// Description: particle update -//////////////////////////////////////////////////////////////////// +/** + * particle update + */ void PointParticle:: update() { } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticle:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -95,12 +77,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticle:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/pointParticle.h b/panda/src/particlesystem/pointParticle.h index b11bb7d550..f9fe566a40 100644 --- a/panda/src/particlesystem/pointParticle.h +++ b/panda/src/particlesystem/pointParticle.h @@ -1,27 +1,25 @@ -// Filename: pointParticle.h -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticle.h + * @author charles + * @date 2000-06-19 + */ #ifndef POINTPARTICLE_H #define POINTPARTICLE_H #include "baseParticle.h" -//////////////////////////////////////////////////////////////////// -// Class : PointParticle -// Description : Describes a particle that requires representation -// by a point (pixel, sparkle, billboard) -//////////////////////////////////////////////////////////////////// +/** + * Describes a particle that requires representation by a point (pixel, + * sparkle, billboard) + */ class EXPCL_PANDAPHYSICS PointParticle : public BaseParticle { public: PointParticle(PN_stdfloat lifespan = 0.0f, bool alive = false); diff --git a/panda/src/particlesystem/pointParticleFactory.cxx b/panda/src/particlesystem/pointParticleFactory.cxx index 40a15fe559..71a06d763e 100644 --- a/panda/src/particlesystem/pointParticleFactory.cxx +++ b/panda/src/particlesystem/pointParticleFactory.cxx @@ -1,77 +1,63 @@ -// Filename: pointParticleFactory.cxx -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticleFactory.cxx + * @author charles + * @date 2000-07-05 + */ #include "pointParticleFactory.h" #include "pointParticle.h" #include -//////////////////////////////////////////////////////////////////// -// Function: PointParticleFactory -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ PointParticleFactory:: PointParticleFactory() : BaseParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: PointParticleFactory -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ PointParticleFactory:: PointParticleFactory(const PointParticleFactory ©) : BaseParticleFactory(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~PointParticleFactory -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ PointParticleFactory:: ~PointParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: populate_child_particle -// Access: Public -// Description: child particle generation function -//////////////////////////////////////////////////////////////////// +/** + * child particle generation function + */ void PointParticleFactory:: populate_child_particle(BaseParticle *bp) const { bp->set_oriented(false); } -//////////////////////////////////////////////////////////////////// -// Function: alloc_particle -// Access: Public -// Description: child particle generation function -//////////////////////////////////////////////////////////////////// +/** + * child particle generation function + */ BaseParticle *PointParticleFactory:: alloc_particle() const { return new PointParticle; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticleFactory:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -79,12 +65,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticleFactory:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/pointParticleFactory.h b/panda/src/particlesystem/pointParticleFactory.h index ff82089be5..0ce2b6e232 100644 --- a/panda/src/particlesystem/pointParticleFactory.h +++ b/panda/src/particlesystem/pointParticleFactory.h @@ -1,26 +1,24 @@ -// Filename: pointParticleFactory.h -// Created by: charles (05Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticleFactory.h + * @author charles + * @date 2000-07-05 + */ #ifndef POINTPARTICLEFACTORY_H #define POINTPARTICLEFACTORY_H #include "baseParticleFactory.h" -//////////////////////////////////////////////////////////////////// -// Class : PointParticleFactory -// Description : Creates point particles to user specs -//////////////////////////////////////////////////////////////////// +/** + * Creates point particles to user specs + */ class EXPCL_PANDAPHYSICS PointParticleFactory : public BaseParticleFactory { PUBLISHED: diff --git a/panda/src/particlesystem/pointParticleRenderer.I b/panda/src/particlesystem/pointParticleRenderer.I index 408dbd5250..fa76ff89bc 100644 --- a/panda/src/particlesystem/pointParticleRenderer.I +++ b/panda/src/particlesystem/pointParticleRenderer.I @@ -1,103 +1,92 @@ -// Filename: pointParticleRenderer.I -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticleRenderer.I + * @author charles + * @date 2000-06-20 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_point_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PointParticleRenderer:: set_point_size(PN_stdfloat point_size) { _point_size = point_size; _thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _point_size); } -//////////////////////////////////////////////////////////////////// -// Function: set_start_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PointParticleRenderer:: set_start_color(const LColor& sc) { _start_color = sc; } -//////////////////////////////////////////////////////////////////// -// Function: set_end_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PointParticleRenderer:: set_end_color(const LColor& ec) { _end_color = ec; } -//////////////////////////////////////////////////////////////////// -// Function: set_blend_type -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PointParticleRenderer:: set_blend_type(PointParticleRenderer::PointParticleBlendType bt) { _blend_type = bt; } -//////////////////////////////////////////////////////////////////// -// Function: set_blend_method -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PointParticleRenderer:: set_blend_method(BaseParticleRenderer::ParticleRendererBlendMethod bm) { _blend_method = bm; } -//////////////////////////////////////////////////////////////////// -// Function: get_point_size -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat PointParticleRenderer:: get_point_size() const { return _point_size; } -//////////////////////////////////////////////////////////////////// -// Function: get_start_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& PointParticleRenderer:: get_start_color() const { return _start_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_end_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& PointParticleRenderer:: get_end_color() const { return _end_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_blend_type -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PointParticleRenderer::PointParticleBlendType PointParticleRenderer:: get_blend_type() const { return _blend_type; } -//////////////////////////////////////////////////////////////////// -// Function: get_blend_method -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleRenderer::ParticleRendererBlendMethod PointParticleRenderer:: get_blend_method() const { return _blend_method; diff --git a/panda/src/particlesystem/pointParticleRenderer.cxx b/panda/src/particlesystem/pointParticleRenderer.cxx index d1a7ba759e..2a5d345d37 100644 --- a/panda/src/particlesystem/pointParticleRenderer.cxx +++ b/panda/src/particlesystem/pointParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: pointParticleRenderer.cxx -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticleRenderer.cxx + * @author charles + * @date 2000-06-20 + */ #include "pointParticleRenderer.h" #include "boundingSphere.h" @@ -22,11 +21,9 @@ PStatCollector PointParticleRenderer::_render_collector("App:Particles:Point:Render"); -//////////////////////////////////////////////////////////////////// -// Function: PointParticleRenderer -// Access: Public -// Description: special constructor -//////////////////////////////////////////////////////////////////// +/** + * special constructor + */ PointParticleRenderer:: PointParticleRenderer(ParticleRendererAlphaMode am, PN_stdfloat point_size, @@ -41,11 +38,9 @@ PointParticleRenderer(ParticleRendererAlphaMode am, resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: PointParticleRenderer -// Access: Public -// Description: Copy constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy constructor + */ PointParticleRenderer:: PointParticleRenderer(const PointParticleRenderer& copy) : BaseParticleRenderer(copy) @@ -59,31 +54,24 @@ PointParticleRenderer(const PointParticleRenderer& copy) : resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: ~PointParticleRenderer -// Access: Public -// Description: Simple destructor -//////////////////////////////////////////////////////////////////// +/** + * Simple destructor + */ PointParticleRenderer:: ~PointParticleRenderer() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: for spawning systems from dead particles -//////////////////////////////////////////////////////////////////// +/** + * for spawning systems from dead particles + */ BaseParticleRenderer *PointParticleRenderer:: make_copy() { return new PointParticleRenderer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: resize_pool -// Access: Public -// Description: reallocate the space for the vertex and color -// pools -//////////////////////////////////////////////////////////////////// +/** + * reallocate the space for the vertex and color pools + */ void PointParticleRenderer:: resize_pool(int new_size) { if (new_size == _max_pool_size) @@ -94,11 +82,9 @@ resize_pool(int new_size) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: init_geoms -// Access: Private -// Description: On-construction initialization -//////////////////////////////////////////////////////////////////// +/** + * On-construction initialization + */ void PointParticleRenderer:: init_geoms() { _vdata = new GeomVertexData @@ -114,29 +100,23 @@ init_geoms() { render_node->add_geom(_point_primitive, _render_state->add_attrib(_thick)); } -//////////////////////////////////////////////////////////////////// -// Function: birth_particle -// Access: Private, Virtual -// Description: child birth -//////////////////////////////////////////////////////////////////// +/** + * child birth + */ void PointParticleRenderer:: birth_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: kill_particle -// Access: Private, Virtual -// Description: child kill -//////////////////////////////////////////////////////////////////// +/** + * child kill + */ void PointParticleRenderer:: kill_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: create_color -// Access: Private -// Description: Generates the point color based on the render_type -//////////////////////////////////////////////////////////////////// +/** + * Generates the point color based on the render_type + */ LColor PointParticleRenderer:: create_color(const BaseParticle *p) { LColor color; @@ -197,11 +177,9 @@ create_color(const BaseParticle *p) { return color; } -//////////////////////////////////////////////////////////////////// -// Function: render -// Access: Public -// Description: renders the particle system out to a GeomNode -//////////////////////////////////////////////////////////////////// +/** + * renders the particle system out to a GeomNode + */ void PointParticleRenderer:: render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { PStatTimer t1(_render_collector); @@ -275,12 +253,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { get_render_node()->mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -288,12 +263,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PointParticleRenderer:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "PointParticleRenderer:\n"; diff --git a/panda/src/particlesystem/pointParticleRenderer.h b/panda/src/particlesystem/pointParticleRenderer.h index d691cd296b..4d1ee48f8c 100644 --- a/panda/src/particlesystem/pointParticleRenderer.h +++ b/panda/src/particlesystem/pointParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: pointParticleRenderer.h -// Created by: charles (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointParticleRenderer.h + * @author charles + * @date 2000-06-20 + */ #ifndef POINTPARTICLERENDERER_H #define POINTPARTICLERENDERER_H @@ -26,12 +25,10 @@ #include "geomPoints.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : PointParticleRenderer -// Description : Simple point/point particle renderer. Does NOT -// handle billboards- use BillboardParticleRenderer -// for that. -//////////////////////////////////////////////////////////////////// +/** + * Simple point/point particle renderer. Does NOT handle billboards- use + * BillboardParticleRenderer for that. + */ class EXPCL_PANDAPHYSICS PointParticleRenderer : public BaseParticleRenderer { PUBLISHED: diff --git a/panda/src/particlesystem/rectangleEmitter.I b/panda/src/particlesystem/rectangleEmitter.I index 7c809d8052..3a86e76c61 100644 --- a/panda/src/particlesystem/rectangleEmitter.I +++ b/panda/src/particlesystem/rectangleEmitter.I @@ -1,52 +1,43 @@ -// Filename: rectangleEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rectangleEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_min_bound -// Access: Public -// Description: boundary set -//////////////////////////////////////////////////////////////////// +/** + * boundary set + */ INLINE void RectangleEmitter:: set_min_bound(const LPoint2& vmin) { _vmin = vmin; } -//////////////////////////////////////////////////////////////////// -// Function: set_max_bound -// Access: Public -// Description: boundary set -//////////////////////////////////////////////////////////////////// +/** + * boundary set + */ INLINE void RectangleEmitter:: set_max_bound(const LPoint2& vmax) { _vmax = vmax; } -//////////////////////////////////////////////////////////////////// -// Function: get_min_bound -// Access: Public -// Description: boundary get -//////////////////////////////////////////////////////////////////// +/** + * boundary get + */ INLINE LPoint2 RectangleEmitter:: get_min_bound() const { return _vmin; } -//////////////////////////////////////////////////////////////////// -// Function: get_max_bound -// Access: Public -// Description: boundary get -//////////////////////////////////////////////////////////////////// +/** + * boundary get + */ INLINE LPoint2 RectangleEmitter:: get_max_bound() const { return _vmax; diff --git a/panda/src/particlesystem/rectangleEmitter.cxx b/panda/src/particlesystem/rectangleEmitter.cxx index 4fa67e242e..f261662486 100644 --- a/panda/src/particlesystem/rectangleEmitter.cxx +++ b/panda/src/particlesystem/rectangleEmitter.cxx @@ -1,24 +1,21 @@ -// Filename: rectangleEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rectangleEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "rectangleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: RectangleEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ RectangleEmitter:: RectangleEmitter() : BaseParticleEmitter() { @@ -26,11 +23,9 @@ RectangleEmitter() : _vmax.set( 0.5f, 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: RectangleEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ RectangleEmitter:: RectangleEmitter(const RectangleEmitter ©) : BaseParticleEmitter(copy) { @@ -38,30 +33,24 @@ RectangleEmitter(const RectangleEmitter ©) : _vmax = copy._vmax; } -//////////////////////////////////////////////////////////////////// -// Function: RectangleEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ RectangleEmitter:: ~RectangleEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *RectangleEmitter:: make_copy() { return new RectangleEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: RectangleEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void RectangleEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat t_x = NORMALIZED_RAND(); @@ -75,22 +64,17 @@ assign_initial_position(LPoint3& pos) { pos.set(lerp_x, lerp_y, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: RectangleEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void RectangleEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(0.0f,0.0f,0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void RectangleEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -98,12 +82,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void RectangleEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/rectangleEmitter.h b/panda/src/particlesystem/rectangleEmitter.h index d4c67c6ea5..ecd95728e1 100644 --- a/panda/src/particlesystem/rectangleEmitter.h +++ b/panda/src/particlesystem/rectangleEmitter.h @@ -1,27 +1,24 @@ -// Filename: rectangleEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rectangleEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef RECTANGLEEMITTER_H #define RECTANGLEEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : RectangleEmitter -// Description : Describes a planar square region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar square region in which particles are generated. + */ class EXPCL_PANDAPHYSICS RectangleEmitter : public BaseParticleEmitter { PUBLISHED: RectangleEmitter(); @@ -43,8 +40,7 @@ private: LPoint2 _vmin; LPoint2 _vmax; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none virtual void assign_initial_position(LPoint3& pos); virtual void assign_initial_velocity(LVector3& vel); diff --git a/panda/src/particlesystem/ringEmitter.I b/panda/src/particlesystem/ringEmitter.I index af683baa21..a6b0dcec7e 100644 --- a/panda/src/particlesystem/ringEmitter.I +++ b/panda/src/particlesystem/ringEmitter.I @@ -1,104 +1,84 @@ -// Filename: ringEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ringEmitter.I + * @author charles + * @date 2000-06-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -// Description: radius set -//////////////////////////////////////////////////////////////////// +/** + * radius set + */ INLINE void RingEmitter:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: set_angle -// Access: Public -// Description: angle of elevation set -//////////////////////////////////////////////////////////////////// +/** + * angle of elevation set + */ INLINE void RingEmitter:: set_angle(PN_stdfloat angle) { _aoe = angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_radius_spread -// Access: Public -// Description: radius_spread set -//////////////////////////////////////////////////////////////////// +/** + * radius_spread set + */ INLINE void RingEmitter:: set_radius_spread(PN_stdfloat spread) { _radius_spread = spread; } -//////////////////////////////////////////////////////////////////// -// Function: set_uniform_emission -// Access: Public -// Description: uniform_emission set -//////////////////////////////////////////////////////////////////// +/** + * uniform_emission set + */ INLINE void RingEmitter:: set_uniform_emission(int uniform_emission) { _uniform_emission = uniform_emission; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -// Description: radius get -//////////////////////////////////////////////////////////////////// +/** + * radius get + */ INLINE PN_stdfloat RingEmitter:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_angle -// Access: Public -// Description: angle of elevation get -//////////////////////////////////////////////////////////////////// +/** + * angle of elevation get + */ INLINE PN_stdfloat RingEmitter:: get_angle() const { return _aoe; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius_spread -// Access: Public -// Description: radius_spread get -//////////////////////////////////////////////////////////////////// +/** + * radius_spread get + */ INLINE PN_stdfloat RingEmitter:: get_radius_spread() const { return _radius_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_uniform_emission -// Access: Public -// Description: uniform_emission get -//////////////////////////////////////////////////////////////////// +/** + * uniform_emission get + */ INLINE int RingEmitter:: get_uniform_emission() const { return _uniform_emission; } - - - diff --git a/panda/src/particlesystem/ringEmitter.cxx b/panda/src/particlesystem/ringEmitter.cxx index 80101067a1..c9f7009807 100644 --- a/panda/src/particlesystem/ringEmitter.cxx +++ b/panda/src/particlesystem/ringEmitter.cxx @@ -1,35 +1,30 @@ -// Filename: ringEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ringEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "ringEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: RingEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ RingEmitter:: RingEmitter() : _radius(1.0f), _radius_spread(0.0f), _aoe(0.0f), _uniform_emission(0), _theta(0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: RingEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ RingEmitter:: RingEmitter(const RingEmitter ©) : BaseParticleEmitter(copy) { @@ -43,30 +38,24 @@ RingEmitter(const RingEmitter ©) : _cos_theta = copy._cos_theta; } -//////////////////////////////////////////////////////////////////// -// Function: ~RingEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ RingEmitter:: ~RingEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *RingEmitter:: make_copy() { return new RingEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: RingEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void RingEmitter:: assign_initial_position(LPoint3& pos) { if (_uniform_emission > 0) @@ -90,11 +79,9 @@ assign_initial_position(LPoint3& pos) { pos.set(new_x, new_y, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: RingEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void RingEmitter:: assign_initial_velocity(LVector3& vel) { PN_stdfloat vel_z = sinf(deg_2_rad(_aoe)); @@ -114,12 +101,9 @@ assign_initial_velocity(LVector3& vel) { vel.set(vel_x, vel_y, vel_z); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void RingEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -127,12 +111,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void RingEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/ringEmitter.h b/panda/src/particlesystem/ringEmitter.h index 8b03012dc0..0278e8ac97 100644 --- a/panda/src/particlesystem/ringEmitter.h +++ b/panda/src/particlesystem/ringEmitter.h @@ -1,27 +1,24 @@ -// Filename: ringEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ringEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef RINGEMITTER_H #define RINGEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : RingEmitter -// Description : Describes a planar ring region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar ring region in which particles are generated. + */ class EXPCL_PANDAPHYSICS RingEmitter : public BaseParticleEmitter { PUBLISHED: RingEmitter(); diff --git a/panda/src/particlesystem/sparkleParticleRenderer.I b/panda/src/particlesystem/sparkleParticleRenderer.I index 9c91b9cacb..975577d5aa 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.I +++ b/panda/src/particlesystem/sparkleParticleRenderer.I @@ -1,111 +1,99 @@ -// Filename: sparkleParticleRenderer.I -// Created by: charles (27Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparkleParticleRenderer.I + * @author charles + * @date 2000-06-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_center_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SparkleParticleRenderer:: set_center_color(const LColor& c) { _center_color = c; } -//////////////////////////////////////////////////////////////////// -// Function: set_edge_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SparkleParticleRenderer:: set_edge_color(const LColor& c) { _edge_color = c; } -//////////////////////////////////////////////////////////////////// -// Function: set_life_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SparkleParticleRenderer:: set_life_scale(SparkleParticleRenderer::SparkleParticleLifeScale ls) { _life_scale = ls; } -//////////////////////////////////////////////////////////////////// -// Function: set_birth_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SparkleParticleRenderer:: set_birth_radius(PN_stdfloat radius) { _birth_radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: set_death_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SparkleParticleRenderer:: set_death_radius(PN_stdfloat radius) { _death_radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_center_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& SparkleParticleRenderer:: get_center_color() const { return _center_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_edge_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const LColor& SparkleParticleRenderer:: get_edge_color() const { return _edge_color; } -//////////////////////////////////////////////////////////////////// -// Function: get_life_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE SparkleParticleRenderer::SparkleParticleLifeScale SparkleParticleRenderer:: get_life_scale() const { return _life_scale; } -//////////////////////////////////////////////////////////////////// -// Function: get_birth_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SparkleParticleRenderer:: get_birth_radius() const { return _birth_radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_death_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SparkleParticleRenderer:: get_death_radius() const { return _death_radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SparkleParticleRenderer:: get_radius(BaseParticle *bp) { if (_life_scale == SP_NO_SCALE) diff --git a/panda/src/particlesystem/sparkleParticleRenderer.cxx b/panda/src/particlesystem/sparkleParticleRenderer.cxx index 21adda99a8..5dc2d0772b 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.cxx +++ b/panda/src/particlesystem/sparkleParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: sparkleParticleRenderer.cxx -// Created by: charles (27Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparkleParticleRenderer.cxx + * @author charles + * @date 2000-06-27 + */ #include "sparkleParticleRenderer.h" #include "boundingSphere.h" @@ -22,11 +21,9 @@ PStatCollector SparkleParticleRenderer::_render_collector("App:Particles:Sparkle:Render"); -//////////////////////////////////////////////////////////////////// -// Function: SparkleParticleRenderer -// Access: Public -// Description: Default Constructor -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor + */ SparkleParticleRenderer:: SparkleParticleRenderer() : BaseParticleRenderer(PR_ALPHA_NONE), @@ -37,11 +34,9 @@ SparkleParticleRenderer() : resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: SparkleParticleRenderer -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ SparkleParticleRenderer:: SparkleParticleRenderer(const LColor& center, const LColor& edge, PN_stdfloat birth_radius, PN_stdfloat death_radius, @@ -54,11 +49,9 @@ SparkleParticleRenderer(const LColor& center, const LColor& edge, resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: SparkleParticleRenderer -// Access: Public -// Description: Copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor + */ SparkleParticleRenderer:: SparkleParticleRenderer(const SparkleParticleRenderer& copy) : BaseParticleRenderer(copy) { @@ -71,49 +64,38 @@ SparkleParticleRenderer(const SparkleParticleRenderer& copy) : resize_pool(0); } -//////////////////////////////////////////////////////////////////// -// Function: ~SparkleParticleRenderer -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ SparkleParticleRenderer:: ~SparkleParticleRenderer() { } -//////////////////////////////////////////////////////////////////// -// Function: make copy -// Access: Public -// Description: child virtual for spawning systems -//////////////////////////////////////////////////////////////////// +/** + * child virtual for spawning systems + */ BaseParticleRenderer *SparkleParticleRenderer:: make_copy() { return new SparkleParticleRenderer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: birth_particle -// Access: Private, Virtual -// Description: child birth -//////////////////////////////////////////////////////////////////// +/** + * child birth + */ void SparkleParticleRenderer:: birth_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: kill_particle -// Access: Private, Virtual -// Description: child kill -//////////////////////////////////////////////////////////////////// +/** + * child kill + */ void SparkleParticleRenderer:: kill_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: resize_pool -// Access: Private -// Description: resizes the render pool. Reference counting -// makes this easy. -//////////////////////////////////////////////////////////////////// +/** + * resizes the render pool. Reference counting makes this easy. + */ void SparkleParticleRenderer:: resize_pool(int new_size) { _max_pool_size = new_size; @@ -121,11 +103,9 @@ resize_pool(int new_size) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: init_geoms -// Access: Private -// Description: initializes the geomnodes -//////////////////////////////////////////////////////////////////// +/** + * initializes the geomnodes + */ void SparkleParticleRenderer:: init_geoms() { _vdata = new GeomVertexData @@ -141,11 +121,9 @@ init_geoms() { render_node->add_geom(_line_primitive, _render_state); } -//////////////////////////////////////////////////////////////////// -// Function: render -// Access: Private -// Description: populates the GeomLine -//////////////////////////////////////////////////////////////////// +/** + * populates the GeomLine + */ void SparkleParticleRenderer:: render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { PStatTimer t1(_render_collector); @@ -280,12 +258,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { get_render_node()->mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SparkleParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -293,12 +268,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SparkleParticleRenderer:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "SparkleParticleRenderer:\n"; diff --git a/panda/src/particlesystem/sparkleParticleRenderer.h b/panda/src/particlesystem/sparkleParticleRenderer.h index ce3ae991b8..ee5e85a860 100644 --- a/panda/src/particlesystem/sparkleParticleRenderer.h +++ b/panda/src/particlesystem/sparkleParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: sparkleParticleRenderer.h -// Created by: charles (27Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparkleParticleRenderer.h + * @author charles + * @date 2000-06-27 + */ #ifndef SPARKLEPARTICLERENDERER_H #define SPARKLEPARTICLERENDERER_H @@ -29,10 +28,9 @@ enum SparkleParticleLifeScale { SP_SCALE }; -//////////////////////////////////////////////////////////////////// -// Class : SparkleParticleRenderer -// Description : pretty sparkly things. -//////////////////////////////////////////////////////////////////// +/** + * pretty sparkly things. + */ class EXPCL_PANDAPHYSICS SparkleParticleRenderer : public BaseParticleRenderer { PUBLISHED: enum SparkleParticleLifeScale { diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.I b/panda/src/particlesystem/sphereSurfaceEmitter.I index a1782d6919..1e8eb700bc 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.I +++ b/panda/src/particlesystem/sphereSurfaceEmitter.I @@ -1,35 +1,30 @@ -// Filename: sphereSurfaceEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereSurfaceEmitter.I + * @author charles + * @date 2000-06-26 + */ #include "config_particlesystem.h" -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -// Description: radius set -//////////////////////////////////////////////////////////////////// +/** + * radius set + */ INLINE void SphereSurfaceEmitter:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -// Description: radius get -//////////////////////////////////////////////////////////////////// +/** + * radius get + */ INLINE PN_stdfloat SphereSurfaceEmitter:: get_radius() const { diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.cxx b/panda/src/particlesystem/sphereSurfaceEmitter.cxx index 44668ea7c3..37b6a274fb 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.cxx +++ b/panda/src/particlesystem/sphereSurfaceEmitter.cxx @@ -1,64 +1,53 @@ -// Filename: sphereSurfaceEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereSurfaceEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "sphereSurfaceEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: SphereSurfaceEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ SphereSurfaceEmitter:: SphereSurfaceEmitter() { _radius = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: SphereSurfaceEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ SphereSurfaceEmitter:: SphereSurfaceEmitter(const SphereSurfaceEmitter ©) : BaseParticleEmitter(copy) { _radius = copy._radius; } -//////////////////////////////////////////////////////////////////// -// Function: ~SphereSurfaceEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ SphereSurfaceEmitter:: ~SphereSurfaceEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *SphereSurfaceEmitter:: make_copy() { return new SphereSurfaceEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SphereSurfaceEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void SphereSurfaceEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat z, theta, r; @@ -70,22 +59,17 @@ assign_initial_position(LPoint3& pos) { pos.set(r * cosf(theta), r * sinf(theta), z); } -//////////////////////////////////////////////////////////////////// -// Function: SphereSurfaceEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void SphereSurfaceEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(0,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SphereSurfaceEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -93,12 +77,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SphereSurfaceEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/sphereSurfaceEmitter.h b/panda/src/particlesystem/sphereSurfaceEmitter.h index 53943390dd..50a5dda839 100644 --- a/panda/src/particlesystem/sphereSurfaceEmitter.h +++ b/panda/src/particlesystem/sphereSurfaceEmitter.h @@ -1,27 +1,24 @@ -// Filename: sphereSurfaceEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereSurfaceEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef SPHERESURFACEEMITTER_H #define SPHERESURFACEEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : SphereSurfaceEmitter -// Description : Describes a curved space in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a curved space in which particles are generated. + */ class EXPCL_PANDAPHYSICS SphereSurfaceEmitter : public BaseParticleEmitter { PUBLISHED: SphereSurfaceEmitter(); @@ -39,8 +36,7 @@ PUBLISHED: private: PN_stdfloat _radius; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none virtual void assign_initial_position(LPoint3& pos); virtual void assign_initial_velocity(LVector3& vel); diff --git a/panda/src/particlesystem/sphereVolumeEmitter.I b/panda/src/particlesystem/sphereVolumeEmitter.I index e876e247f9..b0e5fc041f 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.I +++ b/panda/src/particlesystem/sphereVolumeEmitter.I @@ -1,35 +1,30 @@ -// Filename: sphereVolumeEmitter.I -// Created by: charles (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereVolumeEmitter.I + * @author charles + * @date 2000-06-26 + */ #include "config_particlesystem.h" -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -// Description: radius set -//////////////////////////////////////////////////////////////////// +/** + * radius set + */ INLINE void SphereVolumeEmitter:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -// Description: radius get -//////////////////////////////////////////////////////////////////// +/** + * radius get + */ INLINE PN_stdfloat SphereVolumeEmitter:: get_radius() const { diff --git a/panda/src/particlesystem/sphereVolumeEmitter.cxx b/panda/src/particlesystem/sphereVolumeEmitter.cxx index 5eda0bb648..5b541ce220 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.cxx +++ b/panda/src/particlesystem/sphereVolumeEmitter.cxx @@ -1,34 +1,29 @@ -// Filename: sphereVolumeEmitter.cxx -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereVolumeEmitter.cxx + * @author charles + * @date 2000-06-22 + */ #include "sphereVolumeEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: SphereVolumeEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ SphereVolumeEmitter:: SphereVolumeEmitter() { _radius = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: SphereVolumeEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ SphereVolumeEmitter:: SphereVolumeEmitter(const SphereVolumeEmitter ©) : BaseParticleEmitter(copy) { @@ -36,30 +31,24 @@ SphereVolumeEmitter(const SphereVolumeEmitter ©) : _particle_pos = copy._particle_pos; } -//////////////////////////////////////////////////////////////////// -// Function: ~SphereVolumeEmitter -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ SphereVolumeEmitter:: ~SphereVolumeEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ BaseParticleEmitter *SphereVolumeEmitter:: make_copy() { return new SphereVolumeEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SphereVolumeEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void SphereVolumeEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat z, theta, r; @@ -82,24 +71,19 @@ assign_initial_position(LPoint3& pos) { pos = _particle_pos; } -//////////////////////////////////////////////////////////////////// -// Function: SphereVolumeEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void SphereVolumeEmitter:: assign_initial_velocity(LVector3& vel) { - // set velocity to [0..1] according to distance from center, - // along vector from center to position + // set velocity to [0..1] according to distance from center, along vector + // from center to position vel = _particle_pos / _radius; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SphereVolumeEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -107,12 +91,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SphereVolumeEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/sphereVolumeEmitter.h b/panda/src/particlesystem/sphereVolumeEmitter.h index 32857c8ca4..29d49b92a9 100644 --- a/panda/src/particlesystem/sphereVolumeEmitter.h +++ b/panda/src/particlesystem/sphereVolumeEmitter.h @@ -1,27 +1,24 @@ -// Filename: sphereVolumeEmitter.h -// Created by: charles (22Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sphereVolumeEmitter.h + * @author charles + * @date 2000-06-22 + */ #ifndef SPHEREVOLUMEEMITTER_H #define SPHEREVOLUMEEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : SphereVolumeEmitter -// Description : Describes a voluminous spherical region in which -// particles are generated. -//////////////////////////////////////////////////////////////////// +/** + * Describes a voluminous spherical region in which particles are generated. + */ class EXPCL_PANDAPHYSICS SphereVolumeEmitter : public BaseParticleEmitter { PUBLISHED: SphereVolumeEmitter(); @@ -39,8 +36,7 @@ PUBLISHED: private: PN_stdfloat _radius; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none // scratch variables that carry over from position calc to velocity calc LPoint3 _particle_pos; diff --git a/panda/src/particlesystem/spriteParticleRenderer.I b/panda/src/particlesystem/spriteParticleRenderer.I index 059e1c700f..1f1d4e488b 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.I +++ b/panda/src/particlesystem/spriteParticleRenderer.I @@ -1,29 +1,24 @@ -// Filename: spriteParticleRenderer.I -// Created by: charles (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spriteParticleRenderer.I + * @author charles + * @date 2000-07-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_texture -// Access: Published -// Description: Sets the renderer up to render the entire texture -// image. The scale of each particle is based on the -// size of the texture in each dimension, modified by -// texels_per_unit. -// -// Used to set the size of the particles. Will clear -// all previously loaded textures and animations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the renderer up to render the entire texture image. The scale of each + * particle is based on the size of the texture in each dimension, modified by + * texels_per_unit. + * + * Used to set the size of the particles. Will clear all previously loaded + * textures and animations. + */ INLINE void SpriteParticleRenderer:: set_texture(Texture *tex, PN_stdfloat texels_per_unit) { if (tex != (Texture *)NULL) { @@ -41,14 +36,11 @@ set_texture(Texture *tex, PN_stdfloat texels_per_unit) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::add_texture -// Access: Published -// Description: Adds texture to image pool, effectively creating a -// single frame animation that can be selected at -// particle birth. This should only be called after -// a previous call to set_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Adds texture to image pool, effectively creating a single frame animation + * that can be selected at particle birth. This should only be called after a + * previous call to set_texture(). + */ INLINE void SpriteParticleRenderer:: add_texture(Texture *tex, PN_stdfloat texels_per_unit, bool resize) { if (_anims.size() == 0) { @@ -69,11 +61,9 @@ add_texture(Texture *tex, PN_stdfloat texels_per_unit, bool resize) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::remove_animation -// Access: Published -// Description: Removes an animation texture set from the renderer. -//////////////////////////////////////////////////////////////////// +/** + * Removes an animation texture set from the renderer. + */ INLINE void SpriteParticleRenderer:: remove_animation(const int n) { nassertv(n < (int)_anims.size()); @@ -90,27 +80,21 @@ remove_animation(const int n) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_ll_uv -// Access: Public -// Description: Sets the UV coordinate of the lower-left corner of -// all the sprites generated by this renderer. Normally -// this is (0, 0), but it might be set to something else -// to use only a portion of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the UV coordinate of the lower-left corner of all the sprites + * generated by this renderer. Normally this is (0, 0), but it might be set + * to something else to use only a portion of the texture. + */ INLINE void SpriteParticleRenderer:: set_ll_uv(const LTexCoord &ll_uv) { set_ll_uv(ll_uv,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_ll_uv -// Access: Public -// Description: Sets the UV coordinate of the lower-left corner of -// all the sprites generated by this renderer. Normally -// this is (0, 0), but it might be set to something else -// to use only a portion of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the UV coordinate of the lower-left corner of all the sprites + * generated by this renderer. Normally this is (0, 0), but it might be set + * to something else to use only a portion of the texture. + */ INLINE void SpriteParticleRenderer:: set_ll_uv(const LTexCoord &ll_uv, const int anim, const int frame) { if(anim < (int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) { @@ -118,27 +102,21 @@ set_ll_uv(const LTexCoord &ll_uv, const int anim, const int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_ur_uv -// Access: Public -// Description: Sets the UV coordinate of the upper-right corner of -// all the sprites generated by this renderer. Normally -// this is (1, 1), but it might be set to something else -// to use only a portion of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the UV coordinate of the upper-right corner of all the sprites + * generated by this renderer. Normally this is (1, 1), but it might be set + * to something else to use only a portion of the texture. + */ INLINE void SpriteParticleRenderer:: set_ur_uv(const LTexCoord &ur_uv) { set_ur_uv(ur_uv,0,0); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_ur_uv -// Access: Public -// Description: Sets the UV coordinate of the upper-right corner of -// all the sprites generated by this renderer. Normally -// this is (1, 1), but it might be set to something else -// to use only a portion of the texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the UV coordinate of the upper-right corner of all the sprites + * generated by this renderer. Normally this is (1, 1), but it might be set + * to something else to use only a portion of the texture. + */ INLINE void SpriteParticleRenderer:: set_ur_uv(const LTexCoord &ur_uv, const int anim, const int frame) { if(anim < (int)_anims.size() && frame < (int)_anims[anim]->get_num_frames()) { @@ -146,11 +124,9 @@ set_ur_uv(const LTexCoord &ur_uv, const int anim, const int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_size -// Access: Public -// Description: Sets the size of each particle in world units. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of each particle in world units. + */ INLINE void SpriteParticleRenderer:: set_size(PN_stdfloat width, PN_stdfloat height) { _width = width; @@ -158,154 +134,138 @@ set_size(PN_stdfloat width, PN_stdfloat height) { init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_color(const LColor &color) { _color = color; _color_interpolation_manager->set_default_color(_color); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_x_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_x_scale_flag(bool animate_x_ratio) { _animate_x_ratio = animate_x_ratio; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_y_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_y_scale_flag(bool animate_y_ratio) { _animate_y_ratio = animate_y_ratio; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_anim_angle_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_anim_angle_flag(bool animate_theta) { _animate_theta = animate_theta; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_initial_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_initial_x_scale(PN_stdfloat initial_x_scale) { _initial_x_scale = initial_x_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_final_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_final_x_scale(PN_stdfloat final_x_scale) { _final_x_scale = final_x_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_initial_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_initial_y_scale(PN_stdfloat initial_y_scale) { _initial_y_scale = initial_y_scale; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_final_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_final_y_scale(PN_stdfloat final_y_scale) { _final_y_scale = final_y_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_nonanimated_theta -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_nonanimated_theta(PN_stdfloat theta) { _theta = theta; init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_alpha_blend_method -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_alpha_blend_method(ParticleRendererBlendMethod bm) { _blend_method = bm; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_alpha_disable -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_alpha_disable(bool ad) { _alpha_disable = ad; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_animate_frames_enable -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_animate_frames_enable(bool an) { _animate_frames = an; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_animate_frames_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_animate_frames_rate(PN_stdfloat r) { nassertv( r >= 0.0); _animate_frames_rate = r; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_animate_frames_index -// Access: Public// Purpose : Sets the frame to be used when animation is disabled. -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void SpriteParticleRenderer:: set_animate_frames_index(int i) { nassertv(i < (int)_anims[0]->get_num_frames()); _animate_frames_index = i; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_texture -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE Texture *SpriteParticleRenderer:: get_texture() const { return get_texture(0,0); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_texture -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE Texture *SpriteParticleRenderer:: get_texture(const int anim, const int frame) const { if(_anims.size() == 0) { @@ -336,23 +296,17 @@ get_last_anim() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_ll_uv -// Access: Public -// Description: Returns the UV coordinate of the lower-left corner; -// see set_ll_uv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinate of the lower-left corner; see set_ll_uv(). + */ INLINE LTexCoord SpriteParticleRenderer:: get_ll_uv() const { return get_ll_uv(0,0); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_ll_uv -// Access: Public -// Description: Returns the UV coordinate of the lower-left corner; -// see set_ll_uv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinate of the lower-left corner; see set_ll_uv(). + */ INLINE LTexCoord SpriteParticleRenderer:: get_ll_uv(const int anim, const int frame) const { int a = anim < (int)_anims.size()?anim:0; @@ -360,23 +314,17 @@ get_ll_uv(const int anim, const int frame) const { return _anims[a]->get_ll(f); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_ur_uv -// Access: Public -// Description: Returns the UV coordinate of the lower-left corner; -// see set_ur_uv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinate of the lower-left corner; see set_ur_uv(). + */ INLINE LTexCoord SpriteParticleRenderer:: get_ur_uv() const { return get_ur_uv(0,0); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_ur_uv -// Access: Public -// Description: Returns the UV coordinate of the upper-right corner; -// see set_ur_uv(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinate of the upper-right corner; see set_ur_uv(). + */ INLINE LTexCoord SpriteParticleRenderer:: get_ur_uv(const int anim, const int frame) const { int a = anim < (int)_anims.size()?anim:0; @@ -384,156 +332,137 @@ get_ur_uv(const int anim, const int frame) const { return _anims[a]->get_ur(f); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_width -// Access: Public -// Description: Returns the width of each particle in world units. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of each particle in world units. + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_width() const { return _width; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_height -// Access: Public -// Description: Returns the height of each particle in world units. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of each particle in world units. + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_height() const { return _height; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_color -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE LColor SpriteParticleRenderer:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_x_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool SpriteParticleRenderer:: get_x_scale_flag() const { return _animate_x_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_y_scale_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool SpriteParticleRenderer:: get_y_scale_flag() const { return _animate_y_ratio; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_anim_angle_flag -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool SpriteParticleRenderer:: get_anim_angle_flag() const { return _animate_theta; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_initial_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_initial_x_scale() const { return _initial_x_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_final_x_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_final_x_scale() const { return _final_x_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_initial_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_initial_y_scale() const { return _initial_y_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_final_y_scale -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_final_y_scale() const { return _final_y_scale; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_nonanimated_theta -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_nonanimated_theta() const { return _theta; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_alpha_blend_method -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseParticleRenderer::ParticleRendererBlendMethod SpriteParticleRenderer:: get_alpha_blend_method() const { return _blend_method; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_alpha_disable -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool SpriteParticleRenderer:: get_alpha_disable() const { return _alpha_disable; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_animate_frames_enable -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool SpriteParticleRenderer:: get_animate_frames_enable() const { return _animate_frames; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_animate_frames_rate -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat SpriteParticleRenderer:: get_animate_frames_rate() const { return _animate_frames_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_animate_frames_index -// Access: Public// Purpose : Gets the frame to be used when animation is disabled. -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int SpriteParticleRenderer:: get_animate_frames_index() const { return _animate_frames_index; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::get_color_interpolation_manager -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE ColorInterpolationManager* SpriteParticleRenderer:: get_color_interpolation_manager() const { return _color_interpolation_manager; diff --git a/panda/src/particlesystem/spriteParticleRenderer.cxx b/panda/src/particlesystem/spriteParticleRenderer.cxx index e0752a64e8..7c5756bc6f 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.cxx +++ b/panda/src/particlesystem/spriteParticleRenderer.cxx @@ -1,16 +1,15 @@ -// Filename: spriteParticleRenderer.cxx -// Created by: charles (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spriteParticleRenderer.cxx + * @author charles + * @date 2000-07-13 + */ #include "spriteParticleRenderer.h" #include "boundingSphere.h" @@ -33,11 +32,9 @@ PStatCollector SpriteParticleRenderer::_render_collector("App:Particles:Sprite:Render"); -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::SpriteParticleRenderer -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ SpriteParticleRenderer:: SpriteParticleRenderer(Texture *tex) : BaseParticleRenderer(PR_ALPHA_NONE), @@ -66,11 +63,9 @@ SpriteParticleRenderer(Texture *tex) : init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::SpriteParticleRenderer -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ SpriteParticleRenderer:: SpriteParticleRenderer(const SpriteParticleRenderer& copy) : BaseParticleRenderer(copy), @@ -100,42 +95,37 @@ SpriteParticleRenderer(const SpriteParticleRenderer& copy) : init_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::~SpriteParticleRenderer -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ SpriteParticleRenderer:: ~SpriteParticleRenderer() { get_render_node()->remove_all_geoms(); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::make_copy -// Access: Public -// Description: child dynamic copy -//////////////////////////////////////////////////////////////////// +/** + * child dynamic copy + */ BaseParticleRenderer *SpriteParticleRenderer:: make_copy() { return new SpriteParticleRenderer(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::extract_textures_from_node -// Access: Public -// Description: Pull either a set of textures from a SequenceNode or -// a single texture from a GeomNode. This function is called -// in both set_from_node() and add_from_node(). Notice the -// second parameter. This nodepath will reference the GeomNode -// holding the first texture in the returned TextureCollection. -//////////////////////////////////////////////////////////////////// +/** + * Pull either a set of textures from a SequenceNode or a single texture from + * a GeomNode. This function is called in both set_from_node() and + * add_from_node(). Notice the second parameter. This nodepath will + * reference the GeomNode holding the first texture in the returned + * TextureCollection. + */ int SpriteParticleRenderer:: extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col, TextureCollection &tex_col) { NodePath tex_node_path = node_path; NodePath geom_node_path; - // Look for a sequence node first, in case they want animated texture sprites + // Look for a sequence node first, in case they want animated texture + // sprites if (!tex_node_path.is_empty() && tex_node_path.node()->get_type() != SequenceNode::get_class_type()) { tex_node_path = node_path.find("**/+SequenceNode"); } @@ -143,12 +133,13 @@ extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col // Nodepath contains a sequence node, attempt to read its textures. if (!tex_node_path.is_empty()) { int frame_count = tex_node_path.get_num_children(); - // We do it this way in order to preserve the order of the textures in the sequence. - // If we use a find_all_textures() that order is lost. + // We do it this way in order to preserve the order of the textures in the + // sequence. If we use a find_all_textures() that order is lost. for (int i = 0; i < frame_count; ++i) { geom_node_path = tex_node_path.get_child(i); if (!geom_node_path.is_empty()) { - // Since this is a SequenceNode, there will be only one texture on this geom_node_path. + // Since this is a SequenceNode, there will be only one texture on + // this geom_node_path. tex_col.add_textures_from(geom_node_path.find_all_textures()); np_col.add_path(geom_node_path); } @@ -161,7 +152,8 @@ extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col } } - // If a sequence node is not found, we just want to look for a regular geom node. + // If a sequence node is not found, we just want to look for a regular geom + // node. if (geom_node_path.is_empty()) { // Find the first GeomNode. if (!node_path.is_empty() && node_path.node()->get_type() != GeomNode::get_class_type()) { @@ -187,17 +179,15 @@ extract_textures_from_node(const NodePath &node_path, NodePathCollection &np_col return 1; } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_from_node -// Access: Public -// Description: If the source type is important, use this one. -// -// model and node should lead to node_path like this: -// node_path = loader.loadModel(model).find(node) -// -// This will remove all previously add textures and -// resize the renderer to match the new geometry. -//////////////////////////////////////////////////////////////////// +/** + * If the source type is important, use this one. + * + * model and node should lead to node_path like this: node_path = + * loader.loadModel(model).find(node) + * + * This will remove all previously add textures and resize the renderer to + * match the new geometry. + */ void SpriteParticleRenderer:: set_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels) { // Clear all texture information @@ -205,38 +195,30 @@ set_from_node(const NodePath &node_path, const string &model, const string &node add_from_node(node_path,model,node,size_from_texels,true); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::set_from_node -// Access: Public -// Description: Sets the properties on this renderer from the geometry -// referenced by the indicated NodePath. This should be -// a reference to a GeomNode or a SequenceNode; it -// extracts out the texture and UV range from the node. -// -// This will remove all previously added textures and -// animations. It will also resize the renderer to match -// this new geometry. -// -// If node_path refers to a GeomNode(or has one beneath it) -// the texture, its size, and UV data will be extracted -// from that. -// -// If node_path references a SequenceNode(or has one -// beneath it) with multiple GeomNodes beneath it, -// the size data will correspond only to the first -// GeomNode found with a valid texture, while the texture -// and UV information will be stored for each individual -// node. -// -// If size_from_texels is true, the particle size is -// based on the number of texels in the source image; -// otherwise, it is based on the size of the first -// polygon found in the node. -// -// model and node are the two items used to construct -// node_path. If the source type is important, use -// set_from_node(NodePath,string,string,bool) instead. -//////////////////////////////////////////////////////////////////// +/** + * Sets the properties on this renderer from the geometry referenced by the + * indicated NodePath. This should be a reference to a GeomNode or a + * SequenceNode; it extracts out the texture and UV range from the node. + * + * This will remove all previously added textures and animations. It will + * also resize the renderer to match this new geometry. + * + * If node_path refers to a GeomNode(or has one beneath it) the texture, its + * size, and UV data will be extracted from that. + * + * If node_path references a SequenceNode(or has one beneath it) with multiple + * GeomNodes beneath it, the size data will correspond only to the first + * GeomNode found with a valid texture, while the texture and UV information + * will be stored for each individual node. + * + * If size_from_texels is true, the particle size is based on the number of + * texels in the source image; otherwise, it is based on the size of the first + * polygon found in the node. + * + * model and node are the two items used to construct node_path. If the + * source type is important, use set_from_node(NodePath,string,string,bool) + * instead. + */ void SpriteParticleRenderer:: set_from_node(const NodePath &node_path, bool size_from_texels) { nassertv(!node_path.is_empty()); @@ -245,23 +227,19 @@ set_from_node(const NodePath &node_path, bool size_from_texels) { add_from_node(node_path,size_from_texels,true); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::add_from_node -// Access: Public -// Description: This will allow the renderer to randomly choose -// from more than one texture or sequence at particle -// birth. -// -// If the source type is important, use this one. -// -// model and node should lead to node_path like this: -// node_path = loader.loadModel(model).find(node) -// -// If resize is true, or if there are no textures -// currently on the renderer, it will force the -// renderer to use the size information from this -// node from now on. (Default is false) -//////////////////////////////////////////////////////////////////// +/** + * This will allow the renderer to randomly choose from more than one texture + * or sequence at particle birth. + * + * If the source type is important, use this one. + * + * model and node should lead to node_path like this: node_path = + * loader.loadModel(model).find(node) + * + * If resize is true, or if there are no textures currently on the renderer, + * it will force the renderer to use the size information from this node from + * now on. (Default is false) + */ void SpriteParticleRenderer:: add_from_node(const NodePath &node_path, const string &model, const string &node, bool size_from_texels, bool resize) { int anim_count = _anims.size(); @@ -273,18 +251,14 @@ add_from_node(const NodePath &node_path, const string &model, const string &node } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::add_from_node -// Access: Public -// Description: This will allow the renderer to randomly choose -// from more than one texture or sequence at particle -// birth. -// -// If resize is true, or if there are no textures -// currently on the renderer, it will force the -// renderer to use the size information from this -// node from now on. (Default is false) -//////////////////////////////////////////////////////////////////// +/** + * This will allow the renderer to randomly choose from more than one texture + * or sequence at particle birth. + * + * If resize is true, or if there are no textures currently on the renderer, + * it will force the renderer to use the size information from this node from + * now on. (Default is false) + */ void SpriteParticleRenderer:: add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { nassertv(!node_path.is_empty()); @@ -340,9 +314,9 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { } if (got_texcoord) { - // We don't really pay attention to orientation of UV's here; a - // minor flaw. We assume the minimum is in the lower-left, and - // the maximum is in the upper-right. + // We don't really pay attention to orientation of UV's here; a minor + // flaw. We assume the minimum is in the lower-left, and the maximum + // is in the upper-right. ll.push_back(min_uv); ur.push_back(max_uv); } @@ -396,8 +370,8 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { PN_stdfloat y_texels = _anims[0]->get_frame(0)->get_y_size() * fabs(_anims[0]->get_ur(0)[1] - _anims[0]->get_ll(0)[1]); set_size(y_texels * width / height, y_texels); } else { - // If size_from_texels is false, we get the particle size from - // the size of the polygon. + // If size_from_texels is false, we get the particle size from the + // size of the polygon. set_size(width, height); } @@ -410,11 +384,9 @@ add_from_node(const NodePath &node_path, bool size_from_texels, bool resize) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::resize_pool -// Access: Private -// Description: reallocate the vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * reallocate the vertex pool. + */ void SpriteParticleRenderer:: resize_pool(int new_size) { if (new_size != _pool_size) { @@ -423,13 +395,10 @@ resize_pool(int new_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::init_geoms -// Access: Public -// Description: initializes everything, called on traumatic events -// such as construction and serious particlesystem -// modifications -//////////////////////////////////////////////////////////////////// +/** + * initializes everything, called on traumatic events such as construction and + * serious particlesystem modifications + */ void SpriteParticleRenderer:: init_geoms() { CPT(RenderState) state = _render_state; @@ -505,7 +474,8 @@ init_geoms() { _sprites[i].push_back(new GeomPoints(Geom::UH_stream)); geom->add_primitive(_sprites[i][j]); - // This will be overwritten in render(), but we had to have some initial value + // This will be overwritten in render(), but we had to have some initial + // value _sprite_writer[i].push_back(SpriteWriter()); state = state->add_attrib(RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _base_y_scale * _height, true)); @@ -513,8 +483,8 @@ init_geoms() { state = state->add_attrib(TextureAttrib::make(anim->get_frame(j))); state = state->add_attrib(TexGenAttrib::make(TextureStage::get_default(), TexGenAttrib::M_point_sprite)); - // Build a transform to convert the texture coordinates to the - // ll, ur space. + // Build a transform to convert the texture coordinates to the ll, ur + // space. LPoint2 ul(anim->get_ll(j)[0], anim->get_ur(j)[1]); LPoint2 lr(anim->get_ur(j)[0], anim->get_ll(j)[1]); LVector2 sc = lr - ul; @@ -530,32 +500,25 @@ init_geoms() { nassertv(render_node->check_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::birth_particle -// Access: Private -// Description: child birth, one of those 'there-if-we-want-it' -// things. not really too useful here, so it turns -// out we don't really want it. -//////////////////////////////////////////////////////////////////// +/** + * child birth, one of those 'there-if-we-want-it' things. not really too + * useful here, so it turns out we don't really want it. + */ void SpriteParticleRenderer:: birth_particle(int index) { _birth_list.push_back(index); } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::kill_particle -// Access: Private -// Description: child death -//////////////////////////////////////////////////////////////////// +/** + * child death + */ void SpriteParticleRenderer:: kill_particle(int) { } -//////////////////////////////////////////////////////////////////// -// Function: SpriteParticleRenderer::render -// Access: Private -// Description: big child render. populates the geom node. -//////////////////////////////////////////////////////////////////// +/** + * big child render. populates the geom node. + */ void SpriteParticleRenderer:: render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { PStatTimer t1(_render_collector); @@ -569,21 +532,26 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { int i,j; // loop counters int anim_count = _anims.size(); // number of animations int frame; // frame index, used in indicating which frame to use when not animated - // First, since this is the only time we have access to the actual particles, do some delayed initialization. + // First, since this is the only time we have access to the actual + // particles, do some delayed initialization. if (_animate_frames || anim_count) { if (!_birth_list.empty()) { for (vector_int::iterator vIter = _birth_list.begin(); vIter != _birth_list.end(); ++vIter) { cur_particle = (BaseParticle*)po_vector[*vIter].p(); i = int(NORMALIZED_RAND()*anim_count); - // If there are multiple animations to choose from, choose one at random for this new particle + // If there are multiple animations to choose from, choose one at + // random for this new particle cur_particle->set_index(i < anim_count?i:i-1); - // This is an experimental age offset so that the animations don't appear synchronized. - // If we are using animations, try to vary the frame flipping a bit for particles in the same litter. - // A similar effect might be a achieved by using a small lifespan spread value on the factory. + // This is an experimental age offset so that the animations don't + // appear synchronized. If we are using animations, try to vary the + // frame flipping a bit for particles in the same litter. A similar + // effect might be a achieved by using a small lifespan spread value + // on the factory. - // Perhaps we should look into other methods. The age offset doesn't seem to be cutting it. + // Perhaps we should look into other methods. The age offset doesn't + // seem to be cutting it. if (_animate_frames) { cur_particle->set_age(cur_particle->get_age()+i/10.0*cur_particle->get_lifespan()); } @@ -592,9 +560,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { } _birth_list.clear(); - // Create vertex writers for each of the possible geoms. - // Could possibly be changed to only create writers for geoms that would be used - // according to the animation configuration. + // Create vertex writers for each of the possible geoms. Could possibly be + // changed to only create writers for geoms that would be used according to + // the animation configuration. for (i = 0; i < anim_count; ++i) { for (j = 0; j < _anim_size[i]; ++j) { // Set the particle per frame counts to 0. @@ -643,8 +611,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { PN_stdfloat t = cur_particle->get_parameterized_age(); int anim_index = cur_particle->get_index(); - // If an animation has been removed, we need to reassign - // those particles assigned to the removed animation. + // If an animation has been removed, we need to reassign those particles + // assigned to the removed animation. if(_animation_removed && (anim_index >= anim_count)) { anim_index = int(NORMALIZED_RAND()*anim_count); anim_index = anim_index& po_vector, int ttl_particles) { frame = (frame < _anim_size[anim_index]) ? frame : (_anim_size[anim_index]-1); ++_ttl_count[anim_index][frame]; - // Calculate the color - // This is where we'll want to give the renderer the new color + // Calculate the color This is where we'll want to give the renderer the + // new color LColor c = _color_interpolation_manager->generateColor(t); int alphamode=get_alpha_mode(); @@ -733,9 +701,8 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { _sprites[i][j]->clear_vertices(); _sprite_writer[i][j].clear(); - // We have to reassign the GeomVertexData and GeomPrimitive to - // the Geom, and the Geom to the GeomNode, in case it got - // flattened away. + // We have to reassign the GeomVertexData and GeomPrimitive to the Geom, + // and the Geom to the GeomNode, in case it got flattened away. _sprite_primitive[i][j]->set_primitive(0, _sprites[i][j]); _sprite_primitive[i][j]->set_vertex_data(_vdata[i][j]); @@ -773,12 +740,9 @@ render(pvector< PT(PhysicsObject) >& po_vector, int ttl_particles) { _animation_removed = false; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SpriteParticleRenderer:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -786,16 +750,14 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void SpriteParticleRenderer:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "SpriteParticleRenderer:\n"; - // indent(out, indent_level + 2) << "_sprite_primitive "<<_sprite_primitive<<"\n"; + // indent(out, indent_level + 2) << "_sprite_primitive + // "<<_sprite_primitive<<"\n"; indent(out, indent_level + 2) << "_color "<<_color<<"\n"; indent(out, indent_level + 2) << "_initial_x_scale "<<_initial_x_scale<<"\n"; indent(out, indent_level + 2) << "_final_x_scale "<<_final_x_scale<<"\n"; diff --git a/panda/src/particlesystem/spriteParticleRenderer.h b/panda/src/particlesystem/spriteParticleRenderer.h index 7c954bc06e..e3f9ccc5d7 100644 --- a/panda/src/particlesystem/spriteParticleRenderer.h +++ b/panda/src/particlesystem/spriteParticleRenderer.h @@ -1,16 +1,15 @@ -// Filename: spriteParticleRenderer.h -// Created by: charles (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spriteParticleRenderer.h + * @author charles + * @date 2000-07-13 + */ #ifndef SPRITEPARTICLERENDERER_H #define SPRITEPARTICLERENDERER_H @@ -33,13 +32,11 @@ class NodePath; -//////////////////////////////////////////////////////////////////// -// Class : SpriteWriter -// Description : Helper class used by SpriteParticleRenderer to -// keep track of the various GeomVertexWriters -// associated with each geom created in -// SpriteParticleRenderer::init_geoms(). -//////////////////////////////////////////////////////////////////// +/** + * Helper class used by SpriteParticleRenderer to keep track of the various + * GeomVertexWriters associated with each geom created in + * SpriteParticleRenderer::init_geoms(). + */ class SpriteWriter { public: SpriteWriter() { @@ -67,12 +64,10 @@ public: GeomVertexWriter aspect_ratio; }; -//////////////////////////////////////////////////////////////////// -// Class : SpriteAnim -// Description : Helper class used by SpriteParticleRenderer to -// keep track of its textures and their respective UVs -// and source types. -//////////////////////////////////////////////////////////////////// +/** + * Helper class used by SpriteParticleRenderer to keep track of its textures + * and their respective UVs and source types. + */ class SpriteAnim : public ReferenceCount{ PUBLISHED: enum SourceType { @@ -125,7 +120,7 @@ public: textures.push_back(t.get_texture(i)); } }; - + void set_ll(const int n, LTexCoord c) { ll[n] = c; } @@ -153,11 +148,9 @@ private: string _source_tex,_source_model,_source_node; }; -//////////////////////////////////////////////////////////////////// -// Class : SpriteParticleRenderer -// Description : Renders a particle system with high-speed nasty -// trick sprites. -//////////////////////////////////////////////////////////////////// +/** + * Renders a particle system with high-speed nasty trick sprites. + */ class EXPCL_PANDAPHYSICS SpriteParticleRenderer : public BaseParticleRenderer { PUBLISHED: SpriteParticleRenderer(Texture *tex = (Texture *) NULL); @@ -186,7 +179,7 @@ PUBLISHED: INLINE void set_y_scale_flag(bool animate_y_ratio); INLINE void set_anim_angle_flag(bool animate_theta); INLINE void set_initial_x_scale(PN_stdfloat initial_x_scale); - INLINE void set_final_x_scale(PN_stdfloat final_x_scale); + INLINE void set_final_x_scale(PN_stdfloat final_x_scale); INLINE void set_initial_y_scale(PN_stdfloat initial_y_scale); INLINE void set_final_y_scale(PN_stdfloat final_y_scale); INLINE void set_nonanimated_theta(PN_stdfloat theta); @@ -219,8 +212,8 @@ PUBLISHED: INLINE PN_stdfloat get_final_y_scale() const; INLINE PN_stdfloat get_nonanimated_theta() const; INLINE ParticleRendererBlendMethod get_alpha_blend_method() const; - INLINE bool get_alpha_disable() const; - INLINE bool get_animate_frames_enable() const; + INLINE bool get_alpha_disable() const; + INLINE bool get_animate_frames_enable() const; INLINE PN_stdfloat get_animate_frames_rate() const; INLINE int get_animate_frames_index() const; diff --git a/panda/src/particlesystem/tangentRingEmitter.I b/panda/src/particlesystem/tangentRingEmitter.I index 9c829c55da..f89c2f42e8 100644 --- a/panda/src/particlesystem/tangentRingEmitter.I +++ b/panda/src/particlesystem/tangentRingEmitter.I @@ -1,48 +1,43 @@ -// Filename: tangentRingEmitter.I -// Created by: charles (25Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tangentRingEmitter.I + * @author charles + * @date 2000-07-25 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void TangentRingEmitter:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: set_radius_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void TangentRingEmitter:: set_radius_spread(PN_stdfloat spread) { _radius_spread = spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat TangentRingEmitter:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat TangentRingEmitter:: get_radius_spread() const { return _radius_spread; diff --git a/panda/src/particlesystem/tangentRingEmitter.cxx b/panda/src/particlesystem/tangentRingEmitter.cxx index 359f5fa5f2..5c77c5491e 100644 --- a/panda/src/particlesystem/tangentRingEmitter.cxx +++ b/panda/src/particlesystem/tangentRingEmitter.cxx @@ -1,35 +1,30 @@ -// Filename: tangentRingEmitter.cxx -// Created by: charles (25Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tangentRingEmitter.cxx + * @author charles + * @date 2000-07-25 + */ #include "tangentRingEmitter.h" -//////////////////////////////////////////////////////////////////// -// Function: tangentRingEmitter -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ TangentRingEmitter:: TangentRingEmitter() { _radius = 1.0f; _radius_spread = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: tangentRingEmitter -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ TangentRingEmitter:: TangentRingEmitter(const TangentRingEmitter ©) : BaseParticleEmitter(copy) { @@ -37,30 +32,24 @@ TangentRingEmitter(const TangentRingEmitter ©) : _radius_spread = copy._radius_spread; } -//////////////////////////////////////////////////////////////////// -// Function: ~tangentringemitter -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ TangentRingEmitter:: ~TangentRingEmitter() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: child copier -//////////////////////////////////////////////////////////////////// +/** + * child copier + */ BaseParticleEmitter *TangentRingEmitter:: make_copy() { return new TangentRingEmitter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: TangentRingEmitter::assign_initial_position -// Access: Public -// Description: Generates a location for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a location for a new particle + */ void TangentRingEmitter:: assign_initial_position(LPoint3& pos) { PN_stdfloat theta = NORMALIZED_RAND() * 2.0f * MathNumbers::pi_f; @@ -72,22 +61,17 @@ assign_initial_position(LPoint3& pos) { pos.set(new_radius * _x, new_radius * _y, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TangentRingEmitter::assign_initial_velocity -// Access: Public -// Description: Generates a velocity for a new particle -//////////////////////////////////////////////////////////////////// +/** + * Generates a velocity for a new particle + */ void TangentRingEmitter:: assign_initial_velocity(LVector3& vel) { vel.set(-_y, _x, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void TangentRingEmitter:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -95,12 +79,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void TangentRingEmitter:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/tangentRingEmitter.h b/panda/src/particlesystem/tangentRingEmitter.h index 90110c0c03..0bea13ee17 100644 --- a/panda/src/particlesystem/tangentRingEmitter.h +++ b/panda/src/particlesystem/tangentRingEmitter.h @@ -1,28 +1,25 @@ -// Filename: tangentRingEmitter.h -// Created by: charles (25Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tangentRingEmitter.h + * @author charles + * @date 2000-07-25 + */ #ifndef TANGENTRINGEMITTER_H #define TANGENTRINGEMITTER_H #include "baseParticleEmitter.h" -//////////////////////////////////////////////////////////////////// -// Class : TangentRingEmitter -// Description : Describes a planar ring region in which -// tangent particles are generated, and particles -// fly off tangential to the ring. -//////////////////////////////////////////////////////////////////// +/** + * Describes a planar ring region in which tangent particles are generated, + * and particles fly off tangential to the ring. + */ class EXPCL_PANDAPHYSICS TangentRingEmitter : public BaseParticleEmitter { PUBLISHED: TangentRingEmitter(); @@ -44,8 +41,7 @@ private: PN_stdfloat _radius; PN_stdfloat _radius_spread; - // CUSTOM EMISSION PARAMETERS - // none + // CUSTOM EMISSION PARAMETERS none // scratch variables that carry over from position calc to velocity calc PN_stdfloat _x; diff --git a/panda/src/particlesystem/zSpinParticle.I b/panda/src/particlesystem/zSpinParticle.I index 9ffd006e9c..77791881d2 100644 --- a/panda/src/particlesystem/zSpinParticle.I +++ b/panda/src/particlesystem/zSpinParticle.I @@ -1,48 +1,43 @@ -// Filename: zSpinParticle.I -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticle.I + * @author charles + * @date 2000-08-16 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_initial_angle -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE void ZSpinParticle:: set_initial_angle(PN_stdfloat t) { _initial_angle = t; } -//////////////////////////////////////////////////////////////////// -// Function: get_initial_angle -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE PN_stdfloat ZSpinParticle:: get_initial_angle() const { return _initial_angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_final_angle -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE void ZSpinParticle:: set_final_angle(PN_stdfloat t) { _final_angle = t; } -//////////////////////////////////////////////////////////////////// -// Function: get_final_angle -// Description: accessor -//////////////////////////////////////////////////////////////////// +/** + * accessor + */ INLINE PN_stdfloat ZSpinParticle:: get_final_angle() const { return _final_angle; @@ -67,5 +62,3 @@ INLINE bool ZSpinParticle:: get_angular_velocity_enabled() const { return _bUseAngularVelocity; } - - diff --git a/panda/src/particlesystem/zSpinParticle.cxx b/panda/src/particlesystem/zSpinParticle.cxx index bf552d5560..560fa12a72 100644 --- a/panda/src/particlesystem/zSpinParticle.cxx +++ b/panda/src/particlesystem/zSpinParticle.cxx @@ -1,25 +1,22 @@ -// Filename: zSpinParticle.cxx -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticle.cxx + * @author charles + * @date 2000-08-16 + */ #include "zSpinParticle.h" #include "cmath.h" -//////////////////////////////////////////////////////////////////// -// Function: ZSpinParticle -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ZSpinParticle:: ZSpinParticle() : BaseParticle() { @@ -30,11 +27,9 @@ ZSpinParticle() : _bUseAngularVelocity = false; } -//////////////////////////////////////////////////////////////////// -// Function: ZSpinParticle -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ZSpinParticle:: ZSpinParticle(const ZSpinParticle ©) : BaseParticle(copy) { @@ -45,43 +40,36 @@ ZSpinParticle(const ZSpinParticle ©) : _bUseAngularVelocity = copy._bUseAngularVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: ~ZSpinParticle -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ZSpinParticle:: ~ZSpinParticle() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: dynamic copier -//////////////////////////////////////////////////////////////////// +/** + * dynamic copier + */ PhysicsObject *ZSpinParticle:: make_copy() const { return new ZSpinParticle(*this); } -//////////////////////////////////////////////////////////////////// -// Function: init -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZSpinParticle:: init() { } -//////////////////////////////////////////////////////////////////// -// Function: update -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZSpinParticle:: update() { - // if using final_angle, want age to range from [0,1] over lifespan, so use parameterized_age - // for angular velocity, should be allowed to range freely upward, use regular age + // if using final_angle, want age to range from [0,1] over lifespan, so use + // parameterized_age for angular velocity, should be allowed to range freely + // upward, use regular age if(_bUseAngularVelocity) { // interpolate the current orientation @@ -93,39 +81,32 @@ update() { // normalize the result to [0..360) _cur_angle = cmod(_cur_angle, (PN_stdfloat)360.0); - // if _cur_angle was negative, it is still negative after cmod, - // wrap it around by adding 360 + // if _cur_angle was negative, it is still negative after cmod, wrap it + // around by adding 360 - // is this really necessary? should be in range of sin/cos + // is this really necessary? should be in range of sincos if(_cur_angle < 0.0f) _cur_angle += 360.0f; } -//////////////////////////////////////////////////////////////////// -// Function: die -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ZSpinParticle:: die() { } -//////////////////////////////////////////////////////////////////// -// Function: get_theta -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat ZSpinParticle:: get_theta() const { return _cur_angle; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ZSpinParticle:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -133,12 +114,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ZSpinParticle:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/zSpinParticle.h b/panda/src/particlesystem/zSpinParticle.h index 521df2ee7d..302aedc5d9 100644 --- a/panda/src/particlesystem/zSpinParticle.h +++ b/panda/src/particlesystem/zSpinParticle.h @@ -1,30 +1,27 @@ -// Filename: zSpinParticle.h -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticle.h + * @author charles + * @date 2000-08-16 + */ #ifndef ZSPINPARTICLE_H #define ZSPINPARTICLE_H #include "baseParticle.h" -//////////////////////////////////////////////////////////////////// -// Class : ZSpinParticle -// Description : describes a particle that spins along its z axis. -// this is kind of an intermediary class- if you're -// using a SpriteParticleRenderer and you want your -// sprites to spin without having them be full-blown -// oriented (i.e. angry quat math), use this. -//////////////////////////////////////////////////////////////////// +/** + * describes a particle that spins along its z axis. this is kind of an + * intermediary class- if you're using a SpriteParticleRenderer and you want + * your sprites to spin without having them be full-blown oriented (i.e. + * angry quat math), use this. + */ class EXPCL_PANDAPHYSICS ZSpinParticle : public BaseParticle { public: ZSpinParticle(); @@ -45,8 +42,8 @@ public: INLINE void set_final_angle(PN_stdfloat t); INLINE PN_stdfloat get_final_angle() const; - // 'set_final_angle' and 'angular_velocity' are mutually exclusive apis - // if angular-velocity is specified, final_angle is ignored + // 'set_final_angle' and 'angular_velocity' are mutually exclusive apis if + // angular-velocity is specified, final_angle is ignored INLINE void set_angular_velocity(PN_stdfloat v); INLINE PN_stdfloat get_angular_velocity() const; diff --git a/panda/src/particlesystem/zSpinParticleFactory.I b/panda/src/particlesystem/zSpinParticleFactory.I index f11a4c7882..ec75fb5f30 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.I +++ b/panda/src/particlesystem/zSpinParticleFactory.I @@ -1,94 +1,83 @@ -// Filename: zSpinParticleFactory.I -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticleFactory.I + * @author charles + * @date 2000-08-16 + */ +/** -//////////////////////////////////////////////////////////////////// -// Function: set_initial_angle -// Access: Public -//////////////////////////////////////////////////////////////////// + */ INLINE void ZSpinParticleFactory:: set_initial_angle(PN_stdfloat angle) { _initial_angle = angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_final_angle -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ZSpinParticleFactory:: set_final_angle(PN_stdfloat angle) { _final_angle = angle; } -//////////////////////////////////////////////////////////////////// -// Function: set_initial_angle_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ZSpinParticleFactory:: set_initial_angle_spread(PN_stdfloat spread) { _initial_angle_spread = spread; } -//////////////////////////////////////////////////////////////////// -// Function: set_final_angle_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ZSpinParticleFactory:: set_final_angle_spread(PN_stdfloat spread) { _final_angle_spread = spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_initial_angle -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ZSpinParticleFactory:: get_initial_angle() const { return _initial_angle; } -//////////////////////////////////////////////////////////////////// -// Function: get_final_angle -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ZSpinParticleFactory:: get_final_angle() const { return _final_angle; } -//////////////////////////////////////////////////////////////////// -// Function: get_initial_angle_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ZSpinParticleFactory:: get_initial_angle_spread() const { return _initial_angle_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_final_angle_spread -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ZSpinParticleFactory:: get_final_angle_spread() const { return _final_angle_spread; } -//////////////////////////////////////////////////////////////////// -// Function: get_angular_velocity -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat ZSpinParticleFactory:: get_angular_velocity() const { return _angular_velocity; @@ -119,4 +108,3 @@ INLINE bool ZSpinParticleFactory:: get_angular_velocity_enabled() const { return _bUseAngularVelocity; } - diff --git a/panda/src/particlesystem/zSpinParticleFactory.cxx b/panda/src/particlesystem/zSpinParticleFactory.cxx index 86a4c915bb..f8c21efccb 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.cxx +++ b/panda/src/particlesystem/zSpinParticleFactory.cxx @@ -1,25 +1,22 @@ -// Filename: zSpinParticleFactory.cxx -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticleFactory.cxx + * @author charles + * @date 2000-08-16 + */ #include "zSpinParticleFactory.h" #include "zSpinParticle.h" -//////////////////////////////////////////////////////////////////// -// Function: ZSpinParticleFactory -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ ZSpinParticleFactory:: ZSpinParticleFactory() : BaseParticleFactory() { @@ -32,11 +29,9 @@ ZSpinParticleFactory() : _bUseAngularVelocity = false; } -//////////////////////////////////////////////////////////////////// -// Function: ZSpinParticleFactory -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ZSpinParticleFactory:: ZSpinParticleFactory(const ZSpinParticleFactory ©) : BaseParticleFactory(copy) { @@ -49,30 +44,24 @@ ZSpinParticleFactory(const ZSpinParticleFactory ©) : _bUseAngularVelocity = copy._bUseAngularVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: ~ZSpinParticleFactory -// Access: Virtual, Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ZSpinParticleFactory:: ~ZSpinParticleFactory() { } -//////////////////////////////////////////////////////////////////// -// Function: alloc_particle -// Access: Private, Virtual -// Description: factory method -//////////////////////////////////////////////////////////////////// +/** + * factory method + */ BaseParticle *ZSpinParticleFactory:: alloc_particle() const { return new ZSpinParticle; } -//////////////////////////////////////////////////////////////////// -// Function: populate_child_particle -// Access: Private, Virtual -// Description: factory populator -//////////////////////////////////////////////////////////////////// +/** + * factory populator + */ void ZSpinParticleFactory:: populate_child_particle(BaseParticle *bp) const { ZSpinParticle *zsp = (ZSpinParticle *) bp; @@ -83,12 +72,9 @@ populate_child_particle(BaseParticle *bp) const { zsp->enable_angular_velocity(_bUseAngularVelocity); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ZSpinParticleFactory:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -96,12 +82,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ZSpinParticleFactory:: write(ostream &out, int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/particlesystem/zSpinParticleFactory.h b/panda/src/particlesystem/zSpinParticleFactory.h index 215297c0dd..ca6aa5b8d8 100644 --- a/panda/src/particlesystem/zSpinParticleFactory.h +++ b/panda/src/particlesystem/zSpinParticleFactory.h @@ -1,26 +1,24 @@ -// Filename: zSpinParticleFactory.h -// Created by: charles (16Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file zSpinParticleFactory.h + * @author charles + * @date 2000-08-16 + */ #ifndef ZSPINPARTICLEFACTORY_H #define ZSPINPARTICLEFACTORY_H #include "baseParticleFactory.h" -//////////////////////////////////////////////////////////////////// -// Class : ZSpinParticleFactory -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSICS ZSpinParticleFactory : public BaseParticleFactory { PUBLISHED: ZSpinParticleFactory(); diff --git a/panda/src/pgraph/accumulatedAttribs.I b/panda/src/pgraph/accumulatedAttribs.I index cb73d9ace5..79465c4a45 100644 --- a/panda/src/pgraph/accumulatedAttribs.I +++ b/panda/src/pgraph/accumulatedAttribs.I @@ -1,14 +1,12 @@ -// Filename: accumulatedAttribs.I -// Created by: drose (30Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file accumulatedAttribs.I + * @author drose + * @date 2003-01-30 + */ diff --git a/panda/src/pgraph/accumulatedAttribs.cxx b/panda/src/pgraph/accumulatedAttribs.cxx index 31ad390c88..ea35b495ab 100644 --- a/panda/src/pgraph/accumulatedAttribs.cxx +++ b/panda/src/pgraph/accumulatedAttribs.cxx @@ -1,16 +1,15 @@ -// Filename: accumulatedAttribs.cxx -// Created by: drose (30Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file accumulatedAttribs.cxx + * @author drose + * @date 2003-01-30 + */ #include "accumulatedAttribs.h" #include "sceneGraphReducer.h" @@ -24,11 +23,9 @@ #include "config_pgraph.h" -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AccumulatedAttribs:: AccumulatedAttribs() { _transform = TransformState::make_identity(); @@ -41,11 +38,9 @@ AccumulatedAttribs() { _other = RenderState::make_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AccumulatedAttribs:: AccumulatedAttribs(const AccumulatedAttribs ©) : _transform(copy._transform), @@ -65,11 +60,9 @@ AccumulatedAttribs(const AccumulatedAttribs ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AccumulatedAttribs:: operator = (const AccumulatedAttribs ©) { _transform = copy._transform; @@ -88,11 +81,9 @@ operator = (const AccumulatedAttribs ©) { _other = copy._other; } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AccumulatedAttribs:: write(ostream &out, int attrib_types, int indent_level) const { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { @@ -138,13 +129,10 @@ write(ostream &out, int attrib_types, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::collect -// Access: Public -// Description: Collects the state and transform from the indicated -// node and adds it to the accumulator, removing it from -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Collects the state and transform from the indicated node and adds it to the + * accumulator, removing it from the node. + */ void AccumulatedAttribs:: collect(PandaNode *node, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { @@ -159,23 +147,20 @@ collect(PandaNode *node, int attrib_types) { node->set_state(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::collect -// Access: Public -// Description: Collects the state and transform from the indicated -// node and adds it to the accumulator, removing it from -// the state (and returning a new state). -//////////////////////////////////////////////////////////////////// +/** + * Collects the state and transform from the indicated node and adds it to the + * accumulator, removing it from the state (and returning a new state). + */ CPT(RenderState) AccumulatedAttribs:: collect(const RenderState *state, int attrib_types) { CPT(RenderState) new_state = state; if ((attrib_types & SceneGraphReducer::TT_color) != 0) { - const RenderAttrib *node_attrib = + const RenderAttrib *node_attrib = new_state->get_attrib(ColorAttrib::get_class_slot()); if (node_attrib != (const RenderAttrib *)NULL) { int color_override = new_state->get_override(ColorAttrib::get_class_slot()); - if (color_override >= _color_override || + if (color_override >= _color_override || _color == (const RenderAttrib *)NULL) { // The node has a color attribute; apply it. if (_color == (const RenderAttrib *)NULL) { @@ -190,7 +175,7 @@ collect(const RenderState *state, int attrib_types) { } if ((attrib_types & SceneGraphReducer::TT_color_scale) != 0) { - const RenderAttrib *node_attrib = + const RenderAttrib *node_attrib = new_state->get_attrib(ColorScaleAttrib::get_class_slot()); if (node_attrib != (const RenderAttrib *)NULL) { int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_slot()); @@ -208,7 +193,7 @@ collect(const RenderState *state, int attrib_types) { } if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { - const RenderAttrib *node_attrib = + const RenderAttrib *node_attrib = new_state->get_attrib(TexMatrixAttrib::get_class_slot()); if (node_attrib != (const RenderAttrib *)NULL) { int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_slot()); @@ -224,13 +209,13 @@ collect(const RenderState *state, int attrib_types) { new_state = new_state->remove_attrib(TexMatrixAttrib::get_class_slot()); } - // We also need to accumulate the texture state if we are - // accumulating texture matrix. - const RenderAttrib *tex_attrib = + // We also need to accumulate the texture state if we are accumulating + // texture matrix. + const RenderAttrib *tex_attrib = new_state->get_attrib(TextureAttrib::get_class_slot()); if (tex_attrib != (const RenderAttrib *)NULL) { int texture_override = new_state->get_override(TextureAttrib::get_class_slot()); - if (texture_override >= _texture_override || + if (texture_override >= _texture_override || _texture == (const RenderAttrib *)NULL) { if (_texture == (const RenderAttrib *)NULL) { _texture = tex_attrib; @@ -240,18 +225,18 @@ collect(const RenderState *state, int attrib_types) { _texture_override = texture_override; } - // However, we don't remove the texture state from the node. - // We're just accumulating it so we can tell which texture - // coordinates are safe to flatten. + // However, we don't remove the texture state from the node. We're just + // accumulating it so we can tell which texture coordinates are safe to + // flatten. } } if ((attrib_types & SceneGraphReducer::TT_clip_plane) != 0) { - const RenderAttrib *node_attrib = + const RenderAttrib *node_attrib = new_state->get_attrib(ClipPlaneAttrib::get_class_slot()); if (node_attrib != (const RenderAttrib *)NULL) { int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_slot()); - if (clip_plane_override >= _clip_plane_override || + if (clip_plane_override >= _clip_plane_override || _clip_plane == (const RenderAttrib *)NULL) { if (_clip_plane == (const RenderAttrib *)NULL) { _clip_plane = node_attrib; @@ -265,7 +250,7 @@ collect(const RenderState *state, int attrib_types) { } if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { - const RenderAttrib *node_attrib = + const RenderAttrib *node_attrib = new_state->get_attrib(CullFaceAttrib::get_class_slot()); if (node_attrib != (const RenderAttrib *)NULL) { int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_slot()); @@ -292,15 +277,11 @@ collect(const RenderState *state, int attrib_types) { return new_state; } -//////////////////////////////////////////////////////////////////// -// Function: AccumulatedAttribs::apply_to_node -// Access: Public -// Description: Stores the indicated attributes in the node's -// transform and state information; does not attempt to -// apply the properties to the vertices. Clears the -// attributes from the accumulator for future -// traversals. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated attributes in the node's transform and state + * information; does not attempt to apply the properties to the vertices. + * Clears the attributes from the accumulator for future traversals. + */ void AccumulatedAttribs:: apply_to_node(PandaNode *node, int attrib_types) { if ((attrib_types & SceneGraphReducer::TT_transform) != 0) { diff --git a/panda/src/pgraph/accumulatedAttribs.h b/panda/src/pgraph/accumulatedAttribs.h index 50e1a6d5e0..d71da61111 100644 --- a/panda/src/pgraph/accumulatedAttribs.h +++ b/panda/src/pgraph/accumulatedAttribs.h @@ -1,16 +1,15 @@ -// Filename: accumulatedAttribs.h -// Created by: drose (30Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file accumulatedAttribs.h + * @author drose + * @date 2003-01-30 + */ #ifndef ACCUMULATEDATTRIBS_H #define ACCUMULATEDATTRIBS_H @@ -23,21 +22,19 @@ class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : AccumulatedAttribs -// Description : This class is used by the SceneGraphReducer to -// maintain and accumulate the set of attributes we have -// encountered on each node that might eventually be -// applied to the vertices at the leaves. -//////////////////////////////////////////////////////////////////// +/** + * This class is used by the SceneGraphReducer to maintain and accumulate the + * set of attributes we have encountered on each node that might eventually be + * applied to the vertices at the leaves. + */ class EXPCL_PANDA_PGRAPH AccumulatedAttribs { public: AccumulatedAttribs(); AccumulatedAttribs(const AccumulatedAttribs ©); void operator = (const AccumulatedAttribs ©); - + void write(ostream &out, int attrib_types, int indent_level) const; - + void collect(PandaNode *node, int attrib_types); CPT(RenderState) collect(const RenderState *state, int attrib_types); void apply_to_node(PandaNode *node, int attrib_types); @@ -61,5 +58,3 @@ public: #include "accumulatedAttribs.I" #endif - - diff --git a/panda/src/pgraph/alphaTestAttrib.I b/panda/src/pgraph/alphaTestAttrib.I index d16bdcadcd..0b25b40f26 100644 --- a/panda/src/pgraph/alphaTestAttrib.I +++ b/panda/src/pgraph/alphaTestAttrib.I @@ -1,24 +1,19 @@ -// Filename: alphaTestAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file alphaTestAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::Constructor -// Access: Private -// Description: Use AlphaTestAttrib::make() to construct a new -// AlphaTestAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use AlphaTestAttrib::make() to construct a new AlphaTestAttrib object. + */ INLINE AlphaTestAttrib:: AlphaTestAttrib(AlphaTestAttrib::PandaCompareFunc mode, PN_stdfloat reference_alpha) : @@ -26,21 +21,17 @@ AlphaTestAttrib(AlphaTestAttrib::PandaCompareFunc mode, { } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::get_mode -// Access: Published -// Description: Returns the alpha write mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha write mode. + */ INLINE AlphaTestAttrib::PandaCompareFunc AlphaTestAttrib:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::get_reference_alpha -// Access: Published -// Description: Returns the alpha reference value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha reference value. + */ INLINE PN_stdfloat AlphaTestAttrib:: get_reference_alpha() const { return _reference_alpha; diff --git a/panda/src/pgraph/alphaTestAttrib.cxx b/panda/src/pgraph/alphaTestAttrib.cxx index b9f4531bc5..5a37a23531 100644 --- a/panda/src/pgraph/alphaTestAttrib.cxx +++ b/panda/src/pgraph/alphaTestAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: alphaTestAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file alphaTestAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "alphaTestAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,11 +22,9 @@ TypeHandle AlphaTestAttrib::_type_handle; int AlphaTestAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::make -// Access: Published, Static -// Description: Constructs a new AlphaTestAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new AlphaTestAttrib object. + */ CPT(RenderAttrib) AlphaTestAttrib:: make(PandaCompareFunc mode, PN_stdfloat reference_value) { assert((reference_value >=0.0f) && (reference_value <=1.0f)); @@ -35,23 +32,18 @@ make(PandaCompareFunc mode, PN_stdfloat reference_value) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) AlphaTestAttrib:: make_default() { return return_new(new AlphaTestAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AlphaTestAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -59,21 +51,18 @@ output(ostream &out) const { out << "," << _reference_alpha; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived AlphaTestAttrib -// types to return a unique number indicating whether -// this AlphaTestAttrib is equivalent to the other one. -// -// This should return 0 if the two AlphaTestAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two AlphaTestAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived AlphaTestAttrib types to return a + * unique number indicating whether this AlphaTestAttrib is equivalent to the + * other one. + * + * This should return 0 if the two AlphaTestAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two AlphaTestAttrib objects whose get_type() + * functions return the same. + */ int AlphaTestAttrib:: compare_to_impl(const RenderAttrib *other) const { const AlphaTestAttrib *ta = (const AlphaTestAttrib *)other; @@ -90,16 +79,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t AlphaTestAttrib:: get_hash_impl() const { size_t hash = 0; @@ -108,33 +93,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) AlphaTestAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AlphaTestAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AlphaTestAttrib. + */ void AlphaTestAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AlphaTestAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -143,14 +121,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_reference_alpha); } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AlphaTestAttrib is encountered -// in the Bam file. It should create the AlphaTestAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AlphaTestAttrib is encountered in the Bam file. It should create the + * AlphaTestAttrib and extract its information from the file. + */ TypedWritable *AlphaTestAttrib:: make_from_bam(const FactoryParams ¶ms) { AlphaTestAttrib *attrib = new AlphaTestAttrib; @@ -163,13 +138,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: AlphaTestAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AlphaTestAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AlphaTestAttrib. + */ void AlphaTestAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/alphaTestAttrib.h b/panda/src/pgraph/alphaTestAttrib.h index 3714f39d9d..8d620e66e7 100644 --- a/panda/src/pgraph/alphaTestAttrib.h +++ b/panda/src/pgraph/alphaTestAttrib.h @@ -1,16 +1,15 @@ -// Filename: alphaTestAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file alphaTestAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef ALPHATESTATTRIB_H #define ALPHATESTATTRIB_H @@ -20,11 +19,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AlphaTestAttrib -// Description : Enables or disables writing of pixel to framebuffer -// based on its alpha value relative to a reference alpha value -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables writing of pixel to framebuffer based on its alpha + * value relative to a reference alpha value + */ class EXPCL_PANDA_PGRAPH AlphaTestAttrib : public RenderAttrib { private: INLINE AlphaTestAttrib(PandaCompareFunc mode = M_always, @@ -89,4 +87,3 @@ private: #include "alphaTestAttrib.I" #endif - diff --git a/panda/src/pgraph/antialiasAttrib.I b/panda/src/pgraph/antialiasAttrib.I index c917897466..4ca71e4b7e 100644 --- a/panda/src/pgraph/antialiasAttrib.I +++ b/panda/src/pgraph/antialiasAttrib.I @@ -1,61 +1,48 @@ -// Filename: antialiasAttrib.I -// Created by: drose (26Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file antialiasAttrib.I + * @author drose + * @date 2005-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::Constructor -// Access: Private -// Description: Use AntialiasAttrib::make() to construct a new -// AntialiasAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use AntialiasAttrib::make() to construct a new AntialiasAttrib object. + */ INLINE AntialiasAttrib:: AntialiasAttrib(unsigned short mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::get_mode -// Access: Published -// Description: Returns the specified antialias mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified antialias mode. + */ INLINE unsigned short AntialiasAttrib:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::get_mode_type -// Access: Published -// Description: Returns the specified antialias mode, with the -// quality bits masked out. This therefore indicates -// only the requested type of antialiasing: M_none, -// M_auto, or some specific combination. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified antialias mode, with the quality bits masked out. + * This therefore indicates only the requested type of antialiasing: M_none, + * M_auto, or some specific combination. + */ INLINE unsigned short AntialiasAttrib:: get_mode_type() const { return _mode & M_type_mask; } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::get_mode_quality -// Access: Published -// Description: Returns the specified antialias mode, with the type -// bits masked out. This therefore indicates only the -// requested quality settings: one of M_faster, -// M_better, M_dont_care, or zero (unspecified). -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified antialias mode, with the type bits masked out. This + * therefore indicates only the requested quality settings: one of M_faster, + * M_better, M_dont_care, or zero (unspecified). + */ INLINE unsigned short AntialiasAttrib:: get_mode_quality() const { return _mode & ~M_type_mask; diff --git a/panda/src/pgraph/antialiasAttrib.cxx b/panda/src/pgraph/antialiasAttrib.cxx index e2242f34be..ef35490753 100644 --- a/panda/src/pgraph/antialiasAttrib.cxx +++ b/panda/src/pgraph/antialiasAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: antialiasAttrib.cxx -// Created by: drose (26Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file antialiasAttrib.cxx + * @author drose + * @date 2005-01-26 + */ #include "antialiasAttrib.h" #include "config_pgraph.h" @@ -24,65 +23,51 @@ TypeHandle AntialiasAttrib::_type_handle; int AntialiasAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::make -// Access: Published, Static -// Description: Constructs a new AntialiasAttrib object. -// -// The mode should be either M_none, M_auto, or a union -// of any or all of M_point, M_line, M_polygon, and -// M_multisample. Also, in addition to the above -// choices, it may include either of M_better of -// M_faster to specify a performance/quality tradeoff -// hint. -// -// If M_none is specified, no antialiasing is performed. -// -// If M_multisample is specified, it means to use the -// special framebuffer multisample bits for -// antialiasing, if it is available. If so, the -// M_point, M_line, and M_polygon modes are ignored. -// This advanced antialiasing mode is only available on -// certain graphics hardware. If it is not available, -// the M_multisample bit is ignored (and the other modes -// may be used instead, if specified). -// -// M_point, M_line, and/or M_polygon specify -// per-primitive smoothing. When enabled, M_point and -// M_line may force transparency on. M_polygon requires -// a frame buffer that includes an alpha channel, and it -// works best if the primitives are sorted -// front-to-back. -// -// If M_auto is specified, M_multisample is selected if -// it is available, otherwise M_polygon is selected, -// unless drawing lines or points, in which case M_line -// or M_point is selected (these two generally produce -// better results than M_multisample) -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new AntialiasAttrib object. + * + * The mode should be either M_none, M_auto, or a union of any or all of + * M_point, M_line, M_polygon, and M_multisample. Also, in addition to the + * above choices, it may include either of M_better of M_faster to specify a + * performance/quality tradeoff hint. + * + * If M_none is specified, no antialiasing is performed. + * + * If M_multisample is specified, it means to use the special framebuffer + * multisample bits for antialiasing, if it is available. If so, the M_point, + * M_line, and M_polygon modes are ignored. This advanced antialiasing mode + * is only available on certain graphics hardware. If it is not available, + * the M_multisample bit is ignored (and the other modes may be used instead, + * if specified). + * + * M_point, M_line, and/or M_polygon specify per-primitive smoothing. When + * enabled, M_point and M_line may force transparency on. M_polygon requires + * a frame buffer that includes an alpha channel, and it works best if the + * primitives are sorted front-to-back. + * + * If M_auto is specified, M_multisample is selected if it is available, + * otherwise M_polygon is selected, unless drawing lines or points, in which + * case M_line or M_point is selected (these two generally produce better + * results than M_multisample) + */ CPT(RenderAttrib) AntialiasAttrib:: make(unsigned short mode) { AntialiasAttrib *attrib = new AntialiasAttrib(mode); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) AntialiasAttrib:: make_default() { return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AntialiasAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -125,21 +110,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived AntialiasAttrib -// types to return a unique number indicating whether -// this AntialiasAttrib is equivalent to the other one. -// -// This should return 0 if the two AntialiasAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two AntialiasAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived AntialiasAttrib types to return a + * unique number indicating whether this AntialiasAttrib is equivalent to the + * other one. + * + * This should return 0 if the two AntialiasAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two AntialiasAttrib objects whose get_type() + * functions return the same. + */ int AntialiasAttrib:: compare_to_impl(const RenderAttrib *other) const { const AntialiasAttrib *ta = (const AntialiasAttrib *)other; @@ -150,16 +132,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t AntialiasAttrib:: get_hash_impl() const { size_t hash = 0; @@ -167,23 +145,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) AntialiasAttrib:: compose_impl(const RenderAttrib *other) const { const AntialiasAttrib *ta = (const AntialiasAttrib *)other; @@ -198,9 +170,8 @@ compose_impl(const RenderAttrib *other) const { mode_type = ta->get_mode_type(); } else { - // Otherwise, the both modes reflect an explicit setting. In that - // case, these modes combine in the sensible way, as a union of - // bits. + // Otherwise, the both modes reflect an explicit setting. In that case, + // these modes combine in the sensible way, as a union of bits. mode_type = get_mode_type() | ta->get_mode_type(); } @@ -215,23 +186,18 @@ compose_impl(const RenderAttrib *other) const { return make(mode_type | mode_quality); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AntialiasAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AntialiasAttrib. + */ void AntialiasAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AntialiasAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -239,14 +205,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint16(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AntialiasAttrib is encountered -// in the Bam file. It should create the AntialiasAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AntialiasAttrib is encountered in the Bam file. It should create the + * AntialiasAttrib and extract its information from the file. + */ TypedWritable *AntialiasAttrib:: make_from_bam(const FactoryParams ¶ms) { AntialiasAttrib *attrib = new AntialiasAttrib(M_none); @@ -259,13 +222,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AntialiasAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AntialiasAttrib. + */ void AntialiasAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); @@ -273,20 +233,18 @@ fillin(DatagramIterator &scan, BamReader *manager) { _mode = scan.get_uint16(); } -//////////////////////////////////////////////////////////////////// -// Function: AntialiasAttrib::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AntialiasAttrib:: init_type() { RenderAttrib::init_type(); register_type(_type_handle, "AntialiasAttrib", RenderAttrib::get_class_type()); - // This is defined here, since we have otherwise no guarantee that - // the config var has already been constructed by the time we call - // init_type() at static init time. + // This is defined here, since we have otherwise no guarantee that the + // config var has already been constructed by the time we call init_type() + // at static init time. static ConfigVariableBool default_antialias_enable ("default-antialias-enable", false, PRC_DESC("Set this true to enable the M_auto antialiasing mode for all " diff --git a/panda/src/pgraph/antialiasAttrib.h b/panda/src/pgraph/antialiasAttrib.h index d975f60575..146561407d 100644 --- a/panda/src/pgraph/antialiasAttrib.h +++ b/panda/src/pgraph/antialiasAttrib.h @@ -1,16 +1,15 @@ -// Filename: antialiasAttrib.h -// Created by: drose (26Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file antialiasAttrib.h + * @author drose + * @date 2005-01-26 + */ #ifndef ANTIALIASATTRIB_H #define ANTIALIASATTRIB_H @@ -21,11 +20,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AntialiasAttrib -// Description : Specifies whether or how to enable antialiasing, if -// supported by the backend renderer. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether or how to enable antialiasing, if supported by the + * backend renderer. + */ class EXPCL_PANDA_PGRAPH AntialiasAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -37,7 +35,7 @@ PUBLISHED: M_auto = 0x001f, M_type_mask = 0x001f, - // Extra add-on bits for performance/quality hints. + // Extra add-on bits for performancequality hints. M_faster = 0x0020, M_better = 0x0040, M_dont_care = 0x0060, @@ -99,4 +97,3 @@ private: #include "antialiasAttrib.I" #endif - diff --git a/panda/src/pgraph/attribNodeRegistry.I b/panda/src/pgraph/attribNodeRegistry.I index 2904491204..30e66ca84c 100644 --- a/panda/src/pgraph/attribNodeRegistry.I +++ b/panda/src/pgraph/attribNodeRegistry.I @@ -1,23 +1,19 @@ -// Filename: attribNodeRegistry.I -// Created by: drose (07Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file attribNodeRegistry.I + * @author drose + * @date 2007-07-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::get_global_ptr -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AttribNodeRegistry *AttribNodeRegistry:: get_global_ptr() { if (_global_ptr == (AttribNodeRegistry *)NULL) { @@ -26,11 +22,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::Entry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AttribNodeRegistry::Entry:: Entry(const NodePath &node) : _type(node.node()->get_type()), @@ -39,11 +33,9 @@ Entry(const NodePath &node) : { } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::Entry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE AttribNodeRegistry::Entry:: Entry(TypeHandle type, const string &name) : _type(type), @@ -51,11 +43,9 @@ Entry(TypeHandle type, const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::Entry::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool AttribNodeRegistry::Entry:: operator < (const Entry &other) const { if (_type != other._type) { diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index e8636ba7d3..0d540c19d2 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -1,48 +1,41 @@ -// Filename: attribNodeRegistry.cxx -// Created by: drose (07Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file attribNodeRegistry.cxx + * @author drose + * @date 2007-07-07 + */ #include "attribNodeRegistry.h" #include "lightMutexHolder.h" AttribNodeRegistry * TVOLATILE AttribNodeRegistry::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AttribNodeRegistry:: AttribNodeRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::add_node -// Access: Published -// Description: Adds the indicated NodePath to the registry. The -// name and type of the node are noted at the time of -// this call; if the name changes later, it will not -// update the registry index. -// -// The NodePath must reference some kind of an attribute -// node, such as a LightNode or a PlaneNode. When bam -// files that reference an attribute node of the same -// type and the same name are loaded, they will quietly -// be redirected to reference this NodePath. -// -// If there is already a node matching the indicated -// name and type, it will be replaced. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated NodePath to the registry. The name and type of the node + * are noted at the time of this call; if the name changes later, it will not + * update the registry index. + * + * The NodePath must reference some kind of an attribute node, such as a + * LightNode or a PlaneNode. When bam files that reference an attribute node + * of the same type and the same name are loaded, they will quietly be + * redirected to reference this NodePath. + * + * If there is already a node matching the indicated name and type, it will be + * replaced. + */ void AttribNodeRegistry:: add_node(const NodePath &attrib_node) { nassertv(!attrib_node.is_empty()); @@ -55,18 +48,14 @@ add_node(const NodePath &attrib_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::remove_node -// Access: Published -// Description: Removes the indicated NodePath from the registry. -// The name of the node must not have changed since the -// matching call to add_node(), or it will not be -// successfully removed. -// -// Returns true if the NodePath is found and removed, -// false if it is not found (for instance, because the -// name has changed). -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated NodePath from the registry. The name of the node + * must not have changed since the matching call to add_node(), or it will not + * be successfully removed. + * + * Returns true if the NodePath is found and removed, false if it is not found + * (for instance, because the name has changed). + */ bool AttribNodeRegistry:: remove_node(const NodePath &attrib_node) { nassertr(!attrib_node.is_empty(), false); @@ -79,14 +68,11 @@ remove_node(const NodePath &attrib_node) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::lookup_node -// Access: Published -// Description: Looks up the indicated NodePath in the registry. If -// there is a node already in the registry with the -// matching name and type, returns that NodePath -// instead; otherwise, returns the original NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the indicated NodePath in the registry. If there is a node + * already in the registry with the matching name and type, returns that + * NodePath instead; otherwise, returns the original NodePath. + */ NodePath AttribNodeRegistry:: lookup_node(const NodePath &orig_node) const { nassertr(!orig_node.is_empty(), orig_node); @@ -99,22 +85,18 @@ lookup_node(const NodePath &orig_node) const { return orig_node; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::get_num_nodes -// Access: Published -// Description: Returns the total number of nodes in the registry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of nodes in the registry. + */ int AttribNodeRegistry:: get_num_nodes() const { LightMutexHolder holder(_lock); return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::get_node -// Access: Published -// Description: Returns the nth NodePath recorded in the registry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth NodePath recorded in the registry. + */ NodePath AttribNodeRegistry:: get_node(int n) const { LightMutexHolder holder(_lock); @@ -122,12 +104,9 @@ get_node(int n) const { return _entries[n]._node; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::get_node_type -// Access: Published -// Description: Returns the type of the nth node, as recorded in the -// registry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the nth node, as recorded in the registry. + */ TypeHandle AttribNodeRegistry:: get_node_type(int n) const { LightMutexHolder holder(_lock); @@ -135,15 +114,11 @@ get_node_type(int n) const { return _entries[n]._type; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::get_node_name -// Access: Published -// Description: Returns the name of the nth node, as recorded in the -// registry. This will be the node name as it was at -// the time the node was recorded; if the node has -// changed names since then, this will still return the -// original name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the nth node, as recorded in the registry. This will + * be the node name as it was at the time the node was recorded; if the node + * has changed names since then, this will still return the original name. + */ string AttribNodeRegistry:: get_node_name(int n) const { LightMutexHolder holder(_lock); @@ -151,15 +126,12 @@ get_node_name(int n) const { return _entries[n]._name; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::find_node -// Access: Published -// Description: Returns the index number of the indicated NodePath in -// the registry (assuming its name hasn't changed since -// it was recorded in the registry), or -1 if the -// NodePath cannot be found (for instance, because its -// name has changed). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the indicated NodePath in the registry + * (assuming its name hasn't changed since it was recorded in the registry), + * or -1 if the NodePath cannot be found (for instance, because its name has + * changed). + */ int AttribNodeRegistry:: find_node(const NodePath &attrib_node) const { nassertr(!attrib_node.is_empty(), -1); @@ -171,13 +143,10 @@ find_node(const NodePath &attrib_node) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::find_node -// Access: Published -// Description: Returns the index number of the node with the -// indicated type and name in the registry, or -1 if -// there is no such node in the registry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the node with the indicated type and name in + * the registry, or -1 if there is no such node in the registry. + */ int AttribNodeRegistry:: find_node(TypeHandle type, const string &name) const { LightMutexHolder holder(_lock); @@ -188,11 +157,9 @@ find_node(TypeHandle type, const string &name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::remove_node -// Access: Published -// Description: Removes the nth node from the registry. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth node from the registry. + */ void AttribNodeRegistry:: remove_node(int n) { LightMutexHolder holder(_lock); @@ -200,22 +167,18 @@ remove_node(int n) { _entries.erase(_entries.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::clear -// Access: Published -// Description: Removes all nodes from the registry. -//////////////////////////////////////////////////////////////////// +/** + * Removes all nodes from the registry. + */ void AttribNodeRegistry:: clear() { LightMutexHolder holder(_lock); _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AttribNodeRegistry:: output(ostream &out) const { LightMutexHolder holder(_lock); @@ -244,11 +207,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AttribNodeRegistry:: write(ostream &out) const { LightMutexHolder holder(_lock); @@ -261,11 +222,9 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AttribNodeRegistry::make_global_ptr -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AttribNodeRegistry:: make_global_ptr() { AttribNodeRegistry *ptr = new AttribNodeRegistry; diff --git a/panda/src/pgraph/attribNodeRegistry.h b/panda/src/pgraph/attribNodeRegistry.h index 84b5805887..46170e1ea9 100644 --- a/panda/src/pgraph/attribNodeRegistry.h +++ b/panda/src/pgraph/attribNodeRegistry.h @@ -1,16 +1,15 @@ -// Filename: attribNodeRegistry.h -// Created by: drose (07Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file attribNodeRegistry.h + * @author drose + * @date 2007-07-07 + */ #ifndef ATTRIBNODEREGISTRY_H #define ATTRIBNODEREGISTRY_H @@ -20,21 +19,17 @@ #include "ordered_vector.h" #include "lightMutex.h" -//////////////////////////////////////////////////////////////////// -// Class : AttribNodeRegistry -// Description : This global object records NodePaths that are -// referenced by scene graph attribs, such as -// ClipPlaneAttribs and LightAttribs. -// -// Its primary purpose is to unify attribs that are -// loaded in from bam files. Attrib nodes are -// identified by name and type; when a bam file that -// contains references to some attrib nodes is loaded, -// those nodes are first looked up here in the -// AttribNodeRegistry. If there is a match (by name and -// node type), the identified node is used instead of -// the node referenced within the bam file itself. -//////////////////////////////////////////////////////////////////// +/** + * This global object records NodePaths that are referenced by scene graph + * attribs, such as ClipPlaneAttribs and LightAttribs. + * + * Its primary purpose is to unify attribs that are loaded in from bam files. + * Attrib nodes are identified by name and type; when a bam file that contains + * references to some attrib nodes is loaded, those nodes are first looked up + * here in the AttribNodeRegistry. If there is a match (by name and node + * type), the identified node is used instead of the node referenced within + * the bam file itself. + */ class EXPCL_PANDA_PGRAPH AttribNodeRegistry { protected: AttribNodeRegistry(); @@ -85,4 +80,3 @@ private: #include "attribNodeRegistry.I" #endif - diff --git a/panda/src/pgraph/audioVolumeAttrib.I b/panda/src/pgraph/audioVolumeAttrib.I index cfd803ffd6..3c66cf9ffe 100644 --- a/panda/src/pgraph/audioVolumeAttrib.I +++ b/panda/src/pgraph/audioVolumeAttrib.I @@ -1,24 +1,19 @@ -// Filename: audioVolumeAttrib.I -// Created by: darren (15Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioVolumeAttrib.I + * @author darren + * @date 2006-12-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::Copy Constructor -// Access: Protected -// Description: Use AudioVolumeAttrib::make() to construct a new -// AudioVolumeAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use AudioVolumeAttrib::make() to construct a new AudioVolumeAttrib object. + */ INLINE AudioVolumeAttrib:: AudioVolumeAttrib(const AudioVolumeAttrib ©) : _off(copy._off), @@ -27,37 +22,29 @@ AudioVolumeAttrib(const AudioVolumeAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::is_off -// Access: Published -// Description: Returns true if the AudioVolumeAttrib will ignore any -// color scales inherited from above, false otherwise. -// This is not the same thing as !has_scale(); a -// AudioVolumeAttrib may have the "off" flag set and also -// have another scale specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the AudioVolumeAttrib will ignore any color scales + * inherited from above, false otherwise. This is not the same thing as + * !has_scale(); a AudioVolumeAttrib may have the "off" flag set and also have + * another scale specified. + */ INLINE bool AudioVolumeAttrib:: is_off() const { return _off; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::has_volume -// Access: Published -// Description: Returns true if the AudioVolumeAttrib has a -// non-identity volume, false otherwise (in which case it -// might be an off attrib or an identity attrib). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the AudioVolumeAttrib has a non-identity volume, false + * otherwise (in which case it might be an off attrib or an identity attrib). + */ INLINE bool AudioVolumeAttrib:: has_volume() const { return _has_volume; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::get_volume -// Access: Published -// Description: Returns the volume to be applied to sounds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the volume to be applied to sounds. + */ INLINE PN_stdfloat AudioVolumeAttrib:: get_volume() const { return _volume; diff --git a/panda/src/pgraph/audioVolumeAttrib.cxx b/panda/src/pgraph/audioVolumeAttrib.cxx index 59c055f447..1f545cef8e 100644 --- a/panda/src/pgraph/audioVolumeAttrib.cxx +++ b/panda/src/pgraph/audioVolumeAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: audioVolumeAttrib.cxx -// Created by: darren (15Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioVolumeAttrib.cxx + * @author darren + * @date 2006-12-15 + */ #include "audioVolumeAttrib.h" #include "graphicsStateGuardianBase.h" @@ -25,12 +24,9 @@ CPT(RenderAttrib) AudioVolumeAttrib::_identity_attrib; TypeHandle AudioVolumeAttrib::_type_handle; int AudioVolumeAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::Constructor -// Access: Protected -// Description: Use AudioVolumeAttrib::make() to construct a new -// AudioVolumeAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use AudioVolumeAttrib::make() to construct a new AudioVolumeAttrib object. + */ AudioVolumeAttrib:: AudioVolumeAttrib(bool off, PN_stdfloat volume) : _off(off), @@ -40,15 +36,13 @@ AudioVolumeAttrib(bool off, PN_stdfloat volume) : _has_volume = !IS_NEARLY_EQUAL(_volume, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::make_identity -// Access: Published, Static -// Description: Constructs an identity audio volume attrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an identity audio volume attrib. + */ CPT(RenderAttrib) AudioVolumeAttrib:: make_identity() { - // We make identity a special case and store a pointer forever once - // we find it the first time. + // We make identity a special case and store a pointer forever once we find + // it the first time. if (_identity_attrib == (AudioVolumeAttrib *)NULL) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, 1.0f);; _identity_attrib = return_new(attrib); @@ -57,51 +51,41 @@ make_identity() { return _identity_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::make -// Access: Published, Static -// Description: Constructs a new AudioVolumeAttrib object that indicates -// audio volume should be scaled by the indicated factor. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new AudioVolumeAttrib object that indicates audio volume + * should be scaled by the indicated factor. + */ CPT(RenderAttrib) AudioVolumeAttrib:: make(PN_stdfloat volume) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, volume); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::make_off -// Access: Published, Static -// Description: Constructs a new AudioVolumeAttrib object that ignores -// any AudioVolumeAttrib inherited from above. You may -// also specify an additional volume scale to apply to -// geometry below (using set_volume()). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new AudioVolumeAttrib object that ignores any + * AudioVolumeAttrib inherited from above. You may also specify an additional + * volume scale to apply to geometry below (using set_volume()). + */ CPT(RenderAttrib) AudioVolumeAttrib:: make_off() { - AudioVolumeAttrib *attrib = + AudioVolumeAttrib *attrib = new AudioVolumeAttrib(true, 1.0f); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) AudioVolumeAttrib:: make_default() { return return_new(new AudioVolumeAttrib(false, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::set_volume -// Access: Published -// Description: Returns a new AudioVolumeAttrib, just like this one, but -// with the volume changed to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new AudioVolumeAttrib, just like this one, but with the volume + * changed to the indicated value. + */ CPT(RenderAttrib) AudioVolumeAttrib:: set_volume(PN_stdfloat volume) const { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(*this); @@ -111,11 +95,9 @@ set_volume(PN_stdfloat volume) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AudioVolumeAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -130,21 +112,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived AudioVolumeAttrib -// types to return a unique number indicating whether -// this AudioVolumeAttrib is equivalent to the other one. -// -// This should return 0 if the two AudioVolumeAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two AudioVolumeAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived AudioVolumeAttrib types to return a + * unique number indicating whether this AudioVolumeAttrib is equivalent to + * the other one. + * + * This should return 0 if the two AudioVolumeAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two AudioVolumeAttrib objects whose + * get_type() functions return the same. + */ int AudioVolumeAttrib:: compare_to_impl(const RenderAttrib *other) const { const AudioVolumeAttrib *ta = (const AudioVolumeAttrib *)other; @@ -160,16 +139,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t AudioVolumeAttrib:: get_hash_impl() const { size_t hash = 0; @@ -178,23 +153,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) AudioVolumeAttrib:: compose_impl(const RenderAttrib *other) const { const AudioVolumeAttrib *ta = (const AudioVolumeAttrib *)other; @@ -207,15 +176,12 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) AudioVolumeAttrib:: invert_compose_impl(const RenderAttrib *other) const { if (is_off()) { @@ -229,42 +195,34 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AudioVolumeAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AudioVolumeAttrib. + */ void AudioVolumeAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AudioVolumeAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); - // We cheat, and modify the bam stream without upping the bam - // version. We can do this since we know that no existing bam files - // have an AudioVolumeAttrib in them. + // We cheat, and modify the bam stream without upping the bam version. We + // can do this since we know that no existing bam files have an + // AudioVolumeAttrib in them. dg.add_bool(_off); dg.add_stdfloat(_volume); } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AudioVolumeAttrib is encountered -// in the Bam file. It should create the AudioVolumeAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AudioVolumeAttrib is encountered in the Bam file. It should create + * the AudioVolumeAttrib and extract its information from the file. + */ TypedWritable *AudioVolumeAttrib:: make_from_bam(const FactoryParams ¶ms) { AudioVolumeAttrib *attrib = new AudioVolumeAttrib(false, 1.0f); @@ -277,13 +235,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: AudioVolumeAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AudioVolumeAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AudioVolumeAttrib. + */ void AudioVolumeAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/audioVolumeAttrib.h b/panda/src/pgraph/audioVolumeAttrib.h index ebfab1077d..29ccf23563 100644 --- a/panda/src/pgraph/audioVolumeAttrib.h +++ b/panda/src/pgraph/audioVolumeAttrib.h @@ -1,16 +1,15 @@ -// Filename: audioVolumeAttrib.h -// Created by: darren (15Dec06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file audioVolumeAttrib.h + * @author darren + * @date 2006-12-15 + */ #ifndef AUDIOVOLUMEATTRIB_H #define AUDIOVOLUMEATTRIB_H @@ -22,11 +21,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AudioVolumeAttrib -// Description : Applies a scale to audio volume for positional sounds -// in the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Applies a scale to audio volume for positional sounds in the scene graph. + */ class EXPCL_PANDA_PGRAPH AudioVolumeAttrib : public RenderAttrib { protected: AudioVolumeAttrib(bool off, PN_stdfloat volume); @@ -97,4 +94,3 @@ private: #include "audioVolumeAttrib.I" #endif - diff --git a/panda/src/pgraph/auxBitplaneAttrib.I b/panda/src/pgraph/auxBitplaneAttrib.I index f6adb81d08..1e3389072e 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.I +++ b/panda/src/pgraph/auxBitplaneAttrib.I @@ -1,37 +1,29 @@ -// Filename: auxBitplaneAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxBitplaneAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::Constructor -// Access: Private -// Description: Use AuxBitplaneAttrib::make() to construct a new -// AuxBitplaneAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use AuxBitplaneAttrib::make() to construct a new AuxBitplaneAttrib object. + */ INLINE AuxBitplaneAttrib:: AuxBitplaneAttrib(int outputs) : _outputs(outputs) { } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::get_outputs -// Access: Published -// Description: Returns the AuxBitplaneAttrib output bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AuxBitplaneAttrib output bits. + */ INLINE int AuxBitplaneAttrib:: get_outputs() const { return _outputs; } - diff --git a/panda/src/pgraph/auxBitplaneAttrib.cxx b/panda/src/pgraph/auxBitplaneAttrib.cxx index 5f836a0b87..1d8a5b3095 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.cxx +++ b/panda/src/pgraph/auxBitplaneAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: auxBitplaneAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxBitplaneAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "auxBitplaneAttrib.h" #include "graphicsStateGuardianBase.h" @@ -24,11 +23,9 @@ TypeHandle AuxBitplaneAttrib::_type_handle; int AuxBitplaneAttrib::_attrib_slot; CPT(RenderAttrib) AuxBitplaneAttrib::_default; -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::make -// Access: Published, Static -// Description: Constructs a default AuxBitplaneAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a default AuxBitplaneAttrib object. + */ CPT(RenderAttrib) AuxBitplaneAttrib:: make() { if (_default == 0) { @@ -38,54 +35,44 @@ make() { return _default; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::make -// Access: Published, Static -// Description: Constructs a specified AuxBitplaneAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a specified AuxBitplaneAttrib object. + */ CPT(RenderAttrib) AuxBitplaneAttrib:: make(int outputs) { AuxBitplaneAttrib *attrib = new AuxBitplaneAttrib(outputs); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) AuxBitplaneAttrib:: make_default() { return return_new(new AuxBitplaneAttrib(0)); } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AuxBitplaneAttrib:: output(ostream &out) const { out << get_type() << "(" << _outputs << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived AuxBitplaneAttrib -// types to return a unique number indicating whether -// this AuxBitplaneAttrib is equivalent to the other one. -// -// This should return 0 if the two AuxBitplaneAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two AuxBitplaneAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived AuxBitplaneAttrib types to return a + * unique number indicating whether this AuxBitplaneAttrib is equivalent to + * the other one. + * + * This should return 0 if the two AuxBitplaneAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two AuxBitplaneAttrib objects whose + * get_type() functions return the same. + */ int AuxBitplaneAttrib:: compare_to_impl(const RenderAttrib *other) const { const AuxBitplaneAttrib *ta = (const AuxBitplaneAttrib *)other; @@ -97,16 +84,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t AuxBitplaneAttrib:: get_hash_impl() const { size_t hash = 0; @@ -114,33 +97,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) AuxBitplaneAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AuxBitplaneAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AuxBitplaneAttrib. + */ void AuxBitplaneAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AuxBitplaneAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -148,14 +124,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int32(_outputs); } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AuxBitplaneAttrib is encountered -// in the Bam file. It should create the AuxBitplaneAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AuxBitplaneAttrib is encountered in the Bam file. It should create + * the AuxBitplaneAttrib and extract its information from the file. + */ TypedWritable *AuxBitplaneAttrib:: make_from_bam(const FactoryParams ¶ms) { AuxBitplaneAttrib *attrib = new AuxBitplaneAttrib(0); @@ -164,17 +137,14 @@ make_from_bam(const FactoryParams ¶ms) { parse_params(params, scan, manager); attrib->fillin(scan, manager); - + return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: AuxBitplaneAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AuxBitplaneAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AuxBitplaneAttrib. + */ void AuxBitplaneAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/auxBitplaneAttrib.h b/panda/src/pgraph/auxBitplaneAttrib.h index 4285294f33..75ac6aee01 100644 --- a/panda/src/pgraph/auxBitplaneAttrib.h +++ b/panda/src/pgraph/auxBitplaneAttrib.h @@ -1,16 +1,15 @@ -// Filename: auxBitplaneAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxBitplaneAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef AUXBITPLANEATTRIB_H #define AUXBITPLANEATTRIB_H @@ -20,40 +19,33 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : AuxBitplaneAttrib -// Description : Modern frame buffers can have 'aux' bitplanes, which -// are additional bitplanes above and beyond the -// standard depth and color. This attrib controls what -// gets rendered into those additional bitplanes. It -// can also affect what goes into the alpha channel -// of the primary color buffer. -// -// ABO_glow: copy the glow map into the alpha channel -// of the primary frame buffer. If there is no glow -// map, set it to zero. Caveat: it is not -// possible to write glow or depth values to the -// framebuffer alpha channel at the same time as using -// alpha blending or alpha testing. Any attempt to use -// transparency, blending, or alpha testing will cause -// this flag to be overridden. -// -// ABO_aux_normal: put the camera-space normal into -// the into the R,G components of the first auxiliary -// bitplane. -// -// ABO_aux_modelz: put the clip-space Z coordinate of -// the center of the model (after perspective divide) -// into the B channel of the first auxiliary bitplane. -// -// ABO_aux_glow: put a copy of the glow map into the -// alpha channel of the first auxiliary bitplane. -// If there is no glow map, set it to zero. -// -// AuxBitplaneAttrib is relevant only when shader -// generation is enabled. Otherwise, it has no effect. -// -//////////////////////////////////////////////////////////////////// +/** + * Modern frame buffers can have 'aux' bitplanes, which are additional + * bitplanes above and beyond the standard depth and color. This attrib + * controls what gets rendered into those additional bitplanes. It can also + * affect what goes into the alpha channel of the primary color buffer. + * + * ABO_glow: copy the glow map into the alpha channel of the primary frame + * buffer. If there is no glow map, set it to zero. Caveat: it is not + * possible to write glow or depth values to the framebuffer alpha channel at + * the same time as using alpha blending or alpha testing. Any attempt to use + * transparency, blending, or alpha testing will cause this flag to be + * overridden. + * + * ABO_aux_normal: put the camera-space normal into the into the R,G + * components of the first auxiliary bitplane. + * + * ABO_aux_modelz: put the clip-space Z coordinate of the center of the model + * (after perspective divide) into the B channel of the first auxiliary + * bitplane. + * + * ABO_aux_glow: put a copy of the glow map into the alpha channel of the + * first auxiliary bitplane. If there is no glow map, set it to zero. + * + * AuxBitplaneAttrib is relevant only when shader generation is enabled. + * Otherwise, it has no effect. + * + */ class EXPCL_PANDA_PGRAPH AuxBitplaneAttrib : public RenderAttrib { private: INLINE AuxBitplaneAttrib(int outputs); @@ -61,24 +53,24 @@ private: PUBLISHED: enum AuxBitplaneOutput { ABO_glow = 1, - + ABO_aux_normal = 2, ABO_aux_glow = 4, }; static CPT(RenderAttrib) make(); static CPT(RenderAttrib) make(int outputs); static CPT(RenderAttrib) make_default(); - + INLINE int get_outputs() const; - + public: virtual void output(ostream &out) const; - + protected: virtual int compare_to_impl(const RenderAttrib *other) const; virtual size_t get_hash_impl() const; virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const; - + private: int _outputs; @@ -99,7 +91,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -123,4 +115,3 @@ private: #include "auxBitplaneAttrib.I" #endif - diff --git a/panda/src/pgraph/auxSceneData.I b/panda/src/pgraph/auxSceneData.I index a7ff38265a..e80d5f6469 100644 --- a/panda/src/pgraph/auxSceneData.I +++ b/panda/src/pgraph/auxSceneData.I @@ -1,25 +1,21 @@ -// Filename: auxSceneData.I -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxSceneData.I + * @author drose + * @date 2004-09-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::Constructor -// Access: Protected -// Description: This is protected, since you normally don't want to -// create a plain AuxSceneData object; instead, create -// an instance of a derived class that actually has some -// useful data in it. -//////////////////////////////////////////////////////////////////// +/** + * This is protected, since you normally don't want to create a plain + * AuxSceneData object; instead, create an instance of a derived class that + * actually has some useful data in it. + */ INLINE AuxSceneData:: AuxSceneData(double duration) : _duration(duration), @@ -27,59 +23,46 @@ AuxSceneData(double duration) : { } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::set_duration -// Access: Public -// Description: Specifies the minimum length in time, in seconds, to -// keep this AuxSceneData object around in the scene -// graph after the last time it was rendered. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the minimum length in time, in seconds, to keep this AuxSceneData + * object around in the scene graph after the last time it was rendered. + */ INLINE void AuxSceneData:: set_duration(double duration) { _duration = duration; } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::get_duration -// Access: Public -// Description: Returns the minimum length in time, in seconds, to -// keep this AuxSceneData object around in the scene -// graph after the last time it was rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum length in time, in seconds, to keep this AuxSceneData + * object around in the scene graph after the last time it was rendered. + */ INLINE double AuxSceneData:: get_duration() const { return _duration; } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::set_last_render_time -// Access: Public -// Description: Should be called with the current frame_time each -// time the AuxSceneData is used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be called with the current frame_time each time the AuxSceneData is + * used during traversal. + */ INLINE void AuxSceneData:: set_last_render_time(double last_render_time) { _last_render_time = last_render_time; } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::get_last_render_time -// Access: Public -// Description: Returns the last time this object was used during -// traversal (according to set_last_render_time()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the last time this object was used during traversal (according to + * set_last_render_time()). + */ INLINE double AuxSceneData:: get_last_render_time() const { return _last_render_time; } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::get_expiration_time -// Access: Public -// Description: Returns the frame_time at which this AuxSceneData -// object is currently scheduled to be removed from the -// scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame_time at which this AuxSceneData object is currently + * scheduled to be removed from the scene graph. + */ INLINE double AuxSceneData:: get_expiration_time() const { return _last_render_time + _duration; diff --git a/panda/src/pgraph/auxSceneData.cxx b/panda/src/pgraph/auxSceneData.cxx index 1ab1f655d7..b0a50cb1c0 100644 --- a/panda/src/pgraph/auxSceneData.cxx +++ b/panda/src/pgraph/auxSceneData.cxx @@ -1,37 +1,32 @@ -// Filename: auxSceneData.cxx -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxSceneData.cxx + * @author drose + * @date 2004-09-27 + */ #include "auxSceneData.h" #include "indent.h" TypeHandle AuxSceneData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AuxSceneData:: output(ostream &out) const { out << get_type() << " expires " << get_expiration_time(); } -//////////////////////////////////////////////////////////////////// -// Function: AuxSceneData::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AuxSceneData:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; diff --git a/panda/src/pgraph/auxSceneData.h b/panda/src/pgraph/auxSceneData.h index 4984412507..ec117bdc17 100644 --- a/panda/src/pgraph/auxSceneData.h +++ b/panda/src/pgraph/auxSceneData.h @@ -1,16 +1,15 @@ -// Filename: auxSceneData.h -// Created by: drose (27Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file auxSceneData.h + * @author drose + * @date 2004-09-27 + */ #ifndef AUXSCENEDATA_H #define AUXSCENEDATA_H @@ -20,18 +19,15 @@ #include "typedReferenceCount.h" #include "clockObject.h" -//////////////////////////////////////////////////////////////////// -// Class : AuxSceneData -// Description : This is a base class for a generic data structure -// that can be attached per-instance to the camera, to -// store per-instance data that must be preserved over -// multiple frames. -// -// In particular, this is used to implement the -// FadeLODNode, which must remember during traversal at -// what point it is in the fade, separately for each -// instance and for each camera. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for a generic data structure that can be attached per- + * instance to the camera, to store per-instance data that must be preserved + * over multiple frames. + * + * In particular, this is used to implement the FadeLODNode, which must + * remember during traversal at what point it is in the fade, separately for + * each instance and for each camera. + */ class EXPCL_PANDA_PGRAPH AuxSceneData : public TypedReferenceCount { protected: INLINE AuxSceneData(double duration = 0.0); diff --git a/panda/src/pgraph/bamFile.I b/panda/src/pgraph/bamFile.I index 847f995225..b3305cbe48 100644 --- a/panda/src/pgraph/bamFile.I +++ b/panda/src/pgraph/bamFile.I @@ -1,40 +1,31 @@ -// Filename: bamFile.I -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamFile.I + * @author drose + * @date 2000-07-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamFile::is_valid_read -// Access: Public -// Description: Returns true if the Bam file is open and ready for -// reading with no errors so far detected, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Bam file is open and ready for reading with no errors + * so far detected, or false otherwise. + */ INLINE bool BamFile:: is_valid_read() const { return (_reader != (BamReader *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::is_valid_write -// Access: Public -// Description: Returns true if the Bam file is open and ready for -// writing with no errors so far detected, or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the Bam file is open and ready for writing with no errors + * so far detected, or false otherwise. + */ INLINE bool BamFile:: is_valid_write() const { return (_writer != (BamWriter *)NULL); } - diff --git a/panda/src/pgraph/bamFile.cxx b/panda/src/pgraph/bamFile.cxx index 5a438900b8..83256c340a 100644 --- a/panda/src/pgraph/bamFile.cxx +++ b/panda/src/pgraph/bamFile.cxx @@ -1,16 +1,15 @@ -// Filename: bamFile.cxx -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamFile.cxx + * @author drose + * @date 2000-07-02 + */ #include "bamFile.h" #include "config_pgraph.h" @@ -25,33 +24,27 @@ #include "virtualFileSystem.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: BamFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamFile:: BamFile() { _reader = NULL; _writer = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamFile:: ~BamFile() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::open_read -// Access: Public -// Description: Attempts to open the indicated filename for reading. -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the indicated filename for reading. Returns true if + * successful, false on error. + */ bool BamFile:: open_read(const Filename &bam_filename, bool report_errors) { close(); @@ -63,13 +56,10 @@ open_read(const Filename &bam_filename, bool report_errors) { return continue_open_read(bam_filename, report_errors); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::open_read -// Access: Public -// Description: Attempts to open the indicated stream for reading. -// The filename is just for information purposes only. -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the indicated stream for reading. The filename is just + * for information purposes only. Returns true if successful, false on error. + */ bool BamFile:: open_read(istream &in, const string &bam_filename, bool report_errors) { close(); @@ -81,17 +71,14 @@ open_read(istream &in, const string &bam_filename, bool report_errors) { return continue_open_read(bam_filename, report_errors); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::read_object -// Access: Public -// Description: Reads and returns the next object from the Bam file, -// or NULL if the end of the file has been reached, or -// if there is an error condition. Use is_eof() to -// differentiate these two cases. -// -// The pointers returned by this method will not be -// valid for use until resolve() is subsequently called. -//////////////////////////////////////////////////////////////////// +/** + * Reads and returns the next object from the Bam file, or NULL if the end of + * the file has been reached, or if there is an error condition. Use is_eof() + * to differentiate these two cases. + * + * The pointers returned by this method will not be valid for use until + * resolve() is subsequently called. + */ TypedWritable *BamFile:: read_object() { if (_reader == (BamReader *)NULL) { @@ -101,29 +88,22 @@ read_object() { return _reader->read_object(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::is_eof -// Access: Public -// Description: Returns true if the reader has reached end-of-file, -// false otherwise. This call is only valid after a -// call to read_object(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader has reached end-of-file, false otherwise. This + * call is only valid after a call to read_object(). + */ bool BamFile:: is_eof() const { return _reader != (BamReader *)NULL && _reader->is_eof(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::resolve -// Access: Public -// Description: This must be called after one or more objects have -// been read via calls to read_object() in order to -// resolve all internal pointer references in the -// objects read and make all the pointers valid. It -// returns true if all objects are successfully -// resolved, or false if some have not been (in which -// case you must call resolve() again later). -//////////////////////////////////////////////////////////////////// +/** + * This must be called after one or more objects have been read via calls to + * read_object() in order to resolve all internal pointer references in the + * objects read and make all the pointers valid. It returns true if all + * objects are successfully resolved, or false if some have not been (in which + * case you must call resolve() again later). + */ bool BamFile:: resolve() { if (_reader == (BamReader *)NULL) { @@ -133,39 +113,33 @@ resolve() { return _reader->resolve(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::read_node -// Access: Public -// Description: Although the bam file format is general enough to -// store a list of objects of arbitrary type, bam files -// on disk usually contain just one object, a PandaNode -// that is the root of a scene graph. (Bam files that -// store other kinds of things are usually given the -// extension "boo", for "binary other objects", to -// differentiate them from the normal scene graph type -// file.) -// -// This is a convenience method for when you believe you -// are reading a scene graph bam file. It reads the one -// PandaNode and returns it. It also calls resolve() to -// fully resolve the object, since we expect this will -// be the only object in the file. -// -// If the bam file contains something other than a -// PandaNode, an error is printed and NULL is returned. -//////////////////////////////////////////////////////////////////// +/** + * Although the bam file format is general enough to store a list of objects + * of arbitrary type, bam files on disk usually contain just one object, a + * PandaNode that is the root of a scene graph. (Bam files that store other + * kinds of things are usually given the extension "boo", for "binary other + * objects", to differentiate them from the normal scene graph type file.) + * + * This is a convenience method for when you believe you are reading a scene + * graph bam file. It reads the one PandaNode and returns it. It also calls + * resolve() to fully resolve the object, since we expect this will be the + * only object in the file. + * + * If the bam file contains something other than a PandaNode, an error is + * printed and NULL is returned. + */ PT(PandaNode) BamFile:: read_node(bool report_errors) { PT(PandaNode) result; TypedWritable *object = read_object(); - if (object != (TypedWritable *)NULL && + if (object != (TypedWritable *)NULL && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a - // BamCacheRecord, it's really a cache data file and not a true - // bam file; but skip over the cache data record and let the user - // treat it like an ordinary bam file. + // BamCacheRecord, it's really a cache data file and not a true bam file; + // but skip over the cache data record and let the user treat it like an + // ordinary bam file. object = read_object(); } @@ -205,14 +179,11 @@ read_node(bool report_errors) { } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::open_write -// Access: Public -// Description: Attempts to open the indicated file for writing. If -// another file by the same name already exists, it will -// be silently removed. Returns true if successful, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the indicated file for writing. If another file by the + * same name already exists, it will be silently removed. Returns true if + * successful, false otherwise. + */ bool BamFile:: open_write(const Filename &bam_filename, bool report_errors) { close(); @@ -229,13 +200,10 @@ open_write(const Filename &bam_filename, bool report_errors) { return continue_open_write(bam_filename, report_errors); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::open_write -// Access: Public -// Description: Attempts to open the indicated stream for writing. -// The filename is just for information purposes only. -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the indicated stream for writing. The filename is just + * for information purposes only. Returns true if successful, false on error. + */ bool BamFile:: open_write(ostream &out, const string &bam_filename, bool report_errors) { close(); @@ -248,12 +216,10 @@ open_write(ostream &out, const string &bam_filename, bool report_errors) { return continue_open_write(bam_filename, report_errors); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::write_object -// Access: Public -// Description: Writes the indicated object to the Bam file. Returns -// true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated object to the Bam file. Returns true if successful, + * false on error. + */ bool BamFile:: write_object(const TypedWritable *object) { if (_writer == (BamWriter *)NULL) { @@ -268,15 +234,13 @@ write_object(const TypedWritable *object) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::close -// Access: Public -// Description: Closes the input or output stream. -//////////////////////////////////////////////////////////////////// +/** + * Closes the input or output stream. + */ void BamFile:: close() { if (_reader != (BamReader *)NULL) { - // resolve(); + // resolve(); delete _reader; _reader = NULL; } @@ -289,14 +253,11 @@ close() { } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_file_major_ver -// Access: Public -// Description: Returns the major version number of the file -// currently being read, or the system current major -// version number if no file is currently open for -// reading. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number of the file currently being read, or the + * system current major version number if no file is currently open for + * reading. + */ int BamFile:: get_file_major_ver() { if (_reader == (BamReader *)NULL) { @@ -305,14 +266,11 @@ get_file_major_ver() { return _reader->get_file_major_ver(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_file_minor_ver -// Access: Public -// Description: Returns the minor version number of the file -// currently being read, or the system current minor -// version number if no file is currently open for -// reading. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number of the file currently being read, or the + * system current minor version number if no file is currently open for + * reading. + */ int BamFile:: get_file_minor_ver() { if (_reader == (BamReader *)NULL) { @@ -321,12 +279,10 @@ get_file_minor_ver() { return _reader->get_file_minor_ver(); } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_file_endian -// Access: Public -// Description: Returns the endian preference indicated by the Bam -// file currently being read or written. -//////////////////////////////////////////////////////////////////// +/** + * Returns the endian preference indicated by the Bam file currently being + * read or written. + */ BamFile::BamEndian BamFile:: get_file_endian() const { if (_writer != (BamWriter *)NULL) { @@ -339,13 +295,10 @@ get_file_endian() const { return bam_endian; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_file_stdfloat_double -// Access: Public -// Description: Returns true if the file stores all "standard" -// floats as 64-bit doubles, or false if they are 32-bit -// floats. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file stores all "standard" floats as 64-bit doubles, or + * false if they are 32-bit floats. + */ bool BamFile:: get_file_stdfloat_double() const { if (_writer != (BamWriter *)NULL) { @@ -358,61 +311,46 @@ get_file_stdfloat_double() const { return bam_stdfloat_double; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_current_major_ver -// Access: Public -// Description: Returns the system current major version number. -// This is the version number that will be assigned to -// any generated Bam files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system current major version number. This is the version + * number that will be assigned to any generated Bam files. + */ int BamFile:: get_current_major_ver() { return _bam_major_ver; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_current_minor_ver -// Access: Public -// Description: Returns the system current minor version number. -// This is the version number that will be assigned to -// any generated Bam files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the system current minor version number. This is the version + * number that will be assigned to any generated Bam files. + */ int BamFile:: get_current_minor_ver() { return _bam_minor_ver; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_reader -// Access: Public -// Description: Returns the BamReader in charge of performing the -// read operations. This will return NULL unless -// open_read() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BamReader in charge of performing the read operations. This + * will return NULL unless open_read() was called. + */ BamReader *BamFile:: get_reader() { return _reader; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::get_writer -// Access: Public -// Description: Returns the BamWriter in charge of performing the -// write operations. This will return NULL unless -// open_write() was called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BamWriter in charge of performing the write operations. This + * will return NULL unless open_write() was called. + */ BamWriter *BamFile:: get_writer() { return _writer; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::continue_open_read -// Access: Private -// Description: Reads the header of the recently-opened bam stream -// and prepares to read the contents of the file. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the header of the recently-opened bam stream and prepares to read the + * contents of the file. Returns true if successful, false otherwise. + */ bool BamFile:: continue_open_read(const string &bam_filename, bool report_errors) { _bam_filename = bam_filename; @@ -446,13 +384,10 @@ continue_open_read(const string &bam_filename, bool report_errors) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamFile::continue_open_write -// Access: Private -// Description: Writers the header of the recently-opened bam stream -// and prepares to write the contents of the file. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writers the header of the recently-opened bam stream and prepares to write + * the contents of the file. Returns true if successful, false otherwise. + */ bool BamFile:: continue_open_write(const string &bam_filename, bool report_errors) { _bam_filename = bam_filename; diff --git a/panda/src/pgraph/bamFile.h b/panda/src/pgraph/bamFile.h index 24976b5f10..e96581729e 100644 --- a/panda/src/pgraph/bamFile.h +++ b/panda/src/pgraph/bamFile.h @@ -1,16 +1,15 @@ -// Filename: bamFile.h -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamFile.h + * @author drose + * @date 2000-07-02 + */ #ifndef BAMFILE_H #define BAMFILE_H @@ -27,21 +26,18 @@ class BamWriter; class TypedWritable; class Filename; -//////////////////////////////////////////////////////////////////// -// Class : BamFile -// Description : The principle public interface to reading and writing -// Bam disk files. See also BamReader and BamWriter, -// the more general implementation of this class. -// -// Bam files are most often used to store scene graphs -// or subgraphs, and by convention they are given -// filenames ending in the extension ".bam" when they -// are used for this purpose. However, a Bam file may -// store any arbitrary list of TypedWritable objects; -// in this more general usage, they are given filenames -// ending in ".boo" to differentiate them from the more -// common scene graph files. -//////////////////////////////////////////////////////////////////// +/** + * The principle public interface to reading and writing Bam disk files. See + * also BamReader and BamWriter, the more general implementation of this + * class. + * + * Bam files are most often used to store scene graphs or subgraphs, and by + * convention they are given filenames ending in the extension ".bam" when + * they are used for this purpose. However, a Bam file may store any + * arbitrary list of TypedWritable objects; in this more general usage, they + * are given filenames ending in ".boo" to differentiate them from the more + * common scene graph files. + */ class EXPCL_PANDA_PGRAPH BamFile : public BamEnums { PUBLISHED: BamFile(); diff --git a/panda/src/pgraph/billboardEffect.I b/panda/src/pgraph/billboardEffect.I index 9cbe4621f6..d94d8135f7 100644 --- a/panda/src/pgraph/billboardEffect.I +++ b/panda/src/pgraph/billboardEffect.I @@ -1,148 +1,115 @@ -// Filename: billboardEffect.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file billboardEffect.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::Constructor -// Access: Private -// Description: Use BillboardEffect::make() to construct a new -// BillboardEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use BillboardEffect::make() to construct a new BillboardEffect object. + */ INLINE BillboardEffect:: BillboardEffect() { _off = true; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::make_axis -// Access: Published, Static -// Description: A convenience function to make a typical -// axis-rotating billboard. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to make a typical axis-rotating billboard. + */ INLINE CPT(RenderEffect) BillboardEffect:: make_axis() { - return make(LVector3::up(), false, true, + return make(LVector3::up(), false, true, 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::make_point_eye -// Access: Published, Static -// Description: A convenience function to make a typical -// eye-relative point-rotating billboard. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to make a typical eye-relative point-rotating + * billboard. + */ INLINE CPT(RenderEffect) BillboardEffect:: make_point_eye() { return make(LVector3::up(), true, false, 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::make_point_world -// Access: Published, Static -// Description: A convenience function to make a typical -// world-relative point-rotating billboard. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to make a typical world-relative point-rotating + * billboard. + */ INLINE CPT(RenderEffect) BillboardEffect:: make_point_world() { return make(LVector3::up(), false, false, 0.0f, NodePath(), LPoint3(0.0f, 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::is_off -// Access: Published -// Description: Returns true if the BillboardEffect is an 'off' -// BillboardEffect, indicating that it does not enable -// billboarding. This kind of BillboardEffect isn't -// particularly useful and isn't normally created or -// stored in the graph; it might be implicitly -// discovered as the result of a -// NodePath::get_rel_state(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the BillboardEffect is an 'off' BillboardEffect, indicating + * that it does not enable billboarding. This kind of BillboardEffect isn't + * particularly useful and isn't normally created or stored in the graph; it + * might be implicitly discovered as the result of a + * NodePath::get_rel_state(). + */ INLINE bool BillboardEffect:: is_off() const { return _off; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_up_vector -// Access: Published -// Description: Returns the up vector in effect for this billboard. -//////////////////////////////////////////////////////////////////// +/** + * Returns the up vector in effect for this billboard. + */ INLINE const LVector3 &BillboardEffect:: get_up_vector() const { return _up_vector; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_eye_relative -// Access: Published -// Description: Returns true if this billboard interprets the up -// vector relative to the camera, or false if it is -// relative to the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this billboard interprets the up vector relative to the + * camera, or false if it is relative to the world. + */ INLINE bool BillboardEffect:: get_eye_relative() const { return _eye_relative; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_axial_rotate -// Access: Published -// Description: Returns true if this billboard rotates only around -// the axis of the up vector, or false if it rotates -// freely in three dimensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this billboard rotates only around the axis of the up + * vector, or false if it rotates freely in three dimensions. + */ INLINE bool BillboardEffect:: get_axial_rotate() const { return _axial_rotate; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_offset -// Access: Published -// Description: Returns the distance toward the camera (or the -// look_at_point) the billboard is moved towards, after -// rotating. This can be used to ensure the billboard -// is not obscured by nearby geometry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the distance toward the camera (or the look_at_point) the billboard + * is moved towards, after rotating. This can be used to ensure the billboard + * is not obscured by nearby geometry. + */ INLINE PN_stdfloat BillboardEffect:: get_offset() const { return _offset; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_look_at -// Access: Published -// Description: Returns the node this billboard will rotate to look -// towards. If this is empty, it means the billboard -// will rotate towards the current camera node, wherever -// that might be. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node this billboard will rotate to look towards. If this is + * empty, it means the billboard will rotate towards the current camera node, + * wherever that might be. + */ INLINE const NodePath &BillboardEffect:: get_look_at() const { return _look_at; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::get_look_at_point -// Access: Published -// Description: Returns the point, relative to the look_at node, -// towards which the billboard will rotate. Normally -// this is (0, 0, 0). -//////////////////////////////////////////////////////////////////// +/** + * Returns the point, relative to the look_at node, towards which the + * billboard will rotate. Normally this is (0, 0, 0). + */ INLINE const LPoint3 &BillboardEffect:: get_look_at_point() const { return _look_at_point; diff --git a/panda/src/pgraph/billboardEffect.cxx b/panda/src/pgraph/billboardEffect.cxx index 3578014b05..dad0638245 100644 --- a/panda/src/pgraph/billboardEffect.cxx +++ b/panda/src/pgraph/billboardEffect.cxx @@ -1,16 +1,15 @@ -// Filename: billboardEffect.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file billboardEffect.cxx + * @author drose + * @date 2002-03-14 + */ #include "billboardEffect.h" #include "cullTraverser.h" @@ -24,12 +23,9 @@ TypeHandle BillboardEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::make -// Access: Published, Static -// Description: Constructs a new BillboardEffect object with the -// indicated properties. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new BillboardEffect object with the indicated properties. + */ CPT(RenderEffect) BillboardEffect:: make(const LVector3 &up_vector, bool eye_relative, bool axial_rotate, PN_stdfloat offset, const NodePath &look_at, @@ -45,39 +41,30 @@ make(const LVector3 &up_vector, bool eye_relative, return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of RenderEffect by calling the -// xform() method, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * RenderEffect by calling the xform() method, false otherwise. + */ bool BillboardEffect:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::prepare_flatten_transform -// Access: Public, Virtual -// Description: Preprocesses the accumulated transform that is about -// to be applied to (or through) this node due to a -// flatten operation. The returned value will be used -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Preprocesses the accumulated transform that is about to be applied to (or + * through) this node due to a flatten operation. The returned value will be + * used instead. + */ CPT(TransformState) BillboardEffect:: prepare_flatten_transform(const TransformState *net_transform) const { - // We don't want any flatten operation to rotate the billboarded - // node, since the billboard effect should eat any rotation that - // comes in from above. + // We don't want any flatten operation to rotate the billboarded node, since + // the billboard effect should eat any rotation that comes in from above. return net_transform->set_hpr(LVecBase3(0, 0, 0)); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BillboardEffect:: output(ostream &out) const { out << get_type() << ":"; @@ -108,37 +95,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool BillboardEffect:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void BillboardEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -149,13 +127,12 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, return; } - // Since the "modelview" transform from the cull traverser already - // includes the inverse camera transform, the camera transform is - // identity. + // Since the "modelview" transform from the cull traverser already includes + // the inverse camera transform, the camera transform is identity. CPT(TransformState) camera_transform = TransformState::make_identity(); - // But if we're rotating to face something other than the camera, we - // have to compute the "camera" transform to compensate for that. + // But if we're rotating to face something other than the camera, we have to + // compute the "camera" transform to compensate for that. if (!_look_at.is_empty()) { camera_transform = trav->get_camera_transform()->invert_compose(_look_at.get_net_transform()); } @@ -163,42 +140,34 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, compute_billboard(node_transform, modelview_transform, camera_transform); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::has_adjust_transform -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if adjust_transform() has been defined, and -// therefore the RenderEffect has some effect on the -// node's apparent local and net transforms. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if + * adjust_transform() has been defined, and therefore the RenderEffect has + * some effect on the node's apparent local and net transforms. + */ bool BillboardEffect:: has_adjust_transform() const { - // A BillboardEffect can only affect the net transform when it is to - // a particular node. A billboard to a camera is camera-dependent, - // of course, so it has no effect in the absence of any particular - // camera viewing it. + // A BillboardEffect can only affect the net transform when it is to a + // particular node. A billboard to a camera is camera-dependent, of course, + // so it has no effect in the absence of any particular camera viewing it. return !_look_at.is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::adjust_transform -// Access: Public, Virtual -// Description: Performs some operation on the node's apparent net -// and/or local transforms. This will only be called if -// has_adjust_transform() is redefined to return true. -// -// Both parameters are in/out. The original transforms -// will be passed in, and they may (or may not) be -// modified in-place by the RenderEffect. -//////////////////////////////////////////////////////////////////// +/** + * Performs some operation on the node's apparent net and/or local transforms. + * This will only be called if has_adjust_transform() is redefined to return + * true. + * + * Both parameters are in/out. The original transforms will be passed in, and + * they may (or may not) be modified in-place by the RenderEffect. + */ void BillboardEffect:: adjust_transform(CPT(TransformState) &net_transform, CPT(TransformState) &node_transform, PandaNode *) const { - // A BillboardEffect can only affect the net transform when it is to - // a particular node. A billboard to a camera is camera-dependent, - // of course, so it has no effect in the absence of any particular - // camera viewing it. + // A BillboardEffect can only affect the net transform when it is to a + // particular node. A billboard to a camera is camera-dependent, of course, + // so it has no effect in the absence of any particular camera viewing it. if (_look_at.is_empty()) { return; } @@ -209,21 +178,18 @@ adjust_transform(CPT(TransformState) &net_transform, } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived BillboardEffect -// types to return a unique number indicating whether -// this BillboardEffect is equivalent to the other one. -// -// This should return 0 if the two BillboardEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two BillboardEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived BillboardEffect types to return a + * unique number indicating whether this BillboardEffect is equivalent to the + * other one. + * + * This should return 0 if the two BillboardEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two BillboardEffect objects whose get_type() + * functions return the same. + */ int BillboardEffect:: compare_to_impl(const RenderEffect *other) const { const BillboardEffect *ta; @@ -253,27 +219,23 @@ compare_to_impl(const RenderEffect *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::compute_billboard -// Access: Private -// Description: Computes the billboard operation given the parent's -// net transform and the camera transform. -// -// The result is applied to node_transform, which is -// modified in-place. -//////////////////////////////////////////////////////////////////// +/** + * Computes the billboard operation given the parent's net transform and the + * camera transform. + * + * The result is applied to node_transform, which is modified in-place. + */ void BillboardEffect:: -compute_billboard(CPT(TransformState) &node_transform, - const TransformState *net_transform, +compute_billboard(CPT(TransformState) &node_transform, + const TransformState *net_transform, const TransformState *camera_transform) const { - // First, extract out just the translation component of the node's - // local transform. This gets applied to the net transform, to - // compute the look-at direction properly. + // First, extract out just the translation component of the node's local + // transform. This gets applied to the net transform, to compute the look- + // at direction properly. CPT(TransformState) translate = TransformState::make_pos(node_transform->get_pos()); - // And then the translation gets removed from the node, but we keep - // its rotation etc., which gets applied after the billboard - // operation. + // And then the translation gets removed from the node, but we keep its + // rotation etc., which gets applied after the billboard operation. node_transform = node_transform->set_pos(LPoint3(0.0f, 0.0f, 0.0f)); CPT(TransformState) rel_transform = @@ -288,11 +250,10 @@ compute_billboard(CPT(TransformState) &node_transform, // Determine the look_at point in the camera space. LVector3 camera_pos, up; - // If this is an eye-relative Billboard, then (a) the up vector is - // relative to the camera, not to the world, and (b) the look - // direction is towards the plane that contains the camera, - // perpendicular to the forward direction, not directly to the - // camera. + // If this is an eye-relative Billboard, then (a) the up vector is relative + // to the camera, not to the world, and (b) the look direction is towards + // the plane that contains the camera, perpendicular to the forward + // direction, not directly to the camera. if (_eye_relative) { up = _up_vector * rel_mat; @@ -311,8 +272,8 @@ compute_billboard(CPT(TransformState) &node_transform, look_at(rotate, camera_pos, up); } - // Also slide the billboard geometry towards the camera according to - // the offset factor. + // Also slide the billboard geometry towards the camera according to the + // offset factor. if (_offset != 0.0f) { LVector3 translate(rel_mat(3, 0), rel_mat(3, 1), rel_mat(3, 2)); translate.normalize(); @@ -323,23 +284,18 @@ compute_billboard(CPT(TransformState) &node_transform, node_transform = translate->compose(TransformState::make_mat(rotate))->compose(node_transform); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BillboardEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BillboardEffect. + */ void BillboardEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BillboardEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); @@ -351,18 +307,14 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_offset); _look_at_point.write_datagram(dg); - // *** We don't write out the _look_at NodePath right now. Maybe - // we should. + // *** We don't write out the _look_at NodePath right now. Maybe we should. } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BillboardEffect is encountered -// in the Bam file. It should create the BillboardEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BillboardEffect is encountered in the Bam file. It should create the + * BillboardEffect and extract its information from the file. + */ TypedWritable *BillboardEffect:: make_from_bam(const FactoryParams ¶ms) { BillboardEffect *effect = new BillboardEffect; @@ -375,13 +327,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: BillboardEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BillboardEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BillboardEffect. + */ void BillboardEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); diff --git a/panda/src/pgraph/billboardEffect.h b/panda/src/pgraph/billboardEffect.h index 97c941b725..2d528453f9 100644 --- a/panda/src/pgraph/billboardEffect.h +++ b/panda/src/pgraph/billboardEffect.h @@ -1,16 +1,15 @@ -// Filename: billboardEffect.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file billboardEffect.h + * @author drose + * @date 2002-03-14 + */ #ifndef BILLBOARDEFFECT_H #define BILLBOARDEFFECT_H @@ -21,12 +20,10 @@ #include "luse.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : BillboardEffect -// Description : Indicates that geometry at this node should -// automatically rotate to face the camera, or any other -// arbitrary node. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that geometry at this node should automatically rotate to face + * the camera, or any other arbitrary node. + */ class EXPCL_PANDA_PGRAPH BillboardEffect : public RenderEffect { private: INLINE BillboardEffect(); @@ -69,8 +66,8 @@ protected: virtual int compare_to_impl(const RenderEffect *other) const; private: - void compute_billboard(CPT(TransformState) &node_transform, - const TransformState *net_transform, + void compute_billboard(CPT(TransformState) &node_transform, + const TransformState *net_transform, const TransformState *camera_transform) const; private: @@ -89,7 +86,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -111,4 +108,3 @@ private: #include "billboardEffect.I" #endif - diff --git a/panda/src/pgraph/cacheStats.I b/panda/src/pgraph/cacheStats.I index 5810f8bae1..a83e480757 100644 --- a/panda/src/pgraph/cacheStats.I +++ b/panda/src/pgraph/cacheStats.I @@ -1,23 +1,19 @@ -// Filename: cacheStats.I -// Created by: drose (24Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cacheStats.I + * @author drose + * @date 2007-07-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::maybe_report -// Access: Public -// Description: Outputs a report if enough time has elapsed. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a report if enough time has elapsed. + */ INLINE void CacheStats:: maybe_report(const char *name) { #ifndef NDEBUG @@ -32,11 +28,9 @@ maybe_report(const char *name) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::inc_hits -// Access: Public -// Description: Increments by 1 the count of cache hits. -//////////////////////////////////////////////////////////////////// +/** + * Increments by 1 the count of cache hits. + */ INLINE void CacheStats:: inc_hits() { #ifndef NDEBUG @@ -44,11 +38,9 @@ inc_hits() { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::inc_misses -// Access: Public -// Description: Increments by 1 the count of cache misses. -//////////////////////////////////////////////////////////////////// +/** + * Increments by 1 the count of cache misses. + */ INLINE void CacheStats:: inc_misses() { #ifndef NDEBUG @@ -56,13 +48,10 @@ inc_misses() { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::inc_adds -// Access: Public -// Description: Increments by 1 the count of elements added to the -// cache. If is_new is true, the element was added to a -// previously empty hashtable. -//////////////////////////////////////////////////////////////////// +/** + * Increments by 1 the count of elements added to the cache. If is_new is + * true, the element was added to a previously empty hashtable. + */ INLINE void CacheStats:: inc_adds(bool is_new) { #ifndef NDEBUG @@ -73,12 +62,9 @@ inc_adds(bool is_new) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::inc_dels -// Access: Public -// Description: Increments by 1 the count of elements removed from -// the cache. -//////////////////////////////////////////////////////////////////// +/** + * Increments by 1 the count of elements removed from the cache. + */ INLINE void CacheStats:: inc_dels() { #ifndef NDEBUG @@ -86,13 +72,10 @@ inc_dels() { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::add_total_size -// Access: Public -// Description: Adds the indicated count (positive or negative) to -// the total number of entries for the cache -// (net occupied size of all the hashtables). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated count (positive or negative) to the total number of + * entries for the cache (net occupied size of all the hashtables). + */ INLINE void CacheStats:: add_total_size(int count) { #ifndef NDEBUG @@ -100,13 +83,10 @@ add_total_size(int count) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::add_num_states -// Access: Public -// Description: Adds the indicated count (positive or negative) to -// the total count of individual RenderState or -// TransformState objects. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated count (positive or negative) to the total count of + * individual RenderState or TransformState objects. + */ INLINE void CacheStats:: add_num_states(int count) { #ifndef NDEBUG diff --git a/panda/src/pgraph/cacheStats.cxx b/panda/src/pgraph/cacheStats.cxx index aa6556db3f..88a5498384 100644 --- a/panda/src/pgraph/cacheStats.cxx +++ b/panda/src/pgraph/cacheStats.cxx @@ -1,32 +1,29 @@ -// Filename: cacheStats.cxx -// Created by: drose (24Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cacheStats.cxx + * @author drose + * @date 2007-07-24 + */ #include "cacheStats.h" -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::init -// Access: Public -// Description: Initializes the CacheStats for the first time. We -// don't use the constructor for this, since we can't -// guarantee ordering of static constructors. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the CacheStats for the first time. We don't use the + * constructor for this, since we can't guarantee ordering of static + * constructors. + */ void CacheStats:: init() { #ifndef NDEBUG // Let's not use the clock at static init time. reset(0.0); - //reset(ClockObject::get_global_clock()->get_real_time()); + // reset(ClockObject::get_global_clock()->get_real_time()); _total_cache_size = 0; _num_states = 0; @@ -35,12 +32,10 @@ init() { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::reset -// Access: Public -// Description: Reinitializes just those parts of the CacheStats that -// should be reset between each reporting interval. -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes just those parts of the CacheStats that should be reset + * between each reporting interval. + */ void CacheStats:: reset(double now) { #ifndef NDEBUG @@ -53,20 +48,18 @@ reset(double now) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: CacheStats::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CacheStats:: write(ostream &out, const char *name) const { #ifndef NDEBUG - out << name << " cache: " << _cache_hits << " hits, " + out << name << " cache: " << _cache_hits << " hits, " << _cache_misses << " misses\n" << _cache_adds + _cache_new_adds << "(" << _cache_new_adds << ") adds(new), " << _cache_dels << " dels, " << _total_cache_size << " / " << _num_states << " = " - << (double)_total_cache_size / (double)_num_states + << (double)_total_cache_size / (double)_num_states << " average cache size\n"; #endif // NDEBUG } diff --git a/panda/src/pgraph/cacheStats.h b/panda/src/pgraph/cacheStats.h index 3c2239f4b2..45fb1e6043 100644 --- a/panda/src/pgraph/cacheStats.h +++ b/panda/src/pgraph/cacheStats.h @@ -1,16 +1,15 @@ -// Filename: cacheStats.h -// Created by: drose (24Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cacheStats.h + * @author drose + * @date 2007-07-24 + */ #ifndef CACHESTATS_H #define CACHESTATS_H @@ -19,12 +18,10 @@ #include "clockObject.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : CacheStats -// Description : This is used to track the utilization of the -// TransformState and RenderState caches, for low-level -// performance tuning information. -//////////////////////////////////////////////////////////////////// +/** + * This is used to track the utilization of the TransformState and RenderState + * caches, for low-level performance tuning information. + */ class EXPCL_PANDA_PGRAPH CacheStats { public: void init(); diff --git a/panda/src/pgraph/camera.I b/panda/src/pgraph/camera.I index a1d5cc1f58..7da5a9d4c9 100644 --- a/panda/src/pgraph/camera.I +++ b/panda/src/pgraph/camera.I @@ -1,272 +1,209 @@ -// Filename: camera.I -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file camera.I + * @author drose + * @date 2002-02-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_active -// Access: Published -// Description: Sets the active flag on the camera. When the camera -// is not active, nothing will be rendered. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag on the camera. When the camera is not active, nothing + * will be rendered. + */ INLINE void Camera:: set_active(bool active) { _active = active; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::is_active -// Access: Published -// Description: Returns the current setting of the active flag on the -// camera. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the active flag on the camera. + */ INLINE bool Camera:: is_active() const { return _active; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_scene -// Access: Published -// Description: Sets the scene that will be rendered by the camera. -// This is normally the root node of a scene graph, -// typically a node called 'render', although it could -// represent the root of any subgraph. -// -// Note that the use of this method is now deprecated. -// In the absence of an explicit scene set on the -// camera, the camera will render whatever scene it is -// parented into. This is the preferred way to specify -// the scene, since it is the more intuitive mechanism. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scene that will be rendered by the camera. This is normally the + * root node of a scene graph, typically a node called 'render', although it + * could represent the root of any subgraph. + * + * Note that the use of this method is now deprecated. In the absence of an + * explicit scene set on the camera, the camera will render whatever scene it + * is parented into. This is the preferred way to specify the scene, since it + * is the more intuitive mechanism. + */ INLINE void Camera:: set_scene(const NodePath &scene) { _scene = scene; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_scene -// Access: Published -// Description: Returns the scene that will be rendered by the -// camera. See set_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene that will be rendered by the camera. See set_scene(). + */ INLINE const NodePath &Camera:: get_scene() const { return _scene; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_num_display_regions -// Access: Published -// Description: Returns the number of display regions associated with -// the camera. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of display regions associated with the camera. + */ INLINE int Camera:: get_num_display_regions() const { return _display_regions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_display_region -// Access: Published -// Description: Returns the nth display region associated with the -// camera. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth display region associated with the camera. + */ INLINE DisplayRegionBase *Camera:: get_display_region(int n) const { nassertr(n >= 0 && n < (int)_display_regions.size(), (DisplayRegionBase *)NULL); return _display_regions[n]; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_camera_mask -// Access: Published -// Description: Changes the set of bits that represent the subset of -// the scene graph the camera will render. -// -// During the cull traversal, a node is not visited if -// none of its draw mask bits intersect with the -// camera's camera mask bits. These masks can be used -// to selectively hide and show different parts of the -// scene graph from different cameras that are otherwise -// viewing the same scene. -//////////////////////////////////////////////////////////////////// +/** + * Changes the set of bits that represent the subset of the scene graph the + * camera will render. + * + * During the cull traversal, a node is not visited if none of its draw mask + * bits intersect with the camera's camera mask bits. These masks can be used + * to selectively hide and show different parts of the scene graph from + * different cameras that are otherwise viewing the same scene. + */ INLINE void Camera:: set_camera_mask(DrawMask mask) { - // You shouldn't attempt to use Panda's reserved "overall" bit as a - // camera mask. + // You shouldn't attempt to use Panda's reserved "overall" bit as a camera + // mask. nassertv((mask & PandaNode::get_overall_bit()).is_zero()); _camera_mask = mask; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_camera_mask -// Access: Published -// Description: Returns the set of bits that represent the subset of -// the scene graph the camera will render. See -// set_camera_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of bits that represent the subset of the scene graph the + * camera will render. See set_camera_mask(). + */ INLINE DrawMask Camera:: get_camera_mask() const { return _camera_mask; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_cull_center -// Access: Published -// Description: Specifies the point from which the culling operations -// are performed. Normally, this is the same as the -// camera, and that is the default if this is not -// specified; but it may sometimes be useful to perform -// the culling from some other viewpoint, particularly -// when you are debugging the culling itself. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point from which the culling operations are performed. + * Normally, this is the same as the camera, and that is the default if this + * is not specified; but it may sometimes be useful to perform the culling + * from some other viewpoint, particularly when you are debugging the culling + * itself. + */ INLINE void Camera:: set_cull_center(const NodePath &cull_center) { _cull_center = cull_center; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_cull_center -// Access: Published -// Description: Returns the point from which the culling operations -// will be performed, if it was set by -// set_cull_center(), or the empty NodePath otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point from which the culling operations will be performed, if + * it was set by set_cull_center(), or the empty NodePath otherwise. + */ INLINE const NodePath &Camera:: get_cull_center() const { return _cull_center; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_cull_bounds -// Access: Published -// Description: Specifies the bounding volume that should be used to -// perform culling from this camera. Normally, this is -// the bounding volume returned from the active lens' -// make_bounds() call, but you may override this to -// specify a custom volume if you require. The -// specified bounding volume will be understood to be in -// the coordinate space of the get_cull_center() node. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the bounding volume that should be used to perform culling from + * this camera. Normally, this is the bounding volume returned from the + * active lens' make_bounds() call, but you may override this to specify a + * custom volume if you require. The specified bounding volume will be + * understood to be in the coordinate space of the get_cull_center() node. + */ INLINE void Camera:: set_cull_bounds(BoundingVolume *cull_bounds) { _cull_bounds = cull_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_cull_bounds -// Access: Published -// Description: Returns the custom cull volume that was set by -// set_cull_bounds(), if any, or NULL if no custom cull -// volume was set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the custom cull volume that was set by set_cull_bounds(), if any, + * or NULL if no custom cull volume was set. + */ INLINE BoundingVolume *Camera:: get_cull_bounds() const { return _cull_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_lod_center -// Access: Published -// Description: Specifies the point from which the LOD distances -// are measured. Normally, this is the same as the -// camera, and that is the default if this is not -// specified; but it may sometimes be useful to perform -// the distance test from some other viewpoint. This -// may be used, for instance, to reduce LOD popping when -// the camera rotates in a small circle about an avatar. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point from which the LOD distances are measured. Normally, + * this is the same as the camera, and that is the default if this is not + * specified; but it may sometimes be useful to perform the distance test from + * some other viewpoint. This may be used, for instance, to reduce LOD + * popping when the camera rotates in a small circle about an avatar. + */ INLINE void Camera:: set_lod_center(const NodePath &lod_center) { _lod_center = lod_center; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_lod_center -// Access: Published -// Description: Returns the point from which the LOD distances will -// be measured, if it was set by set_lod_center(), or -// the empty NodePath otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point from which the LOD distances will be measured, if it was + * set by set_lod_center(), or the empty NodePath otherwise. + */ INLINE const NodePath &Camera:: get_lod_center() const { return _lod_center; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_initial_state -// Access: Published -// Description: Sets the initial state which is applied to all nodes -// in the scene, as if it were set at the top of the -// scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Sets the initial state which is applied to all nodes in the scene, as if it + * were set at the top of the scene graph. + */ INLINE void Camera:: set_initial_state(const RenderState *state) { _initial_state = state; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_initial_state -// Access: Published -// Description: Returns the initial state as set by a previous call -// to set_initial_state(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the initial state as set by a previous call to set_initial_state(). + */ INLINE CPT(RenderState) Camera:: get_initial_state() const { return _initial_state; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_tag_state_key -// Access: Published -// Description: Sets the tag key which, when encountered as a tag on -// nodes in the scene graph, causes this Camera to apply -// an arbitrary state transition based on the value of -// the tag (as specified to set_tag_state()). -//////////////////////////////////////////////////////////////////// +/** + * Sets the tag key which, when encountered as a tag on nodes in the scene + * graph, causes this Camera to apply an arbitrary state transition based on + * the value of the tag (as specified to set_tag_state()). + */ INLINE void Camera:: set_tag_state_key(const string &tag_state_key) { _tag_state_key = tag_state_key; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_tag_state_key -// Access: Published -// Description: Returns the tag key as set by a previous call to -// set_tag_state_key(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the tag key as set by a previous call to set_tag_state_key(). + */ INLINE const string &Camera:: get_tag_state_key() const { return _tag_state_key; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_lod_scale -// Access: Published -// Description: Returns the multiplier for LOD distances. -//////////////////////////////////////////////////////////////////// +/** + * Returns the multiplier for LOD distances. + */ INLINE PN_stdfloat Camera:: get_lod_scale() const { return _lod_scale; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_lod_scale -// Access: Published -// Description: Sets the multiplier for LOD distances. This value -// is multiplied with the LOD scale set on LodNodes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the multiplier for LOD distances. This value is multiplied with the + * LOD scale set on LodNodes. + */ INLINE void Camera:: set_lod_scale(PN_stdfloat value) { _lod_scale = value; diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index e32b3968ca..e2e1bef0f9 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -1,16 +1,15 @@ -// Filename: camera.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file camera.cxx + * @author drose + * @date 2002-02-26 + */ #include "pandabase.h" #include "camera.h" @@ -19,11 +18,9 @@ TypeHandle Camera::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Camera::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Camera:: Camera(const string &name, Lens *lens) : LensNode(name, lens), @@ -34,11 +31,9 @@ Camera(const string &name, Lens *lens) : set_lod_scale(1.0); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Camera:: Camera(const Camera ©) : LensNode(copy), @@ -52,110 +47,85 @@ Camera(const Camera ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Camera::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Camera:: ~Camera() { - // We don't have to destroy the display region(s) associated with - // the camera; they're responsible for themselves. However, they - // should have removed themselves before we destruct, or something - // went wrong. + // We don't have to destroy the display region(s) associated with the + // camera; they're responsible for themselves. However, they should have + // removed themselves before we destruct, or something went wrong. nassertv(_display_regions.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *Camera:: make_copy() const { return new Camera(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool Camera:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a Character. + */ bool Camera:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_tag_state -// Access: Published -// Description: Associates a particular state transition with the -// indicated tag value. When a node is encountered -// during traversal with the tag key specified by -// set_tag_state_key(), if the value of that tag matches -// tag_state, then the indicated state is applied to -// this node--but only when it is rendered by this -// camera. -// -// This can be used to apply special effects to nodes -// when they are rendered by certain cameras. It is -// particularly useful for multipass rendering, in which -// specialty cameras might be needed to render the scene -// with a particular set of effects. -//////////////////////////////////////////////////////////////////// +/** + * Associates a particular state transition with the indicated tag value. + * When a node is encountered during traversal with the tag key specified by + * set_tag_state_key(), if the value of that tag matches tag_state, then the + * indicated state is applied to this node--but only when it is rendered by + * this camera. + * + * This can be used to apply special effects to nodes when they are rendered + * by certain cameras. It is particularly useful for multipass rendering, in + * which specialty cameras might be needed to render the scene with a + * particular set of effects. + */ void Camera:: set_tag_state(const string &tag_state, const RenderState *state) { _tag_states[tag_state] = state; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::clear_tag_state -// Access: Published -// Description: Removes the association established by a previous -// call to set_tag_state(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the association established by a previous call to set_tag_state(). + */ void Camera:: clear_tag_state(const string &tag_state) { _tag_states.erase(tag_state); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::clear_tag_state -// Access: Published -// Description: Removes all associations established by previous -// calls to set_tag_state(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all associations established by previous calls to set_tag_state(). + */ void Camera:: clear_tag_states() { _tag_states.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::has_tag_state -// Access: Published -// Description: Returns true if set_tag_state() has previously been -// called with the indicated tag state, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_tag_state() has previously been called with the + * indicated tag state, false otherwise. + */ bool Camera:: has_tag_state(const string &tag_state) const { TagStates::const_iterator tsi; @@ -163,13 +133,10 @@ has_tag_state(const string &tag_state) const { return (tsi != _tag_states.end()); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_tag_state -// Access: Published -// Description: Returns the state associated with the indicated tag -// state by a previous call to set_tag_state(), or the -// empty state if nothing has been associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the state associated with the indicated tag state by a previous + * call to set_tag_state(), or the empty state if nothing has been associated. + */ CPT(RenderState) Camera:: get_tag_state(const string &tag_state) const { TagStates::const_iterator tsi; @@ -180,13 +147,10 @@ get_tag_state(const string &tag_state) const { return RenderState::make_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::set_aux_scene_data -// Access: Published -// Description: Associates the indicated AuxSceneData object with the -// given NodePath, possibly replacing a previous -// data defined for the same NodePath, if any. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated AuxSceneData object with the given NodePath, + * possibly replacing a previous data defined for the same NodePath, if any. + */ void Camera:: set_aux_scene_data(const NodePath &node_path, AuxSceneData *data) { if (data == (AuxSceneData *)NULL) { @@ -196,13 +160,10 @@ set_aux_scene_data(const NodePath &node_path, AuxSceneData *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: Camera::clear_aux_scene_data -// Access: Published -// Description: Removes the AuxSceneData associated with the -// indicated NodePath. Returns true if it is removed -// successfully, false if it was already gone. -//////////////////////////////////////////////////////////////////// +/** + * Removes the AuxSceneData associated with the indicated NodePath. Returns + * true if it is removed successfully, false if it was already gone. + */ bool Camera:: clear_aux_scene_data(const NodePath &node_path) { AuxData::iterator ai; @@ -215,12 +176,10 @@ clear_aux_scene_data(const NodePath &node_path) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::get_aux_scene_data -// Access: Published -// Description: Returns the AuxSceneData associated with the -// indicated NodePath, or NULL if nothing is associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AuxSceneData associated with the indicated NodePath, or NULL if + * nothing is associated. + */ AuxSceneData *Camera:: get_aux_scene_data(const NodePath &node_path) const { AuxData::const_iterator ai; @@ -232,12 +191,9 @@ get_aux_scene_data(const NodePath &node_path) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::list_aux_scene_data -// Access: Published -// Description: Outputs all of the NodePaths and AuxSceneDatas in -// use. -//////////////////////////////////////////////////////////////////// +/** + * Outputs all of the NodePaths and AuxSceneDatas in use. + */ void Camera:: list_aux_scene_data(ostream &out) const { out << _aux_data.size() << " data objects held:\n"; @@ -247,14 +203,11 @@ list_aux_scene_data(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Camera::cleanup_aux_scene_data -// Access: Published -// Description: Walks through the list of currently-assigned -// AuxSceneData objects and releases any that are -// past their expiration times. Returns the number of -// elements released. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the list of currently-assigned AuxSceneData objects and + * releases any that are past their expiration times. Returns the number of + * elements released. + */ int Camera:: cleanup_aux_scene_data(Thread *current_thread) { int num_deleted = 0; @@ -278,25 +231,19 @@ cleanup_aux_scene_data(Thread *current_thread) { return num_deleted; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::add_display_region -// Access: Private -// Description: Adds the indicated DisplayRegion to the set of -// DisplayRegions shared by the camera. This is only -// intended to be called from the DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated DisplayRegion to the set of DisplayRegions shared by the + * camera. This is only intended to be called from the DisplayRegion. + */ void Camera:: add_display_region(DisplayRegionBase *display_region) { _display_regions.push_back(display_region); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::remove_display_region -// Access: Private -// Description: Removes the indicated DisplayRegion from the set of -// DisplayRegions shared by the camera. This is only -// intended to be called from the DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated DisplayRegion from the set of DisplayRegions shared + * by the camera. This is only intended to be called from the DisplayRegion. + */ void Camera:: remove_display_region(DisplayRegionBase *display_region) { DisplayRegions::iterator dri = @@ -306,23 +253,18 @@ remove_display_region(DisplayRegionBase *display_region) { } } -//////////////////////////////////////////////////////////////////// -// Function: Camera::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Camera. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Camera. + */ void Camera:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Camera:: write_datagram(BamWriter *manager, Datagram &dg) { LensNode::write_datagram(manager, dg); @@ -331,14 +273,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint32(_camera_mask.get_word()); } -//////////////////////////////////////////////////////////////////// -// Function: Camera::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Camera is encountered -// in the Bam file. It should create the Camera -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Camera is encountered in the Bam file. It should create the Camera + * and extract its information from the file. + */ TypedWritable *Camera:: make_from_bam(const FactoryParams ¶ms) { Camera *node = new Camera(""); @@ -351,13 +290,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: Camera::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Camera. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Camera. + */ void Camera:: fillin(DatagramIterator &scan, BamReader *manager) { LensNode::fillin(scan, manager); diff --git a/panda/src/pgraph/camera.h b/panda/src/pgraph/camera.h index 35b21b8894..71b15ec243 100644 --- a/panda/src/pgraph/camera.h +++ b/panda/src/pgraph/camera.h @@ -1,16 +1,15 @@ -// Filename: camera.h -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file camera.h + * @author drose + * @date 2002-02-26 + */ #ifndef CAMERA_H #define CAMERA_H @@ -28,12 +27,10 @@ #include "auxSceneData.h" #include "displayRegionBase.h" -//////////////////////////////////////////////////////////////////// -// Class : Camera -// Description : A node that can be positioned around in the scene -// graph to represent a point of view for rendering a -// scene. -//////////////////////////////////////////////////////////////////// +/** + * A node that can be positioned around in the scene graph to represent a + * point of view for rendering a scene. + */ class EXPCL_PANDA_PGRAPH Camera : public LensNode { PUBLISHED: explicit Camera(const string &name, Lens *lens = new PerspectiveLens()); diff --git a/panda/src/pgraph/clipPlaneAttrib.I b/panda/src/pgraph/clipPlaneAttrib.I index 41d50c3408..49167ec5a3 100644 --- a/panda/src/pgraph/clipPlaneAttrib.I +++ b/panda/src/pgraph/clipPlaneAttrib.I @@ -1,36 +1,28 @@ -// Filename: clipPlaneAttrib.I -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clipPlaneAttrib.I + * @author drose + * @date 2002-07-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::Constructor -// Access: Protected -// Description: Use ClipPlaneAttrib::make() to construct a new -// ClipPlaneAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ClipPlaneAttrib::make() to construct a new ClipPlaneAttrib object. + */ INLINE ClipPlaneAttrib:: ClipPlaneAttrib() { _off_all_planes = false; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::Copy Constructor -// Access: Protected -// Description: Use ClipPlaneAttrib::make() to construct a new -// ClipPlaneAttrib object. The copy constructor is only -// defined to facilitate methods like add_on_plane(). -//////////////////////////////////////////////////////////////////// +/** + * Use ClipPlaneAttrib::make() to construct a new ClipPlaneAttrib object. The + * copy constructor is only defined to facilitate methods like add_on_plane(). + */ INLINE ClipPlaneAttrib:: ClipPlaneAttrib(const ClipPlaneAttrib ©) : _on_planes(copy._on_planes), @@ -39,107 +31,84 @@ ClipPlaneAttrib(const ClipPlaneAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_num_on_planes -// Access: Published -// Description: Returns the number of planes that are enabled by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of planes that are enabled by the attribute. + */ INLINE int ClipPlaneAttrib:: get_num_on_planes() const { return _on_planes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_on_plane -// Access: Published -// Description: Returns the nth plane enabled by the attribute, -// sorted in render order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth plane enabled by the attribute, sorted in render order. + */ INLINE NodePath ClipPlaneAttrib:: get_on_plane(int n) const { nassertr(n >= 0 && n < (int)_on_planes.size(), NodePath::fail()); return _on_planes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::has_on_plane -// Access: Published -// Description: Returns true if the indicated plane is enabled by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated plane is enabled by the attrib, false + * otherwise. + */ INLINE bool ClipPlaneAttrib:: has_on_plane(const NodePath &plane) const { return _on_planes.find(plane) != _on_planes.end(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_num_off_planes -// Access: Published -// Description: Returns the number of planes that are disabled by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of planes that are disabled by the attribute. + */ INLINE int ClipPlaneAttrib:: get_num_off_planes() const { return _off_planes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_off_plane -// Access: Published -// Description: Returns the nth plane disabled by the attribute, -// sorted in arbitrary (pointer) order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth plane disabled by the attribute, sorted in arbitrary + * (pointer) order. + */ INLINE NodePath ClipPlaneAttrib:: get_off_plane(int n) const { nassertr(n >= 0 && n < (int)_off_planes.size(), NodePath::fail()); return _off_planes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::has_off_plane -// Access: Published -// Description: Returns true if the indicated plane is disabled by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated plane is disabled by the attrib, false + * otherwise. + */ INLINE bool ClipPlaneAttrib:: has_off_plane(const NodePath &plane) const { return _off_planes.find(plane) != _off_planes.end() || (_off_all_planes && !has_on_plane(plane)); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::has_all_off -// Access: Published -// Description: Returns true if this attrib disables all planes -// (although it may also enable some). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this attrib disables all planes (although it may also + * enable some). + */ INLINE bool ClipPlaneAttrib:: has_all_off() const { return _off_all_planes; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::is_identity -// Access: Published -// Description: Returns true if this is an identity attrib: it does -// not change the set of planes in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an identity attrib: it does not change the set of + * planes in use. + */ INLINE bool ClipPlaneAttrib:: is_identity() const { return _on_planes.empty() && _off_planes.empty() && !_off_all_planes; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::check_filtered -// Access: Private -// Description: Confirms whether the _filtered table is still valid. -// It may become invalid if someone calls -// PlaneNode::set_priority(). -// -// If the table is invalid, transparently empties it -// before returning. -//////////////////////////////////////////////////////////////////// +/** + * Confirms whether the _filtered table is still valid. It may become invalid + * if someone calls PlaneNode::set_priority(). + * + * If the table is invalid, transparently empties it before returning. + */ INLINE void ClipPlaneAttrib:: check_filtered() const { if (_sort_seq != PlaneNode::get_sort_seq()) { diff --git a/panda/src/pgraph/clipPlaneAttrib.cxx b/panda/src/pgraph/clipPlaneAttrib.cxx index 74a7d31bf7..d36817a20d 100644 --- a/panda/src/pgraph/clipPlaneAttrib.cxx +++ b/panda/src/pgraph/clipPlaneAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: clipPlaneAttrib.cxx -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clipPlaneAttrib.cxx + * @author drose + * @date 2002-07-11 + */ #include "clipPlaneAttrib.h" #include "pandaNode.h" @@ -28,8 +27,8 @@ CPT(RenderAttrib) ClipPlaneAttrib::_all_off_attrib; TypeHandle ClipPlaneAttrib::_type_handle; int ClipPlaneAttrib::_attrib_slot; -// This STL Function object is used in filter_to_max(), below, to sort -// a list of PlaneNodes in reverse order by priority. +// This STL Function object is used in filter_to_max(), below, to sort a list +// of PlaneNodes in reverse order by priority. class ComparePlaneNodePriorities { public: bool operator ()(const NodePath &a, const NodePath &b) const { @@ -37,20 +36,18 @@ public: PlaneNode *pa = DCAST(PlaneNode, a.node()); PlaneNode *pb = DCAST(PlaneNode, b.node()); nassertr(pa != (PlaneNode *)NULL && pb != (PlaneNode *)NULL, a < b); - + return pa->get_priority() > pb->get_priority(); } }; -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that enables (or -// disables, according to op) the indicated plane(s). -// -// This method is now deprecated. Use add_on_plane() or -// add_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that enables (or disables, + * according to op) the indicated plane(s). + * + * This method is now deprecated. Use add_on_plane() or add_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make(ClipPlaneAttrib::Operation op, PlaneNode *plane) { pgraph_cat.warning() @@ -63,7 +60,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane) { attrib = make_all_off(); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane)); return attrib; - + case O_add: attrib = make(); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane)); @@ -79,15 +76,13 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane) { return make(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that turns on (or -// off, according to op) the indicate plane(s). -// -// This method is now deprecated. Use add_on_plane() or -// add_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that turns on (or off, according to + * op) the indicate plane(s). + * + * This method is now deprecated. Use add_on_plane() or add_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2) { pgraph_cat.warning() @@ -101,7 +96,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2) { attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane1)); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane2)); return attrib; - + case O_add: attrib = make(); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane1)); @@ -119,15 +114,13 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2) { return make(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that turns on (or -// off, according to op) the indicate plane(s). -// -// This method is now deprecated. Use add_on_plane() or -// add_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that turns on (or off, according to + * op) the indicate plane(s). + * + * This method is now deprecated. Use add_on_plane() or add_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, PlaneNode *plane3) { @@ -143,7 +136,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane2)); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane3)); return attrib; - + case O_add: attrib = make(); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane1)); @@ -163,15 +156,13 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, return make(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that turns on (or -// off, according to op) the indicate plane(s). -// -// This method is now deprecated. Use add_on_plane() or -// add_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that turns on (or off, according to + * op) the indicate plane(s). + * + * This method is now deprecated. Use add_on_plane() or add_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, PlaneNode *plane3, PlaneNode *plane4) { @@ -188,7 +179,7 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane3)); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane4)); return attrib; - + case O_add: attrib = make(); attrib = DCAST(ClipPlaneAttrib, attrib)->add_on_plane(NodePath(plane1)); @@ -210,34 +201,26 @@ make(ClipPlaneAttrib::Operation op, PlaneNode *plane1, PlaneNode *plane2, return make(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make_default() { return return_new(new ClipPlaneAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_operation -// Access: Published -// Description: Returns the basic operation type of the ClipPlaneAttrib. -// If this is O_set, the planes listed here completely -// replace any planes that were already on. If this is -// O_add, the planes here are added to the set of of -// planes that were already on, and if O_remove, the -// planes here are removed from the set of planes that -// were on. -// -// This method is now deprecated. ClipPlaneAttribs -// nowadays have a separate list of on_planes and -// off_planes, so this method doesn't make sense. Query -// the lists independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basic operation type of the ClipPlaneAttrib. If this is O_set, + * the planes listed here completely replace any planes that were already on. + * If this is O_add, the planes here are added to the set of of planes that + * were already on, and if O_remove, the planes here are removed from the set + * of planes that were on. + * + * This method is now deprecated. ClipPlaneAttribs nowadays have a separate + * list of on_planes and off_planes, so this method doesn't make sense. Query + * the lists independently. + */ ClipPlaneAttrib::Operation ClipPlaneAttrib:: get_operation() const { pgraph_cat.warning() @@ -254,16 +237,13 @@ get_operation() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_num_planes -// Access: Published -// Description: Returns the number of planes listed in the attribute. -// -// This method is now deprecated. ClipPlaneAttribs -// nowadays have a separate list of on_planes and -// off_planes, so this method doesn't make sense. Query -// the lists independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of planes listed in the attribute. + * + * This method is now deprecated. ClipPlaneAttribs nowadays have a separate + * list of on_planes and off_planes, so this method doesn't make sense. Query + * the lists independently. + */ int ClipPlaneAttrib:: get_num_planes() const { pgraph_cat.warning() @@ -276,16 +256,13 @@ get_num_planes() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_plane -// Access: Published -// Description: Returns the nth plane listed in the attribute. -// -// This method is now deprecated. ClipPlaneAttribs -// nowadays have a separate list of on_planes and -// off_planes, so this method doesn't make sense. Query -// the lists independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth plane listed in the attribute. + * + * This method is now deprecated. ClipPlaneAttribs nowadays have a separate + * list of on_planes and off_planes, so this method doesn't make sense. Query + * the lists independently. + */ PlaneNode *ClipPlaneAttrib:: get_plane(int n) const { pgraph_cat.warning() @@ -298,17 +275,14 @@ get_plane(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::has_plane -// Access: Published -// Description: Returns true if the indicated plane is listed in the -// attrib, false otherwise. -// -// This method is now deprecated. ClipPlaneAttribs -// nowadays have a separate list of on_planes and -// off_planes, so this method doesn't make sense. Query -// the lists independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated plane is listed in the attrib, false + * otherwise. + * + * This method is now deprecated. ClipPlaneAttribs nowadays have a separate + * list of on_planes and off_planes, so this method doesn't make sense. Query + * the lists independently. + */ bool ClipPlaneAttrib:: has_plane(PlaneNode *plane) const { pgraph_cat.warning() @@ -321,15 +295,13 @@ has_plane(PlaneNode *plane) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::add_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane added to the list of planes. -// -// This method is now deprecated. Use add_on_plane() or -// add_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane added to the list of planes. + * + * This method is now deprecated. Use add_on_plane() or add_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: add_plane(PlaneNode *plane) const { pgraph_cat.warning() @@ -342,16 +314,13 @@ add_plane(PlaneNode *plane) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::remove_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane removed from the list of -// planes. -// -// This method is now deprecated. Use remove_on_plane() -// or remove_off_plane() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane removed from the list of planes. + * + * This method is now deprecated. Use remove_on_plane() or remove_off_plane() + * instead. + */ CPT(RenderAttrib) ClipPlaneAttrib:: remove_plane(PlaneNode *plane) const { pgraph_cat.warning() @@ -364,16 +333,13 @@ remove_plane(PlaneNode *plane) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that does nothing. + */ CPT(RenderAttrib) ClipPlaneAttrib:: make() { - // We make it a special case and store a pointer to the empty attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty attrib forever + // once we find it the first time, as an optimization. if (_empty_attrib == (RenderAttrib *)NULL) { _empty_attrib = return_new(new ClipPlaneAttrib); } @@ -381,16 +347,14 @@ make() { return _empty_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make_all_off -// Access: Published, Static -// Description: Constructs a new ClipPlaneAttrib object that disables -// all planes (and hence disables clipping). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ClipPlaneAttrib object that disables all planes (and hence + * disables clipping). + */ CPT(RenderAttrib) ClipPlaneAttrib:: make_all_off() { - // We make it a special case and store a pointer to the off attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the off attrib forever + // once we find it the first time, as an optimization. if (_all_off_attrib == (RenderAttrib *)NULL) { ClipPlaneAttrib *attrib = new ClipPlaneAttrib; attrib->_off_all_planes = true; @@ -400,13 +364,10 @@ make_all_off() { return _all_off_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::add_on_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane added to the list of planes -// enabled by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane added to the list of planes enabled by this attrib. + */ CPT(RenderAttrib) ClipPlaneAttrib:: add_on_plane(const NodePath &plane) const { nassertr(!plane.is_empty() && plane.node()->is_of_type(PlaneNode::get_class_type()), this); @@ -414,7 +375,7 @@ add_on_plane(const NodePath &plane) const { attrib->_on_planes.insert(plane); attrib->_off_planes.erase(plane); - pair insert_result = + pair insert_result = attrib->_on_planes.insert(Planes::value_type(plane)); if (insert_result.second) { // Also ensure it is removed from the off_planes list. @@ -424,13 +385,10 @@ add_on_plane(const NodePath &plane) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::remove_on_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane removed from the list of -// planes enabled by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane removed from the list of planes enabled by this attrib. + */ CPT(RenderAttrib) ClipPlaneAttrib:: remove_on_plane(const NodePath &plane) const { nassertr(!plane.is_empty() && plane.node()->is_of_type(PlaneNode::get_class_type()), this); @@ -439,13 +397,10 @@ remove_on_plane(const NodePath &plane) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::add_off_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane added to the list of planes -// disabled by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane added to the list of planes disabled by this attrib. + */ CPT(RenderAttrib) ClipPlaneAttrib:: add_off_plane(const NodePath &plane) const { nassertr(!plane.is_empty() && plane.node()->is_of_type(PlaneNode::get_class_type()), this); @@ -457,13 +412,10 @@ add_off_plane(const NodePath &plane) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::remove_off_plane -// Access: Published -// Description: Returns a new ClipPlaneAttrib, just like this one, but -// with the indicated plane removed from the list of -// planes disabled by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, just like this one, but with the indicated + * plane removed from the list of planes disabled by this attrib. + */ CPT(RenderAttrib) ClipPlaneAttrib:: remove_off_plane(const NodePath &plane) const { nassertr(!plane.is_empty() && plane.node()->is_of_type(PlaneNode::get_class_type()), this); @@ -472,14 +424,11 @@ remove_off_plane(const NodePath &plane) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::filter_to_max -// Access: Public -// Description: Returns a new ClipPlaneAttrib, very much like this one, -// but with the number of on_planes reduced to be no -// more than max_clip_planes. The number of off_planes in -// the new ClipPlaneAttrib is undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ClipPlaneAttrib, very much like this one, but with the number + * of on_planes reduced to be no more than max_clip_planes. The number of + * off_planes in the new ClipPlaneAttrib is undefined. + */ CPT(ClipPlaneAttrib) ClipPlaneAttrib:: filter_to_max(int max_clip_planes) const { if (max_clip_planes < 0 || (int)_on_planes.size() <= max_clip_planes) { @@ -487,8 +436,8 @@ filter_to_max(int max_clip_planes) const { return this; } - // Since check_filtered() will clear the _filtered list if we are out - // of date, we should call it first. + // Since check_filtered() will clear the _filtered list if we are out of + // date, we should call it first. check_filtered(); Filtered::const_iterator fi; @@ -499,12 +448,12 @@ filter_to_max(int max_clip_planes) const { return (*fi).second; } - // Harder case: we have to compute it now. We must choose the n - // planeNodes with the highest priority in our list of planeNodes. + // Harder case: we have to compute it now. We must choose the n planeNodes + // with the highest priority in our list of planeNodes. Planes priority_planes = _on_planes; // This sort function uses the STL function object defined above. - sort(priority_planes.begin(), priority_planes.end(), + sort(priority_planes.begin(), priority_planes.end(), ComparePlaneNodePriorities()); // Now lop off all of the planeNodes after the first max_clip_planes. @@ -520,34 +469,29 @@ filter_to_max(int max_clip_planes) const { CPT(RenderAttrib) new_attrib = return_new(attrib); - // Finally, record this newly-created attrib in the map for next - // time. + // Finally, record this newly-created attrib in the map for next time. CPT(ClipPlaneAttrib) planeNode_attrib = (const ClipPlaneAttrib *)new_attrib.p(); ((ClipPlaneAttrib *)this)->_filtered[max_clip_planes] = planeNode_attrib; return planeNode_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::compose_off -// Access: Public -// Description: This is a special method which composes two -// ClipPlaneAttribs with regard only to their set of -// "off" clip planes, for the purposes of deriving -// PandaNode::get_off_clip_planes(). -// -// The result will be a ClipPlaneAttrib that represents -// the union of all of the clip planes turned off in -// either attrib. The set of on planes in the result is -// undefined and should be ignored. -//////////////////////////////////////////////////////////////////// +/** + * This is a special method which composes two ClipPlaneAttribs with regard + * only to their set of "off" clip planes, for the purposes of deriving + * PandaNode::get_off_clip_planes(). + * + * The result will be a ClipPlaneAttrib that represents the union of all of + * the clip planes turned off in either attrib. The set of on planes in the + * result is undefined and should be ignored. + */ CPT(RenderAttrib) ClipPlaneAttrib:: compose_off(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; DCAST_INTO_R(ta, other, 0); if (_off_all_planes || (!ta->_off_all_planes && ta->_off_planes.empty())) { - // If we turn off all planes, or the other turns none off, the - // result is the same as this one. + // If we turn off all planes, or the other turns none off, the result is + // the same as this one. return this; } @@ -561,21 +505,21 @@ compose_off(const RenderAttrib *other) const { // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_attrib->_on_planes); - while (ai != _off_planes.end() && + while (ai != _off_planes.end() && bi != ta->_off_planes.end()) { if ((*ai) < (*bi)) { - // Here is a plane that we have in the original, which is not - // present in the secondary. + // Here is a plane that we have in the original, which is not present in + // the secondary. *result = *ai; ++ai; ++result; } else if ((*bi) < (*ai)) { - // Here is a new plane we have in the secondary, that was not - // present in the original. + // Here is a new plane we have in the secondary, that was not present in + // the original. *result = *bi; ++bi; ++result; @@ -604,11 +548,9 @@ compose_off(const RenderAttrib *other) const { return return_new(new_attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ClipPlaneAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -639,7 +581,7 @@ output(ostream &out) const { out << " on"; } } - + Planes::const_iterator li; for (li = _on_planes.begin(); li != _on_planes.end(); ++li) { NodePath plane = (*li); @@ -647,21 +589,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ClipPlaneAttrib -// types to return a unique number indicating whether -// this ClipPlaneAttrib is equivalent to the other one. -// -// This should return 0 if the two ClipPlaneAttrib -// objects are equivalent, a number less than zero if -// this one should be sorted before the other one, and a -// number greater than zero otherwise. -// -// This will only be called with two ClipPlaneAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ClipPlaneAttrib types to return a + * unique number indicating whether this ClipPlaneAttrib is equivalent to the + * other one. + * + * This should return 0 if the two ClipPlaneAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ClipPlaneAttrib objects whose get_type() + * functions return the same. + */ int ClipPlaneAttrib:: compare_to_impl(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; @@ -716,20 +655,16 @@ compare_to_impl(const RenderAttrib *other) const { if (ofi != ta->_off_planes.end()) { return -1; } - + return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ClipPlaneAttrib:: get_hash_impl() const { size_t hash = 0; @@ -740,8 +675,8 @@ get_hash_impl() const { hash = plane.add_hash(hash); } - // This bool value goes here, between the two lists, to - // differentiate between the two. + // This bool value goes here, between the two lists, to differentiate + // between the two. hash = int_hash::add_hash(hash, (int)_off_all_planes); for (li = _off_planes.begin(); li != _off_planes.end(); ++li) { @@ -752,72 +687,65 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) ClipPlaneAttrib:: compose_impl(const RenderAttrib *other) const { const ClipPlaneAttrib *ta; DCAST_INTO_R(ta, other, 0); if (ta->_off_all_planes) { - // If the other type turns off all planes, it doesn't matter what - // we are. + // If the other type turns off all planes, it doesn't matter what we are. return ta; } - // This is a three-way merge between ai, bi, and ci, except that bi - // and ci should have no intersection and therefore needn't be - // compared to each other. + // This is a three-way merge between ai, bi, and ci, except that bi and ci + // should have no intersection and therefore needn't be compared to each + // other. Planes::const_iterator ai = _on_planes.begin(); Planes::const_iterator bi = ta->_on_planes.begin(); Planes::const_iterator ci = ta->_off_planes.begin(); // Create a new ClipPlaneAttrib that will hold the result. ClipPlaneAttrib *new_attrib = new ClipPlaneAttrib; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_attrib->_on_planes); - while (ai != _on_planes.end() && - bi != ta->_on_planes.end() && + while (ai != _on_planes.end() && + bi != ta->_on_planes.end() && ci != ta->_off_planes.end()) { if ((*ai) < (*bi)) { if ((*ai) < (*ci)) { - // Here is a plane that we have in the original, which is not - // present in the secondary. + // Here is a plane that we have in the original, which is not present + // in the secondary. *result = *ai; ++ai; ++result; } else if ((*ci) < (*ai)) { - // Here is a plane that is disabled in the secondary, but - // was not present in the original. + // Here is a plane that is disabled in the secondary, but was not + // present in the original. ++ci; } else { // (*ci) == (*ai) - // Here is a plane that is disabled in the secondary, and - // was present in the original. + // Here is a plane that is disabled in the secondary, and was present + // in the original. ++ai; ++ci; } } else if ((*bi) < (*ai)) { - // Here is a new plane we have in the secondary, that was not - // present in the original. + // Here is a new plane we have in the secondary, that was not present in + // the original. *result = *bi; ++bi; ++result; @@ -833,15 +761,15 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_planes.end() && bi != ta->_on_planes.end()) { if ((*ai) < (*bi)) { - // Here is a plane that we have in the original, which is not - // present in the secondary. + // Here is a plane that we have in the original, which is not present in + // the secondary. *result = *ai; ++ai; ++result; } else if ((*bi) < (*ai)) { - // Here is a new plane we have in the secondary, that was not - // present in the original. + // Here is a new plane we have in the secondary, that was not present in + // the original. *result = *bi; ++bi; ++result; @@ -857,20 +785,20 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_planes.end() && ci != ta->_off_planes.end()) { if ((*ai) < (*ci)) { - // Here is a plane that we have in the original, which is not - // present in the secondary. + // Here is a plane that we have in the original, which is not present in + // the secondary. *result = *ai; ++ai; ++result; - + } else if ((*ci) < (*ai)) { - // Here is a plane that is disabled in the secondary, but - // was not present in the original. + // Here is a plane that is disabled in the secondary, but was not + // present in the original. ++ci; - + } else { // (*ci) == (*ai) - // Here is a plane that is disabled in the secondary, and - // was present in the original. + // Here is a plane that is disabled in the secondary, and was present in + // the original. ++ai; ++ci; } @@ -891,64 +819,51 @@ compose_impl(const RenderAttrib *other) const { return return_new(new_attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) ClipPlaneAttrib:: invert_compose_impl(const RenderAttrib *other) const { - // I think in this case the other attrib always wins. Maybe this - // needs a bit more thought. It's hard to imagine that it's even - // important to compute this properly. + // I think in this case the other attrib always wins. Maybe this needs a + // bit more thought. It's hard to imagine that it's even important to + // compute this properly. return other; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) ClipPlaneAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::sort_on_planes -// Access: Private -// Description: This is patterned after -// TextureAttrib::sort_on_stages(), but since planeNodes -// don't actually require sorting, this only empties the -// _filtered map. -//////////////////////////////////////////////////////////////////// +/** + * This is patterned after TextureAttrib::sort_on_stages(), but since + * planeNodes don't actually require sorting, this only empties the _filtered + * map. + */ void ClipPlaneAttrib:: sort_on_planes() { _sort_seq = PlaneNode::get_sort_seq(); _filtered.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ClipPlaneAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ClipPlaneAttrib. + */ void ClipPlaneAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ClipPlaneAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -972,13 +887,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int ClipPlaneAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -1011,10 +923,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PandaNode *node; DCAST_INTO_R(node, p_list[pi++], pi); - // We go through some effort to look up the node in the registry - // without creating a NodePath around it first (which would up, - // and then down, the reference count, possibly deleting the - // node). + // We go through some effort to look up the node in the registry without + // creating a NodePath around it first (which would up, and then down, + // the reference count, possibly deleting the node). int ni = areg->find_node(node->get_type(), node->get_name()); if (ni != -1) { (*ci) = areg->get_node(ni); @@ -1045,29 +956,22 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool ClipPlaneAttrib:: require_fully_complete() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ClipPlaneAttrib is encountered -// in the Bam file. It should create the ClipPlaneAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ClipPlaneAttrib is encountered in the Bam file. It should create the + * ClipPlaneAttrib and extract its information from the file. + */ TypedWritable *ClipPlaneAttrib:: make_from_bam(const FactoryParams ¶ms) { ClipPlaneAttrib *attrib = new ClipPlaneAttrib; @@ -1080,13 +984,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ClipPlaneAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ClipPlaneAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ClipPlaneAttrib. + */ void ClipPlaneAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); @@ -1095,8 +996,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { int num_off_planes = scan.get_uint16(); - // Push back an empty NodePath for each off Plane for now, until we - // get the actual list of pointers later in complete_pointers(). + // Push back an empty NodePath for each off Plane for now, until we get the + // actual list of pointers later in complete_pointers(). _off_planes.resize(num_off_planes); if (manager->get_file_minor_ver() >= 40) { for (int i = 0; i < num_off_planes; i++) { diff --git a/panda/src/pgraph/clipPlaneAttrib.h b/panda/src/pgraph/clipPlaneAttrib.h index f6f6a05b96..c695e0391d 100644 --- a/panda/src/pgraph/clipPlaneAttrib.h +++ b/panda/src/pgraph/clipPlaneAttrib.h @@ -1,16 +1,15 @@ -// Filename: clipPlaneAttrib.h -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clipPlaneAttrib.h + * @author drose + * @date 2002-07-11 + */ #ifndef CLIPPINGPLANEATTRIB_H #define CLIPPINGPLANEATTRIB_H @@ -23,14 +22,12 @@ #include "ordered_vector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ClipPlaneAttrib -// Description : This functions similarly to a LightAttrib. It -// indicates the set of clipping planes that modify the -// geometry at this level and below. A ClipPlaneAttrib -// can either add planes or remove planes from the total -// set of clipping planes in effect. -//////////////////////////////////////////////////////////////////// +/** + * This functions similarly to a LightAttrib. It indicates the set of + * clipping planes that modify the geometry at this level and below. A + * ClipPlaneAttrib can either add planes or remove planes from the total set + * of clipping planes in effect. + */ class EXPCL_PANDA_PGRAPH ClipPlaneAttrib : public RenderAttrib { private: INLINE ClipPlaneAttrib(); @@ -38,23 +35,22 @@ private: PUBLISHED: - // This is the old, deprecated interface to ClipPlaneAttrib. Do not - // use any of these methods for new code; these methods will be - // removed soon. + // This is the old, deprecated interface to ClipPlaneAttrib. Do not use any + // of these methods for new code; these methods will be removed soon. enum Operation { O_set, O_add, O_remove }; - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, PlaneNode *plane); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, PlaneNode *plane1, PlaneNode *plane2); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, PlaneNode *plane1, PlaneNode *plane2, PlaneNode *plane3); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, PlaneNode *plane1, PlaneNode *plane2, PlaneNode *plane3, PlaneNode *plane4); static CPT(RenderAttrib) make_default(); @@ -69,8 +65,7 @@ PUBLISHED: CPT(RenderAttrib) remove_plane(PlaneNode *plane) const; - // The following is the new, more general interface to the - // ClipPlaneAttrib. + // The following is the new, more general interface to the ClipPlaneAttrib. static CPT(RenderAttrib) make(); static CPT(RenderAttrib) make_all_off(); @@ -113,7 +108,7 @@ private: typedef ov_set Planes; Planes _on_planes, _off_planes; bool _off_all_planes; - + typedef pmap< int, CPT(ClipPlaneAttrib) > Filtered; Filtered _filtered; @@ -139,7 +134,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -163,4 +158,3 @@ private: #include "clipPlaneAttrib.I" #endif - diff --git a/panda/src/pgraph/colorAttrib.I b/panda/src/pgraph/colorAttrib.I index f420a4cced..dbcf16819e 100644 --- a/panda/src/pgraph/colorAttrib.I +++ b/panda/src/pgraph/colorAttrib.I @@ -1,24 +1,19 @@ -// Filename: colorAttrib.I -// Created by: drose (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorAttrib.I + * @author drose + * @date 2002-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::Constructor -// Access: Private -// Description: Use ColorAttrib::make() to construct a new -// ColorAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorAttrib::make() to construct a new ColorAttrib object. + */ INLINE ColorAttrib:: ColorAttrib(ColorAttrib::Type type, const LColor &color) : _type(type), @@ -27,33 +22,25 @@ ColorAttrib(ColorAttrib::Type type, const LColor &color) : quantize_color(); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::get_color_type -// Access: Published -// Description: Returns the type of color specified by this -// ColorAttrib. The options are: -// -// T_vertex - use the vertex color specified in the -// geometry itself. -// -// T_flat - use the color specified in this -// ColorAttrib for all geometry. You can get this -// color via get_color(). -// -// T_off - use the color white. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of color specified by this ColorAttrib. The options are: + * + * T_vertex - use the vertex color specified in the geometry itself. + * + * T_flat - use the color specified in this ColorAttrib for all geometry. You + * can get this color via get_color(). + * + * T_off - use the color white. + */ INLINE ColorAttrib::Type ColorAttrib:: get_color_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::get_color -// Access: Published -// Description: If the type is T_flat or T_off, this returns the -// color that will be applied to geometry. If the type -// is T_vertex, this is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * If the type is T_flat or T_off, this returns the color that will be applied + * to geometry. If the type is T_vertex, this is meaningless. + */ INLINE const LColor &ColorAttrib:: get_color() const { return _color; diff --git a/panda/src/pgraph/colorAttrib.cxx b/panda/src/pgraph/colorAttrib.cxx index 9cb2095bc9..7e007851fb 100644 --- a/panda/src/pgraph/colorAttrib.cxx +++ b/panda/src/pgraph/colorAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: colorAttrib.cxx -// Created by: drose (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorAttrib.cxx + * @author drose + * @date 2002-02-22 + */ #include "colorAttrib.h" #include "graphicsStateGuardianBase.h" @@ -25,13 +24,10 @@ int ColorAttrib::_attrib_slot; CPT(RenderAttrib) ColorAttrib::_off; CPT(RenderAttrib) ColorAttrib::_vertex; -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::make_vertex -// Access: Published, Static -// Description: Constructs a new ColorAttrib object that indicates -// geometry should be rendered according to its own -// vertex color. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorAttrib object that indicates geometry should be + * rendered according to its own vertex color. + */ CPT(RenderAttrib) ColorAttrib:: make_vertex() { if (_vertex != 0) { @@ -42,24 +38,20 @@ make_vertex() { return _vertex; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::make_flat -// Access: Published, Static -// Description: Constructs a new ColorAttrib object that indicates -// geometry should be rendered in the indicated color. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorAttrib object that indicates geometry should be + * rendered in the indicated color. + */ CPT(RenderAttrib) ColorAttrib:: make_flat(const LColor &color) { ColorAttrib *attrib = new ColorAttrib(T_flat, color); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::make_off -// Access: Published, Static -// Description: Constructs a new ColorAttrib object that indicates -// geometry should be rendered in white. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorAttrib object that indicates geometry should be + * rendered in white. + */ CPT(RenderAttrib) ColorAttrib:: make_off() { if (_off != 0) { @@ -70,23 +62,18 @@ make_off() { return _off; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ColorAttrib:: make_default() { return make_off(); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ColorAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -105,21 +92,17 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ColorAttrib -// types to return a unique number indicating whether -// this ColorAttrib is equivalent to the other one. -// -// This should return 0 if the two ColorAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ColorAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ColorAttrib types to return a unique + * number indicating whether this ColorAttrib is equivalent to the other one. + * + * This should return 0 if the two ColorAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ColorAttrib objects whose get_type() + * functions return the same. + */ int ColorAttrib:: compare_to_impl(const RenderAttrib *other) const { const ColorAttrib *ta = (const ColorAttrib *)other; @@ -133,16 +116,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ColorAttrib:: get_hash_impl() const { size_t hash = 0; @@ -153,28 +132,23 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) ColorAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { - // For a ColorAttrib, the only relevant information is the type: is - // it flat-shaded or vertex-shaded? The actual color value is read - // by the shader from the graphics state. + // For a ColorAttrib, the only relevant information is the type: is it flat- + // shaded or vertex-shaded? The actual color value is read by the shader + // from the graphics state. ColorAttrib *attrib = new ColorAttrib(_type, LColor(1.0f, 1.0f, 1.0f, 1.0f)); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::quantize_color -// Access: Private -// Description: Quantizes the color color to the nearest multiple of -// 1000, just to prevent runaway accumulation of -// only slightly-different ColorAttribs. -//////////////////////////////////////////////////////////////////// +/** + * Quantizes the color color to the nearest multiple of 1000, just to prevent + * runaway accumulation of only slightly-different ColorAttribs. + */ void ColorAttrib:: quantize_color() { switch (_type) { @@ -195,23 +169,18 @@ quantize_color() { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ColorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ColorAttrib. + */ void ColorAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ColorAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -220,14 +189,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { _color.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ColorAttrib is encountered -// in the Bam file. It should create the ColorAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ColorAttrib is encountered in the Bam file. It should create the + * ColorAttrib and extract its information from the file. + */ TypedWritable *ColorAttrib:: make_from_bam(const FactoryParams ¶ms) { ColorAttrib *attrib = new ColorAttrib(T_off, LColor::zero()); @@ -240,13 +206,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ColorAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ColorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ColorAttrib. + */ void ColorAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/colorAttrib.h b/panda/src/pgraph/colorAttrib.h index 8a7e70a6e1..e2f38f46ed 100644 --- a/panda/src/pgraph/colorAttrib.h +++ b/panda/src/pgraph/colorAttrib.h @@ -1,16 +1,15 @@ -// Filename: colorAttrib.h -// Created by: drose (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorAttrib.h + * @author drose + * @date 2002-02-22 + */ #ifndef COLORATTRIB_H #define COLORATTRIB_H @@ -22,11 +21,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ColorAttrib -// Description : Indicates what color should be applied to renderable -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Indicates what color should be applied to renderable geometry. + */ class EXPCL_PANDA_PGRAPH ColorAttrib : public RenderAttrib { PUBLISHED: enum Type { @@ -77,7 +74,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -102,4 +99,3 @@ private: #include "colorAttrib.I" #endif - diff --git a/panda/src/pgraph/colorBlendAttrib.I b/panda/src/pgraph/colorBlendAttrib.I index 99d183a12e..fa2aca94ff 100644 --- a/panda/src/pgraph/colorBlendAttrib.I +++ b/panda/src/pgraph/colorBlendAttrib.I @@ -1,24 +1,19 @@ -// Filename: colorBlendAttrib.I -// Created by: drose (29Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorBlendAttrib.I + * @author drose + * @date 2002-03-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::Constructor -// Access: Private -// Description: Use ColorBlendAttrib::make() to construct a new -// ColorBlendAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorBlendAttrib::make() to construct a new ColorBlendAttrib object. + */ INLINE ColorBlendAttrib:: ColorBlendAttrib() : _mode(M_none), @@ -30,12 +25,9 @@ ColorBlendAttrib() : { } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::Constructor -// Access: Private -// Description: Use ColorBlendAttrib::make() to construct a new -// ColorBlendAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorBlendAttrib::make() to construct a new ColorBlendAttrib object. + */ INLINE ColorBlendAttrib:: ColorBlendAttrib(ColorBlendAttrib::Mode mode, ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b, @@ -49,74 +41,59 @@ ColorBlendAttrib(ColorBlendAttrib::Mode mode, { } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_mode -// Access: Published -// Description: Returns the colorBlend mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the colorBlend mode. + */ INLINE ColorBlendAttrib::Mode ColorBlendAttrib:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_operand_a -// Access: Published -// Description: Returns the multiplier for the first component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the multiplier for the first component. + */ INLINE ColorBlendAttrib::Operand ColorBlendAttrib:: get_operand_a() const { return _a; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_operand_b -// Access: Published -// Description: Returns the multiplier for the second component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the multiplier for the second component. + */ INLINE ColorBlendAttrib::Operand ColorBlendAttrib:: get_operand_b() const { return _b; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_color -// Access: Published -// Description: Returns the constant color associated with the attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns the constant color associated with the attrib. + */ INLINE LColor ColorBlendAttrib:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::involves_constant_color -// Access: Published -// Description: Returns true if the this attrib uses the -// constant color, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the this attrib uses the constant color, false otherwise. + */ INLINE bool ColorBlendAttrib:: involves_constant_color() const { return _involves_constant_color; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::involves_color_scale -// Access: Published -// Description: Returns true if the this attrib uses the -// color scale attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the this attrib uses the color scale attrib, false + * otherwise. + */ INLINE bool ColorBlendAttrib:: involves_color_scale() const { return _involves_color_scale; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::involves_constant_color -// Access: Published, Static -// Description: Returns true if the indicated operand uses the -// constant color, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated operand uses the constant color, false + * otherwise. + */ INLINE bool ColorBlendAttrib:: involves_constant_color(ColorBlendAttrib::Operand operand) { switch (operand) { @@ -131,12 +108,10 @@ involves_constant_color(ColorBlendAttrib::Operand operand) { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::involves_color_scale -// Access: Published, Static -// Description: Returns true if the indicated operand uses the -// color scale attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated operand uses the color scale attrib, false + * otherwise. + */ INLINE bool ColorBlendAttrib:: involves_color_scale(ColorBlendAttrib::Operand operand) { switch (operand) { diff --git a/panda/src/pgraph/colorBlendAttrib.cxx b/panda/src/pgraph/colorBlendAttrib.cxx index 7c6c5aea23..ef5d934976 100644 --- a/panda/src/pgraph/colorBlendAttrib.cxx +++ b/panda/src/pgraph/colorBlendAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: colorBlendAttrib.cxx -// Created by: drose (29Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorBlendAttrib.cxx + * @author drose + * @date 2002-03-29 + */ #include "colorBlendAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,26 +22,20 @@ TypeHandle ColorBlendAttrib::_type_handle; int ColorBlendAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::make_off -// Access: Published, Static -// Description: Constructs a new ColorBlendAttrib object that -// disables special-effect blending, allowing normal -// transparency to be used instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorBlendAttrib object that disables special-effect + * blending, allowing normal transparency to be used instead. + */ CPT(RenderAttrib) ColorBlendAttrib:: make_off() { ColorBlendAttrib *attrib = new ColorBlendAttrib; return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::make -// Access: Published, Static -// Description: Constructs a new ColorBlendAttrib object. This -// constructor is deprecated; use the one below, which -// takes three or four parameters, instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorBlendAttrib object. This constructor is deprecated; + * use the one below, which takes three or four parameters, instead. + */ CPT(RenderAttrib) ColorBlendAttrib:: make(ColorBlendAttrib::Mode mode) { ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, O_one, O_one, @@ -50,38 +43,30 @@ make(ColorBlendAttrib::Mode mode) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::make -// Access: Published, Static -// Description: Constructs a new ColorBlendAttrib object that enables -// special-effect blending. This supercedes -// transparency. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorBlendAttrib object that enables special-effect + * blending. This supercedes transparency. + */ CPT(RenderAttrib) ColorBlendAttrib:: -make(ColorBlendAttrib::Mode mode, +make(ColorBlendAttrib::Mode mode, ColorBlendAttrib::Operand a, ColorBlendAttrib::Operand b, const LColor &color) { ColorBlendAttrib *attrib = new ColorBlendAttrib(mode, a, b, color); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ColorBlendAttrib:: make_default() { return return_new(new ColorBlendAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ColorBlendAttrib:: output(ostream &out) const { out << get_type() << ":" << get_mode(); @@ -96,21 +81,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ColorBlendAttrib -// types to return a unique number indicating whether -// this ColorBlendAttrib is equivalent to the other one. -// -// This should return 0 if the two ColorBlendAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ColorBlendAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ColorBlendAttrib types to return a + * unique number indicating whether this ColorBlendAttrib is equivalent to the + * other one. + * + * This should return 0 if the two ColorBlendAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ColorBlendAttrib objects whose get_type() + * functions return the same. + */ int ColorBlendAttrib:: compare_to_impl(const RenderAttrib *other) const { const ColorBlendAttrib *ta = (const ColorBlendAttrib *)other; @@ -130,16 +112,12 @@ compare_to_impl(const RenderAttrib *other) const { return _color.compare_to(ta->_color); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ColorBlendAttrib:: get_hash_impl() const { size_t hash = 0; @@ -151,33 +129,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) ColorBlendAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ColorBlendAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ColorBlendAttrib. + */ void ColorBlendAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ColorBlendAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -188,14 +159,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { _color.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ColorBlendAttrib is encountered -// in the Bam file. It should create the ColorBlendAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ColorBlendAttrib is encountered in the Bam file. It should create the + * ColorBlendAttrib and extract its information from the file. + */ TypedWritable *ColorBlendAttrib:: make_from_bam(const FactoryParams ¶ms) { ColorBlendAttrib *attrib = new ColorBlendAttrib; @@ -208,13 +176,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ColorBlendAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ColorBlendAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ColorBlendAttrib. + */ void ColorBlendAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); @@ -228,10 +193,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _involves_color_scale = involves_color_scale(_a) || involves_color_scale(_b); } -//////////////////////////////////////////////////////////////////// -// Function: ostream << ColorBlendAttrib::Mode -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, ColorBlendAttrib::Mode mode) { switch (mode) { @@ -257,10 +221,9 @@ operator << (ostream &out, ColorBlendAttrib::Mode mode) { return out << "**invalid ColorBlendAttrib::Mode(" << (int)mode << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: ostream << ColorBlendAttrib::Operand -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, ColorBlendAttrib::Operand operand) { switch (operand) { diff --git a/panda/src/pgraph/colorBlendAttrib.h b/panda/src/pgraph/colorBlendAttrib.h index 0de99e04e5..3e836fdb45 100644 --- a/panda/src/pgraph/colorBlendAttrib.h +++ b/panda/src/pgraph/colorBlendAttrib.h @@ -1,16 +1,15 @@ -// Filename: colorBlendAttrib.h -// Created by: drose (29Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorBlendAttrib.h + * @author drose + * @date 2002-03-29 + */ #ifndef COLORBLENDATTRIB_H #define COLORBLENDATTRIB_H @@ -21,12 +20,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ColorBlendAttrib -// Description : This specifies how colors are blended into the frame -// buffer, for special effects. This overrides -// transparency if transparency is also specified. -//////////////////////////////////////////////////////////////////// +/** + * This specifies how colors are blended into the frame buffer, for special + * effects. This overrides transparency if transparency is also specified. + */ class EXPCL_PANDA_PGRAPH ColorBlendAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -55,12 +52,11 @@ PUBLISHED: O_one_minus_constant_alpha, O_incoming_color_saturate, // valid only for operand a - // If you set either of the operands to any of the below, the - // blend color is taken from the current ColorScaleAttrib. This - // also inhibits the normal behavior of the ColorScaleAttrib; it - // no longer directly scales the vertex colors, on the assumption - // that you will instead take care of the scale here, in the blend - // mode. + // If you set either of the operands to any of the below, the blend color + // is taken from the current ColorScaleAttrib. This also inhibits the + // normal behavior of the ColorScaleAttrib; it no longer directly scales + // the vertex colors, on the assumption that you will instead take care of + // the scale here, in the blend mode. O_color_scale, O_one_minus_color_scale, O_alpha_scale, @@ -120,7 +116,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/pgraph/colorScaleAttrib.I b/panda/src/pgraph/colorScaleAttrib.I index e23b18aa5a..755ed7a2be 100644 --- a/panda/src/pgraph/colorScaleAttrib.I +++ b/panda/src/pgraph/colorScaleAttrib.I @@ -1,24 +1,19 @@ -// Filename: colorScaleAttrib.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorScaleAttrib.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::Copy Constructor -// Access: Protected -// Description: Use ColorScaleAttrib::make() to construct a new -// ColorScaleAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorScaleAttrib::make() to construct a new ColorScaleAttrib object. + */ INLINE ColorScaleAttrib:: ColorScaleAttrib(const ColorScaleAttrib ©) : _off(copy._off), @@ -29,73 +24,56 @@ ColorScaleAttrib(const ColorScaleAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::is_off -// Access: Published -// Description: Returns true if the ColorScaleAttrib will ignore any -// color scales inherited from above, false otherwise. -// This is not the same thing as !has_scale(); a -// ColorScaleAttrib may have the "off" flag set and also -// have another scale specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ColorScaleAttrib will ignore any color scales inherited + * from above, false otherwise. This is not the same thing as !has_scale(); a + * ColorScaleAttrib may have the "off" flag set and also have another scale + * specified. + */ INLINE bool ColorScaleAttrib:: is_off() const { return _off; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::is_identity -// Access: Published -// Description: Returns true if the ColorScaleAttrib is an identity -// attrib, false if it is either an off attrib or it has -// a scale. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ColorScaleAttrib is an identity attrib, false if it is + * either an off attrib or it has a scale. + */ INLINE bool ColorScaleAttrib:: is_identity() const { return !_off && !_has_scale; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::has_scale -// Access: Published -// Description: Returns true if the ColorScaleAttrib has a -// non-identity scale, false otherwise (in which case it -// might be an off attrib or an identity attrib). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ColorScaleAttrib has a non-identity scale, false + * otherwise (in which case it might be an off attrib or an identity attrib). + */ INLINE bool ColorScaleAttrib:: has_scale() const { return _has_scale; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::has_rgb_scale -// Access: Published -// Description: Returns true if the ColorScaleAttrib has a -// non-identity scale in the RGB components (ignoring -// alpha), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ColorScaleAttrib has a non-identity scale in the RGB + * components (ignoring alpha), or false otherwise. + */ INLINE bool ColorScaleAttrib:: has_rgb_scale() const { return _has_rgb_scale; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::has_alpha_scale -// Access: Published -// Description: Returns true if the ColorScaleAttrib has a -// non-identity scale in the alpha component (ignoring -// RGB), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ColorScaleAttrib has a non-identity scale in the alpha + * component (ignoring RGB), or false otherwise. + */ INLINE bool ColorScaleAttrib:: has_alpha_scale() const { return _has_alpha_scale; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::get_scale -// Access: Published -// Description: Returns the scale to be applied to colors. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale to be applied to colors. + */ INLINE const LVecBase4 &ColorScaleAttrib:: get_scale() const { return _scale; diff --git a/panda/src/pgraph/colorScaleAttrib.cxx b/panda/src/pgraph/colorScaleAttrib.cxx index dbdf0511cd..0975757604 100644 --- a/panda/src/pgraph/colorScaleAttrib.cxx +++ b/panda/src/pgraph/colorScaleAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: colorScaleAttrib.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorScaleAttrib.cxx + * @author drose + * @date 2002-03-14 + */ #include "colorScaleAttrib.h" #include "graphicsStateGuardianBase.h" @@ -25,12 +24,9 @@ TypeHandle ColorScaleAttrib::_type_handle; int ColorScaleAttrib::_attrib_slot; CPT(RenderAttrib) ColorScaleAttrib::_identity_attrib; -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::Constructor -// Access: Protected -// Description: Use ColorScaleAttrib::make() to construct a new -// ColorScaleAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorScaleAttrib::make() to construct a new ColorScaleAttrib object. + */ ColorScaleAttrib:: ColorScaleAttrib(bool off, const LVecBase4 &scale) : _off(off), @@ -42,15 +38,13 @@ ColorScaleAttrib(bool off, const LVecBase4 &scale) : _has_alpha_scale = !IS_NEARLY_EQUAL(_scale[3], 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::make_identity -// Access: Published, Static -// Description: Constructs an identity scale attrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an identity scale attrib. + */ CPT(RenderAttrib) ColorScaleAttrib:: make_identity() { - // We make identity a special case and store a pointer forever once - // we find it the first time. + // We make identity a special case and store a pointer forever once we find + // it the first time. if (_identity_attrib == (ColorScaleAttrib *)NULL) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f));; _identity_attrib = return_new(attrib); @@ -59,51 +53,41 @@ make_identity() { return _identity_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::make -// Access: Published, Static -// Description: Constructs a new ColorScaleAttrib object that indicates -// geometry should be scaled by the indicated factor. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorScaleAttrib object that indicates geometry should be + * scaled by the indicated factor. + */ CPT(RenderAttrib) ColorScaleAttrib:: make(const LVecBase4 &scale) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, scale); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::make_off -// Access: Published, Static -// Description: Constructs a new ColorScaleAttrib object that ignores -// any ColorScaleAttrib inherited from above. You may -// also specify an additional color scale to apply to -// geometry below (using set_scale()). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorScaleAttrib object that ignores any ColorScaleAttrib + * inherited from above. You may also specify an additional color scale to + * apply to geometry below (using set_scale()). + */ CPT(RenderAttrib) ColorScaleAttrib:: make_off() { - ColorScaleAttrib *attrib = + ColorScaleAttrib *attrib = new ColorScaleAttrib(true, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ColorScaleAttrib:: make_default() { return return_new(new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f))); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::set_scale -// Access: Published -// Description: Returns a new ColorScaleAttrib, just like this one, but -// with the scale changed to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ColorScaleAttrib, just like this one, but with the scale + * changed to the indicated value. + */ CPT(RenderAttrib) ColorScaleAttrib:: set_scale(const LVecBase4 &scale) const { ColorScaleAttrib *attrib = new ColorScaleAttrib(*this); @@ -115,46 +99,35 @@ set_scale(const LVecBase4 &scale) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::lower_attrib_can_override -// Access: Public, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return false if a RenderAttrib on a -// higher node will compose into a RenderAttrib on a -// lower node that has a higher override value, or false -// if the lower RenderAttrib will completely replace the -// state. -// -// The default behavior is false: normally, a -// RenderAttrib in the graph cannot completely override -// a RenderAttrib above it, regardless of its override -// value--instead, the two attribs are composed. But -// for some kinds of RenderAttribs, it is useful to -// allow this kind of override. -// -// This method only handles the one special case of a -// lower RenderAttrib with a higher override value. If -// the higher RenderAttrib has a higher override value, -// it always completely overrides. And if both -// RenderAttribs have the same override value, they are -// always composed. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return false if a RenderAttrib on a higher node will compose + * into a RenderAttrib on a lower node that has a higher override value, or + * false if the lower RenderAttrib will completely replace the state. + * + * The default behavior is false: normally, a RenderAttrib in the graph cannot + * completely override a RenderAttrib above it, regardless of its override + * value--instead, the two attribs are composed. But for some kinds of + * RenderAttribs, it is useful to allow this kind of override. + * + * This method only handles the one special case of a lower RenderAttrib with + * a higher override value. If the higher RenderAttrib has a higher override + * value, it always completely overrides. And if both RenderAttribs have the + * same override value, they are always composed. + */ bool ColorScaleAttrib:: lower_attrib_can_override() const { - // A ColorScaleAttrib doesn't compose through an override. This - // allows us to meaningfully set an override on a lower node, which - // prevents any color scales from coming in from above. + // A ColorScaleAttrib doesn't compose through an override. This allows us + // to meaningfully set an override on a lower node, which prevents any color + // scales from coming in from above. return true; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ColorScaleAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -169,21 +142,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ColorScaleAttrib -// types to return a unique number indicating whether -// this ColorScaleAttrib is equivalent to the other one. -// -// This should return 0 if the two ColorScaleAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ColorScaleAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ColorScaleAttrib types to return a + * unique number indicating whether this ColorScaleAttrib is equivalent to the + * other one. + * + * This should return 0 if the two ColorScaleAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ColorScaleAttrib objects whose get_type() + * functions return the same. + */ int ColorScaleAttrib:: compare_to_impl(const RenderAttrib *other) const { const ColorScaleAttrib *ta = (const ColorScaleAttrib *)other; @@ -195,16 +165,12 @@ compare_to_impl(const RenderAttrib *other) const { return _scale.compare_to(ta->_scale); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ColorScaleAttrib:: get_hash_impl() const { size_t hash = 0; @@ -213,23 +179,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) ColorScaleAttrib:: compose_impl(const RenderAttrib *other) const { const ColorScaleAttrib *ta = (const ColorScaleAttrib *)other; @@ -242,20 +202,17 @@ compose_impl(const RenderAttrib *other) const { ta->_scale[1] * _scale[1], ta->_scale[2] * _scale[2], ta->_scale[3] * _scale[3]); - + ColorScaleAttrib *attrib = new ColorScaleAttrib(is_off(), new_scale); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) ColorScaleAttrib:: invert_compose_impl(const RenderAttrib *other) const { if (is_off()) { @@ -272,27 +229,21 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) ColorScaleAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { // A ColorScaleAttrib doesn't directly contribute to the auto-shader - // contents--instead, the shader is always written to query - // attr_colorscale at runtime. So the attrib itself means nothing - // to the shader. + // contents--instead, the shader is always written to query attr_colorscale + // at runtime. So the attrib itself means nothing to the shader. return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::quantize_scale -// Access: Private -// Description: Quantizes the color scale to the nearest multiple of -// 1000, just to prevent runaway accumulation of -// only slightly-different ColorScaleAttribs. -//////////////////////////////////////////////////////////////////// +/** + * Quantizes the color scale to the nearest multiple of 1000, just to prevent + * runaway accumulation of only slightly-different ColorScaleAttribs. + */ void ColorScaleAttrib:: quantize_scale() { _scale[0] = cfloor(_scale[0] * 1000.0f + 0.5f) * 0.001f; @@ -301,42 +252,34 @@ quantize_scale() { _scale[3] = cfloor(_scale[3] * 1000.0f + 0.5f) * 0.001f; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ColorScaleAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ColorScaleAttrib. + */ void ColorScaleAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ColorScaleAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); - // We cheat, and modify the bam stream without upping the bam - // version. We can do this since we know that no existing bam files - // have a ColorScaleAttrib in them. + // We cheat, and modify the bam stream without upping the bam version. We + // can do this since we know that no existing bam files have a + // ColorScaleAttrib in them. dg.add_bool(_off); _scale.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ColorScaleAttrib is encountered -// in the Bam file. It should create the ColorScaleAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ColorScaleAttrib is encountered in the Bam file. It should create the + * ColorScaleAttrib and extract its information from the file. + */ TypedWritable *ColorScaleAttrib:: make_from_bam(const FactoryParams ¶ms) { ColorScaleAttrib *attrib = new ColorScaleAttrib(false, LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)); @@ -349,13 +292,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ColorScaleAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ColorScaleAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ColorScaleAttrib. + */ void ColorScaleAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/colorScaleAttrib.h b/panda/src/pgraph/colorScaleAttrib.h index 2fd09b5c3c..060b2721a1 100644 --- a/panda/src/pgraph/colorScaleAttrib.h +++ b/panda/src/pgraph/colorScaleAttrib.h @@ -1,16 +1,15 @@ -// Filename: colorScaleAttrib.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorScaleAttrib.h + * @author drose + * @date 2002-03-14 + */ #ifndef COLORSCALEATTRIB_H #define COLORSCALEATTRIB_H @@ -22,11 +21,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ColorScaleAttrib -// Description : Applies a scale to colors in the scene graph and on -// vertices. -//////////////////////////////////////////////////////////////////// +/** + * Applies a scale to colors in the scene graph and on vertices. + */ class EXPCL_PANDA_PGRAPH ColorScaleAttrib : public RenderAttrib { protected: ColorScaleAttrib(bool off, const LVecBase4 &scale); @@ -83,7 +80,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -108,4 +105,3 @@ private: #include "colorScaleAttrib.I" #endif - diff --git a/panda/src/pgraph/colorWriteAttrib.I b/panda/src/pgraph/colorWriteAttrib.I index cacdcc9ee8..a7ec441d43 100644 --- a/panda/src/pgraph/colorWriteAttrib.I +++ b/panda/src/pgraph/colorWriteAttrib.I @@ -1,36 +1,28 @@ -// Filename: colorWriteAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorWriteAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::Constructor -// Access: Private -// Description: Use ColorWriteAttrib::make() to construct a new -// ColorWriteAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ColorWriteAttrib::make() to construct a new ColorWriteAttrib object. + */ INLINE ColorWriteAttrib:: ColorWriteAttrib(unsigned int channels) : _channels(channels) { } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::get_channels -// Access: Published -// Description: Returns the mask of color channels that are enabled -// by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mask of color channels that are enabled by this attrib. + */ INLINE unsigned int ColorWriteAttrib:: get_channels() const { return _channels; diff --git a/panda/src/pgraph/colorWriteAttrib.cxx b/panda/src/pgraph/colorWriteAttrib.cxx index 66e2ab329f..98c889a0de 100644 --- a/panda/src/pgraph/colorWriteAttrib.cxx +++ b/panda/src/pgraph/colorWriteAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: colorWriteAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorWriteAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "colorWriteAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,34 +22,27 @@ TypeHandle ColorWriteAttrib::_type_handle; int ColorWriteAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::make -// Access: Published, Static -// Description: Constructs a new ColorWriteAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ColorWriteAttrib object. + */ CPT(RenderAttrib) ColorWriteAttrib:: make(unsigned int channels) { ColorWriteAttrib *attrib = new ColorWriteAttrib(channels); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ColorWriteAttrib:: make_default() { return return_new(new ColorWriteAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ColorWriteAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -72,37 +64,30 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ColorWriteAttrib -// types to return a unique number indicating whether -// this ColorWriteAttrib is equivalent to the other one. -// -// This should return 0 if the two ColorWriteAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ColorWriteAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ColorWriteAttrib types to return a + * unique number indicating whether this ColorWriteAttrib is equivalent to the + * other one. + * + * This should return 0 if the two ColorWriteAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ColorWriteAttrib objects whose get_type() + * functions return the same. + */ int ColorWriteAttrib:: compare_to_impl(const RenderAttrib *other) const { const ColorWriteAttrib *ta = (const ColorWriteAttrib *)other; return (int)_channels - (int)ta->_channels; } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ColorWriteAttrib:: get_hash_impl() const { size_t hash = 0; @@ -110,23 +95,18 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ColorWriteAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ColorWriteAttrib. + */ void ColorWriteAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ColorWriteAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -134,14 +114,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint8(_channels); } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ColorWriteAttrib is encountered -// in the Bam file. It should create the ColorWriteAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ColorWriteAttrib is encountered in the Bam file. It should create the + * ColorWriteAttrib and extract its information from the file. + */ TypedWritable *ColorWriteAttrib:: make_from_bam(const FactoryParams ¶ms) { ColorWriteAttrib *attrib = new ColorWriteAttrib; @@ -154,13 +131,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ColorWriteAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ColorWriteAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ColorWriteAttrib. + */ void ColorWriteAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/colorWriteAttrib.h b/panda/src/pgraph/colorWriteAttrib.h index a9c4442e14..76d9d5c1db 100644 --- a/panda/src/pgraph/colorWriteAttrib.h +++ b/panda/src/pgraph/colorWriteAttrib.h @@ -1,16 +1,15 @@ -// Filename: colorWriteAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorWriteAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef COLORWRITEATTRIB_H #define COLORWRITEATTRIB_H @@ -21,13 +20,11 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ColorWriteAttrib -// Description : Enables or disables writing to the color buffer. -// This is primarily useful for certain special effects -// in which it is important to write to the depth buffer -// without affecting the color buffer. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables writing to the color buffer. This is primarily useful + * for certain special effects in which it is important to write to the depth + * buffer without affecting the color buffer. + */ class EXPCL_PANDA_PGRAPH ColorWriteAttrib : public RenderAttrib { PUBLISHED: enum Channels { @@ -76,7 +73,7 @@ PUBLISHED: virtual int get_slot() const { return get_class_slot(); } - + public: static TypeHandle get_class_type() { return _type_handle; @@ -100,4 +97,3 @@ private: #include "colorWriteAttrib.I" #endif - diff --git a/panda/src/pgraph/compassEffect.I b/panda/src/pgraph/compassEffect.I index 115f12cf54..483370a19c 100644 --- a/panda/src/pgraph/compassEffect.I +++ b/panda/src/pgraph/compassEffect.I @@ -1,48 +1,37 @@ -// Filename: compassEffect.I -// Created by: drose (16Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compassEffect.I + * @author drose + * @date 2002-07-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::Constructor -// Access: Private -// Description: Use CompassEffect::make() to construct a new -// CompassEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use CompassEffect::make() to construct a new CompassEffect object. + */ INLINE CompassEffect:: CompassEffect() { _properties = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::get_reference -// Access: Published -// Description: Returns the reference node from which the -// CompassEffect inherits its transform. If this is -// empty, it means the root of the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference node from which the CompassEffect inherits its + * transform. If this is empty, it means the root of the scene graph. + */ INLINE const NodePath &CompassEffect:: get_reference() const { return _reference; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::get_properties -// Access: Published -// Description: Returns the bitmask of properties that this -// CompassEffect object inherits from its reference -// node (or from the root). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bitmask of properties that this CompassEffect object inherits + * from its reference node (or from the root). + */ INLINE int CompassEffect:: get_properties() const { return _properties; diff --git a/panda/src/pgraph/compassEffect.cxx b/panda/src/pgraph/compassEffect.cxx index f2987348c2..c1e0cf24a8 100644 --- a/panda/src/pgraph/compassEffect.cxx +++ b/panda/src/pgraph/compassEffect.cxx @@ -1,16 +1,15 @@ -// Filename: compassEffect.cxx -// Created by: drose (16Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compassEffect.cxx + * @author drose + * @date 2002-07-16 + */ #include "compassEffect.h" #include "cullTraverserData.h" @@ -23,17 +22,13 @@ TypeHandle CompassEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::make -// Access: Published, Static -// Description: Constructs a new CompassEffect object. If the -// reference is an empty NodePath, it means the -// CompassEffect is relative to the root of the scene -// graph; otherwise, it's relative to the indicated -// node. The properties bitmask specifies the set of -// properties that the compass node inherits from the -// reference instead of from its parent. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CompassEffect object. If the reference is an empty + * NodePath, it means the CompassEffect is relative to the root of the scene + * graph; otherwise, it's relative to the indicated node. The properties + * bitmask specifies the set of properties that the compass node inherits from + * the reference instead of from its parent. + */ CPT(RenderEffect) CompassEffect:: make(const NodePath &reference, int properties) { CompassEffect *effect = new CompassEffect; @@ -42,23 +37,18 @@ make(const NodePath &reference, int properties) { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of RenderEffect by calling the -// xform() method, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * RenderEffect by calling the xform() method, false otherwise. + */ bool CompassEffect:: safe_to_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CompassEffect:: output(ostream &out) const { out << get_type() << ":"; @@ -99,37 +89,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool CompassEffect:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void CompassEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -149,36 +130,30 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, true_net_transform->invert_compose(want_net_transform); // And modify our local node's apparent transform so that - // true_net_transform->compose(new_node_transform) produces the same - // result we would have gotten had we actually computed + // true_net_transform->compose(new_node_transform) produces the same result + // we would have gotten had we actually computed // want_transform->compose(orig_node_transform). node_transform = compass_transform->compose(node_transform); } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::has_adjust_transform -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if adjust_transform() has been defined, and -// therefore the RenderEffect has some effect on the -// node's apparent local and net transforms. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if + * adjust_transform() has been defined, and therefore the RenderEffect has + * some effect on the node's apparent local and net transforms. + */ bool CompassEffect:: has_adjust_transform() const { return (_properties != 0); } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::adjust_transform -// Access: Public, Virtual -// Description: Performs some operation on the node's apparent net -// and/or local transforms. This will only be called if -// has_adjust_transform() is redefined to return true. -// -// Both parameters are in/out. The original transforms -// will be passed in, and they may (or may not) be -// modified in-place by the RenderEffect. -//////////////////////////////////////////////////////////////////// +/** + * Performs some operation on the node's apparent net and/or local transforms. + * This will only be called if has_adjust_transform() is redefined to return + * true. + * + * Both parameters are in/out. The original transforms will be passed in, and + * they may (or may not) be modified in-place by the RenderEffect. + */ void CompassEffect:: adjust_transform(CPT(TransformState) &net_transform, CPT(TransformState) &node_transform, @@ -188,9 +163,8 @@ adjust_transform(CPT(TransformState) &net_transform, return; } - // The reference transform: where we are acting as if we inherit - // from. Either the root node (identity) or the specified reference - // node. + // The reference transform: where we are acting as if we inherit from. + // Either the root node (identity) or the specified reference node. CPT(TransformState) ref_transform; if (_reference.is_empty()) { ref_transform = TransformState::make_identity(); @@ -198,18 +172,18 @@ adjust_transform(CPT(TransformState) &net_transform, ref_transform = _reference.get_net_transform(); } - // Now compute the net transform we actually want to achieve. This - // is all of the components from the net transform we want to - // inherit normally from our parent, with all of the components from - // the ref transform we want to inherit from our reference. + // Now compute the net transform we actually want to achieve. This is all + // of the components from the net transform we want to inherit normally from + // our parent, with all of the components from the ref transform we want to + // inherit from our reference. CPT(TransformState) want_net_transform; if (_properties == P_all) { // If we want to steal the whole transform, that's easy. want_net_transform = ref_transform; } else { - // How much of the pos do we want to steal? We can always - // determine a transform's pos, even if it's nondecomposable. + // How much of the pos do we want to steal? We can always determine a + // transform's pos, even if it's nondecomposable. LVecBase3 want_pos = net_transform->get_pos(); const LVecBase3 &ref_pos = ref_transform->get_pos(); if ((_properties & P_x) != 0) { @@ -225,18 +199,18 @@ adjust_transform(CPT(TransformState) &net_transform, if ((_properties & ~P_pos) == 0) { // If we only want to steal the pos, that's pretty easy. want_net_transform = net_transform->set_pos(want_pos); - + } else if ((_properties & (P_rot | P_scale)) == (P_rot | P_scale)) { // If we want to steal everything *but* the pos, also easy. want_net_transform = ref_transform->set_pos(want_pos); - + } else { // For any other combination, we have to be able to decompose both // transforms. - if (!net_transform->has_components() || + if (!net_transform->has_components() || !ref_transform->has_components()) { - // If we can't decompose, just do the best we can: steal - // everything but the pos. + // If we can't decompose, just do the best we can: steal everything + // but the pos. want_net_transform = ref_transform->set_pos(want_pos); } else { @@ -267,21 +241,18 @@ adjust_transform(CPT(TransformState) &net_transform, net_transform = want_net_transform; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived CompassEffect -// types to return a unique number indicating whether -// this CompassEffect is equivalent to the other one. -// -// This should return 0 if the two CompassEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two CompassEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived CompassEffect types to return a unique + * number indicating whether this CompassEffect is equivalent to the other + * one. + * + * This should return 0 if the two CompassEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two CompassEffect objects whose get_type() + * functions return the same. + */ int CompassEffect:: compare_to_impl(const RenderEffect *other) const { const CompassEffect *ta; @@ -297,39 +268,31 @@ compare_to_impl(const RenderEffect *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CompassEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CompassEffect. + */ void CompassEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CompassEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); dg.add_uint16(_properties); - // *** We don't write out the _reference NodePath right now. Maybe - // we should. + // *** We don't write out the _reference NodePath right now. Maybe we + // should. } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CompassEffect is encountered -// in the Bam file. It should create the CompassEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CompassEffect is encountered in the Bam file. It should create the + * CompassEffect and extract its information from the file. + */ TypedWritable *CompassEffect:: make_from_bam(const FactoryParams ¶ms) { CompassEffect *effect = new CompassEffect; @@ -342,13 +305,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: CompassEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CompassEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CompassEffect. + */ void CompassEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); diff --git a/panda/src/pgraph/compassEffect.h b/panda/src/pgraph/compassEffect.h index 9b6d19038d..60ec6d03e9 100644 --- a/panda/src/pgraph/compassEffect.h +++ b/panda/src/pgraph/compassEffect.h @@ -1,16 +1,15 @@ -// Filename: compassEffect.h -// Created by: drose (16Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compassEffect.h + * @author drose + * @date 2002-07-16 + */ #ifndef COMPASSEFFECT_H #define COMPASSEFFECT_H @@ -21,37 +20,29 @@ #include "luse.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : CompassEffect -// Description : A CompassEffect causes a node to inherit its rotation -// (or pos or scale, if specified) from some other -// reference node in the graph, or more often from the -// root. -// -// In its purest form, a CompassEffect is used to keep -// the node's rotation fixed relative to the top of the -// scene graph, despite other transforms that may exist -// above the node. Hence the name: the node behaves -// like a magnetic compass, always pointing in the same -// direction. -// -// As an couple of generalizing extensions, the -// CompassEffect may also be set up to always orient its -// node according to some other reference node than the -// root of the scene graph. Furthermore, it may -// optionally adjust any of pos, rotation, or scale, -// instead of necessarily rotation; and it may adjust -// individual pos and scale components. (Rotation may -// not be adjusted on an individual component basis; -// that's just asking for trouble.) -// -// Be careful when using the pos and scale modes. In -// these modes, it's possible for the CompassEffect to -// move its node far from its normal bounding volume, -// causing culling to fail. If this is an issue, you -// may need to explicitly set a large (or infinite) -// bounding volume on the effect node. -//////////////////////////////////////////////////////////////////// +/** + * A CompassEffect causes a node to inherit its rotation (or pos or scale, if + * specified) from some other reference node in the graph, or more often from + * the root. + * + * In its purest form, a CompassEffect is used to keep the node's rotation + * fixed relative to the top of the scene graph, despite other transforms that + * may exist above the node. Hence the name: the node behaves like a magnetic + * compass, always pointing in the same direction. + * + * As an couple of generalizing extensions, the CompassEffect may also be set + * up to always orient its node according to some other reference node than + * the root of the scene graph. Furthermore, it may optionally adjust any of + * pos, rotation, or scale, instead of necessarily rotation; and it may adjust + * individual pos and scale components. (Rotation may not be adjusted on an + * individual component basis; that's just asking for trouble.) + * + * Be careful when using the pos and scale modes. In these modes, it's + * possible for the CompassEffect to move its node far from its normal + * bounding volume, causing culling to fail. If this is an issue, you may + * need to explicitly set a large (or infinite) bounding volume on the effect + * node. + */ class EXPCL_PANDA_PGRAPH CompassEffect : public RenderEffect { private: INLINE CompassEffect(); @@ -69,7 +60,7 @@ PUBLISHED: P_scale = 0x070, P_all = 0x07f, }; - static CPT(RenderEffect) make(const NodePath &reference, + static CPT(RenderEffect) make(const NodePath &reference, int properties = P_rot); INLINE const NodePath &get_reference() const; @@ -103,7 +94,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -125,4 +116,3 @@ private: #include "compassEffect.I" #endif - diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 319660780d..d5427a659f 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -1,16 +1,15 @@ -// Filename: config_pgraph.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgraph.cxx + * @author drose + * @date 2002-02-21 + */ #include "config_pgraph.h" @@ -370,14 +369,12 @@ ConfigVariableBool allow_live_flatten "only has an effect when Panda is not compiled for a release " "build.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpgraph -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpgraph() { static bool initialized = false; @@ -512,9 +509,9 @@ init_libpgraph() { TransformState::register_with_read_factory(); TransparencyAttrib::register_with_read_factory(); - // By initializing the _states map up front, we also guarantee that - // the _states_lock mutex gets created before we spawn any threads - // (assuming no one is creating threads at static init time). + // By initializing the _states map up front, we also guarantee that the + // _states_lock mutex gets created before we spawn any threads (assuming no + // one is creating threads at static init time). TransformState::init_states(); RenderState::init_states(); RenderEffects::init_states(); diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 876eae7485..988c9b1d2b 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -1,16 +1,15 @@ -// Filename: config_pgraph.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgraph.h + * @author drose + * @date 2002-02-21 + */ #ifndef CONFIG_PGRAPH_H #define CONFIG_PGRAPH_H diff --git a/panda/src/pgraph/cullBin.I b/panda/src/pgraph/cullBin.I index 3e78aca5ed..12f18c6e37 100644 --- a/panda/src/pgraph/cullBin.I +++ b/panda/src/pgraph/cullBin.I @@ -1,25 +1,21 @@ -// Filename: cullBin.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBin.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBin::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBin:: -CullBin(const CullBin ©) : +CullBin(const CullBin ©) : _name(copy._name), _bin_type(copy._bin_type), _gsg(copy._gsg), @@ -28,11 +24,9 @@ CullBin(const CullBin ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBin:: CullBin(const string &name, CullBin::BinType bin_type, GraphicsStateGuardianBase *gsg, @@ -45,21 +39,17 @@ CullBin(const string &name, CullBin::BinType bin_type, { } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &CullBin:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::get_bin_tyep -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullBin::BinType CullBin:: get_bin_type() const { return _bin_type; diff --git a/panda/src/pgraph/cullBin.cxx b/panda/src/pgraph/cullBin.cxx index 7ce254d5b3..4d5cea887a 100644 --- a/panda/src/pgraph/cullBin.cxx +++ b/panda/src/pgraph/cullBin.cxx @@ -1,16 +1,15 @@ -// Filename: cullBin.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBin.cxx + * @author drose + * @date 2002-02-28 + */ #include "cullBin.h" #include "config_pgraph.h" @@ -24,61 +23,45 @@ PStatCollector CullBin::_cull_bin_pcollector("Cull:Sort"); TypeHandle CullBin::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullBin::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBin:: ~CullBin() { } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::make_next -// Access: Public, Virtual -// Description: Returns a newly-allocated CullBin object that -// contains a copy of just the subset of the data from -// this CullBin object that is worth keeping around -// for next frame. -// -// If a particular CullBin object has no data worth -// preserving till next frame, it is acceptable to -// return NULL (which is the default behavior of this -// method). -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated CullBin object that contains a copy of just the + * subset of the data from this CullBin object that is worth keeping around + * for next frame. + * + * If a particular CullBin object has no data worth preserving till next + * frame, it is acceptable to return NULL (which is the default behavior of + * this method). + */ PT(CullBin) CullBin:: make_next() const { return (CullBin *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::finish_cull -// Access: Public, Virtual -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullBin:: finish_cull(SceneSetup *, Thread *) { } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::make_result_graph -// Access: Public -// Description: Returns a special scene graph constructed to -// represent the results of the cull. This will be a -// single node with a list of GeomNode children, which -// represent the various geom objects discovered by the -// cull. -// -// This is useful mainly for high-level debugging and -// abstraction tools; it should not be mistaken for the -// low-level cull result itself. For the low-level cull -// result, use draw() to efficiently draw the culled -// scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special scene graph constructed to represent the results of the + * cull. This will be a single node with a list of GeomNode children, which + * represent the various geom objects discovered by the cull. + * + * This is useful mainly for high-level debugging and abstraction tools; it + * should not be mistaken for the low-level cull result itself. For the low- + * level cull result, use draw() to efficiently draw the culled scene. + */ PT(PandaNode) CullBin:: make_result_graph() { PT(PandaNode) root_node = new PandaNode(get_name()); @@ -87,11 +70,9 @@ make_result_graph() { return root_node; } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::ResultGraphBuilder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullBin::ResultGraphBuilder:: ResultGraphBuilder(PandaNode *root_node) : _object_index(0), @@ -99,20 +80,17 @@ ResultGraphBuilder(PandaNode *root_node) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::ResultGraphBuilder::add_object -// Access: Public -// Description: Called in fill_result_graph() by a derived CullBin -// class to add each culled object to the result -// returned by make_result_graph(). -//////////////////////////////////////////////////////////////////// +/** + * Called in fill_result_graph() by a derived CullBin class to add each culled + * object to the result returned by make_result_graph(). + */ void CullBin::ResultGraphBuilder:: add_object(CullableObject *object) { if (_current_transform != object->_internal_transform || _current_state != object->_state) { - // Create a new GeomNode to hold the net transform and state. We - // choose to create a new GeomNode for each new state, to make it - // clearer to the observer when the state changes. + // Create a new GeomNode to hold the net transform and state. We choose + // to create a new GeomNode for each new state, to make it clearer to the + // observer when the state changes. _current_transform = object->_internal_transform; _current_state = object->_state; _current_node = new GeomNode("object_" + format_string(_object_index)); @@ -125,11 +103,9 @@ add_object(CullableObject *object) { ++_object_index; } -//////////////////////////////////////////////////////////////////// -// Function: CullBin::ResultGraphBuilder::record_one_object -// Access: Private -// Description: Records a single object. -//////////////////////////////////////////////////////////////////// +/** + * Records a single object. + */ void CullBin::ResultGraphBuilder:: record_one_object(GeomNode *node, CullableObject *object) { PT(Geom) new_geom = object->_geom->make_copy(); diff --git a/panda/src/pgraph/cullBin.h b/panda/src/pgraph/cullBin.h index e93f7bed9b..3f9615cccb 100644 --- a/panda/src/pgraph/cullBin.h +++ b/panda/src/pgraph/cullBin.h @@ -1,16 +1,15 @@ -// Filename: cullBin.h -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBin.h + * @author drose + * @date 2002-02-27 + */ #ifndef CULLBIN_H #define CULLBIN_H @@ -30,17 +29,14 @@ class RenderState; class PandaNode; class GeomNode; -//////////////////////////////////////////////////////////////////// -// Class : CullBin -// Description : A collection of Geoms and their associated state, for -// a particular scene. The cull traversal (and the -// BinCullHandler) assigns Geoms to bins as it comes -// across them. -// -// This is an abstract base class; derived classes like -// CullBinStateSorted and CullBinBackToFront provide the -// actual implementation. -//////////////////////////////////////////////////////////////////// +/** + * A collection of Geoms and their associated state, for a particular scene. + * The cull traversal (and the BinCullHandler) assigns Geoms to bins as it + * comes across them. + * + * This is an abstract base class; derived classes like CullBinStateSorted and + * CullBinBackToFront provide the actual implementation. + */ class EXPCL_PANDA_PGRAPH CullBin : public TypedReferenceCount, public CullBinEnums { protected: INLINE CullBin(const CullBin ©); @@ -119,6 +115,3 @@ private: #include "cullBin.I" #endif - - - diff --git a/panda/src/pgraph/cullBinAttrib.I b/panda/src/pgraph/cullBinAttrib.I index 0d6fda49c1..945d3244ca 100644 --- a/panda/src/pgraph/cullBinAttrib.I +++ b/panda/src/pgraph/cullBinAttrib.I @@ -1,49 +1,38 @@ -// Filename: cullBinAttrib.I -// Created by: drose (01Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinAttrib.I + * @author drose + * @date 2002-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::Constructor -// Access: Private -// Description: Use CullBinAttrib::make() to construct a new -// CullBinAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use CullBinAttrib::make() to construct a new CullBinAttrib object. + */ INLINE CullBinAttrib:: CullBinAttrib() { _draw_order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::get_bin_name -// Access: Published -// Description: Returns the name of the bin this attribute specifies. -// If this is the empty string, it refers to the default -// bin. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the bin this attribute specifies. If this is the empty + * string, it refers to the default bin. + */ INLINE const string &CullBinAttrib:: get_bin_name() const { return _bin_name; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::get_draw_order -// Access: Published -// Description: Returns the draw order this attribute specifies. -// Some bins (in particular, CullBinFixed bins) use this -// to further specify the order in which objects should -// be rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the draw order this attribute specifies. Some bins (in particular, + * CullBinFixed bins) use this to further specify the order in which objects + * should be rendered. + */ INLINE int CullBinAttrib:: get_draw_order() const { return _draw_order; diff --git a/panda/src/pgraph/cullBinAttrib.cxx b/panda/src/pgraph/cullBinAttrib.cxx index 3d7707b93e..f8eb40626d 100644 --- a/panda/src/pgraph/cullBinAttrib.cxx +++ b/panda/src/pgraph/cullBinAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinAttrib.cxx -// Created by: drose (01Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinAttrib.cxx + * @author drose + * @date 2002-03-01 + */ #include "cullBinAttrib.h" #include "bamReader.h" @@ -21,17 +20,13 @@ TypeHandle CullBinAttrib::_type_handle; int CullBinAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::make -// Access: Published, Static -// Description: Constructs a new CullBinAttrib assigning geometry -// into the named bin. If the bin name is the empty -// string, the default bin is used. -// -// The draw_order specifies further ordering information -// which is relevant only to certain kinds of bins (in -// particular CullBinFixed type bins). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CullBinAttrib assigning geometry into the named bin. If + * the bin name is the empty string, the default bin is used. + * + * The draw_order specifies further ordering information which is relevant + * only to certain kinds of bins (in particular CullBinFixed type bins). + */ CPT(RenderAttrib) CullBinAttrib:: make(const string &bin_name, int draw_order) { CullBinAttrib *attrib = new CullBinAttrib; @@ -40,23 +35,18 @@ make(const string &bin_name, int draw_order) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) CullBinAttrib:: make_default() { return return_new(new CullBinAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CullBinAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -67,21 +57,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived CullBinAttrib -// types to return a unique number indicating whether -// this CullBinAttrib is equivalent to the other one. -// -// This should return 0 if the two CullBinAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two CullBinAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived CullBinAttrib types to return a unique + * number indicating whether this CullBinAttrib is equivalent to the other + * one. + * + * This should return 0 if the two CullBinAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two CullBinAttrib objects whose get_type() + * functions return the same. + */ int CullBinAttrib:: compare_to_impl(const RenderAttrib *other) const { const CullBinAttrib *ta = (const CullBinAttrib *)other; @@ -92,16 +79,12 @@ compare_to_impl(const RenderAttrib *other) const { return strcmp(_bin_name.c_str(), ta->_bin_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t CullBinAttrib:: get_hash_impl() const { size_t hash = 0; @@ -110,23 +93,18 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CullBinAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CullBinAttrib. + */ void CullBinAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CullBinAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -135,14 +113,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int32(_draw_order); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CullBinAttrib is encountered -// in the Bam file. It should create the CullBinAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CullBinAttrib is encountered in the Bam file. It should create the + * CullBinAttrib and extract its information from the file. + */ TypedWritable *CullBinAttrib:: make_from_bam(const FactoryParams ¶ms) { CullBinAttrib *attrib = new CullBinAttrib; @@ -155,13 +130,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CullBinAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CullBinAttrib. + */ void CullBinAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/cullBinAttrib.h b/panda/src/pgraph/cullBinAttrib.h index f1a0809caf..c61fd2ebfc 100644 --- a/panda/src/pgraph/cullBinAttrib.h +++ b/panda/src/pgraph/cullBinAttrib.h @@ -1,16 +1,15 @@ -// Filename: cullBinAttrib.h -// Created by: drose (01Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinAttrib.h + * @author drose + * @date 2002-03-01 + */ #ifndef CULLBINATTRIB_H #define CULLBINATTRIB_H @@ -21,12 +20,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : CullBinAttrib -// Description : Assigns geometry to a particular bin by name. The -// bins must be created separately via the -// CullBinManager interface. -//////////////////////////////////////////////////////////////////// +/** + * Assigns geometry to a particular bin by name. The bins must be created + * separately via the CullBinManager interface. + */ class EXPCL_PANDA_PGRAPH CullBinAttrib : public RenderAttrib { private: INLINE CullBinAttrib(); @@ -64,7 +61,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -88,4 +85,3 @@ private: #include "cullBinAttrib.I" #endif - diff --git a/panda/src/pgraph/cullBinEnums.h b/panda/src/pgraph/cullBinEnums.h index 4aff4eff9a..aa82fe2203 100644 --- a/panda/src/pgraph/cullBinEnums.h +++ b/panda/src/pgraph/cullBinEnums.h @@ -1,27 +1,25 @@ -// Filename: cullBinEnums.h -// Created by: drose (03Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinEnums.h + * @author drose + * @date 2006-04-03 + */ #ifndef CULLBINENUMS_H #define CULLBINENUMS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : CullBinEnums -// Description : Provides scoping for the enumerated type shared by -// CullBin and CullBinManager. -//////////////////////////////////////////////////////////////////// +/** + * Provides scoping for the enumerated type shared by CullBin and + * CullBinManager. + */ class EXPCL_PANDA_PGRAPH CullBinEnums { PUBLISHED: enum BinType { @@ -35,4 +33,3 @@ PUBLISHED: }; #endif - diff --git a/panda/src/pgraph/cullBinManager.I b/panda/src/pgraph/cullBinManager.I index 0ba7368060..7bafdea5d6 100644 --- a/panda/src/pgraph/cullBinManager.I +++ b/panda/src/pgraph/cullBinManager.I @@ -1,38 +1,30 @@ -// Filename: cullBinManager.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinManager.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::SortBins::Constructor -// Access: Public -// Description: This is a function object whose sole purpose is to -// put the _sorted_bins vector in the proper order for -// rendering the bins. -//////////////////////////////////////////////////////////////////// +/** + * This is a function object whose sole purpose is to put the _sorted_bins + * vector in the proper order for rendering the bins. + */ INLINE CullBinManager::SortBins:: SortBins(CullBinManager *manager) : _manager(manager) { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::SortBins::operator () -// Access: Public -// Description: The function call method of the function object. -// Returns true if the two bin indices are already in -// sorted order with a < b, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * The function call method of the function object. Returns true if the two + * bin indices are already in sorted order with a < b, or false otherwise. + */ INLINE bool CullBinManager::SortBins:: operator () (int a, int b) const { return _manager->_bin_definitions[a]._sort < _manager->_bin_definitions[b]._sort; @@ -40,45 +32,37 @@ operator () (int a, int b) const { -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_num_bins -// Access: Published -// Description: Returns the number of bins in the world. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bins in the world. + */ INLINE int CullBinManager:: get_num_bins() const { - // We quietly sort the bins in order if they are not already sorted. - // This is a non-const operation, but we pretend it's const because - // it's intended to be a transparent update. + // We quietly sort the bins in order if they are not already sorted. This + // is a non-const operation, but we pretend it's const because it's intended + // to be a transparent update. if (!_bins_are_sorted) { ((CullBinManager *)this)->do_sort_bins(); } return _sorted_bins.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin -// Access: Published -// Description: Returns the bin_index of the nth bin in the set, -// where n is a number between 0 and get_num_bins(). -// This returns the list of bin_index numbers, in sorted -// order (that is, in the order in which the bins should -// be rendered). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bin_index of the nth bin in the set, where n is a number + * between 0 and get_num_bins(). This returns the list of bin_index numbers, + * in sorted order (that is, in the order in which the bins should be + * rendered). + */ INLINE int CullBinManager:: get_bin(int n) const { nassertr(n >= 0 && n < (int)_sorted_bins.size(), -1); return _sorted_bins[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_name -// Access: Published -// Description: Returns the name of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). The bin's name may not be changed -// during the life of the bin. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the bin with the indicated bin_index (where bin_index + * was retrieved by get_bin() or find_bin()). The bin's name may not be + * changed during the life of the bin. + */ INLINE string CullBinManager:: get_bin_name(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), string()); @@ -86,13 +70,10 @@ get_bin_name(int bin_index) const { return _bin_definitions[bin_index]._name; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_type -// Access: Published -// Description: Returns the type of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the bin with the indicated bin_index (where bin_index + * was retrieved by get_bin() or find_bin()). + */ INLINE CullBinManager::BinType CullBinManager:: get_bin_type(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), BT_invalid); @@ -100,12 +81,9 @@ get_bin_type(int bin_index) const { return _bin_definitions[bin_index]._type; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_type -// Access: Published -// Description: Returns the type of the bin with the indicated -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the bin with the indicated name. + */ INLINE CullBinManager::BinType CullBinManager:: get_bin_type(const string &name) const { int bin_index = find_bin(name); @@ -113,17 +91,13 @@ get_bin_type(const string &name) const { return get_bin_type(bin_index); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_type -// Access: Published -// Description: Changes the type of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -// -// The change might be effective immediately, or it -// might take place next frame, depending on the bin -// type. -//////////////////////////////////////////////////////////////////// +/** + * Changes the type of the bin with the indicated bin_index (where bin_index + * was retrieved by get_bin() or find_bin()). + * + * The change might be effective immediately, or it might take place next + * frame, depending on the bin type. + */ INLINE void CullBinManager:: set_bin_type(int bin_index, CullBinManager::BinType type) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); @@ -131,16 +105,12 @@ set_bin_type(int bin_index, CullBinManager::BinType type) { _bin_definitions[bin_index]._type = type; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_type -// Access: Published -// Description: Changes the type of the bin with the indicated -// name. -// -// The change might be effective immediately, or it -// might take place next frame, depending on the bin -// type. -//////////////////////////////////////////////////////////////////// +/** + * Changes the type of the bin with the indicated name. + * + * The change might be effective immediately, or it might take place next + * frame, depending on the bin type. + */ INLINE void CullBinManager:: set_bin_type(const string &name, CullBinManager::BinType type) { int bin_index = find_bin(name); @@ -148,17 +118,13 @@ set_bin_type(const string &name, CullBinManager::BinType type) { set_bin_type(bin_index, type); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_sort -// Access: Published -// Description: Returns the sort order of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -// -// The bins are rendered in increasing order by their -// sort order; this number may be changed from time to -// time to reorder the bins. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort order of the bin with the indicated bin_index (where + * bin_index was retrieved by get_bin() or find_bin()). + * + * The bins are rendered in increasing order by their sort order; this number + * may be changed from time to time to reorder the bins. + */ INLINE int CullBinManager:: get_bin_sort(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), 0); @@ -166,16 +132,12 @@ get_bin_sort(int bin_index) const { return _bin_definitions[bin_index]._sort; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_sort -// Access: Published -// Description: Returns the sort order of the bin with the indicated -// name. -// -// The bins are rendered in increasing order by their -// sort order; this number may be changed from time to -// time to reorder the bins. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort order of the bin with the indicated name. + * + * The bins are rendered in increasing order by their sort order; this number + * may be changed from time to time to reorder the bins. + */ INLINE int CullBinManager:: get_bin_sort(const string &name) const { int bin_index = find_bin(name); @@ -183,17 +145,13 @@ get_bin_sort(const string &name) const { return get_bin_sort(bin_index); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_sort -// Access: Published -// Description: Changes the sort order of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -// -// The bins are rendered in increasing order by their -// sort order; this number may be changed from time to -// time to reorder the bins. -//////////////////////////////////////////////////////////////////// +/** + * Changes the sort order of the bin with the indicated bin_index (where + * bin_index was retrieved by get_bin() or find_bin()). + * + * The bins are rendered in increasing order by their sort order; this number + * may be changed from time to time to reorder the bins. + */ INLINE void CullBinManager:: set_bin_sort(int bin_index, int sort) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); @@ -202,16 +160,12 @@ set_bin_sort(int bin_index, int sort) { _bins_are_sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_sort -// Access: Published -// Description: Changes the sort order of the bin with the indicated -// name. -// -// The bins are rendered in increasing order by their -// sort order; this number may be changed from time to -// time to reorder the bins. -//////////////////////////////////////////////////////////////////// +/** + * Changes the sort order of the bin with the indicated name. + * + * The bins are rendered in increasing order by their sort order; this number + * may be changed from time to time to reorder the bins. + */ INLINE void CullBinManager:: set_bin_sort(const string &name, int sort) { int bin_index = find_bin(name); @@ -219,16 +173,12 @@ set_bin_sort(const string &name, int sort) { set_bin_sort(bin_index, sort); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_active -// Access: Published -// Description: Returns the active flag of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -// -// When a bin is marked inactive, all geometry assigned -// to it is not rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag of the bin with the indicated bin_index (where + * bin_index was retrieved by get_bin() or find_bin()). + * + * When a bin is marked inactive, all geometry assigned to it is not rendered. + */ INLINE bool CullBinManager:: get_bin_active(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), false); @@ -236,15 +186,11 @@ get_bin_active(int bin_index) const { return _bin_definitions[bin_index]._active; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_active -// Access: Published -// Description: Returns the active flag of the bin with the indicated -// name. -// -// When a bin is marked inactive, all geometry assigned -// to it is not rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag of the bin with the indicated name. + * + * When a bin is marked inactive, all geometry assigned to it is not rendered. + */ INLINE bool CullBinManager:: get_bin_active(const string &name) const { int bin_index = find_bin(name); @@ -252,16 +198,12 @@ get_bin_active(const string &name) const { return get_bin_active(bin_index); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_active -// Access: Published -// Description: Changes the active flag of the bin with the indicated -// bin_index (where bin_index was retrieved by get_bin() -// or find_bin()). -// -// When a bin is marked inactive, all geometry assigned -// to it is not rendered. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active flag of the bin with the indicated bin_index (where + * bin_index was retrieved by get_bin() or find_bin()). + * + * When a bin is marked inactive, all geometry assigned to it is not rendered. + */ INLINE void CullBinManager:: set_bin_active(int bin_index, bool active) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); @@ -269,15 +211,11 @@ set_bin_active(int bin_index, bool active) { _bin_definitions[bin_index]._active = active; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_active -// Access: Published -// Description: Changes the active flag of the bin with the indicated -// name. -// -// When a bin is marked inactive, all geometry assigned -// to it is not rendered. -//////////////////////////////////////////////////////////////////// +/** + * Changes the active flag of the bin with the indicated name. + * + * When a bin is marked inactive, all geometry assigned to it is not rendered. + */ INLINE void CullBinManager:: set_bin_active(const string &name, bool active) { int bin_index = find_bin(name); @@ -286,57 +224,49 @@ set_bin_active(const string &name, bool active) { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_flash_active -// Access: Published -// Description: Returns true if the bin with the given bin_index is -// configured to flash at a predetermined color (where -// bin_index was retrieved by get_bin() or find_bin()). -// -// This method is not available in release builds. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the bin with the given bin_index is configured to flash at + * a predetermined color (where bin_index was retrieved by get_bin() or + * find_bin()). + * + * This method is not available in release builds. + */ INLINE bool CullBinManager:: get_bin_flash_active(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), false); return _bin_definitions[bin_index]._flash_active; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_bin_flash_color -// Access: Published -// Description: Returns the color that this bin has been configured -// to flash to, if configured. -// -// This method is not available in release builds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color that this bin has been configured to flash to, if + * configured. + * + * This method is not available in release builds. + */ INLINE const LColor &CullBinManager:: get_bin_flash_color(int bin_index) const { nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), LColor::zero()); return _bin_definitions[bin_index]._flash_color; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_flash_active -// Access: Published -// Description: When set to true, the given bin_index is configured -// to flash at a predetermined color (where -// bin_index was retrieved by get_bin() or find_bin()). -// -// This method is not available in release builds. -//////////////////////////////////////////////////////////////////// +/** + * When set to true, the given bin_index is configured to flash at a + * predetermined color (where bin_index was retrieved by get_bin() or + * find_bin()). + * + * This method is not available in release builds. + */ INLINE void CullBinManager:: set_bin_flash_active(int bin_index, bool active) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); _bin_definitions[bin_index]._flash_active = active; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::set_bin_flash_color -// Access: Published -// Description: Changes the flash color for the given bin index. -// -// This method is not available in release builds. -//////////////////////////////////////////////////////////////////// +/** + * Changes the flash color for the given bin index. + * + * This method is not available in release builds. + */ INLINE void CullBinManager:: set_bin_flash_color(int bin_index, const LColor &color) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); @@ -344,12 +274,9 @@ set_bin_flash_color(int bin_index, const LColor &color) { } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::get_global_ptr -// Access: Published, Static -// Description: Returns the pointer to the global CullBinManager -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the global CullBinManager object. + */ INLINE CullBinManager *CullBinManager:: get_global_ptr() { if (_global_ptr == (CullBinManager *)NULL) { diff --git a/panda/src/pgraph/cullBinManager.cxx b/panda/src/pgraph/cullBinManager.cxx index 9223035f82..0d979cf7e7 100644 --- a/panda/src/pgraph/cullBinManager.cxx +++ b/panda/src/pgraph/cullBinManager.cxx @@ -1,16 +1,15 @@ -// Filename: cullBinManager.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinManager.cxx + * @author drose + * @date 2002-02-28 + */ #include "cullBinManager.h" #include "renderState.h" @@ -21,15 +20,12 @@ CullBinManager *CullBinManager::_global_ptr = (CullBinManager *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::Constructor -// Access: Protected -// Description: The constructor is not intended to be called -// directly; there is only one CullBinManager and it -// constructs itself. This could have been a private -// constructor, but gcc issues a spurious warning if the -// constructor is private and the class has no friends. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there is only one + * CullBinManager and it constructs itself. This could have been a private + * constructor, but gcc issues a spurious warning if the constructor is + * private and the class has no friends. + */ CullBinManager:: CullBinManager() { _bins_are_sorted = true; @@ -38,30 +34,24 @@ CullBinManager() { setup_initial_bins(); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::Destructor -// Access: Protected -// Description: Don't call the destructor. -//////////////////////////////////////////////////////////////////// +/** + * Don't call the destructor. + */ CullBinManager:: ~CullBinManager() { } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::add_bin -// Access: Published -// Description: Defines a new bin with the indicated name, and -// returns the new bin_index. If there is already a bin -// with the same name returns its bin_index if it had -// the same properties; otherwise, reports an error and -// returns -1. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new bin with the indicated name, and returns the new bin_index. + * If there is already a bin with the same name returns its bin_index if it + * had the same properties; otherwise, reports an error and returns -1. + */ int CullBinManager:: add_bin(const string &name, BinType type, int sort) { BinsByName::const_iterator bni = _bins_by_name.find(name); if (bni != _bins_by_name.end()) { - // We already have such a bin. This is not a problem if the bin - // has the same properties. + // We already have such a bin. This is not a problem if the bin has the + // same properties. int bin_index = (*bni).second; nassertr(bin_index >= 0 && bin_index < (int)_bin_definitions.size(), -1); const BinDefinition &def = _bin_definitions[bin_index]; @@ -77,12 +67,11 @@ add_bin(const string &name, BinType type, int sort) { return -1; } - // No bin by that name already; choose a bin_index to assign to the - // newly created bin. + // No bin by that name already; choose a bin_index to assign to the newly + // created bin. int new_bin_index = -1; if (_unused_bin_index) { - // If there is some bin index that's not being used, we can claim - // it. + // If there is some bin index that's not being used, we can claim it. int i = 0; for (i = 0; i < (int)_bin_definitions.size() && new_bin_index == -1; i++) { if (!_bin_definitions[i]._in_use) { @@ -128,17 +117,13 @@ add_bin(const string &name, BinType type, int sort) { return new_bin_index; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::remove_bin -// Access: Published -// Description: Permanently removes the indicated bin. This -// operation is not protected from the pipeline and will -// disturb whatever is currently rendering in draw. You -// should not call this during the normal course of -// rendering a frame; it is intended only as an aid to -// development, to allow the developer to interactively -// fiddle with the set of bins. -//////////////////////////////////////////////////////////////////// +/** + * Permanently removes the indicated bin. This operation is not protected + * from the pipeline and will disturb whatever is currently rendering in draw. + * You should not call this during the normal course of rendering a frame; it + * is intended only as an aid to development, to allow the developer to + * interactively fiddle with the set of bins. + */ void CullBinManager:: remove_bin(int bin_index) { nassertv(bin_index >= 0 && bin_index < (int)_bin_definitions.size()); @@ -151,24 +136,21 @@ remove_bin(int bin_index) { _sorted_bins.erase(si); _bins_by_name.erase(_bin_definitions[bin_index]._name); - // Now we have to make sure all of the data objects in the world - // that had cached this bin index or have a bin object are correctly - // updated. + // Now we have to make sure all of the data objects in the world that had + // cached this bin index or have a bin object are correctly updated. - // First, tell all the RenderStates in the world to reset their bin - // index cache. + // First, tell all the RenderStates in the world to reset their bin index + // cache. RenderState::bin_removed(bin_index); // Now tell all the CullResults to clear themselves up too. CullResult::bin_removed(bin_index); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::find_bin -// Access: Published -// Description: Returns the bin_index associated with the bin of the -// given name, or -1 if no bin has that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bin_index associated with the bin of the given name, or -1 if + * no bin has that name. + */ int CullBinManager:: find_bin(const string &name) const { BinsByName::const_iterator bni; @@ -179,11 +161,9 @@ find_bin(const string &name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CullBinManager:: write(ostream &out) const { if (!_bins_are_sorted) { @@ -197,14 +177,11 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::make_new_bin -// Access: Public -// Description: Intended to be called by CullResult when a new -// CullBin pointer corresponding to the indicated -// bin_index is required. It allocates and returns a -// brand new CullBin object of the appropriate type. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by CullResult when a new CullBin pointer + * corresponding to the indicated bin_index is required. It allocates and + * returns a brand new CullBin object of the appropriate type. + */ PT(CullBin) CullBinManager:: make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) { @@ -224,37 +201,29 @@ make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::register_bin_type -// Access: Public -// Description: Intended to be called at startup type by each CullBin -// type, to register the constructor for each type. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called at startup type by each CullBin type, to register the + * constructor for each type. + */ void CullBinManager:: register_bin_type(BinType type, CullBinManager::BinConstructor *constructor) { bool inserted = _bin_constructors.insert(BinConstructors::value_type(type, constructor)).second; nassertv(inserted); } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::do_sort_bins -// Access: Private -// Description: Puts the _sorted_bins vector in proper rendering -// order. -//////////////////////////////////////////////////////////////////// +/** + * Puts the _sorted_bins vector in proper rendering order. + */ void CullBinManager:: do_sort_bins() { sort(_sorted_bins.begin(), _sorted_bins.end(), SortBins(this)); _bins_are_sorted = true; } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::setup_initial_bins -// Access: Private -// Description: Called only at construction time to create the -// default bins and the bins specified in the Configrc -// file. -//////////////////////////////////////////////////////////////////// +/** + * Called only at construction time to create the default bins and the bins + * specified in the Configrc file. + */ void CullBinManager:: setup_initial_bins() { ConfigVariableList cull_bin @@ -269,8 +238,8 @@ setup_initial_bins() { for (int bi = 0; bi < num_bins; bi++) { string def = cull_bin.get_unique_value(bi); - // This is a string in three tokens, separated by whitespace: - // bin_name sort type + // This is a string in three tokens, separated by whitespace: bin_name + // sort type vector_string words; extract_words(def, words); @@ -299,8 +268,8 @@ setup_initial_bins() { } } - // Now add the default bins, unless the names have already been - // specified explicitly in the Config file, above. + // Now add the default bins, unless the names have already been specified + // explicitly in the Config file, above. if (find_bin("background") == -1) { add_bin("background", BT_fixed, 10); } @@ -318,13 +287,10 @@ setup_initial_bins() { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::parse_bin_type -// Access: Private, Static -// Description: Given the name of a bin type, returns the -// corresponding BinType value, or BT_invalid if it is -// an unknown type. -//////////////////////////////////////////////////////////////////// +/** + * Given the name of a bin type, returns the corresponding BinType value, or + * BT_invalid if it is an unknown type. + */ CullBinManager::BinType CullBinManager:: parse_bin_type(const string &bin_type) { if (cmp_nocase_uh(bin_type, "unsorted") == 0) { @@ -347,10 +313,9 @@ parse_bin_type(const string &bin_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullBinManager::BinType output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, CullBinManager::BinType bin_type) { switch (bin_type) { diff --git a/panda/src/pgraph/cullBinManager.h b/panda/src/pgraph/cullBinManager.h index 3957359b50..79ac5d9749 100644 --- a/panda/src/pgraph/cullBinManager.h +++ b/panda/src/pgraph/cullBinManager.h @@ -1,16 +1,15 @@ -// Filename: cullBinManager.h -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullBinManager.h + * @author drose + * @date 2002-02-27 + */ #ifndef CULLBINMANAGER_H #define CULLBINMANAGER_H @@ -28,11 +27,10 @@ class CullResult; class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : CullBinManager -// Description : This is a global object that maintains the collection -// of named CullBins in the world. -//////////////////////////////////////////////////////////////////// +/** + * This is a global object that maintains the collection of named CullBins in + * the world. + */ class EXPCL_PANDA_PGRAPH CullBinManager : public CullBinEnums { protected: CullBinManager(); @@ -82,9 +80,9 @@ public: PT(CullBin) make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); - // This defines the factory interface for defining constructors to - // bin types (the implementations are in the cull directory, not - // here in pgraph, so we can't call the constructors directly). + // This defines the factory interface for defining constructors to bin types + // (the implementations are in the cull directory, not here in pgraph, so we + // can't call the constructors directly). typedef CullBin *BinConstructor(const string &name, GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector); diff --git a/panda/src/pgraph/cullFaceAttrib.I b/panda/src/pgraph/cullFaceAttrib.I index 6757e59a0d..a0590e5291 100644 --- a/panda/src/pgraph/cullFaceAttrib.I +++ b/panda/src/pgraph/cullFaceAttrib.I @@ -1,24 +1,19 @@ -// Filename: cullFaceAttrib.I -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullFaceAttrib.I + * @author drose + * @date 2002-02-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::Constructor -// Access: Private -// Description: Use CullFaceAttrib::make() to construct a new -// CullFaceAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use CullFaceAttrib::make() to construct a new CullFaceAttrib object. + */ INLINE CullFaceAttrib:: CullFaceAttrib(CullFaceAttrib::Mode mode, bool reverse) : _mode(mode), @@ -26,29 +21,21 @@ CullFaceAttrib(CullFaceAttrib::Mode mode, bool reverse) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::get_actual_mode -// Access: Published -// Description: Returns the actual culling mode, without considering -// the effects of the reverse flag. See also -// get_effective_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual culling mode, without considering the effects of the + * reverse flag. See also get_effective_mode(). + */ INLINE CullFaceAttrib::Mode CullFaceAttrib:: get_actual_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::get_reverse -// Access: Published -// Description: Returns the 'reverse' flag. If this is true, the -// actual cull direction (clockwise -// vs. counterclockwise) is the reverse of what is -// specified here. This allows support for -// make_reverse(), which defines a CullFaceAttrib that -// reverses whatever the sense of culling would have -// been. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 'reverse' flag. If this is true, the actual cull direction + * (clockwise vs. counterclockwise) is the reverse of what is specified here. + * This allows support for make_reverse(), which defines a CullFaceAttrib that + * reverses whatever the sense of culling would have been. + */ INLINE bool CullFaceAttrib:: get_reverse() const { return _reverse; diff --git a/panda/src/pgraph/cullFaceAttrib.cxx b/panda/src/pgraph/cullFaceAttrib.cxx index 8fa8b1c19b..db3527a653 100644 --- a/panda/src/pgraph/cullFaceAttrib.cxx +++ b/panda/src/pgraph/cullFaceAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: cullFaceAttrib.cxx -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullFaceAttrib.cxx + * @author drose + * @date 2002-02-27 + */ #include "cullFaceAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,61 +22,47 @@ TypeHandle CullFaceAttrib::_type_handle; int CullFaceAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::make -// Access: Published, Static -// Description: Constructs a new CullFaceAttrib object that specifies -// how to cull geometry. By Panda convention, vertices -// are ordered counterclockwise when seen from the -// front, so the M_cull_clockwise will cull backfacing -// polygons. -// -// M_cull_unchanged is an identity attrib; if this is -// applied to vertices without any other intervening -// attrib, it is the same as applying the default -// attrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CullFaceAttrib object that specifies how to cull geometry. + * By Panda convention, vertices are ordered counterclockwise when seen from + * the front, so the M_cull_clockwise will cull backfacing polygons. + * + * M_cull_unchanged is an identity attrib; if this is applied to vertices + * without any other intervening attrib, it is the same as applying the + * default attrib. + */ CPT(RenderAttrib) CullFaceAttrib:: make(CullFaceAttrib::Mode mode) { CullFaceAttrib *attrib = new CullFaceAttrib(mode, false); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::make_reverse -// Access: Published, Static -// Description: Constructs a new CullFaceAttrib object that reverses -// the effects of any other CullFaceAttrib objects in -// the scene graph. M_cull_clockwise will be treated as -// M_cull_counter_clockwise, and vice-versa. -// M_cull_none is unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new CullFaceAttrib object that reverses the effects of any + * other CullFaceAttrib objects in the scene graph. M_cull_clockwise will be + * treated as M_cull_counter_clockwise, and vice-versa. M_cull_none is + * unchanged. + */ CPT(RenderAttrib) CullFaceAttrib:: make_reverse() { CullFaceAttrib *attrib = new CullFaceAttrib(M_cull_unchanged, true); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) CullFaceAttrib:: make_default() { return return_new(new CullFaceAttrib(M_cull_clockwise, false)); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::get_effective_mode -// Access: Published -// Description: Returns the effective culling mode. This is the same -// as the actual culling mode, unless the reverse flag -// is set, which swaps CW for CCW and vice-versa. Also, -// M_cull_unchanged is mapped to M_cull_none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the effective culling mode. This is the same as the actual culling + * mode, unless the reverse flag is set, which swaps CW for CCW and vice- + * versa. Also, M_cull_unchanged is mapped to M_cull_none. + */ CullFaceAttrib::Mode CullFaceAttrib:: get_effective_mode() const { if (_reverse) { @@ -106,15 +91,13 @@ get_effective_mode() const { break; } } - + return M_cull_none; } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CullFaceAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -137,21 +120,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived CullFaceAttrib -// types to return a unique number indicating whether -// this CullFaceAttrib is equivalent to the other one. -// -// This should return 0 if the two CullFaceAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two CullFaceAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived CullFaceAttrib types to return a + * unique number indicating whether this CullFaceAttrib is equivalent to the + * other one. + * + * This should return 0 if the two CullFaceAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two CullFaceAttrib objects whose get_type() + * functions return the same. + */ int CullFaceAttrib:: compare_to_impl(const RenderAttrib *other) const { const CullFaceAttrib *ta = (const CullFaceAttrib *)other; @@ -162,16 +142,12 @@ compare_to_impl(const RenderAttrib *other) const { return (int)_reverse - (int)ta->_reverse; } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t CullFaceAttrib:: get_hash_impl() const { size_t hash = 0; @@ -180,35 +156,29 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) CullFaceAttrib:: compose_impl(const RenderAttrib *other) const { const CullFaceAttrib *ta = (const CullFaceAttrib *)other; if (!_reverse && ta->_mode != M_cull_unchanged) { - // The normal case (there is nothing funny going on): the second - // attrib completely replaces this attrib. + // The normal case (there is nothing funny going on): the second attrib + // completely replaces this attrib. return other; } - // In the more complex case, the two attribs affect each other in - // some way, and we must generate a new attrib from the result. + // In the more complex case, the two attribs affect each other in some way, + // and we must generate a new attrib from the result. Mode mode = _mode; if (ta->_mode != M_cull_unchanged) { mode = ta->_mode; @@ -219,21 +189,18 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) CullFaceAttrib:: invert_compose_impl(const RenderAttrib *other) const { const CullFaceAttrib *ta = (const CullFaceAttrib *)other; - // The invert case is the same as the normal case, except that the - // meaning of _reverse is inverted. See compose_impl(), above. + // The invert case is the same as the normal case, except that the meaning + // of _reverse is inverted. See compose_impl(), above. if (_reverse && ta->_mode != M_cull_unchanged) { return other; @@ -249,23 +216,18 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CullFaceAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CullFaceAttrib. + */ void CullFaceAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CullFaceAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -274,14 +236,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_reverse); } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CullFaceAttrib is encountered -// in the Bam file. It should create the CullFaceAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CullFaceAttrib is encountered in the Bam file. It should create the + * CullFaceAttrib and extract its information from the file. + */ TypedWritable *CullFaceAttrib:: make_from_bam(const FactoryParams ¶ms) { CullFaceAttrib *attrib = new CullFaceAttrib(M_cull_none, false); @@ -294,13 +253,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: CullFaceAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CullFaceAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CullFaceAttrib. + */ void CullFaceAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/cullFaceAttrib.h b/panda/src/pgraph/cullFaceAttrib.h index 7ac2427e91..1dc2d8147e 100644 --- a/panda/src/pgraph/cullFaceAttrib.h +++ b/panda/src/pgraph/cullFaceAttrib.h @@ -1,16 +1,15 @@ -// Filename: cullFaceAttrib.h -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullFaceAttrib.h + * @author drose + * @date 2002-02-27 + */ #ifndef CULLFACEATTRIB_H #define CULLFACEATTRIB_H @@ -21,11 +20,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : CullFaceAttrib -// Description : Indicates which faces should be culled based on their -// vertex ordering. -//////////////////////////////////////////////////////////////////// +/** + * Indicates which faces should be culled based on their vertex ordering. + */ class EXPCL_PANDA_PGRAPH CullFaceAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -75,7 +72,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -100,4 +97,3 @@ private: #include "cullFaceAttrib.I" #endif - diff --git a/panda/src/pgraph/cullHandler.I b/panda/src/pgraph/cullHandler.I index 01ceb6adf1..4ea7a13837 100644 --- a/panda/src/pgraph/cullHandler.I +++ b/panda/src/pgraph/cullHandler.I @@ -1,25 +1,21 @@ -// Filename: cullHandler.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullHandler.I + * @author drose + * @date 2002-03-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: CullHandler::draw -// Access: Public, Static -// Description: Draws the indicated CullableObject, with full support -// for decals if they are attached to the object. The -// appropriate state is set on the GSG before drawing -// the object. -//////////////////////////////////////////////////////////////////// +/** + * Draws the indicated CullableObject, with full support for decals if they + * are attached to the object. The appropriate state is set on the GSG before + * drawing the object. + */ INLINE void CullHandler:: draw(CullableObject *object, GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { diff --git a/panda/src/pgraph/cullHandler.cxx b/panda/src/pgraph/cullHandler.cxx index 2bbe56924c..b8f889706d 100644 --- a/panda/src/pgraph/cullHandler.cxx +++ b/panda/src/pgraph/cullHandler.cxx @@ -1,16 +1,15 @@ -// Filename: cullHandler.cxx -// Created by: drose (23Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullHandler.cxx + * @author drose + * @date 2002-02-23 + */ #include "cullHandler.h" #include "cullableObject.h" @@ -19,35 +18,27 @@ #include "renderState.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: CullHandler::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullHandler:: CullHandler() { } -//////////////////////////////////////////////////////////////////// -// Function: CullHandler::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullHandler:: ~CullHandler() { } -//////////////////////////////////////////////////////////////////// -// Function: CullHandler::record_object -// Access: Public, Virtual -// Description: This callback function is intended to be overridden -// by a derived class. This is called as each Geom is -// discovered by the CullTraverser. -// -// The CullHandler becomes the owner of the -// CullableObject pointer and is expected to delete it -// later. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is intended to be overridden by a derived class. + * This is called as each Geom is discovered by the CullTraverser. + * + * The CullHandler becomes the owner of the CullableObject pointer and is + * expected to delete it later. + */ void CullHandler:: record_object(CullableObject *object, const CullTraverser *traverser) { nout << *object->_geom << " " << *object->_internal_transform << " " @@ -55,13 +46,10 @@ record_object(CullableObject *object, const CullTraverser *traverser) { delete object; } -//////////////////////////////////////////////////////////////////// -// Function: CullHandler::end_traverse -// Access: Public, Virtual -// Description: This callback function is intended to be overridden -// by a derived class. This is called at the end of the -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * This callback function is intended to be overridden by a derived class. + * This is called at the end of the traversal. + */ void CullHandler:: end_traverse() { } diff --git a/panda/src/pgraph/cullHandler.h b/panda/src/pgraph/cullHandler.h index d9b44d6eb0..9d42d6bad8 100644 --- a/panda/src/pgraph/cullHandler.h +++ b/panda/src/pgraph/cullHandler.h @@ -1,16 +1,15 @@ -// Filename: cullHandler.h -// Created by: drose (23Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullHandler.h + * @author drose + * @date 2002-02-23 + */ #ifndef CULLHANDLER_H #define CULLHANDLER_H @@ -21,19 +20,17 @@ class CullTraverser; -//////////////////////////////////////////////////////////////////// -// Class : CullHandler -// Description : This defines the abstract interface for an object -// that receives Geoms identified by the CullTraverser. -// By itself, it's not a particularly useful class; to -// use it, derive from it and redefine record_object(). -//////////////////////////////////////////////////////////////////// +/** + * This defines the abstract interface for an object that receives Geoms + * identified by the CullTraverser. By itself, it's not a particularly useful + * class; to use it, derive from it and redefine record_object(). + */ class EXPCL_PANDA_PGRAPH CullHandler { public: CullHandler(); virtual ~CullHandler(); - virtual void record_object(CullableObject *object, + virtual void record_object(CullableObject *object, const CullTraverser *traverser); virtual void end_traverse(); @@ -45,6 +42,3 @@ public: #include "cullHandler.I" #endif - - - diff --git a/panda/src/pgraph/cullPlanes.I b/panda/src/pgraph/cullPlanes.I index 8d0e45331e..a96b022824 100644 --- a/panda/src/pgraph/cullPlanes.I +++ b/panda/src/pgraph/cullPlanes.I @@ -1,32 +1,26 @@ -// Filename: cullPlanes.I -// Created by: drose (23Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullPlanes.I + * @author drose + * @date 2005-08-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullPlanes:: CullPlanes() { } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullPlanes:: CullPlanes(const CullPlanes ©) : _planes(copy._planes), @@ -34,32 +28,25 @@ CullPlanes(const CullPlanes ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::Copy Assignment Operator -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CullPlanes:: operator = (const CullPlanes ©) { _planes = copy._planes; _occluders = copy._occluders; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullPlanes:: ~CullPlanes() { } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::is_empty -// Access: Public -// Description: Returns true if there are no planes listed in the -// CullPlanes object. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no planes listed in the CullPlanes object. + */ INLINE bool CullPlanes:: is_empty() const { return _planes.empty() && _occluders.empty(); diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index d923974baf..782637c973 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -1,16 +1,15 @@ -// Filename: cullPlanes.cxx -// Created by: drose (23Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullPlanes.cxx + * @author drose + * @date 2005-08-23 + */ #include "cullPlanes.h" #include "cullTraverser.h" @@ -19,31 +18,26 @@ #include "occluderEffect.h" #include "boundingBox.h" -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::make_empty -// Access: Public, Static -// Description: Returns a pointer to an empty CullPlanes object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to an empty CullPlanes object. + */ CPT(CullPlanes) CullPlanes:: make_empty() { static CPT(CullPlanes) empty; if (empty == NULL) { empty = new CullPlanes; // Artificially tick the reference count, just to ensure we won't - // accidentally modify this object in any of the copy-on-write - // operations below. + // accidentally modify this object in any of the copy-on-write operations + // below. empty->ref(); } return empty; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::xform -// Access: Public -// Description: Returns a pointer to a new CullPlanes object that is -// the same as this one, but with the clip planes -// modified by the indicated transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a new CullPlanes object that is the same as this one, + * but with the clip planes modified by the indicated transform. + */ CPT(CullPlanes) CullPlanes:: xform(const LMatrix4 &mat) const { PT(CullPlanes) new_planes; @@ -74,18 +68,14 @@ xform(const LMatrix4 &mat) const { return new_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::apply_state -// Access: Public -// Description: Returns a pointer to a new CullPlanes object that is -// the same as this one, but with the indicated -// attributes applied to the state. -// -// In particular, any new ClipPlanes given in -// net_attrib, if it is not NULL, will be added to the -// state, unless those ClipPlanes are also listed in -// off_attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a new CullPlanes object that is the same as this one, + * but with the indicated attributes applied to the state. + * + * In particular, any new ClipPlanes given in net_attrib, if it is not NULL, + * will be added to the state, unless those ClipPlanes are also listed in + * off_attrib. + */ CPT(CullPlanes) CullPlanes:: apply_state(const CullTraverser *trav, const CullTraverserData *data, const ClipPlaneAttrib *net_attrib, @@ -111,8 +101,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, Planes::const_iterator pi = new_planes->_planes.find(clip_plane); if (pi == new_planes->_planes.end()) { if (!off_attrib->has_off_plane(clip_plane)) { - // Here's a new clip plane; add it to the list. For this we - // need the net transform to this node. + // Here's a new clip plane; add it to the list. For this we need + // the net transform to this node. if (net_transform == (TransformState *)NULL) { net_transform = data->get_net_transform(trav); } @@ -130,8 +120,7 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, if (node_effect != (OccluderEffect *)NULL) { CPT(TransformState) center_transform = NULL; - // We'll need to know the occluder's frustum in cull-center - // space. + // We'll need to know the occluder's frustum in cull-center space. SceneSetup *scene = trav->get_scene(); const Lens *lens = scene->get_lens(); @@ -146,8 +135,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, CPT(TransformState) occluder_transform = occluder.get_transform(scene->get_cull_center()); - // And the transform from cull-center space into the current - // node's coordinate space. + // And the transform from cull-center space into the current node's + // coordinate space. if (center_transform == (TransformState *)NULL) { if (net_transform == (TransformState *)NULL) { net_transform = data->get_net_transform(trav); @@ -156,16 +145,15 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, center_transform = net_transform->invert_compose(scene->get_cull_center().get_net_transform()); } - // Compare the occluder node's bounding volume to the view - // frustum. We construct a new bounding volume because (a) - // the node's existing bounding volume is in the coordinate - // space of its parent, which isn't what we have here, and (b) - // we might as well make a BoundingBox, which is as tight as - // possible, and creating one isn't any less efficient than - // transforming the existing bounding volume. + // Compare the occluder node's bounding volume to the view frustum. + // We construct a new bounding volume because (a) the node's existing + // bounding volume is in the coordinate space of its parent, which + // isn't what we have here, and (b) we might as well make a + // BoundingBox, which is as tight as possible, and creating one isn't + // any less efficient than transforming the existing bounding volume. PT(BoundingBox) occluder_gbv; - // Get a transform from the occluder directly to this node's - // space for comparing with the current view frustum. + // Get a transform from the occluder directly to this node's space for + // comparing with the current view frustum. CPT(TransformState) composed_transform = center_transform->compose(occluder_transform); const LMatrix4 &composed_mat = composed_transform->get_mat(); LPoint3 ccp[4]; @@ -252,8 +240,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } } - // Also check if the new occluder is completely within any of - // our existing occluder volumes. + // Also check if the new occluder is completely within any of our + // existing occluder volumes. bool is_enclosed = false; Occluders::const_iterator oi; for (oi = _occluders.begin(); oi != _occluders.end(); ++oi) { @@ -264,16 +252,15 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, } } if (is_enclosed) { - // No reason to add this occluder; it's behind an existing - // occluder. + // No reason to add this occluder; it's behind an existing occluder. if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "Ignoring occluder " << occluder << ": behind another.\n"; } continue; } - // TODO: perhaps we should also check whether any existing - // occluders are fully contained within this new one. + // TODO: perhaps we should also check whether any existing occluders + // are fully contained within this new one. // Get the occluder coordinates in global space. const LMatrix4 &occluder_mat = occluder.get_net_transform()->get_mat(); @@ -282,8 +269,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, points_near[2] = occluder_node->get_vertex(2) * occluder_mat; points_near[3] = occluder_node->get_vertex(3) * occluder_mat; - // For the far points, project PAST the far clip of the lens - // to ensures we get stuff that might be intersecting the far clip. + // For the far points, project PAST the far clip of the lens to + // ensures we get stuff that might be intersecting the far clip. LPoint3 center = scene->get_cull_center().get_net_transform()->get_pos(); PN_stdfloat far_clip = scene->get_lens()->get_far() * 2.0; LPoint3 points_far[4]; @@ -292,8 +279,8 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, points_far[2] = normalize(points_near[2] - center) * far_clip + points_near[2]; points_far[3] = normalize(points_near[3] - center) * far_clip + points_near[3]; - // With these points, construct the bounding frustum of the - // occluded region. + // With these points, construct the bounding frustum of the occluded + // region. PT(BoundingHexahedron) frustum = new BoundingHexahedron(points_far[1], points_far[2], points_far[3], points_far[0], points_near[1], points_near[2], points_near[3], points_near[0]); @@ -312,20 +299,16 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, return new_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::do_cull -// Access: Public -// Description: Tests the indicated bounding volume against all of -// the clip planes in this object. Sets result to an -// appropriate union of -// BoundingVolume::IntersectionFlags, similar to the -// result of BoundingVolume::contains(). -// -// Also, if the bounding volume is completely in front -// of any of the clip planes, removes those planes both -// from this object and from the indicated state, -// returning a new CullPlanes object in that case. -//////////////////////////////////////////////////////////////////// +/** + * Tests the indicated bounding volume against all of the clip planes in this + * object. Sets result to an appropriate union of + * BoundingVolume::IntersectionFlags, similar to the result of + * BoundingVolume::contains(). + * + * Also, if the bounding volume is completely in front of any of the clip + * planes, removes those planes both from this object and from the indicated + * state, returning a new CullPlanes object in that case. + */ CPT(CullPlanes) CullPlanes:: do_cull(int &result, CPT(RenderState) &state, const GeometricBoundingVolume *node_gbv) const { @@ -337,9 +320,9 @@ do_cull(int &result, CPT(RenderState) &state, CPT(CullPlanes) new_planes = this; if (orig_cpa == (ClipPlaneAttrib *)NULL) { - // If there are no clip planes in the state, the node is completely - // in front of all zero of the clip planes. (This can happen if - // someone directly changes the state during the traversal.) + // If there are no clip planes in the state, the node is completely in + // front of all zero of the clip planes. (This can happen if someone + // directly changes the state during the traversal.) CullPlanes *planes = new CullPlanes; planes->_occluders = _occluders; new_planes = planes; @@ -351,15 +334,14 @@ do_cull(int &result, CPT(RenderState) &state, for (pi = _planes.begin(); pi != _planes.end(); ++pi) { int plane_result = (*pi).second->contains(node_gbv); if (plane_result == BoundingVolume::IF_no_intersection) { - // The node is completely behind this clip plane and gets - // culled. Short-circuit the rest of the logic; none of the - // other planes matter. + // The node is completely behind this clip plane and gets culled. + // Short-circuit the rest of the logic; none of the other planes + // matter. result = plane_result; return new_planes; } else if ((plane_result & BoundingVolume::IF_all) != 0) { - // The node is completely in front of this clip plane. We don't - // need to consider this plane ever again for any descendents of - // this node. + // The node is completely in front of this clip plane. We don't need + // to consider this plane ever again for any descendents of this node. new_planes = new_planes->remove_plane((*pi).first); nassertr(new_planes != this, new_planes); new_cpa = DCAST(ClipPlaneAttrib, new_cpa->remove_on_plane((*pi).first)); @@ -381,21 +363,19 @@ do_cull(int &result, CPT(RenderState) &state, for (oi = _occluders.begin(); oi != _occluders.end(); ++oi) { int occluder_result = (*oi).second->contains(node_gbv); if (occluder_result == BoundingVolume::IF_no_intersection) { - // The node is completely in front of this occluder. We don't - // need to consider this occluder ever again for any descendents of - // this node. + // The node is completely in front of this occluder. We don't need to + // consider this occluder ever again for any descendents of this node. - // Reverse the sense of the test, because an occluder volume is - // the inverse of a cull plane volume: it describes the volume - // that is to be culled, not the volume that is to be kept. + // Reverse the sense of the test, because an occluder volume is the + // inverse of a cull plane volume: it describes the volume that is to be + // culled, not the volume that is to be kept. occluder_result = BoundingVolume::IF_all | BoundingVolume::IF_possible | BoundingVolume::IF_some; new_planes = new_planes->remove_occluder((*oi).first); nassertr(new_planes != this, new_planes); } else if ((occluder_result & BoundingVolume::IF_all) != 0) { - // The node is completely behind this occluder and gets culled. - // Short-circuit the rest of the logic; none of the other - // occluders matter. + // The node is completely behind this occluder and gets culled. Short- + // circuit the rest of the logic; none of the other occluders matter. result = BoundingVolume::IF_no_intersection; return new_planes; } @@ -406,13 +386,10 @@ do_cull(int &result, CPT(RenderState) &state, return new_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::remove_plane -// Access: Public -// Description: Returns a pointer to a new CullPlanes object that is -// the same as this one, but with the indicated -// clip plane removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a new CullPlanes object that is the same as this one, + * but with the indicated clip plane removed. + */ CPT(CullPlanes) CullPlanes:: remove_plane(const NodePath &clip_plane) const { PT(CullPlanes) new_planes; @@ -429,13 +406,10 @@ remove_plane(const NodePath &clip_plane) const { return new_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::remove_occluder -// Access: Public -// Description: Returns a pointer to a new CullPlanes object that is -// the same as this one, but with the indicated -// occluder removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to a new CullPlanes object that is the same as this one, + * but with the indicated occluder removed. + */ CPT(CullPlanes) CullPlanes:: remove_occluder(const NodePath &occluder) const { PT(CullPlanes) new_planes; @@ -452,11 +426,9 @@ remove_occluder(const NodePath &occluder) const { return new_planes; } -//////////////////////////////////////////////////////////////////// -// Function: CullPlanes::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CullPlanes:: write(ostream &out) const { out << "CullPlanes (" << _planes.size() << " planes and " diff --git a/panda/src/pgraph/cullPlanes.h b/panda/src/pgraph/cullPlanes.h index 0a41984ec9..483eb2d30a 100644 --- a/panda/src/pgraph/cullPlanes.h +++ b/panda/src/pgraph/cullPlanes.h @@ -1,16 +1,15 @@ -// Filename: cullPlanes.h -// Created by: drose (23Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullPlanes.h + * @author drose + * @date 2005-08-23 + */ #ifndef CULLPLANES_H #define CULLPLANES_H @@ -27,27 +26,24 @@ class ClipPlaneAttrib; class OccluderEffect; -//////////////////////////////////////////////////////////////////// -// Class : CullPlanes -// Description : This represents the set of clip planes and/or -// occluders that are definitely in effect for the -// current node of the CullTraverserData, as well as on -// all child nodes. Any clip planes and occluders in -// this list may be safely culled against. -// -// This does not include the clip planes that are in -// effect now, but might later be turned off by a child -// node, since we can't safely cull against such clip -// planes. -// -// The bounding volumes in this object are transformed -// for each level of the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * This represents the set of clip planes and/or occluders that are definitely + * in effect for the current node of the CullTraverserData, as well as on all + * child nodes. Any clip planes and occluders in this list may be safely + * culled against. + * + * This does not include the clip planes that are in effect now, but might + * later be turned off by a child node, since we can't safely cull against + * such clip planes. + * + * The bounding volumes in this object are transformed for each level of the + * scene graph. + */ class EXPCL_PANDA_PGRAPH CullPlanes : public ReferenceCount { protected: INLINE CullPlanes(); INLINE CullPlanes(const CullPlanes ©); - INLINE void operator = (const CullPlanes ©); + INLINE void operator = (const CullPlanes ©); public: INLINE ~CullPlanes(); @@ -57,7 +53,7 @@ public: static CPT(CullPlanes) make_empty(); CPT(CullPlanes) xform(const LMatrix4 &mat) const; - CPT(CullPlanes) apply_state(const CullTraverser *trav, + CPT(CullPlanes) apply_state(const CullTraverser *trav, const CullTraverserData *data, const ClipPlaneAttrib *net_attrib, const ClipPlaneAttrib *off_attrib, diff --git a/panda/src/pgraph/cullResult.I b/panda/src/pgraph/cullResult.I index 36a54b786e..92b60a88b4 100644 --- a/panda/src/pgraph/cullResult.I +++ b/panda/src/pgraph/cullResult.I @@ -1,52 +1,41 @@ -// Filename: cullResult.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullResult.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullResult::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullResult:: ~CullResult() { } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_bin -// Access: Public -// Description: Returns the CullBin associated with the indicated -// bin_index, or NULL if the bin_index is invalid. If -// there is the first time this bin_index has been -// requested for this CullResult, creates a new CullBin -// object on the fly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CullBin associated with the indicated bin_index, or NULL if the + * bin_index is invalid. If there is the first time this bin_index has been + * requested for this CullResult, creates a new CullBin object on the fly. + */ INLINE CullBin *CullResult:: get_bin(int bin_index) { - if (bin_index >= 0 && bin_index < (int)_bins.size() && + if (bin_index >= 0 && bin_index < (int)_bins.size() && _bins[bin_index] != (CullBin *)NULL) { return _bins[bin_index]; } return make_new_bin(bin_index); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::check_flash_bin -// Access: Private -// Description: If the user configured flash-bin-binname, then update -// the object's state to flash all the geometry in the -// bin. -//////////////////////////////////////////////////////////////////// +/** + * If the user configured flash-bin-binname, then update the object's state to + * flash all the geometry in the bin. + */ INLINE void CullResult:: check_flash_bin(CPT(RenderState) &state, CullBinManager *bin_manager, int bin_index) { #ifndef NDEBUG @@ -56,13 +45,10 @@ check_flash_bin(CPT(RenderState) &state, CullBinManager *bin_manager, int bin_in #endif } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::check_flash_transparency -// Access: Private -// Description: If the user configured show-transparency, then -// update the object's state to flash the current -// geometry with the specified color. -//////////////////////////////////////////////////////////////////// +/** + * If the user configured show-transparency, then update the object's state to + * flash the current geometry with the specified color. + */ INLINE void CullResult:: check_flash_transparency(CPT(RenderState) &state, const LColor &color) { #ifndef NDEBUG diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index b346218868..3cc5380ab2 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -1,16 +1,15 @@ -// Filename: cullResult.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullResult.cxx + * @author drose + * @date 2002-02-28 + */ #include "cullResult.h" #include "cullBinManager.h" @@ -32,36 +31,29 @@ TypeHandle CullResult::_type_handle; -// This value is used instead of 1.0 to represent the alpha level of a -// pixel that is to be considered "opaque" for the purposes of M_dual. -// -// Ideally, 1.0 is the only correct value for this. Realistically, we -// have to fudge it lower for two reasons: -// -// (1) The modelers tend to paint textures with very slight -// transparency levels in places that are not intended to be -// transparent, without realizing it. These very faint transparency -// regions are normally (almost) invisible, but when rendered with -// M_dual they may be revealed as regions of poor alpha sorting. -// -// (2) There seems to be some problem in DX where, in certain -// circumstances apparently related to automatic texture management, -// it spontaneously drops out the bottom two bits of an eight-bit -// alpha channel, causing a value of 255 to become a value of 252 -// instead. -// -// We use 256 as the denominator here (instead of, say, 255) because a -// fractional power of two will have a terminating representation in -// base 2, and thus will be more likely to have a precise value in -// whatever internal representation the graphics API will use. +/* + * This value is used instead of 1.0 to represent the alpha level of a pixel + * that is to be considered "opaque" for the purposes of M_dual. Ideally, 1.0 + * is the only correct value for this. Realistically, we have to fudge it + * lower for two reasons: (1) The modelers tend to paint textures with very + * slight transparency levels in places that are not intended to be + * transparent, without realizing it. These very faint transparency regions + * are normally (almost) invisible, but when rendered with M_dual they may be + * revealed as regions of poor alpha sorting. (2) There seems to be some + * problem in DX where, in certain circumstances apparently related to + * automatic texture management, it spontaneously drops out the bottom two + * bits of an eight-bit alpha channel, causing a value of 255 to become a + * value of 252 instead. We use 256 as the denominator here (instead of, say, + * 255) because a fractional power of two will have a terminating + * representation in base 2, and thus will be more likely to have a precise + * value in whatever internal representation the graphics API will use. + */ static const PN_stdfloat dual_opaque_level = 252.0 / 256.0; static const double bin_color_flash_rate = 1.0; // 1 state change per second -//////////////////////////////////////////////////////////////////// -// Function: CullResult::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullResult:: CullResult(GraphicsStateGuardianBase *gsg, const PStatCollector &draw_region_pcollector) : @@ -77,14 +69,11 @@ CullResult(GraphicsStateGuardianBase *gsg, #endif } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::make_next -// Access: Published -// Description: Returns a newly-allocated CullResult object that -// contains a copy of just the subset of the data from -// this CullResult object that is worth keeping around -// for next frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated CullResult object that contains a copy of just + * the subset of the data from this CullResult object that is worth keeping + * around for next frame. + */ PT(CullResult) CullResult:: make_next() const { PT(CullResult) new_result = new CullResult(_gsg, _draw_region_pcollector); @@ -105,13 +94,10 @@ make_next() const { return new_result; } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::add_object -// Access: Published -// Description: Adds the indicated CullableObject to the appropriate -// bin. The bin becomes the owner of the object -// pointer, and will eventually delete it. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated CullableObject to the appropriate bin. The bin becomes + * the owner of the object pointer, and will eventually delete it. + */ void CullResult:: add_object(CullableObject *object, const CullTraverser *traverser) { static const LColor flash_alpha_color(0.92, 0.96, 0.10, 1.0f); @@ -145,8 +131,8 @@ add_object(CullableObject *object, const CullTraverser *traverser) { if (object->_state->get_attrib(trans)) { switch (trans->get_mode()) { case TransparencyAttrib::M_alpha: - // M_alpha implies an alpha-write test, so we don't waste time - // writing 0-valued pixels. + // M_alpha implies an alpha-write test, so we don't waste time writing + // 0-valued pixels. object->_state = object->_state->compose(get_alpha_state()); check_flash_transparency(object->_state, flash_alpha_color); break; @@ -159,8 +145,8 @@ add_object(CullableObject *object, const CullTraverser *traverser) { case TransparencyAttrib::M_multisample: case TransparencyAttrib::M_multisample_mask: - // The multisample modes are implemented using M_binary if the - // GSG in use doesn't support multisample. + // The multisample modes are implemented using M_binary if the GSG in + // use doesn't support multisample. if (!_gsg->get_supports_multisample()) { object->_state = object->_state->compose(get_binary_state()); } @@ -176,18 +162,17 @@ add_object(CullableObject *object, const CullTraverser *traverser) { break; } - // M_dual is implemented by drawing the opaque parts first, - // without transparency, then drawing the transparent parts - // later. This means we must copy the object and add it to - // both bins. We can only do this if we do not have an - // explicit bin already applied; otherwise, M_dual falls back - // to M_alpha. + // M_dual is implemented by drawing the opaque parts first, without + // transparency, then drawing the transparent parts later. This means + // we must copy the object and add it to both bins. We can only do this + // if we do not have an explicit bin already applied; otherwise, M_dual + // falls back to M_alpha. { const CullBinAttrib *bin_attrib; if (!object->_state->get_attrib(bin_attrib) || bin_attrib->get_bin_name().empty()) { - // We make a copy of the object to draw the transparent part; - // this gets placed in the transparent bin. + // We make a copy of the object to draw the transparent part; this + // gets placed in the transparent bin. #ifndef NDEBUG if (m_dual_transparent) #endif @@ -208,8 +193,8 @@ add_object(CullableObject *object, const CullTraverser *traverser) { } } - // Now we can draw the opaque part. This will end up in - // the opaque bin. + // Now we can draw the opaque part. This will end up in the opaque + // bin. object->_state = object->_state->compose(get_dual_opaque_state()); #ifndef NDEBUG if (!m_dual_opaque) { @@ -218,8 +203,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { } #endif } - // The object is assigned to a specific bin; M_dual becomes - // M_alpha. + // The object is assigned to a specific bin; M_dual becomes M_alpha. } break; @@ -257,36 +241,31 @@ add_object(CullableObject *object, const CullTraverser *traverser) { nassertv(bin != (CullBin *)NULL); check_flash_bin(object->_state, bin_manager, bin_index); - // Munge vertices as needed for the GSG's requirements, and the - // object's current state. + // Munge vertices as needed for the GSG's requirements, and the object's + // current state. if (object->munge_geom(_gsg, _gsg->get_geom_munger(object->_state, current_thread), traverser, force)) { - // The object may or may not now be fully resident, but this may - // not matter, since the GSG may have the necessary buffers - // already loaded. We'll let the GSG ultimately decide whether to - // render it. + // The object may or may not now be fully resident, but this may not + // matter, since the GSG may have the necessary buffers already loaded. + // We'll let the GSG ultimately decide whether to render it. bin->add_object(object, current_thread); } else { delete object; } } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::finish_cull -// Access: Published -// Description: Called after all the geoms have been added, this -// indicates that the cull process is finished for this -// frame and gives the bins a chance to do any -// post-processing (like sorting) before moving on to -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the geoms have been added, this indicates that the cull + * process is finished for this frame and gives the bins a chance to do any + * post-processing (like sorting) before moving on to draw. + */ void CullResult:: finish_cull(SceneSetup *scene_setup, Thread *current_thread) { CullBinManager *bin_manager = CullBinManager::get_global_ptr(); for (size_t i = 0; i < _bins.size(); ++i) { if (!bin_manager->get_bin_active(i)) { - // If the bin isn't active, don't sort it, and don't draw it. - // In fact, clear it. + // If the bin isn't active, don't sort it, and don't draw it. In fact, + // clear it. _bins[i] = NULL; } else { @@ -298,12 +277,9 @@ finish_cull(SceneSetup *scene_setup, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::draw -// Access: Published -// Description: Asks all the bins to draw themselves in the correct -// order. -//////////////////////////////////////////////////////////////////// +/** + * Asks all the bins to draw themselves in the correct order. + */ void CullResult:: draw(Thread *current_thread) { bool force = !_gsg->get_effective_incomplete_render(); @@ -321,22 +297,16 @@ draw(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::make_result_graph -// Access: Published -// Description: Returns a special scene graph constructed to -// represent the results of the cull. This will be a -// hierarchy of nodes, one node for each bin, each of -// which will in term be a parent of a number of -// GeomNodes, representing the geometry drawn in each -// bin. -// -// This is useful mainly for high-level debugging and -// abstraction tools; it should not be mistaken for the -// low-level cull result itself. For the low-level cull -// result, use draw() to efficiently draw the culled -// scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special scene graph constructed to represent the results of the + * cull. This will be a hierarchy of nodes, one node for each bin, each of + * which will in term be a parent of a number of GeomNodes, representing the + * geometry drawn in each bin. + * + * This is useful mainly for high-level debugging and abstraction tools; it + * should not be mistaken for the low-level cull result itself. For the low- + * level cull result, use draw() to efficiently draw the culled scene. + */ PT(PandaNode) CullResult:: make_result_graph() { PT(PandaNode) root_node = new PandaNode("cull_result"); @@ -356,26 +326,21 @@ make_result_graph() { return root_node; } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::bin_removed -// Access: Public, Static -// Description: Intended to be called by -// CullBinManager::remove_bin(), this informs all the -// CullResults in the world to remove the indicated -// bin_index from their cache if it has been cached. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by CullBinManager::remove_bin(), this informs all the + * CullResults in the world to remove the indicated bin_index from their cache + * if it has been cached. + */ void CullResult:: bin_removed(int bin_index) { // Do something here. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::make_new_bin -// Access: Private -// Description: Allocates a new CullBin for the given bin_index and -// stores it for next time. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a new CullBin for the given bin_index and stores it for next + * time. + */ CullBin *CullResult:: make_new_bin(int bin_index) { CullBinManager *bin_manager = CullBinManager::get_global_ptr(); @@ -390,19 +355,16 @@ make_new_bin(int bin_index) { } nassertr(bin_index >= 0 && bin_index < (int)_bins.size(), NULL); - // Prevent unnecessary ref/unref by swapping the PointerTos. + // Prevent unnecessary refunref by swapping the PointerTos. swap(_bins[bin_index], bin); } return bin_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_rescale_normal_state -// Access: Private -// Description: Returns a RenderState containing the given rescale -// normal attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState containing the given rescale normal attribute. + */ const RenderState *CullResult:: get_rescale_normal_state(RescaleNormalAttrib::Mode mode) { static CPT(RenderState) states[RescaleNormalAttrib::M_auto + 1]; @@ -413,29 +375,24 @@ get_rescale_normal_state(RescaleNormalAttrib::Mode mode) { return states[mode].p(); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_alpha_state -// Access: Private -// Description: Returns a RenderState that changes the alpha test to -// > 0, for implementing M_alpha. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that changes the alpha test to > 0, for implementing + * M_alpha. + */ const RenderState *CullResult:: get_alpha_state() { static CPT(RenderState) state = NULL; if (state == (const RenderState *)NULL) { - // We don't monkey with the priority, since we want to allow the - // user to override this if he desires. + // We don't monkey with the priority, since we want to allow the user to + // override this if he desires. state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f)); } return state.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_binary_state -// Access: Private -// Description: Returns a RenderState that applies the effects of -// M_binary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that applies the effects of M_binary. + */ const RenderState *CullResult:: get_binary_state() { static CPT(RenderState) state = NULL; @@ -448,12 +405,9 @@ get_binary_state() { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: CullResult::apply_flash_color -// Access: Private -// Description: Update the object's state to flash the geometry -// with a solid color. -//////////////////////////////////////////////////////////////////// +/** + * Update the object's state to flash the geometry with a solid color. + */ void CullResult:: apply_flash_color(CPT(RenderState) &state, const LColor &flash_color) { int cycle = (int)(ClockObject::get_global_clock()->get_frame_time() * bin_color_flash_rate); @@ -468,21 +422,19 @@ apply_flash_color(CPT(RenderState) &state, const LColor &flash_color) { } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_dual_transparent_state -// Access: Private -// Description: Returns a RenderState that renders only the -// transparent parts of an object, in support of M_dual. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that renders only the transparent parts of an object, + * in support of M_dual. + */ const RenderState *CullResult:: get_dual_transparent_state() { static CPT(RenderState) state = NULL; if (state == (const RenderState *)NULL) { - // The alpha test for > 0 prevents us from drawing empty pixels, - // and hence filling up the depth buffer with large empty spaces - // that may obscure other things. However, this does mean we draw - // pixels twice where the alpha == 1.0 (since they were already - // drawn in the opaque pass). This is not normally a problem. + // The alpha test for > 0 prevents us from drawing empty pixels, and hence + // filling up the depth buffer with large empty spaces that may obscure + // other things. However, this does mean we draw pixels twice where the + // alpha == 1.0 (since they were already drawn in the opaque pass). This + // is not normally a problem. state = RenderState::make(AlphaTestAttrib::make(AlphaTestAttrib::M_greater, 0.0f), TransparencyAttrib::make(TransparencyAttrib::M_alpha), DepthWriteAttrib::make(DepthWriteAttrib::M_off), @@ -512,12 +464,10 @@ get_dual_transparent_state() { return state.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_dual_opaque_state -// Access: Private -// Description: Returns a RenderState that renders only the -// opaque parts of an object, in support of M_dual. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that renders only the opaque parts of an object, in + * support of M_dual. + */ const RenderState *CullResult:: get_dual_opaque_state() { static CPT(RenderState) state = NULL; @@ -547,12 +497,10 @@ get_dual_opaque_state() { return state.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_wireframe_filled_state -// Access: Private -// Description: Returns a RenderState that is composed with the -// filled part of an M_filled_wireframe model. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that is composed with the filled part of an + * M_filled_wireframe model. + */ const RenderState *CullResult:: get_wireframe_filled_state() { static CPT(RenderState) state = RenderState::make( @@ -561,12 +509,10 @@ get_wireframe_filled_state() { return state.p(); } -//////////////////////////////////////////////////////////////////// -// Function: CullResult::get_wireframe_overlay_state -// Access: Private -// Description: Returns a RenderState that renders only the -// wireframe part of an M_filled_wireframe model. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState that renders only the wireframe part of an + * M_filled_wireframe model. + */ CPT(RenderState) CullResult:: get_wireframe_overlay_state(const RenderModeAttrib *rmode) { return RenderState::make( @@ -579,4 +525,3 @@ get_wireframe_overlay_state(const RenderModeAttrib *rmode) { rmode->get_thickness(), rmode->get_perspective())); } - diff --git a/panda/src/pgraph/cullResult.h b/panda/src/pgraph/cullResult.h index 585b27e606..1e500e994d 100644 --- a/panda/src/pgraph/cullResult.h +++ b/panda/src/pgraph/cullResult.h @@ -1,16 +1,15 @@ -// Filename: cullResult.h -// Created by: drose (27Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullResult.h + * @author drose + * @date 2002-02-27 + */ #ifndef CULLRESULT_H #define CULLRESULT_H @@ -34,17 +33,14 @@ class RenderState; class SceneSetup; class TransformState; -//////////////////////////////////////////////////////////////////// -// Class : CullResult -// Description : This stores the result of a BinCullHandler traversal: -// an ordered collection of CullBins, each of which -// holds a number of Geoms and RenderStates to be -// rendered in some defined order. -// -// This is also used to keep the results of last frame's -// cull traversal around to make next frame's traversal -// of the same scene a little easier. -//////////////////////////////////////////////////////////////////// +/** + * This stores the result of a BinCullHandler traversal: an ordered collection + * of CullBins, each of which holds a number of Geoms and RenderStates to be + * rendered in some defined order. + * + * This is also used to keep the results of last frame's cull traversal around + * to make next frame's traversal of the same scene a little easier. + */ class EXPCL_PANDA_PGRAPH CullResult : public ReferenceCount { public: CullResult(GraphicsStateGuardianBase *gsg, @@ -110,4 +106,3 @@ private: #include "cullResult.I" #endif - diff --git a/panda/src/pgraph/cullTraverser.I b/panda/src/pgraph/cullTraverser.I index 76df04145a..180b94b37a 100644 --- a/panda/src/pgraph/cullTraverser.I +++ b/panda/src/pgraph/cullTraverser.I @@ -1,243 +1,189 @@ -// Filename: cullTraverser.I -// Created by: drose (23Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverser.I + * @author drose + * @date 2002-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_gsg -// Access: Published -// Description: Returns the GraphicsStateGuardian in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GraphicsStateGuardian in effect. + */ INLINE GraphicsStateGuardianBase *CullTraverser:: get_gsg() const { return _gsg; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_current_thread -// Access: Published -// Description: Returns the currently-executing thread object, as -// passed to the CullTraverser constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the currently-executing thread object, as passed to the + * CullTraverser constructor. + */ INLINE Thread *CullTraverser:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_scene -// Access: Published -// Description: Returns the SceneSetup object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SceneSetup object. + */ INLINE SceneSetup *CullTraverser:: get_scene() const { return _scene_setup; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::has_tag_state_key -// Access: Published -// Description: Returns true if a nonempty tag state key has been -// specified for the scene's camera, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a nonempty tag state key has been specified for the scene's + * camera, false otherwise. + */ INLINE bool CullTraverser:: has_tag_state_key() const { return _has_tag_state_key; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_tag_state_key -// Access: Published -// Description: Returns the tag state key that has been specified for -// the scene's camera, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tag state key that has been specified for the scene's camera, + * if any. + */ INLINE const string &CullTraverser:: get_tag_state_key() const { return _tag_state_key; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_camera_transform -// Access: Published -// Description: Returns the position of the camera relative to the -// starting node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the camera relative to the starting node. + */ INLINE const TransformState *CullTraverser:: get_camera_transform() const { return _scene_setup->get_camera_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_world_transform -// Access: Published -// Description: Returns the position of the starting node relative -// to the camera. This is the inverse of the camera -// transform. -// -// Note that this value is always the position of the -// starting node, not the current node, even if it is -// sampled during a traversal. To get the transform of -// the current node use -// CullTraverserData::get_modelview_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the starting node relative to the camera. This is + * the inverse of the camera transform. + * + * Note that this value is always the position of the starting node, not the + * current node, even if it is sampled during a traversal. To get the + * transform of the current node use + * CullTraverserData::get_modelview_transform(). + */ INLINE const TransformState *CullTraverser:: get_world_transform() const { return _scene_setup->get_world_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_initial_state -// Access: Published -// Description: Returns the initial RenderState at the top of the -// scene graph we are traversing, or the empty state if -// the initial state was never set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the initial RenderState at the top of the scene graph we are + * traversing, or the empty state if the initial state was never set. + */ INLINE const RenderState *CullTraverser:: get_initial_state() const { return _initial_state; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_depth_offset_decals -// Access: Published -// Description: Returns true, as depth offsets are the only way -// that we implement decals nowadays. -//////////////////////////////////////////////////////////////////// +/** + * Returns true, as depth offsets are the only way that we implement decals + * nowadays. + */ INLINE bool CullTraverser:: get_depth_offset_decals() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::set_camera_mask -// Access: Published -// Description: Changes the visibility mask for the camera viewing -// the scene. This is normally set automatically -// at the time setup_scene() is called; you should -// change this only if you want to render some set of -// objects different from what the camera normally would -// draw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the visibility mask for the camera viewing the scene. This is + * normally set automatically at the time setup_scene() is called; you should + * change this only if you want to render some set of objects different from + * what the camera normally would draw. + */ INLINE void CullTraverser:: set_camera_mask(const DrawMask &camera_mask) { _camera_mask = camera_mask; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_camera_mask -// Access: Published -// Description: Returns the visibility mask from the camera viewing -// the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the visibility mask from the camera viewing the scene. + */ INLINE const DrawMask &CullTraverser:: get_camera_mask() const { return _camera_mask; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::set_view_frustum -// Access: Published -// Description: Specifies the bounding volume that corresponds to the -// view frustum. Any primitives that fall entirely -// outside of this volume are not drawn. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the bounding volume that corresponds to the view frustum. Any + * primitives that fall entirely outside of this volume are not drawn. + */ INLINE void CullTraverser:: set_view_frustum(GeometricBoundingVolume *view_frustum) { _view_frustum = view_frustum; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_view_frustum -// Access: Published -// Description: Returns the bounding volume that corresponds to the -// view frustum, or NULL if the view frustum is not in -// use or has not been set. -// -// Note that the view frustum returned here is always in -// the coordinate space of the starting node, not the -// current node, even if it is sampled during a -// traversal. To get the view frustum in the current -// node's coordinate space, check in the current -// CullTraverserData. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume that corresponds to the view frustum, or NULL + * if the view frustum is not in use or has not been set. + * + * Note that the view frustum returned here is always in the coordinate space + * of the starting node, not the current node, even if it is sampled during a + * traversal. To get the view frustum in the current node's coordinate space, + * check in the current CullTraverserData. + */ INLINE GeometricBoundingVolume *CullTraverser:: get_view_frustum() const { return _view_frustum; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::set_cull_handler -// Access: Published -// Description: Specifies the object that will receive the culled -// Geoms. This must be set before calling traverse(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the object that will receive the culled Geoms. This must be set + * before calling traverse(). + */ INLINE void CullTraverser:: set_cull_handler(CullHandler *cull_handler) { _cull_handler = cull_handler; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_cull_handler -// Access: Published -// Description: Returns the object that will receive the culled -// Geoms. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object that will receive the culled Geoms. + */ INLINE CullHandler *CullTraverser:: get_cull_handler() const { return _cull_handler; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::set_portal_clipper -// Access: Published -// Description: Specifies _portal_clipper object pointer that -// subsequent traverse() or traverse_below may use. -//////////////////////////////////////////////////////////////////// +/** + * Specifies _portal_clipper object pointer that subsequent traverse() or + * traverse_below may use. + */ INLINE void CullTraverser:: set_portal_clipper(PortalClipper *portal_clipper) { _portal_clipper = portal_clipper; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_portal_clipper -// Access: Published -// Description: Returns the _portal_clipper pointer -//////////////////////////////////////////////////////////////////// +/** + * Returns the _portal_clipper pointer + */ INLINE PortalClipper *CullTraverser:: get_portal_clipper() const { return _portal_clipper; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_effective_incomplete_render -// Access: Published -// Description: Returns true if the cull traversal is effectively in -// incomplete_render state, considering both the GSG's -// incomplete_render and the current DisplayRegion's -// incomplete_render flags. This returns the flag -// during the cull traversal; see -// GSG::get_effective_incomplete_render() for this same -// flag during the draw traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cull traversal is effectively in incomplete_render + * state, considering both the GSG's incomplete_render and the current + * DisplayRegion's incomplete_render flags. This returns the flag during the + * cull traversal; see GSG::get_effective_incomplete_render() for this same + * flag during the draw traversal. + */ INLINE bool CullTraverser:: get_effective_incomplete_render() const { return _effective_incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::flush_level -// Access: Published, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CullTraverser:: flush_level() { _nodes_pcollector.flush_level(); @@ -246,11 +192,9 @@ flush_level() { _geoms_occluded_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::do_traverse -// Access: Protected -// Description: This is implemented inline to reduce recursion. -//////////////////////////////////////////////////////////////////// +/** + * This is implemented inline to reduce recursion. + */ INLINE void CullTraverser:: do_traverse(CullTraverserData &data) { if (is_in_view(data)) { @@ -276,8 +220,8 @@ do_traverse(CullTraverserData &data) { // Something in this node is worth taking a closer look. const RenderEffects *node_effects = node_reader->get_effects(); if (node_effects->has_show_bounds()) { - // If we should show the bounding volume for this node, make it - // up now. + // If we should show the bounding volume for this node, make it up + // now. show_bounds(data, node_effects->has_show_tight_bounds()); } @@ -288,9 +232,9 @@ do_traverse(CullTraverserData &data) { if (fog != (const FogAttrib *)NULL && fog->get_fog() != (Fog *)NULL) { // If we just introduced a FogAttrib here, call adjust_to_camera() - // now. This maybe isn't the perfect time to call it, but it's - // good enough; and at this time we have all the information we - // need for it. + // now. This maybe isn't the perfect time to call it, but it's good + // enough; and at this time we have all the information we need for + // it. fog->get_fog()->adjust_to_camera(get_camera_transform()); } diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index 2a92792e03..5d08b4e5dd 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -1,16 +1,15 @@ -// Filename: cullTraverser.cxx -// Created by: drose (23eb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverser.cxx + * @author drose + * @date 2002-02-23 + */ #include "config_pgraph.h" #include "cullTraverser.h" @@ -43,11 +42,9 @@ PStatCollector CullTraverser::_geoms_occluded_pcollector("Geoms:Occluded"); TypeHandle CullTraverser::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullTraverser:: CullTraverser() : _gsg(NULL), @@ -61,11 +58,9 @@ CullTraverser() : _effective_incomplete_render = true; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullTraverser:: CullTraverser(const CullTraverser ©) : _gsg(copy._gsg), @@ -82,13 +77,10 @@ CullTraverser(const CullTraverser ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::set_scene -// Access: Published, Virtual -// Description: Sets the SceneSetup object that indicates the initial -// camera position, etc. This must be called before -// traversal begins. -//////////////////////////////////////////////////////////////////// +/** + * Sets the SceneSetup object that indicates the initial camera position, etc. + * This must be called before traversal begins. + */ void CullTraverser:: set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsg, bool dr_incomplete_render) { @@ -107,20 +99,17 @@ set_scene(SceneSetup *scene_setup, GraphicsStateGuardianBase *gsg, _effective_incomplete_render = _gsg->get_incomplete_render() && dr_incomplete_render; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::traverse -// Access: Published -// Description: Begins the traversal from the indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Begins the traversal from the indicated node. + */ void CullTraverser:: traverse(const NodePath &root) { nassertv(_cull_handler != (CullHandler *)NULL); nassertv(_scene_setup != (SceneSetup *)NULL); if (allow_portal_cull) { - // This _view_frustum is in cull_center space - //Erik: obsolete? - //PT(GeometricBoundingVolume) vf = _view_frustum; + // This _view_frustum is in cull_center space Erik: obsolete? + // PT(GeometricBoundingVolume) vf = _view_frustum; GeometricBoundingVolume *local_frustum = NULL; PT(BoundingVolume) bv = _scene_setup->get_lens()->make_bounds(); @@ -167,25 +156,20 @@ traverse(const NodePath &root) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::traverse -// Access: Published -// Description: Traverses from the next node with the given -// data, which has been constructed with the node but -// has not yet been converted into the node's space. -//////////////////////////////////////////////////////////////////// +/** + * Traverses from the next node with the given data, which has been + * constructed with the node but has not yet been converted into the node's + * space. + */ void CullTraverser:: traverse(CullTraverserData &data) { do_traverse(data); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::traverse_below -// Access: Published, Virtual -// Description: Traverses all the children of the indicated node, -// with the given data, which has been converted into -// the node's space. -//////////////////////////////////////////////////////////////////// +/** + * Traverses all the children of the indicated node, with the given data, + * which has been converted into the node's space. + */ void CullTraverser:: traverse_below(CullTraverserData &data) { _nodes_pcollector.add_level(1); @@ -198,9 +182,8 @@ traverse_below(CullTraverserData &data) { // Check for a decal effect. const RenderEffects *node_effects = node_reader->get_effects(); if (node_effects->has_decal()) { - // If we *are* implementing decals with DepthOffsetAttribs, - // apply it now, so that each child of this node gets offset by - // a tiny amount. + // If we *are* implementing decals with DepthOffsetAttribs, apply it + // now, so that each child of this node gets offset by a tiny amount. data._state = data._state->compose(get_depth_offset_state()); #ifndef NDEBUG // This is just a sanity check message. @@ -232,24 +215,18 @@ traverse_below(CullTraverserData &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::end_traverse -// Access: Published, Virtual -// Description: Should be called when the traverser has finished -// traversing its scene, this gives it a chance to do -// any necessary finalization. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the traverser has finished traversing its scene, this + * gives it a chance to do any necessary finalization. + */ void CullTraverser:: end_traverse() { _cull_handler->end_traverse(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::draw_bounding_volume -// Access: Published -// Description: Draws an appropriate visualization of the indicated -// bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Draws an appropriate visualization of the indicated bounding volume. + */ void CullTraverser:: draw_bounding_volume(const BoundingVolume *vol, const TransformState *internal_transform) const { @@ -269,25 +246,19 @@ draw_bounding_volume(const BoundingVolume *vol, } } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::is_in_view -// Access: Protected, Virtual -// Description: Returns true if the current node is fully or -// partially within the viewing area and should be -// drawn, or false if it (and all of its children) -// should be pruned. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current node is fully or partially within the viewing + * area and should be drawn, or false if it (and all of its children) should + * be pruned. + */ bool CullTraverser:: is_in_view(CullTraverserData &data) { return data.is_in_view(_camera_mask); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::show_bounds -// Access: Private -// Description: Draws an appropriate visualization of the node's -// external bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Draws an appropriate visualization of the node's external bounding volume. + */ void CullTraverser:: show_bounds(CullTraverserData &data, bool tight) { PandaNode *node = data.node(); @@ -320,12 +291,9 @@ show_bounds(CullTraverserData &data, bool tight) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::make_bounds_viz -// Access: Private, Static -// Description: Returns an appropriate visualization of the indicated -// bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns an appropriate visualization of the indicated bounding volume. + */ PT(Geom) CullTraverser:: make_bounds_viz(const BoundingVolume *vol) { PT(Geom) geom; @@ -446,12 +414,10 @@ make_bounds_viz(const BoundingVolume *vol) { return geom; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::make_tight_bounds_viz -// Access: Private -// Description: Returns a bounding-box visualization of the indicated -// node's "tight" bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns a bounding-box visualization of the indicated node's "tight" + * bounding volume. + */ PT(Geom) CullTraverser:: make_tight_bounds_viz(PandaNode *node) const { PT(Geom) geom; @@ -480,8 +446,8 @@ make_tight_bounds_viz(PandaNode *node) const { PT(GeomLinestrips) strip = new GeomLinestrips(Geom::UH_stream); - // We wind one long linestrip around the wireframe cube. This - // does require backtracking a few times here and there. + // We wind one long linestrip around the wireframe cube. This does + // require backtracking a few times here and there. strip->add_vertex(0); strip->add_vertex(1); strip->add_vertex(3); @@ -507,12 +473,10 @@ make_tight_bounds_viz(PandaNode *node) const { return geom; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::compute_point -// Access: Private, Static -// Description: Returns a point on the surface of the sphere. -// latitude and longitude range from 0.0 to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns a point on the surface of the sphere. latitude and longitude range + * from 0.0 to 1.0. + */ LVertex CullTraverser:: compute_point(const BoundingSphere *sphere, PN_stdfloat latitude, PN_stdfloat longitude) { @@ -526,16 +490,14 @@ compute_point(const BoundingSphere *sphere, return p * sphere->get_radius() + sphere->get_center(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_bounds_outer_viz_state -// Access: Private, Static -// Description: Returns a RenderState for rendering the outside -// surfaces of the bounding volume visualizations. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the outside surfaces of the bounding + * volume visualizations. + */ CPT(RenderState) CullTraverser:: get_bounds_outer_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make @@ -546,16 +508,14 @@ get_bounds_outer_viz_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_bounds_inner_viz_state -// Access: Private, Static -// Description: Returns a RenderState for rendering the inside -// surfaces of the bounding volume visualizations. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the inside surfaces of the bounding + * volume visualizations. + */ CPT(RenderState) CullTraverser:: get_bounds_inner_viz_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make @@ -566,16 +526,13 @@ get_bounds_inner_viz_state() { return state; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverser::get_depth_offset_state -// Access: Private, Static -// Description: Returns a RenderState for increasing the DepthOffset -// by one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for increasing the DepthOffset by one. + */ CPT(RenderState) CullTraverser:: get_depth_offset_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make diff --git a/panda/src/pgraph/cullTraverser.h b/panda/src/pgraph/cullTraverser.h index 21aa8619d7..c137ecbbbf 100644 --- a/panda/src/pgraph/cullTraverser.h +++ b/panda/src/pgraph/cullTraverser.h @@ -1,16 +1,15 @@ -// Filename: cullTraverser.h -// Created by: drose (23eb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverser.h + * @author drose + * @date 2002-02-23 + */ #ifndef CULLTRAVERSER_H #define CULLTRAVERSER_H @@ -37,14 +36,12 @@ class CullTraverserData; class PortalClipper; class NodePath; -//////////////////////////////////////////////////////////////////// -// Class : CullTraverser -// Description : This object performs a depth-first traversal of the -// scene graph, with optional view-frustum culling, -// collecting CullState and searching for GeomNodes. -// Each renderable Geom encountered is passed along with -// its associated RenderState to the CullHandler object. -//////////////////////////////////////////////////////////////////// +/** + * This object performs a depth-first traversal of the scene graph, with + * optional view-frustum culling, collecting CullState and searching for + * GeomNodes. Each renderable Geom encountered is passed along with its + * associated RenderState to the CullHandler object. + */ class EXPCL_PANDA_PGRAPH CullTraverser : public TypedReferenceCount { PUBLISHED: CullTraverser(); diff --git a/panda/src/pgraph/cullTraverserData.I b/panda/src/pgraph/cullTraverserData.I index 5cd227322d..4367d1608e 100644 --- a/panda/src/pgraph/cullTraverserData.I +++ b/panda/src/pgraph/cullTraverserData.I @@ -1,22 +1,19 @@ -// Filename: cullTraverserData.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverserData.I + * @author drose + * @date 2002-03-06 + */ -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullTraverserData:: CullTraverserData(const NodePath &start, const TransformState *net_transform, @@ -37,11 +34,9 @@ CullTraverserData(const NodePath &start, _node_reader.check_cached(check_bounds); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullTraverserData:: CullTraverserData(const CullTraverserData ©) : _node_path(copy._node_path), @@ -55,11 +50,9 @@ CullTraverserData(const CullTraverserData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CullTraverserData:: operator = (const CullTraverserData ©) { _node_path = copy._node_path; @@ -72,12 +65,10 @@ operator = (const CullTraverserData ©) { _portal_depth = copy._portal_depth; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::Constructor -// Access: Public -// Description: This constructor creates a CullTraverserData object -// that reflects the next node down in the traversal. -//////////////////////////////////////////////////////////////////// +/** + * This constructor creates a CullTraverserData object that reflects the next + * node down in the traversal. + */ INLINE CullTraverserData:: CullTraverserData(const CullTraverserData &parent, PandaNode *child) : _node_path(parent._node_path, child), @@ -95,89 +86,70 @@ CullTraverserData(const CullTraverserData &parent, PandaNode *child) : _node_reader.check_cached(check_bounds); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullTraverserData:: ~CullTraverserData() { } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::node -// Access: Published -// Description: Returns the node traversed to so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node traversed to so far. + */ INLINE PandaNode *CullTraverserData:: node() const { return _node_path.node(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::node_reader -// Access: Public -// Description: Returns the PipelineReader for the node traversed to -// so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PipelineReader for the node traversed to so far. + */ INLINE PandaNodePipelineReader *CullTraverserData:: node_reader() { return &_node_reader; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::node_reader -// Access: Public -// Description: Returns the PipelineReader for the node traversed to -// so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PipelineReader for the node traversed to so far. + */ INLINE const PandaNodePipelineReader *CullTraverserData:: node_reader() const { return &_node_reader; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::get_modelview_transform -// Access: Published -// Description: Returns the modelview transform: the relative -// transform from the camera to the model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the modelview transform: the relative transform from the camera to + * the model. + */ INLINE CPT(TransformState) CullTraverserData:: get_modelview_transform(const CullTraverser *trav) const { return trav->get_world_transform()->compose(_net_transform); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::get_internal_transform -// Access: Published -// Description: Returns the internal transform: the modelview -// transform in the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal transform: the modelview transform in the GSG's + * internal coordinate system. + */ INLINE CPT(TransformState) CullTraverserData:: get_internal_transform(const CullTraverser *trav) const { return trav->get_scene()->get_cs_world_transform()->compose(_net_transform); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::get_net_transform -// Access: Published -// Description: Returns the net transform: the relative transform -// from root of the scene graph to the current node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net transform: the relative transform from root of the scene + * graph to the current node. + */ INLINE const TransformState *CullTraverserData:: get_net_transform(const CullTraverser *) const { return _net_transform; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::is_in_view -// Access: Published -// Description: Returns true if the current node is within the view -// frustum, false otherwise. If the node's bounding -// volume falls completely within the view frustum, this -// will also reset the view frustum pointer, saving some -// work for future nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current node is within the view frustum, false + * otherwise. If the node's bounding volume falls completely within the view + * frustum, this will also reset the view frustum pointer, saving some work + * for future nodes. + */ INLINE bool CullTraverserData:: is_in_view(const DrawMask &camera_mask) { if (_node_reader.get_transform()->is_invalid()) { @@ -186,15 +158,14 @@ is_in_view(const DrawMask &camera_mask) { } if (!_node_reader.compare_draw_mask(_draw_mask, camera_mask)) { - // If there are no draw bits in common with the camera, the node - // is out. + // If there are no draw bits in common with the camera, the node is out. return false; } if (_view_frustum == (GeometricBoundingVolume *)NULL && _cull_planes->is_empty()) { - // If the transform is valid, but we don't have a frustum or any - // clip planes or occluders, it's always in. + // If the transform is valid, but we don't have a frustum or any clip + // planes or occluders, it's always in. return true; } @@ -202,15 +173,11 @@ is_in_view(const DrawMask &camera_mask) { return is_in_view_impl(); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::is_this_node_hidden -// Access: Published -// Description: Returns true if this particular node is hidden, even -// though we might be traversing past this node to find -// a child node that has had show_through() called for -// it. If this returns true, the node should not be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular node is hidden, even though we might be + * traversing past this node to find a child node that has had show_through() + * called for it. If this returns true, the node should not be rendered. + */ INLINE bool CullTraverserData:: is_this_node_hidden(const DrawMask &camera_mask) const { return (_draw_mask & PandaNode::get_overall_bit()).is_zero() || diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 2fc0f1665c..186869cde6 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -1,16 +1,15 @@ -// Filename: cullTraverserData.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverserData.cxx + * @author drose + * @date 2002-03-06 + */ #include "cullTraverserData.h" #include "cullTraverser.h" @@ -28,22 +27,19 @@ #include "renderState.h" -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::apply_transform_and_state -// Access: Published -// Description: Applies the transform and state from the current -// node onto the current data. This also evaluates -// billboards, etc. -//////////////////////////////////////////////////////////////////// +/** + * Applies the transform and state from the current node onto the current + * data. This also evaluates billboards, etc. + */ void CullTraverserData:: apply_transform_and_state(CullTraverser *trav) { CPT(RenderState) node_state = _node_reader.get_state(); if (trav->has_tag_state_key() && _node_reader.has_tag(trav->get_tag_state_key())) { - // Here's a node that has been tagged with the special key for our - // current camera. This indicates some special state transition - // for this node, which is unique to this camera. + // Here's a node that has been tagged with the special key for our current + // camera. This indicates some special state transition for this node, + // which is unique to this camera. const Camera *camera = trav->get_scene()->get_camera_node(); string tag_state = _node_reader.get_tag(trav->get_tag_state_key()); node_state = node_state->compose(camera->get_tag_state(tag_state)); @@ -55,13 +51,10 @@ apply_transform_and_state(CullTraverser *trav) { _node_reader.get_off_clip_planes()); } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::apply_transform_and_state -// Access: Published -// Description: Applies the indicated transform and state changes -// (e.g. as extracted from a node) onto the current -// data. This also evaluates billboards, etc. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform and state changes (e.g. as extracted from + * a node) onto the current data. This also evaluates billboards, etc. + */ void CullTraverserData:: apply_transform_and_state(CullTraverser *trav, CPT(TransformState) node_transform, @@ -77,12 +70,11 @@ apply_transform_and_state(CullTraverser *trav, if ((_view_frustum != (GeometricBoundingVolume *)NULL) || (!_cull_planes->is_empty())) { - // We need to move the viewing frustums into the node's - // coordinate space by applying the node's inverse transform. + // We need to move the viewing frustums into the node's coordinate space + // by applying the node's inverse transform. if (node_transform->is_singular()) { - // But we can't invert a singular transform! Instead of - // trying, we'll just give up on frustum culling from this - // point down. + // But we can't invert a singular transform! Instead of trying, we'll + // just give up on frustum culling from this point down. _view_frustum = (GeometricBoundingVolume *)NULL; _cull_planes = CullPlanes::make_empty(); @@ -90,8 +82,8 @@ apply_transform_and_state(CullTraverser *trav, CPT(TransformState) inv_transform = node_transform->invert_compose(TransformState::make_identity()); - // Copy the bounding volumes for the frustums so we can - // transform them. + // Copy the bounding volumes for the frustums so we can transform + // them. if (_view_frustum != (GeometricBoundingVolume *)NULL) { _view_frustum = _view_frustum->make_copy()->as_geometric_bounding_volume(); nassertv(_view_frustum != (GeometricBoundingVolume *)NULL); @@ -114,11 +106,9 @@ apply_transform_and_state(CullTraverser *trav, } } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::is_in_view_impl -// Access: Private -// Description: The private implementation of is_in_view(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of is_in_view(). + */ bool CullTraverserData:: is_in_view_impl() { const GeometricBoundingVolume *node_gbv = NULL; @@ -143,27 +133,26 @@ is_in_view_impl() { return false; } - // If we have fake view-frustum culling enabled, instead of - // actually culling an object we simply force it to be drawn in - // red wireframe. + // If we have fake view-frustum culling enabled, instead of actually + // culling an object we simply force it to be drawn in red wireframe. _view_frustum = (GeometricBoundingVolume *)NULL; CPT(RenderState) fake_state = get_fake_view_frustum_cull_state(); _state = _state->compose(fake_state); #endif } else if ((result & BoundingVolume::IF_all) != 0) { - // The node and its descendents are completely enclosed within - // the frustum. No need to cull further. + // The node and its descendents are completely enclosed within the + // frustum. No need to cull further. _view_frustum = (GeometricBoundingVolume *)NULL; } else { // The node is partially, but not completely, within the viewing // frustum. if (_node_reader.is_final()) { - // Normally we'd keep testing child bounding volumes as we - // continue down. But this node has the "final" flag, so the - // user is claiming that there is some important reason we - // should consider everything visible at this point. So be it. + // Normally we'd keep testing child bounding volumes as we continue + // down. But this node has the "final" flag, so the user is claiming + // that there is some important reason we should consider everything + // visible at this point. So be it. _view_frustum = (GeometricBoundingVolume *)NULL; } } @@ -187,8 +176,8 @@ is_in_view_impl() { } if (_node_reader.is_final()) { - // Even though the node may be partially within the clip planes, - // do no more culling against them below this node. + // Even though the node may be partially within the clip planes, do no + // more culling against them below this node. _cull_planes = CullPlanes::make_empty(); if (pgraph_cat.is_spam()) { @@ -212,9 +201,9 @@ is_in_view_impl() { #endif } else if ((result & BoundingVolume::IF_all) != 0) { - // The node and its descendents are completely in front of all - // of the clip planes and occluders. The do_cull() call should - // therefore have removed all of the clip planes and occluders. + // The node and its descendents are completely in front of all of the + // clip planes and occluders. The do_cull() call should therefore have + // removed all of the clip planes and occluders. nassertr(_cull_planes->is_empty(), true); } } @@ -222,20 +211,17 @@ is_in_view_impl() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CullTraverserData::get_fake_view_frustum_cull_state -// Access: Private, Static -// Description: Returns a RenderState for rendering stuff in red -// wireframe, strictly for the fake_view_frustum_cull -// effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering stuff in red wireframe, strictly for + * the fake_view_frustum_cull effect. + */ CPT(RenderState) CullTraverserData:: get_fake_view_frustum_cull_state() { #ifdef NDEBUG return NULL; #else - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make diff --git a/panda/src/pgraph/cullTraverserData.h b/panda/src/pgraph/cullTraverserData.h index a8b3da130c..80d523fe0c 100644 --- a/panda/src/pgraph/cullTraverserData.h +++ b/panda/src/pgraph/cullTraverserData.h @@ -1,16 +1,15 @@ -// Filename: cullTraverserData.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullTraverserData.h + * @author drose + * @date 2002-03-06 + */ #ifndef CULLTRAVERSERDATA_H #define CULLTRAVERSERDATA_H @@ -28,20 +27,16 @@ class PandaNode; class CullTraverser; -//////////////////////////////////////////////////////////////////// -// Class : CullTraverserData -// Description : This collects together the pieces of data that are -// accumulated for each node while walking the scene -// graph during the cull traversal. -// -// Having this as a separate object simplifies the -// parameter list to CullTraverser::r_traverse(), as -// well as to other functions like -// PandaNode::cull_callback(). It also makes it easier -// to add cull parameters, and provides a place to -// abstract out some of the cull behavior (like -// view-frustum culling). -//////////////////////////////////////////////////////////////////// +/** + * This collects together the pieces of data that are accumulated for each + * node while walking the scene graph during the cull traversal. + * + * Having this as a separate object simplifies the parameter list to + * CullTraverser::r_traverse(), as well as to other functions like + * PandaNode::cull_callback(). It also makes it easier to add cull + * parameters, and provides a place to abstract out some of the cull behavior + * (like view-frustum culling). + */ class EXPCL_PANDA_PGRAPH CullTraverserData { public: INLINE CullTraverserData(const NodePath &start, diff --git a/panda/src/pgraph/cullableObject.I b/panda/src/pgraph/cullableObject.I index b2b1a8962a..242496587f 100644 --- a/panda/src/pgraph/cullableObject.I +++ b/panda/src/pgraph/cullableObject.I @@ -1,24 +1,19 @@ -// Filename: cullableObject.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullableObject.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::Constructor -// Access: Public -// Description: Creates an empty CullableObject whose pointers can be -// filled in later. -//////////////////////////////////////////////////////////////////// +/** + * Creates an empty CullableObject whose pointers can be filled in later. + */ INLINE CullableObject:: CullableObject() { #ifdef DO_MEMORY_USAGE @@ -26,12 +21,10 @@ CullableObject() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::Constructor -// Access: Public -// Description: Creates a CullableObject based the indicated geom, -// with the indicated render state and transform. -//////////////////////////////////////////////////////////////////// +/** + * Creates a CullableObject based the indicated geom, with the indicated + * render state and transform. + */ INLINE CullableObject:: CullableObject(const Geom *geom, const RenderState *state, const TransformState *internal_transform) : @@ -44,11 +37,9 @@ CullableObject(const Geom *geom, const RenderState *state, #endif } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::Copy Constructor -// Access: Public -// Description: Copies the CullableObject. -//////////////////////////////////////////////////////////////////// +/** + * Copies the CullableObject. + */ INLINE CullableObject:: CullableObject(const CullableObject ©) : _geom(copy._geom), @@ -62,11 +53,9 @@ CullableObject(const CullableObject ©) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::Copy Assignment Operator -// Access: Public -// Description: Copies the CullableObject. -//////////////////////////////////////////////////////////////////// +/** + * Copies the CullableObject. + */ INLINE void CullableObject:: operator = (const CullableObject ©) { _geom = copy._geom; @@ -77,13 +66,10 @@ operator = (const CullableObject ©) { _draw_callback = copy._draw_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::draw -// Access: Public -// Description: Draws the cullable object on the GSG immediately, in -// the GSG's current state. This should only be called -// from the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Draws the cullable object on the GSG immediately, in the GSG's current + * state. This should only be called from the draw thread. + */ INLINE void CullableObject:: draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { if (_draw_callback != (CallbackObject *)NULL) { @@ -104,14 +90,11 @@ draw(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::request_resident -// Access: Public -// Description: Returns true if all the data necessary to render this -// object is currently resident in memory. If this -// returns false, the data will be brought back into -// memory shortly; try again later. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all the data necessary to render this object is currently + * resident in memory. If this returns false, the data will be brought back + * into memory shortly; try again later. + */ INLINE bool CullableObject:: request_resident() const { bool resident = true; @@ -125,67 +108,54 @@ request_resident() const { } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::set_draw_callback -// Access: Public -// Description: Specifies a CallbackObject that will be responsible -// for drawing this object. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a CallbackObject that will be responsible for drawing this + * object. + */ INLINE void CullableObject:: set_draw_callback(CallbackObject *draw_callback) { _draw_callback = draw_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void CullableObject:: flush_level() { _sw_sprites_pcollector.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::draw_inline -// Access: Private -// Description: Draws the cullable object on the GSG immediately, in -// the GSG's current state. This should only be called -// from the draw thread. Assumes the GSG has already -// been set to the appropriate state. -//////////////////////////////////////////////////////////////////// +/** + * Draws the cullable object on the GSG immediately, in the GSG's current + * state. This should only be called from the draw thread. Assumes the GSG + * has already been set to the appropriate state. + */ INLINE void CullableObject:: draw_inline(GraphicsStateGuardianBase *gsg, bool force, Thread *current_thread) { _geom->draw(gsg, _munger, _munged_data, force, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::SortPoints::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CullableObject::SortPoints:: SortPoints(const CullableObject::PointData *array) : _array(array) { } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::SortPoints::operator () -// Access: Public -// Description: Orders the points from back-to-front for correct -// transparency sorting in munge_points_to_quads -//////////////////////////////////////////////////////////////////// +/** + * Orders the points from back-to-front for correct transparency sorting in + * munge_points_to_quads + */ INLINE bool CullableObject::SortPoints:: operator () (unsigned short a, unsigned short b) const { return _array[a]._dist > _array[b]._dist; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::SourceFormat::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CullableObject::SourceFormat:: operator < (const CullableObject::SourceFormat &other) const { if (_format != other._format) { diff --git a/panda/src/pgraph/cullableObject.cxx b/panda/src/pgraph/cullableObject.cxx index 2eae19dac5..33503de0eb 100644 --- a/panda/src/pgraph/cullableObject.cxx +++ b/panda/src/pgraph/cullableObject.cxx @@ -1,16 +1,15 @@ -// Filename: cullableObject.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullableObject.cxx + * @author drose + * @date 2002-03-04 + */ #include "cullableObject.h" #include "lightAttrib.h" @@ -43,17 +42,13 @@ PStatCollector CullableObject::_sw_sprites_pcollector("SW Sprites"); TypeHandle CullableObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::munge_geom -// Access: Public -// Description: Uses the indicated GeomMunger to transform the geom -// and/or its vertices. -// -// If force is false, this may do nothing and return -// false if the vertex data is nonresident. If force is -// true, this will always return true, but it may have -// to block while the vertex data is paged in. -//////////////////////////////////////////////////////////////////// +/** + * Uses the indicated GeomMunger to transform the geom and/or its vertices. + * + * If force is false, this may do nothing and return false if the vertex data + * is nonresident. If force is true, this will always return true, but it may + * have to block while the vertex data is paged in. + */ bool CullableObject:: munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger, const CullTraverser *traverser, @@ -95,9 +90,8 @@ munge_geom(GraphicsStateGuardianBase *gsg, GraphicsStateGuardianBase *gsg = traverser->get_gsg(); int gsg_bits = gsg->get_supported_geom_rendering(); if (!hardware_point_sprites) { - // If support for hardware point sprites or perspective-scaled - // points is disabled, we don't allow the GSG to tell us it - // supports them. + // If support for hardware point sprites or perspective-scaled points is + // disabled, we don't allow the GSG to tell us it supports them. gsg_bits &= ~(Geom::GR_point_perspective | Geom::GR_point_sprite); } if (!hardware_points) { @@ -108,10 +102,10 @@ munge_geom(GraphicsStateGuardianBase *gsg, int unsupported_bits = geom_rendering & ~gsg_bits; if ((unsupported_bits & Geom::GR_point_bits) != 0) { - // The GSG doesn't support rendering these fancy points - // directly; we have to render them in software instead. - // Munge them into quads. This will replace the _geom and - // _munged_data, and might also replace _state. + // The GSG doesn't support rendering these fancy points directly; we + // have to render them in software instead. Munge them into quads. + // This will replace the _geom and _munged_data, and might also replace + // _state. if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "munge_points_to_quads() for geometry with bits: " @@ -123,15 +117,15 @@ munge_geom(GraphicsStateGuardianBase *gsg, } } - // Now invoke the munger to ensure the resulting geometry is in - // a GSG-friendly form. + // Now invoke the munger to ensure the resulting geometry is in a GSG- + // friendly form. if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) { return false; } - // If we have prepared it for skinning via the shader generator, - // mark a flag on the state so that the shader generator will do this. - // We should probably find a cleaner way to do this. + // If we have prepared it for skinning via the shader generator, mark a + // flag on the state so that the shader generator will do this. We should + // probably find a cleaner way to do this. const ShaderAttrib *sattr; if (_state->get_attrib(sattr) && sattr->auto_shader()) { GeomVertexDataPipelineReader data_reader(_munged_data, current_thread); @@ -145,10 +139,9 @@ munge_geom(GraphicsStateGuardianBase *gsg, StateMunger *state_munger = (StateMunger *)munger; _state = state_munger->munge_state(_state); - // If there is any animation left in the vertex data after it - // has been munged--that is, we couldn't arrange to handle the - // animation in hardware--then we have to calculate that - // animation now. + // If there is any animation left in the vertex data after it has been + // munged--that is, we couldn't arrange to handle the animation in + // hardware--then we have to calculate that animation now. bool cpu_animated = false; CPT(GeomVertexData) animated_vertices = @@ -177,11 +170,9 @@ munge_geom(GraphicsStateGuardianBase *gsg, return true; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CullableObject:: output(ostream &out) const { if (_geom != (Geom *)NULL) { @@ -191,20 +182,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::munge_points_to_quads -// Access: Private -// Description: Converts a table of points to quads for rendering on -// systems that don't support fancy points. -// -// This may replace _geom, _munged_data, and _state. -//////////////////////////////////////////////////////////////////// +/** + * Converts a table of points to quads for rendering on systems that don't + * support fancy points. + * + * This may replace _geom, _munged_data, and _state. + */ bool CullableObject:: munge_points_to_quads(const CullTraverser *traverser, bool force) { Thread *current_thread = traverser->get_current_thread(); - // Better get the animated vertices, in case we're showing sprites - // on an animated model for some reason. + // Better get the animated vertices, in case we're showing sprites on an + // animated model for some reason. CPT(GeomVertexData) source_data = _munged_data->animate_vertices(force, current_thread); @@ -258,8 +247,8 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { perspective = render_mode->get_perspective(); if (render_mode->get_mode() != RenderModeAttrib::M_filled_flat) { - // Render the new polygons with M_filled_flat, for a slight - // performance advantage when software rendering. + // Render the new polygons with M_filled_flat, for a slight performance + // advantage when software rendering. _state = _state->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled_flat)); } } @@ -278,15 +267,15 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { // We have to construct the format now. PT(GeomVertexArrayFormat) new_array_format; if (sformat._retransform_sprites) { - // With retransform_sprites in effect, we will be sending ordinary - // 3-D points to the graphics API. + // With retransform_sprites in effect, we will be sending ordinary 3-D + // points to the graphics API. new_array_format = new GeomVertexArrayFormat(InternalName::get_vertex(), 3, Geom::NT_stdfloat, Geom::C_point); } else { - // Without retransform_sprites, we will be sending 4-component - // clip-space points. + // Without retransform_sprites, we will be sending 4-component clip- + // space points. new_array_format = new GeomVertexArrayFormat(InternalName::get_vertex(), 4, Geom::NT_stdfloat, @@ -335,8 +324,8 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { int viewport_width = scene->get_viewport_width(); int viewport_height = scene->get_viewport_height(); - // We need a standard projection matrix, in a known coordinate - // system, to compute the perspective height. + // We need a standard projection matrix, in a known coordinate system, to + // compute the perspective height. LMatrix4 height_projection; if (perspective) { height_projection = @@ -348,10 +337,9 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { LMatrix4 inv_render_transform; inv_render_transform.invert_from(render_transform); - // Now convert all of the vertices in the GeomVertexData to quads. - // We always convert all the vertices, assuming all the vertices are - // referenced by GeomPrimitives, because we want to optimize for the - // most common case. + // Now convert all of the vertices in the GeomVertexData to quads. We + // always convert all the vertices, assuming all the vertices are referenced + // by GeomPrimitives, because we want to optimize for the most common case. int orig_verts = source_data->get_num_rows(); int new_verts = 4 * orig_verts; // each vertex becomes four. @@ -364,9 +352,9 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { GeomVertexWriter new_color(new_data, InternalName::get_color()); GeomVertexWriter new_texcoord(new_data, InternalName::get_texcoord()); - // We'll keep an array of all of the points' eye-space coordinates, - // and their distance from the camera, so we can sort the points for - // each primitive, below. + // We'll keep an array of all of the points' eye-space coordinates, and + // their distance from the camera, so we can sort the points for each + // primitive, below. PointData *points; { PStatTimer t2(_munge_sprites_verts_pcollector, current_thread); @@ -387,23 +375,22 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { PN_stdfloat scale_y = point_size; if (perspective) { - // Perspective-sized points. Here point_size is the point's - // height in 3-d units. To arrange that, we need to figure out - // the appropriate scaling factor based on the current viewport - // and projection matrix. + // Perspective-sized points. Here point_size is the point's height in + // 3-d units. To arrange that, we need to figure out the appropriate + // scaling factor based on the current viewport and projection matrix. LVector3 height(0.0f, point_size * scale, scale); height = height * height_projection; scale_y = height[1] * viewport_height; - // We should then divide the radius by the distance from the - // camera plane, to emulate the glPointParameters() behavior. + // We should then divide the radius by the distance from the camera + // plane, to emulate the glPointParameters() behavior. if (!lens->is_orthographic()) { scale_y /= dist; } } - // Also factor in the homogeneous scale for being in clip - // coordinates still. + // Also factor in the homogeneous scale for being in clip coordinates + // still. scale_y *= p4[3]; PN_stdfloat scale_x = scale_y; @@ -423,16 +410,16 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { c1 = c1 * mat; } - // Finally, scale the corners in their newly-rotated position, - // to compensate for the aspect ratio of the viewport. + // Finally, scale the corners in their newly-rotated position, to + // compensate for the aspect ratio of the viewport. PN_stdfloat rx = 1.0f / viewport_width; PN_stdfloat ry = 1.0f / viewport_height; c0.set(c0[0] * rx, c0[1] * ry); c1.set(c1[0] * rx, c1[1] * ry); if (retransform_sprites) { - // With retransform_sprites in effect, we must reconvert the - // resulting quad back into the original 3-D space. + // With retransform_sprites in effect, we must reconvert the resulting + // quad back into the original 3-D space. new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]))); new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]))); new_vertex.set_data4(inv_render_transform.xform(LPoint4(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]))); @@ -447,8 +434,8 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } } else { - // Without retransform_sprites, we can simply load the - // clip-space coordinates. + // Without retransform_sprites, we can simply load the clip-space + // coordinates. new_vertex.set_data4(p4[0] + c0[0], p4[1] + c0[1], p4[2], p4[3]); new_vertex.set_data4(p4[0] + c1[0], p4[1] + c1[1], p4[2], p4[3]); new_vertex.set_data4(p4[0] - c1[0], p4[1] - c1[1], p4[2], p4[3]); @@ -489,8 +476,8 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { nassertr(new_data->get_num_rows() == new_verts, false); } - // Determine the format we should use to store the indices. - // Don't choose NT_uint8, as Direct3D 9 doesn't support it. + // Determine the format we should use to store the indices. Don't choose + // NT_uint8, as Direct3D 9 doesn't support it. const GeomVertexArrayFormat *new_prim_format = NULL; if (new_verts < 0xffff) { new_prim_format = GeomPrimitive::get_index_format(GeomEnums::NT_uint16); @@ -502,17 +489,16 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { PT(Geom) new_geom = new Geom(new_data); // Replace each primitive in the Geom (it's presumably a GeomPoints - // primitive, although it might be some other kind of primitive if - // we got here because RenderModeAttrib::M_point is enabled) with a - // new primitive that replaces each vertex with a quad of the - // appropriate scale and orientation. + // primitive, although it might be some other kind of primitive if we got + // here because RenderModeAttrib::M_point is enabled) with a new primitive + // that replaces each vertex with a quad of the appropriate scale and + // orientation. - // BUG: if we're rendering polygons in M_point mode with a - // CullFaceAttrib in effect, we won't actually apply the - // CullFaceAttrib but will always render all of the vertices of the - // polygons. This is certainly a bug, but a very minor one; and in - // order to fix it we'd have to do the face culling ourselves--not - // sure if it's worth it. + // BUG: if we're rendering polygons in M_point mode with a CullFaceAttrib in + // effect, we won't actually apply the CullFaceAttrib but will always render + // all of the vertices of the polygons. This is certainly a bug, but a very + // minor one; and in order to fix it we'd have to do the face culling + // ourselves--not sure if it's worth it. { PStatTimer t3(_munge_sprites_prims_pcollector, current_thread); @@ -544,16 +530,15 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { } } - // Now sort the points in order from back-to-front so they will - // render properly with transparency, at least with each other. + // Now sort the points in order from back-to-front so they will render + // properly with transparency, at least with each other. sort(vertices, vertices_end, SortPoints(points)); - // Go through the points, now in sorted order, and generate a pair - // of triangles for each one. We generate indexed triangles - // instead of two-triangle strips, since this seems to be - // generally faster on PC hardware (otherwise, we'd have to nearly - // double the vertices to stitch all the little triangle strips - // together). + // Go through the points, now in sorted order, and generate a pair of + // triangles for each one. We generate indexed triangles instead of + // two-triangle strips, since this seems to be generally faster on PC + // hardware (otherwise, we'd have to nearly double the vertices to + // stitch all the little triangle strips together). PT(GeomPrimitive) new_primitive = new GeomTriangles(Geom::UH_stream); int new_prim_verts = 6 * num_vertices; // two triangles per point. @@ -595,19 +580,16 @@ munge_points_to_quads(const CullTraverser *traverser, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::get_flash_cpu_state -// Access: Private, Static -// Description: Returns a RenderState for flashing the object red, to -// show it is animated by the CPU when -// show-vertex-animation is on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for flashing the object red, to show it is animated + * by the CPU when show-vertex-animation is on. + */ CPT(RenderState) CullableObject:: get_flash_cpu_state() { static const LColor flash_cpu_color(0.8f, 0.2, 0.2, 1.0f); - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) flash_cpu_state = (const RenderState *)NULL; if (flash_cpu_state == (const RenderState *)NULL) { flash_cpu_state = RenderState::make @@ -619,19 +601,16 @@ get_flash_cpu_state() { return flash_cpu_state; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::get_flash_hardware_state -// Access: Private, Static -// Description: Returns a RenderState for flashing the object blue, -// to show it is animated by the hardware when -// show-vertex-animation is on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for flashing the object blue, to show it is animated + * by the hardware when show-vertex-animation is on. + */ CPT(RenderState) CullableObject:: get_flash_hardware_state() { static const LColor flash_hardware_color(0.2, 0.2, 0.8, 1.0); - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) flash_hardware_state = (const RenderState *)NULL; if (flash_hardware_state == (const RenderState *)NULL) { flash_hardware_state = RenderState::make @@ -643,11 +622,9 @@ get_flash_hardware_state() { return flash_hardware_state; } -//////////////////////////////////////////////////////////////////// -// Function: CullableObject::SourceFormat::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CullableObject::SourceFormat:: SourceFormat(const GeomVertexFormat *format, bool sprite_texcoord) : _format(format), diff --git a/panda/src/pgraph/cullableObject.h b/panda/src/pgraph/cullableObject.h index 575ae4c35f..82fd0df3a5 100644 --- a/panda/src/pgraph/cullableObject.h +++ b/panda/src/pgraph/cullableObject.h @@ -1,16 +1,15 @@ -// Filename: cullableObject.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cullableObject.h + * @author drose + * @date 2002-03-04 + */ #ifndef CULLABLEOBJECT_H #define CULLABLEOBJECT_H @@ -36,12 +35,10 @@ class CullTraverser; -//////////////////////////////////////////////////////////////////// -// Class : CullableObject -// Description : The smallest atom of cull. This is normally just a -// Geom and its associated state, but it also contain -// a draw callback. -//////////////////////////////////////////////////////////////////// +/** + * The smallest atom of cull. This is normally just a Geom and its associated + * state, but it also contain a draw callback. + */ class EXPCL_PANDA_PGRAPH CullableObject #ifdef DO_MEMORY_USAGE : public ReferenceCount // We inherit from ReferenceCount just to get the memory type tracking that MemoryUsage provides. diff --git a/panda/src/pgraph/decalEffect.I b/panda/src/pgraph/decalEffect.I index 52fb5fa9b6..29ec5335cb 100644 --- a/panda/src/pgraph/decalEffect.I +++ b/panda/src/pgraph/decalEffect.I @@ -1,24 +1,19 @@ -// Filename: decalEffect.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decalEffect.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::Constructor -// Access: Private -// Description: Use DecalEffect::make() to construct a new -// DecalEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use DecalEffect::make() to construct a new DecalEffect object. + */ INLINE DecalEffect:: DecalEffect() { } diff --git a/panda/src/pgraph/decalEffect.cxx b/panda/src/pgraph/decalEffect.cxx index 13445294b6..1997c0288b 100644 --- a/panda/src/pgraph/decalEffect.cxx +++ b/panda/src/pgraph/decalEffect.cxx @@ -1,16 +1,15 @@ -// Filename: decalEffect.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decalEffect.cxx + * @author drose + * @date 2002-03-14 + */ #include "decalEffect.h" #include "bamReader.h" @@ -20,81 +19,64 @@ TypeHandle DecalEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::make -// Access: Published, Static -// Description: Constructs a new DecalEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new DecalEffect object. + */ CPT(RenderEffect) DecalEffect:: make() { DecalEffect *effect = new DecalEffect; return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if this kind of effect can safely be -// combined with sibling nodes that share the exact same -// effect, or false if this is not a good idea. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of effect can safely be combined with sibling + * nodes that share the exact same effect, or false if this is not a good + * idea. + */ bool DecalEffect:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived DecalEffect -// types to return a unique number indicating whether -// this DecalEffect is equivalent to the other one. -// -// This should return 0 if the two DecalEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two DecalEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived DecalEffect types to return a unique + * number indicating whether this DecalEffect is equivalent to the other one. + * + * This should return 0 if the two DecalEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two DecalEffect objects whose get_type() + * functions return the same. + */ int DecalEffect:: compare_to_impl(const RenderEffect *other) const { - // All DecalEffects are equivalent--there are no properties to - // store. + // All DecalEffects are equivalent--there are no properties to store. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// DecalEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type DecalEffect. + */ void DecalEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DecalEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type DecalEffect is encountered -// in the Bam file. It should create the DecalEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type DecalEffect is encountered in the Bam file. It should create the + * DecalEffect and extract its information from the file. + */ TypedWritable *DecalEffect:: make_from_bam(const FactoryParams ¶ms) { DecalEffect *effect = new DecalEffect; @@ -107,13 +89,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: DecalEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new DecalEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new DecalEffect. + */ void DecalEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); diff --git a/panda/src/pgraph/decalEffect.h b/panda/src/pgraph/decalEffect.h index 9d386f48e2..2c567d8690 100644 --- a/panda/src/pgraph/decalEffect.h +++ b/panda/src/pgraph/decalEffect.h @@ -1,16 +1,15 @@ -// Filename: decalEffect.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file decalEffect.h + * @author drose + * @date 2002-03-14 + */ #ifndef DECALEFFECT_H #define DECALEFFECT_H @@ -21,12 +20,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : DecalEffect -// Description : Applied to a GeomNode to indicate that the children -// of this GeomNode are coplanar and should be drawn as -// decals (eliminating Z-fighting). -//////////////////////////////////////////////////////////////////// +/** + * Applied to a GeomNode to indicate that the children of this GeomNode are + * coplanar and should be drawn as decals (eliminating Z-fighting). + */ class EXPCL_PANDA_PGRAPH DecalEffect : public RenderEffect { private: INLINE DecalEffect(); @@ -45,7 +42,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -67,4 +64,3 @@ private: #include "decalEffect.I" #endif - diff --git a/panda/src/pgraph/depthOffsetAttrib.I b/panda/src/pgraph/depthOffsetAttrib.I index 015c759b70..186027654d 100644 --- a/panda/src/pgraph/depthOffsetAttrib.I +++ b/panda/src/pgraph/depthOffsetAttrib.I @@ -1,24 +1,19 @@ -// Filename: depthOffsetAttrib.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthOffsetAttrib.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::Constructor -// Access: Private -// Description: Use DepthOffsetAttrib::make() to construct a new -// DepthOffsetAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use DepthOffsetAttrib::make() to construct a new DepthOffsetAttrib object. + */ INLINE DepthOffsetAttrib:: DepthOffsetAttrib(int offset, PN_stdfloat min_value, PN_stdfloat max_value) : _offset(offset), @@ -27,35 +22,27 @@ DepthOffsetAttrib(int offset, PN_stdfloat min_value, PN_stdfloat max_value) : { } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::get_offset -// Access: Published -// Description: Returns the depth offset represented by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth offset represented by this attrib. + */ INLINE int DepthOffsetAttrib:: get_offset() const { return _offset; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::get_min_value -// Access: Published -// Description: Returns the value for the minimum (closest) depth -// value to be stored in the buffer, in the range 0 -// .. 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value for the minimum (closest) depth value to be stored in the + * buffer, in the range 0 .. 1. + */ INLINE PN_stdfloat DepthOffsetAttrib:: get_min_value() const { return _min_value; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::get_max_value -// Access: Published -// Description: Returns the value for the maximum (farthest) depth -// value to be stored in the buffer, in the range 0 -// .. 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value for the maximum (farthest) depth value to be stored in + * the buffer, in the range 0 .. 1. + */ INLINE PN_stdfloat DepthOffsetAttrib:: get_max_value() const { return _max_value; diff --git a/panda/src/pgraph/depthOffsetAttrib.cxx b/panda/src/pgraph/depthOffsetAttrib.cxx index 8861947048..a4339c333a 100644 --- a/panda/src/pgraph/depthOffsetAttrib.cxx +++ b/panda/src/pgraph/depthOffsetAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: depthOffsetAttrib.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthOffsetAttrib.cxx + * @author drose + * @date 2002-03-14 + */ #include "depthOffsetAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,30 +22,23 @@ TypeHandle DepthOffsetAttrib::_type_handle; int DepthOffsetAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::make -// Access: Published, Static -// Description: Constructs a new DepthOffsetAttrib object that -// indicates the relative amount of bias to write to the -// depth buffer for subsequent geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new DepthOffsetAttrib object that indicates the relative + * amount of bias to write to the depth buffer for subsequent geometry. + */ CPT(RenderAttrib) DepthOffsetAttrib:: make(int offset) { DepthOffsetAttrib *attrib = new DepthOffsetAttrib(offset, 0.0f, 1.0f); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::make -// Access: Published, Static -// Description: Constructs a new DepthOffsetAttrib object that -// indicates the bias, and also specifies a minimum and -// maximum (or, more precisely, nearest and farthest) -// values to write to the depth buffer, in the range 0 -// .. 1. This range is 0, 1 by default; setting it to -// some other range can be used to create additional -// depth buffer effects. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new DepthOffsetAttrib object that indicates the bias, and also + * specifies a minimum and maximum (or, more precisely, nearest and farthest) + * values to write to the depth buffer, in the range 0 .. 1. This range is 0, + * 1 by default; setting it to some other range can be used to create + * additional depth buffer effects. + */ CPT(RenderAttrib) DepthOffsetAttrib:: make(int offset, PN_stdfloat min_value, PN_stdfloat max_value) { nassertr(min_value >= 0.0f && min_value <= 1.0f, NULL); @@ -55,44 +47,36 @@ make(int offset, PN_stdfloat min_value, PN_stdfloat max_value) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) DepthOffsetAttrib:: make_default() { return return_new(new DepthOffsetAttrib(0, 0.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DepthOffsetAttrib:: output(ostream &out) const { out << get_type() << ":(" << get_offset() << ", " << get_min_value() << ", " << get_max_value() << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived DepthOffsetAttrib -// types to return a unique number indicating whether -// this DepthOffsetAttrib is equivalent to the other one. -// -// This should return 0 if the two DepthOffsetAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two DepthOffsetAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived DepthOffsetAttrib types to return a + * unique number indicating whether this DepthOffsetAttrib is equivalent to + * the other one. + * + * This should return 0 if the two DepthOffsetAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two DepthOffsetAttrib objects whose + * get_type() functions return the same. + */ int DepthOffsetAttrib:: compare_to_impl(const RenderAttrib *other) const { const DepthOffsetAttrib *ta = (const DepthOffsetAttrib *)other; @@ -109,16 +93,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t DepthOffsetAttrib:: get_hash_impl() const { size_t hash = 0; @@ -128,23 +108,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) DepthOffsetAttrib:: compose_impl(const RenderAttrib *other) const { const DepthOffsetAttrib *ta = (const DepthOffsetAttrib *)other; @@ -155,15 +129,12 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) DepthOffsetAttrib:: invert_compose_impl(const RenderAttrib *other) const { const DepthOffsetAttrib *ta = (const DepthOffsetAttrib *)other; @@ -174,23 +145,18 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// DepthOffsetAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type DepthOffsetAttrib. + */ void DepthOffsetAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DepthOffsetAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -200,14 +166,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_max_value); } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type DepthOffsetAttrib is encountered -// in the Bam file. It should create the DepthOffsetAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type DepthOffsetAttrib is encountered in the Bam file. It should create + * the DepthOffsetAttrib and extract its information from the file. + */ TypedWritable *DepthOffsetAttrib:: make_from_bam(const FactoryParams ¶ms) { DepthOffsetAttrib *attrib = new DepthOffsetAttrib(0, 0.0f, 1.0f); @@ -220,13 +183,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: DepthOffsetAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new DepthOffsetAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new DepthOffsetAttrib. + */ void DepthOffsetAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/depthOffsetAttrib.h b/panda/src/pgraph/depthOffsetAttrib.h index 626d24707f..fe617fa56a 100644 --- a/panda/src/pgraph/depthOffsetAttrib.h +++ b/panda/src/pgraph/depthOffsetAttrib.h @@ -1,16 +1,15 @@ -// Filename: depthOffsetAttrib.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthOffsetAttrib.h + * @author drose + * @date 2002-03-14 + */ #ifndef DEPTHOFFSETATTRIB_H #define DEPTHOFFSETATTRIB_H @@ -22,40 +21,32 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : DepthOffsetAttrib -// Description : This is a special kind of attribute that instructs -// the graphics driver to apply an offset or bias to the -// generated depth values for rendered polygons, before -// they are written to the depth buffer. -// -// This can be used to shift polygons forward slightly, -// to resolve depth conflicts. The cull traverser may -// optionally use this, for instance, to implement -// decals. However, driver support for this feature -// seems to be spotty, so use with caution. -// -// The bias is always an integer number, and each -// integer increment represents the smallest possible -// increment in Z that is sufficient to completely -// resolve two coplanar polygons. Positive numbers are -// closer towards the camera. -// -// Nested DepthOffsetAttrib values accumulate; that is, -// a DepthOffsetAttrib with a value of 1 beneath another -// DepthOffsetAttrib with a value of 2 presents a net -// offset of 3. (A DepthOffsetAttrib will not, however, -// combine with any other DepthOffsetAttribs with a -// lower override parameter.) The net value should -// probably not exceed 16 or drop below 0 for maximum -// portability. -// -// Also, and only tangentially related, the -// DepthOffsetAttrib can be used to constrain the Z -// output value to a subset of the usual [0, 1] range -// (or reversing its direction) by specifying a new -// min_value and max_value. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of attribute that instructs the graphics driver to + * apply an offset or bias to the generated depth values for rendered + * polygons, before they are written to the depth buffer. + * + * This can be used to shift polygons forward slightly, to resolve depth + * conflicts. The cull traverser may optionally use this, for instance, to + * implement decals. However, driver support for this feature seems to be + * spotty, so use with caution. + * + * The bias is always an integer number, and each integer increment represents + * the smallest possible increment in Z that is sufficient to completely + * resolve two coplanar polygons. Positive numbers are closer towards the + * camera. + * + * Nested DepthOffsetAttrib values accumulate; that is, a DepthOffsetAttrib + * with a value of 1 beneath another DepthOffsetAttrib with a value of 2 + * presents a net offset of 3. (A DepthOffsetAttrib will not, however, + * combine with any other DepthOffsetAttribs with a lower override parameter.) + * The net value should probably not exceed 16 or drop below 0 for maximum + * portability. + * + * Also, and only tangentially related, the DepthOffsetAttrib can be used to + * constrain the Z output value to a subset of the usual [0, 1] range (or + * reversing its direction) by specifying a new min_value and max_value. + */ class EXPCL_PANDA_PGRAPH DepthOffsetAttrib : public RenderAttrib { private: INLINE DepthOffsetAttrib(int offset, PN_stdfloat min_value, PN_stdfloat max_value); @@ -98,7 +89,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -123,4 +114,3 @@ private: #include "depthOffsetAttrib.I" #endif - diff --git a/panda/src/pgraph/depthTestAttrib.I b/panda/src/pgraph/depthTestAttrib.I index 86db02a5a3..9b0504609f 100644 --- a/panda/src/pgraph/depthTestAttrib.I +++ b/panda/src/pgraph/depthTestAttrib.I @@ -1,35 +1,28 @@ -// Filename: depthTestAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthTestAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::Constructor -// Access: Private -// Description: Use DepthTestAttrib::make() to construct a new -// DepthTestAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use DepthTestAttrib::make() to construct a new DepthTestAttrib object. + */ INLINE DepthTestAttrib:: DepthTestAttrib(DepthTestAttrib::PandaCompareFunc mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::get_mode -// Access: Published -// Description: Returns the depth write mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth write mode. + */ INLINE DepthTestAttrib::PandaCompareFunc DepthTestAttrib:: get_mode() const { return _mode; diff --git a/panda/src/pgraph/depthTestAttrib.cxx b/panda/src/pgraph/depthTestAttrib.cxx index f1cb49a429..b75f63b436 100644 --- a/panda/src/pgraph/depthTestAttrib.cxx +++ b/panda/src/pgraph/depthTestAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: depthTestAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthTestAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "depthTestAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,55 +22,45 @@ TypeHandle DepthTestAttrib::_type_handle; int DepthTestAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::make -// Access: Published, Static -// Description: Constructs a new DepthTestAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new DepthTestAttrib object. + */ CPT(RenderAttrib) DepthTestAttrib:: make(DepthTestAttrib::PandaCompareFunc mode) { DepthTestAttrib *attrib = new DepthTestAttrib(mode); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) DepthTestAttrib:: make_default() { return return_new(new DepthTestAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DepthTestAttrib:: output(ostream &out) const { out << get_type() << ":"; output_comparefunc(out,_mode); } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived DepthTestAttrib -// types to return a unique number indicating whether -// this DepthTestAttrib is equivalent to the other one. -// -// This should return 0 if the two DepthTestAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two DepthTestAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived DepthTestAttrib types to return a + * unique number indicating whether this DepthTestAttrib is equivalent to the + * other one. + * + * This should return 0 if the two DepthTestAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two DepthTestAttrib objects whose get_type() + * functions return the same. + */ int DepthTestAttrib:: compare_to_impl(const RenderAttrib *other) const { const DepthTestAttrib *ta = (const DepthTestAttrib *)other; @@ -79,16 +68,12 @@ compare_to_impl(const RenderAttrib *other) const { return (int)_mode - (int)ta->_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t DepthTestAttrib:: get_hash_impl() const { size_t hash = 0; @@ -96,23 +81,18 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// DepthTestAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type DepthTestAttrib. + */ void DepthTestAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DepthTestAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -120,14 +100,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type DepthTestAttrib is encountered -// in the Bam file. It should create the DepthTestAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type DepthTestAttrib is encountered in the Bam file. It should create the + * DepthTestAttrib and extract its information from the file. + */ TypedWritable *DepthTestAttrib:: make_from_bam(const FactoryParams ¶ms) { DepthTestAttrib *attrib = new DepthTestAttrib; @@ -140,13 +117,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: DepthTestAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new DepthTestAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new DepthTestAttrib. + */ void DepthTestAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/depthTestAttrib.h b/panda/src/pgraph/depthTestAttrib.h index 373fd48723..66eb9fb135 100644 --- a/panda/src/pgraph/depthTestAttrib.h +++ b/panda/src/pgraph/depthTestAttrib.h @@ -1,16 +1,15 @@ -// Filename: depthTestAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthTestAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef DEPTHTESTATTRIB_H #define DEPTHTESTATTRIB_H @@ -21,10 +20,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : DepthTestAttrib -// Description : Enables or disables writing to the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables writing to the depth buffer. + */ class EXPCL_PANDA_PGRAPH DepthTestAttrib : public RenderAttrib { private: INLINE DepthTestAttrib(PandaCompareFunc mode = M_less); @@ -60,7 +58,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -84,4 +82,3 @@ private: #include "depthTestAttrib.I" #endif - diff --git a/panda/src/pgraph/depthWriteAttrib.I b/panda/src/pgraph/depthWriteAttrib.I index 3e8e17b2d3..7a07cfa865 100644 --- a/panda/src/pgraph/depthWriteAttrib.I +++ b/panda/src/pgraph/depthWriteAttrib.I @@ -1,35 +1,28 @@ -// Filename: depthWriteAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthWriteAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::Constructor -// Access: Private -// Description: Use DepthWriteAttrib::make() to construct a new -// DepthWriteAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use DepthWriteAttrib::make() to construct a new DepthWriteAttrib object. + */ INLINE DepthWriteAttrib:: DepthWriteAttrib(DepthWriteAttrib::Mode mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::get_mode -// Access: Published -// Description: Returns the depth write mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth write mode. + */ INLINE DepthWriteAttrib::Mode DepthWriteAttrib:: get_mode() const { return _mode; diff --git a/panda/src/pgraph/depthWriteAttrib.cxx b/panda/src/pgraph/depthWriteAttrib.cxx index db0d724a54..eef6264d47 100644 --- a/panda/src/pgraph/depthWriteAttrib.cxx +++ b/panda/src/pgraph/depthWriteAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: depthWriteAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthWriteAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "depthWriteAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,34 +22,27 @@ TypeHandle DepthWriteAttrib::_type_handle; int DepthWriteAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::make -// Access: Published, Static -// Description: Constructs a new DepthWriteAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new DepthWriteAttrib object. + */ CPT(RenderAttrib) DepthWriteAttrib:: make(DepthWriteAttrib::Mode mode) { DepthWriteAttrib *attrib = new DepthWriteAttrib(mode); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) DepthWriteAttrib:: make_default() { return return_new(new DepthWriteAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DepthWriteAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -64,21 +56,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived DepthWriteAttrib -// types to return a unique number indicating whether -// this DepthWriteAttrib is equivalent to the other one. -// -// This should return 0 if the two DepthWriteAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two DepthWriteAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived DepthWriteAttrib types to return a + * unique number indicating whether this DepthWriteAttrib is equivalent to the + * other one. + * + * This should return 0 if the two DepthWriteAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two DepthWriteAttrib objects whose get_type() + * functions return the same. + */ int DepthWriteAttrib:: compare_to_impl(const RenderAttrib *other) const { const DepthWriteAttrib *ta = (const DepthWriteAttrib *)other; @@ -86,16 +75,12 @@ compare_to_impl(const RenderAttrib *other) const { return (int)_mode - (int)ta->_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t DepthWriteAttrib:: get_hash_impl() const { size_t hash = 0; @@ -103,23 +88,18 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// DepthWriteAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type DepthWriteAttrib. + */ void DepthWriteAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DepthWriteAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -127,14 +107,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type DepthWriteAttrib is encountered -// in the Bam file. It should create the DepthWriteAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type DepthWriteAttrib is encountered in the Bam file. It should create the + * DepthWriteAttrib and extract its information from the file. + */ TypedWritable *DepthWriteAttrib:: make_from_bam(const FactoryParams ¶ms) { DepthWriteAttrib *attrib = new DepthWriteAttrib; @@ -147,13 +124,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: DepthWriteAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new DepthWriteAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new DepthWriteAttrib. + */ void DepthWriteAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/depthWriteAttrib.h b/panda/src/pgraph/depthWriteAttrib.h index 9b6af606a5..7efdf4a70f 100644 --- a/panda/src/pgraph/depthWriteAttrib.h +++ b/panda/src/pgraph/depthWriteAttrib.h @@ -1,16 +1,15 @@ -// Filename: depthWriteAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file depthWriteAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef DEPTHWRITEATTRIB_H #define DEPTHWRITEATTRIB_H @@ -21,10 +20,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : DepthWriteAttrib -// Description : Enables or disables writing to the depth buffer. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables writing to the depth buffer. + */ class EXPCL_PANDA_PGRAPH DepthWriteAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -66,7 +64,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -90,4 +88,3 @@ private: #include "depthWriteAttrib.I" #endif - diff --git a/panda/src/pgraph/findApproxLevelEntry.I b/panda/src/pgraph/findApproxLevelEntry.I index e0bc921f4a..6404f93be4 100644 --- a/panda/src/pgraph/findApproxLevelEntry.I +++ b/panda/src/pgraph/findApproxLevelEntry.I @@ -1,23 +1,19 @@ -// Filename: findApproxLevelEntry.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxLevelEntry.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FindApproxLevelEntry:: FindApproxLevelEntry(const WorkingNodePath &node_path, FindApproxPath &approx_path) : _node_path(node_path), @@ -28,12 +24,10 @@ FindApproxLevelEntry(const WorkingNodePath &node_path, FindApproxPath &approx_pa nassertv(_node_path.is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::Constructor -// Access: Public -// Description: This constructor is used to construct the next entry -// based on a child node of the previous entry's node. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is used to construct the next entry based on a child node + * of the previous entry's node. + */ INLINE FindApproxLevelEntry:: FindApproxLevelEntry(const FindApproxLevelEntry &parent, PandaNode *child_node, int i, @@ -47,11 +41,9 @@ FindApproxLevelEntry(const FindApproxLevelEntry &parent, nassertv(_node_path.is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FindApproxLevelEntry:: FindApproxLevelEntry(const FindApproxLevelEntry ©) : _node_path(copy._node_path), @@ -62,11 +54,9 @@ FindApproxLevelEntry(const FindApproxLevelEntry ©) : nassertv(_node_path.is_valid()); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FindApproxLevelEntry:: operator = (const FindApproxLevelEntry ©) { _node_path = copy._node_path; @@ -76,24 +66,19 @@ operator = (const FindApproxLevelEntry ©) { } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::next_is_stashed -// Access: Public -// Description: Returns true if the next node matched by this entry -// must be a stashed node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the next node matched by this entry must be a stashed node, + * false otherwise. + */ INLINE bool FindApproxLevelEntry:: next_is_stashed(int increment) const { return _approx_path.matches_stashed(_i + increment); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::is_solution -// Access: Public -// Description: Returns true if this entry represents a solution to -// the search; i.e. all the components of the path have -// been successfully matched. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this entry represents a solution to the search; i.e. all + * the components of the path have been successfully matched. + */ INLINE bool FindApproxLevelEntry:: is_solution(int increment) const { return (_i + increment >= _approx_path.get_num_components()); diff --git a/panda/src/pgraph/findApproxLevelEntry.cxx b/panda/src/pgraph/findApproxLevelEntry.cxx index 3c3cb2b5b7..2b5679e271 100644 --- a/panda/src/pgraph/findApproxLevelEntry.cxx +++ b/panda/src/pgraph/findApproxLevelEntry.cxx @@ -1,16 +1,15 @@ -// Filename: findApproxLevelEntry.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxLevelEntry.cxx + * @author drose + * @date 2002-03-13 + */ #include "findApproxLevelEntry.h" #include "nodePathCollection.h" @@ -19,12 +18,9 @@ TypeHandle FindApproxLevelEntry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::output -// Access: Public -// Description: Formats the entry for meaningful output. For -// debugging only. -//////////////////////////////////////////////////////////////////// +/** + * Formats the entry for meaningful output. For debugging only. + */ void FindApproxLevelEntry:: output(ostream &out) const { out << "(" << _node_path << "):"; @@ -37,12 +33,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::write_level -// Access: Public -// Description: Writes the entire level (a linked list of entries -// beginning at this entry). For debugging only. -//////////////////////////////////////////////////////////////////// +/** + * Writes the entire level (a linked list of entries beginning at this entry). + * For debugging only. + */ void FindApproxLevelEntry:: write_level(ostream &out, int indent_level) const { for (const FindApproxLevelEntry *entry = this; @@ -53,27 +47,22 @@ write_level(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::consider_node -// Access: Public -// Description: Considers the node represented by the entry for -// matching the find path. If a solution is found, it -// is added to result; if the children of this node -// should be considered, the appropriate entries are -// added to next_level. -// -// The return value is true if result now contains -// max_matches solutions, or false if we should keep -// looking. -//////////////////////////////////////////////////////////////////// +/** + * Considers the node represented by the entry for matching the find path. If + * a solution is found, it is added to result; if the children of this node + * should be considered, the appropriate entries are added to next_level. + * + * The return value is true if result now contains max_matches solutions, or + * false if we should keep looking. + */ bool FindApproxLevelEntry:: consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, int max_matches, int increment) const { if (is_solution(increment)) { - // If the entry represents a solution, save it and we're done with - // the entry. + // If the entry represents a solution, save it and we're done with the + // entry. result.add_path(_node_path.get_node_path()); - if (max_matches > 0 && result.get_num_paths() >= max_matches) { + if (max_matches > 0 && result.get_num_paths() >= max_matches) { return true; } @@ -83,19 +72,19 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, // If the entry is not itself a solution, consider its children. if (_approx_path.is_component_match_many(_i + increment)) { - // Match any number, zero or more, levels of nodes. This is the - // tricky case that requires this whole nutty breadth-first thing. + // Match any number, zero or more, levels of nodes. This is the tricky + // case that requires this whole nutty breadth-first thing. - // This means we must reconsider our own entry with the next path - // entry, before we consider the next entry--this supports - // matching zero levels of nodes. + // This means we must reconsider our own entry with the next path entry, + // before we consider the next entry--this supports matching zero levels + // of nodes. - // We used to make a temporary copy of our own record, and then - // increment _i on that copy, but we can't do that nowadays - // because the WorkingNodePath object stores a pointer to each - // previous generation, which means we can't use any temporary - // FindApproxLevelEntry objects. Instead, we pass around the - // increment parameter, which increments _i on the fly. + // We used to make a temporary copy of our own record, and then increment + // _i on that copy, but we can't do that nowadays because the + // WorkingNodePath object stores a pointer to each previous generation, + // which means we can't use any temporary FindApproxLevelEntry objects. + // Instead, we pass around the increment parameter, which increments _i on + // the fly. if (consider_node(result, next_level, max_matches, increment + 1)) { return true; @@ -113,7 +102,7 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, int num_children = children.get_num_children(); for (int i = 0; i < num_children; i++) { PandaNode *child_node = children.get_child(i); - + consider_next_step(child_node, next_level, increment); } } @@ -123,7 +112,7 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, int num_stashed = this_node->get_num_stashed(); for (int i = 0; i < num_stashed; i++) { PandaNode *stashed_node = this_node->get_stashed(i); - + consider_next_step(stashed_node, next_level, increment); } } @@ -131,35 +120,29 @@ consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, return false; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxLevelEntry::consider_next_step -// Access: Public -// Description: Compares the indicated child node (which is assumed -// to be a child of _node_path) with the next component -// of the path. If it matches, generates whatever -// additional entries are appropriate and stores them in -// next_level. -//////////////////////////////////////////////////////////////////// +/** + * Compares the indicated child node (which is assumed to be a child of + * _node_path) with the next component of the path. If it matches, generates + * whatever additional entries are appropriate and stores them in next_level. + */ void FindApproxLevelEntry:: -consider_next_step(PandaNode *child_node, FindApproxLevelEntry *&next_level, +consider_next_step(PandaNode *child_node, FindApproxLevelEntry *&next_level, int increment) const { nassertv(child_node != _node_path.node()); if (!_approx_path.return_hidden() && child_node->is_overall_hidden()) { - // If the approx path does not allow us to return hidden nodes, - // and this node has indeed been completely hidden, then stop - // here. + // If the approx path does not allow us to return hidden nodes, and this + // node has indeed been completely hidden, then stop here. return; } nassertv(_i + increment < _approx_path.get_num_components()); if (_approx_path.is_component_match_many(_i + increment)) { - // Match any number, zero or more, levels of nodes. This is the - // tricky case that requires this whole nutty breadth-first thing. + // Match any number, zero or more, levels of nodes. This is the tricky + // case that requires this whole nutty breadth-first thing. - // And now we just add the next entry without incrementing its - // path entry. + // And now we just add the next entry without incrementing its path entry. next_level = new FindApproxLevelEntry (*this, child_node, _i + increment, next_level); diff --git a/panda/src/pgraph/findApproxLevelEntry.h b/panda/src/pgraph/findApproxLevelEntry.h index 8e076fffa7..48c8663869 100644 --- a/panda/src/pgraph/findApproxLevelEntry.h +++ b/panda/src/pgraph/findApproxLevelEntry.h @@ -1,16 +1,15 @@ -// Filename: findApproxLevelEntry.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxLevelEntry.h + * @author drose + * @date 2002-03-13 + */ #ifndef FINDAPPROXLEVELENTRY_H #define FINDAPPROXLEVELENTRY_H @@ -22,13 +21,11 @@ class NodePathCollection; -//////////////////////////////////////////////////////////////////// -// Class : FindApproxLevelEntry -// Description : This class is local to this package only; it doesn't -// get exported. It represents a single node under -// consideration for matching at a single point in the -// breadth-first search. -//////////////////////////////////////////////////////////////////// +/** + * This class is local to this package only; it doesn't get exported. It + * represents a single node under consideration for matching at a single point + * in the breadth-first search. + */ class FindApproxLevelEntry { public: INLINE FindApproxLevelEntry(const WorkingNodePath &node_path, @@ -42,10 +39,10 @@ public: INLINE bool next_is_stashed(int increment) const; - bool consider_node(NodePathCollection &result, + bool consider_node(NodePathCollection &result, FindApproxLevelEntry *&next_level, int max_matches, int increment) const; - void consider_next_step(PandaNode *child_node, + void consider_next_step(PandaNode *child_node, FindApproxLevelEntry *&next_level, int increment) const; INLINE bool is_solution(int increment) const; @@ -53,14 +50,13 @@ public: void output(ostream &out) const; void write_level(ostream &out, int indent_level) const; - // _node_path represents the most recent node that we have - // previously accepted as being a partial solution. + // _node_path represents the most recent node that we have previously + // accepted as being a partial solution. WorkingNodePath _node_path; - // _i represents the next component in the approx_path that must be - // matched against all of the children of _node_path, above. If _i - // refers to the end of the approx_path, then _node_path is a - // solution. + // _i represents the next component in the approx_path that must be matched + // against all of the children of _node_path, above. If _i refers to the + // end of the approx_path, then _node_path is a solution. int _i; FindApproxPath &_approx_path; FindApproxLevelEntry *_next; diff --git a/panda/src/pgraph/findApproxPath.I b/panda/src/pgraph/findApproxPath.I index 5c75515d26..616766a3ea 100644 --- a/panda/src/pgraph/findApproxPath.I +++ b/panda/src/pgraph/findApproxPath.I @@ -1,23 +1,19 @@ -// Filename: findApproxPath.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxPath.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FindApproxPath:: FindApproxPath() { _return_hidden = true; @@ -25,46 +21,38 @@ FindApproxPath() { _case_insensitive = false; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::get_num_components -// Access: Public -// Description: Returns the number of components in the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of components in the path. + */ INLINE int FindApproxPath:: get_num_components() const { return _path.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::is_component_match_many -// Access: Public -// Description: Returns true if the nth component is of type -// match_many, which will require special handling. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth component is of type match_many, which will require + * special handling. + */ INLINE bool FindApproxPath:: is_component_match_many(int index) const { nassertr(index >= 0 && index < (int)_path.size(), false); return (_path[index]._type == CT_match_many); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::matches_component -// Access: Public -// Description: Returns true if the nth component of the path matches -// the indicated node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth component of the path matches the indicated node, + * false otherwise. + */ INLINE bool FindApproxPath:: matches_component(int index, PandaNode *node) const { nassertr(index >= 0 && index < (int)_path.size(), false); return (_path[index].matches(node)); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::matches_stashed -// Access: Public -// Description: Returns true if the nth component of the path matches -// a stashed node only, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth component of the path matches a stashed node only, + * false otherwise. + */ INLINE bool FindApproxPath:: matches_stashed(int index) const { if (index >= 0 && index < (int)_path.size()) { @@ -74,45 +62,36 @@ matches_stashed(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::return_hidden -// Access: Public -// Description: Returns true if this path allows returning of hidden -// nodes, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this path allows returning of hidden nodes, false + * otherwise. + */ INLINE bool FindApproxPath:: return_hidden() const { return _return_hidden; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::return_stashed -// Access: Public -// Description: Returns true if this path allows returning of stashed -// nodes, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this path allows returning of stashed nodes, false + * otherwise. + */ INLINE bool FindApproxPath:: return_stashed() const { return _return_stashed; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::case_insensitive -// Access: Public -// Description: Returns true if the search is case-insensitive, false -// if it is case-sensitive. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the search is case-insensitive, false if it is case- + * sensitive. + */ INLINE bool FindApproxPath:: case_insensitive() const { return _case_insensitive; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::output_component -// Access: Public -// Description: Formats the nth component of the path to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Formats the nth component of the path to the indicated output stream. + */ INLINE void FindApproxPath:: output_component(ostream &out, int index) const { nassertv(index >= 0 && index < (int)_path.size()); diff --git a/panda/src/pgraph/findApproxPath.cxx b/panda/src/pgraph/findApproxPath.cxx index b83cca7140..0b8d035580 100644 --- a/panda/src/pgraph/findApproxPath.cxx +++ b/panda/src/pgraph/findApproxPath.cxx @@ -1,16 +1,15 @@ -// Filename: findApproxPath.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxPath.cxx + * @author drose + * @date 2002-03-13 + */ #include "findApproxPath.h" #include "config_pgraph.h" @@ -19,12 +18,9 @@ #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::Component::matches -// Access: Public -// Description: Returns true if the indicated node matches this -// component, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated node matches this component, false otherwise. + */ bool FindApproxPath::Component:: matches(PandaNode *node) const { string node_name; @@ -47,8 +43,8 @@ matches(PandaNode *node) const { return (node->is_exact_type(_type_handle)); case CT_match_inexact_type: - // Match the node's type inexactly: it's a match if the node - // is the type, or is derived from the type. + // Match the node's type inexactly: it's a match if the node is the type, + // or is derived from the type. return (node->is_of_type(_type_handle)); case CT_match_tag: @@ -77,11 +73,9 @@ matches(PandaNode *node) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::Component::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FindApproxPath::Component:: output(ostream &out) const { out << _type; @@ -111,14 +105,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_string -// Access: Public -// Description: Adds a sequence of components separated by slashes, -// followed optionally by a semicolon and a sequence of -// control flags, to the path sequence. Returns true if -// successful, false if the string contained an error. -//////////////////////////////////////////////////////////////////// +/** + * Adds a sequence of components separated by slashes, followed optionally by + * a semicolon and a sequence of control flags, to the path sequence. Returns + * true if successful, false if the string contained an error. + */ bool FindApproxPath:: add_string(const string &str_path) { // First, chop the string up by slashes into its components. @@ -134,10 +125,10 @@ add_string(const string &str_path) { size_t semicolon = str_path.rfind(';'); - // We want to find the *last* semicolon at start or later, if there - // happens to be more than one. rfind will find the rightmost - // semicolon in the entire string; if this is less than start, there - // is no semicolon right of start. + // We want to find the *last* semicolon at start or later, if there happens + // to be more than one. rfind will find the rightmost semicolon in the + // entire string; if this is less than start, there is no semicolon right of + // start. if (semicolon < start) { semicolon = string::npos; } @@ -161,14 +152,11 @@ add_string(const string &str_path) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_flags -// Access: Public -// Description: Adds a sequence of control flags. This will be a -// sequence of letters preceded by either '+' or '-', -// with no intervening punctuation. Returns true if -// successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Adds a sequence of control flags. This will be a sequence of letters + * preceded by either '+' or '-', with no intervening punctuation. Returns + * true if successful, false otherwise. + */ bool FindApproxPath:: add_flags(const string &str_flags) { string::const_iterator pi = str_flags.begin(); @@ -220,14 +208,11 @@ add_flags(const string &str_flags) { } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_component -// Access: Public -// Description: Adds a single component to the path sequence, defined -// by a string as might appear between slashes in the -// path string. Returns true if successful, false if -// the string component was in some way invalid. -//////////////////////////////////////////////////////////////////// +/** + * Adds a single component to the path sequence, defined by a string as might + * appear between slashes in the path string. Returns true if successful, + * false if the string component was in some way invalid. + */ bool FindApproxPath:: add_component(string str_component) { int flags = 0; @@ -293,12 +278,9 @@ add_component(string str_component) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_name -// Access: Public -// Description: Adds a component that must match the name of a node -// exactly. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that must match the name of a node exactly. + */ void FindApproxPath:: add_match_name(const string &name, int flags) { Component comp; @@ -308,13 +290,10 @@ add_match_name(const string &name, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_name_glob -// Access: Public -// Description: Adds a component that must match the name of a node -// using standard shell globbing rules, with wildcard -// characters accepted. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that must match the name of a node using standard shell + * globbing rules, with wildcard characters accepted. + */ void FindApproxPath:: add_match_name_glob(const string &name, int flags) { Component comp; @@ -324,20 +303,18 @@ add_match_name_glob(const string &name, int flags) { comp._glob.set_case_sensitive(!_case_insensitive); comp._flags = flags; if (!comp._glob.has_glob_characters()) { - // The glob pattern contains no special characters; make it a - // literal match for efficiency. + // The glob pattern contains no special characters; make it a literal + // match for efficiency. add_match_name(name, flags); } else { _path.push_back(comp); } } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_exact_type -// Access: Public -// Description: Adds a component that must match the type of a node -// exactly, with no derived types matching. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that must match the type of a node exactly, with no + * derived types matching. + */ void FindApproxPath:: add_match_exact_type(TypeHandle type, int flags) { Component comp; @@ -347,12 +324,10 @@ add_match_exact_type(TypeHandle type, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_inexact_type -// Access: Public -// Description: Adds a component that must match the type of a node -// or be a base class of the node's type. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that must match the type of a node or be a base class of + * the node's type. + */ void FindApproxPath:: add_match_inexact_type(TypeHandle type, int flags) { Component comp; @@ -362,13 +337,10 @@ add_match_inexact_type(TypeHandle type, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_tag -// Access: Public -// Description: Adds a component that will match a node that has a -// tag with the indicated key, no matter what the value -// is. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that will match a node that has a tag with the indicated + * key, no matter what the value is. + */ void FindApproxPath:: add_match_tag(const string &name, int flags) { Component comp; @@ -378,14 +350,11 @@ add_match_tag(const string &name, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_tag_value -// Access: Public -// Description: Adds a component that will match a node that has a -// tag with the indicated key. The value may be "*" to -// match any value, or a particular glob pattern to -// match only those nodes with the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that will match a node that has a tag with the indicated + * key. The value may be "*" to match any value, or a particular glob pattern + * to match only those nodes with the indicated value. + */ void FindApproxPath:: add_match_tag_value(const string &name, const string &value, int flags) { Component comp; @@ -396,12 +365,9 @@ add_match_tag_value(const string &name, const string &value, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_one -// Access: Public -// Description: Adds a component that will match any node (but not a -// chain of many nodes). -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that will match any node (but not a chain of many nodes). + */ void FindApproxPath:: add_match_one(int flags) { Component comp; @@ -410,12 +376,9 @@ add_match_one(int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_many -// Access: Public -// Description: Adds a component that will match a chain of zero or -// more consecutive nodes. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that will match a chain of zero or more consecutive nodes. + */ void FindApproxPath:: add_match_many(int flags) { Component comp; @@ -424,12 +387,9 @@ add_match_many(int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::add_match_pointer -// Access: Public -// Description: Adds a component that must match a particular node -// exactly, by pointer. -//////////////////////////////////////////////////////////////////// +/** + * Adds a component that must match a particular node exactly, by pointer. + */ void FindApproxPath:: add_match_pointer(PandaNode *pointer, int flags) { Component comp; @@ -439,11 +399,9 @@ add_match_pointer(PandaNode *pointer, int flags) { _path.push_back(comp); } -//////////////////////////////////////////////////////////////////// -// Function: FindApproxPath::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FindApproxPath:: output(ostream &out) const { out << "("; @@ -495,4 +453,3 @@ operator << (ostream &out, FindApproxPath::ComponentType type) { return out << "**invalid**"; }; - diff --git a/panda/src/pgraph/findApproxPath.h b/panda/src/pgraph/findApproxPath.h index 4b502e55e8..7b0d138d94 100644 --- a/panda/src/pgraph/findApproxPath.h +++ b/panda/src/pgraph/findApproxPath.h @@ -1,16 +1,15 @@ -// Filename: findApproxPath.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file findApproxPath.h + * @author drose + * @date 2002-03-13 + */ #ifndef FINDAPPROXPATH_H #define FINDAPPROXPATH_H @@ -24,13 +23,11 @@ class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : FindApproxPath -// Description : This class is local to this package only; it doesn't -// get exported. It chops a string path, as supplied to -// find_up() or find_down(), and breaks it up into its -// component pieces. -//////////////////////////////////////////////////////////////////// +/** + * This class is local to this package only; it doesn't get exported. It + * chops a string path, as supplied to find_up() or find_down(), and breaks it + * up into its component pieces. + */ class FindApproxPath { public: INLINE FindApproxPath(); @@ -63,8 +60,8 @@ public: INLINE void output_component(ostream &out, int index) const; #if !defined(WIN32_VC) && !defined(WIN64_VC) -// Visual C++ won't let us define the ostream operator functions for -// these guys if they're private--even though we declare them friends. +// Visual C++ won't let us define the ostream operator functions for these +// guys if they're private--even though we declare them friends. private: #endif enum ComponentType { diff --git a/panda/src/pgraph/fog.I b/panda/src/pgraph/fog.I index e04488f81e..dd2b75cbdf 100644 --- a/panda/src/pgraph/fog.I +++ b/panda/src/pgraph/fog.I @@ -1,64 +1,52 @@ -// Filename: fog.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fog.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Fog::Mode Fog:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_mode -// Access: Published -// Description: Specifies the computation that is used to determine -// the fog effect. If this is M_linear, then the fog -// will range from linearly from the onset point to the -// opaque point (or for the distances specified in -// set_linear_range), and the fog object should be -// parented into the scene graph, or to the camera. -// -// If this is anything else, the onset point and opaque -// point are not used, and the fog effect is based on -// the value specified to set_exp_density(), and it -// doesn't matter to which node the fog object is -// parented, or if it is parented anywhere at all. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the computation that is used to determine the fog effect. If + * this is M_linear, then the fog will range from linearly from the onset + * point to the opaque point (or for the distances specified in + * set_linear_range), and the fog object should be parented into the scene + * graph, or to the camera. + * + * If this is anything else, the onset point and opaque point are not used, + * and the fog effect is based on the value specified to set_exp_density(), + * and it doesn't matter to which node the fog object is parented, or if it is + * parented anywhere at all. + */ INLINE void Fog:: set_mode(Mode mode) { _mode = mode; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_color -// Access: Published -// Description: Returns the color of the fog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of the fog. + */ INLINE const LColor &Fog:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_color -// Access: Published -// Description: Sets the color of the fog. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the fog. + */ INLINE void Fog:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { _color[0] = r; @@ -66,31 +54,25 @@ set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { _color[2] = b; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_color -// Access: Published -// Description: Sets the color of the fog. The alpha component is -// not used. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the fog. The alpha component is not used. + */ INLINE void Fog:: set_color(const LColor &color) { _color = color; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_range -// Access: Published -// Description: Specifies the effects of the fog in linear distance -// units. This is only used if the mode is M_linear. -// -// This specifies a fog that begins at distance onset -// units from the origin, and becomes totally opaque at -// distance opaque units from the origin, along the -// forward axis (usually Y). -// -// This function also implicitly sets the mode the -// M_linear, if it is not already set. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the effects of the fog in linear distance units. This is only + * used if the mode is M_linear. + * + * This specifies a fog that begins at distance onset units from the origin, + * and becomes totally opaque at distance opaque units from the origin, along + * the forward axis (usually Y). + * + * This function also implicitly sets the mode the M_linear, if it is not + * already set. + */ INLINE void Fog:: set_linear_range(PN_stdfloat onset, PN_stdfloat opaque) { LVector3 forward = LVector3::forward(); @@ -101,115 +83,90 @@ set_linear_range(PN_stdfloat onset, PN_stdfloat opaque) { _mode = M_linear; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_linear_onset_point -// Access: Published -// Description: Returns the point in space at which the fog begins. -// This is only used if the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space at which the fog begins. This is only used if + * the mode is M_linear. + */ INLINE const LPoint3 &Fog:: get_linear_onset_point() const { return _linear_onset_point; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_onset_point -// Access: Published -// Description: Specifies the point in space at which the fog begins. -// This is only used if the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point in space at which the fog begins. This is only used if + * the mode is M_linear. + */ INLINE void Fog:: set_linear_onset_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _linear_onset_point.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_onset_point -// Access: Published -// Description: Specifies the point in space at which the fog begins. -// This is only used if the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point in space at which the fog begins. This is only used if + * the mode is M_linear. + */ INLINE void Fog:: set_linear_onset_point(const LPoint3 &linear_onset_point) { _linear_onset_point = linear_onset_point; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_linear_opaque_point -// Access: Published -// Description: Returns the point in space at which the fog -// completely obscures geometry. This is only used if -// the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space at which the fog completely obscures geometry. + * This is only used if the mode is M_linear. + */ INLINE const LPoint3 &Fog:: get_linear_opaque_point() const { return _linear_opaque_point; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_opaque_point -// Access: Published -// Description: Specifies the point in space at which the fog -// completely obscures geometry. This is only used if -// the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point in space at which the fog completely obscures geometry. + * This is only used if the mode is M_linear. + */ INLINE void Fog:: set_linear_opaque_point(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _linear_opaque_point.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_opaque_point -// Access: Published -// Description: Specifies the point in space at which the fog -// completely obscures geometry. This is only used if -// the mode is M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the point in space at which the fog completely obscures geometry. + * This is only used if the mode is M_linear. + */ INLINE void Fog:: set_linear_opaque_point(const LPoint3 &linear_opaque_point) { _linear_opaque_point = linear_opaque_point; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_linear_fallback -// Access: Published -// Description: Fog effects are traditionally defined in -// camera-relative space, but the Panda Fog node has a -// special mode in which it can define a linear fog -// effect in an arbitrary coordinate space. -// -// This is done by specifying 3-d onset and opaque -// points, and parenting the Fog object somewhere within -// the scene graph. In this mode, the fog will be -// rendered as if it extended along the vector from the -// onset point to the opaque point, in 3-d space. -// -// However, the underlying fog effect supported by -// hardware is generally only one-dimensional, and must -// be rendered based on linear distance from the camera -// plane. Thus, this in-the-world effect is most -// effective when the fog vector from onset point to -// opaque point is most nearly parallel to the camera's -// eye vector. -// -// As the angle between the fog vector and the eye -// vector increases, the accuracy of the effect -// diminishes, up to a complete breakdown of the effect -// at a 90 degree angle. -// -// This function exists to define the workaround to this -// problem. The linear fallback parameters given here -// specify how the fog should be rendered when the -// parameters are exceeded in this way. -// -// The angle parameter is the minimum angle, in degrees, -// of the fog vector to the eye vector, at which the -// fallback effect should be employed. The onset and -// opaque parameters specify the camera-relative onset -// and opaque distances to pass to the rendering -// hardware when employing the fallback effect. This -// supercedes the 3-d onset point and opaque points. -//////////////////////////////////////////////////////////////////// +/** + * Fog effects are traditionally defined in camera-relative space, but the + * Panda Fog node has a special mode in which it can define a linear fog + * effect in an arbitrary coordinate space. + * + * This is done by specifying 3-d onset and opaque points, and parenting the + * Fog object somewhere within the scene graph. In this mode, the fog will be + * rendered as if it extended along the vector from the onset point to the + * opaque point, in 3-d space. + * + * However, the underlying fog effect supported by hardware is generally only + * one-dimensional, and must be rendered based on linear distance from the + * camera plane. Thus, this in-the-world effect is most effective when the + * fog vector from onset point to opaque point is most nearly parallel to the + * camera's eye vector. + * + * As the angle between the fog vector and the eye vector increases, the + * accuracy of the effect diminishes, up to a complete breakdown of the effect + * at a 90 degree angle. + * + * This function exists to define the workaround to this problem. The linear + * fallback parameters given here specify how the fog should be rendered when + * the parameters are exceeded in this way. + * + * The angle parameter is the minimum angle, in degrees, of the fog vector to + * the eye vector, at which the fallback effect should be employed. The onset + * and opaque parameters specify the camera-relative onset and opaque + * distances to pass to the rendering hardware when employing the fallback + * effect. This supercedes the 3-d onset point and opaque points. + */ INLINE void Fog:: set_linear_fallback(PN_stdfloat angle, PN_stdfloat onset, PN_stdfloat opaque) { _linear_fallback_cosa = ccos(deg_2_rad(angle)); @@ -217,28 +174,22 @@ set_linear_fallback(PN_stdfloat angle, PN_stdfloat onset, PN_stdfloat opaque) { _linear_fallback_opaque = opaque; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_exp_density -// Access: Published -// Description: Returns the density of the fog for exponential -// calculations. This is only used if the mode is not -// M_linear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the density of the fog for exponential calculations. This is only + * used if the mode is not M_linear. + */ INLINE PN_stdfloat Fog:: get_exp_density() const { return _exp_density; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::set_exp_density -// Access: Published -// Description: Sets the density of the fog for exponential -// calculations. This is only used if the mode is not -// M_linear. -// -// If the mode is currently set to M_linear, this -// function implicitly sets it to M_exponential. -//////////////////////////////////////////////////////////////////// +/** + * Sets the density of the fog for exponential calculations. This is only + * used if the mode is not M_linear. + * + * If the mode is currently set to M_linear, this function implicitly sets it + * to M_exponential. + */ INLINE void Fog:: set_exp_density(PN_stdfloat exp_density) { nassertv((exp_density >= 0.0) && (exp_density <= 1.0)); diff --git a/panda/src/pgraph/fog.cxx b/panda/src/pgraph/fog.cxx index 23fe6264eb..06c831f337 100644 --- a/panda/src/pgraph/fog.cxx +++ b/panda/src/pgraph/fog.cxx @@ -1,16 +1,15 @@ -// Filename: fog.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fog.cxx + * @author drose + * @date 2002-03-14 + */ #include "pandabase.h" @@ -44,14 +43,12 @@ operator << (ostream &out, Fog::Mode mode) { return out << "**invalid**(" << (int)mode << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Fog:: -Fog(const string &name) : - PandaNode(name) +Fog(const string &name) : + PandaNode(name) { _mode = M_linear; _color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -65,11 +62,9 @@ Fog(const string &name) : _transformed_opaque = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Fog:: Fog(const Fog ©) : PandaNode(copy) @@ -86,46 +81,36 @@ Fog(const Fog ©) : _transformed_opaque = copy._transformed_opaque; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Fog:: ~Fog() { } -//////////////////////////////////////////////////////////////////// -// Function: Fog::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *Fog:: make_copy() const { return new Fog(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Fog::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void Fog:: xform(const LMatrix4 &mat) { _linear_onset_point = _linear_onset_point * mat; _linear_opaque_point = _linear_opaque_point * mat; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Fog:: output(ostream &out) const { out << "fog: " << _mode; @@ -142,28 +127,23 @@ output(ostream &out) const { }; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::adjust_to_camera -// Access: Public -// Description: This function is intended to be called by the cull -// traverser to compute the appropriate camera-relative -// onset and opaque distances, based on the fog node's -// position within the scene graph (if linear fog is in -// effect). -//////////////////////////////////////////////////////////////////// +/** + * This function is intended to be called by the cull traverser to compute the + * appropriate camera-relative onset and opaque distances, based on the fog + * node's position within the scene graph (if linear fog is in effect). + */ void Fog:: adjust_to_camera(const TransformState *camera_transform) { LVector3 forward = LVector3::forward(); LPoint3 onset_point, opaque_point; if (get_num_parents() != 0) { - // Linear fog is relative to the fog's net transform in the scene - // graph. + // Linear fog is relative to the fog's net transform in the scene graph. NodePath this_np(this); - CPT(TransformState) rel_transform = + CPT(TransformState) rel_transform = camera_transform->invert_compose(this_np.get_net_transform()); - + const LMatrix4 &mat = rel_transform->get_mat(); // How far out of whack are we? @@ -171,8 +151,7 @@ adjust_to_camera(const TransformState *camera_transform) { fog_vector.normalize(); PN_stdfloat cosa = fog_vector.dot(forward); if (cabs(cosa) < _linear_fallback_cosa) { - // The fog vector is too far from the eye vector; use the - // fallback mode. + // The fog vector is too far from the eye vector; use the fallback mode. _transformed_onset = _linear_fallback_onset; _transformed_opaque = _linear_fallback_opaque; @@ -188,34 +167,27 @@ adjust_to_camera(const TransformState *camera_transform) { } } -//////////////////////////////////////////////////////////////////// -// Function: Fog::get_linear_range -// Access: Public -// Description: Retrieves the current onset and offset ranges. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current onset and offset ranges. + */ void Fog:: get_linear_range(PN_stdfloat &onset, PN_stdfloat &opaque) { onset = _transformed_onset; opaque = _transformed_opaque; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Fog. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Fog. + */ void Fog:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Fog::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Fog:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -230,14 +202,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_linear_fallback_opaque); } -//////////////////////////////////////////////////////////////////// -// Function: Fog::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Fog is encountered -// in the Bam file. It should create the Fog -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Fog is encountered in the Bam file. It should create the Fog and + * extract its information from the file. + */ TypedWritable *Fog:: make_from_bam(const FactoryParams ¶ms) { Fog *node = new Fog(""); @@ -250,13 +219,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: Fog::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Fog. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Fog. + */ void Fog:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/fog.h b/panda/src/pgraph/fog.h index 5e27b32aed..7a7831eb9e 100644 --- a/panda/src/pgraph/fog.h +++ b/panda/src/pgraph/fog.h @@ -1,16 +1,15 @@ -// Filename: fog.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fog.h + * @author drose + * @date 2002-03-14 + */ #ifndef FOG_H #define FOG_H @@ -24,25 +23,21 @@ class TransformState; -//////////////////////////////////////////////////////////////////// -// Class : Fog -// Description : Specifies how atmospheric fog effects are applied to -// geometry. The Fog object is now a PandaNode, which -// means it can be used similarly to a Light to define -// effects relative to a particular coordinate system -// within the scene graph. -// -// In exponential mode, the fog effects are always -// camera-relative, and it does not matter where the Fog -// node is parented. However, in linear mode, the onset -// and opaque distances are defined as offsets along the -// local forward axis (e.g. the Y axis). This allows -// the fog effect to be localized to a particular region -// in space, rather than always camera-relative. If the -// fog object is not parented to any node, it is used to -// generate traditonal camera-relative fog, as if it -// were parented to the camera. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how atmospheric fog effects are applied to geometry. The Fog + * object is now a PandaNode, which means it can be used similarly to a Light + * to define effects relative to a particular coordinate system within the + * scene graph. + * + * In exponential mode, the fog effects are always camera-relative, and it + * does not matter where the Fog node is parented. However, in linear mode, + * the onset and opaque distances are defined as offsets along the local + * forward axis (e.g. the Y axis). This allows the fog effect to be + * localized to a particular region in space, rather than always camera- + * relative. If the fog object is not parented to any node, it is used to + * generate traditonal camera-relative fog, as if it were parented to the + * camera. + */ class EXPCL_PANDA_PGRAPH Fog : public PandaNode { PUBLISHED: Fog(const string &name); @@ -116,7 +111,7 @@ protected: PN_stdfloat _linear_fallback_cosa; PN_stdfloat _linear_fallback_onset, _linear_fallback_opaque; - + PN_stdfloat _transformed_onset, _transformed_opaque; public: diff --git a/panda/src/pgraph/fogAttrib.I b/panda/src/pgraph/fogAttrib.I index 26ebeb45d5..e19a72a376 100644 --- a/panda/src/pgraph/fogAttrib.I +++ b/panda/src/pgraph/fogAttrib.I @@ -1,46 +1,36 @@ -// Filename: fogAttrib.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fogAttrib.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::Constructor -// Access: Private -// Description: Use FogAttrib::make() to construct a new FogAttrib -// object. -//////////////////////////////////////////////////////////////////// +/** + * Use FogAttrib::make() to construct a new FogAttrib object. + */ INLINE FogAttrib:: FogAttrib() { } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::is_off -// Access: Published -// Description: Returns true if the FogAttrib is an 'off' FogAttrib, -// indicating that it should disable fog. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the FogAttrib is an 'off' FogAttrib, indicating that it + * should disable fog. + */ INLINE bool FogAttrib:: is_off() const { return _fog == (const Fog *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::get_fog -// Access: Published -// Description: If the FogAttrib is not an 'off' FogAttrib, -// returns the fog that is associated. Otherwise, -// return NULL. -//////////////////////////////////////////////////////////////////// +/** + * If the FogAttrib is not an 'off' FogAttrib, returns the fog that is + * associated. Otherwise, return NULL. + */ INLINE Fog *FogAttrib:: get_fog() const { return _fog; diff --git a/panda/src/pgraph/fogAttrib.cxx b/panda/src/pgraph/fogAttrib.cxx index c830277651..0606298fa4 100644 --- a/panda/src/pgraph/fogAttrib.cxx +++ b/panda/src/pgraph/fogAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: fogAttrib.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fogAttrib.cxx + * @author drose + * @date 2002-03-14 + */ #include "fogAttrib.h" #include "graphicsStateGuardianBase.h" @@ -22,12 +21,10 @@ TypeHandle FogAttrib::_type_handle; int FogAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::make -// Access: Published, Static -// Description: Constructs a new FogAttrib object suitable for -// rendering the indicated fog onto geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new FogAttrib object suitable for rendering the indicated fog + * onto geometry. + */ CPT(RenderAttrib) FogAttrib:: make(Fog *fog) { FogAttrib *attrib = new FogAttrib; @@ -35,35 +32,27 @@ make(Fog *fog) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) FogAttrib:: make_default() { return return_new(new FogAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::make_off -// Access: Published, Static -// Description: Constructs a new FogAttrib object suitable for -// rendering unfogd geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new FogAttrib object suitable for rendering unfogd geometry. + */ CPT(RenderAttrib) FogAttrib:: make_off() { FogAttrib *attrib = new FogAttrib; return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FogAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -74,44 +63,36 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived FogAttrib -// types to return a unique number indicating whether -// this FogAttrib is equivalent to the other one. -// -// This should return 0 if the two FogAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two FogAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived FogAttrib types to return a unique + * number indicating whether this FogAttrib is equivalent to the other one. + * + * This should return 0 if the two FogAttrib objects are equivalent, a number + * less than zero if this one should be sorted before the other one, and a + * number greater than zero otherwise. + * + * This will only be called with two FogAttrib objects whose get_type() + * functions return the same. + */ int FogAttrib:: compare_to_impl(const RenderAttrib *other) const { const FogAttrib *ta = (const FogAttrib *)other; - // Comparing pointers by subtraction is problematic. Instead of - // doing this, we'll just depend on the built-in != and < operators - // for comparing pointers. + // Comparing pointers by subtraction is problematic. Instead of doing this, + // we'll just depend on the built-in != and < operators for comparing + // pointers. if (_fog != ta->_fog) { return _fog < ta->_fog ? -1 : 1; } return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t FogAttrib:: get_hash_impl() const { size_t hash = 0; @@ -119,33 +100,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) FogAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// FogAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type FogAttrib. + */ void FogAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void FogAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -153,13 +127,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _fog); } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int FogAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -172,14 +143,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type FogAttrib is encountered -// in the Bam file. It should create the FogAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type FogAttrib is encountered in the Bam file. It should create the + * FogAttrib and extract its information from the file. + */ TypedWritable *FogAttrib:: make_from_bam(const FactoryParams ¶ms) { FogAttrib *attrib = new FogAttrib; @@ -192,13 +160,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: FogAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new FogAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new FogAttrib. + */ void FogAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/fogAttrib.h b/panda/src/pgraph/fogAttrib.h index 0b93e24126..1762fb09ee 100644 --- a/panda/src/pgraph/fogAttrib.h +++ b/panda/src/pgraph/fogAttrib.h @@ -1,16 +1,15 @@ -// Filename: fogAttrib.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fogAttrib.h + * @author drose + * @date 2002-03-14 + */ #ifndef FOGATTRIB_H #define FOGATTRIB_H @@ -20,10 +19,9 @@ #include "renderAttrib.h" #include "fog.h" -//////////////////////////////////////////////////////////////////// -// Class : FogAttrib -// Description : Applies a Fog to the geometry at and below this node. -//////////////////////////////////////////////////////////////////// +/** + * Applies a Fog to the geometry at and below this node. + */ class EXPCL_PANDA_PGRAPH FogAttrib : public RenderAttrib { private: INLINE FogAttrib(); @@ -63,7 +61,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -87,4 +85,3 @@ private: #include "fogAttrib.I" #endif - diff --git a/panda/src/pgraph/geomDrawCallbackData.I b/panda/src/pgraph/geomDrawCallbackData.I index 7ae9233058..55dd6325bd 100644 --- a/panda/src/pgraph/geomDrawCallbackData.I +++ b/panda/src/pgraph/geomDrawCallbackData.I @@ -1,25 +1,21 @@ -// Filename: geomDrawCallbackData.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomDrawCallbackData.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomDrawCallbackData:: -GeomDrawCallbackData(CullableObject *obj, GraphicsStateGuardianBase *gsg, +GeomDrawCallbackData(CullableObject *obj, GraphicsStateGuardianBase *gsg, bool force) : _obj(obj), _gsg(gsg), @@ -28,64 +24,49 @@ GeomDrawCallbackData(CullableObject *obj, GraphicsStateGuardianBase *gsg, { } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::get_object -// Access: Published -// Description: Returns a pointer to the particular object that is -// being drawn. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular object that is being drawn. + */ INLINE CullableObject *GeomDrawCallbackData:: get_object() const { return _obj; } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::get_gsg -// Access: Published -// Description: Returns a pointer to the current GSG. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the current GSG. + */ INLINE GraphicsStateGuardianBase *GeomDrawCallbackData:: get_gsg() const { return _gsg; } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::get_force -// Access: Published -// Description: Returns true if any required data should be forced -// into memory if necessary to render the object, or -// false if the object should be omitted if some of the -// data is not available (at least until the data -// becomes available later). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any required data should be forced into memory if necessary + * to render the object, or false if the object should be omitted if some of + * the data is not available (at least until the data becomes available + * later). + */ INLINE bool GeomDrawCallbackData:: get_force() const { return _force; } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::set_lost_state -// Access: Published -// Description: Sets the lost_state flag. If this is true, the -// callback does not have to be quite so careful to -// clean up after itself; Panda will assume that the -// graphics state is in an unknown state after the -// callback has finished, and will issue all the -// necessary calls to restore it. If this is false, -// Panda will assume the callback will leave the -// graphics state exactly as it came in, and won't -// bother to try to restore it. The default is true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the lost_state flag. If this is true, the callback does not have to + * be quite so careful to clean up after itself; Panda will assume that the + * graphics state is in an unknown state after the callback has finished, and + * will issue all the necessary calls to restore it. If this is false, Panda + * will assume the callback will leave the graphics state exactly as it came + * in, and won't bother to try to restore it. The default is true. + */ INLINE void GeomDrawCallbackData:: set_lost_state(bool lost_state) { _lost_state = lost_state; } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::get_lost_state -// Access: Published -// Description: Returns the lost_state flag. See set_lost_state(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the lost_state flag. See set_lost_state(). + */ INLINE bool GeomDrawCallbackData:: get_lost_state() const { return _lost_state; diff --git a/panda/src/pgraph/geomDrawCallbackData.cxx b/panda/src/pgraph/geomDrawCallbackData.cxx index 40078988c3..283fe9711c 100644 --- a/panda/src/pgraph/geomDrawCallbackData.cxx +++ b/panda/src/pgraph/geomDrawCallbackData.cxx @@ -1,16 +1,15 @@ -// Filename: geomDrawCallbackData.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomDrawCallbackData.cxx + * @author drose + * @date 2009-03-13 + */ #include "geomDrawCallbackData.h" #include "cullableObject.h" @@ -18,30 +17,25 @@ TypeHandle GeomDrawCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomDrawCallbackData:: output(ostream &out) const { - out << get_type() << "(" << (void *)_obj << ", " << (void *)_gsg + out << get_type() << "(" << (void *)_obj << ", " << (void *)_gsg << ", " << _force << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomDrawCallbackData::upcall -// Access: Published, Virtual -// Description: You should make this call during the callback if you -// want to continue the normal rendering function that -// would have been done in the absence of a callback. -// -// Specifically, this method will add the Geoms in this -// node to the list of renderable objects for drawing. -// If this callback was made on a CallbackNode, it -// doesn't actually do anything, since only a GeomNode -// holds geoms. -//////////////////////////////////////////////////////////////////// +/** + * You should make this call during the callback if you want to continue the + * normal rendering function that would have been done in the absence of a + * callback. + * + * Specifically, this method will add the Geoms in this node to the list of + * renderable objects for drawing. If this callback was made on a + * CallbackNode, it doesn't actually do anything, since only a GeomNode holds + * geoms. + */ void GeomDrawCallbackData:: upcall() { // Go ahead and draw the object, if we have one. @@ -51,7 +45,7 @@ upcall() { _gsg->clear_state_and_transform(); } - _obj->_geom->draw(_gsg, _obj->_munger, _obj->_munged_data, _force, + _obj->_geom->draw(_gsg, _obj->_munger, _obj->_munged_data, _force, Thread::get_current_thread()); } } diff --git a/panda/src/pgraph/geomDrawCallbackData.h b/panda/src/pgraph/geomDrawCallbackData.h index ecce6b8476..7e45f9eef2 100644 --- a/panda/src/pgraph/geomDrawCallbackData.h +++ b/panda/src/pgraph/geomDrawCallbackData.h @@ -1,16 +1,15 @@ -// Filename: geomDrawCallbackData.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomDrawCallbackData.h + * @author drose + * @date 2009-03-13 + */ #ifndef GEOMDRAWCALLBACKDATA_H #define GEOMDRAWCALLBACKDATA_H @@ -22,15 +21,13 @@ class CullableObject; class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : GeomDrawCallbackData -// Description : This specialization on CallbackData is passed when -// the callback is initiated from deep within the draw -// traversal, for a particular Geom. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on CallbackData is passed when the callback is + * initiated from deep within the draw traversal, for a particular Geom. + */ class EXPCL_PANDA_PGRAPH GeomDrawCallbackData : public CallbackData { public: - INLINE GeomDrawCallbackData(CullableObject *obj, + INLINE GeomDrawCallbackData(CullableObject *obj, GraphicsStateGuardianBase *gsg, bool force); PUBLISHED: diff --git a/panda/src/pgraph/geomNode.I b/panda/src/pgraph/geomNode.I index cd9a72084b..431d5e1d2e 100644 --- a/panda/src/pgraph/geomNode.I +++ b/panda/src/pgraph/geomNode.I @@ -1,47 +1,37 @@ -// Filename: geomNode.I -// Created by: drose (23Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomNode.I + * @author drose + * @date 2002-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::set_preserved -// Access: Published -// Description: Sets the "preserved" flag. When this is true, the -// GeomNode will be left untouched by any flatten -// operations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "preserved" flag. When this is true, the GeomNode will be left + * untouched by any flatten operations. + */ INLINE void GeomNode:: set_preserved(bool value) { _preserved = value; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_preserved -// Access: Published -// Description: Returns the "preserved" flag. When this is true, the -// GeomNode will be left untouched by any flatten -// operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "preserved" flag. When this is true, the GeomNode will be left + * untouched by any flatten operations. + */ INLINE bool GeomNode:: get_preserved() const { return _preserved; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_num_geoms -// Access: Published -// Description: Returns the number of geoms in the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of geoms in the node. + */ INLINE int GeomNode:: get_num_geoms() const { CDReader cdata(_cycler); @@ -49,14 +39,11 @@ get_num_geoms() const { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_geom -// Access: Published -// Description: Returns the nth geom of the node. This object should -// not be modified, since the same object might be -// shared between multiple different GeomNodes, but see -// modify_geom(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth geom of the node. This object should not be modified, + * since the same object might be shared between multiple different GeomNodes, + * but see modify_geom(). + */ INLINE CPT(Geom) GeomNode:: get_geom(int n) const { CDReader cdata(_cycler); @@ -65,24 +52,18 @@ get_geom(int n) const { return (*geoms)[n]._geom.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::modify_geom -// Access: Published -// Description: Returns the nth geom of the node, suitable for -// modifying it. If the nth Geom has multiple reference -// counts to it, reassigns it to an identical copy -// first, and returns the new copy--this provides a -// "copy on write" that ensures that the Geom that is -// returned is unique to this GeomNode and is not shared -// with any other GeomNodes. -// -// Note that if this method is called in a downstream -// stage (for instance, during cull or draw), then it -// will propagate the new list of Geoms upstream all the -// way to pipeline stage 0, which may step on changes -// that were made independently in pipeline stage 0. -// Use with caution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth geom of the node, suitable for modifying it. If the nth + * Geom has multiple reference counts to it, reassigns it to an identical copy + * first, and returns the new copy--this provides a "copy on write" that + * ensures that the Geom that is returned is unique to this GeomNode and is + * not shared with any other GeomNodes. + * + * Note that if this method is called in a downstream stage (for instance, + * during cull or draw), then it will propagate the new list of Geoms upstream + * all the way to pipeline stage 0, which may step on changes that were made + * independently in pipeline stage 0. Use with caution. + */ INLINE PT(Geom) GeomNode:: modify_geom(int n) { CDWriter cdata(_cycler, true); @@ -92,16 +73,12 @@ modify_geom(int n) { return (*geoms)[n]._geom.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_geom_state -// Access: Published -// Description: Returns the RenderState associated with the nth geom -// of the node. This is just the RenderState directly -// associated with the Geom; the actual state in which -// the Geom is rendered will also be affected by -// RenderStates that appear on the scene graph in nodes -// above this GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderState associated with the nth geom of the node. This is + * just the RenderState directly associated with the Geom; the actual state in + * which the Geom is rendered will also be affected by RenderStates that + * appear on the scene graph in nodes above this GeomNode. + */ INLINE const RenderState *GeomNode:: get_geom_state(int n) const { CDReader cdata(_cycler); @@ -110,23 +87,17 @@ get_geom_state(int n) const { return (*geoms)[n]._state; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::set_geom_state -// Access: Published -// Description: Changes the RenderState associated with the nth geom -// of the node. This is just the RenderState directly -// associated with the Geom; the actual state in which -// the Geom is rendered will also be affected by -// RenderStates that appear on the scene graph in nodes -// above this GeomNode. -// -// Note that if this method is called in a downstream -// stage (for instance, during cull or draw), then it -// will propagate the new list of Geoms upstream all the -// way to pipeline stage 0, which may step on changes -// that were made independently in pipeline stage 0. -// Use with caution. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RenderState associated with the nth geom of the node. This is + * just the RenderState directly associated with the Geom; the actual state in + * which the Geom is rendered will also be affected by RenderStates that + * appear on the scene graph in nodes above this GeomNode. + * + * Note that if this method is called in a downstream stage (for instance, + * during cull or draw), then it will propagate the new list of Geoms upstream + * all the way to pipeline stage 0, which may step on changes that were made + * independently in pipeline stage 0. Use with caution. + */ INLINE void GeomNode:: set_geom_state(int n, const RenderState *state) { CDWriter cdata(_cycler, true); @@ -135,11 +106,9 @@ set_geom_state(int n, const RenderState *state) { (*geoms)[n]._state = state; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::remove_geom -// Access: Published -// Description: Removes the nth geom from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth geom from the node. + */ INLINE void GeomNode:: remove_geom(int n) { CDWriter cdata(_cycler); @@ -150,11 +119,9 @@ remove_geom(int n) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::remove_all_geoms -// Access: Published -// Description: Removes all the geoms from the node at once. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the geoms from the node at once. + */ INLINE void GeomNode:: remove_all_geoms() { CDWriter cdata(_cycler); @@ -162,36 +129,29 @@ remove_all_geoms() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_default_collide_mask -// Access: Published, Static -// Description: Returns the default into_collide_mask assigned to new -// GeomNodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default into_collide_mask assigned to new GeomNodes. + */ INLINE CollideMask GeomNode:: get_default_collide_mask() { return default_geom_node_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::count_name -// Access: Private -// Description: Increments the count for the indicated InternalName. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count for the indicated InternalName. + */ INLINE void GeomNode:: count_name(GeomNode::NameCount &name_count, const InternalName *name) { - pair result = + pair result = name_count.insert(NameCount::value_type(name, 1)); if (!result.second) { (*result.first).second++; } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_name_count -// Access: Private -// Description: Returns the count for the indicated InternalName. -//////////////////////////////////////////////////////////////////// +/** + * Returns the count for the indicated InternalName. + */ INLINE int GeomNode:: get_name_count(const GeomNode::NameCount &name_count, const InternalName *name) { NameCount::const_iterator ni; @@ -202,34 +162,26 @@ get_name_count(const GeomNode::NameCount &name_count, const InternalName *name) return 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_geoms -// Access: Published -// Description: Returns an object that can be used to walk through -// the list of geoms of the node. When you intend to -// visit multiple geoms, using this is slightly -// faster than calling get_geom() directly on the -// GeomNode, since this object avoids reopening the -// PipelineCycler each time. -// -// This object also protects you from self-modifying -// loops (e.g. adding or removing geoms during -// traversal), since a virtual copy of the geoms is -// made ahead of time. The virtual copy is fast--it is -// a form of copy-on-write, so the list is not actually -// copied unless it is modified during the traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of geoms of the + * node. When you intend to visit multiple geoms, using this is slightly + * faster than calling get_geom() directly on the GeomNode, since this object + * avoids reopening the PipelineCycler each time. + * + * This object also protects you from self-modifying loops (e.g. adding or + * removing geoms during traversal), since a virtual copy of the geoms is made + * ahead of time. The virtual copy is fast--it is a form of copy-on-write, so + * the list is not actually copied unless it is modified during the traversal. + */ INLINE GeomNode::Geoms GeomNode:: get_geoms(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return Geoms(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::GeomEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::GeomEntry:: GeomEntry(Geom *geom, const RenderState *state) : _geom(geom), @@ -237,130 +189,104 @@ GeomEntry(Geom *geom, const RenderState *state) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::CData:: CData() : _geoms(new GeomNode::GeomList) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::get_geoms -// Access: Public -// Description: Returns a read-only pointer to the _geoms list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the _geoms list. + */ INLINE CPT(GeomNode::GeomList) GeomNode::CData:: get_geoms() const { return _geoms.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::modify_geoms -// Access: Public -// Description: Returns a modifiable, unique pointer to the _geoms -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable, unique pointer to the _geoms list. + */ INLINE PT(GeomNode::GeomList) GeomNode::CData:: modify_geoms() { return _geoms.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::set_geoms -// Access: Public -// Description: Replaces the _geoms list with a new list. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the _geoms list with a new list. + */ INLINE void GeomNode::CData:: set_geoms(GeomNode::GeomList *geoms) { _geoms = geoms; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::Geoms:: Geoms() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::Geoms:: Geoms(const GeomNode::CData *cdata) : _geoms(cdata->get_geoms()) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::Geoms:: Geoms(const GeomNode::Geoms ©) : _geoms(copy._geoms) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomNode::Geoms:: operator = (const GeomNode::Geoms ©) { _geoms = copy._geoms; } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomNode::Geoms:: Geoms(GeomNode::Geoms &&from) NOEXCEPT : _geoms(move(from._geoms)) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void GeomNode::Geoms:: operator = (GeomNode::Geoms &&from) NOEXCEPT { _geoms = move(from._geoms); } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::get_num_geoms -// Access: Public -// Description: Returns the number of geoms of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of geoms of the node. + */ INLINE int GeomNode::Geoms:: get_num_geoms() const { nassertr(!_geoms.is_null(), 0); return _geoms->size(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::get_geom -// Access: Public -// Description: Returns the nth geom of the node. This object should -// not be modified, since the same object might be -// shared between multiple different GeomNodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth geom of the node. This object should not be modified, + * since the same object might be shared between multiple different GeomNodes. + */ INLINE CPT(Geom) GeomNode::Geoms:: get_geom(int n) const { nassertr(!_geoms.is_null(), NULL); @@ -368,16 +294,12 @@ get_geom(int n) const { return (*_geoms)[n]._geom.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Geoms::get_geom_state -// Access: Public -// Description: Returns the RenderState associated with the nth geom -// of the node. This is just the RenderState directly -// associated with the Geom; the actual state in which -// the Geom is rendered will also be affected by -// RenderStates that appear on the scene graph in nodes -// above this GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderState associated with the nth geom of the node. This is + * just the RenderState directly associated with the Geom; the actual state in + * which the Geom is rendered will also be affected by RenderStates that + * appear on the scene graph in nodes above this GeomNode. + */ INLINE const RenderState *GeomNode::Geoms:: get_geom_state(int n) const { nassertr(!_geoms.is_null(), NULL); diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index aa9b70a852..bfbd24f04f 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -1,16 +1,15 @@ -// Filename: geomNode.cxx -// Created by: drose (23eb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomNode.cxx + * @author drose + * @date 2002-02-23 + */ #include "geomNode.h" #include "geom.h" @@ -46,11 +45,9 @@ bool allow_flatten_color = ConfigVariableBool TypeHandle GeomNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomNode:: GeomNode(const string &name) : PandaNode(name) @@ -61,11 +58,9 @@ GeomNode(const string &name) : set_into_collide_mask(get_default_collide_mask()); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomNode:: GeomNode(const GeomNode ©) : PandaNode(copy), @@ -74,41 +69,32 @@ GeomNode(const GeomNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomNode:: ~GeomNode() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *GeomNode:: make_copy() const { return new GeomNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::apply_attribs_to_vertices -// Access: Public, Virtual -// Description: Applies whatever attributes are specified in the -// AccumulatedAttribs object (and by the attrib_types -// bitmask) to the vertices on this node, if -// appropriate. If this node uses geom arrays like a -// GeomNode, the supplied GeomTransformer may be used to -// unify shared arrays across multiple different nodes. -// -// This is a generalization of xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ void GeomNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -130,10 +116,10 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomList::iterator gi; PT(GeomList) geoms = cdata->modify_geoms(); - // Iterate based on the number of geoms, not using STL iterators. - // This allows us to append to the list in the code below (which - // we might do when doublesiding polys) without visiting those new - // nodes during the traversal. + // Iterate based on the number of geoms, not using STL iterators. This + // allows us to append to the list in the code below (which we might do + // when doublesiding polys) without visiting those new nodes during the + // traversal. size_t num_geoms = geoms->size(); for (size_t i = 0; i < num_geoms; ++i) { GeomEntry *entry = &(*geoms)[i]; @@ -172,9 +158,8 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if (csa->get_scale() != LVecBase4(1.0f, 1.0f, 1.0f, 1.0f)) { - // Now, if we have an "off" or "flat" color attribute, we - // simply modify the color attribute, and leave the - // vertices alone. + // Now, if we have an "off" or "flat" color attribute, we simply + // modify the color attribute, and leave the vertices alone. CPT(RenderAttrib) ra = entry->_state->get_attrib_def(ColorAttrib::get_class_slot()); CPT(ColorAttrib) ca = DCAST(ColorAttrib, ra); if(allow_flatten_color) { @@ -184,13 +169,13 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } else { if (ca->get_color_type() == ColorAttrib::T_off) { entry->_state = entry->_state->set_attrib(ColorAttrib::make_vertex()); - // ColorAttrib::T_off means the color scale becomes - // the new color. + // ColorAttrib::T_off means the color scale becomes the new + // color. entry->_state = entry->_state->set_attrib(ColorAttrib::make_flat(csa->get_scale())); } else if (ca->get_color_type() == ColorAttrib::T_flat) { - // ColorAttrib::T_flat means the color scale modulates - // the specified color to produce a new color. + // ColorAttrib::T_flat means the color scale modulates the + // specified color to produce a new color. const LColor &c1 = ca->get_color(); const LVecBase4 &c2 = csa->get_scale(); LColor color(c1[0] * c2[0], c1[1] * c2[1], @@ -198,8 +183,8 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, entry->_state = entry->_state->set_attrib(ColorAttrib::make_flat(color)); } else { - // Otherwise, we have vertex color, and we just scale - // it normally. + // Otherwise, we have vertex color, and we just scale it + // normally. if (transformer.transform_colors(new_geom, csa->get_scale())) { any_changed = true; } @@ -212,12 +197,11 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, if ((attrib_types & SceneGraphReducer::TT_tex_matrix) != 0) { if (geom_attribs._tex_matrix != (const RenderAttrib *)NULL) { - // Determine which texture coordinate names are used more than - // once. This assumes we have discovered all of the textures - // that are in effect on the GeomNode; this may not be true if - // there is a texture that has been applied at a node above - // that from which we started the flatten operation, but - // caveat programmer. + // Determine which texture coordinate names are used more than once. + // This assumes we have discovered all of the textures that are in + // effect on the GeomNode; this may not be true if there is a + // texture that has been applied at a node above that from which we + // started the flatten operation, but caveat programmer. NameCount name_count; if (geom_attribs._texture != (RenderAttrib *)NULL) { @@ -240,13 +224,13 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, TextureStage *stage = tma->get_stage(i); InternalName *name = stage->get_texcoord_name(); if (get_name_count(name_count, name) > 1) { - // We can't transform these texcoords, since the name is - // used by more than one active stage. + // We can't transform these texcoords, since the name is used by + // more than one active stage. new_tma = DCAST(TexMatrixAttrib, new_tma->add_stage(stage, tma->get_transform(stage))); } else { - // It's safe to transform these texcoords; the name is - // used by no more than one active stage. + // It's safe to transform these texcoords; the name is used by + // no more than one active stage. if (transformer.transform_texcoords(new_geom, name, name, tma->get_mat(stage))) { any_changed = true; } @@ -263,9 +247,9 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, entry->_state = geom_attribs._other->compose(entry->_state); } - // We handle cull_face last, since that might involve - // duplicating the geom, and we'd also like to duplicate all of - // the changes we may have applied in the above. + // We handle cull_face last, since that might involve duplicating the + // geom, and we'd also like to duplicate all of the changes we may have + // applied in the above. if ((attrib_types & SceneGraphReducer::TT_cull_face) != 0) { if (geom_attribs._cull_face != (const RenderAttrib *)NULL) { @@ -277,16 +261,15 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, { bool has_normals = (new_geom->get_vertex_data()->has_column(InternalName::get_normal())); if (has_normals) { - // If the geometry has normals, we have to duplicate - // it to reverse the normals on the duplicate copy. + // If the geometry has normals, we have to duplicate it to + // reverse the normals on the duplicate copy. PT(Geom) dup_geom = new_geom->reverse(); transformer.reverse_normals(dup_geom); geoms->push_back(GeomEntry(dup_geom, entry->_state)); - // The above push_back() operation might have - // invalidated our old pointer into the list, so we - // reassign it now. + // The above push_back() operation might have invalidated our + // old pointer into the list, so we reassign it now. entry = &(*geoms)[i]; } else { @@ -325,18 +308,14 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, transformer.register_vertices(this, false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -// -// For a GeomNode, this does the right thing, but it is -// better to use a GeomTransformer instead, since it -// will share the new arrays properly between different -// GeomNodes. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + * + * For a GeomNode, this does the right thing, but it is better to use a + * GeomTransformer instead, since it will share the new arrays properly + * between different GeomNodes. + */ void GeomNode:: xform(const LMatrix4 &mat) { GeomTransformer transformer; @@ -344,16 +323,12 @@ xform(const LMatrix4 &mat) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of PandaNode by duplicating -// instances (by calling dupe_for_flatten()), false -// otherwise (for instance, a Camera cannot be safely -// flattened, because the Camera pointer itself is -// meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * PandaNode by duplicating instances (by calling dupe_for_flatten()), false + * otherwise (for instance, a Camera cannot be safely flattened, because the + * Camera pointer itself is meaningful). + */ bool GeomNode:: safe_to_flatten() const { if (_preserved) { @@ -363,16 +338,12 @@ safe_to_flatten() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool GeomNode:: safe_to_combine() const { if (_preserved) { @@ -382,14 +353,10 @@ safe_to_combine() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::r_prepare_scene -// Access: Protected, Virtual -// Description: The recursive implementation of prepare_scene(). -// Don't call this directly; call -// PandaNode::prepare_scene() or -// NodePath::prepare_scene() instead. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of prepare_scene(). Don't call this directly; + * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. + */ void GeomNode:: r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) { @@ -433,7 +400,7 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, int num_stages = ta->get_num_on_stages(); for (int i = 0; i < num_stages; ++i) { Texture *texture = ta->get_on_texture(ta->get_on_stage(i)); - //TODO: prepare the sampler states, if specified. + // TODO: prepare the sampler states, if specified. if (texture != (Texture *)NULL) { texture->prepare(prepared_objects); } @@ -449,8 +416,8 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, if (shader != (Shader *)NULL) { shader->prepare(prepared_objects); } - //TODO: prepare the shader inputs. - //TODO: Invoke the shader generator if enabled. + // TODO: prepare the shader inputs. TODO: Invoke the shader generator + // if enabled. } } @@ -458,21 +425,16 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::combine_with -// Access: Public, Virtual -// Description: Collapses this node with the other node, if possible, -// and returns a pointer to the combined node, or NULL -// if the two nodes cannot safely be combined. -// -// The return value may be this, other, or a new node -// altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two nodes and what the -// collapsed node should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this node with the other node, if possible, and returns a pointer + * to the combined node, or NULL if the two nodes cannot safely be combined. + * + * The return value may be this, other, or a new node altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two nodes + * and what the collapsed node should look like. + */ PandaNode *GeomNode:: combine_with(PandaNode *other) { if (is_exact_type(get_class_type()) && @@ -486,22 +448,17 @@ combine_with(PandaNode *other) { return PandaNode::combine_with(other); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::calc_tight_bounds -// Access: Public, Virtual -// Description: This is used to support -// NodePath::calc_tight_bounds(). It is not intended to -// be called directly, and it has nothing to do with the -// normal Panda bounding-volume computation. -// -// If the node contains any geometry, this updates -// min_point and max_point to enclose its bounding box. -// found_any is to be set true if the node has any -// geometry at all, or left alone if it has none. This -// method may be called over several nodes, so it may -// enter with min_point, max_point, and found_any -// already set. -//////////////////////////////////////////////////////////////////// +/** + * This is used to support NodePath::calc_tight_bounds(). It is not intended + * to be called directly, and it has nothing to do with the normal Panda + * bounding-volume computation. + * + * If the node contains any geometry, this updates min_point and max_point to + * enclose its bounding box. found_any is to be set true if the node has any + * geometry at all, or left alone if it has none. This method may be called + * over several nodes, so it may enter with min_point, max_point, and + * found_any already set. + */ CPT(TransformState) GeomNode:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { @@ -525,29 +482,22 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, return next_transform; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool GeomNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::add_for_draw -// Access: Public, Virtual -// Description: Adds the node's contents to the CullResult we are -// building up during the cull traversal, so that it -// will be drawn at render time. For most nodes other -// than GeomNodes, this is a do-nothing operation. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node's contents to the CullResult we are building up during the + * cull traversal, so that it will be drawn at render time. For most nodes + * other than GeomNodes, this is a do-nothing operation. + */ void GeomNode:: add_for_draw(CullTraverser *trav, CullTraverserData &data) { trav->_geom_nodes_pcollector.add_level(1); @@ -576,11 +526,10 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { continue; } - // Cull the Geom bounding volume against the view frustum - // and/or the cull planes. Don't bother unless we've got more - // than one Geom, since otherwise the bounding volume of the - // GeomNode is (probably) the same as that of the one Geom, - // and we've already culled against that. + // Cull the Geom bounding volume against the view frustum andor the cull + // planes. Don't bother unless we've got more than one Geom, since + // otherwise the bounding volume of the GeomNode is (probably) the same as + // that of the one Geom, and we've already culled against that. if (num_geoms > 1) { if (data._view_frustum != (GeometricBoundingVolume *)NULL) { // Cull the individual Geom against the view frustum. @@ -614,30 +563,24 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::get_legal_collide_mask -// Access: Published, Virtual -// Description: Returns the subset of CollideMask bits that may be -// set for this particular type of PandaNode. For most -// nodes, this is 0; it doesn't make sense to set a -// CollideMask for most kinds of nodes. -// -// For nodes that can be collided with, such as GeomNode -// and CollisionNode, this returns all bits on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of CollideMask bits that may be set for this particular + * type of PandaNode. For most nodes, this is 0; it doesn't make sense to set + * a CollideMask for most kinds of nodes. + * + * For nodes that can be collided with, such as GeomNode and CollisionNode, + * this returns all bits on. + */ CollideMask GeomNode:: get_legal_collide_mask() const { return CollideMask::all_on(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::add_geom -// Access: Published -// Description: Adds a new Geom to the node. The geom is given the -// indicated state (which may be -// RenderState::make_empty(), to completely inherit its -// state from the scene graph). -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Geom to the node. The geom is given the indicated state (which + * may be RenderState::make_empty(), to completely inherit its state from the + * scene graph). + */ void GeomNode:: add_geom(Geom *geom, const RenderState *state) { nassertv(geom != (Geom *)NULL); @@ -655,12 +598,10 @@ add_geom(Geom *geom, const RenderState *state) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::add_geoms_from -// Access: Published -// Description: Copies the Geoms (and their associated RenderStates) -// from the indicated GeomNode into this one. -//////////////////////////////////////////////////////////////////// +/** + * Copies the Geoms (and their associated RenderStates) from the indicated + * GeomNode into this one. + */ void GeomNode:: add_geoms_from(const GeomNode *other) { Thread *current_thread = Thread::get_current_thread(); @@ -682,19 +623,15 @@ add_geoms_from(const GeomNode *other) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::set_geom -// Access: Public -// Description: Replaces the nth Geom of the node with a new pointer. -// There must already be a Geom in this slot. -// -// Note that if this method is called in a downstream -// stage (for instance, during cull or draw), then it -// will propagate the new list of Geoms upstream all the -// way to pipeline stage 0, which may step on changes -// that were made independently in pipeline stage 0. -// Use with caution. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the nth Geom of the node with a new pointer. There must already + * be a Geom in this slot. + * + * Note that if this method is called in a downstream stage (for instance, + * during cull or draw), then it will propagate the new list of Geoms upstream + * all the way to pipeline stage 0, which may step on changes that were made + * independently in pipeline stage 0. Use with caution. + */ void GeomNode:: set_geom(int n, Geom *geom) { nassertv(geom != (Geom *)NULL); @@ -708,14 +645,11 @@ set_geom(int n, Geom *geom) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::check_valid -// Access: Published -// Description: Verifies that the each Geom within the GeomNode -// reference vertices that actually exist within its -// GeomVertexData. Returns true if the GeomNode appears -// to be valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the each Geom within the GeomNode reference vertices that + * actually exist within its GeomVertexData. Returns true if the GeomNode + * appears to be valid, false otherwise. + */ bool GeomNode:: check_valid() const { int num_geoms = get_num_geoms(); @@ -729,20 +663,16 @@ check_valid() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::decompose -// Access: Published -// Description: Calls decompose() on each Geom with the GeomNode. -// This decomposes higher-order primitive types, like -// triangle strips, into lower-order types like indexed -// triangles. Normally there is no reason to do this, -// but it can be useful as an early preprocessing step, -// to allow a later call to unify() to proceed more -// quickly. -// -// See also SceneGraphReducer::decompose(), which is the -// normal way this is called. -//////////////////////////////////////////////////////////////////// +/** + * Calls decompose() on each Geom with the GeomNode. This decomposes higher- + * order primitive types, like triangle strips, into lower-order types like + * indexed triangles. Normally there is no reason to do this, but it can be + * useful as an early preprocessing step, to allow a later call to unify() to + * proceed more quickly. + * + * See also SceneGraphReducer::decompose(), which is the normal way this is + * called. + */ void GeomNode:: decompose() { Thread *current_thread = Thread::get_current_thread(); @@ -761,30 +691,24 @@ decompose() { CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::unify -// Access: Published -// Description: Attempts to unify all of the Geoms contained within -// this node into a single Geom, or at least as few -// Geoms as possible. In turn, the individual -// GeomPrimitives contained within each resulting Geom -// are also unified. The goal is to reduce the number -// of GeomPrimitives within the node as far as possible. -// This may result in composite primitives, such as -// triangle strips and triangle fans, being decomposed -// into triangles. See also Geom::unify(). -// -// max_indices represents the maximum number of indices -// that will be put in any one GeomPrimitive. If -// preserve_order is true, then the primitives will not -// be reordered during the operation, even if this -// results in a suboptimal result. -// -// In order for this to be successful, the primitives -// must reference the same GeomVertexData, have the same -// fundamental primitive type, and have compatible shade -// models. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to unify all of the Geoms contained within this node into a single + * Geom, or at least as few Geoms as possible. In turn, the individual + * GeomPrimitives contained within each resulting Geom are also unified. The + * goal is to reduce the number of GeomPrimitives within the node as far as + * possible. This may result in composite primitives, such as triangle strips + * and triangle fans, being decomposed into triangles. See also + * Geom::unify(). + * + * max_indices represents the maximum number of indices that will be put in + * any one GeomPrimitive. If preserve_order is true, then the primitives will + * not be reordered during the operation, even if this results in a suboptimal + * result. + * + * In order for this to be successful, the primitives must reference the same + * GeomVertexData, have the same fundamental primitive type, and have + * compatible shade models. + */ void GeomNode:: unify(int max_indices, bool preserve_order) { bool any_changed = false; @@ -796,8 +720,8 @@ unify(int max_indices, bool preserve_order) { PT(GeomList) new_geoms = new GeomList; // Try to unify each Geom with each preceding Geom. This is an n^2 - // operation, but usually there are only a handful of Geoms to - // consider, so that's not a big deal. + // operation, but usually there are only a handful of Geoms to consider, + // so that's not a big deal. GeomList::const_iterator gi; CPT(GeomList) old_geoms = cdata->get_geoms(); for (gi = old_geoms->begin(); gi != old_geoms->end(); ++gi) { @@ -821,8 +745,8 @@ unify(int max_indices, bool preserve_order) { } if (preserve_order) { - // If we're insisting on preserving the order, we can only - // attempt to merge with the tail of the list. + // If we're insisting on preserving the order, we can only attempt + // to merge with the tail of the list. break; } } @@ -853,12 +777,9 @@ unify(int max_indices, bool preserve_order) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::write_geoms -// Access: Published -// Description: Writes a short description of all the Geoms in the -// node. -//////////////////////////////////////////////////////////////////// +/** + * Writes a short description of all the Geoms in the node. + */ void GeomNode:: write_geoms(ostream &out, int indent_level) const { CDReader cdata(_cycler); @@ -872,12 +793,9 @@ write_geoms(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::write_verbose -// Access: Published -// Description: Writes a detailed description of all the Geoms in the -// node. -//////////////////////////////////////////////////////////////////// +/** + * Writes a detailed description of all the Geoms in the node. + */ void GeomNode:: write_verbose(ostream &out, int indent_level) const { CDReader cdata(_cycler); @@ -893,17 +811,15 @@ write_verbose(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomNode:: output(ostream &out) const { - // Accumulate the total set of RenderAttrib types that are applied - // to any of our Geoms, so we can output them too. The result will - // be the list of attrib types that might be applied to some Geoms, - // but not necessarily to all Geoms. + // Accumulate the total set of RenderAttrib types that are applied to any of + // our Geoms, so we can output them too. The result will be the list of + // attrib types that might be applied to some Geoms, but not necessarily to + // all Geoms. CDReader cdata(_cycler); @@ -928,29 +844,23 @@ output(ostream &out) const { out << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::is_geom_node -// Access: Public, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from GeomNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(GeomNode::get_class_type()), since this -// test is so important to rendering. -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from GeomNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(GeomNode::get_class_type()), since this test is so important to + * rendering. + */ bool GeomNode:: is_geom_node() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::do_premunge -// Access: Public -// Description: Uses the indicated GSG to premunge the Geoms in this -// node to optimize them for eventual rendering. See -// SceneGraphReducer::premunge(). -//////////////////////////////////////////////////////////////////// +/** + * Uses the indicated GSG to premunge the Geoms in this node to optimize them + * for eventual rendering. See SceneGraphReducer::premunge(). + */ void GeomNode:: do_premunge(GraphicsStateGuardianBase *gsg, const RenderState *node_state, @@ -973,12 +883,10 @@ do_premunge(GraphicsStateGuardianBase *gsg, CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::r_mark_geom_bounds_stale -// Access: Protected, Virtual -// Description: Recursively calls Geom::mark_bounds_stale() on every -// Geom at this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Recursively calls Geom::mark_bounds_stale() on every Geom at this node and + * below. + */ void GeomNode:: r_mark_geom_bounds_stale(Thread *current_thread) { OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { @@ -997,14 +905,11 @@ r_mark_geom_bounds_stale(Thread *current_thread) { PandaNode::r_mark_geom_bounds_stale(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Returns a newly-allocated BoundingVolume that -// represents the internal contents of the node. Should -// be overridden by PandaNode classes that contain -// something internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated BoundingVolume that represents the internal + * contents of the node. Should be overridden by PandaNode classes that + * contain something internally. + */ void GeomNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -1047,8 +952,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, if (btype == BoundingVolume::BT_box || (btype != BoundingVolume::BT_sphere && all_box)) { - // If all of the child volumes are a BoundingBox, then our volume - // is also a BoundingBox. + // If all of the child volumes are a BoundingBox, then our volume is also + // a BoundingBox. gbv = new BoundingBox; } else { // Otherwise, it's a sphere. @@ -1065,46 +970,39 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = num_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type GeomNode. + */ void GeomNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void GeomNode:: finalize(BamReader *manager) { if (manager->get_file_minor_ver() < 14) { - // With version 6.14, we changed the default ColorAttrib - // behavior from make_vertex() to make_flat(). This means that - // every Geom that contains vertex colors now needs to have an - // explicit ColorAttrib::make_vertex() on its state. + // With version 6.14, we changed the default ColorAttrib behavior from + // make_vertex() to make_flat(). This means that every Geom that contains + // vertex colors now needs to have an explicit ColorAttrib::make_vertex() + // on its state. - // Since we shouldn't override a different ColorAttrib inherited - // from above, we create this new attrib with an override of -1. + // Since we shouldn't override a different ColorAttrib inherited from + // above, we create this new attrib with an override of -1. CPT(InternalName) color = InternalName::get_color(); CPT(RenderAttrib) vertex_color = ColorAttrib::make_vertex(); @@ -1145,14 +1043,11 @@ finalize(BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type GeomNode is encountered -// in the Bam file. It should create the GeomNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type GeomNode is encountered in the Bam file. It should create the + * GeomNode and extract its information from the file. + */ TypedWritable *GeomNode:: make_from_bam(const FactoryParams ¶ms) { GeomNode *node = new GeomNode(""); @@ -1169,46 +1064,37 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomNode. + */ void GeomNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomNode::CData:: CData(const GeomNode::CData ©) : _geoms(copy._geoms) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *GeomNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void GeomNode::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { CPT(GeomList) geoms = _geoms.get_read_pointer(); @@ -1224,13 +1110,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int GeomNode::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -1247,13 +1130,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: GeomNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new GeomNode. + */ void GeomNode::CData:: fillin(DatagramIterator &scan, BamReader *manager) { int num_geoms = scan.get_uint16(); diff --git a/panda/src/pgraph/geomNode.h b/panda/src/pgraph/geomNode.h index cfdbd85e2c..a490a914b4 100644 --- a/panda/src/pgraph/geomNode.h +++ b/panda/src/pgraph/geomNode.h @@ -1,16 +1,15 @@ -// Filename: geomNode.h -// Created by: drose (22eb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomNode.h + * @author drose + * @date 2002-02-22 + */ #ifndef GEOMNODE_H #define GEOMNODE_H @@ -27,13 +26,11 @@ class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : GeomNode -// Description : A node that holds Geom objects, renderable pieces of -// geometry. This is the primary kind of leaf node in -// the scene graph; almost all visible objects will be -// contained in a GeomNode somewhere. -//////////////////////////////////////////////////////////////////// +/** + * A node that holds Geom objects, renderable pieces of geometry. This is the + * primary kind of leaf node in the scene graph; almost all visible objects + * will be contained in a GeomNode somewhere. + */ class EXPCL_PANDA_PGRAPH GeomNode : public PandaNode { PUBLISHED: explicit GeomNode(const string &name); @@ -47,7 +44,7 @@ public: int attrib_types, GeomTransformer &transformer); virtual void xform(const LMatrix4 &mat); - virtual PandaNode *combine_with(PandaNode *other); + virtual PandaNode *combine_with(PandaNode *other); virtual CPT(TransformState) calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, @@ -110,8 +107,8 @@ protected: Thread *current_thread) const; public: - // This must be declared public so that VC6 will allow the nested - // CData class to access it. + // This must be declared public so that VC6 will allow the nested CData + // class to access it. class GeomEntry { public: INLINE GeomEntry(Geom *geom, const RenderState *state); @@ -159,9 +156,8 @@ private: public: // This class is returned from get_geoms(). It is similar to - // PandaNode::get_children(); use this to walk through the list of - // geoms faster than walking through the geoms directly from the - // node. + // PandaNode::get_children(); use this to walk through the list of geoms + // faster than walking through the geoms directly from the node. class EXPCL_PANDA_PGRAPH Geoms { public: INLINE Geoms(); @@ -187,8 +183,8 @@ public: // This data is only needed when reading from a bam file. class BamAuxData : public BamReader::AuxData { public: - // We just hold a pointer to the RenderState that may otherwise - // lose its pointers before it can finalize. + // We just hold a pointer to the RenderState that may otherwise lose its + // pointers before it can finalize. CPT(RenderState) _hold_state; }; @@ -201,7 +197,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/pgraph/geomTransformer.I b/panda/src/pgraph/geomTransformer.I index ca496477cc..c048abb98d 100644 --- a/panda/src/pgraph/geomTransformer.I +++ b/panda/src/pgraph/geomTransformer.I @@ -1,47 +1,39 @@ -// Filename: geomTransformer.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTransformer.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::get_max_collect_vertices -// Access: Public -// Description: Returns the maximum number of vertices that may be -// put into a single GeomVertexData as a result of -// collecting multiple objects in collect_vertex_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of vertices that may be put into a single + * GeomVertexData as a result of collecting multiple objects in + * collect_vertex_data(). + */ INLINE int GeomTransformer:: get_max_collect_vertices() const { return _max_collect_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::set_max_collect_vertices -// Access: Public -// Description: Specifies the maximum number of vertices that may be -// put into a single GeomVertexData as a result of -// collecting multiple objects in collect_vertex_data(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum number of vertices that may be put into a single + * GeomVertexData as a result of collecting multiple objects in + * collect_vertex_data(). + */ INLINE void GeomTransformer:: set_max_collect_vertices(int max_collect_vertices) { _max_collect_vertices = max_collect_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::SourceVertices::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::SourceVertices:: operator < (const GeomTransformer::SourceVertices &other) const { if (_vertex_data != other._vertex_data) { @@ -50,11 +42,9 @@ operator < (const GeomTransformer::SourceVertices &other) const { return (_mat.compare_to(other._mat) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::SourceTexCoords::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::SourceTexCoords:: operator < (const GeomTransformer::SourceTexCoords &other) const { if (_vertex_data != other._vertex_data) { @@ -69,11 +59,9 @@ operator < (const GeomTransformer::SourceTexCoords &other) const { return (_mat.compare_to(other._mat) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::SourceColors::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::SourceColors:: operator < (const GeomTransformer::SourceColors &other) const { if (_vertex_data != other._vertex_data) { @@ -82,11 +70,9 @@ operator < (const GeomTransformer::SourceColors &other) const { return (_color.compare_to(other._color) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::SourceTextureColors::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::SourceTextureColors:: operator < (const GeomTransformer::SourceTextureColors &other) const { if (_vertex_data != other._vertex_data) { @@ -107,11 +93,9 @@ operator < (const GeomTransformer::SourceTextureColors &other) const { return (_base_color.compare_to(other._base_color) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::SourceFormat::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::SourceFormat:: operator < (const GeomTransformer::SourceFormat &other) const { if (_format != other._format) { @@ -120,11 +104,9 @@ operator < (const GeomTransformer::SourceFormat &other) const { return _vertex_data < other._vertex_data; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedKey::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool GeomTransformer::NewCollectedKey:: operator < (const GeomTransformer::NewCollectedKey &other) const { if (_format != other._format) { @@ -139,14 +121,10 @@ operator < (const GeomTransformer::NewCollectedKey &other) const { return _name < other._name; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::VertexDataAssoc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE GeomTransformer::VertexDataAssoc:: VertexDataAssoc() { _might_have_unused = false; } - - diff --git a/panda/src/pgraph/geomTransformer.cxx b/panda/src/pgraph/geomTransformer.cxx index 3c209abbb2..10648b7686 100644 --- a/panda/src/pgraph/geomTransformer.cxx +++ b/panda/src/pgraph/geomTransformer.cxx @@ -1,16 +1,15 @@ -// Filename: geomTransformer.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTransformer.cxx + * @author drose + * @date 2002-03-14 + */ #include "geomTransformer.h" #include "sceneGraphReducer.h" @@ -41,11 +40,9 @@ PStatCollector GeomTransformer::_apply_set_format_collector("*:Flatten:apply:set TypeHandle GeomTransformer::NewCollectedData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTransformer:: GeomTransformer() : // The default value here comes from the Config file. @@ -53,34 +50,27 @@ GeomTransformer() : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTransformer:: GeomTransformer(const GeomTransformer ©) : _max_collect_vertices(copy._max_collect_vertices) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTransformer:: ~GeomTransformer() { finish_collect(false); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::register_vertices -// Access: Public -// Description: Records the association of the Geom with its -// GeomVertexData, for the purpose of later removing -// unused vertices. -//////////////////////////////////////////////////////////////////// +/** + * Records the association of the Geom with its GeomVertexData, for the + * purpose of later removing unused vertices. + */ void GeomTransformer:: register_vertices(Geom *geom, bool might_have_unused) { VertexDataAssoc &assoc = _vdata_assoc[geom->get_vertex_data()]; @@ -90,13 +80,10 @@ register_vertices(Geom *geom, bool might_have_unused) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::register_vertices -// Access: Public -// Description: Records the association of the Geom with its -// GeomVertexData, for the purpose of later removing -// unused vertices. -//////////////////////////////////////////////////////////////////// +/** + * Records the association of the Geom with its GeomVertexData, for the + * purpose of later removing unused vertices. + */ void GeomTransformer:: register_vertices(GeomNode *node, bool might_have_unused) { Thread *current_thread = Thread::get_current_thread(); @@ -113,13 +100,10 @@ register_vertices(GeomNode *node, bool might_have_unused) { CLOSE_ITERATE_CURRENT_AND_UPSTREAM(node->_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_vertices -// Access: Public -// Description: Transforms the vertices and the normals in the -// indicated Geom by the indicated matrix. Returns true -// if the Geom was changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the vertices and the normals in the indicated Geom by the + * indicated matrix. Returns true if the Geom was changed, false otherwise. + */ bool GeomTransformer:: transform_vertices(Geom *geom, const LMatrix4 &mat) { PStatTimer timer(_apply_vertex_collector); @@ -128,7 +112,7 @@ transform_vertices(Geom *geom, const LMatrix4 &mat) { SourceVertices sv; sv._mat = mat; sv._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _vertices[sv]; if (new_data._vdata.is_null()) { // We have not yet converted these vertices. Do so now. @@ -136,7 +120,7 @@ transform_vertices(Geom *geom, const LMatrix4 &mat) { new_vdata->transform_vertices(mat); new_data._vdata = new_vdata; } - + geom->set_vertex_data(new_data._vdata); if (sv._vertex_data->get_ref_count() > 1) { _vdata_assoc[new_data._vdata]._might_have_unused = true; @@ -147,17 +131,13 @@ transform_vertices(Geom *geom, const LMatrix4 &mat) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_vertices -// Access: Public -// Description: Transforms the vertices and the normals in all of the -// Geoms within the indicated GeomNode by the indicated -// matrix. Does not destructively change Geoms; -// instead, a copy will be made of each Geom to be -// changed, in case multiple GeomNodes reference the -// same Geom. Returns true if the GeomNode was changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the vertices and the normals in all of the Geoms within the + * indicated GeomNode by the indicated matrix. Does not destructively change + * Geoms; instead, a copy will be made of each Geom to be changed, in case + * multiple GeomNodes reference the same Geom. Returns true if the GeomNode + * was changed, false otherwise. + */ bool GeomTransformer:: transform_vertices(GeomNode *node, const LMatrix4 &mat) { bool any_changed = false; @@ -186,15 +166,12 @@ transform_vertices(GeomNode *node, const LMatrix4 &mat) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_texcoords -// Access: Public -// Description: Transforms the texture coordinates in the indicated -// Geom by the indicated matrix. Returns true if the -// Geom was changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the texture coordinates in the indicated Geom by the indicated + * matrix. Returns true if the Geom was changed, false otherwise. + */ bool GeomTransformer:: -transform_texcoords(Geom *geom, const InternalName *from_name, +transform_texcoords(Geom *geom, const InternalName *from_name, InternalName *to_name, const LMatrix4 &mat) { PStatTimer timer(_apply_texcoord_collector); @@ -205,7 +182,7 @@ transform_texcoords(Geom *geom, const InternalName *from_name, st._from = from_name; st._to = to_name; st._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _texcoords[st]; if (new_data._vdata.is_null()) { if (!st._vertex_data->has_column(from_name)) { @@ -214,31 +191,31 @@ transform_texcoords(Geom *geom, const InternalName *from_name, } PT(GeomVertexData) new_vdata; - + // We have not yet converted these texcoords. Do so now. if (st._vertex_data->has_column(to_name)) { new_vdata = new GeomVertexData(*st._vertex_data); } else { - const GeomVertexColumn *old_column = + const GeomVertexColumn *old_column = st._vertex_data->get_format()->get_column(from_name); new_vdata = st._vertex_data->replace_column (to_name, old_column->get_num_components(), old_column->get_numeric_type(), old_column->get_contents()); } - + CPT(GeomVertexFormat) format = new_vdata->get_format(); - + GeomVertexWriter tdata(new_vdata, to_name); GeomVertexReader fdata(new_vdata, from_name); - + while (!fdata.is_at_end()) { const LPoint4 &coord = fdata.get_data4(); tdata.set_data4(coord * mat); } new_data._vdata = new_vdata; } - + geom->set_vertex_data(new_data._vdata); if (st._vertex_data->get_ref_count() > 1) { _vdata_assoc[new_data._vdata]._might_have_unused = true; @@ -249,17 +226,13 @@ transform_texcoords(Geom *geom, const InternalName *from_name, } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_texcoords -// Access: Public -// Description: Transforms the texture coordinates in all of the -// Geoms within the indicated GeomNode by the indicated -// matrix. Does not destructively change Geoms; -// instead, a copy will be made of each Geom to be -// changed, in case multiple GeomNodes reference the -// same Geom. Returns true if the GeomNode was changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the texture coordinates in all of the Geoms within the indicated + * GeomNode by the indicated matrix. Does not destructively change Geoms; + * instead, a copy will be made of each Geom to be changed, in case multiple + * GeomNodes reference the same Geom. Returns true if the GeomNode was + * changed, false otherwise. + */ bool GeomTransformer:: transform_texcoords(GeomNode *node, const InternalName *from_name, InternalName *to_name, const LMatrix4 &mat) { @@ -281,13 +254,10 @@ transform_texcoords(GeomNode *node, const InternalName *from_name, } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::set_color -// Access: Public -// Description: Overrides the color indicated within the Geom with -// the given replacement color. Returns true if the -// Geom was changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Overrides the color indicated within the Geom with the given replacement + * color. Returns true if the Geom was changed, false otherwise. + */ bool GeomTransformer:: set_color(Geom *geom, const LColor &color) { PStatTimer timer(_apply_set_color_collector); @@ -295,7 +265,7 @@ set_color(Geom *geom, const LColor &color) { SourceColors sc; sc._color = color; sc._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _fcolors[sc]; if (new_data._vdata.is_null()) { // We have not yet converted these colors. Do so now. @@ -306,7 +276,7 @@ set_color(Geom *geom, const LColor &color) { (color, 1, Geom::NT_packed_dabc, Geom::C_color); } } - + geom->set_vertex_data(new_data._vdata); if (sc._vertex_data->get_ref_count() > 1) { _vdata_assoc[new_data._vdata]._might_have_unused = true; @@ -317,14 +287,11 @@ set_color(Geom *geom, const LColor &color) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::set_color -// Access: Public -// Description: Overrides the color indicated within the GeomNode -// with the given replacement color. Returns true if -// any Geom in the GeomNode was changed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Overrides the color indicated within the GeomNode with the given + * replacement color. Returns true if any Geom in the GeomNode was changed, + * false otherwise. + */ bool GeomTransformer:: set_color(GeomNode *node, const LColor &color) { bool any_changed = false; @@ -344,13 +311,10 @@ set_color(GeomNode *node, const LColor &color) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_colors -// Access: Public -// Description: Transforms the colors in the indicated Geom by the -// indicated scale. Returns true if the Geom was -// changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the colors in the indicated Geom by the indicated scale. + * Returns true if the Geom was changed, false otherwise. + */ bool GeomTransformer:: transform_colors(Geom *geom, const LVecBase4 &scale) { PStatTimer timer(_apply_scale_color_collector); @@ -360,7 +324,7 @@ transform_colors(Geom *geom, const LVecBase4 &scale) { SourceColors sc; sc._color = scale; sc._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _tcolors[sc]; if (new_data._vdata.is_null()) { // We have not yet converted these colors. Do so now. @@ -371,7 +335,7 @@ transform_colors(Geom *geom, const LVecBase4 &scale) { (scale, 1, Geom::NT_packed_dabc, Geom::C_color); } } - + geom->set_vertex_data(new_data._vdata); if (sc._vertex_data->get_ref_count() > 1) { _vdata_assoc[new_data._vdata]._might_have_unused = true; @@ -382,16 +346,13 @@ transform_colors(Geom *geom, const LVecBase4 &scale) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::transform_colors -// Access: Public -// Description: Transforms the colors in all of the Geoms within the -// indicated GeomNode by the indicated scale. Does -// not destructively change Geoms; instead, a copy will -// be made of each Geom to be changed, in case multiple -// GeomNodes reference the same Geom. Returns true if -// the GeomNode was changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the colors in all of the Geoms within the indicated GeomNode by + * the indicated scale. Does not destructively change Geoms; instead, a copy + * will be made of each Geom to be changed, in case multiple GeomNodes + * reference the same Geom. Returns true if the GeomNode was changed, false + * otherwise. + */ bool GeomTransformer:: transform_colors(GeomNode *node, const LVecBase4 &scale) { bool any_changed = false; @@ -412,16 +373,13 @@ transform_colors(GeomNode *node, const LVecBase4 &scale) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::apply_texture_colors -// Access: Public -// Description: Removes textures from Geoms by applying the texture -// colors to the vertices. -// -// See apply_texure_colors(GeomNode *, RenderState *). -//////////////////////////////////////////////////////////////////// +/** + * Removes textures from Geoms by applying the texture colors to the vertices. + * + * See apply_texure_colors(GeomNode *, RenderState *). + */ bool GeomTransformer:: -apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, +apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, const TexMatrixAttrib *tma, const LColor &base_color, bool keep_vertex_color) { PStatTimer timer(_apply_texture_color_collector); @@ -433,12 +391,11 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, return false; } - if (peeker->get_x_size() == 1 && - peeker->get_y_size() == 1 && + if (peeker->get_x_size() == 1 && + peeker->get_y_size() == 1 && peeker->get_z_size() == 1) { - // If it's just a one-pixel texture (e.g. a simple ram image), - // don't bother scanning the UV's. Just extract the color and - // apply it. + // If it's just a one-pixel texture (e.g. a simple ram image), don't + // bother scanning the UV's. Just extract the color and apply it. LColor color; peeker->lookup(color, 0.0f, 0.0f); color.set(color[0] * base_color[0], @@ -459,13 +416,12 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, got_mat = !mat.almost_equal(LMatrix4::ident_mat()); } - // This version of the code just applied one overall flat color to - // the entire mesh. Turned out not to be good enough. Instead, - // we'll look up each vertex in the texture map and apply the - // nearest color to the vertex. + // This version of the code just applied one overall flat color to the + // entire mesh. Turned out not to be good enough. Instead, we'll look up + // each vertex in the texture map and apply the nearest color to the vertex. /* - // Scan the UV's to get the used range. This is particularly - // necessary for palettized textures. + // Scan the UV's to get the used range. This is particularly necessary for + // palettized textures. LPoint3 min_point, max_point; bool found_any = false; @@ -475,10 +431,10 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, ts->get_texcoord_name(), Thread::get_current_thread()); if (found_any) { - // Now use that UV range to determine the overall color of the - // geom's texture. + // Now use that UV range to determine the overall color of the geom's + // texture. LColor color; - peeker->filter_rect(color, + peeker->filter_rect(color, min_point[0], min_point[1], min_point[2], max_point[0], max_point[1], max_point[2]); color.set(color[0] * base_color[0], @@ -502,7 +458,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, stc._base_color = base_color; stc._keep_vertex_color = keep_vertex_color; stc._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _tex_colors[stc]; if (new_data._vdata.is_null()) { // We have not yet applied these texture colors. Do so now. @@ -518,7 +474,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, (LColor(1.0f, 1.0f, 1.0f, 1.0f), 1, Geom::NT_packed_dabc, Geom::C_color)); keep_vertex_color = false; } - + // Check whether it has 2-d or 3-d texture coordinates. bool tex3d = false; const GeomVertexColumn *column = vdata->get_format()->get_column(ts->get_texcoord_name()); @@ -528,14 +484,14 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, if (column->get_num_components() >= 3) { tex3d = true; } - - // Now walk through the vertices and apply each color from the - // texture as we go. + + // Now walk through the vertices and apply each color from the texture as + // we go. if (keep_vertex_color) { // We want to modulate the existing vertex color. GeomVertexReader gtexcoord(vdata, ts->get_texcoord_name()); GeomVertexRewriter gcolor(vdata, InternalName::get_color()); - + if (got_mat || tex3d) { while (!gtexcoord.is_at_end()) { LTexCoord3 p = gtexcoord.get_data3(); @@ -566,7 +522,7 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, // We want to replace any existing vertex color. GeomVertexReader gtexcoord(vdata, ts->get_texcoord_name()); GeomVertexWriter gcolor(vdata, InternalName::get_color()); - + if (got_mat || tex3d) { while (!gtexcoord.is_at_end()) { LTexCoord3 p = gtexcoord.get_data3(); @@ -605,23 +561,18 @@ apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::apply_texture_colors -// Access: Public -// Description: Removes textures from Geoms by applying the texture -// colors to the vertices. This is primarily useful to -// simplify a low-LOD model. -// -// Only the bottommost texture is used (if there is more -// than one), and it is applied as if it were -// M_modulate, and WM_repeat, regardless of its actual -// settings. If the texture has a simple_ram_image, -// this may be used if the main image isn't resident. -// -// After this call, there will be no texturing specified -// on the GeomNode level. Of course, there might still -// be texturing inherited from above. -//////////////////////////////////////////////////////////////////// +/** + * Removes textures from Geoms by applying the texture colors to the vertices. + * This is primarily useful to simplify a low-LOD model. + * + * Only the bottommost texture is used (if there is more than one), and it is + * applied as if it were M_modulate, and WM_repeat, regardless of its actual + * settings. If the texture has a simple_ram_image, this may be used if the + * main image isn't resident. + * + * After this call, there will be no texturing specified on the GeomNode + * level. Of course, there might still be texturing inherited from above. + */ bool GeomTransformer:: apply_texture_colors(GeomNode *node, const RenderState *state) { bool any_changed = false; @@ -677,13 +628,10 @@ apply_texture_colors(GeomNode *node, const RenderState *state) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::apply_state -// Access: Public -// Description: Applies the indicated render state to all the of -// Geoms. Returns true if the GeomNode was changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated render state to all the of Geoms. Returns true if + * the GeomNode was changed, false otherwise. + */ bool GeomTransformer:: apply_state(GeomNode *node, const RenderState *state) { bool any_changed = false; @@ -703,12 +651,10 @@ apply_state(GeomNode *node, const RenderState *state) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::set_format -// Access: Public -// Description: Changes the GeomVertexData of the indicated Geom to -// use the specified format. -//////////////////////////////////////////////////////////////////// +/** + * Changes the GeomVertexData of the indicated Geom to use the specified + * format. + */ bool GeomTransformer:: set_format(Geom *geom, const GeomVertexFormat *new_format) { PStatTimer timer(_apply_set_format_collector); @@ -718,7 +664,7 @@ set_format(Geom *geom, const GeomVertexFormat *new_format) { SourceFormat sf; sf._format = new_format; sf._vertex_data = geom->get_vertex_data(); - + NewVertexData &new_data = _format[sf]; if (new_data._vdata.is_null()) { if (sf._vertex_data->get_format() == new_format) { @@ -731,7 +677,7 @@ set_format(Geom *geom, const GeomVertexFormat *new_format) { new_vdata->set_format(new_format); new_data._vdata = new_vdata; } - + geom->set_vertex_data(new_data._vdata); if (sf._vertex_data->get_ref_count() > 1) { _vdata_assoc[new_data._vdata]._might_have_unused = true; @@ -741,13 +687,10 @@ set_format(Geom *geom, const GeomVertexFormat *new_format) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::remove_column -// Access: Public -// Description: Removes the named column from the vertex data in the -// Geom. Returns true if the Geom was changed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named column from the vertex data in the Geom. Returns true if + * the Geom was changed, false otherwise. + */ bool GeomTransformer:: remove_column(Geom *geom, const InternalName *column) { CPT(GeomVertexFormat) format = geom->get_vertex_data()->get_format(); @@ -764,13 +707,10 @@ remove_column(Geom *geom, const InternalName *column) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::remove_column -// Access: Public -// Description: Removes the named column from the vertex datas within -// the GeomNode. Returns true if the GeomNode was -// changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named column from the vertex datas within the GeomNode. + * Returns true if the GeomNode was changed, false otherwise. + */ bool GeomTransformer:: remove_column(GeomNode *node, const InternalName *column) { bool any_changed = false; @@ -790,32 +730,28 @@ remove_column(GeomNode *node, const InternalName *column) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::make_compatible_state -// Access: Public -// Description: Checks if the different geoms in the GeomNode have -// different RenderStates. If so, tries to make the -// RenderStates the same. It does this by -// canonicalizing the ColorAttribs, and in the future, -// possibly other attribs. -//////////////////////////////////////////////////////////////////// +/** + * Checks if the different geoms in the GeomNode have different RenderStates. + * If so, tries to make the RenderStates the same. It does this by + * canonicalizing the ColorAttribs, and in the future, possibly other attribs. + */ bool GeomTransformer:: make_compatible_state(GeomNode *node) { if (node->get_num_geoms() < 2) { return false; } - + GeomNode::CDWriter cdata(node->_cycler); GeomNode::GeomList::iterator gi; PT(GeomNode::GeomList) geoms = cdata->modify_geoms(); - // For each geom, calculate a canonicalized RenderState, and - // classify all the geoms according to that. By "canonicalize" - // here, we simply mean removing the ColorAttrib. - + // For each geom, calculate a canonicalized RenderState, and classify all + // the geoms according to that. By "canonicalize" here, we simply mean + // removing the ColorAttrib. + typedef pmap > StateTable; StateTable state_table; - + for (int i = 0; i < (int)geoms->size(); i++) { GeomNode::GeomEntry &entry = (*geoms)[i]; CPT(RenderState) canon = entry._state->remove_attrib(ColorAttrib::get_class_slot()); @@ -823,14 +759,14 @@ make_compatible_state(GeomNode *node) { } // For each group of geoms, check for mismatch. - + bool any_changed = false; StateTable::iterator si; for (si = state_table.begin(); si != state_table.end(); si++) { - - // If the geoms in the group already have the same RenderStates, - // then nothing needs to be done to this group. - + + // If the geoms in the group already have the same RenderStates, then + // nothing needs to be done to this group. + const pvector &indices = (*si).second; bool mismatch = false; for (int i = 1; i < (int)indices.size(); i++) { @@ -842,11 +778,11 @@ make_compatible_state(GeomNode *node) { if (!mismatch) { continue; } - - // The geoms do not have the same RenderState, but they could, - // since their canonicalized states are the same. Canonicalize - // them, by applying the colors to the vertices. - + + // The geoms do not have the same RenderState, but they could, since their + // canonicalized states are the same. Canonicalize them, by applying the + // colors to the vertices. + const RenderState *canon_state = (*si).first; for (int i = 0; i < (int)indices.size(); i++) { GeomNode::GeomEntry &entry = (*geoms)[indices[i]]; @@ -861,8 +797,8 @@ make_compatible_state(GeomNode *node) { } } } else { - // A flat color (or "off", which is white). Set the vertices - // to the indicated flat color. + // A flat color (or "off", which is white). Set the vertices to the + // indicated flat color. LColor c = ca->get_color(); PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy(); if (set_color(new_geom, c)) { @@ -873,17 +809,14 @@ make_compatible_state(GeomNode *node) { any_changed = true; } } - + return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::reverse_normals -// Access: Public -// Description: Reverses the lighting normals on the vertex data, if -// any. Returns true if the Geom was changed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the lighting normals on the vertex data, if any. Returns true if + * the Geom was changed, false otherwise. + */ bool GeomTransformer:: reverse_normals(Geom *geom) { nassertr(geom != (Geom *)NULL, false); @@ -907,27 +840,20 @@ reverse_normals(Geom *geom) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::doubleside -// Access: Public -// Description: Duplicates triangles in this GeomNode so that each -// triangle is back-to-back with another triangle facing -// in the opposite direction. If the geometry has -// vertex normals, this will also duplicate and reverse -// the normals, so that lighting will work correctly -// from both sides. Note that calling this when the -// geometry is already doublesided (with back-to-back -// polygons) will result in multiple redundant coplanar -// polygons. -// -// Also see CullFaceAttrib, which can enable rendering -// of both sides of a triangle without having to -// duplicate it (but which doesn't necessarily work in -// the presence of lighting). -// -// Returns true if any Geoms are modified, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Duplicates triangles in this GeomNode so that each triangle is back-to-back + * with another triangle facing in the opposite direction. If the geometry + * has vertex normals, this will also duplicate and reverse the normals, so + * that lighting will work correctly from both sides. Note that calling this + * when the geometry is already doublesided (with back-to-back polygons) will + * result in multiple redundant coplanar polygons. + * + * Also see CullFaceAttrib, which can enable rendering of both sides of a + * triangle without having to duplicate it (but which doesn't necessarily work + * in the presence of lighting). + * + * Returns true if any Geoms are modified, false otherwise. + */ bool GeomTransformer:: doubleside(GeomNode *node) { int num_geoms = node->get_num_geoms(); @@ -935,41 +861,36 @@ doubleside(GeomNode *node) { CPT(Geom) orig_geom = node->get_geom(i); bool has_normals = (orig_geom->get_vertex_data()->has_column(InternalName::get_normal())); if (has_normals) { - // If the geometry has normals, we have to duplicate it to - // reverse the normals on the duplicate copy. + // If the geometry has normals, we have to duplicate it to reverse the + // normals on the duplicate copy. PT(Geom) new_geom = orig_geom->reverse(); reverse_normals(new_geom); node->add_geom(new_geom, node->get_geom_state(i)); - + } else { - // If there are no normals, we can just doubleside it in - // place. This is preferable because we can share vertices. + // If there are no normals, we can just doubleside it in place. This is + // preferable because we can share vertices. orig_geom.clear(); node->modify_geom(i)->doubleside_in_place(); } } - + return (num_geoms != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::reverse -// Access: Public -// Description: Reverses the winding order of triangles in this -// GeomNode so that each triangle is facing in the -// opposite direction. If the geometry has vertex -// normals, this will also reverse the normals, so that -// lighting will work correctly. -// -// Also see CullFaceAttrib, which can effectively change -// the facing of a triangle having to modify its -// vertices (but which doesn't necessarily work in the -// presence of lighting). -// -// Returns true if any Geoms are modified, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the winding order of triangles in this GeomNode so that each + * triangle is facing in the opposite direction. If the geometry has vertex + * normals, this will also reverse the normals, so that lighting will work + * correctly. + * + * Also see CullFaceAttrib, which can effectively change the facing of a + * triangle having to modify its vertices (but which doesn't necessarily work + * in the presence of lighting). + * + * Returns true if any Geoms are modified, false otherwise. + */ bool GeomTransformer:: reverse(GeomNode *node) { int num_geoms = node->get_num_geoms(); @@ -978,22 +899,17 @@ reverse(GeomNode *node) { geom->reverse_in_place(); reverse_normals(geom); } - + return (num_geoms != 0); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::finish_apply -// Access: Public -// Description: Should be called after performing any -// operations--particularly -// PandaNode::apply_attribs_to_vertices()--that might -// result in new GeomVertexData objects being duplicated -// and modified. This walks through those newly -// duplicated objects and ensures that redundant unused -// vertices have not been created, removing them if they -// have. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after performing any operations--particularly + * PandaNode::apply_attribs_to_vertices()--that might result in new + * GeomVertexData objects being duplicated and modified. This walks through + * those newly duplicated objects and ensures that redundant unused vertices + * have not been created, removing them if they have. + */ void GeomTransformer:: finish_apply() { VertexDataAssocMap::iterator vi; @@ -1012,23 +928,19 @@ finish_apply() { _format.clear(); _reversed_normals.clear(); } - -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::collect_vertex_data -// Access: Public -// Description: Collects together GeomVertexDatas from different -// geoms into one big (or several big) GeomVertexDatas. -// Returns the number of unique GeomVertexDatas created. -// -// If format_only is true, this only makes -// GeomVertexFormats compatible; it does not otherwise -// combine vertices. -// -// You should follow this up with a call to -// finish_collect(), but you probably don't want to call -// this method directly anyway. Call -// SceneGraphReducer::collect_vertex_data() instead. -//////////////////////////////////////////////////////////////////// + +/** + * Collects together GeomVertexDatas from different geoms into one big (or + * several big) GeomVertexDatas. Returns the number of unique GeomVertexDatas + * created. + * + * If format_only is true, this only makes GeomVertexFormats compatible; it + * does not otherwise combine vertices. + * + * You should follow this up with a call to finish_collect(), but you probably + * don't want to call this method directly anyway. Call + * SceneGraphReducer::collect_vertex_data() instead. + */ int GeomTransformer:: collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { CPT(GeomVertexData) vdata = geom->get_vertex_data(); @@ -1069,16 +981,15 @@ collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { return 0; } - // We haven't collected this vertex data yet; associate it with a - // new data. + // We haven't collected this vertex data yet; associate it with a new data. NewCollectedMap::iterator ni = _new_collected_map.find(key); NewCollectedData *ncd; if (ni != _new_collected_map.end()) { ncd = (*ni).second; } else { - // We haven't encountered a compatible GeomVertexData before. - // Create a new entry. + // We haven't encountered a compatible GeomVertexData before. Create a + // new entry. ncd = new NewCollectedData(vdata); _new_collected_list.push_back(ncd); _new_collected_map[key] = ncd; @@ -1109,7 +1020,7 @@ collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { source_geom._geom = geom; source_geom._vertex_offset = vertex_offset; ncd->_source_geoms.push_back(source_geom); - + SourceData source_data; source_data._vdata = vdata; source_data._num_vertices = this_num_vertices; @@ -1121,23 +1032,18 @@ collect_vertex_data(Geom *geom, int collect_bits, bool format_only) { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::collect_vertex_data -// Access: Public -// Description: Collects together individual GeomVertexData -// structures that share the same format into one big -// GeomVertexData structure. This is intended to -// minimize context switches on the graphics card. -// -// If format_only is true, this only makes -// GeomVertexFormats compatible; it does not otherwise -// combine vertices. -// -// You should follow this up with a call to -// finish_collect(), but you probably don't want to call -// this method directly anyway. Call -// SceneGraphReducer::collect_vertex_data() instead. -//////////////////////////////////////////////////////////////////// +/** + * Collects together individual GeomVertexData structures that share the same + * format into one big GeomVertexData structure. This is intended to minimize + * context switches on the graphics card. + * + * If format_only is true, this only makes GeomVertexFormats compatible; it + * does not otherwise combine vertices. + * + * You should follow this up with a call to finish_collect(), but you probably + * don't want to call this method directly anyway. Call + * SceneGraphReducer::collect_vertex_data() instead. + */ int GeomTransformer:: collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { int num_adjusted = 0; @@ -1153,13 +1059,13 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { if ((collect_bits & SceneGraphReducer::CVD_avoid_dynamic) != 0 && new_geom->get_vertex_data()->get_usage_hint() < Geom::UH_static) { - // This one has some dynamic properties. Collect it - // independently of the outside world. + // This one has some dynamic properties. Collect it independently of + // the outside world. if (dynamic == (GeomTransformer *)NULL) { dynamic = new GeomTransformer(*this); } num_adjusted += dynamic->collect_vertex_data(new_geom, collect_bits, format_only); - + } else { num_adjusted += collect_vertex_data(new_geom, collect_bits, format_only); } @@ -1173,26 +1079,21 @@ collect_vertex_data(GeomNode *node, int collect_bits, bool format_only) { return num_adjusted; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::finish_collect -// Access: Public -// Description: This should be called after a call to -// collect_vertex_data() to finalize the changes and -// apply them to the vertices in the graph. If this is -// not called, it will be called automatically by the -// GeomTransformer destructor. -// -// If format_only is true, this returns the number of -// GeomVertexDatas modified to use a new format. If -// false, it returns the number of GeomVertexDatas -// created. -//////////////////////////////////////////////////////////////////// +/** + * This should be called after a call to collect_vertex_data() to finalize the + * changes and apply them to the vertices in the graph. If this is not + * called, it will be called automatically by the GeomTransformer destructor. + * + * If format_only is true, this returns the number of GeomVertexDatas modified + * to use a new format. If false, it returns the number of GeomVertexDatas + * created. + */ int GeomTransformer:: finish_collect(bool format_only) { int num_adjusted = 0; NewCollectedList::iterator nci; - for (nci = _new_collected_list.begin(); + for (nci = _new_collected_list.begin(); nci != _new_collected_list.end(); ++nci) { NewCollectedData *ncd = (*nci); @@ -1211,21 +1112,18 @@ finish_collect(bool format_only) { return num_adjusted; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::premunge_geom -// Access: Public -// Description: Uses the indicated munger to premunge the given Geom -// to optimize it for eventual rendering. See -// SceneGraphReducer::premunge(). -//////////////////////////////////////////////////////////////////// +/** + * Uses the indicated munger to premunge the given Geom to optimize it for + * eventual rendering. See SceneGraphReducer::premunge(). + */ PT(Geom) GeomTransformer:: premunge_geom(const Geom *geom, GeomMunger *munger) { - // This method had been originally provided to cache the result for - // a particular geom/munger and vdata/munger combination, similar to - // the way other GeomTransformer methods work. On reflection, this - // additional caching is not necessary, since the GeomVertexFormat - // does its own caching, and there's no danger of that cache filling - // up during the span of one frame. + // This method had been originally provided to cache the result for a + // particular geommunger and vdatamunger combination, similar to the way + // other GeomTransformer methods work. On reflection, this additional + // caching is not necessary, since the GeomVertexFormat does its own + // caching, and there's no danger of that cache filling up during the span + // of one frame. CPT(GeomVertexData) vdata = geom->get_vertex_data(); vdata = munger->premunge_data(vdata); @@ -1238,11 +1136,9 @@ premunge_geom(const Geom *geom, GeomMunger *munger) { return geom_copy; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTransformer::NewCollectedData:: NewCollectedData(const GeomVertexData *source_data) { _new_format = source_data->get_format(); @@ -1251,22 +1147,18 @@ NewCollectedData(const GeomVertexData *source_data) { _num_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedData::apply_format_only_changes -// Access: Public -// Description: Actually adjusts the GeomVertexDatas found in a -// collect_vertex_data() format-only call to have the -// same vertex format. Returns the number of vdatas -// modified. -//////////////////////////////////////////////////////////////////// +/** + * Actually adjusts the GeomVertexDatas found in a collect_vertex_data() + * format-only call to have the same vertex format. Returns the number of + * vdatas modified. + */ int GeomTransformer::NewCollectedData:: apply_format_only_changes() { int num_modified = 0; - // We probably don't need to use a map, since - // GeomVertexData::convert_to() already caches its result, but we do - // it anyway just in case there's danger of overflowing the cache. - // What the heck, it's easy to do. + // We probably don't need to use a map, since GeomVertexData::convert_to() + // already caches its result, but we do it anyway just in case there's + // danger of overflowing the cache. What the heck, it's easy to do. typedef pmap< CPT(GeomVertexData), CPT(GeomVertexData) > VDataMap; VDataMap vdata_map; @@ -1295,12 +1187,10 @@ apply_format_only_changes() { return num_modified; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedData::apply_collect_changes -// Access: Public -// Description: Actually combines all of the vertex datas found in a -// previous call to collect_vertex_data(). -//////////////////////////////////////////////////////////////////// +/** + * Actually combines all of the vertex datas found in a previous call to + * collect_vertex_data(). + */ int GeomTransformer::NewCollectedData:: apply_collect_changes() { if (_num_vertices == 0) { @@ -1320,9 +1210,9 @@ apply_collect_changes() { CPT(GeomVertexData) vdata = sd._vdata; if (_new_format != vdata->get_format()) { - // Convert (non-destructively) the current Geom's vertex - // data to the new format, so we can just blindly append the - // vertices to _new_data, within append_vdata(). + // Convert (non-destructively) the current Geom's vertex data to the new + // format, so we can just blindly append the vertices to _new_data, + // within append_vdata(). vdata = vdata->convert_to(_new_format); } @@ -1346,12 +1236,10 @@ apply_collect_changes() { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedData::append_vdata -// Access: Public -// Description: Appends the vertices from the indicated source -// GeomVertexData to the end of the working data. -//////////////////////////////////////////////////////////////////// +/** + * Appends the vertices from the indicated source GeomVertexData to the end of + * the working data. + */ void GeomTransformer::NewCollectedData:: append_vdata(const GeomVertexData *vdata, int vertex_offset) { for (int i = 0; i < vdata->get_num_arrays(); ++i) { @@ -1367,12 +1255,11 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { old_array->get_handle(), 0, copy_bytes); } - // Also, copy the animation data (if any). This means combining - // transform and/or slider tables, and might therefore mean - // remapping transform indices in the vertices. Each of these has a - // slightly different way to handle the remapping, because they have - // slightly different kinds of data. - + // Also, copy the animation data (if any). This means combining transform + // andor slider tables, and might therefore mean remapping transform indices + // in the vertices. Each of these has a slightly different way to handle + // the remapping, because they have slightly different kinds of data. + if (vdata->get_transform_table() != (TransformTable *)NULL || _new_data->get_transform_table() != (TransformTable *)NULL) { // The TransformTable. @@ -1386,34 +1273,33 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { temp_table->add_transform(identity_transform); old_table = TransformTable::register_table(temp_table); } - - // First, build a mapping of the transforms we already have in the - // current table. We must do this because the TransformTable - // doesn't automatically unquify index numbers for us (it doesn't - // store an index). + + // First, build a mapping of the transforms we already have in the current + // table. We must do this because the TransformTable doesn't + // automatically unquify index numbers for us (it doesn't store an index). typedef pmap AddedTransforms; AddedTransforms added_transforms; - + int num_old_transforms = old_table->get_num_transforms(); for (int i = 0; i < num_old_transforms; i++) { added_transforms[old_table->get_transform(i)] = i; } - - // Now create a new table. We have to create a new table instead - // of modifying the existing one, since a registered - // TransformTable cannot be modified. + + // Now create a new table. We have to create a new table instead of + // modifying the existing one, since a registered TransformTable cannot be + // modified. PT(TransformTable) new_table; if (_new_data->get_transform_table() != (TransformTable *)NULL) { new_table = new TransformTable(*_new_data->get_transform_table()); } else { new_table = new TransformTable; } - - // Now walk through the old table and copy over its transforms. - // We will build up an IndexMap of old index numbers to new index - // numbers while we go, which we can use to modify the vertices. + + // Now walk through the old table and copy over its transforms. We will + // build up an IndexMap of old index numbers to new index numbers while we + // go, which we can use to modify the vertices. IndexMap transform_map; - + int num_transforms = old_table->get_num_transforms(); transform_map.reserve(num_transforms); for (int ti = 0; ti < num_transforms; ++ti) { @@ -1431,10 +1317,9 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } _new_data->set_transform_table(TransformTable::register_table(new_table)); - // And now modify the vertices to update the indices to their new - // values in the new table. This requires a nested loop, since - // each column of transform_index might define multiple index - // values. + // And now modify the vertices to update the indices to their new values + // in the new table. This requires a nested loop, since each column of + // transform_index might define multiple index values. GeomVertexRewriter index(_new_data, InternalName::get_transform_index()); if (index.has_column()) { int num_values = index.get_column()->get_num_values(); @@ -1453,16 +1338,15 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } if (vdata->get_transform_blend_table() != (TransformBlendTable *)NULL) { - // The TransformBlendTable. This one is the easiest, because we - // can modify it directly, and it will uniquify blend objects for - // us. + // The TransformBlendTable. This one is the easiest, because we can + // modify it directly, and it will uniquify blend objects for us. + + // We have few special optimizations to handle the TransformBlendTable, + // since it's a very common case and therefore worth spending a bit of + // effort to optimize deeply. - // We have few special optimizations to handle the - // TransformBlendTable, since it's a very common case and - // therefore worth spending a bit of effort to optimize deeply. - CPT(TransformBlendTable) old_btable = vdata->get_transform_blend_table(); - + if (_new_btable == (TransformBlendTable *)NULL) { _new_btable = new TransformBlendTable; _new_btable->add_blend(TransformBlend()); @@ -1482,9 +1366,8 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { blend_map.push_back(bj); } - // Modify the indices. This is simpler than the transform_index, - // above, because each column of transform_blend may only define - // one index value. + // Modify the indices. This is simpler than the transform_index, above, + // because each column of transform_blend may only define one index value. GeomVertexRewriter index(_new_data, InternalName::get_transform_blend()); if (index.has_column()) { int num_rows = vdata->get_num_rows(); @@ -1498,13 +1381,13 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } } - + if (vdata->get_slider_table() != (SliderTable *)NULL) { // The SliderTable. This one requires making a copy, like the - // TransformTable (since it can't be modified once registered - // either), but at least it uniquifies sliders added to it. Also, - // it doesn't require indexing into it, so we don't have to build - // an IndexMap to modify the vertices with. + // TransformTable (since it can't be modified once registered either), but + // at least it uniquifies sliders added to it. Also, it doesn't require + // indexing into it, so we don't have to build an IndexMap to modify the + // vertices with. const SliderTable *old_sliders = vdata->get_slider_table(); PT(SliderTable) new_sliders; if (_new_data->get_slider_table() != (SliderTable *)NULL) { @@ -1522,12 +1405,9 @@ append_vdata(const GeomVertexData *vdata, int vertex_offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::NewCollectedData::update_geoms -// Access: Public -// Description: Updates all of the source Geoms to reference the new -// vertex data. -//////////////////////////////////////////////////////////////////// +/** + * Updates all of the source Geoms to reference the new vertex data. + */ void GeomTransformer::NewCollectedData:: update_geoms() { SourceGeoms::iterator sgi; @@ -1537,11 +1417,9 @@ update_geoms() { } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTransformer::VertexDataAssoc::remove_unused_vertices -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomTransformer::VertexDataAssoc:: remove_unused_vertices(const GeomVertexData *vdata) { if (_geoms.empty()) { diff --git a/panda/src/pgraph/geomTransformer.h b/panda/src/pgraph/geomTransformer.h index 5166fc70e8..e20732764f 100644 --- a/panda/src/pgraph/geomTransformer.h +++ b/panda/src/pgraph/geomTransformer.h @@ -1,16 +1,15 @@ -// Filename: geomTransformer.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTransformer.h + * @author drose + * @date 2002-03-14 + */ #ifndef GEOMTRANSFORMER_H #define GEOMTRANSFORMER_H @@ -28,22 +27,18 @@ class InternalName; class GeomMunger; class Texture; -//////////////////////////////////////////////////////////////////// -// Class : GeomTransformer -// Description : An object specifically designed to transform the -// vertices of a Geom without disturbing indexing or -// affecting any other Geoms that may share the same -// vertex arrays, and without needlessly wasting memory -// when different Geoms sharing the same vertex arrays -// are transformed by the same amount. -// -// If you create a single GeomTransformer and use it to -// transform a number of different Geoms by various -// transformations, then those Geoms which happen to -// share the same arrays and are transformed by the same -// amounts will still share the same arrays as each -// other (but different from the original arrays). -//////////////////////////////////////////////////////////////////// +/** + * An object specifically designed to transform the vertices of a Geom without + * disturbing indexing or affecting any other Geoms that may share the same + * vertex arrays, and without needlessly wasting memory when different Geoms + * sharing the same vertex arrays are transformed by the same amount. + * + * If you create a single GeomTransformer and use it to transform a number of + * different Geoms by various transformations, then those Geoms which happen + * to share the same arrays and are transformed by the same amounts will still + * share the same arrays as each other (but different from the original + * arrays). + */ class EXPCL_PANDA_PGRAPH GeomTransformer { public: GeomTransformer(); @@ -70,7 +65,7 @@ public: bool transform_colors(Geom *geom, const LVecBase4 &scale); bool transform_colors(GeomNode *node, const LVecBase4 &scale); - bool apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, + bool apply_texture_colors(Geom *geom, TextureStage *ts, Texture *tex, const TexMatrixAttrib *tma, const LColor &base_color, bool keep_vertex_color); bool apply_texture_colors(GeomNode *node, const RenderState *state); @@ -101,8 +96,8 @@ private: typedef pvector GeomList; // Keeps track of the Geoms that are associated with a particular - // GeomVertexData. Also tracks whether the vertex data might have - // unused vertices because of our actions. + // GeomVertexData. Also tracks whether the vertex data might have unused + // vertices because of our actions. class VertexDataAssoc { public: INLINE VertexDataAssoc(); @@ -113,15 +108,15 @@ private: typedef pmap VertexDataAssocMap; VertexDataAssocMap _vdata_assoc; - // Corresponds to a new GeomVertexData created as needed during an - // apply operation. + // Corresponds to a new GeomVertexData created as needed during an apply + // operation. class NewVertexData { public: CPT(GeomVertexData) _vdata; }; - // The table of GeomVertexData objects that have been transformed by - // a particular matrix. + // The table of GeomVertexData objects that have been transformed by a + // particular matrix. class SourceVertices { public: INLINE bool operator < (const SourceVertices &other) const; @@ -132,8 +127,8 @@ private: typedef pmap NewVertices; NewVertices _vertices; - // The table of GeomVertexData objects whose texture coordinates - // have been transformed by a particular matrix. + // The table of GeomVertexData objects whose texture coordinates have been + // transformed by a particular matrix. class SourceTexCoords { public: INLINE bool operator < (const SourceTexCoords &other) const; @@ -146,8 +141,7 @@ private: typedef pmap NewTexCoords; NewTexCoords _texcoords; - // The table of GeomVertexData objects whose colors have been - // modified. + // The table of GeomVertexData objects whose colors have been modified. class SourceColors { public: INLINE bool operator < (const SourceColors &other) const; @@ -157,14 +151,14 @@ private: }; typedef pmap NewColors; - // We have two concepts of colors: the "fixed" colors, which are - // slapped in as a complete replacement of the original colors - // (e.g. via a ColorAttrib), and the "transformed" colors, which are - // modified from the original colors (e.g. via a ColorScaleAttrib). + // We have two concepts of colors: the "fixed" colors, which are slapped in + // as a complete replacement of the original colors (e.g. via a + // ColorAttrib), and the "transformed" colors, which are modified from the + // original colors (e.g. via a ColorScaleAttrib). NewColors _fcolors, _tcolors; - // The table of GeomVertexData objects whose texture colors have - // been applied. + // The table of GeomVertexData objects whose texture colors have been + // applied. class SourceTextureColors { public: INLINE bool operator < (const SourceTextureColors &other) const; @@ -179,8 +173,8 @@ private: typedef pmap NewTextureColors; NewTextureColors _tex_colors; - // The table of GeomVertexData objects whose vertex formats have - // been modified. For set_format(): record (format + vertex_data) -> + // The table of GeomVertexData objects whose vertex formats have been + // modified. For set_format(): record (format + vertex_data) -> // vertex_data. class SourceFormat { public: @@ -192,8 +186,7 @@ private: typedef pmap NewFormat; NewFormat _format; - // The table of GeomVertexData objects whose normals have been - // reversed. + // The table of GeomVertexData objects whose normals have been reversed. typedef pmap ReversedNormals; ReversedNormals _reversed_normals; @@ -254,7 +247,7 @@ private: static void init_type() { register_type(_type_handle, "GeomTransformer::NewCollectedData"); } - + private: static TypeHandle _type_handle; }; @@ -277,7 +270,7 @@ private: static PStatCollector _apply_scale_color_collector; static PStatCollector _apply_texture_color_collector; static PStatCollector _apply_set_format_collector; - + public: static void init_type() { NewCollectedData::init_type(); @@ -287,4 +280,3 @@ public: #include "geomTransformer.I" #endif - diff --git a/panda/src/pgraph/internalNameCollection.I b/panda/src/pgraph/internalNameCollection.I index 67d217b351..01b5241828 100644 --- a/panda/src/pgraph/internalNameCollection.I +++ b/panda/src/pgraph/internalNameCollection.I @@ -1,43 +1,35 @@ -// Filename: internalNameCollection.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalNameCollection.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE InternalNameCollection:: ~InternalNameCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void InternalNameCollection:: operator += (const InternalNameCollection &other) { add_names_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::operator + -// Access: Published -// Description: Returns a InternalNameCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a InternalNameCollection representing the concatenation of the two + * lists. + */ INLINE InternalNameCollection InternalNameCollection:: operator + (const InternalNameCollection &other) const { InternalNameCollection a(*this); diff --git a/panda/src/pgraph/internalNameCollection.cxx b/panda/src/pgraph/internalNameCollection.cxx index f5242e7b21..f1ab629206 100644 --- a/panda/src/pgraph/internalNameCollection.cxx +++ b/panda/src/pgraph/internalNameCollection.cxx @@ -1,62 +1,52 @@ -// Filename: internalNameCollection.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalNameCollection.cxx + * @author drose + * @date 2002-03-16 + */ #include "internalNameCollection.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InternalNameCollection:: InternalNameCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ InternalNameCollection:: InternalNameCollection(const InternalNameCollection ©) : _names(copy._names) { } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void InternalNameCollection:: operator = (const InternalNameCollection ©) { _names = copy._names; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::add_name -// Access: Published -// Description: Adds a new InternalName to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new InternalName to the collection. + */ void InternalNameCollection:: add_name(const InternalName *name) { // If the pointer to our internal array is shared by any other // InternalNameCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren InternalNameCollection - // objects. + // inadvertently modify any of our brethren InternalNameCollection objects. if (_names.get_ref_count() > 1) { InternalNames old_names = _names; @@ -67,13 +57,10 @@ add_name(const InternalName *name) { _names.push_back(name); } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::remove_name -// Access: Published -// Description: Removes the indicated InternalName from the collection. -// Returns true if the name was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated InternalName from the collection. Returns true if + * the name was removed, false if it was not a member of the collection. + */ bool InternalNameCollection:: remove_name(const InternalName *name) { int name_index = -1; @@ -90,8 +77,7 @@ remove_name(const InternalName *name) { // If the pointer to our internal array is shared by any other // InternalNameCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren InternalNameCollection - // objects. + // inadvertently modify any of our brethren InternalNameCollection objects. if (_names.get_ref_count() > 1) { InternalNames old_names = _names; @@ -103,14 +89,11 @@ remove_name(const InternalName *name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::add_names_from -// Access: Published -// Description: Adds all the InternalNames indicated in the other -// collection to this name. The other names are simply -// appended to the end of the names in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the InternalNames indicated in the other collection to this name. + * The other names are simply appended to the end of the names in this list; + * duplicates are not automatically removed. + */ void InternalNameCollection:: add_names_from(const InternalNameCollection &other) { int other_num_names = other.get_num_names(); @@ -120,12 +103,10 @@ add_names_from(const InternalNameCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::remove_names_from -// Access: Published -// Description: Removes from this collection all of the InternalNames -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the InternalNames listed in the other + * collection. + */ void InternalNameCollection:: remove_names_from(const InternalNameCollection &other) { InternalNames new_names; @@ -139,14 +120,11 @@ remove_names_from(const InternalNameCollection &other) { _names = new_names; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::remove_duplicate_names -// Access: Published -// Description: Removes any duplicate entries of the same InternalNames -// on this collection. If a InternalName appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same InternalNames on this collection. + * If a InternalName appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void InternalNameCollection:: remove_duplicate_names() { InternalNames new_names; @@ -168,12 +146,10 @@ remove_duplicate_names() { _names = new_names; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::has_name -// Access: Published -// Description: Returns true if the indicated InternalName appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated InternalName appears in this collection, + * false otherwise. + */ bool InternalNameCollection:: has_name(const InternalName *name) const { for (int i = 0; i < get_num_names(); i++) { @@ -184,31 +160,25 @@ has_name(const InternalName *name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::clear -// Access: Published -// Description: Removes all InternalNames from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all InternalNames from the collection. + */ void InternalNameCollection:: clear() { _names.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::get_num_names -// Access: Published -// Description: Returns the number of InternalNames in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of InternalNames in the collection. + */ int InternalNameCollection:: get_num_names() const { return _names.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::get_name -// Access: Published -// Description: Returns the nth InternalName in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth InternalName in the collection. + */ const InternalName *InternalNameCollection:: get_name(int index) const { nassertr(index >= 0 && index < (int)_names.size(), NULL); @@ -216,13 +186,10 @@ get_name(int index) const { return _names[index]; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::operator [] -// Access: Published -// Description: Returns the nth InternalName in the collection. This is -// the same as get_name(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth InternalName in the collection. This is the same as + * get_name(), but it may be a more convenient way to access it. + */ const InternalName *InternalNameCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_names.size(), NULL); @@ -230,23 +197,19 @@ operator [] (int index) const { return _names[index]; } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::size -// Access: Published -// Description: Returns the number of names in the collection. This -// is the same thing as get_num_names(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of names in the collection. This is the same thing as + * get_num_names(). + */ int InternalNameCollection:: size() const { return _names.size(); } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// InternalNameCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the InternalNameCollection to the + * indicated output stream. + */ void InternalNameCollection:: output(ostream &out) const { if (get_num_names() == 1) { @@ -256,12 +219,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: InternalNameCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// InternalNameCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the InternalNameCollection to + * the indicated output stream. + */ void InternalNameCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_names(); i++) { diff --git a/panda/src/pgraph/internalNameCollection.h b/panda/src/pgraph/internalNameCollection.h index fbf59b5bbe..0c024cfaed 100644 --- a/panda/src/pgraph/internalNameCollection.h +++ b/panda/src/pgraph/internalNameCollection.h @@ -1,16 +1,15 @@ -// Filename: internalNameCollection.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file internalNameCollection.h + * @author drose + * @date 2002-03-16 + */ #ifndef INTERNALNAMECOLLECTION_H #define INTERNALNAMECOLLECTION_H @@ -19,10 +18,9 @@ #include "pointerToArray.h" #include "internalName.h" -//////////////////////////////////////////////////////////////////// -// Class : InternalNameCollection -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_PGRAPH InternalNameCollection { PUBLISHED: InternalNameCollection(); @@ -62,5 +60,3 @@ INLINE ostream &operator << (ostream &out, const InternalNameCollection &col) { #include "internalNameCollection.I" #endif - - diff --git a/panda/src/pgraph/lensNode.I b/panda/src/pgraph/lensNode.I index c6a252690a..fd7c67f192 100644 --- a/panda/src/pgraph/lensNode.I +++ b/panda/src/pgraph/lensNode.I @@ -1,61 +1,48 @@ -// Filename: lensNode.I -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lensNode.I + * @author drose + * @date 2002-02-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LensNode::copy_lens -// Access: Published -// Description: Sets up the LensNode using a copy of the -// indicated Lens. If the original Lens is -// changed or destroyed, this LensNode is not -// affected. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the LensNode using a copy of the indicated Lens. If the original + * Lens is changed or destroyed, this LensNode is not affected. + */ INLINE void LensNode:: copy_lens(const Lens &lens) { return copy_lens(0, lens); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::copy_lens -// Access: Published -// Description: Copies the indicated lens into the specified slot. -//////////////////////////////////////////////////////////////////// +/** + * Copies the indicated lens into the specified slot. + */ INLINE void LensNode:: copy_lens(int index, const Lens &lens) { set_lens(index, lens.make_copy()); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::set_lens -// Access: Published -// Description: Sets up the LensNode using this particular Lens -// pointer. If the lens is subsequently modified, the -// LensNode properties immediately reflect the change. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the LensNode using this particular Lens pointer. If the lens is + * subsequently modified, the LensNode properties immediately reflect the + * change. + */ INLINE void LensNode:: set_lens(Lens *lens) { return set_lens(0, lens); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::get_lens -// Access: Published -// Description: Returns a pointer to the particular Lens -// associated with this LensNode, or NULL if there is -// not yet a Lens associated. If an index number is -// specified, returns the nth lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular Lens associated with this LensNode, or + * NULL if there is not yet a Lens associated. If an index number is + * specified, returns the nth lens. + */ INLINE Lens *LensNode:: get_lens(int index) const { nassertr(index >= 0 && index < max_lenses, NULL); // Sanity check @@ -66,11 +53,9 @@ get_lens(int index) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::get_lens_active -// Access: Published -// Description: Returns the active flag for the nth lens. -//////////////////////////////////////////////////////////////////// +/** + * Returns the active flag for the nth lens. + */ INLINE bool LensNode:: get_lens_active(int index) const { nassertr(index >= 0 && index < max_lenses, false); @@ -81,37 +66,27 @@ get_lens_active(int index) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::activate_lens -// Access: Published -// Description: An alternate way to call set_lens_active(index, -// true). -//////////////////////////////////////////////////////////////////// +/** + * An alternate way to call set_lens_active(index, true). + */ INLINE bool LensNode:: activate_lens(int index) { return set_lens_active(index, true); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::deactivate_lens -// Access: Published -// Description: An alternate way to call set_lens_active(index, -// false). -//////////////////////////////////////////////////////////////////// +/** + * An alternate way to call set_lens_active(index, false). + */ INLINE bool LensNode:: deactivate_lens(int index) { return set_lens_active(index, false); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::is_in_view -// Access: Published -// Description: Returns true if the given point is within the bounds -// of the lens of the LensNode (i.e. if the camera can -// see the point). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given point is within the bounds of the lens of the + * LensNode (i.e. if the camera can see the point). + */ INLINE bool LensNode:: is_in_view(const LPoint3 &pos) { return is_in_view(0, pos); } - diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 46ca325058..108d482aa5 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -1,16 +1,15 @@ -// Filename: lensNode.cxx -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lensNode.cxx + * @author drose + * @date 2002-02-26 + */ #include "lensNode.h" #include "geometricBoundingVolume.h" @@ -23,11 +22,9 @@ TypeHandle LensNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LensNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LensNode:: LensNode(const string &name, Lens *lens) : PandaNode(name) @@ -38,11 +35,9 @@ LensNode(const string &name, Lens *lens) : set_lens(0, lens); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LensNode:: LensNode(const LensNode ©) : PandaNode(copy), @@ -50,42 +45,32 @@ LensNode(const LensNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::xform -// Access: Published, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void LensNode:: xform(const LMatrix4 &mat) { PandaNode::xform(mat); // We need to actually transform the lens here. } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::make_copy -// Access: Published, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *LensNode:: make_copy() const { return new LensNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::set_lens -// Access: Published -// Description: Sets the indicated lens. Although a LensNode -// normally holds only one lens, it may optionally -// include multiple lenses, each with a different index -// number. The different lenses may be referenced by -// index number on the DisplayRegion. Adding a new lens -// automatically makes it active. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated lens. Although a LensNode normally holds only one lens, + * it may optionally include multiple lenses, each with a different index + * number. The different lenses may be referenced by index number on the + * DisplayRegion. Adding a new lens automatically makes it active. + */ void LensNode:: set_lens(int index, Lens *lens) { nassertv(index >= 0 && index < max_lenses); // Sanity check @@ -95,7 +80,7 @@ set_lens(int index, Lens *lens) { slot._is_active = false; _lenses.push_back(slot); } - + _lenses[index]._lens = lens; _lenses[index]._is_active = true; @@ -104,15 +89,12 @@ set_lens(int index, Lens *lens) { } } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::set_lens_active -// Access: Published -// Description: Sets the active flag for the nth lens. When a lens -// is inactive, it is not used for rendering, and any -// DisplayRegions associated with it are implicitly -// inactive as well. Returns true if the flag is -// changed, false if it already had this value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the active flag for the nth lens. When a lens is inactive, it is not + * used for rendering, and any DisplayRegions associated with it are + * implicitly inactive as well. Returns true if the flag is changed, false if + * it already had this value. + */ bool LensNode:: set_lens_active(int index, bool flag) { nassertr(index >= 0 && index < max_lenses, false); @@ -135,13 +117,10 @@ set_lens_active(int index, bool flag) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::is_in_view -// Access: Published -// Description: Returns true if the given point is within the bounds -// of the lens of the LensNode (i.e. if the camera can -// see the point). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given point is within the bounds of the lens of the + * LensNode (i.e. if the camera can see the point). + */ bool LensNode:: is_in_view(int index, const LPoint3 &pos) { Lens *lens = get_lens(index); @@ -155,13 +134,10 @@ is_in_view(int index, const LPoint3 &pos) { return (ret != 0); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::show_frustum -// Access: Published -// Description: Enables the drawing of the lens's frustum to aid in -// visualization. This actually creates a GeomNode -// which is parented to the LensNode. -//////////////////////////////////////////////////////////////////// +/** + * Enables the drawing of the lens's frustum to aid in visualization. This + * actually creates a GeomNode which is parented to the LensNode. + */ void LensNode:: show_frustum() { if (_shown_frustum != (PandaNode *)NULL) { @@ -180,12 +156,9 @@ show_frustum() { } } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::hide_frustum -// Access: Published -// Description: Disables the drawing of the lens's frustum to aid in -// visualization. -//////////////////////////////////////////////////////////////////// +/** + * Disables the drawing of the lens's frustum to aid in visualization. + */ void LensNode:: hide_frustum() { if (_shown_frustum != (PandaNode *)NULL) { @@ -194,11 +167,9 @@ hide_frustum() { } } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LensNode:: output(ostream &out) const { PandaNode::output(out); @@ -215,11 +186,9 @@ output(ostream &out) const { out << " )"; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LensNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); @@ -233,40 +202,31 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LensNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type LensNode. + */ void LensNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LensNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); - // For now, we only write out lens 0, simply because that's what we - // always have done. Should probably write out all lenses for the - // future. + // For now, we only write out lens 0, simply because that's what we always + // have done. Should probably write out all lenses for the future. manager->write_pointer(dg, get_lens(0)); } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int LensNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -274,14 +234,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type LensNode is encountered -// in the Bam file. It should create the LensNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type LensNode is encountered in the Bam file. It should create the + * LensNode and extract its information from the file. + */ TypedWritable *LensNode:: make_from_bam(const FactoryParams ¶ms) { LensNode *node = new LensNode(""); @@ -294,13 +251,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: LensNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LensNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LensNode. + */ void LensNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/lensNode.h b/panda/src/pgraph/lensNode.h index 1db8b193b5..dead36fbe3 100644 --- a/panda/src/pgraph/lensNode.h +++ b/panda/src/pgraph/lensNode.h @@ -1,16 +1,15 @@ -// Filename: lensNode.h -// Created by: drose (26Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lensNode.h + * @author drose + * @date 2002-02-26 + */ #ifndef LENSNODE_H #define LENSNODE_H @@ -22,13 +21,11 @@ #include "perspectiveLens.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : LensNode -// Description : A node that contains a Lens. The most important -// example of this kind of node is a Camera, but other -// kinds of nodes also contain a lens (for instance, a -// Spotlight). -//////////////////////////////////////////////////////////////////// +/** + * A node that contains a Lens. The most important example of this kind of + * node is a Camera, but other kinds of nodes also contain a lens (for + * instance, a Spotlight). + */ class EXPCL_PANDA_PGRAPH LensNode : public PandaNode { PUBLISHED: LensNode(const string &name, Lens *lens = NULL); @@ -48,7 +45,7 @@ PUBLISHED: INLINE void set_lens(Lens *lens); void set_lens(int index, Lens *lens); INLINE Lens *get_lens(int index = 0) const; - + bool set_lens_active(int index, bool active); INLINE bool get_lens_active(int index) const; @@ -72,7 +69,7 @@ protected: typedef pvector Lenses; Lenses _lenses; - + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); diff --git a/panda/src/pgraph/light.I b/panda/src/pgraph/light.I index 2ca49d2315..4b84c409aa 100644 --- a/panda/src/pgraph/light.I +++ b/panda/src/pgraph/light.I @@ -1,23 +1,19 @@ -// Filename: light.I -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file light.I + * @author drose + * @date 2002-03-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Light::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Light::CData:: CData() : _color(1.0f, 1.0f, 1.0f, 1.0f), @@ -25,11 +21,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: Light::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Light::CData:: CData(const Light::CData ©) : _color(copy._color), @@ -38,11 +32,9 @@ CData(const Light::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Light::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Light:: Light() : _priority(0), @@ -51,11 +43,9 @@ Light() : { } -//////////////////////////////////////////////////////////////////// -// Function: Light::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Light:: Light(const Light ©) : _priority(copy._priority), @@ -65,22 +55,18 @@ Light(const Light ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_color -// Access: Published -// Description: Returns the basic color of the light. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basic color of the light. + */ INLINE const LColor &Light:: get_color() const { CDReader cdata(_cycler); return cdata->_color; } -//////////////////////////////////////////////////////////////////// -// Function: Light::set_color -// Access: Published -// Description: Sets the basic color of the light. -//////////////////////////////////////////////////////////////////// +/** + * Sets the basic color of the light. + */ INLINE void Light:: set_color(const LColor &color) { CDWriter cdata(_cycler); @@ -89,85 +75,65 @@ set_color(const LColor &color) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: Light::has_color_temperature -// Access: Published -// Description: Returns true if the color was specified as a -// temperature in kelvins, and get_color_temperature -// is defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the color was specified as a temperature in kelvins, and + * get_color_temperature is defined. + */ INLINE bool Light:: has_color_temperature() const { return _has_color_temperature; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_color_temperature -// Access: Published -// Description: Returns the basic color temperature of the light, -// assuming has_color_temperature() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basic color temperature of the light, assuming + * has_color_temperature() returns true. + */ INLINE PN_stdfloat Light:: get_color_temperature() const { nassertr(_has_color_temperature, _color_temperature); return _color_temperature; } -//////////////////////////////////////////////////////////////////// -// Function: Light::set_priority -// Access: Published -// Description: Changes the relative importance of this light -// relative to the other lights that are applied -// simultaneously. -// -// The priority number is used to decide which of the -// requested lights are to be selected for rendering -// when more lights are requested than the hardware will -// support. The highest-priority n lights are selected -// for rendering. -// -// This is similar to TextureStage::set_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the relative importance of this light relative to the other lights + * that are applied simultaneously. + * + * The priority number is used to decide which of the requested lights are to + * be selected for rendering when more lights are requested than the hardware + * will support. The highest-priority n lights are selected for rendering. + * + * This is similar to TextureStage::set_priority(). + */ INLINE void Light:: set_priority(int priority) { _priority = priority; - // Update the global flag to indicate that all LightAttribs in the - // world must now re-sort their lists. + // Update the global flag to indicate that all LightAttribs in the world + // must now re-sort their lists. _sort_seq++; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_priority -// Access: Published -// Description: Returns the priority associated with this light. See -// set_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the priority associated with this light. See set_priority(). + */ INLINE int Light:: get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_sort_seq -// Access: Public, Static -// Description: Returns a global sequence number that is incremented -// any time any Light in the world changes sort -// or priority. This is used by LightAttrib to -// determine when it is necessary to re-sort its -// internal array of stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns a global sequence number that is incremented any time any Light in + * the world changes sort or priority. This is used by LightAttrib to + * determine when it is necessary to re-sort its internal array of stages. + */ INLINE UpdateSeq Light:: get_sort_seq() { return _sort_seq; } -//////////////////////////////////////////////////////////////////// -// Function: Light::mark_viz_stale -// Access: Protected -// Description: Indicates that the internal visualization object will -// need to be updated. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the internal visualization object will need to be updated. + */ INLINE void Light:: mark_viz_stale() { CDWriter cdata(_cycler); diff --git a/panda/src/pgraph/light.cxx b/panda/src/pgraph/light.cxx index 1a2ea89095..705469591e 100644 --- a/panda/src/pgraph/light.cxx +++ b/panda/src/pgraph/light.cxx @@ -1,16 +1,15 @@ -// Filename: light.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file light.cxx + * @author mike + * @date 1997-01-09 + */ #include "light.h" #include "bamWriter.h" @@ -23,68 +22,55 @@ UpdateSeq Light::_sort_seq; TypeHandle Light::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Light::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Light::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Light::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Light::CData:: write_datagram(BamWriter *, Datagram &dg) const { _color.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: Light::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void Light::CData:: fillin(DatagramIterator &scan, BamReader *) { _color.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: Light::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Light:: ~Light() { } -//////////////////////////////////////////////////////////////////// -// Function: Light::is_ambient_light -// Access: Published, Virtual -// Description: Returns true if this is an AmbientLight, false if it -// is some other kind of light. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an AmbientLight, false if it is some other kind of + * light. + */ bool Light:: is_ambient_light() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Light::set_color_temperature -// Access: Published -// Description: Sets the color temperature of the light in kelvins. -// This will recalculate the light's color. -// -// The default value is 6500 K, corresponding to a -// perfectly white light assuming a D65 white point. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color temperature of the light in kelvins. This will recalculate + * the light's color. + * + * The default value is 6500 K, corresponding to a perfectly white light + * assuming a D65 white point. + */ void Light:: set_color_temperature(PN_stdfloat temperature) { if (_has_color_temperature && _color_temperature == temperature) { @@ -140,74 +126,59 @@ set_color_temperature(PN_stdfloat temperature) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_exponent -// Access: Public, Virtual -// Description: For spotlights, returns the exponent that controls -// the amount of light falloff from the center of the -// spotlight. For other kinds of lights, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * For spotlights, returns the exponent that controls the amount of light + * falloff from the center of the spotlight. For other kinds of lights, + * returns 0. + */ PN_stdfloat Light:: get_exponent() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_specular_color -// Access: Public, Virtual -// Description: Returns the color of specular highlights generated -// by the light. This value is meaningless for ambient -// lights. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of specular highlights generated by the light. This + * value is meaningless for ambient lights. + */ const LColor &Light:: get_specular_color() const { static const LColor white(1, 1, 1, 1); return white; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_attenuation -// Access: Public, Virtual -// Description: Returns the terms of the attenuation equation for the -// light. These are, in order, the constant, linear, -// and quadratic terms based on the distance from the -// point to the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the terms of the attenuation equation for the light. These are, in + * order, the constant, linear, and quadratic terms based on the distance from + * the point to the vertex. + */ const LVecBase3 &Light:: get_attenuation() const { static const LVecBase3 no_atten(1, 0, 0); return no_atten; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_vector_to_light -// Access: Public, Virtual -// Description: Computes the vector from a particular vertex to this -// light. The exact vector depends on the type of light -// (e.g. point lights return a different result than -// directional lights). -// -// The input parameters are the vertex position in -// question, expressed in object space, and the matrix -// which converts from light space to object space. The -// result is expressed in object space. -// -// The return value is true if the result is successful, -// or false if it cannot be computed (e.g. for an -// ambient light). -//////////////////////////////////////////////////////////////////// +/** + * Computes the vector from a particular vertex to this light. The exact + * vector depends on the type of light (e.g. point lights return a different + * result than directional lights). + * + * The input parameters are the vertex position in question, expressed in + * object space, and the matrix which converts from light space to object + * space. The result is expressed in object space. + * + * The return value is true if the result is successful, or false if it cannot + * be computed (e.g. for an ambient light). + */ bool Light:: get_vector_to_light(LVector3 &, const LPoint3 &, const LMatrix4 &) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Light::get_viz -// Access: Public -// Description: Returns a GeomNode that may be rendered to visualize -// the Light. This is used during the cull traversal to -// render the Lights that have been made visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomNode that may be rendered to visualize the Light. This is + * used during the cull traversal to render the Lights that have been made + * visible. + */ GeomNode *Light:: get_viz() { CDLockedReader cdata(_cycler); @@ -221,22 +192,18 @@ get_viz() { return cdata->_viz_geom; } -//////////////////////////////////////////////////////////////////// -// Function: Light::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the indicated GeomNode up with Geoms suitable -// for rendering this light. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated GeomNode up with Geoms suitable for rendering this + * light. + */ void Light:: fill_viz_geom(GeomNode *) { } -//////////////////////////////////////////////////////////////////// -// Function: Light::write_datagram -// Access: Protected -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Light:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_has_color_temperature); @@ -248,13 +215,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int32(_priority); } -//////////////////////////////////////////////////////////////////// -// Function: Light::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void Light:: fillin(DatagramIterator &scan, BamReader *manager) { if (manager->get_file_minor_ver() >= 39) { diff --git a/panda/src/pgraph/light.h b/panda/src/pgraph/light.h index 0765a920c3..05fa4c10f6 100644 --- a/panda/src/pgraph/light.h +++ b/panda/src/pgraph/light.h @@ -1,16 +1,15 @@ -// Filename: light.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file light.h + * @author mike + * @date 1997-01-09 + */ #ifndef LIGHT_H #define LIGHT_H @@ -31,14 +30,11 @@ class NodePath; class PandaNode; class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : Light -// Description : The abstract interface to all kinds of lights. The -// actual light objects also inherit from PandaNode, and -// can therefore be added to the scene graph at some -// arbitrary point to define the coordinate system of -// effect. -//////////////////////////////////////////////////////////////////// +/** + * The abstract interface to all kinds of lights. The actual light objects + * also inherit from PandaNode, and can therefore be added to the scene graph + * at some arbitrary point to define the coordinate system of effect. + */ class EXPCL_PANDA_PGRAPH Light { PUBLISHED: INLINE Light(); @@ -85,11 +81,10 @@ protected: virtual void fill_viz_geom(GeomNode *viz_geom); INLINE void mark_viz_stale(); - // This enumerated class defines the relative class priority of - // different kinds of lights. This hierarchy is only used to - // resolve multiple lights of the same priority specified by - // set_priority(). In general, the first items in this list have a - // lesser priority than later items. + // This enumerated class defines the relative class priority of different + // kinds of lights. This hierarchy is only used to resolve multiple lights + // of the same priority specified by set_priority(). In general, the first + // items in this list have a lesser priority than later items. enum ClassPriority { CP_ambient_priority, CP_point_priority, @@ -98,14 +93,13 @@ protected: }; private: - // The priority is not cycled, because there's no real reason to do - // so, and cycling it makes it difficult to synchronize with the - // LightAttribs. + // The priority is not cycled, because there's no real reason to do so, and + // cycling it makes it difficult to synchronize with the LightAttribs. int _priority; static UpdateSeq _sort_seq; - // The color temperature is not cycled either, because we only need - // to pass down the computed color anyway. + // The color temperature is not cycled either, because we only need to pass + // down the computed color anyway. bool _has_color_temperature; PN_stdfloat _color_temperature; diff --git a/panda/src/pgraph/lightAttrib.I b/panda/src/pgraph/lightAttrib.I index 2e644bb3a8..5281acc1a3 100644 --- a/panda/src/pgraph/lightAttrib.I +++ b/panda/src/pgraph/lightAttrib.I @@ -1,36 +1,28 @@ -// Filename: lightAttrib.I -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightAttrib.I + * @author drose + * @date 2002-03-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::Constructor -// Access: Protected -// Description: Use LightAttrib::make() to construct a new -// LightAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use LightAttrib::make() to construct a new LightAttrib object. + */ INLINE LightAttrib:: LightAttrib() { _off_all_lights = false; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::Copy Constructor -// Access: Protected -// Description: Use LightAttrib::make() to construct a new -// LightAttrib object. The copy constructor is only -// defined to facilitate methods like add_on_light(). -//////////////////////////////////////////////////////////////////// +/** + * Use LightAttrib::make() to construct a new LightAttrib object. The copy + * constructor is only defined to facilitate methods like add_on_light(). + */ INLINE LightAttrib:: LightAttrib(const LightAttrib ©) : _on_lights(copy._on_lights), @@ -39,107 +31,84 @@ LightAttrib(const LightAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_num_on_lights -// Access: Published -// Description: Returns the number of lights that are turned on by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of lights that are turned on by the attribute. + */ INLINE int LightAttrib:: get_num_on_lights() const { return _on_lights.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_on_light -// Access: Published -// Description: Returns the nth light turned on by the attribute, -// sorted in render order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth light turned on by the attribute, sorted in render order. + */ INLINE NodePath LightAttrib:: get_on_light(int n) const { nassertr(n >= 0 && n < (int)_on_lights.size(), NodePath::fail()); return _on_lights[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::has_on_light -// Access: Published -// Description: Returns true if the indicated light is turned on by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated light is turned on by the attrib, false + * otherwise. + */ INLINE bool LightAttrib:: has_on_light(const NodePath &light) const { return _on_lights.find(light) != _on_lights.end(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_num_off_lights -// Access: Published -// Description: Returns the number of lights that are turned off by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of lights that are turned off by the attribute. + */ INLINE int LightAttrib:: get_num_off_lights() const { return _off_lights.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_off_light -// Access: Published -// Description: Returns the nth light turned off by the attribute, -// sorted in arbitrary (pointer) order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth light turned off by the attribute, sorted in arbitrary + * (pointer) order. + */ INLINE NodePath LightAttrib:: get_off_light(int n) const { nassertr(n >= 0 && n < (int)_off_lights.size(), NodePath::fail()); return _off_lights[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::has_off_light -// Access: Published -// Description: Returns true if the indicated light is turned off by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated light is turned off by the attrib, false + * otherwise. + */ INLINE bool LightAttrib:: has_off_light(const NodePath &light) const { return _off_lights.find(light) != _off_lights.end() || (_off_all_lights && !has_on_light(light)); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::has_all_off -// Access: Published -// Description: Returns true if this attrib turns off all lights -// (although it may also turn some on). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this attrib turns off all lights (although it may also turn + * some on). + */ INLINE bool LightAttrib:: has_all_off() const { return _off_all_lights; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::is_identity -// Access: Published -// Description: Returns true if this is an identity attrib: it does -// not change the set of lights in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an identity attrib: it does not change the set of + * lights in use. + */ INLINE bool LightAttrib:: is_identity() const { return _on_lights.empty() && _off_lights.empty() && !_off_all_lights; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::check_filtered -// Access: Private -// Description: Confirms whether the _filtered table is still valid. -// It may become invalid if someone calls -// Light::set_priority(). -// -// If the table is invalid, transparently empties it -// before returning. -//////////////////////////////////////////////////////////////////// +/** + * Confirms whether the _filtered table is still valid. It may become invalid + * if someone calls Light::set_priority(). + * + * If the table is invalid, transparently empties it before returning. + */ INLINE void LightAttrib:: check_filtered() const { if (_sort_seq != Light::get_sort_seq()) { diff --git a/panda/src/pgraph/lightAttrib.cxx b/panda/src/pgraph/lightAttrib.cxx index 59a83e10cb..459d3e6991 100644 --- a/panda/src/pgraph/lightAttrib.cxx +++ b/panda/src/pgraph/lightAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: lightAttrib.cxx -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightAttrib.cxx + * @author drose + * @date 2002-03-26 + */ #include "lightAttrib.h" #include "pandaNode.h" @@ -30,9 +29,9 @@ int LightAttrib::_attrib_slot; CPT(RenderAttrib) LightAttrib::_all_off_attrib; TypeHandle LightAttrib::_type_handle; -// This STL Function object is used in filter_to_max(), below, to sort -// a list of Lights in reverse order by priority. In the case of two -// lights with equal priority, the class priority is compared. +// This STL Function object is used in filter_to_max(), below, to sort a list +// of Lights in reverse order by priority. In the case of two lights with +// equal priority, the class priority is compared. class CompareLightPriorities { public: bool operator ()(const NodePath &a, const NodePath &b) const { @@ -40,7 +39,7 @@ public: Light *la = a.node()->as_light(); Light *lb = b.node()->as_light(); nassertr(la != (Light *)NULL && lb != (Light *)NULL, a < b); - + if (la->get_priority() != lb->get_priority()) { return la->get_priority() > lb->get_priority(); } @@ -48,15 +47,13 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make -// Access: Published, Static -// Description: Constructs a new LightAttrib object that turns on (or -// off, according to op) the indicated light(s). -// -// This method is now deprecated. Use add_on_light() or -// add_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that turns on (or off, according to op) + * the indicated light(s). + * + * This method is now deprecated. Use add_on_light() or add_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: make(LightAttrib::Operation op, Light *light) { pgraph_cat.warning() @@ -69,7 +66,7 @@ make(LightAttrib::Operation op, Light *light) { attrib = make_all_off(); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light->as_node())); return attrib; - + case O_add: attrib = make(); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light->as_node())); @@ -85,15 +82,13 @@ make(LightAttrib::Operation op, Light *light) { return make(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make -// Access: Published, Static -// Description: Constructs a new LightAttrib object that turns on (or -// off, according to op) the indicate light(s). -// -// This method is now deprecated. Use add_on_light() or -// add_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that turns on (or off, according to op) + * the indicate light(s). + * + * This method is now deprecated. Use add_on_light() or add_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: make(LightAttrib::Operation op, Light *light1, Light *light2) { pgraph_cat.warning() @@ -107,7 +102,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2) { attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light1->as_node())); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light2->as_node())); return attrib; - + case O_add: attrib = make(); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light1->as_node())); @@ -125,18 +120,16 @@ make(LightAttrib::Operation op, Light *light1, Light *light2) { return make(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make -// Access: Published, Static -// Description: Constructs a new LightAttrib object that turns on (or -// off, according to op) the indicate light(s). -// -// This method is now deprecated. Use add_on_light() or -// add_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that turns on (or off, according to op) + * the indicate light(s). + * + * This method is now deprecated. Use add_on_light() or add_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: make(LightAttrib::Operation op, Light *light1, Light *light2, - Light *light3) { + Light *light3) { pgraph_cat.warning() << "Using deprecated LightAttrib interface.\n"; @@ -149,7 +142,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light2->as_node())); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light3->as_node())); return attrib; - + case O_add: attrib = make(); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light1->as_node())); @@ -169,15 +162,13 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, return make(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make -// Access: Published, Static -// Description: Constructs a new LightAttrib object that turns on (or -// off, according to op) the indicate light(s). -// -// This method is now deprecated. Use add_on_light() or -// add_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that turns on (or off, according to op) + * the indicate light(s). + * + * This method is now deprecated. Use add_on_light() or add_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: make(LightAttrib::Operation op, Light *light1, Light *light2, Light *light3, Light *light4) { @@ -194,7 +185,7 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light3->as_node())); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light4->as_node())); return attrib; - + case O_add: attrib = make(); attrib = DCAST(LightAttrib, attrib)->add_on_light(NodePath(light1->as_node())); @@ -216,34 +207,26 @@ make(LightAttrib::Operation op, Light *light1, Light *light2, return make(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) LightAttrib:: make_default() { return return_new(new LightAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_operation -// Access: Published -// Description: Returns the basic operation type of the LightAttrib. -// If this is O_set, the lights listed here completely -// replace any lights that were already on. If this is -// O_add, the lights here are added to the set of of -// lights that were already on, and if O_remove, the -// lights here are removed from the set of lights that -// were on. -// -// This method is now deprecated. LightAttribs nowadays -// have a separate list of on_lights and off_lights, so -// this method doesn't make sense. Query the lists -// independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basic operation type of the LightAttrib. If this is O_set, the + * lights listed here completely replace any lights that were already on. If + * this is O_add, the lights here are added to the set of of lights that were + * already on, and if O_remove, the lights here are removed from the set of + * lights that were on. + * + * This method is now deprecated. LightAttribs nowadays have a separate list + * of on_lights and off_lights, so this method doesn't make sense. Query the + * lists independently. + */ LightAttrib::Operation LightAttrib:: get_operation() const { pgraph_cat.warning() @@ -260,16 +243,13 @@ get_operation() const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_num_lights -// Access: Published -// Description: Returns the number of lights listed in the attribute. -// -// This method is now deprecated. LightAttribs nowadays -// have a separate list of on_lights and off_lights, so -// this method doesn't make sense. Query the lists -// independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of lights listed in the attribute. + * + * This method is now deprecated. LightAttribs nowadays have a separate list + * of on_lights and off_lights, so this method doesn't make sense. Query the + * lists independently. + */ int LightAttrib:: get_num_lights() const { pgraph_cat.warning() @@ -282,16 +262,13 @@ get_num_lights() const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_light -// Access: Published -// Description: Returns the nth light listed in the attribute. -// -// This method is now deprecated. LightAttribs nowadays -// have a separate list of on_lights and off_lights, so -// this method doesn't make sense. Query the lists -// independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth light listed in the attribute. + * + * This method is now deprecated. LightAttribs nowadays have a separate list + * of on_lights and off_lights, so this method doesn't make sense. Query the + * lists independently. + */ Light *LightAttrib:: get_light(int n) const { pgraph_cat.warning() @@ -304,17 +281,14 @@ get_light(int n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::has_light -// Access: Published -// Description: Returns true if the indicated light is listed in the -// attrib, false otherwise. -// -// This method is now deprecated. LightAttribs nowadays -// have a separate list of on_lights and off_lights, so -// this method doesn't make sense. Query the lists -// independently. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated light is listed in the attrib, false + * otherwise. + * + * This method is now deprecated. LightAttribs nowadays have a separate list + * of on_lights and off_lights, so this method doesn't make sense. Query the + * lists independently. + */ bool LightAttrib:: has_light(Light *light) const { pgraph_cat.warning() @@ -327,15 +301,13 @@ has_light(Light *light) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::add_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light added to the list of lights. -// -// This method is now deprecated. Use add_on_light() or -// add_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * added to the list of lights. + * + * This method is now deprecated. Use add_on_light() or add_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: add_light(Light *light) const { pgraph_cat.warning() @@ -348,16 +320,13 @@ add_light(Light *light) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::remove_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light removed from the list of -// lights. -// -// This method is now deprecated. Use remove_on_light() -// or remove_off_light() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * removed from the list of lights. + * + * This method is now deprecated. Use remove_on_light() or remove_off_light() + * instead. + */ CPT(RenderAttrib) LightAttrib:: remove_light(Light *light) const { pgraph_cat.warning() @@ -370,16 +339,13 @@ remove_light(Light *light) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make -// Access: Published, Static -// Description: Constructs a new LightAttrib object that does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that does nothing. + */ CPT(RenderAttrib) LightAttrib:: make() { - // We make it a special case and store a pointer to the empty attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty attrib forever + // once we find it the first time, as an optimization. if (_empty_attrib == (RenderAttrib *)NULL) { _empty_attrib = return_new(new LightAttrib); } @@ -387,16 +353,14 @@ make() { return _empty_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make_all_off -// Access: Published, Static -// Description: Constructs a new LightAttrib object that turns off -// all lights (and hence disables lighting). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightAttrib object that turns off all lights (and hence + * disables lighting). + */ CPT(RenderAttrib) LightAttrib:: make_all_off() { - // We make it a special case and store a pointer to the off attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the off attrib forever + // once we find it the first time, as an optimization. if (_all_off_attrib == (RenderAttrib *)NULL) { LightAttrib *attrib = new LightAttrib; attrib->_off_all_lights = true; @@ -406,13 +370,10 @@ make_all_off() { return _all_off_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::add_on_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light added to the list of lights -// turned on by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * added to the list of lights turned on by this attrib. + */ CPT(RenderAttrib) LightAttrib:: add_on_light(const NodePath &light) const { nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); @@ -420,7 +381,7 @@ add_on_light(const NodePath &light) const { attrib->_on_lights.insert(light); attrib->_off_lights.erase(light); - pair insert_result = + pair insert_result = attrib->_on_lights.insert(Lights::value_type(light)); if (insert_result.second) { // Also ensure it is removed from the off_lights list. @@ -430,13 +391,10 @@ add_on_light(const NodePath &light) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::remove_on_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light removed from the list of -// lights turned on by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * removed from the list of lights turned on by this attrib. + */ CPT(RenderAttrib) LightAttrib:: remove_on_light(const NodePath &light) const { nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); @@ -445,13 +403,10 @@ remove_on_light(const NodePath &light) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::add_off_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light added to the list of lights -// turned off by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * added to the list of lights turned off by this attrib. + */ CPT(RenderAttrib) LightAttrib:: add_off_light(const NodePath &light) const { nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); @@ -463,13 +418,10 @@ add_off_light(const NodePath &light) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::remove_off_light -// Access: Published -// Description: Returns a new LightAttrib, just like this one, but -// with the indicated light removed from the list of -// lights turned off by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, just like this one, but with the indicated light + * removed from the list of lights turned off by this attrib. + */ CPT(RenderAttrib) LightAttrib:: remove_off_light(const NodePath &light) const { nassertr(!light.is_empty() && light.node()->as_light() != (Light *)NULL, this); @@ -478,19 +430,15 @@ remove_off_light(const NodePath &light) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::filter_to_max -// Access: Public -// Description: Returns a new LightAttrib, very much like this one, -// but with the number of on_lights reduced to be no -// more than max_lights. The number of off_lights in -// the new LightAttrib is undefined. -// -// The number of AmbientLights is not included in the -// count. All AmbientLights in the original attrib are -// always included in the result, regardless of the -// value of max_lights. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new LightAttrib, very much like this one, but with the number of + * on_lights reduced to be no more than max_lights. The number of off_lights + * in the new LightAttrib is undefined. + * + * The number of AmbientLights is not included in the count. All + * AmbientLights in the original attrib are always included in the result, + * regardless of the value of max_lights. + */ CPT(LightAttrib) LightAttrib:: filter_to_max(int max_lights) const { if (max_lights < 0 || (int)_on_lights.size() <= max_lights) { @@ -498,8 +446,8 @@ filter_to_max(int max_lights) const { return this; } - // Since check_filtered() will clear the _filtered list if we are out - // of date, we should call it first. + // Since check_filtered() will clear the _filtered list if we are out of + // date, we should call it first. check_filtered(); Filtered::const_iterator fi; @@ -510,8 +458,8 @@ filter_to_max(int max_lights) const { return (*fi).second; } - // Harder case: we have to compute it now. We must choose the n - // lights with the highest priority in our list of lights. + // Harder case: we have to compute it now. We must choose the n lights with + // the highest priority in our list of lights. Lights priority_lights, ambient_lights; // Separate the list of lights into ambient lights and other lights. @@ -527,11 +475,11 @@ filter_to_max(int max_lights) const { } // This sort function uses the STL function object defined above. - sort(priority_lights.begin(), priority_lights.end(), + sort(priority_lights.begin(), priority_lights.end(), CompareLightPriorities()); // Now lop off all of the lights after the first max_lights. - if ((int)priority_lights.size() > max_lights) { + if ((int)priority_lights.size() > max_lights) { priority_lights.erase(priority_lights.begin() + max_lights, priority_lights.end()); } @@ -550,21 +498,17 @@ filter_to_max(int max_lights) const { CPT(RenderAttrib) new_attrib = return_new(attrib); - // Finally, record this newly-created attrib in the map for next - // time. + // Finally, record this newly-created attrib in the map for next time. CPT(LightAttrib) light_attrib = (const LightAttrib *)new_attrib.p(); ((LightAttrib *)this)->_filtered[max_lights] = light_attrib; return light_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_most_important_light -// Access: Public -// Description: Returns the most important light (that is, the light -// with the highest priority) in the LightAttrib, -// excluding any ambient lights. Returns an empty -// NodePath if no non-ambient lights are found. -//////////////////////////////////////////////////////////////////// +/** + * Returns the most important light (that is, the light with the highest + * priority) in the LightAttrib, excluding any ambient lights. Returns an + * empty NodePath if no non-ambient lights are found. + */ NodePath LightAttrib:: get_most_important_light() const { NodePath best; @@ -585,11 +529,9 @@ get_most_important_light() const { return best; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -617,14 +559,14 @@ output(ostream &out) const { out << " " << light; } else { out << " " << light.get_name(); - } + } } if (!_on_lights.empty()) { out << " on"; } } - + Lights::const_iterator li; for (li = _on_lights.begin(); li != _on_lights.end(); ++li) { NodePath light = (*li); @@ -632,15 +574,13 @@ output(ostream &out) const { out << " " << light; } else { out << " " << light.get_name(); - } + } } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightAttrib:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_type() << ":"; @@ -671,7 +611,7 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "on\n"; } } - + Lights::const_iterator li; for (li = _on_lights.begin(); li != _on_lights.end(); ++li) { NodePath light = (*li); @@ -679,21 +619,17 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived LightAttrib -// types to return a unique number indicating whether -// this LightAttrib is equivalent to the other one. -// -// This should return 0 if the two LightAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two LightAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived LightAttrib types to return a unique + * number indicating whether this LightAttrib is equivalent to the other one. + * + * This should return 0 if the two LightAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two LightAttrib objects whose get_type() + * functions return the same. + */ int LightAttrib:: compare_to_impl(const RenderAttrib *other) const { const LightAttrib *ta = (const LightAttrib *)other; @@ -747,20 +683,16 @@ compare_to_impl(const RenderAttrib *other) const { if (ofi != ta->_off_lights.end()) { return -1; } - + return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t LightAttrib:: get_hash_impl() const { size_t hash = 0; @@ -771,8 +703,8 @@ get_hash_impl() const { hash = light.add_hash(hash); } - // This bool value goes here, between the two lists, to - // differentiate between the two. + // This bool value goes here, between the two lists, to differentiate + // between the two. hash = int_hash::add_hash(hash, (int)_off_all_lights); for (li = _off_lights.begin(); li != _off_lights.end(); ++li) { @@ -783,71 +715,64 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) LightAttrib:: compose_impl(const RenderAttrib *other) const { const LightAttrib *ta = (const LightAttrib *)other; if (ta->_off_all_lights) { - // If the other type turns off all lights, it doesn't matter what - // we are. + // If the other type turns off all lights, it doesn't matter what we are. return ta; } - // This is a three-way merge between ai, bi, and ci, except that bi - // and ci should have no intersection and therefore needn't be - // compared to each other. + // This is a three-way merge between ai, bi, and ci, except that bi and ci + // should have no intersection and therefore needn't be compared to each + // other. Lights::const_iterator ai = _on_lights.begin(); Lights::const_iterator bi = ta->_on_lights.begin(); Lights::const_iterator ci = ta->_off_lights.begin(); // Create a new LightAttrib that will hold the result. LightAttrib *new_attrib = new LightAttrib; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_attrib->_on_lights); - while (ai != _on_lights.end() && - bi != ta->_on_lights.end() && + while (ai != _on_lights.end() && + bi != ta->_on_lights.end() && ci != ta->_off_lights.end()) { if ((*ai) < (*bi)) { if ((*ai) < (*ci)) { - // Here is a light that we have in the original, which is not - // present in the secondary. + // Here is a light that we have in the original, which is not present + // in the secondary. *result = *ai; ++ai; ++result; } else if ((*ci) < (*ai)) { - // Here is a light that is turned off in the secondary, but - // was not present in the original. + // Here is a light that is turned off in the secondary, but was not + // present in the original. ++ci; } else { // (*ci) == (*ai) - // Here is a light that is turned off in the secondary, and - // was present in the original. + // Here is a light that is turned off in the secondary, and was + // present in the original. ++ai; ++ci; } } else if ((*bi) < (*ai)) { - // Here is a new light we have in the secondary, that was not - // present in the original. + // Here is a new light we have in the secondary, that was not present in + // the original. *result = *bi; ++bi; ++result; @@ -863,15 +788,15 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_lights.end() && bi != ta->_on_lights.end()) { if ((*ai) < (*bi)) { - // Here is a light that we have in the original, which is not - // present in the secondary. + // Here is a light that we have in the original, which is not present in + // the secondary. *result = *ai; ++ai; ++result; } else if ((*bi) < (*ai)) { - // Here is a new light we have in the secondary, that was not - // present in the original. + // Here is a new light we have in the secondary, that was not present in + // the original. *result = *bi; ++bi; ++result; @@ -887,20 +812,20 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_lights.end() && ci != ta->_off_lights.end()) { if ((*ai) < (*ci)) { - // Here is a light that we have in the original, which is not - // present in the secondary. + // Here is a light that we have in the original, which is not present in + // the secondary. *result = *ai; ++ai; ++result; - + } else if ((*ci) < (*ai)) { - // Here is a light that is turned off in the secondary, but - // was not present in the original. + // Here is a light that is turned off in the secondary, but was not + // present in the original. ++ci; - + } else { // (*ci) == (*ai) - // Here is a light that is turned off in the secondary, and - // was present in the original. + // Here is a light that is turned off in the secondary, and was present + // in the original. ++ai; ++ci; } @@ -921,64 +846,50 @@ compose_impl(const RenderAttrib *other) const { return return_new(new_attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) LightAttrib:: invert_compose_impl(const RenderAttrib *other) const { - // I think in this case the other attrib always wins. Maybe this - // needs a bit more thought. It's hard to imagine that it's even - // important to compute this properly. + // I think in this case the other attrib always wins. Maybe this needs a + // bit more thought. It's hard to imagine that it's even important to + // compute this properly. return other; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) LightAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::sort_on_lights -// Access: Private -// Description: This is patterned after -// TextureAttrib::sort_on_stages(), but since lights -// don't actually require sorting, this only empties the -// _filtered map. -//////////////////////////////////////////////////////////////////// +/** + * This is patterned after TextureAttrib::sort_on_stages(), but since lights + * don't actually require sorting, this only empties the _filtered map. + */ void LightAttrib:: sort_on_lights() { _sort_seq = Light::get_sort_seq(); _filtered.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LightAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type LightAttrib. + */ void LightAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LightAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -1002,13 +913,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int LightAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -1045,13 +953,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void LightAttrib:: finalize(BamReader *manager) { if (manager->get_file_minor_ver() >= 40) { @@ -1093,8 +999,7 @@ finalize(BamReader *manager) { // If it's in the registry, add that NodePath. _off_lights.push_back(areg->get_node(n)); } else { - // Otherwise, add any arbitrary NodePath. Complain if it's - // ambiguous. + // Otherwise, add any arbitrary NodePath. Complain if it's ambiguous. _off_lights.push_back(NodePath(node)); } } @@ -1107,8 +1012,7 @@ finalize(BamReader *manager) { // If it's in the registry, add that NodePath. _on_lights.push_back(areg->get_node(n)); } else { - // Otherwise, add any arbitrary NodePath. Complain if it's - // ambiguous. + // Otherwise, add any arbitrary NodePath. Complain if it's ambiguous. _on_lights.push_back(NodePath(node)); } } @@ -1119,14 +1023,11 @@ finalize(BamReader *manager) { _on_lights.sort(); } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type LightAttrib is encountered -// in the Bam file. It should create the LightAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type LightAttrib is encountered in the Bam file. It should create the + * LightAttrib and extract its information from the file. + */ TypedWritable *LightAttrib:: make_from_bam(const FactoryParams ¶ms) { LightAttrib *attrib = new LightAttrib; @@ -1141,13 +1042,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: LightAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LightAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LightAttrib. + */ void LightAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/lightAttrib.h b/panda/src/pgraph/lightAttrib.h index af45e5570f..1053dac3fe 100644 --- a/panda/src/pgraph/lightAttrib.h +++ b/panda/src/pgraph/lightAttrib.h @@ -1,16 +1,15 @@ -// Filename: lightAttrib.h -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightAttrib.h + * @author drose + * @date 2002-03-26 + */ #ifndef LIGHTATTRIB_H #define LIGHTATTRIB_H @@ -23,13 +22,11 @@ #include "ordered_vector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : LightAttrib -// Description : Indicates which set of lights should be considered -// "on" to illuminate geometry at this level and below. -// A LightAttrib can either add lights or remove lights -// from the total set of "on" lights. -//////////////////////////////////////////////////////////////////// +/** + * Indicates which set of lights should be considered "on" to illuminate + * geometry at this level and below. A LightAttrib can either add lights or + * remove lights from the total set of "on" lights. + */ class EXPCL_PANDA_PGRAPH LightAttrib : public RenderAttrib { protected: INLINE LightAttrib(); @@ -37,22 +34,21 @@ protected: PUBLISHED: - // This is the old, deprecated interface to LightAttrib. Do not use - // any of these methods for new code; these methods will be removed - // soon. + // This is the old, deprecated interface to LightAttrib. Do not use any of + // these methods for new code; these methods will be removed soon. enum Operation { O_set, O_add, O_remove }; - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, Light *light); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, Light *light1, Light *light2); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, Light *light1, Light *light2, Light *light3); - static CPT(RenderAttrib) make(Operation op, + static CPT(RenderAttrib) make(Operation op, Light *light1, Light *light2, Light *light3, Light *light4); static CPT(RenderAttrib) make_default(); @@ -67,8 +63,7 @@ PUBLISHED: CPT(RenderAttrib) remove_light(Light *light) const; - // The following is the new, more general interface to the - // LightAttrib. + // The following is the new, more general interface to the LightAttrib. static CPT(RenderAttrib) make(); static CPT(RenderAttrib) make_all_off(); @@ -135,8 +130,7 @@ public: class BamAuxData : public BamReader::AuxData { public: // We hold a pointer to each of the PandaNodes on the on_list and - // off_list. We will later convert these to NodePaths in - // finalize(). + // off_list. We will later convert these to NodePaths in finalize(). int _num_off_lights; int _num_on_lights; NodeList _off_list; @@ -153,7 +147,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -177,4 +171,3 @@ private: #include "lightAttrib.I" #endif - diff --git a/panda/src/pgraph/lightRampAttrib.I b/panda/src/pgraph/lightRampAttrib.I index 254681973d..67b4455c6d 100644 --- a/panda/src/pgraph/lightRampAttrib.I +++ b/panda/src/pgraph/lightRampAttrib.I @@ -1,24 +1,19 @@ -// Filename: lightRampAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightRampAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::Constructor -// Access: Private -// Description: Use LightRampAttrib::make() to construct a new -// LightRampAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use LightRampAttrib::make() to construct a new LightRampAttrib object. + */ INLINE LightRampAttrib:: LightRampAttrib() { _mode = LRT_default; @@ -28,32 +23,26 @@ LightRampAttrib() { _threshold[1] = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::get_mode -// Access: Published -// Description: Returns the LightRampAttrib mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LightRampAttrib mode. + */ INLINE LightRampAttrib::LightRampMode LightRampAttrib:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::get_level -// Access: Published -// Description: Returns the nth lighting level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth lighting level. + */ INLINE PN_stdfloat LightRampAttrib:: get_level(int n) const { if ((n<0)||(n>1)) return 0.0; return _level[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::get_threshold -// Access: Published -// Description: Returns the nth threshold level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth threshold level. + */ INLINE PN_stdfloat LightRampAttrib:: get_threshold(int n) const { if ((n<0)||(n>1)) return 0.0; diff --git a/panda/src/pgraph/lightRampAttrib.cxx b/panda/src/pgraph/lightRampAttrib.cxx index 3f9c15cfbb..78ba5aaef1 100644 --- a/panda/src/pgraph/lightRampAttrib.cxx +++ b/panda/src/pgraph/lightRampAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: lightRampAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightRampAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "lightRampAttrib.h" #include "graphicsStateGuardianBase.h" @@ -24,13 +23,10 @@ TypeHandle LightRampAttrib::_type_handle; int LightRampAttrib::_attrib_slot; CPT(RenderAttrib) LightRampAttrib::_default; -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_default -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This -// is the standard OpenGL lighting ramp, which clamps -// the final light total to the 0-1 range. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This is the standard OpenGL + * lighting ramp, which clamps the final light total to the 0-1 range. + */ CPT(RenderAttrib) LightRampAttrib:: make_default() { if (_default == 0) { @@ -40,13 +36,11 @@ make_default() { return _default; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_identity -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This -// differs from the usual OpenGL lighting model in that -// it does not clamp the final lighting total to (0,1). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This differs from the usual + * OpenGL lighting model in that it does not clamp the final lighting total to + * (0,1). + */ CPT(RenderAttrib) LightRampAttrib:: make_identity() { LightRampAttrib *attrib = new LightRampAttrib(); @@ -54,20 +48,12 @@ make_identity() { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_single_threshold -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This -// causes the luminance of the diffuse lighting -// contribution to be quantized using a single threshold: -// @code -// if (original_luminance > threshold0) { -// luminance = level0; -// } else { -// luminance = 0.0; -// } -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This causes the luminance of the + * diffuse lighting contribution to be quantized using a single threshold: + * @code if (original_luminance > threshold0) { luminance = level0; } else { + * luminance = 0.0; } @endcode + */ CPT(RenderAttrib) LightRampAttrib:: make_single_threshold(PN_stdfloat thresh0, PN_stdfloat val0) { LightRampAttrib *attrib = new LightRampAttrib(); @@ -77,22 +63,13 @@ make_single_threshold(PN_stdfloat thresh0, PN_stdfloat val0) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_double_threshold -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This -// causes the luminance of the diffuse lighting -// contribution to be quantized using two thresholds: -// @code -// if (original_luminance > threshold1) { -// luminance = level1; -// } else if (original_luminance > threshold0) { -// luminance = level0; -// } else { -// luminance = 0.0; -// } -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This causes the luminance of the + * diffuse lighting contribution to be quantized using two thresholds: @code + * if (original_luminance > threshold1) { luminance = level1; } else if + * (original_luminance > threshold0) { luminance = level0; } else { luminance + * = 0.0; } @endcode + */ CPT(RenderAttrib) LightRampAttrib:: make_double_threshold(PN_stdfloat thresh0, PN_stdfloat val0, PN_stdfloat thresh1, PN_stdfloat val1) { LightRampAttrib *attrib = new LightRampAttrib(); @@ -104,28 +81,22 @@ make_double_threshold(PN_stdfloat thresh0, PN_stdfloat val0, PN_stdfloat thresh1 return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_hdr0 -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This causes -// an HDR tone mapping operation to be applied. -// -// Normally, brightness values greater than 1 cannot be -// distinguished from each other, causing very brightly lit -// objects to wash out white and all detail to be erased. -// HDR tone mapping remaps brightness values in the range -// 0-infinity into the range (0,1), making it possible to -// distinguish detail in scenes whose brightness exceeds 1. -// -// However, the monitor has finite contrast. Normally, all -// of that contrast is used to represent brightnesses in -// the range 0-1. The HDR0 tone mapping operator 'steals' -// one quarter of that contrast to represent brightnesses in -// the range 1-infinity. -// @code -// FINAL_RGB = (RGB^3 + RGB^2 + RGB) / (RGB^3 + RGB^2 + RGB + 1) -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This causes an HDR tone mapping + * operation to be applied. + * + * Normally, brightness values greater than 1 cannot be distinguished from + * each other, causing very brightly lit objects to wash out white and all + * detail to be erased. HDR tone mapping remaps brightness values in the + * range 0-infinity into the range (0,1), making it possible to distinguish + * detail in scenes whose brightness exceeds 1. + * + * However, the monitor has finite contrast. Normally, all of that contrast + * is used to represent brightnesses in the range 0-1. The HDR0 tone mapping + * operator 'steals' one quarter of that contrast to represent brightnesses in + * the range 1-infinity. @code FINAL_RGB = (RGB^3 + RGB^2 + RGB) / (RGB^3 + + * RGB^2 + RGB + 1) @endcode + */ CPT(RenderAttrib) LightRampAttrib:: make_hdr0() { LightRampAttrib *attrib = new LightRampAttrib(); @@ -133,28 +104,22 @@ make_hdr0() { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_hdr1 -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This causes -// an HDR tone mapping operation to be applied. -// -// Normally, brightness values greater than 1 cannot be -// distinguished from each other, causing very brightly lit -// objects to wash out white and all detail to be erased. -// HDR tone mapping remaps brightness values in the range -// 0-infinity into the range (0,1), making it possible to -// distinguish detail in scenes whose brightness exceeds 1. -// -// However, the monitor has finite contrast. Normally, all -// of that contrast is used to represent brightnesses in -// the range 0-1. The HDR1 tone mapping operator 'steals' -// one third of that contrast to represent brightnesses in -// the range 1-infinity. -// @code -// FINAL_RGB = (RGB^2 + RGB) / (RGB^2 + RGB + 1) -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This causes an HDR tone mapping + * operation to be applied. + * + * Normally, brightness values greater than 1 cannot be distinguished from + * each other, causing very brightly lit objects to wash out white and all + * detail to be erased. HDR tone mapping remaps brightness values in the + * range 0-infinity into the range (0,1), making it possible to distinguish + * detail in scenes whose brightness exceeds 1. + * + * However, the monitor has finite contrast. Normally, all of that contrast + * is used to represent brightnesses in the range 0-1. The HDR1 tone mapping + * operator 'steals' one third of that contrast to represent brightnesses in + * the range 1-infinity. @code FINAL_RGB = (RGB^2 + RGB) / (RGB^2 + RGB + 1) + * @endcode + */ CPT(RenderAttrib) LightRampAttrib:: make_hdr1() { LightRampAttrib *attrib = new LightRampAttrib(); @@ -162,28 +127,21 @@ make_hdr1() { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_hdr2 -// Access: Published, Static -// Description: Constructs a new LightRampAttrib object. This causes -// an HDR tone mapping operation to be applied. -// -// Normally, brightness values greater than 1 cannot be -// distinguished from each other, causing very brightly lit -// objects to wash out white and all detail to be erased. -// HDR tone mapping remaps brightness values in the range -// 0-infinity into the range (0,1), making it possible to -// distinguish detail in scenes whose brightness exceeds 1. -// -// However, the monitor has finite contrast. Normally, all -// of that contrast is used to represent brightnesses in -// the range 0-1. The HDR2 tone mapping operator 'steals' -// one half of that contrast to represent brightnesses in -// the range 1-infinity. -// @code -// FINAL_RGB = (RGB) / (RGB + 1) -// @endcode -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new LightRampAttrib object. This causes an HDR tone mapping + * operation to be applied. + * + * Normally, brightness values greater than 1 cannot be distinguished from + * each other, causing very brightly lit objects to wash out white and all + * detail to be erased. HDR tone mapping remaps brightness values in the + * range 0-infinity into the range (0,1), making it possible to distinguish + * detail in scenes whose brightness exceeds 1. + * + * However, the monitor has finite contrast. Normally, all of that contrast + * is used to represent brightnesses in the range 0-1. The HDR2 tone mapping + * operator 'steals' one half of that contrast to represent brightnesses in + * the range 1-infinity. @code FINAL_RGB = (RGB) / (RGB + 1) @endcode + */ CPT(RenderAttrib) LightRampAttrib:: make_hdr2() { LightRampAttrib *attrib = new LightRampAttrib(); @@ -191,11 +149,9 @@ make_hdr2() { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightRampAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -224,21 +180,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived LightRampAttrib -// types to return a unique number indicating whether -// this LightRampAttrib is equivalent to the other one. -// -// This should return 0 if the two LightRampAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two LightRampAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived LightRampAttrib types to return a + * unique number indicating whether this LightRampAttrib is equivalent to the + * other one. + * + * This should return 0 if the two LightRampAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two LightRampAttrib objects whose get_type() + * functions return the same. + */ int LightRampAttrib:: compare_to_impl(const RenderAttrib *other) const { const LightRampAttrib *ta = (const LightRampAttrib *)other; @@ -260,16 +213,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t LightRampAttrib:: get_hash_impl() const { size_t hash = 0; @@ -282,33 +231,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) LightRampAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LightRampAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type LightRampAttrib. + */ void LightRampAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LightRampAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -322,14 +264,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type LightRampAttrib is encountered -// in the Bam file. It should create the LightRampAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type LightRampAttrib is encountered in the Bam file. It should create the + * LightRampAttrib and extract its information from the file. + */ TypedWritable *LightRampAttrib:: make_from_bam(const FactoryParams ¶ms) { LightRampAttrib *attrib = new LightRampAttrib; @@ -338,17 +277,14 @@ make_from_bam(const FactoryParams ¶ms) { parse_params(params, scan, manager); attrib->fillin(scan, manager); - + return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: LightRampAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LightRampAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LightRampAttrib. + */ void LightRampAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/lightRampAttrib.h b/panda/src/pgraph/lightRampAttrib.h index bb7236cd3f..08c3a1ea84 100644 --- a/panda/src/pgraph/lightRampAttrib.h +++ b/panda/src/pgraph/lightRampAttrib.h @@ -1,16 +1,15 @@ -// Filename: lightRampAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightRampAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef LIGHTRAMPATTRIB_H #define LIGHTRAMPATTRIB_H @@ -20,15 +19,12 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : LightRampAttrib -// Description : A Light Ramp is any unary operator that takes a -// rendered pixel as input, and adjusts the brightness -// of that pixel. For example, gamma correction is a -// kind of light ramp. So is HDR tone mapping. So is -// cartoon shading. See the constructors for an -// explanation of each kind of ramp. -//////////////////////////////////////////////////////////////////// +/** + * A Light Ramp is any unary operator that takes a rendered pixel as input, + * and adjusts the brightness of that pixel. For example, gamma correction is + * a kind of light ramp. So is HDR tone mapping. So is cartoon shading. See + * the constructors for an explanation of each kind of ramp. + */ class EXPCL_PANDA_PGRAPH LightRampAttrib : public RenderAttrib { private: INLINE LightRampAttrib(); @@ -50,20 +46,20 @@ PUBLISHED: static CPT(RenderAttrib) make_hdr0(); static CPT(RenderAttrib) make_hdr1(); static CPT(RenderAttrib) make_hdr2(); - + INLINE LightRampMode get_mode() const; INLINE PN_stdfloat get_level(int n) const; INLINE PN_stdfloat get_threshold(int n) const; - + public: virtual void output(ostream &out) const; - + protected: virtual int compare_to_impl(const RenderAttrib *other) const; virtual size_t get_hash_impl() const; virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const; - + private: LightRampMode _mode; PN_stdfloat _level[2]; @@ -86,7 +82,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -110,4 +106,3 @@ private: #include "lightRampAttrib.I" #endif - diff --git a/panda/src/pgraph/loader.I b/panda/src/pgraph/loader.I index dcc82cda3c..25295c32dc 100644 --- a/panda/src/pgraph/loader.I +++ b/panda/src/pgraph/loader.I @@ -1,105 +1,84 @@ -// Filename: loader.I -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loader.I + * @author mike + * @date 1997-01-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Loader::Results:: Results() { } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Loader::Results:: Results(const Loader::Results ©) : _files(copy._files) { } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void Loader::Results:: operator = (const Loader::Results ©) { _files = copy._files; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Loader::Results:: ~Results() { } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::clear -// Access: Published -// Description: Removes all the files from the list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the files from the list. + */ INLINE void Loader::Results:: clear() { _files.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::get_num_files -// Access: Published -// Description: Returns the number of files on the result list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of files on the result list. + */ INLINE int Loader::Results:: get_num_files() const { return _files.size(); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::get_file -// Access: Published -// Description: Returns the nth file on the result list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth file on the result list. + */ INLINE const Filename &Loader::Results:: get_file(int n) const { nassertr(n >= 0 && n < (int)_files.size(), _files[0]._path); return _files[n]._path; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::get_file_type -// Access: Published -// Description: Returns the file type of the nth file on the result -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the file type of the nth file on the result list. + */ INLINE LoaderFileType *Loader::Results:: get_file_type(int n) const { nassertr(n >= 0 && n < (int)_files.size(), NULL); return _files[n]._type; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::Results::add_file -// Access: Published -// Description: Adds a new file to the result list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new file to the result list. + */ INLINE void Loader::Results:: add_file(const Filename &file, LoaderFileType *type) { ConsiderFile cf; @@ -108,57 +87,43 @@ add_file(const Filename &file, LoaderFileType *type) { _files.push_back(cf); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::set_task_manager -// Access: Published -// Description: Specifies the task manager that is used for -// asynchronous loads. The default is the global task -// manager. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the task manager that is used for asynchronous loads. The + * default is the global task manager. + */ INLINE void Loader:: set_task_manager(AsyncTaskManager *task_manager) { _task_manager = task_manager; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::get_task_manager -// Access: Published -// Description: Returns the task manager that is used for -// asynchronous loads. -//////////////////////////////////////////////////////////////////// +/** + * Returns the task manager that is used for asynchronous loads. + */ INLINE AsyncTaskManager *Loader:: get_task_manager() const { return _task_manager; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::set_task_chain -// Access: Published -// Description: Specifies the task chain that is used for -// asynchronous loads. The default is the initial name -// of the Loader object. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the task chain that is used for asynchronous loads. The default + * is the initial name of the Loader object. + */ INLINE void Loader:: set_task_chain(const string &task_chain) { _task_chain = task_chain; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::get_task_chain -// Access: Published -// Description: Returns the task chain that is used for -// asynchronous loads. -//////////////////////////////////////////////////////////////////// +/** + * Returns the task chain that is used for asynchronous loads. + */ INLINE const string &Loader:: get_task_chain() const { return _task_chain; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::stop_threads -// Access: Published -// Description: Stop any threads used for asynchronous loads. -//////////////////////////////////////////////////////////////////// +/** + * Stop any threads used for asynchronous loads. + */ INLINE void Loader:: stop_threads() { PT(AsyncTaskChain) chain = _task_manager->find_task_chain(_task_chain); @@ -167,27 +132,21 @@ stop_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: Loader::remove -// Access: Published -// Description: Removes a pending asynchronous load request. Returns -// true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes a pending asynchronous load request. Returns true if successful, + * false otherwise. + */ INLINE bool Loader:: remove(AsyncTask *task) { return _task_manager->remove(task); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::load_sync -// Access: Published -// Description: Loads the file immediately, waiting for it to -// complete. -// -// If search is true, the file is searched for along the -// model path; otherwise, only the exact filename is -// loaded. -//////////////////////////////////////////////////////////////////// +/** + * Loads the file immediately, waiting for it to complete. + * + * If search is true, the file is searched for along the model path; + * otherwise, only the exact filename is loaded. + */ INLINE PT(PandaNode) Loader:: load_sync(const Filename &filename, const LoaderOptions &options) const { if (!_file_types_loaded) { @@ -196,34 +155,27 @@ load_sync(const Filename &filename, const LoaderOptions &options) const { return load_file(filename, options); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::load_async -// Access: Published -// Description: Begins an asynchronous load request. To use this -// call, first call make_async_request() to create a new -// ModelLoadRequest object with the filename you wish to -// load, and then add that object to the Loader with -// load_async. This function will return immediately, -// and the model will be loaded in the background. -// -// To determine when the model has completely loaded, -// you may poll request->is_ready() from time to time, -// or set the done_event on the request object and -// listen for that event. When the model is ready, you -// may retrieve it via request->get_model(). -//////////////////////////////////////////////////////////////////// +/** + * Begins an asynchronous load request. To use this call, first call + * make_async_request() to create a new ModelLoadRequest object with the + * filename you wish to load, and then add that object to the Loader with + * load_async. This function will return immediately, and the model will be + * loaded in the background. + * + * To determine when the model has completely loaded, you may poll + * request->is_ready() from time to time, or set the done_event on the request + * object and listen for that event. When the model is ready, you may + * retrieve it via request->get_model(). + */ INLINE void Loader:: load_async(AsyncTask *request) { request->set_task_chain(_task_chain); _task_manager->add(request); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::save_sync -// Access: Published -// Description: Saves the file immediately, waiting for it to -// complete. -//////////////////////////////////////////////////////////////////// +/** + * Saves the file immediately, waiting for it to complete. + */ INLINE bool Loader:: save_sync(const Filename &filename, const LoaderOptions &options, PandaNode *node) const { @@ -233,36 +185,28 @@ save_sync(const Filename &filename, const LoaderOptions &options, return save_file(filename, options, node); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::save_async -// Access: Published -// Description: Begins an asynchronous save request. To use this -// call, first call make_async_save_request() to create -// a new ModelSaveRequest object with the filename you -// wish to load, and then add that object to the Loader -// with save_async. This function will return -// immediately, and the model will be loaded in the -// background. -// -// To determine when the model has completely loaded, -// you may poll request->is_ready() from time to time, -// or set the done_event on the request object and -// listen for that event. When the request is ready, -// you may retrieve the success or failure via -// request->get_success(). -//////////////////////////////////////////////////////////////////// +/** + * Begins an asynchronous save request. To use this call, first call + * make_async_save_request() to create a new ModelSaveRequest object with the + * filename you wish to load, and then add that object to the Loader with + * save_async. This function will return immediately, and the model will be + * loaded in the background. + * + * To determine when the model has completely loaded, you may poll + * request->is_ready() from time to time, or set the done_event on the request + * object and listen for that event. When the request is ready, you may + * retrieve the success or failure via request->get_success(). + */ INLINE void Loader:: save_async(AsyncTask *request) { request->set_task_chain(_task_chain); _task_manager->add(request); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::get_global_ptr -// Access: Published -// Description: Returns a pointer to the global Loader. This is the -// Loader that most code should use for loading models. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global Loader. This is the Loader that most code + * should use for loading models. + */ INLINE Loader *Loader:: get_global_ptr() { if (_global_ptr == (Loader *)NULL) { diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 44cc41de60..3b3042ba48 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -1,16 +1,15 @@ -// Filename: loader.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loader.cxx + * @author mike + * @date 1997-01-09 + */ #include "loader.h" #include "loaderFileType.h" @@ -37,11 +36,9 @@ bool Loader::_file_types_loaded = false; PT(Loader) Loader::_global_ptr; TypeHandle Loader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Loader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Loader:: Loader(const string &name) : Namable(name) @@ -73,24 +70,20 @@ Loader(const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: Loader::make_async_request -// Access: Published -// Description: Returns a new AsyncTask object suitable for adding to -// load_async() to start an asynchronous model load. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new AsyncTask object suitable for adding to load_async() to start + * an asynchronous model load. + */ PT(AsyncTask) Loader:: make_async_request(const Filename &filename, const LoaderOptions &options) { return new ModelLoadRequest(string("model:")+filename.get_basename(), filename, options, this); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::make_async_save_request -// Access: Published -// Description: Returns a new AsyncTask object suitable for adding to -// save_async() to start an asynchronous model save. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new AsyncTask object suitable for adding to save_async() to start + * an asynchronous model save. + */ PT(AsyncTask) Loader:: make_async_save_request(const Filename &filename, const LoaderOptions &options, PandaNode *node) { @@ -98,12 +91,10 @@ make_async_save_request(const Filename &filename, const LoaderOptions &options, filename, options, node, this); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::load_bam_stream -// Access: Published -// Description: Attempts to read a bam file from the indicated stream -// and return the scene graph defined there. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to read a bam file from the indicated stream and return the scene + * graph defined there. + */ PT(PandaNode) Loader:: load_bam_stream(istream &in) { BamFile bam_file; @@ -114,11 +105,9 @@ load_bam_stream(istream &in) { return bam_file.read_node(); } -//////////////////////////////////////////////////////////////////// -// Function: Loader::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Loader:: output(ostream &out) const { out << get_type() << " " << get_name(); @@ -129,17 +118,13 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Loader::load_file -// Access: Private -// Description: Loads a single scene graph file, if possible. -// Returns the Node that is the root of the file, or -// NULL if the file cannot be loaded. -// -// If search is true, the file is searched for along the -// model path; otherwise, only the exact filename is -// loaded. -//////////////////////////////////////////////////////////////////// +/** + * Loads a single scene graph file, if possible. Returns the Node that is the + * root of the file, or NULL if the file cannot be loaded. + * + * If search is true, the file is searched for along the model path; + * otherwise, only the exact filename is loaded. + */ PT(PandaNode) Loader:: load_file(const Filename &filename, const LoaderOptions &options) const { Filename this_filename(filename); @@ -149,8 +134,8 @@ load_file(const Filename &filename, const LoaderOptions &options) const { string extension = this_filename.get_extension(); if (extension.empty()) { - // If the filename has no filename extension, append the default - // extension specified in the Config file. + // If the filename has no filename extension, append the default extension + // specified in the Config file. this_filename = this_filename.get_fullpath() + default_model_extension.get_value(); extension = this_filename.get_extension(); } @@ -212,8 +197,8 @@ load_file(const Filename &filename, const LoaderOptions &options) const { search = false; } - // Now that we've decided whether to search for the file, don't try - // to search again. + // Now that we've decided whether to search for the file, don't try to + // search again. this_options.set_flags(this_options.get_flags() & ~LoaderOptions::LF_search); VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -274,13 +259,10 @@ load_file(const Filename &filename, const LoaderOptions &options) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::try_load_file -// Access: Private -// Description: The implementatin of load_file(), this tries a single -// possible file without searching further along the -// path. -//////////////////////////////////////////////////////////////////// +/** + * The implementatin of load_file(), this tries a single possible file without + * searching further along the path. + */ PT(PandaNode) Loader:: try_load_file(const Filename &pathname, const LoaderOptions &options, LoaderFileType *requested_type) const { @@ -289,8 +271,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, bool allow_ram_cache = requested_type->get_allow_ram_cache(options); if (allow_ram_cache) { - // If we're allowing a RAM cache, use the ModelPool to load the - // file. + // If we're allowing a RAM cache, use the ModelPool to load the file. PT(PandaNode) node = ModelPool::get_model(pathname, true); if (node != (PandaNode *)NULL) { if ((options.get_flags() & LoaderOptions::LF_allow_instance) == 0) { @@ -309,8 +290,7 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, PT(BamCacheRecord) record; if (cache->get_cache_models() && requested_type->get_allow_disk_cache(options)) { - // See if the model can be found in the on-disk cache, if it is - // active. + // See if the model can be found in the on-disk cache, if it is active. record = cache->lookup(pathname, "bam"); if (record != (BamCacheRecord *)NULL) { if (record->has_data()) { @@ -331,9 +311,9 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, model_root->set_timestamp(record->get_source_timestamp()); if (allow_ram_cache) { - // Store the loaded model in the RAM cache, and make sure - // we return a copy so that this node can be modified - // independently from the RAM cached version. + // Store the loaded model in the RAM cache, and make sure we + // return a copy so that this node can be modified independently + // from the RAM cached version. ModelPool::add_model(pathname, model_root); if ((options.get_flags() & LoaderOptions::LF_allow_instance) == 0) { return model_root->copy_subgraph(); @@ -367,9 +347,9 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, } if (allow_ram_cache && result->is_of_type(ModelRoot::get_class_type())) { - // Store the loaded model in the RAM cache, and make sure - // we return a copy so that this node can be modified - // independently from the RAM cached version. + // Store the loaded model in the RAM cache, and make sure we return a + // copy so that this node can be modified independently from the RAM + // cached version. ModelPool::add_model(pathname, DCAST(ModelRoot, result.p())); if ((options.get_flags() & LoaderOptions::LF_allow_instance) == 0) { result = result->copy_subgraph(); @@ -382,13 +362,10 @@ try_load_file(const Filename &pathname, const LoaderOptions &options, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::save_file -// Access: Private -// Description: Saves a scene graph to a single file, if possible. -// The file type written is implicit in the filename -// extension. -//////////////////////////////////////////////////////////////////// +/** + * Saves a scene graph to a single file, if possible. The file type written + * is implicit in the filename extension. + */ bool Loader:: save_file(const Filename &filename, const LoaderOptions &options, PandaNode *node) const { @@ -399,8 +376,8 @@ save_file(const Filename &filename, const LoaderOptions &options, string extension = this_filename.get_extension(); if (extension.empty()) { - // If the filename has no filename extension, append the default - // extension specified in the Config file. + // If the filename has no filename extension, append the default extension + // specified in the Config file. this_filename = this_filename.get_fullpath() + default_model_extension.get_value(); extension = this_filename.get_extension(); } @@ -467,12 +444,10 @@ save_file(const Filename &filename, const LoaderOptions &options, return result; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::try_save_file -// Access: Private -// Description: The implementation of save_file(), this tries to -// write a specific file type. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of save_file(), this tries to write a specific file + * type. + */ bool Loader:: try_save_file(const Filename &pathname, const LoaderOptions &options, PandaNode *node, LoaderFileType *requested_type) const { @@ -482,14 +457,11 @@ try_save_file(const Filename &pathname, const LoaderOptions &options, return result; } -//////////////////////////////////////////////////////////////////// -// Function: Loader::load_file_types -// Access: Private, Static -// Description: Loads up all of the dynamic libraries named in a -// load-file-type Configure variable. Presumably this -// will make the various file types available for -// runtime loading. -//////////////////////////////////////////////////////////////////// +/** + * Loads up all of the dynamic libraries named in a load-file-type Configure + * variable. Presumably this will make the various file types available for + * runtime loading. + */ void Loader:: load_file_types() { if (!_file_types_loaded) { @@ -518,9 +490,9 @@ load_file_types() { } } else if (words.size() > 1) { - // Multiple words: the first n words are filename extensions, - // and the last word is the name of the library to load should - // any of those filename extensions be encountered. + // Multiple words: the first n words are filename extensions, and the + // last word is the name of the library to load should any of those + // filename extensions be encountered. LoaderFileTypeRegistry *registry = LoaderFileTypeRegistry::get_global_ptr(); size_t num_extensions = words.size() - 1; string library_name = words[num_extensions]; @@ -540,16 +512,12 @@ load_file_types() { } } -//////////////////////////////////////////////////////////////////// -// Function: Loader::make_global_ptr -// Access: Private, Static -// Description: Called once per application to create the global -// loader object. -//////////////////////////////////////////////////////////////////// +/** + * Called once per application to create the global loader object. + */ void Loader:: make_global_ptr() { nassertv(_global_ptr == (Loader *)NULL); _global_ptr = new Loader("loader"); } - diff --git a/panda/src/pgraph/loader.h b/panda/src/pgraph/loader.h index adfd77fd86..b39dc952cd 100644 --- a/panda/src/pgraph/loader.h +++ b/panda/src/pgraph/loader.h @@ -1,16 +1,15 @@ -// Filename: loader.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loader.h + * @author mike + * @date 1997-01-09 + */ #ifndef LOADER_H #define LOADER_H @@ -29,21 +28,17 @@ class LoaderFileType; -//////////////////////////////////////////////////////////////////// -// Class : Loader -// Description : A convenient class for loading models from disk, in -// bam or egg format (or any of a number of other -// formats implemented by a LoaderFileType, such as -// ptloader). -// -// This class supports synchronous as well as -// asynchronous loading. In asynchronous loading, the -// model is loaded in the background by a thread, and an -// event will be generated when the model is available. -// If threading is not available, the asynchronous -// loading interface may be used, but it loads -// synchronously. -//////////////////////////////////////////////////////////////////// +/** + * A convenient class for loading models from disk, in bam or egg format (or + * any of a number of other formats implemented by a LoaderFileType, such as + * ptloader). + * + * This class supports synchronous as well as asynchronous loading. In + * asynchronous loading, the model is loaded in the background by a thread, + * and an event will be generated when the model is available. If threading + * is not available, the asynchronous loading interface may be used, but it + * loads synchronously. + */ class EXPCL_PANDA_PGRAPH Loader : public TypedReferenceCount, public Namable { private: class ConsiderFile { diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index a6256559b6..c064361a68 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileType.cxx -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileType.cxx + * @author drose + * @date 2000-06-20 + */ #include "loaderFileType.h" #include "loaderOptions.h" @@ -19,107 +18,84 @@ TypeHandle LoaderFileType::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileType:: LoaderFileType() { - // Derived LoaderFileType classes that return a different result - // based on the setting of certain LoaderOptions flags (like - // LF_convert_anim) should set those bits in the following bitmask, - // so that we will not inadvertently cache a model without - // respecting these flags. + // Derived LoaderFileType classes that return a different result based on + // the setting of certain LoaderOptions flags (like LF_convert_anim) should + // set those bits in the following bitmask, so that we will not + // inadvertently cache a model without respecting these flags. _no_cache_flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileType:: ~LoaderFileType() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::get_additional_extensions -// Access: Published, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this loader. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this loader. + */ string LoaderFileType:: get_additional_extensions() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileType:: supports_compressed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::get_allow_disk_cache -// Access: Published, Virtual -// Description: Returns true if the loader flags allow retrieving the -// model from the on-disk bam cache (if it is enabled), -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the loader flags allow retrieving the model from the on- + * disk bam cache (if it is enabled), false otherwise. + */ bool LoaderFileType:: get_allow_disk_cache(const LoaderOptions &options) const { return (options.get_flags() & (LoaderOptions::LF_no_disk_cache | _no_cache_flags)) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::get_allow_ram_cache -// Access: Published, Virtual -// Description: Returns true if the loader flags allow retrieving the -// model from the in-memory ModelPool cache, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the loader flags allow retrieving the model from the in- + * memory ModelPool cache, false otherwise. + */ bool LoaderFileType:: get_allow_ram_cache(const LoaderOptions &options) const { return (options.get_flags() & (LoaderOptions::LF_no_ram_cache | _no_cache_flags)) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::supports_load -// Access: Published, Virtual -// Description: Returns true if the file type can be used to load -// files, and load_file() is supported. Returns false -// if load_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to load files, and load_file() is + * supported. Returns false if load_file() is unimplemented and will always + * fail. + */ bool LoaderFileType:: supports_load() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::supports_save -// Access: Published, Virtual -// Description: Returns true if the file type can be used to save -// files, and save_file() is supported. Returns false -// if save_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to save files, and save_file() is + * supported. Returns false if save_file() is unimplemented and will always + * fail. + */ bool LoaderFileType:: supports_save() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileType:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { @@ -128,11 +104,9 @@ load_file(const Filename &path, const LoaderOptions &options, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileType::save_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool LoaderFileType:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { diff --git a/panda/src/pgraph/loaderFileType.h b/panda/src/pgraph/loaderFileType.h index 8a25db238c..af1c21e2e7 100644 --- a/panda/src/pgraph/loaderFileType.h +++ b/panda/src/pgraph/loaderFileType.h @@ -1,16 +1,15 @@ -// Filename: loaderFileType.h -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileType.h + * @author drose + * @date 2000-06-20 + */ #ifndef LOADERFILETYPE_H #define LOADERFILETYPE_H @@ -26,13 +25,11 @@ class LoaderOptions; class BamCacheRecord; -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileType -// Description : This is the base class for a family of scene-graph -// file types that the Loader supports. Each kind of -// loader that's available should define a corresponding -// LoaderFileType object and register itself. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a family of scene-graph file types that the + * Loader supports. Each kind of loader that's available should define a + * corresponding LoaderFileType object and register itself. + */ class EXPCL_PANDA_PGRAPH LoaderFileType : public TypedObject { protected: LoaderFileType(); @@ -80,4 +77,3 @@ private: }; #endif - diff --git a/panda/src/pgraph/loaderFileTypeBam.cxx b/panda/src/pgraph/loaderFileTypeBam.cxx index bce1fb38b9..6859ff9306 100644 --- a/panda/src/pgraph/loaderFileTypeBam.cxx +++ b/panda/src/pgraph/loaderFileTypeBam.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeBam.cxx -// Created by: jason (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeBam.cxx + * @author jason + * @date 2000-06-21 + */ #include "loaderFileTypeBam.h" #include "config_pgraph.h" @@ -23,76 +22,61 @@ TypeHandle LoaderFileTypeBam::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeBam:: LoaderFileTypeBam() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeBam:: get_name() const { return "Bam"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeBam:: get_extension() const { return "bam"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeBam:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::supports_load -// Access: Published, Virtual -// Description: Returns true if the file type can be used to load -// files, and load_file() is supported. Returns false -// if load_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to load files, and load_file() is + * supported. Returns false if load_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypeBam:: supports_load() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::supports_save -// Access: Published, Virtual -// Description: Returns true if the file type can be used to save -// files, and save_file() is supported. Returns false -// if save_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to save files, and save_file() is + * supported. Returns false if save_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypeBam:: supports_save() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeBam:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { @@ -120,11 +104,9 @@ load_file(const Filename &path, const LoaderOptions &options, } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeBam::save_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool LoaderFileTypeBam:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { diff --git a/panda/src/pgraph/loaderFileTypeBam.h b/panda/src/pgraph/loaderFileTypeBam.h index f293d8e871..11c5687229 100644 --- a/panda/src/pgraph/loaderFileTypeBam.h +++ b/panda/src/pgraph/loaderFileTypeBam.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeBam.h -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeBam.h + * @author drose + * @date 2000-06-20 + */ #ifndef LOADERFILETYPEBAM_H #define LOADERFILETYPEBAM_H @@ -19,10 +18,9 @@ #include "loaderFileType.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeBam -// Description : This defines the Loader interface to read Bam files. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to read Bam files. + */ class EXPCL_PANDA_PGRAPH LoaderFileTypeBam : public LoaderFileType { public: LoaderFileTypeBam(); @@ -58,4 +56,3 @@ private: }; #endif - diff --git a/panda/src/pgraph/loaderFileTypeRegistry.cxx b/panda/src/pgraph/loaderFileTypeRegistry.cxx index 13b4e5e425..8ed3774368 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.cxx +++ b/panda/src/pgraph/loaderFileTypeRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeRegistry.cxx -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeRegistry.cxx + * @author drose + * @date 2000-06-20 + */ #include "loaderFileTypeRegistry.h" #include "loaderFileType.h" @@ -24,29 +23,23 @@ LoaderFileTypeRegistry *LoaderFileTypeRegistry::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeRegistry:: LoaderFileTypeRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeRegistry:: ~LoaderFileTypeRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::register_type -// Access: Public -// Description: Defines a new LoaderFileType in the universe. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new LoaderFileType in the universe. + */ void LoaderFileTypeRegistry:: register_type(LoaderFileType *type) { // Make sure we haven't already registered this type. @@ -73,16 +66,12 @@ register_type(LoaderFileType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::register_deferred_type -// Access: Public -// Description: Records a type associated with a particular extension -// to be loaded in the future. The named library will -// be dynamically loaded the first time files of this -// extension are loaded; presumably this library will -// call register_type() when it initializes, thus making -// the extension loadable. -//////////////////////////////////////////////////////////////////// +/** + * Records a type associated with a particular extension to be loaded in the + * future. The named library will be dynamically loaded the first time files + * of this extension are loaded; presumably this library will call + * register_type() when it initializes, thus making the extension loadable. + */ void LoaderFileTypeRegistry:: register_deferred_type(const string &extension, const string &library) { string dcextension = downcase(extension); @@ -90,8 +79,8 @@ register_deferred_type(const string &extension, const string &library) { Extensions::const_iterator ei; ei = _extensions.find(dcextension); if (ei != _extensions.end()) { - // We already have a loader for this type; no need to register - // another one. + // We already have a loader for this type; no need to register another + // one. if (loader_cat->is_debug()) { loader_cat->debug() << "Attempt to register loader library " << library @@ -122,34 +111,27 @@ register_deferred_type(const string &extension, const string &library) { _deferred_types[dcextension] = library; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::get_num_types -// Access: Published -// Description: Returns the total number of types registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of types registered. + */ int LoaderFileTypeRegistry:: get_num_types() const { return _types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::get_type -// Access: Published -// Description: Returns the nth type registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth type registered. + */ LoaderFileType *LoaderFileTypeRegistry:: get_type(int n) const { nassertr(n >= 0 && n < (int)_types.size(), NULL); return _types[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::get_type_from_extension -// Access: Published -// Description: Determines the type of the file based on the indicated -// extension (without a leading dot). Returns NULL if -// the extension matches no known file types. -//////////////////////////////////////////////////////////////////// +/** + * Determines the type of the file based on the indicated extension (without a + * leading dot). Returns NULL if the extension matches no known file types. + */ LoaderFileType *LoaderFileTypeRegistry:: get_type_from_extension(const string &extension) { string dcextension = downcase(extension); @@ -162,10 +144,9 @@ get_type_from_extension(const string &extension) { DeferredTypes::iterator di; di = _deferred_types.find(dcextension); if (di != _deferred_types.end()) { - // We do! Try to load the deferred library on-the-fly. Note - // that this is a race condition if we support threaded loading; - // this whole function needs to be protected from multiple - // entry. + // We do! Try to load the deferred library on-the-fly. Note that this + // is a race condition if we support threaded loading; this whole + // function needs to be protected from multiple entry. string name = (*di).second; Filename dlname = Filename::dso_filename("lib" + name + ".so"); _deferred_types.erase(di); @@ -175,7 +156,7 @@ get_type_from_extension(const string &extension) { void *tmp = load_dso(get_plugin_path().get_value(), dlname); if (tmp == (void *)NULL) { loader_cat->warning() - << "Unable to load " << dlname.to_os_specific() << ": " + << "Unable to load " << dlname.to_os_specific() << ": " << load_dso_error() << endl; return NULL; } else if (loader_cat.is_debug()) { @@ -189,20 +170,18 @@ get_type_from_extension(const string &extension) { } if (ei == _extensions.end()) { - // Nothing matches that extension, even after we've checked for a - // deferred type description. + // Nothing matches that extension, even after we've checked for a deferred + // type description. return NULL; } return (*ei).second; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::write -// Access: Published -// Description: Writes a list of supported file types to the -// indicated output stream, one per line. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of supported file types to the indicated output stream, one + * per line. + */ void LoaderFileTypeRegistry:: write(ostream &out, int indent_level) const { if (_types.empty()) { @@ -247,12 +226,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the global LoaderFileTypeRegistry -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global LoaderFileTypeRegistry object. + */ LoaderFileTypeRegistry *LoaderFileTypeRegistry:: get_global_ptr() { if (_global_ptr == (LoaderFileTypeRegistry *)NULL) { @@ -261,12 +237,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeRegistry::record_extension -// Access: Private -// Description: Records a filename extension recognized by a loader -// file type. -//////////////////////////////////////////////////////////////////// +/** + * Records a filename extension recognized by a loader file type. + */ void LoaderFileTypeRegistry:: record_extension(const string &extension, LoaderFileType *type) { string dcextension = downcase(extension); diff --git a/panda/src/pgraph/loaderFileTypeRegistry.h b/panda/src/pgraph/loaderFileTypeRegistry.h index 610435d26c..8ae64a51ea 100644 --- a/panda/src/pgraph/loaderFileTypeRegistry.h +++ b/panda/src/pgraph/loaderFileTypeRegistry.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeRegistry.h -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeRegistry.h + * @author drose + * @date 2000-06-20 + */ #ifndef LOADERFILETYPEREGISTRY_H #define LOADERFILETYPEREGISTRY_H @@ -23,11 +22,9 @@ class LoaderFileType; class Filename; -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeRegistry -// Description : This class maintains the set of all known -// LoaderFileTypes in the universe. -//////////////////////////////////////////////////////////////////// +/** + * This class maintains the set of all known LoaderFileTypes in the universe. + */ class EXPCL_PANDA_PGRAPH LoaderFileTypeRegistry { protected: LoaderFileTypeRegistry(); @@ -65,4 +62,3 @@ private: }; #endif - diff --git a/panda/src/pgraph/materialAttrib.I b/panda/src/pgraph/materialAttrib.I index c48ea37fc0..2f2652f43c 100644 --- a/panda/src/pgraph/materialAttrib.I +++ b/panda/src/pgraph/materialAttrib.I @@ -1,47 +1,36 @@ -// Filename: materialAttrib.I -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialAttrib.I + * @author drose + * @date 2002-03-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::Constructor -// Access: Private -// Description: Use MaterialAttrib::make() to construct a new -// MaterialAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use MaterialAttrib::make() to construct a new MaterialAttrib object. + */ INLINE MaterialAttrib:: MaterialAttrib() { } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::is_off -// Access: Published -// Description: Returns true if the MaterialAttrib is an 'off' -// MaterialAttrib, indicating that it should disable -// the use of materials. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the MaterialAttrib is an 'off' MaterialAttrib, indicating + * that it should disable the use of materials. + */ INLINE bool MaterialAttrib:: is_off() const { return _material == (const Material *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::get_material -// Access: Published -// Description: If the MaterialAttrib is not an 'off' MaterialAttrib, -// returns the material that is associated. Otherwise, -// return NULL. -//////////////////////////////////////////////////////////////////// +/** + * If the MaterialAttrib is not an 'off' MaterialAttrib, returns the material + * that is associated. Otherwise, return NULL. + */ INLINE Material *MaterialAttrib:: get_material() const { return _material; diff --git a/panda/src/pgraph/materialAttrib.cxx b/panda/src/pgraph/materialAttrib.cxx index d77c47a969..c3facc7bb4 100644 --- a/panda/src/pgraph/materialAttrib.cxx +++ b/panda/src/pgraph/materialAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: materialAttrib.cxx -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialAttrib.cxx + * @author drose + * @date 2002-03-04 + */ #include "materialAttrib.h" #include "graphicsStateGuardianBase.h" @@ -22,12 +21,10 @@ TypeHandle MaterialAttrib::_type_handle; int MaterialAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::make -// Access: Published, Static -// Description: Constructs a new MaterialAttrib object suitable for -// rendering the indicated material onto geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new MaterialAttrib object suitable for rendering the indicated + * material onto geometry. + */ CPT(RenderAttrib) MaterialAttrib:: make(Material *material) { MaterialAttrib *attrib = new MaterialAttrib; @@ -36,35 +33,28 @@ make(Material *material) { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::make_off -// Access: Published, Static -// Description: Constructs a new MaterialAttrib object suitable for -// rendering unmateriald geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new MaterialAttrib object suitable for rendering unmateriald + * geometry. + */ CPT(RenderAttrib) MaterialAttrib:: make_off() { MaterialAttrib *attrib = new MaterialAttrib; return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) MaterialAttrib:: make_default() { return return_new(new MaterialAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaterialAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -75,44 +65,37 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived MaterialAttrib -// types to return a unique number indicating whether -// this MaterialAttrib is equivalent to the other one. -// -// This should return 0 if the two MaterialAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two MaterialAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived MaterialAttrib types to return a + * unique number indicating whether this MaterialAttrib is equivalent to the + * other one. + * + * This should return 0 if the two MaterialAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two MaterialAttrib objects whose get_type() + * functions return the same. + */ int MaterialAttrib:: compare_to_impl(const RenderAttrib *other) const { const MaterialAttrib *ta = (const MaterialAttrib *)other; - // Comparing pointers by subtraction is problematic. Instead of - // doing this, we'll just depend on the built-in != and < operators - // for comparing pointers. + // Comparing pointers by subtraction is problematic. Instead of doing this, + // we'll just depend on the built-in != and < operators for comparing + // pointers. if (_material != ta->_material) { return _material < ta->_material ? -1 : 1; } return 0; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t MaterialAttrib:: get_hash_impl() const { size_t hash = 0; @@ -120,33 +103,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) MaterialAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// MaterialAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type MaterialAttrib. + */ void MaterialAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void MaterialAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -154,13 +130,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_pointer(dg, _material); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int MaterialAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -173,14 +146,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type MaterialAttrib is encountered -// in the Bam file. It should create the MaterialAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type MaterialAttrib is encountered in the Bam file. It should create the + * MaterialAttrib and extract its information from the file. + */ TypedWritable *MaterialAttrib:: make_from_bam(const FactoryParams ¶ms) { MaterialAttrib *attrib = new MaterialAttrib; @@ -192,13 +162,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MaterialAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MaterialAttrib. + */ void MaterialAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/materialAttrib.h b/panda/src/pgraph/materialAttrib.h index f43ec7e07c..729e9ac345 100644 --- a/panda/src/pgraph/materialAttrib.h +++ b/panda/src/pgraph/materialAttrib.h @@ -1,16 +1,15 @@ -// Filename: materialAttrib.h -// Created by: drose (04Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialAttrib.h + * @author drose + * @date 2002-03-04 + */ #ifndef MATERIALATTRIB_H #define MATERIALATTRIB_H @@ -20,13 +19,11 @@ #include "renderAttrib.h" #include "material.h" -//////////////////////////////////////////////////////////////////// -// Class : MaterialAttrib -// Description : Indicates which, if any, material should be applied -// to geometry. The material is used primarily to -// control lighting effects, and isn't necessary (or -// useful) in the absence of lighting. -//////////////////////////////////////////////////////////////////// +/** + * Indicates which, if any, material should be applied to geometry. The + * material is used primarily to control lighting effects, and isn't necessary + * (or useful) in the absence of lighting. + */ class EXPCL_PANDA_PGRAPH MaterialAttrib : public RenderAttrib { private: INLINE MaterialAttrib(); @@ -66,7 +63,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -90,4 +87,3 @@ private: #include "materialAttrib.I" #endif - diff --git a/panda/src/pgraph/materialCollection.I b/panda/src/pgraph/materialCollection.I index 041b01a64f..f76b00c27e 100644 --- a/panda/src/pgraph/materialCollection.I +++ b/panda/src/pgraph/materialCollection.I @@ -1,43 +1,35 @@ -// Filename: materialCollection.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialCollection.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MaterialCollection:: ~MaterialCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void MaterialCollection:: operator += (const MaterialCollection &other) { add_materials_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::operator + -// Access: Published -// Description: Returns a MaterialCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a MaterialCollection representing the concatenation of the two + * lists. + */ INLINE MaterialCollection MaterialCollection:: operator + (const MaterialCollection &other) const { MaterialCollection a(*this); diff --git a/panda/src/pgraph/materialCollection.cxx b/panda/src/pgraph/materialCollection.cxx index c27f386f75..665a924cbc 100644 --- a/panda/src/pgraph/materialCollection.cxx +++ b/panda/src/pgraph/materialCollection.cxx @@ -1,62 +1,52 @@ -// Filename: materialCollection.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialCollection.cxx + * @author drose + * @date 2002-03-16 + */ #include "materialCollection.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaterialCollection:: MaterialCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaterialCollection:: MaterialCollection(const MaterialCollection ©) : _materials(copy._materials) { } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaterialCollection:: operator = (const MaterialCollection ©) { _materials = copy._materials; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::add_material -// Access: Published -// Description: Adds a new Material to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Material to the collection. + */ void MaterialCollection:: add_material(Material *node_material) { // If the pointer to our internal array is shared by any other // MaterialCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren MaterialCollection - // objects. + // inadvertently modify any of our brethren MaterialCollection objects. if (_materials.get_ref_count() > 1) { Materials old_materials = _materials; @@ -67,13 +57,10 @@ add_material(Material *node_material) { _materials.push_back(node_material); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::remove_material -// Access: Published -// Description: Removes the indicated Material from the collection. -// Returns true if the material was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated Material from the collection. Returns true if the + * material was removed, false if it was not a member of the collection. + */ bool MaterialCollection:: remove_material(Material *node_material) { int material_index = -1; @@ -90,8 +77,7 @@ remove_material(Material *node_material) { // If the pointer to our internal array is shared by any other // MaterialCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren MaterialCollection - // objects. + // inadvertently modify any of our brethren MaterialCollection objects. if (_materials.get_ref_count() > 1) { Materials old_materials = _materials; @@ -103,14 +89,11 @@ remove_material(Material *node_material) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::add_materials_from -// Access: Published -// Description: Adds all the Materials indicated in the other -// collection to this material. The other materials are simply -// appended to the end of the materials in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the Materials indicated in the other collection to this material. + * The other materials are simply appended to the end of the materials in this + * list; duplicates are not automatically removed. + */ void MaterialCollection:: add_materials_from(const MaterialCollection &other) { int other_num_materials = other.get_num_materials(); @@ -120,12 +103,10 @@ add_materials_from(const MaterialCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::remove_materials_from -// Access: Published -// Description: Removes from this collection all of the Materials -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the Materials listed in the other + * collection. + */ void MaterialCollection:: remove_materials_from(const MaterialCollection &other) { Materials new_materials; @@ -139,14 +120,11 @@ remove_materials_from(const MaterialCollection &other) { _materials = new_materials; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::remove_duplicate_materials -// Access: Published -// Description: Removes any duplicate entries of the same Materials -// on this collection. If a Material appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same Materials on this collection. If + * a Material appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void MaterialCollection:: remove_duplicate_materials() { Materials new_materials; @@ -168,12 +146,10 @@ remove_duplicate_materials() { _materials = new_materials; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::has_material -// Access: Published -// Description: Returns true if the indicated Material appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated Material appears in this collection, false + * otherwise. + */ bool MaterialCollection:: has_material(Material *material) const { for (int i = 0; i < get_num_materials(); i++) { @@ -184,23 +160,18 @@ has_material(Material *material) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::clear -// Access: Published -// Description: Removes all Materials from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all Materials from the collection. + */ void MaterialCollection:: clear() { _materials.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::find_material -// Access: Published -// Description: Returns the material in the collection with the -// indicated name, if any, or NULL if no material has -// that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material in the collection with the indicated name, if any, or + * NULL if no material has that name. + */ Material *MaterialCollection:: find_material(const string &name) const { int num_materials = get_num_materials(); @@ -213,21 +184,17 @@ find_material(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::get_num_materials -// Access: Published -// Description: Returns the number of Materials in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of Materials in the collection. + */ int MaterialCollection:: get_num_materials() const { return _materials.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::get_material -// Access: Published -// Description: Returns the nth Material in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Material in the collection. + */ Material *MaterialCollection:: get_material(int index) const { nassertr(index >= 0 && index < (int)_materials.size(), NULL); @@ -235,13 +202,10 @@ get_material(int index) const { return _materials[index]; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::operator [] -// Access: Published -// Description: Returns the nth Material in the collection. This is -// the same as get_material(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth Material in the collection. This is the same as + * get_material(), but it may be a more convenient way to access it. + */ Material *MaterialCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_materials.size(), NULL); @@ -249,23 +213,19 @@ operator [] (int index) const { return _materials[index]; } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::size -// Access: Published -// Description: Returns the number of materials in the collection. This -// is the same thing as get_num_materials(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of materials in the collection. This is the same thing + * as get_num_materials(). + */ int MaterialCollection:: size() const { return _materials.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// MaterialCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the MaterialCollection to the + * indicated output stream. + */ void MaterialCollection:: output(ostream &out) const { if (get_num_materials() == 1) { @@ -275,12 +235,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MaterialCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// MaterialCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the MaterialCollection to the + * indicated output stream. + */ void MaterialCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_materials(); i++) { diff --git a/panda/src/pgraph/materialCollection.h b/panda/src/pgraph/materialCollection.h index 2b607f6513..97bfcd71a1 100644 --- a/panda/src/pgraph/materialCollection.h +++ b/panda/src/pgraph/materialCollection.h @@ -1,16 +1,15 @@ -// Filename: materialCollection.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file materialCollection.h + * @author drose + * @date 2002-03-16 + */ #ifndef MATERIALCOLLECTION_H #define MATERIALCOLLECTION_H @@ -19,10 +18,9 @@ #include "pointerToArray.h" #include "material.h" -//////////////////////////////////////////////////////////////////// -// Class : MaterialCollection -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_PGRAPH MaterialCollection { PUBLISHED: MaterialCollection(); @@ -63,5 +61,3 @@ INLINE ostream &operator << (ostream &out, const MaterialCollection &col) { #include "materialCollection.I" #endif - - diff --git a/panda/src/pgraph/modelFlattenRequest.I b/panda/src/pgraph/modelFlattenRequest.I index b0e8af4821..248d122c40 100644 --- a/panda/src/pgraph/modelFlattenRequest.I +++ b/panda/src/pgraph/modelFlattenRequest.I @@ -1,24 +1,20 @@ -// Filename: modelFlattenRequest.I -// Created by: drose (30Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelFlattenRequest.I + * @author drose + * @date 2007-03-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelFlattenRequest::Constructor -// Access: Published -// Description: Create a new ModelFlattenRequest, and add it to the loader -// via load_async(), to begin an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * Create a new ModelFlattenRequest, and add it to the loader via + * load_async(), to begin an asynchronous load. + */ INLINE ModelFlattenRequest:: ModelFlattenRequest(PandaNode *orig) : AsyncTask(orig->get_name()), @@ -27,34 +23,28 @@ ModelFlattenRequest(PandaNode *orig) : { } -//////////////////////////////////////////////////////////////////// -// Function: ModelFlattenRequest::get_orig -// Access: Published -// Description: Returns the original, unflattened node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the original, unflattened node. + */ INLINE PandaNode *ModelFlattenRequest:: get_orig() const { return _orig; } -//////////////////////////////////////////////////////////////////// -// Function: ModelFlattenRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. When this returns true, you may -// retrieve the model loaded by calling get_result(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + * When this returns true, you may retrieve the model loaded by calling + * get_result(). + */ INLINE bool ModelFlattenRequest:: is_ready() const { return _is_ready; } -//////////////////////////////////////////////////////////////////// -// Function: ModelFlattenRequest::get_model -// Access: Published -// Description: Returns the flattened copy of the model. It is an -// error to call this unless is_ready() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flattened copy of the model. It is an error to call this + * unless is_ready() returns true. + */ INLINE PandaNode *ModelFlattenRequest:: get_model() const { nassertr(_is_ready, NULL); diff --git a/panda/src/pgraph/modelFlattenRequest.cxx b/panda/src/pgraph/modelFlattenRequest.cxx index 7d98406477..74a7db8461 100644 --- a/panda/src/pgraph/modelFlattenRequest.cxx +++ b/panda/src/pgraph/modelFlattenRequest.cxx @@ -1,32 +1,28 @@ -// Filename: modelFlattenRequest.cxx -// Created by: drose (30Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelFlattenRequest.cxx + * @author drose + * @date 2007-03-30 + */ #include "modelFlattenRequest.h" #include "nodePath.h" TypeHandle ModelFlattenRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ModelFlattenRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, copies and flattens the -// model. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, copies and flattens the model. + */ AsyncTask::DoneStatus ModelFlattenRequest:: do_task() { - // We make another instance of the original node, so we can safely - // flatten that without affecting the original copy. + // We make another instance of the original node, so we can safely flatten + // that without affecting the original copy. NodePath np("flatten_root"); np.attach_new_node(_orig); np.flatten_strong(); diff --git a/panda/src/pgraph/modelFlattenRequest.h b/panda/src/pgraph/modelFlattenRequest.h index c7a714ca46..0cea9d87d2 100644 --- a/panda/src/pgraph/modelFlattenRequest.h +++ b/panda/src/pgraph/modelFlattenRequest.h @@ -1,16 +1,15 @@ -// Filename: modelFlattenRequest.h -// Created by: drose (30Mar07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelFlattenRequest.h + * @author drose + * @date 2007-03-30 + */ #ifndef MODELFLATTENREQUEST #define MODELFLATTENREQUEST @@ -21,35 +20,32 @@ #include "pandaNode.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelFlattenRequest -// Description : This class object manages a single asynchronous -// request to flatten a model. The model will be -// duplicated and flattened in a sub-thread (if -// threading is available), without affecting the -// original model; and when the result is done it may be -// retrieved from this object. -//////////////////////////////////////////////////////////////////// +/** + * This class object manages a single asynchronous request to flatten a model. + * The model will be duplicated and flattened in a sub-thread (if threading is + * available), without affecting the original model; and when the result is + * done it may be retrieved from this object. + */ class EXPCL_PANDA_PGRAPH ModelFlattenRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(ModelFlattenRequest); PUBLISHED: INLINE ModelFlattenRequest(PandaNode *orig); - + INLINE PandaNode *get_orig() const; - + INLINE bool is_ready() const; INLINE PandaNode *get_model() const; - + protected: virtual DoneStatus do_task(); - + private: PT(PandaNode) _orig; bool _is_ready; PT(PandaNode) _model; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -63,7 +59,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/pgraph/modelLoadRequest.I b/panda/src/pgraph/modelLoadRequest.I index 802f158495..7392194510 100644 --- a/panda/src/pgraph/modelLoadRequest.I +++ b/panda/src/pgraph/modelLoadRequest.I @@ -1,70 +1,56 @@ -// Filename: modelLoadRequest.I -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelLoadRequest.I + * @author drose + * @date 2006-08-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::get_filename -// Access: Published -// Description: Returns the filename associated with this -// asynchronous ModelLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename associated with this asynchronous ModelLoadRequest. + */ INLINE const Filename &ModelLoadRequest:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::get_options -// Access: Published -// Description: Returns the LoaderOptions associated with this -// asynchronous ModelLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LoaderOptions associated with this asynchronous + * ModelLoadRequest. + */ INLINE const LoaderOptions &ModelLoadRequest:: get_options() const { return _options; } -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::get_loader -// Access: Published -// Description: Returns the Loader object associated with this -// asynchronous ModelLoadRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Loader object associated with this asynchronous + * ModelLoadRequest. + */ INLINE Loader *ModelLoadRequest:: get_loader() const { return _loader; } -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. When this returns true, you may -// retrieve the model loaded by calling get_model(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + * When this returns true, you may retrieve the model loaded by calling + * get_model(). + */ INLINE bool ModelLoadRequest:: is_ready() const { return _is_ready; } -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::get_model -// Access: Published -// Description: Returns the model that was loaded asynchronously, if -// any, or NULL if there was an error. It is an error -// to call this unless is_ready() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the model that was loaded asynchronously, if any, or NULL if there + * was an error. It is an error to call this unless is_ready() returns true. + */ INLINE PandaNode *ModelLoadRequest:: get_model() const { nassertr(_is_ready, NULL); diff --git a/panda/src/pgraph/modelLoadRequest.cxx b/panda/src/pgraph/modelLoadRequest.cxx index e66b4e1fb6..bc1b767b5c 100644 --- a/panda/src/pgraph/modelLoadRequest.cxx +++ b/panda/src/pgraph/modelLoadRequest.cxx @@ -1,16 +1,15 @@ -// Filename: modelLoadRequest.cxx -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelLoadRequest.cxx + * @author drose + * @date 2006-08-29 + */ #include "modelLoadRequest.h" #include "loader.h" @@ -18,14 +17,12 @@ TypeHandle ModelLoadRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::Constructor -// Access: Published -// Description: Create a new ModelLoadRequest, and add it to the loader -// via load_async(), to begin an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * Create a new ModelLoadRequest, and add it to the loader via load_async(), + * to begin an asynchronous load. + */ ModelLoadRequest:: -ModelLoadRequest(const string &name, +ModelLoadRequest(const string &name, const Filename &filename, const LoaderOptions &options, Loader *loader) : AsyncTask(name), @@ -36,11 +33,9 @@ ModelLoadRequest(const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, loads the one model. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, loads the one model. + */ AsyncTask::DoneStatus ModelLoadRequest:: do_task() { double delay = async_load_delay; diff --git a/panda/src/pgraph/modelLoadRequest.h b/panda/src/pgraph/modelLoadRequest.h index 06160418d5..06d4307236 100644 --- a/panda/src/pgraph/modelLoadRequest.h +++ b/panda/src/pgraph/modelLoadRequest.h @@ -1,16 +1,15 @@ -// Filename: modelLoadRequest.h -// Created by: drose (29Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelLoadRequest.h + * @author drose + * @date 2006-08-29 + */ #ifndef MODELLOADREQUEST #define MODELLOADREQUEST @@ -24,40 +23,38 @@ #include "pointerTo.h" #include "loader.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelLoadRequest -// Description : A class object that manages a single asynchronous -// model load request. Create a new ModelLoadRequest, -// and add it to the loader via load_async(), to begin -// an asynchronous load. -//////////////////////////////////////////////////////////////////// +/** + * A class object that manages a single asynchronous model load request. + * Create a new ModelLoadRequest, and add it to the loader via load_async(), + * to begin an asynchronous load. + */ class EXPCL_PANDA_PGRAPH ModelLoadRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(ModelLoadRequest); PUBLISHED: ModelLoadRequest(const string &name, - const Filename &filename, + const Filename &filename, const LoaderOptions &options, Loader *loader); - + INLINE const Filename &get_filename() const; INLINE const LoaderOptions &get_options() const; INLINE Loader *get_loader() const; - + INLINE bool is_ready() const; INLINE PandaNode *get_model() const; - + protected: virtual DoneStatus do_task(); - + private: Filename _filename; LoaderOptions _options; PT(Loader) _loader; bool _is_ready; PT(PandaNode) _model; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -71,7 +68,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/pgraph/modelNode.I b/panda/src/pgraph/modelNode.I index 0bbe313477..da0f61b0d4 100644 --- a/panda/src/pgraph/modelNode.I +++ b/panda/src/pgraph/modelNode.I @@ -1,23 +1,19 @@ -// Filename: modelNode.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelNode.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelNode:: ModelNode(const string &name) : PandaNode(name) @@ -27,88 +23,69 @@ ModelNode(const string &name) : _transform_limit = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::set_preserve_transform -// Access: Public -// Description: Sets the preserve_transform flag. This restricts the -// ability of a flatten operation to affect the -// transform stored on this node, and/or the node -// itself. In the order from weakest to strongest -// restrictions, the possible flags are: -// -// PT_drop_node - This node should be removed at the -// next flatten call. -// -// PT_none - The transform may be adjusted at will. The -// node itself will not be removed. This is the -// default. -// -// PT_net - Preserve the net transform from the root, -// but it's acceptable to modify the local transform -// stored on this particular node if necessary, so long -// as the net transform is not changed. This eliminates -// the need to drop an extra transform on the node -// above. -// -// PT_local - The local (and net) transform should not -// be changed in any way. If necessary, an extra -// transform will be left on the node above to guarantee -// this. This is a stronger restriction than PT_net. -// -// PT_no_touch - The local transform will not be -// changed, the node will not be removed, and -// furthermore any flatten operation will not continue -// below this node--this node and all descendents are -// protected from the effects of flatten. -//////////////////////////////////////////////////////////////////// +/** + * Sets the preserve_transform flag. This restricts the ability of a flatten + * operation to affect the transform stored on this node, and/or the node + * itself. In the order from weakest to strongest restrictions, the possible + * flags are: + * + * PT_drop_node - This node should be removed at the next flatten call. + * + * PT_none - The transform may be adjusted at will. The node itself will not + * be removed. This is the default. + * + * PT_net - Preserve the net transform from the root, but it's acceptable to + * modify the local transform stored on this particular node if necessary, so + * long as the net transform is not changed. This eliminates the need to drop + * an extra transform on the node above. + * + * PT_local - The local (and net) transform should not be changed in any way. + * If necessary, an extra transform will be left on the node above to + * guarantee this. This is a stronger restriction than PT_net. + * + * PT_no_touch - The local transform will not be changed, the node will not be + * removed, and furthermore any flatten operation will not continue below this + * node--this node and all descendents are protected from the effects of + * flatten. + */ INLINE void ModelNode:: set_preserve_transform(ModelNode::PreserveTransform preserve_transform) { _preserve_transform = preserve_transform; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::get_preserve_transform -// Access: Public -// Description: Returns the current setting of the preserve_transform -// flag. See set_preserve_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the preserve_transform flag. See + * set_preserve_transform(). + */ INLINE ModelNode::PreserveTransform ModelNode:: get_preserve_transform() const { return _preserve_transform; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::set_preserve_attributes -// Access: Public -// Description: Sets the preserve_attributes flag. This restricts the -// ability of a flatten operation to affect the -// render attributes stored on this node. -// -// The value should be the union of bits from -// SceneGraphReducer::AttribTypes that represent the -// attributes that should *not* be changed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the preserve_attributes flag. This restricts the ability of a flatten + * operation to affect the render attributes stored on this node. + * + * The value should be the union of bits from SceneGraphReducer::AttribTypes + * that represent the attributes that should *not* be changed. + */ INLINE void ModelNode:: set_preserve_attributes(int preserve_attributes) { _preserve_attributes = preserve_attributes; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::get_preserve_attributes -// Access: Public -// Description: Returns the current setting of the preserve_attributes -// flag. See set_preserve_attributes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the preserve_attributes flag. See + * set_preserve_attributes(). + */ INLINE int ModelNode:: get_preserve_attributes() const { return _preserve_attributes; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelNode:: ModelNode(const ModelNode ©) : PandaNode(copy), diff --git a/panda/src/pgraph/modelNode.cxx b/panda/src/pgraph/modelNode.cxx index 890d1b0cb8..7542c04bc8 100644 --- a/panda/src/pgraph/modelNode.cxx +++ b/panda/src/pgraph/modelNode.cxx @@ -1,16 +1,15 @@ -// Filename: modelNode.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelNode.cxx + * @author drose + * @date 2002-03-16 + */ #include "modelNode.h" @@ -21,35 +20,27 @@ TypeHandle ModelNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *ModelNode:: make_copy() const { return new ModelNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::combine_with -// Access: Public, Virtual -// Description: Collapses this PandaNode with the other PandaNode, if -// possible, and returns a pointer to the combined -// PandaNode, or NULL if the two PandaNodes cannot -// safely be combined. -// -// The return value may be this, other, or a new -// PandaNode altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two PandaNodes and -// what the collapsed PandaNode should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this PandaNode with the other PandaNode, if possible, and returns + * a pointer to the combined PandaNode, or NULL if the two PandaNodes cannot + * safely be combined. + * + * The return value may be this, other, or a new PandaNode altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two + * PandaNodes and what the collapsed PandaNode should look like. + */ PandaNode *ModelNode:: combine_with(PandaNode *other) { if (_preserve_transform == PT_drop_node) { @@ -60,123 +51,94 @@ combine_with(PandaNode *other) { return PandaNode::combine_with(other); } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of Node by duplicating -// instances, false otherwise (for instance, a Camera -// cannot be safely flattened, because the Camera -// pointer itself is meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * Node by duplicating instances, false otherwise (for instance, a Camera + * cannot be safely flattened, because the Camera pointer itself is + * meaningful). + */ bool ModelNode:: safe_to_flatten() const { return _preserve_transform == PT_drop_node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::safe_to_flatten_below -// Access: Public, Virtual -// Description: Returns true if a flatten operation may safely -// continue past this node, or false if nodes below this -// node may not be molested. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a flatten operation may safely continue past this node, or + * false if nodes below this node may not be molested. + */ bool ModelNode:: safe_to_flatten_below() const { return _preserve_transform != PT_no_touch; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of Node by calling the xform() -// method, false otherwise. For instance, it's usually -// a bad idea to attempt to xform a Character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * Node by calling the xform() method, false otherwise. For instance, it's + * usually a bad idea to attempt to xform a Character. + */ bool ModelNode:: safe_to_transform() const { return _preserve_transform == PT_none || _preserve_transform == PT_drop_node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::safe_to_modify_transform -// Access: Public, Virtual -// Description: Returns true if it is safe to automatically adjust -// the transform on this kind of node. Usually, this is -// only a bad idea if the user expects to find a -// particular transform on the node. -// -// ModelNodes with the preserve_transform flag set are -// presently the only kinds of nodes that should not -// have their transform even adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is safe to automatically adjust the transform on this + * kind of node. Usually, this is only a bad idea if the user expects to find + * a particular transform on the node. + * + * ModelNodes with the preserve_transform flag set are presently the only + * kinds of nodes that should not have their transform even adjusted. + */ bool ModelNode:: safe_to_modify_transform() const { return _preserve_transform != PT_local && _preserve_transform != PT_no_touch; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool ModelNode:: safe_to_combine() const { return _preserve_transform == PT_drop_node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::preserve_name -// Access: Public, Virtual -// Description: Returns true if the node's name has extrinsic meaning -// and must be preserved across a flatten operation, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node's name has extrinsic meaning and must be preserved + * across a flatten operation, false otherwise. + */ bool ModelNode:: preserve_name() const { return _preserve_transform != PT_drop_node && _preserve_transform != PT_no_touch; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::get_unsafe_to_apply_attribs -// Access: Public, Virtual -// Description: Returns the union of all attributes from -// SceneGraphReducer::AttribTypes that may not safely be -// applied to the vertices of this node. If this is -// nonzero, these attributes must be dropped at this -// node as a state change. -// -// This is a generalization of safe_to_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all attributes from SceneGraphReducer::AttribTypes + * that may not safely be applied to the vertices of this node. If this is + * nonzero, these attributes must be dropped at this node as a state change. + * + * This is a generalization of safe_to_transform(). + */ int ModelNode:: get_unsafe_to_apply_attribs() const { return _preserve_attributes; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ModelNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ModelNode. + */ void ModelNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: test_transform -// Access: Private -// Description: This tests the transform to make sure it's within -// the specified limits. It's done so we can assert -// to see when an invalid transform is being applied. -//////////////////////////////////////////////////////////////////// +/** + * This tests the transform to make sure it's within the specified limits. + * It's done so we can assert to see when an invalid transform is being + * applied. + */ void ModelNode:: test_transform(const TransformState *ts) const { LPoint3 pos(ts->get_pos()); @@ -188,14 +150,11 @@ test_transform(const TransformState *ts) const { nassertv(pos[2] > -_transform_limit); } -//////////////////////////////////////////////////////////////////// -// Function: transform_changed -// Access: Private, Virtual -// Description: node hook. This function handles outside -// (non-physics) actions on the actor -// and updates the internal representation of the node. -// i.e. copy from PandaNode to PhysicsObject -//////////////////////////////////////////////////////////////////// +/** + * node hook. This function handles outside (non-physics) actions on the + * actor and updates the internal representation of the node. i.e. copy from + * PandaNode to PhysicsObject + */ void ModelNode:: transform_changed() { PandaNode::transform_changed(); @@ -208,12 +167,10 @@ transform_changed() { } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ModelNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -221,14 +178,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint16(_preserve_attributes); } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ModelNode is encountered -// in the Bam file. It should create the ModelNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ModelNode is encountered in the Bam file. It should create the + * ModelNode and extract its information from the file. + */ TypedWritable *ModelNode:: make_from_bam(const FactoryParams ¶ms) { ModelNode *node = new ModelNode(""); @@ -241,13 +195,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ModelNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ModelNode. + */ void ModelNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/modelNode.h b/panda/src/pgraph/modelNode.h index 11dc8411e2..aa4620f671 100644 --- a/panda/src/pgraph/modelNode.h +++ b/panda/src/pgraph/modelNode.h @@ -1,16 +1,15 @@ -// Filename: modelNode.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelNode.h + * @author drose + * @date 2002-03-16 + */ #ifndef MODELNODE_H #define MODELNODE_H @@ -19,18 +18,16 @@ #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelNode -// Description : This node is placed at key points within the scene -// graph to indicate the roots of "models": subtrees -// that are conceptually to be treated as a single unit, -// like a car or a room, for instance. It doesn't -// affect rendering or any other operations; it's -// primarily useful as a high-level model indication. -// -// ModelNodes are created in response to a { 1 } -// flag within an egg file. -//////////////////////////////////////////////////////////////////// +/** + * This node is placed at key points within the scene graph to indicate the + * roots of "models": subtrees that are conceptually to be treated as a single + * unit, like a car or a room, for instance. It doesn't affect rendering or + * any other operations; it's primarily useful as a high-level model + * indication. + * + * ModelNodes are created in response to a { 1 } flag within an egg + * file. + */ class EXPCL_PANDA_PGRAPH ModelNode : public PandaNode { PUBLISHED: INLINE ModelNode(const string &name); @@ -41,7 +38,7 @@ protected: public: virtual PandaNode *make_copy() const; - virtual PandaNode *combine_with(PandaNode *other); + virtual PandaNode *combine_with(PandaNode *other); virtual bool safe_to_flatten() const; virtual bool safe_to_flatten_below() const; virtual bool safe_to_transform() const; @@ -107,5 +104,3 @@ private: #include "modelNode.I" #endif - - diff --git a/panda/src/pgraph/modelPool.I b/panda/src/pgraph/modelPool.I index 252e3e196e..26efd0a8c8 100644 --- a/panda/src/pgraph/modelPool.I +++ b/panda/src/pgraph/modelPool.I @@ -1,198 +1,151 @@ -// Filename: modelPool.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelPool.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::has_model -// Access: Public, Static -// Description: Returns true if the model has ever been loaded, -// false otherwise. Note that this does not guarantee -// that the model is still up-to-date. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the model has ever been loaded, false otherwise. Note that + * this does not guarantee that the model is still up-to-date. + */ INLINE bool ModelPool:: has_model(const Filename &filename) { return get_ptr()->ns_has_model(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::verify_model -// Access: Public, Static -// Description: Loads the given filename up as a model, if it has -// not already been loaded, and returns true to indicate -// success, or false to indicate failure. If this -// returns true, it is probable that a subsequent call -// to load_model() with the same model name will -// return a valid PandaNode. -// -// However, even if this returns true, it is still -// possible for a subsequent call to load_model() to -// fail. This can happen if cache-check-timestamps is -// true, and the on-disk file is subsequently modified -// to replace it with an invalid model. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up as a model, if it has not already been loaded, + * and returns true to indicate success, or false to indicate failure. If + * this returns true, it is probable that a subsequent call to load_model() + * with the same model name will return a valid PandaNode. + * + * However, even if this returns true, it is still possible for a subsequent + * call to load_model() to fail. This can happen if cache-check-timestamps is + * true, and the on-disk file is subsequently modified to replace it with an + * invalid model. + */ INLINE bool ModelPool:: verify_model(const Filename &filename) { return load_model(filename) != (ModelRoot *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::get_model -// Access: Public, Static -// Description: Returns the model that has already been previously -// loaded, or NULL otherwise. If verify is true, it -// will check if the file is still up-to-date (and -// hasn't been modified in the meantime), and if not, -// will still return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the model that has already been previously loaded, or NULL + * otherwise. If verify is true, it will check if the file is still up-to- + * date (and hasn't been modified in the meantime), and if not, will still + * return NULL. + */ INLINE ModelRoot *ModelPool:: get_model(const Filename &filename, bool verify) { return get_ptr()->ns_get_model(filename, verify); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::load_model -// Access: Public, Static -// Description: Loads the given filename up as a model, if it has -// not already been loaded, and returns the new model. -// If a model with the same filename was previously -// loaded, returns that one instead (unless -// cache-check-timestamps is true and the file has -// recently changed). If the model file cannot be -// found, or cannot be loaded for some reason, returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up as a model, if it has not already been loaded, + * and returns the new model. If a model with the same filename was + * previously loaded, returns that one instead (unless cache-check-timestamps + * is true and the file has recently changed). If the model file cannot be + * found, or cannot be loaded for some reason, returns NULL. + */ INLINE ModelRoot *ModelPool:: load_model(const Filename &filename, const LoaderOptions &options) { return get_ptr()->ns_load_model(filename, options); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::add_model -// Access: Public, Static -// Description: Adds the indicated already-loaded model to the -// pool. The model will replace any previously-loaded -// model in the pool that had the same filename. -// -// This two-parameter version of this method is -// deprecated; use the one-parameter add_model(model) -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated already-loaded model to the pool. The model will + * replace any previously-loaded model in the pool that had the same filename. + * + * This two-parameter version of this method is deprecated; use the one- + * parameter add_model(model) instead. + */ INLINE void ModelPool:: add_model(const Filename &filename, ModelRoot *model) { get_ptr()->ns_add_model(filename, model); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::release_model -// Access: Public, Static -// Description: Removes the indicated model from the pool, -// indicating it will never be loaded again; the model -// may then be freed. If this function is never called, -// a reference count will be maintained on every model -// every loaded, and models will never be freed. -// -// This version of this method is deprecated; use -// release_model(model) instead. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated model from the pool, indicating it will never be + * loaded again; the model may then be freed. If this function is never + * called, a reference count will be maintained on every model every loaded, + * and models will never be freed. + * + * This version of this method is deprecated; use release_model(model) + * instead. + */ INLINE void ModelPool:: release_model(const Filename &filename) { get_ptr()->ns_release_model(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::add_model -// Access: Public, Static -// Description: Adds the indicated already-loaded model to the -// pool. The model will replace any previously-loaded -// model in the pool that had the same filename. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated already-loaded model to the pool. The model will + * replace any previously-loaded model in the pool that had the same filename. + */ INLINE void ModelPool:: add_model(ModelRoot *model) { get_ptr()->ns_add_model(model); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::release_model -// Access: Public, Static -// Description: Removes the indicated model from the pool, -// indicating it will never be loaded again; the model -// may then be freed. If this function (and -// garbage_collect()) is never called, a reference count -// will be maintained on every model every loaded, and -// models will never be freed. -// -// The model's get_fullpath() value should not have been -// changed during its lifetime, or this function may -// fail to locate it in the pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated model from the pool, indicating it will never be + * loaded again; the model may then be freed. If this function (and + * garbage_collect()) is never called, a reference count will be maintained on + * every model every loaded, and models will never be freed. + * + * The model's get_fullpath() value should not have been changed during its + * lifetime, or this function may fail to locate it in the pool. + */ INLINE void ModelPool:: release_model(ModelRoot *model) { get_ptr()->ns_release_model(model); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::release_all_models -// Access: Public, Static -// Description: Releases all models in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all models in the pool and restores the pool to the empty state. + */ INLINE void ModelPool:: release_all_models() { get_ptr()->ns_release_all_models(); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::garbage_collect -// Access: Public, Static -// Description: Releases only those models in the pool that have a -// reference count of exactly 1; i.e. only those -// models that are not being used outside of the pool. -// Returns the number of models released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those models in the pool that have a reference count of + * exactly 1; i.e. only those models that are not being used outside of the + * pool. Returns the number of models released. + */ INLINE int ModelPool:: garbage_collect() { return get_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::list_contents -// Access: Public, Static -// Description: Lists the contents of the model pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the model pool to the indicated output stream. + */ INLINE void ModelPool:: list_contents(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::list_contents -// Access: Public, Static -// Description: Lists the contents of the model pool to cout. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the model pool to cout. + */ INLINE void ModelPool:: list_contents() { get_ptr()->ns_list_contents(cout); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one ModelPool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one ModelPool in the universe and it constructs itself. + */ INLINE ModelPool:: ModelPool() { } diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index fedd3c1134..70d7b318c9 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -1,16 +1,15 @@ -// Filename: modelPool.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelPool.cxx + * @author drose + * @date 2002-03-12 + */ #include "modelPool.h" #include "loader.h" @@ -21,23 +20,18 @@ ModelPool *ModelPool::_global_ptr = (ModelPool *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::write -// Access: Published, Static -// Description: Lists the contents of the model pool to the -// indicated output stream. -// Helps with debugging. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the model pool to the indicated output stream. Helps + * with debugging. + */ void ModelPool:: write(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_has_model -// Access: Private -// Description: The nonstatic implementation of has_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of has_model(). + */ bool ModelPool:: ns_has_model(const Filename &filename) { LightMutexHolder holder(_lock); @@ -51,11 +45,9 @@ ns_has_model(const Filename &filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_get_model -// Access: Private -// Description: The nonstatic implementation of get_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of get_model(). + */ ModelRoot *ModelPool:: ns_get_model(const Filename &filename, bool verify) { @@ -80,8 +72,8 @@ ns_get_model(const Filename &filename, bool verify) { } if (cached_model == NULL) { - // This filename was previously attempted, but it did not - // exist (or the model could not be loaded for some reason). + // This filename was previously attempted, but it did not exist (or the + // model could not be loaded for some reason). if (cache_check_timestamps) { // Check to see if there is a file there now. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -91,8 +83,7 @@ ns_get_model(const Filename &filename, bool verify) { } } } else { - // This filename was previously attempted, and successfully - // loaded. + // This filename was previously attempted, and successfully loaded. if (cache_check_timestamps && cached_model->get_timestamp() != 0 && !cached_model->get_fullpath().empty()) { // Compare the timestamp to the file on-disk. @@ -103,8 +94,8 @@ ns_get_model(const Filename &filename, bool verify) { got_cached_model = false; } else if (vfile->get_timestamp() > cached_model->get_timestamp()) { - // The file still exists, but it has a newer timestamp than - // the one we previously loaded. Force it to re-load. + // The file still exists, but it has a newer timestamp than the one + // we previously loaded. Force it to re-load. got_cached_model = false; } } @@ -122,11 +113,9 @@ ns_get_model(const Filename &filename, bool verify) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_load_model -// Access: Private -// Description: The nonstatic implementation of load_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_model(). + */ ModelRoot *ModelPool:: ns_load_model(const Filename &filename, const LoaderOptions &options) { @@ -163,8 +152,8 @@ ns_load_model(const Filename &filename, const LoaderOptions &options) { { LightMutexHolder holder(_lock); - // Look again, in case someone has just loaded the model in - // another thread. + // Look again, in case someone has just loaded the model in another + // thread. Models::const_iterator ti; ti = _models.find(filename); if (ti != _models.end() && (*ti).second != cached_model) { @@ -178,11 +167,9 @@ ns_load_model(const Filename &filename, const LoaderOptions &options) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_add_model -// Access: Private -// Description: The nonstatic implementation of add_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of add_model(). + */ void ModelPool:: ns_add_model(const Filename &filename, ModelRoot *model) { LightMutexHolder holder(_lock); @@ -194,11 +181,9 @@ ns_add_model(const Filename &filename, ModelRoot *model) { _models[filename] = model; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_release_model -// Access: Private -// Description: The nonstatic implementation of release_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_model(). + */ void ModelPool:: ns_release_model(const Filename &filename) { LightMutexHolder holder(_lock); @@ -209,11 +194,9 @@ ns_release_model(const Filename &filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_add_model -// Access: Private -// Description: The nonstatic implementation of add_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of add_model(). + */ void ModelPool:: ns_add_model(ModelRoot *model) { LightMutexHolder holder(_lock); @@ -221,11 +204,9 @@ ns_add_model(ModelRoot *model) { _models[model->get_fullpath()] = model; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_release_model -// Access: Private -// Description: The nonstatic implementation of release_model(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_model(). + */ void ModelPool:: ns_release_model(ModelRoot *model) { LightMutexHolder holder(_lock); @@ -236,22 +217,18 @@ ns_release_model(ModelRoot *model) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_release_all_models -// Access: Private -// Description: The nonstatic implementation of release_all_models(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_models(). + */ void ModelPool:: ns_release_all_models() { LightMutexHolder holder(_lock); _models.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int ModelPool:: ns_garbage_collect() { LightMutexHolder holder(_lock); @@ -278,11 +255,9 @@ ns_garbage_collect() { return num_released; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void ModelPool:: ns_list_contents(ostream &out) const { LightMutexHolder holder(_lock); @@ -304,12 +279,10 @@ ns_list_contents(ostream &out) const { << _models.size() - num_models << " entries for nonexistent files)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ModelPool::get_ptr -// Access: Private, Static -// Description: Initializes and/or returns the global pointer to the -// one ModelPool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one ModelPool object + * in the system. + */ ModelPool *ModelPool:: get_ptr() { if (_global_ptr == (ModelPool *)NULL) { diff --git a/panda/src/pgraph/modelPool.h b/panda/src/pgraph/modelPool.h index 55b2379fde..34eefba0b5 100644 --- a/panda/src/pgraph/modelPool.h +++ b/panda/src/pgraph/modelPool.h @@ -1,16 +1,15 @@ -// Filename: modelPool.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelPool.h + * @author drose + * @date 2002-03-12 + */ #ifndef MODELPOOL_H #define MODELPOOL_H @@ -24,27 +23,22 @@ #include "pmap.h" #include "loaderOptions.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelPool -// Description : This class unifies all references to the same -// filename, so that multiple attempts to load the same -// model will return the same pointer. Note that the -// default behavior is thus to make instances: use with -// caution. Use the copy_subgraph() method on Node (or -// use NodePath::copy_to) to make modifiable copies of -// the node. -// -// Unlike TexturePool, this class does not automatically -// resolve the model filenames before loading, so a -// relative path and an absolute path to the same model -// will appear to be different filenames. -// -// However, see the Loader class, which is now the -// preferred interface for loading models. The Loader -// class can resolve filenames, supports threaded -// loading, and can automatically consult the ModelPool, -// according to the supplied LoaderOptions. -//////////////////////////////////////////////////////////////////// +/** + * This class unifies all references to the same filename, so that multiple + * attempts to load the same model will return the same pointer. Note that + * the default behavior is thus to make instances: use with caution. Use the + * copy_subgraph() method on Node (or use NodePath::copy_to) to make + * modifiable copies of the node. + * + * Unlike TexturePool, this class does not automatically resolve the model + * filenames before loading, so a relative path and an absolute path to the + * same model will appear to be different filenames. + * + * However, see the Loader class, which is now the preferred interface for + * loading models. The Loader class can resolve filenames, supports threaded + * loading, and can automatically consult the ModelPool, according to the + * supplied LoaderOptions. + */ class EXPCL_PANDA_PGRAPH ModelPool { PUBLISHED: INLINE static bool has_model(const Filename &filename); @@ -96,5 +90,3 @@ private: #include "modelPool.I" #endif - - diff --git a/panda/src/pgraph/modelRoot.I b/panda/src/pgraph/modelRoot.I index dd48148130..df1bedaf7b 100644 --- a/panda/src/pgraph/modelRoot.I +++ b/panda/src/pgraph/modelRoot.I @@ -1,23 +1,19 @@ -// Filename: modelRoot.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelRoot.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelRoot:: ModelRoot(const string &name) : ModelNode(name), @@ -27,11 +23,9 @@ ModelRoot(const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelRoot:: ModelRoot(const Filename &fullpath, time_t timestamp) : ModelNode(fullpath.get_basename()), @@ -41,114 +35,88 @@ ModelRoot(const Filename &fullpath, time_t timestamp) : { } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::get_model_ref_count -// Access: Published -// Description: Returns the number of copies that exist of this -// particular ModelRoot node. Each time -// ModelRoot::copy_subgraph() or make_copy() is called -// (or some other copying mechanism, such as -// NodePath.copy_to(), is used), this count will -// increment by one in all copies; when one of the -// copies is destructed, this count will decrement. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of copies that exist of this particular ModelRoot node. + * Each time ModelRoot::copy_subgraph() or make_copy() is called (or some + * other copying mechanism, such as NodePath.copy_to(), is used), this count + * will increment by one in all copies; when one of the copies is destructed, + * this count will decrement. + */ INLINE int ModelRoot:: get_model_ref_count() const { return _reference->get_ref_count(); } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::get_fullpath -// Access: Published -// Description: Returns the full pathname of the model represented by -// this node, as found on disk. This is mainly useful -// for reference purposes, but is also used to index the -// ModelRoot into the ModelPool. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname of the model represented by this node, as found + * on disk. This is mainly useful for reference purposes, but is also used to + * index the ModelRoot into the ModelPool. + */ INLINE const Filename &ModelRoot:: get_fullpath() const { return _fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::set_fullpath -// Access: Published -// Description: Sets the full pathname of the model represented by -// this node, as found on disk. This is mainly useful -// for reference purposes, but is also used to index the -// ModelRoot into the ModelPool. -// -// This is normally set automatically when a model is -// loaded, and should not be set directly by the user. -// If you change this on a loaded model, then -// ModelPool::release_model() may fail. -//////////////////////////////////////////////////////////////////// +/** + * Sets the full pathname of the model represented by this node, as found on + * disk. This is mainly useful for reference purposes, but is also used to + * index the ModelRoot into the ModelPool. + * + * This is normally set automatically when a model is loaded, and should not + * be set directly by the user. If you change this on a loaded model, then + * ModelPool::release_model() may fail. + */ INLINE void ModelRoot:: set_fullpath(const Filename &fullpath) { _fullpath = fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::get_timestamp -// Access: Published -// Description: Returns the timestamp of the file on disk that was -// read for this model, at the time it was read, if it -// is known. Returns 0 if the timestamp is not known or -// could not be provided. This can be used as a quick -// (but fallible) check to verify whether the file might -// have changed since the model was read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp of the file on disk that was read for this model, at + * the time it was read, if it is known. Returns 0 if the timestamp is not + * known or could not be provided. This can be used as a quick (but fallible) + * check to verify whether the file might have changed since the model was + * read. + */ INLINE time_t ModelRoot:: get_timestamp() const { return _timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::set_timestamp -// Access: Published -// Description: Sets the timestamp of the file on disk that was read -// for this model. This is normally set automatically -// when a model is loaded, and should not be set -// directly by the user. -//////////////////////////////////////////////////////////////////// +/** + * Sets the timestamp of the file on disk that was read for this model. This + * is normally set automatically when a model is loaded, and should not be set + * directly by the user. + */ INLINE void ModelRoot:: set_timestamp(time_t timestamp) { _timestamp = timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::get_reference -// Access: Published -// Description: Returns the pointer that represents the object shared -// between all copies of this ModelRoot. Since there's -// not much associated with this object other than a -// reference count, normally there's not much reason to -// get the pointer (though it may be compared -// pointerwise with other ModelRoot objects). -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer that represents the object shared between all copies of + * this ModelRoot. Since there's not much associated with this object other + * than a reference count, normally there's not much reason to get the pointer + * (though it may be compared pointerwise with other ModelRoot objects). + */ INLINE ModelRoot::ModelReference *ModelRoot:: get_reference() const { return _reference; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::set_reference -// Access: Published -// Description: Changes the pointer that represents the object shared -// between all copies of this ModelRoot. This will -// disassociate this ModelRoot from all of its copies. -// Normally, there's no reason to do this. -//////////////////////////////////////////////////////////////////// +/** + * Changes the pointer that represents the object shared between all copies of + * this ModelRoot. This will disassociate this ModelRoot from all of its + * copies. Normally, there's no reason to do this. + */ INLINE void ModelRoot:: set_reference(ModelRoot::ModelReference *ref) { _reference = ref; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelRoot:: ModelRoot(const ModelRoot ©) : ModelNode(copy), @@ -158,11 +126,9 @@ ModelRoot(const ModelRoot ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::ModelReference::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ModelRoot::ModelReference:: ModelReference() { } diff --git a/panda/src/pgraph/modelRoot.cxx b/panda/src/pgraph/modelRoot.cxx index 50b0960271..30dbf1e6a6 100644 --- a/panda/src/pgraph/modelRoot.cxx +++ b/panda/src/pgraph/modelRoot.cxx @@ -1,65 +1,53 @@ -// Filename: modelRoot.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelRoot.cxx + * @author drose + * @date 2002-03-16 + */ #include "modelRoot.h" TypeHandle ModelRoot::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *ModelRoot:: make_copy() const { return new ModelRoot(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ModelRoot. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ModelRoot. + */ void ModelRoot:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ModelRoot:: write_datagram(BamWriter *manager, Datagram &dg) { ModelNode::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ModelRoot is encountered -// in the Bam file. It should create the ModelRoot -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ModelRoot is encountered in the Bam file. It should create the + * ModelRoot and extract its information from the file. + */ TypedWritable *ModelRoot:: make_from_bam(const FactoryParams ¶ms) { ModelRoot *node = new ModelRoot(""); @@ -72,13 +60,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelRoot::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ModelRoot. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ModelRoot. + */ void ModelRoot:: fillin(DatagramIterator &scan, BamReader *manager) { ModelNode::fillin(scan, manager); diff --git a/panda/src/pgraph/modelRoot.h b/panda/src/pgraph/modelRoot.h index d8ff784a69..bff0735abf 100644 --- a/panda/src/pgraph/modelRoot.h +++ b/panda/src/pgraph/modelRoot.h @@ -1,16 +1,15 @@ -// Filename: modelRoot.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelRoot.h + * @author drose + * @date 2002-03-16 + */ #ifndef MODELROOT_H #define MODELROOT_H @@ -19,15 +18,12 @@ #include "referenceCount.h" #include "modelNode.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelRoot -// Description : A node of this type is created automatically at the -// root of each model file that is loaded. It may -// eventually contain some information about the -// contents of the model; at the moment, it contains no -// special information, but can be used as a flag to -// indicate the presence of a loaded model file. -//////////////////////////////////////////////////////////////////// +/** + * A node of this type is created automatically at the root of each model file + * that is loaded. It may eventually contain some information about the + * contents of the model; at the moment, it contains no special information, + * but can be used as a flag to indicate the presence of a loaded model file. + */ class EXPCL_PANDA_PGRAPH ModelRoot : public ModelNode { PUBLISHED: INLINE ModelRoot(const string &name); @@ -94,5 +90,3 @@ private: #include "modelRoot.I" #endif - - diff --git a/panda/src/pgraph/modelSaveRequest.I b/panda/src/pgraph/modelSaveRequest.I index ee02c4a5b1..d7ccd1dd09 100644 --- a/panda/src/pgraph/modelSaveRequest.I +++ b/panda/src/pgraph/modelSaveRequest.I @@ -1,80 +1,64 @@ -// Filename: modelSaveRequest.I -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelSaveRequest.I + * @author drose + * @date 2012-12-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::get_filename -// Access: Published -// Description: Returns the filename associated with this -// asynchronous ModelSaveRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename associated with this asynchronous ModelSaveRequest. + */ INLINE const Filename &ModelSaveRequest:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::get_options -// Access: Published -// Description: Returns the LoaderOptions associated with this -// asynchronous ModelSaveRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LoaderOptions associated with this asynchronous + * ModelSaveRequest. + */ INLINE const LoaderOptions &ModelSaveRequest:: get_options() const { return _options; } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::get_node -// Access: Published -// Description: Returns the node that was passed to the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that was passed to the constructor. + */ INLINE PandaNode *ModelSaveRequest:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::get_loader -// Access: Published -// Description: Returns the Loader object associated with this -// asynchronous ModelSaveRequest. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Loader object associated with this asynchronous + * ModelSaveRequest. + */ INLINE Loader *ModelSaveRequest:: get_loader() const { return _loader; } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::is_ready -// Access: Published -// Description: Returns true if this request has completed, false if -// it is still pending. When this returns true, you may -// retrieve the success flag with get_success(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this request has completed, false if it is still pending. + * When this returns true, you may retrieve the success flag with + * get_success(). + */ INLINE bool ModelSaveRequest:: is_ready() const { return _is_ready; } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::get_success -// Access: Published -// Description: Returns the true if the model was saved successfully, -// false otherwise. It is an error to call this unless -// is_ready() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the true if the model was saved successfully, false otherwise. It + * is an error to call this unless is_ready() returns true. + */ INLINE bool ModelSaveRequest:: get_success() const { nassertr(_is_ready, false); diff --git a/panda/src/pgraph/modelSaveRequest.cxx b/panda/src/pgraph/modelSaveRequest.cxx index 02c31b2ab3..45f985454a 100644 --- a/panda/src/pgraph/modelSaveRequest.cxx +++ b/panda/src/pgraph/modelSaveRequest.cxx @@ -1,16 +1,15 @@ -// Filename: modelSaveRequest.cxx -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelSaveRequest.cxx + * @author drose + * @date 2012-12-19 + */ #include "modelSaveRequest.h" #include "loader.h" @@ -18,14 +17,12 @@ TypeHandle ModelSaveRequest::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::Constructor -// Access: Published -// Description: Create a new ModelSaveRequest, and add it to the loader -// via save_async(), to begin an asynchronous save. -//////////////////////////////////////////////////////////////////// +/** + * Create a new ModelSaveRequest, and add it to the loader via save_async(), + * to begin an asynchronous save. + */ ModelSaveRequest:: -ModelSaveRequest(const string &name, +ModelSaveRequest(const string &name, const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader) : AsyncTask(name), @@ -38,11 +35,9 @@ ModelSaveRequest(const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: ModelSaveRequest::do_task -// Access: Protected, Virtual -// Description: Performs the task: that is, saves the one model. -//////////////////////////////////////////////////////////////////// +/** + * Performs the task: that is, saves the one model. + */ AsyncTask::DoneStatus ModelSaveRequest:: do_task() { double delay = async_load_delay; diff --git a/panda/src/pgraph/modelSaveRequest.h b/panda/src/pgraph/modelSaveRequest.h index aa72952fc1..2180813f76 100644 --- a/panda/src/pgraph/modelSaveRequest.h +++ b/panda/src/pgraph/modelSaveRequest.h @@ -1,16 +1,15 @@ -// Filename: modelSaveRequest.h -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modelSaveRequest.h + * @author drose + * @date 2012-12-19 + */ #ifndef MODELSAVEREQUEST #define MODELSAVEREQUEST @@ -24,34 +23,32 @@ #include "pointerTo.h" #include "loader.h" -//////////////////////////////////////////////////////////////////// -// Class : ModelSaveRequest -// Description : A class object that manages a single asynchronous -// model save request. Create a new ModelSaveRequest, -// and add it to the loader via save_async(), to begin -// an asynchronous save. -//////////////////////////////////////////////////////////////////// +/** + * A class object that manages a single asynchronous model save request. + * Create a new ModelSaveRequest, and add it to the loader via save_async(), + * to begin an asynchronous save. + */ class EXPCL_PANDA_PGRAPH ModelSaveRequest : public AsyncTask { public: ALLOC_DELETED_CHAIN(ModelSaveRequest); PUBLISHED: ModelSaveRequest(const string &name, - const Filename &filename, + const Filename &filename, const LoaderOptions &options, PandaNode *node, Loader *loader); - + INLINE const Filename &get_filename() const; INLINE const LoaderOptions &get_options() const; INLINE PandaNode *get_node() const; INLINE Loader *get_loader() const; - + INLINE bool is_ready() const; INLINE bool get_success() const; - + protected: virtual DoneStatus do_task(); - + private: Filename _filename; LoaderOptions _options; @@ -59,7 +56,7 @@ private: PT(Loader) _loader; bool _is_ready; bool _success; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -73,7 +70,7 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index 4c19e3fdc2..1e9813debc 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -1,23 +1,19 @@ -// Filename: nodePath.I -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath.I + * @author drose + * @date 2002-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Default Constructor -// Access: Published -// Description: This constructs an empty NodePath with no nodes. -//////////////////////////////////////////////////////////////////// +/** + * This constructs an empty NodePath with no nodes. + */ INLINE NodePath:: NodePath() : _error_type(ET_ok) @@ -25,13 +21,10 @@ NodePath() : _backup_key = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Constructor -// Access: Published -// Description: This constructs a new NodePath with a single -// node. An ordinary, unattached PandaNode is created -// with the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * This constructs a new NodePath with a single node. An ordinary, unattached + * PandaNode is created with the indicated name. + */ INLINE NodePath:: NodePath(const string &top_node_name, Thread *current_thread) : _error_type(ET_ok) @@ -42,17 +35,13 @@ NodePath(const string &top_node_name, Thread *current_thread) : _backup_key = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Constructor -// Access: Published -// Description: This constructs a NodePath for the indicated node. -// If the node does not have any parents, this creates a -// singleton NodePath; otherwise, it automatically finds -// the path from the node to the root. If the node has -// multiple paths to the root, one path is chosen -// arbitrarily and a warning message is printed (but see -// also NodePath::any_path(), below). -//////////////////////////////////////////////////////////////////// +/** + * This constructs a NodePath for the indicated node. If the node does not + * have any parents, this creates a singleton NodePath; otherwise, it + * automatically finds the path from the node to the root. If the node has + * multiple paths to the root, one path is chosen arbitrarily and a warning + * message is printed (but see also NodePath::any_path(), below). + */ INLINE NodePath:: NodePath(PandaNode *node, Thread *current_thread) : _error_type(ET_ok) @@ -64,15 +53,11 @@ NodePath(PandaNode *node, Thread *current_thread) : _backup_key = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::any_path named constructor -// Access: Published, Static -// Description: Returns a new NodePath that represents any arbitrary -// path from the root to the indicated node. This is -// the same thing that would be returned by -// NodePath(node), except that no warning is issued if -// the path is ambiguous. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new NodePath that represents any arbitrary path from the root to + * the indicated node. This is the same thing that would be returned by + * NodePath(node), except that no warning is issued if the path is ambiguous. + */ INLINE NodePath NodePath:: any_path(PandaNode *node, Thread *current_thread) { NodePath result; @@ -84,11 +69,9 @@ any_path(PandaNode *node, Thread *current_thread) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePath:: NodePath(const NodePath ©) : _head(copy._head), @@ -97,11 +80,9 @@ NodePath(const NodePath ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: operator = (const NodePath ©) { _head = copy._head; @@ -110,11 +91,9 @@ operator = (const NodePath ©) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Move Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePath:: NodePath(NodePath &&from) NOEXCEPT : _head(move(from._head)), @@ -123,11 +102,9 @@ NodePath(NodePath &&from) NOEXCEPT : { } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Move Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: operator = (NodePath &&from) NOEXCEPT { _head = move(from._head); @@ -136,12 +113,10 @@ operator = (NodePath &&from) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear -// Access: Published -// Description: Sets this NodePath to the empty NodePath. It will -// no longer point to any node. -//////////////////////////////////////////////////////////////////// +/** + * Sets this NodePath to the empty NodePath. It will no longer point to any + * node. + */ INLINE void NodePath:: clear() { _head.clear(); @@ -149,12 +124,9 @@ clear() { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::not_found named constructor -// Access: Published, Static -// Description: Creates a NodePath with the ET_not_found error type -// set. -//////////////////////////////////////////////////////////////////// +/** + * Creates a NodePath with the ET_not_found error type set. + */ INLINE NodePath NodePath:: not_found() { NodePath result; @@ -162,12 +134,9 @@ not_found() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::removed named constructor -// Access: Published, Static -// Description: Creates a NodePath with the ET_removed error type -// set. -//////////////////////////////////////////////////////////////////// +/** + * Creates a NodePath with the ET_removed error type set. + */ INLINE NodePath NodePath:: removed() { NodePath result; @@ -175,12 +144,9 @@ removed() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::fail named constructor -// Access: Published, Static -// Description: Creates a NodePath with the ET_fail error type -// set. -//////////////////////////////////////////////////////////////////// +/** + * Creates a NodePath with the ET_fail error type set. + */ INLINE NodePath NodePath:: fail() { NodePath result; @@ -188,84 +154,65 @@ fail() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_max_search_depth -// Access: Published, Static -// Description: Certain operations, such as find() or -// find_all_matches(), require a traversal of the scene -// graph to search for the target node or nodes. This -// traversal does not attempt to detect cycles, so an -// arbitrary cap is set on the depth of the traversal as -// a poor man's cycle detection, in the event that a -// cycle has inadvertently been introduced into the -// scene graph. -// -// There may be other reasons you'd want to truncate a -// search before the bottom of the scene graph has been -// reached. In any event, this function sets the limit -// on the number of levels that a traversal will -// continue, and hence the maximum length of a path that -// may be returned by a traversal. -// -// This is a static method, and so changing this -// parameter affects all of the NodePaths in the -// universe. -//////////////////////////////////////////////////////////////////// +/** + * Certain operations, such as find() or find_all_matches(), require a + * traversal of the scene graph to search for the target node or nodes. This + * traversal does not attempt to detect cycles, so an arbitrary cap is set on + * the depth of the traversal as a poor man's cycle detection, in the event + * that a cycle has inadvertently been introduced into the scene graph. + * + * There may be other reasons you'd want to truncate a search before the + * bottom of the scene graph has been reached. In any event, this function + * sets the limit on the number of levels that a traversal will continue, and + * hence the maximum length of a path that may be returned by a traversal. + * + * This is a static method, and so changing this parameter affects all of the + * NodePaths in the universe. + */ INLINE void NodePath:: set_max_search_depth(int max_search_depth) { _max_search_depth = max_search_depth; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_max_search_depth -// Access: Published, Static -// Description: Returns the current setting of the search depth -// limit. See set_max_search_depth. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the search depth limit. See + * set_max_search_depth. + */ INLINE int NodePath:: get_max_search_depth() { return _max_search_depth; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_empty -// Access: Published -// Description: Returns true if the NodePath contains no nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NodePath contains no nodes. + */ INLINE bool NodePath:: is_empty() const { return (_head == (NodePathComponent *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_singleton -// Access: Published -// Description: Returns true if the NodePath contains exactly one -// node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NodePath contains exactly one node. + */ INLINE bool NodePath:: is_singleton(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); return (_head != (NodePathComponent *)NULL && _head->is_top_node(pipeline_stage, current_thread)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_error_type -// Access: Published -// Description: If is_empty() is true, this returns a code that -// represents the reason why the NodePath is empty. -//////////////////////////////////////////////////////////////////// +/** + * If is_empty() is true, this returns a code that represents the reason why + * the NodePath is empty. + */ INLINE NodePath::ErrorType NodePath:: get_error_type() const { return _error_type; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_top_node -// Access: Published -// Description: Returns the top node of the path, or NULL if the path -// is empty. This requires iterating through the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the top node of the path, or NULL if the path is empty. This + * requires iterating through the path. + */ INLINE PandaNode *NodePath:: get_top_node(Thread *current_thread) const { if (is_empty()) { @@ -275,34 +222,27 @@ get_top_node(Thread *current_thread) const { return get_top(current_thread).node(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::node -// Access: Published -// Description: Returns the referenced node of the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the referenced node of the path. + */ INLINE PandaNode *NodePath:: node() const { nassertr_always(!is_empty(), (PandaNode *)NULL); return _head->get_node(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_key -// Access: Published -// Description: Returns an integer that is guaranteed to be the same -// for all NodePaths that represent the same node -// instance, and different for all NodePaths that -// represent a different node instance. -// -// The same key will be returned for a particular -// instance as long as at least one NodePath exists that -// represents that instance; if all NodePaths for a -// particular instance destruct and a new one is later -// created, it may have a different index. However, a -// given key will never be reused for a different -// instance (unless the app has been running long enough -// that we overflow the integer key value). -//////////////////////////////////////////////////////////////////// +/** + * Returns an integer that is guaranteed to be the same for all NodePaths that + * represent the same node instance, and different for all NodePaths that + * represent a different node instance. + * + * The same key will be returned for a particular instance as long as at least + * one NodePath exists that represents that instance; if all NodePaths for a + * particular instance destruct and a new one is later created, it may have a + * different index. However, a given key will never be reused for a different + * instance (unless the app has been running long enough that we overflow the + * integer key value). + */ INLINE int NodePath:: get_key() const { if (is_empty()) { @@ -311,58 +251,47 @@ get_key() const { return _head->get_key(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::add_hash -// Access: Published -// Description: Adds the NodePath into the running hash. This is -// intended to be used by lower-level code that computes -// a hash for each NodePath. It modifies the hash value -// passed in by a unique adjustment for each NodePath, -// and returns the modified hash. -// -// This is similar to the unique integer returned by -// get_key(), but it is not guaranteed to remain unique -// beyond the lifetime of this particular NodePath. -// Once this NodePath destructs, a different NodePath -// may be created which shares the same hash value. -//////////////////////////////////////////////////////////////////// +/** + * Adds the NodePath into the running hash. This is intended to be used by + * lower-level code that computes a hash for each NodePath. It modifies the + * hash value passed in by a unique adjustment for each NodePath, and returns + * the modified hash. + * + * This is similar to the unique integer returned by get_key(), but it is not + * guaranteed to remain unique beyond the lifetime of this particular + * NodePath. Once this NodePath destructs, a different NodePath may be + * created which shares the same hash value. + */ INLINE size_t NodePath:: add_hash(size_t hash) const { return pointer_hash::add_hash(hash, _head); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_same_graph -// Access: Published -// Description: Returns true if the node represented by this NodePath -// is parented within the same graph as that of the -// other NodePath. This is essentially the same thing -// as asking whether get_top() of both NodePaths is the -// same (e.g., both "render"). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node represented by this NodePath is parented within + * the same graph as that of the other NodePath. This is essentially the same + * thing as asking whether get_top() of both NodePaths is the same (e.g., both + * "render"). + */ INLINE bool NodePath:: is_same_graph(const NodePath &other, Thread *current_thread) const { // Actually, it's possible for the top nodes to be the same, but the - // NodePaths still to be considered in different graphs. But even - // in this case, get_top() will be different for each one. (They'll - // be different singleton NodePaths that happen to reference the - // same node). + // NodePaths still to be considered in different graphs. But even in this + // case, get_top() will be different for each one. (They'll be different + // singleton NodePaths that happen to reference the same node). - // This will happen if one of the top nodes is considered a - // different instance--for instance, render.instance_to(NodePath()) - // returns a different instance of render that appears to have the - // same top node. But this is a very rare thing to do. + // This will happen if one of the top nodes is considered a different + // instance--for instance, render.instance_to(NodePath()) returns a + // different instance of render that appears to have the same top node. But + // this is a very rare thing to do. int a_count, b_count; return (find_common_ancestor(*this, other, a_count, b_count, current_thread) != (NodePathComponent *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_ancestor_of -// Access: Published -// Description: Returns true if the node represented by this NodePath -// is a parent or other ancestor of the other NodePath, -// or false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node represented by this NodePath is a parent or other + * ancestor of the other NodePath, or false if it is not. + */ INLINE bool NodePath:: is_ancestor_of(const NodePath &other, Thread *current_thread) const { int a_count, b_count; @@ -371,19 +300,16 @@ is_ancestor_of(const NodePath &other, Thread *current_thread) const { return false; } - // They are related; now b is descended from a only if a is the - // common ancestor (which is to say, a_count == 0). + // They are related; now b is descended from a only if a is the common + // ancestor (which is to say, a_count == 0). return (a_count == 0); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_common_ancestor -// Access: Published -// Description: Returns the lowest NodePath that both of these two -// NodePaths have in common: the first ancestor that -// both of them share. If the two NodePaths are -// unrelated, returns NodePath::not_found(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the lowest NodePath that both of these two NodePaths have in + * common: the first ancestor that both of them share. If the two NodePaths + * are unrelated, returns NodePath::not_found(). + */ INLINE NodePath NodePath:: get_common_ancestor(const NodePath &other, Thread *current_thread) const { int a_count, b_count; @@ -397,23 +323,18 @@ get_common_ancestor(const NodePath &other, Thread *current_thread) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_num_children -// Access: Published -// Description: Returns the number of children of the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of children of the referenced node. + */ INLINE int NodePath:: get_num_children(Thread *current_thread) const { nassertr_always(!is_empty(), 0); return _head->get_node()->get_num_children(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_child -// Access: Published -// Description: Returns a NodePath representing the nth child of the -// referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NodePath representing the nth child of the referenced node. + */ INLINE NodePath NodePath:: get_child(int n, Thread *current_thread) const { nassertr_always(n >= 0 && n < get_num_children(current_thread), NodePath()); @@ -424,11 +345,9 @@ get_child(int n, Thread *current_thread) const { return child; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::count_num_descendants -// Access: Published -// Description: Returns the number of nodes at and below this level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nodes at and below this level. + */ INLINE int NodePath:: count_num_descendants() const { if (is_empty()) { @@ -437,25 +356,20 @@ count_num_descendants() const { return _head->get_node()->count_num_descendants(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_parent -// Access: Published -// Description: Returns true if the referenced node has a parent; -// i.e. the NodePath chain contains at least two nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the referenced node has a parent; i.e. the NodePath chain + * contains at least two nodes. + */ INLINE bool NodePath:: has_parent(Thread *current_thread) const { return !is_empty() && !is_singleton(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_parent -// Access: Published -// Description: Returns the NodePath to the parent of the referenced -// node: that is, this NodePath, shortened by one node. -// The parent of a singleton NodePath is defined to be -// the empty NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath to the parent of the referenced node: that is, this + * NodePath, shortened by one node. The parent of a singleton NodePath is + * defined to be the empty NodePath. + */ INLINE NodePath NodePath:: get_parent(Thread *current_thread) const { if (!has_parent(current_thread)) { @@ -469,13 +383,10 @@ get_parent(Thread *current_thread) const { return parent; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::attach_new_node -// Access: Published -// Description: Creates an ordinary PandaNode and attaches it below -// the current NodePath, returning a new NodePath that -// references it. -//////////////////////////////////////////////////////////////////// +/** + * Creates an ordinary PandaNode and attaches it below the current NodePath, + * returning a new NodePath that references it. + */ INLINE NodePath NodePath:: attach_new_node(const string &name, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), NodePath::fail()); @@ -483,21 +394,17 @@ attach_new_node(const string &name, int sort, Thread *current_thread) const { return attach_new_node(new PandaNode(name), sort, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::ls -// Access: Published -// Description: Lists the hierarchy at and below the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Lists the hierarchy at and below the referenced node. + */ INLINE void NodePath:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::ls -// Access: Published -// Description: Lists the hierarchy at and below the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Lists the hierarchy at and below the referenced node. + */ INLINE void NodePath:: ls(ostream &out, int indent_level) const { if (is_empty()) { @@ -507,274 +414,217 @@ ls(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::reverse_ls -// Access: Published -// Description: Lists the hierarchy at and above the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Lists the hierarchy at and above the referenced node. + */ INLINE void NodePath:: reverse_ls() const { reverse_ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_state -// Access: Published -// Description: Changes the complete state object on this node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the complete state object on this node. + */ INLINE void NodePath:: set_state(const RenderState *state, Thread *current_thread) { nassertv_always(!is_empty()); node()->set_state(state, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_state -// Access: Published -// Description: Returns the net state on this node from the root. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net state on this node from the root. + */ INLINE CPT(RenderState) NodePath:: get_net_state(Thread *current_thread) const { nassertr(_error_type == ET_ok, RenderState::make_empty()); return r_get_net_state(_head, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_attrib -// Access: Published -// Description: Adds the indicated render attribute to the scene -// graph on this node. This attribute will now apply to -// this node and everything below. If there was already -// an attribute of the same type, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated render attribute to the scene graph on this node. This + * attribute will now apply to this node and everything below. If there was + * already an attribute of the same type, it is replaced. + */ INLINE void NodePath:: set_attrib(const RenderAttrib *attrib, int priority) { nassertv_always(!is_empty()); node()->set_attrib(attrib, priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_attrib -// Access: Published -// Description: Returns the render attribute of the indicated type, -// if it is defined on the node, or NULL if it is not. -// This checks only what is set on this particular node -// level, and has nothing to do with what render -// attributes may be inherited from parent nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render attribute of the indicated type, if it is defined on the + * node, or NULL if it is not. This checks only what is set on this + * particular node level, and has nothing to do with what render attributes + * may be inherited from parent nodes. + */ INLINE const RenderAttrib *NodePath:: get_attrib(TypeHandle type) const { nassertr_always(!is_empty(), NULL); return node()->get_attrib(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_attrib -// Access: Published -// Description: Returns true if there is a render attribute of the -// indicated type defined on this node, or false if -// there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a render attribute of the indicated type defined + * on this node, or false if there is not. + */ INLINE bool NodePath:: has_attrib(TypeHandle type) const { nassertr_always(!is_empty(), false); return node()->has_attrib(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_attrib -// Access: Published -// Description: Removes the render attribute of the given type from -// this node. This node, and the subgraph below, will -// now inherit the indicated render attribute from the -// nodes above this one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the render attribute of the given type from this node. This node, + * and the subgraph below, will now inherit the indicated render attribute + * from the nodes above this one. + */ INLINE void NodePath:: clear_attrib(TypeHandle type) { nassertv_always(!is_empty()); node()->clear_attrib(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_effect -// Access: Published -// Description: Adds the indicated render effect to the scene -// graph on this node. If there was already an effect -// of the same type, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated render effect to the scene graph on this node. If there + * was already an effect of the same type, it is replaced. + */ INLINE void NodePath:: set_effect(const RenderEffect *effect) { nassertv_always(!is_empty()); node()->set_effect(effect); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_effect -// Access: Published -// Description: Returns the render effect of the indicated type, -// if it is defined on the node, or NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render effect of the indicated type, if it is defined on the + * node, or NULL if it is not. + */ INLINE const RenderEffect *NodePath:: get_effect(TypeHandle type) const { nassertr_always(!is_empty(), NULL); return node()->get_effect(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_effect -// Access: Published -// Description: Returns true if there is a render effect of the -// indicated type defined on this node, or false if -// there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a render effect of the indicated type defined on + * this node, or false if there is not. + */ INLINE bool NodePath:: has_effect(TypeHandle type) const { nassertr_always(!is_empty(), false); return node()->has_effect(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_effect -// Access: Published -// Description: Removes the render effect of the given type from -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the render effect of the given type from this node. + */ INLINE void NodePath:: clear_effect(TypeHandle type) { nassertv_always(!is_empty()); node()->clear_effect(type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_effects -// Access: Published -// Description: Sets the complete RenderEffects that will be applied -// this node. This completely replaces whatever has -// been set on this node via repeated calls to -// set_attrib(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the complete RenderEffects that will be applied this node. This + * completely replaces whatever has been set on this node via repeated calls + * to set_attrib(). + */ INLINE void NodePath:: set_effects(const RenderEffects *effects) { nassertv_always(!is_empty()); node()->set_effects(effects); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_effects -// Access: Published -// Description: Returns the complete RenderEffects that will be -// applied to this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete RenderEffects that will be applied to this node. + */ INLINE const RenderEffects *NodePath:: get_effects() const { nassertr_always(!is_empty(), RenderEffects::make_empty()); return node()->get_effects(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_effects -// Access: Published -// Description: Resets this node to have no render effects. -//////////////////////////////////////////////////////////////////// +/** + * Resets this node to have no render effects. + */ INLINE void NodePath:: clear_effects() { nassertv_always(!is_empty()); node()->clear_effects(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_transform -// Access: Published -// Description: Sets the transform object on this node to identity. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform object on this node to identity. + */ INLINE void NodePath:: clear_transform(Thread *current_thread) { set_transform(TransformState::make_identity(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_transform -// Access: Published -// Description: Changes the complete transform object on this node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the complete transform object on this node. + */ INLINE void NodePath:: set_transform(const TransformState *transform, Thread *current_thread) { nassertv_always(!is_empty()); node()->set_transform(transform, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_transform -// Access: Published -// Description: Sets the transform object on this node to identity, -// relative to the other node. This effectively places -// this node at the same position as the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform object on this node to identity, relative to the other + * node. This effectively places this node at the same position as the other + * node. + */ INLINE void NodePath:: clear_transform(const NodePath &other, Thread *current_thread) { set_transform(other, TransformState::make_identity(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_transform -// Access: Published -// Description: Returns the net transform on this node from the root. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net transform on this node from the root. + */ INLINE CPT(TransformState) NodePath:: get_net_transform(Thread *current_thread) const { nassertr(_error_type == ET_ok, TransformState::make_identity()); return r_get_net_transform(_head, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_prev_transform -// Access: Published -// Description: Sets the transform that represents this node's -// "previous" position, one frame ago, for the purposes -// of detecting motion for accurate collision -// calculations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform that represents this node's "previous" position, one + * frame ago, for the purposes of detecting motion for accurate collision + * calculations. + */ INLINE void NodePath:: set_prev_transform(const TransformState *transform, Thread *current_thread) { nassertv_always(!is_empty()); node()->set_prev_transform(transform, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_prev_transform -// Access: Published -// Description: Returns the net "previous" transform on this node -// from the root. See set_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the net "previous" transform on this node from the root. See + * set_prev_transform(). + */ INLINE CPT(TransformState) NodePath:: get_net_prev_transform(Thread *current_thread) const { nassertr(_error_type == ET_ok, TransformState::make_identity()); return r_get_net_prev_transform(_head, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos -// Access: Published -// Description: Sets the translation component of the transform, -// leaving rotation and scale untouched. This also -// resets the node's "previous" position, so that the -// collision system will see the node as having suddenly -// appeared in the new position, without passing any -// points in between. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component of the transform, leaving rotation and scale + * untouched. This also resets the node's "previous" position, so that the + * collision system will see the node as having suddenly appeared in the new + * position, without passing any points in between. + */ INLINE void NodePath:: set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_pos(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fluid_pos -// Access: Published -// Description: Sets the translation component, without changing the -// "previous" position, so that the collision system -// will see the node as moving fluidly from its previous -// position to its new position. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component, without changing the "previous" position, + * so that the collision system will see the node as moving fluidly from its + * previous position to its new position. + */ INLINE void NodePath:: set_fluid_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_fluid_pos(LPoint3(x, y, z)); @@ -795,12 +645,10 @@ get_z() const { return get_pos()[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr -// Access: Published -// Description: Sets the rotation component of the transform, -// leaving translation and scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, leaving translation and scale + * untouched. + */ INLINE void NodePath:: set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_hpr(LVecBase3(h, p, r)); @@ -821,12 +669,10 @@ get_r() const { return get_hpr()[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scale -// Access: Published -// Description: Sets the scale component of the transform, -// leaving translation and rotation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale component of the transform, leaving translation and rotation + * untouched. + */ INLINE void NodePath:: set_scale(PN_stdfloat scale) { set_scale(LVecBase3(scale, scale, scale)); @@ -852,12 +698,10 @@ get_sz() const { return get_scale()[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shear -// Access: Published -// Description: Sets the shear component of the transform, -// leaving translation, rotation, and scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shear component of the transform, leaving translation, rotation, + * and scale untouched. + */ INLINE void NodePath:: set_shear(PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) { set_shear(LVecBase3(shxy, shxz, shyz)); @@ -878,34 +722,28 @@ get_shyz() const { return get_shear()[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, leaving scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, leaving scale + * untouched. + */ INLINE void NodePath:: set_pos_hpr(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_pos_hpr(LVecBase3(x, y, z), LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. + */ INLINE void NodePath:: set_hpr_scale(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { set_hpr_scale(LVecBase3(h, p, r), LVecBase3(sx, sy, sz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, and scale components. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, and scale + * components. + */ INLINE void NodePath:: set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { @@ -913,37 +751,29 @@ set_pos_hpr_scale(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat h, PN LVecBase3(sx, sy, sz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_mat -// Access: Published -// Description: Completely removes any transform from the referenced -// node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any transform from the referenced node. + */ INLINE void NodePath:: clear_mat() { nassertv_always(!is_empty()); node()->clear_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_mat -// Access: Published -// Description: Returns true if a non-identity transform matrix has -// been applied to the referenced node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a non-identity transform matrix has been applied to the + * referenced node, false otherwise. + */ INLINE bool NodePath:: has_mat() const { nassertr_always(!is_empty(), false); return !node()->get_transform()->is_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_mat -// Access: Published -// Description: Returns the transform matrix that has been applied to -// the referenced node, or the identity matrix if no -// matrix has been applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix that has been applied to the referenced node, + * or the identity matrix if no matrix has been applied. + */ INLINE const LMatrix4 &NodePath:: get_mat() const { nassertr_always(!is_empty(), LMatrix4::ident_mat()); @@ -952,50 +782,39 @@ get_mat() const { } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::look_at -// Access: Published -// Description: Sets the transform on this NodePath so that it -// rotates to face the indicated point in space. This -// will overwrite any previously existing scale on the -// node, although it will preserve any translation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform on this NodePath so that it rotates to face the + * indicated point in space. This will overwrite any previously existing + * scale on the node, although it will preserve any translation. + */ INLINE void NodePath:: look_at(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { look_at(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::heads_up -// Access: Published -// Description: Behaves like look_at(), but with a strong preference -// to keeping the up vector oriented in the indicated -// "up" direction. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like look_at(), but with a strong preference to keeping the up + * vector oriented in the indicated "up" direction. + */ INLINE void NodePath:: heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { heads_up(LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos -// Access: Published -// Description: Sets the translation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component of the transform, relative to the other + * node. + */ INLINE void NodePath:: set_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_pos(other, LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fluid_pos -// Access: Published -// Description: Sets the translation component, without changing the -// "previous" position, so that the collision system -// will see the node as moving fluidly from its previous -// position to its new position. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component, without changing the "previous" position, + * so that the collision system will see the node as moving fluidly from its + * previous position to its new position. + */ INLINE void NodePath:: set_fluid_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_fluid_pos(other, LPoint3(x, y, z)); @@ -1016,12 +835,9 @@ get_z(const NodePath &other) const { return get_pos(other)[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr -// Access: Published -// Description: Sets the rotation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, relative to the other node. + */ INLINE void NodePath:: set_hpr(const NodePath &other, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_hpr(other, LPoint3(h, p, r)); @@ -1042,34 +858,26 @@ get_r(const NodePath &other) const { return get_hpr(other)[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scale -// Access: Published -// Description: Sets the scale component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale component of the transform, relative to the other node. + */ INLINE void NodePath:: set_scale(const NodePath &other, PN_stdfloat scale) { set_scale(other, LPoint3(scale, scale, scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scale -// Access: Published -// Description: Sets the scale component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale component of the transform, relative to the other node. + */ INLINE void NodePath:: set_scale(const NodePath &other, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { set_scale(other, LPoint3(sx, sy, sz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_scale -// Access: Published -// Description: Returns the relative scale of the referenced node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative scale of the referenced node as seen from the other + * node. + */ INLINE PN_stdfloat NodePath:: get_sx(const NodePath &other) const { return get_scale(other)[0]; @@ -1085,23 +893,18 @@ get_sz(const NodePath &other) const { return get_scale(other)[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shear -// Access: Published -// Description: Sets the shear component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shear component of the transform, relative to the other node. + */ INLINE void NodePath:: set_shear(const NodePath &other, PN_stdfloat shxy, PN_stdfloat shxz, PN_stdfloat shyz) { set_shear(other, LPoint3(shxy, shxz, shyz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_shear -// Access: Published -// Description: Returns the relative shear of the referenced node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative shear of the referenced node as seen from the other + * node. + */ INLINE PN_stdfloat NodePath:: get_shxy(const NodePath &other) const { return get_shear(other)[0]; @@ -1117,12 +920,10 @@ get_shyz(const NodePath &other) const { return get_shear(other)[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, relative to + * the other node. + */ INLINE void NodePath:: set_pos_hpr(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, @@ -1130,27 +931,21 @@ set_pos_hpr(const NodePath &other, set_pos_hpr(other, LVecBase3(x, y, z), LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. This, or -// set_pos_hpr_scale, is the preferred way to update a -// transform when both hpr and scale are to be changed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. This, or set_pos_hpr_scale, is the preferred way to + * update a transform when both hpr and scale are to be changed. + */ INLINE void NodePath:: set_hpr_scale(const NodePath &other, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r, PN_stdfloat sx, PN_stdfloat sy, PN_stdfloat sz) { set_hpr_scale(other, LVecBase3(h, p, r), LVecBase3(sx, sy, sz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, and scale components, relative -// to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, and scale + * components, relative to the other node. + */ INLINE void NodePath:: set_pos_hpr_scale(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, @@ -1160,68 +955,53 @@ set_pos_hpr_scale(const NodePath &other, LVecBase3(sx, sy, sz)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::look_at -// Access: Published -// Description: Sets the hpr on this NodePath so that it rotates to -// face the indicated point in space, which is relative -// to the other NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Sets the hpr on this NodePath so that it rotates to face the indicated + * point in space, which is relative to the other NodePath. + */ INLINE void NodePath:: look_at(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { look_at(other, LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::heads_up -// Access: Published -// Description: Behaves like look_at(), but with a strong preference -// to keeping the up vector oriented in the indicated -// "up" direction. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like look_at(), but with a strong preference to keeping the up + * vector oriented in the indicated "up" direction. + */ INLINE void NodePath:: heads_up(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { heads_up(other, LPoint3(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_distance -// Access: Published -// Description: Returns the straight-line distance between this -// referenced node's coordinate frame's origin, and that -// of the other node's origin. -//////////////////////////////////////////////////////////////////// +/** + * Returns the straight-line distance between this referenced node's + * coordinate frame's origin, and that of the other node's origin. + */ INLINE PN_stdfloat NodePath:: get_distance(const NodePath &other) const { LPoint3 pos = get_pos(other); return length(LVector3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_scale -// Access: Published -// Description: Sets the color scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the color scale component of the transform + */ INLINE void NodePath:: set_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) { set_color_scale(LVecBase4(sr, sg, sb, sa), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::compose_color_scale -// Access: Published -// Description: Sets the color scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the color scale component of the transform + */ INLINE void NodePath:: compose_color_scale(PN_stdfloat sr, PN_stdfloat sg, PN_stdfloat sb, PN_stdfloat sa, int priority) { compose_color_scale(LVecBase4(sr, sg, sb, sa), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sr -// Access: Published -// Description: Sets the red scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the red scale component of the transform + */ INLINE void NodePath:: set_sr(PN_stdfloat sr) { LVecBase4 new_scale = get_color_scale(); @@ -1230,11 +1010,9 @@ set_sr(PN_stdfloat sr) { set_color_scale(new_scale); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sg -// Access: Published -// Description: Sets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the alpha scale component of the transform + */ INLINE void NodePath:: set_sg(PN_stdfloat sg) { LVecBase4 new_scale = get_color_scale(); @@ -1243,11 +1021,9 @@ set_sg(PN_stdfloat sg) { set_color_scale(new_scale); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sb -// Access: Published -// Description: Sets the blue scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the blue scale component of the transform + */ INLINE void NodePath:: set_sb(PN_stdfloat sb) { LVecBase4 new_scale = get_color_scale(); @@ -1256,11 +1032,9 @@ set_sb(PN_stdfloat sb) { set_color_scale(new_scale); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_sa -// Access: Published -// Description: Sets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the alpha scale component of the transform + */ INLINE void NodePath:: set_sa(PN_stdfloat sa) { LVecBase4 new_scale = get_color_scale(); @@ -1269,321 +1043,257 @@ set_sa(PN_stdfloat sa) { set_color_scale(new_scale); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sr -// Access: Published -// Description: Gets the red scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Gets the red scale component of the transform + */ INLINE PN_stdfloat NodePath:: get_sr() const { return get_color_scale()[0]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sg -// Access: Published -// Description: Gets the green scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Gets the green scale component of the transform + */ INLINE PN_stdfloat NodePath:: get_sg() const { return get_color_scale()[1]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sb -// Access: Published -// Description: Gets the blue scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Gets the blue scale component of the transform + */ INLINE PN_stdfloat NodePath:: get_sb() const { return get_color_scale()[2]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sa -// Access: Published -// Description: Gets the alpha scale component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Gets the alpha scale component of the transform + */ INLINE PN_stdfloat NodePath:: get_sa() const { return get_color_scale()[3]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_float &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_double &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_int &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase4 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase3 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase2 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase4i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase3i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LVecBase2i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase4i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase3i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LVecBase2i &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const PTA_LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LMatrix4 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const LMatrix3 &v, int priority) { set_shader_input(new ShaderInput(id, v, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, int priority) { set_shader_input(new ShaderInput(id, tex, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, const SamplerState &sampler, int priority) { set_shader_input(new ShaderInput(id, tex, sampler, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, Texture *tex, bool read, bool write, int z, int n, int priority) { set_shader_input(new ShaderInput(id, tex, read, write, z, n, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, const NodePath &np, int priority) { set_shader_input(new ShaderInput(id, np, priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, int n1, int n2, int n3, int n4, int priority) { set_shader_input(new ShaderInput(id, LVecBase4i(n1, n2, n3, n4), priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void NodePath:: set_shader_input(CPT_InternalName id, PN_stdfloat n1, PN_stdfloat n2, PN_stdfloat n3, PN_stdfloat n4, int priority) { set_shader_input(new ShaderInput(id, LVecBase4(n1, n2, n3, n4), priority)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_offset -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_offset(TextureStage *stage, PN_stdfloat u, PN_stdfloat v) { set_tex_offset(stage, LVecBase2(u, v)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_offset -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_offset(TextureStage *stage, const LVecBase2 &uv) { nassertv_always(!is_empty()); @@ -1591,16 +1301,12 @@ set_tex_offset(TextureStage *stage, const LVecBase2 &uv) { get_tex_transform(stage)->set_pos2d(uv)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_rotate -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, clockwise in degrees, to UV's -// for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * clockwise in degrees, to UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_rotate(TextureStage *stage, PN_stdfloat r) { nassertv_always(!is_empty()); @@ -1608,15 +1314,12 @@ set_tex_rotate(TextureStage *stage, PN_stdfloat r) { get_tex_transform(stage)->set_rotate2d(r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UVW's for the given stage. -// -// This call is appropriate for 2-d or 3-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UVW's for the given stage. + * + * This call is appropriate for 2-d or 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(TextureStage *stage, PN_stdfloat scale) { nassertv_always(!is_empty()); @@ -1624,29 +1327,23 @@ set_tex_scale(TextureStage *stage, PN_stdfloat scale) { get_tex_transform(stage)->set_scale(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) { set_tex_scale(stage, LVecBase2(su, sv)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(TextureStage *stage, const LVecBase2 &scale) { nassertv_always(!is_empty()); @@ -1654,72 +1351,58 @@ set_tex_scale(TextureStage *stage, const LVecBase2 &scale) { get_tex_transform(stage)->set_scale2d(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_offset -// Access: Published -// Description: Returns the offset set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset set for the UV's for the given stage on the current + * node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE LVecBase2 NodePath:: get_tex_offset(TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase2::zero()); return get_tex_transform(stage)->get_pos2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_rotate -// Access: Published -// Description: Returns the rotation set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation set for the UV's for the given stage on the current + * node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE PN_stdfloat NodePath:: get_tex_rotate(TextureStage *stage) const { nassertr_always(!is_empty(), 0.0f); return get_tex_transform(stage)->get_rotate2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_scale -// Access: Published -// Description: Returns the scale set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale set for the UV's for the given stage on the current node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE LVecBase2 NodePath:: get_tex_scale(TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f)); return get_tex_transform(stage)->get_scale2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_pos -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_pos(TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) { set_tex_pos(stage, LVecBase3(u, v, w)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_pos -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_pos(TextureStage *stage, const LVecBase3 &uvw) { nassertv_always(!is_empty()); @@ -1727,29 +1410,23 @@ set_tex_pos(TextureStage *stage, const LVecBase3 &uvw) { get_tex_transform(stage)->set_pos(uvw)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_hpr -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, as a 3-D HPR, to UVW's -// for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * as a 3-D HPR, to UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_hpr(TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_tex_hpr(stage, LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_hpr -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, as a 3-D HPR, to UVW's -// for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * as a 3-D HPR, to UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_hpr(TextureStage *stage, const LVecBase3 &hpr) { nassertv_always(!is_empty()); @@ -1757,27 +1434,23 @@ set_tex_hpr(TextureStage *stage, const LVecBase3 &hpr) { get_tex_transform(stage)->set_hpr(hpr)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) { set_tex_scale(stage, LVecBase3(su, sv, sw)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(TextureStage *stage, const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -1785,71 +1458,59 @@ set_tex_scale(TextureStage *stage, const LVecBase3 &scale) { get_tex_transform(stage)->set_scale(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_pos -// Access: Published -// Description: Returns the offset set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_pos(TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_hpr -// Access: Published -// Description: Returns the 3-D HPR set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-D HPR set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_hpr(TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_scale_3d -// Access: Published -// Description: Returns the scale set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_scale_3d(TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f)); return get_tex_transform(stage)->get_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_offset -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_offset(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v) { set_tex_offset(other, stage, LVecBase2(u, v)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_offset -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2 &uv) { nassertv_always(!is_empty()); @@ -1857,16 +1518,12 @@ set_tex_offset(const NodePath &other, TextureStage *stage, const LVecBase2 &uv) get_tex_transform(other, stage)->set_pos2d(uv)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_rotate -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, clockwise in degrees, to UV's -// for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * clockwise in degrees, to UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_rotate(const NodePath &other, TextureStage *stage, PN_stdfloat r) { nassertv_always(!is_empty()); @@ -1874,15 +1531,12 @@ set_tex_rotate(const NodePath &other, TextureStage *stage, PN_stdfloat r) { get_tex_transform(other, stage)->set_rotate2d(r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UV's for the given stage. -// -// This call is appropriate for 2-d or 3-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UV's for the given stage. + * + * This call is appropriate for 2-d or 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat scale) { nassertv_always(!is_empty()); @@ -1890,29 +1544,23 @@ set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat scale) { get_tex_transform(stage)->set_scale(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv) { set_tex_scale(other, stage, LVecBase2(su, sv)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UV's for the given stage. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UV's for the given stage. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2 &scale) { nassertv_always(!is_empty()); @@ -1920,72 +1568,58 @@ set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase2 &scale get_tex_transform(stage)->set_scale2d(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_offset -// Access: Published -// Description: Returns the offset set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset set for the UV's for the given stage on the current + * node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE LVecBase2 NodePath:: get_tex_offset(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase2::zero()); return get_tex_transform(other, stage)->get_pos2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_rotate -// Access: Published -// Description: Returns the rotation set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation set for the UV's for the given stage on the current + * node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE PN_stdfloat NodePath:: get_tex_rotate(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), 0.0f); return get_tex_transform(other, stage)->get_rotate2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_scale -// Access: Published -// Description: Returns the scale set for the UV's for the given -// stage on the current node. -// -// This call is appropriate for ordinary 2-d texture -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale set for the UV's for the given stage on the current node. + * + * This call is appropriate for ordinary 2-d texture coordinates. + */ INLINE LVecBase2 NodePath:: get_tex_scale(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase2(1.0f, 1.0f)); return get_tex_transform(other, stage)->get_scale2d(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_pos -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_pos(const NodePath &other, TextureStage *stage, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) { set_tex_pos(other, stage, LVecBase3(u, v, w)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_pos -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated offset to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated offset to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3 &uvw) { nassertv_always(!is_empty()); @@ -1993,29 +1627,23 @@ set_tex_pos(const NodePath &other, TextureStage *stage, const LVecBase3 &uvw) { get_tex_transform(stage)->set_pos(uvw)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_hpr -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, as a 3-D HPR, to UVW's -// for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * as a 3-D HPR, to UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_hpr(const NodePath &other, TextureStage *stage, PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { set_tex_hpr(other, stage, LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_hpr -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated rotation, as a 3-D HPR, to UVW's -// for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated rotation, + * as a 3-D HPR, to UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3 &hpr) { nassertv_always(!is_empty()); @@ -2023,27 +1651,23 @@ set_tex_hpr(const NodePath &other, TextureStage *stage, const LVecBase3 &hpr) { get_tex_transform(stage)->set_hpr(hpr)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(const NodePath &other, TextureStage *stage, PN_stdfloat su, PN_stdfloat sv, PN_stdfloat sw) { set_tex_scale(other, stage, LVecBase3(su, sv, sw)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_scale -// Access: Published -// Description: Sets a texture matrix on the current node to apply -// the indicated scale to UVW's for the given stage. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets a texture matrix on the current node to apply the indicated scale to + * UVW's for the given stage. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE void NodePath:: set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -2051,53 +1675,45 @@ set_tex_scale(const NodePath &other, TextureStage *stage, const LVecBase3 &scale get_tex_transform(stage)->set_scale(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_pos -// Access: Published -// Description: Returns the offset set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_pos(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_hpr -// Access: Published -// Description: Returns the 3-D HPR set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-D HPR set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_hpr(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3::zero()); return get_tex_transform(stage)->get_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_scale_3d -// Access: Published -// Description: Returns the scale set for the UVW's for the given -// stage on the current node. -// -// This call is appropriate for 3-d texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale set for the UVW's for the given stage on the current + * node. + * + * This call is appropriate for 3-d texture coordinates. + */ INLINE LVecBase3 NodePath:: get_tex_scale_3d(const NodePath &other, TextureStage *stage) const { nassertr_always(!is_empty(), LVecBase3(1.0f, 1.0f, 1.0f)); return get_tex_transform(stage)->get_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_project_texture -// Access: Published -// Description: Undoes the effect of project_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of project_texture(). + */ INLINE void NodePath:: clear_project_texture(TextureStage *stage) { clear_texture(stage); @@ -2105,98 +1721,76 @@ clear_project_texture(TextureStage *stage) { clear_tex_projector(stage); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_texcoord -// Access: Published -// Description: Returns true if there are at least some vertices at -// this node and below that use the named texture -// coordinate set, false otherwise. Pass the empty -// string for the default texture coordinate set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are at least some vertices at this node and below + * that use the named texture coordinate set, false otherwise. Pass the empty + * string for the default texture coordinate set. + */ INLINE bool NodePath:: has_texcoord(const string &texcoord_name) const { return has_vertex_column(InternalName::get_texcoord_name(texcoord_name)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_axis -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in two dimensions around the up axis. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in two + * dimensions around the up axis. + */ INLINE void NodePath:: set_billboard_axis(PN_stdfloat offset) { set_billboard_axis(NodePath(), offset); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_point_eye -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in three dimensions about the origin, -// keeping its up vector oriented to the top of the -// camera. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in three + * dimensions about the origin, keeping its up vector oriented to the top of + * the camera. + */ INLINE void NodePath:: set_billboard_point_eye(PN_stdfloat offset) { set_billboard_point_eye(NodePath(), offset); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_point_world -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in three dimensions about the origin, -// keeping its up vector oriented to the sky. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in three + * dimensions about the origin, keeping its up vector oriented to the sky. + */ INLINE void NodePath:: set_billboard_point_world(PN_stdfloat offset) { set_billboard_point_world(NodePath(), offset); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::adjust_all_priorities -// Access: Published -// Description: Adds the indicated adjustment amount (which may be -// negative) to the priority for all transitions on the -// referenced node, and for all nodes in the subgraph -// below. This can be used to force these nodes not to -// be overridden by a high-level state change above. If -// the priority would drop below zero, it is set to -// zero. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated adjustment amount (which may be negative) to the + * priority for all transitions on the referenced node, and for all nodes in + * the subgraph below. This can be used to force these nodes not to be + * overridden by a high-level state change above. If the priority would drop + * below zero, it is set to zero. + */ INLINE void NodePath:: adjust_all_priorities(int adjustment) { nassertv_always(!is_empty()); r_adjust_all_priorities(node(), adjustment); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show -// Access: Published -// Description: Undoes the effect of a previous hide() on this node: -// makes the referenced node (and the entire subgraph -// below this node) visible to all cameras. -// -// This will not reveal the node if a parent node has -// been hidden. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous hide() on this node: makes the referenced + * node (and the entire subgraph below this node) visible to all cameras. + * + * This will not reveal the node if a parent node has been hidden. + */ INLINE void NodePath:: show() { nassertv_always(!is_empty()); node()->adjust_draw_mask(DrawMask::all_off(), DrawMask::all_off(), PandaNode::get_overall_bit()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show -// Access: Published -// Description: Makes the referenced node visible just to the -// cameras whose camera_mask shares the indicated bits. -// -// This undoes the effect of a previous hide() call. It -// will not reveal the node if a parent node has been -// hidden. However, see show_through(). -//////////////////////////////////////////////////////////////////// +/** + * Makes the referenced node visible just to the cameras whose camera_mask + * shares the indicated bits. + * + * This undoes the effect of a previous hide() call. It will not reveal the + * node if a parent node has been hidden. However, see show_through(). + */ INLINE void NodePath:: show(DrawMask camera_mask) { nassertv_always(!is_empty()); @@ -2204,35 +1798,28 @@ show(DrawMask camera_mask) { node()->adjust_draw_mask(DrawMask::all_off(), DrawMask::all_off(), camera_mask); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show_through -// Access: Published -// Description: Makes the referenced node visible just to the -// cameras whose camera_mask shares the indicated bits. -// -// Unlike show(), this will reveal the node even if a -// parent node has been hidden, thus "showing through" a -// parent's hide(). -//////////////////////////////////////////////////////////////////// +/** + * Makes the referenced node visible just to the cameras whose camera_mask + * shares the indicated bits. + * + * Unlike show(), this will reveal the node even if a parent node has been + * hidden, thus "showing through" a parent's hide(). + */ INLINE void NodePath:: show_through() { nassertv_always(!is_empty()); node()->adjust_draw_mask(PandaNode::get_overall_bit(), DrawMask::all_off(), DrawMask::all_off()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show_through -// Access: Published -// Description: Makes the referenced node visible just to the -// cameras whose camera_mask shares the indicated bits. -// -// Unlike show(), this will reveal the node even if a -// parent node has been hidden via the one-parameter -// hide() method, thus "showing through" a parent's -// hide(). (However, it will not show through a -// parent's hide() call if the no-parameter form of -// hide() was used.) -//////////////////////////////////////////////////////////////////// +/** + * Makes the referenced node visible just to the cameras whose camera_mask + * shares the indicated bits. + * + * Unlike show(), this will reveal the node even if a parent node has been + * hidden via the one-parameter hide() method, thus "showing through" a + * parent's hide(). (However, it will not show through a parent's hide() call + * if the no-parameter form of hide() was used.) + */ INLINE void NodePath:: show_through(DrawMask camera_mask) { nassertv_always(!is_empty()); @@ -2240,32 +1827,26 @@ show_through(DrawMask camera_mask) { node()->adjust_draw_mask(camera_mask, DrawMask::all_off(), DrawMask::all_off()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::hide -// Access: Published -// Description: Makes the referenced node (and the entire subgraph -// below this node) invisible to all cameras. It -// remains part of the scene graph, its bounding volume -// still contributes to its parent's bounding volume, -// and it will still be involved in collision tests. -//////////////////////////////////////////////////////////////////// +/** + * Makes the referenced node (and the entire subgraph below this node) + * invisible to all cameras. It remains part of the scene graph, its bounding + * volume still contributes to its parent's bounding volume, and it will still + * be involved in collision tests. + */ INLINE void NodePath:: hide() { nassertv_always(!is_empty()); node()->adjust_draw_mask(DrawMask::all_off(), PandaNode::get_overall_bit(), DrawMask::all_off()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::hide -// Access: Published -// Description: Makes the referenced node invisible just to the -// cameras whose camera_mask shares the indicated bits. -// -// This will also hide any nodes below this node in the -// scene graph, including those nodes for which show() -// has been called, but it will not hide descendent -// nodes for which show_through() has been called. -//////////////////////////////////////////////////////////////////// +/** + * Makes the referenced node invisible just to the cameras whose camera_mask + * shares the indicated bits. + * + * This will also hide any nodes below this node in the scene graph, including + * those nodes for which show() has been called, but it will not hide + * descendent nodes for which show_through() has been called. + */ INLINE void NodePath:: hide(DrawMask camera_mask) { nassertv_always(!is_empty()); @@ -2273,61 +1854,47 @@ hide(DrawMask camera_mask) { node()->adjust_draw_mask(DrawMask::all_off(), camera_mask, DrawMask::all_off()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_hidden -// Access: Published -// Description: Returns true if the referenced node is hidden from -// the indicated camera(s) either directly, or because -// some ancestor is hidden. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the referenced node is hidden from the indicated camera(s) + * either directly, or because some ancestor is hidden. + */ INLINE bool NodePath:: is_hidden(DrawMask camera_mask) const { return !get_hidden_ancestor(camera_mask).is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::is_stashed -// Access: Published -// Description: Returns true if the referenced node is stashed either -// directly, or because some ancestor is stashed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the referenced node is stashed either directly, or because + * some ancestor is stashed. + */ INLINE bool NodePath:: is_stashed() const { return !get_stashed_ancestor().is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_collide_mask -// Access: Published -// Description: Returns the union of all of the into_collide_masks -// for nodes at this level and below. This is the same -// thing as node()->get_net_collide_mask(). -// -// If you want to return what the into_collide_mask of -// this node itself is, without regard to its children, -// use node()->get_into_collide_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all of the into_collide_masks for nodes at this level + * and below. This is the same thing as node()->get_net_collide_mask(). + * + * If you want to return what the into_collide_mask of this node itself is, + * without regard to its children, use node()->get_into_collide_mask(). + */ INLINE CollideMask NodePath:: get_collide_mask() const { nassertr_always(!is_empty(), CollideMask::all_off()); return node()->get_net_collide_mask(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_collide_mask -// Access: Published -// Description: Recursively applies the indicated CollideMask to the -// into_collide_masks for all nodes at this level and -// below. If node_type is not TypeHandle::none(), then -// only nodes matching (or inheriting from) the -// indicated PandaNode subclass are modified. -// -// The default is to change all bits, but if -// bits_to_change is not all bits on, then only the bits -// that are set in bits_to_change are modified, allowing -// this call to change only a subset of the bits in the -// subgraph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively applies the indicated CollideMask to the into_collide_masks for + * all nodes at this level and below. If node_type is not TypeHandle::none(), + * then only nodes matching (or inheriting from) the indicated PandaNode + * subclass are modified. + * + * The default is to change all bits, but if bits_to_change is not all bits + * on, then only the bits that are set in bits_to_change are modified, + * allowing this call to change only a subset of the bits in the subgraph. + */ INLINE void NodePath:: set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, TypeHandle node_type) { @@ -2340,202 +1907,161 @@ set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, node_type); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::operator == -// Access: Published -// Description: Returns true if the two paths are equivalent; that -// is, if they contain the same list of nodes in the same -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are equivalent; that is, if they contain the + * same list of nodes in the same order. + */ INLINE bool NodePath:: operator == (const NodePath &other) const { return _head == other._head; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::operator != -// Access: Published -// Description: Returns true if the two paths are not equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are not equivalent. + */ INLINE bool NodePath:: operator != (const NodePath &other) const { return _head != other._head; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::operator < -// Access: Published -// Description: Returns true if this NodePath sorts before the other -// one, false otherwise. The sorting order of two -// nonequivalent NodePaths is consistent but undefined, -// and is useful only for storing NodePaths in a sorted -// container like an STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this NodePath sorts before the other one, false otherwise. + * The sorting order of two nonequivalent NodePaths is consistent but + * undefined, and is useful only for storing NodePaths in a sorted container + * like an STL set. + */ INLINE bool NodePath:: operator < (const NodePath &other) const { return _head < other._head; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::compare_to -// Access: Published -// Description: Returns a number less than zero if this NodePath -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -// -// Two NodePaths are considered equivalent if they -// consist of exactly the same list of nodes in the same -// order. Otherwise, they are different; different -// NodePaths will be ranked in a consistent but -// undefined ordering; the ordering is useful only for -// placing the NodePaths in a sorted container like an -// STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this NodePath sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * + * Two NodePaths are considered equivalent if they consist of exactly the same + * list of nodes in the same order. Otherwise, they are different; different + * NodePaths will be ranked in a consistent but undefined ordering; the + * ordering is useful only for placing the NodePaths in a sorted container + * like an STL set. + */ INLINE int NodePath:: compare_to(const NodePath &other) const { - // Nowadays, the NodePathComponents at the head are pointerwise - // equivalent if and only if the NodePaths are equivalent. So we - // only have to compare pointers. + // Nowadays, the NodePathComponents at the head are pointerwise equivalent + // if and only if the NodePaths are equivalent. So we only have to compare + // pointers. if (_head != other._head) { return _head < other._head ? -1 : 1; } return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_model_nodes -// Access: Published -// Description: Recursively walks through the scene graph at this -// level and below, looking for ModelNodes, and calls -// model_node->set_preserve_transform(PT_drop_node) on -// each one. This allows a subsequent call to -// flatten_strong() to eliminate all of the ModelNodes. -// -// Returns the number of ModelNodes found. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the scene graph at this level and below, looking + * for ModelNodes, and calls model_node->set_preserve_transform(PT_drop_node) + * on each one. This allows a subsequent call to flatten_strong() to + * eliminate all of the ModelNodes. + * + * Returns the number of ModelNodes found. + */ INLINE int NodePath:: clear_model_nodes() { nassertr_always(!is_empty(), 0); return r_clear_model_nodes(node()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tag -// Access: Published -// Description: Associates a user-defined value with a user-defined -// key which is stored on the node. This value has no -// meaning to Panda; but it is stored indefinitely on -// the node until it is requested again. -// -// Each unique key stores a different string value. -// There is no effective limit on the number of -// different keys that may be stored or on the length of -// any one key's value. -//////////////////////////////////////////////////////////////////// +/** + * Associates a user-defined value with a user-defined key which is stored on + * the node. This value has no meaning to Panda; but it is stored + * indefinitely on the node until it is requested again. + * + * Each unique key stores a different string value. There is no effective + * limit on the number of different keys that may be stored or on the length + * of any one key's value. + */ INLINE void NodePath:: set_tag(const string &key, const string &value) { nassertv_always(!is_empty()); node()->set_tag(key, value); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tag -// Access: Published -// Description: Retrieves the user-defined value that was previously -// set on this node for the particular key, if any. If -// no value has been previously set, returns the empty -// string. See also get_net_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the user-defined value that was previously set on this node for + * the particular key, if any. If no value has been previously set, returns + * the empty string. See also get_net_tag(). + */ INLINE string NodePath:: get_tag(const string &key) const { - // An empty NodePath quietly returns no tags. This makes - // get_net_tag() easier to implement. + // An empty NodePath quietly returns no tags. This makes get_net_tag() + // easier to implement. if (is_empty()) { return string(); } return node()->get_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tag_keys -// Access: Published -// Description: Fills the given vector up with the -// list of tags on this PandaNode. -// -// It is the user's responsibility to ensure that the -// keys vector is empty before making this call; -// otherwise, the new files will be appended to it. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of tags on this PandaNode. + * + * It is the user's responsibility to ensure that the keys vector is empty + * before making this call; otherwise, the new files will be appended to it. + */ INLINE void NodePath:: get_tag_keys(vector_string &keys) const { nassertv_always(!is_empty()); node()->get_tag_keys(keys); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_tag -// Access: Published -// Description: Returns true if a value has been defined on this node -// for the particular key (even if that value is the -// empty string), or false if no value has been set. -// See also has_net_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value has been defined on this node for the particular + * key (even if that value is the empty string), or false if no value has been + * set. See also has_net_tag(). + */ INLINE bool NodePath:: has_tag(const string &key) const { - // An empty NodePath quietly has no tags. This makes has_net_tag() - // easier to implement. + // An empty NodePath quietly has no tags. This makes has_net_tag() easier + // to implement. if (is_empty()) { return false; } return node()->has_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tag -// Access: Published -// Description: Removes the value defined for this key on this -// particular node. After a call to clear_tag(), -// has_tag() will return false for the indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Removes the value defined for this key on this particular node. After a + * call to clear_tag(), has_tag() will return false for the indicated key. + */ INLINE void NodePath:: clear_tag(const string &key) { nassertv_always(!is_empty()); node()->clear_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_tag -// Access: Published -// Description: Returns the tag value that has been defined on this -// node, or the nearest ancestor node, for the indicated -// key. If no value has been defined for the indicated -// key on any ancestor node, returns the empty string. -// See also get_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the tag value that has been defined on this node, or the nearest + * ancestor node, for the indicated key. If no value has been defined for the + * indicated key on any ancestor node, returns the empty string. See also + * get_tag(). + */ INLINE string NodePath:: get_net_tag(const string &key) const { return find_net_tag(key).get_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_net_tag -// Access: Published -// Description: Returns true if the indicated tag value has been -// defined on this node or on any ancestor node, or -// false otherwise. See also has_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated tag value has been defined on this node or on + * any ancestor node, or false otherwise. See also has_tag(). + */ INLINE bool NodePath:: has_net_tag(const string &key) const { return !find_net_tag(key).is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::list_tags -// Access: Published -// Description: Lists the tags to the nout stream, one per line. See -// PandaNode::list_tags() for a variant that allows you -// to specify the output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the tags to the nout stream, one per line. See + * PandaNode::list_tags() for a variant that allows you to specify the output + * stream. + */ INLINE void NodePath:: list_tags() const { nassertv_always(!is_empty()); @@ -2543,39 +2069,32 @@ list_tags() const { nout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_name -// Access: Published -// Description: Changes the name of the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the referenced node. + */ INLINE void NodePath:: set_name(const string &name) { nassertv_always(!is_empty()); node()->set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_name -// Access: Published -// Description: Returns the name of the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the referenced node. + */ INLINE string NodePath:: get_name() const { nassertr_always(!is_empty(), string()); return node()->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::encode_to_bam_stream -// Access: Published -// Description: Converts the NodePath object into a single -// stream of data using a BamWriter, and returns that -// data as a string string. Returns empty string on -// failure. This is similar to write_bam_stream(). -// -// This method is used by __reduce__ to handle streaming -// of NodePaths to a pickle file. -//////////////////////////////////////////////////////////////////// +/** + * Converts the NodePath object into a single stream of data using a + * BamWriter, and returns that data as a string string. Returns empty string + * on failure. This is similar to write_bam_stream(). + * + * This method is used by __reduce__ to handle streaming of NodePaths to a + * pickle file. + */ INLINE string NodePath:: encode_to_bam_stream() const { string data; @@ -2590,4 +2109,3 @@ INLINE ostream &operator << (ostream &out, const NodePath &node_path) { node_path.output(out); return out; } - diff --git a/panda/src/pgraph/nodePath.cxx b/panda/src/pgraph/nodePath.cxx index 102ca908e7..c6bfff127c 100644 --- a/panda/src/pgraph/nodePath.cxx +++ b/panda/src/pgraph/nodePath.cxx @@ -1,19 +1,16 @@ -// Filename: nodePath.cxx -// Created by: drose (25Feb02) -// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads -// for set_shader_input) -// Updated by: weifengh, PandaSE(30Apr10) (added set_shader_auto) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath.cxx + * @author drose + * @date 2002-02-25 + + */ #include "nodePath.h" #include "nodePathCollection.h" @@ -74,21 +71,18 @@ #include "bam.h" #include "bamWriter.h" -// stack seems to overflow on Intel C++ at 7000. If we need more than -// 7000, need to increase stack size. +// stack seems to overflow on Intel C++ at 7000. If we need more than 7000, +// need to increase stack size. int NodePath::_max_search_depth = 7000; TypeHandle NodePath::_type_handle; PStatCollector NodePath::_get_transform_pcollector("*:NodePath:get_transform"); PStatCollector NodePath::_verify_complete_pcollector("*:NodePath:verify_complete"); -//////////////////////////////////////////////////////////////////// -// Function: NodePath::Constructor -// Access: Published -// Description: Constructs a NodePath with the indicated parent -// NodePath and child node; the child node must be a -// stashed or unstashed child of the parent. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a NodePath with the indicated parent NodePath and child node; + * the child node must be a stashed or unstashed child of the parent. + */ NodePath:: NodePath(const NodePath &parent, PandaNode *child_node, Thread *current_thread) : @@ -114,22 +108,18 @@ NodePath(const NodePath &parent, PandaNode *child_node, _backup_key = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::operator bool -// Access: Published -// Description: Returns true if the NodePath is valid (not empty), -// or false if it contains no nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NodePath is valid (not empty), or false if it contains + * no nodes. + */ NodePath:: operator bool () const { return !is_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_num_nodes -// Access: Published -// Description: Returns the number of nodes in the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nodes in the path. + */ int NodePath:: get_num_nodes(Thread *current_thread) const { if (is_empty()) { @@ -139,22 +129,18 @@ get_num_nodes(Thread *current_thread) const { return _head->get_length(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_node -// Access: Published -// Description: Returns the nth node of the path, where 0 is the -// referenced (bottom) node and get_num_nodes() - 1 is -// the top node. This requires iterating through the -// path. -// -// Also see node(), which is a convenience function to -// return the same thing as get_node(0) (since the -// bottom node is the most important node in the -// NodePath, and is the one most frequently referenced). -// -// Note that this function returns the same thing as -// get_ancestor(index).node(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth node of the path, where 0 is the referenced (bottom) node + * and get_num_nodes() - 1 is the top node. This requires iterating through + * the path. + * + * Also see node(), which is a convenience function to return the same thing + * as get_node(0) (since the bottom node is the most important node in the + * NodePath, and is the one most frequently referenced). + * + * Note that this function returns the same thing as + * get_ancestor(index).node(). + */ PandaNode *NodePath:: get_node(int index, Thread *current_thread) const { nassertr(index >= 0 && index < get_num_nodes(), NULL); @@ -163,29 +149,26 @@ get_node(int index, Thread *current_thread) const { NodePathComponent *comp = _head; while (index > 0) { - // If this assertion fails, the index was out of range; the - // component's length must have been invalid. + // If this assertion fails, the index was out of range; the component's + // length must have been invalid. nassertr(comp != (NodePathComponent *)NULL, NULL); comp = comp->get_next(pipeline_stage, current_thread); index--; } - // If this assertion fails, the index was out of range; the - // component's length must have been invalid. + // If this assertion fails, the index was out of range; the component's + // length must have been invalid. nassertr(comp != (NodePathComponent *)NULL, NULL); return comp->get_node(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_ancestor -// Access: Published -// Description: Returns the nth ancestor of the path, where 0 is the -// NodePath itself and get_num_nodes() - 1 is get_top(). -// This requires iterating through the path. -// -// Also see get_node(), which returns the same thing as -// a PandaNode pointer, not a NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth ancestor of the path, where 0 is the NodePath itself and + * get_num_nodes() - 1 is get_top(). This requires iterating through the path. + * + * Also see get_node(), which returns the same thing as a PandaNode pointer, + * not a NodePath. + */ NodePath NodePath:: get_ancestor(int index, Thread *current_thread) const { nassertr(index >= 0 && index < get_num_nodes(), NodePath::fail()); @@ -194,15 +177,15 @@ get_ancestor(int index, Thread *current_thread) const { NodePathComponent *comp = _head; while (index > 0) { - // If this assertion fails, the index was out of range; the - // component's length must have been invalid. + // If this assertion fails, the index was out of range; the component's + // length must have been invalid. nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); comp = comp->get_next(pipeline_stage, current_thread); index--; } - // If this assertion fails, the index was out of range; the - // component's length must have been invalid. + // If this assertion fails, the index was out of range; the component's + // length must have been invalid. nassertr(comp != (NodePathComponent *)NULL, NodePath::fail()); NodePath result; @@ -210,12 +193,10 @@ get_ancestor(int index, Thread *current_thread) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_top -// Access: Published -// Description: Returns a singleton NodePath that represents the top -// of the path, or empty NodePath if this path is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns a singleton NodePath that represents the top of the path, or empty + * NodePath if this path is empty. + */ NodePath NodePath:: get_top(Thread *current_thread) const { if (is_empty()) { @@ -236,12 +217,9 @@ get_top(Thread *current_thread) const { } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_children -// Access: Published -// Description: Returns the set of all child nodes of the referenced -// node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of all child nodes of the referenced node. + */ NodePathCollection NodePath:: get_children(Thread *current_thread) const { NodePathCollection result; @@ -263,14 +241,11 @@ get_children(Thread *current_thread) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_stashed_children -// Access: Published -// Description: Returns the set of all child nodes of the referenced -// node that have been stashed. These children are not -// normally visible on the node, and do not appear in -// the list returned by get_children(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of all child nodes of the referenced node that have been + * stashed. These children are not normally visible on the node, and do not + * appear in the list returned by get_children(). + */ NodePathCollection NodePath:: get_stashed_children(Thread *current_thread) const { NodePathCollection result; @@ -291,15 +266,12 @@ get_stashed_children(Thread *current_thread) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_sort -// Access: Published -// Description: Returns the sort value of the referenced node within -// its parent; that is, the sort number passed on the -// last reparenting operation for this node. This will -// control the position of the node within its parent's -// list of children. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort value of the referenced node within its parent; that is, + * the sort number passed on the last reparenting operation for this node. + * This will control the position of the node within its parent's list of + * children. + */ int NodePath:: get_sort(Thread *current_thread) const { if (!has_parent()) { @@ -325,14 +297,11 @@ get_sort(Thread *current_thread) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find -// Access: Published -// Description: Searches for a node below the referenced node that -// matches the indicated string. Returns the shortest -// match found, if any, or an empty NodePath if no match -// can be found. -//////////////////////////////////////////////////////////////////// +/** + * Searches for a node below the referenced node that matches the indicated + * string. Returns the shortest match found, if any, or an empty NodePath if + * no match can be found. + */ NodePath NodePath:: find(const string &path) const { nassertr_always(!is_empty(), fail()); @@ -347,12 +316,10 @@ find(const string &path) const { return col.get_path(0); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_path_to -// Access: Published -// Description: Searches for the indicated node below this node and -// returns the shortest NodePath that connects them. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated node below this node and returns the shortest + * NodePath that connects them. + */ NodePath NodePath:: find_path_to(PandaNode *node) const { nassertr_always(!is_empty(), fail()); @@ -371,14 +338,10 @@ find_path_to(PandaNode *node) const { return col.get_path(0); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_matches -// Access: Published -// Description: Returns the complete set of all NodePaths that begin -// with this NodePath and can be extended by -// path. The shortest paths will be listed -// first. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete set of all NodePaths that begin with this NodePath and + * can be extended by path. The shortest paths will be listed first. + */ NodePathCollection NodePath:: find_all_matches(const string &path) const { NodePathCollection col; @@ -388,13 +351,10 @@ find_all_matches(const string &path) const { return col; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_paths_to -// Access: Published -// Description: Returns the set of all NodePaths that extend from -// this NodePath down to the indicated node. The -// shortest paths will be listed first. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of all NodePaths that extend from this NodePath down to the + * indicated node. The shortest paths will be listed first. + */ NodePathCollection NodePath:: find_all_paths_to(PandaNode *node) const { NodePathCollection col; @@ -408,20 +368,17 @@ find_all_paths_to(PandaNode *node) const { return col; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::reparent_to -// Access: Published -// Description: Removes the referenced node of the NodePath from its -// current parent and attaches it to the referenced node -// of the indicated NodePath. -// -// If the destination NodePath is empty, this is the -// same thing as detach_node(). -// -// If the referenced node is already a child of the -// indicated NodePath (via some other instance), this -// operation fails and leaves the NodePath detached. -//////////////////////////////////////////////////////////////////// +/** + * Removes the referenced node of the NodePath from its current parent and + * attaches it to the referenced node of the indicated NodePath. + * + * If the destination NodePath is empty, this is the same thing as + * detach_node(). + * + * If the referenced node is already a child of the indicated NodePath (via + * some other instance), this operation fails and leaves the NodePath + * detached. + */ void NodePath:: reparent_to(const NodePath &other, int sort, Thread *current_thread) { nassertv(verify_complete()); @@ -438,14 +395,11 @@ reparent_to(const NodePath &other, int sort, Thread *current_thread) { nassertv(reparented); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::stash_to -// Access: Published -// Description: Similar to reparent_to(), but the node is added to -// its new parent's stashed list, so that the result is -// equivalent to calling reparent_to() immediately -// followed by stash(). -//////////////////////////////////////////////////////////////////// +/** + * Similar to reparent_to(), but the node is added to its new parent's stashed + * list, so that the result is equivalent to calling reparent_to() immediately + * followed by stash(). + */ void NodePath:: stash_to(const NodePath &other, int sort, Thread *current_thread) { nassertv(verify_complete()); @@ -462,15 +416,11 @@ stash_to(const NodePath &other, int sort, Thread *current_thread) { nassertv(reparented); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::wrt_reparent_to -// Access: Published -// Description: This functions identically to reparent_to(), except -// the transform on this node is also adjusted so that -// the node remains in the same place in world -// coordinates, even if it is reparented into a -// different coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * This functions identically to reparent_to(), except the transform on this + * node is also adjusted so that the node remains in the same place in world + * coordinates, even if it is reparented into a different coordinate system. + */ void NodePath:: wrt_reparent_to(const NodePath &other, int sort, Thread *current_thread) { nassertv(verify_complete(current_thread)); @@ -489,34 +439,26 @@ wrt_reparent_to(const NodePath &other, int sort, Thread *current_thread) { reparent_to(other, sort, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::instance_to -// Access: Published -// Description: Adds the referenced node of the NodePath as a child -// of the referenced node of the indicated other -// NodePath. Any other parent-child relations of the -// node are unchanged; in particular, the node is not -// removed from its existing parent, if any. -// -// If the node already had an existing parent, this -// method will create a new instance of the node within -// the scene graph. -// -// This does not change the NodePath itself, but does -// return a new NodePath that reflects the new instance -// node. -// -// If the destination NodePath is empty, this creates a -// new instance which is not yet parented to any node. -// A new instance of this sort cannot easily be -// differentiated from other similar instances, but it -// is nevertheless a different instance and it will -// return a different get_id() value. -// -// If the referenced node is already a child of the -// indicated NodePath, returns that already-existing -// instance, unstashing it first if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Adds the referenced node of the NodePath as a child of the referenced node + * of the indicated other NodePath. Any other parent-child relations of the + * node are unchanged; in particular, the node is not removed from its + * existing parent, if any. + * + * If the node already had an existing parent, this method will create a new + * instance of the node within the scene graph. + * + * This does not change the NodePath itself, but does return a new NodePath + * that reflects the new instance node. + * + * If the destination NodePath is empty, this creates a new instance which is + * not yet parented to any node. A new instance of this sort cannot easily be + * differentiated from other similar instances, but it is nevertheless a + * different instance and it will return a different get_id() value. + * + * If the referenced node is already a child of the indicated NodePath, + * returns that already-existing instance, unstashing it first if necessary. + */ NodePath NodePath:: instance_to(const NodePath &other, int sort, Thread *current_thread) const { nassertr(verify_complete(), NodePath::fail()); @@ -526,8 +468,7 @@ instance_to(const NodePath &other, int sort, Thread *current_thread) const { NodePath new_instance; - // First, we'll attach to NULL, to guarantee we get a brand new - // instance. + // First, we'll attach to NULL, to guarantee we get a brand new instance. int pipeline_stage = current_thread->get_pipeline_stage(); new_instance._head = PandaNode::attach(NULL, node(), sort, pipeline_stage, current_thread); @@ -537,9 +478,9 @@ instance_to(const NodePath &other, int sort, Thread *current_thread) const { sort, false, pipeline_stage, current_thread); if (!reparented) { - // Hmm, couldn't reparent. Either making this instance would - // create a cycle, or it was already a child of that node. If it - // was already a child, return that existing NodePath instead. + // Hmm, couldn't reparent. Either making this instance would create a + // cycle, or it was already a child of that node. If it was already a + // child, return that existing NodePath instead. NodePath orig(other, node(), current_thread); if (!orig.is_empty()) { if (orig.is_stashed()) { @@ -552,23 +493,19 @@ instance_to(const NodePath &other, int sort, Thread *current_thread) const { nassertr(reparented, new_instance); } - // instance_to() doesn't reset the velocity delta, unlike most of - // the other reparenting operations. The reasoning is that - // instance_to() is not necessarily a reparenting operation, since - // it doesn't change the original instance. + // instance_to() doesn't reset the velocity delta, unlike most of the other + // reparenting operations. The reasoning is that instance_to() is not + // necessarily a reparenting operation, since it doesn't change the original + // instance. return new_instance; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::instance_under_node -// Access: Published -// Description: Behaves like instance_to(), but implicitly creates a -// new node to instance the geometry under, and returns a -// NodePath to that new node. This allows the -// programmer to set a unique state and/or transform on -// this instance. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like instance_to(), but implicitly creates a new node to instance + * the geometry under, and returns a NodePath to that new node. This allows + * the programmer to set a unique state and/or transform on this instance. + */ NodePath NodePath:: instance_under_node(const NodePath &other, const string &name, int sort, Thread *current_thread) const { @@ -581,15 +518,11 @@ instance_under_node(const NodePath &other, const string &name, int sort, return new_node; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::copy_to -// Access: Published -// Description: Functions like instance_to(), except a deep -// copy is made of the referenced node and all of its -// descendents, which is then parented to the indicated -// node. A NodePath to the newly created copy is -// returned. -//////////////////////////////////////////////////////////////////// +/** + * Functions like instance_to(), except a deep copy is made of the referenced + * node and all of its descendents, which is then parented to the indicated + * node. A NodePath to the newly created copy is returned. + */ NodePath NodePath:: copy_to(const NodePath &other, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), fail()); @@ -606,22 +539,18 @@ copy_to(const NodePath &other, int sort, Thread *current_thread) const { return other.attach_new_node(copy_node, sort, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::attach_new_node -// Access: Published -// Description: Attaches a new node, with or without existing -// parents, to the scene graph below the referenced node -// of this NodePath. This is the preferred way to add -// nodes to the graph. -// -// If the node was already a child of the parent, this -// returns a NodePath to the existing child. -// -// This does *not* automatically extend the current -// NodePath to reflect the attachment; however, a -// NodePath that does reflect this extension is -// returned. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a new node, with or without existing parents, to the scene graph + * below the referenced node of this NodePath. This is the preferred way to + * add nodes to the graph. + * + * If the node was already a child of the parent, this returns a NodePath to + * the existing child. + * + * This does *not* automatically extend the current NodePath to reflect the + * attachment; however, a NodePath that does reflect this extension is + * returned. + */ NodePath NodePath:: attach_new_node(PandaNode *node, int sort, Thread *current_thread) const { nassertr(verify_complete(current_thread), NodePath::fail()); @@ -635,35 +564,28 @@ attach_new_node(PandaNode *node, int sort, Thread *current_thread) const { return new_path; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::remove_node -// Access: Published -// Description: Disconnects the referenced node from the scene graph. -// This will also delete the node if there are no other -// pointers to it. -// -// Normally, this should be called only when you are -// really done with the node. If you want to remove a -// node from the scene graph but keep it around for -// later, you should probably use detach_node() instead. -// -// In practice, the only difference between -// remove_node() and detach_node() is that remove_node() -// also resets the NodePath to empty, which will cause -// the node to be deleted immediately if there are no -// other references. On the other hand, detach_node() -// leaves the NodePath referencing the node, which will -// keep at least one reference to the node for as long -// as the NodePath exists. -//////////////////////////////////////////////////////////////////// +/** + * Disconnects the referenced node from the scene graph. This will also + * delete the node if there are no other pointers to it. + * + * Normally, this should be called only when you are really done with the + * node. If you want to remove a node from the scene graph but keep it around + * for later, you should probably use detach_node() instead. + * + * In practice, the only difference between remove_node() and detach_node() is + * that remove_node() also resets the NodePath to empty, which will cause the + * node to be deleted immediately if there are no other references. On the + * other hand, detach_node() leaves the NodePath referencing the node, which + * will keep at least one reference to the node for as long as the NodePath + * exists. + */ void NodePath:: remove_node(Thread *current_thread) { nassertv(_error_type != ET_not_found); - // If we have no parents, remove_node() is just a do-nothing - // operation; if we have no nodes, maybe we were already removed. - // In either case, quietly do nothing except to ensure the - // NodePath is clear. + // If we have no parents, remove_node() is just a do-nothing operation; if + // we have no nodes, maybe we were already removed. In either case, quietly + // do nothing except to ensure the NodePath is clear. if (!is_empty() && !is_singleton(current_thread)) { node()->reset_prev_transform(current_thread); int pipeline_stage = current_thread->get_pipeline_stage(); @@ -682,27 +604,21 @@ remove_node(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::detach_node -// Access: Published -// Description: Disconnects the referenced node from its parent, but -// does not immediately delete it. The NodePath retains -// a pointer to the node, and becomes a singleton -// NodePath. -// -// This should be called to detach a node from the scene -// graph, with the option of reattaching it later to the -// same parent or to a different parent. -// -// In practice, the only difference between -// remove_node() and detach_node() is that remove_node() -// also resets the NodePath to empty, which will cause -// the node to be deleted immediately if there are no -// other references. On the other hand, detach_node() -// leaves the NodePath referencing the node, which will -// keep at least one reference to the node for as long -// as the NodePath exists. -//////////////////////////////////////////////////////////////////// +/** + * Disconnects the referenced node from its parent, but does not immediately + * delete it. The NodePath retains a pointer to the node, and becomes a + * singleton NodePath. + * + * This should be called to detach a node from the scene graph, with the + * option of reattaching it later to the same parent or to a different parent. + * + * In practice, the only difference between remove_node() and detach_node() is + * that remove_node() also resets the NodePath to empty, which will cause the + * node to be deleted immediately if there are no other references. On the + * other hand, detach_node() leaves the NodePath referencing the node, which + * will keep at least one reference to the node for as long as the NodePath + * exists. + */ void NodePath:: detach_node(Thread *current_thread) { nassertv(_error_type != ET_not_found); @@ -713,11 +629,9 @@ detach_node(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::reverse_ls -// Access: Published -// Description: Lists the hierarchy at and above the referenced node. -//////////////////////////////////////////////////////////////////// +/** + * Lists the hierarchy at and above the referenced node. + */ int NodePath:: reverse_ls(ostream &out, int indent_level) const { if (is_empty()) { @@ -730,12 +644,10 @@ reverse_ls(ostream &out, int indent_level) const { return indent_level + 2; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::output -// Access: Published -// Description: Writes a sensible description of the NodePath to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a sensible description of the NodePath to the indicated output + * stream. + */ void NodePath:: output(ostream &out) const { switch (_error_type) { @@ -759,26 +671,21 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_state -// Access: Published -// Description: Returns the complete state object set on this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete state object set on this node. + */ const RenderState *NodePath:: get_state(Thread *current_thread) const { - // This method is declared non-inline to avoid a compiler bug in - // gcc-3.4 and gcc-4.0. + // This method is declared non-inline to avoid a compiler bug in gcc-3.4 and + // gcc-4.0. nassertr_always(!is_empty(), RenderState::make_empty()); return node()->get_state(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_state -// Access: Published -// Description: Returns the state changes that must be made to -// transition to the render state of this node from the -// render state of the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the state changes that must be made to transition to the render + * state of this node from the render state of the other node. + */ CPT(RenderState) NodePath:: get_state(const NodePath &other, Thread *current_thread) const { nassertr(_error_type == ET_ok && other._error_type == ET_ok, RenderState::make_empty()); @@ -810,14 +717,11 @@ get_state(const NodePath &other, Thread *current_thread) const { return b_state->invert_compose(a_state); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_state -// Access: Published -// Description: Sets the state object on this node, relative to -// the other node. This computes a new state object -// that will have the indicated value when seen from the -// other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state object on this node, relative to the other node. This + * computes a new state object that will have the indicated value when seen + * from the other node. + */ void NodePath:: set_state(const NodePath &other, const RenderState *state, Thread *current_thread) { @@ -836,26 +740,21 @@ set_state(const NodePath &other, const RenderState *state, set_state(new_state, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_transform -// Access: Published -// Description: Returns the complete transform object set on this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete transform object set on this node. + */ const TransformState *NodePath:: get_transform(Thread *current_thread) const { - // This method is declared non-inline to avoid a compiler bug in - // gcc-3.4 and gcc-4.0. + // This method is declared non-inline to avoid a compiler bug in gcc-3.4 and + // gcc-4.0. nassertr_always(!is_empty(), TransformState::make_identity()); return node()->get_transform(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_transform -// Access: Published -// Description: Returns the relative transform to this node from the -// other node; i.e. the transformation of this node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform to this node from the other node; i.e. the + * transformation of this node as seen from the other node. + */ CPT(TransformState) NodePath:: get_transform(const NodePath &other, Thread *current_thread) const { nassertr(_error_type == ET_ok && other._error_type == ET_ok, TransformState::make_identity()); @@ -892,9 +791,9 @@ get_transform(const NodePath &other, Thread *current_thread) const { b_transform = r_get_partial_transform(other._head, b_count, current_thread); } if (b_transform == (TransformState *)NULL) { - // If either path involved a node with a net_transform - // RenderEffect applied, we have to go all the way up to the root - // to get the right answer. + // If either path involved a node with a net_transform RenderEffect + // applied, we have to go all the way up to the root to get the right + // answer. a_transform = r_get_net_transform(_head, current_thread); b_transform = r_get_net_transform(other._head, current_thread); } @@ -902,14 +801,11 @@ get_transform(const NodePath &other, Thread *current_thread) const { return b_transform->invert_compose(a_transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_transform -// Access: Published -// Description: Sets the transform object on this node, relative to -// the other node. This computes a new transform object -// that will have the indicated value when seen from the -// other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform object on this node, relative to the other node. This + * computes a new transform object that will have the indicated value when + * seen from the other node. + */ void NodePath:: set_transform(const NodePath &other, const TransformState *transform, Thread *current_thread) { @@ -928,29 +824,23 @@ set_transform(const NodePath &other, const TransformState *transform, set_transform(new_trans, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_prev_transform -// Access: Published -// Description: Returns the transform that has been set as this -// node's "previous" position. See -// set_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform that has been set as this node's "previous" position. + * See set_prev_transform(). + */ const TransformState *NodePath:: get_prev_transform(Thread *current_thread) const { - // This method is declared non-inline to avoid a compiler bug in - // gcc-3.4 and gcc-4.0. + // This method is declared non-inline to avoid a compiler bug in gcc-3.4 and + // gcc-4.0. nassertr_always(!is_empty(), TransformState::make_identity()); return node()->get_prev_transform(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_prev_transform -// Access: Published -// Description: Returns the relative "previous" transform to this -// node from the other node; i.e. the position of this -// node in the previous frame, as seen by the other node -// in the previous frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative "previous" transform to this node from the other node; + * i.e. the position of this node in the previous frame, as seen by the other + * node in the previous frame. + */ CPT(TransformState) NodePath:: get_prev_transform(const NodePath &other, Thread *current_thread) const { nassertr(_error_type == ET_ok && other._error_type == ET_ok, TransformState::make_identity()); @@ -982,14 +872,11 @@ get_prev_transform(const NodePath &other, Thread *current_thread) const { return b_prev_transform->invert_compose(a_prev_transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_prev_transform -// Access: Published -// Description: Sets the "previous" transform object on this node, -// relative to the other node. This computes a new -// transform object that will have the indicated value -// when seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "previous" transform object on this node, relative to the other + * node. This computes a new transform object that will have the indicated + * value when seen from the other node. + */ void NodePath:: set_prev_transform(const NodePath &other, const TransformState *transform, Thread *current_thread) { @@ -1008,17 +895,13 @@ set_prev_transform(const NodePath &other, const TransformState *transform, set_prev_transform(new_trans, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos -// Access: Published -// Description: Sets the translation component of the transform, -// leaving rotation and scale untouched. This also -// resets the node's "previous" position, so that the -// collision system will see the node as having suddenly -// appeared in the new position, without passing any -// points in between. -// See Also: NodePath::set_fluid_pos -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component of the transform, leaving rotation and scale + * untouched. This also resets the node's "previous" position, so that the + * collision system will see the node as having suddenly appeared in the new + * position, without passing any points in between. See Also: + * NodePath::set_fluid_pos + */ void NodePath:: set_pos(const LVecBase3 &pos) { nassertv_always(!is_empty()); @@ -1050,15 +933,11 @@ set_z(PN_stdfloat z) { set_pos(pos); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fluid_pos -// Access: Published -// Description: Sets the translation component, without changing the -// "previous" position, so that the collision system -// will see the node as moving fluidly from its previous -// position to its new position. -// See Also: NodePath::set_pos -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component, without changing the "previous" position, + * so that the collision system will see the node as moving fluidly from its + * previous position to its new position. See Also: NodePath::set_pos + */ void NodePath:: set_fluid_pos(const LVecBase3 &pos) { nassertv_always(!is_empty()); @@ -1089,43 +968,34 @@ set_fluid_z(PN_stdfloat z) { set_fluid_pos(pos); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_pos -// Access: Published -// Description: Retrieves the translation component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the translation component of the transform. + */ LPoint3 NodePath:: get_pos() const { nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform()->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_pos_delta -// Access: Published -// Description: Returns the delta vector from this node's position in -// the previous frame (according to -// set_prev_transform(), typically set via the use of -// set_fluid_pos()) and its position in the current -// frame. This is the vector used to determine -// collisions. Generally, if the node was last -// repositioned via set_pos(), the delta will be zero; -// if it was adjusted via set_fluid_pos(), the delta -// will represent the change from the previous frame's -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the delta vector from this node's position in the previous frame + * (according to set_prev_transform(), typically set via the use of + * set_fluid_pos()) and its position in the current frame. This is the vector + * used to determine collisions. Generally, if the node was last repositioned + * via set_pos(), the delta will be zero; if it was adjusted via + * set_fluid_pos(), the delta will represent the change from the previous + * frame's position. + */ LVector3 NodePath:: get_pos_delta() const { nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform()->get_pos() - get_prev_transform()->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr -// Access: Published -// Description: Sets the rotation component of the transform, -// leaving translation and scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, leaving translation and scale + * untouched. + */ void NodePath:: set_hpr(const LVecBase3 &hpr) { nassertv_always(!is_empty()); @@ -1164,11 +1034,9 @@ set_r(PN_stdfloat r) { set_transform(transform->set_hpr(hpr)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_hpr -// Access: Published -// Description: Retrieves the rotation component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the rotation component of the transform. + */ LVecBase3 NodePath:: get_hpr() const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1177,12 +1045,10 @@ get_hpr() const { return transform->get_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_quat -// Access: Published -// Description: Sets the rotation component of the transform, -// leaving translation and scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, leaving translation and scale + * untouched. + */ void NodePath:: set_quat(const LQuaternion &quat) { nassertv_always(!is_empty()); @@ -1190,11 +1056,9 @@ set_quat(const LQuaternion &quat) { set_transform(transform->set_quat(quat)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_quat -// Access: Published -// Description: Retrieves the rotation component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the rotation component of the transform. + */ LQuaternion NodePath:: get_quat() const { nassertr_always(!is_empty(), LQuaternion::ident_quat()); @@ -1202,12 +1066,10 @@ get_quat() const { return transform->get_quat(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scale -// Access: Published -// Description: Sets the scale component of the transform, -// leaving translation and rotation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale component of the transform, leaving translation and rotation + * untouched. + */ void NodePath:: set_scale(const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -1242,11 +1104,9 @@ set_sz(PN_stdfloat sz) { set_transform(transform->set_scale(scale)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_scale -// Access: Published -// Description: Retrieves the scale component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the scale component of the transform. + */ LVecBase3 NodePath:: get_scale() const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1254,12 +1114,10 @@ get_scale() const { return transform->get_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shear -// Access: Published -// Description: Sets the shear component of the transform, -// leaving translation and rotation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shear component of the transform, leaving translation and rotation + * untouched. + */ void NodePath:: set_shear(const LVecBase3 &shear) { nassertv_always(!is_empty()); @@ -1294,11 +1152,9 @@ set_shyz(PN_stdfloat shyz) { set_transform(transform->set_shear(shear)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_shear -// Access: Published -// Description: Retrieves the shear component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the shear component of the transform. + */ LVecBase3 NodePath:: get_shear() const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1306,12 +1162,10 @@ get_shear() const { return transform->get_shear(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, leaving scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, leaving scale + * untouched. + */ void NodePath:: set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { nassertv_always(!is_empty()); @@ -1322,12 +1176,10 @@ set_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, leaving scale untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, leaving scale + * untouched. + */ void NodePath:: set_pos_quat(const LVecBase3 &pos, const LQuaternion &quat) { nassertv_always(!is_empty()); @@ -1338,12 +1190,10 @@ set_pos_quat(const LVecBase3 &pos, const LQuaternion &quat) { node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. + */ void NodePath:: set_hpr_scale(const LVecBase3 &hpr, const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -1353,12 +1203,10 @@ set_hpr_scale(const LVecBase3 &hpr, const LVecBase3 &scale) { set_transform(transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_quat_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. + */ void NodePath:: set_quat_scale(const LQuaternion &quat, const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -1368,12 +1216,10 @@ set_quat_scale(const LQuaternion &quat, const LVecBase3 &scale) { set_transform(transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale -// Access: Published -// Description: Replaces the translation, rotation, and scale -// components, implicitly setting shear to 0. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the translation, rotation, and scale components, implicitly + * setting shear to 0. + */ void NodePath:: set_pos_hpr_scale(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { @@ -1383,12 +1229,10 @@ set_pos_hpr_scale(const LVecBase3 &pos, const LVecBase3 &hpr, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat_scale -// Access: Published -// Description: Replaces the translation, rotation, and scale -// components, implicitly setting shear to 0. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the translation, rotation, and scale components, implicitly + * setting shear to 0. + */ void NodePath:: set_pos_quat_scale(const LVecBase3 &pos, const LQuaternion &quat, const LVecBase3 &scale) { @@ -1398,12 +1242,10 @@ set_pos_quat_scale(const LVecBase3 &pos, const LQuaternion &quat, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale_shear -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, scale, and shear components. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, scale, + * and shear components. + */ void NodePath:: set_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale, const LVecBase3 &shear) { @@ -1413,12 +1255,10 @@ set_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat_scale_shear -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, scale, and shear components. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, scale, + * and shear components. + */ void NodePath:: set_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, const LVecBase3 &scale, const LVecBase3 &shear) { @@ -1428,11 +1268,9 @@ set_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_mat -// Access: Published -// Description: Directly sets an arbitrary 4x4 transform matrix. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets an arbitrary 4x4 transform matrix. + */ void NodePath:: set_mat(const LMatrix4 &mat) { nassertv_always(!is_empty()); @@ -1440,12 +1278,10 @@ set_mat(const LMatrix4 &mat) { node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::look_at -// Access: Published -// Description: Sets the hpr on this NodePath so that it -// rotates to face the indicated point in space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the hpr on this NodePath so that it rotates to face the indicated + * point in space. + */ void NodePath:: look_at(const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); @@ -1457,13 +1293,10 @@ look_at(const LPoint3 &point, const LVector3 &up) { set_quat(quat); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::heads_up -// Access: Published -// Description: Behaves like look_at(), but with a strong preference -// to keeping the up vector oriented in the indicated -// "up" direction. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like look_at(), but with a strong preference to keeping the up + * vector oriented in the indicated "up" direction. + */ void NodePath:: heads_up(const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); @@ -1475,12 +1308,10 @@ heads_up(const LPoint3 &point, const LVector3 &up) { set_quat(quat); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos -// Access: Published -// Description: Sets the translation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component of the transform, relative to the other + * node. + */ void NodePath:: set_pos(const NodePath &other, const LVecBase3 &pos) { nassertv_always(!is_empty()); @@ -1488,10 +1319,10 @@ set_pos(const NodePath &other, const LVecBase3 &pos) { CPT(TransformState) orig_transform = get_transform(); if (orig_transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_hpr = orig_transform->get_hpr(); const LVecBase3 &orig_scale = orig_transform->get_scale(); const LVecBase3 &orig_shear = orig_transform->get_shear(); @@ -1500,8 +1331,7 @@ set_pos(const NodePath &other, const LVecBase3 &pos) { set_pos_hpr_scale_shear(get_transform()->get_pos(), orig_hpr, orig_scale, orig_shear); } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_pos(pos)); } node()->reset_prev_transform(); @@ -1531,12 +1361,10 @@ set_z(const NodePath &other, PN_stdfloat z) { set_pos(other, pos); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fluid_pos -// Access: Published -// Description: Sets the translation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation component of the transform, relative to the other + * node. + */ void NodePath:: set_fluid_pos(const NodePath &other, const LVecBase3 &pos) { nassertv_always(!is_empty()); @@ -1544,23 +1372,22 @@ set_fluid_pos(const NodePath &other, const LVecBase3 &pos) { CPT(TransformState) orig_transform = get_transform(); if (orig_transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_hpr = orig_transform->get_hpr(); const LVecBase3 &orig_scale = orig_transform->get_scale(); const LVecBase3 &orig_shear = orig_transform->get_shear(); - // Use the relative set_transform() to compute the relative pos, and - // then reset all of the other components back to the way they were. + // Use the relative set_transform() to compute the relative pos, and then + // reset all of the other components back to the way they were. set_transform(other, rel_transform->set_pos(pos)); set_transform(TransformState::make_pos_hpr_scale_shear (get_transform()->get_pos(), orig_hpr, orig_scale, orig_shear)); } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_pos(pos)); } } @@ -1589,45 +1416,34 @@ set_fluid_z(const NodePath &other, PN_stdfloat z) { set_fluid_pos(other, pos); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_pos -// Access: Published -// Description: Returns the relative position of the referenced node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative position of the referenced node as seen from the other + * node. + */ LPoint3 NodePath:: get_pos(const NodePath &other) const { nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform(other)->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_pos_delta -// Access: Published -// Description: Returns the delta vector from this node's position in -// the previous frame (according to -// set_prev_transform(), typically set via the use of -// set_fluid_pos()) and its position in the current -// frame, as seen in the indicated node's coordinate -// space. This is the vector used to determine -// collisions. Generally, if the node was last -// repositioned via set_pos(), the delta will be zero; -// if it was adjusted via set_fluid_pos(), the delta -// will represent the change from the previous frame's -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the delta vector from this node's position in the previous frame + * (according to set_prev_transform(), typically set via the use of + * set_fluid_pos()) and its position in the current frame, as seen in the + * indicated node's coordinate space. This is the vector used to determine + * collisions. Generally, if the node was last repositioned via set_pos(), + * the delta will be zero; if it was adjusted via set_fluid_pos(), the delta + * will represent the change from the previous frame's position. + */ LVector3 NodePath:: get_pos_delta(const NodePath &other) const { nassertr_always(!is_empty(), LPoint3(0.0f, 0.0f, 0.0f)); return get_transform(other)->get_pos() - get_prev_transform(other)->get_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr -// Access: Published -// Description: Sets the rotation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, relative to the other node. + */ void NodePath:: set_hpr(const NodePath &other, const LVecBase3 &hpr) { nassertv_always(!is_empty()); @@ -1636,10 +1452,10 @@ set_hpr(const NodePath &other, const LVecBase3 &hpr) { CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_pos = transform->get_pos(); const LVecBase3 &orig_scale = transform->get_scale(); const LVecBase3 &orig_shear = transform->get_shear(); @@ -1652,8 +1468,7 @@ set_hpr(const NodePath &other, const LVecBase3 &hpr) { } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_hpr(hpr)); } } @@ -1682,12 +1497,10 @@ set_r(const NodePath &other, PN_stdfloat r) { set_hpr(other, hpr); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_hpr -// Access: Published -// Description: Returns the relative orientation of the bottom node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative orientation of the bottom node as seen from the other + * node. + */ LVecBase3 NodePath:: get_hpr(const NodePath &other) const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1696,12 +1509,9 @@ get_hpr(const NodePath &other) const { return transform->get_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_quat -// Access: Published -// Description: Sets the rotation component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation component of the transform, relative to the other node. + */ void NodePath:: set_quat(const NodePath &other, const LQuaternion &quat) { nassertv_always(!is_empty()); @@ -1709,10 +1519,10 @@ set_quat(const NodePath &other, const LQuaternion &quat) { CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_pos = transform->get_pos(); const LVecBase3 &orig_scale = transform->get_scale(); const LVecBase3 &orig_shear = transform->get_shear(); @@ -1725,18 +1535,15 @@ set_quat(const NodePath &other, const LQuaternion &quat) { } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_quat(quat)); } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_quat -// Access: Published -// Description: Returns the relative orientation of the bottom node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative orientation of the bottom node as seen from the other + * node. + */ LQuaternion NodePath:: get_quat(const NodePath &other) const { nassertr_always(!is_empty(), LQuaternion::ident_quat()); @@ -1744,12 +1551,9 @@ get_quat(const NodePath &other) const { return transform->get_quat(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scale -// Access: Published -// Description: Sets the scale component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale component of the transform, relative to the other node. + */ void NodePath:: set_scale(const NodePath &other, const LVecBase3 &scale) { nassertv_always(!is_empty()); @@ -1757,10 +1561,10 @@ set_scale(const NodePath &other, const LVecBase3 &scale) { CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_pos = transform->get_pos(); const LVecBase3 &orig_hpr = transform->get_hpr(); const LVecBase3 &orig_shear = transform->get_shear(); @@ -1773,8 +1577,7 @@ set_scale(const NodePath &other, const LVecBase3 &scale) { } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_scale(scale)); } } @@ -1803,12 +1606,9 @@ set_sz(const NodePath &other, PN_stdfloat sz) { set_scale(other, scale); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_scale -// Access: Published -// Description: Returns the relative scale of the bottom node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative scale of the bottom node as seen from the other node. + */ LVecBase3 NodePath:: get_scale(const NodePath &other) const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1816,12 +1616,9 @@ get_scale(const NodePath &other) const { return transform->get_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shear -// Access: Published -// Description: Sets the shear component of the transform, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shear component of the transform, relative to the other node. + */ void NodePath:: set_shear(const NodePath &other, const LVecBase3 &shear) { nassertv_always(!is_empty()); @@ -1829,10 +1626,10 @@ set_shear(const NodePath &other, const LVecBase3 &shear) { CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other three components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other three components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_pos = transform->get_pos(); const LVecBase3 &orig_hpr = transform->get_hpr(); const LVecBase3 &orig_scale = transform->get_scale(); @@ -1845,8 +1642,7 @@ set_shear(const NodePath &other, const LVecBase3 &shear) { } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, rel_transform->set_shear(shear)); } } @@ -1875,12 +1671,9 @@ set_shyz(const NodePath &other, PN_stdfloat shyz) { set_shear(other, shear); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_shear -// Access: Published -// Description: Returns the relative shear of the bottom node -// as seen from the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative shear of the bottom node as seen from the other node. + */ LVecBase3 NodePath:: get_shear(const NodePath &other) const { nassertr_always(!is_empty(), LVecBase3(0.0f, 0.0f, 0.0f)); @@ -1888,12 +1681,10 @@ get_shear(const NodePath &other) const { return transform->get_shear(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, relative to + * the other node. + */ void NodePath:: set_pos_hpr(const NodePath &other, const LVecBase3 &pos, const LVecBase3 &hpr) { @@ -1902,10 +1693,10 @@ set_pos_hpr(const NodePath &other, const LVecBase3 &pos, CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other two components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other two components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_scale = transform->get_scale(); const LVecBase3 &orig_shear = transform->get_shear(); @@ -1918,20 +1709,17 @@ set_pos_hpr(const NodePath &other, const LVecBase3 &pos, } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, TransformState::make_pos_hpr_scale_shear (pos, hpr, rel_transform->get_scale(), rel_transform->get_shear())); node()->reset_prev_transform(); } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat -// Access: Published -// Description: Sets the translation and rotation component of the -// transform, relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the translation and rotation component of the transform, relative to + * the other node. + */ void NodePath:: set_pos_quat(const NodePath &other, const LVecBase3 &pos, const LQuaternion &quat) { @@ -1940,10 +1728,10 @@ set_pos_quat(const NodePath &other, const LVecBase3 &pos, CPT(TransformState) transform = get_transform(); if (transform->has_components()) { - // If we had a componentwise transform before we started, we - // should be careful to preserve the other two components. We - // wouldn't need to do this, except for the possibility of - // numerical error or decompose ambiguity. + // If we had a componentwise transform before we started, we should be + // careful to preserve the other two components. We wouldn't need to do + // this, except for the possibility of numerical error or decompose + // ambiguity. const LVecBase3 &orig_scale = transform->get_scale(); const LVecBase3 &orig_shear = transform->get_shear(); @@ -1956,28 +1744,23 @@ set_pos_quat(const NodePath &other, const LVecBase3 &pos, } } else { - // If we didn't have a componentwise transform already, never - // mind. + // If we didn't have a componentwise transform already, never mind. set_transform(other, TransformState::make_pos_quat_scale_shear (pos, quat, rel_transform->get_scale(), rel_transform->get_shear())); node()->reset_prev_transform(); } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_hpr_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. This, or -// set_pos_hpr_scale, is the preferred way to update a -// transform when both hpr and scale are to be changed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. This, or set_pos_hpr_scale, is the preferred way to + * update a transform when both hpr and scale are to be changed. + */ void NodePath:: set_hpr_scale(const NodePath &other, const LVecBase3 &hpr, const LVecBase3 &scale) { - // We don't bother trying very hard to preserve pos across this - // operation, unlike the work we do above to preserve hpr or scale, - // since it generally doesn't matter that much if pos is off by a - // few thousandths. + // We don't bother trying very hard to preserve pos across this operation, + // unlike the work we do above to preserve hpr or scale, since it generally + // doesn't matter that much if pos is off by a few thousandths. nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(other); transform = TransformState::make_pos_hpr_scale_shear @@ -1985,21 +1768,17 @@ set_hpr_scale(const NodePath &other, const LVecBase3 &hpr, const LVecBase3 &scal set_transform(other, transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_quat_scale -// Access: Published -// Description: Sets the rotation and scale components of the -// transform, leaving translation untouched. This, or -// set_pos_quat_scale, is the preferred way to update a -// transform when both quat and scale are to be changed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation and scale components of the transform, leaving + * translation untouched. This, or set_pos_quat_scale, is the preferred way + * to update a transform when both quat and scale are to be changed. + */ void NodePath:: set_quat_scale(const NodePath &other, const LQuaternion &quat, const LVecBase3 &scale) { - // We don't bother trying very hard to preserve pos across this - // operation, unlike the work we do above to preserve quat or scale, - // since it generally doesn't matter that much if pos is off by a - // few thousandths. + // We don't bother trying very hard to preserve pos across this operation, + // unlike the work we do above to preserve quat or scale, since it generally + // doesn't matter that much if pos is off by a few thousandths. nassertv_always(!is_empty()); CPT(TransformState) transform = get_transform(other); transform = TransformState::make_pos_quat_scale_shear @@ -2007,13 +1786,10 @@ set_quat_scale(const NodePath &other, const LQuaternion &quat, set_transform(other, transform); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, and scale components, relative -// to the other node, implicitly setting shear to 0. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, and scale + * components, relative to the other node, implicitly setting shear to 0. + */ void NodePath:: set_pos_hpr_scale(const NodePath &other, const LVecBase3 &pos, const LVecBase3 &hpr, @@ -2024,13 +1800,10 @@ set_pos_hpr_scale(const NodePath &other, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat_scale -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, and scale components, relative -// to the other node, implicitly setting shear to 0. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, and scale + * components, relative to the other node, implicitly setting shear to 0. + */ void NodePath:: set_pos_quat_scale(const NodePath &other, const LVecBase3 &pos, const LQuaternion &quat, @@ -2041,13 +1814,10 @@ set_pos_quat_scale(const NodePath &other, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_hpr_scale_shear -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, scale, and shear components, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, scale, + * and shear components, relative to the other node. + */ void NodePath:: set_pos_hpr_scale_shear(const NodePath &other, const LVecBase3 &pos, const LVecBase3 &hpr, @@ -2058,13 +1828,10 @@ set_pos_hpr_scale_shear(const NodePath &other, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_pos_quat_scale_shear -// Access: Published -// Description: Completely replaces the transform with new -// translation, rotation, scale, and shear components, -// relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Completely replaces the transform with new translation, rotation, scale, + * and shear components, relative to the other node. + */ void NodePath:: set_pos_quat_scale_shear(const NodePath &other, const LVecBase3 &pos, const LQuaternion &quat, @@ -2075,31 +1842,24 @@ set_pos_quat_scale_shear(const NodePath &other, node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_mat -// Access: Published -// Description: Returns the matrix that describes the coordinate -// space of the bottom node, relative to the other -// path's bottom node's coordinate space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that describes the coordinate space of the bottom node, + * relative to the other path's bottom node's coordinate space. + */ LMatrix4 NodePath:: get_mat(const NodePath &other) const { CPT(TransformState) transform = get_transform(other); - // We can't safely return a reference to the matrix, because we - // can't assume the transform won't go away when the function - // returns. If the transform was partially modified by, say, a - // CompassEffect, it won't be stored in the cache, and thus we might - // have the only reference to it. + // We can't safely return a reference to the matrix, because we can't assume + // the transform won't go away when the function returns. If the transform + // was partially modified by, say, a CompassEffect, it won't be stored in + // the cache, and thus we might have the only reference to it. return transform->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_mat -// Access: Published -// Description: Converts the indicated matrix from the other's -// coordinate space to the local coordinate space, and -// applies it to the node. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated matrix from the other's coordinate space to the + * local coordinate space, and applies it to the node. + */ void NodePath:: set_mat(const NodePath &other, const LMatrix4 &mat) { nassertv_always(!is_empty()); @@ -2107,13 +1867,10 @@ set_mat(const NodePath &other, const LMatrix4 &mat) { node()->reset_prev_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_relative_point -// Access: Published -// Description: Given that the indicated point is in the coordinate -// system of the other node, returns the same point in -// this node's coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Given that the indicated point is in the coordinate system of the other + * node, returns the same point in this node's coordinate system. + */ LPoint3 NodePath:: get_relative_point(const NodePath &other, const LVecBase3 &point) const { CPT(TransformState) transform = other.get_transform(*this); @@ -2121,13 +1878,10 @@ get_relative_point(const NodePath &other, const LVecBase3 &point) const { return rel_point; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_relative_vector -// Access: Published -// Description: Given that the indicated vector is in the coordinate -// system of the other node, returns the same vector in -// this node's coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Given that the indicated vector is in the coordinate system of the other + * node, returns the same vector in this node's coordinate system. + */ LVector3 NodePath:: get_relative_vector(const NodePath &other, const LVecBase3 &vec) const { CPT(TransformState) transform = other.get_transform(*this); @@ -2135,13 +1889,10 @@ get_relative_vector(const NodePath &other, const LVecBase3 &vec) const { return rel_vector; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::look_at -// Access: Published -// Description: Sets the transform on this NodePath so that it -// rotates to face the indicated point in space, which -// is relative to the other NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform on this NodePath so that it rotates to face the + * indicated point in space, which is relative to the other NodePath. + */ void NodePath:: look_at(const NodePath &other, const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); @@ -2156,13 +1907,10 @@ look_at(const NodePath &other, const LPoint3 &point, const LVector3 &up) { set_quat(quat); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::heads_up -// Access: Published -// Description: Behaves like look_at(), but with a strong preference -// to keeping the up vector oriented in the indicated -// "up" direction. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like look_at(), but with a strong preference to keeping the up + * vector oriented in the indicated "up" direction. + */ void NodePath:: heads_up(const NodePath &other, const LPoint3 &point, const LVector3 &up) { nassertv_always(!is_empty()); @@ -2178,82 +1926,65 @@ heads_up(const NodePath &other, const LPoint3 &point, const LVector3 &up) { } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color -// Access: Published -// Description: Applies a scene-graph color to the referenced node. -// This color will apply to all geometry at this level -// and below (that does not specify a new color or a -// set_color_off()). -//////////////////////////////////////////////////////////////////// +/** + * Applies a scene-graph color to the referenced node. This color will apply + * to all geometry at this level and below (that does not specify a new color + * or a set_color_off()). + */ void NodePath:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { set_color(LColor(r, g, b, a), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color -// Access: Published -// Description: Applies a scene-graph color to the referenced node. -// This color will apply to all geometry at this level -// and below (that does not specify a new color or a -// set_color_off()). -//////////////////////////////////////////////////////////////////// +/** + * Applies a scene-graph color to the referenced node. This color will apply + * to all geometry at this level and below (that does not specify a new color + * or a set_color_off()). + */ void NodePath:: set_color(const LColor &color, int priority) { nassertv_always(!is_empty()); node()->set_attrib(ColorAttrib::make_flat(color), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using the geometry color. This is normally the -// default, but it may be useful to use this to -// contradict set_color() at a higher node level (or, -// with a priority, to override a set_color() at a lower -// level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using the geometry + * color. This is normally the default, but it may be useful to use this to + * contradict set_color() at a higher node level (or, with a priority, to + * override a set_color() at a lower level). + */ void NodePath:: set_color_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(ColorAttrib::make_vertex(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_color -// Access: Published -// Description: Completely removes any color adjustment from the node. -// This allows the natural color of the geometry, or -// whatever color transitions might be otherwise -// affecting the geometry, to show instead. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any color adjustment from the node. This allows the + * natural color of the geometry, or whatever color transitions might be + * otherwise affecting the geometry, to show instead. + */ void NodePath:: clear_color() { nassertv_always(!is_empty()); node()->clear_attrib(ColorAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_color -// Access: Published -// Description: Returns true if a color has been applied to the given -// node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a color has been applied to the given node, false + * otherwise. + */ bool NodePath:: has_color() const { nassertr_always(!is_empty(), false); return node()->has_attrib(ColorAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_color -// Access: Published -// Description: Returns the color that has been assigned to the node, -// or black if no color has been assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color that has been assigned to the node, or black if no color + * has been assigned. + */ LColor NodePath:: get_color() const { nassertr_always(!is_empty(), false); @@ -2272,42 +2003,32 @@ get_color() const { return LColor(1.0f, 1.0f, 1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_color_scale -// Access: Published -// Description: Returns true if a color scale has been applied -// to the referenced node, false otherwise. It is still -// possible that color at this node might have been -// scaled by an ancestor node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a color scale has been applied to the referenced node, + * false otherwise. It is still possible that color at this node might have + * been scaled by an ancestor node. + */ bool NodePath:: has_color_scale() const { nassertr_always(!is_empty(), false); return node()->has_attrib(ColorScaleAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_color_scale -// Access: Published -// Description: Completely removes any color scale from the -// referenced node. This is preferable to simply -// setting the color scale to identity, as it also -// removes the overhead associated with having a color -// scale at all. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any color scale from the referenced node. This is + * preferable to simply setting the color scale to identity, as it also + * removes the overhead associated with having a color scale at all. + */ void NodePath:: clear_color_scale() { nassertv_always(!is_empty()); node()->clear_attrib(ColorScaleAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::compose_color_scale -// Access: Published -// Description: multiplies the color scale component of the transform, -// with previous color scale leaving translation and -// rotation untouched. -//////////////////////////////////////////////////////////////////// +/** + * multiplies the color scale component of the transform, with previous color + * scale leaving translation and rotation untouched. + */ void NodePath:: compose_color_scale(const LVecBase4 &scale, int priority) { nassertv_always(!is_empty()); @@ -2319,8 +2040,8 @@ compose_color_scale(const LVecBase4 &scale, int priority) { node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); - // Modify the existing ColorScaleAttrib by multiplying with the - // indicated colorScale. + // Modify the existing ColorScaleAttrib by multiplying with the indicated + // colorScale. LVecBase4 prev_color_scale = csa->get_scale(); LVecBase4 new_color_scale(prev_color_scale[0]*scale[0], prev_color_scale[1]*scale[1], @@ -2334,12 +2055,10 @@ compose_color_scale(const LVecBase4 &scale, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_scale -// Access: Published -// Description: Sets the color scale component of the transform, -// leaving translation and rotation untouched. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color scale component of the transform, leaving translation and + * rotation untouched. + */ void NodePath:: set_color_scale(const LVecBase4 &scale, int priority) { nassertv_always(!is_empty()); @@ -2351,8 +2070,7 @@ set_color_scale(const LVecBase4 &scale, int priority) { node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); - // Modify the existing ColorScaleAttrib to add the indicated - // colorScale. + // Modify the existing ColorScaleAttrib to add the indicated colorScale. node()->set_attrib(csa->set_scale(scale), priority); } else { @@ -2361,36 +2079,28 @@ set_color_scale(const LVecBase4 &scale, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_color_scale_off -// Access: Published -// Description: Disables any color scale attribute inherited from -// above. This is not the same thing as -// clear_color_scale(), which undoes any previous -// set_color_scale() operation on this node; rather, -// this actively disables any set_color_scale() that -// might be inherited from a parent node. This also -// disables set_alpha_scale() at the same time. -// -// It is legal to specify a new color scale on the same -// node with a subsequent call to set_color_scale() or -// set_alpha_scale(); this new scale will apply to lower -// geometry. -//////////////////////////////////////////////////////////////////// +/** + * Disables any color scale attribute inherited from above. This is not the + * same thing as clear_color_scale(), which undoes any previous + * set_color_scale() operation on this node; rather, this actively disables + * any set_color_scale() that might be inherited from a parent node. This + * also disables set_alpha_scale() at the same time. + * + * It is legal to specify a new color scale on the same node with a subsequent + * call to set_color_scale() or set_alpha_scale(); this new scale will apply + * to lower geometry. + */ void NodePath:: set_color_scale_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(ColorScaleAttrib::make_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_alpha_scale -// Access: Published -// Description: Sets the alpha scale component of the transform -// without (much) affecting the color scale. Note that -// any priority specified will also apply to the color -// scale. -//////////////////////////////////////////////////////////////////// +/** + * Sets the alpha scale component of the transform without (much) affecting + * the color scale. Note that any priority specified will also apply to the + * color scale. + */ void NodePath:: set_alpha_scale(PN_stdfloat scale, int priority) { nassertv_always(!is_empty()); @@ -2402,8 +2112,7 @@ set_alpha_scale(PN_stdfloat scale, int priority) { node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); - // Modify the existing ColorScaleAttrib to add the indicated - // colorScale. + // Modify the existing ColorScaleAttrib to add the indicated colorScale. const LVecBase4 &sc = csa->get_scale(); node()->set_attrib(csa->set_scale(LVecBase4(sc[0], sc[1], sc[2], scale)), priority); @@ -2413,14 +2122,11 @@ set_alpha_scale(PN_stdfloat scale, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_all_color_scale -// Access: Published -// Description: Scales all the color components of the object by the -// same amount, darkening the object, without (much) -// affecting alpha. Note that any priority specified -// will also apply to the alpha scale. -//////////////////////////////////////////////////////////////////// +/** + * Scales all the color components of the object by the same amount, darkening + * the object, without (much) affecting alpha. Note that any priority + * specified will also apply to the alpha scale. + */ void NodePath:: set_all_color_scale(PN_stdfloat scale, int priority) { nassertv_always(!is_empty()); @@ -2432,8 +2138,7 @@ set_all_color_scale(PN_stdfloat scale, int priority) { node()->get_state()->get_override(ColorScaleAttrib::get_class_slot())); const ColorScaleAttrib *csa = DCAST(ColorScaleAttrib, attrib); - // Modify the existing ColorScaleAttrib to add the indicated - // colorScale. + // Modify the existing ColorScaleAttrib to add the indicated colorScale. const LVecBase4 &sc = csa->get_scale(); node()->set_attrib(csa->set_scale(LVecBase4(scale, scale, scale, sc[3])), priority); @@ -2443,15 +2148,11 @@ set_all_color_scale(PN_stdfloat scale, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_color_scale -// Access: Published -// Description: Returns the complete color scale vector that has been -// applied to this node via a previous call to -// set_color_scale() and/or set_alpha_scale(), or all -// 1's (identity) if no scale has been applied to this -// particular node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete color scale vector that has been applied to this node + * via a previous call to set_color_scale() and/or set_alpha_scale(), or all + * 1's (identity) if no scale has been applied to this particular node. + */ const LVecBase4 &NodePath:: get_color_scale() const { static const LVecBase4 ident_scale(1.0f, 1.0f, 1.0f, 1.0f); @@ -2466,16 +2167,12 @@ get_color_scale() const { return ident_scale; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_light -// Access: Published -// Description: Adds the indicated Light or PolylightNode to the list -// of lights that illuminate geometry at this node and -// below. The light itself should be parented into the -// scene graph elsewhere, to represent the light's -// position in space; but until set_light() is called it -// will illuminate no geometry. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated Light or PolylightNode to the list of lights that + * illuminate geometry at this node and below. The light itself should be + * parented into the scene graph elsewhere, to represent the light's position + * in space; but until set_light() is called it will illuminate no geometry. + */ void NodePath:: set_light(const NodePath &light, int priority) { nassertv_always(!is_empty()); @@ -2490,8 +2187,7 @@ set_light(const NodePath &light, int priority) { node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); - // Modify the existing LightAttrib to add the indicated - // light. + // Modify the existing LightAttrib to add the indicated light. node()->set_attrib(la->add_on_light(light), priority); } else { @@ -2504,8 +2200,8 @@ set_light(const NodePath &light, int priority) { } else if (light.node()->is_of_type(PolylightNode::get_class_type())) { // It's a Polylight object. if (priority != 0) { - // PolylightEffects can't have a priority, since they're just - // an effect to be applied immediately. + // PolylightEffects can't have a priority, since they're just an + // effect to be applied immediately. pgraph_cat.warning() << "Ignoring priority on set_light(" << light << ")\n"; } @@ -2515,8 +2211,7 @@ set_light(const NodePath &light, int priority) { if (effect != (const RenderEffect *)NULL) { const PolylightEffect *ple = DCAST(PolylightEffect, effect); - // Modify the existing PolylightEffect to add the indicated - // light. + // Modify the existing PolylightEffect to add the indicated light. node()->set_effect(ple->add_light(light)); } else { @@ -2530,20 +2225,15 @@ set_light(const NodePath &light, int priority) { nassert_raise("Not a Light object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_light_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no lights at all. This is different -// from not specifying a light; rather, this -// specifically contradicts set_light() at a higher -// node level (or, with a priority, overrides a -// set_light() at a lower level). -// -// If no lights are in effect on a particular piece of -// geometry, that geometry is rendered with lighting -// disabled. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no lights at all. + * This is different from not specifying a light; rather, this specifically + * contradicts set_light() at a higher node level (or, with a priority, + * overrides a set_light() at a lower level). + * + * If no lights are in effect on a particular piece of geometry, that geometry + * is rendered with lighting disabled. + */ void NodePath:: set_light_off(int priority) { nassertv_always(!is_empty()); @@ -2551,19 +2241,15 @@ set_light_off(int priority) { node()->clear_effect(PolylightEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_light_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// without using the indicated Light. This is different -// from not specifying the Light; rather, this -// specifically contradicts set_light() at a higher node -// level (or, with a priority, overrides a set_light() -// at a lower level). -// -// This interface does not support PolylightNodes, which -// cannot be turned off at a lower level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render without using the + * indicated Light. This is different from not specifying the Light; rather, + * this specifically contradicts set_light() at a higher node level (or, with + * a priority, overrides a set_light() at a lower level). + * + * This interface does not support PolylightNodes, which cannot be turned off + * at a lower level. + */ void NodePath:: set_light_off(const NodePath &light, int priority) { nassertv_always(!is_empty()); @@ -2578,14 +2264,14 @@ set_light_off(const NodePath &light, int priority) { node()->get_state()->get_override(LightAttrib::get_class_slot())); const LightAttrib *la = DCAST(LightAttrib, attrib); - // Modify the existing LightAttrib to add the indicated light - // to the "off" list. This also, incidentally, removes it from - // the "on" list if it is there. + // Modify the existing LightAttrib to add the indicated light to the + // "off" list. This also, incidentally, removes it from the "on" list + // if it is there. node()->set_attrib(la->add_off_light(light), priority); } else { - // Create a new LightAttrib for this node that turns off the - // indicated light. + // Create a new LightAttrib for this node that turns off the indicated + // light. CPT(LightAttrib) la = DCAST(LightAttrib, LightAttrib::make()); node()->set_attrib(la->add_off_light(light), priority); } @@ -2595,13 +2281,10 @@ set_light_off(const NodePath &light, int priority) { nassert_raise("Not a Light object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_light -// Access: Published -// Description: Completely removes any lighting operations that may -// have been set via set_light() or set_light_off() -// from this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any lighting operations that may have been set via + * set_light() or set_light_off() from this particular node. + */ void NodePath:: clear_light() { nassertv_always(!is_empty()); @@ -2609,12 +2292,10 @@ clear_light() { node()->clear_effect(PolylightEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_light -// Access: Published -// Description: Removes any reference to the indicated Light or -// PolylightNode from the NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Removes any reference to the indicated Light or PolylightNode from the + * NodePath. + */ void NodePath:: clear_light(const NodePath &light) { nassertv_always(!is_empty()); @@ -2653,14 +2334,11 @@ clear_light(const NodePath &light) { nassert_raise("Not a Light object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_light -// Access: Published -// Description: Returns true if the indicated Light or PolylightNode -// has been specifically enabled on this particular -// node. This means that someone called set_light() on -// this node with the indicated light. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated Light or PolylightNode has been specifically + * enabled on this particular node. This means that someone called + * set_light() on this node with the indicated light. + */ bool NodePath:: has_light(const NodePath &light) const { nassertr_always(!is_empty(), false); @@ -2690,14 +2368,11 @@ has_light(const NodePath &light) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_light_off -// Access: Published -// Description: Returns true if all Lights have been specifically -// disabled on this particular node. This means that -// someone called set_light_off() on this node with no -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all Lights have been specifically disabled on this + * particular node. This means that someone called set_light_off() on this + * node with no parameters. + */ bool NodePath:: has_light_off() const { nassertr_always(!is_empty(), false); @@ -2712,17 +2387,14 @@ has_light_off() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_light_off -// Access: Published -// Description: Returns true if the indicated Light has been -// specifically disabled on this particular node. This -// means that someone called set_light_off() on this -// node with the indicated light. -// -// This interface does not support PolylightNodes, which -// cannot be turned off at a lower level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated Light has been specifically disabled on this + * particular node. This means that someone called set_light_off() on this + * node with the indicated light. + * + * This interface does not support PolylightNodes, which cannot be turned off + * at a lower level. + */ bool NodePath:: has_light_off(const NodePath &light) const { nassertr_always(!is_empty(), false); @@ -2741,16 +2413,13 @@ has_light_off(const NodePath &light) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_clip_plane -// Access: Published -// Description: Adds the indicated clipping plane to the list of -// planes that apply to geometry at this node and below. -// The clipping plane itself, a PlaneNode, should be -// parented into the scene graph elsewhere, to represent -// the plane's position in space; but until -// set_clip_plane() is called it will clip no geometry. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated clipping plane to the list of planes that apply to + * geometry at this node and below. The clipping plane itself, a PlaneNode, + * should be parented into the scene graph elsewhere, to represent the plane's + * position in space; but until set_clip_plane() is called it will clip no + * geometry. + */ void NodePath:: set_clip_plane(const NodePath &clip_plane, int priority) { nassertv_always(!is_empty()); @@ -2762,8 +2431,7 @@ set_clip_plane(const NodePath &clip_plane, int priority) { node()->get_state()->get_override(ClipPlaneAttrib::get_class_slot())); const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); - // Modify the existing ClipPlaneAttrib to add the indicated - // clip_plane. + // Modify the existing ClipPlaneAttrib to add the indicated clip_plane. node()->set_attrib(la->add_on_plane(clip_plane), priority); } else { @@ -2776,37 +2444,29 @@ set_clip_plane(const NodePath &clip_plane, int priority) { nassert_raise("Not a PlaneNode object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_clip_plane_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no clip_planes at all. This is different -// from not specifying a clip_plane; rather, this -// specifically contradicts set_clip_plane() at a higher -// node level (or, with a priority, overrides a -// set_clip_plane() at a lower level). -// -// If no clip_planes are in effect on a particular piece -// of geometry, that geometry is rendered without being -// clipped (other than by the viewing frustum). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no clip_planes at + * all. This is different from not specifying a clip_plane; rather, this + * specifically contradicts set_clip_plane() at a higher node level (or, with + * a priority, overrides a set_clip_plane() at a lower level). + * + * If no clip_planes are in effect on a particular piece of geometry, that + * geometry is rendered without being clipped (other than by the viewing + * frustum). + */ void NodePath:: set_clip_plane_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(ClipPlaneAttrib::make_all_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_clip_plane_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// without being clipped by the indicated PlaneNode. -// This is different from not specifying the PlaneNode; -// rather, this specifically contradicts -// set_clip_plane() at a higher node level (or, with a -// priority, overrides a set_clip_plane() at a lower -// level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render without being clipped + * by the indicated PlaneNode. This is different from not specifying the + * PlaneNode; rather, this specifically contradicts set_clip_plane() at a + * higher node level (or, with a priority, overrides a set_clip_plane() at a + * lower level). + */ void NodePath:: set_clip_plane_off(const NodePath &clip_plane, int priority) { nassertv_always(!is_empty()); @@ -2820,8 +2480,8 @@ set_clip_plane_off(const NodePath &clip_plane, int priority) { const ClipPlaneAttrib *la = DCAST(ClipPlaneAttrib, attrib); // Modify the existing ClipPlaneAttrib to add the indicated clip_plane - // to the "off" list. This also, incidentally, removes it from - // the "on" list if it is there. + // to the "off" list. This also, incidentally, removes it from the "on" + // list if it is there. node()->set_attrib(la->add_off_plane(clip_plane), priority); } else { @@ -2835,25 +2495,19 @@ set_clip_plane_off(const NodePath &clip_plane, int priority) { nassert_raise("Not a PlaneNode object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_clip_plane -// Access: Published -// Description: Completely removes any clip planes that may have been -// set via set_clip_plane() or set_clip_plane_off() from -// this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any clip planes that may have been set via + * set_clip_plane() or set_clip_plane_off() from this particular node. + */ void NodePath:: clear_clip_plane() { nassertv_always(!is_empty()); node()->clear_attrib(ClipPlaneAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_clip_plane -// Access: Published -// Description: Removes any reference to the indicated clipping plane -// from the NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Removes any reference to the indicated clipping plane from the NodePath. + */ void NodePath:: clear_clip_plane(const NodePath &clip_plane) { nassertv_always(!is_empty()); @@ -2879,14 +2533,11 @@ clear_clip_plane(const NodePath &clip_plane) { nassert_raise("Not a PlaneNode object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_clip_plane -// Access: Published -// Description: Returns true if the indicated clipping plane has been -// specifically applied to this particular node. This -// means that someone called set_clip_plane() on this -// node with the indicated clip_plane. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated clipping plane has been specifically applied + * to this particular node. This means that someone called set_clip_plane() + * on this node with the indicated clip_plane. + */ bool NodePath:: has_clip_plane(const NodePath &clip_plane) const { nassertr_always(!is_empty(), false); @@ -2904,14 +2555,11 @@ has_clip_plane(const NodePath &clip_plane) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_clip_plane_off -// Access: Published -// Description: Returns true if all clipping planes have been -// specifically disabled on this particular node. This -// means that someone called set_clip_plane_off() on -// this node with no parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all clipping planes have been specifically disabled on this + * particular node. This means that someone called set_clip_plane_off() on + * this node with no parameters. + */ bool NodePath:: has_clip_plane_off() const { nassertr_always(!is_empty(), false); @@ -2926,14 +2574,11 @@ has_clip_plane_off() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_clip_plane_off -// Access: Published -// Description: Returns true if the indicated clipping plane has been -// specifically disabled on this particular node. This -// means that someone called set_clip_plane_off() on -// this node with the indicated clip_plane. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated clipping plane has been specifically disabled + * on this particular node. This means that someone called + * set_clip_plane_off() on this node with the indicated clip_plane. + */ bool NodePath:: has_clip_plane_off(const NodePath &clip_plane) const { nassertr_always(!is_empty(), false); @@ -2949,16 +2594,13 @@ has_clip_plane_off(const NodePath &clip_plane) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_occluder -// Access: Published -// Description: Adds the indicated occluder to the list of -// occluders that apply to geometry at this node and below. -// The occluder itself, an OccluderNode, should be -// parented into the scene graph elsewhere, to represent -// the occluder's position in space; but until -// set_occluder() is called it will clip no geometry. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated occluder to the list of occluders that apply to geometry + * at this node and below. The occluder itself, an OccluderNode, should be + * parented into the scene graph elsewhere, to represent the occluder's + * position in space; but until set_occluder() is called it will clip no + * geometry. + */ void NodePath:: set_occluder(const NodePath &occluder) { nassertv_always(!is_empty()); @@ -2968,8 +2610,7 @@ set_occluder(const NodePath &occluder) { if (effect != (const RenderEffect *)NULL) { const OccluderEffect *la = DCAST(OccluderEffect, effect); - // Modify the existing OccluderEffect to add the indicated - // occluder. + // Modify the existing OccluderEffect to add the indicated occluder. node()->set_effect(la->add_on_occluder(occluder)); } else { @@ -2982,24 +2623,19 @@ set_occluder(const NodePath &occluder) { nassert_raise("Not an OccluderNode object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_occluder -// Access: Published -// Description: Completely removes any occluders that may have been -// set via set_occluder() from this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any occluders that may have been set via set_occluder() + * from this particular node. + */ void NodePath:: clear_occluder() { nassertv_always(!is_empty()); node()->clear_effect(OccluderEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_occluder -// Access: Published -// Description: Removes any reference to the indicated occluder -// from the NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Removes any reference to the indicated occluder from the NodePath. + */ void NodePath:: clear_occluder(const NodePath &occluder) { nassertv_always(!is_empty()); @@ -3023,14 +2659,11 @@ clear_occluder(const NodePath &occluder) { nassert_raise("Not an OccluderNode object."); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_occluder -// Access: Published -// Description: Returns true if the indicated occluder has been -// specifically applied to this particular node. This -// means that someone called set_occluder() on this -// node with the indicated occluder. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated occluder has been specifically applied to + * this particular node. This means that someone called set_occluder() on + * this node with the indicated occluder. + */ bool NodePath:: has_occluder(const NodePath &occluder) const { nassertr_always(!is_empty(), false); @@ -3048,80 +2681,60 @@ has_occluder(const NodePath &occluder) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scissor -// Access: Published -// Description: Sets up a scissor region on the nodes rendered at -// this level and below. The four coordinates are -// understood to define a rectangle in screen space. -// These numbers are relative to the current -// DisplayRegion, where (0,0) is the lower-left corner -// of the DisplayRegion, and (1,1) is the upper-right -// corner. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a scissor region on the nodes rendered at this level and below. + * The four coordinates are understood to define a rectangle in screen space. + * These numbers are relative to the current DisplayRegion, where (0,0) is the + * lower-left corner of the DisplayRegion, and (1,1) is the upper-right + * corner. + */ void NodePath:: set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_effect(ScissorEffect::make_screen(LVecBase4(left, right, bottom, top))); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scissor -// Access: Published -// Description: Sets up a scissor region on the nodes rendered at -// this level and below. The two points are understood -// to be relative to this node. When these points are -// projected into screen space, they define the -// diagonally-opposite points that determine the scissor -// region. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a scissor region on the nodes rendered at this level and below. + * The two points are understood to be relative to this node. When these + * points are projected into screen space, they define the diagonally-opposite + * points that determine the scissor region. + */ void NodePath:: set_scissor(const LPoint3 &a, const LPoint3 &b) { set_effect(ScissorEffect::make_node(a, b)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scissor -// Access: Published -// Description: Sets up a scissor region on the nodes rendered at -// this level and below. The four points are understood -// to be relative to this node. When these points are -// projected into screen space, they define the -// bounding volume of the scissor region (the scissor -// region is the smallest onscreen rectangle that -// encloses all four points). -//////////////////////////////////////////////////////////////////// +/** + * Sets up a scissor region on the nodes rendered at this level and below. + * The four points are understood to be relative to this node. When these + * points are projected into screen space, they define the bounding volume of + * the scissor region (the scissor region is the smallest onscreen rectangle + * that encloses all four points). + */ void NodePath:: set_scissor(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d) { set_effect(ScissorEffect::make_node(a, b, c, d)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scissor -// Access: Published -// Description: Sets up a scissor region on the nodes rendered at -// this level and below. The two points are understood -// to be relative to the indicated other node. When -// these points are projected into screen space, they -// define the diagonally-opposite points that determine -// the scissor region. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a scissor region on the nodes rendered at this level and below. + * The two points are understood to be relative to the indicated other node. + * When these points are projected into screen space, they define the + * diagonally-opposite points that determine the scissor region. + */ void NodePath:: set_scissor(const NodePath &other, const LPoint3 &a, const LPoint3 &b) { set_effect(ScissorEffect::make_node(a, b, other)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_scissor -// Access: Published -// Description: Sets up a scissor region on the nodes rendered at -// this level and below. The four points are understood -// to be relative to the indicated other node. When -// these points are projected into screen space, they -// define the bounding volume of the scissor region (the -// scissor region is the smallest onscreen rectangle -// that encloses all four points). -//////////////////////////////////////////////////////////////////// +/** + * Sets up a scissor region on the nodes rendered at this level and below. + * The four points are understood to be relative to the indicated other node. + * When these points are projected into screen space, they define the bounding + * volume of the scissor region (the scissor region is the smallest onscreen + * rectangle that encloses all four points). + */ void NodePath:: set_scissor(const NodePath &other, const LPoint3 &a, const LPoint3 &b, @@ -3129,94 +2742,75 @@ set_scissor(const NodePath &other, set_effect(ScissorEffect::make_node(a, b, c, d, other)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_scissor -// Access: Published -// Description: Removes the scissor region that was defined at this -// node level by a previous call to set_scissor(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the scissor region that was defined at this node level by a + * previous call to set_scissor(). + */ void NodePath:: clear_scissor() { clear_effect(ScissorEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_scissor -// Access: Published -// Description: Returns true if a scissor region was defined at this -// node by a previous call to set_scissor(). This does -// not check for scissor regions inherited from a parent -// class. It also does not check for the presence of a -// low-level ScissorAttrib, which is different from the -// ScissorEffect added by set_scissor. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a scissor region was defined at this node by a previous + * call to set_scissor(). This does not check for scissor regions inherited + * from a parent class. It also does not check for the presence of a low- + * level ScissorAttrib, which is different from the ScissorEffect added by + * set_scissor. + */ bool NodePath:: has_scissor() const { return has_effect(ScissorEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_bin -// Access: Published -// Description: Assigns the geometry at this level and below to the -// named rendering bin. It is the user's responsibility -// to ensure that such a bin already exists, either via -// the cull-bin Configrc variable, or by explicitly -// creating a GeomBin of the appropriate type at -// runtime. -// -// There are two default bins created when Panda is -// started: "default" and "fixed". Normally, all -// geometry is assigned to "default" unless specified -// otherwise. This bin renders opaque geometry in -// state-sorted order, followed by transparent geometry -// sorted back-to-front. If any geometry is assigned to -// "fixed", this will be rendered following all the -// geometry in "default", in the order specified by -// draw_order for each piece of geometry so assigned. -// -// The draw_order parameter is meaningful only for -// GeomBinFixed type bins, e.g. "fixed". Other kinds of -// bins ignore it. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the geometry at this level and below to the named rendering bin. + * It is the user's responsibility to ensure that such a bin already exists, + * either via the cull-bin Configrc variable, or by explicitly creating a + * GeomBin of the appropriate type at runtime. + * + * There are two default bins created when Panda is started: "default" and + * "fixed". Normally, all geometry is assigned to "default" unless specified + * otherwise. This bin renders opaque geometry in state-sorted order, + * followed by transparent geometry sorted back-to-front. If any geometry is + * assigned to "fixed", this will be rendered following all the geometry in + * "default", in the order specified by draw_order for each piece of geometry + * so assigned. + * + * The draw_order parameter is meaningful only for GeomBinFixed type bins, + * e.g. "fixed". Other kinds of bins ignore it. + */ void NodePath:: set_bin(const string &bin_name, int draw_order, int priority) { nassertv_always(!is_empty()); node()->set_attrib(CullBinAttrib::make(bin_name, draw_order), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_bin -// Access: Published -// Description: Completely removes any bin adjustment that may have -// been set via set_bin() from this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any bin adjustment that may have been set via set_bin() + * from this particular node. + */ void NodePath:: clear_bin() { nassertv_always(!is_empty()); node()->clear_attrib(CullBinAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_bin -// Access: Published -// Description: Returns true if the node has been assigned to the a -// particular rendering bin via set_bin(), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has been assigned to the a particular rendering + * bin via set_bin(), false otherwise. + */ bool NodePath:: has_bin() const { nassertr_always(!is_empty(), false); return node()->has_attrib(CullBinAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_bin_name -// Access: Published -// Description: Returns the name of the bin that this particular node -// was assigned to via set_bin(), or the empty string if -// no bin was assigned. See set_bin() and has_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the bin that this particular node was assigned to via + * set_bin(), or the empty string if no bin was assigned. See set_bin() and + * has_bin(). + */ string NodePath:: get_bin_name() const { nassertr_always(!is_empty(), string()); @@ -3230,14 +2824,11 @@ get_bin_name() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_bin_draw_order -// Access: Published -// Description: Returns the drawing order associated with the bin -// that this particular node was assigned to via -// set_bin(), or 0 if no bin was assigned. See -// set_bin() and has_bin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the drawing order associated with the bin that this particular node + * was assigned to via set_bin(), or 0 if no bin was assigned. See set_bin() + * and has_bin(). + */ int NodePath:: get_bin_draw_order() const { nassertr_always(!is_empty(), false); @@ -3251,17 +2842,14 @@ get_bin_draw_order() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the default texture stage. -// -// This is the convenience single-texture variant of -// this method; it is now superceded by set_texture() -// that accepts a stage and texture. You may use this -// method if you just want to adjust the default stage. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the default texture stage. + * + * This is the convenience single-texture variant of this method; it is now + * superceded by set_texture() that accepts a stage and texture. You may use + * this method if you just want to adjust the default stage. + */ void NodePath:: set_texture(Texture *tex, int priority) { nassertv_always(!is_empty()); @@ -3269,17 +2857,13 @@ set_texture(Texture *tex, int priority) { set_texture(stage, tex, priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the indicated multitexture -// stage. If there are multiple texture stages -// specified (possibly on multiple different nodes at -// different levels), they will all be applied to -// geometry together, according to the stage -// specification set up in the TextureStage object. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the indicated multitexture stage. If there are multiple texture stages + * specified (possibly on multiple different nodes at different levels), they + * will all be applied to geometry together, according to the stage + * specification set up in the TextureStage object. + */ void NodePath:: set_texture(TextureStage *stage, Texture *tex, int priority) { nassertv_always(!is_empty()); @@ -3290,8 +2874,7 @@ set_texture(TextureStage *stage, Texture *tex, int priority) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); - // Modify the existing TextureAttrib to add the indicated - // texture. + // Modify the existing TextureAttrib to add the indicated texture. node()->set_attrib(tsa->add_on_stage(stage, tex, priority), sg_priority); } else { @@ -3301,23 +2884,18 @@ set_texture(TextureStage *stage, Texture *tex, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the default texture stage. -// -// The given sampler state will override the sampling -// settings on the texture itself. Note that this -// method makes a copy of the sampler settings that -// you give; further changes to this object will not -// be reflected. -// -// This is the convenience single-texture variant of -// this method; it is now superceded by set_texture() -// that accepts a stage and texture. You may use this -// method if you just want to adjust the default stage. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the default texture stage. + * + * The given sampler state will override the sampling settings on the texture + * itself. Note that this method makes a copy of the sampler settings that + * you give; further changes to this object will not be reflected. + * + * This is the convenience single-texture variant of this method; it is now + * superceded by set_texture() that accepts a stage and texture. You may use + * this method if you just want to adjust the default stage. + */ void NodePath:: set_texture(Texture *tex, const SamplerState &sampler, int priority) { nassertv_always(!is_empty()); @@ -3325,23 +2903,17 @@ set_texture(Texture *tex, const SamplerState &sampler, int priority) { set_texture(stage, tex, sampler, priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the indicated multitexture -// stage. If there are multiple texture stages -// specified (possibly on multiple different nodes at -// different levels), they will all be applied to -// geometry together, according to the stage -// specification set up in the TextureStage object. -// -// The given sampler state will override the sampling -// settings on the texture itself. Note that this -// method makes a copy of the sampler settings that -// you give; further changes to this object will not -// be reflected. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the indicated multitexture stage. If there are multiple texture stages + * specified (possibly on multiple different nodes at different levels), they + * will all be applied to geometry together, according to the stage + * specification set up in the TextureStage object. + * + * The given sampler state will override the sampling settings on the texture + * itself. Note that this method makes a copy of the sampler settings that + * you give; further changes to this object will not be reflected. + */ void NodePath:: set_texture(TextureStage *stage, Texture *tex, const SamplerState &sampler, int priority) { nassertv_always(!is_empty()); @@ -3352,8 +2924,7 @@ set_texture(TextureStage *stage, Texture *tex, const SamplerState &sampler, int const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); - // Modify the existing TextureAttrib to add the indicated - // texture. + // Modify the existing TextureAttrib to add the indicated texture. node()->set_attrib(tsa->add_on_stage(stage, tex, sampler, priority), sg_priority); } else { @@ -3363,32 +2934,24 @@ set_texture(TextureStage *stage, Texture *tex, const SamplerState &sampler, int } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no texture, on any stage. This is different -// from not specifying a texture; rather, this -// specifically contradicts set_texture() at a higher -// node level (or, with a priority, overrides a -// set_texture() at a lower level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no texture, on + * any stage. This is different from not specifying a texture; rather, this + * specifically contradicts set_texture() at a higher node level (or, with a + * priority, overrides a set_texture() at a lower level). + */ void NodePath:: set_texture_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(TextureAttrib::make_all_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_texture_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no texture, on the indicated stage. This is -// different from not specifying a texture; rather, this -// specifically contradicts set_texture() at a higher -// node level (or, with a priority, overrides a -// set_texture() at a lower level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no texture, on + * the indicated stage. This is different from not specifying a texture; + * rather, this specifically contradicts set_texture() at a higher node level + * (or, with a priority, overrides a set_texture() at a lower level). + */ void NodePath:: set_texture_off(TextureStage *stage, int priority) { nassertv_always(!is_empty()); @@ -3399,40 +2962,34 @@ set_texture_off(TextureStage *stage, int priority) { const TextureAttrib *tsa = DCAST(TextureAttrib, attrib); int sg_priority = node()->get_state()->get_override(TextureAttrib::get_class_slot()); - // Modify the existing TextureAttrib to add the indicated texture - // to the "off" list. This also, incidentally, removes it from - // the "on" list if it is there. + // Modify the existing TextureAttrib to add the indicated texture to the + // "off" list. This also, incidentally, removes it from the "on" list if + // it is there. node()->set_attrib(tsa->add_off_stage(stage, priority), sg_priority); } else { - // Create a new TextureAttrib for this node that turns off the - // indicated stage. + // Create a new TextureAttrib for this node that turns off the indicated + // stage. CPT(TextureAttrib) tsa = DCAST(TextureAttrib, TextureAttrib::make()); node()->set_attrib(tsa->add_off_stage(stage, priority)); } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_texture -// Access: Published -// Description: Completely removes any texture adjustment that may -// have been set via set_texture() or set_texture_off() -// from this particular node. This allows whatever -// textures might be otherwise affecting the geometry to -// show instead. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any texture adjustment that may have been set via + * set_texture() or set_texture_off() from this particular node. This allows + * whatever textures might be otherwise affecting the geometry to show + * instead. + */ void NodePath:: clear_texture() { nassertv_always(!is_empty()); node()->clear_attrib(TextureAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_texture -// Access: Published -// Description: Removes any reference to the indicated texture stage -// from the NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Removes any reference to the indicated texture stage from the NodePath. + */ void NodePath:: clear_texture(TextureStage *stage) { nassertv_always(!is_empty()); @@ -3454,31 +3011,23 @@ clear_texture(TextureStage *stage) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_texture -// Access: Published -// Description: Returns true if a texture has been applied to this -// particular node via set_texture(), false otherwise. -// This is not the same thing as asking whether the -// geometry at this node will be rendered with -// texturing, as there may be a texture in effect from a -// higher or lower level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a texture has been applied to this particular node via + * set_texture(), false otherwise. This is not the same thing as asking + * whether the geometry at this node will be rendered with texturing, as there + * may be a texture in effect from a higher or lower level. + */ bool NodePath:: has_texture() const { return get_texture() != (Texture *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_texture -// Access: Published -// Description: Returns true if texturing has been specifically -// enabled on this particular node for the indicated -// stage. This means that someone called -// set_texture() on this node with the indicated stage -// name, or the stage_name is the default stage_name, -// and someone called set_texture() on this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if texturing has been specifically enabled on this particular + * node for the indicated stage. This means that someone called set_texture() + * on this node with the indicated stage name, or the stage_name is the + * default stage_name, and someone called set_texture() on this node. + */ bool NodePath:: has_texture(TextureStage *stage) const { nassertr_always(!is_empty(), false); @@ -3493,16 +3042,12 @@ has_texture(TextureStage *stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_texture_off -// Access: Published -// Description: Returns true if texturing has been specifically -// disabled on this particular node via -// set_texture_off(), false otherwise. This is not the -// same thing as asking whether the geometry at this -// node will be rendered untextured, as there may be a -// texture in effect from a higher or lower level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if texturing has been specifically disabled on this particular + * node via set_texture_off(), false otherwise. This is not the same thing as + * asking whether the geometry at this node will be rendered untextured, as + * there may be a texture in effect from a higher or lower level. + */ bool NodePath:: has_texture_off() const { nassertr_always(!is_empty(), false); @@ -3516,16 +3061,12 @@ has_texture_off() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_texture_off -// Access: Published -// Description: Returns true if texturing has been specifically -// disabled on this particular node for the indicated -// stage. This means that someone called -// set_texture_off() on this node with the indicated -// stage name, or that someone called set_texture_off() -// on this node to remove all stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if texturing has been specifically disabled on this particular + * node for the indicated stage. This means that someone called + * set_texture_off() on this node with the indicated stage name, or that + * someone called set_texture_off() on this node to remove all stages. + */ bool NodePath:: has_texture_off(TextureStage *stage) const { nassertr_always(!is_empty(), false); @@ -3540,18 +3081,14 @@ has_texture_off(TextureStage *stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_texture -// Access: Published -// Description: Returns the base-level texture that has been set on -// this particular node, or NULL if no texture has been -// set. This is not necessarily the texture that will -// be applied to the geometry at or below this level, as -// another texture at a higher or lower level may -// override. -// -// See also find_texture(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the base-level texture that has been set on this particular node, + * or NULL if no texture has been set. This is not necessarily the texture + * that will be applied to the geometry at or below this level, as another + * texture at a higher or lower level may override. + * + * See also find_texture(). + */ Texture *NodePath:: get_texture() const { nassertr_always(!is_empty(), NULL); @@ -3565,13 +3102,10 @@ get_texture() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_texture -// Access: Published -// Description: Returns the texture that has been set on the -// indicated stage for this particular node, or NULL if -// no texture has been set for this stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture that has been set on the indicated stage for this + * particular node, or NULL if no texture has been set for this stage. + */ Texture *NodePath:: get_texture(TextureStage *stage) const { nassertr_always(!is_empty(), NULL); @@ -3585,33 +3119,27 @@ get_texture(TextureStage *stage) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_texture_sampler -// Access: Published -// Description: Returns the sampler state that has been given for -// the base-level texture that has been set on this -// particular node. If no sampler state was given, -// this returns the texture's default sampler settings. -// -// It is an error to call this if there is no base-level -// texture applied to this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sampler state that has been given for the base-level texture + * that has been set on this particular node. If no sampler state was given, + * this returns the texture's default sampler settings. + * + * It is an error to call this if there is no base-level texture applied to + * this particular node. + */ const SamplerState &NodePath:: get_texture_sampler() const { return get_texture_sampler(TextureStage::get_default()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_texture_sampler -// Access: Published -// Description: Returns the sampler state that has been given for -// the indicated texture stage that has been set on this -// particular node. If no sampler state was given, -// this returns the texture's default sampler settings. -// -// It is an error to call this if there is no texture -// set for this stage on this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sampler state that has been given for the indicated texture + * stage that has been set on this particular node. If no sampler state was + * given, this returns the texture's default sampler settings. + * + * It is an error to call this if there is no texture set for this stage on + * this particular node. + */ const SamplerState &NodePath:: get_texture_sampler(TextureStage *stage) const { nassertr_always(!is_empty(), SamplerState::get_default()); @@ -3623,11 +3151,9 @@ get_texture_sampler(TextureStage *stage) const { return ta->get_on_sampler(stage); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: set_shader(const Shader *sha, int priority) { nassertv_always(!is_empty()); @@ -3646,21 +3172,17 @@ set_shader(const Shader *sha, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_off -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: set_shader_off(int priority) { set_shader(NULL, priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_auto -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: set_shader_auto(int priority) { nassertv_always(!is_empty()); @@ -3679,11 +3201,9 @@ set_shader_auto(int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_auto -// Access: Published -// Description: overloaded for auto shader customization -//////////////////////////////////////////////////////////////////// +/** + * overloaded for auto shader customization + */ void NodePath:: set_shader_auto(BitMask32 shader_switch, int priority) { nassertv_always(!is_empty()); @@ -3701,11 +3221,9 @@ set_shader_auto(BitMask32 shader_switch, int priority) { node()->set_attrib(sa->set_shader_auto(shader_switch, priority)); } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_shader -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: clear_shader() { nassertv_always(!is_empty()); @@ -3718,11 +3236,9 @@ clear_shader() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_shader -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const Shader *NodePath:: get_shader() const { nassertr_always(!is_empty(), NULL); @@ -3735,11 +3251,9 @@ get_shader() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: set_shader_input(const ShaderInput *inp) { nassertv_always(!is_empty()); @@ -3756,11 +3270,9 @@ set_shader_input(const ShaderInput *inp) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const ShaderInput *NodePath:: get_shader_input(CPT_InternalName id) const { nassertr_always(!is_empty(), NULL); @@ -3774,12 +3286,10 @@ get_shader_input(CPT_InternalName id) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_instance_count -// Access: Published -// Description: Returns the geometry instance count, or 0 if -// disabled. See set_instance_count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the geometry instance count, or 0 if disabled. See + * set_instance_count. + */ int NodePath:: get_instance_count() const { nassertr_always(!is_empty(), 0); @@ -3795,11 +3305,9 @@ get_instance_count() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_shader_input -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: clear_shader_input(CPT_InternalName id) { nassertv_always(!is_empty()); @@ -3812,14 +3320,11 @@ clear_shader_input(CPT_InternalName id) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_instance_count -// Access: Published -// Description: Sets the geometry instance count, or 0 if -// geometry instancing should be disabled. Do not -// confuse with instanceTo which only applies to -// animation instancing. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry instance count, or 0 if geometry instancing should be + * disabled. Do not confuse with instanceTo which only applies to animation + * instancing. + */ void NodePath:: set_instance_count(int instance_count) { nassertv_always(!is_empty()); @@ -3836,12 +3341,10 @@ set_instance_count(int instance_count) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_transform -// Access: Published -// Description: Sets the texture matrix on the current node to the -// indicated transform for the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture matrix on the current node to the indicated transform for + * the given stage. + */ void NodePath:: set_tex_transform(TextureStage *stage, const TransformState *transform) { nassertv_always(!is_empty()); @@ -3851,8 +3354,7 @@ set_tex_transform(TextureStage *stage, const TransformState *transform) { if (attrib != (const RenderAttrib *)NULL) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); - // Modify the existing TexMatrixAttrib to add the indicated - // stage. + // Modify the existing TexMatrixAttrib to add the indicated stage. node()->set_attrib(tma->add_stage(stage, transform)); } else { @@ -3861,23 +3363,18 @@ set_tex_transform(TextureStage *stage, const TransformState *transform) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_transform -// Access: Published -// Description: Removes all texture matrices from the current node. -//////////////////////////////////////////////////////////////////// +/** + * Removes all texture matrices from the current node. + */ void NodePath:: clear_tex_transform() { nassertv_always(!is_empty()); node()->clear_attrib(TexMatrixAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_transform -// Access: Published -// Description: Removes the texture matrix on the current node for -// the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture matrix on the current node for the given stage. + */ void NodePath:: clear_tex_transform(TextureStage *stage) { nassertv_always(!is_empty()); @@ -3897,12 +3394,10 @@ clear_tex_transform(TextureStage *stage) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_tex_transform -// Access: Published -// Description: Returns true if there is an explicit texture matrix -// on the current node for the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an explicit texture matrix on the current node for + * the given stage. + */ bool NodePath:: has_tex_transform(TextureStage *stage) const { nassertr_always(!is_empty(), false); @@ -3917,13 +3412,11 @@ has_tex_transform(TextureStage *stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_transform -// Access: Published -// Description: Returns the texture matrix on the current node for the -// given stage, or identity transform if there is no -// explicit transform set for the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture matrix on the current node for the given stage, or + * identity transform if there is no explicit transform set for the given + * stage. + */ CPT(TransformState) NodePath:: get_tex_transform(TextureStage *stage) const { nassertr_always(!is_empty(), NULL); @@ -3938,12 +3431,10 @@ get_tex_transform(TextureStage *stage) const { return TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_transform -// Access: Published -// Description: Sets the texture matrix on the current node to the -// indicated transform for the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Sets the texture matrix on the current node to the indicated transform for + * the given stage. + */ void NodePath:: set_tex_transform(const NodePath &other, TextureStage *stage, const TransformState *transform) { nassertv(_error_type == ET_ok && other._error_type == ET_ok); @@ -3955,8 +3446,7 @@ set_tex_transform(const NodePath &other, TextureStage *stage, const TransformSta if (attrib != (const RenderAttrib *)NULL) { const TexMatrixAttrib *tma = DCAST(TexMatrixAttrib, attrib); - // Modify the existing TexMatrixAttrib to add the indicated - // stage. + // Modify the existing TexMatrixAttrib to add the indicated stage. state = state->add_attrib(tma->add_stage(stage, transform)); } else { @@ -3973,17 +3463,15 @@ set_tex_transform(const NodePath &other, TextureStage *stage, const TransformSta } CPT(RenderState) new_state = rel_state->compose(state); - // And apply only the TexMatrixAttrib to the current node, leaving - // the others unchanged. + // And apply only the TexMatrixAttrib to the current node, leaving the + // others unchanged. node()->set_attrib(new_state->get_attrib(TexMatrixAttrib::get_class_slot())); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_transform -// Access: Published -// Description: Returns the texture matrix on the current node for the -// given stage, relative to the other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture matrix on the current node for the given stage, + * relative to the other node. + */ CPT(TransformState) NodePath:: get_tex_transform(const NodePath &other, TextureStage *stage) const { nassertr(_error_type == ET_ok && other._error_type == ET_ok, TransformState::make_identity()); @@ -3999,12 +3487,10 @@ get_tex_transform(const NodePath &other, TextureStage *stage) const { return TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_gen -// Access: Published -// Description: Enables automatic texture coordinate generation for -// the indicated texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Enables automatic texture coordinate generation for the indicated texture + * stage. + */ void NodePath:: set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority) { nassertv_always(!is_empty()); @@ -4026,14 +3512,11 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, int priority) { node()->set_attrib(tga->add_stage(stage, mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_gen -// Access: Published -// Description: Enables automatic texture coordinate generation for -// the indicated texture stage. This version of this -// method is useful when setting M_constant, which -// requires a constant texture coordinate value. -//////////////////////////////////////////////////////////////////// +/** + * Enables automatic texture coordinate generation for the indicated texture + * stage. This version of this method is useful when setting M_constant, + * which requires a constant texture coordinate value. + */ void NodePath:: set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, const LTexCoord3 &constant_value, int priority) { @@ -4056,24 +3539,20 @@ set_tex_gen(TextureStage *stage, RenderAttrib::TexGenMode mode, node()->set_attrib(tga->add_stage(stage, mode, constant_value), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_gen -// Access: Published -// Description: Removes the texture coordinate generation mode from -// all texture stages on this node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture coordinate generation mode from all texture stages on + * this node. + */ void NodePath:: clear_tex_gen() { nassertv_always(!is_empty()); node()->clear_attrib(TexGenAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_gen -// Access: Published -// Description: Disables automatic texture coordinate generation for -// the indicated texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Disables automatic texture coordinate generation for the indicated texture + * stage. + */ void NodePath:: clear_tex_gen(TextureStage *stage) { nassertv_always(!is_empty()); @@ -4093,13 +3572,10 @@ clear_tex_gen(TextureStage *stage) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_tex_gen -// Access: Published -// Description: Returns true if there is a mode for automatic texture -// coordinate generation on the current node for the -// given stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a mode for automatic texture coordinate generation + * on the current node for the given stage. + */ bool NodePath:: has_tex_gen(TextureStage *stage) const { nassertr_always(!is_empty(), false); @@ -4114,13 +3590,10 @@ has_tex_gen(TextureStage *stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_gen -// Access: Published -// Description: Returns the texture coordinate generation mode for -// the given stage, or M_off if there is no explicit -// mode set for the given stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture coordinate generation mode for the given stage, or + * M_off if there is no explicit mode set for the given stage. + */ RenderAttrib::TexGenMode NodePath:: get_tex_gen(TextureStage *stage) const { nassertr_always(!is_empty(), TexGenAttrib::M_off); @@ -4135,21 +3608,17 @@ get_tex_gen(TextureStage *stage) const { return TexGenAttrib::M_off; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_tex_projector -// Access: Published -// Description: Establishes a TexProjectorEffect on this node, which -// can be used to establish projective texturing (but -// see also the NodePath::project_texture() convenience -// function), or it can be used to bind this node's -// texture transform to particular node's position in -// space, allowing a LerpInterval (for instance) to -// adjust this node's texture coordinates. -// -// If to is a LensNode, then the fourth parameter, -// lens_index, can be provided to select a particular -// lens to apply. Otherwise lens_index is not used. -//////////////////////////////////////////////////////////////////// +/** + * Establishes a TexProjectorEffect on this node, which can be used to + * establish projective texturing (but see also the + * NodePath::project_texture() convenience function), or it can be used to + * bind this node's texture transform to particular node's position in space, + * allowing a LerpInterval (for instance) to adjust this node's texture + * coordinates. + * + * If to is a LensNode, then the fourth parameter, lens_index, can be provided + * to select a particular lens to apply. Otherwise lens_index is not used. + */ void NodePath:: set_tex_projector(TextureStage *stage, const NodePath &from, const NodePath &to, int lens_index) { @@ -4170,12 +3639,9 @@ set_tex_projector(TextureStage *stage, const NodePath &from, const NodePath &to, node()->set_effect(tpe->add_stage(stage, from, to, lens_index)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_projector -// Access: Published -// Description: Removes the TexProjectorEffect for the indicated -// stage from this node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the TexProjectorEffect for the indicated stage from this node. + */ void NodePath:: clear_tex_projector(TextureStage *stage) { nassertv_always(!is_empty()); @@ -4195,24 +3661,19 @@ clear_tex_projector(TextureStage *stage) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_tex_projector -// Access: Published -// Description: Removes the TexProjectorEffect for all stages from -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the TexProjectorEffect for all stages from this node. + */ void NodePath:: clear_tex_projector() { nassertv_always(!is_empty()); node()->clear_effect(TexProjectorEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_tex_projector -// Access: Published -// Description: Returns true if this node has a TexProjectorEffect -// for the indicated stage, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node has a TexProjectorEffect for the indicated stage, + * false otherwise. + */ bool NodePath:: has_tex_projector(TextureStage *stage) const { nassertr_always(!is_empty(), false); @@ -4227,15 +3688,11 @@ has_tex_projector(TextureStage *stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_projector_from -// Access: Published -// Description: Returns the "from" node associated with the -// TexProjectorEffect on the indicated stage. The -// relative transform between the "from" and the "to" -// nodes is automatically applied to the texture -// transform each frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "from" node associated with the TexProjectorEffect on the + * indicated stage. The relative transform between the "from" and the "to" + * nodes is automatically applied to the texture transform each frame. + */ NodePath NodePath:: get_tex_projector_from(TextureStage *stage) const { nassertr_always(!is_empty(), NodePath::fail()); @@ -4250,15 +3707,11 @@ get_tex_projector_from(TextureStage *stage) const { return NodePath::not_found(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_tex_projector_to -// Access: Published -// Description: Returns the "to" node associated with the -// TexProjectorEffect on the indicated stage. The -// relative transform between the "from" and the "to" -// nodes is automatically applied to the texture -// transform each frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "to" node associated with the TexProjectorEffect on the + * indicated stage. The relative transform between the "from" and the "to" + * nodes is automatically applied to the texture transform each frame. + */ NodePath NodePath:: get_tex_projector_to(TextureStage *stage) const { nassertr_always(!is_empty(), NodePath::fail()); @@ -4273,14 +3726,11 @@ get_tex_projector_to(TextureStage *stage) const { return NodePath::not_found(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::project_texture -// Access: Published -// Description: A convenience function to enable projective texturing -// at this node level and below, using the indicated -// NodePath (which should contain a LensNode) as the -// projector. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to enable projective texturing at this node level + * and below, using the indicated NodePath (which should contain a LensNode) + * as the projector. + */ void NodePath:: project_texture(TextureStage *stage, Texture *tex, const NodePath &projector) { nassertv(!projector.is_empty() && projector.node()->is_of_type(LensNode::get_class_type())); @@ -4289,29 +3739,24 @@ project_texture(TextureStage *stage, Texture *tex, const NodePath &projector) { set_tex_projector(stage, NodePath(), projector); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_vertex_column -// Access: Published -// Description: Returns true if there are at least some vertices at -// this node and below that contain a reference to the -// indicated vertex data column name, false otherwise. -// -// This is particularly useful for testing whether a -// particular model has a given texture coordinate set -// (but see has_texcoord()). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are at least some vertices at this node and below + * that contain a reference to the indicated vertex data column name, false + * otherwise. + * + * This is particularly useful for testing whether a particular model has a + * given texture coordinate set (but see has_texcoord()). + */ bool NodePath:: has_vertex_column(const InternalName *name) const { nassertr_always(!is_empty(), false); return r_has_vertex_column(node(), name); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_vertex_columns -// Access: Published -// Description: Returns a list of all vertex array columns stored on -// some geometry found at this node level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all vertex array columns stored on some geometry found at + * this node level and below. + */ InternalNameCollection NodePath:: find_all_vertex_columns() const { nassertr_always(!is_empty(), InternalNameCollection()); @@ -4326,14 +3771,11 @@ find_all_vertex_columns() const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_vertex_columns -// Access: Published -// Description: Returns a list of all vertex array columns stored on -// some geometry found at this node level and below that -// match the indicated name (which may contain wildcard -// characters). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all vertex array columns stored on some geometry found at + * this node level and below that match the indicated name (which may contain + * wildcard characters). + */ InternalNameCollection NodePath:: find_all_vertex_columns(const string &name) const { nassertr_always(!is_empty(), InternalNameCollection()); @@ -4353,12 +3795,10 @@ find_all_vertex_columns(const string &name) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_texcoords -// Access: Published -// Description: Returns a list of all texture coordinate sets used by -// any geometry at this node level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all texture coordinate sets used by any geometry at this + * node level and below. + */ InternalNameCollection NodePath:: find_all_texcoords() const { nassertr_always(!is_empty(), InternalNameCollection()); @@ -4377,14 +3817,11 @@ find_all_texcoords() const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_texcoords -// Access: Published -// Description: Returns a list of all texture coordinate sets used by -// any geometry at this node level and below that match -// the indicated name (which may contain wildcard -// characters). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all texture coordinate sets used by any geometry at this + * node level and below that match the indicated name (which may contain + * wildcard characters). + */ InternalNameCollection NodePath:: find_all_texcoords(const string &name) const { nassertr_always(!is_empty(), InternalNameCollection()); @@ -4399,8 +3836,8 @@ find_all_texcoords(const string &name) const { for (ti = vertex_columns.begin(); ti != vertex_columns.end(); ++ti) { const InternalName *name = (*ti); if (name->get_top() == texcoord_name) { - // This is a texture coordinate name. Figure out the basename - // of the texture coordinates. + // This is a texture coordinate name. Figure out the basename of the + // texture coordinates. int index = name->find_ancestor("texcoord"); nassertr(index != -1, InternalNameCollection()); string net_basename = name->get_net_basename(index - 1); @@ -4413,14 +3850,11 @@ find_all_texcoords(const string &name) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_texture -// Access: Published -// Description: Returns the first texture found applied to geometry -// at this node or below that matches the indicated name -// (which may contain wildcards). Returns the texture -// if it is found, or NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first texture found applied to geometry at this node or below + * that matches the indicated name (which may contain wildcards). Returns the + * texture if it is found, or NULL if it is not. + */ Texture *NodePath:: find_texture(const string &name) const { nassertr_always(!is_empty(), NULL); @@ -4428,26 +3862,20 @@ find_texture(const string &name) const { return r_find_texture(node(), get_net_state(), glob); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_texture -// Access: Published -// Description: Returns the first texture found applied to geometry -// at this node or below that is assigned to the -// indicated texture stage. Returns the texture if it -// is found, or NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first texture found applied to geometry at this node or below + * that is assigned to the indicated texture stage. Returns the texture if it + * is found, or NULL if it is not. + */ Texture *NodePath:: find_texture(TextureStage *stage) const { nassertr_always(!is_empty(), NULL); return r_find_texture(node(), stage); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_textures -// Access: Published -// Description: Returns a list of a textures applied to geometry at -// this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a textures applied to geometry at this node and below. + */ TextureCollection NodePath:: find_all_textures() const { nassertr_always(!is_empty(), TextureCollection()); @@ -4462,13 +3890,10 @@ find_all_textures() const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_textures -// Access: Published -// Description: Returns a list of a textures applied to geometry at -// this node and below that match the indicated name -// (which may contain wildcard characters). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a textures applied to geometry at this node and below + * that match the indicated name (which may contain wildcard characters). + */ TextureCollection NodePath:: find_all_textures(const string &name) const { nassertr_always(!is_empty(), TextureCollection()); @@ -4488,13 +3913,10 @@ find_all_textures(const string &name) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_textures -// Access: Published -// Description: Returns a list of a textures on geometry at -// this node and below that are assigned to the -// indicated texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a textures on geometry at this node and below that are + * assigned to the indicated texture stage. + */ TextureCollection NodePath:: find_all_textures(TextureStage *stage) const { nassertr_always(!is_empty(), TextureCollection()); @@ -4510,15 +3932,11 @@ find_all_textures(TextureStage *stage) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_texture_stage -// Access: Published -// Description: Returns the first TextureStage found applied to -// geometry at this node or below that matches the -// indicated name (which may contain wildcards). -// Returns the TextureStage if it is found, or NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first TextureStage found applied to geometry at this node or + * below that matches the indicated name (which may contain wildcards). + * Returns the TextureStage if it is found, or NULL if it is not. + */ TextureStage *NodePath:: find_texture_stage(const string &name) const { nassertr_always(!is_empty(), NULL); @@ -4526,12 +3944,10 @@ find_texture_stage(const string &name) const { return r_find_texture_stage(node(), get_net_state(), glob); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_texture_stages -// Access: Published -// Description: Returns a list of a TextureStages applied to geometry -// at this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a TextureStages applied to geometry at this node and + * below. + */ TextureStageCollection NodePath:: find_all_texture_stages() const { nassertr_always(!is_empty(), TextureStageCollection()); @@ -4546,29 +3962,24 @@ find_all_texture_stages() const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::unify_texture_stages -// Access: Published -// Description: Searches through all TextureStages at this node and -// below. Any TextureStages that share the same name as -// the indicated TextureStage object are replaced with -// this object, thus ensuring that all geometry at this -// node and below with a particular TextureStage name is -// using the same TextureStage object. -//////////////////////////////////////////////////////////////////// +/** + * Searches through all TextureStages at this node and below. Any + * TextureStages that share the same name as the indicated TextureStage object + * are replaced with this object, thus ensuring that all geometry at this node + * and below with a particular TextureStage name is using the same + * TextureStage object. + */ void NodePath:: unify_texture_stages(TextureStage *stage) { nassertv_always(!is_empty()); r_unify_texture_stages(node(), stage); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_texture_stages -// Access: Published -// Description: Returns a list of a TextureStages applied to geometry -// at this node and below that match the indicated name -// (which may contain wildcard characters). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a TextureStages applied to geometry at this node and + * below that match the indicated name (which may contain wildcard + * characters). + */ TextureStageCollection NodePath:: find_all_texture_stages(const string &name) const { nassertr_always(!is_empty(), TextureStageCollection()); @@ -4588,14 +3999,11 @@ find_all_texture_stages(const string &name) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_material -// Access: Published -// Description: Returns the first material found applied to geometry -// at this node or below that matches the indicated name -// (which may contain wildcards). Returns the material -// if it is found, or NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first material found applied to geometry at this node or below + * that matches the indicated name (which may contain wildcards). Returns the + * material if it is found, or NULL if it is not. + */ Material *NodePath:: find_material(const string &name) const { nassertr_always(!is_empty(), NULL); @@ -4603,12 +4011,9 @@ find_material(const string &name) const { return r_find_material(node(), get_net_state(), glob); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_materials -// Access: Published -// Description: Returns a list of a materials applied to geometry at -// this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a materials applied to geometry at this node and below. + */ MaterialCollection NodePath:: find_all_materials() const { nassertr_always(!is_empty(), MaterialCollection()); @@ -4623,13 +4028,10 @@ find_all_materials() const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_all_materials -// Access: Published -// Description: Returns a list of a materials applied to geometry at -// this node and below that match the indicated name -// (which may contain wildcard characters). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of a materials applied to geometry at this node and below + * that match the indicated name (which may contain wildcard characters). + */ MaterialCollection NodePath:: find_all_materials(const string &name) const { nassertr_always(!is_empty(), MaterialCollection()); @@ -4649,16 +4051,13 @@ find_all_materials(const string &name) const { return tc; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_material -// Access: Published -// Description: Sets the geometry at this level and below to render -// using the indicated material. -// -// Previously, this operation made a copy of the -// material structure, but nowadays it assigns the -// pointer directly. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using the indicated + * material. + * + * Previously, this operation made a copy of the material structure, but + * nowadays it assigns the pointer directly. + */ void NodePath:: set_material(Material *mat, int priority) { nassertv_always(!is_empty()); @@ -4666,41 +4065,32 @@ set_material(Material *mat, int priority) { node()->set_attrib(MaterialAttrib::make(mat), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_material_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no material. This is normally the default, but -// it may be useful to use this to contradict -// set_material() at a higher node level (or, with a -// priority, to override a set_material() at a lower -// level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no material. + * This is normally the default, but it may be useful to use this to + * contradict set_material() at a higher node level (or, with a priority, to + * override a set_material() at a lower level). + */ void NodePath:: set_material_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(MaterialAttrib::make_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_material -// Access: Published -// Description: Completely removes any material adjustment that may -// have been set via set_material() from this particular -// node. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any material adjustment that may have been set via + * set_material() from this particular node. + */ void NodePath:: clear_material() { nassertv_always(!is_empty()); node()->clear_attrib(MaterialAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_material -// Access: Published -// Description: Returns true if a material has been applied to this -// particular node via set_material(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a material has been applied to this particular node via + * set_material(), false otherwise. + */ bool NodePath:: has_material() const { nassertr_always(!is_empty(), false); @@ -4714,18 +4104,14 @@ has_material() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_material -// Access: Published -// Description: Returns the material that has been set on this -// particular node, or NULL if no material has been set. -// This is not necessarily the material that will be -// applied to the geometry at or below this level, as -// another material at a higher or lower level may -// override. -// -// See also find_material(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the material that has been set on this particular node, or NULL if + * no material has been set. This is not necessarily the material that will + * be applied to the geometry at or below this level, as another material at a + * higher or lower level may override. + * + * See also find_material(). + */ PT(Material) NodePath:: get_material() const { nassertr_always(!is_empty(), NULL); @@ -4739,59 +4125,45 @@ get_material() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fog -// Access: Published -// Description: Sets the geometry at this level and below to render -// using the indicated fog. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using the indicated + * fog. + */ void NodePath:: set_fog(Fog *fog, int priority) { nassertv_always(!is_empty()); node()->set_attrib(FogAttrib::make(fog), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_fog_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no fog. This is normally the default, but -// it may be useful to use this to contradict -// set_fog() at a higher node level (or, with a -// priority, to override a set_fog() at a lower -// level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no fog. This is + * normally the default, but it may be useful to use this to contradict + * set_fog() at a higher node level (or, with a priority, to override a + * set_fog() at a lower level). + */ void NodePath:: set_fog_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(FogAttrib::make_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_fog -// Access: Published -// Description: Completely removes any fog adjustment that may -// have been set via set_fog() or set_fog_off() -// from this particular node. This allows whatever -// fogs might be otherwise affecting the geometry to -// show instead. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any fog adjustment that may have been set via set_fog() + * or set_fog_off() from this particular node. This allows whatever fogs + * might be otherwise affecting the geometry to show instead. + */ void NodePath:: clear_fog() { nassertv_always(!is_empty()); node()->clear_attrib(FogAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_fog -// Access: Published -// Description: Returns true if a fog has been applied to this -// particular node via set_fog(), false otherwise. -// This is not the same thing as asking whether the -// geometry at this node will be rendered with -// fog, as there may be a fog in effect from a higher or -// lower level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a fog has been applied to this particular node via + * set_fog(), false otherwise. This is not the same thing as asking whether + * the geometry at this node will be rendered with fog, as there may be a fog + * in effect from a higher or lower level. + */ bool NodePath:: has_fog() const { nassertr_always(!is_empty(), false); @@ -4805,16 +4177,12 @@ has_fog() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_fog_off -// Access: Published -// Description: Returns true if a fog has been specifically -// disabled on this particular node via -// set_fog_off(), false otherwise. This is not the -// same thing as asking whether the geometry at this -// node will be rendered unfogged, as there may be a -// fog in effect from a higher or lower level. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a fog has been specifically disabled on this particular + * node via set_fog_off(), false otherwise. This is not the same thing as + * asking whether the geometry at this node will be rendered unfogged, as + * there may be a fog in effect from a higher or lower level. + */ bool NodePath:: has_fog_off() const { nassertr_always(!is_empty(), false); @@ -4828,16 +4196,12 @@ has_fog_off() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_fog -// Access: Published -// Description: Returns the fog that has been set on this -// particular node, or NULL if no fog has been set. -// This is not necessarily the fog that will be -// applied to the geometry at or below this level, as -// another fog at a higher or lower level may -// override. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fog that has been set on this particular node, or NULL if no + * fog has been set. This is not necessarily the fog that will be applied to + * the geometry at or below this level, as another fog at a higher or lower + * level may override. + */ Fog *NodePath:: get_fog() const { nassertr_always(!is_empty(), NULL); @@ -4851,12 +4215,10 @@ get_fog() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode_wireframe -// Access: Published -// Description: Sets up the geometry at this level and below (unless -// overridden) to render in wireframe mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the geometry at this level and below (unless overridden) to render + * in wireframe mode. + */ void NodePath:: set_render_mode_wireframe(int priority) { nassertv_always(!is_empty()); @@ -4865,13 +4227,10 @@ set_render_mode_wireframe(int priority) { node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_wireframe, rma->get_thickness(), rma->get_perspective()), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode_filled -// Access: Published -// Description: Sets up the geometry at this level and below (unless -// overridden) to render in filled (i.e. not wireframe) -// mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the geometry at this level and below (unless overridden) to render + * in filled (i.e. not wireframe) mode. + */ void NodePath:: set_render_mode_filled(int priority) { nassertv_always(!is_empty()); @@ -4880,14 +4239,11 @@ set_render_mode_filled(int priority) { node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled, rma->get_thickness(), rma->get_perspective()), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode_filled_wireframe -// Access: Published -// Description: Sets up the geometry at this level and below (unless -// overridden) to render in filled, but overlay the -// wireframe on top with a fixed color. This is useful -// for debug visualizations. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the geometry at this level and below (unless overridden) to render + * in filled, but overlay the wireframe on top with a fixed color. This is + * useful for debug visualizations. + */ void NodePath:: set_render_mode_filled_wireframe(const LColor &wireframe_color, int priority) { nassertv_always(!is_empty()); @@ -4896,21 +4252,16 @@ set_render_mode_filled_wireframe(const LColor &wireframe_color, int priority) { node()->set_attrib(RenderModeAttrib::make(RenderModeAttrib::M_filled_wireframe, rma->get_thickness(), rma->get_perspective(), wireframe_color), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode_perspective -// Access: Published -// Description: Sets up the point geometry at this level and below to -// render as perspective sprites (that is, billboarded -// quads). The thickness, as specified with -// set_render_mode_thickness(), is the width of each -// point in 3-D units, unless it is overridden on a -// per-vertex basis. This does not affect geometry -// other than points. -// -// If you want the quads to be individually textured, -// you should also set a TexGenAttrib::M_point_sprite on -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the point geometry at this level and below to render as perspective + * sprites (that is, billboarded quads). The thickness, as specified with + * set_render_mode_thickness(), is the width of each point in 3-D units, + * unless it is overridden on a per-vertex basis. This does not affect + * geometry other than points. + * + * If you want the quads to be individually textured, you should also set a + * TexGenAttrib::M_point_sprite on the node. + */ void NodePath:: set_render_mode_perspective(bool perspective, int priority) { nassertv_always(!is_empty()); @@ -4919,19 +4270,14 @@ set_render_mode_perspective(bool perspective, int priority) { node()->set_attrib(RenderModeAttrib::make(rma->get_mode(), rma->get_thickness(), perspective, rma->get_wireframe_color()), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode_thickness -// Access: Published -// Description: Sets up the point geometry at this level and below to -// render as thick points (that is, billboarded -// quads). The thickness is in pixels, unless -// set_render_mode_perspective is also true, in which -// case it is in 3-D units. -// -// If you want the quads to be individually textured, -// you should also set a TexGenAttrib::M_point_sprite on -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the point geometry at this level and below to render as thick + * points (that is, billboarded quads). The thickness is in pixels, unless + * set_render_mode_perspective is also true, in which case it is in 3-D units. + * + * If you want the quads to be individually textured, you should also set a + * TexGenAttrib::M_point_sprite on the node. + */ void NodePath:: set_render_mode_thickness(PN_stdfloat thickness, int priority) { nassertv_always(!is_empty()); @@ -4940,13 +4286,10 @@ set_render_mode_thickness(PN_stdfloat thickness, int priority) { node()->set_attrib(RenderModeAttrib::make(rma->get_mode(), thickness, rma->get_perspective(), rma->get_wireframe_color()), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_render_mode -// Access: Published -// Description: Sets up the geometry at this level and below (unless -// overridden) to render in the specified mode and with -// the indicated line and/or point thickness. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the geometry at this level and below (unless overridden) to render + * in the specified mode and with the indicated line and/or point thickness. + */ void NodePath:: set_render_mode(RenderModeAttrib::Mode mode, PN_stdfloat thickness, int priority) { nassertv_always(!is_empty()); @@ -4954,41 +4297,31 @@ set_render_mode(RenderModeAttrib::Mode mode, PN_stdfloat thickness, int priority node()->set_attrib(RenderModeAttrib::make(mode, thickness), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_render_mode -// Access: Published -// Description: Completely removes any render mode adjustment that -// may have been set on this node via -// set_render_mode_wireframe() or -// set_render_mode_filled(). -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any render mode adjustment that may have been set on + * this node via set_render_mode_wireframe() or set_render_mode_filled(). + */ void NodePath:: clear_render_mode() { nassertv_always(!is_empty()); node()->clear_attrib(RenderModeAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_render_mode -// Access: Published -// Description: Returns true if a render mode has been explicitly set -// on this particular node via set_render_mode() (or -// set_render_mode_wireframe() or -// set_render_mode_filled()), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a render mode has been explicitly set on this particular + * node via set_render_mode() (or set_render_mode_wireframe() or + * set_render_mode_filled()), false otherwise. + */ bool NodePath:: has_render_mode() const { nassertr_always(!is_empty(), false); return node()->has_attrib(RenderModeAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_render_mode -// Access: Published -// Description: Returns the render mode that has been specifically -// set on this node via set_render_mode(), or -// M_unchanged if nothing has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render mode that has been specifically set on this node via + * set_render_mode(), or M_unchanged if nothing has been set. + */ RenderModeAttrib::Mode NodePath:: get_render_mode() const { nassertr_always(!is_empty(), RenderModeAttrib::M_unchanged); @@ -5002,13 +4335,10 @@ get_render_mode() const { return RenderModeAttrib::M_unchanged; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_render_mode_thickness -// Access: Published -// Description: Returns the render mode thickness that has been -// specifically set on this node via set_render_mode(), -// or 1.0 if nothing has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render mode thickness that has been specifically set on this + * node via set_render_mode(), or 1.0 if nothing has been set. + */ PN_stdfloat NodePath:: get_render_mode_thickness() const { nassertr_always(!is_empty(), 0.0f); @@ -5022,13 +4352,10 @@ get_render_mode_thickness() const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_render_mode_perspective -// Access: Published -// Description: Returns the flag that has been set on this node via -// set_render_mode_perspective(), or false if no flag -// has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that has been set on this node via + * set_render_mode_perspective(), or false if no flag has been set. + */ bool NodePath:: get_render_mode_perspective() const { nassertr_always(!is_empty(), 0.0f); @@ -5042,15 +4369,11 @@ get_render_mode_perspective() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_two_sided -// Access: Published -// Description: Specifically sets or disables two-sided rendering -// mode on this particular node. If no other nodes -// override, this will cause backfacing polygons to be -// drawn (in two-sided mode, true) or culled (in -// one-sided mode, false). -//////////////////////////////////////////////////////////////////// +/** + * Specifically sets or disables two-sided rendering mode on this particular + * node. If no other nodes override, this will cause backfacing polygons to + * be drawn (in two-sided mode, true) or culled (in one-sided mode, false). + */ void NodePath:: set_two_sided(bool two_sided, int priority) { nassertv_always(!is_empty()); @@ -5063,49 +4386,37 @@ set_two_sided(bool two_sided, int priority) { node()->set_attrib(CullFaceAttrib::make(mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_two_sided -// Access: Published -// Description: Completely removes any two-sided adjustment that -// may have been set on this node via set_two_sided(). -// The geometry at this level and below will -// subsequently be rendered either two-sided or -// one-sided, according to whatever other nodes may have -// had set_two_sided() on it, or according to the -// initial state otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any two-sided adjustment that may have been set on this + * node via set_two_sided(). The geometry at this level and below will + * subsequently be rendered either two-sided or one-sided, according to + * whatever other nodes may have had set_two_sided() on it, or according to + * the initial state otherwise. + */ void NodePath:: clear_two_sided() { nassertv_always(!is_empty()); node()->clear_attrib(CullFaceAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_two_sided -// Access: Published -// Description: Returns true if a two-sided adjustment has been -// explicitly set on this particular node via -// set_two_sided(). If this returns true, then -// get_two_sided() may be called to determine which has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a two-sided adjustment has been explicitly set on this + * particular node via set_two_sided(). If this returns true, then + * get_two_sided() may be called to determine which has been set. + */ bool NodePath:: has_two_sided() const { nassertr_always(!is_empty(), false); return node()->has_attrib(CullFaceAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_two_sided -// Access: Published -// Description: Returns true if two-sided rendering has been -// specifically set on this node via set_two_sided(), or -// false if one-sided rendering has been specifically -// set, or if nothing has been specifically set. See -// also has_two_sided(). This does not necessarily -// imply that the geometry will or will not be rendered -// two-sided, as there may be other nodes that override. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if two-sided rendering has been specifically set on this node + * via set_two_sided(), or false if one-sided rendering has been specifically + * set, or if nothing has been specifically set. See also has_two_sided(). + * This does not necessarily imply that the geometry will or will not be + * rendered two-sided, as there may be other nodes that override. + */ bool NodePath:: get_two_sided() const { nassertr_always(!is_empty(), false); @@ -5119,15 +4430,11 @@ get_two_sided() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_depth_test -// Access: Published -// Description: Specifically sets or disables the testing of the -// depth buffer on this particular node. This is -// normally on in the 3-d scene graph and off in the 2-d -// scene graph; it should be on for rendering most 3-d -// objects properly. -//////////////////////////////////////////////////////////////////// +/** + * Specifically sets or disables the testing of the depth buffer on this + * particular node. This is normally on in the 3-d scene graph and off in the + * 2-d scene graph; it should be on for rendering most 3-d objects properly. + */ void NodePath:: set_depth_test(bool depth_test, int priority) { nassertv_always(!is_empty()); @@ -5140,42 +4447,33 @@ set_depth_test(bool depth_test, int priority) { node()->set_attrib(DepthTestAttrib::make(mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_depth_test -// Access: Published -// Description: Completely removes any depth-test adjustment that -// may have been set on this node via set_depth_test(). -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any depth-test adjustment that may have been set on this + * node via set_depth_test(). + */ void NodePath:: clear_depth_test() { nassertv_always(!is_empty()); node()->clear_attrib(DepthTestAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_depth_test -// Access: Published -// Description: Returns true if a depth-test adjustment has been -// explicitly set on this particular node via -// set_depth_test(). If this returns true, then -// get_depth_test() may be called to determine which has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a depth-test adjustment has been explicitly set on this + * particular node via set_depth_test(). If this returns true, then + * get_depth_test() may be called to determine which has been set. + */ bool NodePath:: has_depth_test() const { nassertr_always(!is_empty(), false); return node()->has_attrib(DepthTestAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_depth_test -// Access: Published -// Description: Returns true if depth-test rendering has been -// specifically set on this node via set_depth_test(), or -// false if depth-test rendering has been specifically -// disabled. If nothing has been specifically set, -// returns true. See also has_depth_test(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if depth-test rendering has been specifically set on this node + * via set_depth_test(), or false if depth-test rendering has been + * specifically disabled. If nothing has been specifically set, returns true. + * See also has_depth_test(). + */ bool NodePath:: get_depth_test() const { nassertr_always(!is_empty(), false); @@ -5189,15 +4487,11 @@ get_depth_test() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_depth_write -// Access: Published -// Description: Specifically sets or disables the writing to the -// depth buffer on this particular node. This is -// normally on in the 3-d scene graph and off in the 2-d -// scene graph; it should be on for rendering most 3-d -// objects properly. -//////////////////////////////////////////////////////////////////// +/** + * Specifically sets or disables the writing to the depth buffer on this + * particular node. This is normally on in the 3-d scene graph and off in the + * 2-d scene graph; it should be on for rendering most 3-d objects properly. + */ void NodePath:: set_depth_write(bool depth_write, int priority) { nassertv_always(!is_empty()); @@ -5210,42 +4504,33 @@ set_depth_write(bool depth_write, int priority) { node()->set_attrib(DepthWriteAttrib::make(mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_depth_write -// Access: Published -// Description: Completely removes any depth-write adjustment that -// may have been set on this node via set_depth_write(). -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any depth-write adjustment that may have been set on + * this node via set_depth_write(). + */ void NodePath:: clear_depth_write() { nassertv_always(!is_empty()); node()->clear_attrib(DepthWriteAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_depth_write -// Access: Published -// Description: Returns true if a depth-write adjustment has been -// explicitly set on this particular node via -// set_depth_write(). If this returns true, then -// get_depth_write() may be called to determine which has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a depth-write adjustment has been explicitly set on this + * particular node via set_depth_write(). If this returns true, then + * get_depth_write() may be called to determine which has been set. + */ bool NodePath:: has_depth_write() const { nassertr_always(!is_empty(), false); return node()->has_attrib(DepthWriteAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_depth_write -// Access: Published -// Description: Returns true if depth-write rendering has been -// specifically set on this node via set_depth_write(), or -// false if depth-write rendering has been specifically -// disabled. If nothing has been specifically set, -// returns true. See also has_depth_write(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if depth-write rendering has been specifically set on this + * node via set_depth_write(), or false if depth-write rendering has been + * specifically disabled. If nothing has been specifically set, returns true. + * See also has_depth_write(). + */ bool NodePath:: get_depth_write() const { nassertr_always(!is_empty(), false); @@ -5259,21 +4544,15 @@ get_depth_write() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_depth_offset -// Access: Published -// Description: This instructs the graphics driver to apply an -// offset or bias to the generated depth values for -// rendered polygons, before they are written to the -// depth buffer. This can be used to shift polygons -// forward slightly, to resolve depth conflicts, or -// self-shadowing artifacts on thin objects. -// The bias is always an integer number, and each -// integer increment represents the smallest possible -// increment in Z that is sufficient to completely -// resolve two coplanar polygons. Positive numbers -// are closer towards the camera. -//////////////////////////////////////////////////////////////////// +/** + * This instructs the graphics driver to apply an offset or bias to the + * generated depth values for rendered polygons, before they are written to + * the depth buffer. This can be used to shift polygons forward slightly, to + * resolve depth conflicts, or self-shadowing artifacts on thin objects. The + * bias is always an integer number, and each integer increment represents the + * smallest possible increment in Z that is sufficient to completely resolve + * two coplanar polygons. Positive numbers are closer towards the camera. + */ void NodePath:: set_depth_offset(int bias, int priority) { nassertv_always(!is_empty()); @@ -5281,39 +4560,31 @@ set_depth_offset(int bias, int priority) { node()->set_attrib(DepthOffsetAttrib::make(bias), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_depth_offset -// Access: Published -// Description: Completely removes any depth-offset adjustment that -// may have been set on this node via set_depth_offset(). -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any depth-offset adjustment that may have been set on + * this node via set_depth_offset(). + */ void NodePath:: clear_depth_offset() { nassertv_always(!is_empty()); node()->clear_attrib(DepthOffsetAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_depth_offset -// Access: Published -// Description: Returns true if a depth-offset adjustment has been -// explicitly set on this particular node via -// set_depth_offset(). If this returns true, then -// get_depth_offset() may be called to determine which has -// been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a depth-offset adjustment has been explicitly set on this + * particular node via set_depth_offset(). If this returns true, then + * get_depth_offset() may be called to determine which has been set. + */ bool NodePath:: has_depth_offset() const { nassertr_always(!is_empty(), false); return node()->has_attrib(DepthOffsetAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_depth_offset -// Access: Published -// Description: Returns the depth offset value if it has been -// specified using set_depth_offset, or 0 if not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the depth offset value if it has been specified using + * set_depth_offset, or 0 if not. + */ int NodePath:: get_depth_offset() const { nassertr_always(!is_empty(), 0); @@ -5327,13 +4598,11 @@ get_depth_offset() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::do_billboard_axis -// Access: Published -// Description: Performs a billboard-type rotate to the indicated -// camera node, one time only, and leaves the object -// rotated. This is similar in principle to heads_up(). -//////////////////////////////////////////////////////////////////// +/** + * Performs a billboard-type rotate to the indicated camera node, one time + * only, and leaves the object rotated. This is similar in principle to + * heads_up(). + */ void NodePath:: do_billboard_axis(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5348,8 +4617,8 @@ do_billboard_axis(const NodePath &camera, PN_stdfloat offset) { ::heads_up(quat, rel_pos, up); set_quat(quat); - // Also slide the geometry towards the camera according to the - // offset factor. + // Also slide the geometry towards the camera according to the offset + // factor. if (offset != 0.0f) { LVector3 translate = rel_mat.get_row3(3); translate.normalize(); @@ -5358,15 +4627,12 @@ do_billboard_axis(const NodePath &camera, PN_stdfloat offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::do_billboard_point_eye -// Access: Published -// Description: Performs a billboard-type rotate to the indicated -// camera node, one time only, and leaves the object -// rotated. This is similar in principle to look_at(), -// although the point_eye billboard effect cannot be -// achieved using the ordinary look_at() call. -//////////////////////////////////////////////////////////////////// +/** + * Performs a billboard-type rotate to the indicated camera node, one time + * only, and leaves the object rotated. This is similar in principle to + * look_at(), although the point_eye billboard effect cannot be achieved using + * the ordinary look_at() call. + */ void NodePath:: do_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5381,8 +4647,8 @@ do_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { ::look_at(quat, rel_pos, up); set_quat(quat); - // Also slide the geometry towards the camera according to the - // offset factor. + // Also slide the geometry towards the camera according to the offset + // factor. if (offset != 0.0f) { LVector3 translate = rel_mat.get_row3(3); translate.normalize(); @@ -5391,13 +4657,11 @@ do_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::do_billboard_point_world -// Access: Published -// Description: Performs a billboard-type rotate to the indicated -// camera node, one time only, and leaves the object -// rotated. This is similar in principle to look_at(). -//////////////////////////////////////////////////////////////////// +/** + * Performs a billboard-type rotate to the indicated camera node, one time + * only, and leaves the object rotated. This is similar in principle to + * look_at(). + */ void NodePath:: do_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5412,8 +4676,8 @@ do_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { ::look_at(quat, rel_pos, up); set_quat(quat); - // Also slide the geometry towards the camera according to the - // offset factor. + // Also slide the geometry towards the camera according to the offset + // factor. if (offset != 0.0f) { LVector3 translate = rel_mat.get_row3(3); translate.normalize(); @@ -5422,14 +4686,11 @@ do_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_axis -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in two dimensions around the up axis, -// towards a specified "camera" instead of to the -// viewing camera. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in two + * dimensions around the up axis, towards a specified "camera" instead of to + * the viewing camera. + */ void NodePath:: set_billboard_axis(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5439,15 +4700,11 @@ set_billboard_axis(const NodePath &camera, PN_stdfloat offset) { node()->set_effect(billboard); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_point_eye -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in three dimensions about the origin, -// keeping its up vector oriented to the top of the -// camera, towards a specified "camera" instead of to -// the viewing camera. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in three + * dimensions about the origin, keeping its up vector oriented to the top of + * the camera, towards a specified "camera" instead of to the viewing camera. + */ void NodePath:: set_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5457,14 +4714,11 @@ set_billboard_point_eye(const NodePath &camera, PN_stdfloat offset) { node()->set_effect(billboard); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_billboard_point_world -// Access: Published -// Description: Puts a billboard transition on the node such that it -// will rotate in three dimensions about the origin, -// keeping its up vector oriented to the sky, towards a -// specified "camera" instead of to the viewing camera. -//////////////////////////////////////////////////////////////////// +/** + * Puts a billboard transition on the node such that it will rotate in three + * dimensions about the origin, keeping its up vector oriented to the sky, + * towards a specified "camera" instead of to the viewing camera. + */ void NodePath:: set_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { nassertv_always(!is_empty()); @@ -5474,74 +4728,58 @@ set_billboard_point_world(const NodePath &camera, PN_stdfloat offset) { node()->set_effect(billboard); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_billboard -// Access: Published -// Description: Removes any billboard effect from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes any billboard effect from the node. + */ void NodePath:: clear_billboard() { nassertv_always(!is_empty()); node()->clear_effect(BillboardEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_billboard -// Access: Published -// Description: Returns true if there is any billboard effect on -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is any billboard effect on the node. + */ bool NodePath:: has_billboard() const { nassertr_always(!is_empty(), false); return node()->has_effect(BillboardEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_compass -// Access: Published -// Description: Puts a compass effect on the node, so that it will -// retain a fixed rotation relative to the reference -// node (or render if the reference node is empty) -// regardless of the transforms above it. -//////////////////////////////////////////////////////////////////// +/** + * Puts a compass effect on the node, so that it will retain a fixed rotation + * relative to the reference node (or render if the reference node is empty) + * regardless of the transforms above it. + */ void NodePath:: set_compass(const NodePath &reference) { nassertv_always(!is_empty()); node()->set_effect(CompassEffect::make(reference)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_compass -// Access: Published -// Description: Removes any compass effect from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes any compass effect from the node. + */ void NodePath:: clear_compass() { nassertv_always(!is_empty()); node()->clear_effect(CompassEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_compass -// Access: Published -// Description: Returns true if there is any compass effect on -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is any compass effect on the node. + */ bool NodePath:: has_compass() const { nassertr_always(!is_empty(), false); return node()->has_effect(CompassEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_transparency -// Access: Published -// Description: Specifically sets or disables transparent rendering -// mode on this particular node. If no other nodes -// override, this will cause items with a non-1 value -// for alpha color to be rendered partially transparent. -//////////////////////////////////////////////////////////////////// +/** + * Specifically sets or disables transparent rendering mode on this particular + * node. If no other nodes override, this will cause items with a non-1 value + * for alpha color to be rendered partially transparent. + */ void NodePath:: set_transparency(TransparencyAttrib::Mode mode, int priority) { nassertv_always(!is_empty()); @@ -5549,49 +4787,38 @@ set_transparency(TransparencyAttrib::Mode mode, int priority) { node()->set_attrib(TransparencyAttrib::make(mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_transparency -// Access: Published -// Description: Completely removes any transparency adjustment that -// may have been set on this node via set_transparency(). -// The geometry at this level and below will -// subsequently be rendered either transparent or not, -// to whatever other nodes may have had -// set_transparency() on them. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any transparency adjustment that may have been set on + * this node via set_transparency(). The geometry at this level and below will + * subsequently be rendered either transparent or not, to whatever other nodes + * may have had set_transparency() on them. + */ void NodePath:: clear_transparency() { nassertv_always(!is_empty()); node()->clear_attrib(TransparencyAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_transparency -// Access: Published -// Description: Returns true if a transparent-rendering adjustment -// has been explicitly set on this particular node via -// set_transparency(). If this returns true, then -// get_transparency() may be called to determine whether -// transparency has been explicitly enabled or -// explicitly disabled for this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a transparent-rendering adjustment has been explicitly set + * on this particular node via set_transparency(). If this returns true, then + * get_transparency() may be called to determine whether transparency has been + * explicitly enabled or explicitly disabled for this node. + */ bool NodePath:: has_transparency() const { nassertr_always(!is_empty(), false); return node()->has_attrib(TransparencyAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_transparency -// Access: Published -// Description: Returns the transparent rendering that has been -// specifically set on this node via set_transparency(), or -// M_none if nontransparent rendering has been specifically -// set, or if nothing has been specifically set. See -// also has_transparency(). This does not necessarily -// imply that the geometry will or will not be rendered -// transparent, as there may be other nodes that override. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transparent rendering that has been specifically set on this + * node via set_transparency(), or M_none if nontransparent rendering has been + * specifically set, or if nothing has been specifically set. See also + * has_transparency(). This does not necessarily imply that the geometry will + * or will not be rendered transparent, as there may be other nodes that + * override. + */ TransparencyAttrib::Mode NodePath:: get_transparency() const { nassertr_always(!is_empty(), TransparencyAttrib::M_none); @@ -5605,12 +4832,10 @@ get_transparency() const { return TransparencyAttrib::M_none; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_antialias -// Access: Published -// Description: Specifies the antialiasing type that should be -// applied at this node and below. See AntialiasAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the antialiasing type that should be applied at this node and + * below. See AntialiasAttrib. + */ void NodePath:: set_antialias(unsigned short mode, int priority) { nassertv_always(!is_empty()); @@ -5618,40 +4843,31 @@ set_antialias(unsigned short mode, int priority) { node()->set_attrib(AntialiasAttrib::make(mode), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_antialias -// Access: Published -// Description: Completely removes any antialias setting that -// may have been set on this node via set_antialias(). -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any antialias setting that may have been set on this + * node via set_antialias(). + */ void NodePath:: clear_antialias() { nassertv_always(!is_empty()); node()->clear_attrib(AntialiasAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_antialias -// Access: Published -// Description: Returns true if an antialias setting has been -// explicitly mode on this particular node via -// set_antialias(). If this returns true, then -// get_antialias() may be called to determine what the -// setting was. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an antialias setting has been explicitly mode on this + * particular node via set_antialias(). If this returns true, then + * get_antialias() may be called to determine what the setting was. + */ bool NodePath:: has_antialias() const { nassertr_always(!is_empty(), false); return node()->has_attrib(AntialiasAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_antialias -// Access: Published -// Description: Returns the antialias setting that has been -// specifically set on this node via set_antialias(), or -// M_none if no setting has been made. -//////////////////////////////////////////////////////////////////// +/** + * Returns the antialias setting that has been specifically set on this node + * via set_antialias(), or M_none if no setting has been made. + */ unsigned short NodePath:: get_antialias() const { nassertr_always(!is_empty(), AntialiasAttrib::M_none); @@ -5665,40 +4881,31 @@ get_antialias() const { return AntialiasAttrib::M_none; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::has_audio_volume -// Access: Published -// Description: Returns true if an audio volume has been applied -// to the referenced node, false otherwise. It is still -// possible that volume at this node might have been -// scaled by an ancestor node. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an audio volume has been applied to the referenced node, + * false otherwise. It is still possible that volume at this node might have + * been scaled by an ancestor node. + */ bool NodePath:: has_audio_volume() const { nassertr_always(!is_empty(), false); return node()->has_attrib(AudioVolumeAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::clear_audio_volume -// Access: Published -// Description: Completely removes any audio volume from the -// referenced node. This is preferable to simply -// setting the audio volume to identity, as it also -// removes the overhead associated with having an audio -// volume at all. -//////////////////////////////////////////////////////////////////// +/** + * Completely removes any audio volume from the referenced node. This is + * preferable to simply setting the audio volume to identity, as it also + * removes the overhead associated with having an audio volume at all. + */ void NodePath:: clear_audio_volume() { nassertv_always(!is_empty()); node()->clear_attrib(AudioVolumeAttrib::get_class_slot()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_audio_volume -// Access: Published -// Description: Sets the audio volume component of the transform -//////////////////////////////////////////////////////////////////// +/** + * Sets the audio volume component of the transform + */ void NodePath:: set_audio_volume(PN_stdfloat volume, int priority) { nassertv_always(!is_empty()); @@ -5710,8 +4917,7 @@ set_audio_volume(PN_stdfloat volume, int priority) { node()->get_state()->get_override(AudioVolumeAttrib::get_class_slot())); CPT(AudioVolumeAttrib) ava = DCAST(AudioVolumeAttrib, attrib); - // Modify the existing AudioVolumeAttrib to add the indicated - // volume. + // Modify the existing AudioVolumeAttrib to add the indicated volume. node()->set_attrib(ava->set_volume(volume), priority); } else { @@ -5720,34 +4926,26 @@ set_audio_volume(PN_stdfloat volume, int priority) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::set_audio_volume_off -// Access: Published -// Description: Disables any audio volume attribute inherited from -// above. This is not the same thing as -// clear_audio_volume(), which undoes any previous -// set_audio_volume() operation on this node; rather, -// this actively disables any set_audio_volume() that -// might be inherited from a parent node. -// -// It is legal to specify a new volume on the same -// node with a subsequent call to set_audio_volume(); -// this new scale will apply to lower nodes. -//////////////////////////////////////////////////////////////////// +/** + * Disables any audio volume attribute inherited from above. This is not the + * same thing as clear_audio_volume(), which undoes any previous + * set_audio_volume() operation on this node; rather, this actively disables + * any set_audio_volume() that might be inherited from a parent node. + * + * It is legal to specify a new volume on the same node with a subsequent call + * to set_audio_volume(); this new scale will apply to lower nodes. + */ void NodePath:: set_audio_volume_off(int priority) { nassertv_always(!is_empty()); node()->set_attrib(AudioVolumeAttrib::make_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_audio_volume -// Access: Published -// Description: Returns the complete audio volume that has been -// applied to this node via a previous call to -// set_audio_volume(), or 1. (identity) if no volume has -// been applied to this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete audio volume that has been applied to this node via a + * previous call to set_audio_volume(), or 1. (identity) if no volume has been + * applied to this particular node. + */ PN_stdfloat NodePath:: get_audio_volume() const { const RenderAttrib *attrib = @@ -5760,12 +4958,10 @@ get_audio_volume() const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_net_audio_volume -// Access: Published -// Description: Returns the complete audio volume for this node -// taking highers nodes in the graph into account. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete audio volume for this node taking highers nodes in the + * graph into account. + */ PN_stdfloat NodePath:: get_net_audio_volume() const { CPT(RenderState) net_state = get_net_state(); @@ -5780,14 +4976,11 @@ get_net_audio_volume() const { return 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_hidden_ancestor -// Access: Published -// Description: Returns the NodePath at or above the referenced node -// that is hidden to the indicated camera(s), or an -// empty NodePath if no ancestor of the referenced node -// is hidden (and the node should be visible). -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath at or above the referenced node that is hidden to the + * indicated camera(s), or an empty NodePath if no ancestor of the referenced + * node is hidden (and the node should be visible). + */ NodePath NodePath:: get_hidden_ancestor(DrawMask camera_mask, Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -5808,21 +5001,16 @@ get_hidden_ancestor(DrawMask camera_mask, Thread *current_thread) const { return not_found(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::stash -// Access: Published -// Description: Removes the referenced node (and the entire subgraph -// below this node) from the scene graph in any normal -// sense. The node will no longer be visible and is not -// tested for collisions; furthermore, no normal scene -// graph traversal will visit the node. The node's -// bounding volume no longer contributes to its parent's -// bounding volume. -// -// A stashed node cannot be located by a normal find() -// operation (although a special find string can still -// retrieve it). -//////////////////////////////////////////////////////////////////// +/** + * Removes the referenced node (and the entire subgraph below this node) from + * the scene graph in any normal sense. The node will no longer be visible + * and is not tested for collisions; furthermore, no normal scene graph + * traversal will visit the node. The node's bounding volume no longer + * contributes to its parent's bounding volume. + * + * A stashed node cannot be located by a normal find() operation (although a + * special find string can still retrieve it). + */ void NodePath:: stash(int sort, Thread *current_thread) { nassertv_always(!is_singleton() && !is_empty()); @@ -5835,14 +5023,11 @@ stash(int sort, Thread *current_thread) { nassertv(reparented); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::unstash -// Access: Published -// Description: Undoes the effect of a previous stash() on this -// node: makes the referenced node (and the entire -// subgraph below this node) once again part of the -// scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous stash() on this node: makes the referenced + * node (and the entire subgraph below this node) once again part of the scene + * graph. + */ void NodePath:: unstash(int sort, Thread *current_thread) { nassertv_always(!is_singleton() && !is_empty()); @@ -5855,11 +5040,9 @@ unstash(int sort, Thread *current_thread) { nassertv(reparented); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::unstash_all -// Access: Published -// Description: Unstashes this node and all stashed child nodes. -//////////////////////////////////////////////////////////////////// +/** + * Unstashes this node and all stashed child nodes. + */ void NodePath:: unstash_all(Thread *current_thread) { NodePathCollection stashed_descendents = find_all_matches("**/@@*"); @@ -5867,14 +5050,11 @@ unstash_all(Thread *current_thread) { unstash(0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_stashed_ancestor -// Access: Published -// Description: Returns the NodePath at or above the referenced node -// that is stashed, or an empty NodePath if no ancestor -// of the referenced node is stashed (and the node should -// be visible). -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath at or above the referenced node that is stashed, or an + * empty NodePath if no ancestor of the referenced node is stashed (and the + * node should be visible). + */ NodePath NodePath:: get_stashed_ancestor(Thread *current_thread) const { NodePathComponent *comp = _head; @@ -5900,12 +5080,10 @@ get_stashed_ancestor(Thread *current_thread) const { return not_found(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::verify_complete -// Access: Published -// Description: Returns true if all of the nodes described in the -// NodePath are connected, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the nodes described in the NodePath are connected, + * or false otherwise. + */ bool NodePath:: verify_complete(Thread *current_thread) const { if (is_empty()) { @@ -5914,10 +5092,10 @@ verify_complete(Thread *current_thread) const { #ifdef HAVE_THREADS if (Thread::is_true_threads()) { - // In a threaded environment, we can't reliably test this, since a - // sub-thread may be mucking with the NodePath's ancestry as we - // try to validate it. NodePaths are inherently not thread-safe, - // but generally that's not an issue. + // In a threaded environment, we can't reliably test this, since a sub- + // thread may be mucking with the NodePath's ancestry as we try to + // validate it. NodePaths are inherently not thread-safe, but generally + // that's not an issue. return true; } #endif // HAVE_THREADS @@ -5962,20 +5140,15 @@ verify_complete(Thread *current_thread) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::premunge_scene -// Access: Published -// Description: Walks through the scene graph beginning at the bottom -// node, and internally adjusts any GeomVertexFormats -// for optimal rendering on the indicated GSG. If this -// step is not done prior to rendering, the formats will -// be optimized at render time instead, for a small -// cost. -// -// It is not normally necessary to do this on a model -// loaded directly from disk, since the loader will do -// this by default. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the scene graph beginning at the bottom node, and internally + * adjusts any GeomVertexFormats for optimal rendering on the indicated GSG. + * If this step is not done prior to rendering, the formats will be optimized + * at render time instead, for a small cost. + * + * It is not normally necessary to do this on a model loaded directly from + * disk, since the loader will do this by default. + */ void NodePath:: premunge_scene(GraphicsStateGuardianBase *gsg) { nassertv_always(!is_empty()); @@ -5989,21 +5162,16 @@ premunge_scene(GraphicsStateGuardianBase *gsg) { gr.premunge(node(), state); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::prepare_scene -// Access: Published -// Description: Walks through the scene graph beginning at the bottom -// node, and does whatever initialization is required to -// render the scene properly with the indicated GSG. It -// is not strictly necessary to call this, since the GSG -// will initialize itself when the scene is rendered, -// but this may take some of the overhead away from that -// process. -// -// In particular, this will ensure that textures and -// vertex buffers within the scene are loaded into -// graphics memory. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the scene graph beginning at the bottom node, and does + * whatever initialization is required to render the scene properly with the + * indicated GSG. It is not strictly necessary to call this, since the GSG + * will initialize itself when the scene is rendered, but this may take some + * of the overhead away from that process. + * + * In particular, this will ensure that textures and vertex buffers within the + * scene are loaded into graphics memory. + */ void NodePath:: prepare_scene(GraphicsStateGuardianBase *gsg) { nassertv_always(!is_empty()); @@ -6011,117 +5179,91 @@ prepare_scene(GraphicsStateGuardianBase *gsg) { node()->prepare_scene(gsg, get_net_state()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show_bounds -// Access: Published -// Description: Causes the bounding volume of the bottom node and all -// of its descendants (that is, the bounding volume -// associated with the the bottom arc) to be rendered, -// if possible. The rendering method is less than -// optimal; this is intended primarily for debugging. -//////////////////////////////////////////////////////////////////// +/** + * Causes the bounding volume of the bottom node and all of its descendants + * (that is, the bounding volume associated with the the bottom arc) to be + * rendered, if possible. The rendering method is less than optimal; this is + * intended primarily for debugging. + */ void NodePath:: show_bounds() { nassertv_always(!is_empty()); node()->set_effect(ShowBoundsEffect::make(false)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::show_tight_bounds -// Access: Published -// Description: Similar to show_bounds(), this draws a bounding box -// representing the "tight" bounds of this node and all -// of its descendants. The bounding box is recomputed -// every frame by reexamining all of the vertices; this -// is far from efficient, but this is intended for -// debugging. -//////////////////////////////////////////////////////////////////// +/** + * Similar to show_bounds(), this draws a bounding box representing the + * "tight" bounds of this node and all of its descendants. The bounding box + * is recomputed every frame by reexamining all of the vertices; this is far + * from efficient, but this is intended for debugging. + */ void NodePath:: show_tight_bounds() { nassertv_always(!is_empty()); node()->set_effect(ShowBoundsEffect::make(true)); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::hide_bounds -// Access: Published -// Description: Stops the rendering of the bounding volume begun with -// show_bounds(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the rendering of the bounding volume begun with show_bounds(). + */ void NodePath:: hide_bounds() { nassertv_always(!is_empty()); node()->clear_effect(ShowBoundsEffect::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::get_bounds -// Access: Published -// Description: Returns a newly-allocated bounding volume containing -// the bottom node and all of its descendants. This is -// the bounding volume on the bottom arc, converted to -// the local coordinate space of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated bounding volume containing the bottom node and + * all of its descendants. This is the bounding volume on the bottom arc, + * converted to the local coordinate space of the node. + */ PT(BoundingVolume) NodePath:: get_bounds(Thread *current_thread) const { nassertr_always(!is_empty(), new BoundingSphere); return node()->get_bounds(current_thread)->make_copy(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::force_recompute_bounds -// Access: Published -// Description: Forces the recomputing of all the bounding volumes at -// every node in the subgraph beginning at this node and -// below. -// -// This should not normally need to be called, since the -// bounding volumes are supposed to be recomputed -// automatically when necessary. It may be useful when -// debugging, to verify that the bounding volumes have -// not become inadvertently stale; it may also be useful -// to force animated characters to update their bounding -// volumes (which does not presently happen -// automatically). -//////////////////////////////////////////////////////////////////// +/** + * Forces the recomputing of all the bounding volumes at every node in the + * subgraph beginning at this node and below. + * + * This should not normally need to be called, since the bounding volumes are + * supposed to be recomputed automatically when necessary. It may be useful + * when debugging, to verify that the bounding volumes have not become + * inadvertently stale; it may also be useful to force animated characters to + * update their bounding volumes (which does not presently happen + * automatically). + */ void NodePath:: force_recompute_bounds() { nassertv_always(!is_empty()); r_force_recompute_bounds(node()); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::write_bounds -// Access: Published -// Description: Writes a description of the bounding volume -// containing the bottom node and all of its descendants -// to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a description of the bounding volume containing the bottom node and + * all of its descendants to the indicated output stream. + */ void NodePath:: write_bounds(ostream &out) const { get_bounds()->write(out); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::calc_tight_bounds -// Access: Published -// Description: Calculates the minimum and maximum vertices of all -// Geoms at this NodePath's bottom node and below. This -// is a tight bounding box; it will generally be tighter -// than the bounding volume returned by get_bounds() -// (but it is more expensive to compute). -// -// The bounding box is computed relative to the parent -// node's coordinate system by default. You can -// optionally specify a different NodePath to compute -// the bounds relative to. Note that the box is always -// axis-aligned against the given NodePath's coordinate -// system, so you might get a differently sized box -// depending on which node you pass. -// -// The return value is true if any points are within the -// bounding volume, or false if none are. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the minimum and maximum vertices of all Geoms at this NodePath's + * bottom node and below. This is a tight bounding box; it will generally be + * tighter than the bounding volume returned by get_bounds() (but it is more + * expensive to compute). + * + * The bounding box is computed relative to the parent node's coordinate + * system by default. You can optionally specify a different NodePath to + * compute the bounds relative to. Note that the box is always axis-aligned + * against the given NodePath's coordinate system, so you might get a + * differently sized box depending on which node you pass. + * + * The return value is true if any points are within the bounding volume, or + * false if none are. + */ bool NodePath:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, const NodePath &other, Thread *current_thread) const { @@ -6141,20 +5283,17 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, return found_any; } +/** + * Analyzes the geometry below this node and reports the number of vertices, + * triangles, etc. This is the same information reported by the bam-info + * program. + */ /* - NB: Had to remove this function to avoid circular dependency when moving SceneGraphAnalyzer into pgraphnodes, attempting to reduce size of pgraph. This function is now defined as a Python extension function instead. -//////////////////////////////////////////////////////////////////// -// Function: NodePath::analyze -// Access: Published -// Description: Analyzes the geometry below this node and reports the -// number of vertices, triangles, etc. This is the same -// information reported by the bam-info program. -//////////////////////////////////////////////////////////////////// void NodePath:: analyze() const { nassertv_always(!is_empty()); @@ -6183,30 +5322,24 @@ analyze() const { } */ -//////////////////////////////////////////////////////////////////// -// Function: NodePath::flatten_light -// Access: Published -// Description: Lightly flattens out the hierarchy below this node by -// applying transforms, colors, and texture matrices -// from the nodes onto the vertices, but does not remove -// any nodes. -// -// This can result in improved rendering performance -// because there will be fewer transforms in the -// resulting scene graph, but the number of nodes will -// remain the same. -// -// In particular, any NodePaths that reference nodes -// within this hierarchy will not be damaged. However, -// since this operation will remove transforms from the -// scene graph, it may be dangerous to apply to nodes -// where you expect to dynamically modify the transform, -// or where you expect the geometry to remain in a -// particular local coordinate system. -// -// The return value is always 0, since flatten_light -// does not remove any nodes. -//////////////////////////////////////////////////////////////////// +/** + * Lightly flattens out the hierarchy below this node by applying transforms, + * colors, and texture matrices from the nodes onto the vertices, but does not + * remove any nodes. + * + * This can result in improved rendering performance because there will be + * fewer transforms in the resulting scene graph, but the number of nodes will + * remain the same. + * + * In particular, any NodePaths that reference nodes within this hierarchy + * will not be damaged. However, since this operation will remove transforms + * from the scene graph, it may be dangerous to apply to nodes where you + * expect to dynamically modify the transform, or where you expect the + * geometry to remain in a particular local coordinate system. + * + * The return value is always 0, since flatten_light does not remove any + * nodes. + */ int NodePath:: flatten_light() { nassertr_always(!is_empty(), 0); @@ -6216,22 +5349,17 @@ flatten_light() { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::flatten_medium -// Access: Published -// Description: A more thorough flattening than flatten_light(), this -// first applies all the transforms, colors, and texture -// matrices from the nodes onto the vertices, and then -// removes unneeded grouping nodes--nodes that have -// exactly one child, for instance, but have no special -// properties in themselves. -// -// This results in improved performance over -// flatten_light() because the number of nodes in the -// scene graph is reduced. -// -// The return value is the number of nodes removed. -//////////////////////////////////////////////////////////////////// +/** + * A more thorough flattening than flatten_light(), this first applies all the + * transforms, colors, and texture matrices from the nodes onto the vertices, + * and then removes unneeded grouping nodes--nodes that have exactly one + * child, for instance, but have no special properties in themselves. + * + * This results in improved performance over flatten_light() because the + * number of nodes in the scene graph is reduced. + * + * The return value is the number of nodes removed. + */ int NodePath:: flatten_medium() { nassertr_always(!is_empty(), 0); @@ -6248,23 +5376,18 @@ flatten_medium() { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::flatten_strong -// Access: Published -// Description: The strongest possible flattening. This first -// applies all of the transforms to the vertices, as in -// flatten_medium(), but then it will combine sibling -// nodes together when possible, in addition to removing -// unnecessary parent-child nodes. This can result in -// substantially fewer nodes, but any nicely-grouped -// hierachical bounding volumes may be lost. -// -// It is generally a good idea to apply this kind of -// flattening only to nodes that will be culled largely -// as a single unit, like a car. Applying this to an -// entire scene may result in overall poorer performance -// because of less-effective culling. -//////////////////////////////////////////////////////////////////// +/** + * The strongest possible flattening. This first applies all of the + * transforms to the vertices, as in flatten_medium(), but then it will + * combine sibling nodes together when possible, in addition to removing + * unnecessary parent-child nodes. This can result in substantially fewer + * nodes, but any nicely-grouped hierachical bounding volumes may be lost. + * + * It is generally a good idea to apply this kind of flattening only to nodes + * that will be culled largely as a single unit, like a car. Applying this to + * an entire scene may result in overall poorer performance because of less- + * effective culling. + */ int NodePath:: flatten_strong() { nassertr_always(!is_empty(), 0); @@ -6281,26 +5404,20 @@ flatten_strong() { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::apply_texture_colors -// Access: Published -// Description: Removes textures from Geoms at this node and below by -// applying the texture colors to the vertices. This is -// primarily useful to simplify a low-LOD model. The -// texture colors are replaced by flat colors that -// approximate the original textures. -// -// Only the bottommost texture on each Geom is used (if -// there is more than one), and it is applied as if it -// were M_modulate, and WM_repeat, regardless of its -// actual settings. If the texture has a -// simple_ram_image, this may be used if the main image -// isn't resident. -// -// After this call, there will be no texturing specified -// at this level and below. Of course, there might -// still be texturing inherited from above. -//////////////////////////////////////////////////////////////////// +/** + * Removes textures from Geoms at this node and below by applying the texture + * colors to the vertices. This is primarily useful to simplify a low-LOD + * model. The texture colors are replaced by flat colors that approximate the + * original textures. + * + * Only the bottommost texture on each Geom is used (if there is more than + * one), and it is applied as if it were M_modulate, and WM_repeat, regardless + * of its actual settings. If the texture has a simple_ram_image, this may be + * used if the main image isn't resident. + * + * After this call, there will be no texturing specified at this level and + * below. Of course, there might still be texturing inherited from above. + */ void NodePath:: apply_texture_colors() { nassertv_always(!is_empty()); @@ -6308,14 +5425,11 @@ apply_texture_colors() { gr.apply_attribs(node(), SceneGraphReducer::TT_apply_texture_color | SceneGraphReducer::TT_tex_matrix | SceneGraphReducer::TT_other); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_net_tag -// Access: Published -// Description: Returns the lowest ancestor of this node that -// contains a tag definition with the indicated key, if -// any, or an empty NodePath if no ancestor of this node -// contains this tag definition. See set_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the lowest ancestor of this node that contains a tag definition + * with the indicated key, if any, or an empty NodePath if no ancestor of this + * node contains this tag definition. See set_tag(). + */ NodePath NodePath:: find_net_tag(const string &key) const { if (is_empty()) { @@ -6327,15 +5441,11 @@ find_net_tag(const string &key) const { return get_parent().find_net_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::write_bam_file -// Access: Published -// Description: Writes the contents of this node and below out to a -// bam file with the indicated filename. This file may -// then be read in again, as is, at some later point. -// Returns true if successful, false on some kind of -// error. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this node and below out to a bam file with the + * indicated filename. This file may then be read in again, as is, at some + * later point. Returns true if successful, false on some kind of error. + */ bool NodePath:: write_bam_file(const Filename &filename) const { nassertr_always(!is_empty(), false); @@ -6345,8 +5455,8 @@ write_bam_file(const Filename &filename) const { bool okflag = false; if (bam_file.open_write(filename)) { - // Tell the BamWriter which node is the root node, for making - // NodePaths relative to when writing them out to the file. + // Tell the BamWriter which node is the root node, for making NodePaths + // relative to when writing them out to the file. bam_file.get_writer()->set_root_node(node()); if (bam_file.write_object(node())) { @@ -6357,12 +5467,9 @@ write_bam_file(const Filename &filename) const { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::write_bam_stream -// Access: Published -// Description: Writes the contents of this node and below out to the -// indicated stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this node and below out to the indicated stream. + */ bool NodePath:: write_bam_stream(ostream &out) const { nassertr_always(!is_empty(), false); @@ -6372,8 +5479,8 @@ write_bam_stream(ostream &out) const { bool okflag = false; if (bam_file.open_write(out)) { - // Tell the BamWriter which node is the root node, for making - // NodePaths relative to when writing them out to the file. + // Tell the BamWriter which node is the root node, for making NodePaths + // relative to when writing them out to the file. bam_file.get_writer()->set_root_node(node()); if (bam_file.write_object(node())) { @@ -6384,34 +5491,27 @@ write_bam_stream(ostream &out) const { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::encode_to_bam_stream -// Access: Published -// Description: Converts the NodePath object into a single -// stream of data using a BamWriter, and stores that -// data in the indicated string. Returns true on -// success, false on failure. -// -// If the BamWriter is NULL, this behaves the same way -// as NodePath::write_bam_stream() and -// PandaNode::encode_to_bam_stream(), in the sense that -// it only writes this node and all nodes below it. -// -// However, if the BamWriter is not NULL, it behaves -// very differently. In this case, it encodes the -// *entire graph* of all nodes connected to the -// NodePath, including all parent nodes and siblings. -// This is necessary for correct streaming of related -// NodePaths and restoration of instances, etc., but it -// does mean you must detach() a node before writing it -// if you want to limit the nodes that get written. -// -// This method is used by __reduce__ to handle streaming -// of NodePaths to a pickle file. The BamWriter case is -// used by the direct.stdpy.pickle module, while the -// saner, non-BamWriter case is used when the standard -// pickle module calls this function. -//////////////////////////////////////////////////////////////////// +/** + * Converts the NodePath object into a single stream of data using a + * BamWriter, and stores that data in the indicated string. Returns true on + * success, false on failure. + * + * If the BamWriter is NULL, this behaves the same way as + * NodePath::write_bam_stream() and PandaNode::encode_to_bam_stream(), in the + * sense that it only writes this node and all nodes below it. + * + * However, if the BamWriter is not NULL, it behaves very differently. In + * this case, it encodes the *entire graph* of all nodes connected to the + * NodePath, including all parent nodes and siblings. This is necessary for + * correct streaming of related NodePaths and restoration of instances, etc., + * but it does mean you must detach() a node before writing it if you want to + * limit the nodes that get written. + * + * This method is used by __reduce__ to handle streaming of NodePaths to a + * pickle file. The BamWriter case is used by the direct.stdpy.pickle module, + * while the saner, non-BamWriter case is used when the standard pickle module + * calls this function. + */ bool NodePath:: encode_to_bam_stream(string &data, BamWriter *writer) const { data.clear(); @@ -6442,12 +5542,12 @@ encode_to_bam_stream(string &data, BamWriter *writer) const { num_nodes = 1; } - // Tell the BamWriter which node is the root node, for making - // NodePaths relative to when writing them out to the file. + // Tell the BamWriter which node is the root node, for making NodePaths + // relative to when writing them out to the file. writer->set_root_node(node()); - // Write an initial Datagram to represent the error type and - // number of nodes. + // Write an initial Datagram to represent the error type and number of + // nodes. Datagram dg; dg.add_uint8(_error_type); dg.add_int32(num_nodes); @@ -6472,14 +5572,10 @@ encode_to_bam_stream(string &data, BamWriter *writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::decode_from_bam_stream -// Access: Published, Static -// Description: Reads the string created by a previous call to -// encode_to_bam_stream(), and extracts and -// returns the NodePath on that string. Returns NULL on -// error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the string created by a previous call to encode_to_bam_stream(), and + * extracts and returns the NodePath on that string. Returns NULL on error. + */ NodePath NodePath:: decode_from_bam_stream(const string &data, BamReader *reader) { NodePath result; @@ -6548,18 +5644,14 @@ decode_from_bam_stream(const string &data, BamReader *reader) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_common_ancestor -// Access: Private, Static -// Description: Walks up from both NodePaths to find the first node -// that both have in common, if any. Fills a_count and -// b_count with the number of nodes below the common -// node in each path. -// -// The return value is the NodePathComponent of the node -// they have in common, or NULL if they have nothing in -// common. -//////////////////////////////////////////////////////////////////// +/** + * Walks up from both NodePaths to find the first node that both have in + * common, if any. Fills a_count and b_count with the number of nodes below + * the common node in each path. + * + * The return value is the NodePathComponent of the node they have in common, + * or NULL if they have nothing in common. + */ NodePathComponent *NodePath:: find_common_ancestor(const NodePath &a, const NodePath &b, int &a_count, int &b_count, Thread *current_thread) { @@ -6597,12 +5689,10 @@ find_common_ancestor(const NodePath &a, const NodePath &b, return ac; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_net_state -// Access: Private -// Description: Recursively determines the net state changes to the -// indicated component node from the root of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net state changes to the indicated component + * node from the root of the graph. + */ CPT(RenderState) NodePath:: r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { if (comp == (NodePathComponent *)NULL) { @@ -6614,14 +5704,11 @@ r_get_net_state(NodePathComponent *comp, Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_partial_state -// Access: Private -// Description: Recursively determines the net state changes to the -// indicated component node from the nth node above it. -// If n exceeds the length of the path, this returns the -// net transform from the root of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net state changes to the indicated component + * node from the nth node above it. If n exceeds the length of the path, this + * returns the net transform from the root of the graph. + */ CPT(RenderState) NodePath:: r_get_partial_state(NodePathComponent *comp, int n, Thread *current_thread) const { @@ -6634,12 +5721,10 @@ r_get_partial_state(NodePathComponent *comp, int n, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_net_transform -// Access: Private -// Description: Recursively determines the net transform to the -// indicated component node from the root of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net transform to the indicated component node + * from the root of the graph. + */ CPT(TransformState) NodePath:: r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { if (comp == (NodePathComponent *)NULL) { @@ -6659,18 +5744,14 @@ r_get_net_transform(NodePathComponent *comp, Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_partial_transform -// Access: Private -// Description: Recursively determines the net transform to the -// indicated component node from the nth node above it. -// If n exceeds the length of the path, this returns the -// net transform from the root of the graph. -// -// If any node in the path had a net_transform effect -// applied, returns NULL--in this case the partial -// transform cannot be easily determined. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net transform to the indicated component node + * from the nth node above it. If n exceeds the length of the path, this + * returns the net transform from the root of the graph. + * + * If any node in the path had a net_transform effect applied, returns NULL-- + * in this case the partial transform cannot be easily determined. + */ CPT(TransformState) NodePath:: r_get_partial_transform(NodePathComponent *comp, int n, Thread *current_thread) const { @@ -6690,13 +5771,10 @@ r_get_partial_transform(NodePathComponent *comp, int n, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_net_prev_transform -// Access: Private -// Description: Recursively determines the net "previous" transform -// to the indicated component node from the root of the -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net "previous" transform to the indicated + * component node from the root of the graph. + */ CPT(TransformState) NodePath:: r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const { if (comp == (NodePathComponent *)NULL) { @@ -6708,15 +5786,11 @@ r_get_net_prev_transform(NodePathComponent *comp, Thread *current_thread) const } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_get_partial_prev_transform -// Access: Private -// Description: Recursively determines the net "previous" transform -// to the indicated component node from the nth node -// above it. If n exceeds the length of the path, this -// returns the net previous transform from the root of -// the graph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the net "previous" transform to the indicated + * component node from the nth node above it. If n exceeds the length of the + * path, this returns the net previous transform from the root of the graph. + */ CPT(TransformState) NodePath:: r_get_partial_prev_transform(NodePathComponent *comp, int n, Thread *current_thread) const { if (n == 0 || comp == (NodePathComponent *)NULL) { @@ -6728,15 +5802,11 @@ r_get_partial_prev_transform(NodePathComponent *comp, int n, Thread *current_thr } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_matches -// Access: Private -// Description: Finds up to max_matches matches against the given -// path string from this node and deeper. The -// max_matches count indicates the maximum number of -// matches to return, or -1 not to limit the number -// returned. -//////////////////////////////////////////////////////////////////// +/** + * Finds up to max_matches matches against the given path string from this + * node and deeper. The max_matches count indicates the maximum number of + * matches to return, or -1 not to limit the number returned. + */ void NodePath:: find_matches(NodePathCollection &result, const string &path, int max_matches) const { @@ -6752,15 +5822,11 @@ find_matches(NodePathCollection &result, const string &path, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_matches -// Access: Private -// Description: Finds up to max_matches matches against the given -// approx_path from this node and deeper. The -// max_matches count indicates the maximum number of -// matches to return, or -1 not to limit the number -// returned. -//////////////////////////////////////////////////////////////////// +/** + * Finds up to max_matches matches against the given approx_path from this + * node and deeper. The max_matches count indicates the maximum number of + * matches to return, or -1 not to limit the number returned. + */ void NodePath:: find_matches(NodePathCollection &result, FindApproxPath &approx_path, int max_matches) const { @@ -6778,13 +5844,10 @@ find_matches(NodePathCollection &result, FindApproxPath &approx_path, find_matches(result, level, max_matches); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::find_matches -// Access: Private -// Description: The fundamental implementation of find_matches(), -// given a starting level (a linked list of -// FindApproxLevelEntry objects). -//////////////////////////////////////////////////////////////////// +/** + * The fundamental implementation of find_matches(), given a starting level (a + * linked list of FindApproxLevelEntry objects). + */ void NodePath:: find_matches(NodePathCollection &result, FindApproxLevelEntry *level, int max_matches) const { @@ -6810,8 +5873,8 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, FindApproxLevelEntry *entry = level; while (entry != (FindApproxLevelEntry *)NULL) { if (entry->consider_node(result, next_level, max_matches, 0)) { - // If we found the requisite number of matches, we can stop. - // Delete all remaining entries and return immediately. + // If we found the requisite number of matches, we can stop. Delete + // all remaining entries and return immediately. while (entry != (FindApproxLevelEntry *)NULL) { FindApproxLevelEntry *next = entry->_next; @@ -6831,10 +5894,10 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, return; } - // Move the entry to the delete chain so we can delete it before - // we return from this method. (We can't delete it immediately, - // because there might be WorkingNodePaths in the next_level - // that reference the WorkingNodePath object within the entry.) + // Move the entry to the delete chain so we can delete it before we + // return from this method. (We can't delete it immediately, because + // there might be WorkingNodePaths in the next_level that reference the + // WorkingNodePath object within the entry.) FindApproxLevelEntry *next = entry->_next; entry->_next = deleted_entries; deleted_entries = entry; @@ -6842,8 +5905,8 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, entry = next; } - // Make sure the remaining entries from this level are added to - // the delete chain. + // Make sure the remaining entries from this level are added to the delete + // chain. while (entry != (FindApproxLevelEntry *)NULL) { FindApproxLevelEntry *next = entry->_next; entry->_next = deleted_entries; @@ -6863,13 +5926,10 @@ find_matches(NodePathCollection &result, FindApproxLevelEntry *level, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_clear_model_nodes -// Access: Private -// Description: The recursive implementation of -// clear_model_nodes(). This walks through the -// subgraph defined by the indicated node and below. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of clear_model_nodes(). This walks through + * the subgraph defined by the indicated node and below. + */ int NodePath:: r_clear_model_nodes(PandaNode *node) { int count = 0; @@ -6890,13 +5950,10 @@ r_clear_model_nodes(PandaNode *node) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_adjust_all_priorities -// Access: Private -// Description: The recursive implementation of -// adjust_all_priorities(). This walks through the -// subgraph defined by the indicated node and below. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of adjust_all_priorities(). This walks + * through the subgraph defined by the indicated node and below. + */ void NodePath:: r_adjust_all_priorities(PandaNode *node, int adjustment) { node->set_state(node->get_state()->adjust_all_priorities(adjustment)); @@ -6917,11 +5974,9 @@ r_adjust_all_priorities(PandaNode *node, int adjustment) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_force_recompute_bounds -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_force_recompute_bounds(PandaNode *node) { if (node->is_geom_node()) { @@ -6945,12 +6000,10 @@ r_force_recompute_bounds(PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_set_collide_mask -// Access: Private -// Description: Recursively applies the indicated collide mask to the -// nodes at and below this node. -//////////////////////////////////////////////////////////////////// +/** + * Recursively applies the indicated collide mask to the nodes at and below + * this node. + */ void NodePath:: r_set_collide_mask(PandaNode *node, CollideMask and_mask, CollideMask or_mask, @@ -6968,11 +6021,9 @@ r_set_collide_mask(PandaNode *node, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_has_vertex_column -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool NodePath:: r_has_vertex_column(PandaNode *node, const InternalName *name) const { if (node->is_geom_node()) { @@ -7002,11 +6053,9 @@ r_has_vertex_column(PandaNode *node, const InternalName *name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_all_vertex_columns -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_find_all_vertex_columns(PandaNode *node, NodePath::InternalNames &vertex_columns) const { @@ -7039,11 +6088,9 @@ r_find_all_vertex_columns(PandaNode *node, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture *NodePath:: r_find_texture(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { @@ -7089,11 +6136,9 @@ r_find_texture(PandaNode *node, const RenderState *state, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_all_textures -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_find_all_textures(PandaNode *node, const RenderState *state, NodePath::Textures &textures) const { @@ -7131,11 +6176,9 @@ r_find_all_textures(PandaNode *node, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture * NodePath:: r_find_texture(PandaNode *node, TextureStage *stage) const { // Look for a TextureAttrib on the node. @@ -7183,11 +6226,9 @@ r_find_texture(PandaNode *node, TextureStage *stage) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_all_textures -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_find_all_textures(PandaNode *node, TextureStage *stage, NodePath::Textures &textures) const { @@ -7230,11 +6271,9 @@ r_find_all_textures(PandaNode *node, TextureStage *stage, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_texture_stage -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureStage * NodePath:: r_find_texture_stage(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { @@ -7280,11 +6319,9 @@ r_find_texture_stage(PandaNode *node, const RenderState *state, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_all_texture_stages -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_find_all_texture_stages(PandaNode *node, const RenderState *state, NodePath::TextureStages &texture_stages) const { @@ -7322,11 +6359,9 @@ r_find_all_texture_stages(PandaNode *node, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_unify_texture_stages -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_unify_texture_stages(PandaNode *node, TextureStage *stage) { // Look for a TextureAttrib on the state. @@ -7371,11 +6406,9 @@ r_unify_texture_stages(PandaNode *node, TextureStage *stage) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_material -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Material *NodePath:: r_find_material(PandaNode *node, const RenderState *state, const GlobPattern &glob) const { @@ -7421,11 +6454,9 @@ r_find_material(PandaNode *node, const RenderState *state, return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::r_find_all_materials -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePath:: r_find_all_materials(PandaNode *node, const RenderState *state, NodePath::Materials &materials) const { @@ -7463,12 +6494,10 @@ r_find_all_materials(PandaNode *node, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void NodePath:: write_datagram(BamWriter *manager, Datagram &dg) const { PandaNode *root = DCAST(PandaNode, manager->get_root_node()); @@ -7511,13 +6540,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { manager->write_pointer(dg, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::complete_pointers -// Access: Public -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int NodePath:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = 0; @@ -7531,9 +6557,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); - // Take an arbitrary path to the root of the NodePath. This probably - // won't be ambiguous, as this is usually the root of the model or scene - // we are currently loading. + // Take an arbitrary path to the root of the NodePath. This probably won't + // be ambiguous, as this is usually the root of the model or scene we are + // currently loading. PT(NodePathComponent) comp = node->get_generic_component(false, pipeline_stage, current_thread); nassertd(!comp.is_null()) { while (p_list[pi++]) {} @@ -7546,9 +6572,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { LightReMutexHolder holder(node->_paths_lock); - // First, walk through the list of NodePathComponents we already - // have on the child, looking for one that already exists, - // referencing the indicated parent component. + // First, walk through the list of NodePathComponents we already have on + // the child, looking for one that already exists, referencing the + // indicated parent component. PandaNode::Paths::const_iterator it; for (it = node->_paths.begin(); it != node->_paths.end(); ++it) { if ((*it)->get_next(pipeline_stage, current_thread) == comp) { @@ -7559,10 +6585,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } if (it == node->_paths.end()) { - // We don't already have a NodePathComponent referring to this - // parent-child relationship. Create a new one. Note that we can't - // verify that they are actually related because we may not have - // completed the node's pointers yet, so we trust that the .bam is right. + // We don't already have a NodePathComponent referring to this parent- + // child relationship. Create a new one. Note that we can't verify + // that they are actually related because we may not have completed the + // node's pointers yet, so we trust that the .bam is right. comp = new NodePathComponent(node, comp, pipeline_stage, current_thread); node->_paths.insert(comp); } @@ -7574,13 +6600,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: NodePath::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new NodePath. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new NodePath. + */ void NodePath:: fillin(DatagramIterator &scan, BamReader *manager) { while(manager->read_pointer(scan)) {}; diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 2ad15a06cb..729bcf37f3 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -1,19 +1,20 @@ -// Filename: nodePath.h -// Created by: drose (25Feb02) -// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads -// for set_shader_input) -// Updated by: weifengh, PandaSE(30Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath.h + * @author drose + * @date 2002-02-25 + * @author fperazzi, PandaSE + * @date 2010-04-06 + * for set_shader_input) + * @author weifengh, PandaSE + * @date 2010-04-30 + */ #ifndef NODEPATH_H #define NODEPATH_H @@ -61,111 +62,77 @@ class SamplerState; class Shader; class ShaderInput; -// -// A NodePath is the fundamental unit of high-level interaction with -// the scene graph. It encapsulates the complete path down to a node -// from some other node, usually the root of the scene graph. This is -// used to resolve ambiguities associated with instancing. -// -// NodePath also contains a number of handy high-level methods for -// common scene-graph manipulations, such as reparenting, and common -// state changes, such as repositioning. -// -// There are also a number of NodePath methods for finding nodes deep -// within the tree by name or by type. These take a path string, -// which at its simplest consists of a series of node names separated -// by slashes, like a directory pathname. -// -// Each component of the path string may optionally consist of one of -// the following special names, instead of a node name: -// -// * -- matches exactly one node, with any name. -// ** -- matches any sequence of zero or more nodes. -// +typename -- matches any node that is or derives from the given type. -// -typename -- matches any node that is the given type exactly. -// =tag -- matches any node that has the indicated tag. -// =tag=value -- matches any node whose tag matches the indicated value. -// -// Furthermore, a node name may itself contain standard filename -// globbing characters, like *, ?, and [a-z], that will be accepted as -// a partial match. (In fact, the '*' special name may be seen as -// just a special case of this.) The globbing characters may not be -// used with the typename matches or with tag matches, but they may -// be used to match a tag's value in the =tag=value syntax. -// -// The special characters "@@", appearing at the beginning of a node -// name, indicate a stashed node. Normally, stashed nodes are not -// returned by a find (but see the special flags, below), but a -// stashed node may be found if it is explicitly named with its -// leading @@ characters. By extension, "@@*" may be used to identify -// any stashed node. -// -// Examples: -// -// "room//graph" will look for a node named "graph", which is a child -// of an unnamed node, which is a child of a node named "room", which -// is a child of the starting path. -// -// "**/red*" will look for any node anywhere in the tree (below the -// starting path) with a name that begins with "red". -// -// "**/+PartBundleNode/**/head" will look for a node named "head", -// somewhere below a PartBundleNode anywhere in the tree. -// -// -// The search is always potentially ambiguous, even if the special -// wildcard operators are not used, because there may be multiple -// nodes in the tree with the same name. In general, in the case of -// an ambiguity, the shortest path is preferred; when a method (such -// as extend_by) must choose only only one of several possible paths, -// it will choose the shortest available; on the other hand, when a -// method (such as find_all_matches) is to return all of the matching -// paths, it will sort them so that the shortest paths appear first in -// the output. -// -// -// Special flags. The entire string may optionally be followed by the -// ";" character, followed by one or more of the following special -// control flags, with no intervening spaces or punctuation: -// -// -h Do not return hidden nodes. -// +h Do return hidden nodes. -// -s Do not return stashed nodes unless explicitly referenced with @@. -// +s Return stashed nodes even without any explicit @@ characters. -// -i Node name comparisons are not case insensitive: case must match -// exactly. -// +i Node name comparisons are case insensitive: case is not important. -// This affects matches against the node name only; node type -// and tag strings are always case sensitive. -// -// The default flags are +h-s-i. -// +/* + * A NodePath is the fundamental unit of high-level interaction with the scene + * graph. It encapsulates the complete path down to a node from some other + * node, usually the root of the scene graph. This is used to resolve + * ambiguities associated with instancing. NodePath also contains a number of + * handy high-level methods for common scene-graph manipulations, such as + * reparenting, and common state changes, such as repositioning. There are + * also a number of NodePath methods for finding nodes deep within the tree by + * name or by type. These take a path string, which at its simplest consists + * of a series of node names separated by slashes, like a directory pathname. + * Each component of the path string may optionally consist of one of the + * following special names, instead of a node name: * -- matches + * exactly one node, with any name. ** -- matches any sequence of + * zero or more nodes. +typename -- matches any node that is or derives from + * the given type. -typename -- matches any node that is the given type + * exactly. =tag -- matches any node that has the indicated tag. + * =tag=value -- matches any node whose tag matches the indicated value. + * Furthermore, a node name may itself contain standard filename globbing + * characters, like *, ?, and [a-z], that will be accepted as a partial match. + * (In fact, the '*' special name may be seen as just a special case of this.) + * The globbing characters may not be used with the typename matches or with + * tag matches, but they may be used to match a tag's value in the =tag=value + * syntax. The special characters "@@", appearing at the beginning of a node + * name, indicate a stashed node. Normally, stashed nodes are not returned by + * a find (but see the special flags, below), but a stashed node may be found + * if it is explicitly named with its leading @@ characters. By extension, + * "@@*" may be used to identify any stashed node. Examples: "roomgraph" will + * look for a node named "graph", which is a child of an unnamed node, which + * is a child of a node named "room", which is a child of the starting path. + * "**red*" will look for any node anywhere in the tree (below the starting + * path) with a name that begins with "red". "**+PartBundleNode**head" will + * look for a node named "head", somewhere below a PartBundleNode anywhere in + * the tree. The search is always potentially ambiguous, even if the special + * wildcard operators are not used, because there may be multiple nodes in the + * tree with the same name. In general, in the case of an ambiguity, the + * shortest path is preferred; when a method (such as extend_by) must choose + * only only one of several possible paths, it will choose the shortest + * available; on the other hand, when a method (such as find_all_matches) is + * to return all of the matching paths, it will sort them so that the shortest + * paths appear first in the output. Special flags. The entire string may + * optionally be followed by the ";" character, followed by one or more of the + * following special control flags, with no intervening spaces or punctuation: + * -h Do not return hidden nodes. +h Do return hidden nodes. -s Do + * not return stashed nodes unless explicitly referenced with @@. +s Return + * stashed nodes even without any explicit @@ characters. -i Node name + * comparisons are not case insensitive: case must match exactly. +i Node + * name comparisons are case insensitive: case is not important. This affects + * matches against the node name only; node type and tag strings are always + * case sensitive. The default flags are +h-s-i. + */ -//////////////////////////////////////////////////////////////////// -// Class : NodePath -// Description : NodePath is the fundamental system for disambiguating -// instances, and also provides a higher-level interface -// for manipulating the scene graph. -// -// A NodePath is a list of connected nodes from the root -// of the graph to any sub-node. Each NodePath -// therefore uniquely describes one instance of a node. -// -// NodePaths themselves are lightweight objects that may -// easily be copied and passed by value. Their data is -// stored as a series of NodePathComponents that are -// stored on the nodes. Holding a NodePath will keep a -// reference count to all the nodes in the path. -// However, if any node in the path is removed or -// reparented (perhaps through a different NodePath), -// the NodePath will automatically be updated to reflect -// the changes. -//////////////////////////////////////////////////////////////////// +/** + * NodePath is the fundamental system for disambiguating instances, and also + * provides a higher-level interface for manipulating the scene graph. + * + * A NodePath is a list of connected nodes from the root of the graph to any + * sub-node. Each NodePath therefore uniquely describes one instance of a + * node. + * + * NodePaths themselves are lightweight objects that may easily be copied and + * passed by value. Their data is stored as a series of NodePathComponents + * that are stored on the nodes. Holding a NodePath will keep a reference + * count to all the nodes in the path. However, if any node in the path is + * removed or reparented (perhaps through a different NodePath), the NodePath + * will automatically be updated to reflect the changes. + */ class EXPCL_PANDA_PGRAPH NodePath { PUBLISHED: - // This enumeration is returned by get_error_type() for an empty - // NodePath to report the reason it's empty. + // This enumeration is returned by get_error_type() for an empty NodePath to + // report the reason it's empty. enum ErrorType { ET_ok = 0, // i.e. not empty, or never assigned to anything. ET_not_found, // returned from a failed find() or similar function. @@ -226,8 +193,8 @@ PUBLISHED: INLINE bool is_ancestor_of(const NodePath &other, Thread *current_thread = Thread::get_current_thread()) const; INLINE NodePath get_common_ancestor(const NodePath &other, Thread *current_thread = Thread::get_current_thread()) const; - // Methods that return collections of NodePaths derived from or - // related to this one. + // Methods that return collections of NodePaths derived from or related to + // this one. NodePathCollection get_children(Thread *current_thread = Thread::get_current_thread()) const; INLINE int get_num_children(Thread *current_thread = Thread::get_current_thread()) const; @@ -245,11 +212,11 @@ PUBLISHED: NodePathCollection find_all_matches(const string &path) const; NodePathCollection find_all_paths_to(PandaNode *node) const; - // Methods that actually move nodes around in the scene graph. The - // optional "sort" parameter can be used to force a particular - // ordering between sibling nodes, useful when dealing with LOD's - // and similar switch nodes. If the sort value is the same, nodes - // will be arranged in the order they were added. + // Methods that actually move nodes around in the scene graph. The optional + // "sort" parameter can be used to force a particular ordering between + // sibling nodes, useful when dealing with LOD's and similar switch nodes. + // If the sort value is the same, nodes will be arranged in the order they + // were added. void reparent_to(const NodePath &other, int sort = 0, Thread *current_thread = Thread::get_current_thread()); void stash_to(const NodePath &other, int sort = 0, @@ -270,8 +237,7 @@ PUBLISHED: void remove_node(Thread *current_thread = Thread::get_current_thread()); void detach_node(Thread *current_thread = Thread::get_current_thread()); - // Handy ways to look at what's there, and other miscellaneous - // operations. + // Handy ways to look at what's there, and other miscellaneous operations. void output(ostream &out) const; @@ -316,8 +282,8 @@ PUBLISHED: INLINE CPT(TransformState) get_net_prev_transform(Thread *current_thread = Thread::get_current_thread()) const; - // Methods that get and set the matrix transform: pos, hpr, scale, - // in the local coordinate system. + // Methods that get and set the matrix transform: pos, hpr, scale, in the + // local coordinate system. INLINE void set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); void set_pos(const LVecBase3 &pos); @@ -411,8 +377,8 @@ PUBLISHED: INLINE void heads_up(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); void heads_up(const LPoint3 &point, const LVector3 &up = LVector3::up()); - // Methods that get and set the matrix transforms relative to some - // other node in the scene graph. These perform an implicit wrt(). + // Methods that get and set the matrix transforms relative to some other + // node in the scene graph. These perform an implicit wrt(). INLINE void set_pos(const NodePath &other, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); void set_pos(const NodePath &other, const LVecBase3 &pos); @@ -526,8 +492,8 @@ PUBLISHED: INLINE PN_stdfloat get_distance(const NodePath &other) const; - // Methods that affect appearance of geometry: color, texture, etc. - // These affect the state at the bottom level only. + // Methods that affect appearance of geometry: color, texture, etc. These + // affect the state at the bottom level only. void set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a = 1.0, int priority = 0); @@ -880,7 +846,7 @@ PUBLISHED: EXTENSION(PyObject *get_tight_bounds(const NodePath &other = NodePath()) const); - // void analyze() const; + // void analyze() const; int flatten_light(); int flatten_medium(); diff --git a/panda/src/pgraph/nodePathCollection.I b/panda/src/pgraph/nodePathCollection.I index db82a6460f..6c7b5df2d6 100644 --- a/panda/src/pgraph/nodePathCollection.I +++ b/panda/src/pgraph/nodePathCollection.I @@ -1,43 +1,35 @@ -// Filename: nodePathCollection.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathCollection.I + * @author drose + * @date 2002-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePathCollection:: ~NodePathCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void NodePathCollection:: operator += (const NodePathCollection &other) { add_paths_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::operator + -// Access: Published -// Description: Returns a NodePathCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NodePathCollection representing the concatenation of the two + * lists. + */ INLINE NodePathCollection NodePathCollection:: operator + (const NodePathCollection &other) const { NodePathCollection a(*this); @@ -45,69 +37,54 @@ operator + (const NodePathCollection &other) const { return a; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::append -// Access: Published -// Description: Adds a new NodePath to the collection. This method -// duplicates the add_path() method; it is provided to -// satisfy Python's naming convention. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new NodePath to the collection. This method duplicates the + * add_path() method; it is provided to satisfy Python's naming convention. + */ void NodePathCollection:: append(const NodePath &node_path) { add_path(node_path); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::extend -// Access: Published -// Description: Appends the other list onto the end of this one. -// This method duplicates the += operator; it is -// provided to satisfy Python's naming convention. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. This method duplicates + * the += operator; it is provided to satisfy Python's naming convention. + */ INLINE void NodePathCollection:: extend(const NodePathCollection &other) { operator += (other); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::ls -// Access: Published -// Description: Lists all the nodes at and below each node in the -// collection hierarchically. -//////////////////////////////////////////////////////////////////// +/** + * Lists all the nodes at and below each node in the collection + * hierarchically. + */ INLINE void NodePathCollection:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_color -// Access: Published -// Description: Colors all NodePaths in the collection -//////////////////////////////////////////////////////////////////// +/** + * Colors all NodePaths in the collection + */ INLINE void NodePathCollection:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { set_color(LColor(r, g, b, a), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_color_scale -// Access: Published -// Description: Applies color scales to all NodePaths in the -// collection. The existing color scale is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Applies color scales to all NodePaths in the collection. The existing + * color scale is replaced. + */ INLINE void NodePathCollection:: set_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { set_color_scale(LVecBase4(r, g, b, a), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::compose_color_scale -// Access: Published -// Description: Applies color scales to all NodePaths in the -// collection. The existing color scale, if any, is -// multiplied by the specified color scale. -//////////////////////////////////////////////////////////////////// +/** + * Applies color scales to all NodePaths in the collection. The existing + * color scale, if any, is multiplied by the specified color scale. + */ INLINE void NodePathCollection:: compose_color_scale(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a, int priority) { compose_color_scale(LVecBase4(r, g, b, a), priority); diff --git a/panda/src/pgraph/nodePathCollection.cxx b/panda/src/pgraph/nodePathCollection.cxx index c704543838..a2310b9e99 100644 --- a/panda/src/pgraph/nodePathCollection.cxx +++ b/panda/src/pgraph/nodePathCollection.cxx @@ -1,16 +1,15 @@ -// Filename: nodePathCollection.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathCollection.cxx + * @author drose + * @date 2002-03-06 + */ #include "nodePathCollection.h" #include "findApproxPath.h" @@ -20,47 +19,38 @@ #include "colorAttrib.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NodePathCollection:: NodePathCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NodePathCollection:: NodePathCollection(const NodePathCollection ©) : _node_paths(copy._node_paths) { } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodePathCollection:: operator = (const NodePathCollection ©) { _node_paths = copy._node_paths; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::add_path -// Access: Published -// Description: Adds a new NodePath to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new NodePath to the collection. + */ void NodePathCollection:: add_path(const NodePath &node_path) { // If the pointer to our internal array is shared by any other // NodePathCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren NodePathCollection - // objects. + // inadvertently modify any of our brethren NodePathCollection objects. if (_node_paths.get_ref_count() > 1) { NodePaths old_node_paths = _node_paths; @@ -71,13 +61,10 @@ add_path(const NodePath &node_path) { _node_paths.push_back(node_path); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::remove_path -// Access: Published -// Description: Removes the indicated NodePath from the collection. -// Returns true if the path was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated NodePath from the collection. Returns true if the + * path was removed, false if it was not a member of the collection. + */ bool NodePathCollection:: remove_path(const NodePath &node_path) { int path_index = -1; @@ -94,8 +81,7 @@ remove_path(const NodePath &node_path) { // If the pointer to our internal array is shared by any other // NodePathCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren NodePathCollection - // objects. + // inadvertently modify any of our brethren NodePathCollection objects. if (_node_paths.get_ref_count() > 1) { NodePaths old_node_paths = _node_paths; @@ -107,14 +93,11 @@ remove_path(const NodePath &node_path) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::add_paths_from -// Access: Published -// Description: Adds all the NodePaths indicated in the other -// collection to this path. The other paths are simply -// appended to the end of the paths in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the NodePaths indicated in the other collection to this path. The + * other paths are simply appended to the end of the paths in this list; + * duplicates are not automatically removed. + */ void NodePathCollection:: add_paths_from(const NodePathCollection &other) { int other_num_paths = other.get_num_paths(); @@ -124,12 +107,10 @@ add_paths_from(const NodePathCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::remove_paths_from -// Access: Published -// Description: Removes from this collection all of the NodePaths -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the NodePaths listed in the other + * collection. + */ void NodePathCollection:: remove_paths_from(const NodePathCollection &other) { NodePaths new_paths; @@ -143,14 +124,11 @@ remove_paths_from(const NodePathCollection &other) { _node_paths = new_paths; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::remove_duplicate_paths -// Access: Published -// Description: Removes any duplicate entries of the same NodePaths -// on this collection. If a NodePath appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same NodePaths on this collection. If + * a NodePath appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void NodePathCollection:: remove_duplicate_paths() { NodePaths new_paths; @@ -172,12 +150,10 @@ remove_duplicate_paths() { _node_paths = new_paths; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::has_path -// Access: Published -// Description: Returns true if the indicated NodePath appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated NodePath appears in this collection, false + * otherwise. + */ bool NodePathCollection:: has_path(const NodePath &path) const { for (int i = 0; i < get_num_paths(); i++) { @@ -188,54 +164,42 @@ has_path(const NodePath &path) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::clear -// Access: Published -// Description: Removes all NodePaths from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all NodePaths from the collection. + */ void NodePathCollection:: clear() { _node_paths.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::reserve -// Access: Published -// Description: This is a hint to Panda to allocate enough memory -// to hold the given number of NodePaths, if you know -// ahead of time how many you will be adding. -//////////////////////////////////////////////////////////////////// +/** + * This is a hint to Panda to allocate enough memory to hold the given number + * of NodePaths, if you know ahead of time how many you will be adding. + */ void NodePathCollection:: reserve(size_t num) { _node_paths.reserve(num); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::is_empty -// Access: Published -// Description: Returns true if there are no NodePaths in the -// collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no NodePaths in the collection, false otherwise. + */ bool NodePathCollection:: is_empty() const { return _node_paths.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::get_num_paths -// Access: Published -// Description: Returns the number of NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of NodePaths in the collection. + */ int NodePathCollection:: get_num_paths() const { return _node_paths.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::get_path -// Access: Published -// Description: Returns the nth NodePath in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth NodePath in the collection. + */ NodePath NodePathCollection:: get_path(int index) const { nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath()); @@ -243,13 +207,10 @@ get_path(int index) const { return _node_paths[index]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::operator [] -// Access: Published -// Description: Returns the nth NodePath in the collection. This is -// the same as get_path(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth NodePath in the collection. This is the same as + * get_path(), but it may be a more convenient way to access it. + */ NodePath NodePathCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_node_paths.size(), NodePath()); @@ -257,23 +218,19 @@ operator [] (int index) const { return _node_paths[index]; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::size -// Access: Published -// Description: Returns the number of paths in the collection. This -// is the same thing as get_num_paths(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of paths in the collection. This is the same thing as + * get_num_paths(). + */ int NodePathCollection:: size() const { return _node_paths.size(); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::ls -// Access: Published -// Description: Lists all the nodes at and below each node in the -// collection hierarchically. -//////////////////////////////////////////////////////////////////// +/** + * Lists all the nodes at and below each node in the collection + * hierarchically. + */ void NodePathCollection:: ls(ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { @@ -284,14 +241,11 @@ ls(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::find_all_matches -// Access: Published -// Description: Returns the complete set of all NodePaths that begin -// with any NodePath in this collection and can be -// extended by path. The shortest paths will be listed -// first. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete set of all NodePaths that begin with any NodePath in + * this collection and can be extended by path. The shortest paths will be + * listed first. + */ NodePathCollection NodePathCollection:: find_all_matches(const string &path) const { NodePathCollection result; @@ -313,12 +267,9 @@ find_all_matches(const string &path) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::reparent_to -// Access: Published -// Description: Reparents all the NodePaths in the collection to the -// indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Reparents all the NodePaths in the collection to the indicated node. + */ void NodePathCollection:: reparent_to(const NodePath &other) { for (int i = 0; i < get_num_paths(); i++) { @@ -326,13 +277,10 @@ reparent_to(const NodePath &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::wrt_reparent_to -// Access: Published -// Description: Reparents all the NodePaths in the collection to the -// indicated node, adjusting each transform so as not to -// move in world coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Reparents all the NodePaths in the collection to the indicated node, + * adjusting each transform so as not to move in world coordinates. + */ void NodePathCollection:: wrt_reparent_to(const NodePath &other) { for (int i = 0; i < get_num_paths(); i++) { @@ -340,11 +288,9 @@ wrt_reparent_to(const NodePath &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::show -// Access: Published -// Description: Shows all NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Shows all NodePaths in the collection. + */ void NodePathCollection:: show() { for (int i = 0; i < get_num_paths(); i++) { @@ -352,11 +298,9 @@ show() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::show -// Access: Published -// Description: Hides all NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Hides all NodePaths in the collection. + */ void NodePathCollection:: hide() { for (int i = 0; i < get_num_paths(); i++) { @@ -364,11 +308,9 @@ hide() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::stash -// Access: Published -// Description: Stashes all NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Stashes all NodePaths in the collection. + */ void NodePathCollection:: stash() { for (int i = 0; i < get_num_paths(); i++) { @@ -376,11 +318,9 @@ stash() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::unstash -// Access: Published -// Description: Unstashes all NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Unstashes all NodePaths in the collection. + */ void NodePathCollection:: unstash() { for (int i = 0; i < get_num_paths(); i++) { @@ -388,11 +328,9 @@ unstash() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::detach -// Access: Published -// Description: Detaches all NodePaths in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Detaches all NodePaths in the collection. + */ void NodePathCollection:: detach() { for (int i = 0; i < get_num_paths(); i++) { @@ -400,17 +338,13 @@ detach() { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::get_collide_mask -// Access: Published -// Description: Returns the union of all of the into_collide_masks -// for nodes at this level and below. This is the same -// thing as node()->get_net_collide_mask(). -// -// If you want to return what the into_collide_mask of -// this node itself is, without regard to its children, -// use node()->get_into_collide_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all of the into_collide_masks for nodes at this level + * and below. This is the same thing as node()->get_net_collide_mask(). + * + * If you want to return what the into_collide_mask of this node itself is, + * without regard to its children, use node()->get_into_collide_mask(). + */ CollideMask NodePathCollection:: get_collide_mask() const { CollideMask collide_mask; @@ -420,19 +354,14 @@ get_collide_mask() const { return collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_collide_mask -// Access: Published -// Description: Recursively applies the indicated CollideMask to the -// into_collide_masks for all nodes at this level and -// below. -// -// The default is to change all bits, but if -// bits_to_change is not all bits on, then only the bits -// that are set in bits_to_change are modified, allowing -// this call to change only a subset of the bits in the -// subgraph. -//////////////////////////////////////////////////////////////////// +/** + * Recursively applies the indicated CollideMask to the into_collide_masks for + * all nodes at this level and below. + * + * The default is to change all bits, but if bits_to_change is not all bits + * on, then only the bits that are set in bits_to_change are modified, + * allowing this call to change only a subset of the bits in the subgraph. + */ void NodePathCollection:: set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, TypeHandle node_type) { @@ -441,18 +370,15 @@ set_collide_mask(CollideMask new_mask, CollideMask bits_to_change, } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::calc_tight_bounds -// Access: Published -// Description: Calculates the minimum and maximum vertices of all -// Geoms at these NodePath's bottom nodes and below -// This is a tight bounding box; it will generally be -// tighter than the bounding volume returned by -// get_bounds() (but it is more expensive to compute). -// -// The return value is true if any points are within the -// bounding volume, or false if none are. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the minimum and maximum vertices of all Geoms at these + * NodePath's bottom nodes and below This is a tight bounding box; it will + * generally be tighter than the bounding volume returned by get_bounds() (but + * it is more expensive to compute). + * + * The return value is true if any points are within the bounding volume, or + * false if none are. + */ bool NodePathCollection:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const { bool have_bounds = false; @@ -484,35 +410,28 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const { return have_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the default texture stage. -// -// This is the deprecated single-texture variant of this -// method; it is now superceded by set_texture() that -// accepts a stage and texture. However, this method -// may be used in the presence of multitexture if you -// just want to adjust the default stage. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the default texture stage. + * + * This is the deprecated single-texture variant of this method; it is now + * superceded by set_texture() that accepts a stage and texture. However, + * this method may be used in the presence of multitexture if you just want to + * adjust the default stage. + */ void NodePathCollection:: set_texture(Texture *tex, int priority) { PT(TextureStage) stage = TextureStage::get_default(); set_texture(stage, tex, priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_texture -// Access: Published -// Description: Adds the indicated texture to the list of textures -// that will be rendered on the indicated multitexture -// stage. If there are multiple texture stages -// specified (possibly on multiple different nodes at -// different levels), they will all be applied to -// geometry together, according to the stage -// specification set up in the TextureStage object. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures that will be rendered on + * the indicated multitexture stage. If there are multiple texture stages + * specified (possibly on multiple different nodes at different levels), they + * will all be applied to geometry together, according to the stage + * specification set up in the TextureStage object. + */ void NodePathCollection:: set_texture(TextureStage *stage, Texture *tex, int priority) { StateMap state_map; @@ -526,40 +445,32 @@ set_texture(TextureStage *stage, Texture *tex, int priority) { // This RenderState has already been encountered; reuse it. np.set_state((*smi).second); } else { - // This RenderState has not yet been encountered; apply the - // attrib to it. + // This RenderState has not yet been encountered; apply the attrib to + // it. np.set_texture(stage, tex, priority); state_map[orig_state] = np.get_state(); } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_texture_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no texture, on any stage. This is different -// from not specifying a texture; rather, this -// specifically contradicts set_texture() at a higher -// node level (or, with a priority, overrides a -// set_texture() at a lower level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no texture, on + * any stage. This is different from not specifying a texture; rather, this + * specifically contradicts set_texture() at a higher node level (or, with a + * priority, overrides a set_texture() at a lower level). + */ void NodePathCollection:: set_texture_off(int priority) { nassertv_always(!is_empty()); set_attrib(TextureAttrib::make_all_off(), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_texture_off -// Access: Published -// Description: Sets the geometry at this level and below to render -// using no texture, on the indicated stage. This is -// different from not specifying a texture; rather, this -// specifically contradicts set_texture() at a higher -// node level (or, with a priority, overrides a -// set_texture() at a lower level). -//////////////////////////////////////////////////////////////////// +/** + * Sets the geometry at this level and below to render using no texture, on + * the indicated stage. This is different from not specifying a texture; + * rather, this specifically contradicts set_texture() at a higher node level + * (or, with a priority, overrides a set_texture() at a lower level). + */ void NodePathCollection:: set_texture_off(TextureStage *stage, int priority) { StateMap state_map; @@ -573,30 +484,26 @@ set_texture_off(TextureStage *stage, int priority) { // This RenderState has already been encountered; reuse it. np.set_state((*smi).second); } else { - // This RenderState has not yet been encountered; apply the - // attrib to it. + // This RenderState has not yet been encountered; apply the attrib to + // it. np.set_texture_off(stage, priority); state_map[orig_state] = np.get_state(); } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_color -// Access: Published -// Description: Colors all NodePaths in the collection -//////////////////////////////////////////////////////////////////// +/** + * Colors all NodePaths in the collection + */ void NodePathCollection:: set_color(const LColor &color, int priority) { set_attrib(ColorAttrib::make_flat(color), priority); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_color_scale -// Access: Published -// Description: Applies color scales to all NodePaths in the -// collection. The existing color scale is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Applies color scales to all NodePaths in the collection. The existing + * color scale is replaced. + */ void NodePathCollection:: set_color_scale(const LVecBase4 &scale, int priority) { StateMap state_map; @@ -610,21 +517,18 @@ set_color_scale(const LVecBase4 &scale, int priority) { // This RenderState has already been encountered; reuse it. np.set_state((*smi).second); } else { - // This RenderState has not yet been encountered; apply the - // attrib to it. + // This RenderState has not yet been encountered; apply the attrib to + // it. np.set_color_scale(scale, priority); state_map[orig_state] = np.get_state(); } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::compose_color_scale -// Access: Published -// Description: Applies color scales to all NodePaths in the -// collection. The existing color scale, if any, is -// multiplied by the specified color scale. -//////////////////////////////////////////////////////////////////// +/** + * Applies color scales to all NodePaths in the collection. The existing + * color scale, if any, is multiplied by the specified color scale. + */ void NodePathCollection:: compose_color_scale(const LVecBase4 &scale, int priority) { StateMap state_map; @@ -638,23 +542,19 @@ compose_color_scale(const LVecBase4 &scale, int priority) { // This RenderState has already been encountered; reuse it. np.set_state((*smi).second); } else { - // This RenderState has not yet been encountered; apply the - // attrib to it. + // This RenderState has not yet been encountered; apply the attrib to + // it. np.compose_color_scale(scale, priority); state_map[orig_state] = np.get_state(); } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::set_attrib -// Access: Published -// Description: Applies the indicated RenderAttrib to all NodePaths -// in the collection. An effort is made to apply the -// attrib to many NodePaths as quickly as possible; -// redundant RenderState compositions are not -// duplicated. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated RenderAttrib to all NodePaths in the collection. An + * effort is made to apply the attrib to many NodePaths as quickly as + * possible; redundant RenderState compositions are not duplicated. + */ void NodePathCollection:: set_attrib(const RenderAttrib *attrib, int priority) { StateMap state_map; @@ -668,20 +568,18 @@ set_attrib(const RenderAttrib *attrib, int priority) { // This RenderState has already been encountered; reuse it. np.set_state((*smi).second); } else { - // This RenderState has not yet been encountered; apply the - // attrib to it. + // This RenderState has not yet been encountered; apply the attrib to + // it. np.set_attrib(attrib, priority); state_map[orig_state] = np.get_state(); } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// NodePathCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the NodePathCollection to the + * indicated output stream. + */ void NodePathCollection:: output(ostream &out) const { if (get_num_paths() == 1) { @@ -691,12 +589,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// NodePathCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the NodePathCollection to the + * indicated output stream. + */ void NodePathCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_paths(); i++) { diff --git a/panda/src/pgraph/nodePathCollection.h b/panda/src/pgraph/nodePathCollection.h index 8527db5b5d..1d1ba9bd1f 100644 --- a/panda/src/pgraph/nodePathCollection.h +++ b/panda/src/pgraph/nodePathCollection.h @@ -1,16 +1,15 @@ -// Filename: nodePathCollection.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathCollection.h + * @author drose + * @date 2002-03-06 + */ #ifndef NODEPATHCOLLECTION_H #define NODEPATHCOLLECTION_H @@ -19,13 +18,11 @@ #include "nodePath.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : NodePathCollection -// Description : This is a set of zero or more NodePaths. It's handy -// for returning from functions that need to return -// multiple NodePaths (for instance, -// NodePaths::get_children). -//////////////////////////////////////////////////////////////////// +/** + * This is a set of zero or more NodePaths. It's handy for returning from + * functions that need to return multiple NodePaths (for instance, + * NodePaths::get_children). + */ class EXPCL_PANDA_PGRAPH NodePathCollection { PUBLISHED: NodePathCollection(); @@ -120,5 +117,3 @@ INLINE ostream &operator << (ostream &out, const NodePathCollection &col) { #include "nodePathCollection.I" #endif - - diff --git a/panda/src/pgraph/nodePathCollection_ext.cxx b/panda/src/pgraph/nodePathCollection_ext.cxx index 48898fb547..28b5ed5255 100644 --- a/panda/src/pgraph/nodePathCollection_ext.cxx +++ b/panda/src/pgraph/nodePathCollection_ext.cxx @@ -1,16 +1,15 @@ -// Filename: nodePathCollection_ext.cxx -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathCollection_ext.cxx + * @author rdb + * @date 2013-12-09 + */ #include "nodePathCollection_ext.h" @@ -25,14 +24,11 @@ extern struct Dtool_PyTypedObject Dtool_LPoint3f; #endif #endif -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::__init__ -// Access: Published -// Description: This special constructor accepts a Python list of -// NodePaths. Since this constructor accepts a generic -// PyObject *, it should be the last constructor listed -// in the class record. -//////////////////////////////////////////////////////////////////// +/** + * This special constructor accepts a Python list of NodePaths. Since this + * constructor accepts a generic PyObject *, it should be the last constructor + * listed in the class record. + */ void Extension:: __init__(PyObject *self, PyObject *sequence) { PyObject *fast = PySequence_Fast(sequence, "NodePathCollection constructor requires a sequence"); @@ -67,44 +63,37 @@ __init__(PyObject *self, PyObject *sequence) { Py_DECREF(fast); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathCollection::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + */ PyObject *Extension:: __reduce__(PyObject *self) const { - // Here we will return a 4-tuple: (Class, (args), None, iterator), - // where iterator is an iterator that will yield successive - // NodePaths. + // Here we will return a 4-tuple: (Class, (args), None, iterator), where + // iterator is an iterator that will yield successive NodePaths. - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. PyObject *this_class = PyObject_Type(self); if (this_class == NULL) { return NULL; } - // Since a NodePathCollection is itself an iterator, we can simply - // pass it as the fourth tuple component. + // Since a NodePathCollection is itself an iterator, we can simply pass it + // as the fourth tuple component. PyObject *result = Py_BuildValue("(O()OO)", this_class, Py_None, self); Py_DECREF(this_class); return result; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_tight_bounds -// Access: Published -// Description: Returns the tight bounds as a 2-tuple of LPoint3 -// objects. This is a convenience function for Python -// users, among which the use of calc_tight_bounds -// may be confusing. -// Returns None if calc_tight_bounds returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tight bounds as a 2-tuple of LPoint3 objects. This is a + * convenience function for Python users, among which the use of + * calc_tight_bounds may be confusing. Returns None if calc_tight_bounds + * returned false. + */ PyObject *Extension:: get_tight_bounds() const { LPoint3 *min_point = new LPoint3; diff --git a/panda/src/pgraph/nodePathCollection_ext.h b/panda/src/pgraph/nodePathCollection_ext.h index 60aa2203ec..3808b2490e 100644 --- a/panda/src/pgraph/nodePathCollection_ext.h +++ b/panda/src/pgraph/nodePathCollection_ext.h @@ -1,16 +1,15 @@ -// Filename: nodePathCollection_ext.h -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathCollection_ext.h + * @author rdb + * @date 2013-12-09 + */ #ifndef NODEPATHCOLLECTION_EXT_H #define NODEPATHCOLLECTION_EXT_H @@ -23,12 +22,10 @@ #include "nodePathCollection.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePathCollection, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePathCollection, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pgraph/nodePathComponent.I b/panda/src/pgraph/nodePathComponent.I index 84a7d192fe..fa16ebe2b9 100644 --- a/panda/src/pgraph/nodePathComponent.I +++ b/panda/src/pgraph/nodePathComponent.I @@ -1,33 +1,27 @@ -// Filename: nodePathComponent.I -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathComponent.I + * @author drose + * @date 2002-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePathComponent::CData:: CData() { _length = 1; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePathComponent::CData:: CData(const NodePathComponent::CData ©) : _next(copy._next), @@ -35,58 +29,47 @@ CData(const NodePathComponent::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::Copy Constructor -// Access: Private -// Description: NodePathComponents should not be copied. -//////////////////////////////////////////////////////////////////// +/** + * NodePathComponents should not be copied. + */ INLINE NodePathComponent:: NodePathComponent(const NodePathComponent ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::Copy Assignment Operator -// Access: Private -// Description: NodePathComponents should not be copied. -//////////////////////////////////////////////////////////////////// +/** + * NodePathComponents should not be copied. + */ INLINE void NodePathComponent:: operator = (const NodePathComponent ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodePathComponent:: ~NodePathComponent() { nassertv(_node != (PandaNode *)NULL); _node->delete_component(this); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::get_node -// Access: Public -// Description: Returns the node referenced by this component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node referenced by this component. + */ INLINE PandaNode *NodePathComponent:: get_node() const { nassertr(_node != (PandaNode *)NULL, _node); return _node; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::has_key -// Access: Public -// Description: Returns true if the key for this component has -// already been generated, false otherwise. Even if -// this returns false, calling get_key() will still -// return a valid key; that will simply cause the key to -// be generated on-the-fly. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the key for this component has already been generated, + * false otherwise. Even if this returns false, calling get_key() will still + * return a valid key; that will simply cause the key to be generated on-the- + * fly. + */ INLINE bool NodePathComponent:: has_key() const { return (_key != 0); @@ -96,4 +79,3 @@ INLINE ostream &operator << (ostream &out, const NodePathComponent &comp) { comp.output(out); return out; } - diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index ca938944e1..4dbacc4539 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -1,45 +1,39 @@ -// Filename: nodePathComponent.cxx -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathComponent.cxx + * @author drose + * @date 2002-02-25 + */ #include "nodePathComponent.h" #include "lightMutexHolder.h" -// We start the key counters off at 1, since 0 is reserved for an -// empty NodePath (and also for an unassigned key). +// We start the key counters off at 1, since 0 is reserved for an empty +// NodePath (and also for an unassigned key). int NodePathComponent::_next_key = 1; LightMutex NodePathComponent::_key_lock("NodePathComponent::_key_lock"); TypeHandle NodePathComponent::_type_handle; TypeHandle NodePathComponent::CData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *NodePathComponent::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::Constructor -// Access: Private -// Description: Constructs a new NodePathComponent from the -// indicated node. Don't try to call this directly; ask -// the PandaNode to do it for you. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new NodePathComponent from the indicated node. Don't try to + * call this directly; ask the PandaNode to do it for you. + */ NodePathComponent:: NodePathComponent(PandaNode *node, NodePathComponent *next, int pipeline_stage, Thread *current_thread) : @@ -51,83 +45,69 @@ NodePathComponent(PandaNode *node, NodePathComponent *next, #endif for (int pipeline_stage_i = pipeline_stage; - pipeline_stage_i >= 0; + pipeline_stage_i >= 0; --pipeline_stage_i) { CDStageWriter cdata(_cycler, pipeline_stage_i, current_thread); cdata->_next = next; - + if (next != (NodePathComponent *)NULL) { cdata->_length = next->get_length(pipeline_stage_i, current_thread) + 1; } } } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::get_key -// Access: Public -// Description: Returns an index number that is guaranteed to be -// unique for this particular NodePathComponent, and not -// to be reused for the lifetime of the application -// (barring integer overflow). -//////////////////////////////////////////////////////////////////// +/** + * Returns an index number that is guaranteed to be unique for this particular + * NodePathComponent, and not to be reused for the lifetime of the application + * (barring integer overflow). + */ int NodePathComponent:: get_key() const { LightMutexHolder holder(_key_lock); if (_key == 0) { - // The first time someone asks for a particular component's key, - // we make it up on the spot. This helps keep us from wasting - // index numbers generating a unique number for *every* component - // in the world (we only have 4.2 billion 32-bit integers, after - // all) + // The first time someone asks for a particular component's key, we make + // it up on the spot. This helps keep us from wasting index numbers + // generating a unique number for *every* component in the world (we only + // have 4.2 billion 32-bit integers, after all) ((NodePathComponent *)this)->_key = _next_key++; } return _key; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::is_top_node -// Access: Public -// Description: Returns true if this component represents the top -// node in the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this component represents the top node in the path. + */ bool NodePathComponent:: is_top_node(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); return (cdata->_next == (NodePathComponent *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::get_length -// Access: Public -// Description: Returns the length of the path to this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of the path to this node. + */ int NodePathComponent:: get_length(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); return cdata->_length; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::get_next -// Access: Public -// Description: Returns the next component in the path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next component in the path. + */ NodePathComponent *NodePathComponent:: get_next(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); NodePathComponent *next = cdata->_next; - + return next; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::fix_length -// Access: Public -// Description: Checks that the length indicated by the component is -// one more than the length of its predecessor. If this -// is broken, fixes it and returns true indicating the -// component has been changed; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the length indicated by the component is one more than the + * length of its predecessor. If this is broken, fixes it and returns true + * indicating the component has been changed; otherwise, returns false. + */ bool NodePathComponent:: fix_length(int pipeline_stage, Thread *current_thread) { CDLockedStageReader cdata(_cycler, pipeline_stage, current_thread); @@ -146,14 +126,11 @@ fix_length(int pipeline_stage, Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::output -// Access: Public -// Description: The recursive implementation of NodePath::output(), -// this writes the names of each node component in order -// from beginning to end, by first walking to the end of -// the linked list and then outputting from there. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of NodePath::output(), this writes the names + * of each node component in order from beginning to end, by first walking to + * the end of the linked list and then outputting from there. + */ void NodePathComponent:: output(ostream &out) const { Thread *current_thread = Thread::get_current_thread(); @@ -183,14 +160,12 @@ output(ostream &out) const { } else { out << "-" << node->get_type(); } - // out << "[" << this->get_length() << "]"; + // out << "[" << this->get_length() << "]"; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::set_next -// Access: Private -// Description: Sets the next pointer in the path. -//////////////////////////////////////////////////////////////////// +/** + * Sets the next pointer in the path. + */ void NodePathComponent:: set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { nassertv(next != (NodePathComponent *)NULL); @@ -198,12 +173,10 @@ set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread) { cdata->_next = next; } -//////////////////////////////////////////////////////////////////// -// Function: NodePathComponent::set_top_node -// Access: Private -// Description: Severs any connection to the next pointer in the -// path and makes this component a top node. -//////////////////////////////////////////////////////////////////// +/** + * Severs any connection to the next pointer in the path and makes this + * component a top node. + */ void NodePathComponent:: set_top_node(int pipeline_stage, Thread *current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index 344170b000..fbe4625c14 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -1,16 +1,15 @@ -// Filename: nodePathComponent.h -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePathComponent.h + * @author drose + * @date 2002-02-25 + */ #ifndef NODEPATHCOMPONENT_H #define NODEPATHCOMPONENT_H @@ -29,22 +28,17 @@ #include "lightMutex.h" #include "deletedChain.h" -//////////////////////////////////////////////////////////////////// -// Class : NodePathComponent -// Description : This is one component of a NodePath. These are -// stored on each PandaNode, as many as one for each of -// the possible instances of the node (but they only -// exist when they are requested, to minimize memory -// waste). A NodePath represents a singly-linked list -// of these from an arbitrary component in the graph to -// the root. -// -// This whole NodePath system is used to disambiguate -// instances in the scene graph, and the -// NodePathComponents are stored in the nodes themselves -// to allow the nodes to keep these up to date as the -// scene graph is manipulated. -//////////////////////////////////////////////////////////////////// +/** + * This is one component of a NodePath. These are stored on each PandaNode, + * as many as one for each of the possible instances of the node (but they + * only exist when they are requested, to minimize memory waste). A NodePath + * represents a singly-linked list of these from an arbitrary component in the + * graph to the root. + * + * This whole NodePath system is used to disambiguate instances in the scene + * graph, and the NodePathComponents are stored in the nodes themselves to + * allow the nodes to keep these up to date as the scene graph is manipulated. + */ class EXPCL_PANDA_PGRAPH NodePathComponent : public ReferenceCount { private: NodePathComponent(PandaNode *node, NodePathComponent *next, @@ -55,27 +49,26 @@ private: public: INLINE ~NodePathComponent(); ALLOC_DELETED_CHAIN(NodePathComponent); - + INLINE PandaNode *get_node() const; INLINE bool has_key() const; int get_key() const; bool is_top_node(int pipeline_stage, Thread *current_thread) const; - + NodePathComponent *get_next(int pipeline_stage, Thread *current_thread) const; int get_length(int pipeline_stage, Thread *current_thread) const; bool fix_length(int pipeline_stage, Thread *current_thread); void output(ostream &out) const; - + private: void set_next(NodePathComponent *next, int pipeline_stage, Thread *current_thread); void set_top_node(int pipeline_stage, Thread *current_thread); - // We don't have to cycle the _node and _key elements, since these - // are permanent properties of this object. (Well, the _key is - // semi-permanent: it becomes permanent after it has been set the - // first time.) + // We don't have to cycle the _node and _key elements, since these are + // permanent properties of this object. (Well, the _key is semi-permanent: + // it becomes permanent after it has been set the first time.) PT(PandaNode) _node; int _key; @@ -92,7 +85,7 @@ private: PT(NodePathComponent) _next; int _length; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -100,7 +93,7 @@ private: static void init_type() { register_type(_type_handle, "NodePathComponent::CData"); } - + private: static TypeHandle _type_handle; }; @@ -125,7 +118,7 @@ public: ReferenceCount::get_class_type()); CData::init_type(); } - + private: static TypeHandle _type_handle; friend class PandaNode; diff --git a/panda/src/pgraph/nodePath_ext.I b/panda/src/pgraph/nodePath_ext.I index f40acd26d8..0931d2d794 100644 --- a/panda/src/pgraph/nodePath_ext.I +++ b/panda/src/pgraph/nodePath_ext.I @@ -1,41 +1,34 @@ -// Filename: nodePath_ext.I -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath_ext.I + * @author rdb + * @date 2013-12-09 + */ #include "pandaNode_ext.h" -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_python_tag_keys -// Access: Published -// Description: Fills the given vector up with the -// list of Python tags on this PandaNode. -// -// It is the user's responsibility to ensure that the -// keys vector is empty before making this call; -// otherwise, the new files will be appended to it. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of Python tags on this PandaNode. + * + * It is the user's responsibility to ensure that the keys vector is empty + * before making this call; otherwise, the new files will be appended to it. + */ INLINE void Extension:: get_python_tag_keys(vector_string &keys) const { nassertv_always(!_this->is_empty()); invoke_extension(_this->node()).get_python_tag_keys(keys); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_tag_keys -// Access: Published -// Description: This variant on get_tag_keys returns a Python list -// of strings. Returns None if the NodePath is empty. -//////////////////////////////////////////////////////////////////// +/** + * This variant on get_tag_keys returns a Python list of strings. Returns + * None if the NodePath is empty. + */ INLINE PyObject *Extension:: get_tag_keys() const { // An empty NodePath returns None @@ -46,13 +39,10 @@ get_tag_keys() const { return invoke_extension(_this->node()).get_tag_keys(); } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_python_tag_keys -// Access: Published -// Description: This variant on get_python_tag_keys returns a -// Python list of strings. -// Returns None if the NodePath is empty. -//////////////////////////////////////////////////////////////////// +/** + * This variant on get_python_tag_keys returns a Python list of strings. + * Returns None if the NodePath is empty. + */ INLINE PyObject *Extension:: get_python_tag_keys() const { // An empty NodePath returns None @@ -63,33 +53,26 @@ get_python_tag_keys() const { return invoke_extension(_this->node()).get_python_tag_keys(); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::set_python_tag -// Access: Published -// Description: Associates an arbitrary Python object with a -// user-defined key which is stored on the node. This -// object has no meaning to Panda; but it is stored -// indefinitely on the node until it is requested again. -// -// Each unique key stores a different Python object. -// There is no effective limit on the number of -// different keys that may be stored or on the nature of -// any one key's object. -//////////////////////////////////////////////////////////////////// +/** + * Associates an arbitrary Python object with a user-defined key which is + * stored on the node. This object has no meaning to Panda; but it is stored + * indefinitely on the node until it is requested again. + * + * Each unique key stores a different Python object. There is no effective + * limit on the number of different keys that may be stored or on the nature + * of any one key's object. + */ INLINE void Extension:: set_python_tag(const string &key, PyObject *value) { nassertv_always(!_this->is_empty()); invoke_extension(_this->node()).set_python_tag(key, value); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_python_tag -// Access: Published -// Description: Retrieves the Python object that was previously -// set on this node for the particular key, if any. If -// no object has been previously set, returns None. -// See also get_net_python_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the Python object that was previously set on this node for the + * particular key, if any. If no object has been previously set, returns + * None. See also get_net_python_tag(). + */ INLINE PyObject *Extension:: get_python_tag(const string &key) const { // An empty NodePath quietly returns no tags. This makes @@ -101,14 +84,11 @@ get_python_tag(const string &key) const { return invoke_extension(_this->node()).get_python_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::has_python_tag -// Access: Published -// Description: Returns true if a Python object has been defined on -// this node for the particular key (even if that value -// is the empty string), or false if no value has been -// set. See also has_net_python_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a Python object has been defined on this node for the + * particular key (even if that value is the empty string), or false if no + * value has been set. See also has_net_python_tag(). + */ INLINE bool Extension:: has_python_tag(const string &key) const { // An empty NodePath quietly has no tags. This makes has_net_python_tag() @@ -119,42 +99,33 @@ has_python_tag(const string &key) const { return invoke_extension(_this->node()).has_python_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::clear_python_tag -// Access: Published -// Description: Removes the Python object defined for this key on this -// particular node. After a call to clear_python_tag(), -// has_python_tag() will return false for the indicated -// key. -//////////////////////////////////////////////////////////////////// +/** + * Removes the Python object defined for this key on this particular node. + * After a call to clear_python_tag(), has_python_tag() will return false for + * the indicated key. + */ INLINE void Extension:: clear_python_tag(const string &key) { nassertv_always(!_this->is_empty()); invoke_extension(_this->node()).clear_python_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_net_python_tag -// Access: Published -// Description: Returns the Python object that has been defined on -// this node, or the nearest ancestor node, for the -// indicated key. If no value has been defined for the -// indicated key on any ancestor node, returns None. -// See also get_python_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the Python object that has been defined on this node, or the + * nearest ancestor node, for the indicated key. If no value has been defined + * for the indicated key on any ancestor node, returns None. See also + * get_python_tag(). + */ INLINE PyObject *Extension:: get_net_python_tag(const string &key) const { NodePath tag_np = find_net_python_tag(key); return invoke_extension(&tag_np).get_python_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::has_net_python_tag -// Access: Published -// Description: Returns true if the indicated Python object has been -// defined on this node or on any ancestor node, or -// false otherwise. See also has_python_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated Python object has been defined on this node + * or on any ancestor node, or false otherwise. See also has_python_tag(). + */ INLINE bool Extension:: has_net_python_tag(const string &key) const { return !find_net_python_tag(key).is_empty(); diff --git a/panda/src/pgraph/nodePath_ext.cxx b/panda/src/pgraph/nodePath_ext.cxx index d38164d3ba..c13ec6326d 100644 --- a/panda/src/pgraph/nodePath_ext.cxx +++ b/panda/src/pgraph/nodePath_ext.cxx @@ -1,16 +1,15 @@ -// Filename: nodePath_ext.cxx -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath_ext.cxx + * @author rdb + * @date 2013-12-09 + */ #include "nodePath_ext.h" #include "typedWritable_ext.h" @@ -27,15 +26,11 @@ extern struct Dtool_PyTypedObject Dtool_LPoint3f; #endif #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: Extension::__copy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.copy(node). Unlike the NodePath copy -// constructor, this makes a duplicate copy of the -// underlying PandaNode (but shares children, instead of -// copying them or omitting them). -//////////////////////////////////////////////////////////////////// +/** + * A special Python method that is invoked by copy.copy(node). Unlike the + * NodePath copy constructor, this makes a duplicate copy of the underlying + * PandaNode (but shares children, instead of copying them or omitting them). + */ NodePath Extension:: __copy__() const { if (_this->is_empty()) { @@ -43,19 +38,15 @@ __copy__() const { return *_this; } - // If we do have a node, duplicate it, and wrap it in a new - // NodePath. + // If we do have a node, duplicate it, and wrap it in a new NodePath. return NodePath(invoke_extension(_this->node()).__copy__()); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::__deepcopy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.deepcopy(np). This calls copy_to() unless the -// NodePath is already present in the provided -// dictionary. -//////////////////////////////////////////////////////////////////// +/** + * A special Python method that is invoked by copy.deepcopy(np). This calls + * copy_to() unless the NodePath is already present in the provided + * dictionary. + */ PyObject *Extension:: __deepcopy__(PyObject *self, PyObject *memo) const { extern struct Dtool_PyTypedObject Dtool_NodePath; @@ -85,40 +76,32 @@ __deepcopy__(PyObject *self, PyObject *memo) const { return dupe; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + * + * This hooks into the native pickle and cPickle modules, but it cannot + * properly handle self-referential BAM objects. + */ PyObject *Extension:: __reduce__(PyObject *self) const { return __reduce_persist__(self, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::__reduce_persist__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This is similar to __reduce__, but it provides -// additional support for the missing persistent-state -// object needed to properly support self-referential -// BAM objects written to the pickle stream. This hooks -// into the pickle and cPickle modules implemented in -// direct/src/stdpy. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + * + * This is similar to __reduce__, but it provides additional support for the + * missing persistent-state object needed to properly support self-referential + * BAM objects written to the pickle stream. This hooks into the pickle and + * cPickle modules implemented in direct/src/stdpy. + */ PyObject *Extension:: __reduce_persist__(PyObject *self, PyObject *pickler) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. BamWriter *writer = NULL; if (pickler != NULL) { @@ -151,9 +134,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { PyObject *func; if (writer != NULL) { - // The modified pickle support: call the "persistent" version of - // this function, which receives the unpickler itself as an - // additional parameter. + // The modified pickle support: call the "persistent" version of this + // function, which receives the unpickler itself as an additional + // parameter. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream_persist"); if (func == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_NodePath_from_bam_stream_persist()"); @@ -162,8 +145,8 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { } } else { - // The traditional pickle support: call the non-persistent version - // of this function. + // The traditional pickle support: call the non-persistent version of this + // function. func = Extension::find_global_decode(this_class, "py_decode_NodePath_from_bam_stream"); if (func == NULL) { @@ -179,14 +162,11 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::find_net_python_tag -// Access: Published -// Description: Returns the lowest ancestor of this node that -// contains a tag definition with the indicated key, if -// any, or an empty NodePath if no ancestor of this node -// contains this tag definition. See set_python_tag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the lowest ancestor of this node that contains a tag definition + * with the indicated key, if any, or an empty NodePath if no ancestor of this + * node contains this tag definition. See set_python_tag(). + */ NodePath Extension:: find_net_python_tag(const string &key) const { if (_this->is_empty()) { @@ -199,23 +179,17 @@ find_net_python_tag(const string &key) const { return invoke_extension(&parent).find_net_python_tag(key); } -//////////////////////////////////////////////////////////////////// -// Function: py_decode_NodePath_from_bam_stream -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -//////////////////////////////////////////////////////////////////// +/** + * This wrapper is defined as a global function to suit pickle's needs. + */ NodePath py_decode_NodePath_from_bam_stream(const string &data) { return py_decode_NodePath_from_bam_stream_persist(NULL, data); } -//////////////////////////////////////////////////////////////////// -// Function: py_decode_NodePath_from_bam_stream_persist -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -//////////////////////////////////////////////////////////////////// +/** + * This wrapper is defined as a global function to suit pickle's needs. + */ NodePath py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &data) { BamReader *reader = NULL; @@ -233,16 +207,13 @@ py_decode_NodePath_from_bam_stream_persist(PyObject *unpickler, const string &da return NodePath::decode_from_bam_stream(data, reader); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_tight_bounds -// Access: Published -// Description: Returns the tight bounds as a 2-tuple of LPoint3 -// objects. This is a convenience function for Python -// users, among which the use of calc_tight_bounds -// may be confusing. -// -// Returns None if calc_tight_bounds returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tight bounds as a 2-tuple of LPoint3 objects. This is a + * convenience function for Python users, among which the use of + * calc_tight_bounds may be confusing. + * + * Returns None if calc_tight_bounds returned false. + */ PyObject *Extension:: get_tight_bounds(const NodePath &other) const { LPoint3 *min_point = new LPoint3; diff --git a/panda/src/pgraph/nodePath_ext.h b/panda/src/pgraph/nodePath_ext.h index 67afe2a383..93573ed6ad 100644 --- a/panda/src/pgraph/nodePath_ext.h +++ b/panda/src/pgraph/nodePath_ext.h @@ -1,16 +1,15 @@ -// Filename: nodePath_ext.h -// Created by: rdb (09Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodePath_ext.h + * @author rdb + * @date 2013-12-09 + */ #ifndef NODEPATH_EXT_H #define NODEPATH_EXT_H @@ -23,12 +22,10 @@ #include "nodePath.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// NodePath, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for NodePath, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pgraph/occluderEffect.I b/panda/src/pgraph/occluderEffect.I index 3073000d37..bd4f118489 100644 --- a/panda/src/pgraph/occluderEffect.I +++ b/panda/src/pgraph/occluderEffect.I @@ -1,81 +1,64 @@ -// Filename: occluderEffect.I -// Created by: drose (17Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderEffect.I + * @author drose + * @date 2011-03-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::Constructor -// Access: Protected -// Description: Use OccluderEffect::make() to construct a new -// OccluderEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use OccluderEffect::make() to construct a new OccluderEffect object. + */ INLINE OccluderEffect:: OccluderEffect() { } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::Copy Constructor -// Access: Protected -// Description: Use OccluderEffect::make() to construct a new -// OccluderEffect object. The copy constructor is only -// defined to facilitate methods like add_on_occluder(). -//////////////////////////////////////////////////////////////////// +/** + * Use OccluderEffect::make() to construct a new OccluderEffect object. The + * copy constructor is only defined to facilitate methods like + * add_on_occluder(). + */ INLINE OccluderEffect:: OccluderEffect(const OccluderEffect ©) : _on_occluders(copy._on_occluders) { } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::get_num_on_occluders -// Access: Published -// Description: Returns the number of occluders that are enabled by -// the effectute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of occluders that are enabled by the effectute. + */ INLINE int OccluderEffect:: get_num_on_occluders() const { return _on_occluders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::get_on_occluder -// Access: Published -// Description: Returns the nth occluder enabled by the effectute, -// sorted in render order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth occluder enabled by the effectute, sorted in render order. + */ INLINE NodePath OccluderEffect:: get_on_occluder(int n) const { nassertr(n >= 0 && n < (int)_on_occluders.size(), NodePath::fail()); return _on_occluders[n]; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::has_on_occluder -// Access: Published -// Description: Returns true if the indicated occluder is enabled by -// the effect, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated occluder is enabled by the effect, false + * otherwise. + */ INLINE bool OccluderEffect:: has_on_occluder(const NodePath &occluder) const { return _on_occluders.find(occluder) != _on_occluders.end(); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::is_identity -// Access: Published -// Description: Returns true if this is an identity effect: it does -// not change the set of occluders in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an identity effect: it does not change the set of + * occluders in use. + */ INLINE bool OccluderEffect:: is_identity() const { return _on_occluders.empty(); diff --git a/panda/src/pgraph/occluderEffect.cxx b/panda/src/pgraph/occluderEffect.cxx index 60a5ab0e9c..d66c5d75ed 100644 --- a/panda/src/pgraph/occluderEffect.cxx +++ b/panda/src/pgraph/occluderEffect.cxx @@ -1,16 +1,15 @@ -// Filename: occluderEffect.cxx -// Created by: drose (17Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderEffect.cxx + * @author drose + * @date 2011-03-17 + */ #include "occluderEffect.h" #include "pandaNode.h" @@ -25,16 +24,13 @@ CPT(RenderEffect) OccluderEffect::_empty_effect; TypeHandle OccluderEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::make -// Access: Published, Static -// Description: Constructs a new OccluderEffect object that does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new OccluderEffect object that does nothing. + */ CPT(RenderEffect) OccluderEffect:: make() { - // We make it a special case and store a pointer to the empty effect - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty effect forever + // once we find it the first time, as an optimization. if (_empty_effect == (RenderEffect *)NULL) { _empty_effect = return_new(new OccluderEffect); } @@ -42,32 +38,26 @@ make() { return _empty_effect; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::add_on_occluder -// Access: Published -// Description: Returns a new OccluderEffect, just like this one, but -// with the indicated occluder added to the list of occluders -// enabled by this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new OccluderEffect, just like this one, but with the indicated + * occluder added to the list of occluders enabled by this effect. + */ CPT(RenderEffect) OccluderEffect:: add_on_occluder(const NodePath &occluder) const { nassertr(!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type()), this); OccluderEffect *effect = new OccluderEffect(*this); effect->_on_occluders.insert(occluder); - pair insert_result = + pair insert_result = effect->_on_occluders.insert(Occluders::value_type(occluder)); return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::remove_on_occluder -// Access: Published -// Description: Returns a new OccluderEffect, just like this one, but -// with the indicated occluder removed from the list of -// occluders enabled by this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new OccluderEffect, just like this one, but with the indicated + * occluder removed from the list of occluders enabled by this effect. + */ CPT(RenderEffect) OccluderEffect:: remove_on_occluder(const NodePath &occluder) const { nassertr(!occluder.is_empty() && occluder.node()->is_of_type(OccluderNode::get_class_type()), this); @@ -76,11 +66,9 @@ remove_on_occluder(const NodePath &occluder) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void OccluderEffect:: output(ostream &out) const { out << get_type() << ":"; @@ -88,7 +76,7 @@ output(ostream &out) const { out << "identity"; } else { out << "on"; - + Occluders::const_iterator li; for (li = _on_occluders.begin(); li != _on_occluders.end(); ++li) { NodePath occluder = (*li); @@ -97,21 +85,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived OccluderEffect -// types to return a unique number indicating whether -// this OccluderEffect is equivalent to the other one. -// -// This should return 0 if the two OccluderEffect -// objects are equivalent, a number less than zero if -// this one should be sorted before the other one, and a -// number greater than zero otherwise. -// -// This will only be called with two OccluderEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived OccluderEffect types to return a + * unique number indicating whether this OccluderEffect is equivalent to the + * other one. + * + * This should return 0 if the two OccluderEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two OccluderEffect objects whose get_type() + * functions return the same. + */ int OccluderEffect:: compare_to_impl(const RenderEffect *other) const { const OccluderEffect *ta; @@ -139,27 +124,22 @@ compare_to_impl(const RenderEffect *other) const { if (oli != ta->_on_occluders.end()) { return -1; } - + return 0; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// OccluderEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type OccluderEffect. + */ void OccluderEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void OccluderEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); @@ -173,13 +153,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int OccluderEffect:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderEffect::complete_pointers(p_list, manager); @@ -217,29 +194,22 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool OccluderEffect:: require_fully_complete() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type OccluderEffect is encountered -// in the Bam file. It should create the OccluderEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type OccluderEffect is encountered in the Bam file. It should create the + * OccluderEffect and extract its information from the file. + */ TypedWritable *OccluderEffect:: make_from_bam(const FactoryParams ¶ms) { OccluderEffect *effect = new OccluderEffect; @@ -252,19 +222,16 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new OccluderEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new OccluderEffect. + */ void OccluderEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); - // Push back an empty NodePath for each Occluder for now, until we - // get the actual list of pointers later in complete_pointers(). + // Push back an empty NodePath for each Occluder for now, until we get the + // actual list of pointers later in complete_pointers(). int num_on_occluders = scan.get_uint16(); _on_occluders.resize(num_on_occluders); if (manager->get_file_minor_ver() >= 40) { diff --git a/panda/src/pgraph/occluderEffect.h b/panda/src/pgraph/occluderEffect.h index 47ecb8b5d2..af2230832f 100644 --- a/panda/src/pgraph/occluderEffect.h +++ b/panda/src/pgraph/occluderEffect.h @@ -1,16 +1,15 @@ -// Filename: occluderEffect.h -// Created by: drose (17Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderEffect.h + * @author drose + * @date 2011-03-17 + */ #ifndef OCCLUDEREFFECT_H #define OCCLUDEREFFECT_H @@ -23,16 +22,13 @@ #include "ordered_vector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : OccluderEffect -// Description : This functions similarly to a LightAttrib or -// ClipPlaneAttrib. It indicates the set of occluders -// that modify the geometry at this level and below. -// Unlike a ClipPlaneAttrib, an OccluderEffect takes -// effect immediately when it is encountered during -// traversal, and thus can only add occluders; it may -// not remove them. -//////////////////////////////////////////////////////////////////// +/** + * This functions similarly to a LightAttrib or ClipPlaneAttrib. It indicates + * the set of occluders that modify the geometry at this level and below. + * Unlike a ClipPlaneAttrib, an OccluderEffect takes effect immediately when + * it is encountered during traversal, and thus can only add occluders; it may + * not remove them. + */ class EXPCL_PANDA_PGRAPH OccluderEffect : public RenderEffect { private: INLINE OccluderEffect(); @@ -77,7 +73,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -99,4 +95,3 @@ private: #include "occluderEffect.I" #endif - diff --git a/panda/src/pgraph/occluderNode.I b/panda/src/pgraph/occluderNode.I index 1e47ce5ffa..11ecea9b5c 100644 --- a/panda/src/pgraph/occluderNode.I +++ b/panda/src/pgraph/occluderNode.I @@ -1,25 +1,21 @@ -// Filename: occluderNode.I -// Created by: jenes (11Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderNode.I + * @author jenes + * @date 2011-03-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::set_vertices -// Access: Published -// Description: Replaces the four vertices of the occluder polygon. -// The vertices should be defined in a counterclockwise -// orientation when looking at the face of the occluder. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the four vertices of the occluder polygon. The vertices should be + * defined in a counterclockwise orientation when looking at the face of the + * occluder. + */ INLINE void OccluderNode:: set_vertices(const LPoint3 &v0, const LPoint3 &v1, const LPoint3 &v2, const LPoint3 &v3) { @@ -31,63 +27,50 @@ set_vertices(const LPoint3 &v0, const LPoint3 &v1, _vertices.push_back(v3); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_num_vertices -// Access: Published -// Description: Returns the number of vertices in the occluder -// polygon. This should always return 4. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the occluder polygon. This should always + * return 4. + */ INLINE int OccluderNode:: get_num_vertices() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_vertex -// Access: Published -// Description: Returns the nth vertex of the occluder polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the occluder polygon. + */ INLINE const LPoint3 &OccluderNode:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero()); return _vertices[n]; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::set_double_sided -// Access: Published -// Description: If true, the back-face will also be used to occlude -//////////////////////////////////////////////////////////////////// +/** + * If true, the back-face will also be used to occlude + */ INLINE void OccluderNode::set_double_sided(bool value) { _double_sided = value; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::is_double_sided -// Access: Published -// Description: Is this occluder double-sided -//////////////////////////////////////////////////////////////////// +/** + * Is this occluder double-sided + */ INLINE bool OccluderNode::is_double_sided() { return _double_sided; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::set_min_coverage -// Access: Published -// Description: Minimum screen coverage needed before occluder used. -// Range should be 0 to 1. For example, setting to 0.2 -// would mean that the occluder needs to cover 20% of -// the screen to be considered. -//////////////////////////////////////////////////////////////////// +/** + * Minimum screen coverage needed before occluder used. Range should be 0 to + * 1. For example, setting to 0.2 would mean that the occluder needs to cover + * 20% of the screen to be considered. + */ INLINE void OccluderNode::set_min_coverage(PN_stdfloat value) { _min_coverage = value; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_min_coverage -// Access: Published -// Description: Returns the minimum screen coverage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum screen coverage. + */ INLINE PN_stdfloat OccluderNode::get_min_coverage() { return _min_coverage; } diff --git a/panda/src/pgraph/occluderNode.cxx b/panda/src/pgraph/occluderNode.cxx index 543c3eb906..c1a4c4d9da 100644 --- a/panda/src/pgraph/occluderNode.cxx +++ b/panda/src/pgraph/occluderNode.cxx @@ -1,16 +1,15 @@ -// Filename: occluderNode.cxx -// Created by: jenes (11Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderNode.cxx + * @author jenes + * @date 2011-03-11 + */ #include "occluderNode.h" @@ -45,15 +44,12 @@ TypeHandle OccluderNode::_type_handle; PT(Texture) OccluderNode::_viz_tex; -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::Constructor -// Access: Public -// Description: The default constructor creates a default occlusion -// polygon in the XZ plane (or XY plane in a y-up -// coordinate system). Use the normal Panda set_pos(), -// set_hpr(), set_scale() to position it appropriately, -// or replace the vertices with set_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * The default constructor creates a default occlusion polygon in the XZ plane + * (or XY plane in a y-up coordinate system). Use the normal Panda set_pos(), + * set_hpr(), set_scale() to position it appropriately, or replace the + * vertices with set_vertices(). + */ OccluderNode:: OccluderNode(const string &name) : PandaNode(name) @@ -69,11 +65,9 @@ OccluderNode(const string &name) : LPoint3::rfu(-1.0, 0.0, 1.0)); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OccluderNode:: OccluderNode(const OccluderNode ©) : PandaNode(copy), @@ -83,47 +77,36 @@ OccluderNode(const OccluderNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OccluderNode:: ~OccluderNode() { } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *OccluderNode:: make_copy() const { return new OccluderNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::preserve_name -// Access: Public, Virtual -// Description: Returns true if the node's name has extrinsic meaning -// and must be preserved across a flatten operation, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node's name has extrinsic meaning and must be preserved + * across a flatten operation, false otherwise. + */ bool OccluderNode:: preserve_name() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void OccluderNode:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -135,35 +118,28 @@ xform(const LMatrix4 &mat) { } } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool OccluderNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // Normally, an OccluderNode is invisible. But if someone shows it, - // we will draw a visualization, a checkerboard-textured polygon. + // Normally, an OccluderNode is invisible. But if someone shows it, we will + // draw a visualization, a checkerboard-textured polygon. CullableObject *occluder_viz = new CullableObject(get_occluder_viz(trav, data), get_occluder_viz_state(trav, data), data.get_internal_transform(trav)); @@ -180,43 +156,33 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool OccluderNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void OccluderNode:: output(ostream &out) const { PandaNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void OccluderNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -226,8 +192,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, PT(BoundingVolume) bound = new BoundingSphere; GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); - // Now actually compute the bounding volume by putting it around all - // of our vertices. + // Now actually compute the bounding volume by putting it around all of our + // vertices. if (!_vertices.empty()) { const LPoint3 *vertices_begin = &_vertices[0]; const LPoint3 *vertices_end = vertices_begin + _vertices.size(); @@ -238,12 +204,10 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_occluder_viz -// Access: Protected -// Description: Returns a Geom that represents the visualization of -// the OccluderNode, as seen from the front. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Geom that represents the visualization of the OccluderNode, as + * seen from the front. + */ PT(Geom) OccluderNode:: get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { if (_occluder_viz == (Geom *)NULL) { @@ -301,17 +265,14 @@ get_occluder_viz(CullTraverser *trav, CullTraverserData &data) { return _occluder_viz; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_occluder_viz_state -// Access: Protected -// Description: Returns the RenderState to apply to the visualization. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderState to apply to the visualization. + */ CPT(RenderState) OccluderNode:: get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { if (_viz_tex == NULL) { - // Create a default texture. We set it up as a 2x2 graytone - // checkerboard, since that's real easy, and it doesn't look like - // a CollisionPolygon. + // Create a default texture. We set it up as a 2x2 graytone checkerboard, + // since that's real easy, and it doesn't look like a CollisionPolygon. _viz_tex = new Texture("occluder_viz"); _viz_tex->setup_2d_texture(2, 2, Texture::T_unsigned_byte, Texture::F_luminance); PTA_uchar image; @@ -341,11 +302,9 @@ get_occluder_viz_state(CullTraverser *trav, CullTraverserData &data) { return state->compose(viz_state); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::get_frame_viz_state -// Access: Protected -// Description: Returns the RenderState to apply to the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderState to apply to the frame. + */ CPT(RenderState) OccluderNode:: get_frame_viz_state(CullTraverser *trav, CullTraverserData &data) { static CPT(RenderState) viz_state; @@ -359,23 +318,18 @@ get_frame_viz_state(CullTraverser *trav, CullTraverserData &data) { return data._state->compose(viz_state); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// OccluderNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type OccluderNode. + */ void OccluderNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void OccluderNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -388,13 +342,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int OccluderNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -402,14 +353,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type OccluderNode is encountered -// in the Bam file. It should create the OccluderNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type OccluderNode is encountered in the Bam file. It should create the + * OccluderNode and extract its information from the file. + */ TypedWritable *OccluderNode:: make_from_bam(const FactoryParams ¶ms) { OccluderNode *node = new OccluderNode(""); @@ -422,13 +370,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: OccluderNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new OccluderNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new OccluderNode. + */ void OccluderNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/occluderNode.h b/panda/src/pgraph/occluderNode.h index 8bae1497c4..92e15e4b8d 100644 --- a/panda/src/pgraph/occluderNode.h +++ b/panda/src/pgraph/occluderNode.h @@ -1,16 +1,15 @@ -// Filename: occluderNode.h -// Created by: jenes (11Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file occluderNode.h + * @author jenes + * @date 2011-03-11 + */ #ifndef OCCLUDERNODE_H #define OCCLUDERNODE_H @@ -23,15 +22,12 @@ #include "geom.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : OccluderNode -// Description : A node in the scene graph that can hold an -// occluder polygon, which must be a rectangle. When -// the occluder is activated with something like -// render.set_occluder(), then objects whose bouding -// volume lies entirely behind the occluder will not be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * A node in the scene graph that can hold an occluder polygon, which must be + * a rectangle. When the occluder is activated with something like + * render.set_occluder(), then objects whose bouding volume lies entirely + * behind the occluder will not be rendered. + */ class EXPCL_PANDA_PGRAPH OccluderNode : public PandaNode { PUBLISHED: OccluderNode(const string &name); diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index 3a1f0c86de..c493ef08f3 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -1,41 +1,33 @@ -// Filename: pandaNode.I -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNode.I + * @author drose + * @date 2002-02-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_num_parents -// Access: Published -// Description: Returns the number of parent nodes this node has. If -// this number is greater than 1, the node has been -// multiply instanced. The order of the parent nodes is -// not meaningful and is not related to the order in -// which the node was instanced to them. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parent nodes this node has. If this number is + * greater than 1, the node has been multiply instanced. The order of the + * parent nodes is not meaningful and is not related to the order in which the + * node was instanced to them. + */ INLINE int PandaNode:: get_num_parents(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->get_up()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_parent -// Access: Published -// Description: Returns the nth parent node of this node. See -// get_num_parents(). Also see get_parents(), if your -// intention is to iterate through the complete list of -// parents; get_parents() is preferable in this case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent node of this node. See get_num_parents(). Also see + * get_parents(), if your intention is to iterate through the complete list of + * parents; get_parents() is preferable in this case. + */ INLINE PandaNode *PandaNode:: get_parent(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -44,40 +36,32 @@ get_parent(int n, Thread *current_thread) const { return (*up)[n].get_parent(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::find_parent -// Access: Published -// Description: Returns the index of the indicated parent node, if it -// is a parent, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated parent node, if it is a parent, or -1 if + * it is not. + */ INLINE int PandaNode:: find_parent(PandaNode *node, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return do_find_parent(node, cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_num_children -// Access: Published -// Description: Returns the number of child nodes this node has. The -// order of the child nodes *is* meaningful and is based -// on the sort number that was passed to add_child(), -// and also on the order in which the nodes were added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child nodes this node has. The order of the child + * nodes *is* meaningful and is based on the sort number that was passed to + * add_child(), and also on the order in which the nodes were added. + */ INLINE int PandaNode:: get_num_children(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->get_down()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_child -// Access: Published -// Description: Returns the nth child node of this node. See -// get_num_children(). Also see get_children(), if your -// intention is to iterate through the complete list of -// children; get_children() is preferable in this case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child node of this node. See get_num_children(). Also see + * get_children(), if your intention is to iterate through the complete list + * of children; get_children() is preferable in this case. + */ INLINE PandaNode *PandaNode:: get_child(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -86,13 +70,10 @@ get_child(int n, Thread *current_thread) const { return (*down)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_child_sort -// Access: Published -// Description: Returns the sort index of the nth child node of this -// node (that is, the number that was passed to -// add_child()). See get_num_children(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth child node of this node (that is, the + * number that was passed to add_child()). See get_num_children(). + */ INLINE int PandaNode:: get_child_sort(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -101,34 +82,27 @@ get_child_sort(int n, Thread *current_thread) const { return (*down)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::find_child -// Access: Published -// Description: Returns the index of the indicated child node, if it -// is a child, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated child node, if it is a child, or -1 if + * it is not. + */ INLINE int PandaNode:: find_child(PandaNode *node, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return do_find_child(node, cdata->get_down()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::stash_child -// Access: Published -// Description: Stashes the indicated child node. This removes the -// child from the list of active children and puts it on -// a special list of stashed children. This child node -// no longer contributes to the bounding volume of the -// PandaNode, and is not visited in normal traversals. -// It is invisible and uncollidable. The child may -// later be restored by calling unstash_child(). -// -// This function returns true if the child node was -// successfully stashed, or false if it was not a child -// of the node in the first place (e.g. it was -// previously stashed). -//////////////////////////////////////////////////////////////////// +/** + * Stashes the indicated child node. This removes the child from the list of + * active children and puts it on a special list of stashed children. This + * child node no longer contributes to the bounding volume of the PandaNode, + * and is not visited in normal traversals. It is invisible and uncollidable. + * The child may later be restored by calling unstash_child(). + * + * This function returns true if the child node was successfully stashed, or + * false if it was not a child of the node in the first place (e.g. it was + * previously stashed). + */ INLINE bool PandaNode:: stash_child(PandaNode *child_node, Thread *current_thread) { int child_index = find_child(child_node, current_thread); @@ -139,22 +113,17 @@ stash_child(PandaNode *child_node, Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::unstash_child -// Access: Published -// Description: Returns the indicated stashed node to normal child -// status. This removes the child from the list of -// stashed children and puts it on the normal list of -// active children. This child node once again -// contributes to the bounding volume of the PandaNode, -// and will be visited in normal traversals. It is -// visible and collidable. -// -// This function returns true if the child node was -// successfully stashed, or false if it was not a child -// of the node in the first place (e.g. it was -// previously stashed). -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated stashed node to normal child status. This removes + * the child from the list of stashed children and puts it on the normal list + * of active children. This child node once again contributes to the bounding + * volume of the PandaNode, and will be visited in normal traversals. It is + * visible and collidable. + * + * This function returns true if the child node was successfully stashed, or + * false if it was not a child of the node in the first place (e.g. it was + * previously stashed). + */ INLINE bool PandaNode:: unstash_child(PandaNode *child_node, Thread *current_thread) { int stashed_index = find_stashed(child_node, current_thread); @@ -165,28 +134,22 @@ unstash_child(PandaNode *child_node, Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_num_stashed -// Access: Published -// Description: Returns the number of stashed nodes this node has. -// These are former children of the node that have been -// moved to the special stashed list via stash_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stashed nodes this node has. These are former + * children of the node that have been moved to the special stashed list via + * stash_child(). + */ INLINE int PandaNode:: get_num_stashed(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->get_stashed()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_stashed -// Access: Published -// Description: Returns the nth stashed child of this node. See -// get_num_stashed(). Also see get_stashed(), if your -// intention is to iterate through the complete list of -// stashed children; get_stashed() is preferable in this -// case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stashed child of this node. See get_num_stashed(). Also + * see get_stashed(), if your intention is to iterate through the complete + * list of stashed children; get_stashed() is preferable in this case. + */ INLINE PandaNode *PandaNode:: get_stashed(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -195,13 +158,10 @@ get_stashed(int n, Thread *current_thread) const { return (*stashed)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_stashed_sort -// Access: Published -// Description: Returns the sort index of the nth stashed node of this -// node (that is, the number that was passed to -// add_child()). See get_num_stashed(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth stashed node of this node (that is, the + * number that was passed to add_child()). See get_num_stashed(). + */ INLINE int PandaNode:: get_stashed_sort(int n, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -210,82 +170,65 @@ get_stashed_sort(int n, Thread *current_thread) const { return (*stashed)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::find_stashed -// Access: Published -// Description: Returns the index of the indicated stashed node, if -// it is a stashed child, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated stashed node, if it is a stashed child, + * or -1 if it is not. + */ INLINE int PandaNode:: find_stashed(PandaNode *node, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return do_find_child(node, cdata->get_stashed()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_attrib -// Access: Published -// Description: Returns the render attribute of the indicated type, -// if it is defined on the node, or NULL if it is not. -// This checks only what is set on this particular node -// level, and has nothing to do with what render -// attributes may be inherited from parent nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render attribute of the indicated type, if it is defined on the + * node, or NULL if it is not. This checks only what is set on this + * particular node level, and has nothing to do with what render attributes + * may be inherited from parent nodes. + */ INLINE CPT(RenderAttrib) PandaNode:: get_attrib(TypeHandle type) const { CDReader cdata(_cycler); return cdata->_state->get_attrib(type); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_attrib -// Access: Published -// Description: Returns the render attribute of the indicated type, -// if it is defined on the node, or NULL if it is not. -// This checks only what is set on this particular node -// level, and has nothing to do with what render -// attributes may be inherited from parent nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render attribute of the indicated type, if it is defined on the + * node, or NULL if it is not. This checks only what is set on this + * particular node level, and has nothing to do with what render attributes + * may be inherited from parent nodes. + */ INLINE CPT(RenderAttrib) PandaNode:: get_attrib(int slot) const { CDReader cdata(_cycler); return cdata->_state->get_attrib(slot); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_attrib -// Access: Published -// Description: Returns true if there is a render attribute of the -// indicated type defined on this node, or false if -// there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a render attribute of the indicated type defined + * on this node, or false if there is not. + */ INLINE bool PandaNode:: has_attrib(TypeHandle type) const { CDReader cdata(_cycler); return cdata->_state->has_attrib(type); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_attrib -// Access: Published -// Description: Returns true if there is a render attribute of the -// indicated type defined on this node, or false if -// there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a render attribute of the indicated type defined + * on this node, or false if there is not. + */ INLINE bool PandaNode:: has_attrib(int slot) const { CDReader cdata(_cycler); return cdata->_state->has_attrib(slot); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_attrib -// Access: Published -// Description: Removes the render attribute of the given type from -// this node. This node, and the subgraph below, will -// now inherit the indicated render attribute from the -// nodes above this one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the render attribute of the given type from this node. This node, + * and the subgraph below, will now inherit the indicated render attribute + * from the nodes above this one. + */ INLINE void PandaNode:: clear_attrib(TypeHandle type) { RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); @@ -293,12 +236,10 @@ clear_attrib(TypeHandle type) { clear_attrib(slot); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_effect -// Access: Published -// Description: Returns the render effect of the indicated type, -// if it is defined on the node, or NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render effect of the indicated type, if it is defined on the + * node, or NULL if it is not. + */ INLINE CPT(RenderEffect) PandaNode:: get_effect(TypeHandle type) const { CDReader cdata(_cycler); @@ -309,13 +250,10 @@ get_effect(TypeHandle type) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_effect -// Access: Published -// Description: Returns true if there is a render effect of the -// indicated type defined on this node, or false if -// there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a render effect of the indicated type defined on + * this node, or false if there is not. + */ INLINE bool PandaNode:: has_effect(TypeHandle type) const { CDReader cdata(_cycler); @@ -323,116 +261,90 @@ has_effect(TypeHandle type) const { return (index >= 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_state -// Access: Published -// Description: Returns the complete RenderState that will be applied -// to all nodes at this level and below, as set on this -// node. This returns only the RenderState set on this -// particular node, and has nothing to do with state -// that might be inherited from above. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete RenderState that will be applied to all nodes at this + * level and below, as set on this node. This returns only the RenderState + * set on this particular node, and has nothing to do with state that might be + * inherited from above. + */ INLINE CPT(RenderState) PandaNode:: get_state(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_state.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_state -// Access: Published -// Description: Resets this node to leave the render state alone. -// Nodes at this level and below will once again inherit -// their render state unchanged from the nodes above -// this level. -//////////////////////////////////////////////////////////////////// +/** + * Resets this node to leave the render state alone. Nodes at this level and + * below will once again inherit their render state unchanged from the nodes + * above this level. + */ INLINE void PandaNode:: clear_state(Thread *current_thread) { set_state(RenderState::make_empty(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_effects -// Access: Published -// Description: Returns the complete RenderEffects that will be -// applied to this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete RenderEffects that will be applied to this node. + */ INLINE CPT(RenderEffects) PandaNode:: get_effects(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_effects; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_effects -// Access: Published -// Description: Resets this node to have no render effects. -//////////////////////////////////////////////////////////////////// +/** + * Resets this node to have no render effects. + */ INLINE void PandaNode:: clear_effects(Thread *current_thread) { set_effects(RenderEffects::make_empty(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_transform -// Access: Published -// Description: Returns the transform that has been set on this -// particular node. This is not the net transform from -// the root, but simply the transform on this particular -// node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform that has been set on this particular node. This is + * not the net transform from the root, but simply the transform on this + * particular node. + */ INLINE CPT(TransformState) PandaNode:: get_transform(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_transform.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_transform -// Access: Published -// Description: Resets the transform on this node to the identity -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Resets the transform on this node to the identity transform. + */ INLINE void PandaNode:: clear_transform(Thread *current_thread) { set_transform(TransformState::make_identity(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_prev_transform -// Access: Published -// Description: Returns the transform that has been set as this -// node's "previous" position. See -// set_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform that has been set as this node's "previous" position. + * See set_prev_transform(). + */ INLINE CPT(TransformState) PandaNode:: get_prev_transform(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_prev_transform.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_dirty_prev_transform -// Access: Published -// Description: Returns true if this node has the -// _dirty_prev_transform flag set, which indicates its -// _prev_transform is different from its _transform -// value (in pipeline stage 0). In this case, the node -// will be visited by reset_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node has the _dirty_prev_transform flag set, which + * indicates its _prev_transform is different from its _transform value (in + * pipeline stage 0). In this case, the node will be visited by + * reset_prev_transform(). + */ INLINE bool PandaNode:: has_dirty_prev_transform() const { return _dirty_prev_transform; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_tag -// Access: Published -// Description: Retrieves the user-defined value that was previously -// set on this node for the particular key, if any. If -// no value has been previously set, returns the empty -// string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the user-defined value that was previously set on this node for + * the particular key, if any. If no value has been previously set, returns + * the empty string. + */ INLINE string PandaNode:: get_tag(const string &key, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -444,13 +356,11 @@ get_tag(const string &key, Thread *current_thread) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_tag -// Access: Published -// Description: Returns true if a value has been defined on this node -// for the particular key (even if that value is the -// empty string), or false if no value has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value has been defined on this node for the particular + * key (even if that value is the empty string), or false if no value has been + * set. + */ INLINE bool PandaNode:: has_tag(const string &key, Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -459,12 +369,10 @@ has_tag(const string &key, Thread *current_thread) const { return (ti != cdata->_tag_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_tags -// Access: Published -// Description: Returns true if the node has any tags (or any Python -// tags) at all, false if it has none. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has any tags (or any Python tags) at all, false if + * it has none. + */ INLINE bool PandaNode:: has_tags() const { CDReader cdata(_cycler); @@ -479,67 +387,51 @@ has_tags() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::ls -// Access: Published -// Description: Lists all the nodes at and below the current path -// hierarchically. -//////////////////////////////////////////////////////////////////// +/** + * Lists all the nodes at and below the current path hierarchically. + */ INLINE void PandaNode:: ls(ostream &out, int indent_level) const { r_list_descendants(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_overall_bit -// Access: Published, Static -// Description: Returns the special bit that, when specifically -// cleared in the node's DrawMask, indicates that the -// node is hidden to all cameras, regardless of the -// remaining DrawMask bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the special bit that, when specifically cleared in the node's + * DrawMask, indicates that the node is hidden to all cameras, regardless of + * the remaining DrawMask bits. + */ INLINE DrawMask PandaNode:: get_overall_bit() { return _overall_bit; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_all_camera_mask -// Access: Published, Static -// Description: Returns a DrawMask that is appropriate for rendering -// to all cameras. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DrawMask that is appropriate for rendering to all cameras. + */ INLINE DrawMask PandaNode:: get_all_camera_mask() { return ~_overall_bit; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_overall_hidden -// Access: Published, Static -// Description: Returns true if the node has been hidden to all -// cameras by clearing its overall bit. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has been hidden to all cameras by clearing its + * overall bit. + */ INLINE bool PandaNode:: is_overall_hidden() const { CDReader cdata(_cycler); return ((cdata->_draw_show_mask | ~cdata->_draw_control_mask) & _overall_bit).is_zero(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_overall_hidden -// Access: Published -// Description: Sets or clears the hidden flag. When the hidden flag -// is true, the node and all of its children are -// invisible to all cameras, regardless of the setting -// of any draw masks. Setting the hidden flag to false -// restores the previous visibility as established by -// the draw masks. -// -// This actually works by twiddling the reserved -// _overall_bit in the node's draw mask, which has -// special meaning. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears the hidden flag. When the hidden flag is true, the node and + * all of its children are invisible to all cameras, regardless of the setting + * of any draw masks. Setting the hidden flag to false restores the previous + * visibility as established by the draw masks. + * + * This actually works by twiddling the reserved _overall_bit in the node's + * draw mask, which has special meaning. + */ INLINE void PandaNode:: set_overall_hidden(bool hidden) { if (hidden) { @@ -549,116 +441,91 @@ set_overall_hidden(bool hidden) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_draw_control_mask -// Access: Published -// Description: Returns the set of bits in draw_show_mask that are -// considered meaningful. See adjust_draw_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of bits in draw_show_mask that are considered meaningful. + * See adjust_draw_mask(). + */ INLINE DrawMask PandaNode:: get_draw_control_mask() const { CDReader cdata(_cycler); return cdata->_draw_control_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_draw_show_mask -// Access: Published -// Description: Returns the hide/show bits of this particular node. -// See adjust_draw_mask(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the hide/show bits of this particular node. See + * adjust_draw_mask(). + */ INLINE DrawMask PandaNode:: get_draw_show_mask() const { CDReader cdata(_cycler); return cdata->_draw_show_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_into_collide_mask -// Access: Published -// Description: Returns the "into" collide mask for this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "into" collide mask for this node. + */ INLINE CollideMask PandaNode:: get_into_collide_mask() const { CDReader cdata(_cycler); return cdata->_into_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_bounds -// Access: Published -// Description: Reverses the effect of a previous call to -// set_bounds(), and allows the node's bounding volume -// to be automatically computed once more based on the -// contents of the node. -//////////////////////////////////////////////////////////////////// +/** + * Reverses the effect of a previous call to set_bounds(), and allows the + * node's bounding volume to be automatically computed once more based on the + * contents of the node. + */ INLINE void PandaNode:: clear_bounds() { set_bounds((BoundingVolume *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_internal_bounds -// Access: Published -// Description: Returns the node's internal bounding volume. This is -// the bounding volume around the node alone, without -// including children. If the user has called -// set_bounds(), it will be the specified bounding -// volume. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node's internal bounding volume. This is the bounding volume + * around the node alone, without including children. If the user has called + * set_bounds(), it will be the specified bounding volume. + */ INLINE CPT(BoundingVolume) PandaNode:: get_internal_bounds(Thread *current_thread) const { return get_internal_bounds(current_thread->get_pipeline_stage(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_internal_vertices -// Access: Published -// Description: Returns the total number of vertices that will be -// rendered by this particular node alone, not -// accounting for its children. -// -// This may not include all vertices for certain dynamic -// effects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of vertices that will be rendered by this + * particular node alone, not accounting for its children. + * + * This may not include all vertices for certain dynamic effects. + */ INLINE int PandaNode:: get_internal_vertices(Thread *current_thread) const { return get_internal_vertices(current_thread->get_pipeline_stage(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_bounds_stale -// Access: Published -// Description: Returns true if the bounding volume of this node is -// stale and will be implicitly recomputed at the next -// call to get_bounds(), or false if it is fresh and -// need not be recomputed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the bounding volume of this node is stale and will be + * implicitly recomputed at the next call to get_bounds(), or false if it is + * fresh and need not be recomputed. + */ bool PandaNode:: is_bounds_stale() const { CDReader cdata(_cycler); return (cdata->_last_bounds_update != cdata->_next_update); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_final -// Access: Published -// Description: Sets the "final" flag on this PandaNode. If -// this is true, than no bounding volume need be tested -// below it; a positive intersection with this node's -// bounding volume is deemed to be a positive -// intersection with all geometry inside. -// -// This is useful to quickly force a larger bounding -// volume around a node when the GeomNodes themselves -// are inaccurate for some reason, without forcing a -// recompute of every nested bounding volume. It's also -// helpful when the bounding volume is tricked by some -// special properties, like billboards, that may move -// geometry out of its bounding volume otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "final" flag on this PandaNode. If this is true, than no bounding + * volume need be tested below it; a positive intersection with this node's + * bounding volume is deemed to be a positive intersection with all geometry + * inside. + * + * This is useful to quickly force a larger bounding volume around a node when + * the GeomNodes themselves are inaccurate for some reason, without forcing a + * recompute of every nested bounding volume. It's also helpful when the + * bounding volume is tricked by some special properties, like billboards, + * that may move geometry out of its bounding volume otherwise. + */ INLINE void PandaNode:: set_final(bool flag) { CDWriter cdata(_cycler); @@ -666,63 +533,51 @@ set_final(bool flag) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_final -// Access: Published -// Description: Returns the current state of the "final" flag. -// Initially, this flag is off (false), but it may be -// changed by an explicit call to set_final(). See -// set_final(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the "final" flag. Initially, this flag is off + * (false), but it may be changed by an explicit call to set_final(). See + * set_final(). + */ INLINE bool PandaNode:: is_final(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_final_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_fancy_bits -// Access: Published -// Description: Returns the union of all of the enum FancyBits values -// corresponding to the various "fancy" attributes that -// are set on the node. If this returns 0, the node has -// nothing interesting about it. This is intended to -// speed traversal by quickly skipping past nodes that -// don't particularly affect the render state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all of the enum FancyBits values corresponding to the + * various "fancy" attributes that are set on the node. If this returns 0, + * the node has nothing interesting about it. This is intended to speed + * traversal by quickly skipping past nodes that don't particularly affect the + * render state. + */ INLINE int PandaNode:: get_fancy_bits(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_fancy_bits; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_user_bounds -// Access: Protected -// Description: Returns the node's user bounding volume. This is the -// bounding volume specified with get_bounds(). This -// will return NULL if the user bounding volume has -// never been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node's user bounding volume. This is the bounding volume + * specified with get_bounds(). This will return NULL if the user bounding + * volume has never been set. + */ INLINE CPT(BoundingVolume) PandaNode:: get_user_bounds(int pipeline_stage, Thread *current_thread) const { CDStageReader cdata(_cycler, pipeline_stage, current_thread); return cdata->_user_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::mark_bounds_stale -// Access: Protected -// Description: Indicates that the bounding volume, or something that -// influences the bounding volume (or any of the other -// things stored in CData, like net_collide_mask), -// may have changed for this node, and that it must be -// recomputed. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the bounding volume, or something that influences the + * bounding volume (or any of the other things stored in CData, like + * net_collide_mask), may have changed for this node, and that it must be + * recomputed. + */ INLINE void PandaNode:: mark_bounds_stale(int pipeline_stage, Thread *current_thread) const { - // We check whether it is already marked stale. If so, we don't have - // to make the call to force_bounds_stale(). + // We check whether it is already marked stale. If so, we don't have to + // make the call to force_bounds_stale(). bool is_stale_bounds; { CDStageReader cdata(_cycler, pipeline_stage, current_thread); @@ -735,14 +590,11 @@ mark_bounds_stale(int pipeline_stage, Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::mark_internal_bounds_stale -// Access: Protected -// Description: Should be called by a derived class to mark the -// internal bounding volume stale, so that -// recompute_internal_bounds() will be called when the -// bounding volume is next requested. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to mark the internal bounding volume + * stale, so that recompute_internal_bounds() will be called when the bounding + * volume is next requested. + */ INLINE void PandaNode:: mark_internal_bounds_stale(int pipeline_stage, Thread *current_thread) { { @@ -752,70 +604,55 @@ mark_internal_bounds_stale(int pipeline_stage, Thread *current_thread) { mark_bounds_stale(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_children -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of children of the node. When you intend to -// visit multiple children, using this is slightly -// faster than calling get_child() directly on the -// PandaNode, since this object avoids reopening the -// PipelineCycler each time. -// -// This object also protects you from self-modifying -// loops (e.g. adding or removing children during -// traversal), since a virtual copy of the children is -// made ahead of time. The virtual copy is fast--it is -// a form of copy-on-write, so the list is not actually -// copied unless it is modified during the traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of children of + * the node. When you intend to visit multiple children, using this is + * slightly faster than calling get_child() directly on the PandaNode, since + * this object avoids reopening the PipelineCycler each time. + * + * This object also protects you from self-modifying loops (e.g. adding or + * removing children during traversal), since a virtual copy of the children + * is made ahead of time. The virtual copy is fast--it is a form of copy-on- + * write, so the list is not actually copied unless it is modified during the + * traversal. + */ INLINE PandaNode::Children PandaNode:: get_children(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return Children(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_stashed -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of children of the node. When you intend to -// visit multiple children, using this is slightly -// faster than calling get_stashed() directly on the -// PandaNode, since this object avoids reopening the -// PipelineCycler each time. -// -// This object also protects you from self-modifying -// loops (e.g. adding or removing children during -// traversal), since a virtual copy of the children is -// made ahead of time. The virtual copy is fast--it is -// a form of copy-on-write, so the list is not actually -// copied unless it is modified during the traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of children of + * the node. When you intend to visit multiple children, using this is + * slightly faster than calling get_stashed() directly on the PandaNode, since + * this object avoids reopening the PipelineCycler each time. + * + * This object also protects you from self-modifying loops (e.g. adding or + * removing children during traversal), since a virtual copy of the children + * is made ahead of time. The virtual copy is fast--it is a form of copy-on- + * write, so the list is not actually copied unless it is modified during the + * traversal. + */ INLINE PandaNode::Stashed PandaNode:: get_stashed(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return Stashed(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_parents -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of parents of the node, similar to -// get_children() and get_stashed(). -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of parents of + * the node, similar to get_children() and get_stashed(). + */ INLINE PandaNode::Parents PandaNode:: get_parents(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return Parents(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::do_find_parent -// Access: Private -// Description: The private implementation of find_parent(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of find_parent(). + */ INLINE int PandaNode:: do_find_parent(PandaNode *node, const CData *cdata) const { CPT(Up) up = cdata->get_up(); @@ -826,14 +663,11 @@ do_find_parent(PandaNode *node, const CData *cdata) const { return ui - up->begin(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::verify_child_no_cycles -// Access: Private -// Description: Ensures that attaching the indicated child node to -// this node would not introduce a cycle in the graph. -// Returns true if the attachment is valid, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that attaching the indicated child node to this node would not + * introduce a cycle in the graph. Returns true if the attachment is valid, + * false otherwise. + */ INLINE bool PandaNode:: verify_child_no_cycles(PandaNode *child_node) { #ifndef NDEBUG @@ -848,13 +682,11 @@ verify_child_no_cycles(PandaNode *child_node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::do_set_dirty_prev_transform -// Access: Private -// Description: Sets the dirty_prev_transform flag, and adds the node -// to the _dirty_prev_transforms chain. Assumes -// _dirty_prev_transforms._lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dirty_prev_transform flag, and adds the node to the + * _dirty_prev_transforms chain. Assumes _dirty_prev_transforms._lock is + * already held. + */ INLINE void PandaNode:: do_set_dirty_prev_transform() { nassertv(_dirty_prev_transforms._lock.debug_is_locked()); @@ -864,13 +696,11 @@ do_set_dirty_prev_transform() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::do_clear_dirty_prev_transform -// Access: Private -// Description: Clears the dirty_prev_transform flag, and removes the node -// from the _dirty_prev_transforms chain. Assumes -// _dirty_prev_transforms._lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Clears the dirty_prev_transform flag, and removes the node from the + * _dirty_prev_transforms chain. Assumes _dirty_prev_transforms._lock is + * already held. + */ INLINE void PandaNode:: do_clear_dirty_prev_transform() { nassertv(_dirty_prev_transforms._lock.debug_is_locked()); @@ -880,11 +710,9 @@ do_clear_dirty_prev_transform() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::DownConnection::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::DownConnection:: DownConnection(PandaNode *child, int sort) : _child(child), @@ -892,90 +720,71 @@ DownConnection(PandaNode *child, int sort) : { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::DownConnection::operator < -// Access: Public -// Description: Provides a partial ordering on the children of a node -// so that they are ranked first in sort order, and then -// (by virtue of the ordered_vector) in the order they -// were added. -//////////////////////////////////////////////////////////////////// +/** + * Provides a partial ordering on the children of a node so that they are + * ranked first in sort order, and then (by virtue of the ordered_vector) in + * the order they were added. + */ INLINE bool PandaNode::DownConnection:: operator < (const DownConnection &other) const { return _sort < other._sort; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::DownConnection::get_child -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *PandaNode::DownConnection:: get_child() const { return _child; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::DownConnection::set_child -// Access: Public -// Description: This is only called by PandaNode::replace_child(). -//////////////////////////////////////////////////////////////////// +/** + * This is only called by PandaNode::replace_child(). + */ INLINE void PandaNode::DownConnection:: set_child(PandaNode *child) { _child = child; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::DownConnection::get_sort -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PandaNode::DownConnection:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::UpConnection::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::UpConnection:: UpConnection(PandaNode *parent) : _parent(parent) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::UpConnection::operator < -// Access: Public -// Description: Sorts the up connections of a node by pointer. This -// is different from the down connections of a node, -// which are sorted by the specified _sort number. This -// makes it easy to locate a particular parent of a node -// by pointer, or to test for a parent-child -// relationship given two node pointers. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the up connections of a node by pointer. This is different from the + * down connections of a node, which are sorted by the specified _sort number. + * This makes it easy to locate a particular parent of a node by pointer, or + * to test for a parent-child relationship given two node pointers. + */ INLINE bool PandaNode::UpConnection:: operator < (const UpConnection &other) const { return _parent < other._parent; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::UpConnection::get_parent -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode *PandaNode::UpConnection:: get_parent() const { return _parent; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::BoundsData::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::BoundsData:: BoundsData() : _internal_bounds(NULL), @@ -984,11 +793,9 @@ BoundsData() : ++_internal_bounds_mark; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::BoundsData::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::BoundsData:: BoundsData(const PandaNode::BoundsData ©) : _internal_bounds(copy._internal_bounds), @@ -998,11 +805,9 @@ BoundsData(const PandaNode::BoundsData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::BoundsData::copy_bounds -// Access: Protected -// Description: Copies just the BoundsData part of the structure. -//////////////////////////////////////////////////////////////////// +/** + * Copies just the BoundsData part of the structure. + */ INLINE void PandaNode::BoundsData:: copy_bounds(const PandaNode::BoundsData ©) { _internal_bounds = copy._internal_bounds; @@ -1011,13 +816,10 @@ copy_bounds(const PandaNode::BoundsData ©) { _internal_bounds_computed = copy._internal_bounds_computed; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::set_fancy_bit -// Access: Public -// Description: Internal function to set (if value is true) or clear -// (if value is false) the indicated bit(s) in the -// _fancy_bits member. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to set (if value is true) or clear (if value is false) + * the indicated bit(s) in the _fancy_bits member. + */ INLINE void PandaNode::CData:: set_fancy_bit(int bits, bool value) { if (value) { @@ -1027,149 +829,118 @@ set_fancy_bit(int bits, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::get_down -// Access: Public -// Description: Returns a read-only pointer to the _down list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the _down list. + */ INLINE CPT(PandaNode::Down) PandaNode::CData:: get_down() const { return _down.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::modify_down -// Access: Public -// Description: Returns a modifiable, unique pointer to the _down -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable, unique pointer to the _down list. + */ INLINE PT(PandaNode::Down) PandaNode::CData:: modify_down() { return _down.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::get_stashed -// Access: Public -// Description: Returns a read-only pointer to the _stashed list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the _stashed list. + */ INLINE CPT(PandaNode::Down) PandaNode::CData:: get_stashed() const { return _stashed.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::modify_stashed -// Access: Public -// Description: Returns a modifiable, unique pointer to the _stashed -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable, unique pointer to the _stashed list. + */ INLINE PT(PandaNode::Down) PandaNode::CData:: modify_stashed() { return _stashed.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::get_up -// Access: Public -// Description: Returns a read-only pointer to the _up list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a read-only pointer to the _up list. + */ INLINE CPT(PandaNode::Up) PandaNode::CData:: get_up() const { return _up.get_read_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::modify_up -// Access: Public -// Description: Returns a modifiable, unique pointer to the _up -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable, unique pointer to the _up list. + */ INLINE PT(PandaNode::Up) PandaNode::CData:: modify_up() { return _up.get_write_pointer(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Children:: Children() { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Children:: Children(const PandaNode::CData *cdata) : _down(cdata->get_down()) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Children:: Children(const PandaNode::Children ©) : _down(copy._down) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Children:: operator = (const PandaNode::Children ©) { _down = copy._down; } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Children:: Children(PandaNode::Children &&from) NOEXCEPT : _down(move(from._down)) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Children:: operator = (PandaNode::Children &&from) NOEXCEPT { _down = move(from._down); } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::get_num_children -// Access: Public -// Description: Returns the number of children of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of children of the node. + */ INLINE int PandaNode::Children:: get_num_children() const { nassertr(_down != (Down *)NULL, 0); return _down->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::get_child -// Access: Public -// Description: Returns the nth child of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of the node. + */ INLINE PandaNode *PandaNode::Children:: get_child(int n) const { nassertr(_down != (Down *)NULL, NULL); @@ -1177,13 +948,10 @@ get_child(int n) const { return (*_down)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Children::get_child_sort -// Access: Public -// Description: Returns the sort index of the nth child node of this -// node (that is, the number that was passed to -// add_child()). See get_num_children(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth child node of this node (that is, the + * number that was passed to add_child()). See get_num_children(). + */ INLINE int PandaNode::Children:: get_child_sort(int n) const { nassertr(_down != (Down *)NULL, -1); @@ -1191,86 +959,70 @@ get_child_sort(int n) const { return (*_down)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Stashed:: Stashed() { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Stashed:: Stashed(const PandaNode::CData *cdata) : _stashed(cdata->get_stashed()) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Stashed:: Stashed(const PandaNode::Stashed ©) : _stashed(copy._stashed) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Stashed:: operator = (const PandaNode::Stashed ©) { _stashed = copy._stashed; } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Stashed:: Stashed(PandaNode::Stashed &&from) NOEXCEPT : _stashed(move(from._stashed)) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Stashed:: operator = (PandaNode::Stashed &&from) NOEXCEPT { _stashed = move(from._stashed); } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::get_num_stashed -// Access: Public -// Description: Returns the number of stashed children of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stashed children of the node. + */ INLINE int PandaNode::Stashed:: get_num_stashed() const { nassertr(_stashed != (Down *)NULL, 0); return _stashed->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::get_stashed -// Access: Public -// Description: Returns the nth stashed child of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stashed child of the node. + */ INLINE PandaNode *PandaNode::Stashed:: get_stashed(int n) const { nassertr(_stashed != (Down *)NULL, NULL); @@ -1278,13 +1030,10 @@ get_stashed(int n) const { return (*_stashed)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Stashed::get_stashed_sort -// Access: Public -// Description: Returns the sort index of the nth child node of this -// node (that is, the number that was passed to -// add_child()). See get_num_stashed(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth child node of this node (that is, the + * number that was passed to add_child()). See get_num_stashed(). + */ INLINE int PandaNode::Stashed:: get_stashed_sort(int n) const { nassertr(_stashed != (Down *)NULL, -1); @@ -1292,86 +1041,70 @@ get_stashed_sort(int n) const { return (*_stashed)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Parents:: Parents() { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Parents:: Parents(const PandaNode::CData *cdata) : _up(cdata->get_up()) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Parents:: Parents(const PandaNode::Parents ©) : _up(copy._up) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Parents:: operator = (const PandaNode::Parents ©) { _up = copy._up; } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::Parents:: Parents(PandaNode::Parents &&from) NOEXCEPT : _up(move(from._up)) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNode::Parents:: operator = (PandaNode::Parents &&from) NOEXCEPT { _up = move(from._up); } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::get_num_parents -// Access: Public -// Description: Returns the number of parents of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parents of the node. + */ INLINE int PandaNode::Parents:: get_num_parents() const { nassertr(_up != (Up *)NULL, 0); return _up->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Parents::get_parent -// Access: Public -// Description: Returns the nth parent of the node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent of the node. + */ INLINE PandaNode *PandaNode::Parents:: get_parent(int n) const { nassertr(_up != (Up *)NULL, NULL); @@ -1379,11 +1112,9 @@ get_parent(int n) const { return (*_up)[n].get_parent(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNodePipelineReader:: PandaNodePipelineReader(const PandaNode *node, Thread *current_thread) : _node(node), @@ -1395,18 +1126,16 @@ PandaNodePipelineReader(const PandaNode *node, Thread *current_thread) : #endif // _DEBUG #ifdef DO_PIPELINING - // We node_ref the CData pointer, so that if anyone makes changes to - // the PandaNode while we hold this pointer, it will force a - // copy--so that this object will remain unchanged (if out-of-date). + // We node_ref the CData pointer, so that if anyone makes changes to the + // PandaNode while we hold this pointer, it will force a copy--so that this + // object will remain unchanged (if out-of-date). _cdata->node_ref(); #endif // DO_PIPELINING } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNodePipelineReader:: PandaNodePipelineReader(const PandaNodePipelineReader ©) : _node(copy._node), @@ -1424,11 +1153,9 @@ PandaNodePipelineReader(const PandaNodePipelineReader ©) : */ } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PandaNodePipelineReader:: operator = (const PandaNodePipelineReader ©) { nassertv(_current_thread == copy._current_thread); @@ -1457,11 +1184,9 @@ operator = (const PandaNodePipelineReader ©) { */ } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNodePipelineReader:: ~PandaNodePipelineReader() { /* @@ -1480,32 +1205,26 @@ INLINE PandaNodePipelineReader:: #endif // _DEBUG } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_node -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const PandaNode *PandaNodePipelineReader:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *PandaNodePipelineReader:: get_current_thread() const { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::release -// Access: Public -// Description: Releases the lock on this object. No future calls -// will be valid on this object. -//////////////////////////////////////////////////////////////////// +/** + * Releases the lock on this object. No future calls will be valid on this + * object. + */ INLINE void PandaNodePipelineReader:: release() { /* @@ -1516,12 +1235,10 @@ release() { */ } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::compose_draw_mask -// Access: Public -// Description: Computes the result of applying this node's draw -// masks to a running draw mask, as during a traversal. -//////////////////////////////////////////////////////////////////// +/** + * Computes the result of applying this node's draw masks to a running draw + * mask, as during a traversal. + */ INLINE void PandaNodePipelineReader:: compose_draw_mask(DrawMask &running_draw_mask) const { nassertv(_cdata != (PandaNode::CData *)NULL); @@ -1529,24 +1246,21 @@ compose_draw_mask(DrawMask &running_draw_mask) const { (_cdata->_draw_show_mask & _cdata->_draw_control_mask); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::compare_draw_mask -// Access: Public -// Description: Compares the running draw mask computed during a -// traversal with this node's net draw masks. Returns -// true if the node should be traversed into, or false -// if there is nothing at this level or below that will -// be visible to the indicated camera_mask. -//////////////////////////////////////////////////////////////////// +/** + * Compares the running draw mask computed during a traversal with this node's + * net draw masks. Returns true if the node should be traversed into, or + * false if there is nothing at this level or below that will be visible to + * the indicated camera_mask. + */ INLINE bool PandaNodePipelineReader:: compare_draw_mask(DrawMask running_draw_mask, DrawMask camera_mask) const { nassertr(_cdata != (PandaNode::CData *)NULL, false); nassertr(_cdata->_last_update == _cdata->_next_update, false); - // As a special case, if net_draw_show_mask is all 0, it means - // either that all nodes under this node are hidden to all cameras, - // or that none of them are renderable nodes (or some combination). - // In either case, we might as well short-circuit. + // As a special case, if net_draw_show_mask is all 0, it means either that + // all nodes under this node are hidden to all cameras, or that none of them + // are renderable nodes (or some combination). In either case, we might as + // well short-circuit. if (_cdata->_net_draw_show_mask.is_zero()) { return false; } @@ -1555,45 +1269,37 @@ compare_draw_mask(DrawMask running_draw_mask, DrawMask camera_mask) const { net_draw_control_mask = _cdata->_net_draw_control_mask; net_draw_show_mask = _cdata->_net_draw_show_mask; - // Now the bits that are not in net_draw_control_mask--that is, - // those bits that are not changed by any of the nodes at this level - // and below--are taken from running_draw_mask, which is inherited - // from above. On the other hand, the bits that *are* in - // net_draw_control_mask--those bits that are changed by any of the - // nodes at this level and below--are taken from net_draw_show_mask, - // which is propagated upwards from below. + // Now the bits that are not in net_draw_control_mask--that is, those bits + // that are not changed by any of the nodes at this level and below--are + // taken from running_draw_mask, which is inherited from above. On the + // other hand, the bits that *are* in net_draw_control_mask--those bits that + // are changed by any of the nodes at this level and below--are taken from + // net_draw_show_mask, which is propagated upwards from below. - // This way, we will traverse into this node if it has any children - // which want to be visited by the traversal, but we will avoid - // traversing into it if all of its children are hidden to this - // camera. + // This way, we will traverse into this node if it has any children which + // want to be visited by the traversal, but we will avoid traversing into it + // if all of its children are hidden to this camera. DrawMask compare_mask = (running_draw_mask & ~net_draw_control_mask) | (net_draw_show_mask & net_draw_control_mask); return !((compare_mask & PandaNode::_overall_bit).is_zero()) && !((compare_mask & camera_mask).is_zero()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_num_parents -// Access: Public -// Description: Returns the number of parent nodes this node has. If -// this number is greater than 1, the node has been -// multiply instanced. The order of the parent nodes is -// not meaningful and is not related to the order in -// which the node was instanced to them. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parent nodes this node has. If this number is + * greater than 1, the node has been multiply instanced. The order of the + * parent nodes is not meaningful and is not related to the order in which the + * node was instanced to them. + */ INLINE int PandaNodePipelineReader:: get_num_parents() const { return _cdata->get_up()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_parent -// Access: Public -// Description: Returns the nth parent node of this node. See -// get_num_parents(). Also see get_parents(), if your -// intention is to iterate through the complete list of -// parents; get_parents() is preferable in this case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parent node of this node. See get_num_parents(). Also see + * get_parents(), if your intention is to iterate through the complete list of + * parents; get_parents() is preferable in this case. + */ INLINE PandaNode *PandaNodePipelineReader:: get_parent(int n) const { CPT(PandaNode::Up) up = _cdata->get_up(); @@ -1601,38 +1307,30 @@ get_parent(int n) const { return (*up)[n].get_parent(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::find_parent -// Access: Public -// Description: Returns the index of the indicated parent node, if it -// is a parent, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated parent node, if it is a parent, or -1 if + * it is not. + */ INLINE int PandaNodePipelineReader:: find_parent(PandaNode *node) const { return _node->do_find_parent(node, _cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_num_children -// Access: Public -// Description: Returns the number of child nodes this node has. The -// order of the child nodes *is* meaningful and is based -// on the sort number that was passed to add_child(), -// and also on the order in which the nodes were added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child nodes this node has. The order of the child + * nodes *is* meaningful and is based on the sort number that was passed to + * add_child(), and also on the order in which the nodes were added. + */ INLINE int PandaNodePipelineReader:: get_num_children() const { return _cdata->get_down()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_child -// Access: Public -// Description: Returns the nth child node of this node. See -// get_num_children(). Also see get_children(), if your -// intention is to iterate through the complete list of -// children; get_children() is preferable in this case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child node of this node. See get_num_children(). Also see + * get_children(), if your intention is to iterate through the complete list + * of children; get_children() is preferable in this case. + */ INLINE PandaNode *PandaNodePipelineReader:: get_child(int n) const { CPT(PandaNode::Down) down = _cdata->get_down(); @@ -1640,13 +1338,10 @@ get_child(int n) const { return (*down)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_child_sort -// Access: Public -// Description: Returns the sort index of the nth child node of this -// node (that is, the number that was passed to -// add_child()). See get_num_children(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth child node of this node (that is, the + * number that was passed to add_child()). See get_num_children(). + */ INLINE int PandaNodePipelineReader:: get_child_sort(int n) const { CPT(PandaNode::Down) down = _cdata->get_down(); @@ -1654,38 +1349,30 @@ get_child_sort(int n) const { return (*down)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::find_child -// Access: Public -// Description: Returns the index of the indicated child node, if it -// is a child, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated child node, if it is a child, or -1 if + * it is not. + */ INLINE int PandaNodePipelineReader:: find_child(PandaNode *node) const { return _node->do_find_child(node, _cdata->get_down()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_num_stashed -// Access: Public -// Description: Returns the number of stashed nodes this node has. -// These are former children of the node that have been -// moved to the special stashed list via stash_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stashed nodes this node has. These are former + * children of the node that have been moved to the special stashed list via + * stash_child(). + */ INLINE int PandaNodePipelineReader:: get_num_stashed() const { return _cdata->get_stashed()->size(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_stashed -// Access: Public -// Description: Returns the nth stashed child of this node. See -// get_num_stashed(). Also see get_stashed(), if your -// intention is to iterate through the complete list of -// stashed children; get_stashed() is preferable in this -// case. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stashed child of this node. See get_num_stashed(). Also + * see get_stashed(), if your intention is to iterate through the complete + * list of stashed children; get_stashed() is preferable in this case. + */ INLINE PandaNode *PandaNodePipelineReader:: get_stashed(int n) const { CPT(PandaNode::Down) stashed = _cdata->get_stashed(); @@ -1693,13 +1380,10 @@ get_stashed(int n) const { return (*stashed)[n].get_child(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_stashed_sort -// Access: Public -// Description: Returns the sort index of the nth stashed node of this -// node (that is, the number that was passed to -// add_child()). See get_num_stashed(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index of the nth stashed node of this node (that is, the + * number that was passed to add_child()). See get_num_stashed(). + */ INLINE int PandaNodePipelineReader:: get_stashed_sort(int n) const { CPT(PandaNode::Down) stashed = _cdata->get_stashed(); @@ -1707,75 +1391,58 @@ get_stashed_sort(int n) const { return (*stashed)[n].get_sort(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::find_stashed -// Access: Public -// Description: Returns the index of the indicated stashed node, if -// it is a stashed child, or -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the indicated stashed node, if it is a stashed child, + * or -1 if it is not. + */ INLINE int PandaNodePipelineReader:: find_stashed(PandaNode *node) const { return _node->do_find_child(node, _cdata->get_stashed()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_state -// Access: Public -// Description: Returns the complete RenderState that will be applied -// to all nodes at this level and below, as set on this -// node. This returns only the RenderState set on this -// particular node, and has nothing to do with state -// that might be inherited from above. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete RenderState that will be applied to all nodes at this + * level and below, as set on this node. This returns only the RenderState + * set on this particular node, and has nothing to do with state that might be + * inherited from above. + */ INLINE const RenderState *PandaNodePipelineReader:: get_state() const { return _cdata->_state; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_effects -// Access: Public -// Description: Returns the complete RenderEffects that will be -// applied to this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete RenderEffects that will be applied to this node. + */ INLINE const RenderEffects *PandaNodePipelineReader:: get_effects() const { return _cdata->_effects; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_transform -// Access: Public -// Description: Returns the transform that has been set on this -// particular node. This is not the net transform from -// the root, but simply the transform on this particular -// node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform that has been set on this particular node. This is + * not the net transform from the root, but simply the transform on this + * particular node. + */ INLINE const TransformState *PandaNodePipelineReader:: get_transform() const { return _cdata->_transform; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_prev_transform -// Access: Public -// Description: Returns the transform that has been set as this -// node's "previous" position. See -// set_prev_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform that has been set as this node's "previous" position. + * See set_prev_transform(). + */ const TransformState *PandaNodePipelineReader:: get_prev_transform() const { return _cdata->_prev_transform; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_tag -// Access: Public -// Description: Retrieves the user-defined value that was previously -// set on this node for the particular key, if any. If -// no value has been previously set, returns the empty -// string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the user-defined value that was previously set on this node for + * the particular key, if any. If no value has been previously set, returns + * the empty string. + */ INLINE string PandaNodePipelineReader:: get_tag(const string &key) const { PandaNode::TagData::const_iterator ti; @@ -1786,13 +1453,11 @@ get_tag(const string &key) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::has_tag -// Access: Public -// Description: Returns true if a value has been defined on this node -// for the particular key (even if that value is the -// empty string), or false if no value has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a value has been defined on this node for the particular + * key (even if that value is the empty string), or false if no value has been + * set. + */ INLINE bool PandaNodePipelineReader:: has_tag(const string &key) const { PandaNode::TagData::const_iterator ti; @@ -1800,154 +1465,121 @@ has_tag(const string &key) const { return (ti != _cdata->_tag_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_net_collide_mask -// Access: Public -// Description: Returns the union of all into_collide_mask() values -// set at CollisionNodes at this level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all into_collide_mask() values set at CollisionNodes + * at this level and below. + */ INLINE CollideMask PandaNodePipelineReader:: get_net_collide_mask() const { nassertr(_cdata->_last_update == _cdata->_next_update, _cdata->_net_collide_mask); return _cdata->_net_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_off_clip_planes -// Access: Public -// Description: Returns a ClipPlaneAttrib which represents the union -// of all of the clip planes that have been turned *off* -// at this level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ClipPlaneAttrib which represents the union of all of the clip + * planes that have been turned *off* at this level and below. + */ INLINE CPT(RenderAttrib) PandaNodePipelineReader:: get_off_clip_planes() const { nassertr(_cdata->_last_update == _cdata->_next_update, _cdata->_off_clip_planes); return _cdata->_off_clip_planes; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_bounds -// Access: Public -// Description: Returns the external bounding volume of this node: a -// bounding volume that contains the user bounding -// volume, the internal bounding volume, and all of the -// children's bounding volumes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the external bounding volume of this node: a bounding volume that + * contains the user bounding volume, the internal bounding volume, and all of + * the children's bounding volumes. + */ INLINE CPT(BoundingVolume) PandaNodePipelineReader:: get_bounds() const { nassertr(_cdata->_last_bounds_update == _cdata->_next_update, _cdata->_external_bounds); return _cdata->_external_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_nested_vertices -// Access: Public -// Description: Returns the total number of vertices that will be -// rendered by this node and all of its descendents. -// -// This is not necessarily an accurate count of vertices -// that will actually be rendered, since this will -// include all vertices of all LOD's, and it will also -// include hidden nodes. It may also omit or only -// approximate certain kinds of dynamic geometry. -// However, it will not include stashed nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of vertices that will be rendered by this node and + * all of its descendents. + * + * This is not necessarily an accurate count of vertices that will actually be + * rendered, since this will include all vertices of all LOD's, and it will + * also include hidden nodes. It may also omit or only approximate certain + * kinds of dynamic geometry. However, it will not include stashed nodes. + */ INLINE int PandaNodePipelineReader:: get_nested_vertices() const { nassertr(_cdata->_last_bounds_update == _cdata->_next_update, _cdata->_nested_vertices); return _cdata->_nested_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::is_final -// Access: Public -// Description: Returns the current state of the "final" flag. -// Initially, this flag is off (false), but it may be -// changed by an explicit call to set_final(). See -// set_final(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the "final" flag. Initially, this flag is off + * (false), but it may be changed by an explicit call to set_final(). See + * set_final(). + */ INLINE bool PandaNodePipelineReader:: is_final() const { return _cdata->_final_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_fancy_bits -// Access: Public -// Description: Returns the union of all of the enum FancyBits values -// corresponding to the various "fancy" attributes that -// are set on the node. If this returns 0, the node has -// nothing interesting about it. This is intended to -// speed traversal by quickly skipping past nodes that -// don't particularly affect the render state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all of the enum FancyBits values corresponding to the + * various "fancy" attributes that are set on the node. If this returns 0, + * the node has nothing interesting about it. This is intended to speed + * traversal by quickly skipping past nodes that don't particularly affect the + * render state. + */ INLINE int PandaNodePipelineReader:: get_fancy_bits() const { return _cdata->_fancy_bits; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_children -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of children of the node. When you intend to -// visit multiple children, using this is slightly -// faster than calling get_child() directly on the -// PandaNode, since this object avoids reopening the -// PipelineCycler each time. -// -// This object also protects you from self-modifying -// loops (e.g. adding or removing children during -// traversal), since a virtual copy of the children is -// made ahead of time. The virtual copy is fast--it is -// a form of copy-on-write, so the list is not actually -// copied unless it is modified during the traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of children of + * the node. When you intend to visit multiple children, using this is + * slightly faster than calling get_child() directly on the PandaNode, since + * this object avoids reopening the PipelineCycler each time. + * + * This object also protects you from self-modifying loops (e.g. adding or + * removing children during traversal), since a virtual copy of the children + * is made ahead of time. The virtual copy is fast--it is a form of copy-on- + * write, so the list is not actually copied unless it is modified during the + * traversal. + */ INLINE PandaNode::Children PandaNodePipelineReader:: get_children() const { return PandaNode::Children(_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_stashed -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of children of the node. When you intend to -// visit multiple children, using this is slightly -// faster than calling get_stashed() directly on the -// PandaNode, since this object avoids reopening the -// PipelineCycler each time. -// -// This object also protects you from self-modifying -// loops (e.g. adding or removing children during -// traversal), since a virtual copy of the children is -// made ahead of time. The virtual copy is fast--it is -// a form of copy-on-write, so the list is not actually -// copied unless it is modified during the traversal. -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of children of + * the node. When you intend to visit multiple children, using this is + * slightly faster than calling get_stashed() directly on the PandaNode, since + * this object avoids reopening the PipelineCycler each time. + * + * This object also protects you from self-modifying loops (e.g. adding or + * removing children during traversal), since a virtual copy of the children + * is made ahead of time. The virtual copy is fast--it is a form of copy-on- + * write, so the list is not actually copied unless it is modified during the + * traversal. + */ INLINE PandaNode::Stashed PandaNodePipelineReader:: get_stashed() const { return PandaNode::Stashed(_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::get_parents -// Access: Public -// Description: Returns an object that can be used to walk through -// the list of parents of the node, similar to -// get_children() and get_stashed(). -//////////////////////////////////////////////////////////////////// +/** + * Returns an object that can be used to walk through the list of parents of + * the node, similar to get_children() and get_stashed(). + */ INLINE PandaNode::Parents PandaNodePipelineReader:: get_parents() const { return PandaNode::Parents(_cdata); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::BamReaderAuxDataDown::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNode::BamReaderAuxDataDown:: BamReaderAuxDataDown() : _down_list(PandaNode::get_class_type()) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index e7bd9d80c7..644696f4b3 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -1,16 +1,15 @@ -// Filename: pandaNode.cxx -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNode.cxx + * @author drose + * @date 2002-02-20 + */ #include "pandaNode.h" #include "config_pgraph.h" @@ -48,36 +47,28 @@ TypeHandle PandaNode::_type_handle; TypeHandle PandaNode::CData::_type_handle; TypeHandle PandaNodePipelineReader::_type_handle; -// -// There are two different interfaces here for making and breaking -// parent-child connections: the fundamental PandaNode interface, via -// add_child() and remove_child() (and related functions), and the -// NodePath support interface, via attach(), detach(), and reparent(). -// They both do essentially the same thing, but with slightly -// different inputs. The PandaNode interfaces try to guess which -// NodePaths should be updated as a result of the scene graph change, -// while the NodePath interfaces already know. -// -// The NodePath support interface functions are strictly called from -// within the NodePath class, and are used to implement -// NodePath::reparent_to() and NodePath::remove_node(), etc. The -// fundamental interface, on the other hand, is intended to be called -// directly by the user. -// -// The fundamental interface has a slightly lower overhead because it -// does not need to create a NodePathComponent chain where one does -// not already exist; however, the NodePath support interface is more -// useful when the NodePath already does exist, because it ensures -// that the particular NodePath calling it is kept appropriately -// up-to-date. -// +/* + * There are two different interfaces here for making and breaking parent- + * child connections: the fundamental PandaNode interface, via add_child() and + * remove_child() (and related functions), and the NodePath support interface, + * via attach(), detach(), and reparent(). They both do essentially the same + * thing, but with slightly different inputs. The PandaNode interfaces try to + * guess which NodePaths should be updated as a result of the scene graph + * change, while the NodePath interfaces already know. The NodePath support + * interface functions are strictly called from within the NodePath class, and + * are used to implement NodePath::reparent_to() and NodePath::remove_node(), + * etc. The fundamental interface, on the other hand, is intended to be + * called directly by the user. The fundamental interface has a slightly + * lower overhead because it does not need to create a NodePathComponent chain + * where one does not already exist; however, the NodePath support interface + * is more useful when the NodePath already does exist, because it ensures + * that the particular NodePath calling it is kept appropriately up-to-date. + */ -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode:: PandaNode(const string &name) : Namable(name), @@ -97,11 +88,9 @@ PandaNode(const string &name) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode:: ~PandaNode() { if (pgraph_cat.is_debug()) { @@ -115,12 +104,12 @@ PandaNode:: do_clear_dirty_prev_transform(); } - // We shouldn't have any parents left by the time we destruct, or - // there's a refcount fault somewhere. + // We shouldn't have any parents left by the time we destruct, or there's a + // refcount fault somewhere. - // Actually, that's not necessarily true anymore, since we might be - // updating a node dynamically via the bam reader, which doesn't - // necessarily keep related pairs of nodes in sync with each other. + // Actually, that's not necessarily true anymore, since we might be updating + // a node dynamically via the bam reader, which doesn't necessarily keep + // related pairs of nodes in sync with each other. /* #ifndef NDEBUG { @@ -133,13 +122,10 @@ PandaNode:: remove_all_children(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Copy Constructor -// Access: Protected -// Description: Do not call the copy constructor directly; instead, -// use make_copy() or copy_subgraph() to make a copy of -// a node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ PandaNode:: PandaNode(const PandaNode ©) : TypedWritableReferenceCount(copy), @@ -188,166 +174,127 @@ PandaNode(const PandaNode ©) : cdata->_fancy_bits = copy_cdata->_fancy_bits; #ifdef HAVE_PYTHON - // Copy and increment all of the Python objects held by the other - // node. + // Copy and increment all of the Python objects held by the other node. cdata->_python_tag_data = copy_cdata->_python_tag_data; cdata->inc_py_refs(); #endif // HAVE_PYTHON } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::Copy Assignment Operator -// Access: Private -// Description: Do not call the copy assignment operator at all. Use -// make_copy() or copy_subgraph() to make a copy of a -// node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy assignment operator at all. Use make_copy() or + * copy_subgraph() to make a copy of a node. + */ void PandaNode:: operator = (const PandaNode ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::dupe_for_flatten -// Access: Public, Virtual -// Description: This is similar to make_copy(), but it makes a copy -// for the specific purpose of flatten. Typically, this -// will be a new PandaNode with a new pointer, but all -// of the internal data will always be shared with the -// original; whereas the new node returned by -// make_copy() might not share the internal data. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to make_copy(), but it makes a copy for the specific + * purpose of flatten. Typically, this will be a new PandaNode with a new + * pointer, but all of the internal data will always be shared with the + * original; whereas the new node returned by make_copy() might not share the + * internal data. + */ PandaNode *PandaNode:: dupe_for_flatten() const { return make_copy(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of PandaNode by duplicating -// instances (by calling dupe_for_flatten()), false -// otherwise (for instance, a Camera cannot be safely -// flattened, because the Camera pointer itself is -// meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * PandaNode by duplicating instances (by calling dupe_for_flatten()), false + * otherwise (for instance, a Camera cannot be safely flattened, because the + * Camera pointer itself is meaningful). + */ bool PandaNode:: safe_to_flatten() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of PandaNode by calling the -// xform() method, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * PandaNode by calling the xform() method, false otherwise. + */ bool PandaNode:: safe_to_transform() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_modify_transform -// Access: Public, Virtual -// Description: Returns true if it is safe to automatically adjust -// the transform on this kind of node. Usually, this is -// only a bad idea if the user expects to find a -// particular transform on the node. -// -// ModelNodes with the preserve_transform flag set are -// presently the only kinds of nodes that should not -// have their transform even adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is safe to automatically adjust the transform on this + * kind of node. Usually, this is only a bad idea if the user expects to find + * a particular transform on the node. + * + * ModelNodes with the preserve_transform flag set are presently the only + * kinds of nodes that should not have their transform even adjusted. + */ bool PandaNode:: safe_to_modify_transform() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool PandaNode:: safe_to_combine() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool PandaNode:: safe_to_combine_children() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::safe_to_flatten_below -// Access: Public, Virtual -// Description: Returns true if a flatten operation may safely -// continue past this node, or false if nodes below this -// node may not be molested. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a flatten operation may safely continue past this node, or + * false if nodes below this node may not be molested. + */ bool PandaNode:: safe_to_flatten_below() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::preserve_name -// Access: Public, Virtual -// Description: Returns true if the node's name has extrinsic meaning -// and must be preserved across a flatten operation, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node's name has extrinsic meaning and must be preserved + * across a flatten operation, false otherwise. + */ bool PandaNode:: preserve_name() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_unsafe_to_apply_attribs -// Access: Public, Virtual -// Description: Returns the union of all attributes from -// SceneGraphReducer::AttribTypes that may not safely be -// applied to the vertices of this node. If this is -// nonzero, these attributes must be dropped at this -// node as a state change. -// -// This is a generalization of safe_to_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all attributes from SceneGraphReducer::AttribTypes + * that may not safely be applied to the vertices of this node. If this is + * nonzero, these attributes must be dropped at this node as a state change. + * + * This is a generalization of safe_to_transform(). + */ int PandaNode:: get_unsafe_to_apply_attribs() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::apply_attribs_to_vertices -// Access: Public, Virtual -// Description: Applies whatever attributes are specified in the -// AccumulatedAttribs object (and by the attrib_types -// bitmask) to the vertices on this node, if -// appropriate. If this node uses geom arrays like a -// GeomNode, the supplied GeomTransformer may be used to -// unify shared arrays across multiple different nodes. -// -// This is a generalization of xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ void PandaNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -366,33 +313,25 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void PandaNode:: xform(const LMatrix4 &) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::combine_with -// Access: Public, Virtual -// Description: Collapses this PandaNode with the other PandaNode, if -// possible, and returns a pointer to the combined -// PandaNode, or NULL if the two PandaNodes cannot -// safely be combined. -// -// The return value may be this, other, or a new -// PandaNode altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two PandaNodes and -// what the collapsed PandaNode should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this PandaNode with the other PandaNode, if possible, and returns + * a pointer to the combined PandaNode, or NULL if the two PandaNodes cannot + * safely be combined. + * + * The return value may be this, other, or a new PandaNode altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two + * PandaNodes and what the collapsed PandaNode should look like. + */ PandaNode *PandaNode:: combine_with(PandaNode *other) { // An unadorned PandaNode always combines with any other PandaNodes by @@ -412,26 +351,20 @@ combine_with(PandaNode *other) { return (PandaNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::calc_tight_bounds -// Access: Public, Virtual -// Description: This is used to support -// NodePath::calc_tight_bounds(). It is not intended to -// be called directly, and it has nothing to do with the -// normal Panda bounding-volume computation. -// -// If the node contains any geometry, this updates -// min_point and max_point to enclose its bounding box. -// found_any is to be set true if the node has any -// geometry at all, or left alone if it has none. This -// method may be called over several nodes, so it may -// enter with min_point, max_point, and found_any -// already set. -// -// This function is recursive, and the return value is -// the transform after it has been modified by this -// node's transform. -//////////////////////////////////////////////////////////////////// +/** + * This is used to support NodePath::calc_tight_bounds(). It is not intended + * to be called directly, and it has nothing to do with the normal Panda + * bounding-volume computation. + * + * If the node contains any geometry, this updates min_point and max_point to + * enclose its bounding box. found_any is to be set true if the node has any + * geometry at all, or left alone if it has none. This method may be called + * over several nodes, so it may enter with min_point, max_point, and + * found_any already set. + * + * This function is recursive, and the return value is the transform after it + * has been modified by this node's transform. + */ CPT(TransformState) PandaNode:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { @@ -448,183 +381,139 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, return next_transform; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PandaNode:: cull_callback(CullTraverser *, CullTraverserData &) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_selective_visibility -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if this kind of node has some restrictions on -// the set of children that should be rendered. Node -// with this property include LODNodes, SwitchNodes, and -// SequenceNodes. -// -// If this function returns true, -// get_first_visible_child() and -// get_next_visible_child() will be called to walk -// through the list of children during cull, instead of -// iterating through the entire list. This method is -// called after cull_callback(), so cull_callback() may -// be responsible for the decisions as to which children -// are visible at the moment. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if this kind of node + * has some restrictions on the set of children that should be rendered. Node + * with this property include LODNodes, SwitchNodes, and SequenceNodes. + * + * If this function returns true, get_first_visible_child() and + * get_next_visible_child() will be called to walk through the list of + * children during cull, instead of iterating through the entire list. This + * method is called after cull_callback(), so cull_callback() may be + * responsible for the decisions as to which children are visible at the + * moment. + */ bool PandaNode:: has_selective_visibility() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_first_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the first visible child -// of this node, or a number >= get_num_children() if -// there are no visible children of this node. This is -// called during the cull traversal, but only if -// has_selective_visibility() has already returned true. -// See has_selective_visibility(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first visible child of this node, or a + * number >= get_num_children() if there are no visible children of this node. + * This is called during the cull traversal, but only if + * has_selective_visibility() has already returned true. See + * has_selective_visibility(). + */ int PandaNode:: get_first_visible_child() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_next_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the next visible child -// of this node following the indicated child, or a -// number >= get_num_children() if there are no more -// visible children of this node. See -// has_selective_visibility() and -// get_first_visible_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the next visible child of this node following + * the indicated child, or a number >= get_num_children() if there are no more + * visible children of this node. See has_selective_visibility() and + * get_first_visible_child(). + */ int PandaNode:: get_next_visible_child(int n) const { return n + 1; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::has_single_child_visibility -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if this kind of node has the special property -// that just one of its children is visible at any given -// time, and furthermore that the particular visible -// child can be determined without reference to any -// external information (such as a camera). At present, -// only SequenceNodes and SwitchNodes fall into this -// category. -// -// If this function returns true, get_visible_child() -// can be called to return the index of the -// currently-visible child. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if this kind of node + * has the special property that just one of its children is visible at any + * given time, and furthermore that the particular visible child can be + * determined without reference to any external information (such as a + * camera). At present, only SequenceNodes and SwitchNodes fall into this + * category. + * + * If this function returns true, get_visible_child() can be called to return + * the index of the currently-visible child. + */ bool PandaNode:: has_single_child_visibility() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the currently visible -// child of this node. This is only meaningful if -// has_single_child_visibility() has returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the currently visible child of this node. This + * is only meaningful if has_single_child_visibility() has returned true. + */ int PandaNode:: get_visible_child() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool PandaNode:: is_renderable() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::add_for_draw -// Access: Public, Virtual -// Description: Adds the node's contents to the CullResult we are -// building up during the cull traversal, so that it -// will be drawn at render time. For most nodes other -// than GeomNodes, this is a do-nothing operation. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node's contents to the CullResult we are building up during the + * cull traversal, so that it will be drawn at render time. For most nodes + * other than GeomNodes, this is a do-nothing operation. + */ void PandaNode:: add_for_draw(CullTraverser *, CullTraverserData &) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::make_copy -// Access: Published, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *PandaNode:: make_copy() const { return new PandaNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::copy_subgraph -// Access: Published -// Description: Allocates and returns a complete copy of this -// PandaNode and the entire scene graph rooted at this -// PandaNode. Some data may still be shared from the -// original (e.g. vertex index tables), but nothing that -// will impede normal use of the PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a complete copy of this PandaNode and the entire + * scene graph rooted at this PandaNode. Some data may still be shared from + * the original (e.g. vertex index tables), but nothing that will impede + * normal use of the PandaNode. + */ PT(PandaNode) PandaNode:: copy_subgraph(Thread *current_thread) const { InstanceMap inst_map; return r_copy_subgraph(inst_map, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::count_num_descendants -// Access: Published -// Description: Returns the number of nodes at and below this level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nodes at and below this level. + */ int PandaNode:: count_num_descendants() const { int count = 1; @@ -639,24 +528,21 @@ count_num_descendants() const { return count; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::add_child -// Access: Published -// Description: Adds a new child to the node. The child is added in -// the relative position indicated by sort; if all -// children have the same sort index, the child is added -// at the end. -// -// If the same child is added to a node more than once, -// the previous instance is first removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new child to the node. The child is added in the relative position + * indicated by sort; if all children have the same sort index, the child is + * added at the end. + * + * If the same child is added to a node more than once, the previous instance + * is first removed. + */ void PandaNode:: add_child(PandaNode *child_node, int sort, Thread *current_thread) { nassertv(child_node != (PandaNode *)NULL); if (!verify_child_no_cycles(child_node)) { - // Whoops, adding this child node would introduce a cycle in the - // scene graph. + // Whoops, adding this child node would introduce a cycle in the scene + // graph. return; } @@ -664,8 +550,8 @@ add_child(PandaNode *child_node, int sort, Thread *current_thread) { PT(PandaNode) keep_child = child_node; remove_child(child_node); - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); CDStageWriter cdata_child(child_node->_cycler, pipeline_stage, current_thread); @@ -688,11 +574,9 @@ add_child(PandaNode *child_node, int sort, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::remove_child -// Access: Published -// Description: Removes the nth child from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth child from the node. + */ void PandaNode:: remove_child(int child_index, Thread *current_thread) { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -720,20 +604,17 @@ remove_child(int child_index, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::remove_child -// Access: Published -// Description: Removes the indicated child from the node. Returns -// true if the child was removed, false if it was not -// already a child of the node. This will also -// successfully remove the child if it had been stashed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated child from the node. Returns true if the child was + * removed, false if it was not already a child of the node. This will also + * successfully remove the child if it had been stashed. + */ bool PandaNode:: remove_child(PandaNode *child_node, Thread *current_thread) { nassertr(child_node != (PandaNode *)NULL, false); - // Make sure the child node is not destructed during the execution - // of this method. + // Make sure the child node is not destructed during the execution of this + // method. PT(PandaNode) keep_child = child_node; // We have to do this for each upstream pipeline stage. @@ -758,15 +639,12 @@ remove_child(PandaNode *child_node, Thread *current_thread) { return any_removed; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::replace_child -// Access: Published -// Description: Searches for the orig_child node in the node's list -// of children, and replaces it with the new_child -// instead. Returns true if the replacement is made, or -// false if the node is not a child or if there is some -// other problem. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the orig_child node in the node's list of children, and + * replaces it with the new_child instead. Returns true if the replacement is + * made, or false if the node is not a child or if there is some other + * problem. + */ bool PandaNode:: replace_child(PandaNode *orig_child, PandaNode *new_child, Thread *current_thread) { @@ -779,13 +657,13 @@ replace_child(PandaNode *orig_child, PandaNode *new_child, } if (!verify_child_no_cycles(new_child)) { - // Whoops, adding this child node would introduce a cycle in the - // scene graph. + // Whoops, adding this child node would introduce a cycle in the scene + // graph. return false; } - // Make sure the orig_child node is not destructed during the - // execution of this method. + // Make sure the orig_child node is not destructed during the execution of + // this method. PT(PandaNode) keep_orig_child = orig_child; // We have to do this for each upstream pipeline stage. @@ -808,20 +686,15 @@ replace_child(PandaNode *orig_child, PandaNode *new_child, } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::stash_child -// Access: Published -// Description: Stashes the indicated child node. This removes the -// child from the list of active children and puts it on -// a special list of stashed children. This child node -// no longer contributes to the bounding volume of the -// PandaNode, and is not visited in normal traversals. -// It is invisible and uncollidable. The child may -// later be restored by calling unstash_child(). -// -// This can only be called from the top pipeline stage -// (i.e. from App). -//////////////////////////////////////////////////////////////////// +/** + * Stashes the indicated child node. This removes the child from the list of + * active children and puts it on a special list of stashed children. This + * child node no longer contributes to the bounding volume of the PandaNode, + * and is not visited in normal traversals. It is invisible and uncollidable. + * The child may later be restored by calling unstash_child(). + * + * This can only be called from the top pipeline stage (i.e. from App). + */ void PandaNode:: stash_child(int child_index, Thread *current_thread) { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -853,30 +726,24 @@ stash_child(int child_index, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::unstash_child -// Access: Published -// Description: Returns the indicated stashed node to normal child -// status. This removes the child from the list of -// stashed children and puts it on the normal list of -// active children. This child node once again -// contributes to the bounding volume of the PandaNode, -// and will be visited in normal traversals. It is -// visible and collidable. -// -// This can only be called from the top pipeline stage -// (i.e. from App). -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated stashed node to normal child status. This removes + * the child from the list of stashed children and puts it on the normal list + * of active children. This child node once again contributes to the bounding + * volume of the PandaNode, and will be visited in normal traversals. It is + * visible and collidable. + * + * This can only be called from the top pipeline stage (i.e. from App). + */ void PandaNode:: unstash_child(int stashed_index, Thread *current_thread) { int pipeline_stage = current_thread->get_pipeline_stage(); nassertv(pipeline_stage == 0); nassertv(stashed_index >= 0 && stashed_index < get_num_stashed()); - // Save a reference count for ourselves. I don't think this should - // be necessary, but there are occasional crashes in stash() during - // furniture moving mode. Perhaps this will eliminate those - // crashes. + // Save a reference count for ourselves. I don't think this should be + // necessary, but there are occasional crashes in stash() during furniture + // moving mode. Perhaps this will eliminate those crashes. PT(PandaNode) self = this; PT(PandaNode) child_node = get_stashed(stashed_index); @@ -901,28 +768,24 @@ unstash_child(int stashed_index, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::add_stashed -// Access: Published -// Description: Adds a new child to the node, directly as a stashed -// child. The child is not added in the normal sense, -// but will be revealed if unstash_child() is called on -// it later. -// -// If the same child is added to a node more than once, -// the previous instance is first removed. -// -// This can only be called from the top pipeline stage -// (i.e. from App). -//////////////////////////////////////////////////////////////////// +/** + * Adds a new child to the node, directly as a stashed child. The child is + * not added in the normal sense, but will be revealed if unstash_child() is + * called on it later. + * + * If the same child is added to a node more than once, the previous instance + * is first removed. + * + * This can only be called from the top pipeline stage (i.e. from App). + */ void PandaNode:: add_stashed(PandaNode *child_node, int sort, Thread *current_thread) { int pipeline_stage = current_thread->get_pipeline_stage(); nassertv(pipeline_stage == 0); if (!verify_child_no_cycles(child_node)) { - // Whoops, adding this child node would introduce a cycle in the - // scene graph. + // Whoops, adding this child node would introduce a cycle in the scene + // graph. return; } @@ -947,11 +810,9 @@ add_stashed(PandaNode *child_node, int sort, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::remove_stashed -// Access: Published -// Description: Removes the nth stashed child from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth stashed child from the node. + */ void PandaNode:: remove_stashed(int child_index, Thread *current_thread) { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -977,15 +838,11 @@ remove_stashed(int child_index, Thread *current_thread) { child_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::remove_all_children -// Access: Published -// Description: Removes all the children from the node at once, -// including stashed children. -// -// This can only be called from the top pipeline stage -// (i.e. from App). -//////////////////////////////////////////////////////////////////// +/** + * Removes all the children from the node at once, including stashed children. + * + * This can only be called from the top pipeline stage (i.e. from App). + */ void PandaNode:: remove_all_children(Thread *current_thread) { // We have to do this for each upstream pipeline stage. @@ -1025,15 +882,12 @@ remove_all_children(Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::steal_children -// Access: Published -// Description: Moves all the children from the other node onto this -// node. -// -// Any NodePaths to child nodes of the other node are -// truncated, rather than moved to the new parent. -//////////////////////////////////////////////////////////////////// +/** + * Moves all the children from the other node onto this node. + * + * Any NodePaths to child nodes of the other node are truncated, rather than + * moved to the new parent. + */ void PandaNode:: steal_children(PandaNode *other, Thread *current_thread) { if (other == this) { @@ -1041,13 +895,12 @@ steal_children(PandaNode *other, Thread *current_thread) { return; } - // We do this through the high-level interface for convenience. - // This could begin to be a problem if we have a node with hundreds - // of children to copy; this could break down the ov_set.insert() - // method, which is an O(n^2) operation. If this happens, we should - // rewrite this to do a simpler add_child() operation that involves - // push_back() instead of insert(), and then sort the down list at - // the end. + // We do this through the high-level interface for convenience. This could + // begin to be a problem if we have a node with hundreds of children to + // copy; this could break down the ov_set.insert() method, which is an + // O(n^2) operation. If this happens, we should rewrite this to do a + // simpler add_child() operation that involves push_back() instead of + // insert(), and then sort the down list at the end. int num_children = other->get_num_children(); int i; @@ -1066,12 +919,10 @@ steal_children(PandaNode *other, Thread *current_thread) { other->remove_all_children(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::copy_children -// Access: Published -// Description: Makes another instance of all the children of the -// other node, copying them to this node. -//////////////////////////////////////////////////////////////////// +/** + * Makes another instance of all the children of the other node, copying them + * to this node. + */ void PandaNode:: copy_children(PandaNode *other, Thread *current_thread) { if (other == this) { @@ -1095,18 +946,15 @@ copy_children(PandaNode *other, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_attrib -// Access: Published -// Description: Adds the indicated render attribute to the scene -// graph on this node. This attribute will now apply to -// this node and everything below. If there was already -// an attribute of the same type, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated render attribute to the scene graph on this node. This + * attribute will now apply to this node and everything below. If there was + * already an attribute of the same type, it is replaced. + */ void PandaNode:: set_attrib(const RenderAttrib *attrib, int override) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. bool any_changed = false; Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { @@ -1129,14 +977,11 @@ set_attrib(const RenderAttrib *attrib, int override) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_attrib -// Access: Published -// Description: Removes the render attribute of the given type from -// this node. This node, and the subgraph below, will -// now inherit the indicated render attribute from the -// nodes above this one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the render attribute of the given type from this node. This node, + * and the subgraph below, will now inherit the indicated render attribute + * from the nodes above this one. + */ void PandaNode:: clear_attrib(int slot) { bool any_changed = false; @@ -1154,8 +999,8 @@ clear_attrib(int slot) { } CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); - // We mark the bounds stale when the state changes, in case - // we have changed a ClipPlaneAttrib. + // We mark the bounds stale when the state changes, in case we have changed + // a ClipPlaneAttrib. if (any_changed) { mark_bounds_stale(current_thread); state_changed(); @@ -1163,17 +1008,14 @@ clear_attrib(int slot) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_effect -// Access: Published -// Description: Adds the indicated render effect to the scene -// graph on this node. If there was already an effect -// of the same type, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated render effect to the scene graph on this node. If there + * was already an effect of the same type, it is replaced. + */ void PandaNode:: set_effect(const RenderEffect *effect) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); @@ -1184,12 +1026,9 @@ set_effect(const RenderEffect *effect) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_effect -// Access: Published -// Description: Removes the render effect of the given type from -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the render effect of the given type from this node. + */ void PandaNode:: clear_effect(TypeHandle type) { Thread *current_thread = Thread::get_current_thread(); @@ -1202,20 +1041,17 @@ clear_effect(TypeHandle type) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_state -// Access: Published -// Description: Sets the complete RenderState that will be applied to -// all nodes at this level and below. (The actual state -// that will be applied to lower nodes is based on the -// composition of RenderStates from above this node as -// well). This completely replaces whatever has been -// set on this node via repeated calls to set_attrib(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the complete RenderState that will be applied to all nodes at this + * level and below. (The actual state that will be applied to lower nodes is + * based on the composition of RenderStates from above this node as well). + * This completely replaces whatever has been set on this node via repeated + * calls to set_attrib(). + */ void PandaNode:: set_state(const RenderState *state, Thread *current_thread) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. bool any_changed = false; OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); @@ -1235,18 +1071,15 @@ set_state(const RenderState *state, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_effects -// Access: Published -// Description: Sets the complete RenderEffects that will be applied -// this node. This completely replaces whatever has -// been set on this node via repeated calls to -// set_attrib(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the complete RenderEffects that will be applied this node. This + * completely replaces whatever has been set on this node via repeated calls + * to set_attrib(). + */ void PandaNode:: set_effects(const RenderEffects *effects, Thread *current_thread) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); cdata->_effects = effects; @@ -1256,20 +1089,17 @@ set_effects(const RenderEffects *effects, Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_transform -// Access: Published -// Description: Sets the transform that will be applied to this node -// and below. This defines a new coordinate space at -// this point in the scene graph and below. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform that will be applied to this node and below. This + * defines a new coordinate space at this point in the scene graph and below. + */ void PandaNode:: set_transform(const TransformState *transform, Thread *current_thread) { // Need to have this held before we grab any other locks. LightMutexHolder holder(_dirty_prev_transforms._lock); - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. bool any_changed = false; OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); @@ -1294,21 +1124,18 @@ set_transform(const TransformState *transform, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_prev_transform -// Access: Published -// Description: Sets the transform that represents this node's -// "previous" position, one frame ago, for the purposes -// of detecting motion for accurate collision -// calculations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform that represents this node's "previous" position, one + * frame ago, for the purposes of detecting motion for accurate collision + * calculations. + */ void PandaNode:: set_prev_transform(const TransformState *transform, Thread *current_thread) { // Need to have this held before we grab any other locks. LightMutexHolder holder(_dirty_prev_transforms._lock); - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); cdata->_prev_transform = transform; @@ -1324,22 +1151,19 @@ set_prev_transform(const TransformState *transform, Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::reset_prev_transform -// Access: Published -// Description: Resets the transform that represents this node's -// "previous" position to the same as the current -// transform. This is not the same thing as clearing it -// to identity. -//////////////////////////////////////////////////////////////////// +/** + * Resets the transform that represents this node's "previous" position to the + * same as the current transform. This is not the same thing as clearing it + * to identity. + */ void PandaNode:: reset_prev_transform(Thread *current_thread) { // Need to have this held before we grab any other locks. LightMutexHolder holder(_dirty_prev_transforms._lock); do_clear_dirty_prev_transform(); - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); @@ -1349,15 +1173,12 @@ reset_prev_transform(Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::reset_all_prev_transform -// Access: Published, Static -// Description: Visits all nodes in the world with the -// _dirty_prev_transform flag--that is, all nodes whose -// _prev_transform is different from the _transform in -// pipeline stage 0--and resets the _prev_transform to -// be the same as _transform. -//////////////////////////////////////////////////////////////////// +/** + * Visits all nodes in the world with the _dirty_prev_transform flag--that is, + * all nodes whose _prev_transform is different from the _transform in + * pipeline stage 0--and resets the _prev_transform to be the same as + * _transform. + */ void PandaNode:: reset_all_prev_transform(Thread *current_thread) { nassertv(current_thread->get_pipeline_stage() == 0); @@ -1386,23 +1207,19 @@ reset_all_prev_transform(Thread *current_thread) { _dirty_prev_transforms._next = &_dirty_prev_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_tag -// Access: Published -// Description: Associates a user-defined value with a user-defined -// key which is stored on the node. This value has no -// meaning to Panda; but it is stored indefinitely on -// the node until it is requested again. -// -// Each unique key stores a different string value. -// There is no effective limit on the number of -// different keys that may be stored or on the length of -// any one key's value. -//////////////////////////////////////////////////////////////////// +/** + * Associates a user-defined value with a user-defined key which is stored on + * the node. This value has no meaning to Panda; but it is stored + * indefinitely on the node until it is requested again. + * + * Each unique key stores a different string value. There is no effective + * limit on the number of different keys that may be stored or on the length + * of any one key's value. + */ void PandaNode:: set_tag(const string &key, const string &value, Thread *current_thread) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); cdata->_tag_data[key] = value; @@ -1412,13 +1229,10 @@ set_tag(const string &key, const string &value, Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_tag -// Access: Published -// Description: Removes the value defined for this key on this -// particular node. After a call to clear_tag(), -// has_tag() will return false for the indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Removes the value defined for this key on this particular node. After a + * call to clear_tag(), has_tag() will return false for the indicated key. + */ void PandaNode:: clear_tag(const string &key, Thread *current_thread) { OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { @@ -1430,14 +1244,11 @@ clear_tag(const string &key, Thread *current_thread) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::copy_tags -// Access: Published -// Description: Copies all of the tags stored on the other node onto -// this node. If a particular tag exists on both nodes, -// the contents of this node's value is replaced by that -// of the other. -//////////////////////////////////////////////////////////////////// +/** + * Copies all of the tags stored on the other node onto this node. If a + * particular tag exists on both nodes, the contents of this node's value is + * replaced by that of the other. + */ void PandaNode:: copy_tags(PandaNode *other) { if (other == this) { @@ -1445,8 +1256,8 @@ copy_tags(PandaNode *other) { return; } - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. Thread *current_thread = Thread::get_current_thread(); OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdataw(_cycler, pipeline_stage, current_thread); @@ -1473,10 +1284,9 @@ copy_tags(PandaNode *other) { result = cdataw->_python_tag_data.insert(PythonTagData::value_type(key, value)); if (!result.second) { - // The insert was unsuccessful; that means the key was already - // present in the map. In this case, we should decrement the - // original value's reference count and replace it with the new - // object. + // The insert was unsuccessful; that means the key was already present + // in the map. In this case, we should decrement the original value's + // reference count and replace it with the new object. PythonTagData::iterator wpti = result.first; PyObject *old_value = (*wpti).second; Py_XDECREF(old_value); @@ -1489,18 +1299,15 @@ copy_tags(PandaNode *other) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::list_tags -// Access: Published -// Description: Writes a list of all the tag keys assigned to the -// node to the indicated stream. Writes one instance of -// the separator following each key (but does not write -// a terminal separator). The value associated with -// each key is not written. -// -// This is mainly for the benefit of the realtime user, -// to see the list of all of the associated tag keys. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of all the tag keys assigned to the node to the indicated + * stream. Writes one instance of the separator following each key (but does + * not write a terminal separator). The value associated with each key is not + * written. + * + * This is mainly for the benefit of the realtime user, to see the list of all + * of the associated tag keys. + */ void PandaNode:: list_tags(ostream &out, const string &separator) const { CDReader cdata(_cycler); @@ -1530,16 +1337,12 @@ list_tags(ostream &out, const string &separator) const { #endif // HAVE_PYTHON } -//////////////////////////////////////////////////////////////////// -// Function: Filename::get_tag_keys -// Access: Published -// Description: Fills the given vector up with the -// list of tags on this PandaNode. -// -// It is the user's responsibility to ensure that the -// keys vector is empty before making this call; -// otherwise, the new keys will be appended to it. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of tags on this PandaNode. + * + * It is the user's responsibility to ensure that the keys vector is empty + * before making this call; otherwise, the new keys will be appended to it. + */ void PandaNode:: get_tag_keys(vector_string &keys) const { CDReader cdata(_cycler); @@ -1552,17 +1355,13 @@ get_tag_keys(vector_string &keys) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::compare_tags -// Access: Published -// Description: Returns a number less than 0, 0, or greater than 0, -// to indicate the similarity of tags between this node -// and the other one. If this returns 0, the tags are -// identical. If it returns other than 0, then the tags -// are different; and the nodes may be sorted into a -// consistent (but arbitrary) ordering based on this -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than 0, 0, or greater than 0, to indicate the + * similarity of tags between this node and the other one. If this returns 0, + * the tags are identical. If it returns other than 0, then the tags are + * different; and the nodes may be sorted into a consistent (but arbitrary) + * ordering based on this number. + */ int PandaNode:: compare_tags(const PandaNode *other) const { CDReader cdata(_cycler); @@ -1642,15 +1441,12 @@ compare_tags(const PandaNode *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::copy_all_properties -// Access: Published -// Description: Copies the TransformState, RenderState, -// RenderEffects, tags, Python tags, and the show/hide -// state from the other node onto this one. Typically -// this is used to prepare a node to replace another -// node in the scene graph (also see replace_node()). -//////////////////////////////////////////////////////////////////// +/** + * Copies the TransformState, RenderState, RenderEffects, tags, Python tags, + * and the show/hide state from the other node onto this one. Typically this + * is used to prepare a node to replace another node in the scene graph (also + * see replace_node()). + */ void PandaNode:: copy_all_properties(PandaNode *other) { if (other == this) { @@ -1687,9 +1483,8 @@ copy_all_properties(PandaNode *other) { cdataw->_draw_control_mask = cdatar->_draw_control_mask; cdataw->_draw_show_mask = cdatar->_draw_show_mask; - // The collide mask becomes the union of the two masks. This is - // important to preserve properties such as the default GeomNode - // bitmask. + // The collide mask becomes the union of the two masks. This is important + // to preserve properties such as the default GeomNode bitmask. cdataw->_into_collide_mask |= cdatar->_into_collide_mask; TagData::const_iterator ti; @@ -1712,10 +1507,9 @@ copy_all_properties(PandaNode *other) { result = cdataw->_python_tag_data.insert(PythonTagData::value_type(key, value)); if (!result.second) { - // The insert was unsuccessful; that means the key was already - // present in the map. In this case, we should decrement the - // original value's reference count and replace it with the new - // object. + // The insert was unsuccessful; that means the key was already present + // in the map. In this case, we should decrement the original value's + // reference count and replace it with the new object. PythonTagData::iterator wpti = result.first; PyObject *old_value = (*wpti).second; Py_XDECREF(old_value); @@ -1754,36 +1548,32 @@ copy_all_properties(PandaNode *other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::replace_node -// Access: Published -// Description: Inserts this node into the scene graph in place of -// the other one, and removes the other node. All scene -// graph attributes (TransformState, RenderState, etc.) -// are copied to this node. -// -// All children are moved to this node, and removed from -// the old node. The new node is left in the same place -// in the old node's parent's list of children. -// -// Even NodePaths that reference the old node are -// updated in-place to reference the new node instead. -// -// This method is intended to be used to replace a node -// of a given type in the scene graph with a node of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Inserts this node into the scene graph in place of the other one, and + * removes the other node. All scene graph attributes (TransformState, + * RenderState, etc.) are copied to this node. + * + * All children are moved to this node, and removed from the old node. The + * new node is left in the same place in the old node's parent's list of + * children. + * + * Even NodePaths that reference the old node are updated in-place to + * reference the new node instead. + * + * This method is intended to be used to replace a node of a given type in the + * scene graph with a node of a different type. + */ void PandaNode:: replace_node(PandaNode *other) { - // nassertv(Thread::get_current_pipeline_stage() == 0); + // nassertv(Thread::get_current_pipeline_stage() == 0); if (other == this) { // Trivial. return; } - // Make sure the other node is not destructed during the - // execution of this method. + // Make sure the other node is not destructed during the execution of this + // method. PT(PandaNode) keep_other = other; // Get all the important scene graph properties. @@ -1810,8 +1600,7 @@ replace_node(PandaNode *other) { for (int i = 0; i < other_parents.get_num_parents(); ++i) { PandaNode *parent = other_parents.get_parent(i); if (find_parent(parent) != -1) { - // This node was already a child of this parent; don't change - // it. + // This node was already a child of this parent; don't change it. parent->remove_child(other); } else { // This node was not yet a child of this parent; now it is. @@ -1820,25 +1609,19 @@ replace_node(PandaNode *other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_unexpected_change -// Access: Published -// Description: Sets one or more of the PandaNode::UnexpectedChange -// bits on, indicating that the corresponding property -// should not change again on this node. Once one of -// these bits has been set, if the property changes, an -// assertion failure will be raised, which is designed -// to assist the developer in identifying the -// troublesome code that modified the property -// unexpectedly. -// -// The input parameter is the union of bits that are to -// be set. To clear these bits later, use -// clear_unexpected_change(). -// -// Since this is a developer debugging tool only, this -// function does nothing in a production (NDEBUG) build. -//////////////////////////////////////////////////////////////////// +/** + * Sets one or more of the PandaNode::UnexpectedChange bits on, indicating + * that the corresponding property should not change again on this node. Once + * one of these bits has been set, if the property changes, an assertion + * failure will be raised, which is designed to assist the developer in + * identifying the troublesome code that modified the property unexpectedly. + * + * The input parameter is the union of bits that are to be set. To clear + * these bits later, use clear_unexpected_change(). + * + * Since this is a developer debugging tool only, this function does nothing + * in a production (NDEBUG) build. + */ void PandaNode:: set_unexpected_change(unsigned int flags) { #ifndef NDEBUG @@ -1846,20 +1629,15 @@ set_unexpected_change(unsigned int flags) { #endif // !NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_unexpected_change -// Access: Published -// Description: Returns nonzero if any of the bits in the input -// parameter are set on this node, or zero if none of -// them are set. More specifically, this returns the -// particular set of bits (masked by the input -// parameter) that have been set on this node. See -// set_unexpected_change(). -// -// Since this is a developer debugging tool only, this -// function always returns zero in a production (NDEBUG) -// build. -//////////////////////////////////////////////////////////////////// +/** + * Returns nonzero if any of the bits in the input parameter are set on this + * node, or zero if none of them are set. More specifically, this returns the + * particular set of bits (masked by the input parameter) that have been set + * on this node. See set_unexpected_change(). + * + * Since this is a developer debugging tool only, this function always returns + * zero in a production (NDEBUG) build. + */ unsigned int PandaNode:: get_unexpected_change(unsigned int flags) const { #ifndef NDEBUG @@ -1869,20 +1647,16 @@ get_unexpected_change(unsigned int flags) const { #endif // !NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::clear_unexpected_change -// Access: Published -// Description: Sets one or more of the PandaNode::UnexpectedChange -// bits off, indicating that the corresponding property -// may once again change on this node. See -// set_unexpected_change(). -// -// The input parameter is the union of bits that are to -// be cleared. -// -// Since this is a developer debugging tool only, this -// function does nothing in a production (NDEBUG) build. -//////////////////////////////////////////////////////////////////// +/** + * Sets one or more of the PandaNode::UnexpectedChange bits off, indicating + * that the corresponding property may once again change on this node. See + * set_unexpected_change(). + * + * The input parameter is the union of bits that are to be cleared. + * + * Since this is a developer debugging tool only, this function does nothing + * in a production (NDEBUG) build. + */ void PandaNode:: clear_unexpected_change(unsigned int flags) { #ifndef NDEBUG @@ -1890,44 +1664,36 @@ clear_unexpected_change(unsigned int flags) { #endif // !NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::adjust_draw_mask -// Access: Published -// Description: Adjusts the hide/show bits of this particular node. -// -// These three parameters can be used to adjust the -// _draw_control_mask and _draw_show_mask independently, -// which work together to provide per-camera visibility -// for the node and its descendents. -// -// _draw_control_mask indicates the bits in -// _draw_show_mask that are significant. Each different -// bit corresponds to a different camera (and these bits -// are assigned via Camera::set_camera_mask()). -// -// Where _draw_control_mask has a 1 bit, a 1 bit in -// _draw_show_mask indicates the node is visible to that -// camera, and a 0 bit indicates the node is hidden to -// that camera. Where _draw_control_mask is 0, the node -// is hidden only if a parent node is hidden. -// -// The meaning of the three parameters is as follows: -// -// * Wherever show_mask is 1, _draw_show_mask and -// _draw_control_mask will be set 1. Thus, show_mask -// indicates the set of cameras to which the node should -// be shown. -// -// * Wherever hide_mask is 1, _draw_show_mask will be -// set 0 and _draw_control_mask will be set 1. Thus, -// hide_mask indicates the set of cameras from which the -// node should be hidden. -// -// * Wherever clear_mask is 1, _draw_control_mask will -// be set 0. Thus, clear_mask indicates the set of -// cameras from which the hidden state should be -// inherited from a parent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the hide/show bits of this particular node. + * + * These three parameters can be used to adjust the _draw_control_mask and + * _draw_show_mask independently, which work together to provide per-camera + * visibility for the node and its descendents. + * + * _draw_control_mask indicates the bits in _draw_show_mask that are + * significant. Each different bit corresponds to a different camera (and + * these bits are assigned via Camera::set_camera_mask()). + * + * Where _draw_control_mask has a 1 bit, a 1 bit in _draw_show_mask indicates + * the node is visible to that camera, and a 0 bit indicates the node is + * hidden to that camera. Where _draw_control_mask is 0, the node is hidden + * only if a parent node is hidden. + * + * The meaning of the three parameters is as follows: + * + * * Wherever show_mask is 1, _draw_show_mask and _draw_control_mask will be + * set 1. Thus, show_mask indicates the set of cameras to which the node + * should be shown. + * + * * Wherever hide_mask is 1, _draw_show_mask will be set 0 and + * _draw_control_mask will be set 1. Thus, hide_mask indicates the set of + * cameras from which the node should be hidden. + * + * * Wherever clear_mask is 1, _draw_control_mask will be set 0. Thus, + * clear_mask indicates the set of cameras from which the hidden state should + * be inherited from a parent. + */ void PandaNode:: adjust_draw_mask(DrawMask show_mask, DrawMask hide_mask, DrawMask clear_mask) { bool any_changed = false; @@ -1958,18 +1724,14 @@ adjust_draw_mask(DrawMask show_mask, DrawMask hide_mask, DrawMask clear_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_net_draw_control_mask -// Access: Published -// Description: Returns the set of bits in get_net_draw_show_mask() -// that have been explicitly set via adjust_draw_mask(), -// rather than implicitly inherited. -// -// A 1 bit in any position of this mask indicates that -// (a) this node has renderable children, and (b) some -// child of this node has made an explicit hide() or -// show_through() call for the corresponding bit. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of bits in get_net_draw_show_mask() that have been + * explicitly set via adjust_draw_mask(), rather than implicitly inherited. + * + * A 1 bit in any position of this mask indicates that (a) this node has + * renderable children, and (b) some child of this node has made an explicit + * hide() or show_through() call for the corresponding bit. + */ DrawMask PandaNode:: get_net_draw_control_mask() const { Thread *current_thread = Thread::get_current_thread(); @@ -1985,22 +1747,18 @@ get_net_draw_control_mask() const { return cdata->_net_draw_control_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_net_draw_show_mask -// Access: Published -// Description: Returns the union of all draw_show_mask values--of -// renderable nodes only--at this level and below. If -// any bit in this mask is 0, there is no reason to -// traverse below this node for a camera with the -// corresponding camera_mask. -// -// The bits in this mask that do not correspond to a 1 -// bit in the net_draw_control_mask are meaningless (and -// will be set to 1). For bits that *do* correspond to -// a 1 bit in the net_draw_control_mask, a 1 bit -// indicates that at least one child should be visible, -// while a 0 bit indicates that all children are hidden. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all draw_show_mask values--of renderable nodes only-- + * at this level and below. If any bit in this mask is 0, there is no reason + * to traverse below this node for a camera with the corresponding + * camera_mask. + * + * The bits in this mask that do not correspond to a 1 bit in the + * net_draw_control_mask are meaningless (and will be set to 1). For bits + * that *do* correspond to a 1 bit in the net_draw_control_mask, a 1 bit + * indicates that at least one child should be visible, while a 0 bit + * indicates that all children are hidden. + */ DrawMask PandaNode:: get_net_draw_show_mask() const { Thread *current_thread = Thread::get_current_thread(); @@ -2016,23 +1774,18 @@ get_net_draw_show_mask() const { return cdata->_net_draw_show_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_into_collide_mask -// Access: Published -// Description: Sets the "into" CollideMask. -// -// This specifies the set of bits that must be shared -// with a CollisionNode's "from" CollideMask in order -// for the CollisionNode to detect a collision with this -// particular node. -// -// The actual CollideMask that will be set is masked by -// the return value from get_legal_collide_mask(). -// Thus, the into_collide_mask cannot be set to anything -// other than nonzero except for those types of nodes -// that can be collided into, such as CollisionNodes and -// GeomNodes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "into" CollideMask. + * + * This specifies the set of bits that must be shared with a CollisionNode's + * "from" CollideMask in order for the CollisionNode to detect a collision + * with this particular node. + * + * The actual CollideMask that will be set is masked by the return value from + * get_legal_collide_mask(). Thus, the into_collide_mask cannot be set to + * anything other than nonzero except for those types of nodes that can be + * collided into, such as CollisionNodes and GeomNodes. + */ void PandaNode:: set_into_collide_mask(CollideMask mask) { mask &= get_legal_collide_mask(); @@ -2054,28 +1807,23 @@ set_into_collide_mask(CollideMask mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_legal_collide_mask -// Access: Published, Virtual -// Description: Returns the subset of CollideMask bits that may be -// set for this particular type of PandaNode. For most -// nodes, this is 0; it doesn't make sense to set a -// CollideMask for most kinds of nodes. -// -// For nodes that can be collided with, such as GeomNode -// and CollisionNode, this returns all bits on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subset of CollideMask bits that may be set for this particular + * type of PandaNode. For most nodes, this is 0; it doesn't make sense to set + * a CollideMask for most kinds of nodes. + * + * For nodes that can be collided with, such as GeomNode and CollisionNode, + * this returns all bits on. + */ CollideMask PandaNode:: get_legal_collide_mask() const { return CollideMask::all_off(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_net_collide_mask -// Access: Published -// Description: Returns the union of all into_collide_mask() values -// set at CollisionNodes at this level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all into_collide_mask() values set at CollisionNodes + * at this level and below. + */ CollideMask PandaNode:: get_net_collide_mask(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -2090,13 +1838,10 @@ get_net_collide_mask(Thread *current_thread) const { return cdata->_net_collide_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_off_clip_planes -// Access: Published -// Description: Returns a ClipPlaneAttrib which represents the union -// of all of the clip planes that have been turned *off* -// at this level and below. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ClipPlaneAttrib which represents the union of all of the clip + * planes that have been turned *off* at this level and below. + */ CPT(RenderAttrib) PandaNode:: get_off_clip_planes(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -2111,21 +1856,16 @@ get_off_clip_planes(Thread *current_thread) const { return cdata->_off_clip_planes; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::prepare_scene -// Access: Published -// Description: Walks through the scene graph beginning at this node, -// and does whatever initialization is required to -// render the scene properly with the indicated GSG. It -// is not strictly necessary to call this, since the GSG -// will initialize itself when the scene is rendered, -// but this may take some of the overhead away from that -// process. -// -// In particular, this will ensure that textures and -// vertex buffers within the scene are loaded into -// graphics memory. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the scene graph beginning at this node, and does whatever + * initialization is required to render the scene properly with the indicated + * GSG. It is not strictly necessary to call this, since the GSG will + * initialize itself when the scene is rendered, but this may take some of the + * overhead away from that process. + * + * In particular, this will ensure that textures and vertex buffers within the + * scene are loaded into graphics memory. + */ void PandaNode:: prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state) { GeomTransformer transformer; @@ -2133,35 +1873,28 @@ prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state) { r_prepare_scene(gsg, node_state, transformer, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_scene_root -// Access: Published -// Description: Returns true if this particular node is known to be -// the render root of some active DisplayRegion -// associated with the global GraphicsEngine, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular node is known to be the render root of some + * active DisplayRegion associated with the global GraphicsEngine, false + * otherwise. + */ bool PandaNode:: is_scene_root() const { - // This function pointer has to be filled in when the global - // GraphicsEngine is created, because we can't link with the - // GraphicsEngine functions directly. + // This function pointer has to be filled in when the global GraphicsEngine + // is created, because we can't link with the GraphicsEngine functions + // directly. if (_scene_root_func != (SceneRootFunc *)NULL) { return (*_scene_root_func)(this); } return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_under_scene_root -// Access: Published -// Description: Returns true if this particular node is in a live -// scene graph: that is, it is a child or descendent of -// a node that is itself a scene root. If this is true, -// this node may potentially be traversed by the render -// traverser. Stashed nodes don't count for this -// purpose, but hidden nodes do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular node is in a live scene graph: that is, it + * is a child or descendent of a node that is itself a scene root. If this is + * true, this node may potentially be traversed by the render traverser. + * Stashed nodes don't count for this purpose, but hidden nodes do. + */ bool PandaNode:: is_under_scene_root() const { if (is_scene_root()) { @@ -2180,21 +1913,17 @@ is_under_scene_root() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaNode:: output(ostream &out) const { out << get_type() << " " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaNode:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this; @@ -2238,25 +1967,20 @@ write(ostream &out, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_bounds_type -// Access: Published -// Description: Specifies the desired type of bounding volume that -// will be created for this node. This is normally -// BoundingVolume::BT_default, which means to set the -// type according to the config variable "bounds-type". -// -// If this is BT_sphere or BT_box, a BoundingSphere or -// BoundingBox is explicitly created. If it is BT_best, -// the appropriate type to best enclose the node's -// children is created. -// -// This affects the bounding volume returned by -// get_bounds(), which is not exactly the same bounding -// volume modified by set_bounds(), because a new -// bounding volume has to be created that includes this -// node and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the desired type of bounding volume that will be created for this + * node. This is normally BoundingVolume::BT_default, which means to set the + * type according to the config variable "bounds-type". + * + * If this is BT_sphere or BT_box, a BoundingSphere or BoundingBox is + * explicitly created. If it is BT_best, the appropriate type to best enclose + * the node's children is created. + * + * This affects the bounding volume returned by get_bounds(), which is not + * exactly the same bounding volume modified by set_bounds(), because a new + * bounding volume has to be created that includes this node and all of its + * children. + */ void PandaNode:: set_bounds_type(BoundingVolume::BoundsType bounds_type) { Thread *current_thread = Thread::get_current_thread(); @@ -2265,41 +1989,33 @@ set_bounds_type(BoundingVolume::BoundsType bounds_type) { cdata->_bounds_type = bounds_type; mark_bounds_stale(pipeline_stage, current_thread); - // GeomNodes, CollisionNodes, and PGItems all have an internal - // bounds that may need to be updated when the bounds_type - // changes. + // GeomNodes, CollisionNodes, and PGItems all have an internal bounds that + // may need to be updated when the bounds_type changes. mark_internal_bounds_stale(pipeline_stage, current_thread); mark_bam_modified(); } CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_bounds_type -// Access: Published -// Description: Returns the bounding volume type set with -// set_bounds_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume type set with set_bounds_type(). + */ BoundingVolume::BoundsType PandaNode:: get_bounds_type() const { CDReader cdata(_cycler); return cdata->_bounds_type; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_bounds -// Access: Published -// Description: Resets the bounding volume so that it is the -// indicated volume. When it is explicitly set, the -// bounding volume will no longer be automatically -// computed according to the contents of the node -// itself, for nodes like GeomNodes and TextNodes that -// contain substance (but the bounding volume will still -// be automatically expanded to include its children). -// -// Call clear_bounds() if you would like to return the -// bounding volume to its default behavior later. -//////////////////////////////////////////////////////////////////// +/** + * Resets the bounding volume so that it is the indicated volume. When it is + * explicitly set, the bounding volume will no longer be automatically + * computed according to the contents of the node itself, for nodes like + * GeomNodes and TextNodes that contain substance (but the bounding volume + * will still be automatically expanded to include its children). + * + * Call clear_bounds() if you would like to return the bounding volume to its + * default behavior later. + */ void PandaNode:: set_bounds(const BoundingVolume *volume) { Thread *current_thread = Thread::get_current_thread(); @@ -2316,11 +2032,9 @@ set_bounds(const BoundingVolume *volume) { CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_bound -// Access: Published -// Description: Deprecated. Use set_bounds() instead. -//////////////////////////////////////////////////////////////////// +/** + * Deprecated. Use set_bounds() instead. + */ void PandaNode:: set_bound(const BoundingVolume *volume) { pgraph_cat.warning() @@ -2328,14 +2042,11 @@ set_bound(const BoundingVolume *volume) { set_bounds(volume); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_bounds -// Access: Published -// Description: Returns the external bounding volume of this node: a -// bounding volume that contains the user bounding -// volume, the internal bounding volume, and all of the -// children's bounding volumes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the external bounding volume of this node: a bounding volume that + * contains the user bounding volume, the internal bounding volume, and all of + * the children's bounding volumes. + */ CPT(BoundingVolume) PandaNode:: get_bounds(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -2354,22 +2065,17 @@ get_bounds(Thread *current_thread) const { return cdata->_external_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_bounds -// Access: Published -// Description: This flavor of get_bounds() return the external -// bounding volume, and also fills in seq with the -// bounding volume's current sequence number. When this -// sequence number changes, it indicates that the -// bounding volume might have changed, e.g. because some -// nested child's bounding volume has changed. -// -// Although this might occasionally increment without -// changing the bounding volume, the bounding volume -// will never change without incrementing this counter, -// so as long as this counter remains unchanged you can -// be confident the bounding volume is also unchanged. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_bounds() return the external bounding volume, and also + * fills in seq with the bounding volume's current sequence number. When this + * sequence number changes, it indicates that the bounding volume might have + * changed, e.g. because some nested child's bounding volume has changed. + * + * Although this might occasionally increment without changing the bounding + * volume, the bounding volume will never change without incrementing this + * counter, so as long as this counter remains unchanged you can be confident + * the bounding volume is also unchanged. + */ CPT(BoundingVolume) PandaNode:: get_bounds(UpdateSeq &seq, Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -2390,19 +2096,15 @@ get_bounds(UpdateSeq &seq, Thread *current_thread) const { return cdata->_external_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_nested_vertices -// Access: Published -// Description: Returns the total number of vertices that will be -// rendered by this node and all of its descendents. -// -// This is not necessarily an accurate count of vertices -// that will actually be rendered, since this will -// include all vertices of all LOD's, and it will also -// include hidden nodes. It may also omit or only -// approximate certain kinds of dynamic geometry. -// However, it will not include stashed nodes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of vertices that will be rendered by this node and + * all of its descendents. + * + * This is not necessarily an accurate count of vertices that will actually be + * rendered, since this will include all vertices of all LOD's, and it will + * also include hidden nodes. It may also omit or only approximate certain + * kinds of dynamic geometry. However, it will not include stashed nodes. + */ int PandaNode:: get_nested_vertices(Thread *current_thread) const { int pipeline_stage = current_thread->get_pipeline_stage(); @@ -2421,24 +2123,19 @@ get_nested_vertices(Thread *current_thread) const { return cdata->_nested_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::mark_bounds_stale -// Access: Published -// Description: Indicates that the bounding volume, or something that -// influences the bounding volume (or any of the other -// things stored in CData, like net_collide_mask), -// may have changed for this node, and that it must be -// recomputed. -// -// With no parameters, this means to iterate through all -// stages including and upstream of the current pipeline -// stage. -// -// This method is intended for internal use; usually it -// is not necessary for a user to call this directly. -// It will be called automatically by derived classes -// when appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the bounding volume, or something that influences the + * bounding volume (or any of the other things stored in CData, like + * net_collide_mask), may have changed for this node, and that it must be + * recomputed. + * + * With no parameters, this means to iterate through all stages including and + * upstream of the current pipeline stage. + * + * This method is intended for internal use; usually it is not necessary for a + * user to call this directly. It will be called automatically by derived + * classes when appropriate. + */ void PandaNode:: mark_bounds_stale(Thread *current_thread) const { OPEN_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler, current_thread) { @@ -2447,22 +2144,17 @@ mark_bounds_stale(Thread *current_thread) const { CLOSE_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::mark_internal_bounds_stale -// Access: Published -// Description: Should be called by a derived class to mark the -// internal bounding volume stale, so that -// compute_internal_bounds() will be called when the -// bounding volume is next requested. -// -// With no parameters, this means to iterate through all -// stages including and upstream of the current pipeline -// stage. -// -// It is normally not necessary to call this method -// directly; each node should be responsible for calling -// it when its internals have changed. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to mark the internal bounding volume + * stale, so that compute_internal_bounds() will be called when the bounding + * volume is next requested. + * + * With no parameters, this means to iterate through all stages including and + * upstream of the current pipeline stage. + * + * It is normally not necessary to call this method directly; each node should + * be responsible for calling it when its internals have changed. + */ void PandaNode:: mark_internal_bounds_stale(Thread *current_thread) { OPEN_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler, current_thread) { @@ -2471,89 +2163,71 @@ mark_internal_bounds_stale(Thread *current_thread) { CLOSE_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_geom_node -// Access: Published, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from GeomNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(GeomNode::get_class_type()), since this -// test is so important to rendering. -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from GeomNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(GeomNode::get_class_type()), since this test is so important to + * rendering. + */ bool PandaNode:: is_geom_node() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_lod_node -// Access: Published, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from LODNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(LODNode::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from LODNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(LODNode::get_class_type()). + */ bool PandaNode:: is_lod_node() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_collision_node -// Access: Published, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from CollisionNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(CollisionNode::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from CollisionNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(CollisionNode::get_class_type()). + */ bool PandaNode:: is_collision_node() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::as_light -// Access: Published, Virtual -// Description: Cross-casts the node to a Light pointer, if it is one -// of the four kinds of Light nodes, or returns NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Cross-casts the node to a Light pointer, if it is one of the four kinds of + * Light nodes, or returns NULL if it is not. + */ Light *PandaNode:: as_light() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::is_ambient_light -// Access: Published, Virtual -// Description: Returns true if this is an AmbientLight, false if it -// is not a light, or it is some other kind of light. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an AmbientLight, false if it is not a light, or it + * is some other kind of light. + */ bool PandaNode:: is_ambient_light() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::decode_from_bam_stream -// Access: Published, Static -// Description: Reads the string created by a previous call to -// encode_to_bam_stream(), and extracts and returns the -// single object on that string. Returns NULL on error. -// -// This method is intended to replace -// decode_raw_from_bam_stream() when you know the stream -// in question returns an object of type PandaNode, -// allowing for easier reference count management. Note -// that the caller is still responsible for maintaining -// the reference count on the return value. -//////////////////////////////////////////////////////////////////// +/** + * Reads the string created by a previous call to encode_to_bam_stream(), and + * extracts and returns the single object on that string. Returns NULL on + * error. + * + * This method is intended to replace decode_raw_from_bam_stream() when you + * know the stream in question returns an object of type PandaNode, allowing + * for easier reference count management. Note that the caller is still + * responsible for maintaining the reference count on the return value. + */ PT(PandaNode) PandaNode:: decode_from_bam_stream(const string &data, BamReader *reader) { TypedWritable *object; @@ -2566,13 +2240,10 @@ decode_from_bam_stream(const string &data, BamReader *reader) { return DCAST(PandaNode, object); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_internal_bounds -// Access: Protected -// Description: Returns the node's internal bounding volume. This is -// the bounding volume around the node alone, without -// including children. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node's internal bounding volume. This is the bounding volume + * around the node alone, without including children. + */ CPT(BoundingVolume) PandaNode:: get_internal_bounds(int pipeline_stage, Thread *current_thread) const { while (true) { @@ -2590,8 +2261,8 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { mark = cdata->_internal_bounds_mark; } - // First, call compute_internal_bounds without acquiring the lock. - // This avoids a deadlock condition. + // First, call compute_internal_bounds without acquiring the lock. This + // avoids a deadlock condition. CPT(BoundingVolume) internal_bounds; int internal_vertices; compute_internal_bounds(internal_bounds, internal_vertices, @@ -2608,22 +2279,18 @@ get_internal_bounds(int pipeline_stage, Thread *current_thread) const { return cdataw->_internal_bounds; } - // Dang, someone in another thread incremented - // _internal_bounds_mark while we weren't holding the lock. That - // means we need to go back and do it again. + // Dang, someone in another thread incremented _internal_bounds_mark while + // we weren't holding the lock. That means we need to go back and do it + // again. } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_internal_vertices -// Access: Protected -// Description: Returns the total number of vertices that will be -// rendered by this particular node alone, not -// accounting for its children. -// -// This may not include all vertices for certain dynamic -// effects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of vertices that will be rendered by this + * particular node alone, not accounting for its children. + * + * This may not include all vertices for certain dynamic effects. + */ int PandaNode:: get_internal_vertices(int pipeline_stage, Thread *current_thread) const { while (true) { @@ -2637,8 +2304,8 @@ get_internal_vertices(int pipeline_stage, Thread *current_thread) const { mark = cdata->_internal_bounds_mark; } - // First, call compute_internal_bounds without acquiring the lock. - // This avoids a deadlock condition. + // First, call compute_internal_bounds without acquiring the lock. This + // avoids a deadlock condition. CPT(BoundingVolume) internal_bounds; int internal_vertices; compute_internal_bounds(internal_bounds, internal_vertices, @@ -2655,21 +2322,18 @@ get_internal_vertices(int pipeline_stage, Thread *current_thread) const { return cdataw->_internal_vertices; } - // Dang, someone in another thread incremented - // _internal_bounds_mark while we weren't holding the lock. That - // means we need to go back and do it again. + // Dang, someone in another thread incremented _internal_bounds_mark while + // we weren't holding the lock. That means we need to go back and do it + // again. } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_internal_bounds -// Access: Protected -// Description: This is provided as an alternate way for a node to -// set its own internal bounds, rather than overloading -// compute_internal_bounds(). If this method is called, -// the internal bounding volume will immediately be set -// to the indicated pointer. -//////////////////////////////////////////////////////////////////// +/** + * This is provided as an alternate way for a node to set its own internal + * bounds, rather than overloading compute_internal_bounds(). If this method + * is called, the internal bounding volume will immediately be set to the + * indicated pointer. + */ void PandaNode:: set_internal_bounds(const BoundingVolume *volume) { Thread *current_thread = Thread::get_current_thread(); @@ -2683,17 +2347,13 @@ set_internal_bounds(const BoundingVolume *volume) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::force_bounds_stale -// Access: Protected -// Description: Similar to mark_bounds_stale(), except that the -// parents of this node marked stale even if this node -// was already considered stale. -// -// With no parameters, this means to iterate through all -// stages including and upstream of the current pipeline -// stage. -//////////////////////////////////////////////////////////////////// +/** + * Similar to mark_bounds_stale(), except that the parents of this node marked + * stale even if this node was already considered stale. + * + * With no parameters, this means to iterate through all stages including and + * upstream of the current pipeline stage. + */ void PandaNode:: force_bounds_stale(Thread *current_thread) { OPEN_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler, current_thread) { @@ -2702,13 +2362,10 @@ force_bounds_stale(Thread *current_thread) { CLOSE_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::force_bounds_stale -// Access: Protected -// Description: Similar to mark_bounds_stale(), except that the -// parents of this node marked stale even if this node -// was already considered stale. -//////////////////////////////////////////////////////////////////// +/** + * Similar to mark_bounds_stale(), except that the parents of this node marked + * stale even if this node was already considered stale. + */ void PandaNode:: force_bounds_stale(int pipeline_stage, Thread *current_thread) { { @@ -2717,13 +2374,13 @@ force_bounds_stale(int pipeline_stage, Thread *current_thread) { mark_bam_modified(); // It is important that we allow this lock to be dropped before we - // continue up the graph; otherwise, we risk deadlock from another - // thread walking down the graph. + // continue up the graph; otherwise, we risk deadlock from another thread + // walking down the graph. } - // It is similarly important that we use get_parents() here to copy - // the parents list, instead of keeping the lock open while we walk - // through the parents list directly on the node. + // It is similarly important that we use get_parents() here to copy the + // parents list, instead of keeping the lock open while we walk through the + // parents list directly on the node. Parents parents; { CDStageReader cdata(_cycler, pipeline_stage, current_thread); @@ -2736,12 +2393,10 @@ force_bounds_stale(int pipeline_stage, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_mark_geom_bounds_stale -// Access: Protected, Virtual -// Description: Recursively calls Geom::mark_bounds_stale() on every -// Geom at this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Recursively calls Geom::mark_bounds_stale() on every Geom at this node and + * below. + */ void PandaNode:: r_mark_geom_bounds_stale(Thread *current_thread) { Children children = get_children(current_thread); @@ -2759,14 +2414,11 @@ r_mark_geom_bounds_stale(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Returns a newly-allocated BoundingVolume that -// represents the internal contents of the node. Should -// be overridden by PandaNode classes that contain -// something internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated BoundingVolume that represents the internal + * contents of the node. Should be overridden by PandaNode classes that + * contain something internally. + */ void PandaNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -2776,83 +2428,63 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::parents_changed -// Access: Protected, Virtual -// Description: Called after a scene graph update that either adds or -// remove parents from this node, this just provides a -// hook for derived PandaNode objects that need to -// update themselves based on the set of parents the -// node has. -//////////////////////////////////////////////////////////////////// +/** + * Called after a scene graph update that either adds or remove parents from + * this node, this just provides a hook for derived PandaNode objects that + * need to update themselves based on the set of parents the node has. + */ void PandaNode:: parents_changed() { nassertv((_unexpected_change_flags & UC_parents) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::children_changed -// Access: Protected, Virtual -// Description: Called after a scene graph update that either adds or -// remove children from this node, this just provides a -// hook for derived PandaNode objects that need to -// update themselves based on the set of children the -// node has. -//////////////////////////////////////////////////////////////////// +/** + * Called after a scene graph update that either adds or remove children from + * this node, this just provides a hook for derived PandaNode objects that + * need to update themselves based on the set of children the node has. + */ void PandaNode:: children_changed() { nassertv((_unexpected_change_flags & UC_children) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::transform_changed -// Access: Protected, Virtual -// Description: Called after the node's transform has been changed -// for any reason, this just provides a hook so derived -// classes can do something special in this case. -//////////////////////////////////////////////////////////////////// +/** + * Called after the node's transform has been changed for any reason, this + * just provides a hook so derived classes can do something special in this + * case. + */ void PandaNode:: transform_changed() { nassertv((_unexpected_change_flags & UC_transform) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::state_changed -// Access: Protected, Virtual -// Description: Called after the node's RenderState has been changed -// for any reason, this just provides a hook so derived -// classes can do something special in this case. -//////////////////////////////////////////////////////////////////// +/** + * Called after the node's RenderState has been changed for any reason, this + * just provides a hook so derived classes can do something special in this + * case. + */ void PandaNode:: state_changed() { nassertv((_unexpected_change_flags & UC_state) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::draw_mask_changed -// Access: Protected, Virtual -// Description: Called after the node's DrawMask has been changed -// for any reason, this just provides a hook so derived -// classes can do something special in this case. -//////////////////////////////////////////////////////////////////// +/** + * Called after the node's DrawMask has been changed for any reason, this just + * provides a hook so derived classes can do something special in this case. + */ void PandaNode:: draw_mask_changed() { nassertv((_unexpected_change_flags & UC_draw_mask) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_copy_subgraph -// Access: Protected, Virtual -// Description: This is the recursive implementation of copy_subgraph(). -// It returns a copy of the entire subgraph rooted at -// this node. -// -// Note that it includes the parameter inst_map, which -// is a map type, and is not (and cannot be) exported -// from PANDA.DLL. Thus, any derivative of PandaNode -// that is not also a member of PANDA.DLL *cannot* -// access this map. -//////////////////////////////////////////////////////////////////// +/** + * This is the recursive implementation of copy_subgraph(). It returns a copy + * of the entire subgraph rooted at this node. + * + * Note that it includes the parameter inst_map, which is a map type, and is + * not (and cannot be) exported from PANDA.DLL. Thus, any derivative of + * PandaNode that is not also a member of PANDA.DLL *cannot* access this map. + */ PT(PandaNode) PandaNode:: r_copy_subgraph(PandaNode::InstanceMap &inst_map, Thread *current_thread) const { PT(PandaNode) copy = make_copy(); @@ -2870,21 +2502,16 @@ r_copy_subgraph(PandaNode::InstanceMap &inst_map, Thread *current_thread) const return copy; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_copy_children -// Access: Protected, Virtual -// Description: This is called by r_copy_subgraph(); the copy has -// already been made of this particular node (and this -// is the copy); this function's job is to copy all of -// the children from the original. -// -// Note that it includes the parameter inst_map, which -// is a map type, and is not (and cannot be) exported -// from PANDA.DLL. Thus, any derivative of PandaNode -// that is not also a member of PANDA.DLL *cannot* -// access this map, and probably should not even -// override this function. -//////////////////////////////////////////////////////////////////// +/** + * This is called by r_copy_subgraph(); the copy has already been made of this + * particular node (and this is the copy); this function's job is to copy all + * of the children from the original. + * + * Note that it includes the parameter inst_map, which is a map type, and is + * not (and cannot be) exported from PANDA.DLL. Thus, any derivative of + * PandaNode that is not also a member of PANDA.DLL *cannot* access this map, + * and probably should not even override this function. + */ void PandaNode:: r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, Thread *current_thread) { @@ -2896,10 +2523,10 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, PandaNode *source_child = (*di).get_child(); PT(PandaNode) dest_child; - // Check to see if we have already copied this child. If we - // have, use the copy. In this way, a subgraph that contains - // instances will be correctly duplicated into another subgraph - // that also contains its own instances. + // Check to see if we have already copied this child. If we have, use the + // copy. In this way, a subgraph that contains instances will be + // correctly duplicated into another subgraph that also contains its own + // instances. InstanceMap::const_iterator ci; ci = inst_map.find(source_child); if (ci != inst_map.end()) { @@ -2913,20 +2540,16 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_prepare_scene -// Access: Public, Virtual -// Description: The recursive implementation of prepare_scene(). -// Don't call this directly; call -// PandaNode::prepare_scene() or -// NodePath::prepare_scene() instead. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of prepare_scene(). Don't call this directly; + * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. + */ void PandaNode:: r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) { Children children = get_children(current_thread); - // We must call get_num_children() each time through the loop, in - // case we're running SIMPLE_THREADS and we get interrupted. + // We must call get_num_children() each time through the loop, in case we're + // running SIMPLE_THREADS and we get interrupted. int i; for (i = 0; i < children.get_num_children(); i++) { PandaNode *child = children.get_child(i); @@ -2942,14 +2565,11 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_cull_callback -// Access: Protected -// Description: Intended to be called in the constructor by any -// subclass that defines cull_callback(), this sets up -// the flags to indicate that the cullback needs to be -// called. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called in the constructor by any subclass that defines + * cull_callback(), this sets up the flags to indicate that the cullback needs + * to be called. + */ void PandaNode:: set_cull_callback() { Thread *current_thread = Thread::get_current_thread(); @@ -2961,11 +2581,9 @@ set_cull_callback() { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::disable_cull_callback -// Access: Protected -// Description: disables the call back -//////////////////////////////////////////////////////////////////// +/** + * disables the call back + */ void PandaNode:: disable_cull_callback() { Thread *current_thread = Thread::get_current_thread(); @@ -2977,19 +2595,17 @@ disable_cull_callback() { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::stage_remove_child -// Access: Private -// Description: The private implementation of remove_child(), for a -// particular pipeline stage. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of remove_child(), for a particular pipeline + * stage. + */ bool PandaNode:: stage_remove_child(PandaNode *child_node, int pipeline_stage, Thread *current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); - // First, look for the parent in the child's up list, to ensure the - // child is known. + // First, look for the parent in the child's up list, to ensure the child is + // known. CDStageWriter cdata_child(child_node->_cycler, pipeline_stage, current_thread); int parent_index = child_node->do_find_parent(this, cdata_child); @@ -3018,19 +2634,16 @@ stage_remove_child(PandaNode *child_node, int pipeline_stage, return true; } - // Never heard of this child. This shouldn't be possible, because - // the parent was in the child's up list, above. Must be some - // internal error. + // Never heard of this child. This shouldn't be possible, because the + // parent was in the child's up list, above. Must be some internal error. nassertr(false, false); return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::stage_replace_child -// Access: Private -// Description: The private implementation of replace_child(), for a -// particular pipeline stage. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of replace_child(), for a particular pipeline + * stage. + */ bool PandaNode:: stage_replace_child(PandaNode *orig_child, PandaNode *new_child, int pipeline_stage, Thread *current_thread) { @@ -3039,8 +2652,8 @@ stage_replace_child(PandaNode *orig_child, PandaNode *new_child, CDStageWriter cdata_orig_child(orig_child->_cycler, pipeline_stage, current_thread); CDStageWriter cdata_new_child(new_child->_cycler, pipeline_stage, current_thread); - // First, look for the parent in the child's up list, to ensure the - // child is known. + // First, look for the parent in the child's up list, to ensure the child + // is known. int parent_index = orig_child->do_find_parent(this, cdata_orig_child); if (parent_index < 0) { // Nope, no relation. @@ -3078,9 +2691,9 @@ stage_replace_child(PandaNode *orig_child, PandaNode *new_child, dc.set_child(new_child); } else { - // Never heard of this child. This shouldn't be possible, because - // the parent was in the child's up list, above. Must be some - // internal error. + // Never heard of this child. This shouldn't be possible, because the + // parent was in the child's up list, above. Must be some internal + // error. nassertr(false, false); return false; } @@ -3105,20 +2718,16 @@ stage_replace_child(PandaNode *orig_child, PandaNode *new_child, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::quick_add_new_child -// Access: Private -// Description: Similar to add_child(), but performs fewer checks. -// The purpose of this method is to add a child node -// that was newly constructed, to a parent node that was -// newly constructed, so we know we have to make fewer -// sanity checks. This is a private method; do not call -// it directly. -//////////////////////////////////////////////////////////////////// +/** + * Similar to add_child(), but performs fewer checks. The purpose of this + * method is to add a child node that was newly constructed, to a parent node + * that was newly constructed, so we know we have to make fewer sanity checks. + * This is a private method; do not call it directly. + */ void PandaNode:: quick_add_new_child(PandaNode *child_node, int sort, Thread *current_thread) { - // Apply this operation to the current stage as well as to all - // upstream stages. + // Apply this operation to the current stage as well as to all upstream + // stages. OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { CDStageWriter cdata(_cycler, pipeline_stage, current_thread); CDStageWriter cdata_child(child_node->_cycler, pipeline_stage, current_thread); @@ -3129,12 +2738,9 @@ quick_add_new_child(PandaNode *child_node, int sort, Thread *current_thread) { CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::report_cycle -// Access: Private -// Description: Raises an assertion when a graph cycle attempt is -// detected (and aborted). -//////////////////////////////////////////////////////////////////// +/** + * Raises an assertion when a graph cycle attempt is detected (and aborted). + */ void PandaNode:: report_cycle(PandaNode *child_node) { ostringstream strm; @@ -3143,13 +2749,10 @@ report_cycle(PandaNode *child_node) { nassert_raise(strm.str()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::find_node_above -// Access: Private -// Description: Returns true if the indicated node is this node, or -// any ancestor of this node; or false if it is not in -// this node's ancestry. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated node is this node, or any ancestor of this + * node; or false if it is not in this node's ancestry. + */ bool PandaNode:: find_node_above(PandaNode *node) { if (node == this) { @@ -3167,23 +2770,20 @@ find_node_above(PandaNode *node) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::attach -// Access: Private, Static -// Description: Creates a new parent-child relationship, and returns -// the new NodePathComponent. If the child was already -// attached to the indicated parent, repositions it and -// returns the original NodePathComponent. -// -// This operation is automatically propagated back up to -// pipeline 0, from the specified pipeline stage. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new parent-child relationship, and returns the new + * NodePathComponent. If the child was already attached to the indicated + * parent, repositions it and returns the original NodePathComponent. + * + * This operation is automatically propagated back up to pipeline 0, from the + * specified pipeline stage. + */ PT(NodePathComponent) PandaNode:: attach(NodePathComponent *parent, PandaNode *child_node, int sort, int pipeline_stage, Thread *current_thread) { if (parent == (NodePathComponent *)NULL) { - // Attaching to NULL means to create a new "instance" with no - // attachments, and no questions asked. + // Attaching to NULL means to create a new "instance" with no attachments, + // and no questions asked. PT(NodePathComponent) child = new NodePathComponent(child_node, (NodePathComponent *)NULL, pipeline_stage, current_thread); @@ -3192,8 +2792,8 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, return child; } - // See if the child was already attached to the parent. If it was, - // we'll use that same NodePathComponent. + // See if the child was already attached to the parent. If it was, we'll + // use that same NodePathComponent. PT(NodePathComponent) child = get_component(parent, child_node, pipeline_stage, current_thread); if (child == (NodePathComponent *)NULL) { @@ -3207,14 +2807,12 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, return child; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::detach -// Access: Private, Static -// Description: Breaks a parent-child relationship. -// -// This operation is automatically propagated back up to -// pipeline 0, from the specified pipeline stage. -//////////////////////////////////////////////////////////////////// +/** + * Breaks a parent-child relationship. + * + * This operation is automatically propagated back up to pipeline 0, from the + * specified pipeline stage. + */ void PandaNode:: detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { nassertv(child != (NodePathComponent *)NULL); @@ -3228,15 +2826,12 @@ detach(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { child->get_node()->parents_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::detach_one_stage -// Access: Private, Static -// Description: Breaks a parent-child relationship. -// -// This operation is not automatically propagated -// upstream. It is applied to the indicated pipeline -// stage only. -//////////////////////////////////////////////////////////////////// +/** + * Breaks a parent-child relationship. + * + * This operation is not automatically propagated upstream. It is applied to + * the indicated pipeline stage only. + */ void PandaNode:: detach_one_stage(NodePathComponent *child, int pipeline_stage, Thread *current_thread) { @@ -3254,14 +2849,13 @@ detach_one_stage(NodePathComponent *child, int pipeline_stage, if (parent_index >= 0) { // Now look for the child and break the actual connection. - // First, look for and remove the parent node from the child's up - // list. + // First, look for and remove the parent node from the child's up list. int num_erased = cdata_child->modify_up()->erase(UpConnection(parent_node)); nassertv(num_erased == 1); - // Now, look for and remove the child node from the parent's down - // list. We also check in the stashed list, in case the child node - // has been stashed. + // Now, look for and remove the child node from the parent's down list. + // We also check in the stashed list, in case the child node has been + // stashed. Down::iterator di; bool found = false; PT(Down) down = cdata_parent->modify_down(); @@ -3293,18 +2887,15 @@ detach_one_stage(NodePathComponent *child, int pipeline_stage, parent_node->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::reparent -// Access: Private, Static -// Description: Switches a node from one parent to another. Returns -// true if the new connection is allowed, or false if it -// conflicts with another instance (that is, another -// instance of the child is already attached to the -// indicated parent). -// -// This operation is automatically propagated back up to -// pipeline 0, from the specified pipeline stage. -//////////////////////////////////////////////////////////////////// +/** + * Switches a node from one parent to another. Returns true if the new + * connection is allowed, or false if it conflicts with another instance (that + * is, another instance of the child is already attached to the indicated + * parent). + * + * This operation is automatically propagated back up to pipeline 0, from the + * specified pipeline stage. + */ bool PandaNode:: reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { @@ -3312,8 +2903,8 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, if (new_parent != (NodePathComponent *)NULL && !new_parent->get_node()->verify_child_no_cycles(child->get_node())) { - // Whoops, adding this child node would introduce a cycle in the - // scene graph. + // Whoops, adding this child node would introduce a cycle in the scene + // graph. return false; } @@ -3336,27 +2927,23 @@ reparent(NodePathComponent *new_parent, NodePathComponent *child, int sort, return any_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::reparent_one_stage -// Access: Private, Static -// Description: Switches a node from one parent to another. Returns -// true if the new connection is allowed, or false if it -// conflicts with another instance (that is, another -// instance of the child is already attached to the -// indicated parent). -// -// This operation is not automatically propagated -// upstream. It is applied to the indicated pipeline -// stage only. -//////////////////////////////////////////////////////////////////// +/** + * Switches a node from one parent to another. Returns true if the new + * connection is allowed, or false if it conflicts with another instance (that + * is, another instance of the child is already attached to the indicated + * parent). + * + * This operation is not automatically propagated upstream. It is applied to + * the indicated pipeline stage only. + */ bool PandaNode:: reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, int sort, bool as_stashed, int pipeline_stage, Thread *current_thread) { nassertr(child != (NodePathComponent *)NULL, false); - // Keep a reference count to the new parent, since detaching the - // child might lose the count. + // Keep a reference count to the new parent, since detaching the child might + // lose the count. PT(NodePathComponent) keep_parent = new_parent; if (!child->is_top_node(pipeline_stage, current_thread)) { @@ -3408,13 +2995,10 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_component -// Access: Private, Static -// Description: Returns the NodePathComponent based on the indicated -// child of the given parent, or NULL if there is no -// such parent-child relationship. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePathComponent based on the indicated child of the given + * parent, or NULL if there is no such parent-child relationship. + */ PT(NodePathComponent) PandaNode:: get_component(NodePathComponent *parent, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { @@ -3423,9 +3007,9 @@ get_component(NodePathComponent *parent, PandaNode *child_node, LightReMutexHolder holder(child_node->_paths_lock); - // First, walk through the list of NodePathComponents we already - // have on the child, looking for one that already exists, - // referencing the indicated parent component. + // First, walk through the list of NodePathComponents we already have on the + // child, looking for one that already exists, referencing the indicated + // parent component. Paths::const_iterator pi; for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { if ((*pi)->get_next(pipeline_stage, current_thread) == parent) { @@ -3434,8 +3018,8 @@ get_component(NodePathComponent *parent, PandaNode *child_node, } } - // We don't already have a NodePathComponent referring to this - // parent-child relationship. Are they actually related? + // We don't already have a NodePathComponent referring to this parent-child + // relationship. Are they actually related? CDStageReader cdata_child(child_node->_cycler, pipeline_stage, current_thread); int parent_index = child_node->do_find_parent(parent_node, cdata_child); @@ -3451,27 +3035,23 @@ get_component(NodePathComponent *parent, PandaNode *child_node, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_top_component -// Access: Private, Static -// Description: Returns a NodePathComponent referencing the -// indicated node as a singleton. It is invalid to call -// this for a node that has parents, unless you are -// about to create a new instance (and immediately -// reconnect the NodePathComponent elsewhere). -// -// If force is true, this will always return something, -// even if it needs to create a new top component; -// otherwise, if force is false, it will return NULL if -// there is not already a top component available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NodePathComponent referencing the indicated node as a singleton. + * It is invalid to call this for a node that has parents, unless you are + * about to create a new instance (and immediately reconnect the + * NodePathComponent elsewhere). + * + * If force is true, this will always return something, even if it needs to + * create a new top component; otherwise, if force is false, it will return + * NULL if there is not already a top component available. + */ PT(NodePathComponent) PandaNode:: get_top_component(PandaNode *child_node, bool force, int pipeline_stage, Thread *current_thread) { LightReMutexHolder holder(child_node->_paths_lock); - // Walk through the list of NodePathComponents we already have on - // the child, looking for one that already exists as a top node. + // Walk through the list of NodePathComponents we already have on the child, + // looking for one that already exists as a top node. Paths::const_iterator pi; for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { if ((*pi)->is_top_node(pipeline_stage, current_thread)) { @@ -3481,13 +3061,13 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage, } if (!force) { - // If we don't care to force the point, return NULL to indicate - // there's not already a top component. + // If we don't care to force the point, return NULL to indicate there's + // not already a top component. return NULL; } - // We don't already have such a NodePathComponent; create and - // return a new one. + // We don't already have such a NodePathComponent; create and return a new + // one. PT(NodePathComponent) child = new NodePathComponent(child_node, (NodePathComponent *)NULL, pipeline_stage, current_thread); @@ -3496,17 +3076,13 @@ get_top_component(PandaNode *child_node, bool force, int pipeline_stage, return child; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::get_generic_component -// Access: Private -// Description: Returns a NodePathComponent referencing this node as -// a path from the root. -// -// Unless accept_ambiguity is true, it is only valid to -// call this if there is an unambiguous path from the -// root; otherwise, a warning will be issued and one -// path will be chosen arbitrarily. -//////////////////////////////////////////////////////////////////// +/** + * Returns a NodePathComponent referencing this node as a path from the root. + * + * Unless accept_ambiguity is true, it is only valid to call this if there is + * an unambiguous path from the root; otherwise, a warning will be issued and + * one path will be chosen arbitrarily. + */ PT(NodePathComponent) PandaNode:: get_generic_component(bool accept_ambiguity, int pipeline_stage, Thread *current_thread) { @@ -3524,14 +3100,11 @@ get_generic_component(bool accept_ambiguity, int pipeline_stage, return result; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_get_generic_component -// Access: Private -// Description: The recursive implementation of -// get_generic_component, this simply sets the flag when -// the ambiguity is detected (so we can report the -// bottom node that started the ambiguous search). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of get_generic_component, this simply sets the + * flag when the ambiguity is detected (so we can report the bottom node that + * started the ambiguous search). + */ PT(NodePathComponent) PandaNode:: r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected, int pipeline_stage, Thread *current_thread) { @@ -3571,13 +3144,10 @@ r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected, return get_component(parent, this, pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::delete_component -// Access: Private -// Description: Removes a NodePathComponent from the set prior to -// its deletion. This should only be called by the -// NodePathComponent destructor. -//////////////////////////////////////////////////////////////////// +/** + * Removes a NodePathComponent from the set prior to its deletion. This + * should only be called by the NodePathComponent destructor. + */ void PandaNode:: delete_component(NodePathComponent *component) { LightReMutexHolder holder(_paths_lock); @@ -3585,24 +3155,18 @@ delete_component(NodePathComponent *component) { nassertv(num_erased == 1); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::sever_connection -// Access: Private, Static -// Description: This is called internally when a parent-child -// connection is broken to update the NodePathComponents -// that reflected this connection. -// -// It severs any NodePathComponents on the child node -// that reference the indicated parent node. These -// components remain unattached; there may therefore be -// multiple "instances" of a node that all have no -// parent, even while there are other instances that do -// have parents. -// -// This operation is not automatically propagated -// upstream. It is applied to the indicated pipeline -// stage only. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally when a parent-child connection is broken to + * update the NodePathComponents that reflected this connection. + * + * It severs any NodePathComponents on the child node that reference the + * indicated parent node. These components remain unattached; there may + * therefore be multiple "instances" of a node that all have no parent, even + * while there are other instances that do have parents. + * + * This operation is not automatically propagated upstream. It is applied to + * the indicated pipeline stage only. + */ void PandaNode:: sever_connection(PandaNode *parent_node, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { @@ -3620,22 +3184,17 @@ sever_connection(PandaNode *parent_node, PandaNode *child_node, child_node->fix_path_lengths(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::new_connection -// Access: Private, Static -// Description: This is called internally when a parent-child -// connection is established to update the -// NodePathComponents that might be involved. -// -// It adjusts any NodePathComponents the child has that -// reference the child as a top node. Any other -// components we can leave alone, because we are making -// a new instance of the child. -// -// This operation is not automatically propagated -// upstream. It is applied to the indicated pipeline -// stage only. -//////////////////////////////////////////////////////////////////// +/** + * This is called internally when a parent-child connection is established to + * update the NodePathComponents that might be involved. + * + * It adjusts any NodePathComponents the child has that reference the child as + * a top node. Any other components we can leave alone, because we are making + * a new instance of the child. + * + * This operation is not automatically propagated upstream. It is applied to + * the indicated pipeline stage only. + */ void PandaNode:: new_connection(PandaNode *parent_node, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { @@ -3651,18 +3210,14 @@ new_connection(PandaNode *parent_node, PandaNode *child_node, child_node->fix_path_lengths(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::fix_path_lengths -// Access: Private -// Description: Recursively fixes the _length member of each -// NodePathComponent at this level and below, after an -// add or delete child operation that might have messed -// these up. -// -// This operation is not automatically propagated -// upstream. It is applied to the indicated pipeline -// stage only. -//////////////////////////////////////////////////////////////////// +/** + * Recursively fixes the _length member of each NodePathComponent at this + * level and below, after an add or delete child operation that might have + * messed these up. + * + * This operation is not automatically propagated upstream. It is applied to + * the indicated pipeline stage only. + */ void PandaNode:: fix_path_lengths(int pipeline_stage, Thread *current_thread) { LightReMutexHolder holder(_paths_lock); @@ -3676,9 +3231,9 @@ fix_path_lengths(int pipeline_stage, Thread *current_thread) { } } - // If any paths were updated, we have to recurse on all of our - // children, since any one of those paths might be shared by any of - // our child nodes. Don't hold any locks while we recurse. + // If any paths were updated, we have to recurse on all of our children, + // since any one of those paths might be shared by any of our child nodes. + // Don't hold any locks while we recurse. if (any_wrong) { Children children; Stashed stashed; @@ -3702,11 +3257,9 @@ fix_path_lengths(int pipeline_stage, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::r_list_descendants -// Access: Private -// Description: The recursive implementation of ls(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of ls(). + */ void PandaNode:: r_list_descendants(ostream &out, int indent_level) const { write(out, indent_level); @@ -3726,17 +3279,15 @@ r_list_descendants(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::do_find_child -// Access: Private -// Description: The private implementation of find_child(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of find_child(). + */ int PandaNode:: do_find_child(PandaNode *node, const PandaNode::Down *down) const { nassertr(node != (PandaNode *)NULL, -1); - // We have to search for the child by brute force, since we don't - // know what sort index it was added as. + // We have to search for the child by brute force, since we don't know what + // sort index it was added as. Down::const_iterator di; for (di = down->begin(); di != down->end(); ++di) { if ((*di).get_child() == node) { @@ -3747,24 +3298,21 @@ do_find_child(PandaNode *node, const PandaNode::Down *down) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::update_cached -// Access: Private -// Description: Updates the cached values of the node that are -// dependent on its children, such as the -// external bounding volume, the _net_collide_mask, -// and the _off_clip_planes. -// -// If update_bounds is false, it will not update the -// bounding volume or vertex count. -// -// The old value should be passed in; it will be -// released. The new value is returned. -//////////////////////////////////////////////////////////////////// +/** + * Updates the cached values of the node that are dependent on its children, + * such as the external bounding volume, the _net_collide_mask, and the + * _off_clip_planes. + * + * If update_bounds is false, it will not update the bounding volume or vertex + * count. + * + * The old value should be passed in; it will be released. The new value is + * returned. + */ PandaNode::CDStageWriter PandaNode:: update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageReader &cdata) { - // We might need to try this a couple of times, in case someone else - // steps on our result. + // We might need to try this a couple of times, in case someone else steps + // on our result. if (drawmask_cat.is_debug()) { drawmask_cat.debug(false) << *this << "::update_cached() {\n"; @@ -3786,8 +3334,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe bool renderable = is_renderable(); if (renderable) { - // If this node is itself renderable, it contributes to the net - // draw mask. + // If this node is itself renderable, it contributes to the net draw + // mask. net_draw_control_mask = cdata->_draw_control_mask; net_draw_show_mask = cdata->_draw_show_mask; } @@ -3808,17 +3356,16 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe int num_vertices = cdata->_internal_vertices; - // Now that we've got all the data we need from the node, we can - // release the lock. + // Now that we've got all the data we need from the node, we can release + // the lock. _cycler.release_read_stage(pipeline_stage, cdata.take_pointer()); int num_children = children.get_num_children(); - // We need to keep references to the bounding volumes, since in a - // threaded environment the pointers might go away while we're - // working (since we're not holding a lock on our set of children - // right now). But we also need the regular pointers, to pass to - // BoundingVolume::around(). + // We need to keep references to the bounding volumes, since in a threaded + // environment the pointers might go away while we're working (since we're + // not holding a lock on our set of children right now). But we also need + // the regular pointers, to pass to BoundingVolume::around(). const BoundingVolume **child_volumes; #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) pvector child_volumes_ref; @@ -3874,42 +3421,37 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe DrawMask child_control_mask = child_cdataw->_net_draw_control_mask; DrawMask child_show_mask = child_cdataw->_net_draw_show_mask; if (!(child_control_mask | child_show_mask).is_zero()) { - // This child includes a renderable node or subtree. Thus, - // we should propagate its draw masks. + // This child includes a renderable node or subtree. Thus, we + // should propagate its draw masks. renderable = true; // For each bit position in the masks, we have assigned the - // following semantic meaning. The number on the left - // represents the pairing of the corresponding bit from the - // control mask and from the show mask: + // following semantic meaning. The number on the left represents + // the pairing of the corresponding bit from the control mask and + // from the show mask: - // 00 : not a renderable node (control 0, show 0) - // 01 : a normally visible node (control 0, show 1) - // 10 : a hidden node (control 1, show 0) - // 11 : a show-through node (control 1, show 1) + // 00 : not a renderable node (control 0, show 0) 01 : a normally + // visible node (control 0, show 1) 10 : a hidden node + // (control 1, show 0) 11 : a show-through node (control 1, show + // 1) - // Now, when we accumulate these masks, we want to do so - // according to the following table, for each bit position: + // Now, when we accumulate these masks, we want to do so according + // to the following table, for each bit position: - // 00 01 10 11 (child) - // --------------------- - // 00 | 00 01 10 11 - // 01 | 01 01 01* 11 - // 10 | 10 01* 10 11 - // 11 | 11 11 11 11 - // (parent) + // 00 01 10 11 (child) --------------------- 00 | 00 01 + // 10 11 01 | 01 01 01* 11 10 | 10 01* 10 11 11 | 11 + // 11 11 11 (parent) - // This table is almost the same as the union of both masks, - // with one exception, marked with a * in the above table: - // if one is 10 and the other is 01--that is, one is hidden - // and the other is normally visible--then the result should - // be 01, normally visible. This is because we only want to - // propagate the hidden bit upwards if *all* renderable - // nodes are hidden. + // This table is almost the same as the union of both masks, with + // one exception, marked with a * in the above table: if one is 10 + // and the other is 01--that is, one is hidden and the other is + // normally visible--then the result should be 01, normally visible. + // This is because we only want to propagate the hidden bit upwards + // if *all* renderable nodes are hidden. - // Get the set of exception bits for which the above rule - // applies. These are the bits for which both bits have - // flipped, but which were not the same in the original. + // Get the set of exception bits for which the above rule applies. + // These are the bits for which both bits have flipped, but which + // were not the same in the original. DrawMask exception_mask = (net_draw_control_mask ^ child_control_mask) & (net_draw_show_mask ^ child_show_mask); exception_mask &= (net_draw_control_mask ^ net_draw_show_mask); @@ -4013,8 +3555,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe CDStageWriter cdataw(_cycler, pipeline_stage, current_thread); if (last_update == cdataw->_last_update && next_update == cdataw->_next_update) { - // Great, no one has monkeyed with these while we were computing - // the cache. Safe to store the computed values and return. + // Great, no one has monkeyed with these while we were computing the + // cache. Safe to store the computed values and return. cdataw->_net_collide_mask = net_collide_mask; if (renderable) { @@ -4030,8 +3572,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe net_draw_show_mask |= show_through_mask; - // There are renderable nodes below, so the implicit draw - // bits are all on. + // There are renderable nodes below, so the implicit draw bits are + // all on. cdataw->_net_draw_control_mask = net_draw_control_mask; cdataw->_net_draw_show_mask = net_draw_show_mask | ~net_draw_control_mask; if (drawmask_cat.is_debug()) { @@ -4039,10 +3581,9 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe << "renderable, set mask " << cdataw->_net_draw_show_mask << "\n"; } } else { - // There are no renderable nodes below, so the implicit draw - // bits are all off. Also, we don't care about the draw - // mask on this particular node (since nothing below it is - // renderable anyway). + // There are no renderable nodes below, so the implicit draw bits + // are all off. Also, we don't care about the draw mask on this + // particular node (since nothing below it is renderable anyway). cdataw->_net_draw_control_mask = net_draw_control_mask; cdataw->_net_draw_show_mask = net_draw_show_mask; if (drawmask_cat.is_debug()) { @@ -4066,9 +3607,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe if (btype == BoundingVolume::BT_box || (btype != BoundingVolume::BT_sphere && all_box && transform->is_identity())) { - // If all of the child volumes are a BoundingBox, and we - // have no transform, then our volume is also a - // BoundingBox. + // If all of the child volumes are a BoundingBox, and we have no + // transform, then our volume is also a BoundingBox. gbv = new BoundingBox; } else { @@ -4082,8 +3622,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe ((BoundingVolume *)gbv)->around(child_begin, child_end); } - // If we have a transform, apply it to the bounding volume we - // just computed. + // If we have a transform, apply it to the bounding volume we just + // computed. if (!transform->is_identity()) { gbv->xform(transform->get_mat()); } @@ -4101,8 +3641,8 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe nassertr(cdataw->_last_update == cdataw->_next_update, cdataw); - // Even though implicit bounding volume is not (yet?) part of - // the bam stream. + // Even though implicit bounding volume is not (yet?) part of the bam + // stream. mark_bam_modified(); return cdataw; } @@ -4114,52 +3654,43 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe } } - // We need to go around again. Release the write lock, and grab - // the read lock back. + // We need to go around again. Release the write lock, and grab the read + // lock back. cdata = CDLockedStageReader(_cycler, pipeline_stage, current_thread); if (cdata->_last_update == cdata->_next_update && (!update_bounds || cdata->_last_bounds_update == cdata->_next_update)) { - // Someone else has computed the cache for us while we were - // diddling with the locks. OK. + // Someone else has computed the cache for us while we were diddling + // with the locks. OK. return CDStageWriter(_cycler, pipeline_stage, cdata); } } while (true); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::set_scene_root_func -// Access: Public, Static -// Description: This is used by the GraphicsEngine to hook in a -// pointer to the scene_root_func(), the function to -// determine whether the node is an active scene root. -// This back-pointer is necessary because we can't make -// calls directly into GraphicsEngine, which is in the -// display module. -//////////////////////////////////////////////////////////////////// +/** + * This is used by the GraphicsEngine to hook in a pointer to the + * scene_root_func(), the function to determine whether the node is an active + * scene root. This back-pointer is necessary because we can't make calls + * directly into GraphicsEngine, which is in the display module. + */ void PandaNode:: set_scene_root_func(SceneRootFunc *func) { _scene_root_func = func; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type PandaNode. + */ void PandaNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PandaNode:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -4168,48 +3699,37 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::update_bam_nested -// Access: Public, Virtual -// Description: Called by the BamWriter when this object has not -// itself been modified recently, but it should check -// its nested objects for updates. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamWriter when this object has not itself been modified + * recently, but it should check its nested objects for updates. + */ void PandaNode:: update_bam_nested(BamWriter *manager) { CDReader cdata(_cycler); cdata->update_bam_nested(manager); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::write_recorder -// Access: Public -// Description: This method is provided for the benefit of classes -// (like MouseRecorder) that inherit from PandaMode and -// also RecorderBase. It's not virtual at this level -// since it doesn't need to be (it's called up from the -// derived class). -// -// This method acts very like write_datagram, but it -// writes the node as appropriate for writing a -// RecorderBase object as described in the beginning of -// a session file, meaning it doesn't need to write -// things such as children. It balances with -// fillin_recorder(). -//////////////////////////////////////////////////////////////////// +/** + * This method is provided for the benefit of classes (like MouseRecorder) + * that inherit from PandaMode and also RecorderBase. It's not virtual at + * this level since it doesn't need to be (it's called up from the derived + * class). + * + * This method acts very like write_datagram, but it writes the node as + * appropriate for writing a RecorderBase object as described in the beginning + * of a session file, meaning it doesn't need to write things such as + * children. It balances with fillin_recorder(). + */ void PandaNode:: write_recorder(BamWriter *, Datagram &dg) { dg.add_string(get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type PandaNode is encountered -// in the Bam file. It should create the PandaNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type PandaNode is encountered in the Bam file. It should create the + * PandaNode and extract its information from the file. + */ TypedWritable *PandaNode:: make_from_bam(const FactoryParams ¶ms) { PandaNode *node = new PandaNode(""); @@ -4222,13 +3742,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PandaNode. + */ void PandaNode:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -4239,26 +3756,20 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::fillin_recorder -// Access: Protected -// Description: This internal function is called by make_recorder (in -// classes derived from RecorderBase, such as -// MouseRecorder) to read in all of the relevant data -// from the session file. It balances with -// write_recorder(). -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_recorder (in classes derived from + * RecorderBase, such as MouseRecorder) to read in all of the relevant data + * from the session file. It balances with write_recorder(). + */ void PandaNode:: fillin_recorder(DatagramIterator &scan, BamReader *) { string name = scan.get_string(); set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode::CData:: CData() : _state(RenderState::make_empty()), @@ -4285,11 +3796,9 @@ CData() : ++_next_update; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode::CData:: CData(const PandaNode::CData ©) : BoundsData(copy), @@ -4323,22 +3832,19 @@ CData(const PandaNode::CData ©) : _up(copy._up) { // Note that this copy constructor is not used by the PandaNode copy - // constructor! Any elements that must be copied between nodes - // should also be explicitly copied there. + // constructor! Any elements that must be copied between nodes should also + // be explicitly copied there. #ifdef HAVE_PYTHON - // Copy and increment all of the Python objects held by the other - // node. + // Copy and increment all of the Python objects held by the other node. _python_tag_data = copy._python_tag_data; inc_py_refs(); #endif // HAVE_PYTHON } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaNode::CData:: ~CData() { #ifdef HAVE_PYTHON @@ -4347,28 +3853,24 @@ PandaNode::CData:: #endif // HAVE_PYTHON } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *PandaNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PandaNode::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { manager->write_pointer(dg, _state); manager->write_pointer(dg, _transform); - // + manager->write_pointer(dg, _effects); dg.add_uint32(_draw_control_mask.get_word()); @@ -4383,39 +3885,31 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_string((*ti).second); } - // + write_up_list(*get_up(), manager, dg); write_down_list(*get_down(), manager, dg); write_down_list(*get_stashed(), manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::update_bam_nested -// Access: Public -// Description: Called by the BamWriter when this object has not -// itself been modified recently, but it should check -// its nested objects for updates. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamWriter when this object has not itself been modified + * recently, but it should check its nested objects for updates. + */ void PandaNode::CData:: update_bam_nested(BamWriter *manager) const { - // No need to check the state pointers for updates, since they're - // all immutable objects. - //manager->consider_update(_state); - //manager->consider_update(_transform); - //manager->consider_update(_effects); + // No need to check the state pointers for updates, since they're all + // immutable objects. manager->consider_update(_state); + // manager->consider_update(_transform); manager->consider_update(_effects); update_up_list(*get_up(), manager); update_down_list(*get_down(), manager); update_down_list(*get_stashed(), manager); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int PandaNode::CData:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = CycleData::complete_pointers(p_list, manager); @@ -4425,41 +3919,43 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { _transform = DCAST(TransformState, p_list[pi++]); _prev_transform = _transform; - // Finalize these pointers now to decrement their artificially-held - // reference counts. We do this now, rather than later, in case - // some other object reassigns them a little later on during - // initialization, before they can finalize themselves normally (for - // instance, the character may change the node's transform). If - // that happens, the pointer may discover that no one else holds its - // reference count when it finalizes, which will constitute a memory - // leak (see the comments in TransformState::finalize(), etc.). +/* + * Finalize these pointers now to decrement their artificially-held reference + * counts. We do this now, rather than later, in case some other object + * reassigns them a little later on during initialization, before they can + * finalize themselves normally (for instance, the character may change the + * node's transform). If that happens, the pointer may discover that no one + * else holds its reference count when it finalizes, which will constitute a + * memory leak (see the comments in TransformState::finalize(), etc.). + */ manager->finalize_now((RenderState *)_state.p()); manager->finalize_now((TransformState *)_transform.p()); - // + // Get the effects pointer. _effects = DCAST(RenderEffects, p_list[pi++]); - // Finalize these pointers now to decrement their artificially-held - // reference counts. We do this now, rather than later, in case - // some other object reassigns them a little later on during - // initialization, before they can finalize themselves normally (for - // instance, the character may change the node's transform). If - // that happens, the pointer may discover that no one else holds its - // reference count when it finalizes, which will constitute a memory - // leak (see the comments in TransformState::finalize(), etc.). +/* + * Finalize these pointers now to decrement their artificially-held reference + * counts. We do this now, rather than later, in case some other object + * reassigns them a little later on during initialization, before they can + * finalize themselves normally (for instance, the character may change the + * node's transform). If that happens, the pointer may discover that no one + * else holds its reference count when it finalizes, which will constitute a + * memory leak (see the comments in TransformState::finalize(), etc.). + */ manager->finalize_now((RenderEffects *)_effects.p()); - // + // Get the parent and child pointers. pi += complete_up_list(*modify_up(), "up", p_list + pi, manager); pi += complete_down_list(*modify_down(), "down", p_list + pi, manager); pi += complete_down_list(*modify_stashed(), "stashed", p_list + pi, manager); - // Since the _effects and _states members have been finalized by - // now, this should be safe. + // Since the _effects and _states members have been finalized by now, this + // should be safe. set_fancy_bit(FB_transform, !_transform->is_identity()); set_fancy_bit(FB_state, !_state->is_empty()); set_fancy_bit(FB_effects, !_effects->is_empty()); @@ -4471,20 +3967,16 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PandaNode. + */ void PandaNode::CData:: fillin(DatagramIterator &scan, BamReader *manager) { // Read the state and transform pointers. manager->read_pointer(scan); manager->read_pointer(scan); - // // Read the effects pointer. manager->read_pointer(scan); @@ -4529,25 +4021,22 @@ fillin(DatagramIterator &scan, BamReader *manager) { _tag_data[key] = value; } - // + fillin_up_list(*modify_up(), "up", scan, manager); fillin_down_list(*modify_down(), "down", scan, manager); fillin_down_list(*modify_stashed(), "stashed", scan, manager); } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::inc_py_refs -// Access: Public -// Description: Increments the reference counts on all held Python -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Increments the reference counts on all held Python objects. + */ void PandaNode::CData:: inc_py_refs() { if (!_python_tag_data.empty()) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) - // This might happen at any time, so be sure the Python state is - // ready for it. + // This might happen at any time, so be sure the Python state is ready for + // it. PyGILState_STATE gstate; gstate = PyGILState_Ensure(); #endif @@ -4566,18 +4055,15 @@ inc_py_refs() { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::dec_py_refs -// Access: Public -// Description: Decrements the reference counts on all held Python -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the reference counts on all held Python objects. + */ void PandaNode::CData:: dec_py_refs() { if (!_python_tag_data.empty()) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) - // This might happen at any time, so be sure the Python state is - // ready for it. + // This might happen at any time, so be sure the Python state is ready for + // it. PyGILState_STATE gstate; gstate = PyGILState_Ensure(); #endif @@ -4597,23 +4083,21 @@ dec_py_refs() { } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::write_up_list -// Access: Public -// Description: Writes the indicated list of parent node pointers to -// the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated list of parent node pointers to the datagram. + */ void PandaNode::CData:: write_up_list(const PandaNode::Up &up_list, BamWriter *manager, Datagram &dg) const { - // When we write a PandaNode, we write out its complete list of - // child node pointers, but we only write out the parent node - // pointers that have already been added to the bam file by a - // previous write operation. This is a bit of trickery that allows - // us to write out just a subgraph (instead of the complete graph) - // when we write out an arbitrary node in the graph, yet also allows - // us to keep nodes completely in sync when we use the bam format - // for streaming scene graph operations over the network. +/* + * When we write a PandaNode, we write out its complete list of child node + * pointers, but we only write out the parent node pointers that have already + * been added to the bam file by a previous write operation. This is a bit of + * trickery that allows us to write out just a subgraph (instead of the + * complete graph) when we write out an arbitrary node in the graph, yet also + * allows us to keep nodes completely in sync when we use the bam format for + * streaming scene graph operations over the network. + */ int num_parents = 0; Up::const_iterator ui; @@ -4633,12 +4117,9 @@ write_up_list(const PandaNode::Up &up_list, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::write_down_list -// Access: Public -// Description: Writes the indicated list of child node pointers to -// the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated list of child node pointers to the datagram. + */ void PandaNode::CData:: write_down_list(const PandaNode::Down &down_list, BamWriter *manager, Datagram &dg) const { @@ -4646,8 +4127,8 @@ write_down_list(const PandaNode::Down &down_list, nassertv(num_children == (int)(PN_uint16)num_children); dg.add_uint16(num_children); - // Should we smarten up the writing of the sort number? Most of the - // time these will all be zero. + // Should we smarten up the writing of the sort number? Most of the time + // these will all be zero. Down::const_iterator di; for (di = down_list.begin(); di != down_list.end(); ++di) { PandaNode *child_node = (*di).get_child(); @@ -4657,12 +4138,9 @@ write_down_list(const PandaNode::Down &down_list, } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::update_up_list -// Access: Public -// Description: Calls consider_update on each node of the indicated -// up list. -//////////////////////////////////////////////////////////////////// +/** + * Calls consider_update on each node of the indicated up list. + */ void PandaNode::CData:: update_up_list(const PandaNode::Up &up_list, BamWriter *manager) const { Up::const_iterator ui; @@ -4674,12 +4152,9 @@ update_up_list(const PandaNode::Up &up_list, BamWriter *manager) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::update_down_list -// Access: Public -// Description: Calls consider_update on each node of the indicated -// up list. -//////////////////////////////////////////////////////////////////// +/** + * Calls consider_update on each node of the indicated up list. + */ void PandaNode::CData:: update_down_list(const PandaNode::Down &down_list, BamWriter *manager) const { Down::const_iterator di; @@ -4689,12 +4164,9 @@ update_down_list(const PandaNode::Down &down_list, BamWriter *manager) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::complete_up_list -// Access: Public -// Description: Calls complete_pointers() on the list of parent node -// pointers. -//////////////////////////////////////////////////////////////////// +/** + * Calls complete_pointers() on the list of parent node pointers. + */ int PandaNode::CData:: complete_up_list(PandaNode::Up &up_list, const string &tag, TypedWritable **p_list, BamReader *manager) { @@ -4709,9 +4181,8 @@ complete_up_list(PandaNode::Up &up_list, const string &tag, new_up_list.push_back(connection); } - // Now we should sort the list, since the sorting is based on - // pointer order, which might be different from one session to the - // next. + // Now we should sort the list, since the sorting is based on pointer order, + // which might be different from one session to the next. new_up_list.sort(); // Make it permanent. @@ -4721,12 +4192,9 @@ complete_up_list(PandaNode::Up &up_list, const string &tag, return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::complete_down_list -// Access: Public -// Description: Calls complete_pointers() on the list of child node -// pointers. -//////////////////////////////////////////////////////////////////// +/** + * Calls complete_pointers() on the list of child node pointers. + */ int PandaNode::CData:: complete_down_list(PandaNode::Down &down_list, const string &tag, TypedWritable **p_list, BamReader *manager) { @@ -4743,9 +4211,9 @@ complete_down_list(PandaNode::Down &down_list, const string &tag, (*di).set_child(child_node); } - // Unlike the up list, we should *not* sort the down list. The down - // list is stored in a specific order, not related to pointer order; - // and this order should be preserved from one session to the next. + // Unlike the up list, we should *not* sort the down list. The down list is + // stored in a specific order, not related to pointer order; and this order + // should be preserved from one session to the next. // Make it permanent. down_list.swap(new_down_list); @@ -4754,13 +4222,10 @@ complete_down_list(PandaNode::Down &down_list, const string &tag, return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::fillin_up_list -// Access: Public -// Description: Reads the indicated list parent node pointers from -// the datagram (or at least calls read_pointer() for -// each one). -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated list parent node pointers from the datagram (or at + * least calls read_pointer() for each one). + */ void PandaNode::CData:: fillin_up_list(PandaNode::Up &up_list, const string &tag, DatagramIterator &scan, BamReader *manager) { @@ -4769,22 +4234,18 @@ fillin_up_list(PandaNode::Up &up_list, const string &tag, manager->read_pointers(scan, num_parents); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNode::CData::fillin_down_list -// Access: Public -// Description: Reads the indicated list child node pointers from -// the datagram (or at least calls read_pointer() for -// each one). -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated list child node pointers from the datagram (or at least + * calls read_pointer() for each one). + */ void PandaNode::CData:: fillin_down_list(PandaNode::Down &down_list, const string &tag, DatagramIterator &scan, BamReader *manager) { int num_children = scan.get_uint16(); - // Create a temporary down_list, with the right number of elements, - // but a NULL value for each pointer (we'll fill in the pointers - // later). We need to do this to associate the sort values with - // their pointers. + // Create a temporary down_list, with the right number of elements, but a + // NULL value for each pointer (we'll fill in the pointers later). We need + // to do this to associate the sort values with their pointers. Down new_down_list(PandaNode::get_class_type()); new_down_list.reserve(num_children); for (int i = 0; i < num_children; i++) { @@ -4794,20 +4255,17 @@ fillin_down_list(PandaNode::Down &down_list, const string &tag, new_down_list.push_back(connection); } - // Now store the temporary down_list in the BamReader, so we can get - // it during the call to complete_down_list(). + // Now store the temporary down_list in the BamReader, so we can get it + // during the call to complete_down_list(). PT(BamReaderAuxDataDown) aux = new BamReaderAuxDataDown; aux->_down_list.swap(new_down_list); manager->set_aux_tag(tag, aux); } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodePipelineReader::check_cached -// Access: Public -// Description: Ensures that the draw masks etc. are properly -// computed on this node. If update_bounds is true, -// also checks the bounding volume. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the draw masks etc. are properly computed on this node. If + * update_bounds is true, also checks the bounding volume. + */ void PandaNodePipelineReader:: check_cached(bool update_bounds) const { UpdateSeq last_update = update_bounds @@ -4817,9 +4275,8 @@ check_cached(bool update_bounds) const { if (last_update != _cdata->_next_update) { // The cache is stale; it needs to be rebuilt. - // We'll need to get a fresh read pointer, since another thread - // might already have modified the pointer on the object since we - // queried it. + // We'll need to get a fresh read pointer, since another thread might + // already have modified the pointer on the object since we queried it. #ifdef DO_PIPELINING node_unref_delete((CycleData *)_cdata); #endif // DO_PIPELINING @@ -4828,9 +4285,8 @@ check_cached(bool update_bounds) const { PandaNode::CDLockedStageReader fresh_cdata(_node->_cycler, pipeline_stage, _current_thread); if (fresh_cdata->_last_update == fresh_cdata->_next_update && (!update_bounds || fresh_cdata->_last_bounds_update == fresh_cdata->_next_update)) { - // What luck, some other thread has already freshened the - // cache for us. Save the new pointer, and let the lock - // release itself. + // What luck, some other thread has already freshened the cache for us. + // Save the new pointer, and let the lock release itself. if (_cdata != (const PandaNode::CData *)fresh_cdata) { ((PandaNodePipelineReader *)this)->_cdata = fresh_cdata; #ifdef DO_PIPELINING @@ -4839,13 +4295,13 @@ check_cached(bool update_bounds) const { } } else { - // No, the cache is still stale. We have to do the work of - // freshening it. + // No, the cache is still stale. We have to do the work of freshening + // it. PStatTimer timer(PandaNode::_update_bounds_pcollector); PandaNode::CDStageWriter cdataw = ((PandaNode *)_node)->update_cached(update_bounds, pipeline_stage, fresh_cdata); nassertv(cdataw->_last_update == cdataw->_next_update); - // As above, we save the new pointer, and then let the lock - // release itself. + // As above, we save the new pointer, and then let the lock release + // itself. if (_cdata != (const PandaNode::CData *)cdataw) { ((PandaNodePipelineReader *)this)->_cdata = cdataw; #ifdef DO_PIPELINING diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 0a7fc952ef..94a5912e8c 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -1,16 +1,15 @@ -// Filename: pandaNode.h -// Created by: drose (20Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNode.h + * @author drose + * @date 2002-02-20 + */ #ifndef PANDANODE_H #define PANDANODE_H @@ -56,18 +55,17 @@ class AccumulatedAttribs; class GeomTransformer; class GraphicsStateGuardianBase; -//////////////////////////////////////////////////////////////////// -// Class : PandaNode -// Description : A basic node of the scene graph or data graph. This -// is the base class of all specialized nodes, and also -// serves as a generic node with no special properties. -//////////////////////////////////////////////////////////////////// +/** + * A basic node of the scene graph or data graph. This is the base class of + * all specialized nodes, and also serves as a generic node with no special + * properties. + */ class EXPCL_PANDA_PGRAPH PandaNode : public TypedWritableReferenceCount, public Namable, public LinkedListNode { PUBLISHED: explicit PandaNode(const string &name); virtual ~PandaNode(); - //published so that characters can be combined. + // published so that characters can be combined. virtual PandaNode *combine_with(PandaNode *other); protected: @@ -265,17 +263,17 @@ PUBLISHED: INLINE void ls(ostream &out, int indent_level) const; - // A node has three bounding volumes: an "external" bounding volume - // that represents the node and all of its children, an "internal" - // bounding volume which represents only the node itself (and is - // usually empty, unless a specific node type sets it otherwise), - // and a "user" bounding volume which is specified by the user. + // A node has three bounding volumes: an "external" bounding volume that + // represents the node and all of its children, an "internal" bounding + // volume which represents only the node itself (and is usually empty, + // unless a specific node type sets it otherwise), and a "user" bounding + // volume which is specified by the user. - // We define set_bounds() and get_bounds() functions so that - // set_bounds() sets the user bounding volume, while get_bounds() - // returns the external bounding volume. Although it might seem - // strange and confusing to do this, this is actually the natural - // way the user thinks about nodes and bounding volumes. + // We define set_bounds() and get_bounds() functions so that set_bounds() + // sets the user bounding volume, while get_bounds() returns the external + // bounding volume. Although it might seem strange and confusing to do + // this, this is actually the natural way the user thinks about nodes and + // bounding volumes. void set_bounds_type(BoundingVolume::BoundsType bounds_type); BoundingVolume::BoundsType get_bounds_type() const; MAKE_PROPERTY(bounds_type, get_bounds_type); @@ -360,9 +358,9 @@ public: Thread *current_thread); protected: - // This is a base class of CData, defined below. It contains just - // the protected (not private) part of CData that will be needed by - // derived classes to implement compute_internal_bounds(). + // This is a base class of CData, defined below. It contains just the + // protected (not private) part of CData that will be needed by derived + // classes to implement compute_internal_bounds(). class EXPCL_PANDA_PGRAPH BoundsData : public CycleData { protected: INLINE BoundsData(); @@ -370,10 +368,10 @@ protected: INLINE void copy_bounds(const BoundsData ©); public: - // This is the "internal" bounding volume, which is normally - // empty, but which a particular PandaNode subclass may define to - // be any arbitrary volume, by calling set_internal_bounds() or by - // overriding compute_internal_bounds(). + // This is the "internal" bounding volume, which is normally empty, but + // which a particular PandaNode subclass may define to be any arbitrary + // volume, by calling set_internal_bounds() or by overriding + // compute_internal_bounds(). CPT(BoundingVolume) _internal_bounds; int _internal_vertices; UpdateSeq _internal_bounds_mark; // incremented on mark_stale @@ -396,8 +394,8 @@ private: void report_cycle(PandaNode *node); bool find_node_above(PandaNode *node); - // parent-child manipulation for NodePath support. Don't try to - // call these directly. + // parent-child manipulation for NodePath support. Don't try to call these + // directly. static PT(NodePathComponent) attach(NodePathComponent *parent, PandaNode *child, int sort, int pipeline_stage, Thread *current_thread); @@ -431,8 +429,8 @@ private: INLINE void do_clear_dirty_prev_transform(); public: - // This must be declared public so that VC6 will allow the nested - // CData class to access it. + // This must be declared public so that VC6 will allow the nested CData + // class to access it. class EXPCL_PANDA_PGRAPH DownConnection { public: INLINE DownConnection(PandaNode *child, int sort); @@ -442,9 +440,8 @@ public: INLINE int get_sort() const; private: - // Child pointers are reference counted. That way, holding a - // pointer to the root of a subgraph keeps the entire subgraph - // around. + // Child pointers are reference counted. That way, holding a pointer to + // the root of a subgraph keeps the entire subgraph around. PT(PandaNode) _child; int _sort; }; @@ -493,23 +490,22 @@ private: typedef CopyOnWriteObj1< UpList, TypeHandle > Up; // We also maintain a set of NodePathComponents in the node. This - // represents the set of instances of this node that we have - // requested a NodePath for. We don't keep reference counts; when - // each NodePathComponent destructs, it removes itself from this - // set. + // represents the set of instances of this node that we have requested a + // NodePath for. We don't keep reference counts; when each + // NodePathComponent destructs, it removes itself from this set. typedef phash_set Paths; - // We don't cycle the set of Paths, since these are across all - // threads. A NodePathComponent, once created, is always associated - // with the same node. We do, however, protect the Paths under a mutex. + // We don't cycle the set of Paths, since these are across all threads. A + // NodePathComponent, once created, is always associated with the same node. + // We do, however, protect the Paths under a mutex. Paths _paths; LightReMutex _paths_lock; bool _dirty_prev_transform; static PandaNodeChain _dirty_prev_transforms; - // This is used to maintain a table of keyed data on each node, for - // the user's purposes. + // This is used to maintain a table of keyed data on each node, for the + // user's purposes. typedef phash_map TagData; #ifdef HAVE_PYTHON typedef phash_map PythonTagData; @@ -538,16 +534,16 @@ private: } public: - // This section contains the lightweight parts of the node that - // are likely to change fairly often: transform and state. + // This section contains the lightweight parts of the node that are likely + // to change fairly often: transform and state. NCPT(RenderState) _state; NCPT(TransformState) _transform; NCPT(TransformState) _prev_transform; public: - // This section contains the heavierweight parts of the node that - // are less likely to change as often: tags, collide mask. + // This section contains the heavierweight parts of the node that are less + // likely to change as often: tags, collide mask. INLINE void set_fancy_bit(int bits, bool value); @@ -563,72 +559,69 @@ private: PythonTagData _python_tag_data; #endif // HAVE_PYTHON - // These two together determine the per-camera visibility of this - // node. See adjust_draw_mask() for details. + // These two together determine the per-camera visibility of this node. + // See adjust_draw_mask() for details. DrawMask _draw_control_mask, _draw_show_mask; - // This is the mask that indicates which CollisionNodes may detect - // a collision with this particular node. By default it is zero - // for an ordinary PandaNode, and all bits on for a CollisionNode - // or GeomNode. + // This is the mask that indicates which CollisionNodes may detect a + // collision with this particular node. By default it is zero for an + // ordinary PandaNode, and all bits on for a CollisionNode or GeomNode. CollideMask _into_collide_mask; // The requested bounding volume type. BoundingVolume::BoundsType _bounds_type; - // This is the user bounding volume, which is only specified by a - // user. It defaults to NULL, which means an empty volume. + // This is the user bounding volume, which is only specified by a user. + // It defaults to NULL, which means an empty volume. CPT(BoundingVolume) _user_bounds; // See BoundsData, above, for _internal_bounds. - // This is true if the external bounds of this node should be - // deemed "final". See set_final(). + // This is true if the external bounds of this node should be deemed + // "final". See set_final(). bool _final_bounds; - // This bitmask is maintained automatically by the internal - // PandaNode code; it contains a 1 for each "fancy" attribute that - // is set on the node. See enum FancyBits, above. + // This bitmask is maintained automatically by the internal PandaNode + // code; it contains a 1 for each "fancy" attribute that is set on the + // node. See enum FancyBits, above. int _fancy_bits; public: - // This section contains the data that is accumulated upward from - // the node's children: that is, the external bounding volume, and - // conceptually similar things like the net_collide_mask, etc. - // None of the data in this object is preserved in a bam file. + // This section contains the data that is accumulated upward from the + // node's children: that is, the external bounding volume, and + // conceptually similar things like the net_collide_mask, etc. None of + // the data in this object is preserved in a bam file. - // This is the union of all into_collide_mask bits for any nodes - // at and below this level. + // This is the union of all into_collide_mask bits for any nodes at and + // below this level. CollideMask _net_collide_mask; // These are similar, for the draw mask. DrawMask _net_draw_control_mask, _net_draw_show_mask; - // This is a ClipPlaneAttrib that represents the union of all clip - // planes that have been turned *off* at and below this level. - // TODO: fix the circular reference counts involved here. + // This is a ClipPlaneAttrib that represents the union of all clip planes + // that have been turned *off* at and below this level. TODO: fix the + // circular reference counts involved here. CPT(RenderAttrib) _off_clip_planes; - // The number of vertices rendered by this node and all child - // nodes. + // The number of vertices rendered by this node and all child nodes. int _nested_vertices; // This is the bounding volume around the _user_bounds, the - // _internal_bounds, and all of the children's external bounding - // volumes. + // _internal_bounds, and all of the children's external bounding volumes. CPT(BoundingVolume) _external_bounds; // When _last_update != _next_update, this cache is stale. UpdateSeq _last_update, _next_update; - // We don't always update the bounding volume and number of - // nested vertices. This indicates the last time they were changed. - // It is never higher than _last_update. + // We don't always update the bounding volume and number of nested + // vertices. This indicates the last time they were changed. It is never + // higher than _last_update. UpdateSeq _last_bounds_update; public: - // This section stores the links to other nodes above and below - // this node in the graph. + // This section stores the links to other nodes above and below this node + // in the graph. void write_up_list(const Up &up_list, BamWriter *manager, Datagram &dg) const; @@ -653,8 +646,8 @@ private: INLINE PT(Up) modify_up(); private: - // We store the child lists by reference, so we can copy them - // quickly. We perform copy-on-write when necessary. + // We store the child lists by reference, so we can copy them quickly. We + // perform copy-on-write when necessary. COWPT(Down) _down; COWPT(Down) _stashed; COWPT(Up) _up; @@ -688,12 +681,11 @@ private: static PStatCollector _update_bounds_pcollector; public: - // This class is returned from get_children(). Use it to walk - // through the list of children. This is faster, and safer, than - // walking through the children one at a time via - // get_num_children()/get_child(), since the list of children is - // saved out ahead of time, rather than having to reacquire the lock - // with each iteration, or to keep the lock held for the entire + // This class is returned from get_children(). Use it to walk through the + // list of children. This is faster, and safer, than walking through the + // children one at a time via get_num_children()get_child(), since the list + // of children is saved out ahead of time, rather than having to reacquire + // the lock with each iteration, or to keep the lock held for the entire // pass. class EXPCL_PANDA_PGRAPH Children { public: @@ -814,11 +806,10 @@ private: friend class Extension; }; -//////////////////////////////////////////////////////////////////// -// Class : PandaNodePipelineReader -// Description : Encapsulates the data from a PandaNode, -// pre-fetched for one stage of the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates the data from a PandaNode, pre-fetched for one stage of the + * pipeline. + */ class EXPCL_PANDA_PGRAPH PandaNodePipelineReader { public: INLINE PandaNodePipelineReader(const PandaNode *object, Thread *current_thread); @@ -900,4 +891,3 @@ INLINE ostream &operator << (ostream &out, const PandaNode &node) { #include "pandaNode.I" #endif - diff --git a/panda/src/pgraph/pandaNodeChain.I b/panda/src/pgraph/pandaNodeChain.I index e3b9b7f931..8a401d3a80 100644 --- a/panda/src/pgraph/pandaNodeChain.I +++ b/panda/src/pgraph/pandaNodeChain.I @@ -1,23 +1,19 @@ -// Filename: pandaNodeChain.I -// Created by: drose (21Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNodeChain.I + * @author drose + * @date 2006-04-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PandaNodeChain::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNodeChain:: PandaNodeChain(const char *lock_name) : LinkedListNode(true), // This object is the root of a list of PandaNodes. @@ -25,11 +21,9 @@ PandaNodeChain(const char *lock_name) : { } -//////////////////////////////////////////////////////////////////// -// Function: PandaNodeChain::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PandaNodeChain:: ~PandaNodeChain() { _next = NULL; diff --git a/panda/src/pgraph/pandaNodeChain.cxx b/panda/src/pgraph/pandaNodeChain.cxx index 428ad03758..d52fb2b4f0 100644 --- a/panda/src/pgraph/pandaNodeChain.cxx +++ b/panda/src/pgraph/pandaNodeChain.cxx @@ -1,15 +1,14 @@ -// Filename: pandaNodeChain.cxx -// Created by: drose (21Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNodeChain.cxx + * @author drose + * @date 2006-04-21 + */ #include "pandaNodeChain.h" diff --git a/panda/src/pgraph/pandaNodeChain.h b/panda/src/pgraph/pandaNodeChain.h index 2bc2863824..002a30041c 100644 --- a/panda/src/pgraph/pandaNodeChain.h +++ b/panda/src/pgraph/pandaNodeChain.h @@ -1,16 +1,15 @@ -// Filename: pandaNodeChain.h -// Created by: drose (21Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNodeChain.h + * @author drose + * @date 2006-04-21 + */ #ifndef PANDANODECHAIN_H #define PANDANODECHAIN_H @@ -21,13 +20,11 @@ class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : PandaNodeChain -// Description : This class maintains a linked list of PandaNodes. -// It's used to maintain a list of PandaNodes whose -// _prev_transform is different from their _transform -// (in pipeline stage 0). -//////////////////////////////////////////////////////////////////// +/** + * This class maintains a linked list of PandaNodes. It's used to maintain a + * list of PandaNodes whose _prev_transform is different from their _transform + * (in pipeline stage 0). + */ class EXPCL_PANDA_PGRAPH PandaNodeChain : private LinkedListNode { public: INLINE PandaNodeChain(const char *lock_name); @@ -41,4 +38,3 @@ public: #include "pandaNodeChain.I" #endif - diff --git a/panda/src/pgraph/pandaNode_ext.cxx b/panda/src/pgraph/pandaNode_ext.cxx index df251cba44..9a12edabd0 100644 --- a/panda/src/pgraph/pandaNode_ext.cxx +++ b/panda/src/pgraph/pandaNode_ext.cxx @@ -1,32 +1,26 @@ -// Filename: pandaNode_ext.cxx -// Created by: CFSworks (30Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNode_ext.cxx + * @author CFSworks + * @date 2014-03-30 + */ #include "pandaNode_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::__copy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.copy(node). Unlike the PandaNode copy -// constructor, which creates a new node without -// children, this shares child pointers (essentially -// making every child an instance). This is intended to -// simulate the behavior of copy.copy() for other -// objects. -//////////////////////////////////////////////////////////////////// +/** + * A special Python method that is invoked by copy.copy(node). Unlike the + * PandaNode copy constructor, which creates a new node without children, this + * shares child pointers (essentially making every child an instance). This + * is intended to simulate the behavior of copy.copy() for other objects. + */ PT(PandaNode) Extension:: __copy__() const { Thread *current_thread = Thread::get_current_thread(); @@ -43,14 +37,11 @@ __copy__() const { return node_dupe; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::__deepcopy__ -// Access: Published -// Description: A special Python method that is invoked by -// copy.deepcopy(node). This calls copy_subgraph() -// unless the node is already present in the provided -// dictionary. -//////////////////////////////////////////////////////////////////// +/** + * A special Python method that is invoked by copy.deepcopy(node). This calls + * copy_subgraph() unless the node is already present in the provided + * dictionary. + */ PyObject *Extension:: __deepcopy__(PyObject *self, PyObject *memo) const { extern struct Dtool_PyTypedObject Dtool_PandaNode; @@ -68,7 +59,7 @@ __deepcopy__(PyObject *self, PyObject *memo) const { // DTool_CreatePyInstanceTyped() steals a C++ reference. node_dupe->ref(); dupe = DTool_CreatePyInstanceTyped - ((void *)node_dupe.p(), Dtool_PandaNode, true, false, + ((void *)node_dupe.p(), Dtool_PandaNode, true, false, node_dupe->get_type_index()); if (PyDict_SetItem(memo, self, dupe) != 0) { @@ -79,20 +70,16 @@ __deepcopy__(PyObject *self, PyObject *memo) const { return dupe; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::set_python_tag -// Access: Published -// Description: Associates an arbitrary Python object with a -// user-defined key which is stored on the node. This -// is similar to set_tag(), except it can store any -// Python object instead of just a string. However, the -// Python object is not recorded to a bam file. -// -// Each unique key stores a different string value. -// There is no effective limit on the number of -// different keys that may be stored or on the length of -// any one key's value. -//////////////////////////////////////////////////////////////////// +/** + * Associates an arbitrary Python object with a user-defined key which is + * stored on the node. This is similar to set_tag(), except it can store any + * Python object instead of just a string. However, the Python object is not + * recorded to a bam file. + * + * Each unique key stores a different string value. There is no effective + * limit on the number of different keys that may be stored or on the length + * of any one key's value. + */ void Extension:: set_python_tag(const string &key, PyObject *value) { Thread *current_thread = Thread::get_current_thread(); @@ -106,10 +93,9 @@ set_python_tag(const string &key, PyObject *value) { result = cdata->_python_tag_data.insert(PandaNode::PythonTagData::value_type(key, value)); if (!result.second) { - // The insert was unsuccessful; that means the key was already - // present in the map. In this case, we should decrement the - // original value's reference count and replace it with the new - // object. + // The insert was unsuccessful; that means the key was already present in + // the map. In this case, we should decrement the original value's + // reference count and replace it with the new object. PandaNode::PythonTagData::iterator ti = result.first; PyObject *old_value = (*ti).second; Py_XDECREF(old_value); @@ -120,13 +106,10 @@ set_python_tag(const string &key, PyObject *value) { _this->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_python_tag -// Access: Published -// Description: Retrieves the Python object that was previously -// set on this node for the particular key, if any. If -// no value has been previously set, returns None. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the Python object that was previously set on this node for the + * particular key, if any. If no value has been previously set, returns None. + */ PyObject *Extension:: get_python_tag(const string &key) const { PandaNode::CDReader cdata(_this->_cycler); @@ -141,13 +124,11 @@ get_python_tag(const string &key) const { return Py_None; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::has_python_tag -// Access: Published -// Description: Returns true if a Python object has been defined on -// this node for the particular key (even if that object -// is None), or false if no object has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a Python object has been defined on this node for the + * particular key (even if that object is None), or false if no object has + * been set. + */ bool Extension:: has_python_tag(const string &key) const { PandaNode::CDReader cdata(_this->_cycler); @@ -156,14 +137,11 @@ has_python_tag(const string &key) const { return (ti != cdata->_python_tag_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::clear_python_tag -// Access: Published -// Description: Removes the Python object defined for this key on -// this particular node. After a call to -// clear_python_tag(), has_python_tag() will return -// false for the indicated key. -//////////////////////////////////////////////////////////////////// +/** + * Removes the Python object defined for this key on this particular node. + * After a call to clear_python_tag(), has_python_tag() will return false for + * the indicated key. + */ void Extension:: clear_python_tag(const string &key) { Thread *current_thread = Thread::get_current_thread(); @@ -183,16 +161,12 @@ clear_python_tag(const string &key) { _this->mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_python_tag_keys -// Access: Published -// Description: Fills the given vector up with the -// list of Python tags on this PandaNode. -// -// It is the user's responsibility to ensure that the -// keys vector is empty before making this call; -// otherwise, the new files will be appended to it. -//////////////////////////////////////////////////////////////////// +/** + * Fills the given vector up with the list of Python tags on this PandaNode. + * + * It is the user's responsibility to ensure that the keys vector is empty + * before making this call; otherwise, the new files will be appended to it. + */ void Extension:: get_python_tag_keys(vector_string &keys) const { PandaNode::CDReader cdata(_this->_cycler); @@ -205,12 +179,9 @@ get_python_tag_keys(vector_string &keys) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_tag_keys -// Access: Published -// Description: This variant on get_tag_keys returns -// a Python list of strings. -//////////////////////////////////////////////////////////////////// +/** + * This variant on get_tag_keys returns a Python list of strings. + */ PyObject *Extension:: get_tag_keys() const { vector_string keys; @@ -230,12 +201,9 @@ get_tag_keys() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_python_tag_keys -// Access: Published -// Description: This variant on get_python_tag_keys returns -// a Python list of strings. -//////////////////////////////////////////////////////////////////// +/** + * This variant on get_python_tag_keys returns a Python list of strings. + */ PyObject *Extension:: get_python_tag_keys() const { vector_string keys; @@ -256,4 +224,3 @@ get_python_tag_keys() const { } #endif // HAVE_PYTHON - diff --git a/panda/src/pgraph/pandaNode_ext.h b/panda/src/pgraph/pandaNode_ext.h index a19dc50db9..f4be38279e 100644 --- a/panda/src/pgraph/pandaNode_ext.h +++ b/panda/src/pgraph/pandaNode_ext.h @@ -1,16 +1,15 @@ -// Filename: pandaNode_ext.h -// Created by: CFSworks (30Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaNode_ext.h + * @author CFSworks + * @date 2014-03-30 + */ #ifndef PANDANODE_EXT_H #define PANDANODE_EXT_H @@ -23,12 +22,10 @@ #include "pandaNode.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// PandaNode, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for PandaNode, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pgraph/paramNodePath.I b/panda/src/pgraph/paramNodePath.I index 8d52ac5ad6..beaa9c5c85 100644 --- a/panda/src/pgraph/paramNodePath.I +++ b/panda/src/pgraph/paramNodePath.I @@ -1,24 +1,19 @@ -// Filename: paramNodePath.I -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramNodePath.I + * @author rdb + * @date 2015-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::Constructor -// Access: Published -// Description: Creates a new ParamNodePath storing the given -// node path object. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ParamNodePath storing the given node path object. + */ INLINE ParamNodePath:: ParamNodePath(const NodePath &node_path) : _node_path(node_path) @@ -26,12 +21,9 @@ ParamNodePath(const NodePath &node_path) : } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::Move Constructor -// Access: Published -// Description: Creates a new ParamNodePath storing the given -// node path object. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new ParamNodePath storing the given node path object. + */ INLINE ParamNodePath:: ParamNodePath(NodePath &&node_path) NOEXCEPT : _node_path(move(node_path)) @@ -39,21 +31,17 @@ ParamNodePath(NodePath &&node_path) NOEXCEPT : } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::get_value_type -// Access: Published, Virtual -// Description: Returns NodePath::get_class_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns NodePath::get_class_type(). + */ INLINE TypeHandle ParamNodePath:: get_value_type() const { return NodePath::get_class_type(); } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::get_value -// Access: Published -// Description: Retrieves the NodePath stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the NodePath stored in the parameter. + */ INLINE const NodePath &ParamNodePath:: get_value() const { return _node_path; diff --git a/panda/src/pgraph/paramNodePath.cxx b/panda/src/pgraph/paramNodePath.cxx index 8f39b69b6c..c243997955 100644 --- a/panda/src/pgraph/paramNodePath.cxx +++ b/panda/src/pgraph/paramNodePath.cxx @@ -1,16 +1,15 @@ -// Filename: paramNodePath.cxx -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramNodePath.cxx + * @author rdb + * @date 2015-02-25 + */ #include "paramNodePath.h" #include "dcast.h" @@ -18,46 +17,36 @@ TypeHandle ParamNodePath::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ParamNodePath:: output(ostream &out) const { out << "node path " << _node_path; } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ParamValue. + */ void ParamNodePath:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ParamNodePath:: write_datagram(BamWriter *manager, Datagram &dg) { ParamValueBase::write_datagram(manager, dg); _node_path.write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int ParamNodePath:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = ParamValueBase::complete_pointers(p_list, manager); @@ -71,14 +60,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ParamValue is encountered -// in the Bam file. It should create the ParamValue -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ParamValue is encountered in the Bam file. It should create the + * ParamValue and extract its information from the file. + */ TypedWritable *ParamNodePath:: make_from_bam(const FactoryParams ¶ms) { ParamNodePath *param = new ParamNodePath; @@ -91,13 +77,10 @@ make_from_bam(const FactoryParams ¶ms) { return param; } -//////////////////////////////////////////////////////////////////// -// Function: ParamNodePath::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ParamValue. + */ void ParamNodePath:: fillin(DatagramIterator &scan, BamReader *manager) { ParamValueBase::fillin(scan, manager); diff --git a/panda/src/pgraph/paramNodePath.h b/panda/src/pgraph/paramNodePath.h index f1634c49ba..25812d8b0f 100644 --- a/panda/src/pgraph/paramNodePath.h +++ b/panda/src/pgraph/paramNodePath.h @@ -1,16 +1,15 @@ -// Filename: paramNodePath.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramNodePath.h + * @author rdb + * @date 2015-02-25 + */ #ifndef PARAMNODEPATH_H #define PARAMNODEPATH_H @@ -19,10 +18,9 @@ #include "paramValue.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : ParamNodePath -// Description : A class object for storing a NodePath as a parameter. -//////////////////////////////////////////////////////////////////// +/** + * A class object for storing a NodePath as a parameter. + */ class EXPCL_PANDA_GOBJ ParamNodePath : public ParamValueBase { protected: INLINE ParamNodePath() {}; diff --git a/panda/src/pgraph/planeNode.I b/panda/src/pgraph/planeNode.I index cdde44ff78..e3983c1305 100644 --- a/panda/src/pgraph/planeNode.I +++ b/panda/src/pgraph/planeNode.I @@ -1,36 +1,30 @@ -// Filename: planeNode.I -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file planeNode.I + * @author drose + * @date 2002-07-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PlaneNode::CData:: CData() : _viz_scale(100.0f) { - // The default plane (perpendicular to the Z-axis) is used until - // another one is specified explicitly. + // The default plane (perpendicular to the Z-axis) is used until another one + // is specified explicitly. } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PlaneNode::CData:: CData(const PlaneNode::CData ©) : _plane(copy._plane), @@ -40,12 +34,9 @@ CData(const PlaneNode::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::set_plane -// Access: Public -// Description: Sets the particular plane represented by the -// PlaneNode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the particular plane represented by the PlaneNode. + */ INLINE void PlaneNode:: set_plane(const LPlane &plane) { CDWriter cdata(_cycler); @@ -56,23 +47,19 @@ set_plane(const LPlane &plane) { } } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_plane -// Access: Public -// Description: Returns the plane represented by the PlaneNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the plane represented by the PlaneNode. + */ INLINE const LPlane &PlaneNode:: get_plane() const { CDReader cdata(_cycler); return cdata->_plane; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::set_viz_scale -// Access: Public -// Description: Specifies the size of the visual representation of -// the plane that is drawn if the PlaneNode is shown. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size of the visual representation of the plane that is drawn + * if the PlaneNode is shown. + */ INLINE void PlaneNode:: set_viz_scale(PN_stdfloat viz_scale) { CDWriter cdata(_cycler); @@ -83,92 +70,71 @@ set_viz_scale(PN_stdfloat viz_scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_viz_scale -// Access: Public -// Description: Returns the size of the visual representation of -// the plane that is drawn if the PlaneNode is shown. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the visual representation of the plane that is drawn if + * the PlaneNode is shown. + */ INLINE PN_stdfloat PlaneNode:: get_viz_scale() const { CDReader cdata(_cycler); return cdata->_viz_scale; } - -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::set_priority -// Access: Published -// Description: Changes the relative importance of this PlaneNode -// (when it is used as a clip plane) relative to the -// other clip planes that are applied simultaneously. -// -// The priority number is used to decide which of the -// requested clip planes are to be activated when more -// clip planes are requested than the hardware will -// support. The highest-priority n planes are selected -// for rendering. -// -// This is similar to TextureStage::set_priority(). -//////////////////////////////////////////////////////////////////// + +/** + * Changes the relative importance of this PlaneNode (when it is used as a + * clip plane) relative to the other clip planes that are applied + * simultaneously. + * + * The priority number is used to decide which of the requested clip planes + * are to be activated when more clip planes are requested than the hardware + * will support. The highest-priority n planes are selected for rendering. + * + * This is similar to TextureStage::set_priority(). + */ INLINE void PlaneNode:: set_priority(int priority) { _priority = priority; - // Update the global flag to indicate that all ClipPlaneAttribs in - // the world must now re-sort their lists. + // Update the global flag to indicate that all ClipPlaneAttribs in the world + // must now re-sort their lists. _sort_seq++; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_priority -// Access: Published -// Description: Returns the priority associated with this clip -// plane. See set_priority(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the priority associated with this clip plane. See set_priority(). + */ INLINE int PlaneNode:: get_priority() const { return _priority; } - -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::set_clip_effect -// Access: Published -// Description: Specifies the sort of things this plane will actually -// clip (when it is used as a clip plane). This is a -// bitmask union of ClipEffect values. If it includes -// CE_visible, then it will clip visible geometry; if it -// includes CE_collision, then it will clip collision -// polygons. If it includes neither bit, it will still -// affect culling, but objects will either be wholly -// behind the clipping plane, or wholly present. -//////////////////////////////////////////////////////////////////// + +/** + * Specifies the sort of things this plane will actually clip (when it is used + * as a clip plane). This is a bitmask union of ClipEffect values. If it + * includes CE_visible, then it will clip visible geometry; if it includes + * CE_collision, then it will clip collision polygons. If it includes neither + * bit, it will still affect culling, but objects will either be wholly behind + * the clipping plane, or wholly present. + */ INLINE void PlaneNode:: set_clip_effect(int clip_effect) { _clip_effect = clip_effect; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_clip_effect -// Access: Published -// Description: Returns the clip_effect bits for this clip plane. -// See set_clip_effect(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the clip_effect bits for this clip plane. See set_clip_effect(). + */ INLINE int PlaneNode:: get_clip_effect() const { return _clip_effect; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_sort_seq -// Access: Public, Static -// Description: Returns a global sequence number that is incremented -// any time any PlaneNode in the world changes sort -// or priority. This is used by ClipPlaneAttrib to -// determine when it is necessary to re-sort its -// internal array of stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns a global sequence number that is incremented any time any PlaneNode + * in the world changes sort or priority. This is used by ClipPlaneAttrib to + * determine when it is necessary to re-sort its internal array of stages. + */ INLINE UpdateSeq PlaneNode:: get_sort_seq() { return _sort_seq; } - diff --git a/panda/src/pgraph/planeNode.cxx b/panda/src/pgraph/planeNode.cxx index 3dfaa6bb89..c096eaeb49 100644 --- a/panda/src/pgraph/planeNode.cxx +++ b/panda/src/pgraph/planeNode.cxx @@ -1,16 +1,15 @@ -// Filename: planeNode.cxx -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file planeNode.cxx + * @author drose + * @date 2002-07-11 + */ #include "planeNode.h" #include "geometricBoundingVolume.h" @@ -30,44 +29,35 @@ UpdateSeq PlaneNode::_sort_seq; TypeHandle PlaneNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *PlaneNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PlaneNode::CData:: write_datagram(BamWriter *, Datagram &dg) const { _plane.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void PlaneNode::CData:: fillin(DatagramIterator &scan, BamReader *) { _plane.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PlaneNode:: PlaneNode(const string &name, const LPlane &plane) : PandaNode(name), @@ -82,11 +72,9 @@ PlaneNode(const string &name, const LPlane &plane) : set_plane(plane); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PlaneNode:: PlaneNode(const PlaneNode ©) : PandaNode(copy), @@ -96,37 +84,29 @@ PlaneNode(const PlaneNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PlaneNode:: output(ostream &out) const { PandaNode::output(out); out << " " << get_plane(); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PlaneNode:: make_copy() const { return new PlaneNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void PlaneNode:: xform(const LMatrix4 &mat) { PandaNode::xform(mat); @@ -136,35 +116,28 @@ xform(const LMatrix4 &mat) { cdata->_back_viz = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PlaneNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // Normally, a PlaneNode is invisible. But if someone shows it, we - // will draw a visualization, a nice yellow wireframe. + // Normally, a PlaneNode is invisible. But if someone shows it, we will + // draw a visualization, a nice yellow wireframe. CullableObject *plane_viz = new CullableObject(get_viz(trav, data), data._state, @@ -175,29 +148,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool PlaneNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Returns a newly-allocated BoundingVolume that -// represents the internal contents of the node. Should -// be overridden by PandaNode classes that contain -// something internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated BoundingVolume that represents the internal + * contents of the node. Should be overridden by PandaNode classes that + * contain something internally. + */ void PlaneNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -208,18 +174,14 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::get_viz -// Access: Protected -// Description: Returns a Geom that represents the visualization of -// the PlaneNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Geom that represents the visualization of the PlaneNode. + */ PT(Geom) PlaneNode:: get_viz(CullTraverser *trav, CullTraverserData &data) { CDLockedReader cdata(_cycler); - // Figure out whether we are looking at the front or the back of the - // plane. + // Figure out whether we are looking at the front or the back of the plane. const Lens *lens = trav->get_scene()->get_lens(); LPlane eye_plane = cdata->_plane * data.get_modelview_transform(trav)->get_mat(); bool front = (eye_plane.dist_to_plane(lens->get_nodal_point()) >= 0.0f); @@ -294,23 +256,18 @@ get_viz(CullTraverser *trav, CullTraverserData &data) { return front ? cdataw->_front_viz : cdataw->_back_viz; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// PlaneNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type PlaneNode. + */ void PlaneNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PlaneNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -319,14 +276,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_uint8(_clip_effect); } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type PlaneNode is encountered -// in the Bam file. It should create the PlaneNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type PlaneNode is encountered in the Bam file. It should create the + * PlaneNode and extract its information from the file. + */ TypedWritable *PlaneNode:: make_from_bam(const FactoryParams ¶ms) { PlaneNode *node = new PlaneNode(""); @@ -339,13 +293,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: PlaneNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PlaneNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PlaneNode. + */ void PlaneNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/planeNode.h b/panda/src/pgraph/planeNode.h index bd46949c9b..1c0a70c9ff 100644 --- a/panda/src/pgraph/planeNode.h +++ b/panda/src/pgraph/planeNode.h @@ -1,16 +1,15 @@ -// Filename: planeNode.h -// Created by: drose (11Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file planeNode.h + * @author drose + * @date 2002-07-11 + */ #ifndef PLANENODE_H #define PLANENODE_H @@ -29,13 +28,11 @@ #include "cycleDataStageWriter.h" #include "pipelineCycler.h" -//////////////////////////////////////////////////////////////////// -// Class : PlaneNode -// Description : A node that contains a plane. This is most often -// used as a clipping plane, but it can serve other -// purposes as well; whenever a plane is needed to be -// defined in some coordinate space in the world. -//////////////////////////////////////////////////////////////////// +/** + * A node that contains a plane. This is most often used as a clipping plane, + * but it can serve other purposes as well; whenever a plane is needed to be + * defined in some coordinate space in the world. + */ class EXPCL_PANDA_PGRAPH PlaneNode : public PandaNode { PUBLISHED: PlaneNode(const string &name, const LPlane &plane = LPlane()); @@ -77,11 +74,10 @@ protected: int pipeline_stage, Thread *current_thread) const; PT(Geom) get_viz(CullTraverser *trav, CullTraverserData &data); - + private: - // The priority is not cycled, because there's no real reason to do - // so, and cycling it makes it difficult to synchronize with the - // ClipPlaneAttribs. + // The priority is not cycled, because there's no real reason to do so, and + // cycling it makes it difficult to synchronize with the ClipPlaneAttribs. int _priority; int _clip_effect; static UpdateSeq _sort_seq; diff --git a/panda/src/pgraph/polylightEffect.I b/panda/src/pgraph/polylightEffect.I index 7711b2b601..1746c4aac8 100644 --- a/panda/src/pgraph/polylightEffect.I +++ b/panda/src/pgraph/polylightEffect.I @@ -1,34 +1,27 @@ -// Filename: polylightEffect.I -// Created by: sshodhan (02Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightEffect.I + * @author sshodhan + * @date 2004-06-02 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::Constructor -// Access: Protected -// Description: Use PolylightEffect::make() to construct a new -// PolylightEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use PolylightEffect::make() to construct a new PolylightEffect object. + */ INLINE PolylightEffect:: PolylightEffect() { } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::Constructor -// Access: Protected -// Description: Copy Constructor used by the const methods -// to modify data on a copy and return a new one -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor used by the const methods to modify data on a copy and + * return a new one + */ INLINE PolylightEffect:: PolylightEffect(const PolylightEffect ©) : _contribution_type(copy._contribution_type), @@ -38,31 +31,25 @@ PolylightEffect(const PolylightEffect ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::get_weight -// Access: Published -// Description: Get the weight value -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PolylightEffect:: +/** + * Get the weight value + */ +INLINE PN_stdfloat PolylightEffect:: get_weight() const { return _weight; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::get_contrib -// Access: Published -// Description: Returns CT_all or CT_proximal -//////////////////////////////////////////////////////////////////// +/** + * Returns CT_all or CT_proximal + */ INLINE PolylightEffect::ContribType PolylightEffect:: get_contrib() const { return _contribution_type; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::get_effect_center -// Access: Published -// Description: Return the value of the _effect_center -//////////////////////////////////////////////////////////////////// +/** + * Return the value of the _effect_center + */ INLINE LPoint3 PolylightEffect:: get_effect_center() const { return _effect_center; diff --git a/panda/src/pgraph/polylightEffect.cxx b/panda/src/pgraph/polylightEffect.cxx index 55c62448ba..f2c49b7f91 100644 --- a/panda/src/pgraph/polylightEffect.cxx +++ b/panda/src/pgraph/polylightEffect.cxx @@ -1,16 +1,15 @@ -// Filename: polylightEffect.cxx -// Created by: sshodhan (02Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightEffect.cxx + * @author sshodhan + * @date 2004-06-02 + */ #include "polylightEffect.h" #include "polylightNode.h" @@ -25,11 +24,9 @@ TypeHandle PolylightEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::make -// Access: Published, Static -// Description: Constructs a new PolylightEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new PolylightEffect object. + */ CPT(RenderEffect) PolylightEffect:: make() { PolylightEffect *effect = new PolylightEffect; @@ -39,11 +36,9 @@ make() { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::make -// Access: Published, Static -// Description: Constructs a new PolylightEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new PolylightEffect object. + */ CPT(RenderEffect) PolylightEffect:: make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center) { PolylightEffect *effect = new PolylightEffect; @@ -53,11 +48,9 @@ make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center) { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::make -// Access: Published, Static -// Description: Constructs a new PolylightEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new PolylightEffect object. + */ CPT(RenderEffect) PolylightEffect:: make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center, const LightGroup &lights) { @@ -69,70 +62,59 @@ make(PN_stdfloat weight, ContribType contrib, const LPoint3 &effect_center, return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool PolylightEffect:: has_cull_callback() const { return !_lightgroup.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void PolylightEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, CPT(RenderState) &node_state) const { - //CPT(RenderAttrib) poly_light_attrib = do_poly_light(trav->get_scene()->get_scene_root(), &data, node_transform); - CPT(RenderAttrib) poly_light_attrib = do_poly_light(trav->get_scene(), &data, node_transform); + // CPT(RenderAttrib) poly_light_attrib = + // do_poly_light(trav->get_scene()->get_scene_root(), &data, + // node_transform); + CPT(RenderAttrib) poly_light_attrib = do_poly_light(trav->get_scene(), &data, node_transform); CPT(RenderState) poly_light_state = RenderState::make(poly_light_attrib); - node_state = node_state->compose(poly_light_state); + node_state = node_state->compose(poly_light_state); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::do_poly_light -// Access: Public -// Description: Gets the node's position and based on distance from -// lights in the lightgroup calculates the color to be -// modulated in. If the avatar is in the range of -// multiple lights, then determine, which light it is -// closer to, and get the weight of the scene_color -// in respect to that light's proximity. -//////////////////////////////////////////////////////////////////// +/** + * Gets the node's position and based on distance from lights in the + * lightgroup calculates the color to be modulated in. If the avatar is in + * the range of multiple lights, then determine, which light it is closer to, + * and get the weight of the scene_color in respect to that light's proximity. + */ CPT(RenderAttrib) PolylightEffect:: do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const TransformState *node_transform) const { - //static bool was_under_polylight = false; + // static bool was_under_polylight = false; PN_stdfloat dist; // To calculate the distance of each light from the node PN_stdfloat r,g,b; // To hold the color calculation PN_stdfloat min_dist; // hold the dist from light that avatar is closer to int num_lights = 0; // Keep track of number of lights for division - PN_stdfloat light_scale; // Variable to calculate attenuation + PN_stdfloat light_scale; // Variable to calculate attenuation PN_stdfloat weight_scale = 1.0f; // Variable to compensate snap of color when you walk inside the light volume PN_stdfloat Rcollect, Gcollect, Bcollect; const NodePath &root = scene->get_scene_root(); - //const NodePath &camera = scene->get_camera_path(); + // const NodePath &camera = scene->get_camera_path(); const NodePath &camera = scene->get_cull_center(); // Initialize Color variables @@ -146,15 +128,15 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran } min_dist = 100000.0; // Cycle through all the lights in this effect's lightgroup - LightGroup::const_iterator light_iter; + LightGroup::const_iterator light_iter; for (light_iter = _lightgroup.begin(); light_iter != _lightgroup.end(); light_iter++){ - const PolylightNode *light = DCAST(PolylightNode, (*light_iter).node()); + const PolylightNode *light = DCAST(PolylightNode, (*light_iter).node()); // light holds the current PolylightNode if (light->is_enabled()) { // if enabled get all the properties PN_stdfloat light_radius = light->get_radius(); - // Calculate the distance of the node from the light - //dist = light_iter->second->get_distance(data->_node_path.get_node_path()); + // Calculate the distance of the node from the light dist = + // light_iter->second->get_distance(data->_node_path.get_node_path()); const NodePath lightnp = *light_iter; LPoint3 relative_point = data->_node_path.get_node_path().get_relative_point(lightnp, light->get_pos()); @@ -167,9 +149,11 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran } if (dist <= light_radius) { // If node is in range of this light - // as to Schuyler's suggestion, lets do some vector processing relative to camera + // as to Schuyler's suggestion, lets do some vector processing + // relative to camera LPoint3 light_position = light->get_pos(); - //LPoint3 camera_position = camera.get_relative_point(lightnp, light->get_pos()); + // LPoint3 camera_position = camera.get_relative_point(lightnp, + // light->get_pos()); LPoint3 camera_position = lightnp.get_relative_point(camera, LPoint3(0,0,0)); LPoint3 avatar_position = lightnp.get_relative_point(data->_node_path.get_node_path(), LPoint3(0,0,0)); LVector3 light_camera = camera_position - light_position; @@ -177,7 +161,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran light_camera.normalize(); light_avatar.normalize(); PN_stdfloat intensity = light_camera.dot(light_avatar); - + if (polylight_info) { pgraph_cat.debug() << "light position = " << light_position << endl; pgraph_cat.debug() << "relative avatar position = " << avatar_position << endl; @@ -186,7 +170,8 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran pgraph_cat.debug() << "light->avatar " << light_avatar << endl; pgraph_cat.debug() << "light->camera.light->avatar = " << intensity << endl; pgraph_cat.debug() << "effect center = " << _effect_center << endl; - //pgraph_cat.debug() << "close to this light = " << light->get_name() << endl; + // pgraph_cat.debug() << "close to this light = " << + // light->get_name() << endl; pgraph_cat.debug() << "dist = " << dist << ";radius = " << light_radius << endl; } @@ -202,7 +187,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran light_color = light->flicker(); } else { light_color = light->get_color(); - //light_color = light->get_color_scenegraph(); + // light_color = light->get_color_scenegraph(); } PN_stdfloat ratio = dist/light_radius; @@ -224,7 +209,7 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran light_scale = 1.0; } */ - //light_scale = 1.0 - ratio*ratio; // graph of 1-x^2 + // light_scale = 1.0 - ratio*ratio; graph of 1-x^2 ratio = 1 - ratio; if (ratio <= 0.8) light_scale = (ratio*ratio)*(3-2*ratio); //graph of x^2(3-x) @@ -238,10 +223,9 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran if (min_dist > dist) { min_dist = dist; - // Keep accumulating each lights contribution... - // we have to prevent color snap, so factor in the weight. - // weight becomes negligent as you are closer to the light - // and opposite otherwise + // Keep accumulating each lights contribution... we have to prevent + // color snap, so factor in the weight. weight becomes negligent as + // you are closer to the light and opposite otherwise weight_scale = _weight * (1.0 - light_scale); } @@ -271,15 +255,15 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran } // for all lights if ( _contribution_type == CT_all) { - // Sometimes to prevent snapping of color at light volume boundaries - // just divide total contribution by all the lights in the effect - // whether or not they contribute color + // Sometimes to prevent snapping of color at light volume boundaries just + // divide total contribution by all the lights in the effect whether or + // not they contribute color num_lights = _lightgroup.size(); } if (num_lights) { - //was_under_polylight = true; - //data->_node_path.get_node_path().set_color_scale_off(); + // was_under_polylight = true; + // data->_node_path.get_node_path().set_color_scale_off(); if (polylight_info) pgraph_cat.debug() << "num lights = " << num_lights << endl; @@ -318,9 +302,9 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran if (polylight_info) pgraph_cat.debug() << "capped: r=" << r << "; g=" << g << "; b=" << b << endl; - // since this rgb will be scaled by scene_color by day night - // cycle, lets undo that effect by dividing this rgb by the - // scene_color. That way, the final render will contain this rgb + // since this rgb will be scaled by scene_color by day night cycle, lets + // undo that effect by dividing this rgb by the scene_color. That way, + // the final render will contain this rgb if (scene_color[0] >= 0.01) r /= scene_color[0]; if (scene_color[1] >= 0.01) @@ -336,8 +320,8 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran else { if (was_under_polylight) { // under no polylight influence...so clear the color scale - //data->_node_path.get_node_path().clear_color_scale(); - //data->_node_path.get_node_path().set_color_scale(scene_color); + // data->_node_path.get_node_path().clear_color_scale(); + // data->_node_path.get_node_path().set_color_scale(scene_color); was_under_polylight = false; } } @@ -346,15 +330,13 @@ do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const Tran return ColorScaleAttrib::make(LVecBase4(r, g, b, 1.0)); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PolylightEffect:: output(ostream &out) const { out << get_type() << ":"; - + LightGroup::const_iterator li; for (li = _lightgroup.begin(); li != _lightgroup.end(); ++li) { NodePath light = (*li); @@ -365,21 +347,18 @@ output(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived PolylightEffect -// types to return a unique number indicating whether -// this PolylightEffect is equivalent to the other one. -// -// This should return 0 if the two PolylightEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two PolylightEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived PolylightEffect types to return a + * unique number indicating whether this PolylightEffect is equivalent to the + * other one. + * + * This should return 0 if the two PolylightEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two PolylightEffect objects whose get_type() + * functions return the same. + */ int PolylightEffect:: compare_to_impl(const RenderEffect *other) const { const PolylightEffect *ta; @@ -388,7 +367,7 @@ compare_to_impl(const RenderEffect *other) const { if (_contribution_type != ta->_contribution_type) { return _contribution_type < ta->_contribution_type ? -1 : 1; } - + if (_weight != ta->_weight) { return _weight < ta->_weight ? -1 :1; } @@ -396,18 +375,15 @@ compare_to_impl(const RenderEffect *other) const { if (_lightgroup != ta->_lightgroup) { return _lightgroup < ta->_lightgroup ? -1 : 1; } - + return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::add_light -// Access: Published -// Description: Add a PolylightNode object to this effect and return -// a new effect -//////////////////////////////////////////////////////////////////// +/** + * Add a PolylightNode object to this effect and return a new effect + */ CPT(RenderEffect) PolylightEffect:: add_light(const NodePath &newlight) const { PolylightEffect *effect = new PolylightEffect(*this); @@ -416,17 +392,14 @@ add_light(const NodePath &newlight) const { } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::remove_light -// Access: Published -// Description: Remove a light from this effect. Return the new updated -// effect -//////////////////////////////////////////////////////////////////// +/** + * Remove a light from this effect. Return the new updated effect + */ CPT(RenderEffect) PolylightEffect:: remove_light(const NodePath &newlight) const { PolylightEffect *effect = new PolylightEffect(*this); LightGroup::iterator light_iter; - light_iter = find(effect->_lightgroup.begin(),effect->_lightgroup.end(), newlight); + light_iter = find(effect->_lightgroup.begin(),effect->_lightgroup.end(), newlight); if (light_iter == effect->_lightgroup.end()) { pgraph_cat.debug() << "Attempt to remove Polylight " << newlight << "; not found.\n"; @@ -435,18 +408,15 @@ remove_light(const NodePath &newlight) const { effect->_lightgroup.erase(light_iter); } return return_new(effect); - + } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::set_weight -// Access: Published -// Description: Set weight and return a new effect... the reason -// this couldnt be done through make was because -// that would return a new effect without the -// lightgroup which is static and cant be accessed -// Here, we just pass that to the make -//////////////////////////////////////////////////////////////////// +/** + * Set weight and return a new effect... the reason this couldnt be done + * through make was because that would return a new effect without the + * lightgroup which is static and cant be accessed Here, we just pass that to + * the make + */ CPT(RenderEffect) PolylightEffect:: set_weight(PN_stdfloat w) const { PolylightEffect *effect = new PolylightEffect(*this); @@ -454,15 +424,12 @@ set_weight(PN_stdfloat w) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::set_contrib -// Access: Published -// Description: Set Contrib Type and return a new effect... the reason -// this couldnt be done through make was because -// that would return a new effect without the -// lightgroup which is static and cant be accessed -// Here, we just pass that to the make -//////////////////////////////////////////////////////////////////// +/** + * Set Contrib Type and return a new effect... the reason this couldnt be done + * through make was because that would return a new effect without the + * lightgroup which is static and cant be accessed Here, we just pass that to + * the make + */ CPT(RenderEffect) PolylightEffect:: set_contrib(ContribType ct) const { PolylightEffect *effect = new PolylightEffect(*this); @@ -470,15 +437,12 @@ set_contrib(ContribType ct) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::set_effect_center -// Access: Published -// Description: Set weight and return a new effect... the reason -// this couldnt be done through make was because -// that would return a new effect without the -// lightgroup which is static and cant be accessed -// Here, we just pass that to the make -//////////////////////////////////////////////////////////////////// +/** + * Set weight and return a new effect... the reason this couldnt be done + * through make was because that would return a new effect without the + * lightgroup which is static and cant be accessed Here, we just pass that to + * the make + */ CPT(RenderEffect) PolylightEffect:: set_effect_center(const LPoint3 &ec) const{ PolylightEffect *effect = new PolylightEffect(*this); @@ -486,16 +450,14 @@ set_effect_center(const LPoint3 &ec) const{ return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightEffect::has_light -// Access: Published -// Description: Returns true if the indicated light is listed in the -// PolylightEffect, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated light is listed in the PolylightEffect, false + * otherwise. + */ bool PolylightEffect:: has_light(const NodePath &light) const { LightGroup::const_iterator li; - li = find(_lightgroup.begin(), _lightgroup.end(), light); + li = find(_lightgroup.begin(), _lightgroup.end(), light); return (li != _lightgroup.end()); } diff --git a/panda/src/pgraph/polylightEffect.h b/panda/src/pgraph/polylightEffect.h index e96f2b9f01..418ac2f5db 100644 --- a/panda/src/pgraph/polylightEffect.h +++ b/panda/src/pgraph/polylightEffect.h @@ -1,16 +1,15 @@ -// Filename: polylightEffect.h -// Created by: sshodhan (01Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightEffect.h + * @author sshodhan + * @date 2004-06-01 + */ #ifndef POLYLIGHTEFFECT_H #define POLYLIGHTEFFECT_H @@ -27,15 +26,12 @@ #include "sceneSetup.h" -//////////////////////////////////////////////////////////////////// -// Class : PolylightEffect -// Description : A PolylightEffect can be used on a node to define a -// LightGroup for that node. A LightGroup contains -// PolylightNodes which are essentially nodes that add -// color to the polygons of a model based on distance. -// PolylightNode is a cheap way to get lighting effects -// specially for night scenes -//////////////////////////////////////////////////////////////////// +/** + * A PolylightEffect can be used on a node to define a LightGroup for that + * node. A LightGroup contains PolylightNodes which are essentially nodes + * that add color to the polygons of a model based on distance. PolylightNode + * is a cheap way to get lighting effects specially for night scenes + */ class EXPCL_PANDA_PGRAPH PolylightEffect : public RenderEffect { PUBLISHED: enum ContribType { @@ -71,7 +67,8 @@ public: CPT(RenderState) &node_state) const; CPT(RenderAttrib) do_poly_light(const SceneSetup *scene, const CullTraverserData *data, const TransformState *node_transform) const; - //CPT(RenderAttrib) do_poly_light(const NodePath &root, const CullTraverserData *data, const TransformState *node_transform) const; + // CPT(RenderAttrib) do_poly_light(const NodePath &root, const + // CullTraverserData *data, const TransformState *node_transform) const; virtual void output(ostream &out) const; @@ -107,6 +104,3 @@ private: ostream &operator << (ostream &out, PolylightEffect::ContribType ct); #endif - - - diff --git a/panda/src/pgraph/polylightNode.I b/panda/src/pgraph/polylightNode.I index aca68fe6f7..7a4fcb5899 100644 --- a/panda/src/pgraph/polylightNode.I +++ b/panda/src/pgraph/polylightNode.I @@ -1,99 +1,79 @@ -// Filename: polylightNode.I -// Created by: sshodhan (02Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightNode.I + * @author sshodhan + * @date 2004-06-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::operator == -// Access: Published -// Description: Returns true if the two lights are equivalent -// that is, all their properties are same -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two lights are equivalent that is, all their properties + * are same + */ INLINE bool PolylightNode:: operator == (const PolylightNode &other) const { return (compare_to(other) == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::operator != -// Access: Published -// Description: Returns true if the two lights are not equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two lights are not equivalent. + */ INLINE bool PolylightNode:: operator != (const PolylightNode &other) const { return (compare_to(other) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::operator < -// Access: Published -// Description: Returns true if this PolylightNode sorts before the other -// one, false otherwise. The sorting order of two -// nonequivalent PolylightNodes is consistent but undefined, -// and is useful only for storing PolylightNodes in a sorted -// container like an STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PolylightNode sorts before the other one, false + * otherwise. The sorting order of two nonequivalent PolylightNodes is + * consistent but undefined, and is useful only for storing PolylightNodes in + * a sorted container like an STL set. + */ INLINE bool PolylightNode:: operator < (const PolylightNode &other) const { return (compare_to(other) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::is_enabled -// Access: Published -// Description: Is this light is enabled/disabled? -//////////////////////////////////////////////////////////////////// +/** + * Is this light is enabled/disabled? + */ INLINE bool PolylightNode:: is_enabled() const { return _enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::enable -// Access: Published -// Description: Enable this light -//////////////////////////////////////////////////////////////////// +/** + * Enable this light + */ INLINE void PolylightNode:: enable(){ _enabled=true; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::disable -// Access: Published -// Description: Disable this light -//////////////////////////////////////////////////////////////////// +/** + * Disable this light + */ INLINE void PolylightNode:: disable(){ _enabled=false; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_pos -// Access: Published -// Description: Set this light's position -//////////////////////////////////////////////////////////////////// +/** + * Set this light's position + */ INLINE void PolylightNode:: set_pos(const LPoint3 &position) { _position = position; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_pos -// Access: Published -// Description: Set this light's position -//////////////////////////////////////////////////////////////////// +/** + * Set this light's position + */ INLINE void PolylightNode:: set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z){ _position[0]=x; @@ -101,41 +81,33 @@ set_pos(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z){ _position[2]=z; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_pos -// Access: Published -// Description: Returns position as a LPoint3 -//////////////////////////////////////////////////////////////////// +/** + * Returns position as a LPoint3 + */ INLINE LPoint3 PolylightNode:: get_pos() const { return _position; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_radius -// Access: Published -// Description: Set radius of the spherical light volume -//////////////////////////////////////////////////////////////////// +/** + * Set radius of the spherical light volume + */ INLINE void PolylightNode:: set_radius(PN_stdfloat r){ _radius=r; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_radius -// Access: Published -// Description: Get radius of the spherical light volume -//////////////////////////////////////////////////////////////////// +/** + * Get radius of the spherical light volume + */ INLINE PN_stdfloat PolylightNode:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_attenuation -// Access: Published -// Description: Set ALINEAR or AQUADRATIC attenuation -//////////////////////////////////////////////////////////////////// +/** + * Set ALINEAR or AQUADRATIC attenuation + */ INLINE bool PolylightNode:: set_attenuation(PolylightNode::Attenuation_Type type){ nassertr(type == ALINEAR || type == AQUADRATIC,false); @@ -144,121 +116,98 @@ set_attenuation(PolylightNode::Attenuation_Type type){ } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_attenuation -// Access: Published -// Description: Get "linear" or "quadratic" attenuation type -//////////////////////////////////////////////////////////////////// +/** + * Get "linear" or "quadratic" attenuation type + */ INLINE PolylightNode::Attenuation_Type PolylightNode:: get_attenuation() const { return _attenuation_type; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_a0 -// Access: Published -// Description: Set the quadratic attenuation factor a0 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Set the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE void PolylightNode:: set_a0(PN_stdfloat a0){ _a0=a0; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_a1 -// Access: Published -// Description: Set the quadratic attenuation factor a1 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Set the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE void PolylightNode:: set_a1(PN_stdfloat a1){ _a1=a1; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_a2 -// Access: Published -// Description: Set the quadratic attenuation factor a2 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Set the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE void PolylightNode:: set_a2(PN_stdfloat a2){ _a2=a2; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_a0 -// Access: Published -// Description: Get the quadratic attenuation factor a0 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Get the quadratic attenuation factor a0 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE PN_stdfloat PolylightNode:: get_a0() const { return _a0; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_a1 -// Access: Published -// Description: Get the quadratic attenuation factor a1 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Get the quadratic attenuation factor a1 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE PN_stdfloat PolylightNode:: get_a1() const { return _a1; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_a2 -// Access: Published -// Description: Get the quadratic attenuation factor a2 -// fd = 1 / ( a0 + a1*distance + a2*distance*distance) -//////////////////////////////////////////////////////////////////// +/** + * Get the quadratic attenuation factor a2 fd = 1 / ( a0 + a1*distance + + * a2*distance*distance) + */ INLINE PN_stdfloat PolylightNode:: get_a2() const { return _a2; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::flicker_on -// Access: Published -// Description: Set flickering to true so at every loop this light's -// color is varied based on flicker_type -//////////////////////////////////////////////////////////////////// +/** + * Set flickering to true so at every loop this light's color is varied based + * on flicker_type + */ INLINE void PolylightNode:: flicker_on(){ _flickering=true; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::flicker_off -// Access: Published -// Description: Turn flickering off -//////////////////////////////////////////////////////////////////// +/** + * Turn flickering off + */ INLINE void PolylightNode:: flicker_off(){ _flickering=false; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::is_flickering -// Access: Published -// Description: Check is this light is flickering -//////////////////////////////////////////////////////////////////// +/** + * Check is this light is flickering + */ INLINE bool PolylightNode:: is_flickering() const { return _flickering; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_flicker_type -// Access: Published -// Description: Flicker type can be FRANDOM or FSIN -// At a later point there might be a FCUSTOM -// Custom flicker will be a set of fix points recorded -// by animating the light's intensity -//////////////////////////////////////////////////////////////////// +/** + * Flicker type can be FRANDOM or FSIN At a later point there might be a + * FCUSTOM Custom flicker will be a set of fix points recorded by animating + * the light's intensity + */ INLINE bool PolylightNode:: set_flicker_type(PolylightNode::Flicker_Type type){ nassertr(type == FRANDOM || type == FSIN,false); @@ -267,102 +216,78 @@ set_flicker_type(PolylightNode::Flicker_Type type){ return true; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_flicker_type -// Access: Published -// Description: Returns FRANDOM or FSIN -//////////////////////////////////////////////////////////////////// +/** + * Returns FRANDOM or FSIN + */ INLINE PolylightNode::Flicker_Type PolylightNode:: get_flicker_type() const { return _flicker_type; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_offset -// Access: Published -// Description: Set the offset value for the random and sin -// flicker variations... used to tweak the flicker -// This value is added to the variation -//////////////////////////////////////////////////////////////////// +/** + * Set the offset value for the random and sin flicker variations... used to + * tweak the flicker This value is added to the variation + */ INLINE void PolylightNode:: set_offset(PN_stdfloat offset){ _offset=offset; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_offset -// Access: Published -// Description: Get the offset value for the random and sin -// flicker variations -//////////////////////////////////////////////////////////////////// +/** + * Get the offset value for the random and sin flicker variations + */ INLINE PN_stdfloat PolylightNode:: get_offset() const { return _offset; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_scale -// Access: Published -// Description: Set the scale value for the random and sin -// flicker variations... used to tweak the flicker -// This value is multiplied with the variation -//////////////////////////////////////////////////////////////////// +/** + * Set the scale value for the random and sin flicker variations... used to + * tweak the flicker This value is multiplied with the variation + */ INLINE void PolylightNode:: set_scale(PN_stdfloat scale){ _scale=scale; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_scale -// Access: Published -// Description: Get the scale value for the random and sin -// flicker variations -//////////////////////////////////////////////////////////////////// +/** + * Get the scale value for the random and sin flicker variations + */ INLINE PN_stdfloat PolylightNode:: get_scale() const { return _scale; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_step_size -// Access: Published -// Description: Set the step size for the sin function in flicker -// This is the increment size for the value supplied -// to the sin function -//////////////////////////////////////////////////////////////////// +/** + * Set the step size for the sin function in flicker This is the increment + * size for the value supplied to the sin function + */ INLINE void PolylightNode:: set_step_size(PN_stdfloat step){ _step_size=step; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_step_size -// Access: Published -// Description: Get the step size for the sin function in flicker -// This is the increment size for the value supplied -// to the sin function -//////////////////////////////////////////////////////////////////// +/** + * Get the step size for the sin function in flicker This is the increment + * size for the value supplied to the sin function + */ INLINE PN_stdfloat PolylightNode:: get_step_size() const { return _step_size; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_color -// Access: Published -// Description: Set the light's color... -//////////////////////////////////////////////////////////////////// +/** + * Set the light's color... + */ INLINE void PolylightNode:: set_color(const LColor &color) { - //PandaNode::set_attrib(ColorAttrib::make_flat(color)); + // PandaNode::set_attrib(ColorAttrib::make_flat(color)); _color = color; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_color -// Access: Published -// Description: Set the light's color... 3 floats between 0 and 1 -//////////////////////////////////////////////////////////////////// +/** + * Set the light's color... 3 floats between 0 and 1 + */ INLINE void PolylightNode:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { /* @@ -379,24 +304,19 @@ set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b) { _color[3] = 1.0; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_color -// Access: Published -// Description: Returns the light's color as LColor -//////////////////////////////////////////////////////////////////// +/** + * Returns the light's color as LColor + */ INLINE LColor PolylightNode:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_color_scenegraph -// Access: Published -// Description: This differs from get_color in that when applying -// the light color we need to make sure that a color -// flattening external to the PolylightNode is not -// ignored. -//////////////////////////////////////////////////////////////////// +/** + * This differs from get_color in that when applying the light color we need + * to make sure that a color flattening external to the PolylightNode is not + * ignored. + */ INLINE LColor PolylightNode:: get_color_scenegraph() const { @@ -414,21 +334,17 @@ get_color_scenegraph() const { } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::set_freq -// Access: Published -// Description: Set frequency of sin flicker -//////////////////////////////////////////////////////////////////// +/** + * Set frequency of sin flicker + */ INLINE void PolylightNode:: set_freq(PN_stdfloat f) { _sin_freq=f; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::get_freq -// Access: Published -// Description: Get frequency of sin flicker -//////////////////////////////////////////////////////////////////// +/** + * Get frequency of sin flicker + */ INLINE PN_stdfloat PolylightNode:: get_freq() const { return _sin_freq; diff --git a/panda/src/pgraph/polylightNode.cxx b/panda/src/pgraph/polylightNode.cxx index 18138d6aab..e7b857367b 100644 --- a/panda/src/pgraph/polylightNode.cxx +++ b/panda/src/pgraph/polylightNode.cxx @@ -1,16 +1,15 @@ -// Filename: polylightNode.cxx -// Created by: sshodhan (02Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightNode.cxx + * @author sshodhan + * @date 2004-06-02 + */ #include "polylightNode.h" #include "config_pgraph.h" @@ -26,12 +25,9 @@ TypeHandle PolylightNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::Constructor -// Access: Published -// Description: Use PolylightNode() to construct a new -// PolylightNode object. -//////////////////////////////////////////////////////////////////// +/** + * Use PolylightNode() to construct a new PolylightNode object. + */ PolylightNode:: PolylightNode(const string &name) : PandaNode(name) @@ -52,26 +48,20 @@ PandaNode(name) _sin_freq = 2.0; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PolylightNode:: make_copy() const { return new PolylightNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PolylightNode:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); @@ -82,23 +72,19 @@ xform(const LMatrix4 &mat) { _position = _position * mat; - // This is a little cheesy and fails miserably in the presence of a - // non-uniform scale. + // This is a little cheesy and fails miserably in the presence of a non- + // uniform scale. LVector3 radius_v = LVector3(_radius, 0.0f, 0.0f) * mat; _radius = length(radius_v); mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::Constructor -// Access: Public -// Description: If flickering is on, the do_poly_light function -// in PolylightNodeEffect will compute this light's color -// based on the variations applied in this function -// Variation can be sin or random -// Use offset, scale and step_size to tweak -// Future addition: custom function variations to flicker -//////////////////////////////////////////////////////////////////// +/** + * If flickering is on, the do_poly_light function in PolylightNodeEffect will + * compute this light's color based on the variations applied in this function + * Variation can be sin or random Use offset, scale and step_size to tweak + * Future addition: custom function variations to flicker + */ LColor PolylightNode::flicker() const { PN_stdfloat r,g,b; @@ -110,7 +96,7 @@ LColor PolylightNode::flicker() const { b = color[2]; if (_flicker_type == FRANDOM) { - //srand((int)ClockObject::get_global_clock()->get_frame_time()); + // srand((int)ClockObject::get_global_clock()->get_frame_time()); variation = (rand()%100); // a value between 0-99 variation /= 100.0; if (polylight_info) @@ -124,9 +110,9 @@ LColor PolylightNode::flicker() const { if (variation < 0.0) variation *= -1.0; } else if (_flicker_type == FCUSTOM) { - // fixed point list of variation values coming soon... - //double index = (ClockObject::get_global_clock()->get_frame_time() % len(fixed_points)) * ClockObject::get_global_clock()->get_dt(); - //index *= _speed; + // fixed point list of variation values coming soon... double index = + // (ClockObject::get_global_clock()->get_frame_time() % len(fixed_points)) + // * ClockObject::get_global_clock()->get_dt(); index *= _speed; /*if (!(int)index > len(fixed_points) { variation = _fixed_points[(int)index]; variation += _offset; @@ -134,10 +120,9 @@ LColor PolylightNode::flicker() const { }*/ } - //variation += _offset; - //variation *= _scale; + // variation += _offset; variation *= _scale; - //printf("Variation: %f\n",variation); + // printf("Variation: %f\n",variation); r += r * variation; g += g * variation; b += b * variation; @@ -153,21 +138,17 @@ LColor PolylightNode::flicker() const { return LColor(r,g,b,1.0); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::compare_to -// Access: Published -// Description: Returns a number less than zero if this PolylightNode -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -// -// Two PolylightNodes are considered equivalent if they -// consist of exactly the same properties -// Otherwise, they are different; different -// PolylightNodes will be ranked in a consistent but -// undefined ordering; the ordering is useful only for -// placing the PolylightNodes in a sorted container like an -// STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this PolylightNode sorts before the + * other one, greater than zero if it sorts after, or zero if they are + * equivalent. + * + * Two PolylightNodes are considered equivalent if they consist of exactly the + * same properties Otherwise, they are different; different PolylightNodes + * will be ranked in a consistent but undefined ordering; the ordering is + * useful only for placing the PolylightNodes in a sorted container like an + * STL set. + */ int PolylightNode:: compare_to(const PolylightNode &other) const { @@ -237,23 +218,18 @@ compare_to(const PolylightNode &other) const { -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// PolylightNode -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type PolylightNode + */ void PolylightNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PolylightNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -264,14 +240,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_radius); } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CompassEffect is encountered -// in the Bam file. It should create the CompassEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CompassEffect is encountered in the Bam file. It should create the + * CompassEffect and extract its information from the file. + */ TypedWritable *PolylightNode:: make_from_bam(const FactoryParams ¶ms) { PolylightNode *light = new PolylightNode(""); @@ -284,13 +257,10 @@ make_from_bam(const FactoryParams ¶ms) { return light; } -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CompassEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CompassEffect. + */ void PolylightNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); @@ -303,16 +273,14 @@ fillin(DatagramIterator &scan, BamReader *manager) { -//////////////////////////////////////////////////////////////////// -// Function: PolylightNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PolylightNode:: output(ostream &out) const { out << get_type() << ":"; - //out << "Position: " << get_x() << " " << get_y() << " " << get_z() << "\n"; - //out << "Color: " << get_r() << " " << get_g() << " " << get_b() << "\n"; + // out << "Position: " << get_x() << " " << get_y() << " " << get_z() << + // "\n"; out << "Color: " << get_r() << " " << get_g() << " " << get_b() << + // "\n"; out << "Radius: " << get_radius() << "\n"; } - diff --git a/panda/src/pgraph/polylightNode.h b/panda/src/pgraph/polylightNode.h index 9e3eb6e253..1b8c236e0b 100644 --- a/panda/src/pgraph/polylightNode.h +++ b/panda/src/pgraph/polylightNode.h @@ -1,16 +1,15 @@ -// Filename: polylightNode.h -// Created by: sshodhan (02Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file polylightNode.h + * @author sshodhan + * @date 2004-06-02 + */ #ifndef POLYLIGHTNODE_H #define POLYLIGHTNODE_H @@ -24,20 +23,18 @@ #include "pandaNode.h" #include "colorAttrib.h" -//////////////////////////////////////////////////////////////////// -// Class : PolylightNode -// Description : A PolylightNode -//////////////////////////////////////////////////////////////////// +/** + * A PolylightNode + */ class EXPCL_PANDA_PGRAPH PolylightNode : public PandaNode{ -//private: +// private: PUBLISHED: /* - // This was the old constructor... interrogate would generate a - // separate wrapper for each parameter... so its better to - // have a simpler constructor and require the programmer - // to use set_* methods. + // This was the old constructor... interrogate would generate a separate + // wrapper for each parameter... so its better to have a simpler constructor + // and require the programmer to use set_* methods. PolylightNode(const string &name, PN_stdfloat x = 0.0, PN_stdfloat y = 0.0, PN_stdfloat z = 0.0, PN_stdfloat r = 1.0, PN_stdfloat g = 1.0, PN_stdfloat b = 1.0, PN_stdfloat radius=50.0, string attenuation_type= "linear", @@ -117,8 +114,7 @@ private: PN_stdfloat _scale; PN_stdfloat _step_size; PN_stdfloat _sin_freq; - //PN_stdfloat _speed; - //PN_stdfloat fixed_points + // PN_stdfloat _speed; PN_stdfloat fixed_points public: @@ -153,5 +149,3 @@ private: #include "polylightNode.I" #endif - - diff --git a/panda/src/pgraph/portalClipper.I b/panda/src/pgraph/portalClipper.I index eb89a1c256..221119feb5 100644 --- a/panda/src/pgraph/portalClipper.I +++ b/panda/src/pgraph/portalClipper.I @@ -1,32 +1,26 @@ -// Filename: portalClipper.I -// Created by: masad (4May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalClipper.I + * @author masad + * @date 2004-05-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Point::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PortalClipper::Point:: Point() { } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Point::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PortalClipper::Point:: Point(const LVecBase3 &point, const LColor &color) : _point(point[0], point[1], point[2]), @@ -34,11 +28,9 @@ Point(const LVecBase3 &point, const LColor &color) : { } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Point::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PortalClipper::Point:: Point(const PortalClipper::Point ©) : _point(copy._point), @@ -46,107 +38,84 @@ Point(const PortalClipper::Point ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Point::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PortalClipper::Point:: operator = (const PortalClipper::Point ©) { _point = copy._point; _color = copy._color; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::move_to -// Access: Public -// Description: Moves the pen to the given point without drawing a -// line. When followed by draw_to(), this marks the -// first point of a line segment; when followed by -// move_to() or create(), this creates a single point. -//////////////////////////////////////////////////////////////////// +/** + * Moves the pen to the given point without drawing a line. When followed by + * draw_to(), this marks the first point of a line segment; when followed by + * move_to() or create(), this creates a single point. + */ INLINE void PortalClipper:: move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { move_to(LVertex(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw_to -// Access: Public -// Description: Draws a line segment from the pen's last position -// (the last call to move_to or draw_to) to the -// indicated point. move_to() and draw_to() only update -// tables; the actual drawing is performed when create() -// is called. -//////////////////////////////////////////////////////////////////// +/** + * Draws a line segment from the pen's last position (the last call to move_to + * or draw_to) to the indicated point. move_to() and draw_to() only update + * tables; the actual drawing is performed when create() is called. + */ INLINE void PortalClipper:: draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { draw_to(LVertex(x, y, z)); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw_camera_frustum -// Access: Public -// Description: Draw the current camera frustum in white color -// -//////////////////////////////////////////////////////////////////// +/** + * Draw the current camera frustum in white color + * + */ INLINE void PortalClipper:: draw_camera_frustum() { _color = LColor(1,1,1,1); draw_hexahedron(_view_frustum); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::set_reduced_frustum -// Access: Public -// Description: Set the current view frustum that is being calculated -// by the portal clipper -// -//////////////////////////////////////////////////////////////////// +/** + * Set the current view frustum that is being calculated by the portal clipper + * + */ INLINE void PortalClipper:: set_reduced_frustum(BoundingHexahedron *frustum) { _reduced_frustum = frustum; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::get_reduced_frustum -// Access: Published -// Description: Return the reduced frustum -//////////////////////////////////////////////////////////////////// +/** + * Return the reduced frustum + */ INLINE BoundingHexahedron *PortalClipper:: get_reduced_frustum() const { return _reduced_frustum; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::set_clip_state -// Access: Public -// Description: Set the clip state of the current portal node -// This is done to remember the state for the child portal nodes -// -//////////////////////////////////////////////////////////////////// +/** + * Set the clip state of the current portal node This is done to remember the + * state for the child portal nodes + * + */ INLINE void PortalClipper:: set_clip_state(const RenderState* clip_state) { _clip_state = clip_state; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::get_clip_state -// Access: Published -// Description: Returns the stored clip state -//////////////////////////////////////////////////////////////////// +/** + * Returns the stored clip state + */ INLINE const RenderState *PortalClipper:: get_clip_state() const { return _clip_state; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::set_reduced_viewport -// Access: Public -// Description: Set the current viewport that is being used -// by the portal clipper -// -//////////////////////////////////////////////////////////////////// +/** + * Set the current viewport that is being used by the portal clipper + * + */ INLINE void PortalClipper:: set_reduced_viewport(const LPoint2& min, const LPoint2& max) { _reduced_viewport_min = min; @@ -154,11 +123,9 @@ set_reduced_viewport(const LPoint2& min, const LPoint2& max) { } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::get_reduced_viewport -// Access: Published -// Description: Return the reduced viewport -//////////////////////////////////////////////////////////////////// +/** + * Return the reduced viewport + */ INLINE void PortalClipper:: get_reduced_viewport(LPoint2& min, LPoint2& max) const { min = _reduced_viewport_min; @@ -167,25 +134,21 @@ get_reduced_viewport(LPoint2& min, LPoint2& max) const { -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::is_facing_view -// Access: Public -// Description: checks if the portal plane (in camera space) -// is facing the camera's near plane -//////////////////////////////////////////////////////////////////// +/** + * checks if the portal plane (in camera space) is facing the camera's near + * plane + */ INLINE bool PortalClipper:: is_facing_view(const LPlane &portal_plane) { portal_cat.debug() << "portal plane check value: " << portal_plane[3] << "\n"; return (portal_plane[3] > 0); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::is_whole_portal_in_view -// Access: Public -// Description: checks if portal_node is within the view frustum. -// If so, then the portal is worth considering. This -// is a 2nd level test to weed out most of the portals -//////////////////////////////////////////////////////////////////// +/** + * checks if portal_node is within the view frustum. If so, then the portal + * is worth considering. This is a 2nd level test to weed out most of the + * portals + */ INLINE bool PortalClipper:: is_whole_portal_in_view(const LMatrix4 &cmat) { // I am about to xform this gbv, so lets make a copy @@ -202,18 +165,16 @@ is_whole_portal_in_view(const LMatrix4 &cmat) { return (result != 0); } +/** + * checks if any of the _coords is within the view frustum. If so, then the + * portal is facing the camera. 2nd level test to make sure this portal is + * worth visiting + */ /* -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::is_partial_portal_in_view -// Access: Public -// Description: checks if any of the _coords is within the view frustum. -// If so, then the portal is facing the camera. 2nd level -// test to make sure this portal is worth visiting -//////////////////////////////////////////////////////////////////// INLINE bool PortalClipper:: is_partial_portal_in_view() { int result = 0; - + // check if any of the _coords in tested frustum for (int j=0; j<_num_vert; ++j) { result |= _reduced_frustum->contains(_coords[j]); @@ -224,17 +185,14 @@ is_partial_portal_in_view() { } */ +/** + * Given the x and z, solve for y: from the plane + */ /* -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::get_plane_depth -// Access: Public -// Description: Given the x and z, solve for y: from the plane -//////////////////////////////////////////////////////////////////// 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 + // 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; @@ -243,7 +201,6 @@ get_plane_depth(PN_stdfloat x, PN_stdfloat z, LPlane *portal_plane) { y = (((portal_plane->_v.v._0*x)+(portal_plane->_v.v._2*z)+portal_plane->_v.v._3) / -(portal_plane->_v.v._1)); } - return y; + return y; } */ - diff --git a/panda/src/pgraph/portalClipper.cxx b/panda/src/pgraph/portalClipper.cxx index b805352688..7b9e55556b 100644 --- a/panda/src/pgraph/portalClipper.cxx +++ b/panda/src/pgraph/portalClipper.cxx @@ -1,16 +1,15 @@ -// Filename: portalClipper.cxx -// Created by: masad (4May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalClipper.cxx + * @author masad + * @date 2004-05-04 + */ #include "portalClipper.h" #include "cullTraverser.h" @@ -33,11 +32,9 @@ TypeHandle PortalClipper::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PortalClipper:: PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup): _reduced_viewport_min(-1,-1), @@ -52,23 +49,18 @@ _clip_state(0) _scene_setup = scene_setup; } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PortalClipper:: ~PortalClipper() { } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::move_to -// Access: Public -// Description: Moves the pen to the given point without drawing a -// line. When followed by draw_to(), this marks the -// first point of a line segment; when followed by -// move_to() or create(), this creates a single point. -//////////////////////////////////////////////////////////////////// +/** + * Moves the pen to the given point without drawing a line. When followed by + * draw_to(), this marks the first point of a line segment; when followed by + * move_to() or create(), this creates a single point. + */ void PortalClipper:: move_to(const LVecBase3 &v) { // We create a new SegmentList with the initial point in it. @@ -79,15 +71,11 @@ move_to(const LVecBase3 &v) { _list.push_back(segs); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw_to -// Access: Public -// Description: Draws a line segment from the pen's last position -// (the last call to move_to or draw_to) to the -// indicated point. move_to() and draw_to() only update -// tables; the actual drawing is performed when create() -// is called. -//////////////////////////////////////////////////////////////////// +/** + * Draws a line segment from the pen's last position (the last call to move_to + * or draw_to) to the indicated point. move_to() and draw_to() only update + * tables; the actual drawing is performed when create() is called. + */ void PortalClipper:: draw_to(const LVecBase3 &v) { if (_list.empty()) { @@ -95,8 +83,8 @@ draw_to(const LVecBase3 &v) { move_to(v); } else { - // Get the current SegmentList, which was the last one we added to - // the LineList. + // Get the current SegmentList, which was the last one we added to the + // LineList. SegmentList &segs = _list.back(); // Add the new point. @@ -104,12 +92,10 @@ draw_to(const LVecBase3 &v) { } } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw a portal frustum -// Access: Public -// Description: Given the BoundingHexahedron draw it using lines -// -//////////////////////////////////////////////////////////////////// +/** + * Given the BoundingHexahedron draw it using lines + * + */ void PortalClipper:: draw_hexahedron(BoundingHexahedron *frustum) { // walk the view frustum as it should be drawn @@ -133,12 +119,10 @@ draw_hexahedron(BoundingHexahedron *frustum) { draw_to(frustum->get_point(6)); draw_to(frustum->get_point(2)); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw the current visible portal -// Access: Public -// Description: _portal_node is the current portal, draw it. -// -//////////////////////////////////////////////////////////////////// +/** + * _portal_node is the current portal, draw it. + * + */ void PortalClipper:: draw_current_portal() { @@ -148,35 +132,31 @@ draw_current_portal() draw_to(_portal_node->get_vertex(3)); } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::draw the lines -// Access: Public -// Description: Draw all the lines in the buffer -// Cyan portal is the original geometry of the portal -// Yellow portal is the AA minmax & clipped portal -// Blue frustum is the frustum through portal -// White frustum is the camera frustum -//////////////////////////////////////////////////////////////////// +/** + * Draw all the lines in the buffer Cyan portal is the original geometry of + * the portal Yellow portal is the AA minmax & clipped portal Blue frustum is + * the frustum through portal White frustum is the camera frustum + */ void PortalClipper:: draw_lines() { if (!_list.empty()) { _created_data = NULL; - + PT(GeomVertexData) vdata = new GeomVertexData ("portal", GeomVertexFormat::get_v3cp(), Geom::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + PT(GeomLinestrips) lines = new GeomLinestrips(Geom::UH_static); PT(GeomPoints) points = new GeomPoints(Geom::UH_static); - + int v = 0; LineList::const_iterator ll; SegmentList::const_iterator sl; - + for (ll = _list.begin(); ll != _list.end(); ll++) { const SegmentList &segs = (*ll); - + if (segs.size() < 2) { // A segment of length 1 is just a point. for (sl = segs.begin(); sl != segs.end(); sl++) { @@ -186,10 +166,9 @@ draw_lines() { v++; } points->close_primitive(); - + } else { - // A segment of length 2 or more is a line segment or - // segments. + // A segment of length 2 or more is a line segment or segments. for (sl = segs.begin(); sl != segs.end(); sl++) { lines->add_vertex(v); vertex.add_data3((*sl)._point); @@ -212,31 +191,30 @@ draw_lines() { } } } -//////////////////////////////////////////////////////////////////// -// Function: PortalClipper::prepare the portal -// Access: Public -// Description: Given the portal draw the frustum with line segs -// for now. More functionalities coming up -//////////////////////////////////////////////////////////////////// +/** + * Given the portal draw the frustum with line segs for now. More + * functionalities coming up + */ bool PortalClipper:: prepare_portal(const NodePath &node_path) { // Get the Portal Node from this node_path PandaNode *node = node_path.node(); _portal_node = NULL; - if (node->is_of_type(PortalNode::get_class_type())) { + if (node->is_of_type(PortalNode::get_class_type())) { _portal_node = DCAST(PortalNode, node); } - // Get the geometry from the portal + // Get the geometry from the portal 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()); + // CPT(TransformState) ctransform = + // node_path.get_transform(_scene_setup->get_camera_path()); LMatrix4 cmat = ctransform->get_mat(); portal_cat.spam() << cmat << endl; - + LVertex temp[4]; temp[0] = _portal_node->get_vertex(0); temp[1] = _portal_node->get_vertex(1); @@ -248,7 +226,7 @@ prepare_portal(const NodePath &node_path) 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; temp[2] = temp[2]*cmat; @@ -266,9 +244,12 @@ prepare_portal(const NodePath &node_path) 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 intersecting the near plane or the 0 point are a weird case anyhow, therefore we don't reduce the frustum any further - // and just return true. In effect the portal doesn't reduce visibility but will draw everything in its out cell + // check if the portal intersects with the cameras 0 point (center of + // projection). In that case the portal will invert itself. portals + // intersecting the near plane or the 0 point are a weird case anyhow, + // therefore we don't reduce the frustum any further and just return true. + // In effect the portal doesn't reduce visibility but will draw everything + // in its out cell const Lens *lens = _scene_setup->get_lens(); LVector3 forward = LVector3::forward(lens->get_coordinate_system()); int forward_axis; @@ -288,7 +269,7 @@ prepare_portal(const NodePath &node_path) portal_cat.debug() << "portal intersects with center of projection.." << endl; return true; } - + // project portal points, so they are in the -1..1 range LPoint3 projected_coords[4]; lens->project(temp[0], projected_coords[0]); @@ -337,7 +318,7 @@ prepare_portal(const NodePath &node_path) lens->extrude(LPoint2(min_x, max_y), near_point[3], far_point[3]); // With these points, construct the new reduced frustum - _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]); portal_cat.debug() << *_reduced_frustum << endl; @@ -350,13 +331,13 @@ prepare_portal(const NodePath &node_path) // lets first add the clipped portal (in yellow) _color = LColor(1,1,0,1); - move_to((near_point[0]*0.99+far_point[0]*0.01)); // I choose a point in the middle between near and far.. could also be some other z value.. + move_to((near_point[0]*0.99+far_point[0]*0.01)); // I choose a point in the middle between near and far.. could also be some other z value.. draw_to((near_point[1]*0.99+far_point[1]*0.01)); draw_to((near_point[2]*0.99+far_point[2]*0.01)); draw_to((near_point[3]*0.99+far_point[3]*0.01)); draw_to((near_point[0]*0.99+far_point[0]*0.01)); - // ok, now lets add the original portal (in cyan) + // ok, now lets add the original portal (in cyan) _color = LColor(0,1,1,1); move_to(temp[0]); draw_to(temp[1]); @@ -367,4 +348,3 @@ prepare_portal(const NodePath &node_path) return true; } - diff --git a/panda/src/pgraph/portalClipper.h b/panda/src/pgraph/portalClipper.h index 4a2b15e264..a1c8f5b179 100644 --- a/panda/src/pgraph/portalClipper.h +++ b/panda/src/pgraph/portalClipper.h @@ -1,16 +1,15 @@ -// Filename: portalClipper.h -// Created by: masad (4May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalClipper.h + * @author masad + * @date 2004-05-04 + */ #ifndef PORTALCLIPPER_H #define PORTALCLIPPER_H @@ -41,14 +40,12 @@ class CullTraverserData; class CullableObject; class NodePath; -//////////////////////////////////////////////////////////////////// -// Class : PortalClipper -// Description : This object performs a depth-first traversal of the -// scene graph, with optional view-frustum culling, -// collecting CullState and searching for GeomNodes. -// Each renderable Geom encountered is passed along with -// its associated RenderState to the CullHandler object. -//////////////////////////////////////////////////////////////////// +/** + * This object performs a depth-first traversal of the scene graph, with + * optional view-frustum culling, collecting CullState and searching for + * GeomNodes. Each renderable Geom encountered is passed along with its + * associated RenderState to the CullHandler object. + */ class EXPCL_PANDA_PGRAPH PortalClipper : public TypedObject { public: PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup); @@ -59,7 +56,7 @@ public: INLINE bool is_whole_portal_in_view(const LMatrix4 &cmat); bool prepare_portal(const NodePath &node_path); - + void draw_lines(); INLINE void draw_camera_frustum(); void draw_hexahedron(BoundingHexahedron *frustum); @@ -74,9 +71,9 @@ public: INLINE BoundingHexahedron *get_reduced_frustum() const; INLINE void set_reduced_frustum(BoundingHexahedron *bh); - INLINE void get_reduced_viewport(LPoint2& min, LPoint2& max) const; + INLINE void get_reduced_viewport(LPoint2& min, LPoint2& max) const; INLINE void set_reduced_viewport(const LPoint2& min, const LPoint2& max); - INLINE const RenderState* get_clip_state() const; + INLINE const RenderState* get_clip_state() const; INLINE void set_clip_state(const RenderState* clip_state); public: @@ -124,8 +121,7 @@ private: PortalNode *_portal_node; // current working portal for dereference ease - //int _num_vert; - //LVertex _coords[4]; + // int _num_vert; LVertex _coords[4]; public: PT(GeomNode) _previous; @@ -135,6 +131,3 @@ public: #include "portalClipper.I" #endif - - - diff --git a/panda/src/pgraph/portalNode.I b/panda/src/pgraph/portalNode.I index c8798e1da3..3cfff7cfc1 100644 --- a/panda/src/pgraph/portalNode.I +++ b/panda/src/pgraph/portalNode.I @@ -1,106 +1,81 @@ -// Filename: portalNode.I -// Created by: masad (13May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalNode.I + * @author masad + * @date 2004-05-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_portal_mask -// Access: Published -// Description: Simultaneously sets both the "from" and "into" -// PortalMask values to the same thing. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously sets both the "from" and "into" PortalMask values to the + * same thing. + */ INLINE void PortalNode:: set_portal_mask(PortalMask mask) { set_from_portal_mask(mask); set_into_portal_mask(mask); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_from_portal_mask -// Access: Published -// Description: Sets the "from" PortalMask. In order for a -// portal to be detected from this object into -// another object, the intersection of this object's -// "from" mask and the other object's "into" mask must -// be nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "from" PortalMask. In order for a portal to be detected from this + * object into another object, the intersection of this object's "from" mask + * and the other object's "into" mask must be nonzero. + */ INLINE void PortalNode:: set_from_portal_mask(PortalMask mask) { _from_portal_mask = mask; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_into_portal_mask -// Access: Published -// Description: Sets the "into" PortalMask. In order for a -// portal to be detected from another object into -// this object, the intersection of the other object's -// "from" mask and this object's "into" mask must be -// nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Sets the "into" PortalMask. In order for a portal to be detected from + * another object into this object, the intersection of the other object's + * "from" mask and this object's "into" mask must be nonzero. + */ INLINE void PortalNode:: set_into_portal_mask(PortalMask mask) { _into_portal_mask = mask; // We mark the bound stale when this changes, not because the actual - // bounding volume changes, but rather because we piggyback the - // computing of the _net_portal_mask on the bounding volume. + // bounding volume changes, but rather because we piggyback the computing of + // the _net_portal_mask on the bounding volume. mark_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_from_portal_mask -// Access: Published -// Description: Returns the current "from" PortalMask. In order for -// a portal to be detected from this object into -// another object, the intersection of this object's -// "from" mask and the other object's "into" mask must -// be nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current "from" PortalMask. In order for a portal to be + * detected from this object into another object, the intersection of this + * object's "from" mask and the other object's "into" mask must be nonzero. + */ INLINE PortalMask PortalNode:: get_from_portal_mask() const { return _from_portal_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_into_portal_mask -// Access: Published -// Description: Returns the current "into" PortalMask. In order for -// a portal to be detected from another object into -// this object, the intersection of the other object's -// "from" mask and this object's "into" mask must be -// nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current "into" PortalMask. In order for a portal to be + * detected from another object into this object, the intersection of the + * other object's "from" mask and this object's "into" mask must be nonzero. + */ INLINE PortalMask PortalNode:: get_into_portal_mask() const { return _into_portal_mask; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_portal_geom -// Access: Published -// Description: Sets the state of the "portal geom" flag for this -// PortalNode. Normally, this is false; when this is -// set true, the PortalSolids in this node will test -// for portals with actual renderable geometry, in -// addition to whatever PortalSolids may be indicated -// by the from_portal_mask. -// -// Setting this to true causes this to test *all* -// GeomNodes for portals. It is an all-or-none -// thing; there is no way to portal with only some -// GeomNodes, as GeomNodes have no into_portal_mask. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the "portal geom" flag for this PortalNode. Normally, + * this is false; when this is set true, the PortalSolids in this node will + * test for portals with actual renderable geometry, in addition to whatever + * PortalSolids may be indicated by the from_portal_mask. + * + * Setting this to true causes this to test *all* GeomNodes for portals. It + * is an all-or-none thing; there is no way to portal with only some + * GeomNodes, as GeomNodes have no into_portal_mask. + */ INLINE void PortalNode:: set_portal_geom(bool flag) { if (flag) { @@ -110,101 +85,78 @@ set_portal_geom(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_portal_geom -// Access: Published -// Description: Returns the current state of the portal_geom flag. -// See set_portal_geom(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the portal_geom flag. See set_portal_geom(). + */ INLINE bool PortalNode:: get_portal_geom() const { return (_flags & F_portal_geom) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::clear_vertices -// Access: Published -// Description: Resets the vertices of the portal to the empty list. -//////////////////////////////////////////////////////////////////// +/** + * Resets the vertices of the portal to the empty list. + */ INLINE void PortalNode:: clear_vertices() { _vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::add_vertex -// Access: Published -// Description: Adds a new vertex to the portal polygon. The -// vertices should be defined in a counterclockwise -// orientation when viewing through the portal. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the portal polygon. The vertices should be defined in + * a counterclockwise orientation when viewing through the portal. + */ INLINE void PortalNode:: add_vertex(const LPoint3 &vertex) { _vertices.push_back(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_num_vertices -// Access: Published -// Description: Returns the number of vertices in the portal polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the portal polygon. + */ INLINE int PortalNode:: get_num_vertices() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_vertex -// Access: Published -// Description: Returns the nth vertex of the portal polygon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the portal polygon. + */ INLINE const LPoint3 &PortalNode:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices.size(), LPoint3::zero()); return _vertices[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_cell_in -// Access: Published -// Description: Sets the cell that this portal belongs to -//////////////////////////////////////////////////////////////////// +/** + * Sets the cell that this portal belongs to + */ INLINE void PortalNode::set_cell_in(const NodePath &cell) { _cell_in = cell; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_cell_in -// Access: Published -// Description: Sets the cell that this portal belongs to -//////////////////////////////////////////////////////////////////// +/** + * Sets the cell that this portal belongs to + */ INLINE NodePath PortalNode::get_cell_in() const { return _cell_in; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_cell_out -// Access: Published -// Description: Sets the cell that this portal leads out to -//////////////////////////////////////////////////////////////////// +/** + * Sets the cell that this portal leads out to + */ INLINE void PortalNode::set_cell_out(const NodePath &cell) { _cell_out = cell; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_cell_out -// Access: Published -// Description: Sets the cell that this portal leads out to -//////////////////////////////////////////////////////////////////// +/** + * Sets the cell that this portal leads out to + */ INLINE NodePath PortalNode::get_cell_out() const { return _cell_out; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_clip_plane -// Access: Published -// Description: this is set if the portal will clip against its -// left and right planes -//////////////////////////////////////////////////////////////////// +/** + * this is set if the portal will clip against its left and right planes + */ INLINE void PortalNode::set_clip_plane(bool value) { _clip_plane = value; if (_clip_plane) { @@ -212,67 +164,52 @@ INLINE void PortalNode::set_clip_plane(bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::is_clip_plane -// Access: Published -// Description: Is this portal clipping against its left-right planes -//////////////////////////////////////////////////////////////////// +/** + * Is this portal clipping against its left-right planes + */ INLINE bool PortalNode::is_clip_plane() { return _clip_plane; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_visible -// Access: Published -// Description: this is set if the portal is facing camera -//////////////////////////////////////////////////////////////////// +/** + * this is set if the portal is facing camera + */ INLINE void PortalNode::set_visible(bool value) { _visible = value; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::is_visible -// Access: Published -// Description: Is this portal facing the camera -//////////////////////////////////////////////////////////////////// +/** + * Is this portal facing the camera + */ INLINE bool PortalNode::is_visible() { return _visible; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_open -// Access: Published -// Description: Python sets this based on curent camera zone -//////////////////////////////////////////////////////////////////// +/** + * Python sets this based on curent camera zone + */ INLINE void PortalNode::set_open(bool value) { _open = value; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::is_open -// Access: Published -// Description: Is this portal open from current camera zone -//////////////////////////////////////////////////////////////////// +/** + * Is this portal open from current camera zone + */ INLINE bool PortalNode::is_open() { return _open; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::set_max_depth -// Access: Published -// Description: Set the maximum depth this portal will be visible at -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum depth this portal will be visible at + */ INLINE void PortalNode::set_max_depth(int value) { _max_depth = value; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_max_depth -// Access: Published -// Description: Returns the maximum depth this portal will be visible at -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum depth this portal will be visible at + */ INLINE int PortalNode::get_max_depth() { return _max_depth; } - diff --git a/panda/src/pgraph/portalNode.cxx b/panda/src/pgraph/portalNode.cxx index a18ec52bb5..d70eacd17e 100644 --- a/panda/src/pgraph/portalNode.cxx +++ b/panda/src/pgraph/portalNode.cxx @@ -1,16 +1,15 @@ -// Filename: portalNode.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalNode.cxx + * @author drose + * @date 2002-03-16 + */ #include "portalNode.h" @@ -34,14 +33,11 @@ TypeHandle PortalNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::Constructor -// Access: Public -// Description: Default constructor, just an empty node, no geo -// This is used to read portal from model. You can also -// use this from python to create an empty portal. Then -// you can set the vertices yourself, with addVertex. -//////////////////////////////////////////////////////////////////// +/** + * Default constructor, just an empty node, no geo This is used to read portal + * from model. You can also use this from python to create an empty portal. + * Then you can set the vertices yourself, with addVertex. + */ PortalNode:: PortalNode(const string &name) : PandaNode(name), @@ -57,12 +53,10 @@ PortalNode(const string &name) : _max_depth = 10; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::Constructor -// Access: Public -// Description: Create a default rectangle as portal. Use this -// to create an arbitrary portal and setup from Python -//////////////////////////////////////////////////////////////////// +/** + * Create a default rectangle as portal. Use this to create an arbitrary + * portal and setup from Python + */ PortalNode:: PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) : PandaNode(name), @@ -83,11 +77,9 @@ PortalNode(const string &name, LPoint3 pos, PN_stdfloat scale) : _max_depth = 10; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PortalNode:: PortalNode(const PortalNode ©) : PandaNode(copy), @@ -104,45 +96,35 @@ PortalNode(const PortalNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PortalNode:: ~PortalNode() { } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PortalNode:: make_copy() const { return new PortalNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::preserve_name -// Access: Public, Virtual -// Description: Returns true if the node's name has extrinsic meaning -// and must be preserved across a flatten operation, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node's name has extrinsic meaning and must be preserved + * across a flatten operation, false otherwise. + */ bool PortalNode:: preserve_name() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::enable_clipping_planes -// Access: Public, Virtual -// Description: initialize the clipping planes and renderstate -//////////////////////////////////////////////////////////////////// +/** + * initialize the clipping planes and renderstate + */ void PortalNode:: enable_clipping_planes() { _top_plane_node = new PlaneNode("top"); @@ -166,40 +148,32 @@ enable_clipping_planes() { _clip_state = RenderState::make(plane_attrib); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PortalNode:: xform(const LMatrix4 &mat) { nassertv(!mat.is_nan()); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::combine_with -// Access: Public, Virtual -// Description: Collapses this node with the other node, if possible, -// and returns a pointer to the combined node, or NULL -// if the two nodes cannot safely be combined. -// -// The return value may be this, other, or a new node -// altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two nodes and what the -// collapsed node should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this node with the other node, if possible, and returns a pointer + * to the combined node, or NULL if the two nodes cannot safely be combined. + * + * The return value may be this, other, or a new node altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two nodes + * and what the collapsed node should look like. + */ PandaNode *PortalNode:: combine_with(PandaNode *other) { if (is_exact_type(get_class_type()) && other->is_exact_type(get_class_type())) { - // Two PortalNodes can combine, but only if they have the same - // name, because the name is often meaningful. + // Two PortalNodes can combine, but only if they have the same name, + // because the name is often meaningful. PortalNode *cother = DCAST(PortalNode, other); if (get_name() == cother->get_name()) { return this; @@ -212,19 +186,15 @@ combine_with(PandaNode *other) { return PandaNode::combine_with(other); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform reduced frustum -// culling. Basically, once the scenegraph comes across -// a portal node, it calculates a CulltraverserData with -// which cell, this portal leads out to and the new -// frustum. Then it traverses that child -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform reduced + * frustum culling. Basically, once the scenegraph comes across a portal + * node, it calculates a CulltraverserData with which cell, this portal leads + * out to and the new frustum. Then it traverses that child + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PortalNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { Thread *current_thread = trav->get_current_thread(); @@ -237,7 +207,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { PT(GeometricBoundingVolume) vf = trav->get_view_frustum(); PT(BoundingVolume) reduced_frustum; - // remember old viewport and frustum, so we can restore them for the siblings. (it gets changed by the prepare_portal call) + // remember old viewport and frustum, so we can restore them for the + // siblings. (it gets changed by the prepare_portal call) LPoint2 old_reduced_viewport_min, old_reduced_viewport_max; portal_viewer->get_reduced_viewport(old_reduced_viewport_min, old_reduced_viewport_max); PT(BoundingHexahedron) old_bh = portal_viewer->get_reduced_frustum(); @@ -251,7 +222,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // The frustum is in camera space vf = DCAST(GeometricBoundingVolume, reduced_frustum); - // create a copy of this reduced frustum, we'll transform it from camera space to the cell_out space + // create a copy of this reduced frustum, we'll transform it from + // camera space to the cell_out space PT(BoundingHexahedron) new_bh = DCAST(BoundingHexahedron, vf->make_copy()); // Get the net trasform of the _cell_out as seen from the camera. @@ -265,7 +237,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // set clipping planes, if desired.. if (_clip_plane) { - // create a copy of this reduced frustum, we'll transform it from camera space to this portal node's space (because the clip planes are attached to this node) + // create a copy of this reduced frustum, we'll transform it from + // camera space to this portal node's space (because the clip planes + // are attached to this node) PT(BoundingHexahedron) temp_bh = DCAST(BoundingHexahedron, vf->make_copy()); CPT(TransformState) temp_frustum_transform = data._node_path.get_node_path().get_net_transform()->invert_compose(portal_viewer->_scene_setup->get_cull_center().get_net_transform()); @@ -297,7 +271,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { portal_cat.spam() << "own clip state " << *_clip_state << endl; portal_cat.spam() << "next state " << *next_state << endl; - // undo parent clip state and compose our new clip state ito the new state + // undo parent clip state and compose our new clip state ito the new + // state if (old_clip_state != NULL) { next_state = old_clip_state->invert_compose(next_state); portal_cat.spam() << "next state after removing parent state " << *next_state << endl; @@ -330,42 +305,32 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool PortalNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void PortalNode:: output(ostream &out) const { PandaNode::output(out); } +/** + * Draws the vertices of this portal rectangle to the screen with a line + */ /* -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::draw -// Access: Public -// Description: Draws the vertices of this portal rectangle to the -// screen with a line -//////////////////////////////////////////////////////////////////// void PortalNode:: draw() const { move_to(get_vertex(0)); @@ -375,14 +340,11 @@ draw() const { } */ -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void PortalNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -392,8 +354,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, PT(BoundingVolume) bound = new BoundingSphere; GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); - // Now actually compute the bounding volume by putting it around all - // of our vertices. + // Now actually compute the bounding volume by putting it around all of our + // vertices. const LPoint3 *vertices_begin = &_vertices[0]; const LPoint3 *vertices_end = vertices_begin + _vertices.size(); @@ -405,18 +367,15 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::get_last_pos_state -// Access: Protected -// Description: Returns a RenderState for rendering the ghosted -// portal rectangle that represents the previous frame's -// position, for those collision nodes that indicate a -// velocity. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the ghosted portal rectangle that + * represents the previous frame's position, for those collision nodes that + * indicate a velocity. + */ CPT(RenderState) PortalNode:: get_last_pos_state() { - // Once someone asks for this pointer, we hold its reference count - // and never free it. + // Once someone asks for this pointer, we hold its reference count and never + // free it. static CPT(RenderState) state = (const RenderState *)NULL; if (state == (const RenderState *)NULL) { state = RenderState::make @@ -428,23 +387,18 @@ get_last_pos_state() { } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// PortalNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type PortalNode. + */ void PortalNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PortalNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -457,13 +411,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int PortalNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); @@ -471,14 +422,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type PortalNode is encountered -// in the Bam file. It should create the PortalNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type PortalNode is encountered in the Bam file. It should create the + * PortalNode and extract its information from the file. + */ TypedWritable *PortalNode:: make_from_bam(const FactoryParams ¶ms) { PortalNode *node = new PortalNode(""); @@ -491,13 +439,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: PortalNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PortalNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PortalNode. + */ void PortalNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraph/portalNode.h b/panda/src/pgraph/portalNode.h index 3466ac6aee..b315b8abff 100644 --- a/panda/src/pgraph/portalNode.h +++ b/panda/src/pgraph/portalNode.h @@ -1,16 +1,15 @@ -// Filename: portalNode.h -// Created by: masad (13May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalNode.h + * @author masad + * @date 2004-05-13 + */ #ifndef PORTALNODE_H #define PORTALNODE_H @@ -23,14 +22,11 @@ #include "nodePath.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : PortalNode -// Description : A node in the scene graph that can hold a -// Portal Polygon, which is a rectangle. Other -// types of polygons are not supported for -// now. It also holds a PT(PandaNode) Cell that -// this portal is connected to -//////////////////////////////////////////////////////////////////// +/** + * A node in the scene graph that can hold a Portal Polygon, which is a + * rectangle. Other types of polygons are not supported for now. It also + * holds a PT(PandaNode) Cell that this portal is connected to + */ class EXPCL_PANDA_PGRAPH PortalNode : public PandaNode { PUBLISHED: PortalNode(const string &name); @@ -88,7 +84,7 @@ PUBLISHED: INLINE void set_open(bool value); INLINE bool is_open(); - // void draw () const; + // void draw () const; protected: virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, @@ -99,9 +95,8 @@ protected: private: CPT(RenderState) get_last_pos_state(); - // This data is not cycled, for now. We assume the collision - // traversal will take place in App only. Perhaps we will revisit - // this later. + // This data is not cycled, for now. We assume the collision traversal will + // take place in App only. Perhaps we will revisit this later. PortalMask _from_portal_mask; PortalMask _into_portal_mask; diff --git a/panda/src/pgraph/renderAttrib.I b/panda/src/pgraph/renderAttrib.I index 91ab7332a0..9e431d7d6a 100644 --- a/panda/src/pgraph/renderAttrib.I +++ b/panda/src/pgraph/renderAttrib.I @@ -1,70 +1,57 @@ -// Filename: renderAttrib.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttrib.I + * @author drose + * @date 2002-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::compose -// Access: Published -// Description: Returns a new RenderAttrib object that represents the -// composition of this attrib with the other attrib. In -// most cases, this is the same as the other attrib; a -// compose b produces b. Some kinds of attributes, like -// a TextureTransform, for instance, might produce a new -// result: a compose b produces c. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderAttrib object that represents the composition of this + * attrib with the other attrib. In most cases, this is the same as the other + * attrib; a compose b produces b. Some kinds of attributes, like a + * TextureTransform, for instance, might produce a new result: a compose b + * produces c. + */ INLINE CPT(RenderAttrib) RenderAttrib:: compose(const RenderAttrib *other) const { return compose_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::invert_compose -// Access: Published -// Description: Returns a new RenderAttrib object that represents the -// composition of the inverse of this attrib with the -// other attrib. In most cases, this is the same as the -// other attrib; !a compose b produces b. Some kinds of -// attributes, like a TextureTransform, for instance, -// might produce a new result: !a compose b produces c. -// -// This is similar to compose() except that the source -// attrib is inverted first. This is used to compute -// the relative attribute for one node as viewed from -// some other node, which is especially useful for -// transform-type attributes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderAttrib object that represents the composition of the + * inverse of this attrib with the other attrib. In most cases, this is the + * same as the other attrib; !a compose b produces b. Some kinds of + * attributes, like a TextureTransform, for instance, might produce a new + * result: !a compose b produces c. + * + * This is similar to compose() except that the source attrib is inverted + * first. This is used to compute the relative attribute for one node as + * viewed from some other node, which is especially useful for transform-type + * attributes. + */ INLINE CPT(RenderAttrib) RenderAttrib:: invert_compose(const RenderAttrib *other) const { return invert_compose_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::compare_to -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// RenderAttribs, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// This method is not needed outside of the RenderAttrib -// class because all equivalent RenderAttrib objects are -// guaranteed to share the same pointer; thus, a pointer -// comparison is always sufficient. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique RenderAttribs, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * This method is not needed outside of the RenderAttrib class because all + * equivalent RenderAttrib objects are guaranteed to share the same pointer; + * thus, a pointer comparison is always sufficient. + */ INLINE int RenderAttrib:: compare_to(const RenderAttrib &other) const { - // First, we compare the types; if they are of different types then - // they sort differently. + // First, we compare the types; if they are of different types then they + // sort differently. TypeHandle type = get_type(); TypeHandle other_type = other.get_type(); if (type != other_type) { @@ -75,61 +62,48 @@ compare_to(const RenderAttrib &other) const { return compare_to_impl(&other); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_hash -// Access: Published -// Description: Returns a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash value for phash_map. + */ INLINE size_t RenderAttrib:: get_hash() const { return _hash; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_unique -// Access: Published -// Description: Returns the pointer to the unique RenderAttrib in -// the cache that is equivalent to this one. This may -// be the same pointer as this object, or it may be a -// different pointer; but it will be an equivalent -// object, and it will be a shared pointer. This may be -// called from time to time to improve cache benefits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the unique RenderAttrib in the cache that is + * equivalent to this one. This may be the same pointer as this object, or it + * may be a different pointer; but it will be an equivalent object, and it + * will be a shared pointer. This may be called from time to time to improve + * cache benefits. + */ INLINE CPT(RenderAttrib) RenderAttrib:: get_unique() const { return return_unique((RenderAttrib *)this); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_auto_shader_attrib -// Access: Published -// Description: Returns the variant of this RenderAttrib that's most -// relevant for associating with an auto-generated -// shader. This should be a new RenderAttrib of the -// same type as this one, with any superfluous data set -// to neutral. Only the parts of the attrib that -// contribute to the shader should be reflected in the -// returned attrib. The idea is to associate the -// auto-generated shader with the most neutral form of -// all states, to allow it to be shared across as many -// RenderState objects as possible. -// -// If this RenderAttrib is completely irrelevant to the -// auto-shader, this should return NULL to indicate that -// the attrib won't be assocaited with the shader at -// all. In this case the attrib does not contribute to -// the shader meaningfully. -//////////////////////////////////////////////////////////////////// +/** + * Returns the variant of this RenderAttrib that's most relevant for + * associating with an auto-generated shader. This should be a new + * RenderAttrib of the same type as this one, with any superfluous data set to + * neutral. Only the parts of the attrib that contribute to the shader should + * be reflected in the returned attrib. The idea is to associate the auto- + * generated shader with the most neutral form of all states, to allow it to + * be shared across as many RenderState objects as possible. + * + * If this RenderAttrib is completely irrelevant to the auto-shader, this + * should return NULL to indicate that the attrib won't be assocaited with the + * shader at all. In this case the attrib does not contribute to the shader + * meaningfully. + */ INLINE CPT(RenderAttrib) RenderAttrib:: get_auto_shader_attrib(const RenderState *state) const { return get_auto_shader_attrib_impl(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::calc_hash -// Access: Published -// Description: Calculates a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a suitable hash value for phash_map. + */ INLINE void RenderAttrib:: calc_hash() { size_t hash = get_hash_impl(); @@ -138,13 +112,10 @@ calc_hash() { _hash = int_hash::add_hash(hash, get_type().get_index()); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::register_slot -// Access: Public, Static -// Description: Adds the indicated TypeHandle to the registry, if it -// is not there already, and returns a unique slot -// number. See RenderAttribRegistry. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated TypeHandle to the registry, if it is not there already, + * and returns a unique slot number. See RenderAttribRegistry. + */ INLINE int RenderAttrib:: register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr(); diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index c7397d0429..334898a510 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: renderAttrib.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttrib.cxx + * @author drose + * @date 2002-02-21 + */ #include "renderAttrib.h" #include "bamReader.h" @@ -27,11 +26,9 @@ int RenderAttrib::_garbage_index = 0; PStatCollector RenderAttrib::_garbage_collect_pcollector("*:State Cache:Garbage Collect"); -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RenderAttrib:: RenderAttrib() { if (_attribs == (Attribs *)NULL) { @@ -40,32 +37,26 @@ RenderAttrib() { _saved_entry = -1; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::Copy Constructor -// Access: Private -// Description: RenderAttribs are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderAttribs are not meant to be copied. + */ RenderAttrib:: RenderAttrib(const RenderAttrib &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::Copy Assignment Operator -// Access: Private -// Description: RenderAttribs are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderAttribs are not meant to be copied. + */ void RenderAttrib:: operator = (const RenderAttrib &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::Destructor -// Access: Public, Virtual -// Description: The destructor is responsible for removing the -// RenderAttrib from the global set if it is there. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the RenderAttrib from the global + * set if it is there. + */ RenderAttrib:: ~RenderAttrib() { LightReMutexHolder holder(*_attribs_lock); @@ -74,103 +65,81 @@ RenderAttrib:: nassertv(_saved_entry == -1); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::lower_attrib_can_override -// Access: Public, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return false if a RenderAttrib on a -// higher node will compose into a RenderAttrib on a -// lower node that has a higher override value, or true -// if the lower RenderAttrib will completely replace the -// state. -// -// The default behavior is false: normally, a -// RenderAttrib in the graph cannot completely override -// a RenderAttrib above it, regardless of its override -// value--instead, the two attribs are composed. But -// for some kinds of RenderAttribs, it is useful to -// allow this kind of override. -// -// This method only handles the one special case of a -// lower RenderAttrib with a higher override value. If -// the higher RenderAttrib has a higher override value, -// it always completely overrides. And if both -// RenderAttribs have the same override value, they are -// always composed. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return false if a RenderAttrib on a higher node will compose + * into a RenderAttrib on a lower node that has a higher override value, or + * true if the lower RenderAttrib will completely replace the state. + * + * The default behavior is false: normally, a RenderAttrib in the graph cannot + * completely override a RenderAttrib above it, regardless of its override + * value--instead, the two attribs are composed. But for some kinds of + * RenderAttribs, it is useful to allow this kind of override. + * + * This method only handles the one special case of a lower RenderAttrib with + * a higher override value. If the higher RenderAttrib has a higher override + * value, it always completely overrides. And if both RenderAttribs have the + * same override value, they are always composed. + */ bool RenderAttrib:: lower_attrib_can_override() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + */ bool RenderAttrib:: has_cull_callback() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. -// -// This is called each time the RenderAttrib is -// discovered applied to a Geom in the traversal. It -// should return true if the Geom is visible, false if -// it should be omitted. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. + * + * This is called each time the RenderAttrib is discovered applied to a Geom + * in the traversal. It should return true if the Geom is visible, false if + * it should be omitted. + */ bool RenderAttrib:: cull_callback(CullTraverser *, const CullTraverserData &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) RenderAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::unref -// Access: Published, Virtual, Final -// Description: This method overrides ReferenceCount::unref() to -// clear the pointer from the global object pool when -// its reference count goes to zero. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to clear the pointer from the + * global object pool when its reference count goes to zero. + */ bool RenderAttrib:: unref() const { if (!state_cache || garbage_collect_states) { - // If we're not using the cache at all, or if we're relying on - // garbage collection, just allow the pointer to unref normally. + // If we're not using the cache at all, or if we're relying on garbage + // collection, just allow the pointer to unref normally. return ReferenceCount::unref(); } - // Here is the normal refcounting case, with a normal cache, and - // without garbage collection in effect. In this case we will pull - // the object out of the cache when its reference count goes to 0. + // Here is the normal refcounting case, with a normal cache, and without + // garbage collection in effect. In this case we will pull the object out + // of the cache when its reference count goes to 0. - // We always have to grab the lock, since we will definitely need to - // be holding it if we happen to drop the reference count to 0. - // Having to grab the lock at every call to unref() is a big - // limiting factor on parallelization. + // We always have to grab the lock, since we will definitely need to be + // holding it if we happen to drop the reference count to 0. Having to grab + // the lock at every call to unref() is a big limiting factor on + // parallelization. LightReMutexHolder holder(*_attribs_lock); if (ReferenceCount::unref()) { @@ -178,41 +147,34 @@ unref() const { return true; } - // The reference count has just reached zero. Make sure the object - // is removed from the global object pool, before anyone else finds - // it and tries to ref it. + // The reference count has just reached zero. Make sure the object is + // removed from the global object pool, before anyone else finds it and + // tries to ref it. ((RenderAttrib *)this)->release_new(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderAttrib:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderAttrib:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_num_attribs -// Access: Published, Static -// Description: Returns the total number of unique RenderAttrib -// objects allocated in the world. This will go up and -// down during normal operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique RenderAttrib objects allocated in the + * world. This will go up and down during normal operations. + */ int RenderAttrib:: get_num_attribs() { LightReMutexHolder holder(*_attribs_lock); @@ -223,13 +185,11 @@ get_num_attribs() { return _attribs->get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::list_attribs -// Access: Published, Static -// Description: Lists all of the RenderAttribs in the cache to the -// output stream, one per line. This can be quite a lot -// of output if the cache is large, so be prepared. -//////////////////////////////////////////////////////////////////// +/** + * Lists all of the RenderAttribs in the cache to the output stream, one per + * line. This can be quite a lot of output if the cache is large, so be + * prepared. + */ void RenderAttrib:: list_attribs(ostream &out) { LightReMutexHolder holder(*_attribs_lock); @@ -245,13 +205,10 @@ list_attribs(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::garbage_collect -// Access: Published, Static -// Description: Performs a garbage-collection cycle. This is called -// automatically from RenderState::garbage_collect(); -// see that method for more information. -//////////////////////////////////////////////////////////////////// +/** + * Performs a garbage-collection cycle. This is called automatically from + * RenderState::garbage_collect(); see that method for more information. + */ int RenderAttrib:: garbage_collect() { if (_attribs == (Attribs *)NULL || !garbage_collect_states) { @@ -280,12 +237,11 @@ garbage_collect() { ++num_elements; RenderAttrib *attrib = (RenderAttrib *)_attribs->get_key(si); if (attrib->get_ref_count() == 1) { - // This attrib has recently been unreffed to 1 (the one we - // added when we stored it in the cache). Now it's time to - // delete it. This is safe, because we're holding the - // _attribs_lock, so it's not possible for some other thread to - // find the attrib in the cache and ref it while we're doing - // this. + // This attrib has recently been unreffed to 1 (the one we added when + // we stored it in the cache). Now it's time to delete it. This is + // safe, because we're holding the _attribs_lock, so it's not possible + // for some other thread to find the attrib in the cache and ref it + // while we're doing this. attrib->release_new(); unref_delete(attrib); } @@ -300,14 +256,11 @@ garbage_collect() { return orig_size - new_size; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::validate_attribs -// Access: Published, Static -// Description: Ensures that the cache is still stored in sorted -// order. Returns true if so, false if there is a -// problem (which implies someone has modified one of -// the supposedly-const RenderAttrib objects). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the cache is still stored in sorted order. Returns true if + * so, false if there is a problem (which implies someone has modified one of + * the supposedly-const RenderAttrib objects). + */ bool RenderAttrib:: validate_attribs() { LightReMutexHolder holder(*_attribs_lock); @@ -373,17 +326,13 @@ validate_attribs() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::return_new -// Access: Protected, Static -// Description: This function is used by derived RenderAttrib types -// to share a common RenderAttrib pointer for all -// equivalent RenderAttrib objects. -// -// This is different from return_unique() in that it -// does not actually guarantee a unique pointer, unless -// uniquify-attribs is set. -//////////////////////////////////////////////////////////////////// +/** + * This function is used by derived RenderAttrib types to share a common + * RenderAttrib pointer for all equivalent RenderAttrib objects. + * + * This is different from return_unique() in that it does not actually + * guarantee a unique pointer, unless uniquify-attribs is set. + */ CPT(RenderAttrib) RenderAttrib:: return_new(RenderAttrib *attrib) { nassertr(attrib != (RenderAttrib *)NULL, attrib); @@ -395,20 +344,16 @@ return_new(RenderAttrib *attrib) { return return_unique(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::return_unique -// Access: Protected, Static -// Description: This function is used by derived RenderAttrib types -// to share a common RenderAttrib pointer for all -// equivalent RenderAttrib objects. -// -// The make() function of the derived type should create -// a new RenderAttrib and pass it through return_new(), -// which will either save the pointer and return it -// unchanged (if this is the first similar such object) -// or delete it and return an equivalent pointer (if -// there was already a similar object saved). -//////////////////////////////////////////////////////////////////// +/** + * This function is used by derived RenderAttrib types to share a common + * RenderAttrib pointer for all equivalent RenderAttrib objects. + * + * The make() function of the derived type should create a new RenderAttrib + * and pass it through return_new(), which will either save the pointer and + * return it unchanged (if this is the first similar such object) or delete it + * and return an equivalent pointer (if there was already a similar object + * saved). + */ CPT(RenderAttrib) RenderAttrib:: return_unique(RenderAttrib *attrib) { nassertr(attrib != (RenderAttrib *)NULL, attrib); @@ -428,16 +373,15 @@ return_unique(RenderAttrib *attrib) { LightReMutexHolder holder(*_attribs_lock); if (attrib->_saved_entry != -1) { - // This attrib is already in the cache. - //nassertr(_attribs->find(attrib) == attrib->_saved_entry, attrib); + // This attrib is already in the cache. nassertr(_attribs->find(attrib) + // == attrib->_saved_entry, attrib); return attrib; } int si = _attribs->find(attrib); if (si != -1) { - // There's an equivalent attrib already in the set. Return it. - // If this is a newly created RenderAttrib, though, be sure to - // delete it. + // There's an equivalent attrib already in the set. Return it. If this + // is a newly created RenderAttrib, though, be sure to delete it. if (attrib->get_ref_count() == 0) { delete attrib; } @@ -446,9 +390,9 @@ return_unique(RenderAttrib *attrib) { // Not already in the set; add it. if (garbage_collect_states) { - // If we'll be garbage collecting attribs explicitly, we'll - // increment the reference count when we store it in the cache, so - // that it won't be deleted while it's in it. + // If we'll be garbage collecting attribs explicitly, we'll increment the + // reference count when we store it in the cache, so that it won't be + // deleted while it's in it. attrib->ref(); } si = _attribs->store(attrib, Empty()); @@ -458,83 +402,63 @@ return_unique(RenderAttrib *attrib) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique number indicating whether -// this RenderAttrib is equivalent to the other one. -// -// This should return 0 if the two RenderAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two RenderAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * number indicating whether this RenderAttrib is equivalent to the other one. + * + * This should return 0 if the two RenderAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two RenderAttrib objects whose get_type() + * functions return the same. + */ int RenderAttrib:: compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t RenderAttrib:: get_hash_impl() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) RenderAttrib:: compose_impl(const RenderAttrib *other) const { return other; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) RenderAttrib:: invert_compose_impl(const RenderAttrib *other) const { return other; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::output_comparefunc -// Access: Protected -// Description: Outputs a string representation of the given -// PandaCompareFunc object. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a string representation of the given PandaCompareFunc object. + */ void RenderAttrib:: output_comparefunc(ostream &out, PandaCompareFunc fn) const { switch (fn) { @@ -576,120 +500,102 @@ output_comparefunc(ostream &out, PandaCompareFunc fn) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::release_new -// Access: Private -// Description: This inverse of return_new, this releases this object -// from the global RenderAttrib table. -// -// You must already be holding _attribs_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * This inverse of return_new, this releases this object from the global + * RenderAttrib table. + * + * You must already be holding _attribs_lock before you call this method. + */ void RenderAttrib:: release_new() { nassertv(_attribs_lock->debug_is_locked()); if (_saved_entry != -1) { - //nassertv(_attribs->find(this) == _saved_entry); + // nassertv(_attribs->find(this) == _saved_entry); _saved_entry = _attribs->find(this); _attribs->remove_element(_saved_entry); _saved_entry = -1; } } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::init_attribs -// Access: Public, Static -// Description: Make sure the global _attribs map is allocated. This -// only has to be done once. We could make this map -// static, but then we run into problems if anyone -// creates a RenderAttrib object at static init time; -// it also seems to cause problems when the Panda shared -// library is unloaded at application exit time. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the global _attribs map is allocated. This only has to be done + * once. We could make this map static, but then we run into problems if + * anyone creates a RenderAttrib object at static init time; it also seems to + * cause problems when the Panda shared library is unloaded at application + * exit time. + */ void RenderAttrib:: init_attribs() { _attribs = new Attribs; - // TODO: we should have a global Panda mutex to allow us to safely - // create _attribs_lock without a startup race condition. For the - // meantime, this is OK because we guarantee that this method is - // called at static init time, presumably when there is still only - // one thread in the world. + // TODO: we should have a global Panda mutex to allow us to safely create + // _attribs_lock without a startup race condition. For the meantime, this + // is OK because we guarantee that this method is called at static init + // time, presumably when there is still only one thread in the world. _attribs_lock = new LightReMutex("RenderAttrib::_attribs_lock"); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RenderAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::change_this -// Access: Public, Static -// Description: Called immediately after complete_pointers(), this -// gives the object a chance to adjust its own pointer -// if desired. Most objects don't change pointers after -// completion, but some need to. -// -// Once this function has been called, the old pointer -// will no longer be accessed. -//////////////////////////////////////////////////////////////////// +/** + * Called immediately after complete_pointers(), this gives the object a + * chance to adjust its own pointer if desired. Most objects don't change + * pointers after completion, but some need to. + * + * Once this function has been called, the old pointer will no longer be + * accessed. + */ TypedWritable *RenderAttrib:: change_this(TypedWritable *old_ptr, BamReader *manager) { // First, uniquify the pointer. RenderAttrib *attrib = DCAST(RenderAttrib, old_ptr); CPT(RenderAttrib) pointer = return_unique(attrib); - // But now we have a problem, since we have to hold the reference - // count and there's no way to return a TypedWritable while still - // holding the reference count! We work around this by explicitly - // upping the count, and also setting a finalize() callback to down - // it later. + // But now we have a problem, since we have to hold the reference count and + // there's no way to return a TypedWritable while still holding the + // reference count! We work around this by explicitly upping the count, and + // also setting a finalize() callback to down it later. if (pointer == attrib) { pointer->ref(); manager->register_finalize(attrib); } - // We have to cast the pointer back to non-const, because the bam - // reader expects that. + // We have to cast the pointer back to non-const, because the bam reader + // expects that. return (RenderAttrib *)pointer.p(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void RenderAttrib:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in change_this(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RenderAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RenderAttrib. + */ void RenderAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index 92386cba1e..12dd33b720 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -1,16 +1,15 @@ -// Filename: renderAttrib.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttrib.h + * @author drose + * @date 2002-02-21 + */ #ifndef RENDERATTRIB_H #define RENDERATTRIB_H @@ -30,33 +29,25 @@ class CullTraverser; class CullTraverserData; class RenderState; -//////////////////////////////////////////////////////////////////// -// Class : RenderAttrib -// Description : This is the base class for a number of render -// attributes (other than transform) that may be set on -// scene graph nodes to control the appearance of -// geometry. This includes TextureAttrib, ColorAttrib, -// etc. -// -// RenderAttrib represents render attributes that always -// propagate down to the leaves without regard to the -// particular node they are assigned to. A RenderAttrib -// will have the same effect on a leaf node whether it -// is assigned to the graph at the leaf or several nodes -// above. This is different from RenderEffect, which -// represents a particular render property that is -// applied immediately to the node on which it is -// encountered, like billboarding or decaling. -// -// You should not attempt to create or modify a -// RenderAttrib directly; instead, use the make() method -// of the appropriate kind of attrib you want. This -// will allocate and return a new RenderAttrib of the -// appropriate type, and it may share pointers if -// possible. Do not modify the new RenderAttrib if you -// wish to change its properties; instead, create a new -// one. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a number of render attributes (other than + * transform) that may be set on scene graph nodes to control the appearance + * of geometry. This includes TextureAttrib, ColorAttrib, etc. + * + * RenderAttrib represents render attributes that always propagate down to the + * leaves without regard to the particular node they are assigned to. A + * RenderAttrib will have the same effect on a leaf node whether it is + * assigned to the graph at the leaf or several nodes above. This is + * different from RenderEffect, which represents a particular render property + * that is applied immediately to the node on which it is encountered, like + * billboarding or decaling. + * + * You should not attempt to create or modify a RenderAttrib directly; + * instead, use the make() method of the appropriate kind of attrib you want. + * This will allocate and return a new RenderAttrib of the appropriate type, + * and it may share pointers if possible. Do not modify the new RenderAttrib + * if you wish to change its properties; instead, create a new one. + */ class EXPCL_PANDA_PGRAPH RenderAttrib : public TypedWritableReferenceCount { protected: RenderAttrib(); @@ -106,71 +97,67 @@ PUBLISHED: M_always // Always draw. }; - // This is the enumerated type for TexGenAttrib. It is inherited - // into TexGenAttrib. It is defined up at this level only to avoid - // circular dependencies in the header files. + // This is the enumerated type for TexGenAttrib. It is inherited into + // TexGenAttrib. It is defined up at this level only to avoid circular + // dependencies in the header files. enum TexGenMode { M_off, - // In the types below, "eye" means the coordinate space of the - // observing camera, and "world" means world coordinates, e.g. the - // coordinate space of the root of the graph. + // In the types below, "eye" means the coordinate space of the observing + // camera, and "world" means world coordinates, e.g. the coordinate space + // of the root of the graph. - // Sphere maps are classic static reflection maps. They are - // supported on just about any hardware, and require a precomputed - // 360-degree fisheye image. Sphere maps only make sense in eye - // coordinate space. + // Sphere maps are classic static reflection maps. They are supported on + // just about any hardware, and require a precomputed 360-degree fisheye + // image. Sphere maps only make sense in eye coordinate space. M_eye_sphere_map, - // Cube maps are a modern improvement on the sphere map; they - // don't suffer from any polar singularities, but they require six - // texture images. They can also be generated dynamically for - // real-time reflections (see GraphicsOutput::make_cube_map()). - // Typically, a statically-generated cube map will be in eye - // space, while a dynamically-generated map will be in world - // space. - // - // Cube mapping is not supported on all hardware. +/* + * Cube maps are a modern improvement on the sphere map; they don't suffer + * from any polar singularities, but they require six texture images. They + * can also be generated dynamically for real-time reflections (see + * GraphicsOutput::make_cube_map()). Typically, a statically-generated cube + * map will be in eye space, while a dynamically-generated map will be in + * world space. Cube mapping is not supported on all hardware. + */ M_world_cube_map, M_eye_cube_map, - // Normal maps are most useful for applying diffuse lighting - // effects via a pregenerated cube map. + // Normal maps are most useful for applying diffuse lighting effects via a + // pregenerated cube map. M_world_normal, M_eye_normal, - // Position maps convert XYZ coordinates directly to texture - // coordinates. This is particularly useful for implementing - // projective texturing (see NodePath::project_texture()). + // Position maps convert XYZ coordinates directly to texture coordinates. + // This is particularly useful for implementing projective texturing (see + // NodePath::project_texture()). M_world_position, M_unused, // formerly M_object_position, now deprecated. M_eye_position, - // With M_point_sprite, texture coordinates will be generated for - // large points in the range (0,0) - (1,1) from upper-left to - // lower-right across the point's face. Without this, each point - // will have just a single uniform texture coordinate value across - // its face. - // - // Unfortunately, the generated texture coordinates are inverted - // (upside-down) from Panda's usual convention, but this is what - // the graphics card manufacturers decided to use. You could use - // a texture matrix to re-invert the texture, but that will - // probably force the sprites' vertices to be computed in the CPU. - // You'll have to paint your textures upside-down if you want true - // hardware sprites. +/* + * With M_point_sprite, texture coordinates will be generated for large points + * in the range (0,0) - (1,1) from upper-left to lower-right across the + * point's face. Without this, each point will have just a single uniform + * texture coordinate value across its face. Unfortunately, the generated + * texture coordinates are inverted (upside-down) from Panda's usual + * convention, but this is what the graphics card manufacturers decided to + * use. You could use a texture matrix to re-invert the texture, but that + * will probably force the sprites' vertices to be computed in the CPU. You'll + * have to paint your textures upside-down if you want true hardware sprites. + */ M_point_sprite, // M_light_vector generated special 3-d texture coordinates that // represented the vector to a particular Light in the scene graph, - // expressed in each vertex's tangent space. This has now been - // removed. We need to reserve the slot in the enum, though, to - // make sure the following enum value still has the same value. + // expressed in each vertex's tangent space. This has now been removed. + // We need to reserve the slot in the enum, though, to make sure the + // following enum value still has the same value. M_unused2, - // M_constant generates the same fixed texture coordinates at each - // vertex. Not terribly useful, of course, except for certain - // special effects involving moving a flat color over an object. + // M_constant generates the same fixed texture coordinates at each vertex. + // Not terribly useful, of course, except for certain special effects + // involving moving a flat color over an object. M_constant, }; @@ -207,8 +194,8 @@ private: int _saved_entry; size_t _hash; - // This keeps track of our current position through the garbage - // collection cycle. + // This keeps track of our current position through the garbage collection + // cycle. static int _garbage_index; static PStatCollector _garbage_collect_pcollector; @@ -250,4 +237,3 @@ INLINE ostream &operator << (ostream &out, const RenderAttrib &attrib) { #include "renderAttrib.I" #endif - diff --git a/panda/src/pgraph/renderAttribRegistry.I b/panda/src/pgraph/renderAttribRegistry.I index ba41733000..1a807794a9 100644 --- a/panda/src/pgraph/renderAttribRegistry.I +++ b/panda/src/pgraph/renderAttribRegistry.I @@ -1,24 +1,20 @@ -// Filename: renderAttribRegistry.I -// Created by: drose (13Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttribRegistry.I + * @author drose + * @date 2008-11-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_slot -// Access: Published -// Description: Returns the slot number assigned to the indicated -// TypeHandle, or 0 if no slot number has been assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the slot number assigned to the indicated TypeHandle, or 0 if no + * slot number has been assigned. + */ INLINE int RenderAttribRegistry:: get_slot(TypeHandle type_handle) const { int type_index = type_handle.get_index(); @@ -28,101 +24,79 @@ get_slot(TypeHandle type_handle) const { return _slots_by_type[(size_t)type_index]; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_max_slots -// Access: Published, Static -// Description: Returns the maximum number that any slot number is -// allowed to grow. Actually, this number will be one -// higher than the highest possible slot number. This -// puts an upper bound on the number of RenderAttrib -// slots that may be allocated, and allows other code to -// define an array of slots. -// -// This number will not change during the lifetime of -// the application. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number that any slot number is allowed to grow. + * Actually, this number will be one higher than the highest possible slot + * number. This puts an upper bound on the number of RenderAttrib slots that + * may be allocated, and allows other code to define an array of slots. + * + * This number will not change during the lifetime of the application. + */ CONSTEXPR int RenderAttribRegistry:: get_max_slots() { return _max_slots; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_num_slots -// Access: Published -// Description: Returns the number of RenderAttrib slots that have -// been allocated. This is one more than the highest -// slot number in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of RenderAttrib slots that have been allocated. This is + * one more than the highest slot number in use. + */ INLINE int RenderAttribRegistry:: get_num_slots() const { return _registry.size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_slot_type -// Access: Published -// Description: Returns the TypeHandle associated with slot n. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle associated with slot n. + */ INLINE TypeHandle RenderAttribRegistry:: get_slot_type(int slot) const { nassertr(slot >= 0 && slot < (int)_registry.size(), TypeHandle::none()); return _registry[slot]._type; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_slot_sort -// Access: Published -// Description: Returns the sort number associated with slot n. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort number associated with slot n. + */ INLINE int RenderAttribRegistry:: get_slot_sort(int slot) const { nassertr(slot >= 0 && slot < (int)_registry.size(), 0); return _registry[slot]._sort; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_slot_default -// Access: Published -// Description: Returns the default RenderAttrib object associated -// with slot n. This is the attrib that should be -// applied in the absence of any other attrib of this -// type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default RenderAttrib object associated with slot n. This is + * the attrib that should be applied in the absence of any other attrib of + * this type. + */ INLINE const RenderAttrib *RenderAttribRegistry:: get_slot_default(int slot) const { nassertr(slot >= 0 && slot < (int)_registry.size(), 0); return _registry[slot]._default_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_num_sorted_slots -// Access: Published -// Description: Returns the number of entries in the sorted_slots -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the sorted_slots list. + */ INLINE int RenderAttribRegistry:: get_num_sorted_slots() const { return _sorted_slots.size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_sorted_slot -// Access: Published -// Description: Returns the nth slot in sorted order. By traversing -// this list, you will retrieve all the slot numbers in -// order according to their registered sort value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth slot in sorted order. By traversing this list, you will + * retrieve all the slot numbers in order according to their registered sort + * value. + */ INLINE int RenderAttribRegistry:: get_sorted_slot(int n) const { nassertr(n >= 0 && n < (int)_sorted_slots.size(), 0); return _sorted_slots[n]; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::get_global_ptr -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderAttribRegistry *RenderAttribRegistry:: get_global_ptr() { if (_global_ptr == (RenderAttribRegistry *)NULL) { @@ -131,43 +105,34 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::quick_get_global_ptr -// Access: Public, Static -// Description: Returns the global_ptr without first ensuring it has -// been initialized. Only safe for code that knows it -// has already been initialized. -//////////////////////////////////////////////////////////////////// +/** + * Returns the global_ptr without first ensuring it has been initialized. + * Only safe for code that knows it has already been initialized. + */ INLINE RenderAttribRegistry *RenderAttribRegistry:: quick_get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::SortSlots::Constructor -// Access: Public -// Description: This is an STL function object for sorting the -// _sorted_slots list into order by slot sort number. -//////////////////////////////////////////////////////////////////// +/** + * This is an STL function object for sorting the _sorted_slots list into + * order by slot sort number. + */ INLINE RenderAttribRegistry::SortSlots:: SortSlots(RenderAttribRegistry *reg) : _reg(reg) { } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::SortSlots::operator () -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool RenderAttribRegistry::SortSlots:: operator () (int a, int b) const { return _reg->get_slot_sort(a) < _reg->get_slot_sort(b); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::RegistryNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderAttribRegistry::RegistryNode:: RegistryNode(TypeHandle type, int sort, const RenderAttrib *default_attrib) : _type(type), diff --git a/panda/src/pgraph/renderAttribRegistry.cxx b/panda/src/pgraph/renderAttribRegistry.cxx index fc7f8d1076..cd011e838d 100644 --- a/panda/src/pgraph/renderAttribRegistry.cxx +++ b/panda/src/pgraph/renderAttribRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: renderAttribRegistry.cxx -// Created by: drose (13Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttribRegistry.cxx + * @author drose + * @date 2008-11-13 + */ #include "renderAttribRegistry.h" #include "renderAttrib.h" @@ -19,11 +18,9 @@ RenderAttribRegistry *RenderAttribRegistry::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RenderAttribRegistry:: RenderAttribRegistry() { _registry.reserve(_max_slots); @@ -34,46 +31,36 @@ RenderAttribRegistry() { _registry.push_back(RegistryNode(TypeHandle::none(), 0, NULL)); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::Destructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RenderAttribRegistry:: ~RenderAttribRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::register_slot -// Access: Public -// Description: Adds the indicated TypeHandle to the registry, if it -// is not there already, and returns a unique slot -// number in the range 0 < slot < get_max_slots(). -// -// The sort value is an arbitrary integer. In general, -// the RenderAttribs will be sorted in order from lowest -// sort value to highest sort value, when they are -// traversed via the get_num_sorted_slots() / -// get_sorted_slot() methods. This will be used to sort -// render states, so that heavier RenderAttribs are -// changed less frequently. In general, you should -// choose sort values such that the heavier -// RenderAttribs (that is, those which are more -// expensive to change) have lower sort values. -// -// The default_attrib pointer should be a newly -// created instance of this attribute that represents -// the default state for this attribute. -// -// register_slot() is intended to be called at -// application start for each different RenderAttrib -// type in the system, to assign a different integer -// slot number to each one. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated TypeHandle to the registry, if it is not there already, + * and returns a unique slot number in the range 0 < slot < get_max_slots(). + * + * The sort value is an arbitrary integer. In general, the RenderAttribs will + * be sorted in order from lowest sort value to highest sort value, when they + * are traversed via the get_num_sorted_slots() get_sorted_slot() methods. + * This will be used to sort render states, so that heavier RenderAttribs are + * changed less frequently. In general, you should choose sort values such + * that the heavier RenderAttribs (that is, those which are more expensive to + * change) have lower sort values. + * + * The default_attrib pointer should be a newly created instance of this + * attribute that represents the default state for this attribute. + * + * register_slot() is intended to be called at application start for each + * different RenderAttrib type in the system, to assign a different integer + * slot number to each one. + */ int RenderAttribRegistry:: register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { - // Sanity check; if this triggers, you either passed a wrong argument, - // or you didn't use the type system correctly. + // Sanity check; if this triggers, you either passed a wrong argument, or + // you didn't use the type system correctly. nassertr(default_attrib->get_type() == type_handle, 0); int type_index = type_handle.get_index(); @@ -95,10 +82,10 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { return 0; } - // Register the default attribute. We don't use return_unique and - // register it even if the state cache is disabled, because we can't read - // the state_cache config variable yet at this time. It probably doesn't - // hurt to have these 32 entries around in the attrib cache. + // Register the default attribute. We don't use return_unique and register + // it even if the state cache is disabled, because we can't read the + // state_cache config variable yet at this time. It probably doesn't hurt + // to have these 32 entries around in the attrib cache. if (default_attrib != (RenderAttrib *)NULL) { default_attrib->calc_hash(); @@ -123,11 +110,9 @@ register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib) { return slot; } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::set_slot_sort -// Access: Published -// Description: Changes the sort number associated with slot n. -//////////////////////////////////////////////////////////////////// +/** + * Changes the sort number associated with slot n. + */ void RenderAttribRegistry:: set_slot_sort(int slot, int sort) { nassertv(slot >= 0 && slot < (int)_registry.size()); @@ -141,11 +126,9 @@ set_slot_sort(int slot, int sort) { ::sort(_sorted_slots.begin(), _sorted_slots.end(), SortSlots(this)); } -//////////////////////////////////////////////////////////////////// -// Function: RenderAttribRegistry::init_global_ptr -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderAttribRegistry:: init_global_ptr() { _global_ptr = new RenderAttribRegistry; diff --git a/panda/src/pgraph/renderAttribRegistry.h b/panda/src/pgraph/renderAttribRegistry.h index 7c8f049ddb..9858192332 100644 --- a/panda/src/pgraph/renderAttribRegistry.h +++ b/panda/src/pgraph/renderAttribRegistry.h @@ -1,16 +1,15 @@ -// Filename: renderAttribRegistry.h -// Created by: drose (13Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderAttribRegistry.h + * @author drose + * @date 2008-11-13 + */ #ifndef RENDERATTRIBREGISTRY_H #define RENDERATTRIBREGISTRY_H @@ -24,13 +23,11 @@ class RenderAttrib; class DeletedBufferChain; -//////////////////////////////////////////////////////////////////// -// Class : RenderAttribRegistry -// Description : This class is used to associate each RenderAttrib -// with a different slot index at runtime, so we can -// store a list of RenderAttribs in the RenderState -// object, and very quickly look them up by type. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to associate each RenderAttrib with a different slot + * index at runtime, so we can store a list of RenderAttribs in the + * RenderState object, and very quickly look them up by type. + */ class EXPCL_PANDA_PGRAPH RenderAttribRegistry { private: RenderAttribRegistry(); @@ -39,13 +36,13 @@ private: public: typedef CPT(RenderAttrib) MakeDefaultFunc(); - // This typedef defines the native bitmask type for indicating which - // slots are present in a RenderState. It must be wide enough to - // allow room for all of the possible RenderAttribs that might - // register themselves. Presently, 32 bits is wide enough, but only - // barely; when we exceed this limit, we will need to go to a 64-bit - // type instead. It will be interesting to see whether a BitMask64 - // or a DoubleBitMask will be faster on a 32-bit machine. + // This typedef defines the native bitmask type for indicating which slots + // are present in a RenderState. It must be wide enough to allow room for + // all of the possible RenderAttribs that might register themselves. + // Presently, 32 bits is wide enough, but only barely; when we exceed this + // limit, we will need to go to a 64-bit type instead. It will be + // interesting to see whether a BitMask64 or a DoubleBitMask will + // be faster on a 32-bit machine. typedef BitMask32 SlotMask; // Raise this number whenever we add a new attrib. This used to be diff --git a/panda/src/pgraph/renderEffect.I b/panda/src/pgraph/renderEffect.I index f3bf83f172..9e9a74ecad 100644 --- a/panda/src/pgraph/renderEffect.I +++ b/panda/src/pgraph/renderEffect.I @@ -1,34 +1,28 @@ -// Filename: renderEffect.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffect.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::compare_to -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// RenderEffects, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// This method is not needed outside of the RenderEffect -// class because all equivalent RenderEffect objects are -// guaranteed to share the same pointer; thus, a pointer -// comparison is always sufficient. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique RenderEffects, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * This method is not needed outside of the RenderEffect class because all + * equivalent RenderEffect objects are guaranteed to share the same pointer; + * thus, a pointer comparison is always sufficient. + */ INLINE int RenderEffect:: compare_to(const RenderEffect &other) const { - // First, we compare the types; if they are of different types then - // they sort differently. + // First, we compare the types; if they are of different types then they + // sort differently. TypeHandle type = get_type(); TypeHandle other_type = other.get_type(); if (type != other_type) { diff --git a/panda/src/pgraph/renderEffect.cxx b/panda/src/pgraph/renderEffect.cxx index 314c156c52..ceada3a109 100644 --- a/panda/src/pgraph/renderEffect.cxx +++ b/panda/src/pgraph/renderEffect.cxx @@ -1,16 +1,15 @@ -// Filename: renderEffect.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffect.cxx + * @author drose + * @date 2002-03-14 + */ #include "renderEffect.h" #include "bamReader.h" @@ -20,212 +19,170 @@ RenderEffect::Effects *RenderEffect::_effects = NULL; TypeHandle RenderEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RenderEffect:: RenderEffect() { if (_effects == (Effects *)NULL) { - // Make sure the global _effects map is allocated. This only has - // to be done once. We could make this map static, but then we - // run into problems if anyone creates a RenderState object at - // static init time; it also seems to cause problems when the - // Panda shared library is unloaded at application exit time. + // Make sure the global _effects map is allocated. This only has to be + // done once. We could make this map static, but then we run into + // problems if anyone creates a RenderState object at static init time; it + // also seems to cause problems when the Panda shared library is unloaded + // at application exit time. _effects = new Effects; } _saved_entry = _effects->end(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::Copy Constructor -// Access: Private -// Description: RenderEffects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderEffects are not meant to be copied. + */ RenderEffect:: RenderEffect(const RenderEffect &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::Copy Assignment Operator -// Access: Private -// Description: RenderEffects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderEffects are not meant to be copied. + */ void RenderEffect:: operator = (const RenderEffect &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::Destructor -// Access: Public, Virtual -// Description: The destructor is responsible for removing the -// RenderEffect from the global set if it is there. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the RenderEffect from the global + * set if it is there. + */ RenderEffect:: ~RenderEffect() { if (_saved_entry != _effects->end()) { - // We cannot make this assertion, because the RenderEffect has - // already partially destructed--this means we cannot look up the - // object in the map. In fact, the map is temporarily invalid - // until we finish destructing, since we screwed up the ordering - // when we changed the return value of get_type(). - // nassertv(_effects->find(this) == _saved_entry); + // We cannot make this assertion, because the RenderEffect has already + // partially destructed--this means we cannot look up the object in the + // map. In fact, the map is temporarily invalid until we finish + // destructing, since we screwed up the ordering when we changed the + // return value of get_type(). nassertv(_effects->find(this) == + // _saved_entry); - // Note: this isn't thread-safe, because once the derived class - // destructor exits and before this destructor completes, the map - // is invalid, and other threads may inadvertently attempt to read - // the invalid map. To make it thread-safe, we need to move this - // functionality to a separate method, that is to be called from - // *each* derived class's destructor (and then we can put the - // above assert back in). + // Note: this isn't thread-safe, because once the derived class destructor + // exits and before this destructor completes, the map is invalid, and + // other threads may inadvertently attempt to read the invalid map. To + // make it thread-safe, we need to move this functionality to a separate + // method, that is to be called from *each* derived class's destructor + // (and then we can put the above assert back in). _effects->erase(_saved_entry); _saved_entry = _effects->end(); } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::safe_to_transform -// Access: Public, Virtual -// Description: Returns true if it is generally safe to transform -// this particular kind of RenderEffect by calling the -// xform() method, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to transform this particular kind of + * RenderEffect by calling the xform() method, false otherwise. + */ bool RenderEffect:: safe_to_transform() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::prepare_flatten_transform -// Access: Public, Virtual -// Description: Preprocesses the accumulated transform that is about -// to be applied to (or through) this node due to a -// flatten operation. The returned value will be used -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Preprocesses the accumulated transform that is about to be applied to (or + * through) this node due to a flatten operation. The returned value will be + * used instead. + */ CPT(TransformState) RenderEffect:: prepare_flatten_transform(const TransformState *net_transform) const { return net_transform; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if this kind of effect can safely be -// combined with sibling nodes that share the exact same -// effect, or false if this is not a good idea. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of effect can safely be combined with sibling + * nodes that share the exact same effect, or false if this is not a good + * idea. + */ bool RenderEffect:: safe_to_combine() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::xform -// Access: Public, Virtual -// Description: Returns a new RenderEffect transformed by the -// indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderEffect transformed by the indicated matrix. + */ CPT(RenderEffect) RenderEffect:: xform(const LMatrix4 &) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool RenderEffect:: has_cull_callback() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void RenderEffect:: cull_callback(CullTraverser *, CullTraverserData &, CPT(TransformState) &, CPT(RenderState) &) const { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::has_adjust_transform -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if adjust_transform() has been defined, and -// therefore the RenderEffect has some effect on the -// node's apparent local and net transforms. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if + * adjust_transform() has been defined, and therefore the RenderEffect has + * some effect on the node's apparent local and net transforms. + */ bool RenderEffect:: has_adjust_transform() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::adjust_transform -// Access: Public, Virtual -// Description: Performs some operation on the node's apparent net -// and/or local transforms. This will only be called if -// has_adjust_transform() is redefined to return true. -// -// Both parameters are in/out. The original transforms -// will be passed in, and they may (or may not) be -// modified in-place by the RenderEffect. -//////////////////////////////////////////////////////////////////// +/** + * Performs some operation on the node's apparent net and/or local transforms. + * This will only be called if has_adjust_transform() is redefined to return + * true. + * + * Both parameters are in/out. The original transforms will be passed in, and + * they may (or may not) be modified in-place by the RenderEffect. + */ void RenderEffect:: adjust_transform(CPT(TransformState) &, CPT(TransformState) &, PandaNode *) const { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderEffect:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderEffect:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::get_num_effects -// Access: Published, Static -// Description: Returns the total number of unique RenderEffect -// objects allocated in the world. This will go up and -// down during normal operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique RenderEffect objects allocated in the + * world. This will go up and down during normal operations. + */ int RenderEffect:: get_num_effects() { if (_effects == (Effects *)NULL) { @@ -234,13 +191,11 @@ get_num_effects() { return _effects->size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::list_effects -// Access: Published, Static -// Description: Lists all of the RenderEffects in the cache to the -// output stream, one per line. This can be quite a lot -// of output if the cache is large, so be prepared. -//////////////////////////////////////////////////////////////////// +/** + * Lists all of the RenderEffects in the cache to the output stream, one per + * line. This can be quite a lot of output if the cache is large, so be + * prepared. + */ void RenderEffect:: list_effects(ostream &out) { out << _effects->size() << " effects:\n"; @@ -251,14 +206,11 @@ list_effects(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::validate_effects -// Access: Published, Static -// Description: Ensures that the cache is still stored in sorted -// order. Returns true if so, false if there is a -// problem (which implies someone has modified one of -// the supposedly-const RenderEffect objects). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the cache is still stored in sorted order. Returns true if + * so, false if there is a problem (which implies someone has modified one of + * the supposedly-const RenderEffect objects). + */ bool RenderEffect:: validate_effects() { if (_effects->empty()) { @@ -283,26 +235,22 @@ validate_effects() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::return_new -// Access: Protected, Static -// Description: This function is used by derived RenderEffect types -// to share a common RenderEffect pointer for all -// equivalent RenderEffect objects. -// -// The make() function of the derived type should create -// a new RenderEffect and pass it through return_new(), -// which will either save the pointer and return it -// unchanged (if this is the first similar such object) -// or delete it and return an equivalent pointer (if -// there was already a similar object saved). -//////////////////////////////////////////////////////////////////// +/** + * This function is used by derived RenderEffect types to share a common + * RenderEffect pointer for all equivalent RenderEffect objects. + * + * The make() function of the derived type should create a new RenderEffect + * and pass it through return_new(), which will either save the pointer and + * return it unchanged (if this is the first similar such object) or delete it + * and return an equivalent pointer (if there was already a similar object + * saved). + */ CPT(RenderEffect) RenderEffect:: return_new(RenderEffect *effect) { nassertr(effect != (RenderEffect *)NULL, effect); - // This should be a newly allocated pointer, not one that was used - // for anything else. + // This should be a newly allocated pointer, not one that was used for + // anything else. nassertr(effect->_saved_entry == _effects->end(), effect); #ifndef NDEBUG @@ -311,113 +259,97 @@ return_new(RenderEffect *effect) { } #endif - // Save the effect in a local PointerTo so that it will be freed at - // the end of this function if no one else uses it. + // Save the effect in a local PointerTo so that it will be freed at the end + // of this function if no one else uses it. CPT(RenderEffect) pt_effect = effect; pair result = _effects->insert(effect); if (result.second) { - // The effect was inserted; save the iterator and return the - // input effect. + // The effect was inserted; save the iterator and return the input effect. effect->_saved_entry = result.first; return pt_effect; } - // The effect was not inserted; there must be an equivalent one - // already in the set. Return that one. + // The effect was not inserted; there must be an equivalent one already in + // the set. Return that one. return *(result.first); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderEffect -// types to return a unique number indicating whether -// this RenderEffect is equivalent to the other one. -// -// This should return 0 if the two RenderEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two RenderEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderEffect types to return a unique + * number indicating whether this RenderEffect is equivalent to the other one. + * + * This should return 0 if the two RenderEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two RenderEffect objects whose get_type() + * functions return the same. + */ int RenderEffect:: compare_to_impl(const RenderEffect *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RenderEffect:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::change_this -// Access: Public, Static -// Description: Called immediately after complete_pointers(), this -// gives the object a chance to adjust its own pointer -// if desired. Most objects don't change pointers after -// completion, but some need to. -// -// Once this function has been called, the old pointer -// will no longer be accessed. -//////////////////////////////////////////////////////////////////// +/** + * Called immediately after complete_pointers(), this gives the object a + * chance to adjust its own pointer if desired. Most objects don't change + * pointers after completion, but some need to. + * + * Once this function has been called, the old pointer will no longer be + * accessed. + */ TypedWritable *RenderEffect:: change_this(TypedWritable *old_ptr, BamReader *manager) { // First, uniquify the pointer. RenderEffect *effect = DCAST(RenderEffect, old_ptr); CPT(RenderEffect) pointer = return_new(effect); - // But now we have a problem, since we have to hold the reference - // count and there's no way to return a TypedWritable while still - // holding the reference count! We work around this by explicitly - // upping the count, and also setting a finalize() callback to down - // it later. + // But now we have a problem, since we have to hold the reference count and + // there's no way to return a TypedWritable while still holding the + // reference count! We work around this by explicitly upping the count, and + // also setting a finalize() callback to down it later. if (pointer == effect) { pointer->ref(); manager->register_finalize(effect); } - - // We have to cast the pointer back to non-const, because the bam - // reader expects that. + + // We have to cast the pointer back to non-const, because the bam reader + // expects that. return (RenderEffect *)pointer.p(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void RenderEffect:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in change_this(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RenderEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RenderEffect. + */ void RenderEffect:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/pgraph/renderEffect.h b/panda/src/pgraph/renderEffect.h index 796ae49008..f8a55de869 100644 --- a/panda/src/pgraph/renderEffect.h +++ b/panda/src/pgraph/renderEffect.h @@ -1,16 +1,15 @@ -// Filename: renderEffect.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffect.h + * @author drose + * @date 2002-03-14 + */ #ifndef RENDEREFFECT_H #define RENDEREFFECT_H @@ -29,30 +28,23 @@ class CullTraverser; class CullTraverserData; class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : RenderEffect -// Description : This is the base class for a number of special render -// effects that may be set on scene graph nodes to -// change the way they render. This includes -// BillboardEffect, DecalEffect, etc. -// -// RenderEffect represents render properties that must -// be applied as soon as they are encountered in the -// scene graph, rather than propagating down to the -// leaves. This is different from RenderAttrib, which -// represents properties like color and texture that -// don't do anything until they propagate down to a -// GeomNode. -// -// You should not attempt to create or modify a -// RenderEffect directly; instead, use the make() method -// of the appropriate kind of effect you want. This -// will allocate and return a new RenderEffect of the -// appropriate type, and it may share pointers if -// possible. Do not modify the new RenderEffect if you -// wish to change its properties; instead, create a new -// one. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a number of special render effects that may be + * set on scene graph nodes to change the way they render. This includes + * BillboardEffect, DecalEffect, etc. + * + * RenderEffect represents render properties that must be applied as soon as + * they are encountered in the scene graph, rather than propagating down to + * the leaves. This is different from RenderAttrib, which represents + * properties like color and texture that don't do anything until they + * propagate down to a GeomNode. + * + * You should not attempt to create or modify a RenderEffect directly; + * instead, use the make() method of the appropriate kind of effect you want. + * This will allocate and return a new RenderEffect of the appropriate type, + * and it may share pointers if possible. Do not modify the new RenderEffect + * if you wish to change its properties; instead, create a new one. + */ class EXPCL_PANDA_PGRAPH RenderEffect : public TypedWritableReferenceCount { protected: RenderEffect(); @@ -107,7 +99,7 @@ public: protected: static TypedWritable *new_from_bam(RenderEffect *effect, BamReader *manager); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -134,4 +126,3 @@ INLINE ostream &operator << (ostream &out, const RenderEffect &effect) { #include "renderEffect.I" #endif - diff --git a/panda/src/pgraph/renderEffects.I b/panda/src/pgraph/renderEffects.I index c78b4ea333..ff42b4ff49 100644 --- a/panda/src/pgraph/renderEffects.I +++ b/panda/src/pgraph/renderEffects.I @@ -1,23 +1,19 @@ -// Filename: renderEffects.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffects.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderEffects::Effect:: Effect(const RenderEffect *effect) : _type(effect->get_type()), @@ -25,25 +21,19 @@ Effect(const RenderEffect *effect) : { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::Constructor -// Access: Public -// Description: This constructor is only used when reading the -// RenderEffects from a bam file. At this point, the -// effect pointer is unknown. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is only used when reading the RenderEffects from a bam + * file. At this point, the effect pointer is unknown. + */ INLINE RenderEffects::Effect:: Effect() { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::Constructor -// Access: Public -// Description: This constructor makes an invalid Effect with no -// RenderEffect pointer; its purpose is just to make an -// object we can use to look up a particular type in the -// Effect set. -//////////////////////////////////////////////////////////////////// +/** + * This constructor makes an invalid Effect with no RenderEffect pointer; its + * purpose is just to make an object we can use to look up a particular type + * in the Effect set. + */ INLINE RenderEffects::Effect:: Effect(TypeHandle type) : _type(type), @@ -51,11 +41,9 @@ Effect(TypeHandle type) : { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderEffects::Effect:: Effect(const Effect ©) : _type(copy._type), @@ -63,40 +51,31 @@ Effect(const Effect ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RenderEffects::Effect:: operator = (const Effect ©) { _type = copy._type; _effect = copy._effect; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::operator < -// Access: Public -// Description: This is used by the Effects set to uniquify -// RenderEffects by type. Only one RenderEffect of a -// given type is allowed in the set. This ordering must -// also match the ordering reported by compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * This is used by the Effects set to uniquify RenderEffects by type. Only + * one RenderEffect of a given type is allowed in the set. This ordering must + * also match the ordering reported by compare_to(). + */ INLINE bool RenderEffects::Effect:: operator < (const Effect &other) const { return _type < other._type; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Effect::compare_to -// Access: Public -// Description: Provides an indication of whether a particular -// effect is equivalent to another one, for purposes -// of generating unique RenderEffects. This should -// compare all properties of the Effect, but it is -// important that the type is compared first, to be -// consistent with the ordering defined by operator <. -//////////////////////////////////////////////////////////////////// +/** + * Provides an indication of whether a particular effect is equivalent to + * another one, for purposes of generating unique RenderEffects. This should + * compare all properties of the Effect, but it is important that the type is + * compared first, to be consistent with the ordering defined by operator <. + */ INLINE int RenderEffects::Effect:: compare_to(const Effect &other) const { if (_type != other._type) { @@ -108,49 +87,38 @@ compare_to(const Effect &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::is_empty -// Access: Published -// Description: Returns true if the state is empty, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state is empty, false otherwise. + */ INLINE bool RenderEffects:: is_empty() const { return _effects.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::get_num_effects -// Access: Published -// Description: Returns the number of separate effects indicated -// in the state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of separate effects indicated in the state. + */ INLINE int RenderEffects:: get_num_effects() const { return _effects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::get_effect -// Access: Published -// Description: Returns the nth effect in the state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth effect in the state. + */ INLINE const RenderEffect *RenderEffects:: get_effect(int n) const { nassertr(n >= 0 && n < (int)_effects.size(), NULL); return _effects[n]._effect; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::has_decal -// Access: Public -// Description: This function is provided as an optimization, to -// speed up the render-time checking for the existance -// of a DecalEffect on this state. It returns true if a -// DecalEffect exists, false otherwise. Note that since -// there is no additional information stored on the -// DecalEffect, there's no point in returning it if it -// exists. -//////////////////////////////////////////////////////////////////// +/** + * This function is provided as an optimization, to speed up the render-time + * checking for the existance of a DecalEffect on this state. It returns true + * if a DecalEffect exists, false otherwise. Note that since there is no + * additional information stored on the DecalEffect, there's no point in + * returning it if it exists. + */ INLINE bool RenderEffects:: has_decal() const { if ((_flags & F_checked_decal) == 0) { @@ -161,17 +129,13 @@ has_decal() const { return ((_flags & F_has_decal) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::has_show_bounds -// Access: Public -// Description: This function is provided as an optimization, to -// speed up the render-time checking for the existance -// of a ShowBoundsEffect on this state. It returns true -// if a ShowBoundsEffect exists, false otherwise. Note -// that since there is no additional information stored -// on the ShowBoundsEffect, there's no point in -// returning it if it exists. -//////////////////////////////////////////////////////////////////// +/** + * This function is provided as an optimization, to speed up the render-time + * checking for the existance of a ShowBoundsEffect on this state. It returns + * true if a ShowBoundsEffect exists, false otherwise. Note that since there + * is no additional information stored on the ShowBoundsEffect, there's no + * point in returning it if it exists. + */ INLINE bool RenderEffects:: has_show_bounds() const { if ((_flags & F_checked_show_bounds) == 0) { @@ -182,13 +146,10 @@ has_show_bounds() const { return ((_flags & F_has_show_bounds) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::has_show_tight_bounds -// Access: Public -// Description: If has_show_bounds() returns true, this will return -// true if the ShowBoundsEffect in question requests -// showing a "tight" bound. -//////////////////////////////////////////////////////////////////// +/** + * If has_show_bounds() returns true, this will return true if the + * ShowBoundsEffect in question requests showing a "tight" bound. + */ INLINE bool RenderEffects:: has_show_tight_bounds() const { if ((_flags & F_checked_show_bounds) == 0) { @@ -199,13 +160,10 @@ has_show_tight_bounds() const { return ((_flags & F_has_show_tight_bounds) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::has_cull_callback -// Access: Public -// Description: This function is provided as an optimization, to -// speed up the render-time checking for the existance -// of an effect with a cull_callback on this state. -//////////////////////////////////////////////////////////////////// +/** + * This function is provided as an optimization, to speed up the render-time + * checking for the existance of an effect with a cull_callback on this state. + */ INLINE bool RenderEffects:: has_cull_callback() const { if ((_flags & F_checked_cull_callback) == 0) { @@ -216,14 +174,11 @@ has_cull_callback() const { return ((_flags & F_has_cull_callback) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::has_adjust_transform -// Access: Public -// Description: This function is provided as an optimization, to -// speed up the render-time checking for the existance -// of an effect with a compute_adjust_transform on this -// state. -//////////////////////////////////////////////////////////////////// +/** + * This function is provided as an optimization, to speed up the render-time + * checking for the existance of an effect with a compute_adjust_transform on + * this state. + */ INLINE bool RenderEffects:: has_adjust_transform() const { if ((_flags & F_checked_adjust_transform) == 0) { diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 7d7872ebfb..077c496e04 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -1,16 +1,15 @@ -// Filename: renderEffects.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffects.cxx + * @author drose + * @date 2002-03-14 + */ #include "renderEffects.h" #include "billboardEffect.h" @@ -35,13 +34,11 @@ RenderEffects::States *RenderEffects::_states = NULL; CPT(RenderEffects) RenderEffects::_empty_state; TypeHandle RenderEffects::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Constructor -// Access: Protected -// Description: Actually, this could be a private constructor, since -// no one inherits from RenderEffects, but gcc gives us a -// spurious warning if all constructors are private. -//////////////////////////////////////////////////////////////////// +/** + * Actually, this could be a private constructor, since no one inherits from + * RenderEffects, but gcc gives us a spurious warning if all constructors are + * private. + */ RenderEffects:: RenderEffects() : _lock("RenderEffects") { if (_states == (States *)NULL) { @@ -51,32 +48,26 @@ RenderEffects() : _lock("RenderEffects") { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Copy Constructor -// Access: Private -// Description: RenderEffects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderEffects are not meant to be copied. + */ RenderEffects:: RenderEffects(const RenderEffects &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Copy Assignment Operator -// Access: Private -// Description: RenderEffects are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderEffects are not meant to be copied. + */ void RenderEffects:: operator = (const RenderEffects &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::Destructor -// Access: Public, Virtual -// Description: The destructor is responsible for removing the -// RenderEffects from the global set if it is there. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the RenderEffects from the + * global set if it is there. + */ RenderEffects:: ~RenderEffects() { // Remove the deleted RenderEffects object from the global pool. @@ -86,13 +77,10 @@ RenderEffects:: nassertv(_saved_entry == _states->end()); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::safe_to_transform -// Access: Public -// Description: Returns true if all of the effects in this set can -// safely be transformed, and therefore the complete set -// can be transformed, by calling xform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the effects in this set can safely be transformed, + * and therefore the complete set can be transformed, by calling xform(). + */ bool RenderEffects:: safe_to_transform() const { Effects::const_iterator ai; @@ -106,14 +94,11 @@ safe_to_transform() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::prepare_flatten_transform -// Access: Public, Virtual -// Description: Preprocesses the accumulated transform that is about -// to be applied to (or through) this node due to a -// flatten operation. The returned value will be used -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Preprocesses the accumulated transform that is about to be applied to (or + * through) this node due to a flatten operation. The returned value will be + * used instead. + */ CPT(TransformState) RenderEffects:: prepare_flatten_transform(const TransformState *net_transform) const { CPT(TransformState) result = net_transform; @@ -126,14 +111,11 @@ prepare_flatten_transform(const TransformState *net_transform) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::safe_to_combine -// Access: Public -// Description: Returns true if all of the effects in this set can -// safely be shared with a sibling node that has the -// exact same set of effects, or false if this would be -// bad for any of the effects. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the effects in this set can safely be shared with a + * sibling node that has the exact same set of effects, or false if this would + * be bad for any of the effects. + */ bool RenderEffects:: safe_to_combine() const { Effects::const_iterator ai; @@ -147,12 +129,9 @@ safe_to_combine() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::xform -// Access: Public, Virtual -// Description: Returns a new RenderEffects transformed by the -// indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderEffects transformed by the indicated matrix. + */ CPT(RenderEffects) RenderEffects:: xform(const LMatrix4 &mat) const { if (is_empty()) { @@ -160,7 +139,7 @@ xform(const LMatrix4 &mat) const { } RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_state->_effects); Effects::const_iterator ai; @@ -175,35 +154,28 @@ xform(const LMatrix4 &mat) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::operator < -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// RenderEffects, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// This method is not needed outside of the RenderEffects -// class because all equivalent RenderEffects objects are -// guaranteed to share the same pointer; thus, a pointer -// comparison is always sufficient. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique RenderEffects, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * This method is not needed outside of the RenderEffects class because all + * equivalent RenderEffects objects are guaranteed to share the same pointer; + * thus, a pointer comparison is always sufficient. + */ bool RenderEffects:: operator < (const RenderEffects &other) const { - // We must compare all the properties of the effects, not just - // the type; thus, we compare them one at a time using compare_to(). + // We must compare all the properties of the effects, not just the type; + // thus, we compare them one at a time using compare_to(). return lexicographical_compare(_effects.begin(), _effects.end(), other._effects.begin(), other._effects.end(), CompareTo()); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::find_effect -// Access: Published -// Description: Searches for an effect with the indicated type in -// the state, and returns its index if it is found, or -// -1 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Searches for an effect with the indicated type in the state, and returns + * its index if it is found, or -1 if it is not. + */ int RenderEffects:: find_effect(TypeHandle type) const { Effects::const_iterator ai = _effects.find(Effect(type)); @@ -213,15 +185,13 @@ find_effect(TypeHandle type) const { return ai - _effects.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make_empty -// Access: Published, Static -// Description: Returns a RenderEffects with no effects set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderEffects with no effects set. + */ CPT(RenderEffects) RenderEffects:: make_empty() { - // The empty state is asked for so often, we make it a special case - // and store a pointer forever once we find it the first time. + // The empty state is asked for so often, we make it a special case and + // store a pointer forever once we find it the first time. if (_empty_state == (RenderEffects *)NULL) { RenderEffects *state = new RenderEffects; _empty_state = return_new(state); @@ -230,11 +200,9 @@ make_empty() { return _empty_state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make -// Access: Published, Static -// Description: Returns a RenderEffects with one effect set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderEffects with one effect set. + */ CPT(RenderEffects) RenderEffects:: make(const RenderEffect *effect) { RenderEffects *state = new RenderEffects; @@ -243,11 +211,9 @@ make(const RenderEffect *effect) { return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make -// Access: Published, Static -// Description: Returns a RenderEffects with two effects set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderEffects with two effects set. + */ CPT(RenderEffects) RenderEffects:: make(const RenderEffect *effect1, const RenderEffect *effect2) { @@ -259,11 +225,9 @@ make(const RenderEffect *effect1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make -// Access: Published, Static -// Description: Returns a RenderEffects with three effects set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderEffects with three effects set. + */ CPT(RenderEffects) RenderEffects:: make(const RenderEffect *effect1, const RenderEffect *effect2, @@ -277,11 +241,9 @@ make(const RenderEffect *effect1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make -// Access: Published, Static -// Description: Returns a RenderEffects with four effects set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderEffects with four effects set. + */ CPT(RenderEffects) RenderEffects:: make(const RenderEffect *effect1, const RenderEffect *effect2, @@ -297,18 +259,15 @@ make(const RenderEffect *effect1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::add_effect -// Access: Published -// Description: Returns a new RenderEffects object that represents the -// same as the source state, with the new RenderEffect -// added. If there is already a RenderEffect with the -// same type, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderEffects object that represents the same as the source + * state, with the new RenderEffect added. If there is already a RenderEffect + * with the same type, it is replaced. + */ CPT(RenderEffects) RenderEffects:: add_effect(const RenderEffect *effect) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_state->_effects); Effect new_effect(effect); @@ -323,10 +282,9 @@ add_effect(const RenderEffect *effect) const { ++result; if (ai != _effects.end() && !(new_effect < (*ai))) { - // At this point we know: - // !((*ai) < new_effect) && !(new_effect < (*ai)) - // which means (*ai) == new_effect--so we should leave it out, - // to avoid duplicating effects in the set. + // At this point we know: !((*ai) < new_effect) && !(new_effect < (*ai)) + // which means (*ai) == new_effect--so we should leave it out, to avoid + // duplicating effects in the set. ++ai; } @@ -339,17 +297,14 @@ add_effect(const RenderEffect *effect) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::remove_effect -// Access: Published -// Description: Returns a new RenderEffects object that represents the -// same as the source state, with the indicated -// RenderEffect removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderEffects object that represents the same as the source + * state, with the indicated RenderEffect removed. + */ CPT(RenderEffects) RenderEffects:: remove_effect(TypeHandle type) const { RenderEffects *new_state = new RenderEffects; - back_insert_iterator result = + back_insert_iterator result = back_inserter(new_state->_effects); Effects::const_iterator ai = _effects.begin(); @@ -365,13 +320,10 @@ remove_effect(TypeHandle type) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::get_effect -// Access: Published, Virtual -// Description: Looks for a RenderEffect of the indicated type in the -// state, and returns it if it is found, or NULL if it -// is not. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a RenderEffect of the indicated type in the state, and returns it + * if it is found, or NULL if it is not. + */ const RenderEffect *RenderEffects:: get_effect(TypeHandle type) const { Effects::const_iterator ai; @@ -382,23 +334,18 @@ get_effect(TypeHandle type) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// check whether the remaining reference count is -// entirely in the cache, and if so, it checks for and -// breaks a cycle in the cache involving this object. -// This is designed to prevent leaks from cyclical -// references within the cache. -// -// Note that this is not a virtual method, and cannot be -// because ReferenceCount itself declares no virtual -// methods (it avoids the overhead of a virtual function -// pointer). But this doesn't matter, because -// PT(TransformState) is a template class, and will call -// the appropriate method even though it is non-virtual. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to check whether the + * remaining reference count is entirely in the cache, and if so, it checks + * for and breaks a cycle in the cache involving this object. This is + * designed to prevent leaks from cyclical references within the cache. + * + * Note that this is not a virtual method, and cannot be because + * ReferenceCount itself declares no virtual methods (it avoids the overhead + * of a virtual function pointer). But this doesn't matter, because + * PT(TransformState) is a template class, and will call the appropriate + * method even though it is non-virtual. + */ bool RenderEffects:: unref() const { LightReMutexHolder holder(*_states_lock); @@ -408,19 +355,17 @@ unref() const { return true; } - // The reference count has just reached zero. Make sure the object - // is removed from the global object pool, before anyone else finds - // it and tries to ref it. + // The reference count has just reached zero. Make sure the object is + // removed from the global object pool, before anyone else finds it and + // tries to ref it. ((RenderEffects *)this)->release_new(); - + return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderEffects:: output(ostream &out) const { out << "E:"; @@ -439,11 +384,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderEffects:: write(ostream &out, int indent_level) const { indent(out, indent_level) << _effects.size() << " effects:\n"; @@ -454,13 +397,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::get_num_states -// Access: Published, Static -// Description: Returns the total number of unique RenderEffects -// objects allocated in the world. This will go up and -// down during normal operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique RenderEffects objects allocated in the + * world. This will go up and down during normal operations. + */ int RenderEffects:: get_num_states() { if (_states == (States *)NULL) { @@ -470,13 +410,11 @@ get_num_states() { return _states->size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::list_states -// Access: Published, Static -// Description: Lists all of the RenderEffects in the cache to the -// output stream, one per line. This can be quite a lot -// of output if the cache is large, so be prepared. -//////////////////////////////////////////////////////////////////// +/** + * Lists all of the RenderEffects in the cache to the output stream, one per + * line. This can be quite a lot of output if the cache is large, so be + * prepared. + */ void RenderEffects:: list_states(ostream &out) { out << _states->size() << " states:\n"; @@ -487,14 +425,11 @@ list_states(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::validate_states -// Access: Published, Static -// Description: Ensures that the cache is still stored in sorted -// order. Returns true if so, false if there is a -// problem (which implies someone has modified one of -// the supposedly-const RenderEffects objects). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the cache is still stored in sorted order. Returns true if + * so, false if there is a problem (which implies someone has modified one of + * the supposedly-const RenderEffects objects). + */ bool RenderEffects:: validate_states() { if (_states->empty()) { @@ -531,13 +466,10 @@ validate_states() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::cull_callback -// Access: Public -// Description: Calls cull_callback() on all effects. You may check -// has_cull_callback() first to see if any effects -// define this method to do anything useful. -//////////////////////////////////////////////////////////////////// +/** + * Calls cull_callback() on all effects. You may check has_cull_callback() + * first to see if any effects define this method to do anything useful. + */ void RenderEffects:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -548,18 +480,15 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::adjust_transform -// Access: Public -// Description: Calls adjust_transform() on all effects. You may check -// has_adjust_transform() first to see if any effects -// define this method to do anything useful. -// -// The order in which the individual effects are applied -// is not defined, so if more than one effect applies a -// change to the transform on any particular node, you -// might get indeterminate results. -//////////////////////////////////////////////////////////////////// +/** + * Calls adjust_transform() on all effects. You may check + * has_adjust_transform() first to see if any effects define this method to do + * anything useful. + * + * The order in which the individual effects are applied is not defined, so if + * more than one effect applies a change to the transform on any particular + * node, you might get indeterminate results. + */ void RenderEffects:: adjust_transform(CPT(TransformState) &net_transform, CPT(TransformState) &node_transform, @@ -569,43 +498,36 @@ adjust_transform(CPT(TransformState) &net_transform, (*ei)._effect->adjust_transform(net_transform, node_transform, node); } } - -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::init_states -// Access: Public, Static -// Description: Make sure the global _states map is allocated. This -// only has to be done once. We could make this map -// static, but then we run into problems if anyone -// creates a RenderEffects object at static init time; -// it also seems to cause problems when the Panda shared -// library is unloaded at application exit time. -//////////////////////////////////////////////////////////////////// + +/** + * Make sure the global _states map is allocated. This only has to be done + * once. We could make this map static, but then we run into problems if + * anyone creates a RenderEffects object at static init time; it also seems to + * cause problems when the Panda shared library is unloaded at application + * exit time. + */ void RenderEffects:: init_states() { _states = new States; - // TODO: we should have a global Panda mutex to allow us to safely - // create _states_lock without a startup race condition. For the - // meantime, this is OK because we guarantee that this method is - // called at static init time, presumably when there is still only - // one thread in the world. + // TODO: we should have a global Panda mutex to allow us to safely create + // _states_lock without a startup race condition. For the meantime, this is + // OK because we guarantee that this method is called at static init time, + // presumably when there is still only one thread in the world. _states_lock = new LightReMutex("RenderEffects::_states_lock"); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } - -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::return_new -// Access: Private, Static -// Description: This function is used to share a common RenderEffects -// pointer for all equivalent RenderEffects objects. -// -// See the similar logic in RenderEffect. The idea is -// to create a new RenderEffects object and pass it -// through this function, which will share the pointer -// with a previously-created RenderEffects object if it is -// equivalent. -//////////////////////////////////////////////////////////////////// + +/** + * This function is used to share a common RenderEffects pointer for all + * equivalent RenderEffects objects. + * + * See the similar logic in RenderEffect. The idea is to create a new + * RenderEffects object and pass it through this function, which will share + * the pointer with a previously-created RenderEffects object if it is + * equivalent. + */ CPT(RenderEffects) RenderEffects:: return_new(RenderEffects *state) { nassertr(state != (RenderEffects *)NULL, state); @@ -624,37 +546,33 @@ return_new(RenderEffects *state) { LightReMutexHolder holder(*_states_lock); - // This should be a newly allocated pointer, not one that was used - // for anything else. + // This should be a newly allocated pointer, not one that was used for + // anything else. nassertr(state->_saved_entry == _states->end(), state); - // Save the state in a local PointerTo so that it will be freed at - // the end of this function if no one else uses it. + // Save the state in a local PointerTo so that it will be freed at the end + // of this function if no one else uses it. CPT(RenderEffects) pt_state = state; pair result = _states->insert(state); if (result.second) { - // The state was inserted; save the iterator and return the - // input state. + // The state was inserted; save the iterator and return the input state. state->_saved_entry = result.first; nassertr(_states->find(state) == state->_saved_entry, pt_state); return pt_state; } - // The state was not inserted; there must be an equivalent one - // already in the set. Return that one. + // The state was not inserted; there must be an equivalent one already in + // the set. Return that one. return *(result.first); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::release_new -// Access: Private -// Description: This inverse of return_new, this releases this object -// from the global RenderEffects table. -// -// You must already be holding _states_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * This inverse of return_new, this releases this object from the global + * RenderEffects table. + * + * You must already be holding _states_lock before you call this method. + */ void RenderEffects:: release_new() { nassertv(_states_lock->debug_is_locked()); @@ -666,11 +584,9 @@ release_new() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::determine_decal -// Access: Private -// Description: This is the private implementation of has_decal(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of has_decal(). + */ void RenderEffects:: determine_decal() { LightMutexHolder holder(_lock); @@ -686,11 +602,9 @@ determine_decal() { _flags |= F_checked_decal; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::determine_show_bounds -// Access: Private -// Description: This is the private implementation of has_show_bounds(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of has_show_bounds(). + */ void RenderEffects:: determine_show_bounds() { LightMutexHolder holder(_lock); @@ -710,11 +624,9 @@ determine_show_bounds() { _flags |= F_checked_show_bounds; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::determine_cull_callback -// Access: Private -// Description: This is the private implementation of has_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of has_cull_callback(). + */ void RenderEffects:: determine_cull_callback() { LightMutexHolder holder(_lock); @@ -734,11 +646,9 @@ determine_cull_callback() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::determine_adjust_transform -// Access: Private -// Description: This is the private implementation of has_adjust_transform(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of has_adjust_transform(). + */ void RenderEffects:: determine_adjust_transform() { LightMutexHolder holder(_lock); @@ -758,23 +668,18 @@ determine_adjust_transform() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// RenderEffects. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type RenderEffects. + */ void RenderEffects:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RenderEffects:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -791,13 +696,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int RenderEffects:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -809,8 +711,8 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { effect._effect = DCAST(RenderEffect, p_list[pi++]); if (effect._effect == (RenderEffect *)NULL) { - // Remove this bogus RenderEffect pointer (it must have been - // from an unwritable class). + // Remove this bogus RenderEffect pointer (it must have been from an + // unwritable class). _effects.erase(_effects.begin() + i); } else { @@ -820,98 +722,83 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { } } - // Now make sure the array is properly sorted. (It won't - // necessarily preserve its correct sort after being read from bam, - // because the sort is based on TypeHandle indices, which can change - // from session to session.) + // Now make sure the array is properly sorted. (It won't necessarily + // preserve its correct sort after being read from bam, because the sort is + // based on TypeHandle indices, which can change from session to session.) _effects.sort(); nassertr(_saved_entry == _states->end(), pi); return pi; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool RenderEffects:: require_fully_complete() const { - // Since we sort _states based on each RenderEffects' operator < - // method, which in turn compares based on each nested RenderEffect - // object's compare_to() method, some of which depend on the - // RenderEffect's pointers having already been completed - // (e.g. CharacterJointEffect), we therefore require each of out our - // nested RenderEffect objects to have been completed before we can - // be completed. + // Since we sort _states based on each RenderEffects' operator < method, + // which in turn compares based on each nested RenderEffect object's + // compare_to() method, some of which depend on the RenderEffect's pointers + // having already been completed (e.g. CharacterJointEffect), we therefore + // require each of out our nested RenderEffect objects to have been + // completed before we can be completed. return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::change_this -// Access: Public, Static -// Description: Called immediately after complete_pointers(), this -// gives the object a chance to adjust its own pointer -// if desired. Most objects don't change pointers after -// completion, but some need to. -// -// Once this function has been called, the old pointer -// will no longer be accessed. -//////////////////////////////////////////////////////////////////// +/** + * Called immediately after complete_pointers(), this gives the object a + * chance to adjust its own pointer if desired. Most objects don't change + * pointers after completion, but some need to. + * + * Once this function has been called, the old pointer will no longer be + * accessed. + */ TypedWritable *RenderEffects:: change_this(TypedWritable *old_ptr, BamReader *manager) { // First, uniquify the pointer. RenderEffects *state = DCAST(RenderEffects, old_ptr); CPT(RenderEffects) pointer = return_new(state); - // But now we have a problem, since we have to hold the reference - // count and there's no way to return a TypedWritable while still - // holding the reference count! We work around this by explicitly - // upping the count, and also setting a finalize() callback to down - // it later. + // But now we have a problem, since we have to hold the reference count and + // there's no way to return a TypedWritable while still holding the + // reference count! We work around this by explicitly upping the count, and + // also setting a finalize() callback to down it later. if (pointer == state) { pointer->ref(); manager->register_finalize(state); } - - // We have to cast the pointer back to non-const, because the bam - // reader expects that. + + // We have to cast the pointer back to non-const, because the bam reader + // expects that. return (RenderEffects *)pointer.p(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void RenderEffects:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in change_this(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type RenderEffects is encountered -// in the Bam file. It should create the RenderEffects -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type RenderEffects is encountered in the Bam file. It should create the + * RenderEffects and extract its information from the file. + */ TypedWritable *RenderEffects:: make_from_bam(const FactoryParams ¶ms) { RenderEffects *state = new RenderEffects; @@ -925,21 +812,18 @@ make_from_bam(const FactoryParams ¶ms) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderEffects::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RenderEffects. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RenderEffects. + */ void RenderEffects:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); int num_effects = scan.get_uint16(); - // Push back a NULL pointer for each effect for now, until we get - // the actual list of pointers later in complete_pointers(). + // Push back a NULL pointer for each effect for now, until we get the actual + // list of pointers later in complete_pointers(). _effects.reserve(num_effects); for (int i = 0; i < num_effects; i++) { manager->read_pointer(scan); diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index b8aafcfc23..e1ece7d2b3 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -1,16 +1,15 @@ -// Filename: renderEffects.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderEffects.h + * @author drose + * @date 2002-03-14 + */ #ifndef RENDEREFFECTS_H #define RENDEREFFECTS_H @@ -31,18 +30,14 @@ class CullTraverser; class CullTraverserData; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RenderEffects -// Description : This represents a unique collection of RenderEffect -// objects that correspond to a particular renderable -// state. -// -// You should not attempt to create or modify a -// RenderEffects object directly. Instead, call one of -// the make() functions to create one for you. And -// instead of modifying a RenderEffects object, create a -// new one. -//////////////////////////////////////////////////////////////////// +/** + * This represents a unique collection of RenderEffect objects that correspond + * to a particular renderable state. + * + * You should not attempt to create or modify a RenderEffects object directly. + * Instead, call one of the make() functions to create one for you. And + * instead of modifying a RenderEffects object, create a new one. + */ class EXPCL_PANDA_PGRAPH RenderEffects : public TypedWritableReferenceCount { protected: RenderEffects(); @@ -121,8 +116,8 @@ private: void determine_adjust_transform(); private: - // This mutex protects _states. It also protects any modification - // to the cache, which is encoded in _composition_cache and + // This mutex protects _states. It also protects any modification to the + // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; typedef pset > States; @@ -130,13 +125,12 @@ private: static CPT(RenderEffects) _empty_state; // This iterator records the entry corresponding to this RenderEffects - // object in the above global set. We keep the iterator around so - // we can remove it when the RenderEffects destructs. + // object in the above global set. We keep the iterator around so we can + // remove it when the RenderEffects destructs. States::iterator _saved_entry; private: - // This is the actual data within the RenderEffects: a set of - // RenderEffects. + // This is the actual data within the RenderEffects: a set of RenderEffects. class Effect { public: INLINE Effect(const RenderEffect *effect); @@ -181,7 +175,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -208,4 +202,3 @@ INLINE ostream &operator << (ostream &out, const RenderEffects &state) { #include "renderEffects.I" #endif - diff --git a/panda/src/pgraph/renderModeAttrib.I b/panda/src/pgraph/renderModeAttrib.I index 4a7bda8dc1..5c42e42f53 100644 --- a/panda/src/pgraph/renderModeAttrib.I +++ b/panda/src/pgraph/renderModeAttrib.I @@ -1,24 +1,19 @@ -// Filename: renderModeAttrib.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderModeAttrib.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::Constructor -// Access: Private -// Description: Use RenderModeAttrib::make() to construct a new -// RenderModeAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use RenderModeAttrib::make() to construct a new RenderModeAttrib object. + */ INLINE RenderModeAttrib:: RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness, bool perspective, const LColor &wireframe_color) : @@ -29,66 +24,50 @@ RenderModeAttrib(RenderModeAttrib::Mode mode, PN_stdfloat thickness, { } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_mode -// Access: Published -// Description: Returns the render mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render mode. + */ INLINE RenderModeAttrib::Mode RenderModeAttrib:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_thickness -// Access: Published -// Description: Returns the line width or point thickness. This is -// only relevant when rendering points or lines, such as -// when the mode is M_wireframe or M_point (or when -// rendering actual points or lines primitives in -// M_polygon mode). -//////////////////////////////////////////////////////////////////// +/** + * Returns the line width or point thickness. This is only relevant when + * rendering points or lines, such as when the mode is M_wireframe or M_point + * (or when rendering actual points or lines primitives in M_polygon mode). + */ INLINE PN_stdfloat RenderModeAttrib:: get_thickness() const { return _thickness; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_perspective -// Access: Published -// Description: Returns the perspective flag. When this is true, the -// point thickness represented by get_thickness() is -// actually a width in 3-d units, and the points should -// scale according to perspective. When it is false, -// the default, the point thickness is actually a width -// in pixels, and points are a uniform size regardless -// of distance from the camera. -//////////////////////////////////////////////////////////////////// +/** + * Returns the perspective flag. When this is true, the point thickness + * represented by get_thickness() is actually a width in 3-d units, and the + * points should scale according to perspective. When it is false, the + * default, the point thickness is actually a width in pixels, and points are + * a uniform size regardless of distance from the camera. + */ INLINE bool RenderModeAttrib:: get_perspective() const { return _perspective; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_wireframe_color -// Access: Published -// Description: Returns the color that is used in M_filled_wireframe -// mode to distinguish the wireframe from the rest of -// the geometry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color that is used in M_filled_wireframe mode to distinguish + * the wireframe from the rest of the geometry. + */ INLINE const LColor &RenderModeAttrib:: get_wireframe_color() const { return _wireframe_color; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_geom_rendering -// Access: Published -// Description: Returns the union of the Geom::GeomRendering bits -// that will be required once this RenderModeAttrib is -// applied to a geom which includes the indicated -// geom_rendering bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the Geom::GeomRendering bits that will be required + * once this RenderModeAttrib is applied to a geom which includes the + * indicated geom_rendering bits. + */ INLINE int RenderModeAttrib:: get_geom_rendering(int geom_rendering) const { if (_mode == M_point) { diff --git a/panda/src/pgraph/renderModeAttrib.cxx b/panda/src/pgraph/renderModeAttrib.cxx index 83a3fe9282..efdf3e7434 100644 --- a/panda/src/pgraph/renderModeAttrib.cxx +++ b/panda/src/pgraph/renderModeAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: renderModeAttrib.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderModeAttrib.cxx + * @author drose + * @date 2002-03-14 + */ #include "renderModeAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,32 +22,24 @@ TypeHandle RenderModeAttrib::_type_handle; int RenderModeAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::make -// Access: Published, Static -// Description: Constructs a new RenderModeAttrib object that specifies -// whether to draw polygons in the normal, filled mode, -// or wireframe mode, or in some other yet-to-be-defined -// mode. -// -// The thickness parameter specifies the thickness to be -// used for wireframe lines, as well as for ordinary -// linestrip lines; it also specifies the diameter of -// points. (Thick lines are presently only supported in -// OpenGL; but thick points are supported on either -// platform.) -// -// If perspective is true, the point thickness -// represented is actually a width in 3-d units, and the -// points should scale according to perspective. When -// it is false, the point thickness is actually a width -// in pixels, and points are a uniform screen size -// regardless of distance from the camera. -// -// In M_filled_wireframe mode, you should also specify -// the wireframe_color, indicating the flat color to -// assign to the overlayed wireframe. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new RenderModeAttrib object that specifies whether to draw + * polygons in the normal, filled mode, or wireframe mode, or in some other + * yet-to-be-defined mode. + * + * The thickness parameter specifies the thickness to be used for wireframe + * lines, as well as for ordinary linestrip lines; it also specifies the + * diameter of points. (Thick lines are presently only supported in OpenGL; + * but thick points are supported on either platform.) + * + * If perspective is true, the point thickness represented is actually a width + * in 3-d units, and the points should scale according to perspective. When + * it is false, the point thickness is actually a width in pixels, and points + * are a uniform screen size regardless of distance from the camera. + * + * In M_filled_wireframe mode, you should also specify the wireframe_color, + * indicating the flat color to assign to the overlayed wireframe. + */ CPT(RenderAttrib) RenderModeAttrib:: make(RenderModeAttrib::Mode mode, PN_stdfloat thickness, bool perspective, const LColor &wireframe_color) { @@ -56,23 +47,18 @@ make(RenderModeAttrib::Mode mode, PN_stdfloat thickness, return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) RenderModeAttrib:: make_default() { return return_new(new RenderModeAttrib(M_filled, 1.0f, false)); } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderModeAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -111,21 +97,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderModeAttrib -// types to return a unique number indicating whether -// this RenderModeAttrib is equivalent to the other one. -// -// This should return 0 if the two RenderModeAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two RenderModeAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderModeAttrib types to return a + * unique number indicating whether this RenderModeAttrib is equivalent to the + * other one. + * + * This should return 0 if the two RenderModeAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two RenderModeAttrib objects whose get_type() + * functions return the same. + */ int RenderModeAttrib:: compare_to_impl(const RenderAttrib *other) const { const RenderModeAttrib *ta = (const RenderModeAttrib *)other; @@ -145,16 +128,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t RenderModeAttrib:: get_hash_impl() const { size_t hash = 0; @@ -167,23 +146,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) RenderModeAttrib:: compose_impl(const RenderAttrib *other) const { const RenderModeAttrib *ta = (const RenderModeAttrib *)other; @@ -198,23 +171,18 @@ compose_impl(const RenderAttrib *other) const { ta->get_wireframe_color()); } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// RenderModeAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type RenderModeAttrib. + */ void RenderModeAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RenderModeAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -228,14 +196,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type RenderModeAttrib is encountered -// in the Bam file. It should create the RenderModeAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type RenderModeAttrib is encountered in the Bam file. It should create the + * RenderModeAttrib and extract its information from the file. + */ TypedWritable *RenderModeAttrib:: make_from_bam(const FactoryParams ¶ms) { RenderModeAttrib *attrib = new RenderModeAttrib(M_filled, 1.0f, false); @@ -248,13 +213,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RenderModeAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RenderModeAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RenderModeAttrib. + */ void RenderModeAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/renderModeAttrib.h b/panda/src/pgraph/renderModeAttrib.h index 1003abc328..0306de9737 100644 --- a/panda/src/pgraph/renderModeAttrib.h +++ b/panda/src/pgraph/renderModeAttrib.h @@ -1,16 +1,15 @@ -// Filename: renderModeAttrib.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderModeAttrib.h + * @author drose + * @date 2002-03-14 + */ #ifndef RENDERMODEATTRIB_H #define RENDERMODEATTRIB_H @@ -22,10 +21,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RenderModeAttrib -// Description : Specifies how polygons are to be drawn. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how polygons are to be drawn. + */ class EXPCL_PANDA_PGRAPH RenderModeAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -37,17 +35,17 @@ PUBLISHED: // Wireframe polygons, possibly with thickness. M_wireframe, - // Points at vertices only, possibly with thickness and/or - // perspective sizing. + // Points at vertices only, possibly with thickness andor perspective + // sizing. M_point, // Filled polygons, without any particular emphasis on perspective - // correctness (a particularly useful designation for software - // rendering sprites). + // correctness (a particularly useful designation for software rendering + // sprites). M_filled_flat, - // Filled polygons with wireframe rendered in front. - // The wireframe is given a solid color. + // Filled polygons with wireframe rendered in front. The wireframe is + // given a solid color. M_filled_wireframe }; @@ -122,4 +120,3 @@ private: #include "renderModeAttrib.I" #endif - diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index c15173cdf9..c6d0520ec4 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -1,46 +1,37 @@ -// Filename: renderState.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderState.I + * @author drose + * @date 2002-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_hash -// Access: Published -// Description: Returns a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash value for phash_map. + */ INLINE size_t RenderState:: get_hash() const { check_hash(); return _hash; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::is_empty -// Access: Published -// Description: Returns true if the state is empty, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the state is empty, false otherwise. + */ INLINE bool RenderState:: is_empty() const { return _filled_slots.is_zero(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::has_cull_callback -// Access: Published -// Description: Returns true if any of the RenderAttribs in this -// state request a cull_callback(), false if none of -// them do. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the RenderAttribs in this state request a + * cull_callback(), false if none of them do. + */ INLINE bool RenderState:: has_cull_callback() const { if ((_flags & F_checked_cull_callback) == 0) { @@ -51,23 +42,18 @@ has_cull_callback() const { return (_flags & F_has_cull_callback) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make_empty -// Access: Published, Static -// Description: Returns a RenderState with no attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with no attributes set. + */ INLINE CPT(RenderState) RenderState:: make_empty() { return _empty_state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::remove_attrib -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with the indicated -// RenderAttrib removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with the indicated RenderAttrib removed. + */ INLINE CPT(RenderState) RenderState:: remove_attrib(TypeHandle type) const { RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); @@ -75,35 +61,28 @@ remove_attrib(TypeHandle type) const { return remove_attrib(slot); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::has_attrib -// Access: Published -// Description: Returns true if an attrib of the indicated type is -// present, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an attrib of the indicated type is present, false + * otherwise. + */ INLINE bool RenderState:: has_attrib(TypeHandle type) const { return get_attrib(type) != (RenderAttrib *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::has_attrib -// Access: Published -// Description: Returns true if an attrib of the indicated type is -// present, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an attrib of the indicated type is present, false + * otherwise. + */ INLINE bool RenderState:: has_attrib(int slot) const { return get_attrib(slot) != (RenderAttrib *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_attrib -// Access: Published -// Description: Looks for a RenderAttrib of the indicated type in the -// state, and returns it if it is found, or NULL if it -// is not. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a RenderAttrib of the indicated type in the state, and returns it + * if it is found, or NULL if it is not. + */ INLINE const RenderAttrib *RenderState:: get_attrib(TypeHandle type) const { RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr(); @@ -111,25 +90,19 @@ get_attrib(TypeHandle type) const { return _attributes[slot]._attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_attrib -// Access: Published -// Description: Returns the RenderAttrib with the indicated slot -// index, or NULL if there is no such RenderAttrib in -// the state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderAttrib with the indicated slot index, or NULL if there is + * no such RenderAttrib in the state. + */ ALWAYS_INLINE const RenderAttrib *RenderState:: get_attrib(int slot) const { return _attributes[slot]._attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_attrib_def -// Access: Published -// Description: Returns the RenderAttrib with the indicated slot -// index, or the default attrib for that slot if there -// is no such RenderAttrib in the state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderAttrib with the indicated slot index, or the default + * attrib for that slot if there is no such RenderAttrib in the state. + */ INLINE const RenderAttrib *RenderState:: get_attrib_def(int slot) const { if (_attributes[slot]._attrib != (RenderAttrib *)NULL) { @@ -139,13 +112,10 @@ get_attrib_def(int slot) const { return reg->get_slot_default(slot); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_override -// Access: Published -// Description: Looks for a RenderAttrib of the indicated type in the -// state, and returns its override value if it is found, -// or 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a RenderAttrib of the indicated type in the state, and returns + * its override value if it is found, or 0 if it is not. + */ INLINE int RenderState:: get_override(TypeHandle type) const { RenderAttribRegistry *reg = RenderAttribRegistry::get_global_ptr(); @@ -153,38 +123,30 @@ get_override(TypeHandle type) const { return _attributes[slot]._override; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_override -// Access: Published -// Description: Looks for a RenderAttrib of the indicated type in the -// state, and returns its override value if it is found, -// or 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a RenderAttrib of the indicated type in the state, and returns + * its override value if it is found, or 0 if it is not. + */ INLINE int RenderState:: get_override(int slot) const { return _attributes[slot]._override; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_unique -// Access: Published -// Description: Returns the pointer to the unique RenderState in -// the cache that is equivalent to this one. This may -// be the same pointer as this object, or it may be a -// different pointer; but it will be an equivalent -// object, and it will be a shared pointer. This may be -// called from time to time to improve cache benefits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the unique RenderState in the cache that is + * equivalent to this one. This may be the same pointer as this object, or it + * may be a different pointer; but it will be an equivalent object, and it + * will be a shared pointer. This may be called from time to time to improve + * cache benefits. + */ INLINE CPT(RenderState) RenderState:: get_unique() const { return return_unique((RenderState *)this); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::cache_ref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE void RenderState:: cache_ref() const { #ifdef DO_PSTATS @@ -196,11 +158,9 @@ cache_ref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::cache_unref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE bool RenderState:: cache_unref() const { #ifdef DO_PSTATS @@ -213,11 +173,9 @@ cache_unref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::node_ref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE void RenderState:: node_ref() const { #ifdef DO_PSTATS @@ -229,11 +187,9 @@ node_ref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::node_unref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE bool RenderState:: node_unref() const { #ifdef DO_PSTATS @@ -246,65 +202,52 @@ node_unref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_composition_cache_num_entries -// Access: Published -// Description: Returns the number of entries in the composition -// cache for this RenderState. This is the number of -// other RenderStates whose composition with this one -// has been cached. This number is not useful for any -// practical reason other than performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the composition cache for this + * RenderState. This is the number of other RenderStates whose composition + * with this one has been cached. This number is not useful for any practical + * reason other than performance analysis. + */ INLINE size_t RenderState:: get_composition_cache_num_entries() const { LightReMutexHolder holder(*_states_lock); return _composition_cache.get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_invert_composition_cache_num_entries -// Access: Published -// Description: Returns the number of entries in the -// invert_composition cache for this RenderState. -// This is similar to the composition cache, but it -// records cache entries for the invert_compose() -// operation. See get_composition_cache_num_entries(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the invert_composition cache for this + * RenderState. This is similar to the composition cache, but it records + * cache entries for the invert_compose() operation. See + * get_composition_cache_num_entries(). + */ INLINE size_t RenderState:: get_invert_composition_cache_num_entries() const { LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_composition_cache_size -// Access: Published -// Description: Returns the number of slots in the composition -// cache for this RenderState. You may use this as -// an upper bound when walking through all of the -// composition cache results via -// get_composition_cache_source() or result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of slots in the composition cache for this RenderState. + * You may use this as an upper bound when walking through all of the + * composition cache results via get_composition_cache_source() or result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE size_t RenderState:: get_composition_cache_size() const { LightReMutexHolder holder(*_states_lock); return _composition_cache.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_composition_cache_source -// Access: Published -// Description: Returns the source RenderState of the nth element -// in the composition cache. Returns NULL if there -// doesn't happen to be an entry in the nth element. -// See get_composition_cache_result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source RenderState of the nth element in the composition cache. + * Returns NULL if there doesn't happen to be an entry in the nth element. + * See get_composition_cache_result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const RenderState *RenderState:: get_composition_cache_source(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -314,20 +257,16 @@ get_composition_cache_source(size_t n) const { return _composition_cache.get_key(n); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_composition_cache_result -// Access: Published -// Description: Returns the result RenderState of the nth element -// in the composition cache. Returns NULL if there -// doesn't happen to be an entry in the nth element. -// -// In general, -// a->compose(a->get_composition_cache_source(n)) == -// a->get_composition_cache_result(n). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the result RenderState of the nth element in the composition cache. + * Returns NULL if there doesn't happen to be an entry in the nth element. + * + * In general, a->compose(a->get_composition_cache_source(n)) == + * a->get_composition_cache_result(n). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const RenderState *RenderState:: get_composition_cache_result(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -337,35 +276,29 @@ get_composition_cache_result(size_t n) const { return _composition_cache.get_data(n)._result; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_invert_composition_cache_size -// Access: Published -// Description: Returns the number of slots in the composition -// cache for this RenderState. You may use this as -// an upper bound when walking through all of the -// composition cache results via -// get_invert_composition_cache_source() or result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of slots in the composition cache for this RenderState. + * You may use this as an upper bound when walking through all of the + * composition cache results via get_invert_composition_cache_source() or + * result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE size_t RenderState:: get_invert_composition_cache_size() const { LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_invert_composition_cache_source -// Access: Published -// Description: Returns the source RenderState of the nth element -// in the invert composition cache. Returns NULL if -// there doesn't happen to be an entry in the nth -// element. See get_invert_composition_cache_result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source RenderState of the nth element in the invert composition + * cache. Returns NULL if there doesn't happen to be an entry in the nth + * element. See get_invert_composition_cache_result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const RenderState *RenderState:: get_invert_composition_cache_source(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -375,21 +308,17 @@ get_invert_composition_cache_source(size_t n) const { return _invert_composition_cache.get_key(n); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_invert_composition_cache_result -// Access: Published -// Description: Returns the result RenderState of the nth element -// in the invert composition cache. Returns NULL if -// there doesn't happen to be an entry in the nth -// element. -// -// In general, -// a->invert_compose(a->get_invert_composition_cache_source(n)) -// == a->get_invert_composition_cache_result(n). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the result RenderState of the nth element in the invert composition + * cache. Returns NULL if there doesn't happen to be an entry in the nth + * element. + * + * In general, a->invert_compose(a->get_invert_composition_cache_source(n)) == + * a->get_invert_composition_cache_result(n). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const RenderState *RenderState:: get_invert_composition_cache_result(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -399,13 +328,10 @@ get_invert_composition_cache_result(size_t n) const { return _invert_composition_cache.get_data(n)._result; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_draw_order -// Access: Published -// Description: Returns the draw order indicated by the -// CullBinAttrib, if any, associated by this state (or 0 -// if there is no CullBinAttrib). See get_bin_index(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the draw order indicated by the CullBinAttrib, if any, associated + * by this state (or 0 if there is no CullBinAttrib). See get_bin_index(). + */ INLINE int RenderState:: get_draw_order() const { if ((_flags & F_checked_bin_index) == 0) { @@ -416,15 +342,12 @@ get_draw_order() const { return _draw_order; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_bin_index -// Access: Published -// Description: Returns the bin index indicated by the CullBinAttrib, -// if any, associated by this state (or the default bin -// index if there is no CullBinAttrib). This function -// is provided as an optimization for determining this -// at render time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bin index indicated by the CullBinAttrib, if any, associated by + * this state (or the default bin index if there is no CullBinAttrib). This + * function is provided as an optimization for determining this at render + * time. + */ INLINE int RenderState:: get_bin_index() const { if ((_flags & F_checked_bin_index) == 0) { @@ -435,15 +358,11 @@ get_bin_index() const { return _bin_index; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::set_destructing -// Access: Private -// Description: This function should only be called from the -// destructor; it indicates that this RenderState -// object is beginning destruction. It is only used as -// a sanity check, and is only meaningful when NDEBUG is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * This function should only be called from the destructor; it indicates that + * this RenderState object is beginning destruction. It is only used as a + * sanity check, and is only meaningful when NDEBUG is not defined. + */ INLINE void RenderState:: set_destructing() { #ifndef NDEBUG @@ -451,15 +370,11 @@ set_destructing() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::is_destructing -// Access: Private -// Description: Returns true if the RenderState object is -// currently within its destructor -// (i.e. set_destructing() has been called). This is -// only used as a sanity check, and is only meaningful -// when NDEBUG is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the RenderState object is currently within its destructor + * (i.e. set_destructing() has been called). This is only used as a sanity + * check, and is only meaningful when NDEBUG is not defined. + */ INLINE bool RenderState:: is_destructing() const { #ifndef NDEBUG @@ -469,12 +384,10 @@ is_destructing() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::consider_update_pstats -// Access: Private -// Description: Calls update_pstats() if the state of the referenced -// bits has changed from the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_pstats() if the state of the referenced bits has changed from + * the indicated value. + */ INLINE void RenderState:: consider_update_pstats(int old_referenced_bits) const { #ifdef DO_PSTATS @@ -485,31 +398,25 @@ consider_update_pstats(int old_referenced_bits) const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Composition::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::Composition:: Composition() { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Composition::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::Composition:: Composition(const RenderState::Composition ©) : _result(copy._result) { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::Attribute:: Attribute(const RenderAttrib *attrib, int override) : _attrib(attrib), @@ -517,22 +424,18 @@ Attribute(const RenderAttrib *attrib, int override) : { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::Attribute:: Attribute(int override) : _override(override) { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::Attribute:: Attribute(const Attribute ©) : _attrib(copy._attrib), @@ -540,25 +443,20 @@ Attribute(const Attribute ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RenderState::Attribute:: operator = (const Attribute ©) { _attrib = copy._attrib; _override = copy._override; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::compare_to -// Access: Public -// Description: Provides an indication of whether a particular -// attribute is equivalent to another one, for purposes -// of generating unique RenderStates. This should -// compare all properties of the Attribute. -//////////////////////////////////////////////////////////////////// +/** + * Provides an indication of whether a particular attribute is equivalent to + * another one, for purposes of generating unique RenderStates. This should + * compare all properties of the Attribute. + */ INLINE int RenderState::Attribute:: compare_to(const Attribute &other) const { if (_attrib != other._attrib) { @@ -577,22 +475,18 @@ compare_to(const Attribute &other) const { return _override - other._override; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Attribute::set -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RenderState::Attribute:: set(const RenderAttrib *attrib, int override) { _attrib = attrib; _override = override; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void RenderState:: flush_level() { _node_counter.flush_level(); @@ -600,13 +494,10 @@ flush_level() { } #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_attrib -// Access: Public -// Description: Handy templated version of get_attrib that -// costs to the right type. Returns true if the -// attribute was present, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Handy templated version of get_attrib that costs to the right type. + * Returns true if the attribute was present, false otherwise. + */ template INLINE bool RenderState:: get_attrib(const AttribType *&attrib) const { @@ -614,12 +505,9 @@ get_attrib(const AttribType *&attrib) const { return (attrib != (const AttribType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_attrib_def -// Access: Public -// Description: Handy templated version of get_attrib_def that -// costs to the right type. -//////////////////////////////////////////////////////////////////// +/** + * Handy templated version of get_attrib_def that costs to the right type. + */ template INLINE void RenderState:: get_attrib_def(const AttribType *&attrib) const { @@ -627,61 +515,50 @@ get_attrib_def(const AttribType *&attrib) const { } #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: RenderState::check_hash -// Access: Private -// Description: Ensures that we know the hash value. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the hash value. + */ INLINE void RenderState:: check_hash() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_hash_known) == 0) { ((RenderState *)this)->calc_hash(); } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_cache_unref -// Access: Private -// Description: Reimplements -// CachedTypedWritableReferenceCount::cache_unref(). We -// do this because we have a non-virtual unref() method. -//////////////////////////////////////////////////////////////////// +/** + * Reimplements CachedTypedWritableReferenceCount::cache_unref(). We do this + * because we have a non-virtual unref() method. + */ INLINE bool RenderState:: do_cache_unref() const { cache_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_node_unref -// Access: Private -// Description: Reimplements NodeReferenceCount::node_unref(). We do -// this because we have a non-virtual unref() method. -//////////////////////////////////////////////////////////////////// +/** + * Reimplements NodeReferenceCount::node_unref(). We do this because we have + * a non-virtual unref() method. + */ INLINE bool RenderState:: do_node_unref() const { node_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::calc_hash -// Access: Private -// Description: Computes the hash value. -//////////////////////////////////////////////////////////////////// +/** + * Computes the hash value. + */ INLINE void RenderState:: calc_hash() { LightMutexHolder holder(_lock); do_calc_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::CompositionCycleDescEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RenderState::CompositionCycleDescEntry:: CompositionCycleDescEntry(const RenderState *obj, const RenderState *result, @@ -691,4 +568,3 @@ CompositionCycleDescEntry(const RenderState *obj, _inverted(inverted) { } - diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 578154a5a8..86437c3122 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -1,16 +1,15 @@ -// Filename: renderState.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderState.cxx + * @author drose + * @date 2002-02-21 + */ #include "renderState.h" #include "transparencyAttrib.h" @@ -57,13 +56,11 @@ CacheStats RenderState::_cache_stats; TypeHandle RenderState::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Constructor -// Access: Protected -// Description: Actually, this could be a private constructor, since -// no one inherits from RenderState, but gcc gives us a -// spurious warning if all constructors are private. -//////////////////////////////////////////////////////////////////// +/** + * Actually, this could be a private constructor, since no one inherits from + * RenderState, but gcc gives us a spurious warning if all constructors are + * private. + */ RenderState:: RenderState() : _flags(0), @@ -80,11 +77,9 @@ RenderState() : _generated_shader = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Copy Constructor -// Access: Private -// Description: RenderStates are only meant to be copied internally. -//////////////////////////////////////////////////////////////////// +/** + * RenderStates are only meant to be copied internally. + */ RenderState:: RenderState(const RenderState ©) : _filled_slots(copy._filled_slots), @@ -104,22 +99,18 @@ RenderState(const RenderState ©) : _generated_shader = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Copy Assignment Operator -// Access: Private -// Description: RenderStates are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * RenderStates are not meant to be copied. + */ void RenderState:: operator = (const RenderState &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::Destructor -// Access: Public, Virtual -// Description: The destructor is responsible for removing the -// RenderState from the global set if it is there. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the RenderState from the global + * set if it is there. + */ RenderState:: ~RenderState() { // We'd better not call the destructor twice on a particular object. @@ -140,24 +131,20 @@ RenderState:: _auto_shader_state = NULL; } - // If this was true at the beginning of the destructor, but is no - // longer true now, probably we've been double-deleted. + // If this was true at the beginning of the destructor, but is no longer + // true now, probably we've been double-deleted. nassertv(get_ref_count() == 0); _cache_stats.add_num_states(-1); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::compare_to -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// RenderStates, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// This method is not needed outside of the RenderState -// class because all equivalent RenderState objects are -// guaranteed to share the same pointer; thus, a pointer -// comparison is always sufficient. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique RenderStates, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * This method is not needed outside of the RenderState class because all + * equivalent RenderState objects are guaranteed to share the same pointer; + * thus, a pointer comparison is always sufficient. + */ int RenderState:: compare_to(const RenderState &other) const { SlotMask mask = _filled_slots | other._filled_slots; @@ -174,16 +161,13 @@ compare_to(const RenderState &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::compare_sort -// Access: Published -// Description: Returns -1, 0, or 1 according to the relative sorting -// of these two RenderStates, with regards to rendering -// performance, so that "heavier" RenderAttribs (as -// defined by RenderAttribRegistry::get_slot_sort()) are -// more likely to be grouped together. This is not -// related to the sorting order defined by compare_to. -//////////////////////////////////////////////////////////////////// +/** + * Returns -1, 0, or 1 according to the relative sorting of these two + * RenderStates, with regards to rendering performance, so that "heavier" + * RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are + * more likely to be grouped together. This is not related to the sorting + * order defined by compare_to. + */ int RenderState:: compare_sort(const RenderState &other) const { if (this == &other) { @@ -207,14 +191,11 @@ compare_sort(const RenderState &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::compare_mask -// Access: Published -// Description: This version of compare_to takes a slot mask that -// indicates which attributes to include in the -// comparison. Unlike compare_to, this method -// compares the attributes by pointer. -//////////////////////////////////////////////////////////////////// +/** + * This version of compare_to takes a slot mask that indicates which + * attributes to include in the comparison. Unlike compare_to, this method + * compares the attributes by pointer. + */ int RenderState:: compare_mask(const RenderState &other, SlotMask compare_mask) const { SlotMask mask = (_filled_slots | other._filled_slots) & compare_mask; @@ -232,14 +213,11 @@ compare_mask(const RenderState &other, SlotMask compare_mask) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::cull_callback -// Access: Published -// Description: Calls cull_callback() on each attrib. If any attrib -// returns false, interrupts the list and returns false -// immediately; otherwise, completes the list and -// returns true. -//////////////////////////////////////////////////////////////////// +/** + * Calls cull_callback() on each attrib. If any attrib returns false, + * interrupts the list and returns false immediately; otherwise, completes the + * list and returns true. + */ bool RenderState:: cull_callback(CullTraverser *trav, const CullTraverserData &data) const { SlotMask mask = _filled_slots; @@ -258,11 +236,9 @@ cull_callback(CullTraverser *trav, const CullTraverserData &data) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with one attribute set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with one attribute set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib *attrib, int override) { RenderState *state = new RenderState; @@ -272,11 +248,9 @@ make(const RenderAttrib *attrib, int override) { return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with two attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with two attributes set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib *attrib1, const RenderAttrib *attrib2, int override) { @@ -288,11 +262,9 @@ make(const RenderAttrib *attrib1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with three attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with three attributes set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib *attrib1, const RenderAttrib *attrib2, @@ -307,11 +279,9 @@ make(const RenderAttrib *attrib1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with four attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with four attributes set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib *attrib1, const RenderAttrib *attrib2, @@ -329,11 +299,9 @@ make(const RenderAttrib *attrib1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with five attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with five attributes set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib *attrib1, const RenderAttrib *attrib2, @@ -354,11 +322,9 @@ make(const RenderAttrib *attrib1, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make -// Access: Published, Static -// Description: Returns a RenderState with n attributes set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState with n attributes set. + */ CPT(RenderState) RenderState:: make(const RenderAttrib * const *attrib, int num_attribs, int override) { if (num_attribs == 0) { @@ -373,24 +339,20 @@ make(const RenderAttrib * const *attrib, int num_attribs, int override) { return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::compose -// Access: Published -// Description: Returns a new RenderState object that represents the -// composition of this state with the other state. -// -// The result of this operation is cached, and will be -// retained as long as both this RenderState object and -// the other RenderState object continue to exist. -// Should one of them destruct, the cached entry will be -// removed, and its pointer will be allowed to destruct -// as well. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the composition of this + * state with the other state. + * + * The result of this operation is cached, and will be retained as long as + * both this RenderState object and the other RenderState object continue to + * exist. Should one of them destruct, the cached entry will be removed, and + * its pointer will be allowed to destruct as well. + */ CPT(RenderState) RenderState:: compose(const RenderState *other) const { - // This method isn't strictly const, because it updates the cache, - // but we pretend that it is because it's only a cache which is - // transparent to the rest of the interface. + // This method isn't strictly const, because it updates the cache, but we + // pretend that it is because it's only a cache which is transparent to the + // rest of the interface. // We handle empty state (identity) as a trivial special case. if (is_empty()) { @@ -411,15 +373,15 @@ compose(const RenderState *other) const { if (index != -1) { Composition &comp = ((RenderState *)this)->_composition_cache.modify_data(index); if (comp._result == (const RenderState *)NULL) { - // Well, it wasn't cached already, but we already had an entry - // (probably created for the reverse direction), so use the same - // entry to store the new result. + // Well, it wasn't cached already, but we already had an entry (probably + // created for the reverse direction), so use the same entry to store + // the new result. CPT(RenderState) result = do_compose(other); comp._result = result; if (result != (const RenderState *)this) { - // See the comments below about the need to up the reference - // count only when the result is not the same as this. + // See the comments below about the need to up the reference count + // only when the result is not the same as this. result->cache_ref(); } } @@ -429,13 +391,12 @@ compose(const RenderState *other) const { } _cache_stats.inc_misses(); - // We need to make a new cache entry, both in this object and in the - // other object. We make both records so the other RenderState - // object will know to delete the entry from this object when it - // destructs, and vice-versa. + // We need to make a new cache entry, both in this object and in the other + // object. We make both records so the other RenderState object will know + // to delete the entry from this object when it destructs, and vice-versa. - // The cache entry in this object is the only one that indicates the - // result; the other will be NULL for now. + // The cache entry in this object is the only one that indicates the result; + // the other will be NULL for now. CPT(RenderState) result = do_compose(other); _cache_stats.add_total_size(1); @@ -450,15 +411,14 @@ compose(const RenderState *other) const { } if (result != (const RenderState *)this) { - // If the result of compose() is something other than this, - // explicitly increment the reference count. We have to be sure - // to decrement it again later, when the composition entry is - // removed from the cache. + // If the result of compose() is something other than this, explicitly + // increment the reference count. We have to be sure to decrement it + // again later, when the composition entry is removed from the cache. result->cache_ref(); - // (If the result was just this again, we still store the - // result, but we don't increment the reference count, since - // that would be a self-referential leak.) + // (If the result was just this again, we still store the result, but we + // don't increment the reference count, since that would be a self- + // referential leak.) } _cache_stats.maybe_report("RenderState"); @@ -466,29 +426,25 @@ compose(const RenderState *other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::invert_compose -// Access: Published -// Description: Returns a new RenderState object that represents the -// composition of this state's inverse with the other -// state. -// -// This is similar to compose(), but is particularly -// useful for computing the relative state of a node as -// viewed from some other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the composition of this + * state's inverse with the other state. + * + * This is similar to compose(), but is particularly useful for computing the + * relative state of a node as viewed from some other node. + */ CPT(RenderState) RenderState:: invert_compose(const RenderState *other) const { - // This method isn't strictly const, because it updates the cache, - // but we pretend that it is because it's only a cache which is - // transparent to the rest of the interface. + // This method isn't strictly const, because it updates the cache, but we + // pretend that it is because it's only a cache which is transparent to the + // rest of the interface. // We handle empty state (identity) as a trivial special case. if (is_empty()) { return other; } - // Unlike compose(), the case of other->is_empty() is not quite as - // trivial for invert_compose(). + // Unlike compose(), the case of other->is_empty() is not quite as trivial + // for invert_compose(). if (other == this) { // a->invert_compose(a) always produces identity. @@ -506,15 +462,15 @@ invert_compose(const RenderState *other) const { if (index != -1) { Composition &comp = ((RenderState *)this)->_invert_composition_cache.modify_data(index); if (comp._result == (const RenderState *)NULL) { - // Well, it wasn't cached already, but we already had an entry - // (probably created for the reverse direction), so use the same - // entry to store the new result. + // Well, it wasn't cached already, but we already had an entry (probably + // created for the reverse direction), so use the same entry to store + // the new result. CPT(RenderState) result = do_invert_compose(other); comp._result = result; if (result != (const RenderState *)this) { - // See the comments below about the need to up the reference - // count only when the result is not the same as this. + // See the comments below about the need to up the reference count + // only when the result is not the same as this. result->cache_ref(); } } @@ -524,13 +480,12 @@ invert_compose(const RenderState *other) const { } _cache_stats.inc_misses(); - // We need to make a new cache entry, both in this object and in the - // other object. We make both records so the other RenderState - // object will know to delete the entry from this object when it - // destructs, and vice-versa. + // We need to make a new cache entry, both in this object and in the other + // object. We make both records so the other RenderState object will know + // to delete the entry from this object when it destructs, and vice-versa. - // The cache entry in this object is the only one that indicates the - // result; the other will be NULL for now. + // The cache entry in this object is the only one that indicates the result; + // the other will be NULL for now. CPT(RenderState) result = do_invert_compose(other); _cache_stats.add_total_size(1); @@ -544,29 +499,24 @@ invert_compose(const RenderState *other) const { } if (result != (const RenderState *)this) { - // If the result of compose() is something other than this, - // explicitly increment the reference count. We have to be sure - // to decrement it again later, when the composition entry is - // removed from the cache. + // If the result of compose() is something other than this, explicitly + // increment the reference count. We have to be sure to decrement it + // again later, when the composition entry is removed from the cache. result->cache_ref(); - // (If the result was just this again, we still store the - // result, but we don't increment the reference count, since - // that would be a self-referential leak.) + // (If the result was just this again, we still store the result, but we + // don't increment the reference count, since that would be a self- + // referential leak.) } return result; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::add_attrib -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with the new RenderAttrib -// added. If there is already a RenderAttrib with the -// same type, it is replaced (unless the override is -// lower). -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with the new RenderAttrib added. If there is already a RenderAttrib + * with the same type, it is replaced (unless the override is lower). + */ CPT(RenderState) RenderState:: add_attrib(const RenderAttrib *attrib, int override) const { int slot = attrib->get_slot(); @@ -583,15 +533,12 @@ add_attrib(const RenderAttrib *attrib, int override) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::set_attrib -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with the new RenderAttrib -// added. If there is already a RenderAttrib with the -// same type, it is replaced unconditionally. The -// override is not changed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with the new RenderAttrib added. If there is already a RenderAttrib + * with the same type, it is replaced unconditionally. The override is not + * changed. + */ CPT(RenderState) RenderState:: set_attrib(const RenderAttrib *attrib) const { RenderState *new_state = new RenderState(*this); @@ -601,15 +548,12 @@ set_attrib(const RenderAttrib *attrib) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::set_attrib -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with the new RenderAttrib -// added. If there is already a RenderAttrib with the -// same type, it is replaced unconditionally. The -// override is also replaced unconditionally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with the new RenderAttrib added. If there is already a RenderAttrib + * with the same type, it is replaced unconditionally. The override is also + * replaced unconditionally. + */ CPT(RenderState) RenderState:: set_attrib(const RenderAttrib *attrib, int override) const { RenderState *new_state = new RenderState(*this); @@ -619,13 +563,10 @@ set_attrib(const RenderAttrib *attrib, int override) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::remove_attrib -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with the indicated -// RenderAttrib removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with the indicated RenderAttrib removed. + */ CPT(RenderState) RenderState:: remove_attrib(int slot) const { if (_attributes[slot]._attrib == NULL) { @@ -644,15 +585,12 @@ remove_attrib(int slot) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::adjust_all_priorities -// Access: Published -// Description: Returns a new RenderState object that represents the -// same as the source state, with all attributes' -// override values incremented (or decremented, if -// negative) by the indicated amount. If the override -// would drop below zero, it is set to zero. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderState object that represents the same as the source + * state, with all attributes' override values incremented (or decremented, if + * negative) by the indicated amount. If the override would drop below zero, + * it is set to zero. + */ CPT(RenderState) RenderState:: adjust_all_priorities(int adjustment) const { RenderState *new_state = new RenderState(*this); @@ -671,41 +609,36 @@ adjust_all_priorities(int adjustment) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// check whether the remaining reference count is -// entirely in the cache, and if so, it checks for and -// breaks a cycle in the cache involving this object. -// This is designed to prevent leaks from cyclical -// references within the cache. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to check whether the + * remaining reference count is entirely in the cache, and if so, it checks + * for and breaks a cycle in the cache involving this object. This is + * designed to prevent leaks from cyclical references within the cache. + */ bool RenderState:: unref() const { if (!state_cache || garbage_collect_states) { - // If we're not using the cache at all, or if we're relying on - // garbage collection, just allow the pointer to unref normally. + // If we're not using the cache at all, or if we're relying on garbage + // collection, just allow the pointer to unref normally. return ReferenceCount::unref(); } - // Here is the normal refcounting case, with a normal cache, and - // without garbage collection in effect. In this case we will pull - // the object out of the cache when its reference count goes to 0. + // Here is the normal refcounting case, with a normal cache, and without + // garbage collection in effect. In this case we will pull the object out + // of the cache when its reference count goes to 0. - // We always have to grab the lock, since we will definitely need to - // be holding it if we happen to drop the reference count to 0. - // Having to grab the lock at every call to unref() is a big - // limiting factor on parallelization. + // We always have to grab the lock, since we will definitely need to be + // holding it if we happen to drop the reference count to 0. Having to grab + // the lock at every call to unref() is a big limiting factor on + // parallelization. LightReMutexHolder holder(*_states_lock); if (auto_break_cycles && uniquify_states) { if (get_cache_ref_count() > 0 && get_ref_count() == get_cache_ref_count() + 1) { - // If we are about to remove the one reference that is not in the - // cache, leaving only references in the cache, then we need to - // check for a cycle involving this RenderState and break it if - // it exists. + // If we are about to remove the one reference that is not in the cache, + // leaving only references in the cache, then we need to check for a + // cycle involving this RenderState and break it if it exists. ((RenderState *)this)->detect_and_break_cycles(); } } @@ -715,30 +648,25 @@ unref() const { return true; } - // The reference count has just reached zero. Make sure the object - // is removed from the global object pool, before anyone else finds - // it and tries to ref it. + // The reference count has just reached zero. Make sure the object is + // removed from the global object pool, before anyone else finds it and + // tries to ref it. ((RenderState *)this)->release_new(); ((RenderState *)this)->remove_cache_pointers(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_auto_shader_state -// Access: Published -// Description: Returns the base RenderState that should have the -// generated_shader stored within it, for generated -// shader states. The returned object might be the same -// as this object, or it might be a different -// RenderState with certain attributes removed, or set -// to their default values. -// -// The point is to avoid needless regeneration of the -// shader attrib by storing the generated shader on a -// common RenderState object, with all irrelevant -// attributes removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the base RenderState that should have the generated_shader stored + * within it, for generated shader states. The returned object might be the + * same as this object, or it might be a different RenderState with certain + * attributes removed, or set to their default values. + * + * The point is to avoid needless regeneration of the shader attrib by storing + * the generated shader on a common RenderState object, with all irrelevant + * attributes removed. + */ const RenderState *RenderState:: get_auto_shader_state() const { if (_auto_shader_state == (const RenderState *)NULL) { @@ -747,11 +675,9 @@ get_auto_shader_state() const { return _auto_shader_state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderState:: output(ostream &out) const { out << "S:"; @@ -777,11 +703,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RenderState:: write(ostream &out, int indent_level) const { if (is_empty()) { @@ -801,28 +725,21 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_max_priority -// Access: Published, Static -// Description: Returns the maximum priority number (sometimes called -// override) that may be set on any node. This may or -// may not be enforced, but the scene graph code assumes -// that no priority numbers will be larger than this, -// and some effects may not work properly if you use a -// larger number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum priority number (sometimes called override) that may be + * set on any node. This may or may not be enforced, but the scene graph code + * assumes that no priority numbers will be larger than this, and some effects + * may not work properly if you use a larger number. + */ int RenderState:: get_max_priority() { return 1000000000; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_num_states -// Access: Published, Static -// Description: Returns the total number of unique RenderState -// objects allocated in the world. This will go up and -// down during normal operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique RenderState objects allocated in the + * world. This will go up and down during normal operations. + */ int RenderState:: get_num_states() { if (_states == (States *)NULL) { @@ -832,24 +749,19 @@ get_num_states() { return _states->get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_num_unused_states -// Access: Published, Static -// Description: Returns the total number of RenderState objects that -// have been allocated but have no references outside of -// the internal RenderState cache. -// -// A nonzero return value is not necessarily indicative -// of leaked references; it is normal for two -// RenderState objects, both of which have references -// held outside the cache, to have to result of their -// composition stored within the cache. This result -// will be retained within the cache until one of the -// base RenderStates is released. -// -// Use list_cycles() to get an idea of the number of -// actual "leaked" RenderState objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of RenderState objects that have been allocated + * but have no references outside of the internal RenderState cache. + * + * A nonzero return value is not necessarily indicative of leaked references; + * it is normal for two RenderState objects, both of which have references + * held outside the cache, to have to result of their composition stored + * within the cache. This result will be retained within the cache until one + * of the base RenderStates is released. + * + * Use list_cycles() to get an idea of the number of actual "leaked" + * RenderState objects. + */ int RenderState:: get_num_unused_states() { if (_states == (States *)NULL) { @@ -857,8 +769,8 @@ get_num_unused_states() { } LightReMutexHolder holder(*_states_lock); - // First, we need to count the number of times each RenderState - // object is recorded in the cache. + // First, we need to count the number of times each RenderState object is + // recorded in the cache. typedef pmap StateCount; StateCount state_count; @@ -875,13 +787,12 @@ get_num_unused_states() { if (state->_composition_cache.has_element(i)) { const RenderState *result = state->_composition_cache.get_data(i)._result; if (result != (const RenderState *)NULL && result != state) { - // Here's a RenderState that's recorded in the cache. - // Count it. + // Here's a RenderState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { - // If the above insert operation fails, then it's already in - // the cache; increment its value. + // If the above insert operation fails, then it's already in the + // cache; increment its value. (*(ir.first)).second++; } } @@ -902,9 +813,9 @@ get_num_unused_states() { } } - // Now that we have the appearance count of each RenderState - // object, we can tell which ones are unreferenced outside of the - // RenderState cache, by comparing these to the reference counts. + // Now that we have the appearance count of each RenderState object, we can + // tell which ones are unreferenced outside of the RenderState cache, by + // comparing these to the reference counts. int num_unused = 0; StateCount::iterator sci; @@ -928,26 +839,19 @@ get_num_unused_states() { return num_unused; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::clear_cache -// Access: Published, Static -// Description: Empties the cache of composed RenderStates. This -// makes every RenderState forget what results when -// it is composed with other RenderStates. -// -// This will eliminate any RenderState objects that -// have been allocated but have no references outside of -// the internal RenderState map. It will not -// eliminate RenderState objects that are still in -// use. -// -// Nowadays, this method should not be necessary, as -// reference-count cycles in the composition cache -// should be automatically detected and broken. -// -// The return value is the number of RenderStates -// freed by this operation. -//////////////////////////////////////////////////////////////////// +/** + * Empties the cache of composed RenderStates. This makes every RenderState + * forget what results when it is composed with other RenderStates. + * + * This will eliminate any RenderState objects that have been allocated but + * have no references outside of the internal RenderState map. It will not + * eliminate RenderState objects that are still in use. + * + * Nowadays, this method should not be necessary, as reference-count cycles in + * the composition cache should be automatically detected and broken. + * + * The return value is the number of RenderStates freed by this operation. + */ int RenderState:: clear_cache() { if (_states == (States *)NULL) { @@ -958,10 +862,10 @@ clear_cache() { PStatTimer timer(_cache_update_pcollector); int orig_size = _states->get_num_entries(); - // First, we need to copy the entire set of states to a temporary - // vector, reference-counting each object. That way we can walk - // through the copy, without fear of dereferencing (and deleting) - // the objects in the map as we go. + // First, we need to copy the entire set of states to a temporary vector, + // reference-counting each object. That way we can walk through the copy, + // without fear of dereferencing (and deleting) the objects in the map as we + // go. { typedef pvector< CPT(RenderState) > TempStates; TempStates temp_states; @@ -976,9 +880,8 @@ clear_cache() { temp_states.push_back(state); } - // Now it's safe to walk through the list, destroying the cache - // within each object as we go. Nothing will be destructed till - // we're done. + // Now it's safe to walk through the list, destroying the cache within + // each object as we go. Nothing will be destructed till we're done. TempStates::iterator ti; for (ti = temp_states.begin(); ti != temp_states.end(); ++ti) { RenderState *state = (RenderState *)(*ti).p(); @@ -1011,28 +914,23 @@ clear_cache() { state->_invert_composition_cache.clear(); } - // Once this block closes and the temp_states object goes away, - // all the destruction will begin. Anything whose reference was - // held only within the various objects' caches will go away. + // Once this block closes and the temp_states object goes away, all the + // destruction will begin. Anything whose reference was held only within + // the various objects' caches will go away. } int new_size = _states->get_num_entries(); return orig_size - new_size; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::garbage_collect -// Access: Published, Static -// Description: Performs a garbage-collection cycle. This must be -// called periodically if garbage-collect-states is true -// to ensure that RenderStates get cleaned up -// appropriately. It does no harm to call it even if -// this variable is not true, but there is probably no -// advantage in that case. -// -// This automatically calls -// RenderAttrib::garbage_collect() as well. -//////////////////////////////////////////////////////////////////// +/** + * Performs a garbage-collection cycle. This must be called periodically if + * garbage-collect-states is true to ensure that RenderStates get cleaned up + * appropriately. It does no harm to call it even if this variable is not + * true, but there is probably no advantage in that case. + * + * This automatically calls RenderAttrib::garbage_collect() as well. + */ int RenderState:: garbage_collect() { int num_attribs = RenderAttrib::garbage_collect(); @@ -1063,21 +961,20 @@ garbage_collect() { if (auto_break_cycles && uniquify_states) { if (state->get_cache_ref_count() > 0 && state->get_ref_count() == state->get_cache_ref_count()) { - // If we have removed all the references to this state not in - // the cache, leaving only references in the cache, then we - // need to check for a cycle involving this RenderState and - // break it if it exists. + // If we have removed all the references to this state not in the + // cache, leaving only references in the cache, then we need to + // check for a cycle involving this RenderState and break it if it + // exists. state->detect_and_break_cycles(); } } if (state->get_ref_count() == 1) { - // This state has recently been unreffed to 1 (the one we - // added when we stored it in the cache). Now it's time to - // delete it. This is safe, because we're holding the - // _states_lock, so it's not possible for some other thread to - // find the state in the cache and ref it while we're doing - // this. + // This state has recently been unreffed to 1 (the one we added when + // we stored it in the cache). Now it's time to delete it. This is + // safe, because we're holding the _states_lock, so it's not possible + // for some other thread to find the state in the cache and ref it + // while we're doing this. state->release_new(); state->remove_cache_pointers(); state->cache_unref(); @@ -1094,13 +991,10 @@ garbage_collect() { return orig_size - new_size + num_attribs; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::clear_munger_cache -// Access: Published, Static -// Description: Completely empties the cache of state + gsg -> -// munger, for all states and all gsg's. Normally there -// is no need to empty this cache. -//////////////////////////////////////////////////////////////////// +/** + * Completely empties the cache of state + gsg -> munger, for all states and + * all gsg's. Normally there is no need to empty this cache. + */ void RenderState:: clear_munger_cache() { LightReMutexHolder holder(*_states_lock); @@ -1116,24 +1010,19 @@ clear_munger_cache() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::list_cycles -// Access: Published, Static -// Description: Detects all of the reference-count cycles in the -// cache and reports them to standard output. -// -// These cycles may be inadvertently created when state -// compositions cycle back to a starting point. -// Nowadays, these cycles should be automatically -// detected and broken, so this method should never list -// any cycles unless there is a bug in that detection -// logic. -// -// The cycles listed here are not leaks in the strictest -// sense of the word, since they can be reclaimed by a -// call to clear_cache(); but they will not be reclaimed -// automatically. -//////////////////////////////////////////////////////////////////// +/** + * Detects all of the reference-count cycles in the cache and reports them to + * standard output. + * + * These cycles may be inadvertently created when state compositions cycle + * back to a starting point. Nowadays, these cycles should be automatically + * detected and broken, so this method should never list any cycles unless + * there is a bug in that detection logic. + * + * The cycles listed here are not leaks in the strictest sense of the word, + * since they can be reclaimed by a call to clear_cache(); but they will not + * be reclaimed automatically. + */ void RenderState:: list_cycles(ostream &out) { if (_states == (States *)NULL) { @@ -1209,13 +1098,11 @@ list_cycles(ostream &out) { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::list_states -// Access: Published, Static -// Description: Lists all of the RenderStates in the cache to the -// output stream, one per line. This can be quite a lot -// of output if the cache is large, so be prepared. -//////////////////////////////////////////////////////////////////// +/** + * Lists all of the RenderStates in the cache to the output stream, one per + * line. This can be quite a lot of output if the cache is large, so be + * prepared. + */ void RenderState:: list_states(ostream &out) { if (_states == (States *)NULL) { @@ -1236,16 +1123,12 @@ list_states(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::validate_states -// Access: Published, Static -// Description: Ensures that the cache is still stored in sorted -// order, and that none of the cache elements have been -// inadvertently deleted. Returns true if so, false if -// there is a problem (which implies someone has -// modified one of the supposedly-const RenderState -// objects). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the cache is still stored in sorted order, and that none of + * the cache elements have been inadvertently deleted. Returns true if so, + * false if there is a problem (which implies someone has modified one of the + * supposedly-const RenderState objects). + */ bool RenderState:: validate_states() { if (_states == (States *)NULL) { @@ -1306,14 +1189,11 @@ validate_states() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::get_geom_rendering -// Access: Published -// Description: Returns the union of the Geom::GeomRendering bits -// that will be required once this RenderState is -// applied to a geom which includes the indicated -// geom_rendering bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the Geom::GeomRendering bits that will be required + * once this RenderState is applied to a geom which includes the indicated + * geom_rendering bits. + */ int RenderState:: get_geom_rendering(int geom_rendering) const { const RenderModeAttrib *render_mode; @@ -1333,27 +1213,21 @@ get_geom_rendering(int geom_rendering) const { return geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::bin_removed -// Access: Public, Static -// Description: Intended to be called by -// CullBinManager::remove_bin(), this informs all the -// RenderStates in the world to remove the indicated -// bin_index from their cache if it has been cached. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called by CullBinManager::remove_bin(), this informs all the + * RenderStates in the world to remove the indicated bin_index from their + * cache if it has been cached. + */ void RenderState:: bin_removed(int bin_index) { // Do something here. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::validate_filled_slots -// Access: Private -// Description: Returns true if the _filled_slots bitmask is -// consistent with the table of RenderAttrib pointers, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the _filled_slots bitmask is consistent with the table of + * RenderAttrib pointers, false otherwise. + */ bool RenderState:: validate_filled_slots() const { SlotMask mask; @@ -1370,11 +1244,9 @@ validate_filled_slots() const { return (mask == _filled_slots); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_calc_hash -// Access: Private -// Description: Computes a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Computes a suitable hash value for phash_map. + */ void RenderState:: do_calc_hash() { _hash = 0; @@ -1394,13 +1266,11 @@ do_calc_hash() { _flags |= F_hash_known; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::assign_auto_shader_state -// Access: Private -// Description: Sets _auto_shader_state to the appropriate -// RenderState object pointer, either the same pointer -// as this object, or some other (simpler) RenderState. -//////////////////////////////////////////////////////////////////// +/** + * Sets _auto_shader_state to the appropriate RenderState object pointer, + * either the same pointer as this object, or some other (simpler) + * RenderState. + */ void RenderState:: assign_auto_shader_state() { CPT(RenderState) state = do_calc_auto_shader_state(); @@ -1416,13 +1286,10 @@ assign_auto_shader_state() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_calc_auto_shader_state -// Access: Private -// Description: Returns the appropriate RenderState that should be -// used to store the auto shader pointer for nodes that -// shader this RenderState. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate RenderState that should be used to store the auto + * shader pointer for nodes that shader this RenderState. + */ CPT(RenderState) RenderState:: do_calc_auto_shader_state() { RenderState *state = new RenderState; @@ -1447,22 +1314,19 @@ do_calc_auto_shader_state() { } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::return_new -// Access: Private, Static -// Description: This function is used to share a common RenderState -// pointer for all equivalent RenderState objects. -// -// This is different from return_unique() in that it -// does not actually guarantee a unique pointer, unless -// uniquify-states is set. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to share a common RenderState pointer for all + * equivalent RenderState objects. + * + * This is different from return_unique() in that it does not actually + * guarantee a unique pointer, unless uniquify-states is set. + */ CPT(RenderState) RenderState:: return_new(RenderState *state) { nassertr(state != (RenderState *)NULL, state); - // Make sure we don't have anything in the 0 slot. If we did, that - // would indicate an uninitialized slot number. + // Make sure we don't have anything in the 0 slot. If we did, that would + // indicate an uninitialized slot number. #ifndef NDEBUG if (state->_attributes[0]._attrib != (RenderAttrib *)NULL) { const RenderAttrib *attrib = state->_attributes[0]._attrib; @@ -1495,18 +1359,14 @@ return_new(RenderState *state) { return return_unique(state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::return_unique -// Access: Private, Static -// Description: This function is used to share a common RenderState -// pointer for all equivalent RenderState objects. -// -// See the similar logic in RenderAttrib. The idea is -// to create a new RenderState object and pass it -// through this function, which will share the pointer -// with a previously-created RenderState object if it is -// equivalent. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to share a common RenderState pointer for all + * equivalent RenderState objects. + * + * See the similar logic in RenderAttrib. The idea is to create a new + * RenderState object and pass it through this function, which will share the + * pointer with a previously-created RenderState object if it is equivalent. + */ CPT(RenderState) RenderState:: return_unique(RenderState *state) { nassertr(state != (RenderState *)NULL, NULL); @@ -1524,13 +1384,13 @@ return_unique(RenderState *state) { LightReMutexHolder holder(*_states_lock); if (state->_saved_entry != -1) { - // This state is already in the cache. - //nassertr(_states->find(state) == state->_saved_entry, pt_state); + // This state is already in the cache. nassertr(_states->find(state) == + // state->_saved_entry, pt_state); return state; } - // Ensure each of the individual attrib pointers has been uniquified - // before we add the state to the cache. + // Ensure each of the individual attrib pointers has been uniquified before + // we add the state to the cache. if (!uniquify_attribs && !state->is_empty()) { SlotMask mask = state->_filled_slots; int slot = mask.get_lowest_on_bit(); @@ -1545,9 +1405,9 @@ return_unique(RenderState *state) { int si = _states->find(state); if (si != -1) { - // There's an equivalent state already in the set. Return it. - // The state that was passed may be newly created and therefore - // may not be automatically deleted. Do that if necessary. + // There's an equivalent state already in the set. Return it. The state + // that was passed may be newly created and therefore may not be + // automatically deleted. Do that if necessary. if (state->get_ref_count() == 0) { delete state; } @@ -1556,9 +1416,9 @@ return_unique(RenderState *state) { // Not already in the set; add it. if (garbage_collect_states) { - // If we'll be garbage collecting states explicitly, we'll - // increment the reference count when we store it in the cache, so - // that it won't be deleted while it's in it. + // If we'll be garbage collecting states explicitly, we'll increment the + // reference count when we store it in the cache, so that it won't be + // deleted while it's in it. state->cache_ref(); } si = _states->store(state, Empty()); @@ -1568,13 +1428,10 @@ return_unique(RenderState *state) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_compose -// Access: Private -// Description: The private implemention of compose(); this actually -// composes two RenderStates, without bothering with the -// cache. -//////////////////////////////////////////////////////////////////// +/** + * The private implemention of compose(); this actually composes two + * RenderStates, without bothering with the cache. + */ CPT(RenderState) RenderState:: do_compose(const RenderState *other) const { PStatTimer timer(_state_compose_pcollector); @@ -1605,18 +1462,17 @@ do_compose(const RenderState *other) const { } else if (a._override < b._override && a._attrib->lower_attrib_can_override()) { - // B, the higher RenderAttrib, overrides. This is a special - // case; normally, a lower RenderAttrib does not override a - // higher one, even if it has a higher override value. But - // certain kinds of RenderAttribs redefine - // lower_attrib_can_override() to return true, allowing this - // override. + // B, the higher RenderAttrib, overrides. This is a special case; + // normally, a lower RenderAttrib does not override a higher one, even + // if it has a higher override value. But certain kinds of + // RenderAttribs redefine lower_attrib_can_override() to return true, + // allowing this override. result = b; } else { - // Either they have the same override value, or B is higher. - // In either case, the result is the composition of the two, - // with B's override value. + // Either they have the same override value, or B is higher. In either + // case, the result is the composition of the two, with B's override + // value. result.set(a._attrib->compose(b._attrib), b._override); } @@ -1627,11 +1483,9 @@ do_compose(const RenderState *other) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::do_invert_compose -// Access: Private -// Description: The private implemention of invert_compose(). -//////////////////////////////////////////////////////////////////// +/** + * The private implemention of invert_compose(). + */ CPT(RenderState) RenderState:: do_invert_compose(const RenderState *other) const { PStatTimer timer(_state_invert_pcollector); @@ -1658,8 +1512,7 @@ do_invert_compose(const RenderState *other) const { result.set(a._attrib->invert_compose(reg->get_slot_default(slot)), 0); } else { - // Both are good. (Overrides are not used in invert_compose.) - // Compose. + // Both are good. (Overrides are not used in invert_compose.) Compose. result.set(a._attrib->invert_compose(b._attrib), 0); } @@ -1669,21 +1522,18 @@ do_invert_compose(const RenderState *other) const { return return_new(new_state); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::detect_and_break_cycles -// Access: Private -// Description: Detects whether there is a cycle in the cache that -// begins with this state. If any are detected, breaks -// them by removing this state from the cache. -//////////////////////////////////////////////////////////////////// +/** + * Detects whether there is a cycle in the cache that begins with this state. + * If any are detected, breaks them by removing this state from the cache. + */ void RenderState:: detect_and_break_cycles() { PStatTimer timer(_state_break_cycles_pcollector); ++_last_cycle_detect; if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { - // Ok, we have a cycle. This will be a leak unless we break the - // cycle by freeing the cache on this object. + // Ok, we have a cycle. This will be a leak unless we break the cycle by + // freeing the cache on this object. if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1703,17 +1553,13 @@ detect_and_break_cycles() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::r_detect_cycles -// Access: Private, Static -// Description: Detects whether there is a cycle in the cache that -// begins with the indicated state. Returns true if at -// least one cycle is found, false if this state is not -// part of any cycles. If a cycle is found and -// cycle_desc is not NULL, then cycle_desc is filled in -// with the list of the steps of the cycle, in reverse -// order. -//////////////////////////////////////////////////////////////////// +/** + * Detects whether there is a cycle in the cache that begins with the + * indicated state. Returns true if at least one cycle is found, false if + * this state is not part of any cycles. If a cycle is found and cycle_desc + * is not NULL, then cycle_desc is filled in with the list of the steps of the + * cycle, in reverse order. + */ bool RenderState:: r_detect_cycles(const RenderState *start_state, const RenderState *current_state, @@ -1722,10 +1568,9 @@ r_detect_cycles(const RenderState *start_state, if (current_state->_cycle_detect == this_seq) { // We've already seen this state; therefore, we've found a cycle. - // However, we only care about cycles that return to the starting - // state and involve more than two steps. If only one or two - // nodes are involved, it doesn't represent a memory leak, so no - // problem there. + // However, we only care about cycles that return to the starting state + // and involve more than two steps. If only one or two nodes are + // involved, it doesn't represent a memory leak, so no problem there. return (current_state == start_state && length > 2); } ((RenderState *)current_state)->_cycle_detect = this_seq; @@ -1773,14 +1618,11 @@ r_detect_cycles(const RenderState *start_state, return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::r_detect_reverse_cycles -// Access: Private, Static -// Description: Works the same as r_detect_cycles, but checks for -// cycles in the reverse direction along the cache -// chain. (A cycle may appear in either direction, and -// we must check both.) -//////////////////////////////////////////////////////////////////// +/** + * Works the same as r_detect_cycles, but checks for cycles in the reverse + * direction along the cache chain. (A cycle may appear in either direction, + * and we must check both.) + */ bool RenderState:: r_detect_reverse_cycles(const RenderState *start_state, const RenderState *current_state, @@ -1789,10 +1631,9 @@ r_detect_reverse_cycles(const RenderState *start_state, if (current_state->_cycle_detect == this_seq) { // We've already seen this state; therefore, we've found a cycle. - // However, we only care about cycles that return to the starting - // state and involve more than two steps. If only one or two - // nodes are involved, it doesn't represent a memory leak, so no - // problem there. + // However, we only care about cycles that return to the starting state + // and involve more than two steps. If only one or two nodes are + // involved, it doesn't represent a memory leak, so no problem there. return (current_state == start_state && length > 2); } ((RenderState *)current_state)->_cycle_detect = this_seq; @@ -1852,38 +1693,31 @@ r_detect_reverse_cycles(const RenderState *start_state, return false; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::release_new -// Access: Private -// Description: This inverse of return_new, this releases this object -// from the global RenderState table. -// -// You must already be holding _states_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * This inverse of return_new, this releases this object from the global + * RenderState table. + * + * You must already be holding _states_lock before you call this method. + */ void RenderState:: release_new() { nassertv(_states_lock->debug_is_locked()); if (_saved_entry != -1) { - //nassertv(_states->find(this) == _saved_entry); + // nassertv(_states->find(this) == _saved_entry); _saved_entry = _states->find(this); _states->remove_element(_saved_entry); _saved_entry = -1; } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::remove_cache_pointers -// Access: Private -// Description: Remove all pointers within the cache from and to this -// particular RenderState. The pointers to this -// object may be scattered around in the various -// CompositionCaches from other RenderState objects. -// -// You must already be holding _states_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * Remove all pointers within the cache from and to this particular + * RenderState. The pointers to this object may be scattered around in the + * various CompositionCaches from other RenderState objects. + * + * You must already be holding _states_lock before you call this method. + */ void RenderState:: remove_cache_pointers() { nassertv(_states_lock->debug_is_locked()); @@ -1896,20 +1730,19 @@ remove_cache_pointers() { _auto_shader_state = NULL; } - // Fortunately, since we added CompositionCache records in pairs, we - // know exactly the set of RenderState objects that have us in their - // cache: it's the same set of RenderState objects that we have in - // our own cache. + // Fortunately, since we added CompositionCache records in pairs, we know + // exactly the set of RenderState objects that have us in their cache: it's + // the same set of RenderState objects that we have in our own cache. - // We do need to put considerable thought into this loop, because as - // we clear out cache entries we'll cause other RenderState - // objects to destruct, which could cause things to get pulled out - // of our own _composition_cache map. We want to allow this (so - // that we don't encounter any just-destructed pointers in our - // cache), but we don't want to get bitten by this cascading effect. - // Instead of walking through the map from beginning to end, - // therefore, we just pull out the first one each time, and erase - // it. +/* + * We do need to put considerable thought into this loop, because as we clear + * out cache entries we'll cause other RenderState objects to destruct, which + * could cause things to get pulled out of our own _composition_cache map. We + * want to allow this (so that we don't encounter any just-destructed pointers + * in our cache), but we don't want to get bitten by this cascading effect. + * Instead of walking through the map from beginning to end, therefore, we + * just pull out the first one each time, and erase it. + */ #ifdef DO_PSTATS if (_composition_cache.is_empty() && _invert_composition_cache.is_empty()) { @@ -1918,8 +1751,8 @@ remove_cache_pointers() { PStatTimer timer(_cache_update_pcollector); #endif // DO_PSTATS - // There are lots of ways to do this loop wrong. Be very careful if - // you need to modify it for any reason. + // There are lots of ways to do this loop wrong. Be very careful if you + // need to modify it for any reason. int i = 0; while (!_composition_cache.is_empty()) { // Scan for the next used slot in the table. @@ -1927,23 +1760,21 @@ remove_cache_pointers() { ++i; } - // It is possible that the "other" RenderState object is - // currently within its own destructor. We therefore can't use a - // PT() to hold its pointer; that could end up calling its - // destructor twice. Fortunately, we don't need to hold its - // reference count to ensure it doesn't destruct while we process - // this loop; as long as we ensure that no *other* RenderState + // It is possible that the "other" RenderState object is currently within + // its own destructor. We therefore can't use a PT() to hold its pointer; + // that could end up calling its destructor twice. Fortunately, we don't + // need to hold its reference count to ensure it doesn't destruct while we + // process this loop; as long as we ensure that no *other* RenderState // objects destruct, there will be no reason for that one to. RenderState *other = (RenderState *)_composition_cache.get_key(i); - // We hold a copy of the composition result so we can dereference - // it later. + // We hold a copy of the composition result so we can dereference it + // later. Composition comp = _composition_cache.get_data(i); - // Now we can remove the element from our cache. We do this now, - // rather than later, before any other RenderState objects have - // had a chance to destruct, so we are confident that our iterator - // is still valid. + // Now we can remove the element from our cache. We do this now, rather + // than later, before any other RenderState objects have had a chance to + // destruct, so we are confident that our iterator is still valid. _composition_cache.remove_element(i); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); @@ -1951,9 +1782,8 @@ remove_cache_pointers() { if (other != this) { int oi = other->_composition_cache.find(this); - // We may or may not still be listed in the other's cache (it - // might be halfway through pulling entries out, from within its - // own destructor). + // We may or may not still be listed in the other's cache (it might be + // halfway through pulling entries out, from within its own destructor). if (oi != -1) { // Hold a copy of the other composition result, too. Composition ocomp = other->_composition_cache.get_data(oi); @@ -1962,18 +1792,17 @@ remove_cache_pointers() { _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - // It's finally safe to let our held pointers go away. This may - // have cascading effects as other RenderState objects are - // destructed, but there will be no harm done if they destruct - // now. + // It's finally safe to let our held pointers go away. This may have + // cascading effects as other RenderState objects are destructed, but + // there will be no harm done if they destruct now. if (ocomp._result != (const RenderState *)NULL && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - // It's finally safe to let our held pointers go away. (See - // comment above.) + // It's finally safe to let our held pointers go away. (See comment + // above.) if (comp._result != (const RenderState *)NULL && comp._result != this) { cache_unref_delete(comp._result); } @@ -2010,12 +1839,9 @@ remove_cache_pointers() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::determine_bin_index -// Access: Private -// Description: This is the private implementation of -// get_bin_index() and get_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of get_bin_index() and get_draw_order(). + */ void RenderState:: determine_bin_index() { LightMutexHolder holder(_lock); @@ -2034,9 +1860,8 @@ determine_bin_index() { } if (bin_name.empty()) { - // No explicit bin is specified; put in the in the default bin, - // either opaque or transparent, based on the transparency - // setting. + // No explicit bin is specified; put in the in the default bin, either + // opaque or transparent, based on the transparency setting. bin_name = "opaque"; const TransparencyAttrib *transparency = DCAST(TransparencyAttrib, get_attrib(TransparencyAttrib::get_class_slot())); @@ -2064,11 +1889,9 @@ determine_bin_index() { _flags |= F_checked_bin_index; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::determine_cull_callback -// Access: Private -// Description: This is the private implementation of has_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * This is the private implementation of has_cull_callback(). + */ void RenderState:: determine_cull_callback() { LightMutexHolder holder(_lock); @@ -2094,11 +1917,9 @@ determine_cull_callback() { _flags |= F_checked_cull_callback; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::fill_default -// Access: Private -// Description: Fills up the state with all of the default attribs. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the state with all of the default attribs. + */ void RenderState:: fill_default() { RenderAttribRegistry *reg = RenderAttribRegistry::quick_get_global_ptr(); @@ -2109,14 +1930,11 @@ fill_default() { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::update_pstats -// Access: Private -// Description: Moves the RenderState object from one PStats category -// to another, so that we can track in PStats how many -// pointers are held by nodes, and how many are held in -// the cache only. -//////////////////////////////////////////////////////////////////// +/** + * Moves the RenderState object from one PStats category to another, so that + * we can track in PStats how many pointers are held by nodes, and how many + * are held in the cache only. + */ void RenderState:: update_pstats(int old_referenced_bits, int new_referenced_bits) { #ifdef DO_PSTATS @@ -2133,54 +1951,45 @@ update_pstats(int old_referenced_bits, int new_referenced_bits) { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::init_states -// Access: Public, Static -// Description: Make sure the global _states map is allocated. This -// only has to be done once. We could make this map -// static, but then we run into problems if anyone -// creates a RenderState object at static init time; -// it also seems to cause problems when the Panda shared -// library is unloaded at application exit time. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the global _states map is allocated. This only has to be done + * once. We could make this map static, but then we run into problems if + * anyone creates a RenderState object at static init time; it also seems to + * cause problems when the Panda shared library is unloaded at application + * exit time. + */ void RenderState:: init_states() { _states = new States; - // TODO: we should have a global Panda mutex to allow us to safely - // create _states_lock without a startup race condition. For the - // meantime, this is OK because we guarantee that this method is - // called at static init time, presumably when there is still only - // one thread in the world. + // TODO: we should have a global Panda mutex to allow us to safely create + // _states_lock without a startup race condition. For the meantime, this is + // OK because we guarantee that this method is called at static init time, + // presumably when there is still only one thread in the world. _states_lock = new LightReMutex("RenderState::_states_lock"); _cache_stats.init(); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); - // Initialize the empty state object as well. It is used so often - // that it is declared globally, and lives forever. + // Initialize the empty state object as well. It is used so often that it + // is declared globally, and lives forever. RenderState *state = new RenderState; state->local_object(); state->_saved_entry = _states->store(state, Empty()); _empty_state = state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// RenderState. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type RenderState. + */ void RenderState:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RenderState:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -2189,8 +1998,8 @@ write_datagram(BamWriter *manager, Datagram &dg) { nassertv(num_attribs == (int)(PN_uint16)num_attribs); dg.add_uint16(num_attribs); - // **** We should smarten up the writing of the override - // number--most of the time these will all be zero. + // **** We should smarten up the writing of the override number--most of the + // time these will all be zero. SlotMask mask = _filled_slots; int slot = mask.get_lowest_on_bit(); while (slot >= 0) { @@ -2204,13 +2013,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int RenderState:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -2238,66 +2044,57 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::change_this -// Access: Public, Static -// Description: Called immediately after complete_pointers(), this -// gives the object a chance to adjust its own pointer -// if desired. Most objects don't change pointers after -// completion, but some need to. -// -// Once this function has been called, the old pointer -// will no longer be accessed. -//////////////////////////////////////////////////////////////////// +/** + * Called immediately after complete_pointers(), this gives the object a + * chance to adjust its own pointer if desired. Most objects don't change + * pointers after completion, but some need to. + * + * Once this function has been called, the old pointer will no longer be + * accessed. + */ TypedWritable *RenderState:: change_this(TypedWritable *old_ptr, BamReader *manager) { // First, uniquify the pointer. RenderState *state = DCAST(RenderState, old_ptr); CPT(RenderState) pointer = return_unique(state); - // But now we have a problem, since we have to hold the reference - // count and there's no way to return a TypedWritable while still - // holding the reference count! We work around this by explicitly - // upping the count, and also setting a finalize() callback to down - // it later. + // But now we have a problem, since we have to hold the reference count and + // there's no way to return a TypedWritable while still holding the + // reference count! We work around this by explicitly upping the count, and + // also setting a finalize() callback to down it later. if (pointer == state) { pointer->ref(); manager->register_finalize(state); } - // We have to cast the pointer back to non-const, because the bam - // reader expects that. + // We have to cast the pointer back to non-const, because the bam reader + // expects that. return (RenderState *)pointer.p(); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void RenderState:: finalize(BamReader *) { // Unref the pointer that we explicitly reffed in change_this(). unref(); - // We should never get back to zero after unreffing our own count, - // because we expect to have been stored in a pointer somewhere. If - // we do get to zero, it's a memory leak; the way to avoid this is - // to call unref_delete() above instead of unref(), but this is - // dangerous to do from within a virtual function. + // We should never get back to zero after unreffing our own count, because + // we expect to have been stored in a pointer somewhere. If we do get to + // zero, it's a memory leak; the way to avoid this is to call unref_delete() + // above instead of unref(), but this is dangerous to do from within a + // virtual function. nassertv(get_ref_count() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type RenderState is encountered -// in the Bam file. It should create the RenderState -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type RenderState is encountered in the Bam file. It should create the + * RenderState and extract its information from the file. + */ TypedWritable *RenderState:: make_from_bam(const FactoryParams ¶ms) { RenderState *state = new RenderState; @@ -2311,13 +2108,10 @@ make_from_bam(const FactoryParams ¶ms) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: RenderState::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RenderState. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RenderState. + */ void RenderState:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -2332,4 +2126,3 @@ fillin(DatagramIterator &scan, BamReader *manager) { (*_read_overrides).push_back(override); } } - diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 9947b68bf1..c15efe68ad 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -1,16 +1,15 @@ -// Filename: renderState.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderState.h + * @author drose + * @date 2002-02-21 + */ #ifndef RENDERSTATE_H #define RENDERSTATE_H @@ -39,18 +38,14 @@ class FactoryParams; class ShaderAttrib; -//////////////////////////////////////////////////////////////////// -// Class : RenderState -// Description : This represents a unique collection of RenderAttrib -// objects that correspond to a particular renderable -// state. -// -// You should not attempt to create or modify a -// RenderState object directly. Instead, call one of -// the make() functions to create one for you. And -// instead of modifying a RenderState object, create a -// new one. -//////////////////////////////////////////////////////////////////// +/** + * This represents a unique collection of RenderAttrib objects that correspond + * to a particular renderable state. + * + * You should not attempt to create or modify a RenderState object directly. + * Instead, call one of the make() functions to create one for you. And + * instead of modifying a RenderState object, create a new one. + */ class EXPCL_PANDA_PGRAPH RenderState : public NodeCachedReferenceCount { protected: RenderState(); @@ -153,8 +148,8 @@ PUBLISHED: EXTENSION(static PyObject *get_states()); PUBLISHED: - // These methods are intended for use by low-level code, but they're - // also handy enough to expose to high-level users. + // These methods are intended for use by low-level code, but they're also + // handy enough to expose to high-level users. INLINE int get_draw_order() const; INLINE int get_bin_index() const; int get_geom_rendering(int geom_rendering) const; @@ -224,14 +219,14 @@ public: static void init_states(); // If this state contains an "auto" ShaderAttrib, then an explicit - // ShaderAttrib will be synthesized by the runtime and stored here. - // I can't declare this as a ShaderAttrib because that would create - // a circular include-file dependency problem. Aaargh. + // ShaderAttrib will be synthesized by the runtime and stored here. I can't + // declare this as a ShaderAttrib because that would create a circular + // include-file dependency problem. Aaargh. mutable CPT(RenderAttrib) _generated_shader; private: - // This mutex protects _states. It also protects any modification - // to the cache, which is encoded in _composition_cache and + // This mutex protects _states. It also protects any modification to the + // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; class Empty { @@ -240,39 +235,38 @@ private: static States *_states; static const RenderState *_empty_state; - // This iterator records the entry corresponding to this - // RenderState object in the above global set. We keep the index - // around so we can remove it when the RenderState destructs. + // This iterator records the entry corresponding to this RenderState object + // in the above global set. We keep the index around so we can remove it + // when the RenderState destructs. int _saved_entry; - // This data structure manages the job of caching the composition of - // two RenderStates. It's complicated because we have to be sure to - // remove the entry if *either* of the input RenderStates destructs. - // To implement this, we always record Composition entries in pairs, - // one in each of the two involved RenderState objects. + // This data structure manages the job of caching the composition of two + // RenderStates. It's complicated because we have to be sure to remove the + // entry if *either* of the input RenderStates destructs. To implement + // this, we always record Composition entries in pairs, one in each of the + // two involved RenderState objects. class Composition { public: INLINE Composition(); INLINE Composition(const Composition ©); - // _result is reference counted if and only if it is not the same - // pointer as this. + // _result is reference counted if and only if it is not the same pointer + // as this. const RenderState *_result; }; - // The first element of the map is the object we compose with. This - // is not reference counted within this map; instead we store a - // companion pointer in the other object, and remove the references - // explicitly when either object destructs. + // The first element of the map is the object we compose with. This is not + // reference counted within this map; instead we store a companion pointer + // in the other object, and remove the references explicitly when either + // object destructs. typedef SimpleHashMap CompositionCache; CompositionCache _composition_cache; CompositionCache _invert_composition_cache; - // This is here to provide a quick cache of GSG + RenderState -> - // GeomMunger for the cull phase. It is here because it is faster - // to look up the GSG in the RenderState pointer than vice-versa, - // since there are likely to be far fewer GSG's than RenderStates. - // The code to manage this map lives in + // This is here to provide a quick cache of GSG + RenderState -> GeomMunger + // for the cull phase. It is here because it is faster to look up the GSG + // in the RenderState pointer than vice-versa, since there are likely to be + // far fewer GSG's than RenderStates. The code to manage this map lives in // GraphicsStateGuardian::get_geom_munger(). typedef WeakKeyHashMap Mungers; mutable Mungers _mungers; @@ -282,8 +276,8 @@ private: UpdateSeq _cycle_detect; static UpdateSeq _last_cycle_detect; - // This keeps track of our current position through the garbage - // collection cycle. + // This keeps track of our current position through the garbage collection + // cycle. static int _garbage_index; static PStatCollector _cache_update_pcollector; @@ -297,8 +291,8 @@ private: static PStatCollector _cache_counter; private: - // This is the actual data within the RenderState: a set of - // max_slots RenderAttribs. + // This is the actual data within the RenderState: a set of max_slots + // RenderAttribs. class Attribute { public: INLINE Attribute(const RenderAttrib *attrib, int override); @@ -313,12 +307,12 @@ private: }; Attribute _attributes[RenderAttribRegistry::_max_slots]; - // We also store a bitmask of the non-NULL attributes in the above - // array. This is redundant, but it is a useful cache. + // We also store a bitmask of the non-NULL attributes in the above array. + // This is redundant, but it is a useful cache. SlotMask _filled_slots; - // We cache the index to the associated CullBin, if there happens to - // be a CullBinAttrib in the state. + // We cache the index to the associated CullBin, if there happens to be a + // CullBinAttrib in the state. int _bin_index; int _draw_order; size_t _hash; @@ -382,4 +376,3 @@ INLINE ostream &operator << (ostream &out, const RenderState &state) { #include "renderState.I" #endif - diff --git a/panda/src/pgraph/renderState_ext.cxx b/panda/src/pgraph/renderState_ext.cxx index 3238677bd0..5a7288f518 100644 --- a/panda/src/pgraph/renderState_ext.cxx +++ b/panda/src/pgraph/renderState_ext.cxx @@ -1,35 +1,31 @@ -// Filename: renderState_ext.cxx -// Created by: CFSworks (31Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderState_ext.cxx + * @author CFSworks + * @date 2014-03-31 + */ #include "renderState_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_composition_cache -// Access: Published -// Description: Returns a list of 2-tuples that represents the -// composition cache. For each tuple in the list, the -// first element is the source render, and the second -// is the result render. If both are None, there is -// no entry in the cache at that slot. -// -// In general, a->compose(source) == result. -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of 2-tuples that represents the composition cache. For each + * tuple in the list, the first element is the source render, and the second + * is the result render. If both are None, there is no entry in the cache at + * that slot. + * + * In general, a->compose(source) == result. + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ PyObject *Extension:: get_composition_cache() const { extern struct Dtool_PyTypedObject Dtool_RenderState; @@ -52,7 +48,7 @@ get_composition_cache() const { Py_INCREF(a); } else { source->ref(); - a = DTool_CreatePyInstanceTyped((void *)source, Dtool_RenderState, + a = DTool_CreatePyInstanceTyped((void *)source, Dtool_RenderState, true, true, source->get_type_index()); } const RenderState *result = _this->_composition_cache.get_data(i)._result; @@ -61,7 +57,7 @@ get_composition_cache() const { Py_INCREF(b); } else { result->ref(); - b = DTool_CreatePyInstanceTyped((void *)result, Dtool_RenderState, + b = DTool_CreatePyInstanceTyped((void *)result, Dtool_RenderState, true, true, result->get_type_index()); } } @@ -74,20 +70,17 @@ get_composition_cache() const { return list; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_invert_composition_cache -// Access: Published -// Description: Returns a list of 2-tuples that represents the -// invert_composition cache. For each tuple in the list, the -// first element is the source render, and the second -// is the result render. If both are None, there is -// no entry in the cache at that slot. -// -// In general, a->invert_compose(source) == result. -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of 2-tuples that represents the invert_composition cache. + * For each tuple in the list, the first element is the source render, and the + * second is the result render. If both are None, there is no entry in the + * cache at that slot. + * + * In general, a->invert_compose(source) == result. + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ PyObject *Extension:: get_invert_composition_cache() const { extern struct Dtool_PyTypedObject Dtool_RenderState; @@ -110,7 +103,7 @@ get_invert_composition_cache() const { Py_INCREF(a); } else { source->ref(); - a = DTool_CreatePyInstanceTyped((void *)source, Dtool_RenderState, + a = DTool_CreatePyInstanceTyped((void *)source, Dtool_RenderState, true, true, source->get_type_index()); } const RenderState *result = _this->_invert_composition_cache.get_data(i)._result; @@ -119,7 +112,7 @@ get_invert_composition_cache() const { Py_INCREF(b); } else { result->ref(); - b = DTool_CreatePyInstanceTyped((void *)result, Dtool_RenderState, + b = DTool_CreatePyInstanceTyped((void *)result, Dtool_RenderState, true, true, result->get_type_index()); } } @@ -132,13 +125,10 @@ get_invert_composition_cache() const { return list; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_states -// Access: Published, Static -// Description: Returns a list of all of the RenderState objects -// in the state cache. The order of elements in this -// cache is arbitrary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all of the RenderState objects in the state cache. The + * order of elements in this cache is arbitrary. + */ PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_RenderState; @@ -158,8 +148,8 @@ get_states() { } const RenderState *state = RenderState::_states->get_key(si); state->ref(); - PyObject *a = - DTool_CreatePyInstanceTyped((void *)state, Dtool_RenderState, + PyObject *a = + DTool_CreatePyInstanceTyped((void *)state, Dtool_RenderState, true, true, state->get_type_index()); nassertr(i < num_states, list); PyList_SET_ITEM(list, i, a); diff --git a/panda/src/pgraph/renderState_ext.h b/panda/src/pgraph/renderState_ext.h index 43830e8021..c452a025af 100644 --- a/panda/src/pgraph/renderState_ext.h +++ b/panda/src/pgraph/renderState_ext.h @@ -1,16 +1,15 @@ -// Filename: renderState_ext.h -// Created by: CFSworks (31Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file renderState_ext.h + * @author CFSworks + * @date 2014-03-31 + */ #ifndef RENDERSTATE_EXT_H #define RENDERSTATE_EXT_H @@ -23,12 +22,10 @@ #include "renderState.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// RenderState, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for RenderState, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pgraph/rescaleNormalAttrib.I b/panda/src/pgraph/rescaleNormalAttrib.I index 2825f44431..faca41b5ce 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.I +++ b/panda/src/pgraph/rescaleNormalAttrib.I @@ -1,48 +1,39 @@ -// Filename: rescaleNormalAttrib.I -// Created by: drose (30Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rescaleNormalAttrib.I + * @author drose + * @date 2004-12-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::Constructor -// Access: Private -// Description: Use RescaleNormalAttrib::make() to construct a new -// RescaleNormalAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use RescaleNormalAttrib::make() to construct a new RescaleNormalAttrib + * object. + */ INLINE RescaleNormalAttrib:: RescaleNormalAttrib(RescaleNormalAttrib::Mode mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::make_default -// Access: Published, Static -// Description: Constructs a RescaleNormalAttrib object that's -// suitable for putting at the top of a scene graph. -// This will contain whatever attrib was suggested by -// the user's rescale-normals Config variable. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a RescaleNormalAttrib object that's suitable for putting at the + * top of a scene graph. This will contain whatever attrib was suggested by + * the user's rescale-normals Config variable. + */ INLINE CPT(RenderAttrib) RescaleNormalAttrib:: make_default() { return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot); } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::get_mode -// Access: Published -// Description: Returns the render mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the render mode. + */ INLINE RescaleNormalAttrib::Mode RescaleNormalAttrib:: get_mode() const { return _mode; diff --git a/panda/src/pgraph/rescaleNormalAttrib.cxx b/panda/src/pgraph/rescaleNormalAttrib.cxx index 33de69efe7..36af8ebafb 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.cxx +++ b/panda/src/pgraph/rescaleNormalAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: rescaleNormalAttrib.cxx -// Created by: drose (30Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rescaleNormalAttrib.cxx + * @author drose + * @date 2004-12-30 + */ #include "rescaleNormalAttrib.h" #include "graphicsStateGuardianBase.h" @@ -27,13 +26,11 @@ TypeHandle RescaleNormalAttrib::_type_handle; int RescaleNormalAttrib::_attrib_slot; CPT(RenderAttrib) RescaleNormalAttrib::_attribs[RescaleNormalAttrib::M_auto + 1]; -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::make -// Access: Published, Static -// Description: Constructs a new RescaleNormalAttrib object that -// specifies whether to rescale normals to compensate -// for transform scales or incorrectly defined normals. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new RescaleNormalAttrib object that specifies whether to + * rescale normals to compensate for transform scales or incorrectly defined + * normals. + */ CPT(RenderAttrib) RescaleNormalAttrib:: make(RescaleNormalAttrib::Mode mode) { if (_attribs[mode].is_null()) { @@ -44,47 +41,38 @@ make(RescaleNormalAttrib::Mode mode) { return _attribs[mode]; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RescaleNormalAttrib:: output(ostream &out) const { out << get_type() << ":" << get_mode(); } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RescaleNormalAttrib -// types to return a unique number indicating whether -// this RescaleNormalAttrib is equivalent to the other one. -// -// This should return 0 if the two RescaleNormalAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two RescaleNormalAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RescaleNormalAttrib types to return a + * unique number indicating whether this RescaleNormalAttrib is equivalent to + * the other one. + * + * This should return 0 if the two RescaleNormalAttrib objects are equivalent, + * a number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two RescaleNormalAttrib objects whose + * get_type() functions return the same. + */ int RescaleNormalAttrib:: compare_to_impl(const RenderAttrib *other) const { const RescaleNormalAttrib *ta = (const RescaleNormalAttrib *)other; return (int)_mode - (int)ta->_mode; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t RescaleNormalAttrib:: get_hash_impl() const { size_t hash = 0; @@ -92,11 +80,9 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) RescaleNormalAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { // We currently only support M_normalize in the ShaderGenerator. @@ -107,23 +93,18 @@ get_auto_shader_attrib_impl(const RenderState *state) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// RescaleNormalAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type RescaleNormalAttrib. + */ void RescaleNormalAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RescaleNormalAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -131,14 +112,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type RescaleNormalAttrib is encountered -// in the Bam file. It should create the RescaleNormalAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type RescaleNormalAttrib is encountered in the Bam file. It should create + * the RescaleNormalAttrib and extract its information from the file. + */ TypedWritable *RescaleNormalAttrib:: make_from_bam(const FactoryParams ¶ms) { RescaleNormalAttrib *attrib = new RescaleNormalAttrib(M_none); @@ -151,13 +129,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RescaleNormalAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RescaleNormalAttrib. + */ void RescaleNormalAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); @@ -165,20 +140,18 @@ fillin(DatagramIterator &scan, BamReader *manager) { _mode = (Mode)scan.get_int8(); } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::init_type -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RescaleNormalAttrib:: init_type() { RenderAttrib::init_type(); register_type(_type_handle, "RescaleNormalAttrib", RenderAttrib::get_class_type()); - // This is defined here, since we have otherwise no guarantee that - // the config var has already been constructed by the time we call - // init_type() at static init time. + // This is defined here, since we have otherwise no guarantee that the + // config var has already been constructed by the time we call init_type() + // at static init time. static ConfigVariableEnum rescale_normals ("rescale-normals", RescaleNormalAttrib::M_auto, PRC_DESC("Specifies the kind of RescaleNormalAttrib that should be " @@ -194,10 +167,9 @@ init_type() { _attribs[mode] = attrib; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::Mode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, RescaleNormalAttrib::Mode mode) { switch (mode) { @@ -217,10 +189,9 @@ operator << (ostream &out, RescaleNormalAttrib::Mode mode) { return out << "(**invalid RescaleNormalAttrib::Mode(" << (int)mode << ")**)"; } -//////////////////////////////////////////////////////////////////// -// Function: RescaleNormalAttrib::Mode input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, RescaleNormalAttrib::Mode &mode) { string word; diff --git a/panda/src/pgraph/rescaleNormalAttrib.h b/panda/src/pgraph/rescaleNormalAttrib.h index 4634d504bb..3017c9a879 100644 --- a/panda/src/pgraph/rescaleNormalAttrib.h +++ b/panda/src/pgraph/rescaleNormalAttrib.h @@ -1,16 +1,15 @@ -// Filename: rescaleNormalAttrib.h -// Created by: drose (30Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rescaleNormalAttrib.h + * @author drose + * @date 2004-12-30 + */ #ifndef RESCALENORMALATTRIB_H #define RESCALENORMALATTRIB_H @@ -21,10 +20,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RescaleNormalAttrib -// Description : Specifies how polygons are to be drawn. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how polygons are to be drawn. + */ class EXPCL_PANDA_PGRAPH RescaleNormalAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -38,9 +36,8 @@ PUBLISHED: // Normals are scaled to unit length; potentially expensive. M_normalize, - // Normals are counterscaled in the presence of a uniform scale - // transform, or normalized in the presence of a non-uniform scale - // transform. + // Normals are counterscaled in the presence of a uniform scale transform, + // or normalized in the presence of a non-uniform scale transform. M_auto, }; @@ -64,8 +61,8 @@ protected: private: Mode _mode; - // There are so few possible combinations, and it's used fairly often, so - // we keep an array of the possible attributes. + // There are so few possible combinations, and it's used fairly often, so we + // keep an array of the possible attributes. static CPT(RenderAttrib) _attribs[M_auto + 1]; PUBLISHED: @@ -105,4 +102,3 @@ EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, RescaleNormalAttrib::Mode #include "rescaleNormalAttrib.I" #endif - diff --git a/panda/src/pgraph/sceneGraphReducer.I b/panda/src/pgraph/sceneGraphReducer.I index 1e79b03b9b..4319b118df 100644 --- a/panda/src/pgraph/sceneGraphReducer.I +++ b/panda/src/pgraph/sceneGraphReducer.I @@ -1,23 +1,19 @@ -// Filename: sceneGraphReducer.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphReducer.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SceneGraphReducer:: SceneGraphReducer(GraphicsStateGuardianBase *gsg) : _combine_radius(0.0f) @@ -25,76 +21,59 @@ SceneGraphReducer(GraphicsStateGuardianBase *gsg) : set_gsg(gsg); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SceneGraphReducer:: ~SceneGraphReducer() { } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::get_gsg -// Access: Published -// Description: Returns the particular GraphicsStateGuardian that -// this object will attempt to optimize to. -// See set_gsg(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular GraphicsStateGuardian that this object will attempt + * to optimize to. See set_gsg(). + */ INLINE GraphicsStateGuardianBase *SceneGraphReducer:: get_gsg() const { return _gsg; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::set_combine_radius -// Access: Published -// Description: Specifies the radius that is used in conjunction with -// CS_within_radius to decide whether a subgraph's -// siblings should be combined into a single node or -// not. -// -// If the CS_within_radius bit is included in the -// combine_siblings_bits parameter passed to flatten, -// than any nodes whose bounding volume is smaller than -// the indicated radius will be combined together (as if -// CS_other were set). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the radius that is used in conjunction with CS_within_radius to + * decide whether a subgraph's siblings should be combined into a single node + * or not. + * + * If the CS_within_radius bit is included in the combine_siblings_bits + * parameter passed to flatten, than any nodes whose bounding volume is + * smaller than the indicated radius will be combined together (as if CS_other + * were set). + */ INLINE void SceneGraphReducer:: set_combine_radius(PN_stdfloat combine_radius) { _combine_radius = combine_radius; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::get_combine_radius -// Access: Published -// Description: Returns the radius that is used in conjunction with -// CS_within_radius. See set_combine_radius(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the radius that is used in conjunction with CS_within_radius. See + * set_combine_radius(). + */ INLINE PN_stdfloat SceneGraphReducer:: get_combine_radius() const { return _combine_radius; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::apply_attribs -// Access: Published -// Description: Walks the scene graph, accumulating attribs of -// the indicated types, applying them to the vertices, -// and removing them from the scene graph. This has a -// performance optimization benefit in itself, but is -// especially useful to pave the way for a call to -// flatten() and greatly improve the effectiveness of -// the flattening operation. -// -// Multiply instanced geometry is duplicated before the -// attribs are applied. -// -// Of course, this operation does make certain dynamic -// operations impossible. -//////////////////////////////////////////////////////////////////// +/** + * Walks the scene graph, accumulating attribs of the indicated types, + * applying them to the vertices, and removing them from the scene graph. + * This has a performance optimization benefit in itself, but is especially + * useful to pave the way for a call to flatten() and greatly improve the + * effectiveness of the flattening operation. + * + * Multiply instanced geometry is duplicated before the attribs are applied. + * + * Of course, this operation does make certain dynamic operations impossible. + */ INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, int attrib_types) { nassertv(check_live_flatten(node)); @@ -105,15 +84,12 @@ apply_attribs(PandaNode *node, int attrib_types) { _transformer.finish_apply(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::apply_attribs -// Access: Published -// Description: This flavor of apply_attribs() can be called -// recursively from within another flatten process -// (e.g. from PandaNode::apply_attribs_to_vertices()). -// The parameters were presumably received from a parent -// SceneGraphReducer object. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of apply_attribs() can be called recursively from within + * another flatten process (e.g. from + * PandaNode::apply_attribs_to_vertices()). The parameters were presumably + * received from a parent SceneGraphReducer object. + */ INLINE void SceneGraphReducer:: apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -121,28 +97,22 @@ apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, r_apply_attribs(node, attribs, attrib_types, transformer); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::make_compatible_format -// Access: Published -// Description: Walks through the tree at this node and below and -// unifies the GeomVertexFormat for any GeomVertexData -// objects that are found, so that all eligible vdatas -// (according to collect_bits; see collect_vertex_data) -// will share the same vertex format. -// -// This will add unused columns where necessary to match -// formats. It can result in suboptimal performance if -// used needlessly. -// -// There is usually no reason to call this explicitly, -// since collect_vertex_data() will do this anyway if it -// has not been done already. However, calling it ahead -// of time can make that future call to -// collect_vertex_data() run a little bit faster. -// -// The return value is the number of vertex datas -// modified. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the tree at this node and below and unifies the + * GeomVertexFormat for any GeomVertexData objects that are found, so that all + * eligible vdatas (according to collect_bits; see collect_vertex_data) will + * share the same vertex format. + * + * This will add unused columns where necessary to match formats. It can + * result in suboptimal performance if used needlessly. + * + * There is usually no reason to call this explicitly, since + * collect_vertex_data() will do this anyway if it has not been done already. + * However, calling it ahead of time can make that future call to + * collect_vertex_data() run a little bit faster. + * + * The return value is the number of vertex datas modified. + */ INLINE int SceneGraphReducer:: make_compatible_format(PandaNode *root, int collect_bits) { nassertr(root != (PandaNode *)NULL, 0); @@ -154,22 +124,17 @@ make_compatible_format(PandaNode *root, int collect_bits) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::collect_vertex_data -// Access: Published -// Description: Collects all different GeomVertexData blocks that -// have compatible formats at this node and below into a -// single, unified block (or at least multiple larger -// blocks). This is intended to reduce rendering -// overhead incurred by switching vertex buffers. It -// can also make a subsequent call to unify() much more -// effective than it would have been otherwise. -// -// The set of bits passed in collect_bits indicates -// which properties are used to differentiate -// GeomVertexData blocks. If it is 0, then more blocks -// will be combined together than if it is nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Collects all different GeomVertexData blocks that have compatible formats + * at this node and below into a single, unified block (or at least multiple + * larger blocks). This is intended to reduce rendering overhead incurred by + * switching vertex buffers. It can also make a subsequent call to unify() + * much more effective than it would have been otherwise. + * + * The set of bits passed in collect_bits indicates which properties are used + * to differentiate GeomVertexData blocks. If it is 0, then more blocks will + * be combined together than if it is nonzero. + */ INLINE int SceneGraphReducer:: collect_vertex_data(PandaNode *root, int collect_bits) { nassertr(root != (PandaNode *)NULL, 0); @@ -181,16 +146,13 @@ collect_vertex_data(PandaNode *root, int collect_bits) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::make_nonindexed -// Access: Published -// Description: Converts indexed geometry to nonindexed geometry at -// the indicated node and below, by duplicating vertices -// where necessary. The parameter nonindexed_bits is a -// union of bits defined in -// SceneGraphReducer::MakeNonindexed, which specifes -// which types of geometry to avoid making nonindexed. -//////////////////////////////////////////////////////////////////// +/** + * Converts indexed geometry to nonindexed geometry at the indicated node and + * below, by duplicating vertices where necessary. The parameter + * nonindexed_bits is a union of bits defined in + * SceneGraphReducer::MakeNonindexed, which specifes which types of geometry + * to avoid making nonindexed. + */ INLINE int SceneGraphReducer:: make_nonindexed(PandaNode *root, int nonindexed_bits) { nassertr(root != (PandaNode *)NULL, 0); @@ -199,17 +161,14 @@ make_nonindexed(PandaNode *root, int nonindexed_bits) { return r_make_nonindexed(root, nonindexed_bits); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::premunge -// Access: Published -// Description: Walks the scene graph rooted at this node and below, -// and uses the indicated GSG to premunge every Geom -// found to optimize it for eventual rendering on the -// indicated GSG. If there is no GSG indicated for the -// SceneGraphReducer, this is a no-op. -// -// This operation will also apply to stashed children. -//////////////////////////////////////////////////////////////////// +/** + * Walks the scene graph rooted at this node and below, and uses the indicated + * GSG to premunge every Geom found to optimize it for eventual rendering on + * the indicated GSG. If there is no GSG indicated for the SceneGraphReducer, + * this is a no-op. + * + * This operation will also apply to stashed children. + */ INLINE void SceneGraphReducer:: premunge(PandaNode *root, const RenderState *initial_state) { nassertv(root != (PandaNode *)NULL); @@ -219,4 +178,3 @@ premunge(PandaNode *root, const RenderState *initial_state) { r_premunge(root, initial_state); } } - diff --git a/panda/src/pgraph/sceneGraphReducer.cxx b/panda/src/pgraph/sceneGraphReducer.cxx index 1f4f028b5a..d0dc3e4411 100644 --- a/panda/src/pgraph/sceneGraphReducer.cxx +++ b/panda/src/pgraph/sceneGraphReducer.cxx @@ -1,16 +1,15 @@ -// Filename: sceneGraphReducer.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphReducer.cxx + * @author drose + * @date 2002-03-14 + */ #include "sceneGraphReducer.h" #include "config_pgraph.h" @@ -34,17 +33,13 @@ PStatCollector SceneGraphReducer::_unify_collector("*:Flatten:unify"); PStatCollector SceneGraphReducer::_remove_unused_collector("*:Flatten:remove unused vertices"); PStatCollector SceneGraphReducer::_premunge_collector("*:Premunge"); -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::set_gsg -// Access: Published -// Description: Specifies the particular GraphicsStateGuardian that -// this object will attempt to optimize to. The GSG may -// specify parameters such as maximum number of vertices -// per vertex data, max number of vertices per -// primitive, and whether triangle strips are preferred. -// It also affects the types of vertex column data that -// is created by premunge(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular GraphicsStateGuardian that this object will + * attempt to optimize to. The GSG may specify parameters such as maximum + * number of vertices per vertex data, max number of vertices per primitive, + * and whether triangle strips are preferred. It also affects the types of + * vertex column data that is created by premunge(). + */ void SceneGraphReducer:: set_gsg(GraphicsStateGuardianBase *gsg) { if (gsg != (GraphicsStateGuardianBase *)NULL) { @@ -62,39 +57,30 @@ set_gsg(GraphicsStateGuardianBase *gsg) { _transformer.set_max_collect_vertices(max_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::clear_gsg -// Access: Published -// Description: Specifies that no particular GraphicsStateGuardian -// will be used to guide the optimization. The -// SceneGraphReducer will instead use config variables -// such as max-collect-vertices and max-collect-indices. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that no particular GraphicsStateGuardian will be used to guide + * the optimization. The SceneGraphReducer will instead use config variables + * such as max-collect-vertices and max-collect-indices. + */ void SceneGraphReducer:: clear_gsg() { _gsg = NULL; _transformer.set_max_collect_vertices(max_collect_vertices); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::flatten -// Access: Published -// Description: Simplifies the graph by removing unnecessary nodes -// and nodes. -// -// In general, a node (and its parent node) is a -// candidate for removal if the node has no siblings and -// the node has no special properties. -// -// If combine_siblings_bits is nonzero, some sibling -// nodes (according to the bits set in -// combine_siblings_bits) may also be collapsed into a -// single node. This will further reduce scene graph -// complexity, sometimes substantially, at the cost of -// reduced spatial separation. -// -// Returns the number of nodes removed from the graph. -//////////////////////////////////////////////////////////////////// +/** + * Simplifies the graph by removing unnecessary nodes and nodes. + * + * In general, a node (and its parent node) is a candidate for removal if the + * node has no siblings and the node has no special properties. + * + * If combine_siblings_bits is nonzero, some sibling nodes (according to the + * bits set in combine_siblings_bits) may also be collapsed into a single + * node. This will further reduce scene graph complexity, sometimes + * substantially, at the cost of reduced spatial separation. + * + * Returns the number of nodes removed from the graph. + */ int SceneGraphReducer:: flatten(PandaNode *root, int combine_siblings_bits) { nassertr(check_live_flatten(root), 0); @@ -106,8 +92,8 @@ flatten(PandaNode *root, int combine_siblings_bits) { do { num_pass_nodes = 0; - // Get a copy of the children list, so we don't have to worry - // about self-modifications. + // Get a copy of the children list, so we don't have to worry about self- + // modifications. PandaNode::Children cr = root->get_children(); // Now visit each of the children in turn. @@ -125,22 +111,18 @@ flatten(PandaNode *root, int combine_siblings_bits) { num_total_nodes += num_pass_nodes; - // If combine_siblings_bits has CS_recurse set, we should repeat - // the above until we don't get any more benefit from flattening, - // because each pass could convert cousins into siblings, which - // may get flattened next pass. + // If combine_siblings_bits has CS_recurse set, we should repeat the above + // until we don't get any more benefit from flattening, because each pass + // could convert cousins into siblings, which may get flattened next pass. } while ((combine_siblings_bits & CS_recurse) != 0 && num_pass_nodes != 0); return num_total_nodes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::remove_column -// Access: Published -// Description: Removes the indicated data column from any -// GeomVertexDatas found at the indicated root and -// below. Returns the number of GeomNodes modified. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated data column from any GeomVertexDatas found at the + * indicated root and below. Returns the number of GeomNodes modified. + */ int SceneGraphReducer:: remove_column(PandaNode *root, const InternalName *column) { nassertr(check_live_flatten(root), 0); @@ -151,15 +133,12 @@ remove_column(PandaNode *root, const InternalName *column) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::make_compatible_state -// Access: Published -// Description: Searches for GeomNodes that contain multiple Geoms -// that differ only in their ColorAttribs. If such a -// GeomNode is found, then all the colors are pushed -// down into the vertices. This makes it feasible for -// the geoms to be unified later. -//////////////////////////////////////////////////////////////////// +/** + * Searches for GeomNodes that contain multiple Geoms that differ only in + * their ColorAttribs. If such a GeomNode is found, then all the colors are + * pushed down into the vertices. This makes it feasible for the geoms to be + * unified later. + */ int SceneGraphReducer:: make_compatible_state(PandaNode *root) { nassertr(check_live_flatten(root), 0); @@ -170,20 +149,16 @@ make_compatible_state(PandaNode *root) { return count; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::decompose -// Access: Published -// Description: Calls decompose() on every GeomNode at this level and -// below. -// -// There is usually no reason to call this explicitly, -// since unify() will do this anyway if it needs to be -// done. However, calling it ahead of time can make -// that future call to unify() run a little bit faster. -// -// This operation has no effect if the config variable -// preserve-triangle-strips has been set true. -//////////////////////////////////////////////////////////////////// +/** + * Calls decompose() on every GeomNode at this level and below. + * + * There is usually no reason to call this explicitly, since unify() will do + * this anyway if it needs to be done. However, calling it ahead of time can + * make that future call to unify() run a little bit faster. + * + * This operation has no effect if the config variable preserve-triangle- + * strips has been set true. + */ void SceneGraphReducer:: decompose(PandaNode *root) { nassertv(check_live_flatten(root)); @@ -194,15 +169,11 @@ decompose(PandaNode *root) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::unify -// Access: Published -// Description: Calls unify() on every GeomNode at this level and -// below. This attempts to reduce the total number of -// individual Geoms and GeomPrimitives by combining -// these objects wherever possible. See -// GeomNode::unify(). -//////////////////////////////////////////////////////////////////// +/** + * Calls unify() on every GeomNode at this level and below. This attempts to + * reduce the total number of individual Geoms and GeomPrimitives by combining + * these objects wherever possible. See GeomNode::unify(). + */ void SceneGraphReducer:: unify(PandaNode *root, bool preserve_order) { nassertv(check_live_flatten(root)); @@ -215,16 +186,12 @@ unify(PandaNode *root, bool preserve_order) { r_unify(root, max_indices, preserve_order); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::remove_unused_vertices -// Access: Published -// Description: Removes any vertices in GeomVertexDatas that are no -// longer used at this level and below. This requires -// remapping vertex indices in all of the -// GeomPrimitives, to remove holes in the -// GeomVertexDatas. It is normally not necessary to -// call this explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Removes any vertices in GeomVertexDatas that are no longer used at this + * level and below. This requires remapping vertex indices in all of the + * GeomPrimitives, to remove holes in the GeomVertexDatas. It is normally not + * necessary to call this explicitly. + */ void SceneGraphReducer:: remove_unused_vertices(PandaNode *root) { nassertv(check_live_flatten(root)); @@ -235,18 +202,15 @@ remove_unused_vertices(PandaNode *root) { Thread::consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::check_live_flatten -// Access: Published -// Description: In a non-release build, returns false if the node is -// correctly not in a live scene graph. (Calling -// flatten on a node that is part of a live scene graph, -// for instance, a node somewhere under render, can -// cause problems in a multithreaded environment.) -// -// If allow_live_flatten is true, or in a release build, -// this always returns true. -//////////////////////////////////////////////////////////////////// +/** + * In a non-release build, returns false if the node is correctly not in a + * live scene graph. (Calling flatten on a node that is part of a live scene + * graph, for instance, a node somewhere under render, can cause problems in a + * multithreaded environment.) + * + * If allow_live_flatten is true, or in a release build, this always returns + * true. + */ bool SceneGraphReducer:: check_live_flatten(PandaNode *node) { #ifndef NDEBUG @@ -262,11 +226,9 @@ check_live_flatten(PandaNode *node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_apply_attribs -// Access: Protected -// Description: The recursive implementation of apply_attribs(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of apply_attribs(). + */ void SceneGraphReducer:: r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -288,8 +250,8 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, next_attribs.write(pgraph_cat.spam(false), attrib_types, 2); } - // Check to see if we can't propagate any of these attribs past - // this node for some reason. + // Check to see if we can't propagate any of these attribs past this node + // for some reason. if (!node->safe_to_flatten_below()) { if (pgraph_cat.is_spam()) { pgraph_cat.spam() @@ -322,9 +284,8 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, } apply_types |= node->get_unsafe_to_apply_attribs(); - // Also, check the children of this node. If any of them indicates - // it is not safe to modify its transform, we must drop our - // transform here. + // Also, check the children of this node. If any of them indicates it is + // not safe to modify its transform, we must drop our transform here. int num_children = node->get_num_children(); int i; if ((apply_types & TT_transform) == 0) { @@ -391,8 +352,8 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, } if (resist_copy) { - // If any of our children should have been copied but weren't, we - // need to drop the state here before continuing. + // If any of our children should have been copied but weren't, we need to + // drop the state here before continuing. next_attribs.apply_to_node(node, attrib_types); } @@ -406,11 +367,9 @@ r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs, } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_flatten -// Access: Protected -// Description: The recursive implementation of flatten(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of flatten(). + */ int SceneGraphReducer:: r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, int combine_siblings_bits) { @@ -422,8 +381,8 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, } if ((combine_siblings_bits & (CS_geom_node | CS_other | CS_recurse)) != 0) { - // Unset CS_within_radius, since we're going to flatten everything - // anyway. This avoids needlessly calculating the bounding volume. + // Unset CS_within_radius, since we're going to flatten everything anyway. + // This avoids needlessly calculating the bounding volume. combine_siblings_bits &= ~CS_within_radius; } @@ -447,9 +406,8 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, << ": " << *bs << " vs. " << _combine_radius << "\n"; } if (!bs->is_infinite() && (bs->is_empty() || bs->get_radius() <= _combine_radius)) { - // This node fits within the specified radius; from here on - // down, we will have CS_other set, instead of - // CS_within_radius. + // This node fits within the specified radius; from here on down, we + // will have CS_other set, instead of CS_within_radius. if (pgraph_cat.is_spam()) { pgraph_cat.spam() << "node fits within radius; flattening tighter.\n"; @@ -470,14 +428,13 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, } } - // Now that the above loop has removed some children, the child - // list saved above is no longer accurate, so hereafter we must - // ask the node for its real child list. + // Now that the above loop has removed some children, the child list saved + // above is no longer accurate, so hereafter we must ask the node for its + // real child list. - // If we have CS_recurse set, then we flatten siblings before - // trying to flatten children. Otherwise, we flatten children - // first, and then flatten siblings, which avoids overly - // enthusiastic flattening. + // If we have CS_recurse set, then we flatten siblings before trying to + // flatten children. Otherwise, we flatten children first, and then + // flatten siblings, which avoids overly enthusiastic flattening. if ((combine_siblings_bits & CS_recurse) != 0 && parent_node->get_num_children() >= 2 && parent_node->safe_to_combine_children()) { @@ -485,8 +442,7 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, } if (parent_node->get_num_children() == 1) { - // If we now have exactly one child, consider flattening the node - // out. + // If we now have exactly one child, consider flattening the node out. PT(PandaNode) child_node = parent_node->get_child(0); int child_sort = parent_node->get_child_sort(0); @@ -511,8 +467,8 @@ r_flatten(PandaNode *grandparent_node, PandaNode *parent_node, num_nodes += flatten_siblings(parent_node, combine_siblings_bits); } - // Finally, if any of our remaining children are plain PandaNodes - // with no children, just remove them. + // Finally, if any of our remaining children are plain PandaNodes with no + // children, just remove them. if (parent_node->safe_to_combine_children()) { for (int i = parent_node->get_num_children() - 1; i >= 0; --i) { PandaNode *child_node = parent_node->get_child(i); @@ -562,26 +518,22 @@ operator () (const PandaNode *node1, const PandaNode *node2) const { } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::flatten_siblings -// Access: Protected -// Description: Attempts to collapse together any pairs of siblings -// of the indicated node that share the same properties. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to collapse together any pairs of siblings of the indicated node + * that share the same properties. + */ int SceneGraphReducer:: flatten_siblings(PandaNode *parent_node, int combine_siblings_bits) { int num_nodes = 0; - // First, collect the children into groups of nodes with common - // properties. + // First, collect the children into groups of nodes with common properties. typedef plist< PT(PandaNode) > NodeList; typedef pmap Collected; Collected collected; { - // Protect this within a local scope, so the Children member will - // destruct and free the read pointer before we try to write to - // these nodes. + // Protect this within a local scope, so the Children member will destruct + // and free the read pointer before we try to write to these nodes. PandaNode::Children cr = parent_node->get_children(); int num_children = cr.get_num_children(); for (int i = 0; i < num_children; i++) { @@ -601,10 +553,10 @@ flatten_siblings(PandaNode *parent_node, int combine_siblings_bits) { } } - // Now visit each of those groups and try to collapse them together. - // A O(n^2) operation, but presumably the number of nodes in each - // group is small. And if each node in the group can collapse with - // any other node, it becomes a O(n) operation. + // Now visit each of those groups and try to collapse them together. A + // O(n^2) operation, but presumably the number of nodes in each group is + // small. And if each node in the group can collapse with any other node, + // it becomes a O(n) operation. Collected::iterator ci; for (ci = collected.begin(); ci != collected.end(); ++ci) { const RenderEffects *effects = (*ci).first->get_effects(); @@ -643,19 +595,17 @@ flatten_siblings(PandaNode *parent_node, int combine_siblings_bits) { return num_nodes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::consider_child -// Access: Protected -// Description: Decides whether or not the indicated child node is a -// suitable candidate for removal. Returns true if the -// node may be removed, false if it should be kept. -//////////////////////////////////////////////////////////////////// +/** + * Decides whether or not the indicated child node is a suitable candidate for + * removal. Returns true if the node may be removed, false if it should be + * kept. + */ bool SceneGraphReducer:: consider_child(PandaNode *grandparent_node, PandaNode *parent_node, PandaNode *child_node) { if (!parent_node->safe_to_combine() || !child_node->safe_to_combine()) { - // One or both nodes cannot be safely combined with another node; - // do nothing. + // One or both nodes cannot be safely combined with another node; do + // nothing. return false; } @@ -677,31 +627,25 @@ consider_child(PandaNode *grandparent_node, PandaNode *parent_node, return true; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::consider_siblings -// Access: Protected -// Description: Decides whether or not the indicated sibling nodes -// should be collapsed into a single node or not. -// Returns true if the nodes may be collapsed, false if -// they should be kept distinct. -//////////////////////////////////////////////////////////////////// +/** + * Decides whether or not the indicated sibling nodes should be collapsed into + * a single node or not. Returns true if the nodes may be collapsed, false if + * they should be kept distinct. + */ bool SceneGraphReducer:: consider_siblings(PandaNode *parent_node, PandaNode *child1, PandaNode *child2) { - // We don't have to worry about the states being different betweeen - // child1 and child2, since the SortByState object already - // guaranteed we only consider children that have the same state. + // We don't have to worry about the states being different betweeen child1 + // and child2, since the SortByState object already guaranteed we only + // consider children that have the same state. return true; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::do_flatten_child -// Access: Protected -// Description: Collapses together the indicated parent node and -// child node and leaves the result attached to the -// grandparent. The return value is true if the node is -// successfully collapsed, false if we chickened out. -//////////////////////////////////////////////////////////////////// +/** + * Collapses together the indicated parent node and child node and leaves the + * result attached to the grandparent. The return value is true if the node + * is successfully collapsed, false if we chickened out. + */ bool SceneGraphReducer:: do_flatten_child(PandaNode *grandparent_node, PandaNode *parent_node, PandaNode *child_node) { @@ -728,18 +672,14 @@ do_flatten_child(PandaNode *grandparent_node, PandaNode *parent_node, return true; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::do_flatten_siblings -// Access: Protected -// Description: Performs the work of collapsing two sibling nodes -// together into a single node, leaving the resulting -// node attached to the parent. -// -// Returns a pointer to a PandaNode that reflects the -// combined node (which may be either of the source nodes, -// or a new node altogether) if the siblings are -// successfully collapsed, or NULL if we chickened out. -//////////////////////////////////////////////////////////////////// +/** + * Performs the work of collapsing two sibling nodes together into a single + * node, leaving the resulting node attached to the parent. + * + * Returns a pointer to a PandaNode that reflects the combined node (which may + * be either of the source nodes, or a new node altogether) if the siblings + * are successfully collapsed, or NULL if we chickened out. + */ PandaNode *SceneGraphReducer:: do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, PandaNode *child2) { @@ -759,25 +699,21 @@ do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, choose_name(new_child, child2, child1); - // Make sure the new child list has child1's children first, - // followed by child2's children. + // Make sure the new child list has child1's children first, followed by + // child2's children. child1->replace_node(child2); new_child->replace_node(child1); return new_child; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::collapse_nodes -// Access: Protected -// Description: Collapses the two nodes into a single node, if -// possible. The 'siblings' flag is true if the two -// nodes are siblings nodes; otherwise, node1 is a -// parent of node2. The return value is the resulting -// node, which may be either one of the source nodes, or -// a new node altogether, or it may be NULL to indicate -// that the collapse operation could not take place. -//////////////////////////////////////////////////////////////////// +/** + * Collapses the two nodes into a single node, if possible. The 'siblings' + * flag is true if the two nodes are siblings nodes; otherwise, node1 is a + * parent of node2. The return value is the resulting node, which may be + * either one of the source nodes, or a new node altogether, or it may be NULL + * to indicate that the collapse operation could not take place. + */ PT(PandaNode) SceneGraphReducer:: collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { PT(PandaNode) result = node2->combine_with(node1); @@ -788,12 +724,10 @@ collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings) { } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::choose_name -// Access: Protected -// Description: Chooses a suitable name for the collapsed node, based -// on the names of the two sources nodes. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a suitable name for the collapsed node, based on the names of the + * two sources nodes. + */ void SceneGraphReducer:: choose_name(PandaNode *preserve, PandaNode *source1, PandaNode *source2) { string name; @@ -812,11 +746,9 @@ choose_name(PandaNode *preserve, PandaNode *source1, PandaNode *source2) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_remove_column -// Access: Private -// Description: The recursive implementation of remove_column(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of remove_column(). + */ int SceneGraphReducer:: r_remove_column(PandaNode *node, const InternalName *column, GeomTransformer &transformer) { @@ -838,11 +770,9 @@ r_remove_column(PandaNode *node, const InternalName *column, return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_make_compatible_state -// Access: Private -// Description: The recursive implementation of make_compatible_state(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of make_compatible_state(). + */ int SceneGraphReducer:: r_make_compatible_state(PandaNode *node, GeomTransformer &transformer) { int num_changed = 0; @@ -863,12 +793,9 @@ r_make_compatible_state(PandaNode *node, GeomTransformer &transformer) { return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_collect_vertex_data -// Access: Private -// Description: The recursive implementation of -// collect_vertex_data(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of collect_vertex_data(). + */ int SceneGraphReducer:: r_collect_vertex_data(PandaNode *node, int collect_bits, GeomTransformer &transformer, bool format_only) { @@ -922,12 +849,9 @@ r_collect_vertex_data(PandaNode *node, int collect_bits, return num_adjusted; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_make_nonindexed -// Access: Private -// Description: The recursive implementation of -// make_nonindexed(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of make_nonindexed(). + */ int SceneGraphReducer:: r_make_nonindexed(PandaNode *node, int nonindexed_bits) { int num_changed = 0; @@ -938,8 +862,8 @@ r_make_nonindexed(PandaNode *node, int nonindexed_bits) { for (int i = 0; i < num_geoms; ++i) { const Geom *geom = geom_node->get_geom(i); - // Check whether the geom is animated or dynamic, and skip it - // if the user specified so. + // Check whether the geom is animated or dynamic, and skip it if the + // user specified so. const GeomVertexData *data = geom->get_vertex_data(); int this_geom_bits = 0; if (data->get_format()->get_animation().get_animation_type() != @@ -952,8 +876,8 @@ r_make_nonindexed(PandaNode *node, int nonindexed_bits) { } if ((nonindexed_bits & this_geom_bits) == 0) { - // The geom meets the user's qualifications for making - // nonindexed, so do it. + // The geom meets the user's qualifications for making nonindexed, so + // do it. PT(Geom) mgeom = geom_node->modify_geom(i); num_changed += mgeom->make_nonindexed((nonindexed_bits & MN_composite_only) != 0); } @@ -970,11 +894,9 @@ r_make_nonindexed(PandaNode *node, int nonindexed_bits) { return num_changed; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_unify -// Access: Private -// Description: The recursive implementation of unify(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of unify(). + */ void SceneGraphReducer:: r_unify(PandaNode *node, int max_indices, bool preserve_order) { if (node->is_geom_node()) { @@ -990,13 +912,10 @@ r_unify(PandaNode *node, int max_indices, bool preserve_order) { Thread::consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_register_vertices -// Access: Private -// Description: Recursively calls -// GeomTransformer::register_vertices() on all GeomNodes -// at the indicated root and below. -//////////////////////////////////////////////////////////////////// +/** + * Recursively calls GeomTransformer::register_vertices() on all GeomNodes at + * the indicated root and below. + */ void SceneGraphReducer:: r_register_vertices(PandaNode *node, GeomTransformer &transformer) { if (node->is_geom_node()) { @@ -1011,11 +930,9 @@ r_register_vertices(PandaNode *node, GeomTransformer &transformer) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_decompose -// Access: Private -// Description: The recursive implementation of decompose(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of decompose(). + */ void SceneGraphReducer:: r_decompose(PandaNode *node) { if (node->is_geom_node()) { @@ -1030,11 +947,9 @@ r_decompose(PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphReducer::r_premunge -// Access: Private -// Description: The recursive implementation of premunge(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of premunge(). + */ void SceneGraphReducer:: r_premunge(PandaNode *node, const RenderState *state) { CPT(RenderState) next_state = state->compose(node->get_state()); diff --git a/panda/src/pgraph/sceneGraphReducer.h b/panda/src/pgraph/sceneGraphReducer.h index 4be6b27e12..43bc38d3eb 100644 --- a/panda/src/pgraph/sceneGraphReducer.h +++ b/panda/src/pgraph/sceneGraphReducer.h @@ -1,16 +1,15 @@ -// Filename: sceneGraphReducer.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphReducer.h + * @author drose + * @date 2002-03-14 + */ #ifndef SCENEGRAPHREDUCER_H #define SCENEGRAPHREDUCER_H @@ -29,17 +28,14 @@ class PandaNode; -//////////////////////////////////////////////////////////////////// -// Class : SceneGraphReducer -// Description : An interface for simplifying ("flattening") scene -// graphs by eliminating unneeded nodes and collapsing -// out unneeded state changes and transforms. -// -// This class is designed so that it may be inherited -// from and specialized, if needed, to fine-tune the -// flattening behavior, but normally the default -// behavior is sufficient. -//////////////////////////////////////////////////////////////////// +/** + * An interface for simplifying ("flattening") scene graphs by eliminating + * unneeded nodes and collapsing out unneeded state changes and transforms. + * + * This class is designed so that it may be inherited from and specialized, if + * needed, to fine-tune the flattening behavior, but normally the default + * behavior is sufficient. + */ class EXPCL_PANDA_PGRAPH SceneGraphReducer { PUBLISHED: INLINE SceneGraphReducer(GraphicsStateGuardianBase *gsg = NULL); @@ -64,55 +60,52 @@ PUBLISHED: }; enum CollectVertexData { - // If set, two GeomVertexDatas with different names will not be - // collected together. + // If set, two GeomVertexDatas with different names will not be collected + // together. CVD_name = 0x001, - // If set, a ModelNode begins a subgraph of nodes whose - // GeomVertexDatas will not be collected with nodes outside the - // subgraph. + // If set, a ModelNode begins a subgraph of nodes whose GeomVertexDatas + // will not be collected with nodes outside the subgraph. CVD_model = 0x002, - // If set, a non-identity transform begins a subgraph of nodes - // whose GeomVertexDatas will not be collected with nodes outside - // the subgraph. + // If set, a non-identity transform begins a subgraph of nodes whose + // GeomVertexDatas will not be collected with nodes outside the subgraph. CVD_transform = 0x004, - // If set, GeomVertexDatas with any usage_hint other than - // UH_static will not be collected with any other Geoms in a - // different GeomNode. However, two different dynamic Geoms - // within the same node might still be collected together. + // If set, GeomVertexDatas with any usage_hint other than UH_static will + // not be collected with any other Geoms in a different GeomNode. + // However, two different dynamic Geoms within the same node might still + // be collected together. CVD_avoid_dynamic = 0x008, - // If set, only those GeomVertexDatas within the same node might - // be collected together. + // If set, only those GeomVertexDatas within the same node might be + // collected together. CVD_one_node_only = 0x010, // If set, two GeomVertexDatas with different formats will not be - // collected together. If not set, GeomVertexDatas of different - // formats may be combined by expanding all GeomVertexDatas to the - // union of all defined columns. + // collected together. If not set, GeomVertexDatas of different formats + // may be combined by expanding all GeomVertexDatas to the union of all + // defined columns. CVD_format = 0x020, - // If set, two GeomVertexDatas with different usage hints (for - // instance, UH_static vs. UH_dynamic) will not be collected - // together. + // If set, two GeomVertexDatas with different usage hints (for instance, + // UH_static vs. UH_dynamic) will not be collected together. CVD_usage_hint = 0x040, - // If set, GeomVertexDatas with unanimated vertices will not be - // combined with GeomVertexDatas with animated vertices. - CVD_animation_type = 0x080, + // If set, GeomVertexDatas with unanimated vertices will not be combined + // with GeomVertexDatas with animated vertices. + CVD_animation_type = 0x080, }; enum MakeNonindexed { - // If set, only composite primitives such as tristrips and trifans - // will be made nonindexed; simple primitives such as triangles - // will be left indexed. + // If set, only composite primitives such as tristrips and trifans will be + // made nonindexed; simple primitives such as triangles will be left + // indexed. MN_composite_only = 0x001, - // If set any GeomVertexData with any animation indication will - // not be adjusted, whether the animation is to be performed on - // the CPU or on the graphics pipe. + // If set any GeomVertexData with any animation indication will not be + // adjusted, whether the animation is to be performed on the CPU or on the + // graphics pipe. MN_avoid_animated = 0x002, // If set, any GeomVertexData or Geom with a usage_hint other than @@ -136,7 +129,7 @@ PUBLISHED: int remove_column(PandaNode *root, const InternalName *column); int make_compatible_state(PandaNode *root); - + INLINE int make_compatible_format(PandaNode *root, int collect_bits = ~0); void decompose(PandaNode *root); @@ -162,15 +155,15 @@ protected: bool consider_siblings(PandaNode *parent_node, PandaNode *child1, PandaNode *child2); - bool do_flatten_child(PandaNode *grandparent_node, + bool do_flatten_child(PandaNode *grandparent_node, PandaNode *parent_node, PandaNode *child_node); - PandaNode *do_flatten_siblings(PandaNode *parent_node, + PandaNode *do_flatten_siblings(PandaNode *parent_node, PandaNode *child1, PandaNode *child2); - PT(PandaNode) collapse_nodes(PandaNode *node1, PandaNode *node2, + PT(PandaNode) collapse_nodes(PandaNode *node1, PandaNode *node2, bool siblings); - void choose_name(PandaNode *preserve, PandaNode *source1, + void choose_name(PandaNode *preserve, PandaNode *source1, PandaNode *source2); int r_remove_column(PandaNode *node, const InternalName *column, diff --git a/panda/src/pgraph/sceneSetup.I b/panda/src/pgraph/sceneSetup.I index 75afb67566..425c538d85 100644 --- a/panda/src/pgraph/sceneSetup.I +++ b/panda/src/pgraph/sceneSetup.I @@ -1,23 +1,19 @@ -// Filename: sceneSetup.I -// Created by: drose (27Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneSetup.I + * @author drose + * @date 2002-03-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SceneSetup:: SceneSetup() { _display_region = NULL; @@ -31,174 +27,136 @@ SceneSetup() { _cs_world_transform = TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_display_region -// Access: Published -// Description: Specifies the display region for the scene. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the display region for the scene. + */ INLINE void SceneSetup:: set_display_region(DisplayRegion *display_region) { _display_region = display_region; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_display_region -// Access: Published -// Description: Returns the display region for the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the display region for the scene. + */ INLINE DisplayRegion *SceneSetup:: get_display_region() const { return _display_region; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_viewport_size -// Access: Published -// Description: Specifies the size of the viewport (display region), -// in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size of the viewport (display region), in pixels. + */ INLINE void SceneSetup:: set_viewport_size(int width, int height) { _viewport_width = width; _viewport_height = height; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_viewport_width -// Access: Published -// Description: Returns the width of the viewport (display region) in -// pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the viewport (display region) in pixels. + */ INLINE int SceneSetup:: get_viewport_width() const { return _viewport_width; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_viewport_height -// Access: Published -// Description: Returns the height of the viewport (display region) in -// pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the viewport (display region) in pixels. + */ INLINE int SceneSetup:: get_viewport_height() const { return _viewport_height; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_scene_root -// Access: Published -// Description: Specifies the root node of the scene. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the root node of the scene. + */ INLINE void SceneSetup:: set_scene_root(const NodePath &scene_root) { _scene_root = scene_root; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_scene_root -// Access: Published -// Description: Returns the root node of the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root node of the scene. + */ INLINE const NodePath &SceneSetup:: get_scene_root() const { return _scene_root; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_camera_path -// Access: Published -// Description: Specifies the NodePath to the camera. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the NodePath to the camera. + */ INLINE void SceneSetup:: set_camera_path(const NodePath &camera_path) { _camera_path = camera_path; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_camera_path -// Access: Published -// Description: Returns the NodePath to the camera. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath to the camera. + */ INLINE const NodePath &SceneSetup:: get_camera_path() const { return _camera_path; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_camera_node -// Access: Published -// Description: Specifies the camera used to render the scene. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the camera used to render the scene. + */ INLINE void SceneSetup:: set_camera_node(Camera *camera_node) { _camera_node = camera_node; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_camera_node -// Access: Published -// Description: Returns the camera used to render the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera used to render the scene. + */ INLINE Camera *SceneSetup:: get_camera_node() const { return _camera_node; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_lens -// Access: Published -// Description: Indicates the particular Lens used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the particular Lens used for rendering. + */ INLINE void SceneSetup:: set_lens(const Lens *lens) { _lens = lens; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_lens -// Access: Published -// Description: Returns the particular Lens used for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular Lens used for rendering. + */ INLINE const Lens *SceneSetup:: get_lens() const { return _lens; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_inverted -// Access: Published -// Description: Changes the current setting of the inverted flag. -// When this is true, the scene is rendered into the -// window upside-down and backwards, that is, inverted -// as if viewed through a mirror placed on the floor. -//////////////////////////////////////////////////////////////////// +/** + * Changes the current setting of the inverted flag. When this is true, the + * scene is rendered into the window upside-down and backwards, that is, + * inverted as if viewed through a mirror placed on the floor. + */ INLINE void SceneSetup:: set_inverted(bool inverted) { _inverted = inverted; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_inverted -// Access: Published -// Description: Returns the current setting of the inverted flag. -// When this is true, the scene is rendered into the -// window upside-down, flipped like a mirror along the X -// axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the inverted flag. When this is true, the + * scene is rendered into the window upside-down, flipped like a mirror along + * the X axis. + */ INLINE bool SceneSetup:: get_inverted() const { return _inverted; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_cull_center -// Access: Published -// Description: Returns the point from which the culling operations -// will be performed. This is normally the camera, but -// if camera->set_cull_center() has been specified, it -// will be that special node instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point from which the culling operations will be performed. + * This is normally the camera, but if camera->set_cull_center() has been + * specified, it will be that special node instead. + */ INLINE const NodePath &SceneSetup:: get_cull_center() const { if (_camera_node->get_cull_center().is_empty()) { @@ -208,15 +166,12 @@ get_cull_center() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_cull_bounds -// Access: Published -// Description: Returns the bounding volume that should be used to -// perform view-frustum culling (in the space of -// get_cull_center()). This is normally the current -// lens' bounding volume, but it may be overridden with -// Camera::set_cull_bounds(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding volume that should be used to perform view-frustum + * culling (in the space of get_cull_center()). This is normally the current + * lens' bounding volume, but it may be overridden with + * Camera::set_cull_bounds(). + */ INLINE PT(BoundingVolume) SceneSetup:: get_cull_bounds() const { PT(BoundingVolume) bounds = _camera_node->get_cull_bounds(); @@ -227,116 +182,88 @@ get_cull_bounds() const { return _lens->make_bounds(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_initial_state -// Access: Published -// Description: Sets the initial state which is applied to all nodes -// in the scene, as if it were set at the top of the -// scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Sets the initial state which is applied to all nodes in the scene, as if it + * were set at the top of the scene graph. + */ INLINE void SceneSetup:: set_initial_state(const RenderState *state) { _initial_state = state; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_initial_state -// Access: Published -// Description: Returns the initial state as set by a previous call -// to set_initial_state(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the initial state as set by a previous call to set_initial_state(). + */ INLINE const RenderState *SceneSetup:: get_initial_state() const { return _initial_state; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_camera_transform -// Access: Published -// Description: Specifies the position of the camera relative to the -// starting node. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position of the camera relative to the starting node. + */ INLINE void SceneSetup:: set_camera_transform(const TransformState *camera_transform) { _camera_transform = camera_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_camera_transform -// Access: Published -// Description: Returns the position of the camera relative to the -// starting node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the camera relative to the starting node. + */ INLINE const TransformState *SceneSetup:: get_camera_transform() const { return _camera_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_world_transform -// Access: Published -// Description: Specifies the position of the starting node relative -// to the camera. This is the inverse of the camera -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position of the starting node relative to the camera. This + * is the inverse of the camera transform. + */ INLINE void SceneSetup:: set_world_transform(const TransformState *world_transform) { _world_transform = world_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_world_transform -// Access: Published -// Description: Returns the position of the starting node relative -// to the camera. This is the inverse of the camera -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the starting node relative to the camera. This is + * the inverse of the camera transform. + */ INLINE const TransformState *SceneSetup:: get_world_transform() const { return _world_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_cs_transform -// Access: Published -// Description: Specifies the transform from the camera's coordinate -// system to the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the transform from the camera's coordinate system to the GSG's + * internal coordinate system. + */ INLINE void SceneSetup:: set_cs_transform(const TransformState *cs_transform) { _cs_transform = cs_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_cs_transform -// Access: Published -// Description: Returns the transform from the camera's coordinate -// system to the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform from the camera's coordinate system to the GSG's + * internal coordinate system. + */ INLINE const TransformState *SceneSetup:: get_cs_transform() const { return _cs_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::set_cs_world_transform -// Access: Published -// Description: Specifies the position from the starting node -// relative to the camera, in the GSG's internal -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the position from the starting node relative to the camera, in + * the GSG's internal coordinate system. + */ INLINE void SceneSetup:: set_cs_world_transform(const TransformState *cs_world_transform) { _cs_world_transform = cs_world_transform; } -//////////////////////////////////////////////////////////////////// -// Function: SceneSetup::get_cs_world_transform -// Access: Published -// Description: Returns the position from the starting node -// relative to the camera, in the GSG's internal -// coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position from the starting node relative to the camera, in the + * GSG's internal coordinate system. + */ INLINE const TransformState *SceneSetup:: get_cs_world_transform() const { return _cs_world_transform; diff --git a/panda/src/pgraph/sceneSetup.cxx b/panda/src/pgraph/sceneSetup.cxx index 0e45ed1e3b..00857ff8e9 100644 --- a/panda/src/pgraph/sceneSetup.cxx +++ b/panda/src/pgraph/sceneSetup.cxx @@ -1,16 +1,15 @@ -// Filename: sceneSetup.cxx -// Created by: drose (27Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneSetup.cxx + * @author drose + * @date 2002-03-27 + */ #include "sceneSetup.h" diff --git a/panda/src/pgraph/sceneSetup.h b/panda/src/pgraph/sceneSetup.h index 2dd740edf3..d2ad0c0edb 100644 --- a/panda/src/pgraph/sceneSetup.h +++ b/panda/src/pgraph/sceneSetup.h @@ -1,16 +1,15 @@ -// Filename: sceneSetup.h -// Created by: drose (27Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneSetup.h + * @author drose + * @date 2002-03-27 + */ #ifndef SCENESETUP_H #define SCENESETUP_H @@ -26,12 +25,10 @@ class DisplayRegion; -//////////////////////////////////////////////////////////////////// -// Class : SceneSetup -// Description : This object holds the camera position, etc., and -// other general setup information for rendering a -// particular scene. -//////////////////////////////////////////////////////////////////// +/** + * This object holds the camera position, etc., and other general setup + * information for rendering a particular scene. + */ class EXPCL_PANDA_PGRAPH SceneSetup : public TypedReferenceCount { public: INLINE SceneSetup(); diff --git a/panda/src/pgraph/scissorAttrib.I b/panda/src/pgraph/scissorAttrib.I index 30dc087324..e23e59ac99 100644 --- a/panda/src/pgraph/scissorAttrib.I +++ b/panda/src/pgraph/scissorAttrib.I @@ -1,52 +1,40 @@ -// Filename: scissorAttrib.I -// Created by: drose (29Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorAttrib.I + * @author drose + * @date 2008-07-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::make -// Access: Published, Static -// Description: Constructs a ScissorAttrib that restricts rendering -// to the indicated frame within the current -// DisplayRegion. (0,0) is the lower-left corner of the -// DisplayRegion, and (1,1) is the upper-right corner. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a ScissorAttrib that restricts rendering to the indicated frame + * within the current DisplayRegion. (0,0) is the lower-left corner of the + * DisplayRegion, and (1,1) is the upper-right corner. + */ INLINE CPT(RenderAttrib) ScissorAttrib:: make(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { return make(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::is_off -// Access: Published -// Description: Returns true if the ScissorAttrib is an 'off' -// ScissorAttrib, indicating that scissor testing is -// disabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ScissorAttrib is an 'off' ScissorAttrib, indicating + * that scissor testing is disabled. + */ INLINE bool ScissorAttrib:: is_off() const { return _off; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::get_frame -// Access: Published -// Description: Returns the left, right, bottom, top coordinates of -// the scissor frame. This defines a frame within the -// current DisplayRegion, where 0,0 is the lower-left -// corner of the DisplayRegion, and 1,1 is the -// upper-right corner. -//////////////////////////////////////////////////////////////////// +/** + * Returns the left, right, bottom, top coordinates of the scissor frame. + * This defines a frame within the current DisplayRegion, where 0,0 is the + * lower-left corner of the DisplayRegion, and 1,1 is the upper-right corner. + */ INLINE const LVecBase4 &ScissorAttrib:: get_frame() const { return _frame; diff --git a/panda/src/pgraph/scissorAttrib.cxx b/panda/src/pgraph/scissorAttrib.cxx index 29814d9668..599fab1e1d 100644 --- a/panda/src/pgraph/scissorAttrib.cxx +++ b/panda/src/pgraph/scissorAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: scissorAttrib.cxx -// Created by: drose (29Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorAttrib.cxx + * @author drose + * @date 2008-07-29 + */ #include "scissorAttrib.h" #include "graphicsStateGuardianBase.h" @@ -24,12 +23,9 @@ TypeHandle ScissorAttrib::_type_handle; int ScissorAttrib::_attrib_slot; CPT(RenderAttrib) ScissorAttrib::_off_attrib; -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::Constructor -// Access: Private -// Description: Use ScissorAttrib::make() to construct a new -// ScissorAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ScissorAttrib::make() to construct a new ScissorAttrib object. + */ ScissorAttrib:: ScissorAttrib(const LVecBase4 &frame) : _frame(frame), @@ -42,12 +38,10 @@ ScissorAttrib(const LVecBase4 &frame) : _frame[3] = max(min(_frame[3], (PN_stdfloat)1.0), _frame[2]); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::make_off -// Access: Published, Static -// Description: Constructs a new ScissorAttrib object that removes -// the scissor region and fills the DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ScissorAttrib object that removes the scissor region and + * fills the DisplayRegion. + */ CPT(RenderAttrib) ScissorAttrib:: make_off() { if (_off_attrib != NULL) { @@ -59,58 +53,47 @@ make_off() { return _off_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::make -// Access: Published, Static -// Description: Constructs a ScissorAttrib that restricts rendering -// to the indicated frame within the current -// DisplayRegion. (0,0) is the lower-left corner of the -// DisplayRegion, and (1,1) is the upper-right corner. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a ScissorAttrib that restricts rendering to the indicated frame + * within the current DisplayRegion. (0,0) is the lower-left corner of the + * DisplayRegion, and (1,1) is the upper-right corner. + */ CPT(RenderAttrib) ScissorAttrib:: make(const LVecBase4 &frame) { ScissorAttrib *attrib = new ScissorAttrib(frame); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ScissorAttrib:: make_default() { return make_off(); - //return return_new(new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f))); + // return return_new(new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f))); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ScissorAttrib:: output(ostream &out) const { out << get_type() << ":[" << _frame << "]"; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ScissorAttrib -// types to return a unique number indicating whether -// this ScissorAttrib is equivalent to the other one. -// -// This should return 0 if the two ScissorAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ScissorAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ScissorAttrib types to return a unique + * number indicating whether this ScissorAttrib is equivalent to the other + * one. + * + * This should return 0 if the two ScissorAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ScissorAttrib objects whose get_type() + * functions return the same. + */ int ScissorAttrib:: compare_to_impl(const RenderAttrib *other) const { const ScissorAttrib *ta = (const ScissorAttrib *)other; @@ -130,16 +113,12 @@ compare_to_impl(const RenderAttrib *other) const { return _frame.compare_to(ta->_frame); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ScissorAttrib:: get_hash_impl() const { size_t hash = 0; @@ -149,23 +128,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) ScissorAttrib:: compose_impl(const RenderAttrib *other) const { if (_off) { @@ -187,23 +160,18 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ScissorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ScissorAttrib. + */ void ScissorAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ScissorAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -212,14 +180,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_off); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ScissorAttrib is encountered -// in the Bam file. It should create the ScissorAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ScissorAttrib is encountered in the Bam file. It should create the + * ScissorAttrib and extract its information from the file. + */ TypedWritable *ScissorAttrib:: make_from_bam(const FactoryParams ¶ms) { ScissorAttrib *attrib = new ScissorAttrib(LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); @@ -232,13 +197,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ScissorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ScissorAttrib. + */ void ScissorAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/scissorAttrib.h b/panda/src/pgraph/scissorAttrib.h index 88475a50fc..941d704a7c 100644 --- a/panda/src/pgraph/scissorAttrib.h +++ b/panda/src/pgraph/scissorAttrib.h @@ -1,16 +1,15 @@ -// Filename: scissorAttrib.h -// Created by: drose (29Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorAttrib.h + * @author drose + * @date 2008-07-29 + */ #ifndef SCISSORATTRIB_H #define SCISSORATTRIB_H @@ -22,22 +21,18 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ScissorAttrib -// Description : This restricts rendering to within a rectangular -// region of the scene, without otherwise affecting the -// viewport or lens properties. Geometry that falls -// outside the scissor region is not rendered. It is -// akin to the OpenGL glScissor() function. -// -// The ScissorAttrib always specifies its region -// relative to its enclosing DisplayRegion, in screen -// space, and performs no culling. -// -// See ScissorEffect if you wish to define a -// region relative to 2-D or 3-D coordinates in the -// scene graph, with culling. -//////////////////////////////////////////////////////////////////// +/** + * This restricts rendering to within a rectangular region of the scene, + * without otherwise affecting the viewport or lens properties. Geometry that + * falls outside the scissor region is not rendered. It is akin to the OpenGL + * glScissor() function. + * + * The ScissorAttrib always specifies its region relative to its enclosing + * DisplayRegion, in screen space, and performs no culling. + * + * See ScissorEffect if you wish to define a region relative to 2-D or 3-D + * coordinates in the scene graph, with culling. + */ class EXPCL_PANDA_PGRAPH ScissorAttrib : public RenderAttrib { private: ScissorAttrib(const LVecBase4 &frame); @@ -107,4 +102,3 @@ private: #include "scissorAttrib.I" #endif - diff --git a/panda/src/pgraph/scissorEffect.I b/panda/src/pgraph/scissorEffect.I index f3a4c1a5f3..c48c988288 100644 --- a/panda/src/pgraph/scissorEffect.I +++ b/panda/src/pgraph/scissorEffect.I @@ -1,89 +1,70 @@ -// Filename: scissorEffect.I -// Created by: drose (30Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorEffect.I + * @author drose + * @date 2008-07-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::is_screen -// Access: Published -// Description: Returns true if the ScissorEffect is a screen-based -// effect, meaning get_frame() has a meaningful value, -// but get_a() and get_b() do not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ScissorEffect is a screen-based effect, meaning + * get_frame() has a meaningful value, but get_a() and get_b() do not. + */ INLINE bool ScissorEffect:: is_screen() const { return _screen; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::get_frame -// Access: Published -// Description: If is_screen() returns true, this method may be -// called to query the screen-based scissor frame. This -// is a series of left, right, bottom, top, representing -// the scissor frame relative to the current -// DisplayRegion. See ScissorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * If is_screen() returns true, this method may be called to query the screen- + * based scissor frame. This is a series of left, right, bottom, top, + * representing the scissor frame relative to the current DisplayRegion. See + * ScissorAttrib. + */ INLINE const LVecBase4 &ScissorEffect:: get_frame() const { return _frame; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::get_num_points -// Access: Published -// Description: Returns the number of node-based scissor points. See -// get_point(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of node-based scissor points. See get_point(). + */ INLINE int ScissorEffect:: get_num_points() const { return (int)_points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::get_point -// Access: Published -// Description: If is_screen() returns false, then get_num_points() and -// get_point() may be called to query the node-based scissor -// frame. These return n points (at least two), which -// are understood to be in the space of this node, and -// which define any opposite corners of the scissor -// frame. -//////////////////////////////////////////////////////////////////// +/** + * If is_screen() returns false, then get_num_points() and get_point() may be + * called to query the node-based scissor frame. These return n points (at + * least two), which are understood to be in the space of this node, and which + * define any opposite corners of the scissor frame. + */ INLINE const LPoint3 &ScissorEffect:: get_point(int n) const { nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); return _points[n]._p; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::get_node -// Access: Published -// Description: Returns the node to which the nth point is relative, -// or empty NodePath to indicate the current node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node to which the nth point is relative, or empty NodePath to + * indicate the current node. + */ INLINE NodePath ScissorEffect:: get_node(int n) const { nassertr(n >= 0 && n < (int)_points.size(), NodePath()); return _points[n]._node; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::get_clip -// Access: Published -// Description: Returns true if this ScissorEffect actually enables -// scissoring, or false if it culls only. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ScissorEffect actually enables scissoring, or false if + * it culls only. + */ INLINE bool ScissorEffect:: get_clip() const { return _clip; diff --git a/panda/src/pgraph/scissorEffect.cxx b/panda/src/pgraph/scissorEffect.cxx index 05867fd913..9794250346 100644 --- a/panda/src/pgraph/scissorEffect.cxx +++ b/panda/src/pgraph/scissorEffect.cxx @@ -1,16 +1,15 @@ -// Filename: scissorEffect.cxx -// Created by: drose (30Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorEffect.cxx + * @author drose + * @date 2008-07-30 + */ #include "scissorEffect.h" #include "scissorAttrib.h" @@ -26,16 +25,13 @@ TypeHandle ScissorEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::Constructor -// Access: Private -// Description: Use ScissorEffect::make() to construct a new -// ScissorEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use ScissorEffect::make() to construct a new ScissorEffect object. + */ ScissorEffect:: ScissorEffect(bool screen, const LVecBase4 &frame, const PointDef *points, int num_points, bool clip) : - _screen(screen), _frame(frame), _clip(clip) + _screen(screen), _frame(frame), _clip(clip) { _points.reserve(num_points); for (int i = 0; i < num_points; ++i) { @@ -43,57 +39,46 @@ ScissorEffect(bool screen, const LVecBase4 &frame, } } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::Copy Constructor -// Access: Private -// Description: Use ScissorEffect::make() to construct a new -// ScissorEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use ScissorEffect::make() to construct a new ScissorEffect object. + */ ScissorEffect:: ScissorEffect(const ScissorEffect ©) : - _screen(copy._screen), + _screen(copy._screen), _frame(copy._frame), _points(copy._points), _clip(copy._clip) { } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_screen -// Access: Published, Static -// Description: Constructs a new screen-relative ScissorEffect. The -// frame defines a left, right, bottom, top region, -// relative to the DisplayRegion. See ScissorAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new screen-relative ScissorEffect. The frame defines a left, + * right, bottom, top region, relative to the DisplayRegion. See + * ScissorAttrib. + */ CPT(RenderEffect) ScissorEffect:: make_screen(const LVecBase4 &frame, bool clip) { ScissorEffect *effect = new ScissorEffect(true, frame, NULL, 0, clip); return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_node -// Access: Published, Static -// Description: Constructs a new node-relative ScissorEffect, with no -// points. This empty ScissorEffect does nothing. You -// must then call add_point a number of times to add the -// points you require. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new node-relative ScissorEffect, with no points. This empty + * ScissorEffect does nothing. You must then call add_point a number of times + * to add the points you require. + */ CPT(RenderEffect) ScissorEffect:: make_node(bool clip) { ScissorEffect *effect = new ScissorEffect(false, LVecBase4::zero(), NULL, 0, clip); return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_node -// Access: Published, Static -// Description: Constructs a new node-relative ScissorEffect. The -// two points are understood to be relative to the -// indicated node, or the current node if the NodePath -// is empty, and determine the diagonally opposite -// corners of the scissor region. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new node-relative ScissorEffect. The two points are + * understood to be relative to the indicated node, or the current node if the + * NodePath is empty, and determine the diagonally opposite corners of the + * scissor region. + */ CPT(RenderEffect) ScissorEffect:: make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node) { PointDef points[2]; @@ -105,15 +90,12 @@ make_node(const LPoint3 &a, const LPoint3 &b, const NodePath &node) { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_node -// Access: Published, Static -// Description: Constructs a new node-relative ScissorEffect. The -// four points are understood to be relative to the -// indicated node, or the current node if the indicated -// NodePath is empty, and determine four points -// surrounding the scissor region. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new node-relative ScissorEffect. The four points are + * understood to be relative to the indicated node, or the current node if the + * indicated NodePath is empty, and determine four points surrounding the + * scissor region. + */ CPT(RenderEffect) ScissorEffect:: make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d, const NodePath &node) { PointDef points[4]; @@ -129,18 +111,14 @@ make_node(const LPoint3 &a, const LPoint3 &b, const LPoint3 &c, const LPoint3 &d return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::add_point -// Access: Published -// Description: Returns a new ScissorEffect with the indicated point -// added. It is only valid to call this on a "node" -// type ScissorEffect. The full set of points, -// projected into screen space, defines the bounding -// volume of the rectangular scissor region. -// -// Each point may be relative to a different node, if -// desired. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ScissorEffect with the indicated point added. It is only + * valid to call this on a "node" type ScissorEffect. The full set of points, + * projected into screen space, defines the bounding volume of the rectangular + * scissor region. + * + * Each point may be relative to a different node, if desired. + */ CPT(RenderEffect) ScissorEffect:: add_point(const LPoint3 &p, const NodePath &node) const { nassertr(!is_screen(), this); @@ -152,12 +130,9 @@ add_point(const LPoint3 &p, const NodePath &node) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::xform -// Access: Public, Virtual -// Description: Returns a new RenderEffect transformed by the -// indicated matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new RenderEffect transformed by the indicated matrix. + */ CPT(RenderEffect) ScissorEffect:: xform(const LMatrix4 &mat) const { if (is_screen()) { @@ -176,11 +151,9 @@ xform(const LMatrix4 &mat) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ScissorEffect:: output(ostream &out) const { out << get_type() << ":"; @@ -203,37 +176,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool ScissorEffect:: has_cull_callback() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void ScissorEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -286,7 +250,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, frame[3] = max(frame[3], pr[1]); } } - + // Scale from -1..1 to 0..1. frame[0] = (frame[0] + 1.0f) * 0.5f; frame[1] = (frame[1] + 1.0f) * 0.5f; @@ -303,11 +267,11 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, if (_clip) { CPT(RenderAttrib) scissor_attrib = ScissorAttrib::make(frame); CPT(RenderState) state = RenderState::make(scissor_attrib); - node_state = node_state->compose(state); + node_state = node_state->compose(state); } - // Set up the culling. We do this by extruding the four corners of - // the frame into the eight corners of the bounding frustum. + // Set up the culling. We do this by extruding the four corners of the + // frame into the eight corners of the bounding frustum. PT(GeometricBoundingVolume) frustum = make_frustum(lens, frame); if (frustum != (GeometricBoundingVolume *)NULL) { frustum->xform(modelview_transform->get_inverse()->get_mat()); @@ -315,21 +279,18 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, } } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ScissorEffect -// types to return a unique number indicating whether -// this ScissorEffect is equivalent to the other one. -// -// This should return 0 if the two ScissorEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ScissorEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ScissorEffect types to return a unique + * number indicating whether this ScissorEffect is equivalent to the other + * one. + * + * This should return 0 if the two ScissorEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ScissorEffect objects whose get_type() + * functions return the same. + */ int ScissorEffect:: compare_to_impl(const RenderEffect *other) const { const ScissorEffect *ta; @@ -365,23 +326,18 @@ compare_to_impl(const RenderEffect *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ScissorEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ScissorEffect. + */ void ScissorEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ScissorEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); @@ -399,14 +355,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_clip); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ScissorEffect is encountered -// in the Bam file. It should create the ScissorEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ScissorEffect is encountered in the Bam file. It should create the + * ScissorEffect and extract its information from the file. + */ TypedWritable *ScissorEffect:: make_from_bam(const FactoryParams ¶ms) { ScissorEffect *effect = new ScissorEffect(true, LVecBase4::zero(), NULL, 0, false); @@ -419,13 +372,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ScissorEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ScissorEffect. + */ void ScissorEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); @@ -445,12 +395,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { _clip = scan.get_bool(); } -//////////////////////////////////////////////////////////////////// -// Function: ScissorEffect::make_frustum -// Access: Private -// Description: Constructs a new bounding frustum from the lens -// properties, given the indicated scissor frame. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new bounding frustum from the lens properties, given the + * indicated scissor frame. + */ PT(GeometricBoundingVolume) ScissorEffect:: make_frustum(const Lens *lens, const LVecBase4 &frame) const{ // Scale the frame from 0 .. 1 into -1 .. 1. diff --git a/panda/src/pgraph/scissorEffect.h b/panda/src/pgraph/scissorEffect.h index 9a86f17fbc..4ac2e9a87d 100644 --- a/panda/src/pgraph/scissorEffect.h +++ b/panda/src/pgraph/scissorEffect.h @@ -1,16 +1,15 @@ -// Filename: scissorEffect.h -// Created by: drose (30Jul08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file scissorEffect.h + * @author drose + * @date 2008-07-30 + */ #ifndef SCISSOREFFECT_H #define SCISSOREFFECT_H @@ -24,14 +23,11 @@ // Forward declarations class Lens; -//////////////////////////////////////////////////////////////////// -// Class : ScissorEffect -// Description : This provides a higher-level wrapper around -// ScissorAttrib. It allows for the scissor region to -// be defined via points relative to the current node, -// and also performs culling based on the scissor -// region. -//////////////////////////////////////////////////////////////////// +/** + * This provides a higher-level wrapper around ScissorAttrib. It allows for + * the scissor region to be defined via points relative to the current node, + * and also performs culling based on the scissor region. + */ class EXPCL_PANDA_PGRAPH ScissorEffect : public RenderEffect { private: class PointDef { @@ -91,7 +87,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -113,4 +109,3 @@ private: #include "scissorEffect.I" #endif - diff --git a/panda/src/pgraph/shadeModelAttrib.I b/panda/src/pgraph/shadeModelAttrib.I index 6ed751e64e..78f16d90f5 100644 --- a/panda/src/pgraph/shadeModelAttrib.I +++ b/panda/src/pgraph/shadeModelAttrib.I @@ -1,35 +1,28 @@ -// Filename: shadeModelAttrib.I -// Created by: drose (14Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shadeModelAttrib.I + * @author drose + * @date 2005-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::Constructor -// Access: Private -// Description: Use ShadeModelAttrib::make() to construct a new -// ShadeModelAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use ShadeModelAttrib::make() to construct a new ShadeModelAttrib object. + */ INLINE ShadeModelAttrib:: ShadeModelAttrib(ShadeModelAttrib::Mode mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::get_mode -// Access: Published -// Description: Returns the shade mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shade mode. + */ INLINE ShadeModelAttrib::Mode ShadeModelAttrib:: get_mode() const { return _mode; diff --git a/panda/src/pgraph/shadeModelAttrib.cxx b/panda/src/pgraph/shadeModelAttrib.cxx index 24f6ef3585..dea61a8521 100644 --- a/panda/src/pgraph/shadeModelAttrib.cxx +++ b/panda/src/pgraph/shadeModelAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: shadeModelAttrib.cxx -// Created by: drose (14Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shadeModelAttrib.cxx + * @author drose + * @date 2005-03-14 + */ #include "shadeModelAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,36 +22,28 @@ TypeHandle ShadeModelAttrib::_type_handle; int ShadeModelAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::make -// Access: Published, Static -// Description: Constructs a new ShadeModelAttrib object that specifies -// whether to draw polygons with flat shading or with -// per-vertex (smooth) shading. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ShadeModelAttrib object that specifies whether to draw + * polygons with flat shading or with per-vertex (smooth) shading. + */ CPT(RenderAttrib) ShadeModelAttrib:: make(ShadeModelAttrib::Mode mode) { ShadeModelAttrib *attrib = new ShadeModelAttrib(mode); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) ShadeModelAttrib:: make_default() { return return_new(new ShadeModelAttrib(M_smooth)); } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ShadeModelAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -67,37 +58,30 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ShadeModelAttrib -// types to return a unique number indicating whether -// this ShadeModelAttrib is equivalent to the other one. -// -// This should return 0 if the two ShadeModelAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ShadeModelAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ShadeModelAttrib types to return a + * unique number indicating whether this ShadeModelAttrib is equivalent to the + * other one. + * + * This should return 0 if the two ShadeModelAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ShadeModelAttrib objects whose get_type() + * functions return the same. + */ int ShadeModelAttrib:: compare_to_impl(const RenderAttrib *other) const { const ShadeModelAttrib *ta = (const ShadeModelAttrib *)other; return (int)_mode - (int)ta->_mode; } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t ShadeModelAttrib:: get_hash_impl() const { size_t hash = 0; @@ -105,23 +89,17 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) ShadeModelAttrib:: compose_impl(const RenderAttrib *other) const { const ShadeModelAttrib *ta = (const ShadeModelAttrib *)other; @@ -130,23 +108,18 @@ compose_impl(const RenderAttrib *other) const { return make(mode); } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ShadeModelAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ShadeModelAttrib. + */ void ShadeModelAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ShadeModelAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -154,14 +127,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ShadeModelAttrib is encountered -// in the Bam file. It should create the ShadeModelAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ShadeModelAttrib is encountered in the Bam file. It should create the + * ShadeModelAttrib and extract its information from the file. + */ TypedWritable *ShadeModelAttrib:: make_from_bam(const FactoryParams ¶ms) { ShadeModelAttrib *attrib = new ShadeModelAttrib(M_smooth); @@ -174,13 +144,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: ShadeModelAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ShadeModelAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ShadeModelAttrib. + */ void ShadeModelAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/shadeModelAttrib.h b/panda/src/pgraph/shadeModelAttrib.h index b2edff59ed..c9550bccac 100644 --- a/panda/src/pgraph/shadeModelAttrib.h +++ b/panda/src/pgraph/shadeModelAttrib.h @@ -1,16 +1,15 @@ -// Filename: shadeModelAttrib.h -// Created by: drose (14Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shadeModelAttrib.h + * @author drose + * @date 2005-03-14 + */ #ifndef SHADEMODELATTRIB_H #define SHADEMODELATTRIB_H @@ -21,11 +20,10 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ShadeModelAttrib -// Description : Specifies whether flat shading (per-polygon) or -// smooth shading (per-vertex) is in effect. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether flat shading (per-polygon) or smooth shading (per-vertex) + * is in effect. + */ class EXPCL_PANDA_PGRAPH ShadeModelAttrib : public RenderAttrib { PUBLISHED: enum Mode { @@ -68,7 +66,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -92,4 +90,3 @@ private: #include "shadeModelAttrib.I" #endif - diff --git a/panda/src/pgraph/shaderAttrib.I b/panda/src/pgraph/shaderAttrib.I index f6eba60d83..f3667b27d9 100644 --- a/panda/src/pgraph/shaderAttrib.I +++ b/panda/src/pgraph/shaderAttrib.I @@ -1,24 +1,21 @@ -// Filename: shaderAttrib.I -// Created by: sshodhan (10Jul04) -// Updated by: weifengh, PandaSE(15Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderAttrib.I + * @author sshodhan + * @date 2004-07-10 + * @author weifengh, PandaSE + * @date 2010-04-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderAttrib:: ShaderAttrib() : _shader(NULL), @@ -36,11 +33,9 @@ ShaderAttrib() : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderAttrib:: ShaderAttrib(const ShaderAttrib ©) : _shader(copy._shader), @@ -59,268 +54,210 @@ ShaderAttrib(const ShaderAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::has_shader -// Access: Published -// Description: If true, the shader field of this attribute overrides -// the shader field of the parent attribute. -//////////////////////////////////////////////////////////////////// +/** + * If true, the shader field of this attribute overrides the shader field of + * the parent attribute. + */ INLINE bool ShaderAttrib:: has_shader() const { return _has_shader; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::auto_shader -// Access: Published -// Description: If true, then this ShaderAttrib does not contain an -// explicit shader - instead, it requests the automatic -// generation of a shader. -//////////////////////////////////////////////////////////////////// +/** + * If true, then this ShaderAttrib does not contain an explicit shader - + * instead, it requests the automatic generation of a shader. + */ INLINE bool ShaderAttrib:: auto_shader() const { return _auto_shader; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::get_shader_priority -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int ShaderAttrib:: get_shader_priority() const { return _shader_priority; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::get_instance_count -// Access: Published -// Description: Returns the number of geometry instances. A value -// of 0 means not to use instancing at all. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of geometry instances. A value of 0 means not to use + * instancing at all. + */ INLINE int ShaderAttrib:: get_instance_count() const { return _instance_count; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ShaderAttrib:: get_flag(int index) const { return (_flags & (1<_instance_count == 0) { attr->_instance_count = over->_instance_count; } else { - // If an instance count is set, check if the other attrib has an instance count set, - // if so, override it, otherwise just keep the current instance count + // If an instance count is set, check if the other attrib has an instance + // count set, if so, override it, otherwise just keep the current instance + // count if (over->_instance_count > 0) { attr->_instance_count = over->_instance_count; } @@ -715,16 +650,14 @@ compose_impl(const RenderAttrib *other) const { return return_new(attr); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) ShaderAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { - // For a ShaderAttrib, we only need to preserve the auto-shader - // flags. Custom shaders, and custom shader inputs, aren't relevant - // to the shader generator. + // For a ShaderAttrib, we only need to preserve the auto-shader flags. + // Custom shaders, and custom shader inputs, aren't relevant to the shader + // generator. ShaderAttrib *attrib = new ShaderAttrib; attrib->_auto_shader = _auto_shader; attrib->_has_shader = _has_shader; @@ -737,13 +670,10 @@ get_auto_shader_attrib_impl(const RenderState *state) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderAttrib::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a Shader object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Shader object + */ void ShaderAttrib:: register_with_read_factory() { // IMPLEMENT ME } - diff --git a/panda/src/pgraph/shaderAttrib.h b/panda/src/pgraph/shaderAttrib.h index 0f686f9aac..9159d52e18 100644 --- a/panda/src/pgraph/shaderAttrib.h +++ b/panda/src/pgraph/shaderAttrib.h @@ -1,19 +1,20 @@ -// Filename: shaderAttrib.h -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads -// for set_shader_input) -// Updated by: weifengh, PandaSE(15Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderAttrib.h + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-06 + * for set_shader_input) + * @author weifengh, PandaSE + * @date 2010-04-15 + */ #ifndef SHADERATTRIB_H #define SHADERATTRIB_H @@ -31,10 +32,9 @@ #include "pta_LVecBase3.h" #include "pta_LVecBase2.h" -//////////////////////////////////////////////////////////////////// -// Class : ShaderAttrib -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_PGRAPH ShaderAttrib: public RenderAttrib { private: INLINE ShaderAttrib(); @@ -174,6 +174,3 @@ private: #include "shaderAttrib.I" #endif // SHADERATTRIB_H - - - diff --git a/panda/src/pgraph/shaderInput.I b/panda/src/pgraph/shaderInput.I index 5a060bb0e6..52f46369ad 100644 --- a/panda/src/pgraph/shaderInput.I +++ b/panda/src/pgraph/shaderInput.I @@ -1,32 +1,28 @@ -// Filename: shaderInput.I -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE (06Apr10) -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderInput.I + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ~ShaderInput() { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, int priority) : _name(MOVE(name)), @@ -35,11 +31,9 @@ ShaderInput(CPT_InternalName name, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, int priority) : _name(MOVE(name)), @@ -49,11 +43,9 @@ ShaderInput(CPT_InternalName name, Texture *tex, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) : _name(MOVE(name)), @@ -63,11 +55,9 @@ ShaderInput(CPT_InternalName name, ParamValueBase *param, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) : _name(MOVE(name)), @@ -77,11 +67,9 @@ ShaderInput(CPT_InternalName name, const PTA_float &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) : _name(MOVE(name)), @@ -91,11 +79,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4f &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) : _name(MOVE(name)), @@ -105,11 +91,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3f &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) : _name(MOVE(name)), @@ -119,11 +103,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2f &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) : _name(MOVE(name)), @@ -134,11 +116,9 @@ ShaderInput(CPT_InternalName name, const LVecBase4f &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) : _name(MOVE(name)), @@ -149,11 +129,9 @@ ShaderInput(CPT_InternalName name, const LVecBase3f &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) : _name(MOVE(name)), @@ -164,11 +142,9 @@ ShaderInput(CPT_InternalName name, const LVecBase2f &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) : _name(MOVE(name)), @@ -178,11 +154,9 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4f &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) : _name(MOVE(name)), @@ -192,11 +166,9 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3f &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) : _name(MOVE(name)), @@ -206,11 +178,9 @@ ShaderInput(CPT_InternalName name, const LMatrix4f &mat, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) : _name(MOVE(name)), @@ -220,11 +190,9 @@ ShaderInput(CPT_InternalName name, const LMatrix3f &mat, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) : _name(MOVE(name)), @@ -234,11 +202,9 @@ ShaderInput(CPT_InternalName name, const PTA_double &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) : _name(MOVE(name)), @@ -248,11 +214,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4d &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) : _name(MOVE(name)), @@ -262,11 +226,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3d &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) : _name(MOVE(name)), @@ -276,11 +238,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2d &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) : _name(MOVE(name)), @@ -291,11 +251,9 @@ ShaderInput(CPT_InternalName name, const LVecBase4d &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) : _name(MOVE(name)), @@ -306,11 +264,9 @@ ShaderInput(CPT_InternalName name, const LVecBase3d &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) : _name(MOVE(name)), @@ -321,11 +277,9 @@ ShaderInput(CPT_InternalName name, const LVecBase2d &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) : _name(MOVE(name)), @@ -335,11 +289,9 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix4d &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) : _name(MOVE(name)), @@ -349,11 +301,9 @@ ShaderInput(CPT_InternalName name, const PTA_LMatrix3d &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) : _name(MOVE(name)), @@ -363,11 +313,9 @@ ShaderInput(CPT_InternalName name, const LMatrix4d &mat, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) : _name(MOVE(name)), @@ -377,11 +325,9 @@ ShaderInput(CPT_InternalName name, const LMatrix3d &mat, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) : _name(MOVE(name)), @@ -391,11 +337,9 @@ ShaderInput(CPT_InternalName name, const PTA_int &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) : _name(MOVE(name)), @@ -405,11 +349,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase4i &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) : _name(MOVE(name)), @@ -419,11 +361,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase3i &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) : _name(MOVE(name)), @@ -433,11 +373,9 @@ ShaderInput(CPT_InternalName name, const PTA_LVecBase2i &ptr, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) : _name(MOVE(name)), @@ -448,11 +386,9 @@ ShaderInput(CPT_InternalName name, const LVecBase4i &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) : _name(MOVE(name)), @@ -463,11 +399,9 @@ ShaderInput(CPT_InternalName name, const LVecBase3i &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ShaderInput:: ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) : _name(MOVE(name)), @@ -478,61 +412,49 @@ ShaderInput(CPT_InternalName name, const LVecBase2i &vec, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const InternalName *ShaderInput:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_value_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int ShaderInput:: get_value_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_priority -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int ShaderInput:: get_priority() const { return _priority; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_vector -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVecBase4 &ShaderInput:: get_vector() const { return _stored_vector; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_ptr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const Shader::ShaderPtrData &ShaderInput:: get_ptr() const { return _stored_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_param -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ParamValueBase *ShaderInput:: get_param() const { return DCAST(ParamValueBase, _value); diff --git a/panda/src/pgraph/shaderInput.cxx b/panda/src/pgraph/shaderInput.cxx index ecb281f6f3..6ba5499490 100644 --- a/panda/src/pgraph/shaderInput.cxx +++ b/panda/src/pgraph/shaderInput.cxx @@ -1,16 +1,15 @@ -// Filename: shaderInput.cxx -// Created by: jyelon (01Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderInput.cxx + * @author jyelon + * @date 2005-09-01 + */ #include "shaderInput.h" #include "paramNodePath.h" @@ -18,13 +17,10 @@ TypeHandle ShaderInput::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_blank -// Access: Public, Static -// Description: Returns a static ShaderInput object with -// name NULL, priority zero, type INVALID, and -// all value-fields cleared. -//////////////////////////////////////////////////////////////////// +/** + * Returns a static ShaderInput object with name NULL, priority zero, type + * INVALID, and all value-fields cleared. + */ const ShaderInput *ShaderInput:: get_blank() { static CPT(ShaderInput) blank; @@ -34,11 +30,9 @@ get_blank() { return blank; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShaderInput:: ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : _name(MOVE(name)), @@ -48,11 +42,9 @@ ShaderInput(CPT_InternalName name, const NodePath &np, int priority) : { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, int n, int priority) : _name(MOVE(name)), @@ -62,11 +54,9 @@ ShaderInput(CPT_InternalName name, Texture *tex, bool read, bool write, int z, i { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ShaderInput:: ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, int priority) : _name(MOVE(name)), @@ -76,22 +66,18 @@ ShaderInput(CPT_InternalName name, Texture *tex, const SamplerState &sampler, in { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_nodepath -// Access: Published -// Description: Warning: no error checking is done. This *will* -// crash if get_value_type() is not M_nodepath. -//////////////////////////////////////////////////////////////////// +/** + * Warning: no error checking is done. This *will* crash if get_value_type() + * is not M_nodepath. + */ const NodePath &ShaderInput:: get_nodepath() const { return DCAST(ParamNodePath, _value)->get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Texture *ShaderInput:: get_texture() const { switch (_type) { @@ -109,11 +95,9 @@ get_texture() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::get_sampler -// Access: Published -// Description: Warning: no error checking is done. -//////////////////////////////////////////////////////////////////// +/** + * Warning: no error checking is done. + */ const SamplerState &ShaderInput:: get_sampler() const { return (_type == M_texture_sampler) @@ -121,11 +105,9 @@ get_sampler() const { : get_texture()->get_default_sampler(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderInput::register_with_read_factory -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ShaderInput:: register_with_read_factory() { // IMPLEMENT ME diff --git a/panda/src/pgraph/shaderInput.h b/panda/src/pgraph/shaderInput.h index 11b4630a53..260d5a6ab1 100644 --- a/panda/src/pgraph/shaderInput.h +++ b/panda/src/pgraph/shaderInput.h @@ -1,17 +1,17 @@ -// Filename: shaderInput.h -// Created by: jyelon (01Sep05) -// Updated by: fperazzi, PandaSE (06Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderInput.h + * @author jyelon + * @date 2005-09-01 + * @author fperazzi, PandaSE + * @date 2010-04-06 + */ #ifndef SHADERINPUT_H #define SHADERINPUT_H @@ -32,12 +32,10 @@ #include "shader.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : ShaderInput -// Description : This is a small container class that can hold any -// one of the value types that can be passed as input -// to a shader. -//////////////////////////////////////////////////////////////////// +/** + * This is a small container class that can hold any one of the value types + * that can be passed as input to a shader. + */ class EXPCL_PANDA_PGRAPH ShaderInput : public TypedWritableReferenceCount { public: INLINE ~ShaderInput(); @@ -147,4 +145,3 @@ private: #include "shaderInput.I" #endif // SHADERINPUT_H - diff --git a/panda/src/pgraph/shaderPool.I b/panda/src/pgraph/shaderPool.I index c63e0c0a5f..3139ff2daf 100644 --- a/panda/src/pgraph/shaderPool.I +++ b/panda/src/pgraph/shaderPool.I @@ -1,127 +1,97 @@ -// Filename: shaderPool.I -// Created by: aignacio (Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderPool.I + * @author aignacio + * @date 2006-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::has_shader -// Access: Public, Static -// Description: Returns true if the shader has ever been loaded, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader has ever been loaded, false otherwise. + */ INLINE bool ShaderPool:: has_shader(const Filename &filename) { return get_ptr()->ns_has_shader(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::verify_shader -// Access: Public, Static -// Description: Loads the given filename up into a shader, if it has -// not already been loaded, and returns true to indicate -// success, or false to indicate failure. If this -// returns true, it is guaranteed that a subsequent call -// to load_shader() with the same shader name will -// return a valid Shader pointer. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a shader, if it has not already been + * loaded, and returns true to indicate success, or false to indicate failure. + * If this returns true, it is guaranteed that a subsequent call to + * load_shader() with the same shader name will return a valid Shader pointer. + */ INLINE bool ShaderPool:: verify_shader(const Filename &filename) { return load_shader(filename) != (Shader *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::load_shader -// Access: Public, Static -// Description: Loads the given filename up into a shader, if it has -// not already been loaded, and returns the new shader. -// If a shader with the same filename was previously -// loaded, returns that one instead. If the shader -// file cannot be found, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a shader, if it has not already been + * loaded, and returns the new shader. If a shader with the same filename was + * previously loaded, returns that one instead. If the shader file cannot be + * found, returns NULL. + */ INLINE CPT(Shader) ShaderPool:: load_shader(const Filename &filename) { return get_ptr()->ns_load_shader(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::add_shader -// Access: Public, Static -// Description: Adds the indicated already-loaded shader to the -// pool. The shader will always replace any -// previously-loaded shader in the pool that had the -// same filename. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated already-loaded shader to the pool. The shader will + * always replace any previously-loaded shader in the pool that had the same + * filename. + */ INLINE void ShaderPool:: add_shader(const Filename &filename, Shader *shader) { get_ptr()->ns_add_shader(filename, shader); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::release_shader -// Access: Public, Static -// Description: Removes the indicated shader from the pool, -// indicating it will never be loaded again; the shader -// may then be freed. If this function is never called, -// a reference count will be maintained on every shader -// every loaded, and shaders will never be freed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated shader from the pool, indicating it will never be + * loaded again; the shader may then be freed. If this function is never + * called, a reference count will be maintained on every shader every loaded, + * and shaders will never be freed. + */ INLINE void ShaderPool:: release_shader(const Filename &filename) { get_ptr()->ns_release_shader(filename); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::release_all_shaders -// Access: Public, Static -// Description: Releases all shaders in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all shaders in the pool and restores the pool to the empty state. + */ INLINE void ShaderPool:: release_all_shaders() { get_ptr()->ns_release_all_shaders(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::garbage_collect -// Access: Public, Static -// Description: Releases only those shaders in the pool that have a -// reference count of exactly 1; i.e. only those -// shaders that are not being used outside of the pool. -// Returns the number of shaders released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those shaders in the pool that have a reference count of + * exactly 1; i.e. only those shaders that are not being used outside of the + * pool. Returns the number of shaders released. + */ INLINE int ShaderPool:: garbage_collect() { return get_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::list_contents -// Access: Public, Static -// Description: Lists the contents of the shader pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the shader pool to the indicated output stream. + */ INLINE void ShaderPool:: list_contents(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one ShaderPool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one ShaderPool in the universe and it constructs itself. + */ INLINE ShaderPool:: ShaderPool() { } diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index 5476960c6e..6334d83789 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -1,16 +1,15 @@ -// Filename: shaderPool.cxx -// Created by: aignacio (Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderPool.cxx + * @author aignacio + * @date 2006-03 + */ #include "shaderPool.h" #include "config_util.h" @@ -22,22 +21,17 @@ ShaderPool *ShaderPool::_global_ptr = (ShaderPool *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::write -// Access: Published, Static -// Description: Lists the contents of the shader pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the shader pool to the indicated output stream. + */ void ShaderPool:: write(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_has_shader -// Access: Private -// Description: The nonstatic implementation of has_shader(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of has_shader(). + */ bool ShaderPool:: ns_has_shader(const Filename &orig_filename) { Filename filename; @@ -54,11 +48,9 @@ ns_has_shader(const Filename &orig_filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_load_shader -// Access: Private -// Description: The nonstatic implementation of load_shader(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_shader(). + */ CPT(Shader) ShaderPool:: ns_load_shader(const Filename &orig_filename) { Filename filename; @@ -81,10 +73,10 @@ ns_load_shader(const Filename &orig_filename) { Shader::ShaderLanguage lang = Shader::SL_none; - // Do some guesswork to see if we can figure out the shader language - // from the file extension. This is really just guesswork - there are - // no standardized extensions for shaders, especially for GLSL. - // These are the ones that appear to be closest to "standard". + // Do some guesswork to see if we can figure out the shader language from + // the file extension. This is really just guesswork - there are no + // standardized extensions for shaders, especially for GLSL. These are the + // ones that appear to be closest to "standard". string ext = downcase(filename.get_extension()); if (ext == "cg" || ext == "sha") { // "sha" is for historical reasons. @@ -105,8 +97,7 @@ ns_load_shader(const Filename &orig_filename) { { LightMutexHolder holder(_lock); - // Now try again. Someone may have loaded the shader in another - // thread. + // Now try again. Someone may have loaded the shader in another thread. Shaders::const_iterator ti; ti = _shaders.find(filename); if (ti != _shaders.end()) { @@ -120,11 +111,9 @@ ns_load_shader(const Filename &orig_filename) { return shader; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_add_shader -// Access: Private -// Description: The nonstatic implementation of add_shader(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of add_shader(). + */ void ShaderPool:: ns_add_shader(const Filename &orig_filename, Shader *shader) { Filename filename; @@ -135,11 +124,9 @@ ns_add_shader(const Filename &orig_filename, Shader *shader) { _shaders[filename] = shader; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_release_shader -// Access: Private -// Description: The nonstatic implementation of release_shader(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_shader(). + */ void ShaderPool:: ns_release_shader(const Filename &filename) { LightMutexHolder holder(_lock); @@ -151,11 +138,9 @@ ns_release_shader(const Filename &filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_release_all_shaders -// Access: Private -// Description: The nonstatic implementation of release_all_shaders(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_shaders(). + */ void ShaderPool:: ns_release_all_shaders() { LightMutexHolder holder(_lock); @@ -163,11 +148,9 @@ ns_release_all_shaders() { _shaders.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int ShaderPool:: ns_garbage_collect() { LightMutexHolder holder(_lock); @@ -195,11 +178,9 @@ ns_garbage_collect() { return num_released; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void ShaderPool:: ns_list_contents(ostream &out) const { LightMutexHolder holder(_lock); @@ -214,12 +195,9 @@ ns_list_contents(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::resolve_filename -// Access: Private -// Description: Searches for the indicated filename along the -// model path. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated filename along the model path. + */ void ShaderPool:: resolve_filename(Filename &new_filename, const Filename &orig_filename) { new_filename = orig_filename; @@ -227,12 +205,10 @@ resolve_filename(Filename &new_filename, const Filename &orig_filename) { vfs->resolve_filename(new_filename, get_model_path()); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderPool::get_ptr -// Access: Private, Static -// Description: Initializes and/or returns the global pointer to the -// one ShaderPool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one ShaderPool object + * in the system. + */ ShaderPool *ShaderPool:: get_ptr() { if (_global_ptr == (ShaderPool *)NULL) { diff --git a/panda/src/pgraph/shaderPool.h b/panda/src/pgraph/shaderPool.h index 2a4bff80a5..ca9ee694fc 100644 --- a/panda/src/pgraph/shaderPool.h +++ b/panda/src/pgraph/shaderPool.h @@ -1,16 +1,15 @@ -// Filename: shaderPool.h -// Created by: aignacio (Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderPool.h + * @author aignacio + * @date 2006-03 + */ #ifndef SHADERPOOL_H #define SHADERPOOL_H @@ -21,13 +20,11 @@ #include "lightMutex.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ShaderPool -// Description : This is the preferred interface for loading shaders for -// the TextNode system. It is similar to ModelPool and -// TexturePool in that it unifies references to the same -// filename. -//////////////////////////////////////////////////////////////////// +/** + * This is the preferred interface for loading shaders for the TextNode + * system. It is similar to ModelPool and TexturePool in that it unifies + * references to the same filename. + */ class EXPCL_PANDA_PGRAPH ShaderPool { PUBLISHED: INLINE static bool has_shader(const Filename &filename); diff --git a/panda/src/pgraph/showBoundsEffect.I b/panda/src/pgraph/showBoundsEffect.I index e652fb8fd5..3de51d9571 100644 --- a/panda/src/pgraph/showBoundsEffect.I +++ b/panda/src/pgraph/showBoundsEffect.I @@ -1,37 +1,29 @@ -// Filename: showBoundsEffect.I -// Created by: drose (25Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showBoundsEffect.I + * @author drose + * @date 2002-03-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::Constructor -// Access: Private -// Description: Use ShowBoundsEffect::make() to construct a new -// ShowBoundsEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use ShowBoundsEffect::make() to construct a new ShowBoundsEffect object. + */ INLINE ShowBoundsEffect:: ShowBoundsEffect() : _tight(false) { } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::get_tight -// Access: Published -// Description: Returns true if the "tight" flag was set, meaning the -// effect should compute and draw the tight bounding-box -// of the node's vertices every frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the "tight" flag was set, meaning the effect should compute + * and draw the tight bounding-box of the node's vertices every frame. + */ INLINE bool ShowBoundsEffect:: get_tight() const { return _tight; diff --git a/panda/src/pgraph/showBoundsEffect.cxx b/panda/src/pgraph/showBoundsEffect.cxx index d724f5be35..fd88350b01 100644 --- a/panda/src/pgraph/showBoundsEffect.cxx +++ b/panda/src/pgraph/showBoundsEffect.cxx @@ -1,16 +1,15 @@ -// Filename: showBoundsEffect.cxx -// Created by: drose (25Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showBoundsEffect.cxx + * @author drose + * @date 2002-03-25 + */ #include "showBoundsEffect.h" #include "bamReader.h" @@ -20,11 +19,9 @@ TypeHandle ShowBoundsEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::make -// Access: Published, Static -// Description: Constructs a new ShowBoundsEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new ShowBoundsEffect object. + */ CPT(RenderEffect) ShowBoundsEffect:: make(bool tight) { ShowBoundsEffect *effect = new ShowBoundsEffect; @@ -32,33 +29,28 @@ make(bool tight) { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if this kind of effect can safely be -// combined with sibling nodes that share the exact same -// effect, or false if this is not a good idea. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of effect can safely be combined with sibling + * nodes that share the exact same effect, or false if this is not a good + * idea. + */ bool ShowBoundsEffect:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived ShowBoundsEffect -// types to return a unique number indicating whether -// this ShowBoundsEffect is equivalent to the other one. -// -// This should return 0 if the two ShowBoundsEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two ShowBoundsEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived ShowBoundsEffect types to return a + * unique number indicating whether this ShowBoundsEffect is equivalent to the + * other one. + * + * This should return 0 if the two ShowBoundsEffect objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two ShowBoundsEffect objects whose get_type() + * functions return the same. + */ int ShowBoundsEffect:: compare_to_impl(const RenderEffect *other) const { const ShowBoundsEffect *ta; @@ -67,37 +59,29 @@ compare_to_impl(const RenderEffect *other) const { return (int)_tight - (int)ta->_tight; } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ShowBoundsEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ShowBoundsEffect. + */ void ShowBoundsEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ShowBoundsEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); dg.add_bool(_tight); } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ShowBoundsEffect is encountered -// in the Bam file. It should create the ShowBoundsEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ShowBoundsEffect is encountered in the Bam file. It should create the + * ShowBoundsEffect and extract its information from the file. + */ TypedWritable *ShowBoundsEffect:: make_from_bam(const FactoryParams ¶ms) { ShowBoundsEffect *effect = new ShowBoundsEffect; @@ -110,13 +94,10 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: ShowBoundsEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ShowBoundsEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ShowBoundsEffect. + */ void ShowBoundsEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); diff --git a/panda/src/pgraph/showBoundsEffect.h b/panda/src/pgraph/showBoundsEffect.h index 686946ca19..e0f8a7950f 100644 --- a/panda/src/pgraph/showBoundsEffect.h +++ b/panda/src/pgraph/showBoundsEffect.h @@ -1,16 +1,15 @@ -// Filename: showBoundsEffect.h -// Created by: drose (25Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file showBoundsEffect.h + * @author drose + * @date 2002-03-25 + */ #ifndef SHOWBOUNDSEFFECT_H #define SHOWBOUNDSEFFECT_H @@ -21,13 +20,11 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : ShowBoundsEffect -// Description : Applied to a GeomNode to cause a visible bounding -// volume to be drawn for this node. This is generally -// used only during development to help identify -// bounding volume issues. -//////////////////////////////////////////////////////////////////// +/** + * Applied to a GeomNode to cause a visible bounding volume to be drawn for + * this node. This is generally used only during development to help identify + * bounding volume issues. + */ class EXPCL_PANDA_PGRAPH ShowBoundsEffect : public RenderEffect { private: INLINE ShowBoundsEffect(); @@ -51,7 +48,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -73,4 +70,3 @@ private: #include "showBoundsEffect.I" #endif - diff --git a/panda/src/pgraph/stateMunger.I b/panda/src/pgraph/stateMunger.I index ba04c77b66..edd3f6669b 100644 --- a/panda/src/pgraph/stateMunger.I +++ b/panda/src/pgraph/stateMunger.I @@ -1,23 +1,19 @@ -// Filename: stateMunger.I -// Created by: drose (04May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stateMunger.I + * @author drose + * @date 2005-05-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: StateMunger::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE StateMunger:: StateMunger(GraphicsStateGuardianBase *gsg) : GeomMunger(gsg) diff --git a/panda/src/pgraph/stateMunger.cxx b/panda/src/pgraph/stateMunger.cxx index 4ab909127b..c57366133d 100644 --- a/panda/src/pgraph/stateMunger.cxx +++ b/panda/src/pgraph/stateMunger.cxx @@ -1,35 +1,30 @@ -// Filename: stateMunger.cxx -// Created by: drose (04May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stateMunger.cxx + * @author drose + * @date 2005-05-04 + */ #include "stateMunger.h" TypeHandle StateMunger::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: StateMunger::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ StateMunger:: ~StateMunger() { } -//////////////////////////////////////////////////////////////////// -// Function: StateMunger::munge_state -// Access: Public -// Description: Given an input state, returns the munged state. -//////////////////////////////////////////////////////////////////// +/** + * Given an input state, returns the munged state. + */ CPT(RenderState) StateMunger:: munge_state(const RenderState *state) { int mi = _state_map.find(state); @@ -45,11 +40,9 @@ munge_state(const RenderState *state) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: StateMunger::munge_state_impl -// Access: Protected, Virtual -// Description: Given an input state, returns the munged state. -//////////////////////////////////////////////////////////////////// +/** + * Given an input state, returns the munged state. + */ CPT(RenderState) StateMunger:: munge_state_impl(const RenderState *state) { return state; diff --git a/panda/src/pgraph/stateMunger.h b/panda/src/pgraph/stateMunger.h index 3a317ffa14..b246d67413 100644 --- a/panda/src/pgraph/stateMunger.h +++ b/panda/src/pgraph/stateMunger.h @@ -1,16 +1,15 @@ -// Filename: stateMunger.h -// Created by: drose (04May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stateMunger.h + * @author drose + * @date 2005-05-04 + */ #ifndef STATEMUNGER_H #define STATEMUNGER_H @@ -20,13 +19,11 @@ #include "renderState.h" #include "weakKeyHashMap.h" -//////////////////////////////////////////////////////////////////// -// Class : StateMunger -// Description : This is just a simple derivative of GeomMunger that -// adds the ability to munge states. That functionality -// can't be declared in the base class, since it doesn't -// really know about RenderState. -//////////////////////////////////////////////////////////////////// +/** + * This is just a simple derivative of GeomMunger that adds the ability to + * munge states. That functionality can't be declared in the base class, + * since it doesn't really know about RenderState. + */ class EXPCL_PANDA_PGRAPH StateMunger : public GeomMunger { public: INLINE StateMunger(GraphicsStateGuardianBase *gsg); @@ -60,4 +57,3 @@ private: #include "stateMunger.I" #endif - diff --git a/panda/src/pgraph/stencilAttrib.I b/panda/src/pgraph/stencilAttrib.I index 39f3a7f026..6574f0a64f 100644 --- a/panda/src/pgraph/stencilAttrib.I +++ b/panda/src/pgraph/stencilAttrib.I @@ -1,22 +1,19 @@ -// Filename: stencilAttrib.I -// Created by: aignacio (18May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stencilAttrib.I + * @author aignacio + * @date 2006-05-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::get_render_state -// Access: Published -// Description: Returns render state. -//////////////////////////////////////////////////////////////////// +/** + * Returns render state. + */ INLINE unsigned int StencilAttrib:: get_render_state(StencilRenderState render_state_identifier) const { return _stencil_render_states[(int)render_state_identifier]; diff --git a/panda/src/pgraph/stencilAttrib.cxx b/panda/src/pgraph/stencilAttrib.cxx index 481626047e..c5ef20e78a 100644 --- a/panda/src/pgraph/stencilAttrib.cxx +++ b/panda/src/pgraph/stencilAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: stencilAttrib.cxx -// Created by: aignacio (18May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stencilAttrib.cxx + * @author aignacio + * @date 2006-05-18 + */ #include "stencilAttrib.h" #include "graphicsStateGuardianBase.h" @@ -44,12 +43,9 @@ stencil_render_state_name_array[StencilAttrib::SRS_total] = "SRS_clear_value", }; -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::Constructor -// Access: Private -// Description: Use StencilAttrib::make() to construct a new -// StencilAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use StencilAttrib::make() to construct a new StencilAttrib object. + */ StencilAttrib:: StencilAttrib() { _stencil_render_states [SRS_front_comparison_function] = M_none; @@ -70,35 +66,27 @@ StencilAttrib() { _stencil_render_states [SRS_clear_value] = 0; } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make_off -// Access: Published, Static -// Description: Constructs a StencilAttrib that has stenciling -// turned off. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a StencilAttrib that has stenciling turned off. + */ CPT(RenderAttrib) StencilAttrib:: make_off() { StencilAttrib *attrib = new StencilAttrib; return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) StencilAttrib:: make_default() { return return_new(new StencilAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make -// Access: Published, Static -// Description: Constructs a front face StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a front face StencilAttrib. + */ CPT(RenderAttrib) StencilAttrib:: make( bool front_enable, @@ -133,11 +121,9 @@ make( return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make_2_sided -// Access: Published, Static -// Description: Constructs a two-sided StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a two-sided StencilAttrib. + */ CPT(RenderAttrib) StencilAttrib:: make_2_sided( bool front_enable, @@ -181,11 +167,9 @@ make_2_sided( return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make -// Access: Published, Static -// Description: Constructs a front face StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a front face StencilAttrib. + */ CPT(RenderAttrib) StencilAttrib:: make_with_clear( bool front_enable, @@ -225,11 +209,9 @@ make_with_clear( return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make_2_sided -// Access: Published, Static -// Description: Constructs a two-sided StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a two-sided StencilAttrib. + */ CPT(RenderAttrib) StencilAttrib:: make_2_sided_with_clear( bool front_enable, @@ -278,11 +260,9 @@ make_2_sided_with_clear( return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void StencilAttrib:: output(ostream &out) const { @@ -294,21 +274,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived StencilAttrib -// types to return a unique number indicating whether -// this StencilAttrib is equivalent to the other one. -// -// This should return 0 if the two StencilAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two StencilAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived StencilAttrib types to return a unique + * number indicating whether this StencilAttrib is equivalent to the other + * one. + * + * This should return 0 if the two StencilAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two StencilAttrib objects whose get_type() + * functions return the same. + */ int StencilAttrib:: compare_to_impl(const RenderAttrib *other) const { const StencilAttrib *sa = (const StencilAttrib *)other; @@ -330,16 +307,12 @@ compare_to_impl(const RenderAttrib *other) const { return compare_result; } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t StencilAttrib:: get_hash_impl() const { size_t hash = 0; @@ -349,23 +322,18 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type StencilAttrib. + */ void StencilAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void StencilAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -375,14 +343,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type StencilAttrib is encountered -// in the Bam file. It should create the StencilAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type StencilAttrib is encountered in the Bam file. It should create the + * StencilAttrib and extract its information from the file. + */ TypedWritable *StencilAttrib:: make_from_bam(const FactoryParams ¶ms) { StencilAttrib *attrib = new StencilAttrib; @@ -395,13 +360,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: StencilAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new StencilAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new StencilAttrib. + */ void StencilAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/stencilAttrib.h b/panda/src/pgraph/stencilAttrib.h index ea19401ccd..9e9086928b 100644 --- a/panda/src/pgraph/stencilAttrib.h +++ b/panda/src/pgraph/stencilAttrib.h @@ -1,16 +1,15 @@ -// Filename: stencilAttrib.h -// Created by: aignacio (18May06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stencilAttrib.h + * @author aignacio + * @date 2006-05-18 + */ #ifndef STENCILATTRIB_H #define STENCILATTRIB_H @@ -20,22 +19,20 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : StencilAttrib -// Description : A StencilAttrib is a collection of all stencil render -// states. The render states in a StencilAttrib are -// read-only. A StencilAttrib is created with make or -// make_2_sided. To determine if two sided stencil is -// supported, call the function GraphicsStateGuardian:: -// get_supports_two_sided_stencil. -//////////////////////////////////////////////////////////////////// +/** + * A StencilAttrib is a collection of all stencil render states. The render + * states in a StencilAttrib are read-only. A StencilAttrib is created with + * make or make_2_sided. To determine if two sided stencil is supported, call + * the function GraphicsStateGuardian:: get_supports_two_sided_stencil. + */ class EXPCL_PANDA_PGRAPH StencilAttrib : public RenderAttrib { private: StencilAttrib(); PUBLISHED: - // enums are duplicated here from class StencilRenderStates for use in Python + // enums are duplicated here from class StencilRenderStates for use in + // Python enum StencilRenderState { SRS_front_comparison_function, SRS_front_stencil_fail_operation, @@ -190,4 +187,3 @@ private: #include "stencilAttrib.I" #endif - diff --git a/panda/src/pgraph/test_pgraph.cxx b/panda/src/pgraph/test_pgraph.cxx index 1c0c3a599f..45df2fe578 100644 --- a/panda/src/pgraph/test_pgraph.cxx +++ b/panda/src/pgraph/test_pgraph.cxx @@ -1,16 +1,15 @@ -// Filename: test_pgraph.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_pgraph.cxx + * @author drose + * @date 2002-02-21 + */ #include "pandaNode.h" #include "nodePath.h" @@ -33,11 +32,11 @@ build_tree(const string &name, int depth) { return node; } -int +int main(int argc, char *argv[]) { - // Build up a tree of height 6. Each level has three children, so - // that there are 3^5 + 3^4 + 3^3 + 3^2 + 3^1 + 3^0 = 364 total nodes. + // Build up a tree of height 6. Each level has three children, so that + // there are 3^5 + 3^4 + 3^3 + 3^2 + 3^1 + 3^0 = 364 total nodes. NodePath root = build_tree("a", 6); diff --git a/panda/src/pgraph/texGenAttrib.I b/panda/src/pgraph/texGenAttrib.I index d539219fe8..b055e7cee9 100644 --- a/panda/src/pgraph/texGenAttrib.I +++ b/panda/src/pgraph/texGenAttrib.I @@ -1,24 +1,19 @@ -// Filename: texGenAttrib.I -// Created by: masad (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texGenAttrib.I + * @author masad + * @date 2004-06-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::Constructor -// Access: Protected -// Description: Use TexGenAttrib::make() to construct a new -// TexGenAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexGenAttrib::make() to construct a new TexGenAttrib object. + */ INLINE TexGenAttrib:: TexGenAttrib() : _num_point_sprites(0), @@ -27,12 +22,9 @@ TexGenAttrib() : { } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::Copy Constructor -// Access: Protected -// Description: Use TexGenAttrib::make() to construct a new -// TexGenAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexGenAttrib::make() to construct a new TexGenAttrib object. + */ INLINE TexGenAttrib:: TexGenAttrib(const TexGenAttrib ©) : _stages(copy._stages), @@ -43,14 +35,11 @@ TexGenAttrib(const TexGenAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::get_geom_rendering -// Access: Published -// Description: Returns the union of the Geom::GeomRendering bits -// that will be required once this TexGenAttrib is -// applied to a geom which includes the indicated -// geom_rendering bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the Geom::GeomRendering bits that will be required + * once this TexGenAttrib is applied to a geom which includes the indicated + * geom_rendering bits. + */ INLINE int TexGenAttrib:: get_geom_rendering(int geom_rendering) const { if ((geom_rendering & Geom::GR_point) != 0) { @@ -60,22 +49,18 @@ get_geom_rendering(int geom_rendering) const { return geom_rendering | _geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::ModeDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TexGenAttrib::ModeDef:: ModeDef() : _mode(M_off) { } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::ModeDef::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int TexGenAttrib::ModeDef:: compare_to(const TexGenAttrib::ModeDef &other) const { if (_mode != other._mode) { @@ -92,4 +77,3 @@ compare_to(const TexGenAttrib::ModeDef &other) const { compare = _constant_value.compare_to(other._constant_value); return compare; } - diff --git a/panda/src/pgraph/texGenAttrib.cxx b/panda/src/pgraph/texGenAttrib.cxx index 5cd538f600..c7ace978c0 100644 --- a/panda/src/pgraph/texGenAttrib.cxx +++ b/panda/src/pgraph/texGenAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: texGenAttrib.cxx -// Created by: masad (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texGenAttrib.cxx + * @author masad + * @date 2004-06-21 + */ #include "texGenAttrib.h" #include "texturePool.h" @@ -25,25 +24,20 @@ CPT(RenderAttrib) TexGenAttrib::_empty_attrib; TypeHandle TexGenAttrib::_type_handle; int TexGenAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexGenAttrib:: ~TexGenAttrib() { } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::make -// Access: Published, Static -// Description: Constructs a TexGenAttrib that generates no stages at -// all. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexGenAttrib that generates no stages at all. + */ CPT(RenderAttrib) TexGenAttrib:: make() { - // We make it a special case and store a pointer to the empty attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty attrib forever + // once we find it the first time, as an optimization. if (_empty_attrib == (RenderAttrib *)NULL) { _empty_attrib = return_new(new TexGenAttrib); } @@ -51,37 +45,28 @@ make() { return _empty_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::make -// Access: Published, Static -// Description: Constructs a TexGenAttrib that generates just the -// indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexGenAttrib that generates just the indicated stage. + */ CPT(RenderAttrib) TexGenAttrib:: make(TextureStage *stage, TexGenAttrib::Mode mode) { return DCAST(TexGenAttrib, make())->add_stage(stage, mode); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) TexGenAttrib:: make_default() { return return_new(new TexGenAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::add_stage -// Access: Published, Static -// Description: Returns a new TexGenAttrib just like this one, -// with the indicated generation mode for the given -// stage. If this stage already exists, its mode is -// replaced. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexGenAttrib just like this one, with the indicated + * generation mode for the given stage. If this stage already exists, its + * mode is replaced. + */ CPT(RenderAttrib) TexGenAttrib:: add_stage(TextureStage *stage, TexGenAttrib::Mode mode) const { nassertr(mode != M_constant, this); @@ -96,17 +81,14 @@ add_stage(TextureStage *stage, TexGenAttrib::Mode mode) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::add_stage -// Access: Published, Static -// Description: Returns a new TexGenAttrib just like this one, -// with the indicated generation mode for the given -// stage. If this stage already exists, its mode is -// replaced. -// -// This variant also accepts constant_value, which is -// only meaningful if mode is M_constant. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexGenAttrib just like this one, with the indicated + * generation mode for the given stage. If this stage already exists, its + * mode is replaced. + * + * This variant also accepts constant_value, which is only meaningful if mode + * is M_constant. + */ CPT(RenderAttrib) TexGenAttrib:: add_stage(TextureStage *stage, TexGenAttrib::Mode mode, const LTexCoord3 &constant_value) const { @@ -123,12 +105,10 @@ add_stage(TextureStage *stage, TexGenAttrib::Mode mode, return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::remove_stage -// Access: Published, Static -// Description: Returns a new TexGenAttrib just like this one, -// with the indicated stage removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexGenAttrib just like this one, with the indicated stage + * removed. + */ CPT(RenderAttrib) TexGenAttrib:: remove_stage(TextureStage *stage) const { Stages::const_iterator si; @@ -150,37 +130,29 @@ remove_stage(TextureStage *stage) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::is_empty -// Access: Published -// Description: Returns true if no stages are defined in the -// TexGenAttrib, false if at least one is. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no stages are defined in the TexGenAttrib, false if at + * least one is. + */ bool TexGenAttrib:: is_empty() const { return _stages.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::has_stage -// Access: Published -// Description: Returns true if there is a mode associated with -// the indicated stage, or false otherwise (in which -// case get_transform(stage) will return M_off). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a mode associated with the indicated stage, or + * false otherwise (in which case get_transform(stage) will return M_off). + */ bool TexGenAttrib:: has_stage(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); return (mi != _stages.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::get_mode -// Access: Published -// Description: Returns the generation mode associated with -// the named texture stage, or M_off if -// nothing is associated with the indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the generation mode associated with the named texture stage, or + * M_off if nothing is associated with the indicated stage. + */ TexGenAttrib::Mode TexGenAttrib:: get_mode(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); @@ -190,27 +162,21 @@ get_mode(TextureStage *stage) const { return M_off; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::has_gen_texcoord_stage -// Access: Published -// Description: Returns true if the indicated TextureStage will have -// texture coordinates generated for it automatically -// (and thus there is no need to upload the texture -// coordinates encoded in the vertices). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated TextureStage will have texture coordinates + * generated for it automatically (and thus there is no need to upload the + * texture coordinates encoded in the vertices). + */ bool TexGenAttrib:: has_gen_texcoord_stage(TextureStage *stage) const { NoTexCoordStages::const_iterator mi = _no_texcoords.find(stage); return (mi != _no_texcoords.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::get_constant_value -// Access: Published -// Description: Returns the constant value associated with the named -// texture stage. This is only meaningful if the mode -// is M_constant. -//////////////////////////////////////////////////////////////////// +/** + * Returns the constant value associated with the named texture stage. This + * is only meaningful if the mode is M_constant. + */ const LTexCoord3 &TexGenAttrib:: get_constant_value(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); @@ -220,11 +186,9 @@ get_constant_value(TextureStage *stage) const { return LTexCoord3::zero(); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexGenAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -280,21 +244,17 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived TexGenAttrib -// types to return a unique number indicating whether -// this TexGenAttrib is equivalent to the other one. -// -// This should return 0 if the two TexGenAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two TexGenAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived TexGenAttrib types to return a unique + * number indicating whether this TexGenAttrib is equivalent to the other one. + * + * This should return 0 if the two TexGenAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two TexGenAttrib objects whose get_type() + * functions return the same. + */ int TexGenAttrib:: compare_to_impl(const RenderAttrib *other) const { const TexGenAttrib *ta = (const TexGenAttrib *)other; @@ -335,16 +295,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t TexGenAttrib:: get_hash_impl() const { size_t hash = 0; @@ -363,29 +319,23 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) TexGenAttrib:: compose_impl(const RenderAttrib *other) const { const TexGenAttrib *ta = (const TexGenAttrib *)other; - // The composition is the union of the two attribs. In the case - // when a stage is in both attribs, we compose the stages. + // The composition is the union of the two attribs. In the case when a + // stage is in both attribs, we compose the stages. TexGenAttrib *attrib = new TexGenAttrib; @@ -428,21 +378,18 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) TexGenAttrib:: invert_compose_impl(const RenderAttrib *other) const { const TexGenAttrib *ta = (const TexGenAttrib *)other; - // The inverse composition works a lot like the composition, except - // we invert the ai stages. + // The inverse composition works a lot like the composition, except we + // invert the ai stages. TexGenAttrib *attrib = new TexGenAttrib; @@ -485,25 +432,20 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) TexGenAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::filled_stages -// Access: Private -// Description: This method is to be called after the _stages map has -// been built up internally through some artificial -// means; it copies the appropriate settings to -// _no_texcoords and updates other internal cache values -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * This method is to be called after the _stages map has been built up + * internally through some artificial means; it copies the appropriate + * settings to _no_texcoords and updates other internal cache values + * appropriately. + */ void TexGenAttrib:: filled_stages() { Stages::iterator ri; @@ -514,13 +456,10 @@ filled_stages() { } } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::record_stage -// Access: Private -// Description: Updates the appropriate internal caches before adding -// the indicated stage with the given mode to the -// _stages map. -//////////////////////////////////////////////////////////////////// +/** + * Updates the appropriate internal caches before adding the indicated stage + * with the given mode to the _stages map. + */ void TexGenAttrib:: record_stage(TextureStage *stage, TexGenAttrib::ModeDef &mode_def) { switch (mode_def._mode) { @@ -538,23 +477,18 @@ record_stage(TextureStage *stage, TexGenAttrib::ModeDef &mode_def) { } } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TexGenAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TexGenAttrib. + */ void TexGenAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TexGenAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -571,13 +505,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TexGenAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -595,14 +526,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TexGenAttrib is encountered -// in the Bam file. It should create the TexGenAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TexGenAttrib is encountered in the Bam file. It should create the + * TexGenAttrib and extract its information from the file. + */ TypedWritable *TexGenAttrib:: make_from_bam(const FactoryParams ¶ms) { TexGenAttrib *attrib = new TexGenAttrib; @@ -615,23 +543,19 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TexGenAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TexGenAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TexGenAttrib. + */ void TexGenAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); size_t num_stages = scan.get_uint16(); - // For now, read in a linear list of the modes we will assign to - // each associated TextureStage pointer. Later, in - // complete_pointers, we'll fill up the map the with appropriate - // TextureStage/Mode pairing. + // For now, read in a linear list of the modes we will assign to each + // associated TextureStage pointer. Later, in complete_pointers, we'll fill + // up the map the with appropriate TextureStageMode pairing. _read_modes.clear(); _read_modes.reserve(num_stages); for (size_t i = 0; i < num_stages; i++) { diff --git a/panda/src/pgraph/texGenAttrib.h b/panda/src/pgraph/texGenAttrib.h index be92aff106..c2b0e87132 100644 --- a/panda/src/pgraph/texGenAttrib.h +++ b/panda/src/pgraph/texGenAttrib.h @@ -1,16 +1,15 @@ -// Filename: texGenAttrib.h -// Created by: masad (21Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texGenAttrib.h + * @author masad + * @date 2004-06-21 + */ #ifndef TEXGENATTRIB_H #define TEXGENATTRIB_H @@ -24,21 +23,17 @@ #include "pointerTo.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : TexGenAttrib -// Description : Computes texture coordinates for geometry -// automatically based on vertex position and/or normal. -// This can be used to implement reflection and/or -// refraction maps, for instance to make shiny surfaces, -// as well as other special effects such as projective -// texturing. -//////////////////////////////////////////////////////////////////// +/** + * Computes texture coordinates for geometry automatically based on vertex + * position and/or normal. This can be used to implement reflection and/or + * refraction maps, for instance to make shiny surfaces, as well as other + * special effects such as projective texturing. + */ class EXPCL_PANDA_PGRAPH TexGenAttrib : public RenderAttrib { PUBLISHED: - // We inherit the definition of our Mode enumerated type from - // RenderAttrib. Normally, Mode would be defined here, but we - // define it in the base class instead as a hack to avoid a problem - // with circular includes. + // We inherit the definition of our Mode enumerated type from RenderAttrib. + // Normally, Mode would be defined here, but we define it in the base class + // instead as a hack to avoid a problem with circular includes. typedef RenderAttrib::TexGenMode Mode; protected: @@ -92,23 +87,22 @@ private: typedef pmap Stages; Stages _stages; - // This is a set of TextureStage pointers for which texture - // coordinates will not be needed from the Geom. It's redundant; - // it's almost the same set that is listed in _stages, above. It's - // just here as an optimization during rendering. + // This is a set of TextureStage pointers for which texture coordinates will + // not be needed from the Geom. It's redundant; it's almost the same set + // that is listed in _stages, above. It's just here as an optimization + // during rendering. typedef pset NoTexCoordStages; NoTexCoordStages _no_texcoords; - // This element is only used during reading from a bam file. It has - // no meaningful value any other time. + // This element is only used during reading from a bam file. It has no + // meaningful value any other time. pvector _read_modes; int _num_point_sprites; - // _point_geom_rendering is the GeomRendering bits that are added by - // the TexGenAttrib if there are any points in the Geom. - // _geom_rendering is the GeomRendering bits that are added - // regardless of the kind of Geom it is. + // _point_geom_rendering is the GeomRendering bits that are added by the + // TexGenAttrib if there are any points in the Geom. _geom_rendering is the + // GeomRendering bits that are added regardless of the kind of Geom it is. int _point_geom_rendering; int _geom_rendering; @@ -154,4 +148,3 @@ private: #include "texGenAttrib.I" #endif - diff --git a/panda/src/pgraph/texMatrixAttrib.I b/panda/src/pgraph/texMatrixAttrib.I index ffb18df5f4..2245d669dd 100644 --- a/panda/src/pgraph/texMatrixAttrib.I +++ b/panda/src/pgraph/texMatrixAttrib.I @@ -1,46 +1,35 @@ -// Filename: texMatrixAttrib.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texMatrixAttrib.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::Constructor -// Access: Protected -// Description: Use TexMatrixAttrib::make() to construct a new -// TexMatrixAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexMatrixAttrib::make() to construct a new TexMatrixAttrib object. + */ INLINE TexMatrixAttrib:: TexMatrixAttrib() { } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::Copy Constructor -// Access: Protected -// Description: Use TexMatrixAttrib::make() to construct a new -// TexMatrixAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexMatrixAttrib::make() to construct a new TexMatrixAttrib object. + */ INLINE TexMatrixAttrib:: TexMatrixAttrib(const TexMatrixAttrib ©) : _stages(copy._stages) { } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_override -// Access: Published -// Description: Returns the override value associated with the -// indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the override value associated with the indicated stage. + */ INLINE int TexMatrixAttrib:: get_override(TextureStage *stage) const { Stages::const_iterator si; @@ -52,14 +41,11 @@ get_override(TextureStage *stage) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_geom_rendering -// Access: Published -// Description: Returns the union of the Geom::GeomRendering bits -// that will be required once this TexMatrixAttrib is -// applied to a geom which includes the indicated -// geom_rendering bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the Geom::GeomRendering bits that will be required + * once this TexMatrixAttrib is applied to a geom which includes the indicated + * geom_rendering bits. + */ INLINE int TexMatrixAttrib:: get_geom_rendering(int geom_rendering) const { if ((geom_rendering & Geom::GR_point_sprite) != 0) { @@ -71,27 +57,22 @@ get_geom_rendering(int geom_rendering) const { return geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::StageNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TexMatrixAttrib::StageNode:: StageNode(const TextureStage *stage) : - // Yeah, we cast away the constness here. Just too much trouble to - // deal with it properly. + // Yeah, we cast away the constness here. Just too much trouble to deal + // with it properly. _stage((TextureStage *)stage), _override(0) { } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::StageNode::operator < -// Access: Public -// Description: Compares the full attributes of StageNodes (as -// opposed to just the pointer compared by -// CompareTextureStagePointer, below). -//////////////////////////////////////////////////////////////////// +/** + * Compares the full attributes of StageNodes (as opposed to just the pointer + * compared by CompareTextureStagePointer, below). + */ INLINE bool TexMatrixAttrib::StageNode:: operator < (const TexMatrixAttrib::StageNode &other) const { if (_stage != other._stage) { @@ -103,14 +84,12 @@ operator < (const TexMatrixAttrib::StageNode &other) const { return _override < other._override; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::CompareTextureStagePointer::operator () -// Access: Public -// Description: This STL function object is used to sort a list of -// texture stages in order by pointer. -//////////////////////////////////////////////////////////////////// +/** + * This STL function object is used to sort a list of texture stages in order + * by pointer. + */ INLINE bool TexMatrixAttrib::CompareTextureStagePointer:: -operator () (const TexMatrixAttrib::StageNode &a, +operator () (const TexMatrixAttrib::StageNode &a, const TexMatrixAttrib::StageNode &b) const { return a._stage < b._stage; } diff --git a/panda/src/pgraph/texMatrixAttrib.cxx b/panda/src/pgraph/texMatrixAttrib.cxx index 26dad659e3..eca96e95b3 100644 --- a/panda/src/pgraph/texMatrixAttrib.cxx +++ b/panda/src/pgraph/texMatrixAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: texMatrixAttrib.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texMatrixAttrib.cxx + * @author drose + * @date 2002-03-14 + */ #include "texMatrixAttrib.h" #include "graphicsStateGuardianBase.h" @@ -25,25 +24,20 @@ CPT(RenderAttrib) TexMatrixAttrib::_empty_attrib; TypeHandle TexMatrixAttrib::_type_handle; int TexMatrixAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexMatrixAttrib:: ~TexMatrixAttrib() { } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::make -// Access: Published, Static -// Description: Constructs a TexMatrixAttrib that applies -// no stages at all. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexMatrixAttrib that applies no stages at all. + */ CPT(RenderAttrib) TexMatrixAttrib:: make() { - // We make it a special case and store a pointer to the empty attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty attrib forever + // once we find it the first time, as an optimization. if (_empty_attrib == (RenderAttrib *)NULL) { _empty_attrib = return_new(new TexMatrixAttrib); } @@ -51,13 +45,10 @@ make() { return _empty_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::make -// Access: Published, Static -// Description: Constructs a TexMatrixAttrib that applies the -// indicated matrix to the default texture stage. This -// interface is deprecated. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexMatrixAttrib that applies the indicated matrix to the + * default texture stage. This interface is deprecated. + */ CPT(RenderAttrib) TexMatrixAttrib:: make(const LMatrix4 &mat) { pgraph_cat.warning() @@ -69,36 +60,29 @@ make(const LMatrix4 &mat) { return make(TextureStage::get_default(), transform); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::make -// Access: Published, Static -// Description: Constructs a TexMatrixAttrib that applies the -// indicated transform to the named texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexMatrixAttrib that applies the indicated transform to the + * named texture stage. + */ CPT(RenderAttrib) TexMatrixAttrib:: make(TextureStage *stage, const TransformState *transform) { return DCAST(TexMatrixAttrib, make())->add_stage(stage, transform); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) TexMatrixAttrib:: make_default() { return return_new(new TexMatrixAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::add_stage -// Access: Published, Static -// Description: Returns a new TexMatrixAttrib just like this one, -// with the indicated transform for the given stage. If -// this stage already exists, its transform is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexMatrixAttrib just like this one, with the indicated + * transform for the given stage. If this stage already exists, its transform + * is replaced. + */ CPT(RenderAttrib) TexMatrixAttrib:: add_stage(TextureStage *stage, const TransformState *transform, int override) const { @@ -110,12 +94,10 @@ add_stage(TextureStage *stage, const TransformState *transform, return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::remove_stage -// Access: Published, Static -// Description: Returns a new TexMatrixAttrib just like this one, -// with the indicated stage removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexMatrixAttrib just like this one, with the indicated stage + * removed. + */ CPT(RenderAttrib) TexMatrixAttrib:: remove_stage(TextureStage *stage) const { TexMatrixAttrib *attrib = new TexMatrixAttrib(*this); @@ -123,85 +105,67 @@ remove_stage(TextureStage *stage) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_mat -// Access: Published -// Description: Returns the transformation matrix associated with -// the default texture stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transformation matrix associated with the default texture + * stage. + */ const LMatrix4 &TexMatrixAttrib:: get_mat() const { return get_mat(TextureStage::get_default()); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::is_empty -// Access: Published -// Description: Returns true if no stages are defined in the -// TexMatrixAttrib, false if at least one is. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no stages are defined in the TexMatrixAttrib, false if at + * least one is. + */ bool TexMatrixAttrib:: is_empty() const { return _stages.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::has_stage -// Access: Published -// Description: Returns true if there is a transform associated with -// the indicated stage, or false otherwise (in which -// case get_transform(stage) will return the identity -// transform). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a transform associated with the indicated stage, + * or false otherwise (in which case get_transform(stage) will return the + * identity transform). + */ bool TexMatrixAttrib:: has_stage(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(StageNode(stage)); return (mi != _stages.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_num_stages -// Access: Published -// Description: Returns the number of stages that are represented by -// this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages that are represented by this attrib. + */ int TexMatrixAttrib:: get_num_stages() const { return _stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_stage -// Access: Published -// Description: Returns the nth stage that is represented by this -// attrib. The TextureStages are in no particular -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stage that is represented by this attrib. The + * TextureStages are in no particular order. + */ TextureStage *TexMatrixAttrib:: get_stage(int n) const { nassertr(n >= 0 && n < (int)_stages.size(), NULL); return _stages[n]._stage; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_mat -// Access: Published -// Description: Returns the transformation matrix associated with -// the indicated texture stage, or identity matrix if -// nothing is associated with the indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transformation matrix associated with the indicated texture + * stage, or identity matrix if nothing is associated with the indicated + * stage. + */ const LMatrix4 &TexMatrixAttrib:: get_mat(TextureStage *stage) const { return get_transform(stage)->get_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_transform -// Access: Published -// Description: Returns the transformation associated with -// the indicated texture stage, or identity matrix if -// nothing is associated with the indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transformation associated with the indicated texture stage, or + * identity matrix if nothing is associated with the indicated stage. + */ CPT(TransformState) TexMatrixAttrib:: get_transform(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(StageNode(stage)); @@ -211,11 +175,9 @@ get_transform(TextureStage *stage) const { return TransformState::make_identity(); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexMatrixAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -230,21 +192,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived TexMatrixAttrib -// types to return a unique number indicating whether -// this TexMatrixAttrib is equivalent to the other one. -// -// This should return 0 if the two TexMatrixAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two TexMatrixAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived TexMatrixAttrib types to return a + * unique number indicating whether this TexMatrixAttrib is equivalent to the + * other one. + * + * This should return 0 if the two TexMatrixAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two TexMatrixAttrib objects whose get_type() + * functions return the same. + */ int TexMatrixAttrib:: compare_to_impl(const RenderAttrib *other) const { const TexMatrixAttrib *ta = (const TexMatrixAttrib *)other; @@ -281,16 +240,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t TexMatrixAttrib:: get_hash_impl() const { size_t hash = 0; @@ -306,29 +261,23 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) TexMatrixAttrib:: compose_impl(const RenderAttrib *other) const { const TexMatrixAttrib *ta = (const TexMatrixAttrib *)other; - // The composition is the union of the two attribs. In the case - // when a stage is in both attribs, we compose the stages. + // The composition is the union of the two attribs. In the case when a + // stage is in both attribs, we compose the stages. TexMatrixAttrib *attrib = new TexMatrixAttrib; @@ -383,21 +332,18 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) TexMatrixAttrib:: invert_compose_impl(const RenderAttrib *other) const { const TexMatrixAttrib *ta = (const TexMatrixAttrib *)other; - // The inverse composition works a lot like the composition, except - // we invert the ai stages. + // The inverse composition works a lot like the composition, except we + // invert the ai stages. TexMatrixAttrib *attrib = new TexMatrixAttrib; @@ -407,7 +353,7 @@ invert_compose_impl(const RenderAttrib *other) const { while (ai != _stages.end() && bi != ta->_stages.end()) { if ((*ai)._stage < (*bi)._stage) { // This stage is in a but not in b. - CPT(TransformState) inv_a = + CPT(TransformState) inv_a = (*ai)._transform->invert_compose(TransformState::make_identity()); StageNode sn((*ai)._stage); sn._transform = inv_a; @@ -436,7 +382,7 @@ invert_compose_impl(const RenderAttrib *other) const { } else { // Override a wins. - CPT(TransformState) inv_a = + CPT(TransformState) inv_a = (*ai)._transform->invert_compose(TransformState::make_identity()); StageNode sn((*ai)._stage); sn._transform = inv_a; @@ -451,7 +397,7 @@ invert_compose_impl(const RenderAttrib *other) const { while (ai != _stages.end()) { // This stage is in a but not in b. - CPT(TransformState) inv_a = + CPT(TransformState) inv_a = (*ai)._transform->invert_compose(TransformState::make_identity()); StageNode sn((*ai)._stage); sn._transform = inv_a; @@ -469,17 +415,15 @@ invert_compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) TexMatrixAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { - // For a TexMatrixAttrib, the particular matrix per TextureStage - // isn't important, just whether there is a matrix at all. So we - // create a new state with an identity matrix everywhere there is a - // matrix at all in the original. + // For a TexMatrixAttrib, the particular matrix per TextureStage isn't + // important, just whether there is a matrix at all. So we create a new + // state with an identity matrix everywhere there is a matrix at all in the + // original. TexMatrixAttrib *attrib = new TexMatrixAttrib; @@ -493,23 +437,18 @@ get_auto_shader_attrib_impl(const RenderState *state) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TexMatrixAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TexMatrixAttrib. + */ void TexMatrixAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TexMatrixAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -526,13 +465,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TexMatrixAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -543,7 +479,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { ts = TextureStagePool::get_stage(ts); const TransformState *transform = DCAST(TransformState, p_list[pi++]); - + StageNode &sn = _stages[sni]; sn._stage = ts; sn._transform = transform; @@ -553,14 +489,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TexMatrixAttrib is encountered -// in the Bam file. It should create the TexMatrixAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TexMatrixAttrib is encountered in the Bam file. It should create the + * TexMatrixAttrib and extract its information from the file. + */ TypedWritable *TexMatrixAttrib:: make_from_bam(const FactoryParams ¶ms) { TexMatrixAttrib *attrib = new TexMatrixAttrib; @@ -573,13 +506,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TexMatrixAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TexMatrixAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TexMatrixAttrib. + */ void TexMatrixAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/texMatrixAttrib.h b/panda/src/pgraph/texMatrixAttrib.h index a1e6d90c94..b0b7790851 100644 --- a/panda/src/pgraph/texMatrixAttrib.h +++ b/panda/src/pgraph/texMatrixAttrib.h @@ -1,16 +1,15 @@ -// Filename: texMatrixAttrib.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texMatrixAttrib.h + * @author drose + * @date 2002-03-14 + */ #ifndef TEXMATRIXATTRIB_H #define TEXMATRIXATTRIB_H @@ -25,11 +24,9 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TexMatrixAttrib -// Description : Applies a transform matrix to UV's before they are -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Applies a transform matrix to UV's before they are rendered. + */ class EXPCL_PANDA_PGRAPH TexMatrixAttrib : public RenderAttrib { protected: INLINE TexMatrixAttrib(); @@ -114,7 +111,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -138,4 +135,3 @@ private: #include "texMatrixAttrib.I" #endif - diff --git a/panda/src/pgraph/texProjectorEffect.I b/panda/src/pgraph/texProjectorEffect.I index c6e8bfe0c6..35e699476e 100644 --- a/panda/src/pgraph/texProjectorEffect.I +++ b/panda/src/pgraph/texProjectorEffect.I @@ -1,76 +1,62 @@ -// Filename: texProjectorEffect.I -// Created by: drose (25Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texProjectorEffect.I + * @author drose + * @date 2004-07-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::Constructor -// Access: Protected -// Description: Use TexProjectorEffect::make() to construct a new -// TexProjectorEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexProjectorEffect::make() to construct a new TexProjectorEffect + * object. + */ INLINE TexProjectorEffect:: TexProjectorEffect() { } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::Copy Constructor -// Access: Protected -// Description: Use TexProjectorEffect::make() to construct a new -// TexProjectorEffect object. -//////////////////////////////////////////////////////////////////// +/** + * Use TexProjectorEffect::make() to construct a new TexProjectorEffect + * object. + */ INLINE TexProjectorEffect:: TexProjectorEffect(const TexProjectorEffect ©) : _stages(copy._stages) { } - -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::StageDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ INLINE TexProjectorEffect::StageDef:: StageDef() : _to_lens_node(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::StageDef::set_from -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TexProjectorEffect::StageDef:: set_from(const NodePath &from) { _from = from; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::StageDef::set_lens_index -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TexProjectorEffect::StageDef:: set_lens_index(int lens_index) { _lens_index = lens_index; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::StageDef::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int TexProjectorEffect::StageDef:: compare_to(const TexProjectorEffect::StageDef &other) const { int compare = _to.compare_to(other._to); diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index 26504a1364..a8f0078dea 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -1,16 +1,15 @@ -// Filename: texProjectorEffect.cxx -// Created by: drose (25Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texProjectorEffect.cxx + * @author drose + * @date 2004-07-25 + */ #include "texProjectorEffect.h" #include "cullTraverserData.h" @@ -26,25 +25,20 @@ CPT(RenderEffect) TexProjectorEffect::_empty_effect; TypeHandle TexProjectorEffect::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexProjectorEffect:: ~TexProjectorEffect() { } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::make -// Access: Published, Static -// Description: Constructs a TexProjectorEffect that modifies -// no stages at all. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a TexProjectorEffect that modifies no stages at all. + */ CPT(RenderEffect) TexProjectorEffect:: make() { - // We make it a special case and store a pointer to the empty effect - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty effect forever + // once we find it the first time, as an optimization. if (_empty_effect == (RenderEffect *)NULL) { _empty_effect = return_new(new TexProjectorEffect); } @@ -52,23 +46,18 @@ make() { return _empty_effect; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::add_stage -// Access: Published, Static -// Description: Returns a new TexProjectorEffect just like this one, -// with the indicated projection for the given stage. -// If this stage already exists, its projection -// definition is replaced. -// -// The relative transform between the "from" and the -// "to" nodes is automatically applied to the texture -// transform each frame. -// -// Furthermore, if the "to" node is a LensNode, its -// projection matrix is also applied to the texture -// transform. In this case, the lens_index may be used -// to select the particular lens that should be used. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexProjectorEffect just like this one, with the indicated + * projection for the given stage. If this stage already exists, its + * projection definition is replaced. + * + * The relative transform between the "from" and the "to" nodes is + * automatically applied to the texture transform each frame. + * + * Furthermore, if the "to" node is a LensNode, its projection matrix is also + * applied to the texture transform. In this case, the lens_index may be used + * to select the particular lens that should be used. + */ CPT(RenderEffect) TexProjectorEffect:: add_stage(TextureStage *stage, const NodePath &from, const NodePath &to, int lens_index) const { TexProjectorEffect *effect = new TexProjectorEffect(*this); @@ -79,12 +68,10 @@ add_stage(TextureStage *stage, const NodePath &from, const NodePath &to, int len return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::remove_stage -// Access: Published, Static -// Description: Returns a new TexProjectorEffect just like this one, -// with the indicated stage removed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TexProjectorEffect just like this one, with the indicated + * stage removed. + */ CPT(RenderEffect) TexProjectorEffect:: remove_stage(TextureStage *stage) const { TexProjectorEffect *effect = new TexProjectorEffect(*this); @@ -92,40 +79,31 @@ remove_stage(TextureStage *stage) const { return return_new(effect); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::is_empty -// Access: Published -// Description: Returns true if no stages are defined in the -// TexProjectorEffect, false if at least one is. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no stages are defined in the TexProjectorEffect, false if + * at least one is. + */ bool TexProjectorEffect:: is_empty() const { return _stages.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::has_stage -// Access: Published -// Description: Returns true if there is a transform associated with -// the indicated stage, or false otherwise (in which -// case get_transform(stage) will return the identity -// transform). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a transform associated with the indicated stage, + * or false otherwise (in which case get_transform(stage) will return the + * identity transform). + */ bool TexProjectorEffect:: has_stage(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); return (mi != _stages.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::get_from -// Access: Published -// Description: Returns the "from" node associated with the -// TexProjectorEffect on the indicated stage. The -// relative transform between the "from" and the "to" -// nodes is automatically applied to the texture -// transform each frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "from" node associated with the TexProjectorEffect on the + * indicated stage. The relative transform between the "from" and the "to" + * nodes is automatically applied to the texture transform each frame. + */ NodePath TexProjectorEffect:: get_from(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); @@ -133,19 +111,14 @@ get_from(TextureStage *stage) const { return (*mi).second._from; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::get_to -// Access: Published -// Description: Returns the "to" node associated with the -// TexProjectorEffect on the indicated stage. The -// relative transform between the "from" and the "to" -// nodes is automatically applied to the texture -// transform each frame. -// -// Furthermore, if the "to" node is a LensNode, its -// projection matrix is also applied to the texture -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "to" node associated with the TexProjectorEffect on the + * indicated stage. The relative transform between the "from" and the "to" + * nodes is automatically applied to the texture transform each frame. + * + * Furthermore, if the "to" node is a LensNode, its projection matrix is also + * applied to the texture transform. + */ NodePath TexProjectorEffect:: get_to(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); @@ -153,15 +126,11 @@ get_to(TextureStage *stage) const { return (*mi).second._to; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::get_lens_index -// Access: Published -// Description: Returns the lens_index associated with the -// TexProjectorEffect on the indicated stage. This is -// only used if the "to" node is a LensNode, in which -// case it specifies the particular lens that should be -// used. -//////////////////////////////////////////////////////////////////// +/** + * Returns the lens_index associated with the TexProjectorEffect on the + * indicated stage. This is only used if the "to" node is a LensNode, in + * which case it specifies the particular lens that should be used. + */ int TexProjectorEffect:: get_lens_index(TextureStage *stage) const { Stages::const_iterator mi = _stages.find(stage); @@ -169,11 +138,9 @@ get_lens_index(TextureStage *stage) const { return (*mi).second._lens_index; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexProjectorEffect:: output(ostream &out) const { out << get_type() << ":"; @@ -187,37 +154,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this effect during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this effect during the cull traversal. + */ bool TexProjectorEffect:: has_cull_callback() const { return !_stages.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. This may include additional manipulation -// of render state or additional visible/invisible -// decisions, or any other arbitrary operation. -// -// At the time this function is called, the current -// node's transform and state have not yet been applied -// to the net_transform and net_state. This callback -// may modify the node_transform and node_state to apply -// an effective change to the render state at this -// level. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. This may include additional manipulation of render + * state or additional visible/invisible decisions, or any other arbitrary + * operation. + * + * At the time this function is called, the current node's transform and state + * have not yet been applied to the net_transform and net_state. This + * callback may modify the node_transform and node_state to apply an effective + * change to the render state at this level. + */ void TexProjectorEffect:: cull_callback(CullTraverser *trav, CullTraverserData &data, CPT(TransformState) &node_transform, @@ -233,15 +191,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, if (def._to_lens_node != (LensNode *)NULL && def._to_lens_node->get_lens() != (Lens *)NULL) { - + // Get the lens's projection matrix, as a TransformState. Lens *lens = def._to_lens_node->get_lens(def._lens_index); if (lens != NULL) { CPT(TransformState) projmat = TransformState::make_mat(lens->get_projection_mat()); - // We need a special transform to convert the -0.5, 0.5 - // centering of the lens's projection matrix to UV's in the - // range of (0, 1). + // We need a special transform to convert the -0.5, 0.5 centering of + // the lens's projection matrix to UV's in the range of (0, 1). static CPT(TransformState) fixmat; if (fixmat == (TransformState *)NULL) { fixmat = TransformState::make_pos_hpr_scale @@ -249,14 +206,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, LVecBase3(0.0f, 0.0f, 0.0f), LVecBase3(0.5f, 0.5f, 1.0f)); } - + // Now apply both to the current transform. transform = fixmat->compose(projmat)->compose(transform); } } if (!transform->is_identity()) { - tex_matrix = DCAST(TexMatrixAttrib, + tex_matrix = DCAST(TexMatrixAttrib, tex_matrix->add_stage(stage, transform)); } } @@ -266,26 +223,23 @@ cull_callback(CullTraverser *trav, CullTraverserData &data, } } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived TexProjectorEffect -// types to return a unique number indicating whether -// this TexProjectorEffect is equivalent to the other one. -// -// This should return 0 if the two TexProjectorEffect objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two TexProjectorEffect -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived TexProjectorEffect types to return a + * unique number indicating whether this TexProjectorEffect is equivalent to + * the other one. + * + * This should return 0 if the two TexProjectorEffect objects are equivalent, + * a number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two TexProjectorEffect objects whose + * get_type() functions return the same. + */ int TexProjectorEffect:: compare_to_impl(const RenderEffect *other) const { const TexProjectorEffect *ta; DCAST_INTO_R(ta, other, 0); - + Stages::const_iterator ai, bi; ai = _stages.begin(); bi = ta->_stages.begin(); @@ -322,46 +276,37 @@ compare_to_impl(const RenderEffect *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TexProjectorEffect. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TexProjectorEffect. + */ void TexProjectorEffect:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TexProjectorEffect:: write_datagram(BamWriter *manager, Datagram &dg) { RenderEffect::write_datagram(manager, dg); // For now, we don't write anything to the bam file for a - // TexProjectorEffect, except a bogus 0 "size" which may one day - // indicate the number of stages in the map that we might write out. + // TexProjectorEffect, except a bogus 0 "size" which may one day indicate + // the number of stages in the map that we might write out. dg.add_uint16(0); - // One day we will write the whole map out. We don't do this yet, - // because (a) we don't have an interface for writing out NodePaths - // to a bam file, and (b) it won't matter until we have the - // Panda-monium system in place, since you can't load a - // TexProjectorEffect from an egg file. + // One day we will write the whole map out. We don't do this yet, because + // (a) we don't have an interface for writing out NodePaths to a bam file, + // and (b) it won't matter until we have the Panda-monium system in place, + // since you can't load a TexProjectorEffect from an egg file. } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TexProjectorEffect:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderEffect::complete_pointers(p_list, manager); @@ -369,14 +314,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TexProjectorEffect is encountered -// in the Bam file. It should create the TexProjectorEffect -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TexProjectorEffect is encountered in the Bam file. It should create + * the TexProjectorEffect and extract its information from the file. + */ TypedWritable *TexProjectorEffect:: make_from_bam(const FactoryParams ¶ms) { TexProjectorEffect *effect = new TexProjectorEffect; @@ -389,31 +331,26 @@ make_from_bam(const FactoryParams ¶ms) { return effect; } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TexProjectorEffect. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TexProjectorEffect. + */ void TexProjectorEffect:: fillin(DatagramIterator &scan, BamReader *manager) { RenderEffect::fillin(scan, manager); size_t num_stages = scan.get_uint16(); - // Since we don't support full reading and writing of - // TexProjectorEffects yet, this value had better be zero. If it's - // not, maybe we're trying to read a bam file that was generated by - // some future version of Panda that does support these things. + // Since we don't support full reading and writing of TexProjectorEffects + // yet, this value had better be zero. If it's not, maybe we're trying to + // read a bam file that was generated by some future version of Panda that + // does support these things. nassertv(num_stages == 0); } -//////////////////////////////////////////////////////////////////// -// Function: TexProjectorEffect::StageDef::set_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexProjectorEffect::StageDef:: set_to(const NodePath &to) { _to = to; diff --git a/panda/src/pgraph/texProjectorEffect.h b/panda/src/pgraph/texProjectorEffect.h index 5775f70b74..faf70caf82 100644 --- a/panda/src/pgraph/texProjectorEffect.h +++ b/panda/src/pgraph/texProjectorEffect.h @@ -1,16 +1,15 @@ -// Filename: texProjectorEffect.h -// Created by: drose (25Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texProjectorEffect.h + * @author drose + * @date 2004-07-25 + */ #ifndef TEXPROJECTOREFFECT_H #define TEXPROJECTOREFFECT_H @@ -23,39 +22,30 @@ class LensNode; -//////////////////////////////////////////////////////////////////// -// Class : TexProjectorEffect -// Description : This effect automatically applies a computed texture -// matrix to the specified texture stage, according to -// the relative position of two specified nodes. -// -// The relative transform from the "from" node to the -// "to" node is applied directly to the texture matrix -// each frame. If the "to" node happens to be a -// LensNode, its lens projection matrix is applied as -// well. -// -// This can be used to apply a number of special -// effects. Fundamentally, it may simply be used to -// provide a separate PandaNode that may be adjusted -// (e.g. via a LerpInterval) in order to easily apply a -// linear transformation to an object's texture -// coordinates (rather than having to explicitly call -// NodePath.set_tex_transform() each frame). -// -// In a more sophisticated case, the TexProjectorEffect -// is particularly useful in conjunction with a -// TexGenAttrib that specifies a mode of -// M_world_position (which copies the world position of -// each vertex to the texture coordinates). Then the -// TexProjector can be used to convert these world -// coordinates to the relative coordinates of a -// particular node, causing (for instance) a texture to -// appear to follow a node around as it moves through -// the world. With a LensNode, you can project a -// texture onto the walls, for instance to apply a -// flashlight effect or an image-based shadow. -//////////////////////////////////////////////////////////////////// +/** + * This effect automatically applies a computed texture matrix to the + * specified texture stage, according to the relative position of two + * specified nodes. + * + * The relative transform from the "from" node to the "to" node is applied + * directly to the texture matrix each frame. If the "to" node happens to be + * a LensNode, its lens projection matrix is applied as well. + * + * This can be used to apply a number of special effects. Fundamentally, it + * may simply be used to provide a separate PandaNode that may be adjusted + * (e.g. via a LerpInterval) in order to easily apply a linear transformation + * to an object's texture coordinates (rather than having to explicitly call + * NodePath.set_tex_transform() each frame). + * + * In a more sophisticated case, the TexProjectorEffect is particularly useful + * in conjunction with a TexGenAttrib that specifies a mode of + * M_world_position (which copies the world position of each vertex to the + * texture coordinates). Then the TexProjector can be used to convert these + * world coordinates to the relative coordinates of a particular node, causing + * (for instance) a texture to appear to follow a node around as it moves + * through the world. With a LensNode, you can project a texture onto the + * walls, for instance to apply a flashlight effect or an image-based shadow. + */ class EXPCL_PANDA_PGRAPH TexProjectorEffect : public RenderEffect { protected: INLINE TexProjectorEffect(); @@ -117,7 +107,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -139,4 +129,3 @@ private: #include "texProjectorEffect.I" #endif - diff --git a/panda/src/pgraph/textureAttrib.I b/panda/src/pgraph/textureAttrib.I index 003e9ca819..da1feca0be 100644 --- a/panda/src/pgraph/textureAttrib.I +++ b/panda/src/pgraph/textureAttrib.I @@ -1,24 +1,19 @@ -// Filename: textureAttrib.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureAttrib.I + * @author drose + * @date 2002-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::Constructor -// Access: Protected -// Description: Use TextureAttrib::make() to construct a new -// TextureAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TextureAttrib::make() to construct a new TextureAttrib object. + */ INLINE TextureAttrib:: TextureAttrib() { _next_implicit_sort = 0; @@ -27,13 +22,10 @@ TextureAttrib() { _filtered_seq = UpdateSeq::old(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::Copy Constructor -// Access: Protected -// Description: Use TextureAttrib::make() to construct a new -// TextureAttrib object. The copy constructor is only -// defined to facilitate methods like add_on_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Use TextureAttrib::make() to construct a new TextureAttrib object. The + * copy constructor is only defined to facilitate methods like add_on_stage(). + */ INLINE TextureAttrib:: TextureAttrib(const TextureAttrib ©) : _on_stages(copy._on_stages), @@ -47,31 +39,24 @@ TextureAttrib(const TextureAttrib ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::is_off -// Access: Published -// Description: Returns true if the TextureAttrib is an 'off' -// TextureAttrib, indicating that it should disable -// texturing. -// -// If multitexture is in effect, a TextureAttrib may not -// be strictly "on" or "off"; therefore, to get a more -// precise answer to this question, you should consider -// using has_all_off() or get_num_off_stages() or -// has_off_stage() instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TextureAttrib is an 'off' TextureAttrib, indicating + * that it should disable texturing. + * + * If multitexture is in effect, a TextureAttrib may not be strictly "on" or + * "off"; therefore, to get a more precise answer to this question, you should + * consider using has_all_off() or get_num_off_stages() or has_off_stage() + * instead. + */ INLINE bool TextureAttrib:: is_off() const { return (_on_stages.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_texture -// Access: Published -// Description: If the TextureAttrib is not an 'off' TextureAttrib, -// returns the base-level texture that is associated. -// Otherwise, return NULL. -//////////////////////////////////////////////////////////////////// +/** + * If the TextureAttrib is not an 'off' TextureAttrib, returns the base-level + * texture that is associated. Otherwise, return NULL. + */ INLINE Texture *TextureAttrib:: get_texture() const { if (_on_stages.empty()) { @@ -81,90 +66,70 @@ get_texture() const { return get_on_texture(filter_to_max(1)->get_on_stage(0)); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_num_on_stages -// Access: Published -// Description: Returns the number of stages that are turned on by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages that are turned on by the attribute. + */ INLINE int TextureAttrib:: get_num_on_stages() const { check_sorted(); return _render_stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_on_stage -// Access: Published -// Description: Returns the nth stage turned on by the attribute, -// sorted in render order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stage turned on by the attribute, sorted in render order. + */ INLINE TextureStage *TextureAttrib:: get_on_stage(int n) const { nassertr(n >= 0 && n < (int)_render_stages.size(), (TextureStage *)NULL); return _render_stages[n]->_stage; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_num_on_ff_stages -// Access: Published -// Description: Returns the number of on-stages that are relevant -// to the classic fixed function pipeline. This excludes -// texture stages such as normal maps. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of on-stages that are relevant to the classic fixed + * function pipeline. This excludes texture stages such as normal maps. + */ INLINE int TextureAttrib:: get_num_on_ff_stages() const { check_sorted(); return _render_ff_stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_render_ff_stage -// Access: Published -// Description: Returns the nth stage turned on by the attribute, -// sorted in render order, including only those relevant -// to the classic fixed function pipeline. This excludes -// texture stages such as normal maps. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stage turned on by the attribute, sorted in render order, + * including only those relevant to the classic fixed function pipeline. This + * excludes texture stages such as normal maps. + */ INLINE TextureStage *TextureAttrib:: get_on_ff_stage(int n) const { nassertr(n >= 0 && n < (int)_render_ff_stages.size(), (TextureStage *)NULL); return _render_ff_stages[n]->_stage; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_ff_tc_index -// Access: Published -// Description: For each TextureStage listed in get_on_ff_stage(), -// this returns a unique index number for the texture -// coordinate name used by that TextureStage. It is -// guaranteed to remain the same index number for each -// texcoord name (for a given set of TextureStages), -// even if the texture render order changes. -//////////////////////////////////////////////////////////////////// +/** + * For each TextureStage listed in get_on_ff_stage(), this returns a unique + * index number for the texture coordinate name used by that TextureStage. It + * is guaranteed to remain the same index number for each texcoord name (for a + * given set of TextureStages), even if the texture render order changes. + */ INLINE int TextureAttrib:: get_ff_tc_index(int n) const { nassertr(n >= 0 && n < (int)_render_ff_stages.size(), -1); return _render_ff_stages[n]->_ff_tc_index; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::has_on_stage -// Access: Published -// Description: Returns true if the indicated stage is turned on by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated stage is turned on by the attrib, false + * otherwise. + */ INLINE bool TextureAttrib:: has_on_stage(TextureStage *stage) const { return _on_stages.find(StageNode(stage)) != _on_stages.end(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_on_texture -// Access: Published -// Description: Returns the texture associated with the indicated -// stage, or NULL if no texture is associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture associated with the indicated stage, or NULL if no + * texture is associated. + */ INLINE Texture *TextureAttrib:: get_on_texture(TextureStage *stage) const { Stages::const_iterator si; @@ -175,14 +140,11 @@ get_on_texture(TextureStage *stage) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_on_sampler -// Access: Published -// Description: Returns the sampler associated with the indicated -// stage, or the one associated with its texture if -// no custom stage has been specified. It is an error -// to call this if the stage does not exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sampler associated with the indicated stage, or the one + * associated with its texture if no custom stage has been specified. It is + * an error to call this if the stage does not exist. + */ INLINE const SamplerState &TextureAttrib:: get_on_sampler(TextureStage *stage) const { Stages::const_iterator si; @@ -193,12 +155,9 @@ get_on_sampler(TextureStage *stage) const { : si->_texture->get_default_sampler(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_on_stage_override -// Access: Published -// Description: Returns the override value associated with the -// indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the override value associated with the indicated stage. + */ INLINE int TextureAttrib:: get_on_stage_override(TextureStage *stage) const { Stages::const_iterator si; @@ -210,73 +169,58 @@ get_on_stage_override(TextureStage *stage) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_num_off_stages -// Access: Published -// Description: Returns the number of stages that are turned off by -// the attribute. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages that are turned off by the attribute. + */ INLINE int TextureAttrib:: get_num_off_stages() const { return _off_stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_off_stage -// Access: Published -// Description: Returns the nth stage turned off by the attribute, -// sorted in arbitrary (pointer) order. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth stage turned off by the attribute, sorted in arbitrary + * (pointer) order. + */ INLINE TextureStage *TextureAttrib:: get_off_stage(int n) const { nassertr(n >= 0 && n < (int)_off_stages.size(), (TextureStage *)NULL); return _off_stages[n]._stage; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::has_off_stage -// Access: Published -// Description: Returns true if the indicated stage is turned off by -// the attrib, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated stage is turned off by the attrib, false + * otherwise. + */ INLINE bool TextureAttrib:: has_off_stage(TextureStage *stage) const { return _off_stages.find(StageNode(stage)) != _off_stages.end() || (_off_all_stages && !has_on_stage(stage)); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::has_all_off -// Access: Published -// Description: Returns true if this attrib turns off all stages -// (although it may also turn some on). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this attrib turns off all stages (although it may also turn + * some on). + */ INLINE bool TextureAttrib:: has_all_off() const { return _off_all_stages; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::is_identity -// Access: Published -// Description: Returns true if this is an identity attrib: it does -// not change the set of stages in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an identity attrib: it does not change the set of + * stages in use. + */ INLINE bool TextureAttrib:: is_identity() const { return _on_stages.empty() && _off_stages.empty() && !_off_all_stages; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::check_sorted -// Access: Private -// Description: Confirms whether the _on_stages list is still sorted. -// It will become unsorted if someone calls -// TextureStage::set_sort(). -// -// If the list requires sorting, transparently sorts it -// before returning. -//////////////////////////////////////////////////////////////////// +/** + * Confirms whether the _on_stages list is still sorted. It will become + * unsorted if someone calls TextureStage::set_sort(). + * + * If the list requires sorting, transparently sorts it before returning. + */ INLINE void TextureAttrib:: check_sorted() const { if (_sort_seq != TextureStage::get_sort_seq()) { @@ -284,15 +228,13 @@ check_sorted() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::StageNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextureAttrib::StageNode:: StageNode(const TextureStage *stage, unsigned int implicit_sort, int override) : - // Yeah, we cast away the constness here. Just too much trouble to - // deal with it properly. + // Yeah, we cast away the constness here. Just too much trouble to deal + // with it properly. _stage((TextureStage *)stage), _implicit_sort(implicit_sort), _override(override), @@ -300,13 +242,10 @@ StageNode(const TextureStage *stage, unsigned int implicit_sort, int override) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::CompareTextureStagePriorities::operator () -// Access: Public -// Description: This STL function object is used to sort a list of -// texture stages in reverse order by priority, and -// within priority, within order by sort. -//////////////////////////////////////////////////////////////////// +/** + * This STL function object is used to sort a list of texture stages in + * reverse order by priority, and within priority, within order by sort. + */ INLINE bool TextureAttrib::CompareTextureStagePriorities:: operator () (const TextureAttrib::StageNode *a, const TextureAttrib::StageNode *b) const { @@ -319,12 +258,10 @@ operator () (const TextureAttrib::StageNode *a, return a->_implicit_sort < b->_implicit_sort; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::CompareTextureStageSort::operator () -// Access: Public -// Description: This STL function object is used to sort a list of -// texture stages in order by sort. -//////////////////////////////////////////////////////////////////// +/** + * This STL function object is used to sort a list of texture stages in order + * by sort. + */ INLINE bool TextureAttrib::CompareTextureStageSort:: operator () (const TextureAttrib::StageNode *a, const TextureAttrib::StageNode *b) const { @@ -334,12 +271,10 @@ operator () (const TextureAttrib::StageNode *a, return a->_implicit_sort < b->_implicit_sort; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::CompareTextureStagePointer::operator () -// Access: Public -// Description: This STL function object is used to sort a list of -// texture stages in order by pointer. -//////////////////////////////////////////////////////////////////// +/** + * This STL function object is used to sort a list of texture stages in order + * by pointer. + */ INLINE bool TextureAttrib::CompareTextureStagePointer:: operator () (const TextureAttrib::StageNode &a, const TextureAttrib::StageNode &b) const { diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index 6de455327e..694a4ca00e 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: textureAttrib.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureAttrib.cxx + * @author drose + * @date 2002-02-21 + */ #include "textureAttrib.h" #include "graphicsStateGuardianBase.h" @@ -28,39 +27,31 @@ TypeHandle TextureAttrib::_type_handle; int TextureAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make -// Access: Published, Static -// Description: Constructs a new TextureAttrib object suitable for -// rendering the indicated texture onto geometry, using -// the default TextureStage. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TextureAttrib object suitable for rendering the indicated + * texture onto geometry, using the default TextureStage. + */ CPT(RenderAttrib) TextureAttrib:: make(Texture *texture) { return DCAST(TextureAttrib, make())->add_on_stage(TextureStage::get_default(), texture); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make_off -// Access: Published, Static -// Description: Constructs a new TextureAttrib object suitable for -// rendering untextured geometry. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TextureAttrib object suitable for rendering untextured + * geometry. + */ CPT(RenderAttrib) TextureAttrib:: make_off() { return make_all_off(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make -// Access: Published, Static -// Description: Constructs a new TextureAttrib object that does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TextureAttrib object that does nothing. + */ CPT(RenderAttrib) TextureAttrib:: make() { - // We make it a special case and store a pointer to the empty attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the empty attrib forever + // once we find it the first time, as an optimization. if (_empty_attrib == (RenderAttrib *)NULL) { _empty_attrib = return_new(new TextureAttrib); } @@ -68,16 +59,14 @@ make() { return _empty_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make_all_off -// Access: Published, Static -// Description: Constructs a new TextureAttrib object that turns off -// all stages (and hence disables texturing). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TextureAttrib object that turns off all stages (and hence + * disables texturing). + */ CPT(RenderAttrib) TextureAttrib:: make_all_off() { - // We make it a special case and store a pointer to the off attrib - // forever once we find it the first time, as an optimization. + // We make it a special case and store a pointer to the off attrib forever + // once we find it the first time, as an optimization. if (_all_off_attrib == (RenderAttrib *)NULL) { TextureAttrib *attrib = new TextureAttrib; attrib->_off_all_stages = true; @@ -87,26 +76,20 @@ make_all_off() { return _all_off_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) TextureAttrib:: make_default() { return make(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::find_on_stage -// Access: Published -// Description: Returns the index number of the indicated -// TextureStage within the list of on_stages, or -1 if -// the indicated stage is not listed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the indicated TextureStage within the list of + * on_stages, or -1 if the indicated stage is not listed. + */ int TextureAttrib:: find_on_stage(const TextureStage *stage) const { Stages::const_iterator si = _on_stages.find(StageNode(stage)); @@ -117,13 +100,10 @@ find_on_stage(const TextureStage *stage) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::add_on_stage -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with the indicated stage added to the list of stages -// turned on by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with the indicated + * stage added to the list of stages turned on by this attrib. + */ CPT(RenderAttrib) TextureAttrib:: add_on_stage(TextureStage *stage, Texture *tex, int override) const { TextureAttrib *attrib = new TextureAttrib(*this); @@ -141,13 +121,10 @@ add_on_stage(TextureStage *stage, Texture *tex, int override) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::add_on_stage -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with the indicated stage added to the list of stages -// turned on by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with the indicated + * stage added to the list of stages turned on by this attrib. + */ CPT(RenderAttrib) TextureAttrib:: add_on_stage(TextureStage *stage, Texture *tex, const SamplerState &sampler, int override) const { TextureAttrib *attrib = new TextureAttrib(*this); @@ -166,13 +143,10 @@ add_on_stage(TextureStage *stage, Texture *tex, const SamplerState &sampler, int return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::remove_on_stage -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with the indicated stage removed from the list of -// stages turned on by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with the indicated + * stage removed from the list of stages turned on by this attrib. + */ CPT(RenderAttrib) TextureAttrib:: remove_on_stage(TextureStage *stage) const { TextureAttrib *attrib = new TextureAttrib(*this); @@ -188,13 +162,10 @@ remove_on_stage(TextureStage *stage) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::add_off_stage -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with the indicated stage added to the list of stages -// turned off by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with the indicated + * stage added to the list of stages turned off by this attrib. + */ CPT(RenderAttrib) TextureAttrib:: add_off_stage(TextureStage *stage, int override) const { TextureAttrib *attrib = new TextureAttrib(*this); @@ -214,13 +185,10 @@ add_off_stage(TextureStage *stage, int override) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::remove_off_stage -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with the indicated stage removed from the list of -// stages turned off by this attrib. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with the indicated + * stage removed from the list of stages turned off by this attrib. + */ CPT(RenderAttrib) TextureAttrib:: remove_off_stage(TextureStage *stage) const { TextureAttrib *attrib = new TextureAttrib(*this); @@ -228,14 +196,11 @@ remove_off_stage(TextureStage *stage) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::unify_texture_stages -// Access: Published -// Description: Returns a new TextureAttrib, just like this one, but -// with any included TextureAttribs that happen to have -// the same name as the given object replaced with the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, just like this one, but with any included + * TextureAttribs that happen to have the same name as the given object + * replaced with the object. + */ CPT(RenderAttrib) TextureAttrib:: unify_texture_stages(TextureStage *stage) const { PT(TextureAttrib) attrib = new TextureAttrib; @@ -281,14 +246,11 @@ unify_texture_stages(TextureStage *stage) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::filter_to_max -// Access: Public -// Description: Returns a new TextureAttrib, very much like this one, -// but with the number of on_stages reduced to be no -// more than max_texture_stages. The number of -// off_stages in the new TextureAttrib is undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TextureAttrib, very much like this one, but with the number + * of on_stages reduced to be no more than max_texture_stages. The number of + * off_stages in the new TextureAttrib is undefined. + */ CPT(TextureAttrib) TextureAttrib:: filter_to_max(int max_texture_stages) const { if ((int)_on_stages.size() <= max_texture_stages) { @@ -309,9 +271,9 @@ filter_to_max(int max_texture_stages) const { return (*fi).second; } - // Harder case: we have to compute it now. We must choose the n - // stages with the highest priority in our list of stages. In the - // case of equal priority, we prefer the stage with the lower sort. + // Harder case: we have to compute it now. We must choose the n stages with + // the highest priority in our list of stages. In the case of equal + // priority, we prefer the stage with the lower sort. check_sorted(); RenderStages priority_stages = _render_stages; @@ -336,60 +298,48 @@ filter_to_max(int max_texture_stages) const { CPT(RenderAttrib) new_attrib = return_new(attrib); - // Finally, record this newly-created attrib in the map for next - // time. + // Finally, record this newly-created attrib in the map for next time. - // TODO: if new_attrib == this, have we just created a circular - // reference count? Whoops! Fix this! + // TODO: if new_attrib == this, have we just created a circular reference + // count? Whoops! Fix this! CPT(TextureAttrib) tex_attrib = (const TextureAttrib *)new_attrib.p(); ((TextureAttrib *)this)->_filtered[max_texture_stages] = tex_attrib; return tex_attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::lower_attrib_can_override -// Access: Public, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return false if a RenderAttrib on a -// higher node will compose into a RenderAttrib on a -// lower node that has a higher override value, or false -// if the lower RenderAttrib will completely replace the -// state. -// -// The default behavior is false: normally, a -// RenderAttrib in the graph cannot completely override -// a RenderAttrib above it, regardless of its override -// value--instead, the two attribs are composed. But -// for some kinds of RenderAttribs, it is useful to -// allow this kind of override. -// -// This method only handles the one special case of a -// lower RenderAttrib with a higher override value. If -// the higher RenderAttrib has a higher override value, -// it always completely overrides. And if both -// RenderAttribs have the same override value, they are -// always composed. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return false if a RenderAttrib on a higher node will compose + * into a RenderAttrib on a lower node that has a higher override value, or + * false if the lower RenderAttrib will completely replace the state. + * + * The default behavior is false: normally, a RenderAttrib in the graph cannot + * completely override a RenderAttrib above it, regardless of its override + * value--instead, the two attribs are composed. But for some kinds of + * RenderAttribs, it is useful to allow this kind of override. + * + * This method only handles the one special case of a lower RenderAttrib with + * a higher override value. If the higher RenderAttrib has a higher override + * value, it always completely overrides. And if both RenderAttribs have the + * same override value, they are always composed. + */ bool TextureAttrib:: lower_attrib_can_override() const { - // A TextureAttrib doesn't compose through an override. Normally, - // there won't be a scene-graph override on a TextureAttrib anyway, - // since the NodePath::set_texture() override is applied to the - // per-TextureStage override value. But there might be a - // scene-graph override if NodePath::adjust_all_priorities() is - // used, and in this case, we'd like for it to stick. + // A TextureAttrib doesn't compose through an override. Normally, there + // won't be a scene-graph override on a TextureAttrib anyway, since the + // NodePath::set_texture() override is applied to the per-TextureStage + // override value. But there might be a scene-graph override if + // NodePath::adjust_all_priorities() is used, and in this case, we'd like + // for it to stick. return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureAttrib:: output(ostream &out) const { check_sorted(); @@ -442,15 +392,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::has_cull_callback -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if cull_callback() has been defined. Otherwise, -// returns false to indicate cull_callback() does not -// need to be called for this node during the cull -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if cull_callback() + * has been defined. Otherwise, returns false to indicate cull_callback() + * does not need to be called for this node during the cull traversal. + */ bool TextureAttrib:: has_cull_callback() const { Stages::const_iterator si; @@ -464,19 +410,15 @@ has_cull_callback() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::cull_callback -// Access: Public, Virtual -// Description: If has_cull_callback() returns true, this function -// will be called during the cull traversal to perform -// any additional operations that should be performed at -// cull time. -// -// This is called each time the RenderAttrib is -// discovered applied to a Geom in the traversal. It -// should return true if the Geom is visible, false if -// it should be omitted. -//////////////////////////////////////////////////////////////////// +/** + * If has_cull_callback() returns true, this function will be called during + * the cull traversal to perform any additional operations that should be + * performed at cull time. + * + * This is called each time the RenderAttrib is discovered applied to a Geom + * in the traversal. It should return true if the Geom is visible, false if + * it should be omitted. + */ bool TextureAttrib:: cull_callback(CullTraverser *trav, const CullTraverserData &data) const { Stages::const_iterator si; @@ -490,21 +432,18 @@ cull_callback(CullTraverser *trav, const CullTraverserData &data) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived TextureAttrib -// types to return a unique number indicating whether -// this TextureAttrib is equivalent to the other one. -// -// This should return 0 if the two TextureAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two TextureAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived TextureAttrib types to return a unique + * number indicating whether this TextureAttrib is equivalent to the other + * one. + * + * This should return 0 if the two TextureAttrib objects are equivalent, a + * number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two TextureAttrib objects whose get_type() + * functions return the same. + */ int TextureAttrib:: compare_to_impl(const RenderAttrib *other) const { const TextureAttrib *ta = (const TextureAttrib *)other; @@ -605,16 +544,12 @@ compare_to_impl(const RenderAttrib *other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t TextureAttrib:: get_hash_impl() const { check_sorted(); @@ -630,8 +565,8 @@ get_hash_impl() const { hash = int_hash::add_hash(hash, sn._override); } - // This bool value goes here, between the two lists, to - // differentiate between the two. + // This bool value goes here, between the two lists, to differentiate + // between the two. hash = int_hash::add_hash(hash, (int)_off_all_stages); for (si = _off_stages.begin(); si != _off_stages.end(); ++si) { @@ -644,36 +579,29 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// This should return the result of applying the other -// RenderAttrib to a node in the scene graph below this -// RenderAttrib, which was already applied. In most -// cases, the result is the same as the other -// RenderAttrib (that is, a subsequent RenderAttrib -// completely replaces the preceding one). On the other -// hand, some kinds of RenderAttrib (for instance, -// ColorTransformAttrib) might combine in meaningful -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * This should return the result of applying the other RenderAttrib to a node + * in the scene graph below this RenderAttrib, which was already applied. In + * most cases, the result is the same as the other RenderAttrib (that is, a + * subsequent RenderAttrib completely replaces the preceding one). On the + * other hand, some kinds of RenderAttrib (for instance, ColorTransformAttrib) + * might combine in meaningful ways. + */ CPT(RenderAttrib) TextureAttrib:: compose_impl(const RenderAttrib *other) const { const TextureAttrib *ta = (const TextureAttrib *)other; if (ta->_off_all_stages) { - // If the other type turns off all stages, it doesn't matter what - // we are. + // If the other type turns off all stages, it doesn't matter what we are. return ta; } - // This is a three-way merge between ai, bi, and ci, except that bi - // and ci should have no intersection and therefore needn't be - // compared to each other. + // This is a three-way merge between ai, bi, and ci, except that bi and ci + // should have no intersection and therefore needn't be compared to each + // other. Stages::const_iterator ai = _on_stages.begin(); Stages::const_iterator bi = ta->_on_stages.begin(); Stages::const_iterator ci = ta->_off_stages.begin(); @@ -686,19 +614,19 @@ compose_impl(const RenderAttrib *other) const { ci != ta->_off_stages.end()) { if ((*ai)._stage < (*bi)._stage) { if ((*ai)._stage < (*ci)._stage) { - // Here is a stage that we have in the original, which is not - // present in the secondary. + // Here is a stage that we have in the original, which is not present + // in the secondary. attrib->_on_stages.insert(attrib->_on_stages.end(), *ai); ++ai; } else if ((*ci)._stage < (*ai)._stage) { - // Here is a stage that is turned off in the secondary, but - // was not present in the original. + // Here is a stage that is turned off in the secondary, but was not + // present in the original. ++ci; } else { // (*ci)._stage == (*ai)._stage - // Here is a stage that is turned off in the secondary, and - // was present in the original. + // Here is a stage that is turned off in the secondary, and was + // present in the original. if ((*ai)._override > (*ci)._override) { // But never mind, keep it anyway. attrib->_on_stages.insert(attrib->_on_stages.end(), *ai); @@ -709,8 +637,8 @@ compose_impl(const RenderAttrib *other) const { } } else if ((*bi)._stage < (*ai)._stage) { - // Here is a new stage we have in the secondary, that was not - // present in the original. + // Here is a new stage we have in the secondary, that was not present in + // the original. attrib->_on_stages.insert(attrib->_on_stages.end(), *bi); ++bi; @@ -728,14 +656,14 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_stages.end() && bi != ta->_on_stages.end()) { if ((*ai)._stage < (*bi)._stage) { - // Here is a stage that we have in the original, which is not - // present in the secondary. + // Here is a stage that we have in the original, which is not present in + // the secondary. attrib->_on_stages.insert(attrib->_on_stages.end(), *ai); ++ai; } else if ((*bi)._stage < (*ai)._stage) { - // Here is a new stage we have in the secondary, that was not - // present in the original. + // Here is a new stage we have in the secondary, that was not present in + // the original. attrib->_on_stages.insert(attrib->_on_stages.end(), *bi); ++bi; @@ -753,19 +681,19 @@ compose_impl(const RenderAttrib *other) const { while (ai != _on_stages.end() && ci != ta->_off_stages.end()) { if ((*ai)._stage < (*ci)._stage) { - // Here is a stage that we have in the original, which is not - // present in the secondary. + // Here is a stage that we have in the original, which is not present in + // the secondary. attrib->_on_stages.insert(attrib->_on_stages.end(), *ai); ++ai; } else if ((*ci)._stage < (*ai)._stage) { - // Here is a stage that is turned off in the secondary, but - // was not present in the original. + // Here is a stage that is turned off in the secondary, but was not + // present in the original. ++ci; } else { // (*ci)._stage == (*ai)._stage - // Here is a stage that is turned off in the secondary, and - // was present in the original. + // Here is a stage that is turned off in the secondary, and was present + // in the original. if ((*ai)._override > (*ci)._override) { // But never mind, keep it anyway. attrib->_on_stages.insert(attrib->_on_stages.end(), *ai); @@ -792,50 +720,40 @@ compose_impl(const RenderAttrib *other) const { return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::invert_compose_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to specify how two consecutive RenderAttrib -// objects of the same type interact. -// -// See invert_compose() and compose_impl(). -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to specify how two + * consecutive RenderAttrib objects of the same type interact. + * + * See invert_compose() and compose_impl(). + */ CPT(RenderAttrib) TextureAttrib:: invert_compose_impl(const RenderAttrib *other) const { - // I think in this case the other attrib always wins. Maybe this - // needs a bit more thought. It's hard to imagine that it's even - // important to compute this properly. + // I think in this case the other attrib always wins. Maybe this needs a + // bit more thought. It's hard to imagine that it's even important to + // compute this properly. return other; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) TextureAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TextureAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TextureAttrib. + */ void TextureAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TextureAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -868,13 +786,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int TextureAttrib:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = RenderAttrib::complete_pointers(p_list, manager); @@ -891,8 +806,8 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { PT(TextureStage) ts = DCAST(TextureStage, p_list[pi++]); ts = TextureStagePool::get_stage(ts); - // The Texture pointer filters itself through the TexturePool, so - // we don't have to do anything special here. + // The Texture pointer filters itself through the TexturePool, so we don't + // have to do anything special here. Texture *tex = DCAST(Texture, p_list[pi++]); if (tex != (Texture *)NULL) { @@ -902,8 +817,8 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { ++sni; } else { - // If we couldn't load a texture pointer, turn off that - // particular texture stage. + // If we couldn't load a texture pointer, turn off that particular + // texture stage. _off_stages.push_back(StageNode(ts)); _on_stages.erase(_on_stages.begin() + sni); } @@ -915,14 +830,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TextureAttrib is encountered -// in the Bam file. It should create the TextureAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TextureAttrib is encountered in the Bam file. It should create the + * TextureAttrib and extract its information from the file. + */ TypedWritable *TextureAttrib:: make_from_bam(const FactoryParams ¶ms) { TextureAttrib *attrib = new TextureAttrib; @@ -935,13 +847,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TextureAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TextureAttrib. + */ void TextureAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); @@ -950,8 +859,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { _off_all_stages = scan.get_bool(); int num_off_stages = scan.get_uint16(); - // Push back a NULL pointer for each off TextureStage for now, until - // we get the actual list of pointers later in complete_pointers(). + // Push back a NULL pointer for each off TextureStage for now, until we get + // the actual list of pointers later in complete_pointers(). int i; _off_stages.reserve(num_off_stages); for (i = 0; i < num_off_stages; i++) { @@ -962,9 +871,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { // Read the _on_stages data. int num_on_stages = scan.get_uint16(); - // Push back a NULL pointer for each off TextureStage and Texture - // for now, until we get the actual list of pointers later in - // complete_pointers(). + // Push back a NULL pointer for each off TextureStage and Texture for now, + // until we get the actual list of pointers later in complete_pointers(). _on_stages.reserve(num_on_stages); _next_implicit_sort = 0; for (i = 0; i < num_on_stages; i++) { @@ -995,13 +903,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureAttrib::sort_on_stages -// Access: Private -// Description: Sorts the list of stages so that they are listed in -// render order. Also clears the _filtered map and -// recalculates the list of fixed-function stages. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the list of stages so that they are listed in render order. Also + * clears the _filtered map and recalculates the list of fixed-function + * stages. + */ void TextureAttrib:: sort_on_stages() { typedef pmap UsedTexcoordIndex; @@ -1021,9 +927,9 @@ sort_on_stages() { const InternalName *name = stage->get_texcoord_name(); // This pair of lines will get the next consecutive texcoord index - // number if this is the first time we have referenced this - // particular texcoord name; otherwise, it will return the same - // index number it returned before. + // number if this is the first time we have referenced this particular + // texcoord name; otherwise, it will return the same index number it + // returned before. UsedTexcoordIndex::iterator ti = used_texcoord_index.insert(UsedTexcoordIndex::value_type(name, (int)used_texcoord_index.size())).first; (*si)._ff_tc_index = (*ti).second; @@ -1038,11 +944,11 @@ sort_on_stages() { sort(_render_stages.begin(), _render_stages.end(), CompareTextureStageSort()); sort(_render_ff_stages.begin(), _render_ff_stages.end(), CompareTextureStageSort()); - // We'd like to clear the _filtered map, in case the TextureStage - // priority values have changed as well, but we can't do that here: - // it's too dangerous. Clearing _filtered might cause - // TextureAttribs to be deleted, and hence removed from the map that - // we might be in the middle of traversing! + // We'd like to clear the _filtered map, in case the TextureStage priority + // values have changed as well, but we can't do that here: it's too + // dangerous. Clearing _filtered might cause TextureAttribs to be deleted, + // and hence removed from the map that we might be in the middle of + // traversing! _sort_seq = TextureStage::get_sort_seq(); } diff --git a/panda/src/pgraph/textureAttrib.h b/panda/src/pgraph/textureAttrib.h index a5f5ed9bf6..2cc5270536 100644 --- a/panda/src/pgraph/textureAttrib.h +++ b/panda/src/pgraph/textureAttrib.h @@ -1,16 +1,15 @@ -// Filename: textureAttrib.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureAttrib.h + * @author drose + * @date 2002-02-21 + */ #ifndef TEXTUREATTRIB_H #define TEXTUREATTRIB_H @@ -25,20 +24,18 @@ #include "vector_int.h" #include "epvector.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureAttrib -// Description : Indicates the set of TextureStages and their -// associated Textures that should be applied to (or -// removed from) a node. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the set of TextureStages and their associated Textures that + * should be applied to (or removed from) a node. + */ class EXPCL_PANDA_PGRAPH TextureAttrib : public RenderAttrib { protected: INLINE TextureAttrib(); INLINE TextureAttrib(const TextureAttrib ©); PUBLISHED: - // These methods are used to create a simple, single-textured layer. - // For multitexture, use the multitexture interfaces, further below. + // These methods are used to create a simple, single-textured layer. For + // multitexture, use the multitexture interfaces, further below. static CPT(RenderAttrib) make(Texture *tex); static CPT(RenderAttrib) make_off(); static CPT(RenderAttrib) make_default(); @@ -46,10 +43,10 @@ PUBLISHED: INLINE bool is_off() const; INLINE Texture *get_texture() const; - // The following methods define the new multitexture mode for - // TextureAttrib. Each TextureAttrib can add or remove individual - // texture stages from the complete set of textures that are to be - // applied; this is similar to the mechanism of LightAttrib. + // The following methods define the new multitexture mode for TextureAttrib. + // Each TextureAttrib can add or remove individual texture stages from the + // complete set of textures that are to be applied; this is similar to the + // mechanism of LightAttrib. static CPT(RenderAttrib) make(); static CPT(RenderAttrib) make_all_off(); diff --git a/panda/src/pgraph/textureStageCollection.I b/panda/src/pgraph/textureStageCollection.I index 1f0a2589e1..1eabc2d9bf 100644 --- a/panda/src/pgraph/textureStageCollection.I +++ b/panda/src/pgraph/textureStageCollection.I @@ -1,43 +1,35 @@ -// Filename: textureStageCollection.I -// Created by: drose (23Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStageCollection.I + * @author drose + * @date 2004-07-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextureStageCollection:: ~TextureStageCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void TextureStageCollection:: operator += (const TextureStageCollection &other) { add_texture_stages_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::operator + -// Access: Published -// Description: Returns a TextureStageCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a TextureStageCollection representing the concatenation of the two + * lists. + */ INLINE TextureStageCollection TextureStageCollection:: operator + (const TextureStageCollection &other) const { TextureStageCollection a(*this); @@ -45,12 +37,10 @@ operator + (const TextureStageCollection &other) const { return a; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::CompareTextureStageSort::operator () -// Access: Public -// Description: This STL function object is used to sort a list of -// texture stages in order by sort. -//////////////////////////////////////////////////////////////////// +/** + * This STL function object is used to sort a list of texture stages in order + * by sort. + */ INLINE bool TextureStageCollection::CompareTextureStageSort:: operator () (const TextureStage *a, const TextureStage *b) const { return a->get_sort() < b->get_sort(); diff --git a/panda/src/pgraph/textureStageCollection.cxx b/panda/src/pgraph/textureStageCollection.cxx index fc84113863..4f707efe63 100644 --- a/panda/src/pgraph/textureStageCollection.cxx +++ b/panda/src/pgraph/textureStageCollection.cxx @@ -1,16 +1,15 @@ -// Filename: textureStageCollection.cxx -// Created by: drose (23Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStageCollection.cxx + * @author drose + * @date 2004-07-23 + */ #include "textureStageCollection.h" @@ -18,47 +17,38 @@ #include "indirectLess.h" #include -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureStageCollection:: TextureStageCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureStageCollection:: TextureStageCollection(const TextureStageCollection ©) : _texture_stages(copy._texture_stages) { } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureStageCollection:: operator = (const TextureStageCollection ©) { _texture_stages = copy._texture_stages; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::add_texture_stage -// Access: Published -// Description: Adds a new TextureStage to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new TextureStage to the collection. + */ void TextureStageCollection:: add_texture_stage(TextureStage *node_texture_stage) { // If the pointer to our internal array is shared by any other // TextureStageCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren TextureStageCollection - // objects. + // inadvertently modify any of our brethren TextureStageCollection objects. if (_texture_stages.get_ref_count() > 1) { TextureStages old_texture_stages = _texture_stages; @@ -69,13 +59,11 @@ add_texture_stage(TextureStage *node_texture_stage) { _texture_stages.push_back(node_texture_stage); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::remove_texture_stage -// Access: Published -// Description: Removes the indicated TextureStage from the collection. -// Returns true if the texture_stage was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated TextureStage from the collection. Returns true if + * the texture_stage was removed, false if it was not a member of the + * collection. + */ bool TextureStageCollection:: remove_texture_stage(TextureStage *node_texture_stage) { int texture_stage_index = -1; @@ -92,8 +80,7 @@ remove_texture_stage(TextureStage *node_texture_stage) { // If the pointer to our internal array is shared by any other // TextureStageCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren TextureStageCollection - // objects. + // inadvertently modify any of our brethren TextureStageCollection objects. if (_texture_stages.get_ref_count() > 1) { TextureStages old_texture_stages = _texture_stages; @@ -105,14 +92,11 @@ remove_texture_stage(TextureStage *node_texture_stage) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::add_texture_stages_from -// Access: Published -// Description: Adds all the TextureStages indicated in the other -// collection to this texture_stage. The other texture_stages are simply -// appended to the end of the texture_stages in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the TextureStages indicated in the other collection to this + * texture_stage. The other texture_stages are simply appended to the end of + * the texture_stages in this list; duplicates are not automatically removed. + */ void TextureStageCollection:: add_texture_stages_from(const TextureStageCollection &other) { int other_num_texture_stages = other.get_num_texture_stages(); @@ -122,12 +106,10 @@ add_texture_stages_from(const TextureStageCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::remove_texture_stages_from -// Access: Published -// Description: Removes from this collection all of the TextureStages -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the TextureStages listed in the other + * collection. + */ void TextureStageCollection:: remove_texture_stages_from(const TextureStageCollection &other) { TextureStages new_texture_stages; @@ -141,14 +123,11 @@ remove_texture_stages_from(const TextureStageCollection &other) { _texture_stages = new_texture_stages; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::remove_duplicate_texture_stages -// Access: Published -// Description: Removes any duplicate entries of the same TextureStages -// on this collection. If a TextureStage appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same TextureStages on this collection. + * If a TextureStage appears multiple times, the first appearance is retained; + * subsequent appearances are removed. + */ void TextureStageCollection:: remove_duplicate_texture_stages() { TextureStages new_texture_stages; @@ -170,12 +149,10 @@ remove_duplicate_texture_stages() { _texture_stages = new_texture_stages; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::has_texture_stage -// Access: Published -// Description: Returns true if the indicated TextureStage appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated TextureStage appears in this collection, + * false otherwise. + */ bool TextureStageCollection:: has_texture_stage(TextureStage *texture_stage) const { for (int i = 0; i < get_num_texture_stages(); i++) { @@ -186,23 +163,18 @@ has_texture_stage(TextureStage *texture_stage) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::clear -// Access: Published -// Description: Removes all TextureStages from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all TextureStages from the collection. + */ void TextureStageCollection:: clear() { _texture_stages.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::find_texture_stage -// Access: Published -// Description: Returns the texture_stage in the collection with the -// indicated name, if any, or NULL if no texture_stage has -// that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture_stage in the collection with the indicated name, if + * any, or NULL if no texture_stage has that name. + */ TextureStage *TextureStageCollection:: find_texture_stage(const string &name) const { int num_texture_stages = get_num_texture_stages(); @@ -215,21 +187,17 @@ find_texture_stage(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::get_num_texture_stages -// Access: Published -// Description: Returns the number of TextureStages in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of TextureStages in the collection. + */ int TextureStageCollection:: get_num_texture_stages() const { return _texture_stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::get_texture_stage -// Access: Published -// Description: Returns the nth TextureStage in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth TextureStage in the collection. + */ TextureStage *TextureStageCollection:: get_texture_stage(int index) const { nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); @@ -237,13 +205,10 @@ get_texture_stage(int index) const { return _texture_stages[index]; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::operator [] -// Access: Published -// Description: Returns the nth TextureStage in the collection. This is -// the same as get_texture_stage(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth TextureStage in the collection. This is the same as + * get_texture_stage(), but it may be a more convenient way to access it. + */ TextureStage *TextureStageCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_texture_stages.size(), NULL); @@ -251,36 +216,29 @@ operator [] (int index) const { return _texture_stages[index]; } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::size -// Access: Published -// Description: Returns the number of texture stages in the -// collection. This is the same thing as -// get_num_texture_stages(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of texture stages in the collection. This is the same + * thing as get_num_texture_stages(). + */ int TextureStageCollection:: size() const { return _texture_stages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::sort -// Access: Published -// Description: Sorts the TextureStages in this collection into order -// by TextureStage::sort(), from lowest to highest. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the TextureStages in this collection into order by + * TextureStage::sort(), from lowest to highest. + */ void TextureStageCollection:: sort() { ::sort(_texture_stages.begin(), _texture_stages.end(), CompareTextureStageSort()); } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// TextureStageCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the TextureStageCollection to the + * indicated output stream. + */ void TextureStageCollection:: output(ostream &out) const { if (get_num_texture_stages() == 1) { @@ -290,12 +248,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureStageCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// TextureStageCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the TextureStageCollection to + * the indicated output stream. + */ void TextureStageCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_texture_stages(); i++) { diff --git a/panda/src/pgraph/textureStageCollection.h b/panda/src/pgraph/textureStageCollection.h index d34872810d..002447decc 100644 --- a/panda/src/pgraph/textureStageCollection.h +++ b/panda/src/pgraph/textureStageCollection.h @@ -1,16 +1,15 @@ -// Filename: textureStageCollection.h -// Created by: drose (23Jul04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureStageCollection.h + * @author drose + * @date 2004-07-23 + */ #ifndef TEXTURESTAGECOLLECTION_H #define TEXTURESTAGECOLLECTION_H @@ -19,10 +18,9 @@ #include "pointerToArray.h" #include "textureStage.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureStageCollection -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_PGRAPH TextureStageCollection { PUBLISHED: TextureStageCollection(); @@ -72,5 +70,3 @@ INLINE ostream &operator << (ostream &out, const TextureStageCollection &col) { #include "textureStageCollection.I" #endif - - diff --git a/panda/src/pgraph/transformState.I b/panda/src/pgraph/transformState.I index 7639e1ced8..3decc64a51 100644 --- a/panda/src/pgraph/transformState.I +++ b/panda/src/pgraph/transformState.I @@ -1,61 +1,48 @@ -// Filename: transformState.I -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformState.I + * @author drose + * @date 2002-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TransformState::operator != -// Access: Published -// Description: Opposite of operator ==. -//////////////////////////////////////////////////////////////////// +/** + * Opposite of operator ==. + */ INLINE bool TransformState:: operator != (const TransformState &other) const { return !(operator == (other)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::compare_to -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// TransformStates, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// Note that if this returns 0, it doesn't necessarily -// imply that operator == returns true; it uses a very -// slightly different comparison threshold. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique TransformStates, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * Note that if this returns 0, it doesn't necessarily imply that operator == + * returns true; it uses a very slightly different comparison threshold. + */ INLINE int TransformState:: compare_to(const TransformState &other) const { return compare_to(other, _uniquify_matrix); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_hash -// Access: Published -// Description: Returns a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable hash value for phash_map. + */ INLINE size_t TransformState:: get_hash() const { check_hash(); return _hash; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos(const LVecBase3 &pos) { return make_pos_hpr_scale(pos, @@ -63,12 +50,9 @@ make_pos(const LVecBase3 &pos) { LVecBase3(1.0f, 1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_hpr -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_hpr(const LVecBase3 &hpr) { return make_pos_hpr_scale(LVecBase3(0.0f, 0.0f, 0.0f), @@ -76,12 +60,9 @@ make_hpr(const LVecBase3 &hpr) { LVecBase3(1.0f, 1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_quat -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_quat(const LQuaternion &quat) { return make_pos_quat_scale(LVecBase3(0.0f, 0.0f, 0.0f), @@ -89,37 +70,28 @@ make_quat(const LQuaternion &quat) { LVecBase3(1.0f, 1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_hpr -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos_hpr(const LVecBase3 &pos, const LVecBase3 &hpr) { return make_pos_hpr_scale(pos, hpr, LVecBase3(1.0, 1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_scale -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_scale(PN_stdfloat scale) { - // We actually map this 3-d uniform make_scale() to the 2-d - // version--might as well call it a 2-d scale. + // We actually map this 3-d uniform make_scale() to the 2-d version--might + // as well call it a 2-d scale. return make_scale2d(scale); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_scale -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_scale(const LVecBase3 &scale) { return make_pos_hpr_scale(LVecBase3(0.0f, 0.0f, 0.0f), @@ -127,12 +99,9 @@ make_scale(const LVecBase3 &scale) { scale); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_shear -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_shear(const LVecBase3 &shear) { return make_pos_hpr_scale_shear(LVecBase3(0.0f, 0.0f, 0.0f), @@ -141,350 +110,269 @@ make_shear(const LVecBase3 &shear) { shear); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_hpr_scale -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos_hpr_scale(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) { return make_pos_hpr_scale_shear(pos, hpr, scale, LVecBase3::zero()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_quat_scale -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos_quat_scale(const LVecBase3 &pos, const LQuaternion &quat, const LVecBase3 &scale) { return make_pos_quat_scale_shear(pos, quat, scale, LVecBase3::zero()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos2d(const LVecBase2 &pos) { return make_pos_rotate_scale2d(pos, 0.0f, LVecBase2(1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_rotate2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_rotate2d(PN_stdfloat rotate) { return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), rotate, LVecBase2(1.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_rotate2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos_rotate2d(const LVecBase2 &pos, PN_stdfloat rotate) { return make_pos_rotate_scale2d(pos, rotate, LVecBase2(1.0, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_scale2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_scale2d(PN_stdfloat scale) { return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), 0.0f, LVecBase2(scale, scale)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_scale2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_scale2d(const LVecBase2 &scale) { return make_pos_rotate_scale2d(LVecBase2(0.0f, 0.0f), 0.0f, scale); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_shear2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_shear2d(PN_stdfloat shear) { return make_pos_rotate_scale_shear2d(LVecBase2(0.0f, 0.0f), 0.0f, LVecBase2(1.0f, 1.0f), shear); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_rotate_scale2d -// Access: Published, Static -// Description: Makes a new 2-d TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new 2-d TransformState with the specified components. + */ INLINE CPT(TransformState) TransformState:: make_pos_rotate_scale2d(const LVecBase2 &pos, PN_stdfloat rotate, const LVecBase2 &scale) { return make_pos_rotate_scale_shear2d(pos, rotate, scale, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::is_identity -// Access: Published -// Description: Returns true if the transform represents the identity -// matrix, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform represents the identity matrix, false + * otherwise. + */ INLINE bool TransformState:: is_identity() const { return ((_flags & F_is_identity) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::is_invalid -// Access: Published -// Description: Returns true if the transform represents an invalid -// matrix, for instance the result of inverting a -// singular matrix, or false if the transform is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform represents an invalid matrix, for instance + * the result of inverting a singular matrix, or false if the transform is + * valid. + */ INLINE bool TransformState:: is_invalid() const { return ((_flags & F_is_invalid) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::is_singular -// Access: Published -// Description: Returns true if the transform represents a singular -// transform (that is, it has a zero scale, and it -// cannot be inverted), or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform represents a singular transform (that is, it + * has a zero scale, and it cannot be inverted), or false otherwise. + */ INLINE bool TransformState:: is_singular() const { check_singular(); return ((_flags & F_is_singular) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::is_2d -// Access: Published -// Description: Returns true if the transform has been constructed -// entirely using the 2-d transform operations, -// e.g. make_pos2d(), and therefore operates strictly in -// two-dimensional space on X and Y only. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform has been constructed entirely using the 2-d + * transform operations, e.g. make_pos2d(), and therefore operates strictly + * in two-dimensional space on X and Y only. + */ INLINE bool TransformState:: is_2d() const { return ((_flags & F_is_2d) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_components -// Access: Published -// Description: Returns true if the transform can be described by -// separate pos, hpr, and scale components. Most -// transforms we use in everyday life can be so -// described, but some kinds of transforms (for -// instance, those involving a skew) cannot. -// -// This is not related to whether the transform was -// originally described componentwise. Even a transform -// that was constructed with a 4x4 may return true here -// if the matrix is a simple affine matrix with no skew. -// -// If this returns true, you may safely call get_hpr() -// and get_scale() to retrieve the components. (You -// may always safely call get_pos() whether this returns -// true or false.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform can be described by separate pos, hpr, and + * scale components. Most transforms we use in everyday life can be so + * described, but some kinds of transforms (for instance, those involving a + * skew) cannot. + * + * This is not related to whether the transform was originally described + * componentwise. Even a transform that was constructed with a 4x4 may return + * true here if the matrix is a simple affine matrix with no skew. + * + * If this returns true, you may safely call get_hpr() and get_scale() to + * retrieve the components. (You may always safely call get_pos() whether + * this returns true or false.) + */ INLINE bool TransformState:: has_components() const { check_components(); return ((_flags & F_has_components) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::components_given -// Access: Published -// Description: Returns true if the transform was specified -// componentwise, or false if it was specified with a -// general 4x4 matrix. If this is true, the components -// returned by get_pos() and get_scale() will be exactly -// those that were set; otherwise, these functions will -// return computed values. If this is true, the -// rotation may have been set either with a hpr trio or -// with a quaternion; hpr_given() or quat_given() can -// resolve the difference. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform was specified componentwise, or false if it + * was specified with a general 4x4 matrix. If this is true, the components + * returned by get_pos() and get_scale() will be exactly those that were set; + * otherwise, these functions will return computed values. If this is true, + * the rotation may have been set either with a hpr trio or with a quaternion; + * hpr_given() or quat_given() can resolve the difference. + */ INLINE bool TransformState:: components_given() const { return ((_flags & F_components_given) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::hpr_given -// Access: Published -// Description: Returns true if the rotation was specified via a trio -// of Euler angles, false otherwise. If this is true, -// get_hpr() will be exactly as set; otherwise, it will -// return a computed value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the rotation was specified via a trio of Euler angles, + * false otherwise. If this is true, get_hpr() will be exactly as set; + * otherwise, it will return a computed value. + */ INLINE bool TransformState:: hpr_given() const { return ((_flags & F_hpr_given) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::quat_given -// Access: Published -// Description: Returns true if the rotation was specified via a -// quaternion, false otherwise. If this is true, -// get_quat() will be exactly as set; otherwise, it will -// return a computed value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the rotation was specified via a quaternion, false + * otherwise. If this is true, get_quat() will be exactly as set; otherwise, + * it will return a computed value. + */ INLINE bool TransformState:: quat_given() const { return ((_flags & F_quat_given) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_pos -// Access: Published -// Description: Returns true if the transform's pos component can be -// extracted out separately. This is generally always -// true, unless the transform is invalid -// (i.e. is_invalid() returns true). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform's pos component can be extracted out + * separately. This is generally always true, unless the transform is invalid + * (i.e. is_invalid() returns true). + */ INLINE bool TransformState:: has_pos() const { return !is_invalid(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_hpr -// Access: Published -// Description: Returns true if the transform's rotation component -// can be extracted out separately and described as a -// set of Euler angles. This is generally true only -// when has_components() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform's rotation component can be extracted out + * separately and described as a set of Euler angles. This is generally true + * only when has_components() is true. + */ INLINE bool TransformState:: has_hpr() const { return has_components(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_quat -// Access: Published -// Description: Returns true if the transform's rotation component -// can be extracted out separately and described as a -// quaternion. This is generally true only when -// has_components() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform's rotation component can be extracted out + * separately and described as a quaternion. This is generally true only when + * has_components() is true. + */ INLINE bool TransformState:: has_quat() const { return has_components(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_scale -// Access: Published -// Description: Returns true if the transform's scale component -// can be extracted out separately. This is generally -// true only when has_components() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform's scale component can be extracted out + * separately. This is generally true only when has_components() is true. + */ INLINE bool TransformState:: has_scale() const { return has_components(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_identity_scale -// Access: Published -// Description: Returns true if the scale is uniform 1.0, or false if -// the scale has some real value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the scale is uniform 1.0, or false if the scale has some + * real value. + */ INLINE bool TransformState:: has_identity_scale() const { check_components(); return (_flags & F_identity_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_uniform_scale -// Access: Published -// Description: Returns true if the scale is uniform across all three -// axes (and therefore can be expressed as a single -// number), or false if the transform has a different -// scale in different dimensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the scale is uniform across all three axes (and therefore + * can be expressed as a single number), or false if the transform has a + * different scale in different dimensions. + */ INLINE bool TransformState:: has_uniform_scale() const { check_components(); return (_flags & F_uniform_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_shear -// Access: Published -// Description: Returns true if the transform's shear component -// can be extracted out separately. This is generally -// true only when has_components() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform's shear component can be extracted out + * separately. This is generally true only when has_components() is true. + */ INLINE bool TransformState:: has_shear() const { return has_components(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_nonzero_shear -// Access: Published -// Description: Returns true if the shear component is non-zero, -// false if it is zero or if the matrix cannot be -// decomposed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shear component is non-zero, false if it is zero or if + * the matrix cannot be decomposed. + */ INLINE bool TransformState:: has_nonzero_shear() const { check_components(); return (_flags & F_has_nonzero_shear) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::has_mat -// Access: Published -// Description: Returns true if the transform can be described as a -// matrix. This is generally always true, unless -// is_invalid() is true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the transform can be described as a matrix. This is + * generally always true, unless is_invalid() is true. + */ INLINE bool TransformState:: has_mat() const { return !is_invalid(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_pos -// Access: Published -// Description: Returns the pos component of the transform. It is an -// error to call this if has_pos() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pos component of the transform. It is an error to call this if + * has_pos() returned false. + */ INLINE const LPoint3 &TransformState:: get_pos() const { check_components(); @@ -492,13 +380,10 @@ get_pos() const { return _pos; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_hpr -// Access: Published -// Description: Returns the rotation component of the transform as a -// trio of Euler angles. It is an error to call this if -// has_components() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component of the transform as a trio of Euler angles. + * It is an error to call this if has_components() returned false. + */ INLINE const LVecBase3 &TransformState:: get_hpr() const { check_hpr(); @@ -506,20 +391,15 @@ get_hpr() const { return _hpr; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_quat -// Access: Published -// Description: Returns the rotation component of the transform as a -// quaternion. The return value will be normalized if a -// normalized quaternion was given to the constructor -// (or if the quaternion was computed implicitly); it -// will be non-normalized if a non-normalized quaternion -// was given to the constructor. See also -// get_norm_quat(). -// -// It is an error to call this if has_components() -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component of the transform as a quaternion. The + * return value will be normalized if a normalized quaternion was given to the + * constructor (or if the quaternion was computed implicitly); it will be non- + * normalized if a non-normalized quaternion was given to the constructor. + * See also get_norm_quat(). + * + * It is an error to call this if has_components() returned false. + */ INLINE const LQuaternion &TransformState:: get_quat() const { check_quat(); @@ -527,15 +407,12 @@ get_quat() const { return _quat; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_norm_quat -// Access: Published -// Description: Returns the rotation component of the transform as a -// quaternion. Unlike the result of get_quat(), the -// return value of this method is guaranteed to be -// normalized. It is an error to call this if -// has_components() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component of the transform as a quaternion. Unlike + * the result of get_quat(), the return value of this method is guaranteed to + * be normalized. It is an error to call this if has_components() returned + * false. + */ INLINE const LQuaternion &TransformState:: get_norm_quat() const { check_norm_quat(); @@ -543,13 +420,10 @@ get_norm_quat() const { return _norm_quat; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_scale -// Access: Published -// Description: Returns the scale component of the transform. It is an -// error to call this if has_components() returned -// false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale component of the transform. It is an error to call this + * if has_components() returned false. + */ INLINE const LVecBase3 &TransformState:: get_scale() const { check_components(); @@ -557,13 +431,10 @@ get_scale() const { return _scale; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_uniform_scale -// Access: Published -// Description: Returns the scale component of the transform, as a -// single number. It is an error to call this if -// has_uniform_scale() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale component of the transform, as a single number. It is an + * error to call this if has_uniform_scale() returned false. + */ INLINE PN_stdfloat TransformState:: get_uniform_scale() const { check_components(); @@ -571,13 +442,10 @@ get_uniform_scale() const { return _scale[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_shear -// Access: Published -// Description: Returns the shear component of the transform. It is -// an error to call this if has_components() returned -// false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shear component of the transform. It is an error to call this + * if has_components() returned false. + */ INLINE const LVecBase3 &TransformState:: get_shear() const { check_components(); @@ -585,11 +453,9 @@ get_shear() const { return _shear; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_mat -// Access: Published -// Description: Returns the matrix that describes the transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix that describes the transform. + */ INLINE const LMatrix4 &TransformState:: get_mat() const { nassertr(has_mat(), LMatrix4::ident_mat()); @@ -597,13 +463,10 @@ get_mat() const { return _mat; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_pos2d -// Access: Published -// Description: Returns the pos component of the 2-d transform. It -// is an error to call this if has_pos() or is_2d() -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pos component of the 2-d transform. It is an error to call + * this if has_pos() or is_2d() returned false. + */ INLINE LVecBase2 TransformState:: get_pos2d() const { check_components(); @@ -611,14 +474,11 @@ get_pos2d() const { return LVecBase2(_pos[0], _pos[1]); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_rotate2d -// Access: Published -// Description: Returns the rotation component of the 2-d transform -// as an angle in degrees clockwise about the origin. -// It is an error to call this if has_components() or -// is_2d() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component of the 2-d transform as an angle in degrees + * clockwise about the origin. It is an error to call this if + * has_components() or is_2d() returned false. + */ INLINE PN_stdfloat TransformState:: get_rotate2d() const { check_hpr(); @@ -636,13 +496,10 @@ get_rotate2d() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_scale2d -// Access: Published -// Description: Returns the scale component of the 2-d transform. It -// is an error to call this if has_components() or -// is_2d() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale component of the 2-d transform. It is an error to call + * this if has_components() or is_2d() returned false. + */ INLINE LVecBase2 TransformState:: get_scale2d() const { check_components(); @@ -650,13 +507,10 @@ get_scale2d() const { return LVecBase2(_scale[0], _scale[1]); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_shear2d -// Access: Published -// Description: Returns the shear component of the 2-d transform. It -// is an error to call this if has_components() or -// is_2d() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shear component of the 2-d transform. It is an error to call + * this if has_components() or is_2d() returned false. + */ INLINE PN_stdfloat TransformState:: get_shear2d() const { check_components(); @@ -664,13 +518,10 @@ get_shear2d() const { return _shear[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_mat3 -// Access: Published -// Description: Returns the 3x3 matrix that describes the 2-d -// transform. It is an error to call this if is_2d() -// returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3x3 matrix that describes the 2-d transform. It is an error to + * call this if is_2d() returned false. + */ INLINE LMatrix3 TransformState:: get_mat3() const { nassertr(has_mat() && is_2d(), LMatrix3::ident_mat()); @@ -680,44 +531,34 @@ get_mat3() const { _mat(3, 0), _mat(3, 1), _mat(3, 3)); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_inverse -// Access: Published -// Description: Returns the inverse of this transform. If you are -// going to immediately compose this result with another -// TransformState, it is faster to do it in one -// operation with invert_compose(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of this transform. If you are going to immediately + * compose this result with another TransformState, it is faster to do it in + * one operation with invert_compose(). + */ INLINE CPT(TransformState) TransformState:: get_inverse() const { return invert_compose(TransformState::make_identity()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_unique -// Access: Published -// Description: Returns the pointer to the unique TransformState in -// the cache that is equivalent to this one. This may -// be the same pointer as this object, or it may be a -// different pointer; but it will be an equivalent -// object, and it will be a shared pointer. This may be -// called from time to time to improve cache benefits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the unique TransformState in the cache that is + * equivalent to this one. This may be the same pointer as this object, or it + * may be a different pointer; but it will be an equivalent object, and it + * will be a shared pointer. This may be called from time to time to improve + * cache benefits. + */ INLINE CPT(TransformState) TransformState:: get_unique() const { return return_unique((TransformState *)this); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_geom_rendering -// Access: Published -// Description: Returns the union of the Geom::GeomRendering bits -// that will be required once this TransformState is -// applied to a geom which includes the indicated -// geom_rendering bits. The RenderState's -// get_geom_rendering() should already have been -// applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the Geom::GeomRendering bits that will be required + * once this TransformState is applied to a geom which includes the indicated + * geom_rendering bits. The RenderState's get_geom_rendering() should already + * have been applied. + */ INLINE int TransformState:: get_geom_rendering(int geom_rendering) const { if ((geom_rendering & GeomEnums::GR_point_perspective) != 0) { @@ -729,11 +570,9 @@ get_geom_rendering(int geom_rendering) const { return geom_rendering; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::cache_ref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE void TransformState:: cache_ref() const { #ifdef DO_PSTATS @@ -745,11 +584,9 @@ cache_ref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::cache_unref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE bool TransformState:: cache_unref() const { #ifdef DO_PSTATS @@ -762,11 +599,9 @@ cache_unref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::node_ref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE void TransformState:: node_ref() const { #ifdef DO_PSTATS @@ -778,11 +613,9 @@ node_ref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::node_unref -// Access: Published -// Description: Overrides this method to update PStats appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Overrides this method to update PStats appropriately. + */ INLINE bool TransformState:: node_unref() const { #ifdef DO_PSTATS @@ -795,65 +628,53 @@ node_unref() const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_composition_cache_num_entries -// Access: Published -// Description: Returns the number of entries in the composition -// cache for this TransformState. This is the number of -// other TransformStates whose composition with this one -// has been cached. This number is not useful for any -// practical reason other than performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the composition cache for this + * TransformState. This is the number of other TransformStates whose + * composition with this one has been cached. This number is not useful for + * any practical reason other than performance analysis. + */ INLINE size_t TransformState:: get_composition_cache_num_entries() const { LightReMutexHolder holder(*_states_lock); return _composition_cache.get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_invert_composition_cache_num_entries -// Access: Published -// Description: Returns the number of entries in the -// invert_composition cache for this TransformState. -// This is similar to the composition cache, but it -// records cache entries for the invert_compose() -// operation. See get_composition_cache_num_entries(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of entries in the invert_composition cache for this + * TransformState. This is similar to the composition cache, but it records + * cache entries for the invert_compose() operation. See + * get_composition_cache_num_entries(). + */ INLINE size_t TransformState:: get_invert_composition_cache_num_entries() const { LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_composition_cache_size -// Access: Published -// Description: Returns the number of slots in the composition -// cache for this TransformState. You may use this as -// an upper bound when walking through all of the -// composition cache results via -// get_composition_cache_source() or result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of slots in the composition cache for this + * TransformState. You may use this as an upper bound when walking through + * all of the composition cache results via get_composition_cache_source() or + * result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE size_t TransformState:: get_composition_cache_size() const { LightReMutexHolder holder(*_states_lock); return _composition_cache.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_composition_cache_source -// Access: Published -// Description: Returns the source TransformState of the nth element -// in the composition cache. Returns NULL if there -// doesn't happen to be an entry in the nth element. -// See get_composition_cache_result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source TransformState of the nth element in the composition + * cache. Returns NULL if there doesn't happen to be an entry in the nth + * element. See get_composition_cache_result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const TransformState *TransformState:: get_composition_cache_source(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -863,20 +684,17 @@ get_composition_cache_source(size_t n) const { return _composition_cache.get_key(n); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_composition_cache_result -// Access: Published -// Description: Returns the result TransformState of the nth element -// in the composition cache. Returns NULL if there -// doesn't happen to be an entry in the nth element. -// -// In general, -// a->compose(a->get_composition_cache_source(n)) == -// a->get_composition_cache_result(n). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the result TransformState of the nth element in the composition + * cache. Returns NULL if there doesn't happen to be an entry in the nth + * element. + * + * In general, a->compose(a->get_composition_cache_source(n)) == + * a->get_composition_cache_result(n). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const TransformState *TransformState:: get_composition_cache_result(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -886,35 +704,29 @@ get_composition_cache_result(size_t n) const { return _composition_cache.get_data(n)._result; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_invert_composition_cache_size -// Access: Published -// Description: Returns the number of slots in the composition -// cache for this TransformState. You may use this as -// an upper bound when walking through all of the -// composition cache results via -// get_invert_composition_cache_source() or result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of slots in the composition cache for this + * TransformState. You may use this as an upper bound when walking through + * all of the composition cache results via + * get_invert_composition_cache_source() or result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE size_t TransformState:: get_invert_composition_cache_size() const { LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_size(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_invert_composition_cache_source -// Access: Published -// Description: Returns the source TransformState of the nth element -// in the invert composition cache. Returns NULL if -// there doesn't happen to be an entry in the nth -// element. See get_invert_composition_cache_result(). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source TransformState of the nth element in the invert + * composition cache. Returns NULL if there doesn't happen to be an entry in + * the nth element. See get_invert_composition_cache_result(). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const TransformState *TransformState:: get_invert_composition_cache_source(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -924,21 +736,17 @@ get_invert_composition_cache_source(size_t n) const { return _invert_composition_cache.get_key(n); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_invert_composition_cache_result -// Access: Published -// Description: Returns the result TransformState of the nth element -// in the invert composition cache. Returns NULL if -// there doesn't happen to be an entry in the nth -// element. -// -// In general, -// a->invert_compose(a->get_invert_composition_cache_source(n)) -// == a->get_invert_composition_cache_result(n). -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the result TransformState of the nth element in the invert + * composition cache. Returns NULL if there doesn't happen to be an entry in + * the nth element. + * + * In general, a->invert_compose(a->get_invert_composition_cache_source(n)) == + * a->get_invert_composition_cache_result(n). + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ INLINE const TransformState *TransformState:: get_invert_composition_cache_result(size_t n) const { LightReMutexHolder holder(*_states_lock); @@ -948,200 +756,167 @@ get_invert_composition_cache_result(size_t n) const { return _invert_composition_cache.get_data(n)._result; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::flush_level -// Access: Public, Static -// Description: Flushes the PStatCollectors used during traversal. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the PStatCollectors used during traversal. + */ INLINE void TransformState:: flush_level() { _node_counter.flush_level(); _cache_counter.flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_node_unref -// Access: Private -// Description: Reimplements NodeReferenceCount::node_unref(). We do -// this because we have a non-virtual unref() method. -//////////////////////////////////////////////////////////////////// +/** + * Reimplements NodeReferenceCount::node_unref(). We do this because we have + * a non-virtual unref() method. + */ INLINE bool TransformState:: do_node_unref() const { node_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_cache_unref -// Access: Private -// Description: Reimplements -// CachedTypedWritableReferenceCount::cache_unref(). We -// do this because we have a non-virtual unref() method. -//////////////////////////////////////////////////////////////////// +/** + * Reimplements CachedTypedWritableReferenceCount::cache_unref(). We do this + * because we have a non-virtual unref() method. + */ INLINE bool TransformState:: do_cache_unref() const { cache_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_hash -// Access: Private -// Description: Ensures that we know the hash value. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the hash value. + */ INLINE void TransformState:: check_hash() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_hash_known) == 0) { ((TransformState *)this)->calc_hash(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_singular -// Access: Private -// Description: Ensures that we know whether the matrix is singular. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know whether the matrix is singular. + */ INLINE void TransformState:: check_singular() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_singular_known) == 0) { ((TransformState *)this)->calc_singular(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_components -// Access: Private -// Description: Ensures that we know the components of the transform -// (or that we know they cannot be derived). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the components of the transform (or that we know they + * cannot be derived). + */ INLINE void TransformState:: check_components() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_components_known) == 0) { ((TransformState *)this)->calc_components(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_hpr -// Access: Private -// Description: Ensures that we know the hpr of the transform -// (or that we know they cannot be derived). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the hpr of the transform (or that we know they cannot + * be derived). + */ INLINE void TransformState:: check_hpr() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_hpr_known) == 0) { ((TransformState *)this)->calc_hpr(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_quat -// Access: Private -// Description: Ensures that we know the quat of the transform -// (or that we know they cannot be derived). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the quat of the transform (or that we know they cannot + * be derived). + */ INLINE void TransformState:: check_quat() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_quat_known) == 0) { ((TransformState *)this)->calc_quat(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_norm_quat -// Access: Private -// Description: Ensures that we know the normalized quat of the transform -// (or that we know they cannot be derived). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the normalized quat of the transform (or that we know + * they cannot be derived). + */ INLINE void TransformState:: check_norm_quat() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_norm_quat_known) == 0) { ((TransformState *)this)->calc_norm_quat(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_mat -// Access: Private -// Description: Ensures that we know the overall matrix. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that we know the overall matrix. + */ INLINE void TransformState:: check_mat() const { - // This pretends to be a const function, even though it's not, - // because it only updates a transparent cache value. + // This pretends to be a const function, even though it's not, because it + // only updates a transparent cache value. if ((_flags & F_mat_known) == 0) { ((TransformState *)this)->calc_mat(); } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_hash -// Access: Private -// Description: Computes the hash value. -//////////////////////////////////////////////////////////////////// +/** + * Computes the hash value. + */ INLINE void TransformState:: calc_hash() { LightMutexHolder holder(_lock); do_calc_hash(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_components -// Access: Private -// Description: Derives the components from the matrix, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Derives the components from the matrix, if possible. + */ INLINE void TransformState:: calc_components() { LightMutexHolder holder(_lock); do_calc_components(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_hpr -// Access: Private -// Description: Derives the hpr, from the matrix if necessary, or -// from the quat. -//////////////////////////////////////////////////////////////////// +/** + * Derives the hpr, from the matrix if necessary, or from the quat. + */ INLINE void TransformState:: calc_hpr() { LightMutexHolder holder(_lock); do_calc_hpr(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_mat -// Access: Private -// Description: Computes the matrix from the components. -//////////////////////////////////////////////////////////////////// +/** + * Computes the matrix from the components. + */ INLINE void TransformState:: calc_mat() { LightMutexHolder holder(_lock); do_calc_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_uniform_scale -// Access: Private -// Description: Should be called immediately after _scale (and -// F_has_components) is set, this checks for a -// identity and/or uniform scale (as well as a non-zero -// shear) and sets the bit appropriately. -// -// It does not matter whether the lock is or is not held -// before calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Should be called immediately after _scale (and F_has_components) is set, + * this checks for a identity and/or uniform scale (as well as a non-zero + * shear) and sets the bit appropriately. + * + * It does not matter whether the lock is or is not held before calling this + * method. + */ INLINE void TransformState:: check_uniform_scale() { if (IS_NEARLY_EQUAL(_scale[0], _scale[1]) && @@ -1157,17 +932,14 @@ check_uniform_scale() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::check_uniform_scale2d -// Access: Private -// Description: Should be called immediately after _scale (and -// F_has_components) is set, for a known 2-d scale, this -// checks for a identity and/or uniform scale (as well -// as a non-zero shear) and sets the bit appropriately. -// -// It does not matter whether the lock is or is not held -// before calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Should be called immediately after _scale (and F_has_components) is set, + * for a known 2-d scale, this checks for a identity and/or uniform scale (as + * well as a non-zero shear) and sets the bit appropriately. + * + * It does not matter whether the lock is or is not held before calling this + * method. + */ INLINE void TransformState:: check_uniform_scale2d() { if (IS_NEARLY_EQUAL(_scale[0], _scale[1])) { @@ -1183,15 +955,11 @@ check_uniform_scale2d() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_destructing -// Access: Private -// Description: This function should only be called from the -// destructor; it indicates that this TransformState -// object is beginning destruction. It is only used as -// a sanity check, and is only meaningful when NDEBUG is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * This function should only be called from the destructor; it indicates that + * this TransformState object is beginning destruction. It is only used as a + * sanity check, and is only meaningful when NDEBUG is not defined. + */ INLINE void TransformState:: set_destructing() { #ifndef NDEBUG @@ -1199,15 +967,11 @@ set_destructing() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::is_destructing -// Access: Private -// Description: Returns true if the TransformState object is -// currently within its destructor -// (i.e. set_destructing() has been called). This is -// only used as a sanity check, and is only meaningful -// when NDEBUG is not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the TransformState object is currently within its + * destructor (i.e. set_destructing() has been called). This is only used as + * a sanity check, and is only meaningful when NDEBUG is not defined. + */ INLINE bool TransformState:: is_destructing() const { #ifndef NDEBUG @@ -1217,12 +981,10 @@ is_destructing() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::consider_update_pstats -// Access: Private -// Description: Calls update_pstats() if the state of the referenced -// bits has changed from the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_pstats() if the state of the referenced bits has changed from + * the indicated value. + */ INLINE void TransformState:: consider_update_pstats(int old_referenced_bits) const { #ifdef DO_PSTATS @@ -1233,31 +995,25 @@ consider_update_pstats(int old_referenced_bits) const { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Composition::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformState::Composition:: Composition() { } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Composition::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformState::Composition:: Composition(const TransformState::Composition ©) : _result(copy._result) { } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::CompositionCycleDescEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TransformState::CompositionCycleDescEntry:: CompositionCycleDescEntry(const TransformState *obj, const TransformState *result, diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 88d5092b77..4d1aade0ec 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -1,16 +1,15 @@ -// Filename: transformState.cxx -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformState.cxx + * @author drose + * @date 2002-02-25 + */ #include "transformState.h" #include "compose_matrix.h" @@ -49,13 +48,11 @@ CacheStats TransformState::_cache_stats; TypeHandle TransformState::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Constructor -// Access: Protected -// Description: Actually, this could be a private constructor, since -// no one inherits from TransformState, but gcc gives us a -// spurious warning if all constructors are private. -//////////////////////////////////////////////////////////////////// +/** + * Actually, this could be a private constructor, since no one inherits from + * TransformState, but gcc gives us a spurious warning if all constructors are + * private. + */ TransformState:: TransformState() : _lock("TransformState") { if (_states == (States *)NULL) { @@ -67,32 +64,26 @@ TransformState() : _lock("TransformState") { _cache_stats.add_num_states(1); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Copy Constructor -// Access: Private -// Description: TransformStates are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * TransformStates are not meant to be copied. + */ TransformState:: TransformState(const TransformState &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Copy Assignment Operator -// Access: Private -// Description: TransformStates are not meant to be copied. -//////////////////////////////////////////////////////////////////// +/** + * TransformStates are not meant to be copied. + */ void TransformState:: operator = (const TransformState &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::Destructor -// Access: Public, Virtual -// Description: The destructor is responsible for removing the -// TransformState from the global set if it is there. -//////////////////////////////////////////////////////////////////// +/** + * The destructor is responsible for removing the TransformState from the + * global set if it is there. + */ TransformState:: ~TransformState() { // We'd better not call the destructor twice on a particular object. @@ -111,29 +102,23 @@ TransformState:: nassertv(_saved_entry == -1); nassertv(_composition_cache.is_empty() && _invert_composition_cache.is_empty()); - // If this was true at the beginning of the destructor, but is no - // longer true now, probably we've been double-deleted. + // If this was true at the beginning of the destructor, but is no longer + // true now, probably we've been double-deleted. nassertv(get_ref_count() == 0); _cache_stats.add_num_states(-1); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::compare_to -// Access: Published -// Description: Provides an arbitrary ordering among all unique -// TransformStates, so we can store the essentially -// different ones in a big set and throw away the rest. -// -// Note that if this returns 0, it doesn't necessarily -// imply that operator == returns true; it uses a very -// slightly different comparison threshold. -// -// If uniquify_matrix is true, then matrix-defined -// TransformStates are also uniqified. If -// uniquify_matrix is false, then only component-defined -// TransformStates are uniquified, which is less -// expensive. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary ordering among all unique TransformStates, so we can + * store the essentially different ones in a big set and throw away the rest. + * + * Note that if this returns 0, it doesn't necessarily imply that operator == + * returns true; it uses a very slightly different comparison threshold. + * + * If uniquify_matrix is true, then matrix-defined TransformStates are also + * uniqified. If uniquify_matrix is false, then only component-defined + * TransformStates are uniquified, which is less expensive. + */ int TransformState:: compare_to(const TransformState &other, bool uniquify_matrix) const { static const int significant_flags = @@ -146,8 +131,8 @@ compare_to(const TransformState &other, bool uniquify_matrix) const { } if ((_flags & (F_is_invalid | F_is_identity)) != 0) { - // All invalid transforms are equivalent to each other, and all - // identity transforms are equivalent to each other. + // All invalid transforms are equivalent to each other, and all identity + // transforms are equivalent to each other. return 0; } @@ -182,8 +167,7 @@ compare_to(const TransformState &other, bool uniquify_matrix) const { // Otherwise, compare the matrices . . . if (uniquify_matrix) { - // . . . but only if the user thinks that's a worthwhile - // comparison. + // . . . but only if the user thinks that's a worthwhile comparison. return get_mat().compare_to(other.get_mat()); } else { @@ -195,20 +179,15 @@ compare_to(const TransformState &other, bool uniquify_matrix) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::operator == -// Access: Published -// Description: Tests equivalence between two transform states. -// We use this instead of compare_to since this is -// faster, and we don't need an ordering between -// TransformStates because we use a hash map. -// -// If uniquify_matrix is true, then matrix-defined -// TransformStates are also uniqified. If -// uniquify_matrix is false, then only component-defined -// TransformStates are uniquified, which is less -// expensive. -//////////////////////////////////////////////////////////////////// +/** + * Tests equivalence between two transform states. We use this instead of + * compare_to since this is faster, and we don't need an ordering between + * TransformStates because we use a hash map. + * + * If uniquify_matrix is true, then matrix-defined TransformStates are also + * uniqified. If uniquify_matrix is false, then only component-defined + * TransformStates are uniquified, which is less expensive. + */ bool TransformState:: operator == (const TransformState &other) const { static const int significant_flags = @@ -221,8 +200,8 @@ operator == (const TransformState &other) const { } if ((_flags & (F_is_invalid | F_is_identity)) != 0) { - // All invalid transforms are equivalent to each other, and all - // identity transforms are equivalent to each other. + // All invalid transforms are equivalent to each other, and all identity + // transforms are equivalent to each other. return true; } @@ -252,8 +231,7 @@ operator == (const TransformState &other) const { // Otherwise, compare the matrices . . . if (_uniquify_matrix) { - // . . . but only if the user thinks that's a worthwhile - // comparison. + // . . . but only if the user thinks that's a worthwhile comparison. return get_mat().almost_equal(other.get_mat()); } else { @@ -262,15 +240,13 @@ operator == (const TransformState &other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_identity -// Access: Published, Static -// Description: Constructs an identity transform. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an identity transform. + */ CPT(TransformState) TransformState:: make_identity() { - // The identity state is asked for so often, we make it a special case - // and store a pointer forever once we find it the first time. + // The identity state is asked for so often, we make it a special case and + // store a pointer forever once we find it the first time. if (_identity_state == (TransformState *)NULL) { TransformState *state = new TransformState; _identity_state = return_unique(state); @@ -279,12 +255,10 @@ make_identity() { return _identity_state; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_invalid -// Access: Published, Static -// Description: Constructs an invalid transform; for instance, the -// result of inverting a singular matrix. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an invalid transform; for instance, the result of inverting a + * singular matrix. + */ CPT(TransformState) TransformState:: make_invalid() { if (_invalid_state == (TransformState *)NULL) { @@ -296,12 +270,9 @@ make_invalid() { return _invalid_state; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_hpr_scale_shear -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ CPT(TransformState) TransformState:: make_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale, const LVecBase3 &shear) { @@ -324,12 +295,9 @@ make_pos_hpr_scale_shear(const LVecBase3 &pos, const LVecBase3 &hpr, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_quat_scale_shear -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified components. + */ CPT(TransformState) TransformState:: make_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, const LVecBase3 &scale, const LVecBase3 &shear) { @@ -352,12 +320,9 @@ make_pos_quat_scale_shear(const LVecBase3 &pos, const LQuaternion &quat, return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_mat -// Access: Published, Static -// Description: Makes a new TransformState with the specified -// transformation matrix. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new TransformState with the specified transformation matrix. + */ CPT(TransformState) TransformState:: make_mat(const LMatrix4 &mat) { nassertr(!mat.is_nan(), make_invalid()); @@ -372,12 +337,9 @@ make_mat(const LMatrix4 &mat) { return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_pos_rotate_scale_shear2d -// Access: Published, Static -// Description: Makes a new two-dimensional TransformState with the -// specified components. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new two-dimensional TransformState with the specified components. + */ CPT(TransformState) TransformState:: make_pos_rotate_scale_shear2d(const LVecBase2 &pos, PN_stdfloat rotate, const LVecBase2 &scale, @@ -416,12 +378,10 @@ make_pos_rotate_scale_shear2d(const LVecBase2 &pos, PN_stdfloat rotate, } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_mat3 -// Access: Published, Static -// Description: Makes a new two-dimensional TransformState with the -// specified 3x3 transformation matrix. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new two-dimensional TransformState with the specified 3x3 + * transformation matrix. + */ CPT(TransformState) TransformState:: make_mat3(const LMatrix3 &mat) { nassertr(!mat.is_nan(), make_invalid()); @@ -439,20 +399,16 @@ make_mat3(const LMatrix3 &mat) { return return_new(state); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_pos -// Access: Published -// Description: Returns a new TransformState object that represents the -// original TransformState with its pos component -// replaced with the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original + * TransformState with its pos component replaced with the indicated value. + */ CPT(TransformState) TransformState:: set_pos(const LVecBase3 &pos) const { nassertr(!pos.is_nan(), this); nassertr(!is_invalid(), this); if (is_identity() || components_given()) { - // If we started with a componentwise transform, we keep it that - // way. + // If we started with a componentwise transform, we keep it that way. if (quat_given()) { return make_pos_quat_scale_shear(pos, get_quat(), get_scale(), get_shear()); } else { @@ -467,57 +423,50 @@ set_pos(const LVecBase3 &pos) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_hpr -// Access: Published -// Description: Returns a new TransformState object that represents the -// original TransformState with its rotation component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original + * TransformState with its rotation component replaced with the indicated + * value, if possible. + */ CPT(TransformState) TransformState:: set_hpr(const LVecBase3 &hpr) const { nassertr(!hpr.is_nan(), this); nassertr(!is_invalid(), this); - // nassertr(has_components(), this); + // nassertr(has_components(), this); return make_pos_hpr_scale_shear(get_pos(), hpr, get_scale(), get_shear()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_quat -// Access: Published -// Description: Returns a new TransformState object that represents the -// original TransformState with its rotation component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original + * TransformState with its rotation component replaced with the indicated + * value, if possible. + */ CPT(TransformState) TransformState:: set_quat(const LQuaternion &quat) const { nassertr(!quat.is_nan(), this); nassertr(!is_invalid(), this); - // nassertr(has_components(), this); + // nassertr(has_components(), this); return make_pos_quat_scale_shear(get_pos(), quat, get_scale(), get_shear()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_scale -// Access: Published -// Description: Returns a new TransformState object that represents the -// original TransformState with its scale component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original + * TransformState with its scale component replaced with the indicated value, + * if possible. + */ CPT(TransformState) TransformState:: set_scale(const LVecBase3 &scale) const { nassertr(!scale.is_nan(), this); nassertr(!is_invalid(), this); if (is_2d() && scale[0] == scale[1] && scale[1] == scale[2]) { - // Don't inflate from 2-d to 3-d just because we got a uniform - // scale. + // Don't inflate from 2-d to 3-d just because we got a uniform scale. return make_pos_rotate_scale_shear2d(get_pos2d(), get_rotate2d(), LVecBase2(scale[0], scale[0]), get_shear2d()); } - // nassertr(has_components(), this); + // nassertr(has_components(), this); if (quat_given()) { return make_pos_quat_scale_shear(get_pos(), get_quat(), scale, get_shear()); } else { @@ -525,18 +474,16 @@ set_scale(const LVecBase3 &scale) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_shear -// Access: Published -// Description: Returns a new TransformState object that represents the -// original TransformState with its shear component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original + * TransformState with its shear component replaced with the indicated value, + * if possible. + */ CPT(TransformState) TransformState:: set_shear(const LVecBase3 &shear) const { nassertr(!shear.is_nan(), this); nassertr(!is_invalid(), this); - // nassertr(has_components(), this); + // nassertr(has_components(), this); if (quat_given()) { return make_pos_quat_scale_shear(get_pos(), get_quat(), get_scale(), shear); } else { @@ -544,13 +491,10 @@ set_shear(const LVecBase3 &shear) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_pos2d -// Access: Published -// Description: Returns a new TransformState object that represents the -// original 2-d TransformState with its pos component -// replaced with the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original 2-d + * TransformState with its pos component replaced with the indicated value. + */ CPT(TransformState) TransformState:: set_pos2d(const LVecBase2 &pos) const { nassertr(!pos.is_nan(), this); @@ -560,8 +504,7 @@ set_pos2d(const LVecBase2 &pos) const { } if (is_identity() || components_given()) { - // If we started with a componentwise transform, we keep it that - // way. + // If we started with a componentwise transform, we keep it that way. return make_pos_rotate_scale_shear2d(pos, get_rotate2d(), get_scale2d(), get_shear2d()); @@ -573,13 +516,11 @@ set_pos2d(const LVecBase2 &pos) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_rotate2d -// Access: Published -// Description: Returns a new TransformState object that represents the -// original 2-d TransformState with its rotation component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original 2-d + * TransformState with its rotation component replaced with the indicated + * value, if possible. + */ CPT(TransformState) TransformState:: set_rotate2d(PN_stdfloat rotate) const { nassertr(!cnan(rotate), this); @@ -603,13 +544,11 @@ set_rotate2d(PN_stdfloat rotate) const { get_shear2d()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_scale2d -// Access: Published -// Description: Returns a new TransformState object that represents the -// original 2-d TransformState with its scale component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original 2-d + * TransformState with its scale component replaced with the indicated value, + * if possible. + */ CPT(TransformState) TransformState:: set_scale2d(const LVecBase2 &scale) const { nassertr(!scale.is_nan(), this); @@ -622,13 +561,11 @@ set_scale2d(const LVecBase2 &scale) const { scale, get_shear2d()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::set_shear2d -// Access: Published -// Description: Returns a new TransformState object that represents the -// original 2-d TransformState with its shear component -// replaced with the indicated value, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the original 2-d + * TransformState with its shear component replaced with the indicated value, + * if possible. + */ CPT(TransformState) TransformState:: set_shear2d(PN_stdfloat shear) const { nassertr(!cnan(shear), this); @@ -640,19 +577,15 @@ set_shear2d(PN_stdfloat shear) const { get_scale2d(), shear); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::compose -// Access: Published -// Description: Returns a new TransformState object that represents the -// composition of this state with the other state. -// -// The result of this operation is cached, and will be -// retained as long as both this TransformState object and -// the other TransformState object continue to exist. -// Should one of them destruct, the cached entry will be -// removed, and its pointer will be allowed to destruct -// as well. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the composition of this + * state with the other state. + * + * The result of this operation is cached, and will be retained as long as + * both this TransformState object and the other TransformState object + * continue to exist. Should one of them destruct, the cached entry will be + * removed, and its pointer will be allowed to destruct as well. + */ CPT(TransformState) TransformState:: compose(const TransformState *other) const { // We handle identity as a trivial special case. @@ -694,32 +627,28 @@ compose(const TransformState *other) const { return result; } - // Not in the cache. Compute a new result. It's important that we - // don't hold the lock while we do this, or we lose the benefit of + // Not in the cache. Compute a new result. It's important that we don't + // hold the lock while we do this, or we lose the benefit of // parallelization. result = do_compose(other); - // It's OK to cast away the constness of this pointer, because the - // cache is a transparent property of the class. + // It's OK to cast away the constness of this pointer, because the cache is + // a transparent property of the class. return ((TransformState *)this)->store_compose(other, result); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::invert_compose -// Access: Published -// Description: Returns a new TransformState object that represents the -// composition of this state's inverse with the other -// state. -// -// This is similar to compose(), but is particularly -// useful for computing the relative state of a node as -// viewed from some other node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new TransformState object that represents the composition of this + * state's inverse with the other state. + * + * This is similar to compose(), but is particularly useful for computing the + * relative state of a node as viewed from some other node. + */ CPT(TransformState) TransformState:: invert_compose(const TransformState *other) const { - // This method isn't strictly const, because it updates the cache, - // but we pretend that it is because it's only a cache which is - // transparent to the rest of the interface. + // This method isn't strictly const, because it updates the cache, but we + // pretend that it is because it's only a cache which is transparent to the + // rest of the interface. // We handle identity as a trivial special case. if (is_identity()) { @@ -765,51 +694,46 @@ invert_compose(const TransformState *other) const { return result; } - // Not in the cache. Compute a new result. It's important that we - // don't hold the lock while we do this, or we lose the benefit of + // Not in the cache. Compute a new result. It's important that we don't + // hold the lock while we do this, or we lose the benefit of // parallelization. result = do_invert_compose(other); - // It's OK to cast away the constness of this pointer, because the - // cache is a transparent property of the class. + // It's OK to cast away the constness of this pointer, because the cache is + // a transparent property of the class. return ((TransformState *)this)->store_invert_compose(other, result); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::unref -// Access: Published, Virtual -// Description: This method overrides ReferenceCount::unref() to -// check whether the remaining reference count is -// entirely in the cache, and if so, it checks for and -// breaks a cycle in the cache involving this object. -// This is designed to prevent leaks from cyclical -// references within the cache. -//////////////////////////////////////////////////////////////////// +/** + * This method overrides ReferenceCount::unref() to check whether the + * remaining reference count is entirely in the cache, and if so, it checks + * for and breaks a cycle in the cache involving this object. This is + * designed to prevent leaks from cyclical references within the cache. + */ bool TransformState:: unref() const { if (!transform_cache || garbage_collect_states) { - // If we're not using the cache at all, or if we're relying on - // garbage collection, just allow the pointer to unref normally. + // If we're not using the cache at all, or if we're relying on garbage + // collection, just allow the pointer to unref normally. return ReferenceCount::unref(); } - // Here is the normal refcounting case, with a normal cache, and - // without garbage collection in effect. In this case we will pull - // the object out of the cache when its reference count goes to 0. + // Here is the normal refcounting case, with a normal cache, and without + // garbage collection in effect. In this case we will pull the object out + // of the cache when its reference count goes to 0. - // We always have to grab the lock, since we will definitely need to - // be holding it if we happen to drop the reference count to 0. - // Having to grab the lock at every call to unref() is a big - // limiting factor on parallelization. + // We always have to grab the lock, since we will definitely need to be + // holding it if we happen to drop the reference count to 0. Having to grab + // the lock at every call to unref() is a big limiting factor on + // parallelization. LightReMutexHolder holder(*_states_lock); if (auto_break_cycles && uniquify_transforms) { if (get_cache_ref_count() > 0 && get_ref_count() == get_cache_ref_count() + 1) { - // If we are about to remove the one reference that is not in the - // cache, leaving only references in the cache, then we need to - // check for a cycle involving this TransformState and break it if - // it exists. + // If we are about to remove the one reference that is not in the cache, + // leaving only references in the cache, then we need to check for a + // cycle involving this TransformState and break it if it exists. ((TransformState *)this)->detect_and_break_cycles(); } } @@ -819,22 +743,19 @@ unref() const { return true; } - // The reference count has just reached zero. Make sure the object - // is removed from the global object pool, before anyone else finds - // it and tries to ref it. + // The reference count has just reached zero. Make sure the object is + // removed from the global object pool, before anyone else finds it and + // tries to ref it. ((TransformState *)this)->release_new(); ((TransformState *)this)->remove_cache_pointers(); return false; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::validate_composition_cache -// Access: Published -// Description: Returns true if the composition cache and invert -// composition cache for this particular TransformState -// are self-consistent and valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the composition cache and invert composition cache for this + * particular TransformState are self-consistent and valid, false otherwise. + */ bool TransformState:: validate_composition_cache() const { LightReMutexHolder holder(*_states_lock); @@ -846,8 +767,8 @@ validate_composition_cache() const { } const TransformState *source = _composition_cache.get_key(i); if (source != (TransformState *)NULL) { - // Check that the source also has a pointer back to this one. We - // always add entries to the composition cache in pairs. + // Check that the source also has a pointer back to this one. We always + // add entries to the composition cache in pairs. int ri = source->_composition_cache.find(this); if (ri == -1) { // Failure! There is no back-pointer. @@ -869,8 +790,8 @@ validate_composition_cache() const { } const TransformState *source = _invert_composition_cache.get_key(i); if (source != (TransformState *)NULL) { - // Check that the source also has a pointer back to this one. We - // always add entries to the composition cache in pairs. + // Check that the source also has a pointer back to this one. We always + // add entries to the composition cache in pairs. int ri = source->_invert_composition_cache.find(this); if (ri == -1) { // Failure! There is no back-pointer. @@ -888,11 +809,9 @@ validate_composition_cache() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformState:: output(ostream &out) const { out << "T:"; @@ -906,16 +825,14 @@ output(ostream &out) const { bool output_hpr = !get_hpr().almost_equal(LVecBase3(0.0f, 0.0f, 0.0f)); if (!components_given()) { - // A leading "m" indicates the transform was described as a full - // matrix, and we are decomposing it for the benefit of the - // user. + // A leading "m" indicates the transform was described as a full matrix, + // and we are decomposing it for the benefit of the user. out << "m"; } else if (output_hpr && quat_given()) { - // A leading "q" indicates that the pos, scale, and shear are - // exactly as specified, but the rotation was described as a - // quaternion, and we are decomposing that to hpr for the - // benefit of the user. + // A leading "q" indicates that the pos, scale, and shear are exactly as + // specified, but the rotation was described as a quaternion, and we are + // decomposing that to hpr for the benefit of the user. out << "q"; } @@ -980,37 +897,29 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransformState:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::write_composition_cache -// Access: Published -// Description: Writes a brief description of the composition cache -// and invert composition cache to the indicated -// ostream. This is not useful except for performance -// analysis, to examine the cache structure. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the composition cache and invert composition + * cache to the indicated ostream. This is not useful except for performance + * analysis, to examine the cache structure. + */ void TransformState:: write_composition_cache(ostream &out, int indent_level) const { indent(out, indent_level + 2) << _composition_cache << "\n"; indent(out, indent_level + 2) << _invert_composition_cache << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_num_states -// Access: Published, Static -// Description: Returns the total number of unique TransformState -// objects allocated in the world. This will go up and -// down during normal operations. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of unique TransformState objects allocated in the + * world. This will go up and down during normal operations. + */ int TransformState:: get_num_states() { if (_states == (States *)NULL) { @@ -1020,24 +929,19 @@ get_num_states() { return _states->get_num_entries(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::get_num_unused_states -// Access: Published, Static -// Description: Returns the total number of TransformState objects that -// have been allocated but have no references outside of -// the internal TransformState cache. -// -// A nonzero return value is not necessarily indicative -// of leaked references; it is normal for two -// TransformState objects, both of which have references -// held outside the cache, to have the result of their -// composition stored within the cache. This result -// will be retained within the cache until one of the -// base TransformStates is released. -// -// Use list_cycles() to get an idea of the number of -// actual "leaked" TransformState objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of TransformState objects that have been allocated + * but have no references outside of the internal TransformState cache. + * + * A nonzero return value is not necessarily indicative of leaked references; + * it is normal for two TransformState objects, both of which have references + * held outside the cache, to have the result of their composition stored + * within the cache. This result will be retained within the cache until one + * of the base TransformStates is released. + * + * Use list_cycles() to get an idea of the number of actual "leaked" + * TransformState objects. + */ int TransformState:: get_num_unused_states() { if (_states == (States *)NULL) { @@ -1045,9 +949,9 @@ get_num_unused_states() { } LightReMutexHolder holder(*_states_lock); - // First, we need to count the number of times each TransformState - // object is recorded in the cache. We could just trust - // get_cache_ref_count(), but we'll be extra cautious for now. + // First, we need to count the number of times each TransformState object is + // recorded in the cache. We could just trust get_cache_ref_count(), but + // we'll be extra cautious for now. typedef pmap StateCount; StateCount state_count; @@ -1064,13 +968,12 @@ get_num_unused_states() { if (state->_composition_cache.has_element(i)) { const TransformState *result = state->_composition_cache.get_data(i)._result; if (result != (const TransformState *)NULL && result != state) { - // Here's a TransformState that's recorded in the cache. - // Count it. + // Here's a TransformState that's recorded in the cache. Count it. pair ir = state_count.insert(StateCount::value_type(result, 1)); if (!ir.second) { - // If the above insert operation fails, then it's already in - // the cache; increment its value. + // If the above insert operation fails, then it's already in the + // cache; increment its value. (*(ir.first)).second++; } } @@ -1091,9 +994,9 @@ get_num_unused_states() { } } - // Now that we have the appearance count of each TransformState - // object, we can tell which ones are unreferenced outside of the - // TransformState cache, by comparing these to the reference counts. + // Now that we have the appearance count of each TransformState object, we + // can tell which ones are unreferenced outside of the TransformState cache, + // by comparing these to the reference counts. int num_unused = 0; StateCount::iterator sci; @@ -1117,26 +1020,20 @@ get_num_unused_states() { return num_unused; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::clear_cache -// Access: Published, Static -// Description: Empties the cache of composed TransformStates. This -// makes every TransformState forget what results when -// it is composed with other TransformStates. -// -// This will eliminate any TransformState objects that -// have been allocated but have no references outside of -// the internal TransformState map. It will not -// eliminate TransformState objects that are still in -// use. -// -// Nowadays, this method should not be necessary, as -// reference-count cycles in the composition cache -// should be automatically detected and broken. -// -// The return value is the number of TransformStates -// freed by this operation. -//////////////////////////////////////////////////////////////////// +/** + * Empties the cache of composed TransformStates. This makes every + * TransformState forget what results when it is composed with other + * TransformStates. + * + * This will eliminate any TransformState objects that have been allocated but + * have no references outside of the internal TransformState map. It will not + * eliminate TransformState objects that are still in use. + * + * Nowadays, this method should not be necessary, as reference-count cycles in + * the composition cache should be automatically detected and broken. + * + * The return value is the number of TransformStates freed by this operation. + */ int TransformState:: clear_cache() { if (_states == (States *)NULL) { @@ -1147,10 +1044,10 @@ clear_cache() { PStatTimer timer(_cache_update_pcollector); int orig_size = _states->get_num_entries(); - // First, we need to copy the entire set of states to a temporary - // vector, reference-counting each object. That way we can walk - // through the copy, without fear of dereferencing (and deleting) - // the objects in the map as we go. + // First, we need to copy the entire set of states to a temporary vector, + // reference-counting each object. That way we can walk through the copy, + // without fear of dereferencing (and deleting) the objects in the map as we + // go. { typedef pvector< CPT(TransformState) > TempStates; TempStates temp_states; @@ -1165,9 +1062,8 @@ clear_cache() { temp_states.push_back(state); } - // Now it's safe to walk through the list, destroying the cache - // within each object as we go. Nothing will be destructed till - // we're done. + // Now it's safe to walk through the list, destroying the cache within + // each object as we go. Nothing will be destructed till we're done. TempStates::iterator ti; for (ti = temp_states.begin(); ti != temp_states.end(); ++ti) { TransformState *state = (TransformState *)(*ti).p(); @@ -1200,25 +1096,21 @@ clear_cache() { state->_invert_composition_cache.clear(); } - // Once this block closes and the temp_states object goes away, - // all the destruction will begin. Anything whose reference was - // held only within the various objects' caches will go away. + // Once this block closes and the temp_states object goes away, all the + // destruction will begin. Anything whose reference was held only within + // the various objects' caches will go away. } int new_size = _states->get_num_entries(); return orig_size - new_size; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::garbage_collect -// Access: Published, Static -// Description: Performs a garbage-collection cycle. This must be -// called periodically if garbage-collect-states is true -// to ensure that TransformStates get cleaned up -// appropriately. It does no harm to call it even if -// this variable is not true, but there is probably no -// advantage in that case. -//////////////////////////////////////////////////////////////////// +/** + * Performs a garbage-collection cycle. This must be called periodically if + * garbage-collect-states is true to ensure that TransformStates get cleaned + * up appropriately. It does no harm to call it even if this variable is not + * true, but there is probably no advantage in that case. + */ int TransformState:: garbage_collect() { if (_states == (States *)NULL || !garbage_collect_states) { @@ -1247,21 +1139,20 @@ garbage_collect() { if (auto_break_cycles && uniquify_transforms) { if (state->get_cache_ref_count() > 0 && state->get_ref_count() == state->get_cache_ref_count()) { - // If we have removed all the references to this state not in - // the cache, leaving only references in the cache, then we - // need to check for a cycle involving this TransformState and - // break it if it exists. + // If we have removed all the references to this state not in the + // cache, leaving only references in the cache, then we need to + // check for a cycle involving this TransformState and break it if + // it exists. state->detect_and_break_cycles(); } } if (state->get_ref_count() == 1) { - // This state has recently been unreffed to 1 (the one we - // added when we stored it in the cache). Now it's time to - // delete it. This is safe, because we're holding the - // _states_lock, so it's not possible for some other thread to - // find the state in the cache and ref it while we're doing - // this. + // This state has recently been unreffed to 1 (the one we added when + // we stored it in the cache). Now it's time to delete it. This is + // safe, because we're holding the _states_lock, so it's not possible + // for some other thread to find the state in the cache and ref it + // while we're doing this. state->release_new(); state->remove_cache_pointers(); state->cache_unref(); @@ -1278,24 +1169,19 @@ garbage_collect() { return orig_size - new_size; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::list_cycles -// Access: Published, Static -// Description: Detects all of the reference-count cycles in the -// cache and reports them to standard output. -// -// These cycles may be inadvertently created when state -// compositions cycle back to a starting point. -// Nowadays, these cycles should be automatically -// detected and broken, so this method should never list -// any cycles unless there is a bug in that detection -// logic. -// -// The cycles listed here are not leaks in the strictest -// sense of the word, since they can be reclaimed by a -// call to clear_cache(); but they will not be reclaimed -// automatically. -//////////////////////////////////////////////////////////////////// +/** + * Detects all of the reference-count cycles in the cache and reports them to + * standard output. + * + * These cycles may be inadvertently created when state compositions cycle + * back to a starting point. Nowadays, these cycles should be automatically + * detected and broken, so this method should never list any cycles unless + * there is a bug in that detection logic. + * + * The cycles listed here are not leaks in the strictest sense of the word, + * since they can be reclaimed by a call to clear_cache(); but they will not + * be reclaimed automatically. + */ void TransformState:: list_cycles(ostream &out) { if (_states == (States *)NULL) { @@ -1371,13 +1257,11 @@ list_cycles(ostream &out) { } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::list_states -// Access: Published, Static -// Description: Lists all of the TransformStates in the cache to the -// output stream, one per line. This can be quite a lot -// of output if the cache is large, so be prepared. -//////////////////////////////////////////////////////////////////// +/** + * Lists all of the TransformStates in the cache to the output stream, one per + * line. This can be quite a lot of output if the cache is large, so be + * prepared. + */ void TransformState:: list_states(ostream &out) { if (_states == (States *)NULL) { @@ -1398,16 +1282,12 @@ list_states(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::validate_states -// Access: Published, Static -// Description: Ensures that the cache is still stored in sorted -// order, and that none of the cache elements have been -// inadvertently deleted. Returns true if so, false if -// there is a problem (which implies someone has -// modified one of the supposedly-const TransformState -// objects). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the cache is still stored in sorted order, and that none of + * the cache elements have been inadvertently deleted. Returns true if so, + * false if there is a problem (which implies someone has modified one of the + * supposedly-const TransformState objects). + */ bool TransformState:: validate_states() { if (_states == (States *)NULL) { @@ -1469,16 +1349,13 @@ validate_states() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::init_states -// Access: Public, Static -// Description: Make sure the global _states map is allocated. This -// only has to be done once. We could make this map -// static, but then we run into problems if anyone -// creates a TransformState object at static init time; -// it also seems to cause problems when the Panda shared -// library is unloaded at application exit time. -//////////////////////////////////////////////////////////////////// +/** + * Make sure the global _states map is allocated. This only has to be done + * once. We could make this map static, but then we run into problems if + * anyone creates a TransformState object at static init time; it also seems + * to cause problems when the Panda shared library is unloaded at application + * exit time. + */ void TransformState:: init_states() { _states = new States; @@ -1491,30 +1368,26 @@ init_states() { "a single pointer. Nowadays, with the transforms stored in a " "hashtable, we're generally better off with this set true.")); - // Store this at the beginning, so that we don't have to query this - // every time that the comparison operator is invoked. + // Store this at the beginning, so that we don't have to query this every + // time that the comparison operator is invoked. _uniquify_matrix = uniquify_matrix; - // TODO: we should have a global Panda mutex to allow us to safely - // create _states_lock without a startup race condition. For the - // meantime, this is OK because we guarantee that this method is - // called at static init time, presumably when there is still only - // one thread in the world. + // TODO: we should have a global Panda mutex to allow us to safely create + // _states_lock without a startup race condition. For the meantime, this is + // OK because we guarantee that this method is called at static init time, + // presumably when there is still only one thread in the world. _states_lock = new LightReMutex("TransformState::_states_lock"); _cache_stats.init(); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::return_new -// Access: Private, Static -// Description: This function is used to share a common TransformState -// pointer for all equivalent TransformState objects. -// -// This is different from return_unique() in that it -// does not actually guarantee a unique pointer, unless -// uniquify-transforms is set. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to share a common TransformState pointer for all + * equivalent TransformState objects. + * + * This is different from return_unique() in that it does not actually + * guarantee a unique pointer, unless uniquify-transforms is set. + */ CPT(TransformState) TransformState:: return_new(TransformState *state) { nassertr(state != (TransformState *)NULL, state); @@ -1525,18 +1398,15 @@ return_new(TransformState *state) { return return_unique(state); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::return_unique -// Access: Private, Static -// Description: This function is used to share a common TransformState -// pointer for all equivalent TransformState objects. -// -// See the similar logic in RenderState. The idea is to -// create a new TransformState object and pass it -// through this function, which will share the pointer -// with a previously-created TransformState object if it -// is equivalent. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to share a common TransformState pointer for all + * equivalent TransformState objects. + * + * See the similar logic in RenderState. The idea is to create a new + * TransformState object and pass it through this function, which will share + * the pointer with a previously-created TransformState object if it is + * equivalent. + */ CPT(TransformState) TransformState:: return_unique(TransformState *state) { nassertr(state != (TransformState *)NULL, state); @@ -1556,13 +1426,13 @@ return_unique(TransformState *state) { LightReMutexHolder holder(*_states_lock); if (state->_saved_entry != -1) { - // This state is already in the cache. - //nassertr(_states->find(state) == state->_saved_entry, state); + // This state is already in the cache. nassertr(_states->find(state) == + // state->_saved_entry, state); return state; } - // Save the state in a local PointerTo so that it will be freed at - // the end of this function if no one else uses it. + // Save the state in a local PointerTo so that it will be freed at the end + // of this function if no one else uses it. CPT(TransformState) pt_state = state; int si = _states->find(state); @@ -1573,9 +1443,9 @@ return_unique(TransformState *state) { // Not already in the set; add it. if (garbage_collect_states) { - // If we'll be garbage collecting states explicitly, we'll - // increment the reference count when we store it in the cache, so - // that it won't be deleted while it's in it. + // If we'll be garbage collecting states explicitly, we'll increment the + // reference count when we store it in the cache, so that it won't be + // deleted while it's in it. state->cache_ref(); } si = _states->store(state, Empty()); @@ -1585,13 +1455,10 @@ return_unique(TransformState *state) { return pt_state; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_compose -// Access: Private -// Description: The private implemention of compose(); this actually -// composes two TransformStates, without bothering with the -// cache. -//////////////////////////////////////////////////////////////////// +/** + * The private implemention of compose(); this actually composes two + * TransformStates, without bothering with the cache. + */ CPT(TransformState) TransformState:: do_compose(const TransformState *other) const { PStatTimer timer(_transform_compose_pcollector); @@ -1604,9 +1471,8 @@ do_compose(const TransformState *other) const { !has_nonzero_shear() && !other->has_nonzero_shear() && ((components_given() && other->has_components()) || (other->components_given() && has_components()))) { - // We will do this operation componentwise if *either* transform - // was given componentwise (and there is no non-uniform scale in - // the way). + // We will do this operation componentwise if *either* transform was given + // componentwise (and there is no non-uniform scale in the way). CPT(TransformState) result; if (is_2d() && other->is_2d()) { @@ -1667,14 +1533,11 @@ do_compose(const TransformState *other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::store_compose -// Access: Private -// Description: Stores the result of a composition in the cache. -// Returns the stored result (it may be a different -// object than the one passed in, due to another thread -// having computed the composition first). -//////////////////////////////////////////////////////////////////// +/** + * Stores the result of a composition in the cache. Returns the stored result + * (it may be a different object than the one passed in, due to another thread + * having computed the composition first). + */ CPT(TransformState) TransformState:: store_compose(const TransformState *other, const TransformState *result) { // Identity should have already been screened. @@ -1692,14 +1555,14 @@ store_compose(const TransformState *other, const TransformState *result) { if (index != -1) { Composition &comp = _composition_cache.modify_data(index); if (comp._result == (const TransformState *)NULL) { - // Well, it wasn't cached already, but we already had an entry - // (probably created for the reverse direction), so use the same - // entry to store the new result. + // Well, it wasn't cached already, but we already had an entry (probably + // created for the reverse direction), so use the same entry to store + // the new result. comp._result = result; if (result != (const TransformState *)this) { - // See the comments below about the need to up the reference - // count only when the result is not the same as this. + // See the comments below about the need to up the reference count + // only when the result is not the same as this. result->cache_ref(); } } @@ -1709,13 +1572,13 @@ store_compose(const TransformState *other, const TransformState *result) { } _cache_stats.inc_misses(); - // We need to make a new cache entry, both in this object and in the - // other object. We make both records so the other TransformState - // object will know to delete the entry from this object when it - // destructs, and vice-versa. + // We need to make a new cache entry, both in this object and in the other + // object. We make both records so the other TransformState object will + // know to delete the entry from this object when it destructs, and vice- + // versa. - // The cache entry in this object is the only one that indicates the - // result; the other will be NULL for now. + // The cache entry in this object is the only one that indicates the result; + // the other will be NULL for now. _cache_stats.add_total_size(1); _cache_stats.inc_adds(_composition_cache.get_size() == 0); @@ -1728,15 +1591,14 @@ store_compose(const TransformState *other, const TransformState *result) { } if (result != (TransformState *)this) { - // If the result of do_compose() is something other than this, - // explicitly increment the reference count. We have to be sure - // to decrement it again later, when the composition entry is - // removed from the cache. + // If the result of do_compose() is something other than this, explicitly + // increment the reference count. We have to be sure to decrement it + // again later, when the composition entry is removed from the cache. result->cache_ref(); - // (If the result was just this again, we still store the - // result, but we don't increment the reference count, since - // that would be a self-referential leak.) + // (If the result was just this again, we still store the result, but we + // don't increment the reference count, since that would be a self- + // referential leak.) } _cache_stats.maybe_report("TransformState"); @@ -1744,14 +1606,11 @@ store_compose(const TransformState *other, const TransformState *result) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::store_invert_compose -// Access: Private -// Description: Stores the result of a composition in the cache. -// Returns the stored result (it may be a different -// object than the one passed in, due to another thread -// having computed the composition first). -//////////////////////////////////////////////////////////////////// +/** + * Stores the result of a composition in the cache. Returns the stored result + * (it may be a different object than the one passed in, due to another thread + * having computed the composition first). + */ CPT(TransformState) TransformState:: store_invert_compose(const TransformState *other, const TransformState *result) { // Identity should have already been screened. @@ -1770,14 +1629,14 @@ store_invert_compose(const TransformState *other, const TransformState *result) if (index != -1) { Composition &comp = ((TransformState *)this)->_invert_composition_cache.modify_data(index); if (comp._result == (const TransformState *)NULL) { - // Well, it wasn't cached already, but we already had an entry - // (probably created for the reverse direction), so use the same - // entry to store the new result. + // Well, it wasn't cached already, but we already had an entry (probably + // created for the reverse direction), so use the same entry to store + // the new result. comp._result = result; if (result != (const TransformState *)this) { - // See the comments below about the need to up the reference - // count only when the result is not the same as this. + // See the comments below about the need to up the reference count + // only when the result is not the same as this. result->cache_ref(); } } @@ -1787,13 +1646,13 @@ store_invert_compose(const TransformState *other, const TransformState *result) } _cache_stats.inc_misses(); - // We need to make a new cache entry, both in this object and in the - // other object. We make both records so the other TransformState - // object will know to delete the entry from this object when it - // destructs, and vice-versa. + // We need to make a new cache entry, both in this object and in the other + // object. We make both records so the other TransformState object will + // know to delete the entry from this object when it destructs, and vice- + // versa. - // The cache entry in this object is the only one that indicates the - // result; the other will be NULL for now. + // The cache entry in this object is the only one that indicates the result; + // the other will be NULL for now. _cache_stats.add_total_size(1); _cache_stats.inc_adds(_invert_composition_cache.get_size() == 0); _invert_composition_cache[other]._result = result; @@ -1805,25 +1664,22 @@ store_invert_compose(const TransformState *other, const TransformState *result) } if (result != (TransformState *)this) { - // If the result of compose() is something other than this, - // explicitly increment the reference count. We have to be sure - // to decrement it again later, when the composition entry is - // removed from the cache. + // If the result of compose() is something other than this, explicitly + // increment the reference count. We have to be sure to decrement it + // again later, when the composition entry is removed from the cache. result->cache_ref(); - // (If the result was just this again, we still store the - // result, but we don't increment the reference count, since - // that would be a self-referential leak.) + // (If the result was just this again, we still store the result, but we + // don't increment the reference count, since that would be a self- + // referential leak.) } return result; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_invert_compose -// Access: Private -// Description: The private implemention of invert_compose(). -//////////////////////////////////////////////////////////////////// +/** + * The private implemention of invert_compose(). + */ CPT(TransformState) TransformState:: do_invert_compose(const TransformState *other) const { PStatTimer timer(_transform_invert_pcollector); @@ -1836,9 +1692,8 @@ do_invert_compose(const TransformState *other) const { !has_nonzero_shear() && !other->has_nonzero_shear() && ((components_given() && other->has_components()) || (other->components_given() && has_components()))) { - // We will do this operation componentwise if *either* transform - // was given componentwise (and there is no non-uniform scale in - // the way). + // We will do this operation componentwise if *either* transform was given + // componentwise (and there is no non-uniform scale in the way). CPT(TransformState) result; if (is_2d() && other->is_2d()) { @@ -1926,8 +1781,8 @@ do_invert_compose(const TransformState *other) const { return make_invalid(); } - // Now that is_singular() has returned false, we can assume that - // _inv_mat has been allocated and filled in. + // Now that is_singular() has returned false, we can assume that _inv_mat + // has been allocated and filled in. nassertr(_inv_mat != (LMatrix4 *)NULL, make_invalid()); if (is_2d() && other->is_2d()) { @@ -1949,21 +1804,18 @@ do_invert_compose(const TransformState *other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::detect_and_break_cycles -// Access: Private -// Description: Detects whether there is a cycle in the cache that -// begins with this state. If any are detected, breaks -// them by removing this state from the cache. -//////////////////////////////////////////////////////////////////// +/** + * Detects whether there is a cycle in the cache that begins with this state. + * If any are detected, breaks them by removing this state from the cache. + */ void TransformState:: detect_and_break_cycles() { PStatTimer timer(_transform_break_cycles_pcollector); ++_last_cycle_detect; if (r_detect_cycles(this, this, 1, _last_cycle_detect, NULL)) { - // Ok, we have a cycle. This will be a leak unless we break the - // cycle by freeing the cache on this object. + // Ok, we have a cycle. This will be a leak unless we break the cycle by + // freeing the cache on this object. if (pgraph_cat.is_debug()) { pgraph_cat.debug() << "Breaking cycle involving " << (*this) << "\n"; @@ -1983,17 +1835,13 @@ detect_and_break_cycles() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::r_detect_cycles -// Access: Private, Static -// Description: Detects whether there is a cycle in the cache that -// begins with the indicated state. Returns true if at -// least one cycle is found, false if this state is not -// part of any cycles. If a cycle is found and -// cycle_desc is not NULL, then cycle_desc is filled in -// with the list of the steps of the cycle, in reverse -// order. -//////////////////////////////////////////////////////////////////// +/** + * Detects whether there is a cycle in the cache that begins with the + * indicated state. Returns true if at least one cycle is found, false if + * this state is not part of any cycles. If a cycle is found and cycle_desc + * is not NULL, then cycle_desc is filled in with the list of the steps of the + * cycle, in reverse order. + */ bool TransformState:: r_detect_cycles(const TransformState *start_state, const TransformState *current_state, @@ -2002,10 +1850,9 @@ r_detect_cycles(const TransformState *start_state, if (current_state->_cycle_detect == this_seq) { // We've already seen this state; therefore, we've found a cycle. - // However, we only care about cycles that return to the starting - // state and involve more than two steps. If only one or two - // nodes are involved, it doesn't represent a memory leak, so no - // problem there. + // However, we only care about cycles that return to the starting state + // and involve more than two steps. If only one or two nodes are + // involved, it doesn't represent a memory leak, so no problem there. return (current_state == start_state && length > 2); } ((TransformState *)current_state)->_cycle_detect = this_seq; @@ -2053,14 +1900,11 @@ r_detect_cycles(const TransformState *start_state, return false; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::r_detect_reverse_cycles -// Access: Private, Static -// Description: Works the same as r_detect_cycles, but checks for -// cycles in the reverse direction along the cache -// chain. (A cycle may appear in either direction, and -// we must check both.) -//////////////////////////////////////////////////////////////////// +/** + * Works the same as r_detect_cycles, but checks for cycles in the reverse + * direction along the cache chain. (A cycle may appear in either direction, + * and we must check both.) + */ bool TransformState:: r_detect_reverse_cycles(const TransformState *start_state, const TransformState *current_state, @@ -2069,10 +1913,9 @@ r_detect_reverse_cycles(const TransformState *start_state, if (current_state->_cycle_detect == this_seq) { // We've already seen this state; therefore, we've found a cycle. - // However, we only care about cycles that return to the starting - // state and involve more than two steps. If only one or two - // nodes are involved, it doesn't represent a memory leak, so no - // problem there. + // However, we only care about cycles that return to the starting state + // and involve more than two steps. If only one or two nodes are + // involved, it doesn't represent a memory leak, so no problem there. return (current_state == start_state && length > 2); } ((TransformState *)current_state)->_cycle_detect = this_seq; @@ -2133,56 +1976,49 @@ r_detect_reverse_cycles(const TransformState *start_state, } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::release_new -// Access: Private -// Description: This inverse of return_new, this releases this object -// from the global TransformState table. -// -// You must already be holding _states_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * This inverse of return_new, this releases this object from the global + * TransformState table. + * + * You must already be holding _states_lock before you call this method. + */ void TransformState:: release_new() { nassertv(_states_lock->debug_is_locked()); if (_saved_entry != -1) { - //nassertv(_states->find(this) == _saved_entry); + // nassertv(_states->find(this) == _saved_entry); _saved_entry = _states->find(this); _states->remove_element(_saved_entry); _saved_entry = -1; } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::remove_cache_pointers -// Access: Private -// Description: Remove all pointers within the cache from and to this -// particular TransformState. The pointers to this -// object may be scattered around in the various -// CompositionCaches from other TransformState objects. -// -// You must already be holding _states_lock before you -// call this method. -//////////////////////////////////////////////////////////////////// +/** + * Remove all pointers within the cache from and to this particular + * TransformState. The pointers to this object may be scattered around in the + * various CompositionCaches from other TransformState objects. + * + * You must already be holding _states_lock before you call this method. + */ void TransformState:: remove_cache_pointers() { nassertv(_states_lock->debug_is_locked()); - // Fortunately, since we added CompositionCache records in pairs, we - // know exactly the set of TransformState objects that have us in their - // cache: it's the same set of TransformState objects that we have in - // our own cache. + // Fortunately, since we added CompositionCache records in pairs, we know + // exactly the set of TransformState objects that have us in their cache: + // it's the same set of TransformState objects that we have in our own + // cache. - // We do need to put considerable thought into this loop, because as - // we clear out cache entries we'll cause other TransformState - // objects to destruct, which could cause things to get pulled out - // of our own _composition_cache map. We want to allow this (so - // that we don't encounter any just-destructed pointers in our - // cache), but we don't want to get bitten by this cascading effect. - // Instead of walking through the map from beginning to end, - // therefore, we just pull out the first one each time, and erase - // it. +/* + * We do need to put considerable thought into this loop, because as we clear + * out cache entries we'll cause other TransformState objects to destruct, + * which could cause things to get pulled out of our own _composition_cache + * map. We want to allow this (so that we don't encounter any just-destructed + * pointers in our cache), but we don't want to get bitten by this cascading + * effect. Instead of walking through the map from beginning to end, + * therefore, we just pull out the first one each time, and erase it. + */ #ifdef DO_PSTATS if (_composition_cache.is_empty() && _invert_composition_cache.is_empty()) { @@ -2191,8 +2027,8 @@ remove_cache_pointers() { PStatTimer timer(_cache_update_pcollector); #endif // DO_PSTATS - // There are lots of ways to do this loop wrong. Be very careful if - // you need to modify it for any reason. + // There are lots of ways to do this loop wrong. Be very careful if you + // need to modify it for any reason. int i = 0; while (!_composition_cache.is_empty()) { // Scan for the next used slot in the table. @@ -2200,23 +2036,22 @@ remove_cache_pointers() { ++i; } - // It is possible that the "other" TransformState object is - // currently within its own destructor. We therefore can't use a - // PT() to hold its pointer; that could end up calling its - // destructor twice. Fortunately, we don't need to hold its - // reference count to ensure it doesn't destruct while we process - // this loop; as long as we ensure that no *other* TransformState - // objects destruct, there will be no reason for that one to. + // It is possible that the "other" TransformState object is currently + // within its own destructor. We therefore can't use a PT() to hold its + // pointer; that could end up calling its destructor twice. Fortunately, + // we don't need to hold its reference count to ensure it doesn't destruct + // while we process this loop; as long as we ensure that no *other* + // TransformState objects destruct, there will be no reason for that one + // to. TransformState *other = (TransformState *)_composition_cache.get_key(i); - // We hold a copy of the composition result so we can dereference - // it later. + // We hold a copy of the composition result so we can dereference it + // later. Composition comp = _composition_cache.get_data(i); - // Now we can remove the element from our cache. We do this now, - // rather than later, before any other TransformState objects have - // had a chance to destruct, so we are confident that our iterator - // is still valid. + // Now we can remove the element from our cache. We do this now, rather + // than later, before any other TransformState objects have had a chance + // to destruct, so we are confident that our iterator is still valid. _composition_cache.remove_element(i); _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); @@ -2224,9 +2059,8 @@ remove_cache_pointers() { if (other != this) { int oi = other->_composition_cache.find(this); - // We may or may not still be listed in the other's cache (it - // might be halfway through pulling entries out, from within its - // own destructor). + // We may or may not still be listed in the other's cache (it might be + // halfway through pulling entries out, from within its own destructor). if (oi != -1) { // Hold a copy of the other composition result, too. Composition ocomp = other->_composition_cache.get_data(oi); @@ -2235,18 +2069,17 @@ remove_cache_pointers() { _cache_stats.add_total_size(-1); _cache_stats.inc_dels(); - // It's finally safe to let our held pointers go away. This may - // have cascading effects as other TransformState objects are - // destructed, but there will be no harm done if they destruct - // now. + // It's finally safe to let our held pointers go away. This may have + // cascading effects as other TransformState objects are destructed, + // but there will be no harm done if they destruct now. if (ocomp._result != (const TransformState *)NULL && ocomp._result != other) { cache_unref_delete(ocomp._result); } } } - // It's finally safe to let our held pointers go away. (See - // comment above.) + // It's finally safe to let our held pointers go away. (See comment + // above.) if (comp._result != (const TransformState *)NULL && comp._result != this) { cache_unref_delete(comp._result); } @@ -2283,11 +2116,9 @@ remove_cache_pointers() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_calc_hash -// Access: Private -// Description: Computes a suitable hash value for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Computes a suitable hash value for phash_map. + */ void TransformState:: do_calc_hash() { PStatTimer timer(_transform_hash_pcollector); @@ -2300,12 +2131,11 @@ do_calc_hash() { _hash = int_hash::add_hash(_hash, flags); if ((_flags & (F_is_invalid | F_is_identity)) == 0) { - // Only bother to put the rest of the stuff in the hash if the - // transform is not invalid or empty. + // Only bother to put the rest of the stuff in the hash if the transform + // is not invalid or empty. if ((_flags & F_components_given) != 0) { - // If the transform was specified componentwise, hash it - // componentwise. + // If the transform was specified componentwise, hash it componentwise. _hash = _pos.add_hash(_hash); if ((_flags & F_hpr_given) != 0) { _hash = _hpr.add_hash(_hash); @@ -2328,9 +2158,9 @@ do_calc_hash() { _hash = _mat.add_hash(_hash); } else { - // Otherwise, hash the pointer only--any two different - // matrix-based TransformStates are considered to be different, - // even if their matrices have the same values. + // Otherwise, hash the pointer only--any two different matrix-based + // TransformStates are considered to be different, even if their + // matrices have the same values. _hash = pointer_hash::add_hash(_hash, this); } @@ -2340,12 +2170,10 @@ do_calc_hash() { _flags |= F_hash_known; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_singular -// Access: Private -// Description: Determines whether the transform is singular (i.e. it -// scales to zero, and has no inverse). -//////////////////////////////////////////////////////////////////// +/** + * Determines whether the transform is singular (i.e. it scales to zero, and + * has no inverse). + */ void TransformState:: calc_singular() { LightMutexHolder holder(_lock); @@ -2358,10 +2186,10 @@ calc_singular() { nassertv((_flags & F_is_invalid) == 0); - // We determine if a matrix is singular by attempting to invert it - // (and we save the result of this invert operation for a subsequent - // do_invert_compose() call, which is almost certain to be made if - // someone is asking whether we're singular). + // We determine if a matrix is singular by attempting to invert it (and we + // save the result of this invert operation for a subsequent + // do_invert_compose() call, which is almost certain to be made if someone + // is asking whether we're singular). // This should be NULL if no one has called calc_singular() yet. nassertv(_inv_mat == (LMatrix4 *)NULL); @@ -2380,12 +2208,10 @@ calc_singular() { _flags |= F_singular_known; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_calc_components -// Access: Private -// Description: This is the implementation of calc_components(); it -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * This is the implementation of calc_components(); it assumes the lock is + * already held. + */ void TransformState:: do_calc_components() { if ((_flags & F_components_known) != 0) { @@ -2405,8 +2231,8 @@ do_calc_components() { _flags |= F_has_components | F_components_known | F_hpr_known | F_quat_known | F_uniform_scale | F_identity_scale; } else { - // If we don't have components and we're not identity, the only - // other explanation is that we were constructed via a matrix. + // If we don't have components and we're not identity, the only other + // explanation is that we were constructed via a matrix. nassertv((_flags & F_mat_known) != 0); if ((_flags & F_mat_known) == 0) { @@ -2414,9 +2240,9 @@ do_calc_components() { } bool possible = decompose_matrix(_mat, _scale, _shear, _hpr, _pos); if (!possible) { - // Some matrices can't be decomposed into scale, hpr, pos. In - // this case, we now know that we cannot compute the components; - // but the closest approximations are stored, at least. + // Some matrices can't be decomposed into scale, hpr, pos. In this + // case, we now know that we cannot compute the components; but the + // closest approximations are stored, at least. _flags |= F_components_known | F_hpr_known; } else { @@ -2430,12 +2256,10 @@ do_calc_components() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_calc_hpr -// Access: Private -// Description: This is the implementation of calc_hpr(); it -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * This is the implementation of calc_hpr(); it assumes the lock is already + * held. + */ void TransformState:: do_calc_hpr() { if ((_flags & F_hpr_known) != 0) { @@ -2458,11 +2282,9 @@ do_calc_hpr() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_quat -// Access: Private -// Description: Derives the quat from the hpr. -//////////////////////////////////////////////////////////////////// +/** + * Derives the quat from the hpr. + */ void TransformState:: calc_quat() { LightMutexHolder holder(_lock); @@ -2486,11 +2308,9 @@ calc_quat() { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::calc_norm_quat -// Access: Private -// Description: Derives the normalized quat from the quat. -//////////////////////////////////////////////////////////////////// +/** + * Derives the normalized quat from the quat. + */ void TransformState:: calc_norm_quat() { PStatTimer timer(_transform_calc_pcollector); @@ -2502,12 +2322,10 @@ calc_norm_quat() { _flags |= F_norm_quat_known; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::do_calc_mat -// Access: Private -// Description: This is the implementation of calc_mat(); it -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * This is the implementation of calc_mat(); it assumes the lock is already + * held. + */ void TransformState:: do_calc_mat() { if ((_flags & F_mat_known) != 0) { @@ -2522,8 +2340,8 @@ do_calc_mat() { _mat = LMatrix4::ident_mat(); } else { - // If we don't have a matrix and we're not identity, the only - // other explanation is that we were constructed via components. + // If we don't have a matrix and we're not identity, the only other + // explanation is that we were constructed via components. nassertv((_flags & F_components_known) != 0); if ((_flags & F_hpr_known) == 0) { do_calc_hpr(); @@ -2534,14 +2352,11 @@ do_calc_mat() { _flags |= F_mat_known; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::update_pstats -// Access: Private -// Description: Moves the TransformState object from one PStats category -// to another, so that we can track in PStats how many -// pointers are held by nodes, and how many are held in -// the cache only. -//////////////////////////////////////////////////////////////////// +/** + * Moves the TransformState object from one PStats category to another, so + * that we can track in PStats how many pointers are held by nodes, and how + * many are held in the cache only. + */ void TransformState:: update_pstats(int old_referenced_bits, int new_referenced_bits) { #ifdef DO_PSTATS @@ -2558,23 +2373,18 @@ update_pstats(int old_referenced_bits, int new_referenced_bits) { #endif // DO_PSTATS } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TransformState. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TransformState. + */ void TransformState:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransformState:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -2620,36 +2430,30 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::change_this -// Access: Public, Static -// Description: Called immediately after complete_pointers(), this -// gives the object a chance to adjust its own pointer -// if desired. Most objects don't change pointers after -// completion, but some need to. -// -// Once this function has been called, the old pointer -// will no longer be accessed. -//////////////////////////////////////////////////////////////////// +/** + * Called immediately after complete_pointers(), this gives the object a + * chance to adjust its own pointer if desired. Most objects don't change + * pointers after completion, but some need to. + * + * Once this function has been called, the old pointer will no longer be + * accessed. + */ PT(TypedWritableReferenceCount) TransformState:: change_this(TypedWritableReferenceCount *old_ptr, BamReader *manager) { // First, uniquify the pointer. TransformState *state = DCAST(TransformState, old_ptr); CPT(TransformState) pointer = return_unique(state); - // We have to cast the pointer back to non-const, because the bam - // reader expects that. + // We have to cast the pointer back to non-const, because the bam reader + // expects that. return (TransformState *)pointer.p(); } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TransformState is encountered -// in the Bam file. It should create the TransformState -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TransformState is encountered in the Bam file. It should create the + * TransformState and extract its information from the file. + */ TypedWritable *TransformState:: make_from_bam(const FactoryParams ¶ms) { TransformState *state = new TransformState; @@ -2663,13 +2467,10 @@ make_from_bam(const FactoryParams ¶ms) { return state; } -//////////////////////////////////////////////////////////////////// -// Function: TransformState::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransformState. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransformState. + */ void TransformState:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index 3b48722775..3287fb1853 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -1,16 +1,15 @@ -// Filename: transformState.h -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformState.h + * @author drose + * @date 2002-02-25 + */ #ifndef TRANSFORMSTATE_H #define TRANSFORMSTATE_H @@ -37,28 +36,21 @@ class GraphicsStateGuardianBase; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TransformState -// Description : Indicates a coordinate-system transform on vertices. -// TransformStates are the primary means for storing -// transformations on the scene graph. -// -// Transforms may be specified in one of two ways: -// componentwise, with a pos-hpr-scale, or with an -// arbitrary transform matrix. If you specify a -// transform componentwise, it will remember its -// original components. -// -// TransformState objects are managed very much like -// RenderState objects. They are immutable and -// reference-counted automatically. -// -// You should not attempt to create or modify a -// TransformState object directly. Instead, call one of -// the make() functions to create one for you. And -// instead of modifying a TransformState object, create a -// new one. -//////////////////////////////////////////////////////////////////// +/** + * Indicates a coordinate-system transform on vertices. TransformStates are + * the primary means for storing transformations on the scene graph. + * + * Transforms may be specified in one of two ways: componentwise, with a pos- + * hpr-scale, or with an arbitrary transform matrix. If you specify a + * transform componentwise, it will remember its original components. + * + * TransformState objects are managed very much like RenderState objects. + * They are immutable and reference-counted automatically. + * + * You should not attempt to create or modify a TransformState object + * directly. Instead, call one of the make() functions to create one for you. + * And instead of modifying a TransformState object, create a new one. + */ class EXPCL_PANDA_PGRAPH TransformState FINAL : public NodeCachedReferenceCount { protected: TransformState(); @@ -259,8 +251,8 @@ private: void remove_cache_pointers(); private: - // This mutex protects _states. It also protects any modification - // to the cache, which is encoded in _composition_cache and + // This mutex protects _states. It also protects any modification to the + // cache, which is encoded in _composition_cache and // _invert_composition_cache. static LightReMutex *_states_lock; class Empty { @@ -270,28 +262,28 @@ private: static CPT(TransformState) _identity_state; static CPT(TransformState) _invalid_state; - // This iterator records the entry corresponding to this - // TransformState object in the above global set. We keep the index - // around so we can remove it when the TransformState destructs. + // This iterator records the entry corresponding to this TransformState + // object in the above global set. We keep the index around so we can + // remove it when the TransformState destructs. int _saved_entry; - // This data structure manages the job of caching the composition of - // two TransformStates. It's complicated because we have to be sure to - // remove the entry if *either* of the input TransformStates destructs. - // To implement this, we always record Composition entries in pairs, - // one in each of the two involved TransformState objects. + // This data structure manages the job of caching the composition of two + // TransformStates. It's complicated because we have to be sure to remove + // the entry if *either* of the input TransformStates destructs. To + // implement this, we always record Composition entries in pairs, one in + // each of the two involved TransformState objects. - // The first element of the map is the object we compose with. This - // is not reference counted within this map; instead we store a - // companion pointer in the other object, and remove the references - // explicitly when either object destructs. + // The first element of the map is the object we compose with. This is not + // reference counted within this map; instead we store a companion pointer + // in the other object, and remove the references explicitly when either + // object destructs. class Composition { public: INLINE Composition(); INLINE Composition(const Composition ©); - // _result is reference counted if and only if it is not the same - // pointer as this. + // _result is reference counted if and only if it is not the same pointer + // as this. const TransformState *_result; }; @@ -303,8 +295,8 @@ private: UpdateSeq _cycle_detect; static UpdateSeq _last_cycle_detect; - // This keeps track of our current position through the garbage - // collection cycle. + // This keeps track of our current position through the garbage collection + // cycle. static int _garbage_index; static bool _uniquify_matrix; @@ -424,4 +416,3 @@ INLINE ostream &operator << (ostream &out, const TransformState &state) { #include "transformState.I" #endif - diff --git a/panda/src/pgraph/transformState_ext.cxx b/panda/src/pgraph/transformState_ext.cxx index a657df7fae..e037cd2a16 100644 --- a/panda/src/pgraph/transformState_ext.cxx +++ b/panda/src/pgraph/transformState_ext.cxx @@ -1,35 +1,31 @@ -// Filename: transformState_ext.cxx -// Created by: CFSworks (30Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformState_ext.cxx + * @author CFSworks + * @date 2014-03-30 + */ #include "transformState_ext.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_composition_cache -// Access: Published -// Description: Returns a list of 2-tuples that represents the -// composition cache. For each tuple in the list, the -// first element is the source transform, and the second -// is the result transform. If both are None, there is -// no entry in the cache at that slot. -// -// In general, a->compose(source) == result. -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of 2-tuples that represents the composition cache. For each + * tuple in the list, the first element is the source transform, and the + * second is the result transform. If both are None, there is no entry in the + * cache at that slot. + * + * In general, a->compose(source) == result. + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ PyObject *Extension:: get_composition_cache() const { extern struct Dtool_PyTypedObject Dtool_TransformState; @@ -54,7 +50,7 @@ get_composition_cache() const { Py_INCREF(a); } else { source->ref(); - a = DTool_CreatePyInstanceTyped((void *)source, Dtool_TransformState, + a = DTool_CreatePyInstanceTyped((void *)source, Dtool_TransformState, true, true, source->get_type_index()); } const TransformState *result = _this->_composition_cache.get_data(si)._result; @@ -63,7 +59,7 @@ get_composition_cache() const { Py_INCREF(b); } else { result->ref(); - b = DTool_CreatePyInstanceTyped((void *)result, Dtool_TransformState, + b = DTool_CreatePyInstanceTyped((void *)result, Dtool_TransformState, true, true, result->get_type_index()); } @@ -78,20 +74,17 @@ get_composition_cache() const { return list; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_invert_composition_cache -// Access: Published -// Description: Returns a list of 2-tuples that represents the -// invert_composition cache. For each tuple in the list, the -// first element is the source transform, and the second -// is the result transform. If both are None, there is -// no entry in the cache at that slot. -// -// In general, a->invert_compose(source) == result. -// -// This has no practical value other than for examining -// the cache for performance analysis. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of 2-tuples that represents the invert_composition cache. + * For each tuple in the list, the first element is the source transform, and + * the second is the result transform. If both are None, there is no entry in + * the cache at that slot. + * + * In general, a->invert_compose(source) == result. + * + * This has no practical value other than for examining the cache for + * performance analysis. + */ PyObject *Extension:: get_invert_composition_cache() const { extern struct Dtool_PyTypedObject Dtool_TransformState; @@ -116,7 +109,7 @@ get_invert_composition_cache() const { Py_INCREF(a); } else { source->ref(); - a = DTool_CreatePyInstanceTyped((void *)source, Dtool_TransformState, + a = DTool_CreatePyInstanceTyped((void *)source, Dtool_TransformState, true, true, source->get_type_index()); } const TransformState *result = _this->_invert_composition_cache.get_data(si)._result; @@ -125,7 +118,7 @@ get_invert_composition_cache() const { Py_INCREF(b); } else { result->ref(); - b = DTool_CreatePyInstanceTyped((void *)result, Dtool_TransformState, + b = DTool_CreatePyInstanceTyped((void *)result, Dtool_TransformState, true, true, result->get_type_index()); } @@ -140,13 +133,10 @@ get_invert_composition_cache() const { return list; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_states -// Access: Published, Static -// Description: Returns a list of all of the TransformState objects -// in the state cache. The order of elements in this -// cache is arbitrary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all of the TransformState objects in the state cache. + * The order of elements in this cache is arbitrary. + */ PyObject *Extension:: get_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; @@ -166,8 +156,8 @@ get_states() { } const TransformState *state = TransformState::_states->get_key(si); state->ref(); - PyObject *a = - DTool_CreatePyInstanceTyped((void *)state, Dtool_TransformState, + PyObject *a = + DTool_CreatePyInstanceTyped((void *)state, Dtool_TransformState, true, true, state->get_type_index()); nassertr(i < num_states, list); PyList_SET_ITEM(list, i, a); @@ -177,13 +167,10 @@ get_states() { return list; } -//////////////////////////////////////////////////////////////////// -// Function: Extension::get_unused_states -// Access: Published, Static -// Description: Returns a list of all of the "unused" TransformState -// objects in the state cache. See -// get_num_unused_states(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all of the "unused" TransformState objects in the state + * cache. See get_num_unused_states(). + */ PyObject *Extension:: get_unused_states() { extern struct Dtool_PyTypedObject Dtool_TransformState; @@ -201,8 +188,8 @@ get_unused_states() { const TransformState *state = TransformState::_states->get_key(si); if (state->get_cache_ref_count() == state->get_ref_count()) { state->ref(); - PyObject *a = - DTool_CreatePyInstanceTyped((void *)state, Dtool_TransformState, + PyObject *a = + DTool_CreatePyInstanceTyped((void *)state, Dtool_TransformState, true, true, state->get_type_index()); PyList_Append(list, a); Py_DECREF(a); diff --git a/panda/src/pgraph/transformState_ext.h b/panda/src/pgraph/transformState_ext.h index 81f3312eb6..98c20cb4b7 100644 --- a/panda/src/pgraph/transformState_ext.h +++ b/panda/src/pgraph/transformState_ext.h @@ -1,16 +1,15 @@ -// Filename: transformState_ext.h -// Created by: CFSworks (31Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transformState_ext.h + * @author CFSworks + * @date 2014-03-31 + */ #ifndef TRANSFORMSTATE_EXT_H #define TRANSFORMSTATE_EXT_H @@ -23,12 +22,10 @@ #include "transformState.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// TransformState, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for TransformState, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pgraph/transparencyAttrib.I b/panda/src/pgraph/transparencyAttrib.I index 6574127a9e..da4e9a280d 100644 --- a/panda/src/pgraph/transparencyAttrib.I +++ b/panda/src/pgraph/transparencyAttrib.I @@ -1,35 +1,29 @@ -// Filename: transparencyAttrib.I -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transparencyAttrib.I + * @author drose + * @date 2002-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::Constructor -// Access: Private -// Description: Use TransparencyAttrib::make() to construct a new -// TransparencyAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Use TransparencyAttrib::make() to construct a new TransparencyAttrib + * object. + */ INLINE TransparencyAttrib:: TransparencyAttrib(TransparencyAttrib::Mode mode) : _mode(mode) { } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::get_mode -// Access: Published -// Description: Returns the transparency mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transparency mode. + */ INLINE TransparencyAttrib::Mode TransparencyAttrib:: get_mode() const { return _mode; diff --git a/panda/src/pgraph/transparencyAttrib.cxx b/panda/src/pgraph/transparencyAttrib.cxx index b2cb9cd75f..358008ac1f 100644 --- a/panda/src/pgraph/transparencyAttrib.cxx +++ b/panda/src/pgraph/transparencyAttrib.cxx @@ -1,16 +1,15 @@ -// Filename: transparencyAttrib.cxx -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transparencyAttrib.cxx + * @author drose + * @date 2002-02-28 + */ #include "transparencyAttrib.h" #include "graphicsStateGuardianBase.h" @@ -23,34 +22,27 @@ TypeHandle TransparencyAttrib::_type_handle; int TransparencyAttrib::_attrib_slot; -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::make -// Access: Published, Static -// Description: Constructs a new TransparencyAttrib object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TransparencyAttrib object. + */ CPT(RenderAttrib) TransparencyAttrib:: make(TransparencyAttrib::Mode mode) { TransparencyAttrib *attrib = new TransparencyAttrib(mode); return return_new(attrib); } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::make_default -// Access: Published, Static -// Description: Returns a RenderAttrib that corresponds to whatever -// the standard default properties for render attributes -// of this type ought to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderAttrib that corresponds to whatever the standard default + * properties for render attributes of this type ought to be. + */ CPT(RenderAttrib) TransparencyAttrib:: make_default() { return return_new(new TransparencyAttrib); } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TransparencyAttrib:: output(ostream &out) const { out << get_type() << ":"; @@ -84,21 +76,18 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::compare_to_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived TransparencyAttrib -// types to return a unique number indicating whether -// this TransparencyAttrib is equivalent to the other one. -// -// This should return 0 if the two TransparencyAttrib objects -// are equivalent, a number less than zero if this one -// should be sorted before the other one, and a number -// greater than zero otherwise. -// -// This will only be called with two TransparencyAttrib -// objects whose get_type() functions return the same. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived TransparencyAttrib types to return a + * unique number indicating whether this TransparencyAttrib is equivalent to + * the other one. + * + * This should return 0 if the two TransparencyAttrib objects are equivalent, + * a number less than zero if this one should be sorted before the other one, + * and a number greater than zero otherwise. + * + * This will only be called with two TransparencyAttrib objects whose + * get_type() functions return the same. + */ int TransparencyAttrib:: compare_to_impl(const RenderAttrib *other) const { const TransparencyAttrib *ta = (const TransparencyAttrib *)other; @@ -106,16 +95,12 @@ compare_to_impl(const RenderAttrib *other) const { return (int)_mode - (int)ta->_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::get_hash_impl -// Access: Protected, Virtual -// Description: Intended to be overridden by derived RenderAttrib -// types to return a unique hash for these particular -// properties. RenderAttribs that compare the same with -// compare_to_impl(), above, should return the same -// hash; RenderAttribs that compare differently should -// return a different hash. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be overridden by derived RenderAttrib types to return a unique + * hash for these particular properties. RenderAttribs that compare the same + * with compare_to_impl(), above, should return the same hash; RenderAttribs + * that compare differently should return a different hash. + */ size_t TransparencyAttrib:: get_hash_impl() const { size_t hash = 0; @@ -123,33 +108,26 @@ get_hash_impl() const { return hash; } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::get_auto_shader_attrib_impl -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CPT(RenderAttrib) TransparencyAttrib:: get_auto_shader_attrib_impl(const RenderState *state) const { return this; } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// TransparencyAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type TransparencyAttrib. + */ void TransparencyAttrib:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TransparencyAttrib:: write_datagram(BamWriter *manager, Datagram &dg) { RenderAttrib::write_datagram(manager, dg); @@ -157,14 +135,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int8(_mode); } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type TransparencyAttrib is encountered -// in the Bam file. It should create the TransparencyAttrib -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type TransparencyAttrib is encountered in the Bam file. It should create + * the TransparencyAttrib and extract its information from the file. + */ TypedWritable *TransparencyAttrib:: make_from_bam(const FactoryParams ¶ms) { TransparencyAttrib *attrib = new TransparencyAttrib; @@ -177,13 +152,10 @@ make_from_bam(const FactoryParams ¶ms) { return attrib; } -//////////////////////////////////////////////////////////////////// -// Function: TransparencyAttrib::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new TransparencyAttrib. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new TransparencyAttrib. + */ void TransparencyAttrib:: fillin(DatagramIterator &scan, BamReader *manager) { RenderAttrib::fillin(scan, manager); diff --git a/panda/src/pgraph/transparencyAttrib.h b/panda/src/pgraph/transparencyAttrib.h index 1831db44f3..fe49dc938e 100644 --- a/panda/src/pgraph/transparencyAttrib.h +++ b/panda/src/pgraph/transparencyAttrib.h @@ -1,16 +1,15 @@ -// Filename: transparencyAttrib.h -// Created by: drose (28Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transparencyAttrib.h + * @author drose + * @date 2002-02-28 + */ #ifndef TRANSPARENCYATTRIB_H #define TRANSPARENCYATTRIB_H @@ -21,24 +20,20 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TransparencyAttrib -// Description : This controls the enabling of transparency. Simply -// setting an alpha component to non-1 does not in -// itself make an object transparent; you must also -// enable transparency mode with a suitable -// TransparencyAttrib. Similarly, it is wasteful to -// render an object with a TransparencyAttrib in -// effect unless you actually want it to be at least -// partially transparent (and it has alpha components -// less than 1). -//////////////////////////////////////////////////////////////////// +/** + * This controls the enabling of transparency. Simply setting an alpha + * component to non-1 does not in itself make an object transparent; you must + * also enable transparency mode with a suitable TransparencyAttrib. + * Similarly, it is wasteful to render an object with a TransparencyAttrib in + * effect unless you actually want it to be at least partially transparent + * (and it has alpha components less than 1). + */ class EXPCL_PANDA_PGRAPH TransparencyAttrib : public RenderAttrib { PUBLISHED: enum Mode { - // The first two should be specifically 0 and 1, for historical - // reasons (NodePath::set_transparency() used to accept a boolean - // value, which corresponded to M_none or M_alpha). + // The first two should be specifically 0 and 1, for historical reasons + // (NodePath::set_transparency() used to accept a boolean value, which + // corresponded to M_none or M_alpha). M_none = 0, // No transparency. M_alpha = 1, // Normal transparency, panda will sort back-to-front. M_notused, // Unused placeholder. Do not use this. @@ -83,7 +78,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -107,4 +102,3 @@ private: #include "transparencyAttrib.I" #endif - diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index da40543b53..36cdbdbf60 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -1,23 +1,19 @@ -// Filename: weakNodePath.I -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakNodePath.I + * @author drose + * @date 2004-09-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WeakNodePath:: WeakNodePath(const NodePath &node_path) : _head(node_path._head), @@ -25,11 +21,9 @@ WeakNodePath(const NodePath &node_path) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WeakNodePath:: WeakNodePath(const WeakNodePath ©) : _head(copy._head), @@ -37,64 +31,51 @@ WeakNodePath(const WeakNodePath ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WeakNodePath:: ~WeakNodePath() { } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator = -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void WeakNodePath:: operator = (const NodePath &node_path) { _head = node_path._head; _backup_key = 0; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator = -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void WeakNodePath:: operator = (const WeakNodePath ©) { _head = copy._head; _backup_key = copy._backup_key; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::is_empty -// Access: Public -// Description: Returns true if the NodePath contains no nodes, or if -// it has been deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NodePath contains no nodes, or if it has been deleted. + */ INLINE bool WeakNodePath:: is_empty() const { return _head == (NodePathComponent *)NULL || _head.was_deleted(); } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::was_deleted -// Access: Public -// Description: Returns true if the NodePath we were referencing has -// been quietly deleted outside of the WeakNodePath. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the NodePath we were referencing has been quietly deleted + * outside of the WeakNodePath. + */ INLINE bool WeakNodePath:: was_deleted() const { return _head != (NodePathComponent *)NULL && _head.was_deleted(); } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::get_node_path -// Access: Public -// Description: Returns the NodePath held within this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath held within this object. + */ INLINE NodePath WeakNodePath:: get_node_path() const { nassertr_always(!was_deleted(), NodePath::fail()); @@ -103,68 +84,53 @@ get_node_path() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::node -// Access: Public -// Description: Returns the PandaNode held within this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PandaNode held within this object. + */ INLINE PandaNode *WeakNodePath:: node() const { nassertr_always(!is_empty(), (PandaNode *)NULL); return _head->get_node(); } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator == -// Access: Published -// Description: Returns true if the two paths are equivalent; that -// is, if they contain the same list of nodes in the same -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are equivalent; that is, if they contain the + * same list of nodes in the same order. + */ INLINE bool WeakNodePath:: operator == (const NodePath &other) const { return _head == other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator != -// Access: Published -// Description: Returns true if the two paths are not equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are not equivalent. + */ INLINE bool WeakNodePath:: operator != (const NodePath &other) const { return _head != other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator < -// Access: Published -// Description: Returns true if this NodePath sorts before the other -// one, false otherwise. The sorting order of two -// nonequivalent NodePaths is consistent but undefined, -// and is useful only for storing NodePaths in a sorted -// container like an STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this NodePath sorts before the other one, false otherwise. + * The sorting order of two nonequivalent NodePaths is consistent but + * undefined, and is useful only for storing NodePaths in a sorted container + * like an STL set. + */ INLINE bool WeakNodePath:: operator < (const NodePath &other) const { return _head < other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::compare_to -// Access: Published -// Description: Returns a number less than zero if this NodePath -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -// -// Two NodePaths are considered equivalent if they -// consist of exactly the same list of nodes in the same -// order. Otherwise, they are different; different -// NodePaths will be ranked in a consistent but -// undefined ordering; the ordering is useful only for -// placing the NodePaths in a sorted container like an -// STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this NodePath sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * + * Two NodePaths are considered equivalent if they consist of exactly the same + * list of nodes in the same order. Otherwise, they are different; different + * NodePaths will be ranked in a consistent but undefined ordering; the + * ordering is useful only for placing the NodePaths in a sorted container + * like an STL set. + */ INLINE int WeakNodePath:: compare_to(const NodePath &other) const { if (_head != other._head) { @@ -173,57 +139,44 @@ compare_to(const NodePath &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator == -// Access: Published -// Description: Returns true if the two paths are equivalent; that -// is, if they contain the same list of nodes in the same -// order. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are equivalent; that is, if they contain the + * same list of nodes in the same order. + */ INLINE bool WeakNodePath:: operator == (const WeakNodePath &other) const { return _head == other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator != -// Access: Published -// Description: Returns true if the two paths are not equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths are not equivalent. + */ INLINE bool WeakNodePath:: operator != (const WeakNodePath &other) const { return _head != other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::operator < -// Access: Published -// Description: Returns true if this WeakNodePath sorts before the other -// one, false otherwise. The sorting order of two -// nonequivalent WeakNodePaths is consistent but undefined, -// and is useful only for storing WeakNodePaths in a sorted -// container like an STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this WeakNodePath sorts before the other one, false + * otherwise. The sorting order of two nonequivalent WeakNodePaths is + * consistent but undefined, and is useful only for storing WeakNodePaths in a + * sorted container like an STL set. + */ INLINE bool WeakNodePath:: operator < (const WeakNodePath &other) const { return _head < other._head; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::compare_to -// Access: Published -// Description: Returns a number less than zero if this WeakNodePath -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -// -// Two WeakNodePaths are considered equivalent if they -// consist of exactly the same list of nodes in the same -// order. Otherwise, they are different; different -// WeakNodePaths will be ranked in a consistent but -// undefined ordering; the ordering is useful only for -// placing the WeakNodePaths in a sorted container like an -// STL set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this WeakNodePath sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + * + * Two WeakNodePaths are considered equivalent if they consist of exactly the + * same list of nodes in the same order. Otherwise, they are different; + * different WeakNodePaths will be ranked in a consistent but undefined + * ordering; the ordering is useful only for placing the WeakNodePaths in a + * sorted container like an STL set. + */ INLINE int WeakNodePath:: compare_to(const WeakNodePath &other) const { if (_head != other._head) { @@ -232,11 +185,9 @@ compare_to(const WeakNodePath &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::get_key -// Access: Public -// Description: Returns the same values as NodePath::get_key(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the same values as NodePath::get_key(). + */ INLINE int WeakNodePath:: get_key() const { if (is_empty() || was_deleted()) { diff --git a/panda/src/pgraph/weakNodePath.cxx b/panda/src/pgraph/weakNodePath.cxx index 8c888b9c2d..a83d797cc9 100644 --- a/panda/src/pgraph/weakNodePath.cxx +++ b/panda/src/pgraph/weakNodePath.cxx @@ -1,24 +1,21 @@ -// Filename: weakNodePath.cxx -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakNodePath.cxx + * @author drose + * @date 2004-09-29 + */ #include "weakNodePath.h" -//////////////////////////////////////////////////////////////////// -// Function: WeakNodePath::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WeakNodePath:: output(ostream &out) const { if (was_deleted()) { diff --git a/panda/src/pgraph/weakNodePath.h b/panda/src/pgraph/weakNodePath.h index 357c02c529..e5b9b79c90 100644 --- a/panda/src/pgraph/weakNodePath.h +++ b/panda/src/pgraph/weakNodePath.h @@ -1,16 +1,15 @@ -// Filename: weakNodePath.h -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakNodePath.h + * @author drose + * @date 2004-09-29 + */ #ifndef WEAKNODEPATH_H #define WEAKNODEPATH_H @@ -21,19 +20,15 @@ #include "nodePathComponent.h" #include "weakPointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakNodePath -// Description : This class is a wrapper around a NodePath that, -// unlike the actual NodePath class, doesn't hold a -// reference count to the node. Thus the node may be -// detached from the scene graph and destructed at any -// time. -// -// You can call is_valid() or was_deleted() at any time -// to determine whether the node is still around; if it -// is, get_node_path() will return the associated -// NodePath. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around a NodePath that, unlike the actual NodePath + * class, doesn't hold a reference count to the node. Thus the node may be + * detached from the scene graph and destructed at any time. + * + * You can call is_valid() or was_deleted() at any time to determine whether + * the node is still around; if it is, get_node_path() will return the + * associated NodePath. + */ class EXPCL_PANDA_PGRAPH WeakNodePath { public: INLINE WeakNodePath(const NodePath &node_path); diff --git a/panda/src/pgraph/workingNodePath.I b/panda/src/pgraph/workingNodePath.I index 4528427983..83010f2009 100644 --- a/panda/src/pgraph/workingNodePath.I +++ b/panda/src/pgraph/workingNodePath.I @@ -1,26 +1,21 @@ -// Filename: workingNodePath.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file workingNodePath.I + * @author drose + * @date 2002-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::Constructor -// Access: Public -// Description: Creates a WorkingNodePath that is the same as the -// indicated NodePath. This is generally used to begin -// the traversal of a scene graph with the root -// NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Creates a WorkingNodePath that is the same as the indicated NodePath. This + * is generally used to begin the traversal of a scene graph with the root + * NodePath. + */ INLINE WorkingNodePath:: WorkingNodePath(const NodePath &start) { nassertv(!start.is_empty()); @@ -29,11 +24,9 @@ WorkingNodePath(const NodePath &start) { _node = start.node(); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WorkingNodePath:: WorkingNodePath(const WorkingNodePath ©) : _next(copy._next), @@ -44,14 +37,11 @@ WorkingNodePath(const WorkingNodePath ©) : _start != (NodePathComponent *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::Constructor -// Access: Public -// Description: Creates a WorkingNodePath that is the same as the -// indicated WorkingNodePath, plus one node. This is -// generally used to continue the traversal to the next -// node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a WorkingNodePath that is the same as the indicated + * WorkingNodePath, plus one node. This is generally used to continue the + * traversal to the next node. + */ INLINE WorkingNodePath:: WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) { _next = &parent; @@ -60,20 +50,16 @@ WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) { nassertv(_node != _next->_node); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WorkingNodePath:: ~WorkingNodePath() { } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void WorkingNodePath:: operator = (const WorkingNodePath ©) { _next = copy._next; @@ -84,12 +70,10 @@ operator = (const WorkingNodePath ©) { _start != (NodePathComponent *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::get_node_path -// Access: Public -// Description: Constructs and returns an actual NodePath that -// represents the same path we have just traversed. -//////////////////////////////////////////////////////////////////// +/** + * Constructs and returns an actual NodePath that represents the same path we + * have just traversed. + */ INLINE NodePath WorkingNodePath:: get_node_path() const { NodePath result; @@ -98,11 +82,9 @@ get_node_path() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::node -// Access: Public -// Description: Returns the node traversed to so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node traversed to so far. + */ INLINE PandaNode *WorkingNodePath:: node() const { return _node; diff --git a/panda/src/pgraph/workingNodePath.cxx b/panda/src/pgraph/workingNodePath.cxx index 6c7865c764..42e8bd7141 100644 --- a/panda/src/pgraph/workingNodePath.cxx +++ b/panda/src/pgraph/workingNodePath.cxx @@ -1,26 +1,23 @@ -// Filename: workingNodePath.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file workingNodePath.cxx + * @author drose + * @date 2002-03-16 + */ #include "workingNodePath.h" -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::is_valid -// Access: Public -// Description: Returns true if the WorkingNodePath object appears to -// be a valid NodePath reference, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the WorkingNodePath object appears to be a valid NodePath + * reference, false otherwise. + */ bool WorkingNodePath:: is_valid() const { if (_node == (PandaNode *)NULL) { @@ -34,16 +31,12 @@ is_valid() const { return _next->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::get_num_nodes -// Access: Public -// Description: Returns the number of nodes in the path from the root -// to the current node. -// -// Since a WorkingNodePath always consists of, at -// minimum, a nonempty parent NodePath and one child -// node, this method will always return at least 2. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nodes in the path from the root to the current node. + * + * Since a WorkingNodePath always consists of, at minimum, a nonempty parent + * NodePath and one child node, this method will always return at least 2. + */ int WorkingNodePath:: get_num_nodes() const { if (_next == (WorkingNodePath *)NULL) { @@ -55,14 +48,11 @@ get_num_nodes() const { return _next->get_num_nodes() + 1; } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::get_node -// Access: Public -// Description: Returns the nth node of the path, where 0 is the -// referenced (bottom) node and get_num_nodes() - 1 is -// the top node. This requires iterating through the -// path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth node of the path, where 0 is the referenced (bottom) node + * and get_num_nodes() - 1 is the top node. This requires iterating through + * the path. + */ PandaNode *WorkingNodePath:: get_node(int index) const { nassertr(index >= 0, NULL); @@ -77,25 +67,20 @@ get_node(int index) const { return _next->get_node(index - 1); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WorkingNodePath:: output(ostream &out) const { - // Cheesy and slow, but when you're outputting the thing, presumably - // you're not in a hurry. + // Cheesy and slow, but when you're outputting the thing, presumably you're + // not in a hurry. get_node_path().output(out); } -//////////////////////////////////////////////////////////////////// -// Function: WorkingNodePath::r_get_node_path -// Access: Private -// Description: The private, recursive implementation of -// get_node_path(), this returns the NodePathComponent -// representing the NodePath. -//////////////////////////////////////////////////////////////////// +/** + * The private, recursive implementation of get_node_path(), this returns the + * NodePathComponent representing the NodePath. + */ PT(NodePathComponent) WorkingNodePath:: r_get_node_path() const { if (_next == (WorkingNodePath *)NULL) { @@ -111,13 +96,13 @@ r_get_node_path() const { Thread *current_thread = Thread::get_current_thread(); int pipeline_stage = current_thread->get_pipeline_stage(); - PT(NodePathComponent) result = + PT(NodePathComponent) result = PandaNode::get_component(comp, _node, pipeline_stage, current_thread); if (result == (NodePathComponent *)NULL) { - // This means we found a disconnected chain in the - // WorkingNodePath's ancestry: the node above this node isn't - // connected. In this case, don't attempt to go higher; just - // truncate the NodePath at the bottom of the disconnect. + // This means we found a disconnected chain in the WorkingNodePath's + // ancestry: the node above this node isn't connected. In this case, + // don't attempt to go higher; just truncate the NodePath at the bottom of + // the disconnect. return PandaNode::get_top_component(_node, true, pipeline_stage, current_thread); } diff --git a/panda/src/pgraph/workingNodePath.h b/panda/src/pgraph/workingNodePath.h index 3af925b5f2..fefcb6b687 100644 --- a/panda/src/pgraph/workingNodePath.h +++ b/panda/src/pgraph/workingNodePath.h @@ -1,16 +1,15 @@ -// Filename: workingNodePath.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file workingNodePath.h + * @author drose + * @date 2002-03-16 + */ #ifndef WORKINGNODEPATH_H #define WORKINGNODEPATH_H @@ -20,28 +19,23 @@ #include "nodePath.h" #include "nodePathComponent.h" -//////////////////////////////////////////////////////////////////// -// Class : WorkingNodePath -// Description : This is a class designed to support low-overhead -// traversals of the complete scene graph, with a memory -// of the complete path through the graph at any given -// point. -// -// You could just use a regular NodePath to do this, but -// since the NodePath requires storing -// NodePathComponents on each node as it is constructed, -// and then removing them when it destructs, there is -// considerable overhead in that approach. -// -// The WorkingNodePath eliminates this overhead (but -// does not guarantee consistency if the scene graph -// changes while the path is held). -// -// At any given point, you may ask the WorkingNodePath -// for its actual NodePath, and it will construct and -// return a new NodePath representing the complete -// generated chain. -//////////////////////////////////////////////////////////////////// +/** + * This is a class designed to support low-overhead traversals of the complete + * scene graph, with a memory of the complete path through the graph at any + * given point. + * + * You could just use a regular NodePath to do this, but since the NodePath + * requires storing NodePathComponents on each node as it is constructed, and + * then removing them when it destructs, there is considerable overhead in + * that approach. + * + * The WorkingNodePath eliminates this overhead (but does not guarantee + * consistency if the scene graph changes while the path is held). + * + * At any given point, you may ask the WorkingNodePath for its actual + * NodePath, and it will construct and return a new NodePath representing the + * complete generated chain. + */ class EXPCL_PANDA_PGRAPH WorkingNodePath { public: INLINE WorkingNodePath(const NodePath &start); @@ -68,9 +62,9 @@ PUBLISHED: private: PT(NodePathComponent) r_get_node_path() const; - // Either one or the other of these pointers will be filled in, but - // never both. We maintain a linked list of WorkingNodePath - // objects, with a NodePathComponent at the head of the list. + // Either one or the other of these pointers will be filled in, but never + // both. We maintain a linked list of WorkingNodePath objects, with a + // NodePathComponent at the head of the list. const WorkingNodePath *_next; PT(NodePathComponent) _start; diff --git a/panda/src/pgraphnodes/ambientLight.I b/panda/src/pgraphnodes/ambientLight.I index 41b377778a..4b8aa4f692 100644 --- a/panda/src/pgraphnodes/ambientLight.I +++ b/panda/src/pgraphnodes/ambientLight.I @@ -1,13 +1,12 @@ -// Filename: ambientLight.I -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ambientLight.I + * @author drose + * @date 2002-03-26 + */ diff --git a/panda/src/pgraphnodes/ambientLight.cxx b/panda/src/pgraphnodes/ambientLight.cxx index f4301b68c6..d3aae3fb54 100644 --- a/panda/src/pgraphnodes/ambientLight.cxx +++ b/panda/src/pgraphnodes/ambientLight.cxx @@ -1,16 +1,15 @@ -// Filename: ambientLight.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ambientLight.cxx + * @author mike + * @date 1997-01-09 + */ #include "ambientLight.h" #include "bamWriter.h" @@ -20,64 +19,49 @@ TypeHandle AmbientLight::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AmbientLight:: -AmbientLight(const string &name) : - LightNode(name) +AmbientLight(const string &name) : + LightNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::Copy Constructor -// Access: Protected -// Description: Do not call the copy constructor directly; instead, -// use make_copy() or copy_subgraph() to make a copy of -// a node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ AmbientLight:: AmbientLight(const AmbientLight ©) : LightNode(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::get_class_priority -// Access: Published, Virtual -// Description: Returns the relative priority associated with all -// lights of this class. This priority is used to order -// lights whose instance priority (get_priority()) is -// the same--the idea is that other things being equal, -// AmbientLights (for instance) are less important than -// DirectionalLights. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative priority associated with all lights of this class. + * This priority is used to order lights whose instance priority + * (get_priority()) is the same--the idea is that other things being equal, + * AmbientLights (for instance) are less important than DirectionalLights. + */ int AmbientLight:: get_class_priority() const { return (int)CP_ambient_priority; } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *AmbientLight:: make_copy() const { return new AmbientLight(*this); } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AmbientLight:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; @@ -85,59 +69,47 @@ write(ostream &out, int indent_level) const { << "color " << get_color() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::is_ambient_light -// Access: Published, Virtual -// Description: Returns true if this is an AmbientLight, false if it -// is some other kind of light. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is an AmbientLight, false if it is some other kind of + * light. + */ bool AmbientLight:: is_ambient_light() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::bind -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AmbientLight:: bind(GraphicsStateGuardianBase *, const NodePath &, int) { - // AmbientLights aren't bound to light id's; this function should - // never be called. + // AmbientLights aren't bound to light id's; this function should never be + // called. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// AmbientLight. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type AmbientLight. + */ void AmbientLight:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AmbientLight:: write_datagram(BamWriter *manager, Datagram &dg) { LightNode::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type AmbientLight is encountered -// in the Bam file. It should create the AmbientLight -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type AmbientLight is encountered in the Bam file. It should create the + * AmbientLight and extract its information from the file. + */ TypedWritable *AmbientLight:: make_from_bam(const FactoryParams ¶ms) { AmbientLight *node = new AmbientLight(""); @@ -150,13 +122,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: AmbientLight::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AmbientLight. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AmbientLight. + */ void AmbientLight:: fillin(DatagramIterator &scan, BamReader *manager) { LightNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/ambientLight.h b/panda/src/pgraphnodes/ambientLight.h index 5083ce00af..e52122bdde 100644 --- a/panda/src/pgraphnodes/ambientLight.h +++ b/panda/src/pgraphnodes/ambientLight.h @@ -1,16 +1,15 @@ -// Filename: ambientLight.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ambientLight.h + * @author mike + * @date 1997-01-09 + */ #ifndef AMBIENTLIGHT_H #define AMBIENTLIGHT_H @@ -19,13 +18,11 @@ #include "lightNode.h" -//////////////////////////////////////////////////////////////////// -// Class : AmbientLight -// Description : A light source that seems to illuminate all points in -// space at once. This kind of light need not actually -// be part of the scene graph, since it has no meaningful -// position. -//////////////////////////////////////////////////////////////////// +/** + * A light source that seems to illuminate all points in space at once. This + * kind of light need not actually be part of the scene graph, since it has no + * meaningful position. + */ class EXPCL_PANDA_PGRAPHNODES AmbientLight : public LightNode { PUBLISHED: AmbientLight(const string &name); @@ -40,7 +37,7 @@ public: PUBLISHED: virtual int get_class_priority() const; - + public: virtual void bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id); diff --git a/panda/src/pgraphnodes/callbackNode.I b/panda/src/pgraphnodes/callbackNode.I index 6a8f8a3317..4db6cb59de 100644 --- a/panda/src/pgraphnodes/callbackNode.I +++ b/panda/src/pgraphnodes/callbackNode.I @@ -1,145 +1,113 @@ -// Filename: callbackNode.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackNode.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::set_cull_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// this node is visited during the cull traversal. This -// callback will be made during the cull thread. -// -// The cull traversal is responsible for determining -// which nodes are visible and within the view frustum, -// and for accumulating state and transform, and -// generally building up the list of CullableObjects -// that are to be eventually passed to the draw -// traversal for rendering. -// -// At the time the cull traversal callback is made, the -// node has been determined to be visible and it has -// passed the bounding-volume test, so it lies within -// the view frustum. -// -// The callback is passed an instance of a -// NodeCullCallbackData, which contains pointers to the -// CullTraverser and CullTraverserData--enough data to -// examine the current node and its place within the -// scene graph. The callback *replaces* the normal cull -// behavior, so if your callback does nothing, the cull -// traversal will not continue below this node. If you -// wish the cull traversal to continue to visit this -// node and below, you must call cbdata->upcall() -// from your callback. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when this node is visited + * during the cull traversal. This callback will be made during the cull + * thread. + * + * The cull traversal is responsible for determining which nodes are visible + * and within the view frustum, and for accumulating state and transform, and + * generally building up the list of CullableObjects that are to be eventually + * passed to the draw traversal for rendering. + * + * At the time the cull traversal callback is made, the node has been + * determined to be visible and it has passed the bounding-volume test, so it + * lies within the view frustum. + * + * The callback is passed an instance of a NodeCullCallbackData, which + * contains pointers to the CullTraverser and CullTraverserData--enough data + * to examine the current node and its place within the scene graph. The + * callback *replaces* the normal cull behavior, so if your callback does + * nothing, the cull traversal will not continue below this node. If you wish + * the cull traversal to continue to visit this node and below, you must call + * cbdata->upcall() from your callback. + */ INLINE void CallbackNode:: set_cull_callback(CallbackObject *object) { CDWriter cdata(_cycler); cdata->_cull_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::clear_cull_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_cull_callback(). + */ INLINE void CallbackNode:: clear_cull_callback() { set_cull_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::get_cull_callback -// Access: Published -// Description: Returns the CallbackObject set by set_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_cull_callback(). + */ INLINE CallbackObject *CallbackNode:: get_cull_callback() const { CDReader cdata(_cycler); return cdata->_cull_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::set_draw_callback -// Access: Published -// Description: Sets the CallbackObject that will be notified when -// this node is visited during the draw traversal. This -// callback will be made during the draw thread. -// -// The draw traversal is responsible for actually -// issuing the commands to the graphics engine to draw -// primitives. Its job is to walk through the list of -// CullableObjects build up by the cull traversal, as -// quickly as possible, issuing the appropriate commands -// to draw each one. -// -// At the time the draw traversal callback is made, the -// graphics state has been loaded with the correct -// modelview transform and render state, and the -// primitives (if any) in this node are ready to be -// drawn. -// -// The callback is passed an instance of a -// GeomDrawCallbackData, which contains pointers to the -// current state and transform, as well as the current -// GSG. There is a Geom pointer as well, but it will -// always be NULL to this callback, since the -// CallbackNode does not itself contain any Geoms. -//////////////////////////////////////////////////////////////////// +/** + * Sets the CallbackObject that will be notified when this node is visited + * during the draw traversal. This callback will be made during the draw + * thread. + * + * The draw traversal is responsible for actually issuing the commands to the + * graphics engine to draw primitives. Its job is to walk through the list of + * CullableObjects build up by the cull traversal, as quickly as possible, + * issuing the appropriate commands to draw each one. + * + * At the time the draw traversal callback is made, the graphics state has + * been loaded with the correct modelview transform and render state, and the + * primitives (if any) in this node are ready to be drawn. + * + * The callback is passed an instance of a GeomDrawCallbackData, which + * contains pointers to the current state and transform, as well as the + * current GSG. There is a Geom pointer as well, but it will always be NULL + * to this callback, since the CallbackNode does not itself contain any Geoms. + */ INLINE void CallbackNode:: set_draw_callback(CallbackObject *object) { CDWriter cdata(_cycler); cdata->_draw_callback = object; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::clear_draw_callback -// Access: Published -// Description: Removes the callback set by an earlier call to -// set_draw_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the callback set by an earlier call to set_draw_callback(). + */ INLINE void CallbackNode:: clear_draw_callback() { set_draw_callback(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::get_draw_callback -// Access: Published -// Description: Returns the CallbackObject set by set_draw_callback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the CallbackObject set by set_draw_callback(). + */ INLINE CallbackObject *CallbackNode:: get_draw_callback() const { CDReader cdata(_cycler); return cdata->_draw_callback; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackNode::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackNode::CData:: CData(const CallbackNode::CData ©) : _cull_callback(copy._cull_callback), diff --git a/panda/src/pgraphnodes/callbackNode.cxx b/panda/src/pgraphnodes/callbackNode.cxx index 03405835b0..17424d5a0a 100644 --- a/panda/src/pgraphnodes/callbackNode.cxx +++ b/panda/src/pgraphnodes/callbackNode.cxx @@ -1,16 +1,15 @@ -// Filename: callbackNode.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackNode.cxx + * @author drose + * @date 2009-03-13 + */ #include "pandabase.h" #include "callbackNode.h" @@ -23,30 +22,25 @@ TypeHandle CallbackNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CallbackNode:: CallbackNode(const string &name) : PandaNode(name) { PandaNode::set_cull_callback(); - // Set up a default, infinite bounding volume, unless the user tells - // us otherwise. Not sure if this is a great idea, because it means - // a naive user will never set the bounding volume and always - // trigger the callback--but that's not altogether a bad default - // behavior. + // Set up a default, infinite bounding volume, unless the user tells us + // otherwise. Not sure if this is a great idea, because it means a naive + // user will never set the bounding volume and always trigger the callback-- + // but that's not altogether a bad default behavior. set_internal_bounds(new OmniBoundingVolume); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CallbackNode:: CallbackNode(const CallbackNode ©) : PandaNode(copy), @@ -54,59 +48,45 @@ CallbackNode(const CallbackNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *CallbackNode:: make_copy() const { return new CallbackNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool CallbackNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool CallbackNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { CallbackObject *cbobj = get_cull_callback(); @@ -122,29 +102,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool CallbackNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::add_for_draw -// Access: Public, Virtual -// Description: Adds the node's contents to the CullResult we are -// building up during the cull traversal, so that it -// will be drawn at render time. For most nodes other -// than GeomNodes, this is a do-nothing operation. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node's contents to the CullResult we are building up during the + * cull traversal, so that it will be drawn at render time. For most nodes + * other than GeomNodes, this is a do-nothing operation. + */ void CallbackNode:: add_for_draw(CullTraverser *trav, CullTraverserData &data) { if (pgraph_cat.is_spam()) { @@ -154,8 +127,8 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } // OK, render this node. Rendering this node means creating a - // CullableObject for the draw_callback, if any. We don't need to - // pass any Geoms, however. + // CullableObject for the draw_callback, if any. We don't need to pass any + // Geoms, however. CallbackObject *cbobj = get_draw_callback(); if (cbobj != (CallbackObject *)NULL) { CullableObject *object = @@ -166,50 +139,39 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void CallbackNode:: output(ostream &out) const { PandaNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// CallbackNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type CallbackNode. + */ void CallbackNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CallbackNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type CallbackNode is encountered -// in the Bam file. It should create the CallbackNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type CallbackNode is encountered in the Bam file. It should create the + * CallbackNode and extract its information from the file. + */ TypedWritable *CallbackNode:: make_from_bam(const FactoryParams ¶ms) { CallbackNode *node = new CallbackNode(""); @@ -222,46 +184,36 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CallbackNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CallbackNode. + */ void CallbackNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *CallbackNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CallbackNode::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { } -//////////////////////////////////////////////////////////////////// -// Function: CallbackNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new CallbackNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new CallbackNode. + */ void CallbackNode::CData:: fillin(DatagramIterator &scan, BamReader *manager) { } diff --git a/panda/src/pgraphnodes/callbackNode.h b/panda/src/pgraphnodes/callbackNode.h index e17d52a789..22f1f0f00b 100644 --- a/panda/src/pgraphnodes/callbackNode.h +++ b/panda/src/pgraphnodes/callbackNode.h @@ -1,16 +1,15 @@ -// Filename: callbackNode.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackNode.h + * @author drose + * @date 2009-03-13 + */ #ifndef CALLBACKNODE_H #define CALLBACKNODE_H @@ -20,11 +19,10 @@ #include "callbackObject.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : CallbackNode -// Description : A special node that can issue arbitrary callbacks to -// user code, either during the cull or draw traversals. -//////////////////////////////////////////////////////////////////// +/** + * A special node that can issue arbitrary callbacks to user code, either + * during the cull or draw traversals. + */ class EXPCL_PANDA_PGRAPHNODES CallbackNode : public PandaNode { PUBLISHED: CallbackNode(const string &name); diff --git a/panda/src/pgraphnodes/computeNode.I b/panda/src/pgraphnodes/computeNode.I index 156657be3c..80d93e73ac 100644 --- a/panda/src/pgraphnodes/computeNode.I +++ b/panda/src/pgraphnodes/computeNode.I @@ -1,75 +1,59 @@ -// Filename: computeNode.I -// Created by: rdb (20Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file computeNode.I + * @author rdb + * @date 2014-06-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::add_dispatch -// Access: Published -// Description: Adds a dispatch command with the given number of -// work groups in the X, Y, and Z dimensions. Any -// of these values may be set to 1 if the respective -// dimension should not be used. -//////////////////////////////////////////////////////////////////// +/** + * Adds a dispatch command with the given number of work groups in the X, Y, + * and Z dimensions. Any of these values may be set to 1 if the respective + * dimension should not be used. + */ INLINE void ComputeNode:: add_dispatch(const LVecBase3i &num_groups) { Dispatcher::CDWriter cdata(_dispatcher->_cycler); cdata->_dispatches.push_back(num_groups); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::add_dispatch -// Access: Published -// Description: Adds a dispatch command with the given number of -// work groups in the X, Y, and Z dimensions. Any -// of these values may be set to 1 if the respective -// dimension should not be used. -//////////////////////////////////////////////////////////////////// +/** + * Adds a dispatch command with the given number of work groups in the X, Y, + * and Z dimensions. Any of these values may be set to 1 if the respective + * dimension should not be used. + */ INLINE void ComputeNode:: add_dispatch(int num_groups_x, int num_groups_y, int num_groups_z) { LVecBase3i num_groups(num_groups_x, num_groups_y, num_groups_z); add_dispatch(num_groups); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::clear_dispatches -// Access: Published -// Description: Removes all dispatch commands. -//////////////////////////////////////////////////////////////////// +/** + * Removes all dispatch commands. + */ INLINE void ComputeNode:: clear_dispatches() { Dispatcher::CDWriter cdata(_dispatcher->_cycler); cdata->_dispatches.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::get_num_dispatches -// Access: Published -// Description: Returns the number of times add_dispatch has been -// called on this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times add_dispatch has been called on this object. + */ INLINE int ComputeNode:: get_num_dispatches() const { Dispatcher::CDReader cdata(_dispatcher->_cycler); return cdata->_dispatches.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::get_dispatch -// Access: Published -// Description: Returns the group counts of the nth dispatch -// associated with this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the group counts of the nth dispatch associated with this object. + */ INLINE const LVecBase3i &ComputeNode:: get_dispatch(int n) const { Dispatcher::CDReader cdata(_dispatcher->_cycler); @@ -77,20 +61,16 @@ get_dispatch(int n) const { return cdata->_dispatches[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ComputeNode::Dispatcher::CData:: CData() { } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ComputeNode::Dispatcher::CData:: CData(const ComputeNode::Dispatcher::CData ©) : _dispatches(copy._dispatches) diff --git a/panda/src/pgraphnodes/computeNode.cxx b/panda/src/pgraphnodes/computeNode.cxx index fd733e62e8..7962378afa 100644 --- a/panda/src/pgraphnodes/computeNode.cxx +++ b/panda/src/pgraphnodes/computeNode.cxx @@ -1,16 +1,15 @@ -// Filename: computeNode.cxx -// Created by: rdb (19Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file computeNode.cxx + * @author rdb + * @date 2014-06-19 + */ #include "pandabase.h" #include "computeNode.h" @@ -23,13 +22,10 @@ TypeHandle ComputeNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Constructor -// Access: Published -// Description: Creates a ComputeNode with the given name. Use -// add_dispatch and also assign a shader using a -// ShaderAttrib. -//////////////////////////////////////////////////////////////////// +/** + * Creates a ComputeNode with the given name. Use add_dispatch and also + * assign a shader using a ShaderAttrib. + */ ComputeNode:: ComputeNode(const string &name) : PandaNode(name), @@ -38,11 +34,9 @@ ComputeNode(const string &name) : set_internal_bounds(new OmniBoundingVolume); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ComputeNode:: ComputeNode(const ComputeNode ©) : PandaNode(copy), @@ -50,57 +44,43 @@ ComputeNode(const ComputeNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *ComputeNode:: make_copy() const { return new ComputeNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool ComputeNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool ComputeNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::add_for_draw -// Access: Public, Virtual -// Description: Adds the node's contents to the CullResult we are -// building up during the cull traversal, so that it -// will be drawn at render time. For most nodes other -// than GeomNodes, this is a do-nothing operation. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node's contents to the CullResult we are building up during the + * cull traversal, so that it will be drawn at render time. For most nodes + * other than GeomNodes, this is a do-nothing operation. + */ void ComputeNode:: add_for_draw(CullTraverser *trav, CullTraverserData &data) { if (pgraph_cat.is_spam()) { @@ -110,8 +90,8 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } // OK, render this node. Rendering this node means creating a - // CullableObject for the Dispatcher. We don't need to pass - // any Geoms, however. + // CullableObject for the Dispatcher. We don't need to pass any Geoms, + // however. CullableObject *object = new CullableObject(NULL, data._state, data.get_internal_transform(trav)); @@ -119,44 +99,35 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { trav->get_cull_handler()->record_object(object, trav); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void ComputeNode:: output(ostream &out) const { PandaNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ComputeNode::Dispatcher:: Dispatcher() { } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ComputeNode::Dispatcher:: Dispatcher(const Dispatcher ©) : _cycler(copy._cycler) { } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::do_callback -// Access: Public, Virtual -// Description: Asks the GSG to dispatch the compute shader. -//////////////////////////////////////////////////////////////////// +/** + * Asks the GSG to dispatch the compute shader. + */ void ComputeNode::Dispatcher:: do_callback(CallbackData *cbdata) { GeomDrawCallbackData *data = (GeomDrawCallbackData *)cbdata; @@ -172,37 +143,29 @@ do_callback(CallbackData *cbdata) { // No need to upcall; we don't have any geometry, after all. } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ComputeNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ComputeNode. + */ void ComputeNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ComputeNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _dispatcher->_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ComputeNode is encountered -// in the Bam file. It should create the ComputeNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ComputeNode is encountered in the Bam file. It should create the + * ComputeNode and extract its information from the file. + */ TypedWritable *ComputeNode:: make_from_bam(const FactoryParams ¶ms) { ComputeNode *node = new ComputeNode(""); @@ -215,35 +178,28 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ComputeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ComputeNode. + */ void ComputeNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); manager->read_cdata(scan, _dispatcher->_cycler); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *ComputeNode::Dispatcher::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void ComputeNode::Dispatcher::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint16(_dispatches.size()); @@ -254,13 +210,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ComputeNode::Dispatcher::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ComputeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ComputeNode. + */ void ComputeNode::Dispatcher::CData:: fillin(DatagramIterator &scan, BamReader *manager) { int num_dispatches = scan.get_uint16(); diff --git a/panda/src/pgraphnodes/computeNode.h b/panda/src/pgraphnodes/computeNode.h index 94f2086c10..feeea69006 100644 --- a/panda/src/pgraphnodes/computeNode.h +++ b/panda/src/pgraphnodes/computeNode.h @@ -1,16 +1,15 @@ -// Filename: computeNode.h -// Created by: rdb (19Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file computeNode.h + * @author rdb + * @date 2014-06-19 + */ #ifndef COMPUTENODE_H #define COMPUTENODE_H @@ -21,12 +20,10 @@ #include "callbackNode.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : ComputeNode -// Description : A special node, the sole purpose of which is to -// invoke a dispatch operation on the assigned -// compute shader. -//////////////////////////////////////////////////////////////////// +/** + * A special node, the sole purpose of which is to invoke a dispatch operation + * on the assigned compute shader. + */ class EXPCL_PANDA_PGRAPHNODES ComputeNode : public PandaNode { PUBLISHED: ComputeNode(const string &name); diff --git a/panda/src/pgraphnodes/config_pgraphnodes.cxx b/panda/src/pgraphnodes/config_pgraphnodes.cxx index 0973afe91a..4623b44d78 100644 --- a/panda/src/pgraphnodes/config_pgraphnodes.cxx +++ b/panda/src/pgraphnodes/config_pgraphnodes.cxx @@ -1,16 +1,15 @@ -// Filename: config_pgraphnodes.cxx -// Created by: drose (05Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgraphnodes.cxx + * @author drose + * @date 2008-11-05 + */ #include "config_pgraphnodes.h" @@ -94,14 +93,12 @@ ConfigVariableDouble parallax_mapping_scale "how much influence the height values have on the texture " "coordinates.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpgraphnodes -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpgraphnodes() { static bool initialized = false; diff --git a/panda/src/pgraphnodes/config_pgraphnodes.h b/panda/src/pgraphnodes/config_pgraphnodes.h index 955798fd22..f633f5bebd 100644 --- a/panda/src/pgraphnodes/config_pgraphnodes.h +++ b/panda/src/pgraphnodes/config_pgraphnodes.h @@ -1,16 +1,15 @@ -// Filename: config_pgraphnodes.h -// Created by: drose (05Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgraphnodes.h + * @author drose + * @date 2008-11-05 + */ #ifndef CONFIG_PGRAPHNODES_H #define CONFIG_PGRAPHNODES_H diff --git a/panda/src/pgraphnodes/directionalLight.I b/panda/src/pgraphnodes/directionalLight.I index 66c2056900..30b6a00188 100644 --- a/panda/src/pgraphnodes/directionalLight.I +++ b/panda/src/pgraphnodes/directionalLight.I @@ -1,23 +1,19 @@ -// Filename: directionalLight.I -// Created by: mike (04eb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directionalLight.I + * @author mike + * @date 1999-02-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DirectionalLight::CData:: CData() : _specular_color(1.0f, 1.0f, 1.0f, 1.0f), @@ -26,11 +22,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DirectionalLight::CData:: CData(const DirectionalLight::CData ©) : _specular_color(copy._specular_color), @@ -39,12 +33,10 @@ CData(const DirectionalLight::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::get_specular_color -// Access: Public, Final -// Description: Returns the color of specular highlights generated by -// the light. This is usually the same as get_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of specular highlights generated by the light. This is + * usually the same as get_color(). + */ INLINE const LColor &DirectionalLight:: get_specular_color() const { if (_has_specular_color) { @@ -55,12 +47,9 @@ get_specular_color() const { } } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::set_specular_color -// Access: Public -// Description: Sets the color of specular highlights generated by -// the light. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of specular highlights generated by the light. + */ INLINE void DirectionalLight:: set_specular_color(const LColor &color) { CDWriter cdata(_cycler); @@ -68,40 +57,32 @@ set_specular_color(const LColor &color) { cdata->_specular_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::clear_specular_color -// Access: Public -// Description: Clears a custom specular color setting, meaning that -// the specular color will now come from the color. -//////////////////////////////////////////////////////////////////// +/** + * Clears a custom specular color setting, meaning that the specular color + * will now come from the color. + */ INLINE void DirectionalLight:: clear_specular_color() { _has_specular_color = false; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::get_point -// Access: Public -// Description: Returns the point in space at which the light is -// located. This is local to the coordinate space in -// which the light is assigned. -// -// This actually has no bearing on the visual effect of -// the light, since the light is rendered as if it were -// infinitely far away. This is only used to create a -// visible representation of the light. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space at which the light is located. This is local to + * the coordinate space in which the light is assigned. + * + * This actually has no bearing on the visual effect of the light, since the + * light is rendered as if it were infinitely far away. This is only used to + * create a visible representation of the light. + */ INLINE const LPoint3 &DirectionalLight:: get_point() const { CDReader cdata(_cycler); return cdata->_point; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::set_point -// Access: Public -// Description: Sets the point in space at which the light is located. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point in space at which the light is located. + */ INLINE void DirectionalLight:: set_point(const LPoint3 &point) { CDWriter cdata(_cycler); @@ -109,24 +90,19 @@ set_point(const LPoint3 &point) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::get_direction -// Access: Public -// Description: Returns the direction in which the light is aimed. -// This is local to the coordinate space in which the -// light is assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction in which the light is aimed. This is local to the + * coordinate space in which the light is assigned. + */ INLINE const LVector3 &DirectionalLight:: get_direction() const { CDReader cdata(_cycler); return cdata->_direction; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::set_direction -// Access: Public -// Description: Sets the direction in which the light is aimed. -//////////////////////////////////////////////////////////////////// +/** + * Sets the direction in which the light is aimed. + */ INLINE void DirectionalLight:: set_direction(const LVector3 &direction) { CDWriter cdata(_cycler); diff --git a/panda/src/pgraphnodes/directionalLight.cxx b/panda/src/pgraphnodes/directionalLight.cxx index 0ad4a558ea..3c9481afa3 100644 --- a/panda/src/pgraphnodes/directionalLight.cxx +++ b/panda/src/pgraphnodes/directionalLight.cxx @@ -1,16 +1,15 @@ -// Filename: directionalLight.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directionalLight.cxx + * @author mike + * @date 1997-01-09 + */ #include "directionalLight.h" #include "orthographicLens.h" @@ -22,22 +21,18 @@ TypeHandle DirectionalLight::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *DirectionalLight::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DirectionalLight::CData:: write_datagram(BamWriter *, Datagram &dg) const { _specular_color.write_datagram(dg); @@ -45,13 +40,10 @@ write_datagram(BamWriter *, Datagram &dg) const { _direction.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void DirectionalLight::CData:: fillin(DatagramIterator &scan, BamReader *) { _specular_color.read_datagram(scan); @@ -59,25 +51,20 @@ fillin(DatagramIterator &scan, BamReader *) { _direction.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DirectionalLight:: -DirectionalLight(const string &name) : +DirectionalLight(const string &name) : LightLensNode(name, new OrthographicLens()), _has_specular_color(false) { } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::Copy Constructor -// Access: Protected -// Description: Do not call the copy constructor directly; instead, -// use make_copy() or copy_subgraph() to make a copy of -// a node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ DirectionalLight:: DirectionalLight(const DirectionalLight ©) : LightLensNode(copy), @@ -86,27 +73,20 @@ DirectionalLight(const DirectionalLight ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *DirectionalLight:: make_copy() const { return new DirectionalLight(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void DirectionalLight:: xform(const LMatrix4 &mat) { LightLensNode::xform(mat); @@ -116,11 +96,9 @@ xform(const LMatrix4 &mat) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DirectionalLight:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; @@ -134,25 +112,20 @@ write(ostream &out, int indent_level) const { << "direction " << get_direction() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::get_vector_to_light -// Access: Public, Virtual -// Description: Computes the vector from a particular vertex to this -// light. The exact vector depends on the type of light -// (e.g. point lights return a different result than -// directional lights). -// -// The input parameters are the vertex position in -// question, expressed in object space, and the matrix -// which converts from light space to object space. The -// result is expressed in object space. -// -// The return value is true if the result is successful, -// or false if it cannot be computed (e.g. for an -// ambient light). -//////////////////////////////////////////////////////////////////// +/** + * Computes the vector from a particular vertex to this light. The exact + * vector depends on the type of light (e.g. point lights return a different + * result than directional lights). + * + * The input parameters are the vertex position in question, expressed in + * object space, and the matrix which converts from light space to object + * space. The result is expressed in object space. + * + * The return value is true if the result is successful, or false if it cannot + * be computed (e.g. for an ambient light). + */ bool DirectionalLight:: -get_vector_to_light(LVector3 &result, const LPoint3 &, +get_vector_to_light(LVector3 &result, const LPoint3 &, const LMatrix4 &to_object_space) { CDReader cdata(_cycler); result = -(cdata->_direction * to_object_space); @@ -160,48 +133,37 @@ get_vector_to_light(LVector3 &result, const LPoint3 &, return true; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::get_class_priority -// Access: Published, Virtual -// Description: Returns the relative priority associated with all -// lights of this class. This priority is used to order -// lights whose instance priority (get_priority()) is -// the same--the idea is that other things being equal, -// AmbientLights (for instance) are less important than -// DirectionalLights. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative priority associated with all lights of this class. + * This priority is used to order lights whose instance priority + * (get_priority()) is the same--the idea is that other things being equal, + * AmbientLights (for instance) are less important than DirectionalLights. + */ int DirectionalLight:: get_class_priority() const { return (int)CP_directional_priority; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::bind -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DirectionalLight:: bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id) { gsg->bind_light(this, light, light_id); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// DirectionalLight. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type DirectionalLight. + */ void DirectionalLight:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void DirectionalLight:: write_datagram(BamWriter *manager, Datagram &dg) { LightLensNode::write_datagram(manager, dg); @@ -209,14 +171,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type DirectionalLight is encountered -// in the Bam file. It should create the DirectionalLight -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type DirectionalLight is encountered in the Bam file. It should create the + * DirectionalLight and extract its information from the file. + */ TypedWritable *DirectionalLight:: make_from_bam(const FactoryParams ¶ms) { DirectionalLight *node = new DirectionalLight(""); @@ -229,13 +188,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: DirectionalLight::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new DirectionalLight. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new DirectionalLight. + */ void DirectionalLight:: fillin(DatagramIterator &scan, BamReader *manager) { LightLensNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/directionalLight.h b/panda/src/pgraphnodes/directionalLight.h index 0bfde2c8cb..5f0404b9a8 100644 --- a/panda/src/pgraphnodes/directionalLight.h +++ b/panda/src/pgraphnodes/directionalLight.h @@ -1,16 +1,15 @@ -// Filename: directionalLight.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file directionalLight.h + * @author mike + * @date 1997-01-09 + */ #ifndef DIRECTIONALLIGHT_H #define DIRECTIONALLIGHT_H @@ -19,11 +18,10 @@ #include "lightLensNode.h" -//////////////////////////////////////////////////////////////////// -// Class : DirectionalLight -// Description : A light shining from infinitely far away in a -// particular direction, like sunlight. -//////////////////////////////////////////////////////////////////// +/** + * A light shining from infinitely far away in a particular direction, like + * sunlight. + */ class EXPCL_PANDA_PGRAPHNODES DirectionalLight : public LightLensNode { PUBLISHED: DirectionalLight(const string &name); diff --git a/panda/src/pgraphnodes/fadeLodNode.I b/panda/src/pgraphnodes/fadeLodNode.I index 577db0d034..41f7d79299 100644 --- a/panda/src/pgraphnodes/fadeLodNode.I +++ b/panda/src/pgraphnodes/fadeLodNode.I @@ -1,73 +1,57 @@ -// Filename: fadeLodNode.I -// Created by: sshodhan (14Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fadeLodNode.I + * @author sshodhan + * @date 2004-06-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::set_fade_time -// Access: Published -// Description: set the time taken to complete an LOD switch -//////////////////////////////////////////////////////////////////// +/** + * set the time taken to complete an LOD switch + */ INLINE void FadeLODNode:: set_fade_time(PN_stdfloat t) { _fade_time = t; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_time -// Access: Published -// Description: get the time taken to complete an LOD switch -//////////////////////////////////////////////////////////////////// +/** + * get the time taken to complete an LOD switch + */ INLINE PN_stdfloat FadeLODNode:: get_fade_time() const { return _fade_time; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_bin_name -// Access: Published -// Description: Returns the cull bin that is assigned to the fading -// part of the geometry during a transition. -//////////////////////////////////////////////////////////////////// +/** + * Returns the cull bin that is assigned to the fading part of the geometry + * during a transition. + */ INLINE const string &FadeLODNode:: get_fade_bin_name() const { return _fade_bin_name; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_bin_draw_order -// Access: Published -// Description: Returns the draw order that is assigned (along with -// the bin name) to the fading part of the geometry -// during a transition. -//////////////////////////////////////////////////////////////////// +/** + * Returns the draw order that is assigned (along with the bin name) to the + * fading part of the geometry during a transition. + */ INLINE int FadeLODNode:: get_fade_bin_draw_order() const { return _fade_bin_draw_order; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_state_override -// Access: Published -// Description: Returns the override value that is applied to the -// state changes necessary to apply the fade effect. -// This should be larger than any attrib overrides on -// the fading geometry. -//////////////////////////////////////////////////////////////////// +/** + * Returns the override value that is applied to the state changes necessary + * to apply the fade effect. This should be larger than any attrib overrides + * on the fading geometry. + */ INLINE int FadeLODNode:: get_fade_state_override() const { return _fade_state_override; } - - diff --git a/panda/src/pgraphnodes/fadeLodNode.cxx b/panda/src/pgraphnodes/fadeLodNode.cxx index 0c339b77a0..5f1f8d15ec 100644 --- a/panda/src/pgraphnodes/fadeLodNode.cxx +++ b/panda/src/pgraphnodes/fadeLodNode.cxx @@ -1,16 +1,15 @@ -// Filename: fadeLodNode.cxx -// Created by: sshodhan (14Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fadeLodNode.cxx + * @author sshodhan + * @date 2004-06-14 + */ #include "fadeLodNode.h" #include "fadeLodNodeData.h" @@ -25,14 +24,12 @@ TypeHandle FadeLODNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FadeLODNode:: FadeLODNode(const string &name) : - LODNode(name) + LODNode(name) { set_cull_callback(); @@ -42,11 +39,9 @@ FadeLODNode(const string &name) : _fade_state_override = lod_fade_state_override; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FadeLODNode:: FadeLODNode(const FadeLODNode ©) : LODNode(copy) @@ -57,44 +52,34 @@ FadeLODNode(const FadeLODNode ©) : _fade_state_override = copy._fade_state_override; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *FadeLODNode:: make_copy() const { return new FadeLODNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool FadeLODNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { if (!support_fade_lod) { @@ -109,14 +94,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { Camera *camera = trav->get_scene()->get_camera_node(); NodePath this_np = data._node_path.get_node_path(); - FadeLODNodeData *ldata = + FadeLODNodeData *ldata = DCAST(FadeLODNodeData, camera->get_aux_scene_data(this_np)); double now = ClockObject::get_global_clock()->get_frame_time(); if (ldata == (AuxSceneData *)NULL || now > ldata->get_expiration_time()) { - // This is the first time we have rendered this instance of this - // LOD node in a while. + // This is the first time we have rendered this instance of this LOD node + // in a while. ldata = new FadeLODNodeData; ldata->_fade_mode = FadeLODNodeData::FM_solid; ldata->_fade_out = -1; @@ -124,32 +109,31 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { camera->set_aux_scene_data(this_np, ldata); } else { - // We had rendered this LOD node last frame (or not too long ago, - // at least). + // We had rendered this LOD node last frame (or not too long ago, at + // least). if (ldata->_fade_mode == FadeLODNodeData::FM_solid) { - // We were drawing just one solid child last frame; check whether - // it's time to begin a transition. + // We were drawing just one solid child last frame; check whether it's + // time to begin a transition. int index = compute_child(trav, data); if (index != ldata->_fade_in) { // Start a transition. if (index >= 0 && ldata->_fade_in >= 0 && get_out(index) > get_out(ldata->_fade_in)) { - // We are fading from a more-detailed model to a - // less-detailed model. + // We are fading from a more-detailed model to a less-detailed + // model. ldata->_fade_mode = FadeLODNodeData::FM_less_detail; } else { - // We are fading from a less-detailed model to a - // more-detailed model. + // We are fading from a less-detailed model to a more-detailed + // model. ldata->_fade_mode = FadeLODNodeData::FM_more_detail; } - - // We start the fade as of the last frame we actually rendered; - // that way, if the object happened to be offscreen for a large - // part of the fade, we'll just view the tail end of it--a - // little nicer. + + // We start the fade as of the last frame we actually rendered; that + // way, if the object happened to be offscreen for a large part of the + // fade, we'll just view the tail end of it--a little nicer. ldata->_fade_start = ldata->get_last_render_time(); - ldata->_fade_out = ldata->_fade_in; + ldata->_fade_out = ldata->_fade_in; ldata->_fade_in = index; } } @@ -158,7 +142,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Play the transition. PN_stdfloat elapsed = now - ldata->_fade_start; - + if (elapsed >= _fade_time) { // Transition complete. ldata->_fade_mode = FadeLODNodeData::FM_solid; @@ -168,11 +152,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { int in_child = ldata->_fade_in; int out_child = ldata->_fade_out; - + if (ldata->_fade_mode == FadeLODNodeData::FM_less_detail) { - // If we're fading from a more-detailed model to a - // less-detailed model, reverse the fade effect for best - // visual quality. + // If we're fading from a more-detailed model to a less-detailed + // model, reverse the fade effect for best visual quality. elapsed = _fade_time - elapsed; int t = in_child; in_child = out_child; @@ -180,54 +163,52 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } nassertr(elapsed >= 0.0f && elapsed <= _fade_time, false); - + if (elapsed < half_fade_time) { - // FIRST HALF OF FADE - // Fade the new LOD in with z writing off - // Keep drawing the old LOD opaque with z writing on + // FIRST HALF OF FADE Fade the new LOD in with z writing off Keep + // drawing the old LOD opaque with z writing on if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); if (child != (PandaNode *)NULL) { CullTraverserData next_data_out(data, child); - next_data_out._state = + next_data_out._state = next_data_out._state->compose(get_fade_1_old_state()); trav->traverse(next_data_out); } } - + if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); if (child != (PandaNode *)NULL) { CullTraverserData next_data_in(data, child); - + PN_stdfloat in_alpha = elapsed / half_fade_time; - next_data_in._state = + next_data_in._state = next_data_in._state->compose(get_fade_1_new_state(in_alpha)); trav->traverse(next_data_in); } } - + } else { - // SECOND HALF OF FADE: - // Fade out the old LOD with z write off and + // SECOND HALF OF FADE: Fade out the old LOD with z write off and // draw the opaque new LOD with z write on if (in_child >= 0 && in_child < get_num_children()) { PandaNode *child = get_child(in_child); if (child != (PandaNode *)NULL) { CullTraverserData next_data_in(data, child); - next_data_in._state = + next_data_in._state = next_data_in._state->compose(get_fade_2_new_state()); trav->traverse(next_data_in); } } - + if (out_child >= 0 && out_child < get_num_children()) { PandaNode *child = get_child(out_child); if (child != (PandaNode *)NULL) { CullTraverserData next_data_out(data, child); - - PN_stdfloat out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; - next_data_out._state = + + PN_stdfloat out_alpha = 1.0f - (elapsed - half_fade_time) / half_fade_time; + next_data_out._state = next_data_out._state->compose(get_fade_2_old_state(out_alpha)); trav->traverse(next_data_out); } @@ -238,8 +219,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } if (ldata->_fade_mode == FadeLODNodeData::FM_solid) { - // This is the normal case: we're not in the middle of a - // transition; we're just drawing one child of the LOD. + // This is the normal case: we're not in the middle of a transition; we're + // just drawing one child of the LOD. int index = ldata->_fade_in; if (index >= 0 && index < get_num_children()) { PandaNode *child = get_child(index); @@ -252,28 +233,23 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { ldata->set_last_render_time(now); ldata->set_duration(_fade_time); - + return false; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FadeLODNode:: output(ostream &out) const { LODNode::output(out); out << " fade time: " << _fade_time; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::set_fade_bin -// Access: Published -// Description: Specifies the cull bin and draw order that is -// assigned to the fading part of the geometry during a -// transition. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the cull bin and draw order that is assigned to the fading part + * of the geometry during a transition. + */ void FadeLODNode:: set_fade_bin(const string &name, int draw_order) { _fade_bin_name = name; @@ -282,14 +258,11 @@ set_fade_bin(const string &name, int draw_order) { _fade_2_old_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::set_fade_state_override -// Access: Published -// Description: Specifies the override value that is applied to the -// state changes necessary to apply the fade effect. -// This should be larger than any attrib overrides on -// the fading geometry. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the override value that is applied to the state changes necessary + * to apply the fade effect. This should be larger than any attrib overrides + * on the fading geometry. + */ void FadeLODNode:: set_fade_state_override(int override) { _fade_state_override = override; @@ -299,12 +272,10 @@ set_fade_state_override(int override) { _fade_2_new_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_1_old_state -// Access: Protected -// Description: Returns a RenderState for rendering the old element -// during first half of fade. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the old element during first half of + * fade. + */ CPT(RenderState) FadeLODNode:: get_fade_1_old_state() { if (_fade_1_old_state == (const RenderState *)NULL) { @@ -314,12 +285,10 @@ get_fade_1_old_state() { return _fade_1_old_state; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_1_new_state -// Access: Protected -// Description: Returns a RenderState for rendering the new element -// during first half of fade. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the new element during first half of + * fade. + */ CPT(RenderState) FadeLODNode:: get_fade_1_new_state(PN_stdfloat in_alpha) { if (_fade_1_new_state == (const RenderState *)NULL) { @@ -335,12 +304,10 @@ get_fade_1_new_state(PN_stdfloat in_alpha) { (RenderState::make(ColorScaleAttrib::make(alpha_scale))); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_2_old_state -// Access: Protected -// Description: Returns a RenderState for rendering the old element -// during second half of fade. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the old element during second half of + * fade. + */ CPT(RenderState) FadeLODNode:: get_fade_2_old_state(PN_stdfloat out_alpha) { if (_fade_2_old_state == (const RenderState *)NULL) { @@ -356,12 +323,10 @@ get_fade_2_old_state(PN_stdfloat out_alpha) { (RenderState::make(ColorScaleAttrib::make(alpha_scale))); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::get_fade_2_new_state -// Access: Protected -// Description: Returns a RenderState for rendering the new element -// during second half of fade. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the new element during second half of + * fade. + */ CPT(RenderState) FadeLODNode:: get_fade_2_new_state() { if (_fade_2_new_state == (const RenderState *)NULL) { @@ -373,36 +338,28 @@ get_fade_2_new_state() { return _fade_2_new_state; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LODNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type LODNode. + */ void FadeLODNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void FadeLODNode:: write_datagram(BamWriter *manager, Datagram &dg) { LODNode::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type LODNode is encountered -// in the Bam file. It should create the LODNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type LODNode is encountered in the Bam file. It should create the LODNode + * and extract its information from the file. + */ TypedWritable *FadeLODNode:: make_from_bam(const FactoryParams ¶ms) { FadeLODNode *node = new FadeLODNode(""); @@ -415,13 +372,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new FadeLODNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new FadeLODNode. + */ void FadeLODNode:: fillin(DatagramIterator &scan, BamReader *manager) { LODNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/fadeLodNode.h b/panda/src/pgraphnodes/fadeLodNode.h index d11459a9ce..79930a39b4 100644 --- a/panda/src/pgraphnodes/fadeLodNode.h +++ b/panda/src/pgraphnodes/fadeLodNode.h @@ -1,16 +1,15 @@ -// Filename: fadeLodNode.h -// Created by: sshodhan (14Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fadeLodNode.h + * @author sshodhan + * @date 2004-06-14 + */ #ifndef FADELODNODE_H #define FADELODNODE_H @@ -19,10 +18,9 @@ #include "lodNode.h" -//////////////////////////////////////////////////////////////////// -// Class : FadeLODNode -// Description : A Level-of-Detail node with alpha based switching. -//////////////////////////////////////////////////////////////////// +/** + * A Level-of-Detail node with alpha based switching. + */ class EXPCL_PANDA_PGRAPHNODES FadeLODNode : public LODNode { PUBLISHED: FadeLODNode(const string &name); @@ -66,7 +64,7 @@ private: CPT(RenderState) _fade_1_old_state; CPT(RenderState) _fade_2_new_state; CPT(RenderState) _fade_2_old_state; - + public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); diff --git a/panda/src/pgraphnodes/fadeLodNodeData.cxx b/panda/src/pgraphnodes/fadeLodNodeData.cxx index 9ec669f03e..d0f0d09987 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.cxx +++ b/panda/src/pgraphnodes/fadeLodNodeData.cxx @@ -1,27 +1,24 @@ -// Filename: fadeLodNodeData.cxx -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fadeLodNodeData.cxx + * @author drose + * @date 2004-09-29 + */ #include "fadeLodNodeData.h" TypeHandle FadeLODNodeData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FadeLODNodeData::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FadeLODNodeData:: output(ostream &out) const { AuxSceneData::output(out); diff --git a/panda/src/pgraphnodes/fadeLodNodeData.h b/panda/src/pgraphnodes/fadeLodNodeData.h index b3c6306f4b..7d629d060e 100644 --- a/panda/src/pgraphnodes/fadeLodNodeData.h +++ b/panda/src/pgraphnodes/fadeLodNodeData.h @@ -1,16 +1,15 @@ -// Filename: fadeLodNodeData.h -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fadeLodNodeData.h + * @author drose + * @date 2004-09-29 + */ #ifndef FADELODNODEDATA_H #define FADELODNODEDATA_H @@ -19,11 +18,10 @@ #include "auxSceneData.h" -//////////////////////////////////////////////////////////////////// -// Class : FadeLODNodeData -// Description : This is the data that is associated with a particular -// instance of the FadeLODNode for the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * This is the data that is associated with a particular instance of the + * FadeLODNode for the scene graph. + */ class EXPCL_PANDA_PGRAPHNODES FadeLODNodeData : public AuxSceneData { public: enum FadeMode { @@ -37,7 +35,7 @@ public: int _fade_in; virtual void output(ostream &out) const; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -57,4 +55,3 @@ private: }; #endif - diff --git a/panda/src/pgraphnodes/lightLensNode.I b/panda/src/pgraphnodes/lightLensNode.I index c21a63affa..8cf9ea7eb6 100644 --- a/panda/src/pgraphnodes/lightLensNode.I +++ b/panda/src/pgraphnodes/lightLensNode.I @@ -1,38 +1,30 @@ -// Filename: lightLensNode.I -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightLensNode.I + * @author drose + * @date 2002-03-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::is_shadow_caster -// Access: Published -// Description: Returns whether this light is configured to cast -// shadows or not. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether this light is configured to cast shadows or not. + */ INLINE bool LightLensNode:: is_shadow_caster() { return _shadow_caster; } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::set_shadow_caster -// Access: Published -// Description: Sets the flag indicating whether this light should -// cast shadows or not. This is the variant without -// buffer size, meaning that the current buffer size -// will be kept (512x512 is the default). -// Note that enabling shadows will require the shader -// generator to be enabled on the scene. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether this light should cast shadows or not. + * This is the variant without buffer size, meaning that the current buffer + * size will be kept (512x512 is the default). Note that enabling shadows will + * require the shader generator to be enabled on the scene. + */ INLINE void LightLensNode:: set_shadow_caster(bool caster) { if (_shadow_caster && !caster) { @@ -42,16 +34,12 @@ set_shadow_caster(bool caster) { set_active(caster); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::set_shadow_caster -// Access: Published -// Description: Sets the flag indicating whether this light should -// cast shadows or not. The xsize and ysize parameters -// specify the size of the shadow buffer that will be -// set up, the sort parameter specifies the sort. -// Note that enabling shadows will require the shader -// generator to be enabled on the scene. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag indicating whether this light should cast shadows or not. + * The xsize and ysize parameters specify the size of the shadow buffer that + * will be set up, the sort parameter specifies the sort. Note that enabling + * shadows will require the shader generator to be enabled on the scene. + */ INLINE void LightLensNode:: set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_sort) { if ((_shadow_caster && !caster) || buffer_xsize != _sb_xsize || buffer_ysize != _sb_ysize) { @@ -71,15 +59,11 @@ set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int buffer_so set_active(caster); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::get_shadow_buffer -// Access: Published -// Description: Returns the buffer that has been constructed for -// a given GSG, or NULL if no such buffer has (yet) -// been constructed. This should be used for -// debugging only, you will not need to call this -// normally. -//////////////////////////////////////////////////////////////////// +/** + * Returns the buffer that has been constructed for a given GSG, or NULL if no + * such buffer has (yet) been constructed. This should be used for debugging + * only, you will not need to call this normally. + */ INLINE GraphicsOutputBase *LightLensNode:: get_shadow_buffer(GraphicsStateGuardianBase *gsg) { ShadowBuffers::iterator it = _sbuffers.find(gsg); diff --git a/panda/src/pgraphnodes/lightLensNode.cxx b/panda/src/pgraphnodes/lightLensNode.cxx index 4116998a80..ba1e93acac 100644 --- a/panda/src/pgraphnodes/lightLensNode.cxx +++ b/panda/src/pgraphnodes/lightLensNode.cxx @@ -1,16 +1,15 @@ -// Filename: lightLensNode.cxx -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightLensNode.cxx + * @author drose + * @date 2002-03-26 + */ #include "lightLensNode.h" #include "bamWriter.h" @@ -23,11 +22,9 @@ TypeHandle LightLensNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LightLensNode:: LightLensNode(const string &name, Lens *lens) : Camera(name, lens) @@ -37,28 +34,24 @@ LightLensNode(const string &name, Lens *lens) : _sb_xsize = 512; _sb_ysize = 512; _sb_sort = -10; - //set_initial_state(RenderState::make(ShaderAttrib::make_off(), 1000)); + // set_initial_state(RenderState::make(ShaderAttrib::make_off(), 1000)); // Backface culling helps eliminating artifacts. set_initial_state(RenderState::make(CullFaceAttrib::make_reverse(), ColorWriteAttrib::make(ColorWriteAttrib::C_off))); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LightLensNode:: ~LightLensNode() { set_active(false); clear_shadow_buffers(); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LightLensNode:: LightLensNode(const LightLensNode ©) : Light(copy), @@ -70,21 +63,18 @@ LightLensNode(const LightLensNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::clear_shadow_buffers -// Access: Protected -// Description: Clears the shadow buffers, meaning they will be -// automatically recreated when the Shader Generator -// needs them. -//////////////////////////////////////////////////////////////////// +/** + * Clears the shadow buffers, meaning they will be automatically recreated + * when the Shader Generator needs them. + */ void LightLensNode:: clear_shadow_buffers() { ShadowBuffers::iterator it; for(it = _sbuffers.begin(); it != _sbuffers.end(); ++it) { PT(Texture) tex = (*it).second->get_texture(); if (tex) { - // Clear it to all ones, so that any shaders that might still - // be using it will see the shadows being disabled. + // Clear it to all ones, so that any shaders that might still be using + // it will see the shadows being disabled. tex->set_clear_color(LColor(1)); tex->clear_image(); } @@ -93,77 +83,63 @@ clear_shadow_buffers() { _sbuffers.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::as_node -// Access: Published, Virtual -// Description: Returns the Light object upcast to a PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Light object upcast to a PandaNode. + */ PandaNode *LightLensNode:: as_node() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::as_light -// Access: Public, Virtual -// Description: Cross-casts the node to a Light pointer, if it is one -// of the four kinds of Light nodes, or returns NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Cross-casts the node to a Light pointer, if it is one of the four kinds of + * Light nodes, or returns NULL if it is not. + */ Light *LightLensNode:: as_light() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightLensNode:: output(ostream &out) const { LensNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightLensNode:: write(ostream &out, int indent_level) const { LensNode::write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LightLensNode:: write_datagram(BamWriter *manager, Datagram &dg) { Camera::write_datagram(manager, dg); Light::write_datagram(manager, dg); - + dg.add_bool(_shadow_caster); dg.add_int32(_sb_xsize); dg.add_int32(_sb_ysize); dg.add_int32(_sb_sort); } -//////////////////////////////////////////////////////////////////// -// Function: LightLensNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LightLensNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LightLensNode. + */ void LightLensNode:: fillin(DatagramIterator &scan, BamReader *manager) { Camera::fillin(scan, manager); Light::fillin(scan, manager); - + bool shadow_caster = scan.get_bool(); int sb_xsize = scan.get_int32(); int sb_ysize = scan.get_int32(); diff --git a/panda/src/pgraphnodes/lightLensNode.h b/panda/src/pgraphnodes/lightLensNode.h index a2d1afab13..205a58b660 100644 --- a/panda/src/pgraphnodes/lightLensNode.h +++ b/panda/src/pgraphnodes/lightLensNode.h @@ -1,16 +1,15 @@ -// Filename: lightLensNode.h -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightLensNode.h + * @author drose + * @date 2002-03-26 + */ #ifndef LIGHTLENSNODE_H #define LIGHTLENSNODE_H @@ -25,13 +24,11 @@ class ShaderGenerator; class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : LightLensNode -// Description : A derivative of Light and of Camera. The name might -// be misleading: it does not directly derive from -// LensNode, but through the Camera class. The Camera -// serves no purpose unless shadows are enabled. -//////////////////////////////////////////////////////////////////// +/** + * A derivative of Light and of Camera. The name might be misleading: it does + * not directly derive from LensNode, but through the Camera class. The + * Camera serves no purpose unless shadows are enabled. + */ class EXPCL_PANDA_PGRAPHNODES LightLensNode : public Light, public Camera { PUBLISHED: LightLensNode(const string &name, Lens *lens = new PerspectiveLens()); @@ -59,8 +56,8 @@ public: virtual Light *as_light(); PUBLISHED: - // We have to explicitly publish these because they resolve the - // multiple inheritance. + // We have to explicitly publish these because they resolve the multiple + // inheritance. virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/pgraphnodes/lightNode.I b/panda/src/pgraphnodes/lightNode.I index 32251859d8..fa968a8b5d 100644 --- a/panda/src/pgraphnodes/lightNode.I +++ b/panda/src/pgraphnodes/lightNode.I @@ -1,13 +1,12 @@ -// Filename: lightNode.I -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightNode.I + * @author drose + * @date 2002-03-26 + */ diff --git a/panda/src/pgraphnodes/lightNode.cxx b/panda/src/pgraphnodes/lightNode.cxx index dbdfee4496..13eae68d6d 100644 --- a/panda/src/pgraphnodes/lightNode.cxx +++ b/panda/src/pgraphnodes/lightNode.cxx @@ -1,16 +1,15 @@ -// Filename: lightNode.cxx -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightNode.cxx + * @author drose + * @date 2002-03-26 + */ #include "lightNode.h" #include "bamWriter.h" @@ -20,90 +19,72 @@ TypeHandle LightNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LightNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LightNode:: -LightNode(const string &name) : - PandaNode(name) +LightNode(const string &name) : + PandaNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LightNode:: -LightNode(const LightNode ©) : +LightNode(const LightNode ©) : Light(copy), PandaNode(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::as_node -// Access: Published, Virtual -// Description: Returns the Light object upcast to a PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Light object upcast to a PandaNode. + */ PandaNode *LightNode:: as_node() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::as_light -// Access: Public, Virtual -// Description: Cross-casts the node to a Light pointer, if it is one -// of the four kinds of Light nodes, or returns NULL if -// it is not. -//////////////////////////////////////////////////////////////////// +/** + * Cross-casts the node to a Light pointer, if it is one of the four kinds of + * Light nodes, or returns NULL if it is not. + */ Light *LightNode:: as_light() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightNode:: output(ostream &out) const { PandaNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LightNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LightNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); Light::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: LightNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LightNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LightNode. + */ void LightNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/lightNode.h b/panda/src/pgraphnodes/lightNode.h index e55ff88223..14ebbd378a 100644 --- a/panda/src/pgraphnodes/lightNode.h +++ b/panda/src/pgraphnodes/lightNode.h @@ -1,16 +1,15 @@ -// Filename: lightNode.h -// Created by: drose (26Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightNode.h + * @author drose + * @date 2002-03-26 + */ #ifndef LIGHTNODE_H #define LIGHTNODE_H @@ -20,12 +19,11 @@ #include "light.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : LightNode -// Description : A derivative of Light and of PandaNode. All kinds of -// Light except Spotlight (which must inherit from -// LensNode instead) inherit from this class. -//////////////////////////////////////////////////////////////////// +/** + * A derivative of Light and of PandaNode. All kinds of Light except + * Spotlight (which must inherit from LensNode instead) inherit from this + * class. + */ class EXPCL_PANDA_PGRAPHNODES LightNode : public Light, public PandaNode { PUBLISHED: LightNode(const string &name); @@ -38,8 +36,8 @@ public: virtual Light *as_light(); PUBLISHED: - // We have to explicitly publish these because they resolve the - // multiple inheritance. + // We have to explicitly publish these because they resolve the multiple + // inheritance. virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/pgraphnodes/lodNode.I b/panda/src/pgraphnodes/lodNode.I index e3d860d089..3a042c2aa5 100644 --- a/panda/src/pgraphnodes/lodNode.I +++ b/panda/src/pgraphnodes/lodNode.I @@ -1,24 +1,19 @@ -// Filename: lodNode.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lodNode.I + * @author drose + * @date 2002-03-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LODNode:: LODNode(const string &name) : PandaNode(name) @@ -26,11 +21,9 @@ LODNode(const string &name) : set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LODNode:: LODNode(const LODNode ©) : PandaNode(copy), @@ -38,19 +31,14 @@ LODNode(const LODNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::add_switch -// Access: Published -// Description: Adds a switch range to the LODNode. This implies -// that the corresponding child node has been parented -// to the node. -// -// The sense of in vs. out distances is as if the object -// were coming towards you from far away: it switches -// "in" at the far distance, and switches "out" at the -// close distance. Thus, "in" should be larger than -// "out". -//////////////////////////////////////////////////////////////////// +/** + * Adds a switch range to the LODNode. This implies that the corresponding + * child node has been parented to the node. + * + * The sense of in vs. out distances is as if the object were coming towards + * you from far away: it switches "in" at the far distance, and switches "out" + * at the close distance. Thus, "in" should be larger than "out". + */ INLINE void LODNode:: add_switch(PN_stdfloat in, PN_stdfloat out) { nassertv(in >= out); @@ -64,12 +52,10 @@ add_switch(PN_stdfloat in, PN_stdfloat out) { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::set_switch -// Access: Published -// Description: Changes the switching range of a particular child of -// the LODNode. See add_switch(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the switching range of a particular child of the LODNode. See + * add_switch(). + */ INLINE bool LODNode:: set_switch(int index, PN_stdfloat in, PN_stdfloat out) { nassertr(in >= out, false); @@ -86,13 +72,10 @@ set_switch(int index, PN_stdfloat in, PN_stdfloat out) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::clear_switches -// Access: Published -// Description: Removes the set of switching ranges for the LODNode, -// presumably in conjunction with removing all of its -// children. See add_switch(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the set of switching ranges for the LODNode, presumably in + * conjunction with removing all of its children. See add_switch(). + */ INLINE void LODNode:: clear_switches() { CDWriter cdata(_cycler); @@ -105,37 +88,30 @@ clear_switches() { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_num_switches -// Access: Published -// Description: Returns the number of switch ranges added to the -// LODNode. This should correspond to the number of -// children of the node in order for the LODNode to -// function correctly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of switch ranges added to the LODNode. This should + * correspond to the number of children of the node in order for the LODNode + * to function correctly. + */ INLINE int LODNode:: get_num_switches() const { CDReader cdata(_cycler); return cdata->_switch_vector.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_lod_scale -// Access: Published -// Description: Returns the multiplier for lod distances -//////////////////////////////////////////////////////////////////// +/** + * Returns the multiplier for lod distances + */ INLINE PN_stdfloat LODNode:: get_lod_scale() const { CDReader cdata(_cycler); return cdata->_lod_scale; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::set_lod_scale -// Access: Published -// Description: Sets the multiplier for lod distances. A higher -// value means you'll see farther switchs than normal -//////////////////////////////////////////////////////////////////// +/** + * Sets the multiplier for lod distances. A higher value means you'll see + * farther switchs than normal + */ INLINE void LODNode:: set_lod_scale(PN_stdfloat value) { CDWriter cdata(_cycler); @@ -143,13 +119,10 @@ set_lod_scale(PN_stdfloat value) { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_in -// Access: Published -// Description: Returns the "in" distance of the indicated switch -// range. This should be larger than the "out" distance -// of the same range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "in" distance of the indicated switch range. This should be + * larger than the "out" distance of the same range. + */ INLINE PN_stdfloat LODNode:: get_in(int index) const { CDReader cdata(_cycler); @@ -157,13 +130,10 @@ get_in(int index) const { return cdata->_switch_vector[index].get_in(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_out -// Access: Published -// Description: Returns the "out" distance of the indicated switch -// range. This should be smaller than the "in" distance -// of the same range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "out" distance of the indicated switch range. This should be + * smaller than the "in" distance of the same range. + */ INLINE PN_stdfloat LODNode:: get_out(int index) const { CDReader cdata(_cycler); @@ -171,41 +141,32 @@ get_out(int index) const { return cdata->_switch_vector[index].get_out(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_lowest_switch -// Access: Published -// Description: Returns the index number of the child with the lowest -// level of detail; that is, the one that is designed to -// be seen from the farthest away. This is usually the -// first child, but it is not necessarily so. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the child with the lowest level of detail; that + * is, the one that is designed to be seen from the farthest away. This is + * usually the first child, but it is not necessarily so. + */ INLINE int LODNode:: get_lowest_switch() const { CDReader cdata(_cycler); return cdata->_lowest; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_highest_switch -// Access: Published -// Description: Returns the index number of the child with the highest -// level of detail; that is, the one that is designed to -// be seen from the closest to the camera. This is -// usually the last child, but it is not necessarily so. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the child with the highest level of detail; + * that is, the one that is designed to be seen from the closest to the + * camera. This is usually the last child, but it is not necessarily so. + */ INLINE int LODNode:: get_highest_switch() const { CDReader cdata(_cycler); return cdata->_highest; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::force_switch -// Access: Published -// Description: Forces the LODNode to show the indicated level -// instead of the level that would normally be shown -// based on the distance from the camera. -//////////////////////////////////////////////////////////////////// +/** + * Forces the LODNode to show the indicated level instead of the level that + * would normally be shown based on the distance from the camera. + */ INLINE void LODNode:: force_switch(int index) { CDWriter cdata(_cycler); @@ -213,26 +174,21 @@ force_switch(int index) { cdata->_got_force_switch = true; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::clear_force_switch -// Access: Published -// Description: Undoes the effect of a previous call to -// force_switch() and releases the LODNode to once again -// display the normal level. -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to force_switch() and releases the + * LODNode to once again display the normal level. + */ INLINE void LODNode:: clear_force_switch() { CDWriter cdata(_cycler); cdata->_got_force_switch = false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::set_center -// Access: Published -// Description: Specifies the center of the LOD. This is the point -// that is compared to the camera (in camera space) to -// determine the particular LOD that should be chosen. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the center of the LOD. This is the point that is compared to the + * camera (in camera space) to determine the particular LOD that should be + * chosen. + */ INLINE void LODNode:: set_center(const LPoint3 ¢er) { CDWriter cdata(_cycler); @@ -243,40 +199,32 @@ set_center(const LPoint3 ¢er) { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_center -// Access: Published -// Description: Returns the center of the LOD. This is the point -// that is compared to the camera (in camera space) to -// determine the particular LOD that should be chosen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of the LOD. This is the point that is compared to the + * camera (in camera space) to determine the particular LOD that should be + * chosen. + */ INLINE const LPoint3 &LODNode:: get_center() const { CDReader cdata(_cycler); return cdata->_center; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::is_any_shown -// Access: Published -// Description: Returns true if any switch has been shown with -// show_switch(), indicating the LODNode is in debug -// show mode; or false if it is in the normal mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any switch has been shown with show_switch(), indicating + * the LODNode is in debug show mode; or false if it is in the normal mode. + */ INLINE bool LODNode:: is_any_shown() const { CDReader cdata(_cycler); return (cdata->_num_shown != 0); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::consider_verify_lods -// Access: Protected -// Description: To be called internally when the node is rendered, -// this will raise an assertion if verify-lods is -// configured true, and verify_child_bounds() returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * To be called internally when the node is rendered, this will raise an + * assertion if verify-lods is configured true, and verify_child_bounds() + * returns false. + */ INLINE void LODNode:: consider_verify_lods(CullTraverser *trav, CullTraverserData &data) { #ifndef NDEBUG @@ -286,11 +234,9 @@ consider_verify_lods(CullTraverser *trav, CullTraverserData &data) { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LODNode::CData:: CData() : _center(0.0f, 0.0f, 0.0f), @@ -303,11 +249,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LODNode::CData:: CData(const LODNode::CData ©) : _center(copy._center), @@ -322,13 +266,11 @@ CData(const LODNode::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LODNode::Switch:: -Switch(PN_stdfloat in, PN_stdfloat out) : +Switch(PN_stdfloat in, PN_stdfloat out) : _shown(false), _bounds_seq(UpdateSeq::old()), _verify_ok(false) @@ -336,31 +278,25 @@ Switch(PN_stdfloat in, PN_stdfloat out) : set_range(in, out); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::get_in -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat LODNode::Switch:: get_in() const { return _in; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::get_out -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat LODNode::Switch:: get_out() const { return _out; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::set_range -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void LODNode::Switch:: set_range(PN_stdfloat in, PN_stdfloat out) { _in = in; @@ -368,35 +304,27 @@ set_range(PN_stdfloat in, PN_stdfloat out) { clear_ring_viz(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::in_range -// Access: Public -// Description: Returns true if the indicated distance is within the -// range for the LOD. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated distance is within the range for the LOD. + */ INLINE bool LODNode::Switch:: in_range(PN_stdfloat dist) const { return (dist >= _out && dist < _in); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::in_range_2 -// Access: Public -// Description: Returns true if the indicated distance squared is -// within the range for the LOD. (The distance value is -// understood to be the square of the distance from the -// camera to the object.) -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated distance squared is within the range for the + * LOD. (The distance value is understood to be the square of the distance + * from the camera to the object.) + */ INLINE bool LODNode::Switch:: in_range_2(PN_stdfloat dist2) const { return (dist2 >= _out * _out && dist2 < _in * _in); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::rescale -// Access: Public -// Description: Scales the switching distances by the indicated factor. -//////////////////////////////////////////////////////////////////// +/** + * Scales the switching distances by the indicated factor. + */ INLINE void LODNode::Switch:: rescale(PN_stdfloat factor) { _in *= factor; @@ -404,44 +332,35 @@ rescale(PN_stdfloat factor) { clear_ring_viz(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::is_shown -// Access: Public -// Description: Returns true if show() has been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if show() has been called. + */ INLINE bool LODNode::Switch:: is_shown() const { return _shown; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::show -// Access: Public -// Description: Shows this ring in debug mode using the indicated -// color. -//////////////////////////////////////////////////////////////////// +/** + * Shows this ring in debug mode using the indicated color. + */ INLINE void LODNode::Switch:: show(const LColor &color) { _shown = true; _show_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::hide -// Access: Public -// Description: Undoes a previous call to show(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes a previous call to show(). + */ INLINE void LODNode::Switch:: hide() { _shown = false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::get_ring_viz -// Access: Public -// Description: Returns a PandaNode suitable for rendering the ring -// associated with this switch. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PandaNode suitable for rendering the ring associated with this + * switch. + */ INLINE PandaNode *LODNode::Switch:: get_ring_viz() const { if (_ring_viz.is_null()) { @@ -451,12 +370,10 @@ get_ring_viz() const { return _ring_viz; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::get_spindle_viz -// Access: Public -// Description: Returns a PandaNode suitable for rendering the center -// spindle of the LODNode, in the color of this switch. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PandaNode suitable for rendering the center spindle of the + * LODNode, in the color of this switch. + */ INLINE PandaNode *LODNode::Switch:: get_spindle_viz() const { if (_spindle_viz.is_null()) { @@ -466,13 +383,10 @@ get_spindle_viz() const { return _spindle_viz; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::get_viz_model_state -// Access: Public -// Description: Returns a RenderState suitable for drawing the -// visible children of this switch level when the -// show_switch() debugging mode is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState suitable for drawing the visible children of this + * switch level when the show_switch() debugging mode is enabled. + */ INLINE const RenderState *LODNode::Switch:: get_viz_model_state() const { if (_viz_model_state.is_null()) { @@ -482,38 +396,30 @@ get_viz_model_state() const { return _viz_model_state; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::write_datagram -// Access: Public -// Description: Writes the contents of the Switch out to the -// datagram, presumably in preparation to writing to a -// Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of the Switch out to the datagram, presumably in + * preparation to writing to a Bam file. + */ INLINE void LODNode::Switch:: write_datagram(Datagram &destination) const { destination.add_stdfloat(_in); destination.add_stdfloat(_out); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::read_datagram -// Access: Public -// Description: Reads the contents of the Switch from the datagram, -// presumably in response to reading a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the contents of the Switch from the datagram, presumably in response + * to reading a Bam file. + */ INLINE void LODNode::Switch:: read_datagram(DatagramIterator &source) { _in = source.get_stdfloat(); _out = source.get_stdfloat(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::clear_ring_viz -// Access: Private -// Description: Resets the internal cache values for the ring and -// spindle viz, and related pointers, for the -// set_switch() debugging mode. -//////////////////////////////////////////////////////////////////// +/** + * Resets the internal cache values for the ring and spindle viz, and related + * pointers, for the set_switch() debugging mode. + */ INLINE void LODNode::Switch:: clear_ring_viz() { _ring_viz.clear(); diff --git a/panda/src/pgraphnodes/lodNode.cxx b/panda/src/pgraphnodes/lodNode.cxx index 278a63c20b..5936b0634b 100644 --- a/panda/src/pgraphnodes/lodNode.cxx +++ b/panda/src/pgraphnodes/lodNode.cxx @@ -1,16 +1,15 @@ -// Filename: lodNode.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lodNode.cxx + * @author drose + * @date 2002-03-06 + */ #include "lodNode.h" #include "fadeLodNode.h" @@ -41,12 +40,10 @@ TypeHandle LODNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LODNode::make_default_lod -// Access: Published, Static -// Description: Creates a new LODNode of the type specified by the -// default-lod-type config variable. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new LODNode of the type specified by the default-lod-type config + * variable. + */ PT(LODNode) LODNode:: make_default_lod(const string &name) { switch (default_lod_type.get_value()) { @@ -55,7 +52,7 @@ make_default_lod(const string &name) { case LNT_fade: return new FadeLODNode(name); - + default: pgraph_cat.error() << "Invalid LODNodeType value: " << (int)default_lod_type << "\n"; @@ -63,55 +60,41 @@ make_default_lod(const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *LODNode:: make_copy() const { return new LODNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool LODNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool LODNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void LODNode:: xform(const LMatrix4 &mat) { CDWriter cdata(_cycler); @@ -124,38 +107,31 @@ xform(const LMatrix4 &mat) { PN_stdfloat factor = y.length(); SwitchVector::iterator si; - for (si = cdata->_switch_vector.begin(); - si != cdata->_switch_vector.end(); + for (si = cdata->_switch_vector.begin(); + si != cdata->_switch_vector.end(); ++si) { (*si).rescale(factor); } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool LODNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { if (is_any_shown()) { @@ -180,7 +156,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { in_range = sw.in_range_2(dist2 * cdata->_lod_scale * trav->get_scene()->get_camera_node()->get_lod_scale()); } - + if (in_range) { // This switch level is in range. Draw its children. PandaNode *child = get_child(index); @@ -191,16 +167,14 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } } - // Now return false indicating that we have already taken care of - // the traversal from here. + // Now return false indicating that we have already taken care of the + // traversal from here. return false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LODNode:: output(ostream &out) const { PandaNode::output(out); @@ -220,37 +194,29 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::is_lod_node -// Access: Published, Virtual -// Description: A simple downcast check. Returns true if this kind -// of node happens to inherit from LODNode, false -// otherwise. -// -// This is provided as a a faster alternative to calling -// is_of_type(LODNode::get_class_type()). -//////////////////////////////////////////////////////////////////// +/** + * A simple downcast check. Returns true if this kind of node happens to + * inherit from LODNode, false otherwise. + * + * This is provided as a a faster alternative to calling + * is_of_type(LODNode::get_class_type()). + */ bool LODNode:: is_lod_node() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::show_switch -// Access: Published -// Description: This is provided as a debugging aid. show_switch() -// will put the LODNode into a special mode where rather -// than computing and drawing the appropriate level of -// the LOD, a ring is drawn around the LODNode center -// indicating the switch distances from the camera for -// the indicated level, and the geometry of the -// indicated level is drawn in wireframe. -// -// Multiple different levels can be visualized this way -// at once. Call hide_switch() or hide_all_switches() to -// undo this mode and restore the LODNode to its normal -// behavior. -//////////////////////////////////////////////////////////////////// +/** + * This is provided as a debugging aid. show_switch() will put the LODNode + * into a special mode where rather than computing and drawing the appropriate + * level of the LOD, a ring is drawn around the LODNode center indicating the + * switch distances from the camera for the indicated level, and the geometry + * of the indicated level is drawn in wireframe. + * + * Multiple different levels can be visualized this way at once. Call + * hide_switch() or hide_all_switches() to undo this mode and restore the + * LODNode to its normal behavior. + */ void LODNode:: show_switch(int index) { CDWriter cdata(_cycler); @@ -258,22 +224,17 @@ show_switch(int index) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::show_switch -// Access: Published -// Description: This is provided as a debugging aid. show_switch() -// will put the LODNode into a special mode where rather -// than computing and drawing the appropriate level of -// the LOD, a ring is drawn around the LODNode center -// indicating the switch distances from the camera for -// the indicated level, and the geometry of the -// indicated level is drawn in wireframe. -// -// Multiple different levels can be visualized this way -// at once. Call hide_switch() or hide_all_switches() to -// undo this mode and restore the LODNode to its normal -// behavior. -//////////////////////////////////////////////////////////////////// +/** + * This is provided as a debugging aid. show_switch() will put the LODNode + * into a special mode where rather than computing and drawing the appropriate + * level of the LOD, a ring is drawn around the LODNode center indicating the + * switch distances from the camera for the indicated level, and the geometry + * of the indicated level is drawn in wireframe. + * + * Multiple different levels can be visualized this way at once. Call + * hide_switch() or hide_all_switches() to undo this mode and restore the + * LODNode to its normal behavior. + */ void LODNode:: show_switch(int index, const LColor &color) { CDWriter cdata(_cycler); @@ -281,11 +242,9 @@ show_switch(int index, const LColor &color) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::hide_switch -// Access: Published -// Description: Disables a previous call to show_switch(). -//////////////////////////////////////////////////////////////////// +/** + * Disables a previous call to show_switch(). + */ void LODNode:: hide_switch(int index) { CDWriter cdata(_cycler); @@ -293,11 +252,9 @@ hide_switch(int index) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::show_all_switches -// Access: Published -// Description: Shows all levels in their default colors. -//////////////////////////////////////////////////////////////////// +/** + * Shows all levels in their default colors. + */ void LODNode:: show_all_switches() { CDWriter cdata(_cycler); @@ -307,12 +264,9 @@ show_all_switches() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::hide_all_switches -// Access: Published -// Description: Hides all levels, restoring the LODNode to normal -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Hides all levels, restoring the LODNode to normal operation. + */ void LODNode:: hide_all_switches() { CDWriter cdata(_cycler); @@ -322,15 +276,12 @@ hide_all_switches() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::verify_child_bounds -// Access: Published -// Description: Returns true if the bounding volumes for the geometry -// of each fhild node entirely fits within the -// switch_in radius for that child, or false otherwise. -// It is almost always a mistake for the geometry of an -// LOD level to be larger than its switch_in radius. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the bounding volumes for the geometry of each fhild node + * entirely fits within the switch_in radius for that child, or false + * otherwise. It is almost always a mistake for the geometry of an LOD level + * to be larger than its switch_in radius. + */ bool LODNode:: verify_child_bounds() const { bool okflag = true; @@ -338,7 +289,7 @@ verify_child_bounds() const { for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { PN_stdfloat suggested_radius; - if (!do_verify_child_bounds(cdata, index, suggested_radius)) { + if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; pgraph_cat.warning() << "Level " << index << " geometry of " << *this @@ -351,21 +302,19 @@ verify_child_bounds() const { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::compute_child -// Access: Protected -// Description: Determines which child should be visible according to -// the current camera position. If a child is visible, -// returns its index number; otherwise, returns -1. -//////////////////////////////////////////////////////////////////// +/** + * Determines which child should be visible according to the current camera + * position. If a child is visible, returns its index number; otherwise, + * returns -1. + */ int LODNode:: compute_child(CullTraverser *trav, CullTraverserData &data) { if (data.get_net_transform(trav)->is_singular()) { - // If we're under a singular transform, we can't compute the LOD; - // select none of them instead. + // If we're under a singular transform, we can't compute the LOD; select + // none of them instead. return -1; } - + CDReader cdata(_cycler); if (cdata->_got_force_switch) { @@ -378,7 +327,7 @@ compute_child(CullTraverser *trav, CullTraverserData &data) { for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { if (cdata->_switch_vector[index].in_range_2(dist2 * cdata->_lod_scale - * trav->get_scene()->get_camera_node()->get_lod_scale())) { + * trav->get_scene()->get_camera_node()->get_lod_scale())) { if (pgraph_cat.is_debug()) { pgraph_cat.debug() << data._node_path << " at distance " << sqrt(dist2) @@ -399,14 +348,11 @@ compute_child(CullTraverser *trav, CullTraverserData &data) { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::show_switches_cull_callback -// Access: Protected -// Description: A special version of cull_callback() that is to be -// invoked when the LODNode is in show_switch() mode. -// This just draws the rings and the wireframe geometry -// for the selected switches. -//////////////////////////////////////////////////////////////////// +/** + * A special version of cull_callback() that is to be invoked when the LODNode + * is in show_switch() mode. This just draws the rings and the wireframe + * geometry for the selected switches. + */ bool LODNode:: show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { CDReader cdata(_cycler); @@ -415,12 +361,12 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { LPoint3 center = cdata->_center * rel_transform->get_mat(); PN_stdfloat dist2 = center.dot(center); - // Now orient the disk(s) in camera space such that their origin is - // at center, and the (0, 0, 0) point in camera space is on the disk. + // Now orient the disk(s) in camera space such that their origin is at + // center, and the (0, 0, 0) point in camera space is on the disk. LMatrix4 mat; look_at(mat, -center, LVector3(0.0f, 0.0f, 1.0f)); mat.set_row(3, center); - CPT(TransformState) viz_transform = + CPT(TransformState) viz_transform = rel_transform->invert_compose(TransformState::make_mat(mat)); for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { @@ -434,8 +380,8 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { } if (in_range) { - // This switch level is in range. Draw its children in the - // funny wireframe mode. + // This switch level is in range. Draw its children in the funny + // wireframe mode. if (index < get_num_children()) { PandaNode *child = get_child(index); if (child != (PandaNode *)NULL) { @@ -454,8 +400,8 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { trav->traverse(next_data2); } - // Draw the rings for this switch level. We do this after we - // have drawn the geometry and the spindle. + // Draw the rings for this switch level. We do this after we have drawn + // the geometry and the spindle. CullTraverserData next_data(data, sw.get_ring_viz()); next_data.apply_transform_and_state(trav, viz_transform, RenderState::make_empty(), @@ -465,19 +411,16 @@ show_switches_cull_callback(CullTraverser *trav, CullTraverserData &data) { } } - // Now return false indicating that we have already taken care of - // the traversal from here. + // Now return false indicating that we have already taken care of the + // traversal from here. return false; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Returns a newly-allocated BoundingVolume that -// represents the internal contents of the node. Should -// be overridden by PandaNode classes that contain -// something internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated BoundingVolume that represents the internal + * contents of the node. Should be overridden by PandaNode classes that + * contain something internally. + */ void LODNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -488,8 +431,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, // If we have any visible rings, those count in the bounding volume. if (is_any_shown()) { - // Now actually compute the bounding volume by putting it around all - // of our geoms' bounding volumes. + // Now actually compute the bounding volume by putting it around all of + // our geoms' bounding volumes. pvector child_volumes; pvector pt_volumes; @@ -506,10 +449,10 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, pt_volumes.push_back(sphere); } } - + const BoundingVolume **child_begin = &child_volumes[0]; const BoundingVolume **child_end = child_begin + child_volumes.size(); - + bound->around(child_begin, child_end); } @@ -517,28 +460,26 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_rel_transform -// Access: Protected -// Description: Returns the relative transform to convert from the -// LODNode space to the camera space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative transform to convert from the LODNode space to the + * camera space. + */ CPT(TransformState) LODNode:: get_rel_transform(CullTraverser *trav, CullTraverserData &data) { // Get a pointer to the camera node. Camera *camera = trav->get_scene()->get_camera_node(); - + // Get the camera space transform. CPT(TransformState) rel_transform; NodePath lod_center = camera->get_lod_center(); if (!lod_center.is_empty()) { - rel_transform = + rel_transform = lod_center.get_net_transform()->invert_compose(data.get_net_transform(trav)); } else { NodePath cull_center = camera->get_cull_center(); if (!cull_center.is_empty()) { - rel_transform = + rel_transform = cull_center.get_net_transform()->invert_compose(data.get_net_transform(trav)); } else { rel_transform = data.get_modelview_transform(trav); @@ -548,11 +489,9 @@ get_rel_transform(CullTraverser *trav, CullTraverserData &data) { return rel_transform; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::do_show_switch -// Access: Private -// Description: The private implementation of show_switch(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of show_switch(). + */ void LODNode:: do_show_switch(LODNode::CData *cdata, int index, const LColor &color) { nassertv(index >= 0 && index < (int)cdata->_switch_vector.size()); @@ -563,11 +502,9 @@ do_show_switch(LODNode::CData *cdata, int index, const LColor &color) { cdata->_switch_vector[index].show(color); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::do_hide_switch -// Access: Private -// Description: The private implementation of hide_switch(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of hide_switch(). + */ void LODNode:: do_hide_switch(LODNode::CData *cdata, int index) { nassertv(index >= 0 && index < (int)cdata->_switch_vector.size()); @@ -578,16 +515,13 @@ do_hide_switch(LODNode::CData *cdata, int index) { cdata->_switch_vector[index].hide(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::do_verify_child_bounds -// Access: Private -// Description: The private implementation of verify_child_bounds(), -// this checks the bounding volume of just one child. -// -// If the return value is false, suggested_radius is -// filled with a radius that ought to be large enough to -// include the child. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of verify_child_bounds(), this checks the + * bounding volume of just one child. + * + * If the return value is false, suggested_radius is filled with a radius that + * ought to be large enough to include the child. + */ bool LODNode:: do_verify_child_bounds(const LODNode::CData *cdata, int index, PN_stdfloat &suggested_radius) const { @@ -601,8 +535,8 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, CPT(BoundingVolume) bv = child->get_bounds(seq); if (seq == sw._bounds_seq) { - // We previously verified this child, and it hasn't changed - // since then. + // We previously verified this child, and it hasn't changed since + // then. return sw._verify_ok; } @@ -614,69 +548,69 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, return true; } if (bv->is_infinite()) { - // To be strict, we ought to look closer if the child has an - // infinite bounding volume, but in practice this is probably - // just a special case (e.g. the child contains the camera) - // that we don't really want to check. + // To be strict, we ought to look closer if the child has an infinite + // bounding volume, but in practice this is probably just a special + // case (e.g. the child contains the camera) that we don't really + // want to check. return true; } - + const Switch &sw = cdata->_switch_vector[index]; - + const GeometricBoundingVolume *gbv; DCAST_INTO_R(gbv, bv, false); BoundingSphere sphere(cdata->_center, sw.get_in()); sphere.local_object(); - + int flags = sphere.contains(gbv); if ((flags & BoundingVolume::IF_all) != 0) { // This child's radius completely encloses its bounding volume. // Perfect. (And this is the most common case.) return true; } - + if (flags == 0) { - // This child's radius doesn't even come close to containing - // its volume. + // This child's radius doesn't even come close to containing its + // volume. nassertr(!gbv->is_infinite(), false); sphere.extend_by(gbv); suggested_radius = sphere.get_radius(); ((Switch &)sw)._verify_ok = false; return false; } - - // This child's radius partially encloses its (loose) bounding - // volume. We have to look closer to determine whether it, in - // fact, fully encloses its geometry. + + // This child's radius partially encloses its (loose) bounding volume. + // We have to look closer to determine whether it, in fact, fully + // encloses its geometry. LPoint3 min_point(0.0f, 0.0f, 0.0f); LPoint3 max_point(0.0f, 0.0f, 0.0f); - + bool found_any = false; - child->calc_tight_bounds(min_point, max_point, found_any, + child->calc_tight_bounds(min_point, max_point, found_any, TransformState::make_identity(), Thread::get_current_thread()); if (!found_any) { // Hmm, the child has no geometry after all. return true; } - - // Now we have a bounding box. Define the largest sphere we can - // that fits within this box. All we can say about this sphere - // is that it should definitely fit entirely within a bounding - // sphere that contains all the points of the child. + + // Now we have a bounding box. Define the largest sphere we can that + // fits within this box. All we can say about this sphere is that it + // should definitely fit entirely within a bounding sphere that contains + // all the points of the child. LPoint3 box_center = (min_point + max_point) / 2.0f; PN_stdfloat box_radius = min(min(max_point[0] - box_center[0], max_point[1] - box_center[1]), max_point[2] - box_center[2]); - + BoundingSphere box_sphere(box_center, box_radius); box_sphere.local_object(); - - // So if any part of this inscribed sphere is outside of the - // radius, then the radius is bad. + + // So if any part of this inscribed sphere is outside of the radius, + // then the radius is bad. flags = sphere.contains(&box_sphere); if ((flags & BoundingVolume::IF_all) == 0) { - // No good. + // No good. if (gbv->is_infinite()) { sphere.extend_by(&box_sphere); } else { @@ -687,16 +621,14 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, return false; } } - } + } return true; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::do_auto_verify_lods -// Access: Private -// Description: Called internally by consider_verify_lods(). -//////////////////////////////////////////////////////////////////// +/** + * Called internally by consider_verify_lods(). + */ void LODNode:: do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { UpdateSeq seq; @@ -704,9 +636,9 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { CDLockedReader cdata(_cycler); if (cdata->_got_force_switch) { - // If we're forcing a particular switch, don't verify the LOD - // sizes, since they don't really apply anymore anyway. Assume - // the user knows what he's doing. + // If we're forcing a particular switch, don't verify the LOD sizes, since + // they don't really apply anymore anyway. Assume the user knows what + // he's doing. return; } @@ -714,13 +646,13 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { // Time to validate the children again. for (int index = 0; index < (int)cdata->_switch_vector.size(); ++index) { PN_stdfloat suggested_radius; - if (!do_verify_child_bounds(cdata, index, suggested_radius)) { + if (!do_verify_child_bounds(cdata, index, suggested_radius)) { const Switch &sw = cdata->_switch_vector[index]; ostringstream strm; strm << "Level " << index << " geometry of " << data._node_path << " is larger than its switch radius; suggest radius of " - << suggested_radius << " instead of " << sw.get_in() + << suggested_radius << " instead of " << sw.get_in() << " (configure verify-lods 0 to ignore this error)"; nassert_raise(strm.str()); } @@ -730,12 +662,9 @@ do_auto_verify_lods(CullTraverser *trav, CullTraverserData &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::get_default_show_color -// Access: Private, Static -// Description: Returns a default color appropriate for showing the -// indicated level. -//////////////////////////////////////////////////////////////////// +/** + * Returns a default color appropriate for showing the indicated level. + */ const LColor &LODNode:: get_default_show_color(int index) { static LColor default_colors[] = { @@ -752,41 +681,33 @@ get_default_show_color(int index) { } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// LODNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type LODNode. + */ void LODNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LODNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type LODNode is encountered -// in the Bam file. It should create the LODNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type LODNode is encountered in the Bam file. It should create the LODNode + * and extract its information from the file. + */ TypedWritable *LODNode:: make_from_bam(const FactoryParams ¶ms) { LODNode *node = new LODNode(""); - + DatagramIterator scan; BamReader *manager; @@ -796,35 +717,28 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LODNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LODNode. + */ void LODNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *LODNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::check_limits -// Access: Public -// Description: Ensures that the _lowest and _highest members are set -// appropriately after a change to the set of switches. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the _lowest and _highest members are set appropriately after a + * change to the set of switches. + */ void LODNode::CData:: check_limits() { _lowest = 0; @@ -839,12 +753,10 @@ check_limits() { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void LODNode::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { _center.write_datagram(dg); @@ -859,13 +771,10 @@ write_datagram(BamWriter *manager, Datagram &dg) const { } } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new LODNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new LODNode. + */ void LODNode::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _center.read_datagram(scan); @@ -883,21 +792,19 @@ fillin(DatagramIterator &scan, BamReader *manager) { _lod_scale = 1; } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::compute_ring_viz -// Access: Private -// Description: Computes a Geom suitable for rendering the ring -// associated with this switch. -//////////////////////////////////////////////////////////////////// +/** + * Computes a Geom suitable for rendering the ring associated with this + * switch. + */ void LODNode::Switch:: compute_ring_viz() { - // We render the ring as a series of concentric ring-shaped triangle - // strips, each of which has num_slices quads. + // We render the ring as a series of concentric ring-shaped triangle strips, + // each of which has num_slices quads. static const int num_slices = 50; static const int num_rings = 1; - // There are also two more triangle strips, one for the outer edge, - // and one for the inner edge. + // There are also two more triangle strips, one for the outer edge, and one + // for the inner edge. static const PN_stdfloat edge_ratio = 0.1; // ratio of edge height to diameter. const GeomVertexFormat *format = GeomVertexFormat::get_v3n3cp(); @@ -940,7 +847,7 @@ compute_ring_viz() { for (si = 0; si < num_slices; ++si) { PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; PN_stdfloat t = MathNumbers::pi * 2.0f * s; - + PN_stdfloat x = ccos(t); PN_stdfloat y = csin(t); @@ -952,7 +859,7 @@ compute_ring_viz() { for (si = 0; si < num_slices; ++si) { PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; PN_stdfloat t = MathNumbers::pi * 2.0f * s; - + PN_stdfloat x = ccos(t); PN_stdfloat y = csin(t); @@ -974,8 +881,7 @@ compute_ring_viz() { strips->close_primitive(); } - // And then one triangle strip for each of the inner and outer - // edges. + // And then one triangle strip for each of the inner and outer edges. for (ri = 0; ri <= 1; ++ri) { for (si = 0; si < num_slices; ++si) { strips->add_vertex((num_rings + 1 + ri * 2) * num_slices + si); @@ -997,7 +903,7 @@ compute_ring_viz() { material->set_twoside(true); material = MaterialPool::get_material(material); - CPT(RenderState) viz_state = + CPT(RenderState) viz_state = RenderState::make(CullFaceAttrib::make(CullFaceAttrib::M_cull_none), TextureAttrib::make_off(), ShaderAttrib::make_off(), @@ -1013,18 +919,15 @@ compute_ring_viz() { _ring_viz = geom_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::compute_spindle_viz -// Access: Private -// Description: Computes a Geom suitable for rendering the LODNode -// spindle in the color of this switch. -//////////////////////////////////////////////////////////////////// +/** + * Computes a Geom suitable for rendering the LODNode spindle in the color of + * this switch. + */ void LODNode::Switch:: compute_spindle_viz() { - // We render the spindle as a cylinder, which consists of num_rings - // rings stacked vertically, each of which is a triangle strip of - // num_slices quads. The scale is -10 .. 10 vertically, with a radius - // of 1.0. + // We render the spindle as a cylinder, which consists of num_rings rings + // stacked vertically, each of which is a triangle strip of num_slices + // quads. The scale is -10 .. 10 vertically, with a radius of 1.0. static const int num_slices = 10; static const int num_rings = 10; @@ -1077,7 +980,7 @@ compute_spindle_viz() { PT(GeomNode) geom_node = new GeomNode("spindle"); geom_node->add_geom(spindle_geom); - CPT(RenderState) viz_state = + CPT(RenderState) viz_state = RenderState::make(CullFaceAttrib::make(CullFaceAttrib::M_cull_clockwise), TextureAttrib::make_off(), ShaderAttrib::make_off(), @@ -1092,17 +995,15 @@ compute_spindle_viz() { _spindle_viz = geom_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: LODNode::Switch::compute_viz_model_state -// Access: Private -// Description: Computes a RenderState for rendering the children of -// this switch in colored wireframe mode. -//////////////////////////////////////////////////////////////////// +/** + * Computes a RenderState for rendering the children of this switch in colored + * wireframe mode. + */ void LODNode::Switch:: compute_viz_model_state() { - // The RenderState::make() function only takes up to four attribs at - // once. Since we need more attribs than that, we have to make up - // our state in two steps. + // The RenderState::make() function only takes up to four attribs at once. + // Since we need more attribs than that, we have to make up our state in two + // steps. _viz_model_state = RenderState::make(RenderModeAttrib::make(RenderModeAttrib::M_wireframe), TextureAttrib::make_off(), ShaderAttrib::make_off(), diff --git a/panda/src/pgraphnodes/lodNode.h b/panda/src/pgraphnodes/lodNode.h index abd98e4cc5..50b17d26e1 100644 --- a/panda/src/pgraphnodes/lodNode.h +++ b/panda/src/pgraphnodes/lodNode.h @@ -1,16 +1,15 @@ -// Filename: lodNode.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lodNode.h + * @author drose + * @date 2002-03-06 + */ #ifndef LODNODE_H #define LODNODE_H @@ -21,13 +20,11 @@ #include "luse.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : LODNode -// Description : A Level-of-Detail node. This selects only one of its -// children for rendering, according to the distance -// from the camera and the table indicated in the -// associated LOD object. -//////////////////////////////////////////////////////////////////// +/** + * A Level-of-Detail node. This selects only one of its children for + * rendering, according to the distance from the camera and the table + * indicated in the associated LOD object. + */ class EXPCL_PANDA_PGRAPHNODES LODNode : public PandaNode { PUBLISHED: INLINE LODNode(const string &name); @@ -48,10 +45,10 @@ public: virtual bool is_lod_node() const; PUBLISHED: - // The sense of in vs. out distances is as if the object were coming - // towards you from far away: it switches "in" at the far distance, - // and switches "out" at the close distance. Thus, "in" should be - // larger than "out". + // The sense of in vs. out distances is as if the object were coming + // towards you from far away: it switches "in" at the far distance, and + // switches "out" at the close distance. Thus, "in" should be larger than + // "out". INLINE void add_switch(PN_stdfloat in, PN_stdfloat out); INLINE bool set_switch(int index, PN_stdfloat in, PN_stdfloat out); @@ -69,8 +66,8 @@ PUBLISHED: INLINE void force_switch(int index); INLINE void clear_force_switch(); - //for performance tuning, increasing this value should improve performance - //at the cost of model quality + // for performance tuning, increasing this value should improve performance + // at the cost of model quality INLINE void set_lod_scale(PN_stdfloat value); INLINE PN_stdfloat get_lod_scale() const; diff --git a/panda/src/pgraphnodes/lodNodeType.cxx b/panda/src/pgraphnodes/lodNodeType.cxx index 8ceb4eb860..2798cdd0f4 100644 --- a/panda/src/pgraphnodes/lodNodeType.cxx +++ b/panda/src/pgraphnodes/lodNodeType.cxx @@ -1,16 +1,15 @@ -// Filename: lodNodeType.cxx -// Created by: drose (08Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lodNodeType.cxx + * @author drose + * @date 2007-06-08 + */ #include "lodNodeType.h" #include "string_utils.h" @@ -21,7 +20,7 @@ operator << (ostream &out, LODNodeType lnt) { switch (lnt) { case LNT_pop: return out << "pop"; - + case LNT_fade: return out << "fade"; } diff --git a/panda/src/pgraphnodes/lodNodeType.h b/panda/src/pgraphnodes/lodNodeType.h index 6be661a39a..bc1964d519 100644 --- a/panda/src/pgraphnodes/lodNodeType.h +++ b/panda/src/pgraphnodes/lodNodeType.h @@ -1,16 +1,15 @@ -// Filename: lodNodeType.h -// Created by: drose (08Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lodNodeType.h + * @author drose + * @date 2007-06-08 + */ #ifndef LODNODETYPE_H #define LODNODETYPE_H @@ -30,5 +29,3 @@ EXPCL_PANDA_PGRAPH ostream &operator << (ostream &out, LODNodeType lnt); EXPCL_PANDA_PGRAPH istream &operator >> (istream &in, LODNodeType &cs); #endif - - diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.I b/panda/src/pgraphnodes/nodeCullCallbackData.I index 1e74208f82..28f81691dc 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.I +++ b/panda/src/pgraphnodes/nodeCullCallbackData.I @@ -1,23 +1,19 @@ -// Filename: nodeCullCallbackData.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCullCallbackData.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodeCullCallbackData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NodeCullCallbackData:: NodeCullCallbackData(CullTraverser *trav, CullTraverserData &data) : _trav(trav), @@ -25,27 +21,21 @@ NodeCullCallbackData(CullTraverser *trav, CullTraverserData &data) : { } -//////////////////////////////////////////////////////////////////// -// Function: NodeCullCallbackData::get_trav -// Access: Published -// Description: Returns the CullTraverser in use at the time of the -// callback. This object contains data that does not -// change during the traversal, such as the -// DisplayRegion and Camera in use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CullTraverser in use at the time of the callback. This object + * contains data that does not change during the traversal, such as the + * DisplayRegion and Camera in use. + */ INLINE CullTraverser *NodeCullCallbackData:: get_trav() const { return _trav; } -//////////////////////////////////////////////////////////////////// -// Function: NodeCullCallbackData::get_data -// Access: Published -// Description: Returns the CullTraverserData in use at the time of the -// callback. This object contains data that changes at -// each node of the traversal, such as the current node -// and the current net transform to that node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the CullTraverserData in use at the time of the callback. This + * object contains data that changes at each node of the traversal, such as + * the current node and the current net transform to that node. + */ INLINE CullTraverserData &NodeCullCallbackData:: get_data() const { return _data; diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.cxx b/panda/src/pgraphnodes/nodeCullCallbackData.cxx index d05b76babc..d0bf763e98 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.cxx +++ b/panda/src/pgraphnodes/nodeCullCallbackData.cxx @@ -1,16 +1,15 @@ -// Filename: nodeCullCallbackData.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCullCallbackData.cxx + * @author drose + * @date 2009-03-13 + */ #include "nodeCullCallbackData.h" #include "callbackNode.h" @@ -21,38 +20,32 @@ TypeHandle NodeCullCallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodeCullCallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void NodeCullCallbackData:: output(ostream &out) const { out << get_type() << "(" << (void *)_trav << ", " << (void *)&_data << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: NodeCullCallbackData::upcall -// Access: Published, Virtual -// Description: You should make this call during the callback if you -// want to continue the normal rendering function that -// would have been done in the absence of a callback. -// -// Specifically, this method will add this node to the -// draw queue, and continue the cull traversal for all -// the nodes below. If you omit this call, this node -// and its children will be pruned from the render -// result. -//////////////////////////////////////////////////////////////////// +/** + * You should make this call during the callback if you want to continue the + * normal rendering function that would have been done in the absence of a + * callback. + * + * Specifically, this method will add this node to the draw queue, and + * continue the cull traversal for all the nodes below. If you omit this + * call, this node and its children will be pruned from the render result. + */ void NodeCullCallbackData:: upcall() { PandaNode *node = _data.node(); if (node->is_of_type(CallbackNode::get_class_type())) { CallbackNode *cbnode = DCAST(CallbackNode, _data.node()); - // OK, render this node. Rendering a CallbackNode means creating - // a CullableObject for the draw_callback, if any. We don't need - // to pass any Geoms, however. + // OK, render this node. Rendering a CallbackNode means creating a + // CullableObject for the draw_callback, if any. We don't need to pass + // any Geoms, however. CallbackObject *cbobj = cbnode->get_draw_callback(); if (cbobj != (CallbackObject *)NULL) { CullableObject *object = diff --git a/panda/src/pgraphnodes/nodeCullCallbackData.h b/panda/src/pgraphnodes/nodeCullCallbackData.h index acc7f84ef8..add737d3d6 100644 --- a/panda/src/pgraphnodes/nodeCullCallbackData.h +++ b/panda/src/pgraphnodes/nodeCullCallbackData.h @@ -1,16 +1,15 @@ -// Filename: nodeCullCallbackData.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCullCallbackData.h + * @author drose + * @date 2009-03-13 + */ #ifndef NODECULLCALLBACKDATA_H #define NODECULLCALLBACKDATA_H @@ -20,12 +19,10 @@ #include "cullTraverser.h" #include "cullTraverserData.h" -//////////////////////////////////////////////////////////////////// -// Class : NodeCullCallbackData -// Description : This kind of CallbackData is passed to the -// CallbackObject added to -// CallbackNode:set_cull_callback(). -//////////////////////////////////////////////////////////////////// +/** + * This kind of CallbackData is passed to the CallbackObject added to + * CallbackNode:set_cull_callback(). + */ class EXPCL_PANDA_PGRAPHNODES NodeCullCallbackData : public CallbackData { public: INLINE NodeCullCallbackData(CullTraverser *trav, CullTraverserData &data); diff --git a/panda/src/pgraphnodes/pointLight.I b/panda/src/pgraphnodes/pointLight.I index 646bd0473c..672d35042a 100644 --- a/panda/src/pgraphnodes/pointLight.I +++ b/panda/src/pgraphnodes/pointLight.I @@ -1,23 +1,19 @@ -// Filename: pointLight.I -// Created by: mike (04eb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointLight.I + * @author mike + * @date 1999-02-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PointLight::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointLight::CData:: CData() : _specular_color(1.0f, 1.0f, 1.0f, 1.0f), @@ -26,11 +22,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PointLight::CData:: CData(const PointLight::CData ©) : _specular_color(copy._specular_color), @@ -39,12 +33,10 @@ CData(const PointLight::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::get_specular_color -// Access: Public, Final -// Description: Returns the color of specular highlights generated by -// the light. This is usually the same as get_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of specular highlights generated by the light. This is + * usually the same as get_color(). + */ INLINE const LColor &PointLight:: get_specular_color() const { if (_has_specular_color) { @@ -55,12 +47,9 @@ get_specular_color() const { } } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::set_specular_color -// Access: Public -// Description: Sets the color of specular highlights generated by -// the light. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of specular highlights generated by the light. + */ INLINE void PointLight:: set_specular_color(const LColor &color) { CDWriter cdata(_cycler); @@ -68,63 +57,50 @@ set_specular_color(const LColor &color) { cdata->_specular_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::clear_specular_color -// Access: Public -// Description: Clears a custom specular color setting, meaning that -// the specular color will now come from the color. -//////////////////////////////////////////////////////////////////// +/** + * Clears a custom specular color setting, meaning that the specular color + * will now come from the color. + */ INLINE void PointLight:: clear_specular_color() { _has_specular_color = false; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::get_attenuation -// Access: Public, Final -// Description: Returns the terms of the attenuation equation for the -// light. These are, in order, the constant, linear, -// and quadratic terms based on the distance from the -// point to the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the terms of the attenuation equation for the light. These are, in + * order, the constant, linear, and quadratic terms based on the distance from + * the point to the vertex. + */ INLINE const LVecBase3 &PointLight:: get_attenuation() const { CDReader cdata(_cycler); return cdata->_attenuation; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::set_attenuation -// Access: Public -// Description: Sets the terms of the attenuation equation for the -// light. These are, in order, the constant, linear, -// and quadratic terms based on the distance from the -// point to the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets the terms of the attenuation equation for the light. These are, in + * order, the constant, linear, and quadratic terms based on the distance from + * the point to the vertex. + */ INLINE void PointLight:: set_attenuation(const LVecBase3 &attenuation) { CDWriter cdata(_cycler); cdata->_attenuation = attenuation; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::get_point -// Access: Public -// Description: Returns the point in space at which the light is -// located. This is local to the coordinate space in -// which the light is assigned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point in space at which the light is located. This is local to + * the coordinate space in which the light is assigned. + */ INLINE const LPoint3 &PointLight:: get_point() const { CDReader cdata(_cycler); return cdata->_point; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::set_point -// Access: Public -// Description: Sets the point in space at which the light is located. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point in space at which the light is located. + */ INLINE void PointLight:: set_point(const LPoint3 &point) { CDWriter cdata(_cycler); diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 99919a2287..2c4bf1641e 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -1,16 +1,15 @@ -// Filename: pointLight.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointLight.cxx + * @author mike + * @date 1997-01-09 + */ #include "pointLight.h" #include "graphicsStateGuardianBase.h" @@ -21,22 +20,18 @@ TypeHandle PointLight::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PointLight::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *PointLight::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PointLight::CData:: write_datagram(BamWriter *, Datagram &dg) const { _specular_color.write_datagram(dg); @@ -44,13 +39,10 @@ write_datagram(BamWriter *, Datagram &dg) const { _point.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void PointLight::CData:: fillin(DatagramIterator &scan, BamReader *) { _specular_color.read_datagram(scan); @@ -58,13 +50,11 @@ fillin(DatagramIterator &scan, BamReader *) { _point.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PointLight:: -PointLight(const string &name) : +PointLight(const string &name) : LightLensNode(name), _has_specular_color(false) { @@ -89,13 +79,10 @@ PointLight(const string &name) : set_lens(5, lens); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::Copy Constructor -// Access: Protected -// Description: Do not call the copy constructor directly; instead, -// use make_copy() or copy_subgraph() to make a copy of -// a node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ PointLight:: PointLight(const PointLight ©) : LightLensNode(copy), @@ -104,27 +91,20 @@ PointLight(const PointLight ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *PointLight:: make_copy() const { return new PointLight(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void PointLight:: xform(const LMatrix4 &mat) { LightLensNode::xform(mat); @@ -133,11 +113,9 @@ xform(const LMatrix4 &mat) { mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PointLight:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; @@ -151,25 +129,20 @@ write(ostream &out, int indent_level) const { << "attenuation " << get_attenuation() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::get_vector_to_light -// Access: Public, Virtual -// Description: Computes the vector from a particular vertex to this -// light. The exact vector depends on the type of light -// (e.g. point lights return a different result than -// directional lights). -// -// The input parameters are the vertex position in -// question, expressed in object space, and the matrix -// which converts from light space to object space. The -// result is expressed in object space. -// -// The return value is true if the result is successful, -// or false if it cannot be computed (e.g. for an -// ambient light). -//////////////////////////////////////////////////////////////////// +/** + * Computes the vector from a particular vertex to this light. The exact + * vector depends on the type of light (e.g. point lights return a different + * result than directional lights). + * + * The input parameters are the vertex position in question, expressed in + * object space, and the matrix which converts from light space to object + * space. The result is expressed in object space. + * + * The return value is true if the result is successful, or false if it cannot + * be computed (e.g. for an ambient light). + */ bool PointLight:: -get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, +get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space) { CDReader cdata(_cycler); LPoint3 point = cdata->_point * to_object_space; @@ -178,48 +151,37 @@ get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::get_class_priority -// Access: Published, Virtual -// Description: Returns the relative priority associated with all -// lights of this class. This priority is used to order -// lights whose instance priority (get_priority()) is -// the same--the idea is that other things being equal, -// AmbientLights (for instance) are less important than -// DirectionalLights. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative priority associated with all lights of this class. + * This priority is used to order lights whose instance priority + * (get_priority()) is the same--the idea is that other things being equal, + * AmbientLights (for instance) are less important than DirectionalLights. + */ int PointLight:: get_class_priority() const { return (int)CP_point_priority; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::bind -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PointLight:: bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id) { gsg->bind_light(this, light, light_id); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// PointLight. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type PointLight. + */ void PointLight:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void PointLight:: write_datagram(BamWriter *manager, Datagram &dg) { LightLensNode::write_datagram(manager, dg); @@ -227,14 +189,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type PointLight is encountered -// in the Bam file. It should create the PointLight -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type PointLight is encountered in the Bam file. It should create the + * PointLight and extract its information from the file. + */ TypedWritable *PointLight:: make_from_bam(const FactoryParams ¶ms) { PointLight *node = new PointLight(""); @@ -247,13 +206,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: PointLight::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new PointLight. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new PointLight. + */ void PointLight:: fillin(DatagramIterator &scan, BamReader *manager) { LightLensNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index f7274d92da..508cee5db7 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -1,16 +1,15 @@ -// Filename: pointLight.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pointLight.h + * @author mike + * @date 1997-01-09 + */ #ifndef POINTLIGHT_H #define POINTLIGHT_H @@ -19,11 +18,10 @@ #include "lightLensNode.h" -//////////////////////////////////////////////////////////////////// -// Class : PointLight -// Description : A light originating from a single point in space, and -// shining in all directions. -//////////////////////////////////////////////////////////////////// +/** + * A light originating from a single point in space, and shining in all + * directions. + */ class EXPCL_PANDA_PGRAPHNODES PointLight : public LightLensNode { PUBLISHED: PointLight(const string &name); diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.I b/panda/src/pgraphnodes/sceneGraphAnalyzer.I index 72a638d9a4..3d7ef0a08d 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.I +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.I @@ -1,316 +1,254 @@ -// Filename: sceneGraphAnalyzer.I -// Created by: drose (15Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzer.I + * @author drose + * @date 2006-10-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::set_lod_mode -// Access: Published -// Description: Specifies the mode in which LODNodes are analyzed. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the mode in which LODNodes are analyzed. + */ INLINE void SceneGraphAnalyzer:: set_lod_mode(LodMode lod_mode) { _lod_mode = lod_mode; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_lod_mode -// Access: Published -// Description: Returns the mode in which LODNodes are analyzed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mode in which LODNodes are analyzed. + */ INLINE SceneGraphAnalyzer::LodMode SceneGraphAnalyzer:: get_lod_mode(LodMode lod_mode) const { return _lod_mode; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_nodes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_nodes() const { return _num_nodes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_instances -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_instances() const { return _num_instances; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_transforms -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_transforms() const { return _num_transforms; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_nodes_with_attribs -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_nodes_with_attribs() const { return _num_nodes_with_attribs; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_lod_nodes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_lod_nodes() const { return _num_lod_nodes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_geom_nodes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_geom_nodes() const { return _num_geom_nodes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_geoms -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_geoms() const { return _num_geoms; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_geom_vertex_datas -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_geom_vertex_datas() const { return _num_geom_vertex_datas; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_geom_vertex_formats -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_geom_vertex_formats() const { return _num_geom_vertex_formats; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_vertex_data_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t SceneGraphAnalyzer:: get_vertex_data_size() const { return _vertex_data_size; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_vertices -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_vertices() const { return _num_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_normals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_normals() const { return _num_normals; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_colors -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_colors() const { return _num_colors; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_texcoords -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_texcoords() const { return _num_texcoords; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_tris -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_tris() const { return _num_tris; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_lines -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_lines() const { return _num_lines; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_points -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_points() const { return _num_points; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_patches -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_patches() const { return _num_patches; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_individual_tris -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_individual_tris() const { return _num_individual_tris; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_tristrips -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_tristrips() const { return _num_tristrips; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_triangles_in_strips -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_triangles_in_strips() const { return _num_triangles_in_strips; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_trifans -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_trifans() const { return _num_trifans; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_triangles_in_fans -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_triangles_in_fans() const { return _num_triangles_in_fans; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_vertices_in_patches -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_vertices_in_patches() const { return _num_vertices_in_patches; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_texture_bytes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_texture_bytes() const { return _texture_bytes; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_long_normals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_long_normals() const { return _num_long_normals; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_num_short_normals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int SceneGraphAnalyzer:: get_num_short_normals() const { return _num_short_normals; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::get_total_normal_length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PN_stdfloat SceneGraphAnalyzer:: get_total_normal_length() const { return _total_normal_length; diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx index 84212b0edd..cb4c892e7c 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.cxx @@ -1,16 +1,15 @@ -// Filename: sceneGraphAnalyzer.cxx -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzer.cxx + * @author drose + * @date 2000-07-02 + */ #include "sceneGraphAnalyzer.h" #include "config_pgraph.h" @@ -33,32 +32,25 @@ #include "pta_ushort.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SceneGraphAnalyzer:: SceneGraphAnalyzer() { _lod_mode = LM_all; clear(); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SceneGraphAnalyzer:: ~SceneGraphAnalyzer() { } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::clear -// Access: Published -// Description: Resets all of the data in the analyzer in preparation -// for a new run. -//////////////////////////////////////////////////////////////////// +/** + * Resets all of the data in the analyzer in preparation for a new run. + */ void SceneGraphAnalyzer:: clear() { _nodes.clear(); @@ -105,25 +97,19 @@ clear() { _total_normal_length = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::add_node -// Access: Published -// Description: Adds a new node to the set of data for analysis. -// Normally, this would only be called once, and passed -// the top of the scene graph, but it's possible to -// repeatedly pass in subgraphs to get an analysis of -// all the graphs together. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new node to the set of data for analysis. Normally, this would only + * be called once, and passed the top of the scene graph, but it's possible to + * repeatedly pass in subgraphs to get an analysis of all the graphs together. + */ void SceneGraphAnalyzer:: add_node(PandaNode *node) { collect_statistics(node, false); } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::write -// Access: Published -// Description: Describes all the data collected. -//////////////////////////////////////////////////////////////////// +/** + * Describes all the data collected. + */ void SceneGraphAnalyzer:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -140,8 +126,8 @@ write(ostream &out, int indent_level) const { out << "\n"; indent(out, indent_level) - << _num_geoms << " Geoms, with " << _num_geom_vertex_datas - << " GeomVertexDatas and " << _num_geom_vertex_formats + << _num_geoms << " Geoms, with " << _num_geom_vertex_datas + << " GeomVertexDatas and " << _num_geom_vertex_formats << " GeomVertexFormats, appear on " << _num_geom_nodes << " GeomNodes.\n"; @@ -167,11 +153,11 @@ write(ostream &out, int indent_level) const { } indent(out, indent_level) - << "GeomVertexData arrays occupy " << (_vertex_data_size + 1023) / 1024 + << "GeomVertexData arrays occupy " << (_vertex_data_size + 1023) / 1024 << "K memory.\n"; indent(out, indent_level) - << "GeomPrimitive arrays occupy " << (_prim_data_size + 1023) / 1024 + << "GeomPrimitive arrays occupy " << (_prim_data_size + 1023) / 1024 << "K memory.\n"; int unreferenced_vertices = 0; @@ -207,7 +193,7 @@ write(ostream &out, int indent_level) const { } indent(out, indent_level) << _vadatas.size() - _unique_vadatas.size() - << " GeomVertexArrayDatas are redundant, wasting " + << " GeomVertexArrayDatas are redundant, wasting " << (wasted_bytes + 1023) / 1024 << "K.\n"; } if (_unique_prim_vadatas.size() != _prim_vadatas.size()) { @@ -225,7 +211,7 @@ write(ostream &out, int indent_level) const { } indent(out, indent_level) << _prim_vadatas.size() - _unique_prim_vadatas.size() - << " GeomPrimitive arrays are redundant, wasting " + << " GeomPrimitive arrays are redundant, wasting " << (wasted_bytes + 1023) / 1024 << "K.\n"; } @@ -274,12 +260,9 @@ write(ostream &out, int indent_level) const { << (_texture_bytes + 1023) / 1024 << "K texture memory required.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. + */ void SceneGraphAnalyzer:: collect_statistics(PandaNode *node, bool under_instance) { _num_nodes++; @@ -290,8 +273,7 @@ collect_statistics(PandaNode *node, bool under_instance) { // This is the first time this node has been encountered. _nodes.insert(Nodes::value_type(node, 1)); } else { - // This node has been encountered before; that makes it an - // instance. + // This node has been encountered before; that makes it an instance. (*ni).second++; _num_instances++; under_instance = true; @@ -300,14 +282,14 @@ collect_statistics(PandaNode *node, bool under_instance) { if (!node->get_state()->is_empty()) { _num_nodes_with_attribs++; - const RenderAttrib *attrib = + const RenderAttrib *attrib = node->get_attrib(TextureAttrib::get_class_slot()); if (attrib != (RenderAttrib *)NULL) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); } - } + } } if (!node->get_transform()->is_identity()) { _num_transforms++; @@ -349,12 +331,9 @@ collect_statistics(PandaNode *node, bool under_instance) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. + */ void SceneGraphAnalyzer:: collect_statistics(GeomNode *geom_node) { nassertv(geom_node != (GeomNode *)NULL); @@ -370,23 +349,20 @@ collect_statistics(GeomNode *geom_node) { const RenderState *geom_state = geom_node->get_geom_state(i); - const RenderAttrib *attrib = + const RenderAttrib *attrib = geom_state->get_attrib(TextureAttrib::get_class_slot()); if (attrib != (RenderAttrib *)NULL) { const TextureAttrib *ta = DCAST(TextureAttrib, attrib); for (int i = 0; i < ta->get_num_on_stages(); i++) { collect_statistics(ta->get_on_texture(ta->get_on_stage(i))); } - } + } } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. + */ void SceneGraphAnalyzer:: collect_statistics(const Geom *geom) { CPT(GeomVertexData) vdata = geom->get_vertex_data(); @@ -394,7 +370,7 @@ collect_statistics(const Geom *geom) { if (result.second) { // This is the first time we've encountered this vertex data. ++_num_geom_vertex_datas; - + CPT(GeomVertexFormat) vformat = vdata->get_format(); bool format_inserted = _vformats.insert(vformat).second; if (format_inserted) { @@ -460,16 +436,16 @@ collect_statistics(const Geom *geom) { collect_statistics(prim->get_maxs()); } } - + if (prim->is_of_type(GeomPoints::get_class_type())) { _num_points += prim->get_num_primitives(); - + } else if (prim->is_of_type(GeomLines::get_class_type())) { _num_lines += prim->get_num_primitives(); - + } else if (prim->is_of_type(GeomLinestrips::get_class_type())) { _num_lines += prim->get_num_faces(); - + } else if (prim->is_of_type(GeomTriangles::get_class_type())) { _num_tris += prim->get_num_primitives(); _num_individual_tris += prim->get_num_primitives(); @@ -496,12 +472,9 @@ collect_statistics(const Geom *geom) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. + */ void SceneGraphAnalyzer:: collect_statistics(Texture *texture) { nassertv(texture != (Texture *)NULL); @@ -511,16 +484,15 @@ collect_statistics(Texture *texture) { // This is the first time this texture has been encountered. _textures.insert(Textures::value_type(texture, 1)); - // Attempt to guess how many bytes of texture memory this one - // requires. + // Attempt to guess how many bytes of texture memory this one requires. int bytes = - texture->get_x_size() * texture->get_y_size() * + texture->get_x_size() * texture->get_y_size() * texture->get_num_components() * texture->get_component_width(); - + if (texture->uses_mipmaps()) { bytes *= 4/3; } - + _texture_bytes += bytes; } else { @@ -529,12 +501,9 @@ collect_statistics(Texture *texture) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. + */ void SceneGraphAnalyzer:: collect_statistics(const GeomVertexArrayData *vadata) { nassertv(vadata != NULL); @@ -547,14 +516,11 @@ collect_statistics(const GeomVertexArrayData *vadata) { } } -//////////////////////////////////////////////////////////////////// -// Function: SceneGraphAnalyzer::collect_prim_statistics -// Access: Private -// Description: Recursively visits each node, counting up the -// statistics. This one records the vertex index array -// associated with a GeomPrimitive, as opposed to the -// vertex data array, component of a GeomVertexData. -//////////////////////////////////////////////////////////////////// +/** + * Recursively visits each node, counting up the statistics. This one records + * the vertex index array associated with a GeomPrimitive, as opposed to the + * vertex data array, component of a GeomVertexData. + */ void SceneGraphAnalyzer:: collect_prim_statistics(const GeomVertexArrayData *vadata) { nassertv(vadata != NULL); diff --git a/panda/src/pgraphnodes/sceneGraphAnalyzer.h b/panda/src/pgraphnodes/sceneGraphAnalyzer.h index 0b1545c7c6..f8d0201766 100644 --- a/panda/src/pgraphnodes/sceneGraphAnalyzer.h +++ b/panda/src/pgraphnodes/sceneGraphAnalyzer.h @@ -1,16 +1,15 @@ -// Filename: sceneGraphAnalyzer.h -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sceneGraphAnalyzer.h + * @author drose + * @date 2000-07-02 + */ #ifndef SCENEGRAPHANALYZER_H #define SCENEGRAPHANALYZER_H @@ -31,11 +30,10 @@ class GeomVertexFormat; class GeomVertexArrayData; class Texture; -//////////////////////////////////////////////////////////////////// -// Class : SceneGraphAnalyzer -// Description : A handy class that can scrub over a scene graph and -// collect interesting statistics on it. -//////////////////////////////////////////////////////////////////// +/** + * A handy class that can scrub over a scene graph and collect interesting + * statistics on it. + */ class EXPCL_PANDA_PGRAPHNODES SceneGraphAnalyzer { PUBLISHED: SceneGraphAnalyzer(); diff --git a/panda/src/pgraphnodes/selectiveChildNode.I b/panda/src/pgraphnodes/selectiveChildNode.I index 8e0202b9a7..a7b886d61a 100644 --- a/panda/src/pgraphnodes/selectiveChildNode.I +++ b/panda/src/pgraphnodes/selectiveChildNode.I @@ -1,23 +1,19 @@ -// Filename: selectiveChildNode.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file selectiveChildNode.I + * @author drose + * @date 2002-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SelectiveChildNode:: SelectiveChildNode(const string &name) : PandaNode(name), @@ -25,11 +21,9 @@ SelectiveChildNode(const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SelectiveChildNode:: SelectiveChildNode(const SelectiveChildNode ©) : PandaNode(copy), @@ -37,13 +31,10 @@ SelectiveChildNode(const SelectiveChildNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::select_child -// Access: Protected -// Description: Selects the indicated child for rendering. This is -// normally called during the cull_callback() method, -// but it may be called at any time. -//////////////////////////////////////////////////////////////////// +/** + * Selects the indicated child for rendering. This is normally called during + * the cull_callback() method, but it may be called at any time. + */ INLINE void SelectiveChildNode:: select_child(int n) { nassertv(n >= 0); diff --git a/panda/src/pgraphnodes/selectiveChildNode.cxx b/panda/src/pgraphnodes/selectiveChildNode.cxx index 403c697177..0fb38560aa 100644 --- a/panda/src/pgraphnodes/selectiveChildNode.cxx +++ b/panda/src/pgraphnodes/selectiveChildNode.cxx @@ -1,70 +1,56 @@ -// Filename: selectiveChildNode.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file selectiveChildNode.cxx + * @author drose + * @date 2002-03-06 + */ #include "selectiveChildNode.h" TypeHandle SelectiveChildNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::has_selective_visibility -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if this kind of node has some restrictions on -// the set of children that should be rendered. Node -// with this property include LODNodes, SwitchNodes, and -// SequenceNodes. -// -// If this function returns true, -// get_first_visible_child() and -// get_next_visible_child() will be called to walk -// through the list of children during cull, instead of -// iterating through the entire list. This method is -// called after cull_callback(), so cull_callback() may -// be responsible for the decisions as to which children -// are visible at the moment. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if this kind of node + * has some restrictions on the set of children that should be rendered. Node + * with this property include LODNodes, SwitchNodes, and SequenceNodes. + * + * If this function returns true, get_first_visible_child() and + * get_next_visible_child() will be called to walk through the list of + * children during cull, instead of iterating through the entire list. This + * method is called after cull_callback(), so cull_callback() may be + * responsible for the decisions as to which children are visible at the + * moment. + */ bool SelectiveChildNode:: has_selective_visibility() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::get_first_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the first visible child -// of this node, or a number >= get_num_children() if -// there are no visible children of this node. This is -// called during the cull traversal, but only if -// has_selective_visibility() has already returned true. -// See has_selective_visibility(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first visible child of this node, or a + * number >= get_num_children() if there are no visible children of this node. + * This is called during the cull traversal, but only if + * has_selective_visibility() has already returned true. See + * has_selective_visibility(). + */ int SelectiveChildNode:: get_first_visible_child() const { return _selected_child; } -//////////////////////////////////////////////////////////////////// -// Function: SelectiveChildNode::get_next_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the next visible child -// of this node following the indicated child, or a -// number >= get_num_children() if there are no more -// visible children of this node. See -// has_selective_visibility() and -// get_first_visible_child(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the next visible child of this node following + * the indicated child, or a number >= get_num_children() if there are no more + * visible children of this node. See has_selective_visibility() and + * get_first_visible_child(). + */ int SelectiveChildNode:: get_next_visible_child(int n) const { return get_num_children(); diff --git a/panda/src/pgraphnodes/selectiveChildNode.h b/panda/src/pgraphnodes/selectiveChildNode.h index 352dfe5289..2175c5d13f 100644 --- a/panda/src/pgraphnodes/selectiveChildNode.h +++ b/panda/src/pgraphnodes/selectiveChildNode.h @@ -1,16 +1,15 @@ -// Filename: selectiveChildNode.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file selectiveChildNode.h + * @author drose + * @date 2002-03-06 + */ #ifndef SELECTIVECHILDNODE_H #define SELECTIVECHILDNODE_H @@ -19,11 +18,10 @@ #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : SelectiveChildNode -// Description : A base class for nodes like LODNode and SequenceNode -// that select only one visible child at a time. -//////////////////////////////////////////////////////////////////// +/** + * A base class for nodes like LODNode and SequenceNode that select only one + * visible child at a time. + */ class EXPCL_PANDA_PGRAPHNODES SelectiveChildNode : public PandaNode { PUBLISHED: INLINE SelectiveChildNode(const string &name); @@ -40,10 +38,10 @@ protected: INLINE void select_child(int n); private: - // Not sure if this should be cycled or not. It's not exactly - // thread-safe not to cycle it, but it doesn't really need the full - // pipeline control. It's probably a problem in the non-thread-safe - // design; need to rethink the design a bit. + // Not sure if this should be cycled or not. It's not exactly thread-safe + // not to cycle it, but it doesn't really need the full pipeline control. + // It's probably a problem in the non-thread-safe design; need to rethink + // the design a bit. int _selected_child; public: diff --git a/panda/src/pgraphnodes/sequenceNode.I b/panda/src/pgraphnodes/sequenceNode.I index f867adbd5e..823a19ea4c 100644 --- a/panda/src/pgraphnodes/sequenceNode.I +++ b/panda/src/pgraphnodes/sequenceNode.I @@ -1,23 +1,19 @@ -// Filename: sequenceNode.I -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sequenceNode.I + * @author drose + * @date 2002-03-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SequenceNode:: SequenceNode(const string &name) : SelectiveChildNode(name) @@ -25,14 +21,11 @@ SequenceNode(const string &name) : set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::set_frame_rate -// Access: Published -// Description: Changes the advertised frame rate of the -// SequenceNode. This can be used in conjunction with -// get_play_rate() to change the effective frame rate of -// the node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the advertised frame rate of the SequenceNode. This can be used in + * conjunction with get_play_rate() to change the effective frame rate of the + * node. + */ INLINE void SequenceNode:: set_frame_rate(double frame_rate) { AnimInterface::set_frame_rate(frame_rate); diff --git a/panda/src/pgraphnodes/sequenceNode.cxx b/panda/src/pgraphnodes/sequenceNode.cxx index 761f841bfb..b8f3ffb8e0 100644 --- a/panda/src/pgraphnodes/sequenceNode.cxx +++ b/panda/src/pgraphnodes/sequenceNode.cxx @@ -1,16 +1,15 @@ -// Filename: sequenceNode.cxx -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sequenceNode.cxx + * @author drose + * @date 2002-03-06 + */ #include "pandabase.h" #include "sequenceNode.h" @@ -18,11 +17,9 @@ TypeHandle SequenceNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SequenceNode:: SequenceNode(const SequenceNode ©) : SelectiveChildNode(copy), @@ -30,184 +27,141 @@ SequenceNode(const SequenceNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::get_num_frames -// Access: Published, Virtual -// Description: Returns the number of frames in the animation. This -// is a property of the animation and may not be -// directly adjusted by the user (although it may change -// without warning with certain kinds of animations, -// since this is a virtual method that may be -// overridden). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames in the animation. This is a property of the + * animation and may not be directly adjusted by the user (although it may + * change without warning with certain kinds of animations, since this is a + * virtual method that may be overridden). + */ int SequenceNode:: get_num_frames() const { return get_num_children(); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool SequenceNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool SequenceNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *SequenceNode:: make_copy() const { return new SequenceNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool SequenceNode:: cull_callback(CullTraverser *, CullTraverserData &) { select_child(get_frame()); return true; } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::get_first_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the first visible child -// of this node, or a number >= get_num_children() if -// there are no visible children of this node. This is -// called during the cull traversal, but only if -// has_selective_visibility() has already returned true. -// See has_selective_visibility(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first visible child of this node, or a + * number >= get_num_children() if there are no visible children of this node. + * This is called during the cull traversal, but only if + * has_selective_visibility() has already returned true. See + * has_selective_visibility(). + */ int SequenceNode:: get_first_visible_child() const { return get_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::has_single_child_visibility -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if this kind of node has the special property -// that just one of its children is visible at any given -// time, and furthermore that the particular visible -// child can be determined without reference to any -// external information (such as a camera). At present, -// only SequenceNodes and SwitchNodes fall into this -// category. -// -// If this function returns true, get_visible_child() -// can be called to return the index of the -// currently-visible child. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if this kind of node + * has the special property that just one of its children is visible at any + * given time, and furthermore that the particular visible child can be + * determined without reference to any external information (such as a + * camera). At present, only SequenceNodes and SwitchNodes fall into this + * category. + * + * If this function returns true, get_visible_child() can be called to return + * the index of the currently-visible child. + */ bool SequenceNode:: has_single_child_visibility() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::get_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the currently visible -// child of this node. This is only meaningful if -// has_single_child_visibility() has returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the currently visible child of this node. This + * is only meaningful if has_single_child_visibility() has returned true. + */ int SequenceNode:: get_visible_child() const { return get_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SequenceNode:: output(ostream &out) const { out << get_type() << " " << get_name() << ": "; AnimInterface::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// SequenceNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type SequenceNode. + */ void SequenceNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SequenceNode:: write_datagram(BamWriter *manager, Datagram &dg) { SelectiveChildNode::write_datagram(manager, dg); AnimInterface::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type SequenceNode is encountered -// in the Bam file. It should create the SequenceNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type SequenceNode is encountered in the Bam file. It should create the + * SequenceNode and extract its information from the file. + */ TypedWritable *SequenceNode:: make_from_bam(const FactoryParams ¶ms) { SequenceNode *node = new SequenceNode(""); @@ -220,13 +174,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SequenceNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SequenceNode. + */ void SequenceNode:: fillin(DatagramIterator &scan, BamReader *manager) { SelectiveChildNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/sequenceNode.h b/panda/src/pgraphnodes/sequenceNode.h index 9ec1cd0f14..13a7a826fa 100644 --- a/panda/src/pgraphnodes/sequenceNode.h +++ b/panda/src/pgraphnodes/sequenceNode.h @@ -1,16 +1,15 @@ -// Filename: sequenceNode.h -// Created by: drose (06Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sequenceNode.h + * @author drose + * @date 2002-03-06 + */ #ifndef SEQUENCENODE_H #define SEQUENCENODE_H @@ -21,11 +20,10 @@ #include "animInterface.h" #include "clockObject.h" -//////////////////////////////////////////////////////////////////// -// Class : SequenceNode -// Description : A node that automatically cycles through rendering -// each one of its children according to its frame rate. -//////////////////////////////////////////////////////////////////// +/** + * A node that automatically cycles through rendering each one of its children + * according to its frame rate. + */ class EXPCL_PANDA_PGRAPHNODES SequenceNode : public SelectiveChildNode, public AnimInterface { PUBLISHED: INLINE SequenceNode(const string &name); diff --git a/panda/src/pgraphnodes/shaderGenerator.I b/panda/src/pgraphnodes/shaderGenerator.I index 09f2a92df0..a024873766 100644 --- a/panda/src/pgraphnodes/shaderGenerator.I +++ b/panda/src/pgraphnodes/shaderGenerator.I @@ -1,14 +1,12 @@ -// Filename: shaderGenerator.I -// Created by: jyelon (15Dec07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderGenerator.I + * @author jyelon + * @date 2007-12-15 + */ diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 702b9f3130..794c3123a9 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -1,20 +1,21 @@ -// Filename: shaderGenerator.cxx -// Created by: jyelon (15Dec07) -// Updated by: weifengh, PandaSE(15Apr10) -// Updated by: agartner, PandaSE(16Apr10) - bug fix to synthesize_shader; -// TextureStage::M_modulate (before this, separate textures formatted as -// alpha wiped color off resulting rgb) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderGenerator.cxx + * @author jyelon + * @date 2007-12-15 + * @author weifengh, PandaSE + * @date 2010-04-15 + * @author agartner, PandaSE + * @date 2010-04-16 + * TextureStage::M_modulate (before this, separate textures formatted as + * alpha wiped color off resulting rgb) + */ #include "shaderGenerator.h" @@ -48,21 +49,18 @@ TypeHandle ShaderGenerator::_type_handle; #ifdef HAVE_CG -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::Constructor -// Access: Published -// Description: Create a ShaderGenerator. This has no state, -// except possibly to cache certain results. -// The parameter that must be passed is the GSG to -// which the shader generator belongs. -//////////////////////////////////////////////////////////////////// +/** + * Create a ShaderGenerator. This has no state, except possibly to cache + * certain results. The parameter that must be passed is the GSG to which the + * shader generator belongs. + */ ShaderGenerator:: ShaderGenerator(GraphicsStateGuardianBase *gsg, GraphicsOutputBase *host) : _gsg(gsg), _host(host) { - // The ATTR# input semantics seem to map to generic vertex attributes - // in both arbvp1 and glslv, which behave more consistently. However, - // they don't exist in Direct3D 9. Use this silly little check for now. + // The ATTR# input semantics seem to map to generic vertex attributes in + // both arbvp1 and glslv, which behave more consistently. However, they + // don't exist in Direct3D 9. Use this silly little check for now. #ifdef _WIN32 _use_generic_attr = !gsg->get_supports_hlsl(); #else @@ -70,22 +68,17 @@ ShaderGenerator(GraphicsStateGuardianBase *gsg, GraphicsOutputBase *host) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::Destructor -// Access: Published, Virtual -// Description: Destroy a ShaderGenerator. -//////////////////////////////////////////////////////////////////// +/** + * Destroy a ShaderGenerator. + */ ShaderGenerator:: ~ShaderGenerator() { } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::reset_register_allocator -// Access: Protected -// Description: Clears the register allocator. Initially, the pool -// of available registers is empty. You have to add -// some if you want there to be any. -//////////////////////////////////////////////////////////////////// +/** + * Clears the register allocator. Initially, the pool of available registers + * is empty. You have to add some if you want there to be any. + */ void ShaderGenerator:: reset_register_allocator() { _vtregs_used = 0; @@ -94,11 +87,9 @@ reset_register_allocator() { _fcregs_used = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::alloc_vreg -// Access: Protected -// Description: Allocate a vreg. -//////////////////////////////////////////////////////////////////// +/** + * Allocate a vreg. + */ const char *ShaderGenerator:: alloc_vreg() { if (_use_generic_attr) { @@ -138,8 +129,8 @@ alloc_vreg() { case 1: _vcregs_used += 1; return "COLOR1"; } } - // These don't exist in arbvp1, though they're reportedly - // supported by other profiles. + // These don't exist in arbvp1, though they're reportedly supported by other + // profiles. switch (_vtregs_used) { case 8: _vtregs_used += 1; return "TEXCOORD8"; case 9: _vtregs_used += 1; return "TEXCOORD9"; @@ -153,11 +144,9 @@ alloc_vreg() { return "UNKNOWN"; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::alloc_freg -// Access: Protected -// Description: Allocate a freg. -//////////////////////////////////////////////////////////////////// +/** + * Allocate a freg. + */ const char *ShaderGenerator:: alloc_freg() { switch (_ftregs_used) { @@ -170,14 +159,13 @@ alloc_freg() { case 6: _ftregs_used += 1; return "TEXCOORD6"; case 7: _ftregs_used += 1; return "TEXCOORD7"; } - // We really shouldn't rely on COLOR fregs, - // since the clamping can have unexpected side-effects. - //switch (_fcregs_used) { - //case 0: _fcregs_used += 1; return "COLOR0"; - //case 1: _fcregs_used += 1; return "COLOR1"; - //} - // These don't exist in arbvp1/arbfp1, though they're - // reportedly supported by other profiles. +/* + * We really shouldn't rely on COLOR fregs, since the clamping can have + * unexpected side-effects. switch (_fcregs_used) { case 0: _fcregs_used += + * 1; return "COLOR0"; case 1: _fcregs_used += 1; return "COLOR1"; } These + * don't exist in arbvp1arbfp1, though they're reportedly supported by other + * profiles. + */ switch (_ftregs_used) { case 8: _ftregs_used += 1; return "TEXCOORD8"; case 9: _ftregs_used += 1; return "TEXCOORD9"; @@ -191,18 +179,15 @@ alloc_freg() { return "UNKNOWN"; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::analyze_renderstate -// Access: Protected -// Description: Analyzes the RenderState prior to shader generation. -// The results of the analysis are stored in instance -// variables of the Shader Generator. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes the RenderState prior to shader generation. The results of the + * analysis are stored in instance variables of the Shader Generator. + */ void ShaderGenerator:: analyze_renderstate(const RenderState *rs) { clear_analysis(); - // verify_enforce_attrib_lock(); + // verify_enforce_attrib_lock(); _state = rs; const AuxBitplaneAttrib *aux_bitplane; rs->get_attrib_def(aux_bitplane); @@ -320,8 +305,8 @@ analyze_renderstate(const RenderState *rs) { } } - // See if there is a normal map, height map, gloss map, or glow map. - // Also check if anything has TexGen. + // See if there is a normal map, height map, gloss map, or glow map. Also + // check if anything has TexGen. const TexGenAttrib *tex_gen; rs->get_attrib_def(tex_gen); @@ -433,8 +418,8 @@ analyze_renderstate(const RenderState *rs) { _separate_ambient_diffuse = true; } - // Do we want to use the ARB_shadow extension? - // This also allows us to use hardware shadows / PCF. + // Do we want to use the ARB_shadow extension? This also allows us to use + // hardware shadows PCF. _use_shadow_filter = _gsg->get_supports_shadow_filter(); @@ -472,13 +457,10 @@ analyze_renderstate(const RenderState *rs) { } } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::clear_analysis -// Access: Protected -// Description: Called after analyze_renderstate to discard all -// the results of the analysis. This is generally done -// after shader generation is complete. -//////////////////////////////////////////////////////////////////// +/** + * Called after analyze_renderstate to discard all the results of the + * analysis. This is generally done after shader generation is complete. + */ void ShaderGenerator:: clear_analysis() { _vertex_colors = false; @@ -524,13 +506,10 @@ clear_analysis() { _lights_np.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::create_shader_attrib -// Access: Protected -// Description: Creates a ShaderAttrib given a generated shader's -// body. Also inserts the lights into the shader -// attrib. -//////////////////////////////////////////////////////////////////// +/** + * Creates a ShaderAttrib given a generated shader's body. Also inserts the + * lights into the shader attrib. + */ CPT(RenderAttrib) ShaderGenerator:: create_shader_attrib(const string &txt) { PT(Shader) shader = Shader::make(txt, Shader::SL_Cg); @@ -542,40 +521,24 @@ create_shader_attrib(const string &txt) { return shattr; } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::synthesize_shader -// Access: Published, Virtual -// Description: This is the routine that implements the next-gen -// fixed function pipeline by synthesizing a shader. -// It also takes care of setting up any buffers -// needed to produce the requested effects. -// -// Currently supports: -// - flat colors -// - vertex colors -// - lighting -// - normal maps, but not multiple -// - gloss maps, but not multiple -// - glow maps, but not multiple -// - materials, but not updates to materials -// - 2D textures -// - all texture stage modes, including combine modes -// - color scale attrib -// - light ramps (for cartoon shading) -// - shadow mapping -// - most texgen modes -// - texmatrix -// - 1D/2D/3D textures, cube textures, 2D tex arrays -// - linear/exp/exp2 fog -// - animation -// -// Not yet supported: -// - dot3_rgb and dot3_rgba combine modes -// -// Potential optimizations -// - omit attenuation calculations if attenuation off -// -//////////////////////////////////////////////////////////////////// +/** + * This is the routine that implements the next-gen fixed function pipeline by + * synthesizing a shader. It also takes care of setting up any buffers needed + * to produce the requested effects. + * + * Currently supports: - flat colors - vertex colors - lighting - normal maps, + * but not multiple - gloss maps, but not multiple - glow maps, but not + * multiple - materials, but not updates to materials - 2D textures - all + * texture stage modes, including combine modes - color scale attrib - light + * ramps (for cartoon shading) - shadow mapping - most texgen modes - + * texmatrix - 1D/2D/3D textures, cube textures, 2D tex arrays - + * linear/exp/exp2 fog - animation + * + * Not yet supported: - dot3_rgb and dot3_rgba combine modes + * + * Potential optimizations - omit attenuation calculations if attenuation off + * + */ CPT(ShaderAttrib) ShaderGenerator:: synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { analyze_renderstate(rs); @@ -936,7 +899,8 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { if (_out_aux_any) { text << "\t o_aux = float4(0, 0, 0, 0);\n"; } - // Now generate any texture coordinates according to TexGenAttrib. If it has a TexMatrixAttrib, also transform them. + // Now generate any texture coordinates according to TexGenAttrib. If it + // has a TexMatrixAttrib, also transform them. for (int i=0; i<_num_textures; i++) { TextureStage *stage = texture->get_on_stage(i); if (tex_gen != NULL && tex_gen->has_stage(stage)) { @@ -1011,7 +975,8 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { if (i != _map_index_height) { Texture *tex = texture->get_on_texture(texture->get_on_stage(i)); nassertr(tex != NULL, NULL); - // Parallax mapping pushes the texture coordinates of the other textures away from the camera. + // Parallax mapping pushes the texture coordinates of the other textures + // away from the camera. if (_map_index_height >= 0 && parallax_mapping_samples > 0) { text << "\t texcoord" << i << ".xyz -= parallax_offset;\n"; } @@ -1258,8 +1223,8 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } text << "\t // End view-space light calculations\n"; - // Combine in alpha, which bypasses lighting calculations. - // Use of lerp here is a workaround for a radeon driver bug. + // Combine in alpha, which bypasses lighting calculations. Use of lerp + // here is a workaround for a radeon driver bug. if (_calc_primary_alpha) { if (_vertex_colors) { text << "\t result.a = l_color.a;\n"; @@ -1279,7 +1244,8 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } } - // Loop first to see if something is using primary_color or last_saved_result. + // Loop first to see if something is using primary_color or + // last_saved_result. bool have_saved_result = false; bool have_primary_color = false; for (int i=0; i<_num_textures; i++) { @@ -1313,13 +1279,11 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { break; } case TextureStage::M_modulate_glow: case TextureStage::M_modulate_gloss: - //in the case of glow or spec we currently see the specularity evenly across the surface - //even if transparency or masking is present - //not sure if this is desired behavior or not. - //*MOST* would construct a spec map based off of - //what is/isn't seen based on the mask/transparency - //this may have to be left alone for now - //agartner + // in the case of glow or spec we currently see the specularity evenly + // across the surface even if transparency or masking is present not + // sure if this is desired behavior or not. *MOST* would construct a + // spec map based off of what isisn't seen based on the masktransparency + // this may have to be left alone for now agartner text << "\t result.rgb *= tex" << i << ";\n"; break; case TextureStage::M_decal: @@ -1466,8 +1430,8 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { } } - // The multiply is a workaround for a radeon driver bug. - // It's annoying as heck, since it produces an extra instruction. + // The multiply is a workaround for a radeon driver bug. It's annoying as + // heck, since it produces an extra instruction. text << "\t o_color = result * 1.000001;\n"; if (_subsume_alpha_test) { text << "\t // Shader subsumes normal alpha test.\n"; @@ -1490,11 +1454,9 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { return DCAST(ShaderAttrib, shattr); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::combine_mode_as_string -// Access: Protected, Static -// Description: This 'synthesizes' a combine mode into a string. -//////////////////////////////////////////////////////////////////// +/** + * This 'synthesizes' a combine mode into a string. + */ const string ShaderGenerator:: combine_mode_as_string(CPT(TextureStage) stage, TextureStage::CombineMode c_mode, bool alpha, short texindex) { ostringstream text; @@ -1547,11 +1509,9 @@ combine_mode_as_string(CPT(TextureStage) stage, TextureStage::CombineMode c_mode return text.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::combine_source_as_string -// Access: Protected, Static -// Description: This 'synthesizes' a combine source into a string. -//////////////////////////////////////////////////////////////////// +/** + * This 'synthesizes' a combine source into a string. + */ const string ShaderGenerator:: combine_source_as_string(CPT(TextureStage) stage, short num, bool alpha, bool single_value, short texindex) { TextureStage::CombineSource c_src = TextureStage::CS_undefined; @@ -1632,12 +1592,9 @@ combine_source_as_string(CPT(TextureStage) stage, short num, bool alpha, bool si return csource.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ShaderGenerator::texture_type_as_string -// Access: Protected, Static -// Description: Returns 1D, 2D, 3D or CUBE, depending on the given -// texture type. -//////////////////////////////////////////////////////////////////// +/** + * Returns 1D, 2D, 3D or CUBE, depending on the given texture type. + */ const string ShaderGenerator:: texture_type_as_string(Texture::TextureType ttype) { switch (ttype) { diff --git a/panda/src/pgraphnodes/shaderGenerator.h b/panda/src/pgraphnodes/shaderGenerator.h index 50c35d2d89..9564bd6120 100644 --- a/panda/src/pgraphnodes/shaderGenerator.h +++ b/panda/src/pgraphnodes/shaderGenerator.h @@ -1,17 +1,17 @@ -// Filename: shaderGenerator.h -// Created by: jyelon (15Dec07) -// Updated by: weifengh, PandaSE(15Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file shaderGenerator.h + * @author jyelon + * @date 2007-12-15 + * @author weifengh, PandaSE + * @date 2010-04-15 + */ #ifndef SHADERGENERATOR_H #define SHADERGENERATOR_H @@ -35,39 +35,29 @@ class Spotlight; class LightAttrib; class GeomVertexAnimationSpec; -//////////////////////////////////////////////////////////////////// -// Class : ShaderGenerator -// Description : The ShaderGenerator is a device that effectively -// replaces the classic fixed function pipeline with -// a 'next-gen' fixed function pipeline. The next-gen -// fixed function pipeline supports features like -// normal mapping, gloss mapping, cartoon lighting, -// and so forth. It works by automatically generating -// a shader from a given RenderState. -// -// Currently, there is one ShaderGenerator object per -// GraphicsStateGuardian. It is our intent that in -// time, people will write classes that derive from -// ShaderGenerator but which yield slightly different -// results. -// -// The ShaderGenerator owes its existence to the -// 'Bamboo Team' at Carnegie Mellon's Entertainment -// Technology Center. This is a group of students -// who, as a semester project, decided that next-gen -// graphics should be accessible to everyone, even if -// they don't know shader programming. The group -// consisted of: -// -// Aaron Lo, Programmer -// Heegun Lee, Programmer -// Erin Fernandez, Artist/Tester -// Joe Grubb, Artist/Tester -// Ivan Ortega, Technical Artist/Tester -// -// Thanks to them! -// -//////////////////////////////////////////////////////////////////// +/** + * The ShaderGenerator is a device that effectively replaces the classic fixed + * function pipeline with a 'next-gen' fixed function pipeline. The next-gen + * fixed function pipeline supports features like normal mapping, gloss + * mapping, cartoon lighting, and so forth. It works by automatically + * generating a shader from a given RenderState. + * + * Currently, there is one ShaderGenerator object per GraphicsStateGuardian. + * It is our intent that in time, people will write classes that derive from + * ShaderGenerator but which yield slightly different results. + * + * The ShaderGenerator owes its existence to the 'Bamboo Team' at Carnegie + * Mellon's Entertainment Technology Center. This is a group of students who, + * as a semester project, decided that next-gen graphics should be accessible + * to everyone, even if they don't know shader programming. The group + * consisted of: + * + * Aaron Lo, Programmer Heegun Lee, Programmer Erin Fernandez, Artist/Tester + * Joe Grubb, Artist/Tester Ivan Ortega, Technical Artist/Tester + * + * Thanks to them! + * + */ class EXPCL_PANDA_PGRAPHNODES ShaderGenerator : public TypedReferenceCount { PUBLISHED: ShaderGenerator(GraphicsStateGuardianBase *gsg, GraphicsOutputBase *host); diff --git a/panda/src/pgraphnodes/spotlight.I b/panda/src/pgraphnodes/spotlight.I index 7c1fdf7ddd..1f42638873 100644 --- a/panda/src/pgraphnodes/spotlight.I +++ b/panda/src/pgraphnodes/spotlight.I @@ -1,23 +1,19 @@ -// Filename: spotlight.I -// Created by: mike (04eb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spotlight.I + * @author mike + * @date 1999-02-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Spotlight::CData:: CData() : _exponent(50.0f), @@ -26,11 +22,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Spotlight::CData:: CData(const Spotlight::CData ©) : _exponent(copy._exponent), @@ -39,42 +33,34 @@ CData(const Spotlight::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_exponent -// Access: Public, Final -// Description: Returns the exponent that controls the amount of -// light falloff from the center of the spotlight. See -// set_exponent(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the exponent that controls the amount of light falloff from the + * center of the spotlight. See set_exponent(). + */ INLINE PN_stdfloat Spotlight:: get_exponent() const { CDReader cdata(_cycler); return cdata->_exponent; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::set_exponent -// Access: Public -// Description: Sets the exponent that controls the amount of light -// falloff from the center of the spotlight. The light -// is attenuated by the cosine of the angle between the -// direction of the light and the direction of the point -// being lighted, raised to the power of this exponent. -// Thus, higher exponents result in a more focused light -// source, regardless of the field-of-view of the lens. -//////////////////////////////////////////////////////////////////// +/** + * Sets the exponent that controls the amount of light falloff from the center + * of the spotlight. The light is attenuated by the cosine of the angle + * between the direction of the light and the direction of the point being + * lighted, raised to the power of this exponent. Thus, higher exponents + * result in a more focused light source, regardless of the field-of-view of + * the lens. + */ INLINE void Spotlight:: set_exponent(PN_stdfloat exponent) { CDWriter cdata(_cycler); cdata->_exponent = exponent; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_specular_color -// Access: Public, Final -// Description: Returns the color of specular highlights generated by -// the light. This is usually the same as get_color(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of specular highlights generated by the light. This is + * usually the same as get_color(). + */ INLINE const LColor &Spotlight:: get_specular_color() const { if (_has_specular_color) { @@ -85,12 +71,9 @@ get_specular_color() const { } } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::set_specular_color -// Access: Public -// Description: Sets the color of specular highlights generated by -// the light. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of specular highlights generated by the light. + */ INLINE void Spotlight:: set_specular_color(const LColor &color) { CDWriter cdata(_cycler); @@ -98,39 +81,31 @@ set_specular_color(const LColor &color) { cdata->_specular_color = color; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::clear_specular_color -// Access: Public -// Description: Clears a custom specular color setting, meaning that -// the specular color will now come from the color. -//////////////////////////////////////////////////////////////////// +/** + * Clears a custom specular color setting, meaning that the specular color + * will now come from the color. + */ INLINE void Spotlight:: clear_specular_color() { _has_specular_color = false; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_attenuation -// Access: Public, Final -// Description: Returns the terms of the attenuation equation for the -// light. These are, in order, the constant, linear, -// and quadratic terms based on the distance from the -// point to the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Returns the terms of the attenuation equation for the light. These are, in + * order, the constant, linear, and quadratic terms based on the distance from + * the point to the vertex. + */ INLINE const LVecBase3 &Spotlight:: get_attenuation() const { CDReader cdata(_cycler); return cdata->_attenuation; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::set_attenuation -// Access: Public -// Description: Sets the terms of the attenuation equation for the -// light. These are, in order, the constant, linear, -// and quadratic terms based on the distance from the -// point to the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets the terms of the attenuation equation for the light. These are, in + * order, the constant, linear, and quadratic terms based on the distance from + * the point to the vertex. + */ INLINE void Spotlight:: set_attenuation(const LVecBase3 &attenuation) { CDWriter cdata(_cycler); diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index ad4f75eb63..b9de0ea121 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -1,16 +1,15 @@ -// Filename: spotlight.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spotlight.cxx + * @author mike + * @date 1997-01-09 + */ #include "spotlight.h" #include "graphicsStateGuardianBase.h" @@ -25,22 +24,18 @@ TypeHandle Spotlight::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *Spotlight::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Spotlight::CData:: write_datagram(BamWriter *, Datagram &dg) const { dg.add_stdfloat(_exponent); @@ -48,13 +43,10 @@ write_datagram(BamWriter *, Datagram &dg) const { _attenuation.write_datagram(dg); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Light. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Light. + */ void Spotlight::CData:: fillin(DatagramIterator &scan, BamReader *) { _exponent = scan.get_stdfloat(); @@ -62,25 +54,20 @@ fillin(DatagramIterator &scan, BamReader *) { _attenuation.read_datagram(scan); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Spotlight:: -Spotlight(const string &name) : +Spotlight(const string &name) : LightLensNode(name), _has_specular_color(false) { } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::Copy Constructor -// Access: Protected -// Description: Do not call the copy constructor directly; instead, -// use make_copy() or copy_subgraph() to make a copy of -// a node. -//////////////////////////////////////////////////////////////////// +/** + * Do not call the copy constructor directly; instead, use make_copy() or + * copy_subgraph() to make a copy of a node. + */ Spotlight:: Spotlight(const Spotlight ©) : LightLensNode(copy), @@ -89,38 +76,29 @@ Spotlight(const Spotlight ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated PandaNode that is a shallow -// copy of this one. It will be a different pointer, -// but its internal data may or may not be shared with -// that of the original PandaNode. No children will be -// copied. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PandaNode that is a shallow copy of this one. It + * will be a different pointer, but its internal data may or may not be shared + * with that of the original PandaNode. No children will be copied. + */ PandaNode *Spotlight:: make_copy() const { return new Spotlight(*this); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::xform -// Access: Public, Virtual -// Description: Transforms the contents of this PandaNode by the -// indicated matrix, if it means anything to do so. For -// most kinds of PandaNodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this PandaNode by the indicated matrix, if it + * means anything to do so. For most kinds of PandaNodes, this does nothing. + */ void Spotlight:: xform(const LMatrix4 &mat) { - LightLensNode::xform(mat); + LightLensNode::xform(mat); mark_viz_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Spotlight:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << ":\n"; @@ -141,47 +119,36 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_vector_to_light -// Access: Public, Virtual -// Description: Computes the vector from a particular vertex to this -// light. The exact vector depends on the type of light -// (e.g. point lights return a different result than -// directional lights). -// -// The input parameters are the vertex position in -// question, expressed in object space, and the matrix -// which converts from light space to object space. The -// result is expressed in object space. -// -// The return value is true if the result is successful, -// or false if it cannot be computed (e.g. for an -// ambient light). -//////////////////////////////////////////////////////////////////// +/** + * Computes the vector from a particular vertex to this light. The exact + * vector depends on the type of light (e.g. point lights return a different + * result than directional lights). + * + * The input parameters are the vertex position in question, expressed in + * object space, and the matrix which converts from light space to object + * space. The result is expressed in object space. + * + * The return value is true if the result is successful, or false if it cannot + * be computed (e.g. for an ambient light). + */ bool Spotlight:: -get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, +get_vector_to_light(LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::make_spot -// Access: Published, Static -// Description: Returns a newly-generated Texture that renders a -// circular spot image as might be cast from the -// spotlight. This may be projected onto target -// geometry (for instance, via -// NodePath::project_texture()) instead of actually -// enabling the light itself, as a cheesy way to make a -// high-resolution spot appear on the geometry. -// -// pixel_width specifies the height and width of the new -// texture in pixels, full_radius is a value in the -// range 0..1 that indicates the relative size of the -// fully bright center spot, and fg and bg are the -// colors of the interior and exterior of the spot, -// respectively. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-generated Texture that renders a circular spot image as + * might be cast from the spotlight. This may be projected onto target + * geometry (for instance, via NodePath::project_texture()) instead of + * actually enabling the light itself, as a cheesy way to make a high- + * resolution spot appear on the geometry. + * + * pixel_width specifies the height and width of the new texture in pixels, + * full_radius is a value in the range 0..1 that indicates the relative size + * of the fully bright center spot, and fg and bg are the colors of the + * interior and exterior of the spot, respectively. + */ PT(Texture) Spotlight:: make_spot(int pixel_width, PN_stdfloat full_radius, LColor &fg, LColor &bg) { int num_channels; @@ -212,44 +179,36 @@ make_spot(int pixel_width, PN_stdfloat full_radius, LColor &fg, LColor &bg) { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_class_priority -// Access: Published, Virtual -// Description: Returns the relative priority associated with all -// lights of this class. This priority is used to order -// lights whose instance priority (get_priority()) is -// the same--the idea is that other things being equal, -// AmbientLights (for instance) are less important than -// DirectionalLights. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative priority associated with all lights of this class. + * This priority is used to order lights whose instance priority + * (get_priority()) is the same--the idea is that other things being equal, + * AmbientLights (for instance) are less important than DirectionalLights. + */ int Spotlight:: get_class_priority() const { return (int)CP_spot_priority; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::bind -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Spotlight:: bind(GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id) { gsg->bind_light(this, light, light_id); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::fill_viz_geom -// Access: Protected, Virtual -// Description: Fills the indicated GeomNode up with Geoms suitable -// for rendering this light. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated GeomNode up with Geoms suitable for rendering this + * light. + */ void Spotlight:: fill_viz_geom(GeomNode *viz_geom) { Lens *lens = get_lens(); if (lens == (Lens *)NULL) { return; } - + PT(Geom) geom = lens->make_geometry(); if (geom == (Geom *)NULL) { return; @@ -258,35 +217,27 @@ fill_viz_geom(GeomNode *viz_geom) { viz_geom->add_geom(geom, get_viz_state()); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::get_viz_state -// Access: Private -// Description: Returns a RenderState for rendering the spotlight -// visualization. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState for rendering the spotlight visualization. + */ CPT(RenderState) Spotlight:: get_viz_state() { return RenderState::make (ColorAttrib::make_flat(get_color())); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Spotlight. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Spotlight. + */ void Spotlight:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void Spotlight:: write_datagram(BamWriter *manager, Datagram &dg) { LightLensNode::write_datagram(manager, dg); @@ -294,14 +245,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Spotlight is encountered -// in the Bam file. It should create the Spotlight -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Spotlight is encountered in the Bam file. It should create the + * Spotlight and extract its information from the file. + */ TypedWritable *Spotlight:: make_from_bam(const FactoryParams ¶ms) { Spotlight *node = new Spotlight(""); @@ -314,13 +262,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: Spotlight::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new Spotlight. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new Spotlight. + */ void Spotlight:: fillin(DatagramIterator &scan, BamReader *manager) { LightLensNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/spotlight.h b/panda/src/pgraphnodes/spotlight.h index 4b28d286e9..5a5cb18c01 100644 --- a/panda/src/pgraphnodes/spotlight.h +++ b/panda/src/pgraphnodes/spotlight.h @@ -1,16 +1,15 @@ -// Filename: spotlight.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file spotlight.h + * @author mike + * @date 1997-01-09 + */ #ifndef SPOTLIGHT_H #define SPOTLIGHT_H @@ -20,20 +19,16 @@ #include "lightLensNode.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : Spotlight -// Description : A light originating from a single point in space, and -// shining in a particular direction, with a cone-shaped -// falloff. -// -// The Spotlight frustum is defined using a Lens, so it -// can have any of the properties that a camera lens can -// have. -// -// Note that the class is named Spotlight instead of -// SpotLight, because "spotlight" is a single English -// word, instead of two words. -//////////////////////////////////////////////////////////////////// +/** + * A light originating from a single point in space, and shining in a + * particular direction, with a cone-shaped falloff. + * + * The Spotlight frustum is defined using a Lens, so it can have any of the + * properties that a camera lens can have. + * + * Note that the class is named Spotlight instead of SpotLight, because + * "spotlight" is a single English word, instead of two words. + */ class EXPCL_PANDA_PGRAPHNODES Spotlight : public LightLensNode { PUBLISHED: Spotlight(const string &name); diff --git a/panda/src/pgraphnodes/switchNode.I b/panda/src/pgraphnodes/switchNode.I index 0386a1e32e..451ec655df 100644 --- a/panda/src/pgraphnodes/switchNode.I +++ b/panda/src/pgraphnodes/switchNode.I @@ -1,44 +1,36 @@ -// Filename: switchNode.I -// Created by: drose (31Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file switchNode.I + * @author drose + * @date 2002-07-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SwitchNode::CData:: CData() { _visible_child = 0; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SwitchNode::CData:: CData(const SwitchNode::CData ©) : _visible_child(copy._visible_child) { } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SwitchNode:: SwitchNode(const string &name) : SelectiveChildNode(name) @@ -46,12 +38,10 @@ SwitchNode(const string &name) : set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::set_visible_child -// Access: Published -// Description: Specifies the particular child of this node, by -// index, that will be visible. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular child of this node, by index, that will be + * visible. + */ INLINE void SwitchNode:: set_visible_child(int index) { nassertv(index >= 0); diff --git a/panda/src/pgraphnodes/switchNode.cxx b/panda/src/pgraphnodes/switchNode.cxx index a49a9e2467..d16afc56c4 100644 --- a/panda/src/pgraphnodes/switchNode.cxx +++ b/panda/src/pgraphnodes/switchNode.cxx @@ -1,16 +1,15 @@ -// Filename: switchNode.cxx -// Created by: drose (31Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file switchNode.cxx + * @author drose + * @date 2002-07-31 + */ #include "pandabase.h" #include "switchNode.h" @@ -18,73 +17,56 @@ TypeHandle SwitchNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *SwitchNode::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// particular kind of PandaNode with other kinds of -// PandaNodes of compatible type, adding children or -// whatever. For instance, an LODNode should not be -// combined with any other PandaNode, because its set of -// children is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this particular kind of + * PandaNode with other kinds of PandaNodes of compatible type, adding + * children or whatever. For instance, an LODNode should not be combined with + * any other PandaNode, because its set of children is meaningful. + */ bool SwitchNode:: safe_to_combine() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::safe_to_combine_children -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine the -// children of this PandaNode with each other. For -// instance, an LODNode's children should not be -// combined with each other, because the set of children -// is meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine the children of this + * PandaNode with each other. For instance, an LODNode's children should not + * be combined with each other, because the set of children is meaningful. + */ bool SwitchNode:: safe_to_combine_children() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SwitchNode::CData:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_int32(_visible_child); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SwitchNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SwitchNode. + */ void SwitchNode::CData:: fillin(DatagramIterator &scan, BamReader *manager) { _visible_child = scan.get_int32(); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SwitchNode:: SwitchNode(const SwitchNode ©) : SelectiveChildNode(copy), @@ -92,128 +74,100 @@ SwitchNode(const SwitchNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *SwitchNode:: make_copy() const { return new SwitchNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool SwitchNode:: cull_callback(CullTraverser *, CullTraverserData &) { select_child(get_visible_child()); return true; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::get_first_visible_child -// Access: Public, Virtual -// Description: Returns the index number of the first visible child -// of this node, or a number >= get_num_children() if -// there are no visible children of this node. This is -// called during the cull traversal, but only if -// has_selective_visibility() has already returned true. -// See has_selective_visibility(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first visible child of this node, or a + * number >= get_num_children() if there are no visible children of this node. + * This is called during the cull traversal, but only if + * has_selective_visibility() has already returned true. See + * has_selective_visibility(). + */ int SwitchNode:: get_first_visible_child() const { return get_visible_child(); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::has_single_child_visibility -// Access: Public, Virtual -// Description: Should be overridden by derived classes to return -// true if this kind of node has the special property -// that just one of its children is visible at any given -// time, and furthermore that the particular visible -// child can be determined without reference to any -// external information (such as a camera). At present, -// only SequenceNodes and SwitchNodes fall into this -// category. -// -// If this function returns true, get_visible_child() -// can be called to return the index of the -// currently-visible child. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by derived classes to return true if this kind of node + * has the special property that just one of its children is visible at any + * given time, and furthermore that the particular visible child can be + * determined without reference to any external information (such as a + * camera). At present, only SequenceNodes and SwitchNodes fall into this + * category. + * + * If this function returns true, get_visible_child() can be called to return + * the index of the currently-visible child. + */ bool SwitchNode:: has_single_child_visibility() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::get_visible_child -// Access: Published, Virtual -// Description: Returns the index of the child that should be visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the child that should be visible. + */ int SwitchNode:: get_visible_child() const { CDReader cdata(_cycler); return cdata->_visible_child; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// SwitchNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type SwitchNode. + */ void SwitchNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SwitchNode:: write_datagram(BamWriter *manager, Datagram &dg) { SelectiveChildNode::write_datagram(manager, dg); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type SwitchNode is encountered -// in the Bam file. It should create the SwitchNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type SwitchNode is encountered in the Bam file. It should create the + * SwitchNode and extract its information from the file. + */ TypedWritable *SwitchNode:: make_from_bam(const FactoryParams ¶ms) { SwitchNode *node = new SwitchNode(""); @@ -226,13 +180,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: SwitchNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SwitchNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SwitchNode. + */ void SwitchNode:: fillin(DatagramIterator &scan, BamReader *manager) { SelectiveChildNode::fillin(scan, manager); diff --git a/panda/src/pgraphnodes/switchNode.h b/panda/src/pgraphnodes/switchNode.h index 6bb0c50066..eca88dd541 100644 --- a/panda/src/pgraphnodes/switchNode.h +++ b/panda/src/pgraphnodes/switchNode.h @@ -1,16 +1,15 @@ -// Filename: switchNode.h -// Created by: drose (31Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file switchNode.h + * @author drose + * @date 2002-07-31 + */ #ifndef SWITCHNODE_H #define SWITCHNODE_H @@ -19,11 +18,10 @@ #include "selectiveChildNode.h" -//////////////////////////////////////////////////////////////////// -// Class : SwitchNode -// Description : A node that renders only one of its children, -// according to the user's indication. -//////////////////////////////////////////////////////////////////// +/** + * A node that renders only one of its children, according to the user's + * indication. + */ class EXPCL_PANDA_PGRAPHNODES SwitchNode : public SelectiveChildNode { PUBLISHED: INLINE SwitchNode(const string &name); diff --git a/panda/src/pgraphnodes/uvScrollNode.I b/panda/src/pgraphnodes/uvScrollNode.I index c83c2d572a..3fb849edc9 100644 --- a/panda/src/pgraphnodes/uvScrollNode.I +++ b/panda/src/pgraphnodes/uvScrollNode.I @@ -1,23 +1,19 @@ -// Filename: uvScrollNode.I -// Created by: zpavlov (30june09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file uvScrollNode.I + * @author zpavlov + * @date 2009-06-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UvScrollNode:: UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed) : PandaNode(name), @@ -26,15 +22,13 @@ UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_st _w_speed(w_speed), _r_speed(r_speed), _start_time(ClockObject::get_global_clock()->get_frame_time()) -{ +{ set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UvScrollNode:: UvScrollNode(const string &name) : PandaNode(name), @@ -43,96 +37,78 @@ UvScrollNode(const string &name) : _w_speed(0), _r_speed(0), _start_time(ClockObject::get_global_clock()->get_frame_time()) -{ +{ set_cull_callback(); } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::set_u_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void UvScrollNode:: set_u_speed(PN_stdfloat u_speed) { _u_speed = u_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::set_v_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void UvScrollNode:: set_v_speed(PN_stdfloat v_speed) { _v_speed = v_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::set_w_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void UvScrollNode:: set_w_speed(PN_stdfloat w_speed) { _w_speed = w_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::set_r_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void UvScrollNode:: set_r_speed(PN_stdfloat r_speed) { _r_speed = r_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvSctrollNode::get_u_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat UvScrollNode:: get_u_speed() const { return _u_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::get_v_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat UvScrollNode:: get_v_speed() const { return _v_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::get_w_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat UvScrollNode:: get_w_speed() const { return _w_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvSctrollNode::get_r_speed -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat UvScrollNode:: get_r_speed() const { return _r_speed; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UvScrollNode:: UvScrollNode(const UvScrollNode ©) : PandaNode(copy), diff --git a/panda/src/pgraphnodes/uvScrollNode.cxx b/panda/src/pgraphnodes/uvScrollNode.cxx index 358ac2c075..caa9e55635 100644 --- a/panda/src/pgraphnodes/uvScrollNode.cxx +++ b/panda/src/pgraphnodes/uvScrollNode.cxx @@ -1,16 +1,15 @@ -// Filename: uvScrollNode.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file uvScrollNode.cxx + * @author drose + * @date 2002-03-16 + */ #include "uvScrollNode.h" @@ -27,36 +26,28 @@ TypeHandle UvScrollNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *UvScrollNode:: make_copy() const { return new UvScrollNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: UvSctrollNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// UvScrollNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type UvScrollNode. + */ void UvScrollNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: UvSctrollNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void UvScrollNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -66,14 +57,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_r_speed); } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ModelNode is encountered -// in the Bam file. It should create the ModelNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ModelNode is encountered in the Bam file. It should create the + * ModelNode and extract its information from the file. + */ TypedWritable *UvScrollNode:: make_from_bam(const FactoryParams ¶ms) { UvScrollNode *node = new UvScrollNode(""); @@ -86,13 +74,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: ModelNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ModelNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ModelNode. + */ void UvScrollNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); @@ -108,31 +93,24 @@ fillin(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: SequenceNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is \true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is \true if this node should be visible, or false if it + * should be culled. + */ bool UvScrollNode:: cull_callback(CullTraverser * trav, CullTraverserData &data) { double elapsed = ClockObject::get_global_clock()->get_frame_time() - _start_time; @@ -149,27 +127,21 @@ cull_callback(CullTraverser * trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::safe_to_flatten -// Access: Public, Virtual -// Description: Returns true if it is generally safe to flatten out -// this particular kind of PandaNode by duplicating -// instances (by calling dupe_for_flatten()), false -// otherwise (for instance, a Camera cannot be safely -// flattened, because the Camera pointer itself is -// meaningful). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to flatten out this particular kind of + * PandaNode by duplicating instances (by calling dupe_for_flatten()), false + * otherwise (for instance, a Camera cannot be safely flattened, because the + * Camera pointer itself is meaningful). + */ bool UvScrollNode:: safe_to_flatten() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: UvScrollNode::safe_to_combine -// Access: Public, Virtual -// Description: Returns true if it is generally safe to combine this -// with other nodes, which it isn't, so don't. Ever. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if it is generally safe to combine this with other nodes, + * which it isn't, so don't. Ever. + */ bool UvScrollNode:: safe_to_combine() const { return false; diff --git a/panda/src/pgraphnodes/uvScrollNode.h b/panda/src/pgraphnodes/uvScrollNode.h index e5a7a4e754..8e59f335e6 100644 --- a/panda/src/pgraphnodes/uvScrollNode.h +++ b/panda/src/pgraphnodes/uvScrollNode.h @@ -1,16 +1,15 @@ -// Filename: uvScrollNode.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file uvScrollNode.h + * @author drose + * @date 2002-03-16 + */ #ifndef UVSCROLLNODE_H #define UVSCROLLNODE_H @@ -21,11 +20,9 @@ #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : UvScrollNode -// Description : This node is placed at key points within the scene -// graph to animate uvs. -//////////////////////////////////////////////////////////////////// +/** + * This node is placed at key points within the scene graph to animate uvs. + */ class EXPCL_PANDA_PGRAPH UvScrollNode : public PandaNode { PUBLISHED: INLINE UvScrollNode(const string &name, PN_stdfloat u_speed, PN_stdfloat v_speed, PN_stdfloat w_speed, PN_stdfloat r_speed); @@ -93,5 +90,3 @@ private: #include "uvScrollNode.I" #endif - - diff --git a/panda/src/pgui/config_pgui.cxx b/panda/src/pgui/config_pgui.cxx index c7e3314fe0..7a1682cc96 100644 --- a/panda/src/pgui/config_pgui.cxx +++ b/panda/src/pgui/config_pgui.cxx @@ -1,16 +1,15 @@ -// Filename: config_pgui.cxx -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgui.cxx + * @author drose + * @date 2001-07-02 + */ #include "config_pgui.h" #include "pgButton.h" @@ -48,14 +47,12 @@ ConfigVariableDouble scroll_continued_delay "scrolled while the user is continuing to hold down the scrollbar " "button.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpgui -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpgui() { static bool initialized = false; diff --git a/panda/src/pgui/config_pgui.h b/panda/src/pgui/config_pgui.h index 4280f7e6fe..012663cf15 100644 --- a/panda/src/pgui/config_pgui.h +++ b/panda/src/pgui/config_pgui.h @@ -1,16 +1,15 @@ -// Filename: config_pgui.h -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pgui.h + * @author drose + * @date 2001-07-02 + */ #ifndef CONFIG_PGUI_H #define CONFIG_PGUI_H diff --git a/panda/src/pgui/pgButton.I b/panda/src/pgui/pgButton.I index fd423d4c3d..ab7f44f503 100644 --- a/panda/src/pgui/pgButton.I +++ b/panda/src/pgui/pgButton.I @@ -1,108 +1,85 @@ -// Filename: pgButton.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButton.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGButton::set_notify -// Access: Published -// Description: Sets the object which will be notified when the -// PGButton changes. Set this to NULL to disable -// this effect. The PGButton does not retain -// ownership of the pointer; it is your responsibility -// to ensure that the notify object does not destruct. -//////////////////////////////////////////////////////////////////// -INLINE void PGButton:: +/** + * Sets the object which will be notified when the PGButton changes. Set this + * to NULL to disable this effect. The PGButton does not retain ownership of + * the pointer; it is your responsibility to ensure that the notify object + * does not destruct. + */ +INLINE void PGButton:: set_notify(PGButtonNotify *notify) { PGItem::set_notify(notify); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::get_notify -// Access: Published -// Description: Returns the object which will be notified when the -// PGButton changes, if any. Returns NULL if there -// is no such object configured. -//////////////////////////////////////////////////////////////////// -INLINE PGButtonNotify *PGButton:: +/** + * Returns the object which will be notified when the PGButton changes, if + * any. Returns NULL if there is no such object configured. + */ +INLINE PGButtonNotify *PGButton:: get_notify() const { return (PGButtonNotify *)PGItem::get_notify(); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::setup -// Access: Published -// Description: Sets up the button using the indicated NodePath as -// arbitrary geometry. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the button using the indicated NodePath as arbitrary geometry. + */ INLINE void PGButton:: setup(const NodePath &ready) { setup(ready, ready, ready, ready); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::setup -// Access: Published -// Description: Sets up the button using the indicated NodePath as -// arbitrary geometry. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the button using the indicated NodePath as arbitrary geometry. + */ INLINE void PGButton:: setup(const NodePath &ready, const NodePath &depressed) { setup(ready, depressed, ready, ready); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::setup -// Access: Published -// Description: Sets up the button using the indicated NodePath as -// arbitrary geometry. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the button using the indicated NodePath as arbitrary geometry. + */ INLINE void PGButton:: -setup(const NodePath &ready, const NodePath &depressed, +setup(const NodePath &ready, const NodePath &depressed, const NodePath &rollover) { setup(ready, depressed, rollover, ready); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::get_click_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the click -// event for all PGButtons. The click event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the click event for all + * PGButtons. The click event is the concatenation of this string followed by + * get_id(). + */ INLINE string PGButton:: get_click_prefix() { return "click-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::get_click_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// button is clicked normally. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the button is clicked + * normally. + */ INLINE string PGButton:: get_click_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_click_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::is_button_down -// Access: Published -// Description: Returns true if the user is currently holding the -// mouse button down on the button, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the user is currently holding the mouse button down on the + * button, false otherwise. + */ INLINE bool PGButton:: is_button_down() { LightReMutexHolder holder(_lock); diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index aed6d9ea36..14821b017e 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -1,16 +1,15 @@ -// Filename: pgButton.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButton.cxx + * @author drose + * @date 2002-03-13 + */ #include "pgButton.h" #include "pgMouseWatcherParameter.h" @@ -23,11 +22,9 @@ TypeHandle PGButton::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGButton::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGButton:: PGButton(const string &name) : PGItem(name) { @@ -37,20 +34,16 @@ PGButton(const string &name) : PGItem(name) set_active(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGButton:: ~PGButton() { } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGButton:: PGButton(const PGButton ©) : PGItem(copy), @@ -59,26 +52,21 @@ PGButton(const PGButton ©) : _button_down = false; } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGButton:: make_copy() const { LightReMutexHolder holder(_lock); return new PGButton(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::enter_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse enters the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse enters the + * region. + */ void PGButton:: enter_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -88,12 +76,10 @@ enter_region(const MouseWatcherParameter ¶m) { PGItem::enter_region(param); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::exit_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse exits the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse exits the + * region. + */ void PGButton:: exit_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -103,13 +89,10 @@ exit_region(const MouseWatcherParameter ¶m) { PGItem::exit_region(param); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the region. + */ void PGButton:: press(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -122,13 +105,10 @@ press(const MouseWatcherParameter ¶m, bool background) { PGItem::press(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void PGButton:: release(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -146,12 +126,10 @@ release(const MouseWatcherParameter ¶m, bool background) { PGItem::release(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::click -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// button is clicked down-and-up by the user normally. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the button is clicked + * down-and-up by the user normally. + */ void PGButton:: click(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -165,15 +143,12 @@ click(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::setup -// Access: Published -// Description: Sets up the button as a default text button using the -// indicated label string. The TextNode defined by -// PGItem::get_text_node() will be used to create the -// label geometry. This automatically sets up the frame -// according to the size of the text. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the button as a default text button using the indicated label + * string. The TextNode defined by PGItem::get_text_node() will be used to + * create the label geometry. This automatically sets up the frame according + * to the size of the text. + */ void PGButton:: setup(const string &label, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); @@ -224,14 +199,11 @@ setup(const string &label, PN_stdfloat bevel) { inactive->add_child(geom); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::setup -// Access: Published -// Description: Sets up the button using the indicated NodePath as -// arbitrary geometry. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the button using the indicated NodePath as arbitrary geometry. + */ void PGButton:: -setup(const NodePath &ready, const NodePath &depressed, +setup(const NodePath &ready, const NodePath &depressed, const NodePath &rollover, const NodePath &inactive) { LightReMutexHolder holder(_lock); clear_state_def(S_ready); @@ -251,14 +223,11 @@ setup(const NodePath &ready, const NodePath &depressed, min_point[2], max_point[2]); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::set_active -// Access: Published, Virtual -// Description: Toggles the active/inactive state of the button. In -// the case of a PGButton, this also changes its visual -// appearance. -//////////////////////////////////////////////////////////////////// -void PGButton:: +/** + * Toggles the active/inactive state of the button. In the case of a + * PGButton, this also changes its visual appearance. + */ +void PGButton:: set_active(bool active) { LightReMutexHolder holder(_lock); if (active != get_active()) { @@ -267,45 +236,35 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::add_click_button -// Access: Published -// Description: Adds the indicated button to the set of buttons that -// can effectively "click" the PGButton. Normally, this -// is just MouseButton::one(). Returns true if the -// button was added, or false if it was already there. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated button to the set of buttons that can effectively + * "click" the PGButton. Normally, this is just MouseButton::one(). Returns + * true if the button was added, or false if it was already there. + */ bool PGButton:: add_click_button(const ButtonHandle &button) { LightReMutexHolder holder(_lock); return _click_buttons.insert(button).second; } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::remove_click_button -// Access: Published -// Description: Removes the indicated button from the set of buttons -// that can effectively "click" the PGButton. Normally, -// this is just MouseButton::one(). Returns true if the -// button was removed, or false if it was not in the -// set. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated button from the set of buttons that can effectively + * "click" the PGButton. Normally, this is just MouseButton::one(). Returns + * true if the button was removed, or false if it was not in the set. + */ bool PGButton:: remove_click_button(const ButtonHandle &button) { LightReMutexHolder holder(_lock); return (_click_buttons.erase(button) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: PGButton::has_click_button -// Access: Published -// Description: Returns true if the indicated button is on the set of -// buttons that can effectively "click" the PGButton. -// Normally, this is just MouseButton::one(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is on the set of buttons that can + * effectively "click" the PGButton. Normally, this is just + * MouseButton::one(). + */ bool PGButton:: has_click_button(const ButtonHandle &button) { LightReMutexHolder holder(_lock); return (_click_buttons.count(button) != 0); } - diff --git a/panda/src/pgui/pgButton.h b/panda/src/pgui/pgButton.h index 837294f5c1..494ed45428 100644 --- a/panda/src/pgui/pgButton.h +++ b/panda/src/pgui/pgButton.h @@ -1,16 +1,15 @@ -// Filename: pgButton.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButton.h + * @author drose + * @date 2002-03-13 + */ #ifndef PGBUTTON_H #define PGBUTTON_H @@ -22,13 +21,11 @@ #include "nodePath.h" #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : PGButton -// Description : This is a particular kind of PGItem that is -// specialized to behave like a normal button object. -// It keeps track of its own state, and handles mouse -// events sensibly. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of PGItem that is specialized to behave like a + * normal button object. It keeps track of its own state, and handles mouse + * events sensibly. + */ class EXPCL_PANDA_PGUI PGButton : public PGItem { PUBLISHED: PGButton(const string &name); @@ -61,7 +58,7 @@ PUBLISHED: void setup(const string &label, PN_stdfloat bevel = 0.1f); INLINE void setup(const NodePath &ready); INLINE void setup(const NodePath &ready, const NodePath &depressed); - INLINE void setup(const NodePath &ready, const NodePath &depressed, + INLINE void setup(const NodePath &ready, const NodePath &depressed, const NodePath &rollover); void setup(const NodePath &ready, const NodePath &depressed, const NodePath &rollover, const NodePath &inactive); diff --git a/panda/src/pgui/pgButtonNotify.I b/panda/src/pgui/pgButtonNotify.I index 6b52071fbf..06bf2c31e7 100644 --- a/panda/src/pgui/pgButtonNotify.I +++ b/panda/src/pgui/pgButtonNotify.I @@ -1,23 +1,19 @@ -// Filename: pgButtonNotify.I -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButtonNotify.I + * @author drose + * @date 2005-08-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGButtonNotify::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGButtonNotify:: PGButtonNotify() { } diff --git a/panda/src/pgui/pgButtonNotify.cxx b/panda/src/pgui/pgButtonNotify.cxx index 2ec92476ee..2656f6850f 100644 --- a/panda/src/pgui/pgButtonNotify.cxx +++ b/panda/src/pgui/pgButtonNotify.cxx @@ -1,25 +1,22 @@ -// Filename: pgButtonNotify.cxx -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButtonNotify.cxx + * @author drose + * @date 2005-08-18 + */ #include "pgButtonNotify.h" #include "pgButton.h" -//////////////////////////////////////////////////////////////////// -// Function: PGButtonNotify::button_click -// Access: Protected, Virtual -// Description: Called whenever a watched PGButton has been clicked. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGButton has been clicked. + */ void PGButtonNotify:: button_click(PGButton *, const MouseWatcherParameter &) { } diff --git a/panda/src/pgui/pgButtonNotify.h b/panda/src/pgui/pgButtonNotify.h index 0d5b53c4dc..07f5feb5d2 100644 --- a/panda/src/pgui/pgButtonNotify.h +++ b/panda/src/pgui/pgButtonNotify.h @@ -1,16 +1,15 @@ -// Filename: pgButtonNotify.h -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgButtonNotify.h + * @author drose + * @date 2005-08-18 + */ #ifndef PGBUTTONNOTIFY_H #define PGBUTTONNOTIFY_H @@ -20,12 +19,10 @@ class PGButton; -//////////////////////////////////////////////////////////////////// -// Class : PGButtonNotify -// Description : Objects that inherit from this class can receive -// notify messages when a slider bar moves or otherwise -// is reconfigured. -//////////////////////////////////////////////////////////////////// +/** + * Objects that inherit from this class can receive notify messages when a + * slider bar moves or otherwise is reconfigured. + */ class EXPCL_PANDA_PGUI PGButtonNotify : public PGItemNotify { public: INLINE PGButtonNotify(); diff --git a/panda/src/pgui/pgCullTraverser.I b/panda/src/pgui/pgCullTraverser.I index c7f781cf15..b939a324a0 100644 --- a/panda/src/pgui/pgCullTraverser.I +++ b/panda/src/pgui/pgCullTraverser.I @@ -1,23 +1,19 @@ -// Filename: pgCullTraverser.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgCullTraverser.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGCullTraverser::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGCullTraverser:: PGCullTraverser(PGTop *top, CullTraverser *trav) : CullTraverser(*trav), diff --git a/panda/src/pgui/pgCullTraverser.cxx b/panda/src/pgui/pgCullTraverser.cxx index dd2f5a380b..915b913479 100644 --- a/panda/src/pgui/pgCullTraverser.cxx +++ b/panda/src/pgui/pgCullTraverser.cxx @@ -1,16 +1,15 @@ -// Filename: pgCullTraverser.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgCullTraverser.cxx + * @author drose + * @date 2002-03-14 + */ #include "pgCullTraverser.h" diff --git a/panda/src/pgui/pgCullTraverser.h b/panda/src/pgui/pgCullTraverser.h index 2d2b1231c5..e43a6a4c85 100644 --- a/panda/src/pgui/pgCullTraverser.h +++ b/panda/src/pgui/pgCullTraverser.h @@ -1,16 +1,15 @@ -// Filename: pgCullTraverser.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgCullTraverser.h + * @author drose + * @date 2002-03-14 + */ #ifndef PGCULLTRAVERSER_H #define PGCULLTRAVERSER_H @@ -20,15 +19,12 @@ #include "pgTop.h" #include "cullTraverser.h" -//////////////////////////////////////////////////////////////////// -// Class : PGCullTraverser -// Description : This is a specialization of CullTraverser for use -// within the pgui system. It is substituted in for the -// normal CullTraverser by the PGTop node. Its purpose -// is to carry additional data through the traversal so -// that PGItems can know how to register their regions -// with the current MouseWatcherGroup. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization of CullTraverser for use within the pgui system. + * It is substituted in for the normal CullTraverser by the PGTop node. Its + * purpose is to carry additional data through the traversal so that PGItems + * can know how to register their regions with the current MouseWatcherGroup. + */ class EXPCL_PANDA_PGUI PGCullTraverser : public CullTraverser { public: INLINE PGCullTraverser(PGTop *top, CullTraverser *trav); @@ -57,6 +53,3 @@ private: #include "pgCullTraverser.I" #endif - - - diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index 28881c5c84..e90ebce374 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -1,31 +1,25 @@ -// Filename: pgEntry.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgEntry.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_text -// Access: Published -// Description: Changes the text currently displayed within the -// entry. This uses the Unicode encoding currently -// specified for the "focus" TextNode; therefore, the -// TextNode must exist before calling set_text(). -// -// The return value is true if all the text is accepted, -// or false if some was truncated (see set_max_width(), -// etc.). -//////////////////////////////////////////////////////////////////// -INLINE bool PGEntry:: +/** + * Changes the text currently displayed within the entry. This uses the + * Unicode encoding currently specified for the "focus" TextNode; therefore, + * the TextNode must exist before calling set_text(). + * + * The return value is true if all the text is accepted, or false if some was + * truncated (see set_max_width(), etc.). + */ +INLINE bool PGEntry:: set_text(const string &text) { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); @@ -33,17 +27,14 @@ set_text(const string &text) { return set_wtext(text_node->decode_text(text)); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_plain_text -// Access: Published -// Description: Returns the text currently displayed within the -// entry, without any embedded properties characters. -// -// This uses the Unicode encoding currently specified -// for the "focus" TextNode; therefore, the TextNode -// must exist before calling get_text(). -//////////////////////////////////////////////////////////////////// -INLINE string PGEntry:: +/** + * Returns the text currently displayed within the entry, without any embedded + * properties characters. + * + * This uses the Unicode encoding currently specified for the "focus" + * TextNode; therefore, the TextNode must exist before calling get_text(). + */ +INLINE string PGEntry:: get_plain_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); @@ -51,15 +42,12 @@ get_plain_text() const { return text_node->encode_wtext(get_plain_wtext()); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_text -// Access: Published -// Description: Returns the text currently displayed within the -// entry. This uses the Unicode encoding currently -// specified for the "focus" TextNode; therefore, the -// TextNode must exist before calling get_text(). -//////////////////////////////////////////////////////////////////// -INLINE string PGEntry:: +/** + * Returns the text currently displayed within the entry. This uses the + * Unicode encoding currently specified for the "focus" TextNode; therefore, + * the TextNode must exist before calling get_text(). + */ +INLINE string PGEntry:: get_text() const { LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); @@ -67,74 +55,58 @@ get_text() const { return text_node->encode_wtext(get_wtext()); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_num_characters -// Access: Published -// Description: Returns the number of characters of text in the -// entry. This is the actual number of visible -// characters, not counting implicit newlines due to -// wordwrapping, or formatted characters for text -// properties changes. If there is an embedded -// TextGraphic object, it counts as one character. -// -// This is also the length of the string returned by -// get_plain_text(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of characters of text in the entry. This is the actual + * number of visible characters, not counting implicit newlines due to + * wordwrapping, or formatted characters for text properties changes. If + * there is an embedded TextGraphic object, it counts as one character. + * + * This is also the length of the string returned by get_plain_text(). + */ INLINE int PGEntry:: get_num_characters() const { LightReMutexHolder holder(_lock); return _text.get_num_characters(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_character -// Access: Published -// Description: Returns the character at the indicated position in -// the entry. If the object at this position is a -// graphic object instead of a character, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the character at the indicated position in the entry. If the + * object at this position is a graphic object instead of a character, returns + * 0. + */ INLINE wchar_t PGEntry:: get_character(int n) const { LightReMutexHolder holder(_lock); return _text.get_character(n); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_graphic -// Access: Published -// Description: Returns the graphic object at the indicated position -// in the pre-wordwrapped string. If the object at this -// position is a character instead of a graphic object, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphic object at the indicated position in the pre-wordwrapped + * string. If the object at this position is a character instead of a graphic + * object, returns NULL. + */ INLINE const TextGraphic *PGEntry:: get_graphic(int n) const { LightReMutexHolder holder(_lock); return _text.get_graphic(n); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_properties -// Access: Published -// Description: Returns the TextProperties in effect for the object -// at the indicated position in the pre-wordwrapped -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextProperties in effect for the object at the indicated + * position in the pre-wordwrapped string. + */ INLINE const TextProperties &PGEntry:: get_properties(int n) const { LightReMutexHolder holder(_lock); return _text.get_properties(n); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_cursor_position -// Access: Published -// Description: Sets the current position of the cursor. This is the -// position within the text at which the next letter -// typed by the user will be inserted; normally it is -// the same as the length of the text. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets the current position of the cursor. This is the position within the + * text at which the next letter typed by the user will be inserted; normally + * it is the same as the length of the text. + */ +INLINE void PGEntry:: set_cursor_position(int position) { LightReMutexHolder holder(_lock); if (_cursor_position != position) { @@ -144,114 +116,93 @@ set_cursor_position(int position) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursor_position -// Access: Published -// Description: Returns the current position of the cursor. -//////////////////////////////////////////////////////////////////// -INLINE int PGEntry:: +/** + * Returns the current position of the cursor. + */ +INLINE int PGEntry:: get_cursor_position() const { LightReMutexHolder holder(_lock); return _cursor_position; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursor_X -// Access: Published -// Description: Returns the node position x of the cursor -//////////////////////////////////////////////////////////////////// +/** + * Returns the node position x of the cursor + */ -INLINE PN_stdfloat PGEntry:: +INLINE PN_stdfloat PGEntry:: get_cursor_X() const { LightReMutexHolder holder(_lock); return _cursor_def.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursor_y -// Access: Published -// Description: Returns the node position y of the cursor -//////////////////////////////////////////////////////////////////// +/** + * Returns the node position y of the cursor + */ -INLINE PN_stdfloat PGEntry:: +INLINE PN_stdfloat PGEntry:: get_cursor_Y() const { LightReMutexHolder holder(_lock); return _cursor_def.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_max_chars -// Access: Published -// Description: Sets the maximum number of characters that may be -// typed into the entry. This is a limit on the number -// of characters, as opposed to the width of the entry; -// see also set_max_width(). -// -// If this is 0, there is no limit. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets the maximum number of characters that may be typed into the entry. + * This is a limit on the number of characters, as opposed to the width of the + * entry; see also set_max_width(). + * + * If this is 0, there is no limit. + */ +INLINE void PGEntry:: set_max_chars(int max_chars) { LightReMutexHolder holder(_lock); _max_chars = max_chars; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_max_chars -// Access: Published -// Description: Returns the current maximum number of characters that -// may be typed into the entry, or 0 if there is no -// limit. See set_max_chars(). -//////////////////////////////////////////////////////////////////// -INLINE int PGEntry:: +/** + * Returns the current maximum number of characters that may be typed into the + * entry, or 0 if there is no limit. See set_max_chars(). + */ +INLINE int PGEntry:: get_max_chars() const { LightReMutexHolder holder(_lock); return _max_chars; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_max_width -// Access: Published -// Description: Sets the maximum width of all characters that may be -// typed into the entry. This is a limit on the width -// of the formatted text, not a fixed limit on the -// number of characters; also set_max_chars(). -// -// If this is 0, there is no limit. -// -// If _num_lines is more than 1, rather than being a -// fixed width on the whole entry, this becomes instead -// the wordwrap width (and the width limit on the entry -// is essentially _max_width * _num_lines). -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets the maximum width of all characters that may be typed into the entry. + * This is a limit on the width of the formatted text, not a fixed limit on + * the number of characters; also set_max_chars(). + * + * If this is 0, there is no limit. + * + * If _num_lines is more than 1, rather than being a fixed width on the whole + * entry, this becomes instead the wordwrap width (and the width limit on the + * entry is essentially _max_width * _num_lines). + */ +INLINE void PGEntry:: set_max_width(PN_stdfloat max_width) { LightReMutexHolder holder(_lock); _max_width = max_width; _text_geom_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_max_width -// Access: Published -// Description: Returns the current maximum width of the characters -// that may be typed into the entry, or 0 if there is no -// limit. See set_max_width(). -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGEntry:: +/** + * Returns the current maximum width of the characters that may be typed into + * the entry, or 0 if there is no limit. See set_max_width(). + */ +INLINE PN_stdfloat PGEntry:: get_max_width() const { LightReMutexHolder holder(_lock); return _max_width; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_num_lines -// Access: Published -// Description: Sets the number of lines of text the PGEntry will -// use. This only has meaning if _max_width is not 0; -// _max_width indicates the wordwrap width of each line. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets the number of lines of text the PGEntry will use. This only has + * meaning if _max_width is not 0; _max_width indicates the wordwrap width of + * each line. + */ +INLINE void PGEntry:: set_num_lines(int num_lines) { LightReMutexHolder holder(_lock); nassertv(num_lines >= 1); @@ -259,112 +210,90 @@ set_num_lines(int num_lines) { _text_geom_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_num_lines -// Access: Published -// Description: Returns the number of lines of text the PGEntry will -// use, if _max_width is not 0. See set_num_lines(). -//////////////////////////////////////////////////////////////////// -INLINE int PGEntry:: +/** + * Returns the number of lines of text the PGEntry will use, if _max_width is + * not 0. See set_num_lines(). + */ +INLINE int PGEntry:: get_num_lines() const { LightReMutexHolder holder(_lock); return _num_lines; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_blink_rate -// Access: Published -// Description: Sets the number of times per second the cursor will -// blink while the entry has keyboard focus. -// -// If this is 0, the cursor does not blink, but is held -// steady. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets the number of times per second the cursor will blink while the entry + * has keyboard focus. + * + * If this is 0, the cursor does not blink, but is held steady. + */ +INLINE void PGEntry:: set_blink_rate(PN_stdfloat blink_rate) { LightReMutexHolder holder(_lock); _blink_rate = blink_rate; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_blink_rate -// Access: Published -// Description: Returns the number of times per second the cursor -// will blink, or 0 if the cursor is not to blink. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGEntry:: +/** + * Returns the number of times per second the cursor will blink, or 0 if the + * cursor is not to blink. + */ +INLINE PN_stdfloat PGEntry:: get_blink_rate() const { LightReMutexHolder holder(_lock); return _blink_rate; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursor_def -// Access: Published -// Description: Returns the Node that will be rendered to represent -// the cursor. You can attach suitable cursor geometry -// to this node. -//////////////////////////////////////////////////////////////////// -INLINE NodePath PGEntry:: +/** + * Returns the Node that will be rendered to represent the cursor. You can + * attach suitable cursor geometry to this node. + */ +INLINE NodePath PGEntry:: get_cursor_def() { LightReMutexHolder holder(_lock); return _cursor_def; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::clear_cursor_def -// Access: Published -// Description: Removes all the children from the cursor_def node, in -// preparation for adding a new definition. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Removes all the children from the cursor_def node, in preparation for + * adding a new definition. + */ +INLINE void PGEntry:: clear_cursor_def() { LightReMutexHolder holder(_lock); _cursor_def.remove_node(); _cursor_def = _cursor_scale.attach_new_node("cursor"); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_cursor_keys_active -// Access: Published -// Description: Sets whether the arrow keys (and home/end) control -// movement of the cursor. If true, they are active; if -// false, they are ignored. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets whether the arrow keys (and home/end) control movement of the cursor. + * If true, they are active; if false, they are ignored. + */ +INLINE void PGEntry:: set_cursor_keys_active(bool flag) { LightReMutexHolder holder(_lock); _cursor_keys_active = flag; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursor_keys_active -// Access: Published -// Description: Returns whether the arrow keys are currently set to -// control movement of the cursor; see -// set_cursor_keys_active(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGEntry:: +/** + * Returns whether the arrow keys are currently set to control movement of the + * cursor; see set_cursor_keys_active(). + */ +INLINE bool PGEntry:: get_cursor_keys_active() const { LightReMutexHolder holder(_lock); return _cursor_keys_active; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_obscure_mode -// Access: Published -// Description: Specifies whether obscure mode should be enabled. In -// obscure mode, a string of asterisks is displayed -// instead of the literal text, e.g. for entering -// passwords. -// -// In obscure mode, the width of the text is computed -// based on the width of the string of asterisks, not on -// the width of the actual text. This has implications -// on the maximum length of text that may be entered if -// max_width is in effect. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Specifies whether obscure mode should be enabled. In obscure mode, a + * string of asterisks is displayed instead of the literal text, e.g. for + * entering passwords. + * + * In obscure mode, the width of the text is computed based on the width of + * the string of asterisks, not on the width of the actual text. This has + * implications on the maximum length of text that may be entered if max_width + * is in effect. + */ +INLINE void PGEntry:: set_obscure_mode(bool flag) { LightReMutexHolder holder(_lock); if (_obscure_mode != flag) { @@ -373,29 +302,22 @@ set_obscure_mode(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_obscure_mode -// Access: Published -// Description: Specifies whether obscure mode is enabled. See -// set_obscure_mode(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGEntry:: +/** + * Specifies whether obscure mode is enabled. See set_obscure_mode(). + */ +INLINE bool PGEntry:: get_obscure_mode() const { LightReMutexHolder holder(_lock); return _obscure_mode; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_overflow_mode -// Access: Published -// Description: Specifies whether overflow mode should be enabled. -// In overflow mode, text can overflow the boundaries -// of the Entry element horizontally. -// -// Overflow mode only works when the number of lines -// is 1. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Specifies whether overflow mode should be enabled. In overflow mode, text + * can overflow the boundaries of the Entry element horizontally. + * + * Overflow mode only works when the number of lines is 1. + */ +INLINE void PGEntry:: set_overflow_mode(bool flag) { LightReMutexHolder holder(_lock); if (_overflow_mode != flag) { @@ -405,237 +327,189 @@ set_overflow_mode(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_overflow_mode -// Access: Published -// Description: Specifies whether overflow mode is enabled. See -// set_overflow_mode(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGEntry:: +/** + * Specifies whether overflow mode is enabled. See set_overflow_mode(). + */ +INLINE bool PGEntry:: get_overflow_mode() const { LightReMutexHolder holder(_lock); return _overflow_mode; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_candidate_active -// Access: Published -// Description: Specifies the name of the TextProperties structure -// added to the TextPropertiesManager that will be used -// to render candidate strings from the IME, used for -// typing characters in east Asian languages. Each -// candidate string represents one possible way to -// interpret the sequence of keys the user has just -// entered; it should not be considered typed yet, but -// it is important for the user to be able to see what -// he is considering entering. -// -// This particular method sets the properties for the -// subset of the current candidate string that the user -// can actively scroll through. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Specifies the name of the TextProperties structure added to the + * TextPropertiesManager that will be used to render candidate strings from + * the IME, used for typing characters in east Asian languages. Each + * candidate string represents one possible way to interpret the sequence of + * keys the user has just entered; it should not be considered typed yet, but + * it is important for the user to be able to see what he is considering + * entering. + * + * This particular method sets the properties for the subset of the current + * candidate string that the user can actively scroll through. + */ +INLINE void PGEntry:: set_candidate_active(const string &candidate_active) { LightReMutexHolder holder(_lock); _candidate_active = candidate_active; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_candidate_active -// Access: Published -// Description: See set_candidate_active(). -//////////////////////////////////////////////////////////////////// -INLINE const string &PGEntry:: +/** + * See set_candidate_active(). + */ +INLINE const string &PGEntry:: get_candidate_active() const { LightReMutexHolder holder(_lock); return _candidate_active; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_candidate_inactive -// Access: Published -// Description: Specifies the name of the TextProperties structure -// added to the TextPropertiesManager that will be used -// to render candidate strings from the IME, used for -// typing characters in east Asian languages. Each -// candidate string represents one possible way to -// interpret the sequence of keys the user has just -// entered; it should not be considered typed yet, but -// it is important for the user to be able to see what -// he is considering entering. -// -// This particular method sets the properties for the -// subset of the current candidate string that the user -// is not actively scrolling through. -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Specifies the name of the TextProperties structure added to the + * TextPropertiesManager that will be used to render candidate strings from + * the IME, used for typing characters in east Asian languages. Each + * candidate string represents one possible way to interpret the sequence of + * keys the user has just entered; it should not be considered typed yet, but + * it is important for the user to be able to see what he is considering + * entering. + * + * This particular method sets the properties for the subset of the current + * candidate string that the user is not actively scrolling through. + */ +INLINE void PGEntry:: set_candidate_inactive(const string &candidate_inactive) { LightReMutexHolder holder(_lock); _candidate_inactive = candidate_inactive; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_candidate_inactive -// Access: Published -// Description: See set_candidate_inactive(). -//////////////////////////////////////////////////////////////////// -INLINE const string &PGEntry:: +/** + * See set_candidate_inactive(). + */ +INLINE const string &PGEntry:: get_candidate_inactive() const { LightReMutexHolder holder(_lock); return _candidate_inactive; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_accept_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the accept -// event for all PGEntries. The accept event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the accept event for all + * PGEntries. The accept event is the concatenation of this string followed + * by get_id(). + */ INLINE string PGEntry:: get_accept_prefix() { return "accept-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_accept_failed_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the accept -// failed event for all PGEntries. This event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the accept failed event for all + * PGEntries. This event is the concatenation of this string followed by + * get_id(). + */ INLINE string PGEntry:: get_accept_failed_prefix() { return "acceptfailed-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_overflow_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the overflow -// event for all PGEntries. The overflow event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the overflow event for all + * PGEntries. The overflow event is the concatenation of this string followed + * by get_id(). + */ INLINE string PGEntry:: get_overflow_prefix() { return "overflow-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_type_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the type -// event for all PGEntries. The type event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the type event for all PGEntries. + * The type event is the concatenation of this string followed by get_id(). + */ INLINE string PGEntry:: get_type_prefix() { return "type-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_erase_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the erase -// event for all PGEntries. The erase event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the erase event for all + * PGEntries. The erase event is the concatenation of this string followed by + * get_id(). + */ INLINE string PGEntry:: get_erase_prefix() { return "erase-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursormove_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the cursor -// event for all PGEntries. The cursor event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the cursor event for all + * PGEntries. The cursor event is the concatenation of this string followed + * by get_id(). + */ INLINE string PGEntry:: get_cursormove_prefix() { return "cursormove-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_accept_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// entry is accepted normally. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the entry is accepted + * normally. + */ INLINE string PGEntry:: get_accept_event(const ButtonHandle &button) const { return get_accept_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_accept_failed_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// entry cannot accept an input -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the entry cannot accept an + * input + */ INLINE string PGEntry:: get_accept_failed_event(const ButtonHandle &button) const { return get_accept_failed_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_overflow_event -// Access: Published -// Description: Returns the event name that will be thrown when too -// much text is attempted to be entered into the -// PGEntry, exceeding either the limit set via -// set_max_chars() or via set_max_width(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when too much text is attempted + * to be entered into the PGEntry, exceeding either the limit set via + * set_max_chars() or via set_max_width(). + */ INLINE string PGEntry:: get_overflow_event() const { return get_overflow_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_type_event -// Access: Published -// Description: Returns the event name that will be thrown whenever -// the user extends the text by typing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown whenever the user extends the + * text by typing. + */ INLINE string PGEntry:: get_type_event() const { return get_type_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_erase_event -// Access: Published -// Description: Returns the event name that will be thrown whenever -// the user erases characters in the text. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown whenever the user erases + * characters in the text. + */ INLINE string PGEntry:: get_erase_event() const { return get_erase_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_cursormove_event -// Access: Published -// Description: Returns the event name that will be thrown whenever -// the cursor moves -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown whenever the cursor moves + */ INLINE string PGEntry:: get_cursormove_event() const { return get_cursormove_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_wtext -// Access: Published -// Description: Changes the text currently displayed within the -// entry. -// -// The return value is true if all the text is accepted, -// or false if some was truncated (see set_max_width(), -// etc.). -//////////////////////////////////////////////////////////////////// -INLINE bool PGEntry:: +/** + * Changes the text currently displayed within the entry. + * + * The return value is true if all the text is accepted, or false if some was + * truncated (see set_max_width(), etc.). + */ +INLINE bool PGEntry:: set_wtext(const wstring &wtext) { LightReMutexHolder holder(_lock); bool ret = _text.set_wtext(wtext); @@ -647,37 +521,30 @@ set_wtext(const wstring &wtext) { return ret; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_plain_wtext -// Access: Published -// Description: Returns the text currently displayed within the -// entry, without any embedded properties characters. -//////////////////////////////////////////////////////////////////// -INLINE wstring PGEntry:: +/** + * Returns the text currently displayed within the entry, without any embedded + * properties characters. + */ +INLINE wstring PGEntry:: get_plain_wtext() const { LightReMutexHolder holder(_lock); return _text.get_plain_wtext(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_wtext -// Access: Published -// Description: Returns the text currently displayed within the -// entry. -//////////////////////////////////////////////////////////////////// -INLINE wstring PGEntry:: +/** + * Returns the text currently displayed within the entry. + */ +INLINE wstring PGEntry:: get_wtext() const { LightReMutexHolder holder(_lock); return _text.get_wtext(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_accept_enabled -// Access: Published -// Description: Sets whether the input may be accepted--use to -// disable submission by the user -//////////////////////////////////////////////////////////////////// -INLINE void PGEntry:: +/** + * Sets whether the input may be accepted--use to disable submission by the + * user + */ +INLINE void PGEntry:: set_accept_enabled(bool enabled) { LightReMutexHolder holder(_lock); _accept_enabled = enabled; diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 7775e1fdc9..12e2636e9a 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -1,16 +1,15 @@ -// Filename: pgEntry.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgEntry.cxx + * @author drose + * @date 2002-03-13 + */ #include "pgEntry.h" #include "pgMouseWatcherParameter.h" @@ -30,13 +29,11 @@ TypeHandle PGEntry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGEntry:: -PGEntry(const string &name) : +PGEntry(const string &name) : PGItem(name), _text(get_text_node()), _obscure_text(get_text_node()) @@ -68,8 +65,8 @@ PGEntry(const string &name) : _cursor_visible = true; // These strings are used to specify the TextProperties to apply to - // candidate strings generated from the IME (for entering text in an - // east Asian language). + // candidate strings generated from the IME (for entering text in an east + // Asian language). _candidate_active = "candidate_active"; _candidate_inactive = "candidate_inactive"; @@ -82,25 +79,20 @@ PGEntry(const string &name) : set_active(true); update_state(); - // Some default parameters so it doesn't crash hard if no one calls - // setup(). + // Some default parameters so it doesn't crash hard if no one calls setup(). setup_minimal(10, 1); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGEntry:: ~PGEntry() { } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGEntry:: PGEntry(const PGEntry ©) : PGItem(copy), @@ -135,27 +127,21 @@ PGEntry(const PGEntry ©) : _cursor_def = copy._cursor_def.copy_to(_cursor_scale); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGEntry:: make_copy() const { LightReMutexHolder holder(_lock); return new PGEntry(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PGEntry:: xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); @@ -163,31 +149,24 @@ xform(const LMatrix4 &mat) { _text_render_root.set_mat(_text_render_root.get_mat() * mat); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGEntry:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); @@ -203,13 +182,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard entry is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard entry + * is depressed while the mouse is within the region. + */ void PGEntry:: press(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -221,7 +197,7 @@ press(const MouseWatcherParameter ¶m, bool background) { bool overflow_mode = get_overflow_mode() && _num_lines == 1; ButtonHandle button = param.get_button(); - + if (button == MouseButton::one() || button == MouseButton::two() || button == MouseButton::three() || @@ -229,8 +205,8 @@ press(const MouseWatcherParameter ¶m, bool background) { button == MouseButton::five()) { // Mouse button; set focus. set_focus(true); - - } else if ((!background && get_focus()) || + + } else if ((!background && get_focus()) || (background && get_background_focus())) { // Keyboard button. if (!_candidate_wtext.empty()) { @@ -248,7 +224,7 @@ press(const MouseWatcherParameter ¶m, bool background) { else { accept_failed(param); } - + } else if (button == KeyboardButton::backspace()) { // Backspace. Remove the character to the left of the cursor. if (_cursor_position > 0) { @@ -258,7 +234,7 @@ press(const MouseWatcherParameter ¶m, bool background) { _text_geom_stale = true; erase(param); } - + } else if (button == KeyboardButton::del()) { // Delete. Remove the character to the right of the cursor. if (_cursor_position < _text.get_num_characters()) { @@ -266,7 +242,7 @@ press(const MouseWatcherParameter ¶m, bool background) { _text_geom_stale = true; erase(param); } - + } else if (button == KeyboardButton::left()) { if (_cursor_keys_active) { // Left arrow. Move the cursor position to the left. @@ -275,14 +251,14 @@ press(const MouseWatcherParameter ¶m, bool background) { _cursor_position = 0; overflow(param); } else { - type(param); + type(param); } _cursor_stale = true; if (overflow_mode){ _text_geom_stale = true; } } - + } else if (button == KeyboardButton::right()) { if (_cursor_keys_active) { // Right arrow. Move the cursor position to the right. @@ -298,7 +274,7 @@ press(const MouseWatcherParameter ¶m, bool background) { _text_geom_stale = true; } } - + } else if (button == KeyboardButton::home()) { if (_cursor_keys_active) { // Home. Move the cursor position to the beginning. @@ -309,7 +285,7 @@ press(const MouseWatcherParameter ¶m, bool background) { } type(param); } - + } else if (button == KeyboardButton::end()) { if (_cursor_keys_active) { // End. Move the cursor position to the end. @@ -320,19 +296,16 @@ press(const MouseWatcherParameter ¶m, bool background) { } type(param); } - } + } } } } PGItem::press(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::keystroke -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user types a key. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user types a key. + */ void PGEntry:: keystroke(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -344,8 +317,8 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { int keycode = param.get_keycode(); if (!isascii(keycode) || isprint(keycode)) { - // A normal visible character. Add a new character to the - // text entry, if there's room. + // A normal visible character. Add a new character to the text entry, + // if there's room. if (!_candidate_wtext.empty()) { _candidate_wtext = wstring(); _text_geom_stale = true; @@ -353,9 +326,9 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { wstring new_char(1, (wchar_t)keycode); if (get_max_chars() > 0 && _text.get_num_characters() >= get_max_chars()) { - // In max_chars mode, we consider it an overflow after we - // have exceeded a fixed number of characters, irrespective - // of the formatted width of those characters. + // In max_chars mode, we consider it an overflow after we have + // exceeded a fixed number of characters, irrespective of the + // formatted width of those characters. overflow(param); } else { @@ -369,47 +342,44 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { too_long = !_obscure_text.set_wtext(wstring(_text.get_num_characters(), '*')); } else { if (!too_long && (_text.get_num_rows() == _num_lines) && !overflow_mode) { - // If we've filled up all of the available lines, we - // must also ensure that the last line is not too long - // (it might be, because of additional whitespace on - // the end). + // If we've filled up all of the available lines, we must also + // ensure that the last line is not too long (it might be, + // because of additional whitespace on the end). int r = _num_lines - 1; int c = _text.get_num_cols(r); - PN_stdfloat last_line_width = + PN_stdfloat last_line_width = _text.get_xpos(r, c) - _text.get_xpos(r, 0); too_long = (last_line_width > _max_width); } - + if (!too_long && keycode == ' ' && !overflow_mode) { - // Even if we haven't filled up all of the available - // lines, we should reject a space that's typed at the - // end of the current line if it would make that line - // exceed the maximum width, just so we don't allow an - // infinite number of spaces to accumulate. + // Even if we haven't filled up all of the available lines, we + // should reject a space that's typed at the end of the current + // line if it would make that line exceed the maximum width, + // just so we don't allow an infinite number of spaces to + // accumulate. int r, c; _text.calc_r_c(r, c, _cursor_position); if (_text.get_num_cols(r) == c + 1) { - // The user is typing at the end of the line. But we - // must allow at least one space at the end of the - // line, so we only make any of the following checks - // if there are already multiple spaces at the end of - // the line. + // The user is typing at the end of the line. But we must + // allow at least one space at the end of the line, so we only + // make any of the following checks if there are already + // multiple spaces at the end of the line. if (c - 1 >= 0 && _text.get_character(r, c - 1) == ' ') { - // Ok, the user is putting multiple spaces on the - // end of a line; we need to make sure the line does - // not grow too wide. Measure the line's width. - PN_stdfloat current_line_width = + // Ok, the user is putting multiple spaces on the end of a + // line; we need to make sure the line does not grow too + // wide. Measure the line's width. + PN_stdfloat current_line_width = _text.get_xpos(r, c + 1) - _text.get_xpos(r, 0); if (current_line_width > _max_width) { - // We have to reject the space, but we don't treat - // it as an overflow condition. + // We have to reject the space, but we don't treat it as + // an overflow condition. _text.set_wsubstr(wstring(), _cursor_position, 1); - // If the user is typing over existing space - // characters, we act as if the right-arrow key - // were pressed instead, and advance the cursor to - // the next position. Otherwise, we just quietly - // eat the space character. - if (_cursor_position < _text.get_num_characters() && + // If the user is typing over existing space characters, + // we act as if the right-arrow key were pressed instead, + // and advance the cursor to the next position. + // Otherwise, we just quietly eat the space character. + if (_cursor_position < _text.get_num_characters() && _text.get_character(_cursor_position) == ' ') { _cursor_position++; _cursor_stale = true; @@ -420,11 +390,11 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { } } } - + if (too_long) { _text.set_wsubstr(wstring(), _cursor_position, 1); overflow(param); - + } else { _cursor_position += new_char.length(); _cursor_stale = true; @@ -438,12 +408,10 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { PGItem::keystroke(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::candidate -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user selects an item from the IME menu. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user selects an item + * from the IME menu. + */ void PGEntry:: candidate(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -463,12 +431,10 @@ candidate(const MouseWatcherParameter ¶m, bool background) { PGItem::candidate(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::accept -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// entry is accepted by the user pressing Enter normally. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the entry is accepted by + * the user pressing Enter normally. + */ void PGEntry:: accept(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -479,12 +445,10 @@ accept(const MouseWatcherParameter ¶m) { set_focus(false); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::accept_failed -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// user presses Enter but we can't accept the input. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user presses Enter + * but we can't accept the input. + */ void PGEntry:: accept_failed(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -492,17 +456,14 @@ accept_failed(const MouseWatcherParameter ¶m) { string event = get_accept_failed_event(param.get_button()); play_sound(event); throw_event(event, EventParameter(ep)); - //set_focus(false); + // set_focus(false); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::overflow -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// entry is overflowed because the user attempts to type -// too many characters, exceeding either set_max_chars() -// or set_max_width(). -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the entry is overflowed + * because the user attempts to type too many characters, exceeding either + * set_max_chars() or set_max_width(). + */ void PGEntry:: overflow(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -512,12 +473,10 @@ overflow(const MouseWatcherParameter ¶m) { throw_event(event, EventParameter(ep)); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::type -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// user extends the text by typing. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user extends the text + * by typing. + */ void PGEntry:: type(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -527,12 +486,10 @@ type(const MouseWatcherParameter ¶m) { throw_event(event, EventParameter(ep)); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::erase -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// user erase characters in the text. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user erase characters + * in the text. + */ void PGEntry:: erase(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -542,12 +499,9 @@ erase(const MouseWatcherParameter ¶m) { throw_event(event, EventParameter(ep)); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::cursormove -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// cursor moves. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the cursor moves. + */ void PGEntry:: cursormove() { LightReMutexHolder holder(_lock); @@ -555,15 +509,12 @@ cursormove() { throw_event(event, EventParameter(_cursor_def.get_x()), EventParameter(_cursor_def.get_y())); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::setup -// Access: Published -// Description: Sets up the entry for normal use. The width is the -// maximum width of characters that will be typed, and -// num_lines is the integer number of lines of text of -// the entry. Both of these together determine the size -// of the entry, based on the TextNode in effect. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the entry for normal use. The width is the maximum width of + * characters that will be typed, and num_lines is the integer number of lines + * of text of the entry. Both of these together determine the size of the + * entry, based on the TextNode in effect. + */ void PGEntry:: setup(PN_stdfloat width, int num_lines) { LightReMutexHolder holder(_lock); @@ -604,9 +555,9 @@ setup(PN_stdfloat width, int num_lines) { right_axis = 1; } - // And get the new minmax to define the frame. We do all this work - // instead of just using the lower-left and upper-right corners, - // just in case the text was rotated. + // And get the new minmax to define the frame. We do all this work instead + // of just using the lower-left and upper-right corners, just in case the + // text was rotated. LVecBase4 frame; frame[0] = min(min(ll[right_axis], ur[right_axis]), min(lr[right_axis], ul[right_axis])); frame[1] = max(max(ll[right_axis], ur[right_axis]), max(lr[right_axis], ul[right_axis])); @@ -648,12 +599,9 @@ setup(PN_stdfloat width, int num_lines) { set_frame_style(S_inactive, style); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::setup_minimal -// Access: Published -// Description: Sets up the entry without creating any frame or other -// decoration. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the entry without creating any frame or other decoration. + */ void PGEntry:: setup_minimal(PN_stdfloat width, int num_lines) { LightReMutexHolder holder(_lock); @@ -677,7 +625,7 @@ setup_minimal(PN_stdfloat width, int num_lines) { ls.move_to(0.0f, 0.0f, -0.15f * line_height); ls.draw_to(0.0f, 0.0f, 0.70f * line_height); get_cursor_def().attach_new_node(ls.create()); - + /* // An underscore cursor would work too. text_node->set_text("_"); @@ -685,15 +633,11 @@ setup_minimal(PN_stdfloat width, int num_lines) { */ } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_text_def -// Access: Published -// Description: Changes the TextNode that will be used to render the -// text within the entry when the entry is in the -// indicated state. The default if nothing is specified -// is the same TextNode returned by -// PGItem::get_text_node(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the TextNode that will be used to render the text within the entry + * when the entry is in the indicated state. The default if nothing is + * specified is the same TextNode returned by PGItem::get_text_node(). + */ void PGEntry:: set_text_def(int state, TextNode *node) { LightReMutexHolder holder(_lock); @@ -707,14 +651,11 @@ set_text_def(int state, TextNode *node) { _text_defs[state] = node; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::get_text_def -// Access: Published -// Description: Returns the TextNode that will be used to render the -// text within the entry when the entry is in the -// indicated state. See set_text_def(). -//////////////////////////////////////////////////////////////////// -TextNode *PGEntry:: +/** + * Returns the TextNode that will be used to render the text within the entry + * when the entry is in the indicated state. See set_text_def(). + */ +TextNode *PGEntry:: get_text_def(int state) const { LightReMutexHolder holder(_lock); if (state < 0 || state >= (int)_text_defs.size()) { @@ -727,27 +668,22 @@ get_text_def(int state) const { return _text_defs[state]; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_active -// Access: Published, Virtual -// Description: Toggles the active/inactive state of the entry. In -// the case of a PGEntry, this also changes its visual -// appearance. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Toggles the active/inactive state of the entry. In the case of a PGEntry, + * this also changes its visual appearance. + */ +void PGEntry:: set_active(bool active) { LightReMutexHolder holder(_lock); PGItem::set_active(active); update_state(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::set_focus -// Access: Published, Virtual -// Description: Toggles the focus state of the entry. In the case of -// a PGEntry, this also changes its visual appearance. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Toggles the focus state of the entry. In the case of a PGEntry, this also + * changes its visual appearance. + */ +void PGEntry:: set_focus(bool focus) { LightReMutexHolder holder(_lock); PGItem::set_focus(focus); @@ -755,15 +691,12 @@ set_focus(bool focus) { update_state(); } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::is_wtext -// Access: Published -// Description: Returns true if any of the characters in the string -// returned by get_wtext() are out of the range of an -// ASCII character (and, therefore, get_wtext() should -// be called in preference to get_text()). -//////////////////////////////////////////////////////////////////// -bool PGEntry:: +/** + * Returns true if any of the characters in the string returned by get_wtext() + * are out of the range of an ASCII character (and, therefore, get_wtext() + * should be called in preference to get_text()). + */ +bool PGEntry:: is_wtext() const { LightReMutexHolder holder(_lock); for (int i = 0; i < _text.get_num_characters(); ++i) { @@ -776,12 +709,9 @@ is_wtext() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::slot_text_def -// Access: Private -// Description: Ensures there is a slot in the array for the given -// text definition. -//////////////////////////////////////////////////////////////////// +/** + * Ensures there is a slot in the array for the given text definition. + */ void PGEntry:: slot_text_def(int state) { while (state >= (int)_text_defs.size()) { @@ -789,17 +719,14 @@ slot_text_def(int state) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::update_text -// Access: Private -// Description: Causes the PGEntry to recompute its text, if -// necessary. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Causes the PGEntry to recompute its text, if necessary. + */ +void PGEntry:: update_text() { TextNode *node = get_text_def(get_state()); nassertv(node != (TextNode *)NULL); - + if (_text_geom_stale || node != _last_text_def) { TextProperties props = *node; props.set_wordwrap(_max_width); @@ -808,8 +735,8 @@ update_text() { _text.set_max_rows(_num_lines); if (node != _last_text_def) { - // Make sure the default properties are applied to all the - // characters in the text. + // Make sure the default properties are applied to all the characters in + // the text. _text.set_wtext(_text.get_wtext()); _last_text_def = node; } @@ -824,8 +751,8 @@ update_text() { assembled = _obscure_text.assemble_text(); } else if (_candidate_wtext.empty()) { - // If we're not trying to display a candidate string, it's easy: - // just display the current text contents. + // If we're not trying to display a candidate string, it's easy: just + // display the current text contents. assembled = _text.assemble_text(); } else { @@ -833,9 +760,9 @@ update_text() { TextProperties inactive = tp_mgr->get_properties(_candidate_inactive); TextProperties active = tp_mgr->get_properties(_candidate_active); - // Insert the complex sequence of characters required to show - // the candidate string in a different color. This gets - // inserted at the current cursor position. + // Insert the complex sequence of characters required to show the + // candidate string in a different color. This gets inserted at the + // current cursor position. wstring cseq; cseq += wstring(1, (wchar_t)text_push_properties_key); cseq += node->decode_text(_candidate_inactive); @@ -860,7 +787,7 @@ update_text() { _current_text.remove_node(); } - _current_text = + _current_text = _text_render_root.attach_new_node(assembled); _current_text.set_mat(node->get_transform()); @@ -870,23 +797,21 @@ update_text() { PN_stdfloat cursor_graphic_pos = _text.get_xpos(0, _cursor_position); PN_stdfloat min_padding = (cursor_graphic_pos - _max_width); - // If the current padding would produce a caret outside the text entry, - // we relocate it. - // Here we also have to make a jump towards the center when the caret - // is going outside the visual area and there's enough text ahead for - // increased usability. - // - // The amount that the caret is moved for hinting depends on the OS, - // and the specific behavior under certain circunstances in different - // Operating Systems is very complicated (the implementation would need - // to "remember" the original typing starting point). For the moment we are - // gonna use an unconditional 50% jump, this behavior is found in some - // Mac dialogs, and it's the easiest to implement by far, while - // providing proven usability. - // PROS: Reduces the amount of scrolling while both writing and navigating - // with arrow keys, which is desirable. - // CONS: The user needs to remember that he/she has exceeded the boundaries, - // but this happens with all implementations to some degree. +/* + * If the current padding would produce a caret outside the text entry, we + * relocate it. Here we also have to make a jump towards the center when the + * caret is going outside the visual area and there's enough text ahead for + * increased usability. The amount that the caret is moved for hinting + * depends on the OS, and the specific behavior under certain circunstances in + * different Operating Systems is very complicated (the implementation would + * need to "remember" the original typing starting point). For the moment we + * are gonna use an unconditional 50% jump, this behavior is found in some Mac + * dialogs, and it's the easiest to implement by far, while providing proven + * usability. PROS: Reduces the amount of scrolling while both writing and + * navigating with arrow keys, which is desirable. CONS: The user needs to + * remember that heshe has exceeded the boundaries, but this happens with all + * implementations to some degree. + */ if (_current_padding < min_padding || _current_padding > cursor_graphic_pos){ _current_padding = min_padding + (cursor_graphic_pos - min_padding) * 0.5; @@ -907,20 +832,18 @@ update_text() { _cursor_stale = true; } - // We'll flatten the text geometry only if we don't have focus. - // Otherwise, we assume the user may be changing it frequently. + // We'll flatten the text geometry only if we don't have focus. Otherwise, + // we assume the user may be changing it frequently. if (!get_focus() && !_text_geom_flattened) { _current_text.flatten_strong(); _text_geom_flattened = true; } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::update_cursor -// Access: Private -// Description: Moves the cursor to its correct position. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Moves the cursor to its correct position. + */ +void PGEntry:: update_cursor() { TextNode *node = get_text_def(get_state()); nassertv(node != (TextNode *)NULL); @@ -948,14 +871,14 @@ update_cursor() { _cursor_def.set_pos(xpos - _current_padding, 0.0f, ypos); _cursor_stale = false; cursormove(); - + } // Should the cursor be visible? if (!get_focus() || !_candidate_wtext.empty()) { show_hide_cursor(false); } else { - double elapsed_time = + double elapsed_time = ClockObject::get_global_clock()->get_frame_time() - _blink_start; int cycle = (int)(elapsed_time * _blink_rate * 2.0f); bool visible = ((cycle & 1) == 0); @@ -963,13 +886,10 @@ update_cursor() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::show_hide_cursor -// Access: Private -// Description: Makes the cursor visible or invisible, e.g. during a -// blink cycle. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Makes the cursor visible or invisible, e.g. during a blink cycle. + */ +void PGEntry:: show_hide_cursor(bool visible) { if (visible != _cursor_visible) { if (visible) { @@ -981,13 +901,10 @@ show_hide_cursor(bool visible) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGEntry::update_state -// Access: Private -// Description: Determines what the correct state for the PGEntry -// should be. -//////////////////////////////////////////////////////////////////// -void PGEntry:: +/** + * Determines what the correct state for the PGEntry should be. + */ +void PGEntry:: update_state() { if (get_active()) { if (get_focus()) { diff --git a/panda/src/pgui/pgEntry.h b/panda/src/pgui/pgEntry.h index b2ad6350f4..3d764edf7f 100644 --- a/panda/src/pgui/pgEntry.h +++ b/panda/src/pgui/pgEntry.h @@ -1,16 +1,15 @@ -// Filename: pgEntry.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgEntry.h + * @author drose + * @date 2002-03-13 + */ #ifndef PGENTRY_H #define PGENTRY_H @@ -25,20 +24,16 @@ #include "clockObject.h" #include "textAssembler.h" -//////////////////////////////////////////////////////////////////// -// Class : PGEntry -// Description : This is a particular kind of PGItem that handles -// simple one-line or short multi-line text entries, of -// the sort where the user can type any string. -// -// A PGEntry does all of its internal manipulation on a -// wide string, so it can store the full Unicode -// character set. The interface can support either the -// wide string getters and setters, or the normal 8-bit -// string getters and setters, which use whatever -// encoding method is specified by the associated -// TextNode. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of PGItem that handles simple one-line or short + * multi-line text entries, of the sort where the user can type any string. + * + * A PGEntry does all of its internal manipulation on a wide string, so it can + * store the full Unicode character set. The interface can support either the + * wide string getters and setters, or the normal 8-bit string getters and + * setters, which use whatever encoding method is specified by the associated + * TextNode. + */ class EXPCL_PANDA_PGUI PGEntry : public PGItem { PUBLISHED: PGEntry(const string &name); @@ -48,7 +43,7 @@ protected: PGEntry(const PGEntry ©); public: - virtual PandaNode *make_copy() const; + virtual PandaNode *make_copy() const; virtual void xform(const LMatrix4 &mat); virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); @@ -84,7 +79,7 @@ PUBLISHED: INLINE void set_cursor_position(int position); INLINE int get_cursor_position() const; - + INLINE PN_stdfloat get_cursor_X() const; INLINE PN_stdfloat get_cursor_Y() const; @@ -135,7 +130,7 @@ PUBLISHED: INLINE string get_type_event() const; INLINE string get_erase_event() const; INLINE string get_cursormove_event() const; - + INLINE bool set_wtext(const wstring &wtext); INLINE wstring get_plain_wtext() const; @@ -177,16 +172,16 @@ private: // This is the subgraph that renders both the text and the cursor. NodePath _text_render_root; - // This is the node for rendering the actual text that is parented - // to the above node when the text is generated. + // This is the node for rendering the actual text that is parented to the + // above node when the text is generated. NodePath _current_text; TextNode *_last_text_def; bool _text_geom_stale; bool _text_geom_flattened; // This is the node that represents the cursor geometry. It is also - // attached to the above node, and is transformed around and/or - // hidden according to the cursor's position and blink state. + // attached to the above node, and is transformed around andor hidden + // according to the cursor's position and blink state. NodePath _cursor_scale; NodePath _cursor_def; diff --git a/panda/src/pgui/pgFrameStyle.I b/panda/src/pgui/pgFrameStyle.I index 50be64ca7c..2882d73935 100644 --- a/panda/src/pgui/pgFrameStyle.I +++ b/panda/src/pgui/pgFrameStyle.I @@ -1,23 +1,19 @@ -// Filename: pgFrameStyle.I -// Created by: drose (03Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgFrameStyle.I + * @author drose + * @date 2001-07-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGFrameStyle:: PGFrameStyle() { _type = T_none; @@ -27,11 +23,9 @@ PGFrameStyle() { _visible_scale.set(1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGFrameStyle:: PGFrameStyle(const PGFrameStyle ©) : _type(copy._type), @@ -43,11 +37,9 @@ PGFrameStyle(const PGFrameStyle ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PGFrameStyle:: operator = (const PGFrameStyle ©) { _type = copy._type; @@ -58,229 +50,178 @@ operator = (const PGFrameStyle ©) { _visible_scale = copy._visible_scale; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGFrameStyle:: ~PGFrameStyle() { } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_type -// Access: Published -// Description: Sets the basic type of frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets the basic type of frame. + */ INLINE void PGFrameStyle:: set_type(PGFrameStyle::Type type) { _type = type; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_type -// Access: Published -// Description: Returns the basic type of frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the basic type of frame. + */ INLINE PGFrameStyle::Type PGFrameStyle:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_color -// Access: Published -// Description: Sets the dominant color of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dominant color of the frame. + */ INLINE void PGFrameStyle:: set_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_color -// Access: Published -// Description: Sets the dominant color of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dominant color of the frame. + */ INLINE void PGFrameStyle:: set_color(const LColor &color) { _color = color; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_color -// Access: Published -// Description: Returns the dominant color of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dominant color of the frame. + */ INLINE LColor PGFrameStyle:: get_color() const { return _color; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_texture -// Access: Published -// Description: Specifies a texture that should be applied to the -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a texture that should be applied to the frame. + */ INLINE void PGFrameStyle:: set_texture(Texture *texture) { _texture = texture; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::has_texture -// Access: Published -// Description: Returns true if a texture has been applied to the -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a texture has been applied to the frame. + */ INLINE bool PGFrameStyle:: has_texture() const { return !_texture.is_null(); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_texture -// Access: Published -// Description: Returns the texture that has been applied to the -// frame, or NULL if no texture has been applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture that has been applied to the frame, or NULL if no + * texture has been applied. + */ INLINE Texture *PGFrameStyle:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::clear_texture -// Access: Published -// Description: Removes the texture from the frame. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture from the frame. + */ INLINE void PGFrameStyle:: clear_texture() { _texture.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_width -// Access: Published -// Description: Sets the width parameter, which has meaning only for -// certain frame types. For instance, this is the width -// of the bevel for T_bevel_in or T_bevel_out. The -// units are in screen units. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width parameter, which has meaning only for certain frame types. + * For instance, this is the width of the bevel for T_bevel_in or T_bevel_out. + * The units are in screen units. + */ INLINE void PGFrameStyle:: set_width(PN_stdfloat x, PN_stdfloat y) { set_width(LVecBase2(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_width -// Access: Published -// Description: Sets the width parameter, which has meaning only for -// certain frame types. For instance, this is the width -// of the bevel for T_bevel_in or T_bevel_out. The -// units are in screen units. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width parameter, which has meaning only for certain frame types. + * For instance, this is the width of the bevel for T_bevel_in or T_bevel_out. + * The units are in screen units. + */ INLINE void PGFrameStyle:: set_width(const LVecBase2 &width) { _width = width; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_width -// Access: Published -// Description: Returns the width parameter, which has meaning only -// for certain frame types. For instance, this is the -// width of the bevel for T_bevel_in or T_bevel_out. -// The units are in screen units. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width parameter, which has meaning only for certain frame + * types. For instance, this is the width of the bevel for T_bevel_in or + * T_bevel_out. The units are in screen units. + */ INLINE const LVecBase2 &PGFrameStyle:: get_width() const { return _width; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_uv_width -// Access: Published -// Description: Sets the uv_width parameter, which indicates the -// amount of the texture that is consumed by the inner -// bevel--the width in texture space of the amount -// indicated by set_width. -//////////////////////////////////////////////////////////////////// +/** + * Sets the uv_width parameter, which indicates the amount of the texture that + * is consumed by the inner bevel--the width in texture space of the amount + * indicated by set_width. + */ INLINE void PGFrameStyle:: set_uv_width(PN_stdfloat u, PN_stdfloat v) { set_uv_width(LVecBase2(u, v)); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_uv_width -// Access: Published -// Description: Sets the uv_width parameter, which indicates the -// amount of the texture that is consumed by the inner -// bevel--the width in texture space of the amount -// indicated by set_width. -//////////////////////////////////////////////////////////////////// +/** + * Sets the uv_width parameter, which indicates the amount of the texture that + * is consumed by the inner bevel--the width in texture space of the amount + * indicated by set_width. + */ INLINE void PGFrameStyle:: set_uv_width(const LVecBase2 &uv_width) { _uv_width = uv_width; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_uv_width -// Access: Published -// Description: See set_uv_width(). -//////////////////////////////////////////////////////////////////// +/** + * See set_uv_width(). + */ INLINE const LVecBase2 &PGFrameStyle:: get_uv_width() const { return _uv_width; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_visible_scale -// Access: Published -// Description: Sets a scale factor on the visible representation of -// the frame, in the X and Y directions. If this scale -// factor is other than 1, it will affect the size of -// the visible frame representation within the actual -// frame border. -//////////////////////////////////////////////////////////////////// +/** + * Sets a scale factor on the visible representation of the frame, in the X + * and Y directions. If this scale factor is other than 1, it will affect the + * size of the visible frame representation within the actual frame border. + */ INLINE void PGFrameStyle:: set_visible_scale(PN_stdfloat x, PN_stdfloat y) { set_visible_scale(LVecBase2(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::set_visible_scale -// Access: Published -// Description: Sets a scale factor on the visible representation of -// the frame, in the X and Y directions. If this scale -// factor is other than 1, it will affect the size of -// the visible frame representation within the actual -// frame border. -//////////////////////////////////////////////////////////////////// +/** + * Sets a scale factor on the visible representation of the frame, in the X + * and Y directions. If this scale factor is other than 1, it will affect the + * size of the visible frame representation within the actual frame border. + */ INLINE void PGFrameStyle:: set_visible_scale(const LVecBase2 &visible_scale) { _visible_scale = visible_scale; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_visible_scale -// Access: Published -// Description: Returns the scale factor on the visible -// representation of the frame, in the X and Y -// directions. If this scale factor is other than 1, it -// will affect the size of the visible frame -// representation within the actual frame border. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor on the visible representation of the frame, in the + * X and Y directions. If this scale factor is other than 1, it will affect + * the size of the visible frame representation within the actual frame + * border. + */ INLINE const LVecBase2 &PGFrameStyle:: get_visible_scale() const { return _visible_scale; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle ostream output -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream & operator << (ostream &out, const PGFrameStyle &pfs) { pfs.output(out); diff --git a/panda/src/pgui/pgFrameStyle.cxx b/panda/src/pgui/pgFrameStyle.cxx index 6f5053e44e..c2106e3ef2 100644 --- a/panda/src/pgui/pgFrameStyle.cxx +++ b/panda/src/pgui/pgFrameStyle.cxx @@ -1,16 +1,15 @@ -// Filename: pgFrameStyle.cxx -// Created by: drose (03Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgFrameStyle.cxx + * @author drose + * @date 2001-07-03 + */ #include "pgFrameStyle.h" #include "geomNode.h" @@ -26,10 +25,9 @@ #include "geomTristrips.h" #include "geomVertexWriter.h" -// Specifies the UV range of textures applied to the frame. Maybe -// we'll have a reason to make this a parameter of the frame style one -// day, but for now it's hardcoded to fit the entire texture over the -// rectangular frame. +// Specifies the UV range of textures applied to the frame. Maybe we'll have +// a reason to make this a parameter of the frame style one day, but for now +// it's hardcoded to fit the entire texture over the rectangular frame. static const LVecBase4 uv_range = LVecBase4(0.0f, 1.0f, 0.0f, 1.0f); ostream & @@ -60,14 +58,11 @@ operator << (ostream &out, PGFrameStyle::Type type) { return out << "**unknown(" << (int)type << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::get_internal_frame -// Access: Published -// Description: Computes the size of the internal frame, given the -// indicated external frame, appropriate for this kind -// of frame style. This simply subtracts the border -// width for those frame styles that include a border. -//////////////////////////////////////////////////////////////////// +/** + * Computes the size of the internal frame, given the indicated external + * frame, appropriate for this kind of frame style. This simply subtracts the + * border width for those frame styles that include a border. + */ LVecBase4 PGFrameStyle:: get_internal_frame(const LVecBase4 &frame) const { LPoint2 center((frame[0] + frame[1]) / 2.0f, @@ -93,11 +88,9 @@ get_internal_frame(const LVecBase4 &frame) const { scaled_frame[3] - _width[1]); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PGFrameStyle:: output(ostream &out) const { out << _type << " color = " << _color << " width = " << _width; @@ -109,14 +102,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::xform -// Access: Public -// Description: Applies the indicated transform to the FrameStyle. -// The return value is true if the frame style is -// transformed, or false if it was not affected by the -// transform. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform to the FrameStyle. The return value is + * true if the frame style is transformed, or false if it was not affected by + * the transform. + */ bool PGFrameStyle:: xform(const LMatrix4 &mat) { // All we can do is scale the X and Y bevel sizes. @@ -125,7 +115,7 @@ xform(const LMatrix4 &mat) { LVector3 x, z; mat.get_row3(x, 0); PN_stdfloat x_scale = x.length(); - + mat.get_row3(z, 2); PN_stdfloat z_scale = z.length(); @@ -149,16 +139,13 @@ xform(const LMatrix4 &mat) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::generate_into -// Access: Public -// Description: Generates geometry representing a frame of the -// indicated size, and parents it to the indicated node, -// with the indicated scene graph sort order. -// -// The return value is the generated NodePath, if any, -// or an empty NodePath if nothing is generated. -//////////////////////////////////////////////////////////////////// +/** + * Generates geometry representing a frame of the indicated size, and parents + * it to the indicated node, with the indicated scene graph sort order. + * + * The return value is the generated NodePath, if any, or an empty NodePath if + * nothing is generated. + */ NodePath PGFrameStyle:: generate_into(const NodePath &parent, const LVecBase4 &frame, int sort) { @@ -213,12 +200,9 @@ generate_into(const NodePath &parent, const LVecBase4 &frame, return parent.attach_new_node(new_node, sort); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::generate_flat_geom -// Access: Private -// Description: Generates the GeomNode appropriate to a T_flat -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Generates the GeomNode appropriate to a T_flat frame. + */ PT(PandaNode) PGFrameStyle:: generate_flat_geom(const LVecBase4 &frame) { PT(GeomNode) gnode = new GeomNode("flat"); @@ -234,10 +218,10 @@ generate_flat_geom(const LVecBase4 &frame) { } else { format = GeomVertexFormat::get_v3(); } - + PT(GeomVertexData) vdata = new GeomVertexData ("PGFrame", format, Geom::UH_static); - + GeomVertexWriter vertex(vdata, InternalName::get_vertex()); vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); vertex.add_data3(LPoint3::rfu(left, 0.0f, bottom)); @@ -250,18 +234,18 @@ generate_flat_geom(const LVecBase4 &frame) { right = uv_range[1]; bottom = uv_range[2]; top = uv_range[3]; - + GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); texcoord.add_data2(left, top); texcoord.add_data2(left, bottom); texcoord.add_data2(right, top); texcoord.add_data2(right, bottom); } - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); strip->add_next_vertices(4); strip->close_primitive(); - + CPT(RenderState) state = RenderState::make(ColorAttrib::make_flat(_color), -1); if (has_texture()) { state = state->set_attrib(TextureAttrib::make(get_texture())); @@ -269,74 +253,36 @@ generate_flat_geom(const LVecBase4 &frame) { PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); gnode->add_geom(geom, state); - + return gnode.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::generate_bevel_geom -// Access: Private -// Description: Generates the GeomNode appropriate to a T_bevel_in -// or T_bevel_out frame. -//////////////////////////////////////////////////////////////////// +/** + * Generates the GeomNode appropriate to a T_bevel_in or T_bevel_out frame. + */ PT(PandaNode) PGFrameStyle:: generate_bevel_geom(const LVecBase4 &frame, bool in) { - // - // Colors: - // - // - // * * * * * * * * * * * * * * * * * * * * * * * - // * * * * - // * * ctop * * - // * * * * - // * * * * * * * * * * * * * * * * * - // * * * * - // * * * * - // * cleft * _color * cright* - // * * * * - // * * * * - // * * * * * * * * * * * * * * * * * - // * * * * - // * * cbottom * * - // * * * * - // * * * * * * * * * * * * * * * * * * * * * * * - // - // - // Vertices: - // - // tristrip 1: - // 4 * * * * * * * * * * * * * * * * * * * * * 6 - // * * * - // * * * - // * * * - // * 5 * * * * * * * * * * * * * 7 - // * * - // * * - // * * - // * * - // * * - // * 3 * * * * * * * * * * * * * 1 - // * * * - // * * * - // * * * - // 2 * * * * * * * * * * * * * * * * * * * * * 0 - // - // tristrip 2: - // 1 - // * * - // * * - // * * - // 5 * * * * * * * * * * * * * 3 * - // * * * - // * * * - // * * * - // * * * - // * * * - // 4 * * * * * * * * * * * * * 2 * - // * * - // * * - // * * - // 0 +/* + * Colors: * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * ctop * * * * + * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * * cleft * + * _color * cright* * * * * * + * * * * * * * * * * * * * * * * * * * * + * * * * * * * * cbottom + * * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * Vertices: tristrip 1: 4 * * * * * * * * * * * * * * * + * * * * * * * 6 * * * * * + * * * * * * 5 * * * * * * * * * * * * + * * 7 * * * * * * * * * * * 3 * * * * * * + * * * * * * * * 1 * * * * * + * * * * * 2 * * * * * * * * * * * * * * + * * * * * * * * 0 tristrip 2: 1 * * * * * * 5 * * * * * * * * * * * * * + * 3 * * * * * + * * * * * * * + * * * * * * 4 * * * * * * * * * * * * * + * 2 * * * * * * * 0 + */ PT(GeomNode) gnode = new GeomNode("bevel"); @@ -395,10 +341,10 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { PT(GeomVertexData) vdata = new GeomVertexData ("PGFrame", format, Geom::UH_static); - + GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); // Tristrip 1. vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); @@ -417,10 +363,10 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { color.add_data4(cleft); color.add_data4(ctop); color.add_data4(ctop); - + strip->add_next_vertices(8); strip->close_primitive(); - + // Tristrip 2. vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); @@ -434,7 +380,7 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { color.add_data4(cright); color.add_data4(_color); color.add_data4(_color); - + strip->add_next_vertices(6); strip->close_primitive(); strip->set_shade_model(Geom::SM_flat_last_vertex); @@ -448,7 +394,7 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { PN_stdfloat cx = (left + right) * 0.5; PN_stdfloat cy = (top + bottom) * 0.5; - + PN_stdfloat inner_left = min(left + _uv_width[0], cx); PN_stdfloat inner_right = max(right - _uv_width[0], cx); PN_stdfloat inner_bottom = min(bottom + _uv_width[1], cy); @@ -473,7 +419,7 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { } PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + CPT(RenderState) state; state = RenderState::make(ShadeModelAttrib::make(ShadeModelAttrib::M_flat), ColorAttrib::make_vertex()); @@ -481,115 +427,48 @@ generate_bevel_geom(const LVecBase4 &frame, bool in) { state = state->set_attrib(TextureAttrib::make(get_texture())); } gnode->add_geom(geom, state); - + return gnode.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::generate_groove_geom -// Access: Private -// Description: Generates the GeomNode appropriate to a T_groove or -// T_ridge frame. -//////////////////////////////////////////////////////////////////// +/** + * Generates the GeomNode appropriate to a T_groove or T_ridge frame. + */ PT(PandaNode) PGFrameStyle:: generate_groove_geom(const LVecBase4 &frame, bool in) { - // - // Colors: - // - // - // * * * * * * * * * * * * * * * * * * * * * * * * * * * - // * * * * - // * * ctop * * - // * * * * - // * * * * * * * * * * * * * * * * * * * * * - // * * * * * * - // * * * cbottom * * * - // * * * * * * - // * * * * * * * * * * * * * * * - // * * * * * * - // * * * * * * - // * cleft * cright* _color * cleft * cright* - // * * * * * * - // * * * * * * - // * * * * * * * * * * * * * * * - // * * * * * * - // * * * ctop * * * - // * * * * * * - // * * * * * * * * * * * * * * * * * * * * * - // * * * * - // * * cbottom * * - // * * * * - // * * * * * * * * * * * * * * * * * * * * * * * * * * * - // - // - // Vertices: - // - // tristrip 1: - // 4 * * * * * * * * * * * * * * * * * * * * * * * * * 6 - // * * * - // * * * - // * * * - // * 5 * * * * * * * * * * * * * * * * * 7 - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * * - // * 3 * * * * * * * * * * * * * * * * * 1 - // * * * - // * * * - // * * * - // 2 * * * * * * * * * * * * * * * * * * * * * * * * * 0 - // - // tristrip 2: - // 4 * * * * * * * * * * * * * * * * * 6 - // * * * - // * * * - // * * * - // * 5 * * * * * * * * * 7 - // * * - // * * - // * * - // * * - // * * - // * 3 * * * * * * * * * 1 - // * * * - // * * * - // * * * - // 2 * * * * * * * * * * * * * * * * * 0 - // - // tristrip 3: - // 1 - // * * - // * * - // * * - // 3 * - // * * * - // * * * - // * * * - // 7 * * * * * * * * * 5 * * - // * * * * - // * * * * - // * * * * - // * * * * - // * * * * - // 6 * * * * * * * * * 4 * * - // * * * - // * * * - // * * * - // 2 * - // * * - // * * - // * * - // 0 +/* + * Colors: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * ctop * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * * cbottom * * * * * + * * * * * * * * * * * * * * * * * + * * * * * * * * * * * + * * * * * * * cleft * cright* _color + * * cleft * cright* * * * * * * * + * * * * * * * * * * * * * * * + * * * * * * * * * * * * + * * * * * ctop * * * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * cbottom * * * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Vertices: + * tristrip 1: 4 * * * * * * * * * * * * * * * * * * * * * * * * * 6 * * + * * * * * * * + * * * 5 * * * * * * * * * * * * * * * * * 7 * * * * * + * * * * * * * * * * * * * * * * * + * * * * * * * 3 * * * * * * * * * * * * * * * * * 1 * * + * * * * * * * + * * 2 * * * * * * * * * * * * * * * * * * * * * * * * * 0 tristrip 2: 4 * * * + * * * * * * * * * * * * * * * 6 * * * * * + * * * * * * 5 * * * * * * * * * 7 * * * + * * * * * * * * * 3 * * * * * * * * * 1 * * + * * * * * * * * 2 * + * * * * * * * * * * * * * * * * * 0 tristrip 3: 1 * * * * * * 3 * + * * * * * * * * * * 7 * * * * * * * * * 5 * + * * * * * * * * * + * * * * * * * * * + * * * * * * 6 * * * * * * * * * 4 * + * * * * * * * * * * * 2 * * * * * * * 0 + */ PT(GeomNode) gnode = new GeomNode("groove"); @@ -652,10 +531,10 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { } PT(GeomVertexData) vdata = new GeomVertexData ("PGFrame", format, Geom::UH_static); - + GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter color(vdata, InternalName::get_color()); - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); // Tristrip 1. vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); @@ -674,10 +553,10 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { color.add_data4(cleft); color.add_data4(ctop); color.add_data4(ctop); - + strip->add_next_vertices(8); strip->close_primitive(); - + // Tristrip 2. vertex.add_data3(LPoint3::rfu(mid_right, 0.0f, mid_bottom)); vertex.add_data3(LPoint3::rfu(inner_right, 0.0f, inner_bottom)); @@ -695,10 +574,10 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { color.add_data4(cright); color.add_data4(cbottom); color.add_data4(cbottom); - + strip->add_next_vertices(8); strip->close_primitive(); - + // Tristrip 3. vertex.add_data3(LPoint3::rfu(right, 0.0f, bottom)); vertex.add_data3(LPoint3::rfu(right, 0.0f, top)); @@ -716,10 +595,10 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { color.add_data4(cleft); color.add_data4(_color); color.add_data4(_color); - + strip->add_next_vertices(8); strip->close_primitive(); - + strip->set_shade_model(Geom::SM_flat_last_vertex); if (has_texture()) { @@ -773,7 +652,7 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); - + CPT(RenderState) state = RenderState::make(ShadeModelAttrib::make(ShadeModelAttrib::M_flat), ColorAttrib::make_vertex()); if (has_texture()) { @@ -784,40 +663,25 @@ generate_groove_geom(const LVecBase4 &frame, bool in) { return gnode.p(); } -//////////////////////////////////////////////////////////////////// -// Function: PGFrameStyle::generate_texture_border_geom -// Access: Private -// Description: Generates the GeomNode appropriate to a -// T_texture_border frame. -//////////////////////////////////////////////////////////////////// +/** + * Generates the GeomNode appropriate to a T_texture_border frame. + */ PT(PandaNode) PGFrameStyle:: generate_texture_border_geom(const LVecBase4 &frame) { - // - // Vertices: - // - // tristrip 1: - // 0 * * * 2 * * * * * * * * * * * * * 4 * * * 6 - // * * * * * * * * * - // * * * * * * * * * * * * - // * * * * * * * * * * - // 1 * * * 3 * * * * * * * * * * * * * 5 * * * 7 - // - // tristrip 2: - // 1 * * * 3 * * * * * * * * * * * * * 5 * * * 7 - // * * * * * - // * * * * * * * * - // * * * * * * * * * - // * * * * * * * * * - // * * * * * * * * - // * * * * * * - // 8 * * *10 * * * * * * * * * * * * *12 * * *14 - // - // tristrip 3: - // 8 * * *10 * * * * * * * * * * * * *12 * * *14 - // * * * * * * * * * - // * * * * * * * * * * * * - // * * * * * * * * * * - // 9 * * *11 * * * * * * * * * * * * *13 * * *15 +/* + * Vertices: tristrip 1: 0 * * * 2 * * * * * * * * * * * * * 4 * * * 6 * * + * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * 1 * * * 3 * * * * * * * + * * * * * * * 5 * * * 7 tristrip 2: 1 * * * 3 * * * * * * * * * * * * * 5 * * + * * 7 * * * * * * * * + * * * * * * * * * * * * * * * * * * + * * * * * * * * * * * * * * * * + * * * * * * 8 * * *10 * * * * * * * * * * * * *12 + * * * *14 tristrip 3: 8 * * *10 * * * * * * * * * * * * *12 * * *14 * * * + * * * * * * * * * * * * * * * * * * * * * * * * + * * * * * * 9 * * *11 * * * * * * * * * * * * *13 * * + * *15 + */ PT(GeomNode) gnode = new GeomNode("flat"); @@ -840,12 +704,12 @@ generate_texture_border_geom(const LVecBase4 &frame) { } else { format = GeomVertexFormat::get_v3(); } - + PT(GeomVertexData) vdata = new GeomVertexData ("PGFrame", format, Geom::UH_static); - + GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + // verts 0,1,2,3 vertex.add_data3(LPoint3::rfu(left, 0.0f, top)); vertex.add_data3(LPoint3::rfu(left, 0.0f, inner_top)); @@ -876,14 +740,14 @@ generate_texture_border_geom(const LVecBase4 &frame) { PN_stdfloat cx = (left + right) * 0.5; PN_stdfloat cy = (top + bottom) * 0.5; - + PN_stdfloat inner_left = min(left + _uv_width[0], cx); PN_stdfloat inner_right = max(right - _uv_width[0], cx); PN_stdfloat inner_bottom = min(bottom + _uv_width[1], cy); PN_stdfloat inner_top = max(top - _uv_width[1], cy); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - + // verts 0,1,2,3 texcoord.add_data2(left, top); texcoord.add_data2(left, inner_top); @@ -905,13 +769,13 @@ generate_texture_border_geom(const LVecBase4 &frame) { texcoord.add_data2(right, inner_bottom); texcoord.add_data2(right, bottom); } - + PT(GeomTristrips) strip = new GeomTristrips(Geom::UH_static); - + // tristrip #1 strip->add_consecutive_vertices(0, 8); strip->close_primitive(); - + // tristrip #2 strip->add_vertex(1); strip->add_vertex(8); @@ -922,11 +786,11 @@ generate_texture_border_geom(const LVecBase4 &frame) { strip->add_vertex(7); strip->add_vertex(14); strip->close_primitive(); - + // tristrip #3 strip->add_consecutive_vertices(8, 8); strip->close_primitive(); - + CPT(RenderState) state = RenderState::make(ColorAttrib::make_flat(_color), -1); if (has_texture()) { state = state->set_attrib(TextureAttrib::make(get_texture())); @@ -935,6 +799,6 @@ generate_texture_border_geom(const LVecBase4 &frame) { PT(Geom) geom = new Geom(vdata); geom->add_primitive(strip); gnode->add_geom(geom, state); - + return gnode.p(); } diff --git a/panda/src/pgui/pgFrameStyle.h b/panda/src/pgui/pgFrameStyle.h index 8402d77bb4..107b217192 100644 --- a/panda/src/pgui/pgFrameStyle.h +++ b/panda/src/pgui/pgFrameStyle.h @@ -1,16 +1,15 @@ -// Filename: pgFrameStyle.h -// Created by: drose (03Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgFrameStyle.h + * @author drose + * @date 2001-07-03 + */ #ifndef PGFRAMESTYLE_H #define PGFRAMESTYLE_H @@ -24,10 +23,9 @@ class PandaNode; class NodePath; -//////////////////////////////////////////////////////////////////// -// Class : PGFrameStyle -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDA_PGUI PGFrameStyle { PUBLISHED: INLINE PGFrameStyle(); diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index 41bdfa0988..7d00a0e595 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -1,56 +1,45 @@ -// Filename: pgItem.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItem.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PGItem:: set_name(const string &name) { Namable::set_name(name); _lock.set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_region -// Access: Public -// Description: Returns the MouseWatcherRegion associated with this -// item. Every PGItem has a MouseWatcherRegion -// associated with it, that is created when the PGItem -// is created; it does not change during the lifetime of -// the PGItem. Even items that do not have a frame have -// an associated MouseWatcherRegion, although it will -// not be used in this case. -//////////////////////////////////////////////////////////////////// -INLINE PGMouseWatcherRegion *PGItem:: +/** + * Returns the MouseWatcherRegion associated with this item. Every PGItem has + * a MouseWatcherRegion associated with it, that is created when the PGItem is + * created; it does not change during the lifetime of the PGItem. Even items + * that do not have a frame have an associated MouseWatcherRegion, although it + * will not be used in this case. + */ +INLINE PGMouseWatcherRegion *PGItem:: get_region() const { LightReMutexHolder holder(_lock); return _region; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_notify -// Access: Published -// Description: Sets the object which will be notified when the -// PGItem changes. Set this to NULL to disable -// this effect. The PGItem does not retain -// ownership of the pointer; it is your responsibility -// to ensure that the notify object does not destruct. -//////////////////////////////////////////////////////////////////// -INLINE void PGItem:: +/** + * Sets the object which will be notified when the PGItem changes. Set this + * to NULL to disable this effect. The PGItem does not retain ownership of + * the pointer; it is your responsibility to ensure that the notify object + * does not destruct. + */ +INLINE void PGItem:: set_notify(PGItemNotify *notify) { LightReMutexHolder holder(_lock); if (_notify != (PGItemNotify *)NULL) { @@ -62,54 +51,43 @@ set_notify(PGItemNotify *notify) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::has_notify -// Access: Published -// Description: Returns true if there is an object configured to be -// notified when the PGItem changes, false otherwise. -//////////////////////////////////////////////////////////////////// -INLINE bool PGItem:: +/** + * Returns true if there is an object configured to be notified when the + * PGItem changes, false otherwise. + */ +INLINE bool PGItem:: has_notify() const { LightReMutexHolder holder(_lock); return (_notify != (PGItemNotify *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_notify -// Access: Published -// Description: Returns the object which will be notified when the -// PGItem changes, if any. Returns NULL if there -// is no such object configured. -//////////////////////////////////////////////////////////////////// -INLINE PGItemNotify *PGItem:: +/** + * Returns the object which will be notified when the PGItem changes, if any. + * Returns NULL if there is no such object configured. + */ +INLINE PGItemNotify *PGItem:: get_notify() const { LightReMutexHolder holder(_lock); return _notify; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_frame -// Access: Published -// Description: Sets the bounding rectangle of the item, in local -// coordinates. This is the region on screen within -// which the mouse will be considered to be within the -// item. Normally, it should correspond to the bounding -// rectangle of the visible geometry of the item. -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the item, in local coordinates. This is the + * region on screen within which the mouse will be considered to be within the + * item. Normally, it should correspond to the bounding rectangle of the + * visible geometry of the item. + */ INLINE void PGItem:: set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_frame(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_frame -// Access: Published -// Description: Sets the bounding rectangle of the item, in local -// coordinates. This is the region on screen within -// which the mouse will be considered to be within the -// item. Normally, it should correspond to the bounding -// rectangle of the visible geometry of the item. -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the item, in local coordinates. This is the + * region on screen within which the mouse will be considered to be within the + * item. Normally, it should correspond to the bounding rectangle of the + * visible geometry of the item. + */ INLINE void PGItem:: set_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); @@ -120,13 +98,10 @@ set_frame(const LVecBase4 &frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_frame -// Access: Published -// Description: Returns the bounding rectangle of the item. See -// set_frame(). It is an error to call this if -// has_frame() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding rectangle of the item. See set_frame(). It is an + * error to call this if has_frame() returns false. + */ INLINE const LVecBase4 &PGItem:: get_frame() const { LightReMutexHolder holder(_lock); @@ -134,25 +109,19 @@ get_frame() const { return _frame; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::has_frame -// Access: Published -// Description: Returns true if the item has a bounding rectangle; -// see set_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the item has a bounding rectangle; see set_frame(). + */ INLINE bool PGItem:: has_frame() const { LightReMutexHolder holder(_lock); return _has_frame; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::clear_frame -// Access: Published -// Description: Removes the bounding rectangle from the item. It -// will no longer be possible to position the mouse -// within the item; see set_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the bounding rectangle from the item. It will no longer be + * possible to position the mouse within the item; see set_frame(). + */ INLINE void PGItem:: clear_frame() { LightReMutexHolder holder(_lock); @@ -162,450 +131,354 @@ clear_frame() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_state -// Access: Published -// Description: Sets the "state" of this particular PGItem. -// -// The PGItem node will render as if it were the -// subgraph assigned to the corresponding index via -// set_state_def(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the "state" of this particular PGItem. + * + * The PGItem node will render as if it were the subgraph assigned to the + * corresponding index via set_state_def(). + */ INLINE void PGItem:: set_state(int state) { LightReMutexHolder holder(_lock); _state = state; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_state -// Access: Published -// Description: Returns the "state" of this particular PGItem. See -// set_state(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the "state" of this particular PGItem. See set_state(). + */ INLINE int PGItem:: get_state() const { LightReMutexHolder holder(_lock); return _state; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_active -// Access: Published -// Description: Returns whether the PGItem is currently active for -// mouse events. See set_active(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the PGItem is currently active for mouse events. See + * set_active(). + */ INLINE bool PGItem:: get_active() const { LightReMutexHolder holder(_lock); return (_flags & F_active) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus -// Access: Published -// Description: Returns whether the PGItem currently has focus for -// keyboard events. See set_focus(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the PGItem currently has focus for keyboard events. See + * set_focus(). + */ INLINE bool PGItem:: get_focus() const { LightReMutexHolder holder(_lock); return (_flags & F_focus) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_background_focus -// Access: Published -// Description: Returns whether background_focus is currently -// enabled. See set_background_focus(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether background_focus is currently enabled. See + * set_background_focus(). + */ INLINE bool PGItem:: get_background_focus() const { LightReMutexHolder holder(_lock); return (_flags & F_background_focus) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_suppress_flags -// Access: Published -// Description: This is just an interface to set the suppress flags -// on the underlying MouseWatcherRegion. See -// MouseWatcherRegion::set_suppress_flags(). -//////////////////////////////////////////////////////////////////// +/** + * This is just an interface to set the suppress flags on the underlying + * MouseWatcherRegion. See MouseWatcherRegion::set_suppress_flags(). + */ INLINE void PGItem:: set_suppress_flags(int suppress_flags) { LightReMutexHolder holder(_lock); _region->set_suppress_flags(suppress_flags); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_suppress_flags -// Access: Published -// Description: This is just an interface to get the suppress flags -// on the underlying MouseWatcherRegion. See -// MouseWatcherRegion::get_suppress_flags(). -//////////////////////////////////////////////////////////////////// +/** + * This is just an interface to get the suppress flags on the underlying + * MouseWatcherRegion. See MouseWatcherRegion::get_suppress_flags(). + */ INLINE int PGItem:: get_suppress_flags() const { LightReMutexHolder holder(_lock); return _region->get_suppress_flags(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_id -// Access: Published -// Description: Returns the unique ID assigned to this PGItem. This -// will be assigned to the region created with the -// MouseWatcher, and will thus be used to generate event -// names. -//////////////////////////////////////////////////////////////////// +/** + * Returns the unique ID assigned to this PGItem. This will be assigned to + * the region created with the MouseWatcher, and will thus be used to generate + * event names. + */ INLINE const string &PGItem:: get_id() const { LightReMutexHolder holder(_lock); return _region->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_id -// Access: Published -// Description: Set the unique ID assigned to this PGItem. It is the -// user's responsibility to ensure that this ID is -// unique. -// -// Normally, this should not need to be called, as the -// PGItem will assign itself an ID when it is created, -// but this function allows the user to decide to -// redefine the ID to be something possibly more -// meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Set the unique ID assigned to this PGItem. It is the user's responsibility + * to ensure that this ID is unique. + * + * Normally, this should not need to be called, as the PGItem will assign + * itself an ID when it is created, but this function allows the user to + * decide to redefine the ID to be something possibly more meaningful. + */ INLINE void PGItem:: set_id(const string &id) { LightReMutexHolder holder(_lock); _region->set_name(id); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_enter_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the enter -// event for all PGItems. The enter event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the enter event for all PGItems. + * The enter event is the concatenation of this string followed by get_id(). + */ INLINE string PGItem:: get_enter_prefix() { return "enter-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_exit_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the exit -// event for all PGItems. The exit event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the exit event for all PGItems. + * The exit event is the concatenation of this string followed by get_id(). + */ INLINE string PGItem:: get_exit_prefix() { return "exit-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_within_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the within -// event for all PGItems. The within event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the within event for all PGItems. + * The within event is the concatenation of this string followed by get_id(). + */ INLINE string PGItem:: get_within_prefix() { return "within-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_without_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the without -// event for all PGItems. The without event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the without event for all + * PGItems. The without event is the concatenation of this string followed by + * get_id(). + */ INLINE string PGItem:: get_without_prefix() { return "without-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus_in_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the focus_in -// event for all PGItems. The focus_in event is the -// concatenation of this string followed by get_id(). -// -// Unlike most item events, this event is thrown with no -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the focus_in event for all + * PGItems. The focus_in event is the concatenation of this string followed + * by get_id(). + * + * Unlike most item events, this event is thrown with no parameters. + */ INLINE string PGItem:: get_focus_in_prefix() { return "fin-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus_out_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the focus_out -// event for all PGItems. The focus_out event is the -// concatenation of this string followed by get_id(). -// -// Unlike most item events, this event is thrown with no -// parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the focus_out event for all + * PGItems. The focus_out event is the concatenation of this string followed + * by get_id(). + * + * Unlike most item events, this event is thrown with no parameters. + */ INLINE string PGItem:: get_focus_out_prefix() { return "fout-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_press_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the press -// event for all PGItems. The press event is the -// concatenation of this string followed by a button -// name, followed by a hyphen and get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the press event for all PGItems. + * The press event is the concatenation of this string followed by a button + * name, followed by a hyphen and get_id(). + */ INLINE string PGItem:: get_press_prefix() { return "press-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_repeat_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the repeat -// event for all PGItems. The repeat event is the -// concatenation of this string followed by a button -// name, followed by a hyphen and get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the repeat event for all PGItems. + * The repeat event is the concatenation of this string followed by a button + * name, followed by a hyphen and get_id(). + */ INLINE string PGItem:: get_repeat_prefix() { return "repeat-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_release_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the release -// event for all PGItems. The release event is the -// concatenation of this string followed by a button -// name, followed by a hyphen and get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the release event for all + * PGItems. The release event is the concatenation of this string followed by + * a button name, followed by a hyphen and get_id(). + */ INLINE string PGItem:: get_release_prefix() { return "release-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_keystroke_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the -// keystroke event for all PGItems. The keystroke event -// is the concatenation of this string followed by a -// hyphen and get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the keystroke event for all + * PGItems. The keystroke event is the concatenation of this string followed + * by a hyphen and get_id(). + */ INLINE string PGItem:: get_keystroke_prefix() { return "keystroke-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_enter_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the mouse enters its frame, but -// not any nested frames. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * mouse enters its frame, but not any nested frames. + */ INLINE string PGItem:: get_enter_event() const { LightReMutexHolder holder(_lock); return get_enter_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_exit_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the mouse exits its frame, or -// enters a nested frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * mouse exits its frame, or enters a nested frame. + */ INLINE string PGItem:: get_exit_event() const { LightReMutexHolder holder(_lock); return get_exit_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_within_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the mouse moves within the -// boundaries of the frame. This is different from the -// enter_event in that the mouse is considered within -// the frame even if it is also within a nested frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * mouse moves within the boundaries of the frame. This is different from the + * enter_event in that the mouse is considered within the frame even if it is + * also within a nested frame. + */ INLINE string PGItem:: get_within_event() const { LightReMutexHolder holder(_lock); return get_within_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_without_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the mouse moves completely outside -// the boundaries of the frame. This is different from -// the exit_event in that the mouse is considered -// within the frame even if it is also within a nested -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * mouse moves completely outside the boundaries of the frame. This is + * different from the exit_event in that the mouse is considered within the + * frame even if it is also within a nested frame. + */ INLINE string PGItem:: get_without_event() const { LightReMutexHolder holder(_lock); return get_without_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus_in_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item gets the keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item gets the keyboard + * focus. + */ INLINE string PGItem:: get_focus_in_event() const { LightReMutexHolder holder(_lock); return get_focus_in_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus_out_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item loses the keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item loses the keyboard + * focus. + */ INLINE string PGItem:: get_focus_out_event() const { LightReMutexHolder holder(_lock); return get_focus_out_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_press_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the indicated mouse or keyboard -// button is depressed while the mouse is within the -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * indicated mouse or keyboard button is depressed while the mouse is within + * the frame. + */ INLINE string PGItem:: get_press_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_press_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_repeat_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the indicated mouse or keyboard -// button is continuously held down while the mouse is -// within the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * indicated mouse or keyboard button is continuously held down while the + * mouse is within the frame. + */ INLINE string PGItem:: get_repeat_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_repeat_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_release_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and the indicated mouse or keyboard -// button, formerly clicked down is within the frame, is -// released. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and the + * indicated mouse or keyboard button, formerly clicked down is within the + * frame, is released. + */ INLINE string PGItem:: get_release_event(const ButtonHandle &button) const { LightReMutexHolder holder(_lock); return get_release_prefix() + button.get_name() + "-" + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_keystroke_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// item is active and any key is pressed by the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the item is active and any + * key is pressed by the user. + */ INLINE string PGItem:: get_keystroke_event() const { LightReMutexHolder holder(_lock); return get_keystroke_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_text_node -// Access: Published, Static -// Description: Changes the TextNode object that will be used by all -// PGItems to generate default labels given a string. -// This can be loaded with the default font, etc. -//////////////////////////////////////////////////////////////////// +/** + * Changes the TextNode object that will be used by all PGItems to generate + * default labels given a string. This can be loaded with the default font, + * etc. + */ INLINE void PGItem:: set_text_node(TextNode *node) { _text_node = node; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_focus_item -// Access: Published, Static -// Description: Returns the one PGItem in the world that currently -// has keyboard focus, if any, or NULL if no item has -// keyboard focus. Use PGItem::set_focus() to activate -// or deactivate keyboard focus on a particular item. -//////////////////////////////////////////////////////////////////// +/** + * Returns the one PGItem in the world that currently has keyboard focus, if + * any, or NULL if no item has keyboard focus. Use PGItem::set_focus() to + * activate or deactivate keyboard focus on a particular item. + */ INLINE PGItem *PGItem:: get_focus_item() { return _focus_item; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_frame_inv_xform -// Access: Published, Static -// Description: Returns the inverse of the frame transform matrix -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of the frame transform matrix + */ INLINE LMatrix4 PGItem:: get_frame_inv_xform() const { LightReMutexHolder holder(_lock); return _frame_inv_xform; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::compute_area -// Access: Private, Static -// Description: Computes the area of the indicated frame. -//////////////////////////////////////////////////////////////////// +/** + * Computes the area of the indicated frame. + */ INLINE PN_stdfloat PGItem:: compute_area(const LVecBase4 &frame) { return (frame[1] - frame[0]) * (frame[3] - frame[2]); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::compare_largest -// Access: Private, Static -// Description: Given that largest is the pointer to the largest -// frame so far, and largest_area is its area, compare -// that to the area of the new frame; if the new frame -// is larger, adjust largest and largest_area -// appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Given that largest is the pointer to the largest frame so far, and + * largest_area is its area, compare that to the area of the new frame; if the + * new frame is larger, adjust largest and largest_area appropriately. + */ INLINE void PGItem:: -compare_largest(const LVecBase4 *&largest, PN_stdfloat &largest_area, +compare_largest(const LVecBase4 *&largest, PN_stdfloat &largest_area, const LVecBase4 *new_frame) { PN_stdfloat new_area = compute_area(*new_frame); if (new_area > largest_area) { @@ -614,11 +487,9 @@ compare_largest(const LVecBase4 *&largest, PN_stdfloat &largest_area, } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::StateDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGItem::StateDef:: StateDef() : _frame_stale(true) diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index e8832e72fa..53966e26d7 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -1,16 +1,15 @@ -// Filename: pgItem.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItem.cxx + * @author drose + * @date 2002-03-13 + */ #include "pgItem.h" #include "pgMouseWatcherParameter.h" @@ -42,22 +41,19 @@ PGItem *PGItem::_focus_item = (PGItem *)NULL; PGItem::BackgroundFocus PGItem::_background_focus; -//////////////////////////////////////////////////////////////////// -// Function: is_right -// Description: Returns true if the 2-d v1 is to the right of v2. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the 2-d v1 is to the right of v2. + */ INLINE bool is_right(const LVector2 &v1, const LVector2 &v2) { return (v1[0] * v2[1] - v1[1] * v2[0]) > 0; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGItem:: -PGItem(const string &name) : +PGItem(const string &name) : PandaNode(name), _lock(name) { @@ -71,11 +67,9 @@ PGItem(const string &name) : _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGItem:: ~PGItem() { if (_notify != (PGItemNotify *)NULL) { @@ -92,11 +86,9 @@ PGItem:: } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGItem:: PGItem(const PGItem ©) : PandaNode(copy), @@ -110,19 +102,19 @@ PGItem(const PGItem ©) : { _notify = NULL; _region = new PGMouseWatcherRegion(this); - - // We give our region the same name as the region for the PGItem - // we're copying--so that this PGItem will generate the same event - // names when the user interacts with it. + + // We give our region the same name as the region for the PGItem we're + // copying--so that this PGItem will generate the same event names when the + // user interacts with it. _region->set_name(copy._region->get_name()); // Make a deep copy of all of the original PGItem's StateDefs. size_t num_state_defs = copy._state_defs.size(); _state_defs.reserve(num_state_defs); for (size_t i = 0; i < num_state_defs; ++i) { - // We cheat and cast away the const, because the frame is just a - // cache. But we have to get the frame out of the source before we - // can safely copy it. + // We cheat and cast away the const, because the frame is just a cache. + // But we have to get the frame out of the source before we can safely + // copy it. StateDef &old_sd = (StateDef &)(copy._state_defs[i]); old_sd._frame.remove_node(); old_sd._frame_stale = true; @@ -135,27 +127,22 @@ PGItem(const PGItem ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::make_copy -// Access: Protected, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGItem:: make_copy() const { LightReMutexHolder holder(_lock); return new PGItem(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::transform_changed -// Access: Protected, Virtual -// Description: Called after the node's transform has been changed -// for any reason, this just provides a hook so derived -// classes can do something special in this case. -//////////////////////////////////////////////////////////////////// +/** + * Called after the node's transform has been changed for any reason, this + * just provides a hook so derived classes can do something special in this + * case. + */ void PGItem:: transform_changed() { LightReMutexHolder holder(_lock); @@ -165,13 +152,11 @@ transform_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::draw_mask_changed -// Access: Protected, Virtual -// Description: Called after the node's draw_mask has been changed -// for any reason, this just provides a hook so derived -// classes can do something special in this case. -//////////////////////////////////////////////////////////////////// +/** + * Called after the node's draw_mask has been changed for any reason, this + * just provides a hook so derived classes can do something special in this + * case. + */ void PGItem:: draw_mask_changed() { LightReMutexHolder holder(_lock); @@ -181,42 +166,34 @@ draw_mask_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGItem:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); bool this_node_hidden = data.is_this_node_hidden(trav->get_camera_mask()); if (!this_node_hidden && has_frame() && get_active()) { - // The item has a frame, so we want to generate a region for it - // and update the MouseWatcher. + // The item has a frame, so we want to generate a region for it and update + // the MouseWatcher. - // We can only do this if our traverser is a PGCullTraverser - // (which will be the case if this node was parented somewhere - // under a PGTop node). + // We can only do this if our traverser is a PGCullTraverser (which will + // be the case if this node was parented somewhere under a PGTop node). if (trav->is_exact_type(PGCullTraverser::get_class_type())) { PGCullTraverser *pg_trav; DCAST_INTO_R(pg_trav, trav, true); @@ -224,22 +201,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { CPT(TransformState) net_transform = data.get_net_transform(trav); const LMatrix4 &transform = net_transform->get_mat(); - // Consider the cull bin this object is in. Since the binning - // affects the render order, we want bins that render later to - // get higher sort values. + // Consider the cull bin this object is in. Since the binning affects + // the render order, we want bins that render later to get higher sort + // values. int bin_index = data._state->get_bin_index(); int sort; CullBinManager *bin_manager = CullBinManager::get_global_ptr(); CullBinManager::BinType bin_type = bin_manager->get_bin_type(bin_index); if (bin_type == CullBinManager::BT_fixed) { - // If the bin is a "fixed" type bin, our local sort is based - // on the fixed order. + // If the bin is a "fixed" type bin, our local sort is based on the + // fixed order. sort = data._state->get_draw_order(); } else if (bin_type == CullBinManager::BT_unsorted) { - // If the bin is an "unsorted" type bin, we base the local - // sort on the scene graph order. + // If the bin is an "unsorted" type bin, we base the local sort on the + // scene graph order. sort = pg_trav->_sort_index; pg_trav->_sort_index++; @@ -248,19 +225,18 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { sort = 0; } - // Now what order does this bin sort relative to the other bins? - // This becomes the high-order part of the final sort count. + // Now what order does this bin sort relative to the other bins? This + // becomes the high-order part of the final sort count. int bin_sort = bin_manager->get_bin_sort(data._state->get_bin_index()); - // Combine the two sorts into a single int. This assumes we - // only need 16 bits for each sort number, possibly an erroneous - // assumption. We should really provide two separate sort - // values, both ints, in the MouseWatcherRegion; but in the - // interest of expediency we work within the existing interface - // which only provides one. + // Combine the two sorts into a single int. This assumes we only need + // 16 bits for each sort number, possibly an erroneous assumption. We + // should really provide two separate sort values, both ints, in the + // MouseWatcherRegion; but in the interest of expediency we work within + // the existing interface which only provides one. sort = (bin_sort << 16) | ((sort + 0x8000) & 0xffff); - if (activate_region(transform, sort, + if (activate_region(transform, sort, DCAST(ClipPlaneAttrib, data._state->get_attrib(ClipPlaneAttrib::get_class_slot())), DCAST(ScissorAttrib, data._state->get_attrib(ScissorAttrib::get_class_slot())))) { pg_trav->_top->add_region(get_region()); @@ -269,8 +245,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { } if (has_state_def(get_state())) { - // This item has a current state definition that we should use - // to render the item. + // This item has a current state definition that we should use to render + // the item. NodePath &root = get_state_def(get_state()); CullTraverserData next_data(data, root.node()); trav->traverse(next_data); @@ -280,29 +256,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool PGItem:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void PGItem:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -325,13 +294,13 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, bound = new BoundingBox; } - // Now actually compute the bounding volume by putting it around all - // of our states' bounding volumes. + // Now actually compute the bounding volume by putting it around all of our + // states' bounding volumes. pvector child_volumes; // We walk through the list of state defs indirectly, calling - // get_state_def() on each one, to ensure that the frames are - // updated correctly before we measure their bounding volumes. + // get_state_def() on each one, to ensure that the frames are updated + // correctly before we measure their bounding volumes. for (int i = 0; i < (int)_state_defs.size(); i++) { NodePath &root = ((PGItem *)this)->get_state_def(i); if (!root.is_empty()) { @@ -350,14 +319,10 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = num_vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::r_prepare_scene -// Access: Protected, Virtual -// Description: The recursive implementation of prepare_scene(). -// Don't call this directly; call -// PandaNode::prepare_scene() or -// NodePath::prepare_scene() instead. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of prepare_scene(). Don't call this directly; + * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. + */ void PGItem:: r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) { @@ -371,17 +336,14 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, child->r_prepare_scene(gsg, child_state, transformer, current_thread); } } - + PandaNode::r_prepare_scene(gsg, node_state, transformer, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PGItem:: xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); @@ -411,22 +373,20 @@ xform(const LMatrix4 &mat) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::activate_region -// Access: Public -// Description: Applies the indicated scene graph transform and order -// as determined by the traversal from PGTop. -// -// The return value is true if the region is valid, or -// false if it is empty or completely clipped. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated scene graph transform and order as determined by the + * traversal from PGTop. + * + * The return value is true if the region is valid, or false if it is empty or + * completely clipped. + */ bool PGItem:: activate_region(const LMatrix4 &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa) { LightReMutexHolder holder(_lock); - // Transform all four vertices, and get the new bounding box. This - // way the region works (mostly) even if has been rotated. + // Transform all four vertices, and get the new bounding box. This way the + // region works (mostly) even if has been rotated. LPoint3 ll = LPoint3::rfu(_frame[0], 0.0f, _frame[2]) * transform; LPoint3 lr = LPoint3::rfu(_frame[1], 0.0f, _frame[2]) * transform; LPoint3 ul = LPoint3::rfu(_frame[0], 0.0f, _frame[3]) * transform; @@ -456,9 +416,9 @@ activate_region(const LMatrix4 &transform, int sort, LVecBase4 frame; if (cpa != (ClipPlaneAttrib *)NULL && cpa->get_num_on_planes() != 0) { - // Apply the clip plane(s) and/or scissor region now that we are - // here in world space. - + // Apply the clip plane(s) andor scissor region now that we are here in + // world space. + ClipPoints points; points.reserve(4); points.push_back(LPoint2(ll[right_axis], ll[up_axis])); @@ -471,13 +431,13 @@ activate_region(const LMatrix4 &transform, int sort, NodePath plane_path = cpa->get_on_plane(i); LPlane plane = DCAST(PlaneNode, plane_path.node())->get_plane(); plane.xform(plane_path.get_net_transform()->get_mat()); - - // We ignore the forward axis, assuming the frame is still in - // the right-up plane after being transformed. Not sure if we really - // need to support general 3-D transforms on 2-D objects. + + // We ignore the forward axis, assuming the frame is still in the right- + // up plane after being transformed. Not sure if we really need to + // support general 3-D transforms on 2-D objects. clip_frame(points, plane); } - + if (points.empty()) { // Turns out it's completely clipped after all. return false; @@ -517,26 +477,23 @@ activate_region(const LMatrix4 &transform, int sort, } _region->set_frame(frame); - + _region->set_sort(sort); _region->set_active(true); - // calculate the inverse of this transform, which is needed to - // go back to the frame space. + // calculate the inverse of this transform, which is needed to go back to + // the frame space. _frame_inv_xform.invert_from(transform); return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::enter_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse enters the region. The mouse is only -// considered to be "entered" in one region at a time; -// in the case of nested regions, it exits the outer -// region before entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse enters the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void PGItem:: enter_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -555,15 +512,12 @@ enter_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::exit_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse exits the region. The mouse is only considered -// to be "entered" in one region at a time; in the case -// of nested regions, it exits the outer region before -// entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse exits the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void PGItem:: exit_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -581,19 +535,15 @@ exit_region(const MouseWatcherParameter ¶m) { get_notify()->item_exit(this, param); } - //pgui_cat.info() << get_name() << "::exit()" << endl; + // pgui_cat.info() << get_name() << "::exit()" << endl; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::within_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves within the boundaries of the region, even -// if it is also within the boundaries of a nested -// region. This is different from "enter", which is -// only called whenever the mouse is within only that -// region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves within + * the boundaries of the region, even if it is also within the boundaries of a + * nested region. This is different from "enter", which is only called + * whenever the mouse is within only that region. + */ void PGItem:: within_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -612,13 +562,10 @@ within_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::without_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves completely outside the boundaries of the -// region. See within(). -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves + * completely outside the boundaries of the region. See within(). + */ void PGItem:: without_region(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -637,12 +584,10 @@ without_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::focus_in -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// widget gets the keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the widget gets the + * keyboard focus. + */ void PGItem:: focus_in() { LightReMutexHolder holder(_lock); @@ -660,12 +605,10 @@ focus_in() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::focus_out -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// widget loses the keyboard focus. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the widget loses the + * keyboard focus. + */ void PGItem:: focus_out() { LightReMutexHolder holder(_lock); @@ -683,13 +626,10 @@ focus_out() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the region. + */ void PGItem:: press(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -715,13 +655,10 @@ press(const MouseWatcherParameter ¶m, bool background) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void PGItem:: release(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -742,12 +679,9 @@ release(const MouseWatcherParameter ¶m, bool background) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::keystroke -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user presses a key. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user presses a key. + */ void PGItem:: keystroke(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -768,12 +702,10 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::candidate -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user highlights an option in the IME window. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user highlights an + * option in the IME window. + */ void PGItem:: candidate(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -790,12 +722,10 @@ candidate(const MouseWatcherParameter ¶m, bool background) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::move -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse is moved while within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse is moved while + * within the region. + */ void PGItem:: move(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -809,12 +739,9 @@ move(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::background_press -// Access: Public, Static -// Description: Calls press() on all the PGItems with background -// focus. -//////////////////////////////////////////////////////////////////// +/** + * Calls press() on all the PGItems with background focus. + */ void PGItem:: background_press(const MouseWatcherParameter ¶m) { BackgroundFocus::const_iterator fi; @@ -826,12 +753,9 @@ background_press(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::background_release -// Access: Public, Static -// Description: Calls release() on all the PGItems with background -// focus. -//////////////////////////////////////////////////////////////////// +/** + * Calls release() on all the PGItems with background focus. + */ void PGItem:: background_release(const MouseWatcherParameter ¶m) { BackgroundFocus::const_iterator fi; @@ -843,12 +767,9 @@ background_release(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::background_keystroke -// Access: Public, Static -// Description: Calls keystroke() on all the PGItems with background -// focus. -//////////////////////////////////////////////////////////////////// +/** + * Calls keystroke() on all the PGItems with background focus. + */ void PGItem:: background_keystroke(const MouseWatcherParameter ¶m) { BackgroundFocus::const_iterator fi; @@ -860,12 +781,9 @@ background_keystroke(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::background_candidate -// Access: Public, Static -// Description: Calls candidate() on all the PGItems with background -// focus. -//////////////////////////////////////////////////////////////////// +/** + * Calls candidate() on all the PGItems with background focus. + */ void PGItem:: background_candidate(const MouseWatcherParameter ¶m) { BackgroundFocus::const_iterator fi; @@ -877,15 +795,12 @@ background_candidate(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_active -// Access: Published, Virtual -// Description: Sets whether the PGItem is active for mouse watching. -// This is not necessarily related to the -// active/inactive appearance of the item, which is -// controlled by set_state(), but it does affect whether -// it responds to mouse events. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the PGItem is active for mouse watching. This is not + * necessarily related to the active/inactive appearance of the item, which is + * controlled by set_state(), but it does affect whether it responds to mouse + * events. + */ void PGItem:: set_active(bool active) { LightReMutexHolder holder(_lock); @@ -900,19 +815,15 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_focus -// Access: Published, Virtual -// Description: Sets whether the PGItem currently has keyboard focus. -// This simply means that the item may respond to -// keyboard events as well as to mouse events; precisely -// what this means is up to the individual item. -// -// Only one PGItem in the world is allowed to have focus -// at any given time. Setting the focus on any other -// item automatically disables the focus from the -// previous item. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the PGItem currently has keyboard focus. This simply means + * that the item may respond to keyboard events as well as to mouse events; + * precisely what this means is up to the individual item. + * + * Only one PGItem in the world is allowed to have focus at any given time. + * Setting the focus on any other item automatically disables the focus from + * the previous item. + */ void PGItem:: set_focus(bool focus) { LightReMutexHolder holder(_lock); @@ -949,15 +860,12 @@ set_focus(bool focus) { _region->set_keyboard(focus); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_background_focus -// Access: Published -// Description: Sets the background_focus flag for this item. When -// background_focus is enabled, the item will receive -// keypress events even if it is not in focus; in fact, -// even if it is not onscreen. Unlike normal focus, -// many items may have background_focus simultaneously. -//////////////////////////////////////////////////////////////////// +/** + * Sets the background_focus flag for this item. When background_focus is + * enabled, the item will receive keypress events even if it is not in focus; + * in fact, even if it is not onscreen. Unlike normal focus, many items may + * have background_focus simultaneously. + */ void PGItem:: set_background_focus(bool focus) { LightReMutexHolder holder(_lock); @@ -977,30 +885,25 @@ set_background_focus(bool focus) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_num_state_defs -// Access: Published -// Description: Returns one more than the highest-numbered state def -// that was ever assigned to the PGItem. The complete -// set of state defs assigned may then be retrieved by -// indexing from 0 to (get_num_state_defs() - 1). -// -// This is only an upper limit on the actual number of -// state defs, since there may be holes in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns one more than the highest-numbered state def that was ever assigned + * to the PGItem. The complete set of state defs assigned may then be + * retrieved by indexing from 0 to (get_num_state_defs() - 1). + * + * This is only an upper limit on the actual number of state defs, since there + * may be holes in the list. + */ int PGItem:: get_num_state_defs() const { LightReMutexHolder holder(_lock); return _state_defs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::has_state_def -// Access: Published -// Description: Returns true if get_state_def() has ever been called -// for the indicated state (thus defining a render -// subgraph for this state index), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if get_state_def() has ever been called for the indicated + * state (thus defining a render subgraph for this state index), false + * otherwise. + */ bool PGItem:: has_state_def(int state) const { LightReMutexHolder holder(_lock); @@ -1010,13 +913,10 @@ has_state_def(int state) const { return (!_state_defs[state]._root.is_empty()); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::clear_state_def -// Access: Published -// Description: Resets the NodePath assigned to the indicated state -// to its initial default, with only a frame -// representation if appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Resets the NodePath assigned to the indicated state to its initial default, + * with only a frame representation if appropriate. + */ void PGItem:: clear_state_def(int state) { LightReMutexHolder holder(_lock); @@ -1031,14 +931,11 @@ clear_state_def(int state) { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_state_def -// Access: Published -// Description: Returns the Node that is the root of the subgraph -// that will be drawn when the PGItem is in the -// indicated state. The first time this is called for a -// particular state index, it may create the Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Node that is the root of the subgraph that will be drawn when + * the PGItem is in the indicated state. The first time this is called for a + * particular state index, it may create the Node. + */ NodePath &PGItem:: get_state_def(int state) { LightReMutexHolder holder(_lock); @@ -1058,12 +955,10 @@ get_state_def(int state) { return _state_defs[state]._root; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::instance_to_state_def -// Access: Published -// Description: Parents an instance of the bottom node of the -// indicated NodePath to the indicated state index. -//////////////////////////////////////////////////////////////////// +/** + * Parents an instance of the bottom node of the indicated NodePath to the + * indicated state index. + */ NodePath PGItem:: instance_to_state_def(int state, const NodePath &path) { LightReMutexHolder holder(_lock); @@ -1077,12 +972,10 @@ instance_to_state_def(int state, const NodePath &path) { return path.instance_to(get_state_def(state)); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_frame_style -// Access: Published -// Description: Returns the kind of frame that will be drawn behind -// the item when it is in the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the kind of frame that will be drawn behind the item when it is in + * the indicated state. + */ PGFrameStyle PGItem:: get_frame_style(int state) { LightReMutexHolder holder(_lock); @@ -1092,57 +985,47 @@ get_frame_style(int state) { return _state_defs[state]._frame_style; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_frame_style -// Access: Published -// Description: Changes the kind of frame that will be drawn behind -// the item when it is in the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Changes the kind of frame that will be drawn behind the item when it is in + * the indicated state. + */ void PGItem:: set_frame_style(int state, const PGFrameStyle &style) { LightReMutexHolder holder(_lock); - // Get the state def node, mainly to ensure that this state is - // slotted and listed as having been defined. + // Get the state def node, mainly to ensure that this state is slotted and + // listed as having been defined. NodePath &root = get_state_def(state); nassertv(!root.is_empty()); - + _state_defs[state]._frame_style = style; _state_defs[state]._frame_stale = true; - + mark_internal_bounds_stale(); } #ifdef HAVE_AUDIO -//////////////////////////////////////////////////////////////////// -// Function: PGItem::set_sound -// Access: Published -// Description: Sets the sound that will be played whenever the -// indicated event occurs. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sound that will be played whenever the indicated event occurs. + */ void PGItem:: set_sound(const string &event, AudioSound *sound) { LightReMutexHolder holder(_lock); _sounds[event] = sound; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::clear_sound -// Access: Published -// Description: Removes the sound associated with the indicated -// event. -//////////////////////////////////////////////////////////////////// +/** + * Removes the sound associated with the indicated event. + */ void PGItem:: clear_sound(const string &event) { LightReMutexHolder holder(_lock); _sounds.erase(event); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_sound -// Access: Published -// Description: Returns the sound associated with the indicated -// event, or NULL if there is no associated sound. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sound associated with the indicated event, or NULL if there is + * no associated sound. + */ AudioSound *PGItem:: get_sound(const string &event) const { LightReMutexHolder holder(_lock); @@ -1153,12 +1036,10 @@ get_sound(const string &event) const { return (AudioSound *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::has_sound -// Access: Published -// Description: Returns true if there is a sound associated with the -// indicated event, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a sound associated with the indicated event, or + * false otherwise. + */ bool PGItem:: has_sound(const string &event) const { LightReMutexHolder holder(_lock); @@ -1166,32 +1047,27 @@ has_sound(const string &event) const { } #endif // HAVE_AUDIO -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_text_node -// Access: Published, Static -// Description: Returns the TextNode object that will be used by all -// PGItems to generate default labels given a string. -// This can be loaded with the default font, etc. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextNode object that will be used by all PGItems to generate + * default labels given a string. This can be loaded with the default font, + * etc. + */ TextNode *PGItem:: get_text_node() { if (_text_node == (TextNode *)NULL) { _text_node = new TextNode("pguiText"); _text_node->set_text_color(0.0f, 0.0f, 0.0f, 1.0f); - // The default TextNode is aligned to the left, for the - // convenience of PGEntry. + // The default TextNode is aligned to the left, for the convenience of + // PGEntry. _text_node->set_align(TextNode::A_left); } return _text_node; } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::play_sound -// Access: Protected -// Description: Plays the sound associated with the indicated event, -// if there is one. -//////////////////////////////////////////////////////////////////// +/** + * Plays the sound associated with the indicated event, if there is one. + */ void PGItem:: play_sound(const string &event) { #ifdef HAVE_AUDIO @@ -1204,22 +1080,17 @@ play_sound(const string &event) { #endif // HAVE_AUDIO } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::reduce_region -// Access: Protected -// Description: The frame parameter is an in/out parameter. This -// function adjusts frame so that it represents the -// largest part of the rectangular region passed in, -// that does not overlap with the rectangular region of -// the indicated obscurer. If the obscurer is NULL, or -// is a hidden node, it is not considered and the frame -// is left unchanged. -// -// This is used by slider bars and scroll frames, which -// have to automatically figure out how much space they -// have to work with after allowing space for scroll -// bars and buttons. -//////////////////////////////////////////////////////////////////// +/** + * The frame parameter is an in/out parameter. This function adjusts frame so + * that it represents the largest part of the rectangular region passed in, + * that does not overlap with the rectangular region of the indicated + * obscurer. If the obscurer is NULL, or is a hidden node, it is not + * considered and the frame is left unchanged. + * + * This is used by slider bars and scroll frames, which have to automatically + * figure out how much space they have to work with after allowing space for + * scroll bars and buttons. + */ void PGItem:: reduce_region(LVecBase4 &frame, PGItem *obscurer) const { if (obscurer != (PGItem *)NULL && !obscurer->is_overall_hidden()) { @@ -1243,27 +1114,23 @@ reduce_region(LVecBase4 &frame, PGItem *obscurer) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::get_relative_frame -// Access: Protected -// Description: Returns the LVecBase4 frame of the indicated item, -// converted into this item's coordinate space. -// Presumably, item is a child of this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LVecBase4 frame of the indicated item, converted into this + * item's coordinate space. Presumably, item is a child of this node. + */ LVecBase4 PGItem:: get_relative_frame(PGItem *item) const { NodePath this_np = NodePath::any_path((PGItem *)this); NodePath item_np = this_np.find_path_to(item); - if (item_np.is_empty()) { + if (item_np.is_empty()) { item_np = NodePath::any_path(item); } const LVecBase4 &orig_frame = item->get_frame(); LMatrix4 transform = item_np.get_mat(this_np); - - // Transform the item's frame into the PGScrollFrame's - // coordinate space. Transform all four vertices, and get the - // new bounding box. This way the region works (mostly) even if - // has been rotated. + + // Transform the item's frame into the PGScrollFrame's coordinate space. + // Transform all four vertices, and get the new bounding box. This way the + // region works (mostly) even if has been rotated. LPoint3 ll(orig_frame[0], 0.0f, orig_frame[2]); LPoint3 lr(orig_frame[1], 0.0f, orig_frame[2]); LPoint3 ul(orig_frame[0], 0.0f, orig_frame[3]); @@ -1272,33 +1139,29 @@ get_relative_frame(PGItem *item) const { lr = lr * transform; ul = ul * transform; ur = ur * transform; - + return LVecBase4(min(min(ll[0], lr[0]), min(ul[0], ur[0])), max(max(ll[0], lr[0]), max(ul[0], ur[0])), min(min(ll[2], lr[2]), min(ul[2], ur[2])), max(max(ll[2], lr[2]), max(ul[2], ur[2]))); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::mouse_to_local -// Access: Protected -// Description: Converts from the 2-d mouse coordinates into the -// coordinate space of the item. -//////////////////////////////////////////////////////////////////// +/** + * Converts from the 2-d mouse coordinates into the coordinate space of the + * item. + */ LPoint3 PGItem:: mouse_to_local(const LPoint2 &mouse_point) const { - // This is ambiguous if the PGItem has multiple instances. Why - // would you do that, anyway? + // This is ambiguous if the PGItem has multiple instances. Why would you do + // that, anyway? NodePath this_np((PGItem *)this); CPT(TransformState) inv_transform = NodePath().get_transform(this_np); return inv_transform->get_mat().xform_point(LVector3::rfu(mouse_point[0], 0, mouse_point[1])); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::frame_changed -// Access: Protected, Virtual -// Description: Called when the user changes the frame size. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user changes the frame size. + */ void PGItem:: frame_changed() { mark_frames_stale(); @@ -1307,12 +1170,9 @@ frame_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::slot_state_def -// Access: Private -// Description: Ensures there is a slot in the array for the given -// state definition. -//////////////////////////////////////////////////////////////////// +/** + * Ensures there is a slot in the array for the given state definition. + */ void PGItem:: slot_state_def(int state) { while (state >= (int)_state_defs.size()) { @@ -1320,12 +1180,9 @@ slot_state_def(int state) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::update_frame -// Access: Private -// Description: Generates a new instance of the frame geometry for -// the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Generates a new instance of the frame geometry for the indicated state. + */ void PGItem:: update_frame(int state) { // First, remove the old frame geometry, if any. @@ -1333,26 +1190,22 @@ update_frame(int state) { _state_defs[state]._frame.remove_node(); } - // We must turn off the stale flag first, before we call - // get_state_def(), to prevent get_state_def() from being a - // recursive call. + // We must turn off the stale flag first, before we call get_state_def(), to + // prevent get_state_def() from being a recursive call. _state_defs[state]._frame_stale = false; // Now create new frame geometry. if (has_frame()) { NodePath &root = get_state_def(state); - _state_defs[state]._frame = + _state_defs[state]._frame = _state_defs[state]._frame_style.generate_into(root, _frame); } } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::mark_frames_stale -// Access: Private -// Description: Marks all the frames in all states stale, so that -// they will be regenerated the next time each state is -// requested. -//////////////////////////////////////////////////////////////////// +/** + * Marks all the frames in all states stale, so that they will be regenerated + * the next time each state is requested. + */ void PGItem:: mark_frames_stale() { StateDefs::iterator di; @@ -1364,17 +1217,13 @@ mark_frames_stale() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: PGItem::clip_frame -// Access: Private -// Description: Clips the four corners of the item's frame by the -// indicated clipping plane, and modifies the points to -// reflect the new set of clipped points. -// -// The return value is true if the set of points is -// unmodified (all points are behind the clip plane), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Clips the four corners of the item's frame by the indicated clipping plane, + * and modifies the points to reflect the new set of clipped points. + * + * The return value is true if the set of points is unmodified (all points are + * behind the clip plane), or false otherwise. + */ bool PGItem:: clip_frame(ClipPoints &source_points, const LPlane &plane) const { if (source_points.empty()) { @@ -1384,18 +1233,18 @@ clip_frame(ClipPoints &source_points, const LPlane &plane) const { LPoint3 from3d; LVector3 delta3d; if (!plane.intersects_plane(from3d, delta3d, LPlane(LVector3(0, 1, 0), LPoint3::zero()))) { - // The clipping plane is parallel to the polygon. The polygon is - // either all in or all out. + // The clipping plane is parallel to the polygon. The polygon is either + // all in or all out. if (plane.dist_to_plane(LPoint3::zero()) < 0.0) { - // A point within the polygon is behind the clipping plane: the - // polygon is all in. + // A point within the polygon is behind the clipping plane: the polygon + // is all in. return true; } return false; } - // Project the line of intersection into the X-Z plane. Now we have - // a 2-d clipping line. + // Project the line of intersection into the X-Z plane. Now we have a 2-d + // clipping line. LPoint2 from2d(from3d[0], from3d[2]); LVector2 delta2d(delta3d[0], delta3d[2]); @@ -1403,13 +1252,12 @@ clip_frame(ClipPoints &source_points, const LPlane &plane) const { PN_stdfloat b = delta2d[0]; PN_stdfloat c = from2d[0] * delta2d[1] - from2d[1] * delta2d[0]; - // Now walk through the points. Any point on the left of our line - // gets removed, and the line segment clipped at the point of - // intersection. + // Now walk through the points. Any point on the left of our line gets + // removed, and the line segment clipped at the point of intersection. - // We might increase the number of vertices by as many as 1, if the - // plane clips off exactly one corner. (We might also decrease the - // number of vertices, or keep them the same number.) + // We might increase the number of vertices by as many as 1, if the plane + // clips off exactly one corner. (We might also decrease the number of + // vertices, or keep them the same number.) ClipPoints new_points; new_points.reserve(source_points.size() + 1); @@ -1421,22 +1269,22 @@ clip_frame(ClipPoints &source_points, const LPlane &plane) const { LPoint2 this_point(*pi); bool this_is_in = is_right(this_point - from2d, delta2d); - // There appears to be a compiler bug in gcc 4.0: we need to - // extract this comparison outside of the if statement. + // There appears to be a compiler bug in gcc 4.0: we need to extract this + // comparison outside of the if statement. bool crossed_over = (this_is_in != last_is_in); if (crossed_over) { - // We have just crossed over the clipping line. Find the point - // of intersection. + // We have just crossed over the clipping line. Find the point of + // intersection. LVector2 d = this_point - last_point; PN_stdfloat denom = (a * d[0] + b * d[1]); if (denom != 0.0) { PN_stdfloat t = -(a * last_point[0] + b * last_point[1] + c) / denom; LPoint2 p = last_point + t * d; - + new_points.push_back(p); last_is_in = this_is_in; } - } + } if (this_is_in) { // We are behind the clipping line. Keep the point. diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index f71cb1800a..003d1fa0c5 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -1,16 +1,15 @@ -// Filename: pgItem.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItem.h + * @author drose + * @date 2002-03-13 + */ #ifndef PGITEM_H #define PGITEM_H @@ -41,20 +40,16 @@ class AudioSound; class ClipPlaneAttrib; class ScissorAttrib; -//////////////////////////////////////////////////////////////////// -// Class : PGItem -// Description : This is the base class for all the various kinds of -// gui widget objects. -// -// It is a Node which corresponds to a rectangular -// region on the screen, and it may have any number of -// "state" subgraphs, one of which is rendered at any -// given time according to its current state. -// -// The PGItem node must be parented to the scene graph -// somewhere beneath a PGTop node in order for this -// behavior to work. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for all the various kinds of gui widget objects. + * + * It is a Node which corresponds to a rectangular region on the screen, and + * it may have any number of "state" subgraphs, one of which is rendered at + * any given time according to its current state. + * + * The PGItem node must be parented to the scene graph somewhere beneath a + * PGTop node in order for this behavior to work. + */ class EXPCL_PANDA_PGUI PGItem : public PandaNode { PUBLISHED: PGItem(const string &name); @@ -197,8 +192,8 @@ private: void mark_frames_stale(); INLINE static PN_stdfloat compute_area(const LVecBase4 &frame); - INLINE static void compare_largest(const LVecBase4 *&largest, - PN_stdfloat &largest_area, + INLINE static void compare_largest(const LVecBase4 *&largest, + PN_stdfloat &largest_area, const LVecBase4 *new_frame); typedef pvector ClipPoints; diff --git a/panda/src/pgui/pgItemNotify.I b/panda/src/pgui/pgItemNotify.I index 88aa39ea16..ff75c188b2 100644 --- a/panda/src/pgui/pgItemNotify.I +++ b/panda/src/pgui/pgItemNotify.I @@ -1,23 +1,19 @@ -// Filename: pgItemNotify.I -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItemNotify.I + * @author drose + * @date 2005-08-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGItemNotify:: PGItemNotify() { } diff --git a/panda/src/pgui/pgItemNotify.cxx b/panda/src/pgui/pgItemNotify.cxx index 8849e831cc..52f01dc63b 100644 --- a/panda/src/pgui/pgItemNotify.cxx +++ b/panda/src/pgui/pgItemNotify.cxx @@ -1,194 +1,153 @@ -// Filename: pgItemNotify.cxx -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItemNotify.cxx + * @author drose + * @date 2005-08-18 + */ #include "pgItemNotify.h" #include "pgItem.h" -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGItemNotify:: ~PGItemNotify() { while (!_items.empty()) { - // Disconnect all of the items that are connected to this - // object. + // Disconnect all of the items that are connected to this object. PGItem *item = (*_items.begin()); nassertv(item->get_notify() == this); (*_items.begin())->set_notify(NULL); } } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_transform_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's local transform -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's local transform has been changed. + */ void PGItemNotify:: item_transform_changed(PGItem *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_frame_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's frame -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's frame has been changed. + */ void PGItemNotify:: item_frame_changed(PGItem *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_draw_mask_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's draw_mask -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's draw_mask has been changed. + */ void PGItemNotify:: item_draw_mask_changed(PGItem *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_enter -// Access: Protected, Virtual -// Description: Called whenever the "enter" event is triggered on a -// watched PGItem. See PGItem::enter_region(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "enter" event is triggered on a watched PGItem. See + * PGItem::enter_region(). + */ void PGItemNotify:: item_enter(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_exit -// Access: Protected, Virtual -// Description: Called whenever the "exit" event is triggered on a -// watched PGItem. See PGItem::exit_region(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "exit" event is triggered on a watched PGItem. See + * PGItem::exit_region(). + */ void PGItemNotify:: item_exit(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_within -// Access: Protected, Virtual -// Description: Called whenever the "within" event is triggered on a -// watched PGItem. See PGItem::within_region(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "within" event is triggered on a watched PGItem. See + * PGItem::within_region(). + */ void PGItemNotify:: item_within(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_without -// Access: Protected, Virtual -// Description: Called whenever the "without" event is triggered on a -// watched PGItem. See PGItem::without_region(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "without" event is triggered on a watched PGItem. See + * PGItem::without_region(). + */ void PGItemNotify:: item_without(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_focus_in -// Access: Protected, Virtual -// Description: Called whenever the "focus_in" event is triggered on a -// watched PGItem. See PGItem::focus_in(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "focus_in" event is triggered on a watched PGItem. See + * PGItem::focus_in(). + */ void PGItemNotify:: item_focus_in(PGItem *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_focus_out -// Access: Protected, Virtual -// Description: Called whenever the "focus_out" event is triggered on a -// watched PGItem. See PGItem::focus_out(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "focus_out" event is triggered on a watched PGItem. + * See PGItem::focus_out(). + */ void PGItemNotify:: item_focus_out(PGItem *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_press -// Access: Protected, Virtual -// Description: Called whenever the "press" event is triggered on a -// watched PGItem. See PGItem::press(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "press" event is triggered on a watched PGItem. See + * PGItem::press(). + */ void PGItemNotify:: item_press(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_release -// Access: Protected, Virtual -// Description: Called whenever the "release" event is triggered on a -// watched PGItem. See PGItem::release(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "release" event is triggered on a watched PGItem. See + * PGItem::release(). + */ void PGItemNotify:: item_release(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_keystroke -// Access: Protected, Virtual -// Description: Called whenever the "keystroke" event is triggered on a -// watched PGItem. See PGItem::keystroke(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "keystroke" event is triggered on a watched PGItem. + * See PGItem::keystroke(). + */ void PGItemNotify:: item_keystroke(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_candidate -// Access: Protected, Virtual -// Description: Called whenever the "candidate" event is triggered on a -// watched PGItem. See PGItem::candidate(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "candidate" event is triggered on a watched PGItem. + * See PGItem::candidate(). + */ void PGItemNotify:: item_candidate(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::item_move -// Access: Protected, Virtual -// Description: Called whenever the "move" event is triggered on a -// watched PGItem. See PGItem::move(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "move" event is triggered on a watched PGItem. See + * PGItem::move(). + */ void PGItemNotify:: item_move(PGItem *, const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::add_item -// Access: Protected, Virtual -// Description: Called by PGItem when a new item is set up to -// notify this object. -//////////////////////////////////////////////////////////////////// +/** + * Called by PGItem when a new item is set up to notify this object. + */ void PGItemNotify:: add_item(PGItem *item) { bool inserted = _items.insert(item).second; nassertv(inserted); } -//////////////////////////////////////////////////////////////////// -// Function: PGItemNotify::remove_item -// Access: Protected, Virtual -// Description: Called by PGItem when an item is no longer set up -// to notify this object. -//////////////////////////////////////////////////////////////////// +/** + * Called by PGItem when an item is no longer set up to notify this object. + */ void PGItemNotify:: remove_item(PGItem *item) { Items::iterator bi; diff --git a/panda/src/pgui/pgItemNotify.h b/panda/src/pgui/pgItemNotify.h index 2a36f1f79f..0562511838 100644 --- a/panda/src/pgui/pgItemNotify.h +++ b/panda/src/pgui/pgItemNotify.h @@ -1,16 +1,15 @@ -// Filename: pgItemNotify.h -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgItemNotify.h + * @author drose + * @date 2005-08-18 + */ #ifndef PGITEMNOTIFY_H #define PGITEMNOTIFY_H @@ -21,12 +20,10 @@ class PGItem; class MouseWatcherParameter; -//////////////////////////////////////////////////////////////////// -// Class : PGItemNotify -// Description : Objects that inherit from this class can receive -// specialized messages when PGItems change in certain -// ways. -//////////////////////////////////////////////////////////////////// +/** + * Objects that inherit from this class can receive specialized messages when + * PGItems change in certain ways. + */ class EXPCL_PANDA_PGUI PGItemNotify { public: INLINE PGItemNotify(); diff --git a/panda/src/pgui/pgMouseWatcherBackground.cxx b/panda/src/pgui/pgMouseWatcherBackground.cxx index 75c8031474..31b21472e2 100644 --- a/panda/src/pgui/pgMouseWatcherBackground.cxx +++ b/panda/src/pgui/pgMouseWatcherBackground.cxx @@ -1,27 +1,24 @@ -// Filename: pgMouseWatcherBackground.cxx -// Created by: drose (23Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherBackground.cxx + * @author drose + * @date 2001-08-23 + */ #include "pgMouseWatcherBackground.h" #include "pgItem.h" TypeHandle PGMouseWatcherBackground::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherBackground:: PGMouseWatcherBackground() : MouseWatcherRegion("PGMouseWatcherBackground", 0, 0, 0, 0) @@ -30,56 +27,42 @@ PGMouseWatcherBackground() : set_keyboard(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherBackground:: ~PGMouseWatcherBackground() { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the background. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the background. + */ void PGMouseWatcherBackground:: press(const MouseWatcherParameter ¶m) { PGItem::background_press(param); } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void PGMouseWatcherBackground:: release(const MouseWatcherParameter ¶m) { PGItem::background_release(param); } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::keystroke -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user presses a key. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user presses a key. + */ void PGMouseWatcherBackground:: keystroke(const MouseWatcherParameter ¶m) { PGItem::background_keystroke(param); } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherBackground::candidate -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user uses the IME. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user uses the IME. + */ void PGMouseWatcherBackground:: candidate(const MouseWatcherParameter ¶m) { PGItem::background_candidate(param); diff --git a/panda/src/pgui/pgMouseWatcherBackground.h b/panda/src/pgui/pgMouseWatcherBackground.h index 4e65e7dbe7..9e2368c974 100644 --- a/panda/src/pgui/pgMouseWatcherBackground.h +++ b/panda/src/pgui/pgMouseWatcherBackground.h @@ -1,16 +1,15 @@ -// Filename: pgMouseWatcherBackground.h -// Created by: drose (23Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherBackground.h + * @author drose + * @date 2001-08-23 + */ #ifndef PGMOUSEWATCHERBACKGROUND_H #define PGMOUSEWATCHERBACKGROUND_H @@ -19,13 +18,11 @@ #include "mouseWatcherRegion.h" -//////////////////////////////////////////////////////////////////// -// Class : PGMouseWatcherBackground -// Description : This is a special kind of MouseWatcherRegion that -// doesn't have a rectangle and is never active, but -// just quietly listens for keypresses and sends them to -// all the PGItems with background focus. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of MouseWatcherRegion that doesn't have a rectangle + * and is never active, but just quietly listens for keypresses and sends them + * to all the PGItems with background focus. + */ class EXPCL_PANDA_PGUI PGMouseWatcherBackground : public MouseWatcherRegion { PUBLISHED: PGMouseWatcherBackground(); diff --git a/panda/src/pgui/pgMouseWatcherGroup.I b/panda/src/pgui/pgMouseWatcherGroup.I index 85f9ab686c..db3ce6b80a 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.I +++ b/panda/src/pgui/pgMouseWatcherGroup.I @@ -1,34 +1,27 @@ -// Filename: pgMouseWatcherGroup.I -// Created by: drose (09Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherGroup.I + * @author drose + * @date 2001-07-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherGroup::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGMouseWatcherGroup:: PGMouseWatcherGroup(PGTop *top) : _top(top) { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherGroup::clear_top -// Access: Public -// Description: Called by the PGTop object to indicate that it is no -// longer keeping the pointer to the PGMouseWatcherGroup -// object. -//////////////////////////////////////////////////////////////////// +/** + * Called by the PGTop object to indicate that it is no longer keeping the + * pointer to the PGMouseWatcherGroup object. + */ INLINE void PGMouseWatcherGroup:: clear_top(PGTop *top) { nassertv(_top == top); diff --git a/panda/src/pgui/pgMouseWatcherGroup.cxx b/panda/src/pgui/pgMouseWatcherGroup.cxx index b95e37aaa8..ccc3e91f31 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.cxx +++ b/panda/src/pgui/pgMouseWatcherGroup.cxx @@ -1,31 +1,28 @@ -// Filename: pgMouseWatcherGroup.cxx -// Created by: drose (09Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherGroup.cxx + * @author drose + * @date 2001-07-09 + */ #include "pgMouseWatcherGroup.h" #include "pgTop.h" TypeHandle PGMouseWatcherGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherGroup::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherGroup:: ~PGMouseWatcherGroup() { - // When the MouseWatcherGroup destructs for whatever reason, the - // PGTop object should lose its MouseWatcher. + // When the MouseWatcherGroup destructs for whatever reason, the PGTop + // object should lose its MouseWatcher. if (_top != (PGTop *)NULL) { _top->_watcher_group = (PGMouseWatcherGroup *)NULL; _top->set_mouse_watcher((MouseWatcher *)NULL); diff --git a/panda/src/pgui/pgMouseWatcherGroup.h b/panda/src/pgui/pgMouseWatcherGroup.h index 3c4a3fa397..f1ad50adda 100644 --- a/panda/src/pgui/pgMouseWatcherGroup.h +++ b/panda/src/pgui/pgMouseWatcherGroup.h @@ -1,16 +1,15 @@ -// Filename: pgMouseWatcherGroup.h -// Created by: drose (09Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherGroup.h + * @author drose + * @date 2001-07-09 + */ #ifndef PGMOUSEWATCHERGROUP_H #define PGMOUSEWATCHERGROUP_H @@ -22,14 +21,11 @@ class PGTop; -//////////////////////////////////////////////////////////////////// -// Class : PGMouseWatcherGroup -// Description : This is a specialization on MouseWatcherGroup, to -// associate it with a PGTop. Originally we had PGTop -// multiply inheriting from NamedNode and -// MouseWatcherGroup, but this causes problems with -// circular reference counts. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on MouseWatcherGroup, to associate it with a + * PGTop. Originally we had PGTop multiply inheriting from NamedNode and + * MouseWatcherGroup, but this causes problems with circular reference counts. + */ class EXPCL_PANDA_PGUI PGMouseWatcherGroup : public MouseWatcherGroup { public: INLINE PGMouseWatcherGroup(PGTop *top); diff --git a/panda/src/pgui/pgMouseWatcherParameter.I b/panda/src/pgui/pgMouseWatcherParameter.I index 6216462381..19cee12a17 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.I +++ b/panda/src/pgui/pgMouseWatcherParameter.I @@ -1,43 +1,35 @@ -// Filename: pgMouseWatcherParameter.I -// Created by: drose (05Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherParameter.I + * @author drose + * @date 2001-07-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGMouseWatcherParameter:: PGMouseWatcherParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGMouseWatcherParameter:: PGMouseWatcherParameter(const MouseWatcherParameter ©) : MouseWatcherParameter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherParameter::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PGMouseWatcherParameter:: operator = (const MouseWatcherParameter ©) { MouseWatcherParameter::operator = (copy); diff --git a/panda/src/pgui/pgMouseWatcherParameter.cxx b/panda/src/pgui/pgMouseWatcherParameter.cxx index 65a5fafef2..52844f5e23 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.cxx +++ b/panda/src/pgui/pgMouseWatcherParameter.cxx @@ -1,35 +1,30 @@ -// Filename: pgMouseWatcherParameter.cxx -// Created by: drose (05Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherParameter.cxx + * @author drose + * @date 2001-07-05 + */ #include "pgMouseWatcherParameter.h" TypeHandle PGMouseWatcherParameter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherParameter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherParameter:: ~PGMouseWatcherParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherParameter::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PGMouseWatcherParameter:: output(ostream &out) const { MouseWatcherParameter::output(out); diff --git a/panda/src/pgui/pgMouseWatcherParameter.h b/panda/src/pgui/pgMouseWatcherParameter.h index 40f8f3e033..930d1d55c2 100644 --- a/panda/src/pgui/pgMouseWatcherParameter.h +++ b/panda/src/pgui/pgMouseWatcherParameter.h @@ -1,16 +1,15 @@ -// Filename: pgMouseWatcherParameter.h -// Created by: drose (05Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherParameter.h + * @author drose + * @date 2001-07-05 + */ #ifndef PGMOUSEWATCHERPARAMETER_H #define PGMOUSEWATCHERPARAMETER_H @@ -20,20 +19,17 @@ #include "mouseWatcherParameter.h" #include "typedWritableReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : PGMouseWatcherParameter -// Description : This specialization on MouseWatcherParameter allows -// us to tag on additional elements to events for the -// gui system, and also inherits from -// TypedWritableReferenceCount so we can attach this thing to an -// event. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on MouseWatcherParameter allows us to tag on additional + * elements to events for the gui system, and also inherits from + * TypedWritableReferenceCount so we can attach this thing to an event. + */ class EXPCL_PANDA_PGUI PGMouseWatcherParameter : public TypedWritableReferenceCount, public MouseWatcherParameter { - // For now, this must inherit from TypedWritableReferenceCount on - // the left, because MSVC++ wants to make that base class be the one - // at the front of the structure, not MouseWatcherParameter for some - // reason, and interrogate assumes that whichever base class is on - // the left will be at the front of the structure. + // For now, this must inherit from TypedWritableReferenceCount on the left, + // because MSVC++ wants to make that base class be the one at the front of + // the structure, not MouseWatcherParameter for some reason, and interrogate + // assumes that whichever base class is on the left will be at the front of + // the structure. public: INLINE PGMouseWatcherParameter(); INLINE PGMouseWatcherParameter(const MouseWatcherParameter ©); diff --git a/panda/src/pgui/pgMouseWatcherRegion.I b/panda/src/pgui/pgMouseWatcherRegion.I index 58ab301cb7..fc36796080 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.I +++ b/panda/src/pgui/pgMouseWatcherRegion.I @@ -1,14 +1,12 @@ -// Filename: pgMouseWatcherRegion.I -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherRegion.I + * @author drose + * @date 2001-07-02 + */ diff --git a/panda/src/pgui/pgMouseWatcherRegion.cxx b/panda/src/pgui/pgMouseWatcherRegion.cxx index 1b1f338d8a..6e0a18daad 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.cxx +++ b/panda/src/pgui/pgMouseWatcherRegion.cxx @@ -1,16 +1,15 @@ -// Filename: pgMouseWatcherRegion.cxx -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherRegion.cxx + * @author drose + * @date 2001-07-02 + */ #include "pgMouseWatcherRegion.h" #include "pgItem.h" @@ -20,11 +19,9 @@ int PGMouseWatcherRegion::_next_index = 0; TypeHandle PGMouseWatcherRegion::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherRegion:: PGMouseWatcherRegion(PGItem *item) : #ifndef CPPPARSER @@ -34,25 +31,20 @@ PGMouseWatcherRegion(PGItem *item) : { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGMouseWatcherRegion:: ~PGMouseWatcherRegion() { } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::enter_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse enters the region. The mouse is only -// considered to be "entered" in one region at a time; -// in the case of nested regions, it exits the outer -// region before entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse enters the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void PGMouseWatcherRegion:: enter_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -60,15 +52,12 @@ enter_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::exit_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse exits the region. The mouse is only considered -// to be "entered" in one region at a time; in the case -// of nested regions, it exits the outer region before -// entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse exits the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void PGMouseWatcherRegion:: exit_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -76,16 +65,12 @@ exit_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::within_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves within the boundaries of the region, even -// if it is also within the boundaries of a nested -// region. This is different from "enter", which is -// only called whenever the mouse is within only that -// region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves within + * the boundaries of the region, even if it is also within the boundaries of a + * nested region. This is different from "enter", which is only called + * whenever the mouse is within only that region. + */ void PGMouseWatcherRegion:: within_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -93,13 +78,10 @@ within_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::without_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves completely outside the boundaries of the -// region. See within_region(). -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves + * completely outside the boundaries of the region. See within_region(). + */ void PGMouseWatcherRegion:: without_region(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -107,13 +89,10 @@ without_region(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the region. + */ void PGMouseWatcherRegion:: press(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -121,13 +100,10 @@ press(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void PGMouseWatcherRegion:: release(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -135,12 +111,9 @@ release(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::keystroke -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user presses a key. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user presses a key. + */ void PGMouseWatcherRegion:: keystroke(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -148,12 +121,10 @@ keystroke(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::candidate -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user selects an option from the IME menu. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user selects an + * option from the IME menu. + */ void PGMouseWatcherRegion:: candidate(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { @@ -161,12 +132,10 @@ candidate(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGMouseWatcherRegion::move -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever -// the user moves the mouse within the region -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the user moves the mouse + * within the region + */ void PGMouseWatcherRegion:: move(const MouseWatcherParameter ¶m) { if (_item != (PGItem *)NULL) { diff --git a/panda/src/pgui/pgMouseWatcherRegion.h b/panda/src/pgui/pgMouseWatcherRegion.h index 43c4a27631..8de129e71e 100644 --- a/panda/src/pgui/pgMouseWatcherRegion.h +++ b/panda/src/pgui/pgMouseWatcherRegion.h @@ -1,16 +1,15 @@ -// Filename: pgMouseWatcherRegion.h -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgMouseWatcherRegion.h + * @author drose + * @date 2001-07-02 + */ #ifndef PGMOUSEWATCHERREGION_H #define PGMOUSEWATCHERREGION_H @@ -21,13 +20,11 @@ class PGItem; -//////////////////////////////////////////////////////////////////// -// Class : PGMouseWatcherRegion -// Description : This is a specialization on MouseWatcherRegion, to -// add a bit more fields that are relevant to the PG -// system. Each PGItem corresponds to exactly one -// PGMouseWatcherRegion. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on MouseWatcherRegion, to add a bit more fields + * that are relevant to the PG system. Each PGItem corresponds to exactly one + * PGMouseWatcherRegion. + */ class EXPCL_PANDA_PGUI PGMouseWatcherRegion : public MouseWatcherRegion { public: PGMouseWatcherRegion(PGItem *item); diff --git a/panda/src/pgui/pgScrollFrame.I b/panda/src/pgui/pgScrollFrame.I index aa5e72acf3..ede2f4201e 100644 --- a/panda/src/pgui/pgScrollFrame.I +++ b/panda/src/pgui/pgScrollFrame.I @@ -1,37 +1,29 @@ -// Filename: pgScrollFrame.I -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgScrollFrame.I + * @author drose + * @date 2005-08-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_virtual_frame -// Access: Published -// Description: Sets the bounding rectangle of the virtual frame. -// This is the size of the large, virtual canvas which -// we can see only a portion of at any given time. -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the virtual frame. This is the size of the + * large, virtual canvas which we can see only a portion of at any given time. + */ INLINE void PGScrollFrame:: set_virtual_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_virtual_frame(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_virtual_frame -// Access: Published -// Description: Sets the bounding rectangle of the virtual frame. -// This is the size of the large, virtual canvas which -// we can see only a portion of at any given time. -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the virtual frame. This is the size of the + * large, virtual canvas which we can see only a portion of at any given time. + */ INLINE void PGScrollFrame:: set_virtual_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); @@ -44,57 +36,46 @@ set_virtual_frame(const LVecBase4 &frame) { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::get_virtual_frame -// Access: Published -// Description: Returns the bounding rectangle of the virtual frame. -// See set_virtual_frame(). If has_virtual_frame() is -// false, this returns the item's clip frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding rectangle of the virtual frame. See + * set_virtual_frame(). If has_virtual_frame() is false, this returns the + * item's clip frame. + */ INLINE const LVecBase4 &PGScrollFrame:: get_virtual_frame() const { LightReMutexHolder holder(_lock); return _has_virtual_frame ? _virtual_frame : get_clip_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::has_virtual_frame -// Access: Published -// Description: Returns true if the virtual frame has a bounding -// rectangle; see set_virtual_frame(). Most -// PGScrollFrame objects will have a virtual frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the virtual frame has a bounding rectangle; see + * set_virtual_frame(). Most PGScrollFrame objects will have a virtual frame. + */ INLINE bool PGScrollFrame:: has_virtual_frame() const { LightReMutexHolder holder(_lock); return _has_virtual_frame; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::clear_virtual_frame -// Access: Published -// Description: Removes the virtual frame from the item. This -// effectively sets the virtual frame to the same size -// as the clip frame. Scrolling will no longer be -// possible. -//////////////////////////////////////////////////////////////////// +/** + * Removes the virtual frame from the item. This effectively sets the virtual + * frame to the same size as the clip frame. Scrolling will no longer be + * possible. + */ INLINE void PGScrollFrame:: clear_virtual_frame() { LightReMutexHolder holder(_lock); _has_virtual_frame = false; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_manage_pieces -// Access: Published -// Description: Sets the manage_pieces flag. When this is true, the -// sub-pieces of the scroll frame--that is, the two -// scroll bars--are automatically positioned and/or -// resized when the scroll frame's overall frame is -// changed. They are also automatically resized to fill -// in the gap when one or the other is hidden. -//////////////////////////////////////////////////////////////////// -INLINE void PGScrollFrame:: +/** + * Sets the manage_pieces flag. When this is true, the sub-pieces of the + * scroll frame--that is, the two scroll bars--are automatically positioned + * and/or resized when the scroll frame's overall frame is changed. They are + * also automatically resized to fill in the gap when one or the other is + * hidden. + */ +INLINE void PGScrollFrame:: set_manage_pieces(bool manage_pieces) { LightReMutexHolder holder(_lock); _manage_pieces = manage_pieces; @@ -102,31 +83,24 @@ set_manage_pieces(bool manage_pieces) { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::get_manage_pieces -// Access: Published -// Description: Returns the manage_pieces flag. See -// set_manage_pieces(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGScrollFrame:: +/** + * Returns the manage_pieces flag. See set_manage_pieces(). + */ +INLINE bool PGScrollFrame:: get_manage_pieces() const { LightReMutexHolder holder(_lock); return _manage_pieces; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_auto_hide -// Access: Published -// Description: Sets the auto_hide flag. When this is true, the -// two scroll bars are automatically hidden if they are -// not needed (that is, if the virtual frame would fit -// within the clip frame without them), and they are -// automatically shown when they are needed. -// -// Setting this flag true forces the manage_pieces flag -// to also be set true. -//////////////////////////////////////////////////////////////////// -INLINE void PGScrollFrame:: +/** + * Sets the auto_hide flag. When this is true, the two scroll bars are + * automatically hidden if they are not needed (that is, if the virtual frame + * would fit within the clip frame without them), and they are automatically + * shown when they are needed. + * + * Setting this flag true forces the manage_pieces flag to also be set true. + */ +INLINE void PGScrollFrame:: set_auto_hide(bool auto_hide) { LightReMutexHolder holder(_lock); _auto_hide = auto_hide; @@ -136,26 +110,20 @@ set_auto_hide(bool auto_hide) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::get_auto_hide -// Access: Published -// Description: Returns the auto_hide flag. See -// set_auto_hide(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGScrollFrame:: +/** + * Returns the auto_hide flag. See set_auto_hide(). + */ +INLINE bool PGScrollFrame:: get_auto_hide() const { LightReMutexHolder holder(_lock); return _auto_hide; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_horizontal_slider -// Access: Published -// Description: Sets the PGSliderBar object that will serve as the -// horizontal scroll bar for this frame. It is your -// responsibility to parent this slider bar to the frame -// and move it to the appropriate place. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PGSliderBar object that will serve as the horizontal scroll bar + * for this frame. It is your responsibility to parent this slider bar to the + * frame and move it to the appropriate place. + */ INLINE void PGScrollFrame:: set_horizontal_slider(PGSliderBar *horizontal_slider) { LightReMutexHolder holder(_lock); @@ -169,39 +137,30 @@ set_horizontal_slider(PGSliderBar *horizontal_slider) { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::clear_horizontal_slider -// Access: Published -// Description: Removes the horizontal scroll bar from control of the -// frame. It is your responsibility to actually remove -// or hide the object itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the horizontal scroll bar from control of the frame. It is your + * responsibility to actually remove or hide the object itself. + */ INLINE void PGScrollFrame:: clear_horizontal_slider() { set_horizontal_slider(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::get_horizontal_slider -// Access: Published -// Description: Returns the PGSliderBar that serves as the horizontal -// scroll bar for this frame, if any, or NULL if it is -// not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PGSliderBar that serves as the horizontal scroll bar for this + * frame, if any, or NULL if it is not set. + */ INLINE PGSliderBar *PGScrollFrame:: get_horizontal_slider() const { LightReMutexHolder holder(_lock); return _horizontal_slider; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::set_vertical_slider -// Access: Published -// Description: Sets the PGSliderBar object that will serve as the -// vertical scroll bar for this frame. It is your -// responsibility to parent this slider bar to the frame -// and move it to the appropriate place. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PGSliderBar object that will serve as the vertical scroll bar for + * this frame. It is your responsibility to parent this slider bar to the + * frame and move it to the appropriate place. + */ INLINE void PGScrollFrame:: set_vertical_slider(PGSliderBar *vertical_slider) { LightReMutexHolder holder(_lock); @@ -215,37 +174,29 @@ set_vertical_slider(PGSliderBar *vertical_slider) { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::clear_vertical_slider -// Access: Published -// Description: Removes the vertical scroll bar from control of the -// frame. It is your responsibility to actually remove -// or hide the object itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the vertical scroll bar from control of the frame. It is your + * responsibility to actually remove or hide the object itself. + */ INLINE void PGScrollFrame:: clear_vertical_slider() { set_vertical_slider(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::get_vertical_slider -// Access: Published -// Description: Returns the PGSliderBar that serves as the vertical -// scroll bar for this frame, if any, or NULL if it is -// not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PGSliderBar that serves as the vertical scroll bar for this + * frame, if any, or NULL if it is not set. + */ INLINE PGSliderBar *PGScrollFrame:: get_vertical_slider() const { LightReMutexHolder holder(_lock); return _vertical_slider; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::recompute -// Access: Published -// Description: Forces the PGScrollFrame to recompute itself right -// now. Normally this should not be required. -//////////////////////////////////////////////////////////////////// +/** + * Forces the PGScrollFrame to recompute itself right now. Normally this + * should not be required. + */ INLINE void PGScrollFrame:: recompute() { LightReMutexHolder holder(_lock); diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index defe06517f..e930ba3b15 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -1,26 +1,23 @@ -// Filename: pgScrollFrame.cxx -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgScrollFrame.cxx + * @author drose + * @date 2005-08-17 + */ #include "pgScrollFrame.h" TypeHandle PGScrollFrame::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGScrollFrame:: PGScrollFrame(const string &name) : PGVirtualFrame(name) { @@ -37,22 +34,18 @@ PGScrollFrame(const string &name) : PGVirtualFrame(name) _vertical_slider = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGScrollFrame:: ~PGScrollFrame() { set_horizontal_slider(NULL); set_vertical_slider(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGScrollFrame:: PGScrollFrame(const PGScrollFrame ©) : PGVirtualFrame(copy), @@ -66,45 +59,35 @@ PGScrollFrame(const PGScrollFrame ©) : _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGScrollFrame:: make_copy() const { LightReMutexHolder holder(_lock); return new PGScrollFrame(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGScrollFrame:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); @@ -120,13 +103,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return PGVirtualFrame::cull_callback(trav, data); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PGScrollFrame:: xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); @@ -135,13 +115,11 @@ xform(const LMatrix4 &mat) { _needs_remanage = true; _needs_recompute_clip = true; } - -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::setup -// Access: Published -// Description: Creates a PGScrollFrame with the indicated -// dimensions, and the indicated virtual frame. -//////////////////////////////////////////////////////////////////// + +/** + * Creates a PGScrollFrame with the indicated dimensions, and the indicated + * virtual frame. + */ void PGScrollFrame:: setup(PN_stdfloat width, PN_stdfloat height, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top, @@ -164,8 +142,7 @@ setup(PN_stdfloat width, PN_stdfloat height, set_virtual_frame(left, right, bottom, top); - // Remove the slider nodes created by a previous call to setup(), if - // any. + // Remove the slider nodes created by a previous call to setup(), if any. if (_horizontal_slider != (PGSliderBar *)NULL) { remove_child(_horizontal_slider); set_horizontal_slider(NULL); @@ -192,12 +169,10 @@ setup(PN_stdfloat width, PN_stdfloat height, set_auto_hide(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::remanage -// Access: Published -// Description: Manages the position and size of the scroll bars. -// Normally this should not need to be called directly. -//////////////////////////////////////////////////////////////////// +/** + * Manages the position and size of the scroll bars. Normally this should not + * need to be called directly. + */ void PGScrollFrame:: remanage() { LightReMutexHolder holder(_lock); @@ -207,7 +182,7 @@ remanage() { LVecBase4 clip = get_frame_style(get_state()).get_internal_frame(frame); // Determine which scroll bars we have in the frame. - + bool got_horizontal = false; PN_stdfloat horizontal_width = 0.0f; if (_horizontal_slider != (PGSliderBar *)NULL) { @@ -215,7 +190,7 @@ remanage() { const LVecBase4 &slider_frame = _horizontal_slider->get_frame(); horizontal_width = slider_frame[3] - slider_frame[2]; } - + bool got_vertical = false; PN_stdfloat vertical_width = 0.0f; if (_vertical_slider != (PGSliderBar *)NULL) { @@ -247,11 +222,11 @@ remanage() { // No need for the horizontal slider. got_horizontal = false; } - + if (virtual_height <= clip_height - horizontal_width) { // No need for the vertical slider. got_vertical = false; - + // Now reconsider the need for the horizontal slider. if (virtual_width <= clip_width) { got_horizontal = false; @@ -279,9 +254,8 @@ remanage() { } } - // Showing or hiding one of the scroll bars might have set this - // flag again indirectly; we clear it again to avoid a feedback - // loop. + // Showing or hiding one of the scroll bars might have set this flag again + // indirectly; we clear it again to avoid a feedback loop. _needs_remanage = false; } @@ -305,16 +279,14 @@ remanage() { clip[2] + horizontal_width, clip[3]); _vertical_slider->clear_transform(); } - + recompute(); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::frame_changed -// Access: Protected, Virtual -// Description: Called when the user changes the frame size. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user changes the frame size. + */ void PGScrollFrame:: frame_changed() { LightReMutexHolder holder(_lock); @@ -323,36 +295,27 @@ frame_changed() { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::item_transform_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's local transform -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's local transform has been changed. + */ void PGScrollFrame:: item_transform_changed(PGItem *) { LightReMutexHolder holder(_lock); _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::item_frame_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's frame -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's frame has been changed. + */ void PGScrollFrame:: item_frame_changed(PGItem *) { LightReMutexHolder holder(_lock); _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::item_draw_mask_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's draw_mask -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's draw_mask has been changed. + */ void PGScrollFrame:: item_draw_mask_changed(PGItem *) { LightReMutexHolder holder(_lock); @@ -360,24 +323,20 @@ item_draw_mask_changed(PGItem *) { _needs_recompute_clip = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::slider_bar_adjust -// Access: Protected, Virtual -// Description: Called whenever a watched PGSliderBar's value -// has been changed by the user or programmatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGSliderBar's value has been changed by the user + * or programmatically. + */ void PGScrollFrame:: slider_bar_adjust(PGSliderBar *) { LightReMutexHolder holder(_lock); _needs_recompute_canvas = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::recompute_clip -// Access: Private -// Description: Recomputes the clipping window of the PGScrollFrame, -// based on the position of the slider bars. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the clipping window of the PGScrollFrame, based on the position + * of the slider bars. + */ void PGScrollFrame:: recompute_clip() { LightReMutexHolder holder(_lock); @@ -399,13 +358,10 @@ recompute_clip() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::recompute_canvas -// Access: Private -// Description: Recomputes the portion of the virtual canvas that is -// visible within the PGScrollFrame, based on the values -// of the slider bars. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the portion of the virtual canvas that is visible within the + * PGScrollFrame, based on the values of the slider bars. + */ void PGScrollFrame:: recompute_canvas() { LightReMutexHolder holder(_lock); @@ -413,26 +369,23 @@ recompute_canvas() { const LVecBase4 &clip = get_clip_frame(); - PN_stdfloat x = interpolate_canvas(clip[0], clip[1], + PN_stdfloat x = interpolate_canvas(clip[0], clip[1], _virtual_frame[0], _virtual_frame[1], _horizontal_slider); - PN_stdfloat y = interpolate_canvas(clip[3], clip[2], + PN_stdfloat y = interpolate_canvas(clip[3], clip[2], _virtual_frame[3], _virtual_frame[2], _vertical_slider); get_canvas_node()->set_transform(TransformState::make_pos(LVector3::rfu(x, 0, y))); } -//////////////////////////////////////////////////////////////////// -// Function: PGScrollFrame::interpolate_canvas -// Access: Private -// Description: Computes the linear translation that should be -// applied to the virtual canvas node, based on the -// corresponding slider bar's position. -//////////////////////////////////////////////////////////////////// +/** + * Computes the linear translation that should be applied to the virtual + * canvas node, based on the corresponding slider bar's position. + */ PN_stdfloat PGScrollFrame:: -interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, +interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar) { LightReMutexHolder holder(_lock); diff --git a/panda/src/pgui/pgScrollFrame.h b/panda/src/pgui/pgScrollFrame.h index 430e0927f8..9847852b1f 100644 --- a/panda/src/pgui/pgScrollFrame.h +++ b/panda/src/pgui/pgScrollFrame.h @@ -1,16 +1,15 @@ -// Filename: pgScrollFrame.h -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgScrollFrame.h + * @author drose + * @date 2005-08-17 + */ #ifndef PGSCROLLFRAME_H #define PGSCROLLFRAME_H @@ -21,21 +20,18 @@ #include "pgSliderBarNotify.h" #include "pgSliderBar.h" -//////////////////////////////////////////////////////////////////// -// Class : PGScrollFrame -// Description : This is a special kind of frame that pretends to be -// much larger than it actually is. You can scroll -// through the frame, as if you're looking through a -// window at the larger frame beneath. All children of -// this frame node are scrolled and clipped as if they -// were children of the larger, virtual frame. -// -// This is implemented as a specialization of -// PGVirtualFrame, which handles the meat of the virtual -// canvas. This class adds automatic support for scroll -// bars, and restricts the virtual transform to -// translate only (no scale or rotate). -//////////////////////////////////////////////////////////////////// +/** + * This is a special kind of frame that pretends to be much larger than it + * actually is. You can scroll through the frame, as if you're looking + * through a window at the larger frame beneath. All children of this frame + * node are scrolled and clipped as if they were children of the larger, + * virtual frame. + * + * This is implemented as a specialization of PGVirtualFrame, which handles + * the meat of the virtual canvas. This class adds automatic support for + * scroll bars, and restricts the virtual transform to translate only (no + * scale or rotate). + */ class EXPCL_PANDA_PGUI PGScrollFrame : public PGVirtualFrame, public PGSliderBarNotify { PUBLISHED: PGScrollFrame(const string &name = ""); @@ -89,7 +85,7 @@ private: void recompute_clip(); void recompute_canvas(); - PN_stdfloat interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, + PN_stdfloat interpolate_canvas(PN_stdfloat clip_min, PN_stdfloat clip_max, PN_stdfloat canvas_min, PN_stdfloat canvas_max, PGSliderBar *slider_bar); diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index 2edbf25c66..927424706f 100644 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -1,64 +1,50 @@ -// Filename: pgSliderBar.I -// Created by: masad (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBar.I + * @author masad + * @date 2004-10-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_notify -// Access: Published -// Description: Sets the object which will be notified when the -// PGSliderBar changes. Set this to NULL to disable -// this effect. The PGSliderBar does not retain -// ownership of the pointer; it is your responsibility -// to ensure that the notify object does not destruct. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the object which will be notified when the PGSliderBar changes. Set + * this to NULL to disable this effect. The PGSliderBar does not retain + * ownership of the pointer; it is your responsibility to ensure that the + * notify object does not destruct. + */ +INLINE void PGSliderBar:: set_notify(PGSliderBarNotify *notify) { PGItem::set_notify(notify); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_notify -// Access: Published -// Description: Returns the object which will be notified when the -// PGSliderBar changes, if any. Returns NULL if there -// is no such object configured. -//////////////////////////////////////////////////////////////////// -INLINE PGSliderBarNotify *PGSliderBar:: +/** + * Returns the object which will be notified when the PGSliderBar changes, if + * any. Returns NULL if there is no such object configured. + */ +INLINE PGSliderBarNotify *PGSliderBar:: get_notify() const { return (PGSliderBarNotify *)PGItem::get_notify(); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_axis -// Access: Published -// Description: Specifies the axis of the slider bar's motion. This -// should be only one of four vectors: (1, 0, 0), (0, 0, -// 1), (-1, 0, 0), or (0, 0, -1). -// -// This specifies the vector in which the thumb moves -// when it is moving from the minimum to the maximum -// value. -// -// The axis must be parallel to one of the screen axes, -// and it must be normalized. Hence, it may only be one -// of the above four possibilities; anything else is an -// error and will result in indeterminate behavior. -// -// Normally, you should not try to set the axis -// directly. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Specifies the axis of the slider bar's motion. This should be only one of + * four vectors: (1, 0, 0), (0, 0, 1), (-1, 0, 0), or (0, 0, -1). + * + * This specifies the vector in which the thumb moves when it is moving from + * the minimum to the maximum value. + * + * The axis must be parallel to one of the screen axes, and it must be + * normalized. Hence, it may only be one of the above four possibilities; + * anything else is an error and will result in indeterminate behavior. + * + * Normally, you should not try to set the axis directly. + */ +INLINE void PGSliderBar:: set_axis(const LVector3 &axis) { LightReMutexHolder holder(_lock); _axis = axis; @@ -66,24 +52,19 @@ set_axis(const LVector3 &axis) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_axis -// Access: Published -// Description: Returns the axis of the slider bar's motion. See -// set_axis(). -//////////////////////////////////////////////////////////////////// -INLINE const LVector3 &PGSliderBar:: +/** + * Returns the axis of the slider bar's motion. See set_axis(). + */ +INLINE const LVector3 &PGSliderBar:: get_axis() const { LightReMutexHolder holder(_lock); return _axis; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_range -// Access: Published -// Description: Sets the minimum and maxmimum value for the slider. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the minimum and maxmimum value for the slider. + */ +INLINE void PGSliderBar:: set_range(PN_stdfloat min_value, PN_stdfloat max_value) { LightReMutexHolder holder(_lock); nassertv(min_value != max_value); @@ -96,112 +77,89 @@ set_range(PN_stdfloat min_value, PN_stdfloat max_value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_min_value -// Access: Published -// Description: Returns the value when the slider is all the way to -// the left. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the value when the slider is all the way to the left. + */ +INLINE PN_stdfloat PGSliderBar:: get_min_value() const { LightReMutexHolder holder(_lock); return _min_value; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_max_value -// Access: Published -// Description: Returns the value when the slider is all the way to -// the right. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the value when the slider is all the way to the right. + */ +INLINE PN_stdfloat PGSliderBar:: get_max_value() const { LightReMutexHolder holder(_lock); return _max_value; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_scroll_size -// Access: Published -// Description: Specifies the amount the slider will move when the -// user clicks on the left or right buttons. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Specifies the amount the slider will move when the user clicks on the left + * or right buttons. + */ +INLINE void PGSliderBar:: set_scroll_size(PN_stdfloat value) { LightReMutexHolder holder(_lock); _scroll_value = value; _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_scroll_size -// Access: Published -// Description: Returns the value last set by set_scroll_size(). -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the value last set by set_scroll_size(). + */ +INLINE PN_stdfloat PGSliderBar:: get_scroll_size() const { LightReMutexHolder holder(_lock); return _scroll_value; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_page_size -// Access: Published -// Description: Specifies the amount of data contained in a single -// page. This indicates how much the thumb will jump -// when the trough is directly clicked; and if -// resize_thumb is true, it also controls the visible -// size of the thumb button. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Specifies the amount of data contained in a single page. This indicates + * how much the thumb will jump when the trough is directly clicked; and if + * resize_thumb is true, it also controls the visible size of the thumb + * button. + */ +INLINE void PGSliderBar:: set_page_size(PN_stdfloat value) { LightReMutexHolder holder(_lock); _page_value = value; _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_page_size -// Access: Published -// Description: Returns the value last set by set_page_size(). -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the value last set by set_page_size(). + */ +INLINE PN_stdfloat PGSliderBar:: get_page_size() const { LightReMutexHolder holder(_lock); return _page_value; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_value -// Access: Published -// Description: Sets the current value of the slider -// programmatically. This should range between -// get_min_value() and get_max_value(). -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the current value of the slider programmatically. This should range + * between get_min_value() and get_max_value(). + */ +INLINE void PGSliderBar:: set_value(PN_stdfloat value) { LightReMutexHolder holder(_lock); set_ratio((value - _min_value) / (_max_value - _min_value)); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_value -// Access: Published -// Description: Returns the current value of the slider. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the current value of the slider. + */ +INLINE PN_stdfloat PGSliderBar:: get_value() const { LightReMutexHolder holder(_lock); return get_ratio() * (_max_value - _min_value) + _min_value; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_ratio -// Access: Published -// Description: Sets the current value of the slider, expressed in -// the range 0 .. 1. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the current value of the slider, expressed in the range 0 .. 1. + */ +INLINE void PGSliderBar:: set_ratio(PN_stdfloat ratio) { LightReMutexHolder holder(_lock); if (!is_button_down()) { @@ -209,70 +167,55 @@ set_ratio(PN_stdfloat ratio) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_ratio -// Access: Published -// Description: Returns the current value of the slider, expressed in -// the range 0 .. 1. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGSliderBar:: +/** + * Returns the current value of the slider, expressed in the range 0 .. 1. + */ +INLINE PN_stdfloat PGSliderBar:: get_ratio() const { LightReMutexHolder holder(_lock); return _ratio; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::is_button_down -// Access: Published -// Description: Returns true if the user is currently holding down -// the mouse button to manipulate the slider. When -// true, calls to set_ratio() or set_value() will have -// no effect. -//////////////////////////////////////////////////////////////////// -INLINE bool PGSliderBar:: +/** + * Returns true if the user is currently holding down the mouse button to + * manipulate the slider. When true, calls to set_ratio() or set_value() will + * have no effect. + */ +INLINE bool PGSliderBar:: is_button_down() const { LightReMutexHolder holder(_lock); - return _dragging || _mouse_button_page || + return _dragging || _mouse_button_page || (_scroll_button_held != (PGItem *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_resize_thumb -// Access: Published -// Description: Sets the resize_thumb flag. When this is true, the -// thumb button's frame will be adjusted so that its -// width visually represents the page size. When this -// is false, the thumb button will be left alone. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the resize_thumb flag. When this is true, the thumb button's frame + * will be adjusted so that its width visually represents the page size. When + * this is false, the thumb button will be left alone. + */ +INLINE void PGSliderBar:: set_resize_thumb(bool resize_thumb) { LightReMutexHolder holder(_lock); _resize_thumb = resize_thumb; _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_resize_thumb -// Access: Published -// Description: Returns the resize_thumb flag. See -// set_resize_thumb(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGSliderBar:: +/** + * Returns the resize_thumb flag. See set_resize_thumb(). + */ +INLINE bool PGSliderBar:: get_resize_thumb() const { LightReMutexHolder holder(_lock); return _resize_thumb; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_manage_pieces -// Access: Published -// Description: Sets the manage_pieces flag. When this is true, the -// sub-pieces of the slider bar--that is, the thumb, and -// the left and right scroll buttons--are automatically -// positioned and/or resized when the slider bar's -// overall frame is changed. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the manage_pieces flag. When this is true, the sub-pieces of the + * slider bar--that is, the thumb, and the left and right scroll buttons--are + * automatically positioned and/or resized when the slider bar's overall frame + * is changed. + */ +INLINE void PGSliderBar:: set_manage_pieces(bool manage_pieces) { LightReMutexHolder holder(_lock); _manage_pieces = manage_pieces; @@ -280,30 +223,23 @@ set_manage_pieces(bool manage_pieces) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_manage_pieces -// Access: Published -// Description: Returns the manage_pieces flag. See -// set_manage_pieces(). -//////////////////////////////////////////////////////////////////// -INLINE bool PGSliderBar:: +/** + * Returns the manage_pieces flag. See set_manage_pieces(). + */ +INLINE bool PGSliderBar:: get_manage_pieces() const { LightReMutexHolder holder(_lock); return _manage_pieces; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_thumb_button -// Access: Published -// Description: Sets the PGButton object that will serve as the thumb -// for this slider. This button visually represents the -// position of the slider, and can be dragged left and -// right by the user. -// -// It is the responsibility of the caller to ensure that -// the button object is parented to the PGSliderBar -// node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PGButton object that will serve as the thumb for this slider. + * This button visually represents the position of the slider, and can be + * dragged left and right by the user. + * + * It is the responsibility of the caller to ensure that the button object is + * parented to the PGSliderBar node. + */ INLINE void PGSliderBar:: set_thumb_button(PGButton *thumb_button) { LightReMutexHolder holder(_lock); @@ -318,42 +254,33 @@ set_thumb_button(PGButton *thumb_button) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::clear_thumb_button -// Access: Published -// Description: Removes the thumb button object from control of the -// frame. It is your responsibility to actually remove -// or hide the button itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the thumb button object from control of the frame. It is your + * responsibility to actually remove or hide the button itself. + */ INLINE void PGSliderBar:: clear_thumb_button() { set_thumb_button(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_thumb_button -// Access: Published -// Description: Returns the PGButton that serves as the thumb for -// this slider, or NULL if it is not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PGButton that serves as the thumb for this slider, or NULL if + * it is not set. + */ INLINE PGButton *PGSliderBar:: get_thumb_button() const { LightReMutexHolder holder(_lock); return _thumb_button; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_left_button -// Access: Published -// Description: Sets the PGButton object that will serve as the left -// scroll button for this slider. This button is -// optional; if present, the user can click on it to -// move scroll_size units at a time to the left. -// -// It is the responsibility of the caller to ensure that -// the button object is parented to the PGSliderBar -// node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PGButton object that will serve as the left scroll button for this + * slider. This button is optional; if present, the user can click on it to + * move scroll_size units at a time to the left. + * + * It is the responsibility of the caller to ensure that the button object is + * parented to the PGSliderBar node. + */ INLINE void PGSliderBar:: set_left_button(PGButton *left_button) { LightReMutexHolder holder(_lock); @@ -368,43 +295,33 @@ set_left_button(PGButton *left_button) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::clear_left_button -// Access: Published -// Description: Removes the left button object from control of the -// frame. It is your responsibility to actually remove -// or hide the button itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the left button object from control of the frame. It is your + * responsibility to actually remove or hide the button itself. + */ INLINE void PGSliderBar:: clear_left_button() { set_left_button(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_left_button -// Access: Published -// Description: Returns the PGButton that serves as the left scroll -// button for this slider, if any, or NULL if it is not -// set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PGButton that serves as the left scroll button for this slider, + * if any, or NULL if it is not set. + */ INLINE PGButton *PGSliderBar:: get_left_button() const { LightReMutexHolder holder(_lock); return _left_button; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_right_button -// Access: Published -// Description: Sets the PGButton object that will serve as the right -// scroll button for this slider. This button is -// optional; if present, the user can click on it to -// move scroll_size units at a time to the right. -// -// It is the responsibility of the caller to ensure that -// the button object is parented to the PGSliderBar -// node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the PGButton object that will serve as the right scroll button for + * this slider. This button is optional; if present, the user can click on it + * to move scroll_size units at a time to the right. + * + * It is the responsibility of the caller to ensure that the button object is + * parented to the PGSliderBar node. + */ INLINE void PGSliderBar:: set_right_button(PGButton *right_button) { LightReMutexHolder holder(_lock); @@ -419,64 +336,50 @@ set_right_button(PGButton *right_button) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::clear_right_button -// Access: Published -// Description: Removes the right button object from control of the -// frame. It is your responsibility to actually remove -// or hide the button itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the right button object from control of the frame. It is your + * responsibility to actually remove or hide the button itself. + */ INLINE void PGSliderBar:: clear_right_button() { set_right_button(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_right_button -// Access: Published -// Description: Returns the PGButton that serves as the right scroll -// button for this slider, if any, or NULL if it is not -// set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PGButton that serves as the right scroll button for this + * slider, if any, or NULL if it is not set. + */ INLINE PGButton *PGSliderBar:: get_right_button() const { LightReMutexHolder holder(_lock); return _right_button; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_adjust_prefix -// Access: Published, Static -// Description: Returns the prefix that is used to define the adjust -// event for all PGSliderBars. The adjust event is the -// concatenation of this string followed by get_id(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that is used to define the adjust event for all + * PGSliderBars. The adjust event is the concatenation of this string + * followed by get_id(). + */ INLINE string PGSliderBar:: get_adjust_prefix() { return "adjust-"; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::get_adjust_event -// Access: Published -// Description: Returns the event name that will be thrown when the -// slider bar value is adjusted by the user or -// programmatically. -//////////////////////////////////////////////////////////////////// +/** + * Returns the event name that will be thrown when the slider bar value is + * adjusted by the user or programmatically. + */ INLINE string PGSliderBar:: get_adjust_event() const { LightReMutexHolder holder(_lock); return get_adjust_prefix() + get_id(); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::internal_set_ratio -// Access: Private -// Description: Sets the current value of the slider, expressed in -// the range 0 .. 1, without checking whether the user -// is currently manipulating the slider. -//////////////////////////////////////////////////////////////////// -INLINE void PGSliderBar:: +/** + * Sets the current value of the slider, expressed in the range 0 .. 1, + * without checking whether the user is currently manipulating the slider. + */ +INLINE void PGSliderBar:: internal_set_ratio(PN_stdfloat ratio) { _ratio = max(min(ratio, (PN_stdfloat)1.0), (PN_stdfloat)0.0); _needs_reposition = true; diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index 53fed5253b..da09bf73f3 100644 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -1,16 +1,15 @@ -// Filename: pgSliderBar.cxx -// Created by: masad (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBar.cxx + * @author masad + * @date 2004-10-19 + */ #include "pgSliderBar.h" #include "pgMouseWatcherParameter.h" @@ -23,13 +22,11 @@ TypeHandle PGSliderBar::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGSliderBar:: -PGSliderBar(const string &name) +PGSliderBar(const string &name) : PGItem(name) { set_cull_callback(); @@ -53,20 +50,16 @@ PGSliderBar(const string &name) set_active(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGSliderBar:: ~PGSliderBar() { } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGSliderBar:: PGSliderBar(const PGSliderBar ©) : PGItem(copy), @@ -88,27 +81,21 @@ PGSliderBar(const PGSliderBar ©) : _dragging = false; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGSliderBar:: make_copy() const { LightReMutexHolder holder(_lock); return new PGSliderBar(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the region. + */ void PGSliderBar:: press(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -124,20 +111,17 @@ press(const MouseWatcherParameter ¶m, bool background) { _mouse_button_page = true; _scroll_button_held = NULL; advance_page(); - _next_advance_time = + _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; } } PGItem::press(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void PGSliderBar:: release(const MouseWatcherParameter ¶m, bool background) { LightReMutexHolder holder(_lock); @@ -150,51 +134,42 @@ release(const MouseWatcherParameter ¶m, bool background) { PGItem::release(param, background); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::move -// Access: Protected, Virtual -// Description: This is a callback hook function, called whenever a -// mouse is moved while within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse is moved while + * within the region. + */ void PGSliderBar:: move(const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); _mouse_pos = param.get_mouse(); if (_dragging) { - // We only get here if we the user originally clicked on the - // track, which caused the slider to move all the way to the mouse - // position, and then started dragging the mouse along the track. - // In this case, we start moving the thumb as if the user had - // started by dragging the thumb directly. + // We only get here if we the user originally clicked on the track, which + // caused the slider to move all the way to the mouse position, and then + // started dragging the mouse along the track. In this case, we start + // moving the thumb as if the user had started by dragging the thumb + // directly. continue_drag(); } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGSliderBar:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); @@ -205,12 +180,12 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { recompute(); } - if (_scroll_button_held != (PGItem *)NULL && + if (_scroll_button_held != (PGItem *)NULL && _next_advance_time <= ClockObject::get_global_clock()->get_frame_time()) { advance_scroll(); } - if (_mouse_button_page && + if (_mouse_button_page && _next_advance_time <= ClockObject::get_global_clock()->get_frame_time()) { advance_page(); } @@ -222,21 +197,18 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return PGItem::cull_callback(trav, data); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::xform -// Access: Public, Virtual -// Description: Transforms the contents of this node by the indicated -// matrix, if it means anything to do so. For most -// kinds of nodes, this does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the contents of this node by the indicated matrix, if it means + * anything to do so. For most kinds of nodes, this does nothing. + */ void PGSliderBar:: xform(const LMatrix4 &mat) { LightReMutexHolder holder(_lock); PGItem::xform(mat); _axis = _axis * mat; - // Make sure we set the thumb to identity position first, so it - // won't be accidentally flattened. + // Make sure we set the thumb to identity position first, so it won't be + // accidentally flattened. if (_thumb_button != (PGButton *)NULL) { _thumb_button->clear_transform(); } @@ -245,13 +217,10 @@ xform(const LMatrix4 &mat) { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::adjust -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// slider value is adjusted by the user or -// programmatically. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the slider value is + * adjusted by the user or programmatically. + */ void PGSliderBar:: adjust() { LightReMutexHolder holder(_lock); @@ -264,20 +233,16 @@ adjust() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::setup_scroll_bar -// Access: Published -// Description: Creates PGSliderBar that represents a vertical or -// horizontal scroll bar (if vertical is true or false, -// respectively), with additional buttons for scrolling, -// and a range of 0 .. 1. -// -// length here is the measurement along the scroll bar, -// and width is the measurement across the scroll bar, -// whether it is vertical or horizontal (so for a -// horizontal scroll bar, the length is actually the x -// dimension, and the width is the y dimension). -//////////////////////////////////////////////////////////////////// +/** + * Creates PGSliderBar that represents a vertical or horizontal scroll bar (if + * vertical is true or false, respectively), with additional buttons for + * scrolling, and a range of 0 .. 1. + * + * length here is the measurement along the scroll bar, and width is the + * measurement across the scroll bar, whether it is vertical or horizontal (so + * for a horizontal scroll bar, the length is actually the x dimension, and + * the width is the y dimension). + */ void PGSliderBar:: setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); @@ -301,8 +266,7 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo style.set_type(PGFrameStyle::T_bevel_out); style.set_width(bevel, bevel); - // Remove the button nodes created by a previous call to setup(), if - // any. + // Remove the button nodes created by a previous call to setup(), if any. if (_thumb_button != (PGButton *)NULL) { remove_child(_thumb_button); set_thumb_button(NULL); @@ -318,14 +282,14 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo PT(PGButton) thumb = new PGButton("thumb"); thumb->setup("", bevel); - thumb->set_frame(-width / 2.0f, width / 2.0f, + thumb->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); add_child(thumb); set_thumb_button(thumb); PT(PGButton) left = new PGButton("left"); left->setup("", bevel); - left->set_frame(-width / 2.0f, width / 2.0f, + left->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); left->set_transform(TransformState::make_pos(((width - length) / 2.0f) * _axis)); add_child(left); @@ -333,7 +297,7 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo PT(PGButton) right = new PGButton("right"); right->setup("", bevel); - right->set_frame(-width / 2.0f, width / 2.0f, + right->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); right->set_transform(TransformState::make_pos(((length - width) / 2.0f) * _axis)); add_child(right); @@ -343,15 +307,13 @@ setup_scroll_bar(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdflo set_manage_pieces(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::setup_slider -// Access: Published -// Description: Creates PGSliderBar that represents a slider that the -// user can use to control an analog quantity. -// -// This is functionally the same as a scroll bar, but it -// has a distinctive look. -//////////////////////////////////////////////////////////////////// +/** + * Creates PGSliderBar that represents a slider that the user can use to + * control an analog quantity. + * + * This is functionally the same as a scroll bar, but it has a distinctive + * look. + */ void PGSliderBar:: setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat bevel) { LightReMutexHolder holder(_lock); @@ -373,8 +335,7 @@ setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat b style.set_width(bevel, bevel); set_frame_style(0, style); - // Remove the button nodes created by a previous call to setup(), if - // any. + // Remove the button nodes created by a previous call to setup(), if any. if (_thumb_button != (PGButton *)NULL) { remove_child(_thumb_button); set_thumb_button(NULL); @@ -390,7 +351,7 @@ setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat b PT(PGButton) thumb = new PGButton("thumb"); thumb->setup(" ", bevel); - thumb->set_frame(-width / 4.0f, width / 4.0f, + thumb->set_frame(-width / 4.0f, width / 4.0f, -width / 2.0f, width / 2.0f); add_child(thumb); set_thumb_button(thumb); @@ -399,15 +360,12 @@ setup_slider(bool vertical, PN_stdfloat length, PN_stdfloat width, PN_stdfloat b set_manage_pieces(true); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::set_active -// Access: Published, Virtual -// Description: Sets whether the PGItem is active for mouse watching. -// This is not necessarily related to the -// active/inactive appearance of the item, which is -// controlled by set_state(), but it does affect whether -// it responds to mouse events. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the PGItem is active for mouse watching. This is not + * necessarily related to the active/inactive appearance of the item, which is + * controlled by set_state(), but it does affect whether it responds to mouse + * events. + */ void PGSliderBar:: set_active(bool active) { LightReMutexHolder holder(_lock); @@ -425,13 +383,10 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::remanage -// Access: Published -// Description: Manages the position and size of the scroll bars and -// the thumb. Normally this should not need to be -// called directly. -//////////////////////////////////////////////////////////////////// +/** + * Manages the position and size of the scroll bars and the thumb. Normally + * this should not need to be called directly. + */ void PGSliderBar:: remanage() { LightReMutexHolder holder(_lock); @@ -444,7 +399,7 @@ remanage() { // The slider is X-dominant. width = frame[3] - frame[2]; length = frame[1] - frame[0]; - + } else { // The slider is Y-dominant. width = frame[1] - frame[0]; @@ -456,19 +411,19 @@ remanage() { (frame[2] + frame[3]) / 2.0f); if (_left_button != (PGButton *)NULL) { - _left_button->set_frame(-width / 2.0f, width / 2.0f, + _left_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _left_button->set_transform(TransformState::make_pos(center + ((width - length) / 2.0f) * _axis)); } if (_right_button != (PGButton *)NULL) { - _right_button->set_frame(-width / 2.0f, width / 2.0f, + _right_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _right_button->set_transform(TransformState::make_pos(center + ((length - width) / 2.0f) * _axis)); } if (_thumb_button != (PGButton *)NULL) { - _thumb_button->set_frame(-width / 2.0f, width / 2.0f, + _thumb_button->set_frame(-width / 2.0f, width / 2.0f, -width / 2.0f, width / 2.0f); _thumb_button->set_transform(TransformState::make_pos(center)); } @@ -476,12 +431,10 @@ remanage() { recompute(); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::recompute -// Access: Published -// Description: Recomputes the position and size of the thumb. -// Normally this should not need to be called directly. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the position and size of the thumb. Normally this should not + * need to be called directly. + */ void PGSliderBar:: recompute() { LightReMutexHolder holder(_lock); @@ -507,23 +460,23 @@ recompute() { LVecBase4 frame = get_frame(); reduce_region(frame, _left_button); reduce_region(frame, _right_button); - + if (fabs(_axis[0]) > fabs(_axis[1] + _axis[2])) { // The slider is X-dominant. - + _min_x = frame[0]; _max_x = frame[1]; - + PN_stdfloat trough_width = _max_x - _min_x; - + if (_thumb_button == (PGButton *)NULL) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); - + } else { const LVecBase4 &thumb_frame = _thumb_button->get_frame(); - + if (_resize_thumb) { // If we're allowed to adjust the thumb's size, we don't need to // find out how wide it is. @@ -531,13 +484,13 @@ recompute() { _thumb_button->set_frame(-_thumb_width / 2.0f, _thumb_width / 2.0f, thumb_frame[2], thumb_frame[3]); } else { - // If we're not adjusting the thumb's size, we do need to know - // its current width. + // If we're not adjusting the thumb's size, we do need to know its + // current width. _thumb_width = thumb_frame[1] - thumb_frame[0]; } - + _range_x = trough_width - _thumb_width; - + if (_axis[0] >= 0.0f) { // The slider runs forwards, left to right. _thumb_start = (_min_x - thumb_frame[0]) * _axis; @@ -547,24 +500,24 @@ recompute() { } _thumb_start += LVector3::rfu(0.0f, 0.0f, (frame[2] + frame[3]) / 2.0f); } - + } else { - // The slider is Y-dominant. We call it X in the variable names, - // but it's really Y (or even Z). - + // The slider is Y-dominant. We call it X in the variable names, but + // it's really Y (or even Z). + _min_x = frame[2]; _max_x = frame[3]; - + PN_stdfloat trough_width = _max_x - _min_x; - + if (_thumb_button == (PGButton *)NULL) { _thumb_width = 0.0f; _range_x = 0.0f; _thumb_start.set(0.0f, 0.0f, 0.0f); - + } else { const LVecBase4 &thumb_frame = _thumb_button->get_frame(); - + if (_resize_thumb) { // If we're allowed to adjust the thumb's size, we don't need to // find out how wide it is. @@ -572,13 +525,13 @@ recompute() { _thumb_button->set_frame(thumb_frame[0], thumb_frame[1], -_thumb_width / 2.0f, _thumb_width / 2.0f); } else { - // If we're not adjusting the thumb's size, we do need to know - // its current width. + // If we're not adjusting the thumb's size, we do need to know its + // current width. _thumb_width = thumb_frame[3] - thumb_frame[2]; } - + _range_x = trough_width - _thumb_width; - + if (_axis[1] >= 0.0f && _axis[2] >= 0.0f) { // The slider runs forwards, bottom to top. _thumb_start = (_min_x - thumb_frame[2]) * _axis; @@ -594,11 +547,9 @@ recompute() { reposition(); } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::frame_changed -// Access: Protected, Virtual -// Description: Called when the user changes the frame size. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user changes the frame size. + */ void PGSliderBar:: frame_changed() { LightReMutexHolder holder(_lock); @@ -607,48 +558,37 @@ frame_changed() { _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_transform_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's local transform -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's local transform has been changed. + */ void PGSliderBar:: item_transform_changed(PGItem *) { LightReMutexHolder holder(_lock); _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_frame_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's frame -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's frame has been changed. + */ void PGSliderBar:: item_frame_changed(PGItem *) { LightReMutexHolder holder(_lock); _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_draw_mask_changed -// Access: Protected, Virtual -// Description: Called whenever a watched PGItem's draw_mask -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGItem's draw_mask has been changed. + */ void PGSliderBar:: item_draw_mask_changed(PGItem *) { LightReMutexHolder holder(_lock); _needs_recompute = true; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_press -// Access: Protected, Virtual -// Description: Called whenever the "press" event is triggered on a -// watched PGItem. See PGItem::press(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "press" event is triggered on a watched PGItem. See + * PGItem::press(). + */ void PGSliderBar:: item_press(PGItem *item, const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -659,7 +599,7 @@ item_press(PGItem *item, const MouseWatcherParameter ¶m) { _scroll_button_held = item; _mouse_button_page = false; advance_scroll(); - _next_advance_time = + _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_initial_delay; } else if (item == _thumb_button) { @@ -668,12 +608,10 @@ item_press(PGItem *item, const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_release -// Access: Protected, Virtual -// Description: Called whenever the "release" event is triggered on a -// watched PGItem. See PGItem::release(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "release" event is triggered on a watched PGItem. See + * PGItem::release(). + */ void PGSliderBar:: item_release(PGItem *item, const MouseWatcherParameter &) { LightReMutexHolder holder(_lock); @@ -688,12 +626,10 @@ item_release(PGItem *item, const MouseWatcherParameter &) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::item_move -// Access: Protected, Virtual -// Description: Called whenever the "move" event is triggered on a -// watched PGItem. See PGItem::move(). -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the "move" event is triggered on a watched PGItem. See + * PGItem::move(). + */ void PGSliderBar:: item_move(PGItem *item, const MouseWatcherParameter ¶m) { LightReMutexHolder holder(_lock); @@ -705,13 +641,10 @@ item_move(PGItem *item, const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::reposition -// Access: Private -// Description: A lighter-weight version of recompute(), this just -// moves the thumb, assuming all other properties are -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * A lighter-weight version of recompute(), this just moves the thumb, + * assuming all other properties are unchanged. + */ void PGSliderBar:: reposition() { _needs_reposition = false; @@ -723,8 +656,8 @@ reposition() { CPT(TransformState) transform = TransformState::make_pos(pos); CPT(TransformState) orig_transform = _thumb_button->get_transform(); - // It's important not to update the transform frivolously, or - // we'll get caught in an update loop. + // It's important not to update the transform frivolously, or we'll get + // caught in an update loop. if (transform == orig_transform) { // No change. } else if (*transform != *orig_transform) { @@ -733,13 +666,10 @@ reposition() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::advance_scroll -// Access: Private -// Description: Advances the scroll bar by one unit in the left or -// right direction while the user is holding down the -// left or right scroll button. -//////////////////////////////////////////////////////////////////// +/** + * Advances the scroll bar by one unit in the left or right direction while + * the user is holding down the left or right scroll button. + */ void PGSliderBar:: advance_scroll() { if (_scroll_button_held == _left_button) { @@ -749,21 +679,17 @@ advance_scroll() { internal_set_ratio(min(_ratio + _scroll_ratio, (PN_stdfloat)1.0)); } - _next_advance_time = + _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_continued_delay; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::advance_page -// Access: Private -// Description: Advances the scroll bar by one page in the left or -// right direction while the user is holding down the -// mouse button on the track. -//////////////////////////////////////////////////////////////////// +/** + * Advances the scroll bar by one page in the left or right direction while + * the user is holding down the mouse button on the track. + */ void PGSliderBar:: advance_page() { - // Is the mouse position left or right of the current thumb - // position? + // Is the mouse position left or right of the current thumb position? LPoint3 mouse = mouse_to_local(_mouse_pos) - _thumb_start; PN_stdfloat target_ratio = mouse.dot(_axis) / _range_x; @@ -776,21 +702,19 @@ advance_page() { } internal_set_ratio(t); if (t == target_ratio) { - // We made it; begin dragging from now on until the user releases - // the mouse. + // We made it; begin dragging from now on until the user releases the + // mouse. begin_drag(); } - _next_advance_time = + _next_advance_time = ClockObject::get_global_clock()->get_frame_time() + scroll_continued_delay; } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::begin_drag -// Access: Private -// Description: Called when the user clicks down on the thumb button, -// possibly to begin dragging. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user clicks down on the thumb button, possibly to begin + * dragging. + */ void PGSliderBar:: begin_drag() { if (_needs_recompute) { @@ -803,12 +727,10 @@ begin_drag() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::continue_drag -// Access: Private -// Description: Called as the user moves the mouse while still -// dragging on the thumb button. -//////////////////////////////////////////////////////////////////// +/** + * Called as the user moves the mouse while still dragging on the thumb + * button. + */ void PGSliderBar:: continue_drag() { if (_needs_recompute) { @@ -820,11 +742,9 @@ continue_drag() { } } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBar::end_drag -// Access: Private -// Description: Called as the user releases the mouse after dragging. -//////////////////////////////////////////////////////////////////// +/** + * Called as the user releases the mouse after dragging. + */ void PGSliderBar:: end_drag() { _dragging = false; diff --git a/panda/src/pgui/pgSliderBar.h b/panda/src/pgui/pgSliderBar.h index 8cd4efe19c..c2b3a90b81 100644 --- a/panda/src/pgui/pgSliderBar.h +++ b/panda/src/pgui/pgSliderBar.h @@ -1,16 +1,15 @@ -// Filename: pgSliderBar.h -// Created by: masad (19Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBar.h + * @author masad + * @date 2004-10-19 + */ #ifndef PGSLIDERBAR_H #define PGSLIDERBAR_H @@ -22,15 +21,13 @@ #include "pgButtonNotify.h" #include "pgButton.h" -//////////////////////////////////////////////////////////////////// -// Class : PGSliderBar -// Description : This is a particular kind of PGItem that draws a -// little bar with a slider that moves from left to -// right indicating a value between the ranges. -// -// This is used as an implementation for both -// DirectSlider and for DirectScrollBar. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of PGItem that draws a little bar with a slider + * that moves from left to right indicating a value between the ranges. + * + * This is used as an implementation for both DirectSlider and for + * DirectScrollBar. + */ class EXPCL_PANDA_PGUI PGSliderBar : public PGItem, public PGButtonNotify { PUBLISHED: PGSliderBar(const string &name = ""); diff --git a/panda/src/pgui/pgSliderBarNotify.I b/panda/src/pgui/pgSliderBarNotify.I index a36b3d73d1..6c51f7f35c 100644 --- a/panda/src/pgui/pgSliderBarNotify.I +++ b/panda/src/pgui/pgSliderBarNotify.I @@ -1,23 +1,19 @@ -// Filename: pgSliderBarNotify.I -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBarNotify.I + * @author drose + * @date 2005-08-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBarNotify::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGSliderBarNotify:: PGSliderBarNotify() { } diff --git a/panda/src/pgui/pgSliderBarNotify.cxx b/panda/src/pgui/pgSliderBarNotify.cxx index 05d7ac51b7..6ddd297b68 100644 --- a/panda/src/pgui/pgSliderBarNotify.cxx +++ b/panda/src/pgui/pgSliderBarNotify.cxx @@ -1,36 +1,30 @@ -// Filename: pgSliderBarNotify.cxx -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBarNotify.cxx + * @author drose + * @date 2005-08-18 + */ #include "pgSliderBarNotify.h" #include "pgSliderBar.h" -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBarNotify::slider_bar_adjust -// Access: Protected, Virtual -// Description: Called whenever a watched PGSliderBar's value -// has been changed by the user or programmatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGSliderBar's value has been changed by the user + * or programmatically. + */ void PGSliderBarNotify:: slider_bar_adjust(PGSliderBar *) { } -//////////////////////////////////////////////////////////////////// -// Function: PGSliderBarNotify::slider_bar_set_range -// Access: Protected, Virtual -// Description: Called whenever a watched PGSliderBar's overall range -// has been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a watched PGSliderBar's overall range has been changed. + */ void PGSliderBarNotify:: slider_bar_set_range(PGSliderBar *) { } diff --git a/panda/src/pgui/pgSliderBarNotify.h b/panda/src/pgui/pgSliderBarNotify.h index d989db042a..2a05126a9d 100644 --- a/panda/src/pgui/pgSliderBarNotify.h +++ b/panda/src/pgui/pgSliderBarNotify.h @@ -1,16 +1,15 @@ -// Filename: pgSliderBarNotify.h -// Created by: drose (18Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgSliderBarNotify.h + * @author drose + * @date 2005-08-18 + */ #ifndef PGSLIDERBARNOTIFY_H #define PGSLIDERBARNOTIFY_H @@ -20,12 +19,10 @@ class PGSliderBar; -//////////////////////////////////////////////////////////////////// -// Class : PGSliderBarNotify -// Description : Objects that inherit from this class can receive -// notify messages when a slider bar moves or otherwise -// is reconfigured. -//////////////////////////////////////////////////////////////////// +/** + * Objects that inherit from this class can receive notify messages when a + * slider bar moves or otherwise is reconfigured. + */ class EXPCL_PANDA_PGUI PGSliderBarNotify : public PGItemNotify { public: INLINE PGSliderBarNotify(); diff --git a/panda/src/pgui/pgTop.I b/panda/src/pgui/pgTop.I index eb2b582af0..76bee2d409 100644 --- a/panda/src/pgui/pgTop.I +++ b/panda/src/pgui/pgTop.I @@ -1,23 +1,19 @@ -// Filename: pgTop.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgTop.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGTop::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PGTop:: PGTop(const PGTop ©) : PandaNode(copy), @@ -26,73 +22,56 @@ PGTop(const PGTop ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::get_mouse_watcher -// Access: Published -// Description: Returns the MouseWatcher pointer that the PGTop object -// registers its PG items with, or NULL if the -// MouseWatcher has not yet been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MouseWatcher pointer that the PGTop object registers its PG + * items with, or NULL if the MouseWatcher has not yet been set. + */ INLINE MouseWatcher *PGTop:: get_mouse_watcher() const { return _watcher; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::get_group -// Access: Published -// Description: Returns the MouseWatcherGroup pointer that the PGTop -// object registers its PG items with, or NULL if the -// MouseWatcher has not yet been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MouseWatcherGroup pointer that the PGTop object registers its + * PG items with, or NULL if the MouseWatcher has not yet been set. + */ INLINE MouseWatcherGroup *PGTop:: get_group() const { return _watcher_group; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::set_start_sort -// Access: Published -// Description: Specifies the sort index that is assigned during the -// traversal to the first PGItem that is discovered -// during traversal. Subsequent PGItems will be -// assigned consecutively higher sort indexes. -// -// This number is used by the MouseWatcher system to -// rank the clickable mouse regions in the same order in -// which the items are rendered, so that items on top -// will receive mouse priority. -// -// Normally, it makes the most sense to leave this -// initial value at its default value of 0, unless you -// need the PGItems to have a particular sort value with -// respect to some other objects in the scene -// (particularly with a second PGTop node). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the sort index that is assigned during the traversal to the first + * PGItem that is discovered during traversal. Subsequent PGItems will be + * assigned consecutively higher sort indexes. + * + * This number is used by the MouseWatcher system to rank the clickable mouse + * regions in the same order in which the items are rendered, so that items on + * top will receive mouse priority. + * + * Normally, it makes the most sense to leave this initial value at its + * default value of 0, unless you need the PGItems to have a particular sort + * value with respect to some other objects in the scene (particularly with a + * second PGTop node). + */ INLINE void PGTop:: set_start_sort(int start_sort) { _start_sort = start_sort; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::get_start_sort -// Access: Published -// Description: Returns the sort index that is assigned during the -// traversal to the first PGItem that is discovered -// during traversal. See set_start_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the sort index that is assigned during the traversal to the first + * PGItem that is discovered during traversal. See set_start_sort(). + */ INLINE int PGTop:: get_start_sort() const { return _start_sort; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::add_region -// Access: Public -// Description: Adds the indicated region to the set of regions in -// the group. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated region to the set of regions in the group. + */ INLINE void PGTop:: add_region(MouseWatcherRegion *region) { nassertv(_watcher_group != (PGMouseWatcherGroup *)NULL); diff --git a/panda/src/pgui/pgTop.cxx b/panda/src/pgui/pgTop.cxx index 93efa5841c..b65aaa81ac 100644 --- a/panda/src/pgui/pgTop.cxx +++ b/panda/src/pgui/pgTop.cxx @@ -1,16 +1,15 @@ -// Filename: pgTop.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgTop.cxx + * @author drose + * @date 2002-03-13 + */ #include "pgTop.h" #include "pgMouseWatcherGroup.h" @@ -21,83 +20,68 @@ TypeHandle PGTop::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGTop::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGTop:: -PGTop(const string &name) : +PGTop(const string &name) : PandaNode(name) { set_cull_callback(); _start_sort = 0; - // A PGTop node normally has an infinite bounding volume. Screw - // culling. + // A PGTop node normally has an infinite bounding volume. Screw culling. set_internal_bounds(new OmniBoundingVolume()); set_final(true); - // Also, screw state sorting. By default, everything under PGTop - // will be unsorted: rendered in scene graph order. This is closer - // to what the user wants anyway in a 2-d scene graph. + // Also, screw state sorting. By default, everything under PGTop will be + // unsorted: rendered in scene graph order. This is closer to what the user + // wants anyway in a 2-d scene graph. set_attrib(CullBinAttrib::make("unsorted", 0)); } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGTop:: ~PGTop() { set_mouse_watcher((MouseWatcher *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::make_copy -// Access: Protected, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGTop:: make_copy() const { return new PGTop(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGTop:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - // We create a new MouseWatcherGroup for the purposes of collecting - // a new set of regions visible onscreen. + // We create a new MouseWatcherGroup for the purposes of collecting a new + // set of regions visible onscreen. PT(PGMouseWatcherGroup) old_watcher_group; if (_watcher_group != (PGMouseWatcherGroup *)NULL) { _watcher_group->clear_top(this); @@ -105,21 +89,19 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { _watcher_group = new PGMouseWatcherGroup(this); } - // Now subsitute for the normal CullTraverser a special one of our - // own choosing. This just carries around a pointer back to the - // PGTop node, for the convenience of PGItems to register themselves - // as they are drawn. + // Now subsitute for the normal CullTraverser a special one of our own + // choosing. This just carries around a pointer back to the PGTop node, for + // the convenience of PGItems to register themselves as they are drawn. PGCullTraverser pg_trav(this, trav); pg_trav.local_object(); pg_trav._sort_index = _start_sort; pg_trav.traverse_below(data); pg_trav.end_traverse(); - // Now tell the watcher about the new set of regions. Strictly - // speaking, we shouldn't do this until the frame that we're about - // to render has been presented; otherwise, we may make regions - // active before they are actually visible. But no one has - // complained about this so far. + // Now tell the watcher about the new set of regions. Strictly speaking, we + // shouldn't do this until the frame that we're about to render has been + // presented; otherwise, we may make regions active before they are actually + // visible. But no one has complained about this so far. if (_watcher_group != (PGMouseWatcherGroup *)NULL) { nassertr(_watcher != (MouseWatcher *)NULL, false); _watcher->replace_group(old_watcher_group, _watcher_group); @@ -129,31 +111,23 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool PGTop:: is_renderable() const { - // We flag the PGTop as renderable, even though it technically - // doesn't have anything to render, but we do need the traverser to - // visit it every frame. + // We flag the PGTop as renderable, even though it technically doesn't have + // anything to render, but we do need the traverser to visit it every frame. return true; } -//////////////////////////////////////////////////////////////////// -// Function: PGTop::set_mouse_watcher -// Access: Published -// Description: Sets the MouseWatcher pointer that the PGTop object -// registers its PG items with. This must be set before -// the PG items are active. -//////////////////////////////////////////////////////////////////// +/** + * Sets the MouseWatcher pointer that the PGTop object registers its PG items + * with. This must be set before the PG items are active. + */ void PGTop:: set_mouse_watcher(MouseWatcher *watcher) { if (_watcher_group != (PGMouseWatcherGroup *)NULL) { diff --git a/panda/src/pgui/pgTop.h b/panda/src/pgui/pgTop.h index 2dc55bb1a7..ead4cce12f 100644 --- a/panda/src/pgui/pgTop.h +++ b/panda/src/pgui/pgTop.h @@ -1,16 +1,15 @@ -// Filename: pgTop.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgTop.h + * @author drose + * @date 2002-03-13 + */ #ifndef PGTOP_H #define PGTOP_H @@ -26,20 +25,16 @@ class GraphicsStateGuardian; class PGMouseWatcherGroup; -//////////////////////////////////////////////////////////////////// -// Class : PGTop -// Description : The "top" node of the new Panda GUI system. This -// node must be parented to the 2-d scene graph, and all -// PG objects should be parented to this node or -// somewhere below it. PG objects not parented within -// this hierarchy will not be clickable. -// -// This node begins the special traversal of the PG -// objects that registers each node within the -// MouseWatcher and forces everything to render in a -// depth-first, left-to-right order, appropriate for 2-d -// objects. -//////////////////////////////////////////////////////////////////// +/** + * The "top" node of the new Panda GUI system. This node must be parented to + * the 2-d scene graph, and all PG objects should be parented to this node or + * somewhere below it. PG objects not parented within this hierarchy will not + * be clickable. + * + * This node begins the special traversal of the PG objects that registers + * each node within the MouseWatcher and forces everything to render in a + * depth-first, left-to-right order, appropriate for 2-d objects. + */ class EXPCL_PANDA_PGUI PGTop : public PandaNode { PUBLISHED: PGTop(const string &name); @@ -70,7 +65,7 @@ private: PT(MouseWatcher) _watcher; PT(PGMouseWatcherGroup) _watcher_group; int _start_sort; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/pgui/pgVirtualFrame.I b/panda/src/pgui/pgVirtualFrame.I index 9dfaba3bd8..67732c9ede 100644 --- a/panda/src/pgui/pgVirtualFrame.I +++ b/panda/src/pgui/pgVirtualFrame.I @@ -1,102 +1,80 @@ -// Filename: pgVirtualFrame.I -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgVirtualFrame.I + * @author drose + * @date 2005-08-17 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::set_clip_frame -// Access: Published -// Description: Sets the bounding rectangle of the clip frame. -// This is the size of the small window through which we -// can see the virtual canvas. Normally, this is the -// same size as the actual frame or smaller (typically -// it is smaller by the size of the bevel, or to make -// room for scroll bars). -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the clip frame. This is the size of the + * small window through which we can see the virtual canvas. Normally, this + * is the same size as the actual frame or smaller (typically it is smaller by + * the size of the bevel, or to make room for scroll bars). + */ INLINE void PGVirtualFrame:: set_clip_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_clip_frame(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::get_clip_frame -// Access: Published -// Description: Returns the bounding rectangle of the clip frame. -// See set_clip_frame(). If has_clip_frame() is -// false, this returns the item's actual frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bounding rectangle of the clip frame. See set_clip_frame(). + * If has_clip_frame() is false, this returns the item's actual frame. + */ INLINE const LVecBase4 &PGVirtualFrame:: get_clip_frame() const { LightReMutexHolder holder(_lock); return _has_clip_frame ? _clip_frame : get_frame(); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::has_clip_frame -// Access: Published -// Description: Returns true if the clip frame has been set; see -// set_clip_frame(). If it has not been set, objects in -// the virtual frame will not be clipped. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the clip frame has been set; see set_clip_frame(). If it + * has not been set, objects in the virtual frame will not be clipped. + */ INLINE bool PGVirtualFrame:: has_clip_frame() const { LightReMutexHolder holder(_lock); return _has_clip_frame; } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::set_canvas_transform -// Access: Published -// Description: Changes the transform of the virtual canvas. This -// transform is applied to all child nodes of the -// canvas_node. -//////////////////////////////////////////////////////////////////// +/** + * Changes the transform of the virtual canvas. This transform is applied to + * all child nodes of the canvas_node. + */ INLINE void PGVirtualFrame:: set_canvas_transform(const TransformState *transform) { LightReMutexHolder holder(_lock); _canvas_node->set_transform(transform); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::get_canvas_transform -// Access: Published -// Description: Returns the transform of the virtual canvas. This -// transform is applied to all child nodes of the -// canvas_node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform of the virtual canvas. This transform is applied to + * all child nodes of the canvas_node. + */ INLINE const TransformState *PGVirtualFrame:: get_canvas_transform() const { LightReMutexHolder holder(_lock); return _canvas_node->get_transform(); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::get_canvas_node -// Access: Published -// Description: Returns the special node that holds all of the -// children that appear in the virtual canvas. -//////////////////////////////////////////////////////////////////// +/** + * Returns the special node that holds all of the children that appear in the + * virtual canvas. + */ INLINE PandaNode *PGVirtualFrame:: get_canvas_node() const { LightReMutexHolder holder(_lock); return _canvas_node; } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::get_canvas_parent -// Access: Published -// Description: Returns the parent node of the canvas_node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the parent node of the canvas_node. + */ INLINE PandaNode *PGVirtualFrame:: get_canvas_parent() const { LightReMutexHolder holder(_lock); diff --git a/panda/src/pgui/pgVirtualFrame.cxx b/panda/src/pgui/pgVirtualFrame.cxx index eb728f471b..b6a6d195b0 100644 --- a/panda/src/pgui/pgVirtualFrame.cxx +++ b/panda/src/pgui/pgVirtualFrame.cxx @@ -1,16 +1,15 @@ -// Filename: pgVirtualFrame.cxx -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgVirtualFrame.cxx + * @author drose + * @date 2005-08-17 + */ #include "pgVirtualFrame.h" #include "scissorEffect.h" @@ -18,11 +17,9 @@ TypeHandle PGVirtualFrame::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGVirtualFrame:: PGVirtualFrame(const string &name) : PGItem(name) { @@ -32,20 +29,16 @@ PGVirtualFrame(const string &name) : PGItem(name) setup_child_nodes(); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGVirtualFrame:: ~PGVirtualFrame() { } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGVirtualFrame:: PGVirtualFrame(const PGVirtualFrame ©) : PGItem(copy), @@ -62,35 +55,27 @@ PGVirtualFrame(const PGVirtualFrame ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGVirtualFrame:: make_copy() const { LightReMutexHolder holder(_lock); return new PGVirtualFrame(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::r_copy_children -// Access: Protected, Virtual -// Description: This is called by r_copy_subgraph(); the copy has -// already been made of this particular node (and this -// is the copy); this function's job is to copy all of -// the children from the original. -// -// Note that it includes the parameter inst_map, which -// is a map type, and is not (and cannot be) exported -// from PANDA.DLL. Thus, any derivative of PandaNode -// that is not also a member of PANDA.DLL *cannot* -// access this map, and probably should not even -// override this function. -//////////////////////////////////////////////////////////////////// +/** + * This is called by r_copy_subgraph(); the copy has already been made of this + * particular node (and this is the copy); this function's job is to copy all + * of the children from the original. + * + * Note that it includes the parameter inst_map, which is a map type, and is + * not (and cannot be) exported from PANDA.DLL. Thus, any derivative of + * PandaNode that is not also a member of PANDA.DLL *cannot* access this map, + * and probably should not even override this function. + */ void PGVirtualFrame:: r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, Thread *current_thread) { @@ -122,13 +107,10 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, clear_clip_frame(); } } - -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::setup -// Access: Published -// Description: Creates a PGVirtualFrame with the indicated -// dimensions. -//////////////////////////////////////////////////////////////////// + +/** + * Creates a PGVirtualFrame with the indicated dimensions. + */ void PGVirtualFrame:: setup(PN_stdfloat width, PN_stdfloat height) { LightReMutexHolder holder(_lock); @@ -150,16 +132,12 @@ setup(PN_stdfloat width, PN_stdfloat height) { bevel, height - 2 * bevel); } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::set_clip_frame -// Access: Published -// Description: Sets the bounding rectangle of the clip frame. -// This is the size of the small window through which we -// can see the virtual canvas. Normally, this is the -// same size as the actual frame or smaller (typically -// it is smaller by the size of the bevel, or to make -// room for scroll bars). -//////////////////////////////////////////////////////////////////// +/** + * Sets the bounding rectangle of the clip frame. This is the size of the + * small window through which we can see the virtual canvas. Normally, this + * is the same size as the actual frame or smaller (typically it is smaller by + * the size of the bevel, or to make room for scroll bars). + */ void PGVirtualFrame:: set_clip_frame(const LVecBase4 &frame) { LightReMutexHolder holder(_lock); @@ -172,44 +150,36 @@ set_clip_frame(const LVecBase4 &frame) { LPoint3(_clip_frame[1], _clip_frame[2], _clip_frame[2]), LPoint3(_clip_frame[1], _clip_frame[3], _clip_frame[3]), LPoint3(_clip_frame[0], _clip_frame[3], _clip_frame[3])); - + _canvas_parent->set_effect(scissor_effect); clip_frame_changed(); } } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::clear_clip_frame -// Access: Published -// Description: Removes the clip frame from the item. This -// disables clipping. -//////////////////////////////////////////////////////////////////// +/** + * Removes the clip frame from the item. This disables clipping. + */ void PGVirtualFrame:: clear_clip_frame() { LightReMutexHolder holder(_lock); if (_has_clip_frame) { _has_clip_frame = false; - + _canvas_parent->clear_effect(ScissorEffect::get_class_type()); clip_frame_changed(); } } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::clip_frame_changed -// Access: Protected, Virtual -// Description: Called when the user changes the clip_frame size. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user changes the clip_frame size. + */ void PGVirtualFrame:: clip_frame_changed() { } -//////////////////////////////////////////////////////////////////// -// Function: PGVirtualFrame::setup_child_nodes -// Access: Private -// Description: Creates the special canvas_node and canvas_parent -// for this object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the special canvas_node and canvas_parent for this object. + */ void PGVirtualFrame:: setup_child_nodes() { _canvas_parent = new ModelNode("canvas_parent"); diff --git a/panda/src/pgui/pgVirtualFrame.h b/panda/src/pgui/pgVirtualFrame.h index 803fb12b8e..f0f90d85d3 100644 --- a/panda/src/pgui/pgVirtualFrame.h +++ b/panda/src/pgui/pgVirtualFrame.h @@ -1,16 +1,15 @@ -// Filename: pgVirtualFrame.h -// Created by: drose (17Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgVirtualFrame.h + * @author drose + * @date 2005-08-17 + */ #ifndef PGVIRTUALFRAME_H #define PGVIRTUALFRAME_H @@ -22,31 +21,25 @@ class TransformState; -//////////////////////////////////////////////////////////////////// -// Class : PGVirtualFrame -// Description : This represents a frame that is rendered as a window -// onto another (possibly much larger) canvas. You can -// only see the portion of the canvas that is below the -// window at any given time. -// -// This works simply by automatically defining a scissor -// effect to be applied to a special child node, called -// the canvas_node, of the PGVirtualFrame node. Every -// object that is parented to the canvas_node will be -// clipped by the scissor effect. Also, you can modify -// the canvas_transform through convenience methods -// here, which actually modifies the transform on the -// canvas_node. -// -// The net effect is that the virtual canvas is -// arbitrarily large, and we can peek at it through the -// scissor region, and scroll through different parts of -// it by modifying the canvas_transform. -// -// See PGScrollFrame for a specialization of this class -// that handles the traditional scrolling canvas, with -// scroll bars. -//////////////////////////////////////////////////////////////////// +/** + * This represents a frame that is rendered as a window onto another (possibly + * much larger) canvas. You can only see the portion of the canvas that is + * below the window at any given time. + * + * This works simply by automatically defining a scissor effect to be applied + * to a special child node, called the canvas_node, of the PGVirtualFrame + * node. Every object that is parented to the canvas_node will be clipped by + * the scissor effect. Also, you can modify the canvas_transform through + * convenience methods here, which actually modifies the transform on the + * canvas_node. + * + * The net effect is that the virtual canvas is arbitrarily large, and we can + * peek at it through the scissor region, and scroll through different parts + * of it by modifying the canvas_transform. + * + * See PGScrollFrame for a specialization of this class that handles the + * traditional scrolling canvas, with scroll bars. + */ class EXPCL_PANDA_PGUI PGVirtualFrame : public PGItem { PUBLISHED: PGVirtualFrame(const string &name = ""); diff --git a/panda/src/pgui/pgWaitBar.I b/panda/src/pgui/pgWaitBar.I index b598272450..c23eea7183 100644 --- a/panda/src/pgui/pgWaitBar.I +++ b/panda/src/pgui/pgWaitBar.I @@ -1,96 +1,80 @@ -// Filename: pgWaitBar.I -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgWaitBar.I + * @author drose + * @date 2002-03-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::set_range -// Access: Published -// Description: Sets the value at which the WaitBar indicates 100%. -//////////////////////////////////////////////////////////////////// -INLINE void PGWaitBar:: +/** + * Sets the value at which the WaitBar indicates 100%. + */ +INLINE void PGWaitBar:: set_range(PN_stdfloat range) { LightReMutexHolder holder(_lock); _range = range; _bar_state = -1; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::get_range -// Access: Published -// Description: Returns the value at which the WaitBar indicates 100%. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGWaitBar:: +/** + * Returns the value at which the WaitBar indicates 100%. + */ +INLINE PN_stdfloat PGWaitBar:: get_range() const { LightReMutexHolder holder(_lock); return _range; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::set_value -// Access: Published -// Description: Sets the current value of the bar. This should range -// between 0 and get_range(). -//////////////////////////////////////////////////////////////////// -INLINE void PGWaitBar:: +/** + * Sets the current value of the bar. This should range between 0 and + * get_range(). + */ +INLINE void PGWaitBar:: set_value(PN_stdfloat value) { LightReMutexHolder holder(_lock); _value = value; _bar_state = -1; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::get_value -// Access: Published -// Description: Returns the current value of the bar. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGWaitBar:: +/** + * Returns the current value of the bar. + */ +INLINE PN_stdfloat PGWaitBar:: get_value() const { LightReMutexHolder holder(_lock); return _value; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::get_percent -// Access: Published -// Description: Returns the percentage complete. -//////////////////////////////////////////////////////////////////// -INLINE PN_stdfloat PGWaitBar:: +/** + * Returns the percentage complete. + */ +INLINE PN_stdfloat PGWaitBar:: get_percent() const { LightReMutexHolder holder(_lock); return (_value / _range) * 100.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::set_bar_style -// Access: Published -// Description: Sets the kind of frame that is drawn on top of the -// WaitBar to represent the amount completed. -//////////////////////////////////////////////////////////////////// -INLINE void PGWaitBar:: +/** + * Sets the kind of frame that is drawn on top of the WaitBar to represent the + * amount completed. + */ +INLINE void PGWaitBar:: set_bar_style(const PGFrameStyle &style) { LightReMutexHolder holder(_lock); _bar_style = style; _bar_state = -1; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::get_bar_style -// Access: Published -// Description: Returns the kind of frame that is drawn on top of the -// WaitBar to represent the amount completed. -//////////////////////////////////////////////////////////////////// -INLINE PGFrameStyle PGWaitBar:: +/** + * Returns the kind of frame that is drawn on top of the WaitBar to represent + * the amount completed. + */ +INLINE PGFrameStyle PGWaitBar:: get_bar_style() const { LightReMutexHolder holder(_lock); return _bar_style; diff --git a/panda/src/pgui/pgWaitBar.cxx b/panda/src/pgui/pgWaitBar.cxx index 55d8872d55..2f6f50a557 100644 --- a/panda/src/pgui/pgWaitBar.cxx +++ b/panda/src/pgui/pgWaitBar.cxx @@ -1,16 +1,15 @@ -// Filename: pgWaitBar.cxx -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgWaitBar.cxx + * @author drose + * @date 2002-03-14 + */ #include "pgWaitBar.h" #include "pgMouseWatcherParameter.h" @@ -19,11 +18,9 @@ TypeHandle PGWaitBar::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGWaitBar:: PGWaitBar(const string &name) : PGItem(name) { @@ -34,20 +31,16 @@ PGWaitBar(const string &name) : PGItem(name) _bar_state = -1; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGWaitBar:: ~PGWaitBar() { } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PGWaitBar:: PGWaitBar(const PGWaitBar ©) : PGItem(copy), @@ -57,45 +50,35 @@ PGWaitBar(const PGWaitBar ©) : _bar_state = -1; } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *PGWaitBar:: make_copy() const { LightReMutexHolder holder(_lock); return new PGWaitBar(*this); } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool PGWaitBar:: cull_callback(CullTraverser *trav, CullTraverserData &data) { LightReMutexHolder holder(_lock); @@ -103,12 +86,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return PGItem::cull_callback(trav, data); } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::setup -// Access: Published -// Description: Creates a PGWaitBar with the indicated dimensions, -// with the indicated maximum range. -//////////////////////////////////////////////////////////////////// +/** + * Creates a PGWaitBar with the indicated dimensions, with the indicated + * maximum range. + */ void PGWaitBar:: setup(PN_stdfloat width, PN_stdfloat height, PN_stdfloat range) { LightReMutexHolder holder(_lock); @@ -131,19 +112,17 @@ setup(PN_stdfloat width, PN_stdfloat height, PN_stdfloat range) { set_bar_style(style); } -//////////////////////////////////////////////////////////////////// -// Function: PGWaitBar::update -// Access: Private -// Description: Computes the appropriate size of the bar frame -// according to the percentage completed. -//////////////////////////////////////////////////////////////////// -void PGWaitBar:: +/** + * Computes the appropriate size of the bar frame according to the percentage + * completed. + */ +void PGWaitBar:: update() { LightReMutexHolder holder(_lock); int state = get_state(); - // If the bar was last drawn in this state and is still current, we - // don't have to draw it again. + // If the bar was last drawn in this state and is still current, we don't + // have to draw it again. if (_bar_state == state) { return; } @@ -170,7 +149,7 @@ update() { PN_stdfloat frac = _value / _range; frac = max(min(frac, (PN_stdfloat)1.0), (PN_stdfloat)0.0); bar_frame[1] = bar_frame[0] + frac * (bar_frame[1] - bar_frame[0]); - + _bar = _bar_style.generate_into(root, bar_frame, 1); } diff --git a/panda/src/pgui/pgWaitBar.h b/panda/src/pgui/pgWaitBar.h index 41603ab551..c4a5359be5 100644 --- a/panda/src/pgui/pgWaitBar.h +++ b/panda/src/pgui/pgWaitBar.h @@ -1,16 +1,15 @@ -// Filename: pgWaitBar.h -// Created by: drose (14Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgWaitBar.h + * @author drose + * @date 2002-03-14 + */ #ifndef PGWAITBAR_H #define PGWAITBAR_H @@ -19,13 +18,11 @@ #include "pgItem.h" -//////////////////////////////////////////////////////////////////// -// Class : PGWaitBar -// Description : This is a particular kind of PGItem that draws a -// little bar that fills from left to right to indicate -// a slow process gradually completing, like a -// traditional "wait, loading" bar. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular kind of PGItem that draws a little bar that fills from + * left to right to indicate a slow process gradually completing, like a + * traditional "wait, loading" bar. + */ class EXPCL_PANDA_PGUI PGWaitBar : public PGItem { PUBLISHED: PGWaitBar(const string &name = ""); diff --git a/panda/src/pgui/test_pgentry.cxx b/panda/src/pgui/test_pgentry.cxx index 13a1161c7e..fb7440c6b4 100644 --- a/panda/src/pgui/test_pgentry.cxx +++ b/panda/src/pgui/test_pgentry.cxx @@ -1,16 +1,15 @@ -// Filename: test_pgentry.cxx -// Created by: drose (30Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_pgentry.cxx + * @author drose + * @date 2004-04-30 + */ #include "pandaFramework.h" #include "pgEntry.h" @@ -34,7 +33,7 @@ main(int argc, char *argv[]) { entry->setup(10, 4); - framework.define_key("escape", "close window", + framework.define_key("escape", "close window", PandaFramework::event_esc, &framework); framework.main_loop(); diff --git a/panda/src/physics/actorNode.I b/panda/src/physics/actorNode.I index c631f94d54..4f430a8ee7 100644 --- a/panda/src/physics/actorNode.I +++ b/panda/src/physics/actorNode.I @@ -1,32 +1,27 @@ -// Filename: actorNode.I -// Created by: charles (07Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file actorNode.I + * @author charles + * @date 2000-08-07 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_contact_vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ActorNode:: set_contact_vector(const LVector3 &contact_vector) { _contact_vector=contact_vector; } -//////////////////////////////////////////////////////////////////// -// Function: get_contact_vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVector3 &ActorNode:: get_contact_vector() const { return _contact_vector; diff --git a/panda/src/physics/actorNode.cxx b/panda/src/physics/actorNode.cxx index 3a431e5f04..e77e8e5ca5 100644 --- a/panda/src/physics/actorNode.cxx +++ b/panda/src/physics/actorNode.cxx @@ -1,16 +1,15 @@ -// Filename: actorNode.cxx -// Created by: charles (07Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file actorNode.cxx + * @author charles + * @date 2000-08-07 + */ #include "actorNode.h" #include "config_physics.h" @@ -20,11 +19,9 @@ TypeHandle ActorNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ActorNode -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ ActorNode:: ActorNode(const string &name) : PhysicalNode(name) { @@ -39,11 +36,9 @@ ActorNode(const string &name) : _transform_limit = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: ActorNode -// Access: Public -// Description: Copy Constructor. -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor. + */ ActorNode:: ActorNode(const ActorNode ©) : PhysicalNode(copy) { @@ -53,22 +48,17 @@ ActorNode(const ActorNode ©) : _transform_limit = copy._transform_limit; } -//////////////////////////////////////////////////////////////////// -// Function: ~ActorNode -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ActorNode:: ~ActorNode() { } -//////////////////////////////////////////////////////////////////// -// Function: update_transform -// Access: Public -// Description: this sets the transform generated by the contained -// Physical, moving the node and subsequent geometry. -// i.e. copy from PhysicsObject to PandaNode -//////////////////////////////////////////////////////////////////// +/** + * this sets the transform generated by the contained Physical, moving the + * node and subsequent geometry. i.e. copy from PhysicsObject to PandaNode + */ void ActorNode:: update_transform() { LMatrix4 lcs = _mass_center->get_lcs(); @@ -79,13 +69,11 @@ update_transform() { _ok_to_callback = true; } -//////////////////////////////////////////////////////////////////// -// Function: test_transform -// Access: Private -// Description: this tests the transform to make sure it's within -// the specified limits. It's done so we can assert -// to see when an invalid transform is being applied. -//////////////////////////////////////////////////////////////////// +/** + * this tests the transform to make sure it's within the specified limits. + * It's done so we can assert to see when an invalid transform is being + * applied. + */ void ActorNode:: test_transform(const TransformState *ts) const { LPoint3 pos(ts->get_pos()); @@ -97,14 +85,11 @@ test_transform(const TransformState *ts) const { nassertv(pos[2] > -_transform_limit); } -//////////////////////////////////////////////////////////////////// -// Function: transform_changed -// Access: Private, Virtual -// Description: node hook. This function handles outside -// (non-physics) actions on the actor -// and updates the internal representation of the node. -// i.e. copy from PandaNode to PhysicsObject -//////////////////////////////////////////////////////////////////// +/** + * node hook. This function handles outside (non-physics) actions on the + * actor and updates the internal representation of the node. i.e. copy from + * PandaNode to PhysicsObject + */ void ActorNode:: transform_changed() { PandaNode::transform_changed(); @@ -131,12 +116,9 @@ transform_changed() { } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ActorNode:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/actorNode.h b/panda/src/physics/actorNode.h index b64ade98aa..2f3690543a 100644 --- a/panda/src/physics/actorNode.h +++ b/panda/src/physics/actorNode.h @@ -1,16 +1,15 @@ -// Filename: actorNode.h -// Created by: charles (07Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file actorNode.h + * @author charles + * @date 2000-08-07 + */ #ifndef ACTORNODE_H #define ACTORNODE_H @@ -18,30 +17,27 @@ #include "pandabase.h" #include "physicalNode.h" -//////////////////////////////////////////////////////////////////// -// Class : ActorNode -// Description : Like a physical node, but with a little more. The -// actornode assumes responsibility for its own -// transform, and changes in its own PhysicsObject will -// be reflected as transforms. This relation goes both -// ways; changes in the transform will update the -// object's position (shoves). -//////////////////////////////////////////////////////////////////// +/** + * Like a physical node, but with a little more. The actornode assumes + * responsibility for its own transform, and changes in its own PhysicsObject + * will be reflected as transforms. This relation goes both ways; changes in + * the transform will update the object's position (shoves). + */ class EXPCL_PANDAPHYSICS ActorNode : public PhysicalNode { PUBLISHED: ActorNode(const string &name = ""); ActorNode(const ActorNode ©); virtual ~ActorNode(); - + PhysicsObject *get_physics_object() { return _mass_center; } - + void set_contact_vector(const LVector3 &contact_vector); const LVector3 &get_contact_vector() const; - // update the parent scene graph node with PhysicsObject information - // i.e. copy from PhysicsObject to PandaNode + // update the parent scene graph node with PhysicsObject information i.e. + // copy from PhysicsObject to PandaNode void update_transform(); - + void set_transform_limit(PN_stdfloat limit) { _transform_limit = limit; }; virtual void write(ostream &out, unsigned int indent=0) const; @@ -51,8 +47,8 @@ private: bool _ok_to_callback; PN_stdfloat _transform_limit; - // node hook if the client changes the node's transform. - // i.e. copy from PandaNode to PhysicsObject + // node hook if the client changes the node's transform. i.e. copy from + // PandaNode to PhysicsObject virtual void transform_changed(); void test_transform(const TransformState *ts) const; diff --git a/panda/src/physics/angularEulerIntegrator.cxx b/panda/src/physics/angularEulerIntegrator.cxx index 10ac482008..9900223d4c 100644 --- a/panda/src/physics/angularEulerIntegrator.cxx +++ b/panda/src/physics/angularEulerIntegrator.cxx @@ -1,66 +1,56 @@ -// Filename: angularEulerIntegrator.cxx -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularEulerIntegrator.cxx + * @author charles + * @date 2000-08-09 + */ #include "angularEulerIntegrator.h" #include "forceNode.h" #include "physicalNode.h" #include "config_physics.h" -//////////////////////////////////////////////////////////////////// -// Function: AngularEulerIntegrator -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ AngularEulerIntegrator:: AngularEulerIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: AngularEulerIntegrator -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ AngularEulerIntegrator:: ~AngularEulerIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: Integrate -// Access: Public -// Description: Integrate a step of motion (based on dt) by -// applying every force in force_vec to every object -// in obj_vec. -//////////////////////////////////////////////////////////////////// +/** + * Integrate a step of motion (based on dt) by applying every force in + * force_vec to every object in obj_vec. + */ void AngularEulerIntegrator:: child_integrate(Physical *physical, AngularForceVector& forces, PN_stdfloat dt) { - // Loop through each object in the set. This processing occurs in - // O(pf) time, where p is the number of physical objects and f is - // the number of forces. Unfortunately, no precomputation of forces - // can occur, as each force is possibly contingent on such things as - // the position and velocity of each physicsobject in the set. - // Accordingly, we have to grunt our way through each one. wrt - // caching of the xform matrix should help. + // Loop through each object in the set. This processing occurs in O(pf) + // time, where p is the number of physical objects and f is the number of + // forces. Unfortunately, no precomputation of forces can occur, as each + // force is possibly contingent on such things as the position and velocity + // of each physicsobject in the set. Accordingly, we have to grunt our way + // through each one. wrt caching of the xform matrix should help. PhysicsObject::Vector::const_iterator current_object_iter; current_object_iter = physical->get_object_vector().begin(); for (; current_object_iter != physical->get_object_vector().end(); ++current_object_iter) { PhysicsObject *current_object = *current_object_iter; - // bail out if this object doesn't exist or doesn't want to be - // processed. + // bail out if this object doesn't exist or doesn't want to be processed. if (current_object == (PhysicsObject *) NULL) { continue; } @@ -78,7 +68,7 @@ child_integrate(Physical *physical, // global forces f_cur = forces.begin(); - // unsigned int index = 0; + // unsigned int index = 0; for (; f_cur != forces.end(); ++f_cur) { AngularForce *cur_force = *f_cur; @@ -105,8 +95,8 @@ child_integrate(Physical *physical, f = cur_force->get_quat(current_object); - // tally it into the accumulation quaternion - // i.e. orientation * f * orientation.conjugate() + // tally it into the accumulation quaternion i.e. orientation * f * + // orientation.conjugate() accum_quat += orientation.xform(f); } @@ -130,16 +120,15 @@ child_integrate(Physical *physical, current_object->set_rotation(rot_quat); } #else - //accum_quat*=viscosityDamper; - //LOrientation orientation = current_object->get_orientation(); + // accum_quat*=viscosityDamper; LOrientation orientation = + // current_object->get_orientation(); - //accum_quat.normalize(); - // x = x + v * t + 0.5 * a * t * t + // accum_quat.normalize(); x = x + v * t + 0.5 * a * t * t orientation = orientation * ((rot_quat * dt) * (accum_quat * (0.5 * dt * dt))); // v = v + a * t rot_quat = rot_quat + (accum_quat * dt); - //if (rot_quat.normalize()) { + // if (rot_quat.normalize()) { if (orientation.normalize() && rot_quat.normalize()) { // and write the results back. current_object->set_orientation(orientation); @@ -149,12 +138,9 @@ child_integrate(Physical *physical, } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularEulerIntegrator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -162,12 +148,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularEulerIntegrator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/angularEulerIntegrator.h b/panda/src/physics/angularEulerIntegrator.h index 6c43dbc8bc..5e342b10f9 100644 --- a/panda/src/physics/angularEulerIntegrator.h +++ b/panda/src/physics/angularEulerIntegrator.h @@ -1,32 +1,30 @@ -// Filename: angularEulerIntegrator.h -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularEulerIntegrator.h + * @author charles + * @date 2000-08-09 + */ #ifndef ANGULAREULERINTEGRATOR_H #define ANGULAREULERINTEGRATOR_H #include "angularIntegrator.h" -//////////////////////////////////////////////////////////////////// -// Class : AngularEulerIntegrator -// Description : Performs Euler integration on a vector of -// physically modelable objects given a quantum dt. -//////////////////////////////////////////////////////////////////// +/** + * Performs Euler integration on a vector of physically modelable objects + * given a quantum dt. + */ class EXPCL_PANDAPHYSICS AngularEulerIntegrator : public AngularIntegrator { PUBLISHED: AngularEulerIntegrator(); virtual ~AngularEulerIntegrator(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/angularForce.cxx b/panda/src/physics/angularForce.cxx index ca13448a65..722a4611ab 100644 --- a/panda/src/physics/angularForce.cxx +++ b/panda/src/physics/angularForce.cxx @@ -1,77 +1,63 @@ -// Filename: angularForce.cxx -// Created by: charles (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularForce.cxx + * @author charles + * @date 2000-08-08 + */ #include "angularForce.h" TypeHandle AngularForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AngularForce -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ AngularForce:: AngularForce() : BaseForce() { } -//////////////////////////////////////////////////////////////////// -// Function: AngularForce -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ AngularForce:: AngularForce(const AngularForce ©) : BaseForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~AngularForce -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ AngularForce:: ~AngularForce() { } -//////////////////////////////////////////////////////////////////// -// Function: get_quat -// Access: Public -// Description: access query -//////////////////////////////////////////////////////////////////// +/** + * access query + */ LRotation AngularForce:: get_quat(const PhysicsObject *po) { LRotation v = get_child_quat(po); return v; } -//////////////////////////////////////////////////////////////////// -// Function: is_linear -// Access: Public -// Description: access query -//////////////////////////////////////////////////////////////////// +/** + * access query + */ bool AngularForce:: is_linear() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -79,12 +65,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/angularForce.h b/panda/src/physics/angularForce.h index 3a66db58d4..7ab04de816 100644 --- a/panda/src/physics/angularForce.h +++ b/panda/src/physics/angularForce.h @@ -1,26 +1,24 @@ -// Filename: angularForce.h -// Created by: charles (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularForce.h + * @author charles + * @date 2000-08-08 + */ #ifndef ANGULARFORCE_H #define ANGULARFORCE_H #include "baseForce.h" -//////////////////////////////////////////////////////////////////// -// Class : AngularForce -// Description : pure virtual parent of all quat-based forces. -//////////////////////////////////////////////////////////////////// +/** + * pure virtual parent of all quat-based forces. + */ class EXPCL_PANDAPHYSICS AngularForce : public BaseForce { PUBLISHED: virtual ~AngularForce(); @@ -28,7 +26,7 @@ PUBLISHED: virtual AngularForce *make_copy() const = 0; LRotation get_quat(const PhysicsObject *po); virtual bool is_linear() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/angularIntegrator.cxx b/panda/src/physics/angularIntegrator.cxx index c0f6b53d79..89db0a040e 100644 --- a/panda/src/physics/angularIntegrator.cxx +++ b/panda/src/physics/angularIntegrator.cxx @@ -1,49 +1,42 @@ -// Filename: angularIntegrator.cxx -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularIntegrator.cxx + * @author charles + * @date 2000-08-09 + */ #include "angularIntegrator.h" ConfigVariableDouble AngularIntegrator::_max_angular_dt ("default_max_angular_dt", 1.0f / 30.0f); -//////////////////////////////////////////////////////////////////// -// Function: AngularIntegrator -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ AngularIntegrator:: AngularIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: ~AngularIntegrator -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ AngularIntegrator:: ~AngularIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: Integrate -// Access: Public -// Description: high-level integration. API. -//////////////////////////////////////////////////////////////////// +/** + * high-level integration. API. + */ void AngularIntegrator:: integrate(Physical *physical, AngularForceVector& forces, PN_stdfloat dt) { - // intercept in case we want to censor/adjust values + // intercept in case we want to censoradjust values if (dt > _max_angular_dt) { dt = _max_angular_dt; } @@ -52,12 +45,9 @@ integrate(Physical *physical, AngularForceVector& forces, child_integrate(physical, forces, dt); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularIntegrator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -65,12 +55,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularIntegrator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/angularIntegrator.h b/panda/src/physics/angularIntegrator.h index f8fa857b9c..4ee8d41009 100644 --- a/panda/src/physics/angularIntegrator.h +++ b/panda/src/physics/angularIntegrator.h @@ -1,16 +1,15 @@ -// Filename: angularIntegrator.h -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularIntegrator.h + * @author charles + * @date 2000-08-09 + */ #ifndef ANGULARINTEGRATOR_H #define ANGULARINTEGRATOR_H @@ -19,12 +18,10 @@ #include "angularForce.h" #include "configVariableDouble.h" -//////////////////////////////////////////////////////////////////// -// Class : BaseAngularIntegrator -// Description : Pure virtual base class for physical modeling. -// Takes physically modelable objects and applies -// forces to them. -//////////////////////////////////////////////////////////////////// +/** + * Pure virtual base class for physical modeling. Takes physically modelable + * objects and applies forces to them. + */ class EXPCL_PANDAPHYSICS AngularIntegrator : public BaseIntegrator { PUBLISHED: virtual ~AngularIntegrator(); @@ -33,7 +30,7 @@ public: void integrate(Physical *physical, AngularForceVector &forces, PN_stdfloat dt); -PUBLISHED: +PUBLISHED: virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; @@ -43,8 +40,8 @@ protected: private: static ConfigVariableDouble _max_angular_dt; - // this allows baseAngularIntegrator to censor/modify data that the - // actual integration function receives. + // this allows baseAngularIntegrator to censormodify data that the actual + // integration function receives. virtual void child_integrate(Physical *physical, AngularForceVector &forces, PN_stdfloat dt) = 0; }; diff --git a/panda/src/physics/angularVectorForce.I b/panda/src/physics/angularVectorForce.I index 7d2eb4db48..dee0569658 100644 --- a/panda/src/physics/angularVectorForce.I +++ b/panda/src/physics/angularVectorForce.I @@ -1,39 +1,35 @@ -// Filename: angularVectorForce.I -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularVectorForce.I + * @author charles + * @date 2000-08-09 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_quat -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void AngularVectorForce:: set_quat(const LRotation &v) { _fvec = v; } -//////////////////////////////////////////////////////////////////// -// Function: set_hpr -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void AngularVectorForce:: set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) { _fvec.set_hpr(LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: get_local_quat -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE LRotation AngularVectorForce:: get_local_quat() const { return _fvec; diff --git a/panda/src/physics/angularVectorForce.cxx b/panda/src/physics/angularVectorForce.cxx index 60e46d98f2..d9ab88b054 100644 --- a/panda/src/physics/angularVectorForce.cxx +++ b/panda/src/physics/angularVectorForce.cxx @@ -1,88 +1,72 @@ -// Filename: angularVectorForce.cxx -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularVectorForce.cxx + * @author charles + * @date 2000-08-09 + */ #include "angularVectorForce.h" TypeHandle AngularVectorForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AngularVectorForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ AngularVectorForce:: AngularVectorForce(const LRotation &vec) : AngularForce(), _fvec(vec) { } -//////////////////////////////////////////////////////////////////// -// Function: AngularVectorForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ AngularVectorForce:: AngularVectorForce(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r) : AngularForce() { _fvec.set_hpr(LVecBase3(h, p, r)); } -//////////////////////////////////////////////////////////////////// -// Function: AngularVectorForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ AngularVectorForce:: AngularVectorForce(const AngularVectorForce ©) : AngularForce(copy) { _fvec = copy._fvec; } -//////////////////////////////////////////////////////////////////// -// Function: ~AngularVectorForce -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ AngularVectorForce:: ~AngularVectorForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Private, Virtual -// Description: dynamic copier -//////////////////////////////////////////////////////////////////// +/** + * dynamic copier + */ AngularForce *AngularVectorForce:: make_copy() const { return new AngularVectorForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_quat -// Access: Private, Virtual -// Description: query -//////////////////////////////////////////////////////////////////// +/** + * query + */ LRotation AngularVectorForce:: get_child_quat(const PhysicsObject *) { return _fvec; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularVectorForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -90,12 +74,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void AngularVectorForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/angularVectorForce.h b/panda/src/physics/angularVectorForce.h index 5ea41be148..edb2cf8994 100644 --- a/panda/src/physics/angularVectorForce.h +++ b/panda/src/physics/angularVectorForce.h @@ -1,27 +1,25 @@ -// Filename: angularVectorForce.h -// Created by: charles (09Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file angularVectorForce.h + * @author charles + * @date 2000-08-09 + */ #ifndef ANGULARVECTORFORCE_H #define ANGULARVECTORFORCE_H #include "angularForce.h" -//////////////////////////////////////////////////////////////////// -// Class : AngularVectorForce -// Description : a simple directed torque force, the angular -// equivalent of simple vector force. -//////////////////////////////////////////////////////////////////// +/** + * a simple directed torque force, the angular equivalent of simple vector + * force. + */ class EXPCL_PANDAPHYSICS AngularVectorForce : public AngularForce { PUBLISHED: AngularVectorForce(const LRotation& quat); @@ -32,7 +30,7 @@ PUBLISHED: INLINE void set_quat(const LRotation& quat); INLINE void set_hpr(PN_stdfloat h, PN_stdfloat p, PN_stdfloat r); INLINE LRotation get_local_quat() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/baseForce.I b/panda/src/physics/baseForce.I index 66f47f681a..8c2cf1e85c 100644 --- a/panda/src/physics/baseForce.I +++ b/panda/src/physics/baseForce.I @@ -1,48 +1,43 @@ -// Filename: baseForce.I -// Created by: charles (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseForce.I + * @author charles + * @date 2000-08-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: get_force_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE ForceNode *BaseForce:: get_force_node() const { return _force_node; } -//////////////////////////////////////////////////////////////////// -// Function: get_force_node_path -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE NodePath BaseForce:: get_force_node_path() const { return _force_node_path; } -//////////////////////////////////////////////////////////////////// -// Function: set_active -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void BaseForce:: set_active(bool active) { _active = active; } -//////////////////////////////////////////////////////////////////// -// Function: get_active -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool BaseForce:: get_active() const { return _active; diff --git a/panda/src/physics/baseForce.cxx b/panda/src/physics/baseForce.cxx index 8f2fc41db2..7a7ba6d71b 100644 --- a/panda/src/physics/baseForce.cxx +++ b/panda/src/physics/baseForce.cxx @@ -1,27 +1,24 @@ -// Filename: baseForce.cxx -// Created by: charles (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseForce.cxx + * @author charles + * @date 2000-08-08 + */ #include "baseForce.h" #include "indent.h" TypeHandle BaseForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BaseForce -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ BaseForce:: BaseForce(bool active) : _force_node(NULL), @@ -29,11 +26,9 @@ BaseForce(bool active) : { } -//////////////////////////////////////////////////////////////////// -// Function: BaseForce -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ BaseForce:: BaseForce(const BaseForce ©) : TypedReferenceCount(copy) @@ -42,32 +37,24 @@ BaseForce(const BaseForce ©) : _force_node = (ForceNode *) NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ~BaseForce -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ BaseForce:: ~BaseForce() { } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseForce:: output(ostream &out) const { out << "BaseForce (id " << this << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseForce:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/panda/src/physics/baseForce.h b/panda/src/physics/baseForce.h index 03846966ef..90d510013b 100644 --- a/panda/src/physics/baseForce.h +++ b/panda/src/physics/baseForce.h @@ -1,16 +1,15 @@ -// Filename: baseForce.h -// Created by: charles (08Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseForce.h + * @author charles + * @date 2000-08-08 + */ #ifndef BASEFORCE_H #define BASEFORCE_H @@ -24,11 +23,9 @@ class ForceNode; -//////////////////////////////////////////////////////////////////// -// Class : BaseForce -// Description : pure virtual base class for all forces that could -// POSSIBLY exist. -//////////////////////////////////////////////////////////////////// +/** + * pure virtual base class for all forces that could POSSIBLY exist. + */ class EXPCL_PANDAPHYSICS BaseForce : public TypedReferenceCount { PUBLISHED: virtual ~BaseForce(); diff --git a/panda/src/physics/baseIntegrator.I b/panda/src/physics/baseIntegrator.I index 80963aa13f..b12b1c2d12 100644 --- a/panda/src/physics/baseIntegrator.I +++ b/panda/src/physics/baseIntegrator.I @@ -1,30 +1,27 @@ -// Filename: baseIntegrator.I -// Created by: charles (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseIntegrator.I + * @author charles + * @date 2000-08-11 + */ -//////////////////////////////////////////////////////////////////// -// Function: get_precomputed_linear_matrices -// Access: Protected -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const BaseIntegrator::MatrixVector &BaseIntegrator:: get_precomputed_linear_matrices() const { return _precomputed_linear_matrices; } -//////////////////////////////////////////////////////////////////// -// Function: get_precomputed_angular_matrices -// Access: Protected -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const BaseIntegrator::MatrixVector &BaseIntegrator:: get_precomputed_angular_matrices() const { return _precomputed_angular_matrices; diff --git a/panda/src/physics/baseIntegrator.cxx b/panda/src/physics/baseIntegrator.cxx index 3e512a5a7d..b21fd38612 100644 --- a/panda/src/physics/baseIntegrator.cxx +++ b/panda/src/physics/baseIntegrator.cxx @@ -1,48 +1,40 @@ -// Filename: baseIntegrator.cxx -// Created by: charles (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseIntegrator.cxx + * @author charles + * @date 2000-08-11 + */ #include "baseIntegrator.h" #include "physicalNode.h" #include "forceNode.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Function: BaseIntegrator -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ BaseIntegrator:: BaseIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: ~BaseIntegrator -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ BaseIntegrator:: ~BaseIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: precompute_linear_matrices -// Access: Protected -// Description: effectively caches the xform matrices between -// the physical's node and every force acting on it -// so that each PhysicsObject in the set held by the -// Physical doesn't have to wrt. -//////////////////////////////////////////////////////////////////// +/** + * effectively caches the xform matrices between the physical's node and every + * force acting on it so that each PhysicsObject in the set held by the + * Physical doesn't have to wrt. + */ void BaseIntegrator:: precompute_linear_matrices(Physical *physical, const LinearForceVector &forces) { @@ -70,7 +62,7 @@ precompute_linear_matrices(Physical *physical, // tally the global xforms LinearForceVector::const_iterator fi; for (fi = forces.begin(); fi != forces.end(); ++fi) { - //LinearForce *cur_force = *fi; + // LinearForce *cur_force = *fi; force_node = (*fi)->get_force_node(); nassertv(force_node != (ForceNode *) NULL); @@ -91,14 +83,11 @@ precompute_linear_matrices(Physical *physical, } } -//////////////////////////////////////////////////////////////////// -// Function: precompute_angular_matrices -// Access: Protected -// Description: effectively caches the xform matrices between -// the physical's node and every force acting on it -// so that each PhysicsObject in the set held by the -// Physical doesn't have to wrt. -//////////////////////////////////////////////////////////////////// +/** + * effectively caches the xform matrices between the physical's node and every + * force acting on it so that each PhysicsObject in the set held by the + * Physical doesn't have to wrt. + */ void BaseIntegrator:: precompute_angular_matrices(Physical *physical, const AngularForceVector &forces) { @@ -146,12 +135,9 @@ precompute_angular_matrices(Physical *physical, } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseIntegrator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -159,12 +145,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_precomputed_linear_matrices -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseIntegrator:: write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -178,12 +161,9 @@ write_precomputed_linear_matrices(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_precomputed_angular_matrices -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseIntegrator:: write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -197,12 +177,9 @@ write_precomputed_angular_matrices(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void BaseIntegrator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/baseIntegrator.h b/panda/src/physics/baseIntegrator.h index 66ba0177b3..aaedce91cd 100644 --- a/panda/src/physics/baseIntegrator.h +++ b/panda/src/physics/baseIntegrator.h @@ -1,16 +1,15 @@ -// Filename: baseIntegrator.h -// Created by: charles (11Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file baseIntegrator.h + * @author charles + * @date 2000-08-11 + */ #ifndef BASEINTEGRATOR_H #define BASEINTEGRATOR_H @@ -28,12 +27,10 @@ class Physical; -//////////////////////////////////////////////////////////////////// -// Class : BaseIntegrator -// Description : pure virtual integrator class that holds cached -// matrix information that really should be common to -// any possible child implementation. -//////////////////////////////////////////////////////////////////// +/** + * pure virtual integrator class that holds cached matrix information that + * really should be common to any possible child implementation. + */ class EXPCL_PANDAPHYSICS BaseIntegrator : public ReferenceCount { public: typedef epvector MatrixVector; @@ -62,10 +59,9 @@ protected: const AngularForceVector &forces); private: - // since the wrt for each physicsobject between its physicalnode - // and however many forces will be the same among one physical, - // the transformation matrices can be pulled out of the inner loop - // and precomputed. + // since the wrt for each physicsobject between its physicalnode and however + // many forces will be the same among one physical, the transformation + // matrices can be pulled out of the inner loop and precomputed. MatrixVector _precomputed_linear_matrices; MatrixVector _precomputed_angular_matrices; }; diff --git a/panda/src/physics/config_physics.cxx b/panda/src/physics/config_physics.cxx index 08cda96a2f..c0db4dcdf4 100644 --- a/panda/src/physics/config_physics.cxx +++ b/panda/src/physics/config_physics.cxx @@ -1,16 +1,15 @@ -// Filename: config_physics.cxx -// Created by: charles (17Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_physics.cxx + * @author charles + * @date 2000-07-17 + */ #include "config_physics.h" #include "physicsCollisionHandler.h" @@ -35,14 +34,12 @@ ConfigureFn(config_physics) { } -//////////////////////////////////////////////////////////////////// -// Function: init_libphysics -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libphysics() { static bool initialized = false; diff --git a/panda/src/physics/config_physics.h b/panda/src/physics/config_physics.h index 12cedc73d3..5b7249d159 100644 --- a/panda/src/physics/config_physics.h +++ b/panda/src/physics/config_physics.h @@ -1,16 +1,15 @@ -// Filename: config_physics.h -// Created by: charles (17Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_physics.h + * @author charles + * @date 2000-07-17 + */ #ifndef CONFIG_PHYSICS_H #define CONFIG_PHYSICS_H @@ -24,9 +23,9 @@ NotifyCategoryDecl(physics, EXPCL_PANDAPHYSICS, EXPTP_PANDAPHYSICS); extern EXPCL_PANDAPHYSICS void init_libphysics(); -// These macros get stripped out in a non-debug build (like asserts). -// Use them like cout but with paranthesis aroud the cout input. -// e.g. foo_debug("The value of bar is " << bar); +// These macros get stripped out in a non-debug build (like asserts). Use them +// like cout but with paranthesis aroud the cout input. e.g. foo_debug("The +// value of bar is " << bar); #ifndef NDEBUG //[ // Non-release build: #define PHYSICS_DEBUG diff --git a/panda/src/physics/forceNode.I b/panda/src/physics/forceNode.I index a17b6bd09e..43ac5be849 100644 --- a/panda/src/physics/forceNode.I +++ b/panda/src/physics/forceNode.I @@ -1,30 +1,27 @@ -// Filename: forceNode.I -// Created by: charles (02Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file forceNode.I + * @author charles + * @date 2000-08-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: clear -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ForceNode:: clear() { _forces.erase(_forces.begin(), _forces.end()); } -//////////////////////////////////////////////////////////////////// -// Function: get_force -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE BaseForce *ForceNode:: get_force(int index) const { nassertr(index >= 0 && index < (int)_forces.size(), @@ -32,19 +29,17 @@ get_force(int index) const { return _forces[index]; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_forces -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int ForceNode:: get_num_forces() const { return _forces.size(); } -//////////////////////////////////////////////////////////////////// -// Function: add_force -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void ForceNode:: add_force(BaseForce *force) { _forces.push_back(force); diff --git a/panda/src/physics/forceNode.cxx b/panda/src/physics/forceNode.cxx index 937b338640..09a0b3bc27 100644 --- a/panda/src/physics/forceNode.cxx +++ b/panda/src/physics/forceNode.cxx @@ -1,66 +1,55 @@ -// Filename: forceNode.cxx -// Created by: charles (02Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file forceNode.cxx + * @author charles + * @date 2000-08-02 + */ #include "forceNode.h" #include "config_physics.h" TypeHandle ForceNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ForceNode -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ ForceNode:: ForceNode(const string &name) : PandaNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: ForceNode -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ ForceNode:: ForceNode(const ForceNode ©) : PandaNode(copy), _forces(copy._forces) { } -//////////////////////////////////////////////////////////////////// -// Function: ~ForceNode -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ ForceNode:: ~ForceNode() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: dynamic child copy -//////////////////////////////////////////////////////////////////// +/** + * dynamic child copy + */ PandaNode *ForceNode:: make_copy() const { return new ForceNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: add_forces_from -// Access: Public -// Description: append operation -//////////////////////////////////////////////////////////////////// +/** + * append operation + */ void ForceNode:: add_forces_from(const ForceNode &other) { pvector< PT(BaseForce) >::iterator last = _forces.end() - 1; @@ -75,11 +64,9 @@ add_forces_from(const ForceNode &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: remove_force -// Access: Public -// Description: remove operation -//////////////////////////////////////////////////////////////////// +/** + * remove operation + */ void ForceNode:: remove_force(BaseForce *f) { pvector< PT(BaseForce) >::iterator found; @@ -90,11 +77,9 @@ remove_force(BaseForce *f) { _forces.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_force -// Access: Public -// Description: remove operation -//////////////////////////////////////////////////////////////////// +/** + * remove operation + */ void ForceNode:: remove_force(int index) { nassertv(index >= 0 && index <= (int)_forces.size()); @@ -107,24 +92,18 @@ remove_force(int index) { _forces.erase(remove); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ForceNode:: output(ostream &out) const { PandaNode::output(out); out<<" ("<<_forces.size()<<" forces)"; } -//////////////////////////////////////////////////////////////////// -// Function: write_linear_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ForceNode:: write_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -133,24 +112,21 @@ write_forces(ostream &out, unsigned int indent) const { i != _forces.end(); ++i) { out.width(indent+2); out<<""; out<<"(id "<<&(*i)<<" "<<(*i)->is_linear()<<")\n"; - //#*#(*i)->write(out, indent+2); + // #*#(*i)->write(out, indent+2); } #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void ForceNode:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"ForceNode (id "<. -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearControlForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -91,12 +77,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearControlForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearControlForce.h b/panda/src/physics/linearControlForce.h index 44627f9c7e..3d9e889130 100644 --- a/panda/src/physics/linearControlForce.h +++ b/panda/src/physics/linearControlForce.h @@ -1,31 +1,27 @@ -// Filename: linearControlForce.h -// Created by: Dave Schuyler (2006) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearControlForce.h + * @author Dave Schuyler + * @date 2006 + */ #ifndef LINEARCONTROLFORCE_H #define LINEARCONTROLFORCE_H #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearControlForce -// Description : Simple directed vector force. This force is -// different from the others in that it can be -// global and still only affect a single object. -// That might not make sense for a physics simulation, -// but it's very handy for a game. I.e. this is -// the force applied by user on the selected object. -//////////////////////////////////////////////////////////////////// +/** + * Simple directed vector force. This force is different from the others in + * that it can be global and still only affect a single object. That might + * not make sense for a physics simulation, but it's very handy for a game. + * I.e. this is the force applied by user on the selected object. + */ class EXPCL_PANDAPHYSICS LinearControlForce : public LinearForce { PUBLISHED: LinearControlForce(const PhysicsObject *po = 0, PN_stdfloat a = 1.0f, diff --git a/panda/src/physics/linearCylinderVortexForce.I b/panda/src/physics/linearCylinderVortexForce.I index e9766c684b..f04dac7bbd 100644 --- a/panda/src/physics/linearCylinderVortexForce.I +++ b/panda/src/physics/linearCylinderVortexForce.I @@ -1,66 +1,59 @@ -// Filename: linearCylinderVortexForce.I -// Created by: charles (24Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearCylinderVortexForce.I + * @author charles + * @date 2000-07-24 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearCylinderVortexForce:: set_radius(PN_stdfloat radius) { _radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: set_length -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearCylinderVortexForce:: set_length(PN_stdfloat length) { _length = length; } -//////////////////////////////////////////////////////////////////// -// Function: set_coef -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearCylinderVortexForce:: set_coef(PN_stdfloat coef) { _coef = coef; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat LinearCylinderVortexForce:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_length -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat LinearCylinderVortexForce:: get_length() const { return _length; } -//////////////////////////////////////////////////////////////////// -// Function: get_coef -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat LinearCylinderVortexForce:: get_coef() const { return _coef; diff --git a/panda/src/physics/linearCylinderVortexForce.cxx b/panda/src/physics/linearCylinderVortexForce.cxx index bb0429a1bb..9976d6b1eb 100644 --- a/panda/src/physics/linearCylinderVortexForce.cxx +++ b/panda/src/physics/linearCylinderVortexForce.cxx @@ -1,16 +1,15 @@ -// Filename: linearCylinderVortexForce.cxx -// Created by: charles (24Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearCylinderVortexForce.cxx + * @author charles + * @date 2000-07-24 + */ #include "config_physics.h" #include "linearCylinderVortexForce.h" @@ -19,11 +18,9 @@ TypeHandle LinearCylinderVortexForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearCylinderVortexForce -// Access: Public -// Description: Simple Constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple Constructor + */ LinearCylinderVortexForce:: LinearCylinderVortexForce(PN_stdfloat radius, PN_stdfloat length, PN_stdfloat coef, PN_stdfloat a, bool md) : @@ -31,11 +28,9 @@ LinearCylinderVortexForce(PN_stdfloat radius, PN_stdfloat length, PN_stdfloat co _radius(radius), _length(length), _coef(coef) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearCylinderVortexForce -// Access: Public -// Description: copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * copy Constructor + */ LinearCylinderVortexForce:: LinearCylinderVortexForce(const LinearCylinderVortexForce ©) : LinearForce(copy) { @@ -44,37 +39,29 @@ LinearCylinderVortexForce(const LinearCylinderVortexForce ©) : _coef = copy._coef; } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearCylinderVortexForce -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ LinearCylinderVortexForce:: ~LinearCylinderVortexForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: child copier -//////////////////////////////////////////////////////////////////// +/** + * child copier + */ LinearForce *LinearCylinderVortexForce:: make_copy() { return new LinearCylinderVortexForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Private, Virtual -// Description: returns the centripetal force vector for the -// passed-in object -//////////////////////////////////////////////////////////////////// +/** + * returns the centripetal force vector for the passed-in object + */ LVector3 LinearCylinderVortexForce:: get_child_vector(const PhysicsObject *po) { - // get the force-space transform- this MUST be the relative matrix - // from the point's local coordinate system to the attached node's - // local system. - // LMatrix4 force_space_xform = LMatrix4::ident_mat(); + // get the force-space transform- this MUST be the relative matrix from the + // point's local coordinate system to the attached node's local system. + // LMatrix4 force_space_xform = LMatrix4::ident_mat(); LVector3 force_vec(0.0f, 0.0f, 0.0f); // project the point into force_space @@ -90,8 +77,8 @@ get_child_vector(const PhysicsObject *po) { PN_stdfloat dist_squared = x_squared + y_squared; PN_stdfloat radius_squared = _radius * _radius; - // squared space increases monotonically wrt linear space, - // so there's no need to sqrt to check inside/outside this disc. + // squared space increases monotonically wrt linear space, so there's no + // need to sqrt to check insideoutside this disc. if (dist_squared > radius_squared) return force_vec; @@ -115,24 +102,20 @@ get_child_vector(const PhysicsObject *po) { LVector3 combined = tangential + centripetal; combined.normalize(); - // a = v^2 / r - //centripetal = centripetal * _coef * (tangential.length_squared() / - // (r + get_nearly_zero_value(r))); + // a = v^2 r centripetal = centripetal * _coef * + // (tangential.length_squared() (r + get_nearly_zero_value(r))); centripetal = combined * _coef * po->get_velocity().length(); - //centripetal = combined * _coef * (po->get_velocity().length() / - // (r + get_nearly_zero_value(r))); + // centripetal = combined * _coef * (po->get_velocity().length() (r + + // get_nearly_zero_value(r))); return centripetal; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearCylinderVortexForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -140,12 +123,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearCylinderVortexForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearCylinderVortexForce.h b/panda/src/physics/linearCylinderVortexForce.h index 8a24bafe3e..14fc911811 100644 --- a/panda/src/physics/linearCylinderVortexForce.h +++ b/panda/src/physics/linearCylinderVortexForce.h @@ -1,32 +1,28 @@ -// Filename: linearCylinderVortexForce.h -// Created by: charles (24Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearCylinderVortexForce.h + * @author charles + * @date 2000-07-24 + */ #ifndef LINEARCYLINDERVORTEXFORCE_H #define LINEARCYLINDERVORTEXFORCE_H #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearCylinderVortexForce -// Description : Defines a cylinder inside of which all forces are -// tangential to the theta of the particle wrt the -// z-axis in local coord. space. This happens by -// assigning the force a node by which the cylinder is -// transformed. Be warned- this will suck anything -// that it can reach directly into orbit and will NOT -// let go. -//////////////////////////////////////////////////////////////////// +/** + * Defines a cylinder inside of which all forces are tangential to the theta + * of the particle wrt the z-axis in local coord. space. This happens by + * assigning the force a node by which the cylinder is transformed. Be + * warned- this will suck anything that it can reach directly into orbit and + * will NOT let go. + */ class EXPCL_PANDAPHYSICS LinearCylinderVortexForce : public LinearForce { PUBLISHED: LinearCylinderVortexForce(PN_stdfloat radius = 1.0f, @@ -45,7 +41,7 @@ PUBLISHED: INLINE void set_length(PN_stdfloat length); INLINE PN_stdfloat get_length() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearDistanceForce.I b/panda/src/physics/linearDistanceForce.I index 245d04f2e9..bc7a436bcf 100644 --- a/panda/src/physics/linearDistanceForce.I +++ b/panda/src/physics/linearDistanceForce.I @@ -1,82 +1,67 @@ -// Filename: linearDistanceForce.I -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearDistanceForce.I + * @author charles + * @date 2000-06-21 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_falloff_type -// Access: Public -// Description: falloff_type encapsulating wrap -//////////////////////////////////////////////////////////////////// +/** + * falloff_type encapsulating wrap + */ INLINE void LinearDistanceForce:: set_falloff_type(FalloffType ft) { _falloff = ft; } -//////////////////////////////////////////////////////////////////// -// Function: set_radius -// Access: Public -// Description: set the radius -//////////////////////////////////////////////////////////////////// +/** + * set the radius + */ INLINE void LinearDistanceForce:: set_radius(PN_stdfloat r) { _radius = r; } -//////////////////////////////////////////////////////////////////// -// Function: set_force_center -// Access: Public -// Description: set the force center -//////////////////////////////////////////////////////////////////// +/** + * set the force center + */ INLINE void LinearDistanceForce:: set_force_center(const LPoint3& p) { _force_center = p; } -//////////////////////////////////////////////////////////////////// -// Function: get_falloff_type -// Access: Public -// Description: falloff_type query -//////////////////////////////////////////////////////////////////// +/** + * falloff_type query + */ INLINE LinearDistanceForce::FalloffType LinearDistanceForce:: get_falloff_type() const { return _falloff; } -//////////////////////////////////////////////////////////////////// -// Function: get_radius -// Access: Public -// Description: radius query -//////////////////////////////////////////////////////////////////// +/** + * radius query + */ INLINE PN_stdfloat LinearDistanceForce:: get_radius() const { return _radius; } -//////////////////////////////////////////////////////////////////// -// Function: get_force_center -// Access: Public -// Description: force_center query -//////////////////////////////////////////////////////////////////// +/** + * force_center query + */ INLINE LPoint3 LinearDistanceForce:: get_force_center() const { return _force_center; } -//////////////////////////////////////////////////////////////////// -// Function: get_scalar_term -// Access: Private -// Description: calculate the term based on falloff -//////////////////////////////////////////////////////////////////// +/** + * calculate the term based on falloff + */ INLINE PN_stdfloat LinearDistanceForce:: get_scalar_term() const { PN_stdfloat r = _radius; diff --git a/panda/src/physics/linearDistanceForce.cxx b/panda/src/physics/linearDistanceForce.cxx index 76879dae8c..65922d0a2a 100644 --- a/panda/src/physics/linearDistanceForce.cxx +++ b/panda/src/physics/linearDistanceForce.cxx @@ -1,26 +1,23 @@ -// Filename: linearDistanceForce.cxx -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearDistanceForce.cxx + * @author charles + * @date 2000-06-21 + */ #include "linearDistanceForce.h" TypeHandle LinearDistanceForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearDistanceForce -// Access: Protected -// Description: Simple constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple constructor + */ LinearDistanceForce:: LinearDistanceForce(const LPoint3& p, FalloffType ft, PN_stdfloat r, PN_stdfloat a, bool m) : LinearForce(a, m), @@ -28,11 +25,9 @@ LinearDistanceForce(const LPoint3& p, FalloffType ft, PN_stdfloat r, PN_stdfloat { } -//////////////////////////////////////////////////////////////////// -// Function: LinearDistanceForce -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearDistanceForce:: LinearDistanceForce(const LinearDistanceForce ©) : LinearForce(copy) { @@ -41,21 +36,16 @@ LinearDistanceForce(const LinearDistanceForce ©) : _force_center = copy._force_center; } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearDistanceForce -// Access: Protected -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearDistanceForce:: ~LinearDistanceForce() { } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearDistanceForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -63,12 +53,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearDistanceForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearDistanceForce.h b/panda/src/physics/linearDistanceForce.h index 2d1fb10a26..4afa6f2d11 100644 --- a/panda/src/physics/linearDistanceForce.h +++ b/panda/src/physics/linearDistanceForce.h @@ -1,16 +1,15 @@ -// Filename: linearDistanceForce.h -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearDistanceForce.h + * @author charles + * @date 2000-06-21 + */ #ifndef LINEARDISTANCEFORCE_H #define LINEARDISTANCEFORCE_H @@ -19,10 +18,9 @@ class BamReader; -//////////////////////////////////////////////////////////////////// -// Class : LinearDistanceForce -// Description : Pure virtual class for sinks and sources -//////////////////////////////////////////////////////////////////// +/** + * Pure virtual class for sinks and sources + */ class EXPCL_PANDAPHYSICS LinearDistanceForce : public LinearForce { PUBLISHED: enum FalloffType { @@ -40,7 +38,7 @@ PUBLISHED: INLINE LPoint3 get_force_center() const; INLINE PN_stdfloat get_scalar_term() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearEulerIntegrator.cxx b/panda/src/physics/linearEulerIntegrator.cxx index 8e7a2fbe31..f208eda299 100644 --- a/panda/src/physics/linearEulerIntegrator.cxx +++ b/panda/src/physics/linearEulerIntegrator.cxx @@ -1,56 +1,43 @@ -// Filename: linearEulerIntegrator.cxx -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearEulerIntegrator.cxx + * @author charles + * @date 2000-06-13 + */ #include "linearEulerIntegrator.h" #include "forceNode.h" #include "physicalNode.h" #include "config_physics.h" -//////////////////////////////////////////////////////////////////// -// Function: LinearEulerIntegrator -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearEulerIntegrator:: LinearEulerIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: LinearEulerIntegrator -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearEulerIntegrator:: ~LinearEulerIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: Integrate -// Access: Public -// Description: Integrate a step of motion (based on dt) by -// applying every force in force_vec to every object -// in obj_vec. -// -// physical, -// The objects being acted upon and the -// set of local forces that are applied -// after the global forces. -// forces, -// Global forces to be applied first. -// dt, -// The delta time of this integration step. -//////////////////////////////////////////////////////////////////// +/** + * Integrate a step of motion (based on dt) by applying every force in + * force_vec to every object in obj_vec. + * + * physical, The objects being acted upon and the set of local forces that are + * applied after the global forces. forces, Global forces to be applied + * first. dt, The delta time of this integration step. + */ void LinearEulerIntegrator:: child_integrate(Physical *physical, LinearForceVector& forces, @@ -72,21 +59,19 @@ child_integrate(Physical *physical, // Get the greater of the local or global viscosity: PN_stdfloat viscosityDamper=1.0f-physical->get_viscosity(); - // Loop through each object in the set. This processing occurs in O(pf) time, - // where p is the number of physical objects and f is the number of - // forces. Unfortunately, no precomputation of forces can occur, as - // each force is possibly contingent on such things as the position and - // velocity of each physicsobject in the set. Accordingly, we have - // to grunt our way through each one. wrt caching of the xform matrix - // should help. + // Loop through each object in the set. This processing occurs in O(pf) + // time, where p is the number of physical objects and f is the number of + // forces. Unfortunately, no precomputation of forces can occur, as each + // force is possibly contingent on such things as the position and velocity + // of each physicsobject in the set. Accordingly, we have to grunt our way + // through each one. wrt caching of the xform matrix should help. PhysicsObject::Vector::const_iterator current_object_iter; current_object_iter = physical->get_object_vector().begin(); for (; current_object_iter != physical->get_object_vector().end(); ++current_object_iter) { PhysicsObject *current_object = *current_object_iter; - // bail out if this object doesn't exist or doesn't want to be - // processed. + // bail out if this object doesn't exist or doesn't want to be processed. if (current_object == (PhysicsObject *) NULL) { continue; } @@ -106,7 +91,7 @@ child_integrate(Physical *physical, // run through each acting force and sum it LVector3 f; - // LMatrix4 force_to_object_xform; + // LMatrix4 force_to_object_xform; LinearForceVector::const_iterator f_cur; @@ -160,8 +145,7 @@ child_integrate(Physical *physical, vel_vec = current_object->get_velocity(); PN_stdfloat mass = current_object->get_mass(); - // we want 'a' in F = ma - // get it by computing F / m + // we want 'a' in F = ma get it by computing F m nassertv(mass != 0.0f); accel_vec = md_accum_vec / mass; accel_vec += non_md_accum_vec; @@ -174,7 +158,8 @@ child_integrate(Physical *physical, PN_stdfloat len = vel_vec.length(); if (len > current_object->get_terminal_velocity()) { - //cout << "Capping terminal velocity at: " << current_object->get_terminal_velocity() << endl; + // cout << "Capping terminal velocity at: " << + // current_object->get_terminal_velocity() << endl; vel_vec *= current_object->get_terminal_velocity() / len; } @@ -200,12 +185,9 @@ child_integrate(Physical *physical, } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearEulerIntegrator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -213,12 +195,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearEulerIntegrator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -227,11 +206,3 @@ write(ostream &out, unsigned int indent) const { LinearIntegrator::write(out, indent+2); #endif //] NDEBUG } - - - - - - - - diff --git a/panda/src/physics/linearEulerIntegrator.h b/panda/src/physics/linearEulerIntegrator.h index 311532ed50..c7b6d3ff47 100644 --- a/panda/src/physics/linearEulerIntegrator.h +++ b/panda/src/physics/linearEulerIntegrator.h @@ -1,32 +1,30 @@ -// Filename: linearEulerIntegrator.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearEulerIntegrator.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEAREULERINTEGRATOR_H #define LINEAREULERINTEGRATOR_H #include "linearIntegrator.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearEulerIntegrator -// Description : Performs Euler integration on a vector of -// physically modelable objects given a quantum dt. -//////////////////////////////////////////////////////////////////// +/** + * Performs Euler integration on a vector of physically modelable objects + * given a quantum dt. + */ class EXPCL_PANDAPHYSICS LinearEulerIntegrator : public LinearIntegrator { PUBLISHED: LinearEulerIntegrator(); virtual ~LinearEulerIntegrator(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearForce.I b/panda/src/physics/linearForce.I index cbf114d6dc..e31bfe9020 100644 --- a/panda/src/physics/linearForce.I +++ b/panda/src/physics/linearForce.I @@ -1,57 +1,51 @@ -// Filename: linearForce.I -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearForce.I + * @author charles + * @date 2000-06-13 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_amplitude -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearForce:: set_amplitude(PN_stdfloat a) { _amplitude = a; } -//////////////////////////////////////////////////////////////////// -// Function: get_amplitude -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat LinearForce:: get_amplitude() const { return _amplitude; } -//////////////////////////////////////////////////////////////////// -// Function: get_mass_dependent -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE bool LinearForce:: get_mass_dependent() const { return _mass_dependent; } -//////////////////////////////////////////////////////////////////// -// Function: set_mass_Dependent -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearForce:: set_mass_dependent(bool m) { _mass_dependent = m; } -//////////////////////////////////////////////////////////////////// -// Function: set_vector_masks -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearForce:: set_vector_masks(bool x, bool y, bool z) { _x_mask = x; @@ -59,10 +53,9 @@ set_vector_masks(bool x, bool y, bool z) { _z_mask = z; } -//////////////////////////////////////////////////////////////////// -// Function: set_vector_masks -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE LVector3 LinearForce:: get_vector_masks() { return LVector3(_x_mask, _y_mask, _z_mask); diff --git a/panda/src/physics/linearForce.cxx b/panda/src/physics/linearForce.cxx index 3b3b114c1c..dde98eba84 100644 --- a/panda/src/physics/linearForce.cxx +++ b/panda/src/physics/linearForce.cxx @@ -1,16 +1,15 @@ -// Filename: linearForce.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearForce.cxx + * @author charles + * @date 2000-06-14 + */ #include "datagram.h" #include "datagramIterator.h" @@ -21,11 +20,9 @@ TypeHandle LinearForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearForce -// Access: Protected -// Description: Default/component-based constructor -//////////////////////////////////////////////////////////////////// +/** + * Default/component-based constructor + */ LinearForce:: LinearForce(PN_stdfloat a, bool mass) : BaseForce(true), @@ -33,11 +30,9 @@ LinearForce(PN_stdfloat a, bool mass) : _x_mask(true), _y_mask(true), _z_mask(true) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearForce -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearForce:: LinearForce(const LinearForce& copy) : BaseForce(copy) { @@ -48,19 +43,16 @@ LinearForce(const LinearForce& copy) : _z_mask = copy._z_mask; } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearForce -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ LinearForce:: ~LinearForce() { } -//////////////////////////////////////////////////////////////////// -// Function: get_vector -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ LVector3 LinearForce:: get_vector(const PhysicsObject *po) { LVector3 child_vector = get_child_vector(po) * _amplitude; @@ -78,21 +70,17 @@ get_vector(const PhysicsObject *po) { return child_vector; } -//////////////////////////////////////////////////////////////////// -// Function: is_linear -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ bool LinearForce:: is_linear() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -100,12 +88,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearForce.h b/panda/src/physics/linearForce.h index c47591c8cf..24d12b7b5f 100644 --- a/panda/src/physics/linearForce.h +++ b/panda/src/physics/linearForce.h @@ -1,27 +1,25 @@ -// Filename: linearForce.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearForce.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEARFORCE_H #define LINEARFORCE_H #include "baseForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearForce -// Description : A force that acts on a PhysicsObject by way of an -// Integrator. This is a pure virtual base class. -//////////////////////////////////////////////////////////////////// +/** + * A force that acts on a PhysicsObject by way of an Integrator. This is a + * pure virtual base class. + */ class EXPCL_PANDAPHYSICS LinearForce : public BaseForce { PUBLISHED: ~LinearForce(); @@ -40,7 +38,7 @@ PUBLISHED: virtual LinearForce *make_copy() = 0; virtual bool is_linear() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearFrictionForce.I b/panda/src/physics/linearFrictionForce.I index 184d59f2a2..01ed85481d 100644 --- a/panda/src/physics/linearFrictionForce.I +++ b/panda/src/physics/linearFrictionForce.I @@ -1,21 +1,19 @@ -// Filename: linearFrictionForce.I -// Created by: charles (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearFrictionForce.I + * @author charles + * @date 2000-07-31 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_coef -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void LinearFrictionForce:: set_coef(PN_stdfloat coef) { // friction shouldn't be outside of [0, 1] @@ -27,10 +25,9 @@ set_coef(PN_stdfloat coef) { _coef = coef; } -//////////////////////////////////////////////////////////////////// -// Function: get_coef -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PN_stdfloat LinearFrictionForce:: get_coef() const { return _coef; diff --git a/panda/src/physics/linearFrictionForce.cxx b/panda/src/physics/linearFrictionForce.cxx index 042f172202..1b28f86e6c 100644 --- a/panda/src/physics/linearFrictionForce.cxx +++ b/panda/src/physics/linearFrictionForce.cxx @@ -1,68 +1,57 @@ -// Filename: linearFrictionForce.cxx -// Created by: charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearFrictionForce.cxx + * @author charles + * @date 2000-06-23 + */ #include "linearFrictionForce.h" #include "config_physics.h" TypeHandle LinearFrictionForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearFrictionForce -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ LinearFrictionForce:: LinearFrictionForce(PN_stdfloat coef, PN_stdfloat a, bool m) : LinearForce(a, m) { set_coef(coef); } -//////////////////////////////////////////////////////////////////// -// Function: LinearFrictionForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearFrictionForce:: LinearFrictionForce(const LinearFrictionForce ©) : LinearForce(copy) { _coef = copy._coef; } -//////////////////////////////////////////////////////////////////// -// Function: LinearFrictionForce -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearFrictionForce:: ~LinearFrictionForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearFrictionForce:: make_copy() { return new LinearFrictionForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LinearFrictionForce -// Access: Public -// Description: Constructor -//////////////////////////////////////////////////////////////////// +/** + * Constructor + */ LVector3 LinearFrictionForce:: get_child_vector(const PhysicsObject* po) { LVector3 v = po->get_velocity(); @@ -74,19 +63,15 @@ get_child_vector(const PhysicsObject* po) { <<" dot "<<(normalize(v).dot(normalize(friction)))); assert(friction.almost_equal(LVector3::zero()) || IS_NEARLY_EQUAL(normalize(v).dot(normalize(friction)), -1.0f)); - // cary said to cap this at zero so that friction can't reverse - // your direction, but it seems to me that if you're computing: - // v + (-v * _coef), _coef in [0, 1] - // that this will always be greater than or equal to zero. + // cary said to cap this at zero so that friction can't reverse your + // direction, but it seems to me that if you're computing: v + (-v * _coef), + // _coef in [0, 1] that this will always be greater than or equal to zero. return friction; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearFrictionForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -94,12 +79,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearFrictionForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearFrictionForce.h b/panda/src/physics/linearFrictionForce.h index 67b1fc31de..af11e73b4a 100644 --- a/panda/src/physics/linearFrictionForce.h +++ b/panda/src/physics/linearFrictionForce.h @@ -1,26 +1,24 @@ -// Filename: linearFrictionForce.h -// Created by: charles (23Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearFrictionForce.h + * @author charles + * @date 2000-06-23 + */ #ifndef LINEARFRICTIONFORCE_H #define LINEARFRICTIONFORCE_H #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearFrictionForce -// Description : Friction-based drag force -//////////////////////////////////////////////////////////////////// +/** + * Friction-based drag force + */ class EXPCL_PANDAPHYSICS LinearFrictionForce : public LinearForce { PUBLISHED: LinearFrictionForce(PN_stdfloat coef = 1.0f, PN_stdfloat a = 1.0f, bool m = false); @@ -29,7 +27,7 @@ PUBLISHED: INLINE void set_coef(PN_stdfloat coef); INLINE PN_stdfloat get_coef() const; - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index 6c88db005b..c58f9a4904 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -1,16 +1,15 @@ -// Filename: linearIntegrator.cxx -// Created by: charles (02Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearIntegrator.cxx + * @author charles + * @date 2000-08-02 + */ #include "linearIntegrator.h" #include "config_physics.h" @@ -21,30 +20,23 @@ ConfigVariableDouble LinearIntegrator::_max_linear_dt ("default_max_linear_dt", 1.0f / 30.0f); -//////////////////////////////////////////////////////////////////// -// Function: BaseLinearIntegrator -// Access: Protected -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearIntegrator:: LinearIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearIntegrator -// Access: Public, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearIntegrator:: ~LinearIntegrator() { } -//////////////////////////////////////////////////////////////////// -// Function: integrate -// Access: Public -// Description: parent integration routine, hands off to child -// virtual. -//////////////////////////////////////////////////////////////////// +/** + * parent integration routine, hands off to child virtual. + */ void LinearIntegrator:: integrate(Physical *physical, LinearForceVector &forces, PN_stdfloat dt) { @@ -60,24 +52,21 @@ integrate(Physical *physical, LinearForceVector &forces, ++current_object_iter) { PhysicsObject *current_object = *current_object_iter; - // bail out if this object doesn't exist or doesn't want to be - // processed. + // bail out if this object doesn't exist or doesn't want to be processed. if (current_object == (PhysicsObject *) NULL) { continue; } - // set the object's last position to its current position before we move it + // set the object's last position to its current position before we move + // it current_object->set_last_position(current_object->get_position()); } child_integrate(physical, forces, dt); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearIntegrator:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -85,12 +74,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearIntegrator:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearIntegrator.h b/panda/src/physics/linearIntegrator.h index 82e036d406..d5e6a1375d 100644 --- a/panda/src/physics/linearIntegrator.h +++ b/panda/src/physics/linearIntegrator.h @@ -1,16 +1,15 @@ -// Filename: linearIntegrator.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearIntegrator.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEARINTEGRATOR_H #define LINEARINTEGRATOR_H @@ -20,12 +19,10 @@ #include "linearForce.h" #include "configVariableDouble.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearIntegrator -// Description : Pure virtual base class for physical modeling. -// Takes physically modelable objects and applies -// forces to them. -//////////////////////////////////////////////////////////////////// +/** + * Pure virtual base class for physical modeling. Takes physically modelable + * objects and applies forces to them. + */ class EXPCL_PANDAPHYSICS LinearIntegrator : public BaseIntegrator { PUBLISHED: virtual ~LinearIntegrator(); @@ -34,7 +31,7 @@ public: void integrate(Physical *physical, LinearForceVector &forces, PN_stdfloat dt); -PUBLISHED: +PUBLISHED: virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; @@ -44,9 +41,9 @@ protected: private: static ConfigVariableDouble _max_linear_dt; - // this allows baseLinearIntegrator to censor/modify data that the - // actual integration function receives. - virtual void child_integrate(Physical *physical, + // this allows baseLinearIntegrator to censormodify data that the actual + // integration function receives. + virtual void child_integrate(Physical *physical, LinearForceVector &forces, PN_stdfloat dt) = 0; }; diff --git a/panda/src/physics/linearJitterForce.cxx b/panda/src/physics/linearJitterForce.cxx index f3ab44207d..d74a14fac6 100644 --- a/panda/src/physics/linearJitterForce.cxx +++ b/panda/src/physics/linearJitterForce.cxx @@ -1,76 +1,62 @@ -// Filename: linearJitterForce.cxx -// Created by: charles (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearJitterForce.cxx + * @author charles + * @date 2000-06-16 + */ #include "linearJitterForce.h" TypeHandle LinearJitterForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearJitterForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearJitterForce:: LinearJitterForce(PN_stdfloat a, bool mass) : LinearRandomForce(a, mass) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearJitterForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearJitterForce:: LinearJitterForce(const LinearJitterForce ©) : LinearRandomForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearJitterForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearJitterForce:: ~LinearJitterForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearJitterForce:: make_copy() { return new LinearJitterForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Public -// Description: random value -//////////////////////////////////////////////////////////////////// +/** + * random value + */ LVector3 LinearJitterForce:: get_child_vector(const PhysicsObject *) { return random_unit_vector(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearJitterForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -78,12 +64,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearJitterForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearJitterForce.h b/panda/src/physics/linearJitterForce.h index 8d0967eb43..bfba75315d 100644 --- a/panda/src/physics/linearJitterForce.h +++ b/panda/src/physics/linearJitterForce.h @@ -1,33 +1,31 @@ -// Filename: linearJitterForce.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearJitterForce.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEARJITTERFORCE_H #define LINEARJITTERFORCE_H #include "linearRandomForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearJitterForce -// Description : Completely random noise force vector. Not -// repeatable, reliable, or predictable. -//////////////////////////////////////////////////////////////////// +/** + * Completely random noise force vector. Not repeatable, reliable, or + * predictable. + */ class EXPCL_PANDAPHYSICS LinearJitterForce : public LinearRandomForce { PUBLISHED: LinearJitterForce(PN_stdfloat a = 1.0f, bool m = false); LinearJitterForce(const LinearJitterForce ©); virtual ~LinearJitterForce(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearNoiseForce.I b/panda/src/physics/linearNoiseForce.I index c30f73204a..0407d46a75 100644 --- a/panda/src/physics/linearNoiseForce.I +++ b/panda/src/physics/linearNoiseForce.I @@ -1,83 +1,67 @@ -// Filename: linearNoiseForce.I -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearNoiseForce.I + * @author charles + * @date 2000-06-19 + */ -//////////////////////////////////////////////////////////////////// -// Function: prn_lookup -// Access: Private -// Description: Returns a valid entry in the prn table -//////////////////////////////////////////////////////////////////// +/** + * Returns a valid entry in the prn table + */ INLINE unsigned char LinearNoiseForce:: prn_lookup(int index) const { return _prn_table[index & 255]; } -//////////////////////////////////////////////////////////////////// -// Function: get_prn_entry -// Access: Private -// Description: Hashes a point, returns a prn -//////////////////////////////////////////////////////////////////// +/** + * Hashes a point, returns a prn + */ INLINE unsigned char LinearNoiseForce:: get_prn_entry(const LPoint3& point) const { return prn_lookup((int)(point[0] + prn_lookup((int)(point[1] + prn_lookup((int)point[2]))))); } -//////////////////////////////////////////////////////////////////// -// Function: get_prn_entry -// Access: Private -// Description: Hashes a point, returns a prn (piecewise) -//////////////////////////////////////////////////////////////////// +/** + * Hashes a point, returns a prn (piecewise) + */ INLINE unsigned char LinearNoiseForce:: get_prn_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) const { return prn_lookup((int)(x + prn_lookup((int)(y + prn_lookup((int)z))))); } -//////////////////////////////////////////////////////////////////// -// Function: get_lattice_entry -// Access: Private -// Description: Hashes a point, returns a gradient vector -//////////////////////////////////////////////////////////////////// +/** + * Hashes a point, returns a gradient vector + */ INLINE LVector3& LinearNoiseForce:: get_lattice_entry(const LPoint3& point) { return _gradient_table[get_prn_entry(point)]; } -//////////////////////////////////////////////////////////////////// -// Function: get_lattice_entry -// Access: Private -// Description: Hashes a point, returns a gradient vector (piecewise) -//////////////////////////////////////////////////////////////////// +/** + * Hashes a point, returns a gradient vector (piecewise) + */ INLINE LVector3& LinearNoiseForce:: get_lattice_entry(const PN_stdfloat x, const PN_stdfloat y, const PN_stdfloat z) { return _gradient_table[get_prn_entry(x, y, z)]; } -//////////////////////////////////////////////////////////////////// -// Function: cubic_step -// Access: Private -// Description: Smooths a parameterized interpolation using -// 2x^3 - 3x^2 -//////////////////////////////////////////////////////////////////// +/** + * Smooths a parameterized interpolation using 2x^3 - 3x^2 + */ INLINE PN_stdfloat LinearNoiseForce:: cubic_step(const PN_stdfloat x) const { return x * x * ((2 * x) - 3); } -//////////////////////////////////////////////////////////////////// -// Function: vlerp -// Access: Private -// Description: Vector linear interpolation -//////////////////////////////////////////////////////////////////// +/** + * Vector linear interpolation + */ INLINE LVector3 LinearNoiseForce:: vlerp(const PN_stdfloat t, const LVector3& v0, const LVector3& v1) const { return v0 + ((v1 - v0) * t); diff --git a/panda/src/physics/linearNoiseForce.cxx b/panda/src/physics/linearNoiseForce.cxx index 37c492f8ea..b7d9109f8f 100644 --- a/panda/src/physics/linearNoiseForce.cxx +++ b/panda/src/physics/linearNoiseForce.cxx @@ -1,16 +1,15 @@ -// Filename: linearNoiseForce.cxx -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearNoiseForce.cxx + * @author charles + * @date 2000-06-13 + */ #include #include @@ -28,16 +27,13 @@ LVector3 LinearNoiseForce::_gradient_table[256]; TypeHandle LinearNoiseForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: InitNoiseTables -// Access: Public -// Description: One-time config function, sets up the PRN -// lattice. -//////////////////////////////////////////////////////////////////// +/** + * One-time config function, sets up the PRN lattice. + */ void LinearNoiseForce:: init_noise_tables() { - // since this is a repeatable noise function, we always want - // to init with the same seed. + // since this is a repeatable noise function, we always want to init with + // the same seed. srand(_random_seed); LVector3 *gtable = _gradient_table; @@ -50,11 +46,9 @@ init_noise_tables() { } } -//////////////////////////////////////////////////////////////////// -// Function: LinearNoiseForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearNoiseForce:: LinearNoiseForce(PN_stdfloat a, bool mass) : LinearRandomForce(a, mass) { @@ -64,41 +58,32 @@ LinearNoiseForce(PN_stdfloat a, bool mass) : } } -//////////////////////////////////////////////////////////////////// -// Function: LinearNoiseForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearNoiseForce:: LinearNoiseForce(const LinearNoiseForce ©) : LinearRandomForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearNoiseForce -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearNoiseForce:: ~LinearNoiseForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearNoiseForce:: make_copy() { return new LinearNoiseForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Public -// Description: Returns the noise value based on the object's -// position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the noise value based on the object's position. + */ LVector3 LinearNoiseForce:: get_child_vector(const PhysicsObject *po) { LPoint3 p = po->get_position(); @@ -147,12 +132,9 @@ get_child_vector(const PhysicsObject *po) { return vlerp(cubic_y, temp0, temp1); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearNoiseForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -160,12 +142,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearNoiseForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearNoiseForce.h b/panda/src/physics/linearNoiseForce.h index a88d8206d1..b0c47b56ea 100644 --- a/panda/src/physics/linearNoiseForce.h +++ b/panda/src/physics/linearNoiseForce.h @@ -1,16 +1,15 @@ -// Filename: linearNoiseForce.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearNoiseForce.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEARNOISEFORCE_H #define LINEARNOISEFORCE_H @@ -19,16 +18,15 @@ #include "linearRandomForce.h" #include "configVariableInt.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearNoiseForce -// Description : Repeating noise force vector. -//////////////////////////////////////////////////////////////////// +/** + * Repeating noise force vector. + */ class EXPCL_PANDAPHYSICS LinearNoiseForce : public LinearRandomForce { PUBLISHED: LinearNoiseForce(PN_stdfloat a = 1.0f, bool m = false); LinearNoiseForce(const LinearNoiseForce ©); virtual ~LinearNoiseForce(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearRandomForce.I b/panda/src/physics/linearRandomForce.I index fe9d10c3c1..af9eb5a237 100644 --- a/panda/src/physics/linearRandomForce.I +++ b/panda/src/physics/linearRandomForce.I @@ -1,22 +1,19 @@ -// Filename: linearRandomForce.I -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearRandomForce.I + * @author charles + * @date 2000-06-19 + */ -//////////////////////////////////////////////////////////////////// -// Function: random_unit_vector -// Access: Protected -// Description: generates a random unit vector -//////////////////////////////////////////////////////////////////// +/** + * generates a random unit vector + */ INLINE LVector3 LinearRandomForce:: random_unit_vector() { PN_stdfloat z, r, theta; @@ -27,4 +24,3 @@ random_unit_vector() { return LVector3(r * ccos(theta), r * csin(theta), z); } - diff --git a/panda/src/physics/linearRandomForce.cxx b/panda/src/physics/linearRandomForce.cxx index a6cb34b2ed..252397c5bc 100644 --- a/panda/src/physics/linearRandomForce.cxx +++ b/panda/src/physics/linearRandomForce.cxx @@ -1,66 +1,54 @@ -// Filename: linearRandomForce.cxx -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearRandomForce.cxx + * @author charles + * @date 2000-06-19 + */ #include "linearRandomForce.h" TypeHandle LinearRandomForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearRandomForce -// Access: Protected -// Description: vector constructor -//////////////////////////////////////////////////////////////////// +/** + * vector constructor + */ LinearRandomForce:: LinearRandomForce(PN_stdfloat a, bool mass) : LinearForce(a, mass) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearRandomForce -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearRandomForce:: LinearRandomForce(const LinearRandomForce ©) : LinearForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearRandomForce -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearRandomForce:: ~LinearRandomForce() { } -//////////////////////////////////////////////////////////////////// -// Function: bounded_rand -// Access: Protected -// Description: Returns a float in [0, 1] -//////////////////////////////////////////////////////////////////// +/** + * Returns a float in [0, 1] + */ PN_stdfloat LinearRandomForce:: bounded_rand() { return ((PN_stdfloat)rand() / (PN_stdfloat)RAND_MAX); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearRandomForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -68,12 +56,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearRandomForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearRandomForce.h b/panda/src/physics/linearRandomForce.h index abeab21ee5..2c05fd9763 100644 --- a/panda/src/physics/linearRandomForce.h +++ b/panda/src/physics/linearRandomForce.h @@ -1,16 +1,15 @@ -// Filename: linearRandomForce.h -// Created by: charles (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearRandomForce.h + * @author charles + * @date 2000-06-19 + */ #ifndef LINEARRANDOMFORCE_H #define LINEARRANDOMFORCE_H @@ -20,14 +19,13 @@ #include "mathNumbers.h" #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearRandomForce -// Description : Pure virtual, parent to noiseForce and jitterForce -//////////////////////////////////////////////////////////////////// +/** + * Pure virtual, parent to noiseForce and jitterForce + */ class EXPCL_PANDAPHYSICS LinearRandomForce : public LinearForce { PUBLISHED: virtual ~LinearRandomForce(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearSinkForce.cxx b/panda/src/physics/linearSinkForce.cxx index 1928a5c318..bee27f2d48 100644 --- a/panda/src/physics/linearSinkForce.cxx +++ b/panda/src/physics/linearSinkForce.cxx @@ -1,88 +1,72 @@ -// Filename: linearSinkForce.cxx -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearSinkForce.cxx + * @author charles + * @date 2000-06-21 + */ #include "linearSinkForce.h" TypeHandle LinearSinkForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearSinkForce -// Access: Public -// Description: Simple constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple constructor + */ LinearSinkForce:: LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a, bool mass) : LinearDistanceForce(p, f, r, a, mass) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearSinkForce -// Access: Public -// Description: Simple constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple constructor + */ LinearSinkForce:: LinearSinkForce() : LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 1.0f, 1.0f, true) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearSinkForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearSinkForce:: LinearSinkForce(const LinearSinkForce ©) : LinearDistanceForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearSinkForce -// Access: Public -// Description: Simple destructor -//////////////////////////////////////////////////////////////////// +/** + * Simple destructor + */ LinearSinkForce:: ~LinearSinkForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearSinkForce:: make_copy() { return new LinearSinkForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Public -// Description: virtual force query -//////////////////////////////////////////////////////////////////// +/** + * virtual force query + */ LVector3 LinearSinkForce:: get_child_vector(const PhysicsObject *po) { return (get_force_center() - po->get_position()) * get_scalar_term(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearSinkForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -90,12 +74,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearSinkForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearSinkForce.h b/panda/src/physics/linearSinkForce.h index 863cb49116..00b3d5008c 100644 --- a/panda/src/physics/linearSinkForce.h +++ b/panda/src/physics/linearSinkForce.h @@ -1,26 +1,24 @@ -// Filename: linearSinkForce.h -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearSinkForce.h + * @author charles + * @date 2000-06-21 + */ #ifndef LINEARSINKFORCE_H #define LINEARSINKFORCE_H #include "linearDistanceForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearSinkForce -// Description : Attractor force. Think black hole. -//////////////////////////////////////////////////////////////////// +/** + * Attractor force. Think black hole. + */ class EXPCL_PANDAPHYSICS LinearSinkForce : public LinearDistanceForce { PUBLISHED: LinearSinkForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, @@ -28,7 +26,7 @@ PUBLISHED: LinearSinkForce(); LinearSinkForce(const LinearSinkForce ©); virtual ~LinearSinkForce(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearSourceForce.cxx b/panda/src/physics/linearSourceForce.cxx index bf7686899a..88db962127 100644 --- a/panda/src/physics/linearSourceForce.cxx +++ b/panda/src/physics/linearSourceForce.cxx @@ -1,88 +1,72 @@ -// Filename: linearSourceForce.cxx -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearSourceForce.cxx + * @author charles + * @date 2000-06-21 + */ #include "linearSourceForce.h" TypeHandle LinearSourceForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearSourceForce -// Access: Public -// Description: Simple constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple constructor + */ LinearSourceForce:: LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a, bool mass) : LinearDistanceForce(p, f, r, a, mass) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearSourceForce -// Access: Public -// Description: Simple constructor -//////////////////////////////////////////////////////////////////// +/** + * Simple constructor + */ LinearSourceForce:: LinearSourceForce() : LinearDistanceForce(LPoint3(0.0f, 0.0f, 0.0f), FT_ONE_OVER_R_SQUARED, 1.0f, 1.0f, true) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearSourceForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearSourceForce:: LinearSourceForce(const LinearSourceForce ©) : LinearDistanceForce(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearSourceForce -// Access: Public -// Description: Simple destructor -//////////////////////////////////////////////////////////////////// +/** + * Simple destructor + */ LinearSourceForce:: ~LinearSourceForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearSourceForce:: make_copy() { return new LinearSourceForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Public -// Description: virtual force query -//////////////////////////////////////////////////////////////////// +/** + * virtual force query + */ LVector3 LinearSourceForce:: get_child_vector(const PhysicsObject *po) { return (po->get_position() - get_force_center()) * get_scalar_term(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearSourceForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -90,12 +74,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearSourceForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearSourceForce.h b/panda/src/physics/linearSourceForce.h index ec08a2564c..9285a15780 100644 --- a/panda/src/physics/linearSourceForce.h +++ b/panda/src/physics/linearSourceForce.h @@ -1,26 +1,24 @@ -// Filename: linearSourceForce.h -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearSourceForce.h + * @author charles + * @date 2000-06-21 + */ #ifndef LINEARSOURCEFORCE_H #define LINEARSOURCEFORCE_H #include "linearDistanceForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearSourceForce -// Description : Repellant force. -//////////////////////////////////////////////////////////////////// +/** + * Repellant force. + */ class EXPCL_PANDAPHYSICS LinearSourceForce : public LinearDistanceForce { PUBLISHED: LinearSourceForce(const LPoint3& p, FalloffType f, PN_stdfloat r, PN_stdfloat a = 1.0f, @@ -28,7 +26,7 @@ PUBLISHED: LinearSourceForce(); LinearSourceForce(const LinearSourceForce ©); virtual ~LinearSourceForce(); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearUserDefinedForce.I b/panda/src/physics/linearUserDefinedForce.I index 7c9a539d4f..8c45f79142 100644 --- a/panda/src/physics/linearUserDefinedForce.I +++ b/panda/src/physics/linearUserDefinedForce.I @@ -1,21 +1,19 @@ -// Filename: linearUserDefinedForce.I -// Created by: charles (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearUserDefinedForce.I + * @author charles + * @date 2000-07-31 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_proc -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ void LinearUserDefinedForce:: set_proc(LVector3 (*proc)(const PhysicsObject *)) { _proc = proc; diff --git a/panda/src/physics/linearUserDefinedForce.cxx b/panda/src/physics/linearUserDefinedForce.cxx index 056af25062..4f6c4f4063 100644 --- a/panda/src/physics/linearUserDefinedForce.cxx +++ b/panda/src/physics/linearUserDefinedForce.cxx @@ -1,26 +1,23 @@ -// Filename: linearUserDefinedForce.cxx -// Created by: charles (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearUserDefinedForce.cxx + * @author charles + * @date 2000-07-31 + */ #include "linearUserDefinedForce.h" TypeHandle LinearUserDefinedForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearUserDefinedForce -// Access: Public -// Description: constructor -//////////////////////////////////////////////////////////////////// +/** + * constructor + */ LinearUserDefinedForce:: LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *), PN_stdfloat a, bool md) : @@ -29,52 +26,41 @@ LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *), { } -//////////////////////////////////////////////////////////////////// -// Function: LinearUserDefinedForce -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ LinearUserDefinedForce:: LinearUserDefinedForce(const LinearUserDefinedForce ©) : LinearForce(copy) { _proc = copy._proc; } -//////////////////////////////////////////////////////////////////// -// Function: ~LinearUserDefinedForce -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ LinearUserDefinedForce:: ~LinearUserDefinedForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Private, Virtual -// Description: child copier -//////////////////////////////////////////////////////////////////// +/** + * child copier + */ LinearForce *LinearUserDefinedForce:: make_copy() { return new LinearUserDefinedForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Private, Virtual -// Description: force builder -//////////////////////////////////////////////////////////////////// +/** + * force builder + */ LVector3 LinearUserDefinedForce:: get_child_vector(const PhysicsObject *po) { return _proc(po); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearUserDefinedForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -82,12 +68,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearUserDefinedForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearUserDefinedForce.h b/panda/src/physics/linearUserDefinedForce.h index 2a65583bc7..1edc850828 100644 --- a/panda/src/physics/linearUserDefinedForce.h +++ b/panda/src/physics/linearUserDefinedForce.h @@ -1,32 +1,29 @@ -// Filename: linearUserDefinedForce.h -// Created by: charles (31Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearUserDefinedForce.h + * @author charles + * @date 2000-07-31 + */ #ifndef LINEARUSERDEFINEDFORCE_H #define LINEARUSERDEFINEDFORCE_H #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearUserDefinedForce -// Description : a programmable force that takes an evaluator fn. -// -// NOTE : AS OF Interrogate => Squeak, this class does NOT -// get FFI'd due to the function pointer bug, and is -// currently NOT getting interrogated. Change this -// in the makefile when the time is right or this class -// becomes needed... -//////////////////////////////////////////////////////////////////// +/** + * a programmable force that takes an evaluator fn. + * + * NOTE : AS OF Interrogate => Squeak, this class does NOT get FFI'd due to + * the function pointer bug, and is currently NOT getting interrogated. + * Change this in the makefile when the time is right or this class becomes + * needed... + */ class EXPCL_PANDAPHYSICS LinearUserDefinedForce : public LinearForce { PUBLISHED: LinearUserDefinedForce(LVector3 (*proc)(const PhysicsObject *) = NULL, @@ -36,7 +33,7 @@ PUBLISHED: virtual ~LinearUserDefinedForce(); INLINE void set_proc(LVector3 (*proc)(const PhysicsObject *)); - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/linearVectorForce.I b/panda/src/physics/linearVectorForce.I index 3ed488ceb8..b5922df7dd 100644 --- a/panda/src/physics/linearVectorForce.I +++ b/panda/src/physics/linearVectorForce.I @@ -1,52 +1,43 @@ -// Filename: linearVectorForce.I -// Created by: charles (21Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearVectorForce.I + * @author charles + * @date 2000-06-21 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_vector -// Access: Public -// Description: encapsulating wrapper -//////////////////////////////////////////////////////////////////// +/** + * encapsulating wrapper + */ INLINE void LinearVectorForce:: set_vector(const LVector3& v) { _fvec = v; } -//////////////////////////////////////////////////////////////////// -// Function: set_vector -// Access: Public -// Description: piecewise encapsulating wrapper -//////////////////////////////////////////////////////////////////// +/** + * piecewise encapsulating wrapper + */ INLINE void LinearVectorForce:: set_vector(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _fvec.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: get_local_vector -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 LinearVectorForce:: get_local_vector() const { return _fvec; } -//////////////////////////////////////////////////////////////////// -// Function: LinearVectorForce::LinearVectorForce += LinearVectorForce -// Access: Public -// Description: Performs a memberwise addition between two LinearVectorForces. -//////////////////////////////////////////////////////////////////// +/** + * Performs a memberwise addition between two LinearVectorForces. + */ LinearVectorForce& LinearVectorForce:: operator += (const LinearVectorForce &other) { _fvec+=other._fvec; diff --git a/panda/src/physics/linearVectorForce.cxx b/panda/src/physics/linearVectorForce.cxx index e5828dbf3a..47848073ec 100644 --- a/panda/src/physics/linearVectorForce.cxx +++ b/panda/src/physics/linearVectorForce.cxx @@ -1,16 +1,15 @@ -// Filename: linearVectorForce.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearVectorForce.cxx + * @author charles + * @date 2000-06-14 + */ #include "datagram.h" #include "datagramIterator.h" @@ -21,74 +20,59 @@ TypeHandle LinearVectorForce::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LinearVectorForce -// Access: Public -// Description: Vector Constructor -//////////////////////////////////////////////////////////////////// +/** + * Vector Constructor + */ LinearVectorForce:: LinearVectorForce(const LVector3& vec, PN_stdfloat a, bool mass) : LinearForce(a, mass), _fvec(vec) { } -//////////////////////////////////////////////////////////////////// -// Function: LinearVectorForce -// Access: Public -// Description: Default/Piecewise constructor -//////////////////////////////////////////////////////////////////// +/** + * Default/Piecewise constructor + */ LinearVectorForce:: LinearVectorForce(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat a, bool mass) : LinearForce(a, mass) { _fvec.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: LinearVectorForce -// Access: Public -// Description: Copy Constructor -//////////////////////////////////////////////////////////////////// +/** + * Copy Constructor + */ LinearVectorForce:: LinearVectorForce(const LinearVectorForce ©) : LinearForce(copy) { _fvec = copy._fvec; } -//////////////////////////////////////////////////////////////////// -// Function: LinearVectorForce -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ LinearVectorForce:: ~LinearVectorForce() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: copier -//////////////////////////////////////////////////////////////////// +/** + * copier + */ LinearForce *LinearVectorForce:: make_copy() { return new LinearVectorForce(*this); } -//////////////////////////////////////////////////////////////////// -// Function: get_child_vector -// Access: Public -// Description: vector access -//////////////////////////////////////////////////////////////////// +/** + * vector access + */ LVector3 LinearVectorForce:: get_child_vector(const PhysicsObject *) { return _fvec; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearVectorForce:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -96,12 +80,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void LinearVectorForce:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/linearVectorForce.h b/panda/src/physics/linearVectorForce.h index 4fa1222001..59adca06cb 100644 --- a/panda/src/physics/linearVectorForce.h +++ b/panda/src/physics/linearVectorForce.h @@ -1,27 +1,25 @@ -// Filename: linearVectorForce.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linearVectorForce.h + * @author charles + * @date 2000-06-13 + */ #ifndef LINEARVECTORFORCE_H #define LINEARVECTORFORCE_H #include "linearForce.h" -//////////////////////////////////////////////////////////////////// -// Class : LinearVectorForce -// Description : Simple directed vector force. Suitable for -// gravity, non-turbulent wind, etc... -//////////////////////////////////////////////////////////////////// +/** + * Simple directed vector force. Suitable for gravity, non-turbulent wind, + * etc... + */ class EXPCL_PANDAPHYSICS LinearVectorForce : public LinearForce { PUBLISHED: LinearVectorForce(const LVector3& vec, PN_stdfloat a = 1.0f, bool mass = false); diff --git a/panda/src/physics/physical.I b/panda/src/physics/physical.I index afbc8d9bac..3b44d50917 100644 --- a/panda/src/physics/physical.I +++ b/panda/src/physics/physical.I @@ -1,83 +1,70 @@ -// Filename: physical.I -// Created by: charles (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physical.I + * @author charles + * @date 2000-06-16 + */ #include -//////////////////////////////////////////////////////////////////// -// Function: clear_linear_forces -// Access: Public -// Description: Erases the linear force list -//////////////////////////////////////////////////////////////////// +/** + * Erases the linear force list + */ INLINE void Physical:: clear_linear_forces() { _linear_forces.erase(_linear_forces.begin(), _linear_forces.end()); } -//////////////////////////////////////////////////////////////////// -// Function: clear_angular_forces -// Access: Public -// Description: Erases the angular force list -//////////////////////////////////////////////////////////////////// +/** + * Erases the angular force list + */ INLINE void Physical:: clear_angular_forces() { _angular_forces.erase(_angular_forces.begin(), _angular_forces.end()); } -//////////////////////////////////////////////////////////////////// -// Function: clear_physics_objects -// Access: Public -// Description: Erases the object list -//////////////////////////////////////////////////////////////////// +/** + * Erases the object list + */ INLINE void Physical:: clear_physics_objects() { _physics_objects.erase(_physics_objects.begin(), _physics_objects.end()); } -//////////////////////////////////////////////////////////////////// -// Function: add_linear_force -// Access: Public -// Description: Adds a linear force to the force list -//////////////////////////////////////////////////////////////////// +/** + * Adds a linear force to the force list + */ INLINE void Physical:: add_linear_force(LinearForce *f) { _linear_forces.push_back(f); } -//////////////////////////////////////////////////////////////////// -// Function: add_angular_force -// Access: Public -// Description: Adds an angular force to the force list -//////////////////////////////////////////////////////////////////// +/** + * Adds an angular force to the force list + */ INLINE void Physical:: add_angular_force(AngularForce *f) { _angular_forces.push_back(f); } -//////////////////////////////////////////////////////////////////// -// Function: remove_linear_force -// Access: Public -// Description: removes a linear force from the force list -//////////////////////////////////////////////////////////////////// +/** + * removes a linear force from the force list + */ INLINE void Physical:: remove_linear_force(LinearForce *f) { LinearForceVector::iterator found; - // this is a PT because the templates don't like what should be - // perfectly allowable, which is to search for bf directly. + // this is a PT because the templates don't like what should be perfectly + // allowable, which is to search for bf directly. PT(LinearForce) pt_lf = f; found = find(_linear_forces.begin(), _linear_forces.end(), pt_lf); @@ -87,11 +74,9 @@ remove_linear_force(LinearForce *f) { _linear_forces.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_angular_force -// Access: Public -// Description: removes an angular force from the force list -//////////////////////////////////////////////////////////////////// +/** + * removes an angular force from the force list + */ INLINE void Physical:: remove_angular_force(AngularForce *f) { AngularForceVector::iterator found; @@ -105,134 +90,118 @@ remove_angular_force(AngularForce *f) { _angular_forces.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: add_physics_object -// Access: Public -// Description: Adds an object to the physics object vector -//////////////////////////////////////////////////////////////////// +/** + * Adds an object to the physics object vector + */ INLINE void Physical:: add_physics_object(PhysicsObject *po) { _physics_objects.push_back(po); } -//////////////////////////////////////////////////////////////////// -// Function: get_physics_manager -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PhysicsManager *Physical:: get_physics_manager() const { return _physics_manager; } -//////////////////////////////////////////////////////////////////// -// Function: get_phys_body -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PhysicsObject *Physical:: get_phys_body() const { return _phys_body; } -//////////////////////////////////////////////////////////////////// -// Function: get_physical_node -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PhysicalNode *Physical:: get_physical_node() const { return _physical_node; } -//////////////////////////////////////////////////////////////////// -// Function: get_physical_node_path -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE NodePath Physical:: get_physical_node_path() const { return NodePath((PandaNode*) _physical_node); } -//////////////////////////////////////////////////////////////////// -// Function: get_object_vector -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const PhysicsObject::Vector &Physical:: get_object_vector() const { return _physics_objects; } -//////////////////////////////////////////////////////////////////// -// Function: get_linear_forces -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const Physical::LinearForceVector &Physical:: get_linear_forces() const { return _linear_forces; } -//////////////////////////////////////////////////////////////////// -// Function: get_angular_forces -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE const Physical::AngularForceVector &Physical:: get_angular_forces() const { return _angular_forces; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_linear_forces -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int Physical:: get_num_linear_forces() const { return _linear_forces.size(); } -//////////////////////////////////////////////////////////////////// -// Function: get_linear_force -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PT(LinearForce) Physical:: get_linear_force(int index) const { nassertr(index >= 0 && index < (int)_linear_forces.size(), NULL); return _linear_forces[index]; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_angular_forces -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int Physical:: get_num_angular_forces() const { return _angular_forces.size(); } -//////////////////////////////////////////////////////////////////// -// Function: get_angular_force -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PT(AngularForce) Physical:: get_angular_force(int index) const { nassertr(index >= 0 && index < (int)_angular_forces.size(), NULL); return _angular_forces[index]; } -//////////////////////////////////////////////////////////////////// -// Function: set_viscosity -// Access: Public -// Description: Set the local viscosity. -//////////////////////////////////////////////////////////////////// +/** + * Set the local viscosity. + */ INLINE void Physical:: set_viscosity(PN_stdfloat viscosity) { _viscosity=viscosity; } -//////////////////////////////////////////////////////////////////// -// Function: get_viscosity -// Access: Public -// Description: Get the local viscosity. -//////////////////////////////////////////////////////////////////// +/** + * Get the local viscosity. + */ INLINE PN_stdfloat Physical:: get_viscosity() const { - //zzzzzzzzzzzzzzzz return max(_viscosity, get_physics_manager()->get_viscosity()); + // zzzzzzzzzzzzzzzz return max(_viscosity, + // get_physics_manager()->get_viscosity()); return _viscosity; } diff --git a/panda/src/physics/physical.cxx b/panda/src/physics/physical.cxx index 4b912d6538..d67b957595 100644 --- a/panda/src/physics/physical.cxx +++ b/panda/src/physics/physical.cxx @@ -1,16 +1,15 @@ -// Filename: physical.cxx -// Created by: charles (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physical.cxx + * @author charles + * @date 2000-06-16 + */ #include "pointerTo.h" @@ -19,23 +18,17 @@ TypeHandle Physical::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Physical -// Access: Public -// Description: Default Constructor -// The idea here is that most physicals will NOT -// be collections of sets (i.e. particle systems -// and whatever else). Because of this, the default -// constructor, unless otherwise specified, will -// automatically allocate and initialize one -// PhysicalObject. This makes it easier for -// high-level work. -// -// pre-alloc is ONLY for multiple-object physicals, -// and if true, fills the physics_object vector -// with dead nodes, pre-allocating for the speed -// end of the speed-vs-overhead deal. -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor The idea here is that most physicals will NOT be + * collections of sets (i.e. particle systems and whatever else). Because of + * this, the default constructor, unless otherwise specified, will + * automatically allocate and initialize one PhysicalObject. This makes it + * easier for high-level work. + * + * pre-alloc is ONLY for multiple-object physicals, and if true, fills the + * physics_object vector with dead nodes, pre-allocating for the speed end of + * the speed-vs-overhead deal. + */ Physical:: Physical(int total_objects, bool pre_alloc) { _viscosity=0.0; @@ -57,13 +50,10 @@ Physical(int total_objects, bool pre_alloc) { } } -//////////////////////////////////////////////////////////////////// -// Function: Physical -// Access: Public -// Description: copy constructor (note- does deep copy of pn's) -// but does NOT attach itself to its template's -// physicsmanager. -//////////////////////////////////////////////////////////////////// +/** + * copy constructor (note- does deep copy of pn's) but does NOT attach itself + * to its template's physicsmanager. + */ Physical:: Physical(const Physical& copy) { _physics_manager = (PhysicsManager *) NULL; @@ -99,26 +89,23 @@ Physical(const Physical& copy) { _phys_body = (PhysicsObject *) NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ~Physical -// Access: Public -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ Physical:: ~Physical() { - // note that this removes a physical from a physics manager. - // this is safe because the physics manager doesn't keep PT's to - // physicals, simply *'s, and also means that we don't have to tell - // the physics manager ourselves when one of our physicals is dead. + // note that this removes a physical from a physics manager. this is safe + // because the physics manager doesn't keep PT's to physicals, simply *'s, + // and also means that we don't have to tell the physics manager ourselves + // when one of our physicals is dead. if (_physics_manager != (PhysicsManager *) NULL) { _physics_manager->remove_physical(this); } } -//////////////////////////////////////////////////////////////////// -// Function: get_objects -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ const PhysicsObjectCollection Physical:: get_objects() const{ PhysicsObjectCollection poc; @@ -132,12 +119,9 @@ get_objects() const{ return poc; } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Physical:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -145,12 +129,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_physics_objects -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Physical:: write_physics_objects(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -164,12 +145,9 @@ write_physics_objects(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_linear_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Physical:: write_linear_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -183,12 +161,9 @@ write_linear_forces(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_angular_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Physical:: write_angular_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -202,12 +177,9 @@ write_angular_forces(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void Physical:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/physical.h b/panda/src/physics/physical.h index ed1fd48ca8..0a9ca1d07c 100644 --- a/panda/src/physics/physical.h +++ b/panda/src/physics/physical.h @@ -1,16 +1,15 @@ -// Filename: physical.h -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physical.h + * @author charles + * @date 2000-06-14 + */ #ifndef PHYSICAL_H #define PHYSICAL_H @@ -31,15 +30,13 @@ class PhysicalNode; class PhysicsManager; -//////////////////////////////////////////////////////////////////// -// Class : Physical -// Description : Defines a set of physically modeled attributes. -// If you want physics applied to your class, derive -// it from this. -//////////////////////////////////////////////////////////////////// +/** + * Defines a set of physically modeled attributes. If you want physics + * applied to your class, derive it from this. + */ class EXPCL_PANDAPHYSICS Physical : public TypedReferenceCount { public: - //typedef pvector PhysicsObjectVector; + // typedef pvector PhysicsObjectVector; typedef pvector LinearForceVector; typedef pvector AngularForceVector; @@ -73,7 +70,7 @@ PUBLISHED: INLINE void set_viscosity(PN_stdfloat viscosity); INLINE PN_stdfloat get_viscosity() const; - + const PhysicsObjectCollection get_objects() const; virtual void output(ostream &out = cout) const; @@ -100,11 +97,11 @@ protected: LinearForceVector _linear_forces; AngularForceVector _angular_forces; - // this pointer exists to make life easy. If a physical exists - // with only one element (i.e. NOT a particle system or set-physical), - // then this pointer points at the only PhysicsObject. The object - // is still of course contained in the _physics_objects vector, but - // this is kind of a quicker way there. + // this pointer exists to make life easy. If a physical exists with only + // one element (i.e. NOT a particle system or set-physical), then this + // pointer points at the only PhysicsObject. The object is still of course + // contained in the _physics_objects vector, but this is kind of a quicker + // way there. PhysicsObject *_phys_body; private: diff --git a/panda/src/physics/physicalNode.I b/panda/src/physics/physicalNode.I index f1ecbb7a2d..6296926055 100644 --- a/panda/src/physics/physicalNode.I +++ b/panda/src/physics/physicalNode.I @@ -1,30 +1,27 @@ -// Filename: physicalNode.I -// Created by: charles (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicalNode.I + * @author charles + * @date 2000-08-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: clear -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PhysicalNode:: clear() { _physicals.erase(_physicals.begin(), _physicals.end()); } -//////////////////////////////////////////////////////////////////// -// Function: get_physical -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE Physical *PhysicalNode:: get_physical(int index) const { nassertr(index >= 0 && index < (int)_physicals.size(), @@ -32,19 +29,17 @@ get_physical(int index) const { return _physicals[index]; } -//////////////////////////////////////////////////////////////////// -// Function: get_num_physicals -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE int PhysicalNode:: get_num_physicals() const { return _physicals.size(); } -//////////////////////////////////////////////////////////////////// -// Function: add_physical -// Access: Public -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE void PhysicalNode:: add_physical(Physical *physical) { _physicals.push_back(physical); diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 99b70717ab..e10c29b625 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -1,67 +1,56 @@ -// Filename: physicalNode.cxx -// Created by: charles (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicalNode.cxx + * @author charles + * @date 2000-08-01 + */ #include "physicalNode.h" // static stuff. TypeHandle PhysicalNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysicalNode -// Access: Public -// Description: default constructor -//////////////////////////////////////////////////////////////////// +/** + * default constructor + */ PhysicalNode:: PhysicalNode(const string &name) : PandaNode(name) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicalNode -// Access: Protected -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ PhysicalNode:: PhysicalNode(const PhysicalNode ©) : PandaNode(copy), _physicals(copy._physicals) { } -//////////////////////////////////////////////////////////////////// -// Function: ~PhysicalNode -// Access: Protected, Virtual -// Description: destructor -//////////////////////////////////////////////////////////////////// +/** + * destructor + */ PhysicalNode:: ~PhysicalNode() { } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: dynamic child copy -//////////////////////////////////////////////////////////////////// +/** + * dynamic child copy + */ PandaNode *PhysicalNode:: make_copy() const { return new PhysicalNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: add_physicals_from -// Access: Public -// Description: append operation -//////////////////////////////////////////////////////////////////// +/** + * append operation + */ void PhysicalNode:: add_physicals_from(const PhysicalNode &other) { pvector< PT(Physical) >::iterator last = _physicals.end() - 1; @@ -74,11 +63,9 @@ add_physicals_from(const PhysicalNode &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: remove_physical -// Access: Public -// Description: remove operation -//////////////////////////////////////////////////////////////////// +/** + * remove operation + */ void PhysicalNode:: remove_physical(Physical *physical) { pvector< PT(Physical) >::iterator found; @@ -89,11 +76,9 @@ remove_physical(Physical *physical) { _physicals.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_physical -// Access: Public -// Description: remove operation -//////////////////////////////////////////////////////////////////// +/** + * remove operation + */ void PhysicalNode:: remove_physical(int index) { nassertv(index >= 0 && index <= (int)_physicals.size()); @@ -105,16 +90,13 @@ remove_physical(int index) { _physicals.erase(remove); } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicalNode:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""; out<<"PhysicalNode:\n"; - //PandaNode::write(out, indent+2); + // PandaNode::write(out, indent+2); #endif //] NDEBUG } diff --git a/panda/src/physics/physicalNode.h b/panda/src/physics/physicalNode.h index e79ef73cbc..80e925dc13 100644 --- a/panda/src/physics/physicalNode.h +++ b/panda/src/physics/physicalNode.h @@ -1,16 +1,15 @@ -// Filename: physicalNode.h -// Created by: charles (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicalNode.h + * @author charles + * @date 2000-08-01 + */ #ifndef PHYSICALNODE_H #define PHYSICALNODE_H @@ -23,11 +22,9 @@ #include "physical.h" #include "config_physics.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysicalNode -// Description : Graph node that encapsulated a series of physical -// objects -//////////////////////////////////////////////////////////////////// +/** + * Graph node that encapsulated a series of physical objects + */ class EXPCL_PANDAPHYSICS PhysicalNode : public PandaNode { PUBLISHED: PhysicalNode(const string &name); diff --git a/panda/src/physics/physicsCollisionHandler.I b/panda/src/physics/physicsCollisionHandler.I index 9dd459b619..48349b00fc 100644 --- a/panda/src/physics/physicsCollisionHandler.I +++ b/panda/src/physics/physicsCollisionHandler.I @@ -1,17 +1,15 @@ -// Filename: physicsCollisionHandler.I -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsCollisionHandler.I + * @author drose + * @date 2002-03-16 + */ INLINE void PhysicsCollisionHandler:: set_almost_stationary_speed(PN_stdfloat speed) { @@ -42,5 +40,3 @@ INLINE PN_stdfloat PhysicsCollisionHandler:: get_dynamic_friction_coef() { return _dynamic_friction_coef; } - - diff --git a/panda/src/physics/physicsCollisionHandler.cxx b/panda/src/physics/physicsCollisionHandler.cxx index 64d2cdbf15..f3be69e927 100644 --- a/panda/src/physics/physicsCollisionHandler.cxx +++ b/panda/src/physics/physicsCollisionHandler.cxx @@ -1,16 +1,15 @@ -// Filename: physicsCollisionHandler.cxx -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsCollisionHandler.cxx + * @author drose + * @date 2002-03-16 + */ #include "physicsCollisionHandler.h" #include "collisionNode.h" @@ -23,11 +22,9 @@ TypeHandle PhysicsCollisionHandler::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysicsCollisionHandler:: PhysicsCollisionHandler() { _almost_stationary_speed = 0.1f; @@ -36,21 +33,16 @@ PhysicsCollisionHandler() { set_horizontal(false); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysicsCollisionHandler:: ~PhysicsCollisionHandler() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::apply_friction -// Access: -// Description: The vel parameter will be modified in place to -// account for friction. -//////////////////////////////////////////////////////////////////// +/** + * The vel parameter will be modified in place to account for friction. + */ void PhysicsCollisionHandler:: apply_friction(ColliderDef &def, LVector3& vel, const LVector3& force, PN_stdfloat angle) { @@ -82,11 +74,9 @@ apply_friction(ColliderDef &def, LVector3& vel, const LVector3& force, } } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::apply_net_shove -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysicsCollisionHandler:: apply_net_shove(ColliderDef &def, const LVector3& net_shove, const LVector3 &force) { @@ -109,17 +99,16 @@ apply_net_shove(ColliderDef &def, const LVector3& net_shove, physics_debug(" force "<get_mat(); - //physics_debug( - // " adjustment trn "<get_mat(); + // physics_debug( " adjustment trn "<get_physics_object()->get_lcs(); physics_debug( @@ -145,12 +134,12 @@ apply_net_shove(ColliderDef &def, const LVector3& net_shove, adjustment*=adjustmentLength; physics_debug( " adjustment mul "< 10.0f) { - // This is a check to see if the velocity is higher than I expect it - // to go. The check value is arbitrary. + // This is a check to see if the velocity is higher than I expect it to + // go. The check value is arbitrary. physics_debug(" vel.length() > 10.0f "<get_physics_object()->set_velocity(vel); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::apply_linear_force -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysicsCollisionHandler:: apply_linear_force(ColliderDef &def, const LVector3 &force) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsCollisionHandler::validate_target -// Access: Protected, Virtual -// Description: Called internally to validate the target passed to -// add_collider(). Returns true if acceptable, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to validate the target passed to add_collider(). Returns + * true if acceptable, false otherwise. + */ bool PhysicsCollisionHandler:: validate_target(const NodePath &target) { if (!CollisionHandlerPhysical::validate_target(target)) { diff --git a/panda/src/physics/physicsCollisionHandler.h b/panda/src/physics/physicsCollisionHandler.h index a1933f2e3f..8811a88756 100644 --- a/panda/src/physics/physicsCollisionHandler.h +++ b/panda/src/physics/physicsCollisionHandler.h @@ -1,16 +1,15 @@ -// Filename: physicsCollisionHandler.h -// Created by: drose (16Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsCollisionHandler.h + * @author drose + * @date 2002-03-16 + */ #ifndef PHYSICSCOLLISIONHANDLER_H #define PHYSICSCOLLISIONHANDLER_H @@ -19,25 +18,24 @@ #include "collisionHandlerPusher.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysicsCollisionHandler -// Description : A specialized kind of CollisionHandler that simply -// pushes back on things that attempt to move into solid -// walls. This also puts forces onto the physics objects -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDAPHYSICS PhysicsCollisionHandler : +/** + * A specialized kind of CollisionHandler that simply pushes back on things + * that attempt to move into solid walls. This also puts forces onto the + * physics objects + */ +class EXPCL_PANDAPHYSICS PhysicsCollisionHandler : public CollisionHandlerPusher { PUBLISHED: PhysicsCollisionHandler(); virtual ~PhysicsCollisionHandler(); - + // These setters and getter are a bit of a hack: INLINE void set_almost_stationary_speed(PN_stdfloat speed); INLINE PN_stdfloat get_almost_stationary_speed(); - + INLINE void set_static_friction_coef(PN_stdfloat coef); INLINE PN_stdfloat get_static_friction_coef(); - + INLINE void set_dynamic_friction_coef(PN_stdfloat coef); INLINE PN_stdfloat get_dynamic_friction_coef(); @@ -76,6 +74,3 @@ private: #include "physicsCollisionHandler.I" #endif - - - diff --git a/panda/src/physics/physicsManager.I b/panda/src/physics/physicsManager.I index eb37cd577c..e9c128c641 100644 --- a/panda/src/physics/physicsManager.I +++ b/panda/src/physics/physicsManager.I @@ -1,22 +1,19 @@ -// Filename: physicsManager.I -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsManager.I + * @author charles + * @date 2000-06-14 + */ -//////////////////////////////////////////////////////////////////// -// Function: attach_physical -// Access: Public -// Description: Registers a Physical class with the manager -//////////////////////////////////////////////////////////////////// +/** + * Registers a Physical class with the manager + */ INLINE void PhysicsManager:: attach_physical(Physical *p) { nassertv(p && p->_physics_manager == NULL); @@ -28,11 +25,9 @@ attach_physical(Physical *p) { } } -//////////////////////////////////////////////////////////////////// -// Function: attach_linear_force -// Access: Public -// Description: Adds a global linear force to the physics manager -//////////////////////////////////////////////////////////////////// +/** + * Adds a global linear force to the physics manager + */ INLINE void PhysicsManager:: add_linear_force(LinearForce *f) { nassertv(f); @@ -44,11 +39,9 @@ add_linear_force(LinearForce *f) { } } -//////////////////////////////////////////////////////////////////// -// Function: attach_physicalnode -// Access: Public -// Description: Please call attach_physical_node instead. -//////////////////////////////////////////////////////////////////// +/** + * Please call attach_physical_node instead. + */ INLINE void PhysicsManager:: attach_physicalnode(PhysicalNode *p) { cerr<<"attach_physicalnode (aka attachPhysicalnode) has been" @@ -58,11 +51,9 @@ attach_physicalnode(PhysicalNode *p) { attach_physical_node(p); } -//////////////////////////////////////////////////////////////////// -// Function: attach_physical_node -// Access: Public -// Description: Registers a physicalnode with the manager -//////////////////////////////////////////////////////////////////// +/** + * Registers a physicalnode with the manager + */ INLINE void PhysicsManager:: attach_physical_node(PhysicalNode *p) { nassertv(p); @@ -71,21 +62,17 @@ attach_physical_node(PhysicalNode *p) { } } -//////////////////////////////////////////////////////////////////// -// Function: clear_linear_forces -// Access: Public -// Description: Resets the physics manager force vector -//////////////////////////////////////////////////////////////////// +/** + * Resets the physics manager force vector + */ INLINE void PhysicsManager:: clear_linear_forces() { _linear_forces.erase(_linear_forces.begin(), _linear_forces.end()); } -//////////////////////////////////////////////////////////////////// -// Function: attach_angular_force -// Access: Public -// Description: Adds a global angular force to the physics manager -//////////////////////////////////////////////////////////////////// +/** + * Adds a global angular force to the physics manager + */ INLINE void PhysicsManager:: add_angular_force(AngularForce *f) { nassertv(f); @@ -96,62 +83,50 @@ add_angular_force(AngularForce *f) { _angular_forces.push_back(f); } -//////////////////////////////////////////////////////////////////// -// Function: clear_angular_forces -// Access: Public -// Description: Resets the physics manager force vector -//////////////////////////////////////////////////////////////////// +/** + * Resets the physics manager force vector + */ INLINE void PhysicsManager:: clear_angular_forces() { _angular_forces.erase(_angular_forces.begin(), _angular_forces.end()); } -//////////////////////////////////////////////////////////////////// -// Function: clear_physicals -// Access: Public -// Description: Resets the physics manager objects vector -//////////////////////////////////////////////////////////////////// +/** + * Resets the physics manager objects vector + */ INLINE void PhysicsManager:: clear_physicals() { _physicals.erase(_physicals.begin(), _physicals.end()); } -//////////////////////////////////////////////////////////////////// -// Function: set_viscosity -// Access: Public -// Description: Set the global viscosity. -//////////////////////////////////////////////////////////////////// +/** + * Set the global viscosity. + */ INLINE void PhysicsManager:: set_viscosity(PN_stdfloat viscosity) { _viscosity=viscosity; } -//////////////////////////////////////////////////////////////////// -// Function: get_viscosity -// Access: Public -// Description: Get the global viscosity. -//////////////////////////////////////////////////////////////////// +/** + * Get the global viscosity. + */ INLINE PN_stdfloat PhysicsManager:: get_viscosity() const { return _viscosity; } -//////////////////////////////////////////////////////////////////// -// Function: attach_linear_integrator -// Access: Public -// Description: Hooks a linear integrator into the manager -//////////////////////////////////////////////////////////////////// +/** + * Hooks a linear integrator into the manager + */ INLINE void PhysicsManager:: attach_linear_integrator(LinearIntegrator *i) { nassertv(i); _linear_integrator = i; } -//////////////////////////////////////////////////////////////////// -// Function: attach_angular_integrator -// Access: Public -// Description: Hooks an angular integrator into the manager -//////////////////////////////////////////////////////////////////// +/** + * Hooks an angular integrator into the manager + */ INLINE void PhysicsManager:: attach_angular_integrator(AngularIntegrator *i) { nassertv(i); diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 5c26cead3d..b108176dd6 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -1,16 +1,15 @@ -// Filename: physicsManager.cxx -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsManager.cxx + * @author charles + * @date 2000-06-14 + */ #include "physicsManager.h" #include "actorNode.h" @@ -21,12 +20,9 @@ ConfigVariableInt PhysicsManager::_random_seed ("physics_manager_random_seed", 139); -//////////////////////////////////////////////////////////////////// -// Function: PhysicsManager -// Access: Public -// Description: Default Constructor. NOTE: EulerIntegrator is -// the standard default. -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor. NOTE: EulerIntegrator is the standard default. + */ PhysicsManager:: PhysicsManager() { _linear_integrator.clear(); @@ -34,11 +30,9 @@ PhysicsManager() { _viscosity=0.0; } -//////////////////////////////////////////////////////////////////// -// Function: ~PhysicsManager -// Access: Public -// Description: Simple Destructor -//////////////////////////////////////////////////////////////////// +/** + * Simple Destructor + */ PhysicsManager:: ~PhysicsManager() { PhysicalsVector::iterator pi; @@ -48,25 +42,20 @@ PhysicsManager:: } } -//////////////////////////////////////////////////////////////////// -// Function: InitRandomSeed -// Access: Public -// Description: One-time config function, sets up the random seed -// used by the physics and particle systems. -// For synchronizing across distributed computers -//////////////////////////////////////////////////////////////////// +/** + * One-time config function, sets up the random seed used by the physics and + * particle systems. For synchronizing across distributed computers + */ void PhysicsManager:: init_random_seed() { - // Use the random seed specified by the physics_manager_random_seed - // Config Variable + // Use the random seed specified by the physics_manager_random_seed Config + // Variable srand(_random_seed); } -//////////////////////////////////////////////////////////////////// -// Function: remove_linear_force -// Access: Public -// Description: takes a linear force out of the physics list -//////////////////////////////////////////////////////////////////// +/** + * takes a linear force out of the physics list + */ void PhysicsManager:: remove_linear_force(LinearForce *f) { nassertv(f); @@ -81,11 +70,9 @@ remove_linear_force(LinearForce *f) { _linear_forces.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_angular_force -// Access: Public -// Description: takes an angular force out of the physics list -//////////////////////////////////////////////////////////////////// +/** + * takes an angular force out of the physics list + */ void PhysicsManager:: remove_angular_force(AngularForce *f) { nassertv(f); @@ -100,11 +87,9 @@ remove_angular_force(AngularForce *f) { _angular_forces.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_physical -// Access: Public -// Description: takes a physical out of the object list -//////////////////////////////////////////////////////////////////// +/** + * takes a physical out of the object list + */ void PhysicsManager:: remove_physical(Physical *p) { nassertv(p); @@ -119,11 +104,9 @@ remove_physical(Physical *p) { _physicals.erase(found); } -//////////////////////////////////////////////////////////////////// -// Function: remove_physical_node -// Access: Public -// Description: Removes a physicalnode from the manager -//////////////////////////////////////////////////////////////////// +/** + * Removes a physicalnode from the manager + */ void PhysicsManager:: remove_physical_node(PhysicalNode *p) { nassertv(p); @@ -132,12 +115,10 @@ remove_physical_node(PhysicalNode *p) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoPhysics -// Access: Public -// Description: This is the main high-level API call. Performs -// integration on every attached Physical. -//////////////////////////////////////////////////////////////////// +/** + * This is the main high-level API call. Performs integration on every + * attached Physical. + */ void PhysicsManager:: do_physics(PN_stdfloat dt) { // now, run through each physics object in the set. @@ -146,14 +127,12 @@ do_physics(PN_stdfloat dt) { Physical *physical = *p_cur; nassertv(physical); - // do linear - //if (_linear_integrator.is_null() == false) { + // do linear if (_linear_integrator.is_null() == false) { if (_linear_integrator) { _linear_integrator->integrate(physical, _linear_forces, dt); } - // do angular - //if (_angular_integrator.is_null() == false) { + // do angular if (_angular_integrator.is_null() == false) { if (_angular_integrator) { _angular_integrator->integrate(physical, _angular_forces, dt); } @@ -167,25 +146,20 @@ do_physics(PN_stdfloat dt) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoPhysics -// Access: Public -// Description: This is the main high-level API call. Performs -// integration on a single physical. Make sure its -// associated forces are active. -//////////////////////////////////////////////////////////////////// +/** + * This is the main high-level API call. Performs integration on a single + * physical. Make sure its associated forces are active. + */ void PhysicsManager:: do_physics(PN_stdfloat dt, Physical *physical) { nassertv(physical); - // do linear - //if (_linear_integrator.is_null() == false) { + // do linear if (_linear_integrator.is_null() == false) { if (_linear_integrator) { _linear_integrator->integrate(physical, _linear_forces, dt); } - // do angular - //if (_angular_integrator.is_null() == false) { + // do angular if (_angular_integrator.is_null() == false) { if (_angular_integrator) { _angular_integrator->integrate(physical, _angular_forces, dt); } @@ -198,12 +172,9 @@ do_physics(PN_stdfloat dt, Physical *physical) { } } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -211,12 +182,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_physicals -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: write_physicals(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -225,7 +193,7 @@ write_physicals(ostream &out, unsigned int indent) const { } out.width(indent); out<<""<<"_physicals ("<<_physicals.size()<<" physicals)\n"; - //out<::const_iterator i=_physicals.begin(); i != _physicals.end(); ++i) { @@ -234,12 +202,9 @@ write_physicals(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: write_linear_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -253,12 +218,9 @@ write_linear_forces(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write_angular_forces -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: write_angular_forces(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -272,12 +234,9 @@ write_angular_forces(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ @@ -305,18 +264,15 @@ write(ostream &out, unsigned int indent) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsManager:: debug_output(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ out.width(indent); out<<""<<"PhysicsManager li"<<(_linear_integrator?1:0)<<" ai"<<(_angular_integrator?1:0)<<"\n"; out<<" _physicals "<<_physicals.size()<<"\n"; - //_physicals._phys_body.write(out, indent+2); + // _physicals._phys_body.write(out, indent+2); out.width(indent+2); diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 4d901de177..80319ef2f0 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -1,16 +1,15 @@ -// Filename: physicsManager.h -// Created by: charles (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsManager.h + * @author charles + * @date 2000-06-14 + */ #ifndef PHYSICSMANAGER_H #define PHYSICSMANAGER_H @@ -30,21 +29,18 @@ #include "configVariableInt.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysicsManager -// Description : Physics don't get much higher-level than this. -// Attach as many Physicals (particle systems, etc..) -// as you want, pick an integrator and go. -//////////////////////////////////////////////////////////////////// +/** + * Physics don't get much higher-level than this. Attach as many Physicals + * (particle systems, etc..) as you want, pick an integrator and go. + */ class EXPCL_PANDAPHYSICS PhysicsManager { public: - // NOTE that the physicals container is NOT reference counted. - // this does indeed mean that you are NOT supposed to use this - // as a primary storage container for the physicals. This is so - // because physicals, on their death, ask to be removed from their - // current physicsmanager, if one exists, relieving the client from - // the task and also allowing for dynamically created and destroyed - // physicals. + // NOTE that the physicals container is NOT reference counted. this does + // indeed mean that you are NOT supposed to use this as a primary storage + // container for the physicals. This is so because physicals, on their + // death, ask to be removed from their current physicsmanager, if one + // exists, relieving the client from the task and also allowing for + // dynamically created and destroyed physicals. typedef pvector PhysicalsVector; typedef pvector LinearForceVector; typedef pvector AngularForceVector; @@ -66,7 +62,7 @@ PUBLISHED: INLINE void set_viscosity(PN_stdfloat viscosity); INLINE PN_stdfloat get_viscosity() const; - + void remove_physical(Physical *p); void remove_physical_node(PhysicalNode *p); void remove_linear_force(LinearForce *f); @@ -74,7 +70,7 @@ PUBLISHED: void do_physics(PN_stdfloat dt); void do_physics(PN_stdfloat dt, Physical *p); void init_random_seed(); - + virtual void output(ostream &out) const; virtual void write_physicals(ostream &out, unsigned int indent=0) const; virtual void write_linear_forces(ostream &out, unsigned int indent=0) const; diff --git a/panda/src/physics/physicsObject.I b/panda/src/physics/physicsObject.I index dd430752c6..327d92461f 100644 --- a/panda/src/physics/physicsObject.I +++ b/panda/src/physics/physicsObject.I @@ -1,58 +1,47 @@ -// Filename: physicsObject.I -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObject.I + * @author charles + * @date 2000-06-13 + */ -//////////////////////////////////////////////////////////////////// -// Function: set_mass -// Access: Public -// Description: Set the mass in slugs (or kilograms). -//////////////////////////////////////////////////////////////////// +/** + * Set the mass in slugs (or kilograms). + */ INLINE void PhysicsObject:: set_mass(PN_stdfloat m) { nassertv(m > 0); _mass = m; } -//////////////////////////////////////////////////////////////////// -// Function: set_position -// Access: Public -// Description: Vector position assignment. This is also used as -// the center of mass. -//////////////////////////////////////////////////////////////////// +/** + * Vector position assignment. This is also used as the center of mass. + */ INLINE void PhysicsObject:: set_position(const LPoint3 &pos) { nassertv(!pos.is_nan()); _position = pos; } -//////////////////////////////////////////////////////////////////// -// Function: set_position -// Access: Public -// Description: Piecewise position assignment -//////////////////////////////////////////////////////////////////// +/** + * Piecewise position assignment + */ INLINE void PhysicsObject:: set_position(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { nassertv(!LPoint3(x, y, z).is_nan()); _position.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: reset_position -// Access: Public -// Description: use this to place an object in a completely new -// position, that has nothing to do with its last -// position. -//////////////////////////////////////////////////////////////////// +/** + * use this to place an object in a completely new position, that has nothing + * to do with its last position. + */ INLINE void PhysicsObject:: reset_position(const LPoint3 &pos) { nassertv(!pos.is_nan()); @@ -61,12 +50,9 @@ reset_position(const LPoint3 &pos) { _velocity.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: reset_orientation -// Access: Public -// Description: set the orientation while clearing the rotation -// velocity. -//////////////////////////////////////////////////////////////////// +/** + * set the orientation while clearing the rotation velocity. + */ INLINE void PhysicsObject:: reset_orientation(const LOrientation &orientation) { nassertv(!orientation.is_nan()); @@ -74,243 +60,195 @@ reset_orientation(const LOrientation &orientation) { _rotation = LRotation::ident_quat(); } -//////////////////////////////////////////////////////////////////// -// Function: set_last_position -// Access: Public -// Description: Last position assignment -//////////////////////////////////////////////////////////////////// +/** + * Last position assignment + */ INLINE void PhysicsObject:: set_last_position(const LPoint3 &pos) { _last_position = pos; } -//////////////////////////////////////////////////////////////////// -// Function: set_velocity -// Access: Public -// Description: Vector velocity assignment -//////////////////////////////////////////////////////////////////// +/** + * Vector velocity assignment + */ INLINE void PhysicsObject:: set_velocity(const LVector3 &vel) { nassertv(!vel.is_nan()); _velocity = vel; } -//////////////////////////////////////////////////////////////////// -// Function: set_velocity -// Access: Public -// Description: Piecewise velocity assignment -//////////////////////////////////////////////////////////////////// +/** + * Piecewise velocity assignment + */ INLINE void PhysicsObject:: set_velocity(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { nassertv(!LVector3(x, y, z).is_nan()); _velocity.set(x, y, z); } -//////////////////////////////////////////////////////////////////// -// Function: add_local_torque -// Access: Public -// Description: Adds an torque force (i.e. an instantanious change -// in velocity). This is a quicker way to get the -// angular velocity, add a vector to it and set that -// value to be the new angular velocity. -//////////////////////////////////////////////////////////////////// +/** + * Adds an torque force (i.e. an instantanious change in velocity). This is + * a quicker way to get the angular velocity, add a vector to it and set that + * value to be the new angular velocity. + */ INLINE void PhysicsObject:: add_local_torque(const LRotation &torque) { nassertv(!torque.is_nan()); _rotation+=_orientation.xform(torque); } -//////////////////////////////////////////////////////////////////// -// Function: add_local_impulse -// Access: Public -// Description: Adds an impulse force (i.e. an instantanious change -// in velocity). This is a quicker way to get the -// velocity, add a vector to it and set that value to -// be the new velocity. -//////////////////////////////////////////////////////////////////// +/** + * Adds an impulse force (i.e. an instantanious change in velocity). This is + * a quicker way to get the velocity, add a vector to it and set that value to + * be the new velocity. + */ INLINE void PhysicsObject:: add_local_impulse(const LVector3 &impulse) { nassertv(!impulse.is_nan()); _velocity += _orientation.xform(impulse); } -//////////////////////////////////////////////////////////////////// -// Function: add_torque -// Access: Public -// Description: Adds an torque force (i.e. an instantanious change -// in velocity). This is a quicker way to get the -// angular velocity, add a vector to it and set that -// value to be the new angular velocity. -//////////////////////////////////////////////////////////////////// +/** + * Adds an torque force (i.e. an instantanious change in velocity). This is + * a quicker way to get the angular velocity, add a vector to it and set that + * value to be the new angular velocity. + */ INLINE void PhysicsObject:: add_torque(const LRotation &torque) { nassertv(!torque.is_nan()); _rotation+=torque; } -//////////////////////////////////////////////////////////////////// -// Function: add_impulse -// Access: Public -// Description: Adds an impulse force (i.e. an instantanious change -// in velocity). This is a quicker way to get the -// velocity, add a vector to it and set that value to -// be the new velocity. -//////////////////////////////////////////////////////////////////// +/** + * Adds an impulse force (i.e. an instantanious change in velocity). This is + * a quicker way to get the velocity, add a vector to it and set that value to + * be the new velocity. + */ INLINE void PhysicsObject:: add_impulse(const LVector3 &impulse) { nassertv(!impulse.is_nan()); _velocity+=impulse; } -//////////////////////////////////////////////////////////////////// -// Function: set_active -// Access: Public -// Description: Process Flag assignment -//////////////////////////////////////////////////////////////////// +/** + * Process Flag assignment + */ INLINE void PhysicsObject:: set_active(bool flag) { _process_me = flag; } -//////////////////////////////////////////////////////////////////// -// Function: set_terminal_velocity -// Access: Public -// Description: tv assignment -//////////////////////////////////////////////////////////////////// +/** + * tv assignment + */ INLINE void PhysicsObject:: set_terminal_velocity(PN_stdfloat tv) { _terminal_velocity = tv; } -//////////////////////////////////////////////////////////////////// -// Function: get_mass -// Access: Public -// Description: Get the mass in slugs (or kilograms). -//////////////////////////////////////////////////////////////////// +/** + * Get the mass in slugs (or kilograms). + */ INLINE PN_stdfloat PhysicsObject:: get_mass() const { return _mass; } -//////////////////////////////////////////////////////////////////// -// Function: get_position -// Access: Public -// Description: Position Query -//////////////////////////////////////////////////////////////////// +/** + * Position Query + */ INLINE LPoint3 PhysicsObject:: get_position() const { return _position; } -//////////////////////////////////////////////////////////////////// -// Function: get_last_position -// Access: Public -// Description: Get the position of the physics object at the start -// of the most recent do_physics. -//////////////////////////////////////////////////////////////////// +/** + * Get the position of the physics object at the start of the most recent + * do_physics. + */ INLINE LPoint3 PhysicsObject:: get_last_position() const { return _last_position; } -//////////////////////////////////////////////////////////////////// -// Function: get_velocity -// Access: Public -// Description: Velocity Query per second -//////////////////////////////////////////////////////////////////// +/** + * Velocity Query per second + */ INLINE LVector3 PhysicsObject:: get_velocity() const { return _velocity; } -//////////////////////////////////////////////////////////////////// -// Function: get_implicit_velocity -// Access: Public -// Description: Velocity Query over the last dt -//////////////////////////////////////////////////////////////////// +/** + * Velocity Query over the last dt + */ INLINE LVector3 PhysicsObject:: get_implicit_velocity() const { return _position-_last_position; } -//////////////////////////////////////////////////////////////////// -// Function: get_active -// Access: Public -// Description: Process Flag Query -//////////////////////////////////////////////////////////////////// +/** + * Process Flag Query + */ INLINE bool PhysicsObject:: get_active() const { return _process_me; } -//////////////////////////////////////////////////////////////////// -// Function: get_terminal_velocity -// Access: Public -// Description: tv query -//////////////////////////////////////////////////////////////////// +/** + * tv query + */ INLINE PN_stdfloat PhysicsObject:: get_terminal_velocity() const { return _terminal_velocity; } -//////////////////////////////////////////////////////////////////// -// Function: set_orientation -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysicsObject:: set_orientation(const LOrientation &orientation) { nassertv(!orientation.is_nan()); _orientation = orientation; } -//////////////////////////////////////////////////////////////////// -// Function: set_rotation -// Access: Public -// Description: set rotation as a quaternion delta per second. -//////////////////////////////////////////////////////////////////// +/** + * set rotation as a quaternion delta per second. + */ INLINE void PhysicsObject:: set_rotation(const LRotation &rotation) { nassertv(!rotation.is_nan()); _rotation = rotation; } -//////////////////////////////////////////////////////////////////// -// Function: get_orientation -// Access: Public -// Description: get current orientation. -//////////////////////////////////////////////////////////////////// +/** + * get current orientation. + */ INLINE LOrientation PhysicsObject:: get_orientation() const { return _orientation; } -//////////////////////////////////////////////////////////////////// -// Function: get_rotation -// Access: Public -// Description: get rotation per second. -//////////////////////////////////////////////////////////////////// +/** + * get rotation per second. + */ INLINE LRotation PhysicsObject:: get_rotation() const { return _rotation; } -//////////////////////////////////////////////////////////////////// -// Function: set_oriented -// Access: Public -// Description: Set flag to determine whether this object should do -// any rotation or orientation calculations. Optimization. -//////////////////////////////////////////////////////////////////// +/** + * Set flag to determine whether this object should do any rotation or + * orientation calculations. Optimization. + */ INLINE void PhysicsObject:: set_oriented(bool flag) { _oriented = flag; } -//////////////////////////////////////////////////////////////////// -// Function: get_oriented -// Access: Public -// Description: See set_oriented(). -//////////////////////////////////////////////////////////////////// +/** + * See set_oriented(). + */ INLINE bool PhysicsObject:: get_oriented() const { return _oriented; diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index 51b6b385fb..dc9b663771 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -1,16 +1,15 @@ -// Filename: physicsObject.cxx -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObject.cxx + * @author charles + * @date 2000-06-13 + */ #include "physicsObject.h" @@ -19,11 +18,9 @@ ConfigVariableDouble PhysicsObject::_default_terminal_velocity TypeHandle PhysicsObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObject -// Access: Public -// Description: Default Constructor -//////////////////////////////////////////////////////////////////// +/** + * Default Constructor + */ PhysicsObject:: PhysicsObject() : _terminal_velocity(_default_terminal_velocity), @@ -38,30 +35,24 @@ PhysicsObject() : _rotation = LRotation::ident_quat(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObject -// Access: Public -// Description: copy constructor -//////////////////////////////////////////////////////////////////// +/** + * copy constructor + */ PhysicsObject:: PhysicsObject(const PhysicsObject& copy) { operator=(copy); } -//////////////////////////////////////////////////////////////////// -// Function: ~PhysicsObject -// Access: Public -// Description: Destructor -//////////////////////////////////////////////////////////////////// +/** + * Destructor + */ PhysicsObject:: ~PhysicsObject() { } -//////////////////////////////////////////////////////////////////// -// Function: Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const PhysicsObject &PhysicsObject:: operator =(const PhysicsObject &other) { _process_me = other._process_me; @@ -77,27 +68,21 @@ operator =(const PhysicsObject &other) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: make_copy -// Access: Public, Virtual -// Description: dynamic copy. -//////////////////////////////////////////////////////////////////// +/** + * dynamic copy. + */ PhysicsObject *PhysicsObject:: make_copy() const { return new PhysicsObject(*this); } -//////////////////////////////////////////////////////////////////// -// Function: add_local_impact -// Access: Public -// Description: Adds an impulse and/or torque (i.e. an instantanious -// change in velocity) based on how well the offset and -// impulse align with the center of mass (aka position). -// If you wanted to immitate this function you could -// work out the impulse and torque and call add_impulse -// and add_torque respectively. -// offset and force are in local coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Adds an impulse and/or torque (i.e. an instantanious change in velocity) + * based on how well the offset and impulse align with the center of mass (aka + * position). If you wanted to immitate this function you could work out the + * impulse and torque and call add_impulse and add_torque respectively. + * offset and force are in local coordinates. + */ void PhysicsObject:: add_local_impact(const LPoint3 &offset_from_center_of_mass, const LVector3 &force) { @@ -108,17 +93,13 @@ add_local_impact(const LPoint3 &offset_from_center_of_mass, _orientation.xform(force)); } -//////////////////////////////////////////////////////////////////// -// Function: add_impact -// Access: Public -// Description: Adds an impulse and/or torque (i.e. an instantanious -// change in velocity) based on how well the offset and -// impulse align with the center of mass (aka position). -// If you wanted to immitate this function you could -// work out the impulse and torque and call add_impulse -// and add_torque respectively. -// offset and force are in global (or parent) coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Adds an impulse and/or torque (i.e. an instantanious change in velocity) + * based on how well the offset and impulse align with the center of mass (aka + * position). If you wanted to immitate this function you could work out the + * impulse and torque and call add_impulse and add_torque respectively. + * offset and force are in global (or parent) coordinates. + */ void PhysicsObject:: add_impact(const LPoint3 &offset, const LVector3 &force) { @@ -143,12 +124,9 @@ add_impact(const LPoint3 &offset, add_impulse(impulse); } -//////////////////////////////////////////////////////////////////// -// Function: get_lcs -// Access: Public -// Description: returns a transform matrix to this object's -// local coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * returns a transform matrix to this object's local coordinate system. + */ LMatrix4 PhysicsObject:: get_lcs() const { LMatrix4 m = LMatrix4::translate_mat(_position); @@ -159,23 +137,18 @@ get_lcs() const { return m; } -//////////////////////////////////////////////////////////////////// -// Function: get_inertial_tensor -// Access: Public -// Description: returns a transform matrix that represents the -// object's willingness to be forced. -//////////////////////////////////////////////////////////////////// +/** + * returns a transform matrix that represents the object's willingness to be + * forced. + */ LMatrix4 PhysicsObject:: get_inertial_tensor() const { return LMatrix4::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: output -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsObject:: output(ostream &out) const { #ifndef NDEBUG //[ @@ -183,12 +156,9 @@ output(ostream &out) const { #endif //] NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: write -// Access: Public -// Description: Write a string representation of this instance to -// . -//////////////////////////////////////////////////////////////////// +/** + * Write a string representation of this instance to . + */ void PhysicsObject:: write(ostream &out, unsigned int indent) const { #ifndef NDEBUG //[ diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index 6d4b4e40a4..5cb266ae7f 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -1,16 +1,15 @@ -// Filename: physicsObject.h -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObject.h + * @author charles + * @date 2000-06-13 + */ #ifndef PHYSICS_OBJECT_H #define PHYSICS_OBJECT_H @@ -20,12 +19,11 @@ #include "luse.h" #include "configVariableDouble.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysicsObject -// Description : A body on which physics will be applied. If you're -// looking to add physical motion to your class, do -// NOT derive from this. Derive from Physical instead. -//////////////////////////////////////////////////////////////////// +/** + * A body on which physics will be applied. If you're looking to add physical + * motion to your class, do NOT derive from this. Derive from Physical + * instead. + */ class EXPCL_PANDAPHYSICS PhysicsObject : public TypedReferenceCount { public: typedef pvector Vector; @@ -44,7 +42,7 @@ PUBLISHED: INLINE void set_mass(PN_stdfloat); INLINE PN_stdfloat get_mass() const; - //INLINE void set_center_of_mass(const LPoint3 &pos); use set_position. + // INLINE void set_center_of_mass(const LPoint3 &pos); use set_position. INLINE void set_position(const LPoint3 &pos); INLINE void set_position(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); INLINE LPoint3 get_position() const; @@ -88,7 +86,7 @@ PUBLISHED: virtual LMatrix4 get_inertial_tensor() const; virtual LMatrix4 get_lcs() const; virtual PhysicsObject *make_copy() const; - + #ifndef NDEBUG void set_name(const string &name) { _name = name; @@ -97,7 +95,7 @@ PUBLISHED: return _name; } #endif - + virtual void output(ostream &out) const; virtual void write(ostream &out, unsigned int indent=0) const; @@ -116,7 +114,7 @@ private: bool _process_me; bool _oriented; - + #ifndef NDEBUG string _name; #endif diff --git a/panda/src/physics/physicsObjectCollection.I b/panda/src/physics/physicsObjectCollection.I index 740f64db07..aecd2decc4 100644 --- a/panda/src/physics/physicsObjectCollection.I +++ b/panda/src/physics/physicsObjectCollection.I @@ -1,43 +1,35 @@ -// Filename: physicsObjectCollection.I -// Created by: joswilso (12Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObjectCollection.I + * @author joswilso + * @date 2006-07-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysicsObjectCollection:: ~PhysicsObjectCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::operator += -// Access: Published -// Description: Appends the other list onto the end of this one. -//////////////////////////////////////////////////////////////////// +/** + * Appends the other list onto the end of this one. + */ INLINE void PhysicsObjectCollection:: operator += (const PhysicsObjectCollection &other) { add_physics_objects_from(other); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::operator + -// Access: Published -// Description: Returns a PhysicsObjectCollection representing the -// concatenation of the two lists. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysicsObjectCollection representing the concatenation of the two + * lists. + */ INLINE PhysicsObjectCollection PhysicsObjectCollection:: operator + (const PhysicsObjectCollection &other) const { PhysicsObjectCollection a(*this); diff --git a/panda/src/physics/physicsObjectCollection.cxx b/panda/src/physics/physicsObjectCollection.cxx index 1e1c7344bc..17ce51158d 100644 --- a/panda/src/physics/physicsObjectCollection.cxx +++ b/panda/src/physics/physicsObjectCollection.cxx @@ -1,62 +1,52 @@ -// Filename: physicsObjectCollection.cxx -// Created by: joswilso (12Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObjectCollection.cxx + * @author joswilso + * @date 2006-07-12 + */ #include "physicsObjectCollection.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysicsObjectCollection:: PhysicsObjectCollection() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysicsObjectCollection:: PhysicsObjectCollection(const PhysicsObjectCollection ©) : _physics_objects(copy._physics_objects) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysicsObjectCollection:: operator = (const PhysicsObjectCollection ©) { _physics_objects = copy._physics_objects; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::add_physics_object -// Access: Published -// Description: Adds a new PhysicsObject to the collection. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new PhysicsObject to the collection. + */ void PhysicsObjectCollection:: add_physics_object(PT(PhysicsObject) physics_object) { // If the pointer to our internal array is shared by any other // PhysicsObjectCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren PhysicsObjectCollection - // objects. + // inadvertently modify any of our brethren PhysicsObjectCollection objects. if (_physics_objects.get_ref_count() > 1) { PhysicsObjects old_physics_objects = _physics_objects; @@ -67,13 +57,11 @@ add_physics_object(PT(PhysicsObject) physics_object) { _physics_objects.push_back(physics_object); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::remove_physics_object -// Access: Published -// Description: Removes the indicated PhysicsObject from the collection. -// Returns true if the physics_object was removed, false if it was -// not a member of the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated PhysicsObject from the collection. Returns true if + * the physics_object was removed, false if it was not a member of the + * collection. + */ bool PhysicsObjectCollection:: remove_physics_object(PT(PhysicsObject) physics_object) { int object_index = -1; @@ -90,8 +78,7 @@ remove_physics_object(PT(PhysicsObject) physics_object) { // If the pointer to our internal array is shared by any other // PhysicsObjectCollections, we have to copy the array now so we won't - // inadvertently modify any of our brethren PhysicsObjectCollection - // objects. + // inadvertently modify any of our brethren PhysicsObjectCollection objects. if (_physics_objects.get_ref_count() > 1) { PhysicsObjects old_physics_objects = _physics_objects; @@ -103,15 +90,11 @@ remove_physics_object(PT(PhysicsObject) physics_object) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::add_physics_objects_from -// Access: Published -// Description: Adds all the PhysicsObjects indicated in the other -// collection to this collection. The other -// physics_objects are simply appended to the end of -// the physics_objects in this list; -// duplicates are not automatically removed. -//////////////////////////////////////////////////////////////////// +/** + * Adds all the PhysicsObjects indicated in the other collection to this + * collection. The other physics_objects are simply appended to the end of + * the physics_objects in this list; duplicates are not automatically removed. + */ void PhysicsObjectCollection:: add_physics_objects_from(const PhysicsObjectCollection &other) { int other_num_physics_objects = other.get_num_physics_objects(); @@ -121,12 +104,10 @@ add_physics_objects_from(const PhysicsObjectCollection &other) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::remove_physics_objects_from -// Access: Published -// Description: Removes from this collection all of the PhysicsObjects -// listed in the other collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this collection all of the PhysicsObjects listed in the other + * collection. + */ void PhysicsObjectCollection:: remove_physics_objects_from(const PhysicsObjectCollection &other) { PhysicsObjects new_physics_objects; @@ -140,14 +121,11 @@ remove_physics_objects_from(const PhysicsObjectCollection &other) { _physics_objects = new_physics_objects; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::remove_duplicate_physics_objects -// Access: Published -// Description: Removes any duplicate entries of the same PhysicsObjects -// on this collection. If a PhysicsObject appears multiple -// times, the first appearance is retained; subsequent -// appearances are removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any duplicate entries of the same PhysicsObjects on this + * collection. If a PhysicsObject appears multiple times, the first + * appearance is retained; subsequent appearances are removed. + */ void PhysicsObjectCollection:: remove_duplicate_physics_objects() { PhysicsObjects new_physics_objects; @@ -169,12 +147,10 @@ remove_duplicate_physics_objects() { _physics_objects = new_physics_objects; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::has_physics_object -// Access: Published -// Description: Returns true if the indicated PhysicsObject appears in -// this collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated PhysicsObject appears in this collection, + * false otherwise. + */ bool PhysicsObjectCollection:: has_physics_object(PT(PhysicsObject) physics_object) const { for (int i = 0; i < get_num_physics_objects(); i++) { @@ -185,42 +161,34 @@ has_physics_object(PT(PhysicsObject) physics_object) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::clear -// Access: Published -// Description: Removes all PhysicsObjects from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Removes all PhysicsObjects from the collection. + */ void PhysicsObjectCollection:: clear() { _physics_objects.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::is_empty -// Access: Published -// Description: Returns true if there are no PhysicsObjects in the -// collection, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no PhysicsObjects in the collection, false + * otherwise. + */ bool PhysicsObjectCollection:: is_empty() const { return _physics_objects.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::get_num_physics_objects -// Access: Published -// Description: Returns the number of PhysicsObjects in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of PhysicsObjects in the collection. + */ int PhysicsObjectCollection:: get_num_physics_objects() const { return _physics_objects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::get_physics_object -// Access: Published -// Description: Returns the nth PhysicsObject in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth PhysicsObject in the collection. + */ PT(PhysicsObject) PhysicsObjectCollection:: get_physics_object(int index) const { nassertr(index >= 0 && index < (int)_physics_objects.size(), PT(PhysicsObject)()); @@ -228,13 +196,10 @@ get_physics_object(int index) const { return _physics_objects[index]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::operator [] -// Access: Published -// Description: Returns the nth PhysicsObject in the collection. This is -// the same as get_physics_object(), but it may be a more -// convenient way to access it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth PhysicsObject in the collection. This is the same as + * get_physics_object(), but it may be a more convenient way to access it. + */ PT(PhysicsObject) PhysicsObjectCollection:: operator [] (int index) const { nassertr(index >= 0 && index < (int)_physics_objects.size(), PT(PhysicsObject)()); @@ -242,24 +207,19 @@ operator [] (int index) const { return _physics_objects[index]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::size -// Access: Published -// Description: Returns the number of physics objects in the -// collection. This is the same thing as -// get_num_physics_objects(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of physics objects in the collection. This is the same + * thing as get_num_physics_objects(). + */ int PhysicsObjectCollection:: size() const { return _physics_objects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::output -// Access: Published -// Description: Writes a brief one-line description of the -// PhysicsObjectCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief one-line description of the PhysicsObjectCollection to the + * indicated output stream. + */ void PhysicsObjectCollection:: output(ostream &out) const { if (get_num_physics_objects() == 1) { @@ -269,16 +229,13 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysicsObjectCollection::write -// Access: Published -// Description: Writes a complete multi-line description of the -// PhysicsObjectCollection to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a complete multi-line description of the PhysicsObjectCollection to + * the indicated output stream. + */ void PhysicsObjectCollection:: write(ostream &out, int indent_level) const { for (int i = 0; i < get_num_physics_objects(); i++) { indent(out, indent_level) << get_physics_object(i) << "\n"; } } - diff --git a/panda/src/physics/physicsObjectCollection.h b/panda/src/physics/physicsObjectCollection.h index e2e2e4c993..4901235ee2 100644 --- a/panda/src/physics/physicsObjectCollection.h +++ b/panda/src/physics/physicsObjectCollection.h @@ -1,16 +1,15 @@ -// Filename: physicsObjectCollection.h -// Created by: joswilso (12Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physicsObjectCollection.h + * @author joswilso + * @date 2006-07-12 + */ #ifndef PHYSICSOBJECTCOLLECTION_H #define PHYSICSOBJECTCOLLECTION_H @@ -19,19 +18,17 @@ #include "physicsObject.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysicsObjectCollection -// Description : This is a set of zero or more PhysicsObjects. It's handy -// for returning from functions that need to return -// multiple PhysicsObjects. -//////////////////////////////////////////////////////////////////// +/** + * This is a set of zero or more PhysicsObjects. It's handy for returning + * from functions that need to return multiple PhysicsObjects. + */ class EXPCL_PANDAPHYSICS PhysicsObjectCollection { PUBLISHED: PhysicsObjectCollection(); PhysicsObjectCollection(const PhysicsObjectCollection ©); void operator = (const PhysicsObjectCollection ©); INLINE ~PhysicsObjectCollection(); - + void add_physics_object(PT(PhysicsObject) physics_object); bool remove_physics_object(PT(PhysicsObject) physics_object); void add_physics_objects_from(const PhysicsObjectCollection &other); @@ -66,5 +63,3 @@ INLINE ostream &operator << (ostream &out, const PhysicsObjectCollection &col) { #include "physicsObjectCollection.I" #endif - - diff --git a/panda/src/physics/test_physics.cxx b/panda/src/physics/test_physics.cxx index 397feae89f..cb2e2f0c9d 100644 --- a/panda/src/physics/test_physics.cxx +++ b/panda/src/physics/test_physics.cxx @@ -1,16 +1,15 @@ -// Filename: test_physics.cxx -// Created by: charles (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_physics.cxx + * @author charles + * @date 2000-06-13 + */ #include #include "physical.h" @@ -20,7 +19,7 @@ class Baseball : public Physical { public: int ttl_balls; - //int color; + // int color; Baseball(int tb = 1) : ttl_balls(tb), Physical(tb, true) {} }; @@ -52,7 +51,7 @@ int main(int argc, char **argv) { // get on with life b.add_linear_force(new LinearJitterForce(0.1f)); - + int i=0; for (PhysicsObject::Vector::const_iterator co=b.get_object_vector().begin(); co != b.get_object_vector().end(); @@ -86,4 +85,3 @@ int main(int argc, char **argv) { return 0; } - diff --git a/panda/src/physx/config_physx.cxx b/panda/src/physx/config_physx.cxx index e97d8360c2..e7a4a653e1 100644 --- a/panda/src/physx/config_physx.cxx +++ b/panda/src/physx/config_physx.cxx @@ -1,16 +1,15 @@ -// Filename: config_physx.cxx -// Created by: enn0x (01Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_physx.cxx + * @author enn0x + * @date 2009-09-01 + */ #include "config_physx.h" #include "pandaSystem.h" @@ -104,14 +103,12 @@ PRC_DESC("Specified the number of internal threads to be created by the " "possible. Default value is '0'. PhysX then runs in an external " "thread, but no additional internal threads will be created.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libphysx -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libphysx() { static bool initialized = false; @@ -175,4 +172,3 @@ init_libphysx() { PandaSystem *ps = PandaSystem::get_global_ptr(); ps->add_system("PhysX"); } - diff --git a/panda/src/physx/config_physx.h b/panda/src/physx/config_physx.h index e0b00fa7af..f17af252b6 100644 --- a/panda/src/physx/config_physx.h +++ b/panda/src/physx/config_physx.h @@ -1,16 +1,15 @@ -// Filename: config_physx.h -// Created by: enn0x (01Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_physx.h + * @author enn0x + * @date 2009-09-01 + */ #ifndef CONFIG_PHYSX_H #define CONFIG_PHYSX_H diff --git a/panda/src/physx/physxActor.I b/panda/src/physx/physxActor.I index 44f09990b4..9b6896e596 100644 --- a/panda/src/physx/physxActor.I +++ b/panda/src/physx/physxActor.I @@ -1,55 +1,44 @@ -// Filename: physxActor.I -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActor.I + * @author enn0x + * @date 2009-09-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxActor:: PhysxActor() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxActor:: ~PhysxActor() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxActor:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxActor:: ls(ostream &out, int indent_level) const { @@ -69,4 +58,3 @@ ls(ostream &out, int indent_level) const { _shapes.ls(out, indent_level); } - diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index 4358a28b9e..fdbce36aff 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -1,16 +1,15 @@ -// Filename: physxActor.cxx -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActor.cxx + * @author enn0x + * @date 2009-09-14 + */ #include "physxActor.h" #include "physxActorDesc.h" @@ -20,11 +19,9 @@ TypeHandle PhysxActor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxActor:: link(NxActor *actorPtr) { @@ -48,11 +45,9 @@ link(NxActor *actorPtr) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxActor:: unlink() { @@ -73,11 +68,9 @@ unlink() { scene->_actors.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxActor:: release() { @@ -88,23 +81,19 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::link_controller -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxActor:: link_controller(PhysxController *controller) { _controller = controller; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::save_body_to_desc -// Access: Published -// Description: Saves the body information of a dynamic actor to -// the passed body descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the body information of a dynamic actor to the passed body + * descriptor. + */ bool PhysxActor:: save_body_to_desc(PhysxBodyDesc &bodyDesc) const { @@ -112,12 +101,9 @@ save_body_to_desc(PhysxBodyDesc &bodyDesc) const { return _ptr->saveBodyToDesc(bodyDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::save_to_desc -// Access: Published -// Description: Saves the state of the actor to the passed -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the actor to the passed descriptor. + */ void PhysxActor:: save_to_desc(PhysxActorDesc &actorDesc) const { @@ -125,14 +111,10 @@ save_to_desc(PhysxActorDesc &actorDesc) const { _ptr->saveToDesc(actorDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_name -// Access: Published -// Description: Sets a name string for the object that can be -// retrieved with get_name(). -// This is for debugging and is not used by the -// engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for the object that can be retrieved with get_name(). + * This is for debugging and is not used by the engine. + */ void PhysxActor:: set_name(const char *name) { @@ -142,11 +124,9 @@ set_name(const char *name) { _ptr->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_name -// Access: Published -// Description: Retrieves the name string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the name string. + */ const char *PhysxActor:: get_name() const { @@ -154,22 +134,18 @@ get_name() const { return _ptr->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::update_transform -// Access: Public -// Description: Updates the transform of an assigned NodePath. If -// the actor has been created by a PhysxController -// then this method will update the NodePath's -// transform from the controller's transform. -//////////////////////////////////////////////////////////////////// +/** + * Updates the transform of an assigned NodePath. If the actor has been + * created by a PhysxController then this method will update the NodePath's + * transform from the controller's transform. + */ void PhysxActor:: update_transform(const LMatrix4f &m) { - // Active transforms are update AFTER scene.fetchResults() has - // been called, and thus can contain removed objects. So either - // update transforms after scene.fetchResults() - which means - // poor performance - or check if an actor has been removed here - // in this method. + // Active transforms are update AFTER scene.fetchResults() has been called, + // and thus can contain removed objects. So either update transforms after + // scene.fetchResults() - which means poor performance - or check if an + // actor has been removed here in this method. if (_error_type != ET_ok) return; if (_np.is_empty()) return; @@ -184,11 +160,9 @@ update_transform(const LMatrix4f &m) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_global_pos -// Access: Published -// Description: Retrieves the actors world space position. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actors world space position. + */ LPoint3f PhysxActor:: get_global_pos() const { @@ -196,11 +170,9 @@ get_global_pos() const { return PhysxManager::nxVec3_to_point3(_ptr->getGlobalPosition()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_global_mat -// Access: Published -// Description: Retrieves the actors world space transform. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actors world space transform. + */ LMatrix4f PhysxActor:: get_global_mat() const { @@ -208,11 +180,9 @@ get_global_mat() const { return PhysxManager::nxMat34_to_mat4(_ptr->getGlobalPose()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_global_quat -// Access: Published -// Description: Retrieves the actors world space orientation. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actors world space orientation. + */ LQuaternionf PhysxActor:: get_global_quat() const { @@ -220,13 +190,10 @@ get_global_quat() const { return PhysxManager::nxQuat_to_quat(_ptr->getGlobalOrientation()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_global_pos -// Access: Published -// Description: Method for setting a dynamic actor's position in -// the world. Please see set_global_mat for some -// caveats. -//////////////////////////////////////////////////////////////////// +/** + * Method for setting a dynamic actor's position in the world. Please see + * set_global_mat for some caveats. + */ void PhysxActor:: set_global_pos(const LPoint3f &pos) { @@ -236,41 +203,29 @@ set_global_pos(const LPoint3f &pos) { _ptr->setGlobalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_global_mat -// Access: Published -// Description: Method for setting a dynamic actor's transform -// matrix in the world. -// -// This method instantaneously changes the actor space -// to world space transformation. -// -// One should exercise restraint in making use of -// these methods. -// -// Static actors should not be moved at all. There are -// various internal data structures for static actors -// which may need to be recomputed when one moves. -// Also, moving static actors will not interact -// correctly with dynamic actors or joints. If you -// would like to directly control an actor's position -// and would like to have it correctly interact with -// dynamic bodies and joints, you should create a -// dynamic body with the BF_kinematic flag, and then -// use the move_global_*() commands to move it along -// a path! -// -// When briefly moving dynamic actors, one should not: -// - Move actors into other actors, thus causing -// interpenetration (an invalid physical state). -// - Move an actor that is connected by a joint to -// another away from the other (thus causing joint -// error). -// - When moving jointed actors the joints' cached -// transform information is destroyed and recreated -// next frame; thus this call is expensive for -// jointed actors. -//////////////////////////////////////////////////////////////////// +/** + * Method for setting a dynamic actor's transform matrix in the world. + * + * This method instantaneously changes the actor space to world space + * transformation. + * + * One should exercise restraint in making use of these methods. + * + * Static actors should not be moved at all. There are various internal data + * structures for static actors which may need to be recomputed when one + * moves. Also, moving static actors will not interact correctly with dynamic + * actors or joints. If you would like to directly control an actor's + * position and would like to have it correctly interact with dynamic bodies + * and joints, you should create a dynamic body with the BF_kinematic flag, + * and then use the move_global_*() commands to move it along a path! + * + * When briefly moving dynamic actors, one should not: - Move actors into + * other actors, thus causing interpenetration (an invalid physical state). - + * Move an actor that is connected by a joint to another away from the other + * (thus causing joint error). - When moving jointed actors the joints' cached + * transform information is destroyed and recreated next frame; thus this call + * is expensive for jointed actors. + */ void PhysxActor:: set_global_mat(const LMatrix4f &mat) { @@ -280,13 +235,10 @@ set_global_mat(const LMatrix4f &mat) { _ptr->setGlobalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_global_hpr -// Access: Published -// Description: Method for setting a dynamic actor's orientation in -// the world. Please see set_global_mat for some -// caveats. -//////////////////////////////////////////////////////////////////// +/** + * Method for setting a dynamic actor's orientation in the world. Please see + * set_global_mat for some caveats. + */ void PhysxActor:: set_global_hpr(float h, float p, float r) { @@ -297,16 +249,14 @@ set_global_hpr(float h, float p, float r) { _ptr->setGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::move_global_pos -// Access: Published -// Description: The move_global_* calls serve to move kinematically -// controlled dynamic actors through the game world. -// -// See move_global_mat() for more information. -// -// This call wakes the actor if it is sleeping. -//////////////////////////////////////////////////////////////////// +/** + * The move_global_* calls serve to move kinematically controlled dynamic + * actors through the game world. + * + * See move_global_mat() for more information. + * + * This call wakes the actor if it is sleeping. + */ void PhysxActor:: move_global_pos(const LPoint3f &pos) { @@ -316,32 +266,25 @@ move_global_pos(const LPoint3f &pos) { _ptr->moveGlobalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::move_global_mat -// Access: Published -// Description: The move_global_* calls serve to move -// kinematically controlled dynamic actors through -// the game world. -// -// You set a dynamic actor to be kinematic using the -// BF_KINEMATIC body flag, used either in the -// PhysBodyDesc or with set_body_flag(). -// -// The move command will result in a velocity that, -// when successfully carried out (i.e. the motion is -// not blocked due to joints or collisions) inside -// run*(), will move the body into the desired pose. -// After the move is carried out during a single time -// step, the velocity is returned to zero. Thus, you -// must continuously call this in every time step for -// kinematic actors so that they move along a path. -// -// These functions simply store the move destination -// until run*() is called, so consecutive calls will -// simply overwrite the stored target variable. -// -// This call wakes the actor if it is sleeping. -//////////////////////////////////////////////////////////////////// +/** + * The move_global_* calls serve to move kinematically controlled dynamic + * actors through the game world. + * + * You set a dynamic actor to be kinematic using the BF_KINEMATIC body flag, + * used either in the PhysBodyDesc or with set_body_flag(). + * + * The move command will result in a velocity that, when successfully carried + * out (i.e. the motion is not blocked due to joints or collisions) inside + * run*(), will move the body into the desired pose. After the move is + * carried out during a single time step, the velocity is returned to zero. + * Thus, you must continuously call this in every time step for kinematic + * actors so that they move along a path. + * + * These functions simply store the move destination until run*() is called, + * so consecutive calls will simply overwrite the stored target variable. + * + * This call wakes the actor if it is sleeping. + */ void PhysxActor:: move_global_mat(const LMatrix4f &mat) { @@ -351,16 +294,14 @@ move_global_mat(const LMatrix4f &mat) { _ptr->moveGlobalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::move_global_hpr -// Access: Published -// Description: The move_global_* calls serve to move kinematically -// controlled dynamic actors through the game world. -// -// See move_global_mat() for more information. -// -// This call wakes the actor if it is sleeping. -//////////////////////////////////////////////////////////////////// +/** + * The move_global_* calls serve to move kinematically controlled dynamic + * actors through the game world. + * + * See move_global_mat() for more information. + * + * This call wakes the actor if it is sleeping. + */ void PhysxActor:: move_global_hpr(float h, float p, float r) { @@ -371,17 +312,13 @@ move_global_hpr(float h, float p, float r) { _ptr->moveGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::attach_node_path -// Access: Published -// Description: Attaches a node path to this actor. The node -// path's transform will be updated automatically if -// the actor's transform changes (and only then). -// -// Note: any non-uniform scale or shear set on the -// NodePath's transform will be overwritten at the -// time of the first update. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a node path to this actor. The node path's transform will be + * updated automatically if the actor's transform changes (and only then). + * + * Note: any non-uniform scale or shear set on the NodePath's transform will + * be overwritten at the time of the first update. + */ void PhysxActor:: attach_node_path(const NodePath &np) { @@ -391,13 +328,10 @@ attach_node_path(const NodePath &np) { _np = NodePath(np); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::detach_node_path -// Access: Published -// Description: Detaches a previously assigned NodePath from this -// actor. The NodePath's transform will no longer -// be updated from the actor's transform. -//////////////////////////////////////////////////////////////////// +/** + * Detaches a previously assigned NodePath from this actor. The NodePath's + * transform will no longer be updated from the actor's transform. + */ void PhysxActor:: detach_node_path() { @@ -406,13 +340,10 @@ detach_node_path() { _np = NodePath(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_node_path -// Access: Published -// Description: Retrieves a previously attached NodePath. An empty -// NodePath will be returned if no NodePath has been -// attached to this actor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves a previously attached NodePath. An empty NodePath will be + * returned if no NodePath has been attached to this actor. + */ NodePath PhysxActor:: get_node_path() const { @@ -421,11 +352,9 @@ get_node_path() const { return _np; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_scene -// Access: Published -// Description: Retrieves the scene which this actor belongs to. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the scene which this actor belongs to. + */ PhysxScene *PhysxActor:: get_scene() const { @@ -437,12 +366,9 @@ get_scene() const { return scene; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_num_shapes -// Access: Published -// Description: Returns the number of shapes assigned to the -// actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of shapes assigned to the actor. + */ unsigned int PhysxActor:: get_num_shapes() const { @@ -451,18 +377,13 @@ get_num_shapes() const { return _ptr->getNbShapes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::create_shape -// Access: Published -// Description: Creates a new shape and adds it to the list of -// shapes of this actor. -// -// Mass properties of dynamic actors will not -// automatically be recomputed to reflect the new mass -// distribution implied by the shape. Follow this call -// with a call to update_mass_from_shapes() to do -// that. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new shape and adds it to the list of shapes of this actor. + * + * Mass properties of dynamic actors will not automatically be recomputed to + * reflect the new mass distribution implied by the shape. Follow this call + * with a call to update_mass_from_shapes() to do that. + */ PhysxShape *PhysxActor:: create_shape(PhysxShapeDesc &desc) { @@ -480,13 +401,10 @@ create_shape(PhysxShapeDesc &desc) { return shape; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_shape -// Access: Published -// Description: Retrieves an individual shape from the actor's -// array of shapes. Index must be in the range from -// zero to (number-of-shapes minus 1). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves an individual shape from the actor's array of shapes. Index must + * be in the range from zero to (number-of-shapes minus 1). + */ PhysxShape *PhysxActor:: get_shape(unsigned int idx) const { @@ -500,14 +418,11 @@ get_shape(unsigned int idx) const { return shape; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_shape_by_name -// Access: Published -// Description: Retrieves an individual shape from the actor's -// array of shapes. The first shape for which the -// shape's name matches the specified name is -// returned, or NULL if no shape has a matching name. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves an individual shape from the actor's array of shapes. The first + * shape for which the shape's name matches the specified name is returned, or + * NULL if no shape has a matching name. + */ PhysxShape *PhysxActor:: get_shape_by_name(const char *name) const { @@ -528,21 +443,17 @@ get_shape_by_name(const char *name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_force -// Access: Published -// Description: Applies a force (or impulse) defined in the global -// coordinate frame to the actor. -// -// This will not induce a torque. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the global coordinate frame to the + * actor. + * + * This will not induce a torque. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_force(const LVector3f force, PhysxForceMode mode, bool wakeup) { @@ -552,27 +463,20 @@ add_force(const LVector3f force, PhysxForceMode mode, bool wakeup) { _ptr->addForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_force_at_pos -// Access: Published -// Description: Applies a force (or impulse) defined in the global -// coordinate frame, acting at a particular point in -// global coordinates, to the actor. -// -// Note that if the force does not act along the -// center of mass of the actor, this will also add the -// corresponding torque. Because forces are reset at -// the end of every timestep, you can maintain a total -// external force on an object by calling this once -// every frame. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the global coordinate frame, acting + * at a particular point in global coordinates, to the actor. + * + * Note that if the force does not act along the center of mass of the actor, + * this will also add the corresponding torque. Because forces are reset at + * the end of every timestep, you can maintain a total external force on an + * object by calling this once every frame. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) { @@ -583,27 +487,20 @@ add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode _ptr->addForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_force_at_local_pos -// Access: Published -// Description: Applies a force (or impulse) defined in the global -// coordinate frame, acting at a particular point in -// local coordinates, to the actor. -// -// Note that if the force does not act along the -// center of mass of the actor, this will also add -// the corresponding torque. Because forces are reset -// at the end of every timestep, you can maintain a -// total external force on an object by calling this -// once every frame. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the global coordinate frame, acting + * at a particular point in local coordinates, to the actor. + * + * Note that if the force does not act along the center of mass of the actor, + * this will also add the corresponding torque. Because forces are reset at + * the end of every timestep, you can maintain a total external force on an + * object by calling this once every frame. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) { @@ -614,19 +511,15 @@ add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMod _ptr->addForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_torque -// Access: Published -// Description: Applies an impulsive torque defined in the global -// coordinate frame to the actor. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies an impulsive torque defined in the global coordinate frame to the + * actor. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) { @@ -636,20 +529,15 @@ add_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) { _ptr->addTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_local_force -// Access: Published -// Description: Applies a force (or impulse) defined in the actor -// local coordinate frame to the actor. -// This will not induce a torque. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the actor local coordinate frame to + * the actor. This will not induce a torque. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_local_force(const LVector3f force, PhysxForceMode mode, bool wakeup) { @@ -659,27 +547,20 @@ add_local_force(const LVector3f force, PhysxForceMode mode, bool wakeup) { _ptr->addLocalForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_local_force_at_pos -// Access: Published -// Description: Applies a force (or impulse) defined in the actor -// local coordinate frame, acting at a particular -// point in global coordinates, to the actor. -// -// Note that if the force does not act along the -// center of mass of the actor, this will also add -// the corresponding torque. Because forces are reset -// at the end of every timestep, you can maintain a -// total external force on an object by calling this -// once every frame. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the actor local coordinate frame, + * acting at a particular point in global coordinates, to the actor. + * + * Note that if the force does not act along the center of mass of the actor, + * this will also add the corresponding torque. Because forces are reset at + * the end of every timestep, you can maintain a total external force on an + * object by calling this once every frame. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) { @@ -690,27 +571,20 @@ add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMod _ptr->addLocalForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_local_force_at_local_pos -// Access: Published -// Description: Applies a force (or impulse) defined in the actor -// local coordinate frame, acting at a particular -// point in local coordinates, to the actor. -// -// Note that if the force does not act along the -// center of mass of the actor, this will also add the -// corresponding torque. Because forces are reset at -// the end of every timestep, you can maintain a total -// external force on an object by calling this once -// every frame. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the actor local coordinate frame, + * acting at a particular point in local coordinates, to the actor. + * + * Note that if the force does not act along the center of mass of the actor, + * this will also add the corresponding torque. Because forces are reset at + * the end of every timestep, you can maintain a total external force on an + * object by calling this once every frame. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) { @@ -721,19 +595,15 @@ add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxFo _ptr->addLocalForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::add_local_torque -// Access: Published -// Description: Applies an impulsive torque defined in the actor -// local coordinate frame to the actor. -// -// Mode determines if the torque is to be conventional -// or impulsive. -// -// The actor must be dynamic. -// This call wakes the actor if it is sleeping and the -// wakeup parameter is true (default). -//////////////////////////////////////////////////////////////////// +/** + * Applies an impulsive torque defined in the actor local coordinate frame to + * the actor. + * + * Mode determines if the torque is to be conventional or impulsive. + * + * The actor must be dynamic. This call wakes the actor if it is sleeping and + * the wakeup parameter is true (default). + */ void PhysxActor:: add_local_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) { @@ -743,41 +613,32 @@ add_local_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) { _ptr->addLocalTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::update_mass_from_shapes -// Access: Published -// Description: Recomputes a dynamic actor's mass properties from -// its shapes. -// -// Given a constant density or total mass, the actors -// mass properties can be recomputed using the shapes -// attached to the actor. If the actor has no shapes, -// then only the totalMass parameter can be used. If -// all shapes in the actor are trigger shapes -// (non-physical), the call will fail. -// -// The mass of each shape is either the shape's local -// density (as specified in the PhysxShapeDesc; -// default 1.0) multiplied by the shape's volume or a -// directly specified shape mass. -// -// The inertia tensor, mass frame and center of mass -// will always be recomputed. If there are no shapes -// in the actor, the mass will be totalMass, and the -// mass frame will be set to the center of the actor. -// -// If you supply a non-zero total mass, the actor's -// mass and inertia will first be computed as above -// and then scaled to fit this total mass. -// -// If you supply a non-zero density, the actor's mass -// and inertia will first be computed as above and -// then scaled by this factor. -// -// Either totalMass or density must be non-zero. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes a dynamic actor's mass properties from its shapes. + * + * Given a constant density or total mass, the actors mass properties can be + * recomputed using the shapes attached to the actor. If the actor has no + * shapes, then only the totalMass parameter can be used. If all shapes in + * the actor are trigger shapes (non-physical), the call will fail. + * + * The mass of each shape is either the shape's local density (as specified in + * the PhysxShapeDesc; default 1.0) multiplied by the shape's volume or a + * directly specified shape mass. + * + * The inertia tensor, mass frame and center of mass will always be + * recomputed. If there are no shapes in the actor, the mass will be + * totalMass, and the mass frame will be set to the center of the actor. + * + * If you supply a non-zero total mass, the actor's mass and inertia will + * first be computed as above and then scaled to fit this total mass. + * + * If you supply a non-zero density, the actor's mass and inertia will first + * be computed as above and then scaled by this factor. + * + * Either totalMass or density must be non-zero. + * + * The actor must be dynamic. + */ bool PhysxActor:: update_mass_from_shapes(float density, float totalMass) { @@ -785,13 +646,10 @@ update_mass_from_shapes(float density, float totalMass) { return _ptr->updateMassFromShapes(density, totalMass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::compute_kinetic_energy -// Access: Published -// Description: Computes the total kinetic (rotational and -// translational) energy of the object. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Computes the total kinetic (rotational and translational) energy of the + * object. The actor must be dynamic. + */ float PhysxActor:: compute_kinetic_energy() const { @@ -799,11 +657,9 @@ compute_kinetic_energy() const { return _ptr->computeKineticEnergy(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::is_dynamic -// Access: Published -// Description: Returns true if the actor is dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the actor is dynamic. + */ bool PhysxActor:: is_dynamic() const { @@ -811,12 +667,10 @@ is_dynamic() const { return _ptr->isDynamic(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_shape_group -// Access: Published -// Description: Sets the collision group for all shapes of this -// actor. See PhysxShape.setGroup(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the collision group for all shapes of this actor. See + * PhysxShape.setGroup(). + */ void PhysxActor:: set_shape_group(unsigned int group) { @@ -831,11 +685,9 @@ set_shape_group(unsigned int group) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_body_flag -// Access: Published -// Description: Raise or lower individual BodyFlag flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual BodyFlag flags. + */ void PhysxActor:: set_body_flag(PhysxBodyFlag flag, bool value) { @@ -847,11 +699,9 @@ set_body_flag(PhysxBodyFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_body_flag -// Access: Published -// Description: Return the specified BodyFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Return the specified BodyFlag flag. + */ bool PhysxActor:: get_body_flag(PhysxBodyFlag flag) const { @@ -859,11 +709,9 @@ get_body_flag(PhysxBodyFlag flag) const { return ptr()->readBodyFlag((NxBodyFlag)flag); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_actor_flag -// Access: Published -// Description: Raise or lower individual ActorFlag flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual ActorFlag flags. + */ void PhysxActor:: set_actor_flag(PhysxActorFlag flag, bool value) { @@ -875,11 +723,9 @@ set_actor_flag(PhysxActorFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_actor_flag -// Access: Published -// Description: Return the specified ActorFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Return the specified ActorFlag flag. + */ bool PhysxActor:: get_actor_flag(PhysxActorFlag flag) const { @@ -887,23 +733,17 @@ get_actor_flag(PhysxActorFlag flag) const { return ptr()->readActorFlag((NxActorFlag)flag); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_contact_report_flag -// Access: Published -// Description: Sets the actor's contact report flags. -// -// These flags are used to determine the kind of -// report that is generated for interactions with -// other actors. -// -// Please note: If the actor is part of an interacting -// pair for which the contact report generation is -// controlled already through any other mechanism -// (for example by use of -// PhysxScene::set_actor_pair_flags) -// then the union of all the specified contact report -// flags will be used to generate the report. -//////////////////////////////////////////////////////////////////// +/** + * Sets the actor's contact report flags. + * + * These flags are used to determine the kind of report that is generated for + * interactions with other actors. + * + * Please note: If the actor is part of an interacting pair for which the + * contact report generation is controlled already through any other mechanism + * (for example by use of PhysxScene::set_actor_pair_flags) then the union of + * all the specified contact report flags will be used to generate the report. + */ void PhysxActor:: set_contact_report_flag(PhysxContactPairFlag flag, bool value) { @@ -921,12 +761,9 @@ set_contact_report_flag(PhysxContactPairFlag flag, bool value) { _ptr->setContactReportFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_contact_report_threshold -// Access: Published -// Description: Sets the force threshold for contact reports. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the force threshold for contact reports. The actor must be dynamic. + */ void PhysxActor:: set_contact_report_threshold(float threshold) { @@ -936,22 +773,18 @@ set_contact_report_threshold(float threshold) { _ptr->setContactReportThreshold(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_group -// Access: Published -// Description: Assigns the actor to a user defined group of -// actors. The actor group must be an integer in -// between 0 and 0x7fff (32767). -// -// This is similar to NxShape groups, except those are -// only five bits and serve a different purpose. -// -// The PhysxScene::set_actor_group_pair_flags() lets -// you set certain behaviors for pairs of actor -// groups. -// -// By default every actor is created in group 0. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the actor to a user defined group of actors. The actor group must + * be an integer in between 0 and 0x7fff (32767). + * + * This is similar to NxShape groups, except those are only five bits and + * serve a different purpose. + * + * The PhysxScene::set_actor_group_pair_flags() lets you set certain behaviors + * for pairs of actor groups. + * + * By default every actor is created in group 0. + */ void PhysxActor:: set_group(unsigned int group) { @@ -961,12 +794,9 @@ set_group(unsigned int group) { ptr()->setGroup(group); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_group -// Access: Published -// Description: Retrieves the actor group this actor is assigned -// to. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actor group this actor is assigned to. + */ unsigned int PhysxActor:: get_group() const { @@ -975,24 +805,18 @@ get_group() const { return ptr()->getGroup(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_dominance_group -// Access: Published -// Description: Assigns dynamic actors a dominance group -// identifier. Dominance groups are integere in the -// range from 0 to 31. -// -// This is similar to shape groups, except those serve -// a different purpose. -// -// The PhysxScene::set_dominance_group_pair() lets you -// set certain behaviors for pairs of dominance -// groups. -// -// By default every actor is created in group 0. -// Static actors must stay in group 0; thus you can -// only call this on dynamic actors. -//////////////////////////////////////////////////////////////////// +/** + * Assigns dynamic actors a dominance group identifier. Dominance groups are + * integere in the range from 0 to 31. + * + * This is similar to shape groups, except those serve a different purpose. + * + * The PhysxScene::set_dominance_group_pair() lets you set certain behaviors + * for pairs of dominance groups. + * + * By default every actor is created in group 0. Static actors must stay in + * group 0; thus you can only call this on dynamic actors. + */ void PhysxActor:: set_dominance_group(unsigned int group) { @@ -1003,11 +827,9 @@ set_dominance_group(unsigned int group) { _ptr->setDominanceGroup(group); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_dominance_group -// Access: Published -// Description: Retrieves the dominance group of this actor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the dominance group of this actor. + */ unsigned int PhysxActor:: get_dominance_group() const { @@ -1016,15 +838,11 @@ get_dominance_group() const { return ptr()->getDominanceGroup(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_angular_damping -// Access: Published -// Description: Sets the angular damping coefficient. Zero -// represents no damping. The angular damping -// coefficient must be nonnegative. The actor must be -// dynamic. -// Default: 0.05 -//////////////////////////////////////////////////////////////////// +/** + * Sets the angular damping coefficient. Zero represents no damping. The + * angular damping coefficient must be nonnegative. The actor must be + * dynamic. Default: 0.05 + */ void PhysxActor:: set_angular_damping(float angDamp) { @@ -1034,12 +852,9 @@ set_angular_damping(float angDamp) { _ptr->setAngularDamping(angDamp); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_angular_damping -// Access: Published -// Description: Returns the angular damping coefficient. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angular damping coefficient. The actor must be dynamic. + */ float PhysxActor:: get_angular_damping() const { @@ -1047,14 +862,11 @@ get_angular_damping() const { return _ptr->getAngularDamping(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_linear_damping -// Access: Published -// Description: Sets the linear damping coefficient. Zero -// represents no damping. The damping coefficient must -// be nonnegative. The actor must be dynamic. -// Default: 0 -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear damping coefficient. Zero represents no damping. The + * damping coefficient must be nonnegative. The actor must be dynamic. + * Default: 0 + */ void PhysxActor:: set_linear_damping(float linDamp) { @@ -1064,12 +876,9 @@ set_linear_damping(float linDamp) { _ptr->setLinearDamping(linDamp); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_linear_damping -// Access: Published -// Description: Retrieves the linear damping coefficient. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the linear damping coefficient. The actor must be dynamic. + */ float PhysxActor:: get_linear_damping() const { @@ -1077,19 +886,15 @@ get_linear_damping() const { return _ptr->getLinearDamping(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_linear_velocity -// Access: Published -// Description: Sets the linear velocity of the actor. -// -// Note that if you continuously set the velocity of -// an actor yourself, forces such as gravity or -// friction will not be able to manifest themselves, -// because forces directly influence only the -// velocity/momentum of an actor. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear velocity of the actor. + * + * Note that if you continuously set the velocity of an actor yourself, forces + * such as gravity or friction will not be able to manifest themselves, + * because forces directly influence only the velocity/momentum of an actor. + * + * The actor must be dynamic. + */ void PhysxActor:: set_linear_velocity(const LVector3f &linVel) { @@ -1099,19 +904,15 @@ set_linear_velocity(const LVector3f &linVel) { _ptr->setLinearVelocity(PhysxManager::vec3_to_nxVec3(linVel)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_angular_velocity -// Access: Published -// Description: Sets the angular velocity of the actor. -// -// Note that if you continuously set the angular -// velocity of an actor yourself, forces such as -// friction will not be able to rotate the actor, -// because forces directly influence only the -// velocity/momentum. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the angular velocity of the actor. + * + * Note that if you continuously set the angular velocity of an actor + * yourself, forces such as friction will not be able to rotate the actor, + * because forces directly influence only the velocity/momentum. + * + * The actor must be dynamic. + */ void PhysxActor:: set_angular_velocity(const LVector3f &angVel) { @@ -1121,32 +922,25 @@ set_angular_velocity(const LVector3f &angVel) { _ptr->setAngularVelocity(PhysxManager::vec3_to_nxVec3(angVel)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_max_angular_velocity -// Access: Published -// Description: Lets you set the maximum angular velocity permitted -// for this actor. -// -// Because for various internal computations, very -// quickly rotating actors introduce error into the -// simulation, which leads to undesired results. -// -// With PhysxManager::set_parameter(PP_max_angular_velocity) -// you can set the default maximum velocity for actors -// created after the call. Bodies' high angular -// velocities are clamped to this value. -// -// However, because some actors, such as car wheels, -// should be able to rotate quickly, you can override -// the default setting on a per-actor basis with the -// below call. Note that objects such as wheels which -// are approximated with spherical or other smooth -// collision primitives can be simulated with -// stability at a much higher angular velocity than, -// say, a box that has corners. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Lets you set the maximum angular velocity permitted for this actor. + * + * Because for various internal computations, very quickly rotating actors + * introduce error into the simulation, which leads to undesired results. + * + * With PhysxManager::set_parameter(PP_max_angular_velocity) you can set the + * default maximum velocity for actors created after the call. Bodies' high + * angular velocities are clamped to this value. + * + * However, because some actors, such as car wheels, should be able to rotate + * quickly, you can override the default setting on a per-actor basis with the + * below call. Note that objects such as wheels which are approximated with + * spherical or other smooth collision primitives can be simulated with + * stability at a much higher angular velocity than, say, a box that has + * corners. + * + * The actor must be dynamic. + */ void PhysxActor:: set_max_angular_velocity(float maxAngVel) { @@ -1156,12 +950,9 @@ set_max_angular_velocity(float maxAngVel) { _ptr->setMaxAngularVelocity(maxAngVel); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_linear_velocity -// Access: Published -// Description: Returns the linear velocity of an actor. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear velocity of an actor. The actor must be dynamic. + */ LVector3f PhysxActor:: get_linear_velocity() const { @@ -1169,12 +960,9 @@ get_linear_velocity() const { return PhysxManager::nxVec3_to_vec3(_ptr->getLinearVelocity()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_angular_velocity -// Access: Published -// Description: Returns the angular velocity of the actor. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angular velocity of the actor. The actor must be dynamic. + */ LVector3f PhysxActor:: get_angular_velocity() const { @@ -1182,12 +970,9 @@ get_angular_velocity() const { return PhysxManager::nxVec3_to_vec3(_ptr->getAngularVelocity()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_max_angular_velocity -// Access: Published -// Description: Returns the maximum angular velocity permitted -// for this actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum angular velocity permitted for this actor. + */ float PhysxActor:: get_max_angular_velocity() const { @@ -1195,15 +980,12 @@ get_max_angular_velocity() const { return _ptr->getMaxAngularVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_point_velocity -// Access: Published -// Description: Computes the velocity of a point given in world -// coordinates if it were attached to the actor and -// moving with it. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Computes the velocity of a point given in world coordinates if it were + * attached to the actor and moving with it. + * + * The actor must be dynamic. + */ LVector3f PhysxActor:: get_point_velocity(const LPoint3f &point) const { @@ -1214,15 +996,12 @@ get_point_velocity(const LPoint3f &point) const { return PhysxManager::nxVec3_to_vec3(_ptr->getPointVelocity(nPoint)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_local_point_velocity -// Access: Published -// Description: Computes the velocity of a point given in body -// local coordinates as if it were attached to the -// actor and moving with it. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Computes the velocity of a point given in body local coordinates as if it + * were attached to the actor and moving with it. + * + * The actor must be dynamic. + */ LVector3f PhysxActor:: get_local_point_velocity(const LPoint3f &point) const { @@ -1233,17 +1012,13 @@ get_local_point_velocity(const LPoint3f &point) const { return PhysxManager::nxVec3_to_vec3(_ptr->getLocalPointVelocity(nPoint)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_linear_momentum -// Access: Published -// Description: Sets the linear momentum of the actor. -// Note that if you continuously set the linear -// momentum of an actor yourself, forces such as -// gravity or friction will not be able to manifest -// themselves, because forces directly influence only -// the velocity/momentum of a actor. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear momentum of the actor. Note that if you continuously set + * the linear momentum of an actor yourself, forces such as gravity or + * friction will not be able to manifest themselves, because forces directly + * influence only the velocity/momentum of a actor. The actor must be + * dynamic. + */ void PhysxActor:: set_linear_momentum(const LVector3f &momentum) { @@ -1251,17 +1026,12 @@ set_linear_momentum(const LVector3f &momentum) { _ptr->setLinearMomentum(PhysxManager::vec3_to_nxVec3(momentum)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_angular_momentum -// Access: Published -// Description: Sets the angular momentum of the actor. -// Note that if you continuously set the angular -// velocity of an actor yourself, forces such as -// friction will not be able to rotate the actor, -// because forces directly influence only the velocity -// of actor. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the angular momentum of the actor. Note that if you continuously set + * the angular velocity of an actor yourself, forces such as friction will not + * be able to rotate the actor, because forces directly influence only the + * velocity of actor. The actor must be dynamic. + */ void PhysxActor:: set_angular_momentum(const LVector3f &momentum) { @@ -1269,14 +1039,10 @@ set_angular_momentum(const LVector3f &momentum) { _ptr->setAngularMomentum(PhysxManager::vec3_to_nxVec3(momentum)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_linear_momentum -// Access: Published -// Description: Retrieves the linear momentum of an actor. -// The momentum is equal to the velocity times the -// mass. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the linear momentum of an actor. The momentum is equal to the + * velocity times the mass. The actor must be dynamic. + */ LVector3f PhysxActor:: get_linear_momentum() const { @@ -1284,14 +1050,11 @@ get_linear_momentum() const { return PhysxManager::nxVec3_to_vec3(_ptr->getLinearMomentum()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_angular_momentum -// Access: Published -// Description: Retrieves the angular momentum of an actor. -// The angular momentum is equal to the angular -// velocity times the global space inertia tensor. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the angular momentum of an actor. The angular momentum is equal + * to the angular velocity times the global space inertia tensor. The actor + * must be dynamic. + */ LVector3f PhysxActor:: get_angular_momentum() const { @@ -1299,19 +1062,15 @@ get_angular_momentum() const { return PhysxManager::nxVec3_to_vec3(_ptr->getAngularMomentum()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_sleep_linear_velocity -// Access: Published -// Description: Sets the linear velocity below which an actor may -// go to sleep. Actors whose linear velocity is above -// this threshold will not be put to sleep. -// -// Setting the sleep angular/linear velocity only -// makes sense when the BF_energy_sleep_test is not -// set. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear velocity below which an actor may go to sleep. Actors + * whose linear velocity is above this threshold will not be put to sleep. + * + * Setting the sleep angular/linear velocity only makes sense when the + * BF_energy_sleep_test is not set. + * + * The actor must be dynamic. + */ void PhysxActor:: set_sleep_linear_velocity(float threshold) { @@ -1319,19 +1078,15 @@ set_sleep_linear_velocity(float threshold) { _ptr->setSleepLinearVelocity(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_sleep_angular_velocity -// Access: Published -// Description: Sets the angular velocity below which an actor may -// go to sleep. Actors whose angular velocity is -// above this threshold will not be put to sleep. -// -// Setting the sleep angular/linear velocity only -// makes sense when the BF_energy_sleep_test is not -// set. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the angular velocity below which an actor may go to sleep. Actors + * whose angular velocity is above this threshold will not be put to sleep. + * + * Setting the sleep angular/linear velocity only makes sense when the + * BF_energy_sleep_test is not set. + * + * The actor must be dynamic. + */ void PhysxActor:: set_sleep_angular_velocity(float threshold) { @@ -1339,21 +1094,16 @@ set_sleep_angular_velocity(float threshold) { _ptr->setSleepAngularVelocity(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_sleep_energy_threshold -// Access: Published -// Description: Sets the energy threshold below which an actor may -// go to sleep. Actors whose kinematic energy is above -// this threshold will not be put to sleep. -// -// Setting the sleep energy threshold only makes sense -// when the BF_energy_sleep_test is set. There are -// also other types of sleeping that uses the linear -// and angular velocities directly instead of the -// energy. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Sets the energy threshold below which an actor may go to sleep. Actors + * whose kinematic energy is above this threshold will not be put to sleep. + * + * Setting the sleep energy threshold only makes sense when the + * BF_energy_sleep_test is set. There are also other types of sleeping that + * uses the linear and angular velocities directly instead of the energy. + * + * The actor must be dynamic. + */ void PhysxActor:: set_sleep_energy_threshold(float threshold) { @@ -1361,14 +1111,11 @@ set_sleep_energy_threshold(float threshold) { _ptr->setSleepEnergyThreshold(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_sleep_linear_velocity -// Access: Published -// Description: Returns the linear velocity below which an actor -// may go to sleep. Actors whose linear velocity is -// above this threshold will not be put to sleep. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear velocity below which an actor may go to sleep. Actors + * whose linear velocity is above this threshold will not be put to sleep. + * The actor must be dynamic. + */ float PhysxActor:: get_sleep_linear_velocity() const { @@ -1376,14 +1123,11 @@ get_sleep_linear_velocity() const { return _ptr->getSleepLinearVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_sleep_angular_velocity -// Access: Published -// Description: Returns the angular velocity below which an actor -// may go to sleep. Actors whose angular velocity is -// above this threshold will not be put to sleep. -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angular velocity below which an actor may go to sleep. Actors + * whose angular velocity is above this threshold will not be put to sleep. + * The actor must be dynamic. + */ float PhysxActor:: get_sleep_angular_velocity() const { @@ -1391,13 +1135,11 @@ get_sleep_angular_velocity() const { return _ptr->getSleepAngularVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_sleep_energy_threshold -// Access: Published -// Description: Returns the energy below which an actor may go to -// sleep. Actors whose energy is above this threshold -// will not be put to sleep. The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns the energy below which an actor may go to sleep. Actors whose + * energy is above this threshold will not be put to sleep. The actor must be + * dynamic. + */ float PhysxActor:: get_sleep_energy_threshold() const { @@ -1405,21 +1147,17 @@ get_sleep_energy_threshold() const { return _ptr->getSleepEnergyThreshold(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::is_sleeping -// Access: Published -// Description: Returns true if this body is sleeping. -// -// When an actor does not move for a period of time, -// it is no longer simulated in order to save time. -// This state is called sleeping. However, because the -// object automatically wakes up when it is either -// touched by an awake object, or one of its -// properties is changed by the user, the entire sleep -// mechanism should be transparent to the user. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this body is sleeping. + * + * When an actor does not move for a period of time, it is no longer simulated + * in order to save time. This state is called sleeping. However, because + * the object automatically wakes up when it is either touched by an awake + * object, or one of its properties is changed by the user, the entire sleep + * mechanism should be transparent to the user. + * + * The actor must be dynamic. + */ bool PhysxActor:: is_sleeping() const { @@ -1427,18 +1165,15 @@ is_sleeping() const { return _ptr->isSleeping(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::wake_up -// Access: Published -// Description: Wakes up the actor if it is sleeping. -// -// The wakeCounterValue determines how long until the -// body is put to sleep, a value of zero means that -// the body is sleeping. wake_up(0) is equivalent to -// PhysxActor::put_to_sleep(). -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Wakes up the actor if it is sleeping. + * + * The wakeCounterValue determines how long until the body is put to sleep, a + * value of zero means that the body is sleeping. wake_up(0) is equivalent to + * PhysxActor::put_to_sleep(). + * + * The actor must be dynamic. + */ void PhysxActor:: wake_up(float wakeCounterValue) { @@ -1446,19 +1181,15 @@ wake_up(float wakeCounterValue) { _ptr->wakeUp(wakeCounterValue); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::put_to_sleep -// Access: Published -// Description: Forces the actor to sleep. -// -// The actor will stay asleep until the next call to -// simulate, and will not wake up until then even when -// otherwise it would (for example a force is applied -// to it). It can however wake up during the next -// do_physics call. -// -// The actor must be dynamic. -//////////////////////////////////////////////////////////////////// +/** + * Forces the actor to sleep. + * + * The actor will stay asleep until the next call to simulate, and will not + * wake up until then even when otherwise it would (for example a force is + * applied to it). It can however wake up during the next do_physics call. + * + * The actor must be dynamic. + */ void PhysxActor:: put_to_sleep() { @@ -1466,11 +1197,9 @@ put_to_sleep() { _ptr->putToSleep(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_mass -// Access: Published -// Description: Sets the mass of a dynamic actor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mass of a dynamic actor. + */ void PhysxActor:: set_mass(float mass) { @@ -1478,11 +1207,9 @@ set_mass(float mass) { _ptr->setMass(mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_mass -// Access: Published -// Description: Returns the mass of the actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mass of the actor. + */ float PhysxActor:: get_mass() const { @@ -1490,12 +1217,9 @@ get_mass() const { return _ptr->getMass(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_local_mat -// Access: Published -// Description: Sets the matrix of the center of mass relative -// to the actor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the matrix of the center of mass relative to the actor. + */ void PhysxActor:: set_c_mass_offset_local_mat(const LMatrix4f &mat) { @@ -1503,12 +1227,9 @@ set_c_mass_offset_local_mat(const LMatrix4f &mat) { _ptr->setCMassOffsetLocalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_local_pos -// Access: Published -// Description: Sets the position of the center of mass relative -// to the actor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the position of the center of mass relative to the actor. + */ void PhysxActor:: set_c_mass_offset_local_pos(const LPoint3f &pos) { @@ -1516,12 +1237,9 @@ set_c_mass_offset_local_pos(const LPoint3f &pos) { _ptr->setCMassOffsetLocalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_local_orientation -// Access: Published -// Description: Sets the orientation of the center of mass relative -// to the actor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the orientation of the center of mass relative to the actor. + */ void PhysxActor:: set_c_mass_offset_local_orientation(const LMatrix3f &mat) { @@ -1529,12 +1247,9 @@ set_c_mass_offset_local_orientation(const LMatrix3f &mat) { _ptr->setCMassOffsetLocalOrientation(PhysxManager::mat3_to_nxMat33(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_global_mat -// Access: Published -// Description: Sets the matrix of the center of mass relative -// to world space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the matrix of the center of mass relative to world space. + */ void PhysxActor:: set_c_mass_offset_global_mat(const LMatrix4f &mat) { @@ -1542,12 +1257,9 @@ set_c_mass_offset_global_mat(const LMatrix4f &mat) { _ptr->setCMassOffsetGlobalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_global_pos -// Access: Published -// Description: Sets the position of the center of mass relative -// to world space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the position of the center of mass relative to world space. + */ void PhysxActor:: set_c_mass_offset_global_pos(const LPoint3f &pos) { @@ -1555,12 +1267,9 @@ set_c_mass_offset_global_pos(const LPoint3f &pos) { _ptr->setCMassOffsetGlobalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_offset_global_orientation -// Access: Published -// Description: Sets the orientation of the center of mass relative -// to world space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the orientation of the center of mass relative to world space. + */ void PhysxActor:: set_c_mass_offset_global_orientation(const LMatrix3f &mat) { @@ -1568,12 +1277,9 @@ set_c_mass_offset_global_orientation(const LMatrix3f &mat) { _ptr->setCMassOffsetGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_global_mat -// Access: Published -// Description: Moves the actor by setting the transform of the -// center of mass. -//////////////////////////////////////////////////////////////////// +/** + * Moves the actor by setting the transform of the center of mass. + */ void PhysxActor:: set_c_mass_global_mat(const LMatrix4f &mat) { @@ -1581,12 +1287,9 @@ set_c_mass_global_mat(const LMatrix4f &mat) { _ptr->setCMassGlobalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_global_pos -// Access: Published -// Description: Moves the actor by setting the position of the -// center of mass. -//////////////////////////////////////////////////////////////////// +/** + * Moves the actor by setting the position of the center of mass. + */ void PhysxActor:: set_c_mass_global_pos(const LPoint3f &pos) { @@ -1594,12 +1297,9 @@ set_c_mass_global_pos(const LPoint3f &pos) { _ptr->setCMassGlobalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_c_mass_global_orientation -// Access: Published -// Description: Moves the actor by setting the orientation of the -// center of mass. -//////////////////////////////////////////////////////////////////// +/** + * Moves the actor by setting the orientation of the center of mass. + */ void PhysxActor:: set_c_mass_global_orientation(const LMatrix3f &mat) { @@ -1607,12 +1307,10 @@ set_c_mass_global_orientation(const LMatrix3f &mat) { _ptr->setCMassGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::set_mass_space_inertia_tensor -// Access: Published -// Description: Sets the inertia tensor, using a parameter -// specified in mass space coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the inertia tensor, using a parameter specified in mass space + * coordinates. + */ void PhysxActor:: set_mass_space_inertia_tensor(const LVector3f &m) { @@ -1620,12 +1318,9 @@ set_mass_space_inertia_tensor(const LVector3f &m) { _ptr->setMassSpaceInertiaTensor(PhysxManager::vec3_to_nxVec3(m)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_global_mat -// Access: Published -// Description: Returns the center of mass transform in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass transform in world space. + */ LMatrix4f PhysxActor:: get_c_mass_global_mat() const { @@ -1633,12 +1328,9 @@ get_c_mass_global_mat() const { return PhysxManager::nxMat34_to_mat4(_ptr->getCMassGlobalPose()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_global_pos -// Access: Published -// Description: Returns the center of mass position in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass position in world space. + */ LPoint3f PhysxActor:: get_c_mass_global_pos() const { @@ -1646,12 +1338,9 @@ get_c_mass_global_pos() const { return PhysxManager::nxVec3_to_point3(_ptr->getCMassGlobalPosition()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_global_orientation -// Access: Published -// Description: Returns the center of mass orientation in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass orientation in world space. + */ LMatrix3f PhysxActor:: get_c_mass_global_orientation() const { @@ -1659,12 +1348,9 @@ get_c_mass_global_orientation() const { return PhysxManager::nxMat33_to_mat3(_ptr->getCMassGlobalOrientation()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_local_mat -// Access: Published -// Description: Returns the center of mass transform relative -// to the actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass transform relative to the actor. + */ LMatrix4f PhysxActor:: get_c_mass_local_mat() const { @@ -1672,12 +1358,9 @@ get_c_mass_local_mat() const { return PhysxManager::nxMat34_to_mat4(_ptr->getCMassLocalPose()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_local_pos -// Access: Published -// Description: Returns the center of mass position relative to -// the actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass position relative to the actor. + */ LPoint3f PhysxActor:: get_c_mass_local_pos() const { @@ -1685,12 +1368,9 @@ get_c_mass_local_pos() const { return PhysxManager::nxVec3_to_point3(_ptr->getCMassLocalPosition()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_c_mass_local_orientation -// Access: Published -// Description: Returns the center of mass orientation relative to -// the actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of mass orientation relative to the actor. + */ LMatrix3f PhysxActor:: get_c_mass_local_orientation() const { @@ -1698,12 +1378,10 @@ get_c_mass_local_orientation() const { return PhysxManager::nxMat33_to_mat3(_ptr->getCMassLocalOrientation()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_mass_space_inertia_tensor -// Access: Published -// Description: Returns the diagonal inertia tensor of the actor -// relative to the mass coordinate frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the diagonal inertia tensor of the actor relative to the mass + * coordinate frame. + */ LVector3f PhysxActor:: get_mass_space_inertia_tensor() const { @@ -1711,12 +1389,10 @@ get_mass_space_inertia_tensor() const { return PhysxManager::nxVec3_to_vec3(_ptr->getMassSpaceInertiaTensor()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_global_inertia_tensor -// Access: Published -// Description: Returns the inertia tensor of the actor relative -// to the world coordinate frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inertia tensor of the actor relative to the world coordinate + * frame. + */ LMatrix3f PhysxActor:: get_global_inertia_tensor() const { @@ -1724,16 +1400,13 @@ get_global_inertia_tensor() const { return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensor()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActor::get_global_inertia_tensor_inverse -// Access: Published -// Description: Returns the inverse of the inertia tensor of the -// actor relative to the world coordinate frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of the inertia tensor of the actor relative to the + * world coordinate frame. + */ LMatrix3f PhysxActor:: get_global_inertia_tensor_inverse() const { nassertr(_error_type == ET_ok, LMatrix3f::ident_mat()); return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensorInverse()); } - diff --git a/panda/src/physx/physxActor.h b/panda/src/physx/physxActor.h index b8bfa9773c..5aaa183463 100644 --- a/panda/src/physx/physxActor.h +++ b/panda/src/physx/physxActor.h @@ -1,16 +1,15 @@ -// Filename: physxActor.h -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActor.h + * @author enn0x + * @date 2009-09-14 + */ #ifndef PHYSXACTOR_H #define PHYSXACTOR_H @@ -31,20 +30,17 @@ class PhysxShapeDesc; class PhysxActorDesc; class PhysxBodyDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxActor -// Description : Actors are the main simulation objects. Actors -// are owned by a scene (PhysxScene). -// -// An actor may optionally encapsulate a dynamic rigid -// body by setting the body member of the actor's -// descriptor when it is created. Otherwise the actor -// will be static (fixed in the world). -// -// Instances of PhysxActor are created by calling -// PhysxScene::create_actor() and destroyed by calling -// PhysxActor::release(). -//////////////////////////////////////////////////////////////////// +/** + * Actors are the main simulation objects. Actors are owned by a scene + * (PhysxScene). + * + * An actor may optionally encapsulate a dynamic rigid body by setting the + * body member of the actor's descriptor when it is created. Otherwise the + * actor will be static (fixed in the world). + * + * Instances of PhysxActor are created by calling PhysxScene::create_actor() + * and destroyed by calling PhysxActor::release(). + */ class EXPCL_PANDAPHYSX PhysxActor : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -94,7 +90,7 @@ PUBLISHED: MAKE_SEQ(get_shapes, get_num_shapes, get_shape); // Forces - void add_force(const LVector3f force, + void add_force(const LVector3f force, PhysxForceMode mode=FM_force, bool wakeup=true); void add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode=FM_force, bool wakeup=true); @@ -150,9 +146,9 @@ PUBLISHED: LVector3f get_angular_velocity() const; float get_max_angular_velocity() const; - // Point Velocity + // Point Velocity LVector3f get_point_velocity(const LPoint3f &point) const; - LVector3f get_local_point_velocity(const LPoint3f &point) const; + LVector3f get_local_point_velocity(const LPoint3f &point) const; // Momentum void set_linear_momentum(const LVector3f &momentum); @@ -182,7 +178,6 @@ PUBLISHED: public: void update_transform(const LMatrix4f &m); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -201,14 +196,13 @@ private: PT(PhysxController) _controller; string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxActor", + register_type(_type_handle, "PhysxActor", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxActorDesc.I b/panda/src/physx/physxActorDesc.I index eaf347bb78..06dfb6b558 100644 --- a/panda/src/physx/physxActorDesc.I +++ b/panda/src/physx/physxActorDesc.I @@ -1,45 +1,36 @@ -// Filename: physxActorDesc.I -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActorDesc.I + * @author enn0x + * @date 2009-09-05 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxActorDesc:: PhysxActorDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxActorDesc:: ~PhysxActorDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxActorDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxActorDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxActorDesc.cxx b/panda/src/physx/physxActorDesc.cxx index ccbac17209..53933cb9e9 100644 --- a/panda/src/physx/physxActorDesc.cxx +++ b/panda/src/physx/physxActorDesc.cxx @@ -1,38 +1,32 @@ -// Filename: physxActorDesc.cxx -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActorDesc.cxx + * @author enn0x + * @date 2009-09-05 + */ #include "physxActorDesc.h" #include "physxBodyDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::add_shape -// Access: Published -// Description: Adds a shape to the list of collision shapes -// composing this actor. -//////////////////////////////////////////////////////////////////// +/** + * Adds a shape to the list of collision shapes composing this actor. + */ void PhysxActorDesc:: add_shape(PhysxShapeDesc &desc) { _desc.shapes.push_back(desc.ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_name -// Access: Published -// Description: Sets the optional debug name for the actor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the optional debug name for the actor. + */ void PhysxActorDesc:: set_name(const char *name) { @@ -40,50 +34,39 @@ set_name(const char *name) { _desc.name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_density -// Access: Published -// Description: Set the density used during mass/intertia -// computation. This value is used if the actor's -// shapes do not have a mass asigned. -//////////////////////////////////////////////////////////////////// +/** + * Set the density used during mass/intertia computation. This value is used + * if the actor's shapes do not have a mass asigned. + */ void PhysxActorDesc:: set_density(float density) { _desc.density = density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_global_pos -// Access: Published -// Description: Set the position of the actor in global space. -//////////////////////////////////////////////////////////////////// +/** + * Set the position of the actor in global space. + */ void PhysxActorDesc:: set_global_pos(const LPoint3f &pos) { _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_global_mat -// Access: Published -// Description: Set the position and orientation of the actor -// in global space. Scaling and shear arenot -// supported, even if the matrix contains a scale or -// shear. -//////////////////////////////////////////////////////////////////// +/** + * Set the position and orientation of the actor in global space. Scaling and + * shear arenot supported, even if the matrix contains a scale or shear. + */ void PhysxActorDesc:: set_global_mat(const LMatrix4f &mat) { _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_global_hpr -// Access: Published -// Description: Sets the orientation of the actor in global space -// by providing angles for heading, pitch and roll. -//////////////////////////////////////////////////////////////////// +/** + * Sets the orientation of the actor in global space by providing angles for + * heading, pitch and roll. + */ void PhysxActorDesc:: set_global_hpr(float h, float p, float r) { @@ -97,75 +80,59 @@ set_global_hpr(float h, float p, float r) { _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::set_body -// Access: Published -// Description: Sets the body descriptor for this actor. The actor -// will be dynmaic if a body descriptor is set, and -// static if no body descriptor is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the body descriptor for this actor. The actor will be dynmaic if a + * body descriptor is set, and static if no body descriptor is set. + */ void PhysxActorDesc:: set_body(PhysxBodyDesc &desc) { _desc.body = &(desc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::get_body -// Access: Published -// Description: Gets the body descriptor for this actor. -//////////////////////////////////////////////////////////////////// +/** + * Gets the body descriptor for this actor. + */ PhysxBodyDesc PhysxActorDesc:: get_body() const { assert(false /* Not implemented */); - //PhysxBodyDesc value; - //value._desc = *(_desc.body); - //return value; + // PhysxBodyDesc value; value._desc = *(_desc.body); return value; return PhysxBodyDesc(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::get_name -// Access: Published -// Description: Returns the optional debug name for this actor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the optional debug name for this actor. + */ const char *PhysxActorDesc:: get_name() const { return _desc.name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::get_density -// Access: Published -// Description: Returns the actor's density. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actor's density. + */ float PhysxActorDesc:: get_density() const { return _desc.density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::get_global_pos -// Access: Published -// Description: Returns the actor's position in global space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actor's position in global space. + */ LPoint3f PhysxActorDesc:: get_global_pos() const { return PhysxManager::nxVec3_to_point3(_desc.globalPose.t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxActorDesc::get_global_mat -// Access: Published -// Description: Returns the actor's transform in global space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actor's transform in global space. + */ LMatrix4f PhysxActorDesc:: get_global_mat() const { return PhysxManager::nxMat34_to_mat4(_desc.globalPose); } - diff --git a/panda/src/physx/physxActorDesc.h b/panda/src/physx/physxActorDesc.h index 3f41e763c2..84a948b815 100644 --- a/panda/src/physx/physxActorDesc.h +++ b/panda/src/physx/physxActorDesc.h @@ -1,16 +1,15 @@ -// Filename: physxActorDesc.h -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxActorDesc.h + * @author enn0x + * @date 2009-09-05 + */ #ifndef PHYSXACTORDESC_H #define PHYSXACTORDESC_H @@ -23,10 +22,9 @@ class PhysxBodyDesc; class PhysxShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxActorDesc -// Description : Descriptor for PhysxActor. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for PhysxActor. + */ class EXPCL_PANDAPHYSX PhysxActorDesc { PUBLISHED: diff --git a/panda/src/physx/physxBodyDesc.I b/panda/src/physx/physxBodyDesc.I index 35b1eb06d5..f223344c59 100644 --- a/panda/src/physx/physxBodyDesc.I +++ b/panda/src/physx/physxBodyDesc.I @@ -1,58 +1,46 @@ -// Filename: physxBodyDesc.I -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBodyDesc.I + * @author enn0x + * @date 2009-09-05 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBodyDesc:: PhysxBodyDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBodyDesc:: ~PhysxBodyDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxBodyDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxBodyDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxBodyDesc.cxx b/panda/src/physx/physxBodyDesc.cxx index 9dfbeca7a2..7a5d8181b0 100644 --- a/panda/src/physx/physxBodyDesc.cxx +++ b/panda/src/physx/physxBodyDesc.cxx @@ -1,330 +1,259 @@ -// Filename: physxBodyDesc.cxx -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBodyDesc.cxx + * @author enn0x + * @date 2009-09-05 + */ #include "physxBodyDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_mass -// Access: Published -// Description: Set the mass of body. -//////////////////////////////////////////////////////////////////// +/** + * Set the mass of body. + */ void PhysxBodyDesc:: set_mass(float mass) { _desc.mass = mass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_mass -// Access: Published -// Description: Get the mass of body. -//////////////////////////////////////////////////////////////////// +/** + * Get the mass of body. + */ float PhysxBodyDesc:: get_mass() const { return _desc.mass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_linear_damping -// Access: Published -// Description: Set the linear damping applied to the body. -//////////////////////////////////////////////////////////////////// +/** + * Set the linear damping applied to the body. + */ void PhysxBodyDesc:: set_linear_damping(float damping) { _desc.linearDamping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_linear_damping -// Access: Published -// Description: Get the linear damping applied to the body. -//////////////////////////////////////////////////////////////////// +/** + * Get the linear damping applied to the body. + */ float PhysxBodyDesc:: get_linear_damping() const { return _desc.linearDamping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_angular_damping -// Access: Published -// Description: Set the angular damping applied to the body. -//////////////////////////////////////////////////////////////////// +/** + * Set the angular damping applied to the body. + */ void PhysxBodyDesc:: set_angular_damping(float damping) { _desc.angularDamping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_angular_damping -// Access: Published -// Description: Get the angular damping applied to the body. -//////////////////////////////////////////////////////////////////// +/** + * Get the angular damping applied to the body. + */ float PhysxBodyDesc:: get_angular_damping() const { return _desc.angularDamping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_linear_velocity -// Access: Published -// Description: Set the linear Velocity of the body. -//////////////////////////////////////////////////////////////////// +/** + * Set the linear Velocity of the body. + */ void PhysxBodyDesc:: set_linear_velocity(const LVector3f &velocity) { _desc.linearVelocity = PhysxManager::vec3_to_nxVec3(velocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_linear_velocity -// Access: Published -// Description: Get the linear Velocity of the body. -//////////////////////////////////////////////////////////////////// +/** + * Get the linear Velocity of the body. + */ LVector3f PhysxBodyDesc:: get_linear_velocity() const { return PhysxManager::nxVec3_to_vec3(_desc.linearVelocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_angular_velocity -// Access: Published -// Description: Set the angular velocity of the body. -//////////////////////////////////////////////////////////////////// +/** + * Set the angular velocity of the body. + */ void PhysxBodyDesc:: set_angular_velocity(const LVector3f &velocity) { _desc.angularVelocity = PhysxManager::vec3_to_nxVec3(velocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_angular_velocity -// Access: Published -// Description: Get the angular velocity of the body. -//////////////////////////////////////////////////////////////////// +/** + * Get the angular velocity of the body. + */ LVector3f PhysxBodyDesc:: get_angular_velocity() const { return PhysxManager::nxVec3_to_vec3(_desc.angularVelocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_max_angular_velocity -// Access: Published -// Description: Set the maximum allowed angular velocity for this -// body. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum allowed angular velocity for this body. + */ void PhysxBodyDesc:: set_max_angular_velocity(float maximum) { _desc.maxAngularVelocity = maximum; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_max_angular_velocity -// Access: Published -// Description: Get the maximum allowed angular velocity for this -// body. -//////////////////////////////////////////////////////////////////// +/** + * Get the maximum allowed angular velocity for this body. + */ float PhysxBodyDesc:: get_max_angular_velocity() const { return _desc.maxAngularVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_sleep_linear_velocity -// Access: Published -// Description: Set the maximum linear velocity at which the body -// can go to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum linear velocity at which the body can go to sleep. + */ void PhysxBodyDesc:: set_sleep_linear_velocity(float velocity) { _desc.sleepLinearVelocity = velocity; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_sleep_linear_velocity -// Access: Published -// Description: Get the maximum linear velocity at which the body -// can go to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Get the maximum linear velocity at which the body can go to sleep. + */ float PhysxBodyDesc:: get_sleep_linear_velocity() const { return _desc.sleepLinearVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_sleep_angular_velocity -// Access: Published -// Description: Set the maximum angular velocity at which body -// can go to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum angular velocity at which body can go to sleep. + */ void PhysxBodyDesc:: set_sleep_angular_velocity(float velocity) { _desc.sleepAngularVelocity = velocity; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_sleep_angular_velocity -// Access: Published -// Description: Get the maximum angular velocity at which body -// can go to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Get the maximum angular velocity at which body can go to sleep. + */ float PhysxBodyDesc:: get_sleep_angular_velocity() const { return _desc.sleepAngularVelocity; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_solver_iteration_count -// Access: Published -// Description: Set the number of solver iterations performed -// when processing joint/contacts connected to this -// body. -//////////////////////////////////////////////////////////////////// +/** + * Set the number of solver iterations performed when processing + * joint/contacts connected to this body. + */ void PhysxBodyDesc:: set_solver_iteration_count(unsigned int count) { _desc.solverIterationCount = count; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_solver_iteration_count -// Access: Published -// Description: Get the number of solver iterations performed -// when processing joint/contacts connected to this -// body. -//////////////////////////////////////////////////////////////////// +/** + * Get the number of solver iterations performed when processing + * joint/contacts connected to this body. + */ unsigned int PhysxBodyDesc:: get_solver_iteration_count() const { return _desc.solverIterationCount; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_sleep_energy_threshold -// Access: Published -// Description: Set the threshold for the energy-based sleeping -// algorithm. Only used when the BF_energy_sleep_test -// flag is set. -//////////////////////////////////////////////////////////////////// +/** + * Set the threshold for the energy-based sleeping algorithm. Only used when + * the BF_energy_sleep_test flag is set. + */ void PhysxBodyDesc:: set_sleep_energy_threshold(float threshold) { _desc.sleepEnergyThreshold = threshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_sleep_energy_threshold -// Access: Published -// Description: Get the threshold for the energy-based sleeping -// algorithm. Only used when the BF_energy_sleep_test -// flag is set. -//////////////////////////////////////////////////////////////////// +/** + * Get the threshold for the energy-based sleeping algorithm. Only used when + * the BF_energy_sleep_test flag is set. + */ float PhysxBodyDesc:: get_sleep_energy_threshold() const { return _desc.sleepEnergyThreshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_sleep_damping -// Access: Published -// Description: Set the damping factor for bodies that are about -// to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Set the damping factor for bodies that are about to sleep. + */ void PhysxBodyDesc:: set_sleep_damping(float damping) { _desc.sleepDamping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_sleep_damping -// Access: Published -// Description: Get the damping factor for bodies that are about -// to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Get the damping factor for bodies that are about to sleep. + */ float PhysxBodyDesc:: get_sleep_damping() const { return _desc.sleepDamping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_mass_local_mat -// Access: Published -// Description: Set the position and orientation of the center -// of mass. -//////////////////////////////////////////////////////////////////// +/** + * Set the position and orientation of the center of mass. + */ void PhysxBodyDesc:: set_mass_local_mat(const LMatrix4f &mat) { _desc.massLocalPose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_mass_local_mat -// Access: Published -// Description: Get the position and orientation of the center -// of mass. -//////////////////////////////////////////////////////////////////// +/** + * Get the position and orientation of the center of mass. + */ LMatrix4f PhysxBodyDesc:: get_mass_local_mat() const { return PhysxManager::nxMat34_to_mat4(_desc.massLocalPose); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_mass_space_inertia -// Access: Published -// Description: Set the diagonal mass space inertia tensor in -// bodies mass frame. -//////////////////////////////////////////////////////////////////// +/** + * Set the diagonal mass space inertia tensor in bodies mass frame. + */ void PhysxBodyDesc:: set_mass_space_inertia(const LVector3f &inertia) { _desc.massSpaceInertia = PhysxManager::vec3_to_nxVec3(inertia); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_mass_space_inertia -// Access: Published -// Description: Get the diagonal mass space inertia tensor in -// bodies mass frame. -//////////////////////////////////////////////////////////////////// +/** + * Get the diagonal mass space inertia tensor in bodies mass frame. + */ LVector3f PhysxBodyDesc:: get_mass_space_inertia() const { return PhysxManager::nxVec3_to_vec3(_desc.massSpaceInertia); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_flag -// Access: Published -// Description: Raise or lower individual body flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual body flags. + */ void PhysxBodyDesc:: set_flag(const PhysxBodyFlag flag, bool value) { @@ -336,82 +265,66 @@ set_flag(const PhysxBodyFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_flag -// Access: Published -// Description: Returns the specified body flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified body flag. + */ bool PhysxBodyDesc:: get_flag(const PhysxBodyFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_ccd_motion_threshold -// Access: Published -// Description: When CCD is globally enabled, it is still not -// performed if the motion distance of all points on -// the body is below this threshold. -//////////////////////////////////////////////////////////////////// +/** + * When CCD is globally enabled, it is still not performed if the motion + * distance of all points on the body is below this threshold. + */ void PhysxBodyDesc:: set_ccd_motion_threshold(float threshold) { _desc.CCDMotionThreshold = threshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_ccd_motion_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxBodyDesc:: get_ccd_motion_threshold() const { return _desc.CCDMotionThreshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_wake_up_counter -// Access: Published -// Description: Set the body's initial wake up counter. -//////////////////////////////////////////////////////////////////// +/** + * Set the body's initial wake up counter. + */ void PhysxBodyDesc:: set_wake_up_counter(float value) { _desc.wakeUpCounter = value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_wake_up_counter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxBodyDesc:: get_wake_up_counter() const { return _desc.wakeUpCounter; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::set_contact_report_threshold -// Access: Published -// Description: Set The force threshold for contact reports. -//////////////////////////////////////////////////////////////////// +/** + * Set The force threshold for contact reports. + */ void PhysxBodyDesc:: set_contact_report_threshold(float threshold) { _desc.contactReportThreshold = threshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBodyDesc::get_contact_report_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxBodyDesc:: get_contact_report_threshold() const { return _desc.contactReportThreshold; } - diff --git a/panda/src/physx/physxBodyDesc.h b/panda/src/physx/physxBodyDesc.h index e4aca2ac23..35fc2be5e3 100644 --- a/panda/src/physx/physxBodyDesc.h +++ b/panda/src/physx/physxBodyDesc.h @@ -1,16 +1,15 @@ -// Filename: physxBodyDesc.h -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBodyDesc.h + * @author enn0x + * @date 2009-09-05 + */ #ifndef PHYSXBODYDESC_H #define PHYSXBODYDESC_H @@ -21,11 +20,9 @@ #include "physxEnums.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBodyDesc -// Description : Descriptor for the optional rigid body dynamic -// state of PhysxActor. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for the optional rigid body dynamic state of PhysxActor. + */ class EXPCL_PANDAPHYSX PhysxBodyDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxBounds3.I b/panda/src/physx/physxBounds3.I index 305ca00180..d9d85775a6 100644 --- a/panda/src/physx/physxBounds3.I +++ b/panda/src/physx/physxBounds3.I @@ -1,35 +1,28 @@ -// Filename: physxBounds3.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBounds3.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBounds3:: PhysxBounds3() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBounds3:: ~PhysxBounds3() { } - diff --git a/panda/src/physx/physxBounds3.cxx b/panda/src/physx/physxBounds3.cxx index c38a302973..17cbdfa661 100644 --- a/panda/src/physx/physxBounds3.cxx +++ b/panda/src/physx/physxBounds3.cxx @@ -1,47 +1,40 @@ -// Filename: physxBounds3.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBounds3.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxBounds3.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::get_max -// Access: Published -// Description: Returns the minimum corner of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum corner of the bounding box. + */ LPoint3f PhysxBounds3:: get_max() const { return PhysxManager::nxVec3_to_point3(_bounds.max); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::get_min -// Access: Published -// Description: Returns the maximum corner of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum corner of the bounding box. + */ LPoint3f PhysxBounds3:: get_min() const { return PhysxManager::nxVec3_to_point3(_bounds.min); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::get_center -// Access: Published -// Description: Returns the center of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of the bounding box. + */ LPoint3f PhysxBounds3:: get_center() const { @@ -50,11 +43,9 @@ get_center() const { return PhysxManager::nxVec3_to_point3(center); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::get_dimensions -// Access: Published -// Description: Returns the extents of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extents of the bounding box. + */ LVector3f PhysxBounds3:: get_dimensions() const { @@ -63,11 +54,9 @@ get_dimensions() const { return PhysxManager::nxVec3_to_vec3(dims); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set_max -// Access: Published -// Description: Sets the maximum corner of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum corner of the bounding box. + */ void PhysxBounds3:: set_max(LPoint3f value) { @@ -76,11 +65,9 @@ set_max(LPoint3f value) { _bounds.max = PhysxManager::point3_to_nxVec3(value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set_min -// Access: Published -// Description: Sets the minimum corner of the bounding box. -//////////////////////////////////////////////////////////////////// +/** + * Sets the minimum corner of the bounding box. + */ void PhysxBounds3:: set_min(LPoint3f value) { @@ -89,14 +76,11 @@ set_min(LPoint3f value) { _bounds.min = PhysxManager::point3_to_nxVec3(value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::bounds_of_obb -// Access: Published -// Description: Sets this to the AABB (axis ligned bounding box) -// of the OBB (oriented bounding box). The OBB is -// described by orientation, translation and half -// dimensions. -//////////////////////////////////////////////////////////////////// +/** + * Sets this to the AABB (axis ligned bounding box) of the OBB (oriented + * bounding box). The OBB is described by orientation, translation and half + * dimensions. + */ void PhysxBounds3:: bounds_of_obb(const LMatrix3f &orientation, const LPoint3f &translation, const LVector3f &half_dims) { @@ -109,22 +93,18 @@ bounds_of_obb(const LMatrix3f &orientation, const LPoint3f &translation, const L PhysxManager::vec3_to_nxVec3(half_dims)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::combine -// Access: Published -// Description: Sets this to the union of this and b2. -//////////////////////////////////////////////////////////////////// +/** + * Sets this to the union of this and b2. + */ void PhysxBounds3:: combine(const PhysxBounds3 &b2) { _bounds.combine(b2._bounds); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::contain -// Access: Published -// Description: Returns TRUE if these bounds contain the point v. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if these bounds contain the point v. + */ bool PhysxBounds3:: contain(const LPoint3f &p) const { @@ -133,23 +113,18 @@ contain(const LPoint3f &p) const { return _bounds.contain(PhysxManager::point3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::fatten -// Access: Published -// Description: Fattens the AABB in all three dimensions by the -// given distance. -//////////////////////////////////////////////////////////////////// +/** + * Fattens the AABB in all three dimensions by the given distance. + */ void PhysxBounds3:: fatten(float distance) { _bounds.fatten(distance); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::include -// Access: Published -// Description: Expands the volume to include the point v. -//////////////////////////////////////////////////////////////////// +/** + * Expands the volume to include the point v. + */ void PhysxBounds3:: include(const LPoint3f &p) { @@ -157,59 +132,46 @@ include(const LPoint3f &p) { _bounds.include(PhysxManager::point3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::intersects -// Access: Published -// Description: Returns TRUE if the intersection of this and b is -// is not empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the intersection of this and b is is not empty. + */ bool PhysxBounds3:: intersects(const PhysxBounds3 &b) const { return _bounds.intersects(b._bounds); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::intersects2d -// Access: Published -// Description: Indicates whether the intersection of this and b -// is empty or not in the plane orthogonal to the -// axis passed (X = 0, Y = 1 or Z = 2). -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the intersection of this and b is empty or not in the + * plane orthogonal to the axis passed (X = 0, Y = 1 or Z = 2). + */ bool PhysxBounds3:: intersects2d(const PhysxBounds3 &b, unsigned axis_to_ignore) const { return _bounds.intersects2D(b._bounds, axis_to_ignore); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::is_empty -// Access: Published -// Description: Returns TRUE if the bounding box is empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the bounding box is empty. + */ bool PhysxBounds3:: is_empty() const { return _bounds.isEmpty(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::scale -// Access: Published -// Description: Scales the AABB by the given factor. -//////////////////////////////////////////////////////////////////// +/** + * Scales the AABB by the given factor. + */ void PhysxBounds3:: scale(float scale) { _bounds.scale(scale); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set -// Access: Published -// Description: Setup this AABB from minimum corner and maximum -// corner. -//////////////////////////////////////////////////////////////////// +/** + * Setup this AABB from minimum corner and maximum corner. + */ void PhysxBounds3:: set(const LPoint3f &min, const LPoint3f &max) { @@ -220,12 +182,9 @@ set(const LPoint3f &min, const LPoint3f &max) { PhysxManager::point3_to_nxVec3(max)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set_center_extents -// Access: Published -// Description: Setup this AABB from center point and extents -// vector. -//////////////////////////////////////////////////////////////////// +/** + * Setup this AABB from center point and extents vector. + */ void PhysxBounds3:: set_center_extents(const LPoint3f ¢er, const LVector3f &extents) { @@ -236,36 +195,29 @@ set_center_extents(const LPoint3f ¢er, const LVector3f &extents) { PhysxManager::vec3_to_nxVec3(extents)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set_empty -// Access: Published -// Description: Sets empty to TRUE. -//////////////////////////////////////////////////////////////////// +/** + * Sets empty to TRUE. + */ void PhysxBounds3:: set_empty() { _bounds.setEmpty(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::set_infinite -// Access: Published -// Description: Sets infinite bounds. -//////////////////////////////////////////////////////////////////// +/** + * Sets infinite bounds. + */ void PhysxBounds3:: set_infinite() { _bounds.setInfinite(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBounds3::transform -// Access: Published -// Description: Transforms this volume as if it was an axis aligned -// bounding box, and then assigns the results' bounds -// to this. The orientation is applied first, then the -// translation. -//////////////////////////////////////////////////////////////////// +/** + * Transforms this volume as if it was an axis aligned bounding box, and then + * assigns the results' bounds to this. The orientation is applied first, + * then the translation. + */ void PhysxBounds3:: transform(const LMatrix3f &orientation, const LPoint3f &translation) { @@ -275,4 +227,3 @@ transform(const LMatrix3f &orientation, const LPoint3f &translation) { _bounds.transform(PhysxManager::mat3_to_nxMat33(orientation), PhysxManager::point3_to_nxVec3(translation)); } - diff --git a/panda/src/physx/physxBounds3.h b/panda/src/physx/physxBounds3.h index 5920f8c991..4d7ec50d26 100644 --- a/panda/src/physx/physxBounds3.h +++ b/panda/src/physx/physxBounds3.h @@ -1,16 +1,15 @@ -// Filename: physxBounds3.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBounds3.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXBOUNDS3_H #define PHYSXBOUNDS3_H @@ -21,14 +20,12 @@ #include "config_physx.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBounds3 -// Description : Represention of a axis aligned bounding box. -// The box is stored as minimum and maximum extent -// corners. Alternate representation would be center -// and dimensions. May be empty or nonempty. If not -// empty, min <= max has to hold. -//////////////////////////////////////////////////////////////////// +/** + * Represention of a axis aligned bounding box. The box is stored as minimum + * and maximum extent corners. Alternate representation would be center and + * dimensions. May be empty or nonempty. If not empty, min <= max has to + * hold. + */ class EXPCL_PANDAPHYSX PhysxBounds3 { PUBLISHED: diff --git a/panda/src/physx/physxBox.I b/panda/src/physx/physxBox.I index 458f366e9e..f668497b65 100644 --- a/panda/src/physx/physxBox.I +++ b/panda/src/physx/physxBox.I @@ -1,35 +1,28 @@ -// Filename: physxBox.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBox.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBox:: PhysxBox() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBox:: ~PhysxBox() { } - diff --git a/panda/src/physx/physxBox.cxx b/panda/src/physx/physxBox.cxx index 1ee31b72d6..ba552d4021 100644 --- a/panda/src/physx/physxBox.cxx +++ b/panda/src/physx/physxBox.cxx @@ -1,25 +1,22 @@ -// Filename: physxBox.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBox.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxBox.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxBox:: PhysxBox(const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) { @@ -28,23 +25,18 @@ PhysxBox(const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) PhysxManager::mat3_to_nxMat33(rot)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::is_valid -// Access: Published -// Description: Returns TRUE if the box is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the box is valid. + */ bool PhysxBox:: is_valid() const { return _box.isValid(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::rotate -// Access: Published -// Description: Recomputes the box after an arbitrary transform by -// a 4x4 matrix. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the box after an arbitrary transform by a 4x4 matrix. + */ void PhysxBox:: rotate(const LMatrix4f &m, PhysxBox &obb) const { @@ -53,55 +45,45 @@ rotate(const LMatrix4f &m, PhysxBox &obb) const { _box.rotate(PhysxManager::mat4_to_nxMat34(m), obb._box); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::set_empty -// Access: Published -// Description: Setups an empty box. -//////////////////////////////////////////////////////////////////// +/** + * Setups an empty box. + */ void PhysxBox:: set_empty() { _box.setEmpty(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::get_center -// Access: Published -// Description: Return center of the box. -//////////////////////////////////////////////////////////////////// +/** + * Return center of the box. + */ LPoint3f PhysxBox:: get_center() const { return PhysxManager::nxVec3_to_point3(_box.GetCenter()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::get_extents -// Access: Published -// Description: Returns the extents (radii) of the box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extents (radii) of the box. + */ LVector3f PhysxBox:: get_extents() const { return PhysxManager::nxVec3_to_vec3(_box.GetExtents()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::get_rot -// Access: Published -// Description: Return the rotation of the box. -//////////////////////////////////////////////////////////////////// +/** + * Return the rotation of the box. + */ LMatrix3f PhysxBox:: get_rot() const { return PhysxManager::nxMat33_to_mat3(_box.GetRot()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::set_center -// Access: Published -// Description: Sets the center of the box. -//////////////////////////////////////////////////////////////////// +/** + * Sets the center of the box. + */ void PhysxBox:: set_center(LPoint3f center) { @@ -110,11 +92,9 @@ set_center(LPoint3f center) { _box.center = PhysxManager::vec3_to_nxVec3(center); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::set_extents -// Access: Published -// Description: Sets the extents of the box. -//////////////////////////////////////////////////////////////////// +/** + * Sets the extents of the box. + */ void PhysxBox:: set_extents(LVector3f extents) { @@ -123,11 +103,9 @@ set_extents(LVector3f extents) { _box.extents = PhysxManager::vec3_to_nxVec3(extents); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBox::set_rot -// Access: Published -// Description: Sets the rotation of the box. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rotation of the box. + */ void PhysxBox:: set_rot(LMatrix3f rot) { @@ -135,4 +113,3 @@ set_rot(LMatrix3f rot) { _box.rot = PhysxManager::mat3_to_nxMat33(rot); } - diff --git a/panda/src/physx/physxBox.h b/panda/src/physx/physxBox.h index 6e899223d7..8c3b7f684f 100644 --- a/panda/src/physx/physxBox.h +++ b/panda/src/physx/physxBox.h @@ -1,16 +1,15 @@ -// Filename: physxBox.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBox.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXBOX_H #define PHYSXBOX_H @@ -21,14 +20,12 @@ #include "config_physx.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBox -// Description : Represents an oriented bounding box, as a center -// point, extents(radii) and a rotation. i.e. the -// center of the box is at the center point, the box -// is rotated around this point with the rotation and -// it is 2*extents in width, height and depth. -//////////////////////////////////////////////////////////////////// +/** + * Represents an oriented bounding box, as a center point, extents(radii) and + * a rotation. i.e. the center of the box is at the center point, the box is + * rotated around this point with the rotation and it is 2*extents in width, + * height and depth. + */ class EXPCL_PANDAPHYSX PhysxBox { PUBLISHED: diff --git a/panda/src/physx/physxBoxController.I b/panda/src/physx/physxBoxController.I index c3bde9405c..1c6d3454b8 100644 --- a/panda/src/physx/physxBoxController.I +++ b/panda/src/physx/physxBoxController.I @@ -1,36 +1,28 @@ -// Filename: physxBoxController.I -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxController.I + * @author enn0x + * @date 2009-09-24 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxController:: PhysxBoxController() : PhysxController() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxController:: ~PhysxBoxController() { } - diff --git a/panda/src/physx/physxBoxController.cxx b/panda/src/physx/physxBoxController.cxx index 731c5a1239..e687114055 100644 --- a/panda/src/physx/physxBoxController.cxx +++ b/panda/src/physx/physxBoxController.cxx @@ -1,27 +1,24 @@ -// Filename: physxBoxController.cxx -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxController.cxx + * @author enn0x + * @date 2009-09-24 + */ #include "physxBoxController.h" #include "physxManager.h" TypeHandle PhysxBoxController::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxController:: link(NxController *controllerPtr) { @@ -40,11 +37,9 @@ link(NxController *controllerPtr) { actor->link_controller(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxController:: unlink() { @@ -59,11 +54,9 @@ unlink() { scene->_controllers.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::set_extents -// Access: Published -// Description: Sets controller's extents. -//////////////////////////////////////////////////////////////////// +/** + * Sets controller's extents. + */ void PhysxBoxController:: set_extents(const LVector3f &extents) { @@ -71,15 +64,12 @@ set_extents(const LVector3f &extents) { _ptr->setExtents(PhysxManager::vec3_to_nxVec3(extents)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxController::get_extents -// Access: Published -// Description: Returns controller's extents. -//////////////////////////////////////////////////////////////////// +/** + * Returns controller's extents. + */ LVector3f PhysxBoxController:: get_extents() const { nassertr(_error_type == ET_ok, LVector3f::zero()); return PhysxManager::nxVec3_to_vec3(_ptr->getExtents()); } - diff --git a/panda/src/physx/physxBoxController.h b/panda/src/physx/physxBoxController.h index a7e749ae77..27f3524a8c 100644 --- a/panda/src/physx/physxBoxController.h +++ b/panda/src/physx/physxBoxController.h @@ -1,16 +1,15 @@ -// Filename: physxBoxController.h -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxController.h + * @author enn0x + * @date 2009-09-24 + */ #ifndef PHYSXBOXCONTROLLER_H #define PHYSXBOXCONTROLLER_H @@ -21,10 +20,9 @@ #include "physxController.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxController -// Description : Box character controller. -//////////////////////////////////////////////////////////////////// +/** + * Box character controller. + */ class EXPCL_PANDAPHYSX PhysxBoxController : public PhysxController { PUBLISHED: @@ -34,7 +32,6 @@ PUBLISHED: void set_extents(const LVector3f &extents); LVector3f get_extents() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxController *ptr() const { return (NxController *)_ptr; }; @@ -44,14 +41,13 @@ public: private: NxBoxController *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxController::init_type(); - register_type(_type_handle, "PhysxBoxController", + register_type(_type_handle, "PhysxBoxController", PhysxController::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxBoxControllerDesc.I b/panda/src/physx/physxBoxControllerDesc.I index 002d2fd34c..44ccbe3723 100644 --- a/panda/src/physx/physxBoxControllerDesc.I +++ b/panda/src/physx/physxBoxControllerDesc.I @@ -1,59 +1,47 @@ -// Filename: physxBoxControllerDesc.I -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxControllerDesc.I + * @author enn0x + * @date 2009-09-22 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxControllerDesc:: PhysxBoxControllerDesc() : PhysxControllerDesc() { _desc.upDirection = (NxHeightFieldAxis)physx_up_axis.get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxControllerDesc:: ~PhysxBoxControllerDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxBoxControllerDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxBoxControllerDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxBoxControllerDesc.cxx b/panda/src/physx/physxBoxControllerDesc.cxx index 30123a3a78..7a05f5cad2 100644 --- a/panda/src/physx/physxBoxControllerDesc.cxx +++ b/panda/src/physx/physxBoxControllerDesc.cxx @@ -1,43 +1,36 @@ -// Filename: physxBoxControllerDesc.cxx -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxControllerDesc.cxx + * @author enn0x + * @date 2009-09-22 + */ #include "physxBoxControllerDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::set_extents -// Access: Published -// Description: Sets the dimensions of the box. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dimensions of the box. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ void PhysxBoxControllerDesc:: set_extents(const LVector3f &extents) { _desc.extents = PhysxManager::vec3_to_nxVec3(extents); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxControllerDesc::get_extents -// Access: Published -// Description: Returns the dimensions of the box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dimensions of the box. + */ LVector3f PhysxBoxControllerDesc:: get_extents() const { return PhysxManager::nxVec3_to_vec3(_desc.extents); } - diff --git a/panda/src/physx/physxBoxControllerDesc.h b/panda/src/physx/physxBoxControllerDesc.h index 7ce60676a5..6ab4cf0f41 100644 --- a/panda/src/physx/physxBoxControllerDesc.h +++ b/panda/src/physx/physxBoxControllerDesc.h @@ -1,16 +1,15 @@ -// Filename: physxBoxControllerDesc.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxControllerDesc.h + * @author enn0x + * @date 2009-09-22 + */ #ifndef PHYSXBOXCONTROLLERDESC_H #define PHYSXBOXCONTROLLERDESC_H @@ -21,10 +20,9 @@ #include "physxControllerDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxControllerDesc -// Description : Descriptor class for PhysxBoxController. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxBoxController. + */ class EXPCL_PANDAPHYSX PhysxBoxControllerDesc : public PhysxControllerDesc { PUBLISHED: diff --git a/panda/src/physx/physxBoxForceFieldShape.I b/panda/src/physx/physxBoxForceFieldShape.I index 2c6bbbafa0..2d57430194 100644 --- a/panda/src/physx/physxBoxForceFieldShape.I +++ b/panda/src/physx/physxBoxForceFieldShape.I @@ -1,36 +1,28 @@ -// Filename: physxBoxForceFieldShape.I -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShape.I + * @author enn0x + * @date 2009-11-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxForceFieldShape:: PhysxBoxForceFieldShape() : PhysxForceFieldShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxForceFieldShape:: ~PhysxBoxForceFieldShape() { } - diff --git a/panda/src/physx/physxBoxForceFieldShape.cxx b/panda/src/physx/physxBoxForceFieldShape.cxx index cd897fad1d..2aff7e32a7 100644 --- a/panda/src/physx/physxBoxForceFieldShape.cxx +++ b/panda/src/physx/physxBoxForceFieldShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxBoxForceFieldShape.cxx -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShape.cxx + * @author enn0x + * @date 2009-11-15 + */ #include "physxBoxForceFieldShape.h" #include "physxBoxForceFieldShapeDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxBoxForceFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxForceFieldShape:: link(NxForceFieldShape *shapePtr) { @@ -36,11 +33,9 @@ link(NxForceFieldShape *shapePtr) { group->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxForceFieldShape:: unlink() { @@ -51,12 +46,9 @@ unlink() { group->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxBoxForceFieldShape:: save_to_desc(PhysxBoxForceFieldShapeDesc &shapeDesc) const { @@ -64,15 +56,12 @@ save_to_desc(PhysxBoxForceFieldShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::set_dimensions -// Access: Published -// Description: Sets the box dimensions. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the box dimensions. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ void PhysxBoxForceFieldShape:: set_dimensions(const LVector3f &vec) { @@ -80,19 +69,15 @@ set_dimensions(const LVector3f &vec) { _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShape::get_dimensions -// Access: Published -// Description: Retrieves the dimensions of the box. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the dimensions of the box. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ LVector3f PhysxBoxForceFieldShape:: get_dimensions() const { nassertr(_error_type == ET_ok, LVector3f::zero()); return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions()); } - diff --git a/panda/src/physx/physxBoxForceFieldShape.h b/panda/src/physx/physxBoxForceFieldShape.h index 62eda5887a..de77b03634 100644 --- a/panda/src/physx/physxBoxForceFieldShape.h +++ b/panda/src/physx/physxBoxForceFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxBoxForceFieldShape.h -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShape.h + * @author enn0x + * @date 2009-11-15 + */ #ifndef PHYSXBOXFORCEFIELDSHAPE_H #define PHYSXBOXFORCEFIELDSHAPE_H @@ -23,10 +22,9 @@ class PhysxBoxForceFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxForceFieldShape -// Description : A box shaped region used to define a force field. -//////////////////////////////////////////////////////////////////// +/** + * A box shaped region used to define a force field. + */ class EXPCL_PANDAPHYSX PhysxBoxForceFieldShape : public PhysxForceFieldShape { PUBLISHED: INLINE PhysxBoxForceFieldShape(); diff --git a/panda/src/physx/physxBoxForceFieldShapeDesc.I b/panda/src/physx/physxBoxForceFieldShapeDesc.I index 8d72625fd7..9310bdd25e 100644 --- a/panda/src/physx/physxBoxForceFieldShapeDesc.I +++ b/panda/src/physx/physxBoxForceFieldShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxBoxForceFieldShapeDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShapeDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxForceFieldShapeDesc:: PhysxBoxForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxForceFieldShapeDesc:: ~PhysxBoxForceFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxBoxForceFieldShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxBoxForceFieldShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxBoxForceFieldShapeDesc.cxx b/panda/src/physx/physxBoxForceFieldShapeDesc.cxx index 98e66affad..af9a5093f7 100644 --- a/panda/src/physx/physxBoxForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxBoxForceFieldShapeDesc.cxx @@ -1,29 +1,25 @@ -// Filename: physxBoxForceFieldShapeDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShapeDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxBoxForceFieldShapeDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::set_dimensions -// Access: Published -// Description: Sets the dimensions of the box. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dimensions of the box. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ void PhysxBoxForceFieldShapeDesc:: set_dimensions(const LVector3f &dimensions) { @@ -31,14 +27,11 @@ set_dimensions(const LVector3f &dimensions) { _desc.dimensions = PhysxManager::vec3_to_nxVec3(dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxForceFieldShapeDesc::get_dimensions -// Access: Published -// Description: Returns the dimensions of the box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dimensions of the box. + */ LVector3f PhysxBoxForceFieldShapeDesc:: get_dimensions() const { return PhysxManager::nxVec3_to_vec3(_desc.dimensions); } - diff --git a/panda/src/physx/physxBoxForceFieldShapeDesc.h b/panda/src/physx/physxBoxForceFieldShapeDesc.h index 2c65ca1d4c..c2db24cb1c 100644 --- a/panda/src/physx/physxBoxForceFieldShapeDesc.h +++ b/panda/src/physx/physxBoxForceFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxBoxForceFieldShapeDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxForceFieldShapeDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXBOXFORCEFIELDSHAPEDESC_H #define PHYSXBOXFORCEFIELDSHAPEDESC_H @@ -21,10 +20,9 @@ #include "physxForceFieldShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxForceFieldShapeDesc -// Description : Descriptor for a box force field shape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for a box force field shape. + */ class EXPCL_PANDAPHYSX PhysxBoxForceFieldShapeDesc : public PhysxForceFieldShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxBoxShape.I b/panda/src/physx/physxBoxShape.I index 730f806b10..c1ad718397 100644 --- a/panda/src/physx/physxBoxShape.I +++ b/panda/src/physx/physxBoxShape.I @@ -1,36 +1,28 @@ -// Filename: physxBoxShape.I -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShape.I + * @author enn0x + * @date 2009-09-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxShape:: PhysxBoxShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxShape:: ~PhysxBoxShape() { } - diff --git a/panda/src/physx/physxBoxShape.cxx b/panda/src/physx/physxBoxShape.cxx index e1fc59f5db..695ed1fd71 100644 --- a/panda/src/physx/physxBoxShape.cxx +++ b/panda/src/physx/physxBoxShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxBoxShape.cxx -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShape.cxx + * @author enn0x + * @date 2009-09-16 + */ #include "physxBoxShape.h" #include "physxBoxShapeDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxBoxShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxShape:: link(NxShape *shapePtr) { @@ -36,11 +33,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxBoxShape:: unlink() { @@ -51,12 +46,9 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxBoxShape:: save_to_desc(PhysxBoxShapeDesc &shapeDesc) const { @@ -64,15 +56,12 @@ save_to_desc(PhysxBoxShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::set_dimensions -// Access: Published -// Description: Sets the box dimensions. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the box dimensions. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ void PhysxBoxShape:: set_dimensions(const LVector3f &vec) { @@ -80,19 +69,15 @@ set_dimensions(const LVector3f &vec) { _ptr->setDimensions(PhysxManager::vec3_to_nxVec3(vec)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShape::get_dimensions -// Access: Published -// Description: Retrieves the dimensions of the box. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the dimensions of the box. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ LVector3f PhysxBoxShape:: get_dimensions() const { nassertr(_error_type == ET_ok, LVector3f::zero()); return PhysxManager::nxVec3_to_vec3(_ptr->getDimensions()); } - diff --git a/panda/src/physx/physxBoxShape.h b/panda/src/physx/physxBoxShape.h index 58d3c3c5da..ffea96c96b 100644 --- a/panda/src/physx/physxBoxShape.h +++ b/panda/src/physx/physxBoxShape.h @@ -1,16 +1,15 @@ -// Filename: physxBoxShape.h -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShape.h + * @author enn0x + * @date 2009-09-16 + */ #ifndef PHYSXBOXSHAPE_H #define PHYSXBOXSHAPE_H @@ -23,21 +22,17 @@ class PhysxBoxShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxShape -// Description : A box shaped collision detection primitive. Each -// shape is owned by the actor which it is attached -// to. -// -// An instance can be created by calling the -// createShape() method of the PhysxActor object that -// will own it, with a PhysxBoxShapeDesc object as the -// parameter, or by adding the shape descriptor to the -// PhysxActorDesc class before creating the actor. -// -// The shape is deleted by calling release() on the -// shape itself. -//////////////////////////////////////////////////////////////////// +/** + * A box shaped collision detection primitive. Each shape is owned by the + * actor which it is attached to. + * + * An instance can be created by calling the createShape() method of the + * PhysxActor object that will own it, with a PhysxBoxShapeDesc object as the + * parameter, or by adding the shape descriptor to the PhysxActorDesc class + * before creating the actor. + * + * The shape is deleted by calling release() on the shape itself. + */ class EXPCL_PANDAPHYSX PhysxBoxShape : public PhysxShape { PUBLISHED: @@ -49,7 +44,6 @@ PUBLISHED: void set_dimensions(const LVector3f &dimensions); LVector3f get_dimensions() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -59,14 +53,13 @@ public: private: NxBoxShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxBoxShape", + register_type(_type_handle, "PhysxBoxShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxBoxShapeDesc.I b/panda/src/physx/physxBoxShapeDesc.I index 447c7bad9a..977811b33d 100644 --- a/panda/src/physx/physxBoxShapeDesc.I +++ b/panda/src/physx/physxBoxShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxBoxShapeDesc.I -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShapeDesc.I + * @author enn0x + * @date 2009-09-08 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxShapeDesc:: PhysxBoxShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxBoxShapeDesc:: ~PhysxBoxShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxBoxShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxBoxShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxBoxShapeDesc.cxx b/panda/src/physx/physxBoxShapeDesc.cxx index 5c955b4cdb..6d67f16e45 100644 --- a/panda/src/physx/physxBoxShapeDesc.cxx +++ b/panda/src/physx/physxBoxShapeDesc.cxx @@ -1,29 +1,25 @@ -// Filename: physxBoxShapeDesc.cxx -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShapeDesc.cxx + * @author enn0x + * @date 2009-09-08 + */ #include "physxBoxShapeDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::set_dimensions -// Access: Published -// Description: Sets the dimensions of the box. -// -// The dimensions are the 'radii' of the box, -// meaning 1/2 extents in x dimension, 1/2 extents -// in y dimension, 1/2 extents in z dimension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dimensions of the box. + * + * The dimensions are the 'radii' of the box, meaning 1/2 extents in x + * dimension, 1/2 extents in y dimension, 1/2 extents in z dimension. + */ void PhysxBoxShapeDesc:: set_dimensions(const LVector3f &dimensions) { @@ -31,14 +27,11 @@ set_dimensions(const LVector3f &dimensions) { _desc.dimensions = PhysxManager::vec3_to_nxVec3(dimensions); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxBoxShapeDesc::get_dimensions -// Access: Published -// Description: Returns the dimensions of the box. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dimensions of the box. + */ LVector3f PhysxBoxShapeDesc:: get_dimensions() const { return PhysxManager::nxVec3_to_vec3(_desc.dimensions); } - diff --git a/panda/src/physx/physxBoxShapeDesc.h b/panda/src/physx/physxBoxShapeDesc.h index ee7542c215..319363b695 100644 --- a/panda/src/physx/physxBoxShapeDesc.h +++ b/panda/src/physx/physxBoxShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxBoxShapeDesc.h -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxBoxShapeDesc.h + * @author enn0x + * @date 2009-09-08 + */ #ifndef PHYSXBOXSHAPEDESC_H #define PHYSXBOXSHAPEDESC_H @@ -21,10 +20,9 @@ #include "physxShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxBoxShapeDesc -// Description : Descriptor class for PhysxBoxShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxBoxShape. + */ class EXPCL_PANDAPHYSX PhysxBoxShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxCapsule.I b/panda/src/physx/physxCapsule.I index 8d901da7d8..2bb2756a51 100644 --- a/panda/src/physx/physxCapsule.I +++ b/panda/src/physx/physxCapsule.I @@ -1,46 +1,37 @@ -// Filename: physxCapsule.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsule.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsule:: PhysxCapsule() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsule:: PhysxCapsule(const PhysxSegment &segment, float radius) { _capsule = NxCapsule(segment._segment, radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsule:: ~PhysxCapsule() { } - diff --git a/panda/src/physx/physxCapsule.cxx b/panda/src/physx/physxCapsule.cxx index 029c1b9fb5..86b7e08739 100644 --- a/panda/src/physx/physxCapsule.cxx +++ b/panda/src/physx/physxCapsule.cxx @@ -1,58 +1,49 @@ -// Filename: physxCapsule.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsule.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxCapsule.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::get_radius -// Access: Published -// Description: Returns the capsule's radius. -//////////////////////////////////////////////////////////////////// +/** + * Returns the capsule's radius. + */ float PhysxCapsule:: get_radius() const { return _capsule.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::set_radius -// Access: Published -// Description: Sets the capsule's radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the capsule's radius. + */ void PhysxCapsule:: set_radius(float radius) { _capsule.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::get_p0 -// Access: Published -// Description: Returns the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the start point of the segment. + */ LPoint3f PhysxCapsule:: get_p0() const { return PhysxManager::nxVec3_to_vec3(_capsule.p0); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::set_p0 -// Access: Published -// Description: Sets the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start point of the segment. + */ void PhysxCapsule:: set_p0(LPoint3f p) { @@ -61,22 +52,18 @@ set_p0(LPoint3f p) { _capsule.p0 = PhysxManager::vec3_to_nxVec3(p); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::get_p1 -// Access: Published -// Description: Returns the end point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the end point of the segment. + */ LPoint3f PhysxCapsule:: get_p1() const { return PhysxManager::nxVec3_to_vec3(_capsule.p1); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::set_p1 -// Access: Published -// Description: Sets the end point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Sets the end point of the segment. + */ void PhysxCapsule:: set_p1(LPoint3f p) { @@ -85,23 +72,19 @@ set_p1(LPoint3f p) { _capsule.p1 = PhysxManager::vec3_to_nxVec3(p); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::get_origin -// Access: Published -// Description: Returns the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the start point of the segment. + */ LPoint3f PhysxCapsule:: get_origin() const { return PhysxManager::nxVec3_to_point3(_capsule.getOrigin()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::compute_direction -// Access: Published -// Description: Returns the direction vector from the segment's -// start point to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction vector from the segment's start point to it's end + * point. + */ void PhysxCapsule:: compute_direction(LPoint3f &dir) const { @@ -112,23 +95,18 @@ compute_direction(LPoint3f &dir) const { PhysxManager::update_point3_from_nxVec3(dir, nDir); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::compute_length -// Access: Published -// Description: Returns the distance from the segment's start point -// to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the distance from the segment's start point to it's end point. + */ float PhysxCapsule:: compute_length() const { return _capsule.computeLength(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::compute_point -// Access: Published -// Description: Computes a point on the segment. -//////////////////////////////////////////////////////////////////// +/** + * Computes a point on the segment. + */ void PhysxCapsule:: compute_point(LPoint3f &p, float t) const { @@ -139,24 +117,19 @@ compute_point(LPoint3f &p, float t) const { PhysxManager::update_point3_from_nxVec3(p, nP); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::compute_square_length -// Access: Published -// Description: Returns the square distance from the segment's -// start point to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the square distance from the segment's start point to it's end + * point. + */ float PhysxCapsule:: compute_square_length() const { return _capsule.computeSquareLength(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsule::set_origin_direction -// Access: Published -// Description: Setup this capsule from origin (start point) and -// direction vector. -//////////////////////////////////////////////////////////////////// +/** + * Setup this capsule from origin (start point) and direction vector. + */ void PhysxCapsule:: set_origin_direction(const LPoint3f &origin, const LVector3f &direction) { @@ -166,4 +139,3 @@ set_origin_direction(const LPoint3f &origin, const LVector3f &direction) { _capsule.setOriginDirection(PhysxManager::point3_to_nxVec3(origin), PhysxManager::vec3_to_nxVec3(direction)); } - diff --git a/panda/src/physx/physxCapsule.h b/panda/src/physx/physxCapsule.h index 7d32826e27..0658676aba 100644 --- a/panda/src/physx/physxCapsule.h +++ b/panda/src/physx/physxCapsule.h @@ -1,16 +1,15 @@ -// Filename: physxCapsule.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsule.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXCAPSULE_H #define PHYSXCAPSULE_H @@ -20,10 +19,9 @@ #include "config_physx.h" #include "physxSegment.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsule -// Description : Represents a capsule. -//////////////////////////////////////////////////////////////////// +/** + * Represents a capsule. + */ class EXPCL_PANDAPHYSX PhysxCapsule { PUBLISHED: diff --git a/panda/src/physx/physxCapsuleController.I b/panda/src/physx/physxCapsuleController.I index 7c4e23e631..fa8dba4e44 100644 --- a/panda/src/physx/physxCapsuleController.I +++ b/panda/src/physx/physxCapsuleController.I @@ -1,36 +1,28 @@ -// Filename: physxCapsuleController.I -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleController.I + * @author enn0x + * @date 2009-09-24 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleController:: PhysxCapsuleController() : PhysxController() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleController:: ~PhysxCapsuleController() { } - diff --git a/panda/src/physx/physxCapsuleController.cxx b/panda/src/physx/physxCapsuleController.cxx index 6313774c21..12f38ecb26 100644 --- a/panda/src/physx/physxCapsuleController.cxx +++ b/panda/src/physx/physxCapsuleController.cxx @@ -1,26 +1,23 @@ -// Filename: physxCapsuleController.cxx -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleController.cxx + * @author enn0x + * @date 2009-09-24 + */ #include "physxCapsuleController.h" TypeHandle PhysxCapsuleController::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleController:: link(NxController *controllerPtr) { @@ -39,11 +36,9 @@ link(NxController *controllerPtr) { actor->link_controller(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleController:: unlink() { @@ -58,11 +53,9 @@ unlink() { scene->_controllers.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::set_radius -// Access: Published -// Description: Resets the controller's radius. -//////////////////////////////////////////////////////////////////// +/** + * Resets the controller's radius. + */ void PhysxCapsuleController:: set_radius(float radius) { @@ -70,11 +63,9 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::set_height -// Access: Published -// Description: Resets the controller's height. -//////////////////////////////////////////////////////////////////// +/** + * Resets the controller's height. + */ void PhysxCapsuleController:: set_height(float height) { @@ -82,11 +73,9 @@ set_height(float height) { _ptr->setHeight(height); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::get_radius -// Access: Published -// Description: Returns the controller's radius. -//////////////////////////////////////////////////////////////////// +/** + * Returns the controller's radius. + */ float PhysxCapsuleController:: get_radius() const { @@ -94,15 +83,12 @@ get_radius() const { return _ptr->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleController::get_height -// Access: Published -// Description: Returns the controller's height. -//////////////////////////////////////////////////////////////////// +/** + * Returns the controller's height. + */ float PhysxCapsuleController:: get_height() const { nassertr(_error_type == ET_ok, 0.0f); return _ptr->getHeight(); } - diff --git a/panda/src/physx/physxCapsuleController.h b/panda/src/physx/physxCapsuleController.h index 1e16c215de..0f9a2a6174 100644 --- a/panda/src/physx/physxCapsuleController.h +++ b/panda/src/physx/physxCapsuleController.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleController.h -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleController.h + * @author enn0x + * @date 2009-09-24 + */ #ifndef PHYSXCAPSULECONTROLLER_H #define PHYSXCAPSULECONTROLLER_H @@ -21,26 +20,20 @@ #include "physxController.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleController -// Description : A capsule character controller. -// -// The capsule is defined as a position, a vertical -// height, and a radius. The height is the same height -// as for PhysxCapsuleShape objects, i.e. the distance -// between the two sphere centers at the end of the -// capsule. In other words: -// -// p = pos (returned by controller) -// h = height -// r = radius -// -// p = center of capsule -// top sphere center = p.y + h*0.5 -// bottom sphere center = p.y - h*0.5 -// top capsule point = p.y + h*0.5 + r -// bottom capsule point = p.y - h*0.5 - r -//////////////////////////////////////////////////////////////////// +/** + * A capsule character controller. + * + * The capsule is defined as a position, a vertical height, and a radius. The + * height is the same height as for PhysxCapsuleShape objects, i.e. the + * distance between the two sphere centers at the end of the capsule. In + * other words: + * + * p = pos (returned by controller) h = height r = radius + * + * p = center of capsule top sphere center = p.y + h*0.5 bottom sphere center + * = p.y - h*0.5 top capsule point = p.y + h*0.5 + r bottom capsule point = + * p.y - h*0.5 - r + */ class EXPCL_PANDAPHYSX PhysxCapsuleController : public PhysxController { PUBLISHED: @@ -52,7 +45,6 @@ PUBLISHED: float get_radius() const; float get_height() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxController *ptr() const { return (NxController *)_ptr; }; @@ -62,14 +54,13 @@ public: private: NxCapsuleController *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxController::init_type(); - register_type(_type_handle, "PhysxCapsuleController", + register_type(_type_handle, "PhysxCapsuleController", PhysxController::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxCapsuleControllerDesc.I b/panda/src/physx/physxCapsuleControllerDesc.I index 3f4334d99f..dc31f876d7 100644 --- a/panda/src/physx/physxCapsuleControllerDesc.I +++ b/panda/src/physx/physxCapsuleControllerDesc.I @@ -1,59 +1,47 @@ -// Filename: physxCapsuleControllerDesc.I -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleControllerDesc.I + * @author enn0x + * @date 2009-09-22 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleControllerDesc:: PhysxCapsuleControllerDesc() : PhysxControllerDesc() { _desc.upDirection = (NxHeightFieldAxis)physx_up_axis.get_value(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleControllerDesc:: ~PhysxCapsuleControllerDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxCapsuleControllerDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxCapsuleControllerDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxCapsuleControllerDesc.cxx b/panda/src/physx/physxCapsuleControllerDesc.cxx index ceee92029d..9d4663949e 100644 --- a/panda/src/physx/physxCapsuleControllerDesc.cxx +++ b/panda/src/physx/physxCapsuleControllerDesc.cxx @@ -1,64 +1,50 @@ -// Filename: physxCapsuleControllerDesc.cxx -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleControllerDesc.cxx + * @author enn0x + * @date 2009-09-22 + */ #include "physxCapsuleControllerDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::set_radius -// Access: Published -// Description: Sets the radius of the capsule's hemispherical -// ends and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * Sets the radius of the capsule's hemispherical ends and its trunk. + */ void PhysxCapsuleControllerDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::set_height -// Access: Published -// Description: Sets the distance between the two hemispherical -// ends of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance between the two hemispherical ends of the capsule. + */ void PhysxCapsuleControllerDesc:: set_height(float height) { _desc.height = height; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::get_radius -// Access: Published -// Description: The radius of the capsule's hemispherical ends -// and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * The radius of the capsule's hemispherical ends and its trunk. + */ float PhysxCapsuleControllerDesc:: get_radius() const { return _desc.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleControllerDesc::get_height -// Access: Published -// Description: The distance between the two hemispherical ends -// of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * The distance between the two hemispherical ends of the capsule. + */ float PhysxCapsuleControllerDesc:: get_height() const { return _desc.height; } - diff --git a/panda/src/physx/physxCapsuleControllerDesc.h b/panda/src/physx/physxCapsuleControllerDesc.h index 37e4a7b7e3..eda4930bf4 100644 --- a/panda/src/physx/physxCapsuleControllerDesc.h +++ b/panda/src/physx/physxCapsuleControllerDesc.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleControllerDesc.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleControllerDesc.h + * @author enn0x + * @date 2009-09-22 + */ #ifndef PHYSXCAPSULECONTROLLERDESC_H #define PHYSXCAPSULECONTROLLERDESC_H @@ -20,10 +19,9 @@ #include "physxControllerDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleControllerDesc -// Description : Descriptor class for PhysxCapsuleController. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxCapsuleController. + */ class EXPCL_PANDAPHYSX PhysxCapsuleControllerDesc : public PhysxControllerDesc { PUBLISHED: diff --git a/panda/src/physx/physxCapsuleForceFieldShape.I b/panda/src/physx/physxCapsuleForceFieldShape.I index f4cc2b9a94..cacaabb431 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.I +++ b/panda/src/physx/physxCapsuleForceFieldShape.I @@ -1,36 +1,28 @@ -// Filename: physxCapsuleForceFieldShape.I -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShape.I + * @author enn0x + * @date 2009-11-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleForceFieldShape:: PhysxCapsuleForceFieldShape() : PhysxForceFieldShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleForceFieldShape:: ~PhysxCapsuleForceFieldShape() { } - diff --git a/panda/src/physx/physxCapsuleForceFieldShape.cxx b/panda/src/physx/physxCapsuleForceFieldShape.cxx index eb56d68043..0aacd1e61b 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.cxx +++ b/panda/src/physx/physxCapsuleForceFieldShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxCapsuleForceFieldShape.cxx -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShape.cxx + * @author enn0x + * @date 2009-11-15 + */ #include "physxCapsuleForceFieldShape.h" #include "physxCapsuleForceFieldShapeDesc.h" TypeHandle PhysxCapsuleForceFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleForceFieldShape:: link(NxForceFieldShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxForceFieldShape *shapePtr) { group->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleForceFieldShape:: unlink() { @@ -50,12 +45,9 @@ unlink() { group->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxCapsuleForceFieldShape:: save_to_desc(PhysxCapsuleForceFieldShapeDesc &shapeDesc) const { @@ -63,11 +55,9 @@ save_to_desc(PhysxCapsuleForceFieldShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::set_radius -// Access: Published -// Description: Alters the radius of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Alters the radius of the capsule. + */ void PhysxCapsuleForceFieldShape:: set_radius(float radius) { @@ -75,11 +65,9 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::set_height -// Access: Published -// Description: Alters the height of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Alters the height of the capsule. + */ void PhysxCapsuleForceFieldShape:: set_height(float height) { @@ -87,11 +75,9 @@ set_height(float height) { _ptr->setHeight(height); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::get_radius -// Access: Published -// Description: Retrieves the radius of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the radius of the capsule. + */ float PhysxCapsuleForceFieldShape:: get_radius() const { @@ -99,15 +85,12 @@ get_radius() const { return _ptr->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShape::get_height -// Access: Published -// Description: Retrieves the height of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the height of the capsule. + */ float PhysxCapsuleForceFieldShape:: get_height() const { nassertr(_error_type == ET_ok, 0.0f); return _ptr->getHeight(); } - diff --git a/panda/src/physx/physxCapsuleForceFieldShape.h b/panda/src/physx/physxCapsuleForceFieldShape.h index deb1492246..ec1417d6e7 100644 --- a/panda/src/physx/physxCapsuleForceFieldShape.h +++ b/panda/src/physx/physxCapsuleForceFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleForceFieldShape.h -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShape.h + * @author enn0x + * @date 2009-11-15 + */ #ifndef PHYSXCAPSULEFORCEFIELDSHAPE_H #define PHYSXCAPSULEFORCEFIELDSHAPE_H @@ -23,11 +22,9 @@ class PhysxCapsuleForceFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleForceFieldShape -// Description : A capsule shaped region used to define a force -// field. -//////////////////////////////////////////////////////////////////// +/** + * A capsule shaped region used to define a force field. + */ class EXPCL_PANDAPHYSX PhysxCapsuleForceFieldShape : public PhysxForceFieldShape { PUBLISHED: @@ -42,7 +39,6 @@ PUBLISHED: float get_radius() const; float get_height() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxForceFieldShape *ptr() const { return (NxForceFieldShape *)_ptr; }; @@ -52,14 +48,13 @@ public: private: NxCapsuleForceFieldShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxForceFieldShape::init_type(); - register_type(_type_handle, "PhysxCapsuleForceFieldShape", + register_type(_type_handle, "PhysxCapsuleForceFieldShape", PhysxForceFieldShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxCapsuleForceFieldShapeDesc.I b/panda/src/physx/physxCapsuleForceFieldShapeDesc.I index 794e8be649..48dec0531f 100644 --- a/panda/src/physx/physxCapsuleForceFieldShapeDesc.I +++ b/panda/src/physx/physxCapsuleForceFieldShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxCapsuleForceFieldShapeDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShapeDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleForceFieldShapeDesc:: PhysxCapsuleForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleForceFieldShapeDesc:: ~PhysxCapsuleForceFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxCapsuleForceFieldShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxCapsuleForceFieldShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx b/panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx index 82145ccdef..870602193d 100644 --- a/panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxCapsuleForceFieldShapeDesc.cxx @@ -1,64 +1,50 @@ -// Filename: physxCapsuleForceFieldShapeDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShapeDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxCapsuleForceFieldShapeDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::set_radius -// Access: Published -// Description: Sets the radius of the capsule's hemispherical -// ends and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * Sets the radius of the capsule's hemispherical ends and its trunk. + */ void PhysxCapsuleForceFieldShapeDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::set_height -// Access: Published -// Description: Sets the distance between the two hemispherical -// ends of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance between the two hemispherical ends of the capsule. + */ void PhysxCapsuleForceFieldShapeDesc:: set_height(float height) { _desc.height = height; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::get_radius -// Access: Published -// Description: The radius of the capsule's hemispherical ends -// and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * The radius of the capsule's hemispherical ends and its trunk. + */ float PhysxCapsuleForceFieldShapeDesc:: get_radius() const { return _desc.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleForceFieldShapeDesc::get_height -// Access: Published -// Description: The distance between the two hemispherical ends -// of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * The distance between the two hemispherical ends of the capsule. + */ float PhysxCapsuleForceFieldShapeDesc:: get_height() const { return _desc.height; } - diff --git a/panda/src/physx/physxCapsuleForceFieldShapeDesc.h b/panda/src/physx/physxCapsuleForceFieldShapeDesc.h index 4eff6a0cf3..55756d6e1a 100644 --- a/panda/src/physx/physxCapsuleForceFieldShapeDesc.h +++ b/panda/src/physx/physxCapsuleForceFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleForceFieldShapeDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleForceFieldShapeDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXCAPSULEFORCEFIELDSHAPEDESC_H #define PHYSXCAPSULEFORCEFIELDSHAPEDESC_H @@ -20,10 +19,9 @@ #include "physxForceFieldShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleForceFieldShapeDesc -// Description : Descriptor for a capsule force field shape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for a capsule force field shape. + */ class EXPCL_PANDAPHYSX PhysxCapsuleForceFieldShapeDesc : public PhysxForceFieldShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxCapsuleShape.I b/panda/src/physx/physxCapsuleShape.I index b24267e48a..9f686d592a 100644 --- a/panda/src/physx/physxCapsuleShape.I +++ b/panda/src/physx/physxCapsuleShape.I @@ -1,36 +1,28 @@ -// Filename: physxCapsuleShape.I -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShape.I + * @author enn0x + * @date 2009-09-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleShape:: PhysxCapsuleShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleShape:: ~PhysxCapsuleShape() { } - diff --git a/panda/src/physx/physxCapsuleShape.cxx b/panda/src/physx/physxCapsuleShape.cxx index 83ae2b0a19..ed4dc24d75 100644 --- a/panda/src/physx/physxCapsuleShape.cxx +++ b/panda/src/physx/physxCapsuleShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxCapsuleShape.cxx -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShape.cxx + * @author enn0x + * @date 2009-09-16 + */ #include "physxCapsuleShape.h" #include "physxCapsuleShapeDesc.h" TypeHandle PhysxCapsuleShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleShape:: link(NxShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCapsuleShape:: unlink() { @@ -50,12 +45,9 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxCapsuleShape:: save_to_desc(PhysxCapsuleShapeDesc &shapeDesc) const { @@ -63,11 +55,9 @@ save_to_desc(PhysxCapsuleShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::set_radius -// Access: Published -// Description: Alters the radius of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Alters the radius of the capsule. + */ void PhysxCapsuleShape:: set_radius(float radius) { @@ -75,11 +65,9 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::set_height -// Access: Published -// Description: Alters the height of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Alters the height of the capsule. + */ void PhysxCapsuleShape:: set_height(float height) { @@ -87,11 +75,9 @@ set_height(float height) { _ptr->setHeight(height); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::get_radius -// Access: Published -// Description: Retrieves the radius of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the radius of the capsule. + */ float PhysxCapsuleShape:: get_radius() const { @@ -99,15 +85,12 @@ get_radius() const { return _ptr->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShape::get_height -// Access: Published -// Description: Retrieves the height of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the height of the capsule. + */ float PhysxCapsuleShape:: get_height() const { nassertr(_error_type == ET_ok, 0.0f); return _ptr->getHeight(); } - diff --git a/panda/src/physx/physxCapsuleShape.h b/panda/src/physx/physxCapsuleShape.h index 05b4f4acc7..5f01645e65 100644 --- a/panda/src/physx/physxCapsuleShape.h +++ b/panda/src/physx/physxCapsuleShape.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleShape.h -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShape.h + * @author enn0x + * @date 2009-09-16 + */ #ifndef PHYSXCAPSULESHAPE_H #define PHYSXCAPSULESHAPE_H @@ -23,26 +22,20 @@ class PhysxCapsuleShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleShape -// Description : A capsule shaped collision detection primitive, -// also known as a line swept sphere. 'radius' is the -// radius of the capsule's hemispherical ends and its -// trunk. 'height' is the distance between the two -// hemispherical ends of the capsule. The height is -// along the capsule's Y axis. Each shape is owned by -// an actor that it is attached to. -// -// An instance can be created by calling the -// createShape() method of the PhysxActor object that -// should own it, with a PhysxCapsuleShapeDesc object -// as the parameter, or by adding the shape descriptor -// into the PhysxActorDesc class before creating the -// actor. -// -// The shape is deleted by calling release() on the -// shape itself. -//////////////////////////////////////////////////////////////////// +/** + * A capsule shaped collision detection primitive, also known as a line swept + * sphere. 'radius' is the radius of the capsule's hemispherical ends and its + * trunk. 'height' is the distance between the two hemispherical ends of the + * capsule. The height is along the capsule's Y axis. Each shape is owned by + * an actor that it is attached to. + * + * An instance can be created by calling the createShape() method of the + * PhysxActor object that should own it, with a PhysxCapsuleShapeDesc object + * as the parameter, or by adding the shape descriptor into the PhysxActorDesc + * class before creating the actor. + * + * The shape is deleted by calling release() on the shape itself. + */ class EXPCL_PANDAPHYSX PhysxCapsuleShape : public PhysxShape { PUBLISHED: @@ -57,7 +50,6 @@ PUBLISHED: float get_radius() const; float get_height() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -67,14 +59,13 @@ public: private: NxCapsuleShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxCapsuleShape", + register_type(_type_handle, "PhysxCapsuleShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxCapsuleShapeDesc.I b/panda/src/physx/physxCapsuleShapeDesc.I index 410872235d..9b2c4f3f43 100644 --- a/panda/src/physx/physxCapsuleShapeDesc.I +++ b/panda/src/physx/physxCapsuleShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxCapsuleShapeDesc.I -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShapeDesc.I + * @author enn0x + * @date 2009-09-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleShapeDesc:: PhysxCapsuleShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCapsuleShapeDesc:: ~PhysxCapsuleShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxCapsuleShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxCapsuleShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxCapsuleShapeDesc.cxx b/panda/src/physx/physxCapsuleShapeDesc.cxx index dd46aed2f8..a44988a689 100644 --- a/panda/src/physx/physxCapsuleShapeDesc.cxx +++ b/panda/src/physx/physxCapsuleShapeDesc.cxx @@ -1,64 +1,50 @@ -// Filename: physxCapsuleShapeDesc.cxx -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShapeDesc.cxx + * @author enn0x + * @date 2009-09-11 + */ #include "physxCapsuleShapeDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::set_radius -// Access: Published -// Description: Sets the radius of the capsule's hemispherical -// ends and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * Sets the radius of the capsule's hemispherical ends and its trunk. + */ void PhysxCapsuleShapeDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::set_height -// Access: Published -// Description: Sets the distance between the two hemispherical -// ends of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance between the two hemispherical ends of the capsule. + */ void PhysxCapsuleShapeDesc:: set_height(float height) { _desc.height = height; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::get_radius -// Access: Published -// Description: The radius of the capsule's hemispherical ends -// and its trunk. -//////////////////////////////////////////////////////////////////// +/** + * The radius of the capsule's hemispherical ends and its trunk. + */ float PhysxCapsuleShapeDesc:: get_radius() const { return _desc.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCapsuleShapeDesc::get_height -// Access: Published -// Description: The distance between the two hemispherical ends -// of the capsule. -//////////////////////////////////////////////////////////////////// +/** + * The distance between the two hemispherical ends of the capsule. + */ float PhysxCapsuleShapeDesc:: get_height() const { return _desc.height; } - diff --git a/panda/src/physx/physxCapsuleShapeDesc.h b/panda/src/physx/physxCapsuleShapeDesc.h index 4eee4955a2..df6899b7e0 100644 --- a/panda/src/physx/physxCapsuleShapeDesc.h +++ b/panda/src/physx/physxCapsuleShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxCapsuleShapeDesc.h -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCapsuleShapeDesc.h + * @author enn0x + * @date 2009-09-11 + */ #ifndef PHYSXCAPSULESHAPEDESC_H #define PHYSXCAPSULESHAPEDESC_H @@ -20,10 +19,9 @@ #include "physxShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCapsuleShapeDesc -// Description : Descriptor class for PhysxCapsuleShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxCapsuleShape. + */ class EXPCL_PANDAPHYSX PhysxCapsuleShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxCcdSkeleton.I b/panda/src/physx/physxCcdSkeleton.I index 4a082e9d78..14b4530d41 100644 --- a/panda/src/physx/physxCcdSkeleton.I +++ b/panda/src/physx/physxCcdSkeleton.I @@ -1,59 +1,47 @@ -// Filename: physxCcdSkeleton.I -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeleton.I + * @author enn0x + * @date 2012-05-01 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCcdSkeleton:: PhysxCcdSkeleton() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCcdSkeleton:: ~PhysxCcdSkeleton() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxCcdSkeleton:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxCcdSkeleton:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxCcdSkeleton.cxx b/panda/src/physx/physxCcdSkeleton.cxx index abd86842bf..22dc3f4173 100644 --- a/panda/src/physx/physxCcdSkeleton.cxx +++ b/panda/src/physx/physxCcdSkeleton.cxx @@ -1,27 +1,24 @@ -// Filename: physxCcdSkeleton.cxx -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeleton.cxx + * @author enn0x + * @date 2012-05-01 + */ #include "physxCcdSkeleton.h" #include "physxMeshPool.h" TypeHandle PhysxCcdSkeleton::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCcdSkeleton:: link(NxCCDSkeleton *skeletonPtr) { @@ -31,11 +28,9 @@ link(NxCCDSkeleton *skeletonPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCcdSkeleton:: unlink() { @@ -44,11 +39,9 @@ unlink() { PhysxManager::get_global_ptr()->_ccd_skeletons.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCcdSkeleton:: release() { @@ -58,14 +51,12 @@ release() { NxGetPhysicsSDK()->releaseCCDSkeleton(*_ptr); _ptr = NULL; - //TODO PhysxMeshPool::release_ccd_skeleton(this); + // TODO PhysxMeshPool::release_ccd_skeleton(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeleton::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxCcdSkeleton:: get_reference_count() const { @@ -73,4 +64,3 @@ get_reference_count() const { return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxCcdSkeleton.h b/panda/src/physx/physxCcdSkeleton.h index e5e4e423a4..bacc319027 100644 --- a/panda/src/physx/physxCcdSkeleton.h +++ b/panda/src/physx/physxCcdSkeleton.h @@ -1,16 +1,15 @@ -// Filename: physxCcdSkeleton.h -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeleton.h + * @author enn0x + * @date 2012-05-01 + */ #ifndef PHYSXCCDSKELETON_H #define PHYSXCCDSKELETON_H @@ -20,18 +19,15 @@ #include "physxObject.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCcdSkeleton -// Description : A Convex Mesh. Internally represented as a list of -// convex polygons. The number of polygons is -// limited to 256. -//////////////////////////////////////////////////////////////////// +/** + * A Convex Mesh. Internally represented as a list of convex polygons. The + * number of polygons is limited to 256. + */ class EXPCL_PANDAPHYSX PhysxCcdSkeleton : public PhysxObject { PUBLISHED: unsigned int get_reference_count() const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -50,14 +46,13 @@ public: private: NxCCDSkeleton *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxCcdSkeleton", + register_type(_type_handle, "PhysxCcdSkeleton", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxCcdSkeletonDesc.I b/panda/src/physx/physxCcdSkeletonDesc.I index 62f457195e..227a6f9684 100644 --- a/panda/src/physx/physxCcdSkeletonDesc.I +++ b/panda/src/physx/physxCcdSkeletonDesc.I @@ -1,23 +1,19 @@ -// Filename: physxCcdSkeletonDesc.I -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeletonDesc.I + * @author enn0x + * @date 2012-05-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCcdSkeletonDesc:: PhysxCcdSkeletonDesc() { @@ -31,11 +27,9 @@ PhysxCcdSkeletonDesc() { _triangles = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCcdSkeletonDesc:: ~PhysxCcdSkeletonDesc() { @@ -48,14 +42,11 @@ INLINE PhysxCcdSkeletonDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxCcdSkeletonDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxCcdSkeletonDesc.cxx b/panda/src/physx/physxCcdSkeletonDesc.cxx index a74eb0388d..fb62f41466 100644 --- a/panda/src/physx/physxCcdSkeletonDesc.cxx +++ b/panda/src/physx/physxCcdSkeletonDesc.cxx @@ -1,16 +1,15 @@ -// Filename: physxCcdSkeletonDesc.cxx -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeletonDesc.cxx + * @author enn0x + * @date 2012-05-01 + */ #include "physxCcdSkeletonDesc.h" #include "physxManager.h" @@ -19,16 +18,13 @@ #include "geomNode.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::set_num_vertices -// Access: Published -// Description: Sets the number of vertices to be stored within -// this triangle mesh. The function allocates memory -// for the vertices, but it does not set any vertices. -// -// This method must be called before any calls to -// set_vertex are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of vertices to be stored within this triangle mesh. The + * function allocates memory for the vertices, but it does not set any + * vertices. + * + * This method must be called before any calls to set_vertex are done! + */ void PhysxCcdSkeletonDesc:: set_num_vertices(unsigned int numVertices) { @@ -42,12 +38,10 @@ set_num_vertices(unsigned int numVertices) { _desc.points = _vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::set_vertex -// Access: Published -// Description: Sets a single vertex. You have to call the function -// set_num_vertices before you can call this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single vertex. You have to call the function set_num_vertices + * before you can call this function. + */ void PhysxCcdSkeletonDesc:: set_vertex(unsigned int idx, const LPoint3f &vert) { @@ -55,15 +49,11 @@ set_vertex(unsigned int idx, const LPoint3f &vert) { _vertices[idx] = PhysxManager::point3_to_nxVec3(vert); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::set_num_triangles -// Access: Published -// Description: Sets the number of triangles to be stored in this -// triangle mesh. -// -// This method must be called before any calls to -// set_triangle are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of triangles to be stored in this triangle mesh. + * + * This method must be called before any calls to set_triangle are done! + */ void PhysxCcdSkeletonDesc:: set_num_triangles(unsigned int numTriangles) { @@ -77,12 +67,9 @@ set_num_triangles(unsigned int numTriangles) { _desc.triangles = _triangles; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::set_triangles -// Access: Published -// Description: Sets a single triangle, by providing the three -// indices i1, i2, i3. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single triangle, by providing the three indices i1, i2, i3. + */ void PhysxCcdSkeletonDesc:: set_triangle(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3) { @@ -95,32 +82,23 @@ set_triangle(unsigned int idx, _triangles[idx + 2] = i3; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::get_desc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const NxSimpleTriangleMesh &PhysxCcdSkeletonDesc:: get_desc() const { return _desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCcdSkeletonDesc::set_from_node_path -// Access: Published -// Description: A convenience method to set the mesh data from -// a NodePath in a single call. The method iterates -// over the NodePath geoms and collects data for -// the triangle mesh. -// -// Do not use the following function when using this -// one: -// - set_num_vertices -// - set_vertex -// - set_num_triangles -// - set_triangle -//////////////////////////////////////////////////////////////////// +/** + * A convenience method to set the mesh data from a NodePath in a single call. + * The method iterates over the NodePath geoms and collects data for the + * triangle mesh. + * + * Do not use the following function when using this one: - set_num_vertices - + * set_vertex - set_num_triangles - set_triangle + */ void PhysxCcdSkeletonDesc:: set_from_node_path(const NodePath &np) { @@ -197,4 +175,3 @@ set_from_node_path(const NodePath &np) { _desc.numTriangles = numTriangles; _desc.triangles = _triangles; } - diff --git a/panda/src/physx/physxCcdSkeletonDesc.h b/panda/src/physx/physxCcdSkeletonDesc.h index 5f9a1b3390..aa7fd0f893 100644 --- a/panda/src/physx/physxCcdSkeletonDesc.h +++ b/panda/src/physx/physxCcdSkeletonDesc.h @@ -1,16 +1,15 @@ -// Filename: physxCcdSkeletonDesc.h -// Created by: enn0x (01May12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCcdSkeletonDesc.h + * @author enn0x + * @date 2012-05-01 + */ #ifndef PHYSXCCDSKELETONDESC_H #define PHYSXCCDSKELETONDESC_H @@ -21,10 +20,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCcdSkeletonDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxCcdSkeletonDesc { PUBLISHED: diff --git a/panda/src/physx/physxCloth.I b/panda/src/physx/physxCloth.I index 4213f624b3..e1027201cd 100644 --- a/panda/src/physx/physxCloth.I +++ b/panda/src/physx/physxCloth.I @@ -1,55 +1,44 @@ -// Filename: physxCloth.I -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCloth.I + * @author enn0x + * @date 2010-03-30 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCloth:: PhysxCloth() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCloth:: ~PhysxCloth() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxCloth:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxCloth:: ls(ostream &out, int indent_level) const { @@ -63,4 +52,3 @@ ls(ostream &out, int indent_level) const { out << "\n"; } - diff --git a/panda/src/physx/physxCloth.cxx b/panda/src/physx/physxCloth.cxx index 0b95626a28..9f2583f7df 100644 --- a/panda/src/physx/physxCloth.cxx +++ b/panda/src/physx/physxCloth.cxx @@ -1,16 +1,15 @@ -// Filename: physxCloth.cxx -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCloth.cxx + * @author enn0x + * @date 2010-03-30 + */ #include "physxCloth.h" #include "physxClothDesc.h" @@ -23,11 +22,9 @@ TypeHandle PhysxCloth::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCloth:: link(NxCloth *clothPtr) { @@ -42,11 +39,9 @@ link(NxCloth *clothPtr) { scene->_cloths.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCloth:: unlink() { @@ -60,11 +55,9 @@ unlink() { _node = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCloth:: release() { @@ -75,11 +68,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::update -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCloth:: update() { @@ -98,11 +89,9 @@ update() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_scene -// Access: Published -// Description: Returns the scene which this cloth belongs to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene which this cloth belongs to. + */ PhysxScene *PhysxCloth:: get_scene() const { @@ -110,11 +99,9 @@ get_scene() const { return (PhysxScene *)_ptr->getScene().userData; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_cloth_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxClothNode *PhysxCloth:: get_cloth_node() const { @@ -122,11 +109,9 @@ get_cloth_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::create_cloth_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxClothNode *PhysxCloth:: create_cloth_node(const char *name) { @@ -138,14 +123,10 @@ create_cloth_node(const char *name) { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_name -// Access: Published -// Description: Sets a name string for the object that can be -// retrieved with get_name(). -// This is for debugging and is not used by the -// engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for the object that can be retrieved with get_name(). + * This is for debugging and is not used by the engine. + */ void PhysxCloth:: set_name(const char *name) { @@ -155,11 +136,9 @@ set_name(const char *name) { _ptr->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_name -// Access: Published -// Description: Retrieves the name string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the name string. + */ const char *PhysxCloth:: get_name() const { @@ -167,12 +146,10 @@ get_name() const { return _ptr->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_group -// Access: Published -// Description: Sets which collision group this cloth is part of. -// Collision group must be between 0 and 31. -//////////////////////////////////////////////////////////////////// +/** + * Sets which collision group this cloth is part of. Collision group must be + * between 0 and 31. + */ void PhysxCloth:: set_group(unsigned int group) { @@ -181,12 +158,9 @@ set_group(unsigned int group) { _ptr->setGroup(group); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_group -// Access: Published -// Description: Retrieves the collision group this cloth is part -// of. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the collision group this cloth is part of. + */ unsigned int PhysxCloth:: get_group() const { @@ -194,11 +168,9 @@ get_group() const { return _ptr->getGroup(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_thickness -// Access: Published -// Description: Sets the cloth thickness (must be positive). -//////////////////////////////////////////////////////////////////// +/** + * Sets the cloth thickness (must be positive). + */ void PhysxCloth:: set_thickness(float thickness) { @@ -206,11 +178,9 @@ set_thickness(float thickness) { _ptr->setThickness(thickness); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_thickness -// Access: Published -// Description: Gets the cloth thickness. -//////////////////////////////////////////////////////////////////// +/** + * Gets the cloth thickness. + */ float PhysxCloth:: get_thickness() const { @@ -218,11 +188,9 @@ get_thickness() const { return _ptr->getThickness(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_density -// Access: Published -// Description: Gets the cloth density. -//////////////////////////////////////////////////////////////////// +/** + * Gets the cloth density. + */ float PhysxCloth:: get_density() const { @@ -230,16 +198,12 @@ get_density() const { return _ptr->getDensity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_relative_grid_spacing -// Access: Published -// Description: Gets the relative grid spacing for the broad -// phase. The cloth is represented by a set of -// world aligned cubical cells in broad phase. The -// size of these cells is determined by multiplying -// the length of the diagonal of the AABB of the -// initial soft body size with this constant. -//////////////////////////////////////////////////////////////////// +/** + * Gets the relative grid spacing for the broad phase. The cloth is + * represented by a set of world aligned cubical cells in broad phase. The + * size of these cells is determined by multiplying the length of the diagonal + * of the AABB of the initial soft body size with this constant. + */ float PhysxCloth:: get_relative_grid_spacing() const { @@ -247,11 +211,9 @@ get_relative_grid_spacing() const { return _ptr->getRelativeGridSpacing(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_num_particles -// Access: Published -// Description: Gets the number of cloth particles. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of cloth particles. + */ unsigned int PhysxCloth:: get_num_particles() { @@ -259,11 +221,9 @@ get_num_particles() { return _ptr->getNumberOfParticles(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_flag -// Access: Published -// Description: Sets the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of a single flag. + */ void PhysxCloth:: set_flag(PhysxClothFlag flag, bool value) { @@ -273,7 +233,7 @@ set_flag(PhysxClothFlag flag, bool value) { if (value == true) { flags |= flag; - } + } else { flags &= ~(flag); } @@ -281,11 +241,9 @@ set_flag(PhysxClothFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_flag -// Access: Published -// Description: Retrieves the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value of a single flag. + */ bool PhysxCloth:: get_flag(PhysxClothFlag flag) const { @@ -294,11 +252,9 @@ get_flag(PhysxClothFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_groups_mask -// Access: Published -// Description: Sets 128-bit mask used for collision filtering. -//////////////////////////////////////////////////////////////////// +/** + * Sets 128-bit mask used for collision filtering. + */ void PhysxCloth:: set_groups_mask(const PhysxGroupsMask &mask) { @@ -308,12 +264,9 @@ set_groups_mask(const PhysxGroupsMask &mask) { _ptr->setGroupsMask(_mask); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_groups_mask -// Access: Published -// Description: Gets the 128-bit groups mask used for collision -// filtering. -//////////////////////////////////////////////////////////////////// +/** + * Gets the 128-bit groups mask used for collision filtering. + */ PhysxGroupsMask PhysxCloth:: get_groups_mask() const { @@ -327,19 +280,15 @@ get_groups_mask() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::is_sleeping -// Access: Published -// Description: Returns true if this cloth is sleeping. -// -// When a cloth does not move for a period of time, -// it is no longer simulated in order to save time. -// This state is called sleeping. However, because the -// object automatically wakes up when it is either -// touched by an awake object, or one of its -// properties is changed by the user, the entire sleep -// mechanism should be transparent to the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this cloth is sleeping. + * + * When a cloth does not move for a period of time, it is no longer simulated + * in order to save time. This state is called sleeping. However, because + * the object automatically wakes up when it is either touched by an awake + * object, or one of its properties is changed by the user, the entire sleep + * mechanism should be transparent to the user. + */ bool PhysxCloth:: is_sleeping() const { @@ -347,16 +296,13 @@ is_sleeping() const { return _ptr->isSleeping(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::wake_up -// Access: Published -// Description: Wakes up the cloth if it is sleeping. -// -// The wakeCounterValue determines how long until the -// body is put to sleep, a value of zero means that -// the body is sleeping. wake_up(0) is equivalent to -// PhysxCloth::put_to_sleep(). -//////////////////////////////////////////////////////////////////// +/** + * Wakes up the cloth if it is sleeping. + * + * The wakeCounterValue determines how long until the body is put to sleep, a + * value of zero means that the body is sleeping. wake_up(0) is equivalent to + * PhysxCloth::put_to_sleep(). + */ void PhysxCloth:: wake_up(float wakeCounterValue) { @@ -364,17 +310,13 @@ wake_up(float wakeCounterValue) { _ptr->wakeUp(wakeCounterValue); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::put_to_sleep -// Access: Published -// Description: Forces the cloth to sleep. -// -// The cloth will stay asleep until the next -// call to simulate, and will not wake up until then -// even when otherwise it would (for example a force -// is applied to it). It can however wake up during -// the next do_physics call. -//////////////////////////////////////////////////////////////////// +/** + * Forces the cloth to sleep. + * + * The cloth will stay asleep until the next call to simulate, and will not + * wake up until then even when otherwise it would (for example a force is + * applied to it). It can however wake up during the next do_physics call. + */ void PhysxCloth:: put_to_sleep() { @@ -382,17 +324,13 @@ put_to_sleep() { _ptr->putToSleep(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_sleep_linear_velocity -// Access: Published -// Description: Sets the linear velocity below which an cloth -// may go to sleep. Cloths whose linear velocity is -// above this threshold will not be put to sleep. -// -// Setting the sleep angular/linear velocity only -// makes sense when the BF_energy_sleep_test is not -// set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear velocity below which an cloth may go to sleep. Cloths + * whose linear velocity is above this threshold will not be put to sleep. + * + * Setting the sleep angular/linear velocity only makes sense when the + * BF_energy_sleep_test is not set. + */ void PhysxCloth:: set_sleep_linear_velocity(float threshold) { @@ -400,13 +338,11 @@ set_sleep_linear_velocity(float threshold) { _ptr->setSleepLinearVelocity(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_sleep_linear_velocity -// Access: Published -// Description: Returns the linear velocity below which an soft -// body may go to sleep. cloths whose linear velocity -// is above this threshold will not be put to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear velocity below which an soft body may go to sleep. + * cloths whose linear velocity is above this threshold will not be put to + * sleep. + */ float PhysxCloth:: get_sleep_linear_velocity() const { @@ -414,12 +350,9 @@ get_sleep_linear_velocity() const { return _ptr->getSleepLinearVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::attach_vertex_to_global_pos -// Access: Published -// Description: Attaches a cloth vertex to a position in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a cloth vertex to a position in world space. + */ void PhysxCloth:: attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) { @@ -429,16 +362,13 @@ attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) { _ptr->attachVertexToGlobalPosition(vertexId, PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::attach_to_shape -// Access: Published -// Description: Attaches the cloth to a shape. All cloth points -// currently inside the shape are attached. -// -// This method only works with primitive and convex -// shapes. Since the inside of a general triangle mesh -// is not clearly defined. -//////////////////////////////////////////////////////////////////// +/** + * Attaches the cloth to a shape. All cloth points currently inside the shape + * are attached. + * + * This method only works with primitive and convex shapes. Since the inside + * of a general triangle mesh is not clearly defined. + */ void PhysxCloth:: attach_to_shape(PhysxShape *shape) { @@ -449,16 +379,12 @@ attach_to_shape(PhysxShape *shape) { _ptr->attachToShape(shape->ptr(), attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::attach_to_colliding_shapes -// Access: Published -// Description: Attaches the cloth to all shapes, currently -// colliding. -// -// This method only works with primitive and convex -// shapes. Since the inside of a general triangle mesh -// is not clearly defined. -//////////////////////////////////////////////////////////////////// +/** + * Attaches the cloth to all shapes, currently colliding. + * + * This method only works with primitive and convex shapes. Since the inside + * of a general triangle mesh is not clearly defined. + */ void PhysxCloth:: attach_to_colliding_shapes() { @@ -468,15 +394,12 @@ attach_to_colliding_shapes() { _ptr->attachToCollidingShapes(attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::detach_from_shape -// Access: Published -// Description: Detaches the cloth from a shape it has been -// attached to before. -// -// If the cloth has not been attached to the shape -// before, the call has no effect. -//////////////////////////////////////////////////////////////////// +/** + * Detaches the cloth from a shape it has been attached to before. + * + * If the cloth has not been attached to the shape before, the call has no + * effect. + */ void PhysxCloth:: detach_from_shape(PhysxShape *shape) { @@ -486,11 +409,9 @@ detach_from_shape(PhysxShape *shape) { _ptr->detachFromShape(shape->ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::free_vertex -// Access: Published -// Description: Frees a previously attached cloth point. -//////////////////////////////////////////////////////////////////// +/** + * Frees a previously attached cloth point. + */ void PhysxCloth:: free_vertex(unsigned int vertexId) { @@ -498,12 +419,9 @@ free_vertex(unsigned int vertexId) { _ptr->freeVertex(vertexId); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::attach_vertex_to_shape -// Access: Published -// Description: Attaches a cloth vertex to a local position within -// a shape. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a cloth vertex to a local position within a shape. + */ void PhysxCloth:: attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos) { @@ -517,11 +435,9 @@ attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_vertex_attachment_status -// Access: Published -// Description: Return the attachment status of the given vertex. -//////////////////////////////////////////////////////////////////// +/** + * Return the attachment status of the given vertex. + */ PhysxEnums::PhysxVertexAttachmentStatus PhysxCloth:: get_vertex_attachment_status(unsigned int vertexId) const { @@ -531,13 +447,11 @@ get_vertex_attachment_status(unsigned int vertexId) const { return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_vertex_attachment_shape -// Access: Published -// Description: Returns the pointer to an attached shape pointer -// of the given vertex. If the vertex is not attached -// or attached to a global position, NULL is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to an attached shape pointer of the given vertex. If + * the vertex is not attached or attached to a global position, NULL is + * returned. + */ PhysxShape *PhysxCloth:: get_vertex_attachment_shape(unsigned int vertexId) const { @@ -550,30 +464,25 @@ get_vertex_attachment_shape(unsigned int vertexId) const { return shape; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_vertex_attachment_pos -// Access: Published -// Description: Returns the attachment position of the given -// vertex. If the vertex is attached to shape, the -// position local to the shape's pose is returned. If -// the vertex is not attached, the return value is -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the attachment position of the given vertex. If the vertex is + * attached to shape, the position local to the shape's pose is returned. If + * the vertex is not attached, the return value is undefined. + */ LPoint3f PhysxCloth:: get_vertex_attachment_pos(unsigned int vertexId) const { nassertr(_error_type == ET_ok, LPoint3f::zero()); - // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), LPoint3f::zero()); + // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), + // LPoint3f::zero()); return PhysxManager::nxVec3_to_point3(_ptr->getVertexAttachmentPosition(vertexId)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_external_acceleration -// Access: Published -// Description: Sets an external acceleration which affects all non -// attached particles of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Sets an external acceleration which affects all non attached particles of + * the cloth. + */ void PhysxCloth:: set_external_acceleration(LVector3f const &acceleration) { @@ -583,12 +492,9 @@ set_external_acceleration(LVector3f const &acceleration) { _ptr->setExternalAcceleration(PhysxManager::vec3_to_nxVec3(acceleration)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::set_wind_acceleration -// Access: Published -// Description: Sets an acceleration acting normal to the cloth -// surface at each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets an acceleration acting normal to the cloth surface at each vertex. + */ void PhysxCloth:: set_wind_acceleration(LVector3f const &acceleration) { @@ -598,12 +504,10 @@ set_wind_acceleration(LVector3f const &acceleration) { _ptr->setWindAcceleration(PhysxManager::vec3_to_nxVec3(acceleration)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_external_acceleration -// Access: Published -// Description: Retrieves the external acceleration which affects -// all non attached particles of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the external acceleration which affects all non attached + * particles of the cloth. + */ LVector3f PhysxCloth:: get_external_acceleration() const { @@ -611,12 +515,10 @@ get_external_acceleration() const { return PhysxManager::nxVec3_to_vec3(_ptr->getExternalAcceleration()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::get_wind_acceleration -// Access: Published -// Description: Retrieves the acceleration acting normal to the -// cloth surface at each vertex -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the acceleration acting normal to the cloth surface at each + * vertex + */ LVector3f PhysxCloth:: get_wind_acceleration() const { @@ -624,13 +526,10 @@ get_wind_acceleration() const { return PhysxManager::nxVec3_to_vec3(_ptr->getWindAcceleration()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::add_force_at_vertex -// Access: Published -// Description: Applies a force (or impulse) defined in the -// global coordinate frame, to a particular vertex -// of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the global coordinate frame, to a + * particular vertex of the cloth. + */ void PhysxCloth:: add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) { @@ -640,13 +539,10 @@ add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) { (NxForceMode) mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::add_force_at_pos -// Access: Published -// Description: Applies a radial force (or impulse) at a -// particular position. All vertices within radius -// will be affected with a quadratic drop-off. -//////////////////////////////////////////////////////////////////// +/** + * Applies a radial force (or impulse) at a particular position. All vertices + * within radius will be affected with a quadratic drop-off. + */ void PhysxCloth:: add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode) { @@ -657,13 +553,10 @@ add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceM (NxForceMode) mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCloth::add_directed_force_at_pos -// Access: Published -// Description: Applies a directed force (or impulse) at a -// particular position. All vertices within radius -// will be affected with a quadratic drop-off. -//////////////////////////////////////////////////////////////////// +/** + * Applies a directed force (or impulse) at a particular position. All + * vertices within radius will be affected with a quadratic drop-off. + */ void PhysxCloth:: add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode) { @@ -673,4 +566,3 @@ add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float rad radius, (NxForceMode) mode); } - diff --git a/panda/src/physx/physxCloth.h b/panda/src/physx/physxCloth.h index 24060529fe..aecada8f5e 100644 --- a/panda/src/physx/physxCloth.h +++ b/panda/src/physx/physxCloth.h @@ -1,16 +1,15 @@ -// Filename: physxCloth.h -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCloth.h + * @author enn0x + * @date 2010-03-30 + */ #ifndef PHYSXCLOTH_H #define PHYSXCLOTH_H @@ -27,10 +26,9 @@ class PhysxScene; class PhysxGroupsMask; class PhysxClothNode; -//////////////////////////////////////////////////////////////////// -// Class : PhysxCloth -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxCloth : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -94,7 +92,6 @@ PUBLISHED: public: void update(); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -109,14 +106,13 @@ private: PT(PhysxClothNode) _node; string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxCloth", + register_type(_type_handle, "PhysxCloth", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxClothDesc.I b/panda/src/physx/physxClothDesc.I index 0472224947..ab8e40eae4 100644 --- a/panda/src/physx/physxClothDesc.I +++ b/panda/src/physx/physxClothDesc.I @@ -1,45 +1,36 @@ -// Filename: physxClothDesc.I -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothDesc.I + * @author enn0x + * @date 2010-03-30 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothDesc:: PhysxClothDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothDesc:: ~PhysxClothDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxClothDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxClothDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxClothDesc.cxx b/panda/src/physx/physxClothDesc.cxx index 1dcf6be50d..cfe9fdf53b 100644 --- a/panda/src/physx/physxClothDesc.cxx +++ b/panda/src/physx/physxClothDesc.cxx @@ -1,26 +1,23 @@ -// Filename: physxClothDesc.cxx -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothDesc.cxx + * @author enn0x + * @date 2010-03-30 + */ #include "physxClothDesc.h" #include "physxClothMesh.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_name(const char *name) { @@ -28,33 +25,27 @@ set_name(const char *name) { _desc.name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_global_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_global_pos(const LPoint3f &pos) { _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_global_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_global_mat(const LMatrix4f &mat) { _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_global_hpr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_global_hpr(float h, float p, float r) { @@ -68,99 +59,81 @@ set_global_hpr(float h, float p, float r) { _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_thickness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_thickness(float thickness) { _desc.thickness = thickness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_density(float density) { _desc.density = density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_bending_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_bending_stiffness(float stiffness) { _desc.bendingStiffness = stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_stretching_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_stretching_stiffness(float stiffness) { _desc.stretchingStiffness = stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_damping_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_damping_coefficient(float damping) { _desc.dampingCoefficient = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_friction(float friction) { _desc.friction = friction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_pressure -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_pressure(float pressure) { _desc.pressure = pressure; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_tear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_tear_factor(float tearFactor) { _desc.tearFactor = tearFactor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_flag -// Access: Published -// Description: Raise or lower individual ClothFlag flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual ClothFlag flags. + */ void PhysxClothDesc:: set_flag(PhysxClothFlag flag, bool value) { @@ -172,167 +145,136 @@ set_flag(PhysxClothFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_solver_iterations -// Access: Published -// Description: Number of solver iterations. -// Small numbers make the simulation faster while -// the cloth gets less stiff. -//////////////////////////////////////////////////////////////////// +/** + * Number of solver iterations. Small numbers make the simulation faster + * while the cloth gets less stiff. + */ void PhysxClothDesc:: set_solver_iterations(unsigned int iterations) { _desc.solverIterations = iterations; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::set_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothDesc:: set_cloth_mesh(PhysxClothMesh *mesh) { _desc.clothMesh = mesh->ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxClothDesc:: get_name() const { return _desc.name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_global_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxClothDesc:: get_global_pos() const { return PhysxManager::nxVec3_to_point3(_desc.globalPose.t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_global_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4f PhysxClothDesc:: get_global_mat() const { return PhysxManager::nxMat34_to_mat4(_desc.globalPose); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_thickness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_thickness() const { return _desc.thickness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_density() const { return _desc.density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_bending_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_bending_stiffness() const { return _desc.bendingStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_stretching_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_stretching_stiffness() const { return _desc.stretchingStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_damping_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_damping_coefficient() const { return _desc.dampingCoefficient; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_friction() const { return _desc.friction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_pressure -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_pressure() const { return _desc.pressure; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_tear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxClothDesc:: get_tear_factor() const { return _desc.tearFactor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxClothDesc:: get_flag(PhysxClothFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_solver_iterations -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxClothDesc:: get_solver_iterations() const { @@ -340,12 +282,10 @@ get_solver_iterations() const { } /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothDesc::get_mesh_numbers -// Access: Public -// Description: Used by PhysScene to query the sizes of arrays -// to allocate for the user buffers in PhysxClothNode. -//////////////////////////////////////////////////////////////////// +/** + * Used by PhysScene to query the sizes of arrays to allocate for the user + * buffers in PhysxClothNode. + */ void PhysxClothDesc:: get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) { @@ -356,4 +296,3 @@ get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) { numTriangles = meshDesc.numTriangles; } */ - diff --git a/panda/src/physx/physxClothDesc.h b/panda/src/physx/physxClothDesc.h index edeb2f55e3..61a62e9a0f 100644 --- a/panda/src/physx/physxClothDesc.h +++ b/panda/src/physx/physxClothDesc.h @@ -1,16 +1,15 @@ -// Filename: physxClothDesc.h -// Created by: enn0x (30Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothDesc.h + * @author enn0x + * @date 2010-03-30 + */ #ifndef PHYSXCLOTHDESC_H #define PHYSXCLOTHDESC_H @@ -23,10 +22,9 @@ class PhysxClothMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxClothDesc -// Description : Descriptor for PhysxCloth. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for PhysxCloth. + */ class EXPCL_PANDAPHYSX PhysxClothDesc : public PhysxEnums { PUBLISHED: @@ -71,7 +69,7 @@ public: NxClothDesc _desc; private: - string _name; + string _name; }; #include "physxClothDesc.I" diff --git a/panda/src/physx/physxClothMesh.I b/panda/src/physx/physxClothMesh.I index 754114655d..1b50324f23 100644 --- a/panda/src/physx/physxClothMesh.I +++ b/panda/src/physx/physxClothMesh.I @@ -1,59 +1,47 @@ -// Filename: physxClothMesh.I -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMesh.I + * @author enn0x + * @date 2010-03-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothMesh:: PhysxClothMesh() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothMesh:: ~PhysxClothMesh() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxClothMesh:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxClothMesh:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxClothMesh.cxx b/panda/src/physx/physxClothMesh.cxx index 242bf75d5c..7a11a450e3 100644 --- a/panda/src/physx/physxClothMesh.cxx +++ b/panda/src/physx/physxClothMesh.cxx @@ -1,27 +1,24 @@ -// Filename: physxClothMesh.cxx -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMesh.cxx + * @author enn0x + * @date 2010-03-28 + */ #include "physxClothMesh.h" #include "physxMeshPool.h" TypeHandle PhysxClothMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothMesh:: link(NxClothMesh *meshPtr) { @@ -31,11 +28,9 @@ link(NxClothMesh *meshPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothMesh:: unlink() { @@ -44,11 +39,9 @@ unlink() { PhysxManager::get_global_ptr()->_cloth_meshes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothMesh:: release() { @@ -61,11 +54,9 @@ release() { PhysxMeshPool::release_cloth_mesh(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMesh::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxClothMesh:: get_reference_count() const { @@ -73,4 +64,3 @@ get_reference_count() const { return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxClothMesh.h b/panda/src/physx/physxClothMesh.h index bf96fa7ab5..b83a867875 100644 --- a/panda/src/physx/physxClothMesh.h +++ b/panda/src/physx/physxClothMesh.h @@ -1,16 +1,15 @@ -// Filename: physxClothMesh.h -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMesh.h + * @author enn0x + * @date 2010-03-28 + */ #ifndef PHYSXCLOTHMESH_H #define PHYSXCLOTHMESH_H @@ -20,16 +19,14 @@ #include "physxObject.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxClothMesh -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxClothMesh : public PhysxObject { PUBLISHED: unsigned int get_reference_count() const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -48,14 +45,13 @@ public: private: NxClothMesh *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxClothMesh", + register_type(_type_handle, "PhysxClothMesh", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxClothMeshDesc.I b/panda/src/physx/physxClothMeshDesc.I index 88a5ebb2da..973883686b 100644 --- a/panda/src/physx/physxClothMeshDesc.I +++ b/panda/src/physx/physxClothMeshDesc.I @@ -1,23 +1,19 @@ -// Filename: physxClothMeshDesc.I -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMeshDesc.I + * @author enn0x + * @date 2010-03-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothMeshDesc:: PhysxClothMeshDesc() { @@ -32,11 +28,9 @@ PhysxClothMeshDesc() { _texcoords = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothMeshDesc:: ~PhysxClothMeshDesc() { @@ -53,33 +47,27 @@ INLINE PhysxClothMeshDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxClothMeshDesc:: is_valid() const { return _desc.isValid(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::get_desc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const NxClothMeshDesc &PhysxClothMeshDesc:: get_desc() const { return _desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::get_texcoords -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const plist PhysxClothMeshDesc:: get_texcoords() const { @@ -92,4 +80,3 @@ get_texcoords() const { return texcoords; } - diff --git a/panda/src/physx/physxClothMeshDesc.cxx b/panda/src/physx/physxClothMeshDesc.cxx index e0319d5c6c..9b234c7d2e 100644 --- a/panda/src/physx/physxClothMeshDesc.cxx +++ b/panda/src/physx/physxClothMeshDesc.cxx @@ -1,16 +1,15 @@ -// Filename: physxClothMeshDesc.cxx -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMeshDesc.cxx + * @author enn0x + * @date 2010-03-28 + */ #include "physxClothMeshDesc.h" #include "physxManager.h" @@ -19,16 +18,13 @@ #include "geomNode.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::set_num_vertices -// Access: Published -// Description: Sets the number of vertices to be stored within -// this triangle mesh. The function allocates memory -// for the vertices, but it does not set any vertices. -// -// This method must be called before any calls to -// set_vertex are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of vertices to be stored within this triangle mesh. The + * function allocates memory for the vertices, but it does not set any + * vertices. + * + * This method must be called before any calls to set_vertex are done! + */ void PhysxClothMeshDesc:: set_num_vertices(unsigned int numVertices) { @@ -50,12 +46,10 @@ set_num_vertices(unsigned int numVertices) { _texcoords = new LPoint2f[numVertices]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::set_vertex -// Access: Published -// Description: Sets a single vertex. You have to call the function -// set_num_vertices before you can call this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single vertex. You have to call the function set_num_vertices + * before you can call this function. + */ void PhysxClothMeshDesc:: set_vertex(unsigned int idx, const LPoint3f &vert, const LPoint2f &texcoord) { @@ -65,15 +59,11 @@ set_vertex(unsigned int idx, const LPoint3f &vert, const LPoint2f &texcoord) { _texcoords[idx] = texcoord; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::set_num_triangles -// Access: Published -// Description: Sets the number of triangles to be stored in this -// triangle mesh. -// -// This method must be called before any calls to -// set_triangle are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of triangles to be stored in this triangle mesh. + * + * This method must be called before any calls to set_triangle are done! + */ void PhysxClothMeshDesc:: set_num_triangles(unsigned int numTriangles) { @@ -87,12 +77,9 @@ set_num_triangles(unsigned int numTriangles) { _desc.triangles = _triangles; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::set_triangles -// Access: Published -// Description: Sets a single triangle, by providing the three -// indices i1, i2, i3. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single triangle, by providing the three indices i1, i2, i3. + */ void PhysxClothMeshDesc:: set_triangle(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3) { @@ -105,21 +92,14 @@ set_triangle(unsigned int idx, _triangles[idx + 2] = i3; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothMeshDesc::set_from_node_path -// Access: Published -// Description: A convenience method to set the mesh data from -// a NodePath in a single call. The method iterates -// over the NodePath geoms and collects data for -// the triangle mesh. -// -// Do not use the following function when using this -// one: -// - set_num_vertices -// - set_vertex -// - set_num_triangles -// - set_triangle -//////////////////////////////////////////////////////////////////// +/** + * A convenience method to set the mesh data from a NodePath in a single call. + * The method iterates over the NodePath geoms and collects data for the + * triangle mesh. + * + * Do not use the following function when using this one: - set_num_vertices - + * set_vertex - set_num_triangles - set_triangle + */ void PhysxClothMeshDesc:: set_from_node_path(const NodePath &np) { @@ -211,4 +191,3 @@ set_from_node_path(const NodePath &np) { _desc.numTriangles = numTriangles; _desc.triangles = _triangles; } - diff --git a/panda/src/physx/physxClothMeshDesc.h b/panda/src/physx/physxClothMeshDesc.h index 68075f97ec..d2c5d79b1e 100644 --- a/panda/src/physx/physxClothMeshDesc.h +++ b/panda/src/physx/physxClothMeshDesc.h @@ -1,16 +1,15 @@ -// Filename: physxClothMeshDesc.h -// Created by: enn0x (28Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothMeshDesc.h + * @author enn0x + * @date 2010-03-28 + */ #ifndef PHYSXCLOTHMESHDESC_H #define PHYSXCLOTHMESHDESC_H @@ -22,10 +21,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxClothMeshDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxClothMeshDesc { PUBLISHED: diff --git a/panda/src/physx/physxClothNode.I b/panda/src/physx/physxClothNode.I index b11eb93cb4..3597004f03 100644 --- a/panda/src/physx/physxClothNode.I +++ b/panda/src/physx/physxClothNode.I @@ -1,24 +1,19 @@ -// Filename: physxClothNode.I -// Created by: enn0x (05Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothNode.I + * @author enn0x + * @date 2010-04-05 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothNode:: PhysxClothNode(const char *name) : GeomNode(name) { @@ -38,11 +33,9 @@ PhysxClothNode(const char *name) : GeomNode(name) { _texcoords = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxClothNode:: ~PhysxClothNode() { @@ -50,4 +43,3 @@ INLINE PhysxClothNode:: delete [] _texcoords; } } - diff --git a/panda/src/physx/physxClothNode.cxx b/panda/src/physx/physxClothNode.cxx index 0aa76c4afa..e5b9ae104a 100644 --- a/panda/src/physx/physxClothNode.cxx +++ b/panda/src/physx/physxClothNode.cxx @@ -1,16 +1,15 @@ -// Filename: physxClothNode.cxx -// Created by: enn0x (05Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothNode.cxx + * @author enn0x + * @date 2010-04-05 + */ #include "physxClothNode.h" #include "physxCloth.h" @@ -21,11 +20,9 @@ TypeHandle PhysxClothNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::allocate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothNode:: allocate(PhysxCloth *cloth) { @@ -69,11 +66,9 @@ allocate(PhysxCloth *cloth) { _cloth->ptr()->setMeshData(_mesh); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::update -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothNode:: update() { @@ -89,11 +84,9 @@ update() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::create_geom -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothNode:: create_geom() { @@ -139,11 +132,9 @@ create_geom() { _prim->close_primitive(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::update_geom -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothNode:: update_geom() { @@ -162,11 +153,9 @@ update_geom() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::update_texcoords -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxClothNode:: update_texcoords() { @@ -185,11 +174,9 @@ update_texcoords() { _numTexcoords = numVertices; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxClothNode::set_texcoords -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxClothNode:: set_texcoords(const Filename &filename) { @@ -226,4 +213,3 @@ set_texcoords(const Filename &filename) { return true; } - diff --git a/panda/src/physx/physxClothNode.h b/panda/src/physx/physxClothNode.h index 27706709be..7c9c887092 100644 --- a/panda/src/physx/physxClothNode.h +++ b/panda/src/physx/physxClothNode.h @@ -1,16 +1,15 @@ -// Filename: physxClothNode.h -// Created by: enn0x (05Apr10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxClothNode.h + * @author enn0x + * @date 2010-04-05 + */ #ifndef PHYSXCLOTHNODE_H #define PHYSXCLOTHNODE_H @@ -28,10 +27,9 @@ class PhysxCloth; -//////////////////////////////////////////////////////////////////// -// Class : PhysxClothNode -// Description : Renderable geometry which represents a cloth mesh. -//////////////////////////////////////////////////////////////////// +/** + * Renderable geometry which represents a cloth mesh. + */ class EXPCL_PANDAPHYSX PhysxClothNode : public GeomNode { PUBLISHED: @@ -62,14 +60,13 @@ private: unsigned int _numTexcoords; float *_texcoords; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { GeomNode::init_type(); - register_type(_type_handle, "PhysxClothNode", + register_type(_type_handle, "PhysxClothNode", GeomNode::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxConstraintDominance.I b/panda/src/physx/physxConstraintDominance.I index 8455f7f738..0d79128d59 100644 --- a/panda/src/physx/physxConstraintDominance.I +++ b/panda/src/physx/physxConstraintDominance.I @@ -1,57 +1,46 @@ -// Filename: physxConstraintDominance.I -// Created by: enn0x (22Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConstraintDominance.I + * @author enn0x + * @date 2009-12-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConstraintDominance:: PhysxConstraintDominance(float d0, float d1) : _dominance(d0, d1) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConstraintDominance:: ~PhysxConstraintDominance() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::get_dominance -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NxConstraintDominance PhysxConstraintDominance:: get_dominance() const { return _dominance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::set_dominance -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxConstraintDominance:: set_dominance(NxConstraintDominance value) { _dominance = value; } - diff --git a/panda/src/physx/physxConstraintDominance.cxx b/panda/src/physx/physxConstraintDominance.cxx index 35af6fd2c8..8227c9826f 100644 --- a/panda/src/physx/physxConstraintDominance.cxx +++ b/panda/src/physx/physxConstraintDominance.cxx @@ -1,60 +1,50 @@ -// Filename: physxConstraintDominance.cxx -// Created by: enn0x (22Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConstraintDominance.cxx + * @author enn0x + * @date 2009-12-22 + */ #include "physxConstraintDominance.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::get_0 -// Access: Published -// Description: Retruns the first dominance factor. -//////////////////////////////////////////////////////////////////// +/** + * Retruns the first dominance factor. + */ float PhysxConstraintDominance:: get_0() const { return _dominance.dominance0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::get_1 -// Access: Published -// Description: Returns the second dominance factor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second dominance factor. + */ float PhysxConstraintDominance:: get_1() const { return _dominance.dominance1; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::set_0 -// Access: Published -// Description: Sets the first dominance factor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the first dominance factor. + */ void PhysxConstraintDominance:: set_0(float d0) { _dominance.dominance0 = d0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConstraintDominance::set_1 -// Access: Published -// Description: Sets the second dominance factor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the second dominance factor. + */ void PhysxConstraintDominance:: set_1(float d1) { _dominance.dominance1 = d1; } - diff --git a/panda/src/physx/physxConstraintDominance.h b/panda/src/physx/physxConstraintDominance.h index 430aa8b9d5..9d35fd9111 100644 --- a/panda/src/physx/physxConstraintDominance.h +++ b/panda/src/physx/physxConstraintDominance.h @@ -1,16 +1,15 @@ -// Filename: physxConstraintDominance.h -// Created by: enn0x (22Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConstraintDominance.h + * @author enn0x + * @date 2009-12-22 + */ #ifndef PHYSXCONSTRAINTDOMINANCE_H #define PHYSXCONSTRAINTDOMINANCE_H @@ -22,16 +21,14 @@ class PhysxShape; -//////////////////////////////////////////////////////////////////// -// Class : PhysxConstraintDominance -// Description : Expresses the dominance relationship of a -// constraint. For the time being only three settings -// are permitted:. (1.0f, 1.0f), (0.0f, 1.0f), and -// (1.0f, 0.0f). -// -// See PhysxScene::set_dominance_group_pair for a -// detailed explanation of dominance behaviour. -//////////////////////////////////////////////////////////////////// +/** + * Expresses the dominance relationship of a constraint. For the time being + * only three settings are permitted:. (1.0f, 1.0f), (0.0f, 1.0f), and (1.0f, + * 0.0f). + * + * See PhysxScene::set_dominance_group_pair for a detailed explanation of + * dominance behaviour. + */ class EXPCL_PANDAPHYSX PhysxConstraintDominance { PUBLISHED: diff --git a/panda/src/physx/physxContactPair.I b/panda/src/physx/physxContactPair.I index 81c661b0ae..479b691dbf 100644 --- a/panda/src/physx/physxContactPair.I +++ b/panda/src/physx/physxContactPair.I @@ -1,36 +1,29 @@ -// Filename: physxContactPair.I -// Created by: enn0x (19Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPair.I + * @author enn0x + * @date 2009-12-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactPair:: PhysxContactPair(const NxContactPair pair) { _pair = pair; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactPair:: ~PhysxContactPair() { } - diff --git a/panda/src/physx/physxContactPair.cxx b/panda/src/physx/physxContactPair.cxx index cf107aa2a5..1ecd1fab6d 100644 --- a/panda/src/physx/physxContactPair.cxx +++ b/panda/src/physx/physxContactPair.cxx @@ -1,16 +1,15 @@ -// Filename: physxContactPair.cxx -// Created by: enn0x (19Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPair.cxx + * @author enn0x + * @date 2009-12-19 + */ #include "physxContactPair.h" #include "physxManager.h" @@ -19,12 +18,9 @@ TypeHandle PhysxContactPair::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_actor_a -// Access: Published -// Description: Returns the first of the two actors that makes up -// this pair. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first of the two actors that makes up this pair. + */ PhysxActor *PhysxContactPair:: get_actor_a() const { @@ -37,12 +33,9 @@ get_actor_a() const { return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_actor_b -// Access: Published -// Description: Returns the second of the two actors that make up -// his pair. -//////////////////////////////////////////////////////////////////// +/** + * Returns the second of the two actors that make up his pair. + */ PhysxActor *PhysxContactPair:: get_actor_b() const { @@ -55,76 +48,61 @@ get_actor_b() const { return (actorPtr == NULL) ? NULL : (PhysxActor *)actorPtr->userData; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::is_deleted_a -// Access: Published -// Description: Returns true if the first of the two actors is -// deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the first of the two actors is deleted. + */ bool PhysxContactPair:: is_deleted_a() const { return _pair.isDeletedActor[0]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::is_deleted_b -// Access: Published -// Description: Returns true if the second of the two actors is -// deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the second of the two actors is deleted. + */ bool PhysxContactPair:: is_deleted_b() const { return _pair.isDeletedActor[1]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_sum_normal_force -// Access: Published -// Description: Returns the total contact normal force that was -// applied for this pair, to maintain nonpenetration -// constraints. -// -// You should set the ContactPairFlag -// CPF_notify_forces in order to receive this value. -// -// @see PhysxScene::set_actor_pair_flag -// @see PhysxScene::set_actor_group_pair_flag -//////////////////////////////////////////////////////////////////// +/** + * Returns the total contact normal force that was applied for this pair, to + * maintain nonpenetration constraints. + * + * You should set the ContactPairFlag CPF_notify_forces in order to receive + * this value. + * + * @see PhysxScene::set_actor_pair_flag @see + * PhysxScene::set_actor_group_pair_flag + */ LVector3f PhysxContactPair:: get_sum_normal_force() const { return PhysxManager::nxVec3_to_vec3(_pair.sumNormalForce); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_sum_friction_force -// Access: Published -// Description: Returns the total tangential force that was applied -// for this pair. -// -// You should set the ContactPairFlag -// CPF_notify_forces in order to receive this value. -// -// @see PhysxScene::set_actor_pair_flag -// @see PhysxScene::set_actor_group_pair_flag -//////////////////////////////////////////////////////////////////// +/** + * Returns the total tangential force that was applied for this pair. + * + * You should set the ContactPairFlag CPF_notify_forces in order to receive + * this value. + * + * @see PhysxScene::set_actor_pair_flag @see + * PhysxScene::set_actor_group_pair_flag + */ LVector3f PhysxContactPair:: get_sum_friction_force() const { return PhysxManager::nxVec3_to_vec3(_pair.sumFrictionForce); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_num_contact_points -// Access: Published -// Description: Returns the total number of contact points reported -// in this pair's contact stream. -// -// This method is a helper for iterating over the -// pair's contact stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of contact points reported in this pair's contact + * stream. + * + * This method is a helper for iterating over the pair's contact stream. + */ unsigned int PhysxContactPair:: get_num_contact_points() { @@ -144,20 +122,15 @@ get_num_contact_points() { return _contacts.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPair::get_contact_point -// Access: Published -// Description: Returns an instance of PhysxContactPoint, which -// represents a single entry of this pair's contact -// stream. -// -// This method is a helper for iterating over the -// pair's contact stream. -//////////////////////////////////////////////////////////////////// +/** + * Returns an instance of PhysxContactPoint, which represents a single entry + * of this pair's contact stream. + * + * This method is a helper for iterating over the pair's contact stream. + */ PhysxContactPoint PhysxContactPair:: get_contact_point(unsigned int idx) const { nassertr(idx < _contacts.size(), PhysxContactPoint::empty()); return _contacts[idx]; } - diff --git a/panda/src/physx/physxContactPair.h b/panda/src/physx/physxContactPair.h index a839d02633..dc48fba5b6 100644 --- a/panda/src/physx/physxContactPair.h +++ b/panda/src/physx/physxContactPair.h @@ -1,16 +1,15 @@ -// Filename: physxContactPair.h -// Created by: enn0x (19Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPair.h + * @author enn0x + * @date 2009-12-19 + */ #ifndef PHYSXCONTACTPAIR_H #define PHYSXCONTACTPAIR_H @@ -25,12 +24,10 @@ class PhysxShape; class PhysxContactPoint; -//////////////////////////////////////////////////////////////////// -// Class : PhysxContactPair -// Description : An instance of this class is send with contact -// reporting events. It contains detailed information -// on the contact. -//////////////////////////////////////////////////////////////////// +/** + * An instance of this class is send with contact reporting events. It + * contains detailed information on the contact. + */ class EXPCL_PANDAPHYSX PhysxContactPair : public TypedReferenceCount { PUBLISHED: @@ -54,14 +51,13 @@ private: NxContactPair _pair; pvector _contacts; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "PhysxContactPair", + register_type(_type_handle, "PhysxContactPair", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxContactPoint.I b/panda/src/physx/physxContactPoint.I index bed1fcd52b..d2dec89747 100644 --- a/panda/src/physx/physxContactPoint.I +++ b/panda/src/physx/physxContactPoint.I @@ -1,36 +1,29 @@ -// Filename: physxContactPoint.I -// Created by: enn0x (20Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPoint.I + * @author enn0x + * @date 2009-12-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactPoint:: PhysxContactPoint() { - //_hit = hit; + // _hit = hit; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactPoint:: ~PhysxContactPoint() { } - diff --git a/panda/src/physx/physxContactPoint.cxx b/panda/src/physx/physxContactPoint.cxx index 4f7cbaa34b..b96150edda 100644 --- a/panda/src/physx/physxContactPoint.cxx +++ b/panda/src/physx/physxContactPoint.cxx @@ -1,16 +1,15 @@ -// Filename: physxContactPoint.cxx -// Created by: enn0x (20Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPoint.cxx + * @author enn0x + * @date 2009-12-20 + */ #include "physxContactPoint.h" #include "physxManager.h" @@ -18,11 +17,9 @@ TypeHandle PhysxContactPoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::set -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxContactPoint:: set(NxContactStreamIterator it) { @@ -34,11 +31,9 @@ set(NxContactStreamIterator it) { _feature_index1 = it.getFeatureIndex1(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxContactPoint PhysxContactPoint:: empty() { @@ -46,69 +41,56 @@ empty() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_point -// Access: Published -// Description: Returns the contact point position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the contact point position. + */ LPoint3f PhysxContactPoint:: get_point() const { return PhysxManager::nxVec3_to_point3(_point); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_normal -// Access: Published -// Description: Retrieves the patch normal. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the patch normal. + */ LVector3f PhysxContactPoint:: get_normal() const { return PhysxManager::nxVec3_to_vec3(_normal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_normal_force -// Access: Published -// Description: Retrieves the point normal force. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the point normal force. + */ float PhysxContactPoint:: get_normal_force() const { return _normal_force; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_separation -// Access: Published -// Description: Return the separation for the contact point. -//////////////////////////////////////////////////////////////////// +/** + * Return the separation for the contact point. + */ float PhysxContactPoint:: get_separation() const { return _separation; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_feature_index0 -// Access: Published -// Description: Retrieves the feature index. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the feature index. + */ unsigned int PhysxContactPoint:: get_feature_index0() const { return _feature_index0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactPoint::get_feature_index1 -// Access: Published -// Description: Retrieves the feature index. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the feature index. + */ unsigned int PhysxContactPoint:: get_feature_index1() const { return _feature_index1; } - diff --git a/panda/src/physx/physxContactPoint.h b/panda/src/physx/physxContactPoint.h index 13e9f56b14..a5da16641a 100644 --- a/panda/src/physx/physxContactPoint.h +++ b/panda/src/physx/physxContactPoint.h @@ -1,16 +1,15 @@ -// Filename: physxContactPoint.h -// Created by: enn0x (20Dec09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactPoint.h + * @author enn0x + * @date 2009-12-20 + */ #ifndef PHYSXCONTACTPOINT_H #define PHYSXCONTACTPOINT_H @@ -23,11 +22,10 @@ class PhysxShape; -//////////////////////////////////////////////////////////////////// -// Class : PhysxContactPoint -// Description : A helper structure for iterating over contact -// streams reported by PhysxContactPair. -//////////////////////////////////////////////////////////////////// +/** + * A helper structure for iterating over contact streams reported by + * PhysxContactPair. + */ class EXPCL_PANDAPHYSX PhysxContactPoint : public TypedObject { PUBLISHED: @@ -54,14 +52,13 @@ private: NxU32 _feature_index0; NxU32 _feature_index1; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "PhysxContactPoint", + register_type(_type_handle, "PhysxContactPoint", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxContactReport.I b/panda/src/physx/physxContactReport.I index dbd4b76862..184ab2d56a 100644 --- a/panda/src/physx/physxContactReport.I +++ b/panda/src/physx/physxContactReport.I @@ -1,36 +1,29 @@ -// Filename: physxContactReport.I -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactReport.I + * @author enn0x + * @date 2009-09-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactReport:: PhysxContactReport() : NxUserContactReport() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxContactReport:: ~PhysxContactReport() { } - diff --git a/panda/src/physx/physxContactReport.cxx b/panda/src/physx/physxContactReport.cxx index 33d2f1b691..f7913a039a 100644 --- a/panda/src/physx/physxContactReport.cxx +++ b/panda/src/physx/physxContactReport.cxx @@ -1,16 +1,15 @@ -// Filename: physxContactReport.cxx -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactReport.cxx + * @author enn0x + * @date 2009-09-19 + */ #include "physxContactReport.h" #include "physxContactPair.h" @@ -22,44 +21,36 @@ PStatCollector PhysxContactReport::_pcollector("App:PhysX:Contact Reporting"); -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::enable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxContactReport:: enable() { _enabled = true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::disable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxContactReport:: disable() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::is_enabled -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxContactReport:: is_enabled() const { return _enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxContactReport::onContactNotify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxContactReport:: onContactNotify(NxContactPair &pair, NxU32 flags) { @@ -98,4 +89,3 @@ onContactNotify(NxContactPair &pair, NxU32 flags) { _pcollector.stop(); } - diff --git a/panda/src/physx/physxContactReport.h b/panda/src/physx/physxContactReport.h index 4bde698c5c..45c760c36f 100644 --- a/panda/src/physx/physxContactReport.h +++ b/panda/src/physx/physxContactReport.h @@ -1,16 +1,15 @@ -// Filename: physxContactReport.h -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxContactReport.h + * @author enn0x + * @date 2009-09-19 + */ #ifndef PHYSXCONTACTREPORT_H #define PHYSXCONTACTREPORT_H @@ -19,11 +18,9 @@ #include "pStatCollector.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxContactReport -// Description : Implementation of the NxUserContactReport -// interface. -//////////////////////////////////////////////////////////////////// +/** + * Implementation of the NxUserContactReport interface. + */ class EXPCL_PANDAPHYSX PhysxContactReport : public NxUserContactReport { public: diff --git a/panda/src/physx/physxController.I b/panda/src/physx/physxController.I index 41bf5c867e..c6b667c35e 100644 --- a/panda/src/physx/physxController.I +++ b/panda/src/physx/physxController.I @@ -1,24 +1,19 @@ -// Filename: physxController.I -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxController.I + * @author enn0x + * @date 2009-09-24 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxController:: PhysxController() : PhysxObject() { @@ -51,22 +46,18 @@ PhysxController() : PhysxObject() { _up_quat_inv.invert(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxController:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxController:: ls(ostream &out, int indent_level) const { @@ -76,4 +67,3 @@ ls(ostream &out, int indent_level) const { out << " A:0x" << get_actor(); out << "\n"; } - diff --git a/panda/src/physx/physxController.cxx b/panda/src/physx/physxController.cxx index 59125f3ff8..4e83a282a4 100644 --- a/panda/src/physx/physxController.cxx +++ b/panda/src/physx/physxController.cxx @@ -1,16 +1,15 @@ -// Filename: physxController.cxx -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxController.cxx + * @author enn0x + * @date 2009-09-24 + */ #include "event.h" #include "eventQueue.h" @@ -24,11 +23,9 @@ TypeHandle PhysxController::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxController:: release() { @@ -39,11 +36,9 @@ release() { cm->releaseController(*ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::factory -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxController *PhysxController:: factory(NxControllerType controllerType) { @@ -64,12 +59,9 @@ factory(NxControllerType controllerType) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::get_actor -// Access: Published -// Description: Retrieves the actor which this controller is -// associated with. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actor which this controller is associated with. + */ PhysxActor *PhysxController:: get_actor() const { @@ -77,13 +69,10 @@ get_actor() const { return (PhysxActor *)(ptr()->getActor()->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_pos -// Access: Published -// Description: Sets the position of the controller is global -// space. This can be used for initial placement or -// for teleporting the character. -//////////////////////////////////////////////////////////////////// +/** + * Sets the position of the controller is global space. This can be used for + * initial placement or for teleporting the character. + */ void PhysxController:: set_pos(const LPoint3f &pos) { @@ -91,12 +80,9 @@ set_pos(const LPoint3f &pos) { ptr()->setPosition(PhysxManager::point3_to_nxExtVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::get_pos -// Access: Published -// Description: Retruns the position of the controller is global -// space. -//////////////////////////////////////////////////////////////////// +/** + * Retruns the position of the controller is global space. + */ LPoint3f PhysxController:: get_pos() const { @@ -104,16 +90,12 @@ get_pos() const { return PhysxManager::nxExtVec3_to_point3(ptr()->getPosition()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_sharpness -// Access: Published -// Description: Sharpness is used to smooth motion with a feedback -// filter, having a value between 0 (so smooth it -// doesn't move) and 1 (no smoothing = unfiltered -// motion). Sharpness can ease the motion curve when -// the auto-step feature is used with boxes. -// Default value is 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Sharpness is used to smooth motion with a feedback filter, having a value + * between 0 (so smooth it doesn't move) and 1 (no smoothing = unfiltered + * motion). Sharpness can ease the motion curve when the auto-step feature is + * used with boxes. Default value is 1.0. + */ void PhysxController:: set_sharpness(float sharpness) { @@ -124,13 +106,10 @@ set_sharpness(float sharpness) { _sharpness = sharpness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::get_sharpness -// Access: Published -// Description: Returns the sharpness used to ease the motion curve -// when the auto-step feature is used. -// Default value is 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sharpness used to ease the motion curve when the auto-step + * feature is used. Default value is 1.0. + */ float PhysxController:: get_sharpness() const { @@ -138,12 +117,9 @@ get_sharpness() const { return _sharpness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_collision -// Access: Published -// Description: Enable/Disable collisions for this controller and -// actor. -//////////////////////////////////////////////////////////////////// +/** + * Enable/Disable collisions for this controller and actor. + */ void PhysxController:: set_collision(bool enable) { @@ -151,16 +127,12 @@ set_collision(bool enable) { ptr()->setCollision(enable); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_min_distance -// Access: Published -// Description: Sets the the minimum travelled distance to consider -// when moving the controller. If travelled distance -// is smaller, the character doesn't move. This is -// used to stop the recursive motion algorithm when -// remaining distance to travel is small. -// The default value is 0.0001. -//////////////////////////////////////////////////////////////////// +/** + * Sets the the minimum travelled distance to consider when moving the + * controller. If travelled distance is smaller, the character doesn't move. + * This is used to stop the recursive motion algorithm when remaining distance + * to travel is small. The default value is 0.0001. + */ void PhysxController:: set_min_distance(float min_dist) { @@ -170,11 +142,9 @@ set_min_distance(float min_dist) { _min_dist = min_dist; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_step_offset -// Access: Published -// Description: Sets the step height/offset for the controller. -//////////////////////////////////////////////////////////////////// +/** + * Sets the step height/offset for the controller. + */ void PhysxController:: set_step_offset(float offset) { @@ -184,12 +154,9 @@ set_step_offset(float offset) { ptr()->setStepOffset(offset); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_global_speed -// Access: Published -// Description: Sets the linear speed of the controller in global -// space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear speed of the controller in global space. + */ void PhysxController:: set_global_speed(const LVector3f &speed) { @@ -199,12 +166,9 @@ set_global_speed(const LVector3f &speed) { _speed = NxVec3(speed.get_x(), speed.get_y(), speed.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_local_speed -// Access: Published -// Description: Sets the linear speed of the controller in local -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear speed of the controller in local coordinates. + */ void PhysxController:: set_local_speed(const LVector3f &speed) { @@ -219,14 +183,11 @@ set_local_speed(const LVector3f &speed) { _speed = (q * _up_quat_inv).rot(s); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_omega -// Access: Published -// Description: Sets the angular velocity (degrees per second) -// of the controller. The angular velocity is used to -// compute the new heading when updating the -// controller. -//////////////////////////////////////////////////////////////////// +/** + * Sets the angular velocity (degrees per second) of the controller. The + * angular velocity is used to compute the new heading when updating the + * controller. + */ void PhysxController:: set_omega(float omega) { @@ -234,14 +195,11 @@ set_omega(float omega) { _omega = omega; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::set_h -// Access: Published -// Description: Sets the heading of the controller is global -// space. Note: only heading is supported. Pitch and -// roll are constrained by PhysX in order to alyways -// keep the character upright. -//////////////////////////////////////////////////////////////////// +/** + * Sets the heading of the controller is global space. Note: only heading is + * supported. Pitch and roll are constrained by PhysX in order to alyways + * keep the character upright. + */ void PhysxController:: set_h(float heading) { @@ -252,12 +210,9 @@ set_h(float heading) { ptr()->getActor()->moveGlobalOrientationQuat(_up_quat * q); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::get_h -// Access: Published -// Description: Returns the heading of the controller in global -// space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the heading of the controller in global space. + */ float PhysxController:: get_h() const { @@ -265,15 +220,11 @@ get_h() const { return _heading; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::report_scene_changed -// Access: Published -// Description: The character controller uses caching in order to -// speed up collision testing, this caching can not -// detect when static objects have changed in the -// scene. You need to call this method when such -// changes have been made. -//////////////////////////////////////////////////////////////////// +/** + * The character controller uses caching in order to speed up collision + * testing, this caching can not detect when static objects have changed in + * the scene. You need to call this method when such changes have been made. + */ void PhysxController:: report_scene_changed() { @@ -281,11 +232,9 @@ report_scene_changed() { ptr()->reportSceneChanged(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::update_controller -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxController:: update_controller(float dt) { @@ -324,11 +273,9 @@ update_controller(float dt) { _omega = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::get_jump_height -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxReal PhysxController:: get_jump_height(float dt, NxVec3 &gravity) { @@ -343,12 +290,10 @@ get_jump_height(float dt, NxVec3 &gravity) { return (h - G) * dt; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::start_jump -// Access: Published -// Description: Enters the jump mode. The parameter is the intial -// upward velocity of the character. -//////////////////////////////////////////////////////////////////// +/** + * Enters the jump mode. The parameter is the intial upward velocity of the + * character. + */ void PhysxController:: start_jump(float v0) { @@ -363,13 +308,10 @@ start_jump(float v0) { _jump_v0 = v0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxController::stop_jump -// Access: Published -// Description: Leaves the jump mode. This method is automatically -// called if a ground collision is detected. Usually -// users need not call this method. -//////////////////////////////////////////////////////////////////// +/** + * Leaves the jump mode. This method is automatically called if a ground + * collision is detected. Usually users need not call this method. + */ void PhysxController:: stop_jump() { @@ -381,12 +323,11 @@ stop_jump() { _jumping = false; - //NxVec3 v = ptr()->getActor()->getLinearVelocity(); - //double velocity = (_up_axis == NX_Z) ? v.z : v.y; + // NxVec3 v = ptr()->getActor()->getLinearVelocity(); double velocity = + // (_up_axis == NX_Z) ? v.z : v.y; Event *event = new Event("physx-controller-down"); event->add_parameter(EventParameter(this)); - //event->add_parameter(EventParameter(velocity)); + // event->add_parameter(EventParameter(velocity)); EventQueue::get_global_event_queue()->queue_event(event); } - diff --git a/panda/src/physx/physxController.h b/panda/src/physx/physxController.h index c593450471..f759f43fea 100644 --- a/panda/src/physx/physxController.h +++ b/panda/src/physx/physxController.h @@ -1,16 +1,15 @@ -// Filename: physxController.h -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxController.h + * @author enn0x + * @date 2009-09-24 + */ #ifndef PHYSXCONTROLLER_H #define PHYSXCONTROLLER_H @@ -25,10 +24,9 @@ class PhysxActor; -//////////////////////////////////////////////////////////////////// -// Class : PhysxController -// Description : Abstract base class for character controllers. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for character controllers. + */ class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -90,14 +88,13 @@ private: NxQuat _up_quat_inv; NxHeightFieldAxis _up_axis; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxController", + register_type(_type_handle, "PhysxController", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxControllerDesc.I b/panda/src/physx/physxControllerDesc.I index de3d3bf50d..bedc5a3fd1 100644 --- a/panda/src/physx/physxControllerDesc.I +++ b/panda/src/physx/physxControllerDesc.I @@ -1,26 +1,20 @@ -// Filename: physxControllerDesc.I -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerDesc.I + * @author enn0x + * @date 2009-09-22 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxControllerDesc:: PhysxControllerDesc() { } - diff --git a/panda/src/physx/physxControllerDesc.cxx b/panda/src/physx/physxControllerDesc.cxx index 8ae3a0103b..9e3427125f 100644 --- a/panda/src/physx/physxControllerDesc.cxx +++ b/panda/src/physx/physxControllerDesc.cxx @@ -1,148 +1,115 @@ -// Filename: physxControllerDesc.cxx -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerDesc.cxx + * @author enn0x + * @date 2009-09-22 + */ #include "physxControllerDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::set_pos -// Access: Published -// Description: Set the position of the character. -//////////////////////////////////////////////////////////////////// +/** + * Set the position of the character. + */ void PhysxControllerDesc:: set_pos(const LPoint3f &pos) { ptr()->position = PhysxManager::point3_to_nxExtVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::set_slope_limit -// Access: Published -// Description: Sets the maximum slope which the character can walk -// up. In general it is desirable to limit where the -// character can walk, in particular it is unrealistic -// for the character to be able to climb arbitary -// slopes. -// The value is expressed in degrees. -// Default: 45.0 degrees. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum slope which the character can walk up. In general it is + * desirable to limit where the character can walk, in particular it is + * unrealistic for the character to be able to climb arbitary slopes. The + * value is expressed in degrees. Default: 45.0 degrees. + */ void PhysxControllerDesc:: set_slope_limit(float slopeLimit) { ptr()->slopeLimit = cosf(NxMath::degToRad(slopeLimit)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::set_skin_width -// Access: Published -// Description: Sets the skin width used by the controller. -// A "skin" around the controller is necessary to -// avoid numerical precision issues. -// This is dependant on the scale of the users world, -// but should be a small, positive non zero value. -// Default: 0.1 -//////////////////////////////////////////////////////////////////// +/** + * Sets the skin width used by the controller. A "skin" around the controller + * is necessary to avoid numerical precision issues. This is dependant on the + * scale of the users world, but should be a small, positive non zero value. + * Default: 0.1 + */ void PhysxControllerDesc:: set_skin_width(float skinWidth) { ptr()->skinWidth = skinWidth; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::set_step_offset -// Access: Published -// Description: Defines the maximum height of an obstacle which the -// character can climb. -// A small value will mean that the character gets -// stuck and cannot walk up stairs etc, a value which -// is too large will mean that the character can climb -// over unrealistically high obstacles. -// Default: 0.5 -//////////////////////////////////////////////////////////////////// +/** + * Defines the maximum height of an obstacle which the character can climb. A + * small value will mean that the character gets stuck and cannot walk up + * stairs etc, a value which is too large will mean that the character can + * climb over unrealistically high obstacles. Default: 0.5 + */ void PhysxControllerDesc:: set_step_offset(float stepOffset) { ptr()->stepOffset = stepOffset; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::set_interaction_flag -// Access: Published -// Description: The interaction flag controls if a character -// controller collides with other controllers. -// The default is to collide with other controllers. -//////////////////////////////////////////////////////////////////// +/** + * The interaction flag controls if a character controller collides with other + * controllers. The default is to collide with other controllers. + */ void PhysxControllerDesc:: set_interaction_flag(bool interactionFlag) { ptr()->interactionFlag = (NxCCTInteractionFlag)interactionFlag; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::get_pos -// Access: Published -// Description: Returns the position of the character. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the character. + */ LPoint3f PhysxControllerDesc:: get_pos() const { return PhysxManager::nxExtVec3_to_point3(ptr()->position); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::get_slope_limit -// Access: Published -// Description: Returns the maximum slope which the character can -// walk up. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum slope which the character can walk up. + */ float PhysxControllerDesc:: get_slope_limit() const { return NxMath::radToDeg(acosf(ptr()->slopeLimit)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::get_skin_width -// Access: Published -// Description: Returns the skin width used by the controller. -//////////////////////////////////////////////////////////////////// +/** + * Returns the skin width used by the controller. + */ float PhysxControllerDesc:: get_skin_width() const { return ptr()->skinWidth; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::get_step_offset -// Access: Published -// Description: Returns the maximum height of an obstacle which the -// character can climb. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum height of an obstacle which the character can climb. + */ float PhysxControllerDesc:: get_step_offset() const { return ptr()->stepOffset; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerDesc::get_interaction_flag -// Access: Published -// Description: Returns the interaction flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the interaction flag. + */ bool PhysxControllerDesc:: get_interaction_flag() const { return (ptr()->interactionFlag) ? true : false; } - diff --git a/panda/src/physx/physxControllerDesc.h b/panda/src/physx/physxControllerDesc.h index 43b35a7a2f..7919b60118 100644 --- a/panda/src/physx/physxControllerDesc.h +++ b/panda/src/physx/physxControllerDesc.h @@ -1,16 +1,15 @@ -// Filename: physxControllerDesc.h -// Created by: enn0x (22Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerDesc.h + * @author enn0x + * @date 2009-09-22 + */ #ifndef PHYSXCONTROLLERDESC_H #define PHYSXCONTROLLERDESC_H @@ -20,10 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxControllerDesc -// Description : Descriptor class for a character controller. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for a character controller. + */ class EXPCL_PANDAPHYSX PhysxControllerDesc { PUBLISHED: diff --git a/panda/src/physx/physxControllerReport.I b/panda/src/physx/physxControllerReport.I index fe8ef8d147..5fa057f572 100644 --- a/panda/src/physx/physxControllerReport.I +++ b/panda/src/physx/physxControllerReport.I @@ -1,58 +1,47 @@ -// Filename: physxControllerReport.I -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerReport.I + * @author enn0x + * @date 2009-09-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxControllerReport:: PhysxControllerReport() : NxUserControllerHitReport() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxControllerReport:: ~PhysxControllerReport() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::set_shape_callback -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxControllerReport:: set_shape_hit_callback(PT(CallbackObject) cbobj) { _shape_hit_cbobj = cbobj; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::set_shape_callback -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxControllerReport:: set_controller_hit_callback(PT(CallbackObject) cbobj) { _controller_hit_cbobj = cbobj; } - diff --git a/panda/src/physx/physxControllerReport.cxx b/panda/src/physx/physxControllerReport.cxx index 8ce216e8dc..dd6cfb225c 100644 --- a/panda/src/physx/physxControllerReport.cxx +++ b/panda/src/physx/physxControllerReport.cxx @@ -1,26 +1,23 @@ -// Filename: physxControllerReport.cxx -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerReport.cxx + * @author enn0x + * @date 2009-09-24 + */ #include "physxControllerReport.h" PStatCollector PhysxControllerReport::_pcollector("App:PhysX:Controller Reporting"); -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::enable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxControllerReport:: enable() { @@ -30,33 +27,27 @@ enable() { _controller_hit_cbobj = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::disable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxControllerReport:: disable() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::is_enabled -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxControllerReport:: is_enabled() const { return _enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::onShapeHit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxControllerAction PhysxControllerReport:: onShapeHit( const NxControllerShapeHit& hit ) { @@ -70,7 +61,7 @@ onShapeHit( const NxControllerShapeHit& hit ) { // Callback PhysxControllerShapeHit cbdata(hit); _shape_hit_cbobj->do_callback(&cbdata); - } + } else { // Default implementation if (1 && hit.shape) { @@ -90,11 +81,9 @@ onShapeHit( const NxControllerShapeHit& hit ) { return NX_ACTION_NONE; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerReport::onControllerHit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxControllerAction PhysxControllerReport:: onControllerHit(const NxControllersHit& hit) { @@ -108,12 +97,12 @@ onControllerHit(const NxControllersHit& hit) { // Callback PhysxControllersHit cbdata(hit); _controller_hit_cbobj->do_callback(&cbdata); - } + } else { // Default implementation if (1 && hit.other) { - // For now other controllers are unpushable. --TODO-- - //return NX_ACTION_PUSH; is not implemented! + // For now other controllers are unpushable. --TODO-- return + // NX_ACTION_PUSH; is not implemented! } } @@ -121,4 +110,3 @@ onControllerHit(const NxControllersHit& hit) { return NX_ACTION_NONE; } - diff --git a/panda/src/physx/physxControllerReport.h b/panda/src/physx/physxControllerReport.h index 7e49a73522..ae2b1808af 100644 --- a/panda/src/physx/physxControllerReport.h +++ b/panda/src/physx/physxControllerReport.h @@ -1,16 +1,15 @@ -// Filename: physxControllerReport.h -// Created by: enn0x (24Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerReport.h + * @author enn0x + * @date 2009-09-24 + */ #ifndef PHYSXCONTROLLERREPORT_H #define PHYSXCONTROLLERREPORT_H @@ -21,11 +20,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxControllerReport -// Description : Implementation of the NxUserControllerHitReport -// interface. -//////////////////////////////////////////////////////////////////// +/** + * Implementation of the NxUserControllerHitReport interface. + */ class EXPCL_PANDAPHYSX PhysxControllerReport : public NxUserControllerHitReport { public: diff --git a/panda/src/physx/physxControllerShapeHit.I b/panda/src/physx/physxControllerShapeHit.I index d3455126a4..a894ae013d 100644 --- a/panda/src/physx/physxControllerShapeHit.I +++ b/panda/src/physx/physxControllerShapeHit.I @@ -1,33 +1,28 @@ -// Filename: physxControllerShapeHit.I -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerShapeHit.I + * @author enn0x + * @date 2012-11-28 + */ -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxControllerShapeHit:: PhysxControllerShapeHit(const NxControllerShapeHit &hit) : _hit(hit) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_controller -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxController *PhysxControllerShapeHit:: get_controller() const { @@ -39,11 +34,9 @@ get_controller() const { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxShape *PhysxControllerShapeHit:: get_shape() const { @@ -55,47 +48,38 @@ get_shape() const { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_world_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LPoint3 PhysxControllerShapeHit:: get_world_pos() const { return PhysxManager::nxExtVec3_to_point3(_hit.worldPos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_world_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 PhysxControllerShapeHit:: get_world_normal() const { return PhysxManager::nxVec3_to_vec3(_hit.worldNormal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_dir -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LVector3 PhysxControllerShapeHit:: get_dir() const { return PhysxManager::nxVec3_to_vec3(_hit.dir); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllerShapeHit::get_length -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat PhysxControllerShapeHit:: get_length() const { return (PN_stdfloat)_hit.length; } - diff --git a/panda/src/physx/physxControllerShapeHit.cxx b/panda/src/physx/physxControllerShapeHit.cxx index b2e7dc3511..d00d66dc64 100644 --- a/panda/src/physx/physxControllerShapeHit.cxx +++ b/panda/src/physx/physxControllerShapeHit.cxx @@ -1,19 +1,16 @@ -// Filename: physxControllerShapeHit.cxx -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerShapeHit.cxx + * @author enn0x + * @date 2012-11-28 + */ #include "physxControllerShapeHit.h" TypeHandle PhysxControllerShapeHit::_type_handle; - - diff --git a/panda/src/physx/physxControllerShapeHit.h b/panda/src/physx/physxControllerShapeHit.h index d92c2b1d1a..b1af192007 100644 --- a/panda/src/physx/physxControllerShapeHit.h +++ b/panda/src/physx/physxControllerShapeHit.h @@ -1,16 +1,15 @@ -// Filename: physxControllerShapeHit.h -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllerShapeHit.h + * @author enn0x + * @date 2012-11-28 + */ #ifndef PHYSXCONTROLLERSHAPEHIT #define PHYSXCONTROLLERSHAPEHIT @@ -25,10 +24,9 @@ class PhysxController; class PhysxShape; -//////////////////////////////////////////////////////////////////// -// Class : PhysxControllerShapeHit -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxControllerShapeHit : public CallbackData { PUBLISHED: @@ -44,14 +42,13 @@ PUBLISHED: private: const NxControllerShapeHit &_hit; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { CallbackData::init_type(); - register_type(_type_handle, "PhysxControllerShapeHit", + register_type(_type_handle, "PhysxControllerShapeHit", CallbackData::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxControllersHit.I b/panda/src/physx/physxControllersHit.I index 124a23664a..74816e9159 100644 --- a/panda/src/physx/physxControllersHit.I +++ b/panda/src/physx/physxControllersHit.I @@ -1,33 +1,28 @@ -// Filename: physxControllersHit.I -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllersHit.I + * @author enn0x + * @date 2012-11-28 + */ -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllersHit::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxControllersHit:: PhysxControllersHit(const NxControllersHit &hit) : _hit(hit) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllersHit::get_controller -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxController *PhysxControllersHit:: get_controller() const { @@ -37,11 +32,9 @@ get_controller() const { return controller; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxControllersHit::get_other -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxController *PhysxControllersHit:: get_other() const { @@ -50,4 +43,3 @@ get_other() const { return other; } - diff --git a/panda/src/physx/physxControllersHit.cxx b/panda/src/physx/physxControllersHit.cxx index 123ecd2d89..88c468a224 100644 --- a/panda/src/physx/physxControllersHit.cxx +++ b/panda/src/physx/physxControllersHit.cxx @@ -1,19 +1,16 @@ -// Filename: physxControllersHit.cxx -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllersHit.cxx + * @author enn0x + * @date 2012-11-28 + */ #include "physxControllersHit.h" TypeHandle PhysxControllersHit::_type_handle; - - diff --git a/panda/src/physx/physxControllersHit.h b/panda/src/physx/physxControllersHit.h index def69fc96d..9538f7eb23 100644 --- a/panda/src/physx/physxControllersHit.h +++ b/panda/src/physx/physxControllersHit.h @@ -1,16 +1,15 @@ -// Filename: physxControllersHit.h -// Created by: enn0x (28Nov12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxControllersHit.h + * @author enn0x + * @date 2012-11-28 + */ #ifndef PHYSXCONTROLLERSHIT #define PHYSXCONTROLLERSHIT @@ -23,10 +22,9 @@ class PhysxController; -//////////////////////////////////////////////////////////////////// -// Class : PhysxControllersHit -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxControllersHit : public CallbackData { PUBLISHED: @@ -38,14 +36,13 @@ PUBLISHED: private: const NxControllersHit &_hit; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { CallbackData::init_type(); - register_type(_type_handle, "PhysxControllersHit", + register_type(_type_handle, "PhysxControllersHit", CallbackData::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxConvexForceFieldShape.I b/panda/src/physx/physxConvexForceFieldShape.I index a38be7ee2e..4ae8f37b1a 100644 --- a/panda/src/physx/physxConvexForceFieldShape.I +++ b/panda/src/physx/physxConvexForceFieldShape.I @@ -1,36 +1,28 @@ -// Filename: physxConvexForceFieldShape.I -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShape.I + * @author enn0x + * @date 2009-11-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexForceFieldShape:: PhysxConvexForceFieldShape() : PhysxForceFieldShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexForceFieldShape:: ~PhysxConvexForceFieldShape() { } - diff --git a/panda/src/physx/physxConvexForceFieldShape.cxx b/panda/src/physx/physxConvexForceFieldShape.cxx index 4e9582b450..406fabd878 100644 --- a/panda/src/physx/physxConvexForceFieldShape.cxx +++ b/panda/src/physx/physxConvexForceFieldShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxConvexForceFieldShape.cxx -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShape.cxx + * @author enn0x + * @date 2009-11-15 + */ #include "physxConvexForceFieldShape.h" #include "physxConvexForceFieldShapeDesc.h" TypeHandle PhysxConvexForceFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexForceFieldShape:: link(NxForceFieldShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxForceFieldShape *shapePtr) { group->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexForceFieldShape:: unlink() { @@ -50,16 +45,12 @@ unlink() { group->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxConvexForceFieldShape:: save_to_desc(PhysxConvexForceFieldShapeDesc &shapeDesc) const { nassertv(_error_type == ET_ok); _ptr->saveToDesc(shapeDesc._desc); } - diff --git a/panda/src/physx/physxConvexForceFieldShape.h b/panda/src/physx/physxConvexForceFieldShape.h index 75b267217a..6b39c23715 100644 --- a/panda/src/physx/physxConvexForceFieldShape.h +++ b/panda/src/physx/physxConvexForceFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxConvexForceFieldShape.h -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShape.h + * @author enn0x + * @date 2009-11-15 + */ #ifndef PHYSXCONVEXFORCEFIELDSHAPE_H #define PHYSXCONVEXFORCEFIELDSHAPE_H @@ -22,10 +21,9 @@ class PhysxConvexForceFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexForceFieldShape -// Description : A convex shaped region used to define force field. -//////////////////////////////////////////////////////////////////// +/** + * A convex shaped region used to define force field. + */ class EXPCL_PANDAPHYSX PhysxConvexForceFieldShape : public PhysxForceFieldShape { PUBLISHED: @@ -34,7 +32,6 @@ PUBLISHED: void save_to_desc(PhysxConvexForceFieldShapeDesc &shapeDesc) const; -//////////////////////////////////////////////////////////////////// public: INLINE NxForceFieldShape *ptr() const { return (NxForceFieldShape *)_ptr; }; @@ -44,14 +41,13 @@ public: private: NxConvexForceFieldShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxForceFieldShape::init_type(); - register_type(_type_handle, "PhysxConvexForceFieldShape", + register_type(_type_handle, "PhysxConvexForceFieldShape", PhysxForceFieldShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxConvexForceFieldShapeDesc.I b/panda/src/physx/physxConvexForceFieldShapeDesc.I index 05d5c83f26..3396efada6 100644 --- a/panda/src/physx/physxConvexForceFieldShapeDesc.I +++ b/panda/src/physx/physxConvexForceFieldShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxConvexForceFieldShapeDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShapeDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexForceFieldShapeDesc:: PhysxConvexForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexForceFieldShapeDesc:: ~PhysxConvexForceFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxConvexForceFieldShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxConvexForceFieldShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxConvexForceFieldShapeDesc.cxx b/panda/src/physx/physxConvexForceFieldShapeDesc.cxx index 3e8585795e..d6f47f1507 100644 --- a/panda/src/physx/physxConvexForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxConvexForceFieldShapeDesc.cxx @@ -1,29 +1,24 @@ -// Filename: physxConvexForceFieldShapeDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShapeDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxConvexForceFieldShapeDesc.h" #include "physxConvexMesh.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexForceFieldShapeDesc::set_mesh -// Access: Published -// Description: Sets the convex mesh for this force field shape. -//////////////////////////////////////////////////////////////////// +/** + * Sets the convex mesh for this force field shape. + */ void PhysxConvexForceFieldShapeDesc:: set_mesh(PhysxConvexMesh *mesh) { _desc.meshData = mesh->ptr(); } - - diff --git a/panda/src/physx/physxConvexForceFieldShapeDesc.h b/panda/src/physx/physxConvexForceFieldShapeDesc.h index e87543c48b..5a42a4b95b 100644 --- a/panda/src/physx/physxConvexForceFieldShapeDesc.h +++ b/panda/src/physx/physxConvexForceFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxConvexForceFieldShapeDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexForceFieldShapeDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXCONVEXFORCEFIELDSHAPEDESC_H #define PHYSXCONVEXFORCEFIELDSHAPEDESC_H @@ -22,10 +21,9 @@ class PhysxConvexMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexForceFieldShapeDesc -// Description : A descriptor for a convex force field shape. -//////////////////////////////////////////////////////////////////// +/** + * A descriptor for a convex force field shape. + */ class EXPCL_PANDAPHYSX PhysxConvexForceFieldShapeDesc : public PhysxForceFieldShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxConvexMesh.I b/panda/src/physx/physxConvexMesh.I index d1e466a32f..79d15bcb3f 100644 --- a/panda/src/physx/physxConvexMesh.I +++ b/panda/src/physx/physxConvexMesh.I @@ -1,59 +1,47 @@ -// Filename: physxConvexMesh.I -// Created by: enn0x (13Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMesh.I + * @author enn0x + * @date 2009-10-13 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexMesh:: PhysxConvexMesh() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexMesh:: ~PhysxConvexMesh() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxConvexMesh:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxConvexMesh:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxConvexMesh.cxx b/panda/src/physx/physxConvexMesh.cxx index bbaa073f08..85bc518d9e 100644 --- a/panda/src/physx/physxConvexMesh.cxx +++ b/panda/src/physx/physxConvexMesh.cxx @@ -1,27 +1,24 @@ -// Filename: physxConvexMesh.cxx -// Created by: enn0x (13Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMesh.cxx + * @author enn0x + * @date 2009-10-13 + */ #include "physxConvexMesh.h" #include "physxMeshPool.h" TypeHandle PhysxConvexMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexMesh:: link(NxConvexMesh *meshPtr) { @@ -31,11 +28,9 @@ link(NxConvexMesh *meshPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexMesh:: unlink() { @@ -44,11 +39,9 @@ unlink() { PhysxManager::get_global_ptr()->_convex_meshes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexMesh:: release() { @@ -61,11 +54,9 @@ release() { PhysxMeshPool::release_convex_mesh(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMesh::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxConvexMesh:: get_reference_count() const { @@ -73,4 +64,3 @@ get_reference_count() const { return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxConvexMesh.h b/panda/src/physx/physxConvexMesh.h index 062f108298..d5f4b55e67 100644 --- a/panda/src/physx/physxConvexMesh.h +++ b/panda/src/physx/physxConvexMesh.h @@ -1,16 +1,15 @@ -// Filename: physxConvexMesh.h -// Created by: enn0x (13Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMesh.h + * @author enn0x + * @date 2009-10-13 + */ #ifndef PHYSXCONVEXMESH_H #define PHYSXCONVEXMESH_H @@ -20,18 +19,15 @@ #include "physxObject.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexMesh -// Description : A Convex Mesh. Internally represented as a list of -// convex polygons. The number of polygons is -// limited to 256. -//////////////////////////////////////////////////////////////////// +/** + * A Convex Mesh. Internally represented as a list of convex polygons. The + * number of polygons is limited to 256. + */ class EXPCL_PANDAPHYSX PhysxConvexMesh : public PhysxObject { PUBLISHED: unsigned int get_reference_count() const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -50,14 +46,13 @@ public: private: NxConvexMesh *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxConvexMesh", + register_type(_type_handle, "PhysxConvexMesh", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxConvexMeshDesc.I b/panda/src/physx/physxConvexMeshDesc.I index 1ea501776a..fae24d3130 100644 --- a/panda/src/physx/physxConvexMeshDesc.I +++ b/panda/src/physx/physxConvexMeshDesc.I @@ -1,23 +1,19 @@ -// Filename: physxConvexMeshDesc.I -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMeshDesc.I + * @author enn0x + * @date 2009-10-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexMeshDesc:: PhysxConvexMeshDesc() { @@ -28,11 +24,9 @@ PhysxConvexMeshDesc() { _vertices = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexMeshDesc:: ~PhysxConvexMeshDesc() { @@ -41,14 +35,11 @@ INLINE PhysxConvexMeshDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxConvexMeshDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxConvexMeshDesc.cxx b/panda/src/physx/physxConvexMeshDesc.cxx index 265ec26e14..0e0cd09f6b 100644 --- a/panda/src/physx/physxConvexMeshDesc.cxx +++ b/panda/src/physx/physxConvexMeshDesc.cxx @@ -1,16 +1,15 @@ -// Filename: physxConvexMeshDesc.cxx -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMeshDesc.cxx + * @author enn0x + * @date 2009-10-11 + */ #include "physxConvexMeshDesc.h" #include "physxManager.h" @@ -19,19 +18,15 @@ #include "geomNode.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::set_num_vertices -// Access: Published -// Description: Sets the number of vertices to be stored within -// this convex mesh. The function allocates memory -// for the vertices, but it does not set any vertices. -// -// This method must be called before any calls to -// set_vertex are done! -// -// The number of vertices in a single convex mesh has -// to be smaller than 256. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of vertices to be stored within this convex mesh. The + * function allocates memory for the vertices, but it does not set any + * vertices. + * + * This method must be called before any calls to set_vertex are done! + * + * The number of vertices in a single convex mesh has to be smaller than 256. + */ void PhysxConvexMeshDesc:: set_num_vertices(unsigned int numVertices) { @@ -47,12 +42,10 @@ set_num_vertices(unsigned int numVertices) { _desc.points = _vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::set_vertex -// Access: Published -// Description: Sets a single vertex. You have to call the function -// set_num_vertices before you can call this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single vertex. You have to call the function set_num_vertices + * before you can call this function. + */ void PhysxConvexMeshDesc:: set_vertex(unsigned int idx, const LPoint3f &vert) { @@ -60,30 +53,23 @@ set_vertex(unsigned int idx, const LPoint3f &vert) { _vertices[idx] = PhysxManager::point3_to_nxVec3(vert); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::get_desc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const NxConvexMeshDesc &PhysxConvexMeshDesc:: get_desc() const { return _desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexMeshDesc::set_from_node_path -// Access: Published -// Description: A convenience method to set the mesh data from -// a NodePath in a single call. The method iterates -// over the NodePath geoms and collects data for -// the convex mesh. -// -// Do not use the following function when using this -// one: -// - set_num_vertices -// - set_vertex -//////////////////////////////////////////////////////////////////// +/** + * A convenience method to set the mesh data from a NodePath in a single call. + * The method iterates over the NodePath geoms and collects data for the + * convex mesh. + * + * Do not use the following function when using this one: - set_num_vertices - + * set_vertex + */ void PhysxConvexMeshDesc:: set_from_node_path(const NodePath &np) { @@ -127,4 +113,3 @@ set_from_node_path(const NodePath &np) { _desc.numVertices = numVertices; _desc.points = _vertices; } - diff --git a/panda/src/physx/physxConvexMeshDesc.h b/panda/src/physx/physxConvexMeshDesc.h index 413291da61..c1f62be8ba 100644 --- a/panda/src/physx/physxConvexMeshDesc.h +++ b/panda/src/physx/physxConvexMeshDesc.h @@ -1,16 +1,15 @@ -// Filename: physxConvexMeshDesc.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexMeshDesc.h + * @author enn0x + * @date 2009-10-11 + */ #ifndef PHYSXCONVEXMESHDESC_H #define PHYSXCONVEXMESHDESC_H @@ -21,10 +20,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexMeshDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxConvexMeshDesc { PUBLISHED: diff --git a/panda/src/physx/physxConvexShape.I b/panda/src/physx/physxConvexShape.I index db1dd53069..1540cbb7da 100644 --- a/panda/src/physx/physxConvexShape.I +++ b/panda/src/physx/physxConvexShape.I @@ -1,36 +1,28 @@ -// Filename: physxConvexShape.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShape.I + * @author enn0x + * @date 2009-10-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexShape:: PhysxConvexShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexShape:: ~PhysxConvexShape() { } - diff --git a/panda/src/physx/physxConvexShape.cxx b/panda/src/physx/physxConvexShape.cxx index 79599e658d..58d4a6c510 100644 --- a/panda/src/physx/physxConvexShape.cxx +++ b/panda/src/physx/physxConvexShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxConvexShape.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShape.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxConvexShape.h" #include "physxConvexShapeDesc.h" TypeHandle PhysxConvexShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexShape:: link(NxShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexShape:: unlink() { @@ -50,16 +45,12 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxConvexShape:: save_to_desc(PhysxConvexShapeDesc &shapeDesc) const { nassertv(_error_type == ET_ok); _ptr->saveToDesc(shapeDesc._desc); } - diff --git a/panda/src/physx/physxConvexShape.h b/panda/src/physx/physxConvexShape.h index c55f73ff3e..8ff196ae68 100644 --- a/panda/src/physx/physxConvexShape.h +++ b/panda/src/physx/physxConvexShape.h @@ -1,16 +1,15 @@ -// Filename: physxConvexShape.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShape.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXCONVEXSHAPE_H #define PHYSXCONVEXSHAPE_H @@ -22,11 +21,9 @@ class PhysxConvexShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexShape -// Description : A shapes which is used to represent an instance of -// an convex mesh. -//////////////////////////////////////////////////////////////////// +/** + * A shapes which is used to represent an instance of an convex mesh. + */ class EXPCL_PANDAPHYSX PhysxConvexShape : public PhysxShape { PUBLISHED: @@ -35,7 +32,6 @@ PUBLISHED: void save_to_desc(PhysxConvexShapeDesc &shapeDesc) const; -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -45,14 +41,13 @@ public: private: NxConvexShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxConvexShape", + register_type(_type_handle, "PhysxConvexShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxConvexShapeDesc.I b/panda/src/physx/physxConvexShapeDesc.I index e177f62c8a..60e025a3b6 100644 --- a/panda/src/physx/physxConvexShapeDesc.I +++ b/panda/src/physx/physxConvexShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxConvexShapeDesc.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShapeDesc.I + * @author enn0x + * @date 2009-10-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexShapeDesc:: PhysxConvexShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxConvexShapeDesc:: ~PhysxConvexShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxConvexShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxConvexShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxConvexShapeDesc.cxx b/panda/src/physx/physxConvexShapeDesc.cxx index 1d908aab52..89b4d0b9b5 100644 --- a/panda/src/physx/physxConvexShapeDesc.cxx +++ b/panda/src/physx/physxConvexShapeDesc.cxx @@ -1,29 +1,24 @@ -// Filename: physxConvexShapeDesc.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShapeDesc.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxConvexShapeDesc.h" #include "physxConvexMesh.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxConvexShapeDesc::set_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxConvexShapeDesc:: set_mesh(PhysxConvexMesh *mesh) { _desc.meshData = mesh->ptr(); } - - diff --git a/panda/src/physx/physxConvexShapeDesc.h b/panda/src/physx/physxConvexShapeDesc.h index bc04c505bd..456bcdce4b 100644 --- a/panda/src/physx/physxConvexShapeDesc.h +++ b/panda/src/physx/physxConvexShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxConvexShapeDesc.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxConvexShapeDesc.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXCONVEXSHAPEDESC_H #define PHYSXCONVEXSHAPEDESC_H @@ -22,10 +21,9 @@ class PhysxConvexMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxConvexShapeDesc -// Description : Descriptor class for PhysxConvexShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxConvexShape. + */ class EXPCL_PANDAPHYSX PhysxConvexShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxCylindricalJoint.I b/panda/src/physx/physxCylindricalJoint.I index 5ec371bbe5..92f5e58f3e 100644 --- a/panda/src/physx/physxCylindricalJoint.I +++ b/panda/src/physx/physxCylindricalJoint.I @@ -1,36 +1,28 @@ -// Filename: physxCylindricalJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCylindricalJoint:: PhysxCylindricalJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCylindricalJoint:: ~PhysxCylindricalJoint() { } - diff --git a/panda/src/physx/physxCylindricalJoint.cxx b/panda/src/physx/physxCylindricalJoint.cxx index 9e699dc648..2a2fbb22d3 100644 --- a/panda/src/physx/physxCylindricalJoint.cxx +++ b/panda/src/physx/physxCylindricalJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxCylindricalJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxCylindricalJoint.h" #include "physxCylindricalJointDesc.h" TypeHandle PhysxCylindricalJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCylindricalJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxCylindricalJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxCylindricalJoint:: save_to_desc(PhysxCylindricalJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxCylindricalJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxCylindricalJoint:: load_from_desc(const PhysxCylindricalJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxCylindricalJoint.h b/panda/src/physx/physxCylindricalJoint.h index bdb8ed1aa2..a7b4cbc2a4 100644 --- a/panda/src/physx/physxCylindricalJoint.h +++ b/panda/src/physx/physxCylindricalJoint.h @@ -1,16 +1,15 @@ -// Filename: physxCylindricalJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXCYLINDRICALJOINT_H #define PHYSXCYLINDRICALJOINT_H @@ -22,12 +21,10 @@ class PhysxCylindricalJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxCylindricalJoint -// Description : Cylindrical Joints permit relative translational -// movement between two bodies along an axis, and also -// relative rotation along the axis. -//////////////////////////////////////////////////////////////////// +/** + * Cylindrical Joints permit relative translational movement between two + * bodies along an axis, and also relative rotation along the axis. + */ class EXPCL_PANDAPHYSX PhysxCylindricalJoint : public PhysxJoint { PUBLISHED: @@ -37,7 +34,6 @@ PUBLISHED: void save_to_desc(PhysxCylindricalJointDesc &jointDesc) const; void load_from_desc(const PhysxCylindricalJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -47,14 +43,13 @@ public: private: NxCylindricalJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxCylindricalJoint", + register_type(_type_handle, "PhysxCylindricalJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxCylindricalJointDesc.I b/panda/src/physx/physxCylindricalJointDesc.I index 45d07794b5..1fd4d9eb9b 100644 --- a/panda/src/physx/physxCylindricalJointDesc.I +++ b/panda/src/physx/physxCylindricalJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxCylindricalJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCylindricalJointDesc:: PhysxCylindricalJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxCylindricalJointDesc:: ~PhysxCylindricalJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxCylindricalJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxCylindricalJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxCylindricalJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxCylindricalJointDesc.cxx b/panda/src/physx/physxCylindricalJointDesc.cxx index 1b1129b11d..699f3858c6 100644 --- a/panda/src/physx/physxCylindricalJointDesc.cxx +++ b/panda/src/physx/physxCylindricalJointDesc.cxx @@ -1,16 +1,14 @@ -// Filename: physxCylindricalJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxCylindricalJointDesc.h" - diff --git a/panda/src/physx/physxCylindricalJointDesc.h b/panda/src/physx/physxCylindricalJointDesc.h index 4046362016..9c382b90d3 100644 --- a/panda/src/physx/physxCylindricalJointDesc.h +++ b/panda/src/physx/physxCylindricalJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxCylindricalJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxCylindricalJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXCYLINDRICALJOINTDESC_H #define PHYSXCYLINDRICALJOINTDESC_H @@ -20,11 +19,9 @@ #include "physxJointDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxCylindricalJointDesc -// Description : Descriptor class for sliding joint. See -// PhysxCylindricalJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for sliding joint. See PhysxCylindricalJoint. + */ class EXPCL_PANDAPHYSX PhysxCylindricalJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxD6Joint.I b/panda/src/physx/physxD6Joint.I index 435bdfcbf3..3306488395 100644 --- a/panda/src/physx/physxD6Joint.I +++ b/panda/src/physx/physxD6Joint.I @@ -1,36 +1,28 @@ -// Filename: physxD6Joint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6Joint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxD6Joint:: PhysxD6Joint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxD6Joint:: ~PhysxD6Joint() { } - diff --git a/panda/src/physx/physxD6Joint.cxx b/panda/src/physx/physxD6Joint.cxx index 4e64b34459..d52f1cdae1 100644 --- a/panda/src/physx/physxD6Joint.cxx +++ b/panda/src/physx/physxD6Joint.cxx @@ -1,27 +1,24 @@ -// Filename: physxD6Joint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6Joint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxD6Joint.h" #include "physxD6JointDesc.h" TypeHandle PhysxD6Joint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxD6Joint:: save_to_desc(PhysxD6JointDesc &jointDesc) const { @@ -63,12 +55,9 @@ save_to_desc(PhysxD6JointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxD6Joint:: load_from_desc(const PhysxD6JointDesc &jointDesc) { @@ -76,11 +65,9 @@ load_from_desc(const PhysxD6JointDesc &jointDesc) { _ptr->loadFromDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::set_drive_angular_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: set_drive_angular_velocity(const LVector3f &v) { @@ -88,11 +75,9 @@ set_drive_angular_velocity(const LVector3f &v) { _ptr->setDriveAngularVelocity(PhysxManager::vec3_to_nxVec3(v)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::set_drive_linear_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: set_drive_linear_velocity(const LVector3f &v) { @@ -100,11 +85,9 @@ set_drive_linear_velocity(const LVector3f &v) { _ptr->setDriveLinearVelocity(PhysxManager::vec3_to_nxVec3(v)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::set_drive_orientation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: set_drive_orientation(const LQuaternionf &quat) { @@ -112,15 +95,12 @@ set_drive_orientation(const LQuaternionf &quat) { _ptr->setDriveOrientation(PhysxManager::quat_to_nxQuat(quat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6Joint::set_drive_position -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6Joint:: set_drive_position(const LPoint3f &pos) { nassertv(_error_type == ET_ok); _ptr->setDrivePosition(PhysxManager::point3_to_nxVec3(pos)); } - diff --git a/panda/src/physx/physxD6Joint.h b/panda/src/physx/physxD6Joint.h index 94afb52d01..56ad3ea24a 100644 --- a/panda/src/physx/physxD6Joint.h +++ b/panda/src/physx/physxD6Joint.h @@ -1,16 +1,15 @@ -// Filename: physxD6Joint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6Joint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXD6JOINT_H #define PHYSXD6JOINT_H @@ -22,14 +21,12 @@ class PhysxD6JointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxD6Joint -// Description : A D6 joint is a general constraint between two -// actors. It allows the user to individually define -// the linear and rotational degrees of freedom. It -// also allows the user to configure the joint with -// limits and driven degrees of freedom as they wish. -//////////////////////////////////////////////////////////////////// +/** + * A D6 joint is a general constraint between two actors. It allows the user + * to individually define the linear and rotational degrees of freedom. It + * also allows the user to configure the joint with limits and driven degrees + * of freedom as they wish. + */ class EXPCL_PANDAPHYSX PhysxD6Joint : public PhysxJoint { PUBLISHED: @@ -44,7 +41,6 @@ PUBLISHED: void set_drive_orientation(const LQuaternionf &quat); void set_drive_position(const LPoint3f &pos); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -54,14 +50,13 @@ public: private: NxD6Joint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxD6Joint", + register_type(_type_handle, "PhysxD6Joint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxD6JointDesc.I b/panda/src/physx/physxD6JointDesc.I index 42adf17589..fdcf297db3 100644 --- a/panda/src/physx/physxD6JointDesc.I +++ b/panda/src/physx/physxD6JointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxD6JointDesc.I -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6JointDesc.I + * @author enn0x + * @date 2009-10-01 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxD6JointDesc:: PhysxD6JointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxD6JointDesc:: ~PhysxD6JointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxD6JointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxD6JointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxD6JointDesc.cxx b/panda/src/physx/physxD6JointDesc.cxx index eab55c0f78..74b10a70d5 100644 --- a/panda/src/physx/physxD6JointDesc.cxx +++ b/panda/src/physx/physxD6JointDesc.cxx @@ -1,159 +1,132 @@ -// Filename: physxD6JointDesc.cxx -// Created by: enn0x (01Octp09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6JointDesc.cxx + * @author enn0x + * @date 2009-10-01 + */ #include "physxD6JointDesc.h" #include "physxManager.h" #include "physxJointDriveDesc.h" #include "physxJointLimitSoftDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_x_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_x_motion(PhysxD6JointMotion xMotion) { _desc.xMotion = (NxD6JointMotion)xMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_y_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_y_motion(PhysxD6JointMotion yMotion) { _desc.yMotion = (NxD6JointMotion)yMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_z_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_z_motion(PhysxD6JointMotion zMotion) { _desc.zMotion = (NxD6JointMotion)zMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_swing1_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_swing1_motion(PhysxD6JointMotion swing1Motion) { _desc.swing1Motion = (NxD6JointMotion)swing1Motion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_swing2_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_swing2_motion(PhysxD6JointMotion swing2Motion) { _desc.swing2Motion = (NxD6JointMotion)swing2Motion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_twist_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_twist_motion(PhysxD6JointMotion twistMotion) { _desc.twistMotion = (NxD6JointMotion)twistMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_x_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_x_drive(const PhysxJointDriveDesc &drive) { _desc.xDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_y_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_y_drive(const PhysxJointDriveDesc &drive) { _desc.yDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_z_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_z_drive(const PhysxJointDriveDesc &drive) { _desc.zDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_swing_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_swing_drive(const PhysxJointDriveDesc &drive) { _desc.swingDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_twist_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_twist_drive(const PhysxJointDriveDesc &drive) { _desc.twistDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_slerp_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_slerp_drive(const PhysxJointDriveDesc &drive) { _desc.slerpDrive = drive._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_flag -// Access: Published -// Description: Sets or clears a single D6JointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single D6JointFlag flag. + */ void PhysxD6JointDesc:: set_flag(PhysxD6JointFlag flag, bool value) { @@ -165,99 +138,81 @@ set_flag(PhysxD6JointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_linear_limit(const PhysxJointLimitSoftDesc &limit) { _desc.linearLimit = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_swing1_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_swing1_limit(const PhysxJointLimitSoftDesc &limit) { _desc.swing1Limit = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_swing2_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_swing2_limit(const PhysxJointLimitSoftDesc &limit) { _desc.swing2Limit = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_twist_limit_low -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_twist_limit_low(const PhysxJointLimitSoftDesc &limit) { _desc.twistLimit.low = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_twist_limit_high -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_twist_limit_high(const PhysxJointLimitSoftDesc &limit) { _desc.twistLimit.high = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_projection_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_projection_distance(float distance) { _desc.projectionDistance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_projection_angle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_projection_angle(float angle) { _desc.projectionAngle = angle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_gear_ratio -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_gear_ratio(float ratio) { _desc.gearRatio = ratio; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_drive_position -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_drive_position(const LPoint3f &pos) { @@ -265,11 +220,9 @@ set_drive_position(const LPoint3f &pos) { _desc.drivePosition = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_drive_linear_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_drive_linear_velocity(const LVector3f &v) { @@ -277,11 +230,9 @@ set_drive_linear_velocity(const LVector3f &v) { _desc.driveLinearVelocity = PhysxManager::vec3_to_nxVec3(v); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_drive_angular_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_drive_angular_velocity(const LVector3f &v) { @@ -289,100 +240,81 @@ set_drive_angular_velocity(const LVector3f &v) { _desc.driveAngularVelocity = PhysxManager::vec3_to_nxVec3(v); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_drive_orientation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxD6JointDesc:: set_drive_orientation(const LQuaternionf &quat) { _desc.driveOrientation = PhysxManager::quat_to_nxQuat(quat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::set_projection_mode -// Access: Published -// Description: Use this to enable joint projection. -// Default is PM_none. -//////////////////////////////////////////////////////////////////// +/** + * Use this to enable joint projection. Default is PM_none. + */ void PhysxD6JointDesc:: set_projection_mode(PhysxProjectionMode mode) { _desc.projectionMode = (NxJointProjectionMode)mode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_x_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_x_motion() const { return (PhysxD6JointMotion)_desc.xMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_y_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_y_motion() const { return (PhysxD6JointMotion)_desc.yMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_z_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_z_motion() const { return (PhysxD6JointMotion)_desc.zMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_swing1_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_swing1_motion() const { return (PhysxD6JointMotion)_desc.swing1Motion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_swing2_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_swing2_motion() const { return (PhysxD6JointMotion)_desc.swing2Motion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_twist_motion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc:: get_twist_motion() const { return (PhysxD6JointMotion)_desc.twistMotion; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_x_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_x_drive() const { @@ -391,11 +323,9 @@ get_x_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_y_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_y_drive() const { @@ -404,11 +334,9 @@ get_y_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_z_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_z_drive() const { @@ -417,11 +345,9 @@ get_z_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_swing_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_swing_drive() const { @@ -430,11 +356,9 @@ get_swing_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_twist_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_twist_drive() const { @@ -443,11 +367,9 @@ get_twist_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_slerp_drive -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointDriveDesc PhysxD6JointDesc:: get_slerp_drive() const { @@ -456,22 +378,18 @@ get_slerp_drive() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxD6JointDesc:: get_flag(PhysxD6JointFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_linear_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitSoftDesc PhysxD6JointDesc:: get_linear_limit() const { @@ -480,11 +398,9 @@ get_linear_limit() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_swing1_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitSoftDesc PhysxD6JointDesc:: get_swing1_limit() const { @@ -493,11 +409,9 @@ get_swing1_limit() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_swing2_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitSoftDesc PhysxD6JointDesc:: get_swing2_limit() const { @@ -506,11 +420,9 @@ get_swing2_limit() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_twist_limit_low -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitSoftDesc PhysxD6JointDesc:: get_twist_limit_low() const { @@ -519,11 +431,9 @@ get_twist_limit_low() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_twist_limit_high -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitSoftDesc PhysxD6JointDesc:: get_twist_limit_high() const { @@ -532,91 +442,74 @@ get_twist_limit_high() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_projection_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxD6JointDesc:: get_projection_distance() const { return _desc.projectionDistance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_projection_angle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxD6JointDesc:: get_projection_angle() const { return _desc.projectionAngle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_gear_ratio -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxD6JointDesc:: get_gear_ratio() const { return _desc.gearRatio; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_drive_position -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxD6JointDesc:: get_drive_position() const { return PhysxManager::nxVec3_to_point3(_desc.drivePosition); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_drive_linear_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxD6JointDesc:: get_drive_linear_velocity() const { return PhysxManager::nxVec3_to_vec3(_desc.driveLinearVelocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_drive_angular_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxD6JointDesc:: get_drive_angular_velocity() const { return PhysxManager::nxVec3_to_vec3(_desc.driveAngularVelocity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_drive_orientation -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LQuaternionf PhysxD6JointDesc:: get_drive_orientation() const { return PhysxManager::nxQuat_to_quat(_desc.driveOrientation); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxD6JointDesc::get_projection_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxProjectionMode PhysxD6JointDesc:: get_projection_mode() const { return (PhysxProjectionMode)_desc.projectionMode; } - diff --git a/panda/src/physx/physxD6JointDesc.h b/panda/src/physx/physxD6JointDesc.h index 5ff094c340..9273aa5b51 100644 --- a/panda/src/physx/physxD6JointDesc.h +++ b/panda/src/physx/physxD6JointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxD6JointDesc.h -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxD6JointDesc.h + * @author enn0x + * @date 2009-10-01 + */ #ifndef PHYSXD6JOINTDESC_H #define PHYSXD6JOINTDESC_H @@ -24,10 +23,9 @@ class PhysxJointDriveDesc; class PhysxJointLimitSoftDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxD6JointDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxD6JointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxDebugGeomNode.I b/panda/src/physx/physxDebugGeomNode.I index 283326be0e..699d7b550a 100644 --- a/panda/src/physx/physxDebugGeomNode.I +++ b/panda/src/physx/physxDebugGeomNode.I @@ -1,24 +1,19 @@ -// Filename: physxDebugGeomNode.I -// Created by: enn0x (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDebugGeomNode.I + * @author enn0x + * @date 2009-09-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDebugGeomNode:: PhysxDebugGeomNode() : GeomNode("debug") { @@ -45,365 +40,298 @@ PhysxDebugGeomNode() : GeomNode("debug") { this->add_geom(_geom_triangles); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDebugGeomNode:: ~PhysxDebugGeomNode() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_world_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_world_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_WORLD_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_body_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_body_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_BODY_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_body_mass_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_body_mass_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_BODY_MASS_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_body_lin_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_body_lin_velocity(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_BODY_LIN_VELOCITY, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_body_ang_velocity -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_body_ang_velocity(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_BODY_ANG_VELOCITY, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_body_joint_groups -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_body_joint_groups(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_BODY_JOINT_GROUPS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_joint_local_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_joint_local_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_joint_world_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_joint_world_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_JOINT_WORLD_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_joint_limits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_joint_limits(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_JOINT_LIMITS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_contact_point -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_contact_point(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CONTACT_POINT, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_contact_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_contact_normal(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CONTACT_NORMAL, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_contact_error -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_contact_error(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CONTACT_ERROR, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_contact_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_contact_force(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CONTACT_FORCE, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_actor_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_actor_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_ACTOR_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_aabbs -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_aabbs(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_AABBS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_shapes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_shapes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_SHAPES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_axes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_axes(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_AXES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_compounds -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_compounds(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_COMPOUNDS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_vnormals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_vnormals(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_VNORMALS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_fnormals -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_fnormals(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_FNORMALS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_edges -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_edges(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_EDGES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_spheres -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_spheres(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_SPHERES, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_static -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_static(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_STATIC, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_dynamic -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_dynamic(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_DYNAMIC, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_free -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_free(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_FREE, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_ccd -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_ccd(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_CCD, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_collision_skeletons -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_collision_skeletons(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_COLLISION_SKELETONS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_cloth_mesh(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CLOTH_MESH, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_cloth_validbounds -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_cloth_validbounds(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_CLOTH_VALIDBOUNDS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_softbody_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_softbody_mesh(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_SOFTBODY_MESH, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_softbody_validbounds -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_softbody_validbounds(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_SOFTBODY_VALIDBOUNDS, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::visualize_force_fields -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxDebugGeomNode:: visualize_force_fields(bool value) { NxGetPhysicsSDK()->setParameter(NX_VISUALIZE_FORCE_FIELDS, value); } - diff --git a/panda/src/physx/physxDebugGeomNode.cxx b/panda/src/physx/physxDebugGeomNode.cxx index d38fd9c163..a609fb2f3c 100644 --- a/panda/src/physx/physxDebugGeomNode.cxx +++ b/panda/src/physx/physxDebugGeomNode.cxx @@ -1,16 +1,15 @@ -// Filename: physxDebugGeomNode.cxx -// Created by: enn0x (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDebugGeomNode.cxx + * @author enn0x + * @date 2009-09-15 + */ #include "physxDebugGeomNode.h" @@ -19,11 +18,9 @@ TypeHandle PhysxDebugGeomNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::update -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDebugGeomNode:: update(NxScene *scenePtr) { @@ -106,33 +103,27 @@ update(NxScene *scenePtr) { physx_cat.spam() << "Updated PhysxDebugGeomNode geometry\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::on -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDebugGeomNode:: on() { NxGetPhysicsSDK()->setParameter(NX_VISUALIZATION_SCALE, _scale); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::off -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDebugGeomNode:: off() { NxGetPhysicsSDK()->setParameter(NX_VISUALIZATION_SCALE, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDebugGeomNode::toggle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDebugGeomNode:: toggle() { @@ -143,4 +134,3 @@ toggle() { off(); } } - diff --git a/panda/src/physx/physxDebugGeomNode.h b/panda/src/physx/physxDebugGeomNode.h index 87114cadb3..b3c2d67a18 100644 --- a/panda/src/physx/physxDebugGeomNode.h +++ b/panda/src/physx/physxDebugGeomNode.h @@ -1,16 +1,15 @@ -// Filename: physxDebugGeomNode.h -// Created by: enn0x (15Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDebugGeomNode.h + * @author enn0x + * @date 2009-09-15 + */ #ifndef PHYSXDEBUGGEOMNODE_H #define PHYSXDEBUGGEOMNODE_H @@ -28,12 +27,10 @@ class PhysxScene; -//////////////////////////////////////////////////////////////////// -// Class : PhysxDebugGeomNode -// Description : Renderable geometry which represents visualizations -// of physics objects. Intended to help with -// debugging code. -//////////////////////////////////////////////////////////////////// +/** + * Renderable geometry which represents visualizations of physics objects. + * Intended to help with debugging code. + */ class EXPCL_PANDAPHYSX PhysxDebugGeomNode : public GeomNode { PUBLISHED: @@ -89,14 +86,13 @@ private: PT(Geom) _geom_triangles; PT(GeomTriangles) _prim_triangles; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { GeomNode::init_type(); - register_type(_type_handle, "PhysxDebugGeomNode", + register_type(_type_handle, "PhysxDebugGeomNode", GeomNode::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxDistanceJoint.I b/panda/src/physx/physxDistanceJoint.I index 05e07a807f..dbc414413b 100644 --- a/panda/src/physx/physxDistanceJoint.I +++ b/panda/src/physx/physxDistanceJoint.I @@ -1,36 +1,28 @@ -// Filename: physxDistanceJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDistanceJoint:: PhysxDistanceJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDistanceJoint:: ~PhysxDistanceJoint() { } - diff --git a/panda/src/physx/physxDistanceJoint.cxx b/panda/src/physx/physxDistanceJoint.cxx index 9ab6a4a4a2..648821ce66 100644 --- a/panda/src/physx/physxDistanceJoint.cxx +++ b/panda/src/physx/physxDistanceJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxDistanceJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxDistanceJoint.h" #include "physxDistanceJointDesc.h" TypeHandle PhysxDistanceJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDistanceJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxDistanceJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxDistanceJoint:: save_to_desc(PhysxDistanceJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxDistanceJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxDistanceJoint:: load_from_desc(const PhysxDistanceJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxDistanceJoint.h b/panda/src/physx/physxDistanceJoint.h index 026c746484..a3be65fb03 100644 --- a/panda/src/physx/physxDistanceJoint.h +++ b/panda/src/physx/physxDistanceJoint.h @@ -1,16 +1,15 @@ -// Filename: physxDistanceJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXDISTANCEJOINT_H #define PHYSXDISTANCEJOINT_H @@ -22,11 +21,10 @@ class PhysxDistanceJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxDistanceJoint -// Description : A distance joint maintains a certain distance -// between two points on two actors. -//////////////////////////////////////////////////////////////////// +/** + * A distance joint maintains a certain distance between two points on two + * actors. + */ class EXPCL_PANDAPHYSX PhysxDistanceJoint : public PhysxJoint { PUBLISHED: @@ -36,7 +34,6 @@ PUBLISHED: void save_to_desc(PhysxDistanceJointDesc &jointDesc) const; void load_from_desc(const PhysxDistanceJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -46,14 +43,13 @@ public: private: NxDistanceJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxDistanceJoint", + register_type(_type_handle, "PhysxDistanceJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxDistanceJointDesc.I b/panda/src/physx/physxDistanceJointDesc.I index 0dc92b97a6..1fb6570661 100644 --- a/panda/src/physx/physxDistanceJointDesc.I +++ b/panda/src/physx/physxDistanceJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxDistanceJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDistanceJointDesc:: PhysxDistanceJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxDistanceJointDesc:: ~PhysxDistanceJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxDistanceJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxDistanceJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxDistanceJointDesc.cxx b/panda/src/physx/physxDistanceJointDesc.cxx index eb7e885b66..657dfa2347 100644 --- a/panda/src/physx/physxDistanceJointDesc.cxx +++ b/panda/src/physx/physxDistanceJointDesc.cxx @@ -1,61 +1,51 @@ -// Filename: physxDistanceJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxDistanceJointDesc.h" #include "physxSpringDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::set_max_distance -// Access: Published -// Description: Sets the maximum rest length of the rope or rod -// between the two anchor points. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum rest length of the rope or rod between the two anchor + * points. + */ void PhysxDistanceJointDesc:: set_max_distance(float distance) { _desc.maxDistance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::set_min_distance -// Access: Published -// Description: Sets the minimum rest length of the rope or rod -// between the two anchor points -//////////////////////////////////////////////////////////////////// +/** + * Sets the minimum rest length of the rope or rod between the two anchor + * points + */ void PhysxDistanceJointDesc:: set_min_distance(float distance) { _desc.minDistance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::set_spring -// Access: Published -// Description: Makes the joint springy. The spring.targetValue -// is not used. -//////////////////////////////////////////////////////////////////// +/** + * Makes the joint springy. The spring.targetValue is not used. + */ void PhysxDistanceJointDesc:: set_spring(const PhysxSpringDesc &spring) { _desc.spring = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::set_flag -// Access: Published -// Description: Sets or clears a single DistanceJointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single DistanceJointFlag flag. + */ void PhysxDistanceJointDesc:: set_flag(PhysxDistanceJointFlag flag, bool value) { @@ -67,33 +57,27 @@ set_flag(PhysxDistanceJointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::get_max_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxDistanceJointDesc:: get_max_distance() const { return _desc.maxDistance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::get_min_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxDistanceJointDesc:: get_min_distance() const { return _desc.minDistance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxDistanceJointDesc:: get_spring() const { @@ -102,14 +86,11 @@ get_spring() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxDistanceJointDesc::get_flag -// Access: Published -// Description: Return a single DistanceJointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Return a single DistanceJointFlag flag. + */ bool PhysxDistanceJointDesc:: get_flag(PhysxDistanceJointFlag flag) const { return (_desc.flags & flag) ? true : false; } - diff --git a/panda/src/physx/physxDistanceJointDesc.h b/panda/src/physx/physxDistanceJointDesc.h index 381055bc8f..6d74797a56 100644 --- a/panda/src/physx/physxDistanceJointDesc.h +++ b/panda/src/physx/physxDistanceJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxDistanceJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxDistanceJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXDISTANCEJOINTDESC_H #define PHYSXDISTANCEJOINTDESC_H @@ -22,11 +21,9 @@ class PhysxSpringDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxDistanceJointDesc -// Description : Descriptor class for distance joint. See -// PhysxDistanceJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for distance joint. See PhysxDistanceJoint. + */ class EXPCL_PANDAPHYSX PhysxDistanceJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxEnums.cxx b/panda/src/physx/physxEnums.cxx index b4cb8332dd..5b186445c2 100644 --- a/panda/src/physx/physxEnums.cxx +++ b/panda/src/physx/physxEnums.cxx @@ -1,16 +1,15 @@ -// Filename: physxEnums.cxx -// Created by: enn0x (23Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxEnums.cxx + * @author enn0x + * @date 2009-09-23 + */ #include "physxEnums.h" @@ -42,7 +41,7 @@ operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) { if (cmp_nocase(word, "x") == 0) { axis = PhysxEnums::X_up; - } + } else if (cmp_nocase(word, "y") == 0) { axis = PhysxEnums::Y_up; } @@ -57,4 +56,3 @@ operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis) { return in; } - diff --git a/panda/src/physx/physxEnums.h b/panda/src/physx/physxEnums.h index 2fe5e9c5d6..fb17ebb978 100644 --- a/panda/src/physx/physxEnums.h +++ b/panda/src/physx/physxEnums.h @@ -1,16 +1,15 @@ -// Filename: physxEnums.h -// Created by: enn0x (23Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxEnums.h + * @author enn0x + * @date 2009-09-23 + */ #ifndef PHYSXENUMS_H #define PHYSXENUMS_H @@ -119,7 +118,7 @@ #define NX_AF_FLUID_DISABLE_COLLISION 1<<3 #define NX_AF_CONTACT_MODIFICATION 1<<4 #define NX_AF_FORCE_CONE_FRICTION 1<<5 -#define NX_AF_USER_ACTOR_PAIR_FILTERING 1<<6 +#define NX_AF_USER_ACTOR_PAIR_FILTERING 1<<6 // PhysxBodyFlag #define NX_BF_DISABLE_GRAVITY 1<<0 @@ -170,8 +169,8 @@ #define NX_NOTIFY_ON_ROLL 1<<5 #define NX_NOTIFY_ON_SLIDE 1<<6 #define NX_NOTIFY_FORCES 1<<7 -#define NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD 1<<8 -#define NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD 1<<9 +#define NX_NOTIFY_ON_START_TOUCH_FORCE_THRESHOLD 1<<8 +#define NX_NOTIFY_ON_END_TOUCH_FORCE_THRESHOLD 1<<9 #define NX_NOTIFY_ON_TOUCH_FORCE_THRESHOLD 1<<10 #define NX_NOTIFY_CONTACT_MODIFICATION 1<<16 @@ -349,11 +348,10 @@ #define NX_WF_AFFECTED_BY_HANDBRAKE 1<<2 #define NX_WF_ACCELERATED 1<<3 -//////////////////////////////////////////////////////////////////// -// Class : PhysxEnums -// Description : This class exists just to provide scoping for the -// enums shared by PhysX classes. -//////////////////////////////////////////////////////////////////// +/** + * This class exists just to provide scoping for the enums shared by PhysX + * classes. + */ class EXPCL_PANDAPHYSX PhysxEnums { PUBLISHED: @@ -621,10 +619,11 @@ PUBLISHED: SF_force_cone_friction = NX_SF_FORCE_CONE_FRICTION, SF_sequential_primary = NX_SF_SEQUENTIAL_PRIMARY, SF_fluid_performance_hint = NX_SF_FLUID_PERFORMANCE_HINT, - //SF_alternative_fluid_triangle_collision = NX_SF_ALTERNATIVE_FLUID_TRIANGLE_COLLISION, - //SF_multithreaded_forcefield = NX_SF_MULTITHREADED_FORCEFIELD, - //SF_simulate_separate_thread = NX_SF_SIMULATE_SEPARATE_THREAD, - //SF_enable_multithread = NX_SF_ENABLE_MULTITHREAD, + // SF_alternative_fluid_triangle_collision = + // NX_SF_ALTERNATIVE_FLUID_TRIANGLE_COLLISION, SF_multithreaded_forcefield + // = NX_SF_MULTITHREADED_FORCEFIELD, SF_simulate_separate_thread = + // NX_SF_SIMULATE_SEPARATE_THREAD, SF_enable_multithread = + // NX_SF_ENABLE_MULTITHREAD, }; enum PhysxShapeFlag { @@ -672,7 +671,7 @@ PUBLISHED: enum PhysxShapesType { ST_static = NX_STATIC_SHAPES , ST_dynamic = NX_DYNAMIC_SHAPES , - ST_all = NX_ALL_SHAPES + ST_all = NX_ALL_SHAPES }; enum PhysxSphericalJointFlag { @@ -719,4 +718,3 @@ EXPCL_PANDAPHYSX ostream &operator << (ostream &out, PhysxEnums::PhysxUpAxis axi EXPCL_PANDAPHYSX istream &operator >> (istream &in, PhysxEnums::PhysxUpAxis &axis); #endif - diff --git a/panda/src/physx/physxFileStream.cxx b/panda/src/physx/physxFileStream.cxx index 6209e6d285..1f308ab410 100644 --- a/panda/src/physx/physxFileStream.cxx +++ b/panda/src/physx/physxFileStream.cxx @@ -1,16 +1,15 @@ -// Filename: physxFileStream.cxx -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFileStream.cxx + * @author enn0x + * @date 2009-10-11 + */ #include "physxFileStream.h" @@ -18,11 +17,9 @@ #include "virtualFileSystem.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(NULL), _vf(NULL), _in(NULL) { if (load) { @@ -34,22 +31,18 @@ PhysxFileStream::PhysxFileStream(const Filename &fn, bool load) : _fp(NULL), _vf } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxFileStream::~PhysxFileStream() { if (_fp) fclose(_fp); if (_vf) _vf->close_read_file(_in); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readByte -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU8 PhysxFileStream::readByte() const { NxU8 b; @@ -58,11 +51,9 @@ NxU8 PhysxFileStream::readByte() const return b; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readWord -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU16 PhysxFileStream::readWord() const { NxU16 w; @@ -71,11 +62,9 @@ NxU16 PhysxFileStream::readWord() const return w; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readDword -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU32 PhysxFileStream::readDword() const { NxU32 d; @@ -84,11 +73,9 @@ NxU32 PhysxFileStream::readDword() const return d; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readFloat -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxFileStream::readFloat() const { NxReal f; @@ -97,11 +84,9 @@ float PhysxFileStream::readFloat() const return f; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readDouble -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double PhysxFileStream::readDouble() const { NxF64 f; @@ -110,22 +95,18 @@ double PhysxFileStream::readDouble() const return f; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::readBuffer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxFileStream::readBuffer(void *buffer, NxU32 size) const { _in->read((char *)buffer, size); NX_ASSERT(!(_in->bad())); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeByte -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeByte(NxU8 b) { size_t w = fwrite(&b, sizeof(NxU8), 1, _fp); @@ -133,11 +114,9 @@ NxStream &PhysxFileStream::storeByte(NxU8 b) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeWord -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeWord(NxU16 w) { size_t ww = fwrite(&w, sizeof(NxU16), 1, _fp); @@ -145,11 +124,9 @@ NxStream &PhysxFileStream::storeWord(NxU16 w) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeDword -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeDword(NxU32 d) { size_t w = fwrite(&d, sizeof(NxU32), 1, _fp); @@ -157,11 +134,9 @@ NxStream &PhysxFileStream::storeDword(NxU32 d) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeFloat -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeFloat(NxReal f) { size_t w = fwrite(&f, sizeof(NxReal), 1, _fp); @@ -169,11 +144,9 @@ NxStream &PhysxFileStream::storeFloat(NxReal f) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeDouble -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeDouble(NxF64 f) { size_t w = fwrite(&f, sizeof(NxF64), 1, _fp); @@ -181,15 +154,12 @@ NxStream &PhysxFileStream::storeDouble(NxF64 f) return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFileStream::storeBuffer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxFileStream::storeBuffer(const void *buffer, NxU32 size) { size_t w = fwrite(buffer, size, 1, _fp); NX_ASSERT(w); return *this; } - diff --git a/panda/src/physx/physxFileStream.h b/panda/src/physx/physxFileStream.h index ea27272819..a8cc858b1b 100644 --- a/panda/src/physx/physxFileStream.h +++ b/panda/src/physx/physxFileStream.h @@ -1,16 +1,15 @@ -// Filename: physxFileStream.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFileStream.h + * @author enn0x + * @date 2009-10-11 + */ #ifndef PHYSXFILESTREAM_H #define PHYSXFILESTREAM_H @@ -21,10 +20,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxFileStream -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxFileStream : public NxStream { public: diff --git a/panda/src/physx/physxFixedJoint.I b/panda/src/physx/physxFixedJoint.I index 489f30e98f..e19b8e494c 100644 --- a/panda/src/physx/physxFixedJoint.I +++ b/panda/src/physx/physxFixedJoint.I @@ -1,36 +1,28 @@ -// Filename: physxFixedJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxFixedJoint:: PhysxFixedJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxFixedJoint:: ~PhysxFixedJoint() { } - diff --git a/panda/src/physx/physxFixedJoint.cxx b/panda/src/physx/physxFixedJoint.cxx index d11277c472..49b5265923 100644 --- a/panda/src/physx/physxFixedJoint.cxx +++ b/panda/src/physx/physxFixedJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxFixedJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxFixedJoint.h" #include "physxFixedJointDesc.h" TypeHandle PhysxFixedJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxFixedJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxFixedJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxFixedJoint:: save_to_desc(PhysxFixedJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxFixedJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxFixedJoint:: load_from_desc(const PhysxFixedJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxFixedJoint.h b/panda/src/physx/physxFixedJoint.h index 6a76decd75..75b409452f 100644 --- a/panda/src/physx/physxFixedJoint.h +++ b/panda/src/physx/physxFixedJoint.h @@ -1,16 +1,15 @@ -// Filename: physxFixedJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXFIXEDJOINT_H #define PHYSXFIXEDJOINT_H @@ -22,11 +21,10 @@ class PhysxFixedJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxFixedJoint -// Description : A fixed joint permits no relative movement between -// two bodies. ie the bodies are glued together. -//////////////////////////////////////////////////////////////////// +/** + * A fixed joint permits no relative movement between two bodies. ie the + * bodies are glued together. + */ class EXPCL_PANDAPHYSX PhysxFixedJoint : public PhysxJoint { PUBLISHED: @@ -36,7 +34,6 @@ PUBLISHED: void save_to_desc(PhysxFixedJointDesc &jointDesc) const; void load_from_desc(const PhysxFixedJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -46,14 +43,13 @@ public: private: NxFixedJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxFixedJoint", + register_type(_type_handle, "PhysxFixedJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxFixedJointDesc.I b/panda/src/physx/physxFixedJointDesc.I index acf448375e..58dcf5b03b 100644 --- a/panda/src/physx/physxFixedJointDesc.I +++ b/panda/src/physx/physxFixedJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxFixedJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxFixedJointDesc:: PhysxFixedJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxFixedJointDesc:: ~PhysxFixedJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxFixedJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxFixedJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxFixedJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxFixedJointDesc.cxx b/panda/src/physx/physxFixedJointDesc.cxx index 0953b3464e..62d3cc3458 100644 --- a/panda/src/physx/physxFixedJointDesc.cxx +++ b/panda/src/physx/physxFixedJointDesc.cxx @@ -1,16 +1,14 @@ -// Filename: physxFixedJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxFixedJointDesc.h" - diff --git a/panda/src/physx/physxFixedJointDesc.h b/panda/src/physx/physxFixedJointDesc.h index 2b5226755c..337f62b39d 100644 --- a/panda/src/physx/physxFixedJointDesc.h +++ b/panda/src/physx/physxFixedJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxFixedJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxFixedJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXFIXEDJOINTDESC_H #define PHYSXFIXEDJOINTDESC_H @@ -20,12 +19,10 @@ #include "physxJointDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxFixedJointDesc -// Description : Descriptor class for fixed joint. A fixed joint -// permits no relative movement between two bodies, -// i. e. the bodies are glued together. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for fixed joint. A fixed joint permits no relative + * movement between two bodies, i. e. the bodies are glued together. + */ class EXPCL_PANDAPHYSX PhysxFixedJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxForceField.I b/panda/src/physx/physxForceField.I index 4c2573ea40..8a1bf87034 100644 --- a/panda/src/physx/physxForceField.I +++ b/panda/src/physx/physxForceField.I @@ -1,55 +1,44 @@ -// Filename: physxForceField.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceField.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceField:: PhysxForceField() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceField:: ~PhysxForceField() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceField:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceField:: ls(ostream &out, int indent_level) const { @@ -57,4 +46,3 @@ ls(ostream &out, int indent_level) const { << " " << _name << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxForceField.cxx b/panda/src/physx/physxForceField.cxx index 67fcd1d033..eada698729 100644 --- a/panda/src/physx/physxForceField.cxx +++ b/panda/src/physx/physxForceField.cxx @@ -1,16 +1,15 @@ -// Filename: physxForceField.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceField.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxForceField.h" #include "physxForceFieldDesc.h" @@ -19,11 +18,9 @@ TypeHandle PhysxForceField::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceField:: link(NxForceField *fieldPtr) { @@ -42,11 +39,9 @@ link(NxForceField *fieldPtr) { group->link(&(_ptr->getIncludeShapeGroup())); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceField:: unlink() { @@ -62,11 +57,9 @@ unlink() { scene->_forcefields.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceField:: release() { @@ -77,11 +70,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceField:: set_name(const char *name) { @@ -91,11 +82,9 @@ set_name(const char *name) { _ptr->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxForceField:: get_name() const { @@ -103,11 +92,9 @@ get_name() const { return _ptr->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::get_scene -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxScene *PhysxForceField:: get_scene() const { @@ -115,11 +102,9 @@ get_scene() const { return (PhysxScene *)(_ptr->getScene().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::get_include_shape_group -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxForceFieldShapeGroup *PhysxForceField:: get_include_shape_group() const { @@ -127,11 +112,9 @@ get_include_shape_group() const { return (PhysxForceFieldShapeGroup *)(_ptr->getIncludeShapeGroup().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::get_num_shape_groups -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxForceField:: get_num_shape_groups() const { @@ -139,11 +122,9 @@ get_num_shape_groups() const { return _ptr->getNbShapeGroups(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceField::get_shape_group -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxForceFieldShapeGroup *PhysxForceField:: get_shape_group(unsigned int idx) const { @@ -160,4 +141,3 @@ get_shape_group(unsigned int idx) const { return (PhysxForceFieldShapeGroup *)(groupPtr->userData); } - diff --git a/panda/src/physx/physxForceField.h b/panda/src/physx/physxForceField.h index e59ec2124d..ca9f068795 100644 --- a/panda/src/physx/physxForceField.h +++ b/panda/src/physx/physxForceField.h @@ -1,16 +1,15 @@ -// Filename: physxForceField.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceField.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXFORCEFIELD_H #define PHYSXFORCEFIELD_H @@ -25,23 +24,20 @@ class PhysxScene; class PhysxForceFieldDesc; class PhysxForceFieldShapeGroup; -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceField -// Description : A force field effector. Instances of this object -// automate the application of forces onto rigid -// bodies, fluid, soft bodies and cloth. -// Force fields allow you to implement for example -// gusts of wind, dust devils, vacuum cleaners or -// anti-gravity zones. -//////////////////////////////////////////////////////////////////// +/** + * A force field effector. Instances of this object automate the application + * of forces onto rigid bodies, fluid, soft bodies and cloth. Force fields + * allow you to implement for example gusts of wind, dust devils, vacuum + * cleaners or anti-gravity zones. + */ class EXPCL_PANDAPHYSX PhysxForceField : public PhysxObject { PUBLISHED: INLINE PhysxForceField(); INLINE ~PhysxForceField(); - //void load_from_desc(const PhysxForceFieldDesc &materialDesc); - //void save_to_desc(PhysxForceFieldDesc &materialDesc) const; + // void load_from_desc(const PhysxForceFieldDesc &materialDesc); void + // save_to_desc(PhysxForceFieldDesc &materialDesc) const; void set_name(const char *name); @@ -53,7 +49,6 @@ PUBLISHED: PhysxForceFieldShapeGroup *get_shape_group(unsigned int idx) const; MAKE_SEQ(get_shape_groups, get_num_shape_groups, get_shape_group); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -70,14 +65,13 @@ private: NxForceField *_ptr; string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxForceField", + register_type(_type_handle, "PhysxForceField", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxForceFieldDesc.I b/panda/src/physx/physxForceFieldDesc.I index 49f5232c1c..3ccdc80214 100644 --- a/panda/src/physx/physxForceFieldDesc.I +++ b/panda/src/physx/physxForceFieldDesc.I @@ -1,44 +1,35 @@ -// Filename: physxForceFieldDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldDesc:: PhysxForceFieldDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldDesc:: ~PhysxForceFieldDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxForceFieldDesc:: set_to_default() { @@ -46,14 +37,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxForceFieldDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxForceFieldDesc.cxx b/panda/src/physx/physxForceFieldDesc.cxx index da7a0d5213..4f8bd1b428 100644 --- a/panda/src/physx/physxForceFieldDesc.cxx +++ b/panda/src/physx/physxForceFieldDesc.cxx @@ -1,16 +1,15 @@ -// Filename: physxForceFieldDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxForceFieldDesc.h" #include "physxForceFieldShapeDesc.h" @@ -18,11 +17,9 @@ #include "physxManager.h" #include "physxActor.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_name(const char *name) { @@ -30,33 +27,27 @@ set_name(const char *name) { _desc.name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_pos(const LPoint3f &pos) { _desc.pose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_mat(const LMatrix4f &mat) { _desc.pose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_hpr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_hpr(float h, float p, float r) { @@ -70,157 +61,128 @@ set_hpr(float h, float p, float r) { _desc.pose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_constant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_constant(const LVector3f &constant) { _kernel.constant = PhysxManager::vec3_to_nxVec3(constant); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_position_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_position_target(const LPoint3f &target) { _kernel.positionTarget = PhysxManager::point3_to_nxVec3(target); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_velocity_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_velocity_target(const LVector3f &target) { _kernel.velocityTarget = PhysxManager::vec3_to_nxVec3(target); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_torus_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_torus_radius(float radius) { _kernel.torusRadius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_falloff_linear -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_falloff_linear(const LVector3f &falloff) { _kernel.falloffLinear = PhysxManager::vec3_to_nxVec3(falloff); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_falloff_quadratic -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_falloff_quadratic(const LVector3f &falloff) { _kernel.falloffQuadratic = PhysxManager::vec3_to_nxVec3(falloff); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_noise -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_noise(const LVector3f &noise) { _kernel.noise = PhysxManager::vec3_to_nxVec3(noise); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_position_multiplier -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_position_multiplier(const LMatrix3f &multiplier) { _kernel.positionMultiplier = PhysxManager::mat3_to_nxMat33(multiplier); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_kernel_velocity_multiplier -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_kernel_velocity_multiplier(const LMatrix3f &multiplier) { _kernel.velocityMultiplier = PhysxManager::mat3_to_nxMat33(multiplier); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::create_kernel -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: create_kernel(NxScene *scenePtr) { _desc.kernel = scenePtr->createForceFieldLinearKernel(_kernel); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_coordinates -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_coordinates(PhysxForceFieldCoordinates coordinates) { _desc.coordinates = (NxForceFieldCoordinates) coordinates; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::add_include_group_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: add_include_group_shape(PhysxForceFieldShapeDesc &desc) { _desc.includeGroupShapes.push_back(desc.ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::add_shape_group -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: add_shape_group(PhysxForceFieldShapeGroup *group) { _desc.shapeGroups.push_back(group->ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldDesc::set_actor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldDesc:: set_actor(PhysxActor *actor) { _desc.actor = actor->ptr(); } - diff --git a/panda/src/physx/physxForceFieldDesc.h b/panda/src/physx/physxForceFieldDesc.h index 7a2327e40c..accacf961e 100644 --- a/panda/src/physx/physxForceFieldDesc.h +++ b/panda/src/physx/physxForceFieldDesc.h @@ -1,16 +1,15 @@ -// Filename: physxForceFieldDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXFORCEFIELDDESC_H #define PHYSXFORCEFIELDDESC_H @@ -25,10 +24,9 @@ class PhysxActor; class PhysxForceFieldShapeDesc; class PhysxForceFieldShapeGroup; -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceFieldDesc -// Description : Descriptor class for force fields. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for force fields. + */ class EXPCL_PANDAPHYSX PhysxForceFieldDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxForceFieldShape.I b/panda/src/physx/physxForceFieldShape.I index 9fa850d831..1dd06f5fe8 100644 --- a/panda/src/physx/physxForceFieldShape.I +++ b/panda/src/physx/physxForceFieldShape.I @@ -1,45 +1,36 @@ -// Filename: physxForceFieldShape.I -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShape.I + * @author enn0x + * @date 2009-11-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShape:: PhysxForceFieldShape() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceFieldShape:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceFieldShape:: ls(ostream &out, int indent_level) const { @@ -47,4 +38,3 @@ ls(ostream &out, int indent_level) const { << " " << _name << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxForceFieldShape.cxx b/panda/src/physx/physxForceFieldShape.cxx index 01bfc23873..a0a2d1b931 100644 --- a/panda/src/physx/physxForceFieldShape.cxx +++ b/panda/src/physx/physxForceFieldShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShape.cxx -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShape.cxx + * @author enn0x + * @date 2009-11-15 + */ #include "physxForceFieldShape.h" #include "physxForceFieldShapeGroup.h" @@ -23,11 +22,9 @@ TypeHandle PhysxForceFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShape:: release() { @@ -37,11 +34,9 @@ release() { ptr()->getShapeGroup().releaseShape(*ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::factory -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxForceFieldShape *PhysxForceFieldShape:: factory(NxShapeType shapeType) { @@ -64,12 +59,10 @@ factory(NxShapeType shapeType) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::get_force_field -// Access: Published -// Description: Returns the owning force field if this is a shape -// of an include group, else NULL will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the owning force field if this is a shape of an include group, else + * NULL will be returned. + */ PhysxForceField *PhysxForceFieldShape:: get_force_field() const { @@ -82,11 +75,9 @@ get_force_field() const { return (PhysxForceField *)(fieldPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::get_shape_group -// Access: Published -// Description: Returns the owning force field shape group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the owning force field shape group. + */ PhysxForceFieldShapeGroup *PhysxForceFieldShape:: get_shape_group() const { @@ -94,12 +85,10 @@ get_shape_group() const { return (PhysxForceFieldShapeGroup *)(ptr()->getShapeGroup().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::set_name -// Access: Published -// Description: Sets a name string for this object. The name can -// be retrieved again with get_name(). -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for this object. The name can be retrieved again with + * get_name(). + */ void PhysxForceFieldShape:: set_name(const char *name) { @@ -109,11 +98,9 @@ set_name(const char *name) { ptr()->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::get_name -// Access: Published -// Description: Returns the name string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name string. + */ const char *PhysxForceFieldShape:: get_name() const { @@ -121,11 +108,9 @@ get_name() const { return ptr()->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::set_mat -// Access: Published -// Description: Sets the force field shape's transform. -//////////////////////////////////////////////////////////////////// +/** + * Sets the force field shape's transform. + */ void PhysxForceFieldShape:: set_mat(const LMatrix4f &mat) { @@ -134,11 +119,9 @@ set_mat(const LMatrix4f &mat) { ptr()->setPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::get_mat -// Access: Published -// Description: Returns the force field shape's transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the force field shape's transform. + */ LMatrix4f PhysxForceFieldShape:: get_mat() const { @@ -147,11 +130,9 @@ get_mat() const { return PhysxManager::nxMat34_to_mat4(ptr()->getPose()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::set_pos -// Access: Published -// Description: Sets the force field shape's translation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the force field shape's translation. + */ void PhysxForceFieldShape:: set_pos(const LPoint3f &pos) { @@ -162,11 +143,9 @@ set_pos(const LPoint3f &pos) { ptr()->setPose(pose); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShape::get_pos -// Access: Published -// Description: Returns the force field shape's translation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the force field shape's translation. + */ LPoint3f PhysxForceFieldShape:: get_pos() const { @@ -174,4 +153,3 @@ get_pos() const { return PhysxManager::nxVec3_to_point3(ptr()->getPose().t); } - diff --git a/panda/src/physx/physxForceFieldShape.h b/panda/src/physx/physxForceFieldShape.h index c7c86c34cf..e9e47cf510 100644 --- a/panda/src/physx/physxForceFieldShape.h +++ b/panda/src/physx/physxForceFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShape.h -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShape.h + * @author enn0x + * @date 2009-11-15 + */ #ifndef PHYSXFORCEFIELDSHAPE_H #define PHYSXFORCEFIELDSHAPE_H @@ -26,10 +25,9 @@ class PhysxForceField; class PhysxForceFieldShapeGroup; -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceFieldShape -// Description : Abstract base class for force field shapes. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for force field shapes. + */ class EXPCL_PANDAPHYSX PhysxForceFieldShape : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -63,14 +61,13 @@ protected: private: string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxForceFieldShape", + register_type(_type_handle, "PhysxForceFieldShape", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxForceFieldShapeDesc.I b/panda/src/physx/physxForceFieldShapeDesc.I index 21fe45e63c..f763262bdc 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.I +++ b/panda/src/physx/physxForceFieldShapeDesc.I @@ -1,36 +1,28 @@ -// Filename: physxForceFieldShapeDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeDesc:: PhysxForceFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeDesc:: ~PhysxForceFieldShapeDesc() { } - diff --git a/panda/src/physx/physxForceFieldShapeDesc.cxx b/panda/src/physx/physxForceFieldShapeDesc.cxx index 907be87762..4ac5f94cb8 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeDesc.cxx @@ -1,25 +1,22 @@ -// Filename: physxForceFieldShapeDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxForceFieldShapeDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::set_name -// Access: Published -// Description: Sets a possible debug name. -//////////////////////////////////////////////////////////////////// +/** + * Sets a possible debug name. + */ void PhysxForceFieldShapeDesc:: set_name(const char *name) { @@ -27,11 +24,9 @@ set_name(const char *name) { ptr()->name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::set_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShapeDesc:: set_pos(const LPoint3f &pos) { @@ -39,11 +34,9 @@ set_pos(const LPoint3f &pos) { ptr()->pose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::set_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShapeDesc:: set_mat(const LMatrix4f &mat) { @@ -51,11 +44,9 @@ set_mat(const LMatrix4f &mat) { ptr()->pose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::set_hpr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShapeDesc:: set_hpr(float h, float p, float r) { @@ -69,36 +60,29 @@ set_hpr(float h, float p, float r) { ptr()->pose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxForceFieldShapeDesc:: get_name() const { return ptr()->name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::get_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxForceFieldShapeDesc:: get_pos() const { return PhysxManager::nxVec3_to_point3(ptr()->pose.t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeDesc::get_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4f PhysxForceFieldShapeDesc:: get_mat() const { return PhysxManager::nxMat34_to_mat4(ptr()->pose); } - diff --git a/panda/src/physx/physxForceFieldShapeDesc.h b/panda/src/physx/physxForceFieldShapeDesc.h index 06ca832a1f..1071f9dddc 100644 --- a/panda/src/physx/physxForceFieldShapeDesc.h +++ b/panda/src/physx/physxForceFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShapeDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXFORCEFIELDSHAPEDESC_H #define PHYSXFORCEFIELDSHAPEDESC_H @@ -20,11 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceFieldShapeDesc -// Description : Abstract base class for descriptors for force -// field shapes descriptors. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for descriptors for force field shapes descriptors. + */ class EXPCL_PANDAPHYSX PhysxForceFieldShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxForceFieldShapeGroup.I b/panda/src/physx/physxForceFieldShapeGroup.I index 3c4b65453e..324b56b396 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.I +++ b/panda/src/physx/physxForceFieldShapeGroup.I @@ -1,55 +1,44 @@ -// Filename: physxForceFieldShapeGroup.I -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroup.I + * @author enn0x + * @date 2009-11-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeGroup:: PhysxForceFieldShapeGroup() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeGroup:: ~PhysxForceFieldShapeGroup() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceFieldShapeGroup:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxForceFieldShapeGroup:: ls(ostream &out, int indent_level) const { @@ -59,4 +48,3 @@ ls(ostream &out, int indent_level) const { _shapes.ls(out, indent_level); } - diff --git a/panda/src/physx/physxForceFieldShapeGroup.cxx b/panda/src/physx/physxForceFieldShapeGroup.cxx index d47cc9f785..c0bb56b93d 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.cxx +++ b/panda/src/physx/physxForceFieldShapeGroup.cxx @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShapeGroup.cxx -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroup.cxx + * @author enn0x + * @date 2009-11-11 + */ #include "physxForceFieldShapeGroup.h" #include "physxForceFieldShapeGroupDesc.h" @@ -19,11 +18,9 @@ TypeHandle PhysxForceFieldShapeGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShapeGroup:: link(NxForceFieldShapeGroup *groupPtr) { @@ -47,11 +44,9 @@ link(NxForceFieldShapeGroup *groupPtr) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxForceFieldShapeGroup:: unlink() { @@ -72,11 +67,9 @@ unlink() { scene->_ffgroups.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::release -// Access: Published -// Description: Releases the force field shape. -//////////////////////////////////////////////////////////////////// +/** + * Releases the force field shape. + */ void PhysxForceFieldShapeGroup:: release() { @@ -87,12 +80,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::get_scene -// Access: Published -// Description: Returns the scene that owns this force field shape -// group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene that owns this force field shape group. + */ PhysxScene *PhysxForceFieldShapeGroup:: get_scene() const { @@ -100,12 +90,10 @@ get_scene() const { return (PhysxScene *)(_ptr->getScene().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::get_force_field -// Access: Published -// Description: Returns the force field of this group if this is -// an include group. If not NULL will be returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the force field of this group if this is an include group. If not + * NULL will be returned. + */ PhysxForceField *PhysxForceFieldShapeGroup:: get_force_field() const { @@ -119,12 +107,9 @@ get_force_field() const { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::save_to_desc -// Access: Published -// Description: Saves the state of the force field shape group -// object to a descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the force field shape group object to a descriptor. + */ void PhysxForceFieldShapeGroup:: save_to_desc(PhysxForceFieldShapeGroupDesc &groupDesc) const { @@ -132,14 +117,10 @@ save_to_desc(PhysxForceFieldShapeGroupDesc &groupDesc) const { _ptr->saveToDesc(groupDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::set_name -// Access: Published -// Description: Sets a name string for the object that can be -// retrieved with get_name(). -// This is for debugging and is not used by the -// engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for the object that can be retrieved with get_name(). + * This is for debugging and is not used by the engine. + */ void PhysxForceFieldShapeGroup:: set_name(const char *name) { @@ -149,11 +130,9 @@ set_name(const char *name) { _ptr->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::get_name -// Access: Published -// Description: Returns the name string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name string. + */ const char *PhysxForceFieldShapeGroup:: get_name() const { @@ -161,12 +140,9 @@ get_name() const { return _ptr->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::get_num_shapes -// Access: Published -// Description: Returns the number of shapes assigned to the -// force field shape group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of shapes assigned to the force field shape group. + */ unsigned int PhysxForceFieldShapeGroup:: get_num_shapes() const { @@ -175,12 +151,9 @@ get_num_shapes() const { return _ptr->getNbShapes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::create_shape -// Access: Published -// Description: Creates a force field shape and adds it to the -// group. -//////////////////////////////////////////////////////////////////// +/** + * Creates a force field shape and adds it to the group. + */ PhysxForceFieldShape *PhysxForceFieldShapeGroup:: create_shape(PhysxForceFieldShapeDesc &desc) { @@ -198,11 +171,9 @@ create_shape(PhysxForceFieldShapeDesc &desc) { return shape; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroup::get_shape -// Access: Published -// Description: Returns the i-th shape in the force field group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the i-th shape in the force field group. + */ PhysxForceFieldShape *PhysxForceFieldShapeGroup:: get_shape(unsigned int idx) const { @@ -219,4 +190,3 @@ get_shape(unsigned int idx) const { return (PhysxForceFieldShape *)(shapePtr->userData); } - diff --git a/panda/src/physx/physxForceFieldShapeGroup.h b/panda/src/physx/physxForceFieldShapeGroup.h index b8883926af..b03e34cfe9 100644 --- a/panda/src/physx/physxForceFieldShapeGroup.h +++ b/panda/src/physx/physxForceFieldShapeGroup.h @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShapeGroup.h -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroup.h + * @author enn0x + * @date 2009-11-11 + */ #ifndef PHYSXFORCEFIELDSHAPEGROUP_H #define PHYSXFORCEFIELDSHAPEGROUP_H @@ -28,10 +27,9 @@ class PhysxForceFieldShape; class PhysxForceFieldShapeDesc; class PhysxForceFieldShapeGroupDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceFieldShapeGroup -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxForceFieldShapeGroup : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -52,7 +50,6 @@ PUBLISHED: PhysxForceFieldShape *get_shape(unsigned int idx) const; MAKE_SEQ(get_shapes, get_num_shapes, get_shape); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -71,14 +68,13 @@ private: NxForceFieldShapeGroup *_ptr; string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxForceFieldShapeGroup", + register_type(_type_handle, "PhysxForceFieldShapeGroup", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.I b/panda/src/physx/physxForceFieldShapeGroupDesc.I index b03655b0c6..ed9561d2ad 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.I +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.I @@ -1,45 +1,36 @@ -// Filename: physxForceFieldShapeGroupDesc.I -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroupDesc.I + * @author enn0x + * @date 2009-11-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeGroupDesc:: PhysxForceFieldShapeGroupDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxForceFieldShapeGroupDesc:: ~PhysxForceFieldShapeGroupDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxForceFieldShapeGroupDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxForceFieldShapeGroupDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx index ac3fa59c1c..974c668824 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.cxx +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.cxx @@ -1,37 +1,30 @@ -// Filename: physxForceFieldShapeGroupDesc.cxx -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroupDesc.cxx + * @author enn0x + * @date 2009-11-11 + */ #include "physxForceFieldShapeGroupDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::add_shape -// Access: Published -// Description: Adds a shape to the list of force field shapes -// composing this shape group. -//////////////////////////////////////////////////////////////////// +/** + * Adds a shape to the list of force field shapes composing this shape group. + */ void PhysxForceFieldShapeGroupDesc:: add_shape(PhysxForceFieldShapeDesc &desc) { _desc.shapes.push_back(desc.ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::set_name -// Access: Published -// Description: Sets the optional debug name for the force field -// shape group. -//////////////////////////////////////////////////////////////////// +/** + * Sets the optional debug name for the force field shape group. + */ void PhysxForceFieldShapeGroupDesc:: set_name(const char *name) { @@ -39,24 +32,18 @@ set_name(const char *name) { _desc.name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::get_name -// Access: Published -// Description: Returns the optional debug name for this force -// field shape group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the optional debug name for this force field shape group. + */ const char *PhysxForceFieldShapeGroupDesc:: get_name() const { return _desc.name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::set_flag -// Access: Published -// Description: Raise or lower individual force field shape group -// flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual force field shape group flags. + */ void PhysxForceFieldShapeGroupDesc:: set_flag(const PhysxForceFieldShapeGroupFlag flag, bool value) { @@ -68,15 +55,11 @@ set_flag(const PhysxForceFieldShapeGroupFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxForceFieldShapeGroupDesc::get_flag -// Access: Published -// Description: Returns the specified force field shape group -// flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified force field shape group flag. + */ bool PhysxForceFieldShapeGroupDesc:: get_flag(const PhysxForceFieldShapeGroupFlag flag) const { return (_desc.flags & flag) ? true : false; } - diff --git a/panda/src/physx/physxForceFieldShapeGroupDesc.h b/panda/src/physx/physxForceFieldShapeGroupDesc.h index 5615eaea48..1f4a9a3206 100644 --- a/panda/src/physx/physxForceFieldShapeGroupDesc.h +++ b/panda/src/physx/physxForceFieldShapeGroupDesc.h @@ -1,16 +1,15 @@ -// Filename: physxForceFieldShapeGroupDesc.h -// Created by: enn0x (11Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxForceFieldShapeGroupDesc.h + * @author enn0x + * @date 2009-11-11 + */ #ifndef PHYSXFORCEFIELDSHAPEGROUPDESC_H #define PHYSXFORCEFIELDSHAPEGROUPDESC_H @@ -22,10 +21,9 @@ class PhysxForceFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxForceFieldShapeGroupDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxForceFieldShapeGroupDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxGroupsMask.I b/panda/src/physx/physxGroupsMask.I index 2ad689b8a0..7ac7b7c609 100644 --- a/panda/src/physx/physxGroupsMask.I +++ b/panda/src/physx/physxGroupsMask.I @@ -1,23 +1,19 @@ -// Filename: physxGroupsMask.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxGroupsMask.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxGroupsMask:: PhysxGroupsMask() { @@ -27,134 +23,109 @@ PhysxGroupsMask() { _mask.bits3 = 0x00000000; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxGroupsMask:: PhysxGroupsMask(NxGroupsMask mask) : _mask(mask) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxGroupsMask:: ~PhysxGroupsMask() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_mask -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NxGroupsMask PhysxGroupsMask:: get_mask() const { return _mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_mask -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxGroupsMask:: set_mask(NxGroupsMask mask) { _mask = mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_bits0 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxGroupsMask:: get_bits0() const { return _mask.bits0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_bits0 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxGroupsMask:: set_bits0(unsigned int bits) { _mask.bits0 = (NxU32) bits; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_bits1 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxGroupsMask:: get_bits1() const { return _mask.bits1; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_bits1 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxGroupsMask:: set_bits1(unsigned int bits) { _mask.bits1 = (NxU32) bits; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_bits2 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxGroupsMask:: get_bits2() const { return _mask.bits2; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_bits2 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxGroupsMask:: set_bits2(unsigned int bits) { _mask.bits2 = (NxU32) bits; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_bits3 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxGroupsMask:: get_bits3() const { return _mask.bits3; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_bits3 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxGroupsMask:: set_bits3(unsigned int bits) { _mask.bits3 = (NxU32) bits; } - diff --git a/panda/src/physx/physxGroupsMask.cxx b/panda/src/physx/physxGroupsMask.cxx index 44e370cf14..e16497350e 100644 --- a/panda/src/physx/physxGroupsMask.cxx +++ b/panda/src/physx/physxGroupsMask.cxx @@ -1,24 +1,21 @@ -// Filename: physxGroupsMask.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxGroupsMask.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxGroupsMask.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::all_on -// Access: Published -// Description: Returns a PhysxGroupsMask whose bits are all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxGroupsMask whose bits are all on. + */ PhysxGroupsMask PhysxGroupsMask:: all_on() { @@ -30,11 +27,9 @@ all_on() { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::all_off -// Access: Published -// Description: Returns a PhysxGroupsMask whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxGroupsMask whose bits are all off. + */ PhysxGroupsMask PhysxGroupsMask:: all_off() { @@ -48,12 +43,9 @@ all_off() { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::set_bit -// Access: Published -// Description: Sets the nth bit on. -// Index must be in the range [0, 127]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. Index must be in the range [0, 127]. + */ void PhysxGroupsMask:: set_bit(unsigned int idx) { @@ -75,12 +67,9 @@ set_bit(unsigned int idx) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::clear_bit -// Access: Published -// Description: Sets the nth bit off. -// Index must be in the range [0, 127]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. Index must be in the range [0, 127]. + */ void PhysxGroupsMask:: clear_bit(unsigned int idx) { @@ -102,13 +91,10 @@ clear_bit(unsigned int idx) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. -// Index must be in the range [0, 127]. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. Index must be + * in the range [0, 127]. + */ bool PhysxGroupsMask:: get_bit(unsigned int idx) const { @@ -130,12 +116,9 @@ get_bit(unsigned int idx) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxGroupsMask::output -// Access: Published -// Description: Writes the PhysxGroupsMask out as a list of ones and -// zeros. -//////////////////////////////////////////////////////////////////// +/** + * Writes the PhysxGroupsMask out as a list of ones and zeros. + */ void PhysxGroupsMask:: output(ostream &out) const { @@ -153,4 +136,3 @@ output(ostream &out) const { out << "/" << name0 << "-" << name1 << "-" << name2 << "-" << name3 << "/"; } - diff --git a/panda/src/physx/physxGroupsMask.h b/panda/src/physx/physxGroupsMask.h index 42eb49c7e8..2383a2675d 100644 --- a/panda/src/physx/physxGroupsMask.h +++ b/panda/src/physx/physxGroupsMask.h @@ -1,16 +1,15 @@ -// Filename: physxGroupsMask.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxGroupsMask.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXGROUPSMASK_H #define PHYSXGROUPSMASK_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxGroupsMask -// Description : 128-bit bitmask class. -//////////////////////////////////////////////////////////////////// +/** + * 128-bit bitmask class. + */ class EXPCL_PANDAPHYSX PhysxGroupsMask { PUBLISHED: diff --git a/panda/src/physx/physxHeightField.I b/panda/src/physx/physxHeightField.I index fde2ec7e88..e06fb3425e 100644 --- a/panda/src/physx/physxHeightField.I +++ b/panda/src/physx/physxHeightField.I @@ -1,59 +1,47 @@ -// Filename: physxHeightField.I -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightField.I + * @author enn0x + * @date 2009-10-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightField:: PhysxHeightField() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightField:: ~PhysxHeightField() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxHeightField:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxHeightField:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxHeightField.cxx b/panda/src/physx/physxHeightField.cxx index 2543921656..b4885a1b26 100644 --- a/panda/src/physx/physxHeightField.cxx +++ b/panda/src/physx/physxHeightField.cxx @@ -1,26 +1,23 @@ -// Filename: physxHeightField.cxx -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightField.cxx + * @author enn0x + * @date 2009-10-15 + */ #include "physxHeightField.h" TypeHandle PhysxHeightField::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightField:: link(NxHeightField *hfPtr) { @@ -29,11 +26,9 @@ link(NxHeightField *hfPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightField:: unlink() { @@ -41,11 +36,9 @@ unlink() { PhysxManager::get_global_ptr()->_heightfields.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::release -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightField:: release() { @@ -56,11 +49,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::get_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxHeightField:: get_height(float x, float y) const { @@ -68,15 +59,12 @@ get_height(float x, float y) const { return _ptr->getHeight(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightField::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxHeightField:: get_reference_count() const { nassertr(_error_type == ET_ok, 0); return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxHeightField.h b/panda/src/physx/physxHeightField.h index 7d03a3c895..4449e09022 100644 --- a/panda/src/physx/physxHeightField.h +++ b/panda/src/physx/physxHeightField.h @@ -1,16 +1,15 @@ -// Filename: physxHeightField.h -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightField.h + * @author enn0x + * @date 2009-10-15 + */ #ifndef PHYSXHEIGHTFIELD_H #define PHYSXHEIGHTFIELD_H @@ -24,28 +23,23 @@ #include "physxTriggerReport.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxHeightField -// Description : A height field object. -// Height fields work in a similar way as triangle -// meshes specified to act as height fields, with -// some important differences: -// -// Triangle meshes can be made of nonuniform geometry, -// while height fields are regular, rectangular grids. -// This means that with PhysxHeightField, you -// sacrifice flexibility in return for improved -// performance and decreased memory consumption. -// -// Height fields are referenced by shape instances of -// type PhysxHeightFieldShape. -// -// To create an instance of this class call -// PhysxManager::create_height_field(), and -// PhysxHeightField::release() to release it. This is -// only possible once you have released all of its -// PhysxHeightFiedShape instances before. -//////////////////////////////////////////////////////////////////// +/** + * A height field object. Height fields work in a similar way as triangle + * meshes specified to act as height fields, with some important differences: + * + * Triangle meshes can be made of nonuniform geometry, while height fields are + * regular, rectangular grids. This means that with PhysxHeightField, you + * sacrifice flexibility in return for improved performance and decreased + * memory consumption. + * + * Height fields are referenced by shape instances of type + * PhysxHeightFieldShape. + * + * To create an instance of this class call + * PhysxManager::create_height_field(), and PhysxHeightField::release() to + * release it. This is only possible once you have released all of its + * PhysxHeightFiedShape instances before. + */ class EXPCL_PANDAPHYSX PhysxHeightField : public PhysxObject { PUBLISHED: @@ -69,14 +63,13 @@ public: private: NxHeightField *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxHeightField", + register_type(_type_handle, "PhysxHeightField", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxHeightFieldDesc.I b/panda/src/physx/physxHeightFieldDesc.I index 19623497be..e6870dd4cb 100644 --- a/panda/src/physx/physxHeightFieldDesc.I +++ b/panda/src/physx/physxHeightFieldDesc.I @@ -1,24 +1,19 @@ -// Filename: physxHeightFieldDesc.I -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldDesc.I + * @author enn0x + * @date 2009-10-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldDesc:: PhysxHeightFieldDesc() { @@ -26,43 +21,35 @@ PhysxHeightFieldDesc() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldDesc:: ~PhysxHeightFieldDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxHeightFieldDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxHeightFieldDesc:: is_valid() const { return _desc.isValid(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_size -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxHeightFieldDesc:: set_size(unsigned int num_rows, unsigned int num_columns) { @@ -80,12 +67,9 @@ set_size(unsigned int num_rows, unsigned int num_columns) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::unset_size -// Access: Private -// Description: Releases the memory allocated for the height field -// samples. -//////////////////////////////////////////////////////////////////// +/** + * Releases the memory allocated for the height field samples. + */ INLINE void PhysxHeightFieldDesc:: unset_size() { @@ -96,4 +80,3 @@ unset_size() { delete[] _samples; } } - diff --git a/panda/src/physx/physxHeightFieldDesc.cxx b/panda/src/physx/physxHeightFieldDesc.cxx index 5027652d3f..5d9340c882 100644 --- a/panda/src/physx/physxHeightFieldDesc.cxx +++ b/panda/src/physx/physxHeightFieldDesc.cxx @@ -1,46 +1,39 @@ -// Filename: physxHeightFieldDesc.cxx -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldDesc.cxx + * @author enn0x + * @date 2009-10-15 + */ #include "physxHeightFieldDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_convex_edge_threshold -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_convex_edge_threshold(float threshold) { _desc.convexEdgeThreshold = threshold; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_thickness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_thickness(float thickness) { _desc.thickness = thickness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_image -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_image(const PNMImage &image, unsigned short materialIndex) { @@ -72,11 +65,9 @@ set_image(const PNMImage &image, unsigned short materialIndex) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_material_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_material_index(unsigned int row, unsigned int column, unsigned short materialIndex0, unsigned short materialIndex1) { @@ -88,17 +79,16 @@ set_material_index(unsigned int row, unsigned int column, unsigned short materia NxU8 *byte = (NxU8 *)_desc.samples + _desc.sampleStride * idx; NxHeightFieldSample* sample = (NxHeightFieldSample *)byte; - //NxHeightFieldSample* sample = ((NxHeightFieldSample *)_desc.samples) + idx; + // NxHeightFieldSample* sample = ((NxHeightFieldSample *)_desc.samples) + + // idx; sample->materialIndex0 = (NxU8)materialIndex0; sample->materialIndex1 = (NxU8)materialIndex1; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_height(unsigned int row, unsigned int column, short height) { @@ -113,11 +103,9 @@ set_height(unsigned int row, unsigned int column, short height) { sample->height = (NxI16)height; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldDesc::set_tess_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldDesc:: set_tess_flag(unsigned int row, unsigned int column, unsigned short value) { @@ -132,4 +120,3 @@ set_tess_flag(unsigned int row, unsigned int column, unsigned short value) { nassertv(value < 2); sample->tessFlag = (NxU8)value; } - diff --git a/panda/src/physx/physxHeightFieldDesc.h b/panda/src/physx/physxHeightFieldDesc.h index 29c8143eca..1a70eff4a6 100644 --- a/panda/src/physx/physxHeightFieldDesc.h +++ b/panda/src/physx/physxHeightFieldDesc.h @@ -1,16 +1,15 @@ -// Filename: physxHeightFieldDesc.h -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldDesc.h + * @author enn0x + * @date 2009-10-15 + */ #ifndef PHYSXHEIGHTFIELDDESC_H #define PHYSXHEIGHTFIELDDESC_H @@ -20,14 +19,11 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxHeightFieldDesc -// Description : Descriptor class for height fields. The height -// field data is copied when a PhysxHeightField object -// is created from this descriptor. After the call -// the user may discard the original height data (e.g. -// release the PNGImage). -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for height fields. The height field data is copied when a + * PhysxHeightField object is created from this descriptor. After the call + * the user may discard the original height data (e.g. release the PNGImage). + */ class EXPCL_PANDAPHYSX PhysxHeightFieldDesc { PUBLISHED: diff --git a/panda/src/physx/physxHeightFieldShape.I b/panda/src/physx/physxHeightFieldShape.I index 3a6fd84560..03b52be971 100644 --- a/panda/src/physx/physxHeightFieldShape.I +++ b/panda/src/physx/physxHeightFieldShape.I @@ -1,36 +1,28 @@ -// Filename: physxHeightFieldShape.I -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShape.I + * @author enn0x + * @date 2009-10-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldShape:: PhysxHeightFieldShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldShape:: ~PhysxHeightFieldShape() { } - diff --git a/panda/src/physx/physxHeightFieldShape.cxx b/panda/src/physx/physxHeightFieldShape.cxx index 6971e3b72e..21d0f6f81f 100644 --- a/panda/src/physx/physxHeightFieldShape.cxx +++ b/panda/src/physx/physxHeightFieldShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxHeightFieldShape.cxx -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShape.cxx + * @author enn0x + * @date 2009-10-15 + */ #include "physxHeightFieldShape.h" #include "physxHeightFieldShapeDesc.h" TypeHandle PhysxHeightFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldShape:: link(NxShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldShape:: unlink() { @@ -50,16 +45,12 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxHeightFieldShape:: save_to_desc(PhysxHeightFieldShapeDesc &shapeDesc) const { nassertv(_error_type == ET_ok); _ptr->saveToDesc(shapeDesc._desc); } - diff --git a/panda/src/physx/physxHeightFieldShape.h b/panda/src/physx/physxHeightFieldShape.h index 7f38f6bdf0..671d0e7366 100644 --- a/panda/src/physx/physxHeightFieldShape.h +++ b/panda/src/physx/physxHeightFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxHeightFieldShape.h -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShape.h + * @author enn0x + * @date 2009-10-15 + */ #ifndef PHYSXHEIGHTFIELDSHAPE_H #define PHYSXHEIGHTFIELDSHAPE_H @@ -22,22 +21,17 @@ class PhysxHeightFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxHeightFieldShape -// Description : This class is a shape instance of a height field -// object of type PhysxHeightField. Each shape is -// owned by an actor that it is attached to. -// -// An instance can be created by calling the -// createShape() method of the PhysxActor object that -// should own it, with a PhysxHeightFieldShapeDesc -// object as the parameter, or by adding the shape -// descriptor into the PhysxActorDesc class before -// creating the actor. -// -// The shape is deleted by calling release() on the -// shape itself. -//////////////////////////////////////////////////////////////////// +/** + * This class is a shape instance of a height field object of type + * PhysxHeightField. Each shape is owned by an actor that it is attached to. + * + * An instance can be created by calling the createShape() method of the + * PhysxActor object that should own it, with a PhysxHeightFieldShapeDesc + * object as the parameter, or by adding the shape descriptor into the + * PhysxActorDesc class before creating the actor. + * + * The shape is deleted by calling release() on the shape itself. + */ class EXPCL_PANDAPHYSX PhysxHeightFieldShape : public PhysxShape { PUBLISHED: @@ -55,14 +49,13 @@ public: private: NxHeightFieldShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxHeightFieldShape", + register_type(_type_handle, "PhysxHeightFieldShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxHeightFieldShapeDesc.I b/panda/src/physx/physxHeightFieldShapeDesc.I index 578cd6a0ac..70a1db5cd9 100644 --- a/panda/src/physx/physxHeightFieldShapeDesc.I +++ b/panda/src/physx/physxHeightFieldShapeDesc.I @@ -1,48 +1,38 @@ -// Filename: physxHeightFieldShapeDesc.I -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShapeDesc.I + * @author enn0x + * @date 2009-10-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldShapeDesc:: PhysxHeightFieldShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxHeightFieldShapeDesc:: ~PhysxHeightFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxHeightFieldShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxHeightFieldShapeDesc.cxx b/panda/src/physx/physxHeightFieldShapeDesc.cxx index aa18776bf5..3f6a7b63f9 100644 --- a/panda/src/physx/physxHeightFieldShapeDesc.cxx +++ b/panda/src/physx/physxHeightFieldShapeDesc.cxx @@ -1,25 +1,22 @@ -// Filename: physxHeightFieldShapeDesc.cxx -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShapeDesc.cxx + * @author enn0x + * @date 2009-10-15 + */ #include "physxHeightFieldShapeDesc.h" #include "physxHeightField.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ void PhysxHeightFieldShapeDesc:: set_to_default() { @@ -33,64 +30,50 @@ set_to_default() { _desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::set_hole_material -// Access: Published -// Description: Sets the the material index that designates holes -// in the height field. This number is compared -// directly to sample materials. Consequently the -// high 9 bits must be zero. -// Default value is 0. -//////////////////////////////////////////////////////////////////// +/** + * Sets the the material index that designates holes in the height field. + * This number is compared directly to sample materials. Consequently the + * high 9 bits must be zero. Default value is 0. + */ void PhysxHeightFieldShapeDesc:: set_hole_material(unsigned short index) { _desc.holeMaterial = (NxMaterialIndex)index; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::set_material_index_high_bits -// Access: Published -// Description: Sets the high 9 bits of this number are used to -// complete the material indices in the samples. The -// remaining low 7 bits must be zero. -// Default value is 0. -//////////////////////////////////////////////////////////////////// +/** + * Sets the high 9 bits of this number are used to complete the material + * indices in the samples. The remaining low 7 bits must be zero. Default + * value is 0. + */ void PhysxHeightFieldShapeDesc:: set_material_index_high_bits(unsigned short index) { _desc.materialIndexHighBits = (NxMaterialIndex)index; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::get_hole_material -// Access: Published -// Description: Returns the the material index that designates -// holes in the height field. -//////////////////////////////////////////////////////////////////// +/** + * Returns the the material index that designates holes in the height field. + */ unsigned short PhysxHeightFieldShapeDesc:: get_hole_material() const { return (unsigned short)_desc.holeMaterial; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::get_material_index_hight_bits -// Access: Published -// Description: Returns the high 9 bits of this number are used to -// complete the material indices in the samples. -//////////////////////////////////////////////////////////////////// +/** + * Returns the high 9 bits of this number are used to complete the material + * indices in the samples. + */ unsigned short PhysxHeightFieldShapeDesc:: get_material_index_hight_bits() const { return (unsigned short)_desc.materialIndexHighBits; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::set_dimensions -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldShapeDesc:: set_dimensions(const LVector3f &dimensions) { @@ -104,14 +87,11 @@ set_dimensions(const LVector3f &dimensions) { _desc.heightScale = dimensions.get_z() / _64K; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxHeightFieldShapeDesc::set_height_field -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxHeightFieldShapeDesc:: set_height_field(const PhysxHeightField &hf) { _desc.heightField = hf.ptr(); } - diff --git a/panda/src/physx/physxHeightFieldShapeDesc.h b/panda/src/physx/physxHeightFieldShapeDesc.h index 9fca5b0ecf..985efc721e 100644 --- a/panda/src/physx/physxHeightFieldShapeDesc.h +++ b/panda/src/physx/physxHeightFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxHeightFieldShapeDesc.h -// Created by: enn0x (15Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxHeightFieldShapeDesc.h + * @author enn0x + * @date 2009-10-15 + */ #ifndef PHYSXHEIGHTFIELDSHAPEDESC_H #define PHYSXHEIGHTFIELDSHAPEDESC_H @@ -22,10 +21,9 @@ class PhysxHeightField; -//////////////////////////////////////////////////////////////////// -// Class : PhysxHeightFieldShapeDesc -// Description : Descriptor class for PhysxHeightFieldShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxHeightFieldShape. + */ class EXPCL_PANDAPHYSX PhysxHeightFieldShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxJoint.I b/panda/src/physx/physxJoint.I index a8301fbd28..1acb52d01d 100644 --- a/panda/src/physx/physxJoint.I +++ b/panda/src/physx/physxJoint.I @@ -1,45 +1,36 @@ -// Filename: physxJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJoint:: PhysxJoint() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxJoint:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxJoint:: ls(ostream &out, int indent_level) const { @@ -60,4 +51,3 @@ ls(ostream &out, int indent_level) const { out << "\n"; } - diff --git a/panda/src/physx/physxJoint.cxx b/panda/src/physx/physxJoint.cxx index 49a26ebd0e..0217d43849 100644 --- a/panda/src/physx/physxJoint.cxx +++ b/panda/src/physx/physxJoint.cxx @@ -1,16 +1,15 @@ -// Filename: physxJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxJoint.h" #include "physxManager.h" @@ -29,11 +28,9 @@ TypeHandle PhysxJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJoint:: release() { @@ -43,11 +40,9 @@ release() { ptr()->getScene().releaseJoint(*ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::factory -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJoint *PhysxJoint:: factory(NxJointType shapeType) { @@ -88,14 +83,10 @@ factory(NxJointType shapeType) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_name -// Access: Published -// Description: Sets a name string for this object. The name can -// be retrieved again with get_name(). -// This is for debugging and is not used by the -// physics engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for this object. The name can be retrieved again with + * get_name(). This is for debugging and is not used by the physics engine. + */ void PhysxJoint:: set_name(const char *name) { @@ -105,11 +96,9 @@ set_name(const char *name) { ptr()->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_name -// Access: Published -// Description: Returns the name string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name string. + */ const char *PhysxJoint:: get_name() const { @@ -117,12 +106,9 @@ get_name() const { return ptr()->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_actor -// Access: Published -// Description: Retrieves the actor which this joint is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actor which this joint is associated with. + */ PhysxActor *PhysxJoint:: get_actor(unsigned int idx) const { @@ -134,12 +120,9 @@ get_actor(unsigned int idx) const { return (PhysxActor *)(actorPtr[idx]->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_scene -// Access: Published -// Description: Retrieves the scene which this joint is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the scene which this joint is associated with. + */ PhysxScene *PhysxJoint:: get_scene() const { @@ -147,12 +130,10 @@ get_scene() const { return (PhysxScene *)(ptr()->getScene().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_global_anchor -// Access: Published -// Description: Sets the point where the two actors are attached, -// specified in global coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the point where the two actors are attached, specified in global + * coordinates. + */ void PhysxJoint:: set_global_anchor(const LPoint3f &anchor) { @@ -160,11 +141,9 @@ set_global_anchor(const LPoint3f &anchor) { ptr()->setGlobalAnchor(PhysxManager::point3_to_nxVec3(anchor)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_global_anchor -// Access: Published -// Description: Retrieves the joint anchor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the joint anchor. + */ LPoint3f PhysxJoint:: get_global_anchor() const { @@ -172,12 +151,10 @@ get_global_anchor() const { return PhysxManager::nxVec3_to_point3(ptr()->getGlobalAnchor()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_global_axis -// Access: Published -// Description: Sets the direction of the joint's primary axis, -// specified in global coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Sets the direction of the joint's primary axis, specified in global + * coordinates. + */ void PhysxJoint:: set_global_axis(const LVector3f &axis) { @@ -185,11 +162,9 @@ set_global_axis(const LVector3f &axis) { ptr()->setGlobalAxis(PhysxManager::vec3_to_nxVec3(axis)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_global_axis -// Access: Published -// Description: Retrieves the joint axis. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the joint axis. + */ LVector3f PhysxJoint:: get_global_axis() const { @@ -197,33 +172,28 @@ get_global_axis() const { return PhysxManager::nxVec3_to_vec3(ptr()->getGlobalAxis()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_breakable -// Access: Published -// Description: Sets the maximum force magnitude that the joint -// is able to withstand without breaking. -// -// If the joint force rises above this threshold, the -// joint breaks, and becomes disabled. -// -// There are two values, one for linear forces, and -// one for angular forces. Both values are used -// directly as a value for the maximum impulse -// tolerated by the joint constraints. -// -// Both force values are NX_MAX_REAL by default. -// This setting makes the joint unbreakable. The values -// should always be nonnegative. -// -// The distinction between maxForce and maxTorque is -// dependent on how the joint is implemented -// internally, which may not be obvious. For example -// what appears to be an angular degree of freedom may -// be constrained indirectly by a linear constraint. -// -// So in most practical applications the user should -// set both maxTorque and maxForce to low values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum force magnitude that the joint is able to withstand + * without breaking. + * + * If the joint force rises above this threshold, the joint breaks, and + * becomes disabled. + * + * There are two values, one for linear forces, and one for angular forces. + * Both values are used directly as a value for the maximum impulse tolerated + * by the joint constraints. + * + * Both force values are NX_MAX_REAL by default. This setting makes the joint + * unbreakable. The values should always be nonnegative. + * + * The distinction between maxForce and maxTorque is dependent on how the + * joint is implemented internally, which may not be obvious. For example + * what appears to be an angular degree of freedom may be constrained + * indirectly by a linear constraint. + * + * So in most practical applications the user should set both maxTorque and + * maxForce to low values. + */ void PhysxJoint:: set_breakable(float maxForce, float maxTorque) { @@ -231,11 +201,9 @@ set_breakable(float maxForce, float maxTorque) { ptr()->setBreakable(maxForce, maxTorque); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_use_acceleration_spring -// Access: Published -// Description: Switch between acceleration and force based spring. -//////////////////////////////////////////////////////////////////// +/** + * Switch between acceleration and force based spring. + */ void PhysxJoint:: set_use_acceleration_spring(bool value) { @@ -243,11 +211,9 @@ set_use_acceleration_spring(bool value) { ptr()->setUseAccelerationSpring(value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_use_acceleration_spring -// Access: Published -// Description: Checks whether acceleration spring is used. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether acceleration spring is used. + */ bool PhysxJoint:: get_use_acceleration_spring() const { @@ -255,11 +221,9 @@ get_use_acceleration_spring() const { return ptr()->getUseAccelerationSpring(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_solver_extrapolation_factor -// Access: Published -// Description: Sets the solver extrapolation factor. -//////////////////////////////////////////////////////////////////// +/** + * Sets the solver extrapolation factor. + */ void PhysxJoint:: set_solver_extrapolation_factor(float factor) { @@ -267,11 +231,9 @@ set_solver_extrapolation_factor(float factor) { ptr()->setSolverExtrapolationFactor(factor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::get_solver_extrapolation_factor -// Access: Published -// Description: Retrieves the solver extrapolation factor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the solver extrapolation factor. + */ float PhysxJoint:: get_solver_extrapolation_factor() const { @@ -279,31 +241,23 @@ get_solver_extrapolation_factor() const { return ptr()->getSolverExtrapolationFactor(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::set_limit_point -// Access: Published -// Description: Sets the limit point. -// The point is specified in the global coordinate -// frame. -// -// All types of joints may be limited with the same -// system: You may elect a point attached to one of -// the two actors to act as the limit point. You may -// also specify several planes attached to the other -// actor. -// -// The points and planes move together with the actor -// they are attached to. -// -// The simulation then makes certain that the pair -// of actors only move relative to each other so that -// the limit point stays on the positive side of all -// limit planes. -// -// The default limit point is (0,0,0) in the local -// frame of actor2. Calling this deletes all existing -// limit planes -//////////////////////////////////////////////////////////////////// +/** + * Sets the limit point. The point is specified in the global coordinate + * frame. + * + * All types of joints may be limited with the same system: You may elect a + * point attached to one of the two actors to act as the limit point. You may + * also specify several planes attached to the other actor. + * + * The points and planes move together with the actor they are attached to. + * + * The simulation then makes certain that the pair of actors only move + * relative to each other so that the limit point stays on the positive side + * of all limit planes. + * + * The default limit point is (0,0,0) in the local frame of actor2. Calling + * this deletes all existing limit planes + */ void PhysxJoint:: set_limit_point(const LPoint3f &pos, bool isOnActor2) { @@ -311,20 +265,15 @@ set_limit_point(const LPoint3f &pos, bool isOnActor2) { ptr()->setLimitPoint(PhysxManager::point3_to_nxVec3(pos), isOnActor2); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::add_limit_plane -// Access: Published -// Description: Adds a limit plane. -// The parameters are given in global coordinates. -// The plane is affixed to the actor that does not -// have the limit point. -// -// The normal of the plane points toward the positive -// side of the plane, and thus toward the limit point. -// If the normal points away from the limit point at -// the time of this call, the method returns false -// and the limit plane is ignored. -//////////////////////////////////////////////////////////////////// +/** + * Adds a limit plane. The parameters are given in global coordinates. The + * plane is affixed to the actor that does not have the limit point. + * + * The normal of the plane points toward the positive side of the plane, and + * thus toward the limit point. If the normal points away from the limit + * point at the time of this call, the method returns false and the limit + * plane is ignored. + */ void PhysxJoint:: add_limit_plane(const LVector3f &normal, const LPoint3f &pointInPlane, float restitution) { @@ -334,15 +283,12 @@ add_limit_plane(const LVector3f &normal, const LPoint3f &pointInPlane, float res restitution); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJoint::purge_limit_planes -// Access: Published -// Description: Deletes all limit planes added to the joint. -//////////////////////////////////////////////////////////////////// +/** + * Deletes all limit planes added to the joint. + */ void PhysxJoint:: purge_limit_planes() { nassertv(_error_type == ET_ok); ptr()->purgeLimitPlanes(); } - diff --git a/panda/src/physx/physxJoint.h b/panda/src/physx/physxJoint.h index 0029a34e78..25b623c2bc 100644 --- a/panda/src/physx/physxJoint.h +++ b/panda/src/physx/physxJoint.h @@ -1,16 +1,15 @@ -// Filename: physxJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXJOINT_H #define PHYSXJOINT_H @@ -26,12 +25,10 @@ class PhysxActor; class PhysxScene; -//////////////////////////////////////////////////////////////////// -// Class : PhysxJoint -// Description : Abstract base class for the different types of -// joints. All joints are used to connect two dynamic -// actors, or an actor and the environment. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for the different types of joints. All joints are used + * to connect two dynamic actors, or an actor and the environment. + */ class EXPCL_PANDAPHYSX PhysxJoint : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -74,14 +71,13 @@ protected: private: string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxJoint", + register_type(_type_handle, "PhysxJoint", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxJointDesc.I b/panda/src/physx/physxJointDesc.I index df059a4e60..dc511cfecc 100644 --- a/panda/src/physx/physxJointDesc.I +++ b/panda/src/physx/physxJointDesc.I @@ -1,36 +1,28 @@ -// Filename: physxJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointDesc:: PhysxJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointDesc:: ~PhysxJointDesc() { } - diff --git a/panda/src/physx/physxJointDesc.cxx b/panda/src/physx/physxJointDesc.cxx index 811f489028..fec3e3f791 100644 --- a/panda/src/physx/physxJointDesc.cxx +++ b/panda/src/physx/physxJointDesc.cxx @@ -1,25 +1,22 @@ -// Filename: physxJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxJointDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_name -// Access: Published -// Description: Sets a possible debug name. -//////////////////////////////////////////////////////////////////// +/** + * Sets a possible debug name. + */ void PhysxJointDesc:: set_name(const char *name) { @@ -27,48 +24,37 @@ set_name(const char *name) { ptr()->name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_max_force -// Access: Published -// Description: Set a possible debug name. -//////////////////////////////////////////////////////////////////// +/** + * Set a possible debug name. + */ void PhysxJointDesc:: set_max_force(float force) { ptr()->maxForce = force; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_max_torque -// Access: Published -// Description: Set the maximum angular force (torque) that the -// joint can withstand before breaking, must be -// positive. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum angular force (torque) that the joint can withstand before + * breaking, must be positive. + */ void PhysxJointDesc:: set_max_torque(float torque) { ptr()->maxTorque = torque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_solver_extrapolation_factor -// Access: Published -// Description: Set the extrapolation factor for solving joint -// constraints. -//////////////////////////////////////////////////////////////////// +/** + * Set the extrapolation factor for solving joint constraints. + */ void PhysxJointDesc:: set_solver_extrapolation_factor(float factor) { ptr()->solverExtrapolationFactor = factor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_actor -// Access: Published -// Description: Set the two actors connected by the joint. -// idx must be either 0 or 1. -//////////////////////////////////////////////////////////////////// +/** + * Set the two actors connected by the joint. idx must be either 0 or 1. + */ void PhysxJointDesc:: set_actor(unsigned int idx, const PhysxActor &actor) { @@ -76,13 +62,10 @@ set_actor(unsigned int idx, const PhysxActor &actor) { ptr()->actor[idx] = actor.ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_local_normal -// Access: Published -// Description: Set the X axis of joint space, in actor[i]'s space, -// orthogonal to localAxis[i]. -// idx must be either 0 or 1. -//////////////////////////////////////////////////////////////////// +/** + * Set the X axis of joint space, in actor[i]'s space, orthogonal to + * localAxis[i]. idx must be either 0 or 1. + */ void PhysxJointDesc:: set_local_normal(unsigned int idx, const LVector3f &normal) { @@ -90,13 +73,10 @@ set_local_normal(unsigned int idx, const LVector3f &normal) { ptr()->localNormal[idx] = PhysxManager::vec3_to_nxVec3(normal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_local_axis -// Access: Published -// Description: Set the Z axis of joint space, in actor[i]'s space. -// This is the primary axis of the joint. -// idx must be either 0 or 1. -//////////////////////////////////////////////////////////////////// +/** + * Set the Z axis of joint space, in actor[i]'s space. This is the primary + * axis of the joint. idx must be either 0 or 1. + */ void PhysxJointDesc:: set_local_axis(unsigned int idx, const LVector3f &axis) { @@ -104,12 +84,10 @@ set_local_axis(unsigned int idx, const LVector3f &axis) { ptr()->localAxis[idx] = PhysxManager::vec3_to_nxVec3(axis); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_local_anchor -// Access: Published -// Description: Set the attachment point of joint in actor[i]'s -// space. idx must be either 0 or 1. -//////////////////////////////////////////////////////////////////// +/** + * Set the attachment point of joint in actor[i]'s space. idx must be either + * 0 or 1. + */ void PhysxJointDesc:: set_local_anchor(unsigned int idx, const LPoint3f &anchor) { @@ -117,11 +95,9 @@ set_local_anchor(unsigned int idx, const LPoint3f &anchor) { ptr()->localAnchor[idx] = PhysxManager::point3_to_nxVec3(anchor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_joint_flag -// Access: Published -// Description: Set or clear a single JointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Set or clear a single JointFlag. + */ void PhysxJointDesc:: set_joint_flag(PhysxJointFlag flag, bool value) { @@ -133,77 +109,63 @@ set_joint_flag(PhysxJointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_global_axis -// Access: Published -// Description: Set the local axis/normal using a world space axis. -//////////////////////////////////////////////////////////////////// +/** + * Set the local axis/normal using a world space axis. + */ void PhysxJointDesc:: set_global_axis(const LVector3f &axis) { ptr()->setGlobalAxis(PhysxManager::vec3_to_nxVec3(axis)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::set_global_anchor -// Access: Published -// Description: Set the anchor using a world space point. -//////////////////////////////////////////////////////////////////// +/** + * Set the anchor using a world space point. + */ void PhysxJointDesc:: set_global_anchor(const LPoint3f &anchor) { ptr()->setGlobalAnchor(PhysxManager::point3_to_nxVec3(anchor)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxJointDesc:: get_name() const { return ptr()->name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_max_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDesc:: get_max_force() const { return ptr()->maxForce; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_max_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDesc:: get_max_torque() const { return ptr()->maxTorque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_solver_extrapolation_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDesc:: get_solver_extrapolation_factor() const { return ptr()->solverExtrapolationFactor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_local_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxJointDesc:: get_local_normal(unsigned int idx) const { @@ -211,11 +173,9 @@ get_local_normal(unsigned int idx) const { return PhysxManager::nxVec3_to_vec3(ptr()->localNormal[idx]); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_local_axis -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxJointDesc:: get_local_axis(unsigned int idx) const { @@ -223,11 +183,9 @@ get_local_axis(unsigned int idx) const { return PhysxManager::nxVec3_to_vec3(ptr()->localAxis[idx]); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_local_anchor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxJointDesc:: get_local_anchor(unsigned int idx) const { @@ -235,22 +193,18 @@ get_local_anchor(unsigned int idx) const { return PhysxManager::nxVec3_to_point3(ptr()->localAnchor[idx]); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_joint_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxJointDesc:: get_joint_flag(const PhysxJointFlag flag) const { return (ptr()->jointFlags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDesc::get_actor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxActor *PhysxJointDesc:: get_actor(unsigned int idx) const { @@ -264,4 +218,3 @@ get_actor(unsigned int idx) const { return (PhysxActor *)(actorPtr->userData); } } - diff --git a/panda/src/physx/physxJointDesc.h b/panda/src/physx/physxJointDesc.h index e13d877565..9f24e5a214 100644 --- a/panda/src/physx/physxJointDesc.h +++ b/panda/src/physx/physxJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXJOINTDESC_H #define PHYSXJOINTDESC_H @@ -23,10 +22,9 @@ class PhysxActor; -//////////////////////////////////////////////////////////////////// -// Class : PhysxJointDesc -// Description : Abstract base class for joint descriptors. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for joint descriptors. + */ class EXPCL_PANDAPHYSX PhysxJointDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxJointDriveDesc.I b/panda/src/physx/physxJointDriveDesc.I index bd4907251c..d8aeb3adf8 100644 --- a/panda/src/physx/physxJointDriveDesc.I +++ b/panda/src/physx/physxJointDriveDesc.I @@ -1,33 +1,27 @@ -// Filename: physxJointDriveDesc.I -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDriveDesc.I + * @author enn0x + * @date 2009-10-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointDriveDesc:: PhysxJointDriveDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointDriveDesc:: PhysxJointDriveDesc(float spring, float damping, float forceLimit) { @@ -36,13 +30,10 @@ PhysxJointDriveDesc(float spring, float damping, float forceLimit) { _desc.forceLimit = forceLimit; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointDriveDesc:: ~PhysxJointDriveDesc() { } - diff --git a/panda/src/physx/physxJointDriveDesc.cxx b/panda/src/physx/physxJointDriveDesc.cxx index 0b64e7e207..83fd50a511 100644 --- a/panda/src/physx/physxJointDriveDesc.cxx +++ b/panda/src/physx/physxJointDriveDesc.cxx @@ -1,104 +1,86 @@ -// Filename: physxJointDriveDesc.cxx -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDriveDesc.cxx + * @author enn0x + * @date 2009-10-01 + */ #include "physxJointDriveDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointDriveDesc:: set_spring(float spring) { _desc.spring = spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::set_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointDriveDesc:: set_damping(float damping) { _desc.damping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::set_force_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointDriveDesc:: set_force_limit(float forceLimit) { _desc.forceLimit = forceLimit; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::set_drive_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointDriveDesc:: set_drive_type(PhysxD6JointDriveType driveType) { _desc.driveType = (NxD6JointDriveType)driveType; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDriveDesc:: get_spring() const { return _desc.spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::get_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDriveDesc:: get_damping() const { return _desc.damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::get_force_limit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointDriveDesc:: get_force_limit() const { return _desc.forceLimit; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointDriveDesc::get_drive_type -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxD6JointDriveType PhysxJointDriveDesc:: get_drive_type() const { return (PhysxD6JointDriveType)_desc.driveType.bitField; } - diff --git a/panda/src/physx/physxJointDriveDesc.h b/panda/src/physx/physxJointDriveDesc.h index 991e3d051a..156ddee243 100644 --- a/panda/src/physx/physxJointDriveDesc.h +++ b/panda/src/physx/physxJointDriveDesc.h @@ -1,16 +1,15 @@ -// Filename: physxJointDriveDesc.h -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointDriveDesc.h + * @author enn0x + * @date 2009-10-01 + */ #ifndef PHYSXJOINTDRIVEDESC_H #define PHYSXJOINTDRIVEDESC_H @@ -20,11 +19,9 @@ #include "physxEnums.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxJointDriveDesc -// Description : Used to describe drive properties for a -// PhysxD6Joint. -//////////////////////////////////////////////////////////////////// +/** + * Used to describe drive properties for a PhysxD6Joint. + */ class EXPCL_PANDAPHYSX PhysxJointDriveDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxJointLimitDesc.I b/panda/src/physx/physxJointLimitDesc.I index 8881d096ac..83de64ea50 100644 --- a/panda/src/physx/physxJointLimitDesc.I +++ b/panda/src/physx/physxJointLimitDesc.I @@ -1,33 +1,27 @@ -// Filename: physxJointLimitDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitDesc.I + * @author enn0x + * @date 2009-09-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitDesc:: PhysxJointLimitDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitDesc:: PhysxJointLimitDesc(float value, float restitution, float hardness) { @@ -36,13 +30,10 @@ PhysxJointLimitDesc(float value, float restitution, float hardness) { _desc.hardness = hardness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitDesc:: ~PhysxJointLimitDesc() { } - diff --git a/panda/src/physx/physxJointLimitDesc.cxx b/panda/src/physx/physxJointLimitDesc.cxx index e741c8c197..c848bb7c33 100644 --- a/panda/src/physx/physxJointLimitDesc.cxx +++ b/panda/src/physx/physxJointLimitDesc.cxx @@ -1,82 +1,68 @@ -// Filename: physxJointLimitDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxJointLimitDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::set_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitDesc:: set_value(float value) { _desc.value = value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::set_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitDesc:: set_restitution(float restitution) { _desc.restitution = restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::set_hardness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitDesc:: set_hardness(float hardness) { _desc.hardness = hardness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::get_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitDesc:: get_value() const { return _desc.value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::get_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitDesc:: get_restitution() const { return _desc.restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitDesc::get_hardness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitDesc:: get_hardness() const { return _desc.hardness; } - diff --git a/panda/src/physx/physxJointLimitDesc.h b/panda/src/physx/physxJointLimitDesc.h index 3665fa4cf7..a19c81d183 100644 --- a/panda/src/physx/physxJointLimitDesc.h +++ b/panda/src/physx/physxJointLimitDesc.h @@ -1,16 +1,15 @@ -// Filename: physxJointLimitDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXJOINTLIMITDESC_H #define PHYSXJOINTLIMITDESC_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxJointLimitDesc -// Description : Describes a joint limit. -//////////////////////////////////////////////////////////////////// +/** + * Describes a joint limit. + */ class EXPCL_PANDAPHYSX PhysxJointLimitDesc { PUBLISHED: diff --git a/panda/src/physx/physxJointLimitSoftDesc.I b/panda/src/physx/physxJointLimitSoftDesc.I index 4f861f0e39..dc8bffd895 100644 --- a/panda/src/physx/physxJointLimitSoftDesc.I +++ b/panda/src/physx/physxJointLimitSoftDesc.I @@ -1,33 +1,27 @@ -// Filename: physxJointLimitSoftDesc.I -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitSoftDesc.I + * @author enn0x + * @date 2009-10-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitSoftDesc:: PhysxJointLimitSoftDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitSoftDesc:: PhysxJointLimitSoftDesc(float value, float restitution, float spring, float damping) { @@ -37,13 +31,10 @@ PhysxJointLimitSoftDesc(float value, float restitution, float spring, float damp _desc.damping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxJointLimitSoftDesc:: ~PhysxJointLimitSoftDesc() { } - diff --git a/panda/src/physx/physxJointLimitSoftDesc.cxx b/panda/src/physx/physxJointLimitSoftDesc.cxx index 5eab99f184..e0bcf271ce 100644 --- a/panda/src/physx/physxJointLimitSoftDesc.cxx +++ b/panda/src/physx/physxJointLimitSoftDesc.cxx @@ -1,104 +1,86 @@ -// Filename: physxJointLimitSoftDesc.cxx -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitSoftDesc.cxx + * @author enn0x + * @date 2009-10-01 + */ #include "physxJointLimitSoftDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::set_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitSoftDesc:: set_value(float value) { _desc.value = value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::set_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitSoftDesc:: set_restitution(float restitution) { _desc.restitution = restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::set_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitSoftDesc:: set_spring(float spring) { _desc.spring = spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::set_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxJointLimitSoftDesc:: set_damping(float damping) { _desc.damping = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::get_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitSoftDesc:: get_value() const { return _desc.value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::get_restitution -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitSoftDesc:: get_restitution() const { return _desc.restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitSoftDesc:: get_spring() const { return _desc.spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxJointLimitSoftDesc::get_damping -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxJointLimitSoftDesc:: get_damping() const { return _desc.damping; } - diff --git a/panda/src/physx/physxJointLimitSoftDesc.h b/panda/src/physx/physxJointLimitSoftDesc.h index 1d5f9c7b62..eed8e9517a 100644 --- a/panda/src/physx/physxJointLimitSoftDesc.h +++ b/panda/src/physx/physxJointLimitSoftDesc.h @@ -1,16 +1,15 @@ -// Filename: physxJointLimitSoftDesc.h -// Created by: enn0x (01Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxJointLimitSoftDesc.h + * @author enn0x + * @date 2009-10-01 + */ #ifndef PHYSXJOINTLIMITSOFTDESC_H #define PHYSXJOINTLIMITSOFTDESC_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxJointLimitSoftDesc -// Description : Describes a joint limit. -//////////////////////////////////////////////////////////////////// +/** + * Describes a joint limit. + */ class EXPCL_PANDAPHYSX PhysxJointLimitSoftDesc { PUBLISHED: diff --git a/panda/src/physx/physxKitchen.I b/panda/src/physx/physxKitchen.I index f320b511b1..98c9507b6b 100644 --- a/panda/src/physx/physxKitchen.I +++ b/panda/src/physx/physxKitchen.I @@ -1,23 +1,19 @@ -// Filename: physxKitchen.I -// Created by: enn0x (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxKitchen.I + * @author enn0x + * @date 2009-10-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxKitchen:: PhysxKitchen() { @@ -27,14 +23,11 @@ PhysxKitchen() { nassertv_always( status ); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxKitchen:: ~PhysxKitchen() { _cooking->NxCloseCooking(); } - diff --git a/panda/src/physx/physxKitchen.cxx b/panda/src/physx/physxKitchen.cxx index b844c8b8d0..144e6b2cbe 100644 --- a/panda/src/physx/physxKitchen.cxx +++ b/panda/src/physx/physxKitchen.cxx @@ -1,16 +1,15 @@ -// Filename: physxKitchen.cxx -// Created by: enn0x (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxKitchen.cxx + * @author enn0x + * @date 2009-10-12 + */ #include "physxKitchen.h" #include "physxConvexMesh.h" @@ -25,24 +24,18 @@ #include "physxSoftBodyMesh.h" #include "physxSoftBodyMeshDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::set_cooking_params -// Access: Published -// Description: Sets two parameters which affect mesh cooking: -// -// Skin width for convex meshes: -// Specifies the amount to inflate the convex mesh by -// when the new convex hull generator is used. -// Inflating the mesh allows the user to hide -// interpenetration errors by increasing the size of -// the collision mesh with respect to the size of the -// rendered geometry. -// Default value: 0.025f -// -// Hint to choose speed or less memory for collision -// structures. -// Default value: false -//////////////////////////////////////////////////////////////////// +/** + * Sets two parameters which affect mesh cooking: + * + * Skin width for convex meshes: Specifies the amount to inflate the convex + * mesh by when the new convex hull generator is used. Inflating the mesh + * allows the user to hide interpenetration errors by increasing the size of + * the collision mesh with respect to the size of the rendered geometry. + * Default value: 0.025f + * + * Hint to choose speed or less memory for collision structures. Default + * value: false + */ void PhysxKitchen:: set_cooking_params(float skinWidth, bool hintCollisionSpeed) { @@ -55,11 +48,9 @@ set_cooking_params(float skinWidth, bool hintCollisionSpeed) { _cooking->NxSetCookingParams(params); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_convex_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxKitchen:: cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc, const Filename &filename) { @@ -71,11 +62,9 @@ cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc, const Filename &filename) return _cooking->NxCookConvexMesh(meshDesc.get_desc(), fs); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_triangle_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxKitchen:: cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filename) { @@ -87,11 +76,9 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc, const Filename &filena return _cooking->NxCookTriangleMesh(meshDesc.get_desc(), fs); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxKitchen:: cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { @@ -103,11 +90,9 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { return _cooking->NxCookClothMesh(meshDesc.get_desc(), fs); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_soft_body_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxKitchen:: cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc, const Filename &filename) { @@ -119,11 +104,9 @@ cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc, const Filename &filen return _cooking->NxCookSoftBodyMesh(meshDesc.get_desc(), fs); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_texcoords -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxKitchen:: cook_texcoords(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { @@ -131,7 +114,7 @@ cook_texcoords(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { nassertr_always(filename.touch(), false); nassertr_always(meshDesc.is_valid(), false); - const plist texcoords = meshDesc.get_texcoords(); + const plist texcoords = meshDesc.get_texcoords(); // Write texcoords to binary file PhysxFileStream fs = PhysxFileStream(filename.c_str(), false); @@ -162,11 +145,9 @@ cook_texcoords(const PhysxClothMeshDesc &meshDesc, const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_convex_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxConvexMesh *PhysxKitchen:: cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { @@ -190,11 +171,9 @@ cook_convex_mesh(const PhysxConvexMeshDesc &meshDesc) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_triangle_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxTriangleMesh *PhysxKitchen:: cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { @@ -218,11 +197,9 @@ cook_triangle_mesh(const PhysxTriangleMeshDesc &meshDesc) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxClothMesh *PhysxKitchen:: cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { @@ -247,11 +224,9 @@ cook_cloth_mesh(const PhysxClothMeshDesc &meshDesc) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxKitchen::cook_soft_body_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSoftBodyMesh *PhysxKitchen:: cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc) { @@ -275,4 +250,3 @@ cook_soft_body_mesh(const PhysxSoftBodyMeshDesc &meshDesc) { return mesh; } - diff --git a/panda/src/physx/physxKitchen.h b/panda/src/physx/physxKitchen.h index 0b4b438f22..7d43fc7813 100644 --- a/panda/src/physx/physxKitchen.h +++ b/panda/src/physx/physxKitchen.h @@ -1,16 +1,15 @@ -// Filename: physxKitchen.h -// Created by: enn0x (12Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxKitchen.h + * @author enn0x + * @date 2009-10-12 + */ #ifndef PHYSXKITCHEN_H #define PHYSXKITCHEN_H @@ -29,10 +28,9 @@ class PhysxClothMeshDesc; class PhysxSoftBodyMesh; class PhysxSoftBodyMeshDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxKitchen -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxKitchen { PUBLISHED: diff --git a/panda/src/physx/physxLinearInterpolationValues.I b/panda/src/physx/physxLinearInterpolationValues.I index f7883231bf..b2cceb7001 100644 --- a/panda/src/physx/physxLinearInterpolationValues.I +++ b/panda/src/physx/physxLinearInterpolationValues.I @@ -1,35 +1,28 @@ -// Filename: physxLinearInterpolationValues.I -// Created by: enn0x (08Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxLinearInterpolationValues.I + * @author enn0x + * @date 2010-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxLinearInterpolationValues:: PhysxLinearInterpolationValues() : _min(0.0f), _max(0.0f), _map() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxLinearInterpolationValues:: ~PhysxLinearInterpolationValues() { } - diff --git a/panda/src/physx/physxLinearInterpolationValues.cxx b/panda/src/physx/physxLinearInterpolationValues.cxx index fe55d745f0..346d30508f 100644 --- a/panda/src/physx/physxLinearInterpolationValues.cxx +++ b/panda/src/physx/physxLinearInterpolationValues.cxx @@ -1,35 +1,30 @@ -// Filename: physxLinearInterpolationValues.cxx -// Created by: enn0x (08Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxLinearInterpolationValues.cxx + * @author enn0x + * @date 2010-02-08 + */ #include "physxLinearInterpolationValues.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::clear -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxLinearInterpolationValues:: clear() { _map.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::insert -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxLinearInterpolationValues:: insert(float index, float value) { @@ -43,33 +38,27 @@ insert(float index, float value) { _map[index] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::is_valid -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxLinearInterpolationValues:: is_valid(float number) const { return (number >= _min) && (number <= _max); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::get_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxLinearInterpolationValues:: get_size() const { return _map.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::get_value -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxLinearInterpolationValues:: get_value(float number) const { @@ -91,18 +80,16 @@ get_value(float number) const { lower = upper; lower--; - + float w1 = number - lower->first; float w2 = upper->first - number; return ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::get_value_at_index -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxLinearInterpolationValues:: get_value_at_index(int index) const { @@ -115,11 +102,9 @@ get_value_at_index(int index) const { return it->second; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxLinearInterpolationValues::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxLinearInterpolationValues:: output(ostream &out) const { @@ -129,4 +114,3 @@ output(ostream &out) const { cout << it->first << " -> " << it->second << "\n"; } } - diff --git a/panda/src/physx/physxLinearInterpolationValues.h b/panda/src/physx/physxLinearInterpolationValues.h index 5fd96c0604..4770393e34 100644 --- a/panda/src/physx/physxLinearInterpolationValues.h +++ b/panda/src/physx/physxLinearInterpolationValues.h @@ -1,16 +1,15 @@ -// Filename: physxLinearInterpolationValues.h -// Created by: enn0x (08Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxLinearInterpolationValues.h + * @author enn0x + * @date 2010-02-08 + */ #ifndef PHYSXLINEARINTERPOLATIONVALUES_H #define PHYSXLINEARINTERPOLATIONVALUES_H @@ -20,10 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxLinearInterpolationValues -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxLinearInterpolationValues { public: diff --git a/panda/src/physx/physxManager.I b/panda/src/physx/physxManager.I index 63bb1b0709..f6011a7e43 100644 --- a/panda/src/physx/physxManager.I +++ b/panda/src/physx/physxManager.I @@ -1,122 +1,100 @@ -// Filename: physxManager.I -// Created by: enn0x (01Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxManager.I + * @author enn0x + * @date 2009-09-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_sdk -// Access: Public -// Description: Returns a pointer to the NxPhysicsSDK. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the NxPhysicsSDK. + */ INLINE NxPhysicsSDK *PhysxManager:: get_sdk() const { return _sdk; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::vec3_to_nxVec3 -// Access: Public -// Description: Converts from LVector3f to NxVec3. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LVector3f to NxVec3. + */ INLINE NxVec3 PhysxManager:: vec3_to_nxVec3(const LVector3f &v) { return NxVec3(v.get_x(), v.get_y(), v.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxVec3_to_vec3 -// Access: Public -// Description: Converts from NxVec3 to LVector3f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxVec3 to LVector3f. + */ INLINE LVector3f PhysxManager:: nxVec3_to_vec3(const NxVec3 &v) { return LVector3f(v.x, v.y, v.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::vec3_to_nxExtVec3 -// Access: Public -// Description: Converts from LVector3f to NxExtendedVec3. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LVector3f to NxExtendedVec3. + */ INLINE NxExtendedVec3 PhysxManager:: vec3_to_nxExtVec3(const LVector3f &v) { return NxExtendedVec3(v.get_x(), v.get_y(), v.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxExtVec3_to_vec3 -// Access: Public -// Description: Converts from NxExtendedVec3 to LVector3f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxExtendedVec3 to LVector3f. + */ INLINE LVector3f PhysxManager:: nxExtVec3_to_vec3(const NxExtendedVec3 &v) { return LVector3f(v.x, v.y, v.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::point3_to_nxVec3 -// Access: Public -// Description: Converts from LPoint3f to NxVec3. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LPoint3f to NxVec3. + */ INLINE NxVec3 PhysxManager:: point3_to_nxVec3(const LPoint3f &p) { return NxVec3(p.get_x(), p.get_y(), p.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxVec3_to_point3 -// Access: Public -// Description: Converts from NxVec3 to LPoint3f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxVec3 to LPoint3f. + */ INLINE LPoint3f PhysxManager:: nxVec3_to_point3(const NxVec3 &p) { return LPoint3f(p.x, p.y, p.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::point3_to_nxExtVec3 -// Access: Public -// Description: Converts from LPoint3f to NxExtendedVec3. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LPoint3f to NxExtendedVec3. + */ INLINE NxExtendedVec3 PhysxManager:: point3_to_nxExtVec3(const LPoint3f &p) { return NxExtendedVec3(p.get_x(), p.get_y(), p.get_z()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxExtVec3_to_point3 -// Access: Public -// Description: Converts from NxExtendedVec3 to LPoint3f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxExtendedVec3 to LPoint3f. + */ INLINE LPoint3f PhysxManager:: nxExtVec3_to_point3(const NxExtendedVec3 &p) { return LPoint3f(p.x, p.y, p.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::quat_to_nxQuat -// Access: Public -// Description: Converts from LQuaternionf to NxQuat. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LQuaternionf to NxQuat. + */ INLINE NxQuat PhysxManager:: quat_to_nxQuat(const LQuaternionf &q) { @@ -125,22 +103,18 @@ quat_to_nxQuat(const LQuaternionf &q) { return nxq; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxQuat_to_quat -// Access: Public -// Description: Converts from NxQuat to LQuaternionf. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxQuat to LQuaternionf. + */ INLINE LQuaternionf PhysxManager:: nxQuat_to_quat(const NxQuat &q) { return LQuaternionf(q.w, q.x, q.y, q.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::mat4_to_nxMat34 -// Access: Public -// Description: Converts from LMatrix4f to NxMat34. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LMatrix4f to NxMat34. + */ INLINE NxMat34 PhysxManager:: mat4_to_nxMat34(const LMatrix4f &m) { @@ -149,22 +123,18 @@ mat4_to_nxMat34(const LMatrix4f &m) { return NxMat34(mat, v); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxMat34_to_mat4 -// Access: Public -// Description: Converts from NxMat34 to LMatrix4f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxMat34 to LMatrix4f. + */ INLINE LMatrix4f PhysxManager:: nxMat34_to_mat4(const NxMat34 &m) { return LMatrix4f(nxMat33_to_mat3(m.M), nxVec3_to_vec3(m.t)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::mat3_to_nxMat33 -// Access: Public -// Description: Converts from LMatrix3f to NxMat33. -//////////////////////////////////////////////////////////////////// +/** + * Converts from LMatrix3f to NxMat33. + */ INLINE NxMat33 PhysxManager:: mat3_to_nxMat33(const LMatrix3f &m) { @@ -173,11 +143,9 @@ mat3_to_nxMat33(const LMatrix3f &m) { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::nxMat33_to_mat3 -// Access: Public -// Description: Converts from NxMat33 to LMatrix3f. -//////////////////////////////////////////////////////////////////// +/** + * Converts from NxMat33 to LMatrix3f. + */ INLINE LMatrix3f PhysxManager:: nxMat33_to_mat3(const NxMat33 &m) { @@ -188,11 +156,9 @@ nxMat33_to_mat3(const NxMat33 &m) { cells[6], cells[7], cells[8]); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::update_vec3_from_nxVec3 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxManager:: update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec) { @@ -201,11 +167,9 @@ update_vec3_from_nxVec3(LVector3f &v, const NxVec3 &nVec) { v.set_z(nVec.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::update_point3_from_nxVec3 -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxManager:: update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec) { @@ -215,22 +179,18 @@ update_point3_from_nxVec3(LPoint3f &p, const NxVec3 &nVec) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxManager:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxManager:: ls(ostream &out, int indent_level) const { @@ -241,4 +201,3 @@ ls(ostream &out, int indent_level) const { _convex_meshes.ls(out, indent_level); _triangle_meshes.ls(out, indent_level); } - diff --git a/panda/src/physx/physxManager.cxx b/panda/src/physx/physxManager.cxx index 7ed0a4bf8d..297bbbaed4 100644 --- a/panda/src/physx/physxManager.cxx +++ b/panda/src/physx/physxManager.cxx @@ -1,16 +1,15 @@ -// Filename: physxManager.cxx -// Created by: enn0x (01Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxManager.cxx + * @author enn0x + * @date 2009-09-01 + */ #include "physxManager.h" #include "physxScene.h" @@ -19,11 +18,9 @@ PhysxManager *PhysxManager::_global_ptr; PhysxManager::PhysxOutputStream PhysxManager::_outputStream; -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxManager:: PhysxManager() { @@ -45,7 +42,7 @@ PhysxManager() { nassertv_always(error == NXCE_NO_ERROR); nassertv_always(_sdk); - + // Set some default parameters _sdk->setParameter(NX_VISUALIZATION_SCALE, 0.0f); _sdk->setParameter(NX_VISUALIZE_COLLISION_SHAPES, true); @@ -74,11 +71,9 @@ PhysxManager() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxManager:: ~PhysxManager() { @@ -94,12 +89,9 @@ PhysxManager:: NxReleasePhysicsSDK(_sdk); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_global_ptr -// Access: Published -// Description: Returns a pointer to the global PhysxManager -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global PhysxManager object. + */ PhysxManager *PhysxManager:: get_global_ptr() { @@ -115,30 +107,25 @@ get_global_ptr() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_scenes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_scenes() const { return _sdk->getNbScenes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::create_scene -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxScene *PhysxManager:: create_scene(PhysxSceneDesc &sceneDesc) { nassertr(sceneDesc.is_valid(),NULL); - //_desc.timeStepMethod = NX_TIMESTEP_FIXED; - //_desc.maxTimestep = 1.0f / 240.0f; - //_desc.maxIter = 8; + // _desc.timeStepMethod = NX_TIMESTEP_FIXED; _desc.maxTimestep = 1.0f + // 240.0f; _desc.maxIter = 8; sceneDesc._desc.flags |= NX_SF_ENABLE_ACTIVETRANSFORMS; sceneDesc._desc.flags |= NX_SF_SIMULATE_SEPARATE_THREAD; @@ -147,7 +134,7 @@ create_scene(PhysxSceneDesc &sceneDesc) { sceneDesc._desc.flags |= NX_SF_ENABLE_MULTITHREAD; sceneDesc._desc.threadMask=0xfffffffe; sceneDesc._desc.internalThreadCount = physx_internal_threads; - physx_cat.info() << "Multithreading enabled. " + physx_cat.info() << "Multithreading enabled. " << "Additional threads: " << physx_internal_threads << endl; } @@ -162,11 +149,9 @@ create_scene(PhysxSceneDesc &sceneDesc) { return scene; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_scene -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxScene *PhysxManager:: get_scene(unsigned int idx) const { @@ -178,22 +163,18 @@ get_scene(unsigned int idx) const { return scene; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_height_fields -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_height_fields() { return _sdk->getNbHeightFields(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::create_height_field -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxHeightField *PhysxManager:: create_height_field(PhysxHeightFieldDesc &desc) { @@ -210,11 +191,9 @@ create_height_field(PhysxHeightFieldDesc &desc) { return hf; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_height_field -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxHeightField *PhysxManager:: get_height_field(unsigned int idx) { @@ -223,22 +202,18 @@ get_height_field(unsigned int idx) { return (PhysxHeightField *)_heightfields[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_convex_meshes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_convex_meshes() { return _sdk->getNbConvexMeshes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_convex_mesh -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxConvexMesh *PhysxManager:: get_convex_mesh(unsigned int idx) { @@ -247,22 +222,18 @@ get_convex_mesh(unsigned int idx) { return (PhysxConvexMesh *)_convex_meshes[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_triangle_meshes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_triangle_meshes() { return _sdk->getNbTriangleMeshes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_triangle_mesh -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxTriangleMesh *PhysxManager:: get_triangle_mesh(unsigned int idx) { @@ -271,22 +242,18 @@ get_triangle_mesh(unsigned int idx) { return (PhysxTriangleMesh *)_triangle_meshes[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_cloth_meshes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_cloth_meshes() { return _sdk->getNbClothMeshes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_cloth_mesh -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxClothMesh *PhysxManager:: get_cloth_mesh(unsigned int idx) { @@ -295,22 +262,18 @@ get_cloth_mesh(unsigned int idx) { return (PhysxClothMesh *)_cloth_meshes[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_soft_body_meshes -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_soft_body_meshes() { return _sdk->getNbSoftBodyMeshes(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_soft_body_mesh -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSoftBodyMesh *PhysxManager:: get_soft_body_mesh(unsigned int idx) { @@ -319,22 +282,18 @@ get_soft_body_mesh(unsigned int idx) { return (PhysxSoftBodyMesh *)_softbody_meshes[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_ccd_skeletons -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxManager:: get_num_ccd_skeletons() { return _sdk->getNbCCDSkeletons(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::create_ccd_skeleton -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxCcdSkeleton *PhysxManager:: create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { @@ -352,11 +311,9 @@ create_ccd_skeleton(PhysxCcdSkeletonDesc &desc) { return skel; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_ccd_skeleton -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxCcdSkeleton *PhysxManager:: get_ccd_skeleton(unsigned int idx) { @@ -365,49 +322,38 @@ get_ccd_skeleton(unsigned int idx) { return (PhysxCcdSkeleton *)_ccd_skeletons[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::is_hardware_available -// Access: Published -// Description: Returns TRUE if a physcis hardware is available -// on the host system. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if a physcis hardware is available on the host system. + */ bool PhysxManager:: is_hardware_available() { return _sdk->getHWVersion() != NX_HW_VERSION_NONE; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_num_ppus -// Access: Published -// Description: Reports the number of PPUs installed in the host -// system. -//////////////////////////////////////////////////////////////////// +/** + * Reports the number of PPUs installed in the host system. + */ unsigned int PhysxManager:: get_num_ppus() { return _sdk->getNbPPUs(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_hw_version -// Access: Published -// Description: Reports the available revision of the PhysX -// Hardware. Returns 0 if there is no hardware present -// in the machine, 1 for the PhysX Athena revision -// 1.0 card. -//////////////////////////////////////////////////////////////////// +/** + * Reports the available revision of the PhysX Hardware. Returns 0 if there + * is no hardware present in the machine, 1 for the PhysX Athena revision 1.0 + * card. + */ unsigned int PhysxManager:: get_hw_version() { return _sdk->getHWVersion(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_internal_version -// Access: Published -// Description: Reports the internal API version number of the SDK. -//////////////////////////////////////////////////////////////////// +/** + * Reports the internal API version number of the SDK. + */ const char *PhysxManager:: get_internal_version() { @@ -427,33 +373,27 @@ get_internal_version() { return version.str().c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::set_parameter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxManager:: set_parameter(PhysxParameter param, float value) { _sdk->setParameter((NxParameter)param, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_parameter -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxManager:: get_parameter(PhysxParameter param) { return _sdk->getParameter((NxParameter)param); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxManager::get_sdk_error_string -// Access: Private -// Description: Returns the NxSDKCreateError enum as string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NxSDKCreateError enum as string. + */ const char *PhysxManager:: get_sdk_error_string(const NxSDKCreateError &error) { @@ -470,26 +410,22 @@ get_sdk_error_string(const NxSDKCreateError &error) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOutputStream::reportError -// Access: Private -// Description: Reports an error code from the PhysX SDK. -//////////////////////////////////////////////////////////////////// +/** + * Reports an error code from the PhysX SDK. + */ void PhysxManager::PhysxOutputStream:: reportError(NxErrorCode code, const char *message, const char *file, int line) { - physx_cat.error() << get_error_code_string(code) << ": " + physx_cat.error() << get_error_code_string(code) << ": " << message << endl; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOutputStream::get_error_code_string -// Access: Private -// Description: Returns the NxSDKCreateError enum as string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NxSDKCreateError enum as string. + */ const char *PhysxManager::PhysxOutputStream:: get_error_code_string(NxErrorCode code) { - + switch (code) { case NXE_NO_ERROR: return "NO_ERROR"; break; case NXE_INVALID_PARAMETER: return "INVALID_PARAMETER"; break; @@ -504,11 +440,9 @@ get_error_code_string(NxErrorCode code) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOutputStream::reportAssertViolation -// Access: Private -// Description: Reports an assertion violation from the PhysX SDK. -//////////////////////////////////////////////////////////////////// +/** + * Reports an assertion violation from the PhysX SDK. + */ NxAssertResponse PhysxManager::PhysxOutputStream:: reportAssertViolation(const char *message, const char *file, int line) { @@ -517,14 +451,11 @@ reportAssertViolation(const char *message, const char *file, int line) { return NX_AR_CONTINUE; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOutputStream::print -// Access: Private -// Description: Prints some debug text from the PhysX SDK. -//////////////////////////////////////////////////////////////////// +/** + * Prints some debug text from the PhysX SDK. + */ void PhysxManager::PhysxOutputStream:: print(const char *message) { nout << message; } - diff --git a/panda/src/physx/physxManager.h b/panda/src/physx/physxManager.h index b3d67588da..430bebd24f 100644 --- a/panda/src/physx/physxManager.h +++ b/panda/src/physx/physxManager.h @@ -1,16 +1,15 @@ -// Filename: physxManager.h -// Created by: enn0x (01Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxManager.h + * @author enn0x + * @date 2009-09-01 + */ #ifndef PHYSXMANAGER_H #define PHYSXMANAGER_H @@ -35,12 +34,10 @@ class PhysxOutputStream; class PhysxCcdSkeleton; class PhysxCcdSkeletonDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxManager -// Description : The central interface to the PhysX subsystem. -// Used e. g. for setting/retrieving global parameters -// or for creating scenes. -//////////////////////////////////////////////////////////////////// +/** + * The central interface to the PhysX subsystem. Used e. g. for + * setting/retrieving global parameters or for creating scenes. + */ class EXPCL_PANDAPHYSX PhysxManager : public PhysxEnums { protected: diff --git a/panda/src/physx/physxMask.I b/panda/src/physx/physxMask.I index 60d3474d7a..24b38ed612 100644 --- a/panda/src/physx/physxMask.I +++ b/panda/src/physx/physxMask.I @@ -1,47 +1,38 @@ -// Filename: physxMask.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMask.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMask:: PhysxMask() { _mask = 0xffffffff; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMask:: ~PhysxMask() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::get_mask -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NxU32 PhysxMask:: get_mask() const { return _mask; } - diff --git a/panda/src/physx/physxMask.cxx b/panda/src/physx/physxMask.cxx index 6f2959a7d4..f1e31437ea 100644 --- a/panda/src/physx/physxMask.cxx +++ b/panda/src/physx/physxMask.cxx @@ -1,24 +1,21 @@ -// Filename: physxMask.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMask.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxMask.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::all_on -// Access: Published -// Description: Returns a PhysxMask whose bits are all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxMask whose bits are all on. + */ PhysxMask PhysxMask:: all_on() { @@ -27,11 +24,9 @@ all_on() { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::all_off -// Access: Published -// Description: Returns a PhysxMask whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxMask whose bits are all off. + */ PhysxMask PhysxMask:: all_off() { @@ -40,12 +35,9 @@ all_off() { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::set_bit -// Access: Published -// Description: Sets the nth bit on. -// Index must be in the range [0, 31]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. Index must be in the range [0, 31]. + */ void PhysxMask:: set_bit(unsigned int idx) { @@ -53,12 +45,9 @@ set_bit(unsigned int idx) { _mask = _mask | (1 << idx); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::clear_bit -// Access: Published -// Description: Sets the nth bit off. -// Index must be in the range [0, 31]. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. Index must be in the range [0, 31]. + */ void PhysxMask:: clear_bit(unsigned int idx) { @@ -66,13 +55,10 @@ clear_bit(unsigned int idx) { _mask = _mask & ~(1 << idx); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. -// Index must be in the range [0, 31]. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. Index must be + * in the range [0, 31]. + */ bool PhysxMask:: get_bit(unsigned int idx) const { @@ -80,12 +66,9 @@ get_bit(unsigned int idx) const { return (_mask & (1 << idx)) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMask::output -// Access: Published -// Description: Writes the PhysxMask out as a list of ones and -// zeros. -//////////////////////////////////////////////////////////////////// +/** + * Writes the PhysxMask out as a list of ones and zeros. + */ void PhysxMask:: output(ostream &out) const { @@ -97,4 +80,3 @@ output(ostream &out) const { out << "/" << name << "/"; } - diff --git a/panda/src/physx/physxMask.h b/panda/src/physx/physxMask.h index 611a7466f2..5843d18939 100644 --- a/panda/src/physx/physxMask.h +++ b/panda/src/physx/physxMask.h @@ -1,16 +1,15 @@ -// Filename: physxMask.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMask.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXMASK_H #define PHYSXMASK_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMask -// Description : 32-bit bitmask class. -//////////////////////////////////////////////////////////////////// +/** + * 32-bit bitmask class. + */ class EXPCL_PANDAPHYSX PhysxMask { PUBLISHED: diff --git a/panda/src/physx/physxMaterial.I b/panda/src/physx/physxMaterial.I index 448b8f173f..22500d8a35 100644 --- a/panda/src/physx/physxMaterial.I +++ b/panda/src/physx/physxMaterial.I @@ -1,59 +1,47 @@ -// Filename: physxMaterial.I -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterial.I + * @author enn0x + * @date 2009-09-21 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMaterial:: PhysxMaterial() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMaterial:: ~PhysxMaterial() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxMaterial:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxMaterial:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxMaterial.cxx b/panda/src/physx/physxMaterial.cxx index 747cc64bdd..b583bcd000 100644 --- a/panda/src/physx/physxMaterial.cxx +++ b/panda/src/physx/physxMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: physxMaterial.cxx -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterial.cxx + * @author enn0x + * @date 2009-09-21 + */ #include "physxMaterial.h" #include "physxMaterialDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxMaterial::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMaterial:: link(NxMaterial *materialPtr) { @@ -35,11 +32,9 @@ link(NxMaterial *materialPtr) { scene->_materials.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMaterial:: unlink() { @@ -51,11 +46,9 @@ unlink() { scene->_materials.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMaterial:: release() { @@ -66,11 +59,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_scene -// Access: Published -// Description: Returns the scene that owns this material. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene that owns this material. + */ PhysxScene *PhysxMaterial:: get_scene() const { @@ -78,19 +69,16 @@ get_scene() const { return (PhysxScene *)(_ptr->getScene().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_material_index -// Access: Published -// Description: Returns the material index for this material. -// -// Materials are associated with mesh faces and shapes -// using material index identifiers. -// -// If you release a material while its material index -// is still in use by shapes or meshes, the material -// usage of these objects becomes undefined as the -// material index gets recycled. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material index for this material. + * + * Materials are associated with mesh faces and shapes using material index + * identifiers. + * + * If you release a material while its material index is still in use by + * shapes or meshes, the material usage of these objects becomes undefined as + * the material index gets recycled. + */ unsigned short PhysxMaterial:: get_material_index() const { @@ -98,12 +86,10 @@ get_material_index() const { return _ptr->getMaterialIndex(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::load_from_desc -// Access: Published -// Description: Loads the entire state of the material from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the material from a descriptor with a single + * call. + */ void PhysxMaterial:: load_from_desc(const PhysxMaterialDesc &materialDesc) { @@ -111,12 +97,9 @@ load_from_desc(const PhysxMaterialDesc &materialDesc) { _ptr->loadFromDesc(materialDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::save_to_desc -// Access: Published -// Description: Saves the state of the material object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the material object to a descriptor. + */ void PhysxMaterial:: save_to_desc(PhysxMaterialDesc & materialDesc) const { @@ -124,14 +107,11 @@ save_to_desc(PhysxMaterialDesc & materialDesc) const { _ptr->saveToDesc(materialDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_restitution -// Access: Published -// Description: Sets the coefficient of restitution. -// A coefficient of 0 makes the object bounce as -// little as possible, higher values up to 1.0 result -// in more bounce. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of restitution. A coefficient of 0 makes the object + * bounce as little as possible, higher values up to 1.0 result in more + * bounce. + */ void PhysxMaterial:: set_restitution(float restitution) { @@ -139,11 +119,9 @@ set_restitution(float restitution) { _ptr->setRestitution(restitution); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_restitution -// Access: Published -// Description: Returns the coefficient of restitution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coefficient of restitution. + */ float PhysxMaterial:: get_restitution() const { @@ -151,16 +129,12 @@ get_restitution() const { return _ptr->getRestitution(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_static_friction -// Access: Published -// Description: Sets the coefficient of static friction. -// The coefficient of static friction should be in the -// range [0, +inf]. -// If the flag MF_anisotropic is set, then this value -// is used for the primary direction of anisotropy -// (U axis). -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of static friction. The coefficient of static + * friction should be in the range [0, +inf]. If the flag MF_anisotropic is + * set, then this value is used for the primary direction of anisotropy (U + * axis). + */ void PhysxMaterial:: set_static_friction(float coef) { @@ -168,11 +142,9 @@ set_static_friction(float coef) { _ptr->setStaticFriction(coef); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_static_friction -// Access: Published -// Description: Returns the coefficient of static friction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coefficient of static friction. + */ float PhysxMaterial:: get_static_friction() const { @@ -180,18 +152,13 @@ get_static_friction() const { return _ptr->getStaticFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_dynamic_friction -// Access: Published -// Description: Sets the coefficient of dynamic friction. -// The coefficient of dynamic friction should be in -// [0, +inf]. If set to greater than staticFriction, -// the effective value of staticFriction will be -// increased to match. -// If the flag MF_anisotropic is set, then this value -// is used for the primary direction of anisotropy -// (U axis). -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of dynamic friction. The coefficient of dynamic + * friction should be in [0, +inf]. If set to greater than staticFriction, the + * effective value of staticFriction will be increased to match. If the flag + * MF_anisotropic is set, then this value is used for the primary direction of + * anisotropy (U axis). + */ void PhysxMaterial:: set_dynamic_friction(float coef) { @@ -199,11 +166,9 @@ set_dynamic_friction(float coef) { _ptr->setDynamicFriction(coef); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_dynamic_friction -// Access: Published -// Description: Returns the DynamicFriction value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DynamicFriction value. + */ float PhysxMaterial:: get_dynamic_friction() const { @@ -211,14 +176,11 @@ get_dynamic_friction() const { return _ptr->getDynamicFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_static_friction_v -// Access: Published -// Description: Sets the static friction coefficient along the -// secondary (V) axis. This is used when anisotropic -// friction is being applied. I.e. the flag -// MF_anisotropic is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the static friction coefficient along the secondary (V) axis. This is + * used when anisotropic friction is being applied. I.e. the flag + * MF_anisotropic is set. + */ void PhysxMaterial:: set_static_friction_v(float coef) { @@ -226,12 +188,9 @@ set_static_friction_v(float coef) { _ptr->setStaticFrictionV(coef); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_static_friction_v -// Access: Published -// Description: Returns the static friction coefficient for the -// V direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the static friction coefficient for the V direction. + */ float PhysxMaterial:: get_static_friction_v() const { @@ -239,14 +198,11 @@ get_static_friction_v() const { return _ptr->getStaticFrictionV(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_dynamic_friction_v -// Access: Published -// Description: Sets the dynamic friction coefficient along the -// secondary (V) axis. This is used when anisotropic -// friction is being applied. I.e. the flag -// MF_anisotropic is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dynamic friction coefficient along the secondary (V) axis. This + * is used when anisotropic friction is being applied. I.e. the flag + * MF_anisotropic is set. + */ void PhysxMaterial:: set_dynamic_friction_v(float coef) { @@ -254,12 +210,9 @@ set_dynamic_friction_v(float coef) { _ptr->setDynamicFrictionV(coef); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_dynamic_friction_v -// Access: Published -// Description: Returns the dynamic friction coefficient for the -// V direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dynamic friction coefficient for the V direction. + */ float PhysxMaterial:: get_dynamic_friction_v() const { @@ -267,11 +220,9 @@ get_dynamic_friction_v() const { return _ptr->getDynamicFrictionV(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_flag -// Access: Published -// Description: Sets the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of a single flag. + */ void PhysxMaterial:: set_flag(PhysxMaterialFlag flag, bool value) { @@ -288,11 +239,9 @@ set_flag(PhysxMaterialFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_flag -// Access: Published -// Description: Returns the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of a single flag. + */ bool PhysxMaterial:: get_flag(PhysxMaterialFlag flag) const { @@ -300,13 +249,10 @@ get_flag(PhysxMaterialFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_dir_of_anisotropy -// Access: Published -// Description: Sets the shape space direction (unit vector) of -// anisotropy. This is only used if the flag -// MF_anisotropic is set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shape space direction (unit vector) of anisotropy. This is only + * used if the flag MF_anisotropic is set. + */ void PhysxMaterial:: set_dir_of_anisotropy(const LVector3f dir) { @@ -314,11 +260,9 @@ set_dir_of_anisotropy(const LVector3f dir) { _ptr->setDirOfAnisotropy(PhysxManager::vec3_to_nxVec3(dir)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_dir_of_anisotropy -// Access: Published -// Description: Returns the direction of anisotropy value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction of anisotropy value. + */ LVector3f PhysxMaterial:: get_dir_of_anisotropy() const { @@ -326,15 +270,11 @@ get_dir_of_anisotropy() const { return PhysxManager::nxVec3_to_vec3(_ptr->getDirOfAnisotropy()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_friction_combine_mode -// Access: Published -// Description: Sets the friction combine mode. -// - CM_average : Average: (a + b)/2. -// - CM_min : Minimum: min(a,b). -// - CM_multiply : Multiply: a*b. -// - CM_max : Maximum: max(a,b). -//////////////////////////////////////////////////////////////////// +/** + * Sets the friction combine mode. - CM_average : Average: (a + b)/2. - + * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max : + * Maximum: max(a,b). + */ void PhysxMaterial:: set_friction_combine_mode(PhysxCombineMode mode) { @@ -342,11 +282,9 @@ set_friction_combine_mode(PhysxCombineMode mode) { _ptr->setFrictionCombineMode((NxCombineMode)mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_friction_combine_mode -// Access: Published -// Description: Returns the friction combine mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the friction combine mode. + */ PhysxEnums::PhysxCombineMode PhysxMaterial:: get_friction_combine_mode() const { @@ -354,15 +292,11 @@ get_friction_combine_mode() const { return (PhysxCombineMode)_ptr->getFrictionCombineMode(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::set_restitution_combine_mode -// Access: Published -// Description: Sets the restitution combine mode. -// - CM_average : Average: (a + b)/2. -// - CM_min : Minimum: min(a,b). -// - CM_multiply : Multiply: a*b. -// - CM_max : Maximum: max(a,b). -//////////////////////////////////////////////////////////////////// +/** + * Sets the restitution combine mode. - CM_average : Average: (a + b)/2. - + * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max : + * Maximum: max(a,b). + */ void PhysxMaterial:: set_restitution_combine_mode(PhysxCombineMode mode) { @@ -370,15 +304,12 @@ set_restitution_combine_mode(PhysxCombineMode mode) { _ptr->setRestitutionCombineMode((NxCombineMode)mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterial::get_restitution_combine_mode -// Access: Published -// Description: Returns the restitution combine mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the restitution combine mode. + */ PhysxEnums::PhysxCombineMode PhysxMaterial:: get_restitution_combine_mode() const { nassertr(_error_type == ET_ok, CM_average); return (PhysxCombineMode)_ptr->getRestitutionCombineMode(); } - diff --git a/panda/src/physx/physxMaterial.h b/panda/src/physx/physxMaterial.h index 6a0e3e8cf6..c6e6b4d2d2 100644 --- a/panda/src/physx/physxMaterial.h +++ b/panda/src/physx/physxMaterial.h @@ -1,16 +1,15 @@ -// Filename: physxMaterial.h -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterial.h + * @author enn0x + * @date 2009-09-21 + */ #ifndef PHYSXMATERIAL_H #define PHYSXMATERIAL_H @@ -25,29 +24,23 @@ class PhysxScene; class PhysxMaterialDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxMaterial -// Description : A class for describing a shape's surface -// properties. -// -// You can create a material which has different -// friction coefficients depending on the direction -// that a body in contact is trying to move in. This -// is called anisotropic friction. -// -// Anisotropic friction is useful for modeling things -// like sledges, skis etc -// -// When you create an anisotropic material you specify -// the default friction parameters and also friction -// parameters for the V axis. The friction parameters -// for the V axis are applied to motion along the -// direction of anisotropy (dirOfAnisotropy). -// -// Default material: You can change the properties of -// the default material by querying for material -// index 0. -//////////////////////////////////////////////////////////////////// +/** + * A class for describing a shape's surface properties. + * + * You can create a material which has different friction coefficients + * depending on the direction that a body in contact is trying to move in. + * This is called anisotropic friction. + * + * Anisotropic friction is useful for modeling things like sledges, skis etc + * + * When you create an anisotropic material you specify the default friction + * parameters and also friction parameters for the V axis. The friction + * parameters for the V axis are applied to motion along the direction of + * anisotropy (dirOfAnisotropy). + * + * Default material: You can change the properties of the default material by + * querying for material index 0. + */ class EXPCL_PANDAPHYSX PhysxMaterial : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -83,7 +76,6 @@ PUBLISHED: INLINE void ls() const; INLINE void ls(ostream &out, int indent_level=0) const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -96,14 +88,13 @@ public: private: NxMaterial *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxMaterial", + register_type(_type_handle, "PhysxMaterial", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxMaterialDesc.I b/panda/src/physx/physxMaterialDesc.I index e5e7fef644..a63c56b69a 100644 --- a/panda/src/physx/physxMaterialDesc.I +++ b/panda/src/physx/physxMaterialDesc.I @@ -1,58 +1,46 @@ -// Filename: physxMaterialDesc.I -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterialDesc.I + * @author enn0x + * @date 2009-09-21 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMaterialDesc:: PhysxMaterialDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMaterialDesc:: ~PhysxMaterialDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxMaterialDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxMaterialDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxMaterialDesc.cxx b/panda/src/physx/physxMaterialDesc.cxx index 74348b91e2..df226029bb 100644 --- a/panda/src/physx/physxMaterialDesc.cxx +++ b/panda/src/physx/physxMaterialDesc.cxx @@ -1,102 +1,79 @@ -// Filename: physxMaterialDesc.cxx -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterialDesc.cxx + * @author enn0x + * @date 2009-09-21 + */ #include "physxMaterialDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_restitution -// Access: Published -// Description: Sets the coefficient of restitution -- 0 makes the -// object bounce as little as possible, higher values -// up to 1.0 result in more bounce. Note that values -// close to or above 1 may cause stability problems -// and/or increasing energy. Range: [0,1] -// Default: 0.0 -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of restitution -- 0 makes the object bounce as little + * as possible, higher values up to 1.0 result in more bounce. Note that + * values close to or above 1 may cause stability problems and/or increasing + * energy. Range: [0,1] Default: 0.0 + */ void PhysxMaterialDesc:: set_restitution(float restitution) { _desc.restitution = restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_static_friction -// Access: Published -// Description: Sets the coefficient of static friction -- should -// be in [0, +inf]. -// If the flag MF_anisotropic is set, then this value -// is used for the primary direction of anisotropy -// (U axis). -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of static friction -- should be in [0, +inf]. If the + * flag MF_anisotropic is set, then this value is used for the primary + * direction of anisotropy (U axis). + */ void PhysxMaterialDesc:: set_static_friction(float coef) { _desc.staticFriction = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_dynamic_friction -// Access: Published -// Description: Sets the coefficient of dynamic friction -- should -// be in [0, +inf]. If set to greater than -// staticFriction, the effective value of staticFriction -// will be increased to match. -// If the flag MF_anisotropic is set, then this value -// is used for the primary direction of anisotropy -// (U axis). -//////////////////////////////////////////////////////////////////// +/** + * Sets the coefficient of dynamic friction -- should be in [0, +inf]. If set + * to greater than staticFriction, the effective value of staticFriction will + * be increased to match. If the flag MF_anisotropic is set, then this value + * is used for the primary direction of anisotropy (U axis). + */ void PhysxMaterialDesc:: set_dynamic_friction(float coef) { _desc.dynamicFriction = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_static_friction_v -// Access: Published -// Description: Sets the anisotropic static friction coefficient -// for along the secondary (V) axis of anisotropy. -// This is only used if the flag MF_anisotropic is -// set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the anisotropic static friction coefficient for along the secondary + * (V) axis of anisotropy. This is only used if the flag MF_anisotropic is + * set. + */ void PhysxMaterialDesc:: set_static_friction_v(float coef) { _desc.staticFrictionV = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_dynamic_friction_v -// Access: Published -// Description: Sets the anisotropic dynamic friction coefficient -// for along the secondary (V) axis of anisotropy. -// This is only used if the flag MF_anisotropic is -// set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the anisotropic dynamic friction coefficient for along the secondary + * (V) axis of anisotropy. This is only used if the flag MF_anisotropic is + * set. + */ void PhysxMaterialDesc:: set_dynamic_friction_v(float coef) { _desc.dynamicFrictionV = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_flag -// Access: Published -// Description: Sets flags which control the behavior of a -// material. -//////////////////////////////////////////////////////////////////// +/** + * Sets flags which control the behavior of a material. + */ void PhysxMaterialDesc:: set_flag(PhysxMaterialFlag flag, bool value) { @@ -108,151 +85,117 @@ set_flag(PhysxMaterialFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_dir_of_anisotropy -// Access: Published -// Description: Sets the shape space direction (unit vector) of -// anisotropy. -// This is only used if the flag MF_anisotropic is -// set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the shape space direction (unit vector) of anisotropy. This is only + * used if the flag MF_anisotropic is set. + */ void PhysxMaterialDesc:: set_dir_of_anisotropy(const LVector3f dir) { _desc.dirOfAnisotropy = PhysxManager::vec3_to_nxVec3(dir); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_friction_combine_mode -// Access: Published -// Description: Sets the friction combine mode. -// - CM_average : Average: (a + b)/2. -// - CM_min : Minimum: min(a,b). -// - CM_multiply : Multiply: a*b. -// - CM_max : Maximum: max(a,b). -//////////////////////////////////////////////////////////////////// +/** + * Sets the friction combine mode. - CM_average : Average: (a + b)/2. - + * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max : + * Maximum: max(a,b). + */ void PhysxMaterialDesc:: set_friction_combine_mode(PhysxCombineMode mode) { _desc.frictionCombineMode = (NxCombineMode)mode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::set_restitution_combine_mode -// Access: Published -// Description: Sets the restitution combine mode. -// - CM_average : Average: (a + b)/2. -// - CM_min : Minimum: min(a,b). -// - CM_multiply : Multiply: a*b. -// - CM_max : Maximum: max(a,b). -//////////////////////////////////////////////////////////////////// +/** + * Sets the restitution combine mode. - CM_average : Average: (a + b)/2. - + * CM_min : Minimum: min(a,b). - CM_multiply : Multiply: a*b. - CM_max : + * Maximum: max(a,b). + */ void PhysxMaterialDesc:: set_restitution_combine_mode(PhysxCombineMode mode) { _desc.restitutionCombineMode = (NxCombineMode)mode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_restitution -// Access: Published -// Description: Returns the coefficient of restitution. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coefficient of restitution. + */ float PhysxMaterialDesc:: get_restitution() const { return _desc.restitution; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_static_friction -// Access: Published -// Description: Retruns the coefficient of static friction. -//////////////////////////////////////////////////////////////////// +/** + * Retruns the coefficient of static friction. + */ float PhysxMaterialDesc:: get_static_friction() const { return _desc.staticFriction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_dynamic_friction -// Access: Published -// Description: Returns the coefficient of dynamic friction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coefficient of dynamic friction. + */ float PhysxMaterialDesc:: get_dynamic_friction() const { return _desc.dynamicFriction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_static_friction_v -// Access: Published -// Description: Returns the anisotropic static friction coefficient -// for along the secondary (V) axis of anisotropy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anisotropic static friction coefficient for along the secondary + * (V) axis of anisotropy. + */ float PhysxMaterialDesc:: get_static_friction_v() const { return _desc.staticFrictionV; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_dynamic_friction_v -// Access: Published -// Description: Returns the anisotropic dynamic friction -// coefficient for along the secondary (V) axis of -// anisotropy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anisotropic dynamic friction coefficient for along the + * secondary (V) axis of anisotropy. + */ float PhysxMaterialDesc:: get_dynamic_friction_v() const { return _desc.dynamicFrictionV; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_flag -// Access: Published -// Description: Returns flags which control the behavior of a -// material. -//////////////////////////////////////////////////////////////////// +/** + * Returns flags which control the behavior of a material. + */ bool PhysxMaterialDesc:: get_flag(PhysxMaterialFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_dir_of_anisotropy -// Access: Published -// Description: Returns the shape space direction (unit vector) of -// anisotropy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the shape space direction (unit vector) of anisotropy. + */ LVector3f PhysxMaterialDesc:: get_dir_of_anisotropy() const { return PhysxManager::nxVec3_to_vec3(_desc.dirOfAnisotropy); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_friction_combine_mode -// Access: Published -// Description: Returns the friction combine mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the friction combine mode. + */ PhysxEnums::PhysxCombineMode PhysxMaterialDesc:: get_friction_combine_mode() const { return (PhysxCombineMode)_desc.frictionCombineMode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMaterialDesc::get_restitution_combine_mode -// Access: Published -// Description: Returns the restitution combine mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the restitution combine mode. + */ PhysxEnums::PhysxCombineMode PhysxMaterialDesc:: get_restitution_combine_mode() const { return (PhysxCombineMode)_desc.restitutionCombineMode; } - diff --git a/panda/src/physx/physxMaterialDesc.h b/panda/src/physx/physxMaterialDesc.h index 75c04f7f7c..7210530761 100644 --- a/panda/src/physx/physxMaterialDesc.h +++ b/panda/src/physx/physxMaterialDesc.h @@ -1,16 +1,15 @@ -// Filename: physxMaterialDesc.h -// Created by: enn0x (21Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMaterialDesc.h + * @author enn0x + * @date 2009-09-21 + */ #ifndef PHYSXMATERIALDESC_H #define PHYSXMATERIALDESC_H @@ -20,10 +19,9 @@ #include "physxEnums.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMaterialDesc -// Description : Descriptor class for materials. See PhysxMaterial. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for materials. See PhysxMaterial. + */ class EXPCL_PANDAPHYSX PhysxMaterialDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxMemoryReadBuffer.cxx b/panda/src/physx/physxMemoryReadBuffer.cxx index 639d54debc..d70972f58f 100644 --- a/panda/src/physx/physxMemoryReadBuffer.cxx +++ b/panda/src/physx/physxMemoryReadBuffer.cxx @@ -1,44 +1,37 @@ -// Filename: physxMemoryReadBuffer.cxx -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMemoryReadBuffer.cxx + * @author enn0x + * @date 2009-10-11 + */ #include "physxMemoryReadBuffer.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMemoryReadBuffer::PhysxMemoryReadBuffer(const NxU8 *data) : buffer(data) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMemoryReadBuffer::~PhysxMemoryReadBuffer() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readByte -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU8 PhysxMemoryReadBuffer::readByte() const { NxU8 b; @@ -47,11 +40,9 @@ NxU8 PhysxMemoryReadBuffer::readByte() const return b; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readWord -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU16 PhysxMemoryReadBuffer::readWord() const { NxU16 w; @@ -60,11 +51,9 @@ NxU16 PhysxMemoryReadBuffer::readWord() const return w; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readDword -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxU32 PhysxMemoryReadBuffer::readDword() const { NxU32 d; @@ -73,11 +62,9 @@ NxU32 PhysxMemoryReadBuffer::readDword() const return d; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readFloat -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxMemoryReadBuffer::readFloat() const { float f; @@ -86,11 +73,9 @@ float PhysxMemoryReadBuffer::readFloat() const return f; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readDouble -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ double PhysxMemoryReadBuffer::readDouble() const { double f; @@ -99,14 +84,11 @@ double PhysxMemoryReadBuffer::readDouble() const return f; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryReadBuffer::readBuffer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMemoryReadBuffer::readBuffer(void *dest, NxU32 size) const { memcpy(dest, buffer, size); buffer += size; } - diff --git a/panda/src/physx/physxMemoryReadBuffer.h b/panda/src/physx/physxMemoryReadBuffer.h index b2e418667e..5aa791be95 100644 --- a/panda/src/physx/physxMemoryReadBuffer.h +++ b/panda/src/physx/physxMemoryReadBuffer.h @@ -1,16 +1,15 @@ -// Filename: physxMemoryReadBuffer.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMemoryReadBuffer.h + * @author enn0x + * @date 2009-10-11 + */ #ifndef PHYSXMEMORYREADBUFFER_H #define PHYSXMEMORYREADBUFFER_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMemoryReadBuffer -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxMemoryReadBuffer : public NxStream { public: diff --git a/panda/src/physx/physxMemoryWriteBuffer.cxx b/panda/src/physx/physxMemoryWriteBuffer.cxx index b84f8c7c7c..f690b1e327 100644 --- a/panda/src/physx/physxMemoryWriteBuffer.cxx +++ b/panda/src/physx/physxMemoryWriteBuffer.cxx @@ -1,99 +1,82 @@ -// Filename: physxMemoryWriteBuffer.cxx -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMemoryWriteBuffer.cxx + * @author enn0x + * @date 2009-10-11 + */ #include "physxMemoryWriteBuffer.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMemoryWriteBuffer::PhysxMemoryWriteBuffer() : currentSize(0), maxSize(0), data(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMemoryWriteBuffer::~PhysxMemoryWriteBuffer() { NxGetPhysicsSDKAllocator()->free(data); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeByte -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeByte(NxU8 b) { storeBuffer(&b, sizeof(NxU8)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeWord -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeWord(NxU16 w) { storeBuffer(&w, sizeof(NxU16)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeDword -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeDword(NxU32 d) { storeBuffer(&d, sizeof(NxU32)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeFloat -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeFloat(NxReal f) { storeBuffer(&f, sizeof(NxReal)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeDouble -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeDouble(NxF64 f) { storeBuffer(&f, sizeof(NxF64)); return *this; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMemoryWriteBuffer::storeBuffer -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxStream &PhysxMemoryWriteBuffer::storeBuffer(const void *buffer, NxU32 size) { NxU32 expectedSize = currentSize + size; @@ -113,4 +96,3 @@ NxStream &PhysxMemoryWriteBuffer::storeBuffer(const void *buffer, NxU32 size) currentSize += size; return *this; } - diff --git a/panda/src/physx/physxMemoryWriteBuffer.h b/panda/src/physx/physxMemoryWriteBuffer.h index 12e59c00c0..3af1a70b34 100644 --- a/panda/src/physx/physxMemoryWriteBuffer.h +++ b/panda/src/physx/physxMemoryWriteBuffer.h @@ -1,16 +1,15 @@ -// Filename: physxMemoryWriteBuffer.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMemoryWriteBuffer.h + * @author enn0x + * @date 2009-10-11 + */ #ifndef PHYSXMEMORYWRITEBUFFER_H #define PHYSXMEMORYWRITEBUFFER_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMemoryWriteBuffer -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxMemoryWriteBuffer : public NxStream { public: diff --git a/panda/src/physx/physxMeshHash.I b/panda/src/physx/physxMeshHash.I index 28fab7ab55..ca956765a5 100644 --- a/panda/src/physx/physxMeshHash.I +++ b/panda/src/physx/physxMeshHash.I @@ -1,23 +1,19 @@ -// Filename: physxMeshHash.I -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshHash.I + * @author enn0x + * @date 2010-09-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMeshHash:: PhysxMeshHash() { @@ -35,21 +31,17 @@ PhysxMeshHash() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMeshHash:: ~PhysxMeshHash() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::hash_function -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PhysxMeshHash:: hash_function(int xi, int yi, int zi) const { @@ -57,11 +49,9 @@ hash_function(int xi, int yi, int zi) const { return h % _hashIndexSize; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::cell_coord_of -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxMeshHash:: cell_coord_of(const NxVec3 &v, int &xi, int &yi, int &zi) const { @@ -70,15 +60,11 @@ cell_coord_of(const NxVec3 &v, int &xi, int &yi, int &zi) const { zi = (int)(v.z * _invSpacing); if (v.z < 0.0f) zi--; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::get_grid_spacing -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE NxF32 PhysxMeshHash:: get_grid_spacing() const { return 1.0f / _invSpacing; } - - diff --git a/panda/src/physx/physxMeshHash.cxx b/panda/src/physx/physxMeshHash.cxx index ee486680bb..bba45e710e 100644 --- a/panda/src/physx/physxMeshHash.cxx +++ b/panda/src/physx/physxMeshHash.cxx @@ -1,24 +1,21 @@ -// Filename: physxMeshHash.cxx -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshHash.cxx + * @author enn0x + * @date 2010-09-13 + */ #include "physxMeshHash.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::quick_sort -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: quick_sort(pvector &itemIndices, int l, int r) { @@ -42,11 +39,9 @@ quick_sort(pvector &itemIndices, int l, int r) { if (i < r) quick_sort(itemIndices, i, r); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::compress_indices -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: compress_indices(pvector &itemIndices) { @@ -76,11 +71,9 @@ compress_indices(pvector &itemIndices) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::set_grid_spacing -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: set_grid_spacing(float spacing) { @@ -90,11 +83,9 @@ set_grid_spacing(float spacing) { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::reset -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: reset() { @@ -102,11 +93,9 @@ reset() { _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::add -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: add(const NxBounds3 &bounds, int itemIndex) { @@ -130,7 +119,7 @@ add(const NxBounds3 &bounds, int itemIndex) { if (r.timeStamp != _time || r.first < 0) entry.next = -1; - else + else entry.next = r.first; r.first = n; @@ -142,11 +131,9 @@ add(const NxBounds3 &bounds, int itemIndex) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::add -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: add(const NxVec3 &pos, int itemIndex) { @@ -161,9 +148,9 @@ add(const NxVec3 &pos, int itemIndex) { MeshHashRoot &r = _hashIndex[h]; int n = _entries.size(); - if (r.timeStamp != _time || r.first < 0) + if (r.timeStamp != _time || r.first < 0) entry.next = -1; - else + else entry.next = r.first; r.first = n; @@ -172,11 +159,9 @@ add(const NxVec3 &pos, int itemIndex) { _entries.push_back(entry); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::query -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: query(const NxBounds3 &bounds, pvector &itemIndices, int maxIndices) { @@ -210,11 +195,9 @@ query(const NxBounds3 &bounds, pvector &itemIndices, int maxIndices) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::query_unique -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: query_unique(const NxBounds3 &bounds, pvector &itemIndices, int maxIndices) { @@ -222,11 +205,9 @@ query_unique(const NxBounds3 &bounds, pvector &itemIndices, int maxIndices) compress_indices(itemIndices); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::query -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: query(const NxVec3 &pos, pvector &itemIndices, int maxIndices) { @@ -249,15 +230,12 @@ query(const NxVec3 &pos, pvector &itemIndices, int maxIndices) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshHash::query_unique -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshHash:: query_unique(const NxVec3 &pos, pvector &itemIndices, int maxIndices) { query(pos, itemIndices, maxIndices); compress_indices(itemIndices); } - diff --git a/panda/src/physx/physxMeshHash.h b/panda/src/physx/physxMeshHash.h index 031d6f90b3..08301e4ab2 100644 --- a/panda/src/physx/physxMeshHash.h +++ b/panda/src/physx/physxMeshHash.h @@ -1,16 +1,15 @@ -// Filename: physxMeshHash.h -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshHash.h + * @author enn0x + * @date 2010-09-13 + */ #ifndef PHYSXMESHHASH_H #define PHYSXMESHHASH_H @@ -19,12 +18,10 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMeshHash -// Description : Utility class used in building links between a -// tetrahedron mesh (soft body) and a triangle mesh -// used for rendering the soft body. -//////////////////////////////////////////////////////////////////// +/** + * Utility class used in building links between a tetrahedron mesh (soft body) + * and a triangle mesh used for rendering the soft body. + */ class PhysxMeshHash { public: diff --git a/panda/src/physx/physxMeshPool.I b/panda/src/physx/physxMeshPool.I index 3fdc3c8922..113ba4a524 100644 --- a/panda/src/physx/physxMeshPool.I +++ b/panda/src/physx/physxMeshPool.I @@ -1,35 +1,28 @@ -// Filename: physxMeshPool.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshPool.I + * @author enn0x + * @date 2009-10-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMeshPool:: PhysxMeshPool() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMeshPool:: ~PhysxMeshPool() { } - diff --git a/panda/src/physx/physxMeshPool.cxx b/panda/src/physx/physxMeshPool.cxx index 4e89624cc0..71fb20f495 100644 --- a/panda/src/physx/physxMeshPool.cxx +++ b/panda/src/physx/physxMeshPool.cxx @@ -1,16 +1,15 @@ -// Filename: physxMeshPool.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshPool.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxMeshPool.h" #include "physxConvexMesh.h" @@ -26,11 +25,9 @@ PhysxMeshPool::TriangleMeshes PhysxMeshPool::_triangle_meshes; PhysxMeshPool::ClothMeshes PhysxMeshPool::_cloth_meshes; PhysxMeshPool::SoftbodyMeshes PhysxMeshPool::_softbody_meshes; -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::check_file -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMeshPool:: check_filename(const Filename &fn) { @@ -47,11 +44,9 @@ check_filename(const Filename &fn) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::load_convex_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxConvexMesh *PhysxMeshPool:: load_convex_mesh(const Filename &fn) { @@ -86,11 +81,9 @@ load_convex_mesh(const Filename &fn) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::load_triangle_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxTriangleMesh *PhysxMeshPool:: load_triangle_mesh(const Filename &fn) { @@ -125,11 +118,9 @@ load_triangle_mesh(const Filename &fn) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::load_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxClothMesh *PhysxMeshPool:: load_cloth_mesh(const Filename &fn) { @@ -164,11 +155,9 @@ load_cloth_mesh(const Filename &fn) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::load_soft_body_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSoftBodyMesh *PhysxMeshPool:: load_soft_body_mesh(const Filename &fn) { @@ -203,11 +192,9 @@ load_soft_body_mesh(const Filename &fn) { return mesh; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::release_convex_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMeshPool:: release_convex_mesh(PhysxConvexMesh *mesh) { @@ -222,11 +209,9 @@ release_convex_mesh(PhysxConvexMesh *mesh) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::release_triangle_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMeshPool:: release_triangle_mesh(PhysxTriangleMesh *mesh) { @@ -241,11 +226,9 @@ release_triangle_mesh(PhysxTriangleMesh *mesh) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::release_cloth_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMeshPool:: release_cloth_mesh(PhysxClothMesh *mesh) { @@ -260,11 +243,9 @@ release_cloth_mesh(PhysxClothMesh *mesh) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::release_soft_body_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMeshPool:: release_soft_body_mesh(PhysxSoftBodyMesh *mesh) { @@ -279,21 +260,17 @@ release_soft_body_mesh(PhysxSoftBodyMesh *mesh) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::list_content -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshPool:: list_contents() { list_contents(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMeshPool::list_content -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMeshPool:: list_contents(ostream &out) { @@ -307,7 +284,7 @@ list_contents(ostream &out) { PhysxConvexMesh *mesh = (*it).second; out << " " << fn.get_fullpath() - << " (convex mesh, " << mesh->ptr()->getReferenceCount() + << " (convex mesh, " << mesh->ptr()->getReferenceCount() << " references)" << endl; } } @@ -320,7 +297,7 @@ list_contents(ostream &out) { PhysxTriangleMesh *mesh = (*it).second; out << " " << fn.get_fullpath() - << " (triangle mesh, " << mesh->ptr()->getReferenceCount() + << " (triangle mesh, " << mesh->ptr()->getReferenceCount() << " references)\n"; } } @@ -333,7 +310,7 @@ list_contents(ostream &out) { PhysxClothMesh *mesh = (*it).second; out << " " << fn.get_fullpath() - << " (cloth mesh, " << mesh->ptr()->getReferenceCount() + << " (cloth mesh, " << mesh->ptr()->getReferenceCount() << " references)\n"; } } @@ -346,7 +323,7 @@ list_contents(ostream &out) { PhysxSoftBodyMesh *mesh = (*it).second; out << " " << fn.get_fullpath() - << " (soft body mesh, " << mesh->ptr()->getReferenceCount() + << " (soft body mesh, " << mesh->ptr()->getReferenceCount() << " references)\n"; } } @@ -357,13 +334,12 @@ list_contents(ostream &out) { out << " Total number of convex meshes: " << sdk->getNbConvexMeshes() << " created, " << _convex_meshes.size() << " registred\n"; - out << " Total number of triangle meshes: " << sdk->getNbTriangleMeshes() + out << " Total number of triangle meshes: " << sdk->getNbTriangleMeshes() << " created, " << _triangle_meshes.size() << " registred\n"; - out << " Total number of cloth meshes: " << sdk->getNbClothMeshes() + out << " Total number of cloth meshes: " << sdk->getNbClothMeshes() << " created, " << _cloth_meshes.size() << " registred\n"; - out << " Total number of soft body meshes: " << sdk->getNbSoftBodyMeshes() + out << " Total number of soft body meshes: " << sdk->getNbSoftBodyMeshes() << " created, " << _softbody_meshes.size() << " registred\n"; } - diff --git a/panda/src/physx/physxMeshPool.h b/panda/src/physx/physxMeshPool.h index 5dd14ff656..30bec8141b 100644 --- a/panda/src/physx/physxMeshPool.h +++ b/panda/src/physx/physxMeshPool.h @@ -1,16 +1,15 @@ -// Filename: physxMeshPool.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMeshPool.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXMESHPOOL_H #define PHYSXMESHPOOL_H @@ -28,14 +27,12 @@ class PhysxTriangleMesh; class PhysxClothMesh; class PhysxSoftBodyMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxMeshPool -// Description : This class unifies all references to the same -// filename, so that multiple attempts to load the -// same mesh will return the same pointer. -// The mesh filename is automatically resolved before -// an attempt to load the mesh is made. -//////////////////////////////////////////////////////////////////// +/** + * This class unifies all references to the same filename, so that multiple + * attempts to load the same mesh will return the same pointer. The mesh + * filename is automatically resolved before an attempt to load the mesh is + * made. + */ class EXPCL_PANDAPHYSX PhysxMeshPool { PUBLISHED: diff --git a/panda/src/physx/physxMotorDesc.I b/panda/src/physx/physxMotorDesc.I index b41d743ed2..5511500ff5 100644 --- a/panda/src/physx/physxMotorDesc.I +++ b/panda/src/physx/physxMotorDesc.I @@ -1,33 +1,27 @@ -// Filename: physxMotorDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMotorDesc.I + * @author enn0x + * @date 2009-09-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMotorDesc:: PhysxMotorDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMotorDesc:: PhysxMotorDesc(float velTarget, float maxForce, bool freeSpin) { @@ -36,13 +30,10 @@ PhysxMotorDesc(float velTarget, float maxForce, bool freeSpin) { _desc.freeSpin = freeSpin; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxMotorDesc:: ~PhysxMotorDesc() { } - diff --git a/panda/src/physx/physxMotorDesc.cxx b/panda/src/physx/physxMotorDesc.cxx index e2a72360f0..1f230905d1 100644 --- a/panda/src/physx/physxMotorDesc.cxx +++ b/panda/src/physx/physxMotorDesc.cxx @@ -1,82 +1,68 @@ -// Filename: physxMotorDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMotorDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxMotorDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::set_vel_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMotorDesc:: set_vel_target(float velTarget) { _desc.velTarget = velTarget; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::set_max_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMotorDesc:: set_max_force(float maxForce) { _desc.maxForce = maxForce; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::set_free_spin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxMotorDesc:: set_free_spin(bool freeSpin) { _desc.freeSpin = (NX_BOOL)freeSpin; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::get_vel_target -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxMotorDesc:: get_vel_target() const { return _desc.velTarget; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::get_max_force -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxMotorDesc:: get_max_force() const { return _desc.maxForce; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxMotorDesc::get_free_spin -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxMotorDesc:: get_free_spin() const { return (_desc.freeSpin) ? true : false; } - diff --git a/panda/src/physx/physxMotorDesc.h b/panda/src/physx/physxMotorDesc.h index fd3595fba1..9aab85fd16 100644 --- a/panda/src/physx/physxMotorDesc.h +++ b/panda/src/physx/physxMotorDesc.h @@ -1,16 +1,15 @@ -// Filename: physxMotorDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxMotorDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXMOTORDESC_H #define PHYSXMOTORDESC_H @@ -19,15 +18,11 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxMotorDesc -// Description : Describes a joint motor. Some joints can be -// motorized, this allows them to apply a force to -// cause attached actors to move. Joints which can be -// motorized: -// - PhysxPulleyJoint -// - PhysxRevoluteJoint -//////////////////////////////////////////////////////////////////// +/** + * Describes a joint motor. Some joints can be motorized, this allows them to + * apply a force to cause attached actors to move. Joints which can be + * motorized: - PhysxPulleyJoint - PhysxRevoluteJoint + */ class EXPCL_PANDAPHYSX PhysxMotorDesc { PUBLISHED: diff --git a/panda/src/physx/physxObject.I b/panda/src/physx/physxObject.I index d4d7fc3cb9..844aefd182 100644 --- a/panda/src/physx/physxObject.I +++ b/panda/src/physx/physxObject.I @@ -1,41 +1,33 @@ -// Filename: physxObject.I -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObject.I + * @author enn0x + * @date 2009-09-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxObject:: PhysxObject() { _error_type = ET_empty; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxObject:: ~PhysxObject() { #ifdef HAVE_PYTHON - // Decrement the reference count of all - // held Python objects. + // Decrement the reference count of all held Python objects. PythonTagData::const_iterator ti; for (ti = _python_tag_data.begin(); ti != _python_tag_data.end(); ++ti) { PyObject *value = (*ti).second; @@ -45,22 +37,18 @@ INLINE PhysxObject:: } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::has_python_tags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PhysxObject:: has_python_tags() const { return _python_tag_data.empty() ? false : true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::set_python_tag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxObject:: set_python_tag(const string &key, PyObject *value) { @@ -70,10 +58,9 @@ set_python_tag(const string &key, PyObject *value) { result = _python_tag_data.insert(PythonTagData::value_type(key, value)); if (!result.second) { - // The insert was unsuccessful; that means the key was already - // present in the map. In this case, we should decrement the - // original value's reference count and replace it with the new - // object. + // The insert was unsuccessful; that means the key was already present in + // the map. In this case, we should decrement the original value's + // reference count and replace it with the new object. PythonTagData::iterator ti = result.first; PyObject *old_value = (*ti).second; Py_XDECREF(old_value); @@ -81,11 +68,9 @@ set_python_tag(const string &key, PyObject *value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::get_python_tag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PyObject *PhysxObject:: get_python_tag(const string &key) const { @@ -102,11 +87,9 @@ get_python_tag(const string &key) const { return Py_None; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::has_python_tag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PhysxObject:: has_python_tag(const string &key) const { @@ -115,11 +98,9 @@ has_python_tag(const string &key) const { return (ti != _python_tag_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObject::clear_python_tag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxObject:: clear_python_tag(const string &key) { @@ -133,4 +114,3 @@ clear_python_tag(const string &key) { } } #endif // HAVE_PYTHON - diff --git a/panda/src/physx/physxObject.cxx b/panda/src/physx/physxObject.cxx index b9302993ba..72a90b038b 100644 --- a/panda/src/physx/physxObject.cxx +++ b/panda/src/physx/physxObject.cxx @@ -1,18 +1,16 @@ -// Filename: physxObject.cxx -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObject.cxx + * @author enn0x + * @date 2009-09-11 + */ #include "physxObject.h" TypeHandle PhysxObject::_type_handle; - diff --git a/panda/src/physx/physxObject.h b/panda/src/physx/physxObject.h index b3b0c23505..717405736c 100644 --- a/panda/src/physx/physxObject.h +++ b/panda/src/physx/physxObject.h @@ -1,16 +1,15 @@ -// Filename: physxObject.h -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObject.h + * @author enn0x + * @date 2009-09-11 + */ #ifndef PHYSXOBJECT_H #define PHYSXOBJECT_H @@ -23,10 +22,9 @@ #include #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Class : PhysxObject -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxObject : public TypedReferenceCount { #ifdef HAVE_PYTHON @@ -61,14 +59,13 @@ private: PythonTagData _python_tag_data; #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { TypedReferenceCount::init_type(); - register_type(_type_handle, "PhysxObject", + register_type(_type_handle, "PhysxObject", TypedReferenceCount::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxObjectCollection.I b/panda/src/physx/physxObjectCollection.I index 07cb4191ea..128d031bfc 100644 --- a/panda/src/physx/physxObjectCollection.I +++ b/panda/src/physx/physxObjectCollection.I @@ -1,22 +1,19 @@ -// Filename: physxObjectCollection.I -// Created by: enn0x (08Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObjectCollection.I + * @author enn0x + * @date 2009-11-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE unsigned int PhysxObjectCollection:: size() const { @@ -24,11 +21,9 @@ size() const { return _objects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::add -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PhysxObjectCollection:: add(PT(T) object) { @@ -36,11 +31,9 @@ add(PT(T) object) { _objects.push_back(object); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::remove -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PhysxObjectCollection:: remove(PT(T) object) { @@ -57,13 +50,10 @@ remove(PT(T) object) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::get -// Access: Public -// Description: Returns the n-th PhysxObject in the collection. -// The operator [] is maybe a more convenient way to -// access objects from the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th PhysxObject in the collection. The operator [] is maybe a + * more convenient way to access objects from the collection. + */ template INLINE T *PhysxObjectCollection:: get(unsigned int index) const { @@ -72,12 +62,10 @@ get(unsigned int index) const { return _objects[index]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::operator [] -// Access: Public -// Description: Returns the n-th PhysxObject in the collection. -// This is the same as the get() method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th PhysxObject in the collection. This is the same as the + * get() method. + */ template INLINE T *PhysxObjectCollection:: operator [] (unsigned int index) const { @@ -86,11 +74,9 @@ operator [] (unsigned int index) const { return _objects[index]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::ls -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PhysxObjectCollection:: ls() const { @@ -98,11 +84,9 @@ ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxObjectCollection::ls -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PhysxObjectCollection:: ls(ostream &out, int indent_level) const { @@ -111,4 +95,3 @@ ls(ostream &out, int indent_level) const { get(i)->ls(out, indent_level + 2); } } - diff --git a/panda/src/physx/physxObjectCollection.cxx b/panda/src/physx/physxObjectCollection.cxx index fb8d6992e1..061c5be82a 100644 --- a/panda/src/physx/physxObjectCollection.cxx +++ b/panda/src/physx/physxObjectCollection.cxx @@ -1,16 +1,14 @@ -// Filename: physxObjectCollection.cxx -// Created by: enn0x (08Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObjectCollection.cxx + * @author enn0x + * @date 2009-11-08 + */ #include "physxObjectCollection.h" - diff --git a/panda/src/physx/physxObjectCollection.h b/panda/src/physx/physxObjectCollection.h index eadb53428c..ace4799e57 100644 --- a/panda/src/physx/physxObjectCollection.h +++ b/panda/src/physx/physxObjectCollection.h @@ -1,16 +1,15 @@ -// Filename: physxObjectCollection.h -// Created by: enn0x (08Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxObjectCollection.h + * @author enn0x + * @date 2009-11-08 + */ #ifndef PHYSXOBJECTCOLLECTION_H #define PHYSXOBJECTCOLLECTION_H @@ -19,10 +18,9 @@ #include "config_physx.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxObjectCollection -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ template class EXPCL_PANDAPHYSX PhysxObjectCollection { diff --git a/panda/src/physx/physxOverlapReport.I b/panda/src/physx/physxOverlapReport.I index d9083e4164..16394aa48b 100644 --- a/panda/src/physx/physxOverlapReport.I +++ b/panda/src/physx/physxOverlapReport.I @@ -1,35 +1,28 @@ -// Filename: physxOverlapReport.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxOverlapReport.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxOverlapReport:: PhysxOverlapReport() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxOverlapReport:: ~PhysxOverlapReport() { } - diff --git a/panda/src/physx/physxOverlapReport.cxx b/panda/src/physx/physxOverlapReport.cxx index 6a64e1fefb..dc5fafb431 100644 --- a/panda/src/physx/physxOverlapReport.cxx +++ b/panda/src/physx/physxOverlapReport.cxx @@ -1,25 +1,22 @@ -// Filename: physxOverlapReport.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxOverlapReport.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxOverlapReport.h" #include "physxShape.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::onEvent -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxOverlapReport:: onEvent(NxU32 nbEntities, NxShape **entities) { @@ -31,22 +28,18 @@ onEvent(NxU32 nbEntities, NxShape **entities) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::get_num_overlaps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxOverlapReport:: get_num_overlaps() const { return _overlaps.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::get_first_overlap -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxShape *PhysxOverlapReport:: get_first_overlap() { @@ -54,11 +47,9 @@ get_first_overlap() { return get_next_overlap(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::get_next_overlap -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxShape *PhysxOverlapReport:: get_next_overlap() { @@ -66,19 +57,16 @@ get_next_overlap() { return *_iterator++; } - // No more items. Return empty overlap. + // No more items. Return empty overlap. return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxOverlapReport::get_overlap -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxShape *PhysxOverlapReport:: get_overlap(unsigned int idx) { nassertr(idx < get_num_overlaps(), NULL); return _overlaps[idx]; } - diff --git a/panda/src/physx/physxOverlapReport.h b/panda/src/physx/physxOverlapReport.h index 4c0db876d0..13b39654b1 100644 --- a/panda/src/physx/physxOverlapReport.h +++ b/panda/src/physx/physxOverlapReport.h @@ -1,16 +1,15 @@ -// Filename: physxOverlapReport.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxOverlapReport.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXOVERLAPREPORT_H #define PHYSXOVERLAPREPORT_H @@ -26,13 +25,11 @@ class PhysxShape; class PhysxUserEntityReport : public NxUserEntityReport {}; -//////////////////////////////////////////////////////////////////// -// Class : PhysxOverlapReport -// Description : Objects of this class are returned by the 'overlap -// shape' methods, for example overlapSphereShapes. -// They contain an iterable list of all sshapes that -// the raycast query produced. -//////////////////////////////////////////////////////////////////// +/** + * Objects of this class are returned by the 'overlap shape' methods, for + * example overlapSphereShapes. They contain an iterable list of all sshapes + * that the raycast query produced. + */ class EXPCL_PANDAPHYSX PhysxOverlapReport : public PhysxUserEntityReport { PUBLISHED: diff --git a/panda/src/physx/physxPlane.I b/panda/src/physx/physxPlane.I index e177f7dc4e..a974b2b513 100644 --- a/panda/src/physx/physxPlane.I +++ b/panda/src/physx/physxPlane.I @@ -1,46 +1,37 @@ -// Filename: physxPlane.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlane.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlane:: PhysxPlane() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlane:: PhysxPlane(const PhysxPlane &plane) { _plane = plane._plane; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlane:: ~PhysxPlane() { } - diff --git a/panda/src/physx/physxPlane.cxx b/panda/src/physx/physxPlane.cxx index 53cf33811b..380c3bfdb8 100644 --- a/panda/src/physx/physxPlane.cxx +++ b/panda/src/physx/physxPlane.cxx @@ -1,25 +1,22 @@ -// Filename: physxPlane.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlane.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxPlane.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxPlane:: distance(const LPoint3f &p) const { @@ -28,11 +25,9 @@ distance(const LPoint3f &p) const { return _plane.distance(PhysxManager::point3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::belongs -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxPlane:: belongs(const LPoint3f &p) const { @@ -41,22 +36,18 @@ belongs(const LPoint3f &p) const { return _plane.belongs(PhysxManager::point3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::point_in_plane -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxPlane:: point_in_plane() const { return PhysxManager::nxVec3_to_point3(_plane.pointInPlane()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::project -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxPlane:: project(const LPoint3f &p) const { @@ -65,11 +56,9 @@ project(const LPoint3f &p) const { return PhysxManager::nxVec3_to_point3(_plane.project(PhysxManager::point3_to_nxVec3(p))); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::inverse_transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlane:: inverse_transform(const LMatrix4f &transform, PhysxPlane &transformed) const { @@ -78,22 +67,18 @@ inverse_transform(const LMatrix4f &transform, PhysxPlane &transformed) const { _plane.inverseTransform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::normalize -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlane:: normalize() { _plane.normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlane:: transform(const LMatrix4f &transform, PhysxPlane &transformed) const { @@ -102,44 +87,36 @@ transform(const LMatrix4f &transform, PhysxPlane &transformed) const { _plane.transform(PhysxManager::mat4_to_nxMat34(transform), transformed._plane); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::get_d -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxPlane:: get_d() const { return _plane.d; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::set_d -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlane:: set_d(float value) { _plane.d = value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::get_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxPlane:: get_normal() const { return PhysxManager::nxVec3_to_vec3(_plane.normal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::set_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlane:: set_normal(LVector3f normal) { @@ -148,11 +125,9 @@ set_normal(LVector3f normal) { _plane.normal = PhysxManager::vec3_to_nxVec3(normal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::set -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxPlane PhysxPlane:: set(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &p2) { @@ -168,11 +143,9 @@ set(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &p2) { return plane; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlane::zero -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxPlane PhysxPlane:: zero() { @@ -180,4 +153,3 @@ zero() { plane._plane = _plane.zero(); return plane; } - diff --git a/panda/src/physx/physxPlane.h b/panda/src/physx/physxPlane.h index 2227bde49f..9454ad920a 100644 --- a/panda/src/physx/physxPlane.h +++ b/panda/src/physx/physxPlane.h @@ -1,16 +1,15 @@ -// Filename: physxPlane.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlane.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXPLANE_H #define PHYSXPLANE_H @@ -20,10 +19,9 @@ #include "config_physx.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxPlane -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxPlane { PUBLISHED: diff --git a/panda/src/physx/physxPlaneShape.I b/panda/src/physx/physxPlaneShape.I index 96c529e972..613d062fc4 100644 --- a/panda/src/physx/physxPlaneShape.I +++ b/panda/src/physx/physxPlaneShape.I @@ -1,36 +1,28 @@ -// Filename: physxPlaneShape.I -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShape.I + * @author enn0x + * @date 2009-09-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlaneShape:: PhysxPlaneShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlaneShape:: ~PhysxPlaneShape() { } - diff --git a/panda/src/physx/physxPlaneShape.cxx b/panda/src/physx/physxPlaneShape.cxx index 92acf14ff9..49ce975f38 100644 --- a/panda/src/physx/physxPlaneShape.cxx +++ b/panda/src/physx/physxPlaneShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxPlaneShape.cxx -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShape.cxx + * @author enn0x + * @date 2009-09-16 + */ #include "physxPlaneShape.h" #include "physxPlaneShapeDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxPlaneShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlaneShape:: link(NxShape *shapePtr) { @@ -36,11 +33,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPlaneShape:: unlink() { @@ -51,12 +46,9 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxPlaneShape:: save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const { @@ -64,19 +56,14 @@ save_to_desc(PhysxPlaneShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShape::set_plane -// Access: Published -// Description: Sets the plane equation. -// - normal: Normal for the plane, in the global -// frame. Range: direction vector -// - d: Distance coefficient of the plane equation. -// Range: (-inf,inf) -//////////////////////////////////////////////////////////////////// +/** + * Sets the plane equation. - normal: Normal for the plane, in the global + * frame. Range: direction vector - d: Distance coefficient of the plane + * equation. Range: (-inf,inf) + */ void PhysxPlaneShape:: set_plane(const LVector3f &normal, float d) { nassertv(_error_type == ET_ok); _ptr->setPlane(PhysxManager::vec3_to_nxVec3(normal), d); } - diff --git a/panda/src/physx/physxPlaneShape.h b/panda/src/physx/physxPlaneShape.h index b8785481cb..15115bf6fe 100644 --- a/panda/src/physx/physxPlaneShape.h +++ b/panda/src/physx/physxPlaneShape.h @@ -1,16 +1,15 @@ -// Filename: physxPlaneShape.h -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShape.h + * @author enn0x + * @date 2009-09-16 + */ #ifndef PHYSXPLANESHAPE_H #define PHYSXPLANESHAPE_H @@ -23,34 +22,26 @@ class PhysxPlaneShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPlaneShape -// Description : A plane collision detection primitive. By default -// it is configured to be the y == 0 plane. You can -// then set a normal and a d to specify an arbitrary -// plane. d is the distance of the plane from the -// origin along the normal, assuming the normal is -// normalized. Thus the plane equation is: -// normal.x * X + normal.y * Y + normal.z * Z = d -// -// Note: the plane does not represent an infinitely -// thin object, but rather a completely solid -// negative half space (all points p for which -// normal.dot(p) - d < 0 are inside the solid region.) -// -// Each shape is owned by an actor that it is attached -// to. -// -// An instance can be created by calling the -// createShape() method of the PhysxActor object that -// should own it, with a PhysxPlaneShapeDesc object as -// the parameter, or by adding the shape descriptor -// into the PhysxActorDesc class before creating the -// actor. -// -// The shape is deleted by calling release() on the -// shape itself. -//////////////////////////////////////////////////////////////////// +/** + * A plane collision detection primitive. By default it is configured to be + * the y == 0 plane. You can then set a normal and a d to specify an + * arbitrary plane. d is the distance of the plane from the origin along the + * normal, assuming the normal is normalized. Thus the plane equation is: + * normal.x * X + normal.y * Y + normal.z * Z = d + * + * Note: the plane does not represent an infinitely thin object, but rather a + * completely solid negative half space (all points p for which normal.dot(p) + * - d < 0 are inside the solid region.) + * + * Each shape is owned by an actor that it is attached to. + * + * An instance can be created by calling the createShape() method of the + * PhysxActor object that should own it, with a PhysxPlaneShapeDesc object as + * the parameter, or by adding the shape descriptor into the PhysxActorDesc + * class before creating the actor. + * + * The shape is deleted by calling release() on the shape itself. + */ class EXPCL_PANDAPHYSX PhysxPlaneShape : public PhysxShape { PUBLISHED: @@ -61,7 +52,6 @@ PUBLISHED: void set_plane(const LVector3f &normal, float d); -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -71,14 +61,13 @@ public: private: NxPlaneShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxPlaneShape", + register_type(_type_handle, "PhysxPlaneShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxPlaneShapeDesc.I b/panda/src/physx/physxPlaneShapeDesc.I index 08b9d55460..9ddac1ff6f 100644 --- a/panda/src/physx/physxPlaneShapeDesc.I +++ b/panda/src/physx/physxPlaneShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxPlaneShapeDesc.I -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShapeDesc.I + * @author enn0x + * @date 2009-09-08 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlaneShapeDesc:: PhysxPlaneShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPlaneShapeDesc:: ~PhysxPlaneShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxPlaneShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxPlaneShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxPlaneShapeDesc.cxx b/panda/src/physx/physxPlaneShapeDesc.cxx index d526ccb8f7..74e1b8d252 100644 --- a/panda/src/physx/physxPlaneShapeDesc.cxx +++ b/panda/src/physx/physxPlaneShapeDesc.cxx @@ -1,27 +1,23 @@ -// Filename: physxPlaneShapeDesc.cxx -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShapeDesc.cxx + * @author enn0x + * @date 2009-09-08 + */ #include "physxPlaneShapeDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxPlaneShapeDesc::set_plane -// Access: Published -// Description: Sets the parameters of the plane equation. -// normal: Plane normal. -// d: The distance from the origin. -//////////////////////////////////////////////////////////////////// +/** + * Sets the parameters of the plane equation. normal: Plane normal. d: The + * distance from the origin. + */ void PhysxPlaneShapeDesc:: set_plane(const LVector3f &normal, float d) { @@ -30,4 +26,3 @@ set_plane(const LVector3f &normal, float d) { _desc.normal = PhysxManager::vec3_to_nxVec3(normal); _desc.d = d; } - diff --git a/panda/src/physx/physxPlaneShapeDesc.h b/panda/src/physx/physxPlaneShapeDesc.h index 00c09f4583..cb205e5763 100644 --- a/panda/src/physx/physxPlaneShapeDesc.h +++ b/panda/src/physx/physxPlaneShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxPlaneShapeDesc.h -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPlaneShapeDesc.h + * @author enn0x + * @date 2009-09-08 + */ #ifndef PHYSXPLANESHAPEDESC_H #define PHYSXPLANESHAPEDESC_H @@ -22,10 +21,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxPlaneShapeDesc -// Description : Descriptor class for PhysxPlaneShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxPlaneShape. + */ class EXPCL_PANDAPHYSX PhysxPlaneShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxPointInPlaneJoint.I b/panda/src/physx/physxPointInPlaneJoint.I index 4a60567141..2e7d85c017 100644 --- a/panda/src/physx/physxPointInPlaneJoint.I +++ b/panda/src/physx/physxPointInPlaneJoint.I @@ -1,36 +1,28 @@ -// Filename: physxPointInPlaneJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointInPlaneJoint:: PhysxPointInPlaneJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointInPlaneJoint:: ~PhysxPointInPlaneJoint() { } - diff --git a/panda/src/physx/physxPointInPlaneJoint.cxx b/panda/src/physx/physxPointInPlaneJoint.cxx index 33638f3afa..34c4b0df42 100644 --- a/panda/src/physx/physxPointInPlaneJoint.cxx +++ b/panda/src/physx/physxPointInPlaneJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxPointInPlaneJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxPointInPlaneJoint.h" #include "physxPointInPlaneJointDesc.h" TypeHandle PhysxPointInPlaneJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPointInPlaneJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPointInPlaneJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxPointInPlaneJoint:: save_to_desc(PhysxPointInPlaneJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxPointInPlaneJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxPointInPlaneJoint:: load_from_desc(const PhysxPointInPlaneJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxPointInPlaneJoint.h b/panda/src/physx/physxPointInPlaneJoint.h index 9db3125245..e35eebb230 100644 --- a/panda/src/physx/physxPointInPlaneJoint.h +++ b/panda/src/physx/physxPointInPlaneJoint.h @@ -1,16 +1,15 @@ -// Filename: physxPointInPlaneJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXPOINTINPLANEJOINT_H #define PHYSXPOINTINPLANEJOINT_H @@ -22,16 +21,12 @@ class PhysxPointInPlaneJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPointInPlaneJoint -// Description : A point in plane joint constrains a point on one -// body to only move inside a plane attached to another -// body. -// The starting point of the point is defined as the -// anchor point. The plane through this point is -// specified by its normal which is the joint axis -// vector. -//////////////////////////////////////////////////////////////////// +/** + * A point in plane joint constrains a point on one body to only move inside a + * plane attached to another body. The starting point of the point is defined + * as the anchor point. The plane through this point is specified by its + * normal which is the joint axis vector. + */ class EXPCL_PANDAPHYSX PhysxPointInPlaneJoint : public PhysxJoint { PUBLISHED: @@ -41,7 +36,6 @@ PUBLISHED: void save_to_desc(PhysxPointInPlaneJointDesc &jointDesc) const; void load_from_desc(const PhysxPointInPlaneJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -51,14 +45,13 @@ public: private: NxPointInPlaneJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxPointInPlaneJoint", + register_type(_type_handle, "PhysxPointInPlaneJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxPointInPlaneJointDesc.I b/panda/src/physx/physxPointInPlaneJointDesc.I index fbb921a466..1e841bb2fb 100644 --- a/panda/src/physx/physxPointInPlaneJointDesc.I +++ b/panda/src/physx/physxPointInPlaneJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxPointInPlaneJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointInPlaneJointDesc:: PhysxPointInPlaneJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointInPlaneJointDesc:: ~PhysxPointInPlaneJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxPointInPlaneJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointInPlaneJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxPointInPlaneJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxPointInPlaneJointDesc.cxx b/panda/src/physx/physxPointInPlaneJointDesc.cxx index 1251f7b24e..8a0384810a 100644 --- a/panda/src/physx/physxPointInPlaneJointDesc.cxx +++ b/panda/src/physx/physxPointInPlaneJointDesc.cxx @@ -1,16 +1,14 @@ -// Filename: physxPointInPlaneJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxPointInPlaneJointDesc.h" - diff --git a/panda/src/physx/physxPointInPlaneJointDesc.h b/panda/src/physx/physxPointInPlaneJointDesc.h index c32dd11ca7..2b1ce4de8d 100644 --- a/panda/src/physx/physxPointInPlaneJointDesc.h +++ b/panda/src/physx/physxPointInPlaneJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxPointInPlaneJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointInPlaneJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXPOINTINPLANEJOINTDESC_H #define PHYSXPOINTINPLANEJOINTDESC_H @@ -20,11 +19,9 @@ #include "physxJointDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxPointInPlaneJointDesc -// Description : Descriptor class for point-in-plane joint. See -// PhysxPointInPlaneJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for point-in-plane joint. See PhysxPointInPlaneJoint. + */ class EXPCL_PANDAPHYSX PhysxPointInPlaneJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxPointOnLineJoint.I b/panda/src/physx/physxPointOnLineJoint.I index 836c1d0826..17092185e1 100644 --- a/panda/src/physx/physxPointOnLineJoint.I +++ b/panda/src/physx/physxPointOnLineJoint.I @@ -1,36 +1,28 @@ -// Filename: physxPointOnLineJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointOnLineJoint:: PhysxPointOnLineJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointOnLineJoint:: ~PhysxPointOnLineJoint() { } - diff --git a/panda/src/physx/physxPointOnLineJoint.cxx b/panda/src/physx/physxPointOnLineJoint.cxx index bd4d8a0df6..1cdf84981f 100644 --- a/panda/src/physx/physxPointOnLineJoint.cxx +++ b/panda/src/physx/physxPointOnLineJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxPointOnLineJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxPointOnLineJoint.h" #include "physxPointOnLineJointDesc.h" TypeHandle PhysxPointOnLineJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPointOnLineJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPointOnLineJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxPointOnLineJoint:: save_to_desc(PhysxPointOnLineJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxPointOnLineJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxPointOnLineJoint:: load_from_desc(const PhysxPointOnLineJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxPointOnLineJoint.h b/panda/src/physx/physxPointOnLineJoint.h index 3d090c6eeb..7a24819522 100644 --- a/panda/src/physx/physxPointOnLineJoint.h +++ b/panda/src/physx/physxPointOnLineJoint.h @@ -1,16 +1,15 @@ -// Filename: physxPointOnLineJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXPOINTONLINEJOINT_H #define PHYSXPOINTONLINEJOINT_H @@ -22,15 +21,12 @@ class PhysxPointOnLineJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPointOnLineJoint -// Description : A point on line joint constrains a point on one -// body to only move along a line attached to another -// body. -// The starting point of the joint is defined as the -// anchor point. The line through this point is -// specified by its direction (axis) vector. -//////////////////////////////////////////////////////////////////// +/** + * A point on line joint constrains a point on one body to only move along a + * line attached to another body. The starting point of the joint is defined + * as the anchor point. The line through this point is specified by its + * direction (axis) vector. + */ class EXPCL_PANDAPHYSX PhysxPointOnLineJoint : public PhysxJoint { PUBLISHED: @@ -40,7 +36,6 @@ PUBLISHED: void save_to_desc(PhysxPointOnLineJointDesc &jointDesc) const; void load_from_desc(const PhysxPointOnLineJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -50,14 +45,13 @@ public: private: NxPointOnLineJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxPointOnLineJoint", + register_type(_type_handle, "PhysxPointOnLineJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxPointOnLineJointDesc.I b/panda/src/physx/physxPointOnLineJointDesc.I index 6bac93e08d..c62346df54 100644 --- a/panda/src/physx/physxPointOnLineJointDesc.I +++ b/panda/src/physx/physxPointOnLineJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxPointOnLineJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointOnLineJointDesc:: PhysxPointOnLineJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPointOnLineJointDesc:: ~PhysxPointOnLineJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxPointOnLineJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPointOnLineJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxPointOnLineJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxPointOnLineJointDesc.cxx b/panda/src/physx/physxPointOnLineJointDesc.cxx index 1b661538d4..3aef1d0ee0 100644 --- a/panda/src/physx/physxPointOnLineJointDesc.cxx +++ b/panda/src/physx/physxPointOnLineJointDesc.cxx @@ -1,16 +1,14 @@ -// Filename: physxPointOnLineJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxPointOnLineJointDesc.h" - diff --git a/panda/src/physx/physxPointOnLineJointDesc.h b/panda/src/physx/physxPointOnLineJointDesc.h index 1846fcd163..4a283516f4 100644 --- a/panda/src/physx/physxPointOnLineJointDesc.h +++ b/panda/src/physx/physxPointOnLineJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxPointOnLineJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPointOnLineJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXPOINTONLINEJOINTDESC_H #define PHYSXPOINTONLINEJOINTDESC_H @@ -20,11 +19,9 @@ #include "physxJointDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxPointOnLineJointDesc -// Description : Descriptor class for point-on-line joint. -// See PhysxPointOnLineJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for point-on-line joint. See PhysxPointOnLineJoint. + */ class EXPCL_PANDAPHYSX PhysxPointOnLineJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxPrismaticJoint.I b/panda/src/physx/physxPrismaticJoint.I index 91d82dce03..6be48ffcb6 100644 --- a/panda/src/physx/physxPrismaticJoint.I +++ b/panda/src/physx/physxPrismaticJoint.I @@ -1,36 +1,28 @@ -// Filename: physxPrismaticJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPrismaticJoint:: PhysxPrismaticJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPrismaticJoint:: ~PhysxPrismaticJoint() { } - diff --git a/panda/src/physx/physxPrismaticJoint.cxx b/panda/src/physx/physxPrismaticJoint.cxx index 98831a479d..9fd765c94f 100644 --- a/panda/src/physx/physxPrismaticJoint.cxx +++ b/panda/src/physx/physxPrismaticJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxPrismaticJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxPrismaticJoint.h" #include "physxPrismaticJointDesc.h" TypeHandle PhysxPrismaticJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPrismaticJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPrismaticJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxPrismaticJoint:: save_to_desc(PhysxPrismaticJointDesc &jointDesc) const { @@ -63,16 +55,12 @@ save_to_desc(PhysxPrismaticJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxPrismaticJoint:: load_from_desc(const PhysxPrismaticJointDesc &jointDesc) { nassertv(_error_type == ET_ok); _ptr->loadFromDesc(jointDesc._desc); } - diff --git a/panda/src/physx/physxPrismaticJoint.h b/panda/src/physx/physxPrismaticJoint.h index c6979edc55..0aa1f2b54d 100644 --- a/panda/src/physx/physxPrismaticJoint.h +++ b/panda/src/physx/physxPrismaticJoint.h @@ -1,16 +1,15 @@ -// Filename: physxPrismaticJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXPRISMATICJOINT_H #define PHYSXPRISMATICJOINT_H @@ -22,12 +21,10 @@ class PhysxPrismaticJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPrismaticJoint -// Description : A prismatic joint permits relative translational -// movement between two bodies along an axis, but no -// relative rotational movement. -//////////////////////////////////////////////////////////////////// +/** + * A prismatic joint permits relative translational movement between two + * bodies along an axis, but no relative rotational movement. + */ class EXPCL_PANDAPHYSX PhysxPrismaticJoint : public PhysxJoint { PUBLISHED: @@ -37,7 +34,6 @@ PUBLISHED: void save_to_desc(PhysxPrismaticJointDesc &jointDesc) const; void load_from_desc(const PhysxPrismaticJointDesc &jointDesc); -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -47,14 +43,13 @@ public: private: NxPrismaticJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxPrismaticJoint", + register_type(_type_handle, "PhysxPrismaticJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxPrismaticJointDesc.I b/panda/src/physx/physxPrismaticJointDesc.I index 39a2a52c72..b44bcc3493 100644 --- a/panda/src/physx/physxPrismaticJointDesc.I +++ b/panda/src/physx/physxPrismaticJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxPrismaticJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPrismaticJointDesc:: PhysxPrismaticJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPrismaticJointDesc:: ~PhysxPrismaticJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxPrismaticJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPrismaticJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxPrismaticJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxPrismaticJointDesc.cxx b/panda/src/physx/physxPrismaticJointDesc.cxx index 0f7899bbe6..8643b0fd06 100644 --- a/panda/src/physx/physxPrismaticJointDesc.cxx +++ b/panda/src/physx/physxPrismaticJointDesc.cxx @@ -1,16 +1,14 @@ -// Filename: physxPrismaticJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxPrismaticJointDesc.h" - diff --git a/panda/src/physx/physxPrismaticJointDesc.h b/panda/src/physx/physxPrismaticJointDesc.h index 2ea3bdcaf2..0b6f2a58fa 100644 --- a/panda/src/physx/physxPrismaticJointDesc.h +++ b/panda/src/physx/physxPrismaticJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxPrismaticJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPrismaticJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXPRISMATICJOINTDESC_H #define PHYSXPRISMATICJOINTDESC_H @@ -20,11 +19,9 @@ #include "physxJointDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxPrismaticJointDesc -// Description : Descriptor class for prismatic joint. See -// PhysxPrismaticJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for prismatic joint. See PhysxPrismaticJoint. + */ class EXPCL_PANDAPHYSX PhysxPrismaticJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxPulleyJoint.I b/panda/src/physx/physxPulleyJoint.I index b3104276ee..ca714f8d05 100644 --- a/panda/src/physx/physxPulleyJoint.I +++ b/panda/src/physx/physxPulleyJoint.I @@ -1,36 +1,28 @@ -// Filename: physxPulleyJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPulleyJoint:: PhysxPulleyJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPulleyJoint:: ~PhysxPulleyJoint() { } - diff --git a/panda/src/physx/physxPulleyJoint.cxx b/panda/src/physx/physxPulleyJoint.cxx index 1a6fa1f75e..3b98de1cef 100644 --- a/panda/src/physx/physxPulleyJoint.cxx +++ b/panda/src/physx/physxPulleyJoint.cxx @@ -1,16 +1,15 @@ -// Filename: physxPulleyJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxPulleyJoint.h" #include "physxPulleyJointDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxPulleyJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPulleyJoint:: link(NxJoint *jointPtr) { @@ -36,11 +33,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxPulleyJoint:: unlink() { @@ -51,12 +46,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxPulleyJoint:: save_to_desc(PhysxPulleyJointDesc &jointDesc) const { @@ -64,12 +56,9 @@ save_to_desc(PhysxPulleyJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxPulleyJoint:: load_from_desc(const PhysxPulleyJointDesc &jointDesc) { @@ -77,37 +66,30 @@ load_from_desc(const PhysxPulleyJointDesc &jointDesc) { _ptr->loadFromDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::set_motor -// Access: Published -// Description: Sets motor parameters for the joint. -// -// For a positive velTarget, the motor pulls the first -// body towards its pulley, for a negative velTarget, -// the motor pulls the second body towards its pulley. -// -// velTarget - the relative velocity the motor is -// trying to achieve. The motor will only be able to -// reach this velocity if the maxForce is sufficiently -// large. If the joint is moving faster than this -// velocity, the motor will actually try to brake. If -// you set this to infinity then the motor will keep -// speeding up, unless there is some sort of -// resistance on the attached bodies. -// -// maxForce - the maximum force the motor can exert. -// Zero disables the motor. Default is 0, should -// be >= 0. Setting this to a very large value if -// velTarget is also very large may not be a good -// idea. -// -// freeSpin - if this flag is set, and if the joint -// is moving faster than velTarget, then neither -// braking nor additional acceleration will result. -// default: false. -// -// This automatically enables the motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets motor parameters for the joint. + * + * For a positive velTarget, the motor pulls the first body towards its + * pulley, for a negative velTarget, the motor pulls the second body towards + * its pulley. + * + * velTarget - the relative velocity the motor is trying to achieve. The + * motor will only be able to reach this velocity if the maxForce is + * sufficiently large. If the joint is moving faster than this velocity, the + * motor will actually try to brake. If you set this to infinity then the + * motor will keep speeding up, unless there is some sort of resistance on the + * attached bodies. + * + * maxForce - the maximum force the motor can exert. Zero disables the motor. + * Default is 0, should be >= 0. Setting this to a very large value if + * velTarget is also very large may not be a good idea. + * + * freeSpin - if this flag is set, and if the joint is moving faster than + * velTarget, then neither braking nor additional acceleration will result. + * default: false. + * + * This automatically enables the motor. + */ void PhysxPulleyJoint:: set_motor(const PhysxMotorDesc &motor) { @@ -115,11 +97,9 @@ set_motor(const PhysxMotorDesc &motor) { _ptr->setMotor(motor._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::set_flag -// Access: Published -// Description: Sets or clear a single pulley joint flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clear a single pulley joint flag. + */ void PhysxPulleyJoint:: set_flag(PhysxPulleyJointFlag flag, bool value) { @@ -136,11 +116,9 @@ set_flag(PhysxPulleyJointFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::get_flag -// Access: Published -// Description: Retrieves the value of a single PulleyJointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value of a single PulleyJointFlag. + */ bool PhysxPulleyJoint:: get_flag(PhysxPulleyJointFlag flag) const { @@ -148,11 +126,9 @@ get_flag(PhysxPulleyJointFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJoint::get_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMotorDesc PhysxPulleyJoint:: get_motor() const { @@ -162,4 +138,3 @@ get_motor() const { _ptr->getMotor(value._desc); return value; } - diff --git a/panda/src/physx/physxPulleyJoint.h b/panda/src/physx/physxPulleyJoint.h index 2ae057a3e9..421ac6488e 100644 --- a/panda/src/physx/physxPulleyJoint.h +++ b/panda/src/physx/physxPulleyJoint.h @@ -1,16 +1,15 @@ -// Filename: physxPulleyJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXPULLEYJOINT_H #define PHYSXPULLEYJOINT_H @@ -23,11 +22,10 @@ class PhysxMotorDesc; class PhysxPulleyJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPulleyJoint -// Description : A pulley joint simulates a rope between two -// objects passing over two pulleys. -//////////////////////////////////////////////////////////////////// +/** + * A pulley joint simulates a rope between two objects passing over two + * pulleys. + */ class EXPCL_PANDAPHYSX PhysxPulleyJoint : public PhysxJoint { PUBLISHED: @@ -43,7 +41,6 @@ PUBLISHED: bool get_flag(PhysxPulleyJointFlag flag) const; PhysxMotorDesc get_motor() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -53,14 +50,13 @@ public: private: NxPulleyJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxPulleyJoint", + register_type(_type_handle, "PhysxPulleyJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxPulleyJointDesc.I b/panda/src/physx/physxPulleyJointDesc.I index 56a340c908..a31e1316b9 100644 --- a/panda/src/physx/physxPulleyJointDesc.I +++ b/panda/src/physx/physxPulleyJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxPulleyJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPulleyJointDesc:: PhysxPulleyJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxPulleyJointDesc:: ~PhysxPulleyJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxPulleyJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxPulleyJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxPulleyJointDesc.cxx b/panda/src/physx/physxPulleyJointDesc.cxx index bb150247f4..c436879940 100644 --- a/panda/src/physx/physxPulleyJointDesc.cxx +++ b/panda/src/physx/physxPulleyJointDesc.cxx @@ -1,61 +1,50 @@ -// Filename: physxPulleyJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxPulleyJointDesc.h" #include "physxMotorDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_distance -// Access: Published -// Description: Sets the rest length of the rope connecting the -// two objects. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rest length of the rope connecting the two objects. + */ void PhysxPulleyJointDesc:: set_distance(float distance) { _desc.distance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_stiffness -// Access: Published -// Description: Sets how stiff the constraint is, between 0 and 1 -// (stiffest) -//////////////////////////////////////////////////////////////////// +/** + * Sets how stiff the constraint is, between 0 and 1 (stiffest) + */ void PhysxPulleyJointDesc:: set_stiffness(float stiffness) { _desc.stiffness = stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_ratio -// Access: Published -// Description: Sets the transmission ratio. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transmission ratio. + */ void PhysxPulleyJointDesc:: set_ratio(float ratio) { _desc.ratio = ratio; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_flag -// Access: Published -// Description: Sets or clears a single PulleyJointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single PulleyJointFlag flag. + */ void PhysxPulleyJointDesc:: set_flag(PhysxPulleyJointFlag flag, bool value) { @@ -67,12 +56,9 @@ set_flag(PhysxPulleyJointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_pulley -// Access: Published -// Description: Sets the suspension points of two bodies in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the suspension points of two bodies in world space. + */ void PhysxPulleyJointDesc:: set_pulley(unsigned int idx, const LPoint3f pos) { @@ -80,66 +66,54 @@ set_pulley(unsigned int idx, const LPoint3f pos) { _desc.pulley[idx] = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::set_motor -// Access: Published -// Description: Sets an optional joint motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets an optional joint motor. + */ void PhysxPulleyJointDesc:: set_motor(const PhysxMotorDesc &motor) { _desc.motor = motor._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxPulleyJointDesc:: get_distance() const { return _desc.distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxPulleyJointDesc:: get_stiffness() const { return _desc.stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_ratio -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxPulleyJointDesc:: get_ratio() const { return _desc.ratio; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxPulleyJointDesc:: get_flag(PhysxPulleyJointFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_pulley -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxPulleyJointDesc:: get_pulley(unsigned int idx) const { @@ -147,11 +121,9 @@ get_pulley(unsigned int idx) const { return PhysxManager::nxVec3_to_point3(_desc.pulley[idx]); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxPulleyJointDesc::get_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMotorDesc PhysxPulleyJointDesc:: get_motor() const { @@ -159,4 +131,3 @@ get_motor() const { value._desc = _desc.motor; return value; } - diff --git a/panda/src/physx/physxPulleyJointDesc.h b/panda/src/physx/physxPulleyJointDesc.h index a167ee7910..154dd4fc2a 100644 --- a/panda/src/physx/physxPulleyJointDesc.h +++ b/panda/src/physx/physxPulleyJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxPulleyJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxPulleyJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXPULLEYJOINTDESC_H #define PHYSXPULLEYJOINTDESC_H @@ -22,11 +21,9 @@ class PhysxMotorDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxPulleyJointDesc -// Description : Descriptor class for distance joint. See -// PhysxPulleyJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for distance joint. See PhysxPulleyJoint. + */ class EXPCL_PANDAPHYSX PhysxPulleyJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxRay.I b/panda/src/physx/physxRay.I index b798c28b4a..9a7407a79c 100644 --- a/panda/src/physx/physxRay.I +++ b/panda/src/physx/physxRay.I @@ -1,23 +1,19 @@ -// Filename: physxRay.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRay.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRay:: PhysxRay() { @@ -27,13 +23,10 @@ PhysxRay() { _length = NX_MAX_F32; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRay:: ~PhysxRay() { } - diff --git a/panda/src/physx/physxRay.cxx b/panda/src/physx/physxRay.cxx index c622fc4160..d62007deb7 100644 --- a/panda/src/physx/physxRay.cxx +++ b/panda/src/physx/physxRay.cxx @@ -1,25 +1,22 @@ -// Filename: physxRay.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRay.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxRay.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::set_origin -// Access: Published -// Description: Sets the ray origin. -//////////////////////////////////////////////////////////////////// +/** + * Sets the ray origin. + */ void PhysxRay:: set_origin(const LPoint3f &origin) { @@ -27,23 +24,18 @@ set_origin(const LPoint3f &origin) { _ray.orig = PhysxManager::point3_to_nxVec3(origin); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::get_origin -// Access: Published -// Description: Returns the ray origin -//////////////////////////////////////////////////////////////////// +/** + * Returns the ray origin + */ LPoint3f PhysxRay:: get_origin() const { return PhysxManager::nxVec3_to_point3(_ray.orig); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::set_direction -// Access: Published -// Description: Set the ray direction. It is not required to pass -// a normalized vector. -//////////////////////////////////////////////////////////////////// +/** + * Set the ray direction. It is not required to pass a normalized vector. + */ void PhysxRay:: set_direction(const LVector3f &direction) { @@ -53,25 +45,20 @@ set_direction(const LVector3f &direction) { _ray.dir.normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::get_direction -// Access: Published -// Description: Returns the ray direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ray direction. + */ LVector3f PhysxRay:: get_direction() const { return PhysxManager::nxVec3_to_vec3(_ray.dir); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::set_length -// Access: Published -// Description: Sets the ray length. If no length is set then the -// ray will be virtually infinite (the maximum -// floating point number will be used, e.g. -// 3.40282346639e+038). -//////////////////////////////////////////////////////////////////// +/** + * Sets the ray length. If no length is set then the ray will be virtually + * infinite (the maximum floating point number will be used, e.g. + * 3.40282346639e+038). + */ void PhysxRay:: set_length(float length) { @@ -79,15 +66,11 @@ set_length(float length) { _length = length; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRay::get_length -// Access: Published -// Description: Returns the ray length. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ray length. + */ float PhysxRay:: get_length() const { return _length; } - - diff --git a/panda/src/physx/physxRay.h b/panda/src/physx/physxRay.h index a1a9bfec4e..9274576bd1 100644 --- a/panda/src/physx/physxRay.h +++ b/panda/src/physx/physxRay.h @@ -1,16 +1,15 @@ -// Filename: physxRay.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRay.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXRAY_H #define PHYSXRAY_H @@ -20,11 +19,10 @@ #include "config_physx.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxRay -// Description : Represents an ray as an origin and direction. -// The ray will be infinite if no length is given. -//////////////////////////////////////////////////////////////////// +/** + * Represents an ray as an origin and direction. The ray will be infinite if + * no length is given. + */ class EXPCL_PANDAPHYSX PhysxRay { PUBLISHED: diff --git a/panda/src/physx/physxRaycastHit.I b/panda/src/physx/physxRaycastHit.I index 340f2c3928..0decd62512 100644 --- a/panda/src/physx/physxRaycastHit.I +++ b/panda/src/physx/physxRaycastHit.I @@ -1,36 +1,29 @@ -// Filename: physxRaycastHit.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastHit.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRaycastHit:: PhysxRaycastHit(const NxRaycastHit hit) { _hit = hit; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRaycastHit:: ~PhysxRaycastHit() { } - diff --git a/panda/src/physx/physxRaycastHit.cxx b/panda/src/physx/physxRaycastHit.cxx index 24cefa3d11..30d983f0ea 100644 --- a/panda/src/physx/physxRaycastHit.cxx +++ b/panda/src/physx/physxRaycastHit.cxx @@ -1,37 +1,32 @@ -// Filename: physxRaycastHit.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastHit.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxRaycastHit.h" #include "physxManager.h" #include "physxShape.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::is_empty -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxRaycastHit:: is_empty() const { return (_hit.shape == NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::get_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxShape *PhysxRaycastHit:: get_shape() const { @@ -39,36 +34,29 @@ get_shape() const { return (PhysxShape *)_hit.shape->userData; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::get_impact_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxRaycastHit:: get_impact_pos() const { return PhysxManager::nxVec3_to_point3(_hit.worldImpact); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::get_impact_normal -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxRaycastHit:: get_impact_normal() const { return PhysxManager::nxVec3_to_vec3(_hit.worldNormal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastHit::get_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxRaycastHit:: get_distance() const { return _hit.distance; } - diff --git a/panda/src/physx/physxRaycastHit.h b/panda/src/physx/physxRaycastHit.h index a70b28aae9..918ee506dd 100644 --- a/panda/src/physx/physxRaycastHit.h +++ b/panda/src/physx/physxRaycastHit.h @@ -1,16 +1,15 @@ -// Filename: physxRaycastHit.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastHit.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXRAYCASTHIT_H #define PHYSXRAYCASTHIT_H @@ -22,12 +21,10 @@ class PhysxShape; -//////////////////////////////////////////////////////////////////// -// Class : PhysxRaycastHit -// Description : This structure captures results for a single -// raycast query. See PhysxScene for raycasting -// methods. -//////////////////////////////////////////////////////////////////// +/** + * This structure captures results for a single raycast query. See PhysxScene + * for raycasting methods. + */ class EXPCL_PANDAPHYSX PhysxRaycastHit { PUBLISHED: diff --git a/panda/src/physx/physxRaycastReport.I b/panda/src/physx/physxRaycastReport.I index 9d66902fbc..2e8e5a7481 100644 --- a/panda/src/physx/physxRaycastReport.I +++ b/panda/src/physx/physxRaycastReport.I @@ -1,35 +1,28 @@ -// Filename: physxRaycastReport.I -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastReport.I + * @author enn0x + * @date 2009-10-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRaycastReport:: PhysxRaycastReport() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRaycastReport:: ~PhysxRaycastReport() { } - diff --git a/panda/src/physx/physxRaycastReport.cxx b/panda/src/physx/physxRaycastReport.cxx index 4c03f21939..cb00d85b10 100644 --- a/panda/src/physx/physxRaycastReport.cxx +++ b/panda/src/physx/physxRaycastReport.cxx @@ -1,25 +1,22 @@ -// Filename: physxRaycastReport.cxx -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastReport.cxx + * @author enn0x + * @date 2009-10-21 + */ #include "physxRaycastReport.h" #include "physxRaycastHit.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::onRaycast -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxRaycastReport:: onHit(const NxRaycastHit& hit) { @@ -27,22 +24,18 @@ onHit(const NxRaycastHit& hit) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::get_num_hits -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxRaycastReport:: get_num_hits() const { return _hits.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::get_first_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxRaycastHit PhysxRaycastReport:: get_first_hit() { @@ -50,11 +43,9 @@ get_first_hit() { return get_next_hit(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::get_next_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxRaycastHit PhysxRaycastReport:: get_next_hit() { @@ -62,23 +53,21 @@ get_next_hit() { return *_iterator++; } - // No more items. Return an empty hit. + // No more items. Return an empty hit. NxRaycastHit hit; hit.shape = NULL; return PhysxRaycastHit(hit); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRaycastReport::get_hit -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxRaycastHit PhysxRaycastReport:: get_hit(unsigned int idx) { if (!(idx < _hits.size())) { - // Index out of bounds. Return an empty hit. + // Index out of bounds. Return an empty hit. NxRaycastHit hit; hit.shape = NULL; return PhysxRaycastHit(hit); @@ -86,4 +75,3 @@ get_hit(unsigned int idx) { return _hits[idx]; } - diff --git a/panda/src/physx/physxRaycastReport.h b/panda/src/physx/physxRaycastReport.h index f9d19ba37d..0d5d3f5ab0 100644 --- a/panda/src/physx/physxRaycastReport.h +++ b/panda/src/physx/physxRaycastReport.h @@ -1,16 +1,15 @@ -// Filename: physxRaycastReport.h -// Created by: enn0x (21Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRaycastReport.h + * @author enn0x + * @date 2009-10-21 + */ #ifndef PHYSXRAYCASTREPORT_H #define PHYSXRAYCASTREPORT_H @@ -22,12 +21,10 @@ class PhysxRaycastHit; -//////////////////////////////////////////////////////////////////// -// Class : PhysxRaycastReport -// Description : Objects of this class are returned by the 'raycast -// all' methods. They contain an iterable list of all -// hits that the raycast query produced. -//////////////////////////////////////////////////////////////////// +/** + * Objects of this class are returned by the 'raycast all' methods. They + * contain an iterable list of all hits that the raycast query produced. + */ class EXPCL_PANDAPHYSX PhysxRaycastReport : public NxUserRaycastReport { PUBLISHED: diff --git a/panda/src/physx/physxRevoluteJoint.I b/panda/src/physx/physxRevoluteJoint.I index b5640107c7..b9c803a518 100644 --- a/panda/src/physx/physxRevoluteJoint.I +++ b/panda/src/physx/physxRevoluteJoint.I @@ -1,36 +1,28 @@ -// Filename: physxRevoluteJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRevoluteJoint:: PhysxRevoluteJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRevoluteJoint:: ~PhysxRevoluteJoint() { } - diff --git a/panda/src/physx/physxRevoluteJoint.cxx b/panda/src/physx/physxRevoluteJoint.cxx index a7a853ca9e..5b3f9c5cde 100644 --- a/panda/src/physx/physxRevoluteJoint.cxx +++ b/panda/src/physx/physxRevoluteJoint.cxx @@ -1,16 +1,15 @@ -// Filename: physxRevoluteJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxRevoluteJoint.h" #include "physxRevoluteJointDesc.h" @@ -20,11 +19,9 @@ TypeHandle PhysxRevoluteJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxRevoluteJoint:: link(NxJoint *jointPtr) { @@ -38,11 +35,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxRevoluteJoint:: unlink() { @@ -53,12 +48,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxRevoluteJoint:: save_to_desc(PhysxRevoluteJointDesc &jointDesc) const { @@ -66,12 +58,9 @@ save_to_desc(PhysxRevoluteJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxRevoluteJoint:: load_from_desc(const PhysxRevoluteJointDesc &jointDesc) { @@ -79,19 +68,15 @@ load_from_desc(const PhysxRevoluteJointDesc &jointDesc) { _ptr->loadFromDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_angle -// Access: Published -// Description: Retrieves the current revolute joint angle. -// -// The relative orientation of the bodies is stored -// when the joint is created, or when set_axis() or -// set_anchor() is called. This initial orientation -// returns an angle of zero, and joint angles are -// measured relative to this pose. The angle is in -// the range [-180, 180], with positive angles CCW -// around the axis, measured from body2 to body1. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current revolute joint angle. + * + * The relative orientation of the bodies is stored when the joint is created, + * or when set_axis() or set_anchor() is called. This initial orientation + * returns an angle of zero, and joint angles are measured relative to this + * pose. The angle is in the range [-180, 180], with positive angles CCW + * around the axis, measured from body2 to body1. + */ float PhysxRevoluteJoint:: get_angle() const { @@ -99,13 +84,10 @@ get_angle() const { return NxMath::radToDeg(_ptr->getAngle()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_velocity -// Access: Published -// Description: Retrieves the revolute joint angle's rate of change -// (angular velocity). It is the angular velocity of -// body1 minus body2 projected along the axis. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the revolute joint angle's rate of change (angular velocity). It + * is the angular velocity of body1 minus body2 projected along the axis. + */ float PhysxRevoluteJoint:: get_velocity() const { @@ -113,11 +95,9 @@ get_velocity() const { return _ptr->getVelocity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::set_projection_mode -// Access: Published -// Description: Sets the joint projection mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the joint projection mode. + */ void PhysxRevoluteJoint:: set_projection_mode(PhysxProjectionMode mode) { @@ -125,11 +105,9 @@ set_projection_mode(PhysxProjectionMode mode) { _ptr->setProjectionMode((NxJointProjectionMode)mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_projection_mode -// Access: Published -// Description: Retrieves the joints projection mode. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the joints projection mode. + */ PhysxEnums::PhysxProjectionMode PhysxRevoluteJoint:: get_projection_mode() const { @@ -137,11 +115,9 @@ get_projection_mode() const { return (PhysxProjectionMode)_ptr->getProjectionMode(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::set_flag -// Access: Published -// Description: Sets or clears a single RevoluteJointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single RevoluteJointFlag. + */ void PhysxRevoluteJoint:: set_flag(PhysxRevoluteJointFlag flag, bool value) { @@ -158,11 +134,9 @@ set_flag(PhysxRevoluteJointFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_flag -// Access: Published -// Description: Returns the value of a single RevoluteJointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of a single RevoluteJointFlag. + */ bool PhysxRevoluteJoint:: get_flag(PhysxRevoluteJointFlag flag) const { @@ -170,35 +144,27 @@ get_flag(PhysxRevoluteJointFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::set_spring -// Access: Published -// Description: Sets spring parameters. -// -// The spring is implicitly integrated so no -// instability should result for arbitrary spring and -// damping constants. Using these settings together -// with a motor is not possible -- the motor will have -// priority and the spring settings are ignored. If -// you would like to simulate your motor's internal -// friction, do this by altering the motor parameters -// directly. -// -// spring - The rotational spring acts along the hinge -// axis and tries to force the joint angle to zero. A -// setting of zero disables the spring. Default is 0, -// should be >= 0. -// -// damper - Damping coefficient; acts against the -// hinge's angular velocity. A setting of zero -// disables the damping. The default is 0, should -// be >= 0. -// -// targetValue - The angle at which the spring is -// relaxed. In [-Pi,Pi]. Default is 0. -// -// This automatically enables the spring -//////////////////////////////////////////////////////////////////// +/** + * Sets spring parameters. + * + * The spring is implicitly integrated so no instability should result for + * arbitrary spring and damping constants. Using these settings together with + * a motor is not possible -- the motor will have priority and the spring + * settings are ignored. If you would like to simulate your motor's internal + * friction, do this by altering the motor parameters directly. + * + * spring - The rotational spring acts along the hinge axis and tries to force + * the joint angle to zero. A setting of zero disables the spring. Default + * is 0, should be >= 0. + * + * damper - Damping coefficient; acts against the hinge's angular velocity. A + * setting of zero disables the damping. The default is 0, should be >= 0. + * + * targetValue - The angle at which the spring is relaxed. In [-Pi,Pi]. + * Default is 0. + * + * This automatically enables the spring + */ void PhysxRevoluteJoint:: set_spring(const PhysxSpringDesc &spring) { @@ -206,37 +172,30 @@ set_spring(const PhysxSpringDesc &spring) { _ptr->setSpring(spring._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::set_motor -// Access: Published -// Description: Sets motor parameters for the joint. -// -// For a positive velTarget, the motor pulls the first -// body towards its pulley, for a negative velTarget, -// the motor pulls the second body towards its pulley. -// -// velTarget - the relative velocity the motor is -// trying to achieve. The motor will only be able to -// reach this velocity if the maxForce is sufficiently -// large. If the joint is moving faster than this -// velocity, the motor will actually try to brake. If -// you set this to infinity then the motor will keep -// speeding up, unless there is some sort of -// resistance on the attached bodies. -// -// maxForce - the maximum force the motor can exert. -// Zero disables the motor. Default is 0, should -// be >= 0. Setting this to a very large value if -// velTarget is also very large may not be a good -// idea. -// -// freeSpin - if this flag is set, and if the joint -// is moving faster than velTarget, then neither -// braking nor additional acceleration will result. -// default: false. -// -// This automatically enables the motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets motor parameters for the joint. + * + * For a positive velTarget, the motor pulls the first body towards its + * pulley, for a negative velTarget, the motor pulls the second body towards + * its pulley. + * + * velTarget - the relative velocity the motor is trying to achieve. The + * motor will only be able to reach this velocity if the maxForce is + * sufficiently large. If the joint is moving faster than this velocity, the + * motor will actually try to brake. If you set this to infinity then the + * motor will keep speeding up, unless there is some sort of resistance on the + * attached bodies. + * + * maxForce - the maximum force the motor can exert. Zero disables the motor. + * Default is 0, should be >= 0. Setting this to a very large value if + * velTarget is also very large may not be a good idea. + * + * freeSpin - if this flag is set, and if the joint is moving faster than + * velTarget, then neither braking nor additional acceleration will result. + * default: false. + * + * This automatically enables the motor. + */ void PhysxRevoluteJoint:: set_motor(const PhysxMotorDesc &motor) { @@ -244,36 +203,28 @@ set_motor(const PhysxMotorDesc &motor) { _ptr->setMotor(motor._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::set_limits -// Access: Published -// Description: Sets angular joint limits. -// -// If either of these limits are set, any planar -// limits in PhysxJoint are ignored. The limits are -// angles defined the same way as the values -// that get_angle() returns. -// -// The following has to hold: -// -// Pi < lowAngle < highAngle < Pi Both limits are -// disabled by default. -// Also sets coefficients of restitutions for the low -// and high angular limits. These settings are only -// used if valid limits are set using set_limits(). -// These restitution coefficients work the same way as -// for contacts. -// -// The coefficient of restitution determines whether a -// collision with the joint limit is completely -// elastic (like pool balls, restitution = 1, no -// energy is lost in the collision), completely -// inelastic (like putty, restitution = 0, no rebound -// after collision) or somewhere in between. The -// default is 0 for both. -// -// This automatically enables the limit. -//////////////////////////////////////////////////////////////////// +/** + * Sets angular joint limits. + * + * If either of these limits are set, any planar limits in PhysxJoint are + * ignored. The limits are angles defined the same way as the values that + * get_angle() returns. + * + * The following has to hold: + * + * Pi < lowAngle < highAngle < Pi Both limits are disabled by default. Also + * sets coefficients of restitutions for the low and high angular limits. + * These settings are only used if valid limits are set using set_limits(). + * These restitution coefficients work the same way as for contacts. + * + * The coefficient of restitution determines whether a collision with the + * joint limit is completely elastic (like pool balls, restitution = 1, no + * energy is lost in the collision), completely inelastic (like putty, + * restitution = 0, no rebound after collision) or somewhere in between. The + * default is 0 for both. + * + * This automatically enables the limit. + */ void PhysxRevoluteJoint:: set_limits(const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) { @@ -285,11 +236,9 @@ set_limits(const PhysxJointLimitDesc &low, const PhysxJointLimitDesc &high) { _ptr->setLimits(limits); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_motor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxMotorDesc PhysxRevoluteJoint:: get_motor() const { @@ -300,11 +249,9 @@ get_motor() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJoint::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxRevoluteJoint:: get_spring() const { @@ -314,4 +261,3 @@ get_spring() const { _ptr->getSpring(value._desc); return value; } - diff --git a/panda/src/physx/physxRevoluteJoint.h b/panda/src/physx/physxRevoluteJoint.h index 6494338ead..22c43ea652 100644 --- a/panda/src/physx/physxRevoluteJoint.h +++ b/panda/src/physx/physxRevoluteJoint.h @@ -1,16 +1,15 @@ -// Filename: physxRevoluteJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXREVOLUTEJOINT_H #define PHYSXREVOLUTEJOINT_H @@ -25,14 +24,12 @@ class PhysxSpringDesc; class PhysxMotorDesc; class PhysxJointLimitDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxRevoluteJoint -// Description : A joint which behaves in a similar way to a hinge -// or axel. A hinge joint removes all but a single -// rotational degree of freedom from two objects. The -// axis along which the two bodies may rotate is -// specified with a point and a direction vector. -//////////////////////////////////////////////////////////////////// +/** + * A joint which behaves in a similar way to a hinge or axel. A hinge joint + * removes all but a single rotational degree of freedom from two objects. + * The axis along which the two bodies may rotate is specified with a point + * and a direction vector. + */ class EXPCL_PANDAPHYSX PhysxRevoluteJoint : public PhysxJoint { PUBLISHED: @@ -55,7 +52,6 @@ PUBLISHED: PhysxMotorDesc get_motor() const; PhysxSpringDesc get_spring() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -65,14 +61,13 @@ public: private: NxRevoluteJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxRevoluteJoint", + register_type(_type_handle, "PhysxRevoluteJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxRevoluteJointDesc.I b/panda/src/physx/physxRevoluteJointDesc.I index 8b819f07c6..23ecfeefcf 100644 --- a/panda/src/physx/physxRevoluteJointDesc.I +++ b/panda/src/physx/physxRevoluteJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxRevoluteJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRevoluteJointDesc:: PhysxRevoluteJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxRevoluteJointDesc:: ~PhysxRevoluteJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxRevoluteJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxRevoluteJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxRevoluteJointDesc.cxx b/panda/src/physx/physxRevoluteJointDesc.cxx index c090ef5be6..be11cf4cf1 100644 --- a/panda/src/physx/physxRevoluteJointDesc.cxx +++ b/panda/src/physx/physxRevoluteJointDesc.cxx @@ -1,61 +1,51 @@ -// Filename: physxRevoluteJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxRevoluteJointDesc.h" #include "physxSpringDesc.h" #include "physxMotorDesc.h" #include "physxJointLimitDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_projection_distance -// Access: Published -// Description: Sets the distance beyond which the joint is -// projected. -//////////////////////////////////////////////////////////////////// +/** + * Sets the distance beyond which the joint is projected. + */ void PhysxRevoluteJointDesc:: set_projection_distance(float distance) { _desc.projectionDistance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_projection_angle -// Access: Published -// Description: Sets the angle beyond which the joint is projected. -//////////////////////////////////////////////////////////////////// +/** + * Sets the angle beyond which the joint is projected. + */ void PhysxRevoluteJointDesc:: set_projection_angle(float angle) { _desc.projectionAngle = angle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_spring -// Access: Published -// Description: Sets an aptional spring. -//////////////////////////////////////////////////////////////////// +/** + * Sets an aptional spring. + */ void PhysxRevoluteJointDesc:: set_spring(const PhysxSpringDesc &spring) { _desc.spring = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_flag -// Access: Published -// Description: Sets or clears a single RevoluteJointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single RevoluteJointFlag flag. + */ void PhysxRevoluteJointDesc:: set_flag(PhysxRevoluteJointFlag flag, bool value) { @@ -67,82 +57,63 @@ set_flag(PhysxRevoluteJointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_projection_mode -// Access: Published -// Description: Use this to enable joint projection. -// Default is PM_none. -//////////////////////////////////////////////////////////////////// +/** + * Use this to enable joint projection. Default is PM_none. + */ void PhysxRevoluteJointDesc:: set_projection_mode(PhysxProjectionMode mode) { _desc.projectionMode = (NxJointProjectionMode)mode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_motor -// Access: Published -// Description: Sets an optional joint motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets an optional joint motor. + */ void PhysxRevoluteJointDesc:: set_motor(const PhysxMotorDesc &motor) { _desc.motor = motor._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_limit_low -// Access: Published -// Description: Sets optional limits for the angular motion of the -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Sets optional limits for the angular motion of the joint. + */ void PhysxRevoluteJointDesc:: set_limit_low(const PhysxJointLimitDesc &low) { _desc.limit.low = low._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::set_limit_high -// Access: Published -// Description: Sets optional limits for the angular motion of the -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Sets optional limits for the angular motion of the joint. + */ void PhysxRevoluteJointDesc:: set_limit_high(const PhysxJointLimitDesc &high) { _desc.limit.high = high._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_projection_distance -// Access: Published -// Description: Return the distance beyond which the joint is -// projected. -//////////////////////////////////////////////////////////////////// +/** + * Return the distance beyond which the joint is projected. + */ float PhysxRevoluteJointDesc:: get_projection_distance() const { return _desc.projectionDistance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_projection_angle -// Access: Published -// Description: Return the angle beyond which the joint is -// projected. -//////////////////////////////////////////////////////////////////// +/** + * Return the angle beyond which the joint is projected. + */ float PhysxRevoluteJointDesc:: get_projection_angle() const { return _desc.projectionAngle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxRevoluteJointDesc:: get_spring() const { @@ -151,33 +122,27 @@ get_spring() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxRevoluteJointDesc:: get_flag(PhysxRevoluteJointFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_projection_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxProjectionMode PhysxRevoluteJointDesc:: get_projection_mode() const { return (PhysxProjectionMode)_desc.projectionMode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_motor -// Access: Published -// Description: Sets an optional joint motor. -//////////////////////////////////////////////////////////////////// +/** + * Sets an optional joint motor. + */ PhysxMotorDesc PhysxRevoluteJointDesc:: get_motor() const { @@ -186,11 +151,9 @@ get_motor() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_limit_low -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitDesc PhysxRevoluteJointDesc:: get_limit_low() const { @@ -199,11 +162,9 @@ get_limit_low() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxRevoluteJointDesc::get_limit_high -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitDesc PhysxRevoluteJointDesc:: get_limit_high() const { @@ -211,4 +172,3 @@ get_limit_high() const { value._desc = _desc.limit.high; return value; } - diff --git a/panda/src/physx/physxRevoluteJointDesc.h b/panda/src/physx/physxRevoluteJointDesc.h index d62d0ac447..dd665c614d 100644 --- a/panda/src/physx/physxRevoluteJointDesc.h +++ b/panda/src/physx/physxRevoluteJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxRevoluteJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxRevoluteJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXREVOLUTEJOINTDESC_H #define PHYSXREVOLUTEJOINTDESC_H @@ -24,11 +23,9 @@ class PhysxSpringDesc; class PhysxMotorDesc; class PhysxJointLimitDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxRevoluteJointDesc -// Description : Descriptor class for distance joint. See -// PhysxRevoluteJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for distance joint. See PhysxRevoluteJoint. + */ class EXPCL_PANDAPHYSX PhysxRevoluteJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxScene.I b/panda/src/physx/physxScene.I index 5f5510630e..d611cbe3db 100644 --- a/panda/src/physx/physxScene.I +++ b/panda/src/physx/physxScene.I @@ -1,57 +1,46 @@ -// Filename: physxScene.I -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxScene.I + * @author enn0x + * @date 2009-09-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxScene:: PhysxScene() : PhysxObject() { _debugNode = new PhysxDebugGeomNode(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxScene:: ~PhysxScene() { _debugNode = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxScene:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxScene:: ls(ostream &out, int indent_level) const { @@ -69,25 +58,20 @@ ls(ostream &out, int indent_level) const { _softbodies.ls(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_controller_shape_hit_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxScene:: set_controller_shape_hit_callback(PT(CallbackObject) cbobj) { _controller_report.set_shape_hit_callback(cbobj); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_controller_controller_hit_callback -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxScene:: set_controller_controller_hit_callback(PT(CallbackObject) cbobj) { _controller_report.set_controller_hit_callback(cbobj); } - diff --git a/panda/src/physx/physxScene.cxx b/panda/src/physx/physxScene.cxx index 628cde17c0..e2623ef47a 100644 --- a/panda/src/physx/physxScene.cxx +++ b/panda/src/physx/physxScene.cxx @@ -1,16 +1,15 @@ -// Filename: physxScene.cxx -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxScene.cxx + * @author enn0x + * @date 2009-09-14 + */ #include "physxScene.h" #include "physxManager.h" @@ -36,11 +35,9 @@ PStatCollector PhysxScene::_pcollector_simulate("App:PhysX:Simulate"); PStatCollector PhysxScene::_pcollector_cloth("App:PhysX:Cloth"); PStatCollector PhysxScene::_pcollector_softbody("App:PhysX:Softbody"); -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: link(NxScene *scenePtr) { @@ -65,11 +62,9 @@ link(NxScene *scenePtr) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: unlink() { @@ -168,11 +163,9 @@ unlink() { PhysxManager::get_global_ptr()->_scenes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: release() { @@ -184,18 +177,14 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::simulate -// Access: Published -// Description: Advances the simulation by an elapsedTime time. -// The elapsed time has to be in the range (0, inf). -// -// It is not allowed to modify the physics scene in -// between the simulate(dt) and the fetch_results -// calls! But it is allowed to read from the scene -// and do additional computations, e. g. AI, in -// between these calls. -//////////////////////////////////////////////////////////////////// +/** + * Advances the simulation by an elapsedTime time. The elapsed time has to be + * in the range (0, inf). + * + * It is not allowed to modify the physics scene in between the simulate(dt) + * and the fetch_results calls! But it is allowed to read from the scene and + * do additional computations, e. g. AI, in between these calls. + */ void PhysxScene:: simulate(float dt) { @@ -225,19 +214,14 @@ simulate(float dt) { _pcollector_simulate.stop(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::fetch_results -// Access: Published -// Description: Waits until the simulation has finished, and then -// updates the scene graph with with simulation -// results. -// -// It is not allowed to modify the physics scene in -// between the simulate(dt) and the fetch_results -// calls! But it is allowed to read from the scene -// and do additional computations, e. g. AI, in -// between these calls. -//////////////////////////////////////////////////////////////////// +/** + * Waits until the simulation has finished, and then updates the scene graph + * with with simulation results. + * + * It is not allowed to modify the physics scene in between the simulate(dt) + * and the fetch_results calls! But it is allowed to read from the scene and + * do additional computations, e. g. AI, in between these calls. + */ void PhysxScene:: fetch_results() { @@ -257,8 +241,8 @@ fetch_results() { if (nbTransforms && activeTransforms) { for (NxU32 i=0; isetTiming(0, 0, NX_TIMESTEP_VARIABLE); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_timing_fixed -// Access: Published -// Description: Sets simulation timing parameters used in simulate. -// The elapsed time (parameter "dt" in simulate()) is -// internally subdivided into up to maxIter substeps -// no larger than maxTimestep. If the elapsed time is -// not a multiple of maxTimestep then any remaining -// time is accumulated to be added onto the elapsed -// time for the next time step. If more sub steps than -// maxIter are needed to advance the simulation by -// elapsed time, then the remaining time is also -// accumulated for the next call to simulate(). -// -// This timing method is strongly preferred for -// stable, reproducible simulation. -//////////////////////////////////////////////////////////////////// +/** + * Sets simulation timing parameters used in simulate. The elapsed time + * (parameter "dt" in simulate()) is internally subdivided into up to maxIter + * substeps no larger than maxTimestep. If the elapsed time is not a multiple + * of maxTimestep then any remaining time is accumulated to be added onto the + * elapsed time for the next time step. If more sub steps than maxIter are + * needed to advance the simulation by elapsed time, then the remaining time + * is also accumulated for the next call to simulate(). + * + * This timing method is strongly preferred for stable, reproducible + * simulation. + */ void PhysxScene:: set_timing_fixed(float maxTimestep, unsigned int maxIter) { @@ -335,11 +312,9 @@ set_timing_fixed(float maxTimestep, unsigned int maxIter) { _ptr->setTiming(maxTimestep, maxIter, NX_TIMESTEP_FIXED); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_gravity -// Access: Published -// Description: Sets a constant gravity for the entire scene. -//////////////////////////////////////////////////////////////////// +/** + * Sets a constant gravity for the entire scene. + */ void PhysxScene:: set_gravity(const LVector3f &gravity) { @@ -349,11 +324,9 @@ set_gravity(const LVector3f &gravity) { _ptr->setGravity(PhysxManager::vec3_to_nxVec3(gravity)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_gravity -// Access: Published -// Description: Retrieves the current gravity setting. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current gravity setting. + */ LVector3f PhysxScene:: get_gravity() const { @@ -364,11 +337,9 @@ get_gravity() const { return PhysxManager::nxVec3_to_vec3(gravity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_actors -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxScene:: get_num_actors() const { @@ -377,11 +348,9 @@ get_num_actors() const { return _ptr->getNbActors(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_actor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxActor *PhysxScene:: create_actor(PhysxActorDesc &desc) { @@ -399,11 +368,9 @@ create_actor(PhysxActorDesc &desc) { return actor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_actor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxActor *PhysxScene:: get_actor(unsigned int idx) const { @@ -416,20 +383,15 @@ get_actor(unsigned int idx) const { return actor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_debug_node -// Access: Published -// Description: Retrieves the debug geom node for this scene. The -// debug geom node is used to visualize information -// about the physical scene which can be useful for -// debugging an application. -// -// The debug geom node geometry is generated in global -// coordinates. In order to see correct information -// it is important not to dislocate the debug node. -// Reparent it to render and leave position at -// (0,0,0). -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the debug geom node for this scene. The debug geom node is used + * to visualize information about the physical scene which can be useful for + * debugging an application. + * + * The debug geom node geometry is generated in global coordinates. In order + * to see correct information it is important not to dislocate the debug node. + * Reparent it to render and leave position at (0,0,0). + */ PhysxDebugGeomNode *PhysxScene:: get_debug_geom_node() { @@ -437,11 +399,9 @@ get_debug_geom_node() { return _debugNode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::enable_contact_reporting -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: enable_contact_reporting(bool enabled) { @@ -457,11 +417,9 @@ enable_contact_reporting(bool enabled) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::is_contact_reporting_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxScene:: is_contact_reporting_enabled() const { @@ -470,11 +428,9 @@ is_contact_reporting_enabled() const { return _contact_report.is_enabled(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::enable_trigger_reporting -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: enable_trigger_reporting(bool enabled) { @@ -490,11 +446,9 @@ enable_trigger_reporting(bool enabled) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::is_trigger_reporting_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxScene:: is_trigger_reporting_enabled() const { @@ -503,11 +457,9 @@ is_trigger_reporting_enabled() const { return _trigger_report.is_enabled(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::enable_controller_reporting -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxScene:: enable_controller_reporting(bool enabled) { @@ -521,11 +473,9 @@ enable_controller_reporting(bool enabled) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::is_controller_reporting_enabled -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxScene:: is_controller_reporting_enabled() const { @@ -534,18 +484,14 @@ is_controller_reporting_enabled() const { return _controller_report.is_enabled(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_materials -// Access: Published -// Description: Return the number of materials in the scene. -// -// Note that the returned value is not related to -// material indices. Those may not be allocated -// continuously, and its values may be higher than -// get_num_materials(). This will also include the -// default material which exists without having to -// be created. -//////////////////////////////////////////////////////////////////// +/** + * Return the number of materials in the scene. + * + * Note that the returned value is not related to material indices. Those may + * not be allocated continuously, and its values may be higher than + * get_num_materials(). This will also include the default material which + * exists without having to be created. + */ unsigned int PhysxScene:: get_num_materials() const { @@ -553,17 +499,14 @@ get_num_materials() const { return _ptr->getNbMaterials(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_material -// Access: Published -// Description: Creates a new PhysxMaterial. -// -// The material library consists of an array of -// material objects. Each material has a well defined -// index that can be used to refer to it. If an object -// references an undefined material, the default -// material with index 0 is used instead. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new PhysxMaterial. + * + * The material library consists of an array of material objects. Each + * material has a well defined index that can be used to refer to it. If an + * object references an undefined material, the default material with index 0 + * is used instead. + */ PhysxMaterial *PhysxScene:: create_material(PhysxMaterialDesc &desc) { @@ -581,12 +524,10 @@ create_material(PhysxMaterialDesc &desc) { return material; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_material -// Access: Published -// Description: Creates a new PhysxMaterial using the default -// settings of PhysxMaterialDesc. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new PhysxMaterial using the default settings of + * PhysxMaterialDesc. + */ PhysxMaterial *PhysxScene:: create_material() { @@ -605,15 +546,12 @@ create_material() { return material; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_hightest_material_index -// Access: Published -// Description: Returns current highest valid material index. -// -// Note that not all indices below this are valid if -// some of them belong to meshes that have beed -// freed. -//////////////////////////////////////////////////////////////////// +/** + * Returns current highest valid material index. + * + * Note that not all indices below this are valid if some of them belong to + * meshes that have beed freed. + */ unsigned int PhysxScene:: get_hightest_material_index() const { @@ -621,19 +559,14 @@ get_hightest_material_index() const { return _ptr->getHighestMaterialIndex(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_material_from_index -// Access: Published -// Description: Retrieves the material with the given material -// index. -// -// There is always at least one material in the Scene, -// the default material (index 0). If the specified -// material index is out of range (larger than -// get_hightest_material_index) or belongs to a -// material that has been released, then the default -// material is returned, but no error is reported. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the material with the given material index. + * + * There is always at least one material in the Scene, the default material + * (index 0). If the specified material index is out of range (larger than + * get_hightest_material_index) or belongs to a material that has been + * released, then the default material is returned, but no error is reported. + */ PhysxMaterial *PhysxScene:: get_material_from_index(unsigned int idx) const { @@ -644,13 +577,10 @@ get_material_from_index(unsigned int idx) const { return (PhysxMaterial *)(materialPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_material -// Access: Published -// Description: Retrieves the n-th material from the array of -// materials. See also get_material_from_index, -// which retrieves a material by it's material index. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the n-th material from the array of materials. See also + * get_material_from_index, which retrieves a material by it's material index. + */ PhysxMaterial *PhysxScene:: get_material(unsigned int idx) const { @@ -671,11 +601,9 @@ get_material(unsigned int idx) const { return (PhysxMaterial *)(materialPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_controllers -// Access: Published -// Description: Return the number of controllers in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Return the number of controllers in the scene. + */ unsigned int PhysxScene:: get_num_controllers() const { @@ -684,11 +612,9 @@ get_num_controllers() const { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_controller -// Access: Published -// Description: Creates a new character controller. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new character controller. + */ PhysxController *PhysxScene:: create_controller(PhysxControllerDesc &desc) { @@ -710,11 +636,9 @@ create_controller(PhysxControllerDesc &desc) { return controller; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_controller -// Access: Published -// Description: Retrieves the n-th controller within the scene. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the n-th controller within the scene. + */ PhysxController *PhysxScene:: get_controller(unsigned int idx) const { @@ -727,13 +651,10 @@ get_controller(unsigned int idx) const { return controller; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_joints -// Access: Published -// Description: Returns the number of joints in the scene -// (excluding "dead" joints). Note that this includes -// compartments. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of joints in the scene (excluding "dead" joints). Note + * that this includes compartments. + */ unsigned int PhysxScene:: get_num_joints() const { @@ -741,11 +662,9 @@ get_num_joints() const { return _ptr->getNbJoints(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_joint -// Access: Published -// Description: Creates a joint in this scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a joint in this scene. + */ PhysxJoint *PhysxScene:: create_joint(PhysxJointDesc &desc) { @@ -763,12 +682,9 @@ create_joint(PhysxJointDesc &desc) { return joint; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_joint -// Access: Published -// Description: Retrieve the n-th joint from the array of all the -// joints in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Retrieve the n-th joint from the array of all the joints in the scene. + */ PhysxJoint *PhysxScene:: get_joint(unsigned int idx) const { @@ -786,11 +702,9 @@ get_joint(unsigned int idx) const { return (PhysxJoint *)(jointPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_force_fields -// Access: Published -// Description: Gets the number of force fields in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of force fields in the scene. + */ unsigned int PhysxScene:: get_num_force_fields() const { @@ -798,11 +712,9 @@ get_num_force_fields() const { return _ptr->getNbForceFields(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_force_field -// Access: Published -// Description: Creates a force field in this scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a force field in this scene. + */ PhysxForceField *PhysxScene:: create_force_field(PhysxForceFieldDesc &desc) { @@ -824,12 +736,10 @@ create_force_field(PhysxForceFieldDesc &desc) { return field; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_force_field -// Access: Published -// Description: Returns the n-th force field from the array of -// all the force fields in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th force field from the array of all the force fields in the + * scene. + */ PhysxForceField *PhysxScene:: get_force_field(unsigned int idx) const { @@ -842,12 +752,9 @@ get_force_field(unsigned int idx) const { return (PhysxForceField *)(fieldPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_force_field_shape_groups -// Access: Published -// Description: Gets the number of force field shape groups in -// the scene. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of force field shape groups in the scene. + */ unsigned int PhysxScene:: get_num_force_field_shape_groups() const { @@ -855,12 +762,9 @@ get_num_force_field_shape_groups() const { return _ptr->getNbForceFieldShapeGroups(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_force_field_shape_group -// Access: Published -// Description: Creates a new force field shape group in this -// scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new force field shape group in this scene. + */ PhysxForceFieldShapeGroup *PhysxScene:: create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { @@ -877,12 +781,9 @@ create_force_field_shape_group(PhysxForceFieldShapeGroupDesc &desc) { return group; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_force_field_shape_group -// Access: Published -// Description: Returns the n-th force field shape group in this -// scene -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th force field shape group in this scene + */ PhysxForceFieldShapeGroup *PhysxScene:: get_force_field_shape_group(unsigned int idx) const { @@ -899,11 +800,9 @@ get_force_field_shape_group(unsigned int idx) const { return groupPtr ? (PhysxForceFieldShapeGroup *)groupPtr->userData : NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_cloths -// Access: Published -// Description: Gets the number of cloths in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of cloths in the scene. + */ unsigned int PhysxScene:: get_num_cloths() const { @@ -911,11 +810,9 @@ get_num_cloths() const { return _ptr->getNbCloths(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_cloth -// Access: Published -// Description: Creates a cloth in this scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a cloth in this scene. + */ PhysxCloth *PhysxScene:: create_cloth(PhysxClothDesc &desc) { @@ -932,12 +829,9 @@ create_cloth(PhysxClothDesc &desc) { return cloth; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_cloth -// Access: Published -// Description: Returns the n-th cloth from the array of -// all the cloths in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th cloth from the array of all the cloths in the scene. + */ PhysxCloth *PhysxScene:: get_cloth(unsigned int idx) const { @@ -950,11 +844,9 @@ get_cloth(unsigned int idx) const { return (PhysxCloth *)(clothPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_soft_bodies -// Access: Published -// Description: Gets the number of soft bodies in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of soft bodies in the scene. + */ unsigned int PhysxScene:: get_num_soft_bodies() const { @@ -962,11 +854,9 @@ get_num_soft_bodies() const { return _ptr->getNbSoftBodies(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_soft_body -// Access: Published -// Description: Creates a soft body in this scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a soft body in this scene. + */ PhysxSoftBody *PhysxScene:: create_soft_body(PhysxSoftBodyDesc &desc) { @@ -983,12 +873,10 @@ create_soft_body(PhysxSoftBodyDesc &desc) { return softbody; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_soft_body -// Access: Published -// Description: Returns the n-th soft body from the array of -// all the soft bodies in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th soft body from the array of all the soft bodies in the + * scene. + */ PhysxSoftBody *PhysxScene:: get_soft_body(unsigned int idx) const { @@ -1001,11 +889,9 @@ get_soft_body(unsigned int idx) const { return (PhysxSoftBody *)(softbodyPtr->userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_num_vehicles -// Access: Published -// Description: Returns the number of vehicles in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vehicles in the scene. + */ unsigned int PhysxScene:: get_num_vehicles() const { @@ -1013,11 +899,9 @@ get_num_vehicles() const { return _vehicles.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::create_vehicle -// Access: Published -// Description: Creates a vehicle in this scene. -//////////////////////////////////////////////////////////////////// +/** + * Creates a vehicle in this scene. + */ PhysxVehicle *PhysxScene:: create_vehicle(PhysxVehicleDesc &desc) { @@ -1032,12 +916,9 @@ create_vehicle(PhysxVehicleDesc &desc) { return vehicle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_vehicle -// Access: Published -// Description: Returns the n-th vehicle from the array of all -// the vehicles in the scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th vehicle from the array of all the vehicles in the scene. + */ PhysxVehicle *PhysxScene:: get_vehicle(unsigned int idx) const { @@ -1047,11 +928,9 @@ get_vehicle(unsigned int idx) const { return _vehicles[idx]; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_stats2 -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSceneStats2 PhysxScene:: get_stats2() const { @@ -1059,12 +938,9 @@ get_stats2() const { return PhysxSceneStats2(_ptr->getStats2()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_any_shape -// Access: Published -// Description: Returns true if any shape is intersected by the -// ray. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any shape is intersected by the ray. + */ bool PhysxScene:: raycast_any_shape(const PhysxRay &ray, PhysxShapesType shapesType, @@ -1079,13 +955,10 @@ raycast_any_shape(const PhysxRay &ray, mask.get_mask(), ray._length, groupsPtr); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_closest_shape -// Access: Published -// Description: Returns the first shape that is hit along the ray. -// If not shape is hit then an empty raycast hit -// is returned (is_empty() == true). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first shape that is hit along the ray. If not shape is hit + * then an empty raycast hit is returned (is_empty() == true). + */ PhysxRaycastHit PhysxScene:: raycast_closest_shape(const PhysxRay &ray, PhysxShapesType shapesType, @@ -1113,13 +986,10 @@ raycast_closest_shape(const PhysxRay &ray, return PhysxRaycastHit(hit); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_all_shapes -// Access: Published -// Description: Returns a PhysxRaycastReport object which can be -// used to iterate over all shapes that have been -// hit by the ray. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxRaycastReport object which can be used to iterate over all + * shapes that have been hit by the ray. + */ PhysxRaycastReport PhysxScene:: raycast_all_shapes(const PhysxRay &ray, PhysxShapesType shapesType, @@ -1146,12 +1016,10 @@ raycast_all_shapes(const PhysxRay &ray, return report; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_any_bounds -// Access: Published -// Description: Returns true if any axis aligned bounding box -// enclosing a shape is intersected by the ray. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any axis aligned bounding box enclosing a shape is + * intersected by the ray. + */ bool PhysxScene:: raycast_any_bounds(const PhysxRay &ray, PhysxShapesType shapesType, @@ -1166,14 +1034,11 @@ raycast_any_bounds(const PhysxRay &ray, mask.get_mask(), ray._length, groupsPtr); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_closest_bounds -// Access: Published -// Description: Returns the first axis aligned bounding box -// enclosing a shape that is hit along the ray. -// If not shape is hit then an empty raycast hit -// is returned (is_empty() == true). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first axis aligned bounding box enclosing a shape that is hit + * along the ray. If not shape is hit then an empty raycast hit is returned + * (is_empty() == true). + */ PhysxRaycastHit PhysxScene:: raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType, PhysxMask mask, PhysxGroupsMask *groups, bool smoothNormal) const { @@ -1198,14 +1063,11 @@ raycast_closest_bounds(const PhysxRay &ray, PhysxShapesType shapesType, PhysxMas return PhysxRaycastHit(hit); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::raycast_all_bounds -// Access: Published -// Description: Returns a PhysxRaycastReport object which can be -// used to iterate over all shapes that have been -// enclosed by axis aligned bounding boxes hit by -// the ray. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PhysxRaycastReport object which can be used to iterate over all + * shapes that have been enclosed by axis aligned bounding boxes hit by the + * ray. + */ PhysxRaycastReport PhysxScene:: raycast_all_bounds(const PhysxRay &ray, PhysxShapesType shapesType, @@ -1232,14 +1094,10 @@ raycast_all_bounds(const PhysxRay &ray, return report; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::overlap_sphere_shapes -// Access: Published -// Description: Returns the set of shapes overlapped by the -// world-space sphere. -// You can test against static and/or dynamic objects -// by adjusting 'shapeType'. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of shapes overlapped by the world-space sphere. You can + * test against static and/or dynamic objects by adjusting 'shapeType'. + */ PhysxOverlapReport PhysxScene:: overlap_sphere_shapes(const LPoint3f ¢er, float radius, PhysxShapesType shapesType, @@ -1257,14 +1115,10 @@ overlap_sphere_shapes(const LPoint3f ¢er, float radius, return report; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::overlap_capsule_shapes -// Access: Published -// Description: Returns the set of shapes overlapped by the -// world-space capsule. -// You can test against static and/or dynamic objects -// by adjusting 'shapeType'. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of shapes overlapped by the world-space capsule. You can + * test against static and/or dynamic objects by adjusting 'shapeType'. + */ PhysxOverlapReport PhysxScene:: overlap_capsule_shapes(const LPoint3f &p0, const LPoint3f &p1, float radius, PhysxShapesType shapesType, @@ -1284,21 +1138,16 @@ overlap_capsule_shapes(const LPoint3f &p0, const LPoint3f &p1, float radius, return report; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_actor_pair_flag -// Access: Published -// Description: Sets the pair flags for the given pair of actors. -// -// Calling this on an actor that has no shape(s) has -// no effect. The two actor references must not -// reference the same actor. -// -// It is important to note that the engine stores -// pair flags per shape, even for actor pair flags. -// This means that shapes should be created before -// actor pair flags are set, otherwise the pair flags -// will be ignored. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pair flags for the given pair of actors. + * + * Calling this on an actor that has no shape(s) has no effect. The two actor + * references must not reference the same actor. + * + * It is important to note that the engine stores pair flags per shape, even + * for actor pair flags. This means that shapes should be created before + * actor pair flags are set, otherwise the pair flags will be ignored. + */ void PhysxScene:: set_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, PhysxContactPairFlag flag, bool value) { @@ -1319,15 +1168,11 @@ set_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, _ptr->setActorPairFlags(*ptrA, *ptrB, flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_actor_pair_flag -// Access: Published -// Description: Retrieves a single flag for the given pair of -// actors. -// -// The two actor references must not reference the -// same actor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves a single flag for the given pair of actors. + * + * The two actor references must not reference the same actor. + */ bool PhysxScene:: get_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, PhysxContactPairFlag flag) { @@ -1341,15 +1186,11 @@ get_actor_pair_flag(PhysxActor &actorA, PhysxActor &actorB, return (flags && flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_shape_pair_flag -// Access: Published -// Description: Disables or enables contact generation for a pair -// of shapes. -// -// The two shape references must not reference the -// same shape. -//////////////////////////////////////////////////////////////////// +/** + * Disables or enables contact generation for a pair of shapes. + * + * The two shape references must not reference the same shape. + */ void PhysxScene:: set_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB, bool value) { @@ -1369,16 +1210,12 @@ set_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB, bool value) { _ptr->setShapePairFlags(*ptrA, *ptrB, flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_shape_pair_flag -// Access: Published -// Description: Returns /true/ if contact generation between a pair -// of shapes is enabled, and /false/ if contact -// generation is disables. -// -// The two shape references must not reference the -// same shape. -//////////////////////////////////////////////////////////////////// +/** + * Returns /true/ if contact generation between a pair of shapes is enabled, + * and /false/ if contact generation is disables. + * + * The two shape references must not reference the same shape. + */ bool PhysxScene:: get_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB) { @@ -1391,32 +1228,23 @@ get_shape_pair_flag(PhysxShape &shapeA, PhysxShape &shapeB) { return (flags && NX_IGNORE_PAIR) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_actor_group_pair_flag -// Access: Published -// Description: With this method one can set contact reporting -// flags between actors belonging to a pair of groups. -// -// It is possible to assign each actor to a group -// using PhysxActor::set_group(). This is a different -// set of groups from the shape groups despite the -// similar name. Here up to 0xffff different groups -// are permitted, With this method one can set -// contact reporting flags between actors belonging -// to a pair of groups. -// -// The following flags are permitted: -// - CPF_start_touch -// - CPF_end_touch -// - CPF_touch -// - CPF_start_touch_treshold -// - CPF_end_touch_treshold -// - CPF_touch_treshold -// -// Note that finer grain control of pairwise flags is -// possible using the function -// PhysxScene::set_actor_pair_flags(). -//////////////////////////////////////////////////////////////////// +/** + * With this method one can set contact reporting flags between actors + * belonging to a pair of groups. + * + * It is possible to assign each actor to a group using + * PhysxActor::set_group(). This is a different set of groups from the shape + * groups despite the similar name. Here up to 0xffff different groups are + * permitted, With this method one can set contact reporting flags between + * actors belonging to a pair of groups. + * + * The following flags are permitted: - CPF_start_touch - CPF_end_touch - + * CPF_touch - CPF_start_touch_treshold - CPF_end_touch_treshold - + * CPF_touch_treshold + * + * Note that finer grain control of pairwise flags is possible using the + * function PhysxScene::set_actor_pair_flags(). + */ void PhysxScene:: set_actor_group_pair_flag(unsigned int g1, unsigned int g2, PhysxContactPairFlag flag, bool value) { @@ -1433,12 +1261,9 @@ set_actor_group_pair_flag(unsigned int g1, unsigned int g2, _ptr->setActorGroupPairFlags(g1, g2, flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_actor_group_pair_flag -// Access: Published -// Description: Retrieves a single flag set with -// PhysxScene::set_actor_group_pair_flag() -//////////////////////////////////////////////////////////////////// +/** + * Retrieves a single flag set with PhysxScene::set_actor_group_pair_flag() + */ bool PhysxScene:: get_actor_group_pair_flag(unsigned int g1, unsigned int g2, PhysxContactPairFlag flag) { @@ -1448,11 +1273,9 @@ get_actor_group_pair_flag(unsigned int g1, unsigned int g2, return (flags && flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_filter_ops -// Access: Published -// Description: Setups filtering operations. -//////////////////////////////////////////////////////////////////// +/** + * Setups filtering operations. + */ void PhysxScene:: set_filter_ops(PhysxFilterOp op0, PhysxFilterOp op1, PhysxFilterOp op2) { @@ -1460,11 +1283,9 @@ set_filter_ops(PhysxFilterOp op0, PhysxFilterOp op1, PhysxFilterOp op2) { _ptr->setFilterOps((NxFilterOp)op0, (NxFilterOp)op1, (NxFilterOp)op2); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_filter_bool -// Access: Published -// Description: Setups filtering's boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Setups filtering's boolean value. + */ void PhysxScene:: set_filter_bool(bool flag) { @@ -1472,11 +1293,9 @@ set_filter_bool(bool flag) { _ptr->setFilterBool(flag); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_filter_constant0 -// Access: Published -// Description: Setups filtering's K0 value. -//////////////////////////////////////////////////////////////////// +/** + * Setups filtering's K0 value. + */ void PhysxScene:: set_filter_constant0(const PhysxGroupsMask &mask) { @@ -1484,11 +1303,9 @@ set_filter_constant0(const PhysxGroupsMask &mask) { _ptr->setFilterConstant0(mask.get_mask()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_filter_constant1 -// Access: Published -// Description: Setups filtering's K1 value. -//////////////////////////////////////////////////////////////////// +/** + * Setups filtering's K1 value. + */ void PhysxScene:: set_filter_constant1(const PhysxGroupsMask &mask) { @@ -1496,11 +1313,9 @@ set_filter_constant1(const PhysxGroupsMask &mask) { _ptr->setFilterConstant1(mask.get_mask()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_bool -// Access: Published -// Description: Retrieves filtering's boolean value. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves filtering's boolean value. + */ bool PhysxScene:: get_filter_bool() const { @@ -1508,11 +1323,9 @@ get_filter_bool() const { return _ptr->getFilterBool(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_constant0 -// Access: Published -// Description: Gets filtering constant K0. -//////////////////////////////////////////////////////////////////// +/** + * Gets filtering constant K0. + */ PhysxGroupsMask PhysxScene:: get_filter_constant0() const { @@ -1526,11 +1339,9 @@ get_filter_constant0() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_constant1 -// Access: Published -// Description: Gets filtering constant K1. -//////////////////////////////////////////////////////////////////// +/** + * Gets filtering constant K1. + */ PhysxGroupsMask PhysxScene:: get_filter_constant1() const { @@ -1544,11 +1355,9 @@ get_filter_constant1() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_op0 -// Access: Published -// Description: Retrieves the op0 filtering operation. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the op0 filtering operation. + */ PhysxEnums::PhysxFilterOp PhysxScene:: get_filter_op0() const { @@ -1563,11 +1372,9 @@ get_filter_op0() const { return (PhysxFilterOp)op0; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_op1 -// Access: Published -// Description: Retrieves the op1 filtering operation. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the op1 filtering operation. + */ PhysxEnums::PhysxFilterOp PhysxScene:: get_filter_op1() const { @@ -1582,11 +1389,9 @@ get_filter_op1() const { return (PhysxFilterOp)op1; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_filter_op2 -// Access: Published -// Description: Retrieves the op2 filtering operation. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the op2 filtering operation. + */ PhysxEnums::PhysxFilterOp PhysxScene:: get_filter_op2() const { @@ -1601,22 +1406,18 @@ get_filter_op2() const { return (PhysxFilterOp)op2; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_group_collision_flag -// Access: Published -// Description: Specifies if collision should be performed by a -// pair of shape groups. -// -// It is possible to assign each shape to a collision -// groups using PhysxShape::set_group(). With this -// method one can set whether collisions should be -// detected between shapes belonging to a given pair -// of groups. Initially all pairs are enabled. -// -// Fluids can be assigned to collision groups as well. -// -// Collision groups are integers between 0 and 31. -//////////////////////////////////////////////////////////////////// +/** + * Specifies if collision should be performed by a pair of shape groups. + * + * It is possible to assign each shape to a collision groups using + * PhysxShape::set_group(). With this method one can set whether collisions + * should be detected between shapes belonging to a given pair of groups. + * Initially all pairs are enabled. + * + * Fluids can be assigned to collision groups as well. + * + * Collision groups are integers between 0 and 31. + */ void PhysxScene:: set_group_collision_flag(unsigned int g1, unsigned int g2, bool enable) { @@ -1627,13 +1428,10 @@ set_group_collision_flag(unsigned int g1, unsigned int g2, bool enable) { _ptr->setGroupCollisionFlag((NxCollisionGroup)g1, (NxCollisionGroup)g2, enable); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_group_collision_flag -// Access: Published -// Description: Determines if collision detection is performed -// between a pair of groups. Collision groups are -// integers between 0 and 31. -//////////////////////////////////////////////////////////////////// +/** + * Determines if collision detection is performed between a pair of groups. + * Collision groups are integers between 0 and 31. + */ bool PhysxScene:: get_group_collision_flag(unsigned int g1, unsigned int g2) { @@ -1644,11 +1442,9 @@ get_group_collision_flag(unsigned int g1, unsigned int g2) { return _ptr->getGroupCollisionFlag((NxCollisionGroup)g1, (NxCollisionGroup)g2); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_flag -// Access: Published -// Description: Return the specified scene flag flag. -//////////////////////////////////////////////////////////////////// +/** + * Return the specified scene flag flag. + */ bool PhysxScene:: get_flag(PhysxSceneFlag flag) const { @@ -1656,13 +1452,10 @@ get_flag(PhysxSceneFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::is_hardware_scene -// Access: Published -// Description: Returns TRUE if the the scene is simulated in -// hardware. FALSE if the scene is simulated in -// software. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if the the scene is simulated in hardware. FALSE if the scene + * is simulated in software. + */ bool PhysxScene:: is_hardware_scene() const { @@ -1670,59 +1463,45 @@ is_hardware_scene() const { return (_ptr->getSimType() & NX_SIMULATION_HW) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::set_dominance_group_pair -// Access: Published -// Description: Specifies the dominance behavior of constraints -// between two actors with two certain dominance -// groups. -// -// It is possible to assign each actor to a dominance -// groups using PhysxActor::set_dominance_group(). -// -// With dominance groups one can have all constraints -// (contacts and joints) created between actors act in -// one direction only. This is useful if you want to -// make sure that the movement of the rider of a -// vehicle or the pony tail of a character doesn't -// influence the object it is attached to, while -// keeping the motion of both inherently physical. -// -// Whenever a constraint (i.e. joint or contact) -// between two actors (a0, a1) needs to be solved, the -// groups (g0, g1) of both actors are retrieved. Then -// the constraint dominance setting for this group -// pair is retrieved. -// -// In the constraint, PhysxConstraintDominance::get_0() -// becomes the dominance setting for a0, and -// PhysxConstraintDominance::get_1() becomes the -// dominance setting for a1. A dominance setting of -// 1.0f, the default, will permit the actor to be -// pushed or pulled by the other actor. A dominance -// setting of 0.0f will however prevent the actor to -// be pushed or pulled by the other actor. Thus, a -// PhysxConstraintDominance of (1.0f, 0.0f) makes the -// interaction one-way. -// -// The dominance matrix is initialised by default such -// that: -// - if g1 == g2, then (1.0f, 1.0f) is returned -// - if g1 < g2, then (0.0f, 1.0f) is returned -// - if g1 > g2, then (1.0f, 0.0f) is returned -// -// In other words, actors in higher groups can be -// pushed around by actors in lower groups by default. -// -// These settings should cover most applications, and -// in fact not overriding these settings may likely -// result in higher performance. -// -// Dominance settings are currently specified as -// floats 0.0f or 1.0f because in the future PhysX may -// permit arbitrary fractional settings to express -// 'partly-one-way' interactions. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the dominance behavior of constraints between two actors with two + * certain dominance groups. + * + * It is possible to assign each actor to a dominance groups using + * PhysxActor::set_dominance_group(). + * + * With dominance groups one can have all constraints (contacts and joints) + * created between actors act in one direction only. This is useful if you + * want to make sure that the movement of the rider of a vehicle or the pony + * tail of a character doesn't influence the object it is attached to, while + * keeping the motion of both inherently physical. + * + * Whenever a constraint (i.e. joint or contact) between two actors (a0, a1) + * needs to be solved, the groups (g0, g1) of both actors are retrieved. Then + * the constraint dominance setting for this group pair is retrieved. + * + * In the constraint, PhysxConstraintDominance::get_0() becomes the dominance + * setting for a0, and PhysxConstraintDominance::get_1() becomes the dominance + * setting for a1. A dominance setting of 1.0f, the default, will permit the + * actor to be pushed or pulled by the other actor. A dominance setting of + * 0.0f will however prevent the actor to be pushed or pulled by the other + * actor. Thus, a PhysxConstraintDominance of (1.0f, 0.0f) makes the + * interaction one-way. + * + * The dominance matrix is initialised by default such that: - if g1 == g2, + * then (1.0f, 1.0f) is returned - if g1 < g2, then (0.0f, 1.0f) is returned - + * if g1 > g2, then (1.0f, 0.0f) is returned + * + * In other words, actors in higher groups can be pushed around by actors in + * lower groups by default. + * + * These settings should cover most applications, and in fact not overriding + * these settings may likely result in higher performance. + * + * Dominance settings are currently specified as floats 0.0f or 1.0f because + * in the future PhysX may permit arbitrary fractional settings to express + * 'partly-one-way' interactions. + */ void PhysxScene:: set_dominance_group_pair(unsigned int g1, unsigned int g2, PhysxConstraintDominance dominance ) { @@ -1734,11 +1513,9 @@ set_dominance_group_pair(unsigned int g1, unsigned int g2, PhysxConstraintDomina _ptr->setDominanceGroupPair((NxDominanceGroup)g1, (NxDominanceGroup)g2, d); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_dominance_group_pair -// Access: Published -// Description: Samples the dominance matrix. -//////////////////////////////////////////////////////////////////// +/** + * Samples the dominance matrix. + */ PhysxConstraintDominance PhysxScene:: get_dominance_group_pair(unsigned int g1, unsigned int g2) { @@ -1752,17 +1529,15 @@ get_dominance_group_pair(unsigned int g1, unsigned int g2) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxScene::get_wheel_shape_material -// Access: Published -// Description: Gets the shared material for all wheel shapes. -// -// If this material is not already created then -// calling this method will create the material. -// -// Normally users don't need to call this method. It -// is used internally by PhysWheel::create_wheel. -//////////////////////////////////////////////////////////////////// +/** + * Gets the shared material for all wheel shapes. + * + * If this material is not already created then calling this method will + * create the material. + * + * Normally users don't need to call this method. It is used internally by + * PhysWheel::create_wheel. + */ PhysxMaterial *PhysxScene:: get_wheel_shape_material() { @@ -1776,4 +1551,3 @@ get_wheel_shape_material() { return _wheelShapeMaterial; } - diff --git a/panda/src/physx/physxScene.h b/panda/src/physx/physxScene.h index 0d48ea2797..b26105c644 100644 --- a/panda/src/physx/physxScene.h +++ b/panda/src/physx/physxScene.h @@ -1,16 +1,15 @@ -// Filename: physxScene.h -// Created by: enn0x (14Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxScene.h + * @author enn0x + * @date 2009-09-14 + */ #ifndef PHYSXSCENE_H #define PHYSXSCENE_H @@ -56,20 +55,17 @@ class PhysxClothDesc; class PhysxSoftBody; class PhysxSoftBodyDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxScene -// Description : A scene is a collection of bodies, constraints, -// and effectors which can interact. -// -// The scene simulates the behavior of these objects -// over time. Several scenes may exist at the same -// time, but each body, constraint, or effector object -// is specific to a scene -- they may not be shared. -// -// For example, attempting to create a joint in one -// scene and then using it to attach bodies from a -// different scene results in undefined behavior. -//////////////////////////////////////////////////////////////////// +/** + * A scene is a collection of bodies, constraints, and effectors which can + * interact. + * + * The scene simulates the behavior of these objects over time. Several + * scenes may exist at the same time, but each body, constraint, or effector + * object is specific to a scene -- they may not be shared. + * + * For example, attempting to create a joint in one scene and then using it to + * attach bodies from a different scene results in undefined behavior. + */ class EXPCL_PANDAPHYSX PhysxScene : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -97,7 +93,7 @@ PUBLISHED: LVector3f get_gravity() const; PhysxSceneStats2 get_stats2() const; - bool get_flag(PhysxSceneFlag flag) const; + bool get_flag(PhysxSceneFlag flag) const; bool is_hardware_scene() const; // Actors @@ -220,7 +216,6 @@ PUBLISHED: PhysxFilterOp get_filter_op2() const; PhysxConstraintDominance get_dominance_group_pair(unsigned int g1, unsigned int g2); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -263,14 +258,13 @@ private: static PStatCollector _pcollector_cloth; static PStatCollector _pcollector_softbody; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxScene", + register_type(_type_handle, "PhysxScene", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSceneDesc.I b/panda/src/physx/physxSceneDesc.I index fb3640dfe3..c5134fa6f0 100644 --- a/panda/src/physx/physxSceneDesc.I +++ b/panda/src/physx/physxSceneDesc.I @@ -1,58 +1,46 @@ -// Filename: physxSceneDesc.I -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneDesc.I + * @author enn0x + * @date 2009-09-05 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSceneDesc:: PhysxSceneDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSceneDesc:: ~PhysxSceneDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxSceneDesc:: set_to_default() { _desc.setToDefault(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSceneDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxSceneDesc.cxx b/panda/src/physx/physxSceneDesc.cxx index d5cb81626a..a7ebd6c63b 100644 --- a/panda/src/physx/physxSceneDesc.cxx +++ b/panda/src/physx/physxSceneDesc.cxx @@ -1,26 +1,23 @@ -// Filename: physxSceneDesc.cxx -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneDesc.cxx + * @author enn0x + * @date 2009-09-05 + */ #include "physxSceneDesc.h" #include "physxManager.h" #include "physxBounds3.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_gravity -// Access: Published -// Description: Sets the gravity vector. -//////////////////////////////////////////////////////////////////// +/** + * Sets the gravity vector. + */ void PhysxSceneDesc:: set_gravity(const LVector3f &gravity) { @@ -28,22 +25,18 @@ set_gravity(const LVector3f &gravity) { _desc.gravity = PhysxManager::vec3_to_nxVec3(gravity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_gravity -// Access: Published -// Description: Get the gravity vector. -//////////////////////////////////////////////////////////////////// +/** + * Get the gravity vector. + */ LVector3f PhysxSceneDesc:: get_gravity() const { return PhysxManager::nxVec3_to_vec3(_desc.gravity); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_flag -// Access: Published -// Description: Raise or lower individual scene flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual scene flags. + */ void PhysxSceneDesc:: set_flag(const PhysxSceneFlag flag, bool value) { @@ -55,224 +48,171 @@ set_flag(const PhysxSceneFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_flag -// Access: Published -// Description: Returns the specified scene flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified scene flag. + */ bool PhysxSceneDesc:: get_flag(const PhysxSceneFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_max_bounds -// Access: Published -// Description: Set the max scene bounds. -// -// If scene bounds are provided (maxBounds in the -// descriptor), the SDK takes advantage of this -// information to accelerate scene-level collision -// queries (e.g. raycasting). When using maxBounds, -// you have to make sure created objects stay within -// the scene bounds. In particular, the position of -// dynamic shapes should stay within the provided -// bounds. Otherwise the shapes outside the bounds -// will not be taken into account by all scene queries -// (raycasting, sweep tests, overlap tests, etc). They -// will nonetheless still work correctly for the main -// physics simulation. -//////////////////////////////////////////////////////////////////// +/** + * Set the max scene bounds. + * + * If scene bounds are provided (maxBounds in the descriptor), the SDK takes + * advantage of this information to accelerate scene-level collision queries + * (e.g. raycasting). When using maxBounds, you have to make sure created + * objects stay within the scene bounds. In particular, the position of + * dynamic shapes should stay within the provided bounds. Otherwise the + * shapes outside the bounds will not be taken into account by all scene + * queries (raycasting, sweep tests, overlap tests, etc). They will + * nonetheless still work correctly for the main physics simulation. + */ void PhysxSceneDesc:: set_max_bounds(PhysxBounds3 &bounds) { _desc.maxBounds = &(bounds._bounds); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_max_bounds -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxBounds3 PhysxSceneDesc:: get_max_bounds() const { assert(false /* Not implemented */); - //PhysxBounds3 value; - //value._bounds = *(_desc.maxBounds); - //return value; + // PhysxBounds3 value; value._bounds = *(_desc.maxBounds); return value; return PhysxBounds3(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_static_structure -// Access: Published -// Description: Defines the structure used to store static -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Defines the structure used to store static objects. + */ void PhysxSceneDesc:: set_static_structure(PhysxPruningStructure value) { _desc.staticStructure = (NxPruningStructure)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_dynamic_structure -// Access: Published -// Description: Defines the subdivision level for acceleration -// structures used for scene queries. -// This is only used when maxBounds are defined! -//////////////////////////////////////////////////////////////////// +/** + * Defines the subdivision level for acceleration structures used for scene + * queries. This is only used when maxBounds are defined! + */ void PhysxSceneDesc:: set_dynamic_structure(PhysxPruningStructure value) { _desc.dynamicStructure = (NxPruningStructure)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_static_structure -// Access: Published -// Description: Returns the structure used to store static -// objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the structure used to store static objects. + */ PhysxEnums::PhysxPruningStructure PhysxSceneDesc:: get_static_structure() const { return (PhysxPruningStructure)_desc.staticStructure; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_dynamic_structure -// Access: Published -// Description: Returns the subdivision level for acceleration -// structures used for scene queries. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subdivision level for acceleration structures used for scene + * queries. + */ PhysxEnums::PhysxPruningStructure PhysxSceneDesc:: get_dynamic_structure() const { return (PhysxPruningStructure)_desc.dynamicStructure; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_subdivision_level -// Access: Published -// Description: Defines the subdivision level for acceleration -// structures used for scene queries. -// This is only used when maxBounds are defined! -//////////////////////////////////////////////////////////////////// +/** + * Defines the subdivision level for acceleration structures used for scene + * queries. This is only used when maxBounds are defined! + */ void PhysxSceneDesc:: set_subdivision_level(unsigned int value) { _desc.subdivisionLevel = (NxU32)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_num_grid_cells_x -// Access: Published -// Description: Defines the number of broadphase cells along the -// grid x-axis. Must be power of two. Max is 8 at the -// moment. The broadphase type must be set to -// BPT_sap_multi for this parameter to have -// an effect. -//////////////////////////////////////////////////////////////////// +/** + * Defines the number of broadphase cells along the grid x-axis. Must be + * power of two. Max is 8 at the moment. The broadphase type must be set to + * BPT_sap_multi for this parameter to have an effect. + */ void PhysxSceneDesc:: set_num_grid_cells_x(unsigned int value) { _desc.nbGridCellsX = (NxU32)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_num_grid_cells_y -// Access: Published -// Description: Defines the number of broadphase cells along the -// grid y-axis. Must be power of two. Max is 8 at the -// moment. The broadphase type must be set to -// BPT_sap_multi for this parameter to have -// an effect. -//////////////////////////////////////////////////////////////////// +/** + * Defines the number of broadphase cells along the grid y-axis. Must be + * power of two. Max is 8 at the moment. The broadphase type must be set to + * BPT_sap_multi for this parameter to have an effect. + */ void PhysxSceneDesc:: set_num_grid_cells_y(unsigned int value) { _desc.nbGridCellsY = (NxU32)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_subdivision_level -// Access: Published -// Description: Returns the subdivision level for acceleration -// structures used for scene queries. -//////////////////////////////////////////////////////////////////// +/** + * Returns the subdivision level for acceleration structures used for scene + * queries. + */ unsigned int PhysxSceneDesc:: get_subdivision_level() const { return _desc.subdivisionLevel; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_num_grid_cells_x -// Access: Published -// Description: Returns the number of broadphase cells along the -// grid x-axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of broadphase cells along the grid x-axis. + */ unsigned int PhysxSceneDesc:: get_num_grid_cells_x() const { return _desc.nbGridCellsX; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_num_grid_cells_y -// Access: Published -// Description: Returns the number of broadphase cells along the -// grid y-axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of broadphase cells along the grid y-axis. + */ unsigned int PhysxSceneDesc:: get_num_grid_cells_y() const { return _desc.nbGridCellsY; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::set_bp_type -// Access: Published -// Description: Defines which type of broadphase to use. -// -// (1) BPT_sap_single: A sweep-and-prune (SAP) -// algorithm to find pairs of potentially colliding -// shapes. -// -// (2) BPT_sap_multi: A multi sweep-and-prune -// algorithm to find pairs of potentially colliding -// shapes. Uses a configurable 2D grid to divide the -// scene space into cells. The potentially overlapping -// shape pairs are detected in each cell and the -// information is merged together. This approach is -// usually faster than BPT_sap_single in scenarios -// with many shapes and a high creation/deletion rate -// of shapes. However, the amount of memory required -// is considerably higher depending on the number of -// grid cells used. -// The following extra parameters need to be defined: -// - PhysxSceneDesc.set_max_bounds -// - PhysxSceneDesc.set_num_grid_cells_x -// - PhysxSceneDesc.set_num_grid_cells_y -// (the scene up direction is set via config options) -//////////////////////////////////////////////////////////////////// +/** + * Defines which type of broadphase to use. + * + * (1) BPT_sap_single: A sweep-and-prune (SAP) algorithm to find pairs of + * potentially colliding shapes. + * + * (2) BPT_sap_multi: A multi sweep-and-prune algorithm to find pairs of + * potentially colliding shapes. Uses a configurable 2D grid to divide the + * scene space into cells. The potentially overlapping shape pairs are + * detected in each cell and the information is merged together. This + * approach is usually faster than BPT_sap_single in scenarios with many + * shapes and a high creation/deletion rate of shapes. However, the amount of + * memory required is considerably higher depending on the number of grid + * cells used. The following extra parameters need to be defined: - + * PhysxSceneDesc.set_max_bounds - PhysxSceneDesc.set_num_grid_cells_x - + * PhysxSceneDesc.set_num_grid_cells_y (the scene up direction is set via + * config options) + */ void PhysxSceneDesc:: set_bp_type(PhysxBroadPhaseType value) { _desc.bpType = (NxBroadPhaseType)value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneDesc::get_bp_type -// Access: Published -// Description: Returns the type of broadphase to use. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of broadphase to use. + */ PhysxEnums::PhysxBroadPhaseType PhysxSceneDesc:: get_bp_type() const { return (PhysxBroadPhaseType)_desc.bpType; } - diff --git a/panda/src/physx/physxSceneDesc.h b/panda/src/physx/physxSceneDesc.h index 036684ba3c..3370af5290 100644 --- a/panda/src/physx/physxSceneDesc.h +++ b/panda/src/physx/physxSceneDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSceneDesc.h -// Created by: enn0x (05Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneDesc.h + * @author enn0x + * @date 2009-09-05 + */ #ifndef PHYSXSCENEDESC_H #define PHYSXSCENEDESC_H @@ -23,10 +22,9 @@ class PhysxBounds3; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSceneDesc -// Description : Descriptor for PhysxScene. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for PhysxScene. + */ class EXPCL_PANDAPHYSX PhysxSceneDesc : public PhysxEnums { PUBLISHED: diff --git a/panda/src/physx/physxSceneStats2.I b/panda/src/physx/physxSceneStats2.I index a1d1bc35dd..e5d64f6d03 100644 --- a/panda/src/physx/physxSceneStats2.I +++ b/panda/src/physx/physxSceneStats2.I @@ -1,34 +1,28 @@ -// Filename: physxSceneStats2.I -// Created by: enn0x (20Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneStats2.I + * @author enn0x + * @date 2009-10-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::get_num_stats -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxSceneStats2:: get_num_stats() const { return _ptr->numStats; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::get_cur_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PhysxSceneStats2:: get_cur_value(unsigned int index) const { @@ -36,11 +30,9 @@ get_cur_value(unsigned int index) const { return _ptr->stats[index].curValue; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::get_max_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PhysxSceneStats2:: get_max_value(unsigned int index) const { @@ -48,11 +40,9 @@ get_max_value(unsigned int index) const { return _ptr->stats[index].maxValue; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const char * PhysxSceneStats2:: get_name(unsigned int index) const { @@ -60,15 +50,12 @@ get_name(unsigned int index) const { return _ptr->stats[index].name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::get_parent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE unsigned int PhysxSceneStats2:: get_parent(unsigned int index) const { nassertr(index < _ptr->numStats, 0); return _ptr->stats[index].parent; } - diff --git a/panda/src/physx/physxSceneStats2.cxx b/panda/src/physx/physxSceneStats2.cxx index 8459d93ae5..278c97209b 100644 --- a/panda/src/physx/physxSceneStats2.cxx +++ b/panda/src/physx/physxSceneStats2.cxx @@ -1,37 +1,31 @@ -// Filename: physxSceneStats2.cxx -// Created by: enn0x (20Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneStats2.cxx + * @author enn0x + * @date 2009-10-20 + */ #include "physxSceneStats2.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSceneStats2:: PhysxSceneStats2(const NxSceneStats2 *ptr) { _ptr = ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSceneStats2::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSceneStats2:: ~PhysxSceneStats2() { } - diff --git a/panda/src/physx/physxSceneStats2.h b/panda/src/physx/physxSceneStats2.h index b7f14498fd..1830b136e2 100644 --- a/panda/src/physx/physxSceneStats2.h +++ b/panda/src/physx/physxSceneStats2.h @@ -1,16 +1,15 @@ -// Filename: physxSceneStats2.h -// Created by: enn0x (20Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSceneStats2.h + * @author enn0x + * @date 2009-10-20 + */ #ifndef PHYSXSCENESTATS2_H #define PHYSXSCENESTATS2_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSceneStats2 -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxSceneStats2 { PUBLISHED: diff --git a/panda/src/physx/physxSegment.I b/panda/src/physx/physxSegment.I index 06b0e26dc0..ea2da6e716 100644 --- a/panda/src/physx/physxSegment.I +++ b/panda/src/physx/physxSegment.I @@ -1,46 +1,37 @@ -// Filename: physxSegment.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSegment.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSegment:: PhysxSegment() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSegment:: PhysxSegment(const PhysxSegment &segment) { _segment = segment._segment; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSegment:: ~PhysxSegment() { } - diff --git a/panda/src/physx/physxSegment.cxx b/panda/src/physx/physxSegment.cxx index e6f5afe2ed..f432711d9c 100644 --- a/panda/src/physx/physxSegment.cxx +++ b/panda/src/physx/physxSegment.cxx @@ -1,25 +1,22 @@ -// Filename: physxSegment.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSegment.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxSegment.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSegment:: PhysxSegment(const LPoint3f &p0, const LPoint3f &p1) { @@ -27,22 +24,18 @@ PhysxSegment(const LPoint3f &p0, const LPoint3f &p1) { _segment.p1 = PhysxManager::point3_to_nxVec3(p1); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::get_p0 -// Access: Published -// Description: Returns the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the start point of the segment. + */ LPoint3f PhysxSegment:: get_p0() const { return PhysxManager::nxVec3_to_vec3(_segment.p0); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::set_p0 -// Access: Published -// Description: Sets the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Sets the start point of the segment. + */ void PhysxSegment:: set_p0(LPoint3f p) { @@ -51,22 +44,18 @@ set_p0(LPoint3f p) { _segment.p0 = PhysxManager::vec3_to_nxVec3(p); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::get_p1 -// Access: Published -// Description: Returns the end point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the end point of the segment. + */ LPoint3f PhysxSegment:: get_p1() const { return PhysxManager::nxVec3_to_vec3(_segment.p1); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::set_p1 -// Access: Published -// Description: Sets the end point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Sets the end point of the segment. + */ void PhysxSegment:: set_p1(LPoint3f p) { @@ -75,23 +64,19 @@ set_p1(LPoint3f p) { _segment.p1 = PhysxManager::vec3_to_nxVec3(p); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::get_origin -// Access: Published -// Description: Returns the start point of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the start point of the segment. + */ LPoint3f PhysxSegment:: get_origin() const { return PhysxManager::nxVec3_to_point3(_segment.getOrigin()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::compute_direction -// Access: Published -// Description: Returns the direction vector from the segment's -// start point to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the direction vector from the segment's start point to it's end + * point. + */ void PhysxSegment:: compute_direction(LPoint3f &dir) const { @@ -102,23 +87,18 @@ compute_direction(LPoint3f &dir) const { PhysxManager::update_point3_from_nxVec3(dir, nDir); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::compute_length -// Access: Published -// Description: Returns the distance from the segment's start point -// to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the distance from the segment's start point to it's end point. + */ float PhysxSegment:: compute_length() const { return _segment.computeLength(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::compute_point -// Access: Published -// Description: Computes a point on the segment. -//////////////////////////////////////////////////////////////////// +/** + * Computes a point on the segment. + */ void PhysxSegment:: compute_point(LPoint3f &p, float t) const { @@ -129,24 +109,19 @@ compute_point(LPoint3f &p, float t) const { PhysxManager::update_point3_from_nxVec3(p, nP); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::compute_square_length -// Access: Published -// Description: Returns the square distance from the segment's -// start point to it's end point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the square distance from the segment's start point to it's end + * point. + */ float PhysxSegment:: compute_square_length() const { return _segment.computeSquareLength(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSegment::set_origin_direction -// Access: Published -// Description: Setup this segment from origin (start point) and -// direction vector. -//////////////////////////////////////////////////////////////////// +/** + * Setup this segment from origin (start point) and direction vector. + */ void PhysxSegment:: set_origin_direction(const LPoint3f &origin, const LVector3f &direction) { @@ -156,4 +131,3 @@ set_origin_direction(const LPoint3f &origin, const LVector3f &direction) { _segment.setOriginDirection(PhysxManager::point3_to_nxVec3(origin), PhysxManager::vec3_to_nxVec3(direction)); } - diff --git a/panda/src/physx/physxSegment.h b/panda/src/physx/physxSegment.h index 25891f8920..14633b7030 100644 --- a/panda/src/physx/physxSegment.h +++ b/panda/src/physx/physxSegment.h @@ -1,16 +1,15 @@ -// Filename: physxSegment.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSegment.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXSEGMENT_H #define PHYSXSEGMENT_H @@ -20,10 +19,9 @@ #include "config_physx.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSegment -// Description : Represents a line segment. -//////////////////////////////////////////////////////////////////// +/** + * Represents a line segment. + */ class EXPCL_PANDAPHYSX PhysxSegment { PUBLISHED: diff --git a/panda/src/physx/physxShape.I b/panda/src/physx/physxShape.I index 2156726ebf..1aa796edab 100644 --- a/panda/src/physx/physxShape.I +++ b/panda/src/physx/physxShape.I @@ -1,45 +1,36 @@ -// Filename: physxShape.I -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShape.I + * @author enn0x + * @date 2009-09-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxShape:: PhysxShape() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxShape:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxShape:: ls(ostream &out, int indent_level) const { @@ -47,4 +38,3 @@ ls(ostream &out, int indent_level) const { << " " << _name << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxShape.cxx b/panda/src/physx/physxShape.cxx index 9d958448a7..926001f1be 100644 --- a/panda/src/physx/physxShape.cxx +++ b/panda/src/physx/physxShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxShape.cxx -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShape.cxx + * @author enn0x + * @date 2009-09-16 + */ #include "physxShape.h" #include "physxManager.h" @@ -34,11 +33,9 @@ TypeHandle PhysxShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShape:: release() { @@ -48,11 +45,9 @@ release() { ptr()->getActor().releaseShape(*ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::factory -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxShape *PhysxShape:: factory(NxShapeType shapeType) { @@ -87,12 +82,9 @@ factory(NxShapeType shapeType) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_actor -// Access: Published -// Description: Retrieves the actor which this shape is associated -// with. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the actor which this shape is associated with. + */ PhysxActor *PhysxShape:: get_actor() const { @@ -100,14 +92,10 @@ get_actor() const { return (PhysxActor *)(ptr()->getActor().userData); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_name -// Access: Published -// Description: Sets a name string for this object. The name can -// be retrieved again with get_name(). -// This is for debugging and is not used by the -// physics engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for this object. The name can be retrieved again with + * get_name(). This is for debugging and is not used by the physics engine. + */ void PhysxShape:: set_name(const char *name) { @@ -117,11 +105,9 @@ set_name(const char *name) { ptr()->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_name -// Access: Published -// Description: Returns the name string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name string. + */ const char *PhysxShape:: get_name() const { @@ -129,23 +115,17 @@ get_name() const { return ptr()->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_flag -// Access: Published -// Description: Sets the specified shape flag. -// -// The shape may be turned into a trigger by setting -// one or more of the TriggerFlags to true. A trigger -// shape will not collide with other shapes. Instead, -// if a shape enters the trigger's volume, a trigger -// event will be sent. Trigger events can be listened -// to by DirectObjects. -// -// The following trigger events can be sent: -// - physx-trigger-enter -// - physx-trigger-stay -// - physx-trigger-leave -//////////////////////////////////////////////////////////////////// +/** + * Sets the specified shape flag. + * + * The shape may be turned into a trigger by setting one or more of the + * TriggerFlags to true. A trigger shape will not collide with other shapes. + * Instead, if a shape enters the trigger's volume, a trigger event will be + * sent. Trigger events can be listened to by DirectObjects. + * + * The following trigger events can be sent: - physx-trigger-enter - physx- + * trigger-stay - physx-trigger-leave + */ void PhysxShape:: set_flag(PhysxShapeFlag flag, bool value) { @@ -154,11 +134,9 @@ set_flag(PhysxShapeFlag flag, bool value) { ptr()->setFlag((NxShapeFlag)flag, value); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_flag -// Access: Published -// Description: Returns the specified shape flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified shape flag. + */ bool PhysxShape:: get_flag(PhysxShapeFlag flag) const { @@ -167,12 +145,9 @@ get_flag(PhysxShapeFlag flag) const { return (ptr()->getFlag((NxShapeFlag)flag)) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_skin_width -// Access: Published -// Description: Sets the skin width. -// The skin width must be non-negative. -//////////////////////////////////////////////////////////////////// +/** + * Sets the skin width. The skin width must be non-negative. + */ void PhysxShape:: set_skin_width(float skinWidth) { @@ -182,11 +157,9 @@ set_skin_width(float skinWidth) { ptr()->setSkinWidth(skinWidth); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_skin_width -// Access: Published -// Description: Returns the skin width. -//////////////////////////////////////////////////////////////////// +/** + * Returns the skin width. + */ float PhysxShape:: get_skin_width() const { @@ -195,17 +168,13 @@ get_skin_width() const { return ptr()->getSkinWidth(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_group -// Access: Published -// Description: Sets which collision group this shape is part of. -// -// Default group is 0. Maximum possible group is 31. -// Collision groups are sets of shapes which may or -// may not be set to collision detect with each other; -// this can be set using -// PhysxScene::set_group_collision_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Sets which collision group this shape is part of. + * + * Default group is 0. Maximum possible group is 31. Collision groups are sets + * of shapes which may or may not be set to collision detect with each other; + * this can be set using PhysxScene::set_group_collision_flag(). + */ void PhysxShape:: set_group(unsigned short group) { @@ -215,13 +184,10 @@ set_group(unsigned short group) { ptr()->setGroup(group); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_group -// Access: Published -// Description: Retrieves the collision group set for this shape. -// The collision group is an integer between 0 and -// 31. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the collision group set for this shape. The collision group is + * an integer between 0 and 31. + */ unsigned short PhysxShape:: get_group() const { @@ -230,20 +196,16 @@ get_group() const { return ptr()->getGroup(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_local_pos -// Access: Published -// Description: Set the position of the shape in actor space, i.e. -// relative to the actor it is owned by. -// -// Calling this method does NOT wake the associated -// actor up automatically. -// -// Calling this method does not automatically update -// the inertia properties of the owning actor (if -// applicable); use -// PhysxActor::update_mass_from_shapes() to do this. -//////////////////////////////////////////////////////////////////// +/** + * Set the position of the shape in actor space, i.e. relative to the actor + * it is owned by. + * + * Calling this method does NOT wake the associated actor up automatically. + * + * Calling this method does not automatically update the inertia properties of + * the owning actor (if applicable); use PhysxActor::update_mass_from_shapes() + * to do this. + */ void PhysxShape:: set_local_pos(const LPoint3f &pos) { @@ -252,12 +214,10 @@ set_local_pos(const LPoint3f &pos) { ptr()->setLocalPosition(PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_local_pos -// Access: Published -// Description: Retrieve the position of the shape in actor space, -// i.e. relative to the actor it is owned by. -//////////////////////////////////////////////////////////////////// +/** + * Retrieve the position of the shape in actor space, i.e. relative to the + * actor it is owned by. + */ LPoint3f PhysxShape:: get_local_pos() const { @@ -266,20 +226,16 @@ get_local_pos() const { return PhysxManager::nxVec3_to_point3(ptr()->getLocalPosition()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_local_mat -// Access: Published -// Description: Set the transform of the shape in actor space, -// i.e. relative to the actor it is owned by. -// -// Calling this method does NOT wake the associated -// actor up automatically. -// -// Calling this method does not automatically update -// the inertia properties of the owning actor (if -// applicable); use -// PhysxActor::update_mass_from_shapes() to do this. -//////////////////////////////////////////////////////////////////// +/** + * Set the transform of the shape in actor space, i.e. relative to the actor + * it is owned by. + * + * Calling this method does NOT wake the associated actor up automatically. + * + * Calling this method does not automatically update the inertia properties of + * the owning actor (if applicable); use PhysxActor::update_mass_from_shapes() + * to do this. + */ void PhysxShape:: set_local_mat(const LMatrix4f &mat) { @@ -288,12 +244,10 @@ set_local_mat(const LMatrix4f &mat) { ptr()->setLocalPose(PhysxManager::mat4_to_nxMat34(mat)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_local_mat -// Access: Published -// Description: Retrieve the transform of the shape in actor space, -// i.e. relative to the actor it is owned by. -//////////////////////////////////////////////////////////////////// +/** + * Retrieve the transform of the shape in actor space, i.e. relative to the + * actor it is owned by. + */ LMatrix4f PhysxShape:: get_local_mat() const { @@ -302,12 +256,9 @@ get_local_mat() const { return PhysxManager::nxMat34_to_mat4(ptr()->getLocalPose()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_material_index -// Access: Published -// Description: Returns the material index currently assigned to -// the shape. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material index currently assigned to the shape. + */ unsigned short PhysxShape:: get_material_index() const { @@ -316,11 +267,9 @@ get_material_index() const { return (unsigned int)index; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_material -// Access: Published -// Description: Assigns a material to the shape. -//////////////////////////////////////////////////////////////////// +/** + * Assigns a material to the shape. + */ void PhysxShape:: set_material(const PhysxMaterial &material) { @@ -328,17 +277,14 @@ set_material(const PhysxMaterial &material) { ptr()->setMaterial(material.ptr()->getMaterialIndex()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_material_index -// Access: Published -// Description: Assigns a material index to the shape. -// -// The material index can be retrieved by calling -// PhysxMaterial::get_material_index(). If the material -// index is invalid, it will still be recorded, but -// the default material (at index 0) will effectively -// be used for simulation. -//////////////////////////////////////////////////////////////////// +/** + * Assigns a material index to the shape. + * + * The material index can be retrieved by calling + * PhysxMaterial::get_material_index(). If the material index is invalid, it + * will still be recorded, but the default material (at index 0) will + * effectively be used for simulation. + */ void PhysxShape:: set_material_index(unsigned short index) { @@ -346,13 +292,10 @@ set_material_index(unsigned short index) { ptr()->setMaterial((NxMaterialIndex)index); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_groups_mask -// Access: Published -// Description: Sets 128-bit mask used for collision filtering. -// Does NOT wake the associated actor up -// automatically. -//////////////////////////////////////////////////////////////////// +/** + * Sets 128-bit mask used for collision filtering. Does NOT wake the + * associated actor up automatically. + */ void PhysxShape:: set_groups_mask(const PhysxGroupsMask &mask) { @@ -360,11 +303,9 @@ set_groups_mask(const PhysxGroupsMask &mask) { ptr()->setGroupsMask(mask.get_mask()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_groups_mask -// Access: Published -// Description: Gets 128-bit mask used for collision filtering. -//////////////////////////////////////////////////////////////////// +/** + * Gets 128-bit mask used for collision filtering. + */ PhysxGroupsMask PhysxShape:: get_groups_mask() const { @@ -374,11 +315,9 @@ get_groups_mask() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_world_bounds -// Access: Published -// Description: Returns a world space AABB enclosing this shape. -//////////////////////////////////////////////////////////////////// +/** + * Returns a world space AABB enclosing this shape. + */ PhysxBounds3 PhysxShape:: get_world_bounds() const { @@ -388,12 +327,9 @@ get_world_bounds() const { return bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::check_overlap_aabb -// Access: Published -// Description: Checks whether the shape overlaps a world-space -// AABB or not. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the shape overlaps a world-space AABB or not. + */ bool PhysxShape:: check_overlap_aabb(const PhysxBounds3 &world_bounds) const { @@ -401,12 +337,9 @@ check_overlap_aabb(const PhysxBounds3 &world_bounds) const { return ptr()->checkOverlapAABB(world_bounds._bounds); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::check_overlap_capsule -// Access: Published -// Description: Checks whether the shape overlaps a world-space -// capsule or not. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the shape overlaps a world-space capsule or not. + */ bool PhysxShape:: check_overlap_capsule(const PhysxCapsule &world_capsule) const { @@ -414,12 +347,9 @@ check_overlap_capsule(const PhysxCapsule &world_capsule) const { return ptr()->checkOverlapCapsule(world_capsule._capsule); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::check_overlap_obb -// Access: Published -// Description: Checks whether the shape overlaps a world-space -// OBB or not. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the shape overlaps a world-space OBB or not. + */ bool PhysxShape:: check_overlap_obb(const PhysxBox &world_box) const { @@ -427,12 +357,9 @@ check_overlap_obb(const PhysxBox &world_box) const { return ptr()->checkOverlapOBB(world_box._box); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::check_overlap_sphere -// Access: Published -// Description: Checks whether the shape overlaps a world-space -// sphere or not. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the shape overlaps a world-space sphere or not. + */ bool PhysxShape:: check_overlap_sphere(const PhysxSphere &world_sphere) const { @@ -440,11 +367,9 @@ check_overlap_sphere(const PhysxSphere &world_sphere) const { return ptr()->checkOverlapSphere(world_sphere._sphere); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::raycast -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxRaycastHit PhysxShape:: raycast(const PhysxRay &worldRay, bool firstHit, bool smoothNormal) const { @@ -463,11 +388,9 @@ raycast(const PhysxRay &worldRay, bool firstHit, bool smoothNormal) const { return PhysxRaycastHit(hit); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::set_ccd_skeleton -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShape:: set_ccd_skeleton(PhysxCcdSkeleton *skel) { @@ -477,11 +400,9 @@ set_ccd_skeleton(PhysxCcdSkeleton *skel) { _skel = skel; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShape::get_ccd_skeleton -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxCcdSkeleton *PhysxShape:: get_ccd_skeleton() const { @@ -489,4 +410,3 @@ get_ccd_skeleton() const { return _skel; } - diff --git a/panda/src/physx/physxShape.h b/panda/src/physx/physxShape.h index 222aaca193..660eecc211 100644 --- a/panda/src/physx/physxShape.h +++ b/panda/src/physx/physxShape.h @@ -1,16 +1,15 @@ -// Filename: physxShape.h -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShape.h + * @author enn0x + * @date 2009-09-16 + */ #ifndef PHYSXSHAPE_H #define PHYSXSHAPE_H @@ -34,10 +33,9 @@ class PhysxRay; class PhysxRaycastHit; class PhysxCcdSkeleton; -//////////////////////////////////////////////////////////////////// -// Class : PhysxShape -// Description : Abstract base class for shapes. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for shapes. + */ class EXPCL_PANDAPHYSX PhysxShape : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -91,14 +89,13 @@ private: string _name; PT(PhysxCcdSkeleton) _skel; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxShape", + register_type(_type_handle, "PhysxShape", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxShapeDesc.I b/panda/src/physx/physxShapeDesc.I index 9065cfa569..e16895bb26 100644 --- a/panda/src/physx/physxShapeDesc.I +++ b/panda/src/physx/physxShapeDesc.I @@ -1,36 +1,28 @@ -// Filename: physxShapeDesc.I -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShapeDesc.I + * @author enn0x + * @date 2009-09-08 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxShapeDesc:: PhysxShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxShapeDesc:: ~PhysxShapeDesc() { } - diff --git a/panda/src/physx/physxShapeDesc.cxx b/panda/src/physx/physxShapeDesc.cxx index f2369737ef..2929f00692 100644 --- a/panda/src/physx/physxShapeDesc.cxx +++ b/panda/src/physx/physxShapeDesc.cxx @@ -1,26 +1,23 @@ -// Filename: physxShapeDesc.cxx -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShapeDesc.cxx + * @author enn0x + * @date 2009-09-08 + */ #include "physxShapeDesc.h" #include "physxManager.h" #include "physxMaterial.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_name -// Access: Published -// Description: Sets a possible debug name. -//////////////////////////////////////////////////////////////////// +/** + * Sets a possible debug name. + */ void PhysxShapeDesc:: set_name(const char *name) { @@ -28,14 +25,11 @@ set_name(const char *name) { ptr()->name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_trigger -// Access: Published -// Description: This shape will become a trigger shape if this -// parameter is set to TRUE. It won't take part in -// collisions, but trigger events if some other -// shape passes through it. -//////////////////////////////////////////////////////////////////// +/** + * This shape will become a trigger shape if this parameter is set to TRUE. It + * won't take part in collisions, but trigger events if some other shape + * passes through it. + */ void PhysxShapeDesc:: set_trigger(bool value) { @@ -47,11 +41,9 @@ set_trigger(bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_local_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_local_pos(const LPoint3f &pos) { @@ -59,11 +51,9 @@ set_local_pos(const LPoint3f &pos) { ptr()->localPose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_local_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_local_mat(const LMatrix4f &mat) { @@ -71,11 +61,9 @@ set_local_mat(const LMatrix4f &mat) { ptr()->localPose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_local_hpr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_local_hpr(float h, float p, float r) { @@ -89,28 +77,22 @@ set_local_hpr(float h, float p, float r) { ptr()->localPose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_skin_width -// Access: Published -// Description: Specifies by how much shapes can interpenetrate. -// -// Two shapes will interpenetrate by the sum of their -// skin widths. This means that their graphical -// representations should be adjusted so that they -// just touch when the shapes are interpenetrating. -// -// The default skin width is the 'physx-skin-width' -// parameter. -// -// A skin width sum of zero for two bodies is not -// permitted because it will lead to an unstable -// simulation. -// -// If your simulation jitters because resting bodies -// occasionally lose contact, increasing the size of -// your collision volumes and the skin width may -// improve things. -//////////////////////////////////////////////////////////////////// +/** + * Specifies by how much shapes can interpenetrate. + * + * Two shapes will interpenetrate by the sum of their skin widths. This means + * that their graphical representations should be adjusted so that they just + * touch when the shapes are interpenetrating. + * + * The default skin width is the 'physx-skin-width' parameter. + * + * A skin width sum of zero for two bodies is not permitted because it will + * lead to an unstable simulation. + * + * If your simulation jitters because resting bodies occasionally lose + * contact, increasing the size of your collision volumes and the skin width + * may improve things. + */ void PhysxShapeDesc:: set_skin_width(float skinWidth) { @@ -118,11 +100,9 @@ set_skin_width(float skinWidth) { ptr()->skinWidth = skinWidth; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_shape_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_shape_flag(const PhysxShapeFlag flag, bool value) { @@ -134,32 +114,25 @@ set_shape_flag(const PhysxShapeFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_mass -// Access: Published -// Description: Sets the mass of this individual shape when -// computing mass inertial properties for a rigidbody. -// When mass<=0.0 then density and volume determine -// the mass. Note that this will only be used if the -// body has a zero inertia tensor, or if you call -// PhysxActor::update_mass_from_shapes explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mass of this individual shape when computing mass inertial + * properties for a rigidbody. When mass<=0.0 then density and volume + * determine the mass. Note that this will only be used if the body has a + * zero inertia tensor, or if you call PhysxActor::update_mass_from_shapes + * explicitly. + */ void PhysxShapeDesc:: set_mass(float mass) { ptr()->mass = mass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_density -// Access: Published -// Description: Sets the density of this individual shape when -// computing mass inertial properties for a rigidbody -// (unless a valid mass >0.0 is provided). Note that -// this will only be used if the body has a zero -// inertia tensor, or if you call -// PhysxActor::update_mass_from_shapes explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Sets the density of this individual shape when computing mass inertial + * properties for a rigidbody (unless a valid mass >0.0 is provided). Note + * that this will only be used if the body has a zero inertia tensor, or if + * you call PhysxActor::update_mass_from_shapes explicitly. + */ void PhysxShapeDesc:: set_density(float density) { @@ -167,135 +140,110 @@ set_density(float density) { ptr()->density = density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_group -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_group(unsigned short group) { ptr()->group = group; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxShapeDesc:: get_name() const { return ptr()->name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_local_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxShapeDesc:: get_local_pos() const { return PhysxManager::nxVec3_to_point3(ptr()->localPose.t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_local_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4f PhysxShapeDesc:: get_local_mat() const { return PhysxManager::nxMat34_to_mat4(ptr()->localPose); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_skin_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxShapeDesc:: get_skin_width() const { return ptr()->skinWidth; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_shape_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxShapeDesc:: get_shape_flag(const PhysxShapeFlag flag) const { return (ptr()->shapeFlags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxShapeDesc:: get_mass() const { return ptr()->mass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxShapeDesc:: get_density() const { return ptr()->density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_group -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned short PhysxShapeDesc:: get_group() const { return ptr()->group; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_material -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_material(const PhysxMaterial &material) { ptr()->materialIndex = material.ptr()->getMaterialIndex(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::set_material_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxShapeDesc:: set_material_index(unsigned short index) { ptr()->materialIndex = index; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxShapeDesc::get_material_index -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned short PhysxShapeDesc:: get_material_index() const { return ptr()->materialIndex; } - diff --git a/panda/src/physx/physxShapeDesc.h b/panda/src/physx/physxShapeDesc.h index cdcf976b0b..6ae7452a79 100644 --- a/panda/src/physx/physxShapeDesc.h +++ b/panda/src/physx/physxShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxShapeDesc.h -// Created by: enn0x (08Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxShapeDesc.h + * @author enn0x + * @date 2009-09-08 + */ #ifndef PHYSXSHAPEDESC_H #define PHYSXSHAPEDESC_H @@ -23,12 +22,10 @@ class PhysxMaterial; -//////////////////////////////////////////////////////////////////// -// Class : PhysxShapeDesc -// Description : Abstract base class for shape descriptors. -// Descriptors for all the different shape types are -// derived from this class. -//////////////////////////////////////////////////////////////////// +/** + * Abstract base class for shape descriptors. Descriptors for all the + * different shape types are derived from this class. + */ class EXPCL_PANDAPHYSX PhysxShapeDesc : public PhysxEnums, public ReferenceCount { PUBLISHED: diff --git a/panda/src/physx/physxSoftBody.I b/panda/src/physx/physxSoftBody.I index 92ea648ff8..de1a958608 100644 --- a/panda/src/physx/physxSoftBody.I +++ b/panda/src/physx/physxSoftBody.I @@ -1,55 +1,44 @@ -// Filename: physxSoftBody.I -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBody.I + * @author enn0x + * @date 2010-09-13 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBody:: PhysxSoftBody() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBody:: ~PhysxSoftBody() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxSoftBody:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxSoftBody:: ls(ostream &out, int indent_level) const { @@ -63,4 +52,3 @@ ls(ostream &out, int indent_level) const { out << "\n"; } - diff --git a/panda/src/physx/physxSoftBody.cxx b/panda/src/physx/physxSoftBody.cxx index 5263fac19d..0fb78a6770 100644 --- a/panda/src/physx/physxSoftBody.cxx +++ b/panda/src/physx/physxSoftBody.cxx @@ -1,16 +1,15 @@ -// Filename: physxSoftBody.cxx -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBody.cxx + * @author enn0x + * @date 2010-09-13 + */ #include "physxSoftBody.h" #include "physxSoftBodyDesc.h" @@ -22,11 +21,9 @@ TypeHandle PhysxSoftBody::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBody:: link(NxSoftBody *softbodyPtr) { @@ -41,11 +38,9 @@ link(NxSoftBody *softbodyPtr) { scene->_softbodies.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBody:: unlink() { @@ -59,11 +54,9 @@ unlink() { _node = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBody:: release() { @@ -74,11 +67,9 @@ release() { _ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::update -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBody:: update() { @@ -97,11 +88,9 @@ update() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_scene -// Access: Published -// Description: Returns the scene which this soft body belongs to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scene which this soft body belongs to. + */ PhysxScene *PhysxSoftBody:: get_scene() const { @@ -109,11 +98,9 @@ get_scene() const { return (PhysxScene *)_ptr->getScene().userData; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_soft_body_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSoftBodyNode *PhysxSoftBody:: get_soft_body_node() const { @@ -121,11 +108,9 @@ get_soft_body_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::create_soft_body_node -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSoftBodyNode *PhysxSoftBody:: create_soft_body_node(const char *name) { @@ -137,14 +122,10 @@ create_soft_body_node(const char *name) { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_name -// Access: Published -// Description: Sets a name string for the object that can be -// retrieved with get_name(). -// This is for debugging and is not used by the -// engine. -//////////////////////////////////////////////////////////////////// +/** + * Sets a name string for the object that can be retrieved with get_name(). + * This is for debugging and is not used by the engine. + */ void PhysxSoftBody:: set_name(const char *name) { @@ -154,11 +135,9 @@ set_name(const char *name) { _ptr->setName(_name.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_name -// Access: Published -// Description: Retrieves the name string. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the name string. + */ const char *PhysxSoftBody:: get_name() const { @@ -166,12 +145,10 @@ get_name() const { return _ptr->getName(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_group -// Access: Published -// Description: Sets which collision group this soft body is part -// of. Collision group must be between 0 and 31. -//////////////////////////////////////////////////////////////////// +/** + * Sets which collision group this soft body is part of. Collision group must + * be between 0 and 31. + */ void PhysxSoftBody:: set_group(unsigned int group) { @@ -180,12 +157,9 @@ set_group(unsigned int group) { _ptr->setGroup(group); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_group -// Access: Published -// Description: Retrieves the collision group this soft body is -// part of. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the collision group this soft body is part of. + */ unsigned int PhysxSoftBody:: get_group() const { @@ -193,11 +167,9 @@ get_group() const { return _ptr->getGroup(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_groups_mask -// Access: Published -// Description: Sets 128-bit mask used for collision filtering. -//////////////////////////////////////////////////////////////////// +/** + * Sets 128-bit mask used for collision filtering. + */ void PhysxSoftBody:: set_groups_mask(const PhysxGroupsMask &mask) { @@ -207,12 +179,9 @@ set_groups_mask(const PhysxGroupsMask &mask) { _ptr->setGroupsMask(_mask); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_groups_mask -// Access: Published -// Description: Gets the 128-bit groups mask used for collision -// filtering. -//////////////////////////////////////////////////////////////////// +/** + * Gets the 128-bit groups mask used for collision filtering. + */ PhysxGroupsMask PhysxSoftBody:: get_groups_mask() const { @@ -226,11 +195,9 @@ get_groups_mask() const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_num_particles -// Access: Published -// Description: Gets the number of cloth particles. -//////////////////////////////////////////////////////////////////// +/** + * Gets the number of cloth particles. + */ unsigned int PhysxSoftBody:: get_num_particles() { @@ -238,12 +205,9 @@ get_num_particles() { return _ptr->getNumberOfParticles(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_particle_radius -// Access: Published -// Description: Sets the soft body particle radius (must be -// positive). -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body particle radius (must be positive). + */ void PhysxSoftBody:: set_particle_radius(float radius) { @@ -251,11 +215,9 @@ set_particle_radius(float radius) { _ptr->setParticleRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_particle_radius -// Access: Published -// Description: Gets the soft body particle radius. -//////////////////////////////////////////////////////////////////// +/** + * Gets the soft body particle radius. + */ float PhysxSoftBody:: get_particle_radius() const { @@ -263,11 +225,9 @@ get_particle_radius() const { return _ptr->getParticleRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_flag -// Access: Published -// Description: Sets the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets the value of a single flag. + */ void PhysxSoftBody:: set_flag(PhysxSoftBodyFlag flag, bool value) { @@ -277,7 +237,7 @@ set_flag(PhysxSoftBodyFlag flag, bool value) { if (value == true) { flags |= flag; - } + } else { flags &= ~(flag); } @@ -285,11 +245,9 @@ set_flag(PhysxSoftBodyFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_flag -// Access: Published -// Description: Retrieves the value of a single flag. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value of a single flag. + */ bool PhysxSoftBody:: get_flag(PhysxSoftBodyFlag flag) const { @@ -298,11 +256,9 @@ get_flag(PhysxSoftBodyFlag flag) const { return (_ptr->getFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_density -// Access: Published -// Description: Gets the soft body density. -//////////////////////////////////////////////////////////////////// +/** + * Gets the soft body density. + */ float PhysxSoftBody:: get_density() const { @@ -310,16 +266,12 @@ get_density() const { return _ptr->getDensity(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_relative_grid_spacing -// Access: Published -// Description: Gets the relative grid spacing for the broad -// phase. The cloth is represented by a set of -// world aligned cubical cells in broad phase. The -// size of these cells is determined by multiplying -// the length of the diagonal of the AABB of the -// initial soft body size with this constant. -//////////////////////////////////////////////////////////////////// +/** + * Gets the relative grid spacing for the broad phase. The cloth is + * represented by a set of world aligned cubical cells in broad phase. The + * size of these cells is determined by multiplying the length of the diagonal + * of the AABB of the initial soft body size with this constant. + */ float PhysxSoftBody:: get_relative_grid_spacing() const { @@ -327,12 +279,9 @@ get_relative_grid_spacing() const { return _ptr->getRelativeGridSpacing(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_volume_stiffness -// Access: Published -// Description: Sets the soft body volume stiffness in the range -// from 0 to 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body volume stiffness in the range from 0 to 1. + */ void PhysxSoftBody:: set_volume_stiffness(float stiffness) { @@ -340,11 +289,9 @@ set_volume_stiffness(float stiffness) { ptr()->setVolumeStiffness(stiffness); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_volume_stiffness -// Access: Published -// Description: Retrieves the soft body volume stiffness. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body volume stiffness. + */ float PhysxSoftBody:: get_volume_stiffness() const { @@ -352,12 +299,9 @@ get_volume_stiffness() const { return ptr()->getVolumeStiffness(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_stretching_stiffness -// Access: Published -// Description: Sets the soft body stretching stiffness in the -// range from 0 to 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body stretching stiffness in the range from 0 to 1. + */ void PhysxSoftBody:: set_stretching_stiffness(float stiffness) { @@ -365,11 +309,9 @@ set_stretching_stiffness(float stiffness) { ptr()->setStretchingStiffness(stiffness); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_stretching_stiffness -// Access: Published -// Description: Retrieves the soft body stretching stiffness. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body stretching stiffness. + */ float PhysxSoftBody:: get_stretching_stiffness() const { @@ -377,12 +319,9 @@ get_stretching_stiffness() const { return ptr()->getStretchingStiffness(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_damping_coefficient -// Access: Published -// Description: Sets the damping coefficient in the range from 0 -// to 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the damping coefficient in the range from 0 to 1. + */ void PhysxSoftBody:: set_damping_coefficient(float coef) { @@ -390,11 +329,9 @@ set_damping_coefficient(float coef) { ptr()->setDampingCoefficient(coef); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_damping_coefficient -// Access: Published -// Description: Retrieves the damping coefficient. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the damping coefficient. + */ float PhysxSoftBody:: get_damping_coefficient() const { @@ -402,12 +339,9 @@ get_damping_coefficient() const { return ptr()->getDampingCoefficient(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_friction -// Access: Published -// Description: Sets the soft body friction coefficient in the -// range from 0 to 1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body friction coefficient in the range from 0 to 1. + */ void PhysxSoftBody:: set_friction(float friction) { @@ -415,11 +349,9 @@ set_friction(float friction) { ptr()->setFriction(friction); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_friction -// Access: Published -// Description: Retrieves the soft body friction coefficient. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body friction coefficient. + */ float PhysxSoftBody:: get_friction() const { @@ -427,12 +359,9 @@ get_friction() const { return ptr()->getFriction(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_tear_factor -// Access: Published -// Description: Sets the soft body tear factor (must be larger -// than one). -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body tear factor (must be larger than one). + */ void PhysxSoftBody:: set_tear_factor(float factor) { @@ -441,11 +370,9 @@ set_tear_factor(float factor) { ptr()->setTearFactor(factor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_tear_factor -// Access: Published -// Description: Retrieves the soft body tear factor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body tear factor. + */ float PhysxSoftBody:: get_tear_factor() const { @@ -453,12 +380,9 @@ get_tear_factor() const { return ptr()->getTearFactor(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_attachment_tear_factor -// Access: Published -// Description: Sets the soft body attachment tear factor (must be -// larger than one). -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body attachment tear factor (must be larger than one). + */ void PhysxSoftBody:: set_attachment_tear_factor(float factor) { @@ -467,11 +391,9 @@ set_attachment_tear_factor(float factor) { ptr()->setAttachmentTearFactor(factor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_attachment_tear_factor -// Access: Published -// Description: Retrieves the attachment soft body tear factor. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the attachment soft body tear factor. + */ float PhysxSoftBody:: get_attachment_tear_factor() const { @@ -479,11 +401,9 @@ get_attachment_tear_factor() const { return ptr()->getAttachmentTearFactor(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_solver_iterations -// Access: Published -// Description: Sets the soft body solver iterations. -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body solver iterations. + */ void PhysxSoftBody:: set_solver_iterations(unsigned int iterations) { @@ -491,11 +411,9 @@ set_solver_iterations(unsigned int iterations) { ptr()->setSolverIterations(iterations); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_solver_iterations -// Access: Published -// Description: Retrieves the soft body solver iterations. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body solver iterations. + */ unsigned int PhysxSoftBody:: get_solver_iterations() const { @@ -503,19 +421,15 @@ get_solver_iterations() const { return ptr()->getSolverIterations(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::is_sleeping -// Access: Published -// Description: Returns true if this soft body is sleeping. -// -// When a soft body does not move for a period of -// time, it is no longer simulated in order to save -// time. This state is called sleeping. However, -// because the object automatically wakes up when it -// is either touched by an awake object, or one of its -// properties is changed by the user, the entire sleep -// mechanism should be transparent to the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this soft body is sleeping. + * + * When a soft body does not move for a period of time, it is no longer + * simulated in order to save time. This state is called sleeping. However, + * because the object automatically wakes up when it is either touched by an + * awake object, or one of its properties is changed by the user, the entire + * sleep mechanism should be transparent to the user. + */ bool PhysxSoftBody:: is_sleeping() const { @@ -523,16 +437,13 @@ is_sleeping() const { return _ptr->isSleeping(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::wake_up -// Access: Published -// Description: Wakes up the soft body if it is sleeping. -// -// The wakeCounterValue determines how long until the -// body is put to sleep, a value of zero means that -// the body is sleeping. wake_up(0) is equivalent to -// PhysxSoftBody::put_to_sleep(). -//////////////////////////////////////////////////////////////////// +/** + * Wakes up the soft body if it is sleeping. + * + * The wakeCounterValue determines how long until the body is put to sleep, a + * value of zero means that the body is sleeping. wake_up(0) is equivalent to + * PhysxSoftBody::put_to_sleep(). + */ void PhysxSoftBody:: wake_up(float wakeCounterValue) { @@ -540,17 +451,13 @@ wake_up(float wakeCounterValue) { _ptr->wakeUp(wakeCounterValue); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::put_to_sleep -// Access: Published -// Description: Forces the soft body to sleep. -// -// The soft body will stay asleep until the next -// call to simulate, and will not wake up until then -// even when otherwise it would (for example a force -// is applied to it). It can however wake up during -// the next do_physics call. -//////////////////////////////////////////////////////////////////// +/** + * Forces the soft body to sleep. + * + * The soft body will stay asleep until the next call to simulate, and will + * not wake up until then even when otherwise it would (for example a force is + * applied to it). It can however wake up during the next do_physics call. + */ void PhysxSoftBody:: put_to_sleep() { @@ -558,17 +465,14 @@ put_to_sleep() { _ptr->putToSleep(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_sleep_linear_velocity -// Access: Published -// Description: Sets the linear velocity below which an soft body -// may go to sleep. SoftBodys whose linear velocity is -// above this threshold will not be put to sleep. -// -// Setting the sleep angular/linear velocity only -// makes sense when the BF_energy_sleep_test is not -// set. -//////////////////////////////////////////////////////////////////// +/** + * Sets the linear velocity below which an soft body may go to sleep. + * SoftBodys whose linear velocity is above this threshold will not be put to + * sleep. + * + * Setting the sleep angular/linear velocity only makes sense when the + * BF_energy_sleep_test is not set. + */ void PhysxSoftBody:: set_sleep_linear_velocity(float threshold) { @@ -576,14 +480,11 @@ set_sleep_linear_velocity(float threshold) { _ptr->setSleepLinearVelocity(threshold); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_sleep_linear_velocity -// Access: Published -// Description: Returns the linear velocity below which an soft -// body may go to sleep. Soft bodies whose linear -// velocity is above this threshold will not be put -// to sleep. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear velocity below which an soft body may go to sleep. Soft + * bodies whose linear velocity is above this threshold will not be put to + * sleep. + */ float PhysxSoftBody:: get_sleep_linear_velocity() const { @@ -592,12 +493,9 @@ get_sleep_linear_velocity() const { } #if NX_SDK_VERSION_NUMBER > 281 -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_self_collision_thickness -// Access: Published -// Description: Sets the soft body self collision thickness (must -// be positive). -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body self collision thickness (must be positive). + */ void PhysxSoftBody:: set_self_collision_thickness(float thickness) { @@ -605,11 +503,9 @@ set_self_collision_thickness(float thickness) { _ptr->setSelfCollisionThickness(thickness); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_self_collision_thickness -// Access: Published -// Description: Gets the soft body self collision thickness. -//////////////////////////////////////////////////////////////////// +/** + * Gets the soft body self collision thickness. + */ float PhysxSoftBody:: get_self_collision_thickness() const { @@ -617,11 +513,9 @@ get_self_collision_thickness() const { return _ptr->getSelfCollisionThickness(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_hard_stretch_limitation_factor -// Access: Published -// Description: Sets the soft body hard stretch elongation limit. -//////////////////////////////////////////////////////////////////// +/** + * Sets the soft body hard stretch elongation limit. + */ void PhysxSoftBody:: set_hard_stretch_limitation_factor(float factor) { @@ -629,12 +523,9 @@ set_hard_stretch_limitation_factor(float factor) { ptr()->setHardStretchLimitationFactor(factor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_hard_stretch_limitation_factor -// Access: Published -// Description: Retrieves the soft body hard stretch elongation -// limit. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the soft body hard stretch elongation limit. + */ float PhysxSoftBody:: get_hard_stretch_limitation_factor() const { @@ -651,12 +542,9 @@ get_hard_stretch_limitation_factor() const { /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::attach_vertex_to_global_pos -// Access: Published -// Description: Attaches a cloth vertex to a position in world -// space. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a cloth vertex to a position in world space. + */ void PhysxSoftBody:: attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) { @@ -666,16 +554,13 @@ attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) { _ptr->attachVertexToGlobalPosition(vertexId, PhysxManager::point3_to_nxVec3(pos)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::attach_to_shape -// Access: Published -// Description: Attaches the cloth to a shape. All cloth points -// currently inside the shape are attached. -// -// This method only works with primitive and convex -// shapes. Since the inside of a general triangle mesh -// is not clearly defined. -//////////////////////////////////////////////////////////////////// +/** + * Attaches the cloth to a shape. All cloth points currently inside the shape + * are attached. + * + * This method only works with primitive and convex shapes. Since the inside + * of a general triangle mesh is not clearly defined. + */ void PhysxSoftBody:: attach_to_shape(PhysxShape *shape) { @@ -686,16 +571,12 @@ attach_to_shape(PhysxShape *shape) { _ptr->attachToShape(shape->ptr(), attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::attach_to_colliding_shapes -// Access: Published -// Description: Attaches the cloth to all shapes, currently -// colliding. -// -// This method only works with primitive and convex -// shapes. Since the inside of a general triangle mesh -// is not clearly defined. -//////////////////////////////////////////////////////////////////// +/** + * Attaches the cloth to all shapes, currently colliding. + * + * This method only works with primitive and convex shapes. Since the inside + * of a general triangle mesh is not clearly defined. + */ void PhysxSoftBody:: attach_to_colliding_shapes() { @@ -705,15 +586,12 @@ attach_to_colliding_shapes() { _ptr->attachToCollidingShapes(attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::detach_from_shape -// Access: Published -// Description: Detaches the cloth from a shape it has been -// attached to before. -// -// If the cloth has not been attached to the shape -// before, the call has no effect. -//////////////////////////////////////////////////////////////////// +/** + * Detaches the cloth from a shape it has been attached to before. + * + * If the cloth has not been attached to the shape before, the call has no + * effect. + */ void PhysxSoftBody:: detach_from_shape(PhysxShape *shape) { @@ -723,11 +601,9 @@ detach_from_shape(PhysxShape *shape) { _ptr->detachFromShape(shape->ptr()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::free_vertex -// Access: Published -// Description: Frees a previously attached cloth point. -//////////////////////////////////////////////////////////////////// +/** + * Frees a previously attached cloth point. + */ void PhysxSoftBody:: free_vertex(unsigned int vertexId) { @@ -735,12 +611,9 @@ free_vertex(unsigned int vertexId) { _ptr->freeVertex(vertexId); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::attach_vertex_to_shape -// Access: Published -// Description: Attaches a cloth vertex to a local position within -// a shape. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a cloth vertex to a local position within a shape. + */ void PhysxSoftBody:: attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos) { @@ -754,11 +627,9 @@ attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const attachmentFlags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_vertex_attachment_status -// Access: Published -// Description: Return the attachment status of the given vertex. -//////////////////////////////////////////////////////////////////// +/** + * Return the attachment status of the given vertex. + */ PhysxEnums::PhysxVertexAttachmentStatus PhysxSoftBody:: get_vertex_attachment_status(unsigned int vertexId) const { @@ -768,13 +639,11 @@ get_vertex_attachment_status(unsigned int vertexId) const { return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_vertex_attachment_shape -// Access: Published -// Description: Returns the pointer to an attached shape pointer -// of the given vertex. If the vertex is not attached -// or attached to a global position, NULL is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to an attached shape pointer of the given vertex. If + * the vertex is not attached or attached to a global position, NULL is + * returned. + */ PhysxShape *PhysxSoftBody:: get_vertex_attachment_shape(unsigned int vertexId) const { @@ -787,30 +656,25 @@ get_vertex_attachment_shape(unsigned int vertexId) const { return shape; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_vertex_attachment_pos -// Access: Published -// Description: Returns the attachment position of the given -// vertex. If the vertex is attached to shape, the -// position local to the shape's pose is returned. If -// the vertex is not attached, the return value is -// undefined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the attachment position of the given vertex. If the vertex is + * attached to shape, the position local to the shape's pose is returned. If + * the vertex is not attached, the return value is undefined. + */ LPoint3f PhysxSoftBody:: get_vertex_attachment_pos(unsigned int vertexId) const { nassertr(_error_type == ET_ok, LPoint3f::zero()); - // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), LPoint3f::zero()); + // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), + // LPoint3f::zero()); return PhysxManager::nxVec3_to_point3(_ptr->getVertexAttachmentPosition(vertexId)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_external_acceleration -// Access: Published -// Description: Sets an external acceleration which affects all non -// attached particles of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Sets an external acceleration which affects all non attached particles of + * the cloth. + */ void PhysxSoftBody:: set_external_acceleration(LVector3f const &acceleration) { @@ -820,12 +684,9 @@ set_external_acceleration(LVector3f const &acceleration) { _ptr->setExternalAcceleration(PhysxManager::vec3_to_nxVec3(acceleration)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::set_wind_acceleration -// Access: Published -// Description: Sets an acceleration acting normal to the cloth -// surface at each vertex. -//////////////////////////////////////////////////////////////////// +/** + * Sets an acceleration acting normal to the cloth surface at each vertex. + */ void PhysxSoftBody:: set_wind_acceleration(LVector3f const &acceleration) { @@ -835,12 +696,10 @@ set_wind_acceleration(LVector3f const &acceleration) { _ptr->setWindAcceleration(PhysxManager::vec3_to_nxVec3(acceleration)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_external_acceleration -// Access: Published -// Description: Retrieves the external acceleration which affects -// all non attached particles of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the external acceleration which affects all non attached + * particles of the cloth. + */ LVector3f PhysxSoftBody:: get_external_acceleration() const { @@ -848,12 +707,10 @@ get_external_acceleration() const { return PhysxManager::nxVec3_to_vec3(_ptr->getExternalAcceleration()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::get_wind_acceleration -// Access: Published -// Description: Retrieves the acceleration acting normal to the -// cloth surface at each vertex -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the acceleration acting normal to the cloth surface at each + * vertex + */ LVector3f PhysxSoftBody:: get_wind_acceleration() const { @@ -861,13 +718,10 @@ get_wind_acceleration() const { return PhysxManager::nxVec3_to_vec3(_ptr->getWindAcceleration()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::add_force_at_vertex -// Access: Published -// Description: Applies a force (or impulse) defined in the -// global coordinate frame, to a particular vertex -// of the cloth. -//////////////////////////////////////////////////////////////////// +/** + * Applies a force (or impulse) defined in the global coordinate frame, to a + * particular vertex of the cloth. + */ void PhysxSoftBody:: add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) { @@ -877,13 +731,10 @@ add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) { (NxForceMode) mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::add_force_at_pos -// Access: Published -// Description: Applies a radial force (or impulse) at a -// particular position. All vertices within radius -// will be affected with a quadratic drop-off. -//////////////////////////////////////////////////////////////////// +/** + * Applies a radial force (or impulse) at a particular position. All vertices + * within radius will be affected with a quadratic drop-off. + */ void PhysxSoftBody:: add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode) { @@ -894,13 +745,10 @@ add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceM (NxForceMode) mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBody::add_directed_force_at_pos -// Access: Published -// Description: Applies a directed force (or impulse) at a -// particular position. All vertices within radius -// will be affected with a quadratic drop-off. -//////////////////////////////////////////////////////////////////// +/** + * Applies a directed force (or impulse) at a particular position. All + * vertices within radius will be affected with a quadratic drop-off. + */ void PhysxSoftBody:: add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode) { @@ -911,4 +759,3 @@ add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float rad (NxForceMode) mode); } */ - diff --git a/panda/src/physx/physxSoftBody.h b/panda/src/physx/physxSoftBody.h index 13e2e7b262..58020ed4a8 100644 --- a/panda/src/physx/physxSoftBody.h +++ b/panda/src/physx/physxSoftBody.h @@ -1,16 +1,15 @@ -// Filename: physxSoftBody.h -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBody.h + * @author enn0x + * @date 2010-09-13 + */ #ifndef PHYSXSOFTBODY_H #define PHYSXSOFTBODY_H @@ -27,10 +26,9 @@ class PhysxScene; class PhysxGroupsMask; class PhysxSoftBodyNode; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSoftBody -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxSoftBody : public PhysxObject, public PhysxEnums { PUBLISHED: @@ -116,57 +114,57 @@ PUBLISHED: /* -virtual void getWorldBounds (NxBounds3 &bounds) const =0 -virtual void attachToShape (const NxShape *shape, NxU32 attachmentFlags)=0 -virtual void attachToCollidingShapes (NxU32 attachmentFlags)=0 -virtual void detachFromShape (const NxShape *shape)=0 -virtual void attachVertexToShape (NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags)=0 -virtual void attachVertexToGlobalPosition (const NxU32 vertexId, const NxVec3 &pos)=0 -virtual void freeVertex (const NxU32 vertexId)=0 -virtual bool tearVertex (const NxU32 vertexId, const NxVec3 &normal)=0 -virtual bool raycast (const NxRay &worldRay, NxVec3 &hit, NxU32 &vertexId)=0 -virtual void setMeshData (NxMeshData &meshData)=0 -virtual NxMeshData getMeshData ()=0 -virtual void setSplitPairData (NxSoftBodySplitPairData &splitPairData)=0 -virtual NxSoftBodySplitPairData getSplitPairData ()=0 -virtual void setValidBounds (const NxBounds3 &validBounds)=0 -virtual void getValidBounds (NxBounds3 &validBounds) const =0 -virtual void setPosition (const NxVec3 &position, NxU32 vertexId)=0 -virtual void setPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual NxVec3 getPosition (NxU32 vertexId) const =0 -virtual void getPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual void setVelocity (const NxVec3 &velocity, NxU32 vertexId)=0 -virtual void setVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual NxVec3 getVelocity (NxU32 vertexId) const =0 -virtual void getVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual void setConstrainPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual void setConstrainNormals (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 -virtual void setConstrainCoefficients (const NxSoftBodyConstrainCoefficients *coefficients, NxU32 byteStride=sizeof(NxSoftBodyConstrainCoefficients))=0 -virtual NxU32 queryShapePointers ()=0 -virtual NxU32 getStateByteSize ()=0 -virtual void getShapePointers (NxShape **shapePointers, NxU32 *flags)=0 -virtual void setShapePointers (NxShape **shapePointers, unsigned int numShapes)=0 -virtual void saveStateToStream (NxStream &stream, bool permute=false)=0 -virtual void loadStateFromStream (NxStream &stream)=0 -virtual void setCollisionResponseCoefficient (NxReal coefficient)=0 -virtual NxReal getCollisionResponseCoefficient () const =0 -virtual void setAttachmentResponseCoefficient (NxReal coefficient)=0 -virtual NxReal getAttachmentResponseCoefficient () const =0 -virtual void setFromFluidResponseCoefficient (NxReal coefficient)=0 -virtual NxReal getFromFluidResponseCoefficient () const =0 -virtual void setToFluidResponseCoefficient (NxReal coefficient)=0 -virtual NxReal getToFluidResponseCoefficient () const =0 -virtual void setExternalAcceleration (NxVec3 acceleration)=0 -virtual NxVec3 getExternalAcceleration () const =0 -virtual void setMinAdhereVelocity (NxReal velocity)=0 -virtual NxReal getMinAdhereVelocity () const =0 -virtual void addForceAtVertex (const NxVec3 &force, NxU32 vertexId, NxForceMode mode=NX_FORCE)=0 -virtual void addForceAtPos (const NxVec3 &position, NxReal magnitude, NxReal radius, NxForceMode mode=NX_FORCE)=0 -virtual void addDirectedForceAtPos (const NxVec3 &position, const NxVec3 &force, NxReal radius, NxForceMode mode=NX_FORCE)=0 -virtual bool overlapAABBTetrahedra (const NxBounds3 &bounds, NxU32 &nb, const NxU32 *&indices) const =0 -virtual NxCompartment * getCompartment () const =0 -virtual NxForceFieldMaterial getForceFieldMaterial () const =0 -virtual void setForceFieldMaterial (NxForceFieldMaterial)=0 +virtual void getWorldBounds (NxBounds3 &bounds) const =0 +virtual void attachToShape (const NxShape *shape, NxU32 attachmentFlags)=0 +virtual void attachToCollidingShapes (NxU32 attachmentFlags)=0 +virtual void detachFromShape (const NxShape *shape)=0 +virtual void attachVertexToShape (NxU32 vertexId, const NxShape *shape, const NxVec3 &localPos, NxU32 attachmentFlags)=0 +virtual void attachVertexToGlobalPosition (const NxU32 vertexId, const NxVec3 &pos)=0 +virtual void freeVertex (const NxU32 vertexId)=0 +virtual bool tearVertex (const NxU32 vertexId, const NxVec3 &normal)=0 +virtual bool raycast (const NxRay &worldRay, NxVec3 &hit, NxU32 &vertexId)=0 +virtual void setMeshData (NxMeshData &meshData)=0 +virtual NxMeshData getMeshData ()=0 +virtual void setSplitPairData (NxSoftBodySplitPairData &splitPairData)=0 +virtual NxSoftBodySplitPairData getSplitPairData ()=0 +virtual void setValidBounds (const NxBounds3 &validBounds)=0 +virtual void getValidBounds (NxBounds3 &validBounds) const =0 +virtual void setPosition (const NxVec3 &position, NxU32 vertexId)=0 +virtual void setPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual NxVec3 getPosition (NxU32 vertexId) const =0 +virtual void getPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual void setVelocity (const NxVec3 &velocity, NxU32 vertexId)=0 +virtual void setVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual NxVec3 getVelocity (NxU32 vertexId) const =0 +virtual void getVelocities (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual void setConstrainPositions (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual void setConstrainNormals (void *buffer, NxU32 byteStride=sizeof(NxVec3))=0 +virtual void setConstrainCoefficients (const NxSoftBodyConstrainCoefficients *coefficients, NxU32 byteStride=sizeof(NxSoftBodyConstrainCoefficients))=0 +virtual NxU32 queryShapePointers ()=0 +virtual NxU32 getStateByteSize ()=0 +virtual void getShapePointers (NxShape **shapePointers, NxU32 *flags)=0 +virtual void setShapePointers (NxShape **shapePointers, unsigned int numShapes)=0 +virtual void saveStateToStream (NxStream &stream, bool permute=false)=0 +virtual void loadStateFromStream (NxStream &stream)=0 +virtual void setCollisionResponseCoefficient (NxReal coefficient)=0 +virtual NxReal getCollisionResponseCoefficient () const =0 +virtual void setAttachmentResponseCoefficient (NxReal coefficient)=0 +virtual NxReal getAttachmentResponseCoefficient () const =0 +virtual void setFromFluidResponseCoefficient (NxReal coefficient)=0 +virtual NxReal getFromFluidResponseCoefficient () const =0 +virtual void setToFluidResponseCoefficient (NxReal coefficient)=0 +virtual NxReal getToFluidResponseCoefficient () const =0 +virtual void setExternalAcceleration (NxVec3 acceleration)=0 +virtual NxVec3 getExternalAcceleration () const =0 +virtual void setMinAdhereVelocity (NxReal velocity)=0 +virtual NxReal getMinAdhereVelocity () const =0 +virtual void addForceAtVertex (const NxVec3 &force, NxU32 vertexId, NxForceMode mode=NX_FORCE)=0 +virtual void addForceAtPos (const NxVec3 &position, NxReal magnitude, NxReal radius, NxForceMode mode=NX_FORCE)=0 +virtual void addDirectedForceAtPos (const NxVec3 &position, const NxVec3 &force, NxReal radius, NxForceMode mode=NX_FORCE)=0 +virtual bool overlapAABBTetrahedra (const NxBounds3 &bounds, NxU32 &nb, const NxU32 *&indices) const =0 +virtual NxCompartment * getCompartment () const =0 +virtual NxForceFieldMaterial getForceFieldMaterial () const =0 +virtual void setForceFieldMaterial (NxForceFieldMaterial)=0 */ INLINE void ls() const; @@ -175,7 +173,6 @@ virtual void setForceFieldMaterial (NxForceFieldMaterial)=0 public: void update(); -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -190,14 +187,13 @@ private: PT(PhysxSoftBodyNode) _node; string _name; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxSoftBody", + register_type(_type_handle, "PhysxSoftBody", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSoftBodyDesc.I b/panda/src/physx/physxSoftBodyDesc.I index e26d546be1..e5a02ac6a3 100644 --- a/panda/src/physx/physxSoftBodyDesc.I +++ b/panda/src/physx/physxSoftBodyDesc.I @@ -1,45 +1,36 @@ -// Filename: physxSoftBodyDesc.I -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyDesc.I + * @author enn0x + * @date 2010-09-12 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyDesc:: PhysxSoftBodyDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyDesc:: ~PhysxSoftBodyDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxSoftBodyDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSoftBodyDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxSoftBodyDesc.cxx b/panda/src/physx/physxSoftBodyDesc.cxx index f9485e5b57..8e1016b14c 100644 --- a/panda/src/physx/physxSoftBodyDesc.cxx +++ b/panda/src/physx/physxSoftBodyDesc.cxx @@ -1,26 +1,23 @@ -// Filename: physxSoftBodyDesc.cxx -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyDesc.cxx + * @author enn0x + * @date 2010-09-12 + */ #include "physxSoftBodyDesc.h" #include "physxSoftBodyMesh.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_name(const char *name) { @@ -28,33 +25,27 @@ set_name(const char *name) { _desc.name = _name.c_str(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_global_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_global_pos(const LPoint3f &pos) { _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_global_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_global_mat(const LMatrix4f &mat) { _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_global_hpr -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_global_hpr(float h, float p, float r) { @@ -68,121 +59,99 @@ set_global_hpr(float h, float p, float r) { _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_particle_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_particle_radius(float radius) { _desc.particleRadius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_relative_grid_spacing -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_relative_grid_spacing(float spacing) { _desc.relativeGridSpacing = spacing; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_collision_response_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_collision_response_coefficient(float coef) { _desc.collisionResponseCoefficient = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_attachment_response_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_attachment_response_coefficient(float coef) { _desc.attachmentResponseCoefficient = coef; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_density(float density) { _desc.density = density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_volume_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_volume_stiffness(float stiffness) { _desc.volumeStiffness = stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_stretching_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_stretching_stiffness(float stiffness) { _desc.stretchingStiffness = stiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_damping_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_damping_coefficient(float damping) { _desc.dampingCoefficient = damping; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_friction(float friction) { _desc.friction = friction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_tear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_tear_factor(float tearFactor) { _desc.tearFactor = tearFactor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_flag -// Access: Published -// Description: Raise or lower individual SoftBodyFlag flags. -//////////////////////////////////////////////////////////////////// +/** + * Raise or lower individual SoftBodyFlag flags. + */ void PhysxSoftBodyDesc:: set_flag(PhysxSoftBodyFlag flag, bool value) { @@ -194,189 +163,154 @@ set_flag(PhysxSoftBodyFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_solver_iterations -// Access: Published -// Description: Number of solver iterations. -// Small numbers make the simulation faster while -// the soft body gets less stiff. -//////////////////////////////////////////////////////////////////// +/** + * Number of solver iterations. Small numbers make the simulation faster + * while the soft body gets less stiff. + */ void PhysxSoftBodyDesc:: set_solver_iterations(unsigned int iterations) { _desc.solverIterations = iterations; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::set_soft_body_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyDesc:: set_soft_body_mesh(PhysxSoftBodyMesh *mesh) { _desc.softBodyMesh = mesh->ptr(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_name -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const char *PhysxSoftBodyDesc:: get_name() const { return _desc.name; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_global_pos -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LPoint3f PhysxSoftBodyDesc:: get_global_pos() const { return PhysxManager::nxVec3_to_point3(_desc.globalPose.t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_global_mat -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LMatrix4f PhysxSoftBodyDesc:: get_global_mat() const { return PhysxManager::nxMat34_to_mat4(_desc.globalPose); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_particle_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_particle_radius() const { return _desc.particleRadius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_relative_grid_spacing -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_relative_grid_spacing() const { return _desc.relativeGridSpacing; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_collision_response_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_collision_response_coefficient() const { return _desc.collisionResponseCoefficient; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_attachment_response_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_attachment_response_coefficient() const { return _desc.attachmentResponseCoefficient; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_density -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_density() const { return _desc.density; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_volume_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_volume_stiffness() const { return _desc.volumeStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_stretching_stiffness -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_stretching_stiffness() const { return _desc.stretchingStiffness; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_damping_coefficient -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_damping_coefficient() const { return _desc.dampingCoefficient; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_friction -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_friction() const { return _desc.friction; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_tear_factor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSoftBodyDesc:: get_tear_factor() const { return _desc.tearFactor; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxSoftBodyDesc:: get_flag(PhysxSoftBodyFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_solver_iterations -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ unsigned int PhysxSoftBodyDesc:: get_solver_iterations() const { @@ -384,12 +318,10 @@ get_solver_iterations() const { } /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyDesc::get_mesh_numbers -// Access: Public -// Description: Used by PhysScene to query the sizes of arrays -// to allocate for the user buffers in PhysxSoftBodyNode. -//////////////////////////////////////////////////////////////////// +/** + * Used by PhysScene to query the sizes of arrays to allocate for the user + * buffers in PhysxSoftBodyNode. + */ void PhysxSoftBodyDesc:: get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) { @@ -400,4 +332,3 @@ get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) { numTriangles = meshDesc.numTriangles; } */ - diff --git a/panda/src/physx/physxSoftBodyDesc.h b/panda/src/physx/physxSoftBodyDesc.h index f881ec6270..550649a67f 100644 --- a/panda/src/physx/physxSoftBodyDesc.h +++ b/panda/src/physx/physxSoftBodyDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSoftBodyDesc.h -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyDesc.h + * @author enn0x + * @date 2010-09-12 + */ #ifndef PHYSXSOFTBODYDESC_H #define PHYSXSOFTBODYDESC_H @@ -23,10 +22,9 @@ class PhysxSoftBodyMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSoftBodyDesc -// Description : Descriptor for PhysxSoftBody. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor for PhysxSoftBody. + */ class EXPCL_PANDAPHYSX PhysxSoftBodyDesc : public PhysxEnums { PUBLISHED: @@ -75,7 +73,7 @@ public: NxSoftBodyDesc _desc; private: - string _name; + string _name; }; #include "physxSoftBodyDesc.I" diff --git a/panda/src/physx/physxSoftBodyMesh.I b/panda/src/physx/physxSoftBodyMesh.I index 302d1dec15..fd2e3bfe26 100644 --- a/panda/src/physx/physxSoftBodyMesh.I +++ b/panda/src/physx/physxSoftBodyMesh.I @@ -1,59 +1,47 @@ -// Filename: physxSoftBodyMesh.I -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMesh.I + * @author enn0x + * @date 2010-09-12 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyMesh:: PhysxSoftBodyMesh() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyMesh:: ~PhysxSoftBodyMesh() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxSoftBodyMesh:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxSoftBodyMesh:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxSoftBodyMesh.cxx b/panda/src/physx/physxSoftBodyMesh.cxx index fbdb5c05d5..4cb0c9cc26 100644 --- a/panda/src/physx/physxSoftBodyMesh.cxx +++ b/panda/src/physx/physxSoftBodyMesh.cxx @@ -1,27 +1,24 @@ -// Filename: physxSoftBodyMesh.cxx -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMesh.cxx + * @author enn0x + * @date 2010-09-12 + */ #include "physxSoftBodyMesh.h" #include "physxMeshPool.h" TypeHandle PhysxSoftBodyMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyMesh:: link(NxSoftBodyMesh *meshPtr) { @@ -31,11 +28,9 @@ link(NxSoftBodyMesh *meshPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyMesh:: unlink() { @@ -44,11 +39,9 @@ unlink() { PhysxManager::get_global_ptr()->_softbody_meshes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyMesh:: release() { @@ -61,11 +54,9 @@ release() { PhysxMeshPool::release_soft_body_mesh(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMesh::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxSoftBodyMesh:: get_reference_count() const { @@ -73,4 +64,3 @@ get_reference_count() const { return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxSoftBodyMesh.h b/panda/src/physx/physxSoftBodyMesh.h index 93d01c92d4..ad6615b39e 100644 --- a/panda/src/physx/physxSoftBodyMesh.h +++ b/panda/src/physx/physxSoftBodyMesh.h @@ -1,16 +1,15 @@ -// Filename: physxSoftBodyMesh.h -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMesh.h + * @author enn0x + * @date 2010-09-12 + */ #ifndef PHYSXSOFTBODYMESH_H #define PHYSXSOFTBODYMESH_H @@ -20,16 +19,14 @@ #include "physxObject.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSoftBodyMesh -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxSoftBodyMesh : public PhysxObject { PUBLISHED: unsigned int get_reference_count() const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -48,14 +45,13 @@ public: private: NxSoftBodyMesh *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxSoftBodyMesh", + register_type(_type_handle, "PhysxSoftBodyMesh", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSoftBodyMeshDesc.I b/panda/src/physx/physxSoftBodyMeshDesc.I index ee96ad5121..0cf5663cd7 100644 --- a/panda/src/physx/physxSoftBodyMeshDesc.I +++ b/panda/src/physx/physxSoftBodyMeshDesc.I @@ -1,23 +1,19 @@ -// Filename: physxSoftBodyMeshDesc.I -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMeshDesc.I + * @author enn0x + * @date 2010-09-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyMeshDesc:: PhysxSoftBodyMeshDesc() { @@ -31,11 +27,9 @@ PhysxSoftBodyMeshDesc() { _tetrahedra = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyMeshDesc:: ~PhysxSoftBodyMeshDesc() { @@ -48,25 +42,20 @@ INLINE PhysxSoftBodyMeshDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSoftBodyMeshDesc:: is_valid() const { return _desc.isValid(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::get_desc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const NxSoftBodyMeshDesc &PhysxSoftBodyMeshDesc:: get_desc() const { return _desc; } - diff --git a/panda/src/physx/physxSoftBodyMeshDesc.cxx b/panda/src/physx/physxSoftBodyMeshDesc.cxx index f82ca09b00..b6a4a6aa6d 100644 --- a/panda/src/physx/physxSoftBodyMeshDesc.cxx +++ b/panda/src/physx/physxSoftBodyMeshDesc.cxx @@ -1,30 +1,26 @@ -// Filename: physxSoftBodyMeshDesc.cxx -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMeshDesc.cxx + * @author enn0x + * @date 2010-09-12 + */ #include "physxSoftBodyMeshDesc.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::set_num_vertices -// Access: Published -// Description: Sets the number of vertices to be stored within -// this soft body mesh. The function allocates memory -// for the vertices, but it does not set any vertices. -// -// This method must be called before any calls to -// set_vertex are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of vertices to be stored within this soft body mesh. The + * function allocates memory for the vertices, but it does not set any + * vertices. + * + * This method must be called before any calls to set_vertex are done! + */ void PhysxSoftBodyMeshDesc:: set_num_vertices(unsigned int numVertices) { @@ -39,12 +35,10 @@ set_num_vertices(unsigned int numVertices) { _desc.vertices = _vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::set_vertex -// Access: Published -// Description: Sets a single vertex. You have to call the function -// set_num_vertices before you can call this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single vertex. You have to call the function set_num_vertices + * before you can call this function. + */ void PhysxSoftBodyMeshDesc:: set_vertex(unsigned int idx, const LPoint3f &vert) { @@ -53,15 +47,11 @@ set_vertex(unsigned int idx, const LPoint3f &vert) { _vertices[idx] = PhysxManager::point3_to_nxVec3(vert); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::set_num_tetrahedra -// Access: Published -// Description: Sets the number of tetrahedra to be stored in this -// soft body mesh. -// -// This method must be called before any calls to -// set_tetrahedron are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of tetrahedra to be stored in this soft body mesh. + * + * This method must be called before any calls to set_tetrahedron are done! + */ void PhysxSoftBodyMeshDesc:: set_num_tetrahedra(unsigned int numTetrahedra) { @@ -75,12 +65,9 @@ set_num_tetrahedra(unsigned int numTetrahedra) { _desc.tetrahedra = _tetrahedra; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyMeshDesc::set_tetrahedron -// Access: Published -// Description: Sets a single tetrahedron, by providing the three -// indices i1, i2, i3, i4. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single tetrahedron, by providing the three indices i1, i2, i3, i4. + */ void PhysxSoftBodyMeshDesc:: set_tetrahedron(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3, unsigned int i4) { @@ -93,4 +80,3 @@ set_tetrahedron(unsigned int idx, _tetrahedra[idx + 2] = i3; _tetrahedra[idx + 3] = i4; } - diff --git a/panda/src/physx/physxSoftBodyMeshDesc.h b/panda/src/physx/physxSoftBodyMeshDesc.h index 167141fa63..4032360716 100644 --- a/panda/src/physx/physxSoftBodyMeshDesc.h +++ b/panda/src/physx/physxSoftBodyMeshDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSoftBodyMeshDesc.h -// Created by: enn0x (12Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyMeshDesc.h + * @author enn0x + * @date 2010-09-12 + */ #ifndef PHYSXSOFTBODYMESHDESC_H #define PHYSXSOFTBODYMESHDESC_H @@ -20,10 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSoftBodyMeshDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxSoftBodyMeshDesc { PUBLISHED: diff --git a/panda/src/physx/physxSoftBodyNode.I b/panda/src/physx/physxSoftBodyNode.I index 3f0c65e66b..210db12f7b 100644 --- a/panda/src/physx/physxSoftBodyNode.I +++ b/panda/src/physx/physxSoftBodyNode.I @@ -1,24 +1,19 @@ -// Filename: physxSoftBodyNode.I -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyNode.I + * @author enn0x + * @date 2010-09-13 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyNode:: PhysxSoftBodyNode(const char *name) : GeomNode(name) { @@ -33,13 +28,10 @@ PhysxSoftBodyNode(const char *name) : GeomNode(name) { this->add_geom(_geom); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSoftBodyNode:: ~PhysxSoftBodyNode() { } - diff --git a/panda/src/physx/physxSoftBodyNode.cxx b/panda/src/physx/physxSoftBodyNode.cxx index 859e760b75..99802f2109 100644 --- a/panda/src/physx/physxSoftBodyNode.cxx +++ b/panda/src/physx/physxSoftBodyNode.cxx @@ -1,16 +1,15 @@ -// Filename: physxSoftBodyNode.cxx -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyNode.cxx + * @author enn0x + * @date 2010-09-13 + */ #include "physxSoftBodyNode.h" #include "physxSoftBody.h" @@ -24,11 +23,9 @@ TypeHandle PhysxSoftBodyNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::allocate -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyNode:: allocate(PhysxSoftBody *softbody) { @@ -64,15 +61,12 @@ allocate(PhysxSoftBody *softbody) { _softbody->ptr()->setMeshData(_mesh); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::set_from_geom -// Access: Published -// Description: Reads the vertices and indices from an existing -// Geom and makes a decomposed copy of the data. -// Then computes links between the owning soft body -// tetrahedron mesh in order to render an updated -// geometry every simulation frame. -//////////////////////////////////////////////////////////////////// +/** + * Reads the vertices and indices from an existing Geom and makes a decomposed + * copy of the data. Then computes links between the owning soft body + * tetrahedron mesh in order to render an updated geometry every simulation + * frame. + */ void PhysxSoftBodyNode:: set_from_geom(const Geom *geom) { @@ -124,11 +118,9 @@ set_from_geom(const Geom *geom) { build_tetra_links(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::build_tetra_links -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyNode:: build_tetra_links() { @@ -190,7 +182,7 @@ build_tetra_links() { NxVec3 b = compute_bary_coords(triVert, p0, p1, p2, p3); - // Is the vertex inside the tetrahedron? If yes we take it + // Is the vertex inside the tetrahedron? If yes we take it if (b.x >= 0.0f && b.y >= 0.0f && b.z >= 0.0f && (b.x + b.y + b.z) <= 1.0f) { tmpLink.barycentricCoords = b; tmpLink.tetraNr = j; @@ -217,11 +209,9 @@ build_tetra_links() { delete hash; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::remove_tris_related_to_vertex -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyNode:: remove_tris_related_to_vertex(const int vertexIndex) { @@ -245,11 +235,9 @@ remove_tris_related_to_vertex(const int vertexIndex) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::update_bounds -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyNode:: update_bounds() { @@ -263,18 +251,16 @@ update_bounds() { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::update_normals -// Access: Public -// Description:_bounds.include(mVertices[i]); -//////////////////////////////////////////////////////////////////// +/** + * _bounds.include(mVertices[i]); + */ void PhysxSoftBodyNode:: update_normals() { _normals.resize(_vdata->get_num_rows()); int i; - for (i=0; i<(int)_normals.size(); i++) { + for (i=0; i<(int)_normals.size(); i++) { _normals[i] = LVector3f::zero(); } @@ -299,22 +285,20 @@ update_normals() { _normals[idx2] += n; } - for (i=0; i<(int)_normals.size(); i++) { + for (i=0; i<(int)_normals.size(); i++) { _normals[i].normalize(); } GeomVertexWriter nwriter = GeomVertexWriter(_vdata, InternalName::get_normal()); - for (i=0; i<(int)_normals.size(); i++) { + for (i=0; i<(int)_normals.size(); i++) { n = _normals[i]; nwriter.add_data3f(n.get_x(), n.get_y(), n.get_z()); } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::compute_bary_coords -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NxVec3 PhysxSoftBodyNode:: compute_bary_coords(NxVec3 vertex, NxVec3 p0, NxVec3 p1, NxVec3 p2, NxVec3 p3) const { @@ -350,22 +334,18 @@ compute_bary_coords(NxVec3 vertex, NxVec3 p0, NxVec3 p1, NxVec3 p2, NxVec3 p3) c return baryCoords; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::update -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSoftBodyNode:: update() { update_tetra_links(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSoftBodyNode::update_tetra_links -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxSoftBodyNode:: update_tetra_links() { @@ -411,4 +391,3 @@ update_tetra_links() { return true; } - diff --git a/panda/src/physx/physxSoftBodyNode.h b/panda/src/physx/physxSoftBodyNode.h index f5af8723c1..df2af11e71 100644 --- a/panda/src/physx/physxSoftBodyNode.h +++ b/panda/src/physx/physxSoftBodyNode.h @@ -1,16 +1,15 @@ -// Filename: physxSoftBodyNode.h -// Created by: enn0x (13Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSoftBodyNode.h + * @author enn0x + * @date 2010-09-13 + */ #ifndef PHYSXSOFTBODYNODE_H #define PHYSXSOFTBODYNODE_H @@ -28,11 +27,9 @@ class PhysxSoftBody; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSoftBodyNode -// Description : Renderable geometry which represents a soft body -// mesh. -//////////////////////////////////////////////////////////////////// +/** + * Renderable geometry which represents a soft body mesh. + */ class EXPCL_PANDAPHYSX PhysxSoftBodyNode : public GeomNode { PUBLISHED: @@ -72,14 +69,13 @@ private: PT(PhysxSoftBody) _softbody; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { GeomNode::init_type(); - register_type(_type_handle, "PhysxSoftBodyNode", + register_type(_type_handle, "PhysxSoftBodyNode", GeomNode::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSphere.I b/panda/src/physx/physxSphere.I index fa527d071b..6a9da28307 100644 --- a/panda/src/physx/physxSphere.I +++ b/panda/src/physx/physxSphere.I @@ -1,46 +1,37 @@ -// Filename: physxSphere.I -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphere.I + * @author enn0x + * @date 2009-10-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphere:: PhysxSphere() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphere:: PhysxSphere(const PhysxSphere &sphere) { _sphere = sphere._sphere; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphere:: ~PhysxSphere() { } - diff --git a/panda/src/physx/physxSphere.cxx b/panda/src/physx/physxSphere.cxx index 7c3309fe41..b1060aa7a2 100644 --- a/panda/src/physx/physxSphere.cxx +++ b/panda/src/physx/physxSphere.cxx @@ -1,36 +1,31 @@ -// Filename: physxSphere.cxx -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphere.cxx + * @author enn0x + * @date 2009-10-31 + */ #include "physxSphere.h" #include "physxManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::is_valid -// Access: Published -// Description: Returns TRUE if this sphere is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns TRUE if this sphere is valid. + */ bool PhysxSphere:: is_valid() const { return _sphere.IsValid(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::contains -// Access: Published -// Description: Tests if a point is contained within the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Tests if a point is contained within the sphere. + */ bool PhysxSphere:: contains(const LPoint3f &p) const { @@ -39,62 +34,51 @@ contains(const LPoint3f &p) const { return _sphere.Contains(PhysxManager::vec3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::contains -// Access: Published -// Description: Tests if a sphere is contained within the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Tests if a sphere is contained within the sphere. + */ bool PhysxSphere:: contains(const PhysxSphere &sphere) const { return _sphere.Contains(sphere._sphere); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::contains -// Access: Published -// Description: Tests if an axis aligned box is contained within -// the sphere. The axis aligned box is defined by the -// minimum corner and the maximum corner. -//////////////////////////////////////////////////////////////////// +/** + * Tests if an axis aligned box is contained within the sphere. The axis + * aligned box is defined by the minimum corner and the maximum corner. + */ bool PhysxSphere:: contains(const LPoint3f &min, const LPoint3f &max) const { nassertr(!min.is_nan(), false); nassertr(!max.is_nan(), false); - return _sphere.Contains(PhysxManager::vec3_to_nxVec3(min), + return _sphere.Contains(PhysxManager::vec3_to_nxVec3(min), PhysxManager::vec3_to_nxVec3(max)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::intersect -// Access: Published -// Description: Tests if the sphere intersects another sphere. -// Returns TRUE if the spheres overlap. -//////////////////////////////////////////////////////////////////// +/** + * Tests if the sphere intersects another sphere. Returns TRUE if the spheres + * overlap. + */ bool PhysxSphere:: intersect(const PhysxSphere &sphere) const { return _sphere.Intersect(sphere._sphere); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::get_center -// Access: Published -// Description: Returns the center of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the center of the sphere. + */ LPoint3f PhysxSphere:: get_center() const { return PhysxManager::nxVec3_to_vec3(_sphere.center); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::set_center -// Access: Published -// Description: Sets the center of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Sets the center of the sphere. + */ void PhysxSphere:: set_center(LPoint3f center) { @@ -103,25 +87,20 @@ set_center(LPoint3f center) { _sphere.center = PhysxManager::vec3_to_nxVec3(center); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::get_radius -// Access: Published -// Description: Returns the sphere's radius. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sphere's radius. + */ float PhysxSphere:: get_radius() const { return _sphere.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphere::set_radius -// Access: Published -// Description: Sets the sphere's radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sphere's radius. + */ void PhysxSphere:: set_radius(float radius) { _sphere.radius = radius; } - diff --git a/panda/src/physx/physxSphere.h b/panda/src/physx/physxSphere.h index 4aecad3d77..09a9b4c492 100644 --- a/panda/src/physx/physxSphere.h +++ b/panda/src/physx/physxSphere.h @@ -1,16 +1,15 @@ -// Filename: physxSphere.h -// Created by: enn0x (31Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphere.h + * @author enn0x + * @date 2009-10-31 + */ #ifndef PHYSXSPHERE_H #define PHYSXSPHERE_H @@ -20,11 +19,9 @@ #include "config_physx.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphere -// Description : Represents a sphere defined by its center point -// and radius. -//////////////////////////////////////////////////////////////////// +/** + * Represents a sphere defined by its center point and radius. + */ class EXPCL_PANDAPHYSX PhysxSphere { PUBLISHED: diff --git a/panda/src/physx/physxSphereForceFieldShape.I b/panda/src/physx/physxSphereForceFieldShape.I index b31ee29b69..78232f1fb8 100644 --- a/panda/src/physx/physxSphereForceFieldShape.I +++ b/panda/src/physx/physxSphereForceFieldShape.I @@ -1,36 +1,28 @@ -// Filename: physxSphereForceFieldShape.I -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShape.I + * @author enn0x + * @date 2009-11-15 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereForceFieldShape:: PhysxSphereForceFieldShape() : PhysxForceFieldShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereForceFieldShape:: ~PhysxSphereForceFieldShape() { } - diff --git a/panda/src/physx/physxSphereForceFieldShape.cxx b/panda/src/physx/physxSphereForceFieldShape.cxx index a5f482b058..4f140de456 100644 --- a/panda/src/physx/physxSphereForceFieldShape.cxx +++ b/panda/src/physx/physxSphereForceFieldShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxSphereForceFieldShape.cxx -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShape.cxx + * @author enn0x + * @date 2009-11-15 + */ #include "physxSphereForceFieldShape.h" #include "physxSphereForceFieldShapeDesc.h" TypeHandle PhysxSphereForceFieldShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphereForceFieldShape:: link(NxForceFieldShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxForceFieldShape *shapePtr) { group->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphereForceFieldShape:: unlink() { @@ -50,12 +45,9 @@ unlink() { group->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxSphereForceFieldShape:: save_to_desc(PhysxSphereForceFieldShapeDesc &shapeDesc) const { @@ -63,11 +55,9 @@ save_to_desc(PhysxSphereForceFieldShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::set_radius -// Access: Published -// Description: Sets the sphere radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sphere radius. + */ void PhysxSphereForceFieldShape:: set_radius(float radius) { @@ -75,15 +65,12 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShape::get_radius -// Access: Published -// Description: Returns the radius of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the radius of the sphere. + */ float PhysxSphereForceFieldShape:: get_radius() const { nassertr(_error_type == ET_ok, 0.0f); return _ptr->getRadius(); } - diff --git a/panda/src/physx/physxSphereForceFieldShape.h b/panda/src/physx/physxSphereForceFieldShape.h index 4010e7cf48..1f49e5eeb1 100644 --- a/panda/src/physx/physxSphereForceFieldShape.h +++ b/panda/src/physx/physxSphereForceFieldShape.h @@ -1,16 +1,15 @@ -// Filename: physxSphereForceFieldShape.h -// Created by: enn0x (15Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShape.h + * @author enn0x + * @date 2009-11-15 + */ #ifndef PHYSXSPHEREFORCEFIELDSHAPE_H #define PHYSXSPHEREFORCEFIELDSHAPE_H @@ -23,10 +22,9 @@ class PhysxSphereForceFieldShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphereForceFieldShape -// Description : A spherical force field shape. -//////////////////////////////////////////////////////////////////// +/** + * A spherical force field shape. + */ class EXPCL_PANDAPHYSX PhysxSphereForceFieldShape : public PhysxForceFieldShape { PUBLISHED: @@ -39,7 +37,6 @@ PUBLISHED: float get_radius() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxForceFieldShape *ptr() const { return (NxForceFieldShape *)_ptr; }; @@ -49,14 +46,13 @@ public: private: NxSphereForceFieldShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxForceFieldShape::init_type(); - register_type(_type_handle, "PhysxSphereForceFieldShape", + register_type(_type_handle, "PhysxSphereForceFieldShape", PhysxForceFieldShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSphereForceFieldShapeDesc.I b/panda/src/physx/physxSphereForceFieldShapeDesc.I index 33f6c6171f..efdd6e0525 100644 --- a/panda/src/physx/physxSphereForceFieldShapeDesc.I +++ b/panda/src/physx/physxSphereForceFieldShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxSphereForceFieldShapeDesc.I -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShapeDesc.I + * @author enn0x + * @date 2009-11-06 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereForceFieldShapeDesc:: PhysxSphereForceFieldShapeDesc() : PhysxForceFieldShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereForceFieldShapeDesc:: ~PhysxSphereForceFieldShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxSphereForceFieldShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSphereForceFieldShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxSphereForceFieldShapeDesc.cxx b/panda/src/physx/physxSphereForceFieldShapeDesc.cxx index c94aa556e1..d6fd3dbe78 100644 --- a/panda/src/physx/physxSphereForceFieldShapeDesc.cxx +++ b/panda/src/physx/physxSphereForceFieldShapeDesc.cxx @@ -1,38 +1,32 @@ -// Filename: physxSphereForceFieldShapeDesc.cxx -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShapeDesc.cxx + * @author enn0x + * @date 2009-11-06 + */ #include "physxSphereForceFieldShapeDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::set_radius -// Access: Published -// Description: Radius of shape. Must be positive. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. Must be positive. + */ void PhysxSphereForceFieldShapeDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereForceFieldShapeDesc::get_radius -// Access: Published -// Description: Radius of shape. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. + */ float PhysxSphereForceFieldShapeDesc:: get_radius() const { return _desc.radius; } - diff --git a/panda/src/physx/physxSphereForceFieldShapeDesc.h b/panda/src/physx/physxSphereForceFieldShapeDesc.h index 2c3a3ebf55..df9361bf89 100644 --- a/panda/src/physx/physxSphereForceFieldShapeDesc.h +++ b/panda/src/physx/physxSphereForceFieldShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSphereForceFieldShapeDesc.h -// Created by: enn0x (06Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereForceFieldShapeDesc.h + * @author enn0x + * @date 2009-11-06 + */ #ifndef PHYSXSPHEREFORCEFIELDSHAPEDESC_H #define PHYSXSPHEREFORCEFIELDSHAPEDESC_H @@ -20,10 +19,9 @@ #include "physxForceFieldShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphereForceFieldShapeDesc -// Description : A descriptor for a sphere force field shape. -//////////////////////////////////////////////////////////////////// +/** + * A descriptor for a sphere force field shape. + */ class EXPCL_PANDAPHYSX PhysxSphereForceFieldShapeDesc : public PhysxForceFieldShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxSphereShape.I b/panda/src/physx/physxSphereShape.I index d01268c3e9..880f09493c 100644 --- a/panda/src/physx/physxSphereShape.I +++ b/panda/src/physx/physxSphereShape.I @@ -1,36 +1,28 @@ -// Filename: physxSphereShape.I -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShape.I + * @author enn0x + * @date 2009-09-16 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereShape:: PhysxSphereShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereShape:: ~PhysxSphereShape() { } - diff --git a/panda/src/physx/physxSphereShape.cxx b/panda/src/physx/physxSphereShape.cxx index 5cd52b1723..60d7f15425 100644 --- a/panda/src/physx/physxSphereShape.cxx +++ b/panda/src/physx/physxSphereShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxSphereShape.cxx -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShape.cxx + * @author enn0x + * @date 2009-09-16 + */ #include "physxSphereShape.h" #include "physxSphereShapeDesc.h" TypeHandle PhysxSphereShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphereShape:: link(NxShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphereShape:: unlink() { @@ -50,12 +45,9 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxSphereShape:: save_to_desc(PhysxSphereShapeDesc &shapeDesc) const { @@ -63,11 +55,9 @@ save_to_desc(PhysxSphereShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::set_radius -// Access: Published -// Description: Sets the sphere radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sphere radius. + */ void PhysxSphereShape:: set_radius(float radius) { @@ -75,15 +65,12 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShape::get_radius -// Access: Published -// Description: Returns the radius of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the radius of the sphere. + */ float PhysxSphereShape:: get_radius() const { nassertr(_error_type == ET_ok, 0.0f); return _ptr->getRadius(); } - diff --git a/panda/src/physx/physxSphereShape.h b/panda/src/physx/physxSphereShape.h index 53dcb8ff51..cb01666ee8 100644 --- a/panda/src/physx/physxSphereShape.h +++ b/panda/src/physx/physxSphereShape.h @@ -1,16 +1,15 @@ -// Filename: physxSphereShape.h -// Created by: enn0x (16Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShape.h + * @author enn0x + * @date 2009-09-16 + */ #ifndef PHYSXSPHERESHAPE_H #define PHYSXSPHERESHAPE_H @@ -23,22 +22,17 @@ class PhysxSphereShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphereShape -// Description : A sphere shaped collision detection primitive. -// Each shape is owned by an actor that it is attached -// to. -// -// An instance can be created by calling the -// createShape() method of the PhysxActor object that -// should own it, with a PhysxSphereShapeDesc object -// as the parameter, or by adding the shape descriptor -// into the PhysxActorDesc class before creating the -// actor. -// -// The shape is deleted by calling release() on the -// shape itself. -//////////////////////////////////////////////////////////////////// +/** + * A sphere shaped collision detection primitive. Each shape is owned by an + * actor that it is attached to. + * + * An instance can be created by calling the createShape() method of the + * PhysxActor object that should own it, with a PhysxSphereShapeDesc object as + * the parameter, or by adding the shape descriptor into the PhysxActorDesc + * class before creating the actor. + * + * The shape is deleted by calling release() on the shape itself. + */ class EXPCL_PANDAPHYSX PhysxSphereShape : public PhysxShape { PUBLISHED: @@ -51,7 +45,6 @@ PUBLISHED: float get_radius() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -61,14 +54,13 @@ public: private: NxSphereShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxSphereShape", + register_type(_type_handle, "PhysxSphereShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSphereShapeDesc.I b/panda/src/physx/physxSphereShapeDesc.I index 832b5c2387..0cc60d3065 100644 --- a/panda/src/physx/physxSphereShapeDesc.I +++ b/panda/src/physx/physxSphereShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxSphereShapeDesc.I -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShapeDesc.I + * @author enn0x + * @date 2009-09-11 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereShapeDesc:: PhysxSphereShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphereShapeDesc:: ~PhysxSphereShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxSphereShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSphereShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxSphereShapeDesc.cxx b/panda/src/physx/physxSphereShapeDesc.cxx index 755c29de87..16ab172d37 100644 --- a/panda/src/physx/physxSphereShapeDesc.cxx +++ b/panda/src/physx/physxSphereShapeDesc.cxx @@ -1,38 +1,32 @@ -// Filename: physxSphereShapeDesc.cxx -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShapeDesc.cxx + * @author enn0x + * @date 2009-09-11 + */ #include "physxSphereShapeDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::set_radius -// Access: Published -// Description: Radius of shape. Must be positive. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. Must be positive. + */ void PhysxSphereShapeDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphereShapeDesc::get_radius -// Access: Published -// Description: Radius of shape. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. + */ float PhysxSphereShapeDesc:: get_radius() const { return _desc.radius; } - diff --git a/panda/src/physx/physxSphereShapeDesc.h b/panda/src/physx/physxSphereShapeDesc.h index 7398e33c46..fb7ea37705 100644 --- a/panda/src/physx/physxSphereShapeDesc.h +++ b/panda/src/physx/physxSphereShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSphereShapeDesc.h -// Created by: enn0x (11Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphereShapeDesc.h + * @author enn0x + * @date 2009-09-11 + */ #ifndef PHYSXSPHERESHAPEDESC_H #define PHYSXSPHERESHAPEDESC_H @@ -20,10 +19,9 @@ #include "physxShapeDesc.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphereShapeDesc -// Description : Descriptor class for PhysxSphereShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxSphereShape. + */ class EXPCL_PANDAPHYSX PhysxSphereShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxSphericalJoint.I b/panda/src/physx/physxSphericalJoint.I index 271b869f63..e0b5cda439 100644 --- a/panda/src/physx/physxSphericalJoint.I +++ b/panda/src/physx/physxSphericalJoint.I @@ -1,36 +1,28 @@ -// Filename: physxSphericalJoint.I -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJoint.I + * @author enn0x + * @date 2009-10-02 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphericalJoint:: PhysxSphericalJoint() : PhysxJoint() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphericalJoint:: ~PhysxSphericalJoint() { } - diff --git a/panda/src/physx/physxSphericalJoint.cxx b/panda/src/physx/physxSphericalJoint.cxx index a755ac7402..f1e8606ffa 100644 --- a/panda/src/physx/physxSphericalJoint.cxx +++ b/panda/src/physx/physxSphericalJoint.cxx @@ -1,27 +1,24 @@ -// Filename: physxSphericalJoint.cxx -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJoint.cxx + * @author enn0x + * @date 2009-10-02 + */ #include "physxSphericalJoint.h" #include "physxSphericalJointDesc.h" TypeHandle PhysxSphericalJoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphericalJoint:: link(NxJoint *jointPtr) { @@ -35,11 +32,9 @@ link(NxJoint *jointPtr) { scene->_joints.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSphericalJoint:: unlink() { @@ -50,12 +45,9 @@ unlink() { scene->_joints.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::save_to_desc -// Access: Published -// Description: Saves the state of the joint object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the joint object to a descriptor. + */ void PhysxSphericalJoint:: save_to_desc(PhysxSphericalJointDesc &jointDesc) const { @@ -63,12 +55,9 @@ save_to_desc(PhysxSphericalJointDesc &jointDesc) const { _ptr->saveToDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::load_from_desc -// Access: Published -// Description: Loads the entire state of the joint from a -// descriptor with a single call. -//////////////////////////////////////////////////////////////////// +/** + * Loads the entire state of the joint from a descriptor with a single call. + */ void PhysxSphericalJoint:: load_from_desc(const PhysxSphericalJointDesc &jointDesc) { @@ -76,11 +65,9 @@ load_from_desc(const PhysxSphericalJointDesc &jointDesc) { _ptr->loadFromDesc(jointDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::set_projection_mode -// Access: Published -// Description: Sets the joint projection mode. -//////////////////////////////////////////////////////////////////// +/** + * Sets the joint projection mode. + */ void PhysxSphericalJoint:: set_projection_mode(PhysxProjectionMode mode) { @@ -88,11 +75,9 @@ set_projection_mode(PhysxProjectionMode mode) { _ptr->setProjectionMode((NxJointProjectionMode)mode); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::get_projection_mode -// Access: Published -// Description: Returns the current projection mode settings. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current projection mode settings. + */ PhysxEnums::PhysxProjectionMode PhysxSphericalJoint:: get_projection_mode() const { @@ -100,11 +85,9 @@ get_projection_mode() const { return (PhysxProjectionMode)_ptr->getProjectionMode(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::set_flag -// Access: Published -// Description: Sets or clears a single SphericalJointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single SphericalJointFlag. + */ void PhysxSphericalJoint:: set_flag(PhysxSphericalJointFlag flag, bool value) { @@ -121,15 +104,12 @@ set_flag(PhysxSphericalJointFlag flag, bool value) { _ptr->setFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJoint::get_flag -// Access: Published -// Description: Returns the value of a single SphericalJointFlag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of a single SphericalJointFlag. + */ bool PhysxSphericalJoint:: get_flag(PhysxSphericalJointFlag flag) const { nassertr(_error_type == ET_ok, false); return (_ptr->getFlags() & flag) ? true : false; } - diff --git a/panda/src/physx/physxSphericalJoint.h b/panda/src/physx/physxSphericalJoint.h index af401a7696..e8e44e37a1 100644 --- a/panda/src/physx/physxSphericalJoint.h +++ b/panda/src/physx/physxSphericalJoint.h @@ -1,16 +1,15 @@ -// Filename: physxSphericalJoint.h -// Created by: enn0x (02Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJoint.h + * @author enn0x + * @date 2009-10-02 + */ #ifndef PHYSXSPHERICALJOINT_H #define PHYSXSPHERICALJOINT_H @@ -22,14 +21,11 @@ class PhysxSphericalJointDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphericalJoint -// Description : A sphere joint constrains two points on two bodies -// to coincide. This point, specified in world space -// (this guarantees that the points coincide to start -// with) is the only parameter that has to be -// specified. -//////////////////////////////////////////////////////////////////// +/** + * A sphere joint constrains two points on two bodies to coincide. This + * point, specified in world space (this guarantees that the points coincide + * to start with) is the only parameter that has to be specified. + */ class EXPCL_PANDAPHYSX PhysxSphericalJoint : public PhysxJoint { PUBLISHED: @@ -45,7 +41,6 @@ PUBLISHED: bool get_flag(PhysxSphericalJointFlag flag) const; PhysxProjectionMode get_projection_mode() const; -//////////////////////////////////////////////////////////////////// public: INLINE NxJoint *ptr() const { return (NxJoint *)_ptr; }; @@ -55,14 +50,13 @@ public: private: NxSphericalJoint *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxJoint::init_type(); - register_type(_type_handle, "PhysxSphericalJoint", + register_type(_type_handle, "PhysxSphericalJoint", PhysxJoint::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxSphericalJointDesc.I b/panda/src/physx/physxSphericalJointDesc.I index ae192cf7a8..6c7302b777 100644 --- a/panda/src/physx/physxSphericalJointDesc.I +++ b/panda/src/physx/physxSphericalJointDesc.I @@ -1,45 +1,36 @@ -// Filename: physxSphericalJointDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJointDesc.I + * @author enn0x + * @date 2009-09-28 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphericalJointDesc:: PhysxSphericalJointDesc() : PhysxJointDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSphericalJointDesc:: ~PhysxSphericalJointDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxSphericalJointDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxSphericalJointDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxSphericalJointDesc.cxx b/panda/src/physx/physxSphericalJointDesc.cxx index 65a79c1a1a..a87b755a2b 100644 --- a/panda/src/physx/physxSphericalJointDesc.cxx +++ b/panda/src/physx/physxSphericalJointDesc.cxx @@ -1,38 +1,33 @@ -// Filename: physxSphericalJointDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJointDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxSphericalJointDesc.h" #include "physxManager.h" #include "physxSpringDesc.h" #include "physxJointLimitDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_projection_distance -// Access: Published -// Description: Set the distance above which to project joint. -//////////////////////////////////////////////////////////////////// +/** + * Set the distance above which to project joint. + */ void PhysxSphericalJointDesc:: set_projection_distance(float distance) { _desc.projectionDistance = distance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_flag -// Access: Published -// Description: Sets or clears a single SphericalJointFlag flag. -//////////////////////////////////////////////////////////////////// +/** + * Sets or clears a single SphericalJointFlag flag. + */ void PhysxSphericalJointDesc:: set_flag(PhysxSphericalJointFlag flag, bool value) { @@ -44,45 +39,36 @@ set_flag(PhysxSphericalJointFlag flag, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_twist_spring -// Access: Published -// Description: Sets a spring that works against twisting. -//////////////////////////////////////////////////////////////////// +/** + * Sets a spring that works against twisting. + */ void PhysxSphericalJointDesc:: set_twist_spring(const PhysxSpringDesc &spring) { _desc.twistSpring = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_swing_spring -// Access: Published -// Description: Sets a spring that works against swinging. -//////////////////////////////////////////////////////////////////// +/** + * Sets a spring that works against swinging. + */ void PhysxSphericalJointDesc:: set_swing_spring(const PhysxSpringDesc &spring) { _desc.swingSpring = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_joint_spring -// Access: Published -// Description: Sets a spring that lets the joint get pulled apart. -//////////////////////////////////////////////////////////////////// +/** + * Sets a spring that lets the joint get pulled apart. + */ void PhysxSphericalJointDesc:: set_joint_spring(const PhysxSpringDesc &spring) { _desc.jointSpring = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_swing_axis -// Access: Published -// Description: Set the swing limit axis defined in the joint -// space of actor 0. -//////////////////////////////////////////////////////////////////// +/** + * Set the swing limit axis defined in the joint space of actor 0. + */ void PhysxSphericalJointDesc:: set_swing_axis(const LVector3f &axis) { @@ -90,78 +76,63 @@ set_swing_axis(const LVector3f &axis) { _desc.swingAxis = PhysxManager::vec3_to_nxVec3(axis); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_projection_mode -// Access: Published -// Description: Use this to enable joint projection. -// Default is PM_none. -//////////////////////////////////////////////////////////////////// +/** + * Use this to enable joint projection. Default is PM_none. + */ void PhysxSphericalJointDesc:: set_projection_mode(PhysxProjectionMode mode) { _desc.projectionMode = (NxJointProjectionMode)mode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_twist_limit_low -// Access: Published -// Description: Limits rotation around twist axis. -//////////////////////////////////////////////////////////////////// +/** + * Limits rotation around twist axis. + */ void PhysxSphericalJointDesc:: set_twist_limit_low(const PhysxJointLimitDesc &low) { _desc.twistLimit.low = low._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_twist_limit_high -// Access: Published -// Description: Limits rotation around twist axis. -//////////////////////////////////////////////////////////////////// +/** + * Limits rotation around twist axis. + */ void PhysxSphericalJointDesc:: set_twist_limit_high(const PhysxJointLimitDesc &high) { _desc.twistLimit.high = high._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::set_swing_limit -// Access: Published -// Description: Limits swing of twist axis. -//////////////////////////////////////////////////////////////////// +/** + * Limits swing of twist axis. + */ void PhysxSphericalJointDesc:: set_swing_limit(const PhysxJointLimitDesc &limit) { _desc.swingLimit = limit._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_projection_distance -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSphericalJointDesc:: get_projection_distance() const { return _desc.projectionDistance; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxSphericalJointDesc:: get_flag(PhysxSphericalJointFlag flag) const { return (_desc.flags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_twist_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxSphericalJointDesc:: get_twist_spring() const { @@ -170,11 +141,9 @@ get_twist_spring() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_swing_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxSphericalJointDesc:: get_swing_spring() const { @@ -183,11 +152,9 @@ get_swing_spring() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_joint_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxSphericalJointDesc:: get_joint_spring() const { @@ -196,33 +163,27 @@ get_joint_spring() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_swing_axis -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LVector3f PhysxSphericalJointDesc:: get_swing_axis() const { return PhysxManager::nxVec3_to_vec3(_desc.swingAxis); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_projection_mode -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxEnums::PhysxProjectionMode PhysxSphericalJointDesc:: get_projection_mode() const { return (PhysxProjectionMode)_desc.projectionMode; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_twist_limit_low -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitDesc PhysxSphericalJointDesc:: get_twist_limit_low() const { @@ -231,11 +192,9 @@ get_twist_limit_low() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_twist_limit_high -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxJointLimitDesc PhysxSphericalJointDesc:: get_twist_limit_high() const { @@ -244,11 +203,9 @@ get_twist_limit_high() const { return value; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSphericalJointDesc::get_swing_limit -// Access: Published -// Description: Limits swing of twist axis. -//////////////////////////////////////////////////////////////////// +/** + * Limits swing of twist axis. + */ PhysxJointLimitDesc PhysxSphericalJointDesc:: get_swing_limit() const { @@ -256,4 +213,3 @@ get_swing_limit() const { value._desc = _desc.swingLimit; return value; } - diff --git a/panda/src/physx/physxSphericalJointDesc.h b/panda/src/physx/physxSphericalJointDesc.h index 717ac8932a..31bb011ed0 100644 --- a/panda/src/physx/physxSphericalJointDesc.h +++ b/panda/src/physx/physxSphericalJointDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSphericalJointDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSphericalJointDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXSPHERICALJOINTDESC_H #define PHYSXSPHERICALJOINTDESC_H @@ -23,11 +22,9 @@ class PhysxSpringDesc; class PhysxJointLimitDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxSphericalJointDesc -// Description : Descriptor class for distance joint. See -// PhysxSphericalJoint. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for distance joint. See PhysxSphericalJoint. + */ class EXPCL_PANDAPHYSX PhysxSphericalJointDesc : public PhysxJointDesc { PUBLISHED: diff --git a/panda/src/physx/physxSpringDesc.I b/panda/src/physx/physxSpringDesc.I index 26132d7117..a3bd8e16cf 100644 --- a/panda/src/physx/physxSpringDesc.I +++ b/panda/src/physx/physxSpringDesc.I @@ -1,33 +1,27 @@ -// Filename: physxSpringDesc.I -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSpringDesc.I + * @author enn0x + * @date 2009-09-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSpringDesc:: PhysxSpringDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSpringDesc:: PhysxSpringDesc(float spring, float damper, float target) { @@ -36,13 +30,10 @@ PhysxSpringDesc(float spring, float damper, float target) { _desc.targetValue = target; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxSpringDesc:: ~PhysxSpringDesc() { } - diff --git a/panda/src/physx/physxSpringDesc.cxx b/panda/src/physx/physxSpringDesc.cxx index 70604bba50..1a4a00afa4 100644 --- a/panda/src/physx/physxSpringDesc.cxx +++ b/panda/src/physx/physxSpringDesc.cxx @@ -1,82 +1,68 @@ -// Filename: physxSpringDesc.cxx -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSpringDesc.cxx + * @author enn0x + * @date 2009-09-28 + */ #include "physxSpringDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::set_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSpringDesc:: set_spring(float spring) { _desc.spring = spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::set_damper -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSpringDesc:: set_damper(float damper) { _desc.damper = damper; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::set_target_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxSpringDesc:: set_target_value(float targetValue) { _desc.targetValue = targetValue; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::get_spring -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSpringDesc:: get_spring() const { return _desc.spring; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::get_damper -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSpringDesc:: get_damper() const { return _desc.damper; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxSpringDesc::get_target_value -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxSpringDesc:: get_target_value() const { return _desc.targetValue; } - diff --git a/panda/src/physx/physxSpringDesc.h b/panda/src/physx/physxSpringDesc.h index f695a66c0c..3bb5086c8c 100644 --- a/panda/src/physx/physxSpringDesc.h +++ b/panda/src/physx/physxSpringDesc.h @@ -1,16 +1,15 @@ -// Filename: physxSpringDesc.h -// Created by: enn0x (28Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxSpringDesc.h + * @author enn0x + * @date 2009-09-28 + */ #ifndef PHYSXSPRINGDESC_H #define PHYSXSPRINGDESC_H @@ -19,12 +18,10 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxSpringDesc -// Description : Describes a joint spring. The spring is implicitly -// integrated, so even high spring and damper -// coefficients should be robust. -//////////////////////////////////////////////////////////////////// +/** + * Describes a joint spring. The spring is implicitly integrated, so even + * high spring and damper coefficients should be robust. + */ class EXPCL_PANDAPHYSX PhysxSpringDesc { PUBLISHED: diff --git a/panda/src/physx/physxTriangleMesh.I b/panda/src/physx/physxTriangleMesh.I index 54f5d0a1c2..3b983f3893 100644 --- a/panda/src/physx/physxTriangleMesh.I +++ b/panda/src/physx/physxTriangleMesh.I @@ -1,59 +1,47 @@ -// Filename: physxTriangleMesh.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMesh.I + * @author enn0x + * @date 2009-10-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMesh:: PhysxTriangleMesh() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMesh:: ~PhysxTriangleMesh() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxTriangleMesh:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxTriangleMesh:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxTriangleMesh.cxx b/panda/src/physx/physxTriangleMesh.cxx index a1a7000d5f..80971a3f2e 100644 --- a/panda/src/physx/physxTriangleMesh.cxx +++ b/panda/src/physx/physxTriangleMesh.cxx @@ -1,27 +1,24 @@ -// Filename: physxTriangleMesh.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMesh.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxTriangleMesh.h" #include "physxMeshPool.h" TypeHandle PhysxTriangleMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMesh:: link(NxTriangleMesh *meshPtr) { @@ -31,11 +28,9 @@ link(NxTriangleMesh *meshPtr) { _error_type = ET_ok; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMesh:: unlink() { @@ -44,11 +39,9 @@ unlink() { PhysxManager::get_global_ptr()->_triangle_meshes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::release -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMesh:: release() { @@ -61,11 +54,9 @@ release() { PhysxMeshPool::release_triangle_mesh(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMesh::get_reference_count -// Access: Published -// Description: Returns the reference count for shared meshes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference count for shared meshes. + */ unsigned int PhysxTriangleMesh:: get_reference_count() const { @@ -73,4 +64,3 @@ get_reference_count() const { return _ptr->getReferenceCount(); } - diff --git a/panda/src/physx/physxTriangleMesh.h b/panda/src/physx/physxTriangleMesh.h index fcbb059e17..bf2ef86301 100644 --- a/panda/src/physx/physxTriangleMesh.h +++ b/panda/src/physx/physxTriangleMesh.h @@ -1,16 +1,15 @@ -// Filename: physxTriangleMesh.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMesh.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXTRIANGLEMESH_H #define PHYSXTRIANGLEMESH_H @@ -20,16 +19,14 @@ #include "physxObject.h" #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxTriangleMesh -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxTriangleMesh : public PhysxObject { PUBLISHED: unsigned int get_reference_count() const; -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -48,14 +45,13 @@ public: private: NxTriangleMesh *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxTriangleMesh", + register_type(_type_handle, "PhysxTriangleMesh", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxTriangleMeshDesc.I b/panda/src/physx/physxTriangleMeshDesc.I index 9b7927a7b8..4acd6b09f9 100644 --- a/panda/src/physx/physxTriangleMeshDesc.I +++ b/panda/src/physx/physxTriangleMeshDesc.I @@ -1,23 +1,19 @@ -// Filename: physxTriangleMeshDesc.I -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshDesc.I + * @author enn0x + * @date 2009-10-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshDesc:: PhysxTriangleMeshDesc() { @@ -34,11 +30,9 @@ PhysxTriangleMeshDesc() { _materials = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshDesc:: ~PhysxTriangleMeshDesc() { @@ -55,14 +49,11 @@ INLINE PhysxTriangleMeshDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxTriangleMeshDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxTriangleMeshDesc.cxx b/panda/src/physx/physxTriangleMeshDesc.cxx index aeb27bab8d..896d3cb98b 100644 --- a/panda/src/physx/physxTriangleMeshDesc.cxx +++ b/panda/src/physx/physxTriangleMeshDesc.cxx @@ -1,16 +1,15 @@ -// Filename: physxTriangleMeshDesc.cxx -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshDesc.cxx + * @author enn0x + * @date 2009-10-11 + */ #include "physxTriangleMeshDesc.h" #include "physxManager.h" @@ -19,16 +18,13 @@ #include "geomNode.h" #include "geomVertexReader.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::set_num_vertices -// Access: Published -// Description: Sets the number of vertices to be stored within -// this triangle mesh. The function allocates memory -// for the vertices, but it does not set any vertices. -// -// This method must be called before any calls to -// set_vertex are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of vertices to be stored within this triangle mesh. The + * function allocates memory for the vertices, but it does not set any + * vertices. + * + * This method must be called before any calls to set_vertex are done! + */ void PhysxTriangleMeshDesc:: set_num_vertices(unsigned int numVertices) { @@ -42,12 +38,10 @@ set_num_vertices(unsigned int numVertices) { _desc.points = _vertices; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::set_vertex -// Access: Published -// Description: Sets a single vertex. You have to call the function -// set_num_vertices before you can call this function. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single vertex. You have to call the function set_num_vertices + * before you can call this function. + */ void PhysxTriangleMeshDesc:: set_vertex(unsigned int idx, const LPoint3f &vert) { @@ -55,15 +49,11 @@ set_vertex(unsigned int idx, const LPoint3f &vert) { _vertices[idx] = PhysxManager::point3_to_nxVec3(vert); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::set_num_triangles -// Access: Published -// Description: Sets the number of triangles to be stored in this -// triangle mesh. -// -// This method must be called before any calls to -// set_triangle are done! -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of triangles to be stored in this triangle mesh. + * + * This method must be called before any calls to set_triangle are done! + */ void PhysxTriangleMeshDesc:: set_num_triangles(unsigned int numTriangles, bool use_material_indices) { @@ -86,12 +76,9 @@ set_num_triangles(unsigned int numTriangles, bool use_material_indices) { } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::set_triangles -// Access: Published -// Description: Sets a single triangle, by providing the three -// indices i1, i2, i3. -//////////////////////////////////////////////////////////////////// +/** + * Sets a single triangle, by providing the three indices i1, i2, i3. + */ void PhysxTriangleMeshDesc:: set_triangle(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3, @@ -109,32 +96,23 @@ set_triangle(unsigned int idx, _triangles[idx + 2] = i3; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::get_desc -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const NxTriangleMeshDesc &PhysxTriangleMeshDesc:: get_desc() const { return _desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshDesc::set_from_node_path -// Access: Published -// Description: A convenience method to set the mesh data from -// a NodePath in a single call. The method iterates -// over the NodePath geoms and collects data for -// the triangle mesh. -// -// Do not use the following function when using this -// one: -// - set_num_vertices -// - set_vertex -// - set_num_triangles -// - set_triangle -//////////////////////////////////////////////////////////////////// +/** + * A convenience method to set the mesh data from a NodePath in a single call. + * The method iterates over the NodePath geoms and collects data for the + * triangle mesh. + * + * Do not use the following function when using this one: - set_num_vertices - + * set_vertex - set_num_triangles - set_triangle + */ void PhysxTriangleMeshDesc:: set_from_node_path(const NodePath &np) { @@ -211,4 +189,3 @@ set_from_node_path(const NodePath &np) { _desc.numTriangles = numTriangles; _desc.triangles = _triangles; } - diff --git a/panda/src/physx/physxTriangleMeshDesc.h b/panda/src/physx/physxTriangleMeshDesc.h index d6f31663bd..60b9503964 100644 --- a/panda/src/physx/physxTriangleMeshDesc.h +++ b/panda/src/physx/physxTriangleMeshDesc.h @@ -1,16 +1,15 @@ -// Filename: physxTriangleMeshDesc.h -// Created by: enn0x (11Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshDesc.h + * @author enn0x + * @date 2009-10-11 + */ #ifndef PHYSXTRIANGLEMESHDESC_H #define PHYSXTRIANGLEMESHDESC_H @@ -21,10 +20,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxTriangleMeshDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxTriangleMeshDesc { PUBLISHED: diff --git a/panda/src/physx/physxTriangleMeshShape.I b/panda/src/physx/physxTriangleMeshShape.I index a1244f15e5..35890f2bfb 100644 --- a/panda/src/physx/physxTriangleMeshShape.I +++ b/panda/src/physx/physxTriangleMeshShape.I @@ -1,36 +1,28 @@ -// Filename: physxTriangleMeshShape.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShape.I + * @author enn0x + * @date 2009-10-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshShape:: PhysxTriangleMeshShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshShape:: ~PhysxTriangleMeshShape() { } - diff --git a/panda/src/physx/physxTriangleMeshShape.cxx b/panda/src/physx/physxTriangleMeshShape.cxx index ccd76c9b12..954d0cf321 100644 --- a/panda/src/physx/physxTriangleMeshShape.cxx +++ b/panda/src/physx/physxTriangleMeshShape.cxx @@ -1,27 +1,24 @@ -// Filename: physxTriangleMeshShape.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShape.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxTriangleMeshShape.h" #include "physxTriangleMeshShapeDesc.h" TypeHandle PhysxTriangleMeshShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMeshShape:: link(NxShape *shapePtr) { @@ -35,11 +32,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMeshShape:: unlink() { @@ -50,16 +45,12 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxTriangleMeshShape:: save_to_desc(PhysxTriangleMeshShapeDesc &shapeDesc) const { nassertv(_error_type == ET_ok); _ptr->saveToDesc(shapeDesc._desc); } - diff --git a/panda/src/physx/physxTriangleMeshShape.h b/panda/src/physx/physxTriangleMeshShape.h index e368b2d7cb..57d49311ad 100644 --- a/panda/src/physx/physxTriangleMeshShape.h +++ b/panda/src/physx/physxTriangleMeshShape.h @@ -1,16 +1,15 @@ -// Filename: physxTriangleMeshShape.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShape.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXTRIANGLEMESHSHAPE_H #define PHYSXTRIANGLEMESHSHAPE_H @@ -22,11 +21,9 @@ class PhysxTriangleMeshShapeDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxTriangleMeshShape -// Description : A shapes which is used to represent an instance of -// an convex mesh. -//////////////////////////////////////////////////////////////////// +/** + * A shapes which is used to represent an instance of an convex mesh. + */ class EXPCL_PANDAPHYSX PhysxTriangleMeshShape : public PhysxShape { PUBLISHED: @@ -35,7 +32,6 @@ PUBLISHED: void save_to_desc(PhysxTriangleMeshShapeDesc &shapeDesc) const; -//////////////////////////////////////////////////////////////////// public: INLINE NxShape *ptr() const { return (NxShape *)_ptr; }; @@ -45,14 +41,13 @@ public: private: NxTriangleMeshShape *_ptr; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxShape::init_type(); - register_type(_type_handle, "PhysxTriangleMeshShape", + register_type(_type_handle, "PhysxTriangleMeshShape", PhysxShape::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxTriangleMeshShapeDesc.I b/panda/src/physx/physxTriangleMeshShapeDesc.I index 964f0519da..21c33397bf 100644 --- a/panda/src/physx/physxTriangleMeshShapeDesc.I +++ b/panda/src/physx/physxTriangleMeshShapeDesc.I @@ -1,45 +1,36 @@ -// Filename: physxTriangleMeshShapeDesc.I -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShapeDesc.I + * @author enn0x + * @date 2009-10-14 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshShapeDesc:: PhysxTriangleMeshShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriangleMeshShapeDesc:: ~PhysxTriangleMeshShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxTriangleMeshShapeDesc:: set_to_default() { @@ -47,14 +38,11 @@ set_to_default() { set_name(""); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxTriangleMeshShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxTriangleMeshShapeDesc.cxx b/panda/src/physx/physxTriangleMeshShapeDesc.cxx index b754ed5983..8a1be92e42 100644 --- a/panda/src/physx/physxTriangleMeshShapeDesc.cxx +++ b/panda/src/physx/physxTriangleMeshShapeDesc.cxx @@ -1,29 +1,24 @@ -// Filename: physxTriangleMeshShapeDesc.cxx -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShapeDesc.cxx + * @author enn0x + * @date 2009-10-14 + */ #include "physxTriangleMeshShapeDesc.h" #include "physxTriangleMesh.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriangleMeshShapeDesc::set_mesh -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriangleMeshShapeDesc:: set_mesh(PhysxTriangleMesh *mesh) { _desc.meshData = mesh->ptr(); } - - diff --git a/panda/src/physx/physxTriangleMeshShapeDesc.h b/panda/src/physx/physxTriangleMeshShapeDesc.h index 387a06bbeb..864f00a0e9 100644 --- a/panda/src/physx/physxTriangleMeshShapeDesc.h +++ b/panda/src/physx/physxTriangleMeshShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxTriangleMeshShapeDesc.h -// Created by: enn0x (14Oct09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriangleMeshShapeDesc.h + * @author enn0x + * @date 2009-10-14 + */ #ifndef PHYSXTRIANGLEMESHSHAPEDESC_H #define PHYSXTRIANGLEMESHSHAPEDESC_H @@ -22,10 +21,9 @@ class PhysxTriangleMesh; -//////////////////////////////////////////////////////////////////// -// Class : PhysxTriangleMeshShapeDesc -// Description : Descriptor class for PhysxTriangleMeshShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxTriangleMeshShape. + */ class EXPCL_PANDAPHYSX PhysxTriangleMeshShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physxTriggerReport.I b/panda/src/physx/physxTriggerReport.I index d52b3989bb..33f288ab55 100644 --- a/panda/src/physx/physxTriggerReport.I +++ b/panda/src/physx/physxTriggerReport.I @@ -1,36 +1,29 @@ -// Filename: physxTriggerReport.I -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriggerReport.I + * @author enn0x + * @date 2009-09-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriggerReport:: PhysxTriggerReport() : NxUserTriggerReport() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxTriggerReport:: ~PhysxTriggerReport() { } - diff --git a/panda/src/physx/physxTriggerReport.cxx b/panda/src/physx/physxTriggerReport.cxx index b00483fbd1..6d0ad2cf3e 100644 --- a/panda/src/physx/physxTriggerReport.cxx +++ b/panda/src/physx/physxTriggerReport.cxx @@ -1,16 +1,15 @@ -// Filename: physxTriggerReport.cxx -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriggerReport.cxx + * @author enn0x + * @date 2009-09-19 + */ #include "physxTriggerReport.h" @@ -20,44 +19,36 @@ PStatCollector PhysxTriggerReport::_pcollector("App:PhysX:Trigger Reporting"); -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::enable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriggerReport:: enable() { _enabled = true; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::disable -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriggerReport:: disable() { _enabled = false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::is_enabled -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PhysxTriggerReport:: is_enabled() const { return _enabled; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxTriggerReport::onTrigger -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxTriggerReport:: onTrigger(NxShape &triggerShape, NxShape &otherShape, NxTriggerFlag status) { @@ -90,4 +81,3 @@ onTrigger(NxShape &triggerShape, NxShape &otherShape, NxTriggerFlag status) { _pcollector.stop(); } - diff --git a/panda/src/physx/physxTriggerReport.h b/panda/src/physx/physxTriggerReport.h index 6b068400e7..3a8d37cc3d 100644 --- a/panda/src/physx/physxTriggerReport.h +++ b/panda/src/physx/physxTriggerReport.h @@ -1,16 +1,15 @@ -// Filename: physxTriggerReport.h -// Created by: enn0x (19Sep09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxTriggerReport.h + * @author enn0x + * @date 2009-09-19 + */ #ifndef PHYSXTRIGGERREPORT_H #define PHYSXTRIGGERREPORT_H @@ -20,11 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxTriggerReport -// Description : Implementation of the NxUserTriggerReport -// interface. -//////////////////////////////////////////////////////////////////// +/** + * Implementation of the NxUserTriggerReport interface. + */ class EXPCL_PANDAPHYSX PhysxTriggerReport : public NxUserTriggerReport { public: diff --git a/panda/src/physx/physxUtilLib.I b/panda/src/physx/physxUtilLib.I index df1c0449d2..ff04f2a2c2 100644 --- a/panda/src/physx/physxUtilLib.I +++ b/panda/src/physx/physxUtilLib.I @@ -1,37 +1,30 @@ -// Filename: physxUtilLib.I -// Created by: enn0x (01Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxUtilLib.I + * @author enn0x + * @date 2009-11-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxUtilLib:: PhysxUtilLib() { _ptr = NxGetUtilLib(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxUtilLib:: ~PhysxUtilLib() { _ptr = NULL; } - diff --git a/panda/src/physx/physxUtilLib.cxx b/panda/src/physx/physxUtilLib.cxx index 161e84c9a8..fa26d10883 100644 --- a/panda/src/physx/physxUtilLib.cxx +++ b/panda/src/physx/physxUtilLib.cxx @@ -1,16 +1,15 @@ -// Filename: physxUtilLib.cxx -// Created by: enn0x (01Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxUtilLib.cxx + * @author enn0x + * @date 2009-11-01 + */ #include "physxUtilLib.h" #include "physxManager.h" @@ -22,150 +21,121 @@ #include "physxSegment.h" #include "physxSphere.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_exceptions -// Access: Published -// Description: Set FPU precision. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU precision. + */ void PhysxUtilLib:: set_fpu_exceptions(bool b) { _ptr->NxSetFPUExceptions(b); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_precision24 -// Access: Published -// Description: Set FPU precision. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU precision. + */ void PhysxUtilLib:: set_fpu_precision24() { _ptr->NxSetFPUPrecision24(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_precision53 -// Access: Published -// Description: Set FPU precision. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU precision. + */ void PhysxUtilLib:: set_fpu_precision53() { _ptr->NxSetFPUPrecision53(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_precision64 -// Access: Published -// Description: Set FPU precision. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU precision. + */ void PhysxUtilLib:: set_fpu_precision64() { _ptr->NxSetFPUPrecision64(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_rounding_chop -// Access: Published -// Description: Set FPU precision. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU precision. + */ void PhysxUtilLib:: set_fpu_rounding_chop() { _ptr->NxSetFPURoundingChop(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_rounding_down -// Access: Published -// Description: Set FPU rounding mode. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU rounding mode. + */ void PhysxUtilLib:: set_fpu_rounding_down() { _ptr->NxSetFPURoundingDown(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_rounding_near -// Access: Published -// Description: Set FPU rounding mode. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU rounding mode. + */ void PhysxUtilLib:: set_fpu_rounding_near() { _ptr->NxSetFPURoundingNear(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::set_fpu_rounding_up -// Access: Published -// Description: Set FPU rounding mode. -//////////////////////////////////////////////////////////////////// +/** + * Set FPU rounding mode. + */ void PhysxUtilLib:: set_fpu_rounding_up() { _ptr->NxSetFPURoundingUp(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::int_ceil -// Access: Published -// Description: Convert a floating point number to an integer. -//////////////////////////////////////////////////////////////////// +/** + * Convert a floating point number to an integer. + */ int PhysxUtilLib:: int_ceil(const float &f) { return _ptr->NxIntCeil(f); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::int_chop -// Access: Published -// Description: Convert a floating point number to an integer. -//////////////////////////////////////////////////////////////////// +/** + * Convert a floating point number to an integer. + */ int PhysxUtilLib:: int_chop(const float &f) { return _ptr->NxIntChop(f); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::int_floor -// Access: Published -// Description: Convert a floating point number to an integer. -//////////////////////////////////////////////////////////////////// +/** + * Convert a floating point number to an integer. + */ int PhysxUtilLib:: int_floor(const float &f) { return _ptr->NxIntFloor(f); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::box_contains_point -// Access: Published -// Description: Test if an oriented box contains a point. -// -// \param [in] box -// \param [in] p -//////////////////////////////////////////////////////////////////// +/** + * Test if an oriented box contains a point. + * + * \param [in] box \param [in] p + */ bool PhysxUtilLib:: box_contains_point(const PhysxBox &box, const LPoint3f &p) { return _ptr->NxBoxContainsPoint(box._box, PhysxManager::point3_to_nxVec3(p)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::create_box -// Access: Published -// Description: Create an oriented box from an axis aligned box -// and a transformation. -// -// \param [in] aabb -// \param [in] mat -//////////////////////////////////////////////////////////////////// +/** + * Create an oriented box from an axis aligned box and a transformation. + * + * \param [in] aabb \param [in] mat + */ PhysxBox PhysxUtilLib:: create_box(const PhysxBounds3 &aabb, const LMatrix4f &mat) { @@ -174,17 +144,13 @@ create_box(const PhysxBounds3 &aabb, const LMatrix4f &mat) { return box; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_box_world_edge_normal -// Access: Published -// Description: Compute and edge normals for an oriented box. This -// is an averaged normal, from the two faces sharing -// the edge. The edge index should be from 0 to 11 -// (i.e. a box has 12 edges). -// -// \param [in] box -// \param [in] edge_index -//////////////////////////////////////////////////////////////////// +/** + * Compute and edge normals for an oriented box. This is an averaged normal, + * from the two faces sharing the edge. The edge index should be from 0 to 11 + * (i.e. a box has 12 edges). + * + * \param [in] box \param [in] edge_index + */ LVector3f PhysxUtilLib:: compute_box_world_edge_normal(const PhysxBox &box, unsigned int edge_index) { @@ -196,13 +162,11 @@ compute_box_world_edge_normal(const PhysxBox &box, unsigned int edge_index) { return PhysxManager::nxVec3_to_vec3(nNormal); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_capsule_around_box -// Access: Published -// Description: Compute a capsule which encloses a box. -// -// \param [in] box -//////////////////////////////////////////////////////////////////// +/** + * Compute a capsule which encloses a box. + * + * \param [in] box + */ PhysxCapsule PhysxUtilLib:: compute_capsule_around_box(const PhysxBox &box) { @@ -211,28 +175,23 @@ compute_capsule_around_box(const PhysxBox &box) { return capsule; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::is_box_a_inside_box_b -// Access: Published -// Description: Test if box A is inside another box B. Returns -// TRUE if box A is inside box B. -// -// \param [in] a -// \param [in] b -//////////////////////////////////////////////////////////////////// +/** + * Test if box A is inside another box B. Returns TRUE if box A is inside box + * B. + * + * \param [in] a \param [in] b + */ bool PhysxUtilLib:: is_box_a_inside_box_b(const PhysxBox &a, const PhysxBox &b) { return _ptr->NxIsBoxAInsideBoxB(a._box, b._box); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_box_around_capsule -// Access: Published -// Description: Compute a box which encloses a capsule. -// -// \param [in] capsule -//////////////////////////////////////////////////////////////////// +/** + * Compute a box which encloses a capsule. + * + * \param [in] capsule + */ PhysxBox PhysxUtilLib:: compute_box_around_capsule(const PhysxCapsule &capsule) { @@ -241,15 +200,11 @@ compute_box_around_capsule(const PhysxCapsule &capsule) { return box; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_distance_squared -// Access: Published -// Description: Compute the distance squared from a point to a -// ray. -// -// \param [in] ray -// \param [in] point -//////////////////////////////////////////////////////////////////// +/** + * Compute the distance squared from a point to a ray. + * + * \param [in] ray \param [in] point + */ float PhysxUtilLib:: compute_distance_squared(const PhysxRay &ray, const LPoint3f &point) { @@ -257,15 +212,11 @@ compute_distance_squared(const PhysxRay &ray, const LPoint3f &point) { return _ptr->NxComputeDistanceSquared(ray._ray, PhysxManager::point3_to_nxVec3(point), &t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_square_distance -// Access: Published -// Description: Compute the distance squared from a point to a -// line segment. -// -// \param [in] seg -// \param [in] point -//////////////////////////////////////////////////////////////////// +/** + * Compute the distance squared from a point to a line segment. + * + * \param [in] seg \param [in] point + */ float PhysxUtilLib:: compute_square_distance(const PhysxSegment &seg, const LPoint3f &point) { @@ -273,15 +224,11 @@ compute_square_distance(const PhysxSegment &seg, const LPoint3f &point) { return _ptr->NxComputeSquareDistance(seg._segment, PhysxManager::point3_to_nxVec3(point), &t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::merge_spheres -// Access: Published -// Description: Compute an overall bounding sphere for a pair of -// spheres. -// -// \param [in] sphere0 -// \param [in] sphere1 -//////////////////////////////////////////////////////////////////// +/** + * Compute an overall bounding sphere for a pair of spheres. + * + * \param [in] sphere0 \param [in] sphere1 + */ PhysxSphere PhysxUtilLib:: merge_spheres(const PhysxSphere &sphere0, const PhysxSphere &sphere1) { @@ -290,15 +237,11 @@ merge_spheres(const PhysxSphere &sphere0, const PhysxSphere &sphere1) { return merged; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::normal_to_tangents -// Access: Published -// Description: Get the tangent vectors associated with a normal. -// -// \param [in] n -// \param [out] t1 -// \param [out] t2 -//////////////////////////////////////////////////////////////////// +/** + * Get the tangent vectors associated with a normal. + * + * \param [in] n \param [out] t1 \param [out] t2 + */ void PhysxUtilLib:: normal_to_tangents(const LVector3f &n, LVector3f &t1, LVector3f &t2) { @@ -316,15 +259,11 @@ normal_to_tangents(const LVector3f &n, LVector3f &t1, LVector3f &t2) { t2.set_z(nt2.z); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::find_rotation_matrix -// Access: Published -// Description: Computes a rotation matrix M so that: M * x = b -// (x and b are unit vectors). -// -// \param [in] x -// \param [in] b -//////////////////////////////////////////////////////////////////// +/** + * Computes a rotation matrix M so that: M * x = b (x and b are unit vectors). + * + * \param [in] x \param [in] b + */ LMatrix3f PhysxUtilLib:: find_rotation_matrix(const LVector3f &x, const LVector3f &b) { @@ -335,166 +274,122 @@ find_rotation_matrix(const LVector3f &x, const LVector3f &b) { return PhysxManager::nxMat33_to_mat3(nmat); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_sphere_mass -// Access: Published -// Description: Computes mass of a homogeneous sphere according -// to sphere density. -// -// \param [in] radius -// \param [in] density -//////////////////////////////////////////////////////////////////// +/** + * Computes mass of a homogeneous sphere according to sphere density. + * + * \param [in] radius \param [in] density + */ float PhysxUtilLib:: compute_sphere_mass(float radius, float density) { return _ptr->NxComputeSphereMass(radius, density); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_sphere_density -// Access: Published -// Description: Computes density of a homogeneous sphere according -// to sphere mass -// -// \param [in] radius -// \param [in] mass -//////////////////////////////////////////////////////////////////// +/** + * Computes density of a homogeneous sphere according to sphere mass + * + * \param [in] radius \param [in] mass + */ float PhysxUtilLib:: compute_sphere_density(float radius, float mass) { return _ptr->NxComputeSphereDensity(radius, mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_box_mass -// Access: Published -// Description: Computes mass of a homogeneous box according to -// box density. -// -// \param [in] radius -// \param [in] density -//////////////////////////////////////////////////////////////////// +/** + * Computes mass of a homogeneous box according to box density. + * + * \param [in] radius \param [in] density + */ float PhysxUtilLib:: compute_box_mass(const LVector3f &extents, float density) { return _ptr->NxComputeBoxMass(PhysxManager::vec3_to_nxVec3(extents), density); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_box_density -// Access: Published -// Description: Computes density of a homogeneous box according to -// box mass. -// -// \param [in] radius -// \param [in] mass -//////////////////////////////////////////////////////////////////// +/** + * Computes density of a homogeneous box according to box mass. + * + * \param [in] radius \param [in] mass + */ float PhysxUtilLib:: compute_box_density(const LVector3f &extents, float mass) { return _ptr->NxComputeBoxDensity(PhysxManager::vec3_to_nxVec3(extents), mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_ellipsoid_mass -// Access: Published -// Description: Computes mass of a homogeneous ellipsoid according -// to ellipsoid density. -// -// \param [in] radius -// \param [in] density -//////////////////////////////////////////////////////////////////// +/** + * Computes mass of a homogeneous ellipsoid according to ellipsoid density. + * + * \param [in] radius \param [in] density + */ float PhysxUtilLib:: compute_ellipsoid_mass(const LVector3f &extents, float density ) { return _ptr->NxComputeEllipsoidMass(PhysxManager::vec3_to_nxVec3(extents), density); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_ellipsoid_density -// Access: Published -// Description: Computes density of a homogeneous ellipsoid -// according to ellipsoid mass. -// -// \param [in] radius -// \param [in] mass -//////////////////////////////////////////////////////////////////// +/** + * Computes density of a homogeneous ellipsoid according to ellipsoid mass. + * + * \param [in] radius \param [in] mass + */ float PhysxUtilLib:: compute_ellipsoid_density(const LVector3f &extents, float mass) { return _ptr->NxComputeEllipsoidDensity(PhysxManager::vec3_to_nxVec3(extents), mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_cylinder_mass -// Access: Published -// Description: Computes mass of a homogeneous cylinder according -// to cylinder density. -// -// \param [in] radius -// \param [in] density -//////////////////////////////////////////////////////////////////// +/** + * Computes mass of a homogeneous cylinder according to cylinder density. + * + * \param [in] radius \param [in] density + */ float PhysxUtilLib:: compute_cylinder_mass(float radius, float length, float density) { return _ptr->NxComputeCylinderMass(radius, length, density); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_cylinder_density -// Access: Published -// Description: Computes density of a homogeneous cylinder -// according to cylinder mass. -// -// \param [in] radius -// \param [in] mass -//////////////////////////////////////////////////////////////////// +/** + * Computes density of a homogeneous cylinder according to cylinder mass. + * + * \param [in] radius \param [in] mass + */ float PhysxUtilLib:: compute_cylinder_density(float radius, float length, float mass) { return _ptr->NxComputeCylinderDensity(radius, length, mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_cone_mass -// Access: Published -// Description: Computes mass of a homogeneous cone according to -// cone density. -// -// \param [in] radius -// \param [in] density -//////////////////////////////////////////////////////////////////// +/** + * Computes mass of a homogeneous cone according to cone density. + * + * \param [in] radius \param [in] density + */ float PhysxUtilLib:: compute_cone_mass(float radius, float length, float density) { return _ptr->NxComputeConeMass(radius, length, density); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_cone_density -// Access: Published -// Description: Computes density of a homogeneous cone according -// to cone mass. -// -// \param [in] radius -// \param [in] mass -//////////////////////////////////////////////////////////////////// +/** + * Computes density of a homogeneous cone according to cone mass. + * + * \param [in] radius \param [in] mass + */ float PhysxUtilLib:: compute_cone_density(float radius, float length, float mass) { return _ptr->NxComputeConeDensity(radius, length, mass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_box_inertia_tensor -// Access: Published -// Description: Computes diagonalized inertia tensor for a box. -// -// \param [in] mass -// \param [in] xlength -// \param [in] ylength -// \param [in] zlength -//////////////////////////////////////////////////////////////////// +/** + * Computes diagonalized inertia tensor for a box. + * + * \param [in] mass \param [in] xlength \param [in] ylength \param [in] + * zlength + */ LVector3f PhysxUtilLib:: compute_box_inertia_tensor(float mass, float xlength, float ylength, float zlength) { @@ -503,15 +398,11 @@ compute_box_inertia_tensor(float mass, float xlength, float ylength, float zleng return PhysxManager::nxVec3_to_vec3(tensor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::compute_sphere_inertia_tensor -// Access: Published -// Description: Computes diagonalized inertia tensor for a sphere. -// -// \param [in] mass -// \param [in] radius -// \param [in] hollow -//////////////////////////////////////////////////////////////////// +/** + * Computes diagonalized inertia tensor for a sphere. + * + * \param [in] mass \param [in] radius \param [in] hollow + */ LVector3f PhysxUtilLib:: compute_sphere_inertia_tensor(float mass, float radius, bool hollow) { @@ -520,21 +411,13 @@ compute_sphere_inertia_tensor(float mass, float radius, bool hollow) { return PhysxManager::nxVec3_to_vec3(tensor); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::box_box_intersect -// Access: Published -// Description: Boolean intersection test between two OBBs. Uses -// the separating axis theorem. Disabling 'full_test' -// only performs 6 axis tests out of 15. -// -// \param [in] extents0 -// \param [in] center0 -// \param [in] rotation0 -// \param [in] extents1 -// \param [in] center1 -// \param [in] rotation1 -// \param [in] full_test -//////////////////////////////////////////////////////////////////// +/** + * Boolean intersection test between two OBBs. Uses the separating axis + * theorem. Disabling 'full_test' only performs 6 axis tests out of 15. + * + * \param [in] extents0 \param [in] center0 \param [in] rotation0 \param [in] + * extents1 \param [in] center1 \param [in] rotation1 \param [in] full_test + */ bool PhysxUtilLib:: box_box_intersect(const LVector3f &extents0, const LPoint3f ¢er0, const LMatrix3f &rotation0, const LVector3f &extents1, const LPoint3f ¢er1, const LMatrix3f &rotation1, bool full_test) { @@ -554,18 +437,12 @@ box_box_intersect(const LVector3f &extents0, const LPoint3f ¢er0, const LMat PhysxManager::mat3_to_nxMat33(rotation1), full_test); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::tri_box_intersect -// Access: Published -// Description: Boolean intersection test between a triangle and -// a box. -// -// \param [in] vertex0 -// \param [in] vertex1 -// \param [in] vertex2 -// \param [in] center -// \param [in] extents -//////////////////////////////////////////////////////////////////// +/** + * Boolean intersection test between a triangle and a box. + * + * \param [in] vertex0 \param [in] vertex1 \param [in] vertex2 \param [in] + * center \param [in] extents + */ bool PhysxUtilLib:: tri_box_intersect(const LPoint3f &vertex0, const LPoint3f &vertex1, const LPoint3f &vertex2, const LPoint3f ¢er, const LVector3f &extents) { @@ -583,15 +460,11 @@ tri_box_intersect(const LPoint3f &vertex0, const LPoint3f &vertex1, const LPoint PhysxManager::point3_to_nxVec3(extents)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_plane_intersect -// Access: Published -// Description: Ray-plane intersection test. -// -// \param [in] ray -// \param [in] plane -// \param [out] point_on_plane -//////////////////////////////////////////////////////////////////// +/** + * Ray-plane intersection test. + * + * \param [in] ray \param [in] plane \param [out] point_on_plane + */ bool PhysxUtilLib:: ray_plane_intersect(const PhysxRay &ray, const PhysxPlane &plane, LPoint3f &point_on_plane) { @@ -604,20 +477,13 @@ ray_plane_intersect(const PhysxRay &ray, const PhysxPlane &plane, LPoint3f &poin return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_sphere_intersect -// Access: Published -// Description: Ray-sphere intersection test. Returns true if the -// ray intersects the sphere, and the impact point if -// needed. -// -// \param [in] origin -// \param [in] dir -// \param [in] length -// \param [in] center -// \param [in] radius -// \param [out] hit_pos -//////////////////////////////////////////////////////////////////// +/** + * Ray-sphere intersection test. Returns true if the ray intersects the + * sphere, and the impact point if needed. + * + * \param [in] origin \param [in] dir \param [in] length \param [in] center + * \param [in] radius \param [out] hit_pos + */ bool PhysxUtilLib:: ray_sphere_intersect(const LPoint3f &origin, const LVector3f &dir, float length, const LPoint3f ¢er, float radius, LPoint3f &hit_pos) { @@ -641,18 +507,12 @@ ray_sphere_intersect(const LPoint3f &origin, const LVector3f &dir, float length, return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::segment_box_intersect -// Access: Published -// Description: Segment-AABB intersection test. Also computes -// intersection point. -// -// \param [in] p1 -// \param [in] p2 -// \param [in] bbox_min -// \param [in] bbox_max -// \param [out] intercept -//////////////////////////////////////////////////////////////////// +/** + * Segment-AABB intersection test. Also computes intersection point. + * + * \param [in] p1 \param [in] p2 \param [in] bbox_min \param [in] bbox_max + * \param [out] intercept + */ bool PhysxUtilLib:: segment_box_intersect(const LPoint3f &p1, const LPoint3f &p2, const LPoint3f &bbox_min, const LPoint3f &bbox_max, LPoint3f &intercept) { @@ -674,18 +534,12 @@ segment_box_intersect(const LPoint3f &p1, const LPoint3f &p2, const LPoint3f &bb return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_aabb_intersect -// Access: Published -// Description: Ray-AABB intersection test. Also computes -// intersection point. -// -// \param [in] min -// \param [in] max -// \param [in] origin -// \param [in] dir -// \param [out] coord -//////////////////////////////////////////////////////////////////// +/** + * Ray-AABB intersection test. Also computes intersection point. + * + * \param [in] min \param [in] max \param [in] origin \param [in] dir \param + * [out] coord + */ bool PhysxUtilLib:: ray_aabb_intersect(const LPoint3f &min, const LPoint3f &max, const LPoint3f &origin, const LVector3f &dir, LPoint3f &coord) { @@ -707,18 +561,12 @@ ray_aabb_intersect(const LPoint3f &min, const LPoint3f &max, const LPoint3f &ori return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::segment_obb_intersect -// Access: Published -// Description: Boolean segment-OBB intersection test. Based on -// separating axis theorem. -// -// \param [in] p0 -// \param [in] p1 -// \param [in] center -// \param [in] extents -// \param [in] rot -//////////////////////////////////////////////////////////////////// +/** + * Boolean segment-OBB intersection test. Based on separating axis theorem. + * + * \param [in] p0 \param [in] p1 \param [in] center \param [in] extents \param + * [in] rot + */ bool PhysxUtilLib:: segment_obb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) { @@ -736,17 +584,11 @@ segment_obb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &ce PhysxManager::mat3_to_nxMat33(rot)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::segment_aabb_intersect -// Access: Published -// Description: Boolean segment-AABB intersection test. Based on -// separating axis theorem. -// -// \param [in] p0 -// \param [in] p1 -// \param [in] min -// \param [in] max -//////////////////////////////////////////////////////////////////// +/** + * Boolean segment-AABB intersection test. Based on separating axis theorem. + * + * \param [in] p0 \param [in] p1 \param [in] min \param [in] max + */ bool PhysxUtilLib:: segment_aabb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &min, const LPoint3f &max) { @@ -762,17 +604,11 @@ segment_aabb_intersect(const LPoint3f &p0, const LPoint3f &p1, const LPoint3f &m PhysxManager::point3_to_nxVec3(max)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_obb_intersect -// Access: Published -// Description: Boolean ray-OBB intersection test. Based on -// separating axis theorem. -// -// \param [in] ray -// \param [in] center -// \param [in] extents -// \param [in] rot -//////////////////////////////////////////////////////////////////// +/** + * Boolean ray-OBB intersection test. Based on separating axis theorem. + * + * \param [in] ray \param [in] center \param [in] extents \param [in] rot + */ bool PhysxUtilLib:: ray_obb_intersect(const PhysxRay &ray, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot) { @@ -787,16 +623,12 @@ ray_obb_intersect(const PhysxRay &ray, const LPoint3f ¢er, const LVector3f & PhysxManager::mat3_to_nxMat33(rot)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_capsule_intersect -// Access: Published -// Description: Ray-capsule intersection test. Returns number of -// intersection points (0,1 or 2) along the ray. -// -// \param [in] origin -// \param [in] dir -// \param [in] capsule -//////////////////////////////////////////////////////////////////// +/** + * Ray-capsule intersection test. Returns number of intersection points (0,1 + * or 2) along the ray. + * + * \param [in] origin \param [in] dir \param [in] capsule + */ unsigned int PhysxUtilLib:: ray_capsule_intersect(const LPoint3f &origin, const LVector3f &dir, const PhysxCapsule &capsule) { @@ -811,18 +643,13 @@ ray_capsule_intersect(const LPoint3f &origin, const LVector3f &dir, const PhysxC capsule._capsule, t); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::swept_spheres_intersect -// Access: Published -// Description: Sphere-sphere sweep test. Returns true if spheres -// intersect during their linear motion along -// provided velocity vectors. -// -// \param [in] sphere0 -// \param [in] velocity0 -// \param [in] sphere1 -// \param [in] velocity1 -//////////////////////////////////////////////////////////////////// +/** + * Sphere-sphere sweep test. Returns true if spheres intersect during their + * linear motion along provided velocity vectors. + * + * \param [in] sphere0 \param [in] velocity0 \param [in] sphere1 \param [in] + * velocity1 + */ bool PhysxUtilLib:: swept_spheres_intersect(const PhysxSphere &sphere0, const LVector3f &velocity0, const PhysxSphere &sphere1, const LVector3f &velocity1) { @@ -836,22 +663,14 @@ swept_spheres_intersect(const PhysxSphere &sphere0, const LVector3f &velocity0, PhysxManager::vec3_to_nxVec3(velocity1)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::ray_tri_intersect -// Access: Published -// Description: Ray-triangle intersection test. Returns impact -// distance (t) as well as barycentric coordinates -// (u,v) of impact point. The test performs back face -// culling or not according to 'cull'. -// -// \param [in] orig -// \param [in] dir -// \param [in] vert0 -// \param [in] vert1 -// \param [in] vert2 -// \param [out] hit, with coordinates (t,u,v) -// \param [in] cull -//////////////////////////////////////////////////////////////////// +/** + * Ray-triangle intersection test. Returns impact distance (t) as well as + * barycentric coordinates (u,v) of impact point. The test performs back face + * culling or not according to 'cull'. + * + * \param [in] orig \param [in] dir \param [in] vert0 \param [in] vert1 \param + * [in] vert2 \param [out] hit, with coordinates (t,u,v) \param [in] cull + */ bool PhysxUtilLib:: ray_tri_intersect(const LPoint3f &orig, const LVector3f &dir, const LPoint3f &vert0, const LPoint3f &vert1, const LPoint3f &vert2, LVector3f &hit, bool cull) { @@ -878,19 +697,14 @@ ray_tri_intersect(const LPoint3f &orig, const LVector3f &dir, const LPoint3f &ve return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::sweep_box_capsule -// Access: Published -// Description: Box-vs-capsule sweep test. Sweeps a box against a -// capsule, returns true if box hit the capsule. Also -// returns contact information. -// -// \param [in] box Box -// \param [in] lss Capsule -// \param [in] dir Unit-length sweep direction -// \param [in] length Length of sweep -// \param [out] normal Normal at impact point -//////////////////////////////////////////////////////////////////// +/** + * Box-vs-capsule sweep test. Sweeps a box against a capsule, returns true if + * box hit the capsule. Also returns contact information. + * + * \param [in] box Box \param [in] lss Capsule \param [in] dir Unit-length + * sweep direction \param [in] length Length of sweep \param [out] normal + * Normal at impact point + */ bool PhysxUtilLib:: sweep_box_capsule(const PhysxBox &box, const PhysxCapsule &lss, const LVector3f &dir, float length, LVector3f &normal) { @@ -908,19 +722,14 @@ sweep_box_capsule(const PhysxBox &box, const PhysxCapsule &lss, const LVector3f return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::sweep_box_sphere -// Access: Published -// Description: Box-vs-sphere sweep test. Sweeps a box against a -// sphere, returns true if box hit the sphere. Also -// returns contact information. -// -// \param [in] box Box -// \param [in] sphere Sphere -// \param [in] dir Unit-length sweep direction -// \param [in] length Length of sweep -// \param [out] normal Normal at impact point -//////////////////////////////////////////////////////////////////// +/** + * Box-vs-sphere sweep test. Sweeps a box against a sphere, returns true if + * box hit the sphere. Also returns contact information. + * + * \param [in] box Box \param [in] sphere Sphere \param [in] dir Unit-length + * sweep direction \param [in] length Length of sweep \param [out] normal + * Normal at impact point + */ bool PhysxUtilLib:: sweep_box_sphere(const PhysxBox &box, const PhysxSphere &sphere, const LVector3f &dir, float length, LVector3f &normal) { @@ -938,20 +747,14 @@ sweep_box_sphere(const PhysxBox &box, const PhysxSphere &sphere, const LVector3f return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::sweep_capsule_capsule -// Access: Published -// Description: Capsule-vs-capsule sweep test. Sweeps a capsule -// against a capsule, returns true if capsule hit the -// other capsule. Also returns contact information. -// -// \param [in] lss0 -// \param [in] lss1 -// \param [in] dir Unit-length sweep direction -// \param [in] length Length of sweep -// \param [out] ip Impact point -// \param [out] normal Normal at impact point -//////////////////////////////////////////////////////////////////// +/** + * Capsule-vs-capsule sweep test. Sweeps a capsule against a capsule, returns + * true if capsule hit the other capsule. Also returns contact information. + * + * \param [in] lss0 \param [in] lss1 \param [in] dir Unit-length sweep + * direction \param [in] length Length of sweep \param [out] ip Impact point + * \param [out] normal Normal at impact point + */ bool PhysxUtilLib:: sweep_capsule_capsule(const PhysxCapsule &lss0, const PhysxCapsule &lss1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) { @@ -971,20 +774,14 @@ sweep_capsule_capsule(const PhysxCapsule &lss0, const PhysxCapsule &lss1, const return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::sweep_sphere_capsule -// Access: Published -// Description: Sphere-vs-capsule sweep test. Sweeps a sphere -// against a capsule, returns true if sphere hit the -// capsule. Also returns contact information. -// -// \param [in] sphere -// \param [in] lss -// \param [in] dir Unit-length sweep direction -// \param [in] length Length of sweep -// \param [out] ip Impact point -// \param [out] normal Normal at impact point -//////////////////////////////////////////////////////////////////// +/** + * Sphere-vs-capsule sweep test. Sweeps a sphere against a capsule, returns + * true if sphere hit the capsule. Also returns contact information. + * + * \param [in] sphere \param [in] lss \param [in] dir Unit-length sweep + * direction \param [in] length Length of sweep \param [out] ip Impact point + * \param [out] normal Normal at impact point + */ bool PhysxUtilLib:: sweep_sphere_capsule(const PhysxSphere &sphere, const PhysxCapsule &lss, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) { @@ -1004,20 +801,14 @@ sweep_sphere_capsule(const PhysxSphere &sphere, const PhysxCapsule &lss, const L return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::sweep_box_box -// Access: Published -// Description: Box-vs-box sweep test. Sweeps a box against a box, -// returns true if box hit the other box. Also returns -// contact information. -// -// \param [in] box0 -// \param [in] box1 -// \param [in] dir Unit-length sweep direction -// \param [in] length Length of sweep -// \param [out] ip Impact point -// \param [out] normal Normal at impact point -//////////////////////////////////////////////////////////////////// +/** + * Box-vs-box sweep test. Sweeps a box against a box, returns true if box hit + * the other box. Also returns contact information. + * + * \param [in] box0 \param [in] box1 \param [in] dir Unit-length sweep + * direction \param [in] length Length of sweep \param [out] ip Impact point + * \param [out] normal Normal at impact point + */ bool PhysxUtilLib:: sweep_box_box(const PhysxBox &box0, const PhysxBox &box1, const LVector3f &dir, float length, LPoint3f &ip, LVector3f &normal) { @@ -1037,18 +828,14 @@ sweep_box_box(const PhysxBox &box0, const PhysxBox &box1, const LVector3f &dir, return result; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxUtilLib::point_obb_sqr_dist -// Access: Published -// Description: Point-vs-OBB distance computation. Returns distance -// between a point and an OBB. -// -// \param [in] point The point -// \param [in] center OBB center -// \param [in] extents OBB extents -// \param [in] rot OBB rotation -// \param [out] params Closest point on the box, in box space -//////////////////////////////////////////////////////////////////// +/** + * Point-vs-OBB distance computation. Returns distance between a point and an + * OBB. + * + * \param [in] point The point \param [in] center OBB center \param [in] + * extents OBB extents \param [in] rot OBB rotation \param [out] params + * Closest point on the box, in box space + */ float PhysxUtilLib:: point_obb_sqr_dist(const LPoint3f &point, const LPoint3f ¢er, const LVector3f &extents, const LMatrix3f &rot, LPoint3f ¶ms) { @@ -1069,4 +856,3 @@ point_obb_sqr_dist(const LPoint3f &point, const LPoint3f ¢er, const LVector3 PhysxManager::update_point3_from_nxVec3(params, nParams); return result; } - diff --git a/panda/src/physx/physxUtilLib.h b/panda/src/physx/physxUtilLib.h index 2a9b9f1e9b..acd4901363 100644 --- a/panda/src/physx/physxUtilLib.h +++ b/panda/src/physx/physxUtilLib.h @@ -1,16 +1,15 @@ -// Filename: physxUtilLib.h -// Created by: enn0x (01Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxUtilLib.h + * @author enn0x + * @date 2009-11-01 + */ #ifndef PHYSXUTILLIB_H #define PHYSXUTILLIB_H @@ -28,10 +27,9 @@ class PhysxRay; class PhysxSegment; class PhysxSphere; -//////////////////////////////////////////////////////////////////// -// Class : PhysxUtilLib -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxUtilLib { PUBLISHED: diff --git a/panda/src/physx/physxVehicle.I b/panda/src/physx/physxVehicle.I index d9f6db7f0e..3be65f3a92 100644 --- a/panda/src/physx/physxVehicle.I +++ b/panda/src/physx/physxVehicle.I @@ -1,59 +1,47 @@ -// Filename: physxVehicle.I -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicle.I + * @author enn0x + * @date 2010-03-23 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxVehicle:: PhysxVehicle() : PhysxObject() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxVehicle:: ~PhysxVehicle() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxVehicle:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxVehicle:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxVehicle.cxx b/panda/src/physx/physxVehicle.cxx index aa2cf6f9d4..39314bff32 100644 --- a/panda/src/physx/physxVehicle.cxx +++ b/panda/src/physx/physxVehicle.cxx @@ -1,16 +1,15 @@ -// Filename: physxVehicle.cxx -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicle.cxx + * @author enn0x + * @date 2010-03-23 + */ #include "physxVehicle.h" #include "physxActor.h" @@ -19,11 +18,9 @@ TypeHandle PhysxVehicle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::create -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxVehicle:: create(PhysxScene *scene, PhysxVehicleDesc &desc) { @@ -37,11 +34,9 @@ create(PhysxScene *scene, PhysxVehicleDesc &desc) { _scene->_vehicles.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::release -// Access: Published -// Description: Destroys this vehicle. -//////////////////////////////////////////////////////////////////// +/** + * Destroys this vehicle. + */ void PhysxVehicle:: release() { @@ -51,11 +46,9 @@ release() { _scene->_vehicles.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::update_vehicle -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxVehicle:: update_vehicle(float dt) { @@ -65,11 +58,9 @@ update_vehicle(float dt) { } /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::get_actor -// Access: Published -// Description: Returns the actor for this vehicle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actor for this vehicle. + */ PhysxActor *PhysxVehicle:: get_actor() const { @@ -79,11 +70,9 @@ get_actor() const { */ /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::get_num_wheels -// Access: Published -// Description: Returns the number of wheels on this vehicle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of wheels on this vehicle. + */ unsigned int PhysxVehicle:: get_num_wheels() const { @@ -91,11 +80,9 @@ get_num_wheels() const { return _wheels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicle::get_wheel -// Access: Published -// Description: Returns the n-th wheel of this vehicle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the n-th wheel of this vehicle. + */ PhysxWheel *PhysxVehicle:: get_wheel(unsigned int idx) const { @@ -103,4 +90,3 @@ get_wheel(unsigned int idx) const { return _wheels[idx]; } */ - diff --git a/panda/src/physx/physxVehicle.h b/panda/src/physx/physxVehicle.h index 160f94660f..62f86a9de0 100644 --- a/panda/src/physx/physxVehicle.h +++ b/panda/src/physx/physxVehicle.h @@ -1,16 +1,15 @@ -// Filename: physxVehicle.h -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicle.h + * @author enn0x + * @date 2010-03-23 + */ #ifndef PHYSXVEHICLE_H #define PHYSXVEHICLE_H @@ -26,28 +25,25 @@ class PhysxWheel; class PhysxVehicleDesc; class PhysxScene; -//////////////////////////////////////////////////////////////////// -// Class : PhysxVehicle -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxVehicle : public PhysxObject { PUBLISHED: INLINE PhysxVehicle(); INLINE ~PhysxVehicle(); - //PhysxActor *get_actor() const; + // PhysxActor *get_actor() const; - //unsigned int get_num_wheels() const; - //PhysxWheel *get_wheel(unsigned int idx) const; - //MAKE_SEQ(get_wheels, get_num_wheels, get_wheel); + // unsigned int get_num_wheels() const; PhysxWheel *get_wheel(unsigned int + // idx) const; MAKE_SEQ(get_wheels, get_num_wheels, get_wheel); INLINE void ls() const; INLINE void ls(ostream &out, int indent_level=0) const; private: -//////////////////////////////////////////////////////////////////// PUBLISHED: void release(); @@ -60,14 +56,13 @@ private: PT(PhysxActor) _actor; PT(PhysxScene) _scene; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxVehicle", + register_type(_type_handle, "PhysxVehicle", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxVehicleDesc.I b/panda/src/physx/physxVehicleDesc.I index 3e798b3984..81bba8329f 100644 --- a/panda/src/physx/physxVehicleDesc.I +++ b/panda/src/physx/physxVehicleDesc.I @@ -1,58 +1,47 @@ -// Filename: physxVehicleDesc.I -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicleDesc.I + * @author enn0x + * @date 2010-03-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicleDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxVehicleDesc:: PhysxVehicleDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicleDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxVehicleDesc:: ~PhysxVehicleDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicleDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxVehicleDesc:: set_to_default() { // TODO } -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicleDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxVehicleDesc:: is_valid() const { return true; } - diff --git a/panda/src/physx/physxVehicleDesc.cxx b/panda/src/physx/physxVehicleDesc.cxx index cbe88a6da6..e74d031e58 100644 --- a/panda/src/physx/physxVehicleDesc.cxx +++ b/panda/src/physx/physxVehicleDesc.cxx @@ -1,29 +1,25 @@ -// Filename: physxVehicleDesc.cxx -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicleDesc.cxx + * @author enn0x + * @date 2010-03-23 + */ #include "physxVehicleDesc.h" /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxVehicleDesc::add_wheel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxVehicleDesc:: add_wheel(PhysxWheelDesc *wheelDesc) { _wheels.push_back(wheelDesc); } */ - diff --git a/panda/src/physx/physxVehicleDesc.h b/panda/src/physx/physxVehicleDesc.h index 92fa67bb07..cbb38f28b2 100644 --- a/panda/src/physx/physxVehicleDesc.h +++ b/panda/src/physx/physxVehicleDesc.h @@ -1,16 +1,15 @@ -// Filename: physxVehicleDesc.h -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxVehicleDesc.h + * @author enn0x + * @date 2010-03-23 + */ #ifndef PHYSXVEHICLEDESC_H #define PHYSXVEHICLEDESC_H @@ -19,10 +18,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxVehicleDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxVehicleDesc : public ReferenceCount { PUBLISHED: diff --git a/panda/src/physx/physxWheel.I b/panda/src/physx/physxWheel.I index 6656f998b9..71b43426fd 100644 --- a/panda/src/physx/physxWheel.I +++ b/panda/src/physx/physxWheel.I @@ -1,59 +1,47 @@ -// Filename: physxWheel.I -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheel.I + * @author enn0x + * @date 2010-03-23 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheel:: PhysxWheel() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheel:: ~PhysxWheel() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxWheel:: ls() const { ls(nout); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::ls -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PhysxWheel:: ls(ostream &out, int indent_level) const { indent(out, indent_level) << get_type().get_name() << " (at 0x" << this << ")\n"; } - diff --git a/panda/src/physx/physxWheel.cxx b/panda/src/physx/physxWheel.cxx index d69ae091c1..897c4b54cf 100644 --- a/panda/src/physx/physxWheel.cxx +++ b/panda/src/physx/physxWheel.cxx @@ -1,16 +1,15 @@ -// Filename: physxWheel.cxx -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheel.cxx + * @author enn0x + * @date 2010-03-23 + */ #include "physxWheel.h" #include "physxWheelDesc.h" @@ -19,11 +18,9 @@ TypeHandle PhysxWheel::_type_handle; /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::get_wheel_shape -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxWheelShape *PhysxWheel:: get_wheel_shape() const { @@ -32,16 +29,13 @@ get_wheel_shape() const { */ /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::attach_node_path -// Access: Published -// Description: Attaches a node path to this wheel. The node -// path's transform will be updated automatically. -// -// Note: any non-uniform scale or shear set on the -// NodePath's transform will be overwritten at the -// time of the first update. -//////////////////////////////////////////////////////////////////// +/** + * Attaches a node path to this wheel. The node path's transform will be + * updated automatically. + * + * Note: any non-uniform scale or shear set on the NodePath's transform will + * be overwritten at the time of the first update. + */ void PhysxWheel:: attach_node_path(const NodePath &np) { @@ -50,13 +44,10 @@ attach_node_path(const NodePath &np) { _np = NodePath(np); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::detach_node_path -// Access: Published -// Description: Detaches a previously assigned NodePath from this -// wheel. The NodePath's transform will no longer -// be updated. -//////////////////////////////////////////////////////////////////// +/** + * Detaches a previously assigned NodePath from this wheel. The NodePath's + * transform will no longer be updated. + */ void PhysxWheel:: detach_node_path() { @@ -64,13 +55,10 @@ detach_node_path() { _np = NodePath(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheel::get_node_path -// Access: Published -// Description: Retrieves a previously attached NodePath. An empty -// NodePath will be returned if no NodePath has been -// attached to this wheel. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves a previously attached NodePath. An empty NodePath will be + * returned if no NodePath has been attached to this wheel. + */ NodePath PhysxWheel:: get_node_path() const { @@ -78,4 +66,3 @@ get_node_path() const { return _np; } */ - diff --git a/panda/src/physx/physxWheel.h b/panda/src/physx/physxWheel.h index 0a2cfc6415..25bc92e241 100644 --- a/panda/src/physx/physxWheel.h +++ b/panda/src/physx/physxWheel.h @@ -1,16 +1,15 @@ -// Filename: physxWheel.h -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheel.h + * @author enn0x + * @date 2010-03-23 + */ #ifndef PHYSXWHEEL_H #define PHYSXWHEEL_H @@ -24,22 +23,20 @@ class PhysxWheelDesc; class PhysxWheelShape; -//////////////////////////////////////////////////////////////////// -// Class : PhysxWheel -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxWheel : public PhysxObject { PUBLISHED: INLINE PhysxWheel(); INLINE ~PhysxWheel(); - //PhysxActor *get_touched_actor() const; - //PhysxWheelShape *get_wheel_shape() const; + // PhysxActor *get_touched_actor() const; PhysxWheelShape *get_wheel_shape() + // const; - //void attach_node_path(const NodePath &np); - //void detach_node_path(); - //NodePath get_node_path() const; + // void attach_node_path(const NodePath &np); void detach_node_path(); + // NodePath get_node_path() const; INLINE void ls() const; INLINE void ls(ostream &out, int indent_level=0) const; @@ -50,14 +47,13 @@ private: PT(PhysxWheelShape) _wheelShape; NodePath _np; -//////////////////////////////////////////////////////////////////// public: static TypeHandle get_class_type() { return _type_handle; } static void init_type() { PhysxObject::init_type(); - register_type(_type_handle, "PhysxWheel", + register_type(_type_handle, "PhysxWheel", PhysxObject::get_class_type()); } virtual TypeHandle get_type() const { diff --git a/panda/src/physx/physxWheelDesc.I b/panda/src/physx/physxWheelDesc.I index 8027d50aab..e806d24dc3 100644 --- a/panda/src/physx/physxWheelDesc.I +++ b/panda/src/physx/physxWheelDesc.I @@ -1,55 +1,45 @@ -// Filename: physxWheelDesc.I -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelDesc.I + * @author enn0x + * @date 2010-03-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelDesc:: PhysxWheelDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelDesc:: ~PhysxWheelDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ INLINE void PhysxWheelDesc:: set_to_default() { // TODO } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxWheelDesc:: is_valid() const { @@ -57,4 +47,3 @@ is_valid() const { return true; } - diff --git a/panda/src/physx/physxWheelDesc.cxx b/panda/src/physx/physxWheelDesc.cxx index 3bcfabff5a..6eac9897ba 100644 --- a/panda/src/physx/physxWheelDesc.cxx +++ b/panda/src/physx/physxWheelDesc.cxx @@ -1,29 +1,25 @@ -// Filename: physxWheelDesc.cxx -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelDesc.cxx + * @author enn0x + * @date 2010-03-23 + */ #include "physxWheelDesc.h" /* -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelDesc::set_wheel_radius -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxWheelDesc:: set_wheel_radius(float wheelRadius) { _wheelRadius = wheelRadius; } */ - diff --git a/panda/src/physx/physxWheelDesc.h b/panda/src/physx/physxWheelDesc.h index e059d5f004..56239edf9c 100644 --- a/panda/src/physx/physxWheelDesc.h +++ b/panda/src/physx/physxWheelDesc.h @@ -1,16 +1,15 @@ -// Filename: physxWheelDesc.h -// Created by: enn0x (23Mar10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelDesc.h + * @author enn0x + * @date 2010-03-23 + */ #ifndef PHYSXWHEELDESC_H #define PHYSXWHEELDESC_H @@ -20,10 +19,9 @@ #include "physx_includes.h" -//////////////////////////////////////////////////////////////////// -// Class : PhysxWheelDesc -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_PANDAPHYSX PhysxWheelDesc : public ReferenceCount { PUBLISHED: diff --git a/panda/src/physx/physxWheelShape.I b/panda/src/physx/physxWheelShape.I index a8f0c6bfe1..dfe32fd410 100644 --- a/panda/src/physx/physxWheelShape.I +++ b/panda/src/physx/physxWheelShape.I @@ -1,36 +1,28 @@ -// Filename: physxWheelShape.I -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShape.I + * @author enn0x + * @date 2009-11-09 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelShape:: PhysxWheelShape() : PhysxShape() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelShape:: ~PhysxWheelShape() { } - diff --git a/panda/src/physx/physxWheelShape.cxx b/panda/src/physx/physxWheelShape.cxx index 20fb355002..de34bf760c 100644 --- a/panda/src/physx/physxWheelShape.cxx +++ b/panda/src/physx/physxWheelShape.cxx @@ -1,16 +1,15 @@ -// Filename: physxWheelShape.cxx -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShape.cxx + * @author enn0x + * @date 2009-11-09 + */ #include "physxWheelShape.h" #include "physxWheelShapeDesc.h" @@ -18,11 +17,9 @@ TypeHandle PhysxWheelShape::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::link -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxWheelShape:: link(NxShape *shapePtr) { @@ -36,11 +33,9 @@ link(NxShape *shapePtr) { actor->_shapes.add(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::unlink -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PhysxWheelShape:: unlink() { @@ -51,12 +46,9 @@ unlink() { actor->_shapes.remove(this); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::save_to_desc -// Access: Published -// Description: Saves the state of the shape object to a -// descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Saves the state of the shape object to a descriptor. + */ void PhysxWheelShape:: save_to_desc(PhysxWheelShapeDesc &shapeDesc) const { @@ -64,11 +56,9 @@ save_to_desc(PhysxWheelShapeDesc &shapeDesc) const { _ptr->saveToDesc(shapeDesc._desc); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_radius -// Access: Published -// Description: Sets the sphere radius. -//////////////////////////////////////////////////////////////////// +/** + * Sets the sphere radius. + */ void PhysxWheelShape:: set_radius(float radius) { @@ -76,11 +66,9 @@ set_radius(float radius) { _ptr->setRadius(radius); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_radius -// Access: Published -// Description: Returns the radius of the sphere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the radius of the sphere. + */ float PhysxWheelShape:: get_radius() const { @@ -88,13 +76,10 @@ get_radius() const { return _ptr->getRadius(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_suspension_travel -// Access: Published -// Description: Set the maximum extension distance of suspension -// along shape's -Y axis. The minimum extension is -// always 0. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum extension distance of suspension along shape's -Y axis. + * The minimum extension is always 0. + */ void PhysxWheelShape:: set_suspension_travel(float travel) { @@ -102,11 +87,9 @@ set_suspension_travel(float travel) { _ptr->setSuspensionTravel(travel); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_suspension_travel -// Access: Published -// Description: Returns the suspension travel -//////////////////////////////////////////////////////////////////// +/** + * Returns the suspension travel + */ float PhysxWheelShape:: get_suspension_travel() const { @@ -114,12 +97,10 @@ get_suspension_travel() const { return _ptr->getSuspensionTravel(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_inverse_wheel_mass -// Access: Published -// Description: Set the inverse mass of the wheel. Determines the -// wheel velocity that wheel torques can achieve. -//////////////////////////////////////////////////////////////////// +/** + * Set the inverse mass of the wheel. Determines the wheel velocity that + * wheel torques can achieve. + */ void PhysxWheelShape:: set_inverse_wheel_mass(float invMass) { @@ -127,12 +108,10 @@ set_inverse_wheel_mass(float invMass) { _ptr->setInverseWheelMass(invMass); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_inverse_wheel_mass -// Access: Published -// Description: Returns the inverse mass of the wheel. Determines -// the wheel velocity that wheel torques can achieve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse mass of the wheel. Determines the wheel velocity that + * wheel torques can achieve. + */ float PhysxWheelShape:: get_inverse_wheel_mass() const { @@ -140,12 +119,10 @@ get_inverse_wheel_mass() const { return _ptr->getInverseWheelMass(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_motor_torque -// Access: Published -// Description: Set the sum engine torque on the wheel axle. -// Positive or negative depending on direction -//////////////////////////////////////////////////////////////////// +/** + * Set the sum engine torque on the wheel axle. Positive or negative + * depending on direction + */ void PhysxWheelShape:: set_motor_torque(float torque) { @@ -153,12 +130,10 @@ set_motor_torque(float torque) { _ptr->setMotorTorque(torque); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_motor_torque -// Access: Published -// Description: Retrieves the sum engine torque on the wheel axle. -// Positive or negative depending on direction -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the sum engine torque on the wheel axle. Positive or negative + * depending on direction + */ float PhysxWheelShape:: get_motor_torque() const { @@ -166,12 +141,10 @@ get_motor_torque() const { return _ptr->getMotorTorque(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_brake_torque -// Access: Published -// Description: Must be nonnegative. Very large values should lock -// wheel but should be stable. -//////////////////////////////////////////////////////////////////// +/** + * Must be nonnegative. Very large values should lock wheel but should be + * stable. + */ void PhysxWheelShape:: set_brake_torque(float torque) { @@ -179,12 +152,10 @@ set_brake_torque(float torque) { _ptr->setBrakeTorque(torque); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_brake_torque -// Access: Published -// Description: Must be nonnegative. Very large values should lock -// wheel but should be stable. -//////////////////////////////////////////////////////////////////// +/** + * Must be nonnegative. Very large values should lock wheel but should be + * stable. + */ float PhysxWheelShape:: get_brake_torque() const { @@ -192,12 +163,10 @@ get_brake_torque() const { return _ptr->getBrakeTorque(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_steer_angle -// Access: Published -// Description: Set the steering angle, around shape Y axis. -// The steering angle is measured in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Set the steering angle, around shape Y axis. The steering angle is + * measured in degrees. + */ void PhysxWheelShape:: set_steer_angle(float angle) { @@ -205,12 +174,10 @@ set_steer_angle(float angle) { _ptr->setSteerAngle(NxMath::degToRad(-1.0f * angle)); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_steer_angle -// Access: Published -// Description: Retrieves the steering angle, around shape Y axis. -// The steering angle is measured in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the steering angle, around shape Y axis. The steering angle is + * measured in degrees. + */ float PhysxWheelShape:: get_steer_angle() const { @@ -218,12 +185,10 @@ get_steer_angle() const { return -1.0f * NxMath::radToDeg(_ptr->getSteerAngle()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_steer_angle_rad -// Access: Published -// Description: Set the steering angle, around shape Y axis. -// The steering angle is measured in radians. -//////////////////////////////////////////////////////////////////// +/** + * Set the steering angle, around shape Y axis. The steering angle is + * measured in radians. + */ void PhysxWheelShape:: set_steer_angle_rad(float angle) { @@ -231,12 +196,10 @@ set_steer_angle_rad(float angle) { _ptr->setSteerAngle(-1.0f * angle); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_steer_angle_rad -// Access: Published -// Description: Retrieves the steering angle, around shape Y axis. -// The steering angle is measured in radians. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the steering angle, around shape Y axis. The steering angle is + * measured in radians. + */ float PhysxWheelShape:: get_steer_angle_rad() const { @@ -244,13 +207,10 @@ get_steer_angle_rad() const { return -1.0f * _ptr->getSteerAngle(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_axle_speed -// Access: Published -// Description: Set the current axle rotation speed. -// Note: WSF_axle_speed_override flag must be raised -// for this to have effect! -//////////////////////////////////////////////////////////////////// +/** + * Set the current axle rotation speed. Note: WSF_axle_speed_override flag + * must be raised for this to have effect! + */ void PhysxWheelShape:: set_axle_speed(float speed) { @@ -258,11 +218,9 @@ set_axle_speed(float speed) { _ptr->setAxleSpeed(speed); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_axle_speed -// Access: Published -// Description: Retrieves the current axle rotation speed. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the current axle rotation speed. + */ float PhysxWheelShape:: get_axle_speed() const { @@ -270,11 +228,9 @@ get_axle_speed() const { return _ptr->getAxleSpeed(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_wheel_flag -// Access: Published -// Description: Turns the specified wheel shape flag on or off. -//////////////////////////////////////////////////////////////////// +/** + * Turns the specified wheel shape flag on or off. + */ void PhysxWheelShape:: set_wheel_flag(PhysxWheelShapeFlag flag, bool value) { @@ -290,12 +246,9 @@ set_wheel_flag(PhysxWheelShapeFlag flag, bool value) { _ptr->setWheelFlags(flags); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::get_wheel_flag -// Access: Published -// Description: Returns the value of the specified wheel shape -// flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the specified wheel shape flag. + */ bool PhysxWheelShape:: get_wheel_flag(PhysxWheelShapeFlag flag) const { @@ -303,16 +256,12 @@ get_wheel_flag(PhysxWheelShapeFlag flag) const { return (_ptr->getWheelFlags() & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShape::set_suspension -// Access: Published -// Description: Set the data intended for car wheel suspension -// effects. -//////////////////////////////////////////////////////////////////// +/** + * Set the data intended for car wheel suspension effects. + */ void PhysxWheelShape:: set_suspension(const PhysxSpringDesc &spring) { nassertv(_error_type == ET_ok); return _ptr->setSuspension(spring._desc); } - diff --git a/panda/src/physx/physxWheelShape.h b/panda/src/physx/physxWheelShape.h index ea875fb8f9..7b4a1ee7bd 100644 --- a/panda/src/physx/physxWheelShape.h +++ b/panda/src/physx/physxWheelShape.h @@ -1,16 +1,15 @@ -// Filename: physxWheelShape.h -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShape.h + * @author enn0x + * @date 2009-11-09 + */ #ifndef PHYSXWHEELSHAPE_H #define PHYSXWHEELSHAPE_H @@ -23,49 +22,37 @@ class PhysxWheelShapeDesc; class PhysxSpringDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxWheelShape -// Description : A special shape used for simulating a car wheel. -// The -Y axis should be directed toward the ground. -// -// A ray is cast from the shape's origin along the -Y -// axis. When the ray strikes something, and the -// distance is: -// -// - less than wheelRadius from the shape origin: -// a hard contact is created -// - between wheelRadius and (suspensionTravel + -// wheelRadius): a soft suspension contact is -// created -// - greater than (suspensionTravel + wheelRadius): -// no contact is created. -// -// Thus at the point of greatest possible suspension -// compression the wheel axle will pass through at -// the shape's origin. At the point greatest -// suspension extension the wheel axle will be a -// distance of suspensionTravel from the shape's -// origin. -// -// The suspension's targetValue is 0 for real cars, -// which means that the suspension tries to extend -// all the way. Otherwise one can specify values -// [0,1] for suspensions which have a spring to -// pull the wheel up when it is extended too far. -// 0.5 will then fall halfway along suspensionTravel. -// -// The +Z axis is the 'forward' direction of travel -// for the wheel. -Z is backwards. The wheel rolls -// forward when rotating around the positive direction -// around the X axis. -// -// A positive wheel steering angle corresponds to a -// positive rotation around the shape's Y axis. -// (Castor angles are not modeled.) -// -// The coordinate frame of the shape is rigidly fixed -// on the car. -//////////////////////////////////////////////////////////////////// +/** + * A special shape used for simulating a car wheel. The -Y axis should be + * directed toward the ground. + * + * A ray is cast from the shape's origin along the -Y axis. When the ray + * strikes something, and the distance is: + * + * - less than wheelRadius from the shape origin: a hard contact is created - + * between wheelRadius and (suspensionTravel + wheelRadius): a soft suspension + * contact is created - greater than (suspensionTravel + wheelRadius): no + * contact is created. + * + * Thus at the point of greatest possible suspension compression the wheel + * axle will pass through at the shape's origin. At the point greatest + * suspension extension the wheel axle will be a distance of suspensionTravel + * from the shape's origin. + * + * The suspension's targetValue is 0 for real cars, which means that the + * suspension tries to extend all the way. Otherwise one can specify values + * [0,1] for suspensions which have a spring to pull the wheel up when it is + * extended too far. 0.5 will then fall halfway along suspensionTravel. + * + * The +Z axis is the 'forward' direction of travel for the wheel. -Z is + * backwards. The wheel rolls forward when rotating around the positive + * direction around the X axis. + * + * A positive wheel steering angle corresponds to a positive rotation around + * the shape's Y axis. (Castor angles are not modeled.) + * + * The coordinate frame of the shape is rigidly fixed on the car. + */ class EXPCL_PANDAPHYSX PhysxWheelShape : public PhysxShape { PUBLISHED: INLINE PhysxWheelShape(); diff --git a/panda/src/physx/physxWheelShapeDesc.I b/panda/src/physx/physxWheelShapeDesc.I index e14ebd8615..4a40eb24cf 100644 --- a/panda/src/physx/physxWheelShapeDesc.I +++ b/panda/src/physx/physxWheelShapeDesc.I @@ -1,48 +1,38 @@ -// Filename: physxWheelShapeDesc.I -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShapeDesc.I + * @author enn0x + * @date 2009-11-09 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelShapeDesc:: PhysxWheelShapeDesc() : PhysxShapeDesc() { set_to_default(); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PhysxWheelShapeDesc:: ~PhysxWheelShapeDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::is_valid -// Access: Published -// Description: Returns true if the descriptor is valid. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the descriptor is valid. + */ INLINE bool PhysxWheelShapeDesc:: is_valid() const { return _desc.isValid(); } - diff --git a/panda/src/physx/physxWheelShapeDesc.cxx b/panda/src/physx/physxWheelShapeDesc.cxx index 776fd1e32b..2a3791ba77 100644 --- a/panda/src/physx/physxWheelShapeDesc.cxx +++ b/panda/src/physx/physxWheelShapeDesc.cxx @@ -1,24 +1,21 @@ -// Filename: physxWheelShapeDesc.cxx -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShapeDesc.cxx + * @author enn0x + * @date 2009-11-09 + */ #include "physxWheelShapeDesc.h" -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_to_default -// Access: Published -// Description: (re)sets the structure to the default. -//////////////////////////////////////////////////////////////////// +/** + * (re)sets the structure to the default. + */ void PhysxWheelShapeDesc:: set_to_default() { @@ -28,184 +25,150 @@ set_to_default() { _desc.localPose = PhysxManager::mat4_to_nxMat34(LMatrix4f::y_to_z_up_mat()); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_radius -// Access: Published -// Description: Radius of shape. Must be positive. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. Must be positive. + */ void PhysxWheelShapeDesc:: set_radius(float radius) { _desc.radius = radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_radius -// Access: Published -// Description: Radius of shape. -//////////////////////////////////////////////////////////////////// +/** + * Radius of shape. + */ float PhysxWheelShapeDesc:: get_radius() const { return _desc.radius; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_suspension_travel -// Access: Published -// Description: Set the maximum extension distance of suspension -// along shape's -Y axis. -//////////////////////////////////////////////////////////////////// +/** + * Set the maximum extension distance of suspension along shape's -Y axis. + */ void PhysxWheelShapeDesc:: set_suspension_travel(float suspensionTravel) { _desc.suspensionTravel = suspensionTravel; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_suspension_travel -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxWheelShapeDesc:: get_suspension_travel() const { return _desc.suspensionTravel; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_inverse_wheel_mass -// Access: Published -// Description: Set the inverse mass of the wheel. -//////////////////////////////////////////////////////////////////// +/** + * Set the inverse mass of the wheel. + */ void PhysxWheelShapeDesc:: set_inverse_wheel_mass(float inverseWheelMass) { _desc.inverseWheelMass = inverseWheelMass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_inverse_wheel_mass -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxWheelShapeDesc:: get_inverse_wheel_mass() const { return _desc.inverseWheelMass; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_motor_torque -// Access: Published -// Description: Set the sum engine torque on the wheel axle. -//////////////////////////////////////////////////////////////////// +/** + * Set the sum engine torque on the wheel axle. + */ void PhysxWheelShapeDesc:: set_motor_torque(float motorTorque) { _desc.motorTorque = motorTorque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_motor_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxWheelShapeDesc:: get_motor_torque() const { return _desc.motorTorque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_brake_torque -// Access: Published -// Description: Set the amount of torque applied for braking. -//////////////////////////////////////////////////////////////////// +/** + * Set the amount of torque applied for braking. + */ void PhysxWheelShapeDesc:: set_brake_torque(float brakeTorque) { _desc.brakeTorque = brakeTorque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_brake_torque -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxWheelShapeDesc:: get_brake_torque() const { return _desc.brakeTorque; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_steer_angle -// Access: Published -// Description: Set the steering angle, around shape Y axis. -// The steering angle is measured in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Set the steering angle, around shape Y axis. The steering angle is + * measured in degrees. + */ void PhysxWheelShapeDesc:: set_steer_angle(float steerAngle) { _desc.steerAngle = NxMath::degToRad(steerAngle); } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_steer_angle -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ float PhysxWheelShapeDesc:: get_steer_angle() const { return _desc.steerAngle; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_wheel_flag -// Access: Published -// Description: Turn the specified wheel shape flag on or off. -//////////////////////////////////////////////////////////////////// +/** + * Turn the specified wheel shape flag on or off. + */ void PhysxWheelShapeDesc:: set_wheel_flag(PhysxWheelShapeFlag flag, bool value) { if (value == true) { _desc.wheelFlags |= flag; - } + } else { _desc.wheelFlags &= ~(flag); } } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_wheel_flag -// Access: Published -// Description: Returns the specified wheel shape flag. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specified wheel shape flag. + */ bool PhysxWheelShapeDesc:: get_wheel_flag(const PhysxWheelShapeFlag flag) const { return (_desc.wheelFlags & flag) ? true : false; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::set_suspension -// Access: Published -// Description: Set the data intended for car wheel suspension -// effects. -//////////////////////////////////////////////////////////////////// +/** + * Set the data intended for car wheel suspension effects. + */ void PhysxWheelShapeDesc:: set_suspension(const PhysxSpringDesc &spring) { _desc.suspension = spring._desc; } -//////////////////////////////////////////////////////////////////// -// Function: PhysxWheelShapeDesc::get_suspension -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PhysxSpringDesc PhysxWheelShapeDesc:: get_suspension() const { @@ -213,4 +176,3 @@ get_suspension() const { value._desc = _desc.suspension; return value; } - diff --git a/panda/src/physx/physxWheelShapeDesc.h b/panda/src/physx/physxWheelShapeDesc.h index 679f13afda..85dcf96d62 100644 --- a/panda/src/physx/physxWheelShapeDesc.h +++ b/panda/src/physx/physxWheelShapeDesc.h @@ -1,16 +1,15 @@ -// Filename: physxWheelShapeDesc.h -// Created by: enn0x (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physxWheelShapeDesc.h + * @author enn0x + * @date 2009-11-09 + */ #ifndef PHYSXWHEELSHAPEDESC_H #define PHYSXWHEELSHAPEDESC_H @@ -22,10 +21,9 @@ class PhysxSpringDesc; -//////////////////////////////////////////////////////////////////// -// Class : PhysxWheelShapeDesc -// Description : Descriptor class for PhysxWheelShape. -//////////////////////////////////////////////////////////////////// +/** + * Descriptor class for PhysxWheelShape. + */ class EXPCL_PANDAPHYSX PhysxWheelShapeDesc : public PhysxShapeDesc { PUBLISHED: diff --git a/panda/src/physx/physx_includes.h b/panda/src/physx/physx_includes.h index fceeb7fbe7..b4dac0da9a 100644 --- a/panda/src/physx/physx_includes.h +++ b/panda/src/physx/physx_includes.h @@ -1,16 +1,15 @@ -// Filename: physx_includes.h -// Created by: joswilso (30Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file physx_includes.h + * @author joswilso + * @date 2007-01-30 + */ #ifndef PHYSX_INCLUDES_H #define PHYSX_INCLUDES_H diff --git a/panda/src/pipeline/asyncTaskBase.I b/panda/src/pipeline/asyncTaskBase.I index 9541e75f56..09abcb3a3d 100644 --- a/panda/src/pipeline/asyncTaskBase.I +++ b/panda/src/pipeline/asyncTaskBase.I @@ -1,14 +1,12 @@ -// Filename: asyncTaskBase.I -// Created by: drose (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskBase.I + * @author drose + * @date 2010-02-09 + */ diff --git a/panda/src/pipeline/asyncTaskBase.cxx b/panda/src/pipeline/asyncTaskBase.cxx index 529da4cfa7..4d91d83764 100644 --- a/panda/src/pipeline/asyncTaskBase.cxx +++ b/panda/src/pipeline/asyncTaskBase.cxx @@ -1,16 +1,15 @@ -// Filename: asyncTaskBase.cxx -// Created by: drose (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskBase.cxx + * @author drose + * @date 2010-02-09 + */ #include "asyncTaskBase.h" #include "thread.h" @@ -18,31 +17,24 @@ TypeHandle AsyncTaskBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskBase:: AsyncTaskBase() { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskBase::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AsyncTaskBase:: ~AsyncTaskBase() { } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskBase::record_task -// Access: Protected -// Description: Indicates that this task is now the current task -// running on the indicated thread, presumably the -// current thread. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this task is now the current task running on the indicated + * thread, presumably the current thread. + */ void AsyncTaskBase:: record_task(Thread *current_thread) { nassertv(current_thread->_current_task == NULL); @@ -51,9 +43,8 @@ record_task(Thread *current_thread) { ((void * TVOLATILE &)current_thread->_current_task, (void *)NULL, (void *)this); - // If the return value is other than NULL, someone else must have - // assigned the task first, in another thread. That shouldn't be - // possible. + // If the return value is other than NULL, someone else must have assigned + // the task first, in another thread. That shouldn't be possible. // But different versions of gcc appear to have problems compiling these // assertions correctly. @@ -63,12 +54,9 @@ record_task(Thread *current_thread) { #endif // __GNUC__ } -//////////////////////////////////////////////////////////////////// -// Function: AsyncTaskBase::clear_task -// Access: Protected -// Description: Indicates that this task is no longer running on the -// indicated thread. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this task is no longer running on the indicated thread. + */ void AsyncTaskBase:: clear_task(Thread *current_thread) { nassertv(current_thread->_current_task == this); @@ -77,9 +65,8 @@ clear_task(Thread *current_thread) { ((void * TVOLATILE &)current_thread->_current_task, (void *)this, (void *)NULL); - // If the return value is other than this, someone else must have - // assigned the task first, in another thread. That shouldn't be - // possible. + // If the return value is other than this, someone else must have assigned + // the task first, in another thread. That shouldn't be possible. // But different versions of gcc appear to have problems compiling these // assertions correctly. diff --git a/panda/src/pipeline/asyncTaskBase.h b/panda/src/pipeline/asyncTaskBase.h index cda86b29e3..cdf3884b87 100644 --- a/panda/src/pipeline/asyncTaskBase.h +++ b/panda/src/pipeline/asyncTaskBase.h @@ -1,16 +1,15 @@ -// Filename: asyncTaskBase.h -// Created by: drose (09Feb10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file asyncTaskBase.h + * @author drose + * @date 2010-02-09 + */ #ifndef ASYNCTASKBASE_H #define ASYNCTASKBASE_H @@ -22,12 +21,10 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : AsyncTaskBase -// Description : The abstract base class for AsyncTask. This is -// defined here only so we can store a pointer to the -// current task on the Thread. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for AsyncTask. This is defined here only so we can + * store a pointer to the current task on the Thread. + */ class EXPCL_PANDA_PIPELINE AsyncTaskBase : public TypedReferenceCount, public Namable { protected: AsyncTaskBase(); @@ -40,7 +37,7 @@ PUBLISHED: protected: void record_task(Thread *current_thread); void clear_task(Thread *current_thread); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/pipeline/blockerSimple.I b/panda/src/pipeline/blockerSimple.I index 66370753d8..0188281728 100644 --- a/panda/src/pipeline/blockerSimple.I +++ b/panda/src/pipeline/blockerSimple.I @@ -1,33 +1,27 @@ -// Filename: blockerSimple.I -// Created by: drose (20Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file blockerSimple.I + * @author drose + * @date 2007-06-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BlockerSimple::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BlockerSimple:: BlockerSimple() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BlockerSimple::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BlockerSimple:: ~BlockerSimple() { nassertv(_flags == 0); diff --git a/panda/src/pipeline/blockerSimple.h b/panda/src/pipeline/blockerSimple.h index 4684c4ca6b..71ae25c41d 100644 --- a/panda/src/pipeline/blockerSimple.h +++ b/panda/src/pipeline/blockerSimple.h @@ -1,16 +1,15 @@ -// Filename: blockerSimple.h -// Created by: drose (20Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file blockerSimple.h + * @author drose + * @date 2007-06-20 + */ #ifndef BLOCKERSIMPLE_H #define BLOCKERSIMPLE_H @@ -22,13 +21,11 @@ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : BlockerSimple -// Description : This is a base class for MutexSimpleImpl and -// ConditionVarSimpleImpl. It represents a -// synchronization primitive that one or more threads -// might be blocked on. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for MutexSimpleImpl and ConditionVarSimpleImpl. It + * represents a synchronization primitive that one or more threads might be + * blocked on. + */ class EXPCL_PANDA_PIPELINE BlockerSimple { protected: INLINE BlockerSimple(); diff --git a/panda/src/pipeline/conditionVar.I b/panda/src/pipeline/conditionVar.I index cc50f2d091..d797ab2390 100644 --- a/panda/src/pipeline/conditionVar.I +++ b/panda/src/pipeline/conditionVar.I @@ -1,96 +1,78 @@ -// Filename: conditionVar.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVar.I + * @author drose + * @date 2002-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::Constructor -// Access: Published -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ INLINE ConditionVar:: ConditionVar(Mutex &mutex) : #ifdef DEBUG_THREADS ConditionVarDebug(mutex) -#else +#else ConditionVarDirect(mutex) #endif // DEBUG_THREADS { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVar:: ~ConditionVar() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVar:: -ConditionVar(const ConditionVar ©) : +ConditionVar(const ConditionVar ©) : #ifdef DEBUG_THREADS ConditionVarDebug(copy.get_mutex()) -#else +#else ConditionVarDirect(copy.get_mutex()) #endif // DEBUG_THREADS { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVar:: operator = (const ConditionVar ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::notify_all -// Access: Private -// Description: The notify_all() method is specifically *not* -// provided by ConditionVar. Use ConditionVarFull if -// you need to call this method. -//////////////////////////////////////////////////////////////////// +/** + * The notify_all() method is specifically *not* provided by ConditionVar. + * Use ConditionVarFull if you need to call this method. + */ INLINE void ConditionVar:: notify_all() { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVar::get_mutex -// Access: Published -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE Mutex &ConditionVar:: get_mutex() const { #ifdef DEBUG_THREADS return (Mutex &)ConditionVarDebug::get_mutex(); -#else +#else return (Mutex &)ConditionVarDirect::get_mutex(); #endif // DEBUG_THREADS } diff --git a/panda/src/pipeline/conditionVar.cxx b/panda/src/pipeline/conditionVar.cxx index 9e510567ca..876c338924 100644 --- a/panda/src/pipeline/conditionVar.cxx +++ b/panda/src/pipeline/conditionVar.cxx @@ -1,15 +1,14 @@ -// Filename: conditionVar.cxx -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVar.cxx + * @author drose + * @date 2002-08-09 + */ #include "conditionVar.h" diff --git a/panda/src/pipeline/conditionVar.h b/panda/src/pipeline/conditionVar.h index 87774dfec3..ece37ba6f2 100644 --- a/panda/src/pipeline/conditionVar.h +++ b/panda/src/pipeline/conditionVar.h @@ -1,16 +1,15 @@ -// Filename: conditionVar.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVar.h + * @author drose + * @date 2002-08-09 + */ #ifndef CONDITIONVAR_H #define CONDITIONVAR_H @@ -19,28 +18,23 @@ #include "conditionVarDebug.h" #include "conditionVarDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : ConditionVar -// Description : A condition variable, usually used to communicate -// information about changing state to a thread that is -// waiting for something to happen. A condition -// variable can be used to "wake up" a thread when some -// arbitrary condition has changed. -// -// The ConditionVar class does not support the full -// semantics of POSIX condition variables. In -// particular, it does not support the broadcast or -// notify_all function. See ConditionVarFull for a more -// complete (but possibly more expensive) API. -// -// A condition variable is associated with a single -// mutex, and several condition variables may share the -// same mutex. -// -// This class inherits its implementation either from -// ConditionVarDebug or ConditionVarDirect, depending on -// the definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * A condition variable, usually used to communicate information about + * changing state to a thread that is waiting for something to happen. A + * condition variable can be used to "wake up" a thread when some arbitrary + * condition has changed. + * + * The ConditionVar class does not support the full semantics of POSIX + * condition variables. In particular, it does not support the broadcast or + * notify_all function. See ConditionVarFull for a more complete (but + * possibly more expensive) API. + * + * A condition variable is associated with a single mutex, and several + * condition variables may share the same mutex. + * + * This class inherits its implementation either from ConditionVarDebug or + * ConditionVarDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE ConditionVar : public ConditionVarDebug #else @@ -54,14 +48,12 @@ private: INLINE ConditionVar(const ConditionVar ©); INLINE void operator = (const ConditionVar ©); - // These methods are inherited from the base class. - // INLINE void wait(); + // These methods are inherited from the base class. INLINE void wait(); // INLINE void notify(); private: - // The notify_all() method is specifically *not* provided by - // ConditionVar. Use ConditionVarFull if you need to call this - // method. + // The notify_all() method is specifically *not* provided by ConditionVar. + // Use ConditionVarFull if you need to call this method. INLINE void notify_all(); PUBLISHED: diff --git a/panda/src/pipeline/conditionVarDebug.I b/panda/src/pipeline/conditionVarDebug.I index f360e805bc..6b16125a0e 100644 --- a/panda/src/pipeline/conditionVarDebug.I +++ b/panda/src/pipeline/conditionVarDebug.I @@ -1,47 +1,38 @@ -// Filename: conditionVarDebug.I -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDebug.I + * @author drose + * @date 2006-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVarDebug:: -ConditionVarDebug(const ConditionVarDebug ©) : - _mutex(copy._mutex), +ConditionVarDebug(const ConditionVarDebug ©) : + _mutex(copy._mutex), _impl(*_mutex._global_lock) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVarDebug:: operator = (const ConditionVarDebug ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::get_mutex -// Access: Published -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE MutexDebug &ConditionVarDebug:: get_mutex() const { return _mutex; diff --git a/panda/src/pipeline/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx index 158ec60547..d8c838196e 100644 --- a/panda/src/pipeline/conditionVarDebug.cxx +++ b/panda/src/pipeline/conditionVarDebug.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarDebug.cxx -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDebug.cxx + * @author drose + * @date 2006-02-13 + */ #include "conditionVarDebug.h" #include "thread.h" @@ -18,16 +17,12 @@ #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::Constructor -// Access: Public -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ ConditionVarDebug:: ConditionVarDebug(MutexDebug &mutex) : _mutex(mutex), @@ -36,40 +31,30 @@ ConditionVarDebug(MutexDebug &mutex) : nassertv(!_mutex._allow_recursion); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConditionVarDebug:: ~ConditionVarDebug() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::wait -// Access: Published -// Description: Waits on the condition. The caller must already be -// holding the lock associated with the condition -// variable before calling this function. -// -// wait() will release the lock, then go to sleep until -// some other thread calls notify() on this condition -// variable. At that time at least one thread waiting -// on the same ConditionVarDebug will grab the lock again, -// and then return from wait(). -// -// It is possible that wait() will return even if no one -// has called notify(). It is the responsibility of the -// calling process to verify the condition on return -// from wait, and possibly loop back to wait again if -// necessary. -// -// Note the semantics of a condition variable: the mutex -// must be held before wait() is called, and it will -// still be held when wait() returns. However, it will -// be temporarily released during the wait() call -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition. The caller must already be holding the lock + * associated with the condition variable before calling this function. + * + * wait() will release the lock, then go to sleep until some other thread + * calls notify() on this condition variable. At that time at least one + * thread waiting on the same ConditionVarDebug will grab the lock again, and + * then return from wait(). + * + * It is possible that wait() will return even if no one has called notify(). + * It is the responsibility of the calling process to verify the condition on + * return from wait, and possibly loop back to wait again if necessary. + * + * Note the semantics of a condition variable: the mutex must be held before + * wait() is called, and it will still be held when wait() returns. However, + * it will be temporarily released during the wait() call itself. + */ void ConditionVarDebug:: wait() { _mutex._global_lock->acquire(); @@ -94,7 +79,7 @@ wait() { current_thread->_waiting_on_cvar_full == NULL) { } current_thread->_waiting_on_cvar = this; - + _mutex.do_release(); _impl.wait(); // temporarily releases _global_lock _mutex.do_acquire(current_thread); @@ -111,17 +96,14 @@ wait() { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::wait -// Access: Published -// Description: Waits on the condition, with a timeout. The function -// will return when the condition variable is notified, -// or the timeout occurs. There is no way to directly -// tell which happened, and it is possible that neither -// in fact happened (spurious wakeups are possible). -// -// See wait() with no parameters for more. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition, with a timeout. The function will return when the + * condition variable is notified, or the timeout occurs. There is no way to + * directly tell which happened, and it is possible that neither in fact + * happened (spurious wakeups are possible). + * + * See wait() with no parameters for more. + */ void ConditionVarDebug:: wait(double timeout) { _mutex._global_lock->acquire(); @@ -139,7 +121,7 @@ wait(double timeout) { if (thread_cat.is_spam()) { thread_cat.spam() - << *current_thread << " waiting on " << *this + << *current_thread << " waiting on " << *this << ", with timeout " << timeout << "\n"; } @@ -147,7 +129,7 @@ wait(double timeout) { current_thread->_waiting_on_cvar_full == NULL) { } current_thread->_waiting_on_cvar = this; - + _mutex.do_release(); _impl.wait(timeout); // temporarily releases _global_lock _mutex.do_acquire(current_thread); @@ -164,23 +146,18 @@ wait(double timeout) { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::notify -// Access: Published -// Description: Informs one of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. If multiple threads are currently waiting, -// at least one of them will be woken up, although there -// is no way to predict which one. It is possible that -// more than one thread will be woken up. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify event is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs one of the other threads who are currently blocked on wait() that + * the relevant condition has changed. If multiple threads are currently + * waiting, at least one of them will be woken up, although there is no way to + * predict which one. It is possible that more than one thread will be woken + * up. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify event is lost. + */ void ConditionVarDebug:: notify() { _mutex._global_lock->acquire(); @@ -205,12 +182,10 @@ notify() { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDebug::output -// Access: Published, Virtual -// Description: This method is declared virtual in ConditionVarDebug, -// but non-virtual in ConditionVarDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in ConditionVarDebug, but non-virtual in + * ConditionVarDirect. + */ void ConditionVarDebug:: output(ostream &out) const { out << "ConditionVar " << (void *)this << " on " << _mutex; diff --git a/panda/src/pipeline/conditionVarDebug.h b/panda/src/pipeline/conditionVarDebug.h index 8a5294b015..45754ffdea 100644 --- a/panda/src/pipeline/conditionVarDebug.h +++ b/panda/src/pipeline/conditionVarDebug.h @@ -1,16 +1,15 @@ -// Filename: conditionVarDebug.h -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDebug.h + * @author drose + * @date 2006-02-13 + */ #ifndef CONDITIONVARDEBUG_H #define CONDITIONVARDEBUG_H @@ -21,18 +20,15 @@ #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarDebug -// Description : A condition variable, usually used to communicate -// information about changing state to a thread that is -// waiting for something to happen. A condition -// variable can be used to "wake up" a thread when some -// arbitrary condition has changed. -// -// A condition variable is associated with a single -// mutex, and several condition variables may share the -// same mutex. -//////////////////////////////////////////////////////////////////// +/** + * A condition variable, usually used to communicate information about + * changing state to a thread that is waiting for something to happen. A + * condition variable can be used to "wake up" a thread when some arbitrary + * condition has changed. + * + * A condition variable is associated with a single mutex, and several + * condition variables may share the same mutex. + */ class EXPCL_PANDA_PIPELINE ConditionVarDebug { public: ConditionVarDebug(MutexDebug &mutex); diff --git a/panda/src/pipeline/conditionVarDirect.I b/panda/src/pipeline/conditionVarDirect.I index 9634ff6118..6b9d0351bf 100644 --- a/panda/src/pipeline/conditionVarDirect.I +++ b/panda/src/pipeline/conditionVarDirect.I @@ -1,28 +1,22 @@ -// Filename: conditionVarDirect.I -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDirect.I + * @author drose + * @date 2006-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::Constructor -// Access: Public -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ INLINE ConditionVarDirect:: ConditionVarDirect(MutexDirect &mutex) : _mutex(mutex), @@ -30,114 +24,89 @@ ConditionVarDirect(MutexDirect &mutex) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarDirect:: ~ConditionVarDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVarDirect:: -ConditionVarDirect(const ConditionVarDirect ©) : - _mutex(copy._mutex), +ConditionVarDirect(const ConditionVarDirect ©) : + _mutex(copy._mutex), _impl(_mutex._impl) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVarDirect:: operator = (const ConditionVarDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::get_mutex -// Access: Public -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE MutexDirect &ConditionVarDirect:: get_mutex() const { return _mutex; } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::wait -// Access: Public -// Description: Waits on the condition. The caller must already be -// holding the lock associated with the condition -// variable before calling this function. -// -// wait() will release the lock, then go to sleep until -// some other thread calls notify() on this condition -// variable. At that time at least one thread waiting -// on the same ConditionVarDirect will grab the lock again, -// and then return from wait(). -// -// It is possible that wait() will return even if no one -// has called notify(). It is the responsibility of the -// calling process to verify the condition on return -// from wait, and possibly loop back to wait again if -// necessary. -// -// Note the semantics of a condition variable: the mutex -// must be held before wait() is called, and it will -// still be held when wait() returns. However, it will -// be temporarily released during the wait() call -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition. The caller must already be holding the lock + * associated with the condition variable before calling this function. + * + * wait() will release the lock, then go to sleep until some other thread + * calls notify() on this condition variable. At that time at least one + * thread waiting on the same ConditionVarDirect will grab the lock again, and + * then return from wait(). + * + * It is possible that wait() will return even if no one has called notify(). + * It is the responsibility of the calling process to verify the condition on + * return from wait, and possibly loop back to wait again if necessary. + * + * Note the semantics of a condition variable: the mutex must be held before + * wait() is called, and it will still be held when wait() returns. However, + * it will be temporarily released during the wait() call itself. + */ INLINE void ConditionVarDirect:: wait() { TAU_PROFILE("ConditionVarDirect::wait()", " ", TAU_USER); _impl.wait(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::wait -// Access: Published -// Description: Waits on the condition, with a timeout. The function -// will return when the condition variable is notified, -// or the timeout occurs. There is no way to directly -// tell which happened, and it is possible that neither -// in fact happened (spurious wakeups are possible). -// -// See wait() with no parameters for more. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition, with a timeout. The function will return when the + * condition variable is notified, or the timeout occurs. There is no way to + * directly tell which happened, and it is possible that neither in fact + * happened (spurious wakeups are possible). + * + * See wait() with no parameters for more. + */ void ConditionVarDirect:: wait(double timeout) { TAU_PROFILE("ConditionVarDirect::wait(double)", " ", TAU_USER); _impl.wait(timeout); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::notify -// Access: Public -// Description: Informs one of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. If multiple threads are currently waiting, -// at least one of them will be woken up, although there -// is no way to predict which one. It is possible that -// more than one thread will be woken up. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify event is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs one of the other threads who are currently blocked on wait() that + * the relevant condition has changed. If multiple threads are currently + * waiting, at least one of them will be woken up, although there is no way to + * predict which one. It is possible that more than one thread will be woken + * up. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify event is lost. + */ INLINE void ConditionVarDirect:: notify() { TAU_PROFILE("ConditionVarDirect::notify()", " ", TAU_USER); diff --git a/panda/src/pipeline/conditionVarDirect.cxx b/panda/src/pipeline/conditionVarDirect.cxx index 8c7f7713a6..b3f18f1c0c 100644 --- a/panda/src/pipeline/conditionVarDirect.cxx +++ b/panda/src/pipeline/conditionVarDirect.cxx @@ -1,27 +1,24 @@ -// Filename: conditionVarDirect.cxx -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDirect.cxx + * @author drose + * @date 2006-02-13 + */ #include "conditionVarDirect.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDirect::output -// Access: Public -// Description: This method is declared virtual in ConditionVarDebug, -// but non-virtual in ConditionVarDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in ConditionVarDebug, but non-virtual in + * ConditionVarDirect. + */ void ConditionVarDirect:: output(ostream &out) const { out << "ConditionVar " << (void *)this << " on " << _mutex; diff --git a/panda/src/pipeline/conditionVarDirect.h b/panda/src/pipeline/conditionVarDirect.h index 1487ec0aef..508a7c2bdf 100644 --- a/panda/src/pipeline/conditionVarDirect.h +++ b/panda/src/pipeline/conditionVarDirect.h @@ -1,16 +1,15 @@ -// Filename: conditionVarDirect.h -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDirect.h + * @author drose + * @date 2006-02-13 + */ #ifndef CONDITIONVARDIRECT_H #define CONDITIONVARDIRECT_H @@ -21,18 +20,15 @@ #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarDirect -// Description : A condition variable, usually used to communicate -// information about changing state to a thread that is -// waiting for something to happen. A condition -// variable can be used to "wake up" a thread when some -// arbitrary condition has changed. -// -// A condition variable is associated with a single -// mutex, and several condition variables may share the -// same mutex. -//////////////////////////////////////////////////////////////////// +/** + * A condition variable, usually used to communicate information about + * changing state to a thread that is waiting for something to happen. A + * condition variable can be used to "wake up" a thread when some arbitrary + * condition has changed. + * + * A condition variable is associated with a single mutex, and several + * condition variables may share the same mutex. + */ class EXPCL_PANDA_PIPELINE ConditionVarDirect { public: INLINE ConditionVarDirect(MutexDirect &mutex); diff --git a/panda/src/pipeline/conditionVarDummyImpl.I b/panda/src/pipeline/conditionVarDummyImpl.I index 06119c0e8f..ddb356bfe6 100644 --- a/panda/src/pipeline/conditionVarDummyImpl.I +++ b/panda/src/pipeline/conditionVarDummyImpl.I @@ -1,70 +1,56 @@ -// Filename: conditionVarDummyImpl.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDummyImpl.I + * @author drose + * @date 2002-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarDummyImpl:: ConditionVarDummyImpl(MutexDummyImpl &) { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarDummyImpl:: ~ConditionVarDummyImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarDummyImpl:: wait() { Thread::force_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarDummyImpl:: wait(double) { Thread::force_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarDummyImpl:: notify() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarDummyImpl::notify_all -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarDummyImpl:: notify_all() { } diff --git a/panda/src/pipeline/conditionVarDummyImpl.cxx b/panda/src/pipeline/conditionVarDummyImpl.cxx index 7de8b4c953..36dd47e659 100644 --- a/panda/src/pipeline/conditionVarDummyImpl.cxx +++ b/panda/src/pipeline/conditionVarDummyImpl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarDummyImpl.cxx -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDummyImpl.cxx + * @author drose + * @date 2002-08-09 + */ #include "selectThreadImpl.h" #include "conditionVarDummyImpl.h" diff --git a/panda/src/pipeline/conditionVarDummyImpl.h b/panda/src/pipeline/conditionVarDummyImpl.h index d5d8b06556..150b77f910 100644 --- a/panda/src/pipeline/conditionVarDummyImpl.h +++ b/panda/src/pipeline/conditionVarDummyImpl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarDummyImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarDummyImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef CONDITIONVARDUMMYIMPL_H #define CONDITIONVARDUMMYIMPL_H @@ -23,12 +22,10 @@ class MutexDummyImpl; -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarDummyImpl -// Description : A fake condition variable implementation for -// single-threaded applications that don't need any -// synchronization control. -//////////////////////////////////////////////////////////////////// +/** + * A fake condition variable implementation for single-threaded applications + * that don't need any synchronization control. + */ class EXPCL_PANDA_PIPELINE ConditionVarDummyImpl { public: INLINE ConditionVarDummyImpl(MutexDummyImpl &mutex); diff --git a/panda/src/pipeline/conditionVarFull.I b/panda/src/pipeline/conditionVarFull.I index 7dc3ff6670..21b93b5ec6 100644 --- a/panda/src/pipeline/conditionVarFull.I +++ b/panda/src/pipeline/conditionVarFull.I @@ -1,84 +1,69 @@ -// Filename: conditionVarFull.I -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFull.I + * @author drose + * @date 2006-08-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFull::Constructor -// Access: Published -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ INLINE ConditionVarFull:: ConditionVarFull(Mutex &mutex) : #ifdef DEBUG_THREADS ConditionVarFullDebug(mutex) -#else +#else ConditionVarFullDirect(mutex) #endif // DEBUG_THREADS { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFull::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarFull:: ~ConditionVarFull() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFull::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVarFull:: -ConditionVarFull(const ConditionVarFull ©) : +ConditionVarFull(const ConditionVarFull ©) : #ifdef DEBUG_THREADS ConditionVarFullDebug(copy.get_mutex()) -#else +#else ConditionVarFullDirect(copy.get_mutex()) #endif // DEBUG_THREADS { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFull::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVarFull:: operator = (const ConditionVarFull ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFull::get_mutex -// Access: Published -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE Mutex &ConditionVarFull:: get_mutex() const { #ifdef DEBUG_THREADS return (Mutex &)ConditionVarFullDebug::get_mutex(); -#else +#else return (Mutex &)ConditionVarFullDirect::get_mutex(); #endif // DEBUG_THREADS } diff --git a/panda/src/pipeline/conditionVarFull.cxx b/panda/src/pipeline/conditionVarFull.cxx index 50a4e69ffa..b5a32d477c 100644 --- a/panda/src/pipeline/conditionVarFull.cxx +++ b/panda/src/pipeline/conditionVarFull.cxx @@ -1,15 +1,14 @@ -// Filename: conditionVarFull.cxx -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFull.cxx + * @author drose + * @date 2006-08-28 + */ #include "conditionVarFull.h" diff --git a/panda/src/pipeline/conditionVarFull.h b/panda/src/pipeline/conditionVarFull.h index 3c207cbd06..df25a717a9 100644 --- a/panda/src/pipeline/conditionVarFull.h +++ b/panda/src/pipeline/conditionVarFull.h @@ -1,16 +1,15 @@ -// Filename: conditionVarFull.h -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFull.h + * @author drose + * @date 2006-08-28 + */ #ifndef CONDITIONVARFULL_H #define CONDITIONVARFULL_H @@ -19,34 +18,26 @@ #include "conditionVarFullDebug.h" #include "conditionVarFullDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarFull -// Description : This class implements a condition variable; see -// ConditionVar for a brief introduction to this class. -// The ConditionVarFull class provides a more complete -// implementation than ConditionVar; in particular, it -// provides the notify_all() method, which is guaranteed -// to wake up all threads currently waiting on the -// condition (whereas notify() is guaranteed to wake up -// at least one thread, but may or may not wake up all -// of them). -// -// This class exists because on certain platforms -// (e.g. Win32), implementing notify_all() requires more -// overhead, so you should use ConditionVar for cases -// when you do not require the notify_all() semantics. -// -// There are still some minor semantics that POSIX -// condition variables provide which this implementation -// does not. For instance, it is required (not -// optional) that the caller of notify() or notify_all() -// is holding the condition variable's mutex before the -// call. -// -// This class inherits its implementation either from -// ConditionVarFullDebug or ConditionVarFullDirect, -// depending on the definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a condition variable; see ConditionVar for a brief + * introduction to this class. The ConditionVarFull class provides a more + * complete implementation than ConditionVar; in particular, it provides the + * notify_all() method, which is guaranteed to wake up all threads currently + * waiting on the condition (whereas notify() is guaranteed to wake up at + * least one thread, but may or may not wake up all of them). + * + * This class exists because on certain platforms (e.g. Win32), implementing + * notify_all() requires more overhead, so you should use ConditionVar for + * cases when you do not require the notify_all() semantics. + * + * There are still some minor semantics that POSIX condition variables provide + * which this implementation does not. For instance, it is required (not + * optional) that the caller of notify() or notify_all() is holding the + * condition variable's mutex before the call. + * + * This class inherits its implementation either from ConditionVarFullDebug or + * ConditionVarFullDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE ConditionVarFull : public ConditionVarFullDebug #else diff --git a/panda/src/pipeline/conditionVarFullDebug.I b/panda/src/pipeline/conditionVarFullDebug.I index eac3d6b1eb..bbf60f603d 100644 --- a/panda/src/pipeline/conditionVarFullDebug.I +++ b/panda/src/pipeline/conditionVarFullDebug.I @@ -1,47 +1,38 @@ -// Filename: conditionVarFullDebug.I -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDebug.I + * @author drose + * @date 2006-08-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVarFullDebug:: -ConditionVarFullDebug(const ConditionVarFullDebug ©) : - _mutex(copy._mutex), +ConditionVarFullDebug(const ConditionVarFullDebug ©) : + _mutex(copy._mutex), _impl(*_mutex._global_lock) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVarFullDebug:: operator = (const ConditionVarFullDebug ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::get_mutex -// Access: Published -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE MutexDebug &ConditionVarFullDebug:: get_mutex() const { return _mutex; diff --git a/panda/src/pipeline/conditionVarFullDebug.cxx b/panda/src/pipeline/conditionVarFullDebug.cxx index e848b3c0d8..4c76b513d0 100644 --- a/panda/src/pipeline/conditionVarFullDebug.cxx +++ b/panda/src/pipeline/conditionVarFullDebug.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarFullDebug.cxx -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDebug.cxx + * @author drose + * @date 2006-08-28 + */ #include "conditionVarFullDebug.h" #include "thread.h" @@ -18,16 +17,12 @@ #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::Constructor -// Access: Public -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ ConditionVarFullDebug:: ConditionVarFullDebug(MutexDebug &mutex) : _mutex(mutex), @@ -36,40 +31,30 @@ ConditionVarFullDebug(MutexDebug &mutex) : nassertv(!_mutex._allow_recursion); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ConditionVarFullDebug:: ~ConditionVarFullDebug() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::wait -// Access: Published -// Description: Waits on the condition. The caller must already be -// holding the lock associated with the condition -// variable before calling this function. -// -// wait() will release the lock, then go to sleep until -// some other thread calls notify() on this condition -// variable. At that time at least one thread waiting -// on the same ConditionVarFullDebug will grab the lock again, -// and then return from wait(). -// -// It is possible that wait() will return even if no one -// has called notify(). It is the responsibility of the -// calling process to verify the condition on return -// from wait, and possibly loop back to wait again if -// necessary. -// -// Note the semantics of a condition variable: the mutex -// must be held before wait() is called, and it will -// still be held when wait() returns. However, it will -// be temporarily released during the wait() call -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition. The caller must already be holding the lock + * associated with the condition variable before calling this function. + * + * wait() will release the lock, then go to sleep until some other thread + * calls notify() on this condition variable. At that time at least one + * thread waiting on the same ConditionVarFullDebug will grab the lock again, + * and then return from wait(). + * + * It is possible that wait() will return even if no one has called notify(). + * It is the responsibility of the calling process to verify the condition on + * return from wait, and possibly loop back to wait again if necessary. + * + * Note the semantics of a condition variable: the mutex must be held before + * wait() is called, and it will still be held when wait() returns. However, + * it will be temporarily released during the wait() call itself. + */ void ConditionVarFullDebug:: wait() { _mutex._global_lock->acquire(); @@ -94,7 +79,7 @@ wait() { current_thread->_waiting_on_cvar_full == NULL) { } current_thread->_waiting_on_cvar_full = this; - + _mutex.do_release(); _impl.wait(); // temporarily releases _global_lock _mutex.do_acquire(current_thread); @@ -111,17 +96,14 @@ wait() { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::wait -// Access: Published -// Description: Waits on the condition, with a timeout. The function -// will return when the condition variable is notified, -// or the timeout occurs. There is no way to directly -// tell which happened, and it is possible that neither -// in fact happened (spurious wakeups are possible). -// -// See wait() with no parameters for more. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition, with a timeout. The function will return when the + * condition variable is notified, or the timeout occurs. There is no way to + * directly tell which happened, and it is possible that neither in fact + * happened (spurious wakeups are possible). + * + * See wait() with no parameters for more. + */ void ConditionVarFullDebug:: wait(double timeout) { _mutex._global_lock->acquire(); @@ -139,7 +121,7 @@ wait(double timeout) { if (thread_cat.is_spam()) { thread_cat.spam() - << *current_thread << " waiting on " << *this + << *current_thread << " waiting on " << *this << ", with timeout " << timeout << "\n"; } @@ -147,7 +129,7 @@ wait(double timeout) { current_thread->_waiting_on_cvar_full == NULL) { } current_thread->_waiting_on_cvar_full = this; - + _mutex.do_release(); _impl.wait(timeout); // temporarily releases _global_lock _mutex.do_acquire(current_thread); @@ -164,23 +146,18 @@ wait(double timeout) { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::notify -// Access: Published -// Description: Informs one of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. If multiple threads are currently waiting, -// at least one of them will be woken up, although there -// is no way to predict which one. It is possible that -// more than one thread will be woken up. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify event is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs one of the other threads who are currently blocked on wait() that + * the relevant condition has changed. If multiple threads are currently + * waiting, at least one of them will be woken up, although there is no way to + * predict which one. It is possible that more than one thread will be woken + * up. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify event is lost. + */ void ConditionVarFullDebug:: notify() { _mutex._global_lock->acquire(); @@ -205,20 +182,15 @@ notify() { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::notify -// Access: Published -// Description: Informs all of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify event is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs all of the other threads who are currently blocked on wait() that + * the relevant condition has changed. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify event is lost. + */ void ConditionVarFullDebug:: notify_all() { _mutex._global_lock->acquire(); @@ -243,12 +215,10 @@ notify_all() { _mutex._global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDebug::output -// Access: Published, Virtual -// Description: This method is declared virtual in ConditionVarFullDebug, -// but non-virtual in ConditionVarFullDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in ConditionVarFullDebug, but non-virtual + * in ConditionVarFullDirect. + */ void ConditionVarFullDebug:: output(ostream &out) const { out << "ConditionVarFull " << (void *)this << " on " << _mutex; diff --git a/panda/src/pipeline/conditionVarFullDebug.h b/panda/src/pipeline/conditionVarFullDebug.h index 70518cf0fe..83e36dd809 100644 --- a/panda/src/pipeline/conditionVarFullDebug.h +++ b/panda/src/pipeline/conditionVarFullDebug.h @@ -1,16 +1,15 @@ -// Filename: conditionVarFullDebug.h -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDebug.h + * @author drose + * @date 2006-08-28 + */ #ifndef CONDITIONVARFULLDEBUG_H #define CONDITIONVARFULLDEBUG_H @@ -21,18 +20,15 @@ #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarFullDebug -// Description : A condition variable, usually used to communicate -// information about changing state to a thread that is -// waiting for something to happen. A condition -// variable can be used to "wake up" a thread when some -// arbitrary condition has changed. -// -// A condition variable is associated with a single -// mutex, and several condition variables may share the -// same mutex. -//////////////////////////////////////////////////////////////////// +/** + * A condition variable, usually used to communicate information about + * changing state to a thread that is waiting for something to happen. A + * condition variable can be used to "wake up" a thread when some arbitrary + * condition has changed. + * + * A condition variable is associated with a single mutex, and several + * condition variables may share the same mutex. + */ class EXPCL_PANDA_PIPELINE ConditionVarFullDebug { public: ConditionVarFullDebug(MutexDebug &mutex); diff --git a/panda/src/pipeline/conditionVarFullDirect.I b/panda/src/pipeline/conditionVarFullDirect.I index 1f05a475a8..fa0da2b3c6 100644 --- a/panda/src/pipeline/conditionVarFullDirect.I +++ b/panda/src/pipeline/conditionVarFullDirect.I @@ -1,28 +1,22 @@ -// Filename: conditionVarFullDirect.I -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDirect.I + * @author drose + * @date 2006-08-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::Constructor -// Access: Public -// Description: You must pass in a Mutex to the condition variable -// constructor. This mutex may be shared by other -// condition variables, if desired. It is the caller's -// responsibility to ensure the Mutex object does not -// destruct during the lifetime of the condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * You must pass in a Mutex to the condition variable constructor. This mutex + * may be shared by other condition variables, if desired. It is the caller's + * responsibility to ensure the Mutex object does not destruct during the + * lifetime of the condition variable. + */ INLINE ConditionVarFullDirect:: ConditionVarFullDirect(MutexDirect &mutex) : _mutex(mutex), @@ -30,134 +24,104 @@ ConditionVarFullDirect(MutexDirect &mutex) : { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarFullDirect:: ~ConditionVarFullDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE ConditionVarFullDirect:: -ConditionVarFullDirect(const ConditionVarFullDirect ©) : - _mutex(copy._mutex), +ConditionVarFullDirect(const ConditionVarFullDirect ©) : + _mutex(copy._mutex), _impl(_mutex._impl) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy condition variables. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy condition variables. + */ INLINE void ConditionVarFullDirect:: operator = (const ConditionVarFullDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::get_mutex -// Access: Published -// Description: Returns the mutex associated with this condition -// variable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mutex associated with this condition variable. + */ INLINE MutexDirect &ConditionVarFullDirect:: get_mutex() const { return _mutex; } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::wait -// Access: Published -// Description: Waits on the condition. The caller must already be -// holding the lock associated with the condition -// variable before calling this function. -// -// wait() will release the lock, then go to sleep until -// some other thread calls notify() on this condition -// variable. At that time at least one thread waiting -// on the same ConditionVarFullDirect will grab the lock again, -// and then return from wait(). -// -// It is possible that wait() will return even if no one -// has called notify(). It is the responsibility of the -// calling process to verify the condition on return -// from wait, and possibly loop back to wait again if -// necessary. -// -// Note the semantics of a condition variable: the mutex -// must be held before wait() is called, and it will -// still be held when wait() returns. However, it will -// be temporarily released during the wait() call -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition. The caller must already be holding the lock + * associated with the condition variable before calling this function. + * + * wait() will release the lock, then go to sleep until some other thread + * calls notify() on this condition variable. At that time at least one + * thread waiting on the same ConditionVarFullDirect will grab the lock again, + * and then return from wait(). + * + * It is possible that wait() will return even if no one has called notify(). + * It is the responsibility of the calling process to verify the condition on + * return from wait, and possibly loop back to wait again if necessary. + * + * Note the semantics of a condition variable: the mutex must be held before + * wait() is called, and it will still be held when wait() returns. However, + * it will be temporarily released during the wait() call itself. + */ INLINE void ConditionVarFullDirect:: wait() { TAU_PROFILE("ConditionVarFullDirect::wait()", " ", TAU_USER); _impl.wait(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::wait -// Access: Published -// Description: Waits on the condition, with a timeout. The function -// will return when the condition variable is notified, -// or the timeout occurs. There is no way to directly -// tell which happened, and it is possible that neither -// in fact happened (spurious wakeups are possible). -// -// See wait() with no parameters for more. -//////////////////////////////////////////////////////////////////// +/** + * Waits on the condition, with a timeout. The function will return when the + * condition variable is notified, or the timeout occurs. There is no way to + * directly tell which happened, and it is possible that neither in fact + * happened (spurious wakeups are possible). + * + * See wait() with no parameters for more. + */ void ConditionVarFullDirect:: wait(double timeout) { TAU_PROFILE("ConditionVarFullDirect::wait(double)", " ", TAU_USER); _impl.wait(timeout); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::notify -// Access: Published -// Description: Informs one of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. If multiple threads are currently waiting, -// at least one of them will be woken up, although there -// is no way to predict which one. It is possible that -// more than one thread will be woken up. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs one of the other threads who are currently blocked on wait() that + * the relevant condition has changed. If multiple threads are currently + * waiting, at least one of them will be woken up, although there is no way to + * predict which one. It is possible that more than one thread will be woken + * up. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify is lost. + */ INLINE void ConditionVarFullDirect:: notify() { TAU_PROFILE("ConditionVarFullDirect::notify()", " ", TAU_USER); _impl.notify(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::notify_all -// Access: Published -// Description: Informs all of the other threads who are currently -// blocked on wait() that the relevant condition has -// changed. -// -// The caller must be holding the mutex associated with -// the condition variable before making this call, which -// will not release the mutex. -// -// If no threads are waiting, this is a no-op: the -// notify event is lost. -//////////////////////////////////////////////////////////////////// +/** + * Informs all of the other threads who are currently blocked on wait() that + * the relevant condition has changed. + * + * The caller must be holding the mutex associated with the condition variable + * before making this call, which will not release the mutex. + * + * If no threads are waiting, this is a no-op: the notify event is lost. + */ INLINE void ConditionVarFullDirect:: notify_all() { TAU_PROFILE("ConditionVarFullDirect::notify()", " ", TAU_USER); diff --git a/panda/src/pipeline/conditionVarFullDirect.cxx b/panda/src/pipeline/conditionVarFullDirect.cxx index 8ed0fe6af4..10c30d57c9 100644 --- a/panda/src/pipeline/conditionVarFullDirect.cxx +++ b/panda/src/pipeline/conditionVarFullDirect.cxx @@ -1,27 +1,24 @@ -// Filename: conditionVarFullDirect.cxx -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDirect.cxx + * @author drose + * @date 2006-08-28 + */ #include "conditionVarFullDirect.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullDirect::output -// Access: Public -// Description: This method is declared virtual in ConditionVarFullDebug, -// but non-virtual in ConditionVarFullDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in ConditionVarFullDebug, but non-virtual + * in ConditionVarFullDirect. + */ void ConditionVarFullDirect:: output(ostream &out) const { out << "ConditionVarFull " << (void *)this << " on " << _mutex; diff --git a/panda/src/pipeline/conditionVarFullDirect.h b/panda/src/pipeline/conditionVarFullDirect.h index 7bf3a892a1..79a069e2de 100644 --- a/panda/src/pipeline/conditionVarFullDirect.h +++ b/panda/src/pipeline/conditionVarFullDirect.h @@ -1,16 +1,15 @@ -// Filename: conditionVarFullDirect.h -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullDirect.h + * @author drose + * @date 2006-08-28 + */ #ifndef CONDITIONVARFULLDIRECT_H #define CONDITIONVARFULLDIRECT_H @@ -21,18 +20,15 @@ #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarFullDirect -// Description : A condition variable, usually used to communicate -// information about changing state to a thread that is -// waiting for something to happen. A condition -// variable can be used to "wake up" a thread when some -// arbitrary condition has changed. -// -// A condition variable is associated with a single -// mutex, and several condition variables may share the -// same mutex. -//////////////////////////////////////////////////////////////////// +/** + * A condition variable, usually used to communicate information about + * changing state to a thread that is waiting for something to happen. A + * condition variable can be used to "wake up" a thread when some arbitrary + * condition has changed. + * + * A condition variable is associated with a single mutex, and several + * condition variables may share the same mutex. + */ class EXPCL_PANDA_PIPELINE ConditionVarFullDirect { public: INLINE ConditionVarFullDirect(MutexDirect &mutex); diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.I b/panda/src/pipeline/conditionVarFullWin32Impl.I index 3b3b19601c..361e81ac93 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.I +++ b/panda/src/pipeline/conditionVarFullWin32Impl.I @@ -1,23 +1,19 @@ -// Filename: conditionVarFullWin32Impl.I -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullWin32Impl.I + * @author drose + * @date 2006-08-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarFullWin32Impl:: ConditionVarFullWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; @@ -29,33 +25,29 @@ ConditionVarFullWin32Impl(MutexWin32Impl &mutex) { _waiters_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarFullWin32Impl:: ~ConditionVarFullWin32Impl() { CloseHandle(_event_signal); CloseHandle(_event_broadcast); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarFullWin32Impl:: wait() { AtomicAdjust::inc(_waiters_count); - // It's ok to release the external_mutex here since Win32 - // manual-reset events maintain state when used with SetEvent(). - // This avoids the "lost wakeup" bug... + // It's ok to release the external_mutex here since Win32 manual-reset + // events maintain state when used with SetEvent(). This avoids the "lost + // wakeup" bug... LeaveCriticalSection(_external_mutex); - // Wait for either event to become signaled due to notify() being - // called or notify_all() being called. + // Wait for either event to become signaled due to notify() being called or + // notify_all() being called. int result = WaitForMultipleObjects(2, &_event_signal, FALSE, INFINITE); bool nonzero = AtomicAdjust::dec(_waiters_count); @@ -63,31 +55,29 @@ wait() { // Some thread called notify_all(). if (last_waiter) { - // We're the last waiter to be notified or to stop waiting, so - // reset the manual event. - ResetEvent(_event_broadcast); + // We're the last waiter to be notified or to stop waiting, so reset the + // manual event. + ResetEvent(_event_broadcast); } // Reacquire the . EnterCriticalSection(_external_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarFullWin32Impl:: wait(double timeout) { AtomicAdjust::inc(_waiters_count); - // It's ok to release the external_mutex here since Win32 - // manual-reset events maintain state when used with SetEvent(). - // This avoids the "lost wakeup" bug... + // It's ok to release the external_mutex here since Win32 manual-reset + // events maintain state when used with SetEvent(). This avoids the "lost + // wakeup" bug... LeaveCriticalSection(_external_mutex); - // Wait for either event to become signaled due to notify() being - // called or notify_all() being called. + // Wait for either event to become signaled due to notify() being called or + // notify_all() being called. int result = WaitForMultipleObjects(2, &_event_signal, FALSE, (DWORD)(timeout * 1000.0)); bool nonzero = AtomicAdjust::dec(_waiters_count); @@ -95,20 +85,18 @@ wait(double timeout) { // Some thread called notify_all(). if (last_waiter) { - // We're the last waiter to be notified or to stop waiting, so - // reset the manual event. - ResetEvent(_event_broadcast); + // We're the last waiter to be notified or to stop waiting, so reset the + // manual event. + ResetEvent(_event_broadcast); } // Reacquire the . EnterCriticalSection(_external_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarFullWin32Impl:: notify() { bool have_waiters = AtomicAdjust::get(_waiters_count) > 0; @@ -118,11 +106,9 @@ notify() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarFullWin32Impl::notify_all -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarFullWin32Impl:: notify_all() { bool have_waiters = AtomicAdjust::get(_waiters_count) > 0; diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.cxx b/panda/src/pipeline/conditionVarFullWin32Impl.cxx index 2ab5ba63c9..6d664735d6 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.cxx +++ b/panda/src/pipeline/conditionVarFullWin32Impl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarFullWin32Impl.cxx -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullWin32Impl.cxx + * @author drose + * @date 2006-08-28 + */ #include "selectThreadImpl.h" diff --git a/panda/src/pipeline/conditionVarFullWin32Impl.h b/panda/src/pipeline/conditionVarFullWin32Impl.h index b8130d950e..a42d4d86a8 100644 --- a/panda/src/pipeline/conditionVarFullWin32Impl.h +++ b/panda/src/pipeline/conditionVarFullWin32Impl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarFullWin32Impl.h -// Created by: drose (28Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarFullWin32Impl.h + * @author drose + * @date 2006-08-28 + */ #ifndef CONDITIONVARFULLWIN32IMPL_H #define CONDITIONVARFULLWIN32IMPL_H @@ -26,25 +25,20 @@ class MutexWin32Impl; -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarFullWin32Impl -// Description : Uses Windows native calls to implement a -// conditionVarFull. -// -// We follow the "SetEvent" implementation suggested by -// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html . -// This allows us to implement both notify() and -// notify_all(), but it has more overhead than the -// simpler implementation of ConditionVarWin32Impl. -// -// As described by the above reference, this -// implementation suffers from a few weaknesses; in -// particular, it does not necessarily wake up all -// threads fairly; and it may sometimes incorrectly wake -// up a thread that was not waiting at the time notify() -// was called. But we figure it's good enough for our -// purposes. -//////////////////////////////////////////////////////////////////// +/** + * Uses Windows native calls to implement a conditionVarFull. + * + * We follow the "SetEvent" implementation suggested by + * http://www.cs.wustl.edu/~schmidt/win32-cv-1.html . This allows us to + * implement both notify() and notify_all(), but it has more overhead than the + * simpler implementation of ConditionVarWin32Impl. + * + * As described by the above reference, this implementation suffers from a few + * weaknesses; in particular, it does not necessarily wake up all threads + * fairly; and it may sometimes incorrectly wake up a thread that was not + * waiting at the time notify() was called. But we figure it's good enough + * for our purposes. + */ class EXPCL_PANDA_PIPELINE ConditionVarFullWin32Impl { public: INLINE ConditionVarFullWin32Impl(MutexWin32Impl &mutex); diff --git a/panda/src/pipeline/conditionVarImpl.h b/panda/src/pipeline/conditionVarImpl.h index 37e9d2e681..499a5b0c62 100644 --- a/panda/src/pipeline/conditionVarImpl.h +++ b/panda/src/pipeline/conditionVarImpl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef CONDITIONVARIMPL_H #define CONDITIONVARIMPL_H @@ -52,6 +51,3 @@ typedef ConditionVarPosixImpl ConditionVarFullImpl; #endif #endif - - - diff --git a/panda/src/pipeline/conditionVarPosixImpl.I b/panda/src/pipeline/conditionVarPosixImpl.I index adc8899383..e51c0e8447 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.I +++ b/panda/src/pipeline/conditionVarPosixImpl.I @@ -1,23 +1,19 @@ -// Filename: conditionVarPosixImpl.I -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarPosixImpl.I + * @author drose + * @date 2006-02-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarPosixImpl:: ConditionVarPosixImpl(MutexPosixImpl &mutex) : _mutex(mutex) @@ -27,11 +23,9 @@ ConditionVarPosixImpl(MutexPosixImpl &mutex) : nassertv(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarPosixImpl:: ~ConditionVarPosixImpl() { TAU_PROFILE("ConditionVarPosixImpl::~ConditionVarPosixImpl()", " ", TAU_USER); @@ -39,11 +33,9 @@ INLINE ConditionVarPosixImpl:: nassertv(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarPosixImpl:: wait() { TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); @@ -56,11 +48,9 @@ wait() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarPosixImpl:: notify() { TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER); @@ -68,11 +58,9 @@ notify() { nassertv(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::notify_all -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarPosixImpl:: notify_all() { TAU_PROFILE("ConditionVarPosixImpl::notify()", " ", TAU_USER); diff --git a/panda/src/pipeline/conditionVarPosixImpl.cxx b/panda/src/pipeline/conditionVarPosixImpl.cxx index 1b54fe3759..6613dd53b4 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.cxx +++ b/panda/src/pipeline/conditionVarPosixImpl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarPosixImpl.cxx -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarPosixImpl.cxx + * @author drose + * @date 2006-02-10 + */ #include "selectThreadImpl.h" @@ -19,14 +18,12 @@ #include "conditionVarPosixImpl.h" #include -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarPosixImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarPosixImpl:: wait(double timeout) { - //TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); + // TAU_PROFILE("ConditionVarPosixImpl::wait()", " ", TAU_USER); struct timeval now; gettimeofday(&now, NULL); diff --git a/panda/src/pipeline/conditionVarPosixImpl.h b/panda/src/pipeline/conditionVarPosixImpl.h index c3367aa0c0..e39a5a122b 100644 --- a/panda/src/pipeline/conditionVarPosixImpl.h +++ b/panda/src/pipeline/conditionVarPosixImpl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarPosixImpl.h -// Created by: drose (10Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarPosixImpl.h + * @author drose + * @date 2006-02-10 + */ #ifndef CONDITIONVARPOSIXIMPL_H #define CONDITIONVARPOSIXIMPL_H @@ -28,10 +27,9 @@ class MutexPosixImpl; -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarPosixImpl -// Description : Uses Posix threads to implement a conditionVar. -//////////////////////////////////////////////////////////////////// +/** + * Uses Posix threads to implement a conditionVar. + */ class EXPCL_PANDA_PIPELINE ConditionVarPosixImpl { public: INLINE ConditionVarPosixImpl(MutexPosixImpl &mutex); diff --git a/panda/src/pipeline/conditionVarSimpleImpl.I b/panda/src/pipeline/conditionVarSimpleImpl.I index 623aaa52cd..7815e84d73 100644 --- a/panda/src/pipeline/conditionVarSimpleImpl.I +++ b/panda/src/pipeline/conditionVarSimpleImpl.I @@ -1,41 +1,33 @@ -// Filename: conditionVarSimpleImpl.I -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSimpleImpl.I + * @author drose + * @date 2007-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarSimpleImpl:: ConditionVarSimpleImpl(MutexTrueImpl &mutex) : _mutex(mutex) { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarSimpleImpl:: ~ConditionVarSimpleImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarSimpleImpl:: notify() { if (_flags & F_has_waiters) { @@ -43,11 +35,9 @@ notify() { } } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::notify_all -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarSimpleImpl:: notify_all() { if (_flags & F_has_waiters) { diff --git a/panda/src/pipeline/conditionVarSimpleImpl.cxx b/panda/src/pipeline/conditionVarSimpleImpl.cxx index 62ac49bd4d..9c60c98ff0 100644 --- a/panda/src/pipeline/conditionVarSimpleImpl.cxx +++ b/panda/src/pipeline/conditionVarSimpleImpl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarSimpleImpl.cxx -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSimpleImpl.cxx + * @author drose + * @date 2007-06-19 + */ #include "selectThreadImpl.h" @@ -19,11 +18,9 @@ #include "conditionVarSimpleImpl.h" #include "threadSimpleImpl.h" -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarSimpleImpl:: wait() { _mutex.release_quietly(); @@ -36,19 +33,17 @@ wait() { _mutex.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarSimpleImpl:: wait(double timeout) { _mutex.release_quietly(); - // TODO. For now this will release every frame, since we don't have - // an interface yet on ThreadSimpleManager to do a timed wait. - // Maybe that's good enough forever (it does satisfy the condition - // variable semantics, after all). + // TODO. For now this will release every frame, since we don't have an + // interface yet on ThreadSimpleManager to do a timed wait. Maybe that's + // good enough forever (it does satisfy the condition variable semantics, + // after all). ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); ThreadSimpleImpl *thread = manager->get_current_thread(); manager->enqueue_ready(thread, true); @@ -57,34 +52,30 @@ wait(double timeout) { _mutex.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::do_notify -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarSimpleImpl:: do_notify() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); if (manager->unblock_one(this)) { - // There had been a thread waiting on this condition variable. - // Switch contexts immediately, to make fairness more likely. + // There had been a thread waiting on this condition variable. Switch + // contexts immediately, to make fairness more likely. ThreadSimpleImpl *thread = manager->get_current_thread(); manager->enqueue_ready(thread, false); manager->next_context(); } } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSimpleImpl::do_notify_all -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarSimpleImpl:: do_notify_all() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); if (manager->unblock_all(this)) { - // There had been a thread waiting on this condition variable. - // Switch contexts immediately, to make fairness more likely. + // There had been a thread waiting on this condition variable. Switch + // contexts immediately, to make fairness more likely. ThreadSimpleImpl *thread = manager->get_current_thread(); manager->enqueue_ready(thread, false); manager->next_context(); diff --git a/panda/src/pipeline/conditionVarSimpleImpl.h b/panda/src/pipeline/conditionVarSimpleImpl.h index f7a57822a2..2181a94925 100644 --- a/panda/src/pipeline/conditionVarSimpleImpl.h +++ b/panda/src/pipeline/conditionVarSimpleImpl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarSimpleImpl.h -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSimpleImpl.h + * @author drose + * @date 2007-06-19 + */ #ifndef CONDITIONVARSIMPLEIMPL_H #define CONDITIONVARSIMPLEIMPL_H @@ -23,11 +22,9 @@ #include "blockerSimple.h" #include "mutexTrueImpl.h" -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarSimpleImpl -// Description : Implements a simple condition variable using -// simulated user-space threads. -//////////////////////////////////////////////////////////////////// +/** + * Implements a simple condition variable using simulated user-space threads. + */ class EXPCL_PANDA_PIPELINE ConditionVarSimpleImpl : public BlockerSimple { public: INLINE ConditionVarSimpleImpl(MutexTrueImpl &mutex); diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.I b/panda/src/pipeline/conditionVarSpinlockImpl.I index 3a75e27b12..b4747bd220 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.I +++ b/panda/src/pipeline/conditionVarSpinlockImpl.I @@ -1,53 +1,43 @@ -// Filename: conditionVarSpinlockImpl.I -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSpinlockImpl.I + * @author drose + * @date 2006-04-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSpinlockImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarSpinlockImpl:: ConditionVarSpinlockImpl(MutexSpinlockImpl &mutex) : _mutex(mutex) { _event = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSpinlockImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarSpinlockImpl:: ~ConditionVarSpinlockImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSpinlockImpl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarSpinlockImpl:: notify() { // This will wake up all waiters on the lock. But that's allowed. AtomicAdjust::inc(_event); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSpinlockImpl::notify_all -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarSpinlockImpl:: notify_all() { AtomicAdjust::inc(_event); diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.cxx b/panda/src/pipeline/conditionVarSpinlockImpl.cxx index ddfbb78b0a..f36bc83125 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.cxx +++ b/panda/src/pipeline/conditionVarSpinlockImpl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarSpinlockImpl.cxx -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSpinlockImpl.cxx + * @author drose + * @date 2006-04-11 + */ #include "selectThreadImpl.h" @@ -18,11 +17,9 @@ #include "conditionVarSpinlockImpl.h" -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarSpinlockImpl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ConditionVarSpinlockImpl:: wait() { AtomicAdjust::Integer current = _event; diff --git a/panda/src/pipeline/conditionVarSpinlockImpl.h b/panda/src/pipeline/conditionVarSpinlockImpl.h index 1c71d9fa94..5d8da7bbf7 100644 --- a/panda/src/pipeline/conditionVarSpinlockImpl.h +++ b/panda/src/pipeline/conditionVarSpinlockImpl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarSpinlockImpl.h -// Created by: drose (11Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarSpinlockImpl.h + * @author drose + * @date 2006-04-11 + */ #ifndef CONDITIONVARSPINLOCKIMPL_H #define CONDITIONVARSPINLOCKIMPL_H @@ -26,15 +25,12 @@ class MutexSpinlockImpl; -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarSpinlockImpl -// Description : Uses a simple user-space spinlock to implement a -// condition variable. It is usually not a good idea to -// use this implementation, unless you are building -// Panda for a specific application on a specific SMP -// machine, and you are confident that you have at least -// as many CPU's as you have threads. -//////////////////////////////////////////////////////////////////// +/** + * Uses a simple user-space spinlock to implement a condition variable. It is + * usually not a good idea to use this implementation, unless you are building + * Panda for a specific application on a specific SMP machine, and you are + * confident that you have at least as many CPU's as you have threads. + */ class EXPCL_PANDA_PIPELINE ConditionVarSpinlockImpl { public: INLINE ConditionVarSpinlockImpl(MutexSpinlockImpl &mutex); diff --git a/panda/src/pipeline/conditionVarWin32Impl.I b/panda/src/pipeline/conditionVarWin32Impl.I index e562756e87..263a7d37a4 100644 --- a/panda/src/pipeline/conditionVarWin32Impl.I +++ b/panda/src/pipeline/conditionVarWin32Impl.I @@ -1,23 +1,19 @@ -// Filename: conditionVarWin32Impl.I -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarWin32Impl.I + * @author drose + * @date 2006-02-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarWin32Impl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarWin32Impl:: ConditionVarWin32Impl(MutexWin32Impl &mutex) { _external_mutex = &mutex._lock; @@ -26,21 +22,17 @@ ConditionVarWin32Impl(MutexWin32Impl &mutex) { _event_signal = CreateEvent(NULL, false, false, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarWin32Impl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ConditionVarWin32Impl:: ~ConditionVarWin32Impl() { CloseHandle(_event_signal); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarWin32Impl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarWin32Impl:: wait() { LeaveCriticalSection(_external_mutex); @@ -51,11 +43,9 @@ wait() { EnterCriticalSection(_external_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarWin32Impl::wait -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarWin32Impl:: wait(double timeout) { LeaveCriticalSection(_external_mutex); @@ -66,11 +56,9 @@ wait(double timeout) { EnterCriticalSection(_external_mutex); } -//////////////////////////////////////////////////////////////////// -// Function: ConditionVarWin32Impl::notify -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ConditionVarWin32Impl:: notify() { SetEvent(_event_signal); diff --git a/panda/src/pipeline/conditionVarWin32Impl.cxx b/panda/src/pipeline/conditionVarWin32Impl.cxx index c9f8c0fc14..9d3a95e0b1 100644 --- a/panda/src/pipeline/conditionVarWin32Impl.cxx +++ b/panda/src/pipeline/conditionVarWin32Impl.cxx @@ -1,16 +1,15 @@ -// Filename: conditionVarWin32Impl.cxx -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarWin32Impl.cxx + * @author drose + * @date 2006-02-07 + */ #include "selectThreadImpl.h" diff --git a/panda/src/pipeline/conditionVarWin32Impl.h b/panda/src/pipeline/conditionVarWin32Impl.h index cfc3337637..7ed6513d6e 100644 --- a/panda/src/pipeline/conditionVarWin32Impl.h +++ b/panda/src/pipeline/conditionVarWin32Impl.h @@ -1,16 +1,15 @@ -// Filename: conditionVarWin32Impl.h -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file conditionVarWin32Impl.h + * @author drose + * @date 2006-02-07 + */ #ifndef CONDITIONVARWIN32IMPL_H #define CONDITIONVARWIN32IMPL_H @@ -25,20 +24,16 @@ class MutexWin32Impl; -//////////////////////////////////////////////////////////////////// -// Class : ConditionVarWin32Impl -// Description : Uses Windows native calls to implement a -// conditionVar. -// -// The Windows native synchronization primitives don't -// actually implement a full POSIX-style condition -// variable, but the Event primitive does a fair job if -// we disallow notify_all() (POSIX broadcast). See -// ConditionVarFullWin32Impl for a full implementation -// that includes notify_all(). This class is much -// simpler than that full implementation, so we can -// avoid the overhead required to support broadcast. -//////////////////////////////////////////////////////////////////// +/** + * Uses Windows native calls to implement a conditionVar. + * + * The Windows native synchronization primitives don't actually implement a + * full POSIX-style condition variable, but the Event primitive does a fair + * job if we disallow notify_all() (POSIX broadcast). See + * ConditionVarFullWin32Impl for a full implementation that includes + * notify_all(). This class is much simpler than that full implementation, so + * we can avoid the overhead required to support broadcast. + */ class EXPCL_PANDA_PIPELINE ConditionVarWin32Impl { public: INLINE ConditionVarWin32Impl(MutexWin32Impl &mutex); diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx index 26a35fc544..2dd7106dee 100644 --- a/panda/src/pipeline/config_pipeline.cxx +++ b/panda/src/pipeline/config_pipeline.cxx @@ -1,16 +1,15 @@ -// Filename: config_pipeline.cxx -// Created by: drose (28Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pipeline.cxx + * @author drose + * @date 2006-03-28 + */ #include "config_pipeline.h" #include "asyncTaskBase.h" @@ -55,14 +54,12 @@ ConfigVariableInt thread_stack_size "created for each newly-created thread. Not all thread " "implementations respect this value.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpipeline -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpipeline() { static bool initialized = false; diff --git a/panda/src/pipeline/config_pipeline.h b/panda/src/pipeline/config_pipeline.h index 128444a78e..9da01b0f4a 100644 --- a/panda/src/pipeline/config_pipeline.h +++ b/panda/src/pipeline/config_pipeline.h @@ -1,16 +1,15 @@ -// Filename: config_pipeline.h -// Created by: cary (04Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pipeline.h + * @author cary + * @date 2000-01-04 + */ #ifndef CONFIG_PIPELINE_H #define CONFIG_PIPELINE_H @@ -32,4 +31,3 @@ extern ConfigVariableInt thread_stack_size; extern EXPCL_PANDA_PIPELINE void init_libpipeline(); #endif // CONFIG_PIPELINE_H - diff --git a/panda/src/pipeline/contextSwitch.h b/panda/src/pipeline/contextSwitch.h index f475b9781c..27bb2907ec 100644 --- a/panda/src/pipeline/contextSwitch.h +++ b/panda/src/pipeline/contextSwitch.h @@ -1,8 +1,4 @@ -/* Filename: contextSwitch.h - * Created by: drose (21Jun07) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file contextSwitch.h + * @author drose + * @date 2007-06-21 + */ #ifndef CONTEXTSWITCH_H #define CONTEXTSWITCH_H @@ -34,7 +33,7 @@ struct ThreadContext; #ifdef __cplusplus extern "C" { -#endif +#endif typedef void ContextFunction(struct ThreadContext *from_context, void *); typedef void ThreadFunction(void *); @@ -49,7 +48,7 @@ extern const int is_os_threads; that when switch_to_thread_context() is called, it will begin executing thread_func(data), which should not return. This function will return normally. */ -void init_thread_context(struct ThreadContext *context, +void init_thread_context(struct ThreadContext *context, unsigned char *stack, size_t stack_size, ThreadFunction *thread_func, void *data); @@ -77,9 +76,8 @@ void free_thread_context(struct ThreadContext *context); #ifdef __cplusplus } -#endif +#endif #endif /* THREAD_SIMPLE_IMPL */ #endif /* CONTEXTSWITCH_H */ - diff --git a/panda/src/pipeline/cycleData.I b/panda/src/pipeline/cycleData.I index ea2bf1794a..53c0224eab 100644 --- a/panda/src/pipeline/cycleData.I +++ b/panda/src/pipeline/cycleData.I @@ -1,23 +1,19 @@ -// Filename: cycleData.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleData.I + * @author drose + * @date 2002-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CycleData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CycleData:: CycleData() { } diff --git a/panda/src/pipeline/cycleData.cxx b/panda/src/pipeline/cycleData.cxx index 56a6a9e706..7570aabbf8 100644 --- a/panda/src/pipeline/cycleData.cxx +++ b/panda/src/pipeline/cycleData.cxx @@ -1,104 +1,83 @@ -// Filename: cycleData.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleData.cxx + * @author drose + * @date 2002-02-21 + */ #include "cycleData.h" -//////////////////////////////////////////////////////////////////// -// Function: CycleData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData:: ~CycleData() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CycleData:: write_datagram(BamWriter *, Datagram &) const { } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void CycleData:: write_datagram(BamWriter *, Datagram &, void *) const { } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int CycleData:: complete_pointers(TypedWritable **, BamReader *) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::fillin -// Access: Public, Virtual -// Description: This internal function is intended to be called by -// each class's make_from_bam() method to read in all of -// the relevant data from the BamFile for the new -// object. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is intended to be called by each class's + * make_from_bam() method to read in all of the relevant data from the BamFile + * for the new object. + */ void CycleData:: fillin(DatagramIterator &, BamReader *) { } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::fillin -// Access: Public, Virtual -// Description: This internal function is intended to be called by -// each class's make_from_bam() method to read in all of -// the relevant data from the BamFile for the new -// object. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is intended to be called by each class's + * make_from_bam() method to read in all of the relevant data from the BamFile + * for the new object. + */ void CycleData:: fillin(DatagramIterator &, BamReader *, void *) { } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::get_parent_type -// Access: Public, Virtual -// Description: Returns the type of the container that owns the -// CycleData. This is useful mainly for debugging. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the container that owns the CycleData. This is useful + * mainly for debugging. + */ TypeHandle CycleData:: get_parent_type() const { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleData::output -// Access: Public, Virtual -// Description: Formats the contents of the CycleData in some -// meaningful way for humans. This is useful mainly for -// debugging. -//////////////////////////////////////////////////////////////////// +/** + * Formats the contents of the CycleData in some meaningful way for humans. + * This is useful mainly for debugging. + */ void CycleData:: output(ostream &out) const { out << get_parent_type() << "::CData"; diff --git a/panda/src/pipeline/cycleData.h b/panda/src/pipeline/cycleData.h index 1f0debc814..4a020c9940 100644 --- a/panda/src/pipeline/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -1,16 +1,15 @@ -// Filename: cycleData.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleData.h + * @author drose + * @date 2002-02-21 + */ #ifndef CYCLEDATA_H #define CYCLEDATA_H @@ -25,28 +24,26 @@ class TypedWritable; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : CycleData -// Description : A single page of data maintained by a PipelineCycler. -// Normally you should inherit from this class to define -// the data structures that are important to protect -// between stages of a pipeline. See PipelineCycler. -//////////////////////////////////////////////////////////////////// +/** + * A single page of data maintained by a PipelineCycler. Normally you should + * inherit from this class to define the data structures that are important to + * protect between stages of a pipeline. See PipelineCycler. + */ #ifdef DO_PIPELINING -// If we are compiling in pipelining support, we maintain a pointer to -// a CycleData object in each containing class, instead of the object -// itself. Thus, it should be a ReferenceCount object. Furthermore, -// since we want to make a distinction between references within the -// cycler, and references outside the cycler -// (e.g. GeomPipelineReader), we make it a NodeReferenceCount. -class EXPCL_PANDA_PIPELINE CycleData : public NodeReferenceCount +// If we are compiling in pipelining support, we maintain a pointer to a +// CycleData object in each containing class, instead of the object itself. +// Thus, it should be a ReferenceCount object. Furthermore, since we want to +// make a distinction between references within the cycler, and references +// outside the cycler (e.g. GeomPipelineReader), we make it a +// NodeReferenceCount. +class EXPCL_PANDA_PIPELINE CycleData : public NodeReferenceCount #else // !DO_PIPELINING -// If we are *not* compiling in pipelining support, the CycleData -// object is stored directly within its containing classes, and hence -// should not be a ReferenceCount object. +// If we are *not* compiling in pipelining support, the CycleData object is +// stored directly within its containing classes, and hence should not be a +// ReferenceCount object. class EXPCL_PANDA_PIPELINE CycleData #endif // DO_PIPELINING @@ -77,4 +74,3 @@ operator << (ostream &out, const CycleData &cd) { #include "cycleData.I" #endif - diff --git a/panda/src/pipeline/cycleDataLockedReader.I b/panda/src/pipeline/cycleDataLockedReader.I index 054b598023..05a66c6213 100644 --- a/panda/src/pipeline/cycleDataLockedReader.I +++ b/panda/src/pipeline/cycleDataLockedReader.I @@ -1,28 +1,25 @@ -// Filename: cycleDataLockedReader.I -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedReader.I + * @author drose + * @date 2006-04-30 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: CycleDataLockedReader(const PipelineCycler &cycler, @@ -34,11 +31,9 @@ CycleDataLockedReader(const PipelineCycler &cycler, nassertv(_pointer != (const CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: CycleDataLockedReader(const CycleDataLockedReader ©) : @@ -50,11 +45,9 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : _cycler->increment_read(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataLockedReader:: operator = (const CycleDataLockedReader ©) { @@ -68,11 +61,9 @@ operator = (const CycleDataLockedReader ©) { _cycler->increment_read(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: ~CycleDataLockedReader() { @@ -81,12 +72,9 @@ INLINE CycleDataLockedReader:: } } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataLockedReader:: operator -> () const { @@ -94,12 +82,10 @@ operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataLockedReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataLockedReader to be passed to any function that + * expects a const CycleDataType pointer. + */ template INLINE CycleDataLockedReader:: operator const CycleDataType * () const { @@ -107,16 +93,12 @@ operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::take_pointer (full) -// Access: Public -// Description: This is intended to be called only from -// CycleDataWriter when it elevates the pointer from -// read to write status. This function returns the -// reader's pointer and relinquishes ownership of the -// pointer, rendering the reader invalid for future -// reads. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only from CycleDataWriter when it elevates + * the pointer from read to write status. This function returns the reader's + * pointer and relinquishes ownership of the pointer, rendering the reader + * invalid for future reads. + */ template INLINE const CycleDataType *CycleDataLockedReader:: take_pointer() { @@ -126,12 +108,10 @@ take_pointer() { return pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataLockedReader:: get_current_thread() const { @@ -141,22 +121,18 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: CycleDataLockedReader(const PipelineCycler &cycler, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: CycleDataLockedReader(const CycleDataLockedReader ©) : @@ -164,73 +140,58 @@ CycleDataLockedReader(const CycleDataLockedReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataLockedReader:: operator = (const CycleDataLockedReader ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedReader:: ~CycleDataLockedReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataLockedReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataLockedReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataLockedReader to be passed to any function that + * expects a const CycleDataType pointer. + */ template INLINE CycleDataLockedReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::take_pointer (trivial) -// Access: Public -// Description: This is intended to be called only from -// CycleDataWriter when it elevates the pointer from -// read to write status. This function returns the -// reader's pointer and relinquishes ownership of the -// pointer, rendering the reader invalid for future -// reads. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only from CycleDataWriter when it elevates + * the pointer from read to write status. This function returns the reader's + * pointer and relinquishes ownership of the pointer, rendering the reader + * invalid for future reads. + */ template INLINE const CycleDataType *CycleDataLockedReader:: take_pointer() { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedReader::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataLockedReader:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataLockedReader.cxx b/panda/src/pipeline/cycleDataLockedReader.cxx index 899c182902..4960c3e413 100644 --- a/panda/src/pipeline/cycleDataLockedReader.cxx +++ b/panda/src/pipeline/cycleDataLockedReader.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataLockedReader.cxx -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedReader.cxx + * @author drose + * @date 2006-04-30 + */ #include "cycleDataLockedReader.h" diff --git a/panda/src/pipeline/cycleDataLockedReader.h b/panda/src/pipeline/cycleDataLockedReader.h index 2703ee5724..80deaf3dce 100644 --- a/panda/src/pipeline/cycleDataLockedReader.h +++ b/panda/src/pipeline/cycleDataLockedReader.h @@ -1,16 +1,15 @@ -// Filename: cycleDataLockedReader.h -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedReader.h + * @author drose + * @date 2006-04-30 + */ #ifndef CYCLEDATALOCKEDREADER_H #define CYCLEDATALOCKEDREADER_H @@ -21,39 +20,33 @@ #include "pipelineCycler.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataLockedReader -// Description : This template class calls PipelineCycler::read() in -// the constructor and PipelineCycler::release_read() in -// the destructor. In the interim, it provides a -// transparent read-only access to the CycleData. -// -// Since a lock is held on the data while the instance -// of this class exists, no other thread may modify any -// stage of the pipeline during that time. Thus, this -// class is appropriate to use for cases in which you -// might want to read and then modify the data. It is -// possible to pass an instance of CycleDataLockedReader -// to the CycleDataWriter constructor, which -// automatically elevates the read lock into a write -// lock. -// -// It exists as a syntactic convenience to access the -// data in the CycleData. It also allows the whole -// system to compile down to nothing if -// DO_PIPELINING is not defined. -//////////////////////////////////////////////////////////////////// +/** + * This template class calls PipelineCycler::read() in the constructor and + * PipelineCycler::release_read() in the destructor. In the interim, it + * provides a transparent read-only access to the CycleData. + * + * Since a lock is held on the data while the instance of this class exists, + * no other thread may modify any stage of the pipeline during that time. + * Thus, this class is appropriate to use for cases in which you might want to + * read and then modify the data. It is possible to pass an instance of + * CycleDataLockedReader to the CycleDataWriter constructor, which + * automatically elevates the read lock into a write lock. + * + * It exists as a syntactic convenience to access the data in the CycleData. + * It also allows the whole system to compile down to nothing if DO_PIPELINING + * is not defined. + */ template class CycleDataLockedReader { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER INLINE CycleDataLockedReader(const PipelineCycler &cycler, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataLockedReader(const CycleDataLockedReader ©); INLINE void operator = (const CycleDataLockedReader ©); - + INLINE ~CycleDataLockedReader(); INLINE const CycleDataType *operator -> () const; diff --git a/panda/src/pipeline/cycleDataLockedStageReader.I b/panda/src/pipeline/cycleDataLockedStageReader.I index 2db2c8543a..521df13494 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.I +++ b/panda/src/pipeline/cycleDataLockedStageReader.I @@ -1,28 +1,25 @@ -// Filename: cycleDataLockedStageReader.I -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedStageReader.I + * @author drose + * @date 2006-04-30 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: CycleDataLockedStageReader(const PipelineCycler &cycler, @@ -35,11 +32,9 @@ CycleDataLockedStageReader(const PipelineCycler &cycler, nassertv(_pointer != (const CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: CycleDataLockedStageReader(const CycleDataLockedStageReader ©) : @@ -52,11 +47,9 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © _cycler->increment_read(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataLockedStageReader:: operator = (const CycleDataLockedStageReader ©) { @@ -71,11 +64,9 @@ operator = (const CycleDataLockedStageReader ©) { _cycler->increment_read(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: ~CycleDataLockedStageReader() { @@ -84,12 +75,9 @@ INLINE CycleDataLockedStageReader:: } } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataLockedStageReader:: operator -> () const { @@ -97,12 +85,10 @@ operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataLockedStageReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataLockedStageReader to be passed to any function + * that expects a const CycleDataType pointer. + */ template INLINE CycleDataLockedStageReader:: operator const CycleDataType * () const { @@ -110,16 +96,12 @@ operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::take_pointer (full) -// Access: Public -// Description: This is intended to be called only from -// CycleDataStageWriter when it elevates the pointer from -// read to write status. This function returns the -// reader's pointer and relinquishes ownership of the -// pointer, rendering the reader invalid for future -// reads. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only from CycleDataStageWriter when it + * elevates the pointer from read to write status. This function returns the + * reader's pointer and relinquishes ownership of the pointer, rendering the + * reader invalid for future reads. + */ template INLINE const CycleDataType *CycleDataLockedStageReader:: take_pointer() { @@ -129,12 +111,10 @@ take_pointer() { return pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataLockedStageReader:: get_current_thread() const { @@ -144,11 +124,9 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: CycleDataLockedStageReader(const PipelineCycler &cycler, int, @@ -156,11 +134,9 @@ CycleDataLockedStageReader(const PipelineCycler &cycler, int, _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: CycleDataLockedStageReader(const CycleDataLockedStageReader ©) : @@ -168,73 +144,58 @@ CycleDataLockedStageReader(const CycleDataLockedStageReader © { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataLockedStageReader:: operator = (const CycleDataLockedStageReader ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataLockedStageReader:: ~CycleDataLockedStageReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataLockedStageReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataLockedStageReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataLockedStageReader to be passed to any function + * that expects a const CycleDataType pointer. + */ template INLINE CycleDataLockedStageReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::take_pointer (trivial) -// Access: Public -// Description: This is intended to be called only from -// CycleDataStageWriter when it elevates the pointer from -// read to write status. This function returns the -// reader's pointer and relinquishes ownership of the -// pointer, rendering the reader invalid for future -// reads. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only from CycleDataStageWriter when it + * elevates the pointer from read to write status. This function returns the + * reader's pointer and relinquishes ownership of the pointer, rendering the + * reader invalid for future reads. + */ template INLINE const CycleDataType *CycleDataLockedStageReader:: take_pointer() { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataLockedStageReader::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataLockedStageReader:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataLockedStageReader.cxx b/panda/src/pipeline/cycleDataLockedStageReader.cxx index 71224b0a36..2f409027df 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.cxx +++ b/panda/src/pipeline/cycleDataLockedStageReader.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataLockedStageReader.cxx -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedStageReader.cxx + * @author drose + * @date 2006-04-30 + */ #include "cycleDataLockedStageReader.h" diff --git a/panda/src/pipeline/cycleDataLockedStageReader.h b/panda/src/pipeline/cycleDataLockedStageReader.h index d6b069e1c8..5b7e84cc19 100644 --- a/panda/src/pipeline/cycleDataLockedStageReader.h +++ b/panda/src/pipeline/cycleDataLockedStageReader.h @@ -1,16 +1,15 @@ -// Filename: cycleDataLockedStageReader.h -// Created by: drose (30Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataLockedStageReader.h + * @author drose + * @date 2006-04-30 + */ #ifndef CYCLEDATALOCKEDSTAGEREADER_H #define CYCLEDATALOCKEDSTAGEREADER_H @@ -20,23 +19,21 @@ #include "cycleData.h" #include "pipelineCycler.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataLockedStageReader -// Description : This class is similar to CycleDataLockedReader, -// except it allows reading from a particular stage of -// the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * This class is similar to CycleDataLockedReader, except it allows reading + * from a particular stage of the pipeline. + */ template class CycleDataLockedStageReader { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER - INLINE CycleDataLockedStageReader(const PipelineCycler &cycler, + INLINE CycleDataLockedStageReader(const PipelineCycler &cycler, int stage, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataLockedStageReader(const CycleDataLockedStageReader ©); INLINE void operator = (const CycleDataLockedStageReader ©); - + INLINE ~CycleDataLockedStageReader(); INLINE const CycleDataType *operator -> () const; diff --git a/panda/src/pipeline/cycleDataReader.I b/panda/src/pipeline/cycleDataReader.I index a3e295eceb..d250fc4ad8 100644 --- a/panda/src/pipeline/cycleDataReader.I +++ b/panda/src/pipeline/cycleDataReader.I @@ -1,28 +1,25 @@ -// Filename: cycleDataReader.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataReader.I + * @author drose + * @date 2002-02-21 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: CycleDataReader(const PipelineCycler &cycler, @@ -33,11 +30,9 @@ CycleDataReader(const PipelineCycler &cycler, _pointer = _cycler->read_unlocked(_current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: CycleDataReader(const CycleDataReader ©) : @@ -47,11 +42,9 @@ CycleDataReader(const CycleDataReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataReader:: operator = (const CycleDataReader ©) { @@ -61,58 +54,47 @@ operator = (const CycleDataReader ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: ~CycleDataReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataReader to be passed to any function that expects a + * const CycleDataType pointer. + */ template INLINE CycleDataReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::p (full) -// Access: Public -// Description: This allows the CycleDataReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataReader to be passed to any function that expects a + * const CycleDataType pointer. + */ template INLINE const CycleDataType *CycleDataReader:: p() const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataReader:: get_current_thread() const { @@ -122,22 +104,18 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: CycleDataReader(const PipelineCycler &cycler, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: CycleDataReader(const CycleDataReader ©) : @@ -145,69 +123,56 @@ CycleDataReader(const CycleDataReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataReader:: operator = (const CycleDataReader ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataReader:: ~CycleDataReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataReader to be passed to any function that expects a + * const CycleDataType pointer. + */ template INLINE CycleDataReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::p (trivial) -// Access: Public -// Description: This allows the CycleDataReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataReader to be passed to any function that expects a + * const CycleDataType pointer. + */ template INLINE const CycleDataType *CycleDataReader:: p() const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataReader:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataReader.cxx b/panda/src/pipeline/cycleDataReader.cxx index d5c25c2e57..a1aa0e437d 100644 --- a/panda/src/pipeline/cycleDataReader.cxx +++ b/panda/src/pipeline/cycleDataReader.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataReader.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataReader.cxx + * @author drose + * @date 2002-02-21 + */ #include "cycleDataReader.h" diff --git a/panda/src/pipeline/cycleDataReader.h b/panda/src/pipeline/cycleDataReader.h index 668bac6585..58ba9e77ac 100644 --- a/panda/src/pipeline/cycleDataReader.h +++ b/panda/src/pipeline/cycleDataReader.h @@ -1,16 +1,15 @@ -// Filename: cycleDataReader.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataReader.h + * @author drose + * @date 2002-02-21 + */ #ifndef CYCLEDATAREADER_H #define CYCLEDATAREADER_H @@ -21,27 +20,22 @@ #include "pipelineCycler.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataReader -// Description : This template class calls -// PipelineCycler::read_unlocked(), and then provides a -// transparent read-only access to the CycleData. It is -// used to access the data quickly, without holding a -// lock, for a thread that does not intend to modify the -// data and write it back out. For cases where the data -// might be subsequently modified, you should use -// CycleDataLockedReader. -// -// It exists as a syntactic convenience to access the -// data in the CycleData. It also allows the whole -// system to compile down to nothing if -// DO_PIPELINING is not defined. -//////////////////////////////////////////////////////////////////// +/** + * This template class calls PipelineCycler::read_unlocked(), and then + * provides a transparent read-only access to the CycleData. It is used to + * access the data quickly, without holding a lock, for a thread that does not + * intend to modify the data and write it back out. For cases where the data + * might be subsequently modified, you should use CycleDataLockedReader. + * + * It exists as a syntactic convenience to access the data in the CycleData. + * It also allows the whole system to compile down to nothing if DO_PIPELINING + * is not defined. + */ template class CycleDataReader { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER INLINE CycleDataReader(const PipelineCycler &cycler, Thread *current_thread = Thread::get_current_thread()); diff --git a/panda/src/pipeline/cycleDataStageReader.I b/panda/src/pipeline/cycleDataStageReader.I index f08d8fb684..482cd860db 100644 --- a/panda/src/pipeline/cycleDataStageReader.I +++ b/panda/src/pipeline/cycleDataStageReader.I @@ -1,28 +1,25 @@ -// Filename: cycleDataStageReader.I -// Created by: drose (08Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageReader.I + * @author drose + * @date 2006-02-08 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: CycleDataStageReader(const PipelineCycler &cycler, @@ -34,11 +31,9 @@ CycleDataStageReader(const PipelineCycler &cycler, _pointer = _cycler->read_stage_unlocked(_stage); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: CycleDataStageReader(const CycleDataStageReader ©) : @@ -49,11 +44,9 @@ CycleDataStageReader(const CycleDataStageReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataStageReader:: operator = (const CycleDataStageReader ©) { @@ -64,46 +57,37 @@ operator = (const CycleDataStageReader ©) { _stage = copy._stage; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: ~CycleDataStageReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataStageReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataStageReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataStageReader to be passed to any function that + * expects a const CycleDataType pointer. + */ template INLINE CycleDataStageReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataStageReader:: get_current_thread() const { @@ -113,11 +97,9 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: CycleDataStageReader(const PipelineCycler &cycler, int, @@ -125,11 +107,9 @@ CycleDataStageReader(const PipelineCycler &cycler, int, _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: CycleDataStageReader(const CycleDataStageReader ©) : @@ -137,57 +117,46 @@ CycleDataStageReader(const CycleDataStageReader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataStageReader:: operator = (const CycleDataStageReader ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageReader:: ~CycleDataStageReader() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataStageReader:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataStageReader to be passed to any -// function that expects a const CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataStageReader to be passed to any function that + * expects a const CycleDataType pointer. + */ template INLINE CycleDataStageReader:: operator const CycleDataType * () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageReader::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataStageReader:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataStageReader.cxx b/panda/src/pipeline/cycleDataStageReader.cxx index fe7173819e..d53bed4ea1 100644 --- a/panda/src/pipeline/cycleDataStageReader.cxx +++ b/panda/src/pipeline/cycleDataStageReader.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataStageReader.cxx -// Created by: drose (08Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageReader.cxx + * @author drose + * @date 2006-02-08 + */ #include "cycleDataStageReader.h" diff --git a/panda/src/pipeline/cycleDataStageReader.h b/panda/src/pipeline/cycleDataStageReader.h index 95782f3c9e..c9cc9d5f3d 100644 --- a/panda/src/pipeline/cycleDataStageReader.h +++ b/panda/src/pipeline/cycleDataStageReader.h @@ -1,16 +1,15 @@ -// Filename: cycleDataStageReader.h -// Created by: drose (08Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageReader.h + * @author drose + * @date 2006-02-08 + */ #ifndef CYCLEDATASTAGEREADER_H #define CYCLEDATASTAGEREADER_H @@ -20,19 +19,17 @@ #include "cycleData.h" #include "pipelineCycler.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataStageReader -// Description : This class is similar to CycleDataReader, except it -// allows reading from a particular stage of the -// pipeline. -//////////////////////////////////////////////////////////////////// +/** + * This class is similar to CycleDataReader, except it allows reading from a + * particular stage of the pipeline. + */ template class CycleDataStageReader { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER - INLINE CycleDataStageReader(const PipelineCycler &cycler, + INLINE CycleDataStageReader(const PipelineCycler &cycler, int stage, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataStageReader(const CycleDataStageReader ©); INLINE void operator = (const CycleDataStageReader ©); diff --git a/panda/src/pipeline/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I index 53b7b9c6f6..ab6c53544d 100644 --- a/panda/src/pipeline/cycleDataStageWriter.I +++ b/panda/src/pipeline/cycleDataStageWriter.I @@ -1,28 +1,25 @@ -// Filename: cycleDataStageWriter.I -// Created by: drose (06Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageWriter.I + * @author drose + * @date 2006-02-06 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int stage, @@ -35,11 +32,9 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, nassertv(_pointer != (CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int stage, @@ -52,11 +47,9 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, nassertv(_pointer != (CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(const CycleDataStageWriter ©) : @@ -69,11 +62,9 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : _cycler->increment_write(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataStageWriter:: operator = (const CycleDataStageWriter ©) { @@ -88,13 +79,11 @@ operator = (const CycleDataStageWriter ©) { _cycler->increment_write(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (full) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedStageReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedStageReader from a read to a write pointer (and invalidates + * the reader). + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int stage, @@ -107,13 +96,11 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, _current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (full) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedStageReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedStageReader from a read to a write pointer (and invalidates + * the reader). + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int stage, @@ -127,11 +114,9 @@ CycleDataStageWriter(PipelineCycler &cycler, int stage, force_to_0, _current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: ~CycleDataStageWriter() { @@ -140,12 +125,9 @@ INLINE CycleDataStageWriter:: } } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE CycleDataType *CycleDataStageWriter:: operator -> () { @@ -153,12 +135,9 @@ operator -> () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataStageWriter:: operator -> () const { @@ -166,12 +145,10 @@ operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataStageWriter to be passed to any -// function that expects a CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataStageWriter to be passed to any function that + * expects a CycleDataType pointer. + */ template INLINE CycleDataStageWriter:: operator CycleDataType * () { @@ -179,12 +156,10 @@ operator CycleDataType * () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataStageWriter:: get_current_thread() const { @@ -194,33 +169,27 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &cycler, int, bool, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(const CycleDataStageWriter ©) : @@ -228,24 +197,20 @@ CycleDataStageWriter(const CycleDataStageWriter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataStageWriter:: operator = (const CycleDataStageWriter ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (trivial) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedStageReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedStageReader from a read to a write pointer (and invalidates + * the reader). + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &, int, @@ -254,13 +219,11 @@ CycleDataStageWriter(PipelineCycler &, int, { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Constructor (trivial) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedStageReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedStageReader from a read to a write pointer (and invalidates + * the reader). + */ template INLINE CycleDataStageWriter:: CycleDataStageWriter(PipelineCycler &, int, @@ -270,58 +233,46 @@ CycleDataStageWriter(PipelineCycler &, int, { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataStageWriter:: ~CycleDataStageWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE CycleDataType *CycleDataStageWriter:: operator -> () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataStageWriter:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataStageWriter to be passed to any -// function that expects a CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataStageWriter to be passed to any function that + * expects a CycleDataType pointer. + */ template INLINE CycleDataStageWriter:: operator CycleDataType * () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataStageWriter::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataStageWriter:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataStageWriter.cxx b/panda/src/pipeline/cycleDataStageWriter.cxx index b441dd978f..f45b422fb1 100644 --- a/panda/src/pipeline/cycleDataStageWriter.cxx +++ b/panda/src/pipeline/cycleDataStageWriter.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataStageWriter.cxx -// Created by: drose (06Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageWriter.cxx + * @author drose + * @date 2006-02-06 + */ #include "cycleDataStageWriter.h" diff --git a/panda/src/pipeline/cycleDataStageWriter.h b/panda/src/pipeline/cycleDataStageWriter.h index fee2d05bf8..967a367284 100644 --- a/panda/src/pipeline/cycleDataStageWriter.h +++ b/panda/src/pipeline/cycleDataStageWriter.h @@ -1,16 +1,15 @@ -// Filename: cycleDataStageWriter.h -// Created by: drose (06Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataStageWriter.h + * @author drose + * @date 2006-02-06 + */ #ifndef CYCLEDATASTAGEWRITER_H #define CYCLEDATASTAGEWRITER_H @@ -21,20 +20,18 @@ #include "pipelineCycler.h" #include "cycleDataLockedStageReader.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataStageWriter -// Description : This class is similar to CycleDataWriter, except it -// allows writing to a particular stage of the pipeline. -// Usually this is used to implement writing directly to -// an upstream pipeline value, to recompute a cached -// value there (otherwise, the cached value would go -// away with the next pipeline cycle). -//////////////////////////////////////////////////////////////////// +/** + * This class is similar to CycleDataWriter, except it allows writing to a + * particular stage of the pipeline. Usually this is used to implement + * writing directly to an upstream pipeline value, to recompute a cached value + * there (otherwise, the cached value would go away with the next pipeline + * cycle). + */ template class CycleDataStageWriter { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER INLINE CycleDataStageWriter(PipelineCycler &cycler, int stage, Thread *current_thread = Thread::get_current_thread()); diff --git a/panda/src/pipeline/cycleDataWriter.I b/panda/src/pipeline/cycleDataWriter.I index 73236fdf2d..0f0bc481eb 100644 --- a/panda/src/pipeline/cycleDataWriter.I +++ b/panda/src/pipeline/cycleDataWriter.I @@ -1,28 +1,25 @@ -// Filename: cycleDataWriter.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataWriter.I + * @author drose + * @date 2002-02-21 + */ #ifndef CPPPARSER #ifdef DO_PIPELINING -// This is the implementation for full support of pipelining (as well -// as the sanity-check only implementation). +// This is the implementation for full support of pipelining (as well as the +// sanity-check only implementation). -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, Thread *current_thread) : @@ -33,17 +30,13 @@ CycleDataWriter(PipelineCycler &cycler, Thread *current_thread) : nassertv(_pointer != (CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (full) -// Access: Public -// Description: This two-parameter constructor, with a bool parameter -// for the second parameter, automatically propagates -// the CycleData pointer upstream from the current -// stage, either stopping at the first pointer -// encountered that's different, going or all the way to -// stage 0, according to force_to_0. See -// PipelineCycler::write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * This two-parameter constructor, with a bool parameter for the second + * parameter, automatically propagates the CycleData pointer upstream from the + * current stage, either stopping at the first pointer encountered that's + * different, going or all the way to stage 0, according to force_to_0. See + * PipelineCycler::write_upstream(). + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, bool force_to_0, @@ -55,21 +48,17 @@ CycleDataWriter(PipelineCycler &cycler, bool force_to_0, nassertv(_pointer != (CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (full) -// Access: Public -// Description: This special constructor "steals" a reference count -// from the already-locked cdata object. It does not -// increment the lock count of this object, but will -// release it when the destructor is called. -// -// This is designed for special functions that return an -// already-locked cdata object and expect the caller to -// unlock it. -//////////////////////////////////////////////////////////////////// +/** + * This special constructor "steals" a reference count from the already-locked + * cdata object. It does not increment the lock count of this object, but + * will release it when the destructor is called. + * + * This is designed for special functions that return an already-locked cdata + * object and expect the caller to unlock it. + */ template INLINE CycleDataWriter:: -CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cdata, +CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cdata, Thread *current_thread) : _cycler(&cycler), _current_thread(current_thread) @@ -78,11 +67,9 @@ CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cda nassertv(_pointer != (CycleDataType *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Copy Constructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: CycleDataWriter(const CycleDataWriter ©) : @@ -94,11 +81,9 @@ CycleDataWriter(const CycleDataWriter ©) : _cycler->increment_write(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Copy Assignment (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataWriter:: operator = (const CycleDataWriter ©) { @@ -112,13 +97,11 @@ operator = (const CycleDataWriter ©) { _cycler->increment_write(_pointer); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (full) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedReader from a read to a write pointer (and invalidates the + * reader). + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, @@ -129,15 +112,12 @@ CycleDataWriter(PipelineCycler &cycler, _pointer = _cycler->elevate_read(take_from.take_pointer(), _current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (full) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedReader from a read to a write -// pointer (and invalidates the reader). It also -// propagates the pointer back upstream; see -// PipelineCycler::write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedReader from a read to a write pointer (and invalidates the + * reader). It also propagates the pointer back upstream; see + * PipelineCycler::write_upstream(). + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, @@ -146,15 +126,13 @@ CycleDataWriter(PipelineCycler &cycler, _cycler(&cycler), _current_thread(take_from.get_current_thread()) { - _pointer = _cycler->elevate_read_upstream(take_from.take_pointer(), + _pointer = _cycler->elevate_read_upstream(take_from.take_pointer(), force_to_0, _current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Destructor (full) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: ~CycleDataWriter() { @@ -163,12 +141,9 @@ INLINE CycleDataWriter:: } } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE CycleDataType *CycleDataWriter:: operator -> () { @@ -176,12 +151,9 @@ operator -> () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> (full) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataWriter:: operator -> () const { @@ -189,12 +161,10 @@ operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Typecast pointer (full) -// Access: Public -// Description: This allows the CycleDataWriter to be passed to any -// function that expects a CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataWriter to be passed to any function that expects a + * CycleDataType pointer. + */ template INLINE CycleDataWriter:: operator CycleDataType * () { @@ -202,12 +172,10 @@ operator CycleDataType * () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::get_current_thread (full) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataWriter:: get_current_thread() const { @@ -217,45 +185,37 @@ get_current_thread() const { #else // !DO_PIPELINING // This is the trivial, do-nothing implementation. -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &cycler, bool, Thread *) { _pointer = cycler.cheat(); } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: -CycleDataWriter(PipelineCycler &, CycleDataType *locked_cdata, +CycleDataWriter(PipelineCycler &, CycleDataType *locked_cdata, Thread *) { _pointer = locked_cdata; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: CycleDataWriter(const CycleDataWriter ©) : @@ -263,24 +223,20 @@ CycleDataWriter(const CycleDataWriter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CycleDataWriter:: operator = (const CycleDataWriter ©) { _pointer = copy._pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (trivial) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedReader from a read to a write -// pointer (and invalidates the reader). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedReader from a read to a write pointer (and invalidates the + * reader). + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &, @@ -289,15 +245,12 @@ CycleDataWriter(PipelineCycler &, { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor (trivial) -// Access: Public -// Description: This flavor of the constructor elevates the pointer -// from the CycleDataLockedReader from a read to a write -// pointer (and invalidates the reader). It also -// propagates the pointer back upstream; see -// PipelineCycler::write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of the constructor elevates the pointer from the + * CycleDataLockedReader from a read to a write pointer (and invalidates the + * reader). It also propagates the pointer back upstream; see + * PipelineCycler::write_upstream(). + */ template INLINE CycleDataWriter:: CycleDataWriter(PipelineCycler &, @@ -307,58 +260,46 @@ CycleDataWriter(PipelineCycler &, { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Destructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CycleDataWriter:: ~CycleDataWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE CycleDataType *CycleDataWriter:: operator -> () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> (trivial) -// Access: Public -// Description: This provides an indirect member access to the actual -// CycleData data. -//////////////////////////////////////////////////////////////////// +/** + * This provides an indirect member access to the actual CycleData data. + */ template INLINE const CycleDataType *CycleDataWriter:: operator -> () const { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Typecast pointer (trivial) -// Access: Public -// Description: This allows the CycleDataWriter to be passed to any -// function that expects a CycleDataType pointer. -//////////////////////////////////////////////////////////////////// +/** + * This allows the CycleDataWriter to be passed to any function that expects a + * CycleDataType pointer. + */ template INLINE CycleDataWriter:: operator CycleDataType * () { return _pointer; } -//////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::get_current_thread (trivial) -// Access: Public -// Description: Returns the Thread pointer of the currently-executing -// thread, as passed to the constructor of this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Thread pointer of the currently-executing thread, as passed to + * the constructor of this object. + */ template INLINE Thread *CycleDataWriter:: get_current_thread() const { diff --git a/panda/src/pipeline/cycleDataWriter.cxx b/panda/src/pipeline/cycleDataWriter.cxx index e1969b42de..2affdb34dd 100644 --- a/panda/src/pipeline/cycleDataWriter.cxx +++ b/panda/src/pipeline/cycleDataWriter.cxx @@ -1,15 +1,14 @@ -// Filename: cycleDataWriter.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataWriter.cxx + * @author drose + * @date 2002-02-21 + */ #include "cycleDataWriter.h" diff --git a/panda/src/pipeline/cycleDataWriter.h b/panda/src/pipeline/cycleDataWriter.h index 417546db71..c62f034ca3 100644 --- a/panda/src/pipeline/cycleDataWriter.h +++ b/panda/src/pipeline/cycleDataWriter.h @@ -1,16 +1,15 @@ -// Filename: cycleDataWriter.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cycleDataWriter.h + * @author drose + * @date 2002-02-21 + */ #ifndef CYCLEDATAWRITER_H #define CYCLEDATAWRITER_H @@ -22,29 +21,26 @@ #include "cycleDataLockedReader.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : CycleDataWriter -// Description : This template class calls PipelineCycler::write() in -// the constructor and PipelineCycler::release_write() in -// the destructor. In the interim, it provides a -// transparent read-write access to the CycleData. -// -// It exists as a syntactic convenience to access the -// data in the CycleData. It also allows the whole -// system to compile down to nothing if -// DO_PIPELINING is not defined. -//////////////////////////////////////////////////////////////////// +/** + * This template class calls PipelineCycler::write() in the constructor and + * PipelineCycler::release_write() in the destructor. In the interim, it + * provides a transparent read-write access to the CycleData. + * + * It exists as a syntactic convenience to access the data in the CycleData. + * It also allows the whole system to compile down to nothing if DO_PIPELINING + * is not defined. + */ template class CycleDataWriter { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER INLINE CycleDataWriter(PipelineCycler &cycler, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataWriter(PipelineCycler &cycler, bool force_to_0, Thread *current_thread = Thread::get_current_thread()); - INLINE CycleDataWriter(PipelineCycler &cycler, + INLINE CycleDataWriter(PipelineCycler &cycler, CycleDataType *locked_cdata, Thread *current_thread = Thread::get_current_thread()); INLINE CycleDataWriter(const CycleDataWriter ©); diff --git a/panda/src/pipeline/cyclerHolder.I b/panda/src/pipeline/cyclerHolder.I index 78191952ac..d9d2782373 100644 --- a/panda/src/pipeline/cyclerHolder.I +++ b/panda/src/pipeline/cyclerHolder.I @@ -1,23 +1,19 @@ -// Filename: cyclerHolder.I -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cyclerHolder.I + * @author drose + * @date 2006-02-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CyclerHolder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CyclerHolder:: CyclerHolder(PipelineCyclerBase &cycler) { #ifdef DO_PIPELINING @@ -26,11 +22,9 @@ CyclerHolder(PipelineCyclerBase &cycler) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CyclerHolder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CyclerHolder:: ~CyclerHolder() { #ifdef DO_PIPELINING @@ -38,21 +32,17 @@ INLINE CyclerHolder:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: CyclerHolder::Copy Constructor -// Access: Private -// Description: Do not attempt to copy CyclerHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy CyclerHolders. + */ INLINE CyclerHolder:: CyclerHolder(const CyclerHolder ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: CyclerHolder::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy CyclerHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy CyclerHolders. + */ INLINE void CyclerHolder:: operator = (const CyclerHolder ©) { nassertv(false); diff --git a/panda/src/pipeline/cyclerHolder.cxx b/panda/src/pipeline/cyclerHolder.cxx index b6acdd9b94..eb21a231c5 100644 --- a/panda/src/pipeline/cyclerHolder.cxx +++ b/panda/src/pipeline/cyclerHolder.cxx @@ -1,15 +1,14 @@ -// Filename: cyclerHolder.cxx -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cyclerHolder.cxx + * @author drose + * @date 2006-02-09 + */ #include "cyclerHolder.h" diff --git a/panda/src/pipeline/cyclerHolder.h b/panda/src/pipeline/cyclerHolder.h index 1d25354cab..fa5b81a30f 100644 --- a/panda/src/pipeline/cyclerHolder.h +++ b/panda/src/pipeline/cyclerHolder.h @@ -1,16 +1,15 @@ -// Filename: cyclerHolder.h -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cyclerHolder.h + * @author drose + * @date 2006-02-09 + */ #ifndef CYCLERHOLDER_H #define CYCLERHOLDER_H @@ -18,13 +17,11 @@ #include "pandabase.h" #include "pipelineCyclerBase.h" -//////////////////////////////////////////////////////////////////// -// Class : CyclerHolder -// Description : A lightweight C++ object whose constructor calls -// acquire() and whose destructor calls release() on a -// PipelineCyclerBase object. This is similar to a -// MutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * A lightweight C++ object whose constructor calls acquire() and whose + * destructor calls release() on a PipelineCyclerBase object. This is similar + * to a MutexHolder. + */ class EXPCL_PANDA_PIPELINE CyclerHolder { public: INLINE CyclerHolder(PipelineCyclerBase &cycler); diff --git a/panda/src/pipeline/externalThread.cxx b/panda/src/pipeline/externalThread.cxx index 2f4cfd9928..411c4f2062 100644 --- a/panda/src/pipeline/externalThread.cxx +++ b/panda/src/pipeline/externalThread.cxx @@ -1,54 +1,45 @@ -// Filename: externalThread.cxx -// Created by: drose (30Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file externalThread.cxx + * @author drose + * @date 2006-01-30 + */ #include "externalThread.h" TypeHandle ExternalThread::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ExternalThread::Constructor -// Access: Private -// Description: This constructor is used to create the one global -// ExternalThread object that is shared by all -// externally-created threads that are not specifically -// bound to a particular Thread object. -//////////////////////////////////////////////////////////////////// +/** + * This constructor is used to create the one global ExternalThread object + * that is shared by all externally-created threads that are not specifically + * bound to a particular Thread object. + */ ExternalThread:: ExternalThread() : Thread("External", "External") { init_type(); // in case static init comes in the wrong order _started = true; } -//////////////////////////////////////////////////////////////////// -// Function: ExternalThread::Constructor -// Access: Private -// Description: This constructor is used to create the particular -// Thread object for each external thread that is bound -// via Thread::bind_thread(). -//////////////////////////////////////////////////////////////////// +/** + * This constructor is used to create the particular Thread object for each + * external thread that is bound via Thread::bind_thread(). + */ ExternalThread:: -ExternalThread(const string &name, const string &sync_name) : +ExternalThread(const string &name, const string &sync_name) : Thread(name, sync_name) { _started = true; } - -//////////////////////////////////////////////////////////////////// -// Function: ExternalThread::thread_main -// Access: Private, Virtual -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ void ExternalThread:: thread_main() { } diff --git a/panda/src/pipeline/externalThread.h b/panda/src/pipeline/externalThread.h index 21485edf07..aaff62ac18 100644 --- a/panda/src/pipeline/externalThread.h +++ b/panda/src/pipeline/externalThread.h @@ -1,16 +1,15 @@ -// Filename: externalThread.h -// Created by: drose (30Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file externalThread.h + * @author drose + * @date 2006-01-30 + */ #ifndef EXTERNALTHREAD_H #define EXTERNALTHREAD_H @@ -18,12 +17,10 @@ #include "pandabase.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : ExternalThread -// Description : The special "external thread" class. There is one -// instance of these in the world, and it is returned by -// Thread::get_external_thread(). -//////////////////////////////////////////////////////////////////// +/** + * The special "external thread" class. There is one instance of these in the + * world, and it is returned by Thread::get_external_thread(). + */ class EXPCL_PANDA_PIPELINE ExternalThread : public Thread { private: ExternalThread(); diff --git a/panda/src/pipeline/genericThread.I b/panda/src/pipeline/genericThread.I index 094e0c04fd..11634fd226 100644 --- a/panda/src/pipeline/genericThread.I +++ b/panda/src/pipeline/genericThread.I @@ -1,58 +1,44 @@ -// Filename: genericThread.I -// Created by: drose (09Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericThread.I + * @author drose + * @date 2011-11-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::set_function -// Access: Published -// Description: Replaces the function that is called when the thread -// runs. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called when the thread runs. + */ INLINE void GenericThread:: set_function(GenericThread::ThreadFunc *function) { _function = function; } -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::get_function -// Access: Published -// Description: Returns the function that is called when the thread -// runs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called when the thread runs. + */ INLINE GenericThread::ThreadFunc *GenericThread:: get_function() const { return _function; } -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::set_user_data -// Access: Published -// Description: Replaces the void pointer that is passed to the thread -// function. This is any arbitrary pointer; the thread -// object does no processing on it. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the void pointer that is passed to the thread function. This is + * any arbitrary pointer; the thread object does no processing on it. + */ INLINE void GenericThread:: set_user_data(void *user_data) { _user_data = user_data; } -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::get_user_data -// Access: Published -// Description: Returns the void pointer that is passed to the thread -// function. -//////////////////////////////////////////////////////////////////// +/** + * Returns the void pointer that is passed to the thread function. + */ INLINE void *GenericThread:: get_user_data() const { return _user_data; diff --git a/panda/src/pipeline/genericThread.cxx b/panda/src/pipeline/genericThread.cxx index bc4e56ca29..eb1941a5e3 100644 --- a/panda/src/pipeline/genericThread.cxx +++ b/panda/src/pipeline/genericThread.cxx @@ -1,27 +1,24 @@ -// Filename: genericThread.cxx -// Created by: drose (09Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericThread.cxx + * @author drose + * @date 2011-11-09 + */ #include "genericThread.h" #include "pnotify.h" TypeHandle GenericThread::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GenericThread:: GenericThread(const string &name, const string &sync_name) : Thread(name, sync_name) @@ -30,11 +27,9 @@ GenericThread(const string &name, const string &sync_name) : _user_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GenericThread:: GenericThread(const string &name, const string &sync_name, GenericThread::ThreadFunc *function, void *user_data) : Thread(name, sync_name), @@ -43,11 +38,9 @@ GenericThread(const string &name, const string &sync_name, GenericThread::Thread { } -//////////////////////////////////////////////////////////////////// -// Function: GenericThread::thread_main -// Access: Protected, Virtual -// Description: This is the thread's main execution function. -//////////////////////////////////////////////////////////////////// +/** + * This is the thread's main execution function. + */ void GenericThread:: thread_main() { nassertv(_function != NULL); diff --git a/panda/src/pipeline/genericThread.h b/panda/src/pipeline/genericThread.h index 77e6f95a41..3e07e6a7e1 100644 --- a/panda/src/pipeline/genericThread.h +++ b/panda/src/pipeline/genericThread.h @@ -1,16 +1,15 @@ -// Filename: genericThread.h -// Created by: drose (09Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file genericThread.h + * @author drose + * @date 2011-11-09 + */ #ifndef GENERICTHREAD_H #define GENERICTHREAD_H @@ -18,11 +17,10 @@ #include "pandabase.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : GenericThread -// Description : A generic thread type that allows calling a C-style thread -// function without having to subclass. -//////////////////////////////////////////////////////////////////// +/** + * A generic thread type that allows calling a C-style thread function without + * having to subclass. + */ class EXPCL_PANDA_PIPELINE GenericThread : public Thread { public: typedef void ThreadFunc(void *user_data); @@ -64,4 +62,3 @@ private: #include "genericThread.I" #endif - diff --git a/panda/src/pipeline/lightMutex.I b/panda/src/pipeline/lightMutex.I index 7f6a3096cf..a7bb09ed17 100644 --- a/panda/src/pipeline/lightMutex.I +++ b/panda/src/pipeline/lightMutex.I @@ -1,23 +1,19 @@ -// Filename: lightMutex.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutex.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutex:: #ifdef DEBUG_THREADS LightMutex() : MutexDebug(string(), false, true) @@ -27,11 +23,9 @@ LightMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutex:: #ifdef DEBUG_THREADS LightMutex(const char *name) : MutexDebug(string(name), false, true) @@ -41,11 +35,9 @@ LightMutex(const char *) { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutex:: #ifdef DEBUG_THREADS LightMutex(const string &name) : MutexDebug(name, false, true) @@ -55,20 +47,16 @@ LightMutex(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutex:: ~LightMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Copy Constructor -// Access: Private -// Description: Do not attempt to copy lightMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightMutexes. + */ INLINE LightMutex:: #ifdef DEBUG_THREADS LightMutex(const LightMutex ©) : MutexDebug(string(), false, true) @@ -79,11 +67,9 @@ LightMutex(const LightMutex ©) : MutexDebug(string(), false, true) nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutex::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy lightMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightMutexes. + */ INLINE void LightMutex:: operator = (const LightMutex ©) { nassertv(false); diff --git a/panda/src/pipeline/lightMutex.cxx b/panda/src/pipeline/lightMutex.cxx index 7c1415a7a0..f6c23699fd 100644 --- a/panda/src/pipeline/lightMutex.cxx +++ b/panda/src/pipeline/lightMutex.cxx @@ -1,15 +1,14 @@ -// Filename: lightMutex.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutex.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightMutex.h" diff --git a/panda/src/pipeline/lightMutex.h b/panda/src/pipeline/lightMutex.h index 5cd03a90b4..ad24cfb1e8 100644 --- a/panda/src/pipeline/lightMutex.h +++ b/panda/src/pipeline/lightMutex.h @@ -1,16 +1,15 @@ -// Filename: lightMutex.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutex.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTMUTEX_H #define LIGHTMUTEX_H @@ -19,26 +18,21 @@ #include "mutexDebug.h" #include "lightMutexDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : LightMutex -// Description : This is a standard, non-reentrant mutex, similar to -// the Mutex class. It is different from Mutex in the -// case of SIMPLE_THREADS: in this case, the LightMutex -// class compiles to nothing; it performs no locking -// whatsoever. It is therefore useful only to protect -// very small sections of code, during which you are -// confident there will be no thread yields. -// -// In the normal, system-threaded implementation, this -// class is exactly the same as Mutex. -// -// ConditionVars cannot be used with LightMutex; they -// work only with Mutex. -// -// This class inherits its implementation either from -// MutexDebug or LightMutexDirect, depending on the -// definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * This is a standard, non-reentrant mutex, similar to the Mutex class. It is + * different from Mutex in the case of SIMPLE_THREADS: in this case, the + * LightMutex class compiles to nothing; it performs no locking whatsoever. + * It is therefore useful only to protect very small sections of code, during + * which you are confident there will be no thread yields. + * + * In the normal, system-threaded implementation, this class is exactly the + * same as Mutex. + * + * ConditionVars cannot be used with LightMutex; they work only with Mutex. + * + * This class inherits its implementation either from MutexDebug or + * LightMutexDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE LightMutex : public MutexDebug #else diff --git a/panda/src/pipeline/lightMutexDirect.I b/panda/src/pipeline/lightMutexDirect.I index 3222c03ef5..052ba9a8bf 100644 --- a/panda/src/pipeline/lightMutexDirect.I +++ b/panda/src/pipeline/lightMutexDirect.I @@ -1,145 +1,112 @@ -// Filename: lightMutexDirect.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexDirect.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutexDirect:: LightMutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutexDirect:: ~LightMutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy lightMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightMutexes. + */ INLINE LightMutexDirect:: LightMutexDirect(const LightMutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy lightMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightMutexes. + */ INLINE void LightMutexDirect:: operator = (const LightMutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::acquire -// Access: Published -// Description: Grabs the lightMutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the lightMutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const lightMutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see LightMutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the lightMutex if it is available. If it is not available, blocks + * until it becomes available, then grabs it. In either case, the function + * does not return until the lightMutex is held; you should then call + * unlock(). + * + * This method is considered const so that you can lock and unlock const + * lightMutexes, mainly to allow thread-safe access to otherwise const data. + * + * Also see LightMutexHolder. + */ INLINE void LightMutexDirect:: acquire() const { TAU_PROFILE("void LightMutexDirect::acquire()", " ", TAU_USER); ((LightMutexDirect *)this)->_impl.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::release -// Access: Published -// Description: Releases the lightMutex. It is an error to call this if -// the lightMutex was not already locked. -// -// This method is considered const so that you can lock -// and unlock const lightMutexes, mainly to allow thread-safe -// access to otherwise const data. -//////////////////////////////////////////////////////////////////// +/** + * Releases the lightMutex. It is an error to call this if the lightMutex was + * not already locked. + * + * This method is considered const so that you can lock and unlock const + * lightMutexes, mainly to allow thread-safe access to otherwise const data. + */ INLINE void LightMutexDirect:: release() const { TAU_PROFILE("void LightMutexDirect::release()", " ", TAU_USER); ((LightMutexDirect *)this)->_impl.release(); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::debug_is_locked -// Access: Published -// Description: Returns true if the current thread has locked the -// LightMutex, false otherwise. This method is only intended -// for use in debugging, hence the method name; in the -// LightMutexDirect case, it always returns true, since -// there's not a reliable way to determine this -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current thread has locked the LightMutex, false + * otherwise. This method is only intended for use in debugging, hence the + * method name; in the LightMutexDirect case, it always returns true, since + * there's not a reliable way to determine this otherwise. + */ INLINE bool LightMutexDirect:: debug_is_locked() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::set_name -// Access: Public -// Description: The lightMutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void LightMutexDirect:: set_name(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::clear_name -// Access: Public -// Description: The lightMutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void LightMutexDirect:: clear_name() { } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::has_name -// Access: Public -// Description: The lightMutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE bool LightMutexDirect:: has_name() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::get_name -// Access: Public -// Description: The lightMutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The lightMutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE string LightMutexDirect:: get_name() const { return string(); diff --git a/panda/src/pipeline/lightMutexDirect.cxx b/panda/src/pipeline/lightMutexDirect.cxx index 2a3e82b245..ed5d1a30ff 100644 --- a/panda/src/pipeline/lightMutexDirect.cxx +++ b/panda/src/pipeline/lightMutexDirect.cxx @@ -1,27 +1,24 @@ -// Filename: lightMutexDirect.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexDirect.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightMutexDirect.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: LightMutexDirect::output -// Access: Public -// Description: This method is declared virtual in LightMutexDebug, but -// non-virtual in LightMutexDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in LightMutexDebug, but non-virtual in + * LightMutexDirect. + */ void LightMutexDirect:: output(ostream &out) const { out << "LightMutex " << (void *)this; diff --git a/panda/src/pipeline/lightMutexDirect.h b/panda/src/pipeline/lightMutexDirect.h index bd2ee35071..e2085f6d29 100644 --- a/panda/src/pipeline/lightMutexDirect.h +++ b/panda/src/pipeline/lightMutexDirect.h @@ -1,16 +1,15 @@ -// Filename: lightMutexDirect.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexDirect.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTMUTEXDIRECT_H #define LIGHTMUTEXDIRECT_H @@ -24,12 +23,11 @@ class Thread; #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : LightMutexDirect -// Description : This class implements a lightweight Mutex by making -// direct calls to the underlying implementation layer. -// It doesn't perform any debugging operations. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a lightweight Mutex by making direct calls to the + * underlying implementation layer. It doesn't perform any debugging + * operations. + */ class EXPCL_PANDA_PIPELINE LightMutexDirect { protected: INLINE LightMutexDirect(); @@ -52,11 +50,10 @@ PUBLISHED: private: #ifdef DO_PSTATS - // When PStats is compiled in, we use the full implementation of - // LightMutex, even in the SIMPLE_THREADS case. We have to do this - // since any PStatTimer call may trigger a context switch, and any - // low-level context switch requires all containing mutexes to be - // true mutexes. + // When PStats is compiled in, we use the full implementation of LightMutex, + // even in the SIMPLE_THREADS case. We have to do this since any PStatTimer + // call may trigger a context switch, and any low-level context switch + // requires all containing mutexes to be true mutexes. MutexTrueImpl _impl; #else MutexImpl _impl; diff --git a/panda/src/pipeline/lightMutexHolder.I b/panda/src/pipeline/lightMutexHolder.I index 096f917760..392a234b29 100644 --- a/panda/src/pipeline/lightMutexHolder.I +++ b/panda/src/pipeline/lightMutexHolder.I @@ -1,23 +1,19 @@ -// Filename: lightMutexHolder.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexHolder.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightMutexHolder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutexHolder:: LightMutexHolder(const LightMutex &mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -26,17 +22,14 @@ LightMutexHolder(const LightMutex &mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexHolder::Constructor -// Access: Public -// Description: If the LightMutexHolder constructor is given a pointer to -// a LightMutex object (instead of an actual object), it will -// first check to see if the pointer is NULL, and -// allocate a new LightMutex if it is. This is intended as a -// convenience for functions that may need to reference -// a LightMutex at static init time, when it is impossible to -// guarantee ordering of initializers. -//////////////////////////////////////////////////////////////////// +/** + * If the LightMutexHolder constructor is given a pointer to a LightMutex + * object (instead of an actual object), it will first check to see if the + * pointer is NULL, and allocate a new LightMutex if it is. This is intended + * as a convenience for functions that may need to reference a LightMutex at + * static init time, when it is impossible to guarantee ordering of + * initializers. + */ INLINE LightMutexHolder:: LightMutexHolder(LightMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -48,11 +41,9 @@ LightMutexHolder(LightMutex *&mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexHolder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightMutexHolder:: ~LightMutexHolder() { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -60,21 +51,17 @@ INLINE LightMutexHolder:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexHolder::Copy Constructor -// Access: Private -// Description: Do not attempt to copy LightMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy LightMutexHolders. + */ INLINE LightMutexHolder:: LightMutexHolder(const LightMutexHolder ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightMutexHolder::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy LightMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy LightMutexHolders. + */ INLINE void LightMutexHolder:: operator = (const LightMutexHolder ©) { nassertv(false); diff --git a/panda/src/pipeline/lightMutexHolder.cxx b/panda/src/pipeline/lightMutexHolder.cxx index 61453ccb82..55ea0957b2 100644 --- a/panda/src/pipeline/lightMutexHolder.cxx +++ b/panda/src/pipeline/lightMutexHolder.cxx @@ -1,15 +1,14 @@ -// Filename: lightMutexHolder.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexHolder.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightMutexHolder.h" diff --git a/panda/src/pipeline/lightMutexHolder.h b/panda/src/pipeline/lightMutexHolder.h index 7f9ad4c41c..778ac69722 100644 --- a/panda/src/pipeline/lightMutexHolder.h +++ b/panda/src/pipeline/lightMutexHolder.h @@ -1,16 +1,15 @@ -// Filename: lightMutexHolder.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightMutexHolder.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTMUTEXHOLDER_H #define LIGHTMUTEXHOLDER_H @@ -20,10 +19,9 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : LightMutexHolder -// Description : Similar to MutexHolder, but for a light mutex. -//////////////////////////////////////////////////////////////////// +/** + * Similar to MutexHolder, but for a light mutex. + */ class EXPCL_PANDA_PIPELINE LightMutexHolder { public: INLINE LightMutexHolder(const LightMutex &mutex); diff --git a/panda/src/pipeline/lightReMutex.I b/panda/src/pipeline/lightReMutex.I index 1ace101e29..e1993f5dee 100644 --- a/panda/src/pipeline/lightReMutex.I +++ b/panda/src/pipeline/lightReMutex.I @@ -1,23 +1,19 @@ -// Filename: lightReMutex.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutex.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutex:: #ifdef DEBUG_THREADS LightReMutex() : MutexDebug(string(), true, true) @@ -27,11 +23,9 @@ LightReMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutex:: #ifdef DEBUG_THREADS LightReMutex(const char *name) : MutexDebug(string(name), true, true) @@ -41,11 +35,9 @@ LightReMutex(const char *) { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutex:: #ifdef DEBUG_THREADS LightReMutex(const string &name) : MutexDebug(name, true, true) @@ -55,20 +47,16 @@ LightReMutex(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutex::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutex:: ~LightReMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutex::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE void LightReMutex:: operator = (const LightReMutex ©) { nassertv(false); diff --git a/panda/src/pipeline/lightReMutex.cxx b/panda/src/pipeline/lightReMutex.cxx index e64f8ed730..42db21d607 100644 --- a/panda/src/pipeline/lightReMutex.cxx +++ b/panda/src/pipeline/lightReMutex.cxx @@ -1,15 +1,14 @@ -// Filename: lightReMutex.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutex.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightReMutex.h" diff --git a/panda/src/pipeline/lightReMutex.h b/panda/src/pipeline/lightReMutex.h index cc506acacb..5ae93f4faa 100644 --- a/panda/src/pipeline/lightReMutex.h +++ b/panda/src/pipeline/lightReMutex.h @@ -1,16 +1,15 @@ -// Filename: lightReMutex.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutex.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTREMUTEX_H #define LIGHTREMUTEX_H @@ -19,15 +18,12 @@ #include "mutexDebug.h" #include "lightReMutexDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : LightReMutex -// Description : A lightweight reentrant mutex. See LightMutex and -// ReMutex. -// -// This class inherits its implementation either from -// MutexDebug or LightReMutexDirect, depending on the -// definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * A lightweight reentrant mutex. See LightMutex and ReMutex. + * + * This class inherits its implementation either from MutexDebug or + * LightReMutexDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE LightReMutex : public MutexDebug #else diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I index b601e7dfcd..be78a3919e 100644 --- a/panda/src/pipeline/lightReMutexDirect.I +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -1,25 +1,21 @@ -// Filename: lightReMutexDirect.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexDirect.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutexDirect:: -LightReMutexDirect() +LightReMutexDirect() #ifndef HAVE_REMUTEXIMPL : _cvar_impl(_lock_impl) #endif @@ -30,20 +26,16 @@ LightReMutexDirect() #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutexDirect:: ~LightReMutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy lightReMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightReMutexes. + */ INLINE LightReMutexDirect:: LightReMutexDirect(const LightReMutexDirect ©) #ifndef HAVE_REMUTEXIMPL @@ -53,44 +45,35 @@ LightReMutexDirect(const LightReMutexDirect ©) nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy lightReMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy lightReMutexes. + */ INLINE void LightReMutexDirect:: operator = (const LightReMutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::acquire -// Access: Published -// Description: Grabs the lightReMutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the lightReMutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const lightReMutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see LightReMutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the lightReMutex if it is available. If it is not available, blocks + * until it becomes available, then grabs it. In either case, the function + * does not return until the lightReMutex is held; you should then call + * unlock(). + * + * This method is considered const so that you can lock and unlock const + * lightReMutexes, mainly to allow thread-safe access to otherwise const data. + * + * Also see LightReMutexHolder. + */ INLINE void LightReMutexDirect:: acquire() const { TAU_PROFILE("void LightReMutexDirect::acquire()", " ", TAU_USER); ((LightReMutexDirect *)this)->_impl.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::acquire -// Access: Published -// Description: This variant on acquire() accepts the current thread as -// a parameter, if it is already known, as an -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * This variant on acquire() accepts the current thread as a parameter, if it + * is already known, as an optimization. + */ INLINE void LightReMutexDirect:: acquire(Thread *current_thread) const { TAU_PROFILE("void LightReMutexDirect::acquire(Thread *)", " ", TAU_USER); @@ -101,21 +84,16 @@ acquire(Thread *current_thread) const { #endif // HAVE_REMUTEXIMPL } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::elevate_lock -// Access: Published -// Description: This method increments the lock count, assuming the -// calling thread already holds the lock. After this -// call, release() will need to be called one additional -// time to release the lock. -// -// This method really performs the same function as -// acquire(), but it offers a potential (slight) -// performance benefit when the calling thread knows -// that it already holds the lock. It is an error to -// call this when the calling thread does not hold the -// lock. -//////////////////////////////////////////////////////////////////// +/** + * This method increments the lock count, assuming the calling thread already + * holds the lock. After this call, release() will need to be called one + * additional time to release the lock. + * + * This method really performs the same function as acquire(), but it offers a + * potential (slight) performance benefit when the calling thread knows that + * it already holds the lock. It is an error to call this when the calling + * thread does not hold the lock. + */ INLINE void LightReMutexDirect:: elevate_lock() const { TAU_PROFILE("void LightReMutexDirect::elevate_lock()", " ", TAU_USER); @@ -126,74 +104,55 @@ elevate_lock() const { #endif // HAVE_REMUTEXIMPL } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::release -// Access: Published -// Description: Releases the lightReMutex. It is an error to call this if -// the lightReMutex was not already locked. -// -// This method is considered const so that you can lock -// and unlock const lightReMutexes, mainly to allow thread-safe -// access to otherwise const data. -//////////////////////////////////////////////////////////////////// +/** + * Releases the lightReMutex. It is an error to call this if the lightReMutex + * was not already locked. + * + * This method is considered const so that you can lock and unlock const + * lightReMutexes, mainly to allow thread-safe access to otherwise const data. + */ INLINE void LightReMutexDirect:: release() const { TAU_PROFILE("void LightReMutexDirect::release()", " ", TAU_USER); ((LightReMutexDirect *)this)->_impl.release(); } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::debug_is_locked -// Access: Published -// Description: Returns true if the current thread has locked the -// LightReMutex, false otherwise. This method is only intended -// for use in debugging, hence the method name; in the -// LightReMutexDirect case, it always returns true, since -// there's not a reliable way to determine this -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current thread has locked the LightReMutex, false + * otherwise. This method is only intended for use in debugging, hence the + * method name; in the LightReMutexDirect case, it always returns true, since + * there's not a reliable way to determine this otherwise. + */ INLINE bool LightReMutexDirect:: debug_is_locked() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::set_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void LightReMutexDirect:: set_name(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::clear_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void LightReMutexDirect:: clear_name() { } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::has_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE bool LightReMutexDirect:: has_name() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::get_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE string LightReMutexDirect:: get_name() const { return string(); diff --git a/panda/src/pipeline/lightReMutexDirect.cxx b/panda/src/pipeline/lightReMutexDirect.cxx index 6f0d682b0d..fdfcc71cd2 100644 --- a/panda/src/pipeline/lightReMutexDirect.cxx +++ b/panda/src/pipeline/lightReMutexDirect.cxx @@ -1,28 +1,25 @@ -// Filename: lightReMutexDirect.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexDirect.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightReMutexDirect.h" #include "thread.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexDirect::output -// Access: Published -// Description: This method is declared virtual in MutexDebug, but -// non-virtual in LightReMutexDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in MutexDebug, but non-virtual in + * LightReMutexDirect. + */ void LightReMutexDirect:: output(ostream &out) const { out << "LightReMutex " << (void *)this; diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h index 186c1bca0f..9daeff46a2 100644 --- a/panda/src/pipeline/lightReMutexDirect.h +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -1,16 +1,15 @@ -// Filename: lightReMutexDirect.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexDirect.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTREMUTEXDIRECT_H #define LIGHTREMUTEXDIRECT_H @@ -23,12 +22,11 @@ class Thread; #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : LightReMutexDirect -// Description : This class implements a standard lightReMutex by making -// direct calls to the underlying implementation layer. -// It doesn't perform any debugging operations. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a standard lightReMutex by making direct calls to the + * underlying implementation layer. It doesn't perform any debugging + * operations. + */ class EXPCL_PANDA_PIPELINE LightReMutexDirect { protected: INLINE LightReMutexDirect(); diff --git a/panda/src/pipeline/lightReMutexHolder.I b/panda/src/pipeline/lightReMutexHolder.I index d1106c4628..96141251d7 100644 --- a/panda/src/pipeline/lightReMutexHolder.I +++ b/panda/src/pipeline/lightReMutexHolder.I @@ -1,23 +1,19 @@ -// Filename: lightReMutexHolder.I -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexHolder.I + * @author drose + * @date 2008-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutexHolder:: LightReMutexHolder(const LightReMutex &mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -26,13 +22,10 @@ LightReMutexHolder(const LightReMutex &mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Constructor -// Access: Public -// Description: This variant on the constructor accepts the current -// thread as a parameter, if it is already known, as an -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * This variant on the constructor accepts the current thread as a parameter, + * if it is already known, as an optimization. + */ INLINE LightReMutexHolder:: LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -41,17 +34,14 @@ LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Constructor -// Access: Public -// Description: If the LightReMutexHolder constructor is given a pointer to -// a LightReMutex object (instead of an actual object), it will -// first check to see if the pointer is NULL, and -// allocate a new LightReMutex if it is. This is intended as a -// convenience for functions that may need to reference -// a LightReMutex at static init time, when it is impossible to -// guarantee ordering of initializers. -//////////////////////////////////////////////////////////////////// +/** + * If the LightReMutexHolder constructor is given a pointer to a LightReMutex + * object (instead of an actual object), it will first check to see if the + * pointer is NULL, and allocate a new LightReMutex if it is. This is + * intended as a convenience for functions that may need to reference a + * LightReMutex at static init time, when it is impossible to guarantee + * ordering of initializers. + */ INLINE LightReMutexHolder:: LightReMutexHolder(LightReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -63,11 +53,9 @@ LightReMutexHolder(LightReMutex *&mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LightReMutexHolder:: ~LightReMutexHolder() { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -75,21 +63,17 @@ INLINE LightReMutexHolder:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Copy Constructor -// Access: Private -// Description: Do not attempt to copy LightReMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy LightReMutexHolders. + */ INLINE LightReMutexHolder:: LightReMutexHolder(const LightReMutexHolder ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: LightReMutexHolder::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy LightReMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy LightReMutexHolders. + */ INLINE void LightReMutexHolder:: operator = (const LightReMutexHolder ©) { nassertv(false); diff --git a/panda/src/pipeline/lightReMutexHolder.cxx b/panda/src/pipeline/lightReMutexHolder.cxx index f5d4656153..5c58bad928 100644 --- a/panda/src/pipeline/lightReMutexHolder.cxx +++ b/panda/src/pipeline/lightReMutexHolder.cxx @@ -1,15 +1,14 @@ -// Filename: lightReMutexHolder.cxx -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexHolder.cxx + * @author drose + * @date 2008-10-08 + */ #include "lightReMutexHolder.h" diff --git a/panda/src/pipeline/lightReMutexHolder.h b/panda/src/pipeline/lightReMutexHolder.h index add59cbb74..462b22180b 100644 --- a/panda/src/pipeline/lightReMutexHolder.h +++ b/panda/src/pipeline/lightReMutexHolder.h @@ -1,16 +1,15 @@ -// Filename: lightReMutexHolder.h -// Created by: drose (08Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lightReMutexHolder.h + * @author drose + * @date 2008-10-08 + */ #ifndef LIGHTREMUTEXHOLDER_H #define LIGHTREMUTEXHOLDER_H @@ -20,10 +19,9 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : LightReMutexHolder -// Description : Similar to MutexHolder, but for a light reentrant mutex. -//////////////////////////////////////////////////////////////////// +/** + * Similar to MutexHolder, but for a light reentrant mutex. + */ class EXPCL_PANDA_PIPELINE LightReMutexHolder { public: INLINE LightReMutexHolder(const LightReMutex &mutex); diff --git a/panda/src/pipeline/mainThread.cxx b/panda/src/pipeline/mainThread.cxx index 5f82592c0b..563b8a0e32 100644 --- a/panda/src/pipeline/mainThread.cxx +++ b/panda/src/pipeline/mainThread.cxx @@ -1,38 +1,33 @@ -// Filename: mainThread.cxx -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mainThread.cxx + * @author drose + * @date 2006-01-15 + */ #include "mainThread.h" TypeHandle MainThread::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MainThread::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MainThread:: MainThread() : Thread("Main", "Main") { init_type(); // in case static init comes in the wrong order _impl.setup_main_thread(); _started = true; } - -//////////////////////////////////////////////////////////////////// -// Function: MainThread::thread_main -// Access: Private, Virtual -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ void MainThread:: thread_main() { } diff --git a/panda/src/pipeline/mainThread.h b/panda/src/pipeline/mainThread.h index f9fdb1e349..ad7f4079b2 100644 --- a/panda/src/pipeline/mainThread.h +++ b/panda/src/pipeline/mainThread.h @@ -1,16 +1,15 @@ -// Filename: mainThread.h -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mainThread.h + * @author drose + * @date 2006-01-15 + */ #ifndef MAINTHREAD_H #define MAINTHREAD_H @@ -18,12 +17,10 @@ #include "pandabase.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : MainThread -// Description : The special "main thread" class. There is one -// instance of these in the world, and it is returned by -// Thread::get_main_thread(). -//////////////////////////////////////////////////////////////////// +/** + * The special "main thread" class. There is one instance of these in the + * world, and it is returned by Thread::get_main_thread(). + */ class EXPCL_PANDA_PIPELINE MainThread : public Thread { private: MainThread(); diff --git a/panda/src/pipeline/mutexDebug.I b/panda/src/pipeline/mutexDebug.I index ab2a7e25ca..6a487bde8f 100644 --- a/panda/src/pipeline/mutexDebug.I +++ b/panda/src/pipeline/mutexDebug.I @@ -1,53 +1,42 @@ -// Filename: mutexDebug.I -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDebug.I + * @author drose + * @date 2006-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::Copy Constructor -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE MutexDebug:: MutexDebug(const MutexDebug ©) : _cvar_impl(*get_global_lock()) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE void MutexDebug:: operator = (const MutexDebug ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::acquire -// Access: Published -// Description: Grabs the mutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the mutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const mutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see MutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the mutex if it is available. If it is not available, blocks until + * it becomes available, then grabs it. In either case, the function does not + * return until the mutex is held; you should then call unlock(). + * + * This method is considered const so that you can lock and unlock const + * mutexes, mainly to allow thread-safe access to otherwise const data. + * + * Also see MutexHolder. + */ INLINE void MutexDebug:: acquire(Thread *current_thread) const { TAU_PROFILE("void MutexDebug::acquire(Thread *)", " ", TAU_USER); @@ -57,13 +46,10 @@ acquire(Thread *current_thread) const { _global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::try_acquire -// Access: Published -// Description: Returns immediately, with a true value indicating the -// mutex has been acquired, and false indicating it has -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns immediately, with a true value indicating the mutex has been + * acquired, and false indicating it has not. + */ INLINE bool MutexDebug:: try_acquire(Thread *current_thread) const { TAU_PROFILE("void MutexDebug::acquire(Thread *)", " ", TAU_USER); @@ -74,26 +60,21 @@ try_acquire(Thread *current_thread) const { return acquired; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::elevate_lock -// Access: Published -// Description: This method increments the lock count, assuming the -// calling thread already holds the lock. After this -// call, release() will need to be called one additional -// time to release the lock. -// -// This method really performs the same function as -// acquire(), but it offers a potential (slight) -// performance benefit when the calling thread knows -// that it already holds the lock. It is an error to -// call this when the calling thread does not hold the -// lock. -//////////////////////////////////////////////////////////////////// +/** + * This method increments the lock count, assuming the calling thread already + * holds the lock. After this call, release() will need to be called one + * additional time to release the lock. + * + * This method really performs the same function as acquire(), but it offers a + * potential (slight) performance benefit when the calling thread knows that + * it already holds the lock. It is an error to call this when the calling + * thread does not hold the lock. + */ INLINE void MutexDebug:: elevate_lock() const { TAU_PROFILE("void MutexDebug::elevate_lock()", " ", TAU_USER); - // You may only pass call elevate_lock() on a ReMutex--that is, to a - // mutex whose _allow_recursion flag is true. + // You may only pass call elevate_lock() on a ReMutex--that is, to a mutex + // whose _allow_recursion flag is true. nassertv(_allow_recursion); // Also, it's an error to call this if the lock is not already held. @@ -102,16 +83,13 @@ elevate_lock() const { acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::release -// Access: Published -// Description: Releases the mutex. It is an error to call this if -// the mutex was not already locked. -// -// This method is considered const so that you can lock -// and unlock const mutexes, mainly to allow thread-safe -// access to otherwise const data. -//////////////////////////////////////////////////////////////////// +/** + * Releases the mutex. It is an error to call this if the mutex was not + * already locked. + * + * This method is considered const so that you can lock and unlock const + * mutexes, mainly to allow thread-safe access to otherwise const data. + */ INLINE void MutexDebug:: release() const { TAU_PROFILE("void MutexDebug::release()", " ", TAU_USER); @@ -120,16 +98,12 @@ release() const { _global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::debug_is_locked -// Access: Published -// Description: Returns true if the current thread has locked the -// Mutex, false otherwise. This method is only intended -// for use in debugging, hence the method name; in the -// MutexDebug case, it always returns true, since -// there's not a reliable way to determine this -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current thread has locked the Mutex, false otherwise. + * This method is only intended for use in debugging, hence the method name; + * in the MutexDebug case, it always returns true, since there's not a + * reliable way to determine this otherwise. + */ INLINE bool MutexDebug:: debug_is_locked() const { TAU_PROFILE("bool MutexDebug::debug_is_locked()", " ", TAU_USER); @@ -139,15 +113,12 @@ debug_is_locked() const { return is_locked; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::get_global_lock -// Access: Private, Static -// Description: Ensures the global MutexImpl pointer has been -// created, and returns its pointer. Since this method -// is called by the MutexDebug constructor, any other -// (non-static) methods of MutexDebug may simply assume -// that the pointer has already been created. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the global MutexImpl pointer has been created, and returns its + * pointer. Since this method is called by the MutexDebug constructor, any + * other (non-static) methods of MutexDebug may simply assume that the pointer + * has already been created. + */ INLINE MutexTrueImpl *MutexDebug:: get_global_lock() { if (_global_lock == (MutexTrueImpl *)NULL) { diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index 8e376b8147..d22a923694 100644 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -1,16 +1,15 @@ -// Filename: mutexDebug.cxx -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDebug.cxx + * @author drose + * @date 2006-02-13 + */ #include "mutexDebug.h" #include "thread.h" @@ -21,11 +20,9 @@ int MutexDebug::_pstats_count = 0; MutexTrueImpl *MutexDebug::_global_lock; -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MutexDebug:: MutexDebug(const string &name, bool allow_recursion, bool lightweight) : Namable(name), @@ -37,24 +34,22 @@ MutexDebug(const string &name, bool allow_recursion, bool lightweight) : _cvar_impl(*get_global_lock()) { #ifndef SIMPLE_THREADS - // If we're using real threads, there's no such thing as a - // lightweight mutex. + // If we're using real threads, there's no such thing as a lightweight + // mutex. _lightweight = false; #endif } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::Destructor -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MutexDebug:: ~MutexDebug() { nassertv(_locking_thread == NULL && _lock_count == 0); - // If the config variable says to, allocate (and leak) a string name - // for the mutex, so we can report which mutex it is that has - // destructed after the fact. + // If the config variable says to, allocate (and leak) a string name for the + // mutex, so we can report which mutex it is that has destructed after the + // fact. if (name_deleted_mutexes) { ostringstream strm; strm << *this; @@ -62,17 +57,15 @@ MutexDebug:: _deleted_name = strdup((char *)name.c_str()); } - // Put a distinctive, bogus lock count in upon destruction, so we'll - // be more likely to notice a floating pointer. + // Put a distinctive, bogus lock count in upon destruction, so we'll be more + // likely to notice a floating pointer. _lock_count = -100; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::output -// Access: Public, Virtual -// Description: This method is declared virtual in MutexDebug, but -// non-virtual in MutexDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in MutexDebug, but non-virtual in + * MutexDirect. + */ void MutexDebug:: output(ostream &out) const { if (_lightweight) { @@ -85,12 +78,10 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::output_with_holder -// Access: Public -// Description: Reports the mutex as well as the thread that is -// currently holding it, if any. -//////////////////////////////////////////////////////////////////// +/** + * Reports the mutex as well as the thread that is currently holding it, if + * any. + */ void MutexDebug:: output_with_holder(ostream &out) const { _global_lock->acquire(); @@ -101,15 +92,11 @@ output_with_holder(ostream &out) const { _global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::increment_pstats -// Access: Public, Static -// Description: Intended to be called only by -// PStatClientImpl::client_connect(), this tells the -// global mutex system that PStats is active. Once -// PStats is active, all "light" mutexes are treated the -// same as full mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called only by PStatClientImpl::client_connect(), this tells + * the global mutex system that PStats is active. Once PStats is active, all + * "light" mutexes are treated the same as full mutexes. + */ void MutexDebug:: increment_pstats() { _global_lock->acquire(); @@ -117,13 +104,10 @@ increment_pstats() { _global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::decrement_pstats -// Access: Public, Static -// Description: Intended to be called only by -// PStatClientImpl::client_disconnect(), this tells the -// global mutex system that PStats is no longer active. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called only by PStatClientImpl::client_disconnect(), this + * tells the global mutex system that PStats is no longer active. + */ void MutexDebug:: decrement_pstats() { _global_lock->acquire(); @@ -131,16 +115,13 @@ decrement_pstats() { _global_lock->release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::do_acquire -// Access: Private -// Description: The private implementation of acquire() assumes that -// _lock_impl is held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire() assumes that _lock_impl is held. + */ void MutexDebug:: do_acquire(Thread *current_thread) { - // If this assertion is triggered, you tried to lock a - // recently-destructed mutex. + // If this assertion is triggered, you tried to lock a recently-destructed + // mutex. nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; @@ -161,8 +142,7 @@ do_acquire(Thread *current_thread) { nassertv(_lock_count == 1); } else if (_locking_thread == current_thread) { - // The mutex is already locked by this thread. Increment the lock - // count. + // The mutex is already locked by this thread. Increment the lock count. nassertv(_lock_count > 0); if (!_allow_recursion) { ostringstream ostr; @@ -207,42 +187,42 @@ do_acquire(Thread *current_thread) { } Thread *next_thread = next_mutex->_locking_thread; if (next_thread == NULL) { - // Looks like this mutex isn't actually locked, which means - // the last thread isn't really blocked--it just hasn't woken - // up yet to discover that. In any case, no deadlock. + // Looks like this mutex isn't actually locked, which means the last + // thread isn't really blocked--it just hasn't woken up yet to + // discover that. In any case, no deadlock. break; } - - // The last thread is blocked on this "next thread"'s mutex, but - // what mutex is the next thread blocked on? + + // The last thread is blocked on this "next thread"'s mutex, but what + // mutex is the next thread blocked on? next_mutex = next_thread->_blocked_on_mutex; } - + // OK, no deadlock detected. Carry on. current_thread->_blocked_on_mutex = this; - + // Go to sleep on the condition variable until it's unlocked. - + if (thread_cat->is_debug()) { thread_cat.debug() << *current_thread << " blocking on " << *this << " (held by " << *_locking_thread << ")\n"; } - + while (_locking_thread != (Thread *)NULL) { thread_cat.debug() << *current_thread << " still blocking on " << *this << " (held by " << *_locking_thread << ")\n"; _cvar_impl.wait(); } - + if (thread_cat.is_debug()) { thread_cat.debug() << *current_thread << " acquired " << *this << "\n"; } - + current_thread->_blocked_on_mutex = NULL; - + _locking_thread = current_thread; ++_lock_count; nassertv(_lock_count == 1); @@ -250,16 +230,14 @@ do_acquire(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::do_try_acquire -// Access: Private -// Description: The private implementation of acquire(false) assumes -// that _lock_impl is held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(false) assumes that _lock_impl is + * held. + */ bool MutexDebug:: do_try_acquire(Thread *current_thread) { - // If this assertion is triggered, you tried to lock a - // recently-destructed mutex. + // If this assertion is triggered, you tried to lock a recently-destructed + // mutex. nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; @@ -281,8 +259,7 @@ do_try_acquire(Thread *current_thread) { nassertr(_lock_count == 1, false); } else if (_locking_thread == current_thread) { - // The mutex is already locked by this thread. Increment the lock - // count. + // The mutex is already locked by this thread. Increment the lock count. nassertr(_lock_count > 0, false); if (!_allow_recursion) { // Non-recursive lock; return false. @@ -320,16 +297,13 @@ do_try_acquire(Thread *current_thread) { return acquired; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::do_release -// Access: Private -// Description: The private implementation of acquire() assumes that -// _lock_impl is held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire() assumes that _lock_impl is held. + */ void MutexDebug:: do_release() { - // If this assertion is triggered, you tried to release a - // recently-destructed mutex. + // If this assertion is triggered, you tried to release a recently- + // destructed mutex. nassertd(_lock_count != -100) { pipeline_cat.error() << "Destructed mutex: " << (void *)this << "\n"; @@ -349,14 +323,14 @@ do_release() { // We're not holding this mutex. if (_lightweight) { - // Not a real mutex. This just means we blew past a mutex - // without locking it, above. + // Not a real mutex. This just means we blew past a mutex without + // locking it, above. MissedThreads::iterator mi = _missed_threads.find(current_thread); nassertv(mi != _missed_threads.end()); nassertv((*mi).second > 0); --((*mi).second); - + if ((*mi).second == 0) { _missed_threads.erase(mi); } @@ -400,12 +374,10 @@ do_release() { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::do_debug_is_locked -// Access: Private -// Description: The private implementation of debug_is_locked() -// assumes that _lock_impl is held. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of debug_is_locked() assumes that _lock_impl is + * held. + */ bool MutexDebug:: do_debug_is_locked() const { Thread *current_thread = Thread::get_current_thread(); @@ -424,12 +396,9 @@ do_debug_is_locked() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDebug::report_deadlock -// Access: Private -// Description: Reports a detected deadlock situation. _lock_impl -// should be already held. -//////////////////////////////////////////////////////////////////// +/** + * Reports a detected deadlock situation. _lock_impl should be already held. + */ void MutexDebug:: report_deadlock(Thread *current_thread) { thread_cat->error() @@ -455,7 +424,7 @@ report_deadlock(Thread *current_thread) { next_mutex = next_thread->_blocked_on_mutex; } - thread_cat.error() + thread_cat.error() << "Deadlock!\n"; } diff --git a/panda/src/pipeline/mutexDebug.h b/panda/src/pipeline/mutexDebug.h index 502104d994..24b8b6500f 100644 --- a/panda/src/pipeline/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -1,16 +1,15 @@ -// Filename: mutexDebug.h -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDebug.h + * @author drose + * @date 2006-02-13 + */ #ifndef MUTEXDEBUG_H #define MUTEXDEBUG_H @@ -24,12 +23,10 @@ #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : MutexDebug -// Description : This class implements a standard mutex the hard way, -// by doing everything by hand. This does allow fancy -// things like deadlock detection, however. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a standard mutex the hard way, by doing everything by + * hand. This does allow fancy things like deadlock detection, however. + */ class EXPCL_PANDA_PIPELINE MutexDebug : public Namable { protected: MutexDebug(const string &name, bool allow_recursion, bool lightweight); diff --git a/panda/src/pipeline/mutexDirect.I b/panda/src/pipeline/mutexDirect.I index 16c93aa394..0fb8c8b954 100644 --- a/panda/src/pipeline/mutexDirect.I +++ b/panda/src/pipeline/mutexDirect.I @@ -1,158 +1,121 @@ -// Filename: mutexDirect.I -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDirect.I + * @author drose + * @date 2006-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexDirect:: MutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexDirect:: ~MutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE MutexDirect:: MutexDirect(const MutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE void MutexDirect:: operator = (const MutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::acquire -// Access: Published -// Description: Grabs the mutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the mutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const mutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see MutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the mutex if it is available. If it is not available, blocks until + * it becomes available, then grabs it. In either case, the function does not + * return until the mutex is held; you should then call unlock(). + * + * This method is considered const so that you can lock and unlock const + * mutexes, mainly to allow thread-safe access to otherwise const data. + * + * Also see MutexHolder. + */ INLINE void MutexDirect:: acquire() const { TAU_PROFILE("void MutexDirect::acquire()", " ", TAU_USER); ((MutexDirect *)this)->_impl.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::try_acquire -// Access: Published -// Description: Returns immediately, with a true value indicating the -// mutex has been acquired, and false indicating it has -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns immediately, with a true value indicating the mutex has been + * acquired, and false indicating it has not. + */ INLINE bool MutexDirect:: try_acquire() const { TAU_PROFILE("void MutexDirect::acquire(bool)", " ", TAU_USER); return ((MutexDirect *)this)->_impl.try_acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::release -// Access: Published -// Description: Releases the mutex. It is an error to call this if -// the mutex was not already locked. -// -// This method is considered const so that you can lock -// and unlock const mutexes, mainly to allow thread-safe -// access to otherwise const data. -//////////////////////////////////////////////////////////////////// +/** + * Releases the mutex. It is an error to call this if the mutex was not + * already locked. + * + * This method is considered const so that you can lock and unlock const + * mutexes, mainly to allow thread-safe access to otherwise const data. + */ INLINE void MutexDirect:: release() const { TAU_PROFILE("void MutexDirect::release()", " ", TAU_USER); ((MutexDirect *)this)->_impl.release(); } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::debug_is_locked -// Access: Published -// Description: Returns true if the current thread has locked the -// Mutex, false otherwise. This method is only intended -// for use in debugging, hence the method name; in the -// MutexDirect case, it always returns true, since -// there's not a reliable way to determine this -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current thread has locked the Mutex, false otherwise. + * This method is only intended for use in debugging, hence the method name; + * in the MutexDirect case, it always returns true, since there's not a + * reliable way to determine this otherwise. + */ INLINE bool MutexDirect:: debug_is_locked() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::set_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void MutexDirect:: set_name(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::clear_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void MutexDirect:: clear_name() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::has_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE bool MutexDirect:: has_name() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::get_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE string MutexDirect:: get_name() const { return string(); diff --git a/panda/src/pipeline/mutexDirect.cxx b/panda/src/pipeline/mutexDirect.cxx index b9a25146c1..5f74c67c93 100644 --- a/panda/src/pipeline/mutexDirect.cxx +++ b/panda/src/pipeline/mutexDirect.cxx @@ -1,27 +1,24 @@ -// Filename: mutexDirect.cxx -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDirect.cxx + * @author drose + * @date 2006-02-13 + */ #include "mutexDirect.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: MutexDirect::output -// Access: Public -// Description: This method is declared virtual in MutexDebug, but -// non-virtual in MutexDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in MutexDebug, but non-virtual in + * MutexDirect. + */ void MutexDirect:: output(ostream &out) const { out << "Mutex " << (void *)this; diff --git a/panda/src/pipeline/mutexDirect.h b/panda/src/pipeline/mutexDirect.h index 4954cb3588..494c067a12 100644 --- a/panda/src/pipeline/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -1,16 +1,15 @@ -// Filename: mutexDirect.h -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexDirect.h + * @author drose + * @date 2006-02-13 + */ #ifndef MUTEXDIRECT_H #define MUTEXDIRECT_H @@ -23,12 +22,11 @@ class Thread; #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : MutexDirect -// Description : This class implements a standard mutex by making -// direct calls to the underlying implementation layer. -// It doesn't perform any debugging operations. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a standard mutex by making direct calls to the + * underlying implementation layer. It doesn't perform any debugging + * operations. + */ class EXPCL_PANDA_PIPELINE MutexDirect { protected: INLINE MutexDirect(); diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index 560add49ab..9b1b99d6b6 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -1,23 +1,19 @@ -// Filename: mutexHolder.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexHolder.I + * @author drose + * @date 2002-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexHolder:: MutexHolder(const Mutex &mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -26,36 +22,28 @@ MutexHolder(const Mutex &mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Constructor -// Access: Public -// Description: This variant on the constructor accepts the current -// thread as a parameter, if it is already known, as an -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * This variant on the constructor accepts the current thread as a parameter, + * if it is already known, as an optimization. + */ INLINE MutexHolder:: MutexHolder(const Mutex &mutex, Thread *current_thread) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex = &mutex; // Actually, the regular Mutex class doesn't need the current thread - // parameter at the moment. So not actually an optimization. But - // we keep this method because it causes a symmetry with - // ReMutexHolder. + // parameter at the moment. So not actually an optimization. But we keep + // this method because it causes a symmetry with ReMutexHolder. _mutex->acquire(/*current_thread*/); #endif } -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Constructor -// Access: Public -// Description: If the MutexHolder constructor is given a pointer to -// a Mutex object (instead of an actual object), it will -// first check to see if the pointer is NULL, and -// allocate a new Mutex if it is. This is intended as a -// convenience for functions that may need to reference -// a Mutex at static init time, when it is impossible to -// guarantee ordering of initializers. -//////////////////////////////////////////////////////////////////// +/** + * If the MutexHolder constructor is given a pointer to a Mutex object + * (instead of an actual object), it will first check to see if the pointer is + * NULL, and allocate a new Mutex if it is. This is intended as a convenience + * for functions that may need to reference a Mutex at static init time, when + * it is impossible to guarantee ordering of initializers. + */ INLINE MutexHolder:: MutexHolder(Mutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -67,11 +55,9 @@ MutexHolder(Mutex *&mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexHolder:: ~MutexHolder() { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -79,21 +65,17 @@ INLINE MutexHolder:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Copy Constructor -// Access: Private -// Description: Do not attempt to copy MutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy MutexHolders. + */ INLINE MutexHolder:: MutexHolder(const MutexHolder ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MutexHolder::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy MutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy MutexHolders. + */ INLINE void MutexHolder:: operator = (const MutexHolder ©) { nassertv(false); diff --git a/panda/src/pipeline/mutexHolder.cxx b/panda/src/pipeline/mutexHolder.cxx index 18b9b944a4..bf13c98f8b 100644 --- a/panda/src/pipeline/mutexHolder.cxx +++ b/panda/src/pipeline/mutexHolder.cxx @@ -1,15 +1,14 @@ -// Filename: mutexHolder.cxx -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexHolder.cxx + * @author drose + * @date 2002-08-09 + */ #include "mutexHolder.h" diff --git a/panda/src/pipeline/mutexHolder.h b/panda/src/pipeline/mutexHolder.h index 1147957ff6..26f1af5d9d 100644 --- a/panda/src/pipeline/mutexHolder.h +++ b/panda/src/pipeline/mutexHolder.h @@ -1,16 +1,15 @@ -// Filename: mutexHolder.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexHolder.h + * @author drose + * @date 2002-08-09 + */ #ifndef MUTEXHOLDER_H #define MUTEXHOLDER_H @@ -18,14 +17,11 @@ #include "pandabase.h" #include "pmutex.h" -//////////////////////////////////////////////////////////////////// -// Class : MutexHolder -// Description : A lightweight C++ object whose constructor calls -// acquire() and whose destructor calls release() on a -// mutex. It is a C++ convenience wrapper to call -// release() automatically when a block exits (for -// instance, on return). -//////////////////////////////////////////////////////////////////// +/** + * A lightweight C++ object whose constructor calls acquire() and whose + * destructor calls release() on a mutex. It is a C++ convenience wrapper to + * call release() automatically when a block exits (for instance, on return). + */ class EXPCL_PANDA_PIPELINE MutexHolder { public: INLINE MutexHolder(const Mutex &mutex); @@ -37,10 +33,10 @@ private: INLINE void operator = (const MutexHolder ©); private: - // If HAVE_THREADS is defined, the Mutex class implements an actual - // mutex object of some kind. If HAVE_THREADS is not defined, this - // will be a MutexDummyImpl, which does nothing much anyway, so we - // might as well not even store a pointer to one. + // If HAVE_THREADS is defined, the Mutex class implements an actual mutex + // object of some kind. If HAVE_THREADS is not defined, this will be a + // MutexDummyImpl, which does nothing much anyway, so we might as well not + // even store a pointer to one. #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) const Mutex *_mutex; #endif diff --git a/panda/src/pipeline/mutexSimpleImpl.I b/panda/src/pipeline/mutexSimpleImpl.I index e2defec726..82b3f5fa51 100644 --- a/panda/src/pipeline/mutexSimpleImpl.I +++ b/panda/src/pipeline/mutexSimpleImpl.I @@ -1,41 +1,33 @@ -// Filename: mutexSimpleImpl.I -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSimpleImpl.I + * @author drose + * @date 2007-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexSimpleImpl:: MutexSimpleImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MutexSimpleImpl:: ~MutexSimpleImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MutexSimpleImpl:: acquire() { if (!try_acquire()) { @@ -43,11 +35,9 @@ acquire() { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::try_acquire -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MutexSimpleImpl:: try_acquire() { if ((_flags & F_lock_count) != 0) { @@ -57,12 +47,10 @@ try_acquire() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::release -// Access: Public -// Description: Releases the mutex. An immediate context switch -// might occur if there were waiters on the mutex. -//////////////////////////////////////////////////////////////////// +/** + * Releases the mutex. An immediate context switch might occur if there were + * waiters on the mutex. + */ INLINE void MutexSimpleImpl:: release() { nassertv((_flags & F_lock_count) != 0); @@ -73,12 +61,9 @@ release() { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::release_quietly -// Access: Public -// Description: Releases the mutex, without allowing a context switch -// to occur. -//////////////////////////////////////////////////////////////////// +/** + * Releases the mutex, without allowing a context switch to occur. + */ INLINE void MutexSimpleImpl:: release_quietly() { nassertv((_flags & F_lock_count) != 0); diff --git a/panda/src/pipeline/mutexSimpleImpl.cxx b/panda/src/pipeline/mutexSimpleImpl.cxx index 62d603141c..0908104ae7 100644 --- a/panda/src/pipeline/mutexSimpleImpl.cxx +++ b/panda/src/pipeline/mutexSimpleImpl.cxx @@ -1,16 +1,15 @@ -// Filename: mutexSimpleImpl.cxx -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSimpleImpl.cxx + * @author drose + * @date 2007-06-19 + */ #include "selectThreadImpl.h" @@ -20,15 +19,13 @@ #include "threadSimpleImpl.h" #include "threadSimpleManager.h" -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::do_acquire -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MutexSimpleImpl:: do_acquire() { - // By the time we get here, we already know that someone else is - // holding the lock: (_flags & F_lock_count) != 0. + // By the time we get here, we already know that someone else is holding the + // lock: (_flags & F_lock_count) != 0. ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); ThreadSimpleImpl *thread = manager->get_current_thread(); @@ -36,19 +33,17 @@ do_acquire() { manager->enqueue_block(thread, this); manager->next_context(); } - + _flags |= F_lock_count; } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::do_release -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MutexSimpleImpl:: do_release() { - // By the time we get here, we already know that someone else is - // blocked on this mutex: (_flags & F_waiters) != 0. + // By the time we get here, we already know that someone else is blocked on + // this mutex: (_flags & F_waiters) != 0. ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); if (manager->unblock_one(this)) { // There had been a thread waiting on this mutex. Switch contexts @@ -59,11 +54,9 @@ do_release() { } } -//////////////////////////////////////////////////////////////////// -// Function: MutexSimpleImpl::do_release_quietly -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MutexSimpleImpl:: do_release_quietly() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); diff --git a/panda/src/pipeline/mutexSimpleImpl.h b/panda/src/pipeline/mutexSimpleImpl.h index 929613bb8e..60b5bc56b1 100644 --- a/panda/src/pipeline/mutexSimpleImpl.h +++ b/panda/src/pipeline/mutexSimpleImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexSimpleImpl.h -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexSimpleImpl.h + * @author drose + * @date 2007-06-19 + */ #ifndef MUTEXSIMPLEIMPL_H #define MUTEXSIMPLEIMPL_H @@ -23,24 +22,18 @@ #include "blockerSimple.h" #include "threadSimpleImpl.h" -//////////////////////////////////////////////////////////////////// -// Class : MutexSimpleImpl -// Description : This is the mutex implementation for the simple, -// simulated threads case. It's designed to be as -// lightweight as possible, of course. This -// implementation simply yields the thread when the -// mutex would block. -// -// We can't define this class in dtoolbase along with -// the other mutex implementations, because this -// implementation requires knowing about the -// SimpleThreadManager. This complicates the -// MutexDirect and MutexDebug definitions (we have to -// define a MutexImpl, for code before pipeline to -// use--which maps to MutexDummyImpl--and a -// MutexTrueImpl, for code after pipeline to use--which -// maps to this class, MutexSimpleImpl). -//////////////////////////////////////////////////////////////////// +/** + * This is the mutex implementation for the simple, simulated threads case. + * It's designed to be as lightweight as possible, of course. This + * implementation simply yields the thread when the mutex would block. + * + * We can't define this class in dtoolbase along with the other mutex + * implementations, because this implementation requires knowing about the + * SimpleThreadManager. This complicates the MutexDirect and MutexDebug + * definitions (we have to define a MutexImpl, for code before pipeline to use + * --which maps to MutexDummyImpl--and a MutexTrueImpl, for code after + * pipeline to use--which maps to this class, MutexSimpleImpl). + */ class EXPCL_PANDA_PIPELINE MutexSimpleImpl : public BlockerSimple { public: INLINE MutexSimpleImpl(); diff --git a/panda/src/pipeline/mutexTrueImpl.h b/panda/src/pipeline/mutexTrueImpl.h index 7c6e8dbe50..2366159a38 100644 --- a/panda/src/pipeline/mutexTrueImpl.h +++ b/panda/src/pipeline/mutexTrueImpl.h @@ -1,16 +1,15 @@ -// Filename: mutexTrueImpl.h -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mutexTrueImpl.h + * @author drose + * @date 2007-06-19 + */ #ifndef MUTEXTRUEIMPL_H #define MUTEXTRUEIMPL_H @@ -18,20 +17,19 @@ #include "pandabase.h" #include "mutexImpl.h" -// The MutexTrueImpl typedef is given here in the pipeline directory, -// and is used to implement Mutex and ReMutex (and, therefore, any -// downstream Mutex implementation). +// The MutexTrueImpl typedef is given here in the pipeline directory, and is +// used to implement Mutex and ReMutex (and, therefore, any downstream Mutex +// implementation). -// This is slightly different from the MutexImpl typedef, which is -// given up in dtoolbase, and is used standalone anywhere very -// low-level code needs to protect itself from mutual exclusion. +// This is slightly different from the MutexImpl typedef, which is given up in +// dtoolbase, and is used standalone anywhere very low-level code needs to +// protect itself from mutual exclusion. -// The only difference between the two is in the case of -// THREAD_SIMPLE_IMPL. In this case, MutexImpl maps to -// MutexDummyImpl, while MutexTrueImpl maps to MutexSimpleImpl. This -// distinction is necessary because we cannot define MutexSimpleImpl -// until we have defined the whole ThreadSimpleManager and related -// infrastructure. +// The only difference between the two is in the case of THREAD_SIMPLE_IMPL. +// In this case, MutexImpl maps to MutexDummyImpl, while MutexTrueImpl maps to +// MutexSimpleImpl. This distinction is necessary because we cannot define +// MutexSimpleImpl until we have defined the whole ThreadSimpleManager and +// related infrastructure. #ifdef THREAD_SIMPLE_IMPL @@ -52,6 +50,3 @@ typedef ReMutexImpl ReMutexTrueImpl; #endif // THREAD_SIMPLE_IMPL #endif - - - diff --git a/panda/src/pipeline/pipeline.I b/panda/src/pipeline/pipeline.I index 9e688c1016..8eedc7b363 100644 --- a/panda/src/pipeline/pipeline.I +++ b/panda/src/pipeline/pipeline.I @@ -1,23 +1,19 @@ -// Filename: pipeline.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeline.I + * @author drose + * @date 2002-02-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::get_render_pipeline -// Access: Public, Static -// Description: Returns a pointer to the global render pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global render pipeline. + */ INLINE Pipeline *Pipeline:: get_render_pipeline() { if (_render_pipeline == (Pipeline *)NULL) { @@ -26,35 +22,27 @@ get_render_pipeline() { return _render_pipeline; } -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::set_min_stages -// Access: Public -// Description: Ensures that at least the indicated number of stages -// are in the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that at least the indicated number of stages are in the pipeline. + */ INLINE void Pipeline:: set_min_stages(int min_stages) { set_num_stages(max(min_stages, get_num_stages())); } -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::get_num_stages -// Access: Public -// Description: Returns the number of stages required for the -// pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages required for the pipeline. + */ INLINE int Pipeline:: get_num_stages() const { return _num_stages; } #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::get_num_cyclers -// Access: Public -// Description: Returns the number of PipelineCyclers in the universe -// that reference this Pipeline object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of PipelineCyclers in the universe that reference this + * Pipeline object. + */ INLINE int Pipeline:: get_num_cyclers() const { ReMutexHolder holder(_lock); @@ -63,18 +51,14 @@ get_num_cyclers() const { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::get_num_dirty_cyclers -// Access: Public -// Description: Returns the number of PipelineCyclers in the universe -// that reference this Pipeline object and are currently -// marked "dirty"; that is, there is a difference in -// pointer value between some of their stages. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of PipelineCyclers in the universe that reference this + * Pipeline object and are currently marked "dirty"; that is, there is a + * difference in pointer value between some of their stages. + */ INLINE int Pipeline:: get_num_dirty_cyclers() const { ReMutexHolder holder(_lock); return _num_dirty_cyclers; } #endif // THREADED_PIPELINE - diff --git a/panda/src/pipeline/pipeline.cxx b/panda/src/pipeline/pipeline.cxx index 781b6f6a13..b62d45519f 100644 --- a/panda/src/pipeline/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -1,16 +1,15 @@ -// Filename: pipeline.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeline.cxx + * @author drose + * @date 2002-02-21 + */ #include "pipeline.h" #include "pipelineCyclerTrueImpl.h" @@ -20,11 +19,9 @@ Pipeline *Pipeline::_render_pipeline = (Pipeline *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Pipeline:: Pipeline(const string &name, int num_stages) : Namable(name) @@ -34,22 +31,22 @@ Pipeline(const string &name, int num_stages) : { #ifdef THREADED_PIPELINE - // We maintain all of the cyclers in the world on one of two linked - // lists. Cyclers that are "clean", which is to say, they have the - // same value across all pipeline stages, are stored on the _clean - // list. Cyclers that are "dirty", which have different values - // across some pipeline stages, are stored instead on the _dirty - // list. Cyclers can move themselves from clean to dirty by calling - // add_dirty_cycler(), and cyclers get moved from dirty to clean - // during cycle(). +/* + * We maintain all of the cyclers in the world on one of two linked lists. + * Cyclers that are "clean", which is to say, they have the same value across + * all pipeline stages, are stored on the _clean list. Cyclers that are + * "dirty", which have different values across some pipeline stages, are + * stored instead on the _dirty list. Cyclers can move themselves from clean + * to dirty by calling add_dirty_cycler(), and cyclers get moved from dirty to + * clean during cycle(). + */ // To visit each cycler once requires traversing both lists. _clean.make_head(); _dirty.make_head(); // We also store the total count of all cyclers, clean and dirty, in - // _num_cyclers; and the count of only dirty cyclers in - // _num_dirty_cyclers. + // _num_cyclers; and the count of only dirty cyclers in _num_dirty_cyclers. _num_cyclers = 0; _num_dirty_cyclers = 0; @@ -61,11 +58,9 @@ Pipeline(const string &name, int num_stages) : set_num_stages(num_stages); } -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Pipeline:: ~Pipeline() { #ifdef THREADED_PIPELINE @@ -77,11 +72,9 @@ Pipeline:: #endif // THREADED_PIPELINE } -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::cycle -// Access: Public -// Description: Flows all the pipeline data down to the next stage. -//////////////////////////////////////////////////////////////////// +/** + * Flows all the pipeline data down to the next stage. + */ void Pipeline:: cycle() { #ifdef THREADED_PIPELINE @@ -99,10 +92,10 @@ cycle() { nassertv(_dirty._next == &_dirty); return; } - + nassertv(!_cycling); _cycling = true; - + // Move the dirty list to prev_dirty, for processing. PipelineCyclerLinks prev_dirty; prev_dirty.make_head(); @@ -115,15 +108,15 @@ cycle() { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)prev_dirty._next; cycler->remove_from_list(); ReMutexHolder holder2(cycler->_lock); - - // We save the result of cycle(), so that we can defer the - // side-effects that might occur when CycleDatas destruct, at - // least until the end of this loop. + + // We save the result of cycle(), so that we can defer the side- + // effects that might occur when CycleDatas destruct, at least until + // the end of this loop. saved_cdatas.push_back(cycler->cycle_2()); - + if (cycler->_dirty) { - // The cycler is still dirty after cycling. Keep it on the - // dirty list for next time. + // The cycler is still dirty after cycling. Keep it on the dirty + // list for next time. cycler->insert_before(&_dirty); ++_num_dirty_cyclers; } else { @@ -141,9 +134,9 @@ cycle() { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)prev_dirty._next; cycler->remove_from_list(); ReMutexHolder holder2(cycler->_lock); - + saved_cdatas.push_back(cycler->cycle_3()); - + if (cycler->_dirty) { cycler->insert_before(&_dirty); ++_num_dirty_cyclers; @@ -161,9 +154,9 @@ cycle() { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)prev_dirty._next; cycler->remove_from_list(); ReMutexHolder holder2(cycler->_lock); - + saved_cdatas.push_back(cycler->cycle()); - + if (cycler->_dirty) { cycler->insert_before(&_dirty); ++_num_dirty_cyclers; @@ -176,16 +169,16 @@ cycle() { } break; } - + // Now we're ready for the next frame. prev_dirty.clear_head(); _cycling = false; } - // And now it's safe to let the CycleData pointers in saved_cdatas - // destruct, which may cause cascading deletes, and which will in - // turn cause PipelineCyclers to remove themselves from (or add - // themselves to) the _dirty list. + // And now it's safe to let the CycleData pointers in saved_cdatas destruct, + // which may cause cascading deletes, and which will in turn cause + // PipelineCyclers to remove themselves from (or add themselves to) the + // _dirty list. saved_cdatas.clear(); if (pipeline_cat.is_debug()) { @@ -196,12 +189,9 @@ cycle() { #endif // THREADED_PIPELINE } -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::set_num_stages -// Access: Public -// Description: Specifies the number of stages required for the -// pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of stages required for the pipeline. + */ void Pipeline:: set_num_stages(int num_stages) { nassertv(num_stages >= 1); @@ -209,8 +199,8 @@ set_num_stages(int num_stages) { ReMutexHolder holder(_lock); if (num_stages != _num_stages) { - // We need to lock every PipelineCycler object attached to this - // pipeline before we can adjust the number of stages. + // We need to lock every PipelineCycler object attached to this pipeline + // before we can adjust the number of stages. PipelineCyclerLinks *links; for (links = _clean._next; links != &_clean; links = links->_next) { PipelineCyclerTrueImpl *cycler = (PipelineCyclerTrueImpl *)links; @@ -258,13 +248,10 @@ set_num_stages(int num_stages) { } #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::add_cycler -// Access: Public -// Description: Adds the indicated cycler to the list of cyclers -// associated with the pipeline. This method only -// exists when true pipelining is configured on. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated cycler to the list of cyclers associated with the + * pipeline. This method only exists when true pipelining is configured on. + */ void Pipeline:: add_cycler(PipelineCyclerTrueImpl *cycler) { ReMutexHolder holder(_lock); @@ -273,7 +260,7 @@ add_cycler(PipelineCyclerTrueImpl *cycler) { cycler->insert_before(&_clean); ++_num_cyclers; - + #ifdef DEBUG_THREADS inc_cycler_type(_all_cycler_types, cycler->get_parent_type(), 1); #endif @@ -281,15 +268,12 @@ add_cycler(PipelineCyclerTrueImpl *cycler) { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::add_dirty_cycler -// Access: Public -// Description: Marks the indicated cycler as "dirty", meaning it -// will need to be cycled next frame. This both adds it -// to the "dirty" set and also sets the "dirty" flag -// within the cycler. This method only exists when true -// pipelining is configured on. -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated cycler as "dirty", meaning it will need to be cycled + * next frame. This both adds it to the "dirty" set and also sets the "dirty" + * flag within the cycler. This method only exists when true pipelining is + * configured on. + */ void Pipeline:: add_dirty_cycler(PipelineCyclerTrueImpl *cycler) { nassertv(cycler->_lock.debug_is_locked()); @@ -312,13 +296,10 @@ add_dirty_cycler(PipelineCyclerTrueImpl *cycler) { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::remove_cycler -// Access: Public -// Description: Removes the indicated cycler from the list of cyclers -// associated with the pipeline. This method only -// exists when true pipelining is configured on. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated cycler from the list of cyclers associated with the + * pipeline. This method only exists when true pipelining is configured on. + */ void Pipeline:: remove_cycler(PipelineCyclerTrueImpl *cycler) { nassertv(cycler->_lock.debug_is_locked()); @@ -343,18 +324,14 @@ remove_cycler(PipelineCyclerTrueImpl *cycler) { } #endif // THREADED_PIPELINE -#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::iterate_all_cycler_types -// Access: Public -// Description: Walks through the list of all the different -// PipelineCycler types in the universe. For each one, -// calls the indicated callback function with the -// TypeHandle of the respective type (actually, the -// result of cycler::get_parent_type()) and the count of -// pipeline cyclers of that type. Mainly used for -// PStats reporting. -//////////////////////////////////////////////////////////////////// +#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) +/** + * Walks through the list of all the different PipelineCycler types in the + * universe. For each one, calls the indicated callback function with the + * TypeHandle of the respective type (actually, the result of + * cycler::get_parent_type()) and the count of pipeline cyclers of that type. + * Mainly used for PStats reporting. + */ void Pipeline:: iterate_all_cycler_types(CallbackFunc *func, void *data) const { ReMutexHolder holder(_lock); @@ -365,15 +342,11 @@ iterate_all_cycler_types(CallbackFunc *func, void *data) const { } #endif // THREADED_PIPELINE && DEBUG_THREADS -#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::iterate_dirty_cycler_types -// Access: Public -// Description: Walks through the list of all the different -// PipelineCycler types, for only the dirty -// PipelineCyclers. See also -// iterate_all_cycler_types(). -//////////////////////////////////////////////////////////////////// +#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) +/** + * Walks through the list of all the different PipelineCycler types, for only + * the dirty PipelineCyclers. See also iterate_all_cycler_types(). + */ void Pipeline:: iterate_dirty_cycler_types(CallbackFunc *func, void *data) const { ReMutexHolder holder(_lock); @@ -384,11 +357,9 @@ iterate_dirty_cycler_types(CallbackFunc *func, void *data) const { } #endif // THREADED_PIPELINE && DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::make_render_pipeline -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Pipeline:: make_render_pipeline() { ConfigVariableInt pipeline_stages @@ -405,18 +376,15 @@ make_render_pipeline() { _render_pipeline = new Pipeline("render", pipeline_stages); } -#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) -//////////////////////////////////////////////////////////////////// -// Function: Pipeline::inc_cycler_type -// Access: Private, Static -// Description: Increments (or decrements, according to added) the -// value for TypeHandle in the indicated TypeCount map. -// This is used in DEBUG_THREADS mode to track the types -// of PipelineCyclers that are coming and going, mainly -// for PStats reporting. -// -// It is assumed the lock is held during this call. -//////////////////////////////////////////////////////////////////// +#if defined(THREADED_PIPELINE) && defined(DEBUG_THREADS) +/** + * Increments (or decrements, according to added) the value for TypeHandle in + * the indicated TypeCount map. This is used in DEBUG_THREADS mode to track + * the types of PipelineCyclers that are coming and going, mainly for PStats + * reporting. + * + * It is assumed the lock is held during this call. + */ void Pipeline:: inc_cycler_type(TypeCount &count, TypeHandle type, int addend) { TypeCount::iterator ci = count.find(type); diff --git a/panda/src/pipeline/pipeline.h b/panda/src/pipeline/pipeline.h index 94b005f304..32e9cafad7 100644 --- a/panda/src/pipeline/pipeline.h +++ b/panda/src/pipeline/pipeline.h @@ -1,16 +1,15 @@ -// Filename: pipeline.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipeline.h + * @author drose + * @date 2002-02-21 + */ #ifndef PIPELINE_H #define PIPELINE_H @@ -25,19 +24,15 @@ struct PipelineCyclerTrueImpl; -//////////////////////////////////////////////////////////////////// -// Class : Pipeline -// Description : This class manages a staged pipeline of data, for -// instance the render pipeline, so that each stage of -// the pipeline can simultaneously access different -// copies of the same data. It actually maintains a -// collection of PipelineCycler objects, and manages the -// turning of all of them at once. -// -// There is one default Pipeline object, the render -// pipeline. Other specialty pipelines may be created -// as needed. -//////////////////////////////////////////////////////////////////// +/** + * This class manages a staged pipeline of data, for instance the render + * pipeline, so that each stage of the pipeline can simultaneously access + * different copies of the same data. It actually maintains a collection of + * PipelineCycler objects, and manages the turning of all of them at once. + * + * There is one default Pipeline object, the render pipeline. Other specialty + * pipelines may be created as needed. + */ class EXPCL_PANDA_PIPELINE Pipeline : public Namable { public: Pipeline(const string &name, int num_stages); @@ -58,7 +53,7 @@ public: INLINE int get_num_cyclers() const; INLINE int get_num_dirty_cyclers() const; - + #ifdef DEBUG_THREADS typedef void CallbackFunc(TypeHandle type, int count, void *data); void iterate_all_cycler_types(CallbackFunc *func, void *data) const; @@ -83,7 +78,7 @@ private: #ifdef DEBUG_THREADS typedef pmap TypeCount; TypeCount _all_cycler_types, _dirty_cycler_types; - + static void inc_cycler_type(TypeCount &count, TypeHandle type, int addend); #endif // DEBUG_THREADS @@ -97,4 +92,3 @@ private: #include "pipeline.I" #endif - diff --git a/panda/src/pipeline/pipelineCycler.I b/panda/src/pipeline/pipelineCycler.I index 35f3bf485a..8efce5450a 100644 --- a/panda/src/pipeline/pipelineCycler.I +++ b/panda/src/pipeline/pipelineCycler.I @@ -1,27 +1,23 @@ -// Filename: pipelineCycler.I -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCycler.I + * @author drose + * @date 2002-02-21 + */ #ifdef DO_PIPELINING -// The following implementations are to support the -// PipelineCyclerDummyImpl or the PipelineCyclerTrueImpl. +// The following implementations are to support the PipelineCyclerDummyImpl or +// the PipelineCyclerTrueImpl. -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Constructor (dummy or true) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PipelineCycler:: PipelineCycler(Pipeline *pipeline) : @@ -29,11 +25,9 @@ PipelineCycler(Pipeline *pipeline) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Copy Constructor (dummy or true) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PipelineCycler:: PipelineCycler(const PipelineCycler ©) : @@ -41,77 +35,63 @@ PipelineCycler(const PipelineCycler ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Copy Assignment (dummy or true) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PipelineCycler:: operator = (const PipelineCycler ©) { PipelineCyclerBase::operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_unlocked (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::read_unlocked(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_unlocked(). + */ template INLINE const CycleDataType *PipelineCycler:: read_unlocked(Thread *current_thread) const { return (const CycleDataType *)PipelineCyclerBase::read_unlocked(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::read(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read(). + */ template INLINE const CycleDataType *PipelineCycler:: read(Thread *current_thread) const { return (const CycleDataType *)PipelineCyclerBase::read(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::write(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write(). + */ template INLINE CycleDataType *PipelineCycler:: write(Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::write(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_upstream (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: write_upstream(bool force_to_0, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::write_upstream(force_to_0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read(const CycleDataType *pointer, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::elevate_read(pointer, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_upstream (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read_upstream(const CycleDataType *pointer, bool force_to_0, @@ -119,85 +99,69 @@ elevate_read_upstream(const CycleDataType *pointer, bool force_to_0, return (CycleDataType *)PipelineCyclerBase::elevate_read_upstream(pointer, force_to_0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_stage_unlocked (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::read_stage_unlocked(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_stage_unlocked(). + */ template INLINE const CycleDataType *PipelineCycler:: read_stage_unlocked(int pipeline_stage) const { return (const CycleDataType *)PipelineCyclerBase::read_stage_unlocked(pipeline_stage); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_stage (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_stage(). + */ template INLINE const CycleDataType *PipelineCycler:: read_stage(int pipeline_stage, Thread *current_thread) const { return (const CycleDataType *)PipelineCyclerBase::read_stage(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_stage (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_stage(). + */ template INLINE CycleDataType *PipelineCycler:: -elevate_read_stage(int pipeline_stage, const CycleDataType *pointer, +elevate_read_stage(int pipeline_stage, const CycleDataType *pointer, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::elevate_read_stage(pipeline_stage, pointer, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_stage_upstream (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_stage_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_stage_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: -elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer, +elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer, bool force_to_0, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::elevate_read_stage_upstream(pipeline_stage, pointer, force_to_0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_stage (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_stage(). + */ template INLINE CycleDataType *PipelineCycler:: write_stage(int pipeline_stage, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::write_stage(pipeline_stage, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_stage_upstream (dummy or true) -// Access: Public -// Description: See PipelineCyclerBase::write_stage_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_stage_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: -write_stage_upstream(int pipeline_stage, bool force_to_0, +write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread) { return (CycleDataType *)PipelineCyclerBase::write_stage_upstream(pipeline_stage, force_to_0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::cheat (dummy or true) -// Access: Public -// Description: Returns a pointer without counting it. This is only -// intended for use as the return value for certain -// nassertr() functions, so the application can recover -// after a failure to manage the read and write pointers -// correctly. You should never call this function -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer without counting it. This is only intended for use as + * the return value for certain nassertr() functions, so the application can + * recover after a failure to manage the read and write pointers correctly. + * You should never call this function directly. + */ template INLINE CycleDataType *PipelineCycler:: cheat() const { @@ -205,15 +169,12 @@ cheat() const { } #else // !DO_PIPELINING -// The following implementations are provided for when pipelining is -// not compiled in. They are trivial functions that do as little as -// possible. +// The following implementations are provided for when pipelining is not +// compiled in. They are trivial functions that do as little as possible. -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PipelineCycler:: PipelineCycler(Pipeline *pipeline) : @@ -221,11 +182,9 @@ PipelineCycler(Pipeline *pipeline) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Copy Constructor (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE PipelineCycler:: PipelineCycler(const PipelineCycler ©) : @@ -234,159 +193,129 @@ PipelineCycler(const PipelineCycler ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::Copy Assignment (trivial) -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void PipelineCycler:: operator = (const PipelineCycler ©) { _typed_data = copy._typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_unlocked (trivial) -// Access: Public -// Description: See PipelineCyclerBase::read_unlocked(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_unlocked(). + */ template INLINE const CycleDataType *PipelineCycler:: read_unlocked(Thread *) const { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read (trivial) -// Access: Public -// Description: See PipelineCyclerBase::read(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read(). + */ template INLINE const CycleDataType *PipelineCycler:: read(Thread *) const { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write (trivial) -// Access: Public -// Description: See PipelineCyclerBase::write(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write(). + */ template INLINE CycleDataType *PipelineCycler:: write(Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_upstream (trivial) -// Access: Public -// Description: See PipelineCyclerBase::write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: write_upstream(bool, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read (trivial) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read(const CycleDataType *, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_upstream (trivial) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read_upstream(const CycleDataType *, bool, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_stage_unlocked (trivial) -// Access: Public -// Description: See PipelineCyclerBase::read_stage_unlocked(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_stage_unlocked(). + */ template INLINE const CycleDataType *PipelineCycler:: read_stage_unlocked(int) const { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::read_stage (trivial) -// Access: Public -// Description: See PipelineCyclerBase::read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::read_stage(). + */ template INLINE const CycleDataType *PipelineCycler:: read_stage(int, Thread *) const { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_stage (trivial) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_stage(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read_stage(int, const CycleDataType *, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::elevate_read_stage_upstream (trivial) -// Access: Public -// Description: See PipelineCyclerBase::elevate_read_stage_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::elevate_read_stage_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: elevate_read_stage_upstream(int, const CycleDataType *, bool, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_stage (trivial) -// Access: Public -// Description: See PipelineCyclerBase::write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_stage(). + */ template INLINE CycleDataType *PipelineCycler:: write_stage(int, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::write_stage_upstream (trivial) -// Access: Public -// Description: See PipelineCyclerBase::write_stage_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * See PipelineCyclerBase::write_stage_upstream(). + */ template INLINE CycleDataType *PipelineCycler:: write_stage_upstream(int, bool, Thread *) { return &_typed_data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCycler::cheat (trivial) -// Access: Public -// Description: Returns a pointer without counting it. This is only -// intended for use as the return value for certain -// nassertr() functions, so the application can recover -// after a failure to manage the read and write pointers -// correctly. You should never call this function -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer without counting it. This is only intended for use as + * the return value for certain nassertr() functions, so the application can + * recover after a failure to manage the read and write pointers correctly. + * You should never call this function directly. + */ template INLINE CycleDataType *PipelineCycler:: cheat() const { diff --git a/panda/src/pipeline/pipelineCycler.cxx b/panda/src/pipeline/pipelineCycler.cxx index 99cd50290e..84a1bddcdd 100644 --- a/panda/src/pipeline/pipelineCycler.cxx +++ b/panda/src/pipeline/pipelineCycler.cxx @@ -1,15 +1,14 @@ -// Filename: pipelineCycler.cxx -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCycler.cxx + * @author drose + * @date 2002-02-21 + */ #include "pipelineCycler.h" diff --git a/panda/src/pipeline/pipelineCycler.h b/panda/src/pipeline/pipelineCycler.h index 26d84a2157..f87475c192 100644 --- a/panda/src/pipeline/pipelineCycler.h +++ b/panda/src/pipeline/pipelineCycler.h @@ -1,16 +1,15 @@ -// Filename: pipelineCycler.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCycler.h + * @author drose + * @date 2002-02-21 + */ #ifndef PIPELINECYCLER_H #define PIPELINECYCLER_H @@ -20,36 +19,29 @@ #include "cyclerHolder.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Class : PipelineCycler -// Description : This class maintains different copies of a page of -// data between stages of the graphics pipeline (or any -// other pipelining context). -// -// The class object maintains up to n copies of a -// CycleData structure, one for each stage of the -// pipeline. The head of the pipeline is responsible -// for making changes to its copy, which are then cycled -// through the pipeline at each frame. -// -// To access the data, you must first ask for a readable -// pointer. In order to make changes to the data, you -// must ask for a writable pointer. Both kinds of -// pointers should be released when you are done, as a -// sanity check. The CycleDataReader and -// CycleDataWriter classes transparently handle this. -// -// If pipelining support is not enabled at compile time -// (that is, DO_PIPELINING is not defined), this object -// compiles to a minimum object that presents the same -// interface but with minimal runtime overhead. -// -// We define this as a struct instead of a class to -// guarantee byte placement within the object, so that -// (particularly for the trivial implementation) the -// inherited struct's data is likely to be placed by the -// compiler at the "this" pointer. -//////////////////////////////////////////////////////////////////// +/** + * This class maintains different copies of a page of data between stages of + * the graphics pipeline (or any other pipelining context). + * + * The class object maintains up to n copies of a CycleData structure, one for + * each stage of the pipeline. The head of the pipeline is responsible for + * making changes to its copy, which are then cycled through the pipeline at + * each frame. + * + * To access the data, you must first ask for a readable pointer. In order to + * make changes to the data, you must ask for a writable pointer. Both kinds + * of pointers should be released when you are done, as a sanity check. The + * CycleDataReader and CycleDataWriter classes transparently handle this. + * + * If pipelining support is not enabled at compile time (that is, + * DO_PIPELINING is not defined), this object compiles to a minimum object + * that presents the same interface but with minimal runtime overhead. + * + * We define this as a struct instead of a class to guarantee byte placement + * within the object, so that (particularly for the trivial implementation) + * the inherited struct's data is likely to be placed by the compiler at the + * "this" pointer. + */ template struct PipelineCycler : public PipelineCyclerBase { public: @@ -75,22 +67,21 @@ public: #ifndef DO_PIPELINING private: - // If we are *not* compiling in support for pipelining, we just - // store the CycleData object right here. No pointers needed. + // If we are *not* compiling in support for pipelining, we just store the + // CycleData object right here. No pointers needed. CycleDataType _typed_data; #endif // !DO_PIPELINING }; -// These macros are handy for iterating through the set of pipeline -// stages. They're particularly useful for updating cache values -// upstream of the current stage, or for removing bad pointers from -// all stages of the pipeline. In each case, the variable -// pipeline_stage is defined within the loop to be the current stage -// of the pipeline traversed by the loop. +// These macros are handy for iterating through the set of pipeline stages. +// They're particularly useful for updating cache values upstream of the +// current stage, or for removing bad pointers from all stages of the +// pipeline. In each case, the variable pipeline_stage is defined within the +// loop to be the current stage of the pipeline traversed by the loop. #ifdef DO_PIPELINING -// Iterates through all of the pipeline stages upstream of the current -// stage, but not including the current stage. +// Iterates through all of the pipeline stages upstream of the current stage, +// but not including the current stage. #define OPEN_ITERATE_UPSTREAM_ONLY(cycler, current_thread) { \ CyclerHolder cholder(cycler); \ int pipeline_stage; \ @@ -101,8 +92,8 @@ private: #define CLOSE_ITERATE_UPSTREAM_ONLY(cycler) \ } -// Iterates through all of the pipeline stages upstream of the current -// stage, and including the current stage. +// Iterates through all of the pipeline stages upstream of the current stage, +// and including the current stage. #define OPEN_ITERATE_CURRENT_AND_UPSTREAM(cycler, current_thread) { \ CyclerHolder cholder(cycler); \ int pipeline_stage; \ @@ -136,30 +127,30 @@ private: #else // DO_PIPELINING // These are trivial implementations of the above macros, defined when -// pipelining is not enabled, that simply operate on stage 0 without -// bothering to create a for loop. +// pipelining is not enabled, that simply operate on stage 0 without bothering +// to create a for loop. #define OPEN_ITERATE_UPSTREAM_ONLY(cycler, current_thread) \ if (false) { \ - const int pipeline_stage = -1; + const int pipeline_stage = -1; #define CLOSE_ITERATE_UPSTREAM_ONLY(cycler) \ } #define OPEN_ITERATE_CURRENT_AND_UPSTREAM(cycler, current_thread) { \ const int pipeline_stage = 0; \ - + #define CLOSE_ITERATE_CURRENT_AND_UPSTREAM(cycler) \ } #define OPEN_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(cycler, current_thread) { \ const int pipeline_stage = 0; \ - + #define CLOSE_ITERATE_CURRENT_AND_UPSTREAM_NOLOCK(cycler) \ } #define OPEN_ITERATE_ALL_STAGES(cycler) { \ const int pipeline_stage = 0; \ - + #define CLOSE_ITERATE_ALL_STAGES(cycler) \ } @@ -168,4 +159,3 @@ private: #include "pipelineCycler.I" #endif - diff --git a/panda/src/pipeline/pipelineCyclerBase.h b/panda/src/pipeline/pipelineCyclerBase.h index 663fb23d36..f63399a149 100644 --- a/panda/src/pipeline/pipelineCyclerBase.h +++ b/panda/src/pipeline/pipelineCyclerBase.h @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerBase.h -// Created by: drose (21Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerBase.h + * @author drose + * @date 2002-02-21 + */ #ifndef PIPELINECYCLERBASE_H #define PIPELINECYCLERBASE_H @@ -27,19 +26,17 @@ typedef PipelineCyclerTrueImpl PipelineCyclerBase; #elif defined(DO_PIPELINING) -// With DO_PIPELINING but no threads available, we want the dummy, -// self-validating cycler implementation. +// With DO_PIPELINING but no threads available, we want the dummy, self- +// validating cycler implementation. #include "pipelineCyclerDummyImpl.h" typedef PipelineCyclerDummyImpl PipelineCyclerBase; #else // !DO_PIPELINING -// Without DO_PIPELINING, we only want the trivial, do-nothing -// implementation. +// Without DO_PIPELINING, we only want the trivial, do-nothing implementation. #include "pipelineCyclerTrivialImpl.h" typedef PipelineCyclerTrivialImpl PipelineCyclerBase; #endif // DO_PIPELINING #endif - diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.I b/panda/src/pipeline/pipelineCyclerDummyImpl.I index fc18b73271..997bdc9a09 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.I +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.I @@ -1,23 +1,19 @@ -// Filename: pipelineCyclerDummyImpl.I -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerDummyImpl.I + * @author drose + * @date 2006-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerDummyImpl:: PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline) : _data(initial_data), @@ -31,11 +27,9 @@ PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline) : } } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerDummyImpl:: PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl ©) : _data(copy._data->make_copy()), @@ -46,11 +40,9 @@ PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PipelineCyclerDummyImpl:: operator = (const PipelineCyclerDummyImpl ©) { nassertv(_read_count == 0 && _write_count == 0); @@ -58,23 +50,18 @@ operator = (const PipelineCyclerDummyImpl ©) { _pipeline = copy._pipeline; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerDummyImpl:: ~PipelineCyclerDummyImpl() { nassertv(_read_count == 0 && _write_count == 0 && !_locked); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::acquire -// Access: Public -// Description: Grabs an overall lock on the cycler. Release it with -// a call to release(). This lock should be held while -// walking the list of stages. -//////////////////////////////////////////////////////////////////// +/** + * Grabs an overall lock on the cycler. Release it with a call to release(). + * This lock should be held while walking the list of stages. + */ INLINE void PipelineCyclerDummyImpl:: acquire(Thread *) { TAU_PROFILE("void PipelineCyclerDummyImpl::acquire(Thread *)", " ", TAU_USER); @@ -82,12 +69,9 @@ acquire(Thread *) { _locked = true; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::release -// Access: Public -// Description: Release the overall lock on the cycler that was -// grabbed via acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Release the overall lock on the cycler that was grabbed via acquire(). + */ INLINE void PipelineCyclerDummyImpl:: release() { TAU_PROFILE("void PipelineCyclerDummyImpl::release()", " ", TAU_USER); @@ -95,142 +79,114 @@ release() { _locked = false; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::read_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. No lock is made on the contents; there -// is no guarantee that some other thread won't modify -// this object's data while you are working on it. -// (However, the data within the returned CycleData -// object itself is safe from modification; if another -// thread modifies the data, it will perform a -// copy-on-write, and thereby change the pointer stored -// within the object.) -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. No lock is made on the + * contents; there is no guarantee that some other thread won't modify this + * object's data while you are working on it. (However, the data within the + * returned CycleData object itself is safe from modification; if another + * thread modifies the data, it will perform a copy-on-write, and thereby + * change the pointer stored within the object.) + */ INLINE const CycleData *PipelineCyclerDummyImpl:: read_unlocked(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_unlocked()", " ", TAU_USER); return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::read -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. This pointer should eventually be -// released by calling release_read(). -// -// There should be no outstanding write pointers on the -// data when this function is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. This pointer should + * eventually be released by calling release_read(). + * + * There should be no outstanding write pointers on the data when this + * function is called. + */ INLINE const CycleData *PipelineCyclerDummyImpl:: read(Thread *) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read()", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. ((PipelineCyclerDummyImpl *)this)->_read_count++; - // It's not an error to grab a read pointer while someone else holds - // a read or a write pointer. + // It's not an error to grab a read pointer while someone else holds a read + // or a write pointer. return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::increment_read -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by read(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by read(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerDummyImpl:: increment_read(const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerDummyImpl::increment_read(const CycleData *)", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. nassertv(pointer == _data); nassertv(_read_count > 0); ((PipelineCyclerDummyImpl *)this)->_read_count++; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::release_read -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read(). + */ INLINE void PipelineCyclerDummyImpl:: release_read(const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerDummyImpl::release_read(const CycleData *)", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. nassertv(pointer == _data); nassertv(_read_count > 0); ((PipelineCyclerDummyImpl *)this)->_read_count--; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::write -// Access: Public -// Description: Returns a non-const CycleData pointer, filled with a -// unique copy of the data for the current stage of the -// pipeline as seen by this thread. This pointer may -// now be used to write to the data, and that copy of -// the data will be propagated to all later stages of the -// pipeline. This pointer should eventually be released -// by calling release_write(). -// -// There may only be one outstanding write pointer on a -// given stage at a time, and if there is a write -// pointer there may be no read pointers on the same -// stage (but see elevate_read). -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const CycleData pointer, filled with a unique copy of the + * data for the current stage of the pipeline as seen by this thread. This + * pointer may now be used to write to the data, and that copy of the data + * will be propagated to all later stages of the pipeline. This pointer + * should eventually be released by calling release_write(). + * + * There may only be one outstanding write pointer on a given stage at a time, + * and if there is a write pointer there may be no read pointers on the same + * stage (but see elevate_read). + */ INLINE CycleData *PipelineCyclerDummyImpl:: write(Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write()", " ", TAU_USER); _write_count++; - // It's an error to grab a write pointer while someone else holds a - // read pointer, because doing so may invalidate the read pointer. + // It's an error to grab a write pointer while someone else holds a read + // pointer, because doing so may invalidate the read pointer. nassertr(_read_count == 0, _data); - // It's not an error to do this while someone else holds a write - // pointer, however. + // It's not an error to do this while someone else holds a write pointer, + // however. return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::write_upstream -// Access: Public -// Description: This special variant on write() will automatically -// propagate changes back to upstream pipeline stages. -// If force_to_0 is false, then it propagates back only -// as long as the CycleData pointers are equivalent, -// guaranteeing that it does not modify upstream data -// (other than the modification that will be performed -// by the code that returns this pointer). This is -// particularly appropriate for minor updates, where it -// doesn't matter much if the update is lost, such as -// storing a cached value. -// -// If force_to_0 is dummy, then the CycleData pointer for -// the current pipeline stage is propagated all the way -// back up to stage 0; after this call, there will be -// only one CycleData pointer that is duplicated in all -// stages between stage 0 and the current stage. This -// may undo some recent changes that were made -// independently at pipeline stage 0 (or any other -// upstream stage). However, it guarantees that the -// change that is to be applied at this pipeline stage -// will stick. This is slightly dangerous because of -// the risk of losing upstream changes; generally, this -// should only be done when you are confident that there -// are no upstream changes to be lost (for instance, for -// an object that has been recently created). -//////////////////////////////////////////////////////////////////// +/** + * This special variant on write() will automatically propagate changes back + * to upstream pipeline stages. If force_to_0 is false, then it propagates + * back only as long as the CycleData pointers are equivalent, guaranteeing + * that it does not modify upstream data (other than the modification that + * will be performed by the code that returns this pointer). This is + * particularly appropriate for minor updates, where it doesn't matter much if + * the update is lost, such as storing a cached value. + * + * If force_to_0 is dummy, then the CycleData pointer for the current pipeline + * stage is propagated all the way back up to stage 0; after this call, there + * will be only one CycleData pointer that is duplicated in all stages between + * stage 0 and the current stage. This may undo some recent changes that were + * made independently at pipeline stage 0 (or any other upstream stage). + * However, it guarantees that the change that is to be applied at this + * pipeline stage will stick. This is slightly dangerous because of the risk + * of losing upstream changes; generally, this should only be done when you + * are confident that there are no upstream changes to be lost (for instance, + * for an object that has been recently created). + */ CycleData *PipelineCyclerDummyImpl:: write_upstream(bool, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_upstream(bool)", " ", TAU_USER); @@ -238,15 +194,11 @@ write_upstream(bool, Thread *) { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::elevate_read -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read(const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read(const CycleData *)", " ", TAU_USER); @@ -254,14 +206,11 @@ elevate_read(const CycleData *pointer, Thread *current_thread) { return write(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::elevate_read_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer, like elevate_read(), but also propagates the -// pointer back to upstream stages, like -// write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer, like + * elevate_read(), but also propagates the pointer back to upstream stages, + * like write_upstream(). + */ INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_upstream(const CycleData *, bool)", " ", TAU_USER); @@ -269,29 +218,23 @@ elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current return write_upstream(force_to_0, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::increment_write -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by write(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by write(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerDummyImpl:: increment_write(CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerDummyImpl::increment_write(CycleData *)", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. nassertv(pointer == _data); nassertv(_write_count > 0); ((PipelineCyclerDummyImpl *)this)->_write_count++; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::release_write -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write(). + */ INLINE void PipelineCyclerDummyImpl:: release_write(CycleData *pointer) { TAU_PROFILE("void PipelineCyclerDummyImpl::release_write(CycleData *)", " ", TAU_USER); @@ -300,24 +243,19 @@ release_write(CycleData *pointer) { _write_count--; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::get_num_stages -// Access: Public -// Description: Returns the number of stages in the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages in the pipeline. + */ INLINE int PipelineCyclerDummyImpl:: get_num_stages() { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::read_stage_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated stage of the pipeline. As in -// read_unlocked(), no lock is held on the returned -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * stage of the pipeline. As in read_unlocked(), no lock is held on the + * returned pointer. + */ INLINE const CycleData *PipelineCyclerDummyImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage_unlocked(int)", " ", TAU_USER); @@ -325,57 +263,47 @@ read_stage_unlocked(int pipeline_stage) const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::read_stage -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated stage of the pipeline. This -// pointer should eventually be released by calling -// release_read_stage(). -// -// There should be no outstanding write pointers on the -// data when this function is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * stage of the pipeline. This pointer should eventually be released by + * calling release_read_stage(). + * + * There should be no outstanding write pointers on the data when this + * function is called. + */ INLINE const CycleData *PipelineCyclerDummyImpl:: read_stage(int pipeline_stage, Thread *) const { TAU_PROFILE("const CycleData *PipelineCyclerDummyImpl::read_stage(int, Thread *)", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. nassertr(pipeline_stage == 0, NULL); ((PipelineCyclerDummyImpl *)this)->_read_count++; - // It's not an error to grab a read pointer while someone else holds - // a read or a write pointer. + // It's not an error to grab a read pointer while someone else holds a read + // or a write pointer. return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::release_read_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read_stage(). + */ INLINE void PipelineCyclerDummyImpl:: release_read_stage(int pipeline_stage, const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerDummyImpl::release_read_stage(int, const CycleData *)", " ", TAU_USER); - // This function isn't truly const, but it doesn't change the data - // in any meaningful way, so we pretend it is. + // This function isn't truly const, but it doesn't change the data in any + // meaningful way, so we pretend it is. nassertv(pipeline_stage == 0); nassertv(pointer == _data); nassertv(_read_count > 0); ((PipelineCyclerDummyImpl *)this)->_read_count--; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::write_stage -// Access: Public -// Description: Returns a pointer suitable for writing to the nth -// stage of the pipeline. This is for special -// applications that need to update the entire pipeline -// at once (for instance, to remove an invalid pointer). -// This pointer should later be released with -// release_write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer suitable for writing to the nth stage of the pipeline. + * This is for special applications that need to update the entire pipeline at + * once (for instance, to remove an invalid pointer). This pointer should + * later be released with release_write_stage(). + */ INLINE CycleData *PipelineCyclerDummyImpl:: write_stage(int pipeline_stage, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage(int)", " ", TAU_USER); @@ -384,16 +312,12 @@ write_stage(int pipeline_stage, Thread *) { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::write_stage_upstream -// Access: Public -// Description: Returns a pointer suitable for writing to the nth -// stage of the pipeline. This is for special -// applications that need to update the entire pipeline -// at once (for instance, to remove an invalid pointer). -// This pointer should later be released with -// release_write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer suitable for writing to the nth stage of the pipeline. + * This is for special applications that need to update the entire pipeline at + * once (for instance, to remove an invalid pointer). This pointer should + * later be released with release_write_stage(). + */ INLINE CycleData *PipelineCyclerDummyImpl:: write_stage_upstream(int pipeline_stage, bool, Thread *) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::write_stage_upstream(int)", " ", TAU_USER); @@ -402,15 +326,11 @@ write_stage_upstream(int pipeline_stage, bool, Thread *) { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::elevate_read_stage -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerDummyImpl:: elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); @@ -419,17 +339,13 @@ elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current return write(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::elevate_read_stage_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerDummyImpl:: -elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, +elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerDummyImpl::elevate_read_stage(int, CycleData *)", " ", TAU_USER); nassertr(pipeline_stage == 0, NULL); @@ -437,12 +353,9 @@ elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, return write(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::release_write_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write_stage(). + */ INLINE void PipelineCyclerDummyImpl:: release_write_stage(int pipeline_stage, CycleData *pointer) { TAU_PROFILE("void PipelineCyclerDummyImpl::release_write_stage(int, CycleData *)", " ", TAU_USER); @@ -451,52 +364,40 @@ release_write_stage(int pipeline_stage, CycleData *pointer) { _write_count--; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::get_parent_type -// Access: Public -// Description: Returns the type of object that owns this cycler, as -// reported by CycleData::get_parent_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of object that owns this cycler, as reported by + * CycleData::get_parent_type(). + */ INLINE TypeHandle PipelineCyclerDummyImpl:: get_parent_type() const { return _data->get_parent_type(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::cheat -// Access: Public -// Description: Returns a pointer without counting it. This is only -// intended for use as the return value for certain -// nassertr() functions, so the application can recover -// after a failure to manage the read and write pointers -// correctly. You should never call this function -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer without counting it. This is only intended for use as + * the return value for certain nassertr() functions, so the application can + * recover after a failure to manage the read and write pointers correctly. + * You should never call this function directly. + */ INLINE CycleData *PipelineCyclerDummyImpl:: cheat() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::get_read_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This should -// only be used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This should only be used for debugging purposes. + */ INLINE int PipelineCyclerDummyImpl:: get_read_count() const { return _read_count; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerDummyImpl::get_write_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This will -// normally only be either 0 or 1. This should only be -// used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This will normally only be either 0 or 1. This should + * only be used for debugging purposes. + */ INLINE int PipelineCyclerDummyImpl:: get_write_count() const { return _write_count; diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.cxx b/panda/src/pipeline/pipelineCyclerDummyImpl.cxx index ae5858ccef..ce2a446b90 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.cxx @@ -1,15 +1,14 @@ -// Filename: pipelineCyclerDummyImpl.cxx -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerDummyImpl.cxx + * @author drose + * @date 2006-01-31 + */ #include "pipelineCyclerDummyImpl.h" diff --git a/panda/src/pipeline/pipelineCyclerDummyImpl.h b/panda/src/pipeline/pipelineCyclerDummyImpl.h index 78a56c514e..00e0df9387 100644 --- a/panda/src/pipeline/pipelineCyclerDummyImpl.h +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.h @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerDummyImpl.h -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerDummyImpl.h + * @author drose + * @date 2006-01-31 + */ #ifndef PIPELINECYCLERDUMMYIMPL_H #define PIPELINECYCLERDUMMYIMPL_H @@ -23,24 +22,20 @@ #include "pipeline.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PipelineCyclerDummyImpl -// Description : This is a simple, single-threaded-only implementation -// of PipelineCyclerBase. It is only compiled when -// DO_PIPELINING is defined, but threading is not -// available, which is usually the case only in -// development mode. -// -// This implmentation is similar in principle to -// PipelineCyclerTrivialImpl, except it does basic -// sanity checking to ensure that you use the interface -// in a reasonable way consistent with its design (e.g., -// read() is balanced with release_read(), etc.). -// -// This is defined as a struct instead of a class, -// mainly to be consistent with -// PipelineCyclerTrivialImpl. -//////////////////////////////////////////////////////////////////// +/** + * This is a simple, single-threaded-only implementation of + * PipelineCyclerBase. It is only compiled when DO_PIPELINING is defined, but + * threading is not available, which is usually the case only in development + * mode. + * + * This implmentation is similar in principle to PipelineCyclerTrivialImpl, + * except it does basic sanity checking to ensure that you use the interface + * in a reasonable way consistent with its design (e.g., read() is balanced + * with release_read(), etc.). + * + * This is defined as a struct instead of a class, mainly to be consistent + * with PipelineCyclerTrivialImpl. + */ struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl { public: INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL); @@ -92,4 +87,3 @@ private: #endif // DO_PIPELINING && !HAVE_THREADS #endif - diff --git a/panda/src/pipeline/pipelineCyclerLinks.I b/panda/src/pipeline/pipelineCyclerLinks.I index e285f0bbe8..7b52a935a5 100644 --- a/panda/src/pipeline/pipelineCyclerLinks.I +++ b/panda/src/pipeline/pipelineCyclerLinks.I @@ -1,24 +1,20 @@ -// Filename: pipelineCyclerLinks.I -// Created by: drose (16Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerLinks.I + * @author drose + * @date 2006-02-16 + */ #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerLinks:: PipelineCyclerLinks() { #ifndef NDEBUG @@ -29,11 +25,9 @@ PipelineCyclerLinks() { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerLinks:: ~PipelineCyclerLinks() { nassertv(_next == NULL && _prev == NULL); @@ -41,12 +35,9 @@ INLINE PipelineCyclerLinks:: #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::make_head -// Access: Protected -// Description: When called on an empty object, sets it up to be the -// head of a linked list. -//////////////////////////////////////////////////////////////////// +/** + * When called on an empty object, sets it up to be the head of a linked list. + */ INLINE void PipelineCyclerLinks:: make_head() { nassertv(_next == NULL && _prev == NULL); @@ -56,12 +47,10 @@ make_head() { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::clear_head -// Access: Protected -// Description: When called on the head of an empty linked list, -// resets it to an empty object, for safe destruction. -//////////////////////////////////////////////////////////////////// +/** + * When called on the head of an empty linked list, resets it to an empty + * object, for safe destruction. + */ INLINE void PipelineCyclerLinks:: clear_head() { nassertv(_next == this && _prev == this); @@ -73,12 +62,9 @@ clear_head() { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::remove_from_list -// Access: Protected -// Description: Removes a PipelineCyclerLinks record from the -// doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Removes a PipelineCyclerLinks record from the doubly-linked list. + */ INLINE void PipelineCyclerLinks:: remove_from_list() { nassertv(_prev->_next == this && _next->_prev == this); @@ -92,12 +78,10 @@ remove_from_list() { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::insert_before -// Access: Protected -// Description: Adds a PipelineCyclerLinks record before the indicated -// node in the doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a PipelineCyclerLinks record before the indicated node in the doubly- + * linked list. + */ INLINE void PipelineCyclerLinks:: insert_before(PipelineCyclerLinks *node) { nassertv(node->_prev->_next == node && node->_next->_prev == node); @@ -111,13 +95,10 @@ insert_before(PipelineCyclerLinks *node) { #endif // THREADED_PIPELINE #ifdef THREADED_PIPELINE -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerLinks::take_list -// Access: Protected -// Description: When called on the head of an empty list, takes all -// of the leemnts from the indicated list and moves them -// to this list. -//////////////////////////////////////////////////////////////////// +/** + * When called on the head of an empty list, takes all of the leemnts from the + * indicated list and moves them to this list. + */ INLINE void PipelineCyclerLinks:: take_list(PipelineCyclerLinks &other) { nassertv(_next == this && _prev == this); diff --git a/panda/src/pipeline/pipelineCyclerLinks.h b/panda/src/pipeline/pipelineCyclerLinks.h index ce9d047845..37041fc34c 100644 --- a/panda/src/pipeline/pipelineCyclerLinks.h +++ b/panda/src/pipeline/pipelineCyclerLinks.h @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerLinks.h -// Created by: drose (16Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerLinks.h + * @author drose + * @date 2006-02-16 + */ #ifndef PIPELINECYCLERLINKS_H #define PIPELINECYCLERLINKS_H @@ -19,19 +18,15 @@ #include "selectThreadImpl.h" // for THREADED_PIPELINE definition #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : PipelineCyclerLinks -// Description : This just stores the pointers to implement a -// doubly-linked list of PipelineCyclers for a -// particular Pipeline object. We use a hand-rolled -// linked list rather than any STL container, because we -// want PipelineCyclers to be able to add and remove -// themselves from this list very quickly. -// -// These pointers are inherited from this separate class -// so the Pipeline object itself can be the root of the -// linked list. -//////////////////////////////////////////////////////////////////// +/** + * This just stores the pointers to implement a doubly-linked list of + * PipelineCyclers for a particular Pipeline object. We use a hand-rolled + * linked list rather than any STL container, because we want PipelineCyclers + * to be able to add and remove themselves from this list very quickly. + * + * These pointers are inherited from this separate class so the Pipeline + * object itself can be the root of the linked list. + */ class EXPCL_PANDA_PIPELINE PipelineCyclerLinks { protected: #ifdef THREADED_PIPELINE diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.I b/panda/src/pipeline/pipelineCyclerTrivialImpl.I index e069755aa7..5cc1eecf39 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.I +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.I @@ -1,34 +1,28 @@ -// Filename: pipelineCyclerTrivialImpl.I -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrivialImpl.I + * @author drose + * @date 2006-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrivialImpl:: PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *) { - // In the trivial implementation, a derived class (the - // PipelineCycler template class) stores the CycleData object - // directly within itself, and since we have no data members or - // virtual functions, we get away with assuming the pointer is the - // same as the 'this' pointer. + // In the trivial implementation, a derived class (the PipelineCycler + // template class) stores the CycleData object directly within itself, and + // since we have no data members or virtual functions, we get away with + // assuming the pointer is the same as the 'this' pointer. - // If this turns out not to be true on a particular platform, we - // will have to store the pointer in this class, for a little bit of - // extra overhead. + // If this turns out not to be true on a particular platform, we will have + // to store the pointer in this class, for a little bit of extra overhead. #ifdef SIMPLE_STRUCT_POINTERS nassertv(initial_data == (CycleData *)this); #else @@ -36,78 +30,59 @@ PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrivialImpl:: PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl &) { - // The copy constructor for the PipelineCyclerTrivialImpl case - // doesn't work. Don't try to use it. The PipelineCycler template - // class is #ifdeffed appropriately to call the normal constructor - // instead. + // The copy constructor for the PipelineCyclerTrivialImpl case doesn't work. + // Don't try to use it. The PipelineCycler template class is ifdeffed + // appropriately to call the normal constructor instead. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::Copy Assignment -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PipelineCyclerTrivialImpl:: operator = (const PipelineCyclerTrivialImpl &) { - // The copy assignment operator for the PipelineCyclerTrivialImpl - // case doesn't work. Don't try to use it. The PipelineCycler - // template class is #ifdeffed appropriately not to call this - // method. + // The copy assignment operator for the PipelineCyclerTrivialImpl case + // doesn't work. Don't try to use it. The PipelineCycler template class is + // ifdeffed appropriately not to call this method. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrivialImpl:: ~PipelineCyclerTrivialImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::acquire -// Access: Public -// Description: Grabs an overall lock on the cycler. Release it with -// a call to release(). This lock should be held while -// walking the list of stages. -//////////////////////////////////////////////////////////////////// +/** + * Grabs an overall lock on the cycler. Release it with a call to release(). + * This lock should be held while walking the list of stages. + */ INLINE void PipelineCyclerTrivialImpl:: acquire(Thread *) { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::release -// Access: Public -// Description: Release the overall lock on the cycler that was -// grabbed via acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Release the overall lock on the cycler that was grabbed via acquire(). + */ INLINE void PipelineCyclerTrivialImpl:: release() { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::read_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. No lock is made on the contents; there -// is no guarantee that some other thread won't modify -// this object's data while you are working on it. -// (However, the data within the returned CycleData -// object itself is safe from modification; if another -// thread modifies the data, it will perform a -// copy-on-write, and thereby change the pointer stored -// within the object.) -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. No lock is made on the + * contents; there is no guarantee that some other thread won't modify this + * object's data while you are working on it. (However, the data within the + * returned CycleData object itself is safe from modification; if another + * thread modifies the data, it will perform a copy-on-write, and thereby + * change the pointer stored within the object.) + */ INLINE const CycleData *PipelineCyclerTrivialImpl:: read_unlocked(Thread *) const { #ifdef SIMPLE_STRUCT_POINTERS @@ -117,14 +92,11 @@ read_unlocked(Thread *) const { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::read -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. This pointer should eventually be -// released by calling release_read(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. This pointer should + * eventually be released by calling release_read(). + */ INLINE const CycleData *PipelineCyclerTrivialImpl:: read(Thread *) const { #ifdef SIMPLE_STRUCT_POINTERS @@ -134,43 +106,32 @@ read(Thread *) const { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::increment_read -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by read(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by read(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerTrivialImpl:: increment_read(const CycleData *) const { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::release_read -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read(). + */ INLINE void PipelineCyclerTrivialImpl:: release_read(const CycleData *) const { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::write -// Access: Public -// Description: Returns a non-const CycleData pointer, filled with a -// unique copy of the data for the current stage of the -// pipeline as seen by this thread. This pointer may -// now be used to write to the data, and that copy of -// the data will be propagated to all later stages of the -// pipeline. This pointer should eventually be released -// by calling release_write(). -// -// There may only be one outstanding write pointer on a -// given stage at a time, and if there is a write -// pointer there may be no read pointers on the same -// stage (but see elevate_read). -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const CycleData pointer, filled with a unique copy of the + * data for the current stage of the pipeline as seen by this thread. This + * pointer may now be used to write to the data, and that copy of the data + * will be propagated to all later stages of the pipeline. This pointer + * should eventually be released by calling release_write(). + * + * There may only be one outstanding write pointer on a given stage at a time, + * and if there is a write pointer there may be no read pointers on the same + * stage (but see elevate_read). + */ INLINE CycleData *PipelineCyclerTrivialImpl:: write(Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -180,35 +141,26 @@ write(Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::write_upstream -// Access: Public -// Description: This special variant on write() will automatically -// propagate changes back to upstream pipeline stages. -// If force_to_0 is false, then it propagates back only -// as long as the CycleData pointers are equivalent, -// guaranteeing that it does not modify upstream data -// (other than the modification that will be performed -// by the code that returns this pointer). This is -// particularly appropriate for minor updates, where it -// doesn't matter much if the update is lost, such as -// storing a cached value. -// -// If force_to_0 is trivial, then the CycleData pointer for -// the current pipeline stage is propagated all the way -// back up to stage 0; after this call, there will be -// only one CycleData pointer that is duplicated in all -// stages between stage 0 and the current stage. This -// may undo some recent changes that were made -// independently at pipeline stage 0 (or any other -// upstream stage). However, it guarantees that the -// change that is to be applied at this pipeline stage -// will stick. This is slightly dangerous because of -// the risk of losing upstream changes; generally, this -// should only be done when you are confident that there -// are no upstream changes to be lost (for instance, for -// an object that has been recently created). -//////////////////////////////////////////////////////////////////// +/** + * This special variant on write() will automatically propagate changes back + * to upstream pipeline stages. If force_to_0 is false, then it propagates + * back only as long as the CycleData pointers are equivalent, guaranteeing + * that it does not modify upstream data (other than the modification that + * will be performed by the code that returns this pointer). This is + * particularly appropriate for minor updates, where it doesn't matter much if + * the update is lost, such as storing a cached value. + * + * If force_to_0 is trivial, then the CycleData pointer for the current + * pipeline stage is propagated all the way back up to stage 0; after this + * call, there will be only one CycleData pointer that is duplicated in all + * stages between stage 0 and the current stage. This may undo some recent + * changes that were made independently at pipeline stage 0 (or any other + * upstream stage). However, it guarantees that the change that is to be + * applied at this pipeline stage will stick. This is slightly dangerous + * because of the risk of losing upstream changes; generally, this should only + * be done when you are confident that there are no upstream changes to be + * lost (for instance, for an object that has been recently created). + */ CycleData *PipelineCyclerTrivialImpl:: write_upstream(bool, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -218,15 +170,11 @@ write_upstream(bool, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::elevate_read -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerTrivialImpl:: elevate_read(const CycleData *, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -236,14 +184,11 @@ elevate_read(const CycleData *, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::elevate_read_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer, like elevate_read(), but also propagates the -// pointer back to upstream stages, like -// write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer, like + * elevate_read(), but also propagates the pointer back to upstream stages, + * like write_upstream(). + */ INLINE CycleData *PipelineCyclerTrivialImpl:: elevate_read_upstream(const CycleData *, bool, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -253,45 +198,34 @@ elevate_read_upstream(const CycleData *, bool, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::increment_write -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by write(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by write(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerTrivialImpl:: increment_write(CycleData *) const { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::release_write -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write(). + */ INLINE void PipelineCyclerTrivialImpl:: release_write(CycleData *) { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::get_num_stages -// Access: Public -// Description: Returns the number of stages in the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages in the pipeline. + */ INLINE int PipelineCyclerTrivialImpl:: get_num_stages() { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::read_stage_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated stage of the pipeline. As in -// read_unlocked(), no lock is held on the returned -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * stage of the pipeline. As in read_unlocked(), no lock is held on the + * returned pointer. + */ INLINE const CycleData *PipelineCyclerTrivialImpl:: read_stage_unlocked(int) const { #ifdef SIMPLE_STRUCT_POINTERS @@ -301,14 +235,11 @@ read_stage_unlocked(int) const { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::read_stage -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated pipeline stage. This pointer -// should eventually be released by calling -// release_read(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * pipeline stage. This pointer should eventually be released by calling + * release_read(). + */ INLINE const CycleData *PipelineCyclerTrivialImpl:: read_stage(int, Thread *) const { #ifdef SIMPLE_STRUCT_POINTERS @@ -318,26 +249,19 @@ read_stage(int, Thread *) const { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::release_read_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read_stage(). + */ INLINE void PipelineCyclerTrivialImpl:: release_read_stage(int, const CycleData *) const { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::write_stage -// Access: Public -// Description: Returns a pointer suitable for writing to the nth -// stage of the pipeline. This is for special -// applications that need to update the entire pipeline -// at once (for instance, to remove an invalid pointer). -// This pointer should later be released with -// release_write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer suitable for writing to the nth stage of the pipeline. + * This is for special applications that need to update the entire pipeline at + * once (for instance, to remove an invalid pointer). This pointer should + * later be released with release_write_stage(). + */ INLINE CycleData *PipelineCyclerTrivialImpl:: write_stage(int, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -347,16 +271,12 @@ write_stage(int, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::write_stage_upstream -// Access: Public -// Description: Returns a pointer suitable for writing to the nth -// stage of the pipeline. This is for special -// applications that need to update the entire pipeline -// at once (for instance, to remove an invalid pointer). -// This pointer should later be released with -// release_write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer suitable for writing to the nth stage of the pipeline. + * This is for special applications that need to update the entire pipeline at + * once (for instance, to remove an invalid pointer). This pointer should + * later be released with release_write_stage(). + */ INLINE CycleData *PipelineCyclerTrivialImpl:: write_stage_upstream(int, bool, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -366,15 +286,11 @@ write_stage_upstream(int, bool, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::elevate_read_stage -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerTrivialImpl:: elevate_read_stage(int, const CycleData *, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -384,15 +300,11 @@ elevate_read_stage(int, const CycleData *, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::elevate_read_stage_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerTrivialImpl:: elevate_read_stage_upstream(int, const CycleData *, bool, Thread *) { #ifdef SIMPLE_STRUCT_POINTERS @@ -402,37 +314,28 @@ elevate_read_stage_upstream(int, const CycleData *, bool, Thread *) { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::release_write_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write_stage(). + */ INLINE void PipelineCyclerTrivialImpl:: release_write_stage(int, CycleData *) { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::get_parent_type -// Access: Public -// Description: Returns the type of object that owns this cycler, as -// reported by CycleData::get_parent_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of object that owns this cycler, as reported by + * CycleData::get_parent_type(). + */ INLINE TypeHandle PipelineCyclerTrivialImpl:: get_parent_type() const { return cheat()->get_parent_type(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::cheat -// Access: Public -// Description: Returns a pointer without counting it. This is only -// intended for use as the return value for certain -// nassertr() functions, so the application can recover -// after a failure to manage the read and write pointers -// correctly. You should never call this function -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer without counting it. This is only intended for use as + * the return value for certain nassertr() functions, so the application can + * recover after a failure to manage the read and write pointers correctly. + * You should never call this function directly. + */ INLINE CycleData *PipelineCyclerTrivialImpl:: cheat() const { #ifdef SIMPLE_STRUCT_POINTERS @@ -442,28 +345,21 @@ cheat() const { #endif // SIMPLE_STRUCT_POINTERS } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::get_read_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This should -// only be used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This should only be used for debugging purposes. + */ INLINE int PipelineCyclerTrivialImpl:: get_read_count() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrivialImpl::get_write_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This will -// normally only be either 0 or 1. This should only be -// used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This will normally only be either 0 or 1. This should + * only be used for debugging purposes. + */ INLINE int PipelineCyclerTrivialImpl:: get_write_count() const { return 0; } - diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.cxx b/panda/src/pipeline/pipelineCyclerTrivialImpl.cxx index 2c4d3bba2f..86142793e8 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.cxx @@ -1,15 +1,14 @@ -// Filename: pipelineCyclerTrivialImpl.cxx -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrivialImpl.cxx + * @author drose + * @date 2006-01-31 + */ #include "pipelineCyclerTrivialImpl.h" diff --git a/panda/src/pipeline/pipelineCyclerTrivialImpl.h b/panda/src/pipeline/pipelineCyclerTrivialImpl.h index 52efb7d7e6..ea0593ba24 100644 --- a/panda/src/pipeline/pipelineCyclerTrivialImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.h @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerTrivialImpl.h -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrivialImpl.h + * @author drose + * @date 2006-01-31 + */ #ifndef PIPELINECYCLERTRIVIALIMPL_H #define PIPELINECYCLERTRIVIALIMPL_H @@ -24,26 +23,21 @@ class Pipeline; -//////////////////////////////////////////////////////////////////// -// Class : PipelineCyclerTrivialImpl -// Description : This is the trivial, non-threaded implementation of -// PipelineCyclerBase. It is only compiled when -// DO_PIPELINING is not defined (which usually implies -// that threading is not available). -// -// This implementation is designed to do as little as -// possible, and to compile to nothing, or almost -// nothing. It doesn't actually support pipelining in -// any way. It doesn't even perform any sanity checks -// to speak of. It's designed for a strictly -// single-threaded application, and its purpose is to be -// as low-overhead as possible. -// -// We define this as a struct instead of a class to -// emphasize the importance of byte placement within the -// object, so that the inherited struct's data is likely -// to be placed by the compiler at the "this" pointer. -//////////////////////////////////////////////////////////////////// +/** + * This is the trivial, non-threaded implementation of PipelineCyclerBase. It + * is only compiled when DO_PIPELINING is not defined (which usually implies + * that threading is not available). + * + * This implementation is designed to do as little as possible, and to compile + * to nothing, or almost nothing. It doesn't actually support pipelining in + * any way. It doesn't even perform any sanity checks to speak of. It's + * designed for a strictly single-threaded application, and its purpose is to + * be as low-overhead as possible. + * + * We define this as a struct instead of a class to emphasize the importance + * of byte placement within the object, so that the inherited struct's data is + * likely to be placed by the compiler at the "this" pointer. + */ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl { public: INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); @@ -88,10 +82,9 @@ public: INLINE int get_read_count() const; INLINE int get_write_count() const; - // In a trivial implementation, we only need to store the CycleData - // pointer. Actually, we don't even need to do that, if we're lucky - // and the compiler doesn't do anything funny with the struct - // layout. + // In a trivial implementation, we only need to store the CycleData pointer. + // Actually, we don't even need to do that, if we're lucky and the compiler + // doesn't do anything funny with the struct layout. #ifndef SIMPLE_STRUCT_POINTERS CycleData *_data; #endif // SIMPLE_STRUCT_POINTERS @@ -102,4 +95,3 @@ public: #endif // !DO_PIPELINING #endif - diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.I b/panda/src/pipeline/pipelineCyclerTrueImpl.I index e9264c6455..d2e78fca2d 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.I +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.I @@ -1,70 +1,54 @@ -// Filename: pipelineCyclerTrueImpl.I -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrueImpl.I + * @author drose + * @date 2006-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::acquire -// Access: Public -// Description: Grabs an overall lock on the cycler. Release it with -// a call to release(). This lock should be held while -// walking the list of stages. -//////////////////////////////////////////////////////////////////// +/** + * Grabs an overall lock on the cycler. Release it with a call to release(). + * This lock should be held while walking the list of stages. + */ INLINE void PipelineCyclerTrueImpl:: acquire() { TAU_PROFILE("void PipelineCyclerTrueImpl::acquire()", " ", TAU_USER); _lock.acquire(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::acquire -// Access: Public -// Description: Grabs an overall lock on the cycler. Release it with -// a call to release(). This lock should be held while -// walking the list of stages. -//////////////////////////////////////////////////////////////////// +/** + * Grabs an overall lock on the cycler. Release it with a call to release(). + * This lock should be held while walking the list of stages. + */ INLINE void PipelineCyclerTrueImpl:: acquire(Thread *current_thread) { TAU_PROFILE("void PipelineCyclerTrueImpl::acquire(Thread *)", " ", TAU_USER); _lock.acquire(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::release -// Access: Public -// Description: Release the overall lock on the cycler that was -// grabbed via acquire(). -//////////////////////////////////////////////////////////////////// +/** + * Release the overall lock on the cycler that was grabbed via acquire(). + */ INLINE void PipelineCyclerTrueImpl:: release() { TAU_PROFILE("void PipelineCyclerTrueImpl::release()", " ", TAU_USER); _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::read_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. No lock is made on the contents; there -// is no guarantee that some other thread won't modify -// this object's data while you are working on it. -// (However, the data within the returned CycleData -// object itself is safe from modification; if another -// thread modifies the data, it will perform a -// copy-on-write, and thereby change the pointer stored -// within the object.) -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. No lock is made on the + * contents; there is no guarantee that some other thread won't modify this + * object's data while you are working on it. (However, the data within the + * returned CycleData object itself is safe from modification; if another + * thread modifies the data, it will perform a copy-on-write, and thereby + * change the pointer stored within the object.) + */ INLINE const CycleData *PipelineCyclerTrueImpl:: read_unlocked(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_unlocked(Thread *)", " ", TAU_USER); @@ -75,17 +59,14 @@ read_unlocked(Thread *current_thread) const { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::read -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the current stage of the pipeline as seen by -// this thread. This pointer should eventually be -// released by calling release_read(). -// -// There should be no outstanding write pointers on the -// data when this function is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the current + * stage of the pipeline as seen by this thread. This pointer should + * eventually be released by calling release_read(). + * + * There should be no outstanding write pointers on the data when this + * function is called. + */ INLINE const CycleData *PipelineCyclerTrueImpl:: read(Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read(Thread *)", " ", TAU_USER); @@ -97,13 +78,10 @@ read(Thread *current_thread) const { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::increment_read -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by read(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by read(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerTrueImpl:: increment_read(const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerTrueImpl::increment_read(const CycleData *)", " ", TAU_USER); @@ -115,12 +93,9 @@ increment_read(const CycleData *pointer) const { _lock.elevate_lock(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::release_read -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read(). + */ INLINE void PipelineCyclerTrueImpl:: release_read(const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerTrueImpl::release_read(const CycleData *)", " ", TAU_USER); @@ -132,57 +107,43 @@ release_read(const CycleData *pointer) const { _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::write -// Access: Public -// Description: Returns a non-const CycleData pointer, filled with a -// unique copy of the data for the current stage of the -// pipeline as seen by this thread. This pointer may -// now be used to write to the data, and that copy of -// the data will be propagated to all later stages of the -// pipeline. This pointer should eventually be released -// by calling release_write(). -// -// There may only be one outstanding write pointer on a -// given stage at a time, and if there is a write -// pointer there may be no read pointers on the same -// stage (but see elevate_read). -//////////////////////////////////////////////////////////////////// +/** + * Returns a non-const CycleData pointer, filled with a unique copy of the + * data for the current stage of the pipeline as seen by this thread. This + * pointer may now be used to write to the data, and that copy of the data + * will be propagated to all later stages of the pipeline. This pointer + * should eventually be released by calling release_write(). + * + * There may only be one outstanding write pointer on a given stage at a time, + * and if there is a write pointer there may be no read pointers on the same + * stage (but see elevate_read). + */ INLINE CycleData *PipelineCyclerTrueImpl:: write(Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::write(Thread *)", " ", TAU_USER); return write_stage(current_thread->get_pipeline_stage(), current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::write_upstream -// Access: Public -// Description: This special variant on write() will automatically -// propagate changes back to upstream pipeline stages. -// If force_to_0 is false, then it propagates back only -// as long as the CycleData pointers are equivalent, -// guaranteeing that it does not modify upstream data -// (other than the modification that will be performed -// by the code that returns this pointer). This is -// particularly appropriate for minor updates, where it -// doesn't matter much if the update is lost, such as -// storing a cached value. -// -// If force_to_0 is true, then the CycleData pointer for -// the current pipeline stage is propagated all the way -// back up to stage 0; after this call, there will be -// only one CycleData pointer that is duplicated in all -// stages between stage 0 and the current stage. This -// may undo some recent changes that were made -// independently at pipeline stage 0 (or any other -// upstream stage). However, it guarantees that the -// change that is to be applied at this pipeline stage -// will stick. This is slightly dangerous because of -// the risk of losing upstream changes; generally, this -// should only be done when you are confident that there -// are no upstream changes to be lost (for instance, for -// an object that has been recently created). -//////////////////////////////////////////////////////////////////// +/** + * This special variant on write() will automatically propagate changes back + * to upstream pipeline stages. If force_to_0 is false, then it propagates + * back only as long as the CycleData pointers are equivalent, guaranteeing + * that it does not modify upstream data (other than the modification that + * will be performed by the code that returns this pointer). This is + * particularly appropriate for minor updates, where it doesn't matter much if + * the update is lost, such as storing a cached value. + * + * If force_to_0 is true, then the CycleData pointer for the current pipeline + * stage is propagated all the way back up to stage 0; after this call, there + * will be only one CycleData pointer that is duplicated in all stages between + * stage 0 and the current stage. This may undo some recent changes that were + * made independently at pipeline stage 0 (or any other upstream stage). + * However, it guarantees that the change that is to be applied at this + * pipeline stage will stick. This is slightly dangerous because of the risk + * of losing upstream changes; generally, this should only be done when you + * are confident that there are no upstream changes to be lost (for instance, + * for an object that has been recently created). + */ INLINE CycleData *PipelineCyclerTrueImpl:: write_upstream(bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::write_upstream(bool, Thread *)", " ", TAU_USER); @@ -190,15 +151,11 @@ write_upstream(bool force_to_0, Thread *current_thread) { current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::elevate_read -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// current stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the current stage. + */ INLINE CycleData *PipelineCyclerTrueImpl:: elevate_read(const CycleData *pointer, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read(const CycleData *)", " ", TAU_USER); @@ -212,14 +169,11 @@ elevate_read(const CycleData *pointer, Thread *current_thread) { return new_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::elevate_read_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer, like elevate_read(), but also propagates the -// pointer back to upstream stages, like -// write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer, like + * elevate_read(), but also propagates the pointer back to upstream stages, + * like write_upstream(). + */ INLINE CycleData *PipelineCyclerTrueImpl:: elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_upstream(const CycleData *, bool)", " ", TAU_USER); @@ -233,13 +187,10 @@ elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current return new_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::increment_write -// Access: Public -// Description: Increments the count on a pointer previously -// retrieved by write(); now the pointer will need to be -// released twice. -//////////////////////////////////////////////////////////////////// +/** + * Increments the count on a pointer previously retrieved by write(); now the + * pointer will need to be released twice. + */ INLINE void PipelineCyclerTrueImpl:: increment_write(CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerTrueImpl::increment_write(CycleData *)", " ", TAU_USER); @@ -252,12 +203,9 @@ increment_write(CycleData *pointer) const { _lock.elevate_lock(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::release_write -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write(). + */ INLINE void PipelineCyclerTrueImpl:: release_write(CycleData *pointer) { TAU_PROFILE("void PipelineCyclerTrueImpl::release_write(CycleData *)", " ", TAU_USER); @@ -265,24 +213,19 @@ release_write(CycleData *pointer) { return release_write_stage(pipeline_stage, pointer); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::get_num_stages -// Access: Public -// Description: Returns the number of stages in the pipeline. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of stages in the pipeline. + */ INLINE int PipelineCyclerTrueImpl:: get_num_stages() { return _num_stages; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::read_stage_unlocked -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated stage of the pipeline. As in -// read_unlocked(), no lock is held on the returned -// pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * stage of the pipeline. As in read_unlocked(), no lock is held on the + * returned pointer. + */ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage_unlocked(int pipeline_stage) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage_unlocked(int)", " ", TAU_USER); @@ -292,17 +235,14 @@ read_stage_unlocked(int pipeline_stage) const { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::read_stage -// Access: Public -// Description: Returns a const CycleData pointer, filled with the -// data for the indicated stage of the pipeline. This -// pointer should eventually be released by calling -// release_read_stage(). -// -// There should be no outstanding write pointers on the -// data when this function is called. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const CycleData pointer, filled with the data for the indicated + * stage of the pipeline. This pointer should eventually be released by + * calling release_read_stage(). + * + * There should be no outstanding write pointers on the data when this + * function is called. + */ INLINE const CycleData *PipelineCyclerTrueImpl:: read_stage(int pipeline_stage, Thread *current_thread) const { TAU_PROFILE("const CycleData *PipelineCyclerTrueImpl::read_stage(int, Thread *)", " ", TAU_USER); @@ -313,12 +253,9 @@ read_stage(int pipeline_stage, Thread *current_thread) const { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::release_read_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// read_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to read_stage(). + */ INLINE void PipelineCyclerTrueImpl:: release_read_stage(int pipeline_stage, const CycleData *pointer) const { TAU_PROFILE("void PipelineCyclerTrueImpl::release_read_stage(int, const CycleData *)", " ", TAU_USER); @@ -329,15 +266,11 @@ release_read_stage(int pipeline_stage, const CycleData *pointer) const { _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::elevate_read_stage -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the indicated stage. + */ INLINE CycleData *PipelineCyclerTrueImpl:: elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread) { @@ -351,35 +284,28 @@ elevate_read_stage(int pipeline_stage, const CycleData *pointer, return new_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::elevate_read_stage_upstream -// Access: Public -// Description: Elevates a currently-held read pointer into a write -// pointer. This may or may not change the value of the -// pointer. It is only valid to do this if this is the -// only currently-outstanding read pointer on the -// indicated stage. -//////////////////////////////////////////////////////////////////// +/** + * Elevates a currently-held read pointer into a write pointer. This may or + * may not change the value of the pointer. It is only valid to do this if + * this is the only currently-outstanding read pointer on the indicated stage. + */ INLINE CycleData *PipelineCyclerTrueImpl:: -elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, +elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread) { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)", " ", TAU_USER); #ifdef _DEBUG nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL); nassertr(_data[pipeline_stage]._cdata == pointer, NULL); #endif - CycleData *new_pointer = + CycleData *new_pointer = write_stage_upstream(pipeline_stage, force_to_0, current_thread); _lock.release(); return new_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::release_write_stage -// Access: Public -// Description: Releases a pointer previously obtained via a call to -// write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Releases a pointer previously obtained via a call to write_stage(). + */ INLINE void PipelineCyclerTrueImpl:: release_write_stage(int pipeline_stage, CycleData *pointer) { TAU_PROFILE("void PipelineCyclerTrueImpl::release_write_stage(int, const CycleData *)", " ", TAU_USER); @@ -392,27 +318,21 @@ release_write_stage(int pipeline_stage, CycleData *pointer) { _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::get_parent_type -// Access: Public -// Description: Returns the type of object that owns this cycler, as -// reported by CycleData::get_parent_type(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of object that owns this cycler, as reported by + * CycleData::get_parent_type(). + */ INLINE TypeHandle PipelineCyclerTrueImpl:: get_parent_type() const { return _data[0]._cdata->get_parent_type(); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::cheat -// Access: Public -// Description: Returns a pointer without counting it. This is only -// intended for use as the return value for certain -// nassertr() functions, so the application can recover -// after a failure to manage the read and write pointers -// correctly. You should never call this function -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer without counting it. This is only intended for use as + * the return value for certain nassertr() functions, so the application can + * recover after a failure to manage the read and write pointers correctly. + * You should never call this function directly. + */ INLINE CycleData *PipelineCyclerTrueImpl:: cheat() const { TAU_PROFILE("CycleData *PipelineCyclerTrueImpl::cheat()", " ", TAU_USER); @@ -421,39 +341,30 @@ cheat() const { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::get_read_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This should -// only be used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This should only be used for debugging purposes. + */ INLINE int PipelineCyclerTrueImpl:: get_read_count() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::get_write_count -// Access: Public -// Description: Returns the number of handles currently outstanding -// to read the current stage of the data. This will -// normally only be either 0 or 1. This should only be -// used for debugging purposes. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of handles currently outstanding to read the current + * stage of the data. This will normally only be either 0 or 1. This should + * only be used for debugging purposes. + */ INLINE int PipelineCyclerTrueImpl:: get_write_count() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::cycle_2 -// Access: Private -// Description: This is a special implementation of cycle() for the -// special case of just two stages to the pipeline. It -// does the same thing as cycle(), but is a little bit -// faster because it knows there are exactly two stages. -//////////////////////////////////////////////////////////////////// +/** + * This is a special implementation of cycle() for the special case of just + * two stages to the pipeline. It does the same thing as cycle(), but is a + * little bit faster because it knows there are exactly two stages. + */ INLINE PT(CycleData) PipelineCyclerTrueImpl:: cycle_2() { TAU_PROFILE("PT(CycleData) PipelineCyclerTrueImpl::cycle_2()", " ", TAU_USER); @@ -470,15 +381,11 @@ cycle_2() { return last_val; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::cycle_3 -// Access: Private -// Description: This is a special implementation of cycle() for the -// special case of exactly three stages to the pipeline. -// It does the same thing as cycle(), but is a little -// bit faster because it knows there are exactly three -// stages. -//////////////////////////////////////////////////////////////////// +/** + * This is a special implementation of cycle() for the special case of exactly + * three stages to the pipeline. It does the same thing as cycle(), but is a + * little bit faster because it knows there are exactly three stages. + */ INLINE PT(CycleData) PipelineCyclerTrueImpl:: cycle_3() { TAU_PROFILE("PT(CycleData) PipelineCyclerTrueImpl::cycle_3()", " ", TAU_USER); @@ -500,11 +407,9 @@ cycle_3() { return last_val; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrueImpl::CyclerMutex:: CyclerMutex(PipelineCyclerTrueImpl *cycler) { #ifdef DEBUG_THREADS @@ -512,22 +417,18 @@ CyclerMutex(PipelineCyclerTrueImpl *cycler) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrueImpl::CycleDataNode:: CycleDataNode() : _writes_outstanding(0) { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrueImpl::CycleDataNode:: CycleDataNode(const PipelineCyclerTrueImpl::CycleDataNode ©) : _cdata(copy._cdata), @@ -535,21 +436,17 @@ CycleDataNode(const PipelineCyclerTrueImpl::CycleDataNode ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PipelineCyclerTrueImpl::CycleDataNode:: ~CycleDataNode() { nassertv(_writes_outstanding == 0); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PipelineCyclerTrueImpl::CycleDataNode:: operator = (const PipelineCyclerTrueImpl::CycleDataNode ©) { _cdata = copy._cdata; diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx index f1a8f0852a..9610a98bb9 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerTrueImpl.cxx -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrueImpl.cxx + * @author drose + * @date 2006-01-31 + */ #include "pipelineCyclerTrueImpl.h" @@ -19,11 +18,9 @@ #include "config_pipeline.h" #include "pipeline.h" -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PipelineCyclerTrueImpl:: PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline) : _pipeline(pipeline), @@ -43,11 +40,9 @@ PipelineCyclerTrueImpl(CycleData *initial_data, Pipeline *pipeline) : _pipeline->add_cycler(this); } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PipelineCyclerTrueImpl:: PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : _pipeline(copy._pipeline), @@ -56,18 +51,17 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : { ReMutexHolder holder(_lock); ReMutexHolder holder2(copy._lock); - + _num_stages = _pipeline->get_num_stages(); nassertv(_num_stages == copy._num_stages); _data = new CycleDataNode[_num_stages]; - + // It's no longer critically important that we preserve pointerwise - // equivalence between different stages in the copy, but it doesn't - // cost much and might be a little more efficient, so we do it - // anyway. + // equivalence between different stages in the copy, but it doesn't cost + // much and might be a little more efficient, so we do it anyway. typedef pmap Pointers; Pointers pointers; - + for (int i = 0; i < _num_stages; ++i) { PT(CycleData) &new_pt = pointers[copy._data[i]._cdata]; if (new_pt == NULL) { @@ -82,11 +76,9 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PipelineCyclerTrueImpl:: operator = (const PipelineCyclerTrueImpl ©) { ReMutexHolder holder1(_lock); @@ -109,11 +101,9 @@ operator = (const PipelineCyclerTrueImpl ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PipelineCyclerTrueImpl:: ~PipelineCyclerTrueImpl() { ReMutexHolder holder(_lock); @@ -125,16 +115,12 @@ PipelineCyclerTrueImpl:: _num_stages = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::write_stage -// Access: Public -// Description: Returns a pointer suitable for writing to the nth -// stage of the pipeline. This is for special -// applications that need to update the entire pipeline -// at once (for instance, to remove an invalid pointer). -// This pointer should later be released with -// release_write_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer suitable for writing to the nth stage of the pipeline. + * This is for special applications that need to update the entire pipeline at + * once (for instance, to remove an invalid pointer). This pointer should + * later be released with release_write_stage(). + */ CycleData *PipelineCyclerTrueImpl:: write_stage(int pipeline_stage, Thread *current_thread) { _lock.acquire(current_thread); @@ -148,27 +134,27 @@ write_stage(int pipeline_stage, Thread *current_thread) { CycleData *old_data = _data[pipeline_stage]._cdata; - // We only perform copy-on-write if this is the first CycleData - // requested for write mode from this thread. (We will never have - // outstanding writes for multiple threads, because we hold the - // CyclerMutex during the entire lifetime of write() .. release()). + // We only perform copy-on-write if this is the first CycleData requested + // for write mode from this thread. (We will never have outstanding writes + // for multiple threads, because we hold the CyclerMutex during the entire + // lifetime of write() .. release()). if (_data[pipeline_stage]._writes_outstanding == 0) { - // Only the node reference count is considered an important count - // for copy-on-write purposes. A standard reference of other than 1 - // just means that some code (other that the PipelineCycler) has a - // pointer, which is safe to modify. + // Only the node reference count is considered an important count for + // copy-on-write purposes. A standard reference of other than 1 just + // means that some code (other that the PipelineCycler) has a pointer, + // which is safe to modify. if (old_data->get_node_ref_count() != 1) { // Copy-on-write. _data[pipeline_stage]._cdata = old_data->make_copy(); if (pipeline_cat.is_debug()) { pipeline_cat.debug() - << "Copy-on-write a: " << old_data << " becomes " + << "Copy-on-write a: " << old_data << " becomes " << _data[pipeline_stage]._cdata << "\n"; - //nassertr(false, NULL); + // nassertr(false, NULL); } - - // Now we have differences between some of the data pointers, so - // we're "dirty". Mark it so. + + // Now we have differences between some of the data pointers, so we're + // "dirty". Mark it so. if (!_dirty && _num_stages != 1) { _pipeline->add_dirty_cycler(this); } @@ -179,13 +165,10 @@ write_stage(int pipeline_stage, Thread *current_thread) { return _data[pipeline_stage]._cdata; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::write_stage_upstream -// Access: Public -// Description: This special variant on write_stage() will -// automatically propagate changes back to upstream -// pipeline stages. See write_upstream(). -//////////////////////////////////////////////////////////////////// +/** + * This special variant on write_stage() will automatically propagate changes + * back to upstream pipeline stages. See write_upstream(). + */ CycleData *PipelineCyclerTrueImpl:: write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread) { _lock.acquire(current_thread); @@ -200,52 +183,50 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread CycleData *old_data = _data[pipeline_stage]._cdata; if (old_data->get_ref_count() != 1 || force_to_0) { - // Count the number of references before the current stage, and - // the number of references remaining other than those. + // Count the number of references before the current stage, and the number + // of references remaining other than those. int external_count = old_data->get_ref_count() - 1; int k = pipeline_stage - 1; while (k >= 0 && _data[k]._cdata == old_data) { --k; --external_count; } - - // We only perform copy-on-write if this is the first CycleData - // requested for write mode from this thread. (We will never have - // outstanding writes for multiple threads, because we hold the - // CyclerMutex during the entire lifetime of write() - // .. release()). + + // We only perform copy-on-write if this is the first CycleData requested + // for write mode from this thread. (We will never have outstanding + // writes for multiple threads, because we hold the CyclerMutex during the + // entire lifetime of write() .. release()). if (external_count > 0 && _data[pipeline_stage]._writes_outstanding == 0) { - // There are references other than the ones before this stage in - // the pipeline; perform a copy-on-write. + // There are references other than the ones before this stage in the + // pipeline; perform a copy-on-write. PT(CycleData) new_data = old_data->make_copy(); if (pipeline_cat.is_debug()) { pipeline_cat.debug() - << "Copy-on-write b: " << old_data << " becomes " + << "Copy-on-write b: " << old_data << " becomes " << new_data << "\n"; - //nassertr(false, NULL); + // nassertr(false, NULL); } - + k = pipeline_stage - 1; while (k >= 0 && (_data[k]._cdata == old_data || force_to_0)) { nassertr(_data[k]._writes_outstanding == 0, NULL); _data[k]._cdata = new_data.p(); --k; } - + _data[pipeline_stage]._cdata = new_data; - + if (k >= 0 || pipeline_stage + 1 < _num_stages) { - // Now we have differences between some of the data pointers, - // which makes us "dirty". + // Now we have differences between some of the data pointers, which + // makes us "dirty". if (!_dirty) { _pipeline->add_dirty_cycler(this); } } - + } else if (k >= 0 && force_to_0) { - // There are no external pointers, so no need to copy-on-write, - // but the current pointer doesn't go all the way back. Make it - // do so. + // There are no external pointers, so no need to copy-on-write, but the + // current pointer doesn't go all the way back. Make it do so. while (k >= 0) { nassertr(_data[k]._writes_outstanding == 0, NULL); _data[k]._cdata = old_data; @@ -253,29 +234,25 @@ write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread } } } - + ++(_data[pipeline_stage]._writes_outstanding); return _data[pipeline_stage]._cdata; } - -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::cycle -// Access: Private -// Description: Cycles the data between frames. This is only called -// from Pipeline::cycle(), and presumably it is only -// called if the cycler is "dirty". -// -// At the conclusion of this method, the cycler should -// clear its dirty flag if it is no longer "dirty"--that -// is, if all of the pipeline pointers are the same. -// -// The return value is the CycleData pointer which fell -// off the end of the cycle. If this is allowed to -// destruct immediately, there may be side-effects that -// cascade through the system, so the caller may choose -// to hold the pointer until it can safely be released -// later. -//////////////////////////////////////////////////////////////////// + +/** + * Cycles the data between frames. This is only called from + * Pipeline::cycle(), and presumably it is only called if the cycler is + * "dirty". + * + * At the conclusion of this method, the cycler should clear its dirty flag if + * it is no longer "dirty"--that is, if all of the pipeline pointers are the + * same. + * + * The return value is the CycleData pointer which fell off the end of the + * cycle. If this is allowed to destruct immediately, there may be side- + * effects that cascade through the system, so the caller may choose to hold + * the pointer until it can safely be released later. + */ PT(CycleData) PipelineCyclerTrueImpl:: cycle() { PT(CycleData) last_val = _data[_num_stages - 1]._cdata.p(); @@ -300,26 +277,24 @@ cycle() { return last_val; } -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::set_num_stages -// Access: Private -// Description: Changes the number of stages in the cycler. This is -// only called from Pipeline::set_num_stages(); -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of stages in the cycler. This is only called from + * Pipeline::set_num_stages(); + */ void PipelineCyclerTrueImpl:: set_num_stages(int num_stages) { nassertv(_lock.debug_is_locked()); if (num_stages <= _num_stages) { - // Don't bother to reallocate the array smaller; we just won't use - // the rest of the array. + // Don't bother to reallocate the array smaller; we just won't use the + // rest of the array. for (int i = _num_stages; i < num_stages; ++i) { nassertv(_data[i]._writes_outstanding == 0); _data[i]._cdata.clear(); } _num_stages = num_stages; - + } else { // To increase the array, we must reallocate it larger. @@ -340,11 +315,9 @@ set_num_stages(int num_stages) { } #ifdef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: PipelineCyclerTrueImpl::CyclerMutex::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PipelineCyclerTrueImpl::CyclerMutex:: output(ostream &out) const { out << "CyclerMutex "; @@ -353,5 +326,3 @@ output(ostream &out) const { #endif // DEBUG_THREADS #endif // THREADED_PIPELINE - - diff --git a/panda/src/pipeline/pipelineCyclerTrueImpl.h b/panda/src/pipeline/pipelineCyclerTrueImpl.h index 75bb422b4f..3aa7ffc232 100644 --- a/panda/src/pipeline/pipelineCyclerTrueImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.h @@ -1,16 +1,15 @@ -// Filename: pipelineCyclerTrueImpl.h -// Created by: drose (31Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pipelineCyclerTrueImpl.h + * @author drose + * @date 2006-01-31 + */ #ifndef PIPELINECYCLERTRUEIMPL_H #define PIPELINECYCLERTRUEIMPL_H @@ -30,21 +29,17 @@ class Pipeline; -//////////////////////////////////////////////////////////////////// -// Class : PipelineCyclerTrueImpl -// Description : This is the true, threaded implementation of -// PipelineCyclerBase. It is only compiled when -// threading is available and DO_PIPELINING is defined. -// -// This implementation is designed to do the actual work -// of cycling the data through a pipeline, and returning -// the actual CycleData appropriate to the current -// thread's pipeline stage. -// -// This is defined as a struct instead of a class, -// mainly to be consistent with -// PipelineCyclerTrivialImpl. -//////////////////////////////////////////////////////////////////// +/** + * This is the true, threaded implementation of PipelineCyclerBase. It is + * only compiled when threading is available and DO_PIPELINING is defined. + * + * This implementation is designed to do the actual work of cycling the data + * through a pipeline, and returning the actual CycleData appropriate to the + * current thread's pipeline stage. + * + * This is defined as a struct instead of a class, mainly to be consistent + * with PipelineCyclerTrivialImpl. + */ struct EXPCL_PANDA_PIPELINE PipelineCyclerTrueImpl : public PipelineCyclerLinks { private: PipelineCyclerTrueImpl(); @@ -76,11 +71,11 @@ public: INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const; INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const; CycleData *write_stage(int pipeline_stage, Thread *current_thread); - CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, + CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread); - INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, + INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread); - INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, + INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread); INLINE void release_write_stage(int pipeline_stage, CycleData *pointer); @@ -91,9 +86,9 @@ public: INLINE int get_write_count() const; public: - // We redefine the ReMutex class, solely so we can define the - // output() operator. This is only useful for debugging, but does - // no harm in the production case. + // We redefine the ReMutex class, solely so we can define the output() + // operator. This is only useful for debugging, but does no harm in the + // production case. class CyclerMutex : public ReMutex { public: INLINE CyclerMutex(PipelineCyclerTrueImpl *cycler); @@ -113,8 +108,8 @@ private: private: Pipeline *_pipeline; - // An array of PT(CycleData) objects representing the different - // copies of the cycled data, one for each stage. + // An array of PT(CycleData) objects representing the different copies of + // the cycled data, one for each stage. class CycleDataNode : public MemoryBase { public: INLINE CycleDataNode(); @@ -139,4 +134,3 @@ private: #endif // THREADED_PIPELINE #endif - diff --git a/panda/src/pipeline/pmutex.I b/panda/src/pipeline/pmutex.I index 406265ae2a..1cdfd011d4 100644 --- a/panda/src/pipeline/pmutex.I +++ b/panda/src/pipeline/pmutex.I @@ -1,23 +1,19 @@ -// Filename: pmutex.I -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pmutex.I + * @author drose + * @date 2002-08-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Mutex:: #ifdef DEBUG_THREADS Mutex() : MutexDebug(string(), false, false) @@ -27,11 +23,9 @@ Mutex() { } -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Mutex:: #ifdef DEBUG_THREADS Mutex(const char *name) : MutexDebug(string(name), false, false) @@ -41,11 +35,9 @@ Mutex(const char *) { } -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Mutex:: #ifdef DEBUG_THREADS Mutex(const string &name) : MutexDebug(name, false, false) @@ -55,20 +47,16 @@ Mutex(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Mutex:: ~Mutex() { } -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Copy Constructor -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE Mutex:: #ifdef DEBUG_THREADS Mutex(const Mutex ©) : MutexDebug(string(), false, false) @@ -79,11 +67,9 @@ Mutex(const Mutex ©) : MutexDebug(string(), false, false) nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Mutex::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE void Mutex:: operator = (const Mutex ©) { nassertv(false); diff --git a/panda/src/pipeline/pmutex.cxx b/panda/src/pipeline/pmutex.cxx index 97c089eadb..938e693155 100644 --- a/panda/src/pipeline/pmutex.cxx +++ b/panda/src/pipeline/pmutex.cxx @@ -1,16 +1,15 @@ -// Filename: pmutex.cxx -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pmutex.cxx + * @author drose + * @date 2002-08-08 + */ #include "pmutex.h" #include "thread.h" diff --git a/panda/src/pipeline/pmutex.h b/panda/src/pipeline/pmutex.h index 213ce78080..ef9e653027 100644 --- a/panda/src/pipeline/pmutex.h +++ b/panda/src/pipeline/pmutex.h @@ -1,16 +1,15 @@ -// Filename: pmutex.h -// Created by: cary (16Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pmutex.h + * @author cary + * @date 1998-09-16 + */ #ifndef PMUTEX_H #define PMUTEX_H @@ -19,25 +18,20 @@ #include "mutexDebug.h" #include "mutexDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : Mutex -// Description : A standard mutex, or mutual exclusion lock. Only one -// thread can hold ("lock") a mutex at any given time; -// other threads trying to grab the mutex will block -// until the holding thread releases it. -// -// The standard mutex is not reentrant: a thread may not -// attempt to lock it twice. Although this may happen -// to work on some platforms (e.g. Win32), it will not -// work on all platforms; on some platforms, a thread -// can deadlock itself by attempting to lock the same -// mutex twice. If your code requires a reentrant -// mutex, use the ReMutex class instead. -// -// This class inherits its implementation either from -// MutexDebug or MutexDirect, depending on the -// definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * A standard mutex, or mutual exclusion lock. Only one thread can hold + * ("lock") a mutex at any given time; other threads trying to grab the mutex + * will block until the holding thread releases it. + * + * The standard mutex is not reentrant: a thread may not attempt to lock it + * twice. Although this may happen to work on some platforms (e.g. Win32), + * it will not work on all platforms; on some platforms, a thread can deadlock + * itself by attempting to lock the same mutex twice. If your code requires a + * reentrant mutex, use the ReMutex class instead. + * + * This class inherits its implementation either from MutexDebug or + * MutexDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE Mutex : public MutexDebug #else @@ -56,8 +50,8 @@ private: INLINE void operator = (const Mutex ©); public: - // This is a global mutex set aside for the purpose of protecting - // Notify messages from being interleaved between threads. + // This is a global mutex set aside for the purpose of protecting Notify + // messages from being interleaved between threads. static Mutex _notify_mutex; }; diff --git a/panda/src/pipeline/psemaphore.I b/panda/src/pipeline/psemaphore.I index 783838b1fc..1111e01857 100644 --- a/panda/src/pipeline/psemaphore.I +++ b/panda/src/pipeline/psemaphore.I @@ -1,23 +1,19 @@ -// Filename: psemaphore.I -// Created by: drose (13Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file psemaphore.I + * @author drose + * @date 2008-10-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Semaphore:: Semaphore(int initial_count) : _lock("Semaphore::_lock"), @@ -27,44 +23,35 @@ Semaphore(int initial_count) : nassertv(_count >= 0); } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Semaphore:: ~Semaphore() { } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::Copy Constructor -// Access: Private -// Description: Do not attempt to copy semaphores. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy semaphores. + */ INLINE Semaphore:: -Semaphore(const Semaphore ©) : +Semaphore(const Semaphore ©) : _cvar(_lock) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy semaphores. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy semaphores. + */ INLINE void Semaphore:: operator = (const Semaphore ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::acquire -// Access: Published -// Description: Decrements the internal count. If the count was -// already at zero, blocks until the count is nonzero, -// then decrements it. -//////////////////////////////////////////////////////////////////// +/** + * Decrements the internal count. If the count was already at zero, blocks + * until the count is nonzero, then decrements it. + */ INLINE void Semaphore:: acquire() { TAU_PROFILE("void Semaphore::acquire()", " ", TAU_USER); @@ -76,12 +63,10 @@ acquire() { --_count; } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::try_acquire -// Access: Published -// Description: If the semaphore can be acquired without blocking, -// does so and returns true. Otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * If the semaphore can be acquired without blocking, does so and returns + * true. Otherwise, returns false. + */ INLINE bool Semaphore:: try_acquire() { TAU_PROFILE("void Semaphore::acquire(bool)", " ", TAU_USER); @@ -94,14 +79,12 @@ try_acquire() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::release -// Access: Published -// Description: Increments the semaphore's internal count. This may -// wake up another thread blocked on acquire(). -// -// Returns the count of the semaphore upon release. -//////////////////////////////////////////////////////////////////// +/** + * Increments the semaphore's internal count. This may wake up another thread + * blocked on acquire(). + * + * Returns the count of the semaphore upon release. + */ INLINE int Semaphore:: release() { TAU_PROFILE("void Semaphore::release()", " ", TAU_USER); @@ -111,13 +94,10 @@ release() { return _count; } -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::get_count -// Access: Published -// Description: Returns the current semaphore count. Note that this -// call is not thread-safe (the count may change at any -// time). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current semaphore count. Note that this call is not thread- + * safe (the count may change at any time). + */ INLINE int Semaphore:: get_count() const { TAU_PROFILE("void Semaphore::get_count()", " ", TAU_USER); diff --git a/panda/src/pipeline/psemaphore.cxx b/panda/src/pipeline/psemaphore.cxx index a9c2cb12bd..1142930e3a 100644 --- a/panda/src/pipeline/psemaphore.cxx +++ b/panda/src/pipeline/psemaphore.cxx @@ -1,24 +1,21 @@ -// Filename: psemaphore.cxx -// Created by: drose (13Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file psemaphore.cxx + * @author drose + * @date 2008-10-13 + */ #include "psemaphore.h" -//////////////////////////////////////////////////////////////////// -// Function: Semaphore::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Semaphore:: output(ostream &out) const { MutexHolder holder(_lock); diff --git a/panda/src/pipeline/psemaphore.h b/panda/src/pipeline/psemaphore.h index 5c8e58cc18..229320ab84 100644 --- a/panda/src/pipeline/psemaphore.h +++ b/panda/src/pipeline/psemaphore.h @@ -1,16 +1,15 @@ -// Filename: psemaphore.h -// Created by: drose (13Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file psemaphore.h + * @author drose + * @date 2008-10-13 + */ #ifndef PSEMAPHORE_H #define PSEMAPHORE_H @@ -20,17 +19,14 @@ #include "conditionVar.h" #include "mutexHolder.h" -//////////////////////////////////////////////////////////////////// -// Class : Semaphore -// Description : A classic semaphore synchronization primitive. -// -// A semaphore manages an internal counter which is -// decremented by each acquire() call and incremented by -// each release() call. The counter can never go below -// zero; when acquire() finds that it is zero, it -// blocks, waiting until some other thread calls -// release(). -//////////////////////////////////////////////////////////////////// +/** + * A classic semaphore synchronization primitive. + * + * A semaphore manages an internal counter which is decremented by each + * acquire() call and incremented by each release() call. The counter can + * never go below zero; when acquire() finds that it is zero, it blocks, + * waiting until some other thread calls release(). + */ class EXPCL_PANDA_PIPELINE Semaphore { PUBLISHED: INLINE Semaphore(int initial_count = 1); diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index 7f3528c14e..5800368b77 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -1,16 +1,15 @@ -// Filename: pythonThread.cxx -// Created by: drose (13Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonThread.cxx + * @author drose + * @date 2007-04-13 + */ #include "pythonThread.h" #include "pnotify.h" @@ -20,11 +19,9 @@ TypeHandle PythonThread::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PythonThread::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonThread:: PythonThread(PyObject *function, PyObject *args, const string &name, const string &sync_name) : @@ -53,11 +50,9 @@ PythonThread(PyObject *function, PyObject *args, } } -//////////////////////////////////////////////////////////////////// -// Function: PythonThread::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonThread:: ~PythonThread() { Py_DECREF(_function); @@ -65,16 +60,13 @@ PythonThread:: Py_XDECREF(_result); } -//////////////////////////////////////////////////////////////////// -// Function: PythonThread::join -// Access: Published -// Description: Blocks the calling process until the thread -// terminates. If the thread has already terminated, -// this returns immediately. -// -// The PythonThread flavor of this function returns the -// same value returned by the thread function. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the calling process until the thread terminates. If the thread has + * already terminated, this returns immediately. + * + * The PythonThread flavor of this function returns the same value returned by + * the thread function. + */ PyObject *PythonThread:: join() { Thread::join(); @@ -88,11 +80,9 @@ join() { return _result; } -//////////////////////////////////////////////////////////////////// -// Function: PythonThread::thread_main -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PythonThread:: thread_main() { _result = call_python_func(_function, _args); diff --git a/panda/src/pipeline/pythonThread.h b/panda/src/pipeline/pythonThread.h index 5742242085..f5b015deae 100644 --- a/panda/src/pipeline/pythonThread.h +++ b/panda/src/pipeline/pythonThread.h @@ -1,16 +1,15 @@ -// Filename: pythonThread.h -// Created by: drose (13Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonThread.h + * @author drose + * @date 2007-04-13 + */ #ifndef PYTHONTHREAD_H #define PYTHONTHREAD_H @@ -20,12 +19,11 @@ #include "thread.h" #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Class : PythonThread -// Description : This class is exposed to Python to allow creation of -// a Panda thread from the Python level. It will spawn -// a thread that executes an arbitrary Python functor. -//////////////////////////////////////////////////////////////////// +/** + * This class is exposed to Python to allow creation of a Panda thread from + * the Python level. It will spawn a thread that executes an arbitrary Python + * functor. + */ class EXPCL_PANDA_PIPELINE PythonThread : public Thread { PUBLISHED: PythonThread(PyObject *function, PyObject *args, @@ -62,4 +60,3 @@ private: #endif // HAVE_PYTHON #endif - diff --git a/panda/src/pipeline/reMutex.I b/panda/src/pipeline/reMutex.I index b7b2809805..e67f378c35 100644 --- a/panda/src/pipeline/reMutex.I +++ b/panda/src/pipeline/reMutex.I @@ -1,23 +1,19 @@ -// Filename: reMutex.I -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutex.I + * @author drose + * @date 2006-01-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutex:: #ifdef DEBUG_THREADS ReMutex() : MutexDebug(string(), true, false) @@ -27,11 +23,9 @@ ReMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutex:: #ifdef DEBUG_THREADS ReMutex(const char *name) : MutexDebug(string(name), true, false) @@ -41,11 +35,9 @@ ReMutex(const char *) { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutex:: #ifdef DEBUG_THREADS ReMutex(const string &name) : MutexDebug(name, true, false) @@ -55,20 +47,16 @@ ReMutex(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutex::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutex:: ~ReMutex() { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutex::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy mutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy mutexes. + */ INLINE void ReMutex:: operator = (const ReMutex ©) { nassertv(false); diff --git a/panda/src/pipeline/reMutex.cxx b/panda/src/pipeline/reMutex.cxx index 59598a5453..7c4c43b003 100644 --- a/panda/src/pipeline/reMutex.cxx +++ b/panda/src/pipeline/reMutex.cxx @@ -1,15 +1,14 @@ -// Filename: reMutex.cxx -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutex.cxx + * @author drose + * @date 2006-01-15 + */ #include "reMutex.h" diff --git a/panda/src/pipeline/reMutex.h b/panda/src/pipeline/reMutex.h index 72a51a0657..7a54847388 100644 --- a/panda/src/pipeline/reMutex.h +++ b/panda/src/pipeline/reMutex.h @@ -1,16 +1,15 @@ -// Filename: reMutex.h -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutex.h + * @author drose + * @date 2006-01-15 + */ #ifndef REMUTEX_H #define REMUTEX_H @@ -19,17 +18,14 @@ #include "mutexDebug.h" #include "reMutexDirect.h" -//////////////////////////////////////////////////////////////////// -// Class : ReMutex -// Description : A reentrant mutex. This kind of mutex can be locked -// more than once by the thread that already holds it, -// without deadlock. The thread must eventually release -// the mutex the same number of times it locked it. -// -// This class inherits its implementation either from -// MutexDebug or ReMutexDirect, depending on the -// definition of DEBUG_THREADS. -//////////////////////////////////////////////////////////////////// +/** + * A reentrant mutex. This kind of mutex can be locked more than once by the + * thread that already holds it, without deadlock. The thread must eventually + * release the mutex the same number of times it locked it. + * + * This class inherits its implementation either from MutexDebug or + * ReMutexDirect, depending on the definition of DEBUG_THREADS. + */ #ifdef DEBUG_THREADS class EXPCL_PANDA_PIPELINE ReMutex : public MutexDebug #else diff --git a/panda/src/pipeline/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I index e47e66f316..abdce3562f 100644 --- a/panda/src/pipeline/reMutexDirect.I +++ b/panda/src/pipeline/reMutexDirect.I @@ -1,25 +1,21 @@ -// Filename: reMutexDirect.I -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexDirect.I + * @author drose + * @date 2006-02-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexDirect:: -ReMutexDirect() +ReMutexDirect() #ifndef HAVE_REMUTEXTRUEIMPL : _cvar_impl(_lock_impl) #endif @@ -30,20 +26,16 @@ ReMutexDirect() #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexDirect:: ~ReMutexDirect() { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::Copy Constructor -// Access: Private -// Description: Do not attempt to copy reMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy reMutexes. + */ INLINE ReMutexDirect:: ReMutexDirect(const ReMutexDirect ©) #ifndef HAVE_REMUTEXTRUEIMPL @@ -53,31 +45,24 @@ ReMutexDirect(const ReMutexDirect ©) nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy reMutexes. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy reMutexes. + */ INLINE void ReMutexDirect:: operator = (const ReMutexDirect ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::acquire -// Access: Published -// Description: Grabs the reMutex if it is available. If it is not -// available, blocks until it becomes available, then -// grabs it. In either case, the function does not -// return until the reMutex is held; you should then call -// unlock(). -// -// This method is considered const so that you can lock -// and unlock const reMutexes, mainly to allow thread-safe -// access to otherwise const data. -// -// Also see ReMutexHolder. -//////////////////////////////////////////////////////////////////// +/** + * Grabs the reMutex if it is available. If it is not available, blocks until + * it becomes available, then grabs it. In either case, the function does not + * return until the reMutex is held; you should then call unlock(). + * + * This method is considered const so that you can lock and unlock const + * reMutexes, mainly to allow thread-safe access to otherwise const data. + * + * Also see ReMutexHolder. + */ INLINE void ReMutexDirect:: acquire() const { TAU_PROFILE("void ReMutexDirect::acquire()", " ", TAU_USER); @@ -88,13 +73,10 @@ acquire() const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::acquire -// Access: Published -// Description: This variant on acquire() accepts the current thread as -// a parameter, if it is already known, as an -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * This variant on acquire() accepts the current thread as a parameter, if it + * is already known, as an optimization. + */ INLINE void ReMutexDirect:: acquire(Thread *current_thread) const { TAU_PROFILE("void ReMutexDirect::acquire(Thread *)", " ", TAU_USER); @@ -105,13 +87,10 @@ acquire(Thread *current_thread) const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::try_acquire -// Access: Published -// Description: Returns immediately, with a true value indicating the -// mutex has been acquired, and false indicating it has -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns immediately, with a true value indicating the mutex has been + * acquired, and false indicating it has not. + */ INLINE bool ReMutexDirect:: try_acquire() const { TAU_PROFILE("void ReMutexDirect::acquire(bool)", " ", TAU_USER); @@ -122,13 +101,10 @@ try_acquire() const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::try_acquire -// Access: Published -// Description: Returns immediately, with a true value indicating the -// mutex has been acquired, and false indicating it has -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns immediately, with a true value indicating the mutex has been + * acquired, and false indicating it has not. + */ INLINE bool ReMutexDirect:: try_acquire(Thread *current_thread) const { TAU_PROFILE("void ReMutexDirect::acquire(bool)", " ", TAU_USER); @@ -139,21 +115,16 @@ try_acquire(Thread *current_thread) const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::elevate_lock -// Access: Published -// Description: This method increments the lock count, assuming the -// calling thread already holds the lock. After this -// call, release() will need to be called one additional -// time to release the lock. -// -// This method really performs the same function as -// acquire(), but it offers a potential (slight) -// performance benefit when the calling thread knows -// that it already holds the lock. It is an error to -// call this when the calling thread does not hold the -// lock. -//////////////////////////////////////////////////////////////////// +/** + * This method increments the lock count, assuming the calling thread already + * holds the lock. After this call, release() will need to be called one + * additional time to release the lock. + * + * This method really performs the same function as acquire(), but it offers a + * potential (slight) performance benefit when the calling thread knows that + * it already holds the lock. It is an error to call this when the calling + * thread does not hold the lock. + */ INLINE void ReMutexDirect:: elevate_lock() const { TAU_PROFILE("void ReMutexDirect::elevate_lock()", " ", TAU_USER); @@ -164,16 +135,13 @@ elevate_lock() const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::release -// Access: Published -// Description: Releases the reMutex. It is an error to call this if -// the reMutex was not already locked. -// -// This method is considered const so that you can lock -// and unlock const reMutexes, mainly to allow thread-safe -// access to otherwise const data. -//////////////////////////////////////////////////////////////////// +/** + * Releases the reMutex. It is an error to call this if the reMutex was not + * already locked. + * + * This method is considered const so that you can lock and unlock const + * reMutexes, mainly to allow thread-safe access to otherwise const data. + */ INLINE void ReMutexDirect:: release() const { TAU_PROFILE("void ReMutexDirect::release()", " ", TAU_USER); @@ -184,73 +152,54 @@ release() const { #endif // HAVE_REMUTEXTRUEIMPL } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::debug_is_locked -// Access: Published -// Description: Returns true if the current thread has locked the -// ReMutex, false otherwise. This method is only intended -// for use in debugging, hence the method name; in the -// ReMutexDirect case, it always returns true, since -// there's not a reliable way to determine this -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the current thread has locked the ReMutex, false otherwise. + * This method is only intended for use in debugging, hence the method name; + * in the ReMutexDirect case, it always returns true, since there's not a + * reliable way to determine this otherwise. + */ INLINE bool ReMutexDirect:: debug_is_locked() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::set_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void ReMutexDirect:: set_name(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::clear_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE void ReMutexDirect:: clear_name() { } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::has_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE bool ReMutexDirect:: has_name() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::get_name -// Access: Public -// Description: The mutex name is only defined when compiling in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * The mutex name is only defined when compiling in DEBUG_THREADS mode. + */ INLINE string ReMutexDirect:: get_name() const { return string(); } #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_acquire -// Access: Private -// Description: The private implementation of acquire(), for the case in -// which the underlying lock system does not provide a -// reentrant mutex (and therefore we have to build this -// functionality on top of the existing non-reentrant -// mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ INLINE void ReMutexDirect:: do_acquire() { do_acquire(Thread::get_current_thread()); @@ -258,18 +207,14 @@ do_acquire() { #endif #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_try_acquire -// Access: Private -// Description: The private implementation of acquire(false), for the -// case in which the underlying lock system does not -// provide a reentrant mutex (and therefore we have to -// build this functionality on top of the existing -// non-reentrant mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(false), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ INLINE bool ReMutexDirect:: do_try_acquire() { return do_try_acquire(Thread::get_current_thread()); } #endif - diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index 364e9da1e9..33ff64c4cc 100644 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -1,43 +1,37 @@ -// Filename: reMutexDirect.cxx -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexDirect.cxx + * @author drose + * @date 2006-02-13 + */ #include "reMutexDirect.h" #include "thread.h" #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::output -// Access: Published -// Description: This method is declared virtual in MutexDebug, but -// non-virtual in ReMutexDirect. -//////////////////////////////////////////////////////////////////// +/** + * This method is declared virtual in MutexDebug, but non-virtual in + * ReMutexDirect. + */ void ReMutexDirect:: output(ostream &out) const { out << "ReMutex " << (void *)this; } #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_acquire -// Access: Private -// Description: The private implementation of acquire(), for the case in -// which the underlying lock system does not provide a -// reentrant mutex (and therefore we have to build this -// functionality on top of the existing non-reentrant -// mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ void ReMutexDirect:: do_acquire(Thread *current_thread) { _lock_impl.acquire(); @@ -50,19 +44,18 @@ do_acquire(Thread *current_thread) { } } else if (_locking_thread == current_thread) { - // The mutex is already locked by this thread. Increment the lock - // count. + // The mutex is already locked by this thread. Increment the lock count. ++_lock_count; nassertd(_lock_count > 0) { } - + } else { - // The mutex is locked by some other thread. Go to sleep on the - // condition variable until it's unlocked. + // The mutex is locked by some other thread. Go to sleep on the condition + // variable until it's unlocked. while (_locking_thread != (Thread *)NULL) { _cvar_impl.wait(); } - + _locking_thread = current_thread; ++_lock_count; nassertd(_lock_count == 1) { @@ -73,15 +66,12 @@ do_acquire(Thread *current_thread) { #endif // !HAVE_REMUTEXTRUEIMPL #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_try_acquire -// Access: Private -// Description: The private implementation of acquire(false), for the -// case in which the underlying lock system does not -// provide a reentrant mutex (and therefore we have to -// build this functionality on top of the existing -// non-reentrant mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(false), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ bool ReMutexDirect:: do_try_acquire(Thread *current_thread) { bool acquired = true; @@ -95,12 +85,11 @@ do_try_acquire(Thread *current_thread) { } } else if (_locking_thread == current_thread) { - // The mutex is already locked by this thread. Increment the lock - // count. + // The mutex is already locked by this thread. Increment the lock count. ++_lock_count; nassertd(_lock_count > 0) { } - + } else { // The mutex is locked by some other thread. Return false. acquired = false; @@ -112,15 +101,12 @@ do_try_acquire(Thread *current_thread) { #endif // !HAVE_REMUTEXTRUEIMPL #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_elevate_lock -// Access: Private -// Description: The private implementation of acquire(), for the case in -// which the underlying lock system does not provide a -// reentrant mutex (and therefore we have to build this -// functionality on top of the existing non-reentrant -// mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of acquire(), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ void ReMutexDirect:: do_elevate_lock() { _lock_impl.acquire(); @@ -137,8 +123,8 @@ do_elevate_lock() { } #endif // NDEBUG - // We know the mutex is already locked by this thread. Increment - // the lock count. + // We know the mutex is already locked by this thread. Increment the lock + // count. ++_lock_count; nassertd(_lock_count > 0) { } @@ -148,15 +134,12 @@ do_elevate_lock() { #endif // !HAVE_REMUTEXTRUEIMPL #ifndef HAVE_REMUTEXTRUEIMPL -//////////////////////////////////////////////////////////////////// -// Function: ReMutexDirect::do_release -// Access: Private -// Description: The private implementation of release(), for the case -// in which the underlying lock system does not provide -// a reentrant mutex (and therefore we have to build -// this functionality on top of the existing -// non-reentrant mutex). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of release(), for the case in which the + * underlying lock system does not provide a reentrant mutex (and therefore we + * have to build this functionality on top of the existing non-reentrant + * mutex). + */ void ReMutexDirect:: do_release() { _lock_impl.acquire(); diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index 3336171682..ce86e774f0 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -1,16 +1,15 @@ -// Filename: reMutexDirect.h -// Created by: drose (13Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexDirect.h + * @author drose + * @date 2006-02-13 + */ #ifndef REMUTEXDIRECT_H #define REMUTEXDIRECT_H @@ -23,12 +22,11 @@ class Thread; #ifndef DEBUG_THREADS -//////////////////////////////////////////////////////////////////// -// Class : ReMutexDirect -// Description : This class implements a standard reMutex by making -// direct calls to the underlying implementation layer. -// It doesn't perform any debugging operations. -//////////////////////////////////////////////////////////////////// +/** + * This class implements a standard reMutex by making direct calls to the + * underlying implementation layer. It doesn't perform any debugging + * operations. + */ class EXPCL_PANDA_PIPELINE ReMutexDirect { protected: INLINE ReMutexDirect(); diff --git a/panda/src/pipeline/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I index 899b3023ca..25a0032b4e 100644 --- a/panda/src/pipeline/reMutexHolder.I +++ b/panda/src/pipeline/reMutexHolder.I @@ -1,23 +1,19 @@ -// Filename: reMutexHolder.I -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexHolder.I + * @author drose + * @date 2006-01-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexHolder:: ReMutexHolder(const ReMutex &mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -26,13 +22,10 @@ ReMutexHolder(const ReMutex &mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Constructor -// Access: Public -// Description: This variant on the constructor accepts the current -// thread as a parameter, if it is already known, as an -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * This variant on the constructor accepts the current thread as a parameter, + * if it is already known, as an optimization. + */ INLINE ReMutexHolder:: ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -41,17 +34,13 @@ ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Constructor -// Access: Public -// Description: If the ReMutexHolder constructor is given a pointer to -// a ReMutex object (instead of an actual object), it will -// first check to see if the pointer is NULL, and -// allocate a new ReMutex if it is. This is intended as a -// convenience for functions that may need to reference -// a ReMutex at static init time, when it is impossible to -// guarantee ordering of initializers. -//////////////////////////////////////////////////////////////////// +/** + * If the ReMutexHolder constructor is given a pointer to a ReMutex object + * (instead of an actual object), it will first check to see if the pointer is + * NULL, and allocate a new ReMutex if it is. This is intended as a + * convenience for functions that may need to reference a ReMutex at static + * init time, when it is impossible to guarantee ordering of initializers. + */ INLINE ReMutexHolder:: ReMutexHolder(ReMutex *&mutex) { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -63,11 +52,9 @@ ReMutexHolder(ReMutex *&mutex) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ReMutexHolder:: ~ReMutexHolder() { #if defined(HAVE_THREADS) || defined(DEBUG_THREADS) @@ -75,21 +62,17 @@ INLINE ReMutexHolder:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Copy Constructor -// Access: Private -// Description: Do not attempt to copy ReMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy ReMutexHolders. + */ INLINE ReMutexHolder:: ReMutexHolder(const ReMutexHolder ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ReMutexHolder::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy ReMutexHolders. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy ReMutexHolders. + */ INLINE void ReMutexHolder:: operator = (const ReMutexHolder ©) { nassertv(false); diff --git a/panda/src/pipeline/reMutexHolder.cxx b/panda/src/pipeline/reMutexHolder.cxx index daf5235dfb..e36b2c19e3 100644 --- a/panda/src/pipeline/reMutexHolder.cxx +++ b/panda/src/pipeline/reMutexHolder.cxx @@ -1,15 +1,14 @@ -// Filename: reMutexHolder.cxx -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexHolder.cxx + * @author drose + * @date 2006-01-15 + */ #include "reMutexHolder.h" diff --git a/panda/src/pipeline/reMutexHolder.h b/panda/src/pipeline/reMutexHolder.h index 0941501126..f0830803fb 100644 --- a/panda/src/pipeline/reMutexHolder.h +++ b/panda/src/pipeline/reMutexHolder.h @@ -1,16 +1,15 @@ -// Filename: reMutexHolder.h -// Created by: drose (15Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file reMutexHolder.h + * @author drose + * @date 2006-01-15 + */ #ifndef REMUTEXHOLDER_H #define REMUTEXHOLDER_H @@ -20,10 +19,9 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : ReMutexHolder -// Description : Similar to MutexHolder, but for a reentrant mutex. -//////////////////////////////////////////////////////////////////// +/** + * Similar to MutexHolder, but for a reentrant mutex. + */ class EXPCL_PANDA_PIPELINE ReMutexHolder { public: INLINE ReMutexHolder(const ReMutex &mutex); diff --git a/panda/src/pipeline/test_atomic.cxx b/panda/src/pipeline/test_atomic.cxx index e7229a4b90..ae371114e4 100644 --- a/panda/src/pipeline/test_atomic.cxx +++ b/panda/src/pipeline/test_atomic.cxx @@ -1,16 +1,15 @@ -// Filename: test_atomic.cxx -// Created by: drose (19Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_atomic.cxx + * @author drose + * @date 2006-04-19 + */ #include "pandabase.h" #include "thread.h" @@ -39,7 +38,7 @@ public: MyThread(const string &name) : Thread(name, name) { } - + virtual void thread_main() { OUTPUT(nout << *this << " beginning.\n"); diff --git a/panda/src/pipeline/test_concurrency.cxx b/panda/src/pipeline/test_concurrency.cxx index edf54bed2f..9d092d08c8 100644 --- a/panda/src/pipeline/test_concurrency.cxx +++ b/panda/src/pipeline/test_concurrency.cxx @@ -1,16 +1,15 @@ -// Filename: test_concurrency.cxx -// Created by: drose (06Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_concurrency.cxx + * @author drose + * @date 2006-04-06 + */ #include "pandabase.h" #include "thread.h" @@ -19,8 +18,8 @@ #include "pointerTo.h" #include "trueClock.h" -// The number of iterations to spin within each thread, before -// printing output. +// The number of iterations to spin within each thread, before printing +// output. static const long long iterations_per_output = 100000000; // The amount of time, in seconds, to wait between spawning threads. @@ -51,37 +50,37 @@ volatile MemBlock memblock[number_of_threads]; class MyThread : public Thread { public: - MyThread(const string &name, int index) : + MyThread(const string &name, int index) : Thread(name, name), _index(index) { } - + virtual void thread_main() { OUTPUT(nout << *this << " beginning.\n"); - + double total_seconds = 0.0; TrueClock *clock = TrueClock::get_global_ptr(); volatile int snarf; - + while (total_seconds < thread_run_time) { double start_time = clock->get_short_time(); - + for (long long i = 0; i < iterations_per_output; ++i) { memblock[_index]._value = snarf; } double end_time = clock->get_short_time(); - + double elapsed_seconds = end_time - start_time; double iterations_per_second = iterations_per_output / elapsed_seconds; OUTPUT(nout << *this << " achieving " << iterations_per_second / 1000000.0 << " million iterations per second.\n"); - + total_seconds += elapsed_seconds; - } - + } + OUTPUT(nout << *this << " exiting.\n"); } diff --git a/panda/src/pipeline/test_delete.cxx b/panda/src/pipeline/test_delete.cxx index 16bae7e254..f49606a6f1 100644 --- a/panda/src/pipeline/test_delete.cxx +++ b/panda/src/pipeline/test_delete.cxx @@ -1,16 +1,15 @@ -// Filename: test_delete.cxx -// Created by: drose (18Apr06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_delete.cxx + * @author drose + * @date 2006-04-18 + */ #include "pandabase.h" #include "thread.h" @@ -84,7 +83,7 @@ public: MyThread(const string &name) : Thread(name, name) { } - + virtual void thread_main() { OUTPUT(nout << *this << " beginning.\n"); @@ -108,7 +107,7 @@ public: } int num_del = (int)random_f(max_doobers_per_chunk); num_del = min(num_del, (int)doobers.size()); - + for (int j = 0; j < num_del; ++j) { assert(!doobers.empty()); delete doobers.back(); diff --git a/panda/src/pipeline/test_diners.cxx b/panda/src/pipeline/test_diners.cxx index c29dc3eb02..0a8f01e484 100644 --- a/panda/src/pipeline/test_diners.cxx +++ b/panda/src/pipeline/test_diners.cxx @@ -1,16 +1,15 @@ -// Filename: test_diners.cxx -// Created by: cary (16Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_diners.cxx + * @author cary + * @date 1998-09-16 + */ // A solution to the famous dining philosophers, implemented using the // threading abstraction. This program exercises thread creation and @@ -26,9 +25,8 @@ #include "pstrtod.h" #ifdef WIN32_VC -// Under Windows, the rand() function seems to return a sequence -// per-thread, so we use this trick to set each thread to a different -// seed. +// Under Windows, the rand() function seems to return a sequence per-thread, +// so we use this trick to set each thread to a different seed. static int last_rand = 0; #endif /* __WIN32__ */ @@ -61,9 +59,8 @@ public: ChopstickMutex chopsticks[N_DINERS]; -// At most n philosophers are allowed into the room, others would have to -// wait at the door. This restriction demonstrates the use of condition -// variables. +// At most n philosophers are allowed into the room, others would have to wait +// at the door. This restriction demonstrates the use of condition variables. Mutex room_mutex; @@ -184,7 +181,7 @@ main(int argc, char *argv[]) { while (room_occupancy != 0) { room_condition.wait(); - } + } room_mutex.release(); diff --git a/panda/src/pipeline/test_mutex.cxx b/panda/src/pipeline/test_mutex.cxx index 27a5e0b939..39f5e8a24c 100644 --- a/panda/src/pipeline/test_mutex.cxx +++ b/panda/src/pipeline/test_mutex.cxx @@ -1,16 +1,15 @@ -// Filename: test_mutex.cxx -// Created by: drose (29Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_mutex.cxx + * @author drose + * @date 2006-03-29 + */ #include "pandabase.h" #include "thread.h" @@ -23,12 +22,12 @@ static const double thread_duration = 5.0; class MyThread : public Thread { public: - MyThread(const string &name, MutexImpl &m1, double period) : + MyThread(const string &name, MutexImpl &m1, double period) : Thread(name, name), - _m1(m1), _period(period) + _m1(m1), _period(period) { } - + virtual void thread_main() { TrueClock *clock = TrueClock::get_global_ptr(); double start = clock->get_short_time(); diff --git a/panda/src/pipeline/test_setjmp.cxx b/panda/src/pipeline/test_setjmp.cxx index d0b3a10bbb..3ce1bcf075 100644 --- a/panda/src/pipeline/test_setjmp.cxx +++ b/panda/src/pipeline/test_setjmp.cxx @@ -1,16 +1,15 @@ -// Filename: test_setjmp.cxx -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_setjmp.cxx + * @author drose + * @date 2007-06-19 + */ #include "pandabase.h" @@ -19,9 +18,8 @@ int main(int argc, char *argv[]) { - // If we have ucontext.h, we don't need to use setjmp, so don't - // bother trying to compile this program (it may not compile - // anyway). + // If we have ucontext.h, we don't need to use setjmp, so don't bother + // trying to compile this program (it may not compile anyway). #ifndef PHAVE_UCONTEXT_H jmp_buf buf1, buf2; @@ -33,7 +31,7 @@ main(int argc, char *argv[]) { size_t word_size = sizeof(buf1[0]); size_t num_words = sizeof(buf1) / word_size; - + cerr << num_words << " words of " << word_size << " bytes\n"; for (size_t i = 0; i < num_words; ++i) { cerr << " word " << i << ": " << (void *)buf1[i] << " vs. " @@ -42,6 +40,6 @@ main(int argc, char *argv[]) { cerr << "scratch = " << (void *)scratch << "\n"; cerr << "scratch end = " << (void *)(scratch + 1024) << "\n"; #endif // PHAVE_UCONTEXT_H - + return 0; } diff --git a/panda/src/pipeline/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx index 0c07326a0a..ebf6698216 100644 --- a/panda/src/pipeline/test_threaddata.cxx +++ b/panda/src/pipeline/test_threaddata.cxx @@ -1,16 +1,15 @@ -// Filename: test_threaddata.cxx -// Created by: cary (16Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_threaddata.cxx + * @author cary + * @date 1998-09-16 + */ #include "pandabase.h" #include "thread.h" @@ -33,7 +32,7 @@ private: ThreadWithData:: -ThreadWithData(const string &name, int parameter) : +ThreadWithData(const string &name, int parameter) : Thread(name, name), _parameter(parameter) { @@ -68,7 +67,7 @@ main() { cout << "Unable to start " << name << ".\n"; } else { MutexHolder holder(cout_mutex); - cout << "Started " << name << ", count = " + cout << "Started " << name << ", count = " << thread->get_ref_count() << "\n"; } } diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index fd503c68e5..159f764d6d 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -1,108 +1,84 @@ -// Filename: thread.I -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file thread.I + * @author drose + * @date 2002-08-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Thread::Copy Constructor -// Access: Private -// Description: Do not attempt to copy threads. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy threads. + */ INLINE Thread:: Thread(const Thread ©) : _impl(this) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::Copy Assignment Operator -// Access: Private -// Description: Do not attempt to copy threads. -//////////////////////////////////////////////////////////////////// +/** + * Do not attempt to copy threads. + */ INLINE void Thread:: operator = (const Thread ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_sync_name -// Access: Published -// Description: Returns the sync name of the thread. This name -// collects threads into "sync groups", which are -// expected to run synchronously. This is mainly used -// for the benefit of PStats; threads with the same sync -// name can be ticked all at once via the thread_tick() -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sync name of the thread. This name collects threads into "sync + * groups", which are expected to run synchronously. This is mainly used for + * the benefit of PStats; threads with the same sync name can be ticked all at + * once via the thread_tick() call. + */ INLINE const string &Thread:: get_sync_name() const { return _sync_name; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_pstats_index -// Access: Published -// Description: Returns the PStats index associated with this thread, -// or -1 if no index has yet been associated with this -// thread. This is used internally by the PStatClient; -// you should not need to call this directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStats index associated with this thread, or -1 if no index has + * yet been associated with this thread. This is used internally by the + * PStatClient; you should not need to call this directly. + */ INLINE int Thread:: get_pstats_index() const { return _pstats_index; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_unique_id -// Access: Published -// Description: Returns a string that is guaranteed to be unique to -// this thread, across all processes on the machine, -// during at least the lifetime of this process. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that is guaranteed to be unique to this thread, across all + * processes on the machine, during at least the lifetime of this process. + */ INLINE string Thread:: get_unique_id() const { return _impl.get_unique_id(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_pipeline_stage -// Access: Published -// Description: Returns the Pipeline stage number associated with -// this thread. The default stage is 0 if no stage is -// specified otherwise. See set_pipeline_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the Pipeline stage number associated with this thread. The default + * stage is 0 if no stage is specified otherwise. See set_pipeline_stage(). + */ INLINE int Thread:: get_pipeline_stage() const { return _pipeline_stage; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_min_pipeline_stage -// Access: Published -// Description: Sets this thread's pipeline stage number to at least -// the indicated value, unless it is already larger. -// See set_pipeline_stage(). -//////////////////////////////////////////////////////////////////// +/** + * Sets this thread's pipeline stage number to at least the indicated value, + * unless it is already larger. See set_pipeline_stage(). + */ INLINE void Thread:: set_min_pipeline_stage(int min_pipeline_stage) { set_pipeline_stage(max(_pipeline_stage, min_pipeline_stage)); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_main_thread -// Access: Published, Static -// Description: Returns a pointer to the "main" Thread object--this -// is the Thread that started the whole process. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the "main" Thread object--this is the Thread that + * started the whole process. + */ INLINE Thread *Thread:: get_main_thread() { if (_main_thread == (Thread *)NULL) { @@ -111,15 +87,12 @@ get_main_thread() { return _main_thread; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_external_thread -// Access: Published, Static -// Description: Returns a pointer to the "external" Thread -// object--this is a special Thread object that -// corresponds to any thread spawned outside of Panda's -// threading interface. Note that multiple different -// threads may share this same pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the "external" Thread object--this is a special Thread + * object that corresponds to any thread spawned outside of Panda's threading + * interface. Note that multiple different threads may share this same + * pointer. + */ INLINE Thread *Thread:: get_external_thread() { if (_external_thread == (Thread *)NULL) { @@ -128,19 +101,16 @@ get_external_thread() { return _external_thread; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_current_thread -// Access: Published, Static -// Description: Returns a pointer to the currently-executing Thread -// object. If this is called from the main thread, this -// will return the same value as get_main_thread(). -// -// This will always return some valid Thread pointer. -// It will never return NULL, even if the current thread -// was spawned outside of Panda's threading system, -// although all non-Panda threads will return the exact -// same Thread pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the currently-executing Thread object. If this is + * called from the main thread, this will return the same value as + * get_main_thread(). + * + * This will always return some valid Thread pointer. It will never return + * NULL, even if the current thread was spawned outside of Panda's threading + * system, although all non-Panda threads will return the exact same Thread + * pointer. + */ INLINE Thread *Thread:: get_current_thread() { TAU_PROFILE("Thread *Thread::get_current_thread()", " ", TAU_USER); @@ -155,14 +125,11 @@ get_current_thread() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_current_pipeline_stage -// Access: Published, Static -// Description: Returns the integer pipeline stage associated with -// the current thread. This is the same thing as -// get_current_thread()->get_pipeline_stage(), but it -// may be faster to retrieve in some contexts. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer pipeline stage associated with the current thread. + * This is the same thing as get_current_thread()->get_pipeline_stage(), but + * it may be faster to retrieve in some contexts. + */ INLINE int Thread:: get_current_pipeline_stage() { TAU_PROFILE("int Thread::get_current_pipeline_stage()", " ", TAU_USER); @@ -174,13 +141,10 @@ get_current_pipeline_stage() { #endif // !THREADED_PIPELINE } -//////////////////////////////////////////////////////////////////// -// Function: Thread::is_threading_supported -// Access: Published, Static -// Description: Returns true if threading support has been compiled -// in and enabled, or false if no threading is available -// (and Thread::start() will always fail). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if threading support has been compiled in and enabled, or + * false if no threading is available (and Thread::start() will always fail). + */ INLINE bool Thread:: is_threading_supported() { if (!support_threads) { @@ -189,14 +153,11 @@ is_threading_supported() { return ThreadImpl::is_threading_supported(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::is_true_threads -// Access: Published, Static -// Description: Returns true if a real threading library is available -// that supports actual OS-implemented threads, or false -// if the only threading we can provide is simulated -// user-space threading. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a real threading library is available that supports actual + * OS-implemented threads, or false if the only threading we can provide is + * simulated user-space threading. + */ INLINE bool Thread:: is_true_threads() { if (!support_threads) { @@ -205,18 +166,13 @@ is_true_threads() { return ThreadImpl::is_true_threads(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::is_simple_threads -// Access: Published, Static -// Description: Returns true if Panda is currently compiled for -// "simple threads", which is to say, cooperative -// context switching only, reducing the need for quite -// so many critical section protections. This is not -// necessarily the opposite of "true threads", since one -// possible implementation of simple threads is via true -// threads with mutex protection to ensure only one runs -// at a time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if Panda is currently compiled for "simple threads", which is + * to say, cooperative context switching only, reducing the need for quite so + * many critical section protections. This is not necessarily the opposite of + * "true threads", since one possible implementation of simple threads is via + * true threads with mutex protection to ensure only one runs at a time. + */ INLINE bool Thread:: is_simple_threads() { if (!support_threads) { @@ -225,75 +181,57 @@ is_simple_threads() { return ThreadImpl::is_simple_threads(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::sleep -// Access: Published, Static -// Description: Suspends the current thread for at least the -// indicated amount of time. It might be suspended for -// longer. -//////////////////////////////////////////////////////////////////// +/** + * Suspends the current thread for at least the indicated amount of time. It + * might be suspended for longer. + */ INLINE void Thread:: sleep(double seconds) { TAU_PROFILE("void Thread::sleep(double)", " ", TAU_USER); ThreadImpl::sleep(seconds); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::field_yield -// Access: Published, Static -// Description: Suspends the current thread for the rest of the -// current epoch. -//////////////////////////////////////////////////////////////////// +/** + * Suspends the current thread for the rest of the current epoch. + */ INLINE void Thread:: force_yield() { TAU_PROFILE("void Thread::yield()", " ", TAU_USER); ThreadImpl::yield(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::consider_yield -// Access: Published, Static -// Description: Possibly suspends the current thread for the rest of -// the current epoch, if it has run for enough this -// epoch. This is especially important for the simple -// thread implementation, which relies on cooperative -// yields like this. -//////////////////////////////////////////////////////////////////// +/** + * Possibly suspends the current thread for the rest of the current epoch, if + * it has run for enough this epoch. This is especially important for the + * simple thread implementation, which relies on cooperative yields like this. + */ INLINE void Thread:: consider_yield() { TAU_PROFILE("void Thread::consider_yield()", " ", TAU_USER); ThreadImpl::consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::is_started -// Access: Published -// Description: Returns true if the thread has been started, false if -// it has not, or if join() has already been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the thread has been started, false if it has not, or if + * join() has already been called. + */ INLINE bool Thread:: is_started() const { return _started; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::is_joinable -// Access: Published -// Description: Returns the value of joinable that was passed to the -// start() call. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of joinable that was passed to the start() call. + */ INLINE bool Thread:: is_joinable() const { return _joinable; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::join -// Access: Published -// Description: Blocks the calling process until the thread -// terminates. If the thread has already terminated, -// this returns immediately. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the calling process until the thread terminates. If the thread has + * already terminated, this returns immediately. + */ INLINE void Thread:: join() { TAU_PROFILE("void Thread::join()", " ", TAU_USER); @@ -303,14 +241,11 @@ join() { } } -//////////////////////////////////////////////////////////////////// -// Function: Thread::preempt -// Access: Published -// Description: Indicates that this thread should run as soon as -// possible, preemptying any other threads that may be -// scheduled to run. This may not be implemented on -// every platform. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this thread should run as soon as possible, preemptying any + * other threads that may be scheduled to run. This may not be implemented on + * every platform. + */ INLINE void Thread:: preempt() { if (_started) { @@ -318,63 +253,48 @@ preempt() { } } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_current_task -// Access: Published -// Description: Returns the task currently executing on this thread -// (via the AsyncTaskManager), if any, or NULL if the -// thread is not currently servicing a task. -//////////////////////////////////////////////////////////////////// +/** + * Returns the task currently executing on this thread (via the + * AsyncTaskManager), if any, or NULL if the thread is not currently servicing + * a task. + */ INLINE AsyncTaskBase *Thread:: get_current_task() const { return _current_task; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::prepare_for_exit -// Access: Published -// Description: Should be called by the main thread just before -// exiting the program, this blocks until any remaining -// thread cleanup has finished. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by the main thread just before exiting the program, this + * blocks until any remaining thread cleanup has finished. + */ INLINE void Thread:: prepare_for_exit() { ThreadImpl::prepare_for_exit(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_pstats_index -// Access: Public -// Description: Stores a PStats index to be associated with this -// thread. This is used internally by the PStatClient; -// you should not need to call this directly. -//////////////////////////////////////////////////////////////////// +/** + * Stores a PStats index to be associated with this thread. This is used + * internally by the PStatClient; you should not need to call this directly. + */ INLINE void Thread:: set_pstats_index(int pstats_index) { _pstats_index = pstats_index; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_pstats_callback -// Access: Public -// Description: Stores a PStats callback to be associated with this -// thread. This is used internally by the PStatClient; -// you should not need to call this directly. -//////////////////////////////////////////////////////////////////// +/** + * Stores a PStats callback to be associated with this thread. This is used + * internally by the PStatClient; you should not need to call this directly. + */ INLINE void Thread:: set_pstats_callback(Thread::PStatsCallback *pstats_callback) { _pstats_callback = pstats_callback; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_pstats_callback -// Access: Public -// Description: Returns the PStats callback associated with this thread, -// or NULL if no callback has yet been associated with -// this thread. This is used internally by the -// PStatClient; you should not need to call this -// directly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStats callback associated with this thread, or NULL if no + * callback has yet been associated with this thread. This is used internally + * by the PStatClient; you should not need to call this directly. + */ INLINE Thread::PStatsCallback *Thread:: get_pstats_callback() const { return _pstats_callback; diff --git a/panda/src/pipeline/thread.cxx b/panda/src/pipeline/thread.cxx index b1fd43d65f..db22ee5803 100644 --- a/panda/src/pipeline/thread.cxx +++ b/panda/src/pipeline/thread.cxx @@ -1,16 +1,15 @@ -// Filename: thread.cxx -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file thread.cxx + * @author drose + * @date 2002-08-08 + */ #include "thread.h" #include "mainThread.h" @@ -28,29 +27,23 @@ Thread *Thread::_main_thread; Thread *Thread::_external_thread; TypeHandle Thread::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Thread::Constructor -// Access: Protected -// Description: Creates a new Thread object, but does not -// immediately start executing it. This gives the -// caller a chance to store it in a PT(Thread) object, -// if desired, before the thread gets a chance to -// terminate and destruct itself. -// -// Call start() to begin thread execution. -// -// The name should be unique for each thread (though -// this is not enforced, and not strictly required). -// The sync_name can be shared between multiple -// different threads; threads that run synchronously -// with each other should be given the same sync_name, -// for the benefit of PStats. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Thread object, but does not immediately start executing it. + * This gives the caller a chance to store it in a PT(Thread) object, if + * desired, before the thread gets a chance to terminate and destruct itself. + * + * Call start() to begin thread execution. + * + * The name should be unique for each thread (though this is not enforced, and + * not strictly required). The sync_name can be shared between multiple + * different threads; threads that run synchronously with each other should be + * given the same sync_name, for the benefit of PStats. + */ Thread:: -Thread(const string &name, const string &sync_name) : - Namable(name), - _sync_name(sync_name), - _impl(this) +Thread(const string &name, const string &sync_name) : + Namable(name), + _sync_name(sync_name), + _impl(this) { _started = false; _pstats_index = -1; @@ -71,8 +64,7 @@ Thread(const string &name, const string &sync_name) : #endif #if defined(HAVE_PYTHON) && !defined(SIMPLE_THREADS) - // Ensure that the Python threading system is initialized and ready - // to go. + // Ensure that the Python threading system is initialized and ready to go. #ifdef WITH_THREAD // This symbol defined within Python.h #if PY_VERSION_HEX >= 0x03020000 @@ -84,11 +76,9 @@ Thread(const string &name, const string &sync_name) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: Thread::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Thread:: ~Thread() { #ifdef HAVE_PYTHON @@ -102,38 +92,30 @@ Thread:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: Thread::bind_thread -// Access: Published, Static -// Description: Returns a new Panda Thread object associated with the -// current thread (which has been created externally). -// This can be used to bind a unique Panda Thread object -// with an external thread, such as a new Python thread. -// -// It is particularly useful to bind a Panda Thread -// object to an external thread for the purposes of -// PStats monitoring. Without this call, each external -// thread will be assigned the same global -// ExternalThread object, which means they will all -// appear in the same PStats graph. -// -// It is the caller's responsibility to save the -// returned Thread pointer for the lifetime of the -// external thread. It is an error for the Thread -// pointer to destruct while the external thread is -// still in the system. -// -// It is also an error to call this method from the main -// thread, or twice within a given thread, unless it is -// given the same name each time (in which case the same -// pointer will be returned each time). -//////////////////////////////////////////////////////////////////// +/** + * Returns a new Panda Thread object associated with the current thread (which + * has been created externally). This can be used to bind a unique Panda + * Thread object with an external thread, such as a new Python thread. + * + * It is particularly useful to bind a Panda Thread object to an external + * thread for the purposes of PStats monitoring. Without this call, each + * external thread will be assigned the same global ExternalThread object, + * which means they will all appear in the same PStats graph. + * + * It is the caller's responsibility to save the returned Thread pointer for + * the lifetime of the external thread. It is an error for the Thread pointer + * to destruct while the external thread is still in the system. + * + * It is also an error to call this method from the main thread, or twice + * within a given thread, unless it is given the same name each time (in which + * case the same pointer will be returned each time). + */ PT(Thread) Thread:: bind_thread(const string &name, const string &sync_name) { Thread *current_thread = get_current_thread(); if (current_thread != get_external_thread()) { // This thread already has an associated thread. - nassertr(current_thread->get_name() == name && + nassertr(current_thread->get_name() == name && current_thread->get_sync_name() == sync_name, current_thread); return current_thread; } @@ -143,21 +125,16 @@ bind_thread(const string &name, const string &sync_name) { return thread; } -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_pipeline_stage -// Access: Published -// Description: Specifies the Pipeline stage number associated with -// this thread. The default stage is 0 if no stage is -// specified otherwise. -// -// This must be a value in the range [0 -// .. pipeline->get_num_stages() - 1]. It specifies the -// values that this thread observes for all pipelined -// data. Typically, an application thread will leave -// this at 0, but a render thread may set it to 1 or 2 -// (to operate on the previous frame's data, or the -// second previous frame's data). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the Pipeline stage number associated with this thread. The + * default stage is 0 if no stage is specified otherwise. + * + * This must be a value in the range [0 .. pipeline->get_num_stages() - 1]. + * It specifies the values that this thread observes for all pipelined data. + * Typically, an application thread will leave this at 0, but a render thread + * may set it to 1 or 2 (to operate on the previous frame's data, or the + * second previous frame's data). + */ void Thread:: set_pipeline_stage(int pipeline_stage) { #ifdef THREADED_PIPELINE @@ -172,24 +149,19 @@ set_pipeline_stage(int pipeline_stage) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Thread::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Thread:: output(ostream &out) const { out << get_type() << " " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: Thread::output_blocker -// Access: Published -// Description: Writes a description of the mutex or condition -// variable that this thread is blocked on. Writes -// nothing if there is no blocker, or if we are not in -// DEBUG_THREADS mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a description of the mutex or condition variable that this thread is + * blocked on. Writes nothing if there is no blocker, or if we are not in + * DEBUG_THREADS mode. + */ void Thread:: output_blocker(ostream &out) const { #ifdef DEBUG_THREADS @@ -203,11 +175,9 @@ output_blocker(ostream &out) const { #endif // DEBUG_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: Thread::write_status -// Access: Published, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void Thread:: write_status(ostream &out) { #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) @@ -215,33 +185,25 @@ write_status(ostream &out) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: Thread::start -// Access: Public -// Description: Starts the thread executing. It is only valid to -// call this once. -// -// The thread will begin executing its thread_main() -// function, and will terminate when thread_main() -// returns. -// -// priority is intended as a hint to the relative -// importance of this thread. This may be ignored by -// the thread implementation. -// -// joinable should be set true if you intend to call -// join() to wait for the thread to terminate, or false -// if you don't care and you will never call join(). -// Note that the reference count on the Thread object is -// incremented while the thread itself is running, so if -// you just want to fire and forget a thread, you may -// pass joinable = false, and never store the Thread -// object. It will automatically destruct itself when -// it finishes. -// -// The return value is true if the thread is -// successfully started, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Starts the thread executing. It is only valid to call this once. + * + * The thread will begin executing its thread_main() function, and will + * terminate when thread_main() returns. + * + * priority is intended as a hint to the relative importance of this thread. + * This may be ignored by the thread implementation. + * + * joinable should be set true if you intend to call join() to wait for the + * thread to terminate, or false if you don't care and you will never call + * join(). Note that the reference count on the Thread object is incremented + * while the thread itself is running, so if you just want to fire and forget + * a thread, you may pass joinable = false, and never store the Thread object. + * It will automatically destruct itself when it finishes. + * + * The return value is true if the thread is successfully started, false + * otherwise. + */ bool Thread:: start(ThreadPriority priority, bool joinable) { nassertr(!_started, false); @@ -264,15 +226,12 @@ start(ThreadPriority priority, bool joinable) { } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Thread::set_python_data -// Access: Published -// Description: Sets an arbitrary Python object that may be -// associated with this thread object. This is just for -// the purposes of associated arbitrary Python data with -// the C++ object; other than managing the reference -// count, the C++ code does nothing with this object. -//////////////////////////////////////////////////////////////////// +/** + * Sets an arbitrary Python object that may be associated with this thread + * object. This is just for the purposes of associated arbitrary Python data + * with the C++ object; other than managing the reference count, the C++ code + * does nothing with this object. + */ void Thread:: set_python_data(PyObject *python_data) { Py_DECREF(_python_data); @@ -282,12 +241,9 @@ set_python_data(PyObject *python_data) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Thread::get_python_data -// Access: Published -// Description: Returns the Python object that was set with -// set_python_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the Python object that was set with set_python_data(). + */ PyObject *Thread:: get_python_data() const { Py_INCREF(_python_data); @@ -296,21 +252,18 @@ get_python_data() const { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Thread::call_python_func -// Access: Public -// Description: Internal function to safely call a Python function -// within a sub-thread, that might execute in parallel -// with existing Python code. The return value is the -// return value of the Python function, or NULL if there -// was an exception. -//////////////////////////////////////////////////////////////////// +/** + * Internal function to safely call a Python function within a sub-thread, + * that might execute in parallel with existing Python code. The return value + * is the return value of the Python function, or NULL if there was an + * exception. + */ PyObject *Thread:: call_python_func(PyObject *function, PyObject *args) { nassertr(this == get_current_thread(), NULL); - // Create a new Python thread state data structure, so Python can - // properly lock itself. + // Create a new Python thread state data structure, so Python can properly + // lock itself. PyObject *result = NULL; if (this == get_main_thread()) { @@ -319,21 +272,21 @@ call_python_func(PyObject *function, PyObject *args) { if (result == (PyObject *)NULL) { if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_SystemExit)) { - // If we caught SystemExit, let it pass by without bothering - // to print a callback. + // If we caught SystemExit, let it pass by without bothering to print + // a callback. } else { - // Temporarily save and restore the exception state so we can - // print a callback on-the-spot. + // Temporarily save and restore the exception state so we can print a + // callback on-the-spot. PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); - + Py_XINCREF(exc); Py_XINCREF(val); Py_XINCREF(tb); PyErr_Restore(exc, val, tb); PyErr_Print(); - + PyErr_Restore(exc, val, tb); } } @@ -346,20 +299,20 @@ call_python_func(PyObject *function, PyObject *args) { #else #ifdef SIMPLE_THREADS - // We can't use the PyGILState interface, which assumes we are - // using true OS-level threading. PyGILState enforces policies - // like only one thread state per OS-level thread, which is not - // true in the case of SIMPLE_THREADS. + // We can't use the PyGILState interface, which assumes we are using true + // OS-level threading. PyGILState enforces policies like only one thread + // state per OS-level thread, which is not true in the case of + // SIMPLE_THREADS. - // For some reason I don't fully understand, I'm getting a crash - // when I clean up old PyThreadState objects with - // PyThreadState_Delete(). It appears that the thread state is - // still referenced somewhere at the time I call delete, and the - // crash occurs because I've deleted an active pointer. + // For some reason I don't fully understand, I'm getting a crash when I + // clean up old PyThreadState objects with PyThreadState_Delete(). It + // appears that the thread state is still referenced somewhere at the time + // I call delete, and the crash occurs because I've deleted an active + // pointer. - // Storing these pointers in a vector for permanent recycling - // seems to avoid this problem. I wish I understood better what's - // going wrong, but I guess this workaround will do. + // Storing these pointers in a vector for permanent recycling seems to + // avoid this problem. I wish I understood better what's going wrong, but + // I guess this workaround will do. static pvector thread_states; PyThreadState *orig_thread_state = PyThreadState_Get(); @@ -372,20 +325,20 @@ call_python_func(PyObject *function, PyObject *args) { thread_states.pop_back(); } PyThreadState_Swap(new_thread_state); - + // Call the user's function. result = PyObject_Call(function, args, NULL); if (result == (PyObject *)NULL && PyErr_Occurred()) { - // We got an exception. Move the exception from the current - // thread into the main thread, so it can be handled there. + // We got an exception. Move the exception from the current thread into + // the main thread, so it can be handled there. PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); thread_cat.error() << "Exception occurred within " << *this << "\n"; - // Temporarily restore the exception state so we can print a - // callback on-the-spot. + // Temporarily restore the exception state so we can print a callback + // on-the-spot. Py_XINCREF(exc); Py_XINCREF(val); Py_XINCREF(tb); @@ -394,42 +347,42 @@ call_python_func(PyObject *function, PyObject *args) { PyThreadState_Swap(orig_thread_state); thread_states.push_back(new_thread_state); - //PyThreadState_Clear(new_thread_state); - //PyThreadState_Delete(new_thread_state); + // PyThreadState_Clear(new_thread_state); + // PyThreadState_Delete(new_thread_state); PyErr_Restore(exc, val, tb); - // Now attempt to force the main thread to the head of the ready - // queue, so it can respond to the exception immediately. This - // only works if the main thread is not blocked, of course. + // Now attempt to force the main thread to the head of the ready queue, + // so it can respond to the exception immediately. This only works if + // the main thread is not blocked, of course. Thread::get_main_thread()->preempt(); } else { // No exception. Restore the thread state normally. PyThreadState *state = PyThreadState_Swap(orig_thread_state); thread_states.push_back(new_thread_state); - //PyThreadState_Clear(new_thread_state); - //PyThreadState_Delete(new_thread_state); + // PyThreadState_Clear(new_thread_state); + // PyThreadState_Delete(new_thread_state); } - + #else // SIMPLE_THREADS // With true threading enabled, we're better off using PyGILState. PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - + // Call the user's function. result = PyObject_Call(function, args, NULL); if (result == (PyObject *)NULL && PyErr_Occurred()) { - // We got an exception. Move the exception from the current - // thread into the main thread, so it can be handled there. + // We got an exception. Move the exception from the current thread into + // the main thread, so it can be handled there. PyObject *exc, *val, *tb; PyErr_Fetch(&exc, &val, &tb); thread_cat.error() << "Exception occurred within " << *this << "\n"; - // Temporarily restore the exception state so we can print a - // callback on-the-spot. + // Temporarily restore the exception state so we can print a callback + // on-the-spot. Py_XINCREF(exc); Py_XINCREF(val); Py_XINCREF(tb); @@ -443,7 +396,7 @@ call_python_func(PyObject *function, PyObject *args) { // No exception. Restore the thread state normally. PyGILState_Release(gstate); } - + #endif // SIMPLE_THREADS #endif // HAVE_THREADS @@ -454,14 +407,11 @@ call_python_func(PyObject *function, PyObject *args) { #endif // HAVE_PYTHON #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Thread::handle_python_exception -// Access: Public -// Description: Called when a Python exception is raised during -// processing of a thread. Gets the error string and -// passes it back to the calling Python process in a -// sensible way. -//////////////////////////////////////////////////////////////////// +/** + * Called when a Python exception is raised during processing of a thread. + * Gets the error string and passes it back to the calling Python process in a + * sensible way. + */ void Thread:: handle_python_exception() { /* @@ -504,23 +454,20 @@ handle_python_exception() { thread_cat.error() << "Exception occurred within " << *this << "\n"; - // Now attempt to force the main thread to the head of the ready - // queue, so it will be the one to receive the above assertion. - // This mainly only has an effect if SIMPLE_THREADS is in use. + // Now attempt to force the main thread to the head of the ready queue, so + // it will be the one to receive the above assertion. This mainly only has + // an effect if SIMPLE_THREADS is in use. Thread::get_main_thread()->preempt(); } #endif // HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: Thread::init_main_thread -// Access: Private, Static -// Description: Creates the Thread object that represents the main -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Creates the Thread object that represents the main thread. + */ void Thread:: init_main_thread() { - // There is a chance of mutual recursion at startup. The count - // variable here attempts to protect against that. + // There is a chance of mutual recursion at startup. The count variable + // here attempts to protect against that. static int count = 0; ++count; if (count == 1 && _main_thread == (Thread *)NULL) { @@ -529,12 +476,9 @@ init_main_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: Thread::init_external_thread -// Access: Private, Static -// Description: Creates the Thread object that represents all of the -// external threads. -//////////////////////////////////////////////////////////////////// +/** + * Creates the Thread object that represents all of the external threads. + */ void Thread:: init_external_thread() { if (_external_thread == (Thread *)NULL) { @@ -543,38 +487,29 @@ init_external_thread() { } } -//////////////////////////////////////////////////////////////////// -// Function: Thread::PStatsCallback::Destructor -// Access: Public, Virtual -// Description: Since this class is just an interface definition, -// there is no need to have a destructor. However, we -// must have one anyway to stop gcc's annoying warning. -//////////////////////////////////////////////////////////////////// +/** + * Since this class is just an interface definition, there is no need to have + * a destructor. However, we must have one anyway to stop gcc's annoying + * warning. + */ Thread::PStatsCallback:: ~PStatsCallback() { } -//////////////////////////////////////////////////////////////////// -// Function: Thread::PStatsCallback::deactivate_hook -// Access: Public, Virtual -// Description: Called when the thread is deactivated (swapped for -// another running thread). This is intended to provide -// a callback hook for PStats to assign time to -// individual threads properly, particularly in the -// SIMPLE_THREADS case. -//////////////////////////////////////////////////////////////////// +/** + * Called when the thread is deactivated (swapped for another running thread). + * This is intended to provide a callback hook for PStats to assign time to + * individual threads properly, particularly in the SIMPLE_THREADS case. + */ void Thread::PStatsCallback:: deactivate_hook(Thread *) { } -//////////////////////////////////////////////////////////////////// -// Function: Thread::PStatsCallback::activate_hook -// Access: Public, Virtual -// Description: Called when the thread is activated (resumes -// execution). This is intended to provide a callback -// hook for PStats to assign time to individual threads -// properly, particularly in the SIMPLE_THREADS case. -//////////////////////////////////////////////////////////////////// +/** + * Called when the thread is activated (resumes execution). This is intended + * to provide a callback hook for PStats to assign time to individual threads + * properly, particularly in the SIMPLE_THREADS case. + */ void Thread::PStatsCallback:: activate_hook(Thread *) { } diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index f46978f6a5..71cbe8bcce 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -1,16 +1,15 @@ -// Filename: thread.h -// Created by: cary (16Sep98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file thread.h + * @author cary + * @date 1998-09-16 + */ #ifndef THREAD_H #define THREAD_H @@ -31,18 +30,15 @@ class ConditionVarDebug; class ConditionVarFullDebug; class AsyncTaskBase; -//////////////////////////////////////////////////////////////////// -// Class : Thread -// Description : A thread; that is, a lightweight process. This is an -// abstract base class; to use it, you must subclass -// from it and redefine thread_main(). -// -// The thread itself will keep a reference count on the -// Thread object while it is running; when the thread -// returns from its root function, the Thread object -// will automatically be destructed if no other pointers -// are referencing it. -//////////////////////////////////////////////////////////////////// +/** + * A thread; that is, a lightweight process. This is an abstract base class; + * to use it, you must subclass from it and redefine thread_main(). + * + * The thread itself will keep a reference count on the Thread object while it + * is running; when the thread returns from its root function, the Thread + * object will automatically be destructed if no other pointers are + * referencing it. + */ class EXPCL_PANDA_PIPELINE Thread : public TypedReferenceCount, public Namable { protected: Thread(const string &name, const string &sync_name); diff --git a/panda/src/pipeline/threadDummyImpl.I b/panda/src/pipeline/threadDummyImpl.I index 9e19e9b0ba..930f53fe4b 100644 --- a/panda/src/pipeline/threadDummyImpl.I +++ b/panda/src/pipeline/threadDummyImpl.I @@ -1,132 +1,104 @@ -// Filename: threadDummyImpl.I -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadDummyImpl.I + * @author drose + * @date 2002-08-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadDummyImpl:: ThreadDummyImpl(Thread *) { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadDummyImpl:: ~ThreadDummyImpl() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::setup_main_thread -// Access: Public -// Description: Called for the main thread only, which has been -// already started, to fill in the values appropriate to -// that thread. -//////////////////////////////////////////////////////////////////// +/** + * Called for the main thread only, which has been already started, to fill in + * the values appropriate to that thread. + */ void ThreadDummyImpl:: setup_main_thread() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::start -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadDummyImpl:: start(ThreadPriority, bool) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::join -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: join() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::preempt -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: preempt() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::prepare_for_exit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: prepare_for_exit() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::bind_thread -// Access: Public, Static -// Description: Associates the indicated Thread object with the -// currently-executing thread. You should not call this -// directly; use Thread::bind_thread() instead. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated Thread object with the currently-executing thread. + * You should not call this directly; use Thread::bind_thread() instead. + */ INLINE void ThreadDummyImpl:: bind_thread(Thread *thread) { // This method shouldn't be called in the non-threaded case. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::is_threading_supported -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadDummyImpl:: is_threading_supported() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::is_true_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadDummyImpl:: is_true_threads() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::is_simple_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadDummyImpl:: is_simple_threads() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::sleep -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: sleep(double seconds) { #ifdef WIN32 @@ -139,20 +111,16 @@ sleep(double seconds) { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: yield() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::consider_yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadDummyImpl:: consider_yield() { } diff --git a/panda/src/pipeline/threadDummyImpl.cxx b/panda/src/pipeline/threadDummyImpl.cxx index 3cd2b2a811..419744a4b5 100644 --- a/panda/src/pipeline/threadDummyImpl.cxx +++ b/panda/src/pipeline/threadDummyImpl.cxx @@ -1,16 +1,15 @@ -// Filename: threadDummyImpl.cxx -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadDummyImpl.cxx + * @author drose + * @date 2002-08-09 + */ #include "selectThreadImpl.h" @@ -26,15 +25,12 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::get_unique_id -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string ThreadDummyImpl:: get_unique_id() const { - // In a single-threaded application, this is just the unique process - // ID. + // In a single-threaded application, this is just the unique process ID. ostringstream strm; #ifdef WIN32 strm << GetCurrentProcessId(); @@ -44,11 +40,9 @@ get_unique_id() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadDummyImpl::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Thread *ThreadDummyImpl:: get_current_thread() { return Thread::get_main_thread(); diff --git a/panda/src/pipeline/threadDummyImpl.h b/panda/src/pipeline/threadDummyImpl.h index 689e6386e6..1b2c46cd46 100644 --- a/panda/src/pipeline/threadDummyImpl.h +++ b/panda/src/pipeline/threadDummyImpl.h @@ -1,16 +1,15 @@ -// Filename: threadDummyImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadDummyImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef THREADDUMMYIMPL_H #define THREADDUMMYIMPL_H @@ -32,12 +31,10 @@ class Thread; #include // For Sleep(). #endif -//////////////////////////////////////////////////////////////////// -// Class : ThreadDummyImpl -// Description : A fake thread implementation for single-threaded -// applications. This simply fails whenever you try to -// start a thread. -//////////////////////////////////////////////////////////////////// +/** + * A fake thread implementation for single-threaded applications. This simply + * fails whenever you try to start a thread. + */ class EXPCL_PANDA_PIPELINE ThreadDummyImpl { public: INLINE ThreadDummyImpl(Thread *parent_obj); diff --git a/panda/src/pipeline/threadImpl.h b/panda/src/pipeline/threadImpl.h index a283f8ea79..fd61b54ab0 100644 --- a/panda/src/pipeline/threadImpl.h +++ b/panda/src/pipeline/threadImpl.h @@ -1,16 +1,15 @@ -// Filename: threadImpl.h -// Created by: drose (09Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadImpl.h + * @author drose + * @date 2002-08-09 + */ #ifndef THREADIMPL_H #define THREADIMPL_H diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index 059f0ffbe0..93bdce8e8c 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -1,23 +1,19 @@ -// Filename: threadPosixImpl.I -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadPosixImpl.I + * @author drose + * @date 2006-02-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadPosixImpl:: ThreadPosixImpl(Thread *parent_obj) : _parent_obj(parent_obj) @@ -27,29 +23,23 @@ ThreadPosixImpl(Thread *parent_obj) : _status = S_new; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::preempt -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadPosixImpl:: preempt() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::prepare_for_exit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadPosixImpl:: prepare_for_exit() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::get_current_thread -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *ThreadPosixImpl:: get_current_thread() { TAU_PROFILE("Thread *ThreadPosixImpl::get_current_thread()", " ", TAU_USER); @@ -59,13 +49,10 @@ get_current_thread() { return (Thread *)pthread_getspecific(_pt_ptr_index); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::bind_thread -// Access: Public, Static -// Description: Associates the indicated Thread object with the -// currently-executing thread. You should not call this -// directly; use Thread::bind_thread() instead. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated Thread object with the currently-executing thread. + * You should not call this directly; use Thread::bind_thread() instead. + */ INLINE void ThreadPosixImpl:: bind_thread(Thread *thread) { if (!_got_pt_ptr_index) { @@ -75,41 +62,33 @@ bind_thread(Thread *thread) { nassertv(result == 0); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::is_threading_supported -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadPosixImpl:: is_threading_supported() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::is_true_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadPosixImpl:: is_true_threads() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::is_simple_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadPosixImpl:: is_simple_threads() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::sleep -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadPosixImpl:: sleep(double seconds) { TAU_PROFILE("void ThreadPosixImpl::sleep(double)", " ", TAU_USER); @@ -119,21 +98,17 @@ sleep(double seconds) { nanosleep(&rqtp, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadPosixImpl:: yield() { sleep(0.0); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::consider_yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadPosixImpl:: consider_yield() { } diff --git a/panda/src/pipeline/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx index 74e535c8e2..54b3dfd630 100644 --- a/panda/src/pipeline/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -1,16 +1,15 @@ -// Filename: threadPosixImpl.cxx -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadPosixImpl.cxx + * @author drose + * @date 2006-02-09 + */ #include "threadPosixImpl.h" #include "selectThreadImpl.h" @@ -30,15 +29,13 @@ pthread_key_t ThreadPosixImpl::_pt_ptr_index = 0; bool ThreadPosixImpl::_got_pt_ptr_index = false; -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ThreadPosixImpl:: ~ThreadPosixImpl() { if (thread_cat->is_debug()) { - thread_cat.debug() + thread_cat.debug() << "Deleting thread " << _parent_obj->get_name() << "\n"; } @@ -52,23 +49,18 @@ ThreadPosixImpl:: _mutex.release(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::setup_main_thread -// Access: Public -// Description: Called for the main thread only, which has been -// already started, to fill in the values appropriate to -// that thread. -//////////////////////////////////////////////////////////////////// +/** + * Called for the main thread only, which has been already started, to fill in + * the values appropriate to that thread. + */ void ThreadPosixImpl:: setup_main_thread() { _status = S_running; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::start -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ThreadPosixImpl:: start(ThreadPriority priority, bool joinable) { _mutex.acquire(); @@ -103,8 +95,8 @@ start(ThreadPriority priority, bool joinable) { << "Unable to set stack size.\n"; } - // Ensure the thread has "system" scope, which should ensure it can - // run in parallel with other threads. + // Ensure the thread has "system" scope, which should ensure it can run in + // parallel with other threads. result = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); if (result != 0) { thread_cat->warning() @@ -126,34 +118,33 @@ start(ThreadPriority priority, bool joinable) { param.sched_priority = sched_get_priority_min(current_policy); result = pthread_attr_setschedparam(&attr, ¶m); break; - + case TP_high: case TP_urgent: param.sched_priority = sched_get_priority_max(current_policy); result = pthread_attr_setschedparam(&attr, ¶m); break; - + case TP_normal: default: break; } - + if (result != 0) { thread_cat->warning() << "Unable to specify thread priority.\n"; } - // Increment the parent object's reference count first. The thread - // will eventually decrement it when it terminates. + // Increment the parent object's reference count first. The thread will + // eventually decrement it when it terminates. _parent_obj->ref(); result = pthread_create(&_thread, &attr, &root_func, (void *)this); pthread_attr_destroy(&attr); if (result != 0) { - // Oops, we couldn't start the thread. Be sure to decrement the - // reference count we incremented above, and return false to - // indicate failure. + // Oops, we couldn't start the thread. Be sure to decrement the reference + // count we incremented above, and return false to indicate failure. unref_delete(_parent_obj); _mutex.release(); return false; @@ -164,13 +155,10 @@ start(ThreadPriority priority, bool joinable) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::join -// Access: Public -// Description: Blocks the calling process until the thread -// terminates. If the thread has already terminated, -// this returns immediately. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the calling process until the thread terminates. If the thread has + * already terminated, this returns immediately. + */ void ThreadPosixImpl:: join() { _mutex.acquire(); @@ -184,11 +172,9 @@ join() { _mutex.release(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::get_unique_id -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string ThreadPosixImpl:: get_unique_id() const { ostringstream strm; @@ -197,28 +183,26 @@ get_unique_id() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::root_func -// Access: Private, Static -// Description: The entry point of each thread. -//////////////////////////////////////////////////////////////////// +/** + * The entry point of each thread. + */ void *ThreadPosixImpl:: root_func(void *data) { TAU_REGISTER_THREAD(); { - //TAU_PROFILE("void ThreadPosixImpl::root_func()", " ", TAU_USER); + // TAU_PROFILE("void ThreadPosixImpl::root_func()", " ", TAU_USER); ThreadPosixImpl *self = (ThreadPosixImpl *)data; int result = pthread_setspecific(_pt_ptr_index, self->_parent_obj); nassertr(result == 0, NULL); - + { self->_mutex.acquire(); nassertd(self->_status == S_start_called) { self->_mutex.release(); return NULL; } - + self->_status = S_running; self->_mutex.release(); } @@ -234,15 +218,15 @@ root_func(void *data) { env = NULL; } #endif - + self->_parent_obj->thread_main(); - + if (thread_cat->is_debug()) { thread_cat.debug() - << "Terminating thread " << self->_parent_obj->get_name() + << "Terminating thread " << self->_parent_obj->get_name() << ", count = " << self->_parent_obj->get_ref_count() << "\n"; } - + { self->_mutex.acquire(); nassertd(self->_status == S_running) { @@ -259,21 +243,19 @@ root_func(void *data) { } #endif - // Now drop the parent object reference that we grabbed in start(). - // This might delete the parent object, and in turn, delete the - // ThreadPosixImpl object. + // Now drop the parent object reference that we grabbed in start(). This + // might delete the parent object, and in turn, delete the ThreadPosixImpl + // object. unref_delete(self->_parent_obj); } - + return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadPosixImpl::init_pt_ptr_index -// Access: Private, Static -// Description: Allocate a new index to store the Thread parent -// pointer as a piece of per-thread private data. -//////////////////////////////////////////////////////////////////// +/** + * Allocate a new index to store the Thread parent pointer as a piece of per- + * thread private data. + */ void ThreadPosixImpl:: init_pt_ptr_index() { nassertv(!_got_pt_ptr_index); @@ -287,8 +269,8 @@ init_pt_ptr_index() { _got_pt_ptr_index = true; - // Assume that we must be in the main thread, since this method must - // be called before the first thread is spawned. + // Assume that we must be in the main thread, since this method must be + // called before the first thread is spawned. Thread *main_thread_obj = Thread::get_main_thread(); result = pthread_setspecific(_pt_ptr_index, main_thread_obj); nassertv(result == 0); diff --git a/panda/src/pipeline/threadPosixImpl.h b/panda/src/pipeline/threadPosixImpl.h index 339a784b0a..0168c38665 100644 --- a/panda/src/pipeline/threadPosixImpl.h +++ b/panda/src/pipeline/threadPosixImpl.h @@ -1,16 +1,15 @@ -// Filename: threadPosixImpl.h -// Created by: drose (09Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadPosixImpl.h + * @author drose + * @date 2006-02-09 + */ #ifndef THREADPOSIXIMPL_H #define THREADPOSIXIMPL_H @@ -28,10 +27,9 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : ThreadPosixImpl -// Description : Uses Posix threads to implement a thread. -//////////////////////////////////////////////////////////////////// +/** + * Uses Posix threads to implement a thread. + */ class EXPCL_PANDA_PIPELINE ThreadPosixImpl { public: INLINE ThreadPosixImpl(Thread *parent_obj); diff --git a/panda/src/pipeline/threadPriority.cxx b/panda/src/pipeline/threadPriority.cxx index b1746c442a..0402273099 100644 --- a/panda/src/pipeline/threadPriority.cxx +++ b/panda/src/pipeline/threadPriority.cxx @@ -1,16 +1,15 @@ -// Filename: threadPriority.cxx -// Created by: drose (26Sep08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadPriority.cxx + * @author drose + * @date 2008-09-26 + */ #include "threadPriority.h" #include "pnotify.h" // nassertr diff --git a/panda/src/pipeline/threadPriority.h b/panda/src/pipeline/threadPriority.h index f5a9296830..104b0dac3b 100644 --- a/panda/src/pipeline/threadPriority.h +++ b/panda/src/pipeline/threadPriority.h @@ -1,16 +1,15 @@ -// Filename: threadPriority.h -// Created by: drose (08Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadPriority.h + * @author drose + * @date 2002-08-08 + */ #ifndef THREADPRIORITY_H #define THREADPRIORITY_H @@ -18,10 +17,8 @@ #include "pandabase.h" BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// An enumerated type used by Thread to specify a suggested relative -// priority for a particular thread. -//////////////////////////////////////////////////////////////////// +// An enumerated type used by Thread to specify a suggested relative priority +// for a particular thread. enum ThreadPriority { TP_low, TP_normal, diff --git a/panda/src/pipeline/threadSimpleImpl.I b/panda/src/pipeline/threadSimpleImpl.I index ef2950ac23..41b31b2b14 100644 --- a/panda/src/pipeline/threadSimpleImpl.I +++ b/panda/src/pipeline/threadSimpleImpl.I @@ -1,35 +1,29 @@ -// Filename: threadSimpleImpl.I -// Created by: drose (18Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleImpl.I + * @author drose + * @date 2007-06-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::get_current_thread -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *ThreadSimpleImpl:: get_current_thread() { return ThreadSimpleManager::get_global_ptr()->get_current_thread()->_parent_obj; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::is_same_system_thread -// Access: Public -// Description: Returns true if we are still running within the same -// OS-level thread that this thread begin in, or false -// if this appears to be running in a different thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we are still running within the same OS-level thread that + * this thread begin in, or false if this appears to be running in a different + * thread. + */ INLINE bool ThreadSimpleImpl:: is_same_system_thread() const { #ifdef HAVE_POSIX_THREADS @@ -41,52 +35,41 @@ is_same_system_thread() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::bind_thread -// Access: Public, Static -// Description: Associates the indicated Thread object with the -// currently-executing thread. You should not call this -// directly; use Thread::bind_thread() instead. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated Thread object with the currently-executing thread. + * You should not call this directly; use Thread::bind_thread() instead. + */ INLINE void ThreadSimpleImpl:: bind_thread(Thread *) { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::is_threading_supported -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadSimpleImpl:: is_threading_supported() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::is_true_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadSimpleImpl:: is_true_threads() { return (is_os_threads != 0); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::is_simple_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadSimpleImpl:: is_simple_threads() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::sleep -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadSimpleImpl:: sleep(double seconds) { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); @@ -98,11 +81,9 @@ sleep(double seconds) { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadSimpleImpl:: yield() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); @@ -114,11 +95,9 @@ yield() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::consider_yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadSimpleImpl:: consider_yield() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); @@ -128,11 +107,9 @@ consider_yield() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::consider_yield_this -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadSimpleImpl:: consider_yield_this() { double now = _manager->get_current_time(); @@ -141,21 +118,17 @@ consider_yield_this() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::get_wake_time -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double ThreadSimpleImpl:: get_wake_time() const { return _wake_time; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::write_status -// Access: Public, Static -// Description: Writes a list of threads running and threads blocked. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of threads running and threads blocked. + */ void ThreadSimpleImpl:: write_status(ostream &out) { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); diff --git a/panda/src/pipeline/threadSimpleImpl.cxx b/panda/src/pipeline/threadSimpleImpl.cxx index add02e2c7b..b4c90cd54e 100644 --- a/panda/src/pipeline/threadSimpleImpl.cxx +++ b/panda/src/pipeline/threadSimpleImpl.cxx @@ -1,16 +1,15 @@ -// Filename: threadSimpleImpl.cxx -// Created by: drose (18Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleImpl.cxx + * @author drose + * @date 2007-06-18 + */ #include "selectThreadImpl.h" @@ -24,11 +23,9 @@ ThreadSimpleImpl *volatile ThreadSimpleImpl::_st_this; int ThreadSimpleImpl::_next_unique_id = 1; -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ThreadSimpleImpl:: ThreadSimpleImpl(Thread *parent_obj) : _parent_obj(parent_obj) @@ -60,15 +57,13 @@ ThreadSimpleImpl(Thread *parent_obj) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ThreadSimpleImpl:: ~ThreadSimpleImpl() { if (thread_cat->is_debug()) { - thread_cat.debug() + thread_cat.debug() << "Deleting thread " << _parent_obj->get_name() << "\n"; } nassertv(_status != TS_running); @@ -81,13 +76,10 @@ ThreadSimpleImpl:: _manager->remove_thread(this); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::setup_main_thread -// Access: Public -// Description: Called for the main thread only, which has been -// already started, to fill in the values appropriate to -// that thread. -//////////////////////////////////////////////////////////////////// +/** + * Called for the main thread only, which has been already started, to fill in + * the values appropriate to that thread. + */ void ThreadSimpleImpl:: setup_main_thread() { _status = TS_running; @@ -104,11 +96,9 @@ setup_main_thread() { _manager->set_current_thread(this); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::start -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ThreadSimpleImpl:: start(ThreadPriority priority, bool joinable) { if (thread_cat->is_debug()) { @@ -131,11 +121,11 @@ start(ThreadPriority priority, bool joinable) { case TP_low: _priority_weight = _manager->_simple_thread_low_weight; break; - + case TP_normal: _priority_weight = _manager->_simple_thread_normal_weight; break; - + case TP_high: _priority_weight = _manager->_simple_thread_high_weight; break; @@ -145,8 +135,8 @@ start(ThreadPriority priority, bool joinable) { break; } - // We'll keep the reference count upped while the thread is running. - // When the thread finishes, we'll drop the reference count. + // We'll keep the reference count upped while the thread is running. When + // the thread finishes, we'll drop the reference count. _parent_obj->ref(); #ifdef HAVE_PYTHON @@ -161,13 +151,10 @@ start(ThreadPriority priority, bool joinable) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::join -// Access: Public -// Description: Blocks the calling process until the thread -// terminates. If the thread has already terminated, -// this returns immediately. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the calling process until the thread terminates. If the thread has + * already terminated, this returns immediately. + */ void ThreadSimpleImpl:: join() { nassertv(_joinable); @@ -180,21 +167,17 @@ join() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::preempt -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ThreadSimpleImpl:: preempt() { _manager->preempt(this); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::get_unique_id -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string ThreadSimpleImpl:: get_unique_id() const { ostringstream strm; @@ -208,62 +191,50 @@ get_unique_id() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::prepare_for_exit -// Access: Public, Static -// Description: Waits for all threads to terminate. Normally this is -// called only from the main thread. -//////////////////////////////////////////////////////////////////// +/** + * Waits for all threads to terminate. Normally this is called only from the + * main thread. + */ void ThreadSimpleImpl:: prepare_for_exit() { ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr(); manager->prepare_for_exit(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::sleep_this -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ThreadSimpleImpl:: sleep_this(double seconds) { _manager->enqueue_sleep(this, seconds); _manager->next_context(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::yield_this -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ThreadSimpleImpl:: yield_this(bool volunteer) { if (thread_cat->is_debug() && volunteer) { - thread_cat.debug() + thread_cat.debug() << "Force-yielding " << _parent_obj->get_name() << "\n"; } _manager->enqueue_ready(this, true); _manager->next_context(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::st_begin_thread -// Access: Private, Static -// Description: This method is called as the first introduction to a -// new thread. -//////////////////////////////////////////////////////////////////// +/** + * This method is called as the first introduction to a new thread. + */ void ThreadSimpleImpl:: st_begin_thread(void *data) { ThreadSimpleImpl *self = (ThreadSimpleImpl *)data; self->begin_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleImpl::begin_thread -// Access: Private -// Description: This method is called as the first introduction to a -// new thread. -//////////////////////////////////////////////////////////////////// +/** + * This method is called as the first introduction to a new thread. + */ void ThreadSimpleImpl:: begin_thread() { #ifdef HAVE_PYTHON @@ -277,8 +248,8 @@ begin_thread() { _win32_system_thread_id = GetCurrentThreadId(); #endif - // Here we are executing within the thread. Run the thread_main - // function defined for this thread. + // Here we are executing within the thread. Run the thread_main function + // defined for this thread. _parent_obj->thread_main(); // Now we have completed the thread. @@ -293,7 +264,7 @@ begin_thread() { _manager->enqueue_finished(this); _manager->next_context(); - + // Shouldn't get here. nassertv(false); abort(); diff --git a/panda/src/pipeline/threadSimpleImpl.h b/panda/src/pipeline/threadSimpleImpl.h index 83ba2ec911..aa2e4e7ab7 100644 --- a/panda/src/pipeline/threadSimpleImpl.h +++ b/panda/src/pipeline/threadSimpleImpl.h @@ -1,16 +1,15 @@ -// Filename: threadSimpleImpl.h -// Created by: drose (18Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleImpl.h + * @author drose + * @date 2007-06-18 + */ #ifndef THREADSIMPLEIMPL_H #define THREADSIMPLEIMPL_H @@ -29,28 +28,22 @@ class Thread; class ThreadSimpleManager; class MutexSimpleImpl; -//////////////////////////////////////////////////////////////////// -// Class : ThreadSimpleImpl -// Description : This is a trivial threading implementation for -// applications that don't desire full OS-managed -// threading. It is a user-space implementation of -// threads implemented via setjmp/longjmp, and therefore -// it cannot take advantage of multiple CPU's (the -// application will always run on a single CPU, -// regardless of the number of threads you spawn). -// -// However, since context switching is entirely -// cooperative, synchronization primitives like mutexes -// and condition variables aren't necessary, and the -// Mutex and ConditionVar classes are compiled into -// trivial no-op classes, which can reduce overhead -// substantially compared to a truly threaded -// application. -// -// Be sure that every thread calls -// Thread::consider_yield() occasionally, or it will -// starve the rest of the running threads. -//////////////////////////////////////////////////////////////////// +/** + * This is a trivial threading implementation for applications that don't + * desire full OS-managed threading. It is a user-space implementation of + * threads implemented via setjmp/longjmp, and therefore it cannot take + * advantage of multiple CPU's (the application will always run on a single + * CPU, regardless of the number of threads you spawn). + * + * However, since context switching is entirely cooperative, synchronization + * primitives like mutexes and condition variables aren't necessary, and the + * Mutex and ConditionVar classes are compiled into trivial no-op classes, + * which can reduce overhead substantially compared to a truly threaded + * application. + * + * Be sure that every thread calls Thread::consider_yield() occasionally, or + * it will starve the rest of the running threads. + */ class EXPCL_PANDA_PIPELINE ThreadSimpleImpl { public: ThreadSimpleImpl(Thread *parent_obj); @@ -110,12 +103,10 @@ private: // The amount of time this thread has run recently. unsigned int _run_ticks; - // This is the time at which the currently-running thread started - // execution. + // This is the time at which the currently-running thread started execution. double _start_time; - // This is the time at which the currently-running thread should - // yield. + // This is the time at which the currently-running thread should yield. double _stop_time; // This records the time at which a sleeping thread should wake up. @@ -126,8 +117,8 @@ private: size_t _stack_size; #ifdef HAVE_PYTHON - // If we might be working with Python, we have to manage the Python - // thread state as we switch contexts. + // If we might be working with Python, we have to manage the Python thread + // state as we switch contexts. PyThreadState *_python_state; #endif // HAVE_PYTHON @@ -138,13 +129,12 @@ private: ThreadSimpleManager *_manager; static ThreadSimpleImpl *volatile _st_this; - // We may not mix-and-match OS threads with Panda's SIMPLE_THREADS. - // If we ever get a Panda context switch request from a different OS - // thread than the thread we think we should be in, that's a serious - // error that may cause major consequences. For this reason, we - // store the OS thread's current thread ID here when the thread is - // constructed, and insist that it never changes during the lifetime - // of the thread. + // We may not mix-and-match OS threads with Panda's SIMPLE_THREADS. If we + // ever get a Panda context switch request from a different OS thread than + // the thread we think we should be in, that's a serious error that may + // cause major consequences. For this reason, we store the OS thread's + // current thread ID here when the thread is constructed, and insist that it + // never changes during the lifetime of the thread. #ifdef HAVE_POSIX_THREADS pthread_t _posix_system_thread_id; #endif diff --git a/panda/src/pipeline/threadSimpleManager.I b/panda/src/pipeline/threadSimpleManager.I index abd8cbbf82..70c3f156fe 100644 --- a/panda/src/pipeline/threadSimpleManager.I +++ b/panda/src/pipeline/threadSimpleManager.I @@ -1,46 +1,37 @@ -// Filename: threadSimpleManager.I -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleManager.I + * @author drose + * @date 2007-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::get_current_thread -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadSimpleImpl *ThreadSimpleManager:: get_current_thread() { return _current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::is_same_system_thread -// Access: Public -// Description: Returns true if we are still running within the same -// OS-level thread we think we should be running in, or -// false if this appears to be running in a different -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we are still running within the same OS-level thread we + * think we should be running in, or false if this appears to be running in a + * different thread. + */ INLINE bool ThreadSimpleManager:: is_same_system_thread() const { return _current_thread->is_same_system_thread(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::get_global_ptr -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadSimpleManager *ThreadSimpleManager:: get_global_ptr() { if (!_pointers_initialized) { @@ -49,12 +40,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::CompareStartTime::operator() -// Access: Public -// Description: STL function object to sort the priority queue of -// sleeping threads. -//////////////////////////////////////////////////////////////////// +/** + * STL function object to sort the priority queue of sleeping threads. + */ INLINE bool ThreadSimpleManager::CompareStartTime:: operator ()(ThreadSimpleImpl *a, ThreadSimpleImpl *b) const { return a->get_wake_time() > b->get_wake_time(); diff --git a/panda/src/pipeline/threadSimpleManager.cxx b/panda/src/pipeline/threadSimpleManager.cxx index eafa2f93eb..4c7640b885 100644 --- a/panda/src/pipeline/threadSimpleManager.cxx +++ b/panda/src/pipeline/threadSimpleManager.cxx @@ -1,16 +1,15 @@ -// Filename: threadSimpleManager.cxx -// Created by: drose (19Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleManager.cxx + * @author drose + * @date 2007-06-19 + */ #include "threadSimpleManager.h" @@ -28,11 +27,9 @@ bool ThreadSimpleManager::_pointers_initialized; ThreadSimpleManager *ThreadSimpleManager::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ThreadSimpleManager:: ThreadSimpleManager() : _simple_thread_epoch_timeslice @@ -78,36 +75,32 @@ ThreadSimpleManager() : _clock = TrueClock::get_global_ptr(); _waiting_for_exit = NULL; - // Install these global pointers so very low-level code (code - // defined before the pipeline directory) can yield when necessary. + // Install these global pointers so very low-level code (code defined before + // the pipeline directory) can yield when necessary. global_thread_yield = &Thread::force_yield; global_thread_consider_yield = &Thread::consider_yield; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::enqueue_ready -// Access: Public -// Description: Adds the indicated thread to the ready queue. The -// thread will be executed when its turn comes. If the -// thread is not the currently executing thread, its -// _jmp_context should be filled appropriately. -// -// If volunteer is true, the thread is volunteering to -// sleep before its timeslice has been used up. If -// volunteer is false, the thread would still be running -// if it could. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated thread to the ready queue. The thread will be executed + * when its turn comes. If the thread is not the currently executing thread, + * its _jmp_context should be filled appropriately. + * + * If volunteer is true, the thread is volunteering to sleep before its + * timeslice has been used up. If volunteer is false, the thread would still + * be running if it could. + */ void ThreadSimpleManager:: enqueue_ready(ThreadSimpleImpl *thread, bool volunteer) { - // We actually add it to _next_ready, so that we can tell when we - // have processed every thread in a given epoch. + // We actually add it to _next_ready, so that we can tell when we have + // processed every thread in a given epoch. if (!volunteer) { _next_ready.push_back(thread); } else { - // Unless it's a volunteer, in which case we actually put it to - // sleep for the duration of the timeslice, so it won't interfere - // with timeslice accounting for the remaining ready threads. + // Unless it's a volunteer, in which case we actually put it to sleep for + // the duration of the timeslice, so it won't interfere with timeslice + // accounting for the remaining ready threads. double now = get_current_time(); thread->_wake_time = now + _simple_thread_volunteer_delay; _volunteers.push_back(thread); @@ -115,19 +108,16 @@ enqueue_ready(ThreadSimpleImpl *thread, bool volunteer) { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::enqueue_sleep -// Access: Public -// Description: Adds the indicated thread to the sleep queue, until -// the indicated number of seconds have elapsed. Then -// the thread will be automatically moved to the ready -// queue. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated thread to the sleep queue, until the indicated number of + * seconds have elapsed. Then the thread will be automatically moved to the + * ready queue. + */ void ThreadSimpleManager:: enqueue_sleep(ThreadSimpleImpl *thread, double seconds) { if (thread_cat->is_debug()) { thread_cat.debug() - << *_current_thread->_parent_obj << " sleeping for " + << *_current_thread->_parent_obj << " sleeping for " << seconds << " seconds\n"; } @@ -137,26 +127,21 @@ enqueue_sleep(ThreadSimpleImpl *thread, double seconds) { push_heap(_sleeping.begin(), _sleeping.end(), CompareStartTime()); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::enqueue_block -// Access: Public -// Description: Adds the indicated thread to the blocked queue for -// the indicated blocker. The thread will be awoken by -// a later call to unblock_one() or unblock_all(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated thread to the blocked queue for the indicated blocker. + * The thread will be awoken by a later call to unblock_one() or + * unblock_all(). + */ void ThreadSimpleManager:: enqueue_block(ThreadSimpleImpl *thread, BlockerSimple *blocker) { _blocked[blocker].push_back(thread); blocker->_flags |= BlockerSimple::F_has_waiters; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::unblock_one -// Access: Public -// Description: Unblocks one thread waiting on the indicated blocker, -// if any. Returns true if anything was unblocked, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Unblocks one thread waiting on the indicated blocker, if any. Returns true + * if anything was unblocked, false otherwise. + */ bool ThreadSimpleManager:: unblock_one(BlockerSimple *blocker) { Blocked::iterator bi = _blocked.find(blocker); @@ -179,13 +164,10 @@ unblock_one(BlockerSimple *blocker) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::unblock_all -// Access: Public -// Description: Unblocks all threads waiting on the indicated -// blocker. Returns true if anything was unblocked, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Unblocks all threads waiting on the indicated blocker. Returns true if + * anything was unblocked, false otherwise. + */ bool ThreadSimpleManager:: unblock_all(BlockerSimple *blocker) { Blocked::iterator bi = _blocked.find(blocker); @@ -206,27 +188,21 @@ unblock_all(BlockerSimple *blocker) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::enqueue_finished -// Access: Public -// Description: Adds the indicated thread to the finished queue. -// The manager will drop the reference count on the -// indicated thread at the next epoch. (A thread can't -// drop its own reference count while it is running, -// since that might deallocate its own stack.) -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated thread to the finished queue. The manager will drop the + * reference count on the indicated thread at the next epoch. (A thread can't + * drop its own reference count while it is running, since that might + * deallocate its own stack.) + */ void ThreadSimpleManager:: enqueue_finished(ThreadSimpleImpl *thread) { _finished.push_back(thread); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::preempt -// Access: Public -// Description: Moves the indicated thread to the head of the ready -// queue. If it is not already on the ready queue, does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Moves the indicated thread to the head of the ready queue. If it is not + * already on the ready queue, does nothing. + */ void ThreadSimpleManager:: preempt(ThreadSimpleImpl *thread) { FifoThreads::iterator ti; @@ -237,23 +213,18 @@ preempt(ThreadSimpleImpl *thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::next_context -// Access: Public -// Description: Switches out the currently executing thread and -// chooses a new thread for execution. Before calling -// this, the current thread should have already -// re-enqueued itself with a call to enqueue(), if it -// intends to run again. -// -// This will fill in the current thread's _jmp_context -// member appropriately, and then change the global -// current_thread pointer. -//////////////////////////////////////////////////////////////////// +/** + * Switches out the currently executing thread and chooses a new thread for + * execution. Before calling this, the current thread should have already re- + * enqueued itself with a call to enqueue(), if it intends to run again. + * + * This will fill in the current thread's _jmp_context member appropriately, + * and then change the global current_thread pointer. + */ void ThreadSimpleManager:: next_context() { - // Delete any threads that need it. We can't delete the current - // thread, though. + // Delete any threads that need it. We can't delete the current thread, + // though. while (!_finished.empty() && _finished.front() != _current_thread) { ThreadSimpleImpl *finished_thread = _finished.front(); _finished.pop_front(); @@ -275,8 +246,8 @@ next_context() { #endif // DO_PSTATS save_thread_context(_current_thread->_context, st_choose_next_context, this); - // Pass 2: we have returned into the context, and are now resuming - // the current thread. + // Pass 2: we have returned into the context, and are now resuming the + // current thread. #ifdef DO_PSTATS if (pstats_callback != NULL) { @@ -289,20 +260,17 @@ next_context() { #endif // HAVE_PYTHON } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::prepare_for_exit -// Access: Public -// Description: Blocks until all running threads (other than the -// current thread) have finished. This only works when -// called from the main thread; if called on any other -// thread, nothing will happen. -//////////////////////////////////////////////////////////////////// +/** + * Blocks until all running threads (other than the current thread) have + * finished. This only works when called from the main thread; if called on + * any other thread, nothing will happen. + */ void ThreadSimpleManager:: prepare_for_exit() { if (!_current_thread->_parent_obj->is_exact_type(MainThread::get_class_type())) { if (thread_cat->is_debug()) { thread_cat.debug() - << "Ignoring prepare_for_exit called from " + << "Ignoring prepare_for_exit called from " << *(_current_thread->_parent_obj) << "\n"; } return; @@ -347,25 +315,20 @@ prepare_for_exit() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::set_current_thread -// Access: Public -// Description: Sets the initial value of the current_thread pointer, -// i.e. the main thread. It is valid to call this -// method only exactly once. -//////////////////////////////////////////////////////////////////// +/** + * Sets the initial value of the current_thread pointer, i.e. the main + * thread. It is valid to call this method only exactly once. + */ void ThreadSimpleManager:: set_current_thread(ThreadSimpleImpl *current_thread) { nassertv(_current_thread == (ThreadSimpleImpl *)NULL); _current_thread = current_thread; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::remove_thread -// Access: Public -// Description: Removes the indicated thread from the accounting, for -// instance just before the thread destructs. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated thread from the accounting, for instance just before + * the thread destructs. + */ void ThreadSimpleManager:: remove_thread(ThreadSimpleImpl *thread) { TickRecords new_records; @@ -384,13 +347,10 @@ remove_thread(ThreadSimpleImpl *thread) { _tick_records.swap(new_records); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::system_sleep -// Access: Public, Static -// Description: Calls the appropriate system sleep function to sleep -// the whole process for the indicated number of -// seconds. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate system sleep function to sleep the whole process for + * the indicated number of seconds. + */ void ThreadSimpleManager:: system_sleep(double seconds) { #ifdef WIN32 @@ -403,7 +363,7 @@ system_sleep(double seconds) { rqtp.tv_nsec = long((seconds - (double)rqtp.tv_sec) * 1000000000.0 + 0.5); nanosleep(&rqtp, NULL); */ - + // We use select() as the only way that seems to actually yield the // timeslice. sleep() and nanosleep() don't appear to do the trick. struct timeval tv; @@ -413,11 +373,9 @@ system_sleep(double seconds) { #endif // WIN32 } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::write_status -// Access: Public -// Description: Writes a list of threads running and threads blocked. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of threads running and threads blocked. + */ void ThreadSimpleManager:: write_status(ostream &out) const { out << "Currently running: " << *_current_thread->_parent_obj << "\n"; @@ -467,12 +425,10 @@ write_status(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::system_yield -// Access: Public, Static -// Description: Calls the appropriate system function to yield -// the whole process to any other system processes. -//////////////////////////////////////////////////////////////////// +/** + * Calls the appropriate system function to yield the whole process to any + * other system processes. + */ void ThreadSimpleManager:: system_yield() { if (!_pointers_initialized) { @@ -485,34 +441,27 @@ system_yield() { << "system_yield\n"; } - // There seem to be some issues with modern operating systems not - // wanting to actually yield the timeslice in response to sleep(0). - // In particular, Windows and OSX both seemed to do nothing in that - // call. Whatever. We'll force the point by explicitly sleeping - // for 1 ms in both cases. This is user-configurable in case 1 ms - // is too much (though on Windows that's all the resolution you - // have). + // There seem to be some issues with modern operating systems not wanting to + // actually yield the timeslice in response to sleep(0). In particular, + // Windows and OSX both seemed to do nothing in that call. Whatever. We'll + // force the point by explicitly sleeping for 1 ms in both cases. This is + // user-configurable in case 1 ms is too much (though on Windows that's all + // the resolution you have). system_sleep(_global_ptr->_simple_thread_yield_sleep); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::get_current_time -// Access: Public -// Description: Returns elapsed time in seconds from some undefined -// epoch, via whatever clock the manager is using for -// all thread timing. -//////////////////////////////////////////////////////////////////// +/** + * Returns elapsed time in seconds from some undefined epoch, via whatever + * clock the manager is using for all thread timing. + */ double ThreadSimpleManager:: get_current_time() const { return _clock->get_short_raw_time(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::init_pointers -// Access: Private, Static -// Description: Should be called at startup to initialize the -// simple threading system. -//////////////////////////////////////////////////////////////////// +/** + * Should be called at startup to initialize the simple threading system. + */ void ThreadSimpleManager:: init_pointers() { if (!_pointers_initialized) { @@ -521,8 +470,7 @@ init_pointers() { Thread::get_main_thread(); #ifdef HAVE_PYTHON - // Ensure that the Python threading system is initialized and ready - // to go. + // Ensure that the Python threading system is initialized and ready to go. #if PY_VERSION_HEX >= 0x03020000 Py_Initialize(); @@ -533,24 +481,18 @@ init_pointers() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::st_choose_next_context -// Access: Private, Static -// Description: Select the next context to run. Continuing the work -// of next_context(). -//////////////////////////////////////////////////////////////////// +/** + * Select the next context to run. Continuing the work of next_context(). + */ void ThreadSimpleManager:: st_choose_next_context(struct ThreadContext *from_context, void *data) { ThreadSimpleManager *self = (ThreadSimpleManager *)data; self->choose_next_context(from_context); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::choose_next_context -// Access: Private -// Description: Select the next context to run. Continuing the work -// of next_context(). -//////////////////////////////////////////////////////////////////// +/** + * Select the next context to run. Continuing the work of next_context(). + */ void ThreadSimpleManager:: choose_next_context(struct ThreadContext *from_context) { double now = get_current_time(); @@ -560,12 +502,12 @@ choose_next_context(struct ThreadContext *from_context) { if (!_sleeping.empty() || !_volunteers.empty()) { if (_ready.empty() && _next_ready.empty()) { - // All of our threads are currently sleeping. Therefore, wake - // the volunteer(s) immediately. + // All of our threads are currently sleeping. Therefore, wake the + // volunteer(s) immediately. wake_all_sleepers(_volunteers); - // We should also yield the whole process now, to be polite to - // the rest of the system. + // We should also yield the whole process now, to be polite to the rest + // of the system. system_yield(); now = get_current_time(); } @@ -584,9 +526,9 @@ choose_next_context(struct ThreadContext *from_context) { _ready.swap(_next_ready); if (new_epoch && !_tick_records.empty()) { - // Pop the oldest timeslice record off when we finish an - // epoch without executing any threads, to ensure we don't - // get caught in an "all threads reached budget" loop. + // Pop the oldest timeslice record off when we finish an epoch + // without executing any threads, to ensure we don't get caught in + // an "all threads reached budget" loop. if (thread_cat->is_debug()) { thread_cat.debug() << "All threads exceeded budget.\n"; @@ -605,16 +547,16 @@ choose_next_context(struct ThreadContext *from_context) { _tick_records.pop_front(); } new_epoch = true; - + } else if (!_volunteers.empty()) { - // There are some volunteers. Wake them. Also wake any - // sleepers that need it. + // There are some volunteers. Wake them. Also wake any sleepers that + // need it. if (thread_cat->is_debug()) { thread_cat.debug() << "Waking volunteers.\n"; } - // We should yield the whole process now, to be polite to the - // rest of the system. + // We should yield the whole process now, to be polite to the rest of + // the system. system_yield(); now = get_current_time(); wake_all_sleepers(_volunteers); @@ -633,31 +575,30 @@ choose_next_context(struct ThreadContext *from_context) { now = get_current_time(); wake_sleepers(_sleeping, now); wake_sleepers(_volunteers, now); - + } else { // No threads are ready! if (_waiting_for_exit != NULL) { - // This is a shutdown situation. In this case, we quietly - // abandoned the remaining blocked threads, if any, and - // switch back to the main thread to finish shutting down. + // This is a shutdown situation. In this case, we quietly abandoned + // the remaining blocked threads, if any, and switch back to the + // main thread to finish shutting down. _ready.push_back(_waiting_for_exit); _waiting_for_exit = NULL; break; } - // No threads are ready to run, but we're not explicitly - // shutting down. This is an error condition, an - // unintentional deadlock. + // No threads are ready to run, but we're not explicitly shutting + // down. This is an error condition, an unintentional deadlock. if (!_blocked.empty()) { thread_cat->error() << "Deadlock! All threads blocked.\n"; report_deadlock(); abort(); } - - // No threads are queued anywhere. This is some kind of - // internal error, since normally the main thread, at least, - // should be queued somewhere. + + // No threads are queued anywhere. This is some kind of internal + // error, since normally the main thread, at least, should be queued + // somewhere. thread_cat->error() << "All threads disappeared!\n"; exit(0); @@ -666,7 +607,7 @@ choose_next_context(struct ThreadContext *from_context) { ThreadSimpleImpl *chosen_thread = _ready.front(); _ready.pop_front(); - + double timeslice = determine_timeslice(chosen_thread); if (timeslice > 0.0) { // This thread is ready to roll. Break out of the loop. @@ -676,9 +617,8 @@ choose_next_context(struct ThreadContext *from_context) { break; } - // This thread is not ready to wake up yet. Put it back for next - // epoch. It doesn't count as a volunteer, though--its timeslice - // was used up. + // This thread is not ready to wake up yet. Put it back for next epoch. + // It doesn't count as a volunteer, though--its timeslice was used up. _next_ready.push_back(chosen_thread); } @@ -708,12 +648,10 @@ choose_next_context(struct ThreadContext *from_context) { abort(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::do_timeslice_accounting -// Access: Private -// Description: Records the amount of time the indicated thread has -// run, and updates the moving average. -//////////////////////////////////////////////////////////////////// +/** + * Records the amount of time the indicated thread has run, and updates the + * moving average. + */ void ThreadSimpleManager:: do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { double elapsed = now - thread->_start_time; @@ -723,8 +661,8 @@ do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { << thread->_stop_time - thread->_start_time << " requested.\n"; } - // Clamp the elapsed time at 0. (If it's less than 0, the clock is - // running backwards, ick.) + // Clamp the elapsed time at 0. (If it's less than 0, the clock is running + // backwards, ick.) elapsed = max(elapsed, 0.0); unsigned int ticks = (unsigned int)(elapsed * _tick_scale + 0.5); @@ -740,8 +678,8 @@ do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { // Ensure we don't go negative. record._thread->_run_ticks -= record._tick_count; } else { - // It is possible for this to happen if the application has been - // paused for more than 2^31 ticks. + // It is possible for this to happen if the application has been paused + // for more than 2^31 ticks. record._thread->_run_ticks = 0; } _tick_records.pop_front(); @@ -756,12 +694,10 @@ do_timeslice_accounting(ThreadSimpleImpl *thread, double now) { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::wake_sleepers -// Access: Private -// Description: Moves any threads due to wake up from the sleeping -// queue to the ready queue. -//////////////////////////////////////////////////////////////////// +/** + * Moves any threads due to wake up from the sleeping queue to the ready + * queue. + */ void ThreadSimpleManager:: wake_sleepers(ThreadSimpleManager::Sleeping &sleepers, double now) { while (!sleepers.empty() && sleepers.front()->_wake_time <= now) { @@ -772,12 +708,10 @@ wake_sleepers(ThreadSimpleManager::Sleeping &sleepers, double now) { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::wake_all_sleepers -// Access: Private -// Description: Moves all threads from the indicated sleeping queue -// to the ready queue, regardless of wake time. -//////////////////////////////////////////////////////////////////// +/** + * Moves all threads from the indicated sleeping queue to the ready queue, + * regardless of wake time. + */ void ThreadSimpleManager:: wake_all_sleepers(ThreadSimpleManager::Sleeping &sleepers) { while (!sleepers.empty()) { @@ -788,11 +722,9 @@ wake_all_sleepers(ThreadSimpleManager::Sleeping &sleepers) { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::report_deadlock -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ThreadSimpleManager:: report_deadlock() { Blocked::const_iterator bi; @@ -816,14 +748,11 @@ report_deadlock() { } } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::determine_timeslice -// Access: Private -// Description: Determines the amount of time that should be -// allocated to the next timeslice of this thread, based -// on its priority weight and the amount of time it has -// run recently relative to other threads. -//////////////////////////////////////////////////////////////////// +/** + * Determines the amount of time that should be allocated to the next + * timeslice of this thread, based on its priority weight and the amount of + * time it has run recently relative to other threads. + */ double ThreadSimpleManager:: determine_timeslice(ThreadSimpleImpl *chosen_thread) { if (_ready.empty() && _next_ready.empty()) { @@ -871,12 +800,10 @@ determine_timeslice(ThreadSimpleImpl *chosen_thread) { return remaining_ratio * _simple_thread_epoch_timeslice; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::kill_non_joinable -// Access: Private -// Description: Removes any non-joinable threads from the indicated -// queue and marks them killed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any non-joinable threads from the indicated queue and marks them + * killed. + */ void ThreadSimpleManager:: kill_non_joinable(ThreadSimpleManager::FifoThreads &threads) { FifoThreads new_threads; @@ -898,12 +825,10 @@ kill_non_joinable(ThreadSimpleManager::FifoThreads &threads) { threads.swap(new_threads); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadSimpleManager::kill_non_joinable -// Access: Private -// Description: Removes any non-joinable threads from the indicated -// queue and marks them killed. -//////////////////////////////////////////////////////////////////// +/** + * Removes any non-joinable threads from the indicated queue and marks them + * killed. + */ void ThreadSimpleManager:: kill_non_joinable(ThreadSimpleManager::Sleeping &threads) { Sleeping new_threads; diff --git a/panda/src/pipeline/threadSimpleManager.h b/panda/src/pipeline/threadSimpleManager.h index 34314907f5..364b59be8f 100644 --- a/panda/src/pipeline/threadSimpleManager.h +++ b/panda/src/pipeline/threadSimpleManager.h @@ -1,16 +1,15 @@ -// Filename: threadSimpleManager.h -// Created by: drose (18Jun07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadSimpleManager.h + * @author drose + * @date 2007-06-18 + */ #ifndef THREADSIMPLEMANAGER_H #define THREADSIMPLEMANAGER_H @@ -42,20 +41,17 @@ class ThreadSimpleImpl; class BlockerSimple; struct ThreadContext; -//////////////////////////////////////////////////////////////////// -// Class : ThreadSimpleManager -// Description : This is the global object that selects the -// currently-active thread of the various -// ThreadSimpleImpl objects running, when the -// currently-active thread yields. -// -// This class only exists when we are using the -// ThreadSimple implementation, which is to say, we are -// not using "real" threads. -// -// Generally, you shouldn't be calling these methods -// directly. Call the interfaces on Thread instead. -//////////////////////////////////////////////////////////////////// +/** + * This is the global object that selects the currently-active thread of the + * various ThreadSimpleImpl objects running, when the currently-active thread + * yields. + * + * This class only exists when we are using the ThreadSimple implementation, + * which is to say, we are not using "real" threads. + * + * Generally, you shouldn't be calling these methods directly. Call the + * interfaces on Thread instead. + */ class EXPCL_PANDA_PIPELINE ThreadSimpleManager { private: ThreadSimpleManager(); @@ -120,28 +116,26 @@ public: private: ThreadSimpleImpl *volatile _current_thread; - // The list of ready threads: threads that are ready to execute - // right now. + // The list of ready threads: threads that are ready to execute right now. FifoThreads _ready; - // The list of threads that are ready, but will not be executed - // until next epoch (for instance, because they exceeded their - // timeslice budget this epoch). + // The list of threads that are ready, but will not be executed until next + // epoch (for instance, because they exceeded their timeslice budget this + // epoch). FifoThreads _next_ready; - // The list of threads that are blocked on some ConditionVar or - // Mutex. + // The list of threads that are blocked on some ConditionVar or Mutex. typedef pmap Blocked; Blocked _blocked; - // Priority queue (partially-ordered heap) of sleeping threads, - // based on wakeup time. + // Priority queue (partially-ordered heap) of sleeping threads, based on + // wakeup time. Sleeping _sleeping; - // Priority queue (partially-ordered heap) of volunteer threads, - // based on wakeup time. This are threads that have voluntarily - // yielded a timeslice. They are treated the same as sleeping - // threads, unless all threads are sleeping. + // Priority queue (partially-ordered heap) of volunteer threads, based on + // wakeup time. This are threads that have voluntarily yielded a timeslice. + // They are treated the same as sleeping threads, unless all threads are + // sleeping. Sleeping _volunteers; // Threads which have finished execution and are awaiting cleanup. diff --git a/panda/src/pipeline/threadWin32Impl.I b/panda/src/pipeline/threadWin32Impl.I index ab410a09ee..a4c2b84a21 100644 --- a/panda/src/pipeline/threadWin32Impl.I +++ b/panda/src/pipeline/threadWin32Impl.I @@ -1,23 +1,19 @@ -// Filename: threadWin32Impl.I -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadWin32Impl.I + * @author drose + * @date 2006-02-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ThreadWin32Impl:: ThreadWin32Impl(Thread *parent_obj) : _cv(_mutex), @@ -28,29 +24,23 @@ ThreadWin32Impl(Thread *parent_obj) : _status = S_new; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::preempt -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadWin32Impl:: preempt() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::prepare_for_exit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadWin32Impl:: prepare_for_exit() { } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::get_current_thread -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Thread *ThreadWin32Impl:: get_current_thread() { if (!_got_pt_ptr_index) { @@ -59,13 +49,10 @@ get_current_thread() { return (Thread *)TlsGetValue(_pt_ptr_index); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::bind_thread -// Access: Public, Static -// Description: Associates the indicated Thread object with the -// currently-executing thread. You should not call this -// directly; use Thread::bind_thread() instead. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated Thread object with the currently-executing thread. + * You should not call this directly; use Thread::bind_thread() instead. + */ INLINE void ThreadWin32Impl:: bind_thread(Thread *thread) { if (!_got_pt_ptr_index) { @@ -75,61 +62,49 @@ bind_thread(Thread *thread) { nassertv(result); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::is_threading_supported -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadWin32Impl:: is_threading_supported() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::is_true_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadWin32Impl:: is_true_threads() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::is_simple_threads -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ThreadWin32Impl:: is_simple_threads() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::sleep -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadWin32Impl:: sleep(double seconds) { Sleep((int)(seconds * 1000)); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadWin32Impl:: yield() { Sleep(1); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::consider_yield -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ThreadWin32Impl:: consider_yield() { } diff --git a/panda/src/pipeline/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx index 9ea243ff3f..006a98441e 100644 --- a/panda/src/pipeline/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -1,16 +1,15 @@ -// Filename: threadWin32Impl.cxx -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadWin32Impl.cxx + * @author drose + * @date 2006-02-07 + */ #include "threadWin32Impl.h" #include "selectThreadImpl.h" @@ -24,11 +23,9 @@ DWORD ThreadWin32Impl::_pt_ptr_index = 0; bool ThreadWin32Impl::_got_pt_ptr_index = false; -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ThreadWin32Impl:: ~ThreadWin32Impl() { if (thread_cat->is_debug()) { @@ -38,23 +35,18 @@ ThreadWin32Impl:: CloseHandle(_thread); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::setup_main_thread -// Access: Public -// Description: Called for the main thread only, which has been -// already started, to fill in the values appropriate to -// that thread. -//////////////////////////////////////////////////////////////////// +/** + * Called for the main thread only, which has been already started, to fill in + * the values appropriate to that thread. + */ void ThreadWin32Impl:: setup_main_thread() { _status = S_running; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::start -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ThreadWin32Impl:: start(ThreadPriority priority, bool joinable) { _mutex.acquire(); @@ -74,16 +66,15 @@ start(ThreadPriority priority, bool joinable) { init_pt_ptr_index(); } - // Increment the parent object's reference count first. The thread - // will eventually decrement it when it terminates. + // Increment the parent object's reference count first. The thread will + // eventually decrement it when it terminates. _parent_obj->ref(); - _thread = + _thread = CreateThread(NULL, 0, &root_func, (void *)this, 0, &_thread_id); if (_thread_id == 0) { - // Oops, we couldn't start the thread. Be sure to decrement the - // reference count we incremented above, and return false to - // indicate failure. + // Oops, we couldn't start the thread. Be sure to decrement the reference + // count we incremented above, and return false to indicate failure. unref_delete(_parent_obj); _mutex.release(); return false; @@ -113,13 +104,10 @@ start(ThreadPriority priority, bool joinable) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::join -// Access: Public -// Description: Blocks the calling process until the thread -// terminates. If the thread has already terminated, -// this returns immediately. -//////////////////////////////////////////////////////////////////// +/** + * Blocks the calling process until the thread terminates. If the thread has + * already terminated, this returns immediately. + */ void ThreadWin32Impl:: join() { _mutex.acquire(); @@ -134,11 +122,9 @@ join() { _mutex.release(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::get_unique_id -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string ThreadWin32Impl:: get_unique_id() const { ostringstream strm; @@ -147,21 +133,19 @@ get_unique_id() const { return strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::root_func -// Access: Private, Static -// Description: The entry point of each thread. -//////////////////////////////////////////////////////////////////// +/** + * The entry point of each thread. + */ DWORD ThreadWin32Impl:: root_func(LPVOID data) { TAU_REGISTER_THREAD(); { - //TAU_PROFILE("void ThreadWin32Impl::root_func()", " ", TAU_USER); + // TAU_PROFILE("void ThreadWin32Impl::root_func()", " ", TAU_USER); ThreadWin32Impl *self = (ThreadWin32Impl *)data; BOOL result = TlsSetValue(_pt_ptr_index, self->_parent_obj); nassertr(result, 1); - + { self->_mutex.acquire(); nassertd(self->_status == S_start_called) { @@ -172,15 +156,15 @@ root_func(LPVOID data) { self->_cv.notify(); self->_mutex.release(); } - + self->_parent_obj->thread_main(); - + if (thread_cat->is_debug()) { thread_cat.debug() - << "Terminating thread " << self->_parent_obj->get_name() + << "Terminating thread " << self->_parent_obj->get_name() << ", count = " << self->_parent_obj->get_ref_count() << "\n"; } - + { self->_mutex.acquire(); nassertd(self->_status == S_running) { @@ -191,22 +175,20 @@ root_func(LPVOID data) { self->_cv.notify(); self->_mutex.release(); } - - // Now drop the parent object reference that we grabbed in start(). - // This might delete the parent object, and in turn, delete the - // ThreadWin32Impl object. + + // Now drop the parent object reference that we grabbed in start(). This + // might delete the parent object, and in turn, delete the ThreadWin32Impl + // object. unref_delete(self->_parent_obj); } return 0; } -//////////////////////////////////////////////////////////////////// -// Function: ThreadWin32Impl::init_pt_ptr_index -// Access: Private, Static -// Description: Allocate a new index to store the Thread parent -// pointer as a piece of per-thread private data. -//////////////////////////////////////////////////////////////////// +/** + * Allocate a new index to store the Thread parent pointer as a piece of per- + * thread private data. + */ void ThreadWin32Impl:: init_pt_ptr_index() { nassertv(!_got_pt_ptr_index); @@ -220,8 +202,8 @@ init_pt_ptr_index() { _got_pt_ptr_index = true; - // Assume that we must be in the main thread, since this method must - // be called before the first thread is spawned. + // Assume that we must be in the main thread, since this method must be + // called before the first thread is spawned. Thread *main_thread_obj = Thread::get_main_thread(); BOOL result = TlsSetValue(_pt_ptr_index, main_thread_obj); nassertv(result); diff --git a/panda/src/pipeline/threadWin32Impl.h b/panda/src/pipeline/threadWin32Impl.h index 3957677b5a..665e1be43c 100644 --- a/panda/src/pipeline/threadWin32Impl.h +++ b/panda/src/pipeline/threadWin32Impl.h @@ -1,16 +1,15 @@ -// Filename: threadWin32Impl.h -// Created by: drose (07Feb06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file threadWin32Impl.h + * @author drose + * @date 2006-02-07 + */ #ifndef THREADWIN32IMPL_H #define THREADWIN32IMPL_H @@ -27,10 +26,9 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : ThreadWin32Impl -// Description : Uses native Windows calls to implement a thread. -//////////////////////////////////////////////////////////////////// +/** + * Uses native Windows calls to implement a thread. + */ class EXPCL_PANDA_PIPELINE ThreadWin32Impl { public: INLINE ThreadWin32Impl(Thread *parent_obj); diff --git a/panda/src/pnmimage/config_pnmimage.cxx b/panda/src/pnmimage/config_pnmimage.cxx index ebc1de8e20..1cb8b24bf8 100644 --- a/panda/src/pnmimage/config_pnmimage.cxx +++ b/panda/src/pnmimage/config_pnmimage.cxx @@ -1,16 +1,15 @@ -// Filename: config_pnmimage.cxx -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmimage.cxx + * @author drose + * @date 2000-03-19 + */ #include "config_pnmimage.h" #include "pnmFileType.h" @@ -59,14 +58,12 @@ ConfigVariableDouble pfm_resize_radius "always call box_filter() or gaussian_filter() explicitly with " "a specific radius.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpnmimage -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpnmimage() { static bool initialized = false; diff --git a/panda/src/pnmimage/config_pnmimage.h b/panda/src/pnmimage/config_pnmimage.h index 2f9860959b..9ff40dd5a0 100644 --- a/panda/src/pnmimage/config_pnmimage.h +++ b/panda/src/pnmimage/config_pnmimage.h @@ -1,16 +1,15 @@ -// Filename: config_pnmimage.h -// Created by: drose (19Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmimage.h + * @author drose + * @date 2000-03-19 + */ #ifndef CONFIG_PNMIMAGE_H #define CONFIG_PNMIMAGE_H diff --git a/panda/src/pnmimage/convert_srgb.I b/panda/src/pnmimage/convert_srgb.I index 2354138cb9..57d8d42170 100644 --- a/panda/src/pnmimage/convert_srgb.I +++ b/panda/src/pnmimage/convert_srgb.I @@ -1,81 +1,70 @@ -// Filename: convert_srgb.I -// Created by: rdb (29Oct14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file convert_srgb.I + * @author rdb + * @date 2014-10-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: decode_sRGB_float -// Description: Decodes the sRGB-encoded unsigned char value to -// a linearized float in the range 0-1. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the sRGB-encoded unsigned char value to a linearized float in the + * range 0-1. + */ INLINE float decode_sRGB_float(unsigned char val) { return to_linear_float_table[val]; } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_float -// Description: Decodes the sRGB-encoded floating-point value in -// the range 0-1 to a linearized float in the range -// 0-1. Inputs outside this range produce invalid -// results. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the sRGB-encoded floating-point value in the range 0-1 to a + * linearized float in the range 0-1. Inputs outside this range produce + * invalid results. + */ INLINE float decode_sRGB_float(float val) { return (val <= 0.04045f) ? (val * (1.f / 12.92f)) : cpow((val + 0.055f) * (1.f / 1.055f), 2.4f); } -//////////////////////////////////////////////////////////////////// -// Function: decode_sRGB_uchar -// Description: Decodes the sRGB-encoded unsigned char value to -// a linearized unsigned char value. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the sRGB-encoded unsigned char value to a linearized unsigned char + * value. + */ INLINE unsigned char decode_sRGB_uchar(unsigned char val) { return to_linear_uchar_table[val]; } -//////////////////////////////////////////////////////////////////// -// Function: decode_sRGB_uchar -// Description: Decodes the sRGB-encoded floating-point value in -// the range 0-1 to a linearized unsigned char value. -// Inputs outside this range are clamped. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the sRGB-encoded floating-point value in the range 0-1 to a + * linearized unsigned char value. Inputs outside this range are clamped. + */ INLINE unsigned char decode_sRGB_uchar(float val) { return (val <= 0.04045f) ? (unsigned char)(max(0.f, val) * (255.f / 12.92f) + 0.5f) : (unsigned char)(cpow((min(val, 1.f) + 0.055f) * (1.f / 1.055f), 2.4f) * 255.f + 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_float -// Description: Encodes the linearized unsigned char value to an -// sRGB-encoded floating-point value in ther range 0-1. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized unsigned char value to an sRGB-encoded floating- + * point value in ther range 0-1. + */ INLINE float encode_sRGB_float(unsigned char val) { - // This seems like a very unlikely use case, so I didn't bother - // making a look-up table for this. + // This seems like a very unlikely use case, so I didn't bother making a + // look-up table for this. return (val == 0) ? 0 : (1.055f * cpow((float)val * (1.f / 255.f), 0.41666f) - 0.055f); } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_float -// Description: Encodes the linearized floating-point value in the -// range 0-1 to an sRGB-encoded float in the range -// 0-1. Inputs outside this range produce invalid -// results. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized floating-point value in the range 0-1 to an sRGB- + * encoded float in the range 0-1. Inputs outside this range produce invalid + * results. + */ INLINE float encode_sRGB_float(float val) { return (val < 0.0031308f) @@ -83,34 +72,30 @@ encode_sRGB_float(float val) { : (1.055f * cpow(val, 0.41666f) - 0.055f); } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_uchar -// Description: Encodes the linearized unsigned char value to an -// sRGB-encoded unsigned char value. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized unsigned char value to an sRGB-encoded unsigned char + * value. + */ INLINE unsigned char encode_sRGB_uchar(unsigned char val) { return to_srgb8_table[val]; } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_uchar -// Description: Encodes the linearized floating-point value in the -// range 0-1 to an sRGB-encoded unsigned char value. -// Inputs outside this range are clamped. -// -// When SSE2 support is known at compile time, this -// automatically uses an optimized version. Otherwise, -// it does not attempt runtime CPU detection. If you -// know that SSE2 is supported (ie. if the function -// has_sse2_sRGB_encode() returns true) you should -// call encode_sRGB_uchar_sse2 instead. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized floating-point value in the range 0-1 to an sRGB- + * encoded unsigned char value. Inputs outside this range are clamped. + * + * When SSE2 support is known at compile time, this automatically uses an + * optimized version. Otherwise, it does not attempt runtime CPU detection. + * If you know that SSE2 is supported (ie. if the function + * has_sse2_sRGB_encode() returns true) you should call encode_sRGB_uchar_sse2 + * instead. + */ INLINE unsigned char encode_sRGB_uchar(float val) { #if defined(__SSE2__) || (_M_IX86_FP >= 2) || defined(_M_X64) || defined(_M_AMD64) - // Use a highly optimized approximation that has more than enough - // accuracy for an unsigned char. + // Use a highly optimized approximation that has more than enough accuracy + // for an unsigned char. return encode_sRGB_uchar_sse2(val); #else return (val < 0.0031308f) @@ -119,18 +104,16 @@ encode_sRGB_uchar(float val) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_uchar -// Description: Encodes the linearized floating-point color value -// an sRGB-encoded xel in the range 0-255. -// -// When SSE2 support is known at compile time, this -// automatically uses an optimized version. Otherwise, -// it does not attempt runtime CPU detection. If you -// know that SSE2 is supported (ie. if the function -// has_sse2_sRGB_encode() returns true) you should -// call encode_sRGB_uchar_sse2 instead. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized floating-point color value an sRGB-encoded xel in + * the range 0-255. + * + * When SSE2 support is known at compile time, this automatically uses an + * optimized version. Otherwise, it does not attempt runtime CPU detection. + * If you know that SSE2 is supported (ie. if the function + * has_sse2_sRGB_encode() returns true) you should call encode_sRGB_uchar_sse2 + * instead. + */ INLINE void encode_sRGB_uchar(const LColorf &color, xel &into) { #if defined(__SSE2__) || (_M_IX86_FP >= 2) || defined(_M_X64) || defined(_M_AMD64) @@ -145,19 +128,16 @@ encode_sRGB_uchar(const LColorf &color, xel &into) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: encode_sRGB_uchar -// Description: Encodes the linearized floating-point color value -// an sRGB-encoded xel and alpha in the range 0-255. -// The alpha value is not sRGB-encoded. -// -// When SSE2 support is known at compile time, this -// automatically uses an optimized version. Otherwise, -// it does not attempt runtime CPU detection. If you -// know that SSE2 is supported (ie. if the function -// has_sse2_sRGB_encode() returns true) you should -// call encode_sRGB_uchar_sse2 instead. -//////////////////////////////////////////////////////////////////// +/** + * Encodes the linearized floating-point color value an sRGB-encoded xel and + * alpha in the range 0-255. The alpha value is not sRGB-encoded. + * + * When SSE2 support is known at compile time, this automatically uses an + * optimized version. Otherwise, it does not attempt runtime CPU detection. + * If you know that SSE2 is supported (ie. if the function + * has_sse2_sRGB_encode() returns true) you should call encode_sRGB_uchar_sse2 + * instead. + */ INLINE void encode_sRGB_uchar(const LColorf &color, xel &into, xelval &into_alpha) { #if defined(__SSE2__) || (_M_IX86_FP >= 2) || defined(_M_X64) || defined(_M_AMD64) diff --git a/panda/src/pnmimage/convert_srgb.cxx b/panda/src/pnmimage/convert_srgb.cxx index 184b3d679c..d92a437947 100644 --- a/panda/src/pnmimage/convert_srgb.cxx +++ b/panda/src/pnmimage/convert_srgb.cxx @@ -1,16 +1,15 @@ -// Filename: convert_srgb.cxx -// Created by: rdb (13Nov14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file convert_srgb.cxx + * @author rdb + * @date 2014-11-13 + */ #include "convert_srgb.h" @@ -101,7 +100,8 @@ const float to_linear_float_table[256] = { 0, 0.000304f, 0.000607f, 0.000911f, #if defined(__SSE2__) || (_M_IX86_FP >= 2) || defined(_M_X64) || defined(_M_AMD64) -// SSE2 support enabled at compile time. No runtime detection mechanism needed. +// SSE2 support enabled at compile time. No runtime detection mechanism +// needed. bool has_sse2_sRGB_encode() { return true; diff --git a/panda/src/pnmimage/convert_srgb.h b/panda/src/pnmimage/convert_srgb.h index 376590bf11..dada8918b3 100644 --- a/panda/src/pnmimage/convert_srgb.h +++ b/panda/src/pnmimage/convert_srgb.h @@ -1,16 +1,15 @@ -// Filename: convert_srgb.h -// Created by: rdb (13Nov14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file convert_srgb.h + * @author rdb + * @date 2014-11-13 + */ #ifndef CONVERT_SRGB_H #define CONVERT_SRGB_H @@ -20,8 +19,8 @@ #include "pnmimage_base.h" // The below functions can encode and decode sRGB colors in various -// representations. Some of them are implemented using look-up tables, -// some others using SSE2 intrinsics. +// representations. Some of them are implemented using look-up tables, some +// others using SSE2 intrinsics. extern EXPCL_PANDA_PNMIMAGE const unsigned char to_srgb8_table[256]; extern EXPCL_PANDA_PNMIMAGE const unsigned char to_linear_uchar_table[256]; extern EXPCL_PANDA_PNMIMAGE const float to_linear_float_table[256]; @@ -40,15 +39,15 @@ EXPCL_PANDA_PNMIMAGE INLINE unsigned char encode_sRGB_uchar(float val); END_PUBLISH -// These functions convert more than one component in one go, -// which can be faster due to vectorization. +// These functions convert more than one component in one go, which can be +// faster due to vectorization. EXPCL_PANDA_PNMIMAGE INLINE void encode_sRGB_uchar(const LColorf &from, xel &into); EXPCL_PANDA_PNMIMAGE INLINE void encode_sRGB_uchar(const LColorf &from, xel &into, xelval &into_alpha); -// Use these functions if you know that SSE2 support is available. -// Otherwise, they will crash! +// Use these functions if you know that SSE2 support is available. Otherwise, +// they will crash! #if defined(__SSE2__) || defined(__i386__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) EXPCL_PANDA_PNMIMAGE unsigned char encode_sRGB_uchar_sse2(float val); EXPCL_PANDA_PNMIMAGE void encode_sRGB_uchar_sse2(const LColorf &from, diff --git a/panda/src/pnmimage/convert_srgb_sse2.cxx b/panda/src/pnmimage/convert_srgb_sse2.cxx index 6de58d9584..6ede245e87 100644 --- a/panda/src/pnmimage/convert_srgb_sse2.cxx +++ b/panda/src/pnmimage/convert_srgb_sse2.cxx @@ -1,20 +1,18 @@ -// Filename: convert_srgb_sse2.cxx -// Created by: rdb (13Nov14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file convert_srgb_sse2.cxx + * @author rdb + * @date 2014-11-13 + */ -// This file should always be compiled with SSE2 support. These -// functions will only be called when SSE2 support is detected at -// run-time. +// This file should always be compiled with SSE2 support. These functions +// will only be called when SSE2 support is detected at run-time. #include "convert_srgb.h" #include "luse.h" @@ -25,14 +23,14 @@ #include static INLINE __m128i _encode_sRGB_sse2_mul255(__m128 val) { - // This an SSE2-based approximation of the sRGB encode function. - // It has a maximum error of around 0.001, which is by far small - // enough for a uchar. It is also at least 10x as fast as the - // original; up to 40x when taking advantage of vectorization. - // Note that the fourth float is only multiplied with 255. + // This an SSE2-based approximation of the sRGB encode function. It has a + // maximum error of around 0.001, which is by far small enough for a uchar. + // It is also at least 10x as fast as the original; up to 40x when taking + // advantage of vectorization. Note that the fourth float is only + // multiplied with 255. // Part of the code in this function is derived from: - // http://stackoverflow.com/a/6486630/2135754 + // http:stackoverflow.coma64866302135754 // Clamp to 0-1 range. val = _mm_max_ps(val, _mm_set1_ps(0.0f)); @@ -59,28 +57,27 @@ static INLINE __m128i _encode_sRGB_sse2_mul255(__m128 val) { __m128 xavg = _mm_mul_ps(_mm_add_ps(xover, xunder), _mm_set1_ps(0.5286098f)); - // Take square root twice. Note that this is faster than - // the more expensive _mm_sqrt_ps instruction. + // Take square root twice. Note that this is faster than the more expensive + // _mm_sqrt_ps instruction. xavg = _mm_mul_ps(xavg, _mm_rsqrt_ps(xavg)); xavg = _mm_mul_ps(xavg, _mm_rsqrt_ps(xavg)); - // Bring it into the correct range. These factors are determined - // not on the basis of accuracy, but are chosen such that the - // decoder lookup table produces an equivalent result for any value. + // Bring it into the correct range. These factors are determined not on the + // basis of accuracy, but are chosen such that the decoder lookup table + // produces an equivalent result for any value. xavg = _mm_mul_ps(xavg, _mm_set1_ps(269.122f)); xavg = _mm_sub_ps(xavg, _mm_set1_ps(13.55f)); - // Compute the linear section. This is also the path that - // the alpha channel takes, so we set the alpha multiplier - // to 255 (since alpha is not sRGB-converted). + // Compute the linear section. This is also the path that the alpha channel + // takes, so we set the alpha multiplier to 255 (since alpha is not sRGB- + // converted). __m128 lval = _mm_mul_ps(val, _mm_set_ps(255.0f, 3294.6f, 3294.6f, 3294.6f)); lval = _mm_add_ps(lval, _mm_set1_ps(0.5f)); - // Decide which version to return. Rig the alpha - // comparator to always fail so that the linear path - // is always chosen for alpha. + // Decide which version to return. Rig the alpha comparator to always fail + // so that the linear path is always chosen for alpha. __m128 mask = _mm_cmpge_ps(val, _mm_set_ps(2.0f, 0.0031308f, 0.0031308f, 0.0031308f)); @@ -92,8 +89,8 @@ static INLINE __m128i _encode_sRGB_sse2_mul255(__m128 val) { unsigned char encode_sRGB_uchar_sse2(float val) { - // Running only a single component through this function is still - // way faster than the equivalent non-SSE2 version. + // Running only a single component through this function is still way faster + // than the equivalent non-SSE2 version. return (unsigned char) _mm_extract_epi16(_encode_sRGB_sse2_mul255(_mm_set1_ps(val)), 0); } diff --git a/panda/src/pnmimage/pfmFile.I b/panda/src/pnmimage/pfmFile.I index f3ae0cb5a5..42625aeb32 100644 --- a/panda/src/pnmimage/pfmFile.I +++ b/panda/src/pnmimage/pfmFile.I @@ -1,69 +1,53 @@ -// Filename: pfmFile.I -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmFile.I + * @author drose + * @date 2010-12-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::is_valid -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PfmFile:: is_valid() const { return _num_channels != 0 && (_x_size * _y_size * _num_channels <= (int)_table.size()); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_scale -// Access: Published -// Description: The "scale" is reported in the pfm header and is -// probably meaningless. -//////////////////////////////////////////////////////////////////// +/** + * The "scale" is reported in the pfm header and is probably meaningless. + */ INLINE PN_float32 PfmFile:: get_scale() const { return _scale; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_scale -// Access: Published -// Description: The "scale" is reported in the pfm header and is -// probably meaningless. -//////////////////////////////////////////////////////////////////// +/** + * The "scale" is reported in the pfm header and is probably meaningless. + */ INLINE void PfmFile:: set_scale(PN_float32 scale) { _scale = scale; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point -// Access: Published -// Description: Returns true if there is a valid point at x, y. This -// always returns true unless a "no data" value has been -// set, in which case it returns false if the point at -// x, y is the "no data" value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a valid point at x, y. This always returns true + * unless a "no data" value has been set, in which case it returns false if + * the point at x, y is the "no data" value. + */ INLINE bool PfmFile:: has_point(int x, int y) const { return _has_point(this, x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_channel -// Access: Published -// Description: Returns the cth channel of the point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the cth channel of the point value at the indicated point. + */ INLINE PN_float32 PfmFile:: get_channel(int x, int y, int c) const { nassertr(x >= 0 && x < _x_size && @@ -72,12 +56,9 @@ get_channel(int x, int y, int c) const { return _table[(y * _x_size + x) * _num_channels + c]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_channel -// Access: Published -// Description: Replaces the cth channel of the point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the cth channel of the point value at the indicated point. + */ INLINE void PfmFile:: set_channel(int x, int y, int c, PN_float32 value) { nassertv(x >= 0 && x < _x_size && @@ -86,12 +67,9 @@ set_channel(int x, int y, int c, PN_float32 value) { _table[(y * _x_size + x) * _num_channels + c] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_point1 -// Access: Published -// Description: Returns the 1-component point value at the indicated -// point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 1-component point value at the indicated point. + */ INLINE PN_float32 PfmFile:: get_point1(int x, int y) const { nassertr(x >= 0 && x < _x_size && @@ -99,12 +77,9 @@ get_point1(int x, int y) const { return _table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point1 -// Access: Published -// Description: Replaces the 1-component point value at the indicated -// point. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 1-component point value at the indicated point. + */ INLINE void PfmFile:: set_point1(int x, int y, PN_float32 point) { nassertv(!cnan(point)); @@ -113,13 +88,10 @@ set_point1(int x, int y, PN_float32 point) { _table[(y * _x_size + x) * _num_channels] = point; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_point2 -// Access: Published -// Description: Returns the 2-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 2-component point value at the indicated point. In a 1-channel + * image, the channel value is in the x component. + */ INLINE const LPoint2f &PfmFile:: get_point2(int x, int y) const { nassertr(x >= 0 && x < _x_size && @@ -127,13 +99,10 @@ get_point2(int x, int y) const { return *(LPoint2f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point2 -// Access: Published -// Description: Replaces the 2-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 2-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point2(int x, int y, const LVecBase2f &point) { nassertv(!point.is_nan()); @@ -158,24 +127,18 @@ set_point2(int x, int y, const LVecBase2f &point) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point2 -// Access: Published -// Description: Replaces the 2-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 2-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point2(int x, int y, const LVecBase2d &point) { set_point2(x, y, LCAST(PN_float32, point)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::modify_point2 -// Access: Published -// Description: Returns a modifiable 2-component point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable 2-component point value at the indicated point. + */ INLINE LPoint2f &PfmFile:: modify_point2(int x, int y) { #ifndef NDEBUG @@ -187,60 +150,45 @@ modify_point2(int x, int y) { return *(LPoint2f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_point -// Access: Published -// Description: Returns the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-component point value at the indicated point. In a 1-channel + * image, the channel value is in the x component. + */ INLINE const LPoint3f &PfmFile:: get_point(int x, int y) const { return get_point3(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point -// Access: Published -// Description: Replaces the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 3-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point(int x, int y, const LVecBase3f &point) { set_point3(x, y, point); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point -// Access: Published -// Description: Replaces the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 3-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point(int x, int y, const LVecBase3d &point) { set_point3(x, y, point); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::modify_point -// Access: Published -// Description: Returns a modifiable 3-component point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable 3-component point value at the indicated point. + */ INLINE LPoint3f &PfmFile:: modify_point(int x, int y) { return modify_point3(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_point3 -// Access: Published -// Description: Returns the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 3-component point value at the indicated point. In a 1-channel + * image, the channel value is in the x component. + */ INLINE const LPoint3f &PfmFile:: get_point3(int x, int y) const { nassertr(x >= 0 && x < _x_size && @@ -248,13 +196,10 @@ get_point3(int x, int y) const { return *(LPoint3f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point3 -// Access: Published -// Description: Replaces the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 3-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point3(int x, int y, const LVecBase3f &point) { nassertv(!point.is_nan()); @@ -279,24 +224,18 @@ set_point3(int x, int y, const LVecBase3f &point) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point3 -// Access: Published -// Description: Replaces the 3-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 3-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point3(int x, int y, const LVecBase3d &point) { set_point3(x, y, LCAST(PN_float32, point)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::modify_point3 -// Access: Published -// Description: Returns a modifiable 3-component point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable 3-component point value at the indicated point. + */ INLINE LPoint3f &PfmFile:: modify_point3(int x, int y) { #ifndef NDEBUG @@ -308,13 +247,10 @@ modify_point3(int x, int y) { return *(LPoint3f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_point4 -// Access: Published -// Description: Returns the 4-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the 4-component point value at the indicated point. In a 1-channel + * image, the channel value is in the x component. + */ INLINE const LPoint4f &PfmFile:: get_point4(int x, int y) const { nassertr(x >= 0 && x < _x_size && @@ -322,13 +258,10 @@ get_point4(int x, int y) const { return *(LPoint4f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point4 -// Access: Published -// Description: Replaces the 4-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 4-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point4(int x, int y, const LVecBase4f &point) { nassertv(!point.is_nan()); @@ -353,24 +286,18 @@ set_point4(int x, int y, const LVecBase4f &point) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_point4 -// Access: Published -// Description: Replaces the 4-component point value at the indicated -// point. In a 1-channel image, the channel value is in -// the x component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 4-component point value at the indicated point. In a + * 1-channel image, the channel value is in the x component. + */ INLINE void PfmFile:: set_point4(int x, int y, const LVecBase4d &point) { set_point4(x, y, LCAST(PN_float32, point)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::modify_point4 -// Access: Published -// Description: Returns a modifiable 4-component point value at the -// indicated point. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable 4-component point value at the indicated point. + */ INLINE LPoint4f &PfmFile:: modify_point4(int x, int y) { #ifndef NDEBUG @@ -382,45 +309,36 @@ modify_point4(int x, int y) { return *(LPoint4f *)&_table[(y * _x_size + x) * _num_channels]; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill -// Access: Published -// Description: Fills the table with all of the same value. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with all of the same value. + */ INLINE void PfmFile:: fill(PN_float32 value) { fill(LPoint4f(value, 0.0f, 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill -// Access: Published -// Description: Fills the table with all of the same value. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with all of the same value. + */ INLINE void PfmFile:: fill(const LPoint2f &value) { fill(LPoint4f(value[0], value[1], 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill -// Access: Published -// Description: Fills the table with all of the same value. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with all of the same value. + */ INLINE void PfmFile:: fill(const LPoint3f &value) { fill(LPoint4f(value[0], value[1], value[2], 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_autocrop -// Access: Published -// Description: Computes the minimum range of x and y across the PFM -// file that include all points. If there are no points -// with no_data_value in the grid--that is, all points -// are included--then this will return (0, get_x_size(), -// 0, get_y_size()). -//////////////////////////////////////////////////////////////////// +/** + * Computes the minimum range of x and y across the PFM file that include all + * points. If there are no points with no_data_value in the grid--that is, + * all points are included--then this will return (0, get_x_size(), 0, + * get_y_size()). + */ INLINE bool PfmFile:: calc_autocrop(LVecBase4f &range) const { int x_begin, x_end, y_begin, y_end; @@ -429,15 +347,12 @@ calc_autocrop(LVecBase4f &range) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_autocrop -// Access: Published -// Description: Computes the minimum range of x and y across the PFM -// file that include all points. If there are no points -// with no_data_value in the grid--that is, all points -// are included--then this will return (0, get_x_size(), -// 0, get_y_size()). -//////////////////////////////////////////////////////////////////// +/** + * Computes the minimum range of x and y across the PFM file that include all + * points. If there are no points with no_data_value in the grid--that is, + * all points are included--then this will return (0, get_x_size(), 0, + * get_y_size()). + */ INLINE bool PfmFile:: calc_autocrop(LVecBase4d &range) const { int x_begin, x_end, y_begin, y_end; @@ -446,15 +361,12 @@ calc_autocrop(LVecBase4d &range) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_zero_special -// Access: Published -// Description: Sets the zero_special flag. When this flag is true, -// values of (0, 0, 0) in the pfm file are treated as a -// special case, and are not processed. -// -// This is a special case of set_no_data_value(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the zero_special flag. When this flag is true, values of (0, 0, 0) in + * the pfm file are treated as a special case, and are not processed. + * + * This is a special case of set_no_data_value(). + */ INLINE void PfmFile:: set_zero_special(bool zero_special) { if (zero_special) { @@ -464,16 +376,13 @@ set_zero_special(bool zero_special) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_chan4 -// Access: Published -// Description: Sets the no_data_chan4 flag. When this flag is true, -// and the pfm file has 4 channels, then a negative -// value in the fourth channel indicates no data. When -// it is false, all points are valid. -// -// This is a special case of set_no_data_value(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the no_data_chan4 flag. When this flag is true, and the pfm file has + * 4 channels, then a negative value in the fourth channel indicates no data. + * When it is false, all points are valid. + * + * This is a special case of set_no_data_value(). + */ INLINE void PfmFile:: set_no_data_chan4(bool chan4) { if (chan4 && _num_channels == 4) { @@ -486,36 +395,28 @@ set_no_data_chan4(bool chan4) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_value -// Access: Published -// Description: Sets the special value that means "no data" when it -// appears in the pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Sets the special value that means "no data" when it appears in the pfm + * file. + */ INLINE void PfmFile:: set_no_data_value(const LPoint4d &no_data_value) { set_no_data_value(LCAST(PN_float32, no_data_value)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_threshold -// Access: Published -// Description: Sets the special threshold value. Points that are -// below this value in all components are considered "no -// value". -//////////////////////////////////////////////////////////////////// +/** + * Sets the special threshold value. Points that are below this value in all + * components are considered "no value". + */ INLINE void PfmFile:: set_no_data_threshold(const LPoint4d &no_data_threshold) { set_no_data_threshold(LCAST(PN_float32, no_data_threshold)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_value -// Access: Published -// Description: Removes the special value that means "no data" when it -// appears in the pfm file. All points will thus be -// considered valid. -//////////////////////////////////////////////////////////////////// +/** + * Removes the special value that means "no data" when it appears in the pfm + * file. All points will thus be considered valid. + */ INLINE void PfmFile:: clear_no_data_value() { _has_no_data_value = false; @@ -524,174 +425,135 @@ clear_no_data_value() { _has_point = has_point_noop; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_no_data_value -// Access: Published -// Description: Returns whether a "no data" value has been -// established by set_no_data_value(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether a "no data" value has been established by + * set_no_data_value(). + */ INLINE bool PfmFile:: has_no_data_value() const { return _has_no_data_value; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_no_data_threshold -// Access: Published -// Description: Returns whether a "no data" threshold value has been -// established by set_no_data_threshold(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether a "no data" threshold value has been established by + * set_no_data_threshold(). + */ INLINE bool PfmFile:: has_no_data_threshold() const { return _has_no_data_threshold; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_no_data_value -// Access: Published -// Description: If has_no_data_value() returns true, this returns the -// particular "no data" value. -//////////////////////////////////////////////////////////////////// +/** + * If has_no_data_value() returns true, this returns the particular "no data" + * value. + */ INLINE const LPoint4f &PfmFile:: get_no_data_value() const { nassertr(_has_no_data_value, LPoint4f::zero()); return _no_data_value; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::xform -// Access: Published -// Description: Applies the indicated transform matrix to all points -// in-place. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform matrix to all points in-place. + */ INLINE void PfmFile:: xform(const LMatrix4d &transform) { xform(LCAST(PN_float32, transform)); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::compute_planar_bounds -// Access: Published -// Description: Computes the minmax bounding volume of the points in -// 3-D space, assuming the points represent a -// mostly-planar surface. -// -// This algorithm works by sampling the (square) -// sample_radius pixels at the four point_dist corners -// around the center (cx - pd, cx + pd) and so on, to -// approximate the plane of the surface. Then all of -// the points are projected into that plane and the -// bounding volume of the entire mesh within that plane -// is determined. If points_only is true, the bounding -// volume of only those four points is determined. -// -// center, point_dist and sample_radius are in UV space, -// i.e. in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Computes the minmax bounding volume of the points in 3-D space, assuming + * the points represent a mostly-planar surface. + * + * This algorithm works by sampling the (square) sample_radius pixels at the + * four point_dist corners around the center (cx - pd, cx + pd) and so on, to + * approximate the plane of the surface. Then all of the points are projected + * into that plane and the bounding volume of the entire mesh within that + * plane is determined. If points_only is true, the bounding volume of only + * those four points is determined. + * + * center, point_dist and sample_radius are in UV space, i.e. in the range + * 0..1. + */ INLINE PT(BoundingHexahedron) PfmFile:: compute_planar_bounds(const LPoint2d ¢er, PN_float32 point_dist, PN_float32 sample_radius, bool points_only) const { return compute_planar_bounds(LCAST(PN_float32, center), point_dist, sample_radius, points_only); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::gamma_correct -// Access: Published -// Description: Assuming the image was constructed with a gamma curve -// of from_gamma in the RGB channels, converts it to an -// image with a gamma curve of to_gamma in the RGB -// channels. Does not affect the alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the image was constructed with a gamma curve of from_gamma in the + * RGB channels, converts it to an image with a gamma curve of to_gamma in the + * RGB channels. Does not affect the alpha channel. + */ INLINE void PfmFile:: gamma_correct(float from_gamma, float to_gamma) { apply_exponent(from_gamma / to_gamma); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::gamma_correct_alpha -// Access: Published -// Description: Assuming the image was constructed with a gamma curve -// of from_gamma in the alpha channel, converts it to an -// image with a gamma curve of to_gamma in the alpha -// channel. Does not affect the RGB channels. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the image was constructed with a gamma curve of from_gamma in the + * alpha channel, converts it to an image with a gamma curve of to_gamma in + * the alpha channel. Does not affect the RGB channels. + */ INLINE void PfmFile:: gamma_correct_alpha(float from_gamma, float to_gamma) { apply_exponent(1.0, from_gamma / to_gamma); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. + */ INLINE void PfmFile:: apply_exponent(float gray_exponent) { apply_exponent(gray_exponent, gray_exponent, gray_exponent, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. + */ INLINE void PfmFile:: apply_exponent(float gray_exponent, float alpha_exponent) { apply_exponent(gray_exponent, gray_exponent, gray_exponent, alpha_exponent); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. For a -// grayscale image, the blue_exponent value is used for -// the grayscale value, and red_exponent and -// green_exponent are unused. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. For a + * grayscale image, the blue_exponent value is used for the grayscale value, + * and red_exponent and green_exponent are unused. + */ INLINE void PfmFile:: apply_exponent(float c0_exponent, float c1_exponent, float c2_exponent) { apply_exponent(c0_exponent, c1_exponent, c2_exponent, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_table -// Access: Public -// Description: This is a very low-level function that returns a -// read-only reference to the internal table of -// floating-point numbers. Use this method at your own -// risk. -//////////////////////////////////////////////////////////////////// +/** + * This is a very low-level function that returns a read-only reference to the + * internal table of floating-point numbers. Use this method at your own + * risk. + */ INLINE const vector_float &PfmFile:: get_table() const { return _table; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::swap_table -// Access: Public -// Description: This is a very low-level function that completely -// exchanges the PfmFile's internal table of -// floating-point numbers with whatever you supply. The -// provided table must have an appropriate size. Use -// this method at your own risk. -//////////////////////////////////////////////////////////////////// +/** + * This is a very low-level function that completely exchanges the PfmFile's + * internal table of floating-point numbers with whatever you supply. The + * provided table must have an appropriate size. Use this method at your own + * risk. + */ void PfmFile:: swap_table(vector_float &table) { _table.swap(table); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::setup_sub_image -// Access: Private -// Description: Computes xmin, ymin, xmax, and ymax, based on the -// input parameters for copy_sub_image() and related -// methods. -//////////////////////////////////////////////////////////////////// +/** + * Computes xmin, ymin, xmax, and ymax, based on the input parameters for + * copy_sub_image() and related methods. + */ INLINE void PfmFile:: setup_sub_image(const PfmFile ©, int &xto, int &yto, int &xfrom, int &yfrom, int &x_size, int &y_size, diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index 9456117964..45127887e4 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -1,16 +1,15 @@ -// Filename: pfmFile.cxx -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmFile.cxx + * @author drose + * @date 2010-12-23 + */ #include "config_pnmimage.h" #include "pfmFile.h" @@ -25,11 +24,9 @@ #include "string_utils.h" #include "look_at.h" -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PfmFile:: PfmFile() { _has_no_data_value = false; @@ -39,11 +36,9 @@ PfmFile() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PfmFile:: PfmFile(const PfmFile ©) : PNMImageHeader(copy), @@ -56,11 +51,9 @@ PfmFile(const PfmFile ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::Copy Assignment -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: operator = (const PfmFile ©) { PNMImageHeader::operator = (copy); @@ -72,11 +65,9 @@ operator = (const PfmFile ©) { _has_point = copy._has_point; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::clear -// Access: Published -// Description: Eliminates all data in the file. -//////////////////////////////////////////////////////////////////// +/** + * Eliminates all data in the file. + */ void PfmFile:: clear() { _x_size = 0; @@ -87,14 +78,11 @@ clear() { clear_no_data_value(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::clear -// Access: Published -// Description: Resets to an empty table with a specific size. The -// case of num_channels == 0 is allowed only in the case -// that x_size and y_size are also == 0; and this makes -// an empty (and invalid) PfmFile. -//////////////////////////////////////////////////////////////////// +/** + * Resets to an empty table with a specific size. The case of num_channels == + * 0 is allowed only in the case that x_size and y_size are also == 0; and + * this makes an empty (and invalid) PfmFile. + */ void PfmFile:: clear(int x_size, int y_size, int num_channels) { nassertv(x_size >= 0 && y_size >= 0); @@ -108,24 +96,21 @@ clear(int x_size, int y_size, int num_channels) { _table.clear(); int size = _x_size * _y_size * _num_channels; - // We allocate a little bit bigger to allow safe overflow: you can - // call get_point3() or get_point4() on the last point of a 1- or - // 3-channel image. + // We allocate a little bit bigger to allow safe overflow: you can call + // get_point3() or get_point4() on the last point of a 1- or 3-channel + // image. _table.insert(_table.end(), size + 4, (PN_float32)0.0); clear_no_data_value(); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::read -// Access: Published -// Description: Reads the PFM data from the indicated file, returning -// true on success, false on failure. -// -// This can also handle reading a standard image file -// supported by PNMImage; it will be quietly converted -// to a floating-point type. -//////////////////////////////////////////////////////////////////// +/** + * Reads the PFM data from the indicated file, returning true on success, + * false on failure. + * + * This can also handle reading a standard image file supported by PNMImage; + * it will be quietly converted to a floating-point type. + */ bool PfmFile:: read(const Filename &fullpath) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -151,16 +136,13 @@ read(const Filename &fullpath) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::read -// Access: Published -// Description: Reads the PFM data from the indicated stream, -// returning true on success, false on failure. -// -// This can also handle reading a standard image file -// supported by PNMImage; it will be quietly converted -// to a floating-point type. -//////////////////////////////////////////////////////////////////// +/** + * Reads the PFM data from the indicated stream, returning true on success, + * false on failure. + * + * This can also handle reading a standard image file supported by PNMImage; + * it will be quietly converted to a floating-point type. + */ bool PfmFile:: read(istream &in, const Filename &fullpath) { PNMReader *reader = make_reader(&in, false, fullpath); @@ -171,14 +153,11 @@ read(istream &in, const Filename &fullpath) { return read(reader); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::read -// Access: Published -// Description: Reads the PFM data using the indicated PNMReader. -// -// The PNMReader is always deleted upon completion, -// whether successful or not. -//////////////////////////////////////////////////////////////////// +/** + * Reads the PFM data using the indicated PNMReader. + * + * The PNMReader is always deleted upon completion, whether successful or not. + */ bool PfmFile:: read(PNMReader *reader) { clear(); @@ -207,17 +186,14 @@ read(PNMReader *reader) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::write -// Access: Published -// Description: Writes the PFM data to the indicated file, returning -// true on success, false on failure. -// -// If the type implied by the filename extension -// supports floating-point, the data will be written -// directly; otherwise, the floating-point data will be -// quietly converted to the appropriate integer type. -//////////////////////////////////////////////////////////////////// +/** + * Writes the PFM data to the indicated file, returning true on success, false + * on failure. + * + * If the type implied by the filename extension supports floating-point, the + * data will be written directly; otherwise, the floating-point data will be + * quietly converted to the appropriate integer type. + */ bool PfmFile:: write(const Filename &fullpath) { if (!is_valid()) { @@ -242,12 +218,10 @@ write(const Filename &fullpath) { return write(out, fullpath); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::write -// Access: Published -// Description: Writes the PFM data to the indicated stream, -// returning true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes the PFM data to the indicated stream, returning true on success, + * false on failure. + */ bool PfmFile:: write(ostream &out, const Filename &fullpath) { if (!is_valid()) { @@ -262,14 +236,11 @@ write(ostream &out, const Filename &fullpath) { return write(writer); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::write -// Access: Published -// Description: Writes the PFM data using the indicated PNMWriter. -// -// The PNMWriter is always deleted upon completion, -// whether successful or not. -//////////////////////////////////////////////////////////////////// +/** + * Writes the PFM data using the indicated PNMWriter. + * + * The PNMWriter is always deleted upon completion, whether successful or not. + */ bool PfmFile:: write(PNMWriter *writer) { if (writer == NULL) { @@ -284,8 +255,8 @@ write(PNMWriter *writer) { writer->copy_header_from(*this); if (!writer->supports_floating_point()) { - // Hmm, it's an integer file type. Convert it from the - // floating-point data we have. + // Hmm, it's an integer file type. Convert it from the floating-point + // data we have. PNMImage pnmimage; if (!store(pnmimage)) { delete writer; @@ -302,12 +273,10 @@ write(PNMWriter *writer) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::load -// Access: Published -// Description: Fills the PfmFile with the data from the indicated -// PNMImage, converted to floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Fills the PfmFile with the data from the indicated PNMImage, converted to + * floating-point values. + */ bool PfmFile:: load(const PNMImage &pnmimage) { if (!pnmimage.is_valid()) { @@ -377,12 +346,9 @@ load(const PNMImage &pnmimage) { } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::store -// Access: Published -// Description: Copies the data to the indicated PNMImage, converting -// to RGB values. -//////////////////////////////////////////////////////////////////// +/** + * Copies the data to the indicated PNMImage, converting to RGB values. + */ bool PfmFile:: store(PNMImage &pnmimage) const { if (!is_valid()) { @@ -443,14 +409,11 @@ store(PNMImage &pnmimage) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::store_mask -// Access: Published -// Description: Stores 1 or 0 values into the indicated PNMImage, -// according to has_point() for each pixel. Each valid -// point gets a 1 value; each nonexistent point gets a 0 -// value. -//////////////////////////////////////////////////////////////////// +/** + * Stores 1 or 0 values into the indicated PNMImage, according to has_point() + * for each pixel. Each valid point gets a 1 value; each nonexistent point + * gets a 0 value. + */ bool PfmFile:: store_mask(PNMImage &pnmimage) const { if (!is_valid()) { @@ -467,20 +430,16 @@ store_mask(PNMImage &pnmimage) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::store_mask -// Access: Published -// Description: Stores 1 or 0 values into the indicated PNMImage, -// according to has_point() for each pixel. Each valid -// point gets a 1 value; each nonexistent point gets a 0 -// value. -// -// This flavor of store_mask also checks whether the -// valid points are within the specified min/max range. -// Any valid points without the condition min_point[c] -// <= value[c] <= max_point[c], for any c, are stored -// with a 0 in the mask. -//////////////////////////////////////////////////////////////////// +/** + * Stores 1 or 0 values into the indicated PNMImage, according to has_point() + * for each pixel. Each valid point gets a 1 value; each nonexistent point + * gets a 0 value. + * + * This flavor of store_mask also checks whether the valid points are within + * the specified min/max range. Any valid points without the condition + * min_point[c] <= value[c] <= max_point[c], for any c, are stored with a 0 in + * the mask. + */ bool PfmFile:: store_mask(PNMImage &pnmimage, const LVecBase4f &min_point, const LVecBase4f &max_point) const { if (!is_valid()) { @@ -509,11 +468,9 @@ store_mask(PNMImage &pnmimage, const LVecBase4f &min_point, const LVecBase4f &ma return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill -// Access: Published -// Description: Fills the table with all of the same value. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with all of the same value. + */ void PfmFile:: fill(const LPoint4f &value) { switch (_num_channels) { @@ -559,11 +516,9 @@ fill(const LPoint4f &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_nan -// Access: Published -// Description: Fills the table with all NaN. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with all NaN. + */ void PfmFile:: fill_nan() { PN_float32 nan = make_nan((PN_float32)0.0); @@ -571,23 +526,18 @@ fill_nan() { fill(nan4); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_no_data_value -// Access: Published -// Description: Fills the table with the current no_data value, so -// that the table is empty. -//////////////////////////////////////////////////////////////////// +/** + * Fills the table with the current no_data value, so that the table is empty. + */ void PfmFile:: fill_no_data_value() { fill(_no_data_value); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_channel -// Access: Published -// Description: Fills the indicated channel with all of the same -// value, leaving the other channels unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated channel with all of the same value, leaving the other + * channels unchanged. + */ void PfmFile:: fill_channel(int channel, PN_float32 value) { nassertv(channel >= 0 && channel < _num_channels); @@ -599,25 +549,19 @@ fill_channel(int channel, PN_float32 value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_channel_nan -// Access: Published -// Description: Fills the indicated channel with NaN, leaving the -// other channels unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated channel with NaN, leaving the other channels unchanged. + */ void PfmFile:: fill_channel_nan(int channel) { PN_float32 nan = make_nan((PN_float32)0.0); fill_channel(channel, nan); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_channel_masked -// Access: Published -// Description: Fills the indicated channel with all of the same -// value, but only where the table already has a data -// point. Leaves empty points unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated channel with all of the same value, but only where the + * table already has a data point. Leaves empty points unchanged. + */ void PfmFile:: fill_channel_masked(int channel, PN_float32 value) { nassertv(channel >= 0 && channel < _num_channels); @@ -635,29 +579,22 @@ fill_channel_masked(int channel, PN_float32 value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_channel_masked_nan -// Access: Published -// Description: Fills the indicated channel with NaN, but only where -// the table already has a data point. Leaves empty -// points unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated channel with NaN, but only where the table already has + * a data point. Leaves empty points unchanged. + */ void PfmFile:: fill_channel_masked_nan(int channel) { PN_float32 nan = make_nan((PN_float32)0.0); fill_channel_masked(channel, nan); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_average_point -// Access: Published -// Description: Computes the unweighted average point of all points -// within the box centered at (x, y) with the indicated -// Manhattan-distance radius. Missing points are -// assigned the value of their nearest neighbor. -// Returns true if successful, or false if the point -// value cannot be determined. -//////////////////////////////////////////////////////////////////// +/** + * Computes the unweighted average point of all points within the box centered + * at (x, y) with the indicated Manhattan-distance radius. Missing points are + * assigned the value of their nearest neighbor. Returns true if successful, + * or false if the point value cannot be determined. + */ bool PfmFile:: calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radius) const { result = LPoint3f::zero(); @@ -667,10 +604,10 @@ calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radi int max_x = int(floor(x + radius)); int max_y = int(floor(y + radius)); - // We first construct a mini-grid of x_size by y_size integer values - // to index into the main table. This indirection allows us to fill - // in the holes in the mini-grid with the nearest known values - // before we compute the average. + // We first construct a mini-grid of x_size by y_size integer values to + // index into the main table. This indirection allows us to fill in the + // holes in the mini-grid with the nearest known values before we compute + // the average. int x_size = max_x - min_x + 1; int y_size = max_y - min_y + 1; int size = x_size * y_size; @@ -681,8 +618,7 @@ calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radi pvector mini_grid; mini_grid.insert(mini_grid.end(), size, MiniGridCell()); - // Now collect the known data points and apply them to the - // mini-grid. + // Now collect the known data points and apply them to the mini-grid. min_x = max(min_x, 0); min_y = max(min_y, 0); max_x = min(max_x, _x_size - 1); @@ -725,8 +661,7 @@ calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radi } } - // Now the mini-grid is completely filled, so we can compute the - // average. + // Now the mini-grid is completely filled, so we can compute the average. for (int gi = 0; gi < size; ++gi) { int sxi = mini_grid[gi]._sxi; int syi = mini_grid[gi]._syi; @@ -738,14 +673,11 @@ calc_average_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radi return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_bilinear_point -// Access: Published -// Description: Computes the weighted average of the four nearest -// points to the floating-point index (x, y). Returns -// true if the point has any contributors, false if the -// point is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Computes the weighted average of the four nearest points to the floating- + * point index (x, y). Returns true if the point has any contributors, false + * if the point is unknown. + */ bool PfmFile:: calc_bilinear_point(LPoint3f &result, PN_float32 x, PN_float32 y) const { result = LPoint3f::zero(); @@ -788,15 +720,12 @@ calc_bilinear_point(LPoint3f &result, PN_float32 x, PN_float32 y) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_min_max -// Access: Published -// Description: Calculates the minimum and maximum x, y, and z depth -// component values, representing the bounding box of -// depth values, and places them in the indicated -// vectors. Returns true if successful, false if the -// mesh contains no points. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the minimum and maximum x, y, and z depth component values, + * representing the bounding box of depth values, and places them in the + * indicated vectors. Returns true if successful, false if the mesh contains + * no points. + */ bool PfmFile:: calc_min_max(LVecBase3f &min_depth, LVecBase3f &max_depth) const { bool any_points = false; @@ -829,15 +758,12 @@ calc_min_max(LVecBase3f &min_depth, LVecBase3f &max_depth) const { return any_points; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_autocrop -// Access: Published -// Description: Computes the minimum range of x and y across the PFM -// file that include all points. If there are no points -// with no_data_value in the grid--that is, all points -// are included--then this will return (0, get_x_size(), -// 0, get_y_size()). -//////////////////////////////////////////////////////////////////// +/** + * Computes the minimum range of x and y across the PFM file that include all + * points. If there are no points with no_data_value in the grid--that is, + * all points are included--then this will return (0, get_x_size(), 0, + * get_y_size()). + */ bool PfmFile:: calc_autocrop(int &x_begin, int &x_end, int &y_begin, int &y_end) const { y_begin = 0; @@ -872,13 +798,10 @@ calc_autocrop(int &x_begin, int &x_end, int &y_begin, int &y_end) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::is_row_empty -// Access: Published -// Description: Returns true if all of the points on row y, in the range -// [x_begin, x_end), are the no_data value, or false if -// any one of these points has a value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the points on row y, in the range [x_begin, x_end), + * are the no_data value, or false if any one of these points has a value. + */ bool PfmFile:: is_row_empty(int y, int x_begin, int x_end) const { nassertr(y >= 0 && y < _y_size && @@ -896,13 +819,10 @@ is_row_empty(int y, int x_begin, int x_end) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::is_column_empty -// Access: Published -// Description: Returns true if all of the points on column x, from -// [y_begin, y_end), are the no_data value, or false if -// any one of these points has a value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the points on column x, from [y_begin, y_end), are + * the no_data value, or false if any one of these points has a value. + */ bool PfmFile:: is_column_empty(int x, int y_begin, int y_end) const { nassertr(x >= 0 && x < _x_size && @@ -920,17 +840,13 @@ is_column_empty(int x, int y_begin, int y_end) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_nan -// Access: Published -// Description: Sets the no_data_nan flag. When num_channels is -// nonzero, then a NaN value in any of the first -// num_channels channels indicates no data for that -// point. If num_channels is zero, then all points are -// valid. -// -// This is a special case of set_no_data_value(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the no_data_nan flag. When num_channels is nonzero, then a NaN value + * in any of the first num_channels channels indicates no data for that point. + * If num_channels is zero, then all points are valid. + * + * This is a special case of set_no_data_value(). + */ void PfmFile:: set_no_data_nan(int num_channels) { if (num_channels > 0) { @@ -963,12 +879,10 @@ set_no_data_nan(int num_channels) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_value -// Access: Published -// Description: Sets the special value that means "no data" when it -// appears in the pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Sets the special value that means "no data" when it appears in the pfm + * file. + */ void PfmFile:: set_no_data_value(const LPoint4f &no_data_value) { nassertv(is_valid()); @@ -994,13 +908,10 @@ set_no_data_value(const LPoint4f &no_data_value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::set_no_data_threshold -// Access: Published -// Description: Sets the special threshold value. Points that are -// below this value in all components are considered "no -// value". -//////////////////////////////////////////////////////////////////// +/** + * Sets the special threshold value. Points that are below this value in all + * components are considered "no value". + */ void PfmFile:: set_no_data_threshold(const LPoint4f &no_data_value) { nassertv(is_valid()); @@ -1026,14 +937,11 @@ set_no_data_threshold(const LPoint4f &no_data_value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::resize -// Access: Published -// Description: Applies a simple filter to resample the pfm file -// in-place to the indicated size. Don't confuse this -// with applying a scale to all of the points via -// xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies a simple filter to resample the pfm file in-place to the indicated + * size. Don't confuse this with applying a scale to all of the points via + * xform(). + */ void PfmFile:: resize(int new_x_size, int new_y_size) { if (_x_size == 0 || _y_size == 0 || new_x_size == 0 || new_y_size == 0) { @@ -1056,8 +964,8 @@ resize(int new_x_size, int new_y_size) { result.quick_filter_from(*this); } else { - // Otherwise, we should use box_filter() or gaussian_filter, which - // are more general. + // Otherwise, we should use box_filter() or gaussian_filter, which are + // more general. if (pfm_resize_gaussian) { result.gaussian_filter_from(pfm_resize_radius, *this); } else { @@ -1070,15 +978,12 @@ resize(int new_x_size, int new_y_size) { _y_size = new_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::quick_filter_from -// Access: Public -// Description: Resizes from the given image, with a fixed radius of -// 0.5. This is a very specialized and simple algorithm -// that doesn't handle dropping below the Nyquist rate -// very well, but is quite a bit faster than the more -// general box_filter(), above. -//////////////////////////////////////////////////////////////////// +/** + * Resizes from the given image, with a fixed radius of 0.5. This is a very + * specialized and simple algorithm that doesn't handle dropping below the + * Nyquist rate very well, but is quite a bit faster than the more general + * box_filter(), above. + */ void PfmFile:: quick_filter_from(const PfmFile &from) { if (_x_size == 0 || _y_size == 0) { @@ -1116,8 +1021,8 @@ quick_filter_from(const PfmFile &from) { from_x1 = (to_x + 1.0) * x_scale; from_x1 = min(from_x1, (PN_float32)orig_x_size); - // Now the box from (from_x0, from_y0) - (from_x1, from_y1) - // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). + // Now the box from (from_x0, from_y0) - (from_x1, from_y1) but not + // including (from_x1, from_y1) maps to the pixel (to_x, to_y). PN_float32 result; from.box_filter_region(result, from_x0, from_y0, from_x1, from_y1); new_data.push_back(result); @@ -1141,8 +1046,8 @@ quick_filter_from(const PfmFile &from) { from_x1 = (to_x + 1.0) * x_scale; from_x1 = min(from_x1, (PN_float32)orig_x_size); - // Now the box from (from_x0, from_y0) - (from_x1, from_y1) - // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). + // Now the box from (from_x0, from_y0) - (from_x1, from_y1) but not + // including (from_x1, from_y1) maps to the pixel (to_x, to_y). LPoint2f result; from.box_filter_region(result, from_x0, from_y0, from_x1, from_y1); new_data.push_back(result[0]); @@ -1167,8 +1072,8 @@ quick_filter_from(const PfmFile &from) { from_x1 = (to_x + 1.0) * x_scale; from_x1 = min(from_x1, (PN_float32)orig_x_size); - // Now the box from (from_x0, from_y0) - (from_x1, from_y1) - // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). + // Now the box from (from_x0, from_y0) - (from_x1, from_y1) but not + // including (from_x1, from_y1) maps to the pixel (to_x, to_y). LPoint3f result; from.box_filter_region(result, from_x0, from_y0, from_x1, from_y1); new_data.push_back(result[0]); @@ -1194,8 +1099,8 @@ quick_filter_from(const PfmFile &from) { from_x1 = (to_x + 1.0) * x_scale; from_x1 = min(from_x1, (PN_float32)orig_x_size); - // Now the box from (from_x0, from_y0) - (from_x1, from_y1) - // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). + // Now the box from (from_x0, from_y0) - (from_x1, from_y1) but not + // including (from_x1, from_y1) maps to the pixel (to_x, to_y). LPoint4f result; from.box_filter_region(result, from_x0, from_y0, from_x1, from_y1); new_data.push_back(result[0]); @@ -1223,11 +1128,9 @@ quick_filter_from(const PfmFile &from) { _table.swap(new_data); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::reverse_rows -// Access: Published -// Description: Performs an in-place reversal of the row (y) data. -//////////////////////////////////////////////////////////////////// +/** + * Performs an in-place reversal of the row (y) data. + */ void PfmFile:: reverse_rows() { nassertv(is_valid()); @@ -1249,17 +1152,13 @@ reverse_rows() { _table.swap(reversed); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::flip -// Access: Published -// Description: Reverses, transposes, and/or rotates the table -// in-place according to the specified parameters. If -// flip_x is true, the x axis is reversed; if flip_y is -// true, the y axis is reversed. Then, if transpose is -// true, the x and y axes are exchanged. These -// parameters can be used to select any combination of -// 90-degree or 180-degree rotations and flips. -//////////////////////////////////////////////////////////////////// +/** + * Reverses, transposes, and/or rotates the table in-place according to the + * specified parameters. If flip_x is true, the x axis is reversed; if flip_y + * is true, the y axis is reversed. Then, if transpose is true, the x and y + * axes are exchanged. These parameters can be used to select any combination + * of 90-degree or 180-degree rotations and flips. + */ void PfmFile:: flip(bool flip_x, bool flip_y, bool transpose) { nassertv(is_valid()); @@ -1305,12 +1204,9 @@ flip(bool flip_x, bool flip_y, bool transpose) { _table.swap(flipped); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::xform -// Access: Published -// Description: Applies the indicated transform matrix to all points -// in-place. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform matrix to all points in-place. + */ void PfmFile:: xform(const LMatrix4f &transform) { nassertv(is_valid()); @@ -1326,28 +1222,23 @@ xform(const LMatrix4f &transform) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::forward_distort -// Access: Published -// Description: Applies the distortion indicated in the supplied dist -// map to the current map. The dist map is understood -// to be a mapping of points in the range 0..1 in the -// first two dimensions. -// -// The operation can be expressed symbolically as: -// -// this(u, v) = this(dist(u, v)) -// -// If scale_factor is not 1, it should be a value > 1, -// and it specifies the factor to upscale the working -// table while processing, to reduce artifacts from -// integer truncation. -// -// By convention, the y axis is inverted in the -// distortion map relative to the coordinates here. A y -// value of 0 in the distortion map corresponds with a v -// value of 1 in this file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the distortion indicated in the supplied dist map to the current + * map. The dist map is understood to be a mapping of points in the range + * 0..1 in the first two dimensions. + * + * The operation can be expressed symbolically as: + * + * this(u, v) = this(dist(u, v)) + * + * If scale_factor is not 1, it should be a value > 1, and it specifies the + * factor to upscale the working table while processing, to reduce artifacts + * from integer truncation. + * + * By convention, the y axis is inverted in the distortion map relative to the + * coordinates here. A y value of 0 in the distortion map corresponds with a + * v value of 1 in this file. + */ void PfmFile:: forward_distort(const PfmFile &dist, PN_float32 scale_factor) { int working_x_size = (int)cceil(_x_size * scale_factor); @@ -1404,28 +1295,23 @@ forward_distort(const PfmFile &dist, PN_float32 scale_factor) { _table.swap(result._table); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::reverse_distort -// Access: Published -// Description: Applies the distortion indicated in the supplied dist -// map to the current map. The dist map is understood -// to be a mapping of points in the range 0..1 in the -// first two dimensions. -// -// The operation can be expressed symbolically as: -// -// this(u, v) = dist(this(u, v)) -// -// If scale_factor is not 1, it should be a value > 1, -// and it specifies the factor to upscale the working -// table while processing, to reduce artifacts from -// integer truncation. -// -// By convention, the y axis in inverted in the -// distortion map relative to the coordinates here. A y -// value of 0 in the distortion map corresponds with a v -// value of 1 in this file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the distortion indicated in the supplied dist map to the current + * map. The dist map is understood to be a mapping of points in the range + * 0..1 in the first two dimensions. + * + * The operation can be expressed symbolically as: + * + * this(u, v) = dist(this(u, v)) + * + * If scale_factor is not 1, it should be a value > 1, and it specifies the + * factor to upscale the working table while processing, to reduce artifacts + * from integer truncation. + * + * By convention, the y axis in inverted in the distortion map relative to the + * coordinates here. A y value of 0 in the distortion map corresponds with a + * v value of 1 in this file. + */ void PfmFile:: reverse_distort(const PfmFile &dist, PN_float32 scale_factor) { int working_x_size = (int)cceil(_x_size * scale_factor); @@ -1481,14 +1367,11 @@ reverse_distort(const PfmFile &dist, PN_float32 scale_factor) { _table.swap(result._table); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_1d_lut -// Access: Published -// Description: Assumes that lut is an X by 1, 1-component PfmFile -// whose X axis maps points to target points. For each -// point in this pfm file, computes: p(u, v)[channel] = -// lut(p(u, v)[channel] * x_scale, 0)[0] -//////////////////////////////////////////////////////////////////// +/** + * Assumes that lut is an X by 1, 1-component PfmFile whose X axis maps points + * to target points. For each point in this pfm file, computes: p(u, + * v)[channel] = lut(p(u, v)[channel] * x_scale, 0)[0] + */ void PfmFile:: apply_1d_lut(int channel, const PfmFile &lut, PN_float32 x_scale) { for (int yi = 0; yi < _y_size; ++yi) { @@ -1507,14 +1390,11 @@ apply_1d_lut(int channel, const PfmFile &lut, PN_float32 x_scale) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::merge -// Access: Published -// Description: Wherever there is missing data in this PfmFile (that -// is, wherever has_point() returns false), copy data -// from the other PfmFile, which must be exactly the -// same dimensions as this one. -//////////////////////////////////////////////////////////////////// +/** + * Wherever there is missing data in this PfmFile (that is, wherever + * has_point() returns false), copy data from the other PfmFile, which must be + * exactly the same dimensions as this one. + */ void PfmFile:: merge(const PfmFile &other) { nassertv(is_valid() && other.is_valid()); @@ -1534,17 +1414,13 @@ merge(const PfmFile &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_mask -// Access: Published -// Description: Wherever there is missing data in the other PfmFile, -// set this the corresponding point in this PfmFile to -// missing as well, so that this PfmFile has only points -// where both files have points. -// -// The point is set to "missing" by setting it the -// no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * Wherever there is missing data in the other PfmFile, set this the + * corresponding point in this PfmFile to missing as well, so that this + * PfmFile has only points where both files have points. + * + * The point is set to "missing" by setting it the no_data_value. + */ void PfmFile:: apply_mask(const PfmFile &other) { nassertv(is_valid() && other.is_valid()); @@ -1564,13 +1440,10 @@ apply_mask(const PfmFile &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::copy_channel -// Access: Published -// Description: Copies just the specified channel values from the -// indicated PfmFile (which could be same as this -// PfmFile) into the specified channel of this one. -//////////////////////////////////////////////////////////////////// +/** + * Copies just the specified channel values from the indicated PfmFile (which + * could be same as this PfmFile) into the specified channel of this one. + */ void PfmFile:: copy_channel(int to_channel, const PfmFile &other, int from_channel) { nassertv(is_valid() && other.is_valid()); @@ -1585,13 +1458,10 @@ copy_channel(int to_channel, const PfmFile &other, int from_channel) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::copy_channel_masked -// Access: Published -// Description: Copies just the specified channel values from the -// indicated PfmFile, but only where the other file has -// a data point. -//////////////////////////////////////////////////////////////////// +/** + * Copies just the specified channel values from the indicated PfmFile, but + * only where the other file has a data point. + */ void PfmFile:: copy_channel_masked(int to_channel, const PfmFile &other, int from_channel) { nassertv(is_valid() && other.is_valid()); @@ -1608,13 +1478,10 @@ copy_channel_masked(int to_channel, const PfmFile &other, int from_channel) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_crop -// Access: Published -// Description: Reduces the PFM file to the cells in the rectangle -// bounded by (x_begin, x_end, y_begin, y_end), where -// the _end cells are not included. -//////////////////////////////////////////////////////////////////// +/** + * Reduces the PFM file to the cells in the rectangle bounded by (x_begin, + * x_end, y_begin, y_end), where the _end cells are not included. + */ void PfmFile:: apply_crop(int x_begin, int x_end, int y_begin, int y_end) { nassertv(x_begin >= 0 && x_begin <= x_end && x_end <= _x_size); @@ -1625,9 +1492,9 @@ apply_crop(int x_begin, int x_end, int y_begin, int y_end) { Table new_table; int new_size = new_x_size * new_y_size * _num_channels; - // We allocate a little bit bigger to allow safe overflow: you can - // call get_point3() or get_point4() on the last point of a 1- or - // 3-channel image. + // We allocate a little bit bigger to allow safe overflow: you can call + // get_point3() or get_point4() on the last point of a 1- or 3-channel + // image. new_table.insert(new_table.end(), new_size + 4, (PN_float32)0.0); for (int yi = 0; yi < new_y_size; ++yi) { @@ -1642,13 +1509,10 @@ apply_crop(int x_begin, int x_end, int y_begin, int y_end) { _y_size = new_y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::clear_to_texcoords -// Access: Published -// Description: Replaces this PfmFile with a new PfmFile of size -// x_size x y_size x 3, containing the x y 0 values in -// the range 0 .. 1 according to the x y index. -//////////////////////////////////////////////////////////////////// +/** + * Replaces this PfmFile with a new PfmFile of size x_size x y_size x 3, + * containing the x y 0 values in the range 0 .. 1 according to the x y index. + */ void PfmFile:: clear_to_texcoords(int x_size, int y_size) { clear(x_size, y_size, 3); @@ -1671,15 +1535,12 @@ clear_to_texcoords(int x_size, int y_size) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::pull_spot -// Access: Published -// Description: Applies delta * t to the point values within radius -// (xr, yr) distance of (xc, yc). The t value is scaled -// from 1.0 at the center to 0.0 at radius (xr, yr), and -// this scale follows the specified exponent. Returns -// the number of points affected. -//////////////////////////////////////////////////////////////////// +/** + * Applies delta * t to the point values within radius (xr, yr) distance of + * (xc, yc). The t value is scaled from 1.0 at the center to 0.0 at radius + * (xr, yr), and this scale follows the specified exponent. Returns the + * number of points affected. + */ int PfmFile:: pull_spot(const LPoint4f &delta, float xc, float yc, float xr, float yr, float exponent) { @@ -1710,16 +1571,12 @@ pull_spot(const LPoint4f &delta, float xc, float yc, return count; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::calc_tight_bounds -// Access: Published -// Description: Calculates the minimum and maximum vertices of all -// points within the table. Assumes the table contains -// 3-D points. -// -// The return value is true if any points in the table, -// or false if none are. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the minimum and maximum vertices of all points within the table. + * Assumes the table contains 3-D points. + * + * The return value is true if any points in the table, or false if none are. + */ bool PfmFile:: calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point) const { min_point.set(0.0f, 0.0f, 0.0f); @@ -1751,25 +1608,20 @@ calc_tight_bounds(LPoint3f &min_point, LPoint3f &max_point) const { return found_any; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::compute_planar_bounds -// Access: Published -// Description: Computes the minmax bounding volume of the points in -// 3-D space, assuming the points represent a -// mostly-planar surface. -// -// This algorithm works by sampling the (square) -// sample_radius pixels at the four point_dist corners -// around the center (cx - pd, cx + pd) and so on, to -// approximate the plane of the surface. Then all of -// the points are projected into that plane and the -// bounding volume of the entire mesh within that plane -// is determined. If points_only is true, the bounding -// volume of only those four points is determined. -// -// center, point_dist and sample_radius are in UV space, -// i.e. in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Computes the minmax bounding volume of the points in 3-D space, assuming + * the points represent a mostly-planar surface. + * + * This algorithm works by sampling the (square) sample_radius pixels at the + * four point_dist corners around the center (cx - pd, cx + pd) and so on, to + * approximate the plane of the surface. Then all of the points are projected + * into that plane and the bounding volume of the entire mesh within that + * plane is determined. If points_only is true, the bounding volume of only + * those four points is determined. + * + * center, point_dist and sample_radius are in UV space, i.e. in the range + * 0..1. + */ PT(BoundingHexahedron) PfmFile:: compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 sample_radius, bool points_only) const { LPoint3f p0, p1, p2, p3; @@ -1801,8 +1653,8 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 LVector3f up = (p1 - p0) + (p2 - p3); LPoint3f pcenter = ((p0 + p1 + p2 + p3) * 0.25); - // Compute the transform necessary to rotate all of the points into - // the Y = 0 plane. + // Compute the transform necessary to rotate all of the points into the Y = + // 0 plane. LMatrix4f rotate; look_at(rotate, normal, up); @@ -1873,8 +1725,8 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 PT(BoundingHexahedron) bounds; - // We create a BoundingHexahedron with the points in a particular - // well-defined order, based on the current coordinate system. + // We create a BoundingHexahedron with the points in a particular well- + // defined order, based on the current coordinate system. CoordinateSystem cs = get_default_coordinate_system(); switch (cs) { case CS_yup_right: @@ -1913,23 +1765,18 @@ compute_planar_bounds(const LPoint2f ¢er, PN_float32 point_dist, PN_float32 nassertr(false, NULL); } - // Rotate the bounding volume back into the original space of the - // screen. + // Rotate the bounding volume back into the original space of the screen. bounds->xform(LCAST(PN_stdfloat, rotate)); return bounds; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::compute_sample_point -// Access: Published -// Description: Computes the average of all the point within -// sample_radius (manhattan distance) and the indicated -// point. -// -// The point coordinates are given in UV space, in the -// range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Computes the average of all the point within sample_radius (manhattan + * distance) and the indicated point. + * + * The point coordinates are given in UV space, in the range 0..1. + */ void PfmFile:: compute_sample_point(LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 sample_radius) const { @@ -1972,17 +1819,13 @@ compute_sample_point(LPoint3f &result, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::copy_sub_image -// Access: Published -// Description: Copies a rectangular area of another image into a -// rectangular area of this image. Both images must -// already have been initialized. The upper-left corner -// of the region in both images is specified, and the -// size of the area; if the size is omitted, it defaults -// to the entire other image, or the largest piece that -// will fit. -//////////////////////////////////////////////////////////////////// +/** + * Copies a rectangular area of another image into a rectangular area of this + * image. Both images must already have been initialized. The upper-left + * corner of the region in both images is specified, and the size of the area; + * if the size is omitted, it defaults to the entire other image, or the + * largest piece that will fit. + */ void PfmFile:: copy_sub_image(const PfmFile ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) { @@ -2042,13 +1885,10 @@ copy_sub_image(const PfmFile ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::add_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the copy pixels -// are added to the pixels of the destination, after -// scaling by the specified pixel_scale. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the copy pixels are added to the + * pixels of the destination, after scaling by the specified pixel_scale. + */ void PfmFile:: add_sub_image(const PfmFile ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -2109,13 +1949,10 @@ add_sub_image(const PfmFile ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::mult_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the copy pixels -// are multiplied to the pixels of the destination, after -// scaling by the specified pixel_scale. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the copy pixels are multiplied to the + * pixels of the destination, after scaling by the specified pixel_scale. + */ void PfmFile:: mult_sub_image(const PfmFile ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -2176,14 +2013,11 @@ mult_sub_image(const PfmFile ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::divide_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the copy pixels -// are divided into the pixels of the destination, after -// scaling by the specified pixel_scale. -// dest(x, y) = dest(x, y) / (copy(x, y) * pixel_scale). -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the copy pixels are divided into the + * pixels of the destination, after scaling by the specified pixel_scale. + * dest(x, y) = dest(x, y) / (copy(x, y) * pixel_scale). + */ void PfmFile:: divide_sub_image(const PfmFile ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -2260,12 +2094,10 @@ divide_sub_image(const PfmFile ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::operator *= -// Access: Published -// Description: Multiplies every point value in the image by -// a constant floating-point multiplier value. -//////////////////////////////////////////////////////////////////// +/** + * Multiplies every point value in the image by a constant floating-point + * multiplier value. + */ void PfmFile:: operator *= (float multiplier) { nassertv(is_valid()); @@ -2326,13 +2158,10 @@ operator *= (float multiplier) { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. + */ void PfmFile:: apply_exponent(float c0_exponent, float c1_exponent, float c2_exponent, float c3_exponent) { @@ -2389,26 +2218,20 @@ apply_exponent(float c0_exponent, float c1_exponent, float c2_exponent, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: output(ostream &out) const { out << "floating-point image: " << _x_size << " by " << _y_size << " pixels, " << _num_channels << " channels."; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_region -// Access: Private -// Description: Averages all the points in the rectangle from x0 -// .. y0 to x1 .. y1 into result. The region may be -// defined by floating-point boundaries; the result will -// be weighted by the degree of coverage of each -// included point. -//////////////////////////////////////////////////////////////////// +/** + * Averages all the points in the rectangle from x0 .. y0 to x1 .. y1 into + * result. The region may be defined by floating-point boundaries; the result + * will be weighted by the degree of coverage of each included point. + */ void PfmFile:: box_filter_region(PN_float32 &result, PN_float32 x0, PN_float32 y0, PN_float32 x1, PN_float32 y1) const { @@ -2445,15 +2268,11 @@ box_filter_region(PN_float32 &result, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_region -// Access: Private -// Description: Averages all the points in the rectangle from x0 -// .. y0 to x1 .. y1 into result. The region may be -// defined by floating-point boundaries; the result will -// be weighted by the degree of coverage of each -// included point. -//////////////////////////////////////////////////////////////////// +/** + * Averages all the points in the rectangle from x0 .. y0 to x1 .. y1 into + * result. The region may be defined by floating-point boundaries; the result + * will be weighted by the degree of coverage of each included point. + */ void PfmFile:: box_filter_region(LPoint2f &result, PN_float32 x0, PN_float32 y0, PN_float32 x1, PN_float32 y1) const { @@ -2490,15 +2309,11 @@ box_filter_region(LPoint2f &result, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_region -// Access: Private -// Description: Averages all the points in the rectangle from x0 -// .. y0 to x1 .. y1 into result. The region may be -// defined by floating-point boundaries; the result will -// be weighted by the degree of coverage of each -// included point. -//////////////////////////////////////////////////////////////////// +/** + * Averages all the points in the rectangle from x0 .. y0 to x1 .. y1 into + * result. The region may be defined by floating-point boundaries; the result + * will be weighted by the degree of coverage of each included point. + */ void PfmFile:: box_filter_region(LPoint3f &result, PN_float32 x0, PN_float32 y0, PN_float32 x1, PN_float32 y1) const { @@ -2535,15 +2350,11 @@ box_filter_region(LPoint3f &result, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_region -// Access: Private -// Description: Averages all the points in the rectangle from x0 -// .. y0 to x1 .. y1 into result. The region may be -// defined by floating-point boundaries; the result will -// be weighted by the degree of coverage of each -// included point. -//////////////////////////////////////////////////////////////////// +/** + * Averages all the points in the rectangle from x0 .. y0 to x1 .. y1 into + * result. The region may be defined by floating-point boundaries; the result + * will be weighted by the degree of coverage of each included point. + */ void PfmFile:: box_filter_region(LPoint4f &result, PN_float32 x0, PN_float32 y0, PN_float32 x1, PN_float32 y1) const { @@ -2580,11 +2391,9 @@ box_filter_region(LPoint4f &result, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_line -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_line(PN_float32 &result, PN_float32 &coverage, PN_float32 x0, int y, PN_float32 x1, PN_float32 y_contrib) const { @@ -2609,11 +2418,9 @@ box_filter_line(PN_float32 &result, PN_float32 &coverage, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_line -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_line(LPoint2f &result, PN_float32 &coverage, PN_float32 x0, int y, PN_float32 x1, PN_float32 y_contrib) const { @@ -2638,11 +2445,9 @@ box_filter_line(LPoint2f &result, PN_float32 &coverage, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_line -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_line(LPoint3f &result, PN_float32 &coverage, PN_float32 x0, int y, PN_float32 x1, PN_float32 y_contrib) const { @@ -2667,11 +2472,9 @@ box_filter_line(LPoint3f &result, PN_float32 &coverage, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_line -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_line(LPoint4f &result, PN_float32 &coverage, PN_float32 x0, int y, PN_float32 x1, PN_float32 y_contrib) const { @@ -2696,11 +2499,9 @@ box_filter_line(LPoint4f &result, PN_float32 &coverage, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_point -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_point(PN_float32 &result, PN_float32 &coverage, int x, int y, PN_float32 x_contrib, PN_float32 y_contrib) const { @@ -2714,11 +2515,9 @@ box_filter_point(PN_float32 &result, PN_float32 &coverage, coverage += contrib; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_point -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_point(LPoint2f &result, PN_float32 &coverage, int x, int y, PN_float32 x_contrib, PN_float32 y_contrib) const { @@ -2732,11 +2531,9 @@ box_filter_point(LPoint2f &result, PN_float32 &coverage, coverage += contrib; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_point -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_point(LPoint3f &result, PN_float32 &coverage, int x, int y, PN_float32 x_contrib, PN_float32 y_contrib) const { @@ -2750,11 +2547,9 @@ box_filter_point(LPoint3f &result, PN_float32 &coverage, coverage += contrib; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_point -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmFile:: box_filter_point(LPoint4f &result, PN_float32 &coverage, int x, int y, PN_float32 x_contrib, PN_float32 y_contrib) const { @@ -2768,13 +2563,10 @@ box_filter_point(LPoint4f &result, PN_float32 &coverage, coverage += contrib; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::fill_mini_grid -// Access: Private -// Description: A support function for calc_average_point(), this -// recursively fills in the holes in the mini_grid data -// with the index to the nearest value. -//////////////////////////////////////////////////////////////////// +/** + * A support function for calc_average_point(), this recursively fills in the + * holes in the mini_grid data with the index to the nearest value. + */ void PfmFile:: fill_mini_grid(MiniGridCell *mini_grid, int x_size, int y_size, int xi, int yi, int dist, int sxi, int syi) const { @@ -2796,12 +2588,9 @@ fill_mini_grid(MiniGridCell *mini_grid, int x_size, int y_size, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_noop -// Access: Private, Static -// Description: The implementation of has_point() for -// files without a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for files without a no_data_value. + */ bool PfmFile:: has_point_noop(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2811,12 +2600,10 @@ has_point_noop(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_1 -// Access: Private, Static -// Description: The implementation of has_point() for 1-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for 1-component files with a + * no_data_value. + */ bool PfmFile:: has_point_1(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2826,12 +2613,10 @@ has_point_1(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_2 -// Access: Private, Static -// Description: The implementation of has_point() for 2-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for 2-component files with a + * no_data_value. + */ bool PfmFile:: has_point_2(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2841,12 +2626,10 @@ has_point_2(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_3 -// Access: Private, Static -// Description: The implementation of has_point() for 3-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for 3-component files with a + * no_data_value. + */ bool PfmFile:: has_point_3(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2856,12 +2639,10 @@ has_point_3(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_4 -// Access: Private, Static -// Description: The implementation of has_point() for 4-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for 4-component files with a + * no_data_value. + */ bool PfmFile:: has_point_4(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2871,12 +2652,10 @@ has_point_4(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_threshold_1 -// Access: Private, Static -// Description: The implementation of has_point_threshold() for 1-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point_threshold() for 1-component files with a + * no_data_value. + */ bool PfmFile:: has_point_threshold_1(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2887,12 +2666,10 @@ has_point_threshold_1(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_threshold_2 -// Access: Private, Static -// Description: The implementation of has_point_threshold() for 2-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point_threshold() for 2-component files with a + * no_data_value. + */ bool PfmFile:: has_point_threshold_2(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2904,12 +2681,10 @@ has_point_threshold_2(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_threshold_3 -// Access: Private, Static -// Description: The implementation of has_point_threshold() for 3-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point_threshold() for 3-component files with a + * no_data_value. + */ bool PfmFile:: has_point_threshold_3(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2922,12 +2697,10 @@ has_point_threshold_3(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_threshold_4 -// Access: Private, Static -// Description: The implementation of has_point_threshold() for 4-component -// files with a no_data_value. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point_threshold() for 4-component files with a + * no_data_value. + */ bool PfmFile:: has_point_threshold_4(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2941,13 +2714,11 @@ has_point_threshold_4(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_chan4 -// Access: Private, Static -// Description: The implementation of has_point() for 4-component -// files with set_no_data_chan4() in effect. This means -// that the data is valid iff the fourth channel >= 0. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for 4-component files with + * set_no_data_chan4() in effect. This means that the data is valid iff the + * fourth channel >= 0. + */ bool PfmFile:: has_point_chan4(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2957,13 +2728,10 @@ has_point_chan4(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_nan_1 -// Access: Private, Static -// Description: The implementation of has_point() for -// files with set_no_data_nan() in effect. This means -// that the data is valid iff no components involve NaN. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for files with set_no_data_nan() in + * effect. This means that the data is valid iff no components involve NaN. + */ bool PfmFile:: has_point_nan_1(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2973,13 +2741,10 @@ has_point_nan_1(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_nan_2 -// Access: Private, Static -// Description: The implementation of has_point() for -// files with set_no_data_nan() in effect. This means -// that the data is valid iff no components involve NaN. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for files with set_no_data_nan() in + * effect. This means that the data is valid iff no components involve NaN. + */ bool PfmFile:: has_point_nan_2(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -2989,13 +2754,10 @@ has_point_nan_2(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_nan_3 -// Access: Private, Static -// Description: The implementation of has_point() for -// files with set_no_data_nan() in effect. This means -// that the data is valid iff no components involve NaN. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for files with set_no_data_nan() in + * effect. This means that the data is valid iff no components involve NaN. + */ bool PfmFile:: has_point_nan_3(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && @@ -3005,13 +2767,10 @@ has_point_nan_3(const PfmFile *self, int x, int y) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::has_point_nan_4 -// Access: Private, Static -// Description: The implementation of has_point() for -// files with set_no_data_nan() in effect. This means -// that the data is valid iff no components involve NaN. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of has_point() for files with set_no_data_nan() in + * effect. This means that the data is valid iff no components involve NaN. + */ bool PfmFile:: has_point_nan_4(const PfmFile *self, int x, int y) { if ((x >= 0 && x < self->_x_size) && diff --git a/panda/src/pnmimage/pfmFile.h b/panda/src/pnmimage/pfmFile.h index aae70cc0f0..ea99d011cb 100644 --- a/panda/src/pnmimage/pfmFile.h +++ b/panda/src/pnmimage/pfmFile.h @@ -1,16 +1,15 @@ -// Filename: pfmFile.h -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmFile.h + * @author drose + * @date 2010-12-23 + */ #ifndef PFMFILE_H #define PFMFILE_H @@ -25,12 +24,10 @@ class PNMImage; class PNMReader; class PNMWriter; -//////////////////////////////////////////////////////////////////// -// Class : PfmFile -// Description : Defines a pfm file, a 2-d table of floating-point -// numbers, either 3-component or 1-component, or with a -// special extension, 2- or 4-component. -//////////////////////////////////////////////////////////////////// +/** + * Defines a pfm file, a 2-d table of floating-point numbers, either + * 3-component or 1-component, or with a special extension, 2- or 4-component. + */ class EXPCL_PANDA_PNMIMAGE PfmFile : public PNMImageHeader { PUBLISHED: PfmFile(); diff --git a/panda/src/pnmimage/pfmFile_ext.cxx b/panda/src/pnmimage/pfmFile_ext.cxx index 790e38de8e..a6306cbbf4 100644 --- a/panda/src/pnmimage/pfmFile_ext.cxx +++ b/panda/src/pnmimage/pfmFile_ext.cxx @@ -1,16 +1,15 @@ -// Filename: pfmFile_ext.cxx -// Created by: rdb (26Feb14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmFile_ext.cxx + * @author rdb + * @date 2014-02-26 + */ #include "pfmFile_ext.h" @@ -22,11 +21,9 @@ extern struct Dtool_PyTypedObject Dtool_LPoint3f; extern struct Dtool_PyTypedObject Dtool_LPoint4f; #endif -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::get_points -// Access: Published -// Description: Returns a list of all of the points. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of all of the points. + */ PyObject *Extension:: get_points() const { int num_points = _this->get_x_size() * _this->get_y_size(); @@ -74,14 +71,11 @@ get_points() const { } #if PY_VERSION_HEX >= 0x02060000 -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::__getbuffer__ -// Access: Published -// Description: This is a very low-level function that returns a -// read-only multiview into the internal table of -// floating-point numbers. Use this method at your own -// risk. -//////////////////////////////////////////////////////////////////// +/** + * This is a very low-level function that returns a read-only multiview into + * the internal table of floating-point numbers. Use this method at your own + * risk. + */ int Extension:: __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { @@ -91,12 +85,11 @@ __getbuffer__(PyObject *self, Py_buffer *view, int flags) const { return -1; } - // Since we have absolutely no guarantees about the lifetime - // of this object or the continued validity of the data pointer, - // we should arguably make a copy of the data. However, since - // the whole point of this method is to provide fast access to - // the underlying data, perhaps we can trust the user to handle - // the copy operation himself if he needs to. + // Since we have absolutely no guarantees about the lifetime of this object + // or the continued validity of the data pointer, we should arguably make a + // copy of the data. However, since the whole point of this method is to + // provide fast access to the underlying data, perhaps we can trust the user + // to handle the copy operation himself if he needs to. const vector_float &table = _this->get_table(); int channels = _this->get_num_channels(); int num_pixels = _this->get_x_size() * _this->get_y_size(); diff --git a/panda/src/pnmimage/pfmFile_ext.h b/panda/src/pnmimage/pfmFile_ext.h index 2018d8e394..cf8d4b20aa 100644 --- a/panda/src/pnmimage/pfmFile_ext.h +++ b/panda/src/pnmimage/pfmFile_ext.h @@ -1,16 +1,15 @@ -// Filename: pfmFile_ext.h -// Created by: rdb (26Feb14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmFile_ext.h + * @author rdb + * @date 2014-02-26 + */ #ifndef PFMFILE_EXT_H #define PFMFILE_EXT_H @@ -23,12 +22,10 @@ #include "pfmFile.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// PfmFile, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for PfmFile, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/pnmimage/pnm-image-filter-core.cxx b/panda/src/pnmimage/pnm-image-filter-core.cxx index af918a8c2c..8907068b50 100644 --- a/panda/src/pnmimage/pnm-image-filter-core.cxx +++ b/panda/src/pnmimage/pnm-image-filter-core.cxx @@ -1,20 +1,17 @@ -// Filename: pnm-image-filter-core.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnm-image-filter-core.cxx + */ -// We map X and Y to A and B, because we might change our minds about which -// is dominant, and we map get/set functions for the channel in question to -// GETVAL/SETVAL. +// We map X and Y to A and B, because we might change our minds about which is +// dominant, and we map getset functions for the channel in question to +// GETVALSETVAL. static void @@ -96,4 +93,3 @@ FUNCTION_NAME(IMAGETYPE &dest, const IMAGETYPE &source, } PANDA_FREE_ARRAY(matrix); } - diff --git a/panda/src/pnmimage/pnm-image-filter-sparse-core.cxx b/panda/src/pnmimage/pnm-image-filter-sparse-core.cxx index 70e1514c07..0709c25cd3 100644 --- a/panda/src/pnmimage/pnm-image-filter-sparse-core.cxx +++ b/panda/src/pnmimage/pnm-image-filter-sparse-core.cxx @@ -1,20 +1,19 @@ -// Filename: pnm-image-filter-sparse-core.cxx -// Created by: drose (25Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnm-image-filter-sparse-core.cxx + * @author drose + * @date 2013-01-25 + */ -// We map X and Y to A and B, because we might change our minds about which -// is dominant, and we map get/set functions for the channel in question to -// GETVAL/SETVAL. +// We map X and Y to A and B, because we might change our minds about which is +// dominant, and we map getset functions for the channel in question to +// GETVALSETVAL. static void @@ -67,14 +66,14 @@ FUNCTION_NAME(IMAGETYPE &dest, const IMAGETYPE &source, temp_source, temp_source_weight, source.ASIZE(), scale, filter, filter_width); - + for (a = 0; a < dest.ASIZE(); a++) { matrix[a][b] = temp_dest[a]; matrix_weight[a][b] = temp_dest_weight[a]; } } - PANDA_FREE_ARRAY(temp_source); + PANDA_FREE_ARRAY(temp_source); PANDA_FREE_ARRAY(temp_source_weight); PANDA_FREE_ARRAY(temp_dest); PANDA_FREE_ARRAY(temp_dest_weight); @@ -113,4 +112,3 @@ FUNCTION_NAME(IMAGETYPE &dest, const IMAGETYPE &source, PANDA_FREE_ARRAY(matrix); PANDA_FREE_ARRAY(matrix_weight); } - diff --git a/panda/src/pnmimage/pnm-image-filter.cxx b/panda/src/pnmimage/pnm-image-filter.cxx index 0e304e33f8..ac57b20b23 100644 --- a/panda/src/pnmimage/pnm-image-filter.cxx +++ b/panda/src/pnmimage/pnm-image-filter.cxx @@ -1,16 +1,13 @@ -// Filename: pnm-image-filter.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnm-image-filter.cxx + */ // The functions in this module support spatial filtering of an image by // convolution with an (almost) arbitrary kernel. There are a broad class of @@ -28,9 +25,9 @@ // decreases the complexity of the convolution operation: it is faster to // convolve twice with a one-dimensional kernel than once with a two- // dimensional kernel. In the interim, a temporary matrix of type StoreType -// (a numeric type, described below) is built which contains the results -// from the first convolution. The entire process is then repeated for -// each channel in the image. +// (a numeric type, described below) is built which contains the results from +// the first convolution. The entire process is then repeated for each +// channel in the image. #include "pandabase.h" #include @@ -42,8 +39,8 @@ // WorkType is an abstraction that allows the filtering process to be // recompiled to use either floating-point or integer arithmetic. On SGI -// machines, there doesn't seem to be much of a performance difference-- -// if anything, the integer arithmetic is slower--though certainly other +// machines, there doesn't seem to be much of a performance difference-- if +// anything, the integer arithmetic is slower--though certainly other // architectures may differ. // A StoreType is a numeric type that is used to store the intermediate values @@ -53,18 +50,19 @@ // multiplied by it as a weighted filter (source_max * filter_max must fit // comfortably within a WorkType, with room to spare). -// Floating-point arithmetic is slightly faster and slightly more precise, -// but the main reason to use it is that it is conceptually easy to understand. +// Floating-point arithmetic is slightly faster and slightly more precise, but +// the main reason to use it is that it is conceptually easy to understand. // All values are scaled in the range 0..1, as they should be. // The biggest reason to use integer arithmetic is space. A table of // StoreTypes must be allocated to match the size of the image. On an SGI, // sizeof(float) is 4, while sizeof(short) is 2 and sizeof(char) is, of -// course, 1. Since the source precision is probably 8 bits anyway (there -// are usually 8 bits per channel), it doesn't cost any precision at all to -// use shorts, and not very much to use chars. +// course, 1. Since the source precision is probably 8 bits anyway (there are +// usually 8 bits per channel), it doesn't cost any precision at all to use +// shorts, and not very much to use chars. -// To use double-precision floating point, 8 bytes: (strictly for the neurotic) +// To use double-precision floating point, 8 bytes: (strictly for the +// neurotic) /* typedef double WorkType; typedef double StoreType; @@ -96,9 +94,9 @@ static const WorkType filter_max = 255; // filter_row() filters a single row by convolving with a one-dimensional // kernel filter. The kernel is defined by an array of weights in filter[], -// where the ith element of filter corresponds to abs(d * scale), if scale>1.0, -// and abs(d), if scale<=1.0, where d is the offset from the center and varies -// from -filter_width to filter_width. +// where the ith element of filter corresponds to abs(d * scale), if +// scale>1.0, and abs(d), if scale<=1.0, where d is the offset from the center +// and varies from -filter_width to filter_width. // Note that filter_width is not necessarily the length of the array; it is // the radius of interest of the filter function. The array may need to be @@ -111,9 +109,9 @@ filter_row(StoreType dest[], int dest_len, const WorkType filter[], float filter_width) { // If we are expanding the row (scale > 1.0), we need to look at a - // fractional granularity. Hence, we scale our filter index by - // scale. If we are compressing (scale < 1.0), we don't need to - // fiddle with the filter index, so we leave it at one. + // fractional granularity. Hence, we scale our filter index by scale. If + // we are compressing (scale < 1.0), we don't need to fiddle with the filter + // index, so we leave it at one. float iscale; if (scale < 1.0f) { @@ -133,8 +131,8 @@ filter_row(StoreType dest[], int dest_len, int left = max((int)cfloor(center - filter_width), 0); int right = min((int)cceil(center + filter_width), source_len - 1); - // right_center is the point just to the right of the center. This - // allows us to flip the sign of the offset when we cross the center point. + // right_center is the point just to the right of the center. This allows + // us to flip the sign of the offset when we cross the center point. int right_center = (int)cceil(center); WorkType net_weight = 0; @@ -166,8 +164,8 @@ filter_row(StoreType dest[], int dest_len, Thread::consider_yield(); } -// As above, but we also accept an array of weight values per -// element, to support scaling a sparse array (as in a PfmFile). +// As above, but we also accept an array of weight values per element, to +// support scaling a sparse array (as in a PfmFile). static void filter_sparse_row(StoreType dest[], StoreType dest_weight[], int dest_len, const StoreType source[], const StoreType source_weight[], int source_len, @@ -175,9 +173,9 @@ filter_sparse_row(StoreType dest[], StoreType dest_weight[], int dest_len, const WorkType filter[], float filter_width) { // If we are expanding the row (scale > 1.0), we need to look at a - // fractional granularity. Hence, we scale our filter index by - // scale. If we are compressing (scale < 1.0), we don't need to - // fiddle with the filter index, so we leave it at one. + // fractional granularity. Hence, we scale our filter index by scale. If + // we are compressing (scale < 1.0), we don't need to fiddle with the filter + // index, so we leave it at one. float iscale; if (scale < 1.0) { @@ -197,8 +195,8 @@ filter_sparse_row(StoreType dest[], StoreType dest_weight[], int dest_len, int left = max((int)cfloor(center - filter_width), 0); int right = min((int)cceil(center + filter_width), source_len - 1); - // right_center is the point just to the right of the center. This - // allows us to flip the sign of the offset when we cross the center point. + // right_center is the point just to the right of the center. This allows + // us to flip the sign of the offset when we cross the center point. int right_center = (int)cceil(center); WorkType net_weight = 0; @@ -234,9 +232,9 @@ filter_sparse_row(StoreType dest[], StoreType dest_weight[], int dest_len, // The various filter functions are called before each axis scaling to build // an kernel array suitable for the given scaling factor. Given a scaling -// ratio of the axis (dest_len / source_len), and a width parameter supplied -// by the user, they must build an array of filter values (described above) -// and also set the radius of interest of the filter function. +// ratio of the axis (dest_len source_len), and a width parameter supplied by +// the user, they must build an array of filter values (described above) and +// also set the radius of interest of the filter function. // The values of the elements of filter must completely cover the range // 0..filter_max; the array must have enough elements to include all indices @@ -250,15 +248,15 @@ box_filter_impl(float scale, float width, WorkType *&filter, float &filter_width) { float fscale; if (scale < 1.0) { - // If we are compressing the image, we want to expand the range of - // the filter function to prevent dropping below the Nyquist rate. - // Hence, we divide by scale. + // If we are compressing the image, we want to expand the range of the + // filter function to prevent dropping below the Nyquist rate. Hence, we + // divide by scale. fscale = 1.0 / scale; } else { - // If we are expanding the image, we want to increase the granularity - // of the filter function since we will need to access fractional cel - // values. Hence, we multiply by scale. + // If we are expanding the image, we want to increase the granularity of + // the filter function since we will need to access fractional cel values. + // Hence, we multiply by scale. fscale = scale; } filter_width = width; @@ -276,15 +274,15 @@ gaussian_filter_impl(float scale, float width, WorkType *&filter, float &filter_width) { float fscale; if (scale < 1.0) { - // If we are compressing the image, we want to expand the range of - // the filter function to prevent dropping below the Nyquist rate. - // Hence, we divide by scale (to make fscale larger). + // If we are compressing the image, we want to expand the range of the + // filter function to prevent dropping below the Nyquist rate. Hence, we + // divide by scale (to make fscale larger). fscale = 1.0 / scale; } else { - // If we are expanding the image, we want to increase the granularity - // of the filter function since we will need to access fractional cel - // values. Hence, we multiply by scale (to make fscale larger). + // If we are expanding the image, we want to increase the granularity of + // the filter function since we will need to access fractional cel values. + // Hence, we multiply by scale (to make fscale larger). fscale = scale; } @@ -292,11 +290,11 @@ gaussian_filter_impl(float scale, float width, filter_width = 3.0 * sigma; int actual_width = (int)cceil((filter_width + 1) * fscale); - // G(x, y) = (1/(2 pi sigma^2)) * exp( - (x^2 + y^2) / (2 sigma^2)) + // G(x, y) = (1(2 pi sigma^2)) * exp( - (x^2 + y^2) (2 sigma^2)) - // (We can throw away the initial factor, since these weights will all - // be normalized; and we're only computing a 1-dimensional function, - // so we can ignore the y^2.) + // (We can throw away the initial factor, since these weights will all be + // normalized; and we're only computing a 1-dimensional function, so we can + // ignore the y^2.) filter = (WorkType *)PANDA_MALLOC_ARRAY(actual_width * sizeof(WorkType)); float div = 2 * sigma * sigma; @@ -304,33 +302,33 @@ gaussian_filter_impl(float scale, float width, for (int i = 0; i < actual_width; i++) { float x = i / fscale; filter[i] = (WorkType)(filter_max * exp(-x*x / div)); - // The highest value of the exp function in this range is always 1.0, - // at index value 0. Thus, we scale the whole range by filter_max, - // to produce a filter in the range [0..filter_max]. + // The highest value of the exp function in this range is always 1.0, at + // index value 0. Thus, we scale the whole range by filter_max, to + // produce a filter in the range [0..filter_max]. } } // We have a function, defined in pnm-image-filter-core.cxx, that will scale -// an image in both X and Y directions for a particular channel, by setting -// up the temporary matrix appropriately and calling the above functions. +// an image in both X and Y directions for a particular channel, by setting up +// the temporary matrix appropriately and calling the above functions. // What we really need is a series of such functions, one for each channel, // and also one to scale by X first, and one to scale by Y first. This sounds // a lot like a C++ template: we want to compile the same function several // times to work on slightly different sorts of things each time. However, // the things we want to vary are the particular member functions of PNMImage -// that we call (e.g. Red(), Green(), etc.), and we can't declare a template +// that we call (e.g. Red(), Green(), etc.), and we can't declare a template // of member functions, only of types. -// It's doable using templates. It would involve the declaration of -// lots of silly little functor objects. This is much more compact -// and no more difficult to read. +// It's doable using templates. It would involve the declaration of lots of +// silly little functor objects. This is much more compact and no more +// difficult to read. // The function in pnm-image-filter-core.cxx uses macros to access the member -// functions of PNMImage. Hence, we only need to redefine those macros -// with each instance of the function to cause each instance to operate on -// the correct member. +// functions of PNMImage. Hence, we only need to redefine those macros with +// each instance of the function to cause each instance to operate on the +// correct member. // These instances scale by X first, then by Y. @@ -479,19 +477,19 @@ gaussian_filter_impl(float scale, float width, #undef FUNCTION_NAME -// filter_image pulls everything together, and filters one image into -// another. Both images can be the same with no ill effects. +// filter_image pulls everything together, and filters one image into another. +// Both images can be the same with no ill effects. static void filter_image(PNMImage &dest, const PNMImage &source, float width, FilterFunction *make_filter) { - // We want to scale by the smallest destination axis first, for a - // slight performance gain. + // We want to scale by the smallest destination axis first, for a slight + // performance gain. - // In the PNMImage case (unlike the PfmFile case), the channel - // parameter is not used. We *could* use it to avoid the - // replication of quite so many functions, but we replicate them - // anyway, for another tiny performance gain. + // In the PNMImage case (unlike the PfmFile case), the channel parameter is + // not used. We *could* use it to avoid the replication of quite so many + // functions, but we replicate them anyway, for another tiny performance + // gain. if (dest.get_x_size() <= dest.get_y_size()) { if (dest.is_grayscale() || source.is_grayscale()) { @@ -521,38 +519,31 @@ filter_image(PNMImage &dest, const PNMImage &source, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::box_filter_from -// Access: Public -// Description: Makes a resized copy of the indicated image into this -// one using the indicated filter. The image to be -// copied is squashed and stretched to match the -// dimensions of the current image, applying the -// appropriate filter to perform the stretching. -//////////////////////////////////////////////////////////////////// +/** + * Makes a resized copy of the indicated image into this one using the + * indicated filter. The image to be copied is squashed and stretched to + * match the dimensions of the current image, applying the appropriate filter + * to perform the stretching. + */ void PNMImage:: box_filter_from(float width, const PNMImage ©) { filter_image(*this, copy, width, &box_filter_impl); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::gaussian_filter_from -// Access: Public -// Description: Makes a resized copy of the indicated image into this -// one using the indicated filter. The image to be -// copied is squashed and stretched to match the -// dimensions of the current image, applying the -// appropriate filter to perform the stretching. -//////////////////////////////////////////////////////////////////// +/** + * Makes a resized copy of the indicated image into this one using the + * indicated filter. The image to be copied is squashed and stretched to + * match the dimensions of the current image, applying the appropriate filter + * to perform the stretching. + */ void PNMImage:: gaussian_filter_from(float width, const PNMImage ©) { filter_image(*this, copy, width, &gaussian_filter_impl); } -// Now we do it again, this time for PfmFile. In this case we also -// need to support the sparse variants, since PfmFiles can be -// incomplete. However, we don't need to have a different function -// for each channel. +// Now we do it again, this time for PfmFile. In this case we also need to +// support the sparse variants, since PfmFiles can be incomplete. However, we +// don't need to have a different function for each channel. #define FUNCTION_NAME filter_pfm_xy #define IMAGETYPE PfmFile @@ -616,8 +607,8 @@ gaussian_filter_from(float width, const PNMImage ©) { #undef FUNCTION_NAME -// filter_image pulls everything together, and filters one image into -// another. Both images can be the same with no ill effects. +// filter_image pulls everything together, and filters one image into another. +// Both images can be the same with no ill effects. static void filter_image(PfmFile &dest, const PfmFile &source, float width, FilterFunction *make_filter) { @@ -629,7 +620,7 @@ filter_image(PfmFile &dest, const PfmFile &source, for (int ci = 0; ci < num_channels; ++ci) { filter_pfm_sparse_xy(dest, source, width, make_filter, ci); } - + } else { for (int ci = 0; ci < num_channels; ++ci) { filter_pfm_sparse_yx(dest, source, width, make_filter, ci); @@ -641,7 +632,7 @@ filter_image(PfmFile &dest, const PfmFile &source, for (int ci = 0; ci < num_channels; ++ci) { filter_pfm_xy(dest, source, width, make_filter, ci); } - + } else { for (int ci = 0; ci < num_channels; ++ci) { filter_pfm_yx(dest, source, width, make_filter, ci); @@ -650,37 +641,29 @@ filter_image(PfmFile &dest, const PfmFile &source, } } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::box_filter_from -// Access: Public -// Description: Makes a resized copy of the indicated image into this -// one using the indicated filter. The image to be -// copied is squashed and stretched to match the -// dimensions of the current image, applying the -// appropriate filter to perform the stretching. -//////////////////////////////////////////////////////////////////// +/** + * Makes a resized copy of the indicated image into this one using the + * indicated filter. The image to be copied is squashed and stretched to + * match the dimensions of the current image, applying the appropriate filter + * to perform the stretching. + */ void PfmFile:: box_filter_from(float width, const PfmFile ©) { filter_image(*this, copy, width, &box_filter_impl); } -//////////////////////////////////////////////////////////////////// -// Function: PfmFile::gaussian_filter_from -// Access: Public -// Description: Makes a resized copy of the indicated image into this -// one using the indicated filter. The image to be -// copied is squashed and stretched to match the -// dimensions of the current image, applying the -// appropriate filter to perform the stretching. -//////////////////////////////////////////////////////////////////// +/** + * Makes a resized copy of the indicated image into this one using the + * indicated filter. The image to be copied is squashed and stretched to + * match the dimensions of the current image, applying the appropriate filter + * to perform the stretching. + */ void PfmFile:: gaussian_filter_from(float width, const PfmFile ©) { filter_image(*this, copy, width, &gaussian_filter_impl); } -// // The following functions are support for quick_box_filter(). -// static INLINE void box_filter_xel(const PNMImage &img, @@ -751,23 +734,19 @@ box_filter_region(const PNMImage &image, } } - //cerr << pixel_count << "\n"; + // cerr << pixel_count << "\n"; color /= pixel_count; return color; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::quick_filter_from -// Access: Public -// Description: Resizes from the given image, with a fixed radius of -// 0.5. This is a very specialized and simple algorithm -// that doesn't handle dropping below the Nyquist rate -// very well, but is quite a bit faster than the more -// general box_filter(), above. If borders are -// specified, they will further restrict the size of the -// resulting image. There's no point in using -// quick_box_filter() on a single image. -//////////////////////////////////////////////////////////////////// +/** + * Resizes from the given image, with a fixed radius of 0.5. This is a very + * specialized and simple algorithm that doesn't handle dropping below the + * Nyquist rate very well, but is quite a bit faster than the more general + * box_filter(), above. If borders are specified, they will further restrict + * the size of the resulting image. There's no point in using + * quick_box_filter() on a single image. + */ void PNMImage:: quick_filter_from(const PNMImage &from, int xborder, int yborder) { int from_xs = from.get_x_size(); @@ -799,8 +778,8 @@ quick_filter_from(const PNMImage &from, int xborder, int yborder) { to_x++) { from_x1 = (to_x+1) * x_scale; - // Now the box from (from_x0, from_y0) - (from_x1, from_y1) - // but not including (from_x1, from_y1) maps to the pixel (to_x, to_y). + // Now the box from (from_x0, from_y0) - (from_x1, from_y1) but not + // including (from_x1, from_y1) maps to the pixel (to_x, to_y). color = box_filter_region(from, from_x0, from_y0, from_x1, from_y1); diff --git a/panda/src/pnmimage/pnmBrush.I b/panda/src/pnmimage/pnmBrush.I index 0bc457d58e..bbaf511ae7 100644 --- a/panda/src/pnmimage/pnmBrush.I +++ b/panda/src/pnmimage/pnmBrush.I @@ -1,50 +1,40 @@ -// Filename: pnmBrush.I -// Created by: drose (01Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmBrush.I + * @author drose + * @date 2007-02-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMBrush:: PNMBrush(float xc, float yc) : _xc(xc), _yc(yc) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::get_xc -// Access: Protected -// Description: Returns the coordinates of the brush's center -// pixel. For a one-pixel brush, this will be (0.5, -// 0.5); for a centered two-pixel brush, this will be -// (1.0, 1.0); for a centered three-pixel brush, this -// will be (1.5, 1.5); and so on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinates of the brush's center pixel. For a one-pixel + * brush, this will be (0.5, 0.5); for a centered two-pixel brush, this will + * be (1.0, 1.0); for a centered three-pixel brush, this will be (1.5, 1.5); + * and so on. + */ INLINE float PNMBrush:: get_xc() const { return _xc; } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::get_xc -// Access: Protected -// Description: Returns the coordinates of the brush's center -// pixel. For a one-pixel brush, this will be (0.5, -// 0.5); for a centered two-pixel brush, this will be -// (1.0, 1.0); for a centered three-pixel brush, this -// will be (1.5, 1.5); and so on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinates of the brush's center pixel. For a one-pixel + * brush, this will be (0.5, 0.5); for a centered two-pixel brush, this will + * be (1.0, 1.0); for a centered three-pixel brush, this will be (1.5, 1.5); + * and so on. + */ INLINE float PNMBrush:: get_yc() const { return _yc; diff --git a/panda/src/pnmimage/pnmBrush.cxx b/panda/src/pnmimage/pnmBrush.cxx index cc9d41aeae..64dffab3cb 100644 --- a/panda/src/pnmimage/pnmBrush.cxx +++ b/panda/src/pnmimage/pnmBrush.cxx @@ -1,16 +1,15 @@ -// Filename: pnmBrush.cxx -// Created by: drose (01Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmBrush.cxx + * @author drose + * @date 2007-02-01 + */ #include "pnmBrush.h" #include "pnmImage.h" @@ -70,7 +69,7 @@ public: PNMBlendPixelBrush(const LColorf &color) : PNMPixelBrush(color) { } virtual void draw(PNMImage &image, int x, int y, float pixel_scale) { - if (x >= 0 && x < image.get_x_size() && + if (x >= 0 && x < image.get_x_size() && y >= 0 && y < image.get_y_size()) { image.blend(x, y, _color[0], _color[1], _color[2], _color[3] * pixel_scale); } @@ -242,34 +241,26 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMBrush:: ~PNMBrush() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::make_transparent -// Access: Published, Static -// Description: Returns a new brush that does not paint anything. -// Can be used as either a pen or a fill brush to make -// borderless or unfilled shapes, respectively. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new brush that does not paint anything. Can be used as either a + * pen or a fill brush to make borderless or unfilled shapes, respectively. + */ PT(PNMBrush) PNMBrush:: make_transparent() { return new PNMTransparentBrush(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::make_pixel -// Access: Published, Static -// Description: Returns a new brush that paints a single pixel of the -// indicated color on a border, or paints a solid color -// in an interior. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new brush that paints a single pixel of the indicated color on a + * border, or paints a solid color in an interior. + */ PT(PNMBrush) PNMBrush:: make_pixel(const LColorf &color, PNMBrush::BrushEffect effect) { switch (effect) { @@ -291,13 +282,10 @@ make_pixel(const LColorf &color, PNMBrush::BrushEffect effect) { return new PNMSetPixelBrush(color); } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::make_spot -// Access: Published, Static -// Description: Returns a new brush that paints a spot of the -// indicated color and radius. If fuzzy is true, the -// spot is fuzzy; otherwise, it is hard-edged. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new brush that paints a spot of the indicated color and radius. + * If fuzzy is true, the spot is fuzzy; otherwise, it is hard-edged. + */ PT(PNMBrush) PNMBrush:: make_spot(const LColorf &color, float radius, bool fuzzy, BrushEffect effect) { @@ -338,17 +326,13 @@ make_spot(const LColorf &color, float radius, bool fuzzy, return make_image(spot, half_size, half_size, effect); } -//////////////////////////////////////////////////////////////////// -// Function: PNMBrush::make_image -// Access: Published, Static -// Description: Returns a new brush that paints with the indicated -// image. xc and yc indicate the pixel in the center of -// the brush. -// -// The brush makes a copy of the image; it is safe to -// deallocate or modify the image after making this -// call. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new brush that paints with the indicated image. xc and yc + * indicate the pixel in the center of the brush. + * + * The brush makes a copy of the image; it is safe to deallocate or modify the + * image after making this call. + */ PT(PNMBrush) PNMBrush:: make_image(const PNMImage &image, float xc, float yc, PNMBrush::BrushEffect effect) { diff --git a/panda/src/pnmimage/pnmBrush.h b/panda/src/pnmimage/pnmBrush.h index 82f816e190..febf48f6cc 100644 --- a/panda/src/pnmimage/pnmBrush.h +++ b/panda/src/pnmimage/pnmBrush.h @@ -1,16 +1,15 @@ -// Filename: pnmBrush.h -// Created by: drose (01Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmBrush.h + * @author drose + * @date 2007-02-01 + */ #ifndef PNMBRUSH_H #define PNMBRUSH_H @@ -22,22 +21,18 @@ class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : PNMBrush -// Description : This class is used to control the shape and color of -// the drawing operations performed by a PNMPainter -// object. -// -// Normally, you don't create a PNMBrush directly; -// instead, use one of the static PNMBrush::make_*() -// methods provided here. -// -// A PNMBrush is used to draw the border of a polygon or -// rectangle, as well as for filling its interior. When -// it is used to draw a border, the brush is "smeared" -// over the border; when it is used to fill the -// interior, it is tiled through the interior. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to control the shape and color of the drawing operations + * performed by a PNMPainter object. + * + * Normally, you don't create a PNMBrush directly; instead, use one of the + * static PNMBrush::make_*() methods provided here. + * + * A PNMBrush is used to draw the border of a polygon or rectangle, as well as + * for filling its interior. When it is used to draw a border, the brush is + * "smeared" over the border; when it is used to fill the interior, it is + * tiled through the interior. + */ class EXPCL_PANDA_PNMIMAGE PNMBrush : public ReferenceCount { protected: INLINE PNMBrush(float xc, float yc); diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 80c9b4bb9c..762d86fee4 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileType.cxx -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileType.cxx + * @author drose + * @date 2000-06-15 + */ #include "pnmFileType.h" @@ -22,55 +21,43 @@ bool PNMFileType::_did_init_pnm = false; TypeHandle PNMFileType::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileType:: PNMFileType() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileType:: ~PNMFileType() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::get_num_extensions -// Access: Published, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileType:: get_num_extensions() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::get_extension -// Access: Published, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileType:: get_extension(int) const { nassertr(false, string()); return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::get_suggested_extension -// Access: Published, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileType:: get_suggested_extension() const { if (get_num_extensions() > 0) { @@ -79,62 +66,51 @@ get_suggested_extension() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileType:: has_magic_number() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileType:: matches_magic_number(const string &) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileType:: make_reader(istream *, bool, const string &) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileType:: make_writer(ostream *, bool) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::init_pnm -// Access: Protected, Static -// Description: Initializes the underlying PNM library, if it has not -// already been initialized. This should be called by -// every implementation of make_reader() and -// make_writer(), to ensure that the library is properly -// initialized before any I/O is attempted. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the underlying PNM library, if it has not already been + * initialized. This should be called by every implementation of + * make_reader() and make_writer(), to ensure that the library is properly + * initialized before any I/O is attempted. + */ void PNMFileType:: init_pnm() { if (!_did_init_pnm) { @@ -144,17 +120,13 @@ init_pnm() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileType::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -// -// None of the particular PNMFileType objects store any -// extra data--at least, not yet--so we just define this -// up here to do nothing. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + * + * None of the particular PNMFileType objects store any extra data--at least, + * not yet--so we just define this up here to do nothing. + */ void PNMFileType:: write_datagram(BamWriter *, Datagram &) { } diff --git a/panda/src/pnmimage/pnmFileType.h b/panda/src/pnmimage/pnmFileType.h index 19f583b6b6..d6433ef304 100644 --- a/panda/src/pnmimage/pnmFileType.h +++ b/panda/src/pnmimage/pnmFileType.h @@ -1,16 +1,15 @@ -// Filename: pnmFileType.h -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileType.h + * @author drose + * @date 2000-06-15 + */ #ifndef PNMFILETYPE_H #define PNMFILETYPE_H @@ -26,12 +25,10 @@ class PNMReader; class PNMWriter; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : PNMFileType -// Description : This is the base class of a family of classes that -// represent particular image file types that PNMImage -// supports. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class of a family of classes that represent particular + * image file types that PNMImage supports. + */ class EXPCL_PANDA_PNMIMAGE PNMFileType : public TypedWritable { protected: PNMFileType(); @@ -89,4 +86,3 @@ private: }; #endif - diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.cxx b/panda/src/pnmimage/pnmFileTypeRegistry.cxx index b967714d68..f3cf8c5291 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.cxx +++ b/panda/src/pnmimage/pnmFileTypeRegistry.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeRegistry.cxx -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeRegistry.cxx + * @author drose + * @date 2000-06-15 + */ #include "pnmFileTypeRegistry.h" #include "pnmFileType.h" @@ -24,30 +23,24 @@ PNMFileTypeRegistry *PNMFileTypeRegistry::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeRegistry:: PNMFileTypeRegistry() { _requires_sort = false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeRegistry:: ~PNMFileTypeRegistry() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::register_type -// Access: Public -// Description: Defines a new PNMFileType in the universe. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new PNMFileType in the universe. + */ void PNMFileTypeRegistry:: register_type(PNMFileType *type) { if (pnmimage_cat->is_debug()) { @@ -89,11 +82,9 @@ register_type(PNMFileType *type) { _requires_sort = true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_num_types -// Access: Published -// Description: Returns the total number of types registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of types registered. + */ int PNMFileTypeRegistry:: get_num_types() const { if (_requires_sort) { @@ -102,34 +93,29 @@ get_num_types() const { return _types.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_type -// Access: Published -// Description: Returns the nth type registered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth type registered. + */ PNMFileType *PNMFileTypeRegistry:: get_type(int n) const { nassertr(n >= 0 && n < (int)_types.size(), NULL); return _types[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_type_from_extension -// Access: Published -// Description: Tries to determine what the PNMFileType is likely to -// be for a particular image file based on its -// extension. Returns a suitable PNMFileType pointer, -// or NULL if no type can be determined. -//////////////////////////////////////////////////////////////////// +/** + * Tries to determine what the PNMFileType is likely to be for a particular + * image file based on its extension. Returns a suitable PNMFileType pointer, + * or NULL if no type can be determined. + */ PNMFileType *PNMFileTypeRegistry:: get_type_from_extension(const string &filename) const { if (_requires_sort) { ((PNMFileTypeRegistry *)this)->sort_preferences(); } - // Extract the extension from the filename; if there is no dot, use - // the whole filename as the extension. This allows us to pass in - // just a dotless extension name in lieu of a filename. + // Extract the extension from the filename; if there is no dot, use the + // whole filename as the extension. This allows us to pass in just a + // dotless extension name in lieu of a filename. string extension; size_t dot = filename.rfind('.'); @@ -142,9 +128,8 @@ get_type_from_extension(const string &filename) const { #ifdef HAVE_ZLIB if (extension == "pz") { - // If the extension is .pz, then we've got a Panda-compressed - // image file. Back up some more and get the extension before - // that. + // If the extension is .pz, then we've got a Panda-compressed image file. + // Back up some more and get the extension before that. size_t prev_dot = filename.rfind('.', dot - 1); if (prev_dot == string::npos) { extension = filename.substr(0, dot); @@ -155,18 +140,18 @@ get_type_from_extension(const string &filename) const { #endif // HAVE_ZLIB if (extension.find('/') != string::npos) { - // If we picked the whole filename and it contains slashes, or if - // the rightmost dot wasn't in the basename of the filename, then - // it's actually a filename without an extension. + // If we picked the whole filename and it contains slashes, or if the + // rightmost dot wasn't in the basename of the filename, then it's + // actually a filename without an extension. extension = ""; } Extensions::const_iterator ei; ei = _extensions.find(extension); if (ei == _extensions.end() || (*ei).second.empty()) { - // Nothing matches that string. Try again with a downcased string - // in case we got an all-uppercase filename (most of our - // extensions are downcased). + // Nothing matches that string. Try again with a downcased string in case + // we got an all-uppercase filename (most of our extensions are + // downcased). ei = _extensions.find(downcase(extension)); if (ei == _extensions.end() || (*ei).second.empty()) { @@ -179,15 +164,12 @@ get_type_from_extension(const string &filename) const { return (*ei).second.front(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_type_from_magic_number -// Access: Published -// Description: Tries to determine what the PNMFileType is likely to -// be for a particular image file based on its -// magic number, the first two bytes read from the -// file. Returns a suitable PNMFileType pointer, or -// NULL if no type can be determined. -//////////////////////////////////////////////////////////////////// +/** + * Tries to determine what the PNMFileType is likely to be for a particular + * image file based on its magic number, the first two bytes read from the + * file. Returns a suitable PNMFileType pointer, or NULL if no type can be + * determined. + */ PNMFileType *PNMFileTypeRegistry:: get_type_from_magic_number(const string &magic_number) const { if (_requires_sort) { @@ -206,14 +188,11 @@ get_type_from_magic_number(const string &magic_number) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_type_by_handle -// Access: Published -// Description: Returns the PNMFileType instance stored in the -// registry for the given TypeHandle, e.g. as retrieved -// by a previous call to get_type() on the type -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PNMFileType instance stored in the registry for the given + * TypeHandle, e.g. as retrieved by a previous call to get_type() on the type + * instance. + */ PNMFileType *PNMFileTypeRegistry:: get_type_by_handle(TypeHandle handle) const { Handles::const_iterator hi; @@ -225,12 +204,10 @@ get_type_by_handle(TypeHandle handle) const { return (PNMFileType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::write -// Access: Published -// Description: Writes a list of supported image file types to the -// indicated output stream, one per line. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of supported image file types to the indicated output stream, + * one per line. + */ void PNMFileTypeRegistry:: write(ostream &out, int indent_level) const { if (_types.empty()) { @@ -257,12 +234,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the global PNMFileTypeRegistry -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global PNMFileTypeRegistry object. + */ PNMFileTypeRegistry *PNMFileTypeRegistry:: get_global_ptr() { if (_global_ptr == (PNMFileTypeRegistry *)NULL) { @@ -271,16 +245,12 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeRegistry::sort_preferences -// Access: Private -// Description: Sorts the PNMFileType pointers in order according to -// user-specified preferences in the config file. This -// allows us to choose a particular PNMFileType over -// another for particular extensions when multiple file -// types map to the same extension, or for file types -// that have no magic number. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the PNMFileType pointers in order according to user-specified + * preferences in the config file. This allows us to choose a particular + * PNMFileType over another for particular extensions when multiple file types + * map to the same extension, or for file types that have no magic number. + */ void PNMFileTypeRegistry:: sort_preferences() { // So, we don't do anything here yet. One day we will. diff --git a/panda/src/pnmimage/pnmFileTypeRegistry.h b/panda/src/pnmimage/pnmFileTypeRegistry.h index d2f3a1799b..35c8bcbb20 100644 --- a/panda/src/pnmimage/pnmFileTypeRegistry.h +++ b/panda/src/pnmimage/pnmFileTypeRegistry.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeRegistry.h -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeRegistry.h + * @author drose + * @date 2000-06-15 + */ #ifndef PNMFILETYPEREGISTRY_H #define PNMFILETYPEREGISTRY_H @@ -23,11 +22,9 @@ class PNMFileType; -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeRegistry -// Description : This class maintains the set of all known -// PNMFileTypes in the universe. -//////////////////////////////////////////////////////////////////// +/** + * This class maintains the set of all known PNMFileTypes in the universe. + */ class EXPCL_PANDA_PNMIMAGE PNMFileTypeRegistry { protected: PNMFileTypeRegistry(); @@ -68,4 +65,3 @@ private: }; #endif - diff --git a/panda/src/pnmimage/pnmImage.I b/panda/src/pnmimage/pnmImage.I index ea54ba0ffb..173f543e1e 100644 --- a/panda/src/pnmimage/pnmImage.I +++ b/panda/src/pnmimage/pnmImage.I @@ -1,22 +1,19 @@ -// Filename: pnmImage.I -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImage.I + * @author drose + * @date 2000-06-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImage:: PNMImage() { _array = NULL; @@ -25,11 +22,9 @@ PNMImage() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImage:: PNMImage(int x_size, int y_size, int num_channels, xelval maxval, PNMFileType *type, ColorSpace color_space) { @@ -39,59 +34,47 @@ PNMImage(int x_size, int y_size, int num_channels, xelval maxval, clear(x_size, y_size, num_channels, maxval, type, color_space); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImage:: PNMImage(const PNMImage ©) { - // We don't need to invoke PNMImageHeader's copy constructor, - // because we'll just call copy_from(). + // We don't need to invoke PNMImageHeader's copy constructor, because we'll + // just call copy_from(). _array = NULL; _alpha = NULL; copy_from(copy); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImage:: operator = (const PNMImage ©) { copy_from(copy); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImage:: ~PNMImage() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::clamp_val -// Access: Published -// Description: A handy function to clamp values to -// [0..get_maxval()]. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to clamp values to [0..get_maxval()]. + */ INLINE xelval PNMImage:: clamp_val(int input_value) const { return (xelval)min(max(0, input_value), (int)get_maxval()); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::to_val -// Access: Published -// Description: A handy function to scale non-alpha values from -// [0..1] to [0..get_maxval()]. Do not use this for -// alpha values, see to_alpha_val. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to scale non-alpha values from [0..1] to + * [0..get_maxval()]. Do not use this for alpha values, see to_alpha_val. + */ INLINE xelval PNMImage:: to_val(float input_value) const { switch (_xel_encoding) { @@ -121,24 +104,18 @@ to_val(float input_value) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::to_alpha_val -// Access: Published -// Description: A handy function to scale alpha values from [0..1] -// to [0..get_maxval()]. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to scale alpha values from [0..1] to [0..get_maxval()]. + */ INLINE xelval PNMImage:: to_alpha_val(float input_value) const { return clamp_val((int)(input_value * get_maxval() + 0.5)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::from_val -// Access: Published -// Description: A handy function to scale non-alpha values from -// [0..get_maxval()] to [0..1]. Do not use this for -// alpha values, see from_alpha_val. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to scale non-alpha values from [0..get_maxval()] to + * [0..1]. Do not use this for alpha values, see from_alpha_val. + */ INLINE float PNMImage:: from_val(xelval input_value) const { switch (_xel_encoding) { @@ -165,75 +142,59 @@ from_val(xelval input_value) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::from_alpha_val -// Access: Published -// Description: A handy function to scale alpha values from -// [0..get_maxval()] to [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * A handy function to scale alpha values from [0..get_maxval()] to [0..1]. + */ INLINE float PNMImage:: from_alpha_val(xelval input_value) const { return (float)input_value * _inv_maxval; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill -// Access: Published -// Description: Sets the entire image (except the alpha channel) to -// the given color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire image (except the alpha channel) to the given color. + */ INLINE void PNMImage:: fill(float red, float green, float blue) { fill_val(to_val(red), to_val(green), to_val(blue)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill -// Access: Published -// Description: Sets the entire image (except the alpha channel) to -// the given grayscale level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire image (except the alpha channel) to the given grayscale + * level. + */ INLINE void PNMImage:: fill(float gray) { fill(gray, gray, gray); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill_val -// Access: Published -// Description: Sets the entire image (except the alpha channel) to -// the given grayscale level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire image (except the alpha channel) to the given grayscale + * level. + */ INLINE void PNMImage:: fill_val(xelval gray) { fill_val(gray, gray, gray); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::alpha_fill -// Access: Published -// Description: Sets the entire alpha channel to the given level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire alpha channel to the given level. + */ INLINE void PNMImage:: alpha_fill(float alpha) { alpha_fill_val(to_alpha_val(alpha)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_read_size -// Access: Published -// Description: Specifies the size to we'd like to scale the image -// upon reading it. This will affect the next call to -// read(). This is usually used to reduce the image -// size, e.g. for a thumbnail. -// -// If the file type reader supports it (e.g. JPEG), then -// this will scale the image during the read operation, -// consequently reducing memory and CPU utilization. If -// the file type reader does not support it, this will -// load the image normally, and them perform a linear -// scale after it has been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the size to we'd like to scale the image upon reading it. This + * will affect the next call to read(). This is usually used to reduce the + * image size, e.g. for a thumbnail. + * + * If the file type reader supports it (e.g. JPEG), then this will scale the + * image during the read operation, consequently reducing memory and CPU + * utilization. If the file type reader does not support it, this will load + * the image normally, and them perform a linear scale after it has been + * loaded. + */ INLINE void PNMImage:: set_read_size(int x_size, int y_size) { _read_x_size = x_size; @@ -241,358 +202,280 @@ set_read_size(int x_size, int y_size) { _has_read_size = true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::clear_read_size -// Access: Published -// Description: Undoes the effect of a previous call to -// set_read_size(). -//////////////////////////////////////////////////////////////////// +/** + * Undoes the effect of a previous call to set_read_size(). + */ INLINE void PNMImage:: clear_read_size() { _has_read_size = false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::has_read_size -// Access: Published -// Description: Returns true if set_read_size() has been called. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if set_read_size() has been called. + */ INLINE bool PNMImage:: has_read_size() const { return _has_read_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_read_x_size -// Access: Published -// Description: Returns the requested x_size of the image if -// set_read_size() has been called, or the image x_size -// otherwise (if it is known). -//////////////////////////////////////////////////////////////////// +/** + * Returns the requested x_size of the image if set_read_size() has been + * called, or the image x_size otherwise (if it is known). + */ INLINE int PNMImage:: get_read_x_size() const { return _has_read_size ? _read_x_size : get_x_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_read_y_size -// Access: Published -// Description: Returns the requested y_size of the image if -// set_read_size() has been called, or the image y_size -// otherwise (if it is known). -//////////////////////////////////////////////////////////////////// +/** + * Returns the requested y_size of the image if set_read_size() has been + * called, or the image y_size otherwise (if it is known). + */ INLINE int PNMImage:: get_read_y_size() const { return _has_read_size ? _read_y_size : get_y_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_color_space -// Access: Published -// Description: Returns the color space in which the image is -// encoded. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color space in which the image is encoded. + */ INLINE ColorSpace PNMImage:: get_color_space() const { return _color_space; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::is_valid -// Access: Published -// Description: Returns true if the image has been read in or -// correctly initialized with a height and width. If -// this returns false, virtually all member functions -// except clear() and read() are invalid function calls. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the image has been read in or correctly initialized with a + * height and width. If this returns false, virtually all member functions + * except clear() and read() are invalid function calls. + */ INLINE bool PNMImage:: is_valid() const { return (_array != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_num_channels -// Access: Published -// Description: Changes the number of channels associated with the -// image. The new number of channels must be an integer -// in the range 1 through 4, inclusive. This will -// allocate and/or deallocate memory as necessary to -// accommodate; see set_color_type(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of channels associated with the image. The new number + * of channels must be an integer in the range 1 through 4, inclusive. This + * will allocate and/or deallocate memory as necessary to accommodate; see + * set_color_type(). + */ INLINE void PNMImage:: set_num_channels(int num_channels) { nassertv(num_channels >= 1 && num_channels <= 4); set_color_type((ColorType)num_channels); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::add_alpha -// Access: Published -// Description: Adds an alpha channel to the image, if it does not -// already have one. The alpha channel is initialized -// to zeros. -//////////////////////////////////////////////////////////////////// +/** + * Adds an alpha channel to the image, if it does not already have one. The + * alpha channel is initialized to zeros. + */ INLINE void PNMImage:: add_alpha() { set_color_type(is_grayscale() ? CT_two_channel : CT_four_channel); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::remove_alpha -// Access: Published -// Description: Removes the image's alpha channel, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Removes the image's alpha channel, if it exists. + */ INLINE void PNMImage:: remove_alpha() { set_color_type(is_grayscale() ? CT_grayscale : CT_color); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::make_grayscale -// Access: Published -// Description: Converts the image from RGB to grayscale. Any alpha -// channel, if present, is left undisturbed. -//////////////////////////////////////////////////////////////////// +/** + * Converts the image from RGB to grayscale. Any alpha channel, if present, + * is left undisturbed. + */ INLINE void PNMImage:: make_grayscale() { make_grayscale(_default_rc, _default_gc, _default_bc); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::make_rgb -// Access: Published -// Description: Converts the image from grayscale to RGB. Any alpha -// channel, if present, is left undisturbed. -//////////////////////////////////////////////////////////////////// +/** + * Converts the image from grayscale to RGB. Any alpha channel, if present, + * is left undisturbed. + */ INLINE void PNMImage:: make_rgb() { set_color_type(has_alpha() ? CT_four_channel : CT_color); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_xel_val -// Access: Published -// Description: Returns the RGB color at the indicated pixel. Each -// component is in the range 0..maxval. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RGB color at the indicated pixel. Each component is in the + * range 0..maxval. + */ INLINE xel &PNMImage:: get_xel_val(int x, int y) { nassertr(x >= 0 && x < _x_size && y >= 0 && y < _y_size, _array[0]); return row(y)[x]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_xel_val -// Access: Published -// Description: Returns the RGB color at the indicated pixel. Each -// component is in the range 0..maxval. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RGB color at the indicated pixel. Each component is in the + * range 0..maxval. + */ INLINE xel PNMImage:: get_xel_val(int x, int y) const { nassertr(x >= 0 && x < _x_size && y >= 0 && y < _y_size, _array[0]); return row(y)[x]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel_val -// Access: Published -// Description: Changes the RGB color at the indicated pixel. Each -// component is in the range 0..maxval, encoded in -// the configured color space. See set_xel if you -// instead have a linearized and normalized -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGB color at the indicated pixel. Each component is in the + * range 0..maxval, encoded in the configured color space. See set_xel if you + * instead have a linearized and normalized floating-point value. + */ INLINE void PNMImage:: set_xel_val(int x, int y, const xel &value) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); row(y)[x] = value; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel_val -// Access: Published -// Description: Changes the RGB color at the indicated pixel. Each -// component is in the range 0..maxval, encoded in -// the configured color space. See set_xel if you -// instead have a linearized and normalized -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGB color at the indicated pixel. Each component is in the + * range 0..maxval, encoded in the configured color space. See set_xel if you + * instead have a linearized and normalized floating-point value. + */ INLINE void PNMImage:: set_xel_val(int x, int y, xelval r, xelval g, xelval b) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_ASSIGN(row(y)[x], r, g, b); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel_val -// Access: Published -// Description: Changes all three color components at the indicated -// pixel to the same value. The value is in the range -// component is in the range 0..maxval, encoded in -// the configured color space. See set_xel if you -// instead have a linearized and normalized -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Changes all three color components at the indicated pixel to the same + * value. The value is in the range component is in the range 0..maxval, + * encoded in the configured color space. See set_xel if you instead have a + * linearized and normalized floating-point value. + */ INLINE void PNMImage:: set_xel_val(int x, int y, xelval gray) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_ASSIGN(row(y)[x], gray, gray, gray); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_red_val -// Access: Published -// Description: Returns the red component color at the indicated -// pixel. The value returned is in the range 0..maxval -// and encoded in the configured color space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the red component color at the indicated pixel. The value returned + * is in the range 0..maxval and encoded in the configured color space. + */ INLINE xelval PNMImage:: get_red_val(int x, int y) const { return PPM_GETR(get_xel_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_green_val -// Access: Published -// Description: Returns the green component color at the indicated -// pixel. The value returned is in the range 0..maxval -// and encoded in the configured color space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the green component color at the indicated pixel. The value + * returned is in the range 0..maxval and encoded in the configured color + * space. + */ INLINE xelval PNMImage:: get_green_val(int x, int y) const { return PPM_GETG(get_xel_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_blue_val -// Access: Published -// Description: Returns the blue component color at the indicated -// pixel. The value returned is in the range 0..maxval -// and encoded in the configured color space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blue component color at the indicated pixel. The value + * returned is in the range 0..maxval and encoded in the configured color + * space. + */ INLINE xelval PNMImage:: get_blue_val(int x, int y) const { return PPM_GETB(get_xel_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_gray_val -// Access: Published -// Description: Returns the gray component color at the indicated -// pixel. This only has a meaningful value for -// grayscale images; for other image types, this returns -// the value of the blue channel only. However, also -// see the get_bright() function. -// The value returned is in the range 0..maxval and -// encoded in the configured color space. -//////////////////////////////////////////////////////////////////// +/** + * Returns the gray component color at the indicated pixel. This only has a + * meaningful value for grayscale images; for other image types, this returns + * the value of the blue channel only. However, also see the get_bright() + * function. The value returned is in the range 0..maxval and encoded in the + * configured color space. + */ INLINE xelval PNMImage:: get_gray_val(int x, int y) const { return PPM_GETB(get_xel_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_alpha_val -// Access: Published -// Description: Returns the alpha component color at the indicated -// pixel. It is an error to call this unless -// has_alpha() is true. The value returned is in the -// range 0..maxval and always linear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha component color at the indicated pixel. It is an error + * to call this unless has_alpha() is true. The value returned is in the + * range 0..maxval and always linear. + */ INLINE xelval PNMImage:: get_alpha_val(int x, int y) const { nassertr(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size, 0); return alpha_row(y)[x]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_red_val -// Access: Published -// Description: Sets the red component color only at the indicated -// pixel. The value given should be in the range -// 0..maxval, encoded in the configured color space. -// See set_red if you instead have a linearized and -// normalized floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the red component color only at the indicated pixel. The value given + * should be in the range 0..maxval, encoded in the configured color space. + * See set_red if you instead have a linearized and normalized floating-point + * value. + */ INLINE void PNMImage:: set_red_val(int x, int y, xelval r) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_PUTR(row(y)[x], r); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_green_val -// Access: Published -// Description: Sets the green component color only at the indicated -// pixel. The value given should be in the range -// 0..maxval, encoded in the configured color space. -// See set_green if you instead have a linearized and -// normalized floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the green component color only at the indicated pixel. The value + * given should be in the range 0..maxval, encoded in the configured color + * space. See set_green if you instead have a linearized and normalized + * floating-point value. + */ INLINE void PNMImage:: set_green_val(int x, int y, xelval g) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_PUTG(row(y)[x], g); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_blue_val -// Access: Published -// Description: Sets the blue component color only at the indicated -// pixel. The value given should be in the range -// 0..maxval, encoded in the configured color space. -// See set_blue if you instead have a linearized and -// normalized floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the blue component color only at the indicated pixel. The value given + * should be in the range 0..maxval, encoded in the configured color space. + * See set_blue if you instead have a linearized and normalized floating-point + * value. + */ INLINE void PNMImage:: set_blue_val(int x, int y, xelval b) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_PUTB(row(y)[x], b); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_gray_val -// Access: Published -// Description: Sets the gray component color at the indicated -// pixel. This is only meaningful for grayscale images; -// for other image types, this simply sets the blue -// component color. However, also see set_xel_val(), -// which can set all the component colors to the same -// grayscale level, and hence works correctly both for -// grayscale and color images. The value given should -// be in the range 0..maxval, encoded in the configured -// color space. See set_gray if you instead have a -// linearized normalized floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the gray component color at the indicated pixel. This is only + * meaningful for grayscale images; for other image types, this simply sets + * the blue component color. However, also see set_xel_val(), which can set + * all the component colors to the same grayscale level, and hence works + * correctly both for grayscale and color images. The value given should be + * in the range 0..maxval, encoded in the configured color space. See + * set_gray if you instead have a linearized normalized floating-point value. + */ INLINE void PNMImage:: set_gray_val(int x, int y, xelval gray) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); PPM_PUTB(row(y)[x], gray); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_alpha_val -// Access: Published -// Description: Sets the alpha component color only at the indicated -// pixel. It is an error to call this unless -// has_alpha() is true. The value given should be in -// the range 0..maxval. -// -// This value is always linearly encoded, even if the -// image is set to the sRGB color space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the alpha component color only at the indicated pixel. It is an error + * to call this unless has_alpha() is true. The value given should be in the + * range 0..maxval. + * + * This value is always linearly encoded, even if the image is set to the sRGB + * color space. + */ INLINE void PNMImage:: set_alpha_val(int x, int y, xelval a) { nassertv(_alpha != NULL && x >= 0 && x < _x_size && y >= 0 && y < _y_size); alpha_row(y)[x] = a; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_xel -// Access: Published -// Description: Returns the RGB color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RGB color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE LRGBColorf PNMImage:: get_xel(int x, int y) const { nassertr(x >= 0 && x < _x_size && y >= 0 && y < _y_size, LRGBColorf::zero()); @@ -631,12 +514,10 @@ get_xel(int x, int y) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel -// Access: Published -// Description: Changes the RGB color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGB color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE void PNMImage:: set_xel(int x, int y, const LRGBColorf &value) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); @@ -686,36 +567,29 @@ set_xel(int x, int y, const LRGBColorf &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel -// Access: Published -// Description: Changes the RGB color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGB color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE void PNMImage:: set_xel(int x, int y, float r, float g, float b) { set_xel(x, y, LRGBColorf(r, g, b)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel -// Access: Published -// Description: Changes all three color components at the indicated -// pixel to the same value. The value is a linearized -// float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Changes all three color components at the indicated pixel to the same + * value. The value is a linearized float in the range 0..1. + */ INLINE void PNMImage:: set_xel(int x, int y, float gray) { xelval val = to_val(gray); set_xel_val(x, y, val); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_xel_a -// Access: Published -// Description: Returns the RGBA color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RGBA color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE LColorf PNMImage:: get_xel_a(int x, int y) const { const xel &col = row(y)[x]; @@ -779,12 +653,10 @@ get_xel_a(int x, int y) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel_a -// Access: Published -// Description: Changes the RGBA color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGBA color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE void PNMImage:: set_xel_a(int x, int y, const LColorf &value) { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); @@ -867,494 +739,384 @@ set_xel_a(int x, int y, const LColorf &value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_xel_a -// Access: Published -// Description: Changes the RGBA color at the indicated pixel. Each -// component is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Changes the RGBA color at the indicated pixel. Each component is a + * linearized float in the range 0..1. + */ INLINE void PNMImage:: set_xel_a(int x, int y, float r, float g, float b, float a) { set_xel_a(x, y, LColorf(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_red -// Access: Published -// Description: Returns the red component color at the indicated -// pixel. The value returned is a linearized float -// in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the red component color at the indicated pixel. The value returned + * is a linearized float in the range 0..1. + */ INLINE float PNMImage:: get_red(int x, int y) const { return from_val(get_red_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_green -// Access: Published -// Description: Returns the green component color at the indicated -// pixel. The value returned is a linearized float -// in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the green component color at the indicated pixel. The value + * returned is a linearized float in the range 0..1. + */ INLINE float PNMImage:: get_green(int x, int y) const { return from_val(get_green_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_blue -// Access: Published -// Description: Returns the blue component color at the indicated -// pixel. The value returned is a linearized float -// in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the blue component color at the indicated pixel. The value + * returned is a linearized float in the range 0..1. + */ INLINE float PNMImage:: get_blue(int x, int y) const { return from_val(get_blue_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_gray -// Access: Published -// Description: Returns the gray component color at the indicated -// pixel. This only has a meaningful value for -// grayscale images; for other image types, this returns -// the value of the blue channel only. However, also -// see the get_bright() function. The value returned -// is a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the gray component color at the indicated pixel. This only has a + * meaningful value for grayscale images; for other image types, this returns + * the value of the blue channel only. However, also see the get_bright() + * function. The value returned is a linearized float in the range 0..1. + */ INLINE float PNMImage:: get_gray(int x, int y) const { return from_val(get_gray_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_alpha -// Access: Published -// Description: Returns the alpha component color at the indicated -// pixel. It is an error to call this unless -// has_alpha() is true. The value returned is a float -// in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha component color at the indicated pixel. It is an error + * to call this unless has_alpha() is true. The value returned is a float in + * the range 0..1. + */ INLINE float PNMImage:: get_alpha(int x, int y) const { return from_alpha_val(get_alpha_val(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_red -// Access: Published -// Description: Sets the red component color only at the indicated -// pixel. The value given should be a linearized -// float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the red component color only at the indicated pixel. The value given + * should be a linearized float in the range 0..1. + */ INLINE void PNMImage:: set_red(int x, int y, float r) { set_red_val(x, y, to_val(r)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_green -// Access: Published -// Description: Sets the green component color only at the indicated -// pixel. The value given should be a linearized -// float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the green component color only at the indicated pixel. The value + * given should be a linearized float in the range 0..1. + */ INLINE void PNMImage:: set_green(int x, int y, float g) { set_green_val(x, y, to_val(g)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_blue -// Access: Published -// Description: Sets the blue component color only at the indicated -// pixel. The value given should be a linearized -// float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the blue component color only at the indicated pixel. The value given + * should be a linearized float in the range 0..1. + */ INLINE void PNMImage:: set_blue(int x, int y, float b) { set_blue_val(x, y, to_val(b)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_gray -// Access: Published -// Description: Sets the gray component color at the indicated -// pixel. This is only meaningful for grayscale images; -// for other image types, this simply sets the blue -// component color. However, also see set_xel(), which -// can set all the component colors to the same -// grayscale level, and hence works correctly both for -// grayscale and color images. The value given should -// be a linearized float in the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the gray component color at the indicated pixel. This is only + * meaningful for grayscale images; for other image types, this simply sets + * the blue component color. However, also see set_xel(), which can set all + * the component colors to the same grayscale level, and hence works correctly + * both for grayscale and color images. The value given should be a + * linearized float in the range 0..1. + */ INLINE void PNMImage:: set_gray(int x, int y, float gray) { set_gray_val(x, y, to_val(gray)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_alpha -// Access: Published -// Description: Sets the alpha component color only at the indicated -// pixel. It is an error to call this unless -// has_alpha() is true. The value given should be in -// the range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the alpha component color only at the indicated pixel. It is an error + * to call this unless has_alpha() is true. The value given should be in the + * range 0..1. + */ INLINE void PNMImage:: set_alpha(int x, int y, float a) { set_alpha_val(x, y, to_alpha_val(a)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_bright -// Access: Published -// Description: Returns the linear brightness of the given xel, as a -// linearized float in the range 0..1. This flavor of -// get_bright() returns the correct grayscale brightness -// level for both full-color and grayscale images. -//////////////////////////////////////////////////////////////////// +/** + * Returns the linear brightness of the given xel, as a linearized float in + * the range 0..1. This flavor of get_bright() returns the correct grayscale + * brightness level for both full-color and grayscale images. + */ INLINE float PNMImage:: get_bright(int x, int y) const { return get_bright(x, y, _default_rc, _default_gc, _default_bc); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_bright -// Access: Published -// Description: This flavor of get_bright() works correctly only for -// color images. It returns a single brightness value -// for the RGB color at the indicated pixel, based on -// the supplied weights for each component. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_bright() works correctly only for color images. It + * returns a single brightness value for the RGB color at the indicated pixel, + * based on the supplied weights for each component. + */ INLINE float PNMImage:: get_bright(int x, int y, float rc, float gc, float bc) const { return get_xel(x, y).dot(LVecBase3f(rc, gc, bc)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_bright -// Access: Published -// Description: This flavor of get_bright() works correctly only for -// four-channel images. It returns a single brightness -// value for the RGBA color at the indicated pixel, -// based on the supplied weights for each component. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of get_bright() works correctly only for four-channel images. + * It returns a single brightness value for the RGBA color at the indicated + * pixel, based on the supplied weights for each component. + */ INLINE float PNMImage:: get_bright(int x, int y, float rc, float gc, float bc, float ac) const { return get_xel_a(x, y).dot(LVecBase4f(rc, gc, bc, ac)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::blend -// Access: Published -// Description: Smoothly blends the indicated pixel value in with -// whatever was already in the image, based on the given -// alpha value. An alpha of 1.0 is fully opaque and -// completely replaces whatever was there previously; -// alpha of 0.0 is fully transparent and does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Smoothly blends the indicated pixel value in with whatever was already in + * the image, based on the given alpha value. An alpha of 1.0 is fully opaque + * and completely replaces whatever was there previously; alpha of 0.0 is + * fully transparent and does nothing. + */ INLINE void PNMImage:: blend(int x, int y, const LRGBColorf &val, float alpha) { blend(x, y, val[0], val[1], val[2], alpha); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::box_filter -// Access: Published -// Description: This flavor of box_filter() will apply the filter -// over the entire image without resizing or copying; -// the effect is that of a blur operation. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of box_filter() will apply the filter over the entire image + * without resizing or copying; the effect is that of a blur operation. + */ INLINE void PNMImage:: box_filter(float radius) { box_filter_from(radius, *this); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::gaussian_filter -// Access: Published -// Description: This flavor of gaussian_filter() will apply the filter -// over the entire image without resizing or copying; -// the effect is that of a blur operation. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of gaussian_filter() will apply the filter over the entire + * image without resizing or copying; the effect is that of a blur operation. + */ INLINE void PNMImage:: gaussian_filter(float radius) { gaussian_filter_from(radius, *this); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::gamma_correct -// Access: Published -// Description: Assuming the image was constructed with a gamma curve -// of from_gamma in the RGB channels, converts it to an -// image with a gamma curve of to_gamma in the RGB -// channels. Does not affect the alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the image was constructed with a gamma curve of from_gamma in the + * RGB channels, converts it to an image with a gamma curve of to_gamma in the + * RGB channels. Does not affect the alpha channel. + */ INLINE void PNMImage:: gamma_correct(float from_gamma, float to_gamma) { apply_exponent(from_gamma / to_gamma); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::gamma_correct_alpha -// Access: Published -// Description: Assuming the image was constructed with a gamma curve -// of from_gamma in the alpha channel, converts it to an -// image with a gamma curve of to_gamma in the alpha -// channel. Does not affect the RGB channels. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the image was constructed with a gamma curve of from_gamma in the + * alpha channel, converts it to an image with a gamma curve of to_gamma in + * the alpha channel. Does not affect the RGB channels. + */ INLINE void PNMImage:: gamma_correct_alpha(float from_gamma, float to_gamma) { apply_exponent(1.0, from_gamma / to_gamma); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. + */ INLINE void PNMImage:: apply_exponent(float gray_exponent) { apply_exponent(gray_exponent, gray_exponent, gray_exponent, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. + */ INLINE void PNMImage:: apply_exponent(float gray_exponent, float alpha_exponent) { apply_exponent(gray_exponent, gray_exponent, gray_exponent, alpha_exponent); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. For a -// grayscale image, the blue_exponent value is used for -// the grayscale value, and red_exponent and -// green_exponent are unused. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. For a + * grayscale image, the blue_exponent value is used for the grayscale value, + * and red_exponent and green_exponent are unused. + */ INLINE void PNMImage:: apply_exponent(float red_exponent, float green_exponent, float blue_exponent) { apply_exponent(red_exponent, green_exponent, blue_exponent, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row Constructor -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PNMImage::Row:: Row(PNMImage &image, int y) : _image(image), _y(y) { nassertv(y >= 0 && y < _image._y_size); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::size -// Access: Published -// Description: Get the number of pixels in the row. -//////////////////////////////////////////////////////////////////// +/** + * Get the number of pixels in the row. + */ INLINE size_t PNMImage::Row:: size() const { return _image.get_x_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Fetch the RGB value at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the RGB value at the given column in the row. + */ INLINE LColorf PNMImage::Row:: operator[](int x) const { return _image.get_xel_a(x, _y); } #ifdef HAVE_PYTHON -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Set the pixel at the given column in the row. If -// the image has no alpha channel, the alpha component -// is ignored. -//////////////////////////////////////////////////////////////////// +/** + * Set the pixel at the given column in the row. If the image has no alpha + * channel, the alpha component is ignored. + */ INLINE void PNMImage::Row:: __setitem__(int x, const LColorf &v) { _image.set_xel_a(x, _y, v); } #endif -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Fetch the pixel at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the pixel at the given column in the row. + */ INLINE xel &PNMImage::Row:: get_xel_val(int x) { return _image.get_xel_val(x, _y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Set the pixel at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Set the pixel at the given column in the row. + */ INLINE void PNMImage::Row:: set_xel_val(int x, const xel &v) { _image.set_xel_val(x, _y, v); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Fetch the alpha value at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the alpha value at the given column in the row. + */ INLINE xelval PNMImage::Row:: get_alpha_val(int x) const { return _image.get_alpha_val(x, _y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Row::Array Operator -// Access: Published -// Description: Set the alpha value at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Set the alpha value at the given column in the row. + */ INLINE void PNMImage::Row:: set_alpha_val(int x, xelval v) { _image.set_alpha_val(x, _y, v); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::CRow Constructor -//////////////////////////////////////////////////////////////////// +/** + + */ INLINE PNMImage::CRow:: CRow(const PNMImage &image, int y) : _image(image), _y(y) { nassertv(y >= 0 && y < _image._y_size); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::CRow::size -// Access: Published -// Description: Get the number of pixels in the row. -//////////////////////////////////////////////////////////////////// +/** + * Get the number of pixels in the row. + */ INLINE size_t PNMImage::CRow:: size() const { return _image.get_x_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::CRow::Array Operator -// Access: Published -// Description: Fetch the RGB value at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the RGB value at the given column in the row. + */ INLINE LColorf PNMImage::CRow:: operator[](int x) const { return _image.get_xel_a(x, _y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::CRow::Array Operator -// Access: Published -// Description: Fetch the pixel at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the pixel at the given column in the row. + */ INLINE xel PNMImage::CRow:: get_xel_val(int x) const { return _image.get_xel_val(x, _y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::CRow::Array Operator -// Access: Published -// Description: Fetch the alpha value at the given column in the row. -//////////////////////////////////////////////////////////////////// +/** + * Fetch the alpha value at the given column in the row. + */ INLINE xelval PNMImage::CRow:: get_alpha_val(int x) const { return _image.get_alpha_val(x, _y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Array Operator -// Access: Published -// Description: Allows the PNMImage to appear to be a 2-d array of -// xels. -//////////////////////////////////////////////////////////////////// +/** + * Allows the PNMImage to appear to be a 2-d array of xels. + */ INLINE PNMImage::Row PNMImage:: operator [] (int y) { return Row(*this, y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Array Operator -// Access: Published -// Description: Allows the PNMImage to appear to be a 2-d array of -// xels. -//////////////////////////////////////////////////////////////////// +/** + * Allows the PNMImage to appear to be a 2-d array of xels. + */ INLINE PNMImage::CRow PNMImage:: operator [] (int y) const { return CRow(*this, y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_array -// Access: Public -// Description: Directly access the underlying PNMImage array. Know -// what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Directly access the underlying PNMImage array. Know what you are doing! + */ INLINE xel *PNMImage:: get_array() { return _array; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_array -// Access: Public -// Description: Directly access the underlying PNMImage array. Know -// what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Directly access the underlying PNMImage array. Know what you are doing! + */ INLINE const xel *PNMImage:: get_array() const { return _array; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_alpha_array -// Access: Public -// Description: Directly access the underlying PNMImage array of -// alpha values. Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Directly access the underlying PNMImage array of alpha values. Know what + * you are doing! + */ INLINE xelval *PNMImage:: get_alpha_array() { return _alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_alpha_array -// Access: Public -// Description: Directly access the underlying PNMImage array of -// alpha values. Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Directly access the underlying PNMImage array of alpha values. Know what + * you are doing! + */ INLINE const xelval *PNMImage:: get_alpha_array() const { return _alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::take_array -// Access: Public -// Description: Returns the underlying PNMImage array and removes it -// from the PNMImage. You become the owner of this -// array and must eventually free it with -// PANDA_FREE_ARRAY() (or pass it to another PNMImage -// with set_array()). Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying PNMImage array and removes it from the PNMImage. + * You become the owner of this array and must eventually free it with + * PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_array()). Know + * what you are doing! + */ INLINE xel *PNMImage:: take_array() { xel *array = _array; @@ -1362,15 +1124,12 @@ take_array() { return array; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::take_alpha_array -// Access: Public -// Description: Returns the underlying PNMImage array and removes it -// from the PNMImage. You become the owner of this -// array and must eventually free it with -// PANDA_FREE_ARRAY() (or pass it to another PNMImage -// with set_alpha_array()). Know what you are doing! -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying PNMImage array and removes it from the PNMImage. + * You become the owner of this array and must eventually free it with + * PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_alpha_array()). + * Know what you are doing! + */ INLINE xelval *PNMImage:: take_alpha_array() { xelval *alpha = _alpha; @@ -1378,59 +1137,46 @@ take_alpha_array() { return alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::allocate_array -// Access: Private -// Description: Allocates the internal memory for the RGB or -// grayscale pixels in the image (except alpha). -//////////////////////////////////////////////////////////////////// +/** + * Allocates the internal memory for the RGB or grayscale pixels in the image + * (except alpha). + */ INLINE void PNMImage:: allocate_array() { _array = (xel *)PANDA_MALLOC_ARRAY((size_t)_x_size * (size_t)_y_size * sizeof(xel)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::allocate_alpha -// Access: Private -// Description: Allocates the internal memory for the alpha pixels in -// the image. -//////////////////////////////////////////////////////////////////// +/** + * Allocates the internal memory for the alpha pixels in the image. + */ INLINE void PNMImage:: allocate_alpha() { _alpha = (xelval *)PANDA_MALLOC_ARRAY((size_t)_x_size * (size_t)_y_size * sizeof(xelval)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::row -// Access: Private -// Description: Returns an array of xels corresponding to the nth row -// of the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns an array of xels corresponding to the nth row of the image. + */ INLINE xel *PNMImage:: row(int y) const { nassertr(y >= 0 && y < _y_size, NULL); return _array + y * _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::alpha_row -// Access: Private -// Description: Returns an array of xelvals corresponding to the nth -// row of the alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns an array of xelvals corresponding to the nth row of the alpha + * channel. + */ INLINE xelval *PNMImage:: alpha_row(int y) const { nassertr(_alpha != NULL && y >= 0 && y < _y_size, NULL); return _alpha + y * _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::setup_sub_image -// Access: Private -// Description: Computes xmin, ymin, xmax, and ymax, based on the -// input parameters for copy_sub_image() and related -// methods. -//////////////////////////////////////////////////////////////////// +/** + * Computes xmin, ymin, xmax, and ymax, based on the input parameters for + * copy_sub_image() and related methods. + */ INLINE void PNMImage:: setup_sub_image(const PNMImage ©, int &xto, int &yto, int &xfrom, int &yfrom, int &x_size, int &y_size, @@ -1474,13 +1220,10 @@ setup_sub_image(const PNMImage ©, int &xto, int &yto, ymax = min(ymin + y_size, get_y_size()); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::compute_spot_pixel -// Access: Private, Static -// Description: Called by render_spot to compute the color of a -// single pixel, based in (the square of) its distance -// from the center. -//////////////////////////////////////////////////////////////////// +/** + * Called by render_spot to compute the color of a single pixel, based in (the + * square of) its distance from the center. + */ INLINE void PNMImage:: compute_spot_pixel(LColorf &c, float d2, float min_radius, float max_radius, @@ -1498,14 +1241,11 @@ compute_spot_pixel(LColorf &c, float d2, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator + -// Access: Published -// Description: Returns a new PNMImage in which each pixel value -// is the sum of the corresponding pixel values -// in the two given images. -// Only valid when both images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which each pixel value is the sum of the + * corresponding pixel values in the two given images. Only valid when both + * images have the same size. + */ INLINE PNMImage PNMImage:: operator + (const PNMImage &other) const { PNMImage target (*this); @@ -1513,12 +1253,10 @@ operator + (const PNMImage &other) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator + -// Access: Published -// Description: Returns a new PNMImage in which the provided color -// is added to each pixel in the provided image. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which the provided color is added to each pixel + * in the provided image. + */ INLINE PNMImage PNMImage:: operator + (const LColorf &other) const { PNMImage target (*this); @@ -1526,14 +1264,11 @@ operator + (const LColorf &other) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator - -// Access: Published -// Description: Returns a new PNMImage in which each pixel value -// from the right image is subtracted from each -// pixel value from the left image. -// Only valid when both images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which each pixel value from the right image is + * subtracted from each pixel value from the left image. Only valid when both + * images have the same size. + */ INLINE PNMImage PNMImage:: operator - (const PNMImage &other) const { PNMImage target (*this); @@ -1541,12 +1276,10 @@ operator - (const PNMImage &other) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator - -// Access: Published -// Description: Returns a new PNMImage in which the provided color -// is subtracted from each pixel in the provided image. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which the provided color is subtracted from each + * pixel in the provided image. + */ INLINE PNMImage PNMImage:: operator - (const LColorf &other) const { PNMImage target (*this); @@ -1554,16 +1287,12 @@ operator - (const LColorf &other) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator * -// Access: Published -// Description: Returns a new PNMImage in which each pixel value -// from the left image is multiplied by each -// pixel value from the right image. Note that the -// floating-point values in the 0..1 range are -// multiplied, not in the 0..maxval range. -// Only valid when both images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which each pixel value from the left image is + * multiplied by each pixel value from the right image. Note that the + * floating-point values in the 0..1 range are multiplied, not in the + * 0..maxval range. Only valid when both images have the same size. + */ INLINE PNMImage PNMImage:: operator * (const PNMImage &other) const { PNMImage target (*this); @@ -1571,12 +1300,10 @@ operator * (const PNMImage &other) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator * -// Access: Published -// Description: Multiplies every pixel value in the image by -// a constant floating-point multiplier value. -//////////////////////////////////////////////////////////////////// +/** + * Multiplies every pixel value in the image by a constant floating-point + * multiplier value. + */ INLINE PNMImage PNMImage:: operator * (float multiplier) const { PNMImage target (*this); @@ -1584,12 +1311,10 @@ operator * (float multiplier) const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator * -// Access: Published -// Description: Returns a new PNMImage in which the provided color -// is multiplied to each pixel in the provided image. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage in which the provided color is multiplied to each + * pixel in the provided image. + */ INLINE PNMImage PNMImage:: operator * (const LColorf &other) const { PNMImage target (*this); diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index bbf8574949..7429f38ce7 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1,16 +1,15 @@ -// Filename: pnmImage.cxx -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImage.cxx + * @author drose + * @date 2000-06-14 + */ #include "pnmImage.h" #include "pnmReader.h" @@ -22,11 +21,9 @@ #include "stackedPerlinNoise2.h" #include -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMImage:: PNMImage(const Filename &filename, PNMFileType *type) { _array = NULL; @@ -40,12 +37,10 @@ PNMImage(const Filename &filename, PNMFileType *type) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::clear -// Access: Published -// Description: Frees all memory allocated for the image, and clears -// all its parameters (size, color, type, etc). -//////////////////////////////////////////////////////////////////// +/** + * Frees all memory allocated for the image, and clears all its parameters + * (size, color, type, etc). + */ void PNMImage:: clear() { if (_array != (xel *)NULL) { @@ -68,12 +63,10 @@ clear() { _xel_encoding = XE_generic; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::clear -// Access: Published -// Description: This flavor of clear() reinitializes the image to an -// empty (black) image with the given dimensions. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of clear() reinitializes the image to an empty (black) image + * with the given dimensions. + */ void PNMImage:: clear(int x_size, int y_size, int num_channels, xelval maxval, PNMFileType *type, ColorSpace color_space) { @@ -102,11 +95,9 @@ clear(int x_size, int y_size, int num_channels, setup_rc(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_from -// Access: Published -// Description: Makes this image become a copy of the other image. -//////////////////////////////////////////////////////////////////// +/** + * Makes this image become a copy of the other image. + */ void PNMImage:: copy_from(const PNMImage ©) { clear(); @@ -120,12 +111,9 @@ copy_from(const PNMImage ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_channel -// Access: Published -// Description: Copies a channel from one image into another. -// Images must be the same size -//////////////////////////////////////////////////////////////////// +/** + * Copies a channel from one image into another. Images must be the same size + */ void PNMImage:: copy_channel(const PNMImage ©, int src_channel, int dest_channel) { // Make sure the channels are in range @@ -152,16 +140,13 @@ copy_channel(const PNMImage ©, int src_channel, int dest_channel) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_channel_bits -// Access: Published -// Description: Copies some subset of the bits of the specified -// channel from one image into some subset of the bits -// of the specified channel in another image. Images -// must be the same size. -// -// If right_shift is negative, it means a left shift. -//////////////////////////////////////////////////////////////////// +/** + * Copies some subset of the bits of the specified channel from one image into + * some subset of the bits of the specified channel in another image. Images + * must be the same size. + * + * If right_shift is negative, it means a left shift. + */ void PNMImage:: copy_channel_bits(const PNMImage ©, int src_channel, int dest_channel, xelval src_mask, int right_shift) { // Make sure the channels are in range @@ -203,14 +188,11 @@ copy_channel_bits(const PNMImage ©, int src_channel, int dest_channel, xelva } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_header_from -// Access: Published -// Description: Copies just the header information into this image. -// This will blow away any image data stored in the -// image. The new image data will be allocated, but -// left unitialized. -//////////////////////////////////////////////////////////////////// +/** + * Copies just the header information into this image. This will blow away + * any image data stored in the image. The new image data will be allocated, + * but left unitialized. + */ void PNMImage:: copy_header_from(const PNMImageHeader &header) { clear(); @@ -231,12 +213,10 @@ copy_header_from(const PNMImageHeader &header) { setup_rc(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::take_from -// Access: Published -// Description: Move the contents of the other image into this one, -// and empty the other image. -//////////////////////////////////////////////////////////////////// +/** + * Move the contents of the other image into this one, and empty the other + * image. + */ void PNMImage:: take_from(PNMImage &orig) { clear(); @@ -254,12 +234,9 @@ take_from(PNMImage &orig) { orig.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill_val -// Access: Published -// Description: Sets the entire image (except the alpha channel) to -// the given color. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire image (except the alpha channel) to the given color. + */ void PNMImage:: fill_val(xelval red, xelval green, xelval blue) { if (is_valid()) { @@ -271,11 +248,9 @@ fill_val(xelval red, xelval green, xelval blue) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::alpha_fill_val -// Access: Published -// Description: Sets the entire alpha channel to the given level. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire alpha channel to the given level. + */ void PNMImage:: alpha_fill_val(xelval alpha) { if (is_valid()) { @@ -291,13 +266,11 @@ alpha_fill_val(xelval alpha) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::read -// Access: Published -// Description: Reads the indicated image filename. If type is -// non-NULL, it is a suggestion for the type of file it -// is. Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated image filename. If type is non-NULL, it is a + * suggestion for the type of file it is. Returns true if successful, false + * on error. + */ bool PNMImage:: read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { PNMReader *reader = make_reader(filename, type, report_unknown_type); @@ -309,20 +282,18 @@ read(const Filename &filename, PNMFileType *type, bool report_unknown_type) { return read(reader); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::read -// Access: Published -// Description: Reads the image data from the indicated stream. -// -// The filename is advisory only, and may be used -// to suggest a type if it has a known extension. -// -// If type is non-NULL, it is a suggestion for the type -// of file it is (and a non-NULL type will override any -// magic number test or filename extension lookup). -// -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the image data from the indicated stream. + * + * The filename is advisory only, and may be used to suggest a type if it has + * a known extension. + * + * If type is non-NULL, it is a suggestion for the type of file it is (and a + * non-NULL type will override any magic number test or filename extension + * lookup). + * + * Returns true if successful, false on error. + */ bool PNMImage:: read(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { @@ -335,19 +306,14 @@ read(istream &data, const string &filename, PNMFileType *type, return read(reader); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::read -// Access: Published -// Description: This flavor of read() uses an already-existing -// PNMReader to read the image file. You can get a -// reader via the PNMImageHeader::make_reader() methods. -// This is a good way to examine the header of a file -// (for instance, to determine its size) before actually -// reading the entire image. -// -// The PNMReader is always deleted upon completion, -// whether successful or not. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of read() uses an already-existing PNMReader to read the image + * file. You can get a reader via the PNMImageHeader::make_reader() methods. + * This is a good way to examine the header of a file (for instance, to + * determine its size) before actually reading the entire image. + * + * The PNMReader is always deleted upon completion, whether successful or not. + */ bool PNMImage:: read(PNMReader *reader) { bool has_read_size = _has_read_size; @@ -383,8 +349,8 @@ read(PNMReader *reader) { return pfm.store(*this); } - // We reassign y_size after reading because we might have read a - // truncated file. + // We reassign y_size after reading because we might have read a truncated + // file. _y_size = reader->read_data(_array, _alpha); delete reader; @@ -408,13 +374,10 @@ read(PNMReader *reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::write -// Access: Published -// Description: Writes the image to the indicated filename. If type -// is non-NULL, it is a suggestion for the type of image -// file to write. -//////////////////////////////////////////////////////////////////// +/** + * Writes the image to the indicated filename. If type is non-NULL, it is a + * suggestion for the type of image file to write. + */ bool PNMImage:: write(const Filename &filename, PNMFileType *type) const { if (!is_valid()) { @@ -429,17 +392,15 @@ write(const Filename &filename, PNMFileType *type) const { return write(writer); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::write -// Access: Published -// Description: Writes the image to the indicated ostream. -// -// The filename is advisory only, and may be used -// suggest a type if it has a known extension. -// -// If type is non-NULL, it is a suggestion for the type -// of image file to write. -//////////////////////////////////////////////////////////////////// +/** + * Writes the image to the indicated ostream. + * + * The filename is advisory only, and may be used suggest a type if it has a + * known extension. + * + * If type is non-NULL, it is a suggestion for the type of image file to + * write. + */ bool PNMImage:: write(ostream &data, const string &filename, PNMFileType *type) const { if (!is_valid()) { @@ -455,16 +416,13 @@ write(ostream &data, const string &filename, PNMFileType *type) const { return write(writer); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::write -// Access: Published -// Description: This flavor of write() uses an already-existing -// PNMWriter to write the image file. You can get a -// writer via the PNMImageHeader::make_writer() methods. -// -// The PNMWriter is always deleted upon completion, -// whether successful or not. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of write() uses an already-existing PNMWriter to write the + * image file. You can get a writer via the PNMImageHeader::make_writer() + * methods. + * + * The PNMWriter is always deleted upon completion, whether successful or not. + */ bool PNMImage:: write(PNMWriter *writer) const { if (writer == NULL) { @@ -479,8 +437,8 @@ write(PNMWriter *writer) const { writer->copy_header_from(*this); if (!writer->supports_integer()) { - // Hmm, it's only a floating-point file type. Convert it from the - // integer data we have. + // Hmm, it's only a floating-point file type. Convert it from the integer + // data we have. PfmFile pfm; if (!pfm.load(*this)) { delete writer; @@ -506,16 +464,13 @@ write(PNMWriter *writer) const { return (result == _y_size); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_color_type -// Access: Published -// Description: Translates the image to or from grayscale, color, or -// four-color mode. Grayscale images are converted to -// full-color images with R, G, B set to the original -// gray level; color images are converted to grayscale -// according to the value of Bright(). The alpha -// channel, if added, is initialized to zero. -//////////////////////////////////////////////////////////////////// +/** + * Translates the image to or from grayscale, color, or four-color mode. + * Grayscale images are converted to full-color images with R, G, B set to the + * original gray level; color images are converted to grayscale according to + * the value of Bright(). The alpha channel, if added, is initialized to + * zero. + */ void PNMImage:: set_color_type(PNMImage::ColorType color_type) { nassertv((int)color_type >= 1 && (int)color_type <= 4); @@ -558,25 +513,20 @@ set_color_type(PNMImage::ColorType color_type) { setup_rc(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_color_space -// Access: Published -// Description: Converts the colors in the image to the indicated -// color space. This may be a lossy operation, in -// particular when going from sRGB to linear. -// The alpha channel remains untouched. -// -// Note that, because functions like get_xel() and -// set_xel() work on linearized floating-point values, -// this conversion won't affect those values (aside -// from some minor discrepancies due to storage -// precision). It does affect the values used by -// get_xel_val() and set_xel_val(), though, since -// those operate on encoded colors. -// -// Some color spaces, particularly scRGB, may enforce -// the use of a particular maxval setting. -//////////////////////////////////////////////////////////////////// +/** + * Converts the colors in the image to the indicated color space. This may be + * a lossy operation, in particular when going from sRGB to linear. The alpha + * channel remains untouched. + * + * Note that, because functions like get_xel() and set_xel() work on + * linearized floating-point values, this conversion won't affect those values + * (aside from some minor discrepancies due to storage precision). It does + * affect the values used by get_xel_val() and set_xel_val(), though, since + * those operate on encoded colors. + * + * Some color spaces, particularly scRGB, may enforce the use of a particular + * maxval setting. + */ void PNMImage:: set_color_space(ColorSpace color_space) { nassertv(color_space != CS_unspecified); @@ -653,15 +603,11 @@ set_color_space(ColorSpace color_space) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::make_grayscale -// Access: Published -// Description: Converts the image from RGB to grayscale. Any alpha -// channel, if present, is left undisturbed. The -// optional rc, gc, bc values represent the relative -// weights to apply to each channel to convert it to -// grayscale. -//////////////////////////////////////////////////////////////////// +/** + * Converts the image from RGB to grayscale. Any alpha channel, if present, + * is left undisturbed. The optional rc, gc, bc values represent the relative + * weights to apply to each channel to convert it to grayscale. + */ void PNMImage:: make_grayscale(float rc, float gc, float bc) { if (is_grayscale()) { @@ -679,16 +625,13 @@ make_grayscale(float rc, float gc, float bc) { setup_rc(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::premultiply_alpha -// Access: Published -// Description: Converts an image in-place to its "premultiplied" -// form, where, for every pixel in the image, the -// red, green, and blue components are multiplied by -// that pixel's alpha value. -// -// This does not modify any alpha values. -//////////////////////////////////////////////////////////////////// +/** + * Converts an image in-place to its "premultiplied" form, where, for every + * pixel in the image, the red, green, and blue components are multiplied by + * that pixel's alpha value. + * + * This does not modify any alpha values. + */ void PNMImage:: premultiply_alpha() { if (!has_alpha()) { @@ -706,17 +649,13 @@ premultiply_alpha() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::unpremultiply_alpha -// Access: Published -// Description: Converts an image in-place to its "straight alpha" -// form (presumably from a "premultiplied" form), -// where, for every pixel in the image, the red, -// green, and blue components are divided by that -// pixel's alpha value. -// -// This does not modify any alpha values. -//////////////////////////////////////////////////////////////////// +/** + * Converts an image in-place to its "straight alpha" form (presumably from a + * "premultiplied" form), where, for every pixel in the image, the red, green, + * and blue components are divided by that pixel's alpha value. + * + * This does not modify any alpha values. + */ void PNMImage:: unpremultiply_alpha() { if (!has_alpha()) { @@ -736,11 +675,9 @@ unpremultiply_alpha() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::reverse_rows -// Access: Published -// Description: Performs an in-place reversal of the row (y) data. -//////////////////////////////////////////////////////////////////// +/** + * Performs an in-place reversal of the row (y) data. + */ void PNMImage:: reverse_rows() { if (_array != NULL) { @@ -764,17 +701,13 @@ reverse_rows() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::flip -// Access: Published -// Description: Reverses, transposes, and/or rotates the image -// in-place according to the specified parameters. If -// flip_x is true, the x axis is reversed; if flip_y is -// true, the y axis is reversed. Then, if transpose is -// true, the x and y axes are exchanged. These -// parameters can be used to select any combination of -// 90-degree or 180-degree rotations and flips. -//////////////////////////////////////////////////////////////////// +/** + * Reverses, transposes, and/or rotates the image in-place according to the + * specified parameters. If flip_x is true, the x axis is reversed; if flip_y + * is true, the y axis is reversed. Then, if transpose is true, the x and y + * axes are exchanged. These parameters can be used to select any combination + * of 90-degree or 180-degree rotations and flips. + */ void PNMImage:: flip(bool flip_x, bool flip_y, bool transpose) { if (transpose) { @@ -851,11 +784,9 @@ flip(bool flip_x, bool flip_y, bool transpose) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_maxval -// Access: Published -// Description: Rescales the image to the indicated maxval. -//////////////////////////////////////////////////////////////////// +/** + * Rescales the image to the indicated maxval. + */ void PNMImage:: set_maxval(xelval maxval) { nassertv(maxval > 0); @@ -892,17 +823,13 @@ set_maxval(xelval maxval) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_channel_val -// Access: Published -// Description: Returns the nth component color at the indicated -// pixel. The channel index should be in the range -// 0..(get_num_channels()-1). The channels are ordered B, -// G, R, A. This is slightly less optimal than -// accessing the component values directly by named -// methods. The value returned is in the range -// 0..maxval. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth component color at the indicated pixel. The channel index + * should be in the range 0..(get_num_channels()-1). The channels are ordered + * B, G, R, A. This is slightly less optimal than accessing the component + * values directly by named methods. The value returned is in the range + * 0..maxval. + */ xelval PNMImage:: get_channel_val(int x, int y, int channel) const { switch (channel) { @@ -927,17 +854,13 @@ get_channel_val(int x, int y, int channel) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_channel_val -// Access: Published -// Description: Sets the nth component color at the indicated -// pixel. The channel index should be in the range -// 0..(get_num_channels()-1). The channels are ordered B, -// G, R, A. This is slightly less optimal than -// setting the component values directly by named -// methods. The value given should be in the range -// 0..maxval. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth component color at the indicated pixel. The channel index + * should be in the range 0..(get_num_channels()-1). The channels are ordered + * B, G, R, A. This is slightly less optimal than setting the component + * values directly by named methods. The value given should be in the range + * 0..maxval. + */ void PNMImage:: set_channel_val(int x, int y, int channel, xelval value) { switch (channel) { @@ -966,17 +889,13 @@ set_channel_val(int x, int y, int channel, xelval value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_channel -// Access: Published -// Description: Returns the nth component color at the indicated -// pixel. The channel index should be in the range -// 0..(get_num_channels()-1). The channels are ordered B, -// G, R, A. This is slightly less optimal than -// accessing the component values directly by named -// methods. The value returned is a float in the range -// 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth component color at the indicated pixel. The channel index + * should be in the range 0..(get_num_channels()-1). The channels are ordered + * B, G, R, A. This is slightly less optimal than accessing the component + * values directly by named methods. The value returned is a float in the + * range 0..1. + */ float PNMImage:: get_channel(int x, int y, int channel) const { switch (channel) { @@ -1001,17 +920,13 @@ get_channel(int x, int y, int channel) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_channel -// Access: Published -// Description: Sets the nth component color at the indicated -// pixel. The channel index should be in the range -// 0..(get_num_channels()-1). The channels are ordered B, -// G, R, A. This is slightly less optimal than -// setting the component values directly by named -// methods. The value given should be a float in the -// range 0..1. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth component color at the indicated pixel. The channel index + * should be in the range 0..(get_num_channels()-1). The channels are ordered + * B, G, R, A. This is slightly less optimal than setting the component + * values directly by named methods. The value given should be a float in the + * range 0..1. + */ void PNMImage:: set_channel(int x, int y, int channel, float value) { switch (channel) { @@ -1040,12 +955,10 @@ set_channel(int x, int y, int channel, float value) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_pixel -// Access: Published -// Description: Returns the (r, g, b, a) pixel value at the indicated -// pixel, using a PixelSpec object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the (r, g, b, a) pixel value at the indicated pixel, using a + * PixelSpec object. + */ PNMImage::PixelSpec PNMImage:: get_pixel(int x, int y) const { switch (_num_channels) { @@ -1062,12 +975,10 @@ get_pixel(int x, int y) const { return PixelSpec(0); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_pixel -// Access: Published -// Description: Sets the (r, g, b, a) pixel value at the indicated -// pixel, using a PixelSpec object. -//////////////////////////////////////////////////////////////////// +/** + * Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec + * object. + */ void PNMImage:: set_pixel(int x, int y, const PixelSpec &pixel) { xel p; @@ -1078,15 +989,12 @@ set_pixel(int x, int y, const PixelSpec &pixel) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::blend -// Access: Published -// Description: Smoothly blends the indicated pixel value in with -// whatever was already in the image, based on the given -// alpha value. An alpha of 1.0 is fully opaque and -// completely replaces whatever was there previously; -// alpha of 0.0 is fully transparent and does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Smoothly blends the indicated pixel value in with whatever was already in + * the image, based on the given alpha value. An alpha of 1.0 is fully opaque + * and completely replaces whatever was there previously; alpha of 0.0 is + * fully transparent and does nothing. + */ void PNMImage:: blend(int x, int y, float r, float g, float b, float alpha) { if (alpha >= 1.0) { @@ -1121,18 +1029,14 @@ blend(int x, int y, float r, float g, float b, float alpha) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_array -// Access: Public -// Description: Replaces the underlying PNMImage array with the -// indicated pointer. Know what you are doing! The new -// array must be the correct size and must have been -// allocated via PANDA_MALLOC_ARRAY(). The PNMImage -// object becomes the owner of this pointer and will -// eventually free it with PANDA_FREE_ARRAY(). The -// previous array, if any, will be freed with -// PANDA_FREE_ARRAY() when this call is made. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the underlying PNMImage array with the indicated pointer. Know + * what you are doing! The new array must be the correct size and must have + * been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes the + * owner of this pointer and will eventually free it with PANDA_FREE_ARRAY(). + * The previous array, if any, will be freed with PANDA_FREE_ARRAY() when this + * call is made. + */ void PNMImage:: set_array(xel *array) { if (_array != (xel *)NULL) { @@ -1141,18 +1045,14 @@ set_array(xel *array) { _array = array; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::set_alpha_array -// Access: Public -// Description: Replaces the underlying PNMImage alpha array with the -// indicated pointer. Know what you are doing! The new -// array must be the correct size and must have been -// allocated via PANDA_MALLOC_ARRAY(). The PNMImage -// object becomes the owner of this pointer and will -// eventually free it with PANDA_FREE_ARRAY(). The -// previous array, if any, will be freed with -// PANDA_FREE_ARRAY() when this call is made. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the underlying PNMImage alpha array with the indicated pointer. + * Know what you are doing! The new array must be the correct size and must + * have been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes + * the owner of this pointer and will eventually free it with + * PANDA_FREE_ARRAY(). The previous array, if any, will be freed with + * PANDA_FREE_ARRAY() when this call is made. + */ void PNMImage:: set_alpha_array(xelval *alpha) { if (_alpha != (xelval *)NULL) { @@ -1161,17 +1061,13 @@ set_alpha_array(xelval *alpha) { _alpha = alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_sub_image -// Access: Published -// Description: Copies a rectangular area of another image into a -// rectangular area of this image. Both images must -// already have been initialized. The upper-left corner -// of the region in both images is specified, and the -// size of the area; if the size is omitted, it defaults -// to the entire other image, or the largest piece that -// will fit. -//////////////////////////////////////////////////////////////////// +/** + * Copies a rectangular area of another image into a rectangular area of this + * image. Both images must already have been initialized. The upper-left + * corner of the region in both images is specified, and the size of the area; + * if the size is omitted, it defaults to the entire other image, or the + * largest piece that will fit. + */ void PNMImage:: copy_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) { @@ -1216,21 +1112,17 @@ copy_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::blend_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the alpha -// channel of the copy is used to blend the copy into -// the destination image, instead of overwriting pixels -// unconditionally. -// -// If pixel_scale is not 1.0, it specifies an amount to -// scale each *alpha* value of the source image before -// applying it to the target image. -// -// If pixel_scale is 1.0 and the copy has no alpha -// channel, this degenerates into copy_sub_image(). -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the alpha channel of the copy is used + * to blend the copy into the destination image, instead of overwriting pixels + * unconditionally. + * + * If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* + * value of the source image before applying it to the target image. + * + * If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates + * into copy_sub_image(). + */ void PNMImage:: blend_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -1262,15 +1154,11 @@ blend_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::add_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the copy pixels -// are added to the pixels of the destination, after -// scaling by the specified pixel_scale. Unlike -// blend_sub_image(), the alpha channel is not treated -// specially. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the copy pixels are added to the + * pixels of the destination, after scaling by the specified pixel_scale. + * Unlike blend_sub_image(), the alpha channel is not treated specially. + */ void PNMImage:: add_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -1300,15 +1188,11 @@ add_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::mult_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), except the copy pixels -// are multiplied to the pixels of the destination, after -// scaling by the specified pixel_scale. Unlike -// blend_sub_image(), the alpha channel is not treated -// specially. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), except the copy pixels are multiplied to the + * pixels of the destination, after scaling by the specified pixel_scale. + * Unlike blend_sub_image(), the alpha channel is not treated specially. + */ void PNMImage:: mult_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -1338,20 +1222,16 @@ mult_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::darken_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), but the resulting -// color will be the darker of the source and -// destination colors at each pixel (and at each R, G, -// B, A component value). -// -// If pixel_scale is not 1.0, it specifies an amount to -// scale each pixel value of the source image before -// applying it to the target image. The scale is -// applied with the center at 1.0: scaling the pixel -// value smaller brings it closer to 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), but the resulting color will be the darker + * of the source and destination colors at each pixel (and at each R, G, B, A + * component value). + * + * If pixel_scale is not 1.0, it specifies an amount to scale each pixel value + * of the source image before applying it to the target image. The scale is + * applied with the center at 1.0: scaling the pixel value smaller brings it + * closer to 1.0. + */ void PNMImage:: darken_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -1411,18 +1291,14 @@ darken_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::lighten_sub_image -// Access: Published -// Description: Behaves like copy_sub_image(), but the resulting -// color will be the lighter of the source and -// destination colors at each pixel (and at each R, G, -// B, A component value). -// -// If pixel_scale is not 1.0, it specifies an amount to -// scale each pixel value of the source image before -// applying it to the target image. -//////////////////////////////////////////////////////////////////// +/** + * Behaves like copy_sub_image(), but the resulting color will be the lighter + * of the source and destination colors at each pixel (and at each R, G, B, A + * component value). + * + * If pixel_scale is not 1.0, it specifies an amount to scale each pixel value + * of the source image before applying it to the target image. + */ void PNMImage:: lighten_sub_image(const PNMImage ©, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, @@ -1482,28 +1358,23 @@ lighten_sub_image(const PNMImage ©, int xto, int yto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::threshold -// Access: Published -// Description: Selectively copies each pixel from either one source -// or another source, depending on the pixel value of -// the indicated channel of select_image. -// -// For each pixel (x, y): -// -// s = select_image.get_channel(x, y, channel). Set this -// image's (x, y) to: -// -// lt.get_xel(x, y) if s < threshold, or -// -// ge.get_xel(x, y) if s >= threshold -// -// Any of select_image, lt, or ge may be the same -// PNMImge object as this image, or the same as each -// other; or they may all be different. All images must -// be the same size. As a special case, lt and ge may -// both be 1x1 images instead of the source image size. -//////////////////////////////////////////////////////////////////// +/** + * Selectively copies each pixel from either one source or another source, + * depending on the pixel value of the indicated channel of select_image. + * + * For each pixel (x, y): + * + * s = select_image.get_channel(x, y, channel). Set this image's (x, y) to: + * + * lt.get_xel(x, y) if s < threshold, or + * + * ge.get_xel(x, y) if s >= threshold + * + * Any of select_image, lt, or ge may be the same PNMImge object as this + * image, or the same as each other; or they may all be different. All images + * must be the same size. As a special case, lt and ge may both be 1x1 images + * instead of the source image size. + */ void PNMImage:: threshold(const PNMImage &select_image, int channel, float threshold, const PNMImage <, const PNMImage &ge) { @@ -1514,8 +1385,8 @@ threshold(const PNMImage &select_image, int channel, float threshold, if (lt.get_x_size() == 1 && lt.get_y_size() == 1 && ge.get_x_size() == 1 && ge.get_y_size() == 1) { - // FIXME: what if select_image has different color space? - // 1x1 source images. + // FIXME: what if select_image has different color space? 1x1 source + // images. xel lt_val = lt.get_xel_val(0, 0); xelval lt_alpha = 0; if (lt.has_alpha()) { @@ -1674,7 +1545,8 @@ threshold(const PNMImage &select_image, int channel, float threshold, } } else { - // General case: the maxvals are different. Copy by floating-point value. + // General case: the maxvals are different. Copy by floating-point + // value. int x, y; if (has_alpha() && lt.has_alpha() && ge.has_alpha()) { @@ -1704,29 +1576,23 @@ threshold(const PNMImage &select_image, int channel, float threshold, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill_distance_inside -// Access: Published -// Description: Replaces this image with a grayscale image whose gray -// channel represents the linear Manhattan distance from -// the nearest dark pixel in the given mask image, up to -// the specified radius value (which also becomes the -// new maxval). radius may range from 0 to maxmaxval; -// smaller values will compute faster. A dark pixel is -// defined as one whose pixel value is < threshold. -// -// If shrink_from_border is true, then the mask image is -// considered to be surrounded by a border of dark -// pixels; otherwise, the border isn't considered. -// -// This can be used, in conjunction with threshold, to -// shrink a mask image inwards by a certain number of -// pixels. -// -// The mask image may be the same image as this one, in -// which case it is destructively modified by this -// process. -//////////////////////////////////////////////////////////////////// +/** + * Replaces this image with a grayscale image whose gray channel represents + * the linear Manhattan distance from the nearest dark pixel in the given mask + * image, up to the specified radius value (which also becomes the new + * maxval). radius may range from 0 to maxmaxval; smaller values will compute + * faster. A dark pixel is defined as one whose pixel value is < threshold. + * + * If shrink_from_border is true, then the mask image is considered to be + * surrounded by a border of dark pixels; otherwise, the border isn't + * considered. + * + * This can be used, in conjunction with threshold, to shrink a mask image + * inwards by a certain number of pixels. + * + * The mask image may be the same image as this one, in which case it is + * destructively modified by this process. + */ void PNMImage:: fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shrink_from_border) { nassertv(radius <= PNM_MAXMAXVAL); @@ -1758,25 +1624,19 @@ fill_distance_inside(const PNMImage &mask, float threshold, int radius, bool shr take_from(dist); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::fill_distance_outside -// Access: Published -// Description: Replaces this image with a grayscale image whose gray -// channel represents the linear Manhattan distance from -// the nearest white pixel in the given mask image, up to -// the specified radius value (which also becomes the -// new maxval). radius may range from 0 to maxmaxval; -// smaller values will compute faster. A white pixel is -// defined as one whose pixel value is >= threshold. -// -// This can be used, in conjunction with threshold, to -// grow a mask image outwards by a certain number of -// pixels. -// -// The mask image may be the same image as this one, in -// which case it is destructively modified by this -// process. -//////////////////////////////////////////////////////////////////// +/** + * Replaces this image with a grayscale image whose gray channel represents + * the linear Manhattan distance from the nearest white pixel in the given + * mask image, up to the specified radius value (which also becomes the new + * maxval). radius may range from 0 to maxmaxval; smaller values will compute + * faster. A white pixel is defined as one whose pixel value is >= threshold. + * + * This can be used, in conjunction with threshold, to grow a mask image + * outwards by a certain number of pixels. + * + * The mask image may be the same image as this one, in which case it is + * destructively modified by this process. + */ void PNMImage:: fill_distance_outside(const PNMImage &mask, float threshold, int radius) { nassertv(radius <= PNM_MAXMAXVAL); @@ -1796,25 +1656,20 @@ fill_distance_outside(const PNMImage &mask, float threshold, int radius) { take_from(dist); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::indirect_1d_lookup -// Access: Published -// Description: index_image is a WxH grayscale image, while -// pixel_values is an Nx1 color (or grayscale) image. -// Typically pixel_values will be a 256x1 image. -// -// Fills the PNMImage with a new image the same width -// and height as index_image, with the same number of -// channels as pixel_values. -// -// Each pixel of the new image is computed with the -// formula: -// -// new_image(x, y) = pixel_values(index_image(x, y)[channel], 0) -// -// No interpolation is performed; the nearest value in -// pixel_values is discovered. -//////////////////////////////////////////////////////////////////// +/** + * index_image is a WxH grayscale image, while pixel_values is an Nx1 color + * (or grayscale) image. Typically pixel_values will be a 256x1 image. + * + * Fills the PNMImage with a new image the same width and height as + * index_image, with the same number of channels as pixel_values. + * + * Each pixel of the new image is computed with the formula: + * + * new_image(x, y) = pixel_values(index_image(x, y)[channel], 0) + * + * No interpolation is performed; the nearest value in pixel_values is + * discovered. + */ void PNMImage:: indirect_1d_lookup(const PNMImage &index_image, int channel, const PNMImage &pixel_values) { @@ -1833,15 +1688,12 @@ indirect_1d_lookup(const PNMImage &index_image, int channel, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::rescale -// Access: Published -// Description: Rescales the RGB channel values so that any values in -// the original image between min_val and max_val are -// expanded to the range 0 .. 1. Values below min_val -// are set to 0, and values above max_val are set to 1. -// Does not affect the alpha channel, if any. -//////////////////////////////////////////////////////////////////// +/** + * Rescales the RGB channel values so that any values in the original image + * between min_val and max_val are expanded to the range 0 .. 1. Values below + * min_val are set to 0, and values above max_val are set to 1. Does not + * affect the alpha channel, if any. + */ void PNMImage:: rescale(float min_val, float max_val) { float scale = max_val - min_val; @@ -1868,13 +1720,10 @@ rescale(float min_val, float max_val) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::copy_channel -// Access: Published -// Description: Copies just a single channel from the source image -// into a single channel of this image, leaving the -// remaining channels alone. -//////////////////////////////////////////////////////////////////// +/** + * Copies just a single channel from the source image into a single channel of + * this image, leaving the remaining channels alone. + */ void PNMImage:: copy_channel(const PNMImage ©, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom, @@ -1922,20 +1771,15 @@ copy_channel(const PNMImage ©, int xto, int yto, int cto, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::render_spot -// Access: Published -// Description: Renders a solid-color circle, with a fuzzy edge, into -// the center of the PNMImage. If the PNMImage is -// non-square, this actually renders an ellipse. -// -// The min_radius and max_radius are in the scale 0..1, -// where 1.0 means the full width of the image. If -// min_radius == max_radius, the edge is sharp (but -// still antialiased); otherwise, the pixels between -// min_radius and max_radius are smoothly blended -// between fg and bg colors. -//////////////////////////////////////////////////////////////////// +/** + * Renders a solid-color circle, with a fuzzy edge, into the center of the + * PNMImage. If the PNMImage is non-square, this actually renders an ellipse. + * + * The min_radius and max_radius are in the scale 0..1, where 1.0 means the + * full width of the image. If min_radius == max_radius, the edge is sharp + * (but still antialiased); otherwise, the pixels between min_radius and + * max_radius are smoothly blended between fg and bg colors. + */ void PNMImage:: render_spot(const LColorf &fg, const LColorf &bg, float min_radius, float max_radius) { @@ -1946,8 +1790,8 @@ render_spot(const LColorf &fg, const LColorf &bg, float x_scale = 2.0 / _x_size; float y_scale = 2.0 / _y_size; - // If the width is even, x_center1 == x_center0. If the width is - // odd, x_center1 == x_center0 + 1. + // If the width is even, x_center1 == x_center0. If the width is odd, + // x_center1 == x_center0 + 1. int x_center0 = _x_size / 2; int y_center0 = _y_size / 2; int x_center1 = (_x_size + 1) / 2; @@ -2008,16 +1852,12 @@ render_spot(const LColorf &fg, const LColorf &bg, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::expand_border -// Access: Published -// Description: Expands the image by the indicated number of pixels -// on each edge. The new pixels are set to the -// indicated color. -// -// If any of the values is negative, this actually crops -// the image. -//////////////////////////////////////////////////////////////////// +/** + * Expands the image by the indicated number of pixels on each edge. The new + * pixels are set to the indicated color. + * + * If any of the values is negative, this actually crops the image. + */ void PNMImage:: expand_border(int left, int right, int bottom, int top, const LColorf &color) { @@ -2034,12 +1874,10 @@ expand_border(int left, int right, int bottom, int top, take_from(new_image); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::unfiltered_stretch_from -// Access: Published -// Description: Resizes from the indicated image into this one by -// performing a nearest-point sample. -//////////////////////////////////////////////////////////////////// +/** + * Resizes from the indicated image into this one by performing a nearest- + * point sample. + */ void PNMImage:: unfiltered_stretch_from(const PNMImage ©) { for (int yt = 0; yt < get_y_size(); yt++) { @@ -2061,12 +1899,9 @@ unfiltered_stretch_from(const PNMImage ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::make_histogram -// Access: Published -// Description: Computes a histogram of the colors used in the -// image. -//////////////////////////////////////////////////////////////////// +/** + * Computes a histogram of the colors used in the image. + */ void PNMImage:: make_histogram(PNMImage::Histogram &histogram) { HistMap hist_map; @@ -2088,16 +1923,12 @@ make_histogram(PNMImage::Histogram &histogram) { histogram.swap(pixels, hist_map); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::perlin_noise_fill -// Access: Published -// Description: Fills the image with a grayscale perlin noise -// pattern based on the indicated parameters. -// Uses set_xel to set the grayscale values. -// The sx and sy parameters are in multiples -// of the size of this image. -// See also the PerlinNoise2 class in mathutil. -//////////////////////////////////////////////////////////////////// +/** + * Fills the image with a grayscale perlin noise pattern based on the + * indicated parameters. Uses set_xel to set the grayscale values. The sx + * and sy parameters are in multiples of the size of this image. See also the + * PerlinNoise2 class in mathutil. + */ void PNMImage:: perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed) { float x, y; @@ -2111,12 +1942,10 @@ perlin_noise_fill(float sx, float sy, int table_size, unsigned long seed) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::perlin_noise_fill -// Access: Published -// Description: Variant of perlin_noise_fill that uses an -// existing StackedPerlinNoise2 object. -//////////////////////////////////////////////////////////////////// +/** + * Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 + * object. + */ void PNMImage:: perlin_noise_fill(StackedPerlinNoise2 &perlin) { float x, y; @@ -2129,13 +1958,10 @@ perlin_noise_fill(StackedPerlinNoise2 &perlin) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::remix_channels -// Access: Published -// Description: Transforms every pixel using the operation -// (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); -// Input must be a color image. -//////////////////////////////////////////////////////////////////// +/** + * Transforms every pixel using the operation (Ro,Go,Bo) = + * conv.xform_point(Ri,Gi,Bi); Input must be a color image. + */ void PNMImage:: remix_channels(const LMatrix4 &conv) { int nchannels = get_num_channels(); @@ -2149,16 +1975,12 @@ remix_channels(const LMatrix4 &conv) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::apply_exponent -// Access: Published -// Description: Adjusts each channel of the image by raising the -// corresponding component value to the indicated -// exponent, such that L' = L ^ exponent. For a -// grayscale image, the blue_exponent value is used for -// the grayscale value, and red_exponent and -// green_exponent are unused. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts each channel of the image by raising the corresponding component + * value to the indicated exponent, such that L' = L ^ exponent. For a + * grayscale image, the blue_exponent value is used for the grayscale value, + * and red_exponent and green_exponent are unused. + */ void PNMImage:: apply_exponent(float red_exponent, float green_exponent, float blue_exponent, float alpha_exponent) { @@ -2190,7 +2012,7 @@ apply_exponent(float red_exponent, float green_exponent, float blue_exponent, } } else { - // Apply to the color and/or alpha channels. + // Apply to the color andor alpha channels. switch (num_channels) { case 1: @@ -2245,14 +2067,11 @@ apply_exponent(float red_exponent, float green_exponent, float blue_exponent, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::setup_rc -// Access: Private -// Description: Sets the _default_rc,bc,gc values appropriately -// according to the color type of the image, so that -// get_bright() will return a meaningful value for both -// color and grayscale images. -//////////////////////////////////////////////////////////////////// +/** + * Sets the _default_rc,bc,gc values appropriately according to the color type + * of the image, so that get_bright() will return a meaningful value for both + * color and grayscale images. + */ void PNMImage:: setup_rc() { if (is_grayscale()) { @@ -2266,16 +2085,12 @@ setup_rc() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::setup_encoding -// Access: Private -// Description: Sets the _xel_encoding value apppropriately -// according to the color space, maxval and whether -// the image has an alpha channel, so that to_val and -// from_val will work correctly (and possibly more -// efficiently). -// Should be called after any call to set_maxval. -//////////////////////////////////////////////////////////////////// +/** + * Sets the _xel_encoding value apppropriately according to the color space, + * maxval and whether the image has an alpha channel, so that to_val and + * from_val will work correctly (and possibly more efficiently). Should be + * called after any call to set_maxval. + */ void PNMImage:: setup_encoding() { if (_maxval == 0) { @@ -2341,12 +2156,10 @@ setup_encoding() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::do_fill_distance -// Access: Private -// Description: Recursively fills in the minimum distance measured -// from a certain set of points into the gray channel. -//////////////////////////////////////////////////////////////////// +/** + * Recursively fills in the minimum distance measured from a certain set of + * points into the gray channel. + */ void PNMImage:: do_fill_distance(int xi, int yi, int d) { if (xi < 0 || xi >= get_x_size() || @@ -2364,12 +2177,9 @@ do_fill_distance(int xi, int yi, int d) { do_fill_distance(xi, yi - 1, d + 1); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_average_xel -// Access: Published -// Description: Returns the average color of all of the pixels -// in the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average color of all of the pixels in the image. + */ LRGBColorf PNMImage:: get_average_xel() const { LRGBColorf color (LRGBColorf::zero()); @@ -2389,12 +2199,10 @@ get_average_xel() const { return color; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_average_xel_a -// Access: Published -// Description: Returns the average color of all of the pixels -// in the image, including the alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average color of all of the pixels in the image, including the + * alpha channel. + */ LColorf PNMImage:: get_average_xel_a() const { LColorf color (LColorf::zero()); @@ -2414,12 +2222,9 @@ get_average_xel_a() const { return color; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::get_average_gray -// Access: Published -// Description: Returns the average grayscale component of all of -// the pixels in the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average grayscale component of all of the pixels in the image. + */ float PNMImage:: get_average_gray() const { float gray = 0.0; @@ -2438,13 +2243,10 @@ get_average_gray() const { return gray; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator ~ -// Access: Published -// Description: Returns a new PNMImage that is the complement of -// this PNMImage. This operation is not color-space -// correct. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new PNMImage that is the complement of this PNMImage. This + * operation is not color-space correct. + */ PNMImage PNMImage:: operator ~ () const { PNMImage target (*this); @@ -2471,13 +2273,10 @@ operator ~ () const { return target; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator += -// Access: Published -// Description: Sets each pixel value to the sum of the corresponding -// pixel values in the two given images. Only valid -// when both images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Sets each pixel value to the sum of the corresponding pixel values in the + * two given images. Only valid when both images have the same size. + */ void PNMImage:: operator += (const PNMImage &other) { nassertv(is_valid() && other.is_valid()); @@ -2514,11 +2313,9 @@ operator += (const PNMImage &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator += -// Access: Published -// Description: Adds the provided color to each pixel in this image. -//////////////////////////////////////////////////////////////////// +/** + * Adds the provided color to each pixel in this image. + */ void PNMImage:: operator += (const LColorf &other) { nassertv(is_valid()); @@ -2558,13 +2355,10 @@ operator += (const LColorf &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator -= -// Access: Published -// Description: Subtracts each pixel from the right image from each -// pixel value in this image. Only valid when both -// images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts each pixel from the right image from each pixel value in this + * image. Only valid when both images have the same size. + */ void PNMImage:: operator -= (const PNMImage &other) { nassertv(is_valid() && other.is_valid()); @@ -2601,26 +2395,20 @@ operator -= (const PNMImage &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator -= -// Access: Published -// Description: Subtracts the provided color from each pixel in this -// image. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts the provided color from each pixel in this image. + */ void PNMImage:: operator -= (const LColorf &other) { (*this) += -other; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator *= -// Access: Published -// Description: Multiples each pixel in this image by each -// pixel value from the right image. Note that the -// floating-point values in the 0..1 range are -// multiplied, not in the 0..maxval range. -// Only valid when both images have the same size. -//////////////////////////////////////////////////////////////////// +/** + * Multiples each pixel in this image by each pixel value from the right + * image. Note that the floating-point values in the 0..1 range are + * multiplied, not in the 0..maxval range. Only valid when both images have + * the same size. + */ void PNMImage:: operator *= (const PNMImage &other) { nassertv(is_valid() && other.is_valid()); @@ -2634,13 +2422,10 @@ operator *= (const PNMImage &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator *= -// Access: Published -// Description: Multiplies every pixel value in the image by -// a constant floating-point multiplier value. This -// affects all channels. -//////////////////////////////////////////////////////////////////// +/** + * Multiplies every pixel value in the image by a constant floating-point + * multiplier value. This affects all channels. + */ void PNMImage:: operator *= (float multiplier) { nassertv(is_valid()); @@ -2674,12 +2459,10 @@ operator *= (float multiplier) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMImage::operator *= -// Access: Published -// Description: Multiplies the provided color to each pixel in this -// image. This is a component-wise multiplication. -//////////////////////////////////////////////////////////////////// +/** + * Multiplies the provided color to each pixel in this image. This is a + * component-wise multiplication. + */ void PNMImage:: operator *= (const LColorf &other) { nassertv(is_valid()); diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index 300e20442c..6c32d42225 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -1,16 +1,15 @@ -// Filename: pnmImage.h -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImage.h + * @author drose + * @date 2000-06-14 + */ #ifndef PNMIMAGE_H #define PNMIMAGE_H @@ -27,44 +26,35 @@ class PNMReader; class PNMWriter; class PNMFileType; -//////////////////////////////////////////////////////////////////// -// Class : PNMImage -// Description : The name of this class derives from the fact that we -// originally implemented it as a layer on top of the -// "pnm library", based on netpbm, which was built to -// implement pbm, pgm, and pbm files, and is the -// underlying support of a number of public-domain image -// file converters. Nowadays we are no longer derived -// directly from the pnm library, mainly to allow -// support of C++ iostreams instead of the C stdio FILE -// interface. -// -// Conceptually, a PNMImage is a two-dimensional array -// of xels, which are the PNM-defined generic pixel -// type. Each xel may have a red, green, and blue -// component, or (if the image is grayscale) a gray -// component. The image may be read in, the individual -// xels manipulated, and written out again, or a black -// image may be constructed from scratch. -// -// A PNMImage has a color space and a maxval, the -// combination of which defines how a floating-point -// linear color value is encoded as an integer value in -// memory. The functions ending in _val operate on -// encoded colors, whereas the regular ones work with -// linear floating-point values. All operations are -// color space correct unless otherwise specified. -// -// The image is of size XSize() by YSize() xels, -// numbered from top to bottom, left to right, beginning -// at zero. -// -// Files can be specified by filename, or by an iostream -// pointer. The filename "-" refers to stdin or stdout. -// -// This class is not inherently thread-safe; use it -// from a single thread or protect access using a mutex. -//////////////////////////////////////////////////////////////////// +/** + * The name of this class derives from the fact that we originally implemented + * it as a layer on top of the "pnm library", based on netpbm, which was built + * to implement pbm, pgm, and pbm files, and is the underlying support of a + * number of public-domain image file converters. Nowadays we are no longer + * derived directly from the pnm library, mainly to allow support of C++ + * iostreams instead of the C stdio FILE interface. + * + * Conceptually, a PNMImage is a two-dimensional array of xels, which are the + * PNM-defined generic pixel type. Each xel may have a red, green, and blue + * component, or (if the image is grayscale) a gray component. The image may + * be read in, the individual xels manipulated, and written out again, or a + * black image may be constructed from scratch. + * + * A PNMImage has a color space and a maxval, the combination of which defines + * how a floating-point linear color value is encoded as an integer value in + * memory. The functions ending in _val operate on encoded colors, whereas + * the regular ones work with linear floating-point values. All operations + * are color space correct unless otherwise specified. + * + * The image is of size XSize() by YSize() xels, numbered from top to bottom, + * left to right, beginning at zero. + * + * Files can be specified by filename, or by an iostream pointer. The + * filename "-" refers to stdin or stdout. + * + * This class is not inherently thread-safe; use it from a single thread or + * protect access using a mutex. + */ class EXPCL_PANDA_PNMIMAGE PNMImage : public PNMImageHeader { PUBLISHED: INLINE PNMImage(); @@ -143,10 +133,10 @@ PUBLISHED: BLOCKING void set_maxval(xelval maxval); // The *_val() functions return or set the color values in the range - // [0..get_maxval()]. This range may be different for different - // images! Use the corresponding functions (without _val()) to work - // in the normalized range [0..1]. These return values in the - // image's stored color space. + // [0..get_maxval()]. This range may be different for different images! + // Use the corresponding functions (without _val()) to work in the + // normalized range [0..1]. These return values in the image's stored color + // space. INLINE xel &get_xel_val(int x, int y); INLINE xel get_xel_val(int x, int y) const; @@ -174,9 +164,9 @@ PUBLISHED: PixelSpec get_pixel(int x, int y) const; void set_pixel(int x, int y, const PixelSpec &pixel); - // The corresponding get_xel(), set_xel(), get_red(), etc. functions - // automatically scale their values by get_maxval() into the range - // [0..1], and into the linear color space. + // The corresponding get_xel(), set_xel(), get_red(), etc. functions + // automatically scale their values by get_maxval() into the range [0..1], + // and into the linear color space. INLINE LRGBColorf get_xel(int x, int y) const; INLINE void set_xel(int x, int y, const LRGBColorf &value); @@ -251,8 +241,8 @@ PUBLISHED: void expand_border(int left, int right, int bottom, int top, const LColorf &color); - // The bodies for the non-inline *_filter() functions can be found - // in the file pnm-image-filter.cxx. + // The bodies for the non-inline *_filter() functions can be found in the + // file pnm-image-filter.cxx. INLINE void box_filter(float radius = 1.0); INLINE void gaussian_filter(float radius = 1.0); @@ -283,8 +273,8 @@ PUBLISHED: void do_fill_distance(int xi, int yi, int d); PUBLISHED: - // Provides an accessor for reading or writing the contents of one row - // of the image in-place. + // Provides an accessor for reading or writing the contents of one row of + // the image in-place. class EXPCL_PANDA_PNMIMAGE Row { PUBLISHED: INLINE size_t size() const; @@ -305,8 +295,8 @@ PUBLISHED: int _y; }; - // Provides an accessor for reading the contents of one row of the - // image in-place. + // Provides an accessor for reading the contents of one row of the image in- + // place. class EXPCL_PANDA_PNMIMAGE CRow { PUBLISHED: INLINE size_t size() const; @@ -387,12 +377,12 @@ private: // The reciprocal of _maxval, as an optimization for from_val. float _inv_maxval; - // These method pointers contain the implementation for to_val and - // from_val, respectively, dependent on the maxval and color space. + // These method pointers contain the implementation for to_val and from_val, + // respectively, dependent on the maxval and color space. ColorSpace _color_space; - // The following enum determines which code path we should take in - // the set_xel and get_xel methods. + // The following enum determines which code path we should take in the + // set_xel and get_xel methods. enum XelEncoding { XE_generic, XE_generic_alpha, diff --git a/panda/src/pnmimage/pnmImageHeader.I b/panda/src/pnmimage/pnmImageHeader.I index 31a2997f15..fc62587986 100644 --- a/panda/src/pnmimage/pnmImageHeader.I +++ b/panda/src/pnmimage/pnmImageHeader.I @@ -1,22 +1,19 @@ -// Filename: pnmImageHeader.I -// Created by: drose (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImageHeader.I + * @author drose + * @date 2000-06-15 + */ -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader:: PNMImageHeader() { _x_size = 0; @@ -27,11 +24,9 @@ PNMImageHeader() { _type = (PNMFileType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader:: PNMImageHeader(const PNMImageHeader ©) : _x_size(copy._x_size), @@ -43,11 +38,9 @@ PNMImageHeader(const PNMImageHeader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader:: operator = (const PNMImageHeader ©) { _x_size = copy._x_size; @@ -59,231 +52,180 @@ operator = (const PNMImageHeader ©) { _type = copy._type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader:: ~PNMImageHeader() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_color_type -// Access: Published -// Description: Returns the image type of the image, as an enumerated -// value. This is really just the number of channels -// cast to the enumerated type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the image type of the image, as an enumerated value. This is + * really just the number of channels cast to the enumerated type. + */ INLINE PNMImageHeader::ColorType PNMImageHeader:: get_color_type() const { nassertr(_num_channels >= 1 && _num_channels <= 4, CT_invalid); return (ColorType)_num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_num_channels -// Access: Published -// Description: Returns the number of channels in the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of channels in the image. + */ INLINE int PNMImageHeader:: get_num_channels() const { nassertr(_num_channels >= 1 && _num_channels <= 4, 0); return _num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::is_grayscale -// Access: Published, Static -// Description: This static variant of is_grayscale() returns true if -// the indicated image type represents a grayscale -// image, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This static variant of is_grayscale() returns true if the indicated image + * type represents a grayscale image, false otherwise. + */ INLINE bool PNMImageHeader:: is_grayscale(PNMImageHeader::ColorType color_type) { return (color_type == CT_grayscale || color_type == CT_two_channel); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::is_grayscale -// Access: Published -// Description: Returns false if the image is a full-color image, and -// has red, green, and blue components; true if it is a -// grayscale image and has only a gray component. (The -// gray color is actually stored in the blue channel, -// and the red and green channels are ignored.) -//////////////////////////////////////////////////////////////////// +/** + * Returns false if the image is a full-color image, and has red, green, and + * blue components; true if it is a grayscale image and has only a gray + * component. (The gray color is actually stored in the blue channel, and the + * red and green channels are ignored.) + */ INLINE bool PNMImageHeader:: is_grayscale() const { return is_grayscale(get_color_type()); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::has_alpha -// Access: Published, Static -// Description: This static variant of has_alpha() returns true if -// the indicated image type includes an alpha channel, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * This static variant of has_alpha() returns true if the indicated image type + * includes an alpha channel, false otherwise. + */ INLINE bool PNMImageHeader:: has_alpha(PNMImageHeader::ColorType color_type) { return (color_type == CT_two_channel || color_type == CT_four_channel); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::has_alpha -// Access: Published -// Description: Returns true if the image includes an alpha channel, -// false otherwise. Unlike is_grayscale(), if this -// returns false it is an error to call any of the -// functions accessing the alpha channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the image includes an alpha channel, false otherwise. + * Unlike is_grayscale(), if this returns false it is an error to call any of + * the functions accessing the alpha channel. + */ INLINE bool PNMImageHeader:: has_alpha() const { return has_alpha(get_color_type()); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_maxval -// Access: Published -// Description: Returns the maximum channel value allowable for any -// pixel in this image; for instance, 255 for a typical -// 8-bit-per-channel image. A pixel with this value is -// full on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum channel value allowable for any pixel in this image; + * for instance, 255 for a typical 8-bit-per-channel image. A pixel with this + * value is full on. + */ INLINE xelval PNMImageHeader:: get_maxval() const { return _maxval; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_color_space -// Access: Published -// Description: Returns the color space that the image is encoded -// in, or CS_unspecified if unknown. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color space that the image is encoded in, or CS_unspecified if + * unknown. + */ INLINE ColorSpace PNMImageHeader:: get_color_space() const { return _color_space; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_x_size -// Access: Published -// Description: Returns the number of pixels in the X direction. -// This is one more than the largest allowable X -// coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels in the X direction. This is one more than the + * largest allowable X coordinate. + */ INLINE int PNMImageHeader:: get_x_size() const { return _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_y_size -// Access: Published -// Description: Returns the number of pixels in the Y direction. -// This is one more than the largest allowable Y -// coordinate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels in the Y direction. This is one more than the + * largest allowable Y coordinate. + */ INLINE int PNMImageHeader:: get_y_size() const { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_size -// Access: Published -// Description: Returns the number of pixels in each direction. -// This is one more than the largest allowable -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels in each direction. This is one more than the + * largest allowable coordinates. + */ INLINE LVecBase2i PNMImageHeader:: get_size() const { return LVecBase2i(_x_size, _y_size); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_comment -// Access: Published -// Description: Gets the user comment from the file. -//////////////////////////////////////////////////////////////////// +/** + * Gets the user comment from the file. + */ INLINE string PNMImageHeader:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::set_comment -// Access: Published -// Description: Writes a user comment string to the image (header). -//////////////////////////////////////////////////////////////////// +/** + * Writes a user comment string to the image (header). + */ INLINE void PNMImageHeader:: set_comment(const string& comment) { _comment = comment; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::has_type -// Access: Published -// Description: Returns true if the PNMImageHeader knows what type it -// is, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PNMImageHeader knows what type it is, false otherwise. + */ INLINE bool PNMImageHeader:: has_type() const { return _type != (PNMFileType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::get_type -// Access: Published -// Description: If the file type is known (e.g. has_type() returns -// true), returns its PNMFileType pointer; otherwise, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * If the file type is known (e.g. has_type() returns true), returns its + * PNMFileType pointer; otherwise, returns NULL. + */ INLINE PNMFileType *PNMImageHeader:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::set_type -// Access: Published -// Description: Sets the file type of this PNMImage. This will be -// the default type used when an image is read, if the -// type cannot be determined by magic number or inferred -// by extension, or the type used when the image is -// written, if the type cannot be inferred from the -// filename extension. -//////////////////////////////////////////////////////////////////// +/** + * Sets the file type of this PNMImage. This will be the default type used + * when an image is read, if the type cannot be determined by magic number or + * inferred by extension, or the type used when the image is written, if the + * type cannot be inferred from the filename extension. + */ INLINE void PNMImageHeader:: set_type(PNMFileType *type) { _type = type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::record_color -// Access: Protected -// Description: Records the indicated color in the histogram. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated color in the histogram. + */ INLINE void PNMImageHeader:: record_color(PNMImageHeader::HistMap &hist, const PNMImageHeader::PixelSpec &color) { - // First, try to add the color with a count of 0, in case it does - // not already exist in the table. + // First, try to add the color with a count of 0, in case it does not + // already exist in the table. HistMap::iterator hi = hist.insert(HistMap::value_type(color, 0)).first; // Now that either succeeded or failed, but either way hi is now the - // iterator to the count value in the table associated with the - // given color. Increment that count. + // iterator to the count value in the table associated with the given color. + // Increment that count. (*hi).second++; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(xelval gray_value) : _red(gray_value), @@ -293,11 +235,9 @@ PixelSpec(xelval gray_value) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(xelval gray_value, xelval alpha) : _red(gray_value), @@ -307,11 +247,9 @@ PixelSpec(xelval gray_value, xelval alpha) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(xelval red, xelval green, xelval blue) : _red(red), @@ -321,11 +259,9 @@ PixelSpec(xelval red, xelval green, xelval blue) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(xelval red, xelval green, xelval blue, xelval alpha) : _red(red), @@ -335,11 +271,9 @@ PixelSpec(xelval red, xelval green, xelval blue, xelval alpha) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(const xel &rgb) : _red(PPM_GETR(rgb)), @@ -349,11 +283,9 @@ PixelSpec(const xel &rgb) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(const xel &rgb, xelval alpha) : _red(PPM_GETR(rgb)), @@ -363,11 +295,9 @@ PixelSpec(const xel &rgb, xelval alpha) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpec:: PixelSpec(const PixelSpec ©) : _red(copy._red), @@ -377,11 +307,9 @@ PixelSpec(const PixelSpec ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader::PixelSpec:: operator = (const PixelSpec ©) { _red = copy._red; @@ -390,41 +318,33 @@ operator = (const PixelSpec ©) { _alpha = copy._alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PNMImageHeader::PixelSpec:: operator < (const PixelSpec &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PNMImageHeader::PixelSpec:: operator == (const PixelSpec &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PNMImageHeader::PixelSpec:: operator != (const PixelSpec &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::compare_to -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PNMImageHeader::PixelSpec:: compare_to(const PixelSpec &other) const { if (_red != other._red) { @@ -442,119 +362,95 @@ compare_to(const PixelSpec &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::get_red -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE xelval PNMImageHeader::PixelSpec:: get_red() const { return _red; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::get_green -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE xelval PNMImageHeader::PixelSpec:: get_green() const { return _green; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::get_blue -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE xelval PNMImageHeader::PixelSpec:: get_blue() const { return _blue; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::get_alpha -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE xelval PNMImageHeader::PixelSpec:: get_alpha() const { return _alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::set_red -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader::PixelSpec:: set_red(xelval red) { _red = red; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::set_green -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader::PixelSpec:: set_green(xelval green) { _green = green; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::set_blue -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader::PixelSpec:: set_blue(xelval blue) { _blue = blue; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::set_alpha -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMImageHeader::PixelSpec:: set_alpha(xelval alpha) { _alpha = alpha; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::operator [] -// Access: Published -// Description: Indexes numerically into the components, in the order -// R, G, B, A. This also makes the PixelSpec work like -// a tuple in Python. -//////////////////////////////////////////////////////////////////// +/** + * Indexes numerically into the components, in the order R, G, B, A. This + * also makes the PixelSpec work like a tuple in Python. + */ INLINE xelval PNMImageHeader::PixelSpec:: operator [](int n) const { nassertr(n >= 0 && n < size(), 0); return (&_red)[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::size -// Access: Published, Static -// Description: Specifies the number of components in the PixelSpec; -// this is always 4, regardless of the type of image it -// was taken from. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of components in the PixelSpec; this is always 4, + * regardless of the type of image it was taken from. + */ INLINE int PNMImageHeader::PixelSpec:: size() { return 4; } -// Interrogate seems to have some problem with the syntax of this -// method. Whatever, we don't need it. +// Interrogate seems to have some problem with the syntax of this method. +// Whatever, we don't need it. #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpecCount::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::PixelSpecCount:: PixelSpecCount(const PNMImageHeader::PixelSpec &pixel, int count) : _pixel(pixel), @@ -563,68 +459,53 @@ PixelSpecCount(const PNMImageHeader::PixelSpec &pixel, int count) : } #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpecCount::operator < -// Access: Public -// Description: Used to sort the pixels in order from most common to -// least common. -//////////////////////////////////////////////////////////////////// +/** + * Used to sort the pixels in order from most common to least common. + */ INLINE bool PNMImageHeader::PixelSpecCount:: operator < (const PNMImageHeader::PixelSpecCount &other) const { return _count > other._count; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMImageHeader::Histogram:: Histogram() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::get_num_pixels -// Access: Published -// Description: Returns the number of unique pixel colors in the -// histogram. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique pixel colors in the histogram. + */ INLINE int PNMImageHeader::Histogram:: get_num_pixels() const { return _pixels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::get_pixel -// Access: Published -// Description: Returns the nth unique pixel color in the histogram. -// These are ordered by default from most common to -// least common. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth unique pixel color in the histogram. These are ordered by + * default from most common to least common. + */ INLINE const PNMImageHeader::PixelSpec &PNMImageHeader::Histogram:: get_pixel(int n) const { nassertr(n >= 0 && n < (int)_pixels.size(), _pixels[0]._pixel); return _pixels[n]._pixel; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::get_count -// Access: Published -// Description: Returns the number of occurrences in the image of the -// nth unique pixel color in the histogram. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of occurrences in the image of the nth unique pixel + * color in the histogram. + */ INLINE int PNMImageHeader::Histogram:: get_count(int n) const { nassertr(n >= 0 && n < (int)_pixels.size(), 0); return _pixels[n]._count; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::get_count -// Access: Published -// Description: Returns the number of occurrences in the image of the -// indicated pixel color. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of occurrences in the image of the indicated pixel + * color. + */ INLINE int PNMImageHeader::Histogram:: get_count(const PNMImageHeader::PixelSpec &pixel) const { HistMap::const_iterator hi; @@ -635,13 +516,10 @@ get_count(const PNMImageHeader::PixelSpec &pixel) const { return (*hi).second; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::swap -// Access: Public -// Description: Swaps the data in the Histogram with the indicated -// data. This is normally used to load the Histogram -// data initially in PNMImage::make_histogram(). -//////////////////////////////////////////////////////////////////// +/** + * Swaps the data in the Histogram with the indicated data. This is normally + * used to load the Histogram data initially in PNMImage::make_histogram(). + */ INLINE void PNMImageHeader::Histogram:: swap(PixelCount &pixels, HistMap &hist_map) { _pixels.swap(pixels); diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index f4f002a87c..a73c11d297 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -1,16 +1,15 @@ -// Filename: pnmImageHeader.cxx -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImageHeader.cxx + * @author drose + * @date 2000-06-14 + */ #include "pnmImageHeader.h" #include "pnmFileTypeRegistry.h" @@ -21,15 +20,11 @@ #include "virtualFileSystem.h" #include "zStream.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::read_header -// Access: Published -// Description: Opens up the image file and tries to read its header -// information to determine its size, number of -// channels, etc. If successful, updates the header -// information and returns true; otherwise, returns -// false. -//////////////////////////////////////////////////////////////////// +/** + * Opens up the image file and tries to read its header information to + * determine its size, number of channels, etc. If successful, updates the + * header information and returns true; otherwise, returns false. + */ bool PNMImageHeader:: read_header(const Filename &filename, PNMFileType *type, bool report_unknown_type) { @@ -43,21 +38,18 @@ read_header(const Filename &filename, PNMFileType *type, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::read_header -// Access: Published -// Description: Reads the image header information only from the -// indicated stream. -// -// The filename is advisory only, and may be used -// to suggest a type if it has a known extension. -// -// If type is non-NULL, it is a suggestion for the type -// of file it is (and a non-NULL type will override any -// magic number test or filename extension lookup). -// -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the image header information only from the indicated stream. + * + * The filename is advisory only, and may be used to suggest a type if it has + * a known extension. + * + * If type is non-NULL, it is a suggestion for the type of file it is (and a + * non-NULL type will override any magic number test or filename extension + * lookup). + * + * Returns true if successful, false on error. + */ bool PNMImageHeader:: read_header(istream &data, const string &filename, PNMFileType *type, bool report_unknown_type) { @@ -72,19 +64,14 @@ read_header(istream &data, const string &filename, PNMFileType *type, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::make_reader -// Access: Published -// Description: Returns a newly-allocated PNMReader of the suitable -// type for reading from the indicated image filename, -// or NULL if the filename cannot be read for some -// reason. The filename "-" always stands for standard -// input. If type is specified, it is a suggestion for -// the file type to use. -// -// The PNMReader should be deleted when it is no longer -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PNMReader of the suitable type for reading from + * the indicated image filename, or NULL if the filename cannot be read for + * some reason. The filename "-" always stands for standard input. If type + * is specified, it is a suggestion for the file type to use. + * + * The PNMReader should be deleted when it is no longer needed. + */ PNMReader *PNMImageHeader:: make_reader(const Filename &filename, PNMFileType *type, bool report_unknown_type) const { @@ -117,40 +104,33 @@ make_reader(const Filename &filename, PNMFileType *type, return NULL; } - return make_reader(file, owns_file, filename, string(), type, + return make_reader(file, owns_file, filename, string(), type, report_unknown_type); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::make_reader -// Access: Published -// Description: Returns a newly-allocated PNMReader of the suitable -// type for reading from the already-opened image file, -// or NULL if the file cannot be read for some reason. -// -// owns_file should be set true if the PNMReader is to -// be considered the owner of the stream pointer (in -// which case the stream will be deleted on completion, -// whether successful or not), or false if it should not -// delete it. -// -// The filename parameter is optional here, since the -// file has already been opened; it is only used to -// examine the extension and attempt to guess the file -// type. -// -// If magic_number is nonempty, it is assumed to -// represent the first few bytes that have already been -// read from the file. Some file types may have -// difficulty if this is more than two bytes. -// -// If type is non-NULL, it is a suggestion for the file -// type to use. -// -// The PNMReader should be deleted when it is no longer -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PNMReader of the suitable type for reading from + * the already-opened image file, or NULL if the file cannot be read for some + * reason. + * + * owns_file should be set true if the PNMReader is to be considered the owner + * of the stream pointer (in which case the stream will be deleted on + * completion, whether successful or not), or false if it should not delete + * it. + * + * The filename parameter is optional here, since the file has already been + * opened; it is only used to examine the extension and attempt to guess the + * file type. + * + * If magic_number is nonempty, it is assumed to represent the first few bytes + * that have already been read from the file. Some file types may have + * difficulty if this is more than two bytes. + * + * If type is non-NULL, it is a suggestion for the file type to use. + * + * The PNMReader should be deleted when it is no longer needed. + */ PNMReader *PNMImageHeader:: make_reader(istream *file, bool owns_file, const Filename &filename, string magic_number, PNMFileType *type, @@ -165,11 +145,10 @@ make_reader(istream *file, bool owns_file, const Filename &filename, if (owns_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - // We're assuming here that the file was opened via VFS. That - // may not necessarily be the case, but we don't make that - // distinction. However, at the moment at least, that - // distinction doesn't matter, since vfs->close_read_file() - // just deletes the file pointer anyway. + // We're assuming here that the file was opened via VFS. That may not + // necessarily be the case, but we don't make that distinction. + // However, at the moment at least, that distinction doesn't matter, + // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } return NULL; @@ -191,8 +170,8 @@ make_reader(istream *file, bool owns_file, const Filename &filename, } if (type == (PNMFileType *)NULL && !filename.empty()) { - // We still don't know the type; attempt to guess it from the - // filename extension. + // We still don't know the type; attempt to guess it from the filename + // extension. type = PNMFileTypeRegistry::get_global_ptr()->get_type_from_extension(filename); if (pnmimage_cat.is_debug()) { @@ -229,11 +208,10 @@ make_reader(istream *file, bool owns_file, const Filename &filename, if (owns_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - // We're assuming here that the file was opened via VFS. That - // may not necessarily be the case, but we don't make that - // distinction. However, at the moment at least, that - // distinction doesn't matter, since vfs->close_read_file() - // just deletes the file pointer anyway. + // We're assuming here that the file was opened via VFS. That may not + // necessarily be the case, but we don't make that distinction. + // However, at the moment at least, that distinction doesn't matter, + // since vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(file); } return NULL; @@ -253,19 +231,14 @@ make_reader(istream *file, bool owns_file, const Filename &filename, return reader; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::make_writer -// Access: Published -// Description: Returns a newly-allocated PNMWriter of the suitable -// type for writing an image to the indicated filename, -// or NULL if the filename cannot be written for some -// reason. The filename "-" always stands for standard -// output. If type is specified, it is a suggestion for -// the file type to use. -// -// The PNMWriter should be deleted when it is no longer -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PNMWriter of the suitable type for writing an + * image to the indicated filename, or NULL if the filename cannot be written + * for some reason. The filename "-" always stands for standard output. If + * type is specified, it is a suggestion for the file type to use. + * + * The PNMWriter should be deleted when it is no longer needed. + */ PNMWriter *PNMImageHeader:: make_writer(const Filename &filename, PNMFileType *type) const { if (pnmimage_cat.is_debug()) { @@ -304,30 +277,24 @@ make_writer(const Filename &filename, PNMFileType *type) const { return make_writer(file, owns_file, filename, type); } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::make_writer -// Access: Published -// Description: Returns a newly-allocated PNMWriter of the suitable -// type for writing to the already-opened image file, or -// NULL if the file cannot be written for some reason. -// -// owns_file should be set true if the PNMWriter is to -// be considered the owner of the stream pointer (in -// which case the stream will be deleted on completion, -// whether successful or not), or false if it should not -// delete it. -// -// The filename parameter is optional here, since the -// file has already been opened; it is only used to -// examine the extension and attempt to guess the -// intended file type. -// -// If type is non-NULL, it is a suggestion for the file -// type to use. -// -// The PNMWriter should be deleted when it is no longer -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated PNMWriter of the suitable type for writing to the + * already-opened image file, or NULL if the file cannot be written for some + * reason. + * + * owns_file should be set true if the PNMWriter is to be considered the owner + * of the stream pointer (in which case the stream will be deleted on + * completion, whether successful or not), or false if it should not delete + * it. + * + * The filename parameter is optional here, since the file has already been + * opened; it is only used to examine the extension and attempt to guess the + * intended file type. + * + * If type is non-NULL, it is a suggestion for the file type to use. + * + * The PNMWriter should be deleted when it is no longer needed. + */ PNMWriter *PNMImageHeader:: make_writer(ostream *file, bool owns_file, const Filename &filename, PNMFileType *type) const { @@ -383,16 +350,12 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, return writer; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::read_magic_number -// Access: Published, Static -// Description: Ensures that the first n bytes of the file are read -// into magic_number. If magic_number is initially -// nonempty, assumes these represent the first few bytes -// already extracted. Returns true if successful, false -// if an end of file or error occurred before num_bytes -// could be read. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the first n bytes of the file are read into magic_number. If + * magic_number is initially nonempty, assumes these represent the first few + * bytes already extracted. Returns true if successful, false if an end of + * file or error occurred before num_bytes could be read. + */ bool PNMImageHeader:: read_magic_number(istream *file, string &magic_number, int num_bytes) { while ((int)magic_number.size() < num_bytes) { @@ -406,37 +369,30 @@ read_magic_number(istream *file, string &magic_number, int num_bytes) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PNMImageHeader:: output(ostream &out) const { out << "image: " << _x_size << " by " << _y_size << " pixels, " << _num_channels << " channels, " << _maxval << " maxval."; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::compute_histogram -// Access: Protected -// Description: Computes a histogram of the colors used in the -// indicated rgb/grayscale array and/or alpha array. -// This is most likely to be useful in a PNMWriter -// class, but it is defined at this level in case it has -// general utilty for PNMImages. -// -// Also see PNMImage::make_histogram(), which is a -// higher-level function. -// -// The max_colors parameter, if greater than zero, -// limits the maximum number of colors we are interested -// in. If we encounter more than this number of colors, -// the function aborts before completion and returns -// false; otherwise, it returns true. -//////////////////////////////////////////////////////////////////// +/** + * Computes a histogram of the colors used in the indicated rgb/grayscale + * array and/or alpha array. This is most likely to be useful in a PNMWriter + * class, but it is defined at this level in case it has general utilty for + * PNMImages. + * + * Also see PNMImage::make_histogram(), which is a higher-level function. + * + * The max_colors parameter, if greater than zero, limits the maximum number + * of colors we are interested in. If we encounter more than this number of + * colors, the function aborts before completion and returns false; otherwise, + * it returns true. + */ bool PNMImageHeader:: -compute_histogram(PNMImageHeader::HistMap &hist, +compute_histogram(PNMImageHeader::HistMap &hist, xel *array, xelval *alpha, int max_colors) { int num_pixels = _x_size * _y_size; int pi; @@ -485,14 +441,12 @@ compute_histogram(PNMImageHeader::HistMap &hist, return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::compute_palette -// Access: Protected -// Description: Returns a linear list of all of the colors in the -// image, similar to compute_histogram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a linear list of all of the colors in the image, similar to + * compute_histogram(). + */ bool PNMImageHeader:: -compute_palette(PNMImageHeader::Palette &palette, +compute_palette(PNMImageHeader::Palette &palette, xel *array, xelval *alpha, int max_colors) { HistMap hist; @@ -508,8 +462,8 @@ compute_palette(PNMImageHeader::Palette &palette, return false; } - // Now append the new entries discovered in the histogram onto the - // end of the palette. + // Now append the new entries discovered in the histogram onto the end of + // the palette. palette.reserve(hist.size()); HistMap::const_iterator hi; for (hi = hist.begin(); hi != hist.end(); ++hi) { @@ -521,21 +475,17 @@ compute_palette(PNMImageHeader::Palette &palette, return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::PixelSpec::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PNMImageHeader::PixelSpec:: output(ostream &out) const { out << "(" << _red << ", " << _green << ", " << _blue << ", " << _alpha << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMImageHeader::Histogram::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PNMImageHeader::Histogram:: write(ostream &out) const { out << "Histogram: {\n"; @@ -545,4 +495,3 @@ write(ostream &out) const { } out << "}\n"; } - diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index 38dee38432..1132bed14f 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -1,16 +1,15 @@ -// Filename: pnmImageHeader.h -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmImageHeader.h + * @author drose + * @date 2000-06-14 + */ #ifndef PNMIMAGEHEADER_H #define PNMIMAGEHEADER_H @@ -31,16 +30,13 @@ class PNMFileType; class PNMReader; class PNMWriter; -//////////////////////////////////////////////////////////////////// -// Class : PNMImageHeader -// Description : This is the base class of PNMImage, PNMReader, and -// PNMWriter. It encapsulates all the information -// associated with an image that describes its size, -// number of channels, etc; that is, all the information -// about the image except the image data itself. It's -// the sort of information you typically read from the -// image file's header. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class of PNMImage, PNMReader, and PNMWriter. It + * encapsulates all the information associated with an image that describes + * its size, number of channels, etc; that is, all the information about the + * image except the image data itself. It's the sort of information you + * typically read from the image file's header. + */ class EXPCL_PANDA_PNMIMAGE PNMImageHeader { PUBLISHED: INLINE PNMImageHeader(); @@ -48,9 +44,9 @@ PUBLISHED: INLINE void operator = (const PNMImageHeader ©); INLINE ~PNMImageHeader(); - // This enumerated type indicates the number of channels in the - // image, and also implies an image type. You can treat it either - // as an integer number of channels or as an enumerated image type. + // This enumerated type indicates the number of channels in the image, and + // also implies an image type. You can treat it either as an integer number + // of channels or as an enumerated image type. enum ColorType { CT_invalid = 0, CT_grayscale = 1, @@ -113,9 +109,9 @@ PUBLISHED: void output(ostream &out) const; - // Contains a single pixel specification used in compute_histogram() - // and make_histogram(). Note that pixels are stored by integer - // value, not by floating-point scaled value. + // Contains a single pixel specification used in compute_histogram() and + // make_histogram(). Note that pixels are stored by integer value, not by + // floating-point scaled value. class EXPCL_PANDA_PNMIMAGE PixelSpec { PUBLISHED: INLINE PixelSpec(xelval gray_value); @@ -151,8 +147,8 @@ PUBLISHED: xelval _red, _green, _blue, _alpha; }; - // Associates a pixel specification with an appearance count, for - // use in Histogram, below. + // Associates a pixel specification with an appearance count, for use in + // Histogram, below. class EXPCL_PANDA_PNMIMAGE PixelSpecCount { public: INLINE PixelSpecCount(const PixelSpec &pixel, int count); diff --git a/panda/src/pnmimage/pnmPainter.I b/panda/src/pnmimage/pnmPainter.I index f0353129d0..4d88e4ebbb 100644 --- a/panda/src/pnmimage/pnmPainter.I +++ b/panda/src/pnmimage/pnmPainter.I @@ -1,97 +1,79 @@ -// Filename: pnmPainter.I -// Created by: drose (02Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmPainter.I + * @author drose + * @date 2007-02-02 + */ -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMPainter:: ~PNMPainter() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::set_pen -// Access: Published -// Description: Specifies a PNMBrush that will be used for drawing -// lines and edges. If the brush is a bitmap brush, its -// image will be smeared pixelwise along the line. -// -// Unlike the PNMImage passed to the constructor, the -// PNMPainter will take ownership of the pen. It is not -// necessary to keep a separate pointer to it. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a PNMBrush that will be used for drawing lines and edges. If the + * brush is a bitmap brush, its image will be smeared pixelwise along the + * line. + * + * Unlike the PNMImage passed to the constructor, the PNMPainter will take + * ownership of the pen. It is not necessary to keep a separate pointer to + * it. + */ INLINE void PNMPainter:: set_pen(PNMBrush *pen) { _pen = pen; } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::get_pen -// Access: Published -// Description: Returns the current pen. See set_pen(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current pen. See set_pen(). + */ INLINE PNMBrush *PNMPainter:: get_pen() const { return _pen; } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::set_fill -// Access: Published -// Description: Specifies a PNMBrush that will be used for filling -// in the interiors of objects. If the brush is a -// bitmap brush, its image will be tiled throughout the -// space. -// -// Unlike the PNMImage passed to the constructor, the -// PNMPainter will take ownership of the fill brush. It -// is not necessary to keep a separate pointer to it. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a PNMBrush that will be used for filling in the interiors of + * objects. If the brush is a bitmap brush, its image will be tiled + * throughout the space. + * + * Unlike the PNMImage passed to the constructor, the PNMPainter will take + * ownership of the fill brush. It is not necessary to keep a separate + * pointer to it. + */ INLINE void PNMPainter:: set_fill(PNMBrush *fill) { _fill = fill; } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::get_fill -// Access: Published -// Description: Returns the current fill brush. See set_fill(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current fill brush. See set_fill(). + */ INLINE PNMBrush *PNMPainter:: get_fill() const { return _fill; } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::draw_point -// Access: Published -// Description: Draws an antialiased point on the PNMImage, using the -// current pen. -//////////////////////////////////////////////////////////////////// +/** + * Draws an antialiased point on the PNMImage, using the current pen. + */ INLINE void PNMPainter:: draw_point(float x, float y) { draw_line(x, y, x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::draw_hline_point -// Access: Private -// Description: Called within draw_line() to draw a single point of a -// mostly-horizontal line. -//////////////////////////////////////////////////////////////////// +/** + * Called within draw_line() to draw a single point of a mostly-horizontal + * line. + */ INLINE void PNMPainter:: draw_hline_point(int x, float xa, float ya, float xd, float yd, float pixel_scale) { @@ -106,12 +88,9 @@ draw_hline_point(int x, float xa, float ya, float xd, float yd, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::draw_vline_point -// Access: Private -// Description: Called within draw_line() to draw a single point of a -// mostly-vertical line. -//////////////////////////////////////////////////////////////////// +/** + * Called within draw_line() to draw a single point of a mostly-vertical line. + */ INLINE void PNMPainter:: draw_vline_point(int y, float xa, float ya, float xd, float yd, float pixel_scale) { diff --git a/panda/src/pnmimage/pnmPainter.cxx b/panda/src/pnmimage/pnmPainter.cxx index 8583b0e3f5..1bfdca1bcf 100644 --- a/panda/src/pnmimage/pnmPainter.cxx +++ b/panda/src/pnmimage/pnmPainter.cxx @@ -1,35 +1,28 @@ -// Filename: pnmPainter.cxx -// Created by: drose (02Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmPainter.cxx + * @author drose + * @date 2007-02-02 + */ #include "pnmPainter.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::Constructor -// Access: Published -// Description: The constructor stores a pointer to the PNMImage you -// pass it, but it does not take ownership of the -// object; you are responsible for ensuring that the -// PNMImage does not destruct during the lifetime of the -// PNMPainter object. -// -// The xo, yo coordinates specify an optional offset for -// fill coordinates. If you are painting with a pattern -// fill, these specify the virtual coordinates of the -// upper-left corner of the image, which can allow you -// to adjust the pattern to line up with nested images, -// if necessary. -//////////////////////////////////////////////////////////////////// +/** + * The constructor stores a pointer to the PNMImage you pass it, but it does + * not take ownership of the object; you are responsible for ensuring that the + * PNMImage does not destruct during the lifetime of the PNMPainter object. + * + * The xo, yo coordinates specify an optional offset for fill coordinates. If + * you are painting with a pattern fill, these specify the virtual coordinates + * of the upper-left corner of the image, which can allow you to adjust the + * pattern to line up with nested images, if necessary. + */ PNMPainter:: PNMPainter(PNMImage &image, int xo, int yo) : _image(image), @@ -39,16 +32,12 @@ PNMPainter(PNMImage &image, int xo, int yo) : _fill = PNMBrush::make_pixel(LColorf(1, 1, 1, 1)); } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::draw_line -// Access: Published -// Description: Draws an antialiased line on the PNMImage, using the -// current pen. -//////////////////////////////////////////////////////////////////// +/** + * Draws an antialiased line on the PNMImage, using the current pen. + */ void PNMPainter:: draw_line(float xa, float ya, float xb, float yb) { - // Shift the line coordinates to position the center of the pen on - // the line. + // Shift the line coordinates to position the center of the pen on the line. xa -= (_pen->get_xc() - 0.5); xb -= (_pen->get_xc() - 0.5); ya -= (_pen->get_yc() - 0.5); @@ -143,20 +132,15 @@ draw_line(float xa, float ya, float xb, float yb) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMPainter::draw_rectangle -// Access: Published -// Description: Draws a filled rectangule on the PNMImage, using the -// current pen for the outline, and the current fill -// brush for the interior. -// -// The two coordinates specify any two diagonally -// opposite corners. -//////////////////////////////////////////////////////////////////// +/** + * Draws a filled rectangule on the PNMImage, using the current pen for the + * outline, and the current fill brush for the interior. + * + * The two coordinates specify any two diagonally opposite corners. + */ void PNMPainter:: draw_rectangle(float xa, float ya, float xb, float yb) { - // Make (xa, ya) be the upper-left corner, and (xb, yb) the - // lower-right. + // Make (xa, ya) be the upper-left corner, and (xb, yb) the lower-right. if (xa > xb) { float t = xa; xa = xb; diff --git a/panda/src/pnmimage/pnmPainter.h b/panda/src/pnmimage/pnmPainter.h index 8ea7c38b1f..6abdb1cefa 100644 --- a/panda/src/pnmimage/pnmPainter.h +++ b/panda/src/pnmimage/pnmPainter.h @@ -1,16 +1,15 @@ -// Filename: pnmPainter.h -// Created by: drose (02Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmPainter.h + * @author drose + * @date 2007-02-02 + */ #ifndef PNMPAINTER_H #define PNMPAINTER_H @@ -20,17 +19,14 @@ class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : PNMPainter -// Description : This class provides a number of convenient methods -// for painting drawings directly into a PNMImage. -// -// It stores a pointer to the PNMImage you pass it, but -// it does not take ownership of the object; you are -// responsible for ensuring that the PNMImage does not -// destruct during the lifetime of the PNMPainter -// object. -//////////////////////////////////////////////////////////////////// +/** + * This class provides a number of convenient methods for painting drawings + * directly into a PNMImage. + * + * It stores a pointer to the PNMImage you pass it, but it does not take + * ownership of the object; you are responsible for ensuring that the PNMImage + * does not destruct during the lifetime of the PNMPainter object. + */ class EXPCL_PANDA_PNMIMAGE PNMPainter { PUBLISHED: PNMPainter(PNMImage &image, int xo = 0, int yo = 0); diff --git a/panda/src/pnmimage/pnmReader.I b/panda/src/pnmimage/pnmReader.I index 0aa982b0ce..3e1f5d8fff 100644 --- a/panda/src/pnmimage/pnmReader.I +++ b/panda/src/pnmimage/pnmReader.I @@ -1,22 +1,19 @@ -// Filename: pnmReader.I -// Created by: drose (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmReader.I + * @author drose + * @date 2000-06-16 + */ -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMReader:: PNMReader(PNMFileType *type, istream *file, bool owns_file) : _type(type), @@ -27,16 +24,12 @@ PNMReader(PNMFileType *type, istream *file, bool owns_file) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::set_read_size -// Access: Public -// Description: Instructs the reader to attempt to scale the image to -// the indicated size while reading it. The reader may -// or may not follow this suggestion, or may follow it -// only partially (e.g. by reading a file which is -// slightly reduced in size, but not the precise size -// requested). -//////////////////////////////////////////////////////////////////// +/** + * Instructs the reader to attempt to scale the image to the indicated size + * while reading it. The reader may or may not follow this suggestion, or may + * follow it only partially (e.g. by reading a file which is slightly reduced + * in size, but not the precise size requested). + */ void PNMReader:: set_read_size(int x_size, int y_size) { _read_x_size = x_size; @@ -44,23 +37,18 @@ set_read_size(int x_size, int y_size) { _has_read_size = true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::get_type -// Access: Public -// Description: Returns a pointer to the PNMFileType object that -// created this PNMReader. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PNMFileType object that created this PNMReader. + */ INLINE PNMFileType *PNMReader:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::is_valid -// Access: Public -// Description: Returns true if the PNMReader can be used to read -// data, false if something is wrong. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PNMReader can be used to read data, false if something + * is wrong. + */ INLINE bool PNMReader:: is_valid() const { return _is_valid; diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index 1397e9c482..9f6c3bc2c9 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -1,53 +1,45 @@ -// Filename: pnmReader.cxx -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmReader.cxx + * @author drose + * @date 2000-06-14 + */ #include "pnmReader.h" #include "virtualFileSystem.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMReader:: ~PNMReader() { if (_owns_file) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - // We're assuming here that the file was opened via VFS. That - // may not necessarily be the case, but we don't make that - // distinction. However, at the moment at least, that - // distinction doesn't matter, since vfs->close_read_file() - // just deletes the file pointer anyway. + // We're assuming here that the file was opened via VFS. That may not + // necessarily be the case, but we don't make that distinction. However, + // at the moment at least, that distinction doesn't matter, since + // vfs->close_read_file() just deletes the file pointer anyway. vfs->close_read_file(_file); } _file = (istream *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::prepare_read -// Access: Public, Virtual -// Description: This method will be called before read_data() or -// read_row() is called. It instructs the reader to -// initialize its data structures as necessary to -// actually perform the read operation. -// -// After this call, _x_size and _y_size should reflect -// the actual size that will be filled by read_data() -// (as possibly modified by set_read_size()). -//////////////////////////////////////////////////////////////////// +/** + * This method will be called before read_data() or read_row() is called. It + * instructs the reader to initialize its data structures as necessary to + * actually perform the read operation. + * + * After this call, _x_size and _y_size should reflect the actual size that + * will be filled by read_data() (as possibly modified by set_read_size()). + */ void PNMReader:: prepare_read() { if (!_is_valid) { @@ -70,43 +62,34 @@ prepare_read() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::is_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType represents a -// floating-point image type, false if it is a normal, -// integer type. If this returns true, read_pfm() is -// implemented instead of read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType represents a floating-point image type, + * false if it is a normal, integer type. If this returns true, read_pfm() is + * implemented instead of read_data(). + */ bool PNMReader:: is_floating_point() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::read_pfm -// Access: Public, Virtual -// Description: Reads floating-point data directly into the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads floating-point data directly into the indicated PfmFile. Returns + * true on success, false on failure. + */ bool PNMReader:: read_pfm(PfmFile &pfm) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMReader:: read_data(xel *array, xelval *alpha) { if (!is_valid()) { @@ -126,23 +109,23 @@ read_data(xel *array, xelval *alpha) { } else { int x_reduction = (1 << _x_shift); int y_reduction = (1 << _y_shift); - + int shift = _x_shift + _y_shift; - // We need a temporary buffer, at least one row wide, with - // full-width integers, for accumulating pixel data. + // We need a temporary buffer, at least one row wide, with full-width + // integers, for accumulating pixel data. int *accum_row_array = (int *)alloca(_orig_x_size * sizeof(int) * 3); int *accum_row_alpha = (int *)alloca(_orig_x_size * sizeof(int)); - // Each time we read a row, we will actually read the full row - // here, before we filter it down into the above. + // Each time we read a row, we will actually read the full row here, + // before we filter it down into the above. xel *orig_row_array = (xel *)alloca(_orig_x_size * sizeof(xel)); xelval *orig_row_alpha = (xelval *)alloca(_orig_x_size * sizeof(xelval)); - + int y; for (y = 0; y < _y_size; ++y) { - // Zero out the accumulation data, in preparation for - // holding the results of the below. + // Zero out the accumulation data, in preparation for holding the + // results of the below. memset(accum_row_array, 0, _x_size * sizeof(int) * 3); if (has_alpha()) { memset(accum_row_alpha, 0, _x_size * sizeof(int)); @@ -155,8 +138,8 @@ read_data(xel *array, xelval *alpha) { return y; } - // Boil that row down to its proper, reduced size, and - // accumulate it into the target row. + // Boil that row down to its proper, reduced size, and accumulate it + // into the target row. xel *p = orig_row_array; int *q = accum_row_array; int *qstop = q + _x_size * 3; @@ -184,8 +167,7 @@ read_data(xel *array, xelval *alpha) { } } - // OK, now copy the accumulated pixel data into the final - // result. + // OK, now copy the accumulated pixel data into the final result. xel *target_row_array = array + y * _x_size; xelval *target_row_alpha = alpha + y * _x_size; @@ -210,74 +192,57 @@ read_data(xel *array, xelval *alpha) { } } } - + return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader is capable -// of returning the data one row at a time, via repeated -// calls to read_row(). Returns false if the only way -// to read from this file is all at once, via -// read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader is capable of returning the data + * one row at a time, via repeated calls to read_row(). Returns false if the + * only way to read from this file is all at once, via read_data(). + */ bool PNMReader:: supports_read_row() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -// -// The x_size and y_size parameters are the value of -// _x_size and _y_size as originally filled in by the -// constructor; it is the actual number of pixels in the -// image. (The _x_size and _y_size members may have -// been automatically modified by the time this method -// is called if we are scaling on load, so should not be -// used.) -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + * + * The x_size and y_size parameters are the value of _x_size and _y_size as + * originally filled in by the constructor; it is the actual number of pixels + * in the image. (The _x_size and _y_size members may have been automatically + * modified by the time this method is called if we are scaling on load, so + * should not be used.) + */ bool PNMReader:: read_row(xel *, xelval *, int, int) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::supports_stream_read -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader can read -// from a general stream (including pipes, etc.), or -// false if the reader must occasionally fseek() on its -// input stream, and thus only disk streams are -// supported. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader can read from a general stream + * (including pipes, etc.), or false if the reader must occasionally fseek() + * on its input stream, and thus only disk streams are supported. + */ bool PNMReader:: supports_stream_read() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMReader::get_reduction_shift -// Access: Private -// Description: Determines the reduction factor between the original -// size and the requested size, returned as an exponent -// of power of 2 (that is, a bit shift). -// -// Only power-of-two reductions are supported, since -// those are common, easy, and fast. Other reductions -// will be handled in the higher level code. -//////////////////////////////////////////////////////////////////// +/** + * Determines the reduction factor between the original size and the requested + * size, returned as an exponent of power of 2 (that is, a bit shift). + * + * Only power-of-two reductions are supported, since those are common, easy, + * and fast. Other reductions will be handled in the higher level code. + */ int PNMReader:: get_reduction_shift(int orig_size, int new_size) { if (new_size == 0) { diff --git a/panda/src/pnmimage/pnmReader.h b/panda/src/pnmimage/pnmReader.h index 6d72891210..833c531f29 100644 --- a/panda/src/pnmimage/pnmReader.h +++ b/panda/src/pnmimage/pnmReader.h @@ -1,16 +1,15 @@ -// Filename: pnmReader.h -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmReader.h + * @author drose + * @date 2000-06-14 + */ #ifndef PNMREADER_H #define PNMREADER_H @@ -20,14 +19,11 @@ #include "pnmImageHeader.h" class PfmFile; -//////////////////////////////////////////////////////////////////// -// Class : PNMReader -// Description : This is an abstract base class that defines the -// interface for reading image files of various types. -// Any particular image file type that can be read must -// define a class that inherits from PNMReader to read -// it. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class that defines the interface for reading image + * files of various types. Any particular image file type that can be read + * must define a class that inherits from PNMReader to read it. + */ class EXPCL_PANDA_PNMIMAGE PNMReader : public PNMImageHeader { protected: INLINE PNMReader(PNMFileType *type, istream *file, bool owns_file); diff --git a/panda/src/pnmimage/pnmWriter.I b/panda/src/pnmimage/pnmWriter.I index deacdaac3d..f9686a5c44 100644 --- a/panda/src/pnmimage/pnmWriter.I +++ b/panda/src/pnmimage/pnmWriter.I @@ -1,23 +1,19 @@ -// Filename: pnmWriter.I -// Created by: drose (16Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmWriter.I + * @author drose + * @date 2000-06-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMWriter:: PNMWriter(PNMFileType *type, ostream *file, bool owns_file) : _type(type), @@ -27,89 +23,71 @@ PNMWriter(PNMFileType *type, ostream *file, bool owns_file) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::get_type -// Access: Public -// Description: Returns a pointer to the PNMFileType object that -// created this PNMWriter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PNMFileType object that created this PNMWriter. + */ INLINE PNMFileType *PNMWriter:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::set_color_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMWriter:: set_color_type(ColorType type) { set_num_channels((int)type); } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::set_num_channels -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMWriter:: set_num_channels(int num_channels) { nassertv(num_channels >= 1 && num_channels <= 4); _num_channels = num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::set_maxval -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMWriter:: set_maxval(xelval maxval) { _maxval = maxval; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::set_x_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMWriter:: set_x_size(int x_size) { nassertv(x_size >= 0); _x_size = x_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::set_y_size -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMWriter:: set_y_size(int y_size) { nassertv(y_size >= 0); _y_size = y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::copy_header_from -// Access: Public -// Description: Initializes all the data in the header (x_size, -// y_size, num_channels, etc.) to the same values -// indicated in the given header. This should be done -// before writing anything to the file. -//////////////////////////////////////////////////////////////////// +/** + * Initializes all the data in the header (x_size, y_size, num_channels, etc.) + * to the same values indicated in the given header. This should be done + * before writing anything to the file. + */ INLINE void PNMWriter:: copy_header_from(const PNMImageHeader &header) { PNMImageHeader::operator = (header); } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::is_valid -// Access: Public -// Description: Returns true if the PNMWriter can be used to write -// data, false if something is wrong. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PNMWriter can be used to write data, false if something + * is wrong. + */ INLINE bool PNMWriter:: is_valid() const { return _is_valid; diff --git a/panda/src/pnmimage/pnmWriter.cxx b/panda/src/pnmimage/pnmWriter.cxx index 06dc867826..0115f261aa 100644 --- a/panda/src/pnmimage/pnmWriter.cxx +++ b/panda/src/pnmimage/pnmWriter.cxx @@ -1,25 +1,22 @@ -// Filename: pnmWriter.cxx -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmWriter.cxx + * @author drose + * @date 2000-06-14 + */ #include "pnmWriter.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMWriter:: ~PNMWriter() { if (_owns_file) { @@ -28,65 +25,51 @@ PNMWriter:: _file = (ostream *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::supports_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept a -// floating-point image type, false if it can only -// accept a normal, integer type. If this returns true, -// write_pfm() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept a floating-point image type, + * false if it can only accept a normal, integer type. If this returns true, + * write_pfm() is implemented. + */ bool PNMWriter:: supports_floating_point() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::supports_integer -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept an -// integer image type, false if it can only -// accept a floating-point type. If this returns true, -// write_data() or write_row() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept an integer image type, false if + * it can only accept a floating-point type. If this returns true, + * write_data() or write_row() is implemented. + */ bool PNMWriter:: supports_integer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::write_pfm -// Access: Public, Virtual -// Description: Writes floating-point data from the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes floating-point data from the indicated PfmFile. Returns true on + * success, false on failure. + */ bool PNMWriter:: write_pfm(const PfmFile &pfm) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::write_data -// Access: Public, Virtual -// Description: Writes out an entire image all at once, including the -// header, based on the image data stored in the given -// _x_size * _y_size array and alpha pointers. (If the -// image type has no alpha channel, alpha is ignored.) -// Returns the number of rows correctly written. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_data(). -// -// It is important to delete the PNMWriter class after -// successfully writing the data. Failing to do this -// may result in some data not getting flushed! -// -// Derived classes need not override this if they -// instead provide supports_streaming() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ int PNMWriter:: write_data(xel *array, xelval *alpha) { if (_x_size <= 0 || _y_size <= 0) { @@ -108,84 +91,64 @@ write_data(xel *array, xelval *alpha) { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter supports a streaming interface to + * writing the data: that is, it is capable of writing the image one row at a + * time, via repeated calls to write_row(). Returns false if the only way to + * write from this file is all at once, via write_data(). + */ bool PNMWriter:: supports_write_row() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::supports_grayscale -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter understands -// grayscale images. If this is false, then the rgb -// values of the xel array will be pre-filled with the -// same value across all three channels, to allow the -// writer to simply write out RGB data for a grayscale -// image. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter understands grayscale images. If + * this is false, then the rgb values of the xel array will be pre-filled with + * the same value across all three channels, to allow the writer to simply + * write out RGB data for a grayscale image. + */ bool PNMWriter:: supports_grayscale() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * to write out the image header in preparation to writing out the image data + * one row at a time. Returns true if the header is successfully written, + * false if there is an error. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_header(). + */ bool PNMWriter:: write_header() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * repeatedly to write the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully written, false if there + * is an error. + * + * You must first call write_header() before writing the individual rows. It + * is also important to delete the PNMWriter class after successfully writing + * the last row. Failing to do this may result in some data not getting + * flushed! + */ bool PNMWriter:: write_row(xel *, xelval *) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMWriter::supports_stream_write -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter can write -// to a general stream (including pipes, etc.), or -// false if the writer must occasionally fseek() on its -// output stream, and thus only disk streams are -// supported. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter can write to a general stream + * (including pipes, etc.), or false if the writer must occasionally fseek() + * on its output stream, and thus only disk streams are supported. + */ bool PNMWriter:: supports_stream_write() const { return false; diff --git a/panda/src/pnmimage/pnmWriter.h b/panda/src/pnmimage/pnmWriter.h index 503afcf221..062b89602f 100644 --- a/panda/src/pnmimage/pnmWriter.h +++ b/panda/src/pnmimage/pnmWriter.h @@ -1,16 +1,15 @@ -// Filename: pnmWriter.h -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmWriter.h + * @author drose + * @date 2000-06-14 + */ #ifndef PNMWRITER_H #define PNMWRITER_H @@ -20,23 +19,20 @@ #include "pnmImageHeader.h" class PfmFile; -//////////////////////////////////////////////////////////////////// -// Class : PNMWriter -// Description : This is an abstract base class that defines the -// interface for writing image files of various types. -// Any particular image file type that can be written -// must define a class that inherits from PNMWriter to -// write it. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class that defines the interface for writing image + * files of various types. Any particular image file type that can be written + * must define a class that inherits from PNMWriter to write it. + */ class EXPCL_PANDA_PNMIMAGE PNMWriter : public PNMImageHeader { protected: INLINE PNMWriter(PNMFileType *type, ostream *file, bool owns_file); public: - // It is important to delete the PNMWriter class after successfully - // writing the data. Failing to do this may result in some data not - // getting flushed! + // It is important to delete the PNMWriter class after successfully writing + // the data. Failing to do this may result in some data not getting + // flushed! virtual ~PNMWriter(); INLINE PNMFileType *get_type() const; diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx index ac7d90e096..075b45dcd2 100644 --- a/panda/src/pnmimage/pnmimage_base.cxx +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -1,16 +1,15 @@ -// Filename: pnmimage_base.cxx -// Created by: drose (04Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmimage_base.cxx + * @author drose + * @date 2002-08-04 + */ #include "pnmimage_base.h" #include "streamReader.h" @@ -21,11 +20,9 @@ #include // for sprintf() -//////////////////////////////////////////////////////////////////// -// Function: pm_message -// Description: Outputs the given printf-style message to the user -// and returns. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the given printf-style message to the user and returns. + */ void pm_message(const char *format, ...) { va_list ap; @@ -46,12 +43,10 @@ pm_message(const char *format, ...) { va_end(ap); } -//////////////////////////////////////////////////////////////////// -// Function: pm_error -// Description: Outputs the given printf-style message to the user -// and terminates messily. Minimize use of this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the given printf-style message to the user and terminates messily. + * Minimize use of this function. + */ void pm_error(const char *format, ...) { va_list ap; @@ -71,16 +66,14 @@ pm_error(const char *format, ...) { va_end(ap); - // Now we're supposed to exit. Inconvenient if we were running - // Panda interactively, but that's the way it is. + // Now we're supposed to exit. Inconvenient if we were running Panda + // interactively, but that's the way it is. exit(1); } -//////////////////////////////////////////////////////////////////// -// Function: pm_maxvaltobits -// Description: Returns the number of bits sufficient to hold the -// indicated maxval value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits sufficient to hold the indicated maxval value. + */ int pm_maxvaltobits(int maxval) { int bits = 1; @@ -91,29 +84,26 @@ pm_maxvaltobits(int maxval) { return bits; } -//////////////////////////////////////////////////////////////////// -// Function: pm_bitstomaxval -// Description: Returns the highest maxval that can be represented in -// the indicated number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the highest maxval that can be represented in the indicated number + * of bits. + */ int pm_bitstomaxval(int bits) { return ( 1 << bits ) - 1; } -//////////////////////////////////////////////////////////////////// -// Function: pm_allocrow -// Description: Allocates a row of cols * size bytes. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a row of cols * size bytes. + */ char * pm_allocrow(int cols, int size) { return (char *)PANDA_MALLOC_ARRAY(cols * size); } -//////////////////////////////////////////////////////////////////// -// Function: pm_freerow -// Description: Frees the row previously allocated withm pm_allocrow(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the row previously allocated withm pm_allocrow(). + */ void pm_freerow(char *itrow) { PANDA_FREE_ARRAY(itrow); diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index ad5cf47555..e9c36416cc 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -1,32 +1,31 @@ -// Filename: pnmimage_base.h -// Created by: drose (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmimage_base.h + * @author drose + * @date 2000-06-14 + */ #ifndef PNMIMAGE_BASE_H #define PNMIMAGE_BASE_H -// This header file make a few typedefs and other definitions -// essential to everything in the PNMImage package. +// This header file make a few typedefs and other definitions essential to +// everything in the PNMImage package. #include "pandabase.h" #include "pnotify.h" -// Since we no longer include pnm.h directly, we have to provide our -// own definitions for xel and xelval. +// Since we no longer include pnm.h directly, we have to provide our own +// definitions for xel and xelval. -// For now, we have PGM_BIGGRAYS defined, which gives us 16-bit -// channels. Undefine this if you have memory problems and need to -// use 8-bit channels instead. +// For now, we have PGM_BIGGRAYS defined, which gives us 16-bit channels. +// Undefine this if you have memory problems and need to use 8-bit channels +// instead. #define PGM_BIGGRAYS #ifdef PGM_BIGGRAYS @@ -95,8 +94,8 @@ typedef gray xelval; ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) -// pnm defines these functions, and it's easier to emulate them than -// to rewrite the code that calls them. +// pnm defines these functions, and it's easier to emulate them than to +// rewrite the code that calls them. EXPCL_PANDA_PNMIMAGE void pm_message(const char *format, ...); EXPCL_PANDA_PNMIMAGE void pm_error(const char *format, ...); // doesn't return. diff --git a/panda/src/pnmimagetypes/bmp.h b/panda/src/pnmimagetypes/bmp.h index ecf117d775..d825bc71a1 100644 --- a/panda/src/pnmimagetypes/bmp.h +++ b/panda/src/pnmimagetypes/bmp.h @@ -1,8 +1,4 @@ -/* Filename: bmp.h - * Created by: - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,8 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file bmp.h + */ #ifndef _BMP_H_ #define _BMP_H_ @@ -179,4 +176,3 @@ BMPlenfile( } #endif /* _BMP_H_ */ - diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index 5764259346..99c290bb74 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -1,16 +1,15 @@ -// Filename: config_pnmimagetypes.cxx -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmimagetypes.cxx + * @author drose + * @date 2000-06-17 + */ #include "config_pnmimagetypes.h" #include "pnmFileTypeSGI.h" @@ -51,10 +50,10 @@ ConfigVariableString sgi_imagename PRC_DESC("This string is written to the header of an SGI (*.rgb) file. " "It seems to have documentation purposes only.")); -// TGA supports RLE compression, as well as colormapping and/or -// grayscale images. Set these true to enable these features, if -// possible, or false to disable them. Some programs (like xv) have -// difficulty reading these advanced TGA files. +// TGA supports RLE compression, as well as colormapping andor grayscale +// images. Set these true to enable these features, if possible, or false to +// disable them. Some programs (like xv) have difficulty reading these +// advanced TGA files. ConfigVariableBool tga_rle ("tga-rle", false, PRC_DESC("Set this true to enable RLE compression when writing TGA files.")); @@ -165,14 +164,12 @@ ConfigureFn(config_pnmimagetypes) { init_libpnmimagetypes(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libpnmimagetypes -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpnmimagetypes() { static bool initialized = false; diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.h b/panda/src/pnmimagetypes/config_pnmimagetypes.h index 308918b704..bca20cb449 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.h +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.h @@ -1,16 +1,15 @@ -// Filename: config_pnmimagetypes.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmimagetypes.h + * @author drose + * @date 2000-06-17 + */ #ifndef CONFIG_PNMIMAGETYPES_H #define CONFIG_PNMIMAGETYPES_H @@ -19,8 +18,8 @@ #ifdef HAVE_PNG // If we are going to be including png.h (in the unrelated file -// pnmFileTypePNG.h), be sure to include it before including setjmp.h. -// Ugly hack due to png weirdness with setjmp. +// pnmFileTypePNG.h), be sure to include it before including setjmp.h. Ugly +// hack due to png weirdness with setjmp. #include #endif diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx index 498c7f10e2..9ff4240ecf 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMP.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeBMP.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeBMP.cxx + * @author drose + * @date 2000-06-19 + */ #include "pnmFileTypeBMP.h" @@ -28,105 +27,85 @@ static const int num_extensions_bmp = sizeof(extensions_bmp) / sizeof(const char TypeHandle PNMFileTypeBMP::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeBMP:: PNMFileTypeBMP() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeBMP:: get_name() const { return "Windows BMP"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeBMP:: get_num_extensions() const { return num_extensions_bmp; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeBMP:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_bmp, string()); return extensions_bmp[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeBMP:: get_suggested_extension() const { return "bmp"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeBMP:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypeBMP:: matches_magic_number(const string &magic_number) const { nassertr(magic_number.size() >= 2, false); return (magic_number.substr(0, 2) == "BM"); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeBMP:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeBMP:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -134,30 +113,23 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeBMP:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeBMP); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::make_PNMFileTypeBMP -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeBMP:: make_PNMFileTypeBMP(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMP.h b/panda/src/pnmimagetypes/pnmFileTypeBMP.h index e6fc3b84d0..731fc06477 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMP.h +++ b/panda/src/pnmimagetypes/pnmFileTypeBMP.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeBMP.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeBMP.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPEBMP_H #define PNMFILETYPEBMP_H @@ -23,10 +22,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeBMP -// Description : For reading and writing Windows BMP files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing Windows BMP files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeBMP : public PNMFileType { public: PNMFileTypeBMP(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index e0ec77441d..8d5336b75b 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeBMPReader.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeBMPReader.cxx + * @author drose + * @date 2000-06-19 + */ #include "pnmFileTypeBMP.h" @@ -56,7 +55,7 @@ static int BMPreadrgbtable (istream *fp, unsigned long *ppos, static const char *ifname = "BMP"; static char er_read[] = "%s: read error"; -//static char er_seek[] = "%s: seek error"; +// static char er_seek[] = "%s: seek error"; static int GetByte(istream *fp) @@ -440,11 +439,9 @@ BMPreadbits(xel *array, xelval *alpha_array, } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeBMP::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -511,19 +508,15 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Reader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMFileTypeBMP::Reader:: read_data(xel *array, xelval *alpha_array) { BMPreadbits(array, alpha_array, _file, &pos, offBits, _x_size, _y_size, diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index 4dabd297a7..879682a297 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeBMPWriter.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeBMPWriter.cxx + * @author drose + * @date 2000-06-19 + */ #include "pnmFileTypeBMP.h" @@ -506,11 +505,9 @@ BMPEncode24( } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeBMP::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) @@ -518,28 +515,22 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Writer::write_data -// Access: Public, Virtual -// Description: Writes out an entire image all at once, including the -// header, based on the image data stored in the given -// _x_size * _y_size array and alpha pointers. (If the -// image type has no alpha channel, alpha is ignored.) -// Returns the number of rows correctly written. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_data(). -// -// It is important to delete the PNMWriter class after -// successfully writing the data. Failing to do this -// may result in some data not getting flushed! -// -// Derived classes need not override this if they -// instead provide supports_streaming() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ int PNMFileTypeBMP::Writer:: write_data(xel *array, xelval *) { if (_y_size<=0 || _x_size<=0) { @@ -634,16 +625,12 @@ write_data(xel *array, xelval *) { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Writer::supports_grayscale -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter understands -// grayscale images. If this is false, then the rgb -// values of the xel array will be pre-filled with the -// same value across all three channels, to allow the -// writer to simply write out RGB data for a grayscale -// image. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter understands grayscale images. If + * this is false, then the rgb values of the xel array will be pre-filled with + * the same value across all three channels, to allow the writer to simply + * write out RGB data for a grayscale image. + */ bool PNMFileTypeBMP::Writer:: supports_grayscale() const { return false; diff --git a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx index c9adc807bf..477f921bd2 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeIMG.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeIMG.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeIMG.cxx + * @author drose + * @date 2000-06-19 + */ #include "pnmFileTypeIMG.h" @@ -21,9 +20,9 @@ #include "pnmFileTypeRegistry.h" #include "bamReader.h" -// Since raw image files don't have a magic number, we'll make a little -// sanity check on the size of the image. If either the width or height is -// larger than this, it must be bogus. +// Since raw image files don't have a magic number, we'll make a little sanity +// check on the size of the image. If either the width or height is larger +// than this, it must be bogus. #define INSANE_SIZE 20000 static const char * const extensions_img[] = { @@ -33,81 +32,65 @@ static const int num_extensions_img = sizeof(extensions_img) / sizeof(const char TypeHandle PNMFileTypeIMG::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeIMG:: PNMFileTypeIMG() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeIMG:: get_name() const { return "Raw binary RGB"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeIMG:: get_num_extensions() const { return num_extensions_img; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeIMG:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_img, string()); return extensions_img[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeIMG:: get_suggested_extension() const { return "img"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeIMG:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeIMG:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -149,20 +132,17 @@ write_uchar_IMG(ostream *file, unsigned char x) { file->put(x); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeIMG::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) { if (img_header_type == IHT_long) { if (!read_magic_number(_file, magic_number, 8)) { - // Although raw IMG files have no magic number, they may have a - // pair of ushorts or ulongs at the beginning to indicate the file - // size. + // Although raw IMG files have no magic number, they may have a pair of + // ushorts or ulongs at the beginning to indicate the file size. if (pnmimage_img_cat.is_debug()) { pnmimage_img_cat.debug() << "IMG image file appears to be empty.\n"; @@ -228,30 +208,23 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader supports a streaming interface to + * reading the data: that is, it is capable of returning the data one row at a + * time, via repeated calls to read_row(). Returns false if the only way to + * read from this file is all at once, via read_data(). + */ bool PNMFileTypeIMG::Reader:: supports_read_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + */ bool PNMFileTypeIMG::Reader:: read_row(xel *row_data, xelval *, int x_size, int) { int x; @@ -267,46 +240,36 @@ read_row(xel *row_data, xelval *, int x_size, int) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeIMG::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Writer::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter supports a streaming interface to + * writing the data: that is, it is capable of writing the image one row at a + * time, via repeated calls to write_row(). Returns false if the only way to + * write from this file is all at once, via write_data(). + */ bool PNMFileTypeIMG::Writer:: supports_write_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Writer::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * to write out the image header in preparation to writing out the image data + * one row at a time. Returns true if the header is successfully written, + * false if there is an error. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_header(). + */ bool PNMFileTypeIMG::Writer:: write_header() { if (img_header_type == IHT_long) { @@ -319,21 +282,17 @@ write_header() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::Writer::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * repeatedly to write the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully written, false if there + * is an error. + * + * You must first call write_header() before writing the individual rows. It + * is also important to delete the PNMWriter class after successfully writing + * the last row. Failing to do this may result in some data not getting + * flushed! + */ bool PNMFileTypeIMG::Writer:: write_row(xel *row_data, xelval *) { int x; @@ -348,30 +307,23 @@ write_row(xel *row_data, xelval *) { -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeIMG:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeIMG); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeIMG::make_PNMFileTypeIMG -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeIMG:: make_PNMFileTypeIMG(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeIMG.h b/panda/src/pnmimagetypes/pnmFileTypeIMG.h index bff7c3dc2b..084caf4152 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeIMG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeIMG.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeIMG.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeIMG.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPEIMG_H #define PNMFILETYPEIMG_H @@ -23,10 +22,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeIMG -// Description : For reading and writing headerless R,G,B files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing headerless R,G,B files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeIMG : public PNMFileType { public: PNMFileTypeIMG(); @@ -88,5 +86,3 @@ private: #endif // HAVE_IMG #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx index 1cae4bf499..555fe29074 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeJPG.cxx -// Created by: mike (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeJPG.cxx + * @author mike + * @date 2000-06-19 + */ #include "pnmFileTypeJPG.h" @@ -28,79 +27,63 @@ static const int num_extensions_jpg = sizeof(extensions_jpg) / sizeof(const char TypeHandle PNMFileTypeJPG::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeJPG:: PNMFileTypeJPG() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeJPG:: get_name() const { return "JPEG"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeJPG:: get_num_extensions() const { return num_extensions_jpg; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeJPG:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_jpg, string()); return extensions_jpg[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeJPG:: get_suggested_extension() const { return "jpg"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeJPG:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypeJPG:: matches_magic_number(const string &magic_number) const { nassertr(magic_number.size() >= 2, false); @@ -108,26 +91,22 @@ matches_magic_number(const string &magic_number) const { (char)magic_number[1] == (char)0xd8); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeJPG:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeJPG:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -135,30 +114,23 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeJPG:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeJPG); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::make_PNMFileTypeJPG -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeJPG:: make_PNMFileTypeJPG(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPG.h b/panda/src/pnmimagetypes/pnmFileTypeJPG.h index 936e349568..2dcd506322 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPG.h +++ b/panda/src/pnmimagetypes/pnmFileTypeJPG.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeJPG.h -// Created by: mike (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeJPG.h + * @author mike + * @date 2000-06-17 + */ #ifndef PNMFILETYPEJPG_H #define PNMFILETYPEJPG_H @@ -32,8 +31,8 @@ #ifdef HAVE_PNG // If we are going to be including png.h (in the unrelated file -// pnmFileTypePNG.h), be sure to include it before including setjmp.h. -// Ugly hack due to png weirdness with setjmp. +// pnmFileTypePNG.h), be sure to include it before including setjmp.h. Ugly +// hack due to png weirdness with setjmp. #include #endif @@ -44,10 +43,9 @@ extern "C" { #include } -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeJPG -// Description : For reading and writing Jpeg files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing Jpeg files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeJPG : public PNMFileType { public: PNMFileTypeJPG(); @@ -133,4 +131,3 @@ private: #endif // HAVE_JPEG #endif - diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx index 56ef623a15..333bac61eb 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGReader.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeJPGReader.cxx -// Created by: mike (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeJPGReader.cxx + * @author mike + * @date 2000-06-19 + */ #include "pnmFileTypeJPG.h" @@ -19,11 +18,8 @@ #include "config_pnmimagetypes.h" #include "thread.h" -// -// The following bit of code, for setting up jpeg_istream_src(), was -// lifted from jpeglib, and modified to work with istream instead of -// stdio. -// +// The following bit of code, for setting up jpeg_istream_src(), was lifted +// from jpeglib, and modified to work with istream instead of stdio. /* * jdatasrc.c @@ -243,15 +239,11 @@ jpeg_istream_src (j_decompress_ptr cinfo, istream * infile) -// // The rest of the code in this file is new to Panda. -// -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeJPG::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -302,18 +294,14 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : _cinfo.scale_denom = 1; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Reader::prepare_read -// Access: Public, Virtual -// Description: This method will be called before read_data() or -// read_row() is called. It instructs the reader to -// initialize its data structures as necessary to -// actually perform the read operation. -// -// After this call, _x_size and _y_size should reflect -// the actual size that will be filled by read_data() -// (as possibly modified by set_read_size()). -//////////////////////////////////////////////////////////////////// +/** + * This method will be called before read_data() or read_row() is called. It + * instructs the reader to initialize its data structures as necessary to + * actually perform the read operation. + * + * After this call, _x_size and _y_size should reflect the actual size that + * will be filled by read_data() (as possibly modified by set_read_size()). + */ void PNMFileTypeJPG::Reader:: prepare_read() { if (_has_read_size && _read_x_size != 0 && _read_y_size != 0) { @@ -335,11 +323,9 @@ prepare_read() { _y_size = (int)_cinfo.output_height; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Reader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeJPG::Reader:: ~Reader() { if (_is_valid) { @@ -348,19 +334,15 @@ PNMFileTypeJPG::Reader:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Reader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMFileTypeJPG::Reader:: read_data(xel *array, xelval *) { if (!_is_valid) { @@ -398,7 +380,7 @@ read_data(xel *array, xelval *) { */ jpeg_read_scanlines(&_cinfo, buffer, 1); /* Assume put_scanline_someplace wants a pointer and sample count. */ - //put_scanline_someplace(buffer[0], row_stride); + // put_scanline_someplace(buffer[0], row_stride); JSAMPROW bufptr = buffer[0]; for (int i = 0; i < row_stride; i += _cinfo.output_components) { if (_cinfo.output_components == 1) { diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index a73d1c415c..17a9c5ff58 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeJPGWriter.cxx -// Created by: mike (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeJPGWriter.cxx + * @author mike + * @date 2000-06-19 + */ #include "pnmFileTypeJPG.h" @@ -23,11 +22,8 @@ #include "thread.h" -// -// The following bit of code, for setting up jpeg_ostream_src(), was -// lifted from jpeglib, and modified to work with ostream instead of -// stdio. -// +// The following bit of code, for setting up jpeg_ostream_src(), was lifted +// from jpeglib, and modified to work with ostream instead of stdio. /* * jdatadst.c @@ -185,43 +181,33 @@ jpeg_ostream_dest (j_compress_ptr cinfo, ostream * outfile) -// // The rest of the code in this file is new to Panda. -// -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeJPG::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeJPG::Writer::write_data -// Access: Public, Virtual -// Description: Writes out an entire image all at once, including the -// header, based on the image data stored in the given -// _x_size * _y_size array and alpha pointers. (If the -// image type has no alpha channel, alpha is ignored.) -// Returns the number of rows correctly written. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_data(). -// -// It is important to delete the PNMWriter class after -// successfully writing the data. Failing to do this -// may result in some data not getting flushed! -// -// Derived classes need not override this if they -// instead provide supports_streaming() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ int PNMFileTypeJPG::Writer:: write_data(xel *array, xelval *) { if (_y_size<=0 || _x_size<=0) { @@ -328,8 +314,8 @@ write_data(xel *array, xelval *) { } x++; } - //row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - //(void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + // row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; + // (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); row_pointer[0] = row; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx index e1e92d46a6..49cbc2faba 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePNG.cxx -// Created by: drose (16Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePNG.cxx + * @author drose + * @date 2004-03-16 + */ #include "pnmFileTypePNG.h" @@ -31,11 +30,11 @@ TypeHandle PNMFileTypePNG::_type_handle; static const int png_max_palette = 256; -// This STL comparison functor is used in write_data(), below. It -// sorts the non-maxval alpha pixels to the front of the list. +// This STL comparison functor is used in write_data(), below. It sorts the +// non-maxval alpha pixels to the front of the list. class LowAlphaCompare { public: - bool operator() (const PNMImageHeader::PixelSpec &a, + bool operator() (const PNMImageHeader::PixelSpec &a, const PNMImageHeader::PixelSpec &b) { if (a._alpha != b._alpha) { return a._alpha < b._alpha; @@ -44,11 +43,9 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNG:: PNMFileTypePNG() { // This constructor may run at static init time, so we use the -> @@ -59,135 +56,108 @@ PNMFileTypePNG() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypePNG:: get_name() const { return "PNG"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypePNG:: get_num_extensions() const { return num_extensions_png; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypePNG:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_png, string()); return extensions_png[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypePNG:: get_suggested_extension() const { return "png"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypePNG:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypePNG:: matches_magic_number(const string &magic_number) const { return png_sig_cmp((png_bytep)magic_number.data(), 0, magic_number.length()) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypePNG:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypePNG:: make_writer(ostream *file, bool owns_file) { init_pnm(); return new Writer(this, file, owns_file); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypePNG:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypePNG); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::make_PNMFileTypePNG -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypePNG:: make_PNMFileTypePNG(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNG::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -211,9 +181,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : _is_valid = true; if (setjmp(_jmpbuf)) { - // This is the ANSI C way to handle exceptions. If setjmp(), - // above, returns true, it means that libpng detected an exception - // while executing the code that reads the header info, below. + // This is the ANSI C way to handle exceptions. If setjmp(), above, + // returns true, it means that libpng detected an exception while + // executing the code that reads the header info, below. free_png(); return; } @@ -316,29 +286,23 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : png_read_update_info(_png, _info); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNG::Reader:: ~Reader() { free_png(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMFileTypePNG::Reader:: read_data(xel *array, xelval *alpha_data) { if (!is_valid()) { @@ -346,9 +310,9 @@ read_data(xel *array, xelval *alpha_data) { } if (setjmp(_jmpbuf)) { - // This is the ANSI C way to handle exceptions. If setjmp(), - // above, returns true, it means that libpng detected an exception - // while executing the code that reads the image, below. + // This is the ANSI C way to handle exceptions. If setjmp(), above, + // returns true, it means that libpng detected an exception while + // executing the code that reads the image, below. free_png(); return 0; } @@ -366,10 +330,10 @@ read_data(xel *array, xelval *alpha_data) { << " bytes each.\n"; } - // We need to read a full copy of the image in first, in libpng's - // 2-d array format, mainly because we keep array and alpha data - // separately, and there doesn't appear to be good support to get - // this stuff out row-at-a-time for interlaced files. + // We need to read a full copy of the image in first, in libpng's 2-d array + // format, mainly because we keep array and alpha data separately, and there + // doesn't appear to be good support to get this stuff out row-at-a-time for + // interlaced files. png_bytep *rows = (png_bytep *)PANDA_MALLOC_ARRAY(num_rows * sizeof(png_bytep)); int yi; @@ -444,12 +408,9 @@ read_data(xel *array, xelval *alpha_data) { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::free_png -// Access: Private -// Description: Releases the internal PNG structures and marks the -// reader invalid. -//////////////////////////////////////////////////////////////////// +/** + * Releases the internal PNG structures and marks the reader invalid. + */ void PNMFileTypePNG::Reader:: free_png() { if (_is_valid) { @@ -458,12 +419,9 @@ free_png() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::png_read_data -// Access: Private, Static -// Description: A callback handler that PNG uses to read data from -// the iostream. -//////////////////////////////////////////////////////////////////// +/** + * A callback handler that PNG uses to read data from the iostream. + */ void PNMFileTypePNG::Reader:: png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { Reader *self = (Reader *)png_get_io_ptr(png_ptr); @@ -476,35 +434,31 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { Thread::consider_yield(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::png_warning -// Access: Private, Static -// Description: This is our own warning handler. It is called by the -// png library to issue a warning message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own warning handler. It is called by the png library to issue + * a warning message. + */ void PNMFileTypePNG::Reader:: png_warning(png_structp, png_const_charp warning_msg) { pnmimage_png_cat.warning() << warning_msg << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Reader::png_error -// Access: Private, Static -// Description: This is our own error handler. It is called by the -// png library to issue a fatal error message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own error handler. It is called by the png library to issue a + * fatal error message. + */ void PNMFileTypePNG::Reader:: png_error(png_structp png_ptr, png_const_charp error_msg) { pnmimage_png_cat.error() << error_msg << "\n"; - // The PNG library insists we should not return, so instead of - // returning, we will do a longjmp out of the png code. + // The PNG library insists we should not return, so instead of returning, we + // will do a longjmp out of the png code. Reader *self = (Reader *)png_get_io_ptr(png_ptr); if (self == (Reader *)NULL) { - // Oops, we haven't got a self pointer yet. Return anyway and - // hope we'll be ok. + // Oops, we haven't got a self pointer yet. Return anyway and hope we'll + // be ok. pnmimage_png_cat.error() << "Returning before opening file.\n"; return; @@ -513,11 +467,9 @@ png_error(png_structp png_ptr, png_const_charp error_msg) { longjmp(self->_jmpbuf, true); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNG::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) @@ -541,29 +493,23 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNG::Writer:: ~Writer() { free_png(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::write_data -// Access: Public, Virtual -// Description: Writes in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly write. -// -// Derived classes need not override this if they -// instead provide supports_write_row() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * write. + * + * Derived classes need not override this if they instead provide + * supports_write_row() and write_row(), below. + */ int PNMFileTypePNG::Writer:: write_data(xel *array, xelval *alpha_data) { if (!is_valid()) { @@ -571,9 +517,9 @@ write_data(xel *array, xelval *alpha_data) { } if (setjmp(_jmpbuf)) { - // This is the ANSI C way to handle exceptions. If setjmp(), - // above, returns true, it means that libpng detected an exception - // while executing the code that writes the image, below. + // This is the ANSI C way to handle exceptions. If setjmp(), above, + // returns true, it means that libpng detected an exception while + // executing the code that writes the image, below. free_png(); return 0; } @@ -601,11 +547,10 @@ write_data(xel *array, xelval *alpha_data) { color_type |= PNG_COLOR_MASK_ALPHA; } - // Determine if we should make a palettized image out of this. In - // order for this to be possible and effective, we must have no more - // than 256 unique color/alpha combinations for a color image, and - // the resulting bitdepth should be smaller than what we would have - // otherwise. + // Determine if we should make a palettized image out of this. In order for + // this to be possible and effective, we must have no more than 256 unique + // coloralpha combinations for a color image, and the resulting bitdepth + // should be smaller than what we would have otherwise. Palette palette; HistMap palette_lookup; png_color png_palette_table[png_max_palette]; @@ -631,7 +576,7 @@ write_data(xel *array, xelval *alpha_data) { _maxval != (1 << true_bit_depth) - 1) { pnmimage_png_cat.debug() << "palette bit depth of " << palette_bit_depth - << " improves on bit depth of " << total_bits + << " improves on bit depth of " << total_bits << "; making a palette image.\n"; color_type = PNG_COLOR_TYPE_PALETTE; @@ -652,8 +597,8 @@ write_data(xel *array, xelval *alpha_data) { num_alpha = i + 1; } - // Also build a reverse-lookup from color to palette index in - // the "histogram" structure. + // Also build a reverse-lookup from color to palette index in the + // "histogram" structure. palette_lookup[palette[i]] = i; } @@ -666,7 +611,7 @@ write_data(xel *array, xelval *alpha_data) { } else { pnmimage_png_cat.debug() << "palette bit depth of " << palette_bit_depth - << " does not improve on bit depth of " << total_bits + << " does not improve on bit depth of " << total_bits << "; not making a palette image.\n"; } @@ -728,8 +673,8 @@ write_data(xel *array, xelval *alpha_data) { if (png_bit_depth != true_bit_depth) { png_set_shift(_png, &sig_bit); } - // Since this assumes that _maxval is one less than a power of 2, - // we set val_scale to the appropriate factor in case it is not. + // Since this assumes that _maxval is one less than a power of 2, we set + // val_scale to the appropriate factor in case it is not. int png_maxval = (1 << png_bit_depth) - 1; val_scale = (double)png_maxval / (double)_maxval; } @@ -747,10 +692,9 @@ write_data(xel *array, xelval *alpha_data) { << " bytes.\n"; } - // When writing, we only need to copy the image out one row at a - // time, because we don't mess around with writing interlaced files. - // If we were writing an interlaced file, we'd have to copy the - // whole image first. + // When writing, we only need to copy the image out one row at a time, + // because we don't mess around with writing interlaced files. If we were + // writing an interlaced file, we'd have to copy the whole image first. png_bytep row = (png_byte *)PANDA_MALLOC_ARRAY(row_byte_length * sizeof(png_byte)); @@ -885,12 +829,9 @@ write_data(xel *array, xelval *alpha_data) { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::free_png -// Access: Private -// Description: Releases the internal PNG structures and marks the -// writer invalid. -//////////////////////////////////////////////////////////////////// +/** + * Releases the internal PNG structures and marks the writer invalid. + */ void PNMFileTypePNG::Writer:: free_png() { if (_is_valid) { @@ -899,12 +840,10 @@ free_png() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::make_png_bit_depth -// Access: Private, Static -// Description: Elevates the indicated bit depth to one of the legal -// PNG bit depths: 1, 2, 4, 8, or 16. -//////////////////////////////////////////////////////////////////// +/** + * Elevates the indicated bit depth to one of the legal PNG bit depths: 1, 2, + * 4, 8, or 16. + */ int PNMFileTypePNG::Writer:: make_png_bit_depth(int bit_depth) { switch (bit_depth) { @@ -930,12 +869,9 @@ make_png_bit_depth(int bit_depth) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::png_write_data -// Access: Private, Static -// Description: A callback handler that PNG uses to write data to -// the iostream. -//////////////////////////////////////////////////////////////////// +/** + * A callback handler that PNG uses to write data to the iostream. + */ void PNMFileTypePNG::Writer:: png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { Writer *self = (Writer *)png_get_io_ptr(png_ptr); @@ -947,47 +883,40 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::png_flush_data -// Access: Private, Static -// Description: A callback handler that PNG uses to write data to -// the iostream. -//////////////////////////////////////////////////////////////////// +/** + * A callback handler that PNG uses to write data to the iostream. + */ void PNMFileTypePNG::Writer:: png_flush_data(png_structp png_ptr) { Writer *self = (Writer *)png_get_io_ptr(png_ptr); self->_file->flush(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::png_warning -// Access: Private, Static -// Description: This is our own warning handler. It is called by the -// png library to issue a warning message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own warning handler. It is called by the png library to issue + * a warning message. + */ void PNMFileTypePNG::Writer:: png_warning(png_structp, png_const_charp warning_msg) { pnmimage_png_cat.warning() << warning_msg << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNG::Writer::png_error -// Access: Private, Static -// Description: This is our own error handler. It is called by the -// png library to issue a fatal error message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own error handler. It is called by the png library to issue a + * fatal error message. + */ void PNMFileTypePNG::Writer:: png_error(png_structp png_ptr, png_const_charp error_msg) { pnmimage_png_cat.error() << error_msg << "\n"; - // The PNG library insists we should not return, so instead of - // returning, we will do a longjmp out of the png code. + // The PNG library insists we should not return, so instead of returning, we + // will do a longjmp out of the png code. Writer *self = (Writer *)png_get_io_ptr(png_ptr); if (self == (Writer *)NULL) { - // Oops, we haven't got a self pointer yet. Return anyway and - // hope we'll be ok. + // Oops, we haven't got a self pointer yet. Return anyway and hope we'll + // be ok. pnmimage_png_cat.error() << "Returning before opening file.\n"; return; diff --git a/panda/src/pnmimagetypes/pnmFileTypePNG.h b/panda/src/pnmimagetypes/pnmFileTypePNG.h index 9015f57d6b..79b9fb1f73 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNG.h +++ b/panda/src/pnmimagetypes/pnmFileTypePNG.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePNG.h -// Created by: drose (16Mar04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePNG.h + * @author drose + * @date 2004-03-16 + */ #ifndef PNMFILETYPEPNG_H #define PNMFILETYPEPNG_H @@ -26,10 +25,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypePNG -// Description : For reading and writing PNG files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing PNG files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePNG : public PNMFileType { public: PNMFileTypePNG(); @@ -57,7 +55,7 @@ public: private: void free_png(); - static void png_read_data(png_structp png_ptr, png_bytep data, + static void png_read_data(png_structp png_ptr, png_bytep data, png_size_t length); static void png_error(png_structp png_ptr, png_const_charp error_msg); @@ -66,9 +64,9 @@ public: png_structp _png; png_infop _info; - // We need a jmp_buf to support libpng's fatal error handling, in - // which the error handler must not immediately leave libpng code, - // but must return to the caller in Panda. + // We need a jmp_buf to support libpng's fatal error handling, in which + // the error handler must not immediately leave libpng code, but must + // return to the caller in Panda. jmp_buf _jmpbuf; }; @@ -82,7 +80,7 @@ public: private: void free_png(); static int make_png_bit_depth(int bit_depth); - static void png_write_data(png_structp png_ptr, png_bytep data, + static void png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); static void png_flush_data(png_structp png_ptr); @@ -92,9 +90,9 @@ public: png_structp _png; png_infop _info; - // We need a jmp_buf to support libpng's fatal error handling, in - // which the error handler must not immediately leave libpng code, - // but must return to the caller in Panda. + // We need a jmp_buf to support libpng's fatal error handling, in which + // the error handler must not immediately leave libpng code, but must + // return to the caller in Panda. jmp_buf _jmpbuf; }; diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index 6e800c3372..d1ada1a078 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePNM.cxx -// Created by: drose (04Apr98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePNM.cxx + * @author drose + * @date 1998-04-04 + */ #include "pnmFileTypePNM.h" @@ -204,7 +203,7 @@ pm_getuint(istream * const ifP) { } while (ch != EOF && ch != '\n'); } } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); - + if (ch < '0' || ch > '9') pm_error("junk in file where an unsigned integer should be"); @@ -223,9 +222,9 @@ pm_getuint(istream * const ifP) { } static void -ppm_readppminitrest(istream * const file, - int * const colsP, - int * const rowsP, +ppm_readppminitrest(istream * const file, + int * const colsP, + int * const rowsP, pixval * const maxvalP) { unsigned int maxval; @@ -238,7 +237,7 @@ ppm_readppminitrest(istream * const file, if (maxval > PPM_OVERALLMAXVAL) pm_error("maxval of input image (%u) is too large. " "The maximum allowed by the PPM is %u.", - maxval, PPM_OVERALLMAXVAL); + maxval, PPM_OVERALLMAXVAL); if (maxval == 0) pm_error("maxval of input image is zero."); @@ -246,13 +245,13 @@ ppm_readppminitrest(istream * const file, } static void -pgm_readpgminitrest(istream * const file, - int * const colsP, - int * const rowsP, +pgm_readpgminitrest(istream * const file, + int * const colsP, + int * const rowsP, gray * const maxvalP) { gray maxval; - + /* Read size. */ *colsP = (int)pm_getuint(file); *rowsP = (int)pm_getuint(file); @@ -261,7 +260,7 @@ pgm_readpgminitrest(istream * const file, maxval = pm_getuint(file); if (maxval > PGM_OVERALLMAXVAL) pm_error("maxval of input image (%u) is too large. " - "The maximum allowed by PGM is %u.", + "The maximum allowed by PGM is %u.", maxval, PGM_OVERALLMAXVAL); if (maxval == 0) pm_error("maxval of input image is zero."); @@ -301,7 +300,7 @@ pm_getrawbyte(istream * const file) { return (unsigned char) iby; } -static bit +static bit getbit (istream * const file) { char ch; @@ -311,7 +310,7 @@ getbit (istream * const file) { if ( ch != '0' && ch != '1' ) pm_error( "junk in file where bits should be" ); - + return ( ch == '1' ) ? 1 : 0; } @@ -361,7 +360,7 @@ pgm_getrawsample(istream * const file, gray const maxval) { file->read((char *)byte_pair, 2); pairs_read = file->gcount(); - if (pairs_read == 0) + if (pairs_read == 0) pm_error("EOF /read error while reading a long sample"); /* This could be a few instructions faster if exploited the internal format (i.e. endianness) of a pixval. Then we might be able to @@ -372,7 +371,7 @@ pgm_getrawsample(istream * const file, gray const maxval) { } static void -pgm_readpgmrow(istream* const file, gray* const grayrow, +pgm_readpgmrow(istream* const file, gray* const grayrow, int const cols, gray const maxval, int const format) { switch (format) { @@ -382,20 +381,20 @@ pgm_readpgmrow(istream* const file, gray* const grayrow, grayrow[col] = pm_getuint(file); #ifdef DEBUG if (grayrow[col] > maxval) - pm_error( "value out of bounds (%u > %u)", + pm_error( "value out of bounds (%u > %u)", grayrow[col], maxval ); #endif /*DEBUG*/ } } break; - + case RPGM_FORMAT: { int col; for (col = 0; col < cols; ++col) { grayrow[col] = pgm_getrawsample( file, maxval ); #ifdef DEBUG if ( grayrow[col] > maxval ) - pm_error( "value out of bounds (%u > %u)", + pm_error( "value out of bounds (%u > %u)", grayrow[col], maxval ); #endif /*DEBUG*/ } @@ -521,19 +520,19 @@ pnm_readpnmrow( istream* file, xel* xelrow, int cols, xelval maxval, int format } static void -pbm_writepbminit(ostream * const fileP, - int const cols, - int const rows, +pbm_writepbminit(ostream * const fileP, + int const cols, + int const rows, int const forceplain) { if (!forceplain && !pm_plain_output) { - (*fileP) + (*fileP) << (char)PBM_MAGIC1 << (char)RPBM_MAGIC2 << '\n' << cols << ' ' << rows << '\n'; } else { - (*fileP) + (*fileP) << (char)PBM_MAGIC1 << (char)PBM_MAGIC2 << '\n' @@ -542,20 +541,20 @@ pbm_writepbminit(ostream * const fileP, } static void -pgm_writepgminit(ostream * const fileP, - int const cols, - int const rows, - gray const maxval, +pgm_writepgminit(ostream * const fileP, + int const cols, + int const rows, + gray const maxval, int const forceplain) { bool const plainFormat = forceplain || pm_plain_output; - if (maxval > PGM_OVERALLMAXVAL && !plainFormat) + if (maxval > PGM_OVERALLMAXVAL && !plainFormat) pm_error("too-large maxval passed to ppm_writepgminit(): %d.\n" "Maximum allowed by the PGM format is %d.", maxval, PGM_OVERALLMAXVAL); - (*fileP) + (*fileP) << (char)PGM_MAGIC1 << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PGM_MAGIC2 : RPGM_MAGIC2) << '\n' @@ -563,20 +562,20 @@ pgm_writepgminit(ostream * const fileP, } static void -ppm_writeppminit(ostream* const fileP, - int const cols, - int const rows, - pixval const maxval, +ppm_writeppminit(ostream* const fileP, + int const cols, + int const rows, + pixval const maxval, int const forceplain) { bool const plainFormat = forceplain || pm_plain_output; - if (maxval > PPM_OVERALLMAXVAL && !plainFormat) + if (maxval > PPM_OVERALLMAXVAL && !plainFormat) pm_error("too-large maxval passed to ppm_writeppminit(): %d." "Maximum allowed by the PPM format is %d.", maxval, PPM_OVERALLMAXVAL); - (*fileP) + (*fileP) << (char)PPM_MAGIC1 << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PPM_MAGIC2 : RPPM_MAGIC2) << '\n' @@ -584,11 +583,11 @@ ppm_writeppminit(ostream* const fileP, } static void -pnm_writepnminit(ostream * const fileP, - int const cols, - int const rows, - xelval const maxval, - int const format, +pnm_writepnminit(ostream * const fileP, + int const cols, + int const rows, + xelval const maxval, + int const format, int const forceplain) { bool const plainFormat = forceplain || pm_plain_output; @@ -608,7 +607,7 @@ pnm_writepnminit(ostream * const fileP, default: pm_error("invalid format argument received by pnm_writepnminit(): %d" - "PNM_FORMAT_TYPE(format) must be %d, %d, or %d", + "PNM_FORMAT_TYPE(format) must be %d, %d, or %d", format, PBM_TYPE, PGM_TYPE, PPM_TYPE); } } @@ -670,7 +669,7 @@ writePbmRowRaw(ostream * const fileP, /* routine for partial byte at the end of packed_bits[] Prior to addition of the above enhancement, this method was used for the entire process - */ + */ if (cols % 8 > 0) { int col; @@ -683,12 +682,12 @@ writePbmRowRaw(ostream * const fileP, if (bitrow[col] !=0) item |= 1 << bitshift ; - + packedBits[col/8] = item; } - + writePackedRawRow(fileP, packedBits, cols); - + pbm_freerow_packed(packedBits); } @@ -696,9 +695,9 @@ writePbmRowRaw(ostream * const fileP, static void writePbmRowPlain(ostream * const fileP, - bit * const bitrow, + bit * const bitrow, int const cols) { - + int col, charcount; charcount = 0; @@ -714,9 +713,9 @@ writePbmRowPlain(ostream * const fileP, } static void -pbm_writepbmrow(ostream * const fileP, - bit * const bitrow, - int const cols, +pbm_writepbmrow(ostream * const fileP, + bit * const bitrow, + int const cols, int const forceplain) { if (!forceplain && !pm_plain_output) @@ -762,7 +761,7 @@ pgm_writepgmrowraw(ostream *file, gray *grayrow, int cols, gray maxval ) { } static void -putus(unsigned short const n, +putus(unsigned short const n, ostream * const fileP) { if (n >= 10) @@ -773,8 +772,8 @@ putus(unsigned short const n, static void pgm_writepgmrowplain(ostream * const fileP, - gray * const grayrow, - int const cols, + gray * const grayrow, + int const cols, gray const maxval) { int col, charcount; @@ -801,10 +800,10 @@ pgm_writepgmrowplain(ostream * const fileP, } static void -pgm_writepgmrow(ostream* const fileP, - gray* const grayrow, - int const cols, - gray const maxval, +pgm_writepgmrow(ostream* const fileP, + gray* const grayrow, + int const cols, + gray const maxval, int const forceplain) { if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/) @@ -888,15 +887,15 @@ ppm_writeppmrowplain(ostream *file, pixel *pixelrow, int cols, pixval maxval ) { } static void -ppm_writeppmrow(ostream * const fileP, - pixel * const pixelrow, - int const cols, - pixval const maxval, +ppm_writeppmrow(ostream * const fileP, + pixel * const pixelrow, + int const cols, + pixval const maxval, int const forceplain) { if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/) ppm_writeppmrowplain(fileP, pixelrow, cols, maxval); - else + else ppm_writeppmrowraw(fileP, pixelrow, cols, maxval); } @@ -953,79 +952,63 @@ pnm_writepnmrow(ostream * const fileP, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNM:: PNMFileTypePNM() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypePNM:: get_name() const { return "NetPBM-style PBM/PGM/PPM/PNM"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions_PNM associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions_PNM associated + * with this particular file type. + */ int PNMFileTypePNM:: get_num_extensions() const { return num_extensions_PNM; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypePNM:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_PNM, string()); return extensions_PNM[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypePNM:: get_suggested_extension() const { return "ppm"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypePNM:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypePNM:: matches_magic_number(const string &magic_number) const { return (magic_number.size() >= 2) && @@ -1033,26 +1016,22 @@ matches_magic_number(const string &magic_number) const { (magic_number[1] >= '1' && magic_number[1] <= '6'); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypePNM:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypePNM:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -1060,11 +1039,9 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNM::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -1128,38 +1105,29 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader supports a streaming interface to + * reading the data: that is, it is capable of returning the data one row at a + * time, via repeated calls to read_row(). Returns false if the only way to + * read from this file is all at once, via read_data(). + */ bool PNMFileTypePNM::Reader:: supports_read_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -// -// The x_size and y_size parameters are the value of -// _x_size and _y_size as originally filled in by the -// constructor; it is the actual number of pixels in the -// image. (The _x_size and _y_size members may have -// been automatically modified by the time this method -// is called if we are scaling on load, so should not be -// used.) -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + * + * The x_size and y_size parameters are the value of _x_size and _y_size as + * originally filled in by the constructor; it is the actual number of pixels + * in the image. (The _x_size and _y_size members may have been automatically + * modified by the time this method is called if we are scaling on load, so + * should not be used.) + */ bool PNMFileTypePNM::Reader:: read_row(xel *array, xelval *, int x_size, int y_size) { if (!is_valid()) { @@ -1170,46 +1138,36 @@ read_row(xel *array, xelval *, int x_size, int y_size) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePNM::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter supports a streaming interface to + * writing the data: that is, it is capable of writing the image one row at a + * time, via repeated calls to write_row(). Returns false if the only way to + * write from this file is all at once, via write_data(). + */ bool PNMFileTypePNM::Writer:: supports_write_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * to write out the image header in preparation to writing out the image data + * one row at a time. Returns true if the header is successfully written, + * false if there is an error. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_header(). + */ bool PNMFileTypePNM::Writer:: write_header() { switch (get_color_type()) { @@ -1235,21 +1193,17 @@ write_header() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * repeatedly to write the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully written, false if there + * is an error. + * + * You must first call write_header() before writing the individual rows. It + * is also important to delete the PNMWriter class after successfully writing + * the last row. Failing to do this may result in some data not getting + * flushed! + */ bool PNMFileTypePNM::Writer:: write_row(xel *row_data, xelval *) { pnm_writepnmrow(_file, row_data, _x_size, _maxval, _pnm_format, 0); @@ -1257,30 +1211,23 @@ write_row(xel *row_data, xelval *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypePNM:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypePNM); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_PNMFileTypePNM -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypePNM:: make_PNMFileTypePNM(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.h b/panda/src/pnmimagetypes/pnmFileTypePNM.h index 5050e85fe0..1f5bc4cc7d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.h +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePNM.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePNM.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPEPNM_H #define PNMFILETYPEPNM_H @@ -23,11 +22,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypePNM -// Description : For reading and writing basic PNM files--*.pbm, -// *.ppm, *.pnm. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing basic PNM files--*.pbm, *.ppm, *.pnm. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypePNM : public PNMFileType { public: PNMFileTypePNM(); @@ -98,5 +95,3 @@ private: #endif // HAVE_PNM #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx index 09623e496a..71652689ec 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePfm.cxx -// Created by: drose (04Apr98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePfm.cxx + * @author drose + * @date 1998-04-04 + */ #include "pnmFileTypePfm.h" #include "pfmFile.h" @@ -21,78 +20,62 @@ TypeHandle PNMFileTypePfm::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePfm:: PNMFileTypePfm() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypePfm:: get_name() const { return "Portable Float Map"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypePfm:: get_num_extensions() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypePfm:: get_extension(int n) const { return "pfm"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypePfm:: get_suggested_extension() const { return "pfm"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypePfm:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypePfm:: matches_magic_number(const string &magic_number) const { return (magic_number.size() >= 2) && @@ -101,36 +84,30 @@ matches_magic_number(const string &magic_number) const { magic_number.substr(0, 2) == "pf"); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypePfm:: make_reader(istream *file, bool owns_file, const string &magic_number) { return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypePfm:: make_writer(ostream *file, bool owns_file) { return new Writer(this, file, owns_file); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePfm::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -138,9 +115,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : read_magic_number(_file, magic_number, 2); if (magic_number == "pf") { - // In this case, we're probably reading a special-extension - // 4-channel pfm file, and we need a four-byte magic number to - // confirm this and fully identify the file format. + // In this case, we're probably reading a special-extension 4-channel pfm + // file, and we need a four-byte magic number to confirm this and fully + // identify the file format. read_magic_number(_file, magic_number, 4); } @@ -157,7 +134,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } else if (magic_number == "pf4c") { // Special DRZ extension. _num_channels = 4; - + } else { pnmimage_cat.debug() << "Not a PFM file\n"; @@ -175,30 +152,24 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : return; } - // Skip the last newline/whitespace character before the raw data - // begins. + // Skip the last newlinewhitespace character before the raw data begins. (*_file).get(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Reader::is_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType represents a -// floating-point image type, false if it is a normal, -// integer type. If this returns true, read_pfm() is -// implemented instead of read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType represents a floating-point image type, + * false if it is a normal, integer type. If this returns true, read_pfm() is + * implemented instead of read_data(). + */ bool PNMFileTypePfm::Reader:: is_floating_point() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Reader::read_pfm -// Access: Public, Virtual -// Description: Reads floating-point data directly into the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads floating-point data directly into the indicated PfmFile. Returns + * true on success, false on failure. + */ bool PNMFileTypePfm::Reader:: read_pfm(PfmFile &pfm) { if (!is_valid()) { @@ -253,49 +224,39 @@ read_pfm(PfmFile &pfm) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypePfm::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Writer::supports_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept a -// floating-point image type, false if it can only -// accept a normal, integer type. If this returns true, -// write_pfm() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept a floating-point image type, + * false if it can only accept a normal, integer type. If this returns true, + * write_pfm() is implemented. + */ bool PNMFileTypePfm::Writer:: supports_floating_point() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Writer::supports_integer -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept an -// integer image type, false if it can only -// accept a floating-point type. If this returns true, -// write_data() or write_row() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept an integer image type, false if + * it can only accept a floating-point type. If this returns true, + * write_data() or write_row() is implemented. + */ bool PNMFileTypePfm::Writer:: supports_integer() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::Writer::write_pfm -// Access: Public, Virtual -// Description: Writes floating-point data from the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes floating-point data from the indicated PfmFile. Returns true on + * success, false on failure. + */ bool PNMFileTypePfm::Writer:: write_pfm(const PfmFile &pfm) { nassertr(pfm.is_valid(), false); @@ -327,8 +288,8 @@ write_pfm(const PfmFile &pfm) { scale = 1.0f; } #ifndef WORDS_BIGENDIAN - // Little-endian computers must write a negative scale to indicate - // the little-endian nature of the output. + // Little-endian computers must write a negative scale to indicate the + // little-endian nature of the output. scale = -scale; #endif (*_file) << scale << "\n"; @@ -344,30 +305,23 @@ write_pfm(const PfmFile &pfm) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypePfm:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypePfm); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePfm::make_PNMFileTypePfm -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypePfm:: make_PNMFileTypePfm(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypePfm.h b/panda/src/pnmimagetypes/pnmFileTypePfm.h index faf9727496..cbc7bb4512 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePfm.h +++ b/panda/src/pnmimagetypes/pnmFileTypePfm.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypePfm.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypePfm.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPEPFM_H #define PNMFILETYPEPFM_H @@ -22,11 +21,10 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypePfm -// Description : For reading and writing PFM files using the basic -// PNMImage interface, as if they were basic RGB files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing PFM files using the basic PNMImage interface, as if + * they were basic RGB files. + */ class EXPCL_PANDA_PNMIMAGE PNMFileTypePfm : public PNMFileType { public: PNMFileTypePfm(); @@ -48,7 +46,7 @@ public: class Reader : public PNMReader { public: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number); - + virtual bool is_floating_point(); virtual bool read_pfm(PfmFile &pfm); @@ -92,5 +90,3 @@ private: }; #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx index b09b76ec35..e35880daa3 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGI.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSGI.cxx -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSGI.cxx + * @author drose + * @date 2000-06-17 + */ #include "pnmFileTypeSGI.h" @@ -29,79 +28,63 @@ static const int num_extensions_sgi = sizeof(extensions_sgi) / sizeof(const char TypeHandle PNMFileTypeSGI::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSGI:: PNMFileTypeSGI() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeSGI:: get_name() const { return "SGI RGB"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeSGI:: get_num_extensions() const { return num_extensions_sgi; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeSGI:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_sgi, string()); return extensions_sgi[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeSGI:: get_suggested_extension() const { return "rgb"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeSGI:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypeSGI:: matches_magic_number(const string &magic_number) const { nassertr(magic_number.size() >= 2, false); @@ -111,26 +94,22 @@ matches_magic_number(const string &magic_number) const { return (mn == SGI_MAGIC); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeSGI:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeSGI:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -138,30 +117,23 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeSGI:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeSGI); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::make_PNMFileTypeSGI -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeSGI:: make_PNMFileTypeSGI(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGI.h b/panda/src/pnmimagetypes/pnmFileTypeSGI.h index 7e11b22c40..300ccfd777 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGI.h +++ b/panda/src/pnmimagetypes/pnmFileTypeSGI.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSGI.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSGI.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPESGI_H #define PNMFILETYPESGI_H @@ -23,10 +22,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeSGI -// Description : For reading and writing SGI RGB files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing SGI RGB files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeSGI : public PNMFileType { public: PNMFileTypeSGI(); @@ -136,5 +134,3 @@ private: #endif // HAVE_SGI_RGB #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx index 3546477d23..597dc9296a 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIReader.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSGIReader.cxx -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSGIReader.cxx + * @author drose + * @date 2000-06-17 + */ #include "pnmFileTypeSGI.h" @@ -73,17 +72,15 @@ static void rle_decompress (ScanElem *src, long srclen, ScanElem *dest, lo #define MAXVAL_BYTE 255 #define MAXVAL_WORD 65535 -// This flag shouldn't really be a static global, but it's a little -// tricky to fix and it doesn't do any harm, since it only controls -// whether an error message is repeated. +// This flag shouldn't really be a static global, but it's a little tricky to +// fix and it doesn't do any harm, since it only controls whether an error +// message is repeated. static bool eof_err = false; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSGI::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -144,11 +141,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Reader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSGI::Reader:: ~Reader() { if (table != NULL) { @@ -156,30 +151,23 @@ PNMFileTypeSGI::Reader:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader supports a streaming interface to + * reading the data: that is, it is capable of returning the data one row at a + * time, via repeated calls to read_row(). Returns false if the only way to + * read from this file is all at once, via read_data(). + */ bool PNMFileTypeSGI::Reader:: supports_read_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + */ bool PNMFileTypeSGI::Reader:: read_row(xel *row_data, xelval *alpha_data, int x_size, int y_size) { if (!is_valid()) { @@ -265,8 +253,8 @@ read_header(istream *ifp, Header *head, const string &magic_number) { return false; } - // Actually, some old broken SGI image writers put garbage in this - // field, so just ignore it. + // Actually, some old broken SGI image writers put garbage in this field, + // so just ignore it. /* if (head->colormap != CMAP_NORMAL) { pnmimage_sgi_cat.error() @@ -277,10 +265,10 @@ read_header(istream *ifp, Header *head, const string &magic_number) { /* adjust ysize/zsize to dimension, just to be sure */ - // On reflection, this is a bad idea. Ignore the number of - // dimensions, and take the xsize/ysize/zsize at face value. The - // table was written based on these numbers, after all; you can't - // just change them arbitrarily. + // On reflection, this is a bad idea. Ignore the number of dimensions, + // and take the xsizeysizezsize at face value. The table was written + // based on these numbers, after all; you can't just change them + // arbitrarily. /* switch( head->dimension ) { diff --git a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx index fe1bc643c8..f63431bba1 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSGIWriter.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSGIWriter.cxx -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSGIWriter.cxx + * @author drose + * @date 2000-06-17 + */ #include "pnmFileTypeSGI.h" @@ -75,22 +74,18 @@ put_short_as_byte(ostream *out_file, short s) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSGI::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Writer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSGI::Writer:: ~Writer() { if (table!=NULL) { @@ -101,35 +96,27 @@ PNMFileTypeSGI::Writer:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Writer::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter supports a streaming interface to + * writing the data: that is, it is capable of writing the image one row at a + * time, via repeated calls to write_row(). Returns false if the only way to + * write from this file is all at once, via write_data(). + */ bool PNMFileTypeSGI::Writer:: supports_write_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Writer::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * to write out the image header in preparation to writing out the image data + * one row at a time. Returns true if the header is successfully written, + * false if there is an error. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_header(). + */ bool PNMFileTypeSGI::Writer:: write_header() { table = NULL; @@ -171,8 +158,8 @@ write_header() { if (table!=NULL) { table_start = _file->tellp(); - // The first time we write the table, it has zeroes. We'll correct - // this later. + // The first time we write the table, it has zeroes. We'll correct this + // later. write_table(); } @@ -181,21 +168,17 @@ write_header() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSGI::Writer::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * repeatedly to write the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully written, false if there + * is an error. + * + * You must first call write_header() before writing the individual rows. It + * is also important to delete the PNMWriter class after successfully writing + * the last row. Failing to do this may result in some data not getting + * flushed! + */ bool PNMFileTypeSGI::Writer:: write_row(xel *row_data, xelval *alpha_data) { ScanLine channel[4]; diff --git a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx index 789dd56d13..e2d12c3e33 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSoftImage.cxx -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSoftImage.cxx + * @author drose + * @date 2000-06-17 + */ #include "pnmFileTypeSoftImage.h" @@ -26,7 +25,7 @@ static const int imageCommentLength = 80; static const char imageComment[imageCommentLength+1] = "Written by pnmimage."; -// Values to indicate compressed/uncompressed types +// Values to indicate compresseduncompressed types #define UNCOMPRESSED 0x00 #define MIXED_RUN_LENGTH 0x02 @@ -201,79 +200,63 @@ read_scanline(xel *row_data, xelval *alpha_data, int cols, istream *file, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSoftImage:: PNMFileTypeSoftImage() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeSoftImage:: get_name() const { return "SoftImage"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions_softimage associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions_softimage + * associated with this particular file type. + */ int PNMFileTypeSoftImage:: get_num_extensions() const { return num_extensions_softimage; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeSoftImage:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_softimage, string()); return extensions_softimage[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeSoftImage:: get_suggested_extension() const { return "pic"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeSoftImage:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypeSoftImage:: matches_magic_number(const string &magic_number) const { nassertr(magic_number.size() >= 2, false); @@ -283,26 +266,22 @@ matches_magic_number(const string &magic_number) const { return (mn == SOFTIMAGE_MAGIC1); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeSoftImage:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeSoftImage:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -310,11 +289,9 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSoftImage::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -428,30 +405,23 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader supports a streaming interface to + * reading the data: that is, it is capable of returning the data one row at a + * time, via repeated calls to read_row(). Returns false if the only way to + * read from this file is all at once, via read_data(). + */ bool PNMFileTypeSoftImage::Reader:: supports_read_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + */ bool PNMFileTypeSoftImage::Reader:: read_row(xel *row_data, xelval *alpha_data, int x_size, int) { if (!is_valid()) { @@ -581,8 +551,8 @@ write_scanline(xel *row_data, xelval *alpha_data, int cols, ostream *file, int x = 0; int same = true; - // Go through each value in the scanline, from beginning to end, looking - // for runs of identical values. + // Go through each value in the scanline, from beginning to end, looking for + // runs of identical values. while (x < cols) { if (same) { @@ -647,8 +617,7 @@ write_scanline(xel *row_data, xelval *alpha_data, int cols, ostream *file, write_same(row_data, alpha_data, file, write_data, cols-1, run_length); } else { - // Mighty unlikely, but we might have just run over the - // 128-pixel limit. + // Mighty unlikely, but we might have just run over the 128-pixel limit. if (run_length>128) { int excess = run_length - 128; write_diff(row_data, alpha_data, file, write_data, cols-excess-1, 128); @@ -660,46 +629,36 @@ write_scanline(xel *row_data, xelval *alpha_data, int cols, ostream *file, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeSoftImage::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Writer::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMWriter supports a streaming interface to + * writing the data: that is, it is capable of writing the image one row at a + * time, via repeated calls to write_row(). Returns false if the only way to + * write from this file is all at once, via write_data(). + */ bool PNMFileTypeSoftImage::Writer:: supports_write_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Writer::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * to write out the image header in preparation to writing out the image data + * one row at a time. Returns true if the header is successfully written, + * false if there is an error. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_header(). + */ bool PNMFileTypeSoftImage::Writer:: write_header() { write_ushort_SI(_file, SOFTIMAGE_MAGIC1); @@ -729,21 +688,17 @@ write_header() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::Writer::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// +/** + * If supports_write_row(), above, returns true, this function may be called + * repeatedly to write the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully written, false if there + * is an error. + * + * You must first call write_header() before writing the individual rows. It + * is also important to delete the PNMWriter class after successfully writing + * the last row. Failing to do this may result in some data not getting + * flushed! + */ bool PNMFileTypeSoftImage::Writer:: write_row(xel *row_data, xelval *alpha_data) { if (is_grayscale()) { @@ -762,30 +717,23 @@ write_row(xel *row_data, xelval *alpha_data) { -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeSoftImage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeSoftImage); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeSoftImage::make_PNMFileTypeSoftImage -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeSoftImage:: make_PNMFileTypeSoftImage(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h index d73a3edf93..9fffbbd42d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h +++ b/panda/src/pnmimagetypes/pnmFileTypeSoftImage.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeSoftImage.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeSoftImage.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPESOFTIMAGE_H #define PNMFILETYPESOFTIMAGE_H @@ -23,10 +22,9 @@ #include "pnmReader.h" #include "pnmWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeSoftImage -// Description : For reading and SoftImage native image files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and SoftImage native image files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeSoftImage : public PNMFileType { public: PNMFileTypeSoftImage(); @@ -95,5 +93,3 @@ private: #endif // HAVE_SOFTIMAGE_PIC #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index 98dc389348..75e90d630d 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -1,20 +1,18 @@ -// Filename: pnmFileTypeTGA.cxx -// Created by: drose (27Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeTGA.cxx + * @author drose + * @date 2001-04-27 + */ - -// Much code in this file is borrowed from Netpbm, specifically tgatoppm.c -// and ppmtotga.c. +// Much code in this file is borrowed from Netpbm, specifically tgatoppm.c and +// ppmtotga.c. /* tgatoppm.c - read a TrueVision Targa file and write a portable pixmap ** @@ -102,81 +100,65 @@ typedef char ImageIDField[256]; #define TGA_IL_Two 1 #define TGA_IL_Four 2 -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTGA:: PNMFileTypeTGA() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeTGA:: get_name() const { return "Targa"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions_tga associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions_tga associated + * with this particular file type. + */ int PNMFileTypeTGA:: get_num_extensions() const { return num_extensions_tga; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeTGA:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_tga, string()); return extensions_tga[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeTGA:: get_suggested_extension() const { return "tga"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeTGA:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeTGA:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -184,11 +166,9 @@ make_writer(ostream *file, bool owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTGA::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -321,15 +301,13 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : _x_size = cols; _y_size = rows; - //_num_channels = 3; + // _num_channels = 3; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Reader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTGA::Reader:: ~Reader() { delete tga_head; @@ -341,19 +319,15 @@ PNMFileTypeTGA::Reader:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Reader::read_data -// Access: Public, Virtual -// Description: Reads in an entire image all at once, storing it in -// the pre-allocated _x_size * _y_size array and alpha -// pointers. (If the image type has no alpha channel, -// alpha is ignored.) Returns the number of rows -// correctly read. -// -// Derived classes need not override this if they -// instead provide supports_read_row() and read_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Reads in an entire image all at once, storing it in the pre-allocated + * _x_size * _y_size array and alpha pointers. (If the image type has no + * alpha channel, alpha is ignored.) Returns the number of rows correctly + * read. + * + * Derived classes need not override this if they instead provide + * supports_read_row() and read_row(), below. + */ int PNMFileTypeTGA::Reader:: read_data(xel *array, xelval *alpha) { int truerow = 0; @@ -381,11 +355,9 @@ read_data(xel *array, xelval *alpha) { return rows; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTGA::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) @@ -396,11 +368,9 @@ Writer(PNMFileType *type, ostream *file, bool owns_file) : runlength = (int*)0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::Writer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTGA::Writer:: ~Writer() { delete tgaHeader; @@ -416,32 +386,26 @@ PNMFileTypeTGA::Writer:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeBMP::Writer::write_data -// Access: Public, Virtual -// Description: Writes out an entire image all at once, including the -// header, based on the image data stored in the given -// _x_size * _y_size array and alpha pointers. (If the -// image type has no alpha channel, alpha is ignored.) -// Returns the number of rows correctly written. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_data(). -// -// It is important to delete the PNMWriter class after -// successfully writing the data. Failing to do this -// may result in some data not getting flushed! -// -// Derived classes need not override this if they -// instead provide supports_streaming() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ int PNMFileTypeTGA::Writer:: write_data(xel *array, xelval *) { - // We don't presently support writing 4-channel tga files (since - // ppmtotga doesn't support this). + // We don't presently support writing 4-channel tga files (since ppmtotga + // doesn't support this). rle_flag = tga_rle; int row, col; @@ -585,30 +549,23 @@ write_data(xel *array, xelval *) { -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeTGA:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeTGA); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTGA::make_PNMFileTypeTGA -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeTGA:: make_PNMFileTypeTGA(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); @@ -674,7 +631,7 @@ get_map_entry( istream *ifp, pixel *Value, int Size, gray *Alpha ) { r = g = b = getbyte( ifp ); a = 0; break; - + case 16: /* 5 bits each of red green and blue. */ case 15: /* Watch for byte order. */ j = getbyte( ifp ); @@ -695,7 +652,7 @@ get_map_entry( istream *ifp, pixel *Value, int Size, gray *Alpha ) { else a = 0; break; - + default: pm_error( "unknown colormap pixel size (#2) - %d", Size ); } @@ -789,7 +746,7 @@ getbyte( istream *ifp ) { unsigned char c; c = ifp->get(); - if (ifp->fail() || ifp->eof()) + if (ifp->fail() || ifp->eof()) pm_error( "EOF / read error" ); return c; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.h b/panda/src/pnmimagetypes/pnmFileTypeTGA.h index 8b676bd848..911ebb7c20 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeTGA.h -// Created by: drose (27Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeTGA.h + * @author drose + * @date 2001-04-27 + */ #ifndef PNMFILETYPETGA_H #define PNMFILETYPETGA_H @@ -28,10 +27,9 @@ struct ImageHeader; -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeTGA -// Description : For reading and writing Targa image files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing Targa image files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeTGA : public PNMFileType { public: PNMFileTypeTGA(); @@ -126,5 +124,3 @@ private: #endif // HAVE_TGA #endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index ab09b1f034..46248cf9f0 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeTIFF.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeTIFF.cxx + * @author drose + * @date 2000-06-19 + */ #include "pnmFileTypeTIFF.h" @@ -39,11 +38,11 @@ static const char * const extensions_tiff[] = { }; static const int num_extensions_tiff = sizeof(extensions_tiff) / sizeof(const char *); -// These are configurable parameters to specify TIFF details on -// output. See tiff.h or type man pnmtotiff for a better explanation -// of options. +// These are configurable parameters to specify TIFF details on output. See +// tiff.h or type man pnmtotiff for a better explanation of options. -//unsigned short tiff_compression = COMPRESSION_LZW; // lzw not supported anymore because of big bad Unisys +// unsigned short tiff_compression = COMPRESSION_LZW; lzw not supported +// anymore because of big bad Unisys unsigned short tiff_compression = COMPRESSION_NONE; /* One of: @@ -81,8 +80,8 @@ short tiff_predictor = 0; #define PHOTOMETRIC_DEPTH 32768 #endif -// Here's a number of functions to support the iostream interface -// via the TIFF library. +// Here's a number of functions to support the iostream interface via the TIFF +// library. static tsize_t istream_read(thandle_t fd, tdata_t buf, tsize_t size) { istream *in = (istream *)fd; @@ -101,15 +100,15 @@ ostream_write(thandle_t fd, tdata_t buf, tsize_t size) { static tsize_t ostream_dont_read(thandle_t, tdata_t, tsize_t) { - // This no-op variant of istream_read() is passed in when we open the - // file for writing only. Shouldn't mix reads and writes. + // This no-op variant of istream_read() is passed in when we open the file + // for writing only. Shouldn't mix reads and writes. return 0; } static tsize_t istream_dont_write(thandle_t, tdata_t, tsize_t) { - // This no-op variant of ostream_write() is passed in when we open the - // file for reading only. Shouldn't mix reads and writes. + // This no-op variant of ostream_write() is passed in when we open the file + // for reading only. Shouldn't mix reads and writes. return 0; } @@ -139,7 +138,7 @@ istream_seek(thandle_t fd, toff_t off, int whence) { if (pnmimage_tiff_cat->is_spam()) { pnmimage_tiff_cat->spam() - << "istream_seek(" << (void *)in << ", " << off << ", " + << "istream_seek(" << (void *)in << ", " << off << ", " << whence << "), result = " << in->tellg() << "\n"; } return in->tellg(); @@ -171,7 +170,7 @@ ostream_seek(thandle_t fd, toff_t off, int whence) { if (pnmimage_tiff_cat->is_spam()) { pnmimage_tiff_cat->spam() - << "ostream_seek(" << (void *)out << ", " << off << ", " + << "ostream_seek(" << (void *)out << ", " << off << ", " << whence << "), result = " << out->tellp() << "\n"; } return out->tellp(); @@ -209,11 +208,9 @@ iostream_unmap(thandle_t, tdata_t, toff_t) { bool PNMFileTypeTIFF::_installed_error_handlers = false; TypeHandle PNMFileTypeTIFF::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTIFF:: PNMFileTypeTIFF() { // This constructor may run at static init time, so we use the -> @@ -224,70 +221,56 @@ PNMFileTypeTIFF() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a few words describing the file type. + */ string PNMFileTypeTIFF:: get_name() const { return "TIFF"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions associated with this particular file type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different possible filename extensions associated + * with this particular file type. + */ int PNMFileTypeTIFF:: get_num_extensions() const { return num_extensions_tiff; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth possible filename extension associated with this particular + * file type, without a leading dot. + */ string PNMFileTypeTIFF:: get_extension(int n) const { nassertr(n >= 0 && n < num_extensions_tiff, string()); return extensions_tiff[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable filename extension (without a leading dot) to suggest + * for files of this type, or empty string if no suggestions are available. + */ string PNMFileTypeTIFF:: get_suggested_extension() const { return "tiff"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular file type uses a magic number to identify + * it, false otherwise. + */ bool PNMFileTypeTIFF:: has_magic_number() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated "magic number" byte stream (the initial few + * bytes read from the file) matches this particular file type, false + * otherwise. + */ bool PNMFileTypeTIFF:: matches_magic_number(const string &magic_number) const { nassertr(magic_number.size() >= 2, false); @@ -297,13 +280,11 @@ matches_magic_number(const string &magic_number) const { return (mn == TIFF_BIGENDIAN || mn == TIFF_LITTLEENDIAN); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMReader suitable for reading from this file + * type, if possible. If reading from this file type is not supported, + * returns NULL. + */ PNMReader *PNMFileTypeTIFF:: make_reader(istream *file, bool owns_file, const string &magic_number) { init_pnm(); @@ -311,13 +292,11 @@ make_reader(istream *file, bool owns_file, const string &magic_number) { return new Reader(this, file, owns_file, magic_number); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new PNMWriter suitable for reading from this file + * type, if possible. If writing files of this type is not supported, returns + * NULL. + */ PNMWriter *PNMFileTypeTIFF:: make_writer(ostream *file, bool owns_file) { init_pnm(); @@ -325,11 +304,9 @@ make_writer(ostream *file, bool owns_file) { return new Writer(this, file, owns_file); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTIFF::Reader:: Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : PNMReader(type, file, owns_file) @@ -399,7 +376,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : unsigned short num_extra_samples; unsigned short *extra_samples = NULL; - if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &num_extra_samples, + if (!TIFFGetField(tif, TIFFTAG_EXTRASAMPLES, &num_extra_samples, &extra_samples)) { num_extra_samples = 0; } @@ -408,8 +385,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : assoc_alpha_sample = 0; if (_num_channels == 1 || _num_channels == 3) { - // Look for an alpha channel in one of the extra samples, if - // any. + // Look for an alpha channel in one of the extra samples, if any. bool got_alpha = false; for (unsigned short s = 0; s < num_extra_samples && !got_alpha; s++) { if (extra_samples[s] == EXTRASAMPLE_UNASSALPHA) { @@ -424,10 +400,10 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } - // Unfortunately, Photoshop seems to write - // EXTRASAMPLE_UNSPECIFIED into the EXTRASAMPLES field for its - // alpha channels. If we have exactly one extra channel and - // it's an UNSPECIFIED channel, assume it's meant to be alpha. + // Unfortunately, Photoshop seems to write EXTRASAMPLE_UNSPECIFIED into + // the EXTRASAMPLES field for its alpha channels. If we have exactly + // one extra channel and it's an UNSPECIFIED channel, assume it's meant + // to be alpha. if (!got_alpha && num_extra_samples == 1 && extra_samples[0] == EXTRASAMPLE_UNSPECIFIED) { unassoc_alpha_sample = _num_channels; @@ -435,10 +411,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } else if ((_num_channels == 2 || _num_channels == 4) && num_extra_samples == 0) { - // If we have a 2- or 4-channel image but the extra samples are - // not declared, assume it was written out by a broken TIFF - // implementation and that the extra channel is really meant to - // be alpha. + // If we have a 2- or 4-channel image but the extra samples are not + // declared, assume it was written out by a broken TIFF implementation + // and that the extra channel is really meant to be alpha. unassoc_alpha_sample = _num_channels - 1; if (pnmimage_tiff_cat.is_debug()) { pnmimage_tiff_cat.debug() @@ -448,7 +423,7 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } else { pnmimage_tiff_cat.error() - << "Cannot handle " << spp << "-color image (with " + << "Cannot handle " << spp << "-color image (with " << num_extra_samples << " extra channels).\n"; _is_valid = false; } @@ -567,11 +542,9 @@ Reader(PNMFileType *type, istream *file, bool owns_file, string magic_number) : } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTIFF::Reader:: ~Reader() { if (tif != (struct tiff *)NULL) { @@ -579,25 +552,20 @@ PNMFileTypeTIFF::Reader:: } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::is_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType represents a -// floating-point image type, false if it is a normal, -// integer type. If this returns true, read_pfm() is -// implemented instead of read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType represents a floating-point image type, + * false if it is a normal, integer type. If this returns true, read_pfm() is + * implemented instead of read_data(). + */ bool PNMFileTypeTIFF::Reader:: is_floating_point() { return (sample_format == SAMPLEFORMAT_IEEEFP); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::read_pfm -// Access: Public, Virtual -// Description: Reads floating-point data directly into the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads floating-point data directly into the indicated PfmFile. Returns + * true on success, false on failure. + */ bool PNMFileTypeTIFF::Reader:: read_pfm(PfmFile &pfm) { if (!is_valid()) { @@ -627,30 +595,23 @@ read_pfm(PfmFile &pfm) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular PNMReader supports a streaming interface to + * reading the data: that is, it is capable of returning the data one row at a + * time, via repeated calls to read_row(). Returns false if the only way to + * read from this file is all at once, via read_data(). + */ bool PNMFileTypeTIFF::Reader:: supports_read_row() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -//////////////////////////////////////////////////////////////////// +/** + * If supports_read_row(), above, returns true, this function may be called + * repeatedly to read the image, one horizontal row at a time, beginning from + * the top. Returns true if the row is successfully read, false if there is + * an error or end of file. + */ bool PNMFileTypeTIFF::Reader:: read_row(xel *row_data, xelval *alpha_data, int x_size, int) { if (!is_valid()) { @@ -659,7 +620,7 @@ read_row(xel *row_data, xelval *alpha_data, int x_size, int) { size_t scanline_size = (size_t)TIFFScanlineSize(tif); unsigned char *buf = (unsigned char*) alloca(scanline_size); - + int col; xelval gray, sample; xelval r, g, b; @@ -674,14 +635,14 @@ read_row(xel *row_data, xelval *alpha_data, int x_size, int) { unsigned s; int bits_left = 8; - // Get a pointer to a function that extracts the next bps-bit sample - // from the bitarray. There are a handful of different functions, - // which are optimized for different values of bps. + // Get a pointer to a function that extracts the next bps-bit sample from + // the bitarray. There are a handful of different functions, which are + // optimized for different values of bps. xelval (PNMFileTypeTIFF::Reader::*next_sample)(unsigned char *&buf_ptr, int &bits_left) const; if (bps < 8) { next_sample = &PNMFileTypeTIFF::Reader::next_sample_lt_8; - + } else if (bps == 8) { next_sample = &PNMFileTypeTIFF::Reader::next_sample_8; @@ -689,8 +650,8 @@ read_row(xel *row_data, xelval *alpha_data, int x_size, int) { next_sample = &PNMFileTypeTIFF::Reader::next_sample_16; } else if (bps == 32) { - // Actually, it's not likely that a 32-bit sample will fit within - // a xelval. Deal with this when we come to it. + // Actually, it's not likely that a 32-bit sample will fit within a + // xelval. Deal with this when we come to it. next_sample = &PNMFileTypeTIFF::Reader::next_sample_32; } else { @@ -784,7 +745,7 @@ read_row(xel *row_data, xelval *alpha_data, int x_size, int) { sample = (this->*next_sample)(buf_ptr, bits_left); if (s == unassoc_alpha_sample) { alpha_data[col] = sample; - + } else if (s == assoc_alpha_sample) { alpha_data[col] = sample; if (sample != 0) { @@ -811,12 +772,9 @@ read_row(xel *row_data, xelval *alpha_data, int x_size, int) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::next_sample_lt_8 -// Access: Private -// Description: Returns the next color sample from the row, when it -// is known that bps < 8. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next color sample from the row, when it is known that bps < 8. + */ xelval PNMFileTypeTIFF::Reader:: next_sample_lt_8(unsigned char *&buf_ptr, int &bits_left) const { if (bits_left == 0) { @@ -828,54 +786,44 @@ next_sample_lt_8(unsigned char *&buf_ptr, int &bits_left) const { return (*buf_ptr >> bits_left) & _maxval; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::next_sample_8 -// Access: Private -// Description: Returns the next color sample from the row, when it -// is known that bps == 8. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next color sample from the row, when it is known that bps == 8. + */ xelval PNMFileTypeTIFF::Reader:: next_sample_8(unsigned char *&buf_ptr, int &bits_left) const { return *buf_ptr++; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::next_sample_16 -// Access: Private -// Description: Returns the next color sample from the row, when it -// is known that bps == 16. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next color sample from the row, when it is known that bps == + * 16. + */ xelval PNMFileTypeTIFF::Reader:: next_sample_16(unsigned char *&buf_ptr, int &bits_left) const { - // The TIFF library has already byte-swapped the values if - // necessary. Thus, we only need to treat it as an array of shorts. + // The TIFF library has already byte-swapped the values if necessary. Thus, + // we only need to treat it as an array of shorts. unsigned short result = *(unsigned short *)buf_ptr; buf_ptr += 2; return result; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::next_sample_32 -// Access: Private -// Description: Returns the next color sample from the row, when it -// is known that bps == 32. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next color sample from the row, when it is known that bps == + * 32. + */ xelval PNMFileTypeTIFF::Reader:: next_sample_32(unsigned char *&buf_ptr, int &bits_left) const { - // The TIFF library has already byte-swapped the values if - // necessary. Thus, we only need to treat it as an array of longs. + // The TIFF library has already byte-swapped the values if necessary. Thus, + // we only need to treat it as an array of longs. unsigned long result = *(unsigned long *)buf_ptr; buf_ptr += 2; return (xelval)result; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Reader::next_sample_general -// Access: Private -// Description: Returns the next color sample from the row, in -// general. This unpacks an arbitrary string of bits -// from the sequence. -//////////////////////////////////////////////////////////////////// +/** + * Returns the next color sample from the row, in general. This unpacks an + * arbitrary string of bits from the sequence. + */ xelval PNMFileTypeTIFF::Reader:: next_sample_general(unsigned char *&buf_ptr, int &bits_left) const { unsigned int result = 0; @@ -887,13 +835,13 @@ next_sample_general(unsigned char *&buf_ptr, int &bits_left) const { ++buf_ptr; bits_left = 8; } - + if (bits_needed <= bits_left) { bits_left -= bits_needed; unsigned int mask = (1 << bits_needed) - 1; result |= ((*buf_ptr) >> bits_left) & mask; bits_needed = 0; - + } else { bits_needed -= bits_left; unsigned int mask = (1 << bits_left) - 1; @@ -906,49 +854,39 @@ next_sample_general(unsigned char *&buf_ptr, int &bits_left) const { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMFileTypeTIFF::Writer:: Writer(PNMFileType *type, ostream *file, bool owns_file) : PNMWriter(type, file, owns_file) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Writer::supports_floating_point -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept a -// floating-point image type, false if it can only -// accept a normal, integer type. If this returns true, -// write_pfm() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept a floating-point image type, + * false if it can only accept a normal, integer type. If this returns true, + * write_pfm() is implemented. + */ bool PNMFileTypeTIFF::Writer:: supports_floating_point() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Writer::supports_integer -// Access: Public, Virtual -// Description: Returns true if this PNMFileType can accept an -// integer image type, false if it can only -// accept a floating-point type. If this returns true, -// write_data() or write_row() is implemented. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this PNMFileType can accept an integer image type, false if + * it can only accept a floating-point type. If this returns true, + * write_data() or write_row() is implemented. + */ bool PNMFileTypeTIFF::Writer:: supports_integer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Writer::write_pfm -// Access: Public, Virtual -// Description: Writes floating-point data from the indicated -// PfmFile. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes floating-point data from the indicated PfmFile. Returns true on + * success, false on failure. + */ bool PNMFileTypeTIFF::Writer:: write_pfm(const PfmFile &pfm) { struct tiff *tif; @@ -1002,28 +940,22 @@ write_pfm(const PfmFile &pfm) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::Writer::write_data -// Access: Public, Virtual -// Description: Writes out an entire image all at once, including the -// header, based on the image data stored in the given -// _x_size * _y_size array and alpha pointers. (If the -// image type has no alpha channel, alpha is ignored.) -// Returns the number of rows correctly written. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_data(). -// -// It is important to delete the PNMWriter class after -// successfully writing the data. Failing to do this -// may result in some data not getting flushed! -// -// Derived classes need not override this if they -// instead provide supports_streaming() and write_row(), -// below. -//////////////////////////////////////////////////////////////////// +/** + * Writes out an entire image all at once, including the header, based on the + * image data stored in the given _x_size * _y_size array and alpha pointers. + * (If the image type has no alpha channel, alpha is ignored.) Returns the + * number of rows correctly written. + * + * It is the user's responsibility to fill in the header data via calls to + * set_x_size(), set_num_channels(), etc., or copy_header_from(), before + * calling write_data(). + * + * It is important to delete the PNMWriter class after successfully writing + * the data. Failing to do this may result in some data not getting flushed! + * + * Derived classes need not override this if they instead provide + * supports_streaming() and write_row(), below. + */ int PNMFileTypeTIFF::Writer:: write_data(xel *array, xelval *alpha) { colorhist_vector chv = (colorhist_vector) 0; @@ -1046,12 +978,12 @@ write_data(xel *array, xelval *alpha) { switch ( get_color_type() ) { case CT_color: - // This call is a bit of fakery to convert our proper 2-d array of - // xels to an indirect 2-d array of pixels. We make it look like a - // single row of _x_size * _y_size pixels. + // This call is a bit of fakery to convert our proper 2-d array of xels to + // an indirect 2-d array of pixels. We make it look like a single row of + // _x_size * _y_size pixels. - // We can't actually write palettes bigger than 256 colors, - // regardless of the number of colors we can read. + // We can't actually write palettes bigger than 256 colors, regardless of + // the number of colors we can read. chv = ppm_computecolorhist( (pixel **)&array, _x_size * _y_size, 1, 256, &colors ); if ( chv == (colorhist_vector) 0 ) { @@ -1159,7 +1091,7 @@ write_data(xel *array, xelval *alpha) { TIFFSetField( tif, TIFFTAG_PREDICTOR, tiff_predictor ); TIFFSetField( tif, TIFFTAG_PHOTOMETRIC, photometric ); TIFFSetField( tif, TIFFTAG_FILLORDER, tiff_fillorder ); - //TIFFSetField( tif, TIFFTAG_DOCUMENTNAME, "TIFF Image File"); + // TIFFSetField( tif, TIFFTAG_DOCUMENTNAME, "TIFF Image File"); TIFFSetField( tif, TIFFTAG_IMAGEDESCRIPTION, "Generated via pnmimage.\n" ); TIFFSetField( tif, TIFFTAG_SAMPLESPERPIXEL, samplesperpixel ); @@ -1256,15 +1188,11 @@ write_data(xel *array, xelval *alpha) { return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::install_error_handlers -// Access: Private -// Description: Installs our personal error and warning message -// handlers if they have not already been installed. -// These methods are used to route the Tiff error -// messages through notify, so we can turn some of them -// off. -//////////////////////////////////////////////////////////////////// +/** + * Installs our personal error and warning message handlers if they have not + * already been installed. These methods are used to route the Tiff error + * messages through notify, so we can turn some of them off. + */ void PNMFileTypeTIFF:: install_error_handlers() { if (!_installed_error_handlers) { @@ -1274,12 +1202,10 @@ install_error_handlers() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::tiff_warning -// Access: Private, Static -// Description: This is our own warning handler. It is called by the -// tiff library to issue a warning message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own warning handler. It is called by the tiff library to issue + * a warning message. + */ void PNMFileTypeTIFF:: tiff_warning(const char *, const char *format, va_list ap) { static const int buffer_size = 1024; @@ -1295,12 +1221,10 @@ tiff_warning(const char *, const char *format, va_list ap) { << buffer << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::tiff_error -// Access: Private, Static -// Description: This is our own error handler. It is called by the -// tiff library to issue a error message. -//////////////////////////////////////////////////////////////////// +/** + * This is our own error handler. It is called by the tiff library to issue a + * error message. + */ void PNMFileTypeTIFF:: tiff_error(const char *module, const char *format, va_list ap) { static const int buffer_size = 1024; @@ -1317,30 +1241,23 @@ tiff_error(const char *module, const char *format, va_list ap) { } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PNMFileTypeTIFF:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PNMFileTypeTIFF); } -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypeTIFF::make_PNMFileTypeTIFF -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + * + * In the case of the PNMFileType objects, since these objects are all shared, + * we just pull the object from the registry. + */ TypedWritable *PNMFileTypeTIFF:: make_PNMFileTypeTIFF(const FactoryParams ¶ms) { return PNMFileTypeRegistry::get_global_ptr()->get_type_by_handle(get_class_type()); diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.h b/panda/src/pnmimagetypes/pnmFileTypeTIFF.h index 07f54faf82..21466b2cd9 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.h @@ -1,16 +1,15 @@ -// Filename: pnmFileTypeTIFF.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmFileTypeTIFF.h + * @author drose + * @date 2000-06-17 + */ #ifndef PNMFILETYPETIFF_H #define PNMFILETYPETIFF_H @@ -28,10 +27,9 @@ #define TIFF_COLORMAP_MAXCOLORS 1024 -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypeTIFF -// Description : For reading and writing TIFF files. -//////////////////////////////////////////////////////////////////// +/** + * For reading and writing TIFF files. + */ class EXPCL_PANDA_PNMIMAGETYPES PNMFileTypeTIFF : public PNMFileType { public: PNMFileTypeTIFF(); diff --git a/panda/src/pnmimagetypes/sgi.h b/panda/src/pnmimagetypes/sgi.h index ec14d0beca..cede0f1542 100644 --- a/panda/src/pnmimagetypes/sgi.h +++ b/panda/src/pnmimagetypes/sgi.h @@ -1,8 +1,4 @@ -/* Filename: sgi.h - * Created by: - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,8 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file sgi.h + */ #ifndef SGI_IMAGE_H #define SGI_IMAGE_H diff --git a/panda/src/pnmtext/config_pnmtext.cxx b/panda/src/pnmtext/config_pnmtext.cxx index aa0cab7c93..b806b8d048 100644 --- a/panda/src/pnmtext/config_pnmtext.cxx +++ b/panda/src/pnmtext/config_pnmtext.cxx @@ -1,16 +1,15 @@ -// Filename: config_pnmtext.cxx -// Created by: drose (08Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmtext.cxx + * @author drose + * @date 2003-09-08 + */ #include "config_pnmtext.h" @@ -33,14 +32,12 @@ ConfigVariableDouble text_scale_factor ConfigVariableBool text_native_antialias ("text-native-antialias", true); -//////////////////////////////////////////////////////////////////// -// Function: init_libpnmtext -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpnmtext() { static bool initialized = false; diff --git a/panda/src/pnmtext/config_pnmtext.h b/panda/src/pnmtext/config_pnmtext.h index 5301b71411..48bb1d82c5 100644 --- a/panda/src/pnmtext/config_pnmtext.h +++ b/panda/src/pnmtext/config_pnmtext.h @@ -1,16 +1,15 @@ -// Filename: config_pnmtext.h -// Created by: drose (08Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pnmtext.h + * @author drose + * @date 2003-09-08 + */ #ifndef CONFIG_PNMTEXT_H #define CONFIG_PNMTEXT_H diff --git a/panda/src/pnmtext/freetypeFace.I b/panda/src/pnmtext/freetypeFace.I index 4fc73d665c..7661fd2e0b 100644 --- a/panda/src/pnmtext/freetypeFace.I +++ b/panda/src/pnmtext/freetypeFace.I @@ -1,14 +1,12 @@ -// Filename: freetypeFace.I -// Created by: gogg (16Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFace.I + * @author gogg + * @date 2009-11-16 + */ diff --git a/panda/src/pnmtext/freetypeFace.cxx b/panda/src/pnmtext/freetypeFace.cxx index 231e0b9133..0366e3c49a 100644 --- a/panda/src/pnmtext/freetypeFace.cxx +++ b/panda/src/pnmtext/freetypeFace.cxx @@ -1,16 +1,15 @@ -// Filename: freetypeFace.cxx -// Created by: gogg (16Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFace.cxx + * @author gogg + * @date 2009-11-16 + */ #include "freetypeFace.h" @@ -24,11 +23,9 @@ bool FreetypeFace::_ft_ok = false; TypeHandle FreetypeFace::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FreetypeFace:: FreetypeFace() : _lock("FreetypeFace::_lock") { _face = NULL; @@ -42,11 +39,9 @@ FreetypeFace() : _lock("FreetypeFace::_lock") { } } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FreetypeFace:: ~FreetypeFace() { if (_face != NULL){ @@ -54,17 +49,14 @@ FreetypeFace:: } } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::acquire_face -// Access: Public -// Description: Retrieves the internal freetype face, and also -// acquires the lock. The freetype face is set to the -// indicated size, either as a char_size and dpi, or as -// a specific pixel_width and height, before returning. -// -// You must call release_face() when you are done using -// it, to release the lock. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the internal freetype face, and also acquires the lock. The + * freetype face is set to the indicated size, either as a char_size and dpi, + * or as a specific pixel_width and height, before returning. + * + * You must call release_face() when you are done using it, to release the + * lock. + */ FT_Face FreetypeFace:: acquire_face(int char_size, int dpi, int pixel_width, int pixel_height) { _lock.acquire(); @@ -92,24 +84,19 @@ acquire_face(int char_size, int dpi, int pixel_width, int pixel_height) { return _face; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::release_face -// Access: Public -// Description: Releases the lock acquired by a previous call to -// acquire_face(), and allows another thread to use the -// face. -//////////////////////////////////////////////////////////////////// +/** + * Releases the lock acquired by a previous call to acquire_face(), and allows + * another thread to use the face. + */ void FreetypeFace:: release_face(FT_Face face) { nassertv(_face == face); _lock.release(); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::set_face -// Access: Public -// Description: Replaces the internal freetype face. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the internal freetype face. + */ void FreetypeFace:: set_face(FT_Face face) { MutexHolder holder(_lock); @@ -128,7 +115,7 @@ set_face(FT_Face face) { _name += " "; _name += _face->style_name; } - + pnmtext_cat.info() << "Loaded font " << _name << "\n"; @@ -143,8 +130,8 @@ set_face(FT_Face face) { << "default charmap is " << (void *)_face->charmap << "\n"; } if (_face->charmap == NULL) { - // If for some reason FreeType didn't set us up a charmap, - // then set it up ourselves. + // If for some reason FreeType didn't set us up a charmap, then set it up + // ourselves. if (_face->num_charmaps == 0) { pnmtext_cat.warning() << _name << " has no charmaps available.\n"; @@ -153,7 +140,7 @@ set_face(FT_Face face) { << _name << " has no default Unicode charmap.\n"; if (_face->num_charmaps > 1) { pnmtext_cat.warning() - << "Arbitrarily choosing first of " + << "Arbitrarily choosing first of " << _face->num_charmaps << " charmaps.\n"; } FT_Set_Charmap(_face, _face->charmaps[0]); @@ -161,12 +148,9 @@ set_face(FT_Face face) { } } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFace::initialize_ft_library -// Access: Private, Static -// Description: Should be called exactly once to initialize the -// FreeType library. -//////////////////////////////////////////////////////////////////// +/** + * Should be called exactly once to initialize the FreeType library. + */ void FreetypeFace:: initialize_ft_library() { if (!_ft_initialized) { diff --git a/panda/src/pnmtext/freetypeFace.h b/panda/src/pnmtext/freetypeFace.h index ee200eff89..2070e5ca66 100644 --- a/panda/src/pnmtext/freetypeFace.h +++ b/panda/src/pnmtext/freetypeFace.h @@ -1,16 +1,15 @@ -// Filename: freetypeFace.h -// Created by: gogg (16Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFace.h + * @author gogg + * @date 2009-11-16 + */ #ifndef FREETYPEFACE_H #define FREETYPEFACE_H @@ -27,13 +26,11 @@ #include #include FT_FREETYPE_H -//////////////////////////////////////////////////////////////////// -// Class : FreetypeFont -// Description : This is a reference-counted wrapper for the -// freetype font face object (FT_Face). -// It's used by the FreetypeFont class to store a face -// that can be shared between copied instances. -//////////////////////////////////////////////////////////////////// +/** + * This is a reference-counted wrapper for the freetype font face object + * (FT_Face). It's used by the FreetypeFont class to store a face that can be + * shared between copied instances. + */ class EXPCL_PANDA_PNMTEXT FreetypeFace : public TypedReferenceCount, public Namable { public: FreetypeFace(); @@ -48,8 +45,7 @@ private: static void initialize_ft_library(); private: - // This is provided as a permanent storage for the raw font data, if - // needed. + // This is provided as a permanent storage for the raw font data, if needed. string _font_data; string _name; diff --git a/panda/src/pnmtext/freetypeFont.I b/panda/src/pnmtext/freetypeFont.I index af6fdda503..897100998b 100644 --- a/panda/src/pnmtext/freetypeFont.I +++ b/panda/src/pnmtext/freetypeFont.I @@ -1,320 +1,249 @@ -// Filename: freetypeFont.I -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFont.I + * @author drose + * @date 2003-09-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FreetypeFont:: ~FreetypeFont() { unload_font(); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_point_size -// Access: Public -// Description: Sets the point size of the font. This controls the -// apparent size of the font onscreen. By convention, a -// 10 point font is about 1 screen unit high. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the point size of the font. This controls the apparent size of the + * font onscreen. By convention, a 10 point font is about 1 screen unit high. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool FreetypeFont:: set_point_size(PN_stdfloat point_size) { _point_size = point_size; return reset_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_point_size -// Access: Public -// Description: Returns the point size of the font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point size of the font. + */ INLINE PN_stdfloat FreetypeFont:: get_point_size() const { return _point_size; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_pixels_per_unit -// Access: Public -// Description: Set the resolution of the texture map, and hence the -// clarity of the resulting font. This sets the number -// of pixels in the texture map that are used for each -// onscreen unit. -// -// Setting this number larger results in an easier to -// read font, but at the cost of more texture memory. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Set the resolution of the texture map, and hence the clarity of the + * resulting font. This sets the number of pixels in the texture map that are + * used for each onscreen unit. + * + * Setting this number larger results in an easier to read font, but at the + * cost of more texture memory. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool FreetypeFont:: set_pixels_per_unit(PN_stdfloat pixels_per_unit) { _requested_pixels_per_unit = pixels_per_unit; return reset_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_pixels_per_unit -// Access: Public -// Description: Returns the resolution of the texture map. See -// set_pixels_per_unit(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the resolution of the texture map. See set_pixels_per_unit(). + */ INLINE PN_stdfloat FreetypeFont:: get_pixels_per_unit() const { return _tex_pixels_per_unit; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_pixel_size -// Access: Public -// Description: Computes the appropriate pixels_per_unit value to set -// the size of the font in the texture to the indicated -// number of pixels. This is just another way to -// specify pixels_per_unit(). -//////////////////////////////////////////////////////////////////// +/** + * Computes the appropriate pixels_per_unit value to set the size of the font + * in the texture to the indicated number of pixels. This is just another way + * to specify pixels_per_unit(). + */ INLINE bool FreetypeFont:: set_pixel_size(PN_stdfloat pixel_size) { return set_pixels_per_unit(pixel_size * _points_per_unit / _point_size); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_pixel_size -// Access: Public -// Description: Returns the size of the font in pixels, as it appears -// in the texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the font in pixels, as it appears in the texture. + */ INLINE PN_stdfloat FreetypeFont:: get_pixel_size() const { return _tex_pixels_per_unit * _point_size / _points_per_unit; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_scale_factor -// Access: Public -// Description: Sets the factor by which the font is rendered larger -// by the FreeType library before being filtered down to -// its actual size in the texture as specified by -// set_pixels_per_unit(). This may be set to a number -// larger than 1.0 to improve the font's antialiasing -// (since FreeType doesn't really do a swell job of -// antialiasing by itself). There is some performance -// implication for setting this different than 1.0. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the factor by which the font is rendered larger by the FreeType + * library before being filtered down to its actual size in the texture as + * specified by set_pixels_per_unit(). This may be set to a number larger + * than 1.0 to improve the font's antialiasing (since FreeType doesn't really + * do a swell job of antialiasing by itself). There is some performance + * implication for setting this different than 1.0. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool FreetypeFont:: set_scale_factor(PN_stdfloat scale_factor) { _requested_scale_factor = scale_factor; return reset_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_scale_factor -// Access: Public -// Description: Returns the antialiasing scale factor. See -// set_scale_factor(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the antialiasing scale factor. See set_scale_factor(). + */ INLINE PN_stdfloat FreetypeFont:: get_scale_factor() const { return _scale_factor; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_native_antialias -// Access: Public -// Description: Sets whether the Freetype library's built-in -// antialias mode is enabled. There are two unrelated -// ways to achieve antialiasing: with Freetype's native -// antialias mode, and with the use of a scale_factor -// greater than one. By default, both modes are -// enabled. -// -// At low resolutions, some fonts may do better with one -// mode or the other. In general, Freetype's native -// antialiasing will produce less blurry results, but -// may introduce more artifacts. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the Freetype library's built-in antialias mode is enabled. + * There are two unrelated ways to achieve antialiasing: with Freetype's + * native antialias mode, and with the use of a scale_factor greater than one. + * By default, both modes are enabled. + * + * At low resolutions, some fonts may do better with one mode or the other. + * In general, Freetype's native antialiasing will produce less blurry + * results, but may introduce more artifacts. + */ INLINE void FreetypeFont:: set_native_antialias(bool native_antialias) { _native_antialias = native_antialias; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_native_antialias -// Access: Public -// Description: Returns whether Freetype's built-in antialias mode is -// enabled. See set_native_antialias(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether Freetype's built-in antialias mode is enabled. See + * set_native_antialias(). + */ INLINE bool FreetypeFont:: get_native_antialias() const { return _native_antialias; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_font_pixel_size -// Access: Public -// Description: This is used to report whether the requested pixel -// size is being only approximated by a fixed-pixel-size -// font. This returns 0 in the normal case, in which a -// scalable font is used, or the fixed-pixel-size font -// has exactly the requested pixel size. -// -// If this returns non-zero, it is the pixel size of the -// font that we are using to approximate our desired -// size. -//////////////////////////////////////////////////////////////////// +/** + * This is used to report whether the requested pixel size is being only + * approximated by a fixed-pixel-size font. This returns 0 in the normal + * case, in which a scalable font is used, or the fixed-pixel-size font has + * exactly the requested pixel size. + * + * If this returns non-zero, it is the pixel size of the font that we are + * using to approximate our desired size. + */ INLINE int FreetypeFont:: get_font_pixel_size() const { return _pixel_height; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_line_height -// Access: Public -// Description: Returns the number of units high each line of text -// is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units high each line of text is. + */ INLINE PN_stdfloat FreetypeFont:: get_line_height() const { return _line_height; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_space_advance -// Access: Public -// Description: Returns the number of units wide a space is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units wide a space is. + */ INLINE PN_stdfloat FreetypeFont:: get_space_advance() const { return _space_advance; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_points_per_unit -// Access: Public, Static -// Description: Returns the point size of the font that is one Panda -// unit high. This is an arbitrary Panda convention for -// text, and is set to 10.0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point size of the font that is one Panda unit high. This is an + * arbitrary Panda convention for text, and is set to 10.0. + */ INLINE PN_stdfloat FreetypeFont:: get_points_per_unit() { return _points_per_unit; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_points_per_inch -// Access: Public, Static -// Description: Returns the number of points in one inch. This is a -// universal typographic convention. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of points in one inch. This is a universal typographic + * convention. + */ INLINE PN_stdfloat FreetypeFont:: get_points_per_inch() { return _points_per_inch; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::set_winding_order -// Access: Published -// Description: Specifies an explicitly winding order on this -// particular font. This is only necessary if the -// render_mode is RM_polygon or RM_solid, and only if -// FreeType appears to guess wrong on this font. -// Normally, you should leave this at WO_default. -//////////////////////////////////////////////////////////////////// +/** + * Specifies an explicitly winding order on this particular font. This is + * only necessary if the render_mode is RM_polygon or RM_solid, and only if + * FreeType appears to guess wrong on this font. Normally, you should leave + * this at WO_default. + */ INLINE void FreetypeFont:: set_winding_order(WindingOrder winding_order) { _winding_order = winding_order; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::get_winding_order -// Access: Published -// Description: Returns the winding order set via set_winding_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the winding order set via set_winding_order(). + */ INLINE FreetypeFont::WindingOrder FreetypeFont:: get_winding_order() const { return _winding_order; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::acquire_face -// Access: Protected -// Description: Retrieves the internal freetype face, and also -// acquires the lock. -// -// You must call release_face() when you are done using -// it, to release the lock. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the internal freetype face, and also acquires the lock. + * + * You must call release_face() when you are done using it, to release the + * lock. + */ INLINE FT_Face FreetypeFont:: acquire_face() const { nassertr(_face != NULL, NULL); return _face->acquire_face(_char_size, _dpi, _pixel_width, _pixel_height); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::release_face -// Access: Protected -// Description: Releases the lock acquired by a previous call to -// acquire_face(), and allows another thread to use the -// face. -//////////////////////////////////////////////////////////////////// +/** + * Releases the lock acquired by a previous call to acquire_face(), and allows + * another thread to use the face. + */ INLINE void FreetypeFont:: release_face(FT_Face face) const { nassertv(_face != NULL); _face->release_face(face); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::ContourPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FreetypeFont::ContourPoint:: ContourPoint(const LPoint2 &p, const LVector2 &in, const LVector2 &out) : _p(p), _in(in), _out(out), _radius(0) { } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::ContourPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FreetypeFont::ContourPoint:: ContourPoint(PN_stdfloat px, PN_stdfloat py, PN_stdfloat tx, PN_stdfloat ty) : _p(px, py), _in(tx, ty), _out(tx, ty), _radius(0) { } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::connect_to -// Access: Public -// Description: Connects the indicated point to the next point, whose -// tangent is given. The given tangent becomes the out -// tangent at this point. If the in tangent and out -// tangent are sufficiently close, they will be smoothed -// together. -//////////////////////////////////////////////////////////////////// +/** + * Connects the indicated point to the next point, whose tangent is given. + * The given tangent becomes the out tangent at this point. If the in tangent + * and out tangent are sufficiently close, they will be smoothed together. + */ INLINE void FreetypeFont::ContourPoint:: connect_to(const LVector2 &out) { _out = out; diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index 6f89f5528a..d66bcee868 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -1,16 +1,15 @@ -// Filename: freetypeFont.cxx -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFont.cxx + * @author drose + * @date 2003-09-07 + */ #include "freetypeFont.h" @@ -26,19 +25,16 @@ #undef interface // I don't know where this symbol is defined, but it interferes with FreeType. #include FT_OUTLINE_H -// This constant determines how big a particular point size font -// appears to be. By convention, 10 points is 1 unit (e.g. 1 foot) -// high. +// This constant determines how big a particular point size font appears to +// be. By convention, 10 points is 1 unit (e.g. 1 foot) high. const PN_stdfloat FreetypeFont::_points_per_unit = 10.0f; // A universal typographic convention. const PN_stdfloat FreetypeFont::_points_per_inch = 72.0f; -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FreetypeFont:: FreetypeFont() { _face = NULL; @@ -60,11 +56,9 @@ FreetypeFont() { _pixel_height = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FreetypeFont:: FreetypeFont(const FreetypeFont ©) : Namable(copy), @@ -86,14 +80,11 @@ FreetypeFont(const FreetypeFont ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::load_font -// Access: Protected -// Description: This method accepts the name of some font file -// that FreeType can read, along with face_index, -// indicating which font within the file to load -// (usually 0). -//////////////////////////////////////////////////////////////////// +/** + * This method accepts the name of some font file that FreeType can read, + * along with face_index, indicating which font within the file to load + * (usually 0). + */ bool FreetypeFont:: load_font(const Filename &font_filename, int face_index) { unload_font(); @@ -114,7 +105,7 @@ load_font(const Filename &font_filename, int face_index) { exists = vfs->read_file(path, _face->_font_data, true); if (exists) { FT_Face face; - error = FT_New_Memory_Face(_face->_ft_library, + error = FT_New_Memory_Face(_face->_ft_library, (const FT_Byte *)_face->_font_data.data(), _face->_font_data.length(), face_index, &face); @@ -141,17 +132,14 @@ load_font(const Filename &font_filename, int face_index) { if (!okflag) { unload_font(); } - + return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::load_font -// Access: Protected -// Description: This method accepts a table of data representing -// the font file, loaded from some source other than a -// filename on disk. -//////////////////////////////////////////////////////////////////// +/** + * This method accepts a table of data representing the font file, loaded from + * some source other than a filename on disk. + */ bool FreetypeFont:: load_font(const char *font_data, int data_length, int face_index) { unload_font(); @@ -166,7 +154,7 @@ load_font(const char *font_data, int data_length, int face_index) { int error; FT_Face face; - error = FT_New_Memory_Face(_face->_ft_library, + error = FT_New_Memory_Face(_face->_ft_library, (const FT_Byte *)font_data, data_length, face_index, &face); _face->set_face(face); @@ -178,7 +166,7 @@ load_font(const char *font_data, int data_length, int face_index) { } else if (error) { pnmtext_cat.error() << "Unable to read font: invalid.\n"; - + } else { okflag = reset_scale(); } @@ -186,27 +174,23 @@ load_font(const char *font_data, int data_length, int face_index) { if (!okflag) { unload_font(); } - + return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::unload_font -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FreetypeFont:: unload_font() { _face = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::string_winding_order -// Access: Public -// Description: Returns the WindingOrder value associated with the given -// string representation, or WO_invalid if the string -// does not match any known WindingOrder value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the WindingOrder value associated with the given string + * representation, or WO_invalid if the string does not match any known + * WindingOrder value. + */ FreetypeFont::WindingOrder FreetypeFont:: string_winding_order(const string &string) { if (cmp_nocase_uh(string, "default") == 0) { @@ -220,23 +204,20 @@ string_winding_order(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::load_glyph -// Access: Protected -// Description: Invokes Freetype to load and render the indicated -// glyph into a bitmap. Returns true if successful, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Invokes Freetype to load and render the indicated glyph into a bitmap. + * Returns true if successful, false otherwise. + */ bool FreetypeFont:: load_glyph(FT_Face face, int glyph_index, bool prerender) { int flags = FT_LOAD_RENDER; - if (!_native_antialias) { + if (!_native_antialias) { flags |= FT_LOAD_MONOCHROME; } if (!prerender) { - // If we want to render as an outline font, don't pre-render it to - // a bitmap. + // If we want to render as an outline font, don't pre-render it to a + // bitmap. flags = 0; } @@ -249,18 +230,16 @@ load_glyph(FT_Face face, int glyph_index, bool prerender) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::copy_bitmap_to_pnmimage -// Access: Protected -// Description: Copies a bitmap as rendered by FreeType into a -// PNMImage, so it can be rescaled. -//////////////////////////////////////////////////////////////////// +/** + * Copies a bitmap as rendered by FreeType into a PNMImage, so it can be + * rescaled. + */ void FreetypeFont:: copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { - if (bitmap.pixel_mode == ft_pixel_mode_grays && + if (bitmap.pixel_mode == ft_pixel_mode_grays && bitmap.num_grays == (int)image.get_maxval() + 1) { - // This is the easy case: we can copy the rendered glyph - // directly into our image, one pixel at a time. + // This is the easy case: we can copy the rendered glyph directly into our + // image, one pixel at a time. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { for (int xi = 0; xi < bitmap.width; xi++) { @@ -268,10 +247,10 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { } buffer_row += bitmap.pitch; } - + } else if (bitmap.pixel_mode == ft_pixel_mode_mono) { - // This is a little bit more work: we have to expand the - // one-bit-per-pixel bitmap into a one-byte-per-pixel image. + // This is a little bit more work: we have to expand the one-bit-per-pixel + // bitmap into a one-byte-per-pixel image. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { xelval maxval = image.get_maxval(); @@ -289,14 +268,14 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { bit = 0x80; } } - + buffer_row += bitmap.pitch; } - - + + } else if (bitmap.pixel_mode == ft_pixel_mode_grays) { - // Here we must expand a grayscale pixmap with n levels of gray - // into our 256-level texture. + // Here we must expand a grayscale pixmap with n levels of gray into our + // 256-level texture. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { for (int xi = 0; xi < bitmap.width; xi++) { @@ -304,32 +283,30 @@ copy_bitmap_to_pnmimage(const FT_Bitmap &bitmap, PNMImage &image) { } buffer_row += bitmap.pitch; } - + } else { pnmtext_cat.error() << "Unexpected pixel mode in bitmap: " << (int)bitmap.pixel_mode << "\n"; } } - -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::reset_scale -// Access: Private -// Description: Resets the font based on the current values for -// _point_size, _tex_pixels_per_unit, and _scale_factor. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// + +/** + * Resets the font based on the current values for _point_size, + * _tex_pixels_per_unit, and _scale_factor. Returns true if successful, false + * otherwise. + */ bool FreetypeFont:: reset_scale() { if (_face == NULL) { return false; } - // Get the face, without requesting a particular size yet (we'll - // figure out the size in a second). + // Get the face, without requesting a particular size yet (we'll figure out + // the size in a second). FT_Face face = _face->acquire_face(0, 0, 0, 0); - // The font may be rendered larger (by a factor of _scale_factor), - // and then reduced into the texture. Hence the difference between + // The font may be rendered larger (by a factor of _scale_factor), and then + // reduced into the texture. Hence the difference between // _font_pixels_per_unit and _tex_pixels_per_unit. _tex_pixels_per_unit = _requested_pixels_per_unit; _scale_factor = _requested_scale_factor; @@ -340,13 +317,12 @@ reset_scale() { PN_stdfloat units_per_inch = (_points_per_inch / _points_per_unit); _dpi = (int)(_font_pixels_per_unit * units_per_inch); _char_size = (int)(_point_size * 64); - + int error = FT_Set_Char_Size(face, _char_size, _char_size, _dpi, _dpi); if (error) { - // If we were unable to set a particular char size, perhaps we - // have a non-scalable font. Try to figure out the next larger - // available size, or the largest size available if nothing is - // larger. + // If we were unable to set a particular char size, perhaps we have a non- + // scalable font. Try to figure out the next larger available size, or + // the largest size available if nothing is larger. int desired_height = (int)(_font_pixels_per_unit * _point_size / _points_per_unit + 0.5f); int best_size = -1; int largest_size = -1; @@ -387,7 +363,7 @@ reset_scale() { if (error) { pnmtext_cat.warning() - << "Unable to set " << get_name() + << "Unable to set " << get_name() << " to " << _point_size << "pt at " << _dpi << " dpi.\n"; _line_height = 1.0f; _face->release_face(face); @@ -410,12 +386,9 @@ reset_scale() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::render_distance_field -// Access: Private -// Description: Renders a signed distance field to the PNMImage -// based on the contours. -//////////////////////////////////////////////////////////////////// +/** + * Renders a signed distance field to the PNMImage based on the contours. + */ void FreetypeFont:: render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { Contours::const_iterator ci; @@ -439,8 +412,8 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { for (ci = _contours.begin(); ci != _contours.end(); ++ci) { // Find the shortest distance between this point and the contour. - // Also keep track of the winding number, so we will know whether - // this point is inside or outside the polygon. + // Also keep track of the winding number, so we will know whether this + // point is inside or outside the polygon. const Contour &contour = (*ci); for (size_t i = 1; i < contour._points.size(); ++i) { @@ -470,8 +443,9 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { bool inside = dist_sq < 0; dist_sq *= dist_sq; - //if (v1[0] * vp[1] - vp[0] * v1[1] < 0 && v2[0] * vp[1] - vp[0] * v2[1] < 0) { - //if (v1.signed_angle_deg(vp) < v1.signed_angle_deg(v2) && v1.signed_angle_deg(vp) > 0) { + // if (v1[0] * vp[1] - vp[0] * v1[1] < 0 && v2[0] * vp[1] - + // vp[0] * v2[1] < 0) { if (v1.signed_angle_deg(vp) < + // v1.signed_angle_deg(v2) && v1.signed_angle_deg(vp) > 0) { if (begin[1] <= p[1]) { if (end[1] > p[1]) { if (inside != (v[0] * v1[1] > v[1] * v1[0])) { @@ -541,12 +515,9 @@ render_distance_field(PNMImage &image, int outline, int min_x, int min_y) { } } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::decompose_outline -// Access: Protected -// Description: Ask FreeType to extract the contours out of the -// outline description. -//////////////////////////////////////////////////////////////////// +/** + * Ask FreeType to extract the contours out of the outline description. + */ void FreetypeFont:: decompose_outline(FT_Outline &outline) { FT_Outline_Funcs funcs; @@ -558,8 +529,8 @@ decompose_outline(FT_Outline &outline) { WindingOrder wo = _winding_order; if (wo == WO_default) { - // If we weren't told an explicit winding order, ask FreeType to - // figure it out. Sometimes it appears to guess wrong. + // If we weren't told an explicit winding order, ask FreeType to figure it + // out. Sometimes it appears to guess wrong. #ifdef FT_ORIENTATION_FILL_RIGHT if (FT_Outline_Get_Orientation(&outline) == FT_ORIENTATION_FILL_RIGHT) { wo = WO_right; @@ -567,8 +538,8 @@ decompose_outline(FT_Outline &outline) { wo = WO_left; } #else - // Hmm. Assign a right-winding (TTF) orientation if FreeType - // can't tell us. + // Hmm. Assign a right-winding (TTF) orientation if FreeType can't tell + // us. wo = WO_right; #endif // FT_ORIENTATION_FILL_RIGHT } @@ -581,12 +552,10 @@ decompose_outline(FT_Outline &outline) { FT_Outline_Decompose(&outline, &funcs, (void *)this); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::outline_move_to -// Access: Private, Static -// Description: A callback from FT_Outline_Decompose(). It marks the -// beginning of a new contour. -//////////////////////////////////////////////////////////////////// +/** + * A callback from FT_Outline_Decompose(). It marks the beginning of a new + * contour. + */ int FreetypeFont:: outline_move_to(const FT_Vector *to, void *user) { FreetypeFont *self = (FreetypeFont *)user; @@ -603,12 +572,10 @@ outline_move_to(const FT_Vector *to, void *user) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::outline_line_to -// Access: Private, Static -// Description: A callback from FT_Outline_Decompose(). It marks a -// straight line in the contour. -//////////////////////////////////////////////////////////////////// +/** + * A callback from FT_Outline_Decompose(). It marks a straight line in the + * contour. + */ int FreetypeFont:: outline_line_to(const FT_Vector *to, void *user) { FreetypeFont *self = (FreetypeFont *)user; @@ -633,12 +600,10 @@ outline_line_to(const FT_Vector *to, void *user) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::outline_conic_to -// Access: Private, Static -// Description: A callback from FT_Outline_Decompose(). It marks a -// parabolic (3rd-order) Bezier curve in the contour. -//////////////////////////////////////////////////////////////////// +/** + * A callback from FT_Outline_Decompose(). It marks a parabolic (3rd-order) + * Bezier curve in the contour. + */ int FreetypeFont:: outline_conic_to(const FT_Vector *control, const FT_Vector *to, void *user) { @@ -666,12 +631,10 @@ outline_conic_to(const FT_Vector *control, return self->outline_nurbs(ncr); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::outline_cubic_to -// Access: Private, Static -// Description: A callback from FT_Outline_Decompose(). It marks a -// cubic (4th-order) Bezier curve in the contour. -//////////////////////////////////////////////////////////////////// +/** + * A callback from FT_Outline_Decompose(). It marks a cubic (4th-order) + * Bezier curve in the contour. + */ int FreetypeFont:: outline_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *user) { @@ -701,16 +664,13 @@ outline_cubic_to(const FT_Vector *control1, const FT_Vector *control2, return self->outline_nurbs(ncr); } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::outline_nurbs -// Access: Private -// Description: Called internally by outline_cubic_to() and -// outline_conic_to(). -//////////////////////////////////////////////////////////////////// +/** + * Called internally by outline_cubic_to() and outline_conic_to(). + */ int FreetypeFont:: outline_nurbs(NurbsCurveResult *ncr) { - // Sample it down so that the lines approximate the curve to within - // a "pixel." + // Sample it down so that the lines approximate the curve to within a + // "pixel." ncr->adaptive_sample(1.0f / _font_pixels_per_unit); int num_samples = ncr->get_num_samples(); @@ -718,8 +678,8 @@ outline_nurbs(NurbsCurveResult *ncr) { bool needs_connect = false; int start = 1; if (_contours.back()._points.empty()) { - // If we haven't got the first point of this contour yet, we must - // add it now. + // If we haven't got the first point of this contour yet, we must add it + // now. start = 0; } else { needs_connect = true; @@ -737,9 +697,8 @@ outline_nurbs(NurbsCurveResult *ncr) { if (i < num_samples - 1) { st1 = ncr->get_sample_t(i + 1) * 0.1f + st * 0.9f; } - // Compute the tangent by deltaing nearby points. Don't evaluate - // the tangent from the NURBS, since that doesn't appear to be - // reliable. + // Compute the tangent by deltaing nearby points. Don't evaluate the + // tangent from the NURBS, since that doesn't appear to be reliable. LPoint3 p0, p1; ncr->eval_point(st0, p0); ncr->eval_point(st1, p1); @@ -779,10 +738,9 @@ outline_nurbs(NurbsCurveResult *ncr) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::WindingOrder output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, FreetypeFont::WindingOrder wo) { switch (wo) { @@ -800,10 +758,9 @@ operator << (ostream &out, FreetypeFont::WindingOrder wo) { return out << "(**invalid FreetypeFont::WindingOrder(" << (int)wo << ")**)"; } -//////////////////////////////////////////////////////////////////// -// Function: FreetypeFont::WindingOrder input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, FreetypeFont::WindingOrder &wo) { string word; diff --git a/panda/src/pnmtext/freetypeFont.h b/panda/src/pnmtext/freetypeFont.h index 5501aa8008..a33059f3d7 100644 --- a/panda/src/pnmtext/freetypeFont.h +++ b/panda/src/pnmtext/freetypeFont.h @@ -1,16 +1,15 @@ -// Filename: freetypeFont.h -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file freetypeFont.h + * @author drose + * @date 2003-09-07 + */ #ifndef FREETYPEFONT_H #define FREETYPEFONT_H @@ -32,14 +31,12 @@ class NurbsCurveResult; -//////////////////////////////////////////////////////////////////// -// Class : FreetypeFont -// Description : This is a common base class for both DynamicTextFont -// and PNMTextMaker. Both of these are utility classes -// that use the FreeType library to generate glyphs from -// fonts; this class abstracts out that common wrapper -// around FreeType. -//////////////////////////////////////////////////////////////////// +/** + * This is a common base class for both DynamicTextFont and PNMTextMaker. + * Both of these are utility classes that use the FreeType library to generate + * glyphs from fonts; this class abstracts out that common wrapper around + * FreeType. + */ class EXPCL_PANDA_PNMTEXT FreetypeFont : public Namable { protected: FreetypeFont(); @@ -141,8 +138,8 @@ protected: LPoint2 _p; LVector2 _in, _out; // tangents into and out of the vertex. - // Circular arc approximation of the curve from previous point. - // If radius is 0, this is a straight line. + // Circular arc approximation of the curve from previous point. If radius + // is 0, this is a straight line. LPoint2 _center; PN_stdfloat _radius; }; diff --git a/panda/src/pnmtext/pnmTextGlyph.I b/panda/src/pnmtext/pnmTextGlyph.I index 2bd4024b32..13be381ef6 100644 --- a/panda/src/pnmtext/pnmTextGlyph.I +++ b/panda/src/pnmtext/pnmTextGlyph.I @@ -1,118 +1,90 @@ -// Filename: pnmTextGlyph.I -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextGlyph.I + * @author drose + * @date 2003-09-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_advance -// Access: Public -// Description: Returns the number of pixels by which the pen should -// be advanced after rendering this glyph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels by which the pen should be advanced after + * rendering this glyph. + */ INLINE int PNMTextGlyph:: get_advance() const { return _int_advance; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_left -// Access: Public -// Description: Returns the x coordinate of the leftmost pixel in the -// glyph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x coordinate of the leftmost pixel in the glyph. + */ INLINE int PNMTextGlyph:: get_left() const { return _left; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_right -// Access: Public -// Description: Returns the x coordinate of the rightmost pixel in the -// glyph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x coordinate of the rightmost pixel in the glyph. + */ INLINE int PNMTextGlyph:: get_right() const { return _left + _image.get_x_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_bottom -// Access: Public -// Description: Returns the y coordinate of the bottommost pixel in -// the glyph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y coordinate of the bottommost pixel in the glyph. + */ INLINE int PNMTextGlyph:: get_bottom() const { return _top + _image.get_y_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_top -// Access: Public -// Description: Returns the y coordinate of the topmost pixel in the -// glyph. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y coordinate of the topmost pixel in the glyph. + */ INLINE int PNMTextGlyph:: get_top() const { return _top; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_height -// Access: Public -// Description: Returns the height of the glyph in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the glyph in pixels. + */ INLINE int PNMTextGlyph:: get_height() const { return _image.get_y_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_width -// Access: Public -// Description: Returns the width of the glyph in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the glyph in pixels. + */ INLINE int PNMTextGlyph:: get_width() const { return _image.get_x_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_value -// Access: Public -// Description: Returns the value of the indicated pixel of the -// glyph. The result is in the range [0, 1], where 0 -// indicates the pixel is not part of the glyph, and 1 -// indicates it is. Intermediate values are used to -// represent antialiasing. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value of the indicated pixel of the glyph. The result is in + * the range [0, 1], where 0 indicates the pixel is not part of the glyph, and + * 1 indicates it is. Intermediate values are used to represent antialiasing. + */ INLINE double PNMTextGlyph:: get_value(int x, int y) const { nassertr(x >= 0 && x < get_width() && y >= 0 && y < get_height(), 0.0); - // By convention, the "value" attribute is stored in the blue - // component. + // By convention, the "value" attribute is stored in the blue component. return _image.get_blue(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::get_interior_flag -// Access: Public -// Description: Returns true if the indicated pixel represents a -// pixel in the interior of a hollow font, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated pixel represents a pixel in the interior of a + * hollow font, false otherwise. + */ INLINE bool PNMTextGlyph:: get_interior_flag(int x, int y) const { nassertr(x >= 0 && x < get_width() && diff --git a/panda/src/pnmtext/pnmTextGlyph.cxx b/panda/src/pnmtext/pnmTextGlyph.cxx index 8c4c278dc6..833febd98c 100644 --- a/panda/src/pnmtext/pnmTextGlyph.cxx +++ b/panda/src/pnmtext/pnmTextGlyph.cxx @@ -1,53 +1,44 @@ -// Filename: pnmTextGlyph.cxx -// Created by: drose (03Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextGlyph.cxx + * @author drose + * @date 2002-04-03 + */ #include "pnmTextGlyph.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMTextGlyph:: -PNMTextGlyph(double advance) : - _advance(advance) +PNMTextGlyph(double advance) : + _advance(advance) { _left = 0; _top = 0; _int_advance = (int)floor(_advance + 0.5); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMTextGlyph:: ~PNMTextGlyph() { } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::place -// Access: Public -// Description: Copies the glyph to the indicated destination image -// at the indicated origin. It colors the glyph pixels -// the indicated foreground color, blends antialiased -// pixels with the appropriate amount of the foreground -// color and the existing background color, and leaves -// other pixels alone. -//////////////////////////////////////////////////////////////////// +/** + * Copies the glyph to the indicated destination image at the indicated + * origin. It colors the glyph pixels the indicated foreground color, blends + * antialiased pixels with the appropriate amount of the foreground color and + * the existing background color, and leaves other pixels alone. + */ void PNMTextGlyph:: place(PNMImage &dest_image, int xp, int yp, const LColor &fg) { if (!_image.is_valid()) { @@ -82,13 +73,10 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::place -// Access: Public -// Description: This flavor of place() also fills in the interior -// color. This requires that determine_interior was -// called earlier. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of place() also fills in the interior color. This requires + * that determine_interior was called earlier. + */ void PNMTextGlyph:: place(PNMImage &dest_image, int xp, int yp, const LColor &fg, const LColor &interior) { @@ -137,19 +125,16 @@ place(PNMImage &dest_image, int xp, int yp, const LColor &fg, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::determine_interior -// Access: Private -// Description: Once the glyph has been generated, but before it has -// been scaled down by _scale_factor, walk through the -// glyph and try to determine which parts represent the -// interior portions of a hollow font, and mark them so -// they may be properly colored. -//////////////////////////////////////////////////////////////////// +/** + * Once the glyph has been generated, but before it has been scaled down by + * _scale_factor, walk through the glyph and try to determine which parts + * represent the interior portions of a hollow font, and mark them so they may + * be properly colored. + */ void PNMTextGlyph:: determine_interior() { - // We will use the red component as a working buffer. First, we - // fill the whole thing to maxval. + // We will use the red component as a working buffer. First, we fill the + // whole thing to maxval. int x_size = _image.get_x_size(); int y_size = _image.get_y_size(); xelval maxval = _image.get_maxval(); @@ -159,11 +144,10 @@ determine_interior() { } } - // Now we recursively analyze the image to determine the number of - // walls between each pixel and any edge. All outer edge pixels - // have a value of 0; all dark pixels adjacent to those pixels have - // a value of 1, and light pixels adjacent to those have a value of - // 2, and so on. + // Now we recursively analyze the image to determine the number of walls + // between each pixel and any edge. All outer edge pixels have a value of + // 0; all dark pixels adjacent to those pixels have a value of 1, and light + // pixels adjacent to those have a value of 2, and so on. _scan_interior_points.clear(); for (int yi = 0; yi < y_size; yi++) { scan_interior(0, yi, 0, false, 0); @@ -174,8 +158,8 @@ determine_interior() { scan_interior(xi, y_size - 1, 0, false, 0); } - // Pick up any points that we couldn't visit recursively because of - // the lame stack limit on Windows. + // Pick up any points that we couldn't visit recursively because of the lame + // stack limit on Windows. while (!_scan_interior_points.empty()) { int index = _scan_interior_points.back(); _scan_interior_points.pop_back(); @@ -191,9 +175,9 @@ determine_interior() { } _scan_interior_points.clear(); - // Finally, go back and set any pixel whose red value is two more - // than a multiple of 4 to dark. This indicates the interior part - // of a hollow font. + // Finally, go back and set any pixel whose red value is two more than a + // multiple of 4 to dark. This indicates the interior part of a hollow + // font. for (int yi = 0; yi < y_size; yi++) { for (int xi = 0; xi < x_size; xi++) { xelval code = _image.get_red_val(xi, yi); @@ -206,16 +190,13 @@ determine_interior() { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::scan_interior -// Access: Private -// Description: Recursively scans the image for interior pixels. On -// completion, the image's red channel will be filled -// with 0, 1, 2, etc., representing the number of edges -// between each pixel and the border. -//////////////////////////////////////////////////////////////////// +/** + * Recursively scans the image for interior pixels. On completion, the + * image's red channel will be filled with 0, 1, 2, etc., representing the + * number of edges between each pixel and the border. + */ void PNMTextGlyph:: -scan_interior(int x, int y, xelval new_code, bool neighbor_dark, +scan_interior(int x, int y, xelval new_code, bool neighbor_dark, int recurse_level) { if (x < 0 || y < 0 || x >= _image.get_x_size() || y >= _image.get_y_size()) { return; @@ -233,10 +214,9 @@ scan_interior(int x, int y, xelval new_code, bool neighbor_dark, _image.set_red_val(x, y, new_code); recurse_level++; if (recurse_level > 1024) { - // To cobble around a lame Windows limitation on the length of - // the stack, we must prevent the recursion from going too deep. - // But we still need to remember this pixel so we can come back - // to it later. + // To cobble around a lame Windows limitation on the length of the + // stack, we must prevent the recursion from going too deep. But we + // still need to remember this pixel so we can come back to it later. int index = y * _image.get_x_size() + x; _scan_interior_points.push_back(index); @@ -249,12 +229,10 @@ scan_interior(int x, int y, xelval new_code, bool neighbor_dark, } } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextGlyph::rescale -// Access: Private -// Description: After the image has been rendered large by FreeType, -// scales it small again for placing. -//////////////////////////////////////////////////////////////////// +/** + * After the image has been rendered large by FreeType, scales it small again + * for placing. + */ void PNMTextGlyph:: rescale(double scale_factor) { if (scale_factor == 1.0) { @@ -270,8 +248,8 @@ rescale(double scale_factor) { int orig_left = _left; int orig_top = _top; - // Pad the image by a few pixels all around to allow for - // antialiasing at the edges. + // Pad the image by a few pixels all around to allow for antialiasing at + // the edges. int extra_pad = (int)ceil(scale_factor); orig_x_size += 2*extra_pad; orig_y_size += 2*extra_pad; @@ -284,9 +262,9 @@ rescale(double scale_factor) { int new_left = (int)floor(orig_left / scale_factor); int new_top = (int)ceil(orig_top / scale_factor); - // And scale those back up so we can determine the amount of - // additional padding we need to make the pixels remain in the - // right place after the integer reduction. + // And scale those back up so we can determine the amount of additional + // padding we need to make the pixels remain in the right place after the + // integer reduction. int old_x_size = (int)(new_x_size * scale_factor + 0.5); int old_y_size = (int)(new_y_size * scale_factor + 0.5); int old_left = (int)(new_left * scale_factor + 0.5); diff --git a/panda/src/pnmtext/pnmTextGlyph.h b/panda/src/pnmtext/pnmTextGlyph.h index d2cb7c559b..8042fddc2a 100644 --- a/panda/src/pnmtext/pnmTextGlyph.h +++ b/panda/src/pnmtext/pnmTextGlyph.h @@ -1,16 +1,15 @@ -// Filename: pnmTextGlyph.h -// Created by: drose (03Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextGlyph.h + * @author drose + * @date 2002-04-03 + */ #ifndef PNMTEXTGLYPH_H #define PNMTEXTGLYPH_H @@ -20,10 +19,9 @@ #include "pnmImage.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : PNMTextGlyph -// Description : A single glyph in a PNMTextMaker. -//////////////////////////////////////////////////////////////////// +/** + * A single glyph in a PNMTextMaker. + */ class EXPCL_PANDA_PNMTEXT PNMTextGlyph { PUBLISHED: PNMTextGlyph(double advance); @@ -31,9 +29,9 @@ PUBLISHED: INLINE int get_advance() const; - void place(PNMImage &dest_image, int xp, int yp, + void place(PNMImage &dest_image, int xp, int yp, const LColor &fg); - void place(PNMImage &dest_image, int xp, int yp, + void place(PNMImage &dest_image, int xp, int yp, const LColor &fg, const LColor &interior); INLINE int get_left() const; diff --git a/panda/src/pnmtext/pnmTextMaker.I b/panda/src/pnmtext/pnmTextMaker.I index f74f04ab1e..c8cce09b52 100644 --- a/panda/src/pnmtext/pnmTextMaker.I +++ b/panda/src/pnmtext/pnmTextMaker.I @@ -1,63 +1,50 @@ -// Filename: pnmTextMaker.I -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextMaker.I + * @author drose + * @date 2003-09-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::is_valid -// Access: Public -// Description: Returns true if the PNMTextMaker is valid and ready to -// generate text, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PNMTextMaker is valid and ready to generate text, false + * otherwise. + */ INLINE bool PNMTextMaker:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::set_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PNMTextMaker:: set_align(PNMTextMaker::Alignment align_type) { _align = align_type; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PNMTextMaker::Alignment PNMTextMaker:: get_align() const { return _align; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::set_interior_flag -// Access: Published -// Description: Sets the flag that indicates whether the interior of -// hollow fonts is identified as a preprocess as each -// glyph is loaded. If this flag is true, you may -// specify an interior color along with a fg and bg -// color when you place text; if the flag is false, the -// interior color is ignored. -// -// It is generally best to set_native_antialias(0) when -// using this feature. Also, this works best when the -// pixel size is not very small. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the interior of hollow fonts is + * identified as a preprocess as each glyph is loaded. If this flag is true, + * you may specify an interior color along with a fg and bg color when you + * place text; if the flag is false, the interior color is ignored. + * + * It is generally best to set_native_antialias(0) when using this feature. + * Also, this works best when the pixel size is not very small. + */ INLINE void PNMTextMaker:: set_interior_flag(bool interior_flag) { if (_interior_flag != interior_flag) { @@ -66,94 +53,74 @@ set_interior_flag(bool interior_flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_interior_flag -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool PNMTextMaker:: get_interior_flag() const { return _interior_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::set_fg -// Access: Published -// Description: Sets the foreground color of text that will be -// generated by future calls to generate_into(). This -// is the color that all of the "on" pixels in the font -// will show as. -//////////////////////////////////////////////////////////////////// +/** + * Sets the foreground color of text that will be generated by future calls to + * generate_into(). This is the color that all of the "on" pixels in the font + * will show as. + */ INLINE void PNMTextMaker:: set_fg(const LColor &fg) { _fg = fg; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_fg -// Access: Published -// Description: Returns the foreground color of text that will be -// generated by future calls to generate_into(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the foreground color of text that will be generated by future calls + * to generate_into(). + */ INLINE const LColor &PNMTextMaker:: get_fg() const { return _fg; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::set_interior -// Access: Published -// Description: Sets the color that will be used to render the -// interior portions of hollow fonts in future calls to -// generate_into(). This is respected only if -// interior_flag is true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color that will be used to render the interior portions of hollow + * fonts in future calls to generate_into(). This is respected only if + * interior_flag is true. + */ INLINE void PNMTextMaker:: set_interior(const LColor &interior) { _interior = interior; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_interior -// Access: Published -// Description: Returns the color that will be used to render the -// interior portions of hollow fonts. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color that will be used to render the interior portions of + * hollow fonts. + */ INLINE const LColor &PNMTextMaker:: get_interior() const { return _interior; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::set_distance_field_radius -// Access: Published -// Description: If this is set to something other than 0, Panda -// will generate a signed distance field with the -// given radius. -//////////////////////////////////////////////////////////////////// +/** + * If this is set to something other than 0, Panda will generate a signed + * distance field with the given radius. + */ INLINE void PNMTextMaker:: set_distance_field_radius(int distance_field_radius) { _distance_field_radius = distance_field_radius; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_distance_field_radius -// Access: Published -// Description: Returns the radius previously set with -// set_distance_field_radius, or 0 otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the radius previously set with set_distance_field_radius, or 0 + * otherwise. + */ INLINE int PNMTextMaker:: get_distance_field_radius() const { return _distance_field_radius; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::generate_into -// Access: Public -// Description: Generates a single line of text into the indicated -// image at the indicated position; the return value is -// the total width in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Generates a single line of text into the indicated image at the indicated + * position; the return value is the total width in pixels. + */ INLINE int PNMTextMaker:: generate_into(const string &text, PNMImage &dest_image, int x, int y) { TextEncoder encoder; @@ -161,12 +128,9 @@ generate_into(const string &text, PNMImage &dest_image, int x, int y) { return generate_into(encoder.get_wtext(), dest_image, x, y); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::calc_width -// Access: Public -// Description: Returns the width in pixels of the indicated line of -// text. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width in pixels of the indicated line of text. + */ INLINE int PNMTextMaker:: calc_width(const string &text) { TextEncoder encoder; diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index e74737a038..ad435ffa00 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -1,53 +1,45 @@ -// Filename: pnmTextMaker.cxx -// Created by: drose (03Apr02) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextMaker.cxx + * @author drose + * @date 2002-04-03 + */ #include "pnmTextMaker.h" #include "pnmTextGlyph.h" #include "filename.h" #include "pnmImage.h" -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::Constructor -// Access: Public -// Description: The constructor expects the name of some font file -// that FreeType can read, along with face_index, -// indicating which font within the file to load -// (usually 0). -//////////////////////////////////////////////////////////////////// +/** + * The constructor expects the name of some font file that FreeType can read, + * along with face_index, indicating which font within the file to load + * (usually 0). + */ PNMTextMaker:: PNMTextMaker(const Filename &font_filename, int face_index) { initialize(); _is_valid = load_font(font_filename, face_index); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::Constructor -// Access: Public -// Description: This constructor works as above, but it takes the -// font data from an in-memory buffer instead of from a -// named file. -//////////////////////////////////////////////////////////////////// +/** + * This constructor works as above, but it takes the font data from an in- + * memory buffer instead of from a named file. + */ PNMTextMaker:: PNMTextMaker(const char *font_data, int data_length, int face_index) { initialize(); _is_valid = load_font(font_data, data_length, face_index); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMTextMaker:: PNMTextMaker(const PNMTextMaker ©) : FreetypeFont(copy), @@ -60,11 +52,9 @@ PNMTextMaker(const PNMTextMaker ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMTextMaker:: PNMTextMaker(const FreetypeFont ©) : FreetypeFont(copy), @@ -73,23 +63,18 @@ PNMTextMaker(const FreetypeFont ©) : initialize(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PNMTextMaker:: ~PNMTextMaker() { empty_cache(); } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::generate_into -// Access: Public -// Description: Generates a single line of text into the indicated -// image at the indicated position; the return value is -// the total width in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Generates a single line of text into the indicated image at the indicated + * position; the return value is the total width in pixels. + */ int PNMTextMaker:: generate_into(const wstring &text, PNMImage &dest_image, int x, int y) { // First, measure the total width in pixels. @@ -128,12 +113,9 @@ generate_into(const wstring &text, PNMImage &dest_image, int x, int y) { return width; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::calc_width -// Access: Public -// Description: Returns the width in pixels of the indicated line of -// text. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width in pixels of the indicated line of text. + */ int PNMTextMaker:: calc_width(const wstring &text) { int width = 0; @@ -146,12 +128,10 @@ calc_width(const wstring &text) { return width; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::get_glyph -// Access: Public -// Description: Returns the glyph for the indicated index, or NULL if -// it is not defined in the font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the glyph for the indicated index, or NULL if it is not defined in + * the font. + */ PNMTextGlyph *PNMTextMaker:: get_glyph(int character) { FT_Face face = acquire_face(); @@ -169,12 +149,9 @@ get_glyph(int character) { return glyph; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::initialize -// Access: Private -// Description: Called from both constructors to set up some initial -// values. -//////////////////////////////////////////////////////////////////// +/** + * Called from both constructors to set up some initial values. + */ void PNMTextMaker:: initialize() { _align = A_left; @@ -184,12 +161,9 @@ initialize() { _distance_field_radius = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::make_glyph -// Access: Private -// Description: Creates a new PNMTextGlyph object for the indicated -// index, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new PNMTextGlyph object for the indicated index, if possible. + */ PNMTextGlyph *PNMTextMaker:: make_glyph(int glyph_index) { FT_Face face = acquire_face(); @@ -214,8 +188,7 @@ make_glyph(int glyph_index) { PNMImage &glyph_image = glyph->_image; if (_distance_field_radius != 0) { - // Ask FreeType to extract the contours out of the outline - // description. + // Ask FreeType to extract the contours out of the outline description. decompose_outline(slot->outline); PN_stdfloat tex_x_size, tex_y_size, tex_x_orig, tex_y_orig; @@ -223,7 +196,8 @@ make_glyph(int glyph_index) { TransparencyAttrib::Mode alpha_mode; // Calculate suitable texture dimensions for the signed distance field. - // This is the same calculation that Freetype uses in its bitmap renderer. + // This is the same calculation that Freetype uses in its bitmap + // renderer. FT_Outline_Get_CBox(&slot->outline, &bounds); bounds.xMin = bounds.xMin & ~63; @@ -274,11 +248,9 @@ make_glyph(int glyph_index) { return glyph; } -//////////////////////////////////////////////////////////////////// -// Function: PNMTextMaker::empty_cache -// Access: Private -// Description: Empties the cache of previously-generated glyphs. -//////////////////////////////////////////////////////////////////// +/** + * Empties the cache of previously-generated glyphs. + */ void PNMTextMaker:: empty_cache() { Glyphs::iterator gi; diff --git a/panda/src/pnmtext/pnmTextMaker.h b/panda/src/pnmtext/pnmTextMaker.h index 4f4247c22e..662341c16c 100644 --- a/panda/src/pnmtext/pnmTextMaker.h +++ b/panda/src/pnmtext/pnmTextMaker.h @@ -1,16 +1,15 @@ -// Filename: pnmTextMaker.h -// Created by: drose (03Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pnmTextMaker.h + * @author drose + * @date 2002-04-03 + */ #ifndef PNMTEXTMAKER_H #define PNMTEXTMAKER_H @@ -27,15 +26,12 @@ class Filename; class PNMImage; class PNMTextGlyph; -//////////////////////////////////////////////////////////////////// -// Class : PNMTextMaker -// Description : This object uses the Freetype library to generate -// text directly into an image. It is different from -// the TextNode/DynamicTextFont interface, which use the -// Freetype library to generate text in the scene graph, -// to be rendered onscreen via the Panda render -// traversal. -//////////////////////////////////////////////////////////////////// +/** + * This object uses the Freetype library to generate text directly into an + * image. It is different from the TextNode/DynamicTextFont interface, which + * use the Freetype library to generate text in the scene graph, to be + * rendered onscreen via the Panda render traversal. + */ class EXPCL_PANDA_PNMTEXT PNMTextMaker : public FreetypeFont { PUBLISHED: PNMTextMaker(const Filename &font_filename, int face_index); diff --git a/panda/src/pstatclient/config_pstats.cxx b/panda/src/pstatclient/config_pstats.cxx index a529dba637..4a25d9e85c 100644 --- a/panda/src/pstatclient/config_pstats.cxx +++ b/panda/src/pstatclient/config_pstats.cxx @@ -1,16 +1,15 @@ -// Filename: config_pstats.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pstats.cxx + * @author drose + * @date 2000-07-09 + */ #include "config_pstats.h" @@ -79,8 +78,8 @@ ConfigVariableBool pstats_gpu_timing "is not usually an accurate reflectino of how long the actual " "operation takes on the video card.")); -// The rest are different in that they directly control the server, -// not the client. +// The rest are different in that they directly control the server, not the +// client. ConfigVariableBool pstats_scroll_mode ("pstats-scroll-mode", true); ConfigVariableDouble pstats_history @@ -94,14 +93,12 @@ ConfigVariableBool pstats_mem_other "the total into a single \"Other\" category, or false to show " "each nonzero memory category.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libpstatclient -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpstatclient() { static bool initialized = false; @@ -110,4 +107,3 @@ init_libpstatclient() { } initialized = true; } - diff --git a/panda/src/pstatclient/config_pstats.h b/panda/src/pstatclient/config_pstats.h index be9b0e1e49..d3136ad736 100644 --- a/panda/src/pstatclient/config_pstats.h +++ b/panda/src/pstatclient/config_pstats.h @@ -1,16 +1,15 @@ -// Filename: config_pstats.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pstats.h + * @author drose + * @date 2000-07-09 + */ #ifndef CONFIG_PSTATS_H #define CONFIG_PSTATS_H diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index 1c26ac4d3c..5416b31234 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -1,89 +1,69 @@ -// Filename: pStatClient.I -// Created by: drose (16Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClient.I + * @author drose + * @date 2000-07-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::set_client_name -// Access: Published -// Description: Sets the name of the client. This is reported to the -// PStatsServer, and will presumably be written in the -// title bar or something. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the client. This is reported to the PStatsServer, and + * will presumably be written in the title bar or something. + */ INLINE void PStatClient:: set_client_name(const string &name) { get_impl()->set_client_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_client_name -// Access: Published -// Description: Retrieves the name of the client as set. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the name of the client as set. + */ INLINE string PStatClient:: get_client_name() const { return get_impl()->get_client_name(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::set_max_rate -// Access: Published -// Description: Controls the number of packets that will be sent to -// the server. Normally, one packet is sent per frame, -// but this can flood the server with more packets than -// it can handle if the frame rate is especially good -// (e.g. if nothing is onscreen at the moment). Set -// this parameter to a reasonable number to prevent this -// from happening. -// -// This number specifies the maximum number of packets -// that will be sent to the server per second, per -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Controls the number of packets that will be sent to the server. Normally, + * one packet is sent per frame, but this can flood the server with more + * packets than it can handle if the frame rate is especially good (e.g. if + * nothing is onscreen at the moment). Set this parameter to a reasonable + * number to prevent this from happening. + * + * This number specifies the maximum number of packets that will be sent to + * the server per second, per thread. + */ INLINE void PStatClient:: set_max_rate(double rate) { get_impl()->set_max_rate(rate); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_max_rate -// Access: Published -// Description: Returns the maximum number of packets that will be -// sent to the server per second, per thread. See -// set_max_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of packets that will be sent to the server per + * second, per thread. See set_max_rate(). + */ INLINE double PStatClient:: get_max_rate() const { return get_impl()->get_max_rate(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_num_collectors -// Access: Published -// Description: Returns the total number of collectors the Client -// knows about. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of collectors the Client knows about. + */ INLINE int PStatClient:: get_num_collectors() const { ReMutexHolder holder(_lock); return (int)_num_collectors; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_collector_def -// Access: Published -// Description: Returns the definition body of the nth collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the definition body of the nth collector. + */ INLINE PStatCollectorDef *PStatClient:: get_collector_def(int index) const { nassertr(index >= 0 && index < _num_collectors, NULL); @@ -91,46 +71,36 @@ get_collector_def(int index) const { return get_collector_ptr(index)->get_def(this, index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_num_threads -// Access: Published -// Description: Returns the total number of threads the Client -// knows about. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of threads the Client knows about. + */ INLINE int PStatClient:: get_num_threads() const { ReMutexHolder holder(_lock); return (int)_num_threads; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_thread_name -// Access: Published -// Description: Returns the name of the indicated thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated thread. + */ INLINE string PStatClient:: get_thread_name(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), string()); return get_thread_ptr(index)->_name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_thread_sync_name -// Access: Published -// Description: Returns the sync_name of the indicated thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the sync_name of the indicated thread. + */ INLINE string PStatClient:: get_thread_sync_name(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), string()); return get_thread_ptr(index)->_sync_name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_thread_object -// Access: Published -// Description: Returns the Panda Thread object associated with the -// indicated PStatThread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda Thread object associated with the indicated PStatThread. + */ INLINE Thread *PStatClient:: get_thread_object(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_threads), NULL); @@ -141,15 +111,12 @@ get_thread_object(int index) const { return thread->_thread; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_real_time -// Access: Published -// Description: Returns the time according to to the PStatClient's -// clock object. It keeps its own clock, instead of -// using the global clock object, so the stats won't get -// mucked up if you put the global clock in -// non-real-time mode or something. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time according to to the PStatClient's clock object. It keeps + * its own clock, instead of using the global clock object, so the stats won't + * get mucked up if you put the global clock in non-real-time mode or + * something. + */ INLINE double PStatClient:: get_real_time() const { if (has_impl()) { @@ -158,57 +125,45 @@ get_real_time() const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::connect -// Access: Published, Static -// Description: Attempts to establish a connection to the indicated -// PStatServer. Returns true if successful, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to establish a connection to the indicated PStatServer. Returns + * true if successful, false on failure. + */ INLINE bool PStatClient:: connect(const string &hostname, int port) { return get_global_pstats()->client_connect(hostname, port); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::disconnect -// Access: Published, Static -// Description: Closes the connection previously established. -//////////////////////////////////////////////////////////////////// +/** + * Closes the connection previously established. + */ INLINE void PStatClient:: disconnect() { get_global_pstats()->client_disconnect(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::is_connected -// Access: Published, Static -// Description: Returns true if the client believes it is connected -// to a working PStatServer, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the client believes it is connected to a working + * PStatServer, false otherwise. + */ INLINE bool PStatClient:: is_connected() { return get_global_pstats()->client_is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::resume_after_pause -// Access: Published, Static -// Description: Resumes the PStatClient after the simulation has been -// paused for a while. This allows the stats to -// continue exactly where it left off, instead of -// leaving a big gap that would represent a chug. -//////////////////////////////////////////////////////////////////// +/** + * Resumes the PStatClient after the simulation has been paused for a while. + * This allows the stats to continue exactly where it left off, instead of + * leaving a big gap that would represent a chug. + */ INLINE void PStatClient:: resume_after_pause() { get_global_pstats()->client_resume_after_pause(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_connect -// Access: Published -// Description: The nonstatic implementation of connect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of connect(). + */ INLINE bool PStatClient:: client_connect(string hostname, int port) { ReMutexHolder holder(_lock); @@ -216,24 +171,19 @@ client_connect(string hostname, int port) { return get_impl()->client_connect(hostname, port); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_is_connected -// Access: Published -// Description: The nonstatic implementation of is_connected(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of is_connected(). + */ INLINE bool PStatClient:: client_is_connected() const { return has_impl() && _impl->client_is_connected(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_resume_after_pause -// Access: Published -// Description: Resumes the PStatClient after the simulation has been -// paused for a while. This allows the stats to -// continue exactly where it left off, instead of -// leaving a big gap that would represent a chug. -//////////////////////////////////////////////////////////////////// +/** + * Resumes the PStatClient after the simulation has been paused for a while. + * This allows the stats to continue exactly where it left off, instead of + * leaving a big gap that would represent a chug. + */ INLINE void PStatClient:: client_resume_after_pause() { if (has_impl()) { @@ -241,24 +191,19 @@ client_resume_after_pause() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::has_impl -// Access: Private -// Description: Returns true if the PStatClientImpl object has been -// created for this object yet, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PStatClientImpl object has been created for this object + * yet, false otherwise. + */ INLINE bool PStatClient:: has_impl() const { return (_impl != (PStatClientImpl *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_impl -// Access: Private -// Description: Returns the PStatClientImpl object for this object. -// If the PStatClientImpl object has not yet been -// created, implicitly creates it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStatClientImpl object for this object. If the PStatClientImpl + * object has not yet been created, implicitly creates it. + */ INLINE PStatClientImpl *PStatClient:: get_impl() { ReMutexHolder holder(_lock); @@ -269,47 +214,37 @@ get_impl() { return _impl; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_impl -// Access: Private -// Description: Returns the PStatClientImpl object for this object. -// If the PStatClientImpl object has not yet been -// created, implicitly creates it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStatClientImpl object for this object. If the PStatClientImpl + * object has not yet been created, implicitly creates it. + */ INLINE const PStatClientImpl *PStatClient:: get_impl() const { return ((PStatClient *)this)->get_impl(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_collector_ptr -// Access: Private -// Description: Returns the nth collector in a thread-safe manner, -// even if _lock is not held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth collector in a thread-safe manner, even if _lock is not + * held. + */ INLINE PStatClient::Collector *PStatClient:: get_collector_ptr(int collector_index) const { CollectorPointer *collectors = (CollectorPointer *)AtomicAdjust::get_ptr(_collectors); return collectors[collector_index]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_thread_ptr -// Access: Private -// Description: Returns the nth thread in a thread-safe manner, -// even if _lock is not held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth thread in a thread-safe manner, even if _lock is not held. + */ INLINE PStatClient::InternalThread *PStatClient:: get_thread_ptr(int thread_index) const { ThreadPointer *threads = (ThreadPointer *)AtomicAdjust::get_ptr(_threads); return threads[thread_index]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatClient::Collector:: Collector(int parent_index, const string &name) : _def(NULL), @@ -318,46 +253,36 @@ Collector(int parent_index, const string &name) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::get_parent_index -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PStatClient::Collector:: get_parent_index() const { return _parent_index; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &PStatClient::Collector:: get_name() const { return _name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::is_active -// Access: Public -// Description: Returns true if the indicated collector has been -// designated as active, false otherwise. This might -// return initially false until the collector def has -// actually been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated collector has been designated as active, + * false otherwise. This might return initially false until the collector def + * has actually been created. + */ INLINE bool PStatClient::Collector:: is_active() const { return _def != (PStatCollectorDef *)NULL && _def->_is_active; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::get_def -// Access: Public -// Description: Returns the PStatCollectorDef that contains all of -// the information about the collector. If this object -// has not yet been created, creates it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PStatCollectorDef that contains all of the information about + * the collector. If this object has not yet been created, creates it. + */ INLINE PStatCollectorDef *PStatClient::Collector:: get_def(const PStatClient *client, int this_index) const { if (_def == (PStatCollectorDef *)NULL) { diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 8bf8c74af8..9d87a13036 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -1,22 +1,20 @@ -// Filename: pStatClient.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClient.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatClient.h" #ifdef DO_PSTATS -// This file only defines anything interesting if DO_PSTATS is -// defined. +// This file only defines anything interesting if DO_PSTATS is defined. #include "pStatClientImpl.h" #include "pStatClientControlMessage.h" @@ -49,8 +47,8 @@ PStatCollector PStatClient::_thread_block_pcollector("Wait:Thread block"); PStatClient *PStatClient::_global_pstats = NULL; -// This class is used to report memory usage per TypeHandle. We -// create one of these for each TypeHandle in the system. +// This class is used to report memory usage per TypeHandle. We create one of +// these for each TypeHandle in the system. class TypeHandleCollector { public: PStatCollector _mem_class[TypeHandle::MC_limit]; @@ -59,11 +57,9 @@ typedef pvector TypeHandleCols; static TypeHandleCols type_handle_cols; -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::PerThreadData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClient::PerThreadData:: PerThreadData() { _has_level = false; @@ -71,11 +67,9 @@ PerThreadData() { _nested_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClient:: PStatClient() : _lock("PStatClient::_lock"), @@ -89,45 +83,39 @@ PStatClient() : _threads_size = 0; _num_threads = 0; - // We always have a collector at index 0 named "Frame". This tracks - // the total frame time and is the root of all other collectors. We - // have to make this one by hand since it's the root. + // We always have a collector at index 0 named "Frame". This tracks the + // total frame time and is the root of all other collectors. We have to + // make this one by hand since it's the root. Collector *collector = new Collector(0, "Frame"); - //collector->_def = new PStatCollectorDef(0, "Frame"); - //collector->_def->_parent_index = 0; - //collector->_def->_suggested_color.set(0.5, 0.5, 0.5); + // collector->_def = new PStatCollectorDef(0, "Frame"); + // collector->_def->_parent_index = 0; + // collector->_def->_suggested_color.set(0.5, 0.5, 0.5); add_collector(collector); // The main thread is always at index 0. make_thread(Thread::get_main_thread()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClient:: ~PStatClient() { disconnect(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_collector -// Access: Published -// Description: Returns the nth collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth collector. + */ PStatCollector PStatClient:: get_collector(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_collectors), PStatCollector()); return PStatCollector((PStatClient *)this, index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_collector_name -// Access: Published -// Description: Returns the name of the indicated collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated collector. + */ string PStatClient:: get_collector_name(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_collectors), string()); @@ -135,14 +123,11 @@ get_collector_name(int index) const { return get_collector_ptr(index)->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_collector_fullname -// Access: Published -// Description: Returns the "full name" of the indicated collector. -// This will be the concatenation of all of the -// collector's parents' names (except Frame) and the -// collector's own name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "full name" of the indicated collector. This will be the + * concatenation of all of the collector's parents' names (except Frame) and + * the collector's own name. + */ string PStatClient:: get_collector_fullname(int index) const { nassertr(index >= 0 && index < AtomicAdjust::get(_num_collectors), string()); @@ -157,11 +142,9 @@ get_collector_fullname(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_thread -// Access: Published -// Description: Returns the nth thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth thread. + */ PStatThread PStatClient:: get_thread(int index) const { ReMutexHolder holder(_lock); @@ -169,24 +152,19 @@ get_thread(int index) const { return PStatThread((PStatClient *)this, index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_main_thread -// Access: Published -// Description: Returns a handle to the client's Main thread. This -// is the thread that started the application. -//////////////////////////////////////////////////////////////////// +/** + * Returns a handle to the client's Main thread. This is the thread that + * started the application. + */ PStatThread PStatClient:: get_main_thread() const { return PStatThread((PStatClient *)this, 0); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_current_thread -// Access: Published -// Description: Returns a handle to the currently-executing thread. -// This is the thread that PStatCollectors will be -// counted in if they do not specify otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns a handle to the currently-executing thread. This is the thread + * that PStatCollectors will be counted in if they do not specify otherwise. + */ PStatThread PStatClient:: get_current_thread() const { if (!client_is_connected()) { @@ -197,19 +175,16 @@ get_current_thread() const { return PStatThread(Thread::get_current_thread(), (PStatClient *)this); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::main_tick -// Access: Published, Static -// Description: A convenience function to call new_frame() on the -// global PStatClient's main thread, and any other -// threads with a sync_name of "Main". -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to call new_frame() on the global PStatClient's main + * thread, and any other threads with a sync_name of "Main". + */ void PStatClient:: main_tick() { - // We have code here to report the memory usage. We can't put this - // code inside the MemoryUsage class, where it fits a little better, - // simply because MemoryUsage is a very low-level class that doesn't - // know about PStatClient. + // We have code here to report the memory usage. We can't put this code + // inside the MemoryUsage class, where it fits a little better, simply + // because MemoryUsage is a very low-level class that doesn't know about + // PStatClient. #ifdef DO_MEMORY_USAGE if (is_connected()) { @@ -279,8 +254,8 @@ main_tick() { PStatCollector &col = type_handle_cols[i]._mem_class[mi]; size_t usage = type.get_memory_usage(mc); if (usage > min_usage || col.is_valid()) { - // We have some memory usage on this TypeHandle. See if we - // have a collector for it. + // We have some memory usage on this TypeHandle. See if we have a + // collector for it. if (!col.is_valid()) { const char *category = ""; switch (mc) { @@ -337,8 +312,8 @@ main_tick() { _mmap_nf_unused_size_pcollector.set_level(NeverFreeMemory::get_total_unused()); - // The remaining amount--all collectors smaller than 0.1% of the - // total--go into "other". + // The remaining amount--all collectors smaller than 0.1% of the total--go + // into "other". _heap_single_other_size_pcollector.set_level(single_other_usage); _heap_array_other_size_pcollector.set_level(array_other_usage); _mmap_dc_active_other_size_pcollector.set_level(dc_active_other_usage); @@ -349,24 +324,19 @@ main_tick() { get_global_pstats()->client_main_tick(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::thread_tick -// Access: Published, Static -// Description: A convenience function to call new_frame() on any -// threads with the indicated sync_name -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to call new_frame() on any threads with the + * indicated sync_name + */ void PStatClient:: thread_tick(const string &sync_name) { get_global_pstats()->client_thread_tick(sync_name); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_main_tick -// Access: Published -// Description: A convenience function to call new_frame() on the -// given PStatClient's main thread, and any other -// threads with a sync_name of "Main". -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to call new_frame() on the given PStatClient's main + * thread, and any other threads with a sync_name of "Main". + */ void PStatClient:: client_main_tick() { ReMutexHolder holder(_lock); @@ -391,12 +361,10 @@ client_main_tick() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_thread_tick -// Access: Published -// Description: A convenience function to call new_frame() on all of -// the threads with the indicated sync name. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to call new_frame() on all of the threads with the + * indicated sync name. + */ void PStatClient:: client_thread_tick(const string &sync_name) { ReMutexHolder holder(_lock); @@ -415,11 +383,9 @@ client_thread_tick(const string &sync_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::client_disconnect -// Access: Published -// Description: The nonstatic implementation of disconnect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of disconnect(). + */ void PStatClient:: client_disconnect() { ReMutexHolder holder(_lock); @@ -450,14 +416,11 @@ client_disconnect() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_global_pstats -// Access: Published, Static -// Description: Returns a pointer to the global PStatClient object. -// It's legal to declare your own PStatClient locally, -// but it's also convenient to have a global one that -// everyone can register with. This is the global one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global PStatClient object. It's legal to declare + * your own PStatClient locally, but it's also convenient to have a global one + * that everyone can register with. This is the global one. + */ PStatClient *PStatClient:: get_global_pstats() { if (_global_pstats == (PStatClient *)NULL) { @@ -470,17 +433,13 @@ get_global_pstats() { return _global_pstats; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::make_collector_with_relname -// Access: Private -// Description: Returns a PStatCollector suitable for measuring -// categories with the indicated name. This is normally -// called by a PStatCollector constructor. -// -// The name may contain colons; if it does, it specifies -// a relative path to the client indicated by the parent -// index. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector suitable for measuring categories with the + * indicated name. This is normally called by a PStatCollector constructor. + * + * The name may contain colons; if it does, it specifies a relative path to + * the client indicated by the parent index. + */ PStatCollector PStatClient:: make_collector_with_relname(int parent_index, string relname) { ReMutexHolder holder(_lock); @@ -495,8 +454,8 @@ make_collector_with_relname(int parent_index, string relname) { start++; } - // If the name contains a colon (after the initial colon), it means - // we are making a nested collector. + // If the name contains a colon (after the initial colon), it means we are + // making a nested collector. size_t colon = relname.find(':', start); while (colon != string::npos) { string parent_name = relname.substr(start, colon - start); @@ -512,15 +471,12 @@ make_collector_with_relname(int parent_index, string relname) { return make_collector_with_name(parent_index, name); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::make_collector_with_name -// Access: Private -// Description: Returns a PStatCollector suitable for measuring -// categories with the indicated name. This is normally -// called by a PStatCollector constructor. -// -// The name should not contain colons. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatCollector suitable for measuring categories with the + * indicated name. This is normally called by a PStatCollector constructor. + * + * The name should not contain colons. + */ PStatCollector PStatClient:: make_collector_with_name(int parent_index, const string &name) { ReMutexHolder holder(_lock); @@ -530,9 +486,9 @@ make_collector_with_name(int parent_index, const string &name) { Collector *parent = get_collector_ptr(parent_index); - // A special case: if we asked for a child the same name as its - // parent, we really meant the parent. That is, "Frame:Frame" is - // really the same collector as "Frame". + // A special case: if we asked for a child the same name as its parent, we + // really meant the parent. That is, "Frame:Frame" is really the same + // collector as "Frame". if (parent->get_name() == name) { return PStatCollector(this, parent_index); } @@ -564,12 +520,9 @@ make_collector_with_name(int parent_index, const string &name) { return PStatCollector(this, new_index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::do_get_current_thread -// Access: Private -// Description: Similar to get_current_thread, but does not grab the -// lock. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_current_thread, but does not grab the lock. + */ PStatThread PStatClient:: do_get_current_thread() const { Thread *thread = Thread::get_current_thread(); @@ -578,29 +531,24 @@ do_get_current_thread() const { return PStatThread((PStatClient *)this, thread_index); } - // This is the first time we have encountered this current Thread. - // Make a new PStatThread object for it. + // This is the first time we have encountered this current Thread. Make a + // new PStatThread object for it. return ((PStatClient *)this)->do_make_thread(thread); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::make_thread -// Access: Private -// Description: Returns a PStatThread for the indicated Panda Thread -// object. This is normally called by a PStatThread -// constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatThread for the indicated Panda Thread object. This is + * normally called by a PStatThread constructor. + */ PStatThread PStatClient:: make_thread(Thread *thread) { ReMutexHolder holder(_lock); return do_make_thread(thread); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::do_make_thread -// Access: Private -// Description: As above, but assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * As above, but assumes the lock is already held. + */ PStatThread PStatClient:: do_make_thread(Thread *thread) { int thread_index = thread->get_pstats_index(); @@ -612,8 +560,8 @@ do_make_thread(Thread *thread) { _threads_by_name.find(thread->get_name()); if (ni != _threads_by_name.end()) { - // We have seen a thread with this name before. Can we re-use any - // of them? + // We have seen a thread with this name before. Can we re-use any of + // them? const vector_int &indices = (*ni).second; for (vector_int::const_iterator vi = indices.begin(); vi != indices.end(); @@ -643,12 +591,10 @@ do_make_thread(Thread *thread) { return PStatThread(this, new_index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::make_gpu_thread -// Access: Private -// Description: Returns a PStatThread representing the GPU. -// This is normally called by the GSG only. -//////////////////////////////////////////////////////////////////// +/** + * Returns a PStatThread representing the GPU. This is normally called by the + * GSG only. + */ PStatThread PStatClient:: make_gpu_thread(const string &name) { ReMutexHolder holder(_lock); @@ -660,16 +606,13 @@ make_gpu_thread(const string &name) { return PStatThread(this, new_index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::is_active -// Access: Private -// Description: Returns true if the indicated collector/thread -// combination is active, and we are transmitting stats -// data, or false otherwise. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::is_active(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated collector/thread combination is active, and + * we are transmitting stats data, or false otherwise. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::is_active(). + */ bool PStatClient:: is_active(int collector_index, int thread_index) const { nassertr(collector_index >= 0 && collector_index < AtomicAdjust::get(_num_collectors), false); @@ -680,15 +623,13 @@ is_active(int collector_index, int thread_index) const { get_thread_ptr(thread_index)->_is_active); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::is_started -// Access: Private -// Description: Returns true if the indicated collector/thread -// combination has been started, or false otherwise. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::is_started(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated collector/thread combination has been + * started, or false otherwise. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::is_started(). + */ bool PStatClient:: is_started(int collector_index, int thread_index) const { nassertr(collector_index >= 0 && collector_index < AtomicAdjust::get(_num_collectors), false); @@ -711,13 +652,10 @@ is_started(int collector_index, int thread_index) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::start -// Access: Private -// Description: Marks the indicated collector index as started. -// Normally you would not use this interface directly; -// instead, call PStatCollector::start(). -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated collector index as started. Normally you would not use + * this interface directly; instead, call PStatCollector::start(). + */ void PStatClient:: start(int collector_index, int thread_index) { if (!client_is_connected()) { @@ -735,8 +673,8 @@ start(int collector_index, int thread_index) { if (collector->is_active() && thread->_is_active) { LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { - // This collector wasn't already started in this thread; record - // a new data point. + // This collector wasn't already started in this thread; record a new + // data point. if (thread->_thread_active) { thread->_frame_data.add_start(collector_index, get_real_time()); } @@ -745,13 +683,10 @@ start(int collector_index, int thread_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::start -// Access: Private -// Description: Marks the indicated collector index as started. -// Normally you would not use this interface directly; -// instead, call PStatCollector::start(). -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated collector index as started. Normally you would not use + * this interface directly; instead, call PStatCollector::start(). + */ void PStatClient:: start(int collector_index, int thread_index, double as_of) { if (!client_is_connected()) { @@ -769,8 +704,8 @@ start(int collector_index, int thread_index, double as_of) { if (collector->is_active() && thread->_is_active) { LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { - // This collector wasn't already started in this thread; record - // a new data point. + // This collector wasn't already started in this thread; record a new + // data point. if (thread->_thread_active) { thread->_frame_data.add_start(collector_index, as_of); } @@ -779,13 +714,10 @@ start(int collector_index, int thread_index, double as_of) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::stop -// Access: Private -// Description: Marks the indicated collector index as stopped. -// Normally you would not use this interface directly; -// instead, call PStatCollector::stop(). -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated collector index as stopped. Normally you would not use + * this interface directly; instead, call PStatCollector::stop(). + */ void PStatClient:: stop(int collector_index, int thread_index) { if (!client_is_connected()) { @@ -815,8 +747,8 @@ stop(int collector_index, int thread_index) { collector->_per_thread[thread_index]._nested_count--; if (collector->_per_thread[thread_index]._nested_count == 0) { - // This collector has now been completely stopped; record a new - // data point. + // This collector has now been completely stopped; record a new data + // point. if (thread->_thread_active) { thread->_frame_data.add_stop(collector_index, get_real_time()); } @@ -824,13 +756,10 @@ stop(int collector_index, int thread_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::stop -// Access: Private -// Description: Marks the indicated collector index as stopped. -// Normally you would not use this interface directly; -// instead, call PStatCollector::stop(). -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated collector index as stopped. Normally you would not use + * this interface directly; instead, call PStatCollector::stop(). + */ void PStatClient:: stop(int collector_index, int thread_index, double as_of) { if (!client_is_connected()) { @@ -860,23 +789,20 @@ stop(int collector_index, int thread_index, double as_of) { collector->_per_thread[thread_index]._nested_count--; if (collector->_per_thread[thread_index]._nested_count == 0) { - // This collector has now been completely stopped; record a new - // data point. + // This collector has now been completely stopped; record a new data + // point. thread->_frame_data.add_stop(collector_index, as_of); } } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::clear_level -// Access: Private -// Description: Removes the level value from the indicated collector. -// The collector will no longer be reported as having -// any particular level value. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::clear_level(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the level value from the indicated collector. The collector will + * no longer be reported as having any particular level value. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::clear_level(). + */ void PStatClient:: clear_level(int collector_index, int thread_index) { if (!client_is_connected()) { @@ -896,15 +822,12 @@ clear_level(int collector_index, int thread_index) { collector->_per_thread[thread_index]._level = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::set_level -// Access: Private -// Description: Sets the level value for the indicated collector to -// the given amount. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::set_level(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the level value for the indicated collector to the given amount. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::set_level(). + */ void PStatClient:: set_level(int collector_index, int thread_index, double level) { if (!client_is_connected()) { @@ -920,9 +843,8 @@ set_level(int collector_index, int thread_index, double level) { InternalThread *thread = get_thread_ptr(thread_index); // We don't want to condition this on whether the client is already - // connected or the collector is already active, since we might - // connect the client later, and we will want to have an accurate - // value at that time. + // connected or the collector is already active, since we might connect the + // client later, and we will want to have an accurate value at that time. LightMutexHolder holder(thread->_thread_lock); level *= collector->get_def(this, collector_index)->_factor; @@ -931,17 +853,14 @@ set_level(int collector_index, int thread_index, double level) { collector->_per_thread[thread_index]._level = level; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::add_level -// Access: Private -// Description: Adds the given value (which may be negative) to the -// current value for the given collector. If the -// collector does not already have a level value, it is -// initialized to 0. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::add_level(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the given value (which may be negative) to the current value for the + * given collector. If the collector does not already have a level value, it + * is initialized to 0. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::add_level(). + */ void PStatClient:: add_level(int collector_index, int thread_index, double increment) { if (!client_is_connected()) { @@ -963,15 +882,13 @@ add_level(int collector_index, int thread_index, double increment) { collector->_per_thread[thread_index]._level += increment; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::get_level -// Access: Private -// Description: Returns the current level value of the given collector. -// Returns 0.0 if the pstats client is not connected. -// -// Normally you would not use this interface directly; -// instead, call PStatCollector::get_level(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current level value of the given collector. Returns 0.0 if the + * pstats client is not connected. + * + * Normally you would not use this interface directly; instead, call + * PStatCollector::get_level(). + */ double PStatClient:: get_level(int collector_index, int thread_index) const { if (!client_is_connected()) { @@ -992,83 +909,67 @@ get_level(int collector_index, int thread_index) const { return collector->_per_thread[thread_index]._level / factor; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::start_clock_wait -// Access: Private, Static -// Description: This function is added as a hook into ClockObject, so -// that we may time the delay for -// ClockObject::wait_until(), used for certain special -// clock modes. -// -// This callback is a hack around the fact that we can't -// let the ClockObject directly create a PStatCollector, -// because the pstatclient module depends on putil. -//////////////////////////////////////////////////////////////////// +/** + * This function is added as a hook into ClockObject, so that we may time the + * delay for ClockObject::wait_until(), used for certain special clock modes. + * + * This callback is a hack around the fact that we can't let the ClockObject + * directly create a PStatCollector, because the pstatclient module depends on + * putil. + */ void PStatClient:: start_clock_wait() { _clock_wait_pcollector.start(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::start_clock_busy_wait -// Access: Private, Static -// Description: This function is added as a hook into ClockObject, so -// that we may time the delay for -// ClockObject::wait_until(), used for certain special -// clock modes. -// -// This callback is a hack around the fact that we can't -// let the ClockObject directly create a PStatCollector, -// because the pstatclient module depends on putil. -//////////////////////////////////////////////////////////////////// +/** + * This function is added as a hook into ClockObject, so that we may time the + * delay for ClockObject::wait_until(), used for certain special clock modes. + * + * This callback is a hack around the fact that we can't let the ClockObject + * directly create a PStatCollector, because the pstatclient module depends on + * putil. + */ void PStatClient:: start_clock_busy_wait() { _clock_wait_pcollector.stop(); _clock_busy_wait_pcollector.start(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::stop_clock_wait -// Access: Private, Static -// Description: This function is added as a hook into ClockObject, so -// that we may time the delay for -// ClockObject::wait_until(), used for certain special -// clock modes. -// -// This callback is a hack around the fact that we can't -// let the ClockObject directly create a PStatCollector, -// because the pstatclient module depends on putil. -//////////////////////////////////////////////////////////////////// +/** + * This function is added as a hook into ClockObject, so that we may time the + * delay for ClockObject::wait_until(), used for certain special clock modes. + * + * This callback is a hack around the fact that we can't let the ClockObject + * directly create a PStatCollector, because the pstatclient module depends on + * putil. + */ void PStatClient:: stop_clock_wait() { _clock_busy_wait_pcollector.stop(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::add_collector -// Access: Private -// Description: Adds a new Collector entry to the _collectors array, -// in a thread-safe manner. Assumes _lock is already -// held. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new Collector entry to the _collectors array, in a thread-safe + * manner. Assumes _lock is already held. + */ void PStatClient:: add_collector(PStatClient::Collector *collector) { if (_num_collectors >= _collectors_size) { - // We need to grow the array. We have to be careful here, because - // there might be clients accessing the array right now who are - // not protected by the lock. + // We need to grow the array. We have to be careful here, because there + // might be clients accessing the array right now who are not protected by + // the lock. int new_collectors_size = (_collectors_size == 0) ? 128 : _collectors_size * 2; CollectorPointer *new_collectors = new CollectorPointer[new_collectors_size]; memcpy(new_collectors, _collectors, _num_collectors * sizeof(CollectorPointer)); AtomicAdjust::set_ptr(_collectors, new_collectors); AtomicAdjust::set(_collectors_size, new_collectors_size); - // Now, we still have the old array, which we allow to leak. We - // should delete it, but there might be a thread out there that's - // still trying to access it, so we can't safely delete it; and it - // doesn't really matter much, since it's not a big leak. (We - // will only reallocate the array so many times in an application, - // and then no more.) + // Now, we still have the old array, which we allow to leak. We should + // delete it, but there might be a thread out there that's still trying to + // access it, so we can't safely delete it; and it doesn't really matter + // much, since it's not a big leak. (We will only reallocate the array so + // many times in an application, and then no more.) new_collectors[_num_collectors] = collector; AtomicAdjust::inc(_num_collectors); @@ -1080,36 +981,31 @@ add_collector(PStatClient::Collector *collector) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::add_thread -// Access: Private -// Description: Adds a new InternalThread entry to the _threads -// array, in a thread-safe manner. Assumes _lock is -// already held. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new InternalThread entry to the _threads array, in a thread-safe + * manner. Assumes _lock is already held. + */ void PStatClient:: add_thread(PStatClient::InternalThread *thread) { _threads_by_name[thread->_name].push_back(_num_threads); _threads_by_sync_name[thread->_sync_name].push_back(_num_threads); if (_num_threads >= _threads_size) { - // We need to grow the array. We have to be careful here, because - // there might be clients accessing the array right now who are - // not protected by the lock. + // We need to grow the array. We have to be careful here, because there + // might be clients accessing the array right now who are not protected by + // the lock. int new_threads_size = (_threads_size == 0) ? 128 : _threads_size * 2; ThreadPointer *new_threads = new ThreadPointer[new_threads_size]; memcpy(new_threads, _threads, _num_threads * sizeof(ThreadPointer)); - // We assume that assignment to a pointer and to an int are each - // atomic. + // We assume that assignment to a pointer and to an int are each atomic. AtomicAdjust::set_ptr(_threads, new_threads); AtomicAdjust::set(_threads_size, new_threads_size); - // Now, we still have the old array, which we allow to leak. We - // should delete it, but there might be a thread out there that's - // still trying to access it, so we can't safely delete it; and it - // doesn't really matter much, since it's not a big leak. (We - // will only reallocate the array so many times in an application, - // and then no more.) + // Now, we still have the old array, which we allow to leak. We should + // delete it, but there might be a thread out there that's still trying to + // access it, so we can't safely delete it; and it doesn't really matter + // much, since it's not a big leak. (We will only reallocate the array so + // many times in an application, and then no more.) new_threads[_num_threads] = thread; @@ -1130,21 +1026,16 @@ add_thread(PStatClient::InternalThread *thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::deactivate_hook -// Access: Public, Virtual -// Description: Called when the thread is deactivated (swapped for -// another running thread). This is intended to provide -// a callback hook for PStats to assign time to -// individual threads properly, particularly in the -// SIMPLE_THREADS case. -//////////////////////////////////////////////////////////////////// +/** + * Called when the thread is deactivated (swapped for another running thread). + * This is intended to provide a callback hook for PStats to assign time to + * individual threads properly, particularly in the SIMPLE_THREADS case. + */ void PStatClient:: deactivate_hook(Thread *thread) { - // We shouldn't use a mutex here, because this code is only called - // during the SIMPLE_THREADS case, so a mutex isn't necessary; and - // because we are called during a context switch, so a mutex might - // be dangerous. + // We shouldn't use a mutex here, because this code is only called during + // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are + // called during a context switch, so a mutex might be dangerous. if (_impl == NULL) { return; } @@ -1152,28 +1043,24 @@ deactivate_hook(Thread *thread) { InternalThread *ithread = get_thread_ptr(thread_index); if (ithread->_thread_active) { - // Start _thread_block_pcollector, by hand, being careful not to - // grab any mutexes while we do it. + // Start _thread_block_pcollector, by hand, being careful not to grab any + // mutexes while we do it. double now = _impl->get_real_time(); ithread->_frame_data.add_start(_thread_block_pcollector.get_index(), now); ithread->_thread_active = false; } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::activate_hook -// Access: Public, Virtual -// Description: Called when the thread is activated (resumes -// execution). This is intended to provide a callback -// hook for PStats to assign time to individual threads -// properly, particularly in the SIMPLE_THREADS case. -//////////////////////////////////////////////////////////////////// +/** + * Called when the thread is activated (resumes execution). This is intended + * to provide a callback hook for PStats to assign time to individual threads + * properly, particularly in the SIMPLE_THREADS case. + */ void PStatClient:: activate_hook(Thread *thread) { - // We shouldn't use a mutex here, because this code is only called - // during the SIMPLE_THREADS case, so a mutex isn't necessary; and - // because we are called during a context switch, so a mutex might - // be dangerous. + // We shouldn't use a mutex here, because this code is only called during + // the SIMPLE_THREADS case, so a mutex isn't necessary; and because we are + // called during a context switch, so a mutex might be dangerous. if (_impl == NULL) { return; } @@ -1187,11 +1074,9 @@ activate_hook(Thread *thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::Collector::make_def -// Access: Private -// Description: Creates the new PStatCollectorDef for this collector. -//////////////////////////////////////////////////////////////////// +/** + * Creates the new PStatCollectorDef for this collector. + */ void PStatClient::Collector:: make_def(const PStatClient *client, int this_index) { ReMutexHolder holder(client->_lock); @@ -1206,11 +1091,9 @@ make_def(const PStatClient *client, int this_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::InternalThread::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClient::InternalThread:: InternalThread(Thread *thread) : _thread(thread), @@ -1224,11 +1107,9 @@ InternalThread(Thread *thread) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatClient::InternalThread::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClient::InternalThread:: InternalThread(const string &name, const string &sync_name) : _thread(NULL), diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 1b733a543d..c88ef8f5af 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -1,16 +1,15 @@ -// Filename: pStatClient.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClient.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATCLIENT_H #define PSTATCLIENT_H @@ -37,23 +36,19 @@ class PStatCollectorDef; class PStatThread; class GraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : PStatClient -// Description : Manages the communications to report statistics via a -// network connection to a remote PStatServer. -// -// Normally, there is only one PStatClient in the world, -// although it is possible to have multiple PStatClients -// if extraordinary circumstances require in. Since -// each PStatCollector registers itself with the -// PStatClient when it is created, having multiple -// PStatClients requires special care when constructing -// the various PStatCollectors. -// -// If DO_PSTATS is not defined, we don't want to use -// stats at all. This class is therefore defined as a -// stub class. -//////////////////////////////////////////////////////////////////// +/** + * Manages the communications to report statistics via a network connection to + * a remote PStatServer. + * + * Normally, there is only one PStatClient in the world, although it is + * possible to have multiple PStatClients if extraordinary circumstances + * require in. Since each PStatCollector registers itself with the + * PStatClient when it is created, having multiple PStatClients requires + * special care when constructing the various PStatCollectors. + * + * If DO_PSTATS is not defined, we don't want to use stats at all. This class + * is therefore defined as a stub class. + */ #ifdef DO_PSTATS class EXPCL_PANDA_PSTATCLIENT PStatClient : public ConnectionManager, public Thread::PStatsCallback { public: @@ -152,9 +147,8 @@ private: typedef pmap MultiThingsByName; MultiThingsByName _threads_by_name, _threads_by_sync_name; - // This is for the data that is per-collector, per-thread. A vector - // of these is stored in each Collector object, below, indexed by - // thread index. + // This is for the data that is per-collector, per-thread. A vector of + // these is stored in each Collector object, below, indexed by thread index. class PerThreadData { public: PerThreadData(); @@ -164,8 +158,8 @@ private: }; typedef pvector PerThread; - // This is where the meat of the Collector data is stored. (All the - // stuff in PStatCollector and PStatCollectorDef is just fluff.) + // This is where the meat of the Collector data is stored. (All the stuff + // in PStatCollector and PStatCollectorDef is just fluff.) class Collector { public: INLINE Collector(int parent_index, const string &name); @@ -178,12 +172,11 @@ private: void make_def(const PStatClient *client, int this_index); private: - // This pointer is initially NULL, and will be filled in when it - // is first needed. + // This pointer is initially NULL, and will be filled in when it is first + // needed. PStatCollectorDef *_def; - // This data is used to create the PStatCollectorDef when it is - // needed. + // This data is used to create the PStatCollectorDef when it is needed. int _parent_index; string _name; @@ -197,9 +190,9 @@ private: AtomicAdjust::Integer _collectors_size; // size of the allocated array AtomicAdjust::Integer _num_collectors; // number of in-use elements within the array - // This defines a single thread, i.e. a separate chain of execution, - // independent of all other threads. Timing and level data are - // maintained separately for each thread. + // This defines a single thread, i.e. a separate chain of execution, + // independent of all other threads. Timing and level data are maintained + // separately for each thread. class InternalThread { public: InternalThread(Thread *thread); @@ -216,9 +209,9 @@ private: bool _thread_active; BitArray _active_collectors; // no longer used. - // This mutex is used to protect writes to _frame_data for this - // particular thread, as well as writes to the _per_thread data - // for this particular thread in the Collector class, above. + // This mutex is used to protect writes to _frame_data for this particular + // thread, as well as writes to the _per_thread data for this particular + // thread in the Collector class, above. LightMutex _thread_lock; }; typedef InternalThread *ThreadPointer; diff --git a/panda/src/pstatclient/pStatClientControlMessage.cxx b/panda/src/pstatclient/pStatClientControlMessage.cxx index 176390d0ab..0cecb2aead 100644 --- a/panda/src/pstatclient/pStatClientControlMessage.cxx +++ b/panda/src/pstatclient/pStatClientControlMessage.cxx @@ -1,16 +1,15 @@ -// Filename: pStatClientControlMessage.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientControlMessage.cxx + * @author drose + * @date 2000-07-09 + */ #include "config_pstats.h" #include "pStatClientControlMessage.h" @@ -19,21 +18,17 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatClientControlMessage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientControlMessage:: PStatClientControlMessage() { _type = T_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientControlMessage::encode -// Access: Public -// Description: Writes the message into the indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the message into the indicated datagram. + */ void PStatClientControlMessage:: encode(Datagram &datagram) const { datagram.clear(); @@ -71,12 +66,10 @@ encode(Datagram &datagram) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientControlMessage::decode -// Access: Public -// Description: Extracts the message from the indicated datagram. -// Returns true on success, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the message from the indicated datagram. Returns true on success, + * false on error. + */ bool PStatClientControlMessage:: decode(const Datagram &datagram, PStatClientVersion *version) { DatagramIterator source(datagram); diff --git a/panda/src/pstatclient/pStatClientControlMessage.h b/panda/src/pstatclient/pStatClientControlMessage.h index 803e11c22e..b815f3f558 100644 --- a/panda/src/pstatclient/pStatClientControlMessage.h +++ b/panda/src/pstatclient/pStatClientControlMessage.h @@ -1,16 +1,15 @@ -// Filename: pStatClientControlMessage.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientControlMessage.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATCLIENTCONTROLMESSAGE_H #define PSTATCLIENTCONTROLMESSAGE_H @@ -24,12 +23,10 @@ class Datagram; class PStatClientVersion; -//////////////////////////////////////////////////////////////////// -// Class : PStatClientControlMessage -// Description : This kind of message is sent from the client to the -// server on the TCP socket to establish critical -// control information. -//////////////////////////////////////////////////////////////////// +/** + * This kind of message is sent from the client to the server on the TCP + * socket to establish critical control information. + */ class EXPCL_PANDA_PSTATCLIENT PStatClientControlMessage { public: PStatClientControlMessage(); @@ -63,4 +60,3 @@ public: #endif - diff --git a/panda/src/pstatclient/pStatClientImpl.I b/panda/src/pstatclient/pStatClientImpl.I index 964bde21f2..95f6f13740 100644 --- a/panda/src/pstatclient/pStatClientImpl.I +++ b/panda/src/pstatclient/pStatClientImpl.I @@ -1,116 +1,92 @@ -// Filename: pStatClientImpl.I -// Created by: drose (23Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientImpl.I + * @author drose + * @date 2004-12-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::set_client_name -// Access: Public -// Description: Sets the name of the client. This is reported to the -// PStatsServer, and will presumably be written in the -// title bar or something. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the client. This is reported to the PStatsServer, and + * will presumably be written in the title bar or something. + */ INLINE void PStatClientImpl:: set_client_name(const string &name) { _client_name = name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::get_client_name -// Access: Public -// Description: Retrieves the name of the client as set. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the name of the client as set. + */ INLINE string PStatClientImpl:: get_client_name() const { return _client_name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::set_max_rate -// Access: Public -// Description: Controls the number of packets that will be sent to -// the server. Normally, one packet is sent per frame, -// but this can flood the server with more packets than -// it can handle if the frame rate is especially good -// (e.g. if nothing is onscreen at the moment). Set -// this parameter to a reasonable number to prevent this -// from happening. -// -// This number specifies the maximum number of packets -// that will be sent to the server per second, per -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Controls the number of packets that will be sent to the server. Normally, + * one packet is sent per frame, but this can flood the server with more + * packets than it can handle if the frame rate is especially good (e.g. if + * nothing is onscreen at the moment). Set this parameter to a reasonable + * number to prevent this from happening. + * + * This number specifies the maximum number of packets that will be sent to + * the server per second, per thread. + */ INLINE void PStatClientImpl:: set_max_rate(double rate) { _max_rate = rate; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::get_max_rate -// Access: Public -// Description: Returns the maximum number of packets that will be -// sent to the server per second, per thread. See -// set_max_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of packets that will be sent to the server per + * second, per thread. See set_max_rate(). + */ INLINE double PStatClientImpl:: get_max_rate() const { return _max_rate; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::get_real_time -// Access: Public -// Description: Returns the time according to the PStatClientImpl's -// clock object. It keeps its own clock, instead of -// using the global clock object, so the stats won't get -// mucked up if you put the global clock in -// non-real-time mode or something. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time according to the PStatClientImpl's clock object. It keeps + * its own clock, instead of using the global clock object, so the stats won't + * get mucked up if you put the global clock in non-real-time mode or + * something. + */ INLINE double PStatClientImpl:: get_real_time() const { return _clock->get_short_time() + _delta; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::client_main_tick -// Access: Public -// Description: Called only by PStatClient::client_main_tick(). -//////////////////////////////////////////////////////////////////// +/** + * Called only by PStatClient::client_main_tick(). + */ INLINE void PStatClientImpl:: client_main_tick() { _last_frame = _clock->get_short_time(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::client_is_connected -// Access: Public -// Description: Called only by PStatClient::client_is_connected(). -//////////////////////////////////////////////////////////////////// +/** + * Called only by PStatClient::client_is_connected(). + */ INLINE bool PStatClientImpl:: client_is_connected() const { return _is_connected; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::client_resume_after_pause -// Access: Public -// Description: Called only by PStatClient::client_resume_after_pause(). -//////////////////////////////////////////////////////////////////// +/** + * Called only by PStatClient::client_resume_after_pause(). + */ INLINE void PStatClientImpl:: client_resume_after_pause() { - // Simply reset the clock to the beginning of the last frame. This - // may lose a frame, but on the other hand we won't skip a whole - // slew of frames either. + // Simply reset the clock to the beginning of the last frame. This may lose + // a frame, but on the other hand we won't skip a whole slew of frames + // either. double delta = _clock->get_short_time() - _last_frame; _delta -= delta; } diff --git a/panda/src/pstatclient/pStatClientImpl.cxx b/panda/src/pstatclient/pStatClientImpl.cxx index 2d1feb7853..56f044d2a1 100644 --- a/panda/src/pstatclient/pStatClientImpl.cxx +++ b/panda/src/pstatclient/pStatClientImpl.cxx @@ -1,16 +1,15 @@ -// Filename: pStatClientImpl.cxx -// Created by: drose (23Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientImpl.cxx + * @author drose + * @date 2004-12-23 + */ #include "pStatClientImpl.h" @@ -33,11 +32,9 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientImpl:: PStatClientImpl(PStatClient *client) : _clock(TrueClock::get_global_ptr()), @@ -76,21 +73,17 @@ PStatClientImpl(PStatClient *client) : } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientImpl:: ~PStatClientImpl() { nassertv(!_is_connected); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::client_connect -// Access: Public -// Description: Called only by PStatClient::client_connect(). -//////////////////////////////////////////////////////////////////// +/** + * Called only by PStatClient::client_connect(). + */ bool PStatClientImpl:: client_connect(string hostname, int port) { nassertr(!_is_connected, true); @@ -116,8 +109,8 @@ client_connect(string hostname, int port) { << port << "\n"; return false; } - // Make sure we're not queuing up multiple TCP sockets--we expect - // immediate writes of our TCP datagrams. + // Make sure we're not queuing up multiple TCP sockets--we expect immediate + // writes of our TCP datagrams. _tcp_connection->set_collect_tcp(false); _reader.add_connection(_tcp_connection); @@ -134,11 +127,9 @@ client_connect(string hostname, int port) { return _is_connected; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::client_disconnect -// Access: Public -// Description: Called only by PStatClient::client_disconnect(). -//////////////////////////////////////////////////////////////////// +/** + * Called only by PStatClient::client_disconnect(). + */ void PStatClientImpl:: client_disconnect() { if (_is_connected) { @@ -160,28 +151,25 @@ client_disconnect() { _threads_reported = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::new_frame -// Access: Public -// Description: Called by the PStatThread interface at the beginning -// of every frame, for each thread. This resets the -// clocks for the new frame and transmits the data for -// the previous frame. -//////////////////////////////////////////////////////////////////// +/** + * Called by the PStatThread interface at the beginning of every frame, for + * each thread. This resets the clocks for the new frame and transmits the + * data for the previous frame. + */ void PStatClientImpl:: new_frame(int thread_index) { nassertv(thread_index >= 0 && thread_index < _client->_num_threads); PStatClient::InternalThread *pthread = _client->get_thread_ptr(thread_index); - // If we're the main thread, we should exchange control packets with - // the server. + // If we're the main thread, we should exchange control packets with the + // server. if (thread_index == 0) { transmit_control_data(); } - // If we've got the UDP port by the time the frame starts, it's - // time to become active and start actually tracking data. + // If we've got the UDP port by the time the frame starts, it's time to + // become active and start actually tracking data. if (_got_udp_port) { pthread->_is_active = true; } @@ -198,8 +186,8 @@ new_frame(int thread_index) { // Collector 0 is the whole frame. _client->stop(0, thread_index, frame_start); - // Fill up the level data for all the collectors who have level - // data for this pthread. + // Fill up the level data for all the collectors who have level data for + // this pthread. int num_collectors = _client->_num_collectors; PStatClient::CollectorPointer *collectors = (PStatClient::CollectorPointer *)_client->_collectors; @@ -229,26 +217,24 @@ new_frame(int thread_index) { _client->stop(pstats_index, current_thread_index, get_real_time()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::add_frame -// Access: Public -// Description: Slightly lower-level interface than new_frame that -// takes a set of frame data. -//////////////////////////////////////////////////////////////////// +/** + * Slightly lower-level interface than new_frame that takes a set of frame + * data. + */ void PStatClientImpl:: add_frame(int thread_index, const PStatFrameData &frame_data) { nassertv(thread_index >= 0 && thread_index < _client->_num_threads); PStatClient::InternalThread *pthread = _client->get_thread_ptr(thread_index); - // If we're the main thread, we should exchange control packets with - // the server. + // If we're the main thread, we should exchange control packets with the + // server. if (thread_index == 0) { transmit_control_data(); } - // If we've got the UDP port by the time the frame starts, it's - // time to become active and start actually tracking data. + // If we've got the UDP port by the time the frame starts, it's time to + // become active and start actually tracking data. if (_got_udp_port) { pthread->_is_active = true; } @@ -270,12 +256,10 @@ add_frame(int thread_index, const PStatFrameData &frame_data) { _client->stop(pstats_index, current_thread_index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::transmit_frame_data -// Access: Private -// Description: Should be called once per frame per thread to -// transmit the latest data to the PStatServer. -//////////////////////////////////////////////////////////////////// +/** + * Should be called once per frame per thread to transmit the latest data to + * the PStatServer. + */ void PStatClientImpl:: transmit_frame_data(int thread_index, int frame_number, const PStatFrameData &frame_data) { @@ -283,20 +267,20 @@ transmit_frame_data(int thread_index, int frame_number, PStatClient::InternalThread *thread = _client->get_thread_ptr(thread_index); if (_is_connected && thread->_is_active) { - // We don't want to send too many packets in a hurry and flood the - // server. Check that enough time has elapsed for us to send a - // new packet. If not, we'll drop this packet on the floor and - // send a new one next time around. + // We don't want to send too many packets in a hurry and flood the server. + // Check that enough time has elapsed for us to send a new packet. If + // not, we'll drop this packet on the floor and send a new one next time + // around. double now = get_real_time(); if (now >= thread->_next_packet) { - // We don't want to send more than _max_rate UDP-size packets - // per second, per thread. + // We don't want to send more than _max_rate UDP-size packets per + // second, per thread. double packet_delay = 1.0 / _max_rate; // Send new data. NetDatagram datagram; - // We always start with a zero byte, to differentiate it from a - // control message. + // We always start with a zero byte, to differentiate it from a control + // message. datagram.add_uint8(0); datagram.add_uint16(thread_index); @@ -305,8 +289,8 @@ transmit_frame_data(int thread_index, int frame_number, bool sent; if (!frame_data.write_datagram(datagram, _client)) { - // Too many events to fit in a single datagram. Maybe it was - // a long frame load or something. Just drop the datagram. + // Too many events to fit in a single datagram. Maybe it was a long + // frame load or something. Just drop the datagram. sent = false; } else if (_writer.is_valid_for_udp(datagram)) { @@ -336,8 +320,8 @@ transmit_frame_data(int thread_index, int frame_number, } else { sent = _writer.send(datagram, _tcp_connection); - // If our packets are so large that we must ship them via TCP, - // then artificially slow down the packet rate even further. + // If our packets are so large that we must ship them via TCP, then + // artificially slow down the packet rate even further. int packet_ratio = (datagram.get_length() + maximum_udp_datagram - 1) / maximum_udp_datagram; @@ -356,12 +340,10 @@ transmit_frame_data(int thread_index, int frame_number, } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::transmit_control_data -// Access: Private -// Description: Should be called once a frame to exchange control -// information with the server. -//////////////////////////////////////////////////////////////////// +/** + * Should be called once a frame to exchange control information with the + * server. + */ void PStatClientImpl:: transmit_control_data() { // Check for new messages from the server. @@ -387,11 +369,9 @@ transmit_control_data() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::get_hostname -// Access: Private -// Description: Returns the current machine's hostname. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current machine's hostname. + */ string PStatClientImpl:: get_hostname() { if (_hostname.empty()) { @@ -405,11 +385,9 @@ get_hostname() { return _hostname; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::send_hello -// Access: Private -// Description: Sends the initial greeting message to the server. -//////////////////////////////////////////////////////////////////// +/** + * Sends the initial greeting message to the server. + */ void PStatClientImpl:: send_hello() { nassertv(_is_connected); @@ -426,18 +404,15 @@ send_hello() { _writer.send(datagram, _tcp_connection, true); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::report_new_collectors -// Access: Private -// Description: Sends over any information about new Collectors that -// the user code might have recently created. -//////////////////////////////////////////////////////////////////// +/** + * Sends over any information about new Collectors that the user code might + * have recently created. + */ void PStatClientImpl:: report_new_collectors() { - // Empirically, we determined that you can't send more than about - // 1400 collectors at once without exceeding the 64K limit on a - // single datagram. So we limit ourselves here to sending only - // half that many. + // Empirically, we determined that you can't send more than about 1400 + // collectors at once without exceeding the 64K limit on a single datagram. + // So we limit ourselves here to sending only half that many. static const int max_collectors_at_once = 700; while (_is_connected && _collectors_reported < _client->_num_collectors) { @@ -457,12 +432,10 @@ report_new_collectors() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::report_new_threads -// Access: Private -// Description: Sends over any information about new Threads that -// the user code might have recently created. -//////////////////////////////////////////////////////////////////// +/** + * Sends over any information about new Threads that the user code might have + * recently created. + */ void PStatClientImpl:: report_new_threads() { while (_is_connected && _threads_reported < _client->_num_threads) { @@ -482,12 +455,10 @@ report_new_threads() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::handle_server_control_message -// Access: Private -// Description: Called when a control message has been received by -// the server over the TCP connection. -//////////////////////////////////////////////////////////////////// +/** + * Called when a control message has been received by the server over the TCP + * connection. + */ void PStatClientImpl:: handle_server_control_message(const PStatServerControlMessage &message) { switch (message._type) { @@ -506,12 +477,9 @@ handle_server_control_message(const PStatServerControlMessage &message) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientImpl::connection_reset -// Access: Private, Virtual -// Description: Called by the internal net code when the connection -// has been lost. -//////////////////////////////////////////////////////////////////// +/** + * Called by the internal net code when the connection has been lost. + */ void PStatClientImpl:: connection_reset(const PT(Connection) &connection, bool) { if (connection == _tcp_connection) { diff --git a/panda/src/pstatclient/pStatClientImpl.h b/panda/src/pstatclient/pStatClientImpl.h index 7f95584e09..88327defb5 100644 --- a/panda/src/pstatclient/pStatClientImpl.h +++ b/panda/src/pstatclient/pStatClientImpl.h @@ -1,16 +1,15 @@ -// Filename: pStatClientImpl.h -// Created by: drose (23Dec04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientImpl.h + * @author drose + * @date 2004-12-23 + */ #ifndef PSTATCLIENTIMPL_H #define PSTATCLIENTIMPL_H @@ -35,23 +34,18 @@ class PStatCollector; class PStatCollectorDef; class PStatThread; -//////////////////////////////////////////////////////////////////// -// Class : PStatClientImpl -// Description : This class is the implementation of the actual -// PStatClient class (which is just for interface). All -// of the stuff to manage sending stats up to the server -// is handled by this class. -// -// This separation between PStatClient and -// PStatClientImpl allows the global PStatClient to be -// constructed at static init time, without having to -// consult any config variables at that time. We don't -// actually do any real work until someone explicitly -// calls PStatClient::connect(). -// -// This class doesn't exist at all unless DO_PSTATS is -// defined. -//////////////////////////////////////////////////////////////////// +/** + * This class is the implementation of the actual PStatClient class (which is + * just for interface). All of the stuff to manage sending stats up to the + * server is handled by this class. + * + * This separation between PStatClient and PStatClientImpl allows the global + * PStatClient to be constructed at static init time, without having to + * consult any config variables at that time. We don't actually do any real + * work until someone explicitly calls PStatClient::connect(). + * + * This class doesn't exist at all unless DO_PSTATS is defined. + */ class EXPCL_PANDA_PSTATCLIENT PStatClientImpl : public ConnectionManager { public: PStatClientImpl(PStatClient *client); @@ -124,4 +118,3 @@ private: #endif // DO_PSTATS #endif - diff --git a/panda/src/pstatclient/pStatClientVersion.I b/panda/src/pstatclient/pStatClientVersion.I index f0fee1f9b7..f1ca70e64f 100644 --- a/panda/src/pstatclient/pStatClientVersion.I +++ b/panda/src/pstatclient/pStatClientVersion.I @@ -1,56 +1,45 @@ -// Filename: pStatClientVersion.I -// Created by: drose (21May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientVersion.I + * @author drose + * @date 2001-05-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatClientVersion::get_major_version -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PStatClientVersion:: get_major_version() const { return _major_version; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientVersion::get_minor_version -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int PStatClientVersion:: get_minor_version() const { return _minor_version; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientVersion::set_version -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PStatClientVersion:: set_version(int major_version, int minor_version) { _major_version = major_version; _minor_version = minor_version; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientVersion::is_at_least -// Access: Public -// Description: Returns true if the client version is at least the -// indicated major/minor version number, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the client version is at least the indicated major/minor + * version number, false otherwise. + */ INLINE bool PStatClientVersion:: is_at_least(int major_version, int minor_version) const { return (_major_version > major_version || diff --git a/panda/src/pstatclient/pStatClientVersion.cxx b/panda/src/pstatclient/pStatClientVersion.cxx index 1d1e4aee05..9a046a401c 100644 --- a/panda/src/pstatclient/pStatClientVersion.cxx +++ b/panda/src/pstatclient/pStatClientVersion.cxx @@ -1,26 +1,23 @@ -// Filename: pStatClientVersion.cxx -// Created by: drose (21May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientVersion.cxx + * @author drose + * @date 2001-05-21 + */ #include "pStatClientVersion.h" #include "pStatProperties.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatClientVersion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientVersion:: PStatClientVersion() { _major_version = get_current_pstat_major_version(); diff --git a/panda/src/pstatclient/pStatClientVersion.h b/panda/src/pstatclient/pStatClientVersion.h index e07c4fcd29..de2d1a71bd 100644 --- a/panda/src/pstatclient/pStatClientVersion.h +++ b/panda/src/pstatclient/pStatClientVersion.h @@ -1,16 +1,15 @@ -// Filename: pStatClientVersion.h -// Created by: drose (21May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientVersion.h + * @author drose + * @date 2001-05-21 + */ #ifndef PSTATCLIENTVERSION_H #define PSTATCLIENTVERSION_H @@ -20,12 +19,10 @@ #include "referenceCount.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PStatClientVersion -// Description : Records the version number of a particular client. -// Normally this will be the same as -// get_current_pstat_major/minor_version(). -//////////////////////////////////////////////////////////////////// +/** + * Records the version number of a particular client. Normally this will be + * the same as get_current_pstat_major/minor_version(). + */ class EXPCL_PANDA_PSTATCLIENT PStatClientVersion : public ReferenceCount { public: PStatClientVersion(); @@ -45,4 +42,3 @@ private: #include "pStatClientVersion.I" #endif - diff --git a/panda/src/pstatclient/pStatCollector.I b/panda/src/pstatclient/pStatCollector.I index b6fd3f027a..f103bbbae0 100644 --- a/panda/src/pstatclient/pStatCollector.I +++ b/panda/src/pstatclient/pStatCollector.I @@ -1,27 +1,22 @@ -// Filename: pStatCollector.I -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollector.I + * @author drose + * @date 2000-07-10 + */ #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Constructor -// Access: Private -// Description: Normally, this constructor is called only from -// PStatClient. Use one of the constructors below to -// create your own Collector. -//////////////////////////////////////////////////////////////////// +/** + * Normally, this constructor is called only from PStatClient. Use one of the + * constructors below to create your own Collector. + */ INLINE PStatCollector:: PStatCollector(PStatClient *client, int index) : _client(client), @@ -30,42 +25,34 @@ PStatCollector(PStatClient *client, int index) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Default Constructor -// Access: Public -// Description: Creates an invalid PStatCollector. Any attempt to -// use this collector will crash messily. -// -// You can reassign it to a different, valid one later. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid PStatCollector. Any attempt to use this collector will + * crash messily. + * + * You can reassign it to a different, valid one later. + */ INLINE PStatCollector:: -PStatCollector() : +PStatCollector() : _client(NULL), _index(0), _level(0.0f) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Constructor -// Access: Published -// Description: Creates a new PStatCollector, ready to start -// accumulating data. The name of the collector -// uniquely identifies it among the other collectors; if -// two collectors share the same name then they are -// really the same collector. -// -// The name may also be a compound name, something like -// "Cull:Sort", which indicates that this is a collector -// named "Sort", a child of the collector named "Cull". -// The parent may also be named explicitly by reference -// in the other flavor of the constructor; see further -// comments on this for that constructor. -// -// If the client pointer is non-null, it specifies a -// particular client to register the collector with; -// otherwise, the global client is used. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new PStatCollector, ready to start accumulating data. The name + * of the collector uniquely identifies it among the other collectors; if two + * collectors share the same name then they are really the same collector. + * + * The name may also be a compound name, something like "Cull:Sort", which + * indicates that this is a collector named "Sort", a child of the collector + * named "Cull". The parent may also be named explicitly by reference in the + * other flavor of the constructor; see further comments on this for that + * constructor. + * + * If the client pointer is non-null, it specifies a particular client to + * register the collector with; otherwise, the global client is used. + */ INLINE PStatCollector:: PStatCollector(const string &name, PStatClient *client) : _level(0.0f) @@ -76,29 +63,22 @@ PStatCollector(const string &name, PStatClient *client) : (*this) = client->make_collector_with_relname(0, name); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Constructor -// Access: Published -// Description: Creates a new PStatCollector, ready to start -// accumulating data. The name of the collector -// uniquely identifies it among the other collectors; if -// two collectors share the same name then they are -// really the same collector. -// -// The parent is the collector that conceptually -// includes all of the time measured for this collector. -// For instance, a particular character's animation time -// is owned by the "Animation" collector, which is in -// turn owned by the "Frame" collector. It is not -// strictly necessary that all of the time spent in a -// particular collector is completely nested within time -// spent in its parent's collector. If parent is the -// empty string, the collector is owned by "Frame". -// -// This constructor does not take a client pointer; it -// always creates the new collector on the same client -// as its parent. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new PStatCollector, ready to start accumulating data. The name + * of the collector uniquely identifies it among the other collectors; if two + * collectors share the same name then they are really the same collector. + * + * The parent is the collector that conceptually includes all of the time + * measured for this collector. For instance, a particular character's + * animation time is owned by the "Animation" collector, which is in turn + * owned by the "Frame" collector. It is not strictly necessary that all of + * the time spent in a particular collector is completely nested within time + * spent in its parent's collector. If parent is the empty string, the + * collector is owned by "Frame". + * + * This constructor does not take a client pointer; it always creates the new + * collector on the same client as its parent. + */ INLINE PStatCollector:: PStatCollector(const PStatCollector &parent, const string &name) : _level(0.0f) @@ -108,11 +88,9 @@ PStatCollector(const PStatCollector &parent, const string &name) : parent._client->make_collector_with_relname(parent._index, name); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatCollector:: PStatCollector(const PStatCollector ©) : _client(copy._client), @@ -121,37 +99,29 @@ PStatCollector(const PStatCollector ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PStatCollector:: operator = (const PStatCollector ©) { _client = copy._client; _index = copy._index; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::is_valid -// Access: Published -// Description: Returns true if collector is valid and may be used, -// or false if it was constructed with the default -// constructor (in which case any attempt to use it will -// crash). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if collector is valid and may be used, or false if it was + * constructed with the default constructor (in which case any attempt to use + * it will crash). + */ INLINE bool PStatCollector:: is_valid() const { return (_client != (PStatClient *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_name -// Access: Published -// Description: Returns the local name of this collector. This is -// the rightmost part of the fullname, after the -// rightmost colon. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local name of this collector. This is the rightmost part of + * the fullname, after the rightmost colon. + */ INLINE string PStatCollector:: get_name() const { if (_client != (PStatClient *)NULL) { @@ -160,13 +130,10 @@ get_name() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_fullname -// Access: Published -// Description: Returns the full name of this collector. This -// includes the names of all the collector's parents, -// concatenated together with colons. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full name of this collector. This includes the names of all + * the collector's parents, concatenated together with colons. + */ INLINE string PStatCollector:: get_fullname() const { if (_client != (PStatClient *)NULL) { @@ -175,23 +142,18 @@ get_fullname() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PStatCollector:: output(ostream &out) const { out << "PStatCollector(\"" << get_fullname() << "\")"; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::is_active -// Access: Published -// Description: Returns true if this particular collector is active -// on the default thread, and we are currently -// transmitting PStats data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular collector is active on the default thread, + * and we are currently transmitting PStats data. + */ INLINE bool PStatCollector:: is_active() { #ifndef HAVE_THREADS @@ -201,12 +163,10 @@ is_active() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::is_started -// Access: Published -// Description: Returns true if this particular collector has been -// started on the default thread, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular collector has been started on the default + * thread, or false otherwise. + */ INLINE bool PStatCollector:: is_started() { #ifndef HAVE_THREADS @@ -216,12 +176,10 @@ is_started() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::start -// Access: Published -// Description: Starts this particular timer ticking. This should be -// called before the code you want to measure. -//////////////////////////////////////////////////////////////////// +/** + * Starts this particular timer ticking. This should be called before the + * code you want to measure. + */ INLINE void PStatCollector:: start() { #ifndef HAVE_THREADS @@ -231,12 +189,10 @@ start() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::stop -// Access: Published -// Description: Stops this timer. This should be called after the -// code you want to measure. -//////////////////////////////////////////////////////////////////// +/** + * Stops this timer. This should be called after the code you want to + * measure. + */ INLINE void PStatCollector:: stop() { #ifndef HAVE_THREADS @@ -246,97 +202,77 @@ stop() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::clear_level -// Access: Published -// Description: Removes the level setting associated with this -// collector for the main thread. The collector -// will no longer show up on any level graphs in the -// main thread. This implicitly calls flush_level(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the level setting associated with this collector for the main + * thread. The collector will no longer show up on any level graphs in the + * main thread. This implicitly calls flush_level(). + */ INLINE void PStatCollector:: clear_level() { _client->clear_level(_index, 0); _level = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::set_level -// Access: Published -// Description: Sets the level setting associated with this -// collector for the main thread to the indicated -// value. This implicitly calls flush_level(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the level setting associated with this collector for the main thread + * to the indicated value. This implicitly calls flush_level(). + */ INLINE void PStatCollector:: set_level(double level) { _client->set_level(_index, 0, level); _level = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::add_level -// Access: Published -// Description: Adds the indicated increment (which may be negative) -// to the level setting associated with this collector -// for the main thread. If the collector did not -// already have a level setting for the main thread, it -// is initialized to 0. -// -// As an optimization, the data is not immediately set -// to the PStatClient. It will be sent the next time -// flush_level() is called. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated increment (which may be negative) to the level setting + * associated with this collector for the main thread. If the collector did + * not already have a level setting for the main thread, it is initialized to + * 0. + * + * As an optimization, the data is not immediately set to the PStatClient. It + * will be sent the next time flush_level() is called. + */ INLINE void PStatCollector:: add_level(double increment) { _level += increment; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::sub_level -// Access: Published -// Description: Subtracts the indicated decrement (which may be -// negative) to the level setting associated with this -// collector for the main thread. If the collector did -// not already have a level setting for the main thread, -// it is initialized to 0. -// -// As an optimization, the data is not immediately set -// to the PStatClient. It will be sent the next time -// flush_level() is called. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts the indicated decrement (which may be negative) to the level + * setting associated with this collector for the main thread. If the + * collector did not already have a level setting for the main thread, it is + * initialized to 0. + * + * As an optimization, the data is not immediately set to the PStatClient. It + * will be sent the next time flush_level() is called. + */ INLINE void PStatCollector:: sub_level(double decrement) { _level -= decrement; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::add_level_now -// Access: Published -// Description: Calls add_level() and immediately calls flush_level(). -//////////////////////////////////////////////////////////////////// +/** + * Calls add_level() and immediately calls flush_level(). + */ INLINE void PStatCollector:: add_level_now(double increment) { add_level(increment); flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::sub_level_now -// Access: Published -// Description: Calls sub_level() and immediately calls flush_level(). -//////////////////////////////////////////////////////////////////// +/** + * Calls sub_level() and immediately calls flush_level(). + */ INLINE void PStatCollector:: sub_level_now(double decrement) { sub_level(decrement); flush_level(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::flush_level -// Access: Published -// Description: Updates the PStatClient with the recent results from -// add_level() and sub_level(). -//////////////////////////////////////////////////////////////////// +/** + * Updates the PStatClient with the recent results from add_level() and + * sub_level(). + */ INLINE void PStatCollector:: flush_level() { if (_level != 0.0f) { @@ -345,27 +281,21 @@ flush_level() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_level -// Access: Published -// Description: Returns the current level value of the given -// collector in the main thread. This implicitly calls -// flush_level(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current level value of the given collector in the main thread. + * This implicitly calls flush_level(). + */ INLINE double PStatCollector:: get_level() { flush_level(); return _client->get_level(_index, 0); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::clear_thread_level -// Access: Published -// Description: Removes the level setting associated with this -// collector for the current thread. The collector -// will no longer show up on any level graphs in the -// current thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes the level setting associated with this collector for the current + * thread. The collector will no longer show up on any level graphs in the + * current thread. + */ INLINE void PStatCollector:: clear_thread_level() { #ifndef HAVE_THREADS @@ -375,13 +305,10 @@ clear_thread_level() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::set_thread_level -// Access: Published -// Description: Sets the level setting associated with this -// collector for the current thread to the indicated -// value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the level setting associated with this collector for the current + * thread to the indicated value. + */ INLINE void PStatCollector:: set_thread_level(double level) { #ifndef HAVE_THREADS @@ -391,15 +318,12 @@ set_thread_level(double level) { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::add_thread_level -// Access: Published -// Description: Adds the indicated increment (which may be negative) -// to the level setting associated with this collector -// for the current thread. If the collector did not -// already have a level setting for the current thread, -// it is initialized to 0. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated increment (which may be negative) to the level setting + * associated with this collector for the current thread. If the collector + * did not already have a level setting for the current thread, it is + * initialized to 0. + */ INLINE void PStatCollector:: add_thread_level(double increment) { #ifndef HAVE_THREADS @@ -409,15 +333,12 @@ add_thread_level(double increment) { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::sub_thread_level -// Access: Published -// Description: Subtracts the indicated decrement (which may be -// negative) to the level setting associated with this -// collector for the current thread. If the collector -// did not already have a level setting for the current -// thread, it is initialized to 0. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts the indicated decrement (which may be negative) to the level + * setting associated with this collector for the current thread. If the + * collector did not already have a level setting for the current thread, it + * is initialized to 0. + */ INLINE void PStatCollector:: sub_thread_level(double decrement) { #ifndef HAVE_THREADS @@ -427,12 +348,10 @@ sub_thread_level(double decrement) { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_thread_level -// Access: Published -// Description: Returns the current level value of the given -// collector in the current thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current level value of the given collector in the current + * thread. + */ INLINE double PStatCollector:: get_thread_level() { #ifndef HAVE_THREADS @@ -442,147 +361,116 @@ get_thread_level() { #endif // HAVE_THREADS } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::is_active -// Access: Published -// Description: Returns true if this particular collector is active -// on the indicated thread, and we are currently -// transmitting PStats data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular collector is active on the indicated + * thread, and we are currently transmitting PStats data. + */ INLINE bool PStatCollector:: is_active(const PStatThread &thread) { return _client->is_active(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::is_started -// Access: Published -// Description: Returns true if this particular collector has been -// started on the indicated thread, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular collector has been started on the indicated + * thread, or false otherwise. + */ INLINE bool PStatCollector:: is_started(const PStatThread &thread) { return _client->is_started(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::start -// Access: Published -// Description: Starts this timer ticking within a particular thread. -//////////////////////////////////////////////////////////////////// +/** + * Starts this timer ticking within a particular thread. + */ INLINE void PStatCollector:: start(const PStatThread &thread) { nassertv(_client != NULL); _client->start(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::start -// Access: Published -// Description: Marks that the timer should have been started as of -// the indicated time. This must be a time based on the -// PStatClient's clock (see PStatClient::get_clock()), -// and care should be taken that all such calls exhibit -// a monotonically increasing series of time values. -//////////////////////////////////////////////////////////////////// +/** + * Marks that the timer should have been started as of the indicated time. + * This must be a time based on the PStatClient's clock (see + * PStatClient::get_clock()), and care should be taken that all such calls + * exhibit a monotonically increasing series of time values. + */ INLINE void PStatCollector:: start(const PStatThread &thread, double as_of) { _client->start(_index, thread._index, as_of); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::stop -// Access: Published -// Description: Stops this timer within a particular thread. -//////////////////////////////////////////////////////////////////// +/** + * Stops this timer within a particular thread. + */ INLINE void PStatCollector:: stop(const PStatThread &thread) { _client->stop(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::stop -// Access: Published -// Description: Marks that the timer should have been stopped as of -// the indicated time. This must be a time based on the -// PStatClient's clock (see PStatClient::get_clock()), -// and care should be taken that all such calls exhibit -// a monotonically increasing series of time values. -//////////////////////////////////////////////////////////////////// +/** + * Marks that the timer should have been stopped as of the indicated time. + * This must be a time based on the PStatClient's clock (see + * PStatClient::get_clock()), and care should be taken that all such calls + * exhibit a monotonically increasing series of time values. + */ INLINE void PStatCollector:: stop(const PStatThread &thread, double as_of) { _client->stop(_index, thread._index, as_of); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::clear_level -// Access: Published -// Description: Removes the level setting associated with this -// collector for the indicated thread. The collector -// will no longer show up on any level graphs in this -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Removes the level setting associated with this collector for the indicated + * thread. The collector will no longer show up on any level graphs in this + * thread. + */ INLINE void PStatCollector:: clear_level(const PStatThread &thread) { _client->clear_level(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::set_level -// Access: Published -// Description: Sets the level setting associated with this -// collector for the indicated thread to the indicated -// value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the level setting associated with this collector for the indicated + * thread to the indicated value. + */ INLINE void PStatCollector:: set_level(const PStatThread &thread, double level) { _client->set_level(_index, thread._index, level); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::add_level -// Access: Published -// Description: Adds the indicated increment (which may be negative) -// to the level setting associated with this collector -// for the indicated thread. If the collector did not -// already have a level setting for this thread, it is -// initialized to 0. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated increment (which may be negative) to the level setting + * associated with this collector for the indicated thread. If the collector + * did not already have a level setting for this thread, it is initialized to + * 0. + */ INLINE void PStatCollector:: add_level(const PStatThread &thread, double increment) { _client->add_level(_index, thread._index, increment); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::sub_level -// Access: Published -// Description: Subtracts the indicated decrement (which may be -// negative) to the level setting associated with this -// collector for the indicated thread. If the collector -// did not already have a level setting for this thread, -// it is initialized to 0. -//////////////////////////////////////////////////////////////////// +/** + * Subtracts the indicated decrement (which may be negative) to the level + * setting associated with this collector for the indicated thread. If the + * collector did not already have a level setting for this thread, it is + * initialized to 0. + */ INLINE void PStatCollector:: sub_level(const PStatThread &thread, double decrement) { _client->add_level(_index, thread._index, -decrement); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_level -// Access: Published -// Description: Returns the current level value of the given collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current level value of the given collector. + */ INLINE double PStatCollector:: get_level(const PStatThread &thread) { return _client->get_level(_index, thread._index); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::get_index -// Access: Published -// Description: Returns the index number of this particular collector -// within the PStatClient. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of this particular collector within the + * PStatClient. + */ INLINE int PStatCollector:: get_index() const { return _index; @@ -590,30 +478,25 @@ get_index() const { #else // DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Default Constructor -// Access: Public -// Description: Creates an invalid PStatCollector. Any attempt to -// use this collector will crash messily. -// -// You can reassign it to a different, valid one later. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid PStatCollector. Any attempt to use this collector will + * crash messily. + * + * You can reassign it to a different, valid one later. + */ INLINE PStatCollector:: PStatCollector() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Constructor -// Access: Published -// Description: This bogus version of the function is only defined if -// DO_PSTATS is not defined, meaning all these functions -// should compile to nothing. -//////////////////////////////////////////////////////////////////// +/** + * This bogus version of the function is only defined if DO_PSTATS is not + * defined, meaning all these functions should compile to nothing. + */ INLINE PStatCollector:: PStatCollector(const string &, PStatClient *client) { - // We need this bogus comparison just to prevent the SGI compiler - // from dumping core. It's perfectly meaningless. + // We need this bogus comparison just to prevent the SGI compiler from + // dumping core. It's perfectly meaningless. #ifdef mips if (client == (PStatClient *)NULL) { return; @@ -621,17 +504,14 @@ PStatCollector(const string &, PStatClient *client) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollector::Constructor -// Access: Published -// Description: This bogus version of the function is only defined if -// DO_PSTATS is not defined, meaning all these functions -// should compile to nothing. -//////////////////////////////////////////////////////////////////// +/** + * This bogus version of the function is only defined if DO_PSTATS is not + * defined, meaning all these functions should compile to nothing. + */ INLINE PStatCollector:: PStatCollector(const PStatCollector &parent, const string &) { - // We need this bogus comparison just to prevent the SGI compiler - // from dumping core. It's perfectly meaningless. + // We need this bogus comparison just to prevent the SGI compiler from + // dumping core. It's perfectly meaningless. #ifdef mips if (&parent == (const PStatCollector *)NULL) { return; diff --git a/panda/src/pstatclient/pStatCollector.cxx b/panda/src/pstatclient/pStatCollector.cxx index a5e4ad5653..2f00188fbe 100644 --- a/panda/src/pstatclient/pStatCollector.cxx +++ b/panda/src/pstatclient/pStatCollector.cxx @@ -1,15 +1,14 @@ -// Filename: pStatCollector.cxx -// Created by: drose (18Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollector.cxx + * @author drose + * @date 2011-11-18 + */ #include "pStatCollector.h" diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index cad5e29246..4bcd92d55a 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -1,16 +1,15 @@ -// Filename: pStatCollector.h -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollector.h + * @author drose + * @date 2000-07-10 + */ #ifndef PSTATCOLLECTOR_H #define PSTATCOLLECTOR_H @@ -22,30 +21,25 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : PStatCollector -// Description : A lightweight class that represents a single element -// that may be timed and/or counted via stats. -// -// Collectors can be used to measure two different kinds -// of values: elapsed time, and "other". -// -// To measure elapsed time, call start() and stop() as -// appropriate to bracket the section of code you want -// to time (or use a PStatTimer to do this -// automatically). -// -// To measure anything else, call set_level() and/or -// add_level() to set the "level" value associated with -// this collector. The meaning of the value set for the -// "level" is entirely up to the user; it may represent -// the number of triangles rendered or the kilobytes of -// texture memory consumed, for instance. The level set -// will remain fixed across multiple frames until it is -// reset via another set_level() or adjusted via a call -// to add_level(). It may also be completely removed -// via clear_level(). -//////////////////////////////////////////////////////////////////// +/** + * A lightweight class that represents a single element that may be timed + * and/or counted via stats. + * + * Collectors can be used to measure two different kinds of values: elapsed + * time, and "other". + * + * To measure elapsed time, call start() and stop() as appropriate to bracket + * the section of code you want to time (or use a PStatTimer to do this + * automatically). + * + * To measure anything else, call set_level() and/or add_level() to set the + * "level" value associated with this collector. The meaning of the value set + * for the "level" is entirely up to the user; it may represent the number of + * triangles rendered or the kilobytes of texture memory consumed, for + * instance. The level set will remain fixed across multiple frames until it + * is reset via another set_level() or adjusted via a call to add_level(). It + * may also be completely removed via clear_level(). + */ class EXPCL_PANDA_PSTATCLIENT PStatCollector { #ifdef DO_PSTATS @@ -162,4 +156,3 @@ inline ostream &operator << (ostream &out, const PStatCollector &pcol) { } #endif - diff --git a/panda/src/pstatclient/pStatCollectorDef.cxx b/panda/src/pstatclient/pStatCollectorDef.cxx index fe7ee87a4c..13070343e0 100644 --- a/panda/src/pstatclient/pStatCollectorDef.cxx +++ b/panda/src/pstatclient/pStatCollectorDef.cxx @@ -1,16 +1,15 @@ -// Filename: pStatCollectorDef.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorDef.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatCollectorDef.h" @@ -18,11 +17,9 @@ #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorDef::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatCollectorDef:: PStatCollectorDef() { _index = 0; @@ -37,11 +34,9 @@ PStatCollectorDef() { _active_explicitly_set = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatCollectorDef:: PStatCollectorDef(int index, const string &name) : _index(index), @@ -58,14 +53,11 @@ PStatCollectorDef(int index, const string &name) : _active_explicitly_set = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorDef::set_parent -// Access: Public -// Description: This is normally called only by the PStatClient when -// the new PStatCollectorDef is created; it sets the -// parent of the CollectorDef and inherits whatever -// properties are appropriate. -//////////////////////////////////////////////////////////////////// +/** + * This is normally called only by the PStatClient when the new + * PStatCollectorDef is created; it sets the parent of the CollectorDef and + * inherits whatever properties are appropriate. + */ void PStatCollectorDef:: set_parent(const PStatCollectorDef &parent) { _parent_index = parent._index; @@ -76,12 +68,9 @@ set_parent(const PStatCollectorDef &parent) { _active_explicitly_set = parent._active_explicitly_set; } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorDef::write_datagram -// Access: Public -// Description: Writes the definition of the collectorDef to the -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition of the collectorDef to the datagram. + */ void PStatCollectorDef:: write_datagram(Datagram &destination) const { destination.add_int16(_index); @@ -96,11 +85,9 @@ write_datagram(Datagram &destination) const { destination.add_float32(_factor); } -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorDef::read_datagram -// Access: Public -// Description: Extracts the collectorDef definition from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the collectorDef definition from the datagram. + */ void PStatCollectorDef:: read_datagram(DatagramIterator &source, PStatClientVersion *) { _index = source.get_int16(); diff --git a/panda/src/pstatclient/pStatCollectorDef.h b/panda/src/pstatclient/pStatCollectorDef.h index d084db503f..79996677f2 100644 --- a/panda/src/pstatclient/pStatCollectorDef.h +++ b/panda/src/pstatclient/pStatCollectorDef.h @@ -1,16 +1,15 @@ -// Filename: pStatCollectorDef.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorDef.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATCOLLECTORDEF_H #define PSTATCOLLECTORDEF_H @@ -23,11 +22,10 @@ class DatagramIterator; class PStatClient; class PStatClientVersion; -//////////////////////////////////////////////////////////////////// -// Class : PStatCollectorDef -// Description : Defines the details about the Collectors: the name, -// the suggested color, etc. -//////////////////////////////////////////////////////////////////// +/** + * Defines the details about the Collectors: the name, the suggested color, + * etc. + */ class EXPCL_PANDA_PSTATCLIENT PStatCollectorDef { public: PStatCollectorDef(); @@ -54,4 +52,3 @@ public: }; #endif - diff --git a/panda/src/pstatclient/pStatCollectorForward.I b/panda/src/pstatclient/pStatCollectorForward.I index 33af725c9d..0ab9b71a89 100644 --- a/panda/src/pstatclient/pStatCollectorForward.I +++ b/panda/src/pstatclient/pStatCollectorForward.I @@ -1,23 +1,19 @@ -// Filename: pStatCollectorForward.I -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorForward.I + * @author drose + * @date 2006-10-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorForward::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatCollectorForward:: PStatCollectorForward(const PStatCollector &col) #ifdef DO_PSTATS @@ -25,4 +21,3 @@ PStatCollectorForward(const PStatCollector &col) #endif // DO_PSTATS { } - diff --git a/panda/src/pstatclient/pStatCollectorForward.cxx b/panda/src/pstatclient/pStatCollectorForward.cxx index e596bcc713..d4cf4e6e96 100644 --- a/panda/src/pstatclient/pStatCollectorForward.cxx +++ b/panda/src/pstatclient/pStatCollectorForward.cxx @@ -1,28 +1,24 @@ -// Filename: pStatCollectorForward.cxx -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorForward.cxx + * @author drose + * @date 2006-10-30 + */ #include "pStatCollectorForward.h" #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatCollectorForward::add_level -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PStatCollectorForward:: add_level(double increment) { _col.add_level_now(increment); } #endif // DO_PSTATS - diff --git a/panda/src/pstatclient/pStatCollectorForward.h b/panda/src/pstatclient/pStatCollectorForward.h index 57c96b55a7..e2e7fad744 100644 --- a/panda/src/pstatclient/pStatCollectorForward.h +++ b/panda/src/pstatclient/pStatCollectorForward.h @@ -1,16 +1,15 @@ -// Filename: pStatCollectorForward.h -// Created by: drose (30Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatCollectorForward.h + * @author drose + * @date 2006-10-30 + */ #ifndef PSTATCOLLECTORFORWARD_H #define PSTATCOLLECTORFORWARD_H @@ -19,13 +18,11 @@ #include "pStatCollectorForwardBase.h" #include "pStatCollector.h" -//////////////////////////////////////////////////////////////////// -// Class : PStatCollectorForward -// Description : This class serves as a cheap forward reference to a -// PStatCollector, so that classes that are defined -// before the pstats module may access the -// PStatCollector. -//////////////////////////////////////////////////////////////////// +/** + * This class serves as a cheap forward reference to a PStatCollector, so that + * classes that are defined before the pstats module may access the + * PStatCollector. + */ class EXPCL_PANDA_PSTATCLIENT PStatCollectorForward : public PStatCollectorForwardBase { PUBLISHED: INLINE PStatCollectorForward(const PStatCollector &col); diff --git a/panda/src/pstatclient/pStatFrameData.I b/panda/src/pstatclient/pStatFrameData.I index 9e680c6ff0..47f9a99243 100644 --- a/panda/src/pstatclient/pStatFrameData.I +++ b/panda/src/pstatclient/pStatFrameData.I @@ -1,81 +1,64 @@ -// Filename: pStatFrameData.I -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatFrameData.I + * @author drose + * @date 2000-07-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::is_time_empty -// Access: Public -// Description: Returns true if there are no time events in the frame -// data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no time events in the frame data, false + * otherwise. + */ INLINE bool PStatFrameData:: is_time_empty() const { return _time_data.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::is_level_empty -// Access: Public -// Description: Returns true if there are no levels indicated in the -// frame data, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no levels indicated in the frame data, false + * otherwise. + */ INLINE bool PStatFrameData:: is_level_empty() const { return _level_data.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::is_empty -// Access: Public -// Description: Returns true if the FrameData has no time or level -// data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the FrameData has no time or level data. + */ INLINE bool PStatFrameData:: is_empty() const { return is_time_empty() && is_level_empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::clear -// Access: Public -// Description: Removes all the data points from the frame data, in -// preparation for building up a new frame's worth. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the data points from the frame data, in preparation for + * building up a new frame's worth. + */ INLINE void PStatFrameData:: clear() { _time_data.clear(); _level_data.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::swap -// Access: Public -// Description: Exchanges the data in this object with the data in -// the other. -//////////////////////////////////////////////////////////////////// +/** + * Exchanges the data in this object with the data in the other. + */ INLINE void PStatFrameData:: swap(PStatFrameData &other) { _time_data.swap(other._time_data); _level_data.swap(other._level_data); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::add_start -// Access: Public -// Description: Adds a 'start collector' data point to the frame -// data. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 'start collector' data point to the frame data. + */ INLINE void PStatFrameData:: add_start(int index, double time) { #ifdef _DEBUG @@ -87,12 +70,9 @@ add_start(int index, double time) { _time_data.push_back(dp); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::add_stop -// Access: Public -// Description: Adds a 'stop collector' data point to the frame -// data. -//////////////////////////////////////////////////////////////////// +/** + * Adds a 'stop collector' data point to the frame data. + */ INLINE void PStatFrameData:: add_stop(int index, double time) { #ifdef _DEBUG @@ -104,12 +84,10 @@ add_stop(int index, double time) { _time_data.push_back(dp); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::add_level -// Access: Public -// Description: Adds a particular level value associated with a given -// collector to the frame data. -//////////////////////////////////////////////////////////////////// +/** + * Adds a particular level value associated with a given collector to the + * frame data. + */ INLINE void PStatFrameData:: add_level(int index, double level) { #ifdef _DEBUG @@ -121,13 +99,10 @@ add_level(int index, double level) { _level_data.push_back(dp); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_start -// Access: Public -// Description: Returns the time of the first data point in the frame -// data. This will generally be the time of the start -// of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time of the first data point in the frame data. This will + * generally be the time of the start of the frame. + */ INLINE double PStatFrameData:: get_start() const { if (is_empty()) { @@ -137,13 +112,10 @@ get_start() const { return _time_data.front()._value; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_end -// Access: Public -// Description: Returns the time of the last data point in the frame -// data. This will generally be the time of the end -// of the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time of the last data point in the frame data. This will + * generally be the time of the end of the frame. + */ INLINE double PStatFrameData:: get_end() const { nassertr(!is_empty(), 0.0); @@ -151,11 +123,9 @@ get_end() const { return _time_data.back()._value; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_net_time -// Access: Public -// Description: Returns the total time elapsed for the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total time elapsed for the frame. + */ INLINE double PStatFrameData:: get_net_time() const { nassertr(!is_empty(), 0.0); @@ -163,94 +133,73 @@ get_net_time() const { return _time_data.back()._value - _time_data.front()._value; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_num_events -// Access: Public -// Description: Returns the number of individual events stored in the -// FrameData. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual events stored in the FrameData. + */ INLINE size_t PStatFrameData:: get_num_events() const { return _time_data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_time_collector -// Access: Public -// Description: Returns the index of the collector associated with -// the nth event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the collector associated with the nth event. + */ INLINE int PStatFrameData:: get_time_collector(size_t n) const { nassertr(n < _time_data.size(), 0); return _time_data[n]._index & 0x7fff; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::is_start -// Access: Public -// Description: Returns true if the nth event represents a start -// event, or false if it represents a stop event. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth event represents a start event, or false if it + * represents a stop event. + */ INLINE bool PStatFrameData:: is_start(size_t n) const { nassertr(n < _time_data.size(), 0); return (_time_data[n]._index & 0x8000) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_time -// Access: Public -// Description: Returns the timestamp of the nth event, in seconds -// elapsed since some undefined epoch (which is -// guaranteed to be shared among all events returned -// from a given client). -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp of the nth event, in seconds elapsed since some + * undefined epoch (which is guaranteed to be shared among all events returned + * from a given client). + */ INLINE double PStatFrameData:: get_time(size_t n) const { nassertr(n < _time_data.size(), 0); return _time_data[n]._value; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_num_levels -// Access: Public -// Description: Returns the number of individual level values stored -// in the FrameData. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual level values stored in the FrameData. + */ INLINE size_t PStatFrameData:: get_num_levels() const { return _level_data.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_level_collector -// Access: Public -// Description: Returns the index of the collector associated with -// the nth level value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the collector associated with the nth level value. + */ INLINE int PStatFrameData:: get_level_collector(size_t n) const { nassertr(n < _level_data.size(), 0); return _level_data[n]._index; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::get_level -// Access: Public -// Description: Returns the height of the nth level value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the nth level value. + */ INLINE double PStatFrameData:: get_level(size_t n) const { nassertr(n < _level_data.size(), 0); return _level_data[n]._value; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::DataPoint::operator < -// Access: Public -// Description: Orders the data points by time. -//////////////////////////////////////////////////////////////////// +/** + * Orders the data points by time. + */ INLINE bool PStatFrameData::DataPoint:: operator < (const PStatFrameData::DataPoint &other) const { return _value < other._value; diff --git a/panda/src/pstatclient/pStatFrameData.cxx b/panda/src/pstatclient/pStatFrameData.cxx index 2a5b1cb445..835b30f1df 100644 --- a/panda/src/pstatclient/pStatFrameData.cxx +++ b/panda/src/pstatclient/pStatFrameData.cxx @@ -1,16 +1,15 @@ -// Filename: pStatFrameData.cxx -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatFrameData.cxx + * @author drose + * @date 2000-07-10 + */ #include "pStatFrameData.h" #include "pStatClientVersion.h" @@ -21,23 +20,18 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::sort_time -// Access: Public -// Description: Ensures the frame data is in monotonically increasing -// order by time. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the frame data is in monotonically increasing order by time. + */ void PStatFrameData:: sort_time() { stable_sort(_time_data.begin(), _time_data.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::write_datagram -// Access: Public -// Description: Writes the definition of the FrameData to the -// datagram. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes the definition of the FrameData to the datagram. Returns true on + * success, false on failure. + */ bool PStatFrameData:: write_datagram(Datagram &destination, PStatClient *client) const { Data::const_iterator di; @@ -59,15 +53,13 @@ write_datagram(Datagram &destination, PStatClient *client) const { destination.add_uint16((*di)._index); destination.add_float32((*di)._value); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: PStatFrameData::read_datagram -// Access: Public -// Description: Extracts the FrameData definition from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the FrameData definition from the datagram. + */ void PStatFrameData:: read_datagram(DatagramIterator &source, PStatClientVersion *) { clear(); @@ -91,4 +83,3 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) { } nassertv(source.get_remaining_size() == 0); } - diff --git a/panda/src/pstatclient/pStatFrameData.h b/panda/src/pstatclient/pStatFrameData.h index 12a698354b..45d69cfb7d 100644 --- a/panda/src/pstatclient/pStatFrameData.h +++ b/panda/src/pstatclient/pStatFrameData.h @@ -1,16 +1,15 @@ -// Filename: pStatFrameData.h -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatFrameData.h + * @author drose + * @date 2000-07-10 + */ #ifndef PSTATFRAMEDATA_H #define PSTATFRAMEDATA_H @@ -26,13 +25,11 @@ class DatagramIterator; class PStatClientVersion; class PStatClient; -//////////////////////////////////////////////////////////////////// -// Class : PStatFrameData -// Description : Contains the raw timing and level data for a single -// frame. This is a sequence of start/stop events, as -// well as a table of level values, associated with a -// number of collectors within a single frame. -//////////////////////////////////////////////////////////////////// +/** + * Contains the raw timing and level data for a single frame. This is a + * sequence of start/stop events, as well as a table of level values, + * associated with a number of collectors within a single frame. + */ class EXPCL_PANDA_PSTATCLIENT PStatFrameData { public: INLINE bool is_time_empty() const; @@ -79,4 +76,3 @@ private: #include "pStatFrameData.I" #endif - diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 27356576f9..ca8c7c8ead 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -1,16 +1,15 @@ -// Filename: pStatProperties.cxx -// Created by: drose (17May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatProperties.cxx + * @author drose + * @date 2001-05-17 + */ #include "pStatProperties.h" #include "pStatCollectorDef.h" @@ -26,35 +25,31 @@ static const int current_pstat_major_version = 3; static const int current_pstat_minor_version = 0; -// Initialized at 2.0 on 5/18/01, when version numbers were first added. -// Incremented to 2.1 on 5/21/01 to add support for TCP frame data. -// Incremented to 3.0 on 4/28/05 to bump TCP headers to 32 bits. +// Initialized at 2.0 on 51801, when version numbers were first added. +// Incremented to 2.1 on 52101 to add support for TCP frame data. Incremented +// to 3.0 on 42805 to bump TCP headers to 32 bits. -//////////////////////////////////////////////////////////////////// -// Function: get_current_pstat_major_version -// Description: Returns the current major version number of the -// PStats protocol. This is the version number that -// will be reported by clients running this code, and -// that will be expected by servers running this code. -// -// The major version numbers must match exactly in order -// for a communication to be successful. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current major version number of the PStats protocol. This is + * the version number that will be reported by clients running this code, and + * that will be expected by servers running this code. + * + * The major version numbers must match exactly in order for a communication + * to be successful. + */ int get_current_pstat_major_version() { return current_pstat_major_version; } -//////////////////////////////////////////////////////////////////// -// Function: get_current_pstat_minor_version -// Description: Returns the current minor version number of the -// PStats protocol. This is the version number that -// will be reported by clients running this code, and -// that will be expected by servers running this code. -// -// The minor version numbers need not match exactly, but -// the server must be >= the client. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current minor version number of the PStats protocol. This is + * the version number that will be reported by clients running this code, and + * that will be expected by servers running this code. + * + * The minor version numbers need not match exactly, but the server must be >= + * the client. + */ int get_current_pstat_minor_version() { return current_pstat_minor_version; @@ -63,27 +58,20 @@ get_current_pstat_minor_version() { #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// -// The rest of this file defines the predefined properties (color, -// sort, etc.) for the various PStatCollectors that may be defined -// within Panda or even elsewhere. -// -// It is a little strange to defined these properties here instead of -// where the collectors are actually declared, but it's handy to have -// them all in one place, so we can easily see which colors are -// available, etc. It also makes the declarations a lot simpler, -// since there are quite a few esoteric parameters to specify. -// -// We could define these in some external data file that is read in at -// runtime, so that you could extend this list without having to -// relink panda, but then there are the usual problems with ensuring -// that the file is available to you at runtime. The heck with it. -// -// At least, no other file depends on this file, so it may be modified -// without forcing anything else to be recompiled. -// -//////////////////////////////////////////////////////////////////// +/* + * The rest of this file defines the predefined properties (color, sort, etc.) + * for the various PStatCollectors that may be defined within Panda or even + * elsewhere. It is a little strange to defined these properties here instead + * of where the collectors are actually declared, but it's handy to have them + * all in one place, so we can easily see which colors are available, etc. It + * also makes the declarations a lot simpler, since there are quite a few + * esoteric parameters to specify. We could define these in some external + * data file that is read in at runtime, so that you could extend this list + * without having to relink panda, but then there are the usual problems with + * ensuring that the file is available to you at runtime. The heck with it. + * At least, no other file depends on this file, so it may be modified without + * forcing anything else to be recompiled. + */ typedef PStatCollectorDef::ColorDef ColorDef; @@ -234,12 +222,10 @@ static LevelCollectorProperties level_properties[] = { }; -//////////////////////////////////////////////////////////////////// -// Function: initialize_collector_def_from_table -// Description: Looks up the collector in the compiled-in table -// defined above, and sets its properties appropriately -// if it is found. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the collector in the compiled-in table defined above, and sets its + * properties appropriately if it is found. + */ static void initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *def) { int i; @@ -286,14 +272,12 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d } -//////////////////////////////////////////////////////////////////// -// Function: initialize_collector_def -// Description: This is the only accessor function into this table. -// The PStatCollectorDef constructor calls it when a new -// PStatCollectorDef is created. It should look up in -// the table and find a matching definition for this def -// by name; if one is found, the properties are applied. -//////////////////////////////////////////////////////////////////// +/** + * This is the only accessor function into this table. The PStatCollectorDef + * constructor calls it when a new PStatCollectorDef is created. It should + * look up in the table and find a matching definition for this def by name; + * if one is found, the properties are applied. + */ void initialize_collector_def(const PStatClient *client, PStatCollectorDef *def) { string fullname; @@ -307,10 +291,10 @@ initialize_collector_def(const PStatClient *client, PStatCollectorDef *def) { // First, check the compiled-in defaults. initialize_collector_def_from_table(fullname, def); - // Then, look to Config for more advice. To do this, we first - // change the name to something more like a Config variable name. - // We replace colons and spaces with hyphens, eliminate other - // punctuation, and make all letters lowercase. + // Then, look to Config for more advice. To do this, we first change the + // name to something more like a Config variable name. We replace colons + // and spaces with hyphens, eliminate other punctuation, and make all + // letters lowercase. string config_name; string::const_iterator ni; diff --git a/panda/src/pstatclient/pStatProperties.h b/panda/src/pstatclient/pStatProperties.h index 307b04624d..bdd92bfb1a 100644 --- a/panda/src/pstatclient/pStatProperties.h +++ b/panda/src/pstatclient/pStatProperties.h @@ -1,16 +1,15 @@ -// Filename: pStatProperties.h -// Created by: drose (17May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatProperties.h + * @author drose + * @date 2001-05-17 + */ #ifndef PSTATPROPERTIES_H #define PSTATPROPERTIES_H @@ -29,4 +28,3 @@ void initialize_collector_def(const PStatClient *client, PStatCollectorDef *def) #endif // DO_PSTATS #endif - diff --git a/panda/src/pstatclient/pStatServerControlMessage.cxx b/panda/src/pstatclient/pStatServerControlMessage.cxx index a713eceab4..f5003ba18c 100644 --- a/panda/src/pstatclient/pStatServerControlMessage.cxx +++ b/panda/src/pstatclient/pStatServerControlMessage.cxx @@ -1,16 +1,15 @@ -// Filename: pStatServerControlMessage.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatServerControlMessage.cxx + * @author drose + * @date 2000-07-09 + */ #include "config_pstats.h" #include "pStatServerControlMessage.h" @@ -18,21 +17,17 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatServerControlMessage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatServerControlMessage:: PStatServerControlMessage() { _type = T_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServerControlMessage::encode -// Access: Public -// Description: Writes the message into the indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the message into the indicated datagram. + */ void PStatServerControlMessage:: encode(Datagram &datagram) const { datagram.clear(); @@ -50,12 +45,10 @@ encode(Datagram &datagram) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatServerControlMessage::decode -// Access: Public -// Description: Extracts the message from the indicated datagram. -// Returns true on success, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the message from the indicated datagram. Returns true on success, + * false on error. + */ bool PStatServerControlMessage:: decode(const Datagram &datagram) { DatagramIterator source(datagram); diff --git a/panda/src/pstatclient/pStatServerControlMessage.h b/panda/src/pstatclient/pStatServerControlMessage.h index 35fd3d19c6..332a850530 100644 --- a/panda/src/pstatclient/pStatServerControlMessage.h +++ b/panda/src/pstatclient/pStatServerControlMessage.h @@ -1,16 +1,15 @@ -// Filename: pStatServerControlMessage.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatServerControlMessage.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATSERVERCONTROLMESSAGE_H #define PSTATSERVERCONTROLMESSAGE_H @@ -21,12 +20,10 @@ class Datagram; -//////////////////////////////////////////////////////////////////// -// Class : PStatServerControlMessage -// Description : This kind of message is sent from the server to the -// client on the TCP socket to establish critical -// control information. -//////////////////////////////////////////////////////////////////// +/** + * This kind of message is sent from the server to the client on the TCP + * socket to establish critical control information. + */ class EXPCL_PANDA_PSTATCLIENT PStatServerControlMessage { public: PStatServerControlMessage(); @@ -49,4 +46,3 @@ public: #endif - diff --git a/panda/src/pstatclient/pStatThread.I b/panda/src/pstatclient/pStatThread.I index bf9d673eb9..fcfa992576 100644 --- a/panda/src/pstatclient/pStatThread.I +++ b/panda/src/pstatclient/pStatThread.I @@ -1,36 +1,28 @@ -// Filename: pStatThread.I -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThread.I + * @author drose + * @date 2000-07-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::Default Constructor -// Access: Private -// Description: Normally, this constructor is called only from -// PStatClient. Use one of the constructors below to -// create your own Thread. -//////////////////////////////////////////////////////////////////// +/** + * Normally, this constructor is called only from PStatClient. Use one of the + * constructors below to create your own Thread. + */ INLINE PStatThread:: PStatThread() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::Constructor -// Access: Published -// Description: Normally, this constructor is called only from -// PStatClient. Use one of the constructors below to -// create your own Thread. -//////////////////////////////////////////////////////////////////// +/** + * Normally, this constructor is called only from PStatClient. Use one of the + * constructors below to create your own Thread. + */ INLINE PStatThread:: PStatThread(PStatClient *client, int index) : _client(client), @@ -38,13 +30,10 @@ PStatThread(PStatClient *client, int index) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::Constructor -// Access: Public -// Description: Creates a new named thread. This will be used to -// unify tasks that share a common thread, and -// differentiate tasks that occur in different threads. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new named thread. This will be used to unify tasks that share a + * common thread, and differentiate tasks that occur in different threads. + */ INLINE PStatThread:: PStatThread(Thread *thread, PStatClient *client) { #ifdef DO_PSTATS @@ -57,8 +46,8 @@ PStatThread(Thread *thread, PStatClient *client) { (*this) = PStatThread(client, thread_index); } else { - // This is the first time we have encountered this current Thread. - // Make a new PStatThread object for it. + // This is the first time we have encountered this current Thread. Make a + // new PStatThread object for it. (*this) = client->make_thread(thread); } #else @@ -67,11 +56,9 @@ PStatThread(Thread *thread, PStatClient *client) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatThread:: PStatThread(const PStatThread ©) : _client(copy._client), @@ -79,29 +66,23 @@ PStatThread(const PStatThread ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PStatThread:: operator = (const PStatThread ©) { _client = copy._client; _index = copy._index; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::new_frame -// Access: Public -// Description: This must be called at the start of every "frame", -// whatever a frame may be deemed to be, to accumulate -// all the stats that have collected so far for the -// thread and ship them off to the server. -// -// Calling PStatClient::thread_tick() will automatically -// call this for any threads with the indicated sync -// name. -//////////////////////////////////////////////////////////////////// +/** + * This must be called at the start of every "frame", whatever a frame may be + * deemed to be, to accumulate all the stats that have collected so far for + * the thread and ship them off to the server. + * + * Calling PStatClient::thread_tick() will automatically call this for any + * threads with the indicated sync name. + */ INLINE void PStatThread:: new_frame() { #ifdef DO_PSTATS @@ -109,12 +90,10 @@ new_frame() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::add_frame -// Access: Public -// Description: This is a slightly lower-level version of new_frame -// that also specifies the data to send for this frame. -//////////////////////////////////////////////////////////////////// +/** + * This is a slightly lower-level version of new_frame that also specifies the + * data to send for this frame. + */ INLINE void PStatThread:: add_frame(const PStatFrameData &frame_data) { #ifdef DO_PSTATS @@ -122,12 +101,9 @@ add_frame(const PStatFrameData &frame_data) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::get_index -// Access: Published -// Description: Returns the index number of this particular thread -// within the PStatClient. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of this particular thread within the PStatClient. + */ INLINE int PStatThread:: get_index() const { return _index; diff --git a/panda/src/pstatclient/pStatThread.cxx b/panda/src/pstatclient/pStatThread.cxx index efeeb1c6ad..533fd10789 100644 --- a/panda/src/pstatclient/pStatThread.cxx +++ b/panda/src/pstatclient/pStatThread.cxx @@ -1,26 +1,23 @@ -// Filename: pStatThread.cxx -// Created by: drose (30Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThread.cxx + * @author drose + * @date 2006-01-30 + */ #include "pStatThread.h" #include "pStatClient.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatThread::get_thread -// Access: Published -// Description: Returns the Panda Thread object associated with this -// particular PStatThread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda Thread object associated with this particular + * PStatThread. + */ Thread *PStatThread:: get_thread() const { #ifdef DO_PSTATS diff --git a/panda/src/pstatclient/pStatThread.h b/panda/src/pstatclient/pStatThread.h index db1f4c1bda..23ba20af8e 100644 --- a/panda/src/pstatclient/pStatThread.h +++ b/panda/src/pstatclient/pStatThread.h @@ -1,16 +1,15 @@ -// Filename: pStatThread.h -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThread.h + * @author drose + * @date 2000-07-11 + */ #ifndef PSTATTHREAD_H #define PSTATTHREAD_H @@ -22,12 +21,10 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : PStatThread -// Description : A lightweight class that represents a single thread -// of execution to PStats. It corresponds one-to-one -// with Panda's Thread instance. -//////////////////////////////////////////////////////////////////// +/** + * A lightweight class that represents a single thread of execution to PStats. + * It corresponds one-to-one with Panda's Thread instance. + */ class EXPCL_PANDA_PSTATCLIENT PStatThread { public: INLINE PStatThread(); @@ -59,4 +56,3 @@ friend class PStatCollector; #include "pStatThread.I" #endif - diff --git a/panda/src/pstatclient/pStatTimer.I b/panda/src/pstatclient/pStatTimer.I index b3a39d26dd..03b25b5b6f 100644 --- a/panda/src/pstatclient/pStatTimer.I +++ b/panda/src/pstatclient/pStatTimer.I @@ -1,25 +1,21 @@ -// Filename: pStatTimer.I -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatTimer.I + * @author drose + * @date 2000-07-11 + */ #ifdef DO_PSTATS -//////////////////////////////////////////////////////////////////// -// Function: PStatTimer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatTimer:: PStatTimer(PStatCollector &collector) : _collector(collector), @@ -28,11 +24,9 @@ PStatTimer(PStatCollector &collector) : _collector.start(_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PStatTimer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatTimer:: PStatTimer(PStatCollector &collector, Thread *current_thread) : _collector(collector), @@ -41,11 +35,9 @@ PStatTimer(PStatCollector &collector, Thread *current_thread) : _collector.start(_thread); } -//////////////////////////////////////////////////////////////////// -// Function: PStatTimer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PStatTimer:: ~PStatTimer() { _collector.stop(_thread); diff --git a/panda/src/pstatclient/pStatTimer.h b/panda/src/pstatclient/pStatTimer.h index 640838ecb6..b7a32f27e2 100644 --- a/panda/src/pstatclient/pStatTimer.h +++ b/panda/src/pstatclient/pStatTimer.h @@ -1,16 +1,15 @@ -// Filename: pStatTimer.h -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatTimer.h + * @author drose + * @date 2000-07-11 + */ #ifndef PSTATTIMER_H #define PSTATTIMER_H @@ -21,16 +20,13 @@ class Thread; -//////////////////////////////////////////////////////////////////// -// Class : PStatTimer -// Description : A lightweight class that can be used to automatically -// start and stop a PStatCollector around a section of -// code. It's intended to be used in the following way: -// create a local PStatTimer variable to start the -// Collector, and when the PStatTimer variable goes out -// of scope (for instance, at the end of the function), -// it will automatically stop the Collector. -//////////////////////////////////////////////////////////////////// +/** + * A lightweight class that can be used to automatically start and stop a + * PStatCollector around a section of code. It's intended to be used in the + * following way: create a local PStatTimer variable to start the Collector, + * and when the PStatTimer variable goes out of scope (for instance, at the + * end of the function), it will automatically stop the Collector. + */ class EXPCL_PANDA_PSTATCLIENT PStatTimer { public: #ifdef DO_PSTATS @@ -53,4 +49,3 @@ protected: #include "pStatTimer.I" #endif - diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index 4b8acc9372..11f6f392fe 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -1,16 +1,15 @@ -// Filename: test_client.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_client.cxx + * @author drose + * @date 2000-07-09 + */ #include "config_pstats.h" #include "pStatClient.h" @@ -154,7 +153,7 @@ main(int argc, char *argv[]) { // Make up some random intervals to "wait". for (i = 0; i < (int)_collectors.size(); i++) { if (ds[i].is_level) { - // Make up an amount to add/delete to the level this frame. + // Make up an amount to adddelete to the level this frame. double increment = ds[i].max_ms * (rand() / (RAND_MAX + 1.0) - 0.5); _collectors[i].add_level(increment); @@ -180,8 +179,8 @@ main(int argc, char *argv[]) { } } - // Put the wait requests in order, to allow for the jitter, and - // invoke them. + // Put the wait requests in order, to allow for the jitter, and invoke + // them. static const double delay = 1.0; _collectors[0].stop(client->get_main_thread(), start + delay); @@ -199,8 +198,7 @@ main(int argc, char *argv[]) { _collectors[0].start(client->get_main_thread(), now + total_ms / 1000 + delay); - // Now actually wait some approximation of the time we said we - // did. + // Now actually wait some approximation of the time we said we did. Thread::sleep(total_ms / 1000.0 + delay); } diff --git a/panda/src/putil/animInterface.I b/panda/src/putil/animInterface.I index 6576a4b830..c25e748cbb 100644 --- a/panda/src/putil/animInterface.I +++ b/panda/src/putil/animInterface.I @@ -1,42 +1,32 @@ -// Filename: animInterface.I -// Created by: drose (20Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animInterface.I + * @author drose + * @date 2005-09-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::play -// Access: Published -// Description: Runs the entire animation from beginning to end and -// stops. -//////////////////////////////////////////////////////////////////// +/** + * Runs the entire animation from beginning to end and stops. + */ INLINE void AnimInterface:: play() { play(0, get_num_frames() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::play -// Access: Published -// Description: Runs the animation from the frame "from" to and -// including the frame "to", at which point the -// animation is stopped. Both "from" and "to" frame -// numbers may be outside the range (0, -// get_num_frames()) and the animation will follow the -// range correctly, reporting numbers modulo -// get_num_frames(). For instance, play(0, -// get_num_frames() * 2) will play the animation twice -// and then stop. -//////////////////////////////////////////////////////////////////// +/** + * Runs the animation from the frame "from" to and including the frame "to", + * at which point the animation is stopped. Both "from" and "to" frame + * numbers may be outside the range (0, get_num_frames()) and the animation + * will follow the range correctly, reporting numbers modulo get_num_frames(). + * For instance, play(0, get_num_frames() * 2) will play the animation twice + * and then stop. + */ INLINE void AnimInterface:: play(double from, double to) { { @@ -46,27 +36,21 @@ play(double from, double to) { animation_activated(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::loop -// Access: Published -// Description: Starts the entire animation looping. If restart is -// true, the animation is restarted from the beginning; -// otherwise, it continues from the current frame. -//////////////////////////////////////////////////////////////////// +/** + * Starts the entire animation looping. If restart is true, the animation is + * restarted from the beginning; otherwise, it continues from the current + * frame. + */ INLINE void AnimInterface:: loop(bool restart) { loop(restart, 0, get_num_frames() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::loop -// Access: Published -// Description: Loops the animation from the frame "from" to and -// including the frame "to", indefinitely. If restart -// is true, the animation is restarted from the -// beginning; otherwise, it continues from the current -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Loops the animation from the frame "from" to and including the frame "to", + * indefinitely. If restart is true, the animation is restarted from the + * beginning; otherwise, it continues from the current frame. + */ INLINE void AnimInterface:: loop(bool restart, double from, double to) { { @@ -76,27 +60,20 @@ loop(bool restart, double from, double to) { animation_activated(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::pingpong -// Access: Published -// Description: Starts the entire animation bouncing back and forth -// between its first frame and last frame. If restart -// is true, the animation is restarted from the -// beginning; otherwise, it continues from the current -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Starts the entire animation bouncing back and forth between its first frame + * and last frame. If restart is true, the animation is restarted from the + * beginning; otherwise, it continues from the current frame. + */ INLINE void AnimInterface:: pingpong(bool restart) { pingpong(restart, 0, get_num_frames() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::pingpong -// Access: Published -// Description: Loops the animation from the frame "from" to and -// including the frame "to", and then back in the -// opposite direction, indefinitely. -//////////////////////////////////////////////////////////////////// +/** + * Loops the animation from the frame "from" to and including the frame "to", + * and then back in the opposite direction, indefinitely. + */ INLINE void AnimInterface:: pingpong(bool restart, double from, double to) { { @@ -106,28 +83,22 @@ pingpong(bool restart, double from, double to) { animation_activated(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::stop -// Access: Published -// Description: Stops a currently playing or looping animation right -// where it is. The animation remains posed at the -// current frame. -//////////////////////////////////////////////////////////////////// +/** + * Stops a currently playing or looping animation right where it is. The + * animation remains posed at the current frame. + */ INLINE void AnimInterface:: stop() { CDWriter cdata(_cycler); cdata->pose(cdata->get_full_fframe()); - // Don't call animation_activated() here; stopping an animation - // should not activate it. + // Don't call animation_activated() here; stopping an animation should not + // activate it. } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::pose -// Access: Published -// Description: Sets the animation to the indicated frame and holds -// it there. -//////////////////////////////////////////////////////////////////// +/** + * Sets the animation to the indicated frame and holds it there. + */ INLINE void AnimInterface:: pose(double frame) { { @@ -137,55 +108,42 @@ pose(double frame) { animation_activated(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::set_play_rate -// Access: Published -// Description: Changes the rate at which the animation plays. 1.0 -// is the normal speed, 2.0 is twice normal speed, and -// 0.5 is half normal speed. 0.0 is legal to pause the -// animation, and a negative value will play the -// animation backwards. -//////////////////////////////////////////////////////////////////// +/** + * Changes the rate at which the animation plays. 1.0 is the normal speed, + * 2.0 is twice normal speed, and 0.5 is half normal speed. 0.0 is legal to + * pause the animation, and a negative value will play the animation + * backwards. + */ INLINE void AnimInterface:: set_play_rate(double play_rate) { CDWriter cdata(_cycler); cdata->internal_set_rate(cdata->_frame_rate, play_rate); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_play_rate -// Access: Published -// Description: Returns the rate at which the animation plays. See -// set_play_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the rate at which the animation plays. See set_play_rate(). + */ INLINE double AnimInterface:: get_play_rate() const { CDReader cdata(_cycler); return cdata->_play_rate; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_frame_rate -// Access: Published -// Description: Returns the native frame rate of the animation. This -// is the number of frames per second that will elapse -// when the play_rate is set to 1.0. It is a fixed -// property of the animation and may not be adjusted by -// the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns the native frame rate of the animation. This is the number of + * frames per second that will elapse when the play_rate is set to 1.0. It is + * a fixed property of the animation and may not be adjusted by the user. + */ INLINE double AnimInterface:: get_frame_rate() const { CDReader cdata(_cycler); return cdata->_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_frame -// Access: Published -// Description: Returns the current integer frame number. -// This number will be in the range 0 <= f < -// get_num_frames(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current integer frame number. This number will be in the range + * 0 <= f < get_num_frames(). + */ INLINE int AnimInterface:: get_frame() const { int num_frames = get_num_frames(); @@ -196,18 +154,14 @@ get_frame() const { return cmod(cdata->get_full_frame(0), num_frames); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_next_frame -// Access: Published -// Description: Returns the current integer frame number + 1, -// constrained to the range 0 <= f < get_num_frames(). -// -// If the play mode is PM_play, this will clamp to the -// same value as get_frame() at the end of the -// animation. If the play mode is any other value, this -// will wrap around to frame 0 at the end of the -// animation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current integer frame number + 1, constrained to the range 0 <= + * f < get_num_frames(). + * + * If the play mode is PM_play, this will clamp to the same value as + * get_frame() at the end of the animation. If the play mode is any other + * value, this will wrap around to frame 0 at the end of the animation. + */ INLINE int AnimInterface:: get_next_frame() const { int num_frames = get_num_frames(); @@ -218,117 +172,95 @@ get_next_frame() const { return cmod(cdata->get_full_frame(1), num_frames); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_frac -// Access: Published -// Description: Returns the fractional part of the current frame. -// Normally, this is in the range 0.0 <= f < 1.0, but in -// the one special case of an animation playing to its -// end frame and stopping, it might exactly equal 1.0. -// -// It will always be true that get_full_frame() + -// get_frac() == get_full_fframe(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the fractional part of the current frame. Normally, this is in the + * range 0.0 <= f < 1.0, but in the one special case of an animation playing + * to its end frame and stopping, it might exactly equal 1.0. + * + * It will always be true that get_full_frame() + get_frac() == + * get_full_fframe(). + */ INLINE double AnimInterface:: get_frac() const { CDReader cdata(_cycler); return cdata->get_frac(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_full_frame -// Access: Published -// Description: Returns the current integer frame number. -// -// Unlike the value returned by get_frame(), this frame -// number may extend beyond the range of -// get_num_frames() if the frame range passed to play(), -// loop(), etc. did. -// -// Unlike the value returned by get_full_fframe(), this -// return value will never exceed the value passed to -// to_frame in the play() method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current integer frame number. + * + * Unlike the value returned by get_frame(), this frame number may extend + * beyond the range of get_num_frames() if the frame range passed to play(), + * loop(), etc. did. + * + * Unlike the value returned by get_full_fframe(), this return value will + * never exceed the value passed to to_frame in the play() method. + */ INLINE int AnimInterface:: get_full_frame() const { CDReader cdata(_cycler); return cdata->get_full_frame(0); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_full_fframe -// Access: Published -// Description: Returns the current floating-point frame number. -// -// Unlike the value returned by get_frame(), this frame -// number may extend beyond the range of -// get_num_frames() if the frame range passed to play(), -// loop(), etc. did. -// -// Unlike the value returned by get_full_frame(), this -// return value may equal (to_frame + 1.0), when the -// animation has played to its natural end. However, in -// this case the return value of get_full_frame() will -// be to_frame, not (to_frame + 1). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current floating-point frame number. + * + * Unlike the value returned by get_frame(), this frame number may extend + * beyond the range of get_num_frames() if the frame range passed to play(), + * loop(), etc. did. + * + * Unlike the value returned by get_full_frame(), this return value may equal + * (to_frame + 1.0), when the animation has played to its natural end. + * However, in this case the return value of get_full_frame() will be + * to_frame, not (to_frame + 1). + */ INLINE double AnimInterface:: get_full_fframe() const { CDReader cdata(_cycler); return cdata->get_full_fframe(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::is_playing -// Access: Published -// Description: Returns true if the animation is currently playing, -// false if it is stopped (e.g. because stop() or pose() -// was called, or because it reached the end of the -// animation after play() was called). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the animation is currently playing, false if it is stopped + * (e.g. because stop() or pose() was called, or because it reached the end + * of the animation after play() was called). + */ INLINE bool AnimInterface:: is_playing() const { CDReader cdata(_cycler); return cdata->is_playing(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::set_frame_rate -// Access: Protected -// Description: Should be called by a derived class to specify the -// native frame rate of the animation. It is legal to -// call this after the animation has already started. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to specify the native frame rate of the + * animation. It is legal to call this after the animation has already + * started. + */ INLINE void AnimInterface:: set_frame_rate(double frame_rate) { CDWriter cdata(_cycler); cdata->internal_set_rate(frame_rate, cdata->_play_rate); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::set_num_frames -// Access: Protected -// Description: Should be called by a derived class to specify the -// number of frames of the animation. It is legal to -// call this after the animation has already started, -// but doing so may suddenly change the apparent current -// frame number. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by a derived class to specify the number of frames of the + * animation. It is legal to call this after the animation has already + * started, but doing so may suddenly change the apparent current frame + * number. + */ INLINE void AnimInterface:: set_num_frames(int num_frames) { _num_frames = num_frames; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::get_frac -// Access: Published -// Description: Returns the fractional part of the current frame. -// Normally, this is in the range 0.0 <= f < 1.0, but in -// the one special case of an animation playing to its -// end frame and stopping, it might exactly equal 1.0. -// -// It will always be true that get_full_frame() + -// get_frac() == get_full_fframe(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the fractional part of the current frame. Normally, this is in the + * range 0.0 <= f < 1.0, but in the one special case of an animation playing + * to its end frame and stopping, it might exactly equal 1.0. + * + * It will always be true that get_full_frame() + get_frac() == + * get_full_fframe(). + */ INLINE double AnimInterface::CData:: get_frac() const { return get_full_fframe() - (double)get_full_frame(0); diff --git a/panda/src/putil/animInterface.cxx b/panda/src/putil/animInterface.cxx index 515c54027a..1fd73dc6f0 100644 --- a/panda/src/putil/animInterface.cxx +++ b/panda/src/putil/animInterface.cxx @@ -1,16 +1,15 @@ -// Filename: animInterface.cxx -// Created by: drose (20Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animInterface.cxx + * @author drose + * @date 2005-09-20 + */ #include "animInterface.h" #include "clockObject.h" @@ -21,22 +20,18 @@ TypeHandle AnimInterface::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimInterface:: AnimInterface() : _num_frames(0) { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimInterface:: AnimInterface(const AnimInterface ©) : _num_frames(copy._num_frames), @@ -44,82 +39,64 @@ AnimInterface(const AnimInterface ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimInterface:: ~AnimInterface() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::get_num_frames -// Access: Published, Virtual -// Description: Returns the number of frames in the animation. This -// is a property of the animation and may not be -// directly adjusted by the user (although it may change -// without warning with certain kinds of animations, -// since this is a virtual method that may be -// overridden). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames in the animation. This is a property of the + * animation and may not be directly adjusted by the user (although it may + * change without warning with certain kinds of animations, since this is a + * virtual method that may be overridden). + */ int AnimInterface:: get_num_frames() const { return _num_frames; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimInterface:: output(ostream &out) const { CDReader cdata(_cycler); cdata->output(out); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::animation_activated -// Access: Protected, Virtual -// Description: This is provided as a callback method for when the -// user calls one of the play/loop/pose type methods to -// start the animation playing. -//////////////////////////////////////////////////////////////////// +/** + * This is provided as a callback method for when the user calls one of the + * play/loop/pose type methods to start the animation playing. + */ void AnimInterface:: animation_activated() { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AnimInterface:: write_datagram(BamWriter *manager, Datagram &dg) { dg.add_int32(_num_frames); manager->write_cdata(dg, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AnimInterface. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AnimInterface. + */ void AnimInterface:: fillin(DatagramIterator &scan, BamReader *manager) { _num_frames = scan.get_int32(); manager->read_cdata(scan, _cycler); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimInterface::CData:: CData() : _frame_rate(0.0), @@ -136,11 +113,9 @@ CData() : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AnimInterface::CData:: CData(const AnimInterface::CData ©) : _frame_rate(copy._frame_rate), @@ -157,22 +132,18 @@ CData(const AnimInterface::CData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *AnimInterface::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void AnimInterface::CData:: write_datagram(BamWriter *, Datagram &dg) const { dg.add_stdfloat(_frame_rate); @@ -187,13 +158,10 @@ write_datagram(BamWriter *, Datagram &dg) const { dg.add_stdfloat(_paused_f); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::fillin -// Access: Public, Virtual -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new AnimInterface. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new AnimInterface. + */ void AnimInterface::CData:: fillin(DatagramIterator &scan, BamReader *) { _frame_rate = scan.get_stdfloat(); @@ -209,19 +177,14 @@ fillin(DatagramIterator &scan, BamReader *) { _paused_f = scan.get_stdfloat(); } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::play -// Access: Public -// Description: Runs the animation from the frame "from" to and -// including the frame "to", at which point the -// animation is stopped. Both "from" and "to" frame -// numbers may be outside the range (0, -// get_num_frames()) and the animation will follow the -// range correctly, reporting numbers modulo -// get_num_frames(). For instance, play(0, -// get_num_frames() * 2) will play the animation twice -// and then stop. -//////////////////////////////////////////////////////////////////// +/** + * Runs the animation from the frame "from" to and including the frame "to", + * at which point the animation is stopped. Both "from" and "to" frame + * numbers may be outside the range (0, get_num_frames()) and the animation + * will follow the range correctly, reporting numbers modulo get_num_frames(). + * For instance, play(0, get_num_frames() * 2) will play the animation twice + * and then stop. + */ void AnimInterface::CData:: play(double from, double to) { if (from >= to) { @@ -243,15 +206,11 @@ play(double from, double to) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::loop -// Access: Public -// Description: Loops the animation from the frame "from" to and -// including the frame "to", indefinitely. If restart -// is true, the animation is restarted from the -// beginning; otherwise, it continues from the current -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Loops the animation from the frame "from" to and including the frame "to", + * indefinitely. If restart is true, the animation is restarted from the + * beginning; otherwise, it continues from the current frame. + */ void AnimInterface::CData:: loop(bool restart, double from, double to) { if (from >= to) { @@ -279,13 +238,10 @@ loop(bool restart, double from, double to) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::pingpong -// Access: Public -// Description: Loops the animation from the frame "from" to and -// including the frame "to", and then back in the -// opposite direction, indefinitely. -//////////////////////////////////////////////////////////////////// +/** + * Loops the animation from the frame "from" to and including the frame "to", + * and then back in the opposite direction, indefinitely. + */ void AnimInterface::CData:: pingpong(bool restart, double from, double to) { if (from >= to) { @@ -313,12 +269,9 @@ pingpong(bool restart, double from, double to) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::pose -// Access: Public -// Description: Sets the animation to the indicated frame and holds -// it there. -//////////////////////////////////////////////////////////////////// +/** + * Sets the animation to the indicated frame and holds it there. + */ void AnimInterface::CData:: pose(double frame) { _play_mode = PM_pose; @@ -330,48 +283,39 @@ pose(double frame) { _paused_f = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::get_full_frame -// Access: Public -// Description: Returns the current integer frame number, plus the -// indicated increment. -// -// Unlike the value returned by get_frame(), this frame -// number may extend beyond the range of -// get_num_frames() if the frame range passed to play(), -// loop(), etc. did. -// -// Unlike the value returned by get_full_fframe(), this -// return value will never exceed the value passed to -// to_frame in the play() method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current integer frame number, plus the indicated increment. + * + * Unlike the value returned by get_frame(), this frame number may extend + * beyond the range of get_num_frames() if the frame range passed to play(), + * loop(), etc. did. + * + * Unlike the value returned by get_full_fframe(), this return value will + * never exceed the value passed to to_frame in the play() method. + */ int AnimInterface::CData:: get_full_frame(int increment) const { int frame = (int)floor(get_full_fframe()) + increment; if (_play_mode == PM_play) { - // In play mode, we never let the return value exceed - // (_from_frame, _to_frame). + // In play mode, we never let the return value exceed (_from_frame, + // _to_frame). frame = min(max(frame, _from_frame), _to_frame); } return frame; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::get_full_fframe -// Access: Public -// Description: Returns the current floating-point frame number. -// -// Unlike the value returned by get_frame(), this frame -// number may extend beyond the range of -// get_num_frames() if the frame range passed to play(), -// loop(), etc. did. -// -// Unlike the value returned by get_full_frame(), this -// return value may equal (to_frame + 1.0), when the -// animation has played to its natural end. However, in -// this case the return value of get_full_frame() will -// be to_frame, not (to_frame + 1). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current floating-point frame number. + * + * Unlike the value returned by get_frame(), this frame number may extend + * beyond the range of get_num_frames() if the frame range passed to play(), + * loop(), etc. did. + * + * Unlike the value returned by get_full_frame(), this return value may equal + * (to_frame + 1.0), when the animation has played to its natural end. + * However, in this case the return value of get_full_frame() will be + * to_frame, not (to_frame + 1). + */ double AnimInterface::CData:: get_full_fframe() const { switch (_play_mode) { @@ -400,14 +344,11 @@ get_full_fframe() const { return _start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::is_playing -// Access: Public -// Description: Returns true if the animation is currently playing, -// false if it is stopped (e.g. because stop() or pose() -// was called, or because it reached the end of the -// animation after play() was called). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the animation is currently playing, false if it is stopped + * (e.g. because stop() or pose() was called, or because it reached the end + * of the animation after play() was called). + */ bool AnimInterface::CData:: is_playing() const { switch (_play_mode) { @@ -425,11 +366,9 @@ is_playing() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void AnimInterface::CData:: output(ostream &out) const { switch (_play_mode) { @@ -451,17 +390,15 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::internal_set_rate -// Access: Public -// Description: Called internally to adjust either or both of the -// frame_rate or play_rate without changing the current -// frame number if the animation is already playing. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to adjust either or both of the frame_rate or play_rate + * without changing the current frame number if the animation is already + * playing. + */ void AnimInterface::CData:: internal_set_rate(double frame_rate, double play_rate) { double f = get_f(); - + _frame_rate = frame_rate; _play_rate = play_rate; _effective_frame_rate = frame_rate * play_rate; @@ -471,8 +408,8 @@ internal_set_rate(double frame_rate, double play_rate) { _paused = true; } else { - // Compute a new _start_time that will keep f the same value with - // the new play_rate. + // Compute a new _start_time that will keep f the same value with the new + // play_rate. double new_elapsed = f / _effective_frame_rate; double now = ClockObject::get_global_clock()->get_frame_time(); _start_time = now - new_elapsed; @@ -480,12 +417,10 @@ internal_set_rate(double frame_rate, double play_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: AnimInterface::CData::get_f -// Access: Public -// Description: Returns the current floating-point frame number, -// elapsed since _start_frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current floating-point frame number, elapsed since + * _start_frame. + */ double AnimInterface::CData:: get_f() const { if (_paused) { diff --git a/panda/src/putil/animInterface.h b/panda/src/putil/animInterface.h index 8c0e40665d..1c3b0ec6e5 100644 --- a/panda/src/putil/animInterface.h +++ b/panda/src/putil/animInterface.h @@ -1,16 +1,15 @@ -// Filename: animInterface.h -// Created by: drose (20Sep05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animInterface.h + * @author drose + * @date 2005-09-20 + */ #ifndef ANIMINTERFACE_H #define ANIMINTERFACE_H @@ -28,14 +27,11 @@ class BamReader; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : AnimInterface -// Description : This is the fundamental interface for things that -// have a play/loop/stop type interface for frame-based -// animation, such as animated characters. This is the -// base class for AnimControl and other, similar -// classes. -//////////////////////////////////////////////////////////////////// +/** + * This is the fundamental interface for things that have a play/loop/stop + * type interface for frame-based animation, such as animated characters. + * This is the base class for AnimControl and other, similar classes. + */ class EXPCL_PANDA_PUTIL AnimInterface { protected: AnimInterface(); @@ -91,9 +87,8 @@ private: PM_pingpong, }; - // This data is not cycled, because it is a semi-permanent part of - // the interface. Also, some derivatives of AnimInterface don't - // even use it. + // This data is not cycled, because it is a semi-permanent part of the + // interface. Also, some derivatives of AnimInterface don't even use it. int _num_frames; // This is the data that must be cycled between pipeline stages. @@ -131,7 +126,7 @@ private: double _play_frames; int _from_frame; int _to_frame; - + double _play_rate; double _effective_frame_rate; bool _paused; diff --git a/panda/src/putil/autoTextureScale.cxx b/panda/src/putil/autoTextureScale.cxx index bd9ea61296..38f1c0a62a 100644 --- a/panda/src/putil/autoTextureScale.cxx +++ b/panda/src/putil/autoTextureScale.cxx @@ -1,16 +1,15 @@ -// Filename: autoTextureScale.cxx -// Created by: drose (28Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file autoTextureScale.cxx + * @author drose + * @date 2011-11-28 + */ #include "autoTextureScale.h" #include "string_utils.h" @@ -21,13 +20,13 @@ operator << (ostream &out, AutoTextureScale ats) { switch (ats) { case ATS_none: return out << "none"; - + case ATS_down: return out << "down"; - + case ATS_up: return out << "up"; - + case ATS_pad: return out << "pad"; diff --git a/panda/src/putil/autoTextureScale.h b/panda/src/putil/autoTextureScale.h index 317fc2629d..b51295881f 100644 --- a/panda/src/putil/autoTextureScale.h +++ b/panda/src/putil/autoTextureScale.h @@ -1,16 +1,15 @@ -// Filename: autoTextureScale.h -// Created by: drose (28Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file autoTextureScale.h + * @author drose + * @date 2011-11-28 + */ #ifndef AUTOTEXTURESCALE_H #define AUTOTEXTURESCALE_H diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index ad3bd8ee3f..ca6d0a2800 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -1,65 +1,66 @@ -// Filename: bam.h -// Created by: jason (27Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bam.h + * @author jason + * @date 2000-06-27 + */ -// This file just holds the Magic Number, Major and Minor version -// numbers that are common to both BamWriter and BamReader. +// This file just holds the Magic Number, Major and Minor version numbers that +// are common to both BamWriter and BamReader. #ifndef _BAM_H #define _BAM_H #include "pandabase.h" -// The magic number for a BAM file. It includes a carriage return and -// newline character to help detect files damaged due to faulty -// ASCII/Binary conversion. +// The magic number for a BAM file. It includes a carriage return and newline +// character to help detect files damaged due to faulty ASCIIBinary +// conversion. static const string _bam_header = string("pbj\0\n\r", 6); static const unsigned short _bam_major_ver = 6; -// Bumped to major version 2 on 7/6/00 due to major changes in Character. -// Bumped to major version 3 on 12/8/00 to change float64's to float32's. -// Bumped to major version 4 on 4/10/02 to store new scene graph. -// Bumped to major version 5 on 5/6/05 for new Geom implementation. -// Bumped to major version 6 on 2/11/06 to factor out PandaNode::CData. +// Bumped to major version 2 on 7600 due to major changes in Character. +// Bumped to major version 3 on 12800 to change float64's to float32's. +// Bumped to major version 4 on 41002 to store new scene graph. Bumped to +// major version 5 on 5605 for new Geom implementation. Bumped to major +// version 6 on 21106 to factor out PandaNode::CData. static const unsigned short _bam_first_minor_ver = 14; static const unsigned short _bam_minor_ver = 40; -// Bumped to minor version 14 on 12/19/07 to change default ColorAttrib. -// Bumped to minor version 15 on 4/9/08 to add TextureAttrib::_implicit_sort. -// Bumped to minor version 16 on 5/13/08 to add Texture::_quality_level. -// Bumped to minor version 17 on 8/6/08 to add PartBundle::_anim_preload. -// Bumped to minor version 18 on 8/14/08 to add Texture::_simple_ram_image. -// Bumped to minor version 19 on 8/14/08 to add PandaNode::_bounds_type. -// Bumped to minor version 20 on 4/21/09 to add MovingPartBase::_forced_channel. -// Bumped to minor version 21 on 2/26/08 to add BamEnums::BamObjectCode. -// Bumped to minor version 22 on 7/31/09 to add UvScrollNode R speed. -// Bumped to minor version 23 on 5/4/10 to add internal TextureAttrib overrides. -// Bumped to minor version 24 on 5/4/10 to add internal TexMatrixAttrib overrides. -// Bumped to minor version 25 on 6/22/11 to add support for caching movie files. -// Bumped to minor version 26 on 8/5/11 to add multiview (stereo) Textures. -// Bumped to minor version 27 on 10/9/11 to add stdfloat_double. -// Bumped to minor version 28 on 11/28/11 to add Texture::_auto_texture_scale. -// Bumped to minor version 29 on 12/17/11 to add GeomVertexColumn::_column_alignment. -// Bumped to minor version 30 on 1/22/12 to add Texture::_pad_*_size. -// Bumped to minor version 31 on 2/16/12 to add DepthOffsetAttrib::_min_value, _max_value. -// Bumped to minor version 32 on 6/11/12 to add Texture::_has_read_mipmaps. -// Bumped to minor version 33 on 8/17/13 to add UvScrollNode::_w_speed. -// Bumped to minor version 34 on 9/16/14 to add ScissorAttrib::_off. -// Bumped to minor version 35 on 12/3/14 to change StencilAttrib. -// Bumped to minor version 36 on 12/9/14 to add samplers and lod settings. -// Bumped to minor version 37 on 1/22/15 to add GeomVertexArrayFormat::_divisor. -// Bumped to minor version 38 on 4/15/15 to add various Bullet classes. -// Bumped to minor version 39 on 1/9/16 to change lights and materials. -// Bumped to minor version 40 on 1/11/16 to make NodePaths writable. +/* + * Bumped to minor version 14 on 121907 to change default ColorAttrib. Bumped + * to minor version 15 on 4908 to add TextureAttrib::_implicit_sort. Bumped + * to minor version 16 on 51308 to add Texture::_quality_level. Bumped to + * minor version 17 on 8608 to add PartBundle::_anim_preload. Bumped to minor + * version 18 on 81408 to add Texture::_simple_ram_image. Bumped to minor + * version 19 on 81408 to add PandaNode::_bounds_type. Bumped to minor + * version 20 on 42109 to add MovingPartBase::_forced_channel. Bumped to + * minor version 21 on 22608 to add BamEnums::BamObjectCode. Bumped to minor + * version 22 on 73109 to add UvScrollNode R speed. Bumped to minor version + * 23 on 5410 to add internal TextureAttrib overrides. Bumped to minor + * version 24 on 5410 to add internal TexMatrixAttrib overrides. Bumped to + * minor version 25 on 62211 to add support for caching movie files. Bumped + * to minor version 26 on 8511 to add multiview (stereo) Textures. Bumped to + * minor version 27 on 10911 to add stdfloat_double. Bumped to minor version + * 28 on 112811 to add Texture::_auto_texture_scale. Bumped to minor version + * 29 on 121711 to add GeomVertexColumn::_column_alignment. Bumped to minor + * version 30 on 12212 to add Texture::_pad_*_size. Bumped to minor version + * 31 on 21612 to add DepthOffsetAttrib::_min_value, _max_value. Bumped to + * minor version 32 on 61112 to add Texture::_has_read_mipmaps. Bumped to + * minor version 33 on 81713 to add UvScrollNode::_w_speed. Bumped to minor + * version 34 on 91614 to add ScissorAttrib::_off. Bumped to minor version 35 + * on 12314 to change StencilAttrib. Bumped to minor version 36 on 12914 to + * add samplers and lod settings. Bumped to minor version 37 on 12215 to add + * GeomVertexArrayFormat::_divisor. Bumped to minor version 38 on 41515 to + * add various Bullet classes. Bumped to minor version 39 on 1916 to change + * lights and materials. Bumped to minor version 40 on 11116 to make + * NodePaths writable. + */ #endif diff --git a/panda/src/putil/bamCache.I b/panda/src/putil/bamCache.I index 8345f02b1d..0d359ad29b 100644 --- a/panda/src/putil/bamCache.I +++ b/panda/src/putil/bamCache.I @@ -1,226 +1,180 @@ -// Filename: bamCache.I -// Created by: drose (09Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCache.I + * @author drose + * @date 2006-06-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_active -// Access: Published -// Description: Changes the state of the active flag. "active" means -// that the cache should be consulted automatically on -// loads, "not active" means that objects should be -// loaded directly without consulting the cache. -// -// This represents the global flag. Also see the -// individual cache_models, cache_textures, -// cache_compressed_textures flags. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the active flag. "active" means that the cache should + * be consulted automatically on loads, "not active" means that objects should + * be loaded directly without consulting the cache. + * + * This represents the global flag. Also see the individual cache_models, + * cache_textures, cache_compressed_textures flags. + */ INLINE void BamCache:: set_active(bool active) { ReMutexHolder holder(_lock); _active = active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_active -// Access: Published -// Description: Returns true if the BamCache is currently active, -// false if it is not. "active" means that the cache -// should be consulted automatically on loads, "not -// active" means that objects should be loaded directly -// without consulting the cache. -// -// This represents the global flag. Also see the -// individual cache_models, cache_textures, -// cache_compressed_textures flags. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the BamCache is currently active, false if it is not. + * "active" means that the cache should be consulted automatically on loads, + * "not active" means that objects should be loaded directly without + * consulting the cache. + * + * This represents the global flag. Also see the individual cache_models, + * cache_textures, cache_compressed_textures flags. + */ INLINE bool BamCache:: get_active() const { ReMutexHolder holder(_lock); return _active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_cache_models -// Access: Published -// Description: Indicates whether model files (e.g. egg files and bam -// files) will be stored in the cache, as bam files. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether model files (e.g. egg files and bam files) will be + * stored in the cache, as bam files. + */ INLINE void BamCache:: set_cache_models(bool flag) { ReMutexHolder holder(_lock); _cache_models = flag; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_cache_models -// Access: Published -// Description: Returns whether model files (e.g. egg files and bam -// files) will be stored in the cache, as bam files. -// -// This also returns false if get_active() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether model files (e.g. egg files and bam files) will be stored + * in the cache, as bam files. + * + * This also returns false if get_active() is false. + */ INLINE bool BamCache:: get_cache_models() const { ReMutexHolder holder(_lock); return _cache_models && _active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_cache_textures -// Access: Published -// Description: Indicates whether texture files will be stored in the -// cache, as uncompressed txo files. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether texture files will be stored in the cache, as + * uncompressed txo files. + */ INLINE void BamCache:: set_cache_textures(bool flag) { ReMutexHolder holder(_lock); _cache_textures = flag; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_cache_textures -// Access: Published -// Description: Returns whether texture files (e.g. egg files and bam -// files) will be stored in the cache, as txo files. -// -// This also returns false if get_active() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether texture files (e.g. egg files and bam files) will be + * stored in the cache, as txo files. + * + * This also returns false if get_active() is false. + */ INLINE bool BamCache:: get_cache_textures() const { ReMutexHolder holder(_lock); return _cache_textures && _active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_cache_compressed_textures -// Access: Published -// Description: Indicates whether compressed texture files will be -// stored in the cache, as compressed txo files. The -// compressed data may either be generated in-CPU, via -// the squish library, or it may be extracted from the -// GSG after the texture has been loaded. -// -// This may be set in conjunction with -// set_cache_textures(), or independently of it. If -// set_cache_textures() is true and this is false, all -// textures will be cached in their uncompressed form. -// If set_cache_textures() is false and this is true, -// only compressed textures will be cached, and they -// will be cached in their compressed form. If both are -// true, all textures will be cached, in their -// uncompressed or compressed form appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether compressed texture files will be stored in the cache, as + * compressed txo files. The compressed data may either be generated in-CPU, + * via the squish library, or it may be extracted from the GSG after the + * texture has been loaded. + * + * This may be set in conjunction with set_cache_textures(), or independently + * of it. If set_cache_textures() is true and this is false, all textures + * will be cached in their uncompressed form. If set_cache_textures() is + * false and this is true, only compressed textures will be cached, and they + * will be cached in their compressed form. If both are true, all textures + * will be cached, in their uncompressed or compressed form appropriately. + */ INLINE void BamCache:: set_cache_compressed_textures(bool flag) { ReMutexHolder holder(_lock); _cache_compressed_textures = flag; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_cache_compressed_textures -// Access: Published -// Description: Returns whether compressed texture files will be -// stored in the cache, as compressed txo files. See -// set_cache_compressed_textures(). -// -// This also returns false if get_active() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether compressed texture files will be stored in the cache, as + * compressed txo files. See set_cache_compressed_textures(). + * + * This also returns false if get_active() is false. + */ INLINE bool BamCache:: get_cache_compressed_textures() const { ReMutexHolder holder(_lock); return _cache_compressed_textures && _active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_cache_compiled_shaders -// Access: Published -// Description: Indicates whether compiled shader programs will be -// stored in the cache, as binary .sho files. This -// may not be supported by all shader languages or -// graphics renderers. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether compiled shader programs will be stored in the cache, as + * binary .sho files. This may not be supported by all shader languages or + * graphics renderers. + */ INLINE void BamCache:: set_cache_compiled_shaders(bool flag) { ReMutexHolder holder(_lock); _cache_compiled_shaders = flag; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_cache_compiled_shaders -// Access: Published -// Description: Returns whether compiled shader programs will be -// stored in the cache, as binary .txo files. See -// set_cache_compiled_shaders(). -// -// This also returns false if get_active() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether compiled shader programs will be stored in the cache, as + * binary .txo files. See set_cache_compiled_shaders(). + * + * This also returns false if get_active() is false. + */ INLINE bool BamCache:: get_cache_compiled_shaders() const { ReMutexHolder holder(_lock); return _cache_compiled_shaders && _active; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_root -// Access: Published -// Description: Returns the current root pathname of the cache. See -// set_root(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current root pathname of the cache. See set_root(). + */ INLINE Filename BamCache:: get_root() const { ReMutexHolder holder(_lock); return _root; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_flush_time -// Access: Published -// Description: Specifies the time in seconds between automatic -// flushes of the cache index. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the time in seconds between automatic flushes of the cache index. + */ INLINE void BamCache:: set_flush_time(int flush_time) { ReMutexHolder holder(_lock); _flush_time = flush_time; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_flush_time -// Access: Published -// Description: Returns the time in seconds between automatic -// flushes of the cache index. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time in seconds between automatic flushes of the cache index. + */ INLINE int BamCache:: get_flush_time() const { ReMutexHolder holder(_lock); return _flush_time; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_cache_max_kbytes -// Access: Published -// Description: Specifies the maximum size, in kilobytes, which the -// cache is allowed to grow to. If a newly cached file -// would exceed this size, an older file is removed from -// the cache. -// -// Note that in the case of multiple different processes -// simultaneously operating on the same cache directory, -// the actual cache size may slightly exceed this value -// from time to time due to latency in checking between -// the processes. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the maximum size, in kilobytes, which the cache is allowed to + * grow to. If a newly cached file would exceed this size, an older file is + * removed from the cache. + * + * Note that in the case of multiple different processes simultaneously + * operating on the same cache directory, the actual cache size may slightly + * exceed this value from time to time due to latency in checking between the + * processes. + */ INLINE void BamCache:: set_cache_max_kbytes(int max_kbytes) { ReMutexHolder holder(_lock); @@ -228,56 +182,43 @@ set_cache_max_kbytes(int max_kbytes) { check_cache_size(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_cache_max_kbytes -// Access: Published -// Description: Returns the maximum size, in kilobytes, which the -// cache is allowed to grow to. See -// set_cache_max_kbytes(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum size, in kilobytes, which the cache is allowed to grow + * to. See set_cache_max_kbytes(). + */ INLINE int BamCache:: get_cache_max_kbytes() const { ReMutexHolder holder(_lock); return _max_kbytes; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_read_only -// Access: Published -// Description: Can be used to put the cache in read-only mode, -// or take it out of read-only mode. Note that if you -// put it into read-write mode, and it discovers that -// it does not have write access, it will put itself -// right back into read-only mode. -//////////////////////////////////////////////////////////////////// +/** + * Can be used to put the cache in read-only mode, or take it out of read-only + * mode. Note that if you put it into read-write mode, and it discovers that + * it does not have write access, it will put itself right back into read-only + * mode. + */ INLINE void BamCache:: set_read_only(bool ro) { ReMutexHolder holder(_lock); _read_only = ro; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_read_only -// Access: Published -// Description: Returns true if the cache is in read-only mode. -// Normally, the cache starts in read-write mode. It -// can put itself into read-only mode automatically if -// it discovers that it does not have write access to -// the cache. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the cache is in read-only mode. Normally, the cache starts + * in read-write mode. It can put itself into read-only mode automatically if + * it discovers that it does not have write access to the cache. + */ INLINE bool BamCache:: get_read_only() const { ReMutexHolder holder(_lock); return _read_only; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::get_global_ptr -// Access: Published, Static -// Description: Returns a pointer to the global BamCache object, -// which is used automatically by the ModelPool and -// TexturePool. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global BamCache object, which is used + * automatically by the ModelPool and TexturePool. + */ INLINE BamCache *BamCache:: get_global_ptr() { if (_global_ptr == (BamCache *)NULL) { @@ -286,12 +227,9 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::consider_flush_global_index -// Access: Published, Static -// Description: If there is a global BamCache object, calls -// consider_flush_index() on it. -//////////////////////////////////////////////////////////////////// +/** + * If there is a global BamCache object, calls consider_flush_index() on it. + */ INLINE void BamCache:: consider_flush_global_index() { if (_global_ptr != (BamCache *)NULL) { @@ -299,12 +237,9 @@ consider_flush_global_index() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::flush_global_index -// Access: Published, Static -// Description: If there is a global BamCache object, calls -// flush_index() on it. -//////////////////////////////////////////////////////////////////// +/** + * If there is a global BamCache object, calls flush_index() on it. + */ INLINE void BamCache:: flush_global_index() { if (_global_ptr != (BamCache *)NULL) { @@ -312,12 +247,10 @@ flush_global_index() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::mark_index_stale -// Access: Private -// Description: Indicates that the index has been modified and will -// need to be written to disk eventually. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the index has been modified and will need to be written to + * disk eventually. + */ INLINE void BamCache:: mark_index_stale() { if (_index_stale_since == 0) { diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 0b7871475a..06211b5690 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -1,16 +1,15 @@ -// Filename: bamCache.cxx -// Created by: drose (09Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCache.cxx + * @author drose + * @date 2006-06-09 + */ #include "bamCache.h" #include "bamCacheIndex.h" @@ -30,11 +29,9 @@ BamCache *BamCache::_global_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: BamCache::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamCache:: BamCache() : _active(true), @@ -97,11 +94,9 @@ BamCache() : } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamCache:: ~BamCache() { flush_index(); @@ -109,18 +104,15 @@ BamCache:: _index = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::set_root -// Access: Published -// Description: Changes the current root pathname of the cache. This -// specifies where the cache files are stored on disk. -// This should name a directory that is on a disk local -// to the machine (not on a network-mounted disk), for -// instance, /tmp/panda-cache or /c/panda-cache. -// -// If the directory does not already exist, it will be -// created as a result of this call. -//////////////////////////////////////////////////////////////////// +/** + * Changes the current root pathname of the cache. This specifies where the + * cache files are stored on disk. This should name a directory that is on a + * disk local to the machine (not on a network-mounted disk), for instance, + * /tmp/panda-cache or /c/panda-cache. + * + * If the directory does not already exist, it will be created as a result of + * this call. + */ void BamCache:: set_root(const Filename &root) { ReMutexHolder holder(_lock); @@ -142,28 +134,22 @@ set_root(const Filename &root) { nassertv(vfs->is_directory(_root)); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::lookup -// Access: Published -// Description: Looks up a file in the cache. -// -// If the file is cacheable, then regardless of whether -// the file is found in the cache or not, this returns a -// BamCacheRecord. On the other hand, if the file -// cannot be cached, returns NULL. -// -// If record->has_data() returns true, then the file was -// found in the cache, and you may call -// record->extract_data() to get the object. If -// record->has_data() returns false, then the file was -// not found in the cache or the cache was stale; and -// you should reload the source file (calling -// record->add_dependent_file() for each file loaded, -// including the original source file), and then call -// record->set_data() to record the resulting loaded -// object; and finally, you should call store() to write -// the cached record to disk. -//////////////////////////////////////////////////////////////////// +/** + * Looks up a file in the cache. + * + * If the file is cacheable, then regardless of whether the file is found in + * the cache or not, this returns a BamCacheRecord. On the other hand, if the + * file cannot be cached, returns NULL. + * + * If record->has_data() returns true, then the file was found in the cache, + * and you may call record->extract_data() to get the object. If + * record->has_data() returns false, then the file was not found in the cache + * or the cache was stale; and you should reload the source file (calling + * record->add_dependent_file() for each file loaded, including the original + * source file), and then call record->set_data() to record the resulting + * loaded object; and finally, you should call store() to write the cached + * record to disk. + */ PT(BamCacheRecord) BamCache:: lookup(const Filename &source_filename, const string &cache_extension) { ReMutexHolder holder(_lock); @@ -177,8 +163,8 @@ lookup(const Filename &source_filename, const string &cache_extension) { Filename rel_pathname(source_pathname); rel_pathname.make_relative_to(_root, false); if (rel_pathname.is_local()) { - // If the source pathname is already within the cache directory, - // don't cache it further. + // If the source pathname is already within the cache directory, don't + // cache it further. return NULL; } @@ -188,15 +174,11 @@ lookup(const Filename &source_filename, const string &cache_extension) { return find_and_read_record(source_pathname, cache_filename); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::store -// Access: Published -// Description: Flushes a cache entry to disk. You must have -// retrieved the cache record via a prior call to -// lookup(), and then stored the data via -// record->set_data(). Returns true on success, false -// on failure. -//////////////////////////////////////////////////////////////////// +/** + * Flushes a cache entry to disk. You must have retrieved the cache record + * via a prior call to lookup(), and then stored the data via + * record->set_data(). Returns true on success, false on failure. + */ bool BamCache:: store(BamCacheRecord *record) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -221,9 +203,9 @@ store(BamCacheRecord *record) { Filename cache_pathname = Filename::binary_filename(record->_cache_pathname); - // We actually do the write to a temporary filename first, and then - // move it into place, so that no one attempts to read the file - // while it is in the process of being written. + // We actually do the write to a temporary filename first, and then move it + // into place, so that no one attempts to read the file while it is in the + // process of being written. Thread *current_thread = Thread::get_current_thread(); string extension = current_thread->get_unique_id() + string(".tmp"); Filename temp_pathname = cache_pathname; @@ -285,9 +267,9 @@ store(BamCacheRecord *record) { return false; } - // Now that we are done with the BamWriter, it's important to let - // it destruct now and clean itself up, or it might get mad if we - // delete any TypedWritables below that haven't been written yet. + // Now that we are done with the BamWriter, it's important to let it + // destruct now and clean itself up, or it might get mad if we delete any + // TypedWritables below that haven't been written yet. } record->_record_size = dout.get_file_pos(); @@ -298,7 +280,7 @@ store(BamCacheRecord *record) { vfs->delete_file(cache_pathname); if (!vfs->rename_file(temp_pathname, cache_pathname)) { util_cat.error() - << "Unable to rename " << temp_pathname << " to " + << "Unable to rename " << temp_pathname << " to " << cache_pathname << "\n"; vfs->delete_file(temp_pathname); return false; @@ -310,15 +292,11 @@ store(BamCacheRecord *record) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::emergency_read_only -// Access: Private -// Description: Called when an attempt to write to the cache dir -// has failed, usually for lack of disk space or -// because of incorrect file permissions. Outputs -// an error and puts the BamCache into read-only -// mode. -//////////////////////////////////////////////////////////////////// +/** + * Called when an attempt to write to the cache dir has failed, usually for + * lack of disk space or because of incorrect file permissions. Outputs an + * error and puts the BamCache into read-only mode. + */ void BamCache:: emergency_read_only() { util_cat.error() << @@ -326,12 +304,10 @@ emergency_read_only() { _read_only = true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::consider_flush_index -// Access: Published -// Description: Flushes the index if enough time has elapsed since -// the index was last flushed. -//////////////////////////////////////////////////////////////////// +/** + * Flushes the index if enough time has elapsed since the index was last + * flushed. + */ void BamCache:: consider_flush_index() { ReMutexHolder holder(_lock); @@ -343,11 +319,9 @@ consider_flush_index() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::flush_index -// Access: Published -// Description: Ensures the index is written to disk. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the index is written to disk. + */ void BamCache:: flush_index() { ReMutexHolder holder(_lock); @@ -368,8 +342,8 @@ flush_index() { return; } - // Now atomically write the name of this index file to the index - // reference file. + // Now atomically write the name of this index file to the index reference + // file. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); Filename index_ref_pathname(_root, Filename("index_name.txt")); string old_index = _index_ref_contents; @@ -377,9 +351,9 @@ flush_index() { string orig_index; if (vfs->atomic_compare_and_exchange_contents(index_ref_pathname, orig_index, old_index, new_index)) { - // We successfully wrote our version of the index, and no other - // process beat us to it. Our index is now the official one. - // Remove the old index. + // We successfully wrote our version of the index, and no other process + // beat us to it. Our index is now the official one. Remove the old + // index. vfs->delete_file(_index_pathname); _index_pathname = temp_pathname; _index_ref_contents = new_index; @@ -387,9 +361,8 @@ flush_index() { return; } - // Shoot, some other process updated the index while we were - // trying to update it, and they beat us to it. We have to merge, - // and try again. + // Shoot, some other process updated the index while we were trying to + // update it, and they beat us to it. We have to merge, and try again. vfs->delete_file(temp_pathname); _index_pathname = Filename(_root, Filename(trim(orig_index))); _index_ref_contents = orig_index; @@ -398,23 +371,18 @@ flush_index() { check_cache_size(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::list_index -// Access: Published -// Description: Writes the contents of the index to standard output. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of the index to standard output. + */ void BamCache:: list_index(ostream &out, int indent_level) const { _index->write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::read_index -// Access: Private -// Description: Reads, or re-reads the index file from disk. If -// _index_stale_since is nonzero, the index file is read -// and then merged with our current index. -//////////////////////////////////////////////////////////////////// +/** + * Reads, or re-reads the index file from disk. If _index_stale_since is + * nonzero, the index file is read and then merged with our current index. + */ void BamCache:: read_index() { if (!read_index_pathname(_index_pathname, _index_ref_contents)) { @@ -430,8 +398,8 @@ read_index() { return; } - // We couldn't read the index. Maybe it's been removed already. - // See if the index_pathname has changed. + // We couldn't read the index. Maybe it's been removed already. See if + // the index_pathname has changed. Filename old_index_pathname = _index_pathname; if (!read_index_pathname(_index_pathname, _index_ref_contents)) { // Couldn't read the index ref; rebuild the index. @@ -440,8 +408,7 @@ read_index() { } if (old_index_pathname == _index_pathname) { - // Nope, we just couldn't read it. Delete it and build a new - // one. + // Nope, we just couldn't read it. Delete it and build a new one. VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->delete_file(_index_pathname); rebuild_index(); @@ -451,13 +418,10 @@ read_index() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::read_index_pathname -// Access: Private -// Description: Atomically reads the current index filename from the -// index reference file. The index filename moves -// around as different processes update the index. -//////////////////////////////////////////////////////////////////// +/** + * Atomically reads the current index filename from the index reference file. + * The index filename moves around as different processes update the index. + */ bool BamCache:: read_index_pathname(Filename &index_pathname, string &index_ref_contents) const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -476,16 +440,13 @@ read_index_pathname(Filename &index_pathname, string &index_ref_contents) const return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::merge_index -// Access: Private -// Description: The supplied index file has been updated by some other -// process. Merge it with our current index. -// -// Ownership of the pointer is transferred with this -// call. The caller should assume that new_index will -// be deleted by this method. -//////////////////////////////////////////////////////////////////// +/** + * The supplied index file has been updated by some other process. Merge it + * with our current index. + * + * Ownership of the pointer is transferred with this call. The caller should + * assume that new_index will be deleted by this method. + */ void BamCache:: merge_index(BamCacheIndex *new_index) { if (_index_stale_since == 0) { @@ -502,12 +463,11 @@ merge_index(BamCacheIndex *new_index) { BamCacheIndex::Records::const_iterator ai = old_index->_records.begin(); BamCacheIndex::Records::const_iterator bi = new_index->_records.begin(); - - while (ai != old_index->_records.end() && + + while (ai != old_index->_records.end() && bi != new_index->_records.end()) { if ((*ai).first < (*bi).first) { - // Here is an entry we have in our index, not present in the new - // index. + // Here is an entry we have in our index, not present in the new index. PT(BamCacheRecord) record = (*ai).second; Filename cache_pathname(_root, record->get_cache_filename()); if (cache_pathname.exists()) { @@ -531,13 +491,13 @@ merge_index(BamCacheIndex *new_index) { PT(BamCacheRecord) a_record = (*ai).second; PT(BamCacheRecord) b_record = (*bi).second; if (*a_record == *b_record) { - // They're the same entry. It doesn't really matter which one - // we keep. + // They're the same entry. It doesn't really matter which one we + // keep. _index->_records.insert(_index->_records.end(), BamCacheIndex::Records::value_type(a_record->get_source_pathname(), a_record)); } else { - // They're different. Just throw them both away, and re-read - // the current data from the cache file. + // They're different. Just throw them both away, and re-read the + // current data from the cache file. Filename cache_pathname(_root, a_record->get_cache_filename()); @@ -555,8 +515,7 @@ merge_index(BamCacheIndex *new_index) { } while (ai != old_index->_records.end()) { - // Here is an entry we have in our index, not present in the new - // index. + // Here is an entry we have in our index, not present in the new index. PT(BamCacheRecord) record = (*ai).second; Filename cache_pathname(_root, record->get_cache_filename()); if (cache_pathname.exists()) { @@ -565,7 +524,7 @@ merge_index(BamCacheIndex *new_index) { } ++ai; } - + while (bi != new_index->_records.end()) { // Here is an entry in the new index, not present in our index. PT(BamCacheRecord) record = (*bi).second; @@ -580,12 +539,9 @@ merge_index(BamCacheIndex *new_index) { _index->process_new_records(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::rebuild_index -// Access: Private -// Description: Regenerates the index from scratch by scanning the -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates the index from scratch by scanning the directory. + */ void BamCache:: rebuild_index() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -637,12 +593,10 @@ rebuild_index() { flush_index(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::add_to_index -// Access: Private -// Description: Updates the index entry for the indicated record. -// Note that a copy of the record is made first. -//////////////////////////////////////////////////////////////////// +/** + * Updates the index entry for the indicated record. Note that a copy of the + * record is made first. + */ void BamCache:: add_to_index(const BamCacheRecord *record) { PT(BamCacheRecord) new_record = record->make_copy(); @@ -653,12 +607,9 @@ add_to_index(const BamCacheRecord *record) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::remove_from_index -// Access: Private -// Description: Removes the index entry for the indicated record, if -// there is one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the index entry for the indicated record, if there is one. + */ void BamCache:: remove_from_index(const Filename &source_pathname) { if (_index->remove_record(source_pathname)) { @@ -666,12 +617,10 @@ remove_from_index(const Filename &source_pathname) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::check_cache_size -// Access: Private -// Description: If the cache size has exceeded its specified size -// limit, removes an old file. -//////////////////////////////////////////////////////////////////// +/** + * If the cache size has exceeded its specified size limit, removes an old + * file. + */ void BamCache:: check_cache_size() { if (_index->_cache_size == 0) { @@ -699,13 +648,10 @@ check_cache_size() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::do_read_index -// Access: Private, Static -// Description: Reads the index data from the specified filename. -// Returns a newly-allocated BamCacheIndex object on -// success, or NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the index data from the specified filename. Returns a newly- + * allocated BamCacheIndex object on success, or NULL on failure. + */ BamCacheIndex *BamCache:: do_read_index(const Filename &index_pathname) { if (index_pathname.empty()) { @@ -718,20 +664,20 @@ do_read_index(const Filename &index_pathname) { << "Could not read index file: " << index_pathname << "\n"; return NULL; } - + string head; if (!din.read_header(head, _bam_header.size())) { util_cat.debug() << index_pathname << " is not an index file.\n"; return NULL; } - + if (head != _bam_header) { util_cat.debug() << index_pathname << " is not an index file.\n"; return NULL; } - + BamReader reader(&din); if (!reader.init()) { return NULL; @@ -761,11 +707,9 @@ do_read_index(const Filename &index_pathname) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::do_write_index -// Access: Private, Static -// Description: Writes the given index data to the specified filename. -//////////////////////////////////////////////////////////////////// +/** + * Writes the given index data to the specified filename. + */ bool BamCache:: do_write_index(const Filename &index_pathname, const BamCacheIndex *index) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -790,7 +734,7 @@ do_write_index(const Filename &index_pathname, const BamCacheIndex *index) { vfs->delete_file(index_pathname); return false; } - + if (!writer.write_object(index)) { vfs->delete_file(index_pathname); return false; @@ -800,21 +744,17 @@ do_write_index(const Filename &index_pathname, const BamCacheIndex *index) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::find_and_read_record -// Access: Private -// Description: Looks for the existing cache file that corresponds -// to the indicated filename. Normally, this is the -// specified cache filename exactly; but in the case of -// a hash collision, it may be a variant of the cache -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Looks for the existing cache file that corresponds to the indicated + * filename. Normally, this is the specified cache filename exactly; but in + * the case of a hash collision, it may be a variant of the cache filename. + */ PT(BamCacheRecord) BamCache:: -find_and_read_record(const Filename &source_pathname, +find_and_read_record(const Filename &source_pathname, const Filename &cache_filename) { int pass = 0; while (true) { - PT(BamCacheRecord) record = + PT(BamCacheRecord) record = read_record(source_pathname, cache_filename, pass); if (record != (BamCacheRecord *)NULL) { add_to_index(record); @@ -824,15 +764,12 @@ find_and_read_record(const Filename &source_pathname, } } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::read_record -// Access: Private -// Description: Reads the indicated cache file and returns its -// associated record if it can be read and it matches -// the source filename. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated cache file and returns its associated record if it can + * be read and it matches the source filename. + */ PT(BamCacheRecord) BamCache:: -read_record(const Filename &source_pathname, +read_record(const Filename &source_pathname, const Filename &cache_filename, int pass) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -842,7 +779,7 @@ read_record(const Filename &source_pathname, strm << cache_pathname.get_basename_wo_extension() << "_" << pass; cache_pathname.set_basename_wo_extension(strm.str()); } - + if (!cache_pathname.exists()) { // There is no such cache file already. Declare it. if (util_cat.is_debug()) { @@ -896,11 +833,9 @@ read_record(const Filename &source_pathname, return record; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::do_read_record -// Access: Private, Static -// Description: Actually reads a record from the file. -//////////////////////////////////////////////////////////////////// +/** + * Actually reads a record from the file. + */ PT(BamCacheRecord) BamCache:: do_read_record(const Filename &cache_pathname, bool read_data) { DatagramInputFile din; @@ -911,7 +846,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { } return NULL; } - + string head; if (!din.read_header(head, _bam_header.size())) { if (util_cat.is_debug()) { @@ -920,7 +855,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { } return NULL; } - + if (head != _bam_header) { if (util_cat.is_debug()) { util_cat.debug() @@ -928,12 +863,12 @@ do_read_record(const Filename &cache_pathname, bool read_data) { } return NULL; } - + BamReader reader(&din); if (!reader.init()) { return NULL; } - + TypedWritable *object = reader.read_object(); if (object == (TypedWritable *)NULL) { if (util_cat.is_debug()) { @@ -941,7 +876,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { << cache_pathname << " is empty.\n"; } return NULL; - + } else if (!object->is_of_type(BamCacheRecord::get_class_type())) { if (util_cat.is_debug()) { util_cat.debug() @@ -950,7 +885,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { } return NULL; } - + PT(BamCacheRecord) record = DCAST(BamCacheRecord, object); if (!reader.resolve()) { if (util_cat.is_debug()) { @@ -960,14 +895,13 @@ do_read_record(const Filename &cache_pathname, bool read_data) { return NULL; } - // From this point below, we have validated that the selected - // filename is indeed a cache record for the indicated source file, - // and therefore the cache record will be returned. + // From this point below, we have validated that the selected filename is + // indeed a cache record for the indicated source file, and therefore the + // cache record will be returned. // We still need to decide whether the cache record is stale. if (read_data && record->dependents_unchanged()) { - // The cache record doesn't appear to be stale. Load the cached - // object. + // The cache record doesn't appear to be stale. Load the cached object. TypedWritable *ptr; ReferenceCount *ref_ptr; @@ -984,7 +918,7 @@ do_read_record(const Filename &cache_pathname, bool read_data) { } } } - + // Also get the total file size. PT(VirtualFile) vfile = din.get_vfile(); istream &in = din.get_stream(); @@ -997,13 +931,10 @@ do_read_record(const Filename &cache_pathname, bool read_data) { return record; } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::hash_filename -// Access: Private, Static -// Description: Returns the appropriate filename to use for a cache -// file, given the fullpath string to the source -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate filename to use for a cache file, given the + * fullpath string to the source filename. + */ string BamCache:: hash_filename(const string &filename) { #ifdef HAVE_OPENSSL @@ -1017,8 +948,8 @@ hash_filename(const string &filename) { #else // HAVE_OPENSSL // Without OpenSSL, don't get fancy; just build a simple hash. unsigned int hash = 0; - for (string::const_iterator si = filename.begin(); - si != filename.end(); + for (string::const_iterator si = filename.begin(); + si != filename.end(); ++si) { hash = (hash * 9109) + (unsigned int)(*si); } @@ -1030,11 +961,9 @@ hash_filename(const string &filename) { #endif // HAVE_OPENSSL } -//////////////////////////////////////////////////////////////////// -// Function: BamCache::make_global -// Access: Private, Static -// Description: Constructs the global BamCache object. -//////////////////////////////////////////////////////////////////// +/** + * Constructs the global BamCache object. + */ void BamCache:: make_global() { _global_ptr = new BamCache; diff --git a/panda/src/putil/bamCache.h b/panda/src/putil/bamCache.h index 583cf2a0be..9b533ce5c5 100644 --- a/panda/src/putil/bamCache.h +++ b/panda/src/putil/bamCache.h @@ -1,16 +1,15 @@ -// Filename: bamCache.h -// Created by: drose (09Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCache.h + * @author drose + * @date 2006-06-09 + */ #ifndef BAMCACHE_H #define BAMCACHE_H @@ -28,22 +27,18 @@ class BamCacheIndex; -//////////////////////////////////////////////////////////////////// -// Class : BamCache -// Description : This class maintains a cache of Bam and/or Txo -// objects generated from model files and texture images -// (as well as possibly other kinds of loadable objects -// that can be stored in bam file format). -// -// This class also maintains a persistent index that -// lists all of the cached objects (see BamCacheIndex). -// We go through some considerable effort to make sure -// this index gets saved correctly to disk, even in the -// presence of multiple different processes writing to -// the same index, and without relying too heavily on -// low-level os-provided file locks (which work poorly -// with C++ iostreams). -//////////////////////////////////////////////////////////////////// +/** + * This class maintains a cache of Bam and/or Txo objects generated from model + * files and texture images (as well as possibly other kinds of loadable + * objects that can be stored in bam file format). + * + * This class also maintains a persistent index that lists all of the cached + * objects (see BamCacheIndex). We go through some considerable effort to make + * sure this index gets saved correctly to disk, even in the presence of + * multiple different processes writing to the same index, and without relying + * too heavily on low-level os-provided file locks (which work poorly with C++ + * iostreams). + */ class EXPCL_PANDA_PUTIL BamCache { PUBLISHED: BamCache(); diff --git a/panda/src/putil/bamCacheIndex.I b/panda/src/putil/bamCacheIndex.I index cffbf9fb78..89ca503f60 100644 --- a/panda/src/putil/bamCacheIndex.I +++ b/panda/src/putil/bamCacheIndex.I @@ -1,25 +1,21 @@ -// Filename: bamCacheIndex.I -// Created by: drose (19Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheIndex.I + * @author drose + * @date 2006-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamCacheIndex:: -BamCacheIndex() : +BamCacheIndex() : LinkedListNode(true), _cache_size(0) { diff --git a/panda/src/putil/bamCacheIndex.cxx b/panda/src/putil/bamCacheIndex.cxx index 6ff14ab583..600ee6c328 100644 --- a/panda/src/putil/bamCacheIndex.cxx +++ b/panda/src/putil/bamCacheIndex.cxx @@ -1,16 +1,15 @@ -// Filename: bamCacheIndex.cxx -// Created by: drose (19Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheIndex.cxx + * @author drose + * @date 2006-06-19 + */ #include "bamCacheIndex.h" #include "bamReader.h" @@ -22,25 +21,21 @@ TypeHandle BamCacheIndex::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamCacheIndex:: ~BamCacheIndex() { #ifndef NDEBUG - // We need to "empty" the linked list to make the LinkedListNode - // destructors happy. + // We need to "empty" the linked list to make the LinkedListNode destructors + // happy. release_records(); #endif } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BamCacheIndex:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -59,19 +54,15 @@ write(ostream &out, int indent_level) const { << setw(12) << _cache_size << " bytes total\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::process_new_records -// Access: Private -// Description: Should be called after the _records index has been -// filled externally, this will sort the records by -// access time and calculate _cache_size. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after the _records index has been filled externally, this + * will sort the records by access time and calculate _cache_size. + */ void BamCacheIndex:: process_new_records() { nassertv(_cache_size == 0); - // Fill up a vector so we can sort the records into order by access - // time. + // Fill up a vector so we can sort the records into order by access time. RecordVector rv; rv.reserve(_records.size()); @@ -92,15 +83,12 @@ process_new_records() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::release_records -// Access: Private -// Description: This is the inverse of process_new_records: it -// releases the records from the linked list, so that -// they may be added to another index or whatever. -// Calling this, of course, invalidates the index until -// process_new_records() is called again. -//////////////////////////////////////////////////////////////////// +/** + * This is the inverse of process_new_records: it releases the records from + * the linked list, so that they may be added to another index or whatever. + * Calling this, of course, invalidates the index until process_new_records() + * is called again. + */ void BamCacheIndex:: release_records() { Records::const_iterator ri; @@ -114,12 +102,10 @@ release_records() { _cache_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::evict_old_file -// Access: Private -// Description: Evicts an old file from the cache. Records the -// record. Returns NULL if the cache is empty. -//////////////////////////////////////////////////////////////////// +/** + * Evicts an old file from the cache. Records the record. Returns NULL if + * the cache is empty. + */ PT(BamCacheRecord) BamCacheIndex:: evict_old_file() { if (_next == this) { @@ -127,8 +113,7 @@ evict_old_file() { return NULL; } - // The first record in the linked list is the least-recently-used - // one. + // The first record in the linked list is the least-recently-used one. PT(BamCacheRecord) record = (BamCacheRecord *)_next; bool removed = remove_record(record->get_source_pathname()); nassertr(removed, NULL); @@ -136,18 +121,15 @@ evict_old_file() { return record; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::add_record -// Access: Private -// Description: Adds a newly-created BamCacheRecord into the index. -// If a matching record is already in the index, it is -// replaced with the new record. Returns true if the -// record was added, or false if the equivalent record -// was already there and the index is unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Adds a newly-created BamCacheRecord into the index. If a matching record + * is already in the index, it is replaced with the new record. Returns true + * if the record was added, or false if the equivalent record was already + * there and the index is unchanged. + */ bool BamCacheIndex:: add_record(BamCacheRecord *record) { - pair result = + pair result = _records.insert(Records::value_type(record->get_source_pathname(), record)); if (!result.second) { // We already had a record for this filename; it gets replaced. @@ -168,14 +150,11 @@ add_record(BamCacheRecord *record) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::remove_record -// Access: Private -// Description: Searches for the matching record in the index and -// removes it if it is found. Returns true if the -// record was found and removed, or false if there was -// no such record and the index is unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the matching record in the index and removes it if it is + * found. Returns true if the record was found and removed, or false if there + * was no such record and the index is unchanged. + */ bool BamCacheIndex:: remove_record(const Filename &source_pathname) { Records::iterator ri = _records.find(source_pathname); @@ -191,23 +170,18 @@ remove_record(const Filename &source_pathname) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// BamCacheRecord. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BamCacheRecord. + */ void BamCacheIndex:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BamCacheIndex:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -219,14 +193,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BamCacheIndex is encountered -// in the Bam file. It should create the BamCacheIndex -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BamCacheIndex is encountered in the Bam file. It should create the + * BamCacheIndex and extract its information from the file. + */ TypedWritable *BamCacheIndex:: make_from_bam(const FactoryParams ¶ms) { BamCacheIndex *object = new BamCacheIndex; @@ -239,13 +210,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int BamCacheIndex:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -270,13 +238,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheIndex::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BamCacheIndex. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BamCacheIndex. + */ void BamCacheIndex:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/putil/bamCacheIndex.h b/panda/src/putil/bamCacheIndex.h index fa7acfcb46..f7e8c2b7a5 100644 --- a/panda/src/putil/bamCacheIndex.h +++ b/panda/src/putil/bamCacheIndex.h @@ -1,16 +1,15 @@ -// Filename: bamCacheIndex.h -// Created by: drose (19Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheIndex.h + * @author drose + * @date 2006-06-19 + */ #ifndef BAMCACHEINDEX_H #define BAMCACHEINDEX_H @@ -24,16 +23,13 @@ #include "pmap.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : BamCacheIndex -// Description : This represents the in-memory index that records the -// list of files stored in the BamCache. Since the -// memory is also flushed to disk from time to time, -// this class is a TypedWritable object. -// -// For the most part, this class is used only by the -// BamCache class. -//////////////////////////////////////////////////////////////////// +/** + * This represents the in-memory index that records the list of files stored + * in the BamCache. Since the memory is also flushed to disk from time to + * time, this class is a TypedWritable object. + * + * For the most part, this class is used only by the BamCache class. + */ class EXPCL_PANDA_PUTIL BamCacheIndex : public TypedWritable, public LinkedListNode { private: INLINE BamCacheIndex(); @@ -56,8 +52,8 @@ private: Records _records; streamsize _cache_size; - // This structure is a temporary container. It is only filled in - // while reading from a bam file. + // This structure is a temporary container. It is only filled in while + // reading from a bam file. typedef pvector< PT(BamCacheRecord) > RecordVector; RecordVector _record_vector; @@ -69,7 +65,7 @@ protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); virtual int complete_pointers(TypedWritable **plist, BamReader *manager); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/putil/bamCacheRecord.I b/panda/src/putil/bamCacheRecord.I index 53d3d91cf8..6693b1c694 100644 --- a/panda/src/putil/bamCacheRecord.I +++ b/panda/src/putil/bamCacheRecord.I @@ -1,38 +1,30 @@ -// Filename: bamCacheRecord.I -// Created by: drose (09Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheRecord.I + * @author drose + * @date 2006-06-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::make_copy -// Access: Published -// Description: Returns a duplicate of the BamCacheRecord. The -// duplicate will not have a data pointer set, even -// though one may have been assigned to the original via -// set_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a duplicate of the BamCacheRecord. The duplicate will not have a + * data pointer set, even though one may have been assigned to the original + * via set_data(). + */ INLINE PT(BamCacheRecord) BamCacheRecord:: make_copy() const { return new BamCacheRecord(*this); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::operator == -// Access: Published -// Description: Returns true if the record matches the other record -// in those attributes which get written to disk. Does -// not compare the data pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the record matches the other record in those attributes + * which get written to disk. Does not compare the data pointer. + */ INLINE bool BamCacheRecord:: operator == (const BamCacheRecord &other) const { return (_source_pathname == other._source_pathname && @@ -41,100 +33,75 @@ operator == (const BamCacheRecord &other) const { _record_size == other._record_size); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_source_pathname -// Access: Published -// Description: Returns the full pathname to the source file that -// originally generated this cache request. In some -// cases, for instance in the case of a of a multipage -// texture like "cube_#.png", this may not not a true -// filename on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to the source file that originally generated this + * cache request. In some cases, for instance in the case of a of a multipage + * texture like "cube_#.png", this may not not a true filename on disk. + */ INLINE const Filename &BamCacheRecord:: get_source_pathname() const { return _source_pathname; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_cache_filename -// Access: Published -// Description: Returns the name of the cache file as hashed from the -// source_pathname. This will be relative to the root -// of the cache directory, and it will not include any -// suffixes that may be appended to resolve hash -// conflicts. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the cache file as hashed from the source_pathname. + * This will be relative to the root of the cache directory, and it will not + * include any suffixes that may be appended to resolve hash conflicts. + */ INLINE const Filename &BamCacheRecord:: get_cache_filename() const { return _cache_filename; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_source_timestamp -// Access: Published -// Description: Returns the file timestamp of the original source -// file that generated this cache record, if available. -// In some cases the original file timestamp is not -// available, and this will return 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the file timestamp of the original source file that generated this + * cache record, if available. In some cases the original file timestamp is + * not available, and this will return 0. + */ INLINE time_t BamCacheRecord:: get_source_timestamp() const { return _source_timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_recorded_time -// Access: Published -// Description: Returns the time at which this particular record was -// recorded or updated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time at which this particular record was recorded or updated. + */ INLINE time_t BamCacheRecord:: get_recorded_time() const { return _recorded_time; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_num_dependent_files -// Access: Published -// Description: Returns the number of source files that contribute to -// the cache. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of source files that contribute to the cache. + */ INLINE int BamCacheRecord:: get_num_dependent_files() const { return _files.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_dependent_pathname -// Access: Published -// Description: Returns the full pathname of the nth source files -// that contributes to the cache. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname of the nth source files that contributes to the + * cache. + */ INLINE const Filename &BamCacheRecord:: get_dependent_pathname(int n) const { nassertr(n >= 0 && n < (int)_files.size(), _files[0]._pathname); return _files[n]._pathname; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::has_data -// Access: Published -// Description: Returns true if this cache record has an in-memory -// data object associated--that is, the object stored in -// the cache. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this cache record has an in-memory data object associated-- + * that is, the object stored in the cache. + */ INLINE bool BamCacheRecord:: has_data() const { return (_ptr != (TypedWritable *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::clear_data -// Access: Published -// Description: Removes the in-memory data object associated with -// this record, if any. This does not affect the -// on-disk representation of the record. -//////////////////////////////////////////////////////////////////// +/** + * Removes the in-memory data object associated with this record, if any. + * This does not affect the on-disk representation of the record. + */ INLINE void BamCacheRecord:: clear_data() { if (_ref_ptr != NULL) { @@ -145,31 +112,24 @@ clear_data() { _ref_ptr = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::get_data -// Access: Published -// Description: Returns a pointer to the data stored in the -// record, or NULL if there is no data. The pointer is -// not removed from the record. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the data stored in the record, or NULL if there is no + * data. The pointer is not removed from the record. + */ INLINE TypedWritable *BamCacheRecord:: get_data() const { return _ptr; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::extract_data -// Access: Published -// Description: Fills ptr and ref_ptr with the two different-typed -// pointers to the same object, the data stored within -// this record. This transfers ownership of the data -// pointer; the caller will be responsible for managing -// the reference counts on this object subsequently. -// -// Returns true if the record contained any data (and -// the pointers have been filled), false if it didn't -// (and the pointers are NULL). -//////////////////////////////////////////////////////////////////// +/** + * Fills ptr and ref_ptr with the two different-typed pointers to the same + * object, the data stored within this record. This transfers ownership of + * the data pointer; the caller will be responsible for managing the reference + * counts on this object subsequently. + * + * Returns true if the record contained any data (and the pointers have been + * filled), false if it didn't (and the pointers are NULL). + */ INLINE bool BamCacheRecord:: extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ptr = _ptr; @@ -178,22 +138,17 @@ extract_data(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { return (ptr != (TypedWritable *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::set_data -// Access: Published -// Description: Stores a new data object on the record. You should -// pass the same pointer twice, to both parameters; this -// allows the C++ typecasting to automatically convert -// the pointer into both a TypedWritable and a -// ReferenceCount pointer, so that the BamCacheRecord -// object can reliably manage the reference counts. -// -// You may pass 0 or NULL as the second parameter. If -// you do this, the BamCacheRecord will not manage the -// object's reference count; it will be up to you to -// ensure the object is not deleted during the lifetime -// of the BamCacheRecord object. -//////////////////////////////////////////////////////////////////// +/** + * Stores a new data object on the record. You should pass the same pointer + * twice, to both parameters; this allows the C++ typecasting to automatically + * convert the pointer into both a TypedWritable and a ReferenceCount pointer, + * so that the BamCacheRecord object can reliably manage the reference counts. + * + * You may pass 0 or NULL as the second parameter. If you do this, the + * BamCacheRecord will not manage the object's reference count; it will be up + * to you to ensure the object is not deleted during the lifetime of the + * BamCacheRecord object. + */ INLINE void BamCacheRecord:: set_data(TypedWritable *ptr, ReferenceCount *ref_ptr) { if (_ptr != ptr) { @@ -206,45 +161,37 @@ set_data(TypedWritable *ptr, ReferenceCount *ref_ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::set_data -// Access: Published -// Description: This variant on set_data() is provided to easily -// pass objects deriving from TypedWritable. -//////////////////////////////////////////////////////////////////// +/** + * This variant on set_data() is provided to easily pass objects deriving from + * TypedWritable. + */ INLINE void BamCacheRecord:: set_data(TypedWritable *ptr) { set_data(ptr, ptr->as_reference_count()); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::set_data -// Access: Published -// Description: This variant on set_data() is provided to easily -// pass objects deriving from TypedWritableReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * This variant on set_data() is provided to easily pass objects deriving from + * TypedWritableReferenceCount. + */ INLINE void BamCacheRecord:: set_data(TypedWritableReferenceCount *ptr) { set_data((TypedWritable *)ptr, (ReferenceCount *)ptr); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::set_data -// Access: Published -// Description: This variant on set_data() is provided just to allow -// Python code to pass a 0 as the second parameter. -//////////////////////////////////////////////////////////////////// +/** + * This variant on set_data() is provided just to allow Python code to pass a + * 0 as the second parameter. + */ INLINE void BamCacheRecord:: set_data(TypedWritable *ptr, int dummy) { nassertv(dummy == 0); set_data(ptr, (ReferenceCount *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::SortByAccessTime::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ INLINE bool BamCacheRecord::SortByAccessTime:: operator () (const BamCacheRecord *a, const BamCacheRecord *b) const { return (a->_record_access_time < b->_record_access_time); diff --git a/panda/src/putil/bamCacheRecord.cxx b/panda/src/putil/bamCacheRecord.cxx index daae57af45..b13f1807ef 100644 --- a/panda/src/putil/bamCacheRecord.cxx +++ b/panda/src/putil/bamCacheRecord.cxx @@ -1,16 +1,15 @@ -// Filename: bamCacheRecord.cxx -// Created by: drose (09Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheRecord.cxx + * @author drose + * @date 2006-06-09 + */ #include "bamCacheRecord.h" #include "bamReader.h" @@ -22,11 +21,9 @@ TypeHandle BamCacheRecord::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::Default Constructor -// Access: Private -// Description: Used when reading from a bam file. -//////////////////////////////////////////////////////////////////// +/** + * Used when reading from a bam file. + */ BamCacheRecord:: BamCacheRecord() : _recorded_time(0), @@ -38,13 +35,11 @@ BamCacheRecord() : { } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::Constructor -// Access: Private -// Description: Use BamCache::lookup() to create one of these. -//////////////////////////////////////////////////////////////////// +/** + * Use BamCache::lookup() to create one of these. + */ BamCacheRecord:: -BamCacheRecord(const Filename &source_pathname, +BamCacheRecord(const Filename &source_pathname, const Filename &cache_filename) : _source_pathname(source_pathname), _cache_filename(cache_filename), @@ -57,12 +52,9 @@ BamCacheRecord(const Filename &source_pathname, { } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::Copy Constructor -// Access: Private -// Description: Use make_copy() to make a copy. The copy does not -// share the data pointer. -//////////////////////////////////////////////////////////////////// +/** + * Use make_copy() to make a copy. The copy does not share the data pointer. + */ BamCacheRecord:: BamCacheRecord(const BamCacheRecord ©) : _source_pathname(copy._source_pathname), @@ -76,23 +68,18 @@ BamCacheRecord(const BamCacheRecord ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamCacheRecord:: ~BamCacheRecord() { clear_data(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::dependents_unchanged -// Access: Published -// Description: Returns true if all of the dependent files are still -// the same as when the cache was recorded, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the dependent files are still the same as when the + * cache was recorded, false otherwise. + */ bool BamCacheRecord:: dependents_unchanged() const { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -126,7 +113,7 @@ dependents_unchanged() const { return false; } } - + // Presumably, the file is unchanged. if (util_cat.is_debug()) { util_cat.debug() @@ -143,26 +130,19 @@ dependents_unchanged() const { } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::clear_dependent_files -// Access: Published -// Description: Empties the list of files that contribute to the data -// in this record. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of files that contribute to the data in this record. + */ void BamCacheRecord:: clear_dependent_files() { _files.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::add_dependent_file -// Access: Published -// Description: Adds the indicated file to the list of files that -// will be loaded to generate the data in this record. -// This should be called once for the primary source -// file, and again for each secondary source file, if -// any. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated file to the list of files that will be loaded to + * generate the data in this record. This should be called once for the + * primary source file, and again for each secondary source file, if any. + */ void BamCacheRecord:: add_dependent_file(const Filename &pathname) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -188,12 +168,9 @@ add_dependent_file(const Filename &pathname) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::add_dependent_file -// Access: Published -// Description: Variant of add_dependent_file that takes an already -// opened VirtualFile. -//////////////////////////////////////////////////////////////////// +/** + * Variant of add_dependent_file that takes an already opened VirtualFile. + */ void BamCacheRecord:: add_dependent_file(const VirtualFile *file) { _files.push_back(DependentFile()); @@ -209,21 +186,17 @@ add_dependent_file(const VirtualFile *file) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BamCacheRecord:: output(ostream &out) const { out << "BamCacheRecord " << get_source_pathname(); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BamCacheRecord:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -245,12 +218,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::format_timestamp -// Access: Private, Static -// Description: Returns a timestamp value formatted nicely for -// output. -//////////////////////////////////////////////////////////////////// +/** + * Returns a timestamp value formatted nicely for output. + */ string BamCacheRecord:: format_timestamp(time_t timestamp) { static const size_t buffer_size = 512; @@ -265,8 +235,8 @@ format_timestamp(time_t timestamp) { struct tm *tm_p = localtime(×tamp); if (timestamp > now || (now - timestamp > 86400 * 365)) { - // A timestamp in the future, or more than a year in the past, - // gets a year appended. + // A timestamp in the future, or more than a year in the past, gets a year + // appended. strftime(buffer, buffer_size, "%b %d %Y", tm_p); } else { // Otherwise, within the past year, show the date and time. @@ -276,23 +246,18 @@ format_timestamp(time_t timestamp) { return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::register_with_read_factory -// Access: Published, Static -// Description: Tells the BamReader how to create objects of type -// BamCacheRecord. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type BamCacheRecord. + */ void BamCacheRecord:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::write_datagram -// Access: Published, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BamCacheRecord:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritableReferenceCount::write_datagram(manager, dg); @@ -311,14 +276,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type BamCacheRecord is encountered -// in the Bam file. It should create the BamCacheRecord -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type BamCacheRecord is encountered in the Bam file. It should create the + * BamCacheRecord and extract its information from the file. + */ TypedWritable *BamCacheRecord:: make_from_bam(const FactoryParams ¶ms) { BamCacheRecord *object = new BamCacheRecord; @@ -331,13 +293,10 @@ make_from_bam(const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: BamCacheRecord::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new BamCacheRecord. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new BamCacheRecord. + */ void BamCacheRecord:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritableReferenceCount::fillin(scan, manager); @@ -356,8 +315,8 @@ fillin(DatagramIterator &scan, BamReader *manager) { file._timestamp = scan.get_uint32(); file._size = scan.get_uint64(); - // If we come across the original source file (we normally expect - // to), record that as its timestamp. + // If we come across the original source file (we normally expect to), + // record that as its timestamp. if (file._pathname == _source_pathname) { _source_timestamp = file._timestamp; } diff --git a/panda/src/putil/bamCacheRecord.h b/panda/src/putil/bamCacheRecord.h index fd3d121e4b..77bccf2fbf 100644 --- a/panda/src/putil/bamCacheRecord.h +++ b/panda/src/putil/bamCacheRecord.h @@ -1,16 +1,15 @@ -// Filename: bamCacheRecord.h -// Created by: drose (08Jun06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamCacheRecord.h + * @author drose + * @date 2006-06-08 + */ #ifndef BAMCACHERECORD_H #define BAMCACHERECORD_H @@ -28,19 +27,16 @@ class FactoryParams; class BamCacheRecord; class VirtualFile; -//////////////////////////////////////////////////////////////////// -// Class : BamCacheRecord -// Description : An instance of this class is written to the front of -// a Bam or Txo file to make the file a cached instance -// of some other loadable resource. This record -// contains information needed to test the validity of -// the cache. -//////////////////////////////////////////////////////////////////// +/** + * An instance of this class is written to the front of a Bam or Txo file to + * make the file a cached instance of some other loadable resource. This + * record contains information needed to test the validity of the cache. + */ class EXPCL_PANDA_PUTIL BamCacheRecord : public TypedWritableReferenceCount, public LinkedListNode { private: BamCacheRecord(); - BamCacheRecord(const Filename &source_pathname, + BamCacheRecord(const Filename &source_pathname, const Filename &cache_filename); BamCacheRecord(const BamCacheRecord ©); @@ -107,16 +103,16 @@ private: typedef pvector DependentFiles; DependentFiles _files; - - // The following are not recorded to disk; they are preserved - // in-memory only for the current session. + + // The following are not recorded to disk; they are preserved in-memory only + // for the current session. Filename _cache_pathname; TypedWritable *_ptr; ReferenceCount *_ref_ptr; - // The following are not recorded to disk, nor even returned by the - // BamCache interface. They are strictly meaningful to the - // BamCacheRecords stored internally within the BamCache object. + // The following are not recorded to disk, nor even returned by the BamCache + // interface. They are strictly meaningful to the BamCacheRecords stored + // internally within the BamCache object. time_t _record_access_time; public: @@ -126,7 +122,7 @@ public: protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/putil/bamEnums.cxx b/panda/src/putil/bamEnums.cxx index abc27be284..292227d359 100644 --- a/panda/src/putil/bamEnums.cxx +++ b/panda/src/putil/bamEnums.cxx @@ -1,16 +1,15 @@ -// Filename: bamEnums.cxx -// Created by: drose (26Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamEnums.cxx + * @author drose + * @date 2009-02-26 + */ #include "bamEnums.h" #include "string_utils.h" @@ -21,7 +20,7 @@ operator << (ostream &out, BamEnums::BamEndian be) { switch (be) { case BamEnums::BE_bigendian: return out << "bigendian"; - + case BamEnums::BE_littleendian: return out << "littleendian"; } @@ -57,7 +56,7 @@ operator << (ostream &out, BamEnums::BamObjectCode boc) { switch (boc) { case BamEnums::BOC_push: return out << "push"; - + case BamEnums::BOC_pop: return out << "pop"; @@ -79,13 +78,13 @@ operator << (ostream &out, BamEnums::BamTextureMode btm) { switch (btm) { case BamEnums::BTM_unchanged: return out << "unchanged"; - + case BamEnums::BTM_fullpath: return out << "fullpath"; - + case BamEnums::BTM_relative: return out << "relative"; - + case BamEnums::BTM_basename: return out << "basename"; diff --git a/panda/src/putil/bamEnums.h b/panda/src/putil/bamEnums.h index 5b7469a473..c2cef20db8 100644 --- a/panda/src/putil/bamEnums.h +++ b/panda/src/putil/bamEnums.h @@ -1,35 +1,33 @@ -// Filename: bamEnums.h -// Created by: drose (26Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamEnums.h + * @author drose + * @date 2009-02-26 + */ #ifndef BAMENUMS_H #define BAMENUMS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : BamEnums -// Description : This class exists just to provide scoping for the -// enums shared by BamReader and BamWriter. -//////////////////////////////////////////////////////////////////// +/** + * This class exists just to provide scoping for the enums shared by BamReader + * and BamWriter. + */ class EXPCL_PANDA_PUTIL BamEnums { PUBLISHED: // This defines an enumerated type used to represent the endianness of - // certain numeric values stored in a Bam file. It really has only - // two possible values, either BE_bigendian or BE_littleendian; but - // through a preprocessor trick we also add BE_native, which is the - // same numerically as whichever value the hardware supports natively. + // certain numeric values stored in a Bam file. It really has only two + // possible values, either BE_bigendian or BE_littleendian; but through a + // preprocessor trick we also add BE_native, which is the same numerically + // as whichever value the hardware supports natively. enum BamEndian { BE_bigendian = 0, BE_littleendian = 1, @@ -40,15 +38,16 @@ PUBLISHED: #endif }; - // This is the code written along with each object. It is used to - // control object scoping. A BOC_push includes an object - // definition, and will always be eventually paired with a BOC_pop - // (which does not). A BOC_adjunct includes an object definition - // but does not push the level; it is associated with the current - // level. BOC_remove lists object ID's that have been deallocated - // on the sender end. BOC_file_data may appear at any level and - // indicates the following datagram contains auxiliary file data - // that may be referenced by a later object. +/* + * This is the code written along with each object. It is used to control + * object scoping. A BOC_push includes an object definition, and will always + * be eventually paired with a BOC_pop (which does not). A BOC_adjunct + * includes an object definition but does not push the level; it is associated + * with the current level. BOC_remove lists object ID's that have been + * deallocated on the sender end. BOC_file_data may appear at any level and + * indicates the following datagram contains auxiliary file data that may be + * referenced by a later object. + */ enum BamObjectCode { BOC_push, BOC_pop, @@ -57,8 +56,7 @@ PUBLISHED: BOC_file_data, }; - // This enum is used to control how textures are written to a bam - // stream. + // This enum is used to control how textures are written to a bam stream. enum BamTextureMode { BTM_unchanged, BTM_fullpath, @@ -77,4 +75,3 @@ EXPCL_PANDA_PUTIL ostream &operator << (ostream &out, BamEnums::BamTextureMode b EXPCL_PANDA_PUTIL istream &operator >> (istream &in, BamEnums::BamTextureMode &btm); #endif - diff --git a/panda/src/putil/bamReader.I b/panda/src/putil/bamReader.I index 96f96681cc..19f1a37a9d 100644 --- a/panda/src/putil/bamReader.I +++ b/panda/src/putil/bamReader.I @@ -1,46 +1,37 @@ -// Filename: bamReader.I -// Created by: jason (12Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReader.I + * @author jason + * @date 2000-06-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamReaderAuxData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReaderAuxData:: BamReaderAuxData() { } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_source -// Access: Published -// Description: Returns the current source of the BamReader as set by -// set_source() or the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current source of the BamReader as set by set_source() or the + * constructor. + */ INLINE DatagramGenerator *BamReader:: get_source() { return _source; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_filename -// Access: Published -// Description: If a BAM is a file, then the BamReader should -// contain the name of the file. This enables the -// reader to interpret pathnames in the BAM as relative -// to the directory containing the BAM. -//////////////////////////////////////////////////////////////////// +/** + * If a BAM is a file, then the BamReader should contain the name of the file. + * This enables the reader to interpret pathnames in the BAM as relative to + * the directory containing the BAM. + */ INLINE const Filename &BamReader:: get_filename() const { if (_source != (DatagramGenerator *)NULL) { @@ -50,165 +41,127 @@ get_filename() const { return empty_filename; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_loader_options -// Access: Published -// Description: Returns the LoaderOptions passed to the loader when -// the model was requested, if any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the LoaderOptions passed to the loader when the model was + * requested, if any. + */ INLINE const LoaderOptions &BamReader:: get_loader_options() const { return _loader_options; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::set_loader_options -// Access: Published -// Description: Specifies the LoaderOptions for this BamReader. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the LoaderOptions for this BamReader. + */ INLINE void BamReader:: set_loader_options(const LoaderOptions &options) { _loader_options = options; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::is_eof -// Access: Published -// Description: Returns true if the reader has reached end-of-file, -// false otherwise. This call is only valid after a -// call to read_object(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the reader has reached end-of-file, false otherwise. This + * call is only valid after a call to read_object(). + */ INLINE bool BamReader:: is_eof() const { nassertr(_source != NULL, true); return _source->is_eof(); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file_major_ver -// Access: Published -// Description: Returns the major version number of the Bam file -// currently being read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number of the Bam file currently being read. + */ INLINE int BamReader:: get_file_major_ver() const { return _file_major; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file_minor_ver -// Access: Published -// Description: Returns the minor version number of the Bam file -// currently being read. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number of the Bam file currently being read. + */ INLINE int BamReader:: get_file_minor_ver() const { return _file_minor; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file_endian -// Access: Published -// Description: Returns the endian preference indicated by the Bam -// file currently being read. This does not imply that -// every number is stored using the indicated -// convention, but individual objects may choose to -// respect this flag when recording data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the endian preference indicated by the Bam file currently being + * read. This does not imply that every number is stored using the indicated + * convention, but individual objects may choose to respect this flag when + * recording data. + */ INLINE BamReader::BamEndian BamReader:: get_file_endian() const { return _file_endian; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file_stdfloat_double -// Access: Published -// Description: Returns true if the file stores all "standard" -// floats as 64-bit doubles, or false if they are 32-bit -// floats. This is determined by the compilation flags -// of the version of Panda that generated this file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file stores all "standard" floats as 64-bit doubles, or + * false if they are 32-bit floats. This is determined by the compilation + * flags of the version of Panda that generated this file. + */ INLINE bool BamReader:: get_file_stdfloat_double() const { return _file_stdfloat_double; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_current_major_ver -// Access: Published -// Description: Returns the major version number of Bam files -// supported by the current code base. This must match -// get_file_major_ver() in order to successfully read a -// file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number of Bam files supported by the current code + * base. This must match get_file_major_ver() in order to successfully read a + * file. + */ INLINE int BamReader:: get_current_major_ver() const { return _cur_major; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_current_minor_ver -// Access: Published -// Description: Returns the minor version number of Bam files -// supported by the current code base. This must match -// or exceed get_file_minor_ver() in order to -// successfully read a file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number of Bam files supported by the current code + * base. This must match or exceed get_file_minor_ver() in order to + * successfully read a file. + */ INLINE int BamReader:: get_current_minor_ver() const { return _cur_minor; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file -// Access: Public -// Description: Returns the FileReference that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a file on disk. + */ INLINE const FileReference *BamReader:: get_file() { nassertr(_source != NULL, NULL); return _source->get_file(); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_vfile -// Access: Public -// Description: Returns the VirtualFile that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a VirtualFile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFile that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a VirtualFile. + */ INLINE VirtualFile *BamReader:: get_vfile() { nassertr(_source != NULL, NULL); return _source->get_vfile(); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_file_pos -// Access: Public -// Description: Returns the current file position within the data -// stream, if any, or 0 if the file position is not -// meaningful or cannot be determined. -// -// For BamReaders that return a meaningful file -// position, this will be pointing to the first byte -// following the datagram returned after a call to -// get_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file position within the data stream, if any, or 0 if + * the file position is not meaningful or cannot be determined. + * + * For BamReaders that return a meaningful file position, this will be + * pointing to the first byte following the datagram returned after a call to + * get_datagram(). + */ INLINE streampos BamReader:: get_file_pos() { nassertr(_source != NULL, 0); return _source->get_file_pos(); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_factory -// Access: Public, Static -// Description: Returns the global WritableFactory for generating -// TypedWritable objects -//////////////////////////////////////////////////////////////////// +/** + * Returns the global WritableFactory for generating TypedWritable objects + */ INLINE WritableFactory *BamReader:: get_factory() { if (_factory == (WritableFactory *)NULL) { @@ -217,23 +170,18 @@ get_factory() { return _factory; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::create_factory -// Access: Private, Static -// Description: Creates a new WritableFactory for generating -// TypedWritable objects -//////////////////////////////////////////////////////////////////// +/** + * Creates a new WritableFactory for generating TypedWritable objects + */ INLINE void BamReader:: create_factory() { _factory = new WritableFactory; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_datagram -// Access: Private -// Description: Reads a single datagram from the stream. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single datagram from the stream. Returns true on success, false on + * failure. + */ INLINE bool BamReader:: get_datagram(Datagram &datagram) { nassertr(_source != NULL, false); @@ -249,20 +197,16 @@ get_datagram(Datagram &datagram) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::AuxData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReader::AuxData:: AuxData() { } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::CreatedObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReader::CreatedObj:: CreatedObj() : _created(false), @@ -273,31 +217,24 @@ CreatedObj() : { } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::CreatedObj::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReader::CreatedObj:: ~CreatedObj() { set_ptr(NULL, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::CreatedObj::set_ptr -// Access: Public -// Description: Replaces the pointer to the created object. There -// are actually two pointers to the same object in -// different forms: a generic TypedWritable pointer, and -// an untyped ReferenceCount pointer. We need both -// pointers because some objects (like PandaNode) -// inherit from TypedWritable and ReferenceCount -// independently. -// -// Managing a typed pointer and an untyped -// ReferenceCount pointer to the same object takes just -// a bit of extra care. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the pointer to the created object. There are actually two + * pointers to the same object in different forms: a generic TypedWritable + * pointer, and an untyped ReferenceCount pointer. We need both pointers + * because some objects (like PandaNode) inherit from TypedWritable and + * ReferenceCount independently. + * + * Managing a typed pointer and an untyped ReferenceCount pointer to the same + * object takes just a bit of extra care. + */ INLINE void BamReader::CreatedObj:: set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { if (_ptr != ptr) { @@ -305,10 +242,10 @@ set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { nassertv(_ref_ptr != ref_ptr); unref_delete(_ref_ptr); } - + _ptr = ptr; _ref_ptr = ref_ptr; - + if (_ref_ptr != NULL) { _ref_ptr->ref(); } @@ -317,15 +254,12 @@ set_ptr(TypedWritable *ptr, ReferenceCount *ref_ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: parse_params -// Access: Private, Static -// Description: Takes in a FactoryParams, passed from a WritableFactory -// into any TypedWritable's make function, and parses -// out the datagram that contatins the data it needs to -// construct itself, and parses out the pointer to the -// managing BamReader object -//////////////////////////////////////////////////////////////////// +/** + * Takes in a FactoryParams, passed from a WritableFactory into any + * TypedWritable's make function, and parses out the datagram that contatins + * the data it needs to construct itself, and parses out the pointer to the + * managing BamReader object + */ INLINE void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager) { @@ -334,4 +268,3 @@ parse_params(const FactoryParams ¶ms, scan = param->get_iterator(); manager = param->get_manager(); } - diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index 21fa7dfa74..a7eaea125c 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -1,16 +1,15 @@ -// Filename: bamReader.cxx -// Created by: jason (12Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReader.cxx + * @author jason + * @date 2000-06-12 + */ #include "pandabase.h" #include "pnotify.h" @@ -33,11 +32,9 @@ const int BamReader::_cur_major = _bam_major_ver; const int BamReader::_cur_minor = _bam_minor_ver; -//////////////////////////////////////////////////////////////////// -// Function: BamReader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamReader:: BamReader(DatagramGenerator *source) : _source(source) @@ -53,24 +50,19 @@ BamReader(DatagramGenerator *source) } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamReader:: ~BamReader() { nassertv(_num_extra_objects == 0); nassertv(_nesting_level == 0); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::set_source -// Access: Published -// Description: Changes the source of future datagrams for this -// BamReader. This also implicitly calls init() if it -// has not already been called. -//////////////////////////////////////////////////////////////////// +/** + * Changes the source of future datagrams for this BamReader. This also + * implicitly calls init() if it has not already been called. + */ void BamReader:: set_source(DatagramGenerator *source) { _source = source; @@ -80,16 +72,13 @@ set_source(DatagramGenerator *source) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::init -// Access: Published -// Description: Initializes the BamReader prior to reading any -// objects from its source. This includes reading the -// Bam header. -// -// This returns true if the BamReader successfully -// initialized, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the BamReader prior to reading any objects from its source. + * This includes reading the Bam header. + * + * This returns true if the BamReader successfully initialized, false + * otherwise. + */ bool BamReader:: init() { nassertr(_source != NULL, false); @@ -112,9 +101,9 @@ init() { _file_major = scan.get_uint16(); _file_minor = scan.get_uint16(); - // If the major version is different, or the minor version is - // *newer*, we can't safely load the file. - if (_file_major != _bam_major_ver || + // If the major version is different, or the minor version is *newer*, we + // can't safely load the file. + if (_file_major != _bam_major_ver || _file_minor < _bam_first_minor_ver || _file_minor > _bam_minor_ver) { bam_cat.error() @@ -151,33 +140,27 @@ init() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::set_aux_data -// Access: Published -// Description: Associates an arbitrary block of data with the -// indicated object (or NULL), and the indicated name. -// -// This is intended to provide a place for temporary -// storage for objects reading themselves from the bam -// file. To use it, inherit from BamReader::AuxData and -// store whatever data you like there. Then associate -// your AuxData with the object as it is being read with -// set_aux_data(). You may later set the aux data to -// NULL to remove it; or it will automatically be -// removed (and deleted) after finalize() is called for -// the object in question. -// -// If the TypedWritable pointer is NULL, the the aux -// data is stored globally for the BamReader in general. -// This pointer is available to any bam objects, and -// will not be automatically removed until the BamReader -// itself destructs. -// -// In either case, the name is just an arbitrary -// user-defined key. If there is already a data pointer -// stored for the obj/name pair, that data pointer will -// be replaced (and deleted). -//////////////////////////////////////////////////////////////////// +/** + * Associates an arbitrary block of data with the indicated object (or NULL), + * and the indicated name. + * + * This is intended to provide a place for temporary storage for objects + * reading themselves from the bam file. To use it, inherit from + * BamReader::AuxData and store whatever data you like there. Then associate + * your AuxData with the object as it is being read with set_aux_data(). You + * may later set the aux data to NULL to remove it; or it will automatically + * be removed (and deleted) after finalize() is called for the object in + * question. + * + * If the TypedWritable pointer is NULL, the the aux data is stored globally + * for the BamReader in general. This pointer is available to any bam + * objects, and will not be automatically removed until the BamReader itself + * destructs. + * + * In either case, the name is just an arbitrary user-defined key. If there + * is already a data pointer stored for the obj/name pair, that data pointer + * will be replaced (and deleted). + */ void BamReader:: set_aux_data(TypedWritable *obj, const string &name, BamReader::AuxData *data) { if (data == (void *)NULL) { @@ -195,13 +178,11 @@ set_aux_data(TypedWritable *obj, const string &name, BamReader::AuxData *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_aux_data -// Access: Published -// Description: Returns the pointer previously associated with the -// bam reader by a previous call to set_aux_data(), or -// NULL if data with the indicated key has not been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer previously associated with the bam reader by a previous + * call to set_aux_data(), or NULL if data with the indicated key has not been + * set. + */ BamReader::AuxData *BamReader:: get_aux_data(TypedWritable *obj, const string &name) const { AuxDataTable::const_iterator ti = _aux_data.find(obj); @@ -217,34 +198,26 @@ get_aux_data(TypedWritable *obj, const string &name) const { } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_object -// Access: Published -// Description: Reads a single object from the Bam file. If the -// object type is known, a new object of the appropriate -// type is created and returned; otherwise, NULL is -// returned. NULL is also returned when the end of the -// file is reached. is_eof() may be called to -// differentiate between these two cases. -// -// This may be called repeatedly to extract out all the -// objects in the Bam file, but typically (especially -// for scene graph files, indicated with the .bam -// extension), only one object is retrieved directly -// from the Bam file: the root of the scene graph. The -// remaining objects will all be retrieved recursively -// by the first object. -// -// Note that the object returned may not yet be -// complete. In particular, some of its pointers may -// not be filled in; you must call resolve() to fill in -// all the available pointers before you can safely use -// any objects returned by read_object(). -// -// This flavor of read_object() requires the caller to -// know what type of object it has received in order to -// properly manage the reference counts. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single object from the Bam file. If the object type is known, a + * new object of the appropriate type is created and returned; otherwise, NULL + * is returned. NULL is also returned when the end of the file is reached. + * is_eof() may be called to differentiate between these two cases. + * + * This may be called repeatedly to extract out all the objects in the Bam + * file, but typically (especially for scene graph files, indicated with the + * .bam extension), only one object is retrieved directly from the Bam file: + * the root of the scene graph. The remaining objects will all be retrieved + * recursively by the first object. + * + * Note that the object returned may not yet be complete. In particular, some + * of its pointers may not be filled in; you must call resolve() to fill in + * all the available pointers before you can safely use any objects returned + * by read_object(). + * + * This flavor of read_object() requires the caller to know what type of + * object it has received in order to properly manage the reference counts. + */ TypedWritable *BamReader:: read_object() { TypedWritable *ptr; @@ -257,18 +230,14 @@ read_object() { return ptr; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_object -// Access: Published -// Description: Reads a single object from the Bam file. -// -// This flavor of read_object() returns both a -// TypedWritable and a ReferenceCount pointer to the -// same object, so the reference count may be tracked -// reliably, without having to know precisely what type -// of object we have. It returns true on success, or -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single object from the Bam file. + * + * This flavor of read_object() returns both a TypedWritable and a + * ReferenceCount pointer to the same object, so the reference count may be + * tracked reliably, without having to know precisely what type of object we + * have. It returns true on success, or false on failure. + */ bool BamReader:: read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { ptr = NULL; @@ -280,26 +249,25 @@ read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { // First, read the base object. int object_id = p_read_object(); - // Now that object might have included some pointers to other - // objects, which may still need to be read. And those objects - // might in turn require reading additional objects. Read all the - // remaining objects. + // Now that object might have included some pointers to other objects, which + // may still need to be read. And those objects might in turn require + // reading additional objects. Read all the remaining objects. - // Prior to 6.21, we kept track of _num_extra_objects to know when - // we're done. + // Prior to 6.21, we kept track of _num_extra_objects to know when we're + // done. while (_num_extra_objects > 0) { p_read_object(); _num_extra_objects--; } - // Beginning with 6.21, we use explicit nesting commands to know - // when we're done. + // Beginning with 6.21, we use explicit nesting commands to know when we're + // done. while (_nesting_level > start_level) { p_read_object(); } - // Now look up the pointer of the object we read first. It should - // be available now. + // Now look up the pointer of the object we read first. It should be + // available now. if (object_id == 0) { if (bam_cat.is_spam()) { bam_cat.spam() @@ -337,24 +305,19 @@ read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::resolve -// Access: Published -// Description: This may be called at any time during processing of -// the Bam file to resolve all the known pointers so -// far. It is usually called at the end of the -// processing, after all objects have been read, which -// is generally the best time to call it. -// -// This must be called at least once after reading a -// particular object via get_object() in order to -// validate that object. -// -// The return value is true if all objects have been -// resolved, or false if some objects are still -// outstanding (in which case you will need to call -// resolve() again later). -//////////////////////////////////////////////////////////////////// +/** + * This may be called at any time during processing of the Bam file to resolve + * all the known pointers so far. It is usually called at the end of the + * processing, after all objects have been read, which is generally the best + * time to call it. + * + * This must be called at least once after reading a particular object via + * get_object() in order to validate that object. + * + * The return value is true if all objects have been resolved, or false if + * some objects are still outstanding (in which case you will need to call + * resolve() again later). + */ bool BamReader:: resolve() { bool all_completed; @@ -367,7 +330,7 @@ resolve() { } all_completed = true; any_completed_this_pass = false; - + ObjectPointers::iterator oi; oi = _object_pointers.begin(); while (oi != _object_pointers.end()) { @@ -378,23 +341,23 @@ resolve() { nassertr(ci != _created_objs.end(), false); CreatedObj &created_obj = (*ci).second; - + TypedWritable *object_ptr = created_obj._ptr; // Update _now_creating, so a call to get_int_tag() from within // complete_pointers() will come to the right place. CreatedObjs::iterator was_creating = _now_creating; _now_creating = ci; - + if (resolve_object_pointers(object_ptr, pref)) { // Now remove this object from the list of things that need - // completion. We have to be a bit careful when deleting things - // from the STL container while we are traversing it. + // completion. We have to be a bit careful when deleting things from + // the STL container while we are traversing it. ObjectPointers::iterator old = oi; ++oi; _object_pointers.erase(old); any_completed_this_pass = true; - + // Does the pointer need to change? if (created_obj._change_this_ref != NULL) { // Reference-counting variant. @@ -412,8 +375,8 @@ resolve() { } _created_objs_by_pointer.erase(object_ptr); - // Remove the pointer from the finalize list (the new - // pointer presumably doesn't require finalizing). + // Remove the pointer from the finalize list (the new pointer + // presumably doesn't require finalizing). _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr); @@ -434,15 +397,15 @@ resolve() { } _created_objs_by_pointer.erase(object_ptr); - // Remove the pointer from the finalize list (the new - // pointer presumably doesn't require finalizing). + // Remove the pointer from the finalize list (the new pointer + // presumably doesn't require finalizing). _finalize_list.erase(object_ptr); } created_obj.set_ptr(new_ptr, new_ptr->as_reference_count()); created_obj._change_this = NULL; created_obj._change_this_ref = NULL; } - + } else { // Couldn't complete this object yet; it'll wait for next time. ++oi; @@ -463,13 +426,12 @@ resolve() { if (all_completed) { finalize(); } else { - // Report all the uncompleted objects for no good reason. This - // will probably have to come out later when we have cases in - // which some objects might legitimately be uncompleted after - // calling resolve(), but for now we expect resolve() to always - // succeed. + // Report all the uncompleted objects for no good reason. This will + // probably have to come out later when we have cases in which some + // objects might legitimately be uncompleted after calling resolve(), but + // for now we expect resolve() to always succeed. ObjectPointers::const_iterator oi; - for (oi = _object_pointers.begin(); + for (oi = _object_pointers.begin(); oi != _object_pointers.end(); ++oi) { int object_id = (*oi).first; @@ -486,19 +448,15 @@ resolve() { return all_completed; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::change_pointer -// Access: Published -// Description: Indicates that an object recently read from the bam -// stream should be replaced with a new object. Any -// future occurrences of the original object in the -// stream will henceforth return the new object instead. -// -// The return value is true if the replacement was -// successfully made, or false if the object was not -// read from the stream (or if change_pointer had -// already been called on it). -//////////////////////////////////////////////////////////////////// +/** + * Indicates that an object recently read from the bam stream should be + * replaced with a new object. Any future occurrences of the original object + * in the stream will henceforth return the new object instead. + * + * The return value is true if the replacement was successfully made, or false + * if the object was not read from the stream (or if change_pointer had + * already been called on it). + */ bool BamReader:: change_pointer(const TypedWritable *orig_pointer, const TypedWritable *new_pointer) { if (orig_pointer == new_pointer) { @@ -512,14 +470,14 @@ change_pointer(const TypedWritable *orig_pointer, const TypedWritable *new_point if (bam_cat.is_spam()) { bam_cat.spam() - << "change_pointer(" << (void *)orig_pointer << ", " + << "change_pointer(" << (void *)orig_pointer << ", " << (void *)new_pointer << ") (" << new_pointer->get_type() << ")\n"; } const vector_int &old_refs = (*ci).second; vector_int &new_refs = _created_objs_by_pointer[new_pointer]; - for (vector_int::const_iterator oi = old_refs.begin(); + for (vector_int::const_iterator oi = old_refs.begin(); oi != old_refs.end(); ++oi) { int object_id = (*oi); @@ -546,23 +504,19 @@ change_pointer(const TypedWritable *orig_pointer, const TypedWritable *new_point } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_handle -// Access: Published -// Description: Reads a TypeHandle out of the Datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads a TypeHandle out of the Datagram. + */ TypeHandle BamReader:: read_handle(DatagramIterator &scan) { - // We encode TypeHandles within the Bam file by writing a unique - // index number for each one to the file. When we write a - // particular TypeHandle for the first time, we assign it a new - // index number and then immediately follow it by its definition; - // when we write the same TypeHandle on subsequent times we only - // write the index number. + // We encode TypeHandles within the Bam file by writing a unique index + // number for each one to the file. When we write a particular TypeHandle + // for the first time, we assign it a new index number and then immediately + // follow it by its definition; when we write the same TypeHandle on + // subsequent times we only write the index number. - // Thus, to read a TypeHandle, we first read the index number. If - // it is a number we have not yet encountered, we must then read the - // definition. + // Thus, to read a TypeHandle, we first read the index number. If it is a + // number we have not yet encountered, we must then read the definition. // Here's the index number. int id = scan.get_uint16(); @@ -574,17 +528,16 @@ read_handle(DatagramIterator &scan) { IndexMap::const_iterator mi = _index_map.find(id); if (mi != _index_map.end()) { - // We've encountered this index number before, so there should be - // no type definition following the id. Simply return the - // TypeHandle we previously associated with the id. + // We've encountered this index number before, so there should be no type + // definition following the id. Simply return the TypeHandle we + // previously associated with the id. TypeHandle type = (*mi).second; return type; } - // We haven't encountered this index number before. This means it - // will be immediately followed by the type definition. This - // consists of the string name, followed by the list of parent - // TypeHandles for this type. + // We haven't encountered this index number before. This means it will be + // immediately followed by the type definition. This consists of the string + // name, followed by the list of parent TypeHandles for this type. string name = scan.get_string(); bool new_type = false; @@ -592,12 +545,11 @@ read_handle(DatagramIterator &scan) { TypeHandle type = TypeRegistry::ptr()->find_type(name); if (type == TypeHandle::none()) { // We've never heard of this type before! This is really an error - // condition, but we'll do the best we can and declare it - // on-the-fly. + // condition, but we'll do the best we can and declare it on-the-fly. type = TypeRegistry::ptr()->register_dynamic_type(name); bam_cat.warning() - << "Bam file '" << get_filename() << "' contains objects of unknown type: " + << "Bam file '" << get_filename() << "' contains objects of unknown type: " << type << "\n"; new_type = true; _new_types.insert(type); @@ -631,33 +583,26 @@ read_handle(DatagramIterator &scan) { return type; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_pointer -// Access: Public -// Description: The interface for reading a pointer to another object -// from a Bam file. Objects reading themselves from a -// Bam file should call this when they expect to read a -// pointer to some other object. This function reads -// whatever is stored in the bam file to represent the -// pointer, and advances the datagram iterator -// accordingly. -// -// Rather than returning a pointer immediately, this -// function reads the internal pointer information from -// the datagram and queues up the request. The pointer -// itself may not be available until later (it may be a -// pointer to an object that appears later in the Bam -// file). Later, when all pointers are available, the -// complete_pointers() callback function will be called -// with an array of actual pointers, one for each time -// read_pointer() was called. It is then the calling -// object's responsibility to store these pointers in the -// object properly. -// -// We don't know what the final pointer will be yet, -// but we do know whether it was NULL, so this method -// returns true if the pointer is non-NULL, false if NULL. -//////////////////////////////////////////////////////////////////// +/** + * The interface for reading a pointer to another object from a Bam file. + * Objects reading themselves from a Bam file should call this when they + * expect to read a pointer to some other object. This function reads + * whatever is stored in the bam file to represent the pointer, and advances + * the datagram iterator accordingly. + * + * Rather than returning a pointer immediately, this function reads the + * internal pointer information from the datagram and queues up the request. + * The pointer itself may not be available until later (it may be a pointer to + * an object that appears later in the Bam file). Later, when all pointers + * are available, the complete_pointers() callback function will be called + * with an array of actual pointers, one for each time read_pointer() was + * called. It is then the calling object's responsibility to store these + * pointers in the object properly. + * + * We don't know what the final pointer will be yet, but we do know whether it + * was NULL, so this method returns true if the pointer is non-NULL, false if + * NULL. + */ bool BamReader:: read_pointer(DatagramIterator &scan) { Thread::consider_yield(); @@ -677,8 +622,8 @@ read_pointer(DatagramIterator &scan) { pref._cycler_pointers[_reading_cycler].push_back(object_id); } - // If the object ID is zero (which indicates a NULL pointer), we - // don't have to do anything else. + // If the object ID is zero (which indicates a NULL pointer), we don't have + // to do anything else. if (object_id != 0) { /* CreatedObj new_created_obj; @@ -686,8 +631,8 @@ read_pointer(DatagramIterator &scan) { */ if (get_file_minor_ver() < 21) { - // Prior to bam version 6.21, we expect to read an adjunct - // object for each non-NULL pointer we read. + // Prior to bam version 6.21, we expect to read an adjunct object for + // each non-NULL pointer we read. _num_extra_objects++; } @@ -697,13 +642,10 @@ read_pointer(DatagramIterator &scan) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_pointers -// Access: Public -// Description: A convenience function to read a contiguous list of -// pointers. This is equivalent to calling -// read_pointer() count times. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to read a contiguous list of pointers. This is + * equivalent to calling read_pointer() count times. + */ void BamReader:: read_pointers(DatagramIterator &scan, int count) { for (int i = 0; i < count; i++) { @@ -711,52 +653,41 @@ read_pointers(DatagramIterator &scan, int count) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::skip_pointer -// Access: Public -// Description: Reads and discards a pointer value from the Bam file. -// This pointer will not be counted among the pointers -// read for a given object, and will not be in the list -// of pointers passed to complete_pointers(). -//////////////////////////////////////////////////////////////////// +/** + * Reads and discards a pointer value from the Bam file. This pointer will + * not be counted among the pointers read for a given object, and will not be + * in the list of pointers passed to complete_pointers(). + */ void BamReader:: skip_pointer(DatagramIterator &scan) { read_object_id(scan); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_file_data -// Access: Public -// Description: Reads a block of auxiliary file data from the Bam -// file. This can be a block of arbitrary size, and it -// is assumed it may be quite large. Rather than -// reading the entire block into memory, a file -// reference is returned to locate the block on disk. -// The data must have been written by a matching call to -// write_file_data(). -//////////////////////////////////////////////////////////////////// +/** + * Reads a block of auxiliary file data from the Bam file. This can be a + * block of arbitrary size, and it is assumed it may be quite large. Rather + * than reading the entire block into memory, a file reference is returned to + * locate the block on disk. The data must have been written by a matching + * call to write_file_data(). + */ void BamReader:: read_file_data(SubfileInfo &info) { - // write_file_data() actually writes the blocks in datagrams prior - // to this particular datagram. Assume we get the calls to - // read_file_data() in the same order as the corresponding calls to - // write_file_data(), and just pop the first one off the - // queue. There's no actual data written to the stream at this - // point. + // write_file_data() actually writes the blocks in datagrams prior to this + // particular datagram. Assume we get the calls to read_file_data() in the + // same order as the corresponding calls to write_file_data(), and just pop + // the first one off the queue. There's no actual data written to the + // stream at this point. nassertv(!_file_data_records.empty()); info = _file_data_records.front(); _file_data_records.pop_front(); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_cdata -// Access: Public -// Description: Reads in the indicated CycleData object. This should -// be used by classes that store some or all of their -// data within a CycleData subclass, in support of -// pipelining. This will call the virtual -// CycleData::fillin() method to do the actual reading. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the indicated CycleData object. This should be used by classes + * that store some or all of their data within a CycleData subclass, in + * support of pipelining. This will call the virtual CycleData::fillin() + * method to do the actual reading. + */ void BamReader:: read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler) { PipelineCyclerBase *old_cycler = _reading_cycler; @@ -767,12 +698,10 @@ read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler) { _reading_cycler = old_cycler; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_cdata -// Access: Public -// Description: This flavor of read_cdata allows passing an -// additional parameter to cdata->fillin(). -//////////////////////////////////////////////////////////////////// +/** + * This flavor of read_cdata allows passing an additional parameter to + * cdata->fillin(). + */ void BamReader:: read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler, void *extra_data) { @@ -784,21 +713,17 @@ read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler, _reading_cycler = old_cycler; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::set_int_tag -// Access: Public -// Description: Allows the creating object to store a temporary data -// value on the BamReader. This method may be called -// during an object's fillin() method; it will associate -// an integer value with an arbitrary string key (which -// is in turn associated with the calling object only). -// Later, in the complete_pointers() method, the same -// object may query this data again via get_int_tag(). -// -// The tag string need not be unique between different -// objects, but it should be unique between an object -// and its CData object(s). -//////////////////////////////////////////////////////////////////// +/** + * Allows the creating object to store a temporary data value on the + * BamReader. This method may be called during an object's fillin() method; + * it will associate an integer value with an arbitrary string key (which is + * in turn associated with the calling object only). Later, in the + * complete_pointers() method, the same object may query this data again via + * get_int_tag(). + * + * The tag string need not be unique between different objects, but it should + * be unique between an object and its CData object(s). + */ void BamReader:: set_int_tag(const string &tag, int value) { nassertv(_now_creating != _created_objs.end()); @@ -808,12 +733,10 @@ set_int_tag(const string &tag, int value) { pref._int_tags[tag] = value; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_int_tag -// Access: Public -// Description: Returns the value previously set via set_int_tag(). -// It is an error if no value has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value previously set via set_int_tag(). It is an error if no + * value has been set. + */ int BamReader:: get_int_tag(const string &tag) const { nassertr(_now_creating != _created_objs.end(), 0); @@ -828,26 +751,20 @@ get_int_tag(const string &tag) const { return (*iti).second; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::set_aux_tag -// Access: Public -// Description: Allows the creating object to store a temporary data -// value on the BamReader. This method may be called -// during an object's fillin() method; it will associate -// a newly-allocated BamReaderAuxData construct with an -// arbitrary string key (which is in turn associated -// with the calling object only). Later, in the -// complete_pointers() method, the same object may query -// this data again via get_aux_tag(). -// -// The BamReader will maintain the reference count on -// the BamReaderAuxData, and destruct it when it is -// cleaned up. -// -// The tag string need not be unique between different -// objects, but it should be unique between an object -// and its CData object(s). -//////////////////////////////////////////////////////////////////// +/** + * Allows the creating object to store a temporary data value on the + * BamReader. This method may be called during an object's fillin() method; + * it will associate a newly-allocated BamReaderAuxData construct with an + * arbitrary string key (which is in turn associated with the calling object + * only). Later, in the complete_pointers() method, the same object may query + * this data again via get_aux_tag(). + * + * The BamReader will maintain the reference count on the BamReaderAuxData, + * and destruct it when it is cleaned up. + * + * The tag string need not be unique between different objects, but it should + * be unique between an object and its CData object(s). + */ void BamReader:: set_aux_tag(const string &tag, BamReaderAuxData *value) { nassertv(_now_creating != _created_objs.end()); @@ -857,12 +774,10 @@ set_aux_tag(const string &tag, BamReaderAuxData *value) { pref._aux_tags[tag] = value; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_aux_tag -// Access: Public -// Description: Returns the value previously set via set_aux_tag(). -// It is an error if no value has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value previously set via set_aux_tag(). It is an error if no + * value has been set. + */ BamReaderAuxData *BamReader:: get_aux_tag(const string &tag) const { nassertr(_now_creating != _created_objs.end(), NULL); @@ -877,19 +792,15 @@ get_aux_tag(const string &tag) const { return (*ati).second; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::register_finalize -// Access: Public -// Description: Should be called by an object reading itself from the -// Bam file to indicate that this particular object -// would like to receive the finalize() callback when -// all the objects and pointers in the Bam file are -// completely read. -// -// This provides a hook for objects that need to do any -// additional finalization work after all of their -// related pointers are guaranteed to be filled in. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by an object reading itself from the Bam file to indicate + * that this particular object would like to receive the finalize() callback + * when all the objects and pointers in the Bam file are completely read. + * + * This provides a hook for objects that need to do any additional + * finalization work after all of their related pointers are guaranteed to be + * filled in. + */ void BamReader:: register_finalize(TypedWritable *whom) { nassertv(whom != (TypedWritable *)NULL); @@ -903,37 +814,33 @@ register_finalize(TypedWritable *whom) { _finalize_list.insert(whom); } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::register_change_this -// Access: Public -// Description: Called by an object reading itself from the bam file -// to indicate that the object pointer that will be -// returned is temporary, and will eventually need to be -// replaced with another pointer. -// -// The supplied function pointer will later be called on -// the object, immediately after complete_pointers() is -// called; it should return the new and final pointer. -// -// We use a static function pointer instead of a virtual -// function (as in finalize()), to allow the function to -// destruct the old pointer if necessary. (It is -// invalid to destruct the this pointer within a virtual -// function.) -//////////////////////////////////////////////////////////////////// +/** + * Called by an object reading itself from the bam file to indicate that the + * object pointer that will be returned is temporary, and will eventually need + * to be replaced with another pointer. + * + * The supplied function pointer will later be called on the object, + * immediately after complete_pointers() is called; it should return the new + * and final pointer. + * + * We use a static function pointer instead of a virtual function (as in + * finalize()), to allow the function to destruct the old pointer if + * necessary. (It is invalid to destruct the this pointer within a virtual + * function.) + */ void BamReader:: register_change_this(ChangeThisFunc func, TypedWritable *object) { nassertv(_now_creating != _created_objs.end()); CreatedObj &created_obj = (*_now_creating).second; #ifndef NDEBUG - // Sanity check the pointer--it should always be the same pointer - // after we set it the first time. + // Sanity check the pointer--it should always be the same pointer after we + // set it the first time. if (created_obj._ptr == (TypedWritable *)NULL) { created_obj.set_ptr(object, object->as_reference_count()); } else { - // We've previously assigned this pointer, and we should have - // assigned it to the same this pointer we have now. + // We've previously assigned this pointer, and we should have assigned it + // to the same this pointer we have now. nassertv(created_obj._ptr == object); } #endif // NDEBUG @@ -942,37 +849,33 @@ register_change_this(ChangeThisFunc func, TypedWritable *object) { created_obj._change_this_ref = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::register_change_this -// Access: Public -// Description: Called by an object reading itself from the bam file -// to indicate that the object pointer that will be -// returned is temporary, and will eventually need to be -// replaced with another pointer. -// -// The supplied function pointer will later be called on -// the object, immediately after complete_pointers() is -// called; it should return the new and final pointer. -// -// We use a static function pointer instead of a virtual -// function (as in finalize()), to allow the function to -// destruct the old pointer if necessary. (It is -// invalid to destruct the this pointer within a virtual -// function.) -//////////////////////////////////////////////////////////////////// +/** + * Called by an object reading itself from the bam file to indicate that the + * object pointer that will be returned is temporary, and will eventually need + * to be replaced with another pointer. + * + * The supplied function pointer will later be called on the object, + * immediately after complete_pointers() is called; it should return the new + * and final pointer. + * + * We use a static function pointer instead of a virtual function (as in + * finalize()), to allow the function to destruct the old pointer if + * necessary. (It is invalid to destruct the this pointer within a virtual + * function.) + */ void BamReader:: register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object) { nassertv(_now_creating != _created_objs.end()); CreatedObj &created_obj = (*_now_creating).second; #ifndef NDEBUG - // Sanity check the pointer--it should always be the same pointer - // after we set it the first time. + // Sanity check the pointer--it should always be the same pointer after we + // set it the first time. if (created_obj._ptr == (TypedWritable *)NULL) { created_obj.set_ptr(object, object); } else { - // We've previously assigned this pointer, and we should have - // assigned it to the same this pointer we have now. + // We've previously assigned this pointer, and we should have assigned it + // to the same this pointer we have now. nassertv(created_obj._ptr == object); nassertv(created_obj._ref_ptr == object); } @@ -982,14 +885,11 @@ register_change_this(ChangeThisRefFunc func, TypedWritableReferenceCount *object created_obj._change_this_ref = func; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::finalize_now -// Access: Public -// Description: Forces the finalization of a particular object. This -// may be called by any of the objects during -// finalization, to guarantee finalization ordering -// where it is important. -//////////////////////////////////////////////////////////////////// +/** + * Forces the finalization of a particular object. This may be called by any + * of the objects during finalization, to guarantee finalization ordering + * where it is important. + */ void BamReader:: finalize_now(TypedWritable *whom) { if (whom == (TypedWritable *)NULL) { @@ -1008,45 +908,39 @@ finalize_now(TypedWritable *whom) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::get_pta -// Access: Public -// Description: This function works in conjection with -// register_pta(), below, to read a PointerToArray (PTA) -// from the Bam file, and unify references to the same -// PTA. -// -// The first time get_pta() encounters a particular PTA, -// it will return NULL. This is the indication that the -// caller should then read in the data associated with -// the PTA, and subsequently call register_pta() with -// the address of the filled-in array. -// -// The next time (and all subsequent times) that -// get_pta() encounters this same PTA, it will return -// the pointer that was passed with register_pta(). -// -// Also see the READ_PTA() macro, which consolidates all -// the work that must be done to read a PTA. -//////////////////////////////////////////////////////////////////// +/** + * This function works in conjection with register_pta(), below, to read a + * PointerToArray (PTA) from the Bam file, and unify references to the same + * PTA. + * + * The first time get_pta() encounters a particular PTA, it will return NULL. + * This is the indication that the caller should then read in the data + * associated with the PTA, and subsequently call register_pta() with the + * address of the filled-in array. + * + * The next time (and all subsequent times) that get_pta() encounters this + * same PTA, it will return the pointer that was passed with register_pta(). + * + * Also see the READ_PTA() macro, which consolidates all the work that must be + * done to read a PTA. + */ void *BamReader:: get_pta(DatagramIterator &scan) { nassertr(_pta_id == -1, (void *)NULL); int id = read_pta_id(scan); if (id == 0) { - // As always, a 0 ID indicates a NULL pointer. The caller will - // not be able to differentiate this case from that of a - // previously-read pointer, but that's OK because the next data in - // the Bam file is the length of the array, which will be - // zero--indicating an empty or NULL array. + // As always, a 0 ID indicates a NULL pointer. The caller will not be + // able to differentiate this case from that of a previously-read pointer, + // but that's OK because the next data in the Bam file is the length of + // the array, which will be zero--indicating an empty or NULL array. return (void *)NULL; } PTAMap::iterator pi = _pta_map.find(id); if (pi == _pta_map.end()) { - // This is the first time we've encountered this particular ID, - // meaning we need to read the data now and register it. + // This is the first time we've encountered this particular ID, meaning we + // need to read the data now and register it. _pta_id = id; return (void *)NULL; } @@ -1054,19 +948,15 @@ get_pta(DatagramIterator &scan) { return (*pi).second; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::register_pta -// Access: Public -// Description: The second part of read_pta(), this should be called -// with the pointer to the array that was read in after -// read_pta() returned NULL. This associates the -// pointer with the ID that was previously read, so that -// future calls to read_pta() will return the same -// pointer. -// -// Also see the READ_PTA() macro, which consolidates all -// the work that must be done to read a PTA. -//////////////////////////////////////////////////////////////////// +/** + * The second part of read_pta(), this should be called with the pointer to + * the array that was read in after read_pta() returned NULL. This associates + * the pointer with the ID that was previously read, so that future calls to + * read_pta() will return the same pointer. + * + * Also see the READ_PTA() macro, which consolidates all the work that must be + * done to read a PTA. + */ void BamReader:: register_pta(void *ptr) { if (_pta_id != -1) { @@ -1076,18 +966,15 @@ register_pta(void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::free_object_ids -// Access: Private -// Description: Handles a record that begins with the _remove_flag -// TypeHandle; this contains a list of object ID's that -// will no longer be used in this file and can safely be -// removed. -//////////////////////////////////////////////////////////////////// +/** + * Handles a record that begins with the _remove_flag TypeHandle; this + * contains a list of object ID's that will no longer be used in this file and + * can safely be removed. + */ void BamReader:: free_object_ids(DatagramIterator &scan) { - // We have to fully complete any objects before we remove them. - // Might as well try to complete everything before we get started. + // We have to fully complete any objects before we remove them. Might as + // well try to complete everything before we get started. resolve(); while (scan.get_remaining_size() > 0) { @@ -1115,11 +1002,9 @@ free_object_ids(DatagramIterator &scan) { } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_object_id -// Access: Private -// Description: Reads an object id from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads an object id from the datagram. + */ int BamReader:: read_object_id(DatagramIterator &scan) { int object_id; @@ -1137,11 +1022,9 @@ read_object_id(DatagramIterator &scan) { return object_id; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::read_pta_id -// Access: Private -// Description: Reads an pta id from the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reads an pta id from the datagram. + */ int BamReader:: read_pta_id(DatagramIterator &scan) { int pta_id; @@ -1159,13 +1042,10 @@ read_pta_id(DatagramIterator &scan) { return pta_id; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::p_read_object -// Access: Private -// Description: The private implementation of read_object(); this -// reads an object from the file and returns its object -// ID. -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of read_object(); this reads an object from the + * file and returns its object ID. + */ int BamReader:: p_read_object() { Datagram dg; @@ -1183,8 +1063,8 @@ p_read_object() { // Now extract the object definition from the datagram. DatagramIterator scan(dg); - // First, read the BamObjectCode. In bam versions prior to 6.21, - // there was no BamObjectCode in the stream. + // First, read the BamObjectCode. In bam versions prior to 6.21, there was + // no BamObjectCode in the stream. BamObjectCode boc = BOC_adjunct; if (get_file_minor_ver() >= 21) { boc = (BamObjectCode)scan.get_uint8(); @@ -1202,21 +1082,20 @@ p_read_object() { break; case BOC_remove: - // The BOC_remove code is a special case; it begins a - // record that simply lists all of the object ID's that are no - // longer important to the file and may be released. + // The BOC_remove code is a special case; it begins a record that simply + // lists all of the object ID's that are no longer important to the file + // and may be released. free_object_ids(scan); - // Now that we've freed all of the object id's indicate, read the - // next object id in the stream. It's easiest to do this by - // calling recursively. + // Now that we've freed all of the object id's indicate, read the next + // object id in the stream. It's easiest to do this by calling + // recursively. return p_read_object(); case BOC_file_data: - // Another special case. This marks an auxiliary file data record - // that we skip over for now, but we note its position within the - // stream, so that we can hand it to a future object who may - // request it. + // Another special case. This marks an auxiliary file data record that we + // skip over for now, but we note its position within the stream, so that + // we can hand it to a future object who may request it. { SubfileInfo info; if (!_source->save_datagram(info)) { @@ -1235,11 +1114,10 @@ p_read_object() { return 0; } - // An object definition in a Bam file consists of a TypeHandle - // definition, defining the object's type, followed by an object ID - // index, defining the particular instance (e.g. pointer) of this - // object. - + // An object definition in a Bam file consists of a TypeHandle definition, + // defining the object's type, followed by an object ID index, defining the + // particular instance (e.g. pointer) of this object. + TypeHandle type = read_handle(scan); int object_id = read_object_id(scan); @@ -1250,42 +1128,40 @@ p_read_object() { return 0; } - // There are two cases (not counting the special _remove_flag case, - // above). Either this is a new object definition, or this is a - // reference to an object that was previously defined. + // There are two cases (not counting the special _remove_flag case, above). + // Either this is a new object definition, or this is a reference to an + // object that was previously defined. - // We use the TypeHandle to differentiate these two cases. By - // convention, we write a TypeHandle::none() to the Bam file when we - // are writing a reference to a previously-defined object, but we - // write the object's actual type when we are writing its definition - // right now. + // We use the TypeHandle to differentiate these two cases. By convention, + // we write a TypeHandle::none() to the Bam file when we are writing a + // reference to a previously-defined object, but we write the object's + // actual type when we are writing its definition right now. - // Therefore, if the type is TypeHandle::none(), then we must have - // already read in and created the object (although its pointers may - // not be fully instantiated yet). On the other hand, if the type - // is anything else, then we must read the definition to follow. + // Therefore, if the type is TypeHandle::none(), then we must have already + // read in and created the object (although its pointers may not be fully + // instantiated yet). On the other hand, if the type is anything else, then + // we must read the definition to follow. if (type != TypeHandle::none()) { // Now we are going to read and create a new object. - // First, we must add an entry into the map for this object ID, so - // that in case this function is called recursively during the - // object's factory constructor, we will have some definition for - // the object. For now, we give it a NULL pointer. + // First, we must add an entry into the map for this object ID, so that in + // case this function is called recursively during the object's factory + // constructor, we will have some definition for the object. For now, we + // give it a NULL pointer. CreatedObj new_created_obj; CreatedObjs::iterator oi = _created_objs.insert(CreatedObjs::value_type(object_id, new_created_obj)).first; CreatedObj &created_obj = (*oi).second; if (created_obj._ptr != NULL) { - // This object had already existed; thus, we are just receiving - // an update for it. + // This object had already existed; thus, we are just receiving an + // update for it. - // Update _now_creating during this call so if this function - // calls read_pointer() or register_change_this() we'll match it - // up properly. This might recursively call back into this - // p_read_object(), so be sure to save and restore the original - // value of _now_creating. + // Update _now_creating during this call so if this function calls + // read_pointer() or register_change_this() we'll match it up properly. + // This might recursively call back into this p_read_object(), so be + // sure to save and restore the original value of _now_creating. CreatedObjs::iterator was_creating = _now_creating; _now_creating = oi; created_obj._ptr->fillin(scan, this); @@ -1298,21 +1174,20 @@ p_read_object() { } } else { - // We are receiving a new object. Now we can call the factory - // to create the object. + // We are receiving a new object. Now we can call the factory to create + // the object. // Define the parameters for passing to the object factory. FactoryParams fparams; fparams.add_param(new BamReaderParam(scan, this)); - - // As above, we update and preserve _now_creating during this - // call. + + // As above, we update and preserve _now_creating during this call. CreatedObjs::iterator was_creating = _now_creating; _now_creating = oi; TypedWritable *object = _factory->make_instance_more_general(type, fparams); _now_creating = was_creating; - + // And now we can store the new object pointer in the map. nassertr(created_obj._ptr == object || created_obj._ptr == NULL, object_id); if (object == NULL) { @@ -1323,10 +1198,9 @@ p_read_object() { created_obj._created = true; if (created_obj._change_this_ref != NULL) { - // If the pointer is scheduled to change after - // complete_pointers(), but we have no entry in - // _object_pointers for this object (and hence no plan to call - // complete_pointers()), then just change the pointer + // If the pointer is scheduled to change after complete_pointers(), + // but we have no entry in _object_pointers for this object (and hence + // no plan to call complete_pointers()), then just change the pointer // immediately. ObjectPointers::const_iterator ri = _object_pointers.find(object_id); if (ri == _object_pointers.end()) { @@ -1335,15 +1209,15 @@ p_read_object() { created_obj.set_ptr(object_ref, object_ref); created_obj._change_this = NULL; created_obj._change_this_ref = NULL; - - // Remove the pointer from the finalize list (the new - // pointer presumably doesn't require finalizing). + + // Remove the pointer from the finalize list (the new pointer + // presumably doesn't require finalizing). if (new_ptr != object) { _finalize_list.erase(object); } object = new_ptr; } - + } else if (created_obj._change_this != NULL) { // Non-reference-counting variant. ObjectPointers::const_iterator ri = _object_pointers.find(object_id); @@ -1359,7 +1233,7 @@ p_read_object() { object = new_ptr; } } - + _created_objs_by_pointer[created_obj._ptr].push_back(object_id); // Just some sanity checks @@ -1371,25 +1245,25 @@ p_read_object() { } else if (object->get_type() != type) { if (_new_types.find(type) != _new_types.end()) { - // This was a type we hadn't heard of before, so it's not - // really surprising we didn't know how to create it. - // Suppress the warning (make it a debug statement instead). + // This was a type we hadn't heard of before, so it's not really + // surprising we didn't know how to create it. Suppress the warning + // (make it a debug statement instead). if (bam_cat.is_debug()) { bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ << " was created instead." << endl; } - + } else { - // This was a normal type that we should have known how to - // create. Report the error. + // This was a normal type that we should have known how to create. + // Report the error. bam_cat.warning() << "Attempted to create a " << type.get_name() \ << " but a " << object->get_type() \ << " was created instead." << endl; } - + } else { if (bam_cat.is_spam()) { bam_cat.spam() @@ -1409,37 +1283,34 @@ p_read_object() { return object_id; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::resolve_object_pointers -// Access: Private -// Description: Checks whether all of the pointers a particular -// object is waiting for have been filled in yet. If -// they have, calls complete_pointers() on the object -// and returns true; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether all of the pointers a particular object is waiting for have + * been filled in yet. If they have, calls complete_pointers() on the object + * and returns true; otherwise, returns false. + */ bool BamReader:: -resolve_object_pointers(TypedWritable *object, +resolve_object_pointers(TypedWritable *object, BamReader::PointerReference &pref) { - // Some objects further require all of their nested objects to have - // been completed (i.e. complete_pointers has been called on each - // nested object) before they can themselves be completed. + // Some objects further require all of their nested objects to have been + // completed (i.e. complete_pointers has been called on each nested object) + // before they can themselves be completed. bool require_fully_complete = object->require_fully_complete(); - // First do the PipelineCycler objects. + // First do the PipelineCycler objects. CyclerPointers::iterator ci; ci = pref._cycler_pointers.begin(); while (ci != pref._cycler_pointers.end()) { PipelineCyclerBase *cycler = (*ci).first; const vector_int &pointer_ids = (*ci).second; - + if (resolve_cycler_pointers(cycler, pointer_ids, require_fully_complete)) { - // Now remove this cycler from the list of things that need - // completion. We have to be a bit careful when deleting things - // from the STL container while we are traversing it. + // Now remove this cycler from the list of things that need completion. + // We have to be a bit careful when deleting things from the STL + // container while we are traversing it. CyclerPointers::iterator old = ci; ++ci; pref._cycler_pointers.erase(old); - + } else { // Couldn't complete this cycler yet; it'll wait for next time. ++ci; @@ -1455,26 +1326,25 @@ resolve_object_pointers(TypedWritable *object, } return false; } - - // Now make sure we have all of the pointers this object is - // waiting for. If any of the pointers has not yet been read - // in, we can't resolve this object--we can't do anything for a - // given object until we have *all* outstanding pointers for - // that object. + + // Now make sure we have all of the pointers this object is waiting for. If + // any of the pointers has not yet been read in, we can't resolve this + // object--we can't do anything for a given object until we have *all* + // outstanding pointers for that object. bool is_complete = true; vector_typedWritable references; references.reserve(pref._objects.size()); vector_int::const_iterator pi; - for (pi = pref._objects.begin(); - pi != pref._objects.end() && is_complete; + for (pi = pref._objects.begin(); + pi != pref._objects.end() && is_complete; ++pi) { int child_id = (*pi); if (child_id == 0) { // A NULL pointer is a NULL pointer. references.push_back((TypedWritable *)NULL); - + } else { // See if we have the pointer available now. CreatedObjs::const_iterator oi = _created_objs.find(child_id); @@ -1491,11 +1361,11 @@ resolve_object_pointers(TypedWritable *object, // It's been created, but the pointer might still change. is_complete = false; } else { - if (require_fully_complete && + if (require_fully_complete && _object_pointers.find(child_id) != _object_pointers.end()) { // It's not yet complete itself. is_complete = false; - + } else { // Yes, it's ready. references.push_back(child_obj._ptr); @@ -1504,7 +1374,7 @@ resolve_object_pointers(TypedWritable *object, } } } - + if (is_complete) { // Okay, here's the complete list of pointers for you! nassertr(references.size() == pref._objects.size(), false); @@ -1538,35 +1408,31 @@ resolve_object_pointers(TypedWritable *object, return false; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::resolve_cycler_pointers -// Access: Private -// Description: Checks whether all of the pointers a particular -// PipelineCycler is waiting for have been filled in -// yet. If they have, calls complete_pointers() on the -// cycler and returns true; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether all of the pointers a particular PipelineCycler is waiting + * for have been filled in yet. If they have, calls complete_pointers() on + * the cycler and returns true; otherwise, returns false. + */ bool BamReader:: resolve_cycler_pointers(PipelineCyclerBase *cycler, const vector_int &pointer_ids, bool require_fully_complete) { - // Now make sure we have all of the pointers this cycler is - // waiting for. If any of the pointers has not yet been read - // in, we can't resolve this cycler--we can't do anything for a - // given cycler until we have *all* outstanding pointers for - // that cycler. - + // Now make sure we have all of the pointers this cycler is waiting for. If + // any of the pointers has not yet been read in, we can't resolve this + // cycler--we can't do anything for a given cycler until we have *all* + // outstanding pointers for that cycler. + bool is_complete = true; vector_typedWritable references; - + vector_int::const_iterator pi; for (pi = pointer_ids.begin(); pi != pointer_ids.end() && is_complete; ++pi) { int child_id = (*pi); - + if (child_id == 0) { // A NULL pointer is a NULL pointer. references.push_back((TypedWritable *)NULL); - + } else { // See if we have the pointer available now. CreatedObjs::const_iterator oi = _created_objs.find(child_id); @@ -1581,11 +1447,11 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, is_complete = false; } else { - if (require_fully_complete && + if (require_fully_complete && _object_pointers.find(child_id) != _object_pointers.end()) { // It's not yet complete itself. is_complete = false; - + } else { // Yes, it's ready. references.push_back(child_obj._ptr); @@ -1594,7 +1460,7 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, } } } - + if (is_complete) { // Okay, here's the complete list of pointers for you! CycleData *cdata = cycler->write(Thread::get_current_thread()); @@ -1617,13 +1483,10 @@ resolve_cycler_pointers(PipelineCyclerBase *cycler, return false; } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::finalize -// Access: Private -// Description: Should be called after all objects have been read, -// this will finalize all the objects that registered -// themselves for the finalize callback. -//////////////////////////////////////////////////////////////////// +/** + * Should be called after all objects have been read, this will finalize all + * the objects that registered themselves for the finalize callback. + */ void BamReader:: finalize() { if (bam_cat.is_debug()) { @@ -1654,7 +1517,7 @@ finalize() { if (_aux_data.size() > 1) { // Move the NULL data to the new table; remove the rest. AuxDataTable new_aux_data; - AuxDataTable::iterator nti = + AuxDataTable::iterator nti = new_aux_data.insert(AuxDataTable::value_type((TypedWritable *)NULL, AuxDataNames())).first; (*nti).second.swap((*ti).second); _aux_data.swap(new_aux_data); @@ -1666,12 +1529,9 @@ finalize() { } } -//////////////////////////////////////////////////////////////////// -// Function: BamReader::AuxData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamReader::AuxData:: ~AuxData() { } - diff --git a/panda/src/putil/bamReader.h b/panda/src/putil/bamReader.h index dba9a1170b..885fddaffb 100644 --- a/panda/src/putil/bamReader.h +++ b/panda/src/putil/bamReader.h @@ -1,16 +1,15 @@ -// Filename: bamReader.h -// Created by: jason (12Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReader.h + * @author jason + * @date 2000-06-12 + */ #ifndef __BAM_READER_ #define __BAM_READER_ @@ -54,13 +53,11 @@ } \ } -//////////////////////////////////////////////////////////////////// -// Class : BamReaderAuxData -// Description : Stores auxiliary data that may be piggybacked on the -// BamReader during each object's read pass. To use -// this, subclass BamReaderAuxData and add whatever -// additional data you require. -//////////////////////////////////////////////////////////////////// +/** + * Stores auxiliary data that may be piggybacked on the BamReader during each + * object's read pass. To use this, subclass BamReaderAuxData and add + * whatever additional data you require. + */ class EXPCL_PANDA_PGRAPH BamReaderAuxData : public TypedReferenceCount { public: INLINE BamReaderAuxData(); @@ -83,42 +80,33 @@ public: private: static TypeHandle _type_handle; -}; +}; -//////////////////////////////////////////////////////////////////// -// Class : BamReader -// Description : This is the fundamental interface for extracting -// binary objects from a Bam file, as generated by a -// BamWriter. -// -// A Bam file can be thought of as a linear collection -// of objects. Each object is an instance of a class -// that inherits, directly or indirectly, from -// TypedWritable. The objects may include pointers to -// other objects within the Bam file; the BamReader -// automatically manages these (with help from code -// within each class) and restores the pointers -// correctly. -// -// This is the abstract interface and does not -// specifically deal with disk files, but rather with a -// DatagramGenerator of some kind, which is simply a -// linear source of Datagrams. It is probably from a -// disk file, but it might conceivably be streamed -// directly from a network or some such nonsense. -// -// Bam files are most often used to store scene graphs -// or subgraphs, and by convention they are given -// filenames ending in the extension ".bam" when they -// are used for this purpose. However, a Bam file may -// store any arbitrary list of TypedWritable objects; -// in this more general usage, they are given filenames -// ending in ".boo" to differentiate them from the more -// common scene graph files. -// -// See also BamFile, which defines a higher-level -// interface to read and write Bam files on disk. -//////////////////////////////////////////////////////////////////// +/** + * This is the fundamental interface for extracting binary objects from a Bam + * file, as generated by a BamWriter. + * + * A Bam file can be thought of as a linear collection of objects. Each + * object is an instance of a class that inherits, directly or indirectly, + * from TypedWritable. The objects may include pointers to other objects + * within the Bam file; the BamReader automatically manages these (with help + * from code within each class) and restores the pointers correctly. + * + * This is the abstract interface and does not specifically deal with disk + * files, but rather with a DatagramGenerator of some kind, which is simply a + * linear source of Datagrams. It is probably from a disk file, but it might + * conceivably be streamed directly from a network or some such nonsense. + * + * Bam files are most often used to store scene graphs or subgraphs, and by + * convention they are given filenames ending in the extension ".bam" when + * they are used for this purpose. However, a Bam file may store any + * arbitrary list of TypedWritable objects; in this more general usage, they + * are given filenames ending in ".boo" to differentiate them from the more + * common scene graph files. + * + * See also BamFile, which defines a higher-level interface to read and write + * Bam files on disk. + */ class EXPCL_PANDA_PUTIL BamReader : public BamEnums { public: typedef Factory WritableFactory; @@ -225,9 +213,9 @@ private: INLINE bool get_datagram(Datagram &datagram); public: - // Inherit from this class to piggyback additional temporary data on - // the bamReader (via set_aux_data() and get_aux_data()) for any - // particular objects during the bam reading process. + // Inherit from this class to piggyback additional temporary data on the + // bamReader (via set_aux_data() and get_aux_data()) for any particular + // objects during the bam reading process. class AuxData : public ReferenceCount { public: INLINE AuxData(); @@ -239,19 +227,19 @@ private: DatagramGenerator *_source; bool _needs_init; - + bool _long_object_id; bool _long_pta_id; - // This maps the type index numbers encountered within the Bam file - // to actual TypeHandles. + // This maps the type index numbers encountered within the Bam file to + // actual TypeHandles. typedef phash_map IndexMap; IndexMap _index_map; LoaderOptions _loader_options; - // This maps the object ID numbers encountered within the Bam file - // to the actual pointers of the corresponding generated objects. + // This maps the object ID numbers encountered within the Bam file to the + // actual pointers of the corresponding generated objects. class CreatedObj { public: INLINE CreatedObj(); @@ -267,23 +255,23 @@ private: }; typedef phash_map CreatedObjs; CreatedObjs _created_objs; - // This is the iterator into the above map for the object we are - // currently reading in p_read_object(). It is carefully maintained - // during recursion. We need this so we can associate - // read_pointer() calls with the proper objects. + // This is the iterator into the above map for the object we are currently + // reading in p_read_object(). It is carefully maintained during recursion. + // We need this so we can associate read_pointer() calls with the proper + // objects. CreatedObjs::iterator _now_creating; - // This is the pointer to the current PipelineCycler we are reading, - // if we are within a read_cdata() call. + // This is the pointer to the current PipelineCycler we are reading, if we + // are within a read_cdata() call. PipelineCyclerBase *_reading_cycler; // This is the reverse lookup into the above map. typedef phash_map CreatedObjsByPointer; CreatedObjsByPointer _created_objs_by_pointer; - // This records all the objects that still need their pointers - // completed, along with the object ID's of the pointers they need, - // in the order in which read_pointer() was called, so that we may - // call the appropriate complete_pointers() later. + // This records all the objects that still need their pointers completed, + // along with the object ID's of the pointers they need, in the order in + // which read_pointer() was called, so that we may call the appropriate + // complete_pointers() later. typedef phash_map CyclerPointers; typedef pmap IntTags; typedef pmap AuxTags; @@ -297,15 +285,14 @@ private: typedef phash_map ObjectPointers; ObjectPointers _object_pointers; - // This is the number of extra objects that must still be read (and - // saved in the _created_objs map) before returning from - // read_object(). It is only used when read bam versions prior to - // 6.20. + // This is the number of extra objects that must still be read (and saved in + // the _created_objs map) before returning from read_object(). It is only + // used when read bam versions prior to 6.20. int _num_extra_objects; - // The current nesting level. We are not done reading an object - // until we return to our starting nesting level. It is only used - // when reading bam versions of 6.20 or higher. + // The current nesting level. We are not done reading an object until we + // return to our starting nesting level. It is only used when reading bam + // versions of 6.20 or higher. int _nesting_level; // This is the set of all objects that registered themselves for @@ -319,16 +306,15 @@ private: PTAMap _pta_map; int _pta_id; - // This is a queue of the currently-pending file data blocks that we - // have recently encountered in the stream and still expect a - // subsequent object to request. + // This is a queue of the currently-pending file data blocks that we have + // recently encountered in the stream and still expect a subsequent object + // to request. typedef pdeque FileDataRecords; FileDataRecords _file_data_records; - // This is used internally to record all of the new types created - // on-the-fly to satisfy bam requirements. We keep track of this - // just so we can suppress warning messages from attempts to create - // objects of these types. + // This is used internally to record all of the new types created on-the-fly + // to satisfy bam requirements. We keep track of this just so we can + // suppress warning messages from attempts to create objects of these types. typedef phash_set NewTypes; static NewTypes _new_types; @@ -346,10 +332,9 @@ private: typedef BamReader::WritableFactory WritableFactory; -// Useful function for taking apart the Factory Params in the static -// functions that need to be defined in each writable class that will -// be generated by a factory. Sets the DatagramIterator and the -// BamReader pointers. +// Useful function for taking apart the Factory Params in the static functions +// that need to be defined in each writable class that will be generated by a +// factory. Sets the DatagramIterator and the BamReader pointers. INLINE void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager); diff --git a/panda/src/putil/bamReaderParam.I b/panda/src/putil/bamReaderParam.I index 813b899bfe..9913332f2c 100644 --- a/panda/src/putil/bamReaderParam.I +++ b/panda/src/putil/bamReaderParam.I @@ -1,45 +1,36 @@ -// Filename: bamReaderParam.I -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReaderParam.I + * @author jason + * @date 2000-06-13 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: BamReaderParam::get_iterator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const DatagramIterator &BamReaderParam:: get_iterator() { return _iterator; } -//////////////////////////////////////////////////////////////////// -// Function: BamReaderParam::get_manager -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReader *BamReaderParam:: get_manager() { return _manager; } -//////////////////////////////////////////////////////////////////// -// Function: BamReaderParam::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReaderParam:: BamReaderParam(const DatagramIterator &dgi, BamReader *manager) : _iterator(dgi), @@ -47,11 +38,9 @@ BamReaderParam(const DatagramIterator &dgi, BamReader *manager) : { } -//////////////////////////////////////////////////////////////////// -// Function: BamReaderParam::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BamReaderParam:: ~BamReaderParam() { } diff --git a/panda/src/putil/bamReaderParam.cxx b/panda/src/putil/bamReaderParam.cxx index af8ec70785..9fd4448654 100644 --- a/panda/src/putil/bamReaderParam.cxx +++ b/panda/src/putil/bamReaderParam.cxx @@ -1,16 +1,15 @@ -// Filename: bamReaderParam.cxx -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReaderParam.cxx + * @author jason + * @date 2000-06-13 + */ #include "bamReaderParam.h" diff --git a/panda/src/putil/bamReaderParam.h b/panda/src/putil/bamReaderParam.h index 694e106cb4..a935de3dbe 100644 --- a/panda/src/putil/bamReaderParam.h +++ b/panda/src/putil/bamReaderParam.h @@ -1,16 +1,15 @@ -// Filename: bamReaderParam.h -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamReaderParam.h + * @author jason + * @date 2000-06-13 + */ #ifndef BAMREADERPARAM_H #define BAMREADERPARAM_H @@ -22,11 +21,10 @@ class BamReader; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : BamReaderParam -// Description : The parameters that are passed through the Factory to -// any object constructing itself from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * The parameters that are passed through the Factory to any object + * constructing itself from a Bam file. + */ class EXPCL_PANDA_PUTIL BamReaderParam : public FactoryParam { public: INLINE const DatagramIterator &get_iterator(); @@ -61,4 +59,3 @@ private: #include "bamReaderParam.I" #endif - diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index 555eb9abb1..65335d5bac 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -1,37 +1,30 @@ -// Filename: bamWriter.I -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamWriter.I + * @author jason + * @date 2000-06-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_target -// Access: Published -// Description: Returns the current target of the BamWriter as set by -// set_target() or the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current target of the BamWriter as set by set_target() or the + * constructor. + */ INLINE DatagramSink *BamWriter:: get_target() { return _target; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_filename -// Access: Published -// Description: If a BAM is a file, then the BamWriter should -// contain the name of the file. This enables the -// writer to convert pathnames in the BAM to relative -// to the directory containing the BAM. -//////////////////////////////////////////////////////////////////// +/** + * If a BAM is a file, then the BamWriter should contain the name of the file. + * This enables the writer to convert pathnames in the BAM to relative to the + * directory containing the BAM. + */ INLINE const Filename &BamWriter:: get_filename() const { if (_target != (DatagramSink *)NULL) { @@ -41,79 +34,62 @@ get_filename() const { return empty_filename; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_file_endian -// Access: Published -// Description: Returns the endian preference indicated by the Bam -// file currently being written. This does not imply -// that every number is stored using the indicated -// convention, but individual objects may choose to -// respect this flag when recording data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the endian preference indicated by the Bam file currently being + * written. This does not imply that every number is stored using the + * indicated convention, but individual objects may choose to respect this + * flag when recording data. + */ INLINE BamWriter::BamEndian BamWriter:: get_file_endian() const { return _file_endian; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_file_stdfloat_double -// Access: Published -// Description: Returns true if the file will store all "standard" -// floats as 64-bit doubles, or false if they are 32-bit -// floats. This isn't runtime settable; it's based on -// the compilation flags of the version of Panda that -// generated this file. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file will store all "standard" floats as 64-bit + * doubles, or false if they are 32-bit floats. This isn't runtime settable; + * it's based on the compilation flags of the version of Panda that generated + * this file. + */ INLINE bool BamWriter:: get_file_stdfloat_double() const { return _file_stdfloat_double; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_file_texture_mode -// Access: Published -// Description: Returns the BamTextureMode preference indicated by -// the Bam file currently being written. Texture -// objects written to this Bam file will be encoded -// according to the specified mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the BamTextureMode preference indicated by the Bam file currently + * being written. Texture objects written to this Bam file will be encoded + * according to the specified mode. + */ INLINE BamWriter::BamTextureMode BamWriter:: get_file_texture_mode() const { return _file_texture_mode; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::set_file_texture_mode -// Access: Published -// Description: Changes the BamTextureMode preference for -// the Bam file currently being written. Texture -// objects written to this Bam file will be encoded -// according to the specified mode. -//////////////////////////////////////////////////////////////////// +/** + * Changes the BamTextureMode preference for the Bam file currently being + * written. Texture objects written to this Bam file will be encoded + * according to the specified mode. + */ INLINE void BamWriter:: set_file_texture_mode(BamTextureMode file_texture_mode) { _file_texture_mode = file_texture_mode; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::get_root_node -// Access: Published -// Description: Returns the root node of the part of the scene -// graph we are currently writing out. This is used -// for determining what to make NodePaths relative to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root node of the part of the scene graph we are currently + * writing out. This is used for determining what to make NodePaths relative + * to. + */ INLINE TypedWritable *BamWriter:: get_root_node() const { return _root_node; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::set_root_node -// Access: Published -// Description: Sets the root node of the part of the scene graph -// we are currently writing out. NodePaths written -// to this bam file will be relative to this node. -//////////////////////////////////////////////////////////////////// +/** + * Sets the root node of the part of the scene graph we are currently writing + * out. NodePaths written to this bam file will be relative to this node. + */ INLINE void BamWriter:: set_root_node(TypedWritable *root_node) { _root_node = root_node; diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index 3282647b8b..e26b2c0d8c 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -1,16 +1,15 @@ -// Filename: bamWriter.cxx -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamWriter.cxx + * @author jason + * @date 2000-06-08 + */ #include "pandabase.h" #include "pnotify.h" @@ -24,11 +23,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamWriter:: BamWriter(DatagramSink *target) : _target(target) @@ -37,8 +34,8 @@ BamWriter(DatagramSink *target) : _next_boc = BOC_adjunct; _needs_init = true; - // Initialize the next object and PTA ID's. These start counting at - // 1, since 0 is reserved for NULL. + // Initialize the next object and PTA ID's. These start counting at 1, + // since 0 is reserved for NULL. _next_object_id = 1; _long_object_id = false; _next_pta_id = 1; @@ -49,15 +46,13 @@ BamWriter(DatagramSink *target) : _file_texture_mode = bam_texture_mode; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamWriter:: ~BamWriter() { - // Tell all the TypedWritables whose pointer we are still keeping to - // forget about us. + // Tell all the TypedWritables whose pointer we are still keeping to forget + // about us. StateMap::iterator si; for (si = _state_map.begin(); si != _state_map.end(); ++si) { TypedWritable *object = (TypedWritable *)(*si).first; @@ -65,13 +60,10 @@ BamWriter:: } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::set_target -// Access: Published -// Description: Changes the destination of future datagrams written -// by the BamWriter. This also implicitly calls init() -// if it has not already been called. -//////////////////////////////////////////////////////////////////// +/** + * Changes the destination of future datagrams written by the BamWriter. This + * also implicitly calls init() if it has not already been called. + */ void BamWriter:: set_target(DatagramSink *target) { if (_target != NULL) { @@ -84,24 +76,21 @@ set_target(DatagramSink *target) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::init -// Access: Published -// Description: Initializes the BamWriter prior to writing any -// objects to its output stream. This includes writing -// out the Bam header. -// -// This returns true if the BamWriter successfully -// initialized, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the BamWriter prior to writing any objects to its output + * stream. This includes writing out the Bam header. + * + * This returns true if the BamWriter successfully initialized, false + * otherwise. + */ bool BamWriter:: init() { nassertr(_target != NULL, false); nassertr(_needs_init, false); _needs_init = false; - // Initialize the next object and PTA ID's. These start counting at - // 1, since 0 is reserved for NULL. + // Initialize the next object and PTA ID's. These start counting at 1, + // since 0 is reserved for NULL. _next_object_id = 1; _long_object_id = false; _next_pta_id = 1; @@ -126,34 +115,29 @@ init() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_object -// Access: Published -// Description: Writes a single object to the Bam file, so that the -// BamReader::read_object() can later correctly restore -// the object and all its pointers. -// -// This implicitly also writes any additional objects -// this object references (if they haven't already been -// written), so that pointers may be fully resolved. -// -// This may be called repeatedly to write a sequence of -// objects to the Bam file, but typically (especially -// for scene graph files, indicated with the .bam -// extension), only one object is written directly from -// the Bam file: the root of the scene graph. The -// remaining objects will all be written recursively by -// the first object. -// -// Returns true if the object is successfully written, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes a single object to the Bam file, so that the + * BamReader::read_object() can later correctly restore the object and all its + * pointers. + * + * This implicitly also writes any additional objects this object references + * (if they haven't already been written), so that pointers may be fully + * resolved. + * + * This may be called repeatedly to write a sequence of objects to the Bam + * file, but typically (especially for scene graph files, indicated with the + * .bam extension), only one object is written directly from the Bam file: the + * root of the scene graph. The remaining objects will all be written + * recursively by the first object. + * + * Returns true if the object is successfully written, false otherwise. + */ bool BamWriter:: write_object(const TypedWritable *object) { nassertr(_target != NULL, false); - // Increment the _writing_seq, so we can check for newly stale - // objects during this operation. + // Increment the _writing_seq, so we can check for newly stale objects + // during this operation. ++_writing_seq; // If there are any freed objects to indicate, write them out now. @@ -197,42 +181,32 @@ write_object(const TypedWritable *object) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::has_object -// Access: Published -// Description: Returns true if the object has previously been -// written (or at least requested to be written) to the -// bam file, or false if we've never heard of it before. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the object has previously been written (or at least + * requested to be written) to the bam file, or false if we've never heard of + * it before. + */ bool BamWriter:: has_object(const TypedWritable *object) const { StateMap::const_iterator si = _state_map.find(object); return (si != _state_map.end()); } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::flush -// Access: Published -// Description: Ensures that all data written thus far is manifested -// on the output stream. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that all data written thus far is manifested on the output stream. + */ void BamWriter:: flush() { nassertv(_target != NULL); _target->flush(); } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::consider_update -// Access: Public -// Description: Should be called from -// TypedWritable::update_bam_nested() to recursively -// check the entire hiererachy of writable objects for -// needed updates. This tests the indicated -// TypedWritable object and writes it to the bam stream -// if it has recently been modified, then recurses -// through update_bam_nested. -//////////////////////////////////////////////////////////////////// +/** + * Should be called from TypedWritable::update_bam_nested() to recursively + * check the entire hiererachy of writable objects for needed updates. This + * tests the indicated TypedWritable object and writes it to the bam stream if + * it has recently been modified, then recurses through update_bam_nested. + */ void BamWriter:: consider_update(const TypedWritable *object) { StateMap::iterator si = _state_map.find(object); @@ -245,8 +219,8 @@ consider_update(const TypedWritable *object) { enqueue_object(object); } else if ((*si).second._written_seq == _writing_seq) { - // We have already visited this object this pass, so no need to - // look closer. + // We have already visited this object this pass, so no need to look + // closer. } else if ((*si).second._modified != object->get_bam_modified()) { // This object has been recently modified and needs to be rewritten. @@ -255,51 +229,46 @@ consider_update(const TypedWritable *object) { } else { // Mark that we have now visited this object and pronounced it clean. (*si).second._written_seq = _writing_seq; - + // Recurse to child objects. ((TypedWritable *)object)->update_bam_nested(this); } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_pointer -// Access: Public -// Description: The interface for writing a pointer to another object -// to a Bam file. This is intended to be called by the -// various objects that write themselves to the Bam -// file, within the write_datagram() method. -// -// This writes the pointer out in such a way that the -// BamReader will be able to restore the pointer later. -// If the pointer is to an object that has not yet -// itself been written to the Bam file, that object will -// automatically be written. -//////////////////////////////////////////////////////////////////// +/** + * The interface for writing a pointer to another object to a Bam file. This + * is intended to be called by the various objects that write themselves to + * the Bam file, within the write_datagram() method. + * + * This writes the pointer out in such a way that the BamReader will be able + * to restore the pointer later. If the pointer is to an object that has not + * yet itself been written to the Bam file, that object will automatically be + * written. + */ void BamWriter:: write_pointer(Datagram &packet, const TypedWritable *object) { - // If the pointer is NULL, we always simply write a zero for an - // object ID and leave it at that. + // If the pointer is NULL, we always simply write a zero for an object ID + // and leave it at that. if (object == (const TypedWritable *)NULL) { write_object_id(packet, 0); } else { StateMap::iterator si = _state_map.find(object); if (si == _state_map.end()) { - // We have not written this pointer out yet. This means we must - // queue the object definition up for later. + // We have not written this pointer out yet. This means we must queue + // the object definition up for later. int object_id = enqueue_object(object); write_object_id(packet, object_id); } else { - // We have already assigned this pointer an ID, so it has - // previously been written; but we might still need to rewrite - // it if it is stale. + // We have already assigned this pointer an ID, so it has previously + // been written; but we might still need to rewrite it if it is stale. int object_id = (*si).second._object_id; bool already_written = !(*si).second._written_seq.is_initial(); if ((*si).second._written_seq != _writing_seq && (*si).second._modified != object->get_bam_modified()) { - // This object was previously written, but it has since been - // modified, so we should write it again. + // This object was previously written, but it has since been modified, + // so we should write it again. already_written = false; } @@ -316,19 +285,16 @@ write_pointer(Datagram &packet, const TypedWritable *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_file_data -// Access: Public -// Description: Writes a block of auxiliary file data from the -// indicated file (within the vfs). This can be a block -// of arbitrary size, and it is assumed it may be quite -// large. This must be balanced by a matching call to -// read_file_data() on restore. -//////////////////////////////////////////////////////////////////// +/** + * Writes a block of auxiliary file data from the indicated file (within the + * vfs). This can be a block of arbitrary size, and it is assumed it may be + * quite large. This must be balanced by a matching call to read_file_data() + * on restore. + */ void BamWriter:: write_file_data(SubfileInfo &result, const Filename &filename) { - // We write file data by preceding with a singleton datagram that - // contains only the BOC_file_data token. + // We write file data by preceding with a singleton datagram that contains + // only the BOC_file_data token. Datagram dg; dg.add_uint8(BOC_file_data); if (!_target->put_datagram(dg)) { @@ -337,32 +303,29 @@ write_file_data(SubfileInfo &result, const Filename &filename) { return; } - // Then we can write the file data itself, as its own (possibly - // quite large) followup datagram. + // Then we can write the file data itself, as its own (possibly quite large) + // followup datagram. if (!_target->copy_datagram(result, filename)) { util_cat.error() << "Unable to write file data to output.\n"; return; } - // Both of those get written to the bam stream prior to the datagram - // that represents this particular object, but they'll get pulled - // out in the same order and queued up in the BamReader. + // Both of those get written to the bam stream prior to the datagram that + // represents this particular object, but they'll get pulled out in the same + // order and queued up in the BamReader. } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_file_data -// Access: Public -// Description: Writes a block of auxiliary file data from the -// indicated file (outside of the vfs). This can be a -// block of arbitrary size, and it is assumed it may be -// quite large. This must be balanced by a matching -// call to read_file_data() on restore. -//////////////////////////////////////////////////////////////////// +/** + * Writes a block of auxiliary file data from the indicated file (outside of + * the vfs). This can be a block of arbitrary size, and it is assumed it may + * be quite large. This must be balanced by a matching call to + * read_file_data() on restore. + */ void BamWriter:: write_file_data(SubfileInfo &result, const SubfileInfo &source) { - // We write file data by preceding with a singleton datagram that - // contains only the BOC_file_data token. + // We write file data by preceding with a singleton datagram that contains + // only the BOC_file_data token. Datagram dg; dg.add_uint8(BOC_file_data); if (!_target->put_datagram(dg)) { @@ -371,29 +334,25 @@ write_file_data(SubfileInfo &result, const SubfileInfo &source) { return; } - // Then we can write the file data itself, as its own (possibly - // quite large) followup datagram. + // Then we can write the file data itself, as its own (possibly quite large) + // followup datagram. if (!_target->copy_datagram(result, source)) { util_cat.error() << "Unable to write file data to output.\n"; return; } - // Both of those get written to the bam stream prior to the datagram - // that represents this particular object, but they'll get pulled - // out in the same order and queued up in the BamReader. + // Both of those get written to the bam stream prior to the datagram that + // represents this particular object, but they'll get pulled out in the same + // order and queued up in the BamReader. } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_cdata -// Access: Public -// Description: Writes out the indicated CycleData object. This -// should be used by classes that store some or all of -// their data within a CycleData subclass, in support of -// pipelining. This will call the virtual -// CycleData::write_datagram() method to do the actual -// writing. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the indicated CycleData object. This should be used by classes + * that store some or all of their data within a CycleData subclass, in + * support of pipelining. This will call the virtual + * CycleData::write_datagram() method to do the actual writing. + */ void BamWriter:: write_cdata(Datagram &packet, const PipelineCyclerBase &cycler) { const CycleData *cdata = cycler.read(Thread::get_current_thread()); @@ -401,12 +360,10 @@ write_cdata(Datagram &packet, const PipelineCyclerBase &cycler) { cycler.release_read(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_cdata -// Access: Public -// Description: This version of write_cdata allows passing an -// additional parameter to cdata->write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * This version of write_cdata allows passing an additional parameter to + * cdata->write_datagram(). + */ void BamWriter:: write_cdata(Datagram &packet, const PipelineCyclerBase &cycler, void *extra_data) { @@ -415,39 +372,34 @@ write_cdata(Datagram &packet, const PipelineCyclerBase &cycler, cycler.release_read(cdata); } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::register_pta -// Access: Public -// Description: Prepares to write a PointerToArray to the Bam file, -// unifying references to the same pointer across the -// Bam file. -// -// The writing object should call this prior to writing -// out a PointerToArray. It will return true if the -// same pointer has been written previously, in which -// case the writing object need do nothing further; or -// it will return false if this particular pointer has -// not yet been written, in which case the writing -// object must then write out the contents of the array. -// -// Also see the WRITE_PTA() macro, which consolidates -// the work that must be done to write a PTA. -//////////////////////////////////////////////////////////////////// +/** + * Prepares to write a PointerToArray to the Bam file, unifying references to + * the same pointer across the Bam file. + * + * The writing object should call this prior to writing out a PointerToArray. + * It will return true if the same pointer has been written previously, in + * which case the writing object need do nothing further; or it will return + * false if this particular pointer has not yet been written, in which case + * the writing object must then write out the contents of the array. + * + * Also see the WRITE_PTA() macro, which consolidates the work that must be + * done to write a PTA. + */ bool BamWriter:: register_pta(Datagram &packet, const void *ptr) { if (ptr == (const void *)NULL) { - // A zero for the PTA ID indicates a NULL pointer. This is a - // special case. + // A zero for the PTA ID indicates a NULL pointer. This is a special + // case. write_pta_id(packet, 0); - // We return false to indicate the user must now write out the - // "definition" of the NULL pointer. This is necessary because of - // a quirk in the BamReader's design, which forces callers to read - // the definition of every NULL pointer. Presumably, the caller - // will be able to write the definition in a concise way that will - // clearly indicate a NULL pointer; in the case of a - // PointerToArray, this will generally be simply a zero element - // count. +/* + * We return false to indicate the user must now write out the "definition" of + * the NULL pointer. This is necessary because of a quirk in the BamReader's + * design, which forces callers to read the definition of every NULL pointer. + * Presumably, the caller will be able to write the definition in a concise + * way that will clearly indicate a NULL pointer; in the case of a + * PointerToArray, this will generally be simply a zero element count. + */ return false; } @@ -462,8 +414,8 @@ register_pta(Datagram &packet, const void *ptr) { write_pta_id(packet, pta_id); - // Return false to indicate the caller must now write out the - // array definition. + // Return false to indicate the caller must now write out the array + // definition. return false; } else { @@ -476,24 +428,20 @@ register_pta(Datagram &packet, const void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_handle -// Access: Public -// Description: Writes a TypeHandle to the file in such a way that -// the BamReader can read the same TypeHandle later via -// read_handle(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a TypeHandle to the file in such a way that the BamReader can read + * the same TypeHandle later via read_handle(). + */ void BamWriter:: write_handle(Datagram &packet, TypeHandle type) { - // We encode TypeHandles within the Bam file by writing a unique - // index number for each one to the file. When we write a - // particular TypeHandle for the first time, we assign it a new - // index number and then immediately follow it by its definition; - // when we write the same TypeHandle on subsequent times we only - // write the index number. + // We encode TypeHandles within the Bam file by writing a unique index + // number for each one to the file. When we write a particular TypeHandle + // for the first time, we assign it a new index number and then immediately + // follow it by its definition; when we write the same TypeHandle on + // subsequent times we only write the index number. - // The unique number we choose is actually the internal index number - // of the TypeHandle. Why not? + // The unique number we choose is actually the internal index number of the + // TypeHandle. Why not? int index = type.get_index(); // Also make sure the index number fits within a PN_uint16. @@ -505,13 +453,12 @@ write_handle(Datagram &packet, TypeHandle type) { bool inserted = _types_written.insert(index).second; if (inserted) { - // This is the first time this TypeHandle has been written, so - // also write out its definition. + // This is the first time this TypeHandle has been written, so also + // write out its definition. packet.add_string(type.get_name()); - // We also need to write the derivation of the TypeHandle, in case - // the program reading this file later has never heard of this - // type before. + // We also need to write the derivation of the TypeHandle, in case the + // program reading this file later has never heard of this type before. int num_parent_classes = type.get_num_parent_classes(); nassertv(num_parent_classes <= 255); // Good grief! packet.add_uint8(num_parent_classes); @@ -523,21 +470,18 @@ write_handle(Datagram &packet, TypeHandle type) { } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::object_destructs -// Access: Private -// Description: This is called by the TypedWritable destructor. It -// should remove the pointer from any structures that -// keep a reference to it, and also write a flag to the -// bam file (if it is open) so that a reader will know -// the object id will no longer be used. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the TypedWritable destructor. It should remove the + * pointer from any structures that keep a reference to it, and also write a + * flag to the bam file (if it is open) so that a reader will know the object + * id will no longer be used. + */ void BamWriter:: object_destructs(TypedWritable *object) { StateMap::iterator si = _state_map.find(object); if (si != _state_map.end()) { - // We ought to have written out the object by the time it - // destructs, or we're in trouble when we do write it out. + // We ought to have written out the object by the time it destructs, or + // we're in trouble when we do write it out. nassertv(!(*si).second._written_seq.is_initial()); int object_id = (*si).second._object_id; @@ -547,90 +491,82 @@ object_destructs(TypedWritable *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_object_id -// Access: Private -// Description: Writes the indicated object id to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated object id to the datagram. + */ void BamWriter:: write_object_id(Datagram &dg, int object_id) { if (_long_object_id) { dg.add_uint32(object_id); - + } else { dg.add_uint16(object_id); - // Once we fill up our uint16, we write all object id's - // thereafter with a uint32. + // Once we fill up our uint16, we write all object id's thereafter with a + // uint32. if (object_id == 0xffff) { _long_object_id = true; } } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::write_pta_id -// Access: Private -// Description: Writes the indicated pta id to the datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the indicated pta id to the datagram. + */ void BamWriter:: write_pta_id(Datagram &dg, int pta_id) { if (_long_pta_id) { dg.add_uint32(pta_id); - + } else { dg.add_uint16(pta_id); - // Once we fill up our uint16, we write all pta id's - // thereafter with a uint32. + // Once we fill up our uint16, we write all pta id's thereafter with a + // uint32. if (pta_id == 0xffff) { _long_pta_id = true; } } } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::enqueue_object -// Access: Private -// Description: Assigns an object ID to the object and queues it up -// for later writing to the Bam file. -// -// The return value is the object ID, or 0 if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * Assigns an object ID to the object and queues it up for later writing to + * the Bam file. + * + * The return value is the object ID, or 0 if there is an error. + */ int BamWriter:: enqueue_object(const TypedWritable *object) { Datagram dg; nassertr(object != TypedWritable::Null, 0); - // No object should ever be written out that is not registered as a - // child of TypedWritable. The only way this can happen is if - // someone failed to initialize their type correctly in init_type(). + // No object should ever be written out that is not registered as a child of + // TypedWritable. The only way this can happen is if someone failed to + // initialize their type correctly in init_type(). #ifndef NDEBUG if (!object->is_of_type(TypedWritable::get_class_type())) { util_cat.error() - << "Type " << object->get_type() + << "Type " << object->get_type() << " does not indicate inheritance from TypedWritable.\n" << "(this is almost certainly an oversight in " << object->get_type() << "::init_type().)\n"; } #endif - // We need to assign a unique index number to every object we write - // out. Has this object been assigned a number yet? + // We need to assign a unique index number to every object we write out. + // Has this object been assigned a number yet? int object_id; StateMap::iterator si = _state_map.find(object); if (si == _state_map.end()) { - // No, it hasn't, so assign it the next number in sequence - // arbitrarily. + // No, it hasn't, so assign it the next number in sequence arbitrarily. object_id = _next_object_id; bool inserted = _state_map.insert(StateMap::value_type(object, StoreState(_next_object_id))).second; nassertr(inserted, false); - // Store ourselves on the TypedWritable so that we get notified - // when it destructs. + // Store ourselves on the TypedWritable so that we get notified when it + // destructs. (const_cast(object))->add_bam_writer(this); _next_object_id++; @@ -643,14 +579,12 @@ enqueue_object(const TypedWritable *object) { return object_id; } -//////////////////////////////////////////////////////////////////// -// Function: BamWriter::flush_queue -// Access: Private -// Description: Writes all of the objects on the _object_queue to the -// bam stream, until the queue is empty. -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes all of the objects on the _object_queue to the bam stream, until the + * queue is empty. + * + * Returns true on success, false on failure. + */ bool BamWriter:: flush_queue() { nassertr(_target != NULL, false); @@ -671,8 +605,8 @@ flush_queue() { int object_id = (*si).second._object_id; bool already_written = !(*si).second._written_seq.is_initial(); if ((*si).second._modified != object->get_bam_modified()) { - // This object was previously written, but it has since been - // modified, so we should write it again. + // This object was previously written, but it has since been modified, + // so we should write it again. already_written = false; } @@ -682,18 +616,18 @@ flush_queue() { _next_boc = BOC_adjunct; if (!already_written) { - // The first time we write a particular object, or when we - // update the same object later, we do so by writing its - // TypeHandle (which had better not be TypeHandle::none(), since - // that's our code for a previously-written object), followed by - // the object ID number, followed by the object definition. + // The first time we write a particular object, or when we update the + // same object later, we do so by writing its TypeHandle (which had + // better not be TypeHandle::none(), since that's our code for a + // previously-written object), followed by the object ID number, + // followed by the object definition. TypeHandle type = object->get_type(); nassertr(type != TypeHandle::none(), false); - // Determine what the nearest kind of type is that the reader - // will be able to handle, and write that instead. - TypeHandle registered_type = + // Determine what the nearest kind of type is that the reader will be + // able to handle, and write that instead. + TypeHandle registered_type = BamReader::get_factory()->find_registered_type(type); if (registered_type == TypeHandle::none()) { // We won't be able to read this type again. @@ -714,27 +648,27 @@ flush_queue() { write_object_id(dg, object_id); // We cast the const pointer to non-const so that we may call - // write_datagram() on it. Really, write_datagram() should be a - // const method anyway, but there may be times when a class - // object wants to update some transparent cache value during - // writing or something like that, so it's more convenient to - // cheat and define it as a non-const method. + // write_datagram() on it. Really, write_datagram() should be a const + // method anyway, but there may be times when a class object wants to + // update some transparent cache value during writing or something like + // that, so it's more convenient to cheat and define it as a non-const + // method. ((TypedWritable *)object)->write_datagram(this, dg); (*si).second._written_seq = _writing_seq; (*si).second._modified = object->get_bam_modified(); } else { - // On subsequent times when we write a particular object, we - // write simply TypeHandle::none(), followed by the object ID. - // The occurrence of TypeHandle::none() is an indicator to the - // BamReader that this is a previously-written object. + // On subsequent times when we write a particular object, we write + // simply TypeHandle::none(), followed by the object ID. The occurrence + // of TypeHandle::none() is an indicator to the BamReader that this is a + // previously-written object. write_handle(dg, TypeHandle::none()); write_object_id(dg, object_id); - // The object has not been modified, but maybe one of its child - // objects has. + // The object has not been modified, but maybe one of its child objects + // has. ((TypedWritable *)object)->update_bam_nested(this); } diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index 674aa7044a..cd948a928e 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -1,16 +1,15 @@ -// Filename: bamWriter.h -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamWriter.h + * @author jason + * @date 2000-06-08 + */ #ifndef __BAM_WRITER_ #define __BAM_WRITER_ @@ -35,41 +34,32 @@ } \ -//////////////////////////////////////////////////////////////////// -// Class : BamWriter -// Description : This is the fundamental interface for writing binary -// objects to a Bam file, to be extracted later by a -// BamReader. -// -// A Bam file can be thought of as a linear collection -// of objects. Each object is an instance of a class -// that inherits, directly or indirectly, from -// TypedWritable. The objects may include pointers to -// other objects; the BamWriter automatically manages -// these (with help from code within each class) and -// writes all referenced objects to the file in such a -// way that the pointers may be correctly restored -// later. -// -// This is the abstract interface and does not -// specifically deal with disk files, but rather with a -// DatagramSink of some kind, which simply accepts a -// linear stream of Datagrams. It is probably written -// to a disk file, but it might conceivably be streamed -// directly to a network or some such nonsense. -// -// Bam files are most often used to store scene graphs -// or subgraphs, and by convention they are given -// filenames ending in the extension ".bam" when they -// are used for this purpose. However, a Bam file may -// store any arbitrary list of TypedWritable objects; -// in this more general usage, they are given filenames -// ending in ".boo" to differentiate them from the more -// common scene graph files. -// -// See also BamFile, which defines a higher-level -// interface to read and write Bam files on disk. -//////////////////////////////////////////////////////////////////// +/** + * This is the fundamental interface for writing binary objects to a Bam file, + * to be extracted later by a BamReader. + * + * A Bam file can be thought of as a linear collection of objects. Each + * object is an instance of a class that inherits, directly or indirectly, + * from TypedWritable. The objects may include pointers to other objects; the + * BamWriter automatically manages these (with help from code within each + * class) and writes all referenced objects to the file in such a way that the + * pointers may be correctly restored later. + * + * This is the abstract interface and does not specifically deal with disk + * files, but rather with a DatagramSink of some kind, which simply accepts a + * linear stream of Datagrams. It is probably written to a disk file, but it + * might conceivably be streamed directly to a network or some such nonsense. + * + * Bam files are most often used to store scene graphs or subgraphs, and by + * convention they are given filenames ending in the extension ".bam" when + * they are used for this purpose. However, a Bam file may store any + * arbitrary list of TypedWritable objects; in this more general usage, they + * are given filenames ending in ".boo" to differentiate them from the more + * common scene graph files. + * + * See also BamFile, which defines a higher-level interface to read and write + * Bam files on disk. + */ class EXPCL_PANDA_PUTIL BamWriter : public BamEnums { PUBLISHED: BamWriter(DatagramSink *target = NULL); @@ -129,17 +119,17 @@ private: bool _file_stdfloat_double; BamTextureMode _file_texture_mode; - // Stores the PandaNode representing the root of the node hierarchy - // we are currently writing, if any, for the purpose of writing NodePaths. - // This is a TypedWritable since PandaNode is defined in pgraph. + // Stores the PandaNode representing the root of the node hierarchy we are + // currently writing, if any, for the purpose of writing NodePaths. This is + // a TypedWritable since PandaNode is defined in pgraph. TypedWritable *_root_node; // This is the set of all TypeHandles already written. pset _types_written; - // This keeps track of all of the objects we have written out - // already (or are about to write out), and associates a unique - // object ID number to each one. + // This keeps track of all of the objects we have written out already (or + // are about to write out), and associates a unique object ID number to each + // one. class StoreState { public: int _object_id; @@ -151,35 +141,34 @@ private: typedef phash_map StateMap; StateMap _state_map; - // This seq number is incremented each time we write a new object - // using the top-level write_object() call. It indicates the - // current sequence number we are writing, which is updated in the - // StoreState, above, and used to keep track of which objects may - // need to be checked for internal updates. + // This seq number is incremented each time we write a new object using the + // top-level write_object() call. It indicates the current sequence number + // we are writing, which is updated in the StoreState, above, and used to + // keep track of which objects may need to be checked for internal updates. UpdateSeq _writing_seq; - // This is initialized to BOC_push in write_object(), then cleared - // to BOC_adjunct as each object is written, so that only the first - // object gets written with BOC_push. + // This is initialized to BOC_push in write_object(), then cleared to + // BOC_adjunct as each object is written, so that only the first object gets + // written with BOC_push. BamObjectCode _next_boc; // This is the next object ID that will be assigned to a new object. int _next_object_id; bool _long_object_id; - // This is the queue of objects that need to be written when the - // current object is finished. + // This is the queue of objects that need to be written when the current + // object is finished. typedef pdeque ObjectQueue; ObjectQueue _object_queue; - // This is the set of object_id's that we won't be using any more; - // we'll encode this set into the bam stream so the BamReader will - // be able to clean up its internal structures. + // This is the set of object_id's that we won't be using any more; we'll + // encode this set into the bam stream so the BamReader will be able to + // clean up its internal structures. typedef vector_int FreedObjectIds; FreedObjectIds _freed_object_ids; - // These are used by register_pta() to unify multiple references to - // the same PointerToArray. + // These are used by register_pta() to unify multiple references to the same + // PointerToArray. typedef phash_map PTAMap; PTAMap _pta_map; int _next_pta_id; @@ -195,4 +184,3 @@ private: #include "bamWriter.I" #endif - diff --git a/panda/src/putil/bitArray.I b/panda/src/putil/bitArray.I index 4209812abe..6c16a549d0 100644 --- a/panda/src/putil/bitArray.I +++ b/panda/src/putil/bitArray.I @@ -1,33 +1,27 @@ -// Filename: bitArray.I -// Created by: drose (20Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitArray.I + * @author drose + * @date 2006-01-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray:: BitArray() { _highest_bits = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray:: BitArray(WordType init_value) { if (init_value != 0) { @@ -36,11 +30,9 @@ BitArray(WordType init_value) { _highest_bits = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray:: BitArray(const BitArray ©) : _array(copy._array), @@ -48,11 +40,9 @@ BitArray(const BitArray ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray &BitArray:: operator = (const BitArray ©) { _array = copy._array; @@ -60,12 +50,9 @@ operator = (const BitArray ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Named all_on constructor -// Access: Published, Static -// Description: Returns a BitArray with an infinite array of bits, -// all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitArray with an infinite array of bits, all on. + */ INLINE BitArray BitArray:: all_on() { BitArray result; @@ -73,21 +60,17 @@ all_on() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Named all_on constructor -// Access: Published, Static -// Description: Returns a BitArray whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitArray whose bits are all off. + */ INLINE BitArray BitArray:: all_off() { return BitArray(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Named lower_on constructor -// Access: Published, Static -// Description: Returns a BitArray whose lower on_bits bits are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitArray whose lower on_bits bits are on. + */ INLINE BitArray BitArray:: lower_on(int on_bits) { BitArray result; @@ -95,11 +78,9 @@ lower_on(int on_bits) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Named bit constructor -// Access: Published, Static -// Description: Returns a BitArray with only the indicated bit on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitArray with only the indicated bit on. + */ INLINE BitArray BitArray:: bit(int index) { BitArray result; @@ -107,12 +88,9 @@ bit(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Named range constructor -// Access: Published, Static -// Description: Returns a BitArray whose size bits, beginning at -// low_bit, are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitArray whose size bits, beginning at low_bit, are on. + */ INLINE BitArray BitArray:: range(int low_bit, int size) { BitArray result; @@ -120,89 +98,68 @@ range(int low_bit, int size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray:: ~BitArray() { } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::has_max_num_bits -// Access: Published, Static -// Description: Returns true if there is a maximum number of bits -// that may be stored in this structure, false -// otherwise. If this returns true, the number may be -// queried in get_max_num_bits(). -// -// This method always returns false. The BitArray has -// no maximum number of bits. This method is defined so -// generic programming algorithms can use BitMask or -// BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a maximum number of bits that may be stored in + * this structure, false otherwise. If this returns true, the number may be + * queried in get_max_num_bits(). + * + * This method always returns false. The BitArray has no maximum number of + * bits. This method is defined so generic programming algorithms can use + * BitMask or BitArray interchangeably. + */ CONSTEXPR bool BitArray:: has_max_num_bits() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_max_num_bits -// Access: Published, Static -// Description: If get_max_num_bits() returned true, this method may -// be called to return the maximum number of bits that -// may be stored in this structure. It is an error to -// call this if get_max_num_bits() return false. -// -// It is always an error to call this method. The -// BitArray has no maximum number of bits. This method -// is defined so generic programming algorithms can use -// BitMask or BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * If get_max_num_bits() returned true, this method may be called to return + * the maximum number of bits that may be stored in this structure. It is an + * error to call this if get_max_num_bits() return false. + * + * It is always an error to call this method. The BitArray has no maximum + * number of bits. This method is defined so generic programming algorithms + * can use BitMask or BitArray interchangeably. + */ CONSTEXPR int BitArray:: get_max_num_bits() { return INT_MAX; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_num_bits_per_word -// Access: Published, Static -// Description: Returns the number of bits stored per word -// internally. This is of interest only in that it -// limits the maximum number of bits that may be queried -// or set at once by extract() and store(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits stored per word internally. This is of interest + * only in that it limits the maximum number of bits that may be queried or + * set at once by extract() and store(). + */ CONSTEXPR int BitArray:: get_num_bits_per_word() { return num_bits_per_word; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_num_bits -// Access: Published -// Description: Returns the current number of possibly different bits -// in this array. There are actually an infinite number -// of bits, but every bit higher than this bit will have -// the same value, either 0 or 1 (see -// get_highest_bits()). -// -// This number may grow and/or shrink automatically as -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of possibly different bits in this array. There + * are actually an infinite number of bits, but every bit higher than this bit + * will have the same value, either 0 or 1 (see get_highest_bits()). + * + * This number may grow and/or shrink automatically as needed. + */ INLINE size_t BitArray:: get_num_bits() const { return get_num_words() * (size_t)num_bits_per_word; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. It is valid for n to increase beyond -// get_num_bits(), but the return value get_num_bits() -// will always be the same. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. It is valid + * for n to increase beyond get_num_bits(), but the return value + * get_num_bits() will always be the same. + */ INLINE bool BitArray:: get_bit(int index) const { nassertr(index >= 0, false); @@ -215,12 +172,10 @@ get_bit(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::set_bit -// Access: Published -// Description: Sets the nth bit on. If n >= get_num_bits(), this -// automatically extends the array. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. If n >= get_num_bits(), this automatically extends + * the array. + */ INLINE void BitArray:: set_bit(int index) { nassertv(index >= 0); @@ -235,12 +190,10 @@ set_bit(int index) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::clear_bit -// Access: Published -// Description: Sets the nth bit off. If n >= get_num_bits(), this -// automatically extends the array. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. If n >= get_num_bits(), this automatically extends + * the array. + */ INLINE void BitArray:: clear_bit(int index) { nassertv(index >= 0); @@ -255,12 +208,9 @@ clear_bit(int index) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::set_bit_to -// Access: Published -// Description: Sets the nth bit either on or off, according to the -// indicated bool value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit either on or off, according to the indicated bool value. + */ INLINE void BitArray:: set_bit_to(int index, bool value) { if (value) { @@ -270,26 +220,20 @@ set_bit_to(int index, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_highest_bits -// Access: Published -// Description: Returns true if the infinite set of bits beyond -// get_num_bits() are all on, or false of they are all -// off. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the infinite set of bits beyond get_num_bits() are all on, + * or false of they are all off. + */ INLINE bool BitArray:: get_highest_bits() const { return (_highest_bits != 0); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::extract -// Access: Published -// Description: Returns a word that represents only the indicated -// range of bits within this BitArray, shifted to the -// least-significant position. size must be <= -// get_num_bits_per_word(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a word that represents only the indicated range of bits within this + * BitArray, shifted to the least-significant position. size must be <= + * get_num_bits_per_word(). + */ INLINE BitArray::WordType BitArray:: extract(int low_bit, int size) const { nassertr(size >= 0 && size <= num_bits_per_word, 0); @@ -310,12 +254,10 @@ extract(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::store -// Access: Published -// Description: Stores the indicated word into the indicated range of -// bits with this BitArray. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated word into the indicated range of bits with this + * BitArray. + */ INLINE void BitArray:: store(WordType value, int low_bit, int size) { nassertv(size >= 0); @@ -339,11 +281,9 @@ store(WordType value, int low_bit, int size) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::set_range_to -// Access: Published -// Description: Sets the indicated range of bits to either on or off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits to either on or off. + */ INLINE void BitArray:: set_range_to(bool value, int low_bit, int size) { if (value) { @@ -353,24 +293,19 @@ set_range_to(bool value, int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_num_words -// Access: Published -// Description: Returns the number of possibly-unique words stored in -// the array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of possibly-unique words stored in the array. + */ INLINE size_t BitArray:: get_num_words() const { return _array.size(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_word -// Access: Published -// Description: Returns the nth word in the array. It is valid for n -// to be greater than get_num_words(), but the return -// value beyond get_num_words() will always be the same. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth word in the array. It is valid for n to be greater than + * get_num_words(), but the return value beyond get_num_words() will always be + * the same. + */ INLINE BitArray::MaskType BitArray:: get_word(size_t n) const { nassertr(n >= 0, MaskType::all_off()); @@ -384,13 +319,10 @@ get_word(size_t n) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::set_word -// Access: Published -// Description: Replaces the nth word in the array. If n >= -// get_num_words(), this automatically extends the -// array. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the nth word in the array. If n >= get_num_words(), this + * automatically extends the array. + */ INLINE void BitArray:: set_word(size_t n, WordType value) { ensure_has_word(n); @@ -398,54 +330,43 @@ set_word(size_t n, WordType value) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::clear -// Access: Published -// Description: Sets all the bits in the BitArray off. -//////////////////////////////////////////////////////////////////// +/** + * Sets all the bits in the BitArray off. + */ void BitArray:: clear() { _array.clear(); _highest_bits = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BitArray:: operator == (const BitArray &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool BitArray:: operator != (const BitArray &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator < -// Access: Published -// Description: Returns true if the unsigned integer which is -// represented by this BitArray is less than that of the -// other one, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the unsigned integer which is represented by this BitArray + * is less than that of the other one, false otherwise. + */ INLINE bool BitArray:: operator < (const BitArray &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator & -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator & (const BitArray &other) const { BitArray result(*this); @@ -453,11 +374,9 @@ operator & (const BitArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator | -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator | (const BitArray &other) const { BitArray result(*this); @@ -465,11 +384,9 @@ operator | (const BitArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator ^ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator ^ (const BitArray &other) const { BitArray result(*this); @@ -477,11 +394,9 @@ operator ^ (const BitArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator ~ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator ~ () const { BitArray result(*this); @@ -489,11 +404,9 @@ operator ~ () const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator << -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator << (int shift) const { BitArray result(*this); @@ -501,11 +414,9 @@ operator << (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator >> -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BitArray BitArray:: operator >> (int shift) const { BitArray result(*this); @@ -513,14 +424,11 @@ operator >> (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::copy_on_write -// Access: Private -// Description: Called internally just before writing to the _array -// member, this makes a new copy of _array if it appears -// to be shared with any other objects--thus achieving -// copy-on-write. -//////////////////////////////////////////////////////////////////// +/** + * Called internally just before writing to the _array member, this makes a + * new copy of _array if it appears to be shared with any other objects--thus + * achieving copy-on-write. + */ INLINE void BitArray:: copy_on_write() { if (_array.get_ref_count() > 1) { diff --git a/panda/src/putil/bitArray.cxx b/panda/src/putil/bitArray.cxx index 99e7d7d653..f91c16d573 100644 --- a/panda/src/putil/bitArray.cxx +++ b/panda/src/putil/bitArray.cxx @@ -1,16 +1,15 @@ -// Filename: bitArray.cxx -// Created by: drose (20Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitArray.cxx + * @author drose + * @date 2006-01-20 + */ #include "bitArray.h" #include "sparseArray.h" @@ -19,11 +18,9 @@ TypeHandle BitArray::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BitArray::Constructor (from SparseArray) -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BitArray:: BitArray(const SparseArray &from) { _highest_bits = 0; @@ -40,17 +37,14 @@ BitArray(const SparseArray &from) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::is_zero -// Access: Published -// Description: Returns true if the entire bitmask is zero, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is zero, false otherwise. + */ bool BitArray:: is_zero() const { if (_highest_bits) { - // If all the infinite highest bits are set, certainly the bitmask - // is nonzero. + // If all the infinite highest bits are set, certainly the bitmask is + // nonzero. return false; } @@ -64,17 +58,14 @@ is_zero() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::is_all_on -// Access: Published -// Description: Returns true if the entire bitmask is one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is one, false otherwise. + */ bool BitArray:: is_all_on() const { if (!_highest_bits) { - // If all the infinite highest bits are not set, certainly the - // bitmask is not all on. + // If all the infinite highest bits are not set, certainly the bitmask is + // not all on. return false; } @@ -87,12 +78,9 @@ is_all_on() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::has_any_of -// Access: Published -// Description: Returns true if any bit in the indicated range is -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any bit in the indicated range is set, false otherwise. + */ bool BitArray:: has_any_of(int low_bit, int size) const { if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { @@ -143,12 +131,9 @@ has_any_of(int low_bit, int size) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::has_all_of -// Access: Published -// Description: Returns true if all bits in the indicated range are -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all bits in the indicated range are set, false otherwise. + */ bool BitArray:: has_all_of(int low_bit, int size) const { if ((low_bit + size - 1) / num_bits_per_word >= get_num_words()) { @@ -199,11 +184,9 @@ has_all_of(int low_bit, int size) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::set_range -// Access: Published -// Description: Sets the indicated range of bits on. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits on. + */ void BitArray:: set_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; @@ -251,11 +234,9 @@ set_range(int low_bit, int size) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::clear_range -// Access: Published -// Description: Sets the indicated range of bits off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits off. + */ void BitArray:: clear_range(int low_bit, int size) { int w = low_bit / num_bits_per_word; @@ -303,13 +284,10 @@ clear_range(int low_bit, int size) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_num_on_bits -// Access: Published -// Description: Returns the number of bits that are set to 1 in the -// array. Returns -1 if there are an infinite number of -// 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 1 in the array. Returns -1 if + * there are an infinite number of 1 bits. + */ int BitArray:: get_num_on_bits() const { if (_highest_bits) { @@ -324,13 +302,10 @@ get_num_on_bits() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_num_off_bits -// Access: Published -// Description: Returns the number of bits that are set to 0 in the -// array. Returns -1 if there are an infinite number of -// 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 0 in the array. Returns -1 if + * there are an infinite number of 0 bits. + */ int BitArray:: get_num_off_bits() const { if (!_highest_bits) { @@ -345,12 +320,10 @@ get_num_off_bits() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_lowest_on_bit -// Access: Published -// Description: Returns the index of the lowest 1 bit in the array. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the array. Returns -1 if there + * are no 1 bits. + */ int BitArray:: get_lowest_on_bit() const { int num_words = get_num_words(); @@ -367,12 +340,10 @@ get_lowest_on_bit() const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_lowest_off_bit -// Access: Published -// Description: Returns the index of the lowest 0 bit in the array. -// Returns -1 if there are no 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 0 bit in the array. Returns -1 if there + * are no 0 bits. + */ int BitArray:: get_lowest_off_bit() const { int num_words = get_num_words(); @@ -389,13 +360,10 @@ get_lowest_off_bit() const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_highest_on_bit -// Access: Published -// Description: Returns the index of the highest 1 bit in the array. -// Returns -1 if there are no 1 bits or if there an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the array. Returns -1 if there + * are no 1 bits or if there an infinite number of 1 bits. + */ int BitArray:: get_highest_on_bit() const { if (_highest_bits) { @@ -411,13 +379,10 @@ get_highest_on_bit() const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_highest_off_bit -// Access: Published -// Description: Returns the index of the highest 0 bit in the array. -// Returns -1 if there are no 0 bits or if there an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 0 bit in the array. Returns -1 if there + * are no 0 bits or if there an infinite number of 1 bits. + */ int BitArray:: get_highest_off_bit() const { if (!_highest_bits) { @@ -433,17 +398,13 @@ get_highest_off_bit() const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::get_next_higher_different_bit -// Access: Published -// Description: Returns the index of the next bit in the array, above -// low_bit, whose value is different that the value of -// low_bit. Returns low_bit again if all bits higher -// than low_bit have the same value. -// -// This can be used to quickly iterate through all of -// the bits in the array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the next bit in the array, above low_bit, whose value + * is different that the value of low_bit. Returns low_bit again if all bits + * higher than low_bit have the same value. + * + * This can be used to quickly iterate through all of the bits in the array. + */ int BitArray:: get_next_higher_different_bit(int low_bit) const { int w = low_bit / num_bits_per_word; @@ -473,17 +434,15 @@ get_next_higher_different_bit(int low_bit) const { // The first bit of word w2 is different. return w2 * num_bits_per_word; } - + b2 = _array[w2].get_next_higher_different_bit(0); return w2 * num_bits_per_word + b2; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::invert_in_place -// Access: Published -// Description: Inverts all the bits in the BitArray. This is -// equivalent to array = ~array. -//////////////////////////////////////////////////////////////////// +/** + * Inverts all the bits in the BitArray. This is equivalent to array = + * ~array. + */ void BitArray:: invert_in_place() { _highest_bits = !_highest_bits; @@ -494,15 +453,12 @@ invert_in_place() { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::has_bits_in_common -// Access: Published -// Description: Returns true if this BitArray has any "one" bits in -// common with the other one, false otherwise. -// -// This is equivalent to (array & other) != 0, but may -// be faster. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this BitArray has any "one" bits in common with the other + * one, false otherwise. + * + * This is equivalent to (array & other) != 0, but may be faster. + */ bool BitArray:: has_bits_in_common(const BitArray &other) const { if (_highest_bits && other._highest_bits) { @@ -514,9 +470,9 @@ has_bits_in_common(const BitArray &other) const { // Consider the words that are on top of either array. if (other._array.size() < _array.size() && other._highest_bits) { - // The other array has fewer actual words, and the top n words of - // the other array are all ones. We have bits in common if any of - // our top n words are nonzero. + // The other array has fewer actual words, and the top n words of the + // other array are all ones. We have bits in common if any of our top n + // words are nonzero. Array::const_iterator ai; for (ai = _array.begin() + other._array.size(); ai != _array.end(); @@ -525,11 +481,11 @@ has_bits_in_common(const BitArray &other) const { return true; } } - + } else if (_array.size() < other._array.size() && _highest_bits) { - // This array has fewer actual words, and the top n words of this - // array are all ones. We have bits in common if any of the the - // other's top n words are nonzero. + // This array has fewer actual words, and the top n words of this array + // are all ones. We have bits in common if any of the the other's top n + // words are nonzero. Array::const_iterator ai; for (ai = other._array.begin() + _array.size(); ai != other._array.end(); @@ -551,25 +507,19 @@ has_bits_in_common(const BitArray &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::output -// Access: Published -// Description: Writes the BitArray out as a hex number. For a -// BitArray, this is always the same as output_hex(); -// it's too confusing for the output format to change -// back and forth at runtime. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitArray out as a hex number. For a BitArray, this is always + * the same as output_hex(); it's too confusing for the output format to + * change back and forth at runtime. + */ void BitArray:: output(ostream &out) const { output_hex(out); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::output_binary -// Access: Published -// Description: Writes the BitArray out as a binary number, with -// spaces every four bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitArray out as a binary number, with spaces every four bits. + */ void BitArray:: output_binary(ostream &out, int spaces_every) const { if (_highest_bits) { @@ -584,12 +534,10 @@ output_binary(ostream &out, int spaces_every) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::output_hex -// Access: Published -// Description: Writes the BitArray out as a hexadecimal number, with -// spaces every four digits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitArray out as a hexadecimal number, with spaces every four + * digits. + */ void BitArray:: output_hex(ostream &out, int spaces_every) const { int num_bits = get_num_bits(); @@ -612,25 +560,20 @@ output_hex(ostream &out, int spaces_every) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::write -// Access: Published -// Description: Writes the BitArray out as a binary or a hex number, -// according to the number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitArray out as a binary or a hex number, according to the + * number of bits. + */ void BitArray:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::compare_to -// Access: Published -// Description: Returns a number less than zero if this BitArray sorts -// before the indicated other BitArray, greater than zero -// if it sorts after, or 0 if they are equivalent. This -// is based on the same ordering defined by operator <. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this BitArray sorts before the indicated + * other BitArray, greater than zero if it sorts after, or 0 if they are + * equivalent. This is based on the same ordering defined by operator <. + */ int BitArray:: compare_to(const BitArray &other) const { if (_highest_bits != other._highest_bits) { @@ -650,11 +593,9 @@ compare_to(const BitArray &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator &= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BitArray:: operator &= (const BitArray &other) { size_t num_common_words = min(_array.size(), other._array.size()); @@ -663,15 +604,13 @@ operator &= (const BitArray &other) { // Consider the words that are on top of either array. if (other._array.size() < _array.size() && !other._highest_bits) { - // The other array has fewer actual words, and the top n words of - // the other array are all zeroes. "mask off" the top n words of - // this array. + // The other array has fewer actual words, and the top n words of the + // other array are all zeroes. "mask off" the top n words of this array. _array.erase(_array.begin() + other._array.size(), _array.end()); } else if (_array.size() < other._array.size() && _highest_bits) { - // This array has fewer actual words, and the top n words of this - // array are all ones. "mask on" the top n words of the other - // array. + // This array has fewer actual words, and the top n words of this array + // are all ones. "mask on" the top n words of the other array. Array::const_iterator ai; for (ai = other._array.begin() + _array.size(); ai != other._array.end(); @@ -689,11 +628,9 @@ operator &= (const BitArray &other) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator |= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BitArray:: operator |= (const BitArray &other) { size_t num_common_words = min(_array.size(), other._array.size()); @@ -702,15 +639,14 @@ operator |= (const BitArray &other) { // Consider the words that are on top of either array. if (other._array.size() < _array.size() && other._highest_bits) { - // The other array has fewer actual words, and the top n words of - // the other array are all ones. The top n words of this array - // become ones too (which means we can drop them out). + // The other array has fewer actual words, and the top n words of the + // other array are all ones. The top n words of this array become ones + // too (which means we can drop them out). _array.erase(_array.begin() + other._array.size(), _array.end()); } else if (_array.size() < other._array.size() && !_highest_bits) { - // This array has fewer actual words, and the top n words of this - // array are all zeros. Copy in the top n words of the other - // array. + // This array has fewer actual words, and the top n words of this array + // are all zeros. Copy in the top n words of the other array. Array::const_iterator ai; for (ai = other._array.begin() + _array.size(); ai != other._array.end(); @@ -728,11 +664,9 @@ operator |= (const BitArray &other) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator ^= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BitArray:: operator ^= (const BitArray &other) { size_t num_common_words = min(_array.size(), other._array.size()); @@ -741,9 +675,8 @@ operator ^= (const BitArray &other) { // Consider the words that are on top of either array. if (other._array.size() < _array.size() && other._highest_bits) { - // The other array has fewer actual words, and the top n words of - // the other array are all ones. The top n words of this array - // get inverted. + // The other array has fewer actual words, and the top n words of the + // other array are all ones. The top n words of this array get inverted. Array::iterator ai; for (ai = _array.begin() + other._array.size(); ai != _array.end(); @@ -753,9 +686,8 @@ operator ^= (const BitArray &other) { } else if (_array.size() < other._array.size()) { if (!_highest_bits) { - // This array has fewer actual words, and the top n words of this - // array are all zeros. Copy in the top n words of the other - // array. + // This array has fewer actual words, and the top n words of this array + // are all zeros. Copy in the top n words of the other array. Array::const_iterator ai; for (ai = other._array.begin() + _array.size(); ai != other._array.end(); @@ -763,9 +695,8 @@ operator ^= (const BitArray &other) { _array.push_back(*ai); } } else { - // This array has fewer actual words, and the top n words of this - // array are all ones. Copy in the top n words of the other - // array, inverted. + // This array has fewer actual words, and the top n words of this array + // are all ones. Copy in the top n words of the other array, inverted. Array::const_iterator ai; for (ai = other._array.begin() + _array.size(); ai != other._array.end(); @@ -784,13 +715,10 @@ operator ^= (const BitArray &other) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator <<= -// Access: Published -// Description: Logical left shift. The rightmost bits are filled in -// with zeroes. Since this is an infinite bit array, -// none of the bits on the left are lost. -//////////////////////////////////////////////////////////////////// +/** + * Logical left shift. The rightmost bits are filled in with zeroes. Since + * this is an infinite bit array, none of the bits on the left are lost. + */ void BitArray:: operator <<= (int shift) { if (shift == 0 || _array.empty()) { @@ -851,14 +779,11 @@ operator <<= (int shift) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::operator >>= -// Access: Published -// Description: Logical right shift. The rightmost bits are lost. -// Since this is an infinite bit array, there is no -// question of sign extension; there is no need to -// synthesize bits on the left. -//////////////////////////////////////////////////////////////////// +/** + * Logical right shift. The rightmost bits are lost. Since this is an + * infinite bit array, there is no question of sign extension; there is no + * need to synthesize bits on the left. + */ void BitArray:: operator >>= (int shift) { if (shift == 0 || _array.empty()) { @@ -900,7 +825,7 @@ operator >>= (int shift) { Array::const_iterator ai = _array.begin() + w; nassertv(ai < _array.end()); MaskType next_bits = ((*ai) & upper_mask) >> b; - + ++ai; while (ai != _array.end()) { new_array.push_back((((*ai) & lower_mask) << upshift_count) | next_bits); @@ -919,11 +844,9 @@ operator >>= (int shift) { normalize(); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::generate_hash -// Access: Public -// Description: Adds the bitmask to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the bitmask to the indicated hash generator. + */ void BitArray:: generate_hash(ChecksumHashGenerator &hashgen) const { hashgen.add_int(_highest_bits); @@ -933,12 +856,9 @@ generate_hash(ChecksumHashGenerator &hashgen) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::ensure_has_word -// Access: Private -// Description: Ensures that at least word n has been allocated into -// the array. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that at least word n has been allocated into the array. + */ void BitArray:: ensure_has_word(int n) { copy_on_write(); @@ -954,13 +874,10 @@ ensure_has_word(int n) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::normalize -// Access: Private -// Description: Ensures that the array is the smallest array that -// represents this same value, by removing the topmost -// words that are all bits off (or on). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the array is the smallest array that represents this same + * value, by removing the topmost words that are all bits off (or on). + */ void BitArray:: normalize() { if (_highest_bits) { @@ -982,12 +899,10 @@ normalize() { } } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void BitArray:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint32(_array.size()); @@ -998,12 +913,9 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint8(_highest_bits); } -//////////////////////////////////////////////////////////////////// -// Function: BitArray::read_datagram -// Access: Public -// Description: Reads the object that was previously written to a Bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the object that was previously written to a Bam file. + */ void BitArray:: read_datagram(DatagramIterator &scan, BamReader *manager) { size_t num_words = scan.get_uint32(); diff --git a/panda/src/putil/bitArray.h b/panda/src/putil/bitArray.h index 8bab5c0876..3a4a4b16d2 100644 --- a/panda/src/putil/bitArray.h +++ b/panda/src/putil/bitArray.h @@ -1,16 +1,15 @@ -// Filename: bitArray.h -// Created by: drose (20Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitArray.h + * @author drose + * @date 2006-01-20 + */ #ifndef BITARRAY_H #define BITARRAY_H @@ -31,14 +30,12 @@ class BamReader; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : BitArray -// Description : A dynamic array with an unlimited number of bits. -// -// This is similar to a BitMask, except it appears to -// contain an infinite number of bits. You can use it -// very much as you would use a BitMask. -//////////////////////////////////////////////////////////////////// +/** + * A dynamic array with an unlimited number of bits. + * + * This is similar to a BitMask, except it appears to contain an infinite + * number of bits. You can use it very much as you would use a BitMask. + */ class EXPCL_PANDA_PUTIL BitArray { public: typedef BitMaskNative MaskType; diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 5f4321e213..dca29c5b6a 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -1,25 +1,22 @@ -// Filename: bitMask.I -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitMask.I + * @author drose + * @date 2000-06-08 + */ template TypeHandle BitMask::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask:: BitMask() : @@ -27,11 +24,9 @@ BitMask() : { } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask:: BitMask(WordType init_value) : @@ -39,11 +34,9 @@ BitMask(WordType init_value) : { } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask:: BitMask(const BitMask ©) : @@ -51,11 +44,9 @@ BitMask(const BitMask ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask &BitMask:: operator = (const BitMask ©) { @@ -63,11 +54,9 @@ operator = (const BitMask ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Named all_on constructor -// Access: Published, Static -// Description: Returns a BitMask whose bits are all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask whose bits are all on. + */ template INLINE BitMask BitMask:: all_on() { @@ -76,11 +65,9 @@ all_on() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Named all_on constructor -// Access: Published, Static -// Description: Returns a BitMask whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask whose bits are all off. + */ template INLINE BitMask BitMask:: all_off() { @@ -89,11 +76,9 @@ all_off() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Named lower_on constructor -// Access: Published, Static -// Description: Returns a BitMask whose lower on_bits bits are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask whose lower on_bits bits are on. + */ template INLINE BitMask BitMask:: lower_on(int on_bits) { @@ -107,11 +92,9 @@ lower_on(int on_bits) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Named bit constructor -// Access: Published, Static -// Description: Returns a BitMask with only the indicated bit on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the indicated bit on. + */ template INLINE BitMask BitMask:: bit(int index) { @@ -120,12 +103,9 @@ bit(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Named range constructor -// Access: Published, Static -// Description: Returns a BitMask whose size bits, beginning at -// low_bit, are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask whose size bits, beginning at low_bit, are on. + */ template INLINE BitMask BitMask:: range(int low_bit, int size) { @@ -141,72 +121,56 @@ range(int low_bit, int size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask:: ~BitMask() { } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::has_max_num_bits -// Access: Published, Static -// Description: Returns true if there is a maximum number of bits -// that may be stored in this structure, false -// otherwise. If this returns true, the number may be -// queried in get_max_num_bits(). -// -// This method always returns true. This method is -// defined so generic programming algorithms can use -// BitMask or BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a maximum number of bits that may be stored in + * this structure, false otherwise. If this returns true, the number may be + * queried in get_max_num_bits(). + * + * This method always returns true. This method is defined so generic + * programming algorithms can use BitMask or BitArray interchangeably. + */ template CONSTEXPR bool BitMask:: has_max_num_bits() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_max_num_bits -// Access: Published, Static -// Description: If get_max_num_bits() returned true, this method may -// be called to return the maximum number of bits that -// may be stored in this structure. It is an error to -// call this if get_max_num_bits() return false. -// -// It is never an error to call this method. This -// returns the same thing as get_num_bits(). This -// method is defined so generic programming algorithms -// can use BitMask or BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * If get_max_num_bits() returned true, this method may be called to return + * the maximum number of bits that may be stored in this structure. It is an + * error to call this if get_max_num_bits() return false. + * + * It is never an error to call this method. This returns the same thing as + * get_num_bits(). This method is defined so generic programming algorithms + * can use BitMask or BitArray interchangeably. + */ template CONSTEXPR int BitMask:: get_max_num_bits() { return num_bits; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_num_bits -// Access: Published, Static -// Description: Returns the number of bits available to set in the -// bitmask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits available to set in the bitmask. + */ template CONSTEXPR int BitMask:: get_num_bits() { return num_bits; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. index must be in the range [0, -// num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. index must be + * in the range [0, num_bits). + */ template INLINE bool BitMask:: get_bit(int index) const { @@ -214,12 +178,9 @@ get_bit(int index) const { return (_word & ((WordType)1 << index)) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::set_bit -// Access: Published -// Description: Sets the nth bit on. index must be in the range -// [0, num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. index must be in the range [0, num_bits). + */ template INLINE void BitMask:: set_bit(int index) { @@ -227,12 +188,9 @@ set_bit(int index) { _word |= ((WordType)1 << index); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::clear_bit -// Access: Published -// Description: Sets the nth bit off. index must be in the range -// [0, num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. index must be in the range [0, num_bits). + */ template INLINE void BitMask:: clear_bit(int index) { @@ -240,13 +198,10 @@ clear_bit(int index) { _word &= ~((WordType)1 << index); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::set_bit_to -// Access: Published -// Description: Sets the nth bit either on or off, according to the -// indicated bool value. index must be in the range [0, -// num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit either on or off, according to the indicated bool value. + * index must be in the range [0, num_bits). + */ template INLINE void BitMask:: set_bit_to(int index, bool value) { @@ -257,37 +212,28 @@ set_bit_to(int index, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::is_zero -// Access: Published -// Description: Returns true if the entire bitmask is zero, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is zero, false otherwise. + */ template INLINE bool BitMask:: is_zero() const { return (_word == 0); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::is_all_on -// Access: Published -// Description: Returns true if the entire bitmask is one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is one, false otherwise. + */ template INLINE bool BitMask:: is_all_on() const { return (~_word == 0); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::extract -// Access: Published -// Description: Returns a word that represents only the indicated -// range of bits within this BitMask, shifted to the -// least-significant position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a word that represents only the indicated range of bits within this + * BitMask, shifted to the least-significant position. + */ template INLINE TYPENAME BitMask::WordType BitMask:: extract(int low_bit, int size) const { @@ -295,12 +241,10 @@ extract(int low_bit, int size) const { BitMask::lower_on(size)._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::store -// Access: Published -// Description: Stores the indicated word into the indicated range of -// bits with this BitMask. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated word into the indicated range of bits with this + * BitMask. + */ template INLINE void BitMask:: store(WordType value, int low_bit, int size) { @@ -308,12 +252,9 @@ store(WordType value, int low_bit, int size) { _word = (_word & ~mask) | ((value << low_bit) & mask); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::has_any_of -// Access: Published -// Description: Returns true if any bit in the indicated range is -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any bit in the indicated range is set, false otherwise. + */ template INLINE bool BitMask:: has_any_of(int low_bit, int size) const { @@ -321,12 +262,9 @@ has_any_of(int low_bit, int size) const { return (_word & mask) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::has_all_of -// Access: Published -// Description: Returns true if all bits in the indicated range are -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all bits in the indicated range are set, false otherwise. + */ template INLINE bool BitMask:: has_all_of(int low_bit, int size) const { @@ -334,11 +272,9 @@ has_all_of(int low_bit, int size) const { return (_word & mask) == mask; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::set_range -// Access: Published -// Description: Sets the indicated range of bits on. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits on. + */ template INLINE void BitMask:: set_range(int low_bit, int size) { @@ -346,11 +282,9 @@ set_range(int low_bit, int size) { _word |= mask; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::clear_range -// Access: Published -// Description: Sets the indicated range of bits off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits off. + */ template INLINE void BitMask:: clear_range(int low_bit, int size) { @@ -358,11 +292,9 @@ clear_range(int low_bit, int size) { _word &= ~mask; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::set_range_to -// Access: Published -// Description: Sets the indicated range of bits to either on or off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits to either on or off. + */ template INLINE void BitMask:: set_range_to(bool value, int low_bit, int size) { @@ -373,117 +305,94 @@ set_range_to(bool value, int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_word -// Access: Published -// Description: Returns the entire BitMask as a single word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire BitMask as a single word. + */ template INLINE TYPENAME BitMask::WordType BitMask:: get_word() const { return _word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::set_word -// Access: Published -// Description: Sets the entire BitMask to the value indicated by the -// given word. -//////////////////////////////////////////////////////////////////// +/** + * Sets the entire BitMask to the value indicated by the given word. + */ template INLINE void BitMask:: set_word(WordType value) { _word = value; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_num_on_bits -// Access: Published -// Description: Returns the number of bits that are set to 1 in the -// mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 1 in the mask. + */ template INLINE int BitMask:: get_num_on_bits() const { return count_bits_in_word((WType)_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_num_off_bits -// Access: Published -// Description: Returns the number of bits that are set to 0 in the -// mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 0 in the mask. + */ template INLINE int BitMask:: get_num_off_bits() const { return count_bits_in_word((WType)(~_word)); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_lowest_on_bit -// Access: Published -// Description: Returns the index of the lowest 1 bit in the mask. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the mask. Returns -1 if there are + * no 1 bits. + */ template INLINE int BitMask:: get_lowest_on_bit() const { return ::get_lowest_on_bit(_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_lowest_off_bit -// Access: Published -// Description: Returns the index of the lowest 0 bit in the mask. -// Returns -1 if there are no 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 0 bit in the mask. Returns -1 if there are + * no 0 bits. + */ template INLINE int BitMask:: get_lowest_off_bit() const { return (~(*this)).get_lowest_on_bit(); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_highest_on_bit -// Access: Published -// Description: Returns the index of the highest 1 bit in the mask. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the mask. Returns -1 if there + * are no 1 bits. + */ template INLINE int BitMask:: get_highest_on_bit() const { return ::get_highest_on_bit(_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_highest_off_bit -// Access: Published -// Description: Returns the index of the highest 0 bit in the mask. -// Returns -1 if there are no 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 0 bit in the mask. Returns -1 if there + * are no 0 bits. + */ template INLINE int BitMask:: get_highest_off_bit() const { return (~(*this)).get_highest_on_bit(); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_next_higher_different_bit -// Access: Published -// Description: Returns the index of the next bit in the mask, above -// low_bit, whose value is different that the value of -// low_bit. Returns low_bit again if all bits higher -// than low_bit have the same value. -// -// This can be used to quickly iterate through all of -// the bits in the mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the next bit in the mask, above low_bit, whose value + * is different that the value of low_bit. Returns low_bit again if all bits + * higher than low_bit have the same value. + * + * This can be used to quickly iterate through all of the bits in the mask. + */ template INLINE int BitMask:: get_next_higher_different_bit(int low_bit) const { - // We are allowed to call this method with low_bit == num_bits, - // which is the highest value this method will return. + // We are allowed to call this method with low_bit == num_bits, which is the + // highest value this method will return. nassertr(low_bit >= 0, low_bit); if (low_bit >= num_bits) { return low_bit; @@ -492,29 +401,29 @@ get_next_higher_different_bit(int low_bit) const { WordType is_on = (_word & ((WordType)1 << low_bit)); WordType w; if (is_on) { - // low_bit is 1. Get the next higher 0 bit. To do this, invert - // the word and the get the next higher 1 bit. + // low_bit is 1. Get the next higher 0 bit. To do this, invert the word + // and the get the next higher 1 bit. w = ~_word; } else { // low_bit is 0. Get the next higher 1 bit. w = _word; } - // Mask out all of the bits below low_bit. Since we already know - // that low_bit is 0, we can use (1 << low_bit) instead of (1 << - // (low_bit + 1)), which becomes undefined when (low_bit + 1) == 32. + // Mask out all of the bits below low_bit. Since we already know that + // low_bit is 0, we can use (1 << low_bit) instead of (1 << (low_bit + 1)), + // which becomes undefined when (low_bit + 1) == 32. w &= ~(((WordType)1 << low_bit) - 1); if (w == 0) { - // All higher bits in the word have the same value. Since every - // bit after the topmost bit is 0, we either return the topmost - // bit + 1 to indicate the next 0 bit, or low_bit to indicate we - // have reached the end of the number of bits. + // All higher bits in the word have the same value. Since every bit after + // the topmost bit is 0, we either return the topmost bit + 1 to indicate + // the next 0 bit, or low_bit to indicate we have reached the end of the + // number of bits. return is_on ? num_bits : low_bit; } else { - // Now determine the lowest 1 bit in the remaining word. This - // operation will clear out all bits except for the lowest 1 bit. + // Now determine the lowest 1 bit in the remaining word. This operation + // will clear out all bits except for the lowest 1 bit. w = (w & (~w + 1)); // And the answer is the number of bits in (w - 1). @@ -522,52 +431,42 @@ get_next_higher_different_bit(int low_bit) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::invert_in_place -// Access: Published -// Description: Inverts all the bits in the BitMask. This is -// equivalent to mask = ~mask. -//////////////////////////////////////////////////////////////////// +/** + * Inverts all the bits in the BitMask. This is equivalent to mask = ~mask. + */ template INLINE void BitMask:: invert_in_place() { _word = ~_word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::has_bits_in_common -// Access: Published -// Description: Returns true if this BitMask has any "one" bits in -// common with the other one, false otherwise. -// -// This is equivalent to (mask & other) != 0, but may be -// faster. (Actually, it should only be faster in the -// BitArray case, but this method is provided for the -// benefit of generic programming algorithms). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this BitMask has any "one" bits in common with the other + * one, false otherwise. + * + * This is equivalent to (mask & other) != 0, but may be faster. (Actually, + * it should only be faster in the BitArray case, but this method is provided + * for the benefit of generic programming algorithms). + */ template INLINE bool BitMask:: has_bits_in_common(const BitMask &other) const { return (_word & other._word) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::clear -// Access: Published -// Description: Sets all the bits in the BitMask off. -//////////////////////////////////////////////////////////////////// +/** + * Sets all the bits in the BitMask off. + */ template INLINE void BitMask:: clear() { _word = 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::output -// Access: Published -// Description: Writes the BitMask out as a binary or a hex number, -// according to the number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitMask out as a binary or a hex number, according to the number + * of bits. + */ template void BitMask:: output(ostream &out) const { @@ -578,12 +477,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::output_binary -// Access: Published -// Description: Writes the BitMask out as a binary number, with -// spaces every four bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitMask out as a binary number, with spaces every four bits. + */ template void BitMask:: output_binary(ostream &out, int spaces_every) const { @@ -595,12 +491,10 @@ output_binary(ostream &out, int spaces_every) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::output_hex -// Access: Published -// Description: Writes the BitMask out as a hexadecimal number, with -// spaces every four digits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitMask out as a hexadecimal number, with spaces every four + * digits. + */ template void BitMask:: output_hex(ostream &out, int spaces_every) const { @@ -619,65 +513,52 @@ output_hex(ostream &out, int spaces_every) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::write -// Access: Published -// Description: Writes the BitMask out as a binary or a hex number, -// according to the number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the BitMask out as a binary or a hex number, according to the number + * of bits. + */ template void BitMask:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool BitMask:: operator == (const BitMask &other) const { return _word == other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool BitMask:: operator != (const BitMask &other) const { return _word != other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator < -// Access: Published -// Description: The ordering operator is of limited usefulness with a -// BitMask, however, it has a definition which places -// all unique BitMasks into a unique ordering. It may -// be useful when defining ordered STL containers of -// BitMasks, for instance; and it's required in order to -// export any STL container (ordered or unordered) of -// BitMask under Windows. -//////////////////////////////////////////////////////////////////// +/** + * The ordering operator is of limited usefulness with a BitMask, however, it + * has a definition which places all unique BitMasks into a unique ordering. + * It may be useful when defining ordered STL containers of BitMasks, for + * instance; and it's required in order to export any STL container (ordered + * or unordered) of BitMask under Windows. + */ template INLINE bool BitMask:: operator < (const BitMask &other) const { return _word < other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::compare_to -// Access: Published -// Description: Returns a number less than zero if this BitMask sorts -// before the indicated other BitMask, greater than zero -// if it sorts after, or 0 if they are equivalent. This -// is based on the same ordering defined by operator <. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this BitMask sorts before the indicated + * other BitMask, greater than zero if it sorts after, or 0 if they are + * equivalent. This is based on the same ordering defined by operator <. + */ template INLINE int BitMask:: compare_to(const BitMask &other) const { @@ -690,11 +571,9 @@ compare_to(const BitMask &other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator & -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator & (const BitMask &other) const { @@ -703,11 +582,9 @@ operator & (const BitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator | -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator | (const BitMask &other) const { @@ -716,11 +593,9 @@ operator | (const BitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator ^ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator ^ (const BitMask &other) const { @@ -729,22 +604,18 @@ operator ^ (const BitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator ~ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator ~ () const { return BitMask(~_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator << -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator << (int shift) const { @@ -753,11 +624,9 @@ operator << (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator >> -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE BitMask BitMask:: operator >> (int shift) const { @@ -766,133 +635,109 @@ operator >> (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator &= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void BitMask:: operator &= (const BitMask &other) { _word &= other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator |= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void BitMask:: operator |= (const BitMask &other) { _word |= other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator ^= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void BitMask:: operator ^= (const BitMask &other) { _word ^= other._word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator <<= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void BitMask:: operator <<= (int shift) { _word <<= shift; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::operator >>= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void BitMask:: operator >>= (int shift) { _word >>= shift; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::get_key -// Access: Published -// Description: Returns a mostly unique integer key per unique -// bitmask, suitable for using in a hash table. -//////////////////////////////////////////////////////////////////// +/** + * Returns a mostly unique integer key per unique bitmask, suitable for using + * in a hash table. + */ template INLINE int BitMask:: get_key() const { return (int)_word; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::__nonzero__ -// Access: Published -// Description: Returns true if the bitmask is not zero. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the bitmask is not zero. + */ template INLINE bool BitMask:: __nonzero__() const { return _word != 0; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::generate_hash -// Access: Public -// Description: Adds the bitmask to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the bitmask to the indicated hash generator. + */ template INLINE void BitMask:: generate_hash(ChecksumHashGenerator &hashgen) const { hashgen.add_int(_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void BitMask:: init_type(const string &name) { register_type(_type_handle, name); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::flood_up_in_place -// Access: Published -// Description: Floods this bitmask's bits upwards. -//////////////////////////////////////////////////////////////////// +/** + * Floods this bitmask's bits upwards. + */ template INLINE void BitMask:: flood_up_in_place() { _word = ::flood_bits_up(_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::flood_down_in_place -// Access: Published -// Description: Floods this bitmask's bits downwards. -//////////////////////////////////////////////////////////////////// +/** + * Floods this bitmask's bits downwards. + */ template INLINE void BitMask:: flood_down_in_place() { _word = ::flood_bits_down(_word); } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::flood_bits_up -// Access: Published -// Description: Returns a BitMask with the bits flooded upwards. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with the bits flooded upwards. + */ template INLINE BitMask BitMask:: flood_bits_up() const { @@ -900,11 +745,9 @@ flood_bits_up() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::flood_bits_down -// Access: Published -// Description: Returns a BitMask with the bits flooded down. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with the bits flooded down. + */ template INLINE BitMask BitMask:: flood_bits_down() const { @@ -913,12 +756,10 @@ flood_bits_down() const { } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_highest_bit -// Access: Published -// Description: Returns a BitMask with only the next highest -// bit above the indicated bit on, or all_off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next highest bit above the indicated bit + * on, or all_off. + */ template INLINE BitMask BitMask:: keep_next_highest_bit() const { @@ -930,12 +771,10 @@ keep_next_highest_bit() const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_lowest_bit -// Access: Published -// Description: Returns a BitMask with only the next lower -// bit below the indicated bit on, or all_off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next lower bit below the indicated bit on, + * or all_off. + */ template INLINE BitMask BitMask:: keep_next_lowest_bit() const { @@ -947,12 +786,10 @@ keep_next_lowest_bit() const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_highest_bit -// Access: Published -// Description: Returns a BitMask with only the next highest -// bit above the indicated bit on, or all. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next highest bit above the indicated bit + * on, or all. + */ template INLINE BitMask BitMask:: keep_next_highest_bit(int index) const { @@ -973,12 +810,10 @@ keep_next_highest_bit(int index) const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_lowest_bit -// Access: Published -// Description: Returns a BitMask with only the next lower -// bit below the indicated bit on, or all_off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next lower bit below the indicated bit on, + * or all_off. + */ template INLINE BitMask BitMask:: keep_next_lowest_bit(int index) const { @@ -999,14 +834,11 @@ keep_next_lowest_bit(int index) const { return mask; } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_highest_bit -// Access: Published -// Description: Returns a BitMask with only the next highest "on" -// bit above all "on" bits in the passed in bitmask, or -// all_off. If there are no "on" bits in the passed in -// bitmask, it will return keep_next_highest_bit(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next highest "on" bit above all "on" bits + * in the passed in bitmask, or all_off. If there are no "on" bits in the + * passed in bitmask, it will return keep_next_highest_bit(). + */ template INLINE BitMask BitMask:: keep_next_highest_bit(const BitMask &other) const { @@ -1018,14 +850,11 @@ keep_next_highest_bit(const BitMask &other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: BitMask::keep_next_lowest_bit -// Access: Published -// Description: Returns a BitMask with only the next lowest "on" -// bit below all "on" bits in the passed in bitmask, or -// all_off. If there are no "on" bits in the passed in -// bitmask, it will return keep_next_lowest_bit(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a BitMask with only the next lowest "on" bit below all "on" bits in + * the passed in bitmask, or all_off. If there are no "on" bits in the passed + * in bitmask, it will return keep_next_lowest_bit(). + */ template INLINE BitMask BitMask:: keep_next_lowest_bit(const BitMask &other) const { diff --git a/panda/src/putil/bitMask.cxx b/panda/src/putil/bitMask.cxx index 11c14414b2..22b7370f95 100644 --- a/panda/src/putil/bitMask.cxx +++ b/panda/src/putil/bitMask.cxx @@ -1,16 +1,15 @@ -// Filename: bitMask.cxx -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitMask.cxx + * @author drose + * @date 2000-06-08 + */ #include "bitMask.h" diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 05b9f7ddae..a2b2bdab13 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -1,16 +1,15 @@ -// Filename: bitMask.h -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bitMask.h + * @author drose + * @date 2000-06-08 + */ #ifndef BITMASK_H #define BITMASK_H @@ -25,12 +24,10 @@ #include "checksumHashGenerator.h" -//////////////////////////////////////////////////////////////////// -// Class : BitMask -// Description : A general bitmask class. This stores an array of -// bits of some length that must fit within a given word -// of the indicated type. See also BitArray. -//////////////////////////////////////////////////////////////////// +/** + * A general bitmask class. This stores an array of bits of some length that + * must fit within a given word of the indicated type. See also BitArray. + */ template class BitMask { public: diff --git a/panda/src/putil/buttonHandle.I b/panda/src/putil/buttonHandle.I index ee12c6e13b..40e157baa8 100644 --- a/panda/src/putil/buttonHandle.I +++ b/panda/src/putil/buttonHandle.I @@ -1,167 +1,132 @@ -// Filename: buttonHandle.I -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonHandle.I + * @author drose + * @date 2000-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Constructor -// Access: Published -// Description: The default constructor must do nothing, because we -// can't guarantee ordering of static initializers. If -// the constructor tried to initialize its value, it -// might happen after the value had already been set -// previously by another static initializer! -//////////////////////////////////////////////////////////////////// +/** + * The default constructor must do nothing, because we can't guarantee + * ordering of static initializers. If the constructor tried to initialize + * its value, it might happen after the value had already been set previously + * by another static initializer! + */ INLINE ButtonHandle:: ButtonHandle() { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Constructor -// Access: Published -// Description: Constructs a ButtonHandle with the corresponding -// index number, which may have been returned by an -// earlier call to ButtonHandle::get_index(). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a ButtonHandle with the corresponding index number, which may + * have been returned by an earlier call to ButtonHandle::get_index(). + */ CONSTEXPR ButtonHandle:: ButtonHandle(int index) : _index(index) { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonHandle:: ButtonHandle(const ButtonHandle ©) : _index(copy._index) { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Equality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator == (const ButtonHandle &other) const { return (_index == other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Inequality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator != (const ButtonHandle &other) const { return (_index != other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator < (const ButtonHandle &other) const { return (_index < other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator <= (const ButtonHandle &other) const { return (_index <= other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator > (const ButtonHandle &other) const { return (_index > other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ButtonHandle:: operator >= (const ButtonHandle &other) const { return (_index >= other._index); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::compare_to -// Access: Published -// Description: Sorts ButtonHandles arbitrarily (according to <, >, -// etc.). Returns a number less than 0 if this type -// sorts before the other one, greater than zero if it -// sorts after, 0 if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Sorts ButtonHandles arbitrarily (according to <, >, etc.). Returns a + * number less than 0 if this type sorts before the other one, greater than + * zero if it sorts after, 0 if they are equivalent. + */ INLINE int ButtonHandle:: compare_to(const ButtonHandle &other) const { return _index - other._index; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::get_hash -// Access: Published -// Description: Returns a hash code suitable for phash_map. -//////////////////////////////////////////////////////////////////// +/** + * Returns a hash code suitable for phash_map. + */ INLINE size_t ButtonHandle:: get_hash() const { return (size_t)_index; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::has_ascii_equivalent -// Access: Published -// Description: Returns true if the button was created with an ASCII -// equivalent code (e.g. for a standard keyboard -// button). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the button was created with an ASCII equivalent code (e.g. + * for a standard keyboard button). + */ INLINE bool ButtonHandle:: has_ascii_equivalent() const { return (_index > 0 && _index < 128); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::get_ascii_equivalent -// Access: Published -// Description: Returns the character code associated with the -// button, or '\0' if no ASCII code was associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the character code associated with the button, or '\0' if no ASCII + * code was associated. + */ INLINE char ButtonHandle:: get_ascii_equivalent() const { return has_ascii_equivalent() ? (char)_index : '\0'; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::matches -// Access: Published -// Description: Returns true if this ButtonHandle is the same as the -// other one, or if the other one is an alias for this -// one. (Does not return true if this button is an -// alias for the other one, however.) -// -// This is a more general comparison than operator ==. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this ButtonHandle is the same as the other one, or if the + * other one is an alias for this one. (Does not return true if this button + * is an alias for the other one, however.) + * + * This is a more general comparison than operator ==. + */ INLINE bool ButtonHandle:: matches(const ButtonHandle &other) const { return ((*this) == other || @@ -169,49 +134,38 @@ matches(const ButtonHandle &other) const { get_alias() == other)); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::get_index -// Access: Published -// Description: Returns the integer index associated with this -// ButtonHandle. Each different ButtonHandle will have a -// different index. However, you probably shouldn't be -// using this method; you should just treat the -// ButtonHandles as opaque classes. This is provided -// for the convenience of non-C++ scripting languages to -// build a hashtable of ButtonHandles. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer index associated with this ButtonHandle. Each + * different ButtonHandle will have a different index. However, you probably + * shouldn't be using this method; you should just treat the ButtonHandles as + * opaque classes. This is provided for the convenience of non-C++ scripting + * languages to build a hashtable of ButtonHandles. + */ CONSTEXPR int ButtonHandle:: get_index() const { return _index; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ButtonHandle:: output(ostream &out) const { out << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::none -// Access: Published, Static -// Description: Returns a special zero-valued ButtonHandle that is -// used to indicate no button. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special zero-valued ButtonHandle that is used to indicate no + * button. + */ INLINE ButtonHandle ButtonHandle:: none() { return _none; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::operator bool -// Access: Published -// Description: ButtonHandle::none() evaluates to false, everything -// else evaluates to true. -//////////////////////////////////////////////////////////////////// +/** + * ButtonHandle::none() evaluates to false, everything else evaluates to true. + */ INLINE ButtonHandle:: operator bool () const { return (_index != 0); diff --git a/panda/src/putil/buttonHandle.cxx b/panda/src/putil/buttonHandle.cxx index 49d17eeea3..5495b7ce18 100644 --- a/panda/src/putil/buttonHandle.cxx +++ b/panda/src/putil/buttonHandle.cxx @@ -1,16 +1,15 @@ -// Filename: buttonHandle.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonHandle.cxx + * @author drose + * @date 2000-03-01 + */ #include "buttonHandle.h" #include "buttonRegistry.h" @@ -20,27 +19,21 @@ ButtonHandle ButtonHandle::_none; TypeHandle ButtonHandle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::Constructor -// Access: Published -// Description: Constructs a ButtonHandle with the corresponding -// name, which is looked up in the ButtonRegistry. -// This exists for the purpose of being able to -// automatically coerce a string into a ButtonHandle; -// for most purposes, you should use either the static -// KeyboardButton/MouseButton getters or -// ButtonRegistry::register_button(). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a ButtonHandle with the corresponding name, which is looked up + * in the ButtonRegistry. This exists for the purpose of being able to + * automatically coerce a string into a ButtonHandle; for most purposes, you + * should use either the static KeyboardButton/MouseButton getters or + * ButtonRegistry::register_button(). + */ ButtonHandle:: ButtonHandle(const string &name) { _index = ButtonRegistry::ptr()->get_button(name)._index; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::get_name -// Access: Public -// Description: Returns the name of the button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the button. + */ string ButtonHandle:: get_name() const { if ((*this) == ButtonHandle::none()) { @@ -50,19 +43,14 @@ get_name() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonHandle::get_alias -// Access: Published -// Description: Returns the alias (alternate name) associated with -// the button, if any, or ButtonHandle::none() if the -// button has no alias. -// -// Each button is allowed to have one alias, and -// multiple different buttons can refer to the same -// alias. The alias should be the more general name for -// the button, for instance, shift is an alias for -// lshift, but not vice-versa. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alias (alternate name) associated with the button, if any, or + * ButtonHandle::none() if the button has no alias. + * + * Each button is allowed to have one alias, and multiple different buttons + * can refer to the same alias. The alias should be the more general name for + * the button, for instance, shift is an alias for lshift, but not vice-versa. + */ ButtonHandle ButtonHandle:: get_alias() const { if ((*this) == ButtonHandle::none()) { diff --git a/panda/src/putil/buttonHandle.h b/panda/src/putil/buttonHandle.h index 40dc06865c..d4961f8b50 100644 --- a/panda/src/putil/buttonHandle.h +++ b/panda/src/putil/buttonHandle.h @@ -1,16 +1,15 @@ -// Filename: buttonHandle.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonHandle.h + * @author drose + * @date 2000-03-01 + */ #ifndef BUTTONHANDLE_H #define BUTTONHANDLE_H @@ -19,12 +18,11 @@ #include "typeHandle.h" #include "register_type.h" -//////////////////////////////////////////////////////////////////// -// Class : ButtonHandle -// Description : A ButtonHandle represents a single button from any -// device, including keyboard buttons and mouse buttons -// (but see KeyboardButton and MouseButton). -//////////////////////////////////////////////////////////////////// +/** + * A ButtonHandle represents a single button from any device, including + * keyboard buttons and mouse buttons (but see KeyboardButton and + * MouseButton). + */ class EXPCL_PANDA_PUTIL ButtonHandle FINAL { PUBLISHED: INLINE ButtonHandle(); @@ -80,8 +78,8 @@ private: friend class ButtonRegistry; }; -// It's handy to be able to output a ButtonHandle directly, and see the -// button name. +// It's handy to be able to output a ButtonHandle directly, and see the button +// name. INLINE ostream &operator << (ostream &out, ButtonHandle button) { button.output(out); return out; @@ -90,4 +88,3 @@ INLINE ostream &operator << (ostream &out, ButtonHandle button) { #include "buttonHandle.I" #endif - diff --git a/panda/src/putil/buttonMap.I b/panda/src/putil/buttonMap.I index 39b3a20dfb..bd7e6e4012 100644 --- a/panda/src/putil/buttonMap.I +++ b/panda/src/putil/buttonMap.I @@ -1,70 +1,55 @@ -// Filename: buttonMap.I -// Created by: rdb (09Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonMap.I + * @author rdb + * @date 2014-03-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_num_buttons -// Access: Published -// Description: Returns the number of buttons that this button -// mapping specifies. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of buttons that this button mapping specifies. + */ INLINE size_t ButtonMap:: get_num_buttons() const { return _buttons.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_raw_button -// Access: Published -// Description: Returns the underlying raw button associated with -// the nth button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the underlying raw button associated with the nth button. + */ INLINE ButtonHandle ButtonMap:: get_raw_button(size_t i) const { return _buttons[i]->_raw; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_mapped_button -// Access: Published -// Description: Returns the nth mapped button, meaning the button -// that the nth raw button is mapped to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth mapped button, meaning the button that the nth raw button + * is mapped to. + */ INLINE ButtonHandle ButtonMap:: get_mapped_button(size_t i) const { return _buttons[i]->_mapped; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_mapped_button_label -// Access: Published -// Description: Returns the label associated with the nth mapped -// button, meaning the button that the nth raw -// button is mapped to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the label associated with the nth mapped button, meaning the button + * that the nth raw button is mapped to. + */ INLINE const string &ButtonMap:: get_mapped_button_label(size_t i) const { return _buttons[i]->_label; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_mapped_button -// Access: Published -// Description: Returns the button that the given button is mapped -// to, or ButtonHandle::none() if this map does not -// specify a mapped button for the given raw button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the button that the given button is mapped to, or + * ButtonHandle::none() if this map does not specify a mapped button for the + * given raw button. + */ INLINE ButtonHandle ButtonMap:: get_mapped_button(ButtonHandle raw) const { pmap::const_iterator it; @@ -76,13 +61,11 @@ get_mapped_button(ButtonHandle raw) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::get_mapped_button -// Access: Published -// Description: Returns the button that the given button is mapped -// to, or ButtonHandle::none() if this map does not -// specify a mapped button for the given raw button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the button that the given button is mapped to, or + * ButtonHandle::none() if this map does not specify a mapped button for the + * given raw button. + */ INLINE ButtonHandle ButtonMap:: get_mapped_button(const string &raw_name) const { ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name); @@ -93,18 +76,14 @@ get_mapped_button(const string &raw_name) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtoMap::get_mapped_button_label -// Access: Published -// Description: If the button map specifies a special name for the -// button (eg. if the operating system or keyboard -// device has a localized name describing the key), -// returns it, or the empty string otherwise. -// -// Note that this is not the same as -// get_mapped_button().get_name(), which returns the -// name of the Panda event associated with the button. -//////////////////////////////////////////////////////////////////// +/** + * If the button map specifies a special name for the button (eg. if the + * operating system or keyboard device has a localized name describing the + * key), returns it, or the empty string otherwise. + * + * Note that this is not the same as get_mapped_button().get_name(), which + * returns the name of the Panda event associated with the button. + */ INLINE const string &ButtonMap:: get_mapped_button_label(ButtonHandle raw) const { pmap::const_iterator it; @@ -117,18 +96,14 @@ get_mapped_button_label(ButtonHandle raw) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtoMap::get_mapped_button_label -// Access: Published -// Description: If the button map specifies a special name for the -// button (eg. if the operating system or keyboard -// device has a localized name describing the key), -// returns it, or the empty string otherwise. -// -// Note that this is not the same as -// get_mapped_button().get_name(), which returns the -// name of the Panda event associated with the button. -//////////////////////////////////////////////////////////////////// +/** + * If the button map specifies a special name for the button (eg. if the + * operating system or keyboard device has a localized name describing the + * key), returns it, or the empty string otherwise. + * + * Note that this is not the same as get_mapped_button().get_name(), which + * returns the name of the Panda event associated with the button. + */ INLINE const string &ButtonMap:: get_mapped_button_label(const string &raw_name) const { ButtonHandle raw_button = ButtonRegistry::ptr()->find_button(raw_name); diff --git a/panda/src/putil/buttonMap.cxx b/panda/src/putil/buttonMap.cxx index db88e6df24..7fcc0fa516 100644 --- a/panda/src/putil/buttonMap.cxx +++ b/panda/src/putil/buttonMap.cxx @@ -1,27 +1,24 @@ -// Filename: buttonMap.cxx -// Created by: rdb (09Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonMap.cxx + * @author rdb + * @date 2014-03-09 + */ #include "buttonMap.h" #include "indent.h" TypeHandle ButtonMap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::map_button -// Access: Public -// Description: Registers a new button mapping. -//////////////////////////////////////////////////////////////////// +/** + * Registers a new button mapping. + */ void ButtonMap:: map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { int index = raw_button.get_index(); @@ -38,21 +35,17 @@ map_button(ButtonHandle raw_button, ButtonHandle button, const string &label) { _buttons.push_back(&_button_map[index]); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonMap:: output(ostream &out) const { out << "ButtonMap (" << get_num_buttons() << " buttons)"; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonMap::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonMap:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/panda/src/putil/buttonMap.h b/panda/src/putil/buttonMap.h index 8a2162a34e..1c375ad128 100644 --- a/panda/src/putil/buttonMap.h +++ b/panda/src/putil/buttonMap.h @@ -1,16 +1,15 @@ -// Filename: buttonMap.h -// Created by: rdb (07Mar14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonMap.h + * @author rdb + * @date 2014-03-07 + */ #ifndef BUTTONMAP_H #define BUTTONMAP_H @@ -21,15 +20,13 @@ #include "buttonRegistry.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ButtonMap -// Description : This class represents a map containing all of the -// buttons of a (keyboard) device, though it can also -// be used as a generic mapping between ButtonHandles. -// It maps an underlying 'raw' button to a 'virtual' -// button, which may optionally be associated with an -// appropriate platform-specific name for the button. -//////////////////////////////////////////////////////////////////// +/** + * This class represents a map containing all of the buttons of a (keyboard) + * device, though it can also be used as a generic mapping between + * ButtonHandles. It maps an underlying 'raw' button to a 'virtual' button, + * which may optionally be associated with an appropriate platform-specific + * name for the button. + */ class EXPCL_PANDA_PUTIL ButtonMap : public TypedReferenceCount { PUBLISHED: INLINE size_t get_num_buttons() const; diff --git a/panda/src/putil/buttonRegistry.I b/panda/src/putil/buttonRegistry.I index 8865199623..b531b444f5 100644 --- a/panda/src/putil/buttonRegistry.I +++ b/panda/src/putil/buttonRegistry.I @@ -1,36 +1,30 @@ -// Filename: buttonRegistry.I -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonRegistry.I + * @author drose + * @date 2000-03-01 + */ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::RegistryNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ButtonRegistry::RegistryNode:: RegistryNode(ButtonHandle handle, ButtonHandle alias, const string &name) : - _handle(handle), _alias(alias), _name(name) + _handle(handle), _alias(alias), _name(name) { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::ptr -// Access: Published, Static -// Description: Returns the pointer to the global ButtonRegistry -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the global ButtonRegistry object. + */ INLINE ButtonRegistry *ButtonRegistry:: ptr() { if (_global_pointer == (ButtonRegistry *)NULL) { @@ -39,11 +33,9 @@ ptr() { return _global_pointer; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::get_name -// Access: Public -// Description: Returns the name of the indicated button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated button. + */ INLINE string ButtonRegistry:: get_name(ButtonHandle button) const { RegistryNode *rnode = look_up(button); @@ -51,13 +43,10 @@ get_name(ButtonHandle button) const { return rnode->_name; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::get_alias -// Access: Public -// Description: Returns the alias for the indicated button, or -// ButtonHandle::none() if the button has no specified -// alias. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alias for the indicated button, or ButtonHandle::none() if the + * button has no specified alias. + */ INLINE ButtonHandle ButtonRegistry:: get_alias(ButtonHandle button) const { RegistryNode *rnode = look_up(button); diff --git a/panda/src/putil/buttonRegistry.cxx b/panda/src/putil/buttonRegistry.cxx index ef94897dbd..ff181c95ae 100644 --- a/panda/src/putil/buttonRegistry.cxx +++ b/panda/src/putil/buttonRegistry.cxx @@ -1,51 +1,45 @@ -// Filename: buttonRegistry.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonRegistry.cxx + * @author drose + * @date 2000-03-01 + */ #include "buttonRegistry.h" #include "config_util.h" #include -// In general, we use the util_cat->info() syntax in this file -// (instead of util_cat.info()), because much of this work is done at -// static init time, and we must use the arrow syntax to force -// initialization of the util_cat category. +// In general, we use the util_cat->info() syntax in this file (instead of +// util_cat.info()), because much of this work is done at static init time, +// and we must use the arrow syntax to force initialization of the util_cat +// category. ButtonRegistry *ButtonRegistry::_global_pointer = NULL; -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::register_button -// Access: Public -// Description: Registers a new ButtonHandle with the indicated name, -// and if specified, the indicated ASCII equivalent. -// Returns true if the button was registered, or false -// it was already registered; in either case, the new -// ButtonHandle is loaded into the first parameter. -// -// If the alias is not ButtonHandle::none(), it -// indicates an alias (alternate name) for the same -// button. Each button is allowed to have one alias, -// and multiple different buttons can refer to the same -// alias. The alias should be the more general name for -// the button, for instance, shift is an alias for -// lshift, but not vice-versa. -// -// This defines a new kind of button matching the -// indicated name. The ButtonHandle can then be passed -// around to devices as a button in its own right. -//////////////////////////////////////////////////////////////////// +/** + * Registers a new ButtonHandle with the indicated name, and if specified, the + * indicated ASCII equivalent. Returns true if the button was registered, or + * false it was already registered; in either case, the new ButtonHandle is + * loaded into the first parameter. + * + * If the alias is not ButtonHandle::none(), it indicates an alias (alternate + * name) for the same button. Each button is allowed to have one alias, and + * multiple different buttons can refer to the same alias. The alias should + * be the more general name for the button, for instance, shift is an alias + * for lshift, but not vice-versa. + * + * This defines a new kind of button matching the indicated name. The + * ButtonHandle can then be passed around to devices as a button in its own + * right. + */ bool ButtonRegistry:: register_button(ButtonHandle &button_handle, const string &name, ButtonHandle alias, char ascii_equivalent) { @@ -53,8 +47,8 @@ register_button(ButtonHandle &button_handle, const string &name, ri = _name_registry.find(name); if (ri == _name_registry.end()) { - // The name was not already used; this is the first time this - // button has been defined. + // The name was not already used; this is the first time this button has + // been defined. int index = -1; if (ascii_equivalent != '\0') { @@ -110,13 +104,10 @@ register_button(ButtonHandle &button_handle, const string &name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::get_button -// Access: Published -// Description: Finds a ButtonHandle in the registry matching the -// indicated name. If there is no such ButtonHandle, -// registers a new one and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Finds a ButtonHandle in the registry matching the indicated name. If there + * is no such ButtonHandle, registers a new one and returns it. + */ ButtonHandle ButtonRegistry:: get_button(const string &name) { NameRegistry::const_iterator ri; @@ -131,13 +122,10 @@ get_button(const string &name) { return button; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::find_button -// Access: Published -// Description: Finds a ButtonHandle in the registry matching the -// indicated name. If there is no such ButtonHandle, -// returns ButtonHandle::none(). -//////////////////////////////////////////////////////////////////// +/** + * Finds a ButtonHandle in the registry matching the indicated name. If there + * is no such ButtonHandle, returns ButtonHandle::none(). + */ ButtonHandle ButtonRegistry:: find_button(const string &name) { NameRegistry::const_iterator ri; @@ -150,13 +138,11 @@ find_button(const string &name) { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::find_ascii_button -// Access: Published -// Description: Finds a ButtonHandle in the registry matching the -// indicated ASCII equivalent character. If there is no -// such ButtonHandle, returns ButtonHandle::none(). -//////////////////////////////////////////////////////////////////// +/** + * Finds a ButtonHandle in the registry matching the indicated ASCII + * equivalent character. If there is no such ButtonHandle, returns + * ButtonHandle::none(). + */ ButtonHandle ButtonRegistry:: find_ascii_button(char ascii_equivalent) const { if (_handle_registry[ascii_equivalent] == (RegistryNode *)NULL) { @@ -165,11 +151,9 @@ find_ascii_button(char ascii_equivalent) const { return _handle_registry[ascii_equivalent]->_handle; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ButtonRegistry:: write(ostream &out) const { out << "ASCII equivalents:\n"; @@ -197,16 +181,13 @@ write(ostream &out) const { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonRegistry:: ButtonRegistry() { - // We'll start by filling up the handle_registry with 128 entries - // for ButtonHandle::none(), as well as for all the ASCII - // equivalents. + // We'll start by filling up the handle_registry with 128 entries for + // ButtonHandle::none(), as well as for all the ASCII equivalents. _handle_registry.reserve(128); int i; @@ -215,23 +196,18 @@ ButtonRegistry() { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::init_global_pointer -// Access: Private, Static -// Description: Constructs the ButtonRegistry object for the first -// time. -//////////////////////////////////////////////////////////////////// +/** + * Constructs the ButtonRegistry object for the first time. + */ void ButtonRegistry:: init_global_pointer() { _global_pointer = new ButtonRegistry; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonRegistry::look_up -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonRegistry::RegistryNode *ButtonRegistry:: look_up(ButtonHandle handle) const { nassertr(handle._index != 0, NULL); diff --git a/panda/src/putil/buttonRegistry.h b/panda/src/putil/buttonRegistry.h index 16f842a35f..c57efbf089 100644 --- a/panda/src/putil/buttonRegistry.h +++ b/panda/src/putil/buttonRegistry.h @@ -1,16 +1,15 @@ -// Filename: buttonRegistry.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonRegistry.h + * @author drose + * @date 2000-03-01 + */ #ifndef BUTTONREGISTRY_H #define BUTTONREGISTRY_H @@ -22,13 +21,11 @@ #include "pvector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ButtonRegistry -// Description : The ButtonRegistry class maintains all the assigned -// ButtonHandles in a given system. There should be only -// one ButtonRegistry class during the lifetime of the -// application. -//////////////////////////////////////////////////////////////////// +/** + * The ButtonRegistry class maintains all the assigned ButtonHandles in a + * given system. There should be only one ButtonRegistry class during the + * lifetime of the application. + */ class EXPCL_PANDA_PUTIL ButtonRegistry { protected: class EXPCL_PANDA_PUTIL RegistryNode { @@ -61,8 +58,8 @@ public: INLINE ButtonHandle get_alias(ButtonHandle button) const; private: - // The ButtonRegistry class should never be constructed by user code. - // There is only one in the universe, and it constructs itself! + // The ButtonRegistry class should never be constructed by user code. There + // is only one in the universe, and it constructs itself! ButtonRegistry(); static void init_global_pointer(); diff --git a/panda/src/putil/cPointerCallbackObject.I b/panda/src/putil/cPointerCallbackObject.I index b7a1f4cf74..1b4c61e844 100644 --- a/panda/src/putil/cPointerCallbackObject.I +++ b/panda/src/putil/cPointerCallbackObject.I @@ -1,23 +1,19 @@ -// Filename: cPointerCallbackObject.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cPointerCallbackObject.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CPointerCallbackObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CPointerCallbackObject:: CPointerCallbackObject(CPointerCallbackObject::CallbackFunction *func, void *data) : _func(func), diff --git a/panda/src/putil/cPointerCallbackObject.cxx b/panda/src/putil/cPointerCallbackObject.cxx index 97b067a193..7c921f4e8f 100644 --- a/panda/src/putil/cPointerCallbackObject.cxx +++ b/panda/src/putil/cPointerCallbackObject.cxx @@ -1,31 +1,26 @@ -// Filename: cPointerCallbackObject.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cPointerCallbackObject.cxx + * @author drose + * @date 2009-03-13 + */ #include "cPointerCallbackObject.h" TypeHandle CPointerCallbackObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CPointerCallbackObject::do_callback -// Access: Public, Virtual -// Description: This method called when the callback is triggered; it -// *replaces* the original function. To continue -// performing the original function, you must call -// cbdata->upcall() during the callback. -//////////////////////////////////////////////////////////////////// +/** + * This method called when the callback is triggered; it *replaces* the + * original function. To continue performing the original function, you must + * call cbdata->upcall() during the callback. + */ void CPointerCallbackObject:: do_callback(CallbackData *cbdata) { (*_func)(cbdata, _data); } - diff --git a/panda/src/putil/cPointerCallbackObject.h b/panda/src/putil/cPointerCallbackObject.h index 0de044955f..cfd25f8924 100644 --- a/panda/src/putil/cPointerCallbackObject.h +++ b/panda/src/putil/cPointerCallbackObject.h @@ -1,16 +1,15 @@ -// Filename: cPointerCallbackObject.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cPointerCallbackObject.h + * @author drose + * @date 2009-03-13 + */ #ifndef CPOINTERCALLBACKOBJECT_H #define CPOINTERCALLBACKOBJECT_H @@ -18,12 +17,10 @@ #include "pandabase.h" #include "callbackObject.h" -//////////////////////////////////////////////////////////////////// -// Class : CPointerCallbackObject -// Description : This is a specialization on CallbackObject to allow -// association with a C-style function pointer and a -// void * parameter. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on CallbackObject to allow association with a + * C-style function pointer and a void * parameter. + */ class EXPCL_PANDA_PUTIL CPointerCallbackObject : public CallbackObject { public: typedef void CallbackFunction(CallbackData *cbdata, void *data); diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.I b/panda/src/putil/cachedTypedWritableReferenceCount.I index 74db9efc9f..050c95eb3f 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.I +++ b/panda/src/putil/cachedTypedWritableReferenceCount.I @@ -1,134 +1,112 @@ -// Filename: cachedTypedWritableReferenceCount.I -// Created by: drose (25Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cachedTypedWritableReferenceCount.I + * @author drose + * @date 2005-01-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::Constructor -// Access: Protected -// Description: The ReferenceCount constructor is protected because -// you almost never want to create just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. -// -// ReferenceCount doesn't store any useful information -// in its own right; its only purpose is to add -// reference-counting to some other class via -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount constructor is protected because you almost never want + * to create just a ReferenceCount object by itself, and it's probably a + * mistake if you try. + * + * ReferenceCount doesn't store any useful information in its own right; its + * only purpose is to add reference-counting to some other class via + * inheritance. + */ INLINE CachedTypedWritableReferenceCount:: CachedTypedWritableReferenceCount() { _cache_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::Copy Constructor -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy constructor is protected because you almost -// never want to create just a ReferenceCount object by -// itself, and it's probably a mistake if you try. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy constructor is protected because you almost never want to create + * just a ReferenceCount object by itself, and it's probably a mistake if you + * try. + */ INLINE CachedTypedWritableReferenceCount:: CachedTypedWritableReferenceCount(const CachedTypedWritableReferenceCount ©) : TypedWritableReferenceCount(copy) { _cache_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::Copy Assignment Operator -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy assignment operator is protected because -// you almost never want to copy just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. Instead, this should only be called from a -// derived class that implements this operator and then -// calls up the inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy assignment operator is protected because you almost never want to + * copy just a ReferenceCount object by itself, and it's probably a mistake if + * you try. Instead, this should only be called from a derived class that + * implements this operator and then calls up the inheritance chain. + */ INLINE void CachedTypedWritableReferenceCount:: operator = (const CachedTypedWritableReferenceCount ©) { nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. - // Possibly you used a real pointer instead of a PointerTo at some - // point, and the object was deleted when the PointerTo went out of - // scope. Maybe you tried to create an automatic (local variable) - // instance of a class that derives from ReferenceCount. Or maybe - // your headers are out of sync, and you need to make clean in - // direct or some higher tree. + // If this assertion fails, our own pointer was recently deleted. Possibly + // you used a real pointer instead of a PointerTo at some point, and the + // object was deleted when the PointerTo went out of scope. Maybe you tried + // to create an automatic (local variable) instance of a class that derives + // from ReferenceCount. Or maybe your headers are out of sync, and you need + // to make clean in direct or some higher tree. nassertv(_cache_ref_count != -100); TypedWritableReferenceCount::operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::Destructor -// Access: Protected -// Description: The ReferenceCount destructor is protected to -// discourage users from accidentally trying to delete a -// ReferenceCount pointer directly. This is almost -// always a bad idea, since the destructor is not -// virtual, and you've almost certainly got some pointer -// to something that inherits from ReferenceCount, not -// just a plain old ReferenceCount object. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount destructor is protected to discourage users from + * accidentally trying to delete a ReferenceCount pointer directly. This is + * almost always a bad idea, since the destructor is not virtual, and you've + * almost certainly got some pointer to something that inherits from + * ReferenceCount, not just a plain old ReferenceCount object. + */ INLINE CachedTypedWritableReferenceCount:: ~CachedTypedWritableReferenceCount() { nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertv(_cache_ref_count != -100); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertv(_cache_ref_count >= 0); - // If this assertion fails, someone tried to delete this object - // while its reference count was still positive. Maybe you tried - // to point a PointerTo at a static object (a local variable, - // instead of one allocated via new)? The test below against 0x7f - // is supposed to check for that, but it's a pretty hokey test. + // If this assertion fails, someone tried to delete this object while its + // reference count was still positive. Maybe you tried to point a PointerTo + // at a static object (a local variable, instead of one allocated via new)? + // The test below against 0x7f is supposed to check for that, but it's a + // pretty hokey test. - // Another possibility is you inadvertently omitted a copy - // constructor for a ReferenceCount object, and then bitwise - // copied a dynamically allocated value--reference count and - // all--onto a locally allocated one. + // Another possibility is you inadvertently omitted a copy constructor for a + // ReferenceCount object, and then bitwise copied a dynamically allocated + // value--reference count and all--onto a locally allocated one. nassertv(_cache_ref_count == 0); #ifndef NDEBUG - // Ok, all clear to delete. Now set the reference count to -100, - // so we'll have a better chance of noticing if we happen to have - // a stray pointer to it still out there. + // Ok, all clear to delete. Now set the reference count to -100, so we'll + // have a better chance of noticing if we happen to have a stray pointer to + // it still out there. _cache_ref_count = -100; #endif } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::get_cache_ref_count -// Access: Published -// Description: Returns the current reference count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current reference count. + */ INLINE int CachedTypedWritableReferenceCount:: get_cache_ref_count() const { #ifdef _DEBUG @@ -137,12 +115,10 @@ get_cache_ref_count() const { return (int)AtomicAdjust::get(_cache_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::cache_ref -// Access: Published -// Description: Explicitly increments the cache reference count and -// the normal reference count simultaneously. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly increments the cache reference count and the normal reference + * count simultaneously. + */ INLINE void CachedTypedWritableReferenceCount:: cache_ref() const { #ifdef _DEBUG @@ -153,36 +129,32 @@ cache_ref() const { AtomicAdjust::inc(((CachedTypedWritableReferenceCount *)this)->_cache_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::cache_unref -// Access: Published -// Description: Explicitly decrements the cache reference count and -// the normal reference count simultaneously. -// -// The return value is true if the new reference count -// is nonzero, false if it is zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the cache reference count and the normal reference + * count simultaneously. + * + * The return value is true if the new reference count is nonzero, false if it + * is zero. + */ INLINE bool CachedTypedWritableReferenceCount:: cache_unref() const { #ifdef _DEBUG nassertr(test_ref_count_integrity(), 0); #endif - // If this assertion fails, you tried to unref an object with a - // zero reference count. Are you using ref() and unref() - // directly? Are you sure you can't use PointerTo's? + // If this assertion fails, you tried to unref an object with a zero + // reference count. Are you using ref() and unref() directly? Are you sure + // you can't use PointerTo's? nassertr(_cache_ref_count > 0, 0); - + AtomicAdjust::dec(((CachedTypedWritableReferenceCount *)this)->_cache_ref_count); return ReferenceCount::unref(); } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::test_ref_count_integrity -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ INLINE bool CachedTypedWritableReferenceCount:: test_ref_count_integrity() const { #ifndef NDEBUG @@ -192,38 +164,32 @@ test_ref_count_integrity() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::cache_unref_only -// Access: Protected -// Description: Decrements the cache reference count without affecting -// the normal reference count. Intended to be called by -// derived classes only, presumably to reimplement -// cache_unref(). -//////////////////////////////////////////////////////////////////// +/** + * Decrements the cache reference count without affecting the normal reference + * count. Intended to be called by derived classes only, presumably to + * reimplement cache_unref(). + */ INLINE void CachedTypedWritableReferenceCount:: cache_unref_only() const { #ifdef _DEBUG nassertv(test_ref_count_integrity()); #endif - // If this assertion fails, you tried to unref an object with a - // zero reference count. Are you using ref() and unref() - // directly? Are you sure you can't use PointerTo's? + // If this assertion fails, you tried to unref an object with a zero + // reference count. Are you using ref() and unref() directly? Are you sure + // you can't use PointerTo's? nassertv(_cache_ref_count > 0); - + AtomicAdjust::dec(((CachedTypedWritableReferenceCount *)this)->_cache_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: cache_unref_delete -// Description: This global helper function will unref the given -// ReferenceCount object, and if the reference count -// reaches zero, automatically delete it. It can't be a -// member function because it's usually a bad idea to -// delete an object from within its own member function. -// It's a template function so the destructor doesn't -// have to be virtual. -//////////////////////////////////////////////////////////////////// +/** + * This global helper function will unref the given ReferenceCount object, and + * if the reference count reaches zero, automatically delete it. It can't be + * a member function because it's usually a bad idea to delete an object from + * within its own member function. It's a template function so the destructor + * doesn't have to be virtual. + */ template INLINE void cache_unref_delete(RefCountType *ptr) { @@ -231,4 +197,3 @@ cache_unref_delete(RefCountType *ptr) { delete ptr; } } - diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.cxx b/panda/src/putil/cachedTypedWritableReferenceCount.cxx index b847bc3c77..53e4fa355a 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.cxx +++ b/panda/src/putil/cachedTypedWritableReferenceCount.cxx @@ -1,43 +1,38 @@ -// Filename: cachedTypedWritableReferenceCount.cxx -// Created by: drose (25Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cachedTypedWritableReferenceCount.cxx + * @author drose + * @date 2005-01-25 + */ #include "cachedTypedWritableReferenceCount.h" TypeHandle CachedTypedWritableReferenceCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CachedTypedWritableReferenceCount::do_test_ref_count_integrity -// Access: Protected -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ bool CachedTypedWritableReferenceCount:: do_test_ref_count_integrity() const { nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertr(_cache_ref_count != -100, false); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertr(_cache_ref_count >= 0, false); return TypedWritableReferenceCount::do_test_ref_count_integrity(); diff --git a/panda/src/putil/cachedTypedWritableReferenceCount.h b/panda/src/putil/cachedTypedWritableReferenceCount.h index f57c58a157..15772048dd 100644 --- a/panda/src/putil/cachedTypedWritableReferenceCount.h +++ b/panda/src/putil/cachedTypedWritableReferenceCount.h @@ -1,16 +1,15 @@ -// Filename: cachedTypedWritableReferenceCount.h -// Created by: drose (25Jan05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cachedTypedWritableReferenceCount.h + * @author drose + * @date 2005-01-25 + */ #ifndef CACHEDTYPEDWRITABLEREFERENCECOUNT_H #define CACHEDTYPEDWRITABLEREFERENCECOUNT_H @@ -19,24 +18,19 @@ #include "typedWritableReferenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : CachedTypedWritableReferenceCount -// Description : This is a special extension to ReferenceCount that -// includes dual reference counts: the standard -// reference count number, which includes all references -// to the object, and a separate number (the cache -// reference count) that counts the number of references -// to the object just within its cache alone. When -// get_ref_count() == get_cache_ref_count(), the object -// is not referenced outside the cache. -// -// The cache refs must be explicitly maintained; there -// is no PointerTo<> class to maintain the cache -// reference counts automatically. The cache reference -// count is automatically included in the overall -// reference count: calling cache_ref() and -// cache_unref() automatically calls ref() and unref(). -//////////////////////////////////////////////////////////////////// +/** + * This is a special extension to ReferenceCount that includes dual reference + * counts: the standard reference count number, which includes all references + * to the object, and a separate number (the cache reference count) that + * counts the number of references to the object just within its cache alone. + * When get_ref_count() == get_cache_ref_count(), the object is not referenced + * outside the cache. + * + * The cache refs must be explicitly maintained; there is no PointerTo<> class + * to maintain the cache reference counts automatically. The cache reference + * count is automatically included in the overall reference count: calling + * cache_ref() and cache_unref() automatically calls ref() and unref(). + */ class EXPCL_PANDA_PUTIL CachedTypedWritableReferenceCount : public TypedWritableReferenceCount { protected: INLINE CachedTypedWritableReferenceCount(); diff --git a/panda/src/putil/callbackData.I b/panda/src/putil/callbackData.I index 48de3611a4..749e774228 100644 --- a/panda/src/putil/callbackData.I +++ b/panda/src/putil/callbackData.I @@ -1,23 +1,19 @@ -// Filename: callbackData.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackData.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CallbackData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackData:: CallbackData() { } diff --git a/panda/src/putil/callbackData.cxx b/panda/src/putil/callbackData.cxx index 7b149c8ee9..de7eac9678 100644 --- a/panda/src/putil/callbackData.cxx +++ b/panda/src/putil/callbackData.cxx @@ -1,40 +1,33 @@ -// Filename: callbackData.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackData.cxx + * @author drose + * @date 2009-03-13 + */ #include "callbackData.h" TypeHandle CallbackData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CallbackData::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CallbackData:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackData::upcall -// Access: Published, Virtual -// Description: You should make this call during the callback if you -// want to continue the normal function that would have -// been done in the absence of a callback. -//////////////////////////////////////////////////////////////////// +/** + * You should make this call during the callback if you want to continue the + * normal function that would have been done in the absence of a callback. + */ void CallbackData:: upcall() { } - diff --git a/panda/src/putil/callbackData.h b/panda/src/putil/callbackData.h index 30ed92ea6b..8380788e13 100644 --- a/panda/src/putil/callbackData.h +++ b/panda/src/putil/callbackData.h @@ -1,16 +1,15 @@ -// Filename: callbackData.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackData.h + * @author drose + * @date 2009-03-13 + */ #ifndef CALLBACKDATA_H #define CALLBACKDATA_H @@ -18,17 +17,15 @@ #include "pandabase.h" #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : CallbackData -// Description : This is a generic data block that is passed along to -// a CallbackObject when a callback is made. It -// contains data specific to the particular callback -// type in question. -// -// This is actually an abstract base class and contains -// no data. Specializations of this class will contain -// the actual data relevant to each callback type. -//////////////////////////////////////////////////////////////////// +/** + * This is a generic data block that is passed along to a CallbackObject when + * a callback is made. It contains data specific to the particular callback + * type in question. + * + * This is actually an abstract base class and contains no data. + * Specializations of this class will contain the actual data relevant to each + * callback type. + */ class EXPCL_PANDA_PUTIL CallbackData : public TypedObject { protected: INLINE CallbackData(); diff --git a/panda/src/putil/callbackObject.I b/panda/src/putil/callbackObject.I index d3ff3b5c1a..0d4cb70574 100644 --- a/panda/src/putil/callbackObject.I +++ b/panda/src/putil/callbackObject.I @@ -1,23 +1,19 @@ -// Filename: callbackObject.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackObject.I + * @author drose + * @date 2009-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CallbackObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CallbackObject:: CallbackObject() { } diff --git a/panda/src/putil/callbackObject.cxx b/panda/src/putil/callbackObject.cxx index c78354705a..9f1ce360ac 100644 --- a/panda/src/putil/callbackObject.cxx +++ b/panda/src/putil/callbackObject.cxx @@ -1,40 +1,34 @@ -// Filename: callbackObject.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackObject.cxx + * @author drose + * @date 2009-03-13 + */ #include "callbackObject.h" TypeHandle CallbackObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CallbackObject::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void CallbackObject:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: CallbackObject::do_callback -// Access: Public, Virtual -// Description: This method called when the callback is triggered; it -// *replaces* the original function. To continue -// performing the original function, you must call -// cbdata->upcall() during the callback. -//////////////////////////////////////////////////////////////////// +/** + * This method called when the callback is triggered; it *replaces* the + * original function. To continue performing the original function, you must + * call cbdata->upcall() during the callback. + */ void CallbackObject:: do_callback(CallbackData *) { } diff --git a/panda/src/putil/callbackObject.h b/panda/src/putil/callbackObject.h index bb4f8f1223..320fb9c0ef 100644 --- a/panda/src/putil/callbackObject.h +++ b/panda/src/putil/callbackObject.h @@ -1,16 +1,15 @@ -// Filename: callbackObject.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackObject.h + * @author drose + * @date 2009-03-13 + */ #ifndef CALLBACKOBJECT_H #define CALLBACKOBJECT_H @@ -20,15 +19,12 @@ class CallbackData; -//////////////////////////////////////////////////////////////////// -// Class : CallbackObject -// Description : This is a generic object that can be assigned to a -// callback at various points in the rendering process. -// This is actually a base class for a handful of -// specialized callback object types. You can also -// subclass it yourself to make your own callback -// handler. -//////////////////////////////////////////////////////////////////// +/** + * This is a generic object that can be assigned to a callback at various + * points in the rendering process. This is actually a base class for a + * handful of specialized callback object types. You can also subclass it + * yourself to make your own callback handler. + */ class EXPCL_PANDA_PUTIL CallbackObject : public TypedReferenceCount { protected: INLINE CallbackObject(); diff --git a/panda/src/putil/callbackObject_ext.I b/panda/src/putil/callbackObject_ext.I index 0bf73b2e01..12edcf6b23 100644 --- a/panda/src/putil/callbackObject_ext.I +++ b/panda/src/putil/callbackObject_ext.I @@ -1,26 +1,21 @@ -// Filename: callbackObject_ext.I -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackObject_ext.I + * @author rdb + * @date 2015-02-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: Extension::make -// Access: Published -// Description: This static constructor is merely provided so that -// interrogate can automatically coerce Python -// functions when passing them to a C++ function that -// accepts a CallbackObject. -//////////////////////////////////////////////////////////////////// +/** + * This static constructor is merely provided so that interrogate can + * automatically coerce Python functions when passing them to a C++ function + * that accepts a CallbackObject. + */ INLINE PT(CallbackObject) Extension:: make(PyObject *function) { if (function != Py_None && !PyCallable_Check(function)) { diff --git a/panda/src/putil/callbackObject_ext.h b/panda/src/putil/callbackObject_ext.h index d72713da19..2ddfc03942 100644 --- a/panda/src/putil/callbackObject_ext.h +++ b/panda/src/putil/callbackObject_ext.h @@ -1,16 +1,15 @@ -// Filename: callbackObject_ext.h -// Created by: rdb (25Feb15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file callbackObject_ext.h + * @author rdb + * @date 2015-02-25 + */ #ifndef CALLBACKOBJECT_EXT_H #define CALLBACKOBJECT_EXT_H @@ -24,17 +23,14 @@ #include "pointerTo.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// CallbackObject, which are called instead of -// any C++ methods with the same prototype. -// -// This just defines a static constructor, which makes -// it possible for Interrogate to automatically accept -// a Python function wherever a CallbackObject is -// accepted. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for CallbackObject, which are + * called instead of any C++ methods with the same prototype. + * + * This just defines a static constructor, which makes it possible for + * Interrogate to automatically accept a Python function wherever a + * CallbackObject is accepted. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/putil/clockObject.I b/panda/src/putil/clockObject.I index df3fde9695..d9bcac3a7c 100644 --- a/panda/src/putil/clockObject.I +++ b/panda/src/putil/clockObject.I @@ -1,99 +1,77 @@ -// Filename: clockObject.I -// Created by: drose (17Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clockObject.I + * @author drose + * @date 2000-02-17 + */ -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClockObject:: ~ClockObject() { } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_mode -// Access: Published -// Description: Returns the current mode of the clock. See -// set_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current mode of the clock. See set_mode(). + */ INLINE ClockObject::Mode ClockObject:: get_mode() const { return _mode; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_frame_time -// Access: Published -// Description: Returns the time in seconds as of the last time -// tick() was called (typically, this will be as of the -// start of the current frame). -// -// This is generally the kind of time you want to ask -// for in most rendering and animation contexts, since -// it's important that all of the animation for a given -// frame remains in sync with each other. -//////////////////////////////////////////////////////////////////// +/** + * Returns the time in seconds as of the last time tick() was called + * (typically, this will be as of the start of the current frame). + * + * This is generally the kind of time you want to ask for in most rendering + * and animation contexts, since it's important that all of the animation for + * a given frame remains in sync with each other. + */ INLINE double ClockObject:: get_frame_time(Thread *current_frame) const { CDReader cdata(_cycler, current_frame); return cdata->_reported_frame_time; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_real_time -// Access: Published -// Description: Returns the actual number of seconds elapsed since -// the ClockObject was created, or since it was last -// reset. This is useful for doing real timing -// measurements, e.g. for performance statistics. -// -// This returns the most precise timer we have for short -// time intervals, but it may tend to drift over the -// long haul. If more accurate timekeeping is needed -// over a long period of time, use get_long_time() -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual number of seconds elapsed since the ClockObject was + * created, or since it was last reset. This is useful for doing real timing + * measurements, e.g. for performance statistics. + * + * This returns the most precise timer we have for short time intervals, but + * it may tend to drift over the long haul. If more accurate timekeeping is + * needed over a long period of time, use get_long_time() instead. + */ INLINE double ClockObject:: get_real_time() const { return (_true_clock->get_short_time() - _start_short_time); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_long_time -// Access: Published -// Description: Returns the actual number of seconds elapsed since -// the ClockObject was created, or since it was last -// reset. -// -// This is similar to get_real_time(), except that it -// uses the most accurate counter we have over a long -// period of time, and so it is less likely to drift. -// However, it may not be very precise for measuring -// short intervals. On Windows, for instace, this is -// only accurate to within about 55 milliseconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual number of seconds elapsed since the ClockObject was + * created, or since it was last reset. + * + * This is similar to get_real_time(), except that it uses the most accurate + * counter we have over a long period of time, and so it is less likely to + * drift. However, it may not be very precise for measuring short intervals. + * On Windows, for instace, this is only accurate to within about 55 + * milliseconds. + */ INLINE double ClockObject:: get_long_time() const { return (_true_clock->get_long_time() - _start_long_time); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::reset -// Access: Published -// Description: Simultaneously resets both the time and the frame -// count to zero. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously resets both the time and the frame count to zero. + */ INLINE void ClockObject:: reset() { set_real_time(0.0); @@ -101,42 +79,33 @@ reset() { set_frame_count(0); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_frame_count -// Access: Published -// Description: Returns the number of times tick() has been called -// since the ClockObject was created, or since it was -// last reset. This is generally the number of frames -// that have been rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times tick() has been called since the ClockObject + * was created, or since it was last reset. This is generally the number of + * frames that have been rendered. + */ INLINE int ClockObject:: get_frame_count(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return cdata->_frame_count; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_net_frame_rate -// Access: Published -// Description: Returns the average frame rate since the last reset. -// This is simply the total number of frames divided by -// the total elapsed time. This reports the virtual -// frame rate if the clock is in (or has been in) -// M_non_real_time mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average frame rate since the last reset. This is simply the + * total number of frames divided by the total elapsed time. This reports the + * virtual frame rate if the clock is in (or has been in) M_non_real_time + * mode. + */ INLINE double ClockObject:: get_net_frame_rate(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); return (double)cdata->_frame_count / cdata->_reported_frame_time; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_dt -// Access: Published -// Description: Returns the elapsed time for the previous frame: the -// number of seconds elapsed between the last two calls -// to tick(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the elapsed time for the previous frame: the number of seconds + * elapsed between the last two calls to tick(). + */ INLINE double ClockObject:: get_dt(Thread *current_thread) const { CDReader cdata(_cycler, current_thread); @@ -146,82 +115,65 @@ get_dt(Thread *current_thread) const { return cdata->_dt; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_max_dt -// Access: Published -// Description: Returns the current maximum allowable time elapsed -// between any two frames. See set_max_dt(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current maximum allowable time elapsed between any two frames. + * See set_max_dt(). + */ INLINE double ClockObject:: get_max_dt() const { return _max_dt; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_max_dt -// Access: Published -// Description: Sets a limit on the value returned by get_dt(). If -// this value is less than zero, no limit is imposed; -// otherwise, this is the maximum value that will ever -// be returned by get_dt(), regardless of how much time -// has actually elapsed between frames. -// -// This limit is only imposed in real-time mode; in -// non-real-time mode, the dt is fixed anyway and max_dt -// is ignored. -// -// This is generally used to guarantee reasonable -// behavior even in the presence of a very slow or -// chuggy frame rame. -//////////////////////////////////////////////////////////////////// +/** + * Sets a limit on the value returned by get_dt(). If this value is less than + * zero, no limit is imposed; otherwise, this is the maximum value that will + * ever be returned by get_dt(), regardless of how much time has actually + * elapsed between frames. + * + * This limit is only imposed in real-time mode; in non-real-time mode, the dt + * is fixed anyway and max_dt is ignored. + * + * This is generally used to guarantee reasonable behavior even in the + * presence of a very slow or chuggy frame rame. + */ INLINE void ClockObject:: set_max_dt(double max_dt) { _max_dt = max_dt; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_degrade_factor -// Access: Published -// Description: In degrade mode, returns the ratio by which the -// performance is degraded. A value of 2.0 causes the -// clock to be slowed down by a factor of two (reducing -// performance to 1/2 what would be otherwise). -// -// This has no effect if mode is not M_degrade. -//////////////////////////////////////////////////////////////////// +/** + * In degrade mode, returns the ratio by which the performance is degraded. A + * value of 2.0 causes the clock to be slowed down by a factor of two + * (reducing performance to 1/2 what would be otherwise). + * + * This has no effect if mode is not M_degrade. + */ INLINE double ClockObject:: get_degrade_factor() const { return _degrade_factor; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_degrade_factor -// Access: Published -// Description: In degrade mode, sets the ratio by which the -// performance is degraded. A value of 2.0 causes the -// clock to be slowed down by a factor of two (reducing -// performance to 1/2 what would be otherwise). -// -// This has no effect if mode is not M_degrade. -//////////////////////////////////////////////////////////////////// +/** + * In degrade mode, sets the ratio by which the performance is degraded. A + * value of 2.0 causes the clock to be slowed down by a factor of two + * (reducing performance to 1/2 what would be otherwise). + * + * This has no effect if mode is not M_degrade. + */ INLINE void ClockObject:: set_degrade_factor(double degrade_factor) { _degrade_factor = degrade_factor; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_average_frame_rate_interval -// Access: Published -// Description: Specifies the interval of time (in seconds) over -// which get_average_frame_rate() averages the number of -// frames per second to compute the frame rate. -// Changing this does not necessarily immediately change -// the result of get_average_frame_rate(), until this -// interval of time has elapsed again. -// -// Setting this to zero disables the computation of -// get_average_frame_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the interval of time (in seconds) over which + * get_average_frame_rate() averages the number of frames per second to + * compute the frame rate. Changing this does not necessarily immediately + * change the result of get_average_frame_rate(), until this interval of time + * has elapsed again. + * + * Setting this to zero disables the computation of get_average_frame_rate(). + */ INLINE void ClockObject:: set_average_frame_rate_interval(double time) { _average_frame_rate_interval = time; @@ -230,28 +182,23 @@ set_average_frame_rate_interval(double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_average_frame_rate_interval -// Access: Published -// Description: Returns the interval of time (in seconds) over -// which get_average_frame_rate() averages the number of frames -// per second to compute the frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the interval of time (in seconds) over which + * get_average_frame_rate() averages the number of frames per second to + * compute the frame rate. + */ INLINE double ClockObject:: get_average_frame_rate_interval() const { return _average_frame_rate_interval; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::check_errors -// Access: Published -// Description: Returns true if a clock error was detected since the -// last time check_errors() was called. A clock error -// means that something happened, an OS or BIOS bug, for -// instance, that makes the current value of the clock -// somewhat suspect, and an application may wish to -// resynchronize with any external clocks. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a clock error was detected since the last time + * check_errors() was called. A clock error means that something happened, an + * OS or BIOS bug, for instance, that makes the current value of the clock + * somewhat suspect, and an application may wish to resynchronize with any + * external clocks. + */ INLINE bool ClockObject:: check_errors(Thread *current_thread) { CDReader cdata(_cycler, current_thread); // Just to hold a mutex. @@ -260,13 +207,10 @@ check_errors(Thread *current_thread) { return (_error_count != orig_error_count); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_global_clock -// Access: Published -// Description: Returns a pointer to the global ClockObject. This is -// the ClockObject that most code should use for -// handling scene graph rendering and animation. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the global ClockObject. This is the ClockObject that + * most code should use for handling scene graph rendering and animation. + */ INLINE ClockObject *ClockObject:: get_global_clock() { if (_global_clock == (ClockObject *)NULL) { @@ -275,43 +219,35 @@ get_global_clock() { return _global_clock; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::CData::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ClockObject::CData:: -CData(const ClockObject::CData ©) : - _frame_count(copy._frame_count), +CData(const ClockObject::CData ©) : + _frame_count(copy._frame_count), _reported_frame_time(copy._reported_frame_time), _dt(copy._dt) { } -//////////////////////////////////////////////////////////////////// -// Function: TimeVal::contructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TimeVal:: TimeVal() { } -//////////////////////////////////////////////////////////////////// -// Function: TimeVal::get_sec -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ulong TimeVal:: get_sec() const { return tv[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TimeVal::get_usec -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ulong TimeVal:: get_usec() const { return tv[1]; diff --git a/panda/src/putil/clockObject.cxx b/panda/src/putil/clockObject.cxx index 4215f4e6c8..d53f4ea329 100644 --- a/panda/src/putil/clockObject.cxx +++ b/panda/src/putil/clockObject.cxx @@ -1,16 +1,15 @@ -// Filename: clockObject.cxx -// Created by: drose (17Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clockObject.cxx + * @author drose + * @date 2000-02-17 + */ #include "clockObject.h" #include "config_util.h" @@ -25,18 +24,16 @@ void (*ClockObject::_stop_clock_wait)() = ClockObject::dummy_clock_wait; ClockObject *ClockObject::_global_clock; TypeHandle ClockObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClockObject:: ClockObject() : _ticks(get_class_type()) { _true_clock = TrueClock::get_global_ptr(); - // Each clock except for the application global clock is created in - // M_normal mode. The application global clock is later reset to - // respect clock_mode, which comes from the Config.prc file. + // Each clock except for the application global clock is created in M_normal + // mode. The application global clock is later reset to respect clock_mode, + // which comes from the Config.prc file. _mode = M_normal; _start_short_time = _true_clock->get_short_time(); @@ -74,11 +71,9 @@ ClockObject() : _ticks(get_class_type()) { _error_count = _true_clock->get_error_count(); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClockObject:: ClockObject(const ClockObject ©) : _true_clock(copy._true_clock), @@ -92,60 +87,49 @@ ClockObject(const ClockObject ©) : _error_count(copy._error_count), _average_frame_rate_interval(copy._average_frame_rate_interval), _ticks(copy._ticks), - _cycler(copy._cycler) + _cycler(copy._cycler) { } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_mode -// Access: Published -// Description: Changes the mode of the clock. Normally, the clock -// is in mode M_normal. In this mode, each call to -// tick() will set the value returned by -// get_frame_time() to the current real time; thus, the -// clock simply reports time advancing. -// -// Other possible modes: -// -// M_non_real_time - the clock ignores real time -// completely; at each call to tick(), it pretends that -// exactly dt seconds have elapsed since the last call -// to tick(). You may set the value of dt with -// set_dt() or set_frame_rate(). -// -// M_limited - the clock will run as fast as it can, as -// in M_normal, but will not run faster than the rate -// specified by set_frame_rate(). If the application -// would run faster than this rate, the clock will slow -// down the application. -// -// M_integer - the clock will run as fast as it can, but -// the rate will be constrained to be an integer -// multiple or divisor of the rate specified by -// set_frame_rate(). The clock will slow down the -// application a bit to guarantee this. -// -// M_integer_limited - a combination of M_limited and -// M_integer; the clock will not run faster than -// set_frame_rate(), and if it runs slower, it will run -// at a integer divisor of that rate. -// -// M_forced - the clock forces the application to run at -// the rate specified by set_frame_rate(). If the -// application would run faster than this rate, the -// clock will slow down the application; if the -// application would run slower than this rate, the -// clock slows down time so that the application -// believes it is running at the given rate. -// -// M_degrade - the clock runs at real time, but the -// application is slowed down by a set factor of its -// frame rate, specified by set_degrade_factor(). -// -// M_slave - the clock does not advance, but relies on -// the user to call set_frame_time() and/or -// set_frame_count() each frame. -//////////////////////////////////////////////////////////////////// +/** + * Changes the mode of the clock. Normally, the clock is in mode M_normal. + * In this mode, each call to tick() will set the value returned by + * get_frame_time() to the current real time; thus, the clock simply reports + * time advancing. + * + * Other possible modes: + * + * M_non_real_time - the clock ignores real time completely; at each call to + * tick(), it pretends that exactly dt seconds have elapsed since the last + * call to tick(). You may set the value of dt with set_dt() or + * set_frame_rate(). + * + * M_limited - the clock will run as fast as it can, as in M_normal, but will + * not run faster than the rate specified by set_frame_rate(). If the + * application would run faster than this rate, the clock will slow down the + * application. + * + * M_integer - the clock will run as fast as it can, but the rate will be + * constrained to be an integer multiple or divisor of the rate specified by + * set_frame_rate(). The clock will slow down the application a bit to + * guarantee this. + * + * M_integer_limited - a combination of M_limited and M_integer; the clock + * will not run faster than set_frame_rate(), and if it runs slower, it will + * run at a integer divisor of that rate. + * + * M_forced - the clock forces the application to run at the rate specified by + * set_frame_rate(). If the application would run faster than this rate, the + * clock will slow down the application; if the application would run slower + * than this rate, the clock slows down time so that the application believes + * it is running at the given rate. + * + * M_degrade - the clock runs at real time, but the application is slowed down + * by a set factor of its frame rate, specified by set_degrade_factor(). + * + * M_slave - the clock does not advance, but relies on the user to call + * set_frame_time() and/or set_frame_count() each frame. + */ void ClockObject:: set_mode(ClockObject::Mode mode) { Thread *current_thread = Thread::get_current_thread(); @@ -168,22 +152,17 @@ set_mode(ClockObject::Mode mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_real_time -// Access: Published -// Description: Resets the clock to the indicated time. This -// changes only the real time of the clock as reported -// by get_real_time(), but does not immediately change -// the time reported by get_frame_time()--that will -// change after the next call to tick(). Also see -// reset(), set_frame_time(), and set_frame_count(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the clock to the indicated time. This changes only the real time of + * the clock as reported by get_real_time(), but does not immediately change + * the time reported by get_frame_time()--that will change after the next call + * to tick(). Also see reset(), set_frame_time(), and set_frame_count(). + */ void ClockObject:: set_real_time(double time) { #ifdef NOTIFY_DEBUG - // This is only a debug message, since it happens during normal - // development, particularly at startup, or whenever you break into - // the task loop. + // This is only a debug message, since it happens during normal development, + // particularly at startup, or whenever you break into the task loop. if (util_cat.is_debug() && this == _global_clock) { util_cat.debug() << "Adjusting global clock's real time by " << time - get_real_time() @@ -194,14 +173,11 @@ set_real_time(double time) { _start_long_time = _true_clock->get_long_time() - time; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_frame_time -// Access: Published -// Description: Changes the time as reported for the current frame to -// the indicated time. Normally, the way to adjust the -// frame time is via tick(); this function is provided -// only for occasional special adjustments. -//////////////////////////////////////////////////////////////////// +/** + * Changes the time as reported for the current frame to the indicated time. + * Normally, the way to adjust the frame time is via tick(); this function is + * provided only for occasional special adjustments. + */ void ClockObject:: set_frame_time(double time, Thread *current_thread) { nassertv(current_thread->get_pipeline_stage() == 0); @@ -221,20 +197,17 @@ set_frame_time(double time, Thread *current_thread) { cdata->_frame_count / _user_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_frame_count -// Access: Published -// Description: Resets the number of frames counted to the indicated -// number. Also see reset(), set_real_time(), and -// set_frame_time(). -//////////////////////////////////////////////////////////////////// +/** + * Resets the number of frames counted to the indicated number. Also see + * reset(), set_real_time(), and set_frame_time(). + */ void ClockObject:: set_frame_count(int frame_count, Thread *current_thread) { nassertv(current_thread->get_pipeline_stage() == 0); #ifdef NOTIFY_DEBUG if (this == _global_clock && _mode != M_slave) { util_cat.warning() - << "Adjusting global clock's frame count by " + << "Adjusting global clock's frame count by " << frame_count - get_frame_count() << " frames.\n"; } #endif // NOTIFY_DEBUG @@ -246,17 +219,14 @@ set_frame_count(int frame_count, Thread *current_thread) { cdata->_frame_count / _user_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_dt -// Access: Published -// Description: In non-real-time mode, sets the number of seconds -// that should appear to elapse between frames. In -// forced mode or limited mode, sets our target dt. In -// normal mode, this has no effect. -// -// Also see set_frame_rate(), which is a different way -// to specify the same quantity. -//////////////////////////////////////////////////////////////////// +/** + * In non-real-time mode, sets the number of seconds that should appear to + * elapse between frames. In forced mode or limited mode, sets our target dt. + * In normal mode, this has no effect. + * + * Also see set_frame_rate(), which is a different way to specify the same + * quantity. + */ void ClockObject:: set_dt(double dt) { if (_mode == M_slave) { @@ -274,17 +244,13 @@ set_dt(double dt) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::set_frame_rate -// Access: Published -// Description: In non-real-time mode, sets the number of frames per -// second that we should appear to be running. In forced -// mode or limited mode, sets our target frame rate. In -// normal mode, this has no effect. -// -// Also see set_dt(), which is a different way to -// specify the same quantity. -//////////////////////////////////////////////////////////////////// +/** + * In non-real-time mode, sets the number of frames per second that we should + * appear to be running. In forced mode or limited mode, sets our target + * frame rate. In normal mode, this has no effect. + * + * Also see set_dt(), which is a different way to specify the same quantity. + */ void ClockObject:: set_frame_rate(double frame_rate) { nassertv(frame_rate != 0.0); @@ -307,15 +273,11 @@ set_frame_rate(double frame_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_average_frame_rate -// Access: Published -// Description: Returns the average frame rate in number of frames -// per second over the last -// get_average_frame_rate_interval() seconds. This -// measures the virtual frame rate if the clock is in -// M_non_real_time mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the average frame rate in number of frames per second over the last + * get_average_frame_rate_interval() seconds. This measures the virtual frame + * rate if the clock is in M_non_real_time mode. + */ double ClockObject:: get_average_frame_rate(Thread *current_thread) const { CDStageReader cdata(_cycler, 0, current_thread); @@ -326,12 +288,10 @@ get_average_frame_rate(Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::get_max_frame_duration -// Access: Published -// Description: Returns the maximum frame duration over the last -// get_average_frame_rate_interval() seconds. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum frame duration over the last + * get_average_frame_rate_interval() seconds. + */ double ClockObject:: get_max_frame_duration(Thread *current_thread) const { CDStageReader cdata(_cycler, 0, current_thread); @@ -347,22 +307,17 @@ get_max_frame_duration(Thread *current_thread) const { return max_duration; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::calc_frame_time_deviation -// Access: Published -// Description: Returns the standard deviation of the frame times of -// the frames rendered over the past -// get_average_frame_rate_interval() seconds. This -// number gives an estimate of the chugginess of the -// frame rate; if it is large, there is a large -// variation in the frame rate; if is small, all of the -// frames are consistent in length. -// -// A large value might also represent just a recent -// change in frame rate, for instance, because the -// camera has just rotated from looking at a simple -// scene to looking at a more complex scene. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard deviation of the frame times of the frames rendered + * over the past get_average_frame_rate_interval() seconds. This number gives + * an estimate of the chugginess of the frame rate; if it is large, there is a + * large variation in the frame rate; if is small, all of the frames are + * consistent in length. + * + * A large value might also represent just a recent change in frame rate, for + * instance, because the camera has just rotated from looking at a simple + * scene to looking at a more complex scene. + */ double ClockObject:: calc_frame_rate_deviation(Thread *current_thread) const { CDStageReader cdata(_cycler, 0, current_thread); @@ -382,16 +337,12 @@ calc_frame_rate_deviation(Thread *current_thread) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::tick -// Access: Published -// Description: Instructs the clock that a new frame has just begun. -// In normal, real-time mode, get_frame_time() will -// henceforth report the time as of this instant as the -// current start-of-frame time. In non-real-time mode, -// get_frame_time() will be incremented by the value of -// dt. -//////////////////////////////////////////////////////////////////// +/** + * Instructs the clock that a new frame has just begun. In normal, real-time + * mode, get_frame_time() will henceforth report the time as of this instant + * as the current start-of-frame time. In non-real-time mode, + * get_frame_time() will be incremented by the value of dt. + */ void ClockObject:: tick(Thread *current_thread) { nassertv(current_thread->get_pipeline_stage() == 0); @@ -402,28 +353,27 @@ tick(Thread *current_thread) { double old_time = _actual_frame_time; _actual_frame_time = get_real_time(); - // In case someone munged the clock last frame and sent us - // backward in time, clamp the previous time to the current time - // to make sure we don't report anything strange (or wait - // interminably). + // In case someone munged the clock last frame and sent us backward in + // time, clamp the previous time to the current time to make sure we don't + // report anything strange (or wait interminably). old_time = min(old_time, _actual_frame_time); ++cdata->_frame_count; - + switch (_mode) { case M_normal: // Time runs as it will; we simply report time elapsing. cdata->_dt = _actual_frame_time - old_time; cdata->_reported_frame_time = _actual_frame_time; break; - + case M_non_real_time: - // Ignore real time. We always report the same interval having - // elapsed each frame. + // Ignore real time. We always report the same interval having elapsed + // each frame. cdata->_reported_frame_time = cdata->_reported_frame_time_epoch + cdata->_frame_count / _user_frame_rate; break; - + case M_limited: // If we are running faster than the desired interval, slow down. { @@ -439,12 +389,12 @@ tick(Thread *current_thread) { double dt = _actual_frame_time - old_time; double target_dt = 1.0 / _user_frame_rate; if (dt < target_dt) { - // We're running faster than the desired interval, so slow - // down to the next integer multiple of the frame rate. + // We're running faster than the desired interval, so slow down to + // the next integer multiple of the frame rate. target_dt = target_dt / floor(target_dt / dt); } else { - // We're running slower than the desired interval, so slow - // down to the next integer divisor of the frame rate. + // We're running slower than the desired interval, so slow down to + // the next integer divisor of the frame rate. target_dt = target_dt * ceil(dt / target_dt); } double wait_until_time = old_time + target_dt; @@ -459,12 +409,12 @@ tick(Thread *current_thread) { double dt = _actual_frame_time - old_time; double target_dt = 1.0 / _user_frame_rate; if (dt < target_dt) { - // We're running faster than the desired interval, so slow - // down to the target frame rate. + // We're running faster than the desired interval, so slow down to + // the target frame rate. } else { - // We're running slower than the desired interval, so slow - // down to the next integer divisor of the frame rate. + // We're running slower than the desired interval, so slow down to + // the next integer divisor of the frame rate. target_dt = target_dt * ceil(dt / target_dt); } double wait_until_time = old_time + target_dt; @@ -473,33 +423,33 @@ tick(Thread *current_thread) { cdata->_reported_frame_time = wait_until_time; } break; - + case M_forced: - // If we are running faster than the desired interval, slow down. - // If we are running slower than the desired interval, ignore that - // and pretend we're running at the specified rate. + // If we are running faster than the desired interval, slow down. If we + // are running slower than the desired interval, ignore that and pretend + // we're running at the specified rate. wait_until(old_time + 1.0 / _user_frame_rate); cdata->_reported_frame_time = cdata->_reported_frame_time_epoch + cdata->_frame_count / _user_frame_rate; break; - + case M_degrade: - // Each frame, wait a certain fraction of the previous frame's - // time to degrade performance uniformly. + // Each frame, wait a certain fraction of the previous frame's time to + // degrade performance uniformly. cdata->_dt = (_actual_frame_time - old_time) * _degrade_factor; - + if (_degrade_factor < 1.0) { // If the degrade_factor is less than one, we want to simulate a // higher frame rate by incrementing the clock more slowly. cdata->_reported_frame_time += cdata->_dt; - + } else { - // Otherwise, we simulate a lower frame rate by waiting until - // the appropriate time has elapsed. + // Otherwise, we simulate a lower frame rate by waiting until the + // appropriate time has elapsed. wait_until(old_time + cdata->_dt); cdata->_reported_frame_time = _actual_frame_time; } - + break; case M_slave: @@ -510,27 +460,22 @@ tick(Thread *current_thread) { if (_average_frame_rate_interval > 0.0) { _ticks.push_back(old_reported_time); - while (_ticks.size() > 2 && + while (_ticks.size() > 2 && cdata->_reported_frame_time - _ticks.front() > _average_frame_rate_interval) { _ticks.pop_front(); } } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::sync_frame_time -// Access: Published -// Description: Resets the frame time to the current real time. This -// is similar to tick(), except that it does not advance -// the frame counter and does not affect dt. This is -// intended to be used in the middle of a particularly -// long frame to compensate for the time that has -// already elapsed. -// -// In non-real-time mode, this function has no effect -// (because in this mode all frames take the same length -// of time). -//////////////////////////////////////////////////////////////////// +/** + * Resets the frame time to the current real time. This is similar to tick(), + * except that it does not advance the frame counter and does not affect dt. + * This is intended to be used in the middle of a particularly long frame to + * compensate for the time that has already elapsed. + * + * In non-real-time mode, this function has no effect (because in this mode + * all frames take the same length of time). + */ void ClockObject:: sync_frame_time(Thread *current_thread) { if (_mode == M_normal) { @@ -539,13 +484,10 @@ sync_frame_time(Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::wait_until -// Access: Private -// Description: Waits at the end of a frame until the indicated time -// has arrived. This is used to implement M_forced and -// M_degrade. -//////////////////////////////////////////////////////////////////// +/** + * Waits at the end of a frame until the indicated time has arrived. This is + * used to implement M_forced and M_degrade. + */ void ClockObject:: wait_until(double want_time) { if (want_time <= _actual_frame_time) { @@ -557,7 +499,7 @@ wait_until(double want_time) { #endif double wait_interval = (want_time - _actual_frame_time) - sleep_precision; - + if (wait_interval > 0.0) { Thread::sleep(wait_interval); } @@ -565,7 +507,7 @@ wait_until(double want_time) { #ifdef DO_PSTATS (*_start_clock_busy_wait)(); #endif - + // Now busy-wait until the actual time elapses. while (_actual_frame_time < want_time) { _actual_frame_time = get_real_time(); @@ -576,12 +518,9 @@ wait_until(double want_time) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::make_global_clock -// Access: Private, Static -// Description: Called once per application to create the global -// clock object. -//////////////////////////////////////////////////////////////////// +/** + * Called once per application to create the global clock object. + */ void ClockObject:: make_global_clock() { nassertv(_global_clock == (ClockObject *)NULL); @@ -598,22 +537,18 @@ make_global_clock() { _global_clock->ref(); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::dummy_clock_wait -// Access: Private, Static -// Description: This no-op function is assigned as the initial -// pointer for _start_clock_wait and _stop_clock_wait, -// until the PStatClient comes along and replaces it. -//////////////////////////////////////////////////////////////////// +/** + * This no-op function is assigned as the initial pointer for + * _start_clock_wait and _stop_clock_wait, until the PStatClient comes along + * and replaces it. + */ void ClockObject:: dummy_clock_wait() { } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::CData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ClockObject::CData:: CData() { _frame_count = 0; @@ -622,20 +557,17 @@ CData() { _dt = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::CData::make_copy -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CycleData *ClockObject::CData:: make_copy() const { return new CData(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::Mode ostream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, ClockObject::Mode mode) { switch (mode) { @@ -667,10 +599,9 @@ operator << (ostream &out, ClockObject::Mode mode) { return out << "**invalid ClockObject::Mode(" << (int)mode << ")**"; } -//////////////////////////////////////////////////////////////////// -// Function: ClockObject::Mode istream operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, ClockObject::Mode &mode) { string word; diff --git a/panda/src/putil/clockObject.h b/panda/src/putil/clockObject.h index a21c487bb1..ca7e3d2116 100644 --- a/panda/src/putil/clockObject.h +++ b/panda/src/putil/clockObject.h @@ -1,16 +1,15 @@ -// Filename: clockObject.h -// Created by: drose (19Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file clockObject.h + * @author drose + * @date 1999-02-19 + */ #ifndef CLOCKOBJECT_H #define CLOCKOBJECT_H @@ -37,32 +36,25 @@ PUBLISHED: ulong tv[2]; }; -//////////////////////////////////////////////////////////////////// -// Class : ClockObject -// Description : A ClockObject keeps track of elapsed real time and -// discrete time. In normal mode, get_frame_time() -// returns the time as of the last time tick() was -// called. This is the "discrete" time, and is usually -// used to get the time as of, for instance, the -// beginning of the current frame. -// -// In other modes, as set by set_mode() or the -// clock-mode config variable, get_frame_time() may -// return other values to simulate different timing -// effects, for instance to perform non-real-time -// animation. See set_mode(). -// -// In all modes, get_real_time() always returns the -// elapsed real time in seconds since the ClockObject -// was constructed, or since it was last reset. -// -// You can create your own ClockObject whenever you want -// to have your own local timer. There is also a -// default, global ClockObject intended to represent -// global time for the application; this is normally set -// up to tick every frame so that its get_frame_time() -// will return the time for the current frame. -//////////////////////////////////////////////////////////////////// +/** + * A ClockObject keeps track of elapsed real time and discrete time. In + * normal mode, get_frame_time() returns the time as of the last time tick() + * was called. This is the "discrete" time, and is usually used to get the + * time as of, for instance, the beginning of the current frame. + * + * In other modes, as set by set_mode() or the clock-mode config variable, + * get_frame_time() may return other values to simulate different timing + * effects, for instance to perform non-real-time animation. See set_mode(). + * + * In all modes, get_real_time() always returns the elapsed real time in + * seconds since the ClockObject was constructed, or since it was last reset. + * + * You can create your own ClockObject whenever you want to have your own + * local timer. There is also a default, global ClockObject intended to + * represent global time for the application; this is normally set up to tick + * every frame so that its get_frame_time() will return the time for the + * current frame. + */ class EXPCL_PANDA_PUTIL ClockObject : public ReferenceCount { PUBLISHED: enum Mode { @@ -153,8 +145,7 @@ private: double _degrade_factor; int _error_count; - // For tracking the average frame rate over a certain interval of - // time. + // For tracking the average frame rate over a certain interval of time. double _average_frame_rate_interval; typedef pdeque Ticks; Ticks _ticks; @@ -205,4 +196,3 @@ operator >> (istream &in, ClockObject::Mode &mode); #include "clockObject.I" #endif - diff --git a/panda/src/putil/collideMask.h b/panda/src/putil/collideMask.h index d01a5d6685..26f26adbad 100644 --- a/panda/src/putil/collideMask.h +++ b/panda/src/putil/collideMask.h @@ -1,16 +1,15 @@ -// Filename: collideMask.h -// Created by: drose (03Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collideMask.h + * @author drose + * @date 2000-07-03 + */ #ifndef COLLIDEMASK_H #define COLLIDEMASK_H @@ -19,38 +18,35 @@ #include "bitMask.h" -// This is the data type of the collision mask: the set of bits that -// every CollisionNode has, and that any two nodes must have some in -// common in order to be tested for a mutual intersection. +// This is the data type of the collision mask: the set of bits that every +// CollisionNode has, and that any two nodes must have some in common in order +// to be tested for a mutual intersection. -// This file used to live in the collide directory, but since it's -// such a trivial definition that a few other directories (like egg) -// need without necessarily having to pull in all of collide, it -// seemed better to move it to putil. +// This file used to live in the collide directory, but since it's such a +// trivial definition that a few other directories (like egg) need without +// necessarily having to pull in all of collide, it seemed better to move it +// to putil. typedef BitMask32 CollideMask; -// We need some conventions for initial bits for GeomNodes and -// CollideNodes. These are primarily advisory, since the application -// programmer is free to define each bit as he or she chooses, but -// they also control the initial default values that are assigned to -// new nodes. +// We need some conventions for initial bits for GeomNodes and CollideNodes. +// These are primarily advisory, since the application programmer is free to +// define each bit as he or she chooses, but they also control the initial +// default values that are assigned to new nodes. // By established convention, the lower 20 bits are reserved for -// CollisionNodes. Each CollisionNode has all these bits set on by -// default (and no others). You can (and probably should) change this -// on a per-node basis to specialize CollisionNodes for different -// purposes. +// CollisionNodes. Each CollisionNode has all these bits set on by default +// (and no others). You can (and probably should) change this on a per-node +// basis to specialize CollisionNodes for different purposes. static const CollideMask default_collision_node_collide_mask = CollideMask::lower_on(20); -// The next bit is reserved for generic GeomNodes. Each GeomNode has -// this bit on by default (and no others). You can, of course, set -// any mask you want on a particular GeomNode; this is just the -// default bit if you choose not to do anything. +// The next bit is reserved for generic GeomNodes. Each GeomNode has this bit +// on by default (and no others). You can, of course, set any mask you want +// on a particular GeomNode; this is just the default bit if you choose not to +// do anything. static const CollideMask default_geom_node_collide_mask = CollideMask::bit(20); -// The remaining 11 bits are presently unassigned. No nodes will have -// these bits on by default. +// The remaining 11 bits are presently unassigned. No nodes will have these +// bits on by default. #endif - diff --git a/panda/src/putil/colorSpace.cxx b/panda/src/putil/colorSpace.cxx index 90906fe97e..34c37ee423 100644 --- a/panda/src/putil/colorSpace.cxx +++ b/panda/src/putil/colorSpace.cxx @@ -1,16 +1,15 @@ -// Filename: colorSpace.cxx -// Created by: rdb (02Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorSpace.cxx + * @author rdb + * @date 2014-06-02 + */ #include "colorSpace.h" #include "config_util.h" diff --git a/panda/src/putil/colorSpace.h b/panda/src/putil/colorSpace.h index 86049c0863..97d70ad49f 100644 --- a/panda/src/putil/colorSpace.h +++ b/panda/src/putil/colorSpace.h @@ -1,16 +1,15 @@ -// Filename: colorSpace.h -// Created by: rdb (02Jun14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file colorSpace.h + * @author rdb + * @date 2014-06-02 + */ #ifndef COLORSPACE_H #define COLORSPACE_H @@ -22,24 +21,24 @@ BEGIN_PUBLISH enum ColorSpace { - // This value is not a color space, but is used to indicate that - // a color space has not been specified. + // This value is not a color space, but is used to indicate that a color + // space has not been specified. CS_unspecified = 0, - // CS_linear is not a color space per se, but represents the - // working color space of graphics APIs, which is linearized. Since - // the conversion from sRGB to linear is defined, one could posit - // that it has the ITU-R BT.709 primaries, but this isn't meaningful - // as modern graphics APIs do not perform color management. - // All colors in Panda3D are linear unless otherwise specified. + // CS_linear is not a color space per se, but represents the working color + // space of graphics APIs, which is linearized. Since the conversion from + // sRGB to linear is defined, one could posit that it has the ITU-R BT.709 + // primaries, but this isn't meaningful as modern graphics APIs do not + // perform color management. All colors in Panda3D are linear unless + // otherwise specified. CS_linear, - // This is the standard, gamma-2.2-corrected sRGB color space, as - // used by the majority of image formats. + // This is the standard, gamma-2.2-corrected sRGB color space, as used by + // the majority of image formats. CS_sRGB, - // This is a 16-bit encoded linear color space capable of encoding - // color values in the -0.5...7.4999 range. + // This is a 16-bit encoded linear color space capable of encoding color + // values in the -0.5...7.4999 range. CS_scRGB, }; diff --git a/panda/src/putil/compareTo.I b/panda/src/putil/compareTo.I index 7593d33f16..d327f6b4bb 100644 --- a/panda/src/putil/compareTo.I +++ b/panda/src/putil/compareTo.I @@ -1,23 +1,19 @@ -// Filename: compareTo.I -// Created by: drose (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compareTo.I + * @author drose + * @date 2002-02-22 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CompareTo::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool CompareTo:: operator () (const ObjectType &a, const ObjectType &b) const { diff --git a/panda/src/putil/compareTo.h b/panda/src/putil/compareTo.h index b8c8ad033b..7764b27338 100644 --- a/panda/src/putil/compareTo.h +++ b/panda/src/putil/compareTo.h @@ -1,29 +1,26 @@ -// Filename: compareTo.h -// Created by: drose (22Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file compareTo.h + * @author drose + * @date 2002-02-22 + */ #ifndef COMPARETO_H #define COMPARETO_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : CompareTo -// Description : An STL function object class, this is intended to be -// used on any ordered collection of classes that -// contain a compare_to() method. It defines the order -// of the pointers via compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of classes that contain a compare_to() method. It defines the + * order of the pointers via compare_to(). + */ template class CompareTo { public: @@ -33,4 +30,3 @@ public: #include "compareTo.I" #endif - diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index 44ac7bd6a4..25277a436e 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -1,16 +1,15 @@ -// Filename: config_util.cxx -// Created by: cary (04Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_util.cxx + * @author cary + * @date 2000-01-04 + */ #include "config_util.h" #include "animInterface.h" @@ -83,22 +82,21 @@ ConfigureFn(config_util) { init_libputil(); } -// Set this true to enable tracking of ReferenceCount pointer -// allocation/deallcation via the MemoryUsage object. This is -// primarily useful for detecting memory leaks. It has no effect when -// compiling in NDEBUG mode. -// -// This variable is no longer defined here; instead, it's a member of -// MemoryUsage. -// -// ConfigVariableBool track_memory_usage("track-memory-usage", false); +/* + * Set this true to enable tracking of ReferenceCount pointer + * allocationdeallcation via the MemoryUsage object. This is primarily useful + * for detecting memory leaks. It has no effect when compiling in NDEBUG + * mode. This variable is no longer defined here; instead, it's a member of + * MemoryUsage. ConfigVariableBool track_memory_usage("track-memory-usage", + * false); + */ ConfigVariableSearchPath & get_model_path() { static ConfigVariableSearchPath *model_path = NULL; if (model_path == NULL) { model_path = new ConfigVariableSearchPath - ("model-path", + ("model-path", PRC_DESC("The default directories to search for all models and general " "files loaded into Panda.")); } @@ -159,14 +157,12 @@ ConfigVariableBool cache_check_timestamps "to on-disk caching via model-cache-dir, which always checks the " "timestamps.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libputil -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libputil() { static bool initialized = false; diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h index a2fe2ff06c..1127d35fe4 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_util.h @@ -1,16 +1,15 @@ -// Filename: config_util.h -// Created by: cary (04Jan00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_util.h + * @author cary + * @date 2000-01-04 + */ #ifndef __CONFIG_UTIL_H__ #define __CONFIG_UTIL_H__ @@ -29,11 +28,10 @@ ConfigureDecl(config_util, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDecl(util, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); NotifyCategoryDecl(bam, EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL); -// Actually, we can't determine this config variable the normal way, -// because we must be able to access it at static init time. Instead -// of declaring it a global constant, we'll make it a member of -// MemoryUsage. -//extern EXPCL_PANDA_PUTIL const bool track_memory_usage; +// Actually, we can't determine this config variable the normal way, because +// we must be able to access it at static init time. Instead of declaring it +// a global constant, we'll make it a member of MemoryUsage. extern +// EXPCL_PANDA_PUTIL const bool track_memory_usage; extern EXPCL_PANDA_PUTIL ConfigVariableEnum bam_endian; extern EXPCL_PANDA_PUTIL ConfigVariableBool bam_stdfloat_double; diff --git a/panda/src/putil/configurable.cxx b/panda/src/putil/configurable.cxx index 8e4263138f..cfa2df3413 100644 --- a/panda/src/putil/configurable.cxx +++ b/panda/src/putil/configurable.cxx @@ -1,16 +1,15 @@ -// Filename: configurable.cxx -// Created by: drose (15Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configurable.cxx + * @author drose + * @date 1999-01-15 + */ #include "configurable.h" diff --git a/panda/src/putil/configurable.h b/panda/src/putil/configurable.h index 784646b675..f03870baf9 100644 --- a/panda/src/putil/configurable.h +++ b/panda/src/putil/configurable.h @@ -1,38 +1,32 @@ -// Filename: configurable.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file configurable.h + * @author mike + * @date 1997-01-09 + */ + #ifndef CONFIGURABLE_H #define CONFIGURABLE_H -// -//////////////////////////////////////////////////////////////////// + // Includes -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include "typedObject.h" -//////////////////////////////////////////////////////////////////// // Defines -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Class : Configurable -// Description : An object that has data or parameters that are set -// less frequently (at least occasionally) than every -// frame. We can cache the configuration info by -// by using the "dirty" flag. -//////////////////////////////////////////////////////////////////// +/** + * An object that has data or parameters that are set less frequently (at + * least occasionally) than every frame. We can cache the configuration info + * by by using the "dirty" flag. + */ class EXPCL_PANDA_PUTIL Configurable : public TypedObject { public: @@ -40,12 +34,11 @@ public: virtual void config( void ) { _dirty = false; } INLINE void check_config() const { if (_dirty) { - // This is a sneaky trick to allow check_config() to be called - // from a const member function. Even though we will be calling - // config(), a non-const function that modifies the class - // object, in some sense it's not really modifying the class - // object--it's just updating a few internal settings for - // consistency. + // This is a sneaky trick to allow check_config() to be called from a + // const member function. Even though we will be calling config(), a + // non-const function that modifies the class object, in some sense it's + // not really modifying the class object--it's just updating a few + // internal settings for consistency. ((Configurable *)this)->config(); } } diff --git a/panda/src/putil/copyOnWriteObject.I b/panda/src/putil/copyOnWriteObject.I index 3ad239c47a..c8727d8e7c 100644 --- a/panda/src/putil/copyOnWriteObject.I +++ b/panda/src/putil/copyOnWriteObject.I @@ -1,17 +1,15 @@ -// Filename: copyOnWriteObject.I -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWriteObject.I + * @author drose + * @date 2007-04-09 + */ template TypeHandle CopyOnWriteObj::_type_handle; @@ -19,16 +17,14 @@ TypeHandle CopyOnWriteObj::_type_handle; template TypeHandle CopyOnWriteObj1::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWriteObject:: -CopyOnWriteObject() +CopyOnWriteObject() #ifdef COW_THREADED : _lock_mutex("CopyOnWriteObject::_lock"), - _lock_cvar(_lock_mutex) + _lock_cvar(_lock_mutex) #endif { #ifdef DO_MEMORY_USAGE @@ -40,17 +36,15 @@ CopyOnWriteObject() #endif // COW_THREADED } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObject::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWriteObject:: CopyOnWriteObject(const CopyOnWriteObject ©) : CachedTypedWritableReferenceCount(copy) #ifdef COW_THREADED , _lock_mutex("CopyOnWriteObject::_lock"), - _lock_cvar(_lock_mutex) + _lock_cvar(_lock_mutex) #endif { #ifdef DO_MEMORY_USAGE @@ -62,22 +56,18 @@ CopyOnWriteObject(const CopyOnWriteObject ©) : #endif // COW_THREADED } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObject::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CopyOnWriteObject:: operator = (const CopyOnWriteObject ©) { CachedTypedWritableReferenceCount::operator = (copy); } #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObject::cache_ref -// Access: Published -// Description: See CachedTypedWritableReferenceCount::cache_ref(). -//////////////////////////////////////////////////////////////////// +/** + * See CachedTypedWritableReferenceCount::cache_ref(). + */ INLINE void CopyOnWriteObject:: cache_ref() const { MutexHolder holder(_lock_mutex); @@ -85,57 +75,47 @@ cache_ref() const { } #endif // COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj:: CopyOnWriteObj() { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj:: -CopyOnWriteObj(const Base ©) : - Base(copy) +CopyOnWriteObj(const Base ©) : + Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj:: -CopyOnWriteObj(const CopyOnWriteObj ©) : +CopyOnWriteObj(const CopyOnWriteObj ©) : CopyOnWriteObject(copy), - Base(copy) + Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj::make_cow_copy -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template PT(CopyOnWriteObject) CopyOnWriteObj:: make_cow_copy() { return new CopyOnWriteObj(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void CopyOnWriteObj:: init_type() { @@ -151,61 +131,51 @@ init_type() { CopyOnWriteObject::init_type(); _type_handle = register_dynamic_type("CopyOnWriteObj<" + base_name + ">", - base_type, + base_type, CopyOnWriteObject::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj1::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj1:: CopyOnWriteObj1(Param1 p1) : Base(p1) { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj1::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj1:: -CopyOnWriteObj1(const Base ©) : - Base(copy) +CopyOnWriteObj1(const Base ©) : + Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj1::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWriteObj1:: -CopyOnWriteObj1(const CopyOnWriteObj1 ©) : +CopyOnWriteObj1(const CopyOnWriteObj1 ©) : CopyOnWriteObject(copy), - Base(copy) + Base(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj1::make_cow_copy -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template PT(CopyOnWriteObject) CopyOnWriteObj1:: make_cow_copy() { return new CopyOnWriteObj1(*this); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObj1::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void CopyOnWriteObj1:: init_type() { @@ -221,6 +191,6 @@ init_type() { CopyOnWriteObject::init_type(); _type_handle = register_dynamic_type("CopyOnWriteObj1<" + base_name + ">", - base_type, + base_type, CopyOnWriteObject::get_class_type()); } diff --git a/panda/src/putil/copyOnWriteObject.cxx b/panda/src/putil/copyOnWriteObject.cxx index a7de103126..0faa2f23ce 100644 --- a/panda/src/putil/copyOnWriteObject.cxx +++ b/panda/src/putil/copyOnWriteObject.cxx @@ -1,16 +1,15 @@ -// Filename: copyOnWriteObject.cxx -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWriteObject.cxx + * @author drose + * @date 2007-04-09 + */ #include "copyOnWriteObject.h" #include "mutexHolder.h" @@ -19,16 +18,12 @@ TypeHandle CopyOnWriteObject::_type_handle; #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWriteObject::unref -// Access: Public, Virtual -// Description: Explicitly decrements the reference count. See -// ReferenceCount::unref(). -// -// In the case of a CopyOnWriteObject, when the -// reference count decrements down to the cache -// reference count, the object is implicitly unlocked. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the reference count. See ReferenceCount::unref(). + * + * In the case of a CopyOnWriteObject, when the reference count decrements + * down to the cache reference count, the object is implicitly unlocked. + */ bool CopyOnWriteObject:: unref() const { MutexHolder holder(_lock_mutex); diff --git a/panda/src/putil/copyOnWriteObject.h b/panda/src/putil/copyOnWriteObject.h index e7d1ca7be9..4799c727f1 100644 --- a/panda/src/putil/copyOnWriteObject.h +++ b/panda/src/putil/copyOnWriteObject.h @@ -1,16 +1,15 @@ -// Filename: copyOnWriteObject.h -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWriteObject.h + * @author drose + * @date 2007-04-09 + */ #ifndef COPYONWRITEOBJECT_H #define COPYONWRITEOBJECT_H @@ -22,25 +21,23 @@ #include "conditionVar.h" #include "mutexHolder.h" -// Should we implement full thread protection for CopyOnWritePointer? -// If we can be assured that no other thread will interrupt while a -// write pointer is held, we don't need thread protection. +// Should we implement full thread protection for CopyOnWritePointer? If we +// can be assured that no other thread will interrupt while a write pointer is +// held, we don't need thread protection. -// Nowadays, this is the same thing as asking if HAVE_THREADS is -// defined. Maybe we'll just replace COW_THREADED with HAVE_THREADS -// in the future. +// Nowadays, this is the same thing as asking if HAVE_THREADS is defined. +// Maybe we'll just replace COW_THREADED with HAVE_THREADS in the future. #ifdef HAVE_THREADS #define COW_THREADED 1 #else #undef COW_THREADED #endif -//////////////////////////////////////////////////////////////////// -// Class : CopyOnWriteObject -// Description : This base class provides basic reference counting, -// but also can be used with a CopyOnWritePointer to -// provide get_read_pointer() and get_write_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * This base class provides basic reference counting, but also can be used + * with a CopyOnWritePointer to provide get_read_pointer() and + * get_write_pointer(). + */ class EXPCL_PANDA_PUTIL CopyOnWriteObject : public CachedTypedWritableReferenceCount { public: INLINE CopyOnWriteObject(); @@ -93,12 +90,10 @@ private: friend class CopyOnWritePointer; }; -//////////////////////////////////////////////////////////////////// -// Class : CopyOnWriteObj -// Description : This is similar to RefCountObj, but it implements a -// CopyOnWriteObject inheritance instead of a -// ReferenceCount inheritance. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to RefCountObj, but it implements a CopyOnWriteObject + * inheritance instead of a ReferenceCount inheritance. + */ template class CopyOnWriteObj : public CopyOnWriteObject, public Base { public: @@ -128,11 +123,9 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : CopyOnWriteObj1 -// Description : For objects (e.g. pvectors) whose constructor -// takes a single parameter. -//////////////////////////////////////////////////////////////////// +/** + * For objects (e.g. pvectors) whose constructor takes a single parameter. + */ template class CopyOnWriteObj1 : public CopyOnWriteObject, public Base { public: diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index 47e51fab15..98a0987791 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -1,23 +1,19 @@ -// Filename: copyOnWritePointer.I -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWritePointer.I + * @author drose + * @date 2007-04-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWritePointer:: CopyOnWritePointer(CopyOnWriteObject *object) : _cow_object(object) @@ -27,11 +23,9 @@ CopyOnWritePointer(CopyOnWriteObject *object) : } } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWritePointer:: CopyOnWritePointer(const CopyOnWritePointer ©) : _cow_object(copy._cow_object) @@ -41,21 +35,17 @@ CopyOnWritePointer(const CopyOnWritePointer ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CopyOnWritePointer:: operator = (const CopyOnWritePointer ©) { operator = (copy._cow_object); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CopyOnWritePointer:: operator = (CopyOnWriteObject *object) { if (_cow_object != object) { @@ -69,11 +59,9 @@ operator = (CopyOnWriteObject *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWritePointer:: ~CopyOnWritePointer() { if (_cow_object != (CopyOnWriteObject *)NULL) { @@ -82,11 +70,9 @@ INLINE CopyOnWritePointer:: } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CopyOnWritePointer:: CopyOnWritePointer(CopyOnWritePointer &&move) NOEXCEPT : _cow_object(move._cow_object) @@ -95,11 +81,9 @@ CopyOnWritePointer(CopyOnWritePointer &&move) NOEXCEPT : move._cow_object = (CopyOnWriteObject *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void CopyOnWritePointer:: operator = (CopyOnWritePointer &&move) NOEXCEPT { // Protect against self-move-assignment. @@ -115,47 +99,37 @@ operator = (CopyOnWritePointer &&move) NOEXCEPT { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CopyOnWritePointer:: operator == (const CopyOnWritePointer &other) const { return _cow_object == other._cow_object; } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::operator != -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CopyOnWritePointer:: operator != (const CopyOnWritePointer &other) const { return _cow_object != other._cow_object; } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool CopyOnWritePointer:: operator < (const CopyOnWritePointer &other) const { return _cow_object < other._cow_object; } #ifndef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::get_read_pointer -// Access: Public -// Description: Returns a pointer locked for read. Until this -// pointer dereferences, calls to get_write_pointer() -// will force a copy. -// -// This flavor of the method is written for the -// non-threaded case. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer locked for read. Until this pointer dereferences, calls + * to get_write_pointer() will force a copy. + * + * This flavor of the method is written for the non-threaded case. + */ INLINE const CopyOnWriteObject *CopyOnWritePointer:: get_read_pointer() const { return _cow_object; @@ -163,19 +137,15 @@ get_read_pointer() const { #endif // COW_THREADED #ifndef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::get_write_pointer -// Access: Public -// Description: Returns a pointer locked for write. If another -// thread or threads already hold the pointer locked for -// read, then this will force a copy. -// -// Until this pointer dereferences, calls to -// get_read_pointer() or get_write_pointer() will block. -// -// This flavor of the method is written for the -// non-threaded case. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer locked for write. If another thread or threads already + * hold the pointer locked for read, then this will force a copy. + * + * Until this pointer dereferences, calls to get_read_pointer() or + * get_write_pointer() will block. + * + * This flavor of the method is written for the non-threaded case. + */ INLINE CopyOnWriteObject *CopyOnWritePointer:: get_write_pointer() { if (_cow_object == (CopyOnWriteObject *)NULL) { @@ -191,35 +161,28 @@ get_write_pointer() { } #endif // COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::get_unsafe_pointer -// Access: Public -// Description: Returns an unlocked pointer that you can write to. -// This should only be used in very narrow circumstances -// in which you know that no other thread may be -// accessing the pointer at the same time. -//////////////////////////////////////////////////////////////////// +/** + * Returns an unlocked pointer that you can write to. This should only be + * used in very narrow circumstances in which you know that no other thread + * may be accessing the pointer at the same time. + */ INLINE CopyOnWriteObject *CopyOnWritePointer:: get_unsafe_pointer() { return _cow_object; } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::is_null -// Access: Public -// Description: Returns true if the CopyOnWritePointer contains a -// NULL pointer, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the CopyOnWritePointer contains a NULL pointer, false + * otherwise. + */ bool CopyOnWritePointer:: is_null() const { return (_cow_object == (CopyOnWriteObject *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::clear -// Access: Public -// Description: Sets the pointer to NULL. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pointer to NULL. + */ void CopyOnWritePointer:: clear() { if (_cow_object != (CopyOnWriteObject *)NULL) { @@ -228,26 +191,20 @@ clear() { _cow_object = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::test_ref_count_integrity -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. Returns true if ok, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. Returns true if ok, false otherwise. + */ INLINE bool CopyOnWritePointer:: test_ref_count_integrity() const { nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); return _cow_object->test_ref_count_integrity(); } -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::test_ref_count_nonzero -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't zero, or completely bogus. Returns true -// if ok, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't zero, or + * completely bogus. Returns true if ok, false otherwise. + */ INLINE bool CopyOnWritePointer:: test_ref_count_nonzero() const { nassertr(_cow_object != (CopyOnWriteObject *)NULL, false); @@ -255,11 +212,9 @@ test_ref_count_nonzero() const { } #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWritePointerTo:: CopyOnWritePointerTo(To *object) : CopyOnWritePointer(object) { @@ -267,11 +222,9 @@ CopyOnWritePointerTo(To *object) : CopyOnWritePointer(object) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWritePointerTo:: CopyOnWritePointerTo(const CopyOnWritePointerTo ©) : @@ -281,11 +234,9 @@ CopyOnWritePointerTo(const CopyOnWritePointerTo ©) : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CopyOnWritePointerTo:: operator = (const CopyOnWritePointerTo ©) { @@ -294,11 +245,9 @@ operator = (const CopyOnWritePointerTo ©) { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CopyOnWritePointerTo:: operator = (To *object) { @@ -308,11 +257,9 @@ operator = (To *object) { #ifdef USE_MOVE_SEMANTICS #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::Move Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE CopyOnWritePointerTo:: CopyOnWritePointerTo(CopyOnWritePointerTo &&move) NOEXCEPT : @@ -322,11 +269,9 @@ CopyOnWritePointerTo(CopyOnWritePointerTo &&move) NOEXCEPT : #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::Move Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void CopyOnWritePointerTo:: operator = (CopyOnWritePointerTo &&move) NOEXCEPT { @@ -337,22 +282,18 @@ operator = (CopyOnWritePointerTo &&move) NOEXCEPT { #ifndef CPPPARSER #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::get_read_pointer -// Access: Public -// Description: See CopyOnWritePointer::get_read_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * See CopyOnWritePointer::get_read_pointer(). + */ template INLINE CPT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_read_pointer() const { return (const To *)(CopyOnWritePointer::get_read_pointer().p()); } #else // COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::get_read_pointer -// Access: Public -// Description: See CopyOnWritePointer::get_read_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * See CopyOnWritePointer::get_read_pointer(). + */ template INLINE const TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_read_pointer() const { @@ -363,22 +304,18 @@ get_read_pointer() const { #ifndef CPPPARSER #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::get_write_pointer -// Access: Public -// Description: See CopyOnWritePointer::get_write_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * See CopyOnWritePointer::get_write_pointer(). + */ template INLINE PT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_write_pointer() { return (To *)(CopyOnWritePointer::get_write_pointer().p()); } #else // COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::get_write_pointer -// Access: Public -// Description: See CopyOnWritePointer::get_write_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * See CopyOnWritePointer::get_write_pointer(). + */ template INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_write_pointer() { @@ -388,11 +325,9 @@ get_write_pointer() { #endif // CPPPARSER #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointerTo::get_unsafe_pointer -// Access: Public -// Description: See CopyOnWritePointer::get_unsafe_pointer(). -//////////////////////////////////////////////////////////////////// +/** + * See CopyOnWritePointer::get_unsafe_pointer(). + */ template INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_unsafe_pointer() { diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index 38ba2d63a5..5ff01f1ccc 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -1,16 +1,15 @@ -// Filename: copyOnWritePointer.cxx -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWritePointer.cxx + * @author drose + * @date 2007-04-09 + */ #include "copyOnWritePointer.h" #include "mutexHolder.h" @@ -18,16 +17,12 @@ #include "config_pipeline.h" #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::get_read_pointer -// Access: Public -// Description: Returns a pointer locked for read. Until this -// pointer dereferences, calls to get_write_pointer() -// will force a copy. -// -// This flavor of the method is written for the threaded -// case. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer locked for read. Until this pointer dereferences, calls + * to get_write_pointer() will force a copy. + * + * This flavor of the method is written for the threaded case. + */ CPT(CopyOnWriteObject) CopyOnWritePointer:: get_read_pointer() const { if (_cow_object == (CopyOnWriteObject *)NULL) { @@ -57,19 +52,15 @@ get_read_pointer() const { #endif // COW_THREADED #ifdef COW_THREADED -//////////////////////////////////////////////////////////////////// -// Function: CopyOnWritePointer::get_write_pointer -// Access: Public -// Description: Returns a pointer locked for write. If another -// thread or threads already hold the pointer locked for -// read, then this will force a copy. -// -// Until this pointer dereferences, calls to -// get_read_pointer() or get_write_pointer() will block. -// -// This flavor of the method is written for the threaded -// case. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer locked for write. If another thread or threads already + * hold the pointer locked for read, then this will force a copy. + * + * Until this pointer dereferences, calls to get_read_pointer() or + * get_write_pointer() will block. + * + * This flavor of the method is written for the threaded case. + */ PT(CopyOnWriteObject) CopyOnWritePointer:: get_write_pointer() { if (_cow_object == (CopyOnWriteObject *)NULL) { @@ -104,9 +95,9 @@ get_write_pointer() { _cow_object->cache_ref(); } else if (_cow_object->get_cache_ref_count() > 1) { - // No one else has it specifically read-locked, but there are - // other CopyOnWritePointers holding the same object, so we should - // make our own writable copy anyway. + // No one else has it specifically read-locked, but there are other + // CopyOnWritePointers holding the same object, so we should make our own + // writable copy anyway. if (util_cat.is_debug()) { util_cat.debug() << "Making copy of " << _cow_object->get_type() @@ -121,12 +112,12 @@ get_write_pointer() { } else { // No other thread has the pointer locked, and we're the only - // CopyOnWritePointer with this object. We can safely write to it - // without making a copy. + // CopyOnWritePointer with this object. We can safely write to it without + // making a copy. - // We can't assert that there are no outstanding ordinary - // references to it, though, since the creator of the object might - // have saved himself a reference. + // We can't assert that there are no outstanding ordinary references to + // it, though, since the creator of the object might have saved himself a + // reference. } _cow_object->_lock_status = CopyOnWriteObject::LS_locked_write; _cow_object->_locking_thread = current_thread; diff --git a/panda/src/putil/copyOnWritePointer.h b/panda/src/putil/copyOnWritePointer.h index 20e2f42f50..c40c432670 100644 --- a/panda/src/putil/copyOnWritePointer.h +++ b/panda/src/putil/copyOnWritePointer.h @@ -1,16 +1,15 @@ -// Filename: copyOnWritePointer.h -// Created by: drose (09Apr07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file copyOnWritePointer.h + * @author drose + * @date 2007-04-09 + */ #ifndef COPYONWRITEPOINTER_H #define COPYONWRITEPOINTER_H @@ -21,17 +20,14 @@ #include "pointerTo.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Class : CopyOnWritePointer -// Description : This safely stores the primary, owned pointer to a -// CopyOnWriteObject. At any time, you may call -// get_read_pointer() or get_write_pointer() to get a -// read-only or modifiable pointer to the object stored. -// -// There may be multiple copies of a CopyOnWritePointer -// which all refer to the same shared object. They will -// negotiate with each other properly. -//////////////////////////////////////////////////////////////////// +/** + * This safely stores the primary, owned pointer to a CopyOnWriteObject. At + * any time, you may call get_read_pointer() or get_write_pointer() to get a + * read-only or modifiable pointer to the object stored. + * + * There may be multiple copies of a CopyOnWritePointer which all refer to the + * same shared object. They will negotiate with each other properly. + */ class EXPCL_PANDA_PUTIL CopyOnWritePointer { public: INLINE CopyOnWritePointer(CopyOnWriteObject *object = NULL); @@ -70,16 +66,15 @@ private: }; -//////////////////////////////////////////////////////////////////// -// Class : CopyOnWritePointerTo -// Description : A template wrapper around the above class, mainly to -// handle the little typecasting niceties. -//////////////////////////////////////////////////////////////////// +/** + * A template wrapper around the above class, mainly to handle the little + * typecasting niceties. + */ template class CopyOnWritePointerTo : public CopyOnWritePointer { public: - // By hiding this template from interrogate, we improve compile-time - // speed and memory utilization. + // By hiding this template from interrogate, we improve compile-time speed + // and memory utilization. #ifndef CPPPARSER typedef T To; diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index 21d241d42b..c956fef4ac 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/panda/src/putil/datagramInputFile.I @@ -1,23 +1,19 @@ -// Filename: datagramInputFile.I -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramInputFile.I + * @author drose + * @date 2000-10-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramInputFile:: DatagramInputFile() { _error = false; @@ -27,32 +23,26 @@ DatagramInputFile() { _timestamp = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramInputFile:: ~DatagramInputFile() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::open -// Access: Published -// Description: Opens the indicated filename for reading. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for reading. Returns true on success, false + * on failure. + */ INLINE bool DatagramInputFile:: open(const Filename &filename) { return open(new FileReference(filename)); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_stream -// Access: Published -// Description: Returns the istream represented by the input file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the istream represented by the input file. + */ INLINE istream &DatagramInputFile:: get_stream() { static ifstream null_stream; diff --git a/panda/src/putil/datagramInputFile.cxx b/panda/src/putil/datagramInputFile.cxx index 0cfa5cbbe3..64fa369231 100644 --- a/panda/src/putil/datagramInputFile.cxx +++ b/panda/src/putil/datagramInputFile.cxx @@ -1,16 +1,15 @@ -// Filename: datagramInputFile.cxx -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramInputFile.cxx + * @author drose + * @date 2000-10-30 + */ #include "datagramInputFile.h" #include "temporaryFile.h" @@ -23,12 +22,10 @@ #include "streamReader.h" #include "thread.h" -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::open -// Access: Published -// Description: Opens the indicated filename for reading. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for reading. Returns true on success, false + * on failure. + */ bool DatagramInputFile:: open(const FileReference *file) { close(); @@ -51,15 +48,11 @@ open(const FileReference *file) { return _owns_in && !_in->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::open -// Access: Published -// Description: Starts reading from the indicated stream. Returns -// true on success, false on failure. The -// DatagramInputFile does not take ownership of the -// stream; you are responsible for closing or deleting -// it when you are done. -//////////////////////////////////////////////////////////////////// +/** + * Starts reading from the indicated stream. Returns true on success, false + * on failure. The DatagramInputFile does not take ownership of the stream; + * you are responsible for closing or deleting it when you are done. + */ bool DatagramInputFile:: open(istream &in, const Filename &filename) { close(); @@ -76,12 +69,10 @@ open(istream &in, const Filename &filename) { return !_in->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::close -// Access: Published -// Description: Closes the file. This is also implicitly done when -// the DatagramInputFile destructs. -//////////////////////////////////////////////////////////////////// +/** + * Closes the file. This is also implicitly done when the DatagramInputFile + * destructs. + */ void DatagramInputFile:: close() { _vfile.clear(); @@ -100,15 +91,12 @@ close() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::read_header -// Access: Published -// Description: Reads a sequence of bytes from the beginning of the -// datagram file. This may be called any number of -// times after the file has been opened and before the -// first datagram is read. It may not be called once -// the first datagram has been read. -//////////////////////////////////////////////////////////////////// +/** + * Reads a sequence of bytes from the beginning of the datagram file. This + * may be called any number of times after the file has been opened and before + * the first datagram is read. It may not be called once the first datagram + * has been read. + */ bool DatagramInputFile:: read_header(string &header, size_t num_bytes) { nassertr(!_read_first_datagram, false); @@ -127,13 +115,10 @@ read_header(string &header, size_t num_bytes) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_datagram -// Access: Published, Virtual -// Description: Reads the next datagram from the file. Returns true -// on success, false if there is an error or end of -// file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the next datagram from the file. Returns true on success, false if + * there is an error or end of file. + */ bool DatagramInputFile:: get_datagram(Datagram &data) { nassertr(_in != (istream *)NULL, false); @@ -147,8 +132,8 @@ get_datagram(Datagram &data) { } if (num_bytes_32 == 0) { - // A special case for a zero-length datagram: no need to try to - // read any data. + // A special case for a zero-length datagram: no need to try to read any + // data. data.clear(); return true; } @@ -159,15 +144,14 @@ get_datagram(Datagram &data) { num_bytes = reader.get_uint64(); } - // Make sure we have a reasonable datagram size for putting into - // memory. + // Make sure we have a reasonable datagram size for putting into memory. nassertr(num_bytes == (size_t)num_bytes, false); // Now, read the datagram itself. - // If the number of bytes is large, we will need to allocate a - // temporary buffer from the heap. Otherwise, we can get away with - // allocating it on the stack, via alloca(). + // If the number of bytes is large, we will need to allocate a temporary + // buffer from the heap. Otherwise, we can get away with allocating it on + // the stack, via alloca(). if (num_bytes > 65536) { char *buffer = (char *)PANDA_MALLOC_ARRAY(num_bytes); nassertr(buffer != (char *)NULL, false); @@ -199,19 +183,15 @@ get_datagram(Datagram &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::save_datagram -// Access: Published, Virtual -// Description: Skips over the next datagram without extracting it, -// but saves the relevant file information in the -// SubfileInfo object so that its data may be read -// later. For non-file-based datagram generators, this -// may mean creating a temporary file and copying the -// contents of the datagram to disk. -// -// Returns true on success, false on failure or if this -// method is unimplemented. -//////////////////////////////////////////////////////////////////// +/** + * Skips over the next datagram without extracting it, but saves the relevant + * file information in the SubfileInfo object so that its data may be read + * later. For non-file-based datagram generators, this may mean creating a + * temporary file and copying the contents of the datagram to disk. + * + * Returns true on success, false on failure or if this method is + * unimplemented. + */ bool DatagramInputFile:: save_datagram(SubfileInfo &info) { nassertr(_in != (istream *)NULL, false); @@ -230,8 +210,8 @@ save_datagram(SubfileInfo &info) { num_bytes = reader.get_uint64(); } - // If this stream is file-based, we can just point the SubfileInfo - // directly into this file. + // If this stream is file-based, we can just point the SubfileInfo directly + // into this file. if (_file != (FileReference *)NULL) { info = SubfileInfo(_file, _in->tellg(), num_bytes); _in->seekg(num_bytes, ios::cur); @@ -257,14 +237,14 @@ save_datagram(SubfileInfo &info) { streamsize num_remaining = num_bytes; static const size_t buffer_size = 4096; char buffer[buffer_size]; - + _in->read(buffer, min((streamsize)buffer_size, num_remaining)); streamsize count = _in->gcount(); while (count != 0) { out.write(buffer, count); if (out.fail()) { util_cat.error() - << "Couldn't write " << num_bytes << " bytes to " + << "Couldn't write " << num_bytes << " bytes to " << tfile->get_filename() << "\n"; return false; } @@ -286,24 +266,18 @@ save_datagram(SubfileInfo &info) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::is_eof -// Access: Published, Virtual -// Description: Returns true if the file has reached the end-of-file. -// This test may only be made after a call to -// read_header() or get_datagram() has failed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has reached the end-of-file. This test may only + * be made after a call to read_header() or get_datagram() has failed. + */ bool DatagramInputFile:: is_eof() { return _in != (istream *)NULL ? _in->eof() : true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::is_error -// Access: Published, Virtual -// Description: Returns true if the file has reached an error -// condition. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has reached an error condition. + */ bool DatagramInputFile:: is_error() { if (_in == (istream *)NULL) { @@ -316,66 +290,50 @@ is_error() { return _error; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_filename -// Access: Published, Virtual -// Description: Returns the filename that provides the source for -// these datagrams, if any, or empty string if the -// datagrams do not originate from a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that provides the source for these datagrams, if any, + * or empty string if the datagrams do not originate from a file on disk. + */ const Filename &DatagramInputFile:: get_filename() { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_timestamp -// Access: Published, Virtual -// Description: Returns the on-disk timestamp of the file that was -// read, at the time it was opened, if that is -// available, or 0 if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the on-disk timestamp of the file that was read, at the time it was + * opened, if that is available, or 0 if it is not. + */ time_t DatagramInputFile:: get_timestamp() const { return _timestamp; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_file -// Access: Published, Virtual -// Description: Returns the FileReference that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a file on disk. + */ const FileReference *DatagramInputFile:: get_file() { return _file; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_vfile -// Access: Published, Virtual -// Description: Returns the VirtualFile that provides the source for -// these datagrams, if any, or NULL if the datagrams do -// not originate from a VirtualFile. -//////////////////////////////////////////////////////////////////// +/** + * Returns the VirtualFile that provides the source for these datagrams, if + * any, or NULL if the datagrams do not originate from a VirtualFile. + */ VirtualFile *DatagramInputFile:: get_vfile() { return _vfile; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramInputFile::get_file_pos -// Access: Published, Virtual -// Description: Returns the current file position within the data -// stream, if any, or 0 if the file position is not -// meaningful or cannot be determined. -// -// For DatagramInputFiles that return a meaningful file -// position, this will be pointing to the first byte -// following the datagram returned after a call to -// get_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file position within the data stream, if any, or 0 if + * the file position is not meaningful or cannot be determined. + * + * For DatagramInputFiles that return a meaningful file position, this will be + * pointing to the first byte following the datagram returned after a call to + * get_datagram(). + */ streampos DatagramInputFile:: get_file_pos() { if (_in == (istream *)NULL) { diff --git a/panda/src/putil/datagramInputFile.h b/panda/src/putil/datagramInputFile.h index 9e6e900249..a8f8f67341 100644 --- a/panda/src/putil/datagramInputFile.h +++ b/panda/src/putil/datagramInputFile.h @@ -1,16 +1,15 @@ -// Filename: datagramInputFile.h -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramInputFile.h + * @author drose + * @date 2000-10-30 + */ #ifndef DATAGRAMINPUTFILE_H #define DATAGRAMINPUTFILE_H @@ -22,12 +21,10 @@ #include "fileReference.h" #include "virtualFile.h" -//////////////////////////////////////////////////////////////////// -// Class : DatagramInputFile -// Description : This class can be used to read a binary file that -// consists of an arbitrary header followed by a number -// of datagrams. -//////////////////////////////////////////////////////////////////// +/** + * This class can be used to read a binary file that consists of an arbitrary + * header followed by a number of datagrams. + */ class EXPCL_PANDA_PUTIL DatagramInputFile : public DatagramGenerator { PUBLISHED: INLINE DatagramInputFile(); diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index 2eefc85635..b3dbe95c9c 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/panda/src/putil/datagramOutputFile.I @@ -1,23 +1,19 @@ -// Filename: datagramOutputFile.I -// Created by: drose (27Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramOutputFile.I + * @author drose + * @date 2000-10-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramOutputFile:: DatagramOutputFile() { _error = false; @@ -26,32 +22,26 @@ DatagramOutputFile() { _owns_out = false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DatagramOutputFile:: ~DatagramOutputFile() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::open -// Access: Published -// Description: Opens the indicated filename for writing. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for writing. Returns true on success, false + * on failure. + */ INLINE bool DatagramOutputFile:: open(const Filename &filename) { return open(new FileReference(filename)); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::get_stream -// Access: Published -// Description: Returns the ostream represented by the output file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ostream represented by the output file. + */ INLINE ostream &DatagramOutputFile:: get_stream() { static ofstream null_stream; diff --git a/panda/src/putil/datagramOutputFile.cxx b/panda/src/putil/datagramOutputFile.cxx index d0e3187f35..4ead1274c1 100644 --- a/panda/src/putil/datagramOutputFile.cxx +++ b/panda/src/putil/datagramOutputFile.cxx @@ -1,28 +1,25 @@ -// Filename: datagramOutputFile.cxx -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramOutputFile.cxx + * @author drose + * @date 2000-10-30 + */ #include "datagramOutputFile.h" #include "streamWriter.h" #include "zStream.h" #include -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::open -// Access: Public -// Description: Opens the indicated filename for writing. Returns -// true if successful, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for writing. Returns true if successful, + * false on failure. + */ bool DatagramOutputFile:: open(const FileReference *file) { close(); @@ -44,15 +41,11 @@ open(const FileReference *file) { return _owns_out && !_out->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::open -// Access: Public -// Description: Starts writing to the indicated stream. Returns -// true on success, false on failure. The -// DatagramOutputFile does not take ownership of the -// stream; you are responsible for closing or deleting -// it when you are done. -//////////////////////////////////////////////////////////////////// +/** + * Starts writing to the indicated stream. Returns true on success, false on + * failure. The DatagramOutputFile does not take ownership of the stream; you + * are responsible for closing or deleting it when you are done. + */ bool DatagramOutputFile:: open(ostream &out, const Filename &filename) { close(); @@ -68,12 +61,10 @@ open(ostream &out, const Filename &filename) { return !_out->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::close -// Access: Public -// Description: Closes the file. This is also implicitly done when -// the DatagramOutputFile destructs. -//////////////////////////////////////////////////////////////////// +/** + * Closes the file. This is also implicitly done when the DatagramOutputFile + * destructs. + */ void DatagramOutputFile:: close() { _vfile.clear(); @@ -91,15 +82,12 @@ close() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::write_header -// Access: Public -// Description: Writes a sequence of bytes to the beginning of the -// datagram file. This may be called any number of -// times after the file has been opened and before the -// first datagram is written. It may not be called once -// the first datagram is written. -//////////////////////////////////////////////////////////////////// +/** + * Writes a sequence of bytes to the beginning of the datagram file. This may + * be called any number of times after the file has been opened and before the + * first datagram is written. It may not be called once the first datagram is + * written. + */ bool DatagramOutputFile:: write_header(const string &header) { nassertr(_out != (ostream *)NULL, false); @@ -110,12 +98,10 @@ write_header(const string &header) { return !_out->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::put_datagram -// Access: Public, Virtual -// Description: Writes the given datagram to the file. Returns true -// on success, false if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Writes the given datagram to the file. Returns true on success, false if + * there is an error. + */ bool DatagramOutputFile:: put_datagram(const Datagram &data) { nassertr(_out != (ostream *)NULL, false); @@ -140,18 +126,15 @@ put_datagram(const Datagram &data) { return !_out->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::copy_datagram -// Access: Published, Virtual -// Description: Copies the file data from the entire indicated -// file (via the vfs) as the next datagram. This is -// intended to support potentially very large datagrams. -// -// Returns true on success, false on failure or if this -// method is unimplemented. On true, fills "result" -// with the information that references the copied file, -// if possible. -//////////////////////////////////////////////////////////////////// +/** + * Copies the file data from the entire indicated file (via the vfs) as the + * next datagram. This is intended to support potentially very large + * datagrams. + * + * Returns true on success, false on failure or if this method is + * unimplemented. On true, fills "result" with the information that + * references the copied file, if possible. + */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const Filename &filename) { nassertr(_out != (ostream *)NULL, false); @@ -207,24 +190,20 @@ copy_datagram(SubfileInfo &result, const Filename &filename) { << "Truncated input stream.\n"; return false; } - + result = SubfileInfo(_file, start, size); return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::copy_datagram -// Access: Published, Virtual -// Description: Copies the file data from the range of the indicated -// file (outside of the vfs) as the next datagram. This -// is intended to support potentially very large -// datagrams. -// -// Returns true on success, false on failure or if this -// method is unimplemented. On true, fills "result" -// with the information that references the copied file, -// if possible. -//////////////////////////////////////////////////////////////////// +/** + * Copies the file data from the range of the indicated file (outside of the + * vfs) as the next datagram. This is intended to support potentially very + * large datagrams. + * + * Returns true on success, false on failure or if this method is + * unimplemented. On true, fills "result" with the information that + * references the copied file, if possible. + */ bool DatagramOutputFile:: copy_datagram(SubfileInfo &result, const SubfileInfo &source) { nassertr(_out != (ostream *)NULL, false); @@ -249,7 +228,7 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { static const size_t buffer_size = 4096; char buffer[buffer_size]; - + streampos start = _out->tellp(); in.seekg(source.get_start()); in.read(buffer, min((streamsize)buffer_size, num_remaining)); @@ -277,12 +256,9 @@ copy_datagram(SubfileInfo &result, const SubfileInfo &source) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::is_error -// Access: Public, Virtual -// Description: Returns true if the file has reached an error -// condition. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file has reached an error condition. + */ bool DatagramOutputFile:: is_error() { if (_out == (ostream *)NULL) { @@ -295,12 +271,10 @@ is_error() { return _error; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::flush -// Access: Public, Virtual -// Description: Ensures that all datagrams previously written will be -// visible in the output file. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that all datagrams previously written will be visible in the output + * file. + */ void DatagramOutputFile:: flush() { if (_out != (ostream *)NULL) { @@ -309,42 +283,32 @@ flush() { } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::get_filename -// Access: Published, Virtual -// Description: Returns the filename that provides the target for -// these datagrams, if any, or empty string if the -// datagrams do not get written to a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that provides the target for these datagrams, if any, + * or empty string if the datagrams do not get written to a file on disk. + */ const Filename &DatagramOutputFile:: get_filename() { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::get_file -// Access: Published, Virtual -// Description: Returns the FileReference that provides the target for -// these datagrams, if any, or NULL if the datagrams do -// not written to a file on disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FileReference that provides the target for these datagrams, if + * any, or NULL if the datagrams do not written to a file on disk. + */ const FileReference *DatagramOutputFile:: get_file() { return _file; } -//////////////////////////////////////////////////////////////////// -// Function: DatagramOutputFile::get_file_pos -// Access: Published, Virtual -// Description: Returns the current file position within the data -// stream, if any, or 0 if the file position is not -// meaningful or cannot be determined. -// -// For DatagramOutputFiles that return a meaningful file -// position, this will be pointing to the first byte -// following the datagram returned after a call to -// put_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current file position within the data stream, if any, or 0 if + * the file position is not meaningful or cannot be determined. + * + * For DatagramOutputFiles that return a meaningful file position, this will + * be pointing to the first byte following the datagram returned after a call + * to put_datagram(). + */ streampos DatagramOutputFile:: get_file_pos() { if (_out == (ostream *)NULL) { diff --git a/panda/src/putil/datagramOutputFile.h b/panda/src/putil/datagramOutputFile.h index a3a292bdba..d2013c75ee 100644 --- a/panda/src/putil/datagramOutputFile.h +++ b/panda/src/putil/datagramOutputFile.h @@ -1,16 +1,15 @@ -// Filename: datagramOutputFile.h -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file datagramOutputFile.h + * @author drose + * @date 2000-10-30 + */ #ifndef DATAGRAMOUTPUTFILE_H #define DATAGRAMOUTPUTFILE_H @@ -24,12 +23,10 @@ #include "virtualFileSystem.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Class : DatagramOutputFile -// Description : This class can be used to write a binary file that -// consists of an arbitrary header followed by a number -// of datagrams. -//////////////////////////////////////////////////////////////////// +/** + * This class can be used to write a binary file that consists of an arbitrary + * header followed by a number of datagrams. + */ class EXPCL_PANDA_PUTIL DatagramOutputFile : public DatagramSink { public: INLINE DatagramOutputFile(); diff --git a/panda/src/putil/doubleBitMask.I b/panda/src/putil/doubleBitMask.I index 790fb1c744..6d21ad2ffb 100644 --- a/panda/src/putil/doubleBitMask.I +++ b/panda/src/putil/doubleBitMask.I @@ -1,35 +1,30 @@ -// Filename: doubleBitMask.I -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file doubleBitMask.I + * @author drose + * @date 2000-06-08 + */ template TypeHandle DoubleBitMask::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask:: DoubleBitMask() { } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask:: DoubleBitMask(const DoubleBitMask ©) : @@ -38,11 +33,9 @@ DoubleBitMask(const DoubleBitMask ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask &DoubleBitMask:: operator = (const DoubleBitMask ©) { @@ -51,11 +44,9 @@ operator = (const DoubleBitMask ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Named all_on constructor -// Access: Published, Static -// Description: Returns a DoubleBitMask whose bits are all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DoubleBitMask whose bits are all on. + */ template INLINE DoubleBitMask DoubleBitMask:: all_on() { @@ -65,11 +56,9 @@ all_on() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Named all_on constructor -// Access: Published, Static -// Description: Returns a DoubleBitMask whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DoubleBitMask whose bits are all off. + */ template INLINE DoubleBitMask DoubleBitMask:: all_off() { @@ -79,11 +68,9 @@ all_off() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Named lower_on constructor -// Access: Published, Static -// Description: Returns a DoubleBitMask whose lower on_bits bits are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DoubleBitMask whose lower on_bits bits are on. + */ template INLINE DoubleBitMask DoubleBitMask:: lower_on(int on_bits) { @@ -102,11 +89,9 @@ lower_on(int on_bits) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Named bit constructor -// Access: Published, Static -// Description: Returns a DoubleBitMask with only the indicated bit on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DoubleBitMask with only the indicated bit on. + */ template INLINE DoubleBitMask DoubleBitMask:: bit(int index) { @@ -115,12 +100,9 @@ bit(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Named range constructor -// Access: Published, Static -// Description: Returns a DoubleBitMask whose size bits, beginning at -// low_bit, are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a DoubleBitMask whose size bits, beginning at low_bit, are on. + */ template INLINE DoubleBitMask DoubleBitMask:: range(int low_bit, int size) { @@ -129,72 +111,56 @@ range(int low_bit, int size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask:: ~DoubleBitMask() { } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::has_max_num_bits -// Access: Published, Static -// Description: Returns true if there is a maximum number of bits -// that may be stored in this structure, false -// otherwise. If this returns true, the number may be -// queried in get_max_num_bits(). -// -// This method always returns true. This method is -// defined so generic programming algorithms can use -// DoubleBitMask or BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a maximum number of bits that may be stored in + * this structure, false otherwise. If this returns true, the number may be + * queried in get_max_num_bits(). + * + * This method always returns true. This method is defined so generic + * programming algorithms can use DoubleBitMask or BitArray interchangeably. + */ template CONSTEXPR bool DoubleBitMask:: has_max_num_bits() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_max_num_bits -// Access: Published, Static -// Description: If get_max_num_bits() returned true, this method may -// be called to return the maximum number of bits that -// may be stored in this structure. It is an error to -// call this if get_max_num_bits() return false. -// -// It is never an error to call this method. This -// returns the same thing as get_num_bits(). This -// method is defined so generic programming algorithms -// can use DoubleBitMask or BitArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * If get_max_num_bits() returned true, this method may be called to return + * the maximum number of bits that may be stored in this structure. It is an + * error to call this if get_max_num_bits() return false. + * + * It is never an error to call this method. This returns the same thing as + * get_num_bits(). This method is defined so generic programming algorithms + * can use DoubleBitMask or BitArray interchangeably. + */ template CONSTEXPR int DoubleBitMask:: get_max_num_bits() { return num_bits; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_num_bits -// Access: Published, Static -// Description: Returns the number of bits available to set in the -// doubleBitMask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits available to set in the doubleBitMask. + */ template CONSTEXPR int DoubleBitMask:: get_num_bits() { return num_bits; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. index must be in the range [0, -// num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. index must be + * in the range [0, num_bits). + */ template INLINE bool DoubleBitMask:: get_bit(int index) const { @@ -205,12 +171,9 @@ get_bit(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::set_bit -// Access: Published -// Description: Sets the nth bit on. index must be in the range -// [0, num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. index must be in the range [0, num_bits). + */ template INLINE void DoubleBitMask:: set_bit(int index) { @@ -221,12 +184,9 @@ set_bit(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::clear_bit -// Access: Published -// Description: Sets the nth bit off. index must be in the range -// [0, num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. index must be in the range [0, num_bits). + */ template INLINE void DoubleBitMask:: clear_bit(int index) { @@ -237,13 +197,10 @@ clear_bit(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::set_bit_to -// Access: Published -// Description: Sets the nth bit either on or off, according to the -// indicated bool value. index must be in the range [0, -// num_bits). -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit either on or off, according to the indicated bool value. + * index must be in the range [0, num_bits). + */ template INLINE void DoubleBitMask:: set_bit_to(int index, bool value) { @@ -254,37 +211,28 @@ set_bit_to(int index, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::is_zero -// Access: Published -// Description: Returns true if the entire doubleBitMask is zero, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire doubleBitMask is zero, false otherwise. + */ template INLINE bool DoubleBitMask:: is_zero() const { return (_lo.is_zero() && _hi.is_zero()); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::is_all_on -// Access: Published -// Description: Returns true if the entire doubleBitMask is one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire doubleBitMask is one, false otherwise. + */ template INLINE bool DoubleBitMask:: is_all_on() const { return (_lo.is_all_on() && _hi.is_all_on()); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::extract -// Access: Published -// Description: Returns a word that represents only the indicated -// range of bits within this DoubleBitMask, shifted to the -// least-significant position. -//////////////////////////////////////////////////////////////////// +/** + * Returns a word that represents only the indicated range of bits within this + * DoubleBitMask, shifted to the least-significant position. + */ template INLINE TYPENAME DoubleBitMask::WordType DoubleBitMask:: extract(int low_bit, int size) const { @@ -300,12 +248,10 @@ extract(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::store -// Access: Published -// Description: Stores the indicated word into the indicated range of -// bits with this DoubleBitMask. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated word into the indicated range of bits with this + * DoubleBitMask. + */ template INLINE void DoubleBitMask:: store(WordType value, int low_bit, int size) { @@ -322,12 +268,9 @@ store(WordType value, int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::has_any_of -// Access: Published -// Description: Returns true if any bit in the indicated range is -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any bit in the indicated range is set, false otherwise. + */ template INLINE bool DoubleBitMask:: has_any_of(int low_bit, int size) const { @@ -343,12 +286,9 @@ has_any_of(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::has_all_of -// Access: Published -// Description: Returns true if all bits in the indicated range are -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all bits in the indicated range are set, false otherwise. + */ template INLINE bool DoubleBitMask:: has_all_of(int low_bit, int size) const { @@ -364,11 +304,9 @@ has_all_of(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::set_range -// Access: Published -// Description: Sets the indicated range of bits on. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits on. + */ template INLINE void DoubleBitMask:: set_range(int low_bit, int size) { @@ -385,11 +323,9 @@ set_range(int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::clear_range -// Access: Published -// Description: Sets the indicated range of bits off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits off. + */ template INLINE void DoubleBitMask:: clear_range(int low_bit, int size) { @@ -406,11 +342,9 @@ clear_range(int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::set_range_to -// Access: Published -// Description: Sets the indicated range of bits to either on or off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits to either on or off. + */ template INLINE void DoubleBitMask:: set_range_to(bool value, int low_bit, int size) { @@ -421,36 +355,28 @@ set_range_to(bool value, int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_num_on_bits -// Access: Published -// Description: Returns the number of bits that are set to 1 in the -// mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 1 in the mask. + */ template INLINE int DoubleBitMask:: get_num_on_bits() const { return _lo.get_num_on_bits() + _hi.get_num_on_bits(); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_num_off_bits -// Access: Published -// Description: Returns the number of bits that are set to 0 in the -// mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 0 in the mask. + */ template INLINE int DoubleBitMask:: get_num_off_bits() const { return _lo.get_num_off_bits() + _hi.get_num_off_bits(); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_lowest_on_bit -// Access: Published -// Description: Returns the index of the lowest 1 bit in the mask. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the mask. Returns -1 if there are + * no 1 bits. + */ template INLINE int DoubleBitMask:: get_lowest_on_bit() const { @@ -464,12 +390,10 @@ get_lowest_on_bit() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_lowest_off_bit -// Access: Published -// Description: Returns the index of the lowest 0 bit in the mask. -// Returns -1 if there are no 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 0 bit in the mask. Returns -1 if there are + * no 0 bits. + */ template INLINE int DoubleBitMask:: get_lowest_off_bit() const { @@ -483,12 +407,10 @@ get_lowest_off_bit() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_highest_on_bit -// Access: Published -// Description: Returns the index of the highest 1 bit in the mask. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the mask. Returns -1 if there + * are no 1 bits. + */ template INLINE int DoubleBitMask:: get_highest_on_bit() const { @@ -501,12 +423,10 @@ get_highest_on_bit() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_highest_off_bit -// Access: Published -// Description: Returns the index of the highest 0 bit in the mask. -// Returns -1 if there are no 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 0 bit in the mask. Returns -1 if there + * are no 0 bits. + */ template INLINE int DoubleBitMask:: get_highest_off_bit() const { @@ -519,17 +439,13 @@ get_highest_off_bit() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::get_next_higher_different_bit -// Access: Published -// Description: Returns the index of the next bit in the mask, above -// low_bit, whose value is different that the value of -// low_bit. Returns low_bit again if all bits higher -// than low_bit have the same value. -// -// This can be used to quickly iterate through all of -// the bits in the mask. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the next bit in the mask, above low_bit, whose value + * is different that the value of low_bit. Returns low_bit again if all bits + * higher than low_bit have the same value. + * + * This can be used to quickly iterate through all of the bits in the mask. + */ template INLINE int DoubleBitMask:: get_next_higher_different_bit(int low_bit) const { @@ -551,12 +467,10 @@ get_next_higher_different_bit(int low_bit) const { return result + half_bits; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::invert_in_place -// Access: Published -// Description: Inverts all the bits in the DoubleBitMask. This is -// equivalent to mask = ~mask. -//////////////////////////////////////////////////////////////////// +/** + * Inverts all the bits in the DoubleBitMask. This is equivalent to mask = + * ~mask. + */ template INLINE void DoubleBitMask:: invert_in_place() { @@ -564,29 +478,24 @@ invert_in_place() { _hi.invert_in_place(); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::has_bits_in_common -// Access: Published -// Description: Returns true if this DoubleBitMask has any "one" bits in -// common with the other one, false otherwise. -// -// This is equivalent to (mask & other) != 0, but may be -// faster. (Actually, it should only be faster in the -// BitArray case, but this method is provided for the -// benefit of generic programming algorithms). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this DoubleBitMask has any "one" bits in common with the + * other one, false otherwise. + * + * This is equivalent to (mask & other) != 0, but may be faster. (Actually, + * it should only be faster in the BitArray case, but this method is provided + * for the benefit of generic programming algorithms). + */ template INLINE bool DoubleBitMask:: has_bits_in_common(const DoubleBitMask &other) const { - return _lo.has_bits_in_common(other._lo) || + return _lo.has_bits_in_common(other._lo) || _hi.has_bits_in_common(other._hi); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::clear -// Access: Published -// Description: Sets all the bits in the DoubleBitMask off. -//////////////////////////////////////////////////////////////////// +/** + * Sets all the bits in the DoubleBitMask off. + */ template INLINE void DoubleBitMask:: clear() { @@ -594,24 +503,20 @@ clear() { _hi.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::output -// Access: Published -// Description: Writes the DoubleBitMask out as a binary or a hex number, -// according to the number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the DoubleBitMask out as a binary or a hex number, according to the + * number of bits. + */ template void DoubleBitMask:: output(ostream &out) const { output_hex(out); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::output_binary -// Access: Published -// Description: Writes the DoubleBitMask out as a binary number, with -// spaces every four bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the DoubleBitMask out as a binary number, with spaces every four + * bits. + */ template void DoubleBitMask:: output_binary(ostream &out, int spaces_every) const { @@ -620,12 +525,10 @@ output_binary(ostream &out, int spaces_every) const { _lo.output_binary(out); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::output_hex -// Access: Published -// Description: Writes the DoubleBitMask out as a hexadecimal number, with -// spaces every four digits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the DoubleBitMask out as a hexadecimal number, with spaces every + * four digits. + */ template void DoubleBitMask:: output_hex(ostream &out, int spaces_every) const { @@ -634,51 +537,41 @@ output_hex(ostream &out, int spaces_every) const { _lo.output_hex(out); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::write -// Access: Published -// Description: Writes the DoubleBitMask out as a binary or a hex number, -// according to the number of bits. -//////////////////////////////////////////////////////////////////// +/** + * Writes the DoubleBitMask out as a binary or a hex number, according to the + * number of bits. + */ template void DoubleBitMask:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool DoubleBitMask:: operator == (const DoubleBitMask &other) const { return _lo == other._lo && _hi == other._hi; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE bool DoubleBitMask:: operator != (const DoubleBitMask &other) const { return _lo != other._lo && _hi != other._hi; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator < -// Access: Published -// Description: The ordering operator is of limited usefulness with a -// DoubleBitMask, however, it has a definition which places -// all unique DoubleBitMasks into a unique ordering. It may -// be useful when defining ordered STL containers of -// DoubleBitMasks, for instance; and it's required in order to -// export any STL container (ordered or unordered) of -// DoubleBitMask under Windows. -//////////////////////////////////////////////////////////////////// +/** + * The ordering operator is of limited usefulness with a DoubleBitMask, + * however, it has a definition which places all unique DoubleBitMasks into a + * unique ordering. It may be useful when defining ordered STL containers of + * DoubleBitMasks, for instance; and it's required in order to export any STL + * container (ordered or unordered) of DoubleBitMask under Windows. + */ template INLINE bool DoubleBitMask:: operator < (const DoubleBitMask &other) const { @@ -689,14 +582,12 @@ operator < (const DoubleBitMask &other) const { return _lo < other._lo; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::compare_to -// Access: Published -// Description: Returns a number less than zero if this DoubleBitMask sorts -// before the indicated other DoubleBitMask, greater than zero -// if it sorts after, or 0 if they are equivalent. This -// is based on the same ordering defined by operator <. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this DoubleBitMask sorts before the + * indicated other DoubleBitMask, greater than zero if it sorts after, or 0 if + * they are equivalent. This is based on the same ordering defined by + * operator <. + */ template INLINE int DoubleBitMask:: compare_to(const DoubleBitMask &other) const { @@ -707,11 +598,9 @@ compare_to(const DoubleBitMask &other) const { return _lo.compare_to(other._lo); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator & -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator & (const DoubleBitMask &other) const { @@ -720,11 +609,9 @@ operator & (const DoubleBitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator | -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator | (const DoubleBitMask &other) const { @@ -733,11 +620,9 @@ operator | (const DoubleBitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator ^ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator ^ (const DoubleBitMask &other) const { @@ -746,11 +631,9 @@ operator ^ (const DoubleBitMask &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator ~ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator ~ () const { @@ -759,11 +642,9 @@ operator ~ () const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator << -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator << (int shift) const { @@ -772,11 +653,9 @@ operator << (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator >> -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE DoubleBitMask DoubleBitMask:: operator >> (int shift) const { @@ -785,11 +664,9 @@ operator >> (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator &= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DoubleBitMask:: operator &= (const DoubleBitMask &other) { @@ -797,11 +674,9 @@ operator &= (const DoubleBitMask &other) { _hi &= other._hi; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator |= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DoubleBitMask:: operator |= (const DoubleBitMask &other) { @@ -809,11 +684,9 @@ operator |= (const DoubleBitMask &other) { _hi |= other._hi; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator ^= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DoubleBitMask:: operator ^= (const DoubleBitMask &other) { @@ -821,11 +694,9 @@ operator ^= (const DoubleBitMask &other) { _hi ^= other._hi; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator <<= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DoubleBitMask:: operator <<= (int shift) { @@ -833,11 +704,9 @@ operator <<= (int shift) { _lo <<= shift; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::operator >>= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void DoubleBitMask:: operator >>= (int shift) { @@ -845,11 +714,9 @@ operator >>= (int shift) { _hi >>= shift; } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::generate_hash -// Access: Public -// Description: Adds the doubleBitMask to the indicated hash generator. -//////////////////////////////////////////////////////////////////// +/** + * Adds the doubleBitMask to the indicated hash generator. + */ template INLINE void DoubleBitMask:: generate_hash(ChecksumHashGenerator &hashgen) const { @@ -857,11 +724,9 @@ generate_hash(ChecksumHashGenerator &hashgen) const { _lo.generate_hash(hashgen); } -//////////////////////////////////////////////////////////////////// -// Function: DoubleBitMask::init_type -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void DoubleBitMask:: init_type() { diff --git a/panda/src/putil/doubleBitMask.cxx b/panda/src/putil/doubleBitMask.cxx index 81fab4f3b2..7d68b48dbe 100644 --- a/panda/src/putil/doubleBitMask.cxx +++ b/panda/src/putil/doubleBitMask.cxx @@ -1,16 +1,15 @@ -// Filename: doubleBitMask.cxx -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file doubleBitMask.cxx + * @author drose + * @date 2000-06-08 + */ #include "doubleBitMask.h" diff --git a/panda/src/putil/doubleBitMask.h b/panda/src/putil/doubleBitMask.h index fd627159d6..3b3f521ec2 100644 --- a/panda/src/putil/doubleBitMask.h +++ b/panda/src/putil/doubleBitMask.h @@ -1,16 +1,15 @@ -// Filename: doubleBitMask.h -// Created by: drose (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file doubleBitMask.h + * @author drose + * @date 2000-06-08 + */ #ifndef DOUBLEBITMASK_H #define DOUBLEBITMASK_H @@ -19,15 +18,12 @@ #include "bitMask.h" -//////////////////////////////////////////////////////////////////// -// Class : DoubleBitMask -// Description : This is a special BitMask type that is implemented as -// a pair of lesser BitMask types, to present a -// double-wide bit mask. For instance, on a 32-bit -// system, this can be used to make a single 64-bit bit -// mask. More of these can be ganged up together to -// make a 128-bit mask, and so on. -//////////////////////////////////////////////////////////////////// +/** + * This is a special BitMask type that is implemented as a pair of lesser + * BitMask types, to present a double-wide bit mask. For instance, on a + * 32-bit system, this can be used to make a single 64-bit bit mask. More of + * these can be ganged up together to make a 128-bit mask, and so on. + */ template class DoubleBitMask { public: diff --git a/panda/src/putil/drawMask.h b/panda/src/putil/drawMask.h index 76f0038808..1137b4b592 100644 --- a/panda/src/putil/drawMask.h +++ b/panda/src/putil/drawMask.h @@ -1,16 +1,15 @@ -// Filename: drawMask.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file drawMask.h + * @author drose + * @date 2002-03-13 + */ #ifndef DRAWMASK_H #define DRAWMASK_H @@ -20,11 +19,9 @@ #include "bitMask.h" // This is the data type of the draw mask: the set of bits that every -// PandaNode has, as well as a Camera, and that a node must have at -// least some bits in common with the current Camera in order to be -// visible. +// PandaNode has, as well as a Camera, and that a node must have at least some +// bits in common with the current Camera in order to be visible. typedef BitMask32 DrawMask; #endif - diff --git a/panda/src/putil/factory.I b/panda/src/putil/factory.I index 445cf1696d..37da03c686 100644 --- a/panda/src/putil/factory.I +++ b/panda/src/putil/factory.I @@ -1,77 +1,63 @@ -// Filename: factory.I -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factory.I + * @author drose + * @date 2000-05-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: Factory::make_instance -// Access: Public -// Description: Attempts to create a new instance of some class of -// the indicated type, or some derivative if necessary. -// If an instance of the exact type cannot be created, -// the specified preferred will specify which derived -// class will be preferred. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a new instance of some class of the indicated type, or + * some derivative if necessary. If an instance of the exact type cannot be + * created, the specified preferred will specify which derived class will be + * preferred. + */ template INLINE Type *Factory:: make_instance(TypeHandle handle, const FactoryParams ¶ms) { return (Type *)FactoryBase::make_instance(handle, params); } -//////////////////////////////////////////////////////////////////// -// Function: Factory::make_instance -// Access: Public -// Description: Attempts to create a new instance of some class of -// the indicated type, or some derivative if necessary. -// If an instance of the exact type cannot be created, -// the specified preferred will specify which derived -// class will be preferred. -// -// This flavor of make_instance() accepts a string name -// that indicates the desired type. It must be the name -// of some already-registered type. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a new instance of some class of the indicated type, or + * some derivative if necessary. If an instance of the exact type cannot be + * created, the specified preferred will specify which derived class will be + * preferred. + * + * This flavor of make_instance() accepts a string name that indicates the + * desired type. It must be the name of some already-registered type. + */ template INLINE Type *Factory:: make_instance(const string &type_name, const FactoryParams ¶ms) { return (Type *)FactoryBase::make_instance(type_name, params); } -//////////////////////////////////////////////////////////////////// -// Function: Factory::make_instance_more_general -// Access: Public -// Description: Attempts to create an instance of the type requested, -// or some base type of the type requested. Returns the -// new instance created, or NULL if the instance could -// not be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of the type requested, or some base type of + * the type requested. Returns the new instance created, or NULL if the + * instance could not be created. + */ template INLINE Type *Factory:: make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { return (Type *)FactoryBase::make_instance_more_general(handle, params); } -//////////////////////////////////////////////////////////////////// -// Function: Factory::make_instance_more_general -// Access: Public -// Description: Attempts to create an instance of the type requested, -// or some base type of the type requested. Returns the -// new instance created, or NULL if the instance could -// not be created. -// -// This flavor of make_instance_more_general() accepts a -// string name that indicates the desired type. It must -// be the name of some already-registered type. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of the type requested, or some base type of + * the type requested. Returns the new instance created, or NULL if the + * instance could not be created. + * + * This flavor of make_instance_more_general() accepts a string name that + * indicates the desired type. It must be the name of some already-registered + * type. + */ template INLINE Type *Factory:: make_instance_more_general(const string &type_name, @@ -79,12 +65,9 @@ make_instance_more_general(const string &type_name, return (Type *)FactoryBase::make_instance_more_general(type_name, params); } -//////////////////////////////////////////////////////////////////// -// Function: Factory::register_factory -// Access: Public -// Description: Registers a new kind of thing the Factory will be -// able to create. -//////////////////////////////////////////////////////////////////// +/** + * Registers a new kind of thing the Factory will be able to create. + */ template INLINE void Factory:: register_factory(TypeHandle handle, CreateFunc *func) { diff --git a/panda/src/putil/factory.h b/panda/src/putil/factory.h index 5db8fa2349..f45f1ffce3 100644 --- a/panda/src/putil/factory.h +++ b/panda/src/putil/factory.h @@ -1,16 +1,15 @@ -// Filename: factory.h -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factory.h + * @author drose + * @date 2000-05-08 + */ #ifndef FACTORY_H #define FACTORY_H @@ -19,24 +18,18 @@ #include "factoryBase.h" -//////////////////////////////////////////////////////////////////// -// Class : Factory -// Description : A Factory can be used to create an instance of a -// particular subclass of some general base class. Each -// subclass registers itself with the Factory, supplying -// a function that will construct an instance of that -// subclass; the Factory can later choose a suitable -// subclass and return a newly-constructed pointer to an -// object of that type on the user's demand. This is -// used, for instance, to manage the set of -// GraphicsPipes available to the user. -// -// This is a thin template wrapper around FactoryBase. -// All it does is ensure the types are correctly cast. -// All of its methods are inline, and it has no data -// members, so it is not necessary to export the class -// from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * A Factory can be used to create an instance of a particular subclass of + * some general base class. Each subclass registers itself with the Factory, + * supplying a function that will construct an instance of that subclass; the + * Factory can later choose a suitable subclass and return a newly-constructed + * pointer to an object of that type on the user's demand. This is used, for + * instance, to manage the set of GraphicsPipes available to the user. + * + * This is a thin template wrapper around FactoryBase. All it does is ensure + * the types are correctly cast. All of its methods are inline, and it has no + * data members, so it is not necessary to export the class from the DLL. + */ template class Factory : public FactoryBase { public: @@ -62,4 +55,3 @@ public: #include "factory.I" #endif - diff --git a/panda/src/putil/factoryBase.I b/panda/src/putil/factoryBase.I index 8c1230536b..3452a9758c 100644 --- a/panda/src/putil/factoryBase.I +++ b/panda/src/putil/factoryBase.I @@ -1,31 +1,25 @@ -// Filename: factoryBase.I -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryBase.I + * @author drose + * @date 2000-05-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance -// Access: Public -// Description: Attempts to create a new instance of some class of -// the indicated type, or some derivative if necessary. -// If an instance of the exact type cannot be created, -// the specified priorities will specify which derived -// class will be preferred. -// -// This flavor of make_instance() accepts a string name -// that indicates the desired type. It must be the name -// of some already-registered type. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a new instance of some class of the indicated type, or + * some derivative if necessary. If an instance of the exact type cannot be + * created, the specified priorities will specify which derived class will be + * preferred. + * + * This flavor of make_instance() accepts a string name that indicates the + * desired type. It must be the name of some already-registered type. + */ INLINE TypedObject *FactoryBase:: make_instance(const string &type_name, const FactoryParams ¶ms) { TypeHandle handle = TypeRegistry::ptr()->find_type(type_name); @@ -35,18 +29,15 @@ make_instance(const string &type_name, const FactoryParams ¶ms) { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance_more_general -// Access: Public -// Description: Attempts to create an instance of the type requested, -// or some base type of the type requested. Returns the -// new instance created, or NULL if the instance could -// not be created. -// -// This flavor of make_instance_more_general() accepts a -// string name that indicates the desired type. It must -// be the name of some already-registered type. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of the type requested, or some base type of + * the type requested. Returns the new instance created, or NULL if the + * instance could not be created. + * + * This flavor of make_instance_more_general() accepts a string name that + * indicates the desired type. It must be the name of some already-registered + * type. + */ INLINE TypedObject *FactoryBase:: make_instance_more_general(const string &type_name, const FactoryParams ¶ms) { @@ -55,4 +46,3 @@ make_instance_more_general(const string &type_name, return make_instance_more_general(handle, params); } - diff --git a/panda/src/putil/factoryBase.cxx b/panda/src/putil/factoryBase.cxx index 7977f3db45..935ad7bb33 100644 --- a/panda/src/putil/factoryBase.cxx +++ b/panda/src/putil/factoryBase.cxx @@ -1,48 +1,40 @@ -// Filename: factoryBase.cxx -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryBase.cxx + * @author drose + * @date 2000-05-08 + */ #include "factoryBase.h" #include "indent.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FactoryBase:: FactoryBase() { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FactoryBase:: ~FactoryBase() { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance -// Access: Public -// Description: Attempts to create a new instance of some class of -// the indicated type, or some derivative if necessary. -// If an instance of the exact type cannot be created, -// the specified preferred will specify which derived -// class will be preferred. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create a new instance of some class of the indicated type, or + * some derivative if necessary. If an instance of the exact type cannot be + * created, the specified preferred will specify which derived class will be + * preferred. + */ TypedObject *FactoryBase:: make_instance(TypeHandle handle, const FactoryParams ¶ms) { TypedObject *instance = (TypedObject *)NULL; @@ -66,21 +58,18 @@ make_instance(TypeHandle handle, const FactoryParams ¶ms) { return instance; } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance_more_general -// Access: Public -// Description: Attempts to create an instance of the type requested, -// or some base type of the type requested. Returns the -// new instance created, or NULL if the instance could -// not be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of the type requested, or some base type of + * the type requested. Returns the new instance created, or NULL if the + * instance could not be created. + */ TypedObject *FactoryBase:: make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { TypedObject *object = make_instance_exact(handle, params); if (object == (TypedObject *)NULL) { - // Recursively search through the entire inheritance tree until we - // find something we know about. + // Recursively search through the entire inheritance tree until we find + // something we know about. if (handle.get_num_parent_classes() == 0) { return NULL; } @@ -105,16 +94,12 @@ make_instance_more_general(TypeHandle handle, const FactoryParams ¶ms) { return object; } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::find_registered_type -// Access: Public -// Description: Returns the TypeHandle given, if it is a registered -// type, or if it is not registered, searches for the -// nearest ancestor of the indicated type that is -// registered and returns it. If no ancestor of the -// indicated type is registered, returns -// TypeHandle::none(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle given, if it is a registered type, or if it is not + * registered, searches for the nearest ancestor of the indicated type that is + * registered and returns it. If no ancestor of the indicated type is + * registered, returns TypeHandle::none(). + */ TypeHandle FactoryBase:: find_registered_type(TypeHandle handle) { Creators::const_iterator ci = _creators.find(handle); @@ -123,8 +108,8 @@ find_registered_type(TypeHandle handle) { return handle; } - // Recursively search through the entire inheritance tree until we - // find something we know about. + // Recursively search through the entire inheritance tree until we find + // something we know about. if (handle.get_num_parent_classes() == 0) { return TypeHandle::none(); } @@ -141,12 +126,9 @@ find_registered_type(TypeHandle handle) { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::register_factory -// Access: Public -// Description: Registers a new kind of thing the Factory will be -// able to create. -//////////////////////////////////////////////////////////////////// +/** + * Registers a new kind of thing the Factory will be able to create. + */ void FactoryBase:: register_factory(TypeHandle handle, BaseCreateFunc *func) { nassertv(handle != TypeHandle::none()); @@ -154,26 +136,19 @@ register_factory(TypeHandle handle, BaseCreateFunc *func) { _creators[handle] = func; } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::get_num_types -// Access: Public -// Description: Returns the number of different types the Factory -// knows how to create. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different types the Factory knows how to create. + */ int FactoryBase:: get_num_types() const { return _creators.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::get_type -// Access: Public -// Description: Returns the nth type the Factory knows how to create. -// This is not a terribly efficient function; it's -// included primarily for debugging output. Normally -// you wouldn't need to traverse the list of the -// Factory's types. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth type the Factory knows how to create. This is not a + * terribly efficient function; it's included primarily for debugging output. + * Normally you wouldn't need to traverse the list of the Factory's types. + */ TypeHandle FactoryBase:: get_type(int n) const { nassertr(n >= 0 && n < get_num_types(), TypeHandle::none()); @@ -190,60 +165,46 @@ get_type(int n) const { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::clear_preferred -// Access: Public -// Description: Empties the list of preferred types. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of preferred types. + */ void FactoryBase:: clear_preferred() { _preferred.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::add_preferred -// Access: Public -// Description: Adds the indicated type to the end of the list of -// preferred types. On the next call to -// make_instance(), if the exact type requested cannot -// be created, the preferred types are first tried in -// the order specified. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated type to the end of the list of preferred types. On the + * next call to make_instance(), if the exact type requested cannot be + * created, the preferred types are first tried in the order specified. + */ void FactoryBase:: add_preferred(TypeHandle handle) { nassertv(handle != TypeHandle::none()); _preferred.push_back(handle); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::get_num_preferred -// Access: Public -// Description: Returns the number of types added to the -// preferred-type list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of types added to the preferred-type list. + */ int FactoryBase:: get_num_preferred() const { return _preferred.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::get_preferred -// Access: Public -// Description: Returns the nth type added to the preferred-type -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth type added to the preferred-type list. + */ TypeHandle FactoryBase:: get_preferred(int n) const { nassertr(n >= 0 && n < get_num_preferred(), TypeHandle::none()); return _preferred[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::write_types -// Access: Public -// Description: Writes a list of all known types the Factory can -// create to the indicated output stream, one per line. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of all known types the Factory can create to the indicated + * output stream, one per line. + */ void FactoryBase:: write_types(ostream &out, int indent_level) const { Creators::const_iterator ci; @@ -253,32 +214,25 @@ write_types(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::Copy Constructor -// Access: Private -// Description: Don't copy Factories. -//////////////////////////////////////////////////////////////////// +/** + * Don't copy Factories. + */ FactoryBase:: FactoryBase(const FactoryBase &) { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::Copy Assignment Operator -// Access: Private -// Description: Don't copy Factories. -//////////////////////////////////////////////////////////////////// +/** + * Don't copy Factories. + */ void FactoryBase:: operator = (const FactoryBase &) { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance_exact -// Access: Private -// Description: Attempts to create an instance of the exact type -// requested by the given handle. Returns the new -// instance created, or NULL if the instance could not -// be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of the exact type requested by the given + * handle. Returns the new instance created, or NULL if the instance could + * not be created. + */ TypedObject *FactoryBase:: make_instance_exact(TypeHandle handle, const FactoryParams ¶ms) { Creators::const_iterator ci = _creators.find(handle); @@ -291,18 +245,15 @@ make_instance_exact(TypeHandle handle, const FactoryParams ¶ms) { return (*func)(params); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryBase::make_instance_more_specific -// Access: Private -// Description: Attempts to create an instance of some derived type -// of the type requested by the given handle. Returns -// the new instance created, or NULL if the instance -// could not be created. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to create an instance of some derived type of the type requested + * by the given handle. Returns the new instance created, or NULL if the + * instance could not be created. + */ TypedObject *FactoryBase:: make_instance_more_specific(TypeHandle handle, const FactoryParams ¶ms) { - // First, walk through the established preferred list. Maybe one - // of these qualifies. + // First, walk through the established preferred list. Maybe one of these + // qualifies. Preferred::const_iterator pi; for (pi = _preferred.begin(); pi != _preferred.end(); ++pi) { @@ -315,9 +266,8 @@ make_instance_more_specific(TypeHandle handle, const FactoryParams ¶ms) { } } - // No, we couldn't create anything on the preferred list, so create - // the first thing we know about that derives from the indicated - // type. + // No, we couldn't create anything on the preferred list, so create the + // first thing we know about that derives from the indicated type. Creators::const_iterator ci; for (ci = _creators.begin(); ci != _creators.end(); ++ci) { TypeHandle ctype = (*ci).first; @@ -333,4 +283,3 @@ make_instance_more_specific(TypeHandle handle, const FactoryParams ¶ms) { return NULL; } - diff --git a/panda/src/putil/factoryBase.h b/panda/src/putil/factoryBase.h index 8a10b7a196..13ea0c8eaa 100644 --- a/panda/src/putil/factoryBase.h +++ b/panda/src/putil/factoryBase.h @@ -1,16 +1,15 @@ -// Filename: factoryBase.h -// Created by: cary (06Oct99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryBase.h + * @author cary + * @date 1999-10-06 + */ #ifndef FACTORYBASE_H #define FACTORYBASE_H @@ -24,21 +23,16 @@ #include "pvector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : FactoryBase -// Description : A Factory can be used to create an instance of a -// particular subclass of some general base class. Each -// subclass registers itself with the Factory, supplying -// a function that will construct an instance of that -// subclass; the Factory can later choose a suitable -// subclass and return a newly-constructed pointer to an -// object of that type on the user's demand. This is -// used, for instance, to manage the set of -// GraphicsPipes available to the user. -// -// FactoryBase is the main definition of the thin -// template class Factory. -//////////////////////////////////////////////////////////////////// +/** + * A Factory can be used to create an instance of a particular subclass of + * some general base class. Each subclass registers itself with the Factory, + * supplying a function that will construct an instance of that subclass; the + * Factory can later choose a suitable subclass and return a newly-constructed + * pointer to an object of that type on the user's demand. This is used, for + * instance, to manage the set of GraphicsPipes available to the user. + * + * FactoryBase is the main definition of the thin template class Factory. + */ class EXPCL_PANDA_PUTIL FactoryBase { public: typedef TypedObject *BaseCreateFunc(const FactoryParams ¶ms); diff --git a/panda/src/putil/factoryParam.I b/panda/src/putil/factoryParam.I index 16682ecfc7..e127a2f9df 100644 --- a/panda/src/putil/factoryParam.I +++ b/panda/src/putil/factoryParam.I @@ -1,49 +1,40 @@ -// Filename: factoryParam.I -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParam.I + * @author drose + * @date 2000-05-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FactoryParam:: FactoryParam() { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FactoryParam:: FactoryParam(const FactoryParam &) { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FactoryParam:: operator = (const FactoryParam &) { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FactoryParam:: ~FactoryParam() { } diff --git a/panda/src/putil/factoryParam.cxx b/panda/src/putil/factoryParam.cxx index 1b8a081c60..077aae5528 100644 --- a/panda/src/putil/factoryParam.cxx +++ b/panda/src/putil/factoryParam.cxx @@ -1,16 +1,15 @@ -// Filename: factoryParam.cxx -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParam.cxx + * @author drose + * @date 2000-05-08 + */ #include "factoryParam.h" diff --git a/panda/src/putil/factoryParam.h b/panda/src/putil/factoryParam.h index e1c1527492..8b0aae5323 100644 --- a/panda/src/putil/factoryParam.h +++ b/panda/src/putil/factoryParam.h @@ -1,16 +1,15 @@ -// Filename: factoryParam.h -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParam.h + * @author drose + * @date 2000-05-08 + */ #ifndef FACTORYPARAM_H #define FACTORYPARAM_H @@ -21,16 +20,13 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : FactoryParam -// Description : The base class of any number of specific pieces of -// parameter information that might be passed to a -// Factory's CreateFunc to control what kind of instance -// is created. This class is empty and contains no -// data, but different kinds of factories may expect -// parameters of various types that derive from -// FactoryParam (and do contain data). -//////////////////////////////////////////////////////////////////// +/** + * The base class of any number of specific pieces of parameter information + * that might be passed to a Factory's CreateFunc to control what kind of + * instance is created. This class is empty and contains no data, but + * different kinds of factories may expect parameters of various types that + * derive from FactoryParam (and do contain data). + */ class EXPCL_PANDA_PUTIL FactoryParam : public TypedReferenceCount { public: INLINE FactoryParam(); @@ -59,4 +55,3 @@ private: #include "factoryParam.I" #endif - diff --git a/panda/src/putil/factoryParams.I b/panda/src/putil/factoryParams.I index 536d250b96..3183ae718e 100644 --- a/panda/src/putil/factoryParams.I +++ b/panda/src/putil/factoryParams.I @@ -1,28 +1,25 @@ -// Filename: factoryParams.I -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParams.I + * @author drose + * @date 2000-05-08 + */ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: get_param_into -// Description: A handy convenience template function that extracts a -// parameter of the indicated type from the -// FactoryParams list. If the parameter type is found, -// it fills the pointer and returns true; otherwise, it -// sets the pointer to NULL and returns false. -//////////////////////////////////////////////////////////////////// +/** + * A handy convenience template function that extracts a parameter of the + * indicated type from the FactoryParams list. If the parameter type is + * found, it fills the pointer and returns true; otherwise, it sets the + * pointer to NULL and returns false. + */ template bool get_param_into(ParamType *&pointer, const FactoryParams ¶ms) { FactoryParam *param = diff --git a/panda/src/putil/factoryParams.cxx b/panda/src/putil/factoryParams.cxx index 5cb6526ef4..47e41ebcf3 100644 --- a/panda/src/putil/factoryParams.cxx +++ b/panda/src/putil/factoryParams.cxx @@ -1,89 +1,71 @@ -// Filename: factoryParams.cxx -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParams.cxx + * @author drose + * @date 2000-05-08 + */ #include "factoryParams.h" -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FactoryParams:: FactoryParams() { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FactoryParams:: ~FactoryParams() { } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::add_param -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FactoryParams:: add_param(FactoryParam *param) { nassertv(param != (FactoryParam *)NULL); _params.push_back(param); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::clear -// Access: Public -// Description: Removes all parameters from the set. -//////////////////////////////////////////////////////////////////// +/** + * Removes all parameters from the set. + */ void FactoryParams:: clear() { _params.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::get_num_params -// Access: Public -// Description: Returns the number of parameters that have been added -// to the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parameters that have been added to the set. + */ int FactoryParams:: get_num_params() const { return _params.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::get_param -// Access: Public -// Description: Returns the nth parameter that has been added to the -// set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parameter that has been added to the set. + */ FactoryParam *FactoryParams:: get_param(int n) const { nassertr(n >= 0 && n < (int)_params.size(), NULL); return DCAST(FactoryParam, _params[n]); } -//////////////////////////////////////////////////////////////////// -// Function: FactoryParams::get_param_of_type -// Access: Public -// Description: Returns the first parameter that matches exactly the -// indicated type, or if there are no exact matches, -// returns the first one that derives from the indicated -// type. If no parameters match at all, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first parameter that matches exactly the indicated type, or if + * there are no exact matches, returns the first one that derives from the + * indicated type. If no parameters match at all, returns NULL. + */ FactoryParam *FactoryParams:: get_param_of_type(TypeHandle type) const { Params::const_iterator pi; diff --git a/panda/src/putil/factoryParams.h b/panda/src/putil/factoryParams.h index 99c33042b7..428399dd85 100644 --- a/panda/src/putil/factoryParams.h +++ b/panda/src/putil/factoryParams.h @@ -1,16 +1,15 @@ -// Filename: factoryParams.h -// Created by: drose (08May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file factoryParams.h + * @author drose + * @date 2000-05-08 + */ #ifndef FACTORYPARAMS_H #define FACTORYPARAMS_H @@ -25,18 +24,15 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : FactoryParams -// Description : An instance of this class is passed to the Factory -// when requesting it to do its business and construct a -// new something. It can be filled with optional -// parameters to the CreateFunc for the particular -// subclass the Factory will be creating. -// -// This is just a vector of pointers to *something*; it -// will be up to the individual CreateFuncs to interpret -// this meaningfully. -//////////////////////////////////////////////////////////////////// +/** + * An instance of this class is passed to the Factory when requesting it to do + * its business and construct a new something. It can be filled with optional + * parameters to the CreateFunc for the particular subclass the Factory will + * be creating. + * + * This is just a vector of pointers to *something*; it will be up to the + * individual CreateFuncs to interpret this meaningfully. + */ class EXPCL_PANDA_PUTIL FactoryParams { public: FactoryParams(); diff --git a/panda/src/putil/firstOfPairCompare.I b/panda/src/putil/firstOfPairCompare.I index e152efca1a..82b7ab2ea6 100644 --- a/panda/src/putil/firstOfPairCompare.I +++ b/panda/src/putil/firstOfPairCompare.I @@ -1,33 +1,27 @@ -// Filename: firstOfPairCompare.I -// Created by: drose (04Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file firstOfPairCompare.I + * @author drose + * @date 2000-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FirstOfPairCompare::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE FirstOfPairCompare:: FirstOfPairCompare(Compare compare) : _compare(compare) { } -//////////////////////////////////////////////////////////////////// -// Function: FirstOfPairCompare::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool FirstOfPairCompare:: operator () (const ObjectType &a, const ObjectType &b) const { diff --git a/panda/src/putil/firstOfPairCompare.h b/panda/src/putil/firstOfPairCompare.h index d198bf4104..3ffbcb696e 100644 --- a/panda/src/putil/firstOfPairCompare.h +++ b/panda/src/putil/firstOfPairCompare.h @@ -1,29 +1,26 @@ -// Filename: firstOfPairCompare.h -// Created by: drose (27Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file firstOfPairCompare.h + * @author drose + * @date 2001-06-27 + */ #ifndef FIRSTOFPAIRCOMPARE_H #define FIRSTOFPAIRCOMPARE_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : FirstOfPairCompare -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pairs of objects. -// It invokes the indicated comparison function object -// on the first object of its pair. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pairs of objects. It invokes the indicated comparison + * function object on the first object of its pair. + */ template class FirstOfPairCompare { public: @@ -35,4 +32,3 @@ public: #include "firstOfPairCompare.I" #endif - diff --git a/panda/src/putil/firstOfPairLess.I b/panda/src/putil/firstOfPairLess.I index 8c22481973..d0b6b001a9 100644 --- a/panda/src/putil/firstOfPairLess.I +++ b/panda/src/putil/firstOfPairLess.I @@ -1,22 +1,19 @@ -// Filename: firstOfPairLess.I -// Created by: drose (04Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file firstOfPairLess.I + * @author drose + * @date 2000-04-04 + */ -//////////////////////////////////////////////////////////////////// -// Function: FirstOfPairLess::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool FirstOfPairLess:: operator () (const ObjectType &a, const ObjectType &b) const { diff --git a/panda/src/putil/firstOfPairLess.h b/panda/src/putil/firstOfPairLess.h index 93595461c0..24b6974af0 100644 --- a/panda/src/putil/firstOfPairLess.h +++ b/panda/src/putil/firstOfPairLess.h @@ -1,28 +1,26 @@ -// Filename: firstOfPairLess.h -// Created by: drose (27Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file firstOfPairLess.h + * @author drose + * @date 2001-06-27 + */ #ifndef FIRSTOFPAIRLESS_H #define FIRSTOFPAIRLESS_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : FirstOfPairLess -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pairs of objects. -// It uses < to compare the first elements of the pair. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pairs of objects. It uses < to compare the first elements of + * the pair. + */ template class FirstOfPairLess { public: @@ -32,4 +30,3 @@ public: #include "firstOfPairLess.I" #endif - diff --git a/panda/src/putil/globalPointerRegistry.I b/panda/src/putil/globalPointerRegistry.I index 901eea024f..10dc289e9b 100644 --- a/panda/src/putil/globalPointerRegistry.I +++ b/panda/src/putil/globalPointerRegistry.I @@ -1,68 +1,52 @@ -// Filename: globalPointerRegistry.I -// Created by: drose (03Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalPointerRegistry.I + * @author drose + * @date 2000-02-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::get_pointer -// Access: Public, Static -// Description: Returns the pointer associated with the indicated -// TypeHandle, if any. If no pointer has yet been -// associated, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer associated with the indicated TypeHandle, if any. If + * no pointer has yet been associated, returns NULL. + */ INLINE void *GlobalPointerRegistry:: get_pointer(TypeHandle type) { return get_global_ptr()->ns_get_pointer(type); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::store_pointer -// Access: Public, Static -// Description: Associates the given pointer with the indicated -// TypeHandle. It is an error to call this with a NULL -// pointer, or to call this function more than once with -// a given TypeHandle (without first calling -// clear_pointer). -//////////////////////////////////////////////////////////////////// +/** + * Associates the given pointer with the indicated TypeHandle. It is an error + * to call this with a NULL pointer, or to call this function more than once + * with a given TypeHandle (without first calling clear_pointer). + */ INLINE void GlobalPointerRegistry:: store_pointer(TypeHandle type, void *ptr) { get_global_ptr()->ns_store_pointer(type, ptr); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::clear_pointer -// Access: Public, Static -// Description: Removes the association of the given pointer with the -// indicated TypeHandle. Subsequent calls to -// get_pointer() with this TypeHandle will return NULL, -// until another call to store_pointer() is made. -//////////////////////////////////////////////////////////////////// +/** + * Removes the association of the given pointer with the indicated TypeHandle. + * Subsequent calls to get_pointer() with this TypeHandle will return NULL, + * until another call to store_pointer() is made. + */ INLINE void GlobalPointerRegistry:: clear_pointer(TypeHandle type) { get_global_ptr()->ns_clear_pointer(type); } -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::get_global_pointer -// Access: Private, Static -// Description: Returns a pointer to the single GlobalPointerRegistry -// object. If the object does not yet exist, creates -// it. This indirection is used instead of making all -// the data members of GlobalPointerRegistry static, so -// that we don't have to worry about order dependency -// during static init time. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the single GlobalPointerRegistry object. If the + * object does not yet exist, creates it. This indirection is used instead of + * making all the data members of GlobalPointerRegistry static, so that we + * don't have to worry about order dependency during static init time. + */ INLINE GlobalPointerRegistry *GlobalPointerRegistry:: get_global_ptr() { if (_global_ptr == (GlobalPointerRegistry *)NULL) { diff --git a/panda/src/putil/globalPointerRegistry.cxx b/panda/src/putil/globalPointerRegistry.cxx index 1e75bdee2b..dcec8579bd 100644 --- a/panda/src/putil/globalPointerRegistry.cxx +++ b/panda/src/putil/globalPointerRegistry.cxx @@ -1,34 +1,30 @@ -// Filename: globalPointerRegistry.cxx -// Created by: drose (03Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalPointerRegistry.cxx + * @author drose + * @date 2000-02-03 + */ #include "globalPointerRegistry.h" #include "config_util.h" -// In general, we use the util_cat->info() syntax in this file -// (instead of util_cat.info()), because much of this work is done at -// static init time, and we must use the arrow syntax to force -// initialization of the util_cat category. +// In general, we use the util_cat->info() syntax in this file (instead of +// util_cat.info()), because much of this work is done at static init time, +// and we must use the arrow syntax to force initialization of the util_cat +// category. GlobalPointerRegistry *GlobalPointerRegistry::_global_ptr; -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::ns_get_pointer -// Access: Private -// Description: Returns the pointer associated with the indicated -// TypeHandle, if any. If no pointer has yet been -// associated, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer associated with the indicated TypeHandle, if any. If + * no pointer has yet been associated, returns NULL. + */ void *GlobalPointerRegistry:: ns_get_pointer(TypeHandle type) const { if (type == TypeHandle::none()) { @@ -44,15 +40,11 @@ ns_get_pointer(TypeHandle type) const { return (*pi).second; } -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::ns_store_pointer -// Access: Private -// Description: Associates the given pointer with the indicated -// TypeHandle. It is an error to call this with a NULL -// pointer, or to call this function more than once with -// a given TypeHandle (without first calling -// clear_pointer). -//////////////////////////////////////////////////////////////////// +/** + * Associates the given pointer with the indicated TypeHandle. It is an error + * to call this with a NULL pointer, or to call this function more than once + * with a given TypeHandle (without first calling clear_pointer). + */ void GlobalPointerRegistry:: ns_store_pointer(TypeHandle type, void *ptr) { if (type == TypeHandle::none()) { @@ -83,14 +75,11 @@ ns_store_pointer(TypeHandle type, void *ptr) { } } -//////////////////////////////////////////////////////////////////// -// Function: GlobalPointerRegistry::ns_clear_pointer -// Access: Private -// Description: Removes the association of the given pointer with the -// indicated TypeHandle. Subsequent calls to -// get_pointer() with this TypeHandle will return NULL, -// until another call to store_pointer() is made. -//////////////////////////////////////////////////////////////////// +/** + * Removes the association of the given pointer with the indicated TypeHandle. + * Subsequent calls to get_pointer() with this TypeHandle will return NULL, + * until another call to store_pointer() is made. + */ void GlobalPointerRegistry:: ns_clear_pointer(TypeHandle type) { if (type == TypeHandle::none()) { @@ -98,7 +87,7 @@ ns_clear_pointer(TypeHandle type) { << "GlobalPointerRegistry::clear_pointer() called on empty TypeHandle\n"; } - // It's not an error to clear_pointer() if it was already cleared. - // Don't bother checking that. + // It's not an error to clear_pointer() if it was already cleared. Don't + // bother checking that. _pointers.erase(type); } diff --git a/panda/src/putil/globalPointerRegistry.h b/panda/src/putil/globalPointerRegistry.h index d69810be7b..a107a7f30d 100644 --- a/panda/src/putil/globalPointerRegistry.h +++ b/panda/src/putil/globalPointerRegistry.h @@ -1,16 +1,15 @@ -// Filename: globalPointerRegistry.h -// Created by: drose (03Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file globalPointerRegistry.h + * @author drose + * @date 2000-02-03 + */ #ifndef GLOBALPOINTERREGISTRY_H #define GLOBALPOINTERREGISTRY_H @@ -21,44 +20,33 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : GlobalPointerRegistry -// Description : This class maintains a one-to-one mapping from -// TypeHandle to a void * pointer. Its purpose is to -// store a pointer to some class data for a given class. -// -// Normally, one would simply use a static data member -// to store class data. However, when the static data -// is associated with a template class, the dynamic -// loader may have difficulty in properly resolving the -// statics. -// -// Consider: class foo defines a static member, _a. -// There should be only one instance of _a shared -// between all instances of foo, and there will be -// a different instance of _a shared between all -// instances of foo. -// -// Now suppose that two different shared libraries -// instantiate foo. In each .so, there exists a -// different foo::_a. It is the loader's job to -// recognize this and collapse them together when both -// libraries are loaded. This usually works, but -// sometimes it doesn't, and you end up with two -// different instances of foo::_a; some functions -// see one instance, while others see the other. We -// have particularly seen this problem occur under Linux -// with gcc. -// -// This class attempts to circumvent the problem by -// managing pointers to data based on TypeHandle. Since -// the TypeHandle will already be unique based on the -// string name supplied to the init_type() function, it -// can be used to differentiate foo from -// foo, while allowing different instances of -// foo to guarantee that they share the same static -// data. -//////////////////////////////////////////////////////////////////// +/** + * This class maintains a one-to-one mapping from TypeHandle to a void * + * pointer. Its purpose is to store a pointer to some class data for a given + * class. + * + * Normally, one would simply use a static data member to store class data. + * However, when the static data is associated with a template class, the + * dynamic loader may have difficulty in properly resolving the statics. + * + * Consider: class foo defines a static member, _a. There should be only + * one instance of _a shared between all instances of foo, and there will + * be a different instance of _a shared between all instances of foo. + * + * Now suppose that two different shared libraries instantiate foo. In + * each .so, there exists a different foo::_a. It is the loader's job to + * recognize this and collapse them together when both libraries are loaded. + * This usually works, but sometimes it doesn't, and you end up with two + * different instances of foo::_a; some functions see one instance, while + * others see the other. We have particularly seen this problem occur under + * Linux with gcc. + * + * This class attempts to circumvent the problem by managing pointers to data + * based on TypeHandle. Since the TypeHandle will already be unique based on + * the string name supplied to the init_type() function, it can be used to + * differentiate foo from foo, while allowing different instances + * of foo to guarantee that they share the same static data. + */ class EXPCL_PANDA_PUTIL GlobalPointerRegistry { public: INLINE static void *get_pointer(TypeHandle type); @@ -82,4 +70,3 @@ private: #include "globalPointerRegistry.I" #endif - diff --git a/panda/src/putil/indirectCompareNames.I b/panda/src/putil/indirectCompareNames.I index 50dfed7879..a59cdae566 100644 --- a/panda/src/putil/indirectCompareNames.I +++ b/panda/src/putil/indirectCompareNames.I @@ -1,23 +1,19 @@ -// Filename: indirectCompareNames.I -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareNames.I + * @author drose + * @date 2001-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IndirectCompareNames::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool IndirectCompareNames:: operator () (const ObjectType *a, const ObjectType *b) const { diff --git a/panda/src/putil/indirectCompareNames.h b/panda/src/putil/indirectCompareNames.h index ca1059a4ec..94a04a74c6 100644 --- a/panda/src/putil/indirectCompareNames.h +++ b/panda/src/putil/indirectCompareNames.h @@ -1,31 +1,27 @@ -// Filename: indirectCompareNames.h -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareNames.h + * @author drose + * @date 2001-02-23 + */ #ifndef INDIRECTCOMPARENAMES_H #define INDIRECTCOMPARENAMES_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : IndirectCompareNames -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that define a get_name() method, particularly for -// things that derive from Namable. It defines the -// order of the pointers by case-sensitive name -// comparison. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that define a get_name() method, + * particularly for things that derive from Namable. It defines the order of + * the pointers by case-sensitive name comparison. + */ template class IndirectCompareNames { public: @@ -35,4 +31,3 @@ public: #include "indirectCompareNames.I" #endif - diff --git a/panda/src/putil/indirectCompareSort.I b/panda/src/putil/indirectCompareSort.I index b18fc86d72..7673ffb8c5 100644 --- a/panda/src/putil/indirectCompareSort.I +++ b/panda/src/putil/indirectCompareSort.I @@ -1,23 +1,19 @@ -// Filename: indirectCompareSort.I -// Created by: drose (01Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareSort.I + * @author drose + * @date 2005-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IndirectCompareSort::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool IndirectCompareSort:: operator () (const ObjectType *a, const ObjectType *b) const { diff --git a/panda/src/putil/indirectCompareSort.h b/panda/src/putil/indirectCompareSort.h index 59ef0b1b42..86f8ab41d9 100644 --- a/panda/src/putil/indirectCompareSort.h +++ b/panda/src/putil/indirectCompareSort.h @@ -1,29 +1,26 @@ -// Filename: indirectCompareSort.h -// Created by: drose (01Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareSort.h + * @author drose + * @date 2005-03-01 + */ #ifndef INDIRECTCOMPARESORT_H #define INDIRECTCOMPARESORT_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : IndirectCompareSort -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that define a get_sort() method. It defines the -// order of the pointers by sort comparison. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that define a get_sort() method. It + * defines the order of the pointers by sort comparison. + */ template class IndirectCompareSort { public: @@ -33,4 +30,3 @@ public: #include "indirectCompareSort.I" #endif - diff --git a/panda/src/putil/indirectCompareTo.I b/panda/src/putil/indirectCompareTo.I index a96574791e..96d9766930 100644 --- a/panda/src/putil/indirectCompareTo.I +++ b/panda/src/putil/indirectCompareTo.I @@ -1,23 +1,19 @@ -// Filename: indirectCompareTo.I -// Created by: drose (04Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareTo.I + * @author drose + * @date 2000-04-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IndirectCompareTo::operator () -// Access: Public -// Description: Returns true if a sorts before b, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a sorts before b, false otherwise. + */ template INLINE bool IndirectCompareTo:: operator () (const ObjectType *a, const ObjectType *b) const { diff --git a/panda/src/putil/indirectCompareTo.h b/panda/src/putil/indirectCompareTo.h index 4ec85ab7c9..c3ef1796cd 100644 --- a/panda/src/putil/indirectCompareTo.h +++ b/panda/src/putil/indirectCompareTo.h @@ -1,29 +1,26 @@ -// Filename: indirectCompareTo.h -// Created by: drose (04Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indirectCompareTo.h + * @author drose + * @date 2000-04-04 + */ #ifndef INDIRECTCOMPARETO_H #define INDIRECTCOMPARETO_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : IndirectCompareTo -// Description : An STL function object class, this is intended to be -// used on any ordered collection of pointers to classes -// that contain a compare_to() method. It defines the -// order of the pointers via compare_to(). -//////////////////////////////////////////////////////////////////// +/** + * An STL function object class, this is intended to be used on any ordered + * collection of pointers to classes that contain a compare_to() method. It + * defines the order of the pointers via compare_to(). + */ template class IndirectCompareTo { public: @@ -33,4 +30,3 @@ public: #include "indirectCompareTo.I" #endif - diff --git a/panda/src/putil/ioPtaDatagramFloat.cxx b/panda/src/putil/ioPtaDatagramFloat.cxx index 856bb8d047..a64a44b487 100644 --- a/panda/src/putil/ioPtaDatagramFloat.cxx +++ b/panda/src/putil/ioPtaDatagramFloat.cxx @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramFloat.cxx -// Created by: charles (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramFloat.cxx + * @author charles + * @date 2000-07-10 + */ #include "pandabase.h" @@ -18,11 +17,9 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramFloat::write_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IoPtaDatagramFloat:: write_datagram(BamWriter *, Datagram &dest, CPTA_stdfloat array) { dest.add_uint32(array.size()); @@ -31,11 +28,9 @@ write_datagram(BamWriter *, Datagram &dest, CPTA_stdfloat array) { } } -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramFloat::read_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PTA_stdfloat IoPtaDatagramFloat:: read_datagram(BamReader *, DatagramIterator &source) { PTA_stdfloat array; diff --git a/panda/src/putil/ioPtaDatagramFloat.h b/panda/src/putil/ioPtaDatagramFloat.h index 555f072251..ebe749156b 100644 --- a/panda/src/putil/ioPtaDatagramFloat.h +++ b/panda/src/putil/ioPtaDatagramFloat.h @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramFloat.h -// Created by: charles (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramFloat.h + * @author charles + * @date 2000-07-10 + */ #ifndef _IO_PTA_DATAGRAM_FLOAT #define _IO_PTA_DATAGRAM_FLOAT @@ -25,14 +24,12 @@ class BamWriter; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : IoPtaDatagramFloat -// Description : This class is used to read and write a PTA_stdfloat -// from a Datagram, in support of Bam. It's not -// intended to be constructed; it's just a convenient -// place to scope these static methods which should be -// called directly. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to read and write a PTA_stdfloat from a Datagram, in + * support of Bam. It's not intended to be constructed; it's just a + * convenient place to scope these static methods which should be called + * directly. + */ class EXPCL_PANDA_PUTIL IoPtaDatagramFloat { public: static void write_datagram(BamWriter *manager, Datagram &dest, CPTA_stdfloat array); diff --git a/panda/src/putil/ioPtaDatagramInt.cxx b/panda/src/putil/ioPtaDatagramInt.cxx index 2d95b2a07f..2086e5c700 100644 --- a/panda/src/putil/ioPtaDatagramInt.cxx +++ b/panda/src/putil/ioPtaDatagramInt.cxx @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramInt.cxx -// Created by: jason (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramInt.cxx + * @author jason + * @date 2000-06-26 + */ #include "pandabase.h" @@ -18,11 +17,9 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramInt::write_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IoPtaDatagramInt:: write_datagram(BamWriter *, Datagram &dest, CPTA_int array) { dest.add_uint32(array.size()); @@ -31,11 +28,9 @@ write_datagram(BamWriter *, Datagram &dest, CPTA_int array) { } } -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramInt::read_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PTA_int IoPtaDatagramInt:: read_datagram(BamReader *, DatagramIterator &source) { PTA_int array; @@ -47,4 +42,3 @@ read_datagram(BamReader *, DatagramIterator &source) { return array; } - diff --git a/panda/src/putil/ioPtaDatagramInt.h b/panda/src/putil/ioPtaDatagramInt.h index 4b0712a46c..1d9d65318b 100644 --- a/panda/src/putil/ioPtaDatagramInt.h +++ b/panda/src/putil/ioPtaDatagramInt.h @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramInt.h -// Created by: jason (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramInt.h + * @author jason + * @date 2000-06-26 + */ #ifndef _IO_PTA_DATAGRAM_INT #define _IO_PTA_DATAGRAM_INT @@ -25,13 +24,11 @@ class BamWriter; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : IoPtaDatagramInt -// Description : This class is used to read and write a PTA_int from a -// Datagram, in support of Bam. It's not intended to be -// constructed; it's just a convenient place to scope -// these static methods which should be called directly. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to read and write a PTA_int from a Datagram, in support + * of Bam. It's not intended to be constructed; it's just a convenient place + * to scope these static methods which should be called directly. + */ class EXPCL_PANDA_PUTIL IoPtaDatagramInt { public: static void write_datagram(BamWriter *manager, Datagram &dest, CPTA_int array); @@ -41,4 +38,3 @@ public: typedef IoPtaDatagramInt IPD_int; #endif - diff --git a/panda/src/putil/ioPtaDatagramShort.cxx b/panda/src/putil/ioPtaDatagramShort.cxx index fce287c600..83b66998d9 100644 --- a/panda/src/putil/ioPtaDatagramShort.cxx +++ b/panda/src/putil/ioPtaDatagramShort.cxx @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramShort.cxx -// Created by: jason (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramShort.cxx + * @author jason + * @date 2000-06-26 + */ #include "pandabase.h" @@ -18,11 +17,9 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramShort::write_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IoPtaDatagramShort:: write_datagram(BamWriter *, Datagram &dest, CPTA_ushort array) { dest.add_uint32(array.size()); @@ -31,11 +28,9 @@ write_datagram(BamWriter *, Datagram &dest, CPTA_ushort array) { } } -//////////////////////////////////////////////////////////////////// -// Function: IoPtaDatagramShort::read_datagram -// Access: Public, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PTA_ushort IoPtaDatagramShort:: read_datagram(BamReader *, DatagramIterator &source) { PTA_ushort array; diff --git a/panda/src/putil/ioPtaDatagramShort.h b/panda/src/putil/ioPtaDatagramShort.h index 8a166a12a1..d34c4be9dc 100644 --- a/panda/src/putil/ioPtaDatagramShort.h +++ b/panda/src/putil/ioPtaDatagramShort.h @@ -1,16 +1,15 @@ -// Filename: ioPtaDatagramShort.h -// Created by: jason (26Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ioPtaDatagramShort.h + * @author jason + * @date 2000-06-26 + */ #ifndef _IO_PTA_DATAGRAM_SHORT #define _IO_PTA_DATAGRAM_SHORT @@ -25,14 +24,12 @@ class BamWriter; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : IoPtaDatagramShort -// Description : This class is used to read and write a PTA_ushort -// from a Datagram, in support of Bam. It's not -// intended to be constructed; it's just a convenient -// place to scope these static methods which should be -// called directly. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to read and write a PTA_ushort from a Datagram, in + * support of Bam. It's not intended to be constructed; it's just a + * convenient place to scope these static methods which should be called + * directly. + */ class EXPCL_PANDA_PUTIL IoPtaDatagramShort { public: static void write_datagram(BamWriter *manager, Datagram &dest, CPTA_ushort array); diff --git a/panda/src/putil/iterator_types.h b/panda/src/putil/iterator_types.h index 7a2df25eab..cb405ce18c 100644 --- a/panda/src/putil/iterator_types.h +++ b/panda/src/putil/iterator_types.h @@ -1,28 +1,25 @@ -// Filename: iterator_types.h -// Created by: drose (10Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iterator_types.h + * @author drose + * @date 1999-02-10 + */ #ifndef ITERATOR_TYPES_H #define ITERATOR_TYPES_H -//////////////////////////////////////////////////////////////////// -// Class : first_of_pair_iterator -// Description : This is an iterator adaptor that converts any -// iterator that returns a pair (e.g. a map iterator) -// into one that returns just the first component of -// that pair. -//////////////////////////////////////////////////////////////////// +/** + * This is an iterator adaptor that converts any iterator that returns a pair + * (e.g. a map iterator) into one that returns just the first component of + * that pair. + */ template class first_of_pair_iterator : public pair_iterator { public: @@ -37,13 +34,11 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Class : second_of_pair_iterator -// Description : This is an iterator adaptor that converts any -// iterator that returns a pair (e.g. a map iterator) -// into one that returns just the second component of -// that pair. -//////////////////////////////////////////////////////////////////// +/** + * This is an iterator adaptor that converts any iterator that returns a pair + * (e.g. a map iterator) into one that returns just the second component of + * that pair. + */ template class second_of_pair_iterator : public pair_iterator { public: @@ -58,12 +53,10 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Class : typecast_iterator -// Description : This is an iterator adaptor that explicitly typecasts -// each value returned by the base iterator to the -// indicated type. -//////////////////////////////////////////////////////////////////// +/** + * This is an iterator adaptor that explicitly typecasts each value returned + * by the base iterator to the indicated type. + */ template class typecast_iterator : public base_iterator { public: diff --git a/panda/src/putil/keyboardButton.cxx b/panda/src/putil/keyboardButton.cxx index e683e37d0a..07e5265c03 100644 --- a/panda/src/putil/keyboardButton.cxx +++ b/panda/src/putil/keyboardButton.cxx @@ -1,29 +1,25 @@ -// Filename: keyboardButton.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file keyboardButton.cxx + * @author drose + * @date 2000-03-01 + */ #include "keyboardButton.h" #include "buttonRegistry.h" #include -//////////////////////////////////////////////////////////////////// -// Function: KeyboardButton::ascii_key -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// particular ASCII character, if there is one, or -// ButtonHandle::none() if there is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the particular ASCII character, if + * there is one, or ButtonHandle::none() if there is not. + */ ButtonHandle KeyboardButton:: ascii_key(char ascii_equivalent) { return ButtonRegistry::ptr()->find_ascii_button(ascii_equivalent); @@ -86,25 +82,23 @@ DEFINE_KEYBD_BUTTON_HANDLE(lmeta) DEFINE_KEYBD_BUTTON_HANDLE(rmeta) -//////////////////////////////////////////////////////////////////// -// Function: KeyboardButton::init_keyboard_buttons -// Access: Public, Static -// Description: This is intended to be called only once, by the -// static initialization performed in config_util.cxx. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only once, by the static initialization + * performed in config_util.cxx. + */ void KeyboardButton:: init_keyboard_buttons() { - ButtonRegistry::ptr()->register_button(_space, "space", + ButtonRegistry::ptr()->register_button(_space, "space", ButtonHandle::none(), ' '); - ButtonRegistry::ptr()->register_button(_backspace, "backspace", + ButtonRegistry::ptr()->register_button(_backspace, "backspace", ButtonHandle::none(), '\x08'); - ButtonRegistry::ptr()->register_button(_tab, "tab", + ButtonRegistry::ptr()->register_button(_tab, "tab", ButtonHandle::none(), '\x09'); - ButtonRegistry::ptr()->register_button(_enter, "enter", + ButtonRegistry::ptr()->register_button(_enter, "enter", ButtonHandle::none(), '\x0d'); - ButtonRegistry::ptr()->register_button(_escape, "escape", + ButtonRegistry::ptr()->register_button(_escape, "escape", ButtonHandle::none(), '\x1b'); - ButtonRegistry::ptr()->register_button(_del, "delete", + ButtonRegistry::ptr()->register_button(_del, "delete", ButtonHandle::none(), '\x7f'); ButtonRegistry::ptr()->register_button(_f1, "f1"); diff --git a/panda/src/putil/keyboardButton.h b/panda/src/putil/keyboardButton.h index 499a087e0e..c2d3f3a679 100644 --- a/panda/src/putil/keyboardButton.h +++ b/panda/src/putil/keyboardButton.h @@ -1,16 +1,15 @@ -// Filename: keyboardButton.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file keyboardButton.h + * @author drose + * @date 2000-03-01 + */ #ifndef KEYBOARDBUTTON_H #define KEYBOARDBUTTON_H @@ -19,12 +18,10 @@ #include "buttonHandle.h" -//////////////////////////////////////////////////////////////////// -// Class : KeyboardButton -// Description : This class is just used as a convenient namespace for -// grouping all of these handy functions that return -// buttons which map to standard keyboard keys. -//////////////////////////////////////////////////////////////////// +/** + * This class is just used as a convenient namespace for grouping all of these + * handy functions that return buttons which map to standard keyboard keys. + */ class EXPCL_PANDA_PUTIL KeyboardButton { PUBLISHED: static ButtonHandle ascii_key(char ascii_equivalent); diff --git a/panda/src/putil/linkedListNode.I b/panda/src/putil/linkedListNode.I index f5114628a7..e722108702 100644 --- a/panda/src/putil/linkedListNode.I +++ b/panda/src/putil/linkedListNode.I @@ -1,23 +1,19 @@ -// Filename: linkedListNode.I -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linkedListNode.I + * @author drose + * @date 2006-03-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LinkedListNode:: LinkedListNode() { #ifndef NDEBUG @@ -26,49 +22,38 @@ LinkedListNode() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::Constructor 2 -// Access: Protected -// Description: This constructor should be invoked for any -// LinkedListNodes that will be used to serve as the -// root of a list. It sets up the pointers as an empty -// list. -//////////////////////////////////////////////////////////////////// +/** + * This constructor should be invoked for any LinkedListNodes that will be + * used to serve as the root of a list. It sets up the pointers as an empty + * list. + */ INLINE LinkedListNode:: LinkedListNode(bool) { _next = this; _prev = this; } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::Destructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LinkedListNode:: ~LinkedListNode() { nassertv((_next == NULL && _prev == NULL) || (_next == this && _prev == this)); } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::is_on_list -// Access: Protected -// Description: Returns true if the node is member of any list, false -// if it has been removed or never added. The head of a -// list generally appears to to always be a member of -// itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is member of any list, false if it has been + * removed or never added. The head of a list generally appears to to always + * be a member of itself. + */ INLINE bool LinkedListNode:: is_on_list() const { return (_next != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::remove_from_list -// Access: Protected -// Description: Removes a LinkedListNode record from the -// doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Removes a LinkedListNode record from the doubly-linked list. + */ INLINE void LinkedListNode:: remove_from_list() { nassertv(_prev != NULL && _next != NULL); @@ -81,12 +66,10 @@ remove_from_list() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::insert_before -// Access: Protected -// Description: Adds a LinkedListNode record before the indicated -// node in the doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a LinkedListNode record before the indicated node in the doubly-linked + * list. + */ INLINE void LinkedListNode:: insert_before(LinkedListNode *node) { nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); @@ -98,12 +81,10 @@ insert_before(LinkedListNode *node) { node->_prev = this; } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::insert_after -// Access: Protected -// Description: Adds a LinkedListNode record after the indicated -// node in the doubly-linked list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a LinkedListNode record after the indicated node in the doubly-linked + * list. + */ INLINE void LinkedListNode:: insert_after(LinkedListNode *node) { nassertv(node->_prev != NULL && node->_prev->_next == node && node->_next->_prev == node); @@ -115,14 +96,11 @@ insert_after(LinkedListNode *node) { node->_next = this; } -//////////////////////////////////////////////////////////////////// -// Function: LinkedListNode::take_list_from -// Access: Protected -// Description: Given that this LinkedListNode represents the root of -// a list, and the other pointer represents the root of -// a different list, move all of the nodes (except the -// root itself) from other_root onto this list. -//////////////////////////////////////////////////////////////////// +/** + * Given that this LinkedListNode represents the root of a list, and the other + * pointer represents the root of a different list, move all of the nodes + * (except the root itself) from other_root onto this list. + */ INLINE void LinkedListNode:: take_list_from(LinkedListNode *other_root) { other_root->_next->_prev = _prev; diff --git a/panda/src/putil/linkedListNode.cxx b/panda/src/putil/linkedListNode.cxx index be2be90f9f..8eb4330c2e 100644 --- a/panda/src/putil/linkedListNode.cxx +++ b/panda/src/putil/linkedListNode.cxx @@ -1,15 +1,14 @@ -// Filename: linkedListNode.cxx -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linkedListNode.cxx + * @author drose + * @date 2006-03-16 + */ #include "linkedListNode.h" diff --git a/panda/src/putil/linkedListNode.h b/panda/src/putil/linkedListNode.h index 0c623c096b..9dedbe9e4d 100644 --- a/panda/src/putil/linkedListNode.h +++ b/panda/src/putil/linkedListNode.h @@ -1,16 +1,15 @@ -// Filename: linkedListNode.h -// Created by: drose (16Mar06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file linkedListNode.h + * @author drose + * @date 2006-03-16 + */ #ifndef LINKEDLISTNODE_H #define LINKEDLISTNODE_H @@ -18,20 +17,17 @@ #include "pandabase.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Class : LinkedListNode -// Description : This just stores the pointers to implement a -// doubly-linked list of some kind of object. There are -// occasions when a hand-rolled linked list is more -// appropriate than an STL container. -// -// Typically, each node of the linked list, as well as -// the root of the list, will inherit from this class. -// -// Note that this class is not inherently thread-safe; -// derived classes are responsible for protecting any -// calls into it within mutexes, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * This just stores the pointers to implement a doubly-linked list of some + * kind of object. There are occasions when a hand-rolled linked list is more + * appropriate than an STL container. + * + * Typically, each node of the linked list, as well as the root of the list, + * will inherit from this class. + * + * Note that this class is not inherently thread-safe; derived classes are + * responsible for protecting any calls into it within mutexes, if necessary. + */ class EXPCL_PANDA_PUTIL LinkedListNode { protected: INLINE LinkedListNode(); diff --git a/panda/src/putil/load_prc_file.cxx b/panda/src/putil/load_prc_file.cxx index 37774039ac..d35a3b9c29 100644 --- a/panda/src/putil/load_prc_file.cxx +++ b/panda/src/putil/load_prc_file.cxx @@ -1,16 +1,15 @@ -// Filename: load_prc_file.cxx -// Created by: drose (22Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_prc_file.cxx + * @author drose + * @date 2004-10-22 + */ #include "load_prc_file.h" #include "configPageManager.h" @@ -20,24 +19,19 @@ #include "config_util.h" #include "hashVal.h" -//////////////////////////////////////////////////////////////////// -// Function: load_prc_file -// Description: A convenience function for loading explicit prc files -// from a disk file or from within a multifile (via the -// virtual file system). Save the return value and pass -// it to unload_prc_file() if you ever want to unload -// this file later. -// -// The filename is first searched along the default prc -// search path, and then also along the model path, for -// convenience. -// -// This function is defined in putil instead of in dtool -// with the read of the prc stuff, so that it can take -// advantage of the virtual file system (which is -// defined in express), and the model path (which is in -// putil). -//////////////////////////////////////////////////////////////////// +/** + * A convenience function for loading explicit prc files from a disk file or + * from within a multifile (via the virtual file system). Save the return + * value and pass it to unload_prc_file() if you ever want to unload this file + * later. + * + * The filename is first searched along the default prc search path, and then + * also along the model path, for convenience. + * + * This function is defined in putil instead of in dtool with the read of the + * prc stuff, so that it can take advantage of the virtual file system (which + * is defined in express), and the model path (which is in putil). + */ ConfigPage * load_prc_file(const Filename &filename) { Filename path = filename; @@ -48,24 +42,24 @@ load_prc_file(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); vfs->resolve_filename(path, cp_mgr->get_search_path()) || vfs->resolve_filename(path, get_model_path()); - + istream *file = vfs->open_read_file(path, true); if (file == (istream *)NULL) { util_cat.error() << "Unable to open " << path << "\n"; return NULL; } - + util_cat.info() << "Reading " << path << "\n"; - + ConfigPage *page = cp_mgr->make_explicit_page(path); bool read_ok = page->read_prc(*file); vfs->close_read_file(file); - + if (read_ok) { return page; - + } else { util_cat.info() << "Unable to read " << path << "\n"; @@ -74,18 +68,15 @@ load_prc_file(const Filename &filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: load_prc_file_data -// Description: Another convenience function to load a prc file from -// an explicit string, which represents the contents of -// the prc file. -// -// The first parameter is an arbitrary name to assign to -// this in-memory prc file. Supply a filename if the -// data was read from a file, or use any other name that -// is meaningful to you. The name is only used when the -// set of loaded prc files is listed. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function to load a prc file from an explicit string, + * which represents the contents of the prc file. + * + * The first parameter is an arbitrary name to assign to this in-memory prc + * file. Supply a filename if the data was read from a file, or use any other + * name that is meaningful to you. The name is only used when the set of + * loaded prc files is listed. + */ EXPCL_PANDA_PUTIL ConfigPage * load_prc_file_data(const string &name, const string &data) { istringstream strm(data); @@ -94,11 +85,11 @@ load_prc_file_data(const string &name, const string &data) { ConfigPage *page = cp_mgr->make_explicit_page(name); bool read_ok = page->read_prc(strm); - + if (read_ok) { page->set_trust_level(1); // temp hack return page; - + } else { util_cat.info() << "Unable to read explicit prc data " << name << "\n"; @@ -107,17 +98,14 @@ load_prc_file_data(const string &name, const string &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: unload_prc_file -// Description: Unloads (and deletes) a ConfigPage that represents a -// prc file that was previously loaded by -// load_prc_file(). Returns true if successful, false -// if the file was unknown. -// -// After this function has been called, the ConfigPage -// pointer is no longer valid and should not be used -// again. -//////////////////////////////////////////////////////////////////// +/** + * Unloads (and deletes) a ConfigPage that represents a prc file that was + * previously loaded by load_prc_file(). Returns true if successful, false if + * the file was unknown. + * + * After this function has been called, the ConfigPage pointer is no longer + * valid and should not be used again. + */ bool unload_prc_file(ConfigPage *page) { ConfigPageManager *cp_mgr = ConfigPageManager::get_global_ptr(); @@ -127,12 +115,10 @@ unload_prc_file(ConfigPage *page) { #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: hash_prc_variables -// Description: Fills HashVal with the hash from the current prc file -// state as reported by -// ConfigVariableManager::write_prc_variables(). -//////////////////////////////////////////////////////////////////// +/** + * Fills HashVal with the hash from the current prc file state as reported by + * ConfigVariableManager::write_prc_variables(). + */ void hash_prc_variables(HashVal &hash) { ostringstream strm; diff --git a/panda/src/putil/load_prc_file.h b/panda/src/putil/load_prc_file.h index 4989de0081..b1711bcd6d 100644 --- a/panda/src/putil/load_prc_file.h +++ b/panda/src/putil/load_prc_file.h @@ -1,16 +1,15 @@ -// Filename: load_prc_file.h -// Created by: drose (22Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file load_prc_file.h + * @author drose + * @date 2004-10-22 + */ #ifndef LOAD_PRC_FILE_H #define LOAD_PRC_FILE_H @@ -22,64 +21,51 @@ class ConfigPage; class HashVal; BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: load_prc_file -// Description: A convenience function for loading explicit prc files -// from a disk file or from within a multifile (via the -// virtual file system). Save the return value and pass -// it to unload_prc_file() if you ever want to unload -// this file later. -// -// The filename is first searched along the default prc -// search path, and then also along the model path, for -// convenience. -// -// This function is defined in putil instead of in dtool -// with the read of the prc stuff, so that it can take -// advantage of the virtual file system (which is -// defined in express), and the model path (which is in -// putil). -//////////////////////////////////////////////////////////////////// +/** + * A convenience function for loading explicit prc files from a disk file or + * from within a multifile (via the virtual file system). Save the return + * value and pass it to unload_prc_file() if you ever want to unload this file + * later. + * + * The filename is first searched along the default prc search path, and then + * also along the model path, for convenience. + * + * This function is defined in putil instead of in dtool with the read of the + * prc stuff, so that it can take advantage of the virtual file system (which + * is defined in express), and the model path (which is in putil). + */ EXPCL_PANDA_PUTIL ConfigPage * load_prc_file(const Filename &filename); -//////////////////////////////////////////////////////////////////// -// Function: load_prc_file_data -// Description: Another convenience function to load a prc file from -// an explicit string, which represents the contents of -// the prc file. -// -// The first parameter is an arbitrary name to assign to -// this in-memory prc file. Supply a filename if the -// data was read from a file, or use any other name that -// is meaningful to you. The name is only used when the -// set of loaded prc files is listed. -//////////////////////////////////////////////////////////////////// +/** + * Another convenience function to load a prc file from an explicit string, + * which represents the contents of the prc file. + * + * The first parameter is an arbitrary name to assign to this in-memory prc + * file. Supply a filename if the data was read from a file, or use any other + * name that is meaningful to you. The name is only used when the set of + * loaded prc files is listed. + */ EXPCL_PANDA_PUTIL ConfigPage * load_prc_file_data(const string &name, const string &data); -//////////////////////////////////////////////////////////////////// -// Function: unload_prc_file -// Description: Unloads (and deletes) a ConfigPage that represents a -// prc file that was previously loaded by -// load_prc_file(). Returns true if successful, false -// if the file was unknown. -// -// After this function has been called, the ConfigPage -// pointer is no longer valid and should not be used -// again. -//////////////////////////////////////////////////////////////////// +/** + * Unloads (and deletes) a ConfigPage that represents a prc file that was + * previously loaded by load_prc_file(). Returns true if successful, false if + * the file was unknown. + * + * After this function has been called, the ConfigPage pointer is no longer + * valid and should not be used again. + */ EXPCL_PANDA_PUTIL bool unload_prc_file(ConfigPage *page); #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Function: hash_prc_variables -// Description: Fills HashVal with the hash from the current prc file -// state as reported by -// ConfigVariableManager::write_prc_variables(). -//////////////////////////////////////////////////////////////////// +/** + * Fills HashVal with the hash from the current prc file state as reported by + * ConfigVariableManager::write_prc_variables(). + */ EXPCL_PANDA_PUTIL void hash_prc_variables(HashVal &hash); diff --git a/panda/src/putil/loaderOptions.I b/panda/src/putil/loaderOptions.I index 3be3f16e6d..f28be10370 100644 --- a/panda/src/putil/loaderOptions.I +++ b/panda/src/putil/loaderOptions.I @@ -1,37 +1,31 @@ -// Filename: loaderOptions.I -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderOptions.I + * @author drose + * @date 2005-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LoaderOptions:: -LoaderOptions(int flags, int texture_flags) : - _flags(flags), +LoaderOptions(int flags, int texture_flags) : + _flags(flags), _texture_flags(texture_flags), _texture_num_views(0), _auto_texture_scale(ATS_unspecified) { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LoaderOptions:: LoaderOptions(const LoaderOptions ©) : _flags(copy._flags), @@ -41,11 +35,9 @@ LoaderOptions(const LoaderOptions ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void LoaderOptions:: operator = (const LoaderOptions ©) { _flags = copy._flags; @@ -54,91 +46,72 @@ operator = (const LoaderOptions ©) { _auto_texture_scale = copy._auto_texture_scale; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::set_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void LoaderOptions:: set_flags(int flags) { _flags = flags; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::get_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int LoaderOptions:: get_flags() const { return _flags; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::set_texture_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void LoaderOptions:: set_texture_flags(int texture_flags) { _texture_flags = texture_flags; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::get_texture_flags -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int LoaderOptions:: get_texture_flags() const { return _texture_flags; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::set_texture_num_views -// Access: Published -// Description: Specifies the expected number of views to load for -// the texture. This is ignored unless TF_multiview is -// included in texture_flags. This must be specified -// when loading a 3-d multiview texture, in which case -// it is used to differentiate z levels from separate -// views; it may be zero in the case of 2-d textures or -// cube maps, in which case the number of views can be -// inferred from the number of images found on disk. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the expected number of views to load for the texture. This is + * ignored unless TF_multiview is included in texture_flags. This must be + * specified when loading a 3-d multiview texture, in which case it is used to + * differentiate z levels from separate views; it may be zero in the case of + * 2-d textures or cube maps, in which case the number of views can be + * inferred from the number of images found on disk. + */ INLINE void LoaderOptions:: set_texture_num_views(int texture_num_views) { _texture_num_views = texture_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::get_texture_num_views -// Access: Published -// Description: See set_texture_num_views(). -//////////////////////////////////////////////////////////////////// +/** + * See set_texture_num_views(). + */ INLINE int LoaderOptions:: get_texture_num_views() const { return _texture_num_views; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::set_auto_texture_scale -// Access: Published -// Description: Set this flag to ATS_none, ATS_up, ATS_down, or -// ATS_pad to control how a texture is scaled from -// disk when it is subsequently loaded. Set it to -// ATS_unspecified to restore the default behavior. -//////////////////////////////////////////////////////////////////// +/** + * Set this flag to ATS_none, ATS_up, ATS_down, or ATS_pad to control how a + * texture is scaled from disk when it is subsequently loaded. Set it to + * ATS_unspecified to restore the default behavior. + */ INLINE void LoaderOptions:: set_auto_texture_scale(AutoTextureScale scale) { _auto_texture_scale = scale; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::get_auto_texture_scale -// Access: Published -// Description: See set_auto_texture_scale(). -//////////////////////////////////////////////////////////////////// +/** + * See set_auto_texture_scale(). + */ INLINE AutoTextureScale LoaderOptions:: get_auto_texture_scale() const { return _auto_texture_scale; diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index c31118f3d2..5743deaa63 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -1,35 +1,31 @@ -// Filename: loaderOptions.cxx -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderOptions.cxx + * @author drose + * @date 2005-10-05 + */ #include "loaderOptions.h" #include "config_util.h" #include "indent.h" -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderOptions:: -LoaderOptions(int flags) : - _flags(flags), +LoaderOptions(int flags) : + _flags(flags), _texture_flags(0), _texture_num_views(0), _auto_texture_scale(ATS_unspecified) { - // Shadowing the variables in config_util for static init ordering - // issues. + // Shadowing the variables in config_util for static init ordering issues. static ConfigVariableBool *preload_textures; static ConfigVariableBool *preload_simple_textures; if (preload_textures == NULL) { @@ -47,11 +43,9 @@ LoaderOptions(int flags) : } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LoaderOptions:: output(ostream &out) const { out << "LoaderOptions("; @@ -94,13 +88,11 @@ output(ostream &out) const { out << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::write_flag -// Access: Private -// Description: Used to implement output(). -//////////////////////////////////////////////////////////////////// +/** + * Used to implement output(). + */ void LoaderOptions:: -write_flag(ostream &out, string &sep, +write_flag(ostream &out, string &sep, const string &flag_name, int flag) const { if ((_flags & flag) == flag) { out << sep << flag_name; @@ -108,13 +100,11 @@ write_flag(ostream &out, string &sep, } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderOptions::write_texture_flag -// Access: Private -// Description: Used to implement output(). -//////////////////////////////////////////////////////////////////// +/** + * Used to implement output(). + */ void LoaderOptions:: -write_texture_flag(ostream &out, string &sep, +write_texture_flag(ostream &out, string &sep, const string &flag_name, int flag) const { if ((_texture_flags & flag) == flag) { out << sep << flag_name; diff --git a/panda/src/putil/loaderOptions.h b/panda/src/putil/loaderOptions.h index 569694c6e5..3db6f81f5a 100644 --- a/panda/src/putil/loaderOptions.h +++ b/panda/src/putil/loaderOptions.h @@ -1,16 +1,15 @@ -// Filename: loaderOptions.h -// Created by: drose (05Oct05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderOptions.h + * @author drose + * @date 2005-10-05 + */ #ifndef LOADEROPTIONS_H #define LOADEROPTIONS_H @@ -18,11 +17,9 @@ #include "pandabase.h" #include "autoTextureScale.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderOptions -// Description : Specifies parameters that may be passed to the -// loader. -//////////////////////////////////////////////////////////////////// +/** + * Specifies parameters that may be passed to the loader. + */ class EXPCL_PANDA_PUTIL LoaderOptions { PUBLISHED: // Flags for loading model files. @@ -75,9 +72,9 @@ PUBLISHED: void output(ostream &out) const; private: - void write_flag(ostream &out, string &sep, + void write_flag(ostream &out, string &sep, const string &flag_name, int flag) const; - void write_texture_flag(ostream &out, string &sep, + void write_texture_flag(ostream &out, string &sep, const string &flag_name, int flag) const; int _flags; int _texture_flags; diff --git a/panda/src/putil/modifierButtons.I b/panda/src/putil/modifierButtons.I index 710cb172fc..6ef47b088d 100644 --- a/panda/src/putil/modifierButtons.I +++ b/panda/src/putil/modifierButtons.I @@ -1,59 +1,48 @@ -// Filename: modifierButtons.I -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modifierButtons.I + * @author drose + * @date 2000-03-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void ModifierButtons:: operator = (const ModifierButtons ©) { _button_list = copy._button_list; _state = copy._state; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Equality Operator -// Access: Published -// Description: The equality operator is an exact comparision: the -// two ModifierButtons are equal if they share the same -// button list--indeed, the same pointer--and they all -// the buttons have the same state. Use matches() if a -// less exact equality test is needed. -//////////////////////////////////////////////////////////////////// +/** + * The equality operator is an exact comparision: the two ModifierButtons are + * equal if they share the same button list--indeed, the same pointer--and + * they all the buttons have the same state. Use matches() if a less exact + * equality test is needed. + */ INLINE bool ModifierButtons:: operator == (const ModifierButtons &other) const { return (_button_list == other._button_list && _state == other._state); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Inequality Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ModifierButtons:: operator != (const ModifierButtons &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Ordering Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ModifierButtons:: operator < (const ModifierButtons &other) const { if (_button_list != other._button_list) { @@ -62,15 +51,12 @@ operator < (const ModifierButtons &other) const { return _state < other._state; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::operator & -// Access: Published -// Description: Returns a new ModifierButtons object for which -// is_down() will be true only if it is true on both -// source objects. The set of buttons reported by -// has_button() is not completely defined if both source -// objects have a different set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ModifierButtons object for which is_down() will be true only + * if it is true on both source objects. The set of buttons reported by + * has_button() is not completely defined if both source objects have a + * different set. + */ INLINE ModifierButtons ModifierButtons:: operator & (const ModifierButtons &other) const { ModifierButtons result = *this; @@ -79,15 +65,12 @@ operator & (const ModifierButtons &other) const { } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::operator | -// Access: Published -// Description: Returns a new ModifierButtons object for which -// is_down() will be true if it is true on either of the -// source objects. The set of buttons reported by -// has_button() is not completely defined if both source -// objects have a different set. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new ModifierButtons object for which is_down() will be true if it + * is true on either of the source objects. The set of buttons reported by + * has_button() is not completely defined if both source objects have a + * different set. + */ INLINE ModifierButtons ModifierButtons:: operator | (const ModifierButtons &other) const { ModifierButtons result = *this; @@ -95,61 +78,48 @@ operator | (const ModifierButtons &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::get_num_buttons -// Access: Published -// Description: Returns the number of buttons that the -// ModifierButtons object is monitoring (e.g. the number -// of buttons passed to add_button()). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of buttons that the ModifierButtons object is monitoring + * (e.g. the number of buttons passed to add_button()). + */ INLINE int ModifierButtons:: get_num_buttons() const { return _button_list.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::get_button -// Access: Published -// Description: Returns the nth button that the ModifierButtons -// object is monitoring (the nth button passed to -// add_button()). This must be in the range 0 <= index -// < get_num_buttons(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth button that the ModifierButtons object is monitoring (the + * nth button passed to add_button()). This must be in the range 0 <= index < + * get_num_buttons(). + */ INLINE ButtonHandle ModifierButtons:: get_button(int index) const { nassertr(index >= 0 && index < (int)_button_list.size(), ButtonHandle::none()); return _button_list[index]; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::all_buttons_up -// Access: Published -// Description: Marks all monitored buttons as being in the "up" -// state. -//////////////////////////////////////////////////////////////////// +/** + * Marks all monitored buttons as being in the "up" state. + */ INLINE void ModifierButtons:: all_buttons_up() { _state = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::is_down -// Access: Published -// Description: Returns true if the indicated button is known to be -// down, or false if it is known to be up. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is known to be down, or false if it is + * known to be up. + */ INLINE bool ModifierButtons:: is_down(int index) const { nassertr(index >= 0 && index < (int)_button_list.size(), false); return ((_state & ((BitmaskType)1 << index)) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::is_any_down -// Access: Published -// Description: Returns true if any of the tracked button are known -// to be down, or false if all of them are up. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the tracked button are known to be down, or false if + * all of them are up. + */ INLINE bool ModifierButtons:: is_any_down() const { return _state != 0; diff --git a/panda/src/putil/modifierButtons.cxx b/panda/src/putil/modifierButtons.cxx index bcd0123a12..a0c4a79146 100644 --- a/panda/src/putil/modifierButtons.cxx +++ b/panda/src/putil/modifierButtons.cxx @@ -1,26 +1,23 @@ -// Filename: modifierButtons.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modifierButtons.cxx + * @author drose + * @date 2000-03-01 + */ #include "modifierButtons.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ModifierButtons:: ModifierButtons() : _state(0) @@ -28,11 +25,9 @@ ModifierButtons() : _button_list = PTA(ButtonHandle)::empty_array(0); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ModifierButtons:: ModifierButtons(const ModifierButtons ©) : _button_list(copy._button_list), @@ -40,33 +35,29 @@ ModifierButtons(const ModifierButtons ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ModifierButtons:: ~ModifierButtons() { } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::operator &= -// Access: Published -// Description: Sets is_down() true for any button that is already -// true for this object and the other object. -//////////////////////////////////////////////////////////////////// +/** + * Sets is_down() true for any button that is already true for this object and + * the other object. + */ void ModifierButtons:: operator &= (const ModifierButtons &other) { if (_button_list == other._button_list) { - // Trivially easy case: if the button lists are the same, we can - // do this using a bitmask operation. + // Trivially easy case: if the button lists are the same, we can do this + // using a bitmask operation. _state &= other._state; } else { - // More complicated case: if the button lists are different, we - // have to iterate through the buttons and compare them - // case-by-case. This becomes an n^2 operation, but fortunately - // there won't be more than a handful of buttons. + // More complicated case: if the button lists are different, we have to + // iterate through the buttons and compare them case-by-case. This + // becomes an n^2 operation, but fortunately there won't be more than a + // handful of buttons. int num_buttons = get_num_buttons(); for (int i = 0; i < num_buttons; i++) { if (is_down(i) && !other.is_down(get_button(i))) { @@ -76,26 +67,23 @@ operator &= (const ModifierButtons &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::operator |= -// Access: Published -// Description: Sets is_down() true for any button that is already -// true for this object and the other object. Adds -// whatever buttons are necessary to the list to make -// this so -//////////////////////////////////////////////////////////////////// +/** + * Sets is_down() true for any button that is already true for this object and + * the other object. Adds whatever buttons are necessary to the list to make + * this so + */ void ModifierButtons:: operator |= (const ModifierButtons &other) { if (_button_list == other._button_list) { - // Trivially easy case: if the button lists are the same, we can - // do this using a bitmask operation. + // Trivially easy case: if the button lists are the same, we can do this + // using a bitmask operation. _state |= other._state; } else { - // More complicated case: if the button lists are different, we - // have to iterate through the buttons and compare them - // case-by-case. This becomes an n^2 operation, but fortunately - // there won't be more than a handful of buttons. + // More complicated case: if the button lists are different, we have to + // iterate through the buttons and compare them case-by-case. This + // becomes an n^2 operation, but fortunately there won't be more than a + // handful of buttons. int num_buttons = other.get_num_buttons(); for (int i = 0; i < num_buttons; i++) { if (other.is_down(i)) { @@ -106,25 +94,21 @@ operator |= (const ModifierButtons &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::set_button_list -// Access: Published -// Description: Sets the list of buttons to watch to be the same as -// that of the other ModifierButtons object. This makes -// the lists pointer equivalent (until one or the other -// is later modified). -// -// This will preserve the state of any button that was -// on the original list and is also on the new lists. -// Any other buttons will get reset to the default state -// of "up". -//////////////////////////////////////////////////////////////////// +/** + * Sets the list of buttons to watch to be the same as that of the other + * ModifierButtons object. This makes the lists pointer equivalent (until one + * or the other is later modified). + * + * This will preserve the state of any button that was on the original list + * and is also on the new lists. Any other buttons will get reset to the + * default state of "up". + */ void ModifierButtons:: set_button_list(const ModifierButtons &other) { if (_button_list != other._button_list) { if (_state != 0) { - // If we have some buttons already down, we have to copy them to - // the new state. + // If we have some buttons already down, we have to copy them to the new + // state. BitmaskType new_state = 0; int num_buttons = other.get_num_buttons(); for (int i = 0; i < num_buttons; i++) { @@ -132,7 +116,7 @@ set_button_list(const ModifierButtons &other) { new_state |= ((BitmaskType)1 << i); } } - + _state = new_state; } @@ -140,29 +124,26 @@ set_button_list(const ModifierButtons &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::matches -// Access: Published -// Description: Returns true if the set of buttons indicated as down -// by this ModifierButtons object is the same set of -// buttons indicated as down by the other -// ModifierButtons object. The buttons indicated as up -// are not relevant. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the set of buttons indicated as down by this + * ModifierButtons object is the same set of buttons indicated as down by the + * other ModifierButtons object. The buttons indicated as up are not + * relevant. + */ bool ModifierButtons:: matches(const ModifierButtons &other) const { if (_button_list == other._button_list) { - // If the two objects share the same array, we only need to check - // the bitmask. This is a simple optimization. + // If the two objects share the same array, we only need to check the + // bitmask. This is a simple optimization. return (_state == other._state); } - // The two objects do not share the same array; thus we have to do - // this one button at a time. This is an n-squared operation, but - // presumably there will not be hundreds of buttons to compare. + // The two objects do not share the same array; thus we have to do this one + // button at a time. This is an n-squared operation, but presumably there + // will not be hundreds of buttons to compare. - // First, check that all the buttons indicated as down in our object - // are also indicated as down in the other object. + // First, check that all the buttons indicated as down in our object are + // also indicated as down in the other object. int num_down = 0; int i; @@ -175,10 +156,9 @@ matches(const ModifierButtons &other) const { } } - // Now make sure the total number of buttons indicated as down in - // our object matches the number indicated as down in the other - // object. This ensures there aren't any additional buttons - // indicated down in the other object. + // Now make sure the total number of buttons indicated as down in our object + // matches the number indicated as down in the other object. This ensures + // there aren't any additional buttons indicated down in the other object. int num_other_buttons = other.get_num_buttons(); int num_other_down = 0; for (i = 0; i < num_other_buttons; i++) { @@ -190,15 +170,12 @@ matches(const ModifierButtons &other) const { return (num_down == num_other_down); } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::add_button -// Access: Published -// Description: Adds the indicated button to the set of buttons that -// will be monitored for upness and downness. Returns -// true if the button was added, false if it was already -// being monitored or if too many buttons are currently -// being monitored. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated button to the set of buttons that will be monitored for + * upness and downness. Returns true if the button was added, false if it was + * already being monitored or if too many buttons are currently being + * monitored. + */ bool ModifierButtons:: add_button(ButtonHandle button) { nassertr(button != ButtonHandle::none(), false); @@ -221,12 +198,10 @@ add_button(ButtonHandle button) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::has_button -// Access: Published -// Description: Returns true if the indicated button is in the set of -// buttons being monitored, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is in the set of buttons being + * monitored, false otherwise. + */ bool ModifierButtons:: has_button(ButtonHandle button) const { PTA(ButtonHandle)::const_iterator bi; @@ -239,31 +214,27 @@ has_button(ButtonHandle button) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::remove_button -// Access: Published -// Description: Removes the indicated button from the set of buttons -// being monitored. Returns true if the button was -// removed, false if it was not being monitored in the -// first place. -// -// Unlike the other methods, you cannot remove a button -// by removing its alias; you have to remove exactly the -// button itself. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated button from the set of buttons being monitored. + * Returns true if the button was removed, false if it was not being monitored + * in the first place. + * + * Unlike the other methods, you cannot remove a button by removing its alias; + * you have to remove exactly the button itself. + */ bool ModifierButtons:: remove_button(ButtonHandle button) { // We use i instead of an iterator, because we need to call - // modify_button_list() just before we remove the button, and that - // may invalidate all of the iterators. + // modify_button_list() just before we remove the button, and that may + // invalidate all of the iterators. for (int i = 0; i < (int)_button_list.size(); i++) { if (button == _button_list[i]) { modify_button_list(); _button_list.erase(_button_list.begin() + i); - // Now remove the corresponding bit from the bitmask and shift - // all the bits above it down. + // Now remove the corresponding bit from the bitmask and shift all the + // bits above it down. BitmaskType mask = ((BitmaskType)1 << i); BitmaskType below = mask - 1; BitmaskType above = (~below) & (~mask); @@ -276,16 +247,12 @@ remove_button(ButtonHandle button) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::button_down -// Access: Published -// Description: Records that a particular button has been pressed. -// If the given button is one of the buttons that is -// currently being monitored, this will update the -// internal state appropriately; otherwise, it will do -// nothing. Returns true if the button is one that was -// monitored, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Records that a particular button has been pressed. If the given button is + * one of the buttons that is currently being monitored, this will update the + * internal state appropriately; otherwise, it will do nothing. Returns true + * if the button is one that was monitored, or false otherwise. + */ bool ModifierButtons:: button_down(ButtonHandle button) { for (int i = 0; i < (int)_button_list.size(); i++) { @@ -298,16 +265,12 @@ button_down(ButtonHandle button) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::button_up -// Access: Published -// Description: Records that a particular button has been released. -// If the given button is one of the buttons that is -// currently being monitored, this will update the -// internal state appropriately; otherwise, it will do -// nothing. Returns true if the button is one that was -// monitored, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Records that a particular button has been released. If the given button is + * one of the buttons that is currently being monitored, this will update the + * internal state appropriately; otherwise, it will do nothing. Returns true + * if the button is one that was monitored, or false otherwise. + */ bool ModifierButtons:: button_up(ButtonHandle button) { for (int i = 0; i < (int)_button_list.size(); i++) { @@ -320,13 +283,10 @@ button_up(ButtonHandle button) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::is_down -// Access: Published -// Description: Returns true if the indicated button is known to be -// down, or false if it is known to be up or if it is -// not in the set of buttons being tracked. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is known to be down, or false if it is + * known to be up or if it is not in the set of buttons being tracked. + */ bool ModifierButtons:: is_down(ButtonHandle button) const { for (int i = 0; i < (int)_button_list.size(); i++) { @@ -338,13 +298,10 @@ is_down(ButtonHandle button) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::get_prefix -// Access: Published -// Description: Returns a string which can be used to prefix any -// button name or event name with the unique set of -// modifier buttons currently being held. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string which can be used to prefix any button name or event name + * with the unique set of modifier buttons currently being held. + */ string ModifierButtons:: get_prefix() const { string prefix; @@ -358,12 +315,9 @@ get_prefix() const { return prefix; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::output -// Access: Published -// Description: Writes a one-line summary of the buttons known to be -// down. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line summary of the buttons known to be down. + */ void ModifierButtons:: output(ostream &out) const { out << "["; @@ -375,13 +329,10 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::write -// Access: Published -// Description: Writes a multi-line summary including all of the -// buttons being monitored and which ones are known to -// be down. -//////////////////////////////////////////////////////////////////// +/** + * Writes a multi-line summary including all of the buttons being monitored + * and which ones are known to be down. + */ void ModifierButtons:: write(ostream &out) const { out << "ModifierButtons:\n"; @@ -394,18 +345,14 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ModifierButtons::modify_button_list -// Access: Private -// Description: Implements a poor-man's copy-on-write for the -// ModifierButtons class. If any reference counts are -// held on our _button_list, besides ourselves, then -// allocates and copies a brand new copy of the -// _button_list. This should be done in preparation for -// any modifications to the _button_list, since multiple -// instances of the ModifierButtons object may share the -// same _button_list pointer. -//////////////////////////////////////////////////////////////////// +/** + * Implements a poor-man's copy-on-write for the ModifierButtons class. If + * any reference counts are held on our _button_list, besides ourselves, then + * allocates and copies a brand new copy of the _button_list. This should be + * done in preparation for any modifications to the _button_list, since + * multiple instances of the ModifierButtons object may share the same + * _button_list pointer. + */ void ModifierButtons:: modify_button_list() { if (_button_list.get_ref_count() > 1) { @@ -413,8 +360,8 @@ modify_button_list() { _button_list = PTA(ButtonHandle)::empty_array(0); - // This forces a new allocation and memberwise copy, instead of - // just a reference-counting pointer copy. + // This forces a new allocation and memberwise copy, instead of just a + // reference-counting pointer copy. _button_list.v() = old_list.v(); } diff --git a/panda/src/putil/modifierButtons.h b/panda/src/putil/modifierButtons.h index 3dc40c61ba..d409b30f35 100644 --- a/panda/src/putil/modifierButtons.h +++ b/panda/src/putil/modifierButtons.h @@ -1,16 +1,15 @@ -// Filename: modifierButtons.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file modifierButtons.h + * @author drose + * @date 2000-03-01 + */ #ifndef MODIFIERBUTTONS_H #define MODIFIERBUTTONS_H @@ -20,12 +19,10 @@ #include "buttonHandle.h" #include "pointerToArray.h" -//////////////////////////////////////////////////////////////////// -// Class : ModifierButtons -// Description : This class monitors the state of a number of -// individual buttons and tracks whether each button is -// known to be down or up. -//////////////////////////////////////////////////////////////////// +/** + * This class monitors the state of a number of individual buttons and tracks + * whether each button is known to be down or up. + */ class EXPCL_PANDA_PUTIL ModifierButtons { PUBLISHED: ModifierButtons(); @@ -84,4 +81,3 @@ INLINE ostream &operator << (ostream &out, const ModifierButtons &mb) { #include "modifierButtons.I" #endif - diff --git a/panda/src/putil/mouseButton.cxx b/panda/src/putil/mouseButton.cxx index a0cbbc5485..5f3ebabbe1 100644 --- a/panda/src/putil/mouseButton.cxx +++ b/panda/src/putil/mouseButton.cxx @@ -1,16 +1,15 @@ -// Filename: mouseButton.cxx -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseButton.cxx + * @author drose + * @date 2000-03-01 + */ #include "mouseButton.h" #include "buttonRegistry.h" @@ -24,14 +23,11 @@ ButtonHandle MouseButton::_wheel_down; ButtonHandle MouseButton::_wheel_left; ButtonHandle MouseButton::_wheel_right; -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::button -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// particular numbered mouse button (zero-based), if -// there is one, or ButtonHandle::none() if there is -// not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the particular numbered mouse + * button (zero-based), if there is one, or ButtonHandle::none() if there is + * not. + */ ButtonHandle MouseButton:: button(int button_number) { if (button_number >= 0 && button_number < num_mouse_buttons) { @@ -40,113 +36,86 @@ button(int button_number) { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::one -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// first mouse button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the first mouse button. + */ ButtonHandle MouseButton:: one() { return _buttons[0]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::two -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// second mouse button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the second mouse button. + */ ButtonHandle MouseButton:: two() { return _buttons[1]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::three -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// third mouse button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the third mouse button. + */ ButtonHandle MouseButton:: three() { return _buttons[2]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::four -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// fourth mouse button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the fourth mouse button. + */ ButtonHandle MouseButton:: four() { return _buttons[3]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::five -// Access: Public, Static -// Description: Returns the ButtonHandle associated with the -// fifth mouse button. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle associated with the fifth mouse button. + */ ButtonHandle MouseButton:: five() { return _buttons[4]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::wheel_up -// Access: Public, Static -// Description: Returns the ButtonHandle generated when the mouse -// wheel is rolled one notch upwards. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle generated when the mouse wheel is rolled one notch + * upwards. + */ ButtonHandle MouseButton:: wheel_up() { return _wheel_up; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::wheel_down -// Access: Public, Static -// Description: Returns the ButtonHandle generated when the mouse -// wheel is rolled one notch downwards. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle generated when the mouse wheel is rolled one notch + * downwards. + */ ButtonHandle MouseButton:: wheel_down() { return _wheel_down; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::wheel_left -// Access: Public, Static -// Description: Returns the ButtonHandle generated when the mouse -// is scrolled to the left. Usually, you'll only -// find the horizontal scroll on laptops. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle generated when the mouse is scrolled to the left. + * Usually, you'll only find the horizontal scroll on laptops. + */ ButtonHandle MouseButton:: wheel_left() { return _wheel_left; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::wheel_right -// Access: Public, Static -// Description: Returns the ButtonHandle generated when the mouse -// is scrolled to the right. Usually, you'll only -// find the horizontal scroll on laptops. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ButtonHandle generated when the mouse is scrolled to the right. + * Usually, you'll only find the horizontal scroll on laptops. + */ ButtonHandle MouseButton:: wheel_right() { return _wheel_right; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::is_mouse_button -// Access: Public, Static -// Description: Returns true if the indicated ButtonHandle is a mouse -// button, false if it is some other kind of button. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated ButtonHandle is a mouse button, false if it + * is some other kind of button. + */ bool MouseButton:: is_mouse_button(ButtonHandle button) { for (int i = 0; i < num_mouse_buttons; ++i) { @@ -158,12 +127,10 @@ is_mouse_button(ButtonHandle button) { return button == _wheel_up || button == _wheel_down || button == _wheel_left || button == _wheel_right; } -//////////////////////////////////////////////////////////////////// -// Function: MouseButton::init_mouse_buttons -// Access: Public, Static -// Description: This is intended to be called only once, by the -// static initialization performed in config_util.cxx. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only once, by the static initialization + * performed in config_util.cxx. + */ void MouseButton:: init_mouse_buttons() { char numstr[20]; diff --git a/panda/src/putil/mouseButton.h b/panda/src/putil/mouseButton.h index 0199b822f4..c7e989e1ca 100644 --- a/panda/src/putil/mouseButton.h +++ b/panda/src/putil/mouseButton.h @@ -1,16 +1,15 @@ -// Filename: mouseButton.h -// Created by: drose (01Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseButton.h + * @author drose + * @date 2000-03-01 + */ #ifndef MOUSEBUTTON_H #define MOUSEBUTTON_H @@ -19,12 +18,10 @@ #include "buttonHandle.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseButton -// Description : This class is just used as a convenient namespace for -// grouping all of these handy functions that return -// buttons which map to standard mouse buttons. -//////////////////////////////////////////////////////////////////// +/** + * This class is just used as a convenient namespace for grouping all of these + * handy functions that return buttons which map to standard mouse buttons. + */ class EXPCL_PANDA_PUTIL MouseButton { PUBLISHED: static ButtonHandle button(int button_number); diff --git a/panda/src/putil/mouseData.I b/panda/src/putil/mouseData.I index 517832ef7b..bdcf750af6 100644 --- a/panda/src/putil/mouseData.I +++ b/panda/src/putil/mouseData.I @@ -1,23 +1,19 @@ -// Filename: mouseData.I -// Created by: drose (15Jul02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseData.I + * @author drose + * @date 2002-07-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseData::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseData:: MouseData() { _in_window = false; @@ -25,11 +21,9 @@ MouseData() { _ypos = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseData::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseData:: MouseData(const MouseData ©) : _in_window(copy._in_window), @@ -38,11 +32,9 @@ MouseData(const MouseData ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MouseData::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MouseData:: operator = (const MouseData ©) { _in_window = copy._in_window; @@ -50,31 +42,25 @@ operator = (const MouseData ©) { _ypos = copy._ypos; } -//////////////////////////////////////////////////////////////////// -// Function: MouseData::get_x -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double MouseData:: get_x() const { return _xpos; } -//////////////////////////////////////////////////////////////////// -// Function: MouseData::get_y -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double MouseData:: get_y() const { return _ypos; } -//////////////////////////////////////////////////////////////////// -// Function: MouseData::get_in_window -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool MouseData:: get_in_window() const { return _in_window; diff --git a/panda/src/putil/mouseData.cxx b/panda/src/putil/mouseData.cxx index c1d87fe054..8149672c9b 100644 --- a/panda/src/putil/mouseData.cxx +++ b/panda/src/putil/mouseData.cxx @@ -1,24 +1,21 @@ -// Filename: mouseData.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseData.cxx + * @author drose + * @date 1999-02-08 + */ #include "mouseData.h" -//////////////////////////////////////////////////////////////////// -// Function: MouseData::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseData:: output(ostream &out) const { if (!_in_window) { diff --git a/panda/src/putil/mouseData.h b/panda/src/putil/mouseData.h index 27464db200..4fe2c81b4f 100644 --- a/panda/src/putil/mouseData.h +++ b/panda/src/putil/mouseData.h @@ -1,16 +1,15 @@ -// Filename: mouseData.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseData.h + * @author drose + * @date 1999-02-08 + */ #ifndef MOUSEDATA_H #define MOUSEDATA_H @@ -19,12 +18,10 @@ #include "modifierButtons.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseData -// Description : Holds the data that might be generated by a 2-d -// pointer input device, such as the mouse in the -// GraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Holds the data that might be generated by a 2-d pointer input device, such + * as the mouse in the GraphicsWindow. + */ class EXPCL_PANDA_PUTIL MouseData { PUBLISHED: INLINE MouseData(); @@ -52,5 +49,3 @@ INLINE ostream &operator << (ostream &out, const MouseData &md); #include "mouseData.I" #endif - - diff --git a/panda/src/putil/nameUniquifier.I b/panda/src/putil/nameUniquifier.I index b02a447186..4ccfa1e0b0 100644 --- a/panda/src/putil/nameUniquifier.I +++ b/panda/src/putil/nameUniquifier.I @@ -1,59 +1,47 @@ -// Filename: nameUniquifier.I -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nameUniquifier.I + * @author drose + * @date 2000-02-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NameUniquifier::add_name -// Access: Public -// Description: If name is nonempty and so far unique, returns it -// unchanged. -// -// Otherwise, generates and returns a new name according -// to the following rules: -// -// If the name is empty, the new name is the -// NameUniquifier's "empty" string followed by a number, -// or the "separator" string if the "empty" string is -// empty. -// -// If the name is nonempty, the new name is the original -// name, followed by the NameUniquifier's "separator" -// string, followed by a number. -//////////////////////////////////////////////////////////////////// +/** + * If name is nonempty and so far unique, returns it unchanged. + * + * Otherwise, generates and returns a new name according to the following + * rules: + * + * If the name is empty, the new name is the NameUniquifier's "empty" string + * followed by a number, or the "separator" string if the "empty" string is + * empty. + * + * If the name is nonempty, the new name is the original name, followed by the + * NameUniquifier's "separator" string, followed by a number. + */ INLINE string NameUniquifier:: add_name(const string &name) { return add_name_body(name, name); } -//////////////////////////////////////////////////////////////////// -// Function: NameUniquifier::add_name -// Access: Public -// Description: If name is nonempty and so far unique, returns it -// unchanged. -// -// Otherwise, generates and returns a new name according -// to the following rules: -// -// If the prefix is empty, the new name is the -// NameUniquifier's "empty" string followed by a number, -// or the "separator" string if the "empty" string is -// empty. -// -// If the prefix is nonempty, the new name is the -// prefix, followed by the NameUniquifier's "separator" -// string, followed by a number. -//////////////////////////////////////////////////////////////////// +/** + * If name is nonempty and so far unique, returns it unchanged. + * + * Otherwise, generates and returns a new name according to the following + * rules: + * + * If the prefix is empty, the new name is the NameUniquifier's "empty" string + * followed by a number, or the "separator" string if the "empty" string is + * empty. + * + * If the prefix is nonempty, the new name is the prefix, followed by the + * NameUniquifier's "separator" string, followed by a number. + */ INLINE string NameUniquifier:: add_name(const string &name, const string &prefix) { return add_name_body(name, prefix); diff --git a/panda/src/putil/nameUniquifier.cxx b/panda/src/putil/nameUniquifier.cxx index 0806a46558..0629a58ac9 100644 --- a/panda/src/putil/nameUniquifier.cxx +++ b/panda/src/putil/nameUniquifier.cxx @@ -1,16 +1,15 @@ -// Filename: nameUniquifier.cxx -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nameUniquifier.cxx + * @author drose + * @date 2000-02-16 + */ #include "nameUniquifier.h" @@ -19,18 +18,15 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: NameUniquifier::Constructor -// Access: Public -// Description: Creates a new NameUniquifier. -// -// The separator string is used to separate the original -// name (or supplied prefix) and the generated number -// when a name must be generated. -// -// If the original name is empty, the empty string is -// used, followed by the generated number. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new NameUniquifier. + * + * The separator string is used to separate the original name (or supplied + * prefix) and the generated number when a name must be generated. + * + * If the original name is empty, the empty string is used, followed by the + * generated number. + */ NameUniquifier:: NameUniquifier(const string &separator, const string &empty) : @@ -44,42 +40,34 @@ NameUniquifier(const string &separator, } } -//////////////////////////////////////////////////////////////////// -// Function: NameUniquifier::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ NameUniquifier:: ~NameUniquifier() { } -//////////////////////////////////////////////////////////////////// -// Function: NameUniquifier::add_name_body -// Access: Private -// Description: The actual implementation of the two flavors of -// add_name(). -// -// If name is nonempty and so far unique, returns it -// unchanged. -// -// Otherwise, generates and returns a new name according -// to the following rules: -// -// If the prefix is empty, the new name is the -// NameUniquifier's "empty" string followed by a number, -// or the "separator" string if the "empty" string is -// empty. -// -// If the prefix is nonempty, the new name is the -// prefix, followed by the NameUniquifier's "separator" -// string, followed by a number. -//////////////////////////////////////////////////////////////////// +/** + * The actual implementation of the two flavors of add_name(). + * + * If name is nonempty and so far unique, returns it unchanged. + * + * Otherwise, generates and returns a new name according to the following + * rules: + * + * If the prefix is empty, the new name is the NameUniquifier's "empty" string + * followed by a number, or the "separator" string if the "empty" string is + * empty. + * + * If the prefix is nonempty, the new name is the prefix, followed by the + * NameUniquifier's "separator" string, followed by a number. + */ string NameUniquifier:: add_name_body(const string &name, const string &prefix) { if (!name.empty()) { if (_names.insert(name).second) { - // The name was successfully inserted into the set; therefore, - // it's unique. Return it. + // The name was successfully inserted into the set; therefore, it's + // unique. Return it. return name; } } @@ -104,4 +92,3 @@ add_name_body(const string &name, const string &prefix) { return temp_name; } - diff --git a/panda/src/putil/nameUniquifier.h b/panda/src/putil/nameUniquifier.h index c7a28437fc..7b629771d2 100644 --- a/panda/src/putil/nameUniquifier.h +++ b/panda/src/putil/nameUniquifier.h @@ -1,16 +1,15 @@ -// Filename: nameUniquifier.h -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nameUniquifier.h + * @author drose + * @date 2000-02-16 + */ #ifndef NAMEUNIQUIFIER_H #define NAMEUNIQUIFIER_H @@ -20,14 +19,12 @@ #include #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : NameUniquifier -// Description : A handy class for converting a list of arbitrary -// names (strings) so that each name is guaranteed to be -// unique in the list. Useful for writing egg files -// with unique vertex pool names, or for file converters -// to file formats that require unique node names, etc. -//////////////////////////////////////////////////////////////////// +/** + * A handy class for converting a list of arbitrary names (strings) so that + * each name is guaranteed to be unique in the list. Useful for writing egg + * files with unique vertex pool names, or for file converters to file formats + * that require unique node names, etc. + */ class EXPCL_PANDA_PUTIL NameUniquifier { public: NameUniquifier(const string &separator = string(), diff --git a/panda/src/putil/nodeCachedReferenceCount.I b/panda/src/putil/nodeCachedReferenceCount.I index b4a373fca7..c06016d523 100644 --- a/panda/src/putil/nodeCachedReferenceCount.I +++ b/panda/src/putil/nodeCachedReferenceCount.I @@ -1,134 +1,112 @@ -// Filename: nodeCachedReferenceCount.I -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCachedReferenceCount.I + * @author drose + * @date 2005-05-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::Constructor -// Access: Protected -// Description: The ReferenceCount constructor is protected because -// you almost never want to create just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. -// -// ReferenceCount doesn't store any useful information -// in its own right; its only purpose is to add -// reference-counting to some other class via -// inheritance. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount constructor is protected because you almost never want + * to create just a ReferenceCount object by itself, and it's probably a + * mistake if you try. + * + * ReferenceCount doesn't store any useful information in its own right; its + * only purpose is to add reference-counting to some other class via + * inheritance. + */ INLINE NodeCachedReferenceCount:: NodeCachedReferenceCount() { _node_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::Copy Constructor -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy constructor is protected because you almost -// never want to create just a ReferenceCount object by -// itself, and it's probably a mistake if you try. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy constructor is protected because you almost never want to create + * just a ReferenceCount object by itself, and it's probably a mistake if you + * try. + */ INLINE NodeCachedReferenceCount:: NodeCachedReferenceCount(const NodeCachedReferenceCount ©) : CachedTypedWritableReferenceCount(copy) { _node_ref_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::Copy Assignment Operator -// Access: Protected -// Description: The copies of reference-counted objects do not -// themselves inherit the reference count! -// -// This copy assignment operator is protected because -// you almost never want to copy just a ReferenceCount -// object by itself, and it's probably a mistake if you -// try. Instead, this should only be called from a -// derived class that implements this operator and then -// calls up the inheritance chain. -//////////////////////////////////////////////////////////////////// +/** + * The copies of reference-counted objects do not themselves inherit the + * reference count! + * + * This copy assignment operator is protected because you almost never want to + * copy just a ReferenceCount object by itself, and it's probably a mistake if + * you try. Instead, this should only be called from a derived class that + * implements this operator and then calls up the inheritance chain. + */ INLINE void NodeCachedReferenceCount:: operator = (const NodeCachedReferenceCount ©) { nassertv(this != NULL); - // If this assertion fails, our own pointer was recently deleted. - // Possibly you used a real pointer instead of a PointerTo at some - // point, and the object was deleted when the PointerTo went out of - // scope. Maybe you tried to create an automatic (local variable) - // instance of a class that derives from ReferenceCount. Or maybe - // your headers are out of sync, and you need to make clean in - // direct or some higher tree. + // If this assertion fails, our own pointer was recently deleted. Possibly + // you used a real pointer instead of a PointerTo at some point, and the + // object was deleted when the PointerTo went out of scope. Maybe you tried + // to create an automatic (local variable) instance of a class that derives + // from ReferenceCount. Or maybe your headers are out of sync, and you need + // to make clean in direct or some higher tree. nassertv(_node_ref_count != -100); CachedTypedWritableReferenceCount::operator = (copy); } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::Destructor -// Access: Protected -// Description: The ReferenceCount destructor is protected to -// discourage users from accidentally trying to delete a -// ReferenceCount pointer directly. This is almost -// always a bad idea, since the destructor is not -// virtual, and you've almost certainly got some pointer -// to something that inherits from ReferenceCount, not -// just a plain old ReferenceCount object. -//////////////////////////////////////////////////////////////////// +/** + * The ReferenceCount destructor is protected to discourage users from + * accidentally trying to delete a ReferenceCount pointer directly. This is + * almost always a bad idea, since the destructor is not virtual, and you've + * almost certainly got some pointer to something that inherits from + * ReferenceCount, not just a plain old ReferenceCount object. + */ INLINE NodeCachedReferenceCount:: ~NodeCachedReferenceCount() { nassertv(this != NULL); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertv(_node_ref_count != -100); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertv(_node_ref_count >= 0); - // If this assertion fails, someone tried to delete this object - // while its reference count was still positive. Maybe you tried - // to point a PointerTo at a static object (a local variable, - // instead of one allocated via new)? The test below against 0x7f - // is supposed to check for that, but it's a pretty hokey test. + // If this assertion fails, someone tried to delete this object while its + // reference count was still positive. Maybe you tried to point a PointerTo + // at a static object (a local variable, instead of one allocated via new)? + // The test below against 0x7f is supposed to check for that, but it's a + // pretty hokey test. - // Another possibility is you inadvertently omitted a copy - // constructor for a ReferenceCount object, and then bitwise - // copied a dynamically allocated value--reference count and - // all--onto a locally allocated one. + // Another possibility is you inadvertently omitted a copy constructor for a + // ReferenceCount object, and then bitwise copied a dynamically allocated + // value--reference count and all--onto a locally allocated one. nassertv(_node_ref_count == 0); #ifndef NDEBUG - // Ok, all clear to delete. Now set the reference count to -100, - // so we'll have a better chance of noticing if we happen to have - // a stray pointer to it still out there. + // Ok, all clear to delete. Now set the reference count to -100, so we'll + // have a better chance of noticing if we happen to have a stray pointer to + // it still out there. _node_ref_count = -100; #endif } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::get_node_ref_count -// Access: Published -// Description: Returns the current reference count. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current reference count. + */ INLINE int NodeCachedReferenceCount:: get_node_ref_count() const { #ifdef _DEBUG @@ -137,18 +115,14 @@ get_node_ref_count() const { return (int)AtomicAdjust::get(_node_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::node_ref -// Access: Published -// Description: Explicitly increments the reference count. -// -// This function is const, even though it changes the -// object, because generally fiddling with an object's -// reference count isn't considered part of fiddling -// with the object. An object might be const in other -// ways, but we still need to accurately count the -// number of references to it. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly increments the reference count. + * + * This function is const, even though it changes the object, because + * generally fiddling with an object's reference count isn't considered part + * of fiddling with the object. An object might be const in other ways, but + * we still need to accurately count the number of references to it. + */ INLINE void NodeCachedReferenceCount:: node_ref() const { #ifdef _DEBUG @@ -159,27 +133,23 @@ node_ref() const { AtomicAdjust::inc(((NodeCachedReferenceCount *)this)->_node_ref_count); } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::node_unref -// Access: Published -// Description: Explicitly decrements the node reference count and -// the normal reference count simultaneously. -// -// The return value is true if the new reference count -// is nonzero, false if it is zero. -//////////////////////////////////////////////////////////////////// +/** + * Explicitly decrements the node reference count and the normal reference + * count simultaneously. + * + * The return value is true if the new reference count is nonzero, false if it + * is zero. + */ INLINE bool NodeCachedReferenceCount:: node_unref() const { node_unref_only(); return unref(); } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::test_ref_count_integrity -// Access: Published -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ INLINE bool NodeCachedReferenceCount:: test_ref_count_integrity() const { #ifndef NDEBUG @@ -189,17 +159,14 @@ test_ref_count_integrity() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::get_referenced_bits -// Access: Published -// Description: Returns the union of the values defined in the -// Referenced enum that represents the various things -// that appear to be holding a pointer to this object. -// -// If R_node is included, at least one node is holding a -// pointer; if R_cache is included, at least one cache -// element is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of the values defined in the Referenced enum that + * represents the various things that appear to be holding a pointer to this + * object. + * + * If R_node is included, at least one node is holding a pointer; if R_cache + * is included, at least one cache element is. + */ INLINE int NodeCachedReferenceCount:: get_referenced_bits() const { int result = 0; @@ -213,23 +180,20 @@ get_referenced_bits() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::node_unref_only -// Access: Protected -// Description: Decrements the node reference count without affecting -// the normal reference count. Intended to be called by -// derived classes only, presumably to reimplement -// node_unref(). -//////////////////////////////////////////////////////////////////// +/** + * Decrements the node reference count without affecting the normal reference + * count. Intended to be called by derived classes only, presumably to + * reimplement node_unref(). + */ INLINE void NodeCachedReferenceCount:: node_unref_only() const { #ifdef _DEBUG nassertv(test_ref_count_integrity()); #endif - // If this assertion fails, you tried to unref an object with a - // zero reference count. Are you using ref() and unref() - // directly? Are you sure you can't use PointerTo's? + // If this assertion fails, you tried to unref an object with a zero + // reference count. Are you using ref() and unref() directly? Are you sure + // you can't use PointerTo's? nassertv(_node_ref_count > 0); AtomicAdjust::dec(((NodeCachedReferenceCount *)this)->_node_ref_count); diff --git a/panda/src/putil/nodeCachedReferenceCount.cxx b/panda/src/putil/nodeCachedReferenceCount.cxx index 99000db562..62249dcd42 100644 --- a/panda/src/putil/nodeCachedReferenceCount.cxx +++ b/panda/src/putil/nodeCachedReferenceCount.cxx @@ -1,43 +1,38 @@ -// Filename: nodeCachedReferenceCount.cxx -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCachedReferenceCount.cxx + * @author drose + * @date 2005-05-07 + */ #include "nodeCachedReferenceCount.h" TypeHandle NodeCachedReferenceCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: NodeCachedReferenceCount::do_test_ref_count_integrity -// Access: Protected -// Description: Does some easy checks to make sure that the reference -// count isn't completely bogus. -//////////////////////////////////////////////////////////////////// +/** + * Does some easy checks to make sure that the reference count isn't + * completely bogus. + */ bool NodeCachedReferenceCount:: do_test_ref_count_integrity() const { nassertr(this != NULL, false); - // If this assertion fails, we're trying to delete an object that - // was just deleted. Possibly you used a real pointer instead of a - // PointerTo at some point, and the object was deleted when the - // PointerTo went out of scope. Maybe you tried to create an - // automatic (local variable) instance of a class that derives from - // ReferenceCount. Or maybe your headers are out of sync, and you - // need to make clean in direct or some higher tree. + // If this assertion fails, we're trying to delete an object that was just + // deleted. Possibly you used a real pointer instead of a PointerTo at some + // point, and the object was deleted when the PointerTo went out of scope. + // Maybe you tried to create an automatic (local variable) instance of a + // class that derives from ReferenceCount. Or maybe your headers are out of + // sync, and you need to make clean in direct or some higher tree. nassertr(_node_ref_count != -100, false); - // If this assertion fails, the reference counts are all screwed - // up altogether. Maybe some errant code stomped all over memory - // somewhere. + // If this assertion fails, the reference counts are all screwed up + // altogether. Maybe some errant code stomped all over memory somewhere. nassertr(_node_ref_count >= 0, false); return CachedTypedWritableReferenceCount::do_test_ref_count_integrity(); diff --git a/panda/src/putil/nodeCachedReferenceCount.h b/panda/src/putil/nodeCachedReferenceCount.h index 975b5e2ab2..1ed34650b6 100644 --- a/panda/src/putil/nodeCachedReferenceCount.h +++ b/panda/src/putil/nodeCachedReferenceCount.h @@ -1,16 +1,15 @@ -// Filename: nodeCachedReferenceCount.h -// Created by: drose (07May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file nodeCachedReferenceCount.h + * @author drose + * @date 2005-05-07 + */ #ifndef NODECACHEDREFERENCECOUNT_H #define NODECACHEDREFERENCECOUNT_H @@ -20,44 +19,33 @@ #include "cachedTypedWritableReferenceCount.h" #include "nodeReferenceCount.h" // for node_unref_delete() -//////////////////////////////////////////////////////////////////// -// Class : NodeCachedReferenceCount -// Description : This class further specializes -// CachedTypedWritableReferenceCount to also add a -// node_ref_count, for the purposes of counting the -// number of times the object is referenced by a "node", -// presumably a PandaNode. -// -// This essentially combines the functionality of -// NodeReferenceCount and -// CachedTypedWritableReferenceCount, so that a -// derivative of this object actually has three -// counters: the standard reference count, the "cache" -// reference count, and the "node" reference count. -// Rather than multiply inheriting from the two -// reference count classes, we inherit only from -// CachedTypedWritableReferenceCount and simply -// duplicate the functionality of NodeReferenceCount, to -// avoid all of the problems associated with multiple -// inheritance. -// -// The intended design is to use this as a base class -// for RenderState and TransformState, both of which are -// held by PandaNodes, and also have caches which are -// independently maintained. By keeping track of how -// many nodes hold a pointer to a particular object, we -// can classify each object into node-referenced, -// cache-referenced, or other, which is primarily useful -// for PStats reporting. -// -// As with CachedTypedWritableReferenceCount's -// cache_ref() and cache_unref(), the new methods -// node_ref() and node_unref() automatically increment -// and decrement the primary reference count as well. -// In this case, however, there does exist a -// NodePointerTo<> class to maintain the node_ref -// counters automatically. -//////////////////////////////////////////////////////////////////// +/** + * This class further specializes CachedTypedWritableReferenceCount to also + * add a node_ref_count, for the purposes of counting the number of times the + * object is referenced by a "node", presumably a PandaNode. + * + * This essentially combines the functionality of NodeReferenceCount and + * CachedTypedWritableReferenceCount, so that a derivative of this object + * actually has three counters: the standard reference count, the "cache" + * reference count, and the "node" reference count. Rather than multiply + * inheriting from the two reference count classes, we inherit only from + * CachedTypedWritableReferenceCount and simply duplicate the functionality of + * NodeReferenceCount, to avoid all of the problems associated with multiple + * inheritance. + * + * The intended design is to use this as a base class for RenderState and + * TransformState, both of which are held by PandaNodes, and also have caches + * which are independently maintained. By keeping track of how many nodes + * hold a pointer to a particular object, we can classify each object into + * node-referenced, cache-referenced, or other, which is primarily useful for + * PStats reporting. + * + * As with CachedTypedWritableReferenceCount's cache_ref() and cache_unref(), + * the new methods node_ref() and node_unref() automatically increment and + * decrement the primary reference count as well. In this case, however, + * there does exist a NodePointerTo<> class to maintain the node_ref counters + * automatically. + */ class EXPCL_PANDA_PUTIL NodeCachedReferenceCount : public CachedTypedWritableReferenceCount { protected: INLINE NodeCachedReferenceCount(); @@ -81,7 +69,7 @@ PUBLISHED: protected: INLINE void node_unref_only() const; bool do_test_ref_count_integrity() const; - + private: AtomicAdjust::Integer _node_ref_count; @@ -102,5 +90,4 @@ private: #include "nodeCachedReferenceCount.I" -#endif - +#endif diff --git a/panda/src/putil/paramValue.I b/panda/src/putil/paramValue.I index 30846fe300..f446b88dad 100644 --- a/panda/src/putil/paramValue.I +++ b/panda/src/putil/paramValue.I @@ -1,57 +1,46 @@ -// Filename: paramValue.I -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramValue.I + * @author drose + * @date 1999-02-08 + */ template TypeHandle ParamValue::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParamValueBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ParamValueBase:: ParamValueBase() { } -//////////////////////////////////////////////////////////////////// -// Function: ParamValueBase::get_value_type -// Access: Published, Virtual -// Description: Returns the type of the underlying value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the underlying value. + */ INLINE TypeHandle ParamValueBase:: get_value_type() const { return TypeHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: ParamTypedRefCount::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ParamTypedRefCount:: ParamTypedRefCount(const TypedReferenceCount *value) : _value((TypedReferenceCount *)value) { } -//////////////////////////////////////////////////////////////////// -// Function: ParamTypedRefCount::get_value_type -// Access: Published -// Description: Retrieves the type of the value stored in the -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the type of the value stored in the parameter. + */ INLINE TypeHandle ParamTypedRefCount:: get_value_type() const { if (_value == NULL) { @@ -61,30 +50,24 @@ get_value_type() const { } } -//////////////////////////////////////////////////////////////////// -// Function: ParamTypedRefCount::get_value -// Access: Published -// Description: Retrieves the value stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the parameter. + */ INLINE TypedReferenceCount *ParamTypedRefCount:: get_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ParamValue:: ParamValue() {} -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ParamValue:: ParamValue(const Type &value) : @@ -92,33 +75,26 @@ ParamValue(const Type &value) : { } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE ParamValue:: ~ParamValue() { } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::get_value_type -// Access: Public, Virtual -// Description: Retrieves the type of the value stored in the -// parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the type of the value stored in the parameter. + */ template INLINE TypeHandle ParamValue:: get_value_type() const { return get_type_handle(Type); } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::set_value -// Access: Public, Virtual -// Description: Changes the value stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value stored in the parameter. + */ template INLINE void ParamValue:: set_value(const Type &type) { @@ -126,46 +102,37 @@ set_value(const Type &type) { mark_bam_modified(); } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::get_value -// Access: Public -// Description: Retrieves the value stored in the parameter. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the value stored in the parameter. + */ template INLINE const Type &ParamValue:: get_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE void ParamValue:: output(ostream &out) const { out << _value; } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type ParamValue. + */ template INLINE void ParamValue:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ template INLINE void ParamValue:: write_datagram(BamWriter *manager, Datagram &dg) { @@ -173,14 +140,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { generic_write_datagram(dg, _value); } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type ParamValue is encountered -// in the Bam file. It should create the ParamValue -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type ParamValue is encountered in the Bam file. It should create the + * ParamValue and extract its information from the file. + */ template INLINE TypedWritable *ParamValue:: make_from_bam(const FactoryParams ¶ms) { @@ -194,13 +158,10 @@ make_from_bam(const FactoryParams ¶ms) { return esv; } -//////////////////////////////////////////////////////////////////// -// Function: ParamValue::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new ParamValue. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new ParamValue. + */ template INLINE void ParamValue:: fillin(DatagramIterator &scan, BamReader *manager) { diff --git a/panda/src/putil/paramValue.cxx b/panda/src/putil/paramValue.cxx index 3f67ee1de9..e2ee6dadf1 100644 --- a/panda/src/putil/paramValue.cxx +++ b/panda/src/putil/paramValue.cxx @@ -1,16 +1,15 @@ -// Filename: paramValue.cxx -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramValue.cxx + * @author drose + * @date 1999-02-08 + */ #include "paramValue.h" #include "dcast.h" @@ -44,29 +43,23 @@ template class ParamValue; TypeHandle ParamValueBase::_type_handle; TypeHandle ParamTypedRefCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ParamValueBase::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParamValueBase:: ~ParamValueBase() { } -//////////////////////////////////////////////////////////////////// -// Function: ParamTypedRefCount::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ParamTypedRefCount:: ~ParamTypedRefCount() { } -//////////////////////////////////////////////////////////////////// -// Function: ParamTypedRefCount::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ParamTypedRefCount:: output(ostream &out) const { if (_value == (TypedReferenceCount *)NULL) { diff --git a/panda/src/putil/paramValue.h b/panda/src/putil/paramValue.h index f30be3da15..a75b4360b3 100644 --- a/panda/src/putil/paramValue.h +++ b/panda/src/putil/paramValue.h @@ -1,16 +1,15 @@ -// Filename: paramValue.h -// Created by: drose (08Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paramValue.h + * @author drose + * @date 1999-02-08 + */ #ifndef PARAMVALUE_H #define PARAMVALUE_H @@ -25,12 +24,10 @@ #include "bamWriter.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : ParamValueBase -// Description : A non-template base class of ParamValue (below), -// which serves mainly to define the placeholder for the -// virtual output function. -//////////////////////////////////////////////////////////////////// +/** + * A non-template base class of ParamValue (below), which serves mainly to + * define the placeholder for the virtual output function. + */ class EXPCL_PANDA_PUTIL ParamValueBase : public TypedWritableReferenceCount { public: INLINE ParamValueBase(); @@ -58,12 +55,10 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ParamTypedRefCount -// Description : A class object for storing specifically objects of -// type TypedReferenceCount, which is different than -// TypedWritableReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * A class object for storing specifically objects of type + * TypedReferenceCount, which is different than TypedWritableReferenceCount. + */ class EXPCL_PANDA_PUTIL ParamTypedRefCount : public ParamValueBase { PUBLISHED: INLINE ParamTypedRefCount(const TypedReferenceCount *value); @@ -97,16 +92,13 @@ private: static TypeHandle _type_handle; }; -//////////////////////////////////////////////////////////////////// -// Class : ParamValue -// Description : A handy class object for storing simple values (like -// integers or strings) passed along with an Event -// or to be used as a shader input. -// This is essentially just a wrapper around whatever -// data type you like, to make it a -// TypedWritableReferenceCount object which can be -// passed along inside an EventParameter or ShaderInput. -//////////////////////////////////////////////////////////////////// +/** + * A handy class object for storing simple values (like integers or strings) + * passed along with an Event or to be used as a shader input. This is + * essentially just a wrapper around whatever data type you like, to make it a + * TypedWritableReferenceCount object which can be passed along inside an + * EventParameter or ShaderInput. + */ template class ParamValue : public ParamValueBase { protected: @@ -148,8 +140,8 @@ public: return get_class_type(); } virtual TypeHandle force_init_type() { - // In this case, we can't do anything, since we don't have the - // class' type_name. + // In this case, we can't do anything, since we don't have the class' + // type_name. return get_class_type(); } diff --git a/panda/src/putil/pbitops.I b/panda/src/putil/pbitops.I index 3e3024df42..f746b8ba77 100644 --- a/panda/src/putil/pbitops.I +++ b/panda/src/putil/pbitops.I @@ -1,31 +1,27 @@ -// Filename: pbitops.I -// Created by: drose (10May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pbitops.I + * @author drose + * @date 2008-05-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: count_bits_in_word -// Description: Returns the number of 1 bits in the indicated word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of 1 bits in the indicated word. + */ INLINE int count_bits_in_word(PN_uint16 x) { return (int)num_bits_on[x]; } -//////////////////////////////////////////////////////////////////// -// Function: count_bits_in_word -// Description: Returns the number of 1 bits in the indicated word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of 1 bits in the indicated word. + */ INLINE int count_bits_in_word(PN_uint32 x) { #if defined(__GNUC__) && defined(__POPCNT__) @@ -35,10 +31,9 @@ count_bits_in_word(PN_uint32 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: count_bits_in_word -// Description: Returns the number of 1 bits in the indicated word. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of 1 bits in the indicated word. + */ INLINE int count_bits_in_word(PN_uint64 x) { #if defined(__GNUC__) && defined(__POPCNT__) @@ -48,11 +43,9 @@ count_bits_in_word(PN_uint64 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_down -// Description: Returns a value such that every bit at or below the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or below the highest bit in x is 1. + */ INLINE PN_uint16 flood_bits_down(PN_uint16 x) { x |= (x >> 1); @@ -62,11 +55,9 @@ flood_bits_down(PN_uint16 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_down -// Description: Returns a value such that every bit at or below the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or below the highest bit in x is 1. + */ INLINE PN_uint32 flood_bits_down(PN_uint32 x) { x |= (x >> 1); @@ -77,11 +68,9 @@ flood_bits_down(PN_uint32 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_down -// Description: Returns a value such that every bit at or below the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or below the highest bit in x is 1. + */ INLINE PN_uint64 flood_bits_down(PN_uint64 x) { x |= (x >> 1); @@ -93,11 +82,9 @@ flood_bits_down(PN_uint64 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_up -// Description: Returns a value such that every bit at or above the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or above the highest bit in x is 1. + */ INLINE PN_uint16 flood_bits_up(PN_uint16 x) { x |= (x << 1); @@ -107,11 +94,9 @@ flood_bits_up(PN_uint16 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_up -// Description: Returns a value such that every bit at or above the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or above the highest bit in x is 1. + */ INLINE PN_uint32 flood_bits_up(PN_uint32 x) { x |= (x << 1); @@ -122,11 +107,9 @@ flood_bits_up(PN_uint32 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: flood_bits_up -// Description: Returns a value such that every bit at or above the -// highest bit in x is 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns a value such that every bit at or above the highest bit in x is 1. + */ INLINE PN_uint64 flood_bits_up(PN_uint64 x) { x |= (x << 1); @@ -138,11 +121,10 @@ flood_bits_up(PN_uint64 x) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: get_lowest_on_bit -// Description: Returns the index of the lowest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the word. Returns -1 if there are + * no 1 bits. + */ INLINE int get_lowest_on_bit(PN_uint16 x) { #if defined(_MSC_VER) @@ -160,11 +142,10 @@ get_lowest_on_bit(PN_uint16 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_lowest_on_bit -// Description: Returns the index of the lowest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the word. Returns -1 if there are + * no 1 bits. + */ INLINE int get_lowest_on_bit(PN_uint32 x) { #if defined(_MSC_VER) @@ -182,11 +163,10 @@ get_lowest_on_bit(PN_uint32 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_lowest_on_bit -// Description: Returns the index of the lowest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the word. Returns -1 if there are + * no 1 bits. + */ INLINE int get_lowest_on_bit(PN_uint64 x) { #if defined(_MSC_VER) && defined(_M_X64) @@ -204,11 +184,10 @@ get_lowest_on_bit(PN_uint64 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_highest_on_bit -// Description: Returns the index of the highest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the word. Returns -1 if there + * are no 1 bits. + */ INLINE int get_highest_on_bit(PN_uint16 x) { #if defined(_MSC_VER) @@ -222,11 +201,10 @@ get_highest_on_bit(PN_uint16 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_highest_on_bit -// Description: Returns the index of the highest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the word. Returns -1 if there + * are no 1 bits. + */ INLINE int get_highest_on_bit(PN_uint32 x) { #if defined(_MSC_VER) @@ -240,11 +218,10 @@ get_highest_on_bit(PN_uint32 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_highest_on_bit -// Description: Returns the index of the highest 1 bit in the word. -// Returns -1 if there are no 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the word. Returns -1 if there + * are no 1 bits. + */ INLINE int get_highest_on_bit(PN_uint64 x) { #if defined(_MSC_VER) && defined(_M_X64) @@ -258,37 +235,31 @@ get_highest_on_bit(PN_uint64 x) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: get_next_higher_bit -// Description: Returns the smallest power of 2 greater than x. -// -// Returns the smallest number n such that (1 << n) is -// larger than x. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest power of 2 greater than x. + * + * Returns the smallest number n such that (1 << n) is larger than x. + */ INLINE int get_next_higher_bit(PN_uint16 x) { return get_highest_on_bit(x) + 1; } -//////////////////////////////////////////////////////////////////// -// Function: get_next_higher_bit -// Description: Returns the smallest power of 2 greater than x. -// -// Returns the smallest number n such that (1 << n) is -// larger than x. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest power of 2 greater than x. + * + * Returns the smallest number n such that (1 << n) is larger than x. + */ INLINE int get_next_higher_bit(PN_uint32 x) { return get_highest_on_bit(x) + 1; } -//////////////////////////////////////////////////////////////////// -// Function: get_next_higher_bit -// Description: Returns the smallest power of 2 greater than x. -// -// Returns the smallest number n such that (1 << n) is -// larger than x. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest power of 2 greater than x. + * + * Returns the smallest number n such that (1 << n) is larger than x. + */ INLINE int get_next_higher_bit(PN_uint64 x) { return get_highest_on_bit(x) + 1; diff --git a/panda/src/putil/pbitops.cxx b/panda/src/putil/pbitops.cxx index d5571caec0..c6946de071 100644 --- a/panda/src/putil/pbitops.cxx +++ b/panda/src/putil/pbitops.cxx @@ -1,26 +1,21 @@ -// Filename: pbitops.cxx -// Created by: drose (10May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pbitops.cxx + * @author drose + * @date 2008-05-10 + */ #include "pbitops.h" -// The following table can be generated using this code: -//for (int bit = 0; bit < 16; ++bit) { -// int w = (1 << bit); -// for (int i = 0; i < w; ++i) { -// num_bits_on[i + w] = num_bits_on[i] + 1; -// } -//} +// The following table can be generated using this code: for (int bit = 0; bit +// < 16; ++bit) { int w = (1 << bit); for (int i = 0; i < w; ++i) { +// num_bits_on[i + w] = num_bits_on[i] + 1; } } const unsigned char num_bits_on[65536] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, diff --git a/panda/src/putil/pbitops.h b/panda/src/putil/pbitops.h index b8d832481a..545cce9dba 100644 --- a/panda/src/putil/pbitops.h +++ b/panda/src/putil/pbitops.h @@ -1,16 +1,15 @@ -// Filename: pbitops.h -// Created by: drose (10May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pbitops.h + * @author drose + * @date 2008-05-10 + */ #ifndef PBITOPS_H #define PBITOPS_H @@ -22,10 +21,8 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// This file defines a few low-level bit-operation routines, optimized -// all to heck. -//////////////////////////////////////////////////////////////////// +// This file defines a few low-level bit-operation routines, optimized all to +// heck. INLINE int count_bits_in_word(PN_uint16 x); INLINE int count_bits_in_word(PN_uint32 x); diff --git a/panda/src/putil/portalMask.h b/panda/src/putil/portalMask.h index aa9a24397a..bacc0e005d 100644 --- a/panda/src/putil/portalMask.h +++ b/panda/src/putil/portalMask.h @@ -1,16 +1,15 @@ -// Filename: portalMask.h -// Created by: masad (13May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file portalMask.h + * @author masad + * @date 2004-05-13 + */ #ifndef PORTALMASK_H #define PORTALMASK_H @@ -19,9 +18,9 @@ #include "bitMask.h" -// This is the data type of the collision mask: the set of bits that -// every CollisionNode has, and that any two nodes must have some in -// common in order to be tested for a mutual intersection. +// This is the data type of the collision mask: the set of bits that every +// CollisionNode has, and that any two nodes must have some in common in order +// to be tested for a mutual intersection. // This file is templated from collideMask.h, hence it is here @@ -29,4 +28,3 @@ typedef BitMask32 PortalMask; #endif - diff --git a/panda/src/putil/pta_ushort.cxx b/panda/src/putil/pta_ushort.cxx index 1b16926a64..6323614b99 100644 --- a/panda/src/putil/pta_ushort.cxx +++ b/panda/src/putil/pta_ushort.cxx @@ -1,16 +1,15 @@ -// Filename: pta_ushort.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_ushort.cxx + * @author drose + * @date 2000-05-10 + */ #include "pta_ushort.h" diff --git a/panda/src/putil/pta_ushort.h b/panda/src/putil/pta_ushort.h index e141e136a9..51bf61927d 100644 --- a/panda/src/putil/pta_ushort.h +++ b/panda/src/putil/pta_ushort.h @@ -1,16 +1,15 @@ -// Filename: pta_ushort.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pta_ushort.h + * @author drose + * @date 2000-05-10 + */ #ifndef PTA_USHORT_H #define PTA_USHORT_H @@ -20,14 +19,12 @@ #include "pointerToArray.h" #include "vector_ushort.h" -//////////////////////////////////////////////////////////////////// -// Class : PTA_ushort -// Description : A pta of ushorts. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// +/** + * A pta of ushorts. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a pta of this type (whether they + * need to export it or not) should include this header file, rather than + * defining the pta again. + */ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, PointerToBase >) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_PUTIL, EXPTP_PANDA_PUTIL, PointerToArrayBase) diff --git a/panda/src/putil/pythonCallbackObject.I b/panda/src/putil/pythonCallbackObject.I index a80e952467..7e11ee35dc 100644 --- a/panda/src/putil/pythonCallbackObject.I +++ b/panda/src/putil/pythonCallbackObject.I @@ -1,14 +1,12 @@ -// Filename: pythonCallbackObject.I -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonCallbackObject.I + * @author drose + * @date 2009-03-13 + */ diff --git a/panda/src/putil/pythonCallbackObject.cxx b/panda/src/putil/pythonCallbackObject.cxx index 48b0bbbbe3..f78121630f 100644 --- a/panda/src/putil/pythonCallbackObject.cxx +++ b/panda/src/putil/pythonCallbackObject.cxx @@ -1,16 +1,15 @@ -// Filename: pythonCallbackObject.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonCallbackObject.cxx + * @author drose + * @date 2009-03-13 + */ #include "pythonCallbackObject.h" @@ -32,11 +31,9 @@ ConfigureFn(config_pythonCallbackObject) { extern struct Dtool_PyTypedObject Dtool_TypedObject; #endif -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonCallbackObject:: PythonCallbackObject(PyObject *function) { _function = Py_None; @@ -45,8 +42,7 @@ PythonCallbackObject(PyObject *function) { set_function(function); #ifndef SIMPLE_THREADS - // Ensure that the Python threading system is initialized and ready - // to go. + // Ensure that the Python threading system is initialized and ready to go. #ifdef WITH_THREAD // This symbol defined within Python.h #if PY_VERSION_HEX >= 0x03020000 @@ -58,23 +54,18 @@ PythonCallbackObject(PyObject *function) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PythonCallbackObject:: ~PythonCallbackObject() { Py_DECREF(_function); } -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::set_function -// Access: Published -// Description: Replaces the function that is called for the callback. -// runs. The parameter should be a Python callable -// object. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the function that is called for the callback. runs. The + * parameter should be a Python callable object. + */ void PythonCallbackObject:: set_function(PyObject *function) { Py_DECREF(_function); @@ -85,25 +76,20 @@ set_function(PyObject *function) { } } -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::get_function -// Access: Published -// Description: Returns the function that is called for the callback. -//////////////////////////////////////////////////////////////////// +/** + * Returns the function that is called for the callback. + */ PyObject *PythonCallbackObject:: get_function() { Py_INCREF(_function); return _function; } -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::do_callback -// Access: Public, Virtual -// Description: This method called when the callback is triggered; it -// *replaces* the original function. To continue -// performing the original function, you must call -// cbdata->upcall() during the callback. -//////////////////////////////////////////////////////////////////// +/** + * This method called when the callback is triggered; it *replaces* the + * original function. To continue performing the original function, you must + * call cbdata->upcall() during the callback. + */ void PythonCallbackObject:: do_callback(CallbackData *cbdata) { #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) @@ -119,19 +105,16 @@ do_callback(CallbackData *cbdata) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PythonCallbackObject::do_python_callback -// Access: Private -// Description: The Python calls that implement do_callback(). This -// function is separate so we can acquire the Python -// interpretor lock while it runs. -//////////////////////////////////////////////////////////////////// +/** + * The Python calls that implement do_callback(). This function is separate + * so we can acquire the Python interpretor lock while it runs. + */ void PythonCallbackObject:: do_python_callback(CallbackData *cbdata) { nassertv(cbdata != NULL); - // Wrap the cbdata up in a Python object, then put it in a tuple, - // for the argument list. + // Wrap the cbdata up in a Python object, then put it in a tuple, for the + // argument list. PyObject *pycbdata = DTool_CreatePyInstanceTyped(cbdata, Dtool_TypedObject, false, false, cbdata->get_type_index()); diff --git a/panda/src/putil/pythonCallbackObject.h b/panda/src/putil/pythonCallbackObject.h index 44e45ab19d..a34b1ceecb 100644 --- a/panda/src/putil/pythonCallbackObject.h +++ b/panda/src/putil/pythonCallbackObject.h @@ -1,16 +1,15 @@ -// Filename: pythonCallbackObject.h -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pythonCallbackObject.h + * @author drose + * @date 2009-03-13 + */ #ifndef PYTHONCALLBACKOBJECT_H #define PYTHONCALLBACKOBJECT_H @@ -22,12 +21,10 @@ #include "py_panda.h" #include "callbackObject.h" -//////////////////////////////////////////////////////////////////// -// Class : PythonCallbackObject -// Description : This is a specialization on CallbackObject to allow -// a callback to directly call an arbitarary Python -// function. Powerful! But use with caution. -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on CallbackObject to allow a callback to directly + * call an arbitarary Python function. Powerful! But use with caution. + */ class PythonCallbackObject : public CallbackObject { PUBLISHED: PythonCallbackObject(PyObject *function = Py_None); diff --git a/panda/src/putil/simpleHashMap.I b/panda/src/putil/simpleHashMap.I index 2dac620091..67db8830b9 100644 --- a/panda/src/putil/simpleHashMap.I +++ b/panda/src/putil/simpleHashMap.I @@ -1,23 +1,19 @@ -// Filename: simpleHashMap.I -// Created by: drose (19Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleHashMap.I + * @author drose + * @date 2007-07-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE SimpleHashMap:: SimpleHashMap(const Compare &comp) : @@ -29,23 +25,18 @@ SimpleHashMap(const Compare &comp) : { } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE SimpleHashMap:: ~SimpleHashMap() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::swap -// Access: Public -// Description: Quickly exchanges the contents of this map and the -// other map. -//////////////////////////////////////////////////////////////////// +/** + * Quickly exchanges the contents of this map and the other map. + */ template INLINE void SimpleHashMap:: swap(SimpleHashMap &other) { @@ -66,13 +57,10 @@ swap(SimpleHashMap &other) { other._num_entries = t3; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::find -// Access: Public -// Description: Searches for the indicated key in the table. Returns -// its index number if it is found, or -1 if it is not -// present in the table. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated key in the table. Returns its index number if + * it is found, or -1 if it is not present in the table. + */ template int SimpleHashMap:: find(const Key &key) const { @@ -89,10 +77,10 @@ find(const Key &key) const { return index; } - // There was some other key at the hashed slot. That's a hash - // conflict. Maybe our entry was recorded at a later slot position; - // scan the subsequent positions until we find the entry or an - // unused slot, indicating the end of the scan. + // There was some other key at the hashed slot. That's a hash conflict. + // Maybe our entry was recorded at a later slot position; scan the + // subsequent positions until we find the entry or an unused slot, + // indicating the end of the scan. size_t i = index; i = (i + 1) & (_table_size - 1); while (i != index && has_element(i)) { @@ -106,13 +94,10 @@ find(const Key &key) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::store -// Access: Public -// Description: Records the indicated key/data pair in the map. If -// the key was already present, silently replaces it. -// Returns the index at which it was stored. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated key/data pair in the map. If the key was already + * present, silently replaces it. Returns the index at which it was stored. + */ template int SimpleHashMap:: store(const Key &key, const Value &data) { @@ -143,8 +128,7 @@ store(const Key &key, const Value &data) { return index; } if (is_element(index, key)) { - // This element is already in the map; replace the data at that - // key. + // This element is already in the map; replace the data at that key. _table[index]._data = data; #ifdef _DEBUG nassertr(validate(), index); @@ -152,8 +136,8 @@ store(const Key &key, const Value &data) { return index; } - // There was some other key at the hashed slot. That's a hash - // conflict. Record this entry at a later position. + // There was some other key at the hashed slot. That's a hash conflict. + // Record this entry at a later position. size_t i = index; i = (i + 1) & (_table_size - 1); while (i != index) { @@ -178,19 +162,16 @@ store(const Key &key, const Value &data) { i = (i + 1) & (_table_size - 1); } - // Shouldn't get here unless _num_entries == _table_size, which - // shouldn't be possible due to consider_expand_table(). + // Shouldn't get here unless _num_entries == _table_size, which shouldn't be + // possible due to consider_expand_table(). nassertr(false, -1); return -1; // To satisfy compiler } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::remove -// Access: Public -// Description: Removes the indicated key and its associated data -// from the table. Returns true if the key was removed, -// false if it was not present. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated key and its associated data from the table. Returns + * true if the key was removed, false if it was not present. + */ template INLINE bool SimpleHashMap:: remove(const Key &key) { @@ -202,11 +183,9 @@ remove(const Key &key) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::clear -// Access: Public -// Description: Completely empties the table. -//////////////////////////////////////////////////////////////////// +/** + * Completely empties the table. + */ template void SimpleHashMap:: clear() { @@ -225,13 +204,10 @@ clear() { } } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::operator [] -// Access: Public -// Description: Returns a modifiable reference to the data associated -// with the indicated key, or creates a new data entry -// and returns its reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the data associated with the indicated + * key, or creates a new data entry and returns its reference. + */ template INLINE Value &SimpleHashMap:: operator [] (const Key &key) { @@ -242,25 +218,21 @@ operator [] (const Key &key) { return modify_data(index); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_size -// Access: Public -// Description: Returns the total number of slots in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of slots in the table. + */ template INLINE size_t SimpleHashMap:: get_size() const { return _table_size; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::has_element -// Access: Public -// Description: Returns true if there is an element stored in the nth -// slot, false otherwise. -// -// n should be in the range 0 <= n < get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an element stored in the nth slot, false + * otherwise. + * + * n should be in the range 0 <= n < get_size(). + */ template INLINE bool SimpleHashMap:: has_element(int n) const { @@ -268,16 +240,13 @@ has_element(int n) const { return (get_exists_array()[n] != 0); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_key -// Access: Public -// Description: Returns the key in the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the key in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE const Key &SimpleHashMap:: get_key(int n) const { @@ -285,16 +254,13 @@ get_key(int n) const { return _table[n]._key; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_data -// Access: Public -// Description: Returns the data in the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the data in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE const Value &SimpleHashMap:: get_data(int n) const { @@ -302,17 +268,13 @@ get_data(int n) const { return _table[n]._data; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::modify_data -// Access: Public -// Description: Returns a modifiable reference to the data in the nth -// slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the data in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE Value &SimpleHashMap:: modify_data(int n) { @@ -320,16 +282,13 @@ modify_data(int n) { return _table[n]._data; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::set_data -// Access: Public -// Description: Changes the data for the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the data for the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE void SimpleHashMap:: set_data(int n, const Value &data) { @@ -337,16 +296,13 @@ set_data(int n, const Value &data) { _table[n]._data = data; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::remove_element -// Access: Public -// Description: Removes the nth slot from the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth slot from the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template void SimpleHashMap:: remove_element(int n) { @@ -356,17 +312,15 @@ remove_element(int n) { nassertv(_num_entries > 0); --_num_entries; - // Now we have put a hole in the table. If there was a hash - // conflict in the slot following this one, we have to move it down - // to close the hole. + // Now we have put a hole in the table. If there was a hash conflict in the + // slot following this one, we have to move it down to close the hole. size_t i = (size_t)n; i = (i + 1) & (_table_size - 1); while (has_element(i)) { size_t wants_index = get_hash(_table[i]._key); if (wants_index != i) { - // This one was a hash conflict; try to put it where it belongs. - // We can't just put it in n, since maybe it belongs somewhere - // after n. + // This one was a hash conflict; try to put it where it belongs. We + // can't just put it in n, since maybe it belongs somewhere after n. while (wants_index != i && has_element(wants_index)) { wants_index = (wants_index + 1) & (_table_size - 1); } @@ -376,9 +330,8 @@ remove_element(int n) { } } - // Continue until we encounter the next unused slot. Until we do, - // we can't be sure we've found all of the potential hash - // conflicts. + // Continue until we encounter the next unused slot. Until we do, we + // can't be sure we've found all of the potential hash conflicts. i = (i + 1) & (_table_size - 1); } @@ -387,38 +340,29 @@ remove_element(int n) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_num_entries -// Access: Public -// Description: Returns the number of active entries in the table. -// This is not necessarily related to the number of -// slots in the table as reported by get_size(). Use -// get_size() to iterate through all of the slots, not -// get_num_entries(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of active entries in the table. This is not necessarily + * related to the number of slots in the table as reported by get_size(). Use + * get_size() to iterate through all of the slots, not get_num_entries(). + */ template INLINE size_t SimpleHashMap:: get_num_entries() const { return _num_entries; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::is_empty -// Access: Public -// Description: Returns true if the table is empty; -// i.e. get_num_entries() == 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the table is empty; i.e. get_num_entries() == 0. + */ template INLINE bool SimpleHashMap:: is_empty() const { return (_num_entries == 0); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void SimpleHashMap:: output(ostream &out) const { @@ -431,8 +375,8 @@ output(ostream &out) const { out << " " << _table[i]._key; size_t index = get_hash(_table[i]._key); if (index != i) { - // This was misplaced as the result of a hash conflict. - // Report how far off it is. + // This was misplaced as the result of a hash conflict. Report how + // far off it is. out << "(" << ((_table_size + i - index) & (_table_size - 1)) << ")"; } } @@ -440,11 +384,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void SimpleHashMap:: write(ostream &out) const { @@ -452,12 +394,10 @@ write(ostream &out) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::validate -// Access: Public -// Description: Returns true if the internal table appears to be -// consistent, false if there are some internal errors. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the internal table appears to be consistent, false if there + * are some internal errors. + */ template bool SimpleHashMap:: validate() const { @@ -493,18 +433,14 @@ validate() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_hash -// Access: Private -// Description: Computes an appropriate index number to store the -// given pointer. -//////////////////////////////////////////////////////////////////// +/** + * Computes an appropriate index number to store the given pointer. + */ template INLINE size_t SimpleHashMap:: get_hash(const Key &key) const { /* - // We want a hash constant 0 < k < 1. This one is suggested by - // Knuth: + // We want a hash constant 0 < k < 1. This one is suggested by Knuth: static const double hash_constant = (sqrt(5.0) - 1.0) / 2.0; double f = ((double)_comp(key) * hash_constant); f -= floor(f); @@ -514,11 +450,9 @@ get_hash(const Key &key) const { return ((_comp(key) * (size_t)9973) >> 8) & (_table_size - 1); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::is_element -// Access: Private -// Description: Returns true if element n matches key. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if element n matches key. + */ template INLINE bool SimpleHashMap:: is_element(int n, const Key &key) const { @@ -526,12 +460,10 @@ is_element(int n, const Key &key) const { return _comp.is_equal(_table[n]._key, key); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::store_new_element -// Access: Private -// Description: Constructs a new TableEntry at position n, storing -// the indicated key and value. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TableEntry at position n, storing the indicated key and + * value. + */ template INLINE void SimpleHashMap:: store_new_element(int n, const Key &key, const Value &data) { @@ -539,11 +471,9 @@ store_new_element(int n, const Key &key, const Value &data) { get_exists_array()[n] = true; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::clear_element -// Access: Private -// Description: Destructs the TableEntry at position n. -//////////////////////////////////////////////////////////////////// +/** + * Destructs the TableEntry at position n. + */ template INLINE void SimpleHashMap:: clear_element(int n) { @@ -551,36 +481,31 @@ clear_element(int n) { get_exists_array()[n] = false; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::get_exists_array -// Access: Private -// Description: Returns the beginning of the array of _table_size -// unsigned chars that are the boolean flags for whether -// each element exists (has been constructed) within the -// table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the beginning of the array of _table_size unsigned chars that are + * the boolean flags for whether each element exists (has been constructed) + * within the table. + */ template INLINE unsigned char *SimpleHashMap:: get_exists_array() const { return (unsigned char *)(_table + _table_size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::new_table -// Access: Private -// Description: Allocates a brand new table. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a brand new table. + */ template void SimpleHashMap:: new_table() { nassertv(_table_size == 0 && _num_entries == 0); - // Pick a good initial table size. For now, we make it really - // small. Maybe that's the right answer. + // Pick a good initial table size. For now, we make it really small. Maybe + // that's the right answer. _table_size = 4; - // We allocate enough bytes for _table_size elements of TableEntry, - // plus _table_size more bytes at the end (for the exists array). + // We allocate enough bytes for _table_size elements of TableEntry, plus + // _table_size more bytes at the end (for the exists array). size_t alloc_size = _table_size * sizeof(TableEntry) + _table_size; _deleted_chain = memory_hook->get_deleted_chain(alloc_size); @@ -588,13 +513,10 @@ new_table() { memset(get_exists_array(), 0, _table_size); } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::consider_expand_table -// Access: Private -// Description: Expands the table if it will need it (assuming one -// more element is about to be added). Returns true if -// expanded, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Expands the table if it will need it (assuming one more element is about to + * be added). Returns true if expanded, false otherwise. + */ template INLINE bool SimpleHashMap:: consider_expand_table() { @@ -605,11 +527,9 @@ consider_expand_table() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SimpleHashMap::expand_table -// Access: Private -// Description: Doubles the size of the existing table. -//////////////////////////////////////////////////////////////////// +/** + * Doubles the size of the existing table. + */ template void SimpleHashMap:: expand_table() { @@ -623,8 +543,8 @@ expand_table() { _table_size = (old_table_size << 1); nassertv(_table == NULL); - // We allocate enough bytes for _table_size elements of TableEntry, - // plus _table_size more bytes at the end (for the exists array). + // We allocate enough bytes for _table_size elements of TableEntry, plus + // _table_size more bytes at the end (for the exists array). size_t alloc_size = _table_size * sizeof(TableEntry) + _table_size; _deleted_chain = memory_hook->get_deleted_chain(alloc_size); _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); @@ -644,8 +564,8 @@ expand_table() { } #ifdef USE_MOVE_SEMANTICS - // Use C++11 rvalue references to invoke the move constructor, - // which may be more efficient. + // Use C++11 rvalue references to invoke the move constructor, which may + // be more efficient. new(&_table[new_index]) TableEntry(move(old_map._table[i])); #else new(&_table[new_index]) TableEntry(old_map._table[i]); diff --git a/panda/src/putil/simpleHashMap.cxx b/panda/src/putil/simpleHashMap.cxx index 33ddf4a128..af7f211c07 100644 --- a/panda/src/putil/simpleHashMap.cxx +++ b/panda/src/putil/simpleHashMap.cxx @@ -1,15 +1,14 @@ -// Filename: simpleHashMap.cxx -// Created by: drose (19Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleHashMap.cxx + * @author drose + * @date 2007-07-19 + */ #include "simpleHashMap.h" diff --git a/panda/src/putil/simpleHashMap.h b/panda/src/putil/simpleHashMap.h index 816218251d..7954cd943e 100644 --- a/panda/src/putil/simpleHashMap.h +++ b/panda/src/putil/simpleHashMap.h @@ -1,16 +1,15 @@ -// Filename: simpleHashMap.h -// Created by: drose (19Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file simpleHashMap.h + * @author drose + * @date 2007-07-19 + */ #ifndef SIMPLEHASHMAP_H #define SIMPLEHASHMAP_H @@ -19,16 +18,13 @@ #include "pvector.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Class : SimpleHashMap -// Description : This template class implements an unordered map of -// keys to data, implemented as a hashtable. It is -// similar to STL's hash_map, but (a) it has a simpler -// interface (we don't mess around with iterators), (b) -// it wants an additional method on the Compare object, -// Compare::is_equal(a, b), and (c) it doesn't depend on -// the system STL providing hash_map. -//////////////////////////////////////////////////////////////////// +/** + * This template class implements an unordered map of keys to data, + * implemented as a hashtable. It is similar to STL's hash_map, but (a) it + * has a simpler interface (we don't mess around with iterators), (b) it wants + * an additional method on the Compare object, Compare::is_equal(a, b), and + * (c) it doesn't depend on the system STL providing hash_map. + */ template > > class SimpleHashMap { public: diff --git a/panda/src/putil/sparseArray.I b/panda/src/putil/sparseArray.I index e9fed81d17..fb459806d0 100644 --- a/panda/src/putil/sparseArray.I +++ b/panda/src/putil/sparseArray.I @@ -1,32 +1,26 @@ -// Filename: sparseArray.I -// Created by: drose (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparseArray.I + * @author drose + * @date 2007-02-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray:: SparseArray() : _inverse(false) { } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray:: SparseArray(const SparseArray ©) : _subranges(copy._subranges), @@ -34,11 +28,9 @@ SparseArray(const SparseArray ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray &SparseArray:: operator = (const SparseArray ©) { _subranges = copy._subranges; @@ -46,12 +38,9 @@ operator = (const SparseArray ©) { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Named all_on constructor -// Access: Published, Static -// Description: Returns a SparseArray with an infinite array of bits, -// all on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a SparseArray with an infinite array of bits, all on. + */ INLINE SparseArray SparseArray:: all_on() { SparseArray result; @@ -59,21 +48,17 @@ all_on() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Named all_on constructor -// Access: Published, Static -// Description: Returns a SparseArray whose bits are all off. -//////////////////////////////////////////////////////////////////// +/** + * Returns a SparseArray whose bits are all off. + */ INLINE SparseArray SparseArray:: all_off() { return SparseArray(); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Named lower_on constructor -// Access: Published, Static -// Description: Returns a SparseArray whose lower on_bits bits are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a SparseArray whose lower on_bits bits are on. + */ INLINE SparseArray SparseArray:: lower_on(int on_bits) { SparseArray result; @@ -81,11 +66,9 @@ lower_on(int on_bits) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Named bit constructor -// Access: Published, Static -// Description: Returns a SparseArray with only the indicated bit on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a SparseArray with only the indicated bit on. + */ INLINE SparseArray SparseArray:: bit(int index) { SparseArray result; @@ -93,12 +76,9 @@ bit(int index) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Named range constructor -// Access: Published, Static -// Description: Returns a SparseArray whose size bits, beginning at -// low_bit, are on. -//////////////////////////////////////////////////////////////////// +/** + * Returns a SparseArray whose size bits, beginning at low_bit, are on. + */ INLINE SparseArray SparseArray:: range(int low_bit, int size) { SparseArray result; @@ -106,64 +86,49 @@ range(int low_bit, int size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray:: ~SparseArray() { } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::has_max_num_bits -// Access: Published, Static -// Description: Returns true if there is a maximum number of bits -// that may be stored in this structure, false -// otherwise. If this returns true, the number may be -// queried in get_max_num_bits(). -// -// This method always returns false. The SparseArray has -// no maximum number of bits. This method is defined so -// generic programming algorithms can use BitMask or -// SparseArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a maximum number of bits that may be stored in + * this structure, false otherwise. If this returns true, the number may be + * queried in get_max_num_bits(). + * + * This method always returns false. The SparseArray has no maximum number of + * bits. This method is defined so generic programming algorithms can use + * BitMask or SparseArray interchangeably. + */ INLINE bool SparseArray:: has_max_num_bits() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_max_num_bits -// Access: Published, Static -// Description: If get_max_num_bits() returned true, this method may -// be called to return the maximum number of bits that -// may be stored in this structure. It is an error to -// call this if get_max_num_bits() return false. -// -// It is always an error to call this method. The -// SparseArray has no maximum number of bits. This method -// is defined so generic programming algorithms can use -// BitMask or SparseArray interchangeably. -//////////////////////////////////////////////////////////////////// +/** + * If get_max_num_bits() returned true, this method may be called to return + * the maximum number of bits that may be stored in this structure. It is an + * error to call this if get_max_num_bits() return false. + * + * It is always an error to call this method. The SparseArray has no maximum + * number of bits. This method is defined so generic programming algorithms + * can use BitMask or SparseArray interchangeably. + */ INLINE int SparseArray:: get_max_num_bits() { nassertr(false, 0); return 0; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_num_bits -// Access: Published -// Description: Returns the current number of possibly different bits -// in this array. There are actually an infinite number -// of bits, but every bit higher than this bit will have -// the same value, either 0 or 1 (see -// get_highest_bits()). -// -// This number may grow and/or shrink automatically as -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of possibly different bits in this array. There + * are actually an infinite number of bits, but every bit higher than this bit + * will have the same value, either 0 or 1 (see get_highest_bits()). + * + * This number may grow and/or shrink automatically as needed. + */ INLINE int SparseArray:: get_num_bits() const { if (_subranges.empty()) { @@ -174,47 +139,37 @@ get_num_bits() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_bit -// Access: Published -// Description: Returns true if the nth bit is set, false if it is -// cleared. It is valid for n to increase beyond -// get_num_bits(), but the return value get_num_bits() -// will always be the same. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the nth bit is set, false if it is cleared. It is valid + * for n to increase beyond get_num_bits(), but the return value + * get_num_bits() will always be the same. + */ INLINE bool SparseArray:: get_bit(int index) const { return has_any_of(index, 1); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::set_bit -// Access: Published -// Description: Sets the nth bit on. If n >= get_num_bits(), this -// automatically extends the array. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit on. If n >= get_num_bits(), this automatically extends + * the array. + */ INLINE void SparseArray:: set_bit(int index) { set_range(index, 1); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::clear_bit -// Access: Published -// Description: Sets the nth bit off. If n >= get_num_bits(), this -// automatically extends the array. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit off. If n >= get_num_bits(), this automatically extends + * the array. + */ INLINE void SparseArray:: clear_bit(int index) { clear_range(index, 1); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::set_bit_to -// Access: Published -// Description: Sets the nth bit either on or off, according to the -// indicated bool value. -//////////////////////////////////////////////////////////////////// +/** + * Sets the nth bit either on or off, according to the indicated bool value. + */ INLINE void SparseArray:: set_bit_to(int index, bool value) { if (value) { @@ -224,24 +179,18 @@ set_bit_to(int index, bool value) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_highest_bits -// Access: Published -// Description: Returns true if the infinite set of bits beyond -// get_num_bits() are all on, or false of they are all -// off. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the infinite set of bits beyond get_num_bits() are all on, + * or false of they are all off. + */ INLINE bool SparseArray:: get_highest_bits() const { return _inverse; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::is_zero -// Access: Published -// Description: Returns true if the entire bitmask is zero, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is zero, false otherwise. + */ INLINE bool SparseArray:: is_zero() const { if (_inverse) { @@ -251,12 +200,9 @@ is_zero() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::is_all_on -// Access: Published -// Description: Returns true if the entire bitmask is one, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the entire bitmask is one, false otherwise. + */ bool SparseArray:: is_all_on() const { if (_inverse) { @@ -266,12 +212,9 @@ is_all_on() const { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::has_any_of -// Access: Published -// Description: Returns true if any bit in the indicated range is -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any bit in the indicated range is set, false otherwise. + */ INLINE bool SparseArray:: has_any_of(int low_bit, int size) const { if (_inverse) { @@ -281,12 +224,9 @@ has_any_of(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::has_all_of -// Access: Published -// Description: Returns true if all bits in the indicated range are -// set, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all bits in the indicated range are set, false otherwise. + */ INLINE bool SparseArray:: has_all_of(int low_bit, int size) const { if (_inverse) { @@ -296,11 +236,9 @@ has_all_of(int low_bit, int size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::set_range -// Access: Published -// Description: Sets the indicated range of bits on. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits on. + */ INLINE void SparseArray:: set_range(int low_bit, int size) { if (_inverse) { @@ -310,11 +248,9 @@ set_range(int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::clear_range -// Access: Published -// Description: Sets the indicated range of bits off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits off. + */ INLINE void SparseArray:: clear_range(int low_bit, int size) { if (_inverse) { @@ -324,11 +260,9 @@ clear_range(int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::set_range_to -// Access: Published -// Description: Sets the indicated range of bits to either on or off. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated range of bits to either on or off. + */ INLINE void SparseArray:: set_range_to(bool value, int low_bit, int size) { if (value) { @@ -338,65 +272,52 @@ set_range_to(bool value, int low_bit, int size) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::invert_in_place -// Access: Published -// Description: Inverts all the bits in the SparseArray. This is -// equivalent to array = ~array. -//////////////////////////////////////////////////////////////////// +/** + * Inverts all the bits in the SparseArray. This is equivalent to array = + * ~array. + */ void SparseArray:: invert_in_place() { _inverse = !_inverse; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::clear -// Access: Published -// Description: Sets all the bits in the SparseArray off. -//////////////////////////////////////////////////////////////////// +/** + * Sets all the bits in the SparseArray off. + */ void SparseArray:: clear() { _subranges.clear(); _inverse = false; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SparseArray:: operator == (const SparseArray &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SparseArray:: operator != (const SparseArray &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator < -// Access: Published -// Description: Returns true if the unsigned integer which is -// represented by this SparseArray is less than that of the -// other one, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the unsigned integer which is represented by this + * SparseArray is less than that of the other one, false otherwise. + */ INLINE bool SparseArray:: operator < (const SparseArray &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator & -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator & (const SparseArray &other) const { SparseArray result(*this); @@ -404,11 +325,9 @@ operator & (const SparseArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator | -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator | (const SparseArray &other) const { SparseArray result(*this); @@ -416,11 +335,9 @@ operator | (const SparseArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator ^ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator ^ (const SparseArray &other) const { SparseArray result(*this); @@ -428,11 +345,9 @@ operator ^ (const SparseArray &other) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator ~ -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator ~ () const { SparseArray result(*this); @@ -440,11 +355,9 @@ operator ~ () const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator << -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator << (int shift) const { SparseArray result(*this); @@ -452,11 +365,9 @@ operator << (int shift) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator >> -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray SparseArray:: operator >> (int shift) const { SparseArray result(*this); @@ -465,93 +376,75 @@ operator >> (int shift) const { } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator <<= -// Access: Published -// Description: Logical left shift. Since negative bit positions -// have meaning in a SparseArray, real bit values are -// rotated in on the left (not necessarily zero). -//////////////////////////////////////////////////////////////////// +/** + * Logical left shift. Since negative bit positions have meaning in a + * SparseArray, real bit values are rotated in on the left (not necessarily + * zero). + */ void SparseArray:: operator <<= (int shift) { do_shift(shift); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator >>= -// Access: Published -// Description: Logical right shift. The rightmost bits become -// negative, but are not lost; they will reappear into -// the zero position if the array is later left-shifted. -//////////////////////////////////////////////////////////////////// +/** + * Logical right shift. The rightmost bits become negative, but are not lost; + * they will reappear into the zero position if the array is later left- + * shifted. + */ void SparseArray:: operator >>= (int shift) { do_shift(-shift); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::is_inverse -// Access: Published -// Description: If this is true, the SparseArray is actually defined -// as a list of subranges of integers that are *not* in -// the set. If this is false (the default), then the -// subranges define the integers that *are* in the set. -// This affects the interpretation of the values -// returned by iterating through get_num_subranges(). -//////////////////////////////////////////////////////////////////// +/** + * If this is true, the SparseArray is actually defined as a list of subranges + * of integers that are *not* in the set. If this is false (the default), + * then the subranges define the integers that *are* in the set. This affects + * the interpretation of the values returned by iterating through + * get_num_subranges(). + */ INLINE bool SparseArray:: is_inverse() const { return _inverse; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_num_subranges -// Access: Published -// Description: Returns the number of separate subranges stored in -// the SparseArray. You can use this limit to iterate -// through the subranges, calling get_subrange_begin() -// and get_subrange_end() for each one. -// -// Also see is_inverse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of separate subranges stored in the SparseArray. You + * can use this limit to iterate through the subranges, calling + * get_subrange_begin() and get_subrange_end() for each one. + * + * Also see is_inverse(). + */ INLINE size_t SparseArray:: get_num_subranges() const { return _subranges.size(); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_subrange_begin -// Access: Published -// Description: Returns the first numeric element in the nth -// subrange. -// -// Also see is_inverse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the first numeric element in the nth subrange. + * + * Also see is_inverse(). + */ INLINE int SparseArray:: get_subrange_begin(size_t n) const { nassertr(n < _subranges.size(), 0); return _subranges[n]._begin; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_subrange_end -// Access: Published -// Description: Returns the last numeric element, plus one, in the -// nth subrange. -// -// Also see is_inverse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the last numeric element, plus one, in the nth subrange. + * + * Also see is_inverse(). + */ INLINE int SparseArray:: get_subrange_end(size_t n) const { nassertr(n < _subranges.size(), 0); return _subranges[n]._end; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Subrange::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SparseArray::Subrange:: Subrange(int begin, int end) : _begin(begin), @@ -559,16 +452,13 @@ Subrange(int begin, int end) : { } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Subrange::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool SparseArray::Subrange:: operator < (const SparseArray::Subrange &other) const { // We compare the end values, rather than the begin values, to make - // lower_bound() sensibly return a possible intersection with the - // indicated Subrange. + // lower_bound() sensibly return a possible intersection with the indicated + // Subrange. return _end < other._end; } - diff --git a/panda/src/putil/sparseArray.cxx b/panda/src/putil/sparseArray.cxx index 6db82d8285..37940d1d10 100644 --- a/panda/src/putil/sparseArray.cxx +++ b/panda/src/putil/sparseArray.cxx @@ -1,16 +1,15 @@ -// Filename: sparseArray.cxx -// Created by: drose (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparseArray.cxx + * @author drose + * @date 2007-02-14 + */ #include "sparseArray.h" #include "bitArray.h" @@ -19,11 +18,9 @@ TypeHandle SparseArray::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::Constructor (from BitArray) -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SparseArray:: SparseArray(const BitArray &from) { bool empty_bit = from.get_highest_bits(); @@ -34,8 +31,8 @@ SparseArray(const BitArray &from) { size_t i = 0; // By including get_num_bits()--one more than the last bit--in this - // traversal, we guarantee that we will end on the empty_bit state - // (because the last bit we visit will be one of the highest_bits). + // traversal, we guarantee that we will end on the empty_bit state (because + // the last bit we visit will be one of the highest_bits). while (i <= from.get_num_bits()) { if (from.get_bit(i) != current_state) { // End of a run. @@ -52,13 +49,10 @@ SparseArray(const BitArray &from) { nassertv(current_state == empty_bit); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_num_on_bits -// Access: Published -// Description: Returns the number of bits that are set to 1 in the -// array. Returns -1 if there are an infinite number of -// 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 1 in the array. Returns -1 if + * there are an infinite number of 1 bits. + */ int SparseArray:: get_num_on_bits() const { if (_inverse) { @@ -74,13 +68,10 @@ get_num_on_bits() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_num_off_bits -// Access: Published -// Description: Returns the number of bits that are set to 0 in the -// array. Returns -1 if there are an infinite number of -// 0 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bits that are set to 0 in the array. Returns -1 if + * there are an infinite number of 0 bits. + */ int SparseArray:: get_num_off_bits() const { if (!_inverse) { @@ -96,13 +87,10 @@ get_num_off_bits() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_lowest_on_bit -// Access: Published -// Description: Returns the index of the lowest 1 bit in the array. -// Returns -1 if there are no 1 bits or if there are an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 1 bit in the array. Returns -1 if there + * are no 1 bits or if there are an infinite number of 1 bits. + */ int SparseArray:: get_lowest_on_bit() const { if (_inverse) { @@ -116,13 +104,10 @@ get_lowest_on_bit() const { return _subranges[0]._begin; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_lowest_off_bit -// Access: Published -// Description: Returns the index of the lowest 0 bit in the array. -// Returns -1 if there are no 0 bits or if there are an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the lowest 0 bit in the array. Returns -1 if there + * are no 0 bits or if there are an infinite number of 1 bits. + */ int SparseArray:: get_lowest_off_bit() const { if (!_inverse) { @@ -136,13 +121,10 @@ get_lowest_off_bit() const { return _subranges[0]._begin; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_highest_on_bit -// Access: Published -// Description: Returns the index of the highest 1 bit in the array. -// Returns -1 if there are no 1 bits or if there an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 1 bit in the array. Returns -1 if there + * are no 1 bits or if there an infinite number of 1 bits. + */ int SparseArray:: get_highest_on_bit() const { if (_inverse) { @@ -156,13 +138,10 @@ get_highest_on_bit() const { return _subranges[_subranges.size() - 1]._end - 1; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_highest_off_bit -// Access: Published -// Description: Returns the index of the highest 0 bit in the array. -// Returns -1 if there are no 0 bits or if there an -// infinite number of 1 bits. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the highest 0 bit in the array. Returns -1 if there + * are no 0 bits or if there an infinite number of 1 bits. + */ int SparseArray:: get_highest_off_bit() const { if (!_inverse) { @@ -176,17 +155,13 @@ get_highest_off_bit() const { return _subranges[_subranges.size() - 1]._end - 1; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::get_next_higher_different_bit -// Access: Published -// Description: Returns the index of the next bit in the array, above -// low_bit, whose value is different that the value of -// low_bit. Returns low_bit again if all bits higher -// than low_bit have the same value. -// -// This can be used to quickly iterate through all of -// the bits in the array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the next bit in the array, above low_bit, whose value + * is different that the value of low_bit. Returns low_bit again if all bits + * higher than low_bit have the same value. + * + * This can be used to quickly iterate through all of the bits in the array. + */ int SparseArray:: get_next_higher_different_bit(int low_bit) const { Subrange range(low_bit, low_bit + 1); @@ -212,15 +187,12 @@ get_next_higher_different_bit(int low_bit) const { return next; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::has_bits_in_common -// Access: Published -// Description: Returns true if this SparseArray has any "one" bits in -// common with the other one, false otherwise. -// -// This is equivalent to (array & other) != 0, but may -// be faster. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this SparseArray has any "one" bits in common with the + * other one, false otherwise. + * + * This is equivalent to (array & other) != 0, but may be faster. + */ bool SparseArray:: has_bits_in_common(const SparseArray &other) const { if (_inverse && other._inverse) { @@ -233,16 +205,14 @@ has_bits_in_common(const SparseArray &other) const { return !(*this & other).is_zero(); } - // Actually, we'll handle this easy case the lazy way too. Maybe - // later we'll do this smarter. + // Actually, we'll handle this easy case the lazy way too. Maybe later + // we'll do this smarter. return !(*this & other).is_zero(); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SparseArray:: output(ostream &out) const { out << "[ "; @@ -262,15 +232,12 @@ output(ostream &out) const { out << "]"; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::compare_to -// Access: Published -// Description: Returns a number less than zero if this SparseArray -// sorts before the indicated other SparseArray, greater -// than zero if it sorts after, or 0 if they are -// equivalent. This is based on the same ordering -// defined by operator <. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this SparseArray sorts before the + * indicated other SparseArray, greater than zero if it sorts after, or 0 if + * they are equivalent. This is based on the same ordering defined by + * operator <. + */ int SparseArray:: compare_to(const SparseArray &other) const { if (_inverse != other._inverse) { @@ -311,17 +278,14 @@ compare_to(const SparseArray &other) const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator &= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SparseArray:: operator &= (const SparseArray &other) { - // We do this the slow and stupid way. This could be done much - // better with a little effort, but I'm not at all sure it's worth - // the effort. If you need fast boolean operations, you should - // probably be using a BitArray. + // We do this the slow and stupid way. This could be done much better with + // a little effort, but I'm not at all sure it's worth the effort. If you + // need fast boolean operations, you should probably be using a BitArray. if (_inverse && other._inverse) { do_union(other); @@ -342,17 +306,14 @@ operator &= (const SparseArray &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator |= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SparseArray:: operator |= (const SparseArray &other) { - // We do this the slow and stupid way. This could be done much - // better with a little effort, but I'm not at all sure it's worth - // the effort. If you need fast boolean operations, you should - // probably be using a BitArray. + // We do this the slow and stupid way. This could be done much better with + // a little effort, but I'm not at all sure it's worth the effort. If you + // need fast boolean operations, you should probably be using a BitArray. if (_inverse && other._inverse) { do_intersection(other); @@ -372,29 +333,23 @@ operator |= (const SparseArray &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::operator ^= -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SparseArray:: operator ^= (const SparseArray &other) { - // We do this the slow and stupid way. This could be done much - // better with a little effort, but I'm not at all sure it's worth - // the effort. If you need fast boolean operations, you should - // probably be using a BitArray. + // We do this the slow and stupid way. This could be done much better with + // a little effort, but I'm not at all sure it's worth the effort. If you + // need fast boolean operations, you should probably be using a BitArray. (*this) = ((*this) | other) & ~((*this) & other); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_add_range -// Access: Private -// Description: Adds the consecutive range of integers beginning at -// begin, but not including end, to the array. If this -// range overlaps with another range already in the -// array, the result is the union. -//////////////////////////////////////////////////////////////////// +/** + * Adds the consecutive range of integers beginning at begin, but not + * including end, to the array. If this range overlaps with another range + * already in the array, the result is the union. + */ void SparseArray:: do_add_range(int begin, int end) { if (begin >= end) { @@ -431,8 +386,8 @@ do_add_range(int begin, int end) { Subranges::iterator si2 = si; --si2; if ((*si2)._end >= begin) { - // The new range expands an element within the array to the - // right (but does not intersect the next element). + // The new range expands an element within the array to the right (but + // does not intersect the next element). (*si2)._end = end; // It might also expand it to the left; fall through. si = si2; @@ -469,12 +424,10 @@ do_add_range(int begin, int end) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_remove_range -// Access: Private -// Description: Removes the consecutive range of integers beginning -// at begin, but not including end, from the array. -//////////////////////////////////////////////////////////////////// +/** + * Removes the consecutive range of integers beginning at begin, but not + * including end, from the array. + */ void SparseArray:: do_remove_range(int begin, int end) { if (begin >= end) { @@ -510,8 +463,8 @@ do_remove_range(int begin, int end) { Subranges::iterator si2 = si; --si2; if ((*si2)._end >= begin) { - // The new range shortens an element within the array on the - // right (but does not intersect the next element). + // The new range shortens an element within the array on the right + // (but does not intersect the next element). end = min(end, (*si2)._begin); (*si2)._end = end; // It might also shorten it on the left; fall through. @@ -549,14 +502,11 @@ do_remove_range(int begin, int end) { (*si)._end = min((*si)._end, begin); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_has_any -// Access: Private -// Description: Returns true if any of the consecutive range of -// integers beginning at begin, but not including end, -// appear in the array. Note that this will return -// false for an empty range. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the consecutive range of integers beginning at + * begin, but not including end, appear in the array. Note that this will + * return false for an empty range. + */ bool SparseArray:: do_has_any(int begin, int end) const { if (begin >= end) { @@ -579,14 +529,11 @@ do_has_any(int begin, int end) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_has_all -// Access: Private -// Description: Returns true if all of the consecutive range of -// integers beginning at begin, but not including end, -// appear in the array. Note that this will return -// true for an empty range. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the consecutive range of integers beginning at + * begin, but not including end, appear in the array. Note that this will + * return true for an empty range. + */ bool SparseArray:: do_has_all(int begin, int end) const { if (begin >= end) { @@ -603,12 +550,10 @@ do_has_all(int begin, int end) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_intersection -// Access: Private -// Description: Removes from this array all of the elements that do -// not appear in the other one. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this array all of the elements that do not appear in the other + * one. + */ void SparseArray:: do_intersection(const SparseArray &other) { if (_subranges.empty()) { @@ -632,12 +577,9 @@ do_intersection(const SparseArray &other) { do_remove_range(other_end, my_end); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_union -// Access: Private -// Description: Adds to this array all of the elements that also -// appear in the other one. -//////////////////////////////////////////////////////////////////// +/** + * Adds to this array all of the elements that also appear in the other one. + */ void SparseArray:: do_union(const SparseArray &other) { Subranges::const_iterator si; @@ -646,12 +588,10 @@ do_union(const SparseArray &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_intersection_neg -// Access: Private -// Description: Removes from this array all of the elements that also -// appear in the other one. -//////////////////////////////////////////////////////////////////// +/** + * Removes from this array all of the elements that also appear in the other + * one. + */ void SparseArray:: do_intersection_neg(const SparseArray &other) { Subranges::const_iterator si; @@ -660,12 +600,9 @@ do_intersection_neg(const SparseArray &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::do_shift -// Access: Private -// Description: Shifts all the elements in the array by the indicated -// amount. -//////////////////////////////////////////////////////////////////// +/** + * Shifts all the elements in the array by the indicated amount. + */ void SparseArray:: do_shift(int offset) { if (offset != 0) { @@ -677,12 +614,10 @@ do_shift(int offset) { } } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SparseArray:: write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_uint32(_subranges.size()); @@ -694,12 +629,9 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_bool(_inverse); } -//////////////////////////////////////////////////////////////////// -// Function: SparseArray::read_datagram -// Access: Public -// Description: Reads the object that was previously written to a Bam -// file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the object that was previously written to a Bam file. + */ void SparseArray:: read_datagram(DatagramIterator &scan, BamReader *manager) { size_t num_subranges = scan.get_uint32(); diff --git a/panda/src/putil/sparseArray.h b/panda/src/putil/sparseArray.h index 60657904bc..9ebd205bac 100644 --- a/panda/src/putil/sparseArray.h +++ b/panda/src/putil/sparseArray.h @@ -1,16 +1,15 @@ -// Filename: sparseArray.h -// Created by: drose (14Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sparseArray.h + * @author drose + * @date 2007-02-14 + */ #ifndef SPARSEARRAY_H #define SPARSEARRAY_H @@ -24,28 +23,22 @@ class BamReader; class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : SparseArray -// Description : This class records a set of integers, where each -// integer is either present or not present in the set. -// -// It is similar in principle and in interface to a -// BitArray (which can be thought of as a set of -// integers, one integer corresponding to each different -// bit position), but the SparseArray is implemented as -// a list of min/max subrange lists, rather than as a -// bitmask. -// -// This makes it particularly efficient for storing sets -// which consist of large sections of consecutively -// included or consecutively excluded elements, with -// arbitrarily large integers, but particularly -// inefficient for doing boolean operations such as & or -// |. -// -// Also, unlike BitArray, the SparseArray can store -// negative integers. -//////////////////////////////////////////////////////////////////// +/** + * This class records a set of integers, where each integer is either present + * or not present in the set. + * + * It is similar in principle and in interface to a BitArray (which can be + * thought of as a set of integers, one integer corresponding to each + * different bit position), but the SparseArray is implemented as a list of + * min/max subrange lists, rather than as a bitmask. + * + * This makes it particularly efficient for storing sets which consist of + * large sections of consecutively included or consecutively excluded + * elements, with arbitrarily large integers, but particularly inefficient for + * doing boolean operations such as & or |. + * + * Also, unlike BitArray, the SparseArray can store negative integers. + */ class EXPCL_PANDA_PUTIL SparseArray { PUBLISHED: INLINE SparseArray(); @@ -138,8 +131,7 @@ private: void do_intersection_neg(const SparseArray &other); void do_shift(int offset); - // The SparseArray is implemented as a set of non-overlapping - // Subranges. + // The SparseArray is implemented as a set of non-overlapping Subranges. class Subrange { public: INLINE Subrange(int begin, int end); @@ -177,4 +169,3 @@ operator << (ostream &out, const SparseArray &array) { } #endif - diff --git a/panda/src/putil/test_bam.cxx b/panda/src/putil/test_bam.cxx index 6238933d72..deef264ce1 100644 --- a/panda/src/putil/test_bam.cxx +++ b/panda/src/putil/test_bam.cxx @@ -1,16 +1,15 @@ -// Filename: test_bam.cxx -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_bam.cxx + * @author jason + * @date 2000-06-13 + */ #include "pandabase.h" #include "pnotify.h" @@ -39,9 +38,9 @@ ConfigureFn(config_test_bam) void Person:: write_datagram(BamWriter* manager, Datagram &me) { - //Write out name + // Write out name me.add_string(_name); - //Write out gender + // Write out gender me.add_uint8(myGender); manager->write_pointer(me, _bro); manager->write_pointer(me, _sis); diff --git a/panda/src/putil/test_bam.h b/panda/src/putil/test_bam.h index d0c4f0710b..557b9ba6b4 100644 --- a/panda/src/putil/test_bam.h +++ b/panda/src/putil/test_bam.h @@ -1,17 +1,15 @@ -// Filename: test_bam.h -// Created by: jason (12Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_bam.h + * @author jason + * @date 2000-06-12 + */ #include "pandabase.h" #include "pnotify.h" @@ -172,6 +170,3 @@ public: private: static TypeHandle _type_handle; }; - - - diff --git a/panda/src/putil/test_bamRead.cxx b/panda/src/putil/test_bamRead.cxx index d6bb857194..d49f49434b 100644 --- a/panda/src/putil/test_bamRead.cxx +++ b/panda/src/putil/test_bamRead.cxx @@ -1,16 +1,15 @@ -// Filename: test_bamRead.cxx -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_bamRead.cxx + * @author jason + * @date 2000-06-13 + */ #include "pandabase.h" #include "pnotify.h" diff --git a/panda/src/putil/test_bamWrite.cxx b/panda/src/putil/test_bamWrite.cxx index d3660d7c22..59d56930ec 100644 --- a/panda/src/putil/test_bamWrite.cxx +++ b/panda/src/putil/test_bamWrite.cxx @@ -1,16 +1,15 @@ -// Filename: test_bamWrite.cxx -// Created by: jason (09Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_bamWrite.cxx + * @author jason + * @date 2000-06-09 + */ #include "pandabase.h" #include "pnotify.h" @@ -32,7 +31,7 @@ int main(int argc, char* argv[]) PointerTo bro = new Child("Bob", Person::MALE); PointerTo sis = new Child("Mary Poppins", Person::FEMALE); - //Set up relationships + // Set up relationships dad->setSon(bro.p()); dad->setDaughter(sis.p()); @@ -57,4 +56,3 @@ int main(int argc, char* argv[]) stream.close(); return 0; } - diff --git a/panda/src/putil/test_filename.cxx b/panda/src/putil/test_filename.cxx index 393ed3af18..a4cbfa76e6 100644 --- a/panda/src/putil/test_filename.cxx +++ b/panda/src/putil/test_filename.cxx @@ -1,16 +1,15 @@ -// Filename: test_filename.cxx -// Created by: drose (18Jan99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_filename.cxx + * @author drose + * @date 1999-01-18 + */ #include "filename.h" #include "config_util.h" @@ -111,5 +110,3 @@ main(int argc, char *argv[]) { return(0); } - - diff --git a/panda/src/putil/test_glob.cxx b/panda/src/putil/test_glob.cxx index 05f99d6c3c..32ba0d1927 100644 --- a/panda/src/putil/test_glob.cxx +++ b/panda/src/putil/test_glob.cxx @@ -1,16 +1,15 @@ -// Filename: test_glob.cxx -// Created by: drose (30May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_glob.cxx + * @author drose + * @date 2000-05-30 + */ #include "globPattern.h" @@ -45,5 +44,3 @@ main(int argc, char *argv[]) { return (0); } - - diff --git a/panda/src/putil/test_linestream.cxx b/panda/src/putil/test_linestream.cxx index 4a68f88096..ada0890607 100644 --- a/panda/src/putil/test_linestream.cxx +++ b/panda/src/putil/test_linestream.cxx @@ -1,16 +1,15 @@ -// Filename: test_linestream.cxx -// Created by: drose (26Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_linestream.cxx + * @author drose + * @date 2000-02-26 + */ #include "lineStream.h" @@ -41,5 +40,3 @@ main(int argc, char *argv[]) { return 0; } - - diff --git a/panda/src/putil/timedCycle.I b/panda/src/putil/timedCycle.I index 4604824d1e..84a79563a6 100644 --- a/panda/src/putil/timedCycle.I +++ b/panda/src/putil/timedCycle.I @@ -1,22 +1,19 @@ -// Filename: timedCycle.I -// Created by: jason (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timedCycle.I + * @author jason + * @date 2000-08-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TimedCycle:: TimedCycle() : _cycle_time(30), @@ -28,11 +25,9 @@ TimedCycle() : _global_clock = ClockObject::get_global_clock(); } -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TimedCycle:: TimedCycle(PN_stdfloat cycle_time, int element_count) : _cycle_time(cycle_time), @@ -45,22 +40,18 @@ TimedCycle(PN_stdfloat cycle_time, int element_count) : _inv_cycle_time = 1. / _cycle_time; } -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::set_element_count -// Access: Public -// Description: Set the number of elements being cycled through -//////////////////////////////////////////////////////////////////// +/** + * Set the number of elements being cycled through + */ INLINE void TimedCycle:: set_element_count(int element_count) { _element_count = element_count; } -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::set_cycle_time -// Access: Public -// Description: Set the number of elements being cycled through -//////////////////////////////////////////////////////////////////// +/** + * Set the number of elements being cycled through + */ INLINE void TimedCycle:: set_cycle_time(PN_stdfloat cycle_time) { @@ -78,11 +69,9 @@ set_cycle_time(PN_stdfloat cycle_time) } -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::next_element -// Access: Public -// Description: Set the number of elements being cycled through -//////////////////////////////////////////////////////////////////// +/** + * Set the number of elements being cycled through + */ INLINE int TimedCycle:: next_element() { @@ -95,4 +84,3 @@ next_element() return _current_child; } - diff --git a/panda/src/putil/timedCycle.cxx b/panda/src/putil/timedCycle.cxx index 69a420337c..f85e3aef4b 100644 --- a/panda/src/putil/timedCycle.cxx +++ b/panda/src/putil/timedCycle.cxx @@ -1,40 +1,35 @@ -// Filename: timedCycle.cxx -// Created by: jason (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -#include "pandabase.h" +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timedCycle.cxx + * @author jason + * @date 2000-08-01 + */ + #include "timedCycle.h" #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::write_object -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TimedCycle:: write_datagram(Datagram &me) { me.add_stdfloat(_cycle_time); me.add_uint16(_element_count); } -//////////////////////////////////////////////////////////////////// -// Function: TimedCycle::fillin -// Access: Protected -// Description: This internal function is called by make_TimedCycle to -// read in all of the relevant data from the BamFile for -// the new TimedCycle. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_TimedCycle to read in all of the + * relevant data from the BamFile for the new TimedCycle. + */ void TimedCycle:: fillin(DatagramIterator &scan) { _cycle_time = scan.get_stdfloat(); diff --git a/panda/src/putil/timedCycle.h b/panda/src/putil/timedCycle.h index 41926e31a7..618c50deec 100644 --- a/panda/src/putil/timedCycle.h +++ b/panda/src/putil/timedCycle.h @@ -1,23 +1,19 @@ -// Filename: timedCycle.h -// Created by: jason (01Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file timedCycle.h + * @author jason + * @date 2000-08-01 + */ #ifndef TIMED_CYCLE_H #define TIMED_CYCLE_H -// -//////////////////////////////////////////////////////////////////// // Includes -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include "clockObject.h" @@ -25,13 +21,11 @@ class Datagram; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : TimedCycle -// Description : A class for anything that needs to cycle over -// some finite list of elements in increments based on -// time. All time variables are assumed to be set in -// seconds. -//////////////////////////////////////////////////////////////////// +/** + * A class for anything that needs to cycle over some finite list of elements + * in increments based on time. All time variables are assumed to be set in + * seconds. + */ class EXPCL_PANDA_PUTIL TimedCycle { diff --git a/panda/src/putil/typedWritable.I b/panda/src/putil/typedWritable.I index 796dffc9bb..dc40248c4a 100644 --- a/panda/src/putil/typedWritable.I +++ b/panda/src/putil/typedWritable.I @@ -1,87 +1,69 @@ -// Filename: typedWritable.I -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritable.I + * @author jason + * @date 2000-06-08 + */ -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedWritable:: TypedWritable() : _bam_writers(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedWritable:: TypedWritable(const TypedWritable &) : _bam_writers(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypedWritable:: operator = (const TypedWritable &) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::mark_bam_modified -// Access: Public -// Description: Increments the bam_modified counter, so that this -// object will be invalidated and retransmitted on any -// open bam streams. This should normally not need to -// be called by user code; it should be called -// internally when the object has been changed in a way -// that legitimately requires its retransmission to any -// connected clients. -//////////////////////////////////////////////////////////////////// +/** + * Increments the bam_modified counter, so that this object will be + * invalidated and retransmitted on any open bam streams. This should + * normally not need to be called by user code; it should be called internally + * when the object has been changed in a way that legitimately requires its + * retransmission to any connected clients. + */ INLINE void TypedWritable:: mark_bam_modified() { ++_bam_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::get_bam_modified -// Access: Public -// Description: Returns the current bam_modified counter. This -// counter is normally incremented automatically -// whenever the object is modified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current bam_modified counter. This counter is normally + * incremented automatically whenever the object is modified. + */ INLINE UpdateSeq TypedWritable:: get_bam_modified() const { return _bam_modified; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::encode_to_bam_stream -// Access: Published -// Description: Converts the TypedWritable object into a single -// stream of data using a BamWriter, and returns that -// data as a string string. Returns empty string on -// failure. -// -// This is a convenience method particularly useful for -// cases when you are only serializing a single object. -// If you have many objects to process, it is more -// efficient to use the same BamWriter to serialize all -// of them together. -//////////////////////////////////////////////////////////////////// +/** + * Converts the TypedWritable object into a single stream of data using a + * BamWriter, and returns that data as a string string. Returns empty string + * on failure. + * + * This is a convenience method particularly useful for cases when you are + * only serializing a single object. If you have many objects to process, it + * is more efficient to use the same BamWriter to serialize all of them + * together. + */ INLINE string TypedWritable:: encode_to_bam_stream() const { string data; @@ -90,4 +72,3 @@ encode_to_bam_stream() const { } return data; } - diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index 53359674cc..ed29f779e4 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -1,16 +1,15 @@ -// Filename: typedWritable.cxx -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritable.cxx + * @author jason + * @date 2000-06-08 + */ #include "typedWritable.h" #include "bamWriter.h" @@ -23,11 +22,9 @@ TypeHandle TypedWritable::_type_handle; TypedWritable* const TypedWritable::Null = (TypedWritable*)0L; -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TypedWritable:: ~TypedWritable() { // Remove the object pointer from the BamWriters that reference it. @@ -50,127 +47,99 @@ TypedWritable:: } } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void TypedWritable:: write_datagram(BamWriter *, Datagram &) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::update_bam_nested -// Access: Public, Virtual -// Description: Called by the BamWriter when this object has not -// itself been modified recently, but it should check -// its nested objects for updates. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamWriter when this object has not itself been modified + * recently, but it should check its nested objects for updates. + */ void TypedWritable:: update_bam_nested(BamWriter *) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -// -// This is the callback function that is made by the -// BamReader at some later point, after all of the -// required pointers have been filled in. It is -// necessary because there might be forward references -// in a bam file; when we call read_pointer() in -// fillin(), the object may not have been read from the -// file yet, so we do not have a pointer available at -// that time. Thus, instead of returning a pointer, -// read_pointer() simply reserves a later callback. -// This function provides that callback. The calling -// object is responsible for keeping track of the number -// of times it called read_pointer() and extracting the -// same number of pointers out of the supplied vector, -// and storing them appropriately within the object. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + * + * This is the callback function that is made by the BamReader at some later + * point, after all of the required pointers have been filled in. It is + * necessary because there might be forward references in a bam file; when we + * call read_pointer() in fillin(), the object may not have been read from the + * file yet, so we do not have a pointer available at that time. Thus, + * instead of returning a pointer, read_pointer() simply reserves a later + * callback. This function provides that callback. The calling object is + * responsible for keeping track of the number of times it called + * read_pointer() and extracting the same number of pointers out of the + * supplied vector, and storing them appropriately within the object. + */ int TypedWritable:: complete_pointers(TypedWritable **, BamReader *) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::require_fully_complete -// Access: Public, Virtual -// Description: Some objects require all of their nested pointers to -// have been completed before the objects themselves can -// be completed. If this is the case, override this -// method to return true, and be careful with circular -// references (which would make the object unreadable -// from a bam file). -//////////////////////////////////////////////////////////////////// +/** + * Some objects require all of their nested pointers to have been completed + * before the objects themselves can be completed. If this is the case, + * override this method to return true, and be careful with circular + * references (which would make the object unreadable from a bam file). + */ bool TypedWritable:: require_fully_complete() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::fillin -// Access: Public, Virtual -// Description: This internal function is intended to be called by -// each class's make_from_bam() method to read in all of -// the relevant data from the BamFile for the new -// object. It is also called directly by the BamReader -// to re-read the data for an object that has been -// placed on the stream for an update. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is intended to be called by each class's + * make_from_bam() method to read in all of the relevant data from the BamFile + * for the new object. It is also called directly by the BamReader to re-read + * the data for an object that has been placed on the stream for an update. + */ void TypedWritable:: fillin(DatagramIterator &, BamReader *) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void TypedWritable:: finalize(BamReader *) { } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::as_reference_count -// Access: Public, Virtual -// Description: Returns the pointer cast to a ReferenceCount pointer, -// if it is in fact of that type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer cast to a ReferenceCount pointer, if it is in fact of + * that type. + */ ReferenceCount *TypedWritable:: as_reference_count() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::encode_to_bam_stream -// Access: Published -// Description: Converts the TypedWritable object into a single -// stream of data using a BamWriter, and stores that -// data in the indicated string. Returns true on -// success, false on failure. -// -// This is a convenience method particularly useful for -// cases when you are only serializing a single object. -// If you have many objects to process, it is more -// efficient to use the same BamWriter to serialize all -// of them together. -//////////////////////////////////////////////////////////////////// +/** + * Converts the TypedWritable object into a single stream of data using a + * BamWriter, and stores that data in the indicated string. Returns true on + * success, false on failure. + * + * This is a convenience method particularly useful for cases when you are + * only serializing a single object. If you have many objects to process, it + * is more efficient to use the same BamWriter to serialize all of them + * together. + */ bool TypedWritable:: encode_to_bam_stream(string &data, BamWriter *writer) const { data.clear(); ostringstream stream; - // We use nested scoping to ensure the destructors get called in the - // right order. + // We use nested scoping to ensure the destructors get called in the right + // order. { DatagramOutputFile dout; if (!dout.open(stream)) { @@ -207,33 +176,26 @@ encode_to_bam_stream(string &data, BamWriter *writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::decode_raw_from_bam_stream -// Access: Published, Static -// Description: Reads the string created by a previous call to -// encode_to_bam_stream(), and extracts the single -// object on that string. Returns true on success, -// false on on error. -// -// This variant sets the TypedWritable and -// ReferenceCount pointers separately; both are pointers -// to the same object. The reference count is not -// incremented; it is the caller's responsibility to -// manage the reference count. -// -// Note that this method cannot be used to retrieve -// objects that do not inherit from ReferenceCount, -// because these objects cannot persist beyond the -// lifetime of the BamReader that reads them. To -// retrieve these objects from a bam stream, you must -// construct a BamReader directly. -// -// If you happen to know that the particular object in -// question inherits from TypedWritableReferenceCount or -// PandaNode, consider calling the variant of -// decode_from_bam_stream() defined for those methods, -// which presents a simpler interface. -//////////////////////////////////////////////////////////////////// +/** + * Reads the string created by a previous call to encode_to_bam_stream(), and + * extracts the single object on that string. Returns true on success, false + * on on error. + * + * This variant sets the TypedWritable and ReferenceCount pointers separately; + * both are pointers to the same object. The reference count is not + * incremented; it is the caller's responsibility to manage the reference + * count. + * + * Note that this method cannot be used to retrieve objects that do not + * inherit from ReferenceCount, because these objects cannot persist beyond + * the lifetime of the BamReader that reads them. To retrieve these objects + * from a bam stream, you must construct a BamReader directly. + * + * If you happen to know that the particular object in question inherits from + * TypedWritableReferenceCount or PandaNode, consider calling the variant of + * decode_from_bam_stream() defined for those methods, which presents a + * simpler interface. + */ bool TypedWritable:: decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader) { @@ -273,8 +235,8 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, return false; } - // Protect the pointer from accidental deletion when the BamReader - // goes away. + // Protect the pointer from accidental deletion when the BamReader goes + // away. ref_ptr->ref(); } else { @@ -296,28 +258,25 @@ decode_raw_from_bam_stream(TypedWritable *&ptr, ReferenceCount *&ref_ptr, return false; } - // This BamReader isn't going away, but we have to balance the - // unref() below. + // This BamReader isn't going away, but we have to balance the unref() + // below. ref_ptr->ref(); reader->set_source(NULL); } - // Now decrement the ref count, without deleting the object. This - // may reduce the reference count to zero, but that's OK--we trust - // the caller to manage the reference count from this point on. + // Now decrement the ref count, without deleting the object. This may + // reduce the reference count to zero, but that's OK--we trust the caller to + // manage the reference count from this point on. ref_ptr->unref(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::add_bam_writer -// Access: Private -// Description: Called by the BamWriter to add itself to this -// TypedWritable's list of BamWriters, so that it can -// receive notification whenever this object destructs. -// This method may be safely called from any thread. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamWriter to add itself to this TypedWritable's list of + * BamWriters, so that it can receive notification whenever this object + * destructs. This method may be safely called from any thread. + */ void TypedWritable:: add_bam_writer(BamWriter *writer) { nassertv(writer != (BamWriter *)NULL); @@ -329,7 +288,7 @@ add_bam_writer(BamWriter *writer) { // Assert that we got at least a 2-byte aligned pointer from new. nassertv(((uintptr_t)new_link & (uintptr_t)0x1) == 0); - // This spins if the lower bit is 1, ie. if the pointer is locked. + // This spins if the lower bit is 1, ie. if the pointer is locked. do { begin = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1); @@ -338,20 +297,18 @@ add_bam_writer(BamWriter *writer) { compare_and_exchange_ptr(_bam_writers, (void *)begin, (void *)new_link)); } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::remove_bam_writer -// Access: Private -// Description: The converse of add_bam_writer. -// This method may be safely called from any thread. -//////////////////////////////////////////////////////////////////// +/** + * The converse of add_bam_writer. This method may be safely called from any + * thread. + */ void TypedWritable:: remove_bam_writer(BamWriter *writer) { nassertv(writer != (BamWriter *)NULL); BamWriterLink *begin; - // Grab the head pointer and lock it in one atomic operation. - // We lock it by tagging the pointer. + // Grab the head pointer and lock it in one atomic operation. We lock it by + // tagging the pointer. do { begin = (BamWriterLink *)AtomicAdjust::get_ptr(_bam_writers); begin = (BamWriterLink *)(((uintptr_t)begin) & ~(uintptr_t)0x1); diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h index 9b23f1eba4..20d7a7cb67 100644 --- a/panda/src/putil/typedWritable.h +++ b/panda/src/putil/typedWritable.h @@ -1,16 +1,15 @@ -// Filename: typedWritable.h -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritable.h + * @author jason + * @date 2000-06-08 + */ #ifndef TYPEDWRITABLE_H #define TYPEDWRITABLE_H @@ -27,13 +26,11 @@ class Datagram; class DatagramIterator; class ReferenceCount; -//////////////////////////////////////////////////////////////////// -// Class : TypedWritable -// Description : Base class for objects that can be written to and -// read from Bam files. -// -// See also TypedObject for detailed instructions. -//////////////////////////////////////////////////////////////////// +/** + * Base class for objects that can be written to and read from Bam files. + * + * See also TypedObject for detailed instructions. + */ class EXPCL_PANDA_PUTIL TypedWritable : public TypedObject { public: static TypedWritable* const Null; @@ -73,9 +70,9 @@ private: void add_bam_writer(BamWriter *writer); void remove_bam_writer(BamWriter *writer); - // We may need to store a list of the BamWriter(s) that have a - // reference to this object, so that we can remove the object from - // those tables when it destructs. + // We may need to store a list of the BamWriter(s) that have a reference to + // this object, so that we can remove the object from those tables when it + // destructs. struct BamWriterLink { BamWriter *_writer; BamWriterLink *_next; diff --git a/panda/src/putil/typedWritableReferenceCount.I b/panda/src/putil/typedWritableReferenceCount.I index e0079b3460..3c1b9e54ce 100644 --- a/panda/src/putil/typedWritableReferenceCount.I +++ b/panda/src/putil/typedWritableReferenceCount.I @@ -1,23 +1,19 @@ -// Filename: typedWritableReferenceCount.I -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritableReferenceCount.I + * @author jason + * @date 2000-06-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypedWritableReferenceCount::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedWritableReferenceCount:: TypedWritableReferenceCount() { #ifdef DO_MEMORY_USAGE @@ -25,11 +21,9 @@ TypedWritableReferenceCount() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritableReferenceCount::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedWritableReferenceCount:: TypedWritableReferenceCount(const TypedWritableReferenceCount ©) : TypedWritable(copy), @@ -39,11 +33,9 @@ TypedWritableReferenceCount(const TypedWritableReferenceCount ©) : #endif } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritableReferenceCount::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TypedWritableReferenceCount:: operator = (const TypedWritableReferenceCount ©) { TypedWritable::operator = (copy); diff --git a/panda/src/putil/typedWritableReferenceCount.cxx b/panda/src/putil/typedWritableReferenceCount.cxx index 9e5bcb2910..40a1db268b 100644 --- a/panda/src/putil/typedWritableReferenceCount.cxx +++ b/panda/src/putil/typedWritableReferenceCount.cxx @@ -1,48 +1,41 @@ -// Filename: typedWritableReferenceCount.cxx -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritableReferenceCount.cxx + * @author jason + * @date 2000-06-08 + */ #include "typedWritableReferenceCount.h" #include "dcast.h" TypeHandle TypedWritableReferenceCount::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TypedWritableReferenceCount::as_reference_count -// Access: Public, Virtual -// Description: Returns the pointer cast to a ReferenceCount pointer, -// if it is in fact of that type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer cast to a ReferenceCount pointer, if it is in fact of + * that type. + */ ReferenceCount *TypedWritableReferenceCount:: as_reference_count() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritableReferenceCount::decode_from_bam_stream -// Access: Published, Static -// Description: Reads the string created by a previous call to -// encode_to_bam_stream(), and extracts and returns the -// single object on that string. Returns NULL on error. -// -// This method is intended to replace -// decode_raw_from_bam_stream() when you know the stream -// in question returns an object of type -// TypedWritableReferenceCount, allowing for easier -// reference count management. Note that the caller is -// still responsible for maintaining the reference count -// on the return value. -//////////////////////////////////////////////////////////////////// +/** + * Reads the string created by a previous call to encode_to_bam_stream(), and + * extracts and returns the single object on that string. Returns NULL on + * error. + * + * This method is intended to replace decode_raw_from_bam_stream() when you + * know the stream in question returns an object of type + * TypedWritableReferenceCount, allowing for easier reference count + * management. Note that the caller is still responsible for maintaining the + * reference count on the return value. + */ PT(TypedWritableReferenceCount) TypedWritableReferenceCount:: decode_from_bam_stream(const string &data, BamReader *reader) { TypedWritable *object; diff --git a/panda/src/putil/typedWritableReferenceCount.h b/panda/src/putil/typedWritableReferenceCount.h index 8642d02541..97d7d90029 100644 --- a/panda/src/putil/typedWritableReferenceCount.h +++ b/panda/src/putil/typedWritableReferenceCount.h @@ -1,16 +1,15 @@ -// Filename: typedWritableReferenceCount.h -// Created by: jason (08Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritableReferenceCount.h + * @author jason + * @date 2000-06-08 + */ #ifndef TYPEDWRITABLEREFERENCECOUNT_H #define TYPEDWRITABLEREFERENCECOUNT_H @@ -20,18 +19,15 @@ #include "typedWritable.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : TypedWritableReferenceCount -// Description : A base class for things which need to inherit from -// both TypedWritable and from ReferenceCount. It's -// convenient to define this intermediate base class -// instead of multiply inheriting from the two classes -// each time they are needed, so that we can sensibly -// pass around pointers to things which are both -// TypedWritables and ReferenceCounters. -// -// See also TypedObject for detailed instructions. -//////////////////////////////////////////////////////////////////// +/** + * A base class for things which need to inherit from both TypedWritable and + * from ReferenceCount. It's convenient to define this intermediate base + * class instead of multiply inheriting from the two classes each time they + * are needed, so that we can sensibly pass around pointers to things which + * are both TypedWritables and ReferenceCounters. + * + * See also TypedObject for detailed instructions. + */ class EXPCL_PANDA_PUTIL TypedWritableReferenceCount : public TypedWritable, public ReferenceCount { public: INLINE TypedWritableReferenceCount(); diff --git a/panda/src/putil/typedWritable_ext.cxx b/panda/src/putil/typedWritable_ext.cxx index 80e3ea2d47..afa7f986c8 100644 --- a/panda/src/putil/typedWritable_ext.cxx +++ b/panda/src/putil/typedWritable_ext.cxx @@ -1,16 +1,15 @@ -// Filename: typedWritable_ext.cxx -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritable_ext.cxx + * @author rdb + * @date 2013-12-10 + */ #include "typedWritable_ext.h" @@ -20,43 +19,35 @@ extern Dtool_PyTypedObject Dtool_BamWriter; #endif // CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::__reduce__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + * + * This hooks into the native pickle and cPickle modules, but it cannot + * properly handle self-referential BAM objects. + */ PyObject *Extension:: __reduce__(PyObject *self) const { return __reduce_persist__(self, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::__reduce_persist__ -// Access: Published -// Description: This special Python method is implement to provide -// support for the pickle module. -// -// This is similar to __reduce__, but it provides -// additional support for the missing persistent-state -// object needed to properly support self-referential -// BAM objects written to the pickle stream. This hooks -// into the pickle and cPickle modules implemented in -// direct/src/stdpy. -//////////////////////////////////////////////////////////////////// +/** + * This special Python method is implement to provide support for the pickle + * module. + * + * This is similar to __reduce__, but it provides additional support for the + * missing persistent-state object needed to properly support self-referential + * BAM objects written to the pickle stream. This hooks into the pickle and + * cPickle modules implemented in direct/src/stdpy. + */ PyObject *Extension:: __reduce_persist__(PyObject *self, PyObject *pickler) const { - // We should return at least a 2-tuple, (Class, (args)): the - // necessary class object whose constructor we should call - // (e.g. this), and the arguments necessary to reconstruct this - // object. + // We should return at least a 2-tuple, (Class, (args)): the necessary class + // object whose constructor we should call (e.g. this), and the arguments + // necessary to reconstruct this object. - // Check that we have a decode_from_bam_stream python method. If not, - // we can't use this interface. + // Check that we have a decode_from_bam_stream python method. If not, we + // can't use this interface. PyObject *method = PyObject_GetAttrString(self, "decode_from_bam_stream"); if (method == NULL) { ostringstream stream; @@ -97,9 +88,9 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { PyObject *func; if (writer != NULL) { - // The modified pickle support: call the "persistent" version of - // this function, which receives the unpickler itself as an - // additional parameter. + // The modified pickle support: call the "persistent" version of this + // function, which receives the unpickler itself as an additional + // parameter. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream_persist"); if (func == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't find py_decode_TypedWritable_from_bam_stream_persist()"); @@ -108,8 +99,8 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { } } else { - // The traditional pickle support: call the non-persistent version - // of this function. + // The traditional pickle support: call the non-persistent version of this + // function. func = find_global_decode(this_class, "py_decode_TypedWritable_from_bam_stream"); if (func == NULL) { @@ -125,19 +116,15 @@ __reduce_persist__(PyObject *self, PyObject *pickler) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TypedWritable::find_global_decode -// Access: Public, Static -// Description: This is a support function for __reduce__(). It -// searches for the global function -// py_decode_TypedWritable_from_bam_stream() in this -// class's module, or in the module for any base class. -// (It's really looking for the libpanda module, but we -// can't be sure what name that module was loaded under, -// so we search upwards this way.) -// -// Returns: new reference on success, or NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * This is a support function for __reduce__(). It searches for the global + * function py_decode_TypedWritable_from_bam_stream() in this class's module, + * or in the module for any base class. (It's really looking for the libpanda + * module, but we can't be sure what name that module was loaded under, so we + * search upwards this way.) + * + * Returns: new reference on success, or NULL on failure. + */ PyObject *Extension:: find_global_decode(PyObject *this_class, const char *func_name) { PyObject *module_name = PyObject_GetAttrString(this_class, "__module__"); @@ -180,35 +167,26 @@ find_global_decode(PyObject *this_class, const char *func_name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: py_decode_TypedWritable_from_bam_stream -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -// -// This hooks into the native pickle and cPickle -// modules, but it cannot properly handle -// self-referential BAM objects. -//////////////////////////////////////////////////////////////////// +/** + * This wrapper is defined as a global function to suit pickle's needs. + * + * This hooks into the native pickle and cPickle modules, but it cannot + * properly handle self-referential BAM objects. + */ PyObject * py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const string &data) { return py_decode_TypedWritable_from_bam_stream_persist(NULL, this_class, data); } -//////////////////////////////////////////////////////////////////// -// Function: py_decode_TypedWritable_from_bam_stream_persist -// Access: Published -// Description: This wrapper is defined as a global function to suit -// pickle's needs. -// -// This is similar to -// py_decode_TypedWritable_from_bam_stream, but it -// provides additional support for the missing -// persistent-state object needed to properly support -// self-referential BAM objects written to the pickle -// stream. This hooks into the pickle and cPickle -// modules implemented in direct/src/stdpy. -//////////////////////////////////////////////////////////////////// +/** + * This wrapper is defined as a global function to suit pickle's needs. + * + * This is similar to py_decode_TypedWritable_from_bam_stream, but it provides + * additional support for the missing persistent-state object needed to + * properly support self-referential BAM objects written to the pickle stream. + * This hooks into the pickle and cPickle modules implemented in + * direct/src/stdpy. + */ PyObject * py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *this_class, const string &data) { @@ -222,10 +200,10 @@ py_decode_TypedWritable_from_bam_stream_persist(PyObject *pickler, PyObject *thi } // We need the function PandaNode::decode_from_bam_stream or - // TypedWritableReferenceCount::decode_from_bam_stream, which - // invokes the BamReader to reconstruct this object. Since we use - // the specific object's class as the pointer, we get the particular - // instance of decode_from_bam_stream appropriate to this class. + // TypedWritableReferenceCount::decode_from_bam_stream, which invokes the + // BamReader to reconstruct this object. Since we use the specific object's + // class as the pointer, we get the particular instance of + // decode_from_bam_stream appropriate to this class. PyObject *func = PyObject_GetAttrString(this_class, "decode_from_bam_stream"); if (func == NULL) { diff --git a/panda/src/putil/typedWritable_ext.h b/panda/src/putil/typedWritable_ext.h index b42092ab33..1582021c49 100644 --- a/panda/src/putil/typedWritable_ext.h +++ b/panda/src/putil/typedWritable_ext.h @@ -1,16 +1,15 @@ -// Filename: typedWritable_ext.h -// Created by: rdb (10Dec13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedWritable_ext.h + * @author rdb + * @date 2013-12-10 + */ #ifndef TYPEDWRITABLE_EXT_H #define TYPEDWRITABLE_EXT_H @@ -23,12 +22,10 @@ #include "typedWritable.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// StreamReader, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for StreamReader, which are called + * instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/putil/uniqueIdAllocator.cxx b/panda/src/putil/uniqueIdAllocator.cxx index 24940e22f2..3bca1d1ea6 100644 --- a/panda/src/putil/uniqueIdAllocator.cxx +++ b/panda/src/putil/uniqueIdAllocator.cxx @@ -1,16 +1,15 @@ -// Filename: uniqueIdAllocator.cxx -// Created by: schuyler 2003-03-13 -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file uniqueIdAllocator.cxx + * @author schuyler + * @date 2003-03-13 + */ #include "pandabase.h" #include "pnotify.h" @@ -47,11 +46,9 @@ const PN_uint32 UniqueIdAllocator::IndexAllocated = (PN_uint32)-2; audio_cat->error() << msg << endl -//////////////////////////////////////////////////////////////////// -// Function: UniqueIdAllocator::Constructor -// Access: Published -// Description: Create a free id pool in the range [min:max]. -//////////////////////////////////////////////////////////////////// +/** + * Create a free id pool in the range [min:max]. + */ UniqueIdAllocator:: UniqueIdAllocator(PN_uint32 min, PN_uint32 max) : _min(min), _max(max) { @@ -73,11 +70,9 @@ UniqueIdAllocator(PN_uint32 min, PN_uint32 max) _free = _size; } -//////////////////////////////////////////////////////////////////// -// Function: UniqueIdAllocator::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ UniqueIdAllocator:: ~UniqueIdAllocator() { uniqueIdAllocator_debug("~UniqueIdAllocator()"); @@ -85,13 +80,10 @@ UniqueIdAllocator:: } -//////////////////////////////////////////////////////////////////// -// Function: UniqueIdAllocator::allocate -// Access: Published -// Description: Returns an id between _min and _max (that were passed -// to the constructor). -// IndexEnd is returned if no ids are available. -//////////////////////////////////////////////////////////////////// +/** + * Returns an id between _min and _max (that were passed to the constructor). + * IndexEnd is returned if no ids are available. + */ PN_uint32 UniqueIdAllocator:: allocate() { if (_next_free == IndexEnd) { @@ -112,22 +104,17 @@ allocate() { return id; } -//////////////////////////////////////////////////////////////////// -// Function: UniqueIdAllocator::initial_reserve_id -// Access: Published -// Description: This may be called to mark a particular id as having -// already been allocated (for instance, by a prior -// pass). The specified id is removed from the -// available pool. -// -// Because of the limitations of this algorithm, this is -// most efficient when it is called before the first -// call to allocate(), and when all the calls to -// initial_reserve_id() are made in descending order by -// id. However, this is a performance warning only; if -// performance is not an issue, any id may be reserved -// at any time. -//////////////////////////////////////////////////////////////////// +/** + * This may be called to mark a particular id as having already been allocated + * (for instance, by a prior pass). The specified id is removed from the + * available pool. + * + * Because of the limitations of this algorithm, this is most efficient when + * it is called before the first call to allocate(), and when all the calls to + * initial_reserve_id() are made in descending order by id. However, this is + * a performance warning only; if performance is not an issue, any id may be + * reserved at any time. + */ void UniqueIdAllocator:: initial_reserve_id(PN_uint32 id) { nassertv(id >= _min && id <= _max); // Attempt to reserve out-of-range id. @@ -144,18 +131,17 @@ initial_reserve_id(PN_uint32 id) { _next_free = _table[index]; } else { - // Since we don't store back pointers in the free chain, we have - // to search for the element in the free chain that points to this - // index. + // Since we don't store back pointers in the free chain, we have to search + // for the element in the free chain that points to this index. - // However, there is an easy optimal case: because we expect that - // this call will be made before any calls to allocate(), - // hopefully is it still true that the _table is still set up such - // that _table[i] = i+1 (and if the numbers are reserved in - // descending order, this will be true at least for all i <= - // index). Thus, the free link to slot [index] is expected to be - // the slot right before it, or if not, it usually won't be far - // before it. +/* + * However, there is an easy optimal case: because we expect that this call + * will be made before any calls to allocate(), hopefully is it still true + * that the _table is still set up such that _table[i] = i+1 (and if the + * numbers are reserved in descending order, this will be true at least for + * all i <= index). Thus, the free link to slot [index] is expected to be the + * slot right before it, or if not, it usually won't be far before it. + */ PN_uint32 prev_index = index; while (prev_index > 0 && _table[prev_index - 1] != index) { @@ -186,12 +172,10 @@ initial_reserve_id(PN_uint32 id) { } -//////////////////////////////////////////////////////////////////// -// Function: UniqueIdAllocator::free -// Access: Published -// Description: Free an allocated index (index must be between _min -// and _max that were passed to the constructor). -//////////////////////////////////////////////////////////////////// +/** + * Free an allocated index (index must be between _min and _max that were + * passed to the constructor). + */ void UniqueIdAllocator:: free(PN_uint32 id) { uniqueIdAllocator_debug("free("< (const UpdateSeq &other) const { return (other < (*this)); } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::Comparison operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool UpdateSeq:: operator >= (const UpdateSeq &other) const { return (other <= (*this)); } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::Preincrement operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq UpdateSeq:: operator ++ () { AtomicAdjust::Integer old_seq = AtomicAdjust::get(_seq); AtomicAdjust::Integer new_seq = old_seq + 1; if (priv_is_special(new_seq)) { - // Oops, wraparound. We don't want to confuse the new value - // with our special cases. + // Oops, wraparound. We don't want to confuse the new value with our + // special cases. new_seq = (AtomicAdjust::Integer)SC_old + 1; } @@ -214,8 +174,8 @@ operator ++ () { old_seq = AtomicAdjust::get(_seq); new_seq = old_seq + 1; if (priv_is_special(new_seq)) { - // Oops, wraparound. We don't want to confuse the new value - // with our special cases. + // Oops, wraparound. We don't want to confuse the new value with our + // special cases. new_seq = (AtomicAdjust::Integer)SC_old + 1; } result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); @@ -227,18 +187,16 @@ operator ++ () { return *this; } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::Postincrement operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE UpdateSeq UpdateSeq:: operator ++ (int) { AtomicAdjust::Integer old_seq = AtomicAdjust::get(_seq); AtomicAdjust::Integer new_seq = old_seq + 1; if (priv_is_special(new_seq)) { - // Oops, wraparound. We don't want to confuse the new value - // with our special cases. + // Oops, wraparound. We don't want to confuse the new value with our + // special cases. new_seq = (AtomicAdjust::Integer)SC_old + 1; } @@ -249,8 +207,8 @@ operator ++ (int) { old_seq = AtomicAdjust::get(_seq); new_seq = old_seq + 1; if (priv_is_special(new_seq)) { - // Oops, wraparound. We don't want to confuse the new value - // with our special cases. + // Oops, wraparound. We don't want to confuse the new value with our + // special cases. new_seq = (AtomicAdjust::Integer)SC_old + 1; } result = AtomicAdjust::compare_and_exchange(_seq, old_seq, new_seq); @@ -264,22 +222,18 @@ operator ++ (int) { return temp; } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::get_seq -// Access: Published -// Description: Returns the internal integer value associated with -// the UpdateSeq. Useful for debugging only. -//////////////////////////////////////////////////////////////////// +/** + * Returns the internal integer value associated with the UpdateSeq. Useful + * for debugging only. + */ INLINE AtomicAdjust::Integer UpdateSeq:: get_seq() const { return _seq; } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void UpdateSeq:: output(ostream &out) const { AtomicAdjust::Integer seq = AtomicAdjust::get(_seq); @@ -301,39 +255,33 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::priv_is_special -// Access: Private, Static -// Description: The private implementation of is_special(). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of is_special(). + */ INLINE bool UpdateSeq:: priv_is_special(AtomicAdjust::Integer seq) { // This relies on the assumption that (~0 + 1) == 0. return (((unsigned int)seq + 1) <= 2); } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::priv_lt -// Access: Private, Static -// Description: The private implementation of operator < (). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of operator < (). + */ INLINE bool UpdateSeq:: priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b) { - // The special cases of SC_initial or SC_old are less than all other - // non-special numbers, and SC_initial is less than SC_old. The - // special case of SC_fresh is greater than all other non-special - // numbers. For all other cases, we use a circular comparision such - // that n < m iff (signed)(n - m) < 0. + // The special cases of SC_initial or SC_old are less than all other non- + // special numbers, and SC_initial is less than SC_old. The special case of + // SC_fresh is greater than all other non-special numbers. For all other + // cases, we use a circular comparision such that n < m iff (signed)(n - m) + // < 0. return (priv_is_special(a) || priv_is_special(b)) ? ((unsigned int)a < (unsigned int)b) : ((signed int)(a - b) < 0); } -//////////////////////////////////////////////////////////////////// -// Function: UpdateSeq::priv_le -// Access: Private, Static -// Description: The private implementation of operator <= (). -//////////////////////////////////////////////////////////////////// +/** + * The private implementation of operator <= (). + */ INLINE bool UpdateSeq:: priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b) { return (a == b) || priv_lt(a, b); diff --git a/panda/src/putil/updateSeq.cxx b/panda/src/putil/updateSeq.cxx index 8d5d9c804e..bebb0b45ca 100644 --- a/panda/src/putil/updateSeq.cxx +++ b/panda/src/putil/updateSeq.cxx @@ -1,15 +1,14 @@ -// Filename: updateSeq.cxx -// Created by: mike (30Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file updateSeq.cxx + * @author mike + * @date 1999-09-30 + */ #include "updateSeq.h" diff --git a/panda/src/putil/updateSeq.h b/panda/src/putil/updateSeq.h index ced820d585..4899787244 100644 --- a/panda/src/putil/updateSeq.h +++ b/panda/src/putil/updateSeq.h @@ -1,16 +1,15 @@ -// Filename: updateSeq.h -// Created by: drose (30Sep99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file updateSeq.h + * @author drose + * @date 1999-09-30 + */ #ifndef UPDATE_SEQ #define UPDATE_SEQ @@ -21,25 +20,20 @@ #include "atomicAdjust.h" #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : UpdateSeq -// Description : This is a sequence number that increments -// monotonically. It can be used to track cache -// updates, or serve as a kind of timestamp for any -// changing properties. -// -// A special class is used instead of simply an int, so -// we can elegantly handle such things as wraparound and -// special cases. There are two special cases. -// Firstly, a sequence number is 'initial' when it is -// first created. This sequence is older than any other -// sequence number. Secondly, a sequence number may be -// explicitly set to 'old'. This is older than any -// other sequence number except 'initial'. Finally, we -// have the explicit number 'fresh', which is newer -// than any other sequence number. All other sequences -// are numeric and are monotonically increasing. -//////////////////////////////////////////////////////////////////// +/** + * This is a sequence number that increments monotonically. It can be used to + * track cache updates, or serve as a kind of timestamp for any changing + * properties. + * + * A special class is used instead of simply an int, so we can elegantly + * handle such things as wraparound and special cases. There are two special + * cases. Firstly, a sequence number is 'initial' when it is first created. + * This sequence is older than any other sequence number. Secondly, a + * sequence number may be explicitly set to 'old'. This is older than any + * other sequence number except 'initial'. Finally, we have the explicit + * number 'fresh', which is newer than any other sequence number. All other + * sequences are numeric and are monotonically increasing. + */ class EXPCL_PANDA_PUTIL UpdateSeq { PUBLISHED: INLINE UpdateSeq(); diff --git a/panda/src/putil/vector_typedWritable.cxx b/panda/src/putil/vector_typedWritable.cxx index 93ded49c64..7c306f959f 100644 --- a/panda/src/putil/vector_typedWritable.cxx +++ b/panda/src/putil/vector_typedWritable.cxx @@ -1,16 +1,15 @@ -// Filename: vector_typedWritable.cxx -// Created by: jason (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_typedWritable.cxx + * @author jason + * @date 2000-06-19 + */ #include "vector_typedWritable.h" diff --git a/panda/src/putil/vector_typedWritable.h b/panda/src/putil/vector_typedWritable.h index acac81ce4f..61e87d19fa 100644 --- a/panda/src/putil/vector_typedWritable.h +++ b/panda/src/putil/vector_typedWritable.h @@ -1,16 +1,15 @@ -// Filename: vector_typedWritable.h -// Created by: jason (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_typedWritable.h + * @author jason + * @date 2000-06-19 + */ #ifndef VECTOR_TYPED_WRITABLE_H #define VECTOR_TYPED_WRITABLE_H @@ -21,14 +20,12 @@ class TypedWritable; -//////////////////////////////////////////////////////////////////// -// Class : vector_typedWritable -// Description : A vector of TypedWritable *. This class is defined -// once here, and exported to PANDA.DLL; other packages -// that want to use a vector of this type (whether they -// need to export it or not) should include this header -// file, rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of TypedWritable *. This class is defined once here, and exported + * to PANDA.DLL; other packages that want to use a vector of this type + * (whether they need to export it or not) should include this header file, + * rather than defining the vector again. + */ #define EXPCL EXPCL_PANDA_PUTIL #define EXPTP EXPTP_PANDA_PUTIL diff --git a/panda/src/putil/vector_ulong.cxx b/panda/src/putil/vector_ulong.cxx index 5f5977c3ee..58f63aed5c 100644 --- a/panda/src/putil/vector_ulong.cxx +++ b/panda/src/putil/vector_ulong.cxx @@ -1,16 +1,15 @@ -// Filename: vector_ulong.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_ulong.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_ulong.h" diff --git a/panda/src/putil/vector_ulong.h b/panda/src/putil/vector_ulong.h index 2ae68b334a..7f86a91d4d 100644 --- a/panda/src/putil/vector_ulong.h +++ b/panda/src/putil/vector_ulong.h @@ -1,16 +1,15 @@ -// Filename: vector_ulong.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_ulong.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_ULONG_H #define VECTOR_ULONG_H @@ -19,14 +18,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_ushort -// Description : A vector of ushorts. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of ushorts. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_PANDA_PUTIL #define EXPTP EXPTP_PANDA_PUTIL diff --git a/panda/src/putil/vector_ushort.cxx b/panda/src/putil/vector_ushort.cxx index de0f131c45..274aa9bed0 100644 --- a/panda/src/putil/vector_ushort.cxx +++ b/panda/src/putil/vector_ushort.cxx @@ -1,16 +1,15 @@ -// Filename: vector_ushort.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_ushort.cxx + * @author drose + * @date 2000-05-10 + */ #include "vector_ushort.h" diff --git a/panda/src/putil/vector_ushort.h b/panda/src/putil/vector_ushort.h index 6a7ecd9955..f336da3236 100644 --- a/panda/src/putil/vector_ushort.h +++ b/panda/src/putil/vector_ushort.h @@ -1,16 +1,15 @@ -// Filename: vector_ushort.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_ushort.h + * @author drose + * @date 2000-05-10 + */ #ifndef VECTOR_USHORT_H #define VECTOR_USHORT_H @@ -19,14 +18,12 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : vector_ushort -// Description : A vector of ushorts. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of ushorts. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_PANDA_PUTIL #define EXPTP EXPTP_PANDA_PUTIL diff --git a/panda/src/putil/vector_writable.cxx b/panda/src/putil/vector_writable.cxx index 2f351be26b..3faefc0c2f 100644 --- a/panda/src/putil/vector_writable.cxx +++ b/panda/src/putil/vector_writable.cxx @@ -1,16 +1,14 @@ -// Filename: vector_writable.cxx -// Created by: (15Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_writable.cxx + * @date 2000-06-15 + */ #include "vector_writable.h" diff --git a/panda/src/putil/vector_writable.h b/panda/src/putil/vector_writable.h index a7473a1507..8d3fd4b46a 100644 --- a/panda/src/putil/vector_writable.h +++ b/panda/src/putil/vector_writable.h @@ -1,16 +1,15 @@ -// Filename: vector_writable.h -// Created by: jason (14Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vector_writable.h + * @author jason + * @date 2000-06-14 + */ #ifndef VECTOR_WRITABLE_H #define VECTOR_WRITABLE_H @@ -21,14 +20,12 @@ class Writable; -//////////////////////////////////////////////////////////////////// -// Class : vector_writable -// Description : A vector of Writable *. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// +/** + * A vector of Writable *. This class is defined once here, and exported to + * PANDA.DLL; other packages that want to use a vector of this type (whether + * they need to export it or not) should include this header file, rather than + * defining the vector again. + */ #define EXPCL EXPCL_PANDA_PUTIL #define EXPTP EXPTP_PANDA_PUTIL diff --git a/panda/src/putil/weakKeyHashMap.I b/panda/src/putil/weakKeyHashMap.I index 128936fe20..ea5aa43e9a 100644 --- a/panda/src/putil/weakKeyHashMap.I +++ b/panda/src/putil/weakKeyHashMap.I @@ -1,23 +1,19 @@ -// Filename: weakKeyHashMap.I -// Created by: rdb (13Jul15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakKeyHashMap.I + * @author rdb + * @date 2015-07-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakKeyHashMap:: WeakKeyHashMap() : @@ -28,23 +24,18 @@ WeakKeyHashMap() : { } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template INLINE WeakKeyHashMap:: ~WeakKeyHashMap() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::swap -// Access: Public -// Description: Quickly exchanges the contents of this map and the -// other map. -//////////////////////////////////////////////////////////////////// +/** + * Quickly exchanges the contents of this map and the other map. + */ template INLINE void WeakKeyHashMap:: swap(WeakKeyHashMap &other) { @@ -65,13 +56,10 @@ swap(WeakKeyHashMap &other) { other._num_entries = t3; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::find -// Access: Public -// Description: Searches for the indicated key in the table. Returns -// its index number if it is found, or -1 if it is not -// present in the table. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated key in the table. Returns its index number if + * it is found, or -1 if it is not present in the table. + */ template int WeakKeyHashMap:: find(const Key *key) const { @@ -88,10 +76,10 @@ find(const Key *key) const { return index; } - // There was some other key at the hashed slot. That's a hash - // conflict. Maybe our entry was recorded at a later slot position; - // scan the subsequent positions until we find the entry or an - // unused slot, indicating the end of the scan. + // There was some other key at the hashed slot. That's a hash conflict. + // Maybe our entry was recorded at a later slot position; scan the + // subsequent positions until we find the entry or an unused slot, + // indicating the end of the scan. size_t i = index; i = (i + 1) & (_table_size - 1); while (i != index && has_element(i)) { @@ -105,13 +93,10 @@ find(const Key *key) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::store -// Access: Public -// Description: Records the indicated key/data pair in the map. If -// the key was already present, silently replaces it. -// Returns the index at which it was stored. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated key/data pair in the map. If the key was already + * present, silently replaces it. Returns the index at which it was stored. + */ template int WeakKeyHashMap:: store(const Key *key, const Value &data) { @@ -142,8 +127,7 @@ store(const Key *key, const Value &data) { return index; } if (is_element(index, key)) { - // This element is already in the map; replace the data at that - // key. + // This element is already in the map; replace the data at that key. _table[index]._data = data; #ifdef _DEBUG nassertr(validate(), index); @@ -151,8 +135,8 @@ store(const Key *key, const Value &data) { return index; } - // There was some other key at the hashed slot. That's a hash - // conflict. Record this entry at a later position. + // There was some other key at the hashed slot. That's a hash conflict. + // Record this entry at a later position. size_t i = index; i = (i + 1) & (_table_size - 1); while (i != index) { @@ -177,19 +161,16 @@ store(const Key *key, const Value &data) { i = (i + 1) & (_table_size - 1); } - // Shouldn't get here unless _num_entries == _table_size, which - // shouldn't be possible due to consider_expand_table(). + // Shouldn't get here unless _num_entries == _table_size, which shouldn't be + // possible due to consider_expand_table(). nassertr(false, -1); return -1; // To satisfy compiler } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::remove -// Access: Public -// Description: Removes the indicated key and its associated data -// from the table. Returns true if the key was removed, -// false if it was not present. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated key and its associated data from the table. Returns + * true if the key was removed, false if it was not present. + */ template INLINE bool WeakKeyHashMap:: remove(const Key *key) { @@ -201,11 +182,9 @@ remove(const Key *key) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::clear -// Access: Public -// Description: Completely empties the table. -//////////////////////////////////////////////////////////////////// +/** + * Completely empties the table. + */ template void WeakKeyHashMap:: clear() { @@ -224,13 +203,10 @@ clear() { } } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::operator [] -// Access: Public -// Description: Returns a modifiable reference to the data associated -// with the indicated key, or creates a new data entry -// and returns its reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the data associated with the indicated + * key, or creates a new data entry and returns its reference. + */ template INLINE Value &WeakKeyHashMap:: operator [] (const Key *key) { @@ -241,25 +217,21 @@ operator [] (const Key *key) { return modify_data(index); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_size -// Access: Public -// Description: Returns the total number of slots in the table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of slots in the table. + */ template INLINE size_t WeakKeyHashMap:: get_size() const { return _table_size; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::has_element -// Access: Public -// Description: Returns true if there is an element stored in the nth -// slot, false otherwise. -// -// n should be in the range 0 <= n < get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is an element stored in the nth slot, false + * otherwise. + * + * n should be in the range 0 <= n < get_size(). + */ template INLINE bool WeakKeyHashMap:: has_element(int n) const { @@ -267,16 +239,13 @@ has_element(int n) const { return (get_exists_array()[n] != 0 && !_table[n]._key.was_deleted()); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_key -// Access: Public -// Description: Returns the key in the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the key in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE const Key *WeakKeyHashMap:: get_key(int n) const { @@ -284,16 +253,13 @@ get_key(int n) const { return _table[n]._key; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_data -// Access: Public -// Description: Returns the data in the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the data in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE const Value &WeakKeyHashMap:: get_data(int n) const { @@ -301,17 +267,13 @@ get_data(int n) const { return _table[n]._data; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::modify_data -// Access: Public -// Description: Returns a modifiable reference to the data in the nth -// slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the data in the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE Value &WeakKeyHashMap:: modify_data(int n) { @@ -319,16 +281,13 @@ modify_data(int n) { return _table[n]._data; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::set_data -// Access: Public -// Description: Changes the data for the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the data for the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE void WeakKeyHashMap:: set_data(int n, const Value &data) { @@ -337,16 +296,13 @@ set_data(int n, const Value &data) { } #ifdef USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::set_data -// Access: Public -// Description: Changes the data for the nth slot of the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the data for the nth slot of the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template INLINE void WeakKeyHashMap:: set_data(int n, Value &&data) { @@ -355,16 +311,13 @@ set_data(int n, Value &&data) { } #endif // USE_MOVE_SEMANTICS -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::remove_element -// Access: Public -// Description: Removes the nth slot from the table. -// -// It is an error to call this if there is nothing -// stored in the nth slot (use has_element() to check -// this first). n should be in the range 0 <= n < -// get_size(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth slot from the table. + * + * It is an error to call this if there is nothing stored in the nth slot (use + * has_element() to check this first). n should be in the range 0 <= n < + * get_size(). + */ template void WeakKeyHashMap:: remove_element(int n) { @@ -374,9 +327,8 @@ remove_element(int n) { nassertv(_num_entries > 0); --_num_entries; - // Now we have put a hole in the table. If there was a hash - // conflict in the slot following this one, we have to move it down - // to close the hole. + // Now we have put a hole in the table. If there was a hash conflict in the + // slot following this one, we have to move it down to close the hole. size_t i = (size_t)n; i = (i + 1) & (_table_size - 1); while (get_exists_array()[i] != 0) { @@ -387,9 +339,8 @@ remove_element(int n) { } else { size_t wants_index = get_hash(_table[i]._key); if (wants_index != i) { - // This one was a hash conflict; try to put it where it belongs. - // We can't just put it in n, since maybe it belongs somewhere - // after n. + // This one was a hash conflict; try to put it where it belongs. We + // can't just put it in n, since maybe it belongs somewhere after n. while (wants_index != i && has_element(wants_index)) { // Hash conflict; move it up. wants_index = (wants_index + 1) & (_table_size - 1); @@ -401,9 +352,8 @@ remove_element(int n) { } } - // Continue until we encounter the next unused slot. Until we do, - // we can't be sure we've found all of the potential hash - // conflicts. + // Continue until we encounter the next unused slot. Until we do, we + // can't be sure we've found all of the potential hash conflicts. i = (i + 1) & (_table_size - 1); } @@ -412,45 +362,34 @@ remove_element(int n) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_num_entries -// Access: Public -// Description: Returns the number of active entries in the table. -// This is not necessarily related to the number of -// slots in the table as reported by get_size(). Use -// get_size() to iterate through all of the slots, not -// get_num_entries(). -// -// This is merely an upper bound on the number of -// entries; it may also count false positives for -// pointers that were recently deleted. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of active entries in the table. This is not necessarily + * related to the number of slots in the table as reported by get_size(). Use + * get_size() to iterate through all of the slots, not get_num_entries(). + * + * This is merely an upper bound on the number of entries; it may also count + * false positives for pointers that were recently deleted. + */ template INLINE size_t WeakKeyHashMap:: get_num_entries() const { return _num_entries; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::is_empty -// Access: Public -// Description: Returns true if the table is empty; -// i.e. get_num_entries() == 0. This may return a -// false negatives if a pointer was recently deleted; -// if this returns true, though, you can be sure it's -// empty. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the table is empty; i.e. get_num_entries() == 0. This may + * return a false negatives if a pointer was recently deleted; if this returns + * true, though, you can be sure it's empty. + */ template INLINE bool WeakKeyHashMap:: is_empty() const { return (_num_entries == 0); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void WeakKeyHashMap:: output(ostream &out) const { @@ -463,8 +402,8 @@ output(ostream &out) const { out << " " << _table[i]._key; size_t index = get_hash(_table[i]._key.get_orig()); if (index != i) { - // This was misplaced as the result of a hash conflict. - // Report how far off it is. + // This was misplaced as the result of a hash conflict. Report how + // far off it is. out << "(" << ((_table_size + i - index) & (_table_size - 1)) << ")"; } } @@ -472,11 +411,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template void WeakKeyHashMap:: write(ostream &out) const { @@ -484,12 +421,10 @@ write(ostream &out) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::validate -// Access: Public -// Description: Returns true if the internal table appears to be -// consistent, false if there are some internal errors. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the internal table appears to be consistent, false if there + * are some internal errors. + */ template bool WeakKeyHashMap:: validate() const { @@ -528,18 +463,14 @@ validate() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_hash -// Access: Private -// Description: Computes an appropriate index number to store the -// given pointer. -//////////////////////////////////////////////////////////////////// +/** + * Computes an appropriate index number to store the given pointer. + */ template INLINE size_t WeakKeyHashMap:: get_hash(const Key *key) const { /* - // We want a hash constant 0 < k < 1. This one is suggested by - // Knuth: + // We want a hash constant 0 < k < 1. This one is suggested by Knuth: static const double hash_constant = (sqrt(5.0) - 1.0) / 2.0; double f = ((double)(size_t)key * hash_constant); f -= floor(f); @@ -549,11 +480,9 @@ get_hash(const Key *key) const { return (((size_t)key * (size_t)9973) >> 8) & (_table_size - 1); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::is_element -// Access: Private -// Description: Returns true if element n matches key. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if element n matches key. + */ template INLINE bool WeakKeyHashMap:: is_element(int n, const Key *key) const { @@ -561,18 +490,16 @@ is_element(int n, const Key *key) const { return _table[n]._key == key; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::store_new_element -// Access: Private -// Description: Constructs a new TableEntry at position n, storing -// the indicated key and value. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a new TableEntry at position n, storing the indicated key and + * value. + */ template INLINE void WeakKeyHashMap:: store_new_element(int n, const Key *key, const Value &data) { if (get_exists_array()[n] != 0) { - // There was already an element in this spot. This can happen - // if it was a pointer that had already been deleted. + // There was already an element in this spot. This can happen if it was a + // pointer that had already been deleted. nassertv(_table[n]._key.was_deleted()); _table[n].~TableEntry(); --_num_entries; @@ -581,11 +508,9 @@ store_new_element(int n, const Key *key, const Value &data) { get_exists_array()[n] = true; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::clear_element -// Access: Private -// Description: Destructs the TableEntry at position n. -//////////////////////////////////////////////////////////////////// +/** + * Destructs the TableEntry at position n. + */ template INLINE void WeakKeyHashMap:: clear_element(int n) { @@ -593,36 +518,31 @@ clear_element(int n) { get_exists_array()[n] = false; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::get_exists_array -// Access: Private -// Description: Returns the beginning of the array of _table_size -// unsigned chars that are the boolean flags for whether -// each element exists (has been constructed) within the -// table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the beginning of the array of _table_size unsigned chars that are + * the boolean flags for whether each element exists (has been constructed) + * within the table. + */ template INLINE unsigned char *WeakKeyHashMap:: get_exists_array() const { return (unsigned char *)(_table + _table_size); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::new_table -// Access: Private -// Description: Allocates a brand new table. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a brand new table. + */ template void WeakKeyHashMap:: new_table() { nassertv(_table_size == 0 && _num_entries == 0); - // Pick a good initial table size. For now, we make it really - // small. Maybe that's the right answer. + // Pick a good initial table size. For now, we make it really small. Maybe + // that's the right answer. _table_size = 4; - // We allocate enough bytes for _table_size elements of TableEntry, - // plus _table_size more bytes at the end (for the exists array). + // We allocate enough bytes for _table_size elements of TableEntry, plus + // _table_size more bytes at the end (for the exists array). size_t alloc_size = _table_size * sizeof(TableEntry) + _table_size; _deleted_chain = memory_hook->get_deleted_chain(alloc_size); @@ -630,13 +550,10 @@ new_table() { memset(get_exists_array(), 0, _table_size); } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::consider_expand_table -// Access: Private -// Description: Expands the table if it will need it (assuming one -// more element is about to be added). Returns true if -// the table was modified, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Expands the table if it will need it (assuming one more element is about to + * be added). Returns true if the table was modified, false otherwise. + */ template INLINE bool WeakKeyHashMap:: consider_expand_table() { @@ -657,11 +574,9 @@ consider_expand_table() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: WeakKeyHashMap::expand_table -// Access: Private -// Description: Doubles the size of the existing table. -//////////////////////////////////////////////////////////////////// +/** + * Doubles the size of the existing table. + */ template void WeakKeyHashMap:: expand_table() { @@ -675,8 +590,8 @@ expand_table() { _table_size = (old_table_size << 1); nassertv(_table == NULL); - // We allocate enough bytes for _table_size elements of TableEntry, - // plus _table_size more bytes at the end (for the exists array). + // We allocate enough bytes for _table_size elements of TableEntry, plus + // _table_size more bytes at the end (for the exists array). size_t alloc_size = _table_size * sizeof(TableEntry) + _table_size; _deleted_chain = memory_hook->get_deleted_chain(alloc_size); _table = (TableEntry *)_deleted_chain->allocate(alloc_size, TypeHandle::none()); @@ -696,8 +611,8 @@ expand_table() { } #ifdef USE_MOVE_SEMANTICS - // Use C++11 rvalue references to invoke the move constructor, - // which may be more efficient. + // Use C++11 rvalue references to invoke the move constructor, which may + // be more efficient. new(&_table[new_index]) TableEntry(move(old_map._table[i])); #else new(&_table[new_index]) TableEntry(old_map._table[i]); @@ -710,8 +625,8 @@ expand_table() { nassertv(validate()); nassertv(old_map.validate()); - // Note that since has_element(i) also checks whether the pointer - // has been deleted, we may end up with fewer entries than we - // started with. Good riddance. + // Note that since has_element(i) also checks whether the pointer has been + // deleted, we may end up with fewer entries than we started with. Good + // riddance. nassertv(_num_entries <= old_map._num_entries); } diff --git a/panda/src/putil/weakKeyHashMap.cxx b/panda/src/putil/weakKeyHashMap.cxx index 620603cc82..54aecdb527 100644 --- a/panda/src/putil/weakKeyHashMap.cxx +++ b/panda/src/putil/weakKeyHashMap.cxx @@ -1,15 +1,14 @@ -// Filename: weakKeyHashMap.cxx -// Created by: rdb (13Jul15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakKeyHashMap.cxx + * @author rdb + * @date 2015-07-13 + */ #include "weakKeyHashMap.h" diff --git a/panda/src/putil/weakKeyHashMap.h b/panda/src/putil/weakKeyHashMap.h index fec1400a56..98a8863ee2 100644 --- a/panda/src/putil/weakKeyHashMap.h +++ b/panda/src/putil/weakKeyHashMap.h @@ -1,16 +1,15 @@ -// Filename: weakKeyHashMap.h -// Created by: rdb (13Jul15) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file weakKeyHashMap.h + * @author rdb + * @date 2015-07-13 + */ #ifndef WEAKKEYHASHMAP_H #define WEAKKEYHASHMAP_H @@ -20,18 +19,15 @@ #include "config_util.h" #include "weakPointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : WeakKeyHashMap -// Description : This is a variation on WeakKeyHashMap that stores -// weak pointers as keys, and automatically frees up -// entries from the map when the associated key has -// been deleted. -// -// This is more efficient than using a naive map of -// WeakPointerTo keys since that would incur the cost -// of constructing a weak reference every time a find -// operation is used. -//////////////////////////////////////////////////////////////////// +/** + * This is a variation on WeakKeyHashMap that stores weak pointers as keys, + * and automatically frees up entries from the map when the associated key has + * been deleted. + * + * This is more efficient than using a naive map of WeakPointerTo keys since + * that would incur the cost of constructing a weak reference every time a + * find operation is used. + */ template class WeakKeyHashMap { public: diff --git a/panda/src/putil/writableConfigurable.cxx b/panda/src/putil/writableConfigurable.cxx index 1e60dd01aa..c9e2d66c8f 100644 --- a/panda/src/putil/writableConfigurable.cxx +++ b/panda/src/putil/writableConfigurable.cxx @@ -1,16 +1,15 @@ -// Filename: writableConfigurable.cxx -// Created by: jason (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file writableConfigurable.cxx + * @author jason + * @date 2000-06-19 + */ #include "writableConfigurable.h" diff --git a/panda/src/putil/writableConfigurable.h b/panda/src/putil/writableConfigurable.h index 2592f08fd0..b6b4a56835 100644 --- a/panda/src/putil/writableConfigurable.h +++ b/panda/src/putil/writableConfigurable.h @@ -1,45 +1,36 @@ -// Filename: writableConfigurable.h -// Created by: jason (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file writableConfigurable.h + * @author jason + * @date 2000-06-19 + */ + -// #ifndef WRITABLECONFIGURABLE_H #define WRITABLECONFIGURABLE_H -// -//////////////////////////////////////////////////////////////////// // Includes -//////////////////////////////////////////////////////////////////// #include "pandabase.h" #include "typedWritable.h" -//////////////////////////////////////////////////////////////////// // Defines -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Class : WritableConfigurable -// Description : Defined as a fix to allow creating Configurable and -// Writable objects. Otherwise the compiler gets -// confused since both TypedWritable and Configurable -// inherit from TypedObject. -// -// An object that has data or parameters that are set -// less frequently (at least occasionally) than every -// frame. We can cache the configuration info by -// by using the "dirty" flag. -//////////////////////////////////////////////////////////////////// +/** + * Defined as a fix to allow creating Configurable and Writable objects. + * Otherwise the compiler gets confused since both TypedWritable and + * Configurable inherit from TypedObject. + * + * An object that has data or parameters that are set less frequently (at + * least occasionally) than every frame. We can cache the configuration info + * by by using the "dirty" flag. + */ class EXPCL_PANDA_PUTIL WritableConfigurable : public TypedWritable { public: @@ -47,12 +38,11 @@ public: virtual void config( void ) { _dirty = false; } INLINE void check_config() const { if (_dirty) { - // This is a sneaky trick to allow check_config() to be called - // from a const member function. Even though we will be calling - // config(), a non-const function that modifies the class - // object, in some sense it's not really modifying the class - // object--it's just updating a few internal settings for - // consistency. + // This is a sneaky trick to allow check_config() to be called from a + // const member function. Even though we will be calling config(), a + // non-const function that modifies the class object, in some sense it's + // not really modifying the class object--it's just updating a few + // internal settings for consistency. ((WritableConfigurable *)this)->config(); } } diff --git a/panda/src/putil/writableParam.I b/panda/src/putil/writableParam.I index c69d710734..49b75bf0f9 100644 --- a/panda/src/putil/writableParam.I +++ b/panda/src/putil/writableParam.I @@ -1,33 +1,28 @@ -// Filename: writableParam.I -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file writableParam.I + * @author jason + * @date 2000-06-13 + */ -//////////////////////////////////////////////////////////////////// -// Function: WritableParam::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WritableParam:: WritableParam(const Datagram &datagram) : _packet(datagram) { } -//////////////////////////////////////////////////////////////////// -// Function: WritableParam::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WritableParam:: WritableParam(const WritableParam ©) : FactoryParam(copy), @@ -35,33 +30,26 @@ WritableParam(const WritableParam ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WritableParam::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WritableParam:: ~WritableParam() { } -//////////////////////////////////////////////////////////////////// -// Function: WritableParam::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void WritableParam:: operator = (const WritableParam &) { // The assignment operator cannot be used for this class. nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: WritableParam::get_datagram -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const Datagram& WritableParam:: get_datagram() { return _packet; } - diff --git a/panda/src/putil/writableParam.cxx b/panda/src/putil/writableParam.cxx index 6c75b098c0..cf40a4e8f3 100644 --- a/panda/src/putil/writableParam.cxx +++ b/panda/src/putil/writableParam.cxx @@ -1,16 +1,15 @@ -// Filename: writableParam.cxx -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file writableParam.cxx + * @author jason + * @date 2000-06-13 + */ #include "writableParam.h" diff --git a/panda/src/putil/writableParam.h b/panda/src/putil/writableParam.h index 240c2e48f0..beefff5b8a 100644 --- a/panda/src/putil/writableParam.h +++ b/panda/src/putil/writableParam.h @@ -1,16 +1,15 @@ -// Filename: writableParam.h -// Created by: jason (13Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file writableParam.h + * @author jason + * @date 2000-06-13 + */ #ifndef WRITABLEPARAM_H #define WRITABLEPARAM_H @@ -22,13 +21,11 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : WritableParam -// Description : The specific derivation of FactoryParam that -// contains the information needed by a TypedWritable -// object. Simply contains a Datagram for the object -// to construct itself from. -//////////////////////////////////////////////////////////////////// +/** + * The specific derivation of FactoryParam that contains the information + * needed by a TypedWritable object. Simply contains a Datagram for the + * object to construct itself from. + */ class EXPCL_PANDA_PUTIL WritableParam : public FactoryParam { public: INLINE const Datagram &get_datagram(); @@ -66,4 +63,3 @@ private: #include "writableParam.I" #endif - diff --git a/panda/src/recorder/config_recorder.cxx b/panda/src/recorder/config_recorder.cxx index 5b69eaa223..6057362134 100644 --- a/panda/src/recorder/config_recorder.cxx +++ b/panda/src/recorder/config_recorder.cxx @@ -1,16 +1,15 @@ -// Filename: config_recorder.cxx -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_recorder.cxx + * @author drose + * @date 2004-01-28 + */ #include "config_recorder.h" diff --git a/panda/src/recorder/config_recorder.h b/panda/src/recorder/config_recorder.h index 49ba988e10..09643974ef 100644 --- a/panda/src/recorder/config_recorder.h +++ b/panda/src/recorder/config_recorder.h @@ -1,16 +1,15 @@ -// Filename: config_recorder.h -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_recorder.h + * @author drose + * @date 2004-01-28 + */ #ifndef CONFIG_RECORDER_H #define CONFIG_RECORDER_H diff --git a/panda/src/recorder/mouseRecorder.cxx b/panda/src/recorder/mouseRecorder.cxx index ec1475fbde..a79c7dc49b 100644 --- a/panda/src/recorder/mouseRecorder.cxx +++ b/panda/src/recorder/mouseRecorder.cxx @@ -1,16 +1,15 @@ -// Filename: mouseRecorder.cxx -// Created by: drose (24Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseRecorder.cxx + * @author drose + * @date 2004-01-24 + */ #include "mouseRecorder.h" #include "recorderController.h" @@ -20,11 +19,9 @@ TypeHandle MouseRecorder::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseRecorder:: MouseRecorder(const string &name) : DataNode(name) @@ -46,23 +43,18 @@ MouseRecorder(const string &name) : _xy = new EventStoreVec2(LPoint2(0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseRecorder:: ~MouseRecorder() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::record_frame -// Access: Public, Virtual -// Description: Records the most recent data collected into the -// indicated datagram, and returns true if there is any -// interesting data worth recording, or false if the -// datagram is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Records the most recent data collected into the indicated datagram, and + * returns true if there is any interesting data worth recording, or false if + * the datagram is meaningless. + */ void MouseRecorder:: record_frame(BamWriter *manager, Datagram &dg) { nassertv(is_recording()); @@ -76,12 +68,9 @@ record_frame(BamWriter *manager, Datagram &dg) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::play_frame -// Access: Public, Virtual -// Description: Reloads the most recent data collected from the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reloads the most recent data collected from the indicated datagram. + */ void MouseRecorder:: play_frame(DatagramIterator &scan, BamReader *manager) { nassertv(is_playing()); @@ -95,39 +84,30 @@ play_frame(DatagramIterator &scan, BamReader *manager) { _save_button_events->add_events(button_events); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseRecorder:: output(ostream &out) const { DataNode::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseRecorder:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void MouseRecorder:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -138,8 +118,8 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, _live_button_events->clear(); if (is_playing()) { - // If we're playing back data, copy in the data from a previous - // call to play_frame(). + // If we're playing back data, copy in the data from a previous call to + // play_frame(). has_mouse = _has_mouse; mouse_xy = _mouse_xy; mouse_pixel_xy = _mouse_pixel_xy; @@ -147,8 +127,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, _save_button_events->clear(); } else { - // If we're not playing back data, query the data from the data - // graph + // If we're not playing back data, query the data from the data graph if (input.has_data(_xy_input)) { // The mouse is within the window. Get the current mouse position. @@ -194,53 +173,42 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, output.set_data(_pixel_size_output, input.get_data(_pixel_size_input)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void MouseRecorder:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); RecorderController::get_factory()->register_factory(get_class_type(), make_recorder); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void MouseRecorder:: write_datagram(BamWriter *manager, Datagram &dg) { DataNode::write_datagram(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::write_recorder -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for encoding in the session file. This is very -// similar to write_datagram() for TypedWritable -// objects, but it is used specifically to write the -// Recorder object when generating the session file. In -// many cases, it will be the same as write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for encoding in the + * session file. This is very similar to write_datagram() for TypedWritable + * objects, but it is used specifically to write the Recorder object when + * generating the session file. In many cases, it will be the same as + * write_datagram(). + */ void MouseRecorder:: write_recorder(BamWriter *manager, Datagram &dg) { RecorderBase::write_recorder(manager, dg); DataNode::write_recorder(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *MouseRecorder:: make_from_bam(const FactoryParams ¶ms) { MouseRecorder *node = new MouseRecorder(""); @@ -253,13 +221,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::make_recorder -// Access: Protected, Static -// Description: This is similar to make_from_bam(), but it is -// designed for loading the RecorderBase object from the -// session log created by a RecorderController. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to make_from_bam(), but it is designed for loading the + * RecorderBase object from the session log created by a RecorderController. + */ RecorderBase *MouseRecorder:: make_recorder(const FactoryParams ¶ms) { MouseRecorder *node = new MouseRecorder(""); @@ -272,25 +237,19 @@ make_recorder(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MouseRecorder. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MouseRecorder. + */ void MouseRecorder:: fillin(DatagramIterator &scan, BamReader *manager) { DataNode::fillin(scan, manager); } -//////////////////////////////////////////////////////////////////// -// Function: MouseRecorder::fillin_recorder -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new MouseRecorder. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MouseRecorder. + */ void MouseRecorder:: fillin_recorder(DatagramIterator &scan, BamReader *manager) { RecorderBase::fillin_recorder(scan, manager); diff --git a/panda/src/recorder/mouseRecorder.h b/panda/src/recorder/mouseRecorder.h index 503d8eb8cd..b26b9e76a6 100644 --- a/panda/src/recorder/mouseRecorder.h +++ b/panda/src/recorder/mouseRecorder.h @@ -1,16 +1,15 @@ -// Filename: mouseRecorder.h -// Created by: drose (25Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseRecorder.h + * @author drose + * @date 2004-01-25 + */ #ifndef MOUSERECORDER_H #define MOUSERECORDER_H @@ -25,16 +24,13 @@ class FactoryParams; class BamReader; class BamWriter; -//////////////////////////////////////////////////////////////////// -// Class : MouseRecorder -// Description : This object records any data generated by a -// particular MouseAndKeyboard node on the datagraph for -// a session for eventual playback via a -// DataGraphPlayback (and a PlaybackController). To use -// it, make it a child of the node you wish to record. -// It also serves as a pass-through, so that additional -// child nodes may be parented directly to it. -//////////////////////////////////////////////////////////////////// +/** + * This object records any data generated by a particular MouseAndKeyboard + * node on the datagraph for a session for eventual playback via a + * DataGraphPlayback (and a PlaybackController). To use it, make it a child + * of the node you wish to record. It also serves as a pass-through, so that + * additional child nodes may be parented directly to it. + */ class EXPCL_PANDA_RECORDER MouseRecorder : public DataNode, public RecorderBase { PUBLISHED: MouseRecorder(const string &name); diff --git a/panda/src/recorder/recorderBase.I b/panda/src/recorder/recorderBase.I index 6f4c80276e..ff2efb4ad6 100644 --- a/panda/src/recorder/recorderBase.I +++ b/panda/src/recorder/recorderBase.I @@ -1,38 +1,31 @@ -// Filename: recorderBase.I -// Created by: drose (24Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderBase.I + * @author drose + * @date 2004-01-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::is_recording -// Access: Published -// Description: Returns true if this recorder is presently recording -// data for saving to a session file, false otherwise. -// If this is true, record_data() will be called from -// time to time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this recorder is presently recording data for saving to a + * session file, false otherwise. If this is true, record_data() will be + * called from time to time. + */ INLINE bool RecorderBase:: is_recording() const { return (_flags & F_recording) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::is_playing -// Access: Published -// Description: Returns true if this recorder is presently playing back -// data from session file, false otherwise. If this is -// true, play_data() will be called from time to time. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this recorder is presently playing back data from session + * file, false otherwise. If this is true, play_data() will be called from + * time to time. + */ INLINE bool RecorderBase:: is_playing() const { return (_flags & F_playing) != 0; diff --git a/panda/src/recorder/recorderBase.cxx b/panda/src/recorder/recorderBase.cxx index 8930ebd4e5..51e61ffc2e 100644 --- a/panda/src/recorder/recorderBase.cxx +++ b/panda/src/recorder/recorderBase.cxx @@ -1,85 +1,68 @@ -// Filename: recorderBase.cxx -// Created by: drose (24Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderBase.cxx + * @author drose + * @date 2004-01-24 + */ #include "recorderBase.h" TypeHandle RecorderBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecorderBase:: RecorderBase() { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecorderBase:: ~RecorderBase() { nassertv(_flags == 0); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::record_frame -// Access: Public, Virtual -// Description: Records the most recent data collected into the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Records the most recent data collected into the indicated datagram. + */ void RecorderBase:: record_frame(BamWriter *, Datagram &) { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::play_frame -// Access: Public, Virtual -// Description: Reloads the most recent data collected from the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reloads the most recent data collected from the indicated datagram. + */ void RecorderBase:: play_frame(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::write_recorder -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for encoding in the session file. This is very -// similar to write_datagram() for TypedWritable -// objects, but it is used specifically to write the -// Recorder object when generating the session file. In -// many cases, it will be the same as write_datagram(). -// -// This balances with fillin_recorder(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for encoding in the + * session file. This is very similar to write_datagram() for TypedWritable + * objects, but it is used specifically to write the Recorder object when + * generating the session file. In many cases, it will be the same as + * write_datagram(). + * + * This balances with fillin_recorder(). + */ void RecorderBase:: write_recorder(BamWriter *, Datagram &) { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderBase::fillin_recorder -// Access: Protected -// Description: This internal function is called by make_recorder (in -// derived classes) to read in all of the relevant data -// from the session file. It balances with -// write_recorder(). -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_recorder (in derived classes) to + * read in all of the relevant data from the session file. It balances with + * write_recorder(). + */ void RecorderBase:: fillin_recorder(DatagramIterator &, BamReader *) { } diff --git a/panda/src/recorder/recorderBase.h b/panda/src/recorder/recorderBase.h index 922f751a65..816f74030d 100644 --- a/panda/src/recorder/recorderBase.h +++ b/panda/src/recorder/recorderBase.h @@ -1,16 +1,15 @@ -// Filename: recorderBase.h -// Created by: drose (25Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderBase.h + * @author drose + * @date 2004-01-25 + */ #ifndef RECORDERBASE_H #define RECORDERBASE_H @@ -24,34 +23,26 @@ class Datagram; class DatagramIterator; class TypedWritable; -//////////////////////////////////////////////////////////////////// -// Class : RecorderBase -// Description : This is the base class to a number of objects that -// record particular kinds of user input (like a -// MouseRecorder) to use in conjunction with a -// RecorderController to record the user's inputs -// for a session. -// -// Note that RecorderBase does not actually inherit from -// TypedObject, even though it defines get_type(). The -// assumption is that the classes that derive from -// RecorderBase might also inherit independently from -// TypedObject. -// -// It also does not inherit from TypedWritable, but it -// defines a method called write_recorder() which is -// very similar to a TypedWritable's write_datagram(). -// Classes that derive from RecorderBase and also -// inherit from TypedWritable may choose to remap -// write_recorder() to do exactly the same thing as -// write_datagram(), or they may choose to write -// something slightly different. -// -// Most types of recorders should derive from Recorder, -// as it derives from ReferenceCount, except for -// MouseRecorder, which would otherwise doubly inherit -// from ReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class to a number of objects that record particular kinds + * of user input (like a MouseRecorder) to use in conjunction with a + * RecorderController to record the user's inputs for a session. + * + * Note that RecorderBase does not actually inherit from TypedObject, even + * though it defines get_type(). The assumption is that the classes that + * derive from RecorderBase might also inherit independently from TypedObject. + * + * It also does not inherit from TypedWritable, but it defines a method called + * write_recorder() which is very similar to a TypedWritable's + * write_datagram(). Classes that derive from RecorderBase and also inherit + * from TypedWritable may choose to remap write_recorder() to do exactly the + * same thing as write_datagram(), or they may choose to write something + * slightly different. + * + * Most types of recorders should derive from Recorder, as it derives from + * ReferenceCount, except for MouseRecorder, which would otherwise doubly + * inherit from ReferenceCount. + */ class EXPCL_PANDA_RECORDER RecorderBase { protected: RecorderBase(); @@ -68,8 +59,8 @@ public: virtual void write_recorder(BamWriter *manager, Datagram &dg); - // We can't let RecorderBase inherit from ReferenceCount, so we - // define these so we can still manage the reference count. + // We can't let RecorderBase inherit from ReferenceCount, so we define these + // so we can still manage the reference count. virtual void ref() const=0; virtual bool unref() const=0; diff --git a/panda/src/recorder/recorderController.I b/panda/src/recorder/recorderController.I index 912a6232f6..b6312c0d82 100644 --- a/panda/src/recorder/recorderController.I +++ b/panda/src/recorder/recorderController.I @@ -1,196 +1,155 @@ -// Filename: recorderController.I -// Created by: drose (24Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderController.I + * @author drose + * @date 2004-01-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_start_time -// Access: Published -// Description: Returns the time (and date) at which the current -// session was originally recorded (or, in recording -// mode, the time at which the current session began). -//////////////////////////////////////////////////////////////////// +/** + * Returns the time (and date) at which the current session was originally + * recorded (or, in recording mode, the time at which the current session + * began). + */ INLINE time_t RecorderController:: get_start_time() const { return _header._start_time; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::set_random_seed -// Access: Published -// Description: Indicates an arbitrary number to be recorded in the -// session file as a random seed, should the application -// wish to take advantage of it. This must be set -// before begin_record() is called. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an arbitrary number to be recorded in the session file as a + * random seed, should the application wish to take advantage of it. This + * must be set before begin_record() is called. + */ INLINE void RecorderController:: set_random_seed(int random_seed) { _header._random_seed = random_seed; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_random_seed -// Access: Published -// Description: Returns the random seed that was set by a previous -// call to set_random_seed(), or the number read from -// the session file after begin_playback() has been -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the random seed that was set by a previous call to + * set_random_seed(), or the number read from the session file after + * begin_playback() has been called. + */ INLINE int RecorderController:: get_random_seed() const { return _header._random_seed; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::is_recording -// Access: Published -// Description: Returns true if the controller has been opened for -// output, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the controller has been opened for output, false otherwise. + */ INLINE bool RecorderController:: is_recording() const { return (_writer != (BamWriter *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::is_playing -// Access: Published -// Description: Returns true if the controller has been opened for -// input, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the controller has been opened for input, false otherwise. + */ INLINE bool RecorderController:: is_playing() const { return (_reader != (BamReader *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::is_open -// Access: Published -// Description: Returns true if the controller has been opened for -// either input or output, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the controller has been opened for either input or output, + * false otherwise. + */ INLINE bool RecorderController:: is_open() const { return is_recording() || is_playing(); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_filename -// Access: Published -// Description: Returns the filename that was passed to the most -// recent call to begin_record() or begin_playback(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that was passed to the most recent call to + * begin_record() or begin_playback(). + */ INLINE const Filename &RecorderController:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::is_error -// Access: Published -// Description: Returns true if the controller has been opened for -// input or output output and there is an error on the -// stream, or false if the controller is closed or if -// there is no problem. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the controller has been opened for input or output output + * and there is an error on the stream, or false if the controller is closed + * or if there is no problem. + */ INLINE bool RecorderController:: is_error() { return _dout.is_error() || _din.is_error(); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_clock_offset -// Access: Published -// Description: Returns the delta offset between the actual frame -// time and the frame time written to the log. This is -// essentially the time at which the recording (or -// playback) started. -//////////////////////////////////////////////////////////////////// +/** + * Returns the delta offset between the actual frame time and the frame time + * written to the log. This is essentially the time at which the recording + * (or playback) started. + */ INLINE double RecorderController:: get_clock_offset() const { return _clock_offset; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_frame_offset -// Access: Published -// Description: Returns the delta offset between the actual frame -// count and the frame count written to the log. This is -// essentially the frame number at which the recording -// (or playback) started. -//////////////////////////////////////////////////////////////////// +/** + * Returns the delta offset between the actual frame count and the frame count + * written to the log. This is essentially the frame number at which the + * recording (or playback) started. + */ INLINE int RecorderController:: get_frame_offset() const { return _frame_offset; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::add_recorder -// Access: Published -// Description: Adds the named recorder to the set of recorders that -// are in use. -// -// If the controller is in recording mode, the named -// recorder will begin recording its status to the -// session file. If the controller is in playback mode -// and the name and type matches a recorder in the -// session file, the recorder will begin receiving data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the named recorder to the set of recorders that are in use. + * + * If the controller is in recording mode, the named recorder will begin + * recording its status to the session file. If the controller is in playback + * mode and the name and type matches a recorder in the session file, the + * recorder will begin receiving data. + */ INLINE void RecorderController:: add_recorder(const string &name, RecorderBase *recorder) { _user_table->add_recorder(name, recorder); _user_table_modified = true; - // We can only add the state flag immediately if we are in recording - // mode. In playback mode, we're not sure yet whether the new - // recorder state will actually be playing (we won't know until we - // merge the tables in play_frame()). + // We can only add the state flag immediately if we are in recording mode. + // In playback mode, we're not sure yet whether the new recorder state will + // actually be playing (we won't know until we merge the tables in + // play_frame()). if (is_recording()) { recorder->_flags |= RecorderBase::F_recording; } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::has_recorder -// Access: Published -// Description: Returns true if the named recorder has been added to -// the table by a previous call to add_recorder(), false -// otherwise. -// -// If the controller is in playback mode, this will also -// return false for a recorder that was found in the -// session file but was never explicitly added via -// add_recorder(); see get_recorder(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named recorder has been added to the table by a + * previous call to add_recorder(), false otherwise. + * + * If the controller is in playback mode, this will also return false for a + * recorder that was found in the session file but was never explicitly added + * via add_recorder(); see get_recorder(). + */ INLINE bool RecorderController:: has_recorder(const string &name) const { return (_user_table->get_recorder(name) != (RecorderBase *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_recorder -// Access: Published -// Description: Returns the recorder with the indicated name, or NULL -// if there is no such recorder. -// -// If the controller is in playback mode, this may -// return the recorder matching the indicated name as -// read from the session file, even if it was never -// added to the table by the user. In this case, -// has_recorder() may return false, but get_recorder() -// will return a non-NULL value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the recorder with the indicated name, or NULL if there is no such + * recorder. + * + * If the controller is in playback mode, this may return the recorder + * matching the indicated name as read from the session file, even if it was + * never added to the table by the user. In this case, has_recorder() may + * return false, but get_recorder() will return a non-NULL value. + */ INLINE RecorderBase *RecorderController:: get_recorder(const string &name) const { RecorderBase *recorder = _user_table->get_recorder(name); @@ -200,28 +159,23 @@ get_recorder(const string &name) const { return recorder; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::remove_recorder -// Access: Published -// Description: Removes the named recorder from the table. Returns -// true if successful, false if there was no such -// recorder. -// -// If the controller is in recording mode, the named -// recorder will stop recording. If the controller is -// in playback mode, the named recorder will -// disassociate itself from the session file (but if the -// session file still has data for this name, a default -// recorder will take its place to decode the data from -// the session file). -//////////////////////////////////////////////////////////////////// +/** + * Removes the named recorder from the table. Returns true if successful, + * false if there was no such recorder. + * + * If the controller is in recording mode, the named recorder will stop + * recording. If the controller is in playback mode, the named recorder will + * disassociate itself from the session file (but if the session file still + * has data for this name, a default recorder will take its place to decode + * the data from the session file). + */ INLINE bool RecorderController:: remove_recorder(const string &name) { - // If we are playing or recording, immediately remove the state flag - // from the recorder. (When we are playing, the state flag will get - // removed automatically at the next call to play_frame(), but we - // might as well be aggressive and remove it now. When we are - // recording, we have to remove it now.) + // If we are playing or recording, immediately remove the state flag from + // the recorder. (When we are playing, the state flag will get removed + // automatically at the next call to play_frame(), but we might as well be + // aggressive and remove it now. When we are recording, we have to remove + // it now.) if (is_recording() || is_playing()) { RecorderBase *recorder = _user_table->get_recorder(name); if (recorder != (RecorderBase *)NULL) { @@ -232,44 +186,35 @@ remove_recorder(const string &name) { return _user_table->remove_recorder(name); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::set_frame_tie -// Access: Published -// Description: Sets the frame_tie flag. -// -// When this is true, sessions are played back -// frame-for-frame, based on the frame count of the -// recorded session. This gives the most accurate -// playback, but the playback rate will vary according -// to the frame rate of the playback machine. -// -// When this is false, sessions are played back at real -// time, based on the clock of the recorded session. -// This may introduce playback discrepencies if the -// frames do not fall at exactly the same times as they -// did in the original. -//////////////////////////////////////////////////////////////////// +/** + * Sets the frame_tie flag. + * + * When this is true, sessions are played back frame-for-frame, based on the + * frame count of the recorded session. This gives the most accurate + * playback, but the playback rate will vary according to the frame rate of + * the playback machine. + * + * When this is false, sessions are played back at real time, based on the + * clock of the recorded session. This may introduce playback discrepencies + * if the frames do not fall at exactly the same times as they did in the + * original. + */ INLINE void RecorderController:: set_frame_tie(bool frame_tie) { _frame_tie = frame_tie; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_frame_tie -// Access: Published -// Description: See set_frame_tie(). -//////////////////////////////////////////////////////////////////// +/** + * See set_frame_tie(). + */ INLINE bool RecorderController:: get_frame_tie() const { return _frame_tie; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::get_factory -// Access: Public, Static -// Description: Returns the global RecorderFactory for generating -// TypedWritable objects -//////////////////////////////////////////////////////////////////// +/** + * Returns the global RecorderFactory for generating TypedWritable objects + */ INLINE RecorderController::RecorderFactory *RecorderController:: get_factory() { if (_factory == (RecorderFactory *)NULL) { @@ -278,12 +223,9 @@ get_factory() { return _factory; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::create_factory -// Access: Private, Static -// Description: Creates a new RecorderFactory for generating -// TypedWritable objects -//////////////////////////////////////////////////////////////////// +/** + * Creates a new RecorderFactory for generating TypedWritable objects + */ INLINE void RecorderController:: create_factory() { _factory = new RecorderFactory; diff --git a/panda/src/recorder/recorderController.cxx b/panda/src/recorder/recorderController.cxx index 712fe1c5ac..364619d5ae 100644 --- a/panda/src/recorder/recorderController.cxx +++ b/panda/src/recorder/recorderController.cxx @@ -1,16 +1,15 @@ -// Filename: recorderController.cxx -// Created by: drose (24Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderController.cxx + * @author drose + * @date 2004-01-24 + */ #include "recorderController.h" #include "recorderFrame.h" @@ -23,11 +22,9 @@ TypeHandle RecorderController::_type_handle; RecorderController::RecorderFactory *RecorderController::_factory = NULL; -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecorderController:: RecorderController() { _clock_offset = 0.0; @@ -42,24 +39,19 @@ RecorderController() { _eof = false; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecorderController:: ~RecorderController() { close(); delete _user_table; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::begin_record -// Access: Published -// Description: Begins recording data to the indicated filename. All -// of the recorders in use should already have been -// added. -//////////////////////////////////////////////////////////////////// +/** + * Begins recording data to the indicated filename. All of the recorders in + * use should already have been added. + */ bool RecorderController:: begin_record(const Filename &filename) { close(); @@ -101,17 +93,13 @@ begin_record(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::begin_playback -// Access: Published -// Description: Begins playing back data from the indicated filename. -// All of the recorders in use should already have been -// added, although this may define additional recorders -// if they are present in the file (these new recorders -// will not be used). This may also undefine recorders -// that were previously added but are not present in the -// file. -//////////////////////////////////////////////////////////////////// +/** + * Begins playing back data from the indicated filename. All of the recorders + * in use should already have been added, although this may define additional + * recorders if they are present in the file (these new recorders will not be + * used). This may also undefine recorders that were previously added but are + * not present in the file. + */ bool RecorderController:: begin_playback(const Filename &filename) { close(); @@ -176,11 +164,9 @@ begin_playback(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::close -// Access: Published -// Description: Finishes recording data to the indicated filename. -//////////////////////////////////////////////////////////////////// +/** + * Finishes recording data to the indicated filename. + */ void RecorderController:: close() { if (_writer != (BamWriter *)NULL) { @@ -211,12 +197,10 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::record_frame -// Access: Published -// Description: Gets the next frame of data from all of the active -// recorders and adds it to the output file. -//////////////////////////////////////////////////////////////////// +/** + * Gets the next frame of data from all of the active recorders and adds it to + * the output file. + */ void RecorderController:: record_frame() { if (is_recording()) { @@ -231,12 +215,10 @@ record_frame() { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::play_frame -// Access: Published -// Description: Gets the next frame of data from all of the active -// recorders and adds it to the output file. -//////////////////////////////////////////////////////////////////// +/** + * Gets the next frame of data from all of the active recorders and adds it to + * the output file. + */ void RecorderController:: play_frame() { if (is_playing()) { @@ -256,10 +238,11 @@ play_frame() { return; } - // Insist that the clock runs at the same rate as it did in - // the previous session. - //global_clock->set_frame_time(_next_frame->_timestamp + _clock_offset); - //global_clock->set_real_time(_next_frame->_timestamp + _clock_offset); + // Insist that the clock runs at the same rate as it did in the + // previous session. + // global_clock->set_frame_time(_next_frame->_timestamp + + // _clock_offset); global_clock->set_real_time(_next_frame->_timestamp + // + _clock_offset); // Hmm, that's crummy. Just keep the clock offset up-to-date. _clock_offset = global_clock->get_frame_time() - _next_frame->_timestamp; @@ -280,16 +263,15 @@ play_frame() { } if (_next_frame->_table_changed || _user_table_modified) { - // We're about to change the active table. Temporarily - // disable the playing flag on the currently-active recorders. + // We're about to change the active table. Temporarily disable the + // playing flag on the currently-active recorders. _active_table->clear_flags(RecorderBase::F_playing); delete _active_table; _active_table = new RecorderTable(*_file_table); _active_table->merge_from(*_user_table); _user_table_modified = false; - // Now reenable the playing flag on the newly-active - // recorders. + // Now reenable the playing flag on the newly-active recorders. _active_table->set_flags(RecorderBase::F_playing); } @@ -312,13 +294,10 @@ play_frame() { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderController::read_frame -// Access: Private -// Description: Loads the next frame data from the playback session -// file. Returns the frame data pointer on success, or -// NULL on failure. -//////////////////////////////////////////////////////////////////// +/** + * Loads the next frame data from the playback session file. Returns the + * frame data pointer on success, or NULL on failure. + */ RecorderFrame *RecorderController:: read_frame() { TypedWritable *object = _reader->read_object(); diff --git a/panda/src/recorder/recorderController.h b/panda/src/recorder/recorderController.h index a05c706629..064e882373 100644 --- a/panda/src/recorder/recorderController.h +++ b/panda/src/recorder/recorderController.h @@ -1,16 +1,15 @@ -// Filename: recorderController.h -// Created by: drose (25Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderController.h + * @author drose + * @date 2004-01-25 + */ #ifndef RECORDERCONTROLLER_H #define RECORDERCONTROLLER_H @@ -26,12 +25,10 @@ class RecorderBase; class RecorderFrame; -//////////////////////////////////////////////////////////////////// -// Class : RecorderController -// Description : This object manages the process of recording the -// user's runtime inputs to a bam file so that the -// session can be recreated later. -//////////////////////////////////////////////////////////////////// +/** + * This object manages the process of recording the user's runtime inputs to a + * bam file so that the session can be recreated later. + */ class EXPCL_PANDA_RECORDER RecorderController : public TypedReferenceCount { PUBLISHED: RecorderController(); @@ -91,21 +88,20 @@ private: RecorderTable *_user_table; bool _user_table_modified; - // In playback mode, _file_table represents the table as read - // directly from the session file, with default recorders in each - // slot. + // In playback mode, _file_table represents the table as read directly from + // the session file, with default recorders in each slot. RecorderTable *_file_table; - // In playback mode, _active_table is the result of the merge of - // _file_table and _user_table, with a default recorder or a - // user-specified recorder in each active slot. + // In playback mode, _active_table is the result of the merge of _file_table + // and _user_table, with a default recorder or a user-specified recorder in + // each active slot. RecorderTable *_active_table; RecorderFrame *_next_frame; bool _eof; static RecorderFactory *_factory; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -129,4 +125,3 @@ private: #include "recorderController.I" #endif - diff --git a/panda/src/recorder/recorderFrame.I b/panda/src/recorder/recorderFrame.I index 8944facb21..9f94cd6a4f 100644 --- a/panda/src/recorder/recorderFrame.I +++ b/panda/src/recorder/recorderFrame.I @@ -1,32 +1,26 @@ -// Filename: recorderFrame.I -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderFrame.I + * @author drose + * @date 2004-01-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderFrame:: RecorderFrame() { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderFrame:: RecorderFrame(double timestamp, int frame, bool table_changed, RecorderTable *table) : @@ -37,11 +31,9 @@ RecorderFrame(double timestamp, int frame, { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderFrame:: ~RecorderFrame() { } diff --git a/panda/src/recorder/recorderFrame.cxx b/panda/src/recorder/recorderFrame.cxx index f2b95cae2b..d53e3d46dc 100644 --- a/panda/src/recorder/recorderFrame.cxx +++ b/panda/src/recorder/recorderFrame.cxx @@ -1,16 +1,15 @@ -// Filename: recorderFrame.cxx -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderFrame.cxx + * @author drose + * @date 2004-01-28 + */ #include "recorderFrame.h" #include "recorderTable.h" @@ -20,13 +19,10 @@ TypeHandle RecorderFrame::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::play_frame -// Access: Public -// Description: Once the raw data has been read in from the session -// file, and the table has been decoded, decode the raw -// data and call play_frame on each recorder. -//////////////////////////////////////////////////////////////////// +/** + * Once the raw data has been read in from the session file, and the table has + * been decoded, decode the raw data and call play_frame on each recorder. + */ void RecorderFrame:: play_frame(BamReader *manager) { DatagramIterator scan(_data, _data_pos); @@ -36,23 +32,18 @@ play_frame(BamReader *manager) { nassertv(scan.get_remaining_size() == 0); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void RecorderFrame:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RecorderFrame:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -62,11 +53,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { // Write the table out if it has changed. dg.add_bool(_table_changed); if (_table_changed) { - // As a kludge, we create a new table pointer to write out. - // Otherwise, the pointer won't change and it may not write out - // the changes. Later, we need to add a facility to the bam - // writer to detect when a TypedWritable has changed and should be - // rewritten. + // As a kludge, we create a new table pointer to write out. Otherwise, + // the pointer won't change and it may not write out the changes. Later, + // we need to add a facility to the bam writer to detect when a + // TypedWritable has changed and should be rewritten. _local_table = *_table; manager->write_pointer(dg, &_local_table); } @@ -74,28 +64,21 @@ write_datagram(BamWriter *manager, Datagram &dg) { _table->record_frame(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -// -// This is the callback function that is made by the -// BamReader at some later point, after all of the -// required pointers have been filled in. It is -// necessary because there might be forward references -// in a bam file; when we call read_pointer() in -// fillin(), the object may not have been read from the -// file yet, so we do not have a pointer available at -// that time. Thus, instead of returning a pointer, -// read_pointer() simply reserves a later callback. -// This function provides that callback. The calling -// object is responsible for keeping track of the number -// of times it called read_pointer() and extracting the -// same number of pointers out of the supplied vector, -// and storing them appropriately within the object. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + * + * This is the callback function that is made by the BamReader at some later + * point, after all of the required pointers have been filled in. It is + * necessary because there might be forward references in a bam file; when we + * call read_pointer() in fillin(), the object may not have been read from the + * file yet, so we do not have a pointer available at that time. Thus, + * instead of returning a pointer, read_pointer() simply reserves a later + * callback. This function provides that callback. The calling object is + * responsible for keeping track of the number of times it called + * read_pointer() and extracting the same number of pointers out of the + * supplied vector, and storing them appropriately within the object. + */ int RecorderFrame:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -107,14 +90,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *RecorderFrame:: make_from_bam(const FactoryParams ¶ms) { RecorderFrame *frame = new RecorderFrame; @@ -127,13 +107,10 @@ make_from_bam(const FactoryParams ¶ms) { return frame; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderFrame::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RecorderFrame. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RecorderFrame. + */ void RecorderFrame:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -146,10 +123,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { manager->read_pointer(scan); } - // We can't decode the data in the frame until we have (a) gotten - // back the table pointer, or (b) been told who our owning - // RecorderController is. So we'll just save the raw data for now - // and come back to it. + // We can't decode the data in the frame until we have (a) gotten back the + // table pointer, or (b) been told who our owning RecorderController is. So + // we'll just save the raw data for now and come back to it. _data = scan.get_datagram(); _data_pos = scan.get_current_index(); } diff --git a/panda/src/recorder/recorderFrame.h b/panda/src/recorder/recorderFrame.h index f32be43509..ea7dde90b6 100644 --- a/panda/src/recorder/recorderFrame.h +++ b/panda/src/recorder/recorderFrame.h @@ -1,16 +1,15 @@ -// Filename: recorderFrame.h -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderFrame.h + * @author drose + * @date 2004-01-28 + */ #ifndef RECORDERFRAME_H #define RECORDERFRAME_H @@ -25,13 +24,11 @@ class BamWriter; class BamReader; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RecorderFrame -// Description : This object represents one frame of data in the -// recorded session file. One of these is repeatedly -// created and destructed in recording and playback, -// respectively. -//////////////////////////////////////////////////////////////////// +/** + * This object represents one frame of data in the recorded session file. One + * of these is repeatedly created and destructed in recording and playback, + * respectively. + */ class EXPCL_PANDA_RECORDER RecorderFrame : public TypedWritable { public: INLINE RecorderFrame(); @@ -56,11 +53,11 @@ public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); virtual int complete_pointers(TypedWritable **plist, BamReader *manager); - + protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -82,4 +79,3 @@ private: #include "recorderFrame.I" #endif - diff --git a/panda/src/recorder/recorderHeader.I b/panda/src/recorder/recorderHeader.I index 9848510c5c..b1b90d59c3 100644 --- a/panda/src/recorder/recorderHeader.I +++ b/panda/src/recorder/recorderHeader.I @@ -1,34 +1,28 @@ -// Filename: recorderHeader.I -// Created by: drose (29Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderHeader.I + * @author drose + * @date 2004-01-29 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderHeader:: RecorderHeader() { time(&_start_time); _random_seed = (int)_start_time; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderHeader:: RecorderHeader(const RecorderHeader ©) : _start_time(copy._start_time), @@ -36,22 +30,18 @@ RecorderHeader(const RecorderHeader ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RecorderHeader:: operator = (const RecorderHeader ©) { _start_time = copy._start_time; _random_seed = copy._random_seed; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderHeader:: ~RecorderHeader() { } diff --git a/panda/src/recorder/recorderHeader.cxx b/panda/src/recorder/recorderHeader.cxx index 1c59a32cf9..97a831a612 100644 --- a/panda/src/recorder/recorderHeader.cxx +++ b/panda/src/recorder/recorderHeader.cxx @@ -1,16 +1,15 @@ -// Filename: recorderHeader.cxx -// Created by: drose (29Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderHeader.cxx + * @author drose + * @date 2004-01-29 + */ #include "recorderHeader.h" #include "recorderTable.h" @@ -20,44 +19,35 @@ TypeHandle RecorderHeader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void RecorderHeader:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RecorderHeader:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); - - // One day this will need to be upgraded to a uint64, but probably - // not before 2106. (In 2038, Unix time will overflow a signed - // 32-bit number, but this is an unsigned number and will still be - // good until 2106.) + + // One day this will need to be upgraded to a uint64, but probably not + // before 2106. (In 2038, Unix time will overflow a signed 32-bit number, + // but this is an unsigned number and will still be good until 2106.) dg.add_uint32(_start_time); dg.add_int32(_random_seed); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *RecorderHeader:: make_from_bam(const FactoryParams ¶ms) { RecorderHeader *header = new RecorderHeader; @@ -70,13 +60,10 @@ make_from_bam(const FactoryParams ¶ms) { return header; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderHeader::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RecorderHeader. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RecorderHeader. + */ void RecorderHeader:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/recorder/recorderHeader.h b/panda/src/recorder/recorderHeader.h index a21a39c94c..931000c349 100644 --- a/panda/src/recorder/recorderHeader.h +++ b/panda/src/recorder/recorderHeader.h @@ -1,16 +1,15 @@ -// Filename: recorderHeader.h -// Created by: drose (29Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderHeader.h + * @author drose + * @date 2004-01-29 + */ #ifndef RECORDERHEADER_H #define RECORDERHEADER_H @@ -25,11 +24,10 @@ class BamWriter; class BamReader; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RecorderHeader -// Description : This object contains the header information written -// out at the beginning of a recorded session file. -//////////////////////////////////////////////////////////////////// +/** + * This object contains the header information written out at the beginning of + * a recorded session file. + */ class EXPCL_PANDA_RECORDER RecorderHeader : public TypedWritable { public: INLINE RecorderHeader(); @@ -43,11 +41,11 @@ public: public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); - + protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); void fillin(DatagramIterator &scan, BamReader *manager); - + public: static TypeHandle get_class_type() { return _type_handle; @@ -69,4 +67,3 @@ private: #include "recorderHeader.I" #endif - diff --git a/panda/src/recorder/recorderTable.I b/panda/src/recorder/recorderTable.I index 95c364f26f..6bb2649d97 100644 --- a/panda/src/recorder/recorderTable.I +++ b/panda/src/recorder/recorderTable.I @@ -1,43 +1,35 @@ -// Filename: recorderTable.I -// Created by: drose (27Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderTable.I + * @author drose + * @date 2004-01-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderTable:: RecorderTable() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RecorderTable:: RecorderTable(const RecorderTable ©) { *this = copy; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RecorderTable:: operator = (const RecorderTable ©) { _recorders = copy._recorders; @@ -49,11 +41,9 @@ operator = (const RecorderTable ©) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::add_recorder -// Access: Published -// Description: Adds the named recorder to the set of recorders. -//////////////////////////////////////////////////////////////////// +/** + * Adds the named recorder to the set of recorders. + */ INLINE void RecorderTable:: add_recorder(const string &name, RecorderBase *recorder) { nassertv(recorder != (RecorderBase *)NULL); @@ -69,12 +59,10 @@ add_recorder(const string &name, RecorderBase *recorder) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::get_recorder -// Access: Published -// Description: Returns the recorder with the indicated name, or NULL -// if there is no such recorder. -//////////////////////////////////////////////////////////////////// +/** + * Returns the recorder with the indicated name, or NULL if there is no such + * recorder. + */ INLINE RecorderBase *RecorderTable:: get_recorder(const string &name) const { Recorders::const_iterator ri = _recorders.find(name); @@ -84,13 +72,10 @@ get_recorder(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::remove_recorder -// Access: Published -// Description: Removes the named recorder from the table. Returns -// true if successful, false if there was no such -// recorder. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named recorder from the table. Returns true if successful, + * false if there was no such recorder. + */ INLINE bool RecorderTable:: remove_recorder(const string &name) { Recorders::iterator ri = _recorders.find(name); diff --git a/panda/src/recorder/recorderTable.cxx b/panda/src/recorder/recorderTable.cxx index 25b74c42e8..6b60d82ada 100644 --- a/panda/src/recorder/recorderTable.cxx +++ b/panda/src/recorder/recorderTable.cxx @@ -1,16 +1,15 @@ -// Filename: recorderTable.cxx -// Created by: drose (27Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderTable.cxx + * @author drose + * @date 2004-01-27 + */ #include "recorderTable.h" #include "bamReader.h" @@ -21,11 +20,9 @@ TypeHandle RecorderTable::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RecorderTable:: ~RecorderTable() { Recorders::iterator ri; @@ -34,15 +31,11 @@ RecorderTable:: } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::merge_from -// Access: Public -// Description: Combines the data in the current table (presumably -// just read from disk, and matching exactly with the -// disk data) with the data in the indicated table, -// specified by the user (which may not exactly match -// the disk data). -//////////////////////////////////////////////////////////////////// +/** + * Combines the data in the current table (presumably just read from disk, and + * matching exactly with the disk data) with the data in the indicated table, + * specified by the user (which may not exactly match the disk data). + */ void RecorderTable:: merge_from(const RecorderTable &other) { Recorders::const_iterator ori; @@ -52,14 +45,14 @@ merge_from(const RecorderTable &other) { Recorders::iterator ri = _recorders.find(name); if (ri == _recorders.end()) { - // This may not be an error, since maybe the data isn't here - // yet, but it'll be along later. + // This may not be an error, since maybe the data isn't here yet, but + // it'll be along later. recorder_cat.debug() << "No data for " << name << " in session.\n"; } else if ((*ri).second->get_type() == recorder->get_type()) { - // If we already had a recorder by that name with the same type, - // throw it away (otherwise, keep the one we had before). + // If we already had a recorder by that name with the same type, throw + // it away (otherwise, keep the one we had before). if ((*ri).second != recorder) { recorder->ref(); unref_delete((*ri).second); @@ -74,8 +67,8 @@ merge_from(const RecorderTable &other) { } } - // Now report any recorders in the session file that weren't - // specified by the user. + // Now report any recorders in the session file that weren't specified by + // the user. Recorders::const_iterator ri; for (ri = _recorders.begin(); ri != _recorders.end(); ++ri) { const string &name = (*ri).first; @@ -87,11 +80,9 @@ merge_from(const RecorderTable &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::record_frame -// Access: Published -// Description: Calls record_frame on all recorders. -//////////////////////////////////////////////////////////////////// +/** + * Calls record_frame on all recorders. + */ void RecorderTable:: record_frame(BamWriter *manager, Datagram &dg) { Recorders::iterator ri; @@ -103,11 +94,9 @@ record_frame(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::play_frame -// Access: Published -// Description: Calls play_frame on all recorders. -//////////////////////////////////////////////////////////////////// +/** + * Calls play_frame on all recorders. + */ void RecorderTable:: play_frame(DatagramIterator &scan, BamReader *manager) { Recorders::iterator ri; @@ -119,11 +108,9 @@ play_frame(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::set_flags -// Access: Published -// Description: Sets the given flags on all recorders. -//////////////////////////////////////////////////////////////////// +/** + * Sets the given flags on all recorders. + */ void RecorderTable:: set_flags(short flags) { Recorders::iterator ri; @@ -135,11 +122,9 @@ set_flags(short flags) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::clear_flags -// Access: Published -// Description: Clears the given flags on all recorders. -//////////////////////////////////////////////////////////////////// +/** + * Clears the given flags on all recorders. + */ void RecorderTable:: clear_flags(short flags) { Recorders::iterator ri; @@ -151,11 +136,9 @@ clear_flags(short flags) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RecorderTable:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -170,23 +153,18 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void RecorderTable:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void RecorderTable:: write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable::write_datagram(manager, dg); @@ -202,14 +180,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type Lens is encountered -// in the Bam file. It should create the Lens -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type Lens is encountered in the Bam file. It should create the Lens and + * extract its information from the file. + */ TypedWritable *RecorderTable:: make_from_bam(const FactoryParams ¶ms) { RecorderTable *table = new RecorderTable; @@ -222,13 +197,10 @@ make_from_bam(const FactoryParams ¶ms) { return table; } -//////////////////////////////////////////////////////////////////// -// Function: RecorderTable::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new RecorderTable. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new RecorderTable. + */ void RecorderTable:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/panda/src/recorder/recorderTable.h b/panda/src/recorder/recorderTable.h index f742717406..7a5046c651 100644 --- a/panda/src/recorder/recorderTable.h +++ b/panda/src/recorder/recorderTable.h @@ -1,16 +1,15 @@ -// Filename: recorderTable.h -// Created by: drose (27Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file recorderTable.h + * @author drose + * @date 2004-01-27 + */ #ifndef RECORDERTABLE_H #define RECORDERTABLE_H @@ -25,13 +24,11 @@ class BamWriter; class BamReader; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : RecorderTable -// Description : This object is used by the RecorderController to -// write (and read) a record of the set of recorders in -// use to the bam file. Do not attempt to use it -// directly. -//////////////////////////////////////////////////////////////////// +/** + * This object is used by the RecorderController to write (and read) a record + * of the set of recorders in use to the bam file. Do not attempt to use it + * directly. + */ class EXPCL_PANDA_RECORDER RecorderTable : public TypedWritable { public: INLINE RecorderTable(); @@ -52,9 +49,9 @@ public: void write(ostream &out, int indent_level) const; - // RecorderBase itself doesn't inherit from ReferenceCount, so - // we can't put a PT() around it. Instead, we manage the reference - // count using calls to ref() and unref(). + // RecorderBase itself doesn't inherit from ReferenceCount, so we can't put + // a PT() around it. Instead, we manage the reference count using calls to + // ref() and unref(). typedef pmap Recorders; Recorders _recorders; @@ -89,4 +86,3 @@ private: #include "recorderTable.I" #endif - diff --git a/panda/src/recorder/socketStreamRecorder.I b/panda/src/recorder/socketStreamRecorder.I index 78671a3f8e..90c0585860 100644 --- a/panda/src/recorder/socketStreamRecorder.I +++ b/panda/src/recorder/socketStreamRecorder.I @@ -1,23 +1,19 @@ -// Filename: socketStreamRecorder.I -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStreamRecorder.I + * @author drose + * @date 2004-01-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SocketStreamRecorder:: SocketStreamRecorder() : _stream(NULL), @@ -26,11 +22,9 @@ SocketStreamRecorder() : { } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SocketStreamRecorder:: SocketStreamRecorder(SocketStream *stream, bool owns_stream) : _stream(stream), @@ -39,11 +33,9 @@ SocketStreamRecorder(SocketStream *stream, bool owns_stream) : { } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SocketStreamRecorder:: ~SocketStreamRecorder() { if (_owns_stream) { @@ -51,11 +43,9 @@ INLINE SocketStreamRecorder:: } } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::send_datagram -// Access: Public -// Description: See SocketStream::send_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::send_datagram(). + */ bool SocketStreamRecorder:: send_datagram(const Datagram &dg) { if (_stream != (SocketStream *)NULL) { @@ -64,11 +54,9 @@ send_datagram(const Datagram &dg) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::is_closed -// Access: Published -// Description: See SocketStream::is_closed(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::is_closed(). + */ INLINE bool SocketStreamRecorder:: is_closed() { if (_stream != (SocketStream *)NULL) { @@ -77,11 +65,9 @@ is_closed() { return is_playing() && _closed; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::close -// Access: Published -// Description: See SocketStream::close(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::close(). + */ INLINE void SocketStreamRecorder:: close() { if (_stream != (SocketStream *)NULL) { @@ -90,11 +76,9 @@ close() { _closed = true; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::set_collect_tcp -// Access: Published -// Description: See SocketStream::set_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::set_collect_tcp(). + */ INLINE void SocketStreamRecorder:: set_collect_tcp(bool collect_tcp) { if (_stream != (SocketStream *)NULL) { @@ -102,11 +86,9 @@ set_collect_tcp(bool collect_tcp) { } } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::get_collect_tcp -// Access: Published -// Description: See SocketStream::get_collect_tcp(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::get_collect_tcp(). + */ INLINE bool SocketStreamRecorder:: get_collect_tcp() const { if (_stream != (SocketStream *)NULL) { @@ -115,11 +97,9 @@ get_collect_tcp() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::set_collect_tcp_interval -// Access: Published -// Description: See SocketStream::set_collect_tcp_interval(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::set_collect_tcp_interval(). + */ INLINE void SocketStreamRecorder:: set_collect_tcp_interval(double interval) { if (_stream != (SocketStream *)NULL) { @@ -127,11 +107,9 @@ set_collect_tcp_interval(double interval) { } } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::get_collect_tcp_interval -// Access: Published -// Description: See SocketStream::get_collect_tcp_interval(). -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::get_collect_tcp_interval(). + */ INLINE double SocketStreamRecorder:: get_collect_tcp_interval() const { if (_stream != (SocketStream *)NULL) { @@ -140,11 +118,9 @@ get_collect_tcp_interval() const { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::consider_flush -// Access: Published -// Description: See SocketStream::consider_flush() -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::consider_flush() + */ INLINE bool SocketStreamRecorder:: consider_flush() { if (_stream != (SocketStream *)NULL) { @@ -153,11 +129,9 @@ consider_flush() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::flush -// Access: Published -// Description: See SocketStream::flush() -//////////////////////////////////////////////////////////////////// +/** + * See SocketStream::flush() + */ INLINE bool SocketStreamRecorder:: flush() { if (_stream != (SocketStream *)NULL) { diff --git a/panda/src/recorder/socketStreamRecorder.cxx b/panda/src/recorder/socketStreamRecorder.cxx index 08df0a6a00..1b9493fc03 100644 --- a/panda/src/recorder/socketStreamRecorder.cxx +++ b/panda/src/recorder/socketStreamRecorder.cxx @@ -1,16 +1,15 @@ -// Filename: socketStreamRecorder.cxx -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStreamRecorder.cxx + * @author drose + * @date 2004-01-28 + */ #include "socketStreamRecorder.h" #include "recorderController.h" @@ -21,20 +20,17 @@ TypeHandle SocketStreamRecorder::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::receive_datagram -// Access: Public -// Description: Receives a datagram over the socket by expecting a -// little-endian 16-bit byte count as a prefix. If the -// socket stream is non-blocking, may return false if -// the data is not available; otherwise, returns false -// only if the socket closes. -//////////////////////////////////////////////////////////////////// +/** + * Receives a datagram over the socket by expecting a little-endian 16-bit + * byte count as a prefix. If the socket stream is non-blocking, may return + * false if the data is not available; otherwise, returns false only if the + * socket closes. + */ bool SocketStreamRecorder:: receive_datagram(Datagram &dg) { if (is_playing()) { - // If we're playing back data, the datagrams come only from the - // queue, not from the live connection. + // If we're playing back data, the datagrams come only from the queue, not + // from the live connection. if (!_data.empty()) { dg = _data.front(); _data.pop_front(); @@ -44,8 +40,7 @@ receive_datagram(Datagram &dg) { return false; } else { - // If we're not in playback mode, forward the request to the - // connection. + // If we're not in playback mode, forward the request to the connection. bool got_data = false; if (_stream != (SocketStream *)NULL) { got_data = _stream->receive_datagram(dg); @@ -60,14 +55,11 @@ receive_datagram(Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::record_frame -// Access: Public, Virtual -// Description: Records the most recent data collected into the -// indicated datagram, and returns true if there is any -// interesting data worth recording, or false if the -// datagram is meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Records the most recent data collected into the indicated datagram, and + * returns true if there is any interesting data worth recording, or false if + * the datagram is meaningless. + */ void SocketStreamRecorder:: record_frame(BamWriter *manager, Datagram &dg) { nassertv(is_recording()); @@ -80,12 +72,9 @@ record_frame(BamWriter *manager, Datagram &dg) { } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::play_frame -// Access: Public, Virtual -// Description: Reloads the most recent data collected from the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Reloads the most recent data collected from the indicated datagram. + */ void SocketStreamRecorder:: play_frame(DatagramIterator &scan, BamReader *manager) { nassertv(is_playing()); @@ -98,39 +87,30 @@ play_frame(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// Lens. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type Lens. + */ void SocketStreamRecorder:: register_with_read_factory() { RecorderController::get_factory()->register_factory(get_class_type(), make_recorder); } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::write_recorder -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for encoding in the session file. This is very -// similar to write_datagram() for TypedWritable -// objects, but it is used specifically to write the -// Recorder object when generating the session file. In -// many cases, it will be the same as write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for encoding in the + * session file. This is very similar to write_datagram() for TypedWritable + * objects, but it is used specifically to write the Recorder object when + * generating the session file. In many cases, it will be the same as + * write_datagram(). + */ void SocketStreamRecorder:: write_recorder(BamWriter *manager, Datagram &dg) { RecorderBase::write_recorder(manager, dg); } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::make_recorder -// Access: Protected, Static -// Description: This is similar to make_from_bam(), but it is -// designed for loading the RecorderBase object from the -// session log created by a RecorderController. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to make_from_bam(), but it is designed for loading the + * RecorderBase object from the session log created by a RecorderController. + */ RecorderBase *SocketStreamRecorder:: make_recorder(const FactoryParams ¶ms) { SocketStreamRecorder *node = new SocketStreamRecorder; @@ -143,13 +123,10 @@ make_recorder(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: SocketStreamRecorder::fillin_recorder -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SocketStreamRecorder. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SocketStreamRecorder. + */ void SocketStreamRecorder:: fillin_recorder(DatagramIterator &scan, BamReader *manager) { RecorderBase::fillin_recorder(scan, manager); diff --git a/panda/src/recorder/socketStreamRecorder.h b/panda/src/recorder/socketStreamRecorder.h index 1ad7af2b4e..09513a0c54 100644 --- a/panda/src/recorder/socketStreamRecorder.h +++ b/panda/src/recorder/socketStreamRecorder.h @@ -1,16 +1,15 @@ -// Filename: socketStreamRecorder.h -// Created by: drose (28Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file socketStreamRecorder.h + * @author drose + * @date 2004-01-28 + */ #ifndef SOCKETSTREAMRECORDER_H #define SOCKETSTREAMRECORDER_H @@ -25,23 +24,19 @@ class BamWriter; class FactoryParams; class DatagramIterator; -// At the present, this module is not compiled if OpenSSL is not -// available, since in that case socketStream.h is not compiled -// either. +// At the present, this module is not compiled if OpenSSL is not available, +// since in that case socketStream.h is not compiled either. #ifdef HAVE_OPENSSL -//////////////////////////////////////////////////////////////////// -// Class : SocketStreamRecorder -// Description : Records any data received from the indicated socket -// stream. On playback, it will act as if the incoming -// data is coming over the wire again even if an actual -// connection is not available. -// -// Outbound data will not be recorded, but will be sent -// straight through to the socket if it is connected, or -// silently ignored if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Records any data received from the indicated socket stream. On playback, + * it will act as if the incoming data is coming over the wire again even if + * an actual connection is not available. + * + * Outbound data will not be recorded, but will be sent straight through to + * the socket if it is connected, or silently ignored if it is not. + */ class EXPCL_PANDA_RECORDER SocketStreamRecorder : public RecorderBase, public ReferenceCount { PUBLISHED: diff --git a/panda/src/rocket/config_rocket.cxx b/panda/src/rocket/config_rocket.cxx index 0bb8dd1c0a..b4a43f8127 100644 --- a/panda/src/rocket/config_rocket.cxx +++ b/panda/src/rocket/config_rocket.cxx @@ -1,16 +1,15 @@ -// Filename: config_rocket.cxx -// Created by: rdb (04Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_rocket.cxx + * @author rdb + * @date 2011-11-04 + */ #include "config_rocket.h" #include "rocketFileInterface.h" @@ -34,14 +33,12 @@ ConfigureFn(config_rocket) { init_librocket(); } -//////////////////////////////////////////////////////////////////// -// Function: init_librocket -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_librocket() { static bool initialized = false; diff --git a/panda/src/rocket/config_rocket.h b/panda/src/rocket/config_rocket.h index 4a188cb405..8537ed0519 100644 --- a/panda/src/rocket/config_rocket.h +++ b/panda/src/rocket/config_rocket.h @@ -1,16 +1,15 @@ -// Filename: config_rocket.h -// Created by: rdb (04Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_rocket.h + * @author rdb + * @date 2011-11-04 + */ #ifndef CONFIG_ROCKET_H #define CONFIG_ROCKET_H diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index ba519760f9..99ddcd5256 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -1,26 +1,23 @@ -// Filename: rocketFileInterface.cxx -// Created by: rdb (03Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketFileInterface.cxx + * @author rdb + * @date 2011-11-03 + */ #include "rocketFileInterface.h" #include "virtualFileSystem.h" -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Constructor -// Access: Public -// Description: Constructs a RocketFileInterface for the given -// VFS, or the default if NULL is given. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a RocketFileInterface for the given VFS, or the default if NULL + * is given. + */ RocketFileInterface:: RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) { if (_vfs == NULL) { @@ -28,11 +25,9 @@ RocketFileInterface(VirtualFileSystem *vfs) : _vfs(vfs) { } } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Open -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Rocket::Core::FileHandle RocketFileInterface:: Open(const Rocket::Core::String& path) { rocket_cat.debug() << "Opening " << path.CString() << "\n"; @@ -69,11 +64,9 @@ Open(const Rocket::Core::String& path) { return (Rocket::Core::FileHandle) handle; } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Close -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RocketFileInterface:: Close(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; @@ -85,11 +78,9 @@ Close(Rocket::Core::FileHandle file) { delete handle; } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Read -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t RocketFileInterface:: Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; @@ -101,11 +92,9 @@ Read(void* buffer, size_t size, Rocket::Core::FileHandle file) { return handle->_stream->gcount(); } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Seek -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool RocketFileInterface:: Seek(Rocket::Core::FileHandle file, long offset, int origin) { VirtualFileHandle *handle = (VirtualFileHandle*) file; @@ -127,11 +116,9 @@ Seek(Rocket::Core::FileHandle file, long offset, int origin) { return !handle->_stream->fail(); } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Tell -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t RocketFileInterface:: Tell(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; @@ -142,11 +129,9 @@ Tell(Rocket::Core::FileHandle file) { return handle->_stream->tellg(); } -//////////////////////////////////////////////////////////////////// -// Function: RocketFileInterface::Length -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ size_t RocketFileInterface:: Length(Rocket::Core::FileHandle file) { VirtualFileHandle *handle = (VirtualFileHandle*) file; diff --git a/panda/src/rocket/rocketFileInterface.h b/panda/src/rocket/rocketFileInterface.h index 3014568e82..8a340136b5 100644 --- a/panda/src/rocket/rocketFileInterface.h +++ b/panda/src/rocket/rocketFileInterface.h @@ -1,16 +1,15 @@ -// Filename: rocketFileInterface.h -// Created by: rdb (03Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketFileInterface.h + * @author rdb + * @date 2011-11-03 + */ #ifndef ROCKET_FILE_INTERFACE_H #define ROCKET_FILE_INTERFACE_H @@ -21,11 +20,10 @@ class VirtualFileSystem; -//////////////////////////////////////////////////////////////////// -// Class : RocketFileInterface -// Description : Implementation of FileInterface to allow libRocket -// to read files from the virtual file system. -//////////////////////////////////////////////////////////////////// +/** + * Implementation of FileInterface to allow libRocket to read files from the + * virtual file system. + */ class RocketFileInterface : public Rocket::Core::FileInterface { public: RocketFileInterface(VirtualFileSystem *vfs = NULL); diff --git a/panda/src/rocket/rocketInputHandler.cxx b/panda/src/rocket/rocketInputHandler.cxx index 5cd4d30425..5451beda9e 100644 --- a/panda/src/rocket/rocketInputHandler.cxx +++ b/panda/src/rocket/rocketInputHandler.cxx @@ -1,16 +1,15 @@ -// Filename: rocketInputHandler.cxx -// Created by: rdb (20Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketInputHandler.cxx + * @author rdb + * @date 2011-12-20 + */ #include "rocketInputHandler.h" #include "buttonEventList.h" @@ -28,11 +27,9 @@ using namespace Rocket::Core::Input; TypeHandle RocketInputHandler::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RocketInputHandler::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RocketInputHandler:: RocketInputHandler(const string &name) : DataNode(name), @@ -45,21 +42,17 @@ RocketInputHandler(const string &name) : _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: RocketInputHandler::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RocketInputHandler:: ~RocketInputHandler() { } -//////////////////////////////////////////////////////////////////// -// Function: RocketInputHandler::get_rocket_key -// Access: Published -// Description: Returns the libRocket KeyIdentifier for the given -// ButtonHandle, or KI_UNKNOWN (0) if it wasn't known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the libRocket KeyIdentifier for the given ButtonHandle, or + * KI_UNKNOWN (0) if it wasn't known. + */ int RocketInputHandler:: get_rocket_key(const ButtonHandle handle) { static pmap keymap; @@ -129,8 +122,9 @@ get_rocket_key(const ButtonHandle handle) { keymap[KeyboardButton::ascii_key('\\').get_index()] = KI_OEM_5; keymap[KeyboardButton::ascii_key(']').get_index()] = KI_OEM_6; - // comment says this may either be "<>" or "\|", but "\" (unshifted) is handled already, - // and "<" is only available "shifted" on 101-keyboards, so assume it's this one... + // comment says this may either be "<>" or "\|", but "\" (unshifted) is + // handled already, and "<" is only available "shifted" on 101-keyboards, so + // assume it's this one... keymap[KeyboardButton::ascii_key('<').get_index()] = KI_OEM_102; for (char c = 'a'; c <= 'z'; ++c) { @@ -147,19 +141,14 @@ get_rocket_key(const ButtonHandle handle) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: RocketInputHandler::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void RocketInputHandler:: do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -268,7 +257,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, break; case ButtonEvent::T_keystroke: - // Ignore control characters; otherwise, they actually get added to strings in the UI. + // Ignore control characters; otherwise, they actually get added to + // strings in the UI. if (be._keycode > 0x1F && (be._keycode < 0x7F || be._keycode > 0x9F)) { _text_input.push_back(be._keycode); } @@ -293,13 +283,10 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, } } -//////////////////////////////////////////////////////////////////// -// Function: RocketInputHandler::update_context -// Access: Public -// Description: Updates the libRocket context with the changes -// that we have gathered in do_transmit_data. -// Also calls Update() on the context. -//////////////////////////////////////////////////////////////////// +/** + * Updates the libRocket context with the changes that we have gathered in + * do_transmit_data. Also calls Update() on the context. + */ void RocketInputHandler:: update_context(Rocket::Core::Context *context, int xoffs, int yoffs) { MutexHolder holder(_lock); diff --git a/panda/src/rocket/rocketInputHandler.h b/panda/src/rocket/rocketInputHandler.h index 632a9f9894..e1637ba681 100644 --- a/panda/src/rocket/rocketInputHandler.h +++ b/panda/src/rocket/rocketInputHandler.h @@ -1,16 +1,15 @@ -// Filename: rocketInputHandler.h -// Created by: rdb (20Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketInputHandler.h + * @author rdb + * @date 2011-12-20 + */ #ifndef ROCKETINPUTHANDLER_H #define ROCKETINPUTHANDLER_H @@ -25,11 +24,10 @@ namespace Rocket { } } -//////////////////////////////////////////////////////////////////// -// Class : RocketInputHandler -// Description : DataNode that listens for keyboard and mouse -// events and passes them to libRocket. -//////////////////////////////////////////////////////////////////// +/** + * DataNode that listens for keyboard and mouse events and passes them to + * libRocket. + */ class EXPCL_ROCKET RocketInputHandler : public DataNode { PUBLISHED: RocketInputHandler(const string &name = string()); diff --git a/panda/src/rocket/rocketRegion.I b/panda/src/rocket/rocketRegion.I index eb71b545f1..f9fe378ff7 100644 --- a/panda/src/rocket/rocketRegion.I +++ b/panda/src/rocket/rocketRegion.I @@ -1,41 +1,32 @@ -// Filename: rocketRegion.I -// Created by: rdb (01Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRegion.I + * @author rdb + * @date 2011-12-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::make -// Access: Published, Static -// Description: Creates a libRocket context with the given name -// (must be unique) for the given window. Returns -// a new DisplayRegion where the libRocket context -// will render to. -// This variant of make() creates a region that -// fills the entire window. -//////////////////////////////////////////////////////////////////// +/** + * Creates a libRocket context with the given name (must be unique) for the + * given window. Returns a new DisplayRegion where the libRocket context will + * render to. This variant of make() creates a region that fills the entire + * window. + */ INLINE RocketRegion *RocketRegion:: make(const string &context_name, GraphicsOutput *window) { return make(context_name, window, LVecBase4(0.0f, 1.0f, 0.0f, 1.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::make -// Access: Published, Static -// Description: Creates a libRocket context with the given name -// (must be unique) for the given window. Returns -// a new DisplayRegion where the libRocket context -// will render to. -//////////////////////////////////////////////////////////////////// +/** + * Creates a libRocket context with the given name (must be unique) for the + * given window. Returns a new DisplayRegion where the libRocket context will + * render to. + */ INLINE RocketRegion *RocketRegion:: make(const string &context_name, GraphicsOutput *window, const LVecBase4 &dimensions) { @@ -44,41 +35,33 @@ make(const string &context_name, GraphicsOutput *window, } #ifndef CPPPARSER -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::get_context -// Access: Published -// Description: Returns a pointer to the Rocket context associated -// with this region. Does not increase the reference -// count, so if you want to preserve it for longer -// than this region exists, be sure to call -// AddReference() and RemoveReference() yourself. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the Rocket context associated with this region. Does + * not increase the reference count, so if you want to preserve it for longer + * than this region exists, be sure to call AddReference() and + * RemoveReference() yourself. + */ Rocket::Core::Context* RocketRegion:: get_context() const { return _context; } #endif -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::set_input_handler -// Access: Published -// Description: Sets the RocketInputHandler object from which to -// gather the keyboard and mouse inputs to pass to -// the libRocket context before rendering. -// You may use one input handler to provide inputs to -// any number of RocketRegion objects. -//////////////////////////////////////////////////////////////////// +/** + * Sets the RocketInputHandler object from which to gather the keyboard and + * mouse inputs to pass to the libRocket context before rendering. You may + * use one input handler to provide inputs to any number of RocketRegion + * objects. + */ INLINE void RocketRegion:: set_input_handler(RocketInputHandler *handler) { _input_handler = handler; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::get_input_handler -// Access: Published -// Description: Returns the RocketInputHandler object previously -// passed to set_input_handler. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RocketInputHandler object previously passed to + * set_input_handler. + */ INLINE RocketInputHandler *RocketRegion:: get_input_handler() const { return _input_handler; diff --git a/panda/src/rocket/rocketRegion.cxx b/panda/src/rocket/rocketRegion.cxx index 8709c4c36e..ebfcd630c2 100644 --- a/panda/src/rocket/rocketRegion.cxx +++ b/panda/src/rocket/rocketRegion.cxx @@ -1,16 +1,15 @@ -// Filename: rocketRegion.cxx -// Created by: rdb (30Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRegion.cxx + * @author rdb + * @date 2011-11-30 + */ #include "rocketRegion.h" #include "graphicsOutput.h" @@ -27,18 +26,16 @@ TypeHandle RocketRegion::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::Constructor -// Access: Protected -// Description: Make sure that context_name is unique. -//////////////////////////////////////////////////////////////////// +/** + * Make sure that context_name is unique. + */ RocketRegion:: RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, const string &context_name) : DisplayRegion(window, dr_dimensions) { - // A hack I don't like. libRocket's decorator system has - // a bug somewhere, and this seems to be a workaround. + // A hack I don't like. libRocket's decorator system has a bug somewhere, + // and this seems to be a workaround. if (Rocket::Core::GetRenderInterface() == NULL) { Rocket::Core::SetRenderInterface(&_interface); } @@ -64,11 +61,9 @@ RocketRegion(GraphicsOutput *window, const LVecBase4 &dr_dimensions, set_camera(NodePath(cam)); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RocketRegion:: ~RocketRegion() { if (Rocket::Core::GetRenderInterface() == &_interface) { @@ -81,8 +76,8 @@ RocketRegion:: return; } - // We need to do this because libRocket may call into Python - // code to throw destruction events. + // We need to do this because libRocket may call into Python code to throw + // destruction events. #ifdef HAVE_ROCKET_PYTHON PyGILState_STATE gstate; gstate = PyGILState_Ensure(); @@ -96,19 +91,17 @@ RocketRegion:: } } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::do_cull -// Access: Protected, Virtual -// Description: Performs a cull traversal for this region. -//////////////////////////////////////////////////////////////////// +/** + * Performs a cull traversal for this region. + */ void RocketRegion:: do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, GraphicsStateGuardian *gsg, Thread *current_thread) { PStatTimer timer(get_cull_region_pcollector(), current_thread); - // We (unfortunately) need to do this because libRocket - // may call into Python code to throw events. + // We (unfortunately) need to do this because libRocket may call into Python + // code to throw events. #ifdef HAVE_ROCKET_PYTHON PyGILState_STATE gstate; gstate = PyGILState_Ensure(); @@ -148,14 +141,11 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup, trav->end_traverse(); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::init_debugger -// Access: Published -// Description: Initializes the libRocket debugger. This will -// return false if the debugger failed to initialize, -// or if support for the debugger has not been built -// in (for example in an optimize=4 build). -//////////////////////////////////////////////////////////////////// +/** + * Initializes the libRocket debugger. This will return false if the debugger + * failed to initialize, or if support for the debugger has not been built in + * (for example in an optimize=4 build). + */ bool RocketRegion:: init_debugger() { #ifdef HAVE_ROCKET_DEBUGGER @@ -165,11 +155,9 @@ init_debugger() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::set_debugger_visible -// Access: Published -// Description: Sets whether the debugger should be visible. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the debugger should be visible. + */ void RocketRegion:: set_debugger_visible(bool visible) { #ifdef HAVE_ROCKET_DEBUGGER @@ -177,11 +165,9 @@ set_debugger_visible(bool visible) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::is_debugger_visible -// Access: Published -// Description: Returns true if the debugger is visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the debugger is visible. + */ bool RocketRegion:: is_debugger_visible() const { #ifdef HAVE_ROCKET_DEBUGGER diff --git a/panda/src/rocket/rocketRegion.h b/panda/src/rocket/rocketRegion.h index 8f524708ae..d978ac6305 100644 --- a/panda/src/rocket/rocketRegion.h +++ b/panda/src/rocket/rocketRegion.h @@ -1,16 +1,15 @@ -// Filename: rocketRegion.h -// Created by: rdb (30Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRegion.h + * @author rdb + * @date 2011-11-30 + */ #ifndef ROCKETREGION_H #define ROCKETREGION_H @@ -22,11 +21,10 @@ class OrthographicLens; -//////////////////////////////////////////////////////////////////// -// Class : RocketRegion -// Description : Represents a region in a window or buffer where -// the libRocket UI will be rendered to. -//////////////////////////////////////////////////////////////////// +/** + * Represents a region in a window or buffer where the libRocket UI will be + * rendered to. + */ class EXPCL_ROCKET RocketRegion : public DisplayRegion { protected: RocketRegion(GraphicsOutput *window, const LVecBase4 &dimensions, diff --git a/panda/src/rocket/rocketRegion_ext.cxx b/panda/src/rocket/rocketRegion_ext.cxx index 06791ded82..adc73a219e 100644 --- a/panda/src/rocket/rocketRegion_ext.cxx +++ b/panda/src/rocket/rocketRegion_ext.cxx @@ -1,16 +1,15 @@ -// Filename: rocketRegion_ext.cxx -// Created by: rdb (06Dec11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRegion_ext.cxx + * @author rdb + * @date 2011-12-06 + */ #include "rocketRegion_ext.h" #include "extension.h" @@ -23,16 +22,12 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: RocketRegion::get_context -// Access: Published -// Description: Returns a pointer to the Rocket context associated -// with this region. Will only be valid as long as this -// region still exists, so be sure to toss it when you -// toss the region itself. -// It's best to call this method just once and store -// the context in a Python variable, to avoid overhead. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the Rocket context associated with this region. Will + * only be valid as long as this region still exists, so be sure to toss it + * when you toss the region itself. It's best to call this method just once + * and store the context in a Python variable, to avoid overhead. + */ PyObject* Extension:: get_context() const { try { diff --git a/panda/src/rocket/rocketRegion_ext.h b/panda/src/rocket/rocketRegion_ext.h index 2268a445c6..672844fc44 100644 --- a/panda/src/rocket/rocketRegion_ext.h +++ b/panda/src/rocket/rocketRegion_ext.h @@ -1,16 +1,15 @@ -// Filename: rocketRegion_ext.h -// Created by: rdb (13Sep13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRegion_ext.h + * @author rdb + * @date 2013-09-13 + */ #ifndef ROCKETREGION_EXT_H #define ROCKETREGION_EXT_H @@ -23,12 +22,10 @@ #include "rocketRegion.h" #include "py_panda.h" -//////////////////////////////////////////////////////////////////// -// Class : Extension -// Description : This class defines the extension methods for -// GeomVertexArrayData, which are called instead of -// any C++ methods with the same prototype. -//////////////////////////////////////////////////////////////////// +/** + * This class defines the extension methods for GeomVertexArrayData, which are + * called instead of any C++ methods with the same prototype. + */ template<> class Extension : public ExtensionBase { public: diff --git a/panda/src/rocket/rocketRenderInterface.cxx b/panda/src/rocket/rocketRenderInterface.cxx index 90304cda3b..76e69c6e27 100644 --- a/panda/src/rocket/rocketRenderInterface.cxx +++ b/panda/src/rocket/rocketRenderInterface.cxx @@ -1,16 +1,15 @@ -// Filename: rocketRenderInterface.cxx -// Created by: rdb (04Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRenderInterface.cxx + * @author rdb + * @date 2011-11-04 + */ #include "rocketRenderInterface.h" #include "cullableObject.h" @@ -30,12 +29,10 @@ #include "textureAttrib.h" #include "texturePool.h" -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::render -// Access: Public -// Description: Called by RocketNode in cull_callback. Invokes -// context->Render() and culls the result. -//////////////////////////////////////////////////////////////////// +/** + * Called by RocketNode in cull_callback. Invokes context->Render() and culls + * the result. + */ void RocketRenderInterface:: render(Rocket::Core::Context* context, CullTraverser *trav) { nassertv(context != NULL); @@ -62,11 +59,9 @@ render(Rocket::Core::Context* context, CullTraverser *trav) { _net_state = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::make_geom -// Access: Protected -// Description: Called internally to make a Geom from Rocket data. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to make a Geom from Rocket data. + */ PT(Geom) RocketRenderInterface:: make_geom(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, @@ -108,11 +103,9 @@ make_geom(Rocket::Core::Vertex* vertices, return geom; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::render_geom -// Access: Protected -// Description: Only call this during render(). Culls a geom. -//////////////////////////////////////////////////////////////////// +/** + * Only call this during render(). Culls a geom. + */ void RocketRenderInterface:: render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vector2f& translation) { LVector3 offset = LVector3::right() * translation.x + LVector3::up() * translation.y; @@ -139,12 +132,10 @@ render_geom(const Geom* geom, const RenderState* state, const Rocket::Core::Vect _trav->get_cull_handler()->record_object(object, _trav); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::RenderGeometry -// Access: Protected -// Description: Called by Rocket when it wants to render geometry -// that the application does not wish to optimize. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to render geometry that the application does + * not wish to optimize. + */ void RocketRenderInterface:: RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, @@ -171,12 +162,10 @@ RenderGeometry(Rocket::Core::Vertex* vertices, render_geom(geom, state, translation); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::CompileGeometry -// Access: Protected -// Description: Called by Rocket when it wants to compile geometry -// it believes will be static for the forseeable future. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to compile geometry it believes will be + * static for the forseeable future. + */ Rocket::Core::CompiledGeometryHandle RocketRenderInterface:: CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, @@ -215,12 +204,9 @@ CompileGeometry(Rocket::Core::Vertex* vertices, return (Rocket::Core::CompiledGeometryHandle) c; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::RenderCompiledGeometry -// Access: Protected -// Description: Called by Rocket when it wants to render -// application-compiled geometry. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to render application-compiled geometry. + */ void RocketRenderInterface:: RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation) { @@ -228,23 +214,17 @@ RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rock render_geom(c->_geom, c->_state, translation); } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::ReleaseCompiledGeometry -// Access: Protected -// Description: Called by Rocket when it wants to release -// application-compiled geometry. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to release application-compiled geometry. + */ void RocketRenderInterface:: ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry) { delete (CompiledGeometry*) geometry; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::LoadTexture -// Access: Protected -// Description: Called by Rocket when a texture is required by the -// library. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when a texture is required by the library. + */ bool RocketRenderInterface:: LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, @@ -270,14 +250,14 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, tex->set_minfilter(SamplerState::FT_nearest); tex->set_magfilter(SamplerState::FT_nearest); - // Since libRocket may make layout decisions based on the size of - // the image, it's important that we give it the original size of - // the image file in order to produce consistent results. + // Since libRocket may make layout decisions based on the size of the image, + // it's important that we give it the original size of the image file in + // order to produce consistent results. int width = tex->get_orig_file_x_size(); int height = tex->get_orig_file_y_size(); if (width == 0 && height == 0) { - // This shouldn't happen unless someone is playing very strange - // tricks with the TexturePool, but we might as well handle it. + // This shouldn't happen unless someone is playing very strange tricks + // with the TexturePool, but we might as well handle it. width = tex->get_x_size(); height = tex->get_y_size(); } @@ -290,12 +270,10 @@ LoadTexture(Rocket::Core::TextureHandle& texture_handle, return true; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::GenerateTexture -// Access: Protected -// Description: Called by Rocket when a texture is required to be -// built from an internally-generated sequence of pixels. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when a texture is required to be built from an internally- + * generated sequence of pixels. + */ bool RocketRenderInterface:: GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, @@ -305,8 +283,8 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, tex->setup_2d_texture(source_dimensions.x, source_dimensions.y, Texture::T_unsigned_byte, Texture::F_rgba); - // Pad to nearest power of two if necessary. It may not be necessary - // as libRocket seems to give power-of-two sizes already, but can't hurt. + // Pad to nearest power of two if necessary. It may not be necessary as + // libRocket seems to give power-of-two sizes already, but can't hurt. tex->set_size_padded(source_dimensions.x, source_dimensions.y); PTA_uchar image = tex->modify_ram_image(); @@ -338,12 +316,9 @@ GenerateTexture(Rocket::Core::TextureHandle& texture_handle, return true; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::ReleaseTexture -// Access: Protected -// Description: Called by Rocket when a loaded texture is no longer -// required. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when a loaded texture is no longer required. + */ void RocketRenderInterface:: ReleaseTexture(Rocket::Core::TextureHandle texture_handle) { Texture *tex = (Texture *)texture_handle; @@ -352,23 +327,18 @@ ReleaseTexture(Rocket::Core::TextureHandle texture_handle) { } } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::EnableScissorRegion -// Access: Protected -// Description: Called by Rocket when it wants to enable or disable -// scissoring to clip content. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to enable or disable scissoring to clip + * content. + */ void RocketRenderInterface:: EnableScissorRegion(bool enable) { _enable_scissor = enable; } -//////////////////////////////////////////////////////////////////// -// Function: RocketRenderInterface::SetScissorRegion -// Access: Protected -// Description: Called by Rocket when it wants to change the -// scissor region. -//////////////////////////////////////////////////////////////////// +/** + * Called by Rocket when it wants to change the scissor region. + */ void RocketRenderInterface:: SetScissorRegion(int x, int y, int width, int height) { _scissor[0] = x / (PN_stdfloat) _dimensions.x; diff --git a/panda/src/rocket/rocketRenderInterface.h b/panda/src/rocket/rocketRenderInterface.h index fac486831e..391523c902 100644 --- a/panda/src/rocket/rocketRenderInterface.h +++ b/panda/src/rocket/rocketRenderInterface.h @@ -1,16 +1,15 @@ -// Filename: rocketRenderInterface.h -// Created by: rdb (04Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketRenderInterface.h + * @author rdb + * @date 2011-11-04 + */ #ifndef ROCKET_RENDER_INTERFACE_H #define ROCKET_RENDER_INTERFACE_H @@ -24,11 +23,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Class : RocketRenderInterface -// Description : Class that provides the main render interface for -// libRocket integration. -//////////////////////////////////////////////////////////////////// +/** + * Class that provides the main render interface for libRocket integration. + */ class RocketRenderInterface : public Rocket::Core::RenderInterface { public: void render(Rocket::Core::Context* context, CullTraverser *trav); diff --git a/panda/src/rocket/rocketSystemInterface.cxx b/panda/src/rocket/rocketSystemInterface.cxx index 7f49ef02e8..66d52e9827 100644 --- a/panda/src/rocket/rocketSystemInterface.cxx +++ b/panda/src/rocket/rocketSystemInterface.cxx @@ -1,40 +1,34 @@ -// Filename: rocketSystemInterface.cxx -// Created by: rdb (03Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketSystemInterface.cxx + * @author rdb + * @date 2011-11-03 + */ #include "rocketSystemInterface.h" #include "clockObject.h" -//////////////////////////////////////////////////////////////////// -// Function: RocketSystemInterface::GetElapsedTime -// Access: Public -// Description: Get the number of seconds elapsed since the start -// of the application. -//////////////////////////////////////////////////////////////////// +/** + * Get the number of seconds elapsed since the start of the application. + */ float RocketSystemInterface:: GetElapsedTime() { ClockObject *clock = ClockObject::get_global_clock(); - //XXX not sure exactly how Rocket uses uses it, maybe get_frame_time is better? + // XXX not sure exactly how Rocket uses uses it, maybe get_frame_time is + // better? return clock->get_real_time(); } -//////////////////////////////////////////////////////////////////// -// Function: RocketSystemInterface::LogMessage -// Access: Public -// Description: Log the specified message. Returns true to -// continue execution, false to break into the -// debugger. -//////////////////////////////////////////////////////////////////// +/** + * Log the specified message. Returns true to continue execution, false to + * break into the debugger. + */ bool RocketSystemInterface:: LogMessage(Rocket::Core::Log::Type type, const Rocket::Core::String& message) { switch(type) { diff --git a/panda/src/rocket/rocketSystemInterface.h b/panda/src/rocket/rocketSystemInterface.h index 9233de94d9..b6ee34046c 100644 --- a/panda/src/rocket/rocketSystemInterface.h +++ b/panda/src/rocket/rocketSystemInterface.h @@ -1,16 +1,15 @@ -// Filename: rocketSystemInterface.h -// Created by: rdb (03Nov11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rocketSystemInterface.h + * @author rdb + * @date 2011-11-03 + */ #ifndef ROCKET_SYSTEM_INTERFACE_H #define ROCKET_SYSTEM_INTERFACE_H @@ -20,12 +19,10 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : RocketSystemInterface -// Description : This is an implementation of SystemInterface -// that redirects the log output to Panda's notify -// system. -//////////////////////////////////////////////////////////////////// +/** + * This is an implementation of SystemInterface that redirects the log output + * to Panda's notify system. + */ class RocketSystemInterface : public Rocket::Core::SystemInterface { public: float GetElapsedTime(); diff --git a/panda/src/skel/basicSkel.I b/panda/src/skel/basicSkel.I index 759d02473e..8a8b830bcd 100644 --- a/panda/src/skel/basicSkel.I +++ b/panda/src/skel/basicSkel.I @@ -1,51 +1,41 @@ -// Filename: basicSkel.I -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file basicSkel.I + * @author jyelon + * @date 2007-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BasicSkel:: BasicSkel() { } -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE BasicSkel:: ~BasicSkel() { } -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::set_value -// Access: Public -// Description: Stores an integer value. -//////////////////////////////////////////////////////////////////// +/** + * Stores an integer value. + */ INLINE void BasicSkel:: set_value(int n) { _value = n; } -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::get_value -// Access: Public -// Description: Retreives a value that was previously stored. -//////////////////////////////////////////////////////////////////// +/** + * Retreives a value that was previously stored. + */ INLINE int BasicSkel:: get_value() { return _value; diff --git a/panda/src/skel/basicSkel.cxx b/panda/src/skel/basicSkel.cxx index f01a1755c2..2b5eaab6ca 100644 --- a/panda/src/skel/basicSkel.cxx +++ b/panda/src/skel/basicSkel.cxx @@ -1,38 +1,31 @@ -// Filename: basicSkel.cxx -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file basicSkel.cxx + * @author jyelon + * @date 2007-01-31 + */ #include "basicSkel.h" -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::set_value_alt -// Access: Public -// Description: Stores an integer value. Exact same functionality -// as set_value, except that this isn't an inline -// function. -//////////////////////////////////////////////////////////////////// +/** + * Stores an integer value. Exact same functionality as set_value, except + * that this isn't an inline function. + */ void BasicSkel:: set_value_alt(int n) { _value = n; } -//////////////////////////////////////////////////////////////////// -// Function: BasicSkel::get_value -// Access: Public -// Description: Retreives a value that was previously stored. -// Exact same functionality as get_value, except -// that this isn't an inline function. -//////////////////////////////////////////////////////////////////// +/** + * Retreives a value that was previously stored. Exact same functionality as + * get_value, except that this isn't an inline function. + */ int BasicSkel:: get_value_alt() { return _value; diff --git a/panda/src/skel/basicSkel.h b/panda/src/skel/basicSkel.h index 8703459286..0186eb0f04 100644 --- a/panda/src/skel/basicSkel.h +++ b/panda/src/skel/basicSkel.h @@ -1,31 +1,28 @@ -// Filename: basicSkel.h -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file basicSkel.h + * @author jyelon + * @date 2007-01-31 + */ #ifndef BASICSKEL_H #define BASICSKEL_H #include "pandabase.h" -//////////////////////////////////////////////////////////////////// -// Class : BasicSkel -// Description : This is the most basic of the skeleton classes. -// It stores an integer, and will return it on request. -// -// The skeleton classes are intended to help you learn -// how to add C++ classes to panda. See also the manual, -// "Adding C++ Classes to Panda." -//////////////////////////////////////////////////////////////////// +/** + * This is the most basic of the skeleton classes. It stores an integer, and + * will return it on request. + * + * The skeleton classes are intended to help you learn how to add C++ classes + * to panda. See also the manual, "Adding C++ Classes to Panda." + */ class EXPCL_PANDASKEL BasicSkel { PUBLISHED: INLINE BasicSkel(); @@ -34,10 +31,10 @@ PUBLISHED: // These inline functions allow you to get and set _value. INLINE void set_value(int n); INLINE int get_value(); - + // These do the same thing as the functions above. void set_value_alt(int n); - int get_value_alt(); + int get_value_alt(); private: int _value; @@ -46,4 +43,3 @@ private: #include "basicSkel.I" #endif - diff --git a/panda/src/skel/config_skel.cxx b/panda/src/skel/config_skel.cxx index 009338f840..2c307d3270 100644 --- a/panda/src/skel/config_skel.cxx +++ b/panda/src/skel/config_skel.cxx @@ -1,16 +1,15 @@ -// Filename: config_skel.cxx -// Created by: jyelon (09Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_skel.cxx + * @author jyelon + * @date 2007-02-09 + */ #include "config_skel.h" #include "basicSkel.h" @@ -27,14 +26,12 @@ ConfigureFn(config_skel) { ConfigVariableInt skel_sample_config_variable ("skel-sample-config-variable", 3); -//////////////////////////////////////////////////////////////////// -// Function: init_libskel -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libskel() { static bool initialized = false; @@ -45,4 +42,3 @@ init_libskel() { TypedSkel::init_type(); } - diff --git a/panda/src/skel/config_skel.h b/panda/src/skel/config_skel.h index e1584e644f..a3f5be1a26 100644 --- a/panda/src/skel/config_skel.h +++ b/panda/src/skel/config_skel.h @@ -1,16 +1,15 @@ -// Filename: config_skel.h -// Created by: jyelon (09Feb07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_skel.h + * @author jyelon + * @date 2007-02-09 + */ #ifndef CONFIG_SKEL_H #define CONFIG_SKEL_H @@ -28,5 +27,3 @@ extern ConfigVariableInt skel_sample_config_variable; extern EXPCL_PANDASKEL void init_libskel(); #endif - - diff --git a/panda/src/skel/typedSkel.I b/panda/src/skel/typedSkel.I index e961cb5b18..d1b7f3d199 100644 --- a/panda/src/skel/typedSkel.I +++ b/panda/src/skel/typedSkel.I @@ -1,51 +1,41 @@ -// Filename: typedSkel.I -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedSkel.I + * @author jyelon + * @date 2007-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedSkel:: TypedSkel() { } -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TypedSkel:: ~TypedSkel() { } -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::set_value -// Access: Public -// Description: Stores an integer value. -//////////////////////////////////////////////////////////////////// +/** + * Stores an integer value. + */ INLINE void TypedSkel:: set_value(int n) { _value = n; } -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::get_value -// Access: Public -// Description: Retreives a value that was previously stored. -//////////////////////////////////////////////////////////////////// +/** + * Retreives a value that was previously stored. + */ INLINE int TypedSkel:: get_value() { return _value; diff --git a/panda/src/skel/typedSkel.cxx b/panda/src/skel/typedSkel.cxx index c7a1dbc8e7..5a89030ec9 100644 --- a/panda/src/skel/typedSkel.cxx +++ b/panda/src/skel/typedSkel.cxx @@ -1,40 +1,33 @@ -// Filename: typedSkel.cxx -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedSkel.cxx + * @author jyelon + * @date 2007-01-31 + */ #include "typedSkel.h" TypeHandle TypedSkel::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::set_value_alt -// Access: Public -// Description: Stores an integer value. Exact same functionality -// as set_value, except that this isn't an inline -// function. -//////////////////////////////////////////////////////////////////// +/** + * Stores an integer value. Exact same functionality as set_value, except + * that this isn't an inline function. + */ void TypedSkel:: set_value_alt(int n) { _value = n; } -//////////////////////////////////////////////////////////////////// -// Function: TypedSkel::get_value -// Access: Public -// Description: Retreives a value that was previously stored. -// Exact same functionality as get_value, except -// that this isn't an inline function. -//////////////////////////////////////////////////////////////////// +/** + * Retreives a value that was previously stored. Exact same functionality as + * get_value, except that this isn't an inline function. + */ int TypedSkel:: get_value_alt() { return _value; diff --git a/panda/src/skel/typedSkel.h b/panda/src/skel/typedSkel.h index e5f72af30d..7cd37f71ba 100644 --- a/panda/src/skel/typedSkel.h +++ b/panda/src/skel/typedSkel.h @@ -1,16 +1,15 @@ -// Filename: typedSkel.h -// Created by: jyelon (31Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file typedSkel.h + * @author jyelon + * @date 2007-01-31 + */ #ifndef TYPEDSKEL_H #define TYPEDSKEL_H @@ -18,15 +17,13 @@ #include "pandabase.h" #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : TypedSkel -// Description : Skeleton object that inherits from TypedObject. -// Stores an integer, and will return it on request. -// -// The skeleton classes are intended to help you learn -// how to add C++ classes to panda. See also the manual, -// "Adding C++ Classes to Panda." -//////////////////////////////////////////////////////////////////// +/** + * Skeleton object that inherits from TypedObject. Stores an integer, and + * will return it on request. + * + * The skeleton classes are intended to help you learn how to add C++ classes + * to panda. See also the manual, "Adding C++ Classes to Panda." + */ class EXPCL_PANDASKEL TypedSkel : public TypedObject { PUBLISHED: INLINE TypedSkel(); @@ -35,10 +32,10 @@ PUBLISHED: // These inline functions allow you to get and set _value. INLINE void set_value(int n); INLINE int get_value(); - + // These do the same thing as the functions above. void set_value_alt(int n); - int get_value_alt(); + int get_value_alt(); private: int _value; @@ -66,4 +63,3 @@ private: #include "typedSkel.I" #endif - diff --git a/panda/src/speedtree/config_speedtree.cxx b/panda/src/speedtree/config_speedtree.cxx index 8f4c69a075..fd4eb3cd5a 100644 --- a/panda/src/speedtree/config_speedtree.cxx +++ b/panda/src/speedtree/config_speedtree.cxx @@ -1,16 +1,15 @@ -// Filename: config_speedtree.cxx -// Created by: drose (30Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_speedtree.cxx + * @author drose + * @date 2010-09-30 + */ #include "config_speedtree.h" #include "speedTreeNode.h" @@ -30,7 +29,7 @@ ConfigureFn(config_speedtree) { } ConfigVariableString speedtree_license -("speedtree-license", "", +("speedtree-license", "", PRC_DESC("Specify the license string to pass to SpeedTreeNode::authorize() by default.")); #ifndef CPPPARSER @@ -196,7 +195,7 @@ ConfigVariableInt speedtree_terrain_resolution ("speedtree-terrain-resolution", 33, PRC_DESC("Specifies the number of vertices per edge of each terrain grid " "cell at the highest LOD. This must be a power of two plus 1.")); - + ConfigVariableInt speedtree_terrain_cell_size ("speedtree-terrain-cell-size", 800, PRC_DESC("Specifies the size in spatial units of one edge of a terrain " @@ -249,7 +248,7 @@ ConfigVariableInt speedtree_max_random_try_count "are deemed to be in error, and the function fails.")); ConfigVariableBool speedtree_5_2_stf -("speedtree-5-2-stf", +("speedtree-5-2-stf", #if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 2) true, #else @@ -258,16 +257,14 @@ ConfigVariableBool speedtree_5_2_stf PRC_DESC("The format of the STF file changed in SpeedTree version 5.2. " "Specify true here to read STF files in the new file format, or " "false to read STF files in the pre-5.2 file format.")); - -//////////////////////////////////////////////////////////////////// -// Function: init_libspeedtree -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// + +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libspeedtree() { static bool initialized = false; @@ -290,14 +287,14 @@ init_libspeedtree() { reg->register_type(new LoaderFileTypeStf); } -// We need a SpeedTree custom allocator to integrate with Panda's -// memory management. +// We need a SpeedTree custom allocator to integrate with Panda's memory +// management. class STCustomAllocator : public SpeedTree::CAllocator { public: void *Alloc(size_t block_size) { return PANDA_MALLOC_ARRAY(block_size); } - + void Free(void *block) { if (block != NULL) { PANDA_FREE_ARRAY(block); diff --git a/panda/src/speedtree/config_speedtree.h b/panda/src/speedtree/config_speedtree.h index 3d75e36a50..ab4c6bedaf 100644 --- a/panda/src/speedtree/config_speedtree.h +++ b/panda/src/speedtree/config_speedtree.h @@ -1,16 +1,15 @@ -// Filename: config_speedtree.h -// Created by: drose (30Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_speedtree.h + * @author drose + * @date 2010-09-30 + */ #ifndef CONFIG_SPEEDTREE_H #define CONFIG_SPEEDTREE_H @@ -77,5 +76,3 @@ extern ConfigVariableBool speedtree_5_2_stf; extern EXPCL_PANDASPEEDTREE void init_libspeedtree(); #endif - - diff --git a/panda/src/speedtree/loaderFileTypeSrt.cxx b/panda/src/speedtree/loaderFileTypeSrt.cxx index 662e151254..594267ec26 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.cxx +++ b/panda/src/speedtree/loaderFileTypeSrt.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeSrt.cxx -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeSrt.cxx + * @author drose + * @date 2010-10-06 + */ #include "loaderFileTypeSrt.h" #include "speedTreeNode.h" @@ -18,58 +17,46 @@ TypeHandle LoaderFileTypeSrt::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeSrt::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeSrt:: LoaderFileTypeSrt() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeSrt::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeSrt:: get_name() const { return "SpeedTree compiled tree"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeSrt::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeSrt:: get_extension() const { return "srt"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeSrt::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeSrt:: supports_compressed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeSrt::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeSrt:: -load_file(const Filename &path, const LoaderOptions &, +load_file(const Filename &path, const LoaderOptions &, BamCacheRecord *record) const { if (!path.is_regular_file()) { - // Quietly fail if the file doesn't exist. The Loader expects - // this. + // Quietly fail if the file doesn't exist. The Loader expects this. return NULL; } diff --git a/panda/src/speedtree/loaderFileTypeSrt.h b/panda/src/speedtree/loaderFileTypeSrt.h index 862fb60a04..6d26eeff6b 100644 --- a/panda/src/speedtree/loaderFileTypeSrt.h +++ b/panda/src/speedtree/loaderFileTypeSrt.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeSrt.h -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeSrt.h + * @author drose + * @date 2010-10-06 + */ #ifndef LOADERFILETYPESRT_H #define LOADERFILETYPESRT_H @@ -19,13 +18,11 @@ #include "loaderFileType.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeSrt -// Description : This defines the Loader interface to read SpeedTree -// SRT files, which describe a single tree. It actually -// returns a SpeedTreeNode with just a single tree -// within it. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to read SpeedTree SRT files, which + * describe a single tree. It actually returns a SpeedTreeNode with just a + * single tree within it. + */ class EXPCL_PANDASPEEDTREE LoaderFileTypeSrt : public LoaderFileType { public: LoaderFileTypeSrt(); @@ -56,4 +53,3 @@ private: }; #endif - diff --git a/panda/src/speedtree/loaderFileTypeStf.cxx b/panda/src/speedtree/loaderFileTypeStf.cxx index 948de63b31..7a8f71631d 100644 --- a/panda/src/speedtree/loaderFileTypeStf.cxx +++ b/panda/src/speedtree/loaderFileTypeStf.cxx @@ -1,74 +1,61 @@ -// Filename: loaderFileTypeStf.cxx -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeStf.cxx + * @author drose + * @date 2010-10-06 + */ #include "loaderFileTypeStf.h" #include "speedTreeNode.h" TypeHandle LoaderFileTypeStf::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeStf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeStf:: LoaderFileTypeStf() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeStf::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeStf:: get_name() const { return "SpeedTree compiled tree"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeStf::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeStf:: get_extension() const { return "stf"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeStf::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeStf:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeStf::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeStf:: -load_file(const Filename &path, const LoaderOptions &options, +load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { if (!path.is_regular_file()) { - // Quietly fail if the file doesn't exist. The Loader expects - // this. + // Quietly fail if the file doesn't exist. The Loader expects this. return NULL; } diff --git a/panda/src/speedtree/loaderFileTypeStf.h b/panda/src/speedtree/loaderFileTypeStf.h index 0b63d99687..8ea8eae575 100644 --- a/panda/src/speedtree/loaderFileTypeStf.h +++ b/panda/src/speedtree/loaderFileTypeStf.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeStf.h -// Created by: drose (07Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeStf.h + * @author drose + * @date 2010-10-07 + */ #ifndef LOADERFILETYPESTF_H #define LOADERFILETYPESTF_H @@ -19,12 +18,10 @@ #include "loaderFileType.h" -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeStf -// Description : This defines the Loader interface to read SpeedTree -// STF files--a simple text file that describes a forest -// of trees (references to SRT files). -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to read SpeedTree STF files--a simple + * text file that describes a forest of trees (references to SRT files). + */ class EXPCL_PANDASPEEDTREE LoaderFileTypeStf : public LoaderFileType { public: LoaderFileTypeStf(); @@ -55,4 +52,3 @@ private: }; #endif - diff --git a/panda/src/speedtree/speedTreeNode.I b/panda/src/speedtree/speedTreeNode.I index d8e1639f04..400a26e12b 100644 --- a/panda/src/speedtree/speedTreeNode.I +++ b/panda/src/speedtree/speedTreeNode.I @@ -1,50 +1,39 @@ -// Filename: speedTreeNode.I -// Created by: drose (30Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file speedTreeNode.I + * @author drose + * @date 2010-09-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::is_valid -// Access: Published -// Description: Returns true if the node is valid and ready to -// render, false otherwise. Note that this might not -// become false until after the first time the node is -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is valid and ready to render, false otherwise. + * Note that this might not become false until after the first time the node + * is rendered. + */ INLINE bool SpeedTreeNode:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_num_trees -// Access: Published -// Description: Returns the number of unique tree objects that have -// been added to the node. This count does not include -// multiple instances of the same tree that appear in -// different transforms. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique tree objects that have been added to the node. + * This count does not include multiple instances of the same tree that appear + * in different transforms. + */ INLINE int SpeedTreeNode:: get_num_trees() const { return (int)_trees.size(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_tree -// Access: Published -// Description: Returns the STTree pointer for the nth tree. -// See get_num_trees(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the STTree pointer for the nth tree. See get_num_trees(). + */ INLINE const STTree *SpeedTreeNode:: get_tree(int n) const { nassertr(n >= 0 && n < (int)_trees.size(), NULL); @@ -52,12 +41,10 @@ get_tree(int n) const { return instance_list->get_tree(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_instance_list -// Access: Published -// Description: Returns a list of transforms that corresponds to the -// instances at which the nth tree appears. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of transforms that corresponds to the instances at which the + * nth tree appears. + */ INLINE const SpeedTreeNode::InstanceList &SpeedTreeNode:: get_instance_list(int n) const { nassertr(n >= 0 && n < (int)_trees.size(), *(InstanceList *)NULL); @@ -65,12 +52,9 @@ get_instance_list(int n) const { return *instance_list; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::modify_tree -// Access: Published -// Description: Returns a modifiable STTree pointer for the nth tree -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable STTree pointer for the nth tree instance. + */ INLINE STTree *SpeedTreeNode:: modify_tree(int n) { nassertr(n >= 0 && n < (int)_trees.size(), NULL); @@ -79,182 +63,143 @@ modify_tree(int n) { return (STTree *)instance_list->get_tree(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::clear_terrain -// Access: Published -// Description: Removes the terrain associated with the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes the terrain associated with the node. + */ INLINE void SpeedTreeNode:: clear_terrain() { set_terrain(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::has_terrain -// Access: Published -// Description: Returns true if a valid terrain has been associated -// with the node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a valid terrain has been associated with the node, false + * otherwise. + */ INLINE bool SpeedTreeNode:: has_terrain() const { return _terrain != (STTerrain *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_terrain -// Access: Published -// Description: Returns the terrain associated with the node, or NULL -// if there is no terrain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the terrain associated with the node, or NULL if there is no + * terrain. + */ INLINE STTerrain *SpeedTreeNode:: get_terrain() const { return _terrain; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::set_time_delta -// Access: Published -// Description: Specifies an offset that is to be added each frame to -// the global clock's frame_time for the purpose of -// animating the trees in this particular node. Also -// see set_global_time_delta(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies an offset that is to be added each frame to the global clock's + * frame_time for the purpose of animating the trees in this particular node. + * Also see set_global_time_delta(). + */ INLINE void SpeedTreeNode:: set_time_delta(double delta) { _time_delta = delta; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_time_delta -// Access: Published -// Description: Returns an offset that is to be added each frame to -// the global clock's frame_time for the purpose of -// animating the trees in this particular node. Also -// see get_global_time_delta(). -//////////////////////////////////////////////////////////////////// +/** + * Returns an offset that is to be added each frame to the global clock's + * frame_time for the purpose of animating the trees in this particular node. + * Also see get_global_time_delta(). + */ INLINE double SpeedTreeNode:: get_time_delta() const { return _time_delta; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::set_global_time_delta -// Access: Published, Static -// Description: Specifies an offset that is to be added each frame to -// the global clock's frame_time for the purpose of -// animating the trees in all SpeedTreeNodes. Also -// see set_time_delta(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies an offset that is to be added each frame to the global clock's + * frame_time for the purpose of animating the trees in all SpeedTreeNodes. + * Also see set_time_delta(). + */ INLINE void SpeedTreeNode:: set_global_time_delta(double delta) { _global_time_delta = delta; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_global_time_delta -// Access: Published, Static -// Description: Returns an offset that is to be added each frame to -// the global clock's frame_time for the purpose of -// animating the trees in all SpeedTreeNodes. Also -// see get_time_delta(). -//////////////////////////////////////////////////////////////////// +/** + * Returns an offset that is to be added each frame to the global clock's + * frame_time for the purpose of animating the trees in all SpeedTreeNodes. + * Also see get_time_delta(). + */ INLINE double SpeedTreeNode:: get_global_time_delta() { return _global_time_delta; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SpeedTreeNode::InstanceList:: InstanceList(const STTree *tree) : _tree((STTree *)tree) { } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::operator < -// Access: Public -// Description: Used for comparison for ov_set. -//////////////////////////////////////////////////////////////////// +/** + * Used for comparison for ov_set. + */ INLINE bool SpeedTreeNode::InstanceList:: operator < (const InstanceList &other) const { return _tree < other._tree; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::get_tree -// Access: Published -// Description: Returns the particular tree this list refers to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular tree this list refers to. + */ INLINE const STTree *SpeedTreeNode::InstanceList:: get_tree() const { return _tree; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::get_num_instances -// Access: Published -// Description: Returns the number of instances of this tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of instances of this tree. + */ INLINE int SpeedTreeNode::InstanceList:: get_num_instances() const { return (int)_instances.size(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::get_instance -// Access: Published -// Description: Returns the transform of the nth instance of this -// tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform of the nth instance of this tree. + */ INLINE STTransform SpeedTreeNode::InstanceList:: get_instance(int n) const { nassertr(n >= 0 && n < (int)_instances.size(), STTransform::ident_mat()); return _instances[n]; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::set_instance -// Access: Published -// Description: Replaces the transform of the nth instance of this -// tree. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the transform of the nth instance of this tree. + */ INLINE void SpeedTreeNode::InstanceList:: set_instance(int n, const STTransform &transform) { nassertv(n >= 0 && n < (int)_instances.size()); _instances[n] = transform; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::add_instance -// Access: Published -// Description: Adds a new instance of this tree at the indicated -// transform. Returns the index number of the new -// instance. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new instance of this tree at the indicated transform. Returns the + * index number of the new instance. + */ INLINE int SpeedTreeNode::InstanceList:: add_instance(const STTransform &transform) { _instances.push_back(transform); return ((int)_instances.size() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::remove_instance -// Access: Published -// Description: Removes the nth instance of this tree. -//////////////////////////////////////////////////////////////////// +/** + * Removes the nth instance of this tree. + */ INLINE void SpeedTreeNode::InstanceList:: remove_instance(int n) { nassertv(n >= 0 && n < (int)_instances.size()); _instances.erase(_instances.begin() + n); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::DrawCallback::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SpeedTreeNode::DrawCallback:: DrawCallback(SpeedTreeNode *node) : _node(node) { } diff --git a/panda/src/speedtree/speedTreeNode.cxx b/panda/src/speedtree/speedTreeNode.cxx index c95cf43d42..61150a5a01 100644 --- a/panda/src/speedtree/speedTreeNode.cxx +++ b/panda/src/speedtree/speedTreeNode.cxx @@ -1,16 +1,15 @@ -// Filename: speedTreeNode.cxx -// Created by: drose (13Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file speedTreeNode.cxx + * @author drose + * @date 2009-03-13 + */ #include "pandabase.h" #include "speedTreeNode.h" @@ -59,28 +58,25 @@ PStatCollector SpeedTreeNode::_draw_speedtree_trees_pcollector("Draw:SpeedTree:T PStatCollector SpeedTreeNode::_draw_speedtree_terrain_pcollector("Draw:SpeedTree:Terrain"); PStatCollector SpeedTreeNode::_draw_speedtree_terrain_update_pcollector("Draw:SpeedTree:Terrain:Update"); -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SpeedTreeNode:: SpeedTreeNode(const string &name) : PandaNode(name), #ifdef ST_DELETE_FOREST_HACK - // Early versions of SpeedTree don't destruct unused CForestRender - // objects correctly. To avoid crashes, we have to leak these - // things. + // Early versions of SpeedTree don't destruct unused CForestRender objects + // correctly. To avoid crashes, we have to leak these things. _forest_render(*(new SpeedTree::CForestRender)), #endif _time_delta(0.0) { init_node(); - // For now, set an infinite bounding volume. Maybe in the future - // we'll change this to match whatever set of trees we're holding, - // though it probably doesn't really matter too much. - //set_internal_bounds(new OmniBoundingVolume); - // set_internal_bounds(new BoundingSphere(LPoint3::zero(), 10.0f)); + // For now, set an infinite bounding volume. Maybe in the future we'll + // change this to match whatever set of trees we're holding, though it + // probably doesn't really matter too much. set_internal_bounds(new + // OmniBoundingVolume); set_internal_bounds(new + // BoundingSphere(LPoint3::zero(), 10.0f)); // Intialize the render params. First, get the shader directory. Filename shaders_dir = speedtree_shaders_dir; @@ -126,13 +122,10 @@ SpeedTreeNode(const string &name) : reload_config(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::count_total_instances -// Access: Published -// Description: Returns the total number of trees that will be -// rendered by this node, counting all instances of all -// trees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of trees that will be rendered by this node, + * counting all instances of all trees. + */ int SpeedTreeNode:: count_total_instances() const { int total_instances = 0; @@ -145,14 +138,11 @@ count_total_instances() const { return total_instances; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_tree -// Access: Published -// Description: Adds a new tree for rendering. Returns the -// InstanceList which can be used to add to the -// instances for this tree. If the tree has previously -// been added, returns the existing InstanceList. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new tree for rendering. Returns the InstanceList which can be used + * to add to the instances for this tree. If the tree has previously been + * added, returns the existing InstanceList. + */ SpeedTreeNode::InstanceList &SpeedTreeNode:: add_tree(const STTree *tree) { nassertr(is_valid(), *(InstanceList *)NULL); @@ -161,8 +151,7 @@ add_tree(const STTree *tree) { InstanceList ilist(tree); Trees::iterator ti = _trees.find(&ilist); if (ti == _trees.end()) { - // This is the first time that this particular tree has been - // added. + // This is the first time that this particular tree has been added. InstanceList *instance_list = new InstanceList(tree); pair result = _trees.insert(instance_list); ti = result.first; @@ -182,12 +171,10 @@ add_tree(const STTree *tree) { return *instance_list; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::remove_tree -// Access: Published -// Description: Removes all instances of the indicated tree. Returns -// the number of instances removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all instances of the indicated tree. Returns the number of + * instances removed. + */ int SpeedTreeNode:: remove_tree(const STTree *tree) { InstanceList ilist(tree); @@ -214,11 +201,9 @@ remove_tree(const STTree *tree) { return num_removed; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::remove_all_trees -// Access: Published -// Description: Removes all instances of all trees from the node. -//////////////////////////////////////////////////////////////////// +/** + * Removes all instances of all trees from the node. + */ void SpeedTreeNode:: remove_all_trees() { Trees::iterator ti; @@ -238,12 +223,10 @@ remove_all_trees() { mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::has_instance_list -// Access: Published -// Description: Returns true if the indicated tree has any instances -// within this node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated tree has any instances within this node, + * false otherwise. + */ bool SpeedTreeNode:: has_instance_list(const STTree *tree) const { InstanceList ilist(tree); @@ -251,14 +234,11 @@ has_instance_list(const STTree *tree) const { return (ti != _trees.end()); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::get_instance_list -// Access: Published -// Description: Returns a list of transforms that corresponds to the -// instances at which the indicated tree appears. You -// should ensure that has_instance_list() returns true -// before calling this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns a list of transforms that corresponds to the instances at which the + * indicated tree appears. You should ensure that has_instance_list() returns + * true before calling this method. + */ const SpeedTreeNode::InstanceList &SpeedTreeNode:: get_instance_list(const STTree *tree) const { InstanceList ilist(tree); @@ -273,24 +253,18 @@ get_instance_list(const STTree *tree) const { return *instance_list; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::modify_instance_list -// Access: Published -// Description: Returns a modifiable list of transforms that -// corresponds to the instances of this tree. This is -// equivalent to add_tree(). -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable list of transforms that corresponds to the instances + * of this tree. This is equivalent to add_tree(). + */ SpeedTreeNode::InstanceList &SpeedTreeNode:: modify_instance_list(const STTree *tree) { return add_tree(tree); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_instance -// Access: Published -// Description: Adds a new instance of the indicated tree at the -// indicated transform. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new instance of the indicated tree at the indicated transform. + */ void SpeedTreeNode:: add_instance(const STTree *tree, const STTransform &transform) { if (speedtree_follow_terrain && has_terrain()) { @@ -302,15 +276,12 @@ add_instance(const STTree *tree, const STTransform &transform) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_instances -// Access: Published -// Description: Walks the scene graph beginning at root, looking for -// nested SpeedTreeNodes. For each SpeedTreeNode found, -// adds all of the instances defined within that -// SpeedTreeNode as instances of this node, after -// applying the indicated scene-graph transform. -//////////////////////////////////////////////////////////////////// +/** + * Walks the scene graph beginning at root, looking for nested SpeedTreeNodes. + * For each SpeedTreeNode found, adds all of the instances defined within that + * SpeedTreeNode as instances of this node, after applying the indicated + * scene-graph transform. + */ void SpeedTreeNode:: add_instances(const NodePath &root, const TransformState *transform) { nassertv(!root.is_empty()); @@ -318,13 +289,10 @@ add_instances(const NodePath &root, const TransformState *transform) { Thread::get_current_thread()); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_instances_from -// Access: Published -// Description: Adds all of the instances defined within the -// indicated SpeedTreeNode as instances of this node. -// Does not recurse to children. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the instances defined within the indicated SpeedTreeNode as + * instances of this node. Does not recurse to children. + */ void SpeedTreeNode:: add_instances_from(const SpeedTreeNode *other) { int num_trees = other->get_num_trees(); @@ -341,14 +309,11 @@ add_instances_from(const SpeedTreeNode *other) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_instances_from -// Access: Published -// Description: Adds all of the instances defined within the -// indicated SpeedTreeNode as instances of this node, -// after applying the indicated scene-graph transform. -// Does not recurse to children. -//////////////////////////////////////////////////////////////////// +/** + * Adds all of the instances defined within the indicated SpeedTreeNode as + * instances of this node, after applying the indicated scene-graph transform. + * Does not recurse to children. + */ void SpeedTreeNode:: add_instances_from(const SpeedTreeNode *other, const TransformState *transform) { int num_trees = other->get_num_trees(); @@ -374,19 +339,15 @@ add_instances_from(const SpeedTreeNode *other, const TransformState *transform) } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_random_instances -// Access: Published -// Description: Creates a number of random instances of the indicated -// true, within the indicated range. If a terrain is -// present, height_min and height_max restrict trees to -// the (x, y) positions that fall within the indicated -// terrain, and slope_min and slope_max restrict trees -// to the (x, y) positions that have a matching slope. -// If a terrain is not present, height_min and -// height_max specify a random range of Z heights, and -// slope_min and slope_max are ignored. -//////////////////////////////////////////////////////////////////// +/** + * Creates a number of random instances of the indicated true, within the + * indicated range. If a terrain is present, height_min and height_max + * restrict trees to the (x, y) positions that fall within the indicated + * terrain, and slope_min and slope_max restrict trees to the (x, y) positions + * that have a matching slope. If a terrain is not present, height_min and + * height_max specify a random range of Z heights, and slope_min and slope_max + * are ignored. + */ void SpeedTreeNode:: add_random_instances(const STTree *tree, int quantity, PN_stdfloat x_min, PN_stdfloat x_max, @@ -426,14 +387,11 @@ add_random_instances(const STTree *tree, int quantity, } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_from_stf -// Access: Published -// Description: Opens and reads the named STF (SpeedTree Forest) -// file, and adds the SRT files named within as -// instances of this node. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens and reads the named STF (SpeedTree Forest) file, and adds the SRT + * files named within as instances of this node. Returns true on success, + * false on failure. + */ bool SpeedTreeNode:: add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -467,22 +425,17 @@ add_from_stf(const Filename &stf_filename, const LoaderOptions &options) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_from_stf -// Access: Published -// Description: Reads text data from the indicated stream, which is -// understood to represent the named STF (SpeedTree -// Forest) file, and adds the SRT files named within as -// instances of this node. Returns true on success, -// false on failure. -// -// The pathname is used for reference only; if nonempty, -// it provides a search directory for named SRT files. -// -// The Loader and LoaderOptions, if provided, are used -// to load the SRT files. If the Loader pointer is -// NULL, the default global Loader is used instead. -//////////////////////////////////////////////////////////////////// +/** + * Reads text data from the indicated stream, which is understood to represent + * the named STF (SpeedTree Forest) file, and adds the SRT files named within + * as instances of this node. Returns true on success, false on failure. + * + * The pathname is used for reference only; if nonempty, it provides a search + * directory for named SRT files. + * + * The Loader and LoaderOptions, if provided, are used to load the SRT files. + * If the Loader pointer is NULL, the default global Loader is used instead. + */ bool SpeedTreeNode:: add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options, Loader *loader) { @@ -511,8 +464,8 @@ add_from_stf(istream &in, const Filename &pathname, // Resolve the SRT filename relative to the STF file first. srt_filename.resolve_filename(search); - // Now load up the SRT file using the Panda loader (which will - // also search the model-path if necessary). + // Now load up the SRT file using the Panda loader (which will also + // search the model-path if necessary). PT(PandaNode) srt_root = loader->load_sync(srt_filename); if (srt_root != NULL) { @@ -528,8 +481,8 @@ add_from_stf(istream &in, const Filename &pathname, already_loaded[srt_filename] = tree; } - // Now we've loaded the SRT data, so apply it the appropriate - // number of times to the locations specified. + // Now we've loaded the SRT data, so apply it the appropriate number of + // times to the locations specified. int num_instances; in >> num_instances; for (int ni = 0; ni < num_instances && in && !in.eof(); ++ni) { @@ -538,8 +491,8 @@ add_from_stf(istream &in, const Filename &pathname, in >> pos[0] >> pos[1] >> pos[2] >> rotate >> scale; if (!speedtree_5_2_stf) { - // 5.1 or earlier stf files also included these additional - // values, which we will ignore: + // 5.1 or earlier stf files also included these additional values, + // which we will ignore: PN_stdfloat height_min, height_max, slope_min, slope_max; in >> height_min >> height_max >> slope_min >> slope_max; } @@ -555,8 +508,7 @@ add_from_stf(istream &in, const Filename &pathname, in >> ws; if (!in.eof()) { - // If we didn't read all the way to end-of-file, there was an - // error. + // If we didn't read all the way to end-of-file, there was an error. in.clear(); string text; in >> text; @@ -569,18 +521,15 @@ add_from_stf(istream &in, const Filename &pathname, return true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::setup_terrain -// Access: Published -// Description: A convenience function to set up terrain geometry by -// reading a terrain.txt file as defined by SpeedTree. -// This file names the various map files that define the -// terrain, as well as defining parameters size as its -// size and color. -// -// This method implicitly creates a STBasicTerrain -// object and passes it to set_terrain(). -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to set up terrain geometry by reading a terrain.txt + * file as defined by SpeedTree. This file names the various map files that + * define the terrain, as well as defining parameters size as its size and + * color. + * + * This method implicitly creates a STBasicTerrain object and passes it to + * set_terrain(). + */ bool SpeedTreeNode:: setup_terrain(const Filename &terrain_file) { PT(STBasicTerrain) terrain = new STBasicTerrain; @@ -592,17 +541,13 @@ setup_terrain(const Filename &terrain_file) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::set_terrain -// Access: Published -// Description: Associated a terrain with the node. If the terrain -// has not already been loaded prior to this call, -// load_data() will be called immediately. -// -// The terrain will be rendered using SpeedTree -// callbacks, and trees may be repositioned with a call -// to snap_to_terrain(). -//////////////////////////////////////////////////////////////////// +/** + * Associated a terrain with the node. If the terrain has not already been + * loaded prior to this call, load_data() will be called immediately. + * + * The terrain will be rendered using SpeedTree callbacks, and trees may be + * repositioned with a call to snap_to_terrain(). + */ void SpeedTreeNode:: set_terrain(STTerrain *terrain) { _terrain = NULL; @@ -650,13 +595,10 @@ set_terrain(STTerrain *terrain) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::snap_to_terrain -// Access: Published -// Description: Adjusts all the trees in this node so that their Z -// position matches the height of the terrain at their -// X, Y position. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts all the trees in this node so that their Z position matches the + * height of the terrain at their X, Y position. + */ void SpeedTreeNode:: snap_to_terrain() { Trees::iterator ti; @@ -686,14 +628,11 @@ snap_to_terrain() { _needs_repopulate = true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::reload_config -// Access: Published -// Description: Re-reads the current setting of all of the relevant -// config variables and applies them to this node. This -// can be called after changing config settings, to make -// them apply to this particular node. -//////////////////////////////////////////////////////////////////// +/** + * Re-reads the current setting of all of the relevant config variables and + * applies them to this node. This can be called after changing config + * settings, to make them apply to this particular node. + */ void SpeedTreeNode:: reload_config() { @@ -754,29 +693,23 @@ reload_config() { _needs_repopulate = true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::set_wind -// Access: Published -// Description: Specifies the overall wind strength and direction. -// Gusts are controlled internally. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the overall wind strength and direction. Gusts are controlled + * internally. + */ void SpeedTreeNode:: set_wind(double strength, const LVector3 &direction) { _forest_render.SetGlobalWindStrength(strength); _forest_render.SetGlobalWindDirection(SpeedTree::Vec3(direction[0], direction[1], direction[2])); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::authorize -// Access: Published, Static -// Description: Make this call to initialized the SpeedTree API and -// verify the license. If an empty string is passed for -// the license, the config variable speedtree-license is -// consulted. Returns true on success, false on -// failure. If this call is not made explicitly, it -// will be made implicitly the first time a -// SpeedTreeNode is created. -//////////////////////////////////////////////////////////////////// +/** + * Make this call to initialized the SpeedTree API and verify the license. If + * an empty string is passed for the license, the config variable speedtree- + * license is consulted. Returns true on success, false on failure. If this + * call is not made explicitly, it will be made implicitly the first time a + * SpeedTreeNode is created. + */ bool SpeedTreeNode:: authorize(const string &license) { if (!_authorized) { @@ -796,20 +729,17 @@ authorize(const string &license) { return _authorized; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SpeedTreeNode:: SpeedTreeNode(const SpeedTreeNode ©) : PandaNode(copy), _os_shaders_dir(copy._os_shaders_dir), _shadow_infos(copy._shadow_infos), #ifdef ST_DELETE_FOREST_HACK - // Early versions of SpeedTree don't destruct unused CForestRender - // objects correctly. To avoid crashes, we have to leak these - // things. + // Early versions of SpeedTree don't destruct unused CForestRender objects + // correctly. To avoid crashes, we have to leak these things. _forest_render(*(new SpeedTree::CForestRender)), #endif _time_delta(copy._time_delta) @@ -845,11 +775,9 @@ SpeedTreeNode(const SpeedTreeNode ©) : mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SpeedTreeNode:: ~SpeedTreeNode() { remove_all_trees(); @@ -857,40 +785,32 @@ SpeedTreeNode:: _forest_render.ClearInstances(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *SpeedTreeNode:: make_copy() const { return new SpeedTreeNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::combine_with -// Access: Public, Virtual -// Description: Collapses this node with the other node, if possible, -// and returns a pointer to the combined node, or NULL -// if the two nodes cannot safely be combined. -// -// The return value may be this, other, or a new node -// altogether. -// -// This function is called from GraphReducer::flatten(), -// and need not deal with children; its job is just to -// decide whether to collapse the two nodes and what the -// collapsed node should look like. -//////////////////////////////////////////////////////////////////// +/** + * Collapses this node with the other node, if possible, and returns a pointer + * to the combined node, or NULL if the two nodes cannot safely be combined. + * + * The return value may be this, other, or a new node altogether. + * + * This function is called from GraphReducer::flatten(), and need not deal + * with children; its job is just to decide whether to collapse the two nodes + * and what the collapsed node should look like. + */ PandaNode *SpeedTreeNode:: combine_with(PandaNode *other) { if (is_exact_type(get_class_type()) && other->is_exact_type(get_class_type())) { - // Two SpeedTreeNodes can combine by moving trees from one to the - // other, similar to the way GeomNodes combine. + // Two SpeedTreeNodes can combine by moving trees from one to the other, + // similar to the way GeomNodes combine. SpeedTreeNode *gother = DCAST(SpeedTreeNode, other); // But, not if they both have a terrain set. @@ -908,18 +828,15 @@ combine_with(PandaNode *other) { return PandaNode::combine_with(other); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::apply_attribs_to_vertices -// Access: Public, Virtual -// Description: Applies whatever attributes are specified in the -// AccumulatedAttribs object (and by the attrib_types -// bitmask) to the vertices on this node, if -// appropriate. If this node uses geom arrays like a -// GeomNode, the supplied GeomTransformer may be used to -// unify shared arrays across multiple different nodes. -// -// This is a generalization of xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ void SpeedTreeNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -939,31 +856,24 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::cull_callback -// Access: Public, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool SpeedTreeNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { if (!_is_valid) { @@ -981,8 +891,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { _forest_render.SetGlobalTime(clock->get_frame_time() + _time_delta + _global_time_delta); _forest_render.AdvanceGlobalWind(); - // Compute the modelview and camera transforms, to pass to the - // SpeedTree CView structure. + // Compute the modelview and camera transforms, to pass to the SpeedTree + // CView structure. CPT(TransformState) orig_modelview = data.get_modelview_transform(trav); CPT(TransformState) modelview = trav->get_scene()->get_cs_transform()->compose(orig_modelview); CPT(TransformState) camera_transform = modelview->invert_compose(TransformState::make_identity()); @@ -1002,8 +912,8 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { // Convert the render state to SpeedTree's input. const RenderState *state = data._state; - // Check texture state. If all textures are disabled, then we ask - // SpeedTree to disable textures. + // Check texture state. If all textures are disabled, then we ask SpeedTree + // to disable textures. bool show_textures = true; const TextureAttrib *ta = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_slot())); if (ta != (TextureAttrib *)NULL) { @@ -1012,10 +922,10 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { _forest_render.EnableTexturing(show_textures); _terrain_render.EnableTexturing(show_textures); - // Check lighting state. SpeedTree only supports a single - // directional light; we look for a directional light in the - // lighting state and pass its direction and color to SpeedTree. We - // also accumulate the ambient light colors. + // Check lighting state. SpeedTree only supports a single directional + // light; we look for a directional light in the lighting state and pass its + // direction and color to SpeedTree. We also accumulate the ambient light + // colors. LColor ambient_color(0.0f, 0.0f, 0.0f, 0.0f); DirectionalLight *dlight = NULL; NodePath dlight_np; @@ -1050,13 +960,11 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { diffuse_color = dlight->get_color(); } else { - // No light. But there's no way to turn off lighting in - // SpeedTree. In lieu of this, we just shine a light from - // above. + // No light. But there's no way to turn off lighting in SpeedTree. In + // lieu of this, we just shine a light from above. _light_dir = SpeedTree::Vec3(0.0, 0.0, -1.0); - // Also, we set ambient and diffuse colors to the same full-white - // value. + // Also, we set ambient and diffuse colors to the same full-white value. ambient_color.set(1.0f, 1.0f, 1.0f, 1.0f); diffuse_color.set(1.0f, 1.0f, 1.0f, 1.0f); } @@ -1078,10 +986,9 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { _forest_render.SetShadowFadePercentage(speedtree_shadow_fade); if (!_needs_repopulate) { - // Don't bother culling now unless we're correctly fully - // populated. (Culling won't be accurate unless the forest has - // been populated, but we have to be in the draw traversal to - // populate.) + // Don't bother culling now unless we're correctly fully populated. + // (Culling won't be accurate unless the forest has been populated, but we + // have to be in the draw traversal to populate.) cull_forest(); } @@ -1089,35 +996,28 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool SpeedTreeNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::add_for_draw -// Access: Public, Virtual -// Description: Adds the node's contents to the CullResult we are -// building up during the cull traversal, so that it -// will be drawn at render time. For most nodes other -// than GeomNodes, this is a do-nothing operation. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node's contents to the CullResult we are building up during the + * cull traversal, so that it will be drawn at render time. For most nodes + * other than GeomNodes, this is a do-nothing operation. + */ void SpeedTreeNode:: add_for_draw(CullTraverser *trav, CullTraverserData &data) { if (_is_valid) { - // We create a CullableObject that has an explicit draw_callback - // into this node, so that we can make the appropriate calls into - // SpeedTree to render the forest during the actual draw. + // We create a CullableObject that has an explicit draw_callback into this + // node, so that we can make the appropriate calls into SpeedTree to + // render the forest during the actual draw. CullableObject *object = new CullableObject(NULL, data._state, TransformState::make_identity()); @@ -1126,21 +1026,16 @@ add_for_draw(CullTraverser *trav, CullTraverserData &data) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::prepare_scene -// Access: Published -// Description: Walks through the scene graph beginning at this node, -// and does whatever initialization is required to -// render the scene properly with the indicated GSG. It -// is not strictly necessary to call this, since the GSG -// will initialize itself when the scene is rendered, -// but this may take some of the overhead away from that -// process. -// -// In particular, this will ensure that textures within -// the scene are loaded in texture memory, and display -// lists are built up from static geometry. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the scene graph beginning at this node, and does whatever + * initialization is required to render the scene properly with the indicated + * GSG. It is not strictly necessary to call this, since the GSG will + * initialize itself when the scene is rendered, but this may take some of the + * overhead away from that process. + * + * In particular, this will ensure that textures within the scene are loaded + * in texture memory, and display lists are built up from static geometry. + */ void SpeedTreeNode:: prepare_scene(GraphicsStateGuardianBase *gsgbase, const RenderState *) { GraphicsStateGuardian *gsg = DCAST(GraphicsStateGuardian, gsgbase); @@ -1149,14 +1044,11 @@ prepare_scene(GraphicsStateGuardianBase *gsgbase, const RenderState *) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Returns a newly-allocated BoundingVolume that -// represents the internal contents of the node. Should -// be overridden by PandaNode classes that contain -// something internally. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated BoundingVolume that represents the internal + * contents of the node. Should be overridden by PandaNode classes that + * contain something internally. + */ void SpeedTreeNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -1187,14 +1079,11 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, LPoint3(emax[0], emax[1], emax[2])); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::output -// Access: Public, Virtual -// Description: Writes a brief description of the node to the -// indicated output stream. This is invoked by the << -// operator. It may be overridden in derived classes to -// include some information relevant to the class. -//////////////////////////////////////////////////////////////////// +/** + * Writes a brief description of the node to the indicated output stream. + * This is invoked by the << operator. It may be overridden in derived + * classes to include some information relevant to the class. + */ void SpeedTreeNode:: output(ostream &out) const { PandaNode::output(out); @@ -1203,11 +1092,9 @@ output(ostream &out) const { << count_total_instances() << " total instances)"; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SpeedTreeNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); @@ -1224,12 +1111,9 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::write_error -// Access: Public, Static -// Description: Writes the current SpeedTree error message to the -// indicated stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the current SpeedTree error message to the indicated stream. + */ void SpeedTreeNode:: write_error(ostream &out) { const char *error = SpeedTree::CCore::GetError(); @@ -1239,16 +1123,13 @@ write_error(ostream &out) { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::set_transparent_texture_mode -// Access: Protected -// Description: Uses SpeedTree::CRenderState to set the indicated -// transparency mode. -//////////////////////////////////////////////////////////////////// +/** + * Uses SpeedTree::CRenderState to set the indicated transparency mode. + */ void SpeedTreeNode:: set_transparent_texture_mode(SpeedTree::ETextureAlphaRenderMode eMode) const { - // turn all modes off (no telling what render state the client - // application might be in before this call) + // turn all modes off (no telling what render state the client application + // might be in before this call) SpeedTree::CRenderState::SetBlending(false); SpeedTree::CRenderState::SetAlphaTesting(false); SpeedTree::CRenderState::SetAlphaToCoverage(false); @@ -1269,12 +1150,9 @@ set_transparent_texture_mode(SpeedTree::ETextureAlphaRenderMode eMode) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::init_node -// Access: Private -// Description: Called from the constructor to initialize some -// internal values. -//////////////////////////////////////////////////////////////////// +/** + * Called from the constructor to initialize some internal values. + */ void SpeedTreeNode:: init_node() { PandaNode::set_cull_callback(); @@ -1295,16 +1173,14 @@ init_node() { _forest_render.SetCullCellSize(speedtree_cull_cell_size); // Doesn't appear to be necessary to call this explicitly. - //_forest_render.EnableWind(true); + // _forest_render.EnableWind(true); _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::r_add_instances -// Access: Private -// Description: The recursive implementation of add_instances(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of add_instances(). + */ void SpeedTreeNode:: r_add_instances(PandaNode *node, const TransformState *transform, Thread *current_thread) { @@ -1322,12 +1198,9 @@ r_add_instances(PandaNode *node, const TransformState *transform, } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::repopulate -// Access: Private -// Description: Rebuilds the internal structures as necessary for -// rendering. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the internal structures as necessary for rendering. + */ void SpeedTreeNode:: repopulate() { _forest_render.ClearInstances(); @@ -1338,10 +1211,10 @@ repopulate() { const STTree *tree = instance_list->get_tree(); const STInstances &instances = instance_list->_instances; if (instances.empty()) { - // There are no instances, so don't bother. (This shouldn't - // happen often, because we remove trees from the SpeedTreeNode - // when their instance list goes empty, though it's possible if - // the user has explicitly removed all of the instances.) + // There are no instances, so don't bother. (This shouldn't happen + // often, because we remove trees from the SpeedTreeNode when their + // instance list goes empty, though it's possible if the user has + // explicitly removed all of the instances.) continue; } @@ -1383,12 +1256,9 @@ repopulate() { speedtree_horizontal_billboards); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::update_terrain_cells -// Access: Private -// Description: Called once a frame to load vertex data for -// newly-visible terrain cells. -//////////////////////////////////////////////////////////////////// +/** + * Called once a frame to load vertex data for newly-visible terrain cells. + */ void SpeedTreeNode:: update_terrain_cells() { nassertv(has_terrain()); @@ -1412,7 +1282,7 @@ update_terrain_cells() { nassertv(cell != NULL && cell->GetVbo() != NULL); int cell_yi = cell->Row(); int cell_xi = cell->Col(); - //cerr << "populating cell " << cell_xi << " " << cell_yi << "\n"; + // cerr << "populating cell " << cell_xi << " " << cell_yi << "\n"; _terrain->fill_vertices(vertex_data, cell_xi * cell_size, cell_yi * cell_size, @@ -1429,13 +1299,10 @@ update_terrain_cells() { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::validate_api -// Access: Private -// Description: Returns true if the indicated GSG shares the -// appropriate API for this SpeedTreeNode, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated GSG shares the appropriate API for this + * SpeedTreeNode, false otherwise. + */ bool SpeedTreeNode:: validate_api(GraphicsStateGuardian *gsg) { GraphicsPipe *pipe = gsg->get_pipe(); @@ -1461,14 +1328,11 @@ validate_api(GraphicsStateGuardian *gsg) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::draw_callback -// Access: Private -// Description: Called when the node is visited during the draw -// traversal, by virtue of our DrawCallback construct. -// This makes the calls into SpeedTree to perform the -// actual rendering. -//////////////////////////////////////////////////////////////////// +/** + * Called when the node is visited during the draw traversal, by virtue of our + * DrawCallback construct. This makes the calls into SpeedTree to perform the + * actual rendering. + */ void SpeedTreeNode:: draw_callback(CallbackData *data) { PStatTimer timer(_draw_speedtree_pcollector); @@ -1486,9 +1350,8 @@ draw_callback(CallbackData *data) { _forest_render.StartRender(); if (_forest_render.ShadowsAreEnabled()) { - // Update the shadow maps. TODO: consider updating these only - // every once in a while, instead of every frame, as a simple - // optimization. + // Update the shadow maps. TODO: consider updating these only every once + // in a while, instead of every frame, as a simple optimization. PStatTimer timer(_draw_speedtree_shadows_pcollector); render_forest_into_shadow_maps(); _forest_render.ClearBoundTextures( ); @@ -1530,10 +1393,12 @@ draw_callback(CallbackData *data) { // Now draw the actual trees. PStatTimer timer1(_draw_speedtree_trees_pcollector); - // SpeedTree::ETextureAlphaRenderMode mode = SpeedTree::TRANS_TEXTURE_ALPHA_TESTING; + // SpeedTree::ETextureAlphaRenderMode mode = + // SpeedTree::TRANS_TEXTURE_ALPHA_TESTING; SpeedTree::ETextureAlphaRenderMode mode = SpeedTree::TRANS_TEXTURE_ALPHA_TO_COVERAGE; - //SpeedTree::ETextureAlphaRenderMode mode = SpeedTree::TRANS_TEXTURE_BLENDING; - //SpeedTree::ETextureAlphaRenderMode mode = SpeedTree::TRANS_TEXTURE_NOTHING; + // SpeedTree::ETextureAlphaRenderMode mode = + // SpeedTree::TRANS_TEXTURE_BLENDING; SpeedTree::ETextureAlphaRenderMode + // mode = SpeedTree::TRANS_TEXTURE_NOTHING; set_transparent_texture_mode(SpeedTree::ETextureAlphaRenderMode(mode)); bool branches = _forest_render.RenderBranches(_visible_trees, SpeedTree::RENDER_PASS_STANDARD); @@ -1543,9 +1408,8 @@ draw_callback(CallbackData *data) { bool billboards = _forest_render.RenderBillboards(_visible_trees, SpeedTree::RENDER_PASS_STANDARD, _view); // Sometimes billboards comes back false, particularly if wind is - // disabled; but the billboards appear to have been rendered - // successfully. Weird. Just removing this test from the - // condition. + // disabled; but the billboards appear to have been rendered successfully. + // Weird. Just removing this test from the condition. if (!branches || !fronds || !leaf_meshes || !leaf_cards /* || !billboards */) { speedtree_cat.warning() @@ -1561,18 +1425,16 @@ draw_callback(CallbackData *data) { _forest_render.RenderOverlays(); } - // SpeedTree leaves the graphics state indeterminate. Make sure - // Panda doesn't rely on anything in the state. + // SpeedTree leaves the graphics state indeterminate. Make sure Panda + // doesn't rely on anything in the state. geom_cbdata->set_lost_state(true); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::render_forest_into_shadow_maps -// Access: Private -// Description: Renders the forest from the point of view of the -// light, to fill up the shadow map(s). -//////////////////////////////////////////////////////////////////// +/** + * Renders the forest from the point of view of the light, to fill up the + * shadow map(s). + */ void SpeedTreeNode:: render_forest_into_shadow_maps() { bool success = true; @@ -1582,8 +1444,7 @@ render_forest_into_shadow_maps() { SpeedTree::CRenderState::SetAlphaToCoverage(false); #if defined(SPEEDTREE_OPENGL) - // Ensure the viewport is not constrained. SpeedTree doesn't expect - // that. + // Ensure the viewport is not constrained. SpeedTree doesn't expect that. glDisable(GL_SCISSOR_TEST); #endif @@ -1594,28 +1455,28 @@ render_forest_into_shadow_maps() { if (_forest_render.BeginShadowMap(smi, light_view)) { success &= _forest_render.UploadViewShaderParameters(light_view); - // branch geometry can be rendered with backfacing triangle - // removed, so a closer tolerance can be used + // branch geometry can be rendered with backfacing triangle removed, so + // a closer tolerance can be used SpeedTree::CRenderState::SetPolygonOffset(1.0f, 0.125f); success &= _forest_render.RenderBranches(light_cull, SpeedTree::RENDER_PASS_SHADOW); - // the remaining geometry types cannot be backface culled, so we - // need a much more aggressive offset + // the remaining geometry types cannot be backface culled, so we need a + // much more aggressive offset SpeedTree::CRenderState::SetPolygonOffset(10.0f, 1.0f); success &= _forest_render.RenderFronds(light_cull, SpeedTree::RENDER_PASS_SHADOW); success &= _forest_render.RenderLeafMeshes(light_cull, SpeedTree::RENDER_PASS_SHADOW); success &= _forest_render.RenderLeafCards(light_cull, SpeedTree::RENDER_PASS_SHADOW, light_view); - // We don't bother to render billboard geometry into the shadow - // map(s). + // We don't bother to render billboard geometry into the shadow map(s). success &= _forest_render.EndShadowMap(smi); } } - // SpeedTree::CRenderState::SetMultisampling(m_sUserSettings.m_nSampleCount > 0); + // SpeedTree::CRenderState::SetMultisampling(m_sUserSettings.m_nSampleCount + // > 0); if (!success) { speedtree_cat.warning() @@ -1624,24 +1485,21 @@ render_forest_into_shadow_maps() { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::setup_for_render -// Access: Private -// Description: Does whatever calls are necessary to set up the -// forest for rendering--create vbuffers, load shaders, -// and whatnot. Primarily, this is the calls to -// InitTreeGraphics and the like. -//////////////////////////////////////////////////////////////////// +/** + * Does whatever calls are necessary to set up the forest for rendering-- + * create vbuffers, load shaders, and whatnot. Primarily, this is the calls + * to InitTreeGraphics and the like. + */ void SpeedTreeNode:: setup_for_render(GraphicsStateGuardian *gsg) { if (!_done_first_init) { - // This is the first time we have entered the draw callback since - // creating any SpeedTreeNode. Now we have an opportunity to do - // any initial setup that requires a graphics context. + // This is the first time we have entered the draw callback since creating + // any SpeedTreeNode. Now we have an opportunity to do any initial setup + // that requires a graphics context. #ifdef SPEEDTREE_OPENGL - // For OpenGL, we have to ensure GLEW has been initialized. - // (SpeedTree uses it, though Panda doesn't.) + // For OpenGL, we have to ensure GLEW has been initialized. (SpeedTree + // uses it, though Panda doesn't.) GLenum err = glewInit(); if (err != GLEW_OK) { speedtree_cat.error() @@ -1651,8 +1509,8 @@ setup_for_render(GraphicsStateGuardian *gsg) { return; } - // Insist that OpenGL 2.0 is available as the SpeedTree renderer - // requires it. + // Insist that OpenGL 2.0 is available as the SpeedTree renderer requires + // it. if (!GLEW_VERSION_2_0) { speedtree_cat.error() << "The SpeedTree OpenGL implementation requires OpenGL 2.0 or better to run; this system has version " << glGetString(GL_VERSION) << "\n"; @@ -1694,7 +1552,8 @@ setup_for_render(GraphicsStateGuardian *gsg) { string os_textures_dir; if (!speedtree_textures_dir.empty()) { os_textures_dir = speedtree_textures_dir.get_value().to_os_specific(); - // Ensure the path ends with a terminal slash; SpeedTree requires this. + // Ensure the path ends with a terminal slash; SpeedTree requires + // this. #if defined(WIN32) || defined(WIN64) if (!os_textures_dir.empty() && os_textures_dir[os_textures_dir.length() - 1] != '\\') { os_textures_dir += "\\"; @@ -1726,9 +1585,8 @@ setup_for_render(GraphicsStateGuardian *gsg) { return; } - // This call apparently must be made at draw time, not earlier, - // because it might attempt to create OpenGL index buffers and - // such. + // This call apparently must be made at draw time, not earlier, because it + // might attempt to create OpenGL index buffers and such. _forest_render.UpdateTreeCellExtents(); if (has_terrain()) { @@ -1754,12 +1612,9 @@ setup_for_render(GraphicsStateGuardian *gsg) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::cull_forest -// Access: Private -// Description: Calls the SpeedTree methods to perform the needed -// cull calculations. -//////////////////////////////////////////////////////////////////// +/** + * Calls the SpeedTree methods to perform the needed cull calculations. + */ void SpeedTreeNode:: cull_forest() { { @@ -1788,11 +1643,9 @@ cull_forest() { } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::print_forest_stats -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SpeedTreeNode:: print_forest_stats(const SpeedTree::CForest::SPopulationStats &forest_stats) const { fprintf(stderr, "\n Forest Population Statistics\n"); @@ -1812,23 +1665,18 @@ print_forest_stats(const SpeedTree::CForest::SPopulationStats &forest_stats) con fprintf(stderr, "\n"); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::register_with_read_factory -// Access: Public, Static -// Description: Tells the BamReader how to create objects of type -// SpeedTreeNode. -//////////////////////////////////////////////////////////////////// +/** + * Tells the BamReader how to create objects of type SpeedTreeNode. + */ void SpeedTreeNode:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::write_datagram -// Access: Public, Virtual -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SpeedTreeNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); @@ -1842,14 +1690,11 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::make_from_bam -// Access: Protected, Static -// Description: This function is called by the BamReader's factory -// when a new object of type SpeedTreeNode is encountered -// in the Bam file. It should create the SpeedTreeNode -// and extract its information from the file. -//////////////////////////////////////////////////////////////////// +/** + * This function is called by the BamReader's factory when a new object of + * type SpeedTreeNode is encountered in the Bam file. It should create the + * SpeedTreeNode and extract its information from the file. + */ TypedWritable *SpeedTreeNode:: make_from_bam(const FactoryParams ¶ms) { SpeedTreeNode *node = new SpeedTreeNode(""); @@ -1862,13 +1707,10 @@ make_from_bam(const FactoryParams ¶ms) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::fillin -// Access: Protected -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SpeedTreeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SpeedTreeNode. + */ void SpeedTreeNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); @@ -1889,21 +1731,17 @@ fillin(DatagramIterator &scan, BamReader *manager) { _trees.sort(); } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SpeedTreeNode::InstanceList:: output(ostream &out) const { out << *_tree << ": " << _instances.size() << " instances"; } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SpeedTreeNode::InstanceList:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -1915,12 +1753,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void SpeedTreeNode::InstanceList:: write_datagram(BamWriter *manager, Datagram &dg) { // Compute the relative pathname to the SRT file. @@ -1947,20 +1783,17 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::InstanceList::fillin -// Access: Public -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SpeedTreeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SpeedTreeNode. + */ void SpeedTreeNode::InstanceList:: fillin(DatagramIterator &scan, BamReader *manager) { // Get the relative pathname to the SRT file. string srt_filename = scan.get_string(); - // Now load up the SRT file using the Panda loader (which will - // also search the model-path if necessary). + // Now load up the SRT file using the Panda loader (which will also search + // the model-path if necessary). Loader *loader = Loader::get_global_ptr(); PT(PandaNode) srt_root = loader->load_sync(srt_filename); @@ -1985,14 +1818,11 @@ fillin(DatagramIterator &scan, BamReader *manager) { } } -//////////////////////////////////////////////////////////////////// -// Function: SpeedTreeNode::DrawCallback::do_callback -// Access: Public, Virtual -// Description: This method called when the callback is triggered; it -// *replaces* the original function. To continue -// performing the original function, you must call -// cbdata->upcall() during the callback. -//////////////////////////////////////////////////////////////////// +/** + * This method called when the callback is triggered; it *replaces* the + * original function. To continue performing the original function, you must + * call cbdata->upcall() during the callback. + */ void SpeedTreeNode::DrawCallback:: do_callback(CallbackData *data) { _node->draw_callback(data); diff --git a/panda/src/speedtree/speedTreeNode.h b/panda/src/speedtree/speedTreeNode.h index 6c7d168c87..942312a2fb 100644 --- a/panda/src/speedtree/speedTreeNode.h +++ b/panda/src/speedtree/speedTreeNode.h @@ -1,16 +1,15 @@ -// Filename: speedTreeNode.h -// Created by: drose (30Sep10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file speedTreeNode.h + * @author drose + * @date 2010-09-30 + */ #ifndef SPEEDTREENODE_H #define SPEEDTREENODE_H @@ -31,35 +30,31 @@ class Loader; -// There is a SpeedTree bug that prevents reliably deleting a -// CForestRender object, as of version 5.2. Presumably it will be -// fixed beginning in version 5.3. +// There is a SpeedTree bug that prevents reliably deleting a CForestRender +// object, as of version 5.2. Presumably it will be fixed beginning in +// version 5.3. #if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 3) #undef ST_DELETE_FOREST_HACK #else #define ST_DELETE_FOREST_HACK #endif -//////////////////////////////////////////////////////////////////// -// Class : SpeedTreeNode -// Description : Interfaces with the SpeedTree library to render -// SpeedTree objects, especially trees, within the -// Panda3D scene graph. -// -// SpeedTree also includes some support for a simple -// terrain system, which is available here as well. -// SpeedTree's rather lame grass system is not presently -// exposed. -//////////////////////////////////////////////////////////////////// +/** + * Interfaces with the SpeedTree library to render SpeedTree objects, + * especially trees, within the Panda3D scene graph. + * + * SpeedTree also includes some support for a simple terrain system, which is + * available here as well. SpeedTree's rather lame grass system is not + * presently exposed. + */ class EXPCL_PANDASPEEDTREE SpeedTreeNode : public PandaNode { private: // This definition is required by InstanceList, below. typedef pvector STInstances; PUBLISHED: - // This nested class keeps a linear list of transforms, for the - // purpose of recording instances of a particular STTree. It is - // used below. + // This nested class keeps a linear list of transforms, for the purpose of + // recording instances of a particular STTree. It is used below. class InstanceList { public: INLINE InstanceList(const STTree *tree); @@ -116,17 +111,17 @@ PUBLISHED: void add_instances(const NodePath &root, const TransformState *transform = TransformState::make_identity()); void add_instances_from(const SpeedTreeNode *other); void add_instances_from(const SpeedTreeNode *other, const TransformState *transform); - void add_random_instances(const STTree *tree, int quantity, - PN_stdfloat x_min, PN_stdfloat x_max, + void add_random_instances(const STTree *tree, int quantity, + PN_stdfloat x_min, PN_stdfloat x_max, PN_stdfloat y_min, PN_stdfloat y_max, PN_stdfloat scale_min, PN_stdfloat scale_max, PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max, Randomizer &randomizer = Randomizer()); - bool add_from_stf(const Filename &stf_filename, + bool add_from_stf(const Filename &stf_filename, const LoaderOptions &options = LoaderOptions()); - bool add_from_stf(istream &in, const Filename &pathname, + bool add_from_stf(istream &in, const Filename &pathname, const LoaderOptions &options = LoaderOptions(), Loader *loader = NULL); @@ -153,7 +148,7 @@ public: SpeedTreeNode(const SpeedTreeNode ©); virtual PandaNode *make_copy() const; - virtual PandaNode *combine_with(PandaNode *other); + virtual PandaNode *combine_with(PandaNode *other); virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer); @@ -222,7 +217,7 @@ private: private: string _os_shaders_dir; - + // A list of instances per each unique tree. typedef ov_set > Trees; Trees _trees; diff --git a/panda/src/speedtree/speedtree_api.cxx b/panda/src/speedtree/speedtree_api.cxx index 6cf49f8ff4..6d6e844c03 100644 --- a/panda/src/speedtree/speedtree_api.cxx +++ b/panda/src/speedtree/speedtree_api.cxx @@ -1,15 +1,14 @@ -// Filename: speedtree_api.cxx -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file speedtree_api.cxx + * @author drose + * @date 2010-10-06 + */ #include "speedtree_api.h" diff --git a/panda/src/speedtree/speedtree_api.h b/panda/src/speedtree/speedtree_api.h index d1849d94fa..54252ed163 100644 --- a/panda/src/speedtree/speedtree_api.h +++ b/panda/src/speedtree/speedtree_api.h @@ -1,22 +1,21 @@ -// Filename: speedtree_api.h -// Created by: drose (05Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file speedtree_api.h + * @author drose + * @date 2010-10-05 + */ #ifndef SPEEDTREE_API_H #define SPEEDTREE_API_H -// This header file should be included first, to pull in any of the -// required headers from the SpeedTree API, needed in this directory. +// This header file should be included first, to pull in any of the required +// headers from the SpeedTree API, needed in this directory. #include "speedtree_parameters.h" #include "Core/Core.h" @@ -32,4 +31,3 @@ #endif #endif // SPEEDTREE_API_H - diff --git a/panda/src/speedtree/stBasicTerrain.I b/panda/src/speedtree/stBasicTerrain.I index f256689e32..3d3ac06e6b 100644 --- a/panda/src/speedtree/stBasicTerrain.I +++ b/panda/src/speedtree/stBasicTerrain.I @@ -1,84 +1,65 @@ -// Filename: stBasicTerrain.I -// Created by: drose (12Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stBasicTerrain.I + * @author drose + * @date 2010-10-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::set_height_map -// Access: Published -// Description: Specifies the image filename that will define the -// height map of the terrain. This will require a -// subsequent call to load_data() to actually read the -// data. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the image filename that will define the height map of the + * terrain. This will require a subsequent call to load_data() to actually + * read the data. + */ INLINE void STBasicTerrain:: set_height_map(const Filename &height_map) { _height_map = height_map; _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::get_height_map -// Access: Published -// Description: Returns the image filename that defines the -// height map of the terrain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the image filename that defines the height map of the terrain. + */ INLINE const Filename &STBasicTerrain:: get_height_map() const { return _height_map; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::get_size -// Access: Published -// Description: Returns the length, in scene graph units, of one edge -// of the heightmap as it is manifested by the terrain. -// Increasing this number spreads the heightmap out over -// a greater area. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length, in scene graph units, of one edge of the heightmap as + * it is manifested by the terrain. Increasing this number spreads the + * heightmap out over a greater area. + */ INLINE PN_stdfloat STBasicTerrain:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::interpolate -// Access: Protected, Static -// Description: Convenience function to calculate the linear -// interpolation from A to B. -//////////////////////////////////////////////////////////////////// +/** + * Convenience function to calculate the linear interpolation from A to B. + */ INLINE PN_stdfloat STBasicTerrain:: interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t) { return (a + (b - a) * t); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ template STBasicTerrain::InterpolationData:: -InterpolationData() : _width(0), _height(0) +InterpolationData() : _width(0), _height(0) { } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::reset -// Access: Public -// Description: Resets the array to an empty array of width x height -// cells. -//////////////////////////////////////////////////////////////////// +/** + * Resets the array to an empty array of width x height cells. + */ template void STBasicTerrain::InterpolationData:: reset(int width, int height) { @@ -88,11 +69,9 @@ reset(int width, int height) { _data.insert(_data.begin(), width * height, ValueType()); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::get_nearest_neighbor -// Access: Public -// Description: Returns the value nearest to (u, v) in the data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value nearest to (u, v) in the data. + */ template ValueType STBasicTerrain::InterpolationData:: get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v) const { @@ -103,48 +82,43 @@ get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v) const { return _data[index]; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::calc_bilnear_interpolation -// Access: Public -// Description: Interpolates the value at (u, v) between its four -// nearest neighbors. -//////////////////////////////////////////////////////////////////// +/** + * Interpolates the value at (u, v) between its four nearest neighbors. + */ template ValueType STBasicTerrain::InterpolationData:: calc_bilinear_interpolation(PN_stdfloat u, PN_stdfloat v) const { u -= cfloor(u); v -= cfloor(v); - + u *= (PN_stdfloat)_width; v *= (PN_stdfloat)_height; - + const int lower_x = int(u); const int lower_y = int(v); const int higher_x = (lower_x + 1) % _width; const int higher_y = (lower_y + 1) % _height; - + const PN_stdfloat ratio_x = u - PN_stdfloat(lower_x); const PN_stdfloat ratio_y = v - PN_stdfloat(lower_y); const PN_stdfloat inv_ratio_x = 1.0f - ratio_x; const PN_stdfloat inv_ratio_y = 1.0f - ratio_y; - + nassertr(lower_x + lower_y * _width >= 0 && higher_x + higher_y * _width < (int)_data.size(), 0); const ValueType &t1 = _data[lower_x + lower_y * _width]; const ValueType &t2 = _data[higher_x + lower_y * _width]; const ValueType &t3 = _data[lower_x + higher_y * _width]; const ValueType &t4 = _data[higher_x + higher_y * _width]; - - return (t1 * inv_ratio_x + t2 * ratio_x) * inv_ratio_y + + + return (t1 * inv_ratio_x + t2 * ratio_x) * inv_ratio_y + (t3 * inv_ratio_x + t4 * ratio_x) * ratio_y; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::calc_smooth -// Access: Public -// Description: Approximates the average value at (u, v) over the -// indicated radius, assuming a polynomial curve. -//////////////////////////////////////////////////////////////////// +/** + * Approximates the average value at (u, v) over the indicated radius, + * assuming a polynomial curve. + */ template ValueType STBasicTerrain::InterpolationData:: calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius) const { @@ -172,20 +146,18 @@ calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius) const { PN_stdfloat weight = (1.0f - sqrt((test_point[0] * test_point[0]) + (test_point[1] * test_point[1]))); total_weight += weight; retval += weight * calc_bilinear_interpolation(u + test_point[0], v + test_point[1]); - } - + } + retval /= total_weight; } - + return retval; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::InterpolationData::is_present -// Access: Public -// Description: Returns true if the data is present--that is, reset() -// was called with non-zero values--or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data is present--that is, reset() was called with non- + * zero values--or false otherwise. + */ template bool STBasicTerrain::InterpolationData:: is_present() const { diff --git a/panda/src/speedtree/stBasicTerrain.cxx b/panda/src/speedtree/stBasicTerrain.cxx index 40e17739ee..5ee746dcbf 100644 --- a/panda/src/speedtree/stBasicTerrain.cxx +++ b/panda/src/speedtree/stBasicTerrain.cxx @@ -1,16 +1,15 @@ -// Filename: stBasicTerrain.cxx -// Created by: drose (12Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stBasicTerrain.cxx + * @author drose + * @date 2010-10-12 + */ #include "stBasicTerrain.h" #include "geomVertexWriter.h" @@ -19,8 +18,8 @@ TypeHandle STBasicTerrain::_type_handle; -// VERTEX_ATTRIB_END is defined as a macro that must be evaluated -// within the SpeedTree namespace. +// VERTEX_ATTRIB_END is defined as a macro that must be evaluated within the +// SpeedTree namespace. namespace SpeedTree { static const SVertexAttribDesc st_attrib_end = VERTEX_ATTRIB_END(); } @@ -34,28 +33,23 @@ namespace SpeedTree { { VERTEX_ATTRIB_SEMANTIC_TEXCOORD0, VERTEX_ATTRIB_TYPE_FLOAT, 3 }, VERTEX_ATTRIB_END( ) }; - static const int std_vertex_format_length = + static const int std_vertex_format_length = sizeof(std_vertex_format) / sizeof(std_vertex_format[0]); }; */ -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ STBasicTerrain:: STBasicTerrain() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::Copy Constructor -// Access: Published -// Description: Not sure whether any derived classes will implement -// the copy constructor, but it's defined here at the -// base level just in case. -//////////////////////////////////////////////////////////////////// +/** + * Not sure whether any derived classes will implement the copy constructor, + * but it's defined here at the base level just in case. + */ STBasicTerrain:: STBasicTerrain(const STBasicTerrain ©) : STTerrain(copy), @@ -64,20 +58,16 @@ STBasicTerrain(const STBasicTerrain ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ STBasicTerrain:: ~STBasicTerrain() { } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::clear -// Access: Published, Virtual -// Description: Resets the terrain to its initial, unloaded state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the terrain to its initial, unloaded state. + */ void STBasicTerrain:: clear() { STTerrain::clear(); @@ -87,25 +77,21 @@ clear() { _height_scale = 1.0f; CPT(GeomVertexFormat) format = GeomVertexFormat::register_format - (new GeomVertexArrayFormat(InternalName::get_vertex(), 3, + (new GeomVertexArrayFormat(InternalName::get_vertex(), 3, GeomEnums::NT_stdfloat, GeomEnums::C_point, - InternalName::get_texcoord(), 3, + InternalName::get_texcoord(), 3, GeomEnums::NT_stdfloat, GeomEnums::C_texcoord)); set_vertex_format(format); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::setup_terrain -// Access: Published -// Description: Sets up the terrain by reading a terrain.txt file as -// defined by SpeedTree. This file names the various -// map files that define the terrain, as well as -// defining parameters size as its size and color. -// -// If a relative filename is supplied, the model-path is -// searched. If a directory is named, "terrain.txt" is -// implicitly appended. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the terrain by reading a terrain.txt file as defined by SpeedTree. + * This file names the various map files that define the terrain, as well as + * defining parameters size as its size and color. + * + * If a relative filename is supplied, the model-path is searched. If a + * directory is named, "terrain.txt" is implicitly appended. + */ bool STBasicTerrain:: setup_terrain(const Filename &terrain_filename) { _is_valid = false; @@ -132,23 +118,20 @@ setup_terrain(const Filename &terrain_filename) { << "Couldn't open " << terrain_filename << "\n"; return false; } - + bool success = setup_terrain(*in, fullpath); vfs->close_read_file(in); return success; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::setup_terrain -// Access: Published -// Description: Sets up the terrain by reading a terrain.txt file as -// defined by SpeedTree. This variant on this method -// accepts an istream for an already-opened terrain.txt -// file. The filename is provided for reference, to -// assist relative file operations. It should name the -// terrain.txt file that has been opened. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the terrain by reading a terrain.txt file as defined by SpeedTree. + * This variant on this method accepts an istream for an already-opened + * terrain.txt file. The filename is provided for reference, to assist + * relative file operations. It should name the terrain.txt file that has + * been opened. + */ bool STBasicTerrain:: setup_terrain(istream &in, const Filename &pathname) { clear(); @@ -159,8 +142,8 @@ setup_terrain(istream &in, const Filename &pathname) { in >> keyword; while (in && !in.eof()) { if (keyword == "area") { - // "area" defines the size of the terrain in square kilometers. - // We apply speedtree_area_scale to convert that to local units. + // "area" defines the size of the terrain in square kilometers. We + // apply speedtree_area_scale to convert that to local units. PN_stdfloat area; in >> area; _size = csqrt(area) * speedtree_area_scale; @@ -211,8 +194,7 @@ setup_terrain(istream &in, const Filename &pathname) { in >> ws; if (!in.eof()) { - // If we didn't read all the way to end-of-file, there was an - // error. + // If we didn't read all the way to end-of-file, there was an error. in.clear(); string text; in >> text; @@ -221,8 +203,7 @@ setup_terrain(istream &in, const Filename &pathname) { return false; } - // The first two textures are the normal map and splat map, - // respectively. + // The first two textures are the normal map and splat map, respectively. if (!_splat_layers.empty()) { _normal_map = _splat_layers[0]._filename; _splat_layers.erase(_splat_layers.begin()); @@ -238,17 +219,13 @@ setup_terrain(istream &in, const Filename &pathname) { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::load_data -// Access: Published, Virtual -// Description: This will be called at some point after -// initialization. It should be overridden by a derived -// class to load up the terrain data from its source and -// fill in the data members of this class appropriately, -// especially _is_valid. After this call, if _is_valid -// is true, then get_height() etc. will be called to -// query the terrain's data. -//////////////////////////////////////////////////////////////////// +/** + * This will be called at some point after initialization. It should be + * overridden by a derived class to load up the terrain data from its source + * and fill in the data members of this class appropriately, especially + * _is_valid. After this call, if _is_valid is true, then get_height() etc. + * will be called to query the terrain's data. + */ void STBasicTerrain:: load_data() { _is_valid = false; @@ -260,63 +237,48 @@ load_data() { _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::get_height -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the computed height value at point (x, y) of the -// terrain, where x and y are unbounded and may refer to -// any 2-d point in space. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the computed height + * value at point (x, y) of the terrain, where x and y are unbounded and may + * refer to any 2-d point in space. + */ PN_stdfloat STBasicTerrain:: get_height(PN_stdfloat x, PN_stdfloat y) const { return _height_data.calc_bilinear_interpolation(x / _size, y / _size); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::get_smooth_height -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the approximate average height value over a circle of -// the specified radius, centered at point (x, y) of the -// terrain. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the approximate + * average height value over a circle of the specified radius, centered at + * point (x, y) of the terrain. + */ PN_stdfloat STBasicTerrain:: get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const { return _height_data.calc_smooth(x / _size, y / _size, radius / _size); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::get_slope -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the directionless slope at point (x, y) of the -// terrain, where 0.0 is flat and 1.0 is vertical. This -// is used for determining the legal points to place -// trees and grass. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the directionless + * slope at point (x, y) of the terrain, where 0.0 is flat and 1.0 is + * vertical. This is used for determining the legal points to place trees and + * grass. + */ PN_stdfloat STBasicTerrain:: get_slope(PN_stdfloat x, PN_stdfloat y) const { return _slope_data.calc_bilinear_interpolation(x / _size, y / _size); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::fill_vertices -// Access: Published, Virtual -// Description: After load_data() has been called, this will be -// called occasionally to populate the vertices for a -// terrain cell. -// -// It will be passed a GeomVertexData whose format will -// match get_vertex_format(), and already allocated with -// num_xy * num_xy rows. This method should fill the -// rows of the data with the appropriate vertex data for -// the terrain, over the grid described by the corners -// (start_x, start_y) up to and including (start_x + -// size_x, start_y + size_xy)--a square of the terrain -// with num_xy vertices on a size, arranged in row-major -// order. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this will be called occasionally to + * populate the vertices for a terrain cell. + * + * It will be passed a GeomVertexData whose format will match + * get_vertex_format(), and already allocated with num_xy * num_xy rows. This + * method should fill the rows of the data with the appropriate vertex data + * for the terrain, over the grid described by the corners (start_x, start_y) + * up to and including (start_x + size_x, start_y + size_xy)--a square of the + * terrain with num_xy vertices on a size, arranged in row-major order. + */ void STBasicTerrain:: fill_vertices(GeomVertexData *data, PN_stdfloat start_x, PN_stdfloat start_y, @@ -335,41 +297,34 @@ fill_vertices(GeomVertexData *data, PN_stdfloat y = start_y + yt * size_xy; PN_stdfloat z = get_height(x, y); - + vertex.set_data3(x, y, z); texcoord.set_data3(x * texcoord_scale, -y * texcoord_scale, 1.0f); } } } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STBasicTerrain:: output(ostream &out) const { Namable::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STBasicTerrain:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::read_height_map -// Access: Protected -// Description: Reads the height map image stored in _height_map, and -// stores it in _height_data. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads the height map image stored in _height_map, and stores it in + * _height_data. Returns true on success, false on failure. + */ bool STBasicTerrain:: read_height_map() { PNMImage image(_height_map); @@ -396,16 +351,14 @@ read_height_map() { } compute_slope(0.5f); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::compute_slope -// Access: Protected -// Description: Once _height_data has been filled in, compute the -// corresponding values for _slope_data. -//////////////////////////////////////////////////////////////////// +/** + * Once _height_data has been filled in, compute the corresponding values for + * _slope_data. + */ void STBasicTerrain:: compute_slope(PN_stdfloat smoothing) { nassertv(!_height_data._data.empty()); @@ -461,9 +414,9 @@ compute_slope(PN_stdfloat smoothing) { int top = (j + height - 1) % height; int bottom = (j + 1) % height; - smoothed[i + j * width] = (_slope_data._data[right + j * width] + - _slope_data._data[left + j * width] + - _slope_data._data[i + top * width] + + smoothed[i + j * width] = (_slope_data._data[right + j * width] + + _slope_data._data[left + j * width] + + _slope_data._data[i + top * width] + _slope_data._data[i + bottom * width] + _slope_data._data[right + top * width] + _slope_data._data[right + bottom * width] + @@ -490,21 +443,17 @@ compute_slope(PN_stdfloat smoothing) { } } -//////////////////////////////////////////////////////////////////// -// Function: STBasicTerrain::read_quoted_filename -// Access: Private, Static -// Description: Reads a quoted filename from the input stream, which -// is understood to be relative to the indicated -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Reads a quoted filename from the input stream, which is understood to be + * relative to the indicated directory. + */ void STBasicTerrain:: read_quoted_filename(Filename &result, istream &in, const Filename &dirname) { string filename; in >> filename; - // The terrain.txt file should, in theory, support spaces, but the - // SpeedTree reference application doesn't, so we don't bother - // either. + // The terrain.txt file should, in theory, support spaces, but the SpeedTree + // reference application doesn't, so we don't bother either. if (filename.size() >= 2 && filename[0] == '"' && filename[filename.size() - 1] == '"') { filename = filename.substr(1, filename.size() - 2); } @@ -514,4 +463,3 @@ read_quoted_filename(Filename &result, istream &in, const Filename &dirname) { result = Filename(dirname, result); } } - diff --git a/panda/src/speedtree/stBasicTerrain.h b/panda/src/speedtree/stBasicTerrain.h index 529282bbbd..a61f15a785 100644 --- a/panda/src/speedtree/stBasicTerrain.h +++ b/panda/src/speedtree/stBasicTerrain.h @@ -1,16 +1,15 @@ -// Filename: stBasicTerrain.h -// Created by: drose (12Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stBasicTerrain.h + * @author drose + * @date 2010-10-12 + */ #ifndef STBASICTERRAIN_H #define STBASICTERRAIN_H @@ -20,13 +19,11 @@ #include "luse.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : STBasicTerrain -// Description : A specific implementation of STTerrain that supports -// basic heightmaps loaded from an image file, as -// described in a terrain.txt file similar to those -// provided with the SpeedTree example application. -//////////////////////////////////////////////////////////////////// +/** + * A specific implementation of STTerrain that supports basic heightmaps + * loaded from an image file, as described in a terrain.txt file similar to + * those provided with the SpeedTree example application. + */ class EXPCL_PANDASPEEDTREE STBasicTerrain : public STTerrain { PUBLISHED: STBasicTerrain(); @@ -62,7 +59,7 @@ protected: INLINE PN_stdfloat interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t); private: - static void read_quoted_filename(Filename &result, istream &in, + static void read_quoted_filename(Filename &result, istream &in, const Filename &dirname); protected: @@ -88,9 +85,9 @@ protected: PN_stdfloat _height_scale; InterpolationData _height_data; - //InterpolationData _normal_data; + // InterpolationData _normal_data; InterpolationData _slope_data; - //InterpolationData _ao_data; + // InterpolationData _ao_data; public: static TypeHandle get_class_type() { diff --git a/panda/src/speedtree/stTerrain.I b/panda/src/speedtree/stTerrain.I index f2fc472642..6281182f85 100644 --- a/panda/src/speedtree/stTerrain.I +++ b/panda/src/speedtree/stTerrain.I @@ -1,137 +1,106 @@ -// Filename: stTerrain.I -// Created by: drose (11Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTerrain.I + * @author drose + * @date 2010-10-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::is_valid -// Access: Published -// Description: Returns true if the terrain data is well-defined and -// ready to use. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the terrain data is well-defined and ready to use. + */ INLINE bool STTerrain:: is_valid() const { return _is_valid && !_st_vertex_attribs.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_normal_map -// Access: Published -// Description: Returns the normal map that should be applied to the -// terrain. This will be loaded and supplied to the -// shader. -//////////////////////////////////////////////////////////////////// +/** + * Returns the normal map that should be applied to the terrain. This will be + * loaded and supplied to the shader. + */ INLINE const Filename &STTerrain:: get_normal_map() const { return _normal_map; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_splat_map -// Access: Published -// Description: Returns the splat map that should be applied to the -// terrain. This will be loaded and supplied to the -// shader. Presumably, the shader will use the channels -// of this map to determine which of the splat layers -// are to be rendered at any given point. -//////////////////////////////////////////////////////////////////// +/** + * Returns the splat map that should be applied to the terrain. This will be + * loaded and supplied to the shader. Presumably, the shader will use the + * channels of this map to determine which of the splat layers are to be + * rendered at any given point. + */ INLINE const Filename &STTerrain:: get_splat_map() const { return _splat_map; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_num_splat_layers -// Access: Published -// Description: Returns the number of splat layers that are to be -// applied to the terrain. This must be consistent with -// c_nNumTerrainSplatLayers in SpeedTree's TerrainRI.h. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of splat layers that are to be applied to the terrain. + * This must be consistent with c_nNumTerrainSplatLayers in SpeedTree's + * TerrainRI.h. + */ INLINE int STTerrain:: get_num_splat_layers() const { return _splat_layers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_splat_layer -// Access: Published -// Description: Returns the nth splat layer that is to be applied to -// the terrain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth splat layer that is to be applied to the terrain. + */ INLINE const Filename &STTerrain:: get_splat_layer(int n) const { nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._filename); return _splat_layers[n]._filename; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_splat_layer_tiling -// Access: Published -// Description: Returns the tiling value of the nth splat layer. -// This is an arbitrary UV scale that is applied to each -// layer individually, by the terrain shader. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tiling value of the nth splat layer. This is an arbitrary UV + * scale that is applied to each layer individually, by the terrain shader. + */ INLINE PN_stdfloat STTerrain:: get_splat_layer_tiling(int n) const { nassertr(n >= 0 && n < (int)_splat_layers.size(), 0.0f); return _splat_layers[n]._tiling; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_splat_layer_color -// Access: Published -// Description: Returns the overall color of the nth splat layer. This -// is used just to match the color of the grass to its -// terrain. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall color of the nth splat layer. This is used just to + * match the color of the grass to its terrain. + */ INLINE LColor STTerrain:: get_splat_layer_color(int n) const { nassertr(n >= 0 && n < (int)_splat_layers.size(), _splat_layers[0]._color); return LVecBase4(_splat_layers[n]._color); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_vertex_format -// Access: Published -// Description: Returns the vertex format of the vertex array that is -// supported by this terrain data. A GeomVertexData of -// the requested format will be passed to -// fill_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex format of the vertex array that is supported by this + * terrain data. A GeomVertexData of the requested format will be passed to + * fill_vertices(). + */ INLINE const GeomVertexFormat *STTerrain:: get_vertex_format() { return _vertex_format; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_min_height -// Access: Published -// Description: Returns the smallest height value that might be -// returned by get_height(). This is used as a culling -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest height value that might be returned by get_height(). + * This is used as a culling optimization. + */ INLINE PN_stdfloat STTerrain:: get_min_height() const { return _min_height; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_max_height -// Access: Published -// Description: Returns the largest height value that might be -// returned by get_height(). This is used as a culling -// optimization. -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest height value that might be returned by get_height(). + * This is used as a culling optimization. + */ INLINE PN_stdfloat STTerrain:: get_max_height() const { return _max_height; diff --git a/panda/src/speedtree/stTerrain.cxx b/panda/src/speedtree/stTerrain.cxx index b3d3a2d526..2f5f226856 100644 --- a/panda/src/speedtree/stTerrain.cxx +++ b/panda/src/speedtree/stTerrain.cxx @@ -1,27 +1,24 @@ -// Filename: stTerrain.cxx -// Created by: drose (11Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTerrain.cxx + * @author drose + * @date 2010-10-11 + */ #include "stTerrain.h" #include "indent.h" TypeHandle STTerrain::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ STTerrain:: STTerrain() { _is_valid = false; @@ -29,11 +26,9 @@ STTerrain() { _max_height = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::Copy Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ STTerrain:: STTerrain(const STTerrain ©) : TypedReferenceCount(copy), @@ -47,20 +42,16 @@ STTerrain(const STTerrain ©) : set_vertex_format(copy._vertex_format); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ STTerrain:: ~STTerrain() { } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::clear -// Access: Published, Virtual -// Description: Resets the terrain to its initial, unloaded state. -//////////////////////////////////////////////////////////////////// +/** + * Resets the terrain to its initial, unloaded state. + */ void STTerrain:: clear() { _is_valid = false; @@ -74,70 +65,55 @@ clear() { set_vertex_format(NULL); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::load_data -// Access: Published, Virtual -// Description: This will be called at some point after -// initialization. It should be overridden by a derived -// class to load up the terrain data from its source and -// fill in the data members of this class appropriately, -// especially _is_valid. After this call, if _is_valid -// is true, then get_height() etc. will be called to -// query the terrain's data. -//////////////////////////////////////////////////////////////////// +/** + * This will be called at some point after initialization. It should be + * overridden by a derived class to load up the terrain data from its source + * and fill in the data members of this class appropriately, especially + * _is_valid. After this call, if _is_valid is true, then get_height() etc. + * will be called to query the terrain's data. + */ void STTerrain:: load_data() { } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_height -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the computed height value at point (x, y) of the -// terrain, where x and y are unbounded and may refer to -// any 2-d point in space. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the computed height + * value at point (x, y) of the terrain, where x and y are unbounded and may + * refer to any 2-d point in space. + */ PN_stdfloat STTerrain:: get_height(PN_stdfloat x, PN_stdfloat y) const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_smooth_height -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the approximate average height value over a circle of -// the specified radius, centered at point (x, y) of the -// terrain. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the approximate + * average height value over a circle of the specified radius, centered at + * point (x, y) of the terrain. + */ PN_stdfloat STTerrain:: get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const { return get_height(x, y); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_slope -// Access: Published, Virtual -// Description: After load_data() has been called, this should return -// the directionless slope at point (x, y) of the -// terrain, where 0.0 is flat and 1.0 is vertical. This -// is used for determining the legal points to place -// trees and grass. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this should return the directionless + * slope at point (x, y) of the terrain, where 0.0 is flat and 1.0 is + * vertical. This is used for determining the legal points to place trees and + * grass. + */ PN_stdfloat STTerrain:: get_slope(PN_stdfloat x, PN_stdfloat y) const { return 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::placement_is_acceptable -// Access: Published -// Description: Returns true if the elevation and slope of point (x, -// y) fall within the requested limits, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the elevation and slope of point (x, y) fall within the + * requested limits, false otherwise. + */ bool STTerrain:: placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, - PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max) { PN_stdfloat height = get_height(x, y); if (height < height_min || height > height_max) { @@ -152,72 +128,57 @@ placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, return true; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::fill_vertices -// Access: Published, Virtual -// Description: After load_data() has been called, this will be -// called occasionally to populate the vertices for a -// terrain cell. -// -// It will be passed a GeomVertexData whose format will -// match get_vertex_format(), and already allocated with -// num_xy * num_xy rows. This method should fill the -// rows of the data with the appropriate vertex data for -// the terrain, over the grid described by the corners -// (start_x, start_y) up to and including (start_x + -// size_x, start_y + size_xy)--a square of the terrain -// with num_xy vertices on a side, arranged in row-major -// order. -//////////////////////////////////////////////////////////////////// +/** + * After load_data() has been called, this will be called occasionally to + * populate the vertices for a terrain cell. + * + * It will be passed a GeomVertexData whose format will match + * get_vertex_format(), and already allocated with num_xy * num_xy rows. This + * method should fill the rows of the data with the appropriate vertex data + * for the terrain, over the grid described by the corners (start_x, start_y) + * up to and including (start_x + size_x, start_y + size_xy)--a square of the + * terrain with num_xy vertices on a side, arranged in row-major order. + */ void STTerrain:: fill_vertices(GeomVertexData *data, PN_stdfloat start_x, PN_stdfloat start_y, PN_stdfloat size_xy, int num_xy) const { } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::output -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STTerrain:: output(ostream &out) const { Namable::output(out); } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STTerrain:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::get_st_vertex_format -// Access: Public -// Description: Returns a pointer to the SpeedTree array of vertex -// attribs that defines the vertex format for SpeedTree. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the SpeedTree array of vertex attribs that defines the + * vertex format for SpeedTree. + */ const SpeedTree::SVertexAttribDesc *STTerrain:: get_st_vertex_format() const { - // return SpeedTree::std_vertex_format; + // return SpeedTree::std_vertex_format; nassertr(!_st_vertex_attribs.empty(), NULL); return &_st_vertex_attribs[0]; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::set_vertex_format -// Access: Protected -// Description: Should be called in load_data() by a derived class to -// fill in the _vertex_format member. This will also -// compute and store the appropriate value for -// _st_vertex_attribs. -//////////////////////////////////////////////////////////////////// +/** + * Should be called in load_data() by a derived class to fill in the + * _vertex_format member. This will also compute and store the appropriate + * value for _st_vertex_attribs. + */ bool STTerrain:: set_vertex_format(const GeomVertexFormat *format) { if (format == NULL) { @@ -236,15 +197,11 @@ set_vertex_format(const GeomVertexFormat *format) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::convert_vertex_format -// Access: Protected, Static -// Description: Populates the indicated st_vertex_attribs vector with -// an array of SpeedTree vertex attribute entries that -// corresponds to the requested format. Returns true on -// success, or false if the format cannot be represented -// in SpeedTree. -//////////////////////////////////////////////////////////////////// +/** + * Populates the indicated st_vertex_attribs vector with an array of SpeedTree + * vertex attribute entries that corresponds to the requested format. Returns + * true on success, or false if the format cannot be represented in SpeedTree. + */ bool STTerrain:: convert_vertex_format(STTerrain::VertexAttribs &st_vertex_attribs, const GeomVertexFormat *format) { @@ -270,17 +227,15 @@ convert_vertex_format(STTerrain::VertexAttribs &st_vertex_attribs, } st_vertex_attribs.push_back(SpeedTree::st_attrib_end); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: STTerrain::convert_vertex_column -// Access: Protected, Static -// Description: Converts the indicated vertex column definition to -// the corresponding SpeedTree::SVertexAttribDesc -// format. Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated vertex column definition to the corresponding + * SpeedTree::SVertexAttribDesc format. Returns true on success, false on + * failure. + */ bool STTerrain:: convert_vertex_column(SpeedTree::SVertexAttribDesc &st_attrib, const GeomVertexColumn *column) { @@ -313,4 +268,3 @@ convert_vertex_column(SpeedTree::SVertexAttribDesc &st_attrib, return true; } - diff --git a/panda/src/speedtree/stTerrain.h b/panda/src/speedtree/stTerrain.h index 617a9bf26c..cc2bf94215 100644 --- a/panda/src/speedtree/stTerrain.h +++ b/panda/src/speedtree/stTerrain.h @@ -1,16 +1,15 @@ -// Filename: stTerrain.h -// Created by: drose (11Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTerrain.h + * @author drose + * @date 2010-10-11 + */ #ifndef STTERRAIN_H #define STTERRAIN_H @@ -21,23 +20,19 @@ #include "geomVertexData.h" #include "speedtree_api.h" -//////////////////////////////////////////////////////////////////// -// Class : STTerrain -// Description : This is the abstract base class that defines the -// interface needed to describe a terrain for rendering -// by SpeedTree. To use it, you must subclass and -// override the appropriate virtual methods. Or, -// consider just using STBasicTerrain. -// -// A terrain is defined as a 2-d height function over -// all space: get_height(x, y) may be called for any -// point in space and it should return a reasonable -// value. A terrain also provides normal maps and splat -// maps, as rendered by SpeedTree's Terrain.hlsl shader -// file. -//////////////////////////////////////////////////////////////////// +/** + * This is the abstract base class that defines the interface needed to + * describe a terrain for rendering by SpeedTree. To use it, you must + * subclass and override the appropriate virtual methods. Or, consider just + * using STBasicTerrain. + * + * A terrain is defined as a 2-d height function over all space: get_height(x, + * y) may be called for any point in space and it should return a reasonable + * value. A terrain also provides normal maps and splat maps, as rendered by + * SpeedTree's Terrain.hlsl shader file. + */ class EXPCL_PANDASPEEDTREE STTerrain : public TypedReferenceCount, public Namable { -protected: +protected: STTerrain(); STTerrain(const STTerrain ©); PUBLISHED: @@ -66,7 +61,7 @@ PUBLISHED: virtual PN_stdfloat get_slope(PN_stdfloat x, PN_stdfloat y) const; bool placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, - PN_stdfloat height_min, PN_stdfloat height_max, + PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max); virtual void fill_vertices(GeomVertexData *data, diff --git a/panda/src/speedtree/stTransform.I b/panda/src/speedtree/stTransform.I index 8289720ec1..09f32454c6 100644 --- a/panda/src/speedtree/stTransform.I +++ b/panda/src/speedtree/stTransform.I @@ -1,23 +1,19 @@ -// Filename: stTransform.I -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTransform.I + * @author drose + * @date 2010-10-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Default Constructor -// Access: Published -// Description: The default constructor creates an identity transform. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor creates an identity transform. + */ INLINE STTransform:: STTransform() : _pos(0.0f, 0.0f, 0.0f), @@ -26,11 +22,9 @@ STTransform() : { } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Constructor -// Access: Published -// Description: Construct a transform with componentwise inputs. -//////////////////////////////////////////////////////////////////// +/** + * Construct a transform with componentwise inputs. + */ INLINE STTransform:: STTransform(const LPoint3 &pos, PN_stdfloat rotate, PN_stdfloat scale) : _pos(pos), @@ -39,11 +33,9 @@ STTransform(const LPoint3 &pos, PN_stdfloat rotate, PN_stdfloat scale) : { } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Constructor -// Access: Published -// Description: Construct a transform with componentwise inputs. -//////////////////////////////////////////////////////////////////// +/** + * Construct a transform with componentwise inputs. + */ INLINE STTransform:: STTransform(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat rotate, PN_stdfloat scale) : _pos(x, y, z), @@ -52,11 +44,9 @@ STTransform(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat rotate, PN_ { } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE STTransform:: STTransform(const STTransform ©) : _pos(copy._pos), @@ -65,11 +55,9 @@ STTransform(const STTransform ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void STTransform:: operator = (const STTransform ©) { _pos = copy._pos; @@ -77,12 +65,10 @@ operator = (const STTransform ©) { _scale = copy._scale; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::CInstance constructor -// Access: Public -// Description: This is used internally to construct an STTransform -// from a SpeedTree::CInstance object. -//////////////////////////////////////////////////////////////////// +/** + * This is used internally to construct an STTransform from a + * SpeedTree::CInstance object. + */ INLINE STTransform:: STTransform(const SpeedTree::CInstance &instance) { const SpeedTree::Vec3 &pos = instance.GetPos(); @@ -91,12 +77,10 @@ STTransform(const SpeedTree::CInstance &instance) { _scale = instance.GetScale(); } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::CInstance operator -// Access: Public -// Description: This is used internally to convert an STTransform -// into a SpeedTree::CInstance object. -//////////////////////////////////////////////////////////////////// +/** + * This is used internally to convert an STTransform into a + * SpeedTree::CInstance object. + */ INLINE STTransform:: operator SpeedTree::CInstance () const { SpeedTree::CInstance instance; @@ -106,100 +90,78 @@ operator SpeedTree::CInstance () const { return instance; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::TransformState operator -// Access: Public -// Description: This is used internally to convert an STTransform -// into a TransformState pointer. -//////////////////////////////////////////////////////////////////// +/** + * This is used internally to convert an STTransform into a TransformState + * pointer. + */ INLINE STTransform:: operator CPT(TransformState) () const { - return TransformState::make_pos_hpr_scale(_pos, + return TransformState::make_pos_hpr_scale(_pos, LVecBase3(_rotate, 0.0f, 0.0f), LVecBase3(_scale, _scale, _scale)); } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::ident_mat -// Access: Published, Static -// Description: Returns a global identity transform object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a global identity transform object. + */ INLINE const STTransform &STTransform:: ident_mat() { return _ident_mat; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::set_pos -// Access: Published -// Description: Replaces the translation component. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the translation component. + */ INLINE void STTransform:: set_pos(const LPoint3 &pos) { _pos = pos; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::get_pos -// Access: Published -// Description: Returns the translation component. -//////////////////////////////////////////////////////////////////// +/** + * Returns the translation component. + */ INLINE const LPoint3 &STTransform:: get_pos() const { return _pos; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::set_rotate -// Access: Published -// Description: Replaces the rotation component. Accepts a rotation -// in degrees counter-clockwise around the vertical -// axis. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the rotation component. Accepts a rotation in degrees counter- + * clockwise around the vertical axis. + */ INLINE void STTransform:: set_rotate(PN_stdfloat rotate) { _rotate = rotate; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::get_rotate -// Access: Published -// Description: Returns the rotation component, in degrees -// counter-clockwise around the vertical axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rotation component, in degrees counter-clockwise around the + * vertical axis. + */ INLINE PN_stdfloat STTransform:: get_rotate() const { return _rotate; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::set_scale -// Access: Published -// Description: Replaces the scale component. Accepts a uniform -// scale value. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the scale component. Accepts a uniform scale value. + */ INLINE void STTransform:: set_scale(PN_stdfloat scale) { _scale = scale; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::get_scale -// Access: Published -// Description: Returns the scale component, as a uniform scale -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale component, as a uniform scale value. + */ INLINE PN_stdfloat STTransform:: get_scale() const { return _scale; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::operator *= -// Access: Published -// Description: Composes these transforms and stores the result -// in-place. -//////////////////////////////////////////////////////////////////// +/** + * Composes these transforms and stores the result in-place. + */ INLINE void STTransform:: operator *= (const STTransform &other) { LQuaternion quat; @@ -209,11 +171,9 @@ operator *= (const STTransform &other) { _scale *= other._scale; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::operator * -// Access: Published -// Description: Composes these transforms and returns the result/ -//////////////////////////////////////////////////////////////////// +/** + * Composes these transforms and returns the result + */ INLINE STTransform STTransform:: operator * (const STTransform &other) const { STTransform result = *this; diff --git a/panda/src/speedtree/stTransform.cxx b/panda/src/speedtree/stTransform.cxx index a6bcf5a535..aab4be7e93 100644 --- a/panda/src/speedtree/stTransform.cxx +++ b/panda/src/speedtree/stTransform.cxx @@ -1,32 +1,29 @@ -// Filename: stTransform.cxx -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTransform.cxx + * @author drose + * @date 2010-10-06 + */ #include "stTransform.h" STTransform STTransform::_ident_mat; -//////////////////////////////////////////////////////////////////// -// Function: STTransform::Constructor -// Access: Published -// Description: This constructor accepts a Panda TransformState, for -// instance as extracted from the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts a Panda TransformState, for instance as extracted + * from the scene graph. + */ STTransform:: STTransform(const TransformState *trans) { #ifndef NDEBUG - // Ensure these are initialized to reasonable values in case we fail - // an assertion below. + // Ensure these are initialized to reasonable values in case we fail an + // assertion below. _pos.set(0.0f, 0.0f, 0.0f); _rotate = 0.0f; _scale = 1.0f; @@ -43,22 +40,18 @@ STTransform(const TransformState *trans) { _scale = trans->get_uniform_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STTransform:: output(ostream &out) const { out << "STTransform(" << _pos << ", " << _rotate << ", " << _scale << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::write_datagram -// Access: Public -// Description: Writes the contents of this object to the datagram -// for shipping out to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ void STTransform:: write_datagram(BamWriter *manager, Datagram &dg) { _pos.write_datagram(dg); @@ -66,13 +59,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_stdfloat(_scale); } -//////////////////////////////////////////////////////////////////// -// Function: STTransform::fillin -// Access: Public -// Description: This internal function is called by make_from_bam to -// read in all of the relevant data from the BamFile for -// the new SpeedTreeNode. -//////////////////////////////////////////////////////////////////// +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new SpeedTreeNode. + */ void STTransform:: fillin(DatagramIterator &scan, BamReader *manager) { _pos.read_datagram(scan); diff --git a/panda/src/speedtree/stTransform.h b/panda/src/speedtree/stTransform.h index aa6954fd5e..07d66a3eae 100644 --- a/panda/src/speedtree/stTransform.h +++ b/panda/src/speedtree/stTransform.h @@ -1,16 +1,15 @@ -// Filename: stTransform.h -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTransform.h + * @author drose + * @date 2010-10-06 + */ #ifndef STTRANSFORM_H #define STTRANSFORM_H @@ -20,12 +19,10 @@ #include "speedtree_api.h" #include "deg_2_rad.h" -//////////////////////////////////////////////////////////////////// -// Class : STTransform -// Description : Represents a transform that may be applied to a -// particular instance of a tree when added to the -// SpeedTreeNode. -//////////////////////////////////////////////////////////////////// +/** + * Represents a transform that may be applied to a particular instance of a + * tree when added to the SpeedTreeNode. + */ class EXPCL_PANDASPEEDTREE STTransform { PUBLISHED: INLINE STTransform(); diff --git a/panda/src/speedtree/stTree.I b/panda/src/speedtree/stTree.I index b0e48d791b..5b85294552 100644 --- a/panda/src/speedtree/stTree.I +++ b/panda/src/speedtree/stTree.I @@ -1,57 +1,45 @@ -// Filename: stTree.I -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTree.I + * @author drose + * @date 2010-10-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: STTree::get_fullpath -// Access: Published -// Description: Returns the full pathname to the SRT file that was -// loaded for this tree, as passed to the constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to the SRT file that was loaded for this tree, as + * passed to the constructor. + */ INLINE const Filename &STTree:: get_fullpath() const { return _fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: STTree::is_valid -// Access: Published -// Description: Returns true if the tree was successfully loaded and -// is ready to be used, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the tree was successfully loaded and is ready to be used, + * false otherwise. + */ INLINE bool STTree:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: STTree::get_tree -// Access: Public -// Description: Returns a const pointer to the internal SpeedTree -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a const pointer to the internal SpeedTree object. + */ INLINE const SpeedTree::CTreeRender *STTree:: get_tree() const { return &_tree; } -//////////////////////////////////////////////////////////////////// -// Function: STTree::modify_tree -// Access: Public -// Description: Returns a modifiable pointer to the internal SpeedTree -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable pointer to the internal SpeedTree object. + */ INLINE SpeedTree::CTreeRender *STTree:: modify_tree() { return &_tree; diff --git a/panda/src/speedtree/stTree.cxx b/panda/src/speedtree/stTree.cxx index 84e0d2dc00..fb00fc1bea 100644 --- a/panda/src/speedtree/stTree.cxx +++ b/panda/src/speedtree/stTree.cxx @@ -1,31 +1,27 @@ -// Filename: stTree.cxx -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTree.cxx + * @author drose + * @date 2010-10-06 + */ #include "stTree.h" #include "speedTreeNode.h" TypeHandle STTree::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: STTree::Constructor -// Access: Published -// Description: The constructor reads the indicated SRT file -// immediately. Check is_valid() to determine whether -// the read was successful or not. Note that the -// filename must be a fully-qualified pathname; the -// STTree constructor does not search the model-path. -//////////////////////////////////////////////////////////////////// +/** + * The constructor reads the indicated SRT file immediately. Check is_valid() + * to determine whether the read was successful or not. Note that the + * filename must be a fully-qualified pathname; the STTree constructor does + * not search the model-path. + */ STTree:: STTree(const Filename &fullpath) : Namable(fullpath.get_basename_wo_extension()), @@ -40,9 +36,9 @@ STTree(const Filename &fullpath) : return; } - // Can't use VFS, due to SpeedTree's insistence on using fopen() to - // load dds textures and such. So we go ahead and use the low-level - // Filename interface directly. + // Can't use VFS, due to SpeedTree's insistence on using fopen() to load dds + // textures and such. So we go ahead and use the low-level Filename + // interface directly. /* Filename tree_filename = filename; if (!tree_filename.resolve_filename(get_model_path(), "srt")) { @@ -60,27 +56,23 @@ STTree(const Filename &fullpath) : return; } - speedtree_cat.info() + speedtree_cat.info() << "Read " << _fullpath << "\n"; _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: STTree::Copy Constructor -// Access: Private -// Description: An STTree copy constructor is not supported. -//////////////////////////////////////////////////////////////////// +/** + * An STTree copy constructor is not supported. + */ STTree:: STTree(const STTree ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: STTree::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void STTree:: output(ostream &out) const { if (!is_valid()) { diff --git a/panda/src/speedtree/stTree.h b/panda/src/speedtree/stTree.h index ed37e569a6..55c4dacbb7 100644 --- a/panda/src/speedtree/stTree.h +++ b/panda/src/speedtree/stTree.h @@ -1,16 +1,15 @@ -// Filename: stTree.h -// Created by: drose (06Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file stTree.h + * @author drose + * @date 2010-10-06 + */ #ifndef STTREE_H #define STTREE_H @@ -22,11 +21,10 @@ class SpeedTreeNode; -//////////////////////////////////////////////////////////////////// -// Class : STTree -// Description : Encapsulates a single tree model in the SpeedTree -// library, as loaded from an SRT file. -//////////////////////////////////////////////////////////////////// +/** + * Encapsulates a single tree model in the SpeedTree library, as loaded from + * an SRT file. + */ class EXPCL_PANDASPEEDTREE STTree : public TypedReferenceCount, public Namable { PUBLISHED: STTree(const Filename &fullpath); diff --git a/panda/src/testbed/pgrid.cxx b/panda/src/testbed/pgrid.cxx index a8c7da2475..76f56a58d9 100644 --- a/panda/src/testbed/pgrid.cxx +++ b/panda/src/testbed/pgrid.cxx @@ -1,16 +1,15 @@ -// Filename: pgrid.cxx -// Created by: drose (03Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pgrid.cxx + * @author drose + * @date 2002-04-03 + */ #include "pandaFramework.h" #include "pystub.h" @@ -81,7 +80,8 @@ move_gridded_stuff(GriddedMotionType gridmotiontype, {if(VAL > MAXVAL) {int idivresult = (int)(VAL / (PN_stdfloat)MAXVAL); VAL=VAL-idivresult*MAXVAL;} else \ if(VAL < -MAXVAL) {int idivresult = (int)(VAL / (PN_stdfloat)MAXVAL); VAL=VAL+idivresult*MAXVAL;}} - // probably should use panda lerps for this stuff, but I don't understand how + // probably should use panda lerps for this stuff, but I don't understand + // how if(gridmotiontype==Rotation) { @@ -145,8 +145,8 @@ move_gridded_stuff(GriddedMotionType gridmotiontype, bool get_command_line_opts(int &argc, char **&argv) { - // Use getopt() to decode the optional command-line parameters. - // extern char *optarg; + // Use getopt() to decode the optional command-line parameters. extern char + // *optarg; extern int optind; const char *options = "rm"; int flag = getopt(argc, argv, options); @@ -186,9 +186,9 @@ get_command_line_filenames(int argc, char *argv[], static_filenames.push_back(Filename::from_os_specific(arg)); } else { - // A comma in the filename indicates a gridded file. The syntax - // is filename,count where count represents the number of times - // the file is repeated. + // A comma in the filename indicates a gridded file. The syntax is + // filename,count where count represents the number of times the file is + // repeated. string name = arg.substr(0, comma); string count_str = arg.substr(comma + 1); int count; @@ -209,19 +209,19 @@ get_command_line_filenames(int argc, char *argv[], } void -load_gridded_models(WindowFramework *window, +load_gridded_models(WindowFramework *window, GriddedFilenames &filenames, GriddedInfoArray &info_arr) { - // Load up all the files indicated in the list of gridded filenames - // and store them in the given vector. + // Load up all the files indicated in the list of gridded filenames and + // store them in the given vector. Loader loader; LoaderOptions options; - // options.set_flags(options.get_flags() | LoaderOptions::LF_no_ram_cache); + // options.set_flags(options.get_flags() | LoaderOptions::LF_no_ram_cache); - // First, load up each model from disk once, and store them all - // separate from the scene graph. Also count up the total number of - // models we'll be putting in the grid. + // First, load up each model from disk once, and store them all separate + // from the scene graph. Also count up the total number of models we'll be + // putting in the grid. int grid_count = 0; GriddedFilenames::iterator fi; for (fi = filenames.begin(); fi != filenames.end(); ++fi) { @@ -236,8 +236,8 @@ load_gridded_models(WindowFramework *window, info_arr.clear(); info_arr.reserve(grid_count); - // Compute the integer square root of grid_count, so that we put our - // models in a nice square grid. + // Compute the integer square root of grid_count, so that we put our models + // in a nice square grid. gridwidth=1; while(gridwidth*gridwidth < grid_count) { @@ -247,8 +247,8 @@ load_gridded_models(WindowFramework *window, grid_pos_offset = -gridwidth*GRIDCELLSIZE/2.0; wander_area_pos_offset = -max((PN_stdfloat)fabs(grid_pos_offset), MIN_WANDERAREA_DIMENSION/2.0f); - // Now walk through the list again, copying models into the scene - // graph as we go. + // Now walk through the list again, copying models into the scene graph as + // we go. PN_stdfloat xpos = grid_pos_offset; PN_stdfloat ypos = grid_pos_offset; @@ -268,8 +268,8 @@ load_gridded_models(WindowFramework *window, const GriddedFilename &gf = (*fi); if (!gf._model.is_empty() && gf._count > passnum) { loaded_any = true; - // Copy this model into the scene graph, and assign it a - // position on the grid. + // Copy this model into the scene graph, and assign it a position on + // the grid. ++model_count; PT(PandaNode) node = loader.load_sync(gf._filename, options); @@ -397,8 +397,8 @@ main(int argc, char **argv) { return (1); } - // Extract the remaining arguments into two lists of files: those - // with a grid parameter, and those without. + // Extract the remaining arguments into two lists of files: those with a + // grid parameter, and those without. pvector static_filenames; GriddedFilenames gridded_filenames; get_command_line_filenames(argc, argv, static_filenames, gridded_filenames); diff --git a/panda/src/testbed/pview.cxx b/panda/src/testbed/pview.cxx index e92df5d220..f656a5de3d 100644 --- a/panda/src/testbed/pview.cxx +++ b/panda/src/testbed/pview.cxx @@ -1,16 +1,15 @@ -// Filename: pview.cxx -// Created by: drose (25Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pview.cxx + * @author drose + * @date 2002-02-25 + */ #include "pandaFramework.h" #include "pandaSystem.h" @@ -28,9 +27,9 @@ #include "preprocess_argv.h" #include "graphicsPipeSelection.h" -// By including checkPandaVersion.h, we guarantee that runtime -// attempts to run pview will fail if it inadvertently links with the -// wrong version of libdtool.so/.dll. +// By including checkPandaVersion.h, we guarantee that runtime attempts to run +// pview will fail if it inadvertently links with the wrong version of +// libdtool.so.dll. #include "checkPandaVersion.h" @@ -70,7 +69,7 @@ event_W(const Event *, void *) { WindowFramework *old_window = framework.get_window(0); GraphicsOutput *win = old_window->get_graphics_output(); pipe = win->get_pipe(); - // gsg = win->get_gsg(); + // gsg = win->get_gsg(); } WindowFramework *window = framework.open_window(pipe, gsg); @@ -89,7 +88,7 @@ event_F(const Event *, void *) { void event_Enter(const Event *, void *) { - // alt-enter: toggle between window/fullscreen in the same scene. + // alt-enter: toggle between windowfullscreen in the same scene. // If we already have a window, use the same GSG. GraphicsPipe *pipe = (GraphicsPipe *)NULL; @@ -112,7 +111,7 @@ event_Enter(const Event *, void *) { // set the toggle props.set_fullscreen(!props.get_fullscreen()); int flags = GraphicsPipe::BF_require_window; - + WindowFramework *window = framework.open_window(props, flags, pipe, gsg); if (window != (WindowFramework *)NULL) { window->enable_keyboard(); @@ -153,21 +152,20 @@ event_0(const Event *event, void *) { DisplayRegion *dr = buffer->make_display_region(); dr->set_camera(NodePath(wf->get_camera(0))); - // Make the clear color on the buffer be yellow, so it's obviously - // different from the main scene's background color. + // Make the clear color on the buffer be yellow, so it's obviously different + // from the main scene's background color. buffer->set_clear_color(LColor(1, 1, 0, 0)); - // Apply the offscreen buffer's texture to a card in the main - // window. + // Apply the offscreen buffer's texture to a card in the main window. CardMaker cm("card"); cm.set_frame(0, 1, 0, 1); NodePath card_np(cm.generate()); - + card_np.reparent_to(wf->get_render_2d()); card_np.set_texture(buffer->get_texture()); } -void +void usage() { cerr << "\n" @@ -175,7 +173,7 @@ usage() { " pview -h\n\n"; } -void +void help() { usage(); cerr << @@ -188,7 +186,7 @@ help() { " Convert and play animations, if loading an external file type\n" " (like .mb) directly and if the converter supports animations.\n" " Also implicitly enables the animation controls.\n\n" - + " -c\n" " Automatically center models within the viewing window on startup.\n" " This can also be achieved with the 'c' hotkey at runtime.\n\n" @@ -221,12 +219,12 @@ help() { " -V\n" " Report the current version of Panda, and exit.\n\n" - + " -h\n" " Display this help text.\n\n"; } -void +void report_version() { nout << "\n"; PandaSystem *ps = PandaSystem::get_global_ptr(); @@ -273,7 +271,7 @@ main(int argc, char **argv) { case 'l': show_loading = true; break; - + case 'i': hierarchy_match_flags |= PartGroup::HMF_ok_wrong_root_name; break; @@ -339,8 +337,8 @@ main(int argc, char **argv) { loading->set_align(TextNode::A_center); loading->set_text("Loading..."); - // Allow a couple of frames to go by so the window will be fully - // created and the text will be visible. + // Allow a couple of frames to go by so the window will be fully created + // and the text will be visible. Thread *current_thread = Thread::get_current_thread(); framework.do_frame(current_thread); framework.do_frame(current_thread); @@ -370,7 +368,7 @@ main(int argc, char **argv) { // Make sure the textures are preloaded. framework.get_models().prepare_scene(window->get_graphics_output()->get_gsg()); - + loading_np.remove_node(); if (apply_lighting) { diff --git a/panda/src/testbed/test_lod.cxx b/panda/src/testbed/test_lod.cxx index 8c5330598f..fa62edd785 100644 --- a/panda/src/testbed/test_lod.cxx +++ b/panda/src/testbed/test_lod.cxx @@ -1,16 +1,15 @@ -// Filename: test_lod.cxx -// Created by: drose (24Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_lod.cxx + * @author drose + * @date 2004-09-24 + */ #include "pandaFramework.h" #include "lodNode.h" @@ -29,7 +28,7 @@ create_lod_node(NodePath &models, const char *a, const char *b) { PT(PandaNode) frowney = loader.load_sync(b); PT(LODNode) lod = new FadeLODNode("lod"); - //PT(LODNode) lod = new LODNode("lod"); + // PT(LODNode) lod = new LODNode("lod"); if (!smiley.is_null()) { lod->add_child(smiley); lod->add_switch(10, 0); @@ -74,7 +73,7 @@ main(int argc, char *argv[]) { window2->enable_keyboard(); window2->setup_trackball(); framework.get_models().instance_to(window2->get_render()); - + window2->center_trackball(framework.get_models()); } diff --git a/panda/src/testbed/test_map.cxx b/panda/src/testbed/test_map.cxx index 54d5370e33..2c85f2c11a 100644 --- a/panda/src/testbed/test_map.cxx +++ b/panda/src/testbed/test_map.cxx @@ -1,16 +1,15 @@ -// Filename: test_map.cxx -// Created by: drose (29Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_map.cxx + * @author drose + * @date 2004-09-29 + */ #include "pandabase.h" #include "pmap.h" @@ -74,11 +73,10 @@ static const char * const sample_strings[] = { }; static const size_t num_sample_strings = sizeof(sample_strings) / sizeof(const char *); -void +void insert_fruit() { - // typedef pmap MapType; - // typedef pmap MapType; - // typedef phash_map MapType; + // typedef pmap MapType; typedef pmap MapType; + // typedef phash_map MapType; typedef phash_map MapType; MapType m; @@ -103,7 +101,7 @@ test_performance() { typedef Alpha KeyType; typedef phash_map MapType; - //typedef pmap MapType; + // typedef pmap MapType; MemoryUsage::is_tracking(); ClockObject *clock = ClockObject::get_global_clock(); @@ -133,7 +131,7 @@ test_performance() { for (int p = 0; p < initial_population; p++) { m->insert(MapType::value_type(samples[rand() & sample_mask], 0)); } - cerr << "map with " << m->size() + cerr << "map with " << m->size() << " elements uses " << MemoryUsage::get_current_cpp_size() << " bytes.\n"; @@ -154,9 +152,9 @@ test_performance() { } } -int +int main(int argc, char *argv[]) { - // insert_fruit(); + // insert_fruit(); test_performance(); return 0; diff --git a/panda/src/testbed/test_texmem.cxx b/panda/src/testbed/test_texmem.cxx index fba7b30c2e..76f6adfc57 100644 --- a/panda/src/testbed/test_texmem.cxx +++ b/panda/src/testbed/test_texmem.cxx @@ -1,16 +1,15 @@ -// Filename: test_texmem.cxx -// Created by: drose (03Sep02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_texmem.cxx + * @author drose + * @date 2002-09-03 + */ #include "pandaFramework.h" #include "cardMaker.h" @@ -39,18 +38,18 @@ event_T(const Event *, void *data) { return; } - // We are doing a new shift-t. Hide the normal models, and create a - // new bogus node to show the texture grid object. + // We are doing a new shift-t. Hide the normal models, and create a new + // bogus node to show the texture grid object. models.hide(); bogus_scene = render.attach_new_node("bogus"); - // Try to force a flush of the texture memory by making a scene with - // lots of bogus textures. + // Try to force a flush of the texture memory by making a scene with lots of + // bogus textures. static const int num_quads_side = 20; static const int tex_x_size = 256; static const int tex_y_size = 256; - cerr << "Loading " << num_quads_side * num_quads_side << " textures at " + cerr << "Loading " << num_quads_side * num_quads_side << " textures at " << tex_x_size << ", " << tex_y_size << "\n"; PNMImage white_center(tex_x_size / 4, tex_y_size / 4); @@ -79,7 +78,7 @@ event_T(const Event *, void *data) { bogus_image.copy_sub_image(white_center, (tex_x_size - white_center.get_x_size()) / 2, (tex_y_size - white_center.get_y_size()) / 2); - + PT(Texture) tex = new Texture; tex->set_minfilter(SamplerState::FT_linear_mipmap_linear); tex->load(bogus_image); diff --git a/panda/src/testbed/text_test.cxx b/panda/src/testbed/text_test.cxx index 61232d16d2..f0689940ad 100644 --- a/panda/src/testbed/text_test.cxx +++ b/panda/src/testbed/text_test.cxx @@ -1,16 +1,13 @@ -// Filename: text_test.cxx -// Created by: -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file text_test.cxx + */ #include "eventHandler.h" #include "chancfg.h" diff --git a/panda/src/text/config_text.cxx b/panda/src/text/config_text.cxx index f036b7112b..4790c5ecf7 100644 --- a/panda/src/text/config_text.cxx +++ b/panda/src/text/config_text.cxx @@ -1,16 +1,15 @@ -// Filename: config_text.cxx -// Created by: drose (02Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_text.cxx + * @author drose + * @date 2000-03-02 + */ #include "config_text.h" #include "staticTextFont.h" @@ -132,7 +131,7 @@ ConfigVariableInt text_embed_graphic_key wstring get_text_soft_hyphen_output() { static wstring *text_soft_hyphen_output = NULL; - static ConfigVariableString + static ConfigVariableString cv("text-soft-hyphen-output", "-", PRC_DESC("This is the string that is output, encoded in the default " "encoding, to represent the hyphen character that is " @@ -155,7 +154,7 @@ ConfigVariableDouble text_hyphen_ratio wstring get_text_never_break_before() { static wstring *text_never_break_before = NULL; - static ConfigVariableString + static ConfigVariableString cv("text-never-break-before", ",.-:?!;", PRC_DESC("This string represents a list of individual characters " "that should never appear at the beginning of a line " @@ -200,14 +199,12 @@ ConfigVariableEnum text_render_mode -//////////////////////////////////////////////////////////////////// -// Function: init_libtext -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libtext() { static bool initialized = false; diff --git a/panda/src/text/config_text.h b/panda/src/text/config_text.h index 279f05d083..5c50af6a52 100644 --- a/panda/src/text/config_text.h +++ b/panda/src/text/config_text.h @@ -1,16 +1,15 @@ -// Filename: config_text.h -// Created by: drose (02Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_text.h + * @author drose + * @date 2000-03-02 + */ #ifndef CONFIG_TEXT_H #define CONFIG_TEXT_H diff --git a/panda/src/text/default_font.cxx b/panda/src/text/default_font.cxx index 50bee08edf..9756c94cfc 100644 --- a/panda/src/text/default_font.cxx +++ b/panda/src/text/default_font.cxx @@ -1,68 +1,62 @@ -// Filename: default_font.cxx -// Created by: drose (31Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file default_font.cxx + * @author drose + * @date 2003-01-31 + */ #include "default_font.h" -// The binary data included here was generated from an existing font -// file via the utility program bin2c (defined in pandatool). It is -// used as the default font when no font file is specified by the -// user. +// The binary data included here was generated from an existing font file via +// the utility program bin2c (defined in pandatool). It is used as the +// default font when no font file is specified by the user. -// The particular font we use may come from either of two possible -// sources: +// The particular font we use may come from either of two possible sources: -// If we have the Freetype library available, we use persans.ttf, part -// of the "Perspective Sans" font family downloaded from -// http://www.fontsquirrel.com/fonts/Perspective-Sans, which appears -// to be freeware. -// -// If Freetype is not available, we use cmss12.bam, which was in turn -// generated from cmss12.720pk, and defines "Computer Modern Sans -// Serif", a basic Metafont-generated font supplied with TeX. This -// egg file, by the way, is also distributed with Panda in the models -// tree. +/* + * If we have the Freetype library available, we use persans.ttf, part of the + * "Perspective Sans" font family downloaded from http:www.fontsquirrel + * .comfontsPerspective-Sans, which appears to be freeware. If Freetype is + * not available, we use cmss12.bam, which was in turn generated from + * cmss12.720pk, and defines "Computer Modern Sans Serif", a basic Metafont- + * generated font supplied with TeX. This egg file, by the way, is also + * distributed with Panda in the models tree. + */ #if defined(COMPILE_IN_DEFAULT_FONT) && !defined(CPPPARSER) #ifdef HAVE_FREETYPE -// If we have FreeType available, include the ttf font; it's superior -// because it's dynamic. See above. +// If we have FreeType available, include the ttf font; it's superior because +// it's dynamic. See above. #include "persans.ttf_src.c" #elif defined(HAVE_ZLIB) -// If we don't have FreeType, we have to include the bam font, which -// is kind of bulky but at least we can compress it if we have zlib. +// If we don't have FreeType, we have to include the bam font, which is kind +// of bulky but at least we can compress it if we have zlib. // Regenerate this file with (cmss12.egg can be loaded from the models tree): -// egg2bam -rawtex -o cmss12.bam cmss12.egg -// pzip cmss12.bam -// bin2c -n default_font_data -o cmss12.bam.pz_src.c cmss12.bam.pz +// egg2bam -rawtex -o cmss12.bam cmss12.egg pzip cmss12.bam bin2c -n +// default_font_data -o cmss12.bam.pz_src.c cmss12.bam.pz #include "cmss12.bam.pz_src.c" #else -// If we don't even have zlib, just include the whole uncompressed bam -// file. +// If we don't even have zlib, just include the whole uncompressed bam file. // Regenerate this file with (cmss12.egg can be loaded from the models tree): -// egg2bam -rawtex -o cmss12.bam cmss12.egg -// bin2c -n default_font_data -o cmss12.bam_src.c cmss12.bam +// egg2bam -rawtex -o cmss12.bam cmss12.egg bin2c -n default_font_data -o +// cmss12.bam_src.c cmss12.bam #include "cmss12.bam_src.c" diff --git a/panda/src/text/default_font.h b/panda/src/text/default_font.h index 852f225bf2..b0474b9516 100644 --- a/panda/src/text/default_font.h +++ b/panda/src/text/default_font.h @@ -1,16 +1,15 @@ -// Filename: default_font.h -// Created by: drose (31Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file default_font.h + * @author drose + * @date 2003-01-31 + */ #ifndef DEFAULT_FONT_H #define DEFAULT_FONT_H @@ -25,4 +24,3 @@ extern EXPCL_PANDA_TEXT const int default_font_size; #endif // HAVE_FREETYPE && COMPILE_IN_DEFAULT_FONT && !CPPPARSER #endif - diff --git a/panda/src/text/dynamicTextFont.I b/panda/src/text/dynamicTextFont.I index 2739a40e26..16fd832efe 100644 --- a/panda/src/text/dynamicTextFont.I +++ b/panda/src/text/dynamicTextFont.I @@ -1,41 +1,32 @@ -// Filename: dynamicTextFont.I -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextFont.I + * @author drose + * @date 2002-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_name -// Access: Published -// Description: Disambiguates the get_name() method between that -// inherited from TextFont and that inherited from -// FreetypeFont. -//////////////////////////////////////////////////////////////////// +/** + * Disambiguates the get_name() method between that inherited from TextFont + * and that inherited from FreetypeFont. + */ INLINE const string &DynamicTextFont:: get_name() const { return TextFont::get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_point_size -// Access: Published -// Description: Sets the point size of the font. This controls the -// apparent size of the font onscreen. By convention, a -// 10 point font is about 1 screen unit high. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the point size of the font. This controls the apparent size of the + * font onscreen. By convention, a 10 point font is about 1 screen unit high. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool DynamicTextFont:: set_point_size(PN_stdfloat point_size) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -44,31 +35,25 @@ set_point_size(PN_stdfloat point_size) { return FreetypeFont::set_point_size(point_size); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_point_size -// Access: Published -// Description: Returns the point size of the font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the point size of the font. + */ INLINE PN_stdfloat DynamicTextFont:: get_point_size() const { return FreetypeFont::get_point_size(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_pixels_per_unit -// Access: Published -// Description: Set the resolution of the texture map, and hence the -// clarity of the resulting font. This sets the number -// of pixels in the texture map that are used for each -// onscreen unit. -// -// Setting this number larger results in an easier to -// read font, but at the cost of more texture memory. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Set the resolution of the texture map, and hence the clarity of the + * resulting font. This sets the number of pixels in the texture map that are + * used for each onscreen unit. + * + * Setting this number larger results in an easier to read font, but at the + * cost of more texture memory. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool DynamicTextFont:: set_pixels_per_unit(PN_stdfloat pixels_per_unit) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -77,34 +62,25 @@ set_pixels_per_unit(PN_stdfloat pixels_per_unit) { return FreetypeFont::set_pixels_per_unit(pixels_per_unit); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_pixels_per_unit -// Access: Published -// Description: Returns the resolution of the texture map. See -// set_pixels_per_unit(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the resolution of the texture map. See set_pixels_per_unit(). + */ INLINE PN_stdfloat DynamicTextFont:: get_pixels_per_unit() const { return FreetypeFont::get_pixels_per_unit(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_scale_factor -// Access: Published -// Description: Sets the factor by which the font is rendered larger -// by the FreeType library before being filtered down to -// its actual size in the texture as specified by -// set_pixels_per_unit(). This may be set to a number -// larger than 1.0 to improve the font's antialiasing -// (since FreeType doesn't really do a swell job of -// antialiasing by itself). There is some performance -// implication for setting this different than 1.0, but -// it is probably small. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the factor by which the font is rendered larger by the FreeType + * library before being filtered down to its actual size in the texture as + * specified by set_pixels_per_unit(). This may be set to a number larger + * than 1.0 to improve the font's antialiasing (since FreeType doesn't really + * do a swell job of antialiasing by itself). There is some performance + * implication for setting this different than 1.0, but it is probably small. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE bool DynamicTextFont:: set_scale_factor(PN_stdfloat scale_factor) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -113,32 +89,24 @@ set_scale_factor(PN_stdfloat scale_factor) { return FreetypeFont::set_scale_factor(scale_factor); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_scale_factor -// Access: Published -// Description: Returns the antialiasing scale factor. See -// set_scale_factor(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the antialiasing scale factor. See set_scale_factor(). + */ INLINE PN_stdfloat DynamicTextFont:: get_scale_factor() const { return FreetypeFont::get_scale_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_native_antialias -// Access: Published -// Description: Sets whether the Freetype library's built-in -// antialias mode is enabled. There are two unrelated -// ways to achieve antialiasing: with Freetype's native -// antialias mode, and with the use of a scale_factor -// greater than one. By default, both modes are -// enabled. -// -// At low resolutions, some fonts may do better with one -// mode or the other. In general, Freetype's native -// antialiasing will produce less blurry results, but -// may introduce more artifacts. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the Freetype library's built-in antialias mode is enabled. + * There are two unrelated ways to achieve antialiasing: with Freetype's + * native antialias mode, and with the use of a scale_factor greater than one. + * By default, both modes are enabled. + * + * At low resolutions, some fonts may do better with one mode or the other. + * In general, Freetype's native antialiasing will produce less blurry + * results, but may introduce more artifacts. + */ INLINE void DynamicTextFont:: set_native_antialias(bool native_antialias) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -147,276 +115,218 @@ set_native_antialias(bool native_antialias) { FreetypeFont::set_native_antialias(native_antialias); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_native_antialias -// Access: Published -// Description: Returns whether Freetype's built-in antialias mode is -// enabled. See set_native_antialias(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether Freetype's built-in antialias mode is enabled. See + * set_native_antialias(). + */ INLINE bool DynamicTextFont:: get_native_antialias() const { return FreetypeFont::get_native_antialias(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_font_pixel_size -// Access: Published -// Description: This is used to report whether the requested pixel -// size is being only approximated by a fixed-pixel-size -// font. This returns 0 in the normal case, in which a -// scalable font is used, or the fixed-pixel-size font -// has exactly the requested pixel size. -// -// If this returns non-zero, it is the pixel size of the -// font that we are using to approximate our desired -// size. -//////////////////////////////////////////////////////////////////// +/** + * This is used to report whether the requested pixel size is being only + * approximated by a fixed-pixel-size font. This returns 0 in the normal + * case, in which a scalable font is used, or the fixed-pixel-size font has + * exactly the requested pixel size. + * + * If this returns non-zero, it is the pixel size of the font that we are + * using to approximate our desired size. + */ INLINE int DynamicTextFont:: get_font_pixel_size() const { return FreetypeFont::get_font_pixel_size(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_line_height -// Access: Published -// Description: Returns the number of units high each line of text -// is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units high each line of text is. + */ INLINE PN_stdfloat DynamicTextFont:: get_line_height() const { return TextFont::get_line_height(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_space_advance -// Access: Published -// Description: Returns the number of units wide a space is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units wide a space is. + */ INLINE PN_stdfloat DynamicTextFont:: get_space_advance() const { return TextFont::get_space_advance(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_texture_margin -// Access: Published -// Description: Sets the number of pixels of padding that is added -// around the border of each glyph before adding it to -// the texture map. This reduces the bleed in from -// neighboring glyphs in the texture map. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of pixels of padding that is added around the border of + * each glyph before adding it to the texture map. This reduces the bleed in + * from neighboring glyphs in the texture map. + */ INLINE void DynamicTextFont:: set_texture_margin(int texture_margin) { _texture_margin = texture_margin; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_texture_margin -// Access: Published -// Description: Returns the number of pixels of padding that is added -// around the border of each glyph in the texture map. -// See set_texture_margin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels of padding that is added around the border of + * each glyph in the texture map. See set_texture_margin(). + */ INLINE int DynamicTextFont:: get_texture_margin() const { return _texture_margin; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_poly_margin -// Access: Published -// Description: Sets the number of pixels of padding that is included -// around each glyph in the generated polygons. This -// helps prevent the edges of the glyphs from being cut -// off at small minifications. It is not related to the -// amount of extra pixels reserved in the texture map -// (but it should be set somewhat smaller than this -// number, which is controlled by set_texture_margin(), -// to prevent bleed-in from neighboring letters in the -// texture). -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of pixels of padding that is included around each glyph in + * the generated polygons. This helps prevent the edges of the glyphs from + * being cut off at small minifications. It is not related to the amount of + * extra pixels reserved in the texture map (but it should be set somewhat + * smaller than this number, which is controlled by set_texture_margin(), to + * prevent bleed-in from neighboring letters in the texture). + */ INLINE void DynamicTextFont:: set_poly_margin(PN_stdfloat poly_margin) { _poly_margin = poly_margin; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_poly_margin -// Access: Published -// Description: Returns the number of pixels of padding that is -// included around each glyph in the generated polygons. -// See set_poly_margin(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pixels of padding that is included around each glyph + * in the generated polygons. See set_poly_margin(). + */ INLINE PN_stdfloat DynamicTextFont:: get_poly_margin() const { return _poly_margin; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_page_size -// Access: Published -// Description: Sets the x, y size of the textures that are created -// for the DynamicTextFont. -//////////////////////////////////////////////////////////////////// +/** + * Sets the x, y size of the textures that are created for the + * DynamicTextFont. + */ INLINE void DynamicTextFont:: set_page_size(const LVecBase2i &page_size) { _page_size = page_size; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_page_size -// Access: Published -// Description: Sets the x, y size of the textures that are created -// for the DynamicTextFont. -//////////////////////////////////////////////////////////////////// +/** + * Sets the x, y size of the textures that are created for the + * DynamicTextFont. + */ INLINE void DynamicTextFont:: set_page_size(int x_size, int y_size) { _page_size.set(x_size, y_size); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_page_size -// Access: Published -// Description: Returns the size of the textures that are created -// for the DynamicTextFont. See set_page_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the textures that are created for the DynamicTextFont. + * See set_page_size(). + */ INLINE const LVecBase2i &DynamicTextFont:: get_page_size() const { return _page_size; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_page_x_size -// Access: Published -// Description: Returns the x size of the textures that are created -// for the DynamicTextFont. See set_page_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the x size of the textures that are created for the + * DynamicTextFont. See set_page_size(). + */ INLINE int DynamicTextFont:: get_page_x_size() const { return _page_size.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_page_y_size -// Access: Published -// Description: Returns the y size of the textures that are created -// for the DynamicTextFont. See set_page_size(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the y size of the textures that are created for the + * DynamicTextFont. See set_page_size(). + */ INLINE int DynamicTextFont:: get_page_y_size() const { return _page_size.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_minfilter -// Access: Published -// Description: Sets the filter type used when minimizing the -// textures created for this font. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filter type used when minimizing the textures created for this + * font. + */ INLINE void DynamicTextFont:: set_minfilter(SamplerState::FilterType filter) { _minfilter = filter; update_filters(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_minfilter -// Access: Published -// Description: Returns the filter type used when minimizing the -// textures created for this font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter type used when minimizing the textures created for this + * font. + */ INLINE SamplerState::FilterType DynamicTextFont:: get_minfilter() const { return _minfilter; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_magfilter -// Access: Published -// Description: Sets the filter type used when enlarging the -// textures created for this font. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filter type used when enlarging the textures created for this + * font. + */ INLINE void DynamicTextFont:: set_magfilter(SamplerState::FilterType filter) { _magfilter = filter; update_filters(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_magfilter -// Access: Published -// Description: Returns the filter type used when enlarging the -// textures created for this font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filter type used when enlarging the textures created for this + * font. + */ INLINE SamplerState::FilterType DynamicTextFont:: get_magfilter() const { return _magfilter; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_anisotropic_degree -// Access: Published -// Description: Enables or disables anisotropic filtering on the -// textures created for this font. The default value is -// specified by the text-anisotropic-degree variable. -// See Texture::set_anisotropic_degree(). -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables anisotropic filtering on the textures created for this + * font. The default value is specified by the text-anisotropic-degree + * variable. See Texture::set_anisotropic_degree(). + */ INLINE void DynamicTextFont:: set_anisotropic_degree(int anisotropic_degree) { _anisotropic_degree = anisotropic_degree; update_filters(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_anisotropic_degree -// Access: Published -// Description: Returns the current anisotropic degree for textures -// created for this font. See set_anisotropic_degree(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current anisotropic degree for textures created for this font. + * See set_anisotropic_degree(). + */ INLINE int DynamicTextFont:: get_anisotropic_degree() const { return _anisotropic_degree; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_render_mode -// Access: Published -// Description: Specifies the way the glyphs on this particular font -// are generated. The default is RM_texture, which is -// the only mode supported for bitmap fonts. Other modes -// are possible for most modern fonts. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the way the glyphs on this particular font are generated. The + * default is RM_texture, which is the only mode supported for bitmap fonts. + * Other modes are possible for most modern fonts. + */ INLINE void DynamicTextFont:: set_render_mode(DynamicTextFont::RenderMode render_mode) { _render_mode = render_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_render_mode -// Access: Published -// Description: Returns the way the glyphs on this particular font -// are generated. See set_render_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the way the glyphs on this particular font are generated. See + * set_render_mode(). + */ INLINE DynamicTextFont::RenderMode DynamicTextFont:: get_render_mode() const { return _render_mode; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_fg -// Access: Published -// Description: Changes the color of the foreground pixels of the -// font as they are rendered into the font texture. The -// default is (1, 1, 1, 1), or opaque white, which -// allows text created with the font to be colored -// individually. Normally, you would not change this -// unless you really need a particular color effect to -// appear in the font itself. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the color of the foreground pixels of the font as they are rendered + * into the font texture. The default is (1, 1, 1, 1), or opaque white, which + * allows text created with the font to be colored individually. Normally, + * you would not change this unless you really need a particular color effect + * to appear in the font itself. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE void DynamicTextFont:: set_fg(const LColor &fg) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -426,38 +336,29 @@ set_fg(const LColor &fg) { determine_tex_format(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_fg -// Access: Published -// Description: Returns the color of the foreground pixels of the -// font as they are rendered into the font texture. -// See set_fg(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of the foreground pixels of the font as they are rendered + * into the font texture. See set_fg(). + */ INLINE const LColor &DynamicTextFont:: get_fg() const { return _fg; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_bg -// Access: Published -// Description: Changes the color of the background pixels of the -// font as they are rendered into the font texture. The -// default is (1, 1, 1, 0), or transparent white, which -// allows text created with the font to be colored -// individually. (Note that it should not generally be -// (0, 0, 0, 0), which would tend to bleed into the -// foreground color, unless you have also specified a -// outline color of (0, 0, 0, 1)) . -// -// Normally, you would not change this unless you really -// need a particular color effect to appear in the font -// itself. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the color of the background pixels of the font as they are rendered + * into the font texture. The default is (1, 1, 1, 0), or transparent white, + * which allows text created with the font to be colored individually. (Note + * that it should not generally be (0, 0, 0, 0), which would tend to bleed + * into the foreground color, unless you have also specified a outline color + * of (0, 0, 0, 1)) . + * + * Normally, you would not change this unless you really need a particular + * color effect to appear in the font itself. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE void DynamicTextFont:: set_bg(const LColor &bg) { // If this assertion fails, you didn't call clear() first. RTFM. @@ -467,40 +368,30 @@ set_bg(const LColor &bg) { determine_tex_format(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_bg -// Access: Published -// Description: Returns the color of the background pixels of the -// font as they are rendered into the font texture. -// See set_bg(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of the background pixels of the font as they are rendered + * into the font texture. See set_bg(). + */ INLINE const LColor &DynamicTextFont:: get_bg() const { return _bg; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::set_outline -// Access: Published -// Description: Sets up the font to have an outline around each font -// letter. This is achieved via a Gaussian post-process -// as each letter is generated; there is some runtime -// cost for this effect, but it is minimal as each -// letter is normally generated only once and then -// cached. -// -// The color is the desired color of the outline, width -// is the number of points beyond the letter that the -// outline extends (a typical font is 10 points high), -// and feather is a number in the range 0.0 .. 1.0 that -// controls the softness of the outline. Set the width -// to 0.0 to disable the outline. -// -// This should only be called before any characters have -// been requested out of the font, or immediately after -// calling clear(). -//////////////////////////////////////////////////////////////////// +/** + * Sets up the font to have an outline around each font letter. This is + * achieved via a Gaussian post-process as each letter is generated; there is + * some runtime cost for this effect, but it is minimal as each letter is + * normally generated only once and then cached. + * + * The color is the desired color of the outline, width is the number of + * points beyond the letter that the outline extends (a typical font is 10 + * points high), and feather is a number in the range 0.0 .. 1.0 that controls + * the softness of the outline. Set the width to 0.0 to disable the outline. + * + * This should only be called before any characters have been requested out of + * the font, or immediately after calling clear(). + */ INLINE void DynamicTextFont:: set_outline(const LColor &outline_color, PN_stdfloat outline_width, PN_stdfloat outline_feather) { @@ -513,49 +404,37 @@ set_outline(const LColor &outline_color, PN_stdfloat outline_width, determine_tex_format(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_outline_color -// Access: Published -// Description: Returns the color of the outline pixels of the -// font as they are rendered into the font texture. -// See set_outline(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the color of the outline pixels of the font as they are rendered + * into the font texture. See set_outline(). + */ INLINE const LColor &DynamicTextFont:: get_outline_color() const { return _outline_color; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_outline_width -// Access: Published -// Description: Returns the width of the outline pixels of the -// font, as the number of points beyond each letter. -// See set_outline(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the outline pixels of the font, as the number of + * points beyond each letter. See set_outline(). + */ INLINE PN_stdfloat DynamicTextFont:: get_outline_width() const { return _outline_width; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_outline_feather -// Access: Published -// Description: Returns the softness of the outline pixels of the -// font, as a value in the range 0.0 to 1.0. -// See set_outline(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the softness of the outline pixels of the font, as a value in the + * range 0.0 to 1.0. See set_outline(). + */ INLINE PN_stdfloat DynamicTextFont:: get_outline_feather() const { return _outline_feather; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_tex_format -// Access: Published -// Description: Returns the texture format used to render the -// individual pages. This is set automatically -// according to the colors selected. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture format used to render the individual pages. This is + * set automatically according to the colors selected. + */ INLINE Texture::Format DynamicTextFont:: get_tex_format() const { return _tex_format; diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 9824de0f41..6143db7f61 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -1,23 +1,22 @@ -// Filename: dynamicTextFont.cxx -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextFont.cxx + * @author drose + * @date 2002-02-08 + */ #include "dynamicTextFont.h" #ifdef HAVE_FREETYPE #undef interface // I don't know where this symbol is defined, but it interferes with FreeType. -#include FT_OUTLINE_H +#include FT_OUTLINE_H #ifdef FT_BBOX_H #include FT_BBOX_H #endif @@ -40,22 +39,18 @@ #include "renderState.h" #include "string_utils.h" #include "triangulator.h" -//#include "renderModeAttrib.h" -//#include "antialiasAttrib.h" +// #include "renderModeAttrib.h" #include "antialiasAttrib.h" #include "colorAttrib.h" #include "textureAttrib.h" TypeHandle DynamicTextFont::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::Constructor -// Access: Published -// Description: The constructor expects the name of some font file -// that FreeType can read, along with face_index, -// indicating which font within the file to load -// (usually 0). -//////////////////////////////////////////////////////////////////// +/** + * The constructor expects the name of some font file that FreeType can read, + * along with face_index, indicating which font within the file to load + * (usually 0). + */ DynamicTextFont:: DynamicTextFont(const Filename &font_filename, int face_index) { initialize(); @@ -74,13 +69,10 @@ DynamicTextFont(const Filename &font_filename, int face_index) { _needs_image_processing = false; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::Constructor -// Access: Published -// Description: This constructor accepts a table of data representing -// the font file, loaded from some source other than a -// filename on disk. -//////////////////////////////////////////////////////////////////// +/** + * This constructor accepts a table of data representing the font file, loaded + * from some source other than a filename on disk. + */ DynamicTextFont:: DynamicTextFont(const char *font_data, int data_length, int face_index) { initialize(); @@ -99,11 +91,9 @@ DynamicTextFont(const char *font_data, int data_length, int face_index) { _needs_image_processing = false; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DynamicTextFont:: DynamicTextFont(const DynamicTextFont ©) : TextFont(copy), @@ -127,63 +117,48 @@ DynamicTextFont(const DynamicTextFont ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DynamicTextFont:: ~DynamicTextFont() { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::make_copy -// Access: Published -// Description: Returns a new copy of the same font. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new copy of the same font. + */ PT(TextFont) DynamicTextFont:: make_copy() const { return new DynamicTextFont(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_num_pages -// Access: Published -// Description: Returns the number of pages associated with the font. -// Initially, the font has zero pages; when the first -// piece of text is rendered with the font, it will add -// additional pages as needed. Each page is a Texture -// object that contains the images for each of the -// glyphs currently in use somewhere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of pages associated with the font. Initially, the font + * has zero pages; when the first piece of text is rendered with the font, it + * will add additional pages as needed. Each page is a Texture object that + * contains the images for each of the glyphs currently in use somewhere. + */ int DynamicTextFont:: get_num_pages() const { return _pages.size(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_page -// Access: Published -// Description: Returns the nth page associated with the font. -// Initially, the font has zero pages; when the first -// piece of text is rendered with the font, it will add -// additional pages as needed. Each page is a Texture -// object that contains the images for each of the -// glyphs currently in use somewhere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth page associated with the font. Initially, the font has + * zero pages; when the first piece of text is rendered with the font, it will + * add additional pages as needed. Each page is a Texture object that + * contains the images for each of the glyphs currently in use somewhere. + */ DynamicTextPage *DynamicTextFont:: get_page(int n) const { nassertr(n >= 0 && n < (int)_pages.size(), (DynamicTextPage *)NULL); return _pages[n]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::garbage_collect -// Access: Published -// Description: Removes all of the glyphs from the font that are no -// longer being used by any Geoms. Returns the number -// of glyphs removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the glyphs from the font that are no longer being used by + * any Geoms. Returns the number of glyphs removed. + */ int DynamicTextFont:: garbage_collect() { int removed_count = 0; @@ -213,19 +188,15 @@ garbage_collect() { return removed_count; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::clear -// Access: Published -// Description: Drops all the glyphs out of the cache and frees any -// association with any previously-generated pages. -// -// Calling this frequently can result in wasted texture -// memory, as any previously rendered text will still -// keep a pointer to the old, previously-generated -// pages. As long as the previously rendered text -// remains around, the old pages will also remain -// around. -//////////////////////////////////////////////////////////////////// +/** + * Drops all the glyphs out of the cache and frees any association with any + * previously-generated pages. + * + * Calling this frequently can result in wasted texture memory, as any + * previously rendered text will still keep a pointer to the old, previously- + * generated pages. As long as the previously rendered text remains around, + * the old pages will also remain around. + */ void DynamicTextFont:: clear() { _cache.clear(); @@ -233,34 +204,32 @@ clear() { _empty_glyphs.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DynamicTextFont:: write(ostream &out, int indent_level) const { static const int max_glyph_name = 1024; char glyph_name[max_glyph_name]; indent(out, indent_level) - << "DynamicTextFont " << get_name() << ", " + << "DynamicTextFont " << get_name() << ", " << get_num_pages() << " pages, " << _cache.size() << " glyphs:\n"; Cache::const_iterator ci; for (ci = _cache.begin(); ci != _cache.end(); ++ci) { int glyph_index = (*ci).first; const TextGlyph *glyph = (*ci).second; - indent(out, indent_level + 2) + indent(out, indent_level + 2) << glyph_index; FT_Face face = acquire_face(); if (FT_HAS_GLYPH_NAMES(face)) { - int error = FT_Get_Glyph_Name(face, glyph_index, + int error = FT_Get_Glyph_Name(face, glyph_index, glyph_name, max_glyph_name); - // Some fonts, notably MS Mincho, claim to have glyph names but - // only report ".notdef" as the name of each glyph. Thanks. + // Some fonts, notably MS Mincho, claim to have glyph names but only + // report ".notdef" as the name of each glyph. Thanks. if (!error && strcmp(glyph_name, ".notdef") != 0) { out << " (" << glyph_name << ")"; } @@ -271,17 +240,13 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_glyph -// Access: Public, Virtual -// Description: Gets the glyph associated with the given character -// code, as well as an optional scaling parameter that -// should be applied to the glyph's geometry and advance -// parameters. Returns true if the glyph exists, false -// if it does not. Even if the return value is false, -// the value for glyph might be filled in with a -// printable glyph. -//////////////////////////////////////////////////////////////////// +/** + * Gets the glyph associated with the given character code, as well as an + * optional scaling parameter that should be applied to the glyph's geometry + * and advance parameters. Returns true if the glyph exists, false if it does + * not. Even if the return value is false, the value for glyph might be + * filled in with a printable glyph. + */ bool DynamicTextFont:: get_glyph(int character, CPT(TextGlyph) &glyph) { if (!_is_valid) { @@ -314,12 +279,9 @@ get_glyph(int character, CPT(TextGlyph) &glyph) { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::initialize -// Access: Private -// Description: Called from both constructors to set up some initial -// values. -//////////////////////////////////////////////////////////////////// +/** + * Called from both constructors to set up some initial values. + */ void DynamicTextFont:: initialize() { _texture_margin = text_texture_margin; @@ -327,14 +289,13 @@ initialize() { _page_size.set(text_page_size[0], text_page_size[1]); // We don't necessarily want to use mipmaps, since we don't want to - // regenerate those every time the texture changes, but we probably - // do want at least linear filtering. Use whatever the Configrc - // file suggests. + // regenerate those every time the texture changes, but we probably do want + // at least linear filtering. Use whatever the Configrc file suggests. _minfilter = text_minfilter; _magfilter = text_magfilter; - // Anisotropic filtering can help the look of the text, and doesn't - // require generating mipmaps, but does require hardware support. + // Anisotropic filtering can help the look of the text, and doesn't require + // generating mipmaps, but does require hardware support. _anisotropic_degree = text_anisotropic_degree; _render_mode = text_render_mode; @@ -343,13 +304,10 @@ initialize() { _preferred_page = 0; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::update_filters -// Access: Private -// Description: Reapplies all current filter settings to all of the -// pages. This is normally called whenever the filter -// settings change. -//////////////////////////////////////////////////////////////////// +/** + * Reapplies all current filter settings to all of the pages. This is + * normally called whenever the filter settings change. + */ void DynamicTextFont:: update_filters() { Pages::iterator pi; @@ -361,13 +319,10 @@ update_filters() { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::determine_tex_format -// Access: Private -// Description: Examines the _fg, _bg, and _outline colors to -// determine the appropriate format for the font pages, -// including the outline properties. -//////////////////////////////////////////////////////////////////// +/** + * Examines the _fg, _bg, and _outline colors to determine the appropriate + * format for the font pages, including the outline properties. + */ void DynamicTextFont:: determine_tex_format() { nassertv(get_num_pages() == 0); @@ -393,7 +348,7 @@ determine_tex_format() { needs_grayscale = true; } - if (_fg[3] != 1.0f || _bg[3] != 1.0f || + if (_fg[3] != 1.0f || _bg[3] != 1.0f || (_has_outline && (_outline_color[3] != 1.0f))) { // fg, bg, and outline contain non-opaque alpha values. needs_alpha = true; @@ -415,11 +370,11 @@ determine_tex_format() { if (needs_alpha) { _tex_format = Texture::F_alpha; - if (!_has_outline && + if (!_has_outline && _fg == LColor(1.0f, 1.0f, 1.0f, 1.0f) && _bg == LColor(1.0f, 1.0f, 1.0f, 0.0f)) { - // This is the standard font color. It can be copied directly - // without any need for special processing. + // This is the standard font color. It can be copied directly without + // any need for special processing. _needs_image_processing = false; } @@ -430,14 +385,11 @@ determine_tex_format() { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::make_glyph -// Access: Private -// Description: Slots a space in the texture map for the new -// character and renders the glyph, returning the -// newly-created TextGlyph object, or NULL if the -// glyph cannot be created for some reason. -//////////////////////////////////////////////////////////////////// +/** + * Slots a space in the texture map for the new character and renders the + * glyph, returning the newly-created TextGlyph object, or NULL if the glyph + * cannot be created for some reason. + */ CPT(TextGlyph) DynamicTextFont:: make_glyph(int character, FT_Face face, int glyph_index) { if (!load_glyph(face, glyph_index, false)) { @@ -448,18 +400,18 @@ make_glyph(int character, FT_Face face, int glyph_index) { FT_Bitmap &bitmap = slot->bitmap; if ((bitmap.width == 0 || bitmap.rows == 0) && (glyph_index == 0)) { - // Here's a special case: a glyph_index of 0 means an invalid - // glyph. Some fonts define a symbol to represent an invalid - // glyph, but if that symbol is the empty bitmap, we return NULL, - // and use Panda's invalid glyph in its place. We do this to - // guarantee that every invalid glyph is visible as *something*. + // Here's a special case: a glyph_index of 0 means an invalid glyph. Some + // fonts define a symbol to represent an invalid glyph, but if that symbol + // is the empty bitmap, we return NULL, and use Panda's invalid glyph in + // its place. We do this to guarantee that every invalid glyph is visible + // as *something*. return NULL; } PN_stdfloat advance = slot->advance.x / 64.0; advance /= _font_pixels_per_unit; - if (_render_mode != RM_texture && + if (_render_mode != RM_texture && slot->format == ft_glyph_format_outline) { // Re-stroke the glyph to make it an outline glyph. /* @@ -484,8 +436,7 @@ make_glyph(int character, FT_Face face, int glyph_index) { memcpy(&slot->outline, &border, sizeof(border)); */ - // Ask FreeType to extract the contours out of the outline - // description. + // Ask FreeType to extract the contours out of the outline description. decompose_outline(slot->outline); PT(TextGlyph) glyph = @@ -584,16 +535,15 @@ make_glyph(int character, FT_Face face, int glyph_index) { } else if (_tex_pixels_per_unit == _font_pixels_per_unit && !_needs_image_processing) { - // If the bitmap produced from the font doesn't require scaling - // or any other processing before it goes to the texture, we can - // just copy it directly into the texture. + // If the bitmap produced from the font doesn't require scaling or any + // other processing before it goes to the texture, we can just copy it + // directly into the texture. glyph = slot_glyph(character, bitmap.width, bitmap.rows, advance); copy_bitmap_to_texture(bitmap, glyph); } else { - // Otherwise, we need to copy to a PNMImage first, so we can - // scale it and/or process it; and then copy it to the texture - // from there. + // Otherwise, we need to copy to a PNMImage first, so we can scale it + // andor process it; and then copy it to the texture from there. tex_x_size /= _scale_factor; tex_y_size /= _scale_factor; int int_x_size = (int)ceil(tex_x_size); @@ -647,9 +597,9 @@ make_glyph(int character, FT_Face face, int glyph_index) { origin_x + tex_x_size / _tex_pixels_per_unit + tex_poly_margin, origin_y + tex_poly_margin); - // And the corresponding corners in UV units. We add 0.5f to center - // the UV in the middle of its texel, to minimize roundoff errors - // when we are close to 1-to-1 pixel size. + // And the corresponding corners in UV units. We add 0.5f to center the + // UV in the middle of its texel, to minimize roundoff errors when we + // are close to 1-to-1 pixel size. LVecBase2i page_size = page->get_size(); LVecBase4 texcoords( ((PN_stdfloat)(glyph->_x - _poly_margin) + 0.5f) / page_size[0], @@ -669,35 +619,32 @@ make_glyph(int character, FT_Face face, int glyph_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::copy_bitmap_to_texture -// Access: Private -// Description: Copies a bitmap as rendered by FreeType directly into -// the texture memory image for the indicated glyph, -// without any scaling of pixels. -//////////////////////////////////////////////////////////////////// +/** + * Copies a bitmap as rendered by FreeType directly into the texture memory + * image for the indicated glyph, without any scaling of pixels. + */ void DynamicTextFont:: copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { if (bitmap.pixel_mode == ft_pixel_mode_grays && bitmap.num_grays == 256) { - // This is the easy case: we can memcpy the rendered glyph - // directly into our texture image, one row at a time. + // This is the easy case: we can memcpy the rendered glyph directly into + // our texture image, one row at a time. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { - + unsigned char *texture_row = glyph->get_row(yi); nassertv(texture_row != (unsigned char *)NULL); memcpy(texture_row, buffer_row, bitmap.width); buffer_row += bitmap.pitch; } - + } else if (bitmap.pixel_mode == ft_pixel_mode_mono) { - // This is a little bit more work: we have to expand the - // one-bit-per-pixel bitmap into a one-byte-per-pixel texture. + // This is a little bit more work: we have to expand the one-bit-per-pixel + // bitmap into a one-byte-per-pixel texture. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); nassertv(texture_row != (unsigned char *)NULL); - + int bit = 0x80; unsigned char *b = buffer_row; for (int xi = 0; xi < bitmap.width; xi++) { @@ -712,14 +659,14 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { bit = 0x80; } } - + buffer_row += bitmap.pitch; } - - + + } else if (bitmap.pixel_mode == ft_pixel_mode_grays) { - // Here we must expand a grayscale pixmap with n levels of gray - // into our 256-level texture. + // Here we must expand a grayscale pixmap with n levels of gray into our + // 256-level texture. unsigned char *buffer_row = bitmap.buffer; for (int yi = 0; yi < bitmap.rows; yi++) { unsigned char *texture_row = glyph->get_row(yi); @@ -729,24 +676,21 @@ copy_bitmap_to_texture(const FT_Bitmap &bitmap, DynamicTextGlyph *glyph) { } buffer_row += bitmap.pitch; } - + } else { text_cat.error() << "Unexpected pixel mode in bitmap: " << (int)bitmap.pixel_mode << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::copy_pnmimage_to_texture -// Access: Private -// Description: Copies a bitmap stored in a PNMImage into -// the texture memory image for the indicated glyph. -//////////////////////////////////////////////////////////////////// +/** + * Copies a bitmap stored in a PNMImage into the texture memory image for the + * indicated glyph. + */ void DynamicTextFont:: copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { if (!_needs_image_processing) { - // Copy the image directly into the alpha component of the - // texture. + // Copy the image directly into the alpha component of the texture. nassertv(glyph->_page->get_num_components() == 1); for (int yi = 0; yi < image.get_y_size(); yi++) { unsigned char *texture_row = glyph->get_row(yi); @@ -764,9 +708,9 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { outline.gaussian_filter_from(outline_pixels * 0.707, image); // Filter the resulting outline to make a harder edge. Square - // _outline_feather first to make the range more visually linear - // (this approximately compensates for the Gaussian falloff of - // the feathered edge). + // _outline_feather first to make the range more visually linear (this + // approximately compensates for the Gaussian falloff of the feathered + // edge). PN_stdfloat f = _outline_feather * _outline_feather; for (int yi = 0; yi < outline.get_y_size(); yi++) { @@ -788,21 +732,18 @@ copy_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph) { blend_pnmimage_to_texture(outline, glyph, _outline_color); } - // Colorize the image as we copy it in. This assumes the previous - // color at this part of the texture was already initialized to - // the background color. + // Colorize the image as we copy it in. This assumes the previous color + // at this part of the texture was already initialized to the background + // color. blend_pnmimage_to_texture(image, glyph, _fg); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::blend_pnmimage_to_texture -// Access: Private -// Description: Blends the PNMImage into the appropriate part of the -// texture, where 0.0 in the image indicates the color -// remains the same, and 1.0 indicates the color is -// assigned the indicated foreground color. -//////////////////////////////////////////////////////////////////// +/** + * Blends the PNMImage into the appropriate part of the texture, where 0.0 in + * the image indicates the color remains the same, and 1.0 indicates the color + * is assigned the indicated foreground color. + */ void DynamicTextFont:: blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, const LColor &fg) { @@ -873,15 +814,12 @@ blend_pnmimage_to_texture(const PNMImage &image, DynamicTextGlyph *glyph, } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::slot_glyph -// Access: Private -// Description: Chooses a page that will have room for a glyph of the -// indicated size (after expanding the indicated size by -// the current margin). Returns the newly-allocated -// glyph on the chosen page; the glyph has not been -// filled in yet except with its size. -//////////////////////////////////////////////////////////////////// +/** + * Chooses a page that will have room for a glyph of the indicated size (after + * expanding the indicated size by the current margin). Returns the newly- + * allocated glyph on the chosen page; the glyph has not been filled in yet + * except with its size. + */ DynamicTextGlyph *DynamicTextFont:: slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { // Increase the indicated size by the current margin. @@ -889,10 +827,10 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { y_size += _texture_margin * 2; if (!_pages.empty()) { - // Start searching on the preferred page. That way, we'll fill up - // the preferred page first, and we can gradually rotate this page - // around; it keeps us from spending too much time checking - // already-filled pages for space. + // Start searching on the preferred page. That way, we'll fill up the + // preferred page first, and we can gradually rotate this page around; it + // keeps us from spending too much time checking already-filled pages for + // space. _preferred_page = _preferred_page % _pages.size(); int pi = _preferred_page; @@ -900,8 +838,8 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { DynamicTextPage *page = _pages[pi]; DynamicTextGlyph *glyph = page->slot_glyph(character, x_size, y_size, _texture_margin, advance); if (glyph != (DynamicTextGlyph *)NULL) { - // Once we found a page to hold the glyph, that becomes our - // new preferred page. + // Once we found a page to hold the glyph, that becomes our new + // preferred page. _preferred_page = pi; return glyph; } @@ -918,15 +856,14 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { } while (pi != _preferred_page); } - // All pages are filled. Can we free up space by removing some old - // glyphs? + // All pages are filled. Can we free up space by removing some old glyphs? if (garbage_collect() != 0) { // Yes, we just freed up some space. Try once more, recursively. return slot_glyph(character, x_size, y_size, advance); } else { - // No good; all recorded glyphs are actually in use. We need to - // make a new page. + // No good; all recorded glyphs are actually in use. We need to make a + // new page. _preferred_page = _pages.size(); PT(DynamicTextPage) page = new DynamicTextPage(this, _preferred_page); _pages.push_back(page); @@ -934,12 +871,10 @@ slot_glyph(int character, int x_size, int y_size, PN_stdfloat advance) { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::render_wireframe_contours -// Access: Private -// Description: Converts from the _contours list to an actual glyph -// geometry, as a wireframe render. -//////////////////////////////////////////////////////////////////// +/** + * Converts from the _contours list to an actual glyph geometry, as a + * wireframe render. + */ void DynamicTextFont:: render_wireframe_contours(TextGlyph *glyph) { PT(GeomVertexData) vdata = new GeomVertexData @@ -967,12 +902,10 @@ render_wireframe_contours(TextGlyph *glyph) { _contours.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::render_polygon_contours -// Access: Private -// Description: Converts from the _contours list to an actual glyph -// geometry, as a polygon render. -//////////////////////////////////////////////////////////////////// +/** + * Converts from the _contours list to an actual glyph geometry, as a polygon + * render. + */ void DynamicTextFont:: render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { PT(GeomVertexData) vdata = new GeomVertexData @@ -987,11 +920,11 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { Contours::iterator ci; if (face) { - // First, build up the list of vertices for the face, and - // determine which contours are solid and which are holes. + // First, build up the list of vertices for the face, and determine which + // contours are solid and which are holes. for (ci = _contours.begin(); ci != _contours.end(); ++ci) { Contour &contour = (*ci); - + t.clear_polygon(); contour._start_vertex = t.get_num_vertices(); for (size_t i = 0; i < contour._points.size() - 1; ++i) { @@ -1001,20 +934,20 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { int vi = t.add_vertex(p[0], p[1]); t.add_polygon_vertex(vi); } - + contour._is_solid = t.is_left_winding(); } // Now go back and generate the actual triangles for the face. for (ci = _contours.begin(); ci != _contours.end(); ++ci) { const Contour &contour = (*ci); - + if (contour._is_solid && !contour._points.empty()) { t.clear_polygon(); for (size_t i = 0; i < contour._points.size() - 1; ++i) { t.add_polygon_vertex(contour._start_vertex + i); } - + // Also add all the holes to each polygon. Contours::iterator cj; for (cj = _contours.begin(); cj != _contours.end(); ++cj) { @@ -1026,7 +959,7 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { } } } - + t.triangulate(); int num_triangles = t.get_num_triangles(); for (int ti = 0; ti < num_triangles; ++ti) { @@ -1040,10 +973,9 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { } if (extrude) { - // If we're generating extruded geometry (polygons along the - // edges, down the y axis), generate them now. These are pretty - // easy, but we need to create more vertices--they don't share the - // same normals. + // If we're generating extruded geometry (polygons along the edges, down + // the y axis), generate them now. These are pretty easy, but we need to + // create more vertices--they don't share the same normals. for (ci = _contours.begin(); ci != _contours.end(); ++ci) { const Contour &contour = (*ci); Points::const_iterator pi; @@ -1073,8 +1005,8 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { } if (i != contour._points.size() - 1 && !t_in.almost_equal(t_out)) { - // If the out tangent is different from the in tangent, we - // need to store new vertices for the next quad. + // If the out tangent is different from the in tangent, we need to + // store new vertices for the next quad. LVector3 n_out(t_out[1], 0.0f, -t_out[0]); vertex.add_data3(p[0], 1.0f, p[1]); vertex.add_data3(p[0], 0.0f, p[1]); @@ -1100,13 +1032,13 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { // Now go back and generate the actual triangles for the face. for (ci = _contours.begin(); ci != _contours.end(); ++ci) { const Contour &contour = (*ci); - + if (contour._is_solid && !contour._points.empty()) { t.clear_polygon(); for (size_t i = 0; i < contour._points.size() - 1; ++i) { t.add_polygon_vertex(contour._start_vertex + i); } - + // Also add all the holes to each polygon. Contours::iterator cj; for (cj = _contours.begin(); cj != _contours.end(); ++cj) { @@ -1118,7 +1050,7 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { } } } - + t.triangulate(); int num_triangles = t.get_num_triangles(); for (int ti = 0; ti < num_triangles; ++ti) { @@ -1133,8 +1065,9 @@ render_polygon_contours(TextGlyph *glyph, bool face, bool extrude) { } glyph->set_geom(vdata, tris, RenderState::make_empty()); - // glyph->set_geom(vdata, tris, RenderState::make(RenderModeAttrib::make(RenderModeAttrib::M_wireframe))); - // glyph->set_geom(vdata, tris, RenderState::make(AntialiasAttrib::make(AntialiasAttrib::M_auto))); + // glyph->set_geom(vdata, tris, RenderState::make(RenderModeAttrib::make(Ren + // derModeAttrib::M_wireframe))); glyph->set_geom(vdata, tris, + // RenderState::make(AntialiasAttrib::make(AntialiasAttrib::M_auto))); _contours.clear(); } diff --git a/panda/src/text/dynamicTextFont.h b/panda/src/text/dynamicTextFont.h index 3ce9ee4cc3..773f3a7467 100644 --- a/panda/src/text/dynamicTextFont.h +++ b/panda/src/text/dynamicTextFont.h @@ -1,16 +1,15 @@ -// Filename: dynamicTextFont.h -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextFont.h + * @author drose + * @date 2002-02-08 + */ #ifndef DYNAMICTEXTFONT_H #define DYNAMICTEXTFONT_H @@ -32,14 +31,11 @@ class NurbsCurveResult; -//////////////////////////////////////////////////////////////////// -// Class : DynamicTextFont -// Description : A DynamicTextFont is a special TextFont object that -// rasterizes its glyphs from a standard font file -// (e.g. a TTF file) on the fly. It requires the -// FreeType 2.0 library (or any higher, -// backward-compatible version). -//////////////////////////////////////////////////////////////////// +/** + * A DynamicTextFont is a special TextFont object that rasterizes its glyphs + * from a standard font file (e.g. a TTF file) on the fly. It requires the + * FreeType 2.0 library (or any higher, backward-compatible version). + */ class EXPCL_PANDA_TEXT DynamicTextFont : public TextFont, public FreetypeFont { PUBLISHED: DynamicTextFont(const Filename &font_filename, int face_index = 0); @@ -167,10 +163,9 @@ private: typedef pmap Cache; Cache _cache; - // This is a list of the glyphs that do not have any printable - // properties (e.g. space), but still have an advance measure. We - // store them here to keep their reference counts; they also appear - // in the above table. + // This is a list of the glyphs that do not have any printable properties + // (e.g. space), but still have an advance measure. We store them here to + // keep their reference counts; they also appear in the above table. typedef pvector< PT(TextGlyph) > EmptyGlyphs; EmptyGlyphs _empty_glyphs; diff --git a/panda/src/text/dynamicTextGlyph.I b/panda/src/text/dynamicTextGlyph.I index 0839f56492..e6406e0d0d 100644 --- a/panda/src/text/dynamicTextGlyph.I +++ b/panda/src/text/dynamicTextGlyph.I @@ -1,24 +1,19 @@ -// Filename: dynamicTextGlyph.I -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextGlyph.I + * @author drose + * @date 2002-02-09 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE DynamicTextGlyph:: DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, int x_size, int y_size, int margin, PN_stdfloat advance) : @@ -30,13 +25,10 @@ DynamicTextGlyph(int character, DynamicTextPage *page, int x, int y, { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::Constructor -// Access: Public -// Description: This constructor makes an empty glyph, whose only -// purpose is to remember its width. It has no bitmap -// and no Geom. -//////////////////////////////////////////////////////////////////// +/** + * This constructor makes an empty glyph, whose only purpose is to remember + * its width. It has no bitmap and no Geom. + */ INLINE DynamicTextGlyph:: DynamicTextGlyph(int character, PN_stdfloat advance) : TextGlyph(character, advance), @@ -47,11 +39,9 @@ DynamicTextGlyph(int character, PN_stdfloat advance) : { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::Copy Constructor -// Access: Private -// Description: Copying DynamicTextGlyph objects is not allowed. -//////////////////////////////////////////////////////////////////// +/** + * Copying DynamicTextGlyph objects is not allowed. + */ INLINE DynamicTextGlyph:: DynamicTextGlyph(const DynamicTextGlyph &) : TextGlyph(0) @@ -59,35 +49,28 @@ DynamicTextGlyph(const DynamicTextGlyph &) : nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::Copy Assignment Operator -// Access: Private -// Description: Copying DynamicTextGlyph objects is not allowed. -//////////////////////////////////////////////////////////////////// +/** + * Copying DynamicTextGlyph objects is not allowed. + */ INLINE void DynamicTextGlyph:: operator = (const DynamicTextGlyph &) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_page -// Access: Published -// Description: Returns the DynamicTextPage that this glyph is on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DynamicTextPage that this glyph is on. + */ INLINE DynamicTextPage *DynamicTextGlyph:: get_page() const { return _page; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::intersects -// Access: Published -// Description: Returns true if the particular position this glyph -// has been assigned to overlaps the rectangle whose -// top left corner is at x, y and whose size is given by -// x_size, y_size, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the particular position this glyph has been assigned to + * overlaps the rectangle whose top left corner is at x, y and whose size is + * given by x_size, y_size, or false otherwise. + */ INLINE bool DynamicTextGlyph:: intersects(int x, int y, int x_size, int y_size) const { int hright = x + x_size; @@ -100,89 +83,73 @@ intersects(int x, int y, int x_size, int y_size) const { y >= mbot || hbot <= _y); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_left -// Access: Published -// Description: Returns the vertex coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_left() const { return _quad_dimensions[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_bottom -// Access: Published -// Description: Returns the vertex coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_bottom() const { return _quad_dimensions[1]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_right -// Access: Published -// Description: Returns the vertex coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_right() const { return _quad_dimensions[2]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_top -// Access: Published -// Description: Returns the vertex coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertex coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_top() const { return _quad_dimensions[3]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_uv_left -// Access: Published -// Description: Returns the UV coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_uv_left() const { return _quad_texcoords[0]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_uv_bottom -// Access: Published -// Description: Returns the UV coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_uv_bottom() const { return _quad_texcoords[1]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_uv_right -// Access: Published -// Description: Returns the UV coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_uv_right() const { return _quad_texcoords[2]; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_uv_top -// Access: Published -// Description: Returns the UV coordinates that can be used when -// creating a custom text renderer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the UV coordinates that can be used when creating a custom text + * renderer. + */ INLINE PN_stdfloat DynamicTextGlyph:: get_uv_top() const { return _quad_texcoords[3]; diff --git a/panda/src/text/dynamicTextGlyph.cxx b/panda/src/text/dynamicTextGlyph.cxx index ac1c3a40f1..9727b353f7 100644 --- a/panda/src/text/dynamicTextGlyph.cxx +++ b/panda/src/text/dynamicTextGlyph.cxx @@ -1,16 +1,15 @@ -// Filename: dynamicTextGlyph.cxx -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextGlyph.cxx + * @author drose + * @date 2002-02-09 + */ #include "dynamicTextGlyph.h" @@ -31,23 +30,18 @@ TypeHandle DynamicTextGlyph::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DynamicTextGlyph:: ~DynamicTextGlyph() { } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::get_row -// Access: Public -// Description: Returns a pointer to the first byte in the pixel -// buffer associated with the leftmost pixel in the -// indicated row, where 0 is the topmost row and _y_size -// - _margin * 2 - 1 is the bottommost row. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the first byte in the pixel buffer associated with the + * leftmost pixel in the indicated row, where 0 is the topmost row and _y_size + * - _margin * 2 - 1 is the bottommost row. + */ unsigned char *DynamicTextGlyph:: get_row(int y) { nassertr(y >= 0 && y < _y_size - _margin * 2, (unsigned char *)NULL); @@ -64,36 +58,30 @@ get_row(int y) { int offset = (y * _page->get_x_size()) + x; int pixel_width = _page->get_num_components() * _page->get_component_width(); - return _page->modify_ram_image() + offset * pixel_width; + return _page->modify_ram_image() + offset * pixel_width; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::erase -// Access: Public -// Description: Erases the glyph from the texture map. -//////////////////////////////////////////////////////////////////// +/** + * Erases the glyph from the texture map. + */ void DynamicTextGlyph:: erase(DynamicTextFont *font) { nassertv(_page != (DynamicTextPage *)NULL); nassertv(_page->has_ram_image()); - // The glyph covers the pixels from (_x, _y) over the rectangle - // (_x_size, _y_size), but it doesn't include _margin pixels around - // the interior of the rectangle. Erase all the pixels that the - // glyph covers. - _page->fill_region(_x + _margin, + // The glyph covers the pixels from (_x, _y) over the rectangle (_x_size, + // _y_size), but it doesn't include _margin pixels around the interior of + // the rectangle. Erase all the pixels that the glyph covers. + _page->fill_region(_x + _margin, _page->get_y_size() - (_y + _y_size - _margin), _x_size - _margin * 2, _y_size - _margin * 2, font->get_bg()); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextGlyph::is_whitespace -// Access: Public, Virtual -// Description: Returns true if this glyph represents invisible -// whitespace, or false if it corresponds to some -// visible character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this glyph represents invisible whitespace, or false if it + * corresponds to some visible character. + */ bool DynamicTextGlyph:: is_whitespace() const { return (_page == (DynamicTextPage *)NULL); diff --git a/panda/src/text/dynamicTextGlyph.h b/panda/src/text/dynamicTextGlyph.h index e52823ad92..a90308977c 100644 --- a/panda/src/text/dynamicTextGlyph.h +++ b/panda/src/text/dynamicTextGlyph.h @@ -1,16 +1,15 @@ -// Filename: dynamicTextGlyph.h -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextGlyph.h + * @author drose + * @date 2002-02-09 + */ #ifndef DYNAMICTEXTGLYPH_H #define DYNAMICTEXTGLYPH_H @@ -24,17 +23,15 @@ class DynamicTextPage; class DynamicTextFont; -//////////////////////////////////////////////////////////////////// -// Class : DynamicTextGlyph -// Description : A specialization on TextGlyph that is generated and -// stored by a DynamicTextFont. This keeps some -// additional information, such as where the glyph -// appears on a texture map. -//////////////////////////////////////////////////////////////////// +/** + * A specialization on TextGlyph that is generated and stored by a + * DynamicTextFont. This keeps some additional information, such as where the + * glyph appears on a texture map. + */ class EXPCL_PANDA_TEXT DynamicTextGlyph : public TextGlyph { public: INLINE DynamicTextGlyph(int character, DynamicTextPage *page, - int x, int y, int x_size, int y_size, + int x, int y, int x_size, int y_size, int margin, PN_stdfloat advance); INLINE DynamicTextGlyph(int character, PN_stdfloat advance); private: diff --git a/panda/src/text/dynamicTextPage.I b/panda/src/text/dynamicTextPage.I index 394e34436b..2cbc6b32a9 100644 --- a/panda/src/text/dynamicTextPage.I +++ b/panda/src/text/dynamicTextPage.I @@ -1,54 +1,43 @@ -// Filename: dynamicTextPage.I -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextPage.I + * @author drose + * @date 2002-02-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::get_size -// Access: Published -// Description: Returns the size of the page (texture), in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the page (texture), in pixels. + */ INLINE const LVecBase2i &DynamicTextPage:: get_size() const { return _size; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::get_x_size -// Access: Published -// Description: Returns the x size of the page (texture), in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x size of the page (texture), in pixels. + */ INLINE int DynamicTextPage:: get_x_size() const { return _size.get_x(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::get_y_size -// Access: Published -// Description: Returns the y size of the page (texture), in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y size of the page (texture), in pixels. + */ INLINE int DynamicTextPage:: get_y_size() const { return _size.get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::is_empty -// Access: Published -// Description: Returns true if the page has no glyphs, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the page has no glyphs, false otherwise. + */ INLINE bool DynamicTextPage:: is_empty() const { return _glyphs.empty(); diff --git a/panda/src/text/dynamicTextPage.cxx b/panda/src/text/dynamicTextPage.cxx index fd4720b2b6..093f6fda2d 100644 --- a/panda/src/text/dynamicTextPage.cxx +++ b/panda/src/text/dynamicTextPage.cxx @@ -1,16 +1,15 @@ -// Filename: dynamicTextPage.cxx -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextPage.cxx + * @author drose + * @date 2002-02-09 + */ #include "dynamicTextPage.h" #include "dynamicTextFont.h" @@ -21,21 +20,19 @@ TypeHandle DynamicTextPage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::Constructor -// Access: Publiic -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DynamicTextPage:: -DynamicTextPage(DynamicTextFont *font, int page_number) : +DynamicTextPage(DynamicTextFont *font, int page_number) : _font(font) { - // Since the texture might change frequently, don't try to compress - // it by default. + // Since the texture might change frequently, don't try to compress it by + // default. set_compression(CM_off); - // It's usually pretty important for text to look its best, and it - // doesn't usually have a high fill factor. + // It's usually pretty important for text to look its best, and it doesn't + // usually have a high fill factor. set_quality_level(text_quality_level); _size = _font->get_page_size(); @@ -55,8 +52,8 @@ DynamicTextPage(DynamicTextFont *font, int page_number) : set_anisotropic_degree(_font->get_anisotropic_degree()); - // Clamp to an explicit invisible border, so we don't get bleeding - // at the edges at all. + // Clamp to an explicit invisible border, so we don't get bleeding at the + // edges at all. set_wrap_u(text_wrap_mode); set_wrap_v(text_wrap_mode); set_border_color(font->get_bg()); @@ -65,13 +62,10 @@ DynamicTextPage(DynamicTextFont *font, int page_number) : fill_region(0, 0, _size[0], _size[1], font->get_bg()); } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::slot_glyph -// Access: Public -// Description: Finds space within the page for a glyph of the -// indicated size. If space is found, creates a new -// glyph object and returns it; otherwise, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Finds space within the page for a glyph of the indicated size. If space is + * found, creates a new glyph object and returns it; otherwise, returns NULL. + */ DynamicTextGlyph *DynamicTextPage:: slot_glyph(int character, int x_size, int y_size, int margin, PN_stdfloat advance) { @@ -82,19 +76,16 @@ slot_glyph(int character, int x_size, int y_size, int margin, } // The glyph can be fit at (x, y). Slot it. - PT(DynamicTextGlyph) glyph = + PT(DynamicTextGlyph) glyph = new DynamicTextGlyph(character, this, x, y, x_size, y_size, margin, advance); _glyphs.push_back(glyph); return glyph; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::fill_region -// Access: Private -// Description: Fills a rectangular region of the texture with the -// indicated color. -//////////////////////////////////////////////////////////////////// +/** + * Fills a rectangular region of the texture with the indicated color. + */ void DynamicTextPage:: fill_region(int x, int y, int x_size, int y_size, const LColor &color) { nassertv(x >= 0 && x + x_size <= _size[0] && y >= 0 && y + y_size <= _size[1]); @@ -105,7 +96,7 @@ fill_region(int x, int y, int x_size, int y_size, const LColor &color) { if (get_format() != Texture::F_alpha) { ci = 0; } - + unsigned char v = (unsigned char)(color[ci] * 255.0f); unsigned char *image = modify_ram_image(); @@ -149,7 +140,7 @@ fill_region(int x, int y, int x_size, int y_size, const LColor &color) { row[xi * 3 + 2] = p2; } } - + } else { // (num_components == 4) // RGBA. union { @@ -172,15 +163,12 @@ fill_region(int x, int y, int x_size, int y_size, const LColor &color) { } } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::garbage_collect -// Access: Private -// Description: Removes all of the glyphs from the page that are no -// longer being used by any Geoms. This should only be -// called from DynamicTextFont::garbage_collect(), since -// it is important to remove these glyphs from the -// font's index first. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the glyphs from the page that are no longer being used by + * any Geoms. This should only be called from + * DynamicTextFont::garbage_collect(), since it is important to remove these + * glyphs from the font's index first. + */ int DynamicTextPage:: garbage_collect(DynamicTextFont *font) { int removed_count = 0; @@ -203,14 +191,11 @@ garbage_collect(DynamicTextFont *font) { return removed_count; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::find_hole -// Access: Private -// Description: Searches for a hole of at least x_size by y_size -// pixels somewhere within the page. If a suitable hole -// is found, sets x and y to the top left corner and -// returns true; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Searches for a hole of at least x_size by y_size pixels somewhere within + * the page. If a suitable hole is found, sets x and y to the top left corner + * and returns true; otherwise, returns false. + */ bool DynamicTextPage:: find_hole(int &x, int &y, int x_size, int y_size) const { y = 0; @@ -243,17 +228,13 @@ find_hole(int &x, int &y, int x_size, int y_size) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextPage::find_overlap -// Access: Private -// Description: If the rectangle whose top left corner is x, y and -// whose size is x_size, y_size describes an empty hole -// that does not overlap any placed glyphs, returns -// NULL; otherwise, returns the first placed glyph -// that the image does overlap. It is assumed the -// rectangle lies completely within the boundaries of -// the page itself. -//////////////////////////////////////////////////////////////////// +/** + * If the rectangle whose top left corner is x, y and whose size is x_size, + * y_size describes an empty hole that does not overlap any placed glyphs, + * returns NULL; otherwise, returns the first placed glyph that the image does + * overlap. It is assumed the rectangle lies completely within the boundaries + * of the page itself. + */ DynamicTextGlyph *DynamicTextPage:: find_overlap(int x, int y, int x_size, int y_size) const { Glyphs::const_iterator gi; diff --git a/panda/src/text/dynamicTextPage.h b/panda/src/text/dynamicTextPage.h index e32187f7f4..85c1484acb 100644 --- a/panda/src/text/dynamicTextPage.h +++ b/panda/src/text/dynamicTextPage.h @@ -1,16 +1,15 @@ -// Filename: dynamicTextPage.h -// Created by: drose (09Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dynamicTextPage.h + * @author drose + * @date 2002-02-09 + */ #ifndef DYNAMICTEXTPAGE_H #define DYNAMICTEXTPAGE_H @@ -26,13 +25,11 @@ class DynamicTextFont; -//////////////////////////////////////////////////////////////////// -// Class : DynamicTextPage -// Description : A single "page" of a DynamicTextFont. This is a -// single texture that holds a number of glyphs for -// rendering. The font starts out with one page, and -// will add more as it needs them. -//////////////////////////////////////////////////////////////////// +/** + * A single "page" of a DynamicTextFont. This is a single texture that holds + * a number of glyphs for rendering. The font starts out with one page, and + * will add more as it needs them. + */ class EXPCL_PANDA_TEXT DynamicTextPage : public Texture { public: DynamicTextPage(DynamicTextFont *font, int page_number); diff --git a/panda/src/text/fontPool.I b/panda/src/text/fontPool.I index 95a0a221df..c24906bdcf 100644 --- a/panda/src/text/fontPool.I +++ b/panda/src/text/fontPool.I @@ -1,127 +1,96 @@ -// Filename: fontPool.I -// Created by: drose (31Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fontPool.I + * @author drose + * @date 2003-01-31 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FontPool::has_font -// Access: Public, Static -// Description: Returns true if the font has ever been loaded, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the font has ever been loaded, false otherwise. + */ INLINE bool FontPool:: has_font(const string &filename) { return get_ptr()->ns_has_font(filename); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::verify_font -// Access: Public, Static -// Description: Loads the given filename up into a font, if it has -// not already been loaded, and returns true to indicate -// success, or false to indicate failure. If this -// returns true, it is guaranteed that a subsequent call -// to load_font() with the same font name will -// return a valid Font pointer. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a font, if it has not already been loaded, + * and returns true to indicate success, or false to indicate failure. If + * this returns true, it is guaranteed that a subsequent call to load_font() + * with the same font name will return a valid Font pointer. + */ INLINE bool FontPool:: verify_font(const string &filename) { return load_font(filename) != (TextFont *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::load_font -// Access: Public, Static -// Description: Loads the given filename up into a font, if it has -// not already been loaded, and returns the new font. -// If a font with the same filename was previously -// loaded, returns that one instead. If the font -// file cannot be found, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Loads the given filename up into a font, if it has not already been loaded, + * and returns the new font. If a font with the same filename was previously + * loaded, returns that one instead. If the font file cannot be found, + * returns NULL. + */ INLINE TextFont *FontPool:: load_font(const string &filename) { return get_ptr()->ns_load_font(filename); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::add_font -// Access: Public, Static -// Description: Adds the indicated already-loaded font to the -// pool. The font will always replace any -// previously-loaded font in the pool that had the -// same filename. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated already-loaded font to the pool. The font will always + * replace any previously-loaded font in the pool that had the same filename. + */ INLINE void FontPool:: add_font(const string &filename, TextFont *font) { get_ptr()->ns_add_font(filename, font); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::release_font -// Access: Public, Static -// Description: Removes the indicated font from the pool, -// indicating it will never be loaded again; the font -// may then be freed. If this function is never called, -// a reference count will be maintained on every font -// every loaded, and fonts will never be freed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated font from the pool, indicating it will never be + * loaded again; the font may then be freed. If this function is never + * called, a reference count will be maintained on every font every loaded, + * and fonts will never be freed. + */ INLINE void FontPool:: release_font(const string &filename) { get_ptr()->ns_release_font(filename); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::release_all_fonts -// Access: Public, Static -// Description: Releases all fonts in the pool and restores the -// pool to the empty state. -//////////////////////////////////////////////////////////////////// +/** + * Releases all fonts in the pool and restores the pool to the empty state. + */ INLINE void FontPool:: release_all_fonts() { get_ptr()->ns_release_all_fonts(); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::garbage_collect -// Access: Public, Static -// Description: Releases only those fonts in the pool that have a -// reference count of exactly 1; i.e. only those -// fonts that are not being used outside of the pool. -// Returns the number of fonts released. -//////////////////////////////////////////////////////////////////// +/** + * Releases only those fonts in the pool that have a reference count of + * exactly 1; i.e. only those fonts that are not being used outside of the + * pool. Returns the number of fonts released. + */ INLINE int FontPool:: garbage_collect() { return get_ptr()->ns_garbage_collect(); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::list_contents -// Access: Public, Static -// Description: Lists the contents of the font pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the font pool to the indicated output stream. + */ INLINE void FontPool:: list_contents(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::Constructor -// Access: Private -// Description: The constructor is not intended to be called -// directly; there's only supposed to be one FontPool -// in the universe and it constructs itself. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there's only + * supposed to be one FontPool in the universe and it constructs itself. + */ INLINE FontPool:: FontPool() { } diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index 8c56c90983..1fab675bff 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -1,16 +1,15 @@ -// Filename: fontPool.cxx -// Created by: drose (31Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fontPool.cxx + * @author drose + * @date 2003-01-31 + */ #include "fontPool.h" #include "staticTextFont.h" @@ -24,22 +23,17 @@ FontPool *FontPool::_global_ptr = (FontPool *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: FontPool::write -// Access: Published, Static -// Description: Lists the contents of the font pool to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Lists the contents of the font pool to the indicated output stream. + */ void FontPool:: write(ostream &out) { get_ptr()->ns_list_contents(out); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_has_font -// Access: Private -// Description: The nonstatic implementation of has_font(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of has_font(). + */ bool FontPool:: ns_has_font(const string &str) { LightMutexHolder holder(_lock); @@ -59,11 +53,9 @@ ns_has_font(const string &str) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_load_font -// Access: Private -// Description: The nonstatic implementation of load_font(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of load_font(). + */ TextFont *FontPool:: ns_load_font(const string &str) { string index_str; @@ -73,7 +65,7 @@ ns_load_font(const string &str) { { LightMutexHolder holder(_lock); - + Fonts::const_iterator ti; ti = _fonts.find(index_str); if (ti != _fonts.end()) { @@ -85,9 +77,9 @@ ns_load_font(const string &str) { text_cat.info() << "Loading font " << filename << "\n"; - // Now, figure out how to load the font. If its filename extension - // is "egg" or "bam", or if it's unspecified, assume it's a model - // file, representing a static font. + // Now, figure out how to load the font. If its filename extension is "egg" + // or "bam", or if it's unspecified, assume it's a model file, representing + // a static font. PT(TextFont) font; string extension = filename.get_extension(); @@ -95,13 +87,13 @@ ns_load_font(const string &str) { Loader *model_loader = Loader::get_global_ptr(); PT(PandaNode) node = model_loader->load_sync(filename); if (node != (PandaNode *)NULL) { - // It is a model. Elevate all the priorities by 1, and make a - // font out of it. + // It is a model. Elevate all the priorities by 1, and make a font out + // of it. // On second thought, why should we elevate the priorities? The - // DynamicTextFont doesn't do this, and doing so for the - // StaticTextFont only causes problems (it changes the default - // ColorAttrib from pri -1 to pri 0). + // DynamicTextFont doesn't do this, and doing so for the StaticTextFont + // only causes problems (it changes the default ColorAttrib from pri -1 + // to pri 0). /* NodePath np(node); np.adjust_all_priorities(1); @@ -113,8 +105,8 @@ ns_load_font(const string &str) { #ifdef HAVE_FREETYPE if (font == (TextFont *)NULL || !font->is_valid()) { - // If we couldn't load the font as a model, try using FreeType to - // load it as a font file. + // If we couldn't load the font as a model, try using FreeType to load it + // as a font file. font = new DynamicTextFont(filename, face_index); } #endif @@ -142,11 +134,9 @@ ns_load_font(const string &str) { return font; } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_add_font -// Access: Private -// Description: The nonstatic implementation of add_font(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of add_font(). + */ void FontPool:: ns_add_font(const string &str, TextFont *font) { LightMutexHolder holder(_lock); @@ -160,11 +150,9 @@ ns_add_font(const string &str, TextFont *font) { _fonts[index_str] = font; } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_release_font -// Access: Private -// Description: The nonstatic implementation of release_font(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_font(). + */ void FontPool:: ns_release_font(const string &str) { LightMutexHolder holder(_lock); @@ -181,11 +169,9 @@ ns_release_font(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_release_all_fonts -// Access: Private -// Description: The nonstatic implementation of release_all_fonts(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of release_all_fonts(). + */ void FontPool:: ns_release_all_fonts() { LightMutexHolder holder(_lock); @@ -193,11 +179,9 @@ ns_release_all_fonts() { _fonts.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_garbage_collect -// Access: Private -// Description: The nonstatic implementation of garbage_collect(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of garbage_collect(). + */ int FontPool:: ns_garbage_collect() { LightMutexHolder holder(_lock); @@ -223,11 +207,9 @@ ns_garbage_collect() { return num_released; } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::ns_list_contents -// Access: Private -// Description: The nonstatic implementation of list_contents(). -//////////////////////////////////////////////////////////////////// +/** + * The nonstatic implementation of list_contents(). + */ void FontPool:: ns_list_contents(ostream &out) const { LightMutexHolder holder(_lock); @@ -241,19 +223,14 @@ ns_list_contents(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::lookup_filename -// Access: Private, Static -// Description: Accepts a font "filename", which might consist of a -// filename followed by an optional colon and a face -// index, and splits it out into its two components. -// Then it looks up the filename on the model path. -// Sets the filename and face index accordingly. Also -// sets index_str to be the concatenation of the -// found filename with the face index, thus restoring -// the original input (but normalized to contain the -// full path.) -//////////////////////////////////////////////////////////////////// +/** + * Accepts a font "filename", which might consist of a filename followed by an + * optional colon and a face index, and splits it out into its two components. + * Then it looks up the filename on the model path. Sets the filename and + * face index accordingly. Also sets index_str to be the concatenation of the + * found filename with the face index, thus restoring the original input (but + * normalized to contain the full path.) + */ void FontPool:: lookup_filename(const string &str, string &index_str, Filename &filename, int &face_index) { @@ -280,12 +257,10 @@ lookup_filename(const string &str, string &index_str, index_str = strm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: FontPool::get_ptr -// Access: Private, Static -// Description: Initializes and/or returns the global pointer to the -// one FontPool object in the system. -//////////////////////////////////////////////////////////////////// +/** + * Initializes and/or returns the global pointer to the one FontPool object in + * the system. + */ FontPool *FontPool:: get_ptr() { if (_global_ptr == (FontPool *)NULL) { diff --git a/panda/src/text/fontPool.h b/panda/src/text/fontPool.h index ba4a501324..363e2aade7 100644 --- a/panda/src/text/fontPool.h +++ b/panda/src/text/fontPool.h @@ -1,16 +1,15 @@ -// Filename: fontPool.h -// Created by: drose (31Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fontPool.h + * @author drose + * @date 2003-01-31 + */ #ifndef FONTPOOL_H #define FONTPOOL_H @@ -23,18 +22,16 @@ #include "lightMutex.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : FontPool -// Description : This is the preferred interface for loading fonts for -// the TextNode system. It is similar to ModelPool and -// TexturePool in that it unifies references to the same -// filename. -//////////////////////////////////////////////////////////////////// +/** + * This is the preferred interface for loading fonts for the TextNode system. + * It is similar to ModelPool and TexturePool in that it unifies references to + * the same filename. + */ class EXPCL_PANDA_TEXT FontPool { PUBLISHED: - // These functions take string parameters instead of Filenames - // because the parameters may not be entirely an actual filename: - // they may be a filename followed by a face index. + // These functions take string parameters instead of Filenames because the + // parameters may not be entirely an actual filename: they may be a filename + // followed by a face index. INLINE static bool has_font(const string &filename); INLINE static bool verify_font(const string &filename); diff --git a/panda/src/text/geomTextGlyph.I b/panda/src/text/geomTextGlyph.I index d3fde20345..d04c62b4be 100644 --- a/panda/src/text/geomTextGlyph.I +++ b/panda/src/text/geomTextGlyph.I @@ -1,14 +1,12 @@ -// Filename: geomTextGlyph.I -// Created by: drose (31Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTextGlyph.I + * @author drose + * @date 2005-03-31 + */ diff --git a/panda/src/text/geomTextGlyph.cxx b/panda/src/text/geomTextGlyph.cxx index 607c24a4fc..7af3d0d5e0 100644 --- a/panda/src/text/geomTextGlyph.cxx +++ b/panda/src/text/geomTextGlyph.cxx @@ -1,16 +1,15 @@ -// Filename: geomTextGlyph.cxx -// Created by: drose (31Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTextGlyph.cxx + * @author drose + * @date 2005-03-31 + */ #include "geomTextGlyph.h" #include "datagramIterator.h" @@ -20,29 +19,24 @@ TypeHandle GeomTextGlyph::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTextGlyph:: GeomTextGlyph(const TextGlyph *glyph, const GeomVertexData *data) : Geom(data) { // Initially, there is only one glyph in the Geom. There might be - // additional Glyphs later when we flatten the graph and call - // Geom::unify(). + // additional Glyphs later when we flatten the graph and call Geom::unify(). if (glyph != (const TextGlyph *)NULL) { _glyphs.reserve(1); _glyphs.push_back(glyph); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTextGlyph:: GeomTextGlyph(const GeomVertexData *data) : Geom(data) @@ -50,11 +44,9 @@ GeomTextGlyph(const GeomVertexData *data) : // With this constructor, there are no glyphs initially. } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTextGlyph:: GeomTextGlyph(const GeomTextGlyph ©) : Geom(copy), @@ -62,11 +54,9 @@ GeomTextGlyph(const GeomTextGlyph ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTextGlyph:: GeomTextGlyph(const Geom ©, const TextGlyph *glyph) : Geom(copy) @@ -77,53 +67,42 @@ GeomTextGlyph(const Geom ©, const TextGlyph *glyph) : } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomTextGlyph:: operator = (const GeomTextGlyph ©) { Geom::operator = (copy); _glyphs = copy._glyphs; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GeomTextGlyph:: ~GeomTextGlyph() { } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::make_copy -// Access: Public, Virtual -// Description: Returns a newly-allocated Geom that is a shallow copy -// of this one. It will be a different Geom pointer, -// but its internal data may or may not be shared with -// that of the original Geom. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Geom that is a shallow copy of this one. It will + * be a different Geom pointer, but its internal data may or may not be shared + * with that of the original Geom. + */ Geom *GeomTextGlyph:: make_copy() const { return new GeomTextGlyph(*this); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::copy_primitives_from -// Access: Public, Virtual -// Description: Copies the primitives from the indicated Geom into -// this one. This does require that both Geoms contain -// the same fundamental type primitives, both have a -// compatible shade model, and both use the same -// GeomVertexData. Both Geoms must also be the same -// specific class type (i.e. if one is a GeomTextGlyph, -// they both must be.) -// -// Returns true if the copy is successful, or false -// otherwise (because the Geoms were mismatched). -//////////////////////////////////////////////////////////////////// +/** + * Copies the primitives from the indicated Geom into this one. This does + * require that both Geoms contain the same fundamental type primitives, both + * have a compatible shade model, and both use the same GeomVertexData. Both + * Geoms must also be the same specific class type (i.e. if one is a + * GeomTextGlyph, they both must be.) + * + * Returns true if the copy is successful, or false otherwise (because the + * Geoms were mismatched). + */ bool GeomTextGlyph:: copy_primitives_from(const Geom *other) { if (!Geom::copy_primitives_from(other)) { @@ -140,34 +119,28 @@ copy_primitives_from(const Geom *other) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::count_geom -// Access: Public -// Description: Records the reference count of the other Geom within -// this Geom, as if the primitives were copied in via -// copy_primitives_from() (but does not actually copy -// any primitives). This is particularly necessary for -// GeomTextGlyph's reference counting mechanism. -// -// Does nothing if the other Geom is not a -// GeomTextGlyph. -//////////////////////////////////////////////////////////////////// +/** + * Records the reference count of the other Geom within this Geom, as if the + * primitives were copied in via copy_primitives_from() (but does not actually + * copy any primitives). This is particularly necessary for GeomTextGlyph's + * reference counting mechanism. + * + * Does nothing if the other Geom is not a GeomTextGlyph. + */ void GeomTextGlyph:: count_geom(const Geom *other) { if (other->is_of_type(GeomTextGlyph::get_class_type())) { const GeomTextGlyph *tother; DCAST_INTO_V(tother, other); - + _glyphs.reserve(_glyphs.size() + tother->_glyphs.size()); _glyphs.insert(_glyphs.end(), tother->_glyphs.begin(), tother->_glyphs.end()); } } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomTextGlyph:: output(ostream &out) const { Geom::output(out); @@ -181,11 +154,9 @@ output(ostream &out) const { out << " ]"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GeomTextGlyph:: write(ostream &out, int indent_level) const { Geom::write(out, indent_level); @@ -200,32 +171,25 @@ write(ostream &out, int indent_level) const { out << " ]\n"; } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::add_glyph -// Access: Public -// Description: Adds a glyph to the list of glyphs referenced by -// this Geom. -//////////////////////////////////////////////////////////////////// +/** + * Adds a glyph to the list of glyphs referenced by this Geom. + */ void GeomTextGlyph:: add_glyph(const TextGlyph *glyph) { _glyphs.push_back(glyph); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::register_with_factory -// Access: Public, Static -// Description: Factory method to generate a GeomTextGlyph object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a GeomTextGlyph object + */ void GeomTextGlyph:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_GeomTextGlyph); } -//////////////////////////////////////////////////////////////////// -// Function: GeomTextGlyph::make_GeomTextGlyph -// Access: Public -// Description: Factory method to generate a GeomTextGlyph object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a GeomTextGlyph object + */ TypedWritable* GeomTextGlyph:: make_GeomTextGlyph(const FactoryParams ¶ms) { GeomTextGlyph *me = new GeomTextGlyph((const TextGlyph *)NULL, diff --git a/panda/src/text/geomTextGlyph.h b/panda/src/text/geomTextGlyph.h index 944e07c25a..38d5604ee7 100644 --- a/panda/src/text/geomTextGlyph.h +++ b/panda/src/text/geomTextGlyph.h @@ -1,16 +1,15 @@ -// Filename: geomTextGlyph.h -// Created by: drose (31Mar05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file geomTextGlyph.h + * @author drose + * @date 2005-03-31 + */ #ifndef GEOMTEXTGLYPH_H #define GEOMTEXTGLYPH_H @@ -19,15 +18,12 @@ #include "geom.h" #include "textGlyph.h" -//////////////////////////////////////////////////////////////////// -// Class : GeomTextGlyph -// Description : This is a specialization on Geom for containing a -// primitive intended to represent a TextGlyph. -// Its sole purpose is to maintain the geom count on the -// glyph, so we can determine the actual usage count on -// a dynamic glyph (and thus know when it is safe to -// recycle the glyph). -//////////////////////////////////////////////////////////////////// +/** + * This is a specialization on Geom for containing a primitive intended to + * represent a TextGlyph. Its sole purpose is to maintain the geom count on + * the glyph, so we can determine the actual usage count on a dynamic glyph + * (and thus know when it is safe to recycle the glyph). + */ class EXPCL_PANDA_TEXT GeomTextGlyph : public Geom { public: GeomTextGlyph(const TextGlyph *glyph, const GeomVertexData *data); diff --git a/panda/src/text/staticTextFont.I b/panda/src/text/staticTextFont.I index d834a029f3..85df99bb45 100644 --- a/panda/src/text/staticTextFont.I +++ b/panda/src/text/staticTextFont.I @@ -1,14 +1,12 @@ -// Filename: staticTextFont.I -// Created by: drose (03May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file staticTextFont.I + * @author drose + * @date 2001-05-03 + */ diff --git a/panda/src/text/staticTextFont.cxx b/panda/src/text/staticTextFont.cxx index 1ab0db55fd..88f4186ad7 100644 --- a/panda/src/text/staticTextFont.cxx +++ b/panda/src/text/staticTextFont.cxx @@ -1,16 +1,15 @@ -// Filename: staticTextFont.cxx -// Created by: drose (03May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file staticTextFont.cxx + * @author drose + * @date 2001-05-03 + */ #include "staticTextFont.h" #include "config_text.h" @@ -28,18 +27,14 @@ TypeHandle StaticTextFont::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::Constructor -// Access: Published -// Description: The constructor expects the root node to a model -// generated via egg-mkfont, which consists of a set of -// models, one per each character in the font. -// -// If a CoordinateSystem value is specified, it informs -// the font of the coordinate system in which this model -// was generated. "up" in this coordinate system will -// be the direction of the top of the letters. -//////////////////////////////////////////////////////////////////// +/** + * The constructor expects the root node to a model generated via egg-mkfont, + * which consists of a set of models, one per each character in the font. + * + * If a CoordinateSystem value is specified, it informs the font of the + * coordinate system in which this model was generated. "up" in this + * coordinate system will be the direction of the top of the letters. + */ StaticTextFont:: StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { nassertv(font_def != (PandaNode *)NULL); @@ -53,9 +48,9 @@ StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { NodePath np(font_def); if (_cs != CS_zup_right) { - // We have to convert the entire font to CS_zup_right before we - // can use it, because the text subsystem assumes the glyphs are - // stored in CS_zup_right. + // We have to convert the entire font to CS_zup_right before we can use + // it, because the text subsystem assumes the glyphs are stored in + // CS_zup_right. NodePath temp_root("root"); NodePath temp_child = temp_root.attach_new_node("child"); np = np.copy_to(temp_child); @@ -68,19 +63,18 @@ StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { _cs = CS_zup_right; } - // If there is no explicit quality level or filter settings on the - // textures in the static font, set the appropriate defaults for - // text. + // If there is no explicit quality level or filter settings on the textures + // in the static font, set the appropriate defaults for text. TextureCollection tc = np.find_all_textures(); int num_textures = tc.get_num_textures(); for (int i = 0; i < num_textures; ++i) { Texture *tex = tc.get_texture(i); - - // Don't compress font textures. Though there's a relatively high - // bang-for-the-buck in compressing them, there's an increased - // risk that broken graphics drivers will fail to render the text - // properly, causing troubles for a user who then won't be able to - // navigate the options menus to disable texture compression. + + // Don't compress font textures. Though there's a relatively high bang- + // for-the-buck in compressing them, there's an increased risk that broken + // graphics drivers will fail to render the text properly, causing + // troubles for a user who then won't be able to navigate the options + // menus to disable texture compression. tex->set_compression(Texture::CM_off); if (tex->get_quality_level() == Texture::QL_default) { @@ -96,7 +90,7 @@ StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { find_characters(_font, RenderState::make_empty()); _is_valid = !_glyphs.empty(); - + // Check for an explicit space width. int character = 32; Glyphs::iterator gi = _glyphs.find(character); @@ -108,31 +102,26 @@ StaticTextFont(PandaNode *font_def, CoordinateSystem cs) { set_name(font_def->get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::make_copy -// Access: Published -// Description: Returns a new copy of the same font. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new copy of the same font. + */ PT(TextFont) StaticTextFont:: make_copy() const { return new StaticTextFont(_font); } -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void StaticTextFont:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "StaticTextFont " << get_name() << "; " << _glyphs.size() << " characters available in font:\n"; Glyphs::const_iterator gi; - + // Figure out which symbols we have. We collect lowercase letters, - // uppercase letters, and digits together for the user's - // convenience. + // uppercase letters, and digits together for the user's convenience. static const int num_letters = 26; static const int num_digits = 10; bool lowercase[num_letters]; @@ -153,11 +142,11 @@ write(ostream &out, int indent_level) const { if (islower(ch)) { count_lowercase++; lowercase[ch - 'a'] = true; - + } else if (isupper(ch)) { count_uppercase++; uppercase[ch - 'A'] = true; - + } else if (isdigit(ch)) { count_digits++; digits[ch - '0'] = true; @@ -222,17 +211,13 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::get_glyph -// Access: Public, Virtual -// Description: Gets the glyph associated with the given character -// code, as well as an optional scaling parameter that -// should be applied to the glyph's geometry and advance -// parameters. Returns true if the glyph exists, false -// if it does not. Even if the return value is false, -// the value for glyph might be filled in with a -// printable glyph. -//////////////////////////////////////////////////////////////////// +/** + * Gets the glyph associated with the given character code, as well as an + * optional scaling parameter that should be applied to the glyph's geometry + * and advance parameters. Returns true if the glyph exists, false if it does + * not. Even if the return value is false, the value for glyph might be + * filled in with a printable glyph. + */ bool StaticTextFont:: get_glyph(int character, CPT(TextGlyph) &glyph) { Glyphs::const_iterator gi = _glyphs.find(character); @@ -246,15 +231,11 @@ get_glyph(int character, CPT(TextGlyph) &glyph) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::find_character_gsets -// Access: Private -// Description: Given that 'root' is a PandaNode containing at least -// a polygon and a point which define the character's -// appearance and kern position, respectively, -// recursively walk the hierarchy and root and locate -// those two Geoms. -//////////////////////////////////////////////////////////////////// +/** + * Given that 'root' is a PandaNode containing at least a polygon and a point + * which define the character's appearance and kern position, respectively, + * recursively walk the hierarchy and root and locate those two Geoms. + */ void StaticTextFont:: find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, const RenderState *&state, const RenderState *net_state) { @@ -275,8 +256,7 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, } } if (!found_points) { - // If it doesn't have any points, it must be the regular - // letter. + // If it doesn't have any points, it must be the regular letter. ch = geom; state = next_net_state->compose(geode->get_geom_state(i)); } @@ -292,14 +272,11 @@ find_character_gsets(PandaNode *root, CPT(Geom) &ch, CPT(Geom) &dot, } } -//////////////////////////////////////////////////////////////////// -// Function: StaticTextFont::find_characters -// Access: Private -// Description: Walk the hierarchy beginning at the indicated root -// and locate any nodes whose names are just integers. -// These are taken to be characters, and their -// definitions and kern informations are retrieved. -//////////////////////////////////////////////////////////////////// +/** + * Walk the hierarchy beginning at the indicated root and locate any nodes + * whose names are just integers. These are taken to be characters, and their + * definitions and kern informations are retrieved. + */ void StaticTextFont:: find_characters(PandaNode *root, const RenderState *net_state) { CPT(RenderState) next_net_state = net_state->compose(root->get_state()); @@ -308,9 +285,8 @@ find_characters(PandaNode *root, const RenderState *net_state) { bool all_digits = !name.empty(); const char *p = name.c_str(); while (all_digits && *p != '\0') { - // VC++ complains if we treat an int as a bool, so we have to do - // this != 0 comparison on the int isdigit() function to shut it - // up. + // VC++ complains if we treat an int as a bool, so we have to do this != 0 + // comparison on the int isdigit() function to shut it up. all_digits = (isdigit(*p) != 0); p++; } @@ -323,8 +299,8 @@ find_characters(PandaNode *root, const RenderState *net_state) { find_character_gsets(root, ch, dot, state, next_net_state); PN_stdfloat width = 0.0; if (dot != (Geom *)NULL) { - // Get the first vertex from the "dot" geoset. This will be the - // origin of the next character. + // Get the first vertex from the "dot" geoset. This will be the origin + // of the next character. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); width = reader.get_data1f(); } @@ -332,16 +308,16 @@ find_characters(PandaNode *root, const RenderState *net_state) { _glyphs[character] = new TextGlyph(character, ch, state, width); } else if (name == "ds") { - // The group "ds" is a special node that indicates the font's - // design size, or line height. + // The group "ds" is a special node that indicates the font's design size, + // or line height. CPT(Geom) ch; CPT(Geom) dot; const RenderState *state = NULL; find_character_gsets(root, ch, dot, state, next_net_state); if (dot != (Geom *)NULL) { - // Get the first vertex from the "dot" geoset. This will be the - // design size indicator. + // Get the first vertex from the "dot" geoset. This will be the design + // size indicator. GeomVertexReader reader(dot->get_vertex_data(), InternalName::get_vertex()); LVecBase3 data = reader.get_data3(); _line_height = data[2]; diff --git a/panda/src/text/staticTextFont.h b/panda/src/text/staticTextFont.h index c97796f6ef..95f8430975 100644 --- a/panda/src/text/staticTextFont.h +++ b/panda/src/text/staticTextFont.h @@ -1,16 +1,15 @@ -// Filename: staticTextFont.h -// Created by: drose (03May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file staticTextFont.h + * @author drose + * @date 2001-05-03 + */ #ifndef STATICTEXTFONT_H #define STATICTEXTFONT_H @@ -30,14 +29,12 @@ class Node; class GeomPoint; -//////////////////////////////////////////////////////////////////// -// Class : StaticTextFont -// Description : A StaticTextFont is loaded up from a model that was -// previously generated via egg-mkfont, and contains all -// of its glyphs already generated and available for -// use. It doesn't require linking with any external -// libraries like FreeType. -//////////////////////////////////////////////////////////////////// +/** + * A StaticTextFont is loaded up from a model that was previously generated + * via egg-mkfont, and contains all of its glyphs already generated and + * available for use. It doesn't require linking with any external libraries + * like FreeType. + */ class EXPCL_PANDA_TEXT StaticTextFont : public TextFont { PUBLISHED: StaticTextFont(PandaNode *font_def, CoordinateSystem cs = CS_default); diff --git a/panda/src/text/textAssembler.I b/panda/src/text/textAssembler.I index 0de7f7d06d..5132f78859 100644 --- a/panda/src/text/textAssembler.I +++ b/panda/src/text/textAssembler.I @@ -1,174 +1,134 @@ -// Filename: textAssembler.I -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textAssembler.I + * @author drose + * @date 2004-04-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_usage_hint -// Access: Published -// Description: Specifies the UsageHint that will be applied to -// generated geometry. The default is UH_static, which -// is probably the right setting, but if you know the -// TextNode's geometry will have a short lifespan, it -// may be better to set it to UH_stream. See -// geomEnums.h. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the UsageHint that will be applied to generated geometry. The + * default is UH_static, which is probably the right setting, but if you know + * the TextNode's geometry will have a short lifespan, it may be better to set + * it to UH_stream. See geomEnums.h. + */ INLINE void TextAssembler:: set_usage_hint(Geom::UsageHint usage_hint) { _usage_hint = usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_usage_hint -// Access: Published -// Description: Returns the UsageHint that will be applied to -// generated geometry. See set_usage_hint(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UsageHint that will be applied to generated geometry. See + * set_usage_hint(). + */ INLINE Geom::UsageHint TextAssembler:: get_usage_hint() const { return _usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_max_rows -// Access: Published -// Description: If max_rows is greater than zero, no more than -// max_rows will be accepted. Text beyond that will be -// truncated. -// -// Setting this will not truncate text immediately. You -// must follow this up with a call to set_wtext() to -// truncate the existing text. -//////////////////////////////////////////////////////////////////// +/** + * If max_rows is greater than zero, no more than max_rows will be accepted. + * Text beyond that will be truncated. + * + * Setting this will not truncate text immediately. You must follow this up + * with a call to set_wtext() to truncate the existing text. + */ INLINE void TextAssembler:: set_max_rows(int max_rows) { _max_rows = max_rows; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_max_rows -// Access: Published -// Description: If max_rows is greater than zero, no more than -// max_rows will be accepted. Text beyond that will be -// truncated. -//////////////////////////////////////////////////////////////////// +/** + * If max_rows is greater than zero, no more than max_rows will be accepted. + * Text beyond that will be truncated. + */ INLINE int TextAssembler:: get_max_rows() const { return _max_rows; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_dynamic_merge -// Access: Published -// Description: Sets the dynamic_merge flag. See -// TextNode::set_flatten_flags(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the dynamic_merge flag. See TextNode::set_flatten_flags(). + */ INLINE void TextAssembler:: set_dynamic_merge(bool dynamic_merge) { _dynamic_merge = dynamic_merge; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_dynamic_merge -// Access: Published -// Description: Returns the dynamic_merge flag. See -// TextNode::set_flatten_flags(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the dynamic_merge flag. See TextNode::set_flatten_flags(). + */ INLINE bool TextAssembler:: get_dynamic_merge() const { return _dynamic_merge; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_multiline_mode -// Access: Published -// Description: Sets the multiline mode flag. Set the multiline -// mode to allow text to wrap. It defaults to true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the multiline mode flag. Set the multiline mode to allow text to + * wrap. It defaults to true. + */ INLINE void TextAssembler:: set_multiline_mode(bool flag) { _multiline_mode = flag; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_multiline_mode -// Access: Published -// Description: Returns the multline_mode flag. See -// TextNode::set_multiline_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the multline_mode flag. See TextNode::set_multiline_mode(). + */ INLINE bool TextAssembler:: get_multiline_mode() const { return _multiline_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_properties -// Access: Published -// Description: Specifies the default TextProperties that are applied -// to the text in the absence of any nested property -// change sequences. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default TextProperties that are applied to the text in the + * absence of any nested property change sequences. + */ INLINE void TextAssembler:: set_properties(const TextProperties &properties) { _initial_cprops = new ComputedProperties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_properties -// Access: Published -// Description: Returns the default TextProperties that are applied -// to the text in the absence of any nested property -// change sequences. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default TextProperties that are applied to the text in the + * absence of any nested property change sequences. + */ INLINE const TextProperties &TextAssembler:: get_properties() const { return _initial_cprops->_properties; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_ul -// Access: Published -// Description: Returns the upper-left corner of the assembled text, -// in 2-d text coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the upper-left corner of the assembled text, in 2-d text + * coordinates. + */ INLINE const LVector2 &TextAssembler:: get_ul() const { return _ul; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_lr -// Access: Published -// Description: Returns the lower-right corner of the assembled text, -// in 2-d text coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the lower-right corner of the assembled text, in 2-d text + * coordinates. + */ INLINE const LVector2 &TextAssembler:: get_lr() const { return _lr; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_r -// Access: Published -// Description: Computes the row index of the nth character or -// graphic object in the text and returns it. -// -// If the nth character is not a normal printable -// character with a position in the wordwrapped string, -// returns -1 (for instance, a soft-hyphen character, or -// a newline character, may not have a corresponding -// position). -//////////////////////////////////////////////////////////////////// +/** + * Computes the row index of the nth character or graphic object in the text + * and returns it. + * + * If the nth character is not a normal printable character with a position in + * the wordwrapped string, returns -1 (for instance, a soft-hyphen character, + * or a newline character, may not have a corresponding position). + */ int TextAssembler:: calc_r(int n) const { int r, c; @@ -178,18 +138,14 @@ calc_r(int n) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_c -// Access: Published -// Description: Computes the column index of the nth character or -// graphic object in the text and returns it. -// -// If the nth character is not a normal printable -// character with a position in the wordwrapped string, -// returns -1 (for instance, a soft-hyphen character, or -// a newline character, may not have a corresponding -// position). -//////////////////////////////////////////////////////////////////// +/** + * Computes the column index of the nth character or graphic object in the + * text and returns it. + * + * If the nth character is not a normal printable character with a position in + * the wordwrapped string, returns -1 (for instance, a soft-hyphen character, + * or a newline character, may not have a corresponding position). + */ int TextAssembler:: calc_c(int n) const { int r, c; @@ -199,88 +155,69 @@ calc_c(int n) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_num_characters -// Access: Published -// Description: Returns the number of characters of text, before -// wordwrapping. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of characters of text, before wordwrapping. + */ INLINE int TextAssembler:: get_num_characters() const { return _text_string.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_character -// Access: Published -// Description: Returns the character at the indicated position in -// the pre-wordwrapped string. If the object at this -// position is a graphic object instead of a character, -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the character at the indicated position in the pre-wordwrapped + * string. If the object at this position is a graphic object instead of a + * character, returns 0. + */ INLINE wchar_t TextAssembler:: get_character(int n) const { nassertr(n >= 0 && n < (int)_text_string.size(), 0); return _text_string[n]._character; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_graphic -// Access: Published -// Description: Returns the graphic object at the indicated position -// in the pre-wordwrapped string. If the object at this -// position is a character instead of a graphic object, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphic object at the indicated position in the pre-wordwrapped + * string. If the object at this position is a character instead of a graphic + * object, returns NULL. + */ INLINE const TextGraphic *TextAssembler:: get_graphic(int n) const { nassertr(n >= 0 && n < (int)_text_string.size(), 0); return _text_string[n]._graphic; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_properties -// Access: Published -// Description: Returns the TextProperties in effect for the object -// at the indicated position in the pre-wordwrapped -// string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextProperties in effect for the object at the indicated + * position in the pre-wordwrapped string. + */ INLINE const TextProperties &TextAssembler:: get_properties(int n) const { nassertr(n >= 0 && n < (int)_text_string.size(), *(new TextProperties())); return _text_string[n]._cprops->_properties; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_width -// Access: Published -// Description: Returns the width of the character or object at the -// indicated position in the pre-wordwrapped string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the character or object at the indicated position in + * the pre-wordwrapped string. + */ INLINE PN_stdfloat TextAssembler:: get_width(int n) const { nassertr(n >= 0 && n < (int)_text_string.size(), 0.0f); - + return calc_width(_text_string[n]); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_num_rows -// Access: Published -// Description: Returns the number of rows of text after it has all -// been wordwrapped and assembled. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows of text after it has all been wordwrapped and + * assembled. + */ INLINE int TextAssembler:: get_num_rows() const { return _text_block.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_num_cols -// Access: Published -// Description: Returns the number of characters and/or graphic -// objects in the nth row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of characters and/or graphic objects in the nth row. + */ INLINE int TextAssembler:: get_num_cols(int r) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0); @@ -290,13 +227,11 @@ get_num_cols(int r) const { return _text_block[r]._string.size(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_character -// Access: Published -// Description: Returns the character at the indicated position in -// the indicated row. If the object at this position is -// a graphic object instead of a character, returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the character at the indicated position in the indicated row. If + * the object at this position is a graphic object instead of a character, + * returns 0. + */ INLINE wchar_t TextAssembler:: get_character(int r, int c) const { nassertr(r >= 0 && r < (int)_text_block.size(), 0); @@ -304,14 +239,11 @@ get_character(int r, int c) const { return _text_block[r]._string[c]._character; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_graphic -// Access: Published -// Description: Returns the graphic object at the indicated position -// in the indicated row. If the object at this position -// is a character instead of a graphic object, returns -// NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the graphic object at the indicated position in the indicated row. + * If the object at this position is a character instead of a graphic object, + * returns NULL. + */ INLINE const TextGraphic *TextAssembler:: get_graphic(int r, int c) const { nassertr(r >= 0 && r < (int)_text_block.size(), 0); @@ -319,12 +251,10 @@ get_graphic(int r, int c) const { return _text_block[r]._string[c]._graphic; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_properties -// Access: Published -// Description: Returns the TextProperties in effect for the object -// at the indicated position in the indicated row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextProperties in effect for the object at the indicated + * position in the indicated row. + */ INLINE const TextProperties &TextAssembler:: get_properties(int r, int c) const { nassertr(r >= 0 && r < (int)_text_block.size(), *(new TextProperties())); @@ -332,29 +262,25 @@ get_properties(int r, int c) const { return _text_block[r]._string[c]._cprops->_properties; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_width -// Access: Published -// Description: Returns the width of the character or object at the -// indicated position in the indicated row. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the character or object at the indicated position in + * the indicated row. + */ INLINE PN_stdfloat TextAssembler:: get_width(int r, int c) const { nassertr(r >= 0 && r < (int)_text_block.size(), 0.0f); nassertr(c >= 0 && c < (int)_text_block[r]._string.size(), 0.0f); - + return calc_width(_text_block[r]._string[c]); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_ypos -// Access: Published -// Description: Returns the y position of the origin of all of the -// characters or graphic objects in the indicated row. -// -// It is legal for r to exceed the index number of the -// last row by 1. The value of c is presently ignored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y position of the origin of all of the characters or graphic + * objects in the indicated row. + * + * It is legal for r to exceed the index number of the last row by 1. The + * value of c is presently ignored. + */ INLINE PN_stdfloat TextAssembler:: get_ypos(int r, int) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0.0f); @@ -365,12 +291,9 @@ get_ypos(int r, int) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_width -// Access: Private, Static -// Description: Returns the width of a single character, according to -// its associated font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a single character, according to its associated font. + */ INLINE PN_stdfloat TextAssembler:: calc_width(const TextCharacter &tch) { if (tch._graphic != (TextGraphic *)NULL) { @@ -380,13 +303,11 @@ calc_width(const TextCharacter &tch) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextCharacter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::TextCharacter:: -TextCharacter(wchar_t character, +TextCharacter(wchar_t character, TextAssembler::ComputedProperties *cprops) : _character(character), _graphic(NULL), @@ -394,11 +315,9 @@ TextCharacter(wchar_t character, { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextCharacter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::TextCharacter:: TextCharacter(const TextGraphic *graphic, const wstring &graphic_wname, TextAssembler::ComputedProperties *cprops) : @@ -409,11 +328,9 @@ TextCharacter(const TextGraphic *graphic, const wstring &graphic_wname, { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextCharacter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::TextCharacter:: TextCharacter(const TextAssembler::TextCharacter ©) : _character(copy._character), @@ -423,11 +340,9 @@ TextCharacter(const TextAssembler::TextCharacter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextCharacter::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextAssembler::TextCharacter:: operator = (const TextAssembler::TextCharacter ©) { _character = copy._character; @@ -436,11 +351,9 @@ operator = (const TextAssembler::TextCharacter ©) { _cprops = copy._cprops; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextRow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::TextRow:: TextRow(int row_start) : _row_start(row_start), @@ -450,11 +363,9 @@ TextRow(int row_start) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextRow::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::TextRow:: TextRow(const TextAssembler::TextRow ©) : _string(copy._string), @@ -466,11 +377,9 @@ TextRow(const TextAssembler::TextRow ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::TextRow::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextAssembler::TextRow:: operator = (const TextAssembler::TextRow ©) { _string = copy._string; @@ -481,11 +390,9 @@ operator = (const TextAssembler::TextRow ©) { _eol_cprops = copy._eol_cprops; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::ComputedProperties::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::ComputedProperties:: ComputedProperties(const TextProperties &orig_properties) : _based_on(NULL), @@ -494,11 +401,9 @@ ComputedProperties(const TextProperties &orig_properties) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::ComputedProperties::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::ComputedProperties:: ComputedProperties(ComputedProperties *based_on, const wstring &wname, TextEncoder *encoder) : @@ -506,12 +411,12 @@ ComputedProperties(ComputedProperties *based_on, const wstring &wname, _depth(_based_on->_depth + 1), _wname(wname), _properties(based_on->_properties) -{ - TextPropertiesManager *manager = +{ + TextPropertiesManager *manager = TextPropertiesManager::get_global_ptr(); - // Now we have to encode the wstring into a string, for lookup - // in the TextPropertiesManager. + // Now we have to encode the wstring into a string, for lookup in the + // TextPropertiesManager. string name = encoder->encode_wtext(wname); const TextProperties *named_props = manager->get_properties_ptr(name); @@ -523,11 +428,9 @@ ComputedProperties(ComputedProperties *based_on, const wstring &wname, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollectorKey::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextAssembler::GeomCollectorKey:: GeomCollectorKey(const RenderState *state, const GeomVertexFormat *format) : _state(state), @@ -535,11 +438,9 @@ GeomCollectorKey(const RenderState *state, const GeomVertexFormat *format) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollectorKey::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextAssembler::GeomCollectorKey:: operator < (const TextAssembler::GeomCollectorKey &other) const { if (_state != other._state) { @@ -548,18 +449,14 @@ operator < (const TextAssembler::GeomCollectorKey &other) const { return _format < other._format; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector::count_geom -// Access: Public -// Description: If the indicated Geom is a GeomTextGlyph, increments -// its reference count and adds it into this geom. This -// is necessary to keep references to outstanding -// glyphs, so we know when it's safe to recycle -// no-longer-used glyphs. -// -// If the indicated Geom is an ordinary Geom, does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * If the indicated Geom is a GeomTextGlyph, increments its reference count + * and adds it into this geom. This is necessary to keep references to + * outstanding glyphs, so we know when it's safe to recycle no-longer-used + * glyphs. + * + * If the indicated Geom is an ordinary Geom, does nothing. + */ INLINE void TextAssembler::GeomCollector:: count_geom(const Geom *geom) { #ifdef HAVE_FREETYPE diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 44ff4bcda2..c2092fec6b 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -1,16 +1,15 @@ -// Filename: textAssembler.cxx -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textAssembler.cxx + * @author drose + * @date 2004-04-06 + */ #include "textAssembler.h" #include "textGlyph.h" @@ -35,7 +34,7 @@ #include #include // for sprintf - + // This is the factor by which CT_small scales the character down. static const PN_stdfloat small_accent_scale = 0.6f; @@ -46,46 +45,42 @@ static const PN_stdfloat tiny_accent_scale = 0.4; static const PN_stdfloat squash_accent_scale_x = 0.8f; static const PN_stdfloat squash_accent_scale_y = 0.5f; -// This is the factor by which CT_small_squash scales the character in X and Y. +// This is the factor by which CT_small_squash scales the character in X and +// Y. static const PN_stdfloat small_squash_accent_scale_x = 0.6f; static const PN_stdfloat small_squash_accent_scale_y = 0.3; -// This is the factor by which the advance is reduced for the first -// character of a two-character ligature. +// This is the factor by which the advance is reduced for the first character +// of a two-character ligature. static const PN_stdfloat ligature_advance_scale = 0.6f; -//////////////////////////////////////////////////////////////////// -// Function: isspacew -// Description: An internal function that works like isspace() but is -// safe to call for a wide character. -//////////////////////////////////////////////////////////////////// +/** + * An internal function that works like isspace() but is safe to call for a + * wide character. + */ static INLINE bool isspacew(unsigned int ch) { return isascii(ch) && isspace(ch); } -//////////////////////////////////////////////////////////////////// -// Function: isbreakpoint -// Description: An internal function, similar to isspace(), except it -// does not consider newlines to be whitespace. It also -// includes the soft-hyphen character. -//////////////////////////////////////////////////////////////////// +/** + * An internal function, similar to isspace(), except it does not consider + * newlines to be whitespace. It also includes the soft-hyphen character. + */ static INLINE bool isbreakpoint(unsigned int ch) { - return (ch == ' ' || ch == '\t' || + return (ch == ' ' || ch == '\t' || ch == (unsigned int)text_soft_hyphen_key || ch == (unsigned int)text_soft_break_key); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextAssembler:: -TextAssembler(TextEncoder *encoder) : +TextAssembler(TextEncoder *encoder) : _encoder(encoder), _usage_hint(Geom::UH_static), _max_rows(0), @@ -96,11 +91,9 @@ TextAssembler(TextEncoder *encoder) : clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextAssembler:: TextAssembler(const TextAssembler ©) : _initial_cprops(copy._initial_cprops), @@ -117,11 +110,9 @@ TextAssembler(const TextAssembler ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextAssembler:: operator = (const TextAssembler ©) { _initial_cprops = copy._initial_cprops; @@ -137,20 +128,16 @@ operator = (const TextAssembler ©) { _multiline_mode = copy._multiline_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextAssembler:: ~TextAssembler() { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::clear -// Access: Published -// Description: Reinitializes the contents of the TextAssembler. -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes the contents of the TextAssembler. + */ void TextAssembler:: clear() { _ul.set(0.0f, 0.0f); @@ -161,32 +148,27 @@ clear() { _text_block.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_wtext -// Access: Published -// Description: Accepts a new text string and associated properties -// structure, and precomputes the wordwrapping layout -// appropriately. After this call, -// get_wordwrapped_wtext() and get_num_rows() can be -// called. -// -// The return value is true if all the text is accepted, -// or false if some was truncated (see set_max_rows()). -//////////////////////////////////////////////////////////////////// +/** + * Accepts a new text string and associated properties structure, and + * precomputes the wordwrapping layout appropriately. After this call, + * get_wordwrapped_wtext() and get_num_rows() can be called. + * + * The return value is true if all the text is accepted, or false if some was + * truncated (see set_max_rows()). + */ bool TextAssembler:: set_wtext(const wstring &wtext) { clear(); - // First, expand all of the embedded TextProperties references - // within the string. + // First, expand all of the embedded TextProperties references within the + // string. wstring::const_iterator si = wtext.begin(); scan_wtext(_text_string, si, wtext.end(), _initial_cprops); while (si != wtext.end()) { - // If we returned without consuming the whole string, it means - // there was an embedded text_pop_properties_key that didn't match - // the push. That's worth a warning, and then go back and pick up - // the rest of the string. + // If we returned without consuming the whole string, it means there was + // an embedded text_pop_properties_key that didn't match the push. That's + // worth a warning, and then go back and pick up the rest of the string. text_cat.warning() << "pop_properties encountered without preceding push_properties.\n"; scan_wtext(_text_string, si, wtext.end(), _initial_cprops); @@ -196,23 +178,19 @@ set_wtext(const wstring &wtext) { return wordwrap_text(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::set_wsubstr -// Access: Published -// Description: Replaces the 'count' characters from 'start' of the -// current text with the indicated replacement text. If -// the replacement text does not have count characters, -// the length of the string will be changed accordingly. -// -// The substring may include nested formatting -// characters, but they must be self-contained and -// self-closed. The formatting characters are not -// literally saved in the internal string; they are -// parsed at the time of the set_wsubstr() call. -// -// The return value is true if all the text is accepted, -// or false if some was truncated (see set_max_rows()). -//////////////////////////////////////////////////////////////////// +/** + * Replaces the 'count' characters from 'start' of the current text with the + * indicated replacement text. If the replacement text does not have count + * characters, the length of the string will be changed accordingly. + * + * The substring may include nested formatting characters, but they must be + * self-contained and self-closed. The formatting characters are not + * literally saved in the internal string; they are parsed at the time of the + * set_wsubstr() call. + * + * The return value is true if all the text is accepted, or false if some was + * truncated (see set_max_rows()). + */ bool TextAssembler:: set_wsubstr(const wstring &wtext, int start, int count) { nassertr(start >= 0 && start <= (int)_text_string.size(), false); @@ -235,19 +213,15 @@ set_wsubstr(const wstring &wtext, int start, int count) { return wordwrap_text(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_plain_wtext -// Access: Published -// Description: Returns a wstring that represents the contents of the -// text, without any embedded properties characters. If -// there is an embedded graphic object, a zero value is -// inserted in that position. -// -// This string has the same length as -// get_num_characters(), and the characters in this -// string correspond one-to-one with the characters -// returned by get_character(n). -//////////////////////////////////////////////////////////////////// +/** + * Returns a wstring that represents the contents of the text, without any + * embedded properties characters. If there is an embedded graphic object, a + * zero value is inserted in that position. + * + * This string has the same length as get_num_characters(), and the characters + * in this string correspond one-to-one with the characters returned by + * get_character(n). + */ wstring TextAssembler:: get_plain_wtext() const { wstring wtext; @@ -261,25 +235,20 @@ get_plain_wtext() const { wtext.push_back(0); } } - + return wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_wordwrapped_plain_wtext -// Access: Published -// Description: Returns a wstring that represents the contents of the -// text, with newlines inserted according to the -// wordwrapping. The string will contain no embedded -// properties characters. If there is an embedded -// graphic object, a zero value is inserted in that -// position. -// -// This string has the same number of newline characters -// as get_num_rows(), and the characters in this string -// correspond one-to-one with the characters returned by -// get_character(r, c). -//////////////////////////////////////////////////////////////////// +/** + * Returns a wstring that represents the contents of the text, with newlines + * inserted according to the wordwrapping. The string will contain no + * embedded properties characters. If there is an embedded graphic object, a + * zero value is inserted in that position. + * + * This string has the same number of newline characters as get_num_rows(), + * and the characters in this string correspond one-to-one with the characters + * returned by get_character(r, c). + */ wstring TextAssembler:: get_wordwrapped_plain_wtext() const { wstring wtext; @@ -290,7 +259,7 @@ get_wordwrapped_plain_wtext() const { if (bi != _text_block.begin()) { wtext += '\n'; } - + TextString::const_iterator si; for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); @@ -305,17 +274,13 @@ get_wordwrapped_plain_wtext() const { return wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_wtext -// Access: Published -// Description: Returns a wstring that represents the contents of the -// text. -// -// The string will contain embedded properties -// characters, which may not exactly match the embedded -// properties characters of the original string, but it -// will encode the same way. -//////////////////////////////////////////////////////////////////// +/** + * Returns a wstring that represents the contents of the text. + * + * The string will contain embedded properties characters, which may not + * exactly match the embedded properties characters of the original string, + * but it will encode the same way. + */ wstring TextAssembler:: get_wtext() const { wstring wtext; @@ -339,31 +304,25 @@ get_wtext() const { return wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_wordwrapped_wtext -// Access: Published -// Description: Returns a wstring that represents the contents of the -// text, with newlines inserted according to the -// wordwrapping. -// -// The string will contain embedded properties -// characters, which may not exactly match the embedded -// properties characters of the original string, but it -// will encode the same way. -// -// Embedded properties characters will be closed before -// every newline, then reopened (if necessary) on the -// subsequent character following the newline. This -// means it will be safe to divide the text up at the -// newline characters and treat each line as an -// independent piece. -//////////////////////////////////////////////////////////////////// +/** + * Returns a wstring that represents the contents of the text, with newlines + * inserted according to the wordwrapping. + * + * The string will contain embedded properties characters, which may not + * exactly match the embedded properties characters of the original string, + * but it will encode the same way. + * + * Embedded properties characters will be closed before every newline, then + * reopened (if necessary) on the subsequent character following the newline. + * This means it will be safe to divide the text up at the newline characters + * and treat each line as an independent piece. + */ wstring TextAssembler:: get_wordwrapped_wtext() const { wstring wtext; PT(ComputedProperties) current_cprops = _initial_cprops; - + TextBlock::const_iterator bi; for (bi = _text_block.begin(); bi != _text_block.end(); ++bi) { const TextRow &row = (*bi); @@ -372,7 +331,7 @@ get_wordwrapped_wtext() const { current_cprops = _initial_cprops; wtext += '\n'; } - + TextString::const_iterator si; for (si = row._string.begin(); si != row._string.end(); ++si) { const TextCharacter &tch = (*si); @@ -392,19 +351,15 @@ get_wordwrapped_wtext() const { return wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_r_c -// Access: Published -// Description: Computes the row and column index of the nth -// character or graphic object in the text. Fills r and -// c accordingly. -// -// Returns true if the nth character is valid and has a -// corresponding r and c position, false otherwise (for -// instance, a soft-hyphen character, or a newline -// character, may not have a corresponding position). -// In either case, r and c will be filled in sensibly. -//////////////////////////////////////////////////////////////////// +/** + * Computes the row and column index of the nth character or graphic object in + * the text. Fills r and c accordingly. + * + * Returns true if the nth character is valid and has a corresponding r and c + * position, false otherwise (for instance, a soft-hyphen character, or a + * newline character, may not have a corresponding position). In either case, + * r and c will be filled in sensibly. + */ bool TextAssembler:: calc_r_c(int &r, int &c, int n) const { nassertr(n >= 0 && n <= (int)_text_string.size(), false); @@ -438,18 +393,18 @@ calc_r_c(int &r, int &c, int n) const { nassertr(n > 0, false); if (row._got_soft_hyphens) { - // If there are any soft hyphen or soft break keys in the source - // text, we have to scan past them to get c precisely. + // If there are any soft hyphen or soft break keys in the source text, we + // have to scan past them to get c precisely. c = 0; int i = row._row_start; while (i < n - 1) { - if (_text_string[i]._character != text_soft_hyphen_key && + if (_text_string[i]._character != text_soft_hyphen_key && _text_string[i]._character != text_soft_break_key) { ++c; } ++i; } - if (_text_string[n - 1]._character != text_soft_hyphen_key && + if (_text_string[n - 1]._character != text_soft_hyphen_key && _text_string[n - 1]._character != text_soft_break_key) { ++c; if (_text_string[n - 1]._character == '\n') { @@ -460,8 +415,7 @@ calc_r_c(int &r, int &c, int n) const { } } else { - // If there are no soft characters, then the string maps - // one-to-one. + // If there are no soft characters, then the string maps one-to-one. c = min(n - row._row_start, (int)row._string.size()); if (_text_string[n - 1]._character == '\n') { is_real_char = false; @@ -471,17 +425,14 @@ calc_r_c(int &r, int &c, int n) const { return is_real_char; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_index -// Access: Published -// Description: Computes the character index of the character at the -// rth row and cth column position. This is the inverse -// of calc_r_c(). -// -// It is legal for c to exceed the index number of the -// last column by 1, and it is legal for r to exceed the -// index number of the last row by 1, if c is 0. -//////////////////////////////////////////////////////////////////// +/** + * Computes the character index of the character at the rth row and cth column + * position. This is the inverse of calc_r_c(). + * + * It is legal for c to exceed the index number of the last column by 1, and + * it is legal for r to exceed the index number of the last row by 1, if c is + * 0. + */ int TextAssembler:: calc_index(int r, int c) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0); @@ -494,11 +445,11 @@ calc_index(int r, int c) const { const TextRow &row = _text_block[r]; if (row._got_soft_hyphens) { - // If there are any soft hyphen or soft break keys in the source - // text, we have to scan past them to get n precisely. + // If there are any soft hyphen or soft break keys in the source text, + // we have to scan past them to get n precisely. int n = row._row_start; while (c > 0) { - if (_text_string[n]._character != text_soft_hyphen_key && + if (_text_string[n]._character != text_soft_hyphen_key && _text_string[n]._character != text_soft_break_key) { --c; } @@ -507,24 +458,20 @@ calc_index(int r, int c) const { return n; } else { - // If there are no soft characters, then the string maps - // one-to-one. + // If there are no soft characters, then the string maps one-to-one. return row._row_start + c; } } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_xpos -// Access: Published -// Description: Returns the x position of the origin of the character -// or graphic object at the indicated position in the -// indicated row. -// -// It is legal for c to exceed the index number of the -// last column by 1, and it is legal for r to exceed the -// index number of the last row by 1, if c is 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x position of the origin of the character or graphic object at + * the indicated position in the indicated row. + * + * It is legal for c to exceed the index number of the last column by 1, and + * it is legal for r to exceed the index number of the last row by 1, if c is + * 0. + */ PN_stdfloat TextAssembler:: get_xpos(int r, int c) const { nassertr(r >= 0 && r <= (int)_text_block.size(), 0.0f); @@ -543,23 +490,20 @@ get_xpos(int r, int c) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::assemble_text -// Access: Published -// Description: Actually assembles all of the text into a GeomNode, -// and returns the node (or possibly a parent of the -// node, to keep the shadow separate). Once this has -// been called, you may query the extents of the text -// via get_ul(), get_lr(). -//////////////////////////////////////////////////////////////////// +/** + * Actually assembles all of the text into a GeomNode, and returns the node + * (or possibly a parent of the node, to keep the shadow separate). Once this + * has been called, you may query the extents of the text via get_ul(), + * get_lr(). + */ PT(PandaNode) TextAssembler:: assemble_text() { // Now assemble the text into glyphs. PlacedGlyphs placed_glyphs; assemble_paragraph(placed_glyphs); - // Now that we have a bunch of GlyphPlacements, pull out the Geoms - // and put them under a common node. + // Now that we have a bunch of GlyphPlacements, pull out the Geoms and put + // them under a common node. PT(PandaNode) parent_node = new PandaNode("common"); PT(PandaNode) shadow_node = new PandaNode("shadow"); @@ -611,10 +555,10 @@ assemble_text() { placement.assign_to(shadow_geom_node, shadow_state, shadow); } - // Don't shadow the graphics. That can result in duplication of - // button objects, plus it looks weird. If you want a shadowed - // graphic, you can shadow it yourself before you add it. - //placement.copy_graphic_to(shadow_node, shadow_state, shadow); + // Don't shadow the graphics. That can result in duplication of button + // objects, plus it looks weird. If you want a shadowed graphic, you + // can shadow it yourself before you add it. + // placement.copy_graphic_to(shadow_node, shadow_state, shadow); any_shadow = true; } @@ -645,7 +589,7 @@ assemble_text() { generate_quads(text_geom_node, quad_map); if (any_shadow) { - for (gc = geom_shadow_collector_map.begin(); + for (gc = geom_shadow_collector_map.begin(); gc != geom_shadow_collector_map.end(); ++gc) { (*gc).second.append_geom(shadow_geom_node, (*gc).first._state); @@ -659,14 +603,11 @@ assemble_text() { return parent_node; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_width -// Access: Published, Static -// Description: Returns the width of a single character, according to -// its associated font. This also correctly calculates -// the width of cheesy ligatures and accented -// characters, which may not exist in the font as such. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a single character, according to its associated font. + * This also correctly calculates the width of cheesy ligatures and accented + * characters, which may not exist in the font as such. + */ PN_stdfloat TextAssembler:: calc_width(wchar_t character, const TextProperties &properties) { if (character == ' ') { @@ -683,12 +624,12 @@ calc_width(wchar_t character, const TextProperties &properties) { int additional_flags; PN_stdfloat glyph_scale; PN_stdfloat advance_scale; - get_character_glyphs(character, &properties, + get_character_glyphs(character, &properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); PN_stdfloat advance = 0.0f; - + if (first_glyph != (TextGlyph *)NULL) { advance = first_glyph->get_advance() * advance_scale; } @@ -701,40 +642,32 @@ calc_width(wchar_t character, const TextProperties &properties) { return advance * glyph_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_width -// Access: Published, Static -// Description: Returns the width of a single TextGraphic image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a single TextGraphic image. + */ PN_stdfloat TextAssembler:: calc_width(const TextGraphic *graphic, const TextProperties &properties) { LVecBase4 frame = graphic->get_frame(); return (frame[1] - frame[0]) * properties.get_glyph_scale() * properties.get_text_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::has_exact_character -// Access: Published, Static -// Description: Returns true if the named character exists in the -// font exactly as named, false otherwise. Note that -// because Panda can assemble glyphs together -// automatically using cheesy accent marks, this is not -// a reliable indicator of whether a suitable glyph can -// be rendered for the character. For that, use -// has_character() instead. -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// but returns false for characters that would render -// with the "invalid glyph". It also returns false for -// characters that would be synthesized within Panda, -// but see has_character(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named character exists in the font exactly as named, + * false otherwise. Note that because Panda can assemble glyphs together + * automatically using cheesy accent marks, this is not a reliable indicator + * of whether a suitable glyph can be rendered for the character. For that, + * use has_character() instead. + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), but returns false for characters that would render with + * the "invalid glyph". It also returns false for characters that would be + * synthesized within Panda, but see has_character(). + */ bool TextAssembler:: has_exact_character(wchar_t character, const TextProperties &properties) { if (character == ' ' || character == '\n') { - // A space is a special case. Every font implicitly has a space. - // We also treat newlines specially. + // A space is a special case. Every font implicitly has a space. We also + // treat newlines specially. return true; } @@ -745,24 +678,20 @@ has_exact_character(wchar_t character, const TextProperties &properties) { return font->get_glyph(character, glyph); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::has_character -// Access: Published, Static -// Description: Returns true if the named character exists in the -// font or can be synthesized by Panda, false otherwise. -// (Panda can synthesize some accented characters by -// combining similar-looking glyphs from the font.) -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// but returns false for characters that would render -// with the "invalid glyph". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named character exists in the font or can be + * synthesized by Panda, false otherwise. (Panda can synthesize some accented + * characters by combining similar-looking glyphs from the font.) + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), but returns false for characters that would render with + * the "invalid glyph". + */ bool TextAssembler:: has_character(wchar_t character, const TextProperties &properties) { if (character == ' ' || character == '\n') { - // A space is a special case. Every font implicitly has a space. - // We also treat newlines specially. + // A space is a special case. Every font implicitly has a space. We also + // treat newlines specially. return true; } @@ -773,33 +702,26 @@ has_character(wchar_t character, const TextProperties &properties) { int additional_flags; PN_stdfloat glyph_scale; PN_stdfloat advance_scale; - get_character_glyphs(character, &properties, + get_character_glyphs(character, &properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); return got_glyph; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::is_whitespace -// Access: Published, Static -// Description: Returns true if the indicated character represents -// whitespace in the font, or false if anything visible -// will be rendered for it. -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// and returns false for any other characters, including -// characters that do not exist in the font (these would -// be rendered with the "invalid glyph", which is -// visible). -// -// Note that this function can be reliably used to -// identify Unicode whitespace characters only if the -// font has all of the whitespace characters defined. -// It will return false for any character not in the -// font, even if it is an official Unicode whitespace -// character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character represents whitespace in the font, + * or false if anything visible will be rendered for it. + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), and returns false for any other characters, including + * characters that do not exist in the font (these would be rendered with the + * "invalid glyph", which is visible). + * + * Note that this function can be reliably used to identify Unicode whitespace + * characters only if the font has all of the whitespace characters defined. + * It will return false for any character not in the font, even if it is an + * official Unicode whitespace character. + */ bool TextAssembler:: is_whitespace(wchar_t character, const TextProperties &properties) { if (character == ' ' || character == '\n') { @@ -819,23 +741,21 @@ is_whitespace(wchar_t character, const TextProperties &properties) { return glyph->is_whitespace(); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::scan_wtext -// Access: Private -// Description: Scans through the text string, decoding embedded -// references to TextProperties. The decoded string is -// copied character-by-character into _text_string. -//////////////////////////////////////////////////////////////////// +/** + * Scans through the text string, decoding embedded references to + * TextProperties. The decoded string is copied character-by-character into + * _text_string. + */ void TextAssembler:: scan_wtext(TextAssembler::TextString &output_string, - wstring::const_iterator &si, + wstring::const_iterator &si, const wstring::const_iterator &send, TextAssembler::ComputedProperties *current_cprops) { while (si != send) { if ((*si) == text_push_properties_key) { - // This indicates a nested properties structure. Pull off the - // name of the TextProperties structure, which is everything - // until the next text_push_properties_key. + // This indicates a nested properties structure. Pull off the name of + // the TextProperties structure, which is everything until the next + // text_push_properties_key. wstring wname; ++si; while (si != send && (*si) != text_push_properties_key) { @@ -844,35 +764,34 @@ scan_wtext(TextAssembler::TextString &output_string, } if (si == send) { - // We didn't close the text_push_properties_key. That's an - // error. + // We didn't close the text_push_properties_key. That's an error. text_cat.warning() << "Unclosed push_properties in text.\n"; return; } ++si; - + // Define the new properties by extending the current properties. - PT(ComputedProperties) new_cprops = + PT(ComputedProperties) new_cprops = new ComputedProperties(current_cprops, wname, _encoder); - + // And recursively scan with the nested properties. scan_wtext(output_string, si, send, new_cprops); if (text_cat.is_debug()) { if (si == send) { - // The push was not closed by a pop. That's not an error, - // since we allow people to be sloppy about that; but we'll - // print a debug message at least. + // The push was not closed by a pop. That's not an error, since we + // allow people to be sloppy about that; but we'll print a debug + // message at least. text_cat.debug() << "push_properties not matched by pop_properties.\n"; } } } else if ((*si) == text_pop_properties_key) { - // This indicates the undoing of a previous push_properties_key. - // We simply return to the previous level. + // This indicates the undoing of a previous push_properties_key. We + // simply return to the previous level. ++si; return; @@ -889,8 +808,7 @@ scan_wtext(TextAssembler::TextString &output_string, } if (si == send) { - // We didn't close the text_embed_graphic_key. That's an - // error. + // We didn't close the text_embed_graphic_key. That's an error. text_cat.warning() << "Unclosed embed_graphic in text.\n"; return; @@ -898,11 +816,11 @@ scan_wtext(TextAssembler::TextString &output_string, ++si; - // Now we have to encode the wstring into a string, for lookup - // in the TextPropertiesManager. + // Now we have to encode the wstring into a string, for lookup in the + // TextPropertiesManager. string graphic_name = _encoder->encode_wtext(graphic_wname); - - TextPropertiesManager *manager = + + TextPropertiesManager *manager = TextPropertiesManager::get_global_ptr(); // Get the graphic image. @@ -923,22 +841,18 @@ scan_wtext(TextAssembler::TextString &output_string, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::wordwrap_text -// Access: Private -// Description: Inserts newlines into the _text_string at the -// appropriate places in order to make each line be the -// longest possible line that is not longer than -// wordwrap_width (and does not break any words, if -// possible). Stores the result in _text_block. -// -// If _max_rows is greater than zero, no more than -// _max_rows will be accepted. Text beyond that will be -// truncated. -// -// The return value is true if all the text is accepted, -// or false if some was truncated. -//////////////////////////////////////////////////////////////////// +/** + * Inserts newlines into the _text_string at the appropriate places in order + * to make each line be the longest possible line that is not longer than + * wordwrap_width (and does not break any words, if possible). Stores the + * result in _text_block. + * + * If _max_rows is greater than zero, no more than _max_rows will be accepted. + * Text beyond that will be truncated. + * + * The return value is true if all the text is accepted, or false if some was + * truncated. + */ bool TextAssembler:: wordwrap_text() { _text_block.clear(); @@ -974,8 +888,8 @@ wordwrap_text() { while (p < _text_string.size()) { nassertr(!isspacew(_text_string[p]._character), false); - // Scan the next n characters, until the end of the string or an - // embedded newline character, or we exceed wordwrap_width. + // Scan the next n characters, until the end of the string or an embedded + // newline character, or we exceed wordwrap_width. size_t q = p; bool any_spaces = false; @@ -998,13 +912,13 @@ wordwrap_text() { wordwrap_width = -1.0f; } - if (isspacew(_text_string[q]._character) || + if (isspacew(_text_string[q]._character) || _text_string[q]._character == text_soft_break_key) { if (!last_was_space) { any_spaces = true; // We only care about logging whether there is a soft-hyphen - // character to the right of the rightmost space. Each time - // we encounter a space, we reset this counter. + // character to the right of the rightmost space. Each time we + // encounter a space, we reset this counter. any_hyphens = false; last_space = q; last_space_width = width; @@ -1014,14 +928,13 @@ wordwrap_text() { last_was_space = false; } - // A soft hyphen character is not printed, but marks a point - // at which we might hyphenate a word if we need to. + // A soft hyphen character is not printed, but marks a point at which we + // might hyphenate a word if we need to. if (_text_string[q]._character == text_soft_hyphen_key) { if (wordwrap_width > 0.0f) { - // We only consider this as a possible hyphenation point if - // (a) it is not the very first character, and (b) there is - // enough room for a hyphen character to be printed following - // it. + // We only consider this as a possible hyphenation point if (a) it + // is not the very first character, and (b) there is enough room for + // a hyphen character to be printed following it. if (q != p && width + calc_hyphen_width(_text_string[q]) <= wordwrap_width) { any_hyphens = true; last_hyphen = q; @@ -1033,7 +946,7 @@ wordwrap_text() { } q++; - + if (wordwrap_width > 0.0f && width > wordwrap_width) { // Oops, too many. q--; @@ -1043,14 +956,14 @@ wordwrap_text() { } if (overflow) { - // If we stopped because we exceeded the wordwrap width, then - // try to find an appropriate place to wrap the line or to - // hyphenate, if necessary. + // If we stopped because we exceeded the wordwrap width, then try to + // find an appropriate place to wrap the line or to hyphenate, if + // necessary. nassertr(wordwrap_width > 0.0f, false); if (any_spaces && last_space_width / wordwrap_width >= text_hyphen_ratio) { - // If we have a space that ended up within our safety margin, - // don't use any soft-hyphen characters. + // If we have a space that ended up within our safety margin, don't + // use any soft-hyphen characters. any_hyphens = false; } @@ -1064,11 +977,11 @@ wordwrap_text() { q = last_space; } else { - // Otherwise, this is a forced break. Accept the longest line - // we can that does not leave the next line beginning with one - // of our forbidden characters. + // Otherwise, this is a forced break. Accept the longest line we can + // that does not leave the next line beginning with one of our + // forbidden characters. size_t i = 0; - while ((int)i < text_max_never_break && q - i > p && + while ((int)i < text_max_never_break && q - i > p && get_text_never_break_before().find(_text_string[q - i]._character) != wstring::npos) { i++; } @@ -1080,7 +993,7 @@ wordwrap_text() { // Skip additional whitespace between the lines. size_t next_start = q; - while (next_start < _text_string.size() && + while (next_start < _text_string.size() && isbreakpoint(_text_string[next_start]._character)) { next_start++; } @@ -1091,23 +1004,23 @@ wordwrap_text() { } if (next_start == p) { - // No characters got in at all. This could only happen if the - // wordwrap width is narrower than a single character, or if we - // have a substantial number of leading spaces in a line. + // No characters got in at all. This could only happen if the wordwrap + // width is narrower than a single character, or if we have a + // substantial number of leading spaces in a line. if (initial_width == 0.0f) { - // There was no leading whitespace on the line, so the - // character itself didn't fit within the margins. Let it in - // anyway; what else can we do? + // There was no leading whitespace on the line, so the character + // itself didn't fit within the margins. Let it in anyway; what else + // can we do? q++; next_start++; - while (next_start < _text_string.size() && + while (next_start < _text_string.size() && isbreakpoint(_text_string[next_start]._character)) { next_start++; } } } - + if (needs_newline) { if (_max_rows > 0 && (int)_text_block.size() >= _max_rows) { // Truncate. @@ -1124,7 +1037,7 @@ wordwrap_text() { } for (size_t pi = p; pi < q; pi++) { - if (_text_string[pi]._character != text_soft_hyphen_key && + if (_text_string[pi]._character != text_soft_hyphen_key && _text_string[pi]._character != text_soft_break_key) { _text_block.back()._string.push_back(_text_string[pi]); } else { @@ -1178,13 +1091,10 @@ wordwrap_text() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::calc_hyphen_width -// Access: Private, Static -// Description: Returns the width of the soft-hyphen replacement -// string, according to the indicated character's -// associated font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the soft-hyphen replacement string, according to the + * indicated character's associated font. + */ PN_stdfloat TextAssembler:: calc_hyphen_width(const TextCharacter &tch) { TextFont *font = tch._cprops->_properties.get_font(); @@ -1198,16 +1108,13 @@ calc_hyphen_width(const TextCharacter &tch) { ++wi) { hyphen_width += calc_width(*wi, tch._cprops->_properties); } - + return hyphen_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::generate_quads -// Access: Private -// Description: Generates Geoms for the given quads and adds them -// to the GeomNode. -//////////////////////////////////////////////////////////////////// +/** + * Generates Geoms for the given quads and adds them to the GeomNode. + */ void TextAssembler:: generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { QuadMap::const_iterator qmi; @@ -1218,8 +1125,8 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { static CPT(GeomVertexFormat) format; if (format.is_null()) { - // The optimized code below assumes 32-bit floats, so let's - // make sure we got the right format by creating it ourselves. + // The optimized code below assumes 32-bit floats, so let's make sure we + // got the right format by creating it ourselves. format = GeomVertexFormat::register_format(new GeomVertexArrayFormat( InternalName::get_vertex(), 3, GeomEnums::NT_float32, GeomEnums::C_point, InternalName::get_texcoord(), 2, GeomEnums::NT_float32, GeomEnums::C_texcoord)); @@ -1237,9 +1144,9 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { int i = 0; - // This is quite a critical loop and GeomVertexWriter quickly becomes - // the bottleneck. So, I've written this out the hard way instead. - // Two versions of the loop: one for 32-bit indices, one for 16-bit. + // This is quite a critical loop and GeomVertexWriter quickly becomes the + // bottleneck. So, I've written this out the hard way instead. Two + // versions of the loop: one for 32-bit indices, one for 16-bit. { PT(GeomVertexArrayDataHandle) vtx_handle = vdata->modify_array(0)->modify_handle(); vtx_handle->unclean_set_num_rows(quads.size() * 4); @@ -1377,13 +1284,10 @@ generate_quads(GeomNode *geom_node, const QuadMap &quad_map) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::assemble_paragraph -// Access: Private -// Description: Fills up placed_glyphs, _ul, _lr with -// the contents of _text_block. Also updates _xpos and -// _ypos within the _text_block structure. -//////////////////////////////////////////////////////////////////// +/** + * Fills up placed_glyphs, _ul, _lr with the contents of _text_block. Also + * updates _xpos and _ypos within the _text_block structure. + */ void TextAssembler:: assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { _ul.set(0.0f, 0.0f); @@ -1405,22 +1309,24 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { assemble_row(row, placed_glyphs, row_width, line_height, align, wordwrap); - // Now move the row to its appropriate position. This might - // involve a horizontal as well as a vertical translation. + // Now move the row to its appropriate position. This might involve a + // horizontal as well as a vertical translation. if (num_rows == 0) { // If this is the first row, account for its space. _ul[1] = 0.8f * line_height; } else { - // If it is not the first row, shift the text downward by - // line_height from the previous row. + // If it is not the first row, shift the text downward by line_height + // from the previous row. ypos -= line_height; } _lr[1] = ypos - 0.2 * line_height; - // Apply the requested horizontal alignment to the row. - //[fabius] added a different concept of text alignment based upon a boxed region where his width is defined by the wordwrap size with the upper left corner starting from 0,0,0 - // if the wordwrap size is unspecified the alignment could eventually result wrong. + // Apply the requested horizontal alignment to the row. [fabius] added a + // different concept of text alignment based upon a boxed region where his + // width is defined by the wordwrap size with the upper left corner + // starting from 0,0,0 if the wordwrap size is unspecified the alignment + // could eventually result wrong. PN_stdfloat xpos; switch (align) { case TextProperties::A_left: @@ -1471,24 +1377,21 @@ assemble_paragraph(TextAssembler::PlacedGlyphs &placed_glyphs) { _next_row_ypos = ypos - line_height; } - // num_rows may be smaller than _text_block.size(), if there are - // trailing newlines on the string. + // num_rows may be smaller than _text_block.size(), if there are trailing + // newlines on the string. } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::assemble_row -// Access: Private -// Description: Assembles the letters in the source string, up until -// the first newline or the end of the string into a -// single row (which is parented to _geom_node), and -// computes the length of the row and the maximum -// line_height of all the fonts used in the row. The -// source pointer is moved to the terminating character. -//////////////////////////////////////////////////////////////////// +/** + * Assembles the letters in the source string, up until the first newline or + * the end of the string into a single row (which is parented to _geom_node), + * and computes the length of the row and the maximum line_height of all the + * fonts used in the row. The source pointer is moved to the terminating + * character. + */ void TextAssembler:: assemble_row(TextAssembler::TextRow &row, TextAssembler::PlacedGlyphs &placed_glyphs, - PN_stdfloat &row_width, PN_stdfloat &line_height, + PN_stdfloat &row_width, PN_stdfloat &line_height, TextProperties::Alignment &align, PN_stdfloat &wordwrap) { Thread *current_thread = Thread::get_current_thread(); @@ -1529,19 +1432,19 @@ assemble_row(TextAssembler::TextRow &row, align = properties->get_align(); } - //[fabius] a good place to take wordwrap size + // [fabius] a good place to take wordwrap size if (properties->get_wordwrap() > 0.0f) { wordwrap = properties->get_wordwrap(); } - // And the height of the row is the maximum of all the fonts used - // within the row. + // And the height of the row is the maximum of all the fonts used within + // the row. if (graphic != (TextGraphic *)NULL) { LVecBase4 frame = graphic->get_frame(); line_height = max(line_height, frame[3] - frame[2]); } else { - //[fabius] this is not the right place to calc line height (see below) - // line_height = max(line_height, font->get_line_height()); + // [fabius] this is not the right place to calc line height (see below) + // line_height = max(line_height, font->get_line_height()); } if (character == ' ') { @@ -1562,16 +1465,15 @@ assemble_row(TextAssembler::TextRow &row, PT(PandaNode) model = graphic->get_model().node(); if (graphic->get_instance_flag()) { - // Instance the model in. Create a ModelNode so it doesn't - // get flattened. + // Instance the model in. Create a ModelNode so it doesn't get + // flattened. PT(ModelNode) model_node = new ModelNode(""); model_node->set_preserve_transform(ModelNode::PT_no_touch); model_node->add_child(model); placement._graphic_model = model_node.p(); } else { - // Copy the model in. This the preferred way; it's a little - // cheaper to render than instancing (because flattening is - // more effective). + // Copy the model in. This the preferred way; it's a little cheaper + // to render than instancing (because flattening is more effective). placement._graphic_model = model->copy_subgraph(); } @@ -1580,8 +1482,8 @@ assemble_row(TextAssembler::TextRow &row, PN_stdfloat advance = (frame[1] - frame[0]); - // Now compute the matrix that will transform the glyph (or - // glyphs) into position. + // Now compute the matrix that will transform the glyph (or glyphs) into + // position. placement._scale = properties->get_glyph_scale(); placement._xpos = (xpos - frame[0]); placement._ypos = (properties->get_glyph_shift() - frame[2]); @@ -1600,7 +1502,7 @@ assemble_row(TextAssembler::TextRow &row, int additional_flags; PN_stdfloat glyph_scale; PN_stdfloat advance_scale; - get_character_glyphs(character, properties, + get_character_glyphs(character, properties, got_glyph, first_glyph, second_glyph, accent_type, additional_flags, glyph_scale, advance_scale); @@ -1608,7 +1510,7 @@ assemble_row(TextAssembler::TextRow &row, char buffer[512]; sprintf(buffer, "U+%04x", character); text_cat.warning() - << "No definition in " << font->get_name() + << "No definition in " << font->get_name() << " for character " << buffer; if (character < 128 && isprint((unsigned int)character)) { text_cat.warning(false) @@ -1618,10 +1520,10 @@ assemble_row(TextAssembler::TextRow &row, << "\n"; } - // Build up a GlyphPlacement, indicating all of the Geoms that go - // into this character. Normally, there is only one Geom per - // character, but it may involve multiple Geoms if we need to - // add cheesy accents or ligatures. + // Build up a GlyphPlacement, indicating all of the Geoms that go into + // this character. Normally, there is only one Geom per character, but + // it may involve multiple Geoms if we need to add cheesy accents or + // ligatures. GlyphPlacement placement; glyph_scale *= properties->get_glyph_scale() * properties->get_text_scale(); @@ -1635,9 +1537,8 @@ assemble_row(TextAssembler::TextRow &row, PN_stdfloat advance = 0.0f; if (accent_type != UnicodeLatinMap::AT_none || additional_flags != 0) { - // If we have some special handling to perform, do so now. - // This will probably require the bounding volume of the - // glyph, so go get that. + // If we have some special handling to perform, do so now. This will + // probably require the bounding volume of the glyph, so go get that. LPoint3 min_vert, max_vert; bool found_any = false; if (first_glyph != NULL) { @@ -1653,17 +1554,16 @@ assemble_row(TextAssembler::TextRow &row, LPoint3 centroid = (min_vert + max_vert) / 2.0f; if ((additional_flags & UnicodeLatinMap::AF_turned) != 0) { - // Invert the character. Should we also invert the accent - // mark, so that an accent that would have been above the - // glyph will now be below it? That's what we do here, - // which is probably the right thing to do for n-tilde, - // but not for most of the rest of the accent marks. For - // now we'll assume there are no characters with accent - // marks that also have the turned flag. + // Invert the character. Should we also invert the accent mark, + // so that an accent that would have been above the glyph will now + // be below it? That's what we do here, which is probably the + // right thing to do for n-tilde, but not for most of the rest of + // the accent marks. For now we'll assume there are no characters + // with accent marks that also have the turned flag. - // We rotate the character around its centroid, which may - // not always be the right point, but it's the best we've - // got and it's probably pretty close. + // We rotate the character around its centroid, which may not + // always be the right point, but it's the best we've got and it's + // probably pretty close. placement._scale *= -1; placement._xpos += centroid[0] * 2; placement._ypos += centroid[2] * 2; @@ -1685,8 +1585,8 @@ assemble_row(TextAssembler::TextRow &row, placed_glyphs.push_back(placement); } - // Check if there is a second glyph to create a hacky ligature or - // some such nonsense. + // Check if there is a second glyph to create a hacky ligature or some + // such nonsense. if (second_glyph != (TextGlyph *)NULL) { placement._xpos += advance * glyph_scale; advance += second_glyph->get_advance(); @@ -1707,9 +1607,9 @@ assemble_row(TextAssembler::TextRow &row, row_width = xpos; if (row._eol_cprops != (ComputedProperties *)NULL) { - // If there's an _eol_cprops, it represents the cprops of the - // newline character that ended the line, which should also - // contribute towards the line_height. + // If there's an _eol_cprops, it represents the cprops of the newline + // character that ended the line, which should also contribute towards the + // line_height. const TextProperties *properties = &(row._eol_cprops->_properties); TextFont *font = properties->get_font(); @@ -1722,19 +1622,17 @@ assemble_row(TextAssembler::TextRow &row, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::draw_underscore -// Access: Private, Static -// Description: Creates the geometry to render the underscore line -// for the indicated range of glyphs in this row. -//////////////////////////////////////////////////////////////////// +/** + * Creates the geometry to render the underscore line for the indicated range + * of glyphs in this row. + */ void TextAssembler:: draw_underscore(TextAssembler::PlacedGlyphs &placed_glyphs, PN_stdfloat underscore_start, PN_stdfloat underscore_end, const TextProperties *underscore_properties) { CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3cp(); - PT(GeomVertexData) vdata = + PT(GeomVertexData) vdata = new GeomVertexData("underscore", format, Geom::UH_static); vdata->unclean_set_num_rows(2); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); @@ -1755,9 +1653,10 @@ draw_underscore(TextAssembler::PlacedGlyphs &placed_glyphs, PT(TextGlyph) glyph = new TextGlyph(0, geom, RenderState::make_empty(), 0); - // Eventually we should probably replace this with the set_quad - // approach, or better, for improved performance. - //glyph->set_quad(LVecBase4(underscore_start, y, underscore_end, y+0.1), LVecBase4(0), RenderState::make_empty()); + // Eventually we should probably replace this with the set_quad approach, or + // better, for improved performance. + // glyph->set_quad(LVecBase4(underscore_start, y, underscore_end, y+0.1), + // LVecBase4(0), RenderState::make_empty()); GlyphPlacement placement; placement._glyph = MOVE(glyph); @@ -1769,25 +1668,18 @@ draw_underscore(TextAssembler::PlacedGlyphs &placed_glyphs, placed_glyphs.push_back(placement); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::get_character_glyphs -// Access: Private, Static -// Description: Looks up the glyph(s) from the font for the -// appropriate character. If the desired glyph isn't -// available (especially in the case of an accented -// letter), tries to find a suitable replacement. -// Normally, only one glyph is returned per character, -// but in the case in which we have to simulate a -// missing ligature in the font, two glyphs might be -// returned. -// -// All parameters except the first two are output -// parameters. got_glyph is set true if the glyph (or -// an acceptable substitute) is successfully found, -// false otherwise; but even if it is false, glyph might -// still be non-NULL, indicating a stand-in glyph for a -// missing character. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the glyph(s) from the font for the appropriate character. If the + * desired glyph isn't available (especially in the case of an accented + * letter), tries to find a suitable replacement. Normally, only one glyph is + * returned per character, but in the case in which we have to simulate a + * missing ligature in the font, two glyphs might be returned. + * + * All parameters except the first two are output parameters. got_glyph is + * set true if the glyph (or an acceptable substitute) is successfully found, + * false otherwise; but even if it is false, glyph might still be non-NULL, + * indicating a stand-in glyph for a missing character. + */ void TextAssembler:: get_character_glyphs(int character, const TextProperties *properties, bool &got_glyph, CPT(TextGlyph) &glyph, @@ -1806,23 +1698,23 @@ get_character_glyphs(int character, const TextProperties *properties, glyph_scale = 1.0f; advance_scale = 1.0f; - // Maybe we should remap the character to something else--e.g. a - // small capital. - const UnicodeLatinMap::Entry *map_entry = + // Maybe we should remap the character to something else--e.g. a small + // capital. + const UnicodeLatinMap::Entry *map_entry = UnicodeLatinMap::look_up(character); if (map_entry != NULL) { - if (properties->get_small_caps() && + if (properties->get_small_caps() && map_entry->_toupper_character != character) { character = map_entry->_toupper_character; map_entry = UnicodeLatinMap::look_up(character); glyph_scale = properties->get_small_caps_scale(); } } - + got_glyph = font->get_glyph(character, glyph); if (!got_glyph && map_entry != NULL && map_entry->_ascii_equiv != 0) { - // If we couldn't find the Unicode glyph, try the ASCII - // equivalent (without the accent marks). + // If we couldn't find the Unicode glyph, try the ASCII equivalent + // (without the accent marks). if (map_entry->_ascii_equiv == 'i') { // Special case for the i: we want to try the dotless variant first. got_glyph = font->get_glyph(0x0131, glyph) || @@ -1836,36 +1728,35 @@ get_character_glyphs(int character, const TextProperties *properties, } else { got_glyph = font->get_glyph(map_entry->_ascii_equiv, glyph); } - + if (!got_glyph && map_entry->_toupper_character != character) { - // If we still couldn't find it, try the uppercase - // equivalent. + // If we still couldn't find it, try the uppercase equivalent. character = map_entry->_toupper_character; map_entry = UnicodeLatinMap::look_up(character); if (map_entry != NULL) { got_glyph = font->get_glyph(map_entry->_ascii_equiv, glyph); } } - + if (got_glyph) { accent_type = map_entry->_accent_type; additional_flags = map_entry->_additional_flags; - + bool got_second_glyph = false; if (map_entry->_ascii_additional != 0) { // There's another character, too--probably a ligature. - got_second_glyph = + got_second_glyph = font->get_glyph(map_entry->_ascii_additional, second_glyph); } if ((additional_flags & UnicodeLatinMap::AF_ligature) != 0 && got_second_glyph) { - // If we have two letters that are supposed to be in a - // ligature, just jam them together. + // If we have two letters that are supposed to be in a ligature, just + // jam them together. additional_flags &= ~UnicodeLatinMap::AF_ligature; advance_scale = ligature_advance_scale; } - + if ((additional_flags & UnicodeLatinMap::AF_smallcap) != 0) { additional_flags &= ~UnicodeLatinMap::AF_smallcap; glyph_scale = properties->get_small_caps_scale(); @@ -1874,18 +1765,15 @@ get_character_glyphs(int character, const TextProperties *properties, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::tack_on_accent -// Access: Private -// Description: This is a cheesy attempt to tack on an accent to an -// ASCII letter for which we don't have the appropriate -// already-accented glyph in the font. -//////////////////////////////////////////////////////////////////// +/** + * This is a cheesy attempt to tack on an accent to an ASCII letter for which + * we don't have the appropriate already-accented glyph in the font. + */ void TextAssembler:: tack_on_accent(UnicodeLatinMap::AccentType accent_type, const LPoint3 &min_vert, const LPoint3 &max_vert, const LPoint3 ¢roid, - const TextProperties *properties, + const TextProperties *properties, TextAssembler::GlyphPlacement &placement) const { // Look for a combining accent mark character. @@ -1899,10 +1787,10 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type, switch (accent_type) { case UnicodeLatinMap::AT_grave: - // We use the slash as the grave and acute accents. ASCII does - // have a grave accent character, but a lot of fonts put the - // reverse apostrophe there instead. And some fonts (particularly - // fonts from mf) don't even do backslash. + // We use the slash as the grave and acute accents. ASCII does have a + // grave accent character, but a lot of fonts put the reverse apostrophe + // there instead. And some fonts (particularly fonts from mf) don't even + // do backslash. tack_on_accent('/', CP_above, CT_small_squash_mirror_y, min_vert, max_vert, centroid, properties, placement); break; @@ -2004,8 +1892,8 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type, properties, placement) || tack_on_accent('c', CP_bottom, CT_tiny_mirror_x, min_vert, max_vert, centroid, properties, placement); - //tack_on_accent(',', CP_bottom, CT_none, min_vert, max_vert, centroid, - // properties, placement); + // tack_on_accent(',', CP_bottom, CT_none, min_vert, max_vert, centroid, + // properties, placement); break; case UnicodeLatinMap::AT_comma_below: @@ -2029,14 +1917,11 @@ tack_on_accent(UnicodeLatinMap::AccentType accent_type, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::tack_on_accent -// Access: Private -// Description: Generates a cheesy accent mark above (or below, etc.) -// the character. Returns true if successful, or false -// if the named accent character doesn't exist in the -// font. -//////////////////////////////////////////////////////////////////// +/** + * Generates a cheesy accent mark above (or below, etc.) the character. + * Returns true if successful, or false if the named accent character doesn't + * exist in the font. + */ bool TextAssembler:: tack_on_accent(wchar_t accent_mark, TextAssembler::CheesyPosition position, TextAssembler::CheesyTransform transform, @@ -2288,13 +2173,10 @@ tack_on_accent(wchar_t accent_mark, TextAssembler::CheesyPosition position, return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::ComputedProperties::append_delta -// Access: Public -// Description: Appends to wtext the control sequences necessary to -// change from this ComputedProperties to the indicated -// ComputedProperties. -//////////////////////////////////////////////////////////////////// +/** + * Appends to wtext the control sequences necessary to change from this + * ComputedProperties to the indicated ComputedProperties. + */ void TextAssembler::ComputedProperties:: append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { if (this != other) { @@ -2304,7 +2186,7 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other); - + } else if (other->_depth > _depth) { // Back up a level from the other properties. nassertv(other->_based_on != NULL); @@ -2313,11 +2195,11 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { wtext.push_back(text_push_properties_key); wtext += other->_wname; wtext.push_back(text_push_properties_key); - + } else if (_depth != 0) { // Back up a level from both properties. nassertv(_based_on != NULL && other->_based_on != NULL); - + wtext.push_back(text_pop_properties_key); _based_on->append_delta(wtext, other->_based_on); wtext.push_back(text_push_properties_key); @@ -2327,13 +2209,10 @@ append_delta(wstring &wtext, TextAssembler::ComputedProperties *other) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GlyphPlacement::assign_to -// Access: Private -// Description: Puts the pieces of the GlyphPlacement in the -// indicated GeomNode. The vertices of the Geoms are -// modified by this operation. -//////////////////////////////////////////////////////////////////// +/** + * Puts the pieces of the GlyphPlacement in the indicated GeomNode. The + * vertices of the Geoms are modified by this operation. + */ void TextAssembler::GlyphPlacement:: assign_to(GeomNode *geom_node, const RenderState *state, const LVector2 &offset) const { @@ -2348,14 +2227,11 @@ assign_to(GeomNode *geom_node, const RenderState *state, geom_node->add_geom(geom, state->compose(_glyph->get_state())); } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GlyphPlacement::assign_append_to -// Access: Private -// Description: Puts the pieces of the GlyphPlacement in the -// indicated GeomNode. This flavor will append the -// Geoms with the additional transform applied to the -// vertices. -//////////////////////////////////////////////////////////////////// +/** + * Puts the pieces of the GlyphPlacement in the indicated GeomNode. This + * flavor will append the Geoms with the additional transform applied to the + * vertices. + */ void TextAssembler::GlyphPlacement:: assign_append_to(GeomCollectorMap &geom_collector_map, const RenderState *state, @@ -2381,9 +2257,8 @@ assign_append_to(GeomCollectorMap &geom_collector_map, GeomCollector &geom_collector = (*mi).second; geom_collector.count_geom(geom); - // We use this map to keep track of vertex indices we have already - // added, so that we don't needlessly duplicate vertices into our - // output vertex data. + // We use this map to keep track of vertex indices we have already added, so + // that we don't needlessly duplicate vertices into our output vertex data. VertexIndexMap vimap; for (p = 0; p < geom->get_num_primitives(); p++) { @@ -2392,8 +2267,7 @@ assign_append_to(GeomCollectorMap &geom_collector_map, // Get a new GeomPrimitive of the corresponding type. GeomPrimitive *new_prim = geom_collector.get_primitive(primitive->get_type()); - // Walk through all of the components (e.g. triangles) of the - // primitive. + // Walk through all of the components (e.g. triangles) of the primitive. for (sp = 0; sp < primitive->get_num_primitives(); sp++) { s = primitive->get_primitive_start(sp); e = primitive->get_primitive_end(sp); @@ -2406,17 +2280,16 @@ assign_append_to(GeomCollectorMap &geom_collector_map, pair added = vimap.insert(VertexIndexMap::value_type(vi, 0)); int new_vertex; if (added.second) { - // The insert succeeded. That means this is the first - // time we have encountered this vertex. + // The insert succeeded. That means this is the first time we have + // encountered this vertex. new_vertex = geom_collector.append_vertex(vdata, vi, xform); // Update the map with the newly-created target vertex index. (*(added.first)).second = new_vertex; } else { - // The insert failed. This means we have previously - // encountered this vertex, and we have already entered - // its target vertex index into the vimap. Extract that - // vertex index, so we can reuse it. + // The insert failed. This means we have previously encountered + // this vertex, and we have already entered its target vertex index + // into the vimap. Extract that vertex index, so we can reuse it. new_vertex = (*(added.first)).second; } new_prim->add_vertex(new_vertex); @@ -2426,12 +2299,10 @@ assign_append_to(GeomCollectorMap &geom_collector_map, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GlyphPlacement::assign_quad_to -// Access: Private -// Description: If this glyph is representable as a single quad, -// assigns it to the appropriate position in the map. -//////////////////////////////////////////////////////////////////// +/** + * If this glyph is representable as a single quad, assigns it to the + * appropriate position in the map. + */ void TextAssembler::GlyphPlacement:: assign_quad_to(QuadMap &quad_map, const RenderState *state, const LVector2 &offset) const { @@ -2449,12 +2320,10 @@ assign_quad_to(QuadMap &quad_map, const RenderState *state, } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GlyphPlacement::copy_graphic_to -// Access: Private -// Description: If the GlyphPlacement includes a special graphic, -// copies it to the indicated node. -//////////////////////////////////////////////////////////////////// +/** + * If the GlyphPlacement includes a special graphic, copies it to the + * indicated node. + */ void TextAssembler::GlyphPlacement:: copy_graphic_to(PandaNode *node, const RenderState *state) const { if (_graphic_model != (PandaNode *)NULL) { @@ -2475,12 +2344,10 @@ copy_graphic_to(PandaNode *node, const RenderState *state) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector Constructor -// Access: Public -// Description: constructs the GeomCollector class -// (Geom, GeomTriangles, vertexWriter, texcoordWriter..) -//////////////////////////////////////////////////////////////////// +/** + * constructs the GeomCollector class (Geom, GeomTriangles, vertexWriter, + * texcoordWriter..) + */ TextAssembler::GeomCollector:: GeomCollector(const GeomVertexFormat *format) : _vdata(new GeomVertexData("merged_geom", format, Geom::UH_static)), @@ -2488,11 +2355,9 @@ GeomCollector(const GeomVertexFormat *format) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextAssembler::GeomCollector:: GeomCollector(const TextAssembler::GeomCollector ©) : _vdata(copy._vdata), @@ -2500,14 +2365,11 @@ GeomCollector(const TextAssembler::GeomCollector ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector::get_primitive -// Access: Public -// Description: Returns a GeomPrimitive of the appropriate type. If -// one has not yet been created, returns a newly-created -// one; if one has previously been created of this type, -// returns the previously-created one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomPrimitive of the appropriate type. If one has not yet been + * created, returns a newly-created one; if one has previously been created of + * this type, returns the previously-created one. + */ GeomPrimitive *TextAssembler::GeomCollector:: get_primitive(TypeHandle prim_type) { if (prim_type == GeomTriangles::get_class_type()) { @@ -2536,12 +2398,10 @@ get_primitive(TypeHandle prim_type) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector::append_vertex -// Access: Public -// Description: Adds one vertex to the GeomVertexData. -// Returns the row number of the added vertex. -//////////////////////////////////////////////////////////////////// +/** + * Adds one vertex to the GeomVertexData. Returns the row number of the added + * vertex. + */ int TextAssembler::GeomCollector:: append_vertex(const GeomVertexData *orig_vdata, int orig_row, const LMatrix4 &xform) { @@ -2557,16 +2417,12 @@ append_vertex(const GeomVertexData *orig_vdata, int orig_row, } -//////////////////////////////////////////////////////////////////// -// Function: TextAssembler::GeomCollector::append_geom -// Access: Public -// Description: closes the geomTriangles and appends the geom to -// the given GeomNode -//////////////////////////////////////////////////////////////////// +/** + * closes the geomTriangles and appends the geom to the given GeomNode + */ void TextAssembler::GeomCollector:: append_geom(GeomNode *geom_node, const RenderState *state) { if (_geom->get_num_primitives() > 0) { geom_node->add_geom(_geom, state); } } - diff --git a/panda/src/text/textAssembler.h b/panda/src/text/textAssembler.h index d86f7b4d51..1215765bf5 100644 --- a/panda/src/text/textAssembler.h +++ b/panda/src/text/textAssembler.h @@ -1,16 +1,15 @@ -// Filename: textAssembler.h -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textAssembler.h + * @author drose + * @date 2004-04-06 + */ #ifndef TEXTASSEMBLER_H #define TEXTASSEMBLER_H @@ -34,15 +33,12 @@ class TextEncoder; class TextGraphic; class TextAssembler; -//////////////////////////////////////////////////////////////////// -// Class : TextAssembler -// Description : This class is not normally used directly by user -// code, but is used by the TextNode to lay out a block -// of text and convert it into rows of Geoms according -// to the TextProperties. However, user code may take -// advantage of it, if desired, for very low-level text -// operations. -//////////////////////////////////////////////////////////////////// +/** + * This class is not normally used directly by user code, but is used by the + * TextNode to lay out a block of text and convert it into rows of Geoms + * according to the TextProperties. However, user code may take advantage of + * it, if desired, for very low-level text operations. + */ class EXPCL_PANDA_TEXT TextAssembler { PUBLISHED: TextAssembler(TextEncoder *encoder); @@ -118,7 +114,7 @@ private: class ComputedProperties : public ReferenceCount { public: INLINE ComputedProperties(const TextProperties &orig_properties); - INLINE ComputedProperties(ComputedProperties *based_on, + INLINE ComputedProperties(ComputedProperties *based_on, const wstring &wname, TextEncoder *encoder); void append_delta(wstring &wtext, ComputedProperties *other); @@ -129,13 +125,13 @@ private: }; // These structures are built up and operated on by scan_wtext() and - // wordwrap_text(). It represents the unrolling of the embedded \1 - // .. \2 sequences embedded in the string into a TextProperties - // pointer associated with each character. + // wordwrap_text(). It represents the unrolling of the embedded \1 .. \2 + // sequences embedded in the string into a TextProperties pointer associated + // with each character. class TextCharacter { public: INLINE TextCharacter(wchar_t character, ComputedProperties *cprops); - INLINE TextCharacter(const TextGraphic *graphic, + INLINE TextCharacter(const TextGraphic *graphic, const wstring &graphic_wname, ComputedProperties *cprops); INLINE TextCharacter(const TextCharacter ©); @@ -172,7 +168,7 @@ private: TextBlock _text_block; void scan_wtext(TextString &output_string, - wstring::const_iterator &si, + wstring::const_iterator &si, const wstring::const_iterator &send, ComputedProperties *current_cprops); @@ -181,9 +177,8 @@ private: INLINE static PN_stdfloat calc_width(const TextCharacter &tch); static PN_stdfloat calc_hyphen_width(const TextCharacter &tch); - // These structures are built up by assemble_paragraph() and - // assemble_row(). They represent the actual Geoms as laid out in a - // paragraph. + // These structures are built up by assemble_paragraph() and assemble_row(). + // They represent the actual Geoms as laid out in a paragraph. class GeomCollectorKey { public: @@ -217,8 +212,8 @@ private: typedef pmap GeomCollectorMap; struct QuadDef { - // Copying this class is a performance hotspot, hence we define the - // move constructor. + // Copying this class is a performance hotspot, hence we define the move + // constructor. ALWAYS_INLINE QuadDef() {} ALWAYS_INLINE QuadDef(const QuadDef ©) : _dimensions(copy._dimensions), _uvs(copy._uvs), @@ -264,11 +259,11 @@ private: void assemble_paragraph(PlacedGlyphs &placed_glyphs); void assemble_row(TextRow &row, PlacedGlyphs &row_placed_glyphs, - PN_stdfloat &row_width, PN_stdfloat &line_height, + PN_stdfloat &row_width, PN_stdfloat &line_height, TextProperties::Alignment &align, PN_stdfloat &wordwrap); - // These interfaces are for implementing cheesy accent marks and - // ligatures when the font doesn't support them. + // These interfaces are for implementing cheesy accent marks and ligatures + // when the font doesn't support them. enum CheesyPosition { CP_above, CP_below, @@ -298,7 +293,7 @@ private: static void draw_underscore(TextAssembler::PlacedGlyphs &row_placed_glyphs, - PN_stdfloat underscore_start, PN_stdfloat underscore_end, + PN_stdfloat underscore_start, PN_stdfloat underscore_end, const TextProperties *underscore_properties); static void @@ -314,7 +309,7 @@ private: const LPoint3 &min_vert, const LPoint3 &max_vert, const LPoint3 ¢roid, const TextProperties *properties, GlyphPlacement &placement) const; - bool + bool tack_on_accent(wchar_t accent_mark, CheesyPosition position, CheesyTransform transform, const LPoint3 &min_vert, const LPoint3 &max_vert, @@ -337,4 +332,3 @@ private: #include "textAssembler.I" #endif - diff --git a/panda/src/text/textFont.I b/panda/src/text/textFont.I index c8d1aec4a2..88b742380b 100644 --- a/panda/src/text/textFont.I +++ b/panda/src/text/textFont.I @@ -1,104 +1,79 @@ -// Filename: textFont.I -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textFont.I + * @author drose + * @date 2002-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextFont::is_valid -// Access: Published -// Description: Returns true if the font is valid and ready to use, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the font is valid and ready to use, false otherwise. + */ INLINE bool TextFont:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::operator bool -// Access: Published -// Description: Returns true if the font is valid and ready to use, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the font is valid and ready to use, false otherwise. + */ INLINE TextFont:: operator bool () const { return is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::get_line_height -// Access: Published -// Description: Returns the number of units high each line of text -// is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units high each line of text is. + */ INLINE PN_stdfloat TextFont:: get_line_height() const { return _line_height; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::set_line_height -// Access: Published -// Description: Changes the number of units high each line of text -// is. -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of units high each line of text is. + */ INLINE void TextFont:: set_line_height(PN_stdfloat line_height) { _line_height = line_height; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::get_space_advance -// Access: Published -// Description: Returns the number of units wide a space is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units wide a space is. + */ INLINE PN_stdfloat TextFont:: get_space_advance() const { return _space_advance; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::set_space_advance -// Access: Published -// Description: Changes the number of units wide a space is. -//////////////////////////////////////////////////////////////////// +/** + * Changes the number of units wide a space is. + */ INLINE void TextFont:: set_space_advance(PN_stdfloat space_advance) { _space_advance = space_advance; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::get_total_poly_margin -// Access: Public -// Description: Returns the total margin between the edge of the -// glyph and the edge of the cards. This includes -// _poly_margin and any additional outline. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total margin between the edge of the glyph and the edge of the + * cards. This includes _poly_margin and any additional outline. + */ INLINE PN_stdfloat TextFont:: get_total_poly_margin() const { return _total_poly_margin; } -//////////////////////////////////////////////////////////////////// -// Function: DynamicTextFont::get_glyph -// Access: Public, Virtual -// Description: Gets the glyph associated with the given character -// code, as well as an optional scaling parameter that -// should be applied to the glyph's geometry and advance -// parameters. Returns the glyph on success. On failure, -// it may still return a printable glyph, or it may -// return NULL. -//////////////////////////////////////////////////////////////////// +/** + * Gets the glyph associated with the given character code, as well as an + * optional scaling parameter that should be applied to the glyph's geometry + * and advance parameters. Returns the glyph on success. On failure, it may + * still return a printable glyph, or it may return NULL. + */ INLINE CPT(TextGlyph) TextFont:: get_glyph(int character) { CPT(TextGlyph) glyph; diff --git a/panda/src/text/textFont.cxx b/panda/src/text/textFont.cxx index 3516bfb6d5..70ca9a74d5 100644 --- a/panda/src/text/textFont.cxx +++ b/panda/src/text/textFont.cxx @@ -1,16 +1,15 @@ -// Filename: textFont.cxx -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textFont.cxx + * @author drose + * @date 2002-02-08 + */ #include "textFont.h" #include "config_text.h" @@ -24,11 +23,9 @@ TypeHandle TextFont::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextFont::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextFont:: TextFont() { _is_valid = false; @@ -37,11 +34,9 @@ TextFont() { _total_poly_margin = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextFont:: TextFont(const TextFont ©) : Namable(copy), @@ -52,41 +47,33 @@ TextFont(const TextFont ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextFont:: ~TextFont() { } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextFont:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "TextFont " << get_name() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::get_invalid_glyph -// Access: Public -// Description: Returns a special glyph that can be used as a -// placeholder for any character not in the font. Note -// that it is not guaranteed that a font will return -// this particular glyph for a missing character (it may -// return a glyph of its own devising instead). -// -// Also note that even if a particular accented letter -// is missing from the font, Panda may still be able to -// render a suitable replacement by composing different -// glyphs together to simulate accent marks; this -// happens automatically behind the scenes. -//////////////////////////////////////////////////////////////////// +/** + * Returns a special glyph that can be used as a placeholder for any character + * not in the font. Note that it is not guaranteed that a font will return + * this particular glyph for a missing character (it may return a glyph of its + * own devising instead). + * + * Also note that even if a particular accented letter is missing from the + * font, Panda may still be able to render a suitable replacement by composing + * different glyphs together to simulate accent marks; this happens + * automatically behind the scenes. + */ TextGlyph *TextFont:: get_invalid_glyph() { if (_invalid_glyph == (TextGlyph *)NULL) { @@ -95,13 +82,11 @@ get_invalid_glyph() { return _invalid_glyph; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::string_render_mode -// Access: Public -// Description: Returns the RenderMode value associated with the given -// string representation, or RM_invalid if the string -// does not match any known RenderMode value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RenderMode value associated with the given string + * representation, or RM_invalid if the string does not match any known + * RenderMode value. + */ TextFont::RenderMode TextFont:: string_render_mode(const string &string) { if (cmp_nocase_uh(string, "texture") == 0) { @@ -121,16 +106,13 @@ string_render_mode(const string &string) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::make_invalid_glyph -// Access: Private -// Description: Constructs the special glyph used to represent a -// character not in the font. -//////////////////////////////////////////////////////////////////// +/** + * Constructs the special glyph used to represent a character not in the font. + */ void TextFont:: make_invalid_glyph() { CPT(GeomVertexFormat) vformat = GeomVertexFormat::get_v3(); - PT(GeomVertexData) vdata = + PT(GeomVertexData) vdata = new GeomVertexData("invalid_glyph", vformat, GeomEnums::UH_static); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); @@ -151,10 +133,9 @@ make_invalid_glyph() { _line_height * 0.7f); } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::RenderMode output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, TextFont::RenderMode rm) { switch (rm) { @@ -178,10 +159,9 @@ operator << (ostream &out, TextFont::RenderMode rm) { return out << "(**invalid TextFont::RenderMode(" << (int)rm << ")**)"; } -//////////////////////////////////////////////////////////////////// -// Function: TextFont::RenderMode input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, TextFont::RenderMode &rm) { string word; diff --git a/panda/src/text/textFont.h b/panda/src/text/textFont.h index 79453a97f6..1249e7b817 100644 --- a/panda/src/text/textFont.h +++ b/panda/src/text/textFont.h @@ -1,16 +1,15 @@ -// Filename: textFont.h -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textFont.h + * @author drose + * @date 2002-02-08 + */ #ifndef TEXTFONT_H #define TEXTFONT_H @@ -23,16 +22,13 @@ #include "pmap.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : TextFont -// Description : An encapsulation of a font; i.e. a set of glyphs that -// may be assembled together by a TextNode to represent -// a string of text. -// -// This is just an abstract interface; see -// StaticTextFont or DynamicTextFont for an actual -// implementation. -//////////////////////////////////////////////////////////////////// +/** + * An encapsulation of a font; i.e. a set of glyphs that may be assembled + * together by a TextNode to represent a string of text. + * + * This is just an abstract interface; see StaticTextFont or DynamicTextFont + * for an actual implementation. + */ class EXPCL_PANDA_TEXT TextFont : public TypedReferenceCount, public Namable { public: TextFont(); diff --git a/panda/src/text/textGlyph.I b/panda/src/text/textGlyph.I index b728f1e456..77b3b943b0 100644 --- a/panda/src/text/textGlyph.I +++ b/panda/src/text/textGlyph.I @@ -1,23 +1,19 @@ -// Filename: textGlyph.I -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGlyph.I + * @author drose + * @date 2002-02-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::Default constructor -// Access: Public -// Description: This constructor makes an empty glyph. -//////////////////////////////////////////////////////////////////// +/** + * This constructor makes an empty glyph. + */ INLINE TextGlyph:: TextGlyph(int character, PN_stdfloat advance) : _character(character), @@ -27,16 +23,14 @@ TextGlyph(int character, PN_stdfloat advance) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextGlyph:: -TextGlyph(int character, const Geom *geom, +TextGlyph(int character, const Geom *geom, const RenderState *state, PN_stdfloat advance) : _character(character), - _geom(geom), + _geom(geom), _state(state), _advance(advance), _has_quad(false) @@ -49,11 +43,9 @@ TextGlyph(int character, const Geom *geom, } } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextGlyph:: TextGlyph(const TextGlyph ©) : _character(copy._character), @@ -66,11 +58,9 @@ TextGlyph(const TextGlyph ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextGlyph:: operator = (const TextGlyph ©) { _character = copy._character; @@ -82,43 +72,34 @@ operator = (const TextGlyph ©) { _quad_texcoords = copy._quad_texcoords; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::get_character -// Access: Public -// Description: Returns the Unicode value that corresponds to the -// character this glyph represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Unicode value that corresponds to the character this glyph + * represents. + */ INLINE int TextGlyph:: get_character() const { return _character; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::has_quad -// Access: Public -// Description: Returns true if this glyph contains the definition -// for a simple quad, rather than a more complex piece -// of geometry. -// -// You may still call get_geom() even if this returns -// true, which will synthesize a Geom for this quad. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this glyph contains the definition for a simple quad, + * rather than a more complex piece of geometry. + * + * You may still call get_geom() even if this returns true, which will + * synthesize a Geom for this quad. + */ INLINE bool TextGlyph:: has_quad() const { return _has_quad; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::get_quad -// Access: Public -// Description: Assuming that this glyph is representable as a -// textured quad, returns its dimensions and UV range. -// Returns false if it is not representable as a quad, -// or if it is whitespace. -// -// The order of the components is left, bottom, -// right, top. -//////////////////////////////////////////////////////////////////// +/** + * Assuming that this glyph is representable as a textured quad, returns its + * dimensions and UV range. Returns false if it is not representable as a + * quad, or if it is whitespace. + * + * The order of the components is left, bottom, right, top. + */ INLINE bool TextGlyph:: get_quad(LVecBase4 &dimensions, LVecBase4 &texcoords) const { if (!_has_quad) { @@ -130,25 +111,19 @@ get_quad(LVecBase4 &dimensions, LVecBase4 &texcoords) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::get_state -// Access: Public -// Description: Returns the state in which the glyph should be -// rendered. -//////////////////////////////////////////////////////////////////// +/** + * Returns the state in which the glyph should be rendered. + */ INLINE const RenderState *TextGlyph:: get_state() const { return _state; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::get_advance -// Access: Public -// Description: Returns the distance by which the character pointer -// should be advanced after placing this character; -// i.e. the approximate width the character takes up on -// the line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the distance by which the character pointer should be advanced + * after placing this character; i.e. the approximate width the character + * takes up on the line. + */ INLINE PN_stdfloat TextGlyph:: get_advance() const { return _advance; diff --git a/panda/src/text/textGlyph.cxx b/panda/src/text/textGlyph.cxx index 2ae14329c8..0d3de18db6 100644 --- a/panda/src/text/textGlyph.cxx +++ b/panda/src/text/textGlyph.cxx @@ -1,16 +1,15 @@ -// Filename: textGlyph.cxx -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGlyph.cxx + * @author drose + * @date 2002-02-08 + */ #include "textGlyph.h" #include "geomTextGlyph.h" @@ -20,38 +19,31 @@ TypeHandle TextGlyph::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextGlyph:: ~TextGlyph() { } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::is_whitespace -// Access: Published, Virtual -// Description: Returns true if this glyph represents invisible -// whitespace, or false if it corresponds to some -// visible character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this glyph represents invisible whitespace, or false if it + * corresponds to some visible character. + */ bool TextGlyph:: is_whitespace() const { - // In a static font, there is no explicit glyph for whitespace, so - // all glyphs are non-whitespace. + // In a static font, there is no explicit glyph for whitespace, so all + // glyphs are non-whitespace. return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::get_geom -// Access: Published -// Description: Returns a Geom that renders the particular glyph. -// It will be generated if necessary. -// -// This method will always return a copy of the Geom, -// so the caller is free to modify it. -//////////////////////////////////////////////////////////////////// +/** + * Returns a Geom that renders the particular glyph. It will be generated if + * necessary. + * + * This method will always return a copy of the Geom, so the caller is free to + * modify it. + */ PT(Geom) TextGlyph:: get_geom(Geom::UsageHint usage_hint) const { if (_geom.is_null()) { @@ -67,11 +59,11 @@ get_geom(Geom::UsageHint usage_hint) const { } } - // We always return a copy of the geom. That will allow the caller - // to modify its vertices without fear of stomping on other copies. - // It is also important that we store a reference to this glyph on - // the Geom, since the DynamicTextFont relies on counting references - // to determine whether a glyph is no longer used. + // We always return a copy of the geom. That will allow the caller to + // modify its vertices without fear of stomping on other copies. It is also + // important that we store a reference to this glyph on the Geom, since the + // DynamicTextFont relies on counting references to determine whether a + // glyph is no longer used. PT(Geom) new_geom = new GeomTextGlyph(*_geom, this); new_geom->set_usage_hint(usage_hint); const GeomVertexData *vdata = new_geom->get_vertex_data(); @@ -82,15 +74,12 @@ get_geom(Geom::UsageHint usage_hint) const { return new_geom; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::calc_tight_bounds -// Access: Public -// Description: Expands min_point and max_point to include all of the -// vertices in the glyph, if any. found_any is set -// true if any points are found. It is the caller's -// responsibility to initialize min_point, max_point, -// and found_any before calling this function. -//////////////////////////////////////////////////////////////////// +/** + * Expands min_point and max_point to include all of the vertices in the + * glyph, if any. found_any is set true if any points are found. It is the + * caller's responsibility to initialize min_point, max_point, and found_any + * before calling this function. + */ void TextGlyph:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, Thread *current_thread) const { @@ -104,14 +93,10 @@ calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, } } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::set_quad -// Access: Public -// Description: Sets the glyph using the given quad parameters. -// Any Geom assigned will be cleared. -// The order of the components is left, bottom, -// right, top. -//////////////////////////////////////////////////////////////////// +/** + * Sets the glyph using the given quad parameters. Any Geom assigned will be + * cleared. The order of the components is left, bottom, right, top. + */ void TextGlyph:: set_quad(const LVecBase4 &dimensions, const LVecBase4 &texcoords, const RenderState *state) { @@ -123,14 +108,12 @@ set_quad(const LVecBase4 &dimensions, const LVecBase4 &texcoords, _state = state; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::set_geom -// Access: Public -// Description: Sets the geom from a pre-built Geom object. -// Any quad parameters assigned will be cleared. -//////////////////////////////////////////////////////////////////// +/** + * Sets the geom from a pre-built Geom object. Any quad parameters assigned + * will be cleared. + */ void TextGlyph:: -set_geom(GeomVertexData *vdata, GeomPrimitive *prim, +set_geom(GeomVertexData *vdata, GeomPrimitive *prim, const RenderState *state) { PT(Geom) geom = new GeomTextGlyph(this, vdata); geom->add_primitive(prim); @@ -140,21 +123,17 @@ set_geom(GeomVertexData *vdata, GeomPrimitive *prim, _state = state; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::check_quad_geom -// Access: Private -// Description: Checks if the geom that was passed in is actually -// a quad, and if so, sets the appropriate quad -// parameters. -// -// This is useful when loading static text fonts, so -// that they can still benefit from the fast text -// assembly that is done for quads. -//////////////////////////////////////////////////////////////////// +/** + * Checks if the geom that was passed in is actually a quad, and if so, sets + * the appropriate quad parameters. + * + * This is useful when loading static text fonts, so that they can still + * benefit from the fast text assembly that is done for quads. + */ void TextGlyph:: check_quad_geom() { - // Currently it looks for rather specific signs that this glyph - // has been generated using egg-mkfont. For now, this is fine. + // Currently it looks for rather specific signs that this glyph has been + // generated using egg-mkfont. For now, this is fine. CPT(GeomVertexData) vdata = _geom->get_vertex_data(); if (vdata->get_num_rows() != 4) { return; @@ -257,24 +236,21 @@ check_quad_geom() { _has_quad = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextGlyph::make_quad_geom -// Access: Private -// Description: Generates a Geom representing this text glyph, if -// at all possible. -//////////////////////////////////////////////////////////////////// +/** + * Generates a Geom representing this text glyph, if at all possible. + */ void TextGlyph:: make_quad_geom() { - // The default implementation is to generate a Geom based on the - // get_quad() implementation, if any. + // The default implementation is to generate a Geom based on the get_quad() + // implementation, if any. LVecBase4 dimensions, uvs; if (!get_quad(dimensions, uvs)) { return; } - // Create a corresponding triangle pair. We use a pair of indexed - // triangles rather than a single triangle strip, to avoid the bad - // vertex duplication behavior with lots of two-triangle strips. + // Create a corresponding triangle pair. We use a pair of indexed triangles + // rather than a single triangle strip, to avoid the bad vertex duplication + // behavior with lots of two-triangle strips. PT(GeomVertexData) vdata = new GeomVertexData (string(), GeomVertexFormat::get_v3t2(), Geom::UH_static); vdata->unclean_set_num_rows(4); @@ -308,9 +284,9 @@ make_quad_geom() { index.set_data1i(3); } - // We create a regular Geom here, not a GeomTextGlyph, since doing so - // would create a circular reference. When the get_geom method makes - // a copy, it will add in a pointer to this text glyph. + // We create a regular Geom here, not a GeomTextGlyph, since doing so would + // create a circular reference. When the get_geom method makes a copy, it + // will add in a pointer to this text glyph. PT(Geom) geom = new Geom(vdata); geom->add_primitive(tris); _geom = geom; diff --git a/panda/src/text/textGlyph.h b/panda/src/text/textGlyph.h index 3097a3a3d1..4467c13d3c 100644 --- a/panda/src/text/textGlyph.h +++ b/panda/src/text/textGlyph.h @@ -1,16 +1,15 @@ -// Filename: textGlyph.h -// Created by: drose (08Feb02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGlyph.h + * @author drose + * @date 2002-02-08 + */ #ifndef TEXTGLYPH_H #define TEXTGLYPH_H @@ -22,16 +21,14 @@ #include "pointerTo.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Class : TextGlyph -// Description : A representation of a single glyph (character) from a -// font. This is a piece of renderable geometry of some -// kind. -//////////////////////////////////////////////////////////////////// +/** + * A representation of a single glyph (character) from a font. This is a + * piece of renderable geometry of some kind. + */ class EXPCL_PANDA_TEXT TextGlyph : public TypedReferenceCount { public: INLINE TextGlyph(int character, PN_stdfloat advance=0); - INLINE TextGlyph(int character, const Geom *geom, + INLINE TextGlyph(int character, const Geom *geom, const RenderState *state, PN_stdfloat advance); INLINE TextGlyph(const TextGlyph ©); INLINE void operator = (const TextGlyph ©); diff --git a/panda/src/text/textGraphic.I b/panda/src/text/textGraphic.I index 06bbdbff6e..c4cfe18f0c 100644 --- a/panda/src/text/textGraphic.I +++ b/panda/src/text/textGraphic.I @@ -1,34 +1,28 @@ -// Filename: textGraphic.I -// Created by: drose (18Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGraphic.I + * @author drose + * @date 2006-08-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextGraphic:: TextGraphic() { _frame = LVecBase4::zero(); _instance_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextGraphic:: TextGraphic(const NodePath &model, const LVecBase4 &frame) : _model(model), @@ -37,11 +31,9 @@ TextGraphic(const NodePath &model, const LVecBase4 &frame) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextGraphic:: TextGraphic(const NodePath &model, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) : _model(model), @@ -50,91 +42,72 @@ TextGraphic(const NodePath &model, PN_stdfloat left, PN_stdfloat right, PN_stdfl { } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::get_model -// Access: Published -// Description: Returns the NodePath associated with the graphic, -// that renders the desired image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath associated with the graphic, that renders the desired + * image. + */ INLINE NodePath TextGraphic:: get_model() const { return _model; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::set_model -// Access: Published -// Description: Changes the NodePath associated with the graphic. -// This NodePath should contain geometry that will -// render the desired graphic image. -//////////////////////////////////////////////////////////////////// +/** + * Changes the NodePath associated with the graphic. This NodePath should + * contain geometry that will render the desired graphic image. + */ INLINE void TextGraphic:: set_model(const NodePath &model) { _model = model; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::get_frame -// Access: Published -// Description: Returns the frame specified for the graphic. This is -// the amount of space that will be reserved for the -// graphic when it is embedded in a text paragraph, in -// the form (left, right, bottom, top). -// -// The actual graphic, as rendered by the NodePath -// specified via set_model(), should more or less fit -// within this rectangle. It is not required to fit -// completely within it, but if it does not, it may -// visually overlap with nearby text. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame specified for the graphic. This is the amount of space + * that will be reserved for the graphic when it is embedded in a text + * paragraph, in the form (left, right, bottom, top). + * + * The actual graphic, as rendered by the NodePath specified via set_model(), + * should more or less fit within this rectangle. It is not required to fit + * completely within it, but if it does not, it may visually overlap with + * nearby text. + */ INLINE LVecBase4 TextGraphic:: get_frame() const { return _frame; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::set_frame -// Access: Published -// Description: Specifies the (left, right, bottom, top) bounding -// frame for the graphic. See get_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the (left, right, bottom, top) bounding frame for the graphic. + * See get_frame(). + */ INLINE void TextGraphic:: set_frame(const LVecBase4 &frame) { _frame = frame; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::set_frame -// Access: Published -// Description: Specifies the (left, right, bottom, top) bounding -// frame for the graphic. See get_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the (left, right, bottom, top) bounding frame for the graphic. + * See get_frame(). + */ INLINE void TextGraphic:: set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _frame.set(left, right, bottom, top); } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::get_instance_flag -// Access: Published -// Description: Returns the instance_flag. See set_instance_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the instance_flag. See set_instance_flag(). + */ INLINE bool TextGraphic:: get_instance_flag() const { return _instance_flag; } -//////////////////////////////////////////////////////////////////// -// Function: TextGraphic::set_instance_flag -// Access: Published -// Description: Sets the instance_flag. When this is true, the -// graphic is directly instanced to the scene graph -// whenever it appears; when it is false, the graphic is -// copied. The default is false, which is best for most -// applications. You might need to set it true for -// special kinds of "graphics" like interactive -// elements, for instance a PGEntry. -//////////////////////////////////////////////////////////////////// +/** + * Sets the instance_flag. When this is true, the graphic is directly + * instanced to the scene graph whenever it appears; when it is false, the + * graphic is copied. The default is false, which is best for most + * applications. You might need to set it true for special kinds of + * "graphics" like interactive elements, for instance a PGEntry. + */ INLINE void TextGraphic:: set_instance_flag(bool instance_flag) { _instance_flag = instance_flag; diff --git a/panda/src/text/textGraphic.cxx b/panda/src/text/textGraphic.cxx index 7b4523ab89..67c42bdc66 100644 --- a/panda/src/text/textGraphic.cxx +++ b/panda/src/text/textGraphic.cxx @@ -1,15 +1,14 @@ -// Filename: textGraphic.cxx -// Created by: drose (18Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGraphic.cxx + * @author drose + * @date 2006-08-18 + */ #include "textGraphic.h" diff --git a/panda/src/text/textGraphic.h b/panda/src/text/textGraphic.h index 3b08aec96c..a3d268cd8c 100644 --- a/panda/src/text/textGraphic.h +++ b/panda/src/text/textGraphic.h @@ -1,16 +1,15 @@ -// Filename: textGraphic.h -// Created by: drose (18Aug06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textGraphic.h + * @author drose + * @date 2006-08-18 + */ #ifndef TEXTGRAPHIC_H #define TEXTGRAPHIC_H @@ -20,26 +19,21 @@ #include "config_text.h" #include "nodePath.h" -//////////////////////////////////////////////////////////////////// -// Class : TextGraphic -// Description : This defines a special model that has been -// constructed for the purposes of embedding an -// arbitrary graphic image within a text paragraph. -// -// It can be any arbitrary model, though it should be -// built along the same scale as the text, and it should -// probably be at least mostly two-dimensional. -// Typically, this means it should be constructed in the -// X-Z plane, and it should have a maximum vertical (Z) -// height of 1.0. -// -// The frame specifies an arbitrary bounding volume in -// the form (left, right, bottom, top). This indicates -// the amount of space that will be reserved within the -// paragraph. The actual model is not actually required -// to fit within this rectangle, but if it does not, it -// may visually overlap with nearby text. -//////////////////////////////////////////////////////////////////// +/** + * This defines a special model that has been constructed for the purposes of + * embedding an arbitrary graphic image within a text paragraph. + * + * It can be any arbitrary model, though it should be built along the same + * scale as the text, and it should probably be at least mostly two- + * dimensional. Typically, this means it should be constructed in the X-Z + * plane, and it should have a maximum vertical (Z) height of 1.0. + * + * The frame specifies an arbitrary bounding volume in the form (left, right, + * bottom, top). This indicates the amount of space that will be reserved + * within the paragraph. The actual model is not actually required to fit + * within this rectangle, but if it does not, it may visually overlap with + * nearby text. + */ class EXPCL_PANDA_TEXT TextGraphic { PUBLISHED: INLINE TextGraphic(); diff --git a/panda/src/text/textNode.I b/panda/src/text/textNode.I index 0ed14b862a..41758ba28a 100644 --- a/panda/src/text/textNode.I +++ b/panda/src/text/textNode.I @@ -1,27 +1,21 @@ -// Filename: textNode.I -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textNode.I + * @author drose + * @date 2002-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_line_height -// Access: Published -// Description: Returns the number of units high each line of text -// is. This is based on the font. Note that it is -// possible for the text to include nested font change -// commands, in which case the value of this method is -// questionable. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of units high each line of text is. This is based on + * the font. Note that it is possible for the text to include nested font + * change commands, in which case the value of this method is questionable. + */ INLINE PN_stdfloat TextNode:: get_line_height() const { TextFont *font = get_font(); @@ -32,82 +26,66 @@ get_line_height() const { return font->get_line_height(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_max_rows -// Access: Published -// Description: Sets the maximum number of rows that may be formatted -// by the TextNode. If more text than this is -// attempted, it will be truncated and has_overflow() -// will return true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum number of rows that may be formatted by the TextNode. If + * more text than this is attempted, it will be truncated and has_overflow() + * will return true. + */ INLINE void TextNode:: set_max_rows(int max_rows) { _max_rows = max_rows; invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_max_rows -// Access: Published -// Description: Resets the TextNode's default behavior of not -// limiting the number of rows of text. -//////////////////////////////////////////////////////////////////// +/** + * Resets the TextNode's default behavior of not limiting the number of rows + * of text. + */ INLINE void TextNode:: clear_max_rows() { _max_rows = 0; invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_max_rows -// Access: Published -// Description: Returns true if a limit on the height of the TextNode -// has been set via set_max_rows(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a limit on the height of the TextNode has been set via + * set_max_rows(), false otherwise. + */ INLINE bool TextNode:: has_max_rows() const { return _max_rows > 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_max_rows -// Access: Published -// Description: Returns the limit on the height of the TextNode -// specified by set_max_rows(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the limit on the height of the TextNode specified by + * set_max_rows(). + */ INLINE int TextNode:: get_max_rows() const { return _max_rows; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_overflow -// Access: Published -// Description: Returns true if the last text set on the text node -// exceeded the max_rows constraint, or false if it all -// fit. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last text set on the text node exceeded the max_rows + * constraint, or false if it all fit. + */ INLINE bool TextNode:: has_overflow() const { check_measure(); return (_flags & F_has_overflow) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_frame_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_frame_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_frame_color(const LColor &frame_color) { if (_frame_color != frame_color) { @@ -116,21 +94,17 @@ set_frame_color(const LColor &frame_color) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_frame_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LColor TextNode:: get_frame_color() const { return _frame_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_border -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) { if (!has_card_border() || _card_border_size != size || _card_border_uv_portion != uv_portion) { @@ -141,11 +115,9 @@ set_card_border(PN_stdfloat size, PN_stdfloat uv_portion) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_card_border -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_card_border() { if (has_card_border()) { @@ -154,51 +126,41 @@ clear_card_border() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_border_size -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat TextNode:: get_card_border_size() const { return _card_border_size; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_border_uv_portion -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat TextNode:: get_card_border_uv_portion() const { return _card_border_uv_portion; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_card_border -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextNode:: has_card_border() const { return (_flags & F_has_card_border) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_card_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_card_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_card_color(const LColor &card_color) { if (_card_color != card_color) { @@ -207,21 +169,17 @@ set_card_color(const LColor &card_color) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LColor TextNode:: get_card_color() const { return _card_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_card_texture(Texture *card_texture) { if (card_texture == (Texture *)NULL) { @@ -235,11 +193,9 @@ set_card_texture(Texture *card_texture) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_card_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_card_texture() { if (has_card_texture()) { @@ -249,35 +205,28 @@ clear_card_texture() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_card_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextNode:: has_card_texture() const { return (_flags & F_has_card_texture) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_texture -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE Texture *TextNode:: get_card_texture() const { return _card_texture; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_as_margin -// Access: Published -// Description: Specifies that a border will be drawn around the text -// when it is next created. The parameters are the -// amount of additional padding to insert between the -// frame and the text in each dimension, and all should -// generally be positive. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a border will be drawn around the text when it is next + * created. The parameters are the amount of additional padding to insert + * between the frame and the text in each dimension, and all should generally + * be positive. + */ INLINE void TextNode:: set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= (F_has_frame | F_frame_as_margin); @@ -286,16 +235,12 @@ set_frame_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_ invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_actual -// Access: Published -// Description: Similar to set_frame_as_margin, except the frame is -// specified in actual coordinate units (relative to -// the text's origin), irrespective of the size of the -// text. The left and bottom coordinates should -// generally be negative, while the right and top -// coordinates should generally be positive. -//////////////////////////////////////////////////////////////////// +/** + * Similar to set_frame_as_margin, except the frame is specified in actual + * coordinate units (relative to the text's origin), irrespective of the size + * of the text. The left and bottom coordinates should generally be negative, + * while the right and top coordinates should generally be positive. + */ INLINE void TextNode:: set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= F_has_frame; @@ -305,74 +250,57 @@ set_frame_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_std invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_frame -// Access: Published -// Description: Specifies that a border will not be drawn around the -// text. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a border will not be drawn around the text. + */ INLINE void TextNode:: clear_frame() { _flags &= ~F_has_frame; invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_frame -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextNode:: has_frame() const { return (_flags & F_has_frame) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::is_frame_as_margin -// Access: Published -// Description: If this is true, the frame was set via a call to -// set_frame_as_margin(), and the dimension of the frame -// as returned by get_frame_as_set() represent a margin -// all around the text. If false, then the frame was -// set via a call to set_frame_actual(), and the -// dimensions of the frame as returned by -// get_frame_as_set() are relative to the text's origin. -//////////////////////////////////////////////////////////////////// +/** + * If this is true, the frame was set via a call to set_frame_as_margin(), and + * the dimension of the frame as returned by get_frame_as_set() represent a + * margin all around the text. If false, then the frame was set via a call to + * set_frame_actual(), and the dimensions of the frame as returned by + * get_frame_as_set() are relative to the text's origin. + */ INLINE bool TextNode:: is_frame_as_margin() const { nassertr(has_frame(), false); return (_flags & F_frame_as_margin) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_frame_as_set -// Access: Published -// Description: Returns the dimensions of the frame as set by -// set_frame_as_margin() or set_frame_actual(). Use -// is_frame_actual() to determine how to interpret the -// values returned by this function. It is an error to -// call this if has_frame() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dimensions of the frame as set by set_frame_as_margin() or + * set_frame_actual(). Use is_frame_actual() to determine how to interpret + * the values returned by this function. It is an error to call this if + * has_frame() is false. + */ INLINE LVecBase4 TextNode:: get_frame_as_set() const { nassertr(has_frame(), LVecBase4(0.0, 0.0, 0.0, 0.0)); return LVecBase4(_frame_ul[0], _frame_lr[0], _frame_lr[1], _frame_ul[1]); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_frame_actual -// Access: Published -// Description: Returns the actual dimensions of the frame around the -// text. If the frame was set via set_frame_as_margin(), -// the result returned by this function reflects the -// size of the current text; if the frame was set via -// set_frame_actual(), this returns the values -// actually set. -// -// If the text has no frame at all, this returns the -// dimensions of the text itself, as if the frame were -// set with a margin of 0, 0, 0, 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual dimensions of the frame around the text. If the frame + * was set via set_frame_as_margin(), the result returned by this function + * reflects the size of the current text; if the frame was set via + * set_frame_actual(), this returns the values actually set. + * + * If the text has no frame at all, this returns the dimensions of the text + * itself, as if the frame were set with a margin of 0, 0, 0, 0. + */ INLINE LVecBase4 TextNode:: get_frame_actual() const { if (!has_frame()) { @@ -390,37 +318,28 @@ get_frame_actual() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_line_width -// Access: Published -// Description: Specifies the thickness of the lines that will be -// used to draw the frame. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the thickness of the lines that will be used to draw the frame. + */ INLINE void TextNode:: set_frame_line_width(PN_stdfloat frame_width) { _frame_width = frame_width; invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_frame_line_width -// Access: Published -// Description: Returns the thickness of the lines that will be -// used to draw the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the thickness of the lines that will be used to draw the frame. + */ INLINE PN_stdfloat TextNode:: get_frame_line_width() const { return _frame_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_frame_corners -// Access: Published -// Description: Enables or disables the drawing of corners for the -// frame. These are extra points drawn at each of the -// four corners, to soften the ugly edges generated when -// the line width is greater than one. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables the drawing of corners for the frame. These are extra + * points drawn at each of the four corners, to soften the ugly edges + * generated when the line width is greater than one. + */ INLINE void TextNode:: set_frame_corners(bool corners) { if (corners) { @@ -431,26 +350,20 @@ set_frame_corners(bool corners) { invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_frame_corners -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextNode:: get_frame_corners() const { return (_flags & F_frame_corners) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_as_margin -// Access: Published -// Description: Specifies that a (possibly opaque or semitransparent) -// card will be held behind the text when it is next -// created. Like set_frame_as_margin, the parameters are -// the amount of additional padding to insert around the -// text in each dimension, and all should generally be -// positive. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a (possibly opaque or semitransparent) card will be held + * behind the text when it is next created. Like set_frame_as_margin, the + * parameters are the amount of additional padding to insert around the text + * in each dimension, and all should generally be positive. + */ INLINE void TextNode:: set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= (F_has_card | F_card_as_margin); @@ -459,16 +372,12 @@ set_card_as_margin(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_s invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_actual -// Access: Published -// Description: Similar to set_card_as_margin, except the card is -// specified in actual coordinate units (relative to -// the text's origin), irrespective of the size of the -// text. The left and bottom coordinates should -// generally be negative, while the right and top -// coordinates should generally be positive. -//////////////////////////////////////////////////////////////////// +/** + * Similar to set_card_as_margin, except the card is specified in actual + * coordinate units (relative to the text's origin), irrespective of the size + * of the text. The left and bottom coordinates should generally be negative, + * while the right and top coordinates should generally be positive. + */ INLINE void TextNode:: set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _flags |= F_has_card; @@ -478,14 +387,11 @@ set_card_actual(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdf invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_card_decal -// Access: Published -// Description: Sets the card_decal flag. When this is true, the -// text is decalled onto the card, which is necessary if -// the TextNode is to be rendered in the 3-d world -// without putting it in a bin. -//////////////////////////////////////////////////////////////////// +/** + * Sets the card_decal flag. When this is true, the text is decalled onto the + * card, which is necessary if the TextNode is to be rendered in the 3-d world + * without putting it in a bin. + */ INLINE void TextNode:: set_card_decal(bool card_decal) { if (card_decal) { @@ -496,84 +402,65 @@ set_card_decal(bool card_decal) { invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_card -// Access: Published -// Description: Specifies that a card will not be drawn behind the -// text. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a card will not be drawn behind the text. + */ INLINE void TextNode:: clear_card() { _flags &= ~F_has_card; invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_card -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextNode:: has_card() const { return (_flags & F_has_card) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_decal -// Access: Published -// Description: Returns the card_decal flag. See set_card_decal(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the card_decal flag. See set_card_decal(). + */ INLINE bool TextNode:: get_card_decal() const { return (_flags & F_card_decal) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::is_card_as_margin -// Access: Published -// Description: If this is true, the card was set via a call to -// set_card_as_margin(), and the dimension of the card -// as returned by get_card_as_set() represent a margin -// all around the text. If false, then the card was -// set via a call to set_card_actual(), and the -// dimensions of the card as returned by -// get_card_as_set() are relative to the text's origin. -//////////////////////////////////////////////////////////////////// +/** + * If this is true, the card was set via a call to set_card_as_margin(), and + * the dimension of the card as returned by get_card_as_set() represent a + * margin all around the text. If false, then the card was set via a call to + * set_card_actual(), and the dimensions of the card as returned by + * get_card_as_set() are relative to the text's origin. + */ INLINE bool TextNode:: is_card_as_margin() const { nassertr(has_card(), false); return (_flags & F_card_as_margin) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_as_set -// Access: Published -// Description: Returns the dimensions of the card as set by -// set_card_as_margin() or set_card_actual(). Use -// is_card_actual() to determine how to interpret the -// values returned by this function. It is an error to -// call this if has_card() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dimensions of the card as set by set_card_as_margin() or + * set_card_actual(). Use is_card_actual() to determine how to interpret the + * values returned by this function. It is an error to call this if + * has_card() is false. + */ INLINE LVecBase4 TextNode:: get_card_as_set() const { nassertr(has_card(), LVecBase4(0.0, 0.0, 0.0, 0.0)); return LVecBase4(_card_ul[0], _card_lr[0], _card_lr[1], _card_ul[1]); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_actual -// Access: Published -// Description: Returns the actual dimensions of the card around the -// text. If the card was set via set_card_as_margin(), -// the result returned by this function reflects the -// size of the current text; if the card was set via -// set_card_actual(), this returns the values -// actually set. -// -// If the text has no card at all, this returns the -// dimensions of the text itself, as if the card were -// set with a margin of 0, 0, 0, 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual dimensions of the card around the text. If the card was + * set via set_card_as_margin(), the result returned by this function reflects + * the size of the current text; if the card was set via set_card_actual(), + * this returns the values actually set. + * + * If the text has no card at all, this returns the dimensions of the text + * itself, as if the card were set with a margin of 0, 0, 0, 0. + */ INLINE LVecBase4 TextNode:: get_card_actual() const { if (!has_card()) { @@ -591,15 +478,12 @@ get_card_actual() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_card_transformed -// Access: Published -// Description: Returns the actual card dimensions, transformed by -// the matrix set by set_transform(). This returns the -// card dimensions in actual coordinates as seen by the -// rest of the world. Also see get_upper_left_3d() and -// get_lower_right_3d(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual card dimensions, transformed by the matrix set by + * set_transform(). This returns the card dimensions in actual coordinates as + * seen by the rest of the world. Also see get_upper_left_3d() and + * get_lower_right_3d(). + */ INLINE LVecBase4 TextNode:: get_card_transformed() const { LVecBase4 card = get_card_actual(); @@ -609,551 +493,437 @@ get_card_transformed() const { return LVecBase4(ul[0], lr[0], lr[2], ul[2]); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_transform -// Access: Published -// Description: Sets an additional transform that is applied to the -// entire text paragraph. -//////////////////////////////////////////////////////////////////// +/** + * Sets an additional transform that is applied to the entire text paragraph. + */ INLINE void TextNode:: set_transform(const LMatrix4 &transform) { _transform = transform; invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_transform -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LMatrix4 TextNode:: get_transform() const { return _transform; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_coordinate_system -// Access: Published -// Description: Specifies the coordinate system in which the text -// will be generated. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the coordinate system in which the text will be generated. + */ INLINE void TextNode:: set_coordinate_system(CoordinateSystem coordinate_system) { _coordinate_system = coordinate_system; invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_coordinate_system -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CoordinateSystem TextNode:: get_coordinate_system() const { return _coordinate_system; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_usage_hint -// Access: Published -// Description: Specifies the UsageHint that will be applied to -// generated geometry. The default is UH_static, which -// is probably the right setting, but if you know the -// TextNode's geometry will have a short lifespan, it -// may be better to set it to UH_stream. See -// geomEnums.h. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the UsageHint that will be applied to generated geometry. The + * default is UH_static, which is probably the right setting, but if you know + * the TextNode's geometry will have a short lifespan, it may be better to set + * it to UH_stream. See geomEnums.h. + */ INLINE void TextNode:: set_usage_hint(Geom::UsageHint usage_hint) { _usage_hint = usage_hint; invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_usage_hint -// Access: Published -// Description: Returns the UsageHint that will be applied to -// generated geometry. See set_usage_hint(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the UsageHint that will be applied to generated geometry. See + * set_usage_hint(). + */ INLINE Geom::UsageHint TextNode:: get_usage_hint() const { return _usage_hint; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_flatten_flags -// Access: Published -// Description: Sets the flatten flags. This should be a union of -// the TextNode::FlattenFlags options. This controls -// the degree of flattening performed on the TextNode's -// internal geometry (i.e. the scene graph returned by -// generate()) each time the text is changed. In -// general, more flattening means a more optimal result, -// but it will take more time to generate. -// -// The choice may be any of these three: -// -// FF_none - No flatten operation is called. The -// letters are left as independent Geoms. -// -// FF_light - A flatten_light() operation is called. -// The attributes are applied to the vertices, but no -// nodes are removed. -// -// FF_medium - A flatten_medium() operation is called. -// The attributes are applied to the vertices, and a few -// trivial nodes are removed. -// -// FF_strong - A flatten_strong() operation is called. -// The attributes are applied to the vertices, and the -// resulting nodes are aggressively combined into as few -// nodes as possible. -// -// In addition to the above choices, you may optionally -// include the following flag: -// -// FF_dynamic_merge - Copy the geoms into a single -// GeomVertexData as we go, instead of relying on the -// flatten operation at the end. This pre-flattens the -// text considerably, and may obviate the need for -// flatten altogether; it also tends to improve -// performance considerably even if you do call flatten. -// However, it is not as fast as not calling flatten at -// all. -// -// The default is taken from the text-flatten and -// text-dynamic-merge config variables. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flatten flags. This should be a union of the + * TextNode::FlattenFlags options. This controls the degree of flattening + * performed on the TextNode's internal geometry (i.e. the scene graph + * returned by generate()) each time the text is changed. In general, more + * flattening means a more optimal result, but it will take more time to + * generate. + * + * The choice may be any of these three: + * + * FF_none - No flatten operation is called. The letters are left as + * independent Geoms. + * + * FF_light - A flatten_light() operation is called. The attributes are + * applied to the vertices, but no nodes are removed. + * + * FF_medium - A flatten_medium() operation is called. The attributes are + * applied to the vertices, and a few trivial nodes are removed. + * + * FF_strong - A flatten_strong() operation is called. The attributes are + * applied to the vertices, and the resulting nodes are aggressively combined + * into as few nodes as possible. + * + * In addition to the above choices, you may optionally include the following + * flag: + * + * FF_dynamic_merge - Copy the geoms into a single GeomVertexData as we go, + * instead of relying on the flatten operation at the end. This pre-flattens + * the text considerably, and may obviate the need for flatten altogether; it + * also tends to improve performance considerably even if you do call flatten. + * However, it is not as fast as not calling flatten at all. + * + * The default is taken from the text-flatten and text-dynamic-merge config + * variables. + */ INLINE void TextNode:: set_flatten_flags(int flatten_flags) { _flatten_flags = flatten_flags; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_flatten_flags -// Access: Published -// Description: Returns the flatten flags. See set_flatten_flags(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flatten flags. See set_flatten_flags(). + */ INLINE int TextNode:: get_flatten_flags() const { return _flatten_flags; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_font -// Access: Published -// Description: Sets the font that will be used when making text. If -// this is set to NULL, the default font will be used, -// which can be set via set_default_font(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the font that will be used when making text. If this is set to NULL, + * the default font will be used, which can be set via set_default_font(). + */ INLINE void TextNode:: set_font(TextFont *font) { TextProperties::set_font(font); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_font -// Access: Published -// Description: Resets the font to the default font. -//////////////////////////////////////////////////////////////////// +/** + * Resets the font to the default font. + */ INLINE void TextNode:: clear_font() { TextProperties::clear_font(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_small_caps -// Access: Published -// Description: Sets the small_caps flag. When this is set, -// lowercase letters are generated as scaled-down -// versions of their uppercase equivalents. This is -// particularly useful to set for fonts that do not have -// lowercase letters. -// -// It is also a good idea to set this for a (dynamic) -// font that has already implemented lowercase letters -// as scaled-down versions of their uppercase -// equivalents, since without this flag the texture -// memory may needlessly duplicate equivalent glyphs for -// upper and lowercase letters. Setting this flag -// causes the texture memory to share the mixed-case -// letters. -// -// The amount by which the lowercase letters are scaled -// is specified by set_small_caps_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the small_caps flag. When this is set, lowercase letters are + * generated as scaled-down versions of their uppercase equivalents. This is + * particularly useful to set for fonts that do not have lowercase letters. + * + * It is also a good idea to set this for a (dynamic) font that has already + * implemented lowercase letters as scaled-down versions of their uppercase + * equivalents, since without this flag the texture memory may needlessly + * duplicate equivalent glyphs for upper and lowercase letters. Setting this + * flag causes the texture memory to share the mixed-case letters. + * + * The amount by which the lowercase letters are scaled is specified by + * set_small_caps_scale(). + */ INLINE void TextNode:: set_small_caps(bool small_caps) { TextProperties::set_small_caps(small_caps); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_small_caps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_small_caps() { TextProperties::clear_small_caps(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_small_caps_scale -// Access: Published -// Description: Sets the scale factor applied to lowercase letters -// from their uppercase equivalents, when the small_caps -// flag is in effect. See set_small_caps(). Normally, -// this will be a number less than one. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale factor applied to lowercase letters from their uppercase + * equivalents, when the small_caps flag is in effect. See set_small_caps(). + * Normally, this will be a number less than one. + */ INLINE void TextNode:: set_small_caps_scale(PN_stdfloat small_caps_scale) { TextProperties::set_small_caps_scale(small_caps_scale); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_small_caps_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_small_caps_scale() { TextProperties::clear_small_caps_scale(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_slant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_slant(PN_stdfloat slant) { TextProperties::set_slant(slant); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_slant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_slant() { TextProperties::clear_slant(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_align(TextNode::Alignment align_type) { TextProperties::set_align(align_type); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_align() { TextProperties::clear_align(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_indent -// Access: Published -// Description: Specifies the amount of extra space that is inserted -// before the first character of each line. This can be -// thought of as a left margin. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the amount of extra space that is inserted before the first + * character of each line. This can be thought of as a left margin. + */ INLINE void TextNode:: set_indent(PN_stdfloat indent) { TextProperties::set_indent(indent); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_indent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_indent() { TextProperties::clear_indent(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_wordwrap -// Access: Published -// Description: Sets the text up to automatically wordwrap when it -// exceeds the indicated width. This can be thought of -// as a right margin or margin width. -//////////////////////////////////////////////////////////////////// +/** + * Sets the text up to automatically wordwrap when it exceeds the indicated + * width. This can be thought of as a right margin or margin width. + */ INLINE void TextNode:: set_wordwrap(PN_stdfloat wordwrap) { TextProperties::set_wordwrap(wordwrap); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_wordwrap -// Access: Published -// Description: Removes the wordwrap setting from the TextNode. Text -// will be as wide as it is. -//////////////////////////////////////////////////////////////////// +/** + * Removes the wordwrap setting from the TextNode. Text will be as wide as it + * is. + */ INLINE void TextNode:: clear_wordwrap() { TextProperties::clear_wordwrap(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_text_color(const LColor &text_color) { TextProperties::set_text_color(text_color); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_text_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_text_color -// Access: Published -// Description: Removes the text color specification; the text will -// be colored whatever it was in the source font file. -//////////////////////////////////////////////////////////////////// +/** + * Removes the text color specification; the text will be colored whatever it + * was in the source font file. + */ INLINE void TextNode:: clear_text_color() { TextProperties::clear_text_color(); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_shadow_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: set_shadow_color(const LColor &shadow_color) { TextProperties::set_shadow_color(shadow_color); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_shadow_color() { TextProperties::clear_shadow_color(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_shadow -// Access: Published -// Description: Specifies that the text should be drawn with a -// shadow, by creating a second copy of the text and -// offsetting it slightly behind the first. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the text should be drawn with a shadow, by creating a second + * copy of the text and offsetting it slightly behind the first. + */ INLINE void TextNode:: set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) { set_shadow(LVecBase2(xoffset, yoffset)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_shadow -// Access: Published -// Description: Specifies that the text should be drawn with a -// shadow, by creating a second copy of the text and -// offsetting it slightly behind the first. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the text should be drawn with a shadow, by creating a second + * copy of the text and offsetting it slightly behind the first. + */ INLINE void TextNode:: set_shadow(const LVecBase2 &shadow_offset) { TextProperties::set_shadow(shadow_offset); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_shadow -// Access: Published -// Description: Specifies that a shadow will not be drawn behind the -// text. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a shadow will not be drawn behind the text. + */ INLINE void TextNode:: clear_shadow() { TextProperties::clear_shadow(); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_bin -// Access: Published -// Description: Names the GeomBin that the TextNode geometry should -// be assigned to. If this is set, then a -// GeomBinTransition will be created to explicitly place -// each component in the named bin. -// -// The draw_order value will also be passed to each -// GeomBinTransition as appropriate; this is -// particularly useful if this names a GeomBinFixed, -// e.g. "fixed". -//////////////////////////////////////////////////////////////////// +/** + * Names the GeomBin that the TextNode geometry should be assigned to. If + * this is set, then a GeomBinTransition will be created to explicitly place + * each component in the named bin. + * + * The draw_order value will also be passed to each GeomBinTransition as + * appropriate; this is particularly useful if this names a GeomBinFixed, e.g. + * "fixed". + */ INLINE void TextNode:: set_bin(const string &bin) { TextProperties::set_bin(bin); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_bin -// Access: Published -// Description: Removes the effect of a previous call to -// set_bin(). Text will be drawn in whatever bin -// it would like to be drawn in, with no explicit -// ordering. -//////////////////////////////////////////////////////////////////// +/** + * Removes the effect of a previous call to set_bin(). Text will be drawn in + * whatever bin it would like to be drawn in, with no explicit ordering. + */ INLINE void TextNode:: clear_bin() { TextProperties::clear_bin(); invalidate_no_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_draw_order -// Access: Published -// Description: Sets the drawing order of text created by the -// TextMaker. This is actually the draw order of the -// card and frame. The shadow is drawn at -// _draw_order+1, and the text at _draw_order+2. -// -// This affects the sorting order assigned to the arcs -// as they are created, and also is passed to whatever -// bin may be assigned via set_bin(). -// -// The return value is the first unused draw_order -// number, e.g. _draw_order + 3. -//////////////////////////////////////////////////////////////////// +/** + * Sets the drawing order of text created by the TextMaker. This is actually + * the draw order of the card and frame. The shadow is drawn at + * _draw_order+1, and the text at _draw_order+2. + * + * This affects the sorting order assigned to the arcs as they are created, + * and also is passed to whatever bin may be assigned via set_bin(). + * + * The return value is the first unused draw_order number, e.g. _draw_order + + * 3. + */ INLINE int TextNode:: set_draw_order(int draw_order) { invalidate_no_measure(); return TextProperties::set_draw_order(draw_order); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_draw_order -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_draw_order() { TextProperties::clear_draw_order(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_tab_width -// Access: Published -// Description: Sets the width of each tab stop, in screen units. A -// tab character embedded in the text will advance the -// horizontal position to the next tab stop. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width of each tab stop, in screen units. A tab character embedded + * in the text will advance the horizontal position to the next tab stop. + */ INLINE void TextNode:: set_tab_width(PN_stdfloat tab_width) { TextProperties::set_tab_width(tab_width); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_tab_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_tab_width() { TextProperties::clear_tab_width(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_glyph_scale -// Access: Published -// Description: Specifies the factor by which to scale each letter of -// the text as it is placed. This can be used (possibly -// in conjunction with set_glyph_shift()) to implement -// superscripting or subscripting. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the factor by which to scale each letter of the text as it is + * placed. This can be used (possibly in conjunction with set_glyph_shift()) + * to implement superscripting or subscripting. + */ INLINE void TextNode:: set_glyph_scale(PN_stdfloat glyph_scale) { TextProperties::set_glyph_scale(glyph_scale); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_glyph_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_glyph_scale() { TextProperties::clear_glyph_scale(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_glyph_shift -// Access: Published -// Description: Specifies a vertical amount to shift each letter of -// the text as it is placed. This can be used (possibly -// in conjunction with set_glyph_scale()) to implement -// superscripting or subscripting. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a vertical amount to shift each letter of the text as it is + * placed. This can be used (possibly in conjunction with set_glyph_scale()) + * to implement superscripting or subscripting. + */ INLINE void TextNode:: set_glyph_shift(PN_stdfloat glyph_shift) { TextProperties::set_glyph_shift(glyph_shift); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_glyph_shift -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextNode:: clear_glyph_shift() { TextProperties::clear_glyph_shift(); @@ -1161,318 +931,246 @@ clear_glyph_shift() { } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_text -// Access: Published -// Description: Changes the text that is displayed under the -// TextNode. -//////////////////////////////////////////////////////////////////// +/** + * Changes the text that is displayed under the TextNode. + */ INLINE void TextNode:: set_text(const string &text) { TextEncoder::set_text(text); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_text -// Access: Published -// Description: The two-parameter version of set_text() accepts an -// explicit encoding; the text is immediately decoded -// and stored as a wide-character string. Subsequent -// calls to get_text() will return the same text -// re-encoded using whichever encoding is specified by -// set_encoding(). -//////////////////////////////////////////////////////////////////// +/** + * The two-parameter version of set_text() accepts an explicit encoding; the + * text is immediately decoded and stored as a wide-character string. + * Subsequent calls to get_text() will return the same text re-encoded using + * whichever encoding is specified by set_encoding(). + */ INLINE void TextNode:: set_text(const string &text, TextNode::Encoding encoding) { TextEncoder::set_text(text, encoding); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::clear_text -// Access: Published -// Description: Removes the text from the TextNode. -//////////////////////////////////////////////////////////////////// +/** + * Removes the text from the TextNode. + */ INLINE void TextNode:: clear_text() { TextEncoder::clear_text(); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::append_text -// Access: Published -// Description: Appends the indicates string to the end of the stored -// text. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicates string to the end of the stored text. + */ INLINE void TextNode:: append_text(const string &text) { TextEncoder::append_text(text); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::append_unicode_char -// Access: Published -// Description: Appends a single character to the end of the stored -// text. This may be a wide character, up to 16 bits in -// Unicode. -//////////////////////////////////////////////////////////////////// +/** + * Appends a single character to the end of the stored text. This may be a + * wide character, up to 16 bits in Unicode. + */ INLINE void TextNode:: append_unicode_char(wchar_t character) { TextEncoder::append_unicode_char(character); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_wordwrapped_text -// Access: Public -// Description: Returns a string that represents the contents of the -// text, as it has been formatted by wordwrap rules. -// -// In earlier versions, this did not contain any -// embedded special characters like \1 or \3; now it -// does. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that represents the contents of the text, as it has been + * formatted by wordwrap rules. + * + * In earlier versions, this did not contain any embedded special characters + * like \1 or \3; now it does. + */ INLINE string TextNode:: get_wordwrapped_text() const { return encode_wtext(get_wordwrapped_wtext()); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::calc_width -// Access: Published -// Description: Returns the width of a line of text of arbitrary -// characters. The line should not include the newline -// character. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a line of text of arbitrary characters. The line + * should not include the newline character. + */ INLINE PN_stdfloat TextNode:: calc_width(const string &line) const { return calc_width(decode_text(line)); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::set_wtext -// Access: Published -// Description: Changes the text that is displayed under the -// TextNode, with a wide text. This automatically sets -// the string reported by get_text() to the 8-bit -// encoded version of the same string. -//////////////////////////////////////////////////////////////////// +/** + * Changes the text that is displayed under the TextNode, with a wide text. + * This automatically sets the string reported by get_text() to the 8-bit + * encoded version of the same string. + */ INLINE void TextNode:: set_wtext(const wstring &wtext) { TextEncoder::set_wtext(wtext); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::append_wtext -// Access: Published -// Description: Appends the indicates string to the end of the stored -// wide-character text. -//////////////////////////////////////////////////////////////////// +/** + * Appends the indicates string to the end of the stored wide-character text. + */ INLINE void TextNode:: append_wtext(const wstring &wtext) { TextEncoder::append_wtext(wtext); invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_wordwrapped_wtext -// Access: Published -// Description: Returns a wstring that represents the contents of the -// text, as it has been formatted by wordwrap rules. -// -// In earlier versions, this did not contain any -// embedded special characters like \1 or \3; now it -// does. -//////////////////////////////////////////////////////////////////// +/** + * Returns a wstring that represents the contents of the text, as it has been + * formatted by wordwrap rules. + * + * In earlier versions, this did not contain any embedded special characters + * like \1 or \3; now it does. + */ INLINE wstring TextNode:: get_wordwrapped_wtext() const { check_measure(); return _wordwrapped_wtext; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_left -// Access: Published -// Description: Returns the leftmost extent of the text in local 2-d -// coordinates, unmodified by the set_transform() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the leftmost extent of the text in local 2-d coordinates, + * unmodified by the set_transform() matrix. + */ INLINE PN_stdfloat TextNode:: get_left() const { check_measure(); return _text_ul[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_right -// Access: Published -// Description: Returns the rightmost extent of the text in local 2-d -// coordinates, unmodified by the set_transform() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rightmost extent of the text in local 2-d coordinates, + * unmodified by the set_transform() matrix. + */ INLINE PN_stdfloat TextNode:: get_right() const { check_measure(); return _text_lr[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_bottom -// Access: Published -// Description: Returns the bottommost extent of the text in local -// 2-d coordinates, unmodified by the set_transform() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the bottommost extent of the text in local 2-d coordinates, + * unmodified by the set_transform() matrix. + */ INLINE PN_stdfloat TextNode:: get_bottom() const { check_measure(); return _text_lr[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_top -// Access: Published -// Description: Returns the topmost extent of the text in local 2-d -// coordinates, unmodified by the set_transform() -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the topmost extent of the text in local 2-d coordinates, unmodified + * by the set_transform() matrix. + */ INLINE PN_stdfloat TextNode:: get_top() const { check_measure(); return _text_ul[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_height -// Access: Published -// Description: Returns the net height of the text in local 2-d -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net height of the text in local 2-d coordinates. + */ INLINE PN_stdfloat TextNode:: get_height() const { check_measure(); return _text_ul[1] - _text_lr[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_width -// Access: Published -// Description: Returns the net width of the text in local 2-d -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net width of the text in local 2-d coordinates. + */ INLINE PN_stdfloat TextNode:: get_width() const { check_measure(); return _text_lr[0] - _text_ul[0]; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_upper_left_3d -// Access: Published -// Description: Returns the upper-left extent of the text object, -// after it has been transformed into 3-d space by -// applying the set_transform() matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the upper-left extent of the text object, after it has been + * transformed into 3-d space by applying the set_transform() matrix. + */ INLINE LPoint3 TextNode:: get_upper_left_3d() const { check_measure(); return _ul3d; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_lower_right_3d -// Access: Published -// Description: Returns the lower-right extent of the text object, -// after it has been transformed into 3-d space by -// applying the set_transform() matrix. -//////////////////////////////////////////////////////////////////// +/** + * Returns the lower-right extent of the text object, after it has been + * transformed into 3-d space by applying the set_transform() matrix. + */ INLINE LPoint3 TextNode:: get_lower_right_3d() const { check_measure(); return _lr3d; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_num_rows -// Access: Published -// Description: Returns the number of rows of text that were -// generated. This counts word-wrapped rows as well as -// rows generated due to embedded newlines. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of rows of text that were generated. This counts word- + * wrapped rows as well as rows generated due to embedded newlines. + */ INLINE int TextNode:: get_num_rows() const { check_measure(); return _num_rows; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::update -// Access: Published -// Description: Can be called after the TextNode has been fully -// configured, to force the node to recompute its text -// immediately, rather than waiting for it to be drawn. -// This call is optional. -//////////////////////////////////////////////////////////////////// +/** + * Can be called after the TextNode has been fully configured, to force the + * node to recompute its text immediately, rather than waiting for it to be + * drawn. This call is optional. + */ INLINE void TextNode:: update() { check_rebuild(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::force_update -// Access: Published -// Description: Forces the TextNode to recompute itself now, even if -// it believes nothing has changed. Normally, this -// should not need to be called, but it may be useful if -// some properties change outside of the TextNode's -// knowledge (for instance, within the font). -//////////////////////////////////////////////////////////////////// +/** + * Forces the TextNode to recompute itself now, even if it believes nothing + * has changed. Normally, this should not need to be called, but it may be + * useful if some properties change outside of the TextNode's knowledge (for + * instance, within the font). + */ INLINE void TextNode:: force_update() { invalidate_with_measure(); check_rebuild(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::invalidate_no_measure -// Access: Private -// Description: Called internally whenever some state on the TextNode -// changes, requiring the internal geometry to be -// recomputed, but which will not result in a change in -// the size or shape of the text (for instance, the text -// color changes). -//////////////////////////////////////////////////////////////////// +/** + * Called internally whenever some state on the TextNode changes, requiring + * the internal geometry to be recomputed, but which will not result in a + * change in the size or shape of the text (for instance, the text color + * changes). + */ INLINE void TextNode:: invalidate_no_measure() { _flags |= F_needs_rebuild; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::invalidate_with_measure -// Access: Private -// Description: Called internally whenever some state on the TextNode -// changes, requiring the internal geometry to be -// recomputed, and which will may result in a change in -// the size or shape of the text (for instance, the text -// scale changes). -//////////////////////////////////////////////////////////////////// +/** + * Called internally whenever some state on the TextNode changes, requiring + * the internal geometry to be recomputed, and which will may result in a + * change in the size or shape of the text (for instance, the text scale + * changes). + */ INLINE void TextNode:: invalidate_with_measure() { _flags |= (F_needs_rebuild | F_needs_measure); mark_internal_bounds_stale(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::check_rebuild -// Access: Private -// Description: Called internally to call do_rebuild() if necessary -// (that is, if the internal geometry has changed -// recently). -//////////////////////////////////////////////////////////////////// +/** + * Called internally to call do_rebuild() if necessary (that is, if the + * internal geometry has changed recently). + */ INLINE void TextNode:: check_rebuild() const { if ((_flags & F_needs_rebuild) != 0) { @@ -1480,13 +1178,10 @@ check_rebuild() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::check_measure -// Access: Private -// Description: Called internally to call do_measure() if necessary; -// this will remeasure the text without necessarily -// rebuilding it. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to call do_measure() if necessary; this will remeasure + * the text without necessarily rebuilding it. + */ INLINE void TextNode:: check_measure() const { if ((_flags & F_needs_measure) != 0) { diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index aea9c3552d..b9bfd22125 100644 --- a/panda/src/text/textNode.cxx +++ b/panda/src/text/textNode.cxx @@ -1,16 +1,15 @@ -// Filename: textNode.cxx -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textNode.cxx + * @author drose + * @date 2002-03-13 + */ #include "textNode.h" #include "textGlyph.h" @@ -54,11 +53,9 @@ TypeHandle TextNode::_type_handle; PStatCollector TextNode::_text_generate_pcollector("*:Generate Text"); -//////////////////////////////////////////////////////////////////// -// Function: TextNode::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextNode:: TextNode(const string &name) : PandaNode(name) { set_cull_callback(); @@ -95,16 +92,13 @@ TextNode(const string &name) : PandaNode(name) { _lr3d.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::Copy Constructor -// Access: Published -// Description: It's sort of a copy constructor: it copies the -// indicated TextProperties, without copying a complete -// TextNode. -//////////////////////////////////////////////////////////////////// +/** + * It's sort of a copy constructor: it copies the indicated TextProperties, + * without copying a complete TextNode. + */ TextNode:: -TextNode(const string &name, const TextProperties ©) : - PandaNode(name), TextProperties(copy) +TextNode(const string &name, const TextProperties ©) : + PandaNode(name), TextProperties(copy) { _flags = 0; _max_rows = 0; @@ -127,14 +121,12 @@ TextNode(const string &name, const TextProperties ©) : _lr3d.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::Copy Constructor -// Access: Published -// Description: OK, this is a true copy constructor. -//////////////////////////////////////////////////////////////////// +/** + * OK, this is a true copy constructor. + */ TextNode:: -TextNode(const TextNode ©) : - PandaNode(copy), +TextNode(const TextNode ©) : + PandaNode(copy), TextEncoder(copy), TextProperties(copy), _card_texture(copy._card_texture), @@ -158,35 +150,27 @@ TextNode(const TextNode ©) : invalidate_with_measure(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::make_copy -// Access: Protected, Virtual -// Description: Returns a newly-allocated Node that is a shallow copy -// of this one. It will be a different Node pointer, -// but its internal data may or may not be shared with -// that of the original Node. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated Node that is a shallow copy of this one. It will + * be a different Node pointer, but its internal data may or may not be shared + * with that of the original Node. + */ PandaNode *TextNode:: make_copy() const { return new TextNode(*this); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextNode:: ~TextNode() { } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::calc_width -// Access: Published -// Description: Returns the width of a single character of the font, -// or 0.0 if the character is not known. This may be a -// wide character (greater than 255). -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a single character of the font, or 0.0 if the + * character is not known. This may be a wide character (greater than 255). + */ PN_stdfloat TextNode:: calc_width(wchar_t character) const { TextFont *font = get_font(); @@ -197,24 +181,18 @@ calc_width(wchar_t character) const { return TextAssembler::calc_width(character, *this); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_exact_character -// Access: Published -// Description: Returns true if the named character exists in the -// font exactly as named, false otherwise. Note that -// because Panda can assemble glyphs together -// automatically using cheesy accent marks, this is not -// a reliable indicator of whether a suitable glyph can -// be rendered for the character. For that, use -// has_character() instead. -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// but returns false for characters that would render -// with the "invalid glyph". It also returns false for -// characters that would be synthesized within Panda, -// but see has_character(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named character exists in the font exactly as named, + * false otherwise. Note that because Panda can assemble glyphs together + * automatically using cheesy accent marks, this is not a reliable indicator + * of whether a suitable glyph can be rendered for the character. For that, + * use has_character() instead. + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), but returns false for characters that would render with + * the "invalid glyph". It also returns false for characters that would be + * synthesized within Panda, but see has_character(). + */ bool TextNode:: has_exact_character(wchar_t character) const { TextFont *font = get_font(); @@ -225,19 +203,15 @@ has_exact_character(wchar_t character) const { return TextAssembler::has_exact_character(character, *this); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::has_character -// Access: Published -// Description: Returns true if the named character exists in the -// font or can be synthesized by Panda, false otherwise. -// (Panda can synthesize some accented characters by -// combining similar-looking glyphs from the font.) -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// but returns false for characters that would render -// with the "invalid glyph". -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named character exists in the font or can be + * synthesized by Panda, false otherwise. (Panda can synthesize some accented + * characters by combining similar-looking glyphs from the font.) + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), but returns false for characters that would render with + * the "invalid glyph". + */ bool TextNode:: has_character(wchar_t character) const { TextFont *font = get_font(); @@ -248,27 +222,20 @@ has_character(wchar_t character) const { return TextAssembler::has_character(character, *this); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::is_whitespace -// Access: Published -// Description: Returns true if the indicated character represents -// whitespace in the font, or false if anything visible -// will be rendered for it. -// -// This returns true for whitespace and Unicode -// whitespace characters (if they exist in the font), -// and returns false for any other characters, including -// characters that do not exist in the font (these would -// be rendered with the "invalid glyph", which is -// visible). -// -// Note that this function can be reliably used to -// identify Unicode whitespace characters only if the -// font has all of the whitespace characters defined. -// It will return false for any character not in the -// font, even if it is an official Unicode whitespace -// character. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated character represents whitespace in the font, + * or false if anything visible will be rendered for it. + * + * This returns true for whitespace and Unicode whitespace characters (if they + * exist in the font), and returns false for any other characters, including + * characters that do not exist in the font (these would be rendered with the + * "invalid glyph", which is visible). + * + * Note that this function can be reliably used to identify Unicode whitespace + * characters only if the font has all of the whitespace characters defined. + * It will return false for any character not in the font, even if it is an + * official Unicode whitespace character. + */ bool TextNode:: is_whitespace(wchar_t character) const { TextFont *font = get_font(); @@ -279,14 +246,11 @@ is_whitespace(wchar_t character) const { return TextAssembler::is_whitespace(character, *this); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::calc_width -// Access: Published -// Description: Returns the width of a line of text of arbitrary -// characters. The line should not include the newline -// character or any embedded control characters like \1 -// or \3. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of a line of text of arbitrary characters. The line + * should not include the newline character or any embedded control characters + * like \1 or \3. + */ PN_stdfloat TextNode:: calc_width(const wstring &line) const { PN_stdfloat width = 0.0f; @@ -299,11 +263,9 @@ calc_width(const wstring &line) const { return width; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextNode:: output(ostream &out) const { PandaNode::output(out); @@ -317,11 +279,9 @@ output(ostream &out) const { out << " (" << geom_count << " geoms)"; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::write -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextNode:: write(ostream &out, int indent_level) const { PandaNode::write(out, indent_level); @@ -334,13 +294,11 @@ write(ostream &out, int indent_level) const { << "text is " << get_text() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::generate -// Access: Published -// Description: Generates the text, according to the parameters -// indicated within the TextNode, and returns a Node -// that may be parented within the tree to represent it. -//////////////////////////////////////////////////////////////////// +/** + * Generates the text, according to the parameters indicated within the + * TextNode, and returns a Node that may be parented within the tree to + * represent it. + */ PT(PandaNode) TextNode:: generate() { PStatTimer timer(_text_generate_pcollector); @@ -350,15 +308,14 @@ generate() { << " with '" << get_text() << "'\n"; } - // The strategy here will be to assemble together a bunch of - // letters, instanced from the letter hierarchy of font_def, into - // our own little hierarchy. + // The strategy here will be to assemble together a bunch of letters, + // instanced from the letter hierarchy of font_def, into our own little + // hierarchy. - // There will be one root over the whole text block, that - // contains the transform passed in. Under this root there will be - // another node for each row, that moves the row into the right place - // horizontally and vertically, and for each row, there is another - // node for each character. + // There will be one root over the whole text block, that contains the + // transform passed in. Under this root there will be another node for each + // row, that moves the row into the right place horizontally and vertically, + // and for each row, there is another node for each character. _ul3d.set(0.0f, 0.0f, 0.0f); _lr3d.set(0.0f, 0.0f, 0.0f); @@ -380,9 +337,8 @@ generate() { return root; } - // Compute the overall text transform matrix. We build the text in - // a Z-up coordinate system and then convert it to whatever the user - // asked for. + // Compute the overall text transform matrix. We build the text in a Z-up + // coordinate system and then convert it to whatever the user asked for. LMatrix4 mat = LMatrix4::convert_mat(CS_zup_right, _coordinate_system) * _transform; @@ -418,8 +374,8 @@ generate() { root->add_child(text, get_draw_order() + 2); text->add_child(text_root); - // Save the bounding-box information about the text in a form - // friendly to the user. + // Save the bounding-box information about the text in a form friendly to + // the user. const LVector2 &ul = assembler.get_ul(); const LVector2 &lr = assembler.get_lr(); _ul3d.set(ul[0], 0.0f, ul[1]); @@ -469,8 +425,8 @@ generate() { SceneGraphReducer gr; gr.apply_attribs(card_root); - // In order to decal the text onto the card, the card must - // become the parent of the text. + // In order to decal the text onto the card, the card must become the + // parent of the text. card_root->add_child(root); root = card_root; @@ -499,61 +455,49 @@ generate() { return root; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_internal_geom -// Access: Published -// Description: Returns the actual node that is used internally to -// render the text, if the TextNode is parented within -// the scene graph. -// -// In general, you should not call this method. Call -// generate() instead if you want to get a handle to -// geometry that represents the text. This method is -// provided as a debugging aid only. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual node that is used internally to render the text, if the + * TextNode is parented within the scene graph. + * + * In general, you should not call this method. Call generate() instead if + * you want to get a handle to geometry that represents the text. This method + * is provided as a debugging aid only. + */ PandaNode *TextNode:: get_internal_geom() const { - // Output a nuisance warning to discourage the naive from calling - // this method accidentally. + // Output a nuisance warning to discourage the naive from calling this + // method accidentally. text_cat.info() << "TextNode::get_internal_geom() called.\n"; check_rebuild(); return _internal_geom; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::get_unsafe_to_apply_attribs -// Access: Public, Virtual -// Description: Returns the union of all attributes from -// SceneGraphReducer::AttribTypes that may not safely be -// applied to the vertices of this node. If this is -// nonzero, these attributes must be dropped at this -// node as a state change. -// -// This is a generalization of safe_to_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the union of all attributes from SceneGraphReducer::AttribTypes + * that may not safely be applied to the vertices of this node. If this is + * nonzero, these attributes must be dropped at this node as a state change. + * + * This is a generalization of safe_to_transform(). + */ int TextNode:: get_unsafe_to_apply_attribs() const { - // We have no way to apply these kinds of attributes to our - // TextNode, so insist they get dropped into the PandaNode's basic - // state. - return - SceneGraphReducer::TT_tex_matrix | + // We have no way to apply these kinds of attributes to our TextNode, so + // insist they get dropped into the PandaNode's basic state. + return + SceneGraphReducer::TT_tex_matrix | SceneGraphReducer::TT_other; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::apply_attribs_to_vertices -// Access: Public, Virtual -// Description: Applies whatever attributes are specified in the -// AccumulatedAttribs object (and by the attrib_types -// bitmask) to the vertices on this node, if -// appropriate. If this node uses geom arrays like a -// GeomNode, the supplied GeomTransformer may be used to -// unify shared arrays across multiple different nodes. -// -// This is a generalization of xform(). -//////////////////////////////////////////////////////////////////// +/** + * Applies whatever attributes are specified in the AccumulatedAttribs object + * (and by the attrib_types bitmask) to the vertices on this node, if + * appropriate. If this node uses geom arrays like a GeomNode, the supplied + * GeomTransformer may be used to unify shared arrays across multiple + * different nodes. + * + * This is a generalization of xform(). + */ void TextNode:: apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer) { @@ -562,9 +506,9 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, _transform *= mat; if ((_flags & F_needs_measure) == 0) { - // If we already have a measure, transform it too. We don't - // need to invalidate the 2-d parts, since that's not affected - // by the transform anyway. + // If we already have a measure, transform it too. We don't need to + // invalidate the 2-d parts, since that's not affected by the transform + // anyway. _ul3d = _ul3d * mat; _lr3d = _lr3d * mat; } @@ -614,73 +558,61 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, } } - // Now propagate the attributes down to our already-generated - // geometry, if we have any. - if ((_flags & F_needs_rebuild) == 0 && + // Now propagate the attributes down to our already-generated geometry, if + // we have any. + if ((_flags & F_needs_rebuild) == 0 && _internal_geom != (PandaNode *)NULL) { SceneGraphReducer gr; gr.apply_attribs(_internal_geom, attribs, attrib_types, transformer); } } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::calc_tight_bounds -// Access: Public, Virtual -// Description: This is used to support -// NodePath::calc_tight_bounds(). It is not intended to -// be called directly, and it has nothing to do with the -// normal Panda bounding-volume computation. -// -// If the node contains any geometry, this updates -// min_point and max_point to enclose its bounding box. -// found_any is to be set true if the node has any -// geometry at all, or left alone if it has none. This -// method may be called over several nodes, so it may -// enter with min_point, max_point, and found_any -// already set. -//////////////////////////////////////////////////////////////////// +/** + * This is used to support NodePath::calc_tight_bounds(). It is not intended + * to be called directly, and it has nothing to do with the normal Panda + * bounding-volume computation. + * + * If the node contains any geometry, this updates min_point and max_point to + * enclose its bounding box. found_any is to be set true if the node has any + * geometry at all, or left alone if it has none. This method may be called + * over several nodes, so it may enter with min_point, max_point, and + * found_any already set. + */ CPT(TransformState) TextNode:: calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const TransformState *transform, Thread *current_thread) const { - CPT(TransformState) next_transform = + CPT(TransformState) next_transform = PandaNode::calc_tight_bounds(min_point, max_point, found_any, transform, current_thread); check_rebuild(); if (_internal_geom != (PandaNode *)NULL) { - _internal_geom->calc_tight_bounds(min_point, max_point, + _internal_geom->calc_tight_bounds(min_point, max_point, found_any, next_transform, current_thread); } return next_transform; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::cull_callback -// Access: Protected, Virtual -// Description: This function will be called during the cull -// traversal to perform any additional operations that -// should be performed at cull time. This may include -// additional manipulation of render state or additional -// visible/invisible decisions, or any other arbitrary -// operation. -// -// Note that this function will *not* be called unless -// set_cull_callback() is called in the constructor of -// the derived class. It is necessary to call -// set_cull_callback() to indicated that we require -// cull_callback() to be called. -// -// By the time this function is called, the node has -// already passed the bounding-volume test for the -// viewing frustum, and the node's transform and state -// have already been applied to the indicated -// CullTraverserData object. -// -// The return value is true if this node should be -// visible, or false if it should be culled. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called during the cull traversal to perform any + * additional operations that should be performed at cull time. This may + * include additional manipulation of render state or additional + * visible/invisible decisions, or any other arbitrary operation. + * + * Note that this function will *not* be called unless set_cull_callback() is + * called in the constructor of the derived class. It is necessary to call + * set_cull_callback() to indicated that we require cull_callback() to be + * called. + * + * By the time this function is called, the node has already passed the + * bounding-volume test for the viewing frustum, and the node's transform and + * state have already been applied to the indicated CullTraverserData object. + * + * The return value is true if this node should be visible, or false if it + * should be culled. + */ bool TextNode:: cull_callback(CullTraverser *trav, CullTraverserData &data) { check_rebuild(); @@ -694,29 +626,22 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::is_renderable -// Access: Public, Virtual -// Description: Returns true if there is some value to visiting this -// particular node during the cull traversal for any -// camera, false otherwise. This will be used to -// optimize the result of get_net_draw_show_mask(), so -// that any subtrees that contain only nodes for which -// is_renderable() is false need not be visited. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is some value to visiting this particular node during + * the cull traversal for any camera, false otherwise. This will be used to + * optimize the result of get_net_draw_show_mask(), so that any subtrees that + * contain only nodes for which is_renderable() is false need not be visited. + */ bool TextNode:: is_renderable() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::compute_internal_bounds -// Access: Protected, Virtual -// Description: Called when needed to recompute the node's -// _internal_bound object. Nodes that contain anything -// of substance should redefine this to do the right -// thing. -//////////////////////////////////////////////////////////////////// +/** + * Called when needed to recompute the node's _internal_bound object. Nodes + * that contain anything of substance should redefine this to do the right + * thing. + */ void TextNode:: compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, @@ -727,9 +652,8 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, GeometricBoundingVolume *gbv = DCAST(GeometricBoundingVolume, bound); - // Now enclose the bounding box around the text. We can do this - // without actually generating the text, if we have at least - // measured it. + // Now enclose the bounding box around the text. We can do this without + // actually generating the text, if we have at least measured it. check_measure(); LPoint3 vertices[8]; @@ -748,14 +672,10 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, internal_vertices = 0; // TODO: estimate this better. } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::r_prepare_scene -// Access: Protected, Virtual -// Description: The recursive implementation of prepare_scene(). -// Don't call this directly; call -// PandaNode::prepare_scene() or -// NodePath::prepare_scene() instead. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of prepare_scene(). Don't call this directly; + * call PandaNode::prepare_scene() or NodePath::prepare_scene() instead. + */ void TextNode:: r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) { @@ -766,16 +686,14 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, CPT(RenderState) child_state = node_state->compose(child->get_state()); child->r_prepare_scene(gsg, child_state, transformer, current_thread); } - + PandaNode::r_prepare_scene(gsg, node_state, transformer, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::do_rebuild -// Access: Private -// Description: Removes any existing children of the TextNode, and -// adds the newly generated text instead. -//////////////////////////////////////////////////////////////////// +/** + * Removes any existing children of the TextNode, and adds the newly generated + * text instead. + */ void TextNode:: do_rebuild() { _flags &= ~(F_needs_rebuild | F_needs_measure); @@ -783,24 +701,19 @@ do_rebuild() { } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::do_measure -// Access: Private -// Description: Can be called in lieu of do_rebuild() to measure the -// text and set up the bounding boxes properly without -// actually assembling it. -//////////////////////////////////////////////////////////////////// +/** + * Can be called in lieu of do_rebuild() to measure the text and set up the + * bounding boxes properly without actually assembling it. + */ void TextNode:: do_measure() { // We no longer make this a special case. do_rebuild(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::make_frame -// Access: Private -// Description: Creates a frame around the text. -//////////////////////////////////////////////////////////////////// +/** + * Creates a frame around the text. + */ PT(PandaNode) TextNode:: make_frame() { PT(GeomNode) frame_node = new GeomNode("frame"); @@ -810,28 +723,28 @@ make_frame() { PN_stdfloat right = dimensions[1]; PN_stdfloat bottom = dimensions[2]; PN_stdfloat top = dimensions[3]; - + CPT(RenderAttrib) thick = RenderModeAttrib::make(RenderModeAttrib::M_unchanged, _frame_width); CPT(RenderState) state = RenderState::make(thick); PT(GeomVertexData) vdata = new GeomVertexData ("text", GeomVertexFormat::get_v3(), get_usage_hint()); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); - + vertex.add_data3(left, 0.0f, top); vertex.add_data3(left, 0.0f, bottom); vertex.add_data3(right, 0.0f, bottom); vertex.add_data3(right, 0.0f, top); - + PT(GeomLinestrips) frame = new GeomLinestrips(get_usage_hint()); frame->add_consecutive_vertices(0, 4); frame->add_vertex(0); frame->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(frame); frame_node->add_geom(geom, state); - + if (get_frame_corners()) { PT(GeomPoints) corners = new GeomPoints(get_usage_hint()); corners->add_consecutive_vertices(0, 4); @@ -843,11 +756,9 @@ make_frame() { return frame_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::make_card -// Access: Private -// Description: Creates a card behind the text. -//////////////////////////////////////////////////////////////////// +/** + * Creates a card behind the text. + */ PT(PandaNode) TextNode:: make_card() { PT(GeomNode) card_node = new GeomNode("card"); @@ -862,36 +773,34 @@ make_card() { ("text", GeomVertexFormat::get_v3t2(), get_usage_hint()); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - + vertex.add_data3(left, 0.0f, top); vertex.add_data3(left, 0.0f, bottom); vertex.add_data3(right, 0.0f, top); vertex.add_data3(right, 0.0f, bottom); - + texcoord.add_data2(0.0f, 1.0f); texcoord.add_data2(0.0f, 0.0f); texcoord.add_data2(1.0f, 1.0f); texcoord.add_data2(1.0f, 0.0f); - + PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); card->add_consecutive_vertices(0, 4); card->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(card); - + card_node->add_geom(geom); return card_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::make_card_with_border -// Access: Private -// Description: Creates a card behind the text with a specified border -// for button edge or what have you. -//////////////////////////////////////////////////////////////////// +/** + * Creates a card behind the text with a specified border for button edge or + * what have you. + */ PT(PandaNode) TextNode:: make_card_with_border() { PT(GeomNode) card_node = new GeomNode("card"); @@ -902,20 +811,17 @@ make_card_with_border() { PN_stdfloat bottom = dimensions[2]; PN_stdfloat top = dimensions[3]; - // we now create three tri-strips instead of one - // with vertices arranged as follows: - // - // 1 3 5 7 - one - // 2 4 6 8 / \ two - // 9 11 13 15 \ / - // 10 12 14 16 - three - // +/* + * we now create three tri-strips instead of one with vertices arranged as + * follows: 1 3 5 7 - one 2 4 6 8 \ two 9 11 + * 13 15 \ 10 12 14 16 - three + */ PT(GeomVertexData) vdata = new GeomVertexData ("text", GeomVertexFormat::get_v3t2(), get_usage_hint()); GeomVertexWriter vertex(vdata, InternalName::get_vertex()); GeomVertexWriter texcoord(vdata, InternalName::get_texcoord()); - + // verts 1,2,3,4 vertex.add_data3(left, 0.02, top); vertex.add_data3(left, 0.02, top - _card_border_size); @@ -940,7 +846,7 @@ make_card_with_border() { vertex.add_data3(right - _card_border_size, 0.02, bottom); vertex.add_data3(right, 0.02, bottom + _card_border_size); vertex.add_data3(right, 0.02, bottom); - + texcoord.add_data2(0.0f, 1.0f); //1 texcoord.add_data2(0.0f, 1.0f - _card_border_uv_portion); //2 texcoord.add_data2(0.0f + _card_border_uv_portion, 1.0f); //3 @@ -951,7 +857,7 @@ make_card_with_border() { 1.0f - _card_border_uv_portion); //6 texcoord.add_data2(1.0f, 1.0f); //7 texcoord.add_data2(1.0f, 1.0f - _card_border_uv_portion); //8 - + texcoord.add_data2(0.0f, _card_border_uv_portion); //9 texcoord.add_data2(0.0f, 0.0f); //10 texcoord.add_data2(_card_border_uv_portion, _card_border_uv_portion); //11 @@ -961,13 +867,13 @@ make_card_with_border() { texcoord.add_data2(1.0f - _card_border_uv_portion, 0.0f);//14 texcoord.add_data2(1.0f, _card_border_uv_portion);//15 texcoord.add_data2(1.0f, 0.0f);//16 - + PT(GeomTristrips) card = new GeomTristrips(get_usage_hint()); - + // tristrip #1 card->add_consecutive_vertices(0, 8); card->close_primitive(); - + // tristrip #2 card->add_vertex(1); card->add_vertex(8); @@ -978,26 +884,23 @@ make_card_with_border() { card->add_vertex(7); card->add_vertex(14); card->close_primitive(); - + // tristrip #3 card->add_consecutive_vertices(8, 8); card->close_primitive(); - + PT(Geom) geom = new Geom(vdata); geom->add_primitive(card); - + card_node->add_geom(geom); - + return card_node.p(); } -//////////////////////////////////////////////////////////////////// -// Function: TextNode::count_geoms -// Access: Private, Static -// Description: Recursively counts the number of Geoms at the -// indicated node and below. Strictly for reporting -// this count on output. -//////////////////////////////////////////////////////////////////// +/** + * Recursively counts the number of Geoms at the indicated node and below. + * Strictly for reporting this count on output. + */ int TextNode:: count_geoms(PandaNode *node) { int num_geoms = 0; diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index cb315e6744..5f10e22da3 100644 --- a/panda/src/text/textNode.h +++ b/panda/src/text/textNode.h @@ -1,16 +1,15 @@ -// Filename: textNode.h -// Created by: drose (13Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textNode.h + * @author drose + * @date 2002-03-13 + */ #ifndef TEXTNODE_H #define TEXTNODE_H @@ -26,29 +25,24 @@ #include "luse.h" #include "geom.h" -//////////////////////////////////////////////////////////////////// -// Class : TextNode -// Description : The primary interface to this module. This class -// does basic text assembly; given a string of text and -// a TextFont object, it creates a piece of geometry -// that may be placed in the 3-d or 2-d world to -// represent the indicated text. -// -// The TextNode may be used in one of two ways. -// Naively, it may simply be parented directly into the -// scene graph and rendered as if it were a GeomNode; in -// this mode, the actual polygon geometry that renders -// the text is not directly visible or accessible, but -// remains hidden within the TextNode. -// -// The second way TextNode may be used is as a text -// generator. To use it in this way, do not parent the -// TextNode to the scene graph; instead, set the -// properties of the text and call generate() to return -// an ordinary node, containing ordinary geometry, which -// you may use however you like. Each time you call -// generate() a new node is returned. -//////////////////////////////////////////////////////////////////// +/** + * The primary interface to this module. This class does basic text assembly; + * given a string of text and a TextFont object, it creates a piece of + * geometry that may be placed in the 3-d or 2-d world to represent the + * indicated text. + * + * The TextNode may be used in one of two ways. Naively, it may simply be + * parented directly into the scene graph and rendered as if it were a + * GeomNode; in this mode, the actual polygon geometry that renders the text + * is not directly visible or accessible, but remains hidden within the + * TextNode. + * + * The second way TextNode may be used is as a text generator. To use it in + * this way, do not parent the TextNode to the scene graph; instead, set the + * properties of the text and call generate() to return an ordinary node, + * containing ordinary geometry, which you may use however you like. Each + * time you call generate() a new node is returned. + */ class EXPCL_PANDA_TEXT TextNode : public PandaNode, public TextEncoder, public TextProperties { PUBLISHED: TextNode(const string &name); @@ -135,9 +129,8 @@ PUBLISHED: INLINE void set_flatten_flags(int flatten_flags); INLINE int get_flatten_flags() const; - // These methods are inherited from TextProperties, but we override - // here so we can flag the TextNode as dirty when they have been - // changed. + // These methods are inherited from TextProperties, but we override here so + // we can flag the TextNode as dirty when they have been changed. INLINE void set_font(TextFont *font); INLINE void clear_font(); @@ -187,24 +180,23 @@ PUBLISHED: INLINE void set_glyph_shift(PN_stdfloat glyph_shift); INLINE void clear_glyph_shift(); - // These methods are inherited from TextEncoder, but we override - // here so we can flag the TextNode as dirty when they have been - // changed. + // These methods are inherited from TextEncoder, but we override here so we + // can flag the TextNode as dirty when they have been changed. INLINE void set_text(const string &text); INLINE void set_text(const string &text, Encoding encoding); INLINE void clear_text(); INLINE void append_text(const string &text); INLINE void append_unicode_char(wchar_t character); - // After the text has been set, you can query this to determine how - // it will be wordwrapped. + // After the text has been set, you can query this to determine how it will + // be wordwrapped. INLINE string get_wordwrapped_text() const; - // These methods calculate the width of a single character or a line - // of text in the current font. + // These methods calculate the width of a single character or a line of text + // in the current font. PN_stdfloat calc_width(wchar_t character) const; INLINE PN_stdfloat calc_width(const string &line) const; - + bool has_exact_character(wchar_t character) const; bool has_character(wchar_t character) const; bool is_whitespace(wchar_t character) const; @@ -219,8 +211,8 @@ PUBLISHED: virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; - // The following functions return information about the text that - // was last built (and is currently visible). + // The following functions return information about the text that was last + // built (and is currently visible). INLINE PN_stdfloat get_left() const; INLINE PN_stdfloat get_right() const; INLINE PN_stdfloat get_bottom() const; diff --git a/panda/src/text/textProperties.I b/panda/src/text/textProperties.I index 0adeb553b0..4e73399be1 100644 --- a/panda/src/text/textProperties.I +++ b/panda/src/text/textProperties.I @@ -1,61 +1,48 @@ -// Filename: textProperties.I -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textProperties.I + * @author drose + * @date 2004-04-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: operator != (const TextProperties &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::is_any_specified -// Access: Published -// Description: Returns true if any properties have been specified, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any properties have been specified, false otherwise. + */ INLINE bool TextProperties:: is_any_specified() const { return (_specified != 0); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_default_font -// Access: Published, Static -// Description: Specifies the default font to be used for any -// TextNode whose font is uninitialized or NULL. See -// set_font(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default font to be used for any TextNode whose font is + * uninitialized or NULL. See set_font(). + */ INLINE void TextProperties:: set_default_font(TextFont *font) { - // If the user overrides the default, we don't need to try to load - // whatever it would have been. + // If the user overrides the default, we don't need to try to load whatever + // it would have been. _loaded_default_font = true; _default_font = font; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_default_font -// Access: Published, Static -// Description: Specifies the default font to be used for any -// TextNode whose font is uninitialized or NULL. See -// set_font(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the default font to be used for any TextNode whose font is + * uninitialized or NULL. See set_font(). + */ INLINE TextFont *TextProperties:: get_default_font() { if (!_loaded_default_font) { @@ -64,488 +51,384 @@ get_default_font() { return _default_font; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_font -// Access: Published -// Description: Sets the font that will be used when making text. If -// this is set to NULL, the default font will be used, -// which can be set via set_default_font(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the font that will be used when making text. If this is set to NULL, + * the default font will be used, which can be set via set_default_font(). + */ INLINE void TextProperties:: set_font(TextFont *font) { _font = font; _specified |= F_has_font; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_font -// Access: Published -// Description: Restores the default font to the text. -//////////////////////////////////////////////////////////////////// +/** + * Restores the default font to the text. + */ INLINE void TextProperties:: clear_font() { _font.clear(); _specified &= ~F_has_font; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_font -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_font() const { return (_specified & F_has_font) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_font -// Access: Published -// Description: Returns the font currently in use, if any. If no -// font is in use, this returns the default font. -//////////////////////////////////////////////////////////////////// +/** + * Returns the font currently in use, if any. If no font is in use, this + * returns the default font. + */ INLINE TextFont *TextProperties:: get_font() const { return has_font() ? _font.p() : get_default_font(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_small_caps -// Access: Published -// Description: Sets the small_caps flag. When this is set, -// lowercase letters are generated as scaled-down -// versions of their uppercase equivalents. This is -// particularly useful to set for fonts that do not have -// lowercase letters. -// -// It is also a good idea to set this for a (dynamic) -// font that has already implemented lowercase letters -// as scaled-down versions of their uppercase -// equivalents, since without this flag the texture -// memory may needlessly duplicate equivalent glyphs for -// upper and lowercase letters. Setting this flag -// causes the texture memory to share the mixed-case -// letters. -// -// The amount by which the lowercase letters are scaled -// is specified by set_small_caps_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the small_caps flag. When this is set, lowercase letters are + * generated as scaled-down versions of their uppercase equivalents. This is + * particularly useful to set for fonts that do not have lowercase letters. + * + * It is also a good idea to set this for a (dynamic) font that has already + * implemented lowercase letters as scaled-down versions of their uppercase + * equivalents, since without this flag the texture memory may needlessly + * duplicate equivalent glyphs for upper and lowercase letters. Setting this + * flag causes the texture memory to share the mixed-case letters. + * + * The amount by which the lowercase letters are scaled is specified by + * set_small_caps_scale(). + */ INLINE void TextProperties:: set_small_caps(bool small_caps) { _small_caps = small_caps; _specified |= F_has_small_caps; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_small_caps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_small_caps() { _small_caps = false; _specified &= ~F_has_small_caps; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_small_caps -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_small_caps() const { return (_specified & F_has_small_caps) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_small_caps -// Access: Published -// Description: Returns the small_caps flag. See set_small_caps(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the small_caps flag. See set_small_caps(). + */ INLINE bool TextProperties:: get_small_caps() const { return _small_caps; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_small_caps_scale -// Access: Published -// Description: Sets the scale factor applied to lowercase letters -// from their uppercase equivalents, when the small_caps -// flag is in effect. See set_small_caps(). Normally, -// this will be a number less than one. -//////////////////////////////////////////////////////////////////// +/** + * Sets the scale factor applied to lowercase letters from their uppercase + * equivalents, when the small_caps flag is in effect. See set_small_caps(). + * Normally, this will be a number less than one. + */ INLINE void TextProperties:: set_small_caps_scale(PN_stdfloat small_caps_scale) { _small_caps_scale = small_caps_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_small_caps_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_small_caps_scale() { _small_caps_scale = text_small_caps_scale; _specified &= ~F_has_small_caps_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_small_caps_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_small_caps_scale() const { return (_specified & F_has_small_caps_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_small_caps_scale -// Access: Published -// Description: Returns the scale factor applied to lowercase letters -// from their uppercase equivalents, when the small_caps -// flag is in effect. See set_small_caps() and -// set_small_caps_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor applied to lowercase letters from their uppercase + * equivalents, when the small_caps flag is in effect. See set_small_caps() + * and set_small_caps_scale(). + */ INLINE PN_stdfloat TextProperties:: get_small_caps_scale() const { return _small_caps_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_slant -// Access: Published -// Description: Specifies the factor by which the text slants to the -// right. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the factor by which the text slants to the right. + */ INLINE void TextProperties:: set_slant(PN_stdfloat slant) { _slant = slant; _specified |= F_has_slant; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_slant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_slant() { _slant = 0.0f; _specified &= ~F_has_slant; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_slant -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_slant() const { return (_specified & F_has_slant) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_slant -// Access: Published -// Description: Returns the factor by which the text is specified to -// slant to the right. -//////////////////////////////////////////////////////////////////// +/** + * Returns the factor by which the text is specified to slant to the right. + */ INLINE PN_stdfloat TextProperties:: get_slant() const { return _slant; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_underscore -// Access: Published -// Description: Sets the underscore flag. When this is set, -// the text is underscored with a one-pixel line the -// same color as the text foreground, drawn at the -// baseline. -//////////////////////////////////////////////////////////////////// +/** + * Sets the underscore flag. When this is set, the text is underscored with a + * one-pixel line the same color as the text foreground, drawn at the + * baseline. + */ INLINE void TextProperties:: set_underscore(bool underscore) { _underscore = underscore; _specified |= F_has_underscore; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_underscore -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_underscore() { _underscore = false; _specified &= ~F_has_underscore; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_underscore -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_underscore() const { return (_specified & F_has_underscore) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_underscore -// Access: Published -// Description: Returns the underscore flag. See set_underscore(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the underscore flag. See set_underscore(). + */ INLINE bool TextProperties:: get_underscore() const { return _underscore; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_underscore_height -// Access: Published -// Description: Specifies the vertical height of the underscore, -// relative to the text baseline. This only has meaning -// if the underscore mode is enabled with -// set_underscore(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the vertical height of the underscore, relative to the text + * baseline. This only has meaning if the underscore mode is enabled with + * set_underscore(). + */ INLINE void TextProperties:: set_underscore_height(PN_stdfloat underscore_height) { _underscore_height = underscore_height; _specified |= F_has_underscore_height; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_underscore_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_underscore_height() { _underscore_height = 0.0f; _specified &= ~F_has_underscore_height; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_underscore_height -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_underscore_height() const { return (_specified & F_has_underscore_height) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_underscore_height -// Access: Published -// Description: Returns the vertical height of the underscore; see -// set_underscore_height(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertical height of the underscore; see set_underscore_height(). + */ INLINE PN_stdfloat TextProperties:: get_underscore_height() const { return has_underscore_height() ? _underscore_height : text_default_underscore_height; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_align -// Access: Published -// Description: Specifies the alignment of the text within its -// margins. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the alignment of the text within its margins. + */ INLINE void TextProperties:: set_align(TextProperties::Alignment align_type) { _align = align_type; _specified |= F_has_align; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_align -// Access: Published -// Description: Restores the default alignment of the text. -//////////////////////////////////////////////////////////////////// +/** + * Restores the default alignment of the text. + */ INLINE void TextProperties:: clear_align() { _align = A_left; _specified &= ~F_has_align; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_align() const { return (_specified & F_has_align) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_align -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TextProperties::Alignment TextProperties:: get_align() const { return _align; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_indent -// Access: Published -// Description: Specifies the amount of extra space that is inserted -// before the first character of each line. This can be -// thought of as a left margin. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the amount of extra space that is inserted before the first + * character of each line. This can be thought of as a left margin. + */ INLINE void TextProperties:: set_indent(PN_stdfloat indent) { _indent_width = indent; _specified |= F_has_indent; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_indent -// Access: Published -// Description: Removes the indent setting from the text. Text -// will be as wide as it is. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indent setting from the text. Text will be as wide as it is. + */ INLINE void TextProperties:: clear_indent() { _indent_width = 0.0f; _specified &= ~F_has_indent; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_indent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_indent() const { return (_specified & F_has_indent) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_indent -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat TextProperties:: get_indent() const { return _indent_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_wordwrap -// Access: Published -// Description: Sets the text up to automatically wordwrap when it -// exceeds the indicated width. This can be thought of -// as a right margin or margin width. -//////////////////////////////////////////////////////////////////// +/** + * Sets the text up to automatically wordwrap when it exceeds the indicated + * width. This can be thought of as a right margin or margin width. + */ INLINE void TextProperties:: set_wordwrap(PN_stdfloat wordwrap) { _wordwrap_width = wordwrap; _specified |= F_has_wordwrap; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_wordwrap -// Access: Published -// Description: Removes the wordwrap setting from the text. Text -// will be as wide as it is. -//////////////////////////////////////////////////////////////////// +/** + * Removes the wordwrap setting from the text. Text will be as wide as it is. + */ INLINE void TextProperties:: clear_wordwrap() { _wordwrap_width = 0.0f; _specified &= ~F_has_wordwrap; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_wordwrap -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_wordwrap() const { return (_specified & F_has_wordwrap) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_wordwrap -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PN_stdfloat TextProperties:: get_wordwrap() const { return _wordwrap_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_preserve_trailing_whitespace -// Access: Published -// Description: Sets the preserve_trailing_whitespace flag. When -// this is set, trailing whitespace at the end of the -// line is not stripped when the text is wordwrapped (it -// is stripped by default). Since the trailing -// whitespace is invisible, this is important primarily -// for determining the proper width of a frame or card -// behind the text. -//////////////////////////////////////////////////////////////////// +/** + * Sets the preserve_trailing_whitespace flag. When this is set, trailing + * whitespace at the end of the line is not stripped when the text is + * wordwrapped (it is stripped by default). Since the trailing whitespace is + * invisible, this is important primarily for determining the proper width of + * a frame or card behind the text. + */ INLINE void TextProperties:: set_preserve_trailing_whitespace(bool preserve_trailing_whitespace) { _preserve_trailing_whitespace = preserve_trailing_whitespace; _specified |= F_has_preserve_trailing_whitespace; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_preserve_trailing_whitespace -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_preserve_trailing_whitespace() { _preserve_trailing_whitespace = false; _specified &= ~F_has_preserve_trailing_whitespace; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_preserve_trailing_whitespace -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_preserve_trailing_whitespace() const { return (_specified & F_has_preserve_trailing_whitespace) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_preserve_trailing_whitespace -// Access: Published -// Description: Returns the preserve_trailing_whitespace flag. See -// set_preserve_trailing_whitespace(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the preserve_trailing_whitespace flag. See + * set_preserve_trailing_whitespace(). + */ INLINE bool TextProperties:: get_preserve_trailing_whitespace() const { return _preserve_trailing_whitespace; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: set_text_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_text_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: set_text_color(const LColor &text_color) { _text_color = text_color; @@ -553,12 +436,10 @@ set_text_color(const LColor &text_color) { _text_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_text_color -// Access: Published -// Description: Removes the text color specification; the text will -// be colored whatever it was in the source font file. -//////////////////////////////////////////////////////////////////// +/** + * Removes the text color specification; the text will be colored whatever it + * was in the source font file. + */ INLINE void TextProperties:: clear_text_color() { _text_color.set(1.0f, 1.0f, 1.0f, 1.0f); @@ -566,41 +447,33 @@ clear_text_color() { _text_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_text_color() const { return (_specified & F_has_text_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_text_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LColor TextProperties:: get_text_color() const { return _text_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: set_shadow_color(PN_stdfloat r, PN_stdfloat g, PN_stdfloat b, PN_stdfloat a) { set_shadow_color(LColor(r, g, b, a)); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: set_shadow_color(const LColor &shadow_color) { _shadow_color = shadow_color; @@ -608,11 +481,9 @@ set_shadow_color(const LColor &shadow_color) { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_shadow_color -// Access: Published -// Description: Removes the shadow color specification. -//////////////////////////////////////////////////////////////////// +/** + * Removes the shadow color specification. + */ INLINE void TextProperties:: clear_shadow_color() { _shadow_color.set(0.0f, 0.0f, 0.0f, 1.0f); @@ -620,97 +491,76 @@ clear_shadow_color() { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_shadow_color() const { return (_specified & F_has_shadow_color) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_shadow_color -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE LColor TextProperties:: get_shadow_color() const { return _shadow_color; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_shadow -// Access: Published -// Description: Specifies that the text should be drawn with a -// shadow, by creating a second copy of the text and -// offsetting it slightly behind the first. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the text should be drawn with a shadow, by creating a second + * copy of the text and offsetting it slightly behind the first. + */ INLINE void TextProperties:: set_shadow(PN_stdfloat xoffset, PN_stdfloat yoffset) { set_shadow(LVecBase2(xoffset, yoffset)); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_shadow -// Access: Published -// Description: Specifies that the text should be drawn with a -// shadow, by creating a second copy of the text and -// offsetting it slightly behind the first. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that the text should be drawn with a shadow, by creating a second + * copy of the text and offsetting it slightly behind the first. + */ INLINE void TextProperties:: set_shadow(const LVecBase2 &shadow_offset) { _shadow_offset = shadow_offset; _specified |= F_has_shadow; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_shadow -// Access: Published -// Description: Specifies that a shadow will not be drawn behind the -// text. -//////////////////////////////////////////////////////////////////// +/** + * Specifies that a shadow will not be drawn behind the text. + */ INLINE void TextProperties:: clear_shadow() { _specified &= ~F_has_shadow; _shadow_offset.set(0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_shadow -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_shadow() const { return (_specified & F_has_shadow) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_shadow -// Access: Published -// Description: Returns the offset of the shadow as set by -// set_shadow(). It is an error to call this if -// has_shadow() is false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the offset of the shadow as set by set_shadow(). It is an error to + * call this if has_shadow() is false. + */ INLINE LVector2 TextProperties:: get_shadow() const { return _shadow_offset; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_bin -// Access: Published -// Description: Names the CullBin that the text geometry should be -// assigned to. If this is set, then a CullBinAttrib -// will be created to explicitly place each component in -// the named bin. -// -// The draw_order value will also be passed to each -// CullBinAttrib as appropriate; this is particularly -// useful if this names a CullBinFixed, e.g. "fixed". -//////////////////////////////////////////////////////////////////// +/** + * Names the CullBin that the text geometry should be assigned to. If this is + * set, then a CullBinAttrib will be created to explicitly place each + * component in the named bin. + * + * The draw_order value will also be passed to each CullBinAttrib as + * appropriate; this is particularly useful if this names a CullBinFixed, e.g. + * "fixed". + */ INLINE void TextProperties:: set_bin(const string &bin) { _bin = bin; @@ -719,14 +569,10 @@ set_bin(const string &bin) { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_bin -// Access: Published -// Description: Removes the effect of a previous call to -// set_bin(). Text will be drawn in whatever bin -// it would like to be drawn in, with no explicit -// ordering. -//////////////////////////////////////////////////////////////////// +/** + * Removes the effect of a previous call to set_bin(). Text will be drawn in + * whatever bin it would like to be drawn in, with no explicit ordering. + */ INLINE void TextProperties:: clear_bin() { _bin = string(); @@ -735,43 +581,35 @@ clear_bin() { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_bin -// Access: Published -// Description: Returns true if an explicit drawing bin has been -// set via set_bin(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an explicit drawing bin has been set via set_bin(), false + * otherwise. + */ INLINE bool TextProperties:: has_bin() const { return (_specified & F_has_bin) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_bin -// Access: Published -// Description: Returns the drawing bin set with set_bin(), or empty -// string if no bin has been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the drawing bin set with set_bin(), or empty string if no bin has + * been set. + */ INLINE const string &TextProperties:: get_bin() const { return _bin; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_draw_order -// Access: Published -// Description: Sets the drawing order of text created by the -// TextNode. This is actually the draw order of the -// card and frame. The shadow is drawn at -// _draw_order+1, and the text at _draw_order+2. -// -// This affects the sorting order assigned to the nodes -// as they are created, and also is passed to whatever -// bin may be assigned via set_bin(). -// -// The return value is the first unused draw_order -// number, e.g. _draw_order + 3. -//////////////////////////////////////////////////////////////////// +/** + * Sets the drawing order of text created by the TextNode. This is actually + * the draw order of the card and frame. The shadow is drawn at + * _draw_order+1, and the text at _draw_order+2. + * + * This affects the sorting order assigned to the nodes as they are created, + * and also is passed to whatever bin may be assigned via set_bin(). + * + * The return value is the first unused draw_order number, e.g. _draw_order + + * 3. + */ INLINE int TextProperties:: set_draw_order(int draw_order) { _draw_order = draw_order; @@ -781,11 +619,9 @@ set_draw_order(int draw_order) { return _draw_order + 3; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_draw_order -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_draw_order() { _draw_order = 1; @@ -794,215 +630,169 @@ clear_draw_order() { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_draw_order -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_draw_order() const { return (_specified & F_has_draw_order) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_draw_order -// Access: Published -// Description: Returns the drawing order set with set_draw_order(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the drawing order set with set_draw_order(). + */ INLINE int TextProperties:: get_draw_order() const { return _draw_order; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_tab_width -// Access: Published -// Description: Sets the width of each tab stop, in screen units. A -// tab character embedded in the text will advance the -// horizontal position to the next tab stop. -//////////////////////////////////////////////////////////////////// +/** + * Sets the width of each tab stop, in screen units. A tab character embedded + * in the text will advance the horizontal position to the next tab stop. + */ INLINE void TextProperties:: set_tab_width(PN_stdfloat tab_width) { _tab_width = tab_width; _specified |= F_has_tab_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_tab_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_tab_width() { _tab_width = text_tab_width; _specified &= ~F_has_tab_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_tab_width -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_tab_width() const { return (_specified & F_has_tab_width) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_tab_width -// Access: Published -// Description: Returns the width set via set_tab_width(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the width set via set_tab_width(). + */ INLINE PN_stdfloat TextProperties:: get_tab_width() const { return _tab_width; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_glyph_scale -// Access: Published -// Description: Specifies the factor by which to scale each letter of -// the text as it is placed, in addition to any scales -// inherited from the node or from set_text_scale(). -// This can be used (possibly in conjunction with -// set_glyph_shift()) to implement superscripting or -// subscripting. -// -// The glyph scale is cumulative when applied to nested -// TextProperties. It is intended primarily for -// implementing superscripts, not for scaling the text -// in general. See also set_text_scale(), which is -// intended primarily for scaling the text in general, -// and is not cumulative. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the factor by which to scale each letter of the text as it is + * placed, in addition to any scales inherited from the node or from + * set_text_scale(). This can be used (possibly in conjunction with + * set_glyph_shift()) to implement superscripting or subscripting. + * + * The glyph scale is cumulative when applied to nested TextProperties. It is + * intended primarily for implementing superscripts, not for scaling the text + * in general. See also set_text_scale(), which is intended primarily for + * scaling the text in general, and is not cumulative. + */ INLINE void TextProperties:: set_glyph_scale(PN_stdfloat glyph_scale) { _glyph_scale = glyph_scale; _specified |= F_has_glyph_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_glyph_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_glyph_scale() { _specified &= ~F_has_glyph_scale; _glyph_scale = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_glyph_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_glyph_scale() const { return (_specified & F_has_glyph_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_glyph_scale -// Access: Published -// Description: Returns the scale factor of each letter as specified -// by set_glyph_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor of each letter as specified by set_glyph_scale(). + */ INLINE PN_stdfloat TextProperties:: get_glyph_scale() const { return _glyph_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_glyph_shift -// Access: Published -// Description: Specifies a vertical amount to shift each letter of -// the text as it is placed. This can be used (possibly -// in conjunction with set_glyph_scale()) to implement -// superscripting or subscripting. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a vertical amount to shift each letter of the text as it is + * placed. This can be used (possibly in conjunction with set_glyph_scale()) + * to implement superscripting or subscripting. + */ INLINE void TextProperties:: set_glyph_shift(PN_stdfloat glyph_shift) { _glyph_shift = glyph_shift; _specified |= F_has_glyph_shift; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_glyph_shift -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_glyph_shift() { _specified &= ~F_has_glyph_shift; _glyph_shift = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_glyph_shift -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_glyph_shift() const { return (_specified & F_has_glyph_shift) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_glyph_shift -// Access: Published -// Description: Returns the vertical shift of each letter as -// specified by set_glyph_shift(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the vertical shift of each letter as specified by + * set_glyph_shift(). + */ INLINE PN_stdfloat TextProperties:: get_glyph_shift() const { return _glyph_shift; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::set_text_scale -// Access: Published -// Description: Specifies the factor by which to scale the text, in -// addition to any scalings imposed by the node, as well -// as in addition to the glyph scale. -// -// The text scale is not cumulative when applied to -// nested TextProperties. See also set_glyph_scale(), -// which is cumulative. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the factor by which to scale the text, in addition to any + * scalings imposed by the node, as well as in addition to the glyph scale. + * + * The text scale is not cumulative when applied to nested TextProperties. + * See also set_glyph_scale(), which is cumulative. + */ INLINE void TextProperties:: set_text_scale(PN_stdfloat text_scale) { _text_scale = text_scale; _specified |= F_has_text_scale; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear_text_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void TextProperties:: clear_text_scale() { _specified &= ~F_has_text_scale; _text_scale = 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::has_text_scale -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool TextProperties:: has_text_scale() const { return (_specified & F_has_text_scale) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_text_scale -// Access: Published -// Description: Returns the scale factor of the text as specified -// by set_text_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor of the text as specified by set_text_scale(). + */ INLINE PN_stdfloat TextProperties:: get_text_scale() const { return _text_scale; diff --git a/panda/src/text/textProperties.cxx b/panda/src/text/textProperties.cxx index 116a4309aa..94b02ffc11 100644 --- a/panda/src/text/textProperties.cxx +++ b/panda/src/text/textProperties.cxx @@ -1,16 +1,15 @@ -// Filename: textProperties.cxx -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textProperties.cxx + * @author drose + * @date 2004-04-06 + */ #include "textProperties.h" #include "config_text.h" @@ -28,11 +27,9 @@ bool TextProperties::_loaded_default_font = false; TypeHandle TextProperties::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextProperties:: TextProperties() { _specified = 0; @@ -56,11 +53,9 @@ TextProperties() { _text_scale = 1.0f; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::Copy Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextProperties:: TextProperties(const TextProperties ©) { (*this) = copy; @@ -68,11 +63,9 @@ TextProperties(const TextProperties ©) { _shadow_state = copy._shadow_state; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::Copy Assignment Operator -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextProperties:: operator = (const TextProperties ©) { _specified = copy._specified; @@ -101,11 +94,9 @@ operator = (const TextProperties ©) { _shadow_state.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TextProperties:: operator == (const TextProperties &other) const { if (_specified != other._specified) { @@ -175,25 +166,19 @@ operator == (const TextProperties &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::clear -// Access: Published -// Description: Unsets all properties that have been specified so -// far, and resets the TextProperties structure to its -// initial empty state. -//////////////////////////////////////////////////////////////////// +/** + * Unsets all properties that have been specified so far, and resets the + * TextProperties structure to its initial empty state. + */ void TextProperties:: clear() { (*this) = TextProperties(); } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::add_properties -// Access: Published -// Description: Sets any properties that are explicitly specified in -// other on this object. Leaves other properties -// unchanged. -//////////////////////////////////////////////////////////////////// +/** + * Sets any properties that are explicitly specified in other on this object. + * Leaves other properties unchanged. + */ void TextProperties:: add_properties(const TextProperties &other) { if (other.has_font()) { @@ -240,9 +225,9 @@ add_properties(const TextProperties &other) { set_tab_width(other.get_tab_width()); } - // The glyph scale and shift are a special case: rather than - // replacing the previous value, they modify it, so that they apply - // cumulatively to nested TextProperties. + // The glyph scale and shift are a special case: rather than replacing the + // previous value, they modify it, so that they apply cumulatively to nested + // TextProperties. if (other.has_glyph_shift()) { set_glyph_shift(other.get_glyph_shift() * get_glyph_scale() + get_glyph_shift()); } @@ -256,11 +241,9 @@ add_properties(const TextProperties &other) { } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextProperties:: write(ostream &out, int indent_level) const { if (!is_any_specified()) { @@ -304,11 +287,11 @@ write(ostream &out, int indent_level) const { case A_left: out << "A_left\n"; break; - + case A_right: out << "A_right\n"; break; - + case A_center: out << "A_center\n"; break; @@ -316,11 +299,11 @@ write(ostream &out, int indent_level) const { case A_boxed_left: out << "A_boxed_left\n"; break; - + case A_boxed_right: out << "A_boxed_right\n"; break; - + case A_boxed_center: out << "A_boxed_center\n"; break; @@ -380,12 +363,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_text_state -// Access: Public -// Description: Returns a RenderState object suitable for rendering -// text with these properties. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState object suitable for rendering text with these + * properties. + */ const RenderState *TextProperties:: get_text_state() const { if (!_text_state.is_null()) { @@ -409,12 +390,10 @@ get_text_state() const { return _text_state; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::get_shadow_state -// Access: Public -// Description: Returns a RenderState object suitable for rendering -// the shadow of this text with these properties. -//////////////////////////////////////////////////////////////////// +/** + * Returns a RenderState object suitable for rendering the shadow of this text + * with these properties. + */ const RenderState *TextProperties:: get_shadow_state() const { if (!_shadow_state.is_null()) { @@ -436,16 +415,12 @@ get_shadow_state() const { return _shadow_state; } -//////////////////////////////////////////////////////////////////// -// Function: TextProperties::load_default_font -// Access: Private, Static -// Description: This function is called once (or never), the first -// time someone attempts to render a TextNode using the -// default font. It should attempt to load the default -// font, using the compiled-in version if it is -// available, or whatever system file may be named in -// Configrc. -//////////////////////////////////////////////////////////////////// +/** + * This function is called once (or never), the first time someone attempts to + * render a TextNode using the default font. It should attempt to load the + * default font, using the compiled-in version if it is available, or whatever + * system file may be named in Configrc. + */ void TextProperties:: load_default_font() { _loaded_default_font = true; @@ -462,26 +437,25 @@ load_default_font() { #ifdef COMPILE_IN_DEFAULT_FONT #ifdef HAVE_FREETYPE // Loading the compiled-in FreeType font is relatively easy. - _default_font = new DynamicTextFont((const char *)default_font_data, + _default_font = new DynamicTextFont((const char *)default_font_data, default_font_size, 0); // The compiled-in font seems to confuse FreeType about its winding order. ((DynamicTextFont *)_default_font.p())->set_winding_order(DynamicTextFont::WO_left); #else - // The compiled-in Bam font requires creating a BamFile object to - // decode it. + // The compiled-in Bam font requires creating a BamFile object to decode it. string data((const char *)default_font_data, default_font_size); #ifdef HAVE_ZLIB // The font data is stored compressed; decompress it on-the-fly. istringstream inz(data); IDecompressStream in(&inz, false); - + #else // The font data is stored uncompressed, so just load it. istringstream in(data); #endif // HAVE_ZLIB - + BamFile bam_file; if (bam_file.open_read(in, "default font stream")) { PT(PandaNode) node = bam_file.read_node(); @@ -489,7 +463,7 @@ load_default_font() { _default_font = new StaticTextFont(node); } } - + #endif // HAVE_FREETYPE #endif // COMPILE_IN_DEFAULT_FONT } diff --git a/panda/src/text/textProperties.h b/panda/src/text/textProperties.h index bb27aa49e3..c320e9a37b 100644 --- a/panda/src/text/textProperties.h +++ b/panda/src/text/textProperties.h @@ -1,16 +1,15 @@ -// Filename: textProperties.h -// Created by: drose (06Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textProperties.h + * @author drose + * @date 2004-04-06 + */ #ifndef TEXTPROPERTIES_H #define TEXTPROPERTIES_H @@ -23,27 +22,22 @@ #include "pointerTo.h" #include "renderState.h" -//////////////////////////////////////////////////////////////////// -// Class : TextProperties -// Description : This defines the set of visual properties that may be -// assigned to the individual characters of the text. -// (Properties which affect the overall block of text -// can only be specified on the TextNode directly). -// -// Typically, there is just one set of properties on a -// given block of text, which is set directly on the -// TextNode (TextNode inherits from TextProperties). -// That makes all of the text within a particular block -// have the same appearance. -// -// This separate class exists in order to implement -// multiple different kinds of text appearing within one -// block. The text string itself may reference a -// TextProperties structure by name using the \1 and \2 -// tokens embedded within the string; each nested -// TextProperties structure modifies the appearance of -// subsequent text within the block. -//////////////////////////////////////////////////////////////////// +/** + * This defines the set of visual properties that may be assigned to the + * individual characters of the text. (Properties which affect the overall + * block of text can only be specified on the TextNode directly). + * + * Typically, there is just one set of properties on a given block of text, + * which is set directly on the TextNode (TextNode inherits from + * TextProperties). That makes all of the text within a particular block have + * the same appearance. + * + * This separate class exists in order to implement multiple different kinds + * of text appearing within one block. The text string itself may reference a + * TextProperties structure by name using the \1 and \2 tokens embedded within + * the string; each nested TextProperties structure modifies the appearance of + * subsequent text within the block. + */ class EXPCL_PANDA_TEXT TextProperties { PUBLISHED: enum Alignment { diff --git a/panda/src/text/textPropertiesManager.I b/panda/src/text/textPropertiesManager.I index a210a855aa..c823eb01ad 100644 --- a/panda/src/text/textPropertiesManager.I +++ b/panda/src/text/textPropertiesManager.I @@ -1,14 +1,12 @@ -// Filename: textPropertiesManager.I -// Created by: drose (07Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textPropertiesManager.I + * @author drose + * @date 2004-04-07 + */ diff --git a/panda/src/text/textPropertiesManager.cxx b/panda/src/text/textPropertiesManager.cxx index 1ca6b0ad3d..2d8c93fd32 100644 --- a/panda/src/text/textPropertiesManager.cxx +++ b/panda/src/text/textPropertiesManager.cxx @@ -1,74 +1,61 @@ -// Filename: textPropertiesManager.cxx -// Created by: drose (07Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textPropertiesManager.cxx + * @author drose + * @date 2004-04-07 + */ #include "textPropertiesManager.h" #include "indent.h" TextPropertiesManager *TextPropertiesManager::_global_ptr = (TextPropertiesManager *)NULL; -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::Constructor -// Access: Protected -// Description: The constructor is not intended to be called -// directly; there is only one TextPropertiesManager and -// it constructs itself. This could have been a private -// constructor, but gcc issues a spurious warning if the -// constructor is private and the class has no friends. -//////////////////////////////////////////////////////////////////// +/** + * The constructor is not intended to be called directly; there is only one + * TextPropertiesManager and it constructs itself. This could have been a + * private constructor, but gcc issues a spurious warning if the constructor + * is private and the class has no friends. + */ TextPropertiesManager:: TextPropertiesManager() { } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::Destructor -// Access: Protected -// Description: Don't call the destructor. -//////////////////////////////////////////////////////////////////// +/** + * Don't call the destructor. + */ TextPropertiesManager:: ~TextPropertiesManager() { } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::set_properties -// Access: Published -// Description: Defines the TextProperties associated with the -// indicated name. When the name is subsequently -// encountered in text embedded between \1 characters in -// a TextNode string, the following text will be -// rendered with these properties. -// -// If there was already a TextProperties structure -// associated with this name, it is quietly replaced -// with the new definition. -//////////////////////////////////////////////////////////////////// +/** + * Defines the TextProperties associated with the indicated name. When the + * name is subsequently encountered in text embedded between \1 characters in + * a TextNode string, the following text will be rendered with these + * properties. + * + * If there was already a TextProperties structure associated with this name, + * it is quietly replaced with the new definition. + */ void TextPropertiesManager:: set_properties(const string &name, const TextProperties &properties) { _properties[name] = properties; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::get_properties -// Access: Published -// Description: Returns the TextProperties associated with the -// indicated name. If there was not previously a -// TextProperties associated with this name, a warning -// is printed and then a default TextProperties -// structure is associated with the name, and returned. -// -// Call has_properties() instead to check whether a -// particular name has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextProperties associated with the indicated name. If there + * was not previously a TextProperties associated with this name, a warning is + * printed and then a default TextProperties structure is associated with the + * name, and returned. + * + * Call has_properties() instead to check whether a particular name has been + * defined. + */ TextProperties TextPropertiesManager:: get_properties(const string &name) { Properties::const_iterator pi; @@ -85,17 +72,13 @@ get_properties(const string &name) { return default_properties; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::has_properties -// Access: Published -// Description: Returns true if a TextProperties structure has been -// associated with the indicated name, false otherwise. -// Normally this means set_properties() has been called -// with this name, but because get_properties() will -// implicitly create a default TextProperties structure, -// it may also mean simply that get_properties() has -// been called with the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a TextProperties structure has been associated with the + * indicated name, false otherwise. Normally this means set_properties() has + * been called with this name, but because get_properties() will implicitly + * create a default TextProperties structure, it may also mean simply that + * get_properties() has been called with the indicated name. + */ bool TextPropertiesManager:: has_properties(const string &name) const { Properties::const_iterator pi; @@ -103,71 +86,57 @@ has_properties(const string &name) const { return (pi != _properties.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::clear_properties -// Access: Published -// Description: Removes the named TextProperties structure from the -// manager. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named TextProperties structure from the manager. + */ void TextPropertiesManager:: clear_properties(const string &name) { _properties.erase(name); } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::set_graphic -// Access: Published -// Description: Defines the TextGraphic associated with the -// indicated name. When the name is subsequently -// encountered in text embedded between \5 characters in -// a TextNode string, the specified graphic will be -// embedded in the text at that point. -// -// If there was already a TextGraphic structure -// associated with this name, it is quietly replaced -// with the new definition. -//////////////////////////////////////////////////////////////////// +/** + * Defines the TextGraphic associated with the indicated name. When the name + * is subsequently encountered in text embedded between \5 characters in a + * TextNode string, the specified graphic will be embedded in the text at that + * point. + * + * If there was already a TextGraphic structure associated with this name, it + * is quietly replaced with the new definition. + */ void TextPropertiesManager:: set_graphic(const string &name, const TextGraphic &graphic) { _graphics[name] = graphic; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::set_graphic -// Access: Published -// Description: This flavor of set_graphic implicitly creates a frame -// for the model using the model's actual computed -// bounding volume, as derived from -// NodePath::calc_tight_bounds(). Create a TextGraphic -// object first if you want to have explicit control of -// the frame. -//////////////////////////////////////////////////////////////////// +/** + * This flavor of set_graphic implicitly creates a frame for the model using + * the model's actual computed bounding volume, as derived from + * NodePath::calc_tight_bounds(). Create a TextGraphic object first if you + * want to have explicit control of the frame. + */ void TextPropertiesManager:: set_graphic(const string &name, const NodePath &model) { LPoint3 min_point, max_point; model.calc_tight_bounds(min_point, max_point); - TextGraphic graphic(model, + TextGraphic graphic(model, min_point.dot(LVector3::right()), max_point.dot(LVector3::right()), - min_point.dot(LVector3::up()), + min_point.dot(LVector3::up()), max_point.dot(LVector3::up())); _graphics[name] = graphic; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::get_graphic -// Access: Published -// Description: Returns the TextGraphic associated with the -// indicated name. If there was not previously a -// TextGraphic associated with this name, a warning -// is printed and then a default TextGraphic -// structure is associated with the name, and returned. -// -// Call has_graphic() instead to check whether a -// particular name has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextGraphic associated with the indicated name. If there was + * not previously a TextGraphic associated with this name, a warning is + * printed and then a default TextGraphic structure is associated with the + * name, and returned. + * + * Call has_graphic() instead to check whether a particular name has been + * defined. + */ TextGraphic TextPropertiesManager:: get_graphic(const string &name) { Graphics::const_iterator pi; @@ -184,17 +153,13 @@ get_graphic(const string &name) { return default_graphic; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::has_graphic -// Access: Published -// Description: Returns true if a TextGraphic structure has been -// associated with the indicated name, false otherwise. -// Normally this means set_graphic() has been called -// with this name, but because get_graphic() will -// implicitly create a default TextGraphic structure, -// it may also mean simply that get_graphic() has -// been called with the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a TextGraphic structure has been associated with the + * indicated name, false otherwise. Normally this means set_graphic() has + * been called with this name, but because get_graphic() will implicitly + * create a default TextGraphic structure, it may also mean simply that + * get_graphic() has been called with the indicated name. + */ bool TextPropertiesManager:: has_graphic(const string &name) const { Graphics::const_iterator pi; @@ -202,22 +167,17 @@ has_graphic(const string &name) const { return (pi != _graphics.end()); } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::clear_graphic -// Access: Published -// Description: Removes the named TextGraphic structure from the -// manager. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named TextGraphic structure from the manager. + */ void TextPropertiesManager:: clear_graphic(const string &name) { _graphics.erase(name); } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextPropertiesManager:: write(ostream &out, int indent_level) const { Properties::const_iterator pi; @@ -228,12 +188,9 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::get_global_ptr -// Access: Published, Static -// Description: Returns the pointer to the global TextPropertiesManager -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the global TextPropertiesManager object. + */ TextPropertiesManager *TextPropertiesManager:: get_global_ptr() { if (_global_ptr == (TextPropertiesManager *)NULL) { @@ -242,13 +199,10 @@ get_global_ptr() { return _global_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::get_properties_ptr -// Access: Public -// Description: Returns a pointer to the TextProperties with the -// indicated name, or NULL if there is no properties -// with that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the TextProperties with the indicated name, or NULL if + * there is no properties with that name. + */ const TextProperties *TextPropertiesManager:: get_properties_ptr(const string &name) { Properties::const_iterator pi; @@ -259,13 +213,10 @@ get_properties_ptr(const string &name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextPropertiesManager::get_graphic_ptr -// Access: Public -// Description: Returns a pointer to the TextGraphic with the -// indicated name, or NULL if there is no graphic -// with that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the TextGraphic with the indicated name, or NULL if + * there is no graphic with that name. + */ const TextGraphic *TextPropertiesManager:: get_graphic_ptr(const string &name) { Graphics::const_iterator pi; diff --git a/panda/src/text/textPropertiesManager.h b/panda/src/text/textPropertiesManager.h index 40bee8bbd5..2c4f6b3c84 100644 --- a/panda/src/text/textPropertiesManager.h +++ b/panda/src/text/textPropertiesManager.h @@ -1,16 +1,15 @@ -// Filename: textPropertiesManager.h -// Created by: drose (07Apr04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textPropertiesManager.h + * @author drose + * @date 2004-04-07 + */ #ifndef TEXTPROPERTIESMANAGER_H #define TEXTPROPERTIESMANAGER_H @@ -21,35 +20,27 @@ #include "textProperties.h" #include "textGraphic.h" -//////////////////////////////////////////////////////////////////// -// Class : TextPropertiesManager -// Description : This defines all of the TextProperties structures -// that might be referenced by name from an embedded -// text string. -// -// A text string, as rendered by a TextNode, can contain -// embedded references to one of the TextProperties -// defined here, by enclosing the name between \1 (ASCII -// 0x01) characters; this causes a "push" to the named -// state. All text following the closing \1 character -// will then be rendered in the new state. The next \2 -// (ASCII 0x02) character will then restore the previous -// state for subsequent text. -// -// For instance, "x\1up\1n\2 + y" indicates that the -// character "x" will be rendered in the normal state, -// the character "n" will be rendered in the "up" state, -// and then " + y" will be rendered in the normal state -// again. -// -// This can also be used to define arbitrary models that -// can serve as embedded graphic images in a text -// paragraph. This works similarly; the convention is -// to create a TextGraphic that describes the graphic -// image, and then associate it here via the -// set_graphic() call. Then "\5name\5" will embed the -// named graphic. -//////////////////////////////////////////////////////////////////// +/** + * This defines all of the TextProperties structures that might be referenced + * by name from an embedded text string. + * + * A text string, as rendered by a TextNode, can contain embedded references + * to one of the TextProperties defined here, by enclosing the name between \1 + * (ASCII 0x01) characters; this causes a "push" to the named state. All text + * following the closing \1 character will then be rendered in the new state. + * The next \2 (ASCII 0x02) character will then restore the previous state for + * subsequent text. + * + * For instance, "x\1up\1n\2 + y" indicates that the character "x" will be + * rendered in the normal state, the character "n" will be rendered in the + * "up" state, and then " + y" will be rendered in the normal state again. + * + * This can also be used to define arbitrary models that can serve as embedded + * graphic images in a text paragraph. This works similarly; the convention + * is to create a TextGraphic that describes the graphic image, and then + * associate it here via the set_graphic() call. Then "\5name\5" will embed + * the named graphic. + */ class EXPCL_PANDA_TEXT TextPropertiesManager { protected: TextPropertiesManager(); diff --git a/panda/src/tform/buttonThrower.I b/panda/src/tform/buttonThrower.I index b5aa817858..22832bc933 100644 --- a/panda/src/tform/buttonThrower.I +++ b/panda/src/tform/buttonThrower.I @@ -1,395 +1,310 @@ -// Filename: buttonThrower.I -// Created by: drose (26Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonThrower.I + * @author drose + * @date 2003-12-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_button_down_event -// Access: Published -// Description: Specifies the generic event that is generated (if -// any) each time a key or button is depressed. Unlike -// the specific events that are unique to each key, this -// same event name is used for *all* button events, and -// the name of the button pressed (possibly with -// modifier prefixes) will be sent as a parameter. -// -// If this string is empty, no event is generated. It -// is possible to generate both generic events and -// specific events for the same button. -// -// See also set_keystroke_event(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the generic event that is generated (if any) each time a key or + * button is depressed. Unlike the specific events that are unique to each + * key, this same event name is used for *all* button events, and the name of + * the button pressed (possibly with modifier prefixes) will be sent as a + * parameter. + * + * If this string is empty, no event is generated. It is possible to generate + * both generic events and specific events for the same button. + * + * See also set_keystroke_event(). + */ INLINE void ButtonThrower:: set_button_down_event(const string &button_down_event) { _button_down_event = button_down_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_button_down_event -// Access: Published -// Description: Returns the button_down_event that has been set on -// this ButtonThrower. See set_button_down_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the button_down_event that has been set on this ButtonThrower. See + * set_button_down_event(). + */ INLINE const string &ButtonThrower:: get_button_down_event() const { return _button_down_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_button_up_event -// Access: Published -// Description: Specifies the generic event that is generated (if -// any) each time a key or button is released. See -// set_button_down_event(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the generic event that is generated (if any) each time a key or + * button is released. See set_button_down_event(). + */ INLINE void ButtonThrower:: set_button_up_event(const string &button_up_event) { _button_up_event = button_up_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_button_up_event -// Access: Published -// Description: Returns the button_up_event that has been set on -// this ButtonThrower. See set_button_up_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the button_up_event that has been set on this ButtonThrower. See + * set_button_up_event(). + */ INLINE const string &ButtonThrower:: get_button_up_event() const { return _button_up_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_button_repeat_event -// Access: Published -// Description: Specifies the generic event that is generated (if -// any) repeatedly while a key or button is held down. -// Unlike the specific events that are unique to each -// key, this same event name is used for *all* button -// events, and the name of the button pressed (possibly -// with modifier prefixes) will be sent as a parameter. -// -// If this string is empty, no event is generated. It -// is possible to generate both generic events and -// specific events for the same button. -// -// See also set_keystroke_event(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the generic event that is generated (if any) repeatedly while a + * key or button is held down. Unlike the specific events that are unique to + * each key, this same event name is used for *all* button events, and the + * name of the button pressed (possibly with modifier prefixes) will be sent + * as a parameter. + * + * If this string is empty, no event is generated. It is possible to generate + * both generic events and specific events for the same button. + * + * See also set_keystroke_event(). + */ INLINE void ButtonThrower:: set_button_repeat_event(const string &button_repeat_event) { _button_repeat_event = button_repeat_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_button_repeat_event -// Access: Published -// Description: Returns the button_repeat_event that has been set on -// this ButtonThrower. See set_button_repeat_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the button_repeat_event that has been set on this ButtonThrower. + * See set_button_repeat_event(). + */ INLINE const string &ButtonThrower:: get_button_repeat_event() const { return _button_repeat_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_keystroke_event -// Access: Published -// Description: Specifies the event that is generated (if any) for -// each keystroke that is received. A keystroke is -// different than a button event: it represents the -// semantic meaning of the sequence of keys that have -// been pressed. For instance, pressing shift and 4 -// together will generate the button event "shift-4", -// but it will generate the keystroke "$". -// -// If a key is held down, keyrepeat will cause the same -// keystroke event to be generated repeatedly. This is -// different from the corresponding down event, which -// will only be generated once, followed by a number of -// button repeat events. -// -// This event is generated with a single wstring -// parameter, which is a one-character string that -// contains the keystroke generated. If this event -// string is empty, no event is generated. -// -// See also set_button_down_event(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the event that is generated (if any) for each keystroke that is + * received. A keystroke is different than a button event: it represents the + * semantic meaning of the sequence of keys that have been pressed. For + * instance, pressing shift and 4 together will generate the button event + * "shift-4", but it will generate the keystroke "$". + * + * If a key is held down, keyrepeat will cause the same keystroke event to be + * generated repeatedly. This is different from the corresponding down event, + * which will only be generated once, followed by a number of button repeat + * events. + * + * This event is generated with a single wstring parameter, which is a one- + * character string that contains the keystroke generated. If this event + * string is empty, no event is generated. + * + * See also set_button_down_event(). + */ INLINE void ButtonThrower:: set_keystroke_event(const string &keystroke_event) { _keystroke_event = keystroke_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_keystroke_event -// Access: Published -// Description: Returns the keystroke_event that has been set on this -// ButtonThrower. See set_keystroke_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the keystroke_event that has been set on this ButtonThrower. See + * set_keystroke_event(). + */ INLINE const string &ButtonThrower:: get_keystroke_event() const { return _keystroke_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_candidate_event -// Access: Published -// Description: Specifies the event that is generated (if any) for -// each IME candidate string event received. Events of -// this nature are received only when the user is -// entering data using a Microsoft Input Method Editor, -// typically used for Asian languages such as Japanese -// or Korean. -// -// If you are designing a typing user interface, you -// should track this event to support the use of the -// IME. In response to this event, you should display -// the candidate string in the entry box, with the -// appropriate sections highlighted, so the user can -// scroll through the available choices. -// -// This event is generated with four parameters, in -// order: the candidate string, the character at which -// to start the highlight, the character at which to end -// the highlight, and the current cursor position. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the event that is generated (if any) for each IME candidate + * string event received. Events of this nature are received only when the + * user is entering data using a Microsoft Input Method Editor, typically used + * for Asian languages such as Japanese or Korean. + * + * If you are designing a typing user interface, you should track this event + * to support the use of the IME. In response to this event, you should + * display the candidate string in the entry box, with the appropriate + * sections highlighted, so the user can scroll through the available choices. + * + * This event is generated with four parameters, in order: the candidate + * string, the character at which to start the highlight, the character at + * which to end the highlight, and the current cursor position. + */ INLINE void ButtonThrower:: set_candidate_event(const string &candidate_event) { _candidate_event = candidate_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_candidate_event -// Access: Published -// Description: Returns the candidate_event that has been set on this -// ButtonThrower. See set_candidate_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the candidate_event that has been set on this ButtonThrower. See + * set_candidate_event(). + */ INLINE const string &ButtonThrower:: get_candidate_event() const { return _candidate_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_move_event -// Access: Published -// Description: Specifies the event that is generated (if any) each -// time the mouse is moved within the window. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the event that is generated (if any) each time the mouse is moved + * within the window. + */ INLINE void ButtonThrower:: set_move_event(const string &move_event) { _move_event = move_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_move_event -// Access: Published -// Description: Returns the move_event that has been set on this -// ButtonThrower. See set_move_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the move_event that has been set on this ButtonThrower. See + * set_move_event(). + */ INLINE const string &ButtonThrower:: get_move_event() const { return _move_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_raw_button_down_event -// Access: Published -// Description: Like set_button_down_event, but uses the raw, -// untransformed scan key from the operating system. -// This uses buttons that are independent of the -// user's selected keyboard layout. -//////////////////////////////////////////////////////////////////// +/** + * Like set_button_down_event, but uses the raw, untransformed scan key from + * the operating system. This uses buttons that are independent of the user's + * selected keyboard layout. + */ INLINE void ButtonThrower:: set_raw_button_down_event(const string &raw_button_down_event) { _raw_button_down_event = raw_button_down_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_raw_button_down_event -// Access: Published -// Description: Returns the raw_button_down_event that has been set on -// this ButtonThrower. See set_raw_button_down_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the raw_button_down_event that has been set on this ButtonThrower. + * See set_raw_button_down_event(). + */ INLINE const string &ButtonThrower:: get_raw_button_down_event() const { return _raw_button_down_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_raw_button_up_event -// Access: Published -// Description: Specifies the generic event that is generated (if -// any) each time a key or button is released. See -// set_raw_button_down_event(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the generic event that is generated (if any) each time a key or + * button is released. See set_raw_button_down_event(). + */ INLINE void ButtonThrower:: set_raw_button_up_event(const string &raw_button_up_event) { _raw_button_up_event = raw_button_up_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_raw_button_up_event -// Access: Published -// Description: Returns the raw_button_up_event that has been set on -// this ButtonThrower. See set_raw_button_up_event(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the raw_button_up_event that has been set on this ButtonThrower. + * See set_raw_button_up_event(). + */ INLINE const string &ButtonThrower:: get_raw_button_up_event() const { return _raw_button_up_event; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_prefix -// Access: Published -// Description: Sets the prefix which is prepended to all specific -// event names (that is, event names generated from the -// button name itself, as opposed to the generic event -// names like set_button_down_event) thrown by this -// object. -//////////////////////////////////////////////////////////////////// +/** + * Sets the prefix which is prepended to all specific event names (that is, + * event names generated from the button name itself, as opposed to the + * generic event names like set_button_down_event) thrown by this object. + */ INLINE void ButtonThrower:: set_prefix(const string &prefix) { _prefix = prefix; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_prefix -// Access: Published -// Description: Returns the prefix that has been set on this -// ButtonThrower. See set_prefix(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the prefix that has been set on this ButtonThrower. See + * set_prefix(). + */ INLINE const string &ButtonThrower:: get_prefix() const { return _prefix; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_specific_flag -// Access: Published -// Description: Sets the flag that indicates whether specific events -// (events prefixed by set_prefix, and based on the -// event name) should be generated at all. This is true -// by default, but may be disabled if you are only -// interested in the generic events (for instance, -// events like set_button_down_event). -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether specific events (events prefixed by + * set_prefix, and based on the event name) should be generated at all. This + * is true by default, but may be disabled if you are only interested in the + * generic events (for instance, events like set_button_down_event). + */ INLINE void ButtonThrower:: set_specific_flag(bool specific_flag) { _specific_flag = specific_flag; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_specific_flag -// Access: Published -// Description: Returns the flag that indicates whether specific -// events should be generated. See set_specific_flag(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether specific events should be + * generated. See set_specific_flag(). + */ INLINE bool ButtonThrower:: get_specific_flag() const { return _specific_flag; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_time_flag -// Access: Published -// Description: Sets the flag that indicates whether the time of the -// button event should be passed as a parameter or not. -// When this is true, an additional parameter is -// generated on each event (before all the parameters -// named by add_parameter) that consists of a single -// double value, and reflects the time the button was -// pressed or released, as a value from -// ClockObject::get_global_clock(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the time of the button event should be + * passed as a parameter or not. When this is true, an additional parameter + * is generated on each event (before all the parameters named by + * add_parameter) that consists of a single double value, and reflects the + * time the button was pressed or released, as a value from + * ClockObject::get_global_clock(). + */ INLINE void ButtonThrower:: set_time_flag(bool time_flag) { _time_flag = time_flag; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_time_flag -// Access: Published -// Description: Returns the flag that indicates whether the time of -// the button event should be passed as a parameter. -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether the time of the button event should + * be passed as a parameter. + */ INLINE bool ButtonThrower:: get_time_flag() const { return _time_flag; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_modifier_buttons -// Access: Published -// Description: Returns the set of ModifierButtons that the -// ButtonThrower will consider important enough to -// prepend the event name with. Normally, this set will -// be empty, and the ButtonThrower will therefore ignore -// all ModifierButtons attached to the key events, but -// if one or more buttons have been added to this set, -// and those modifier buttons are set on the button -// event, then the event name will be prepended with the -// names of the modifier buttons. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of ModifierButtons that the ButtonThrower will consider + * important enough to prepend the event name with. Normally, this set will + * be empty, and the ButtonThrower will therefore ignore all ModifierButtons + * attached to the key events, but if one or more buttons have been added to + * this set, and those modifier buttons are set on the button event, then the + * event name will be prepended with the names of the modifier buttons. + */ INLINE const ModifierButtons &ButtonThrower:: get_modifier_buttons() const { return _mods; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_modifier_buttons -// Access: Published -// Description: Changes the set of ModifierButtons that the -// ButtonThrower will consider important enough to -// prepend the event name with. Normally, this set will -// be empty, and the ButtonThrower will therefore ignore -// all ModifierButtons attached to the key events, but -// if one or more buttons have been added to this set, -// then the event name will be prepended with the names -// of the modifier buttons. -// -// It is recommended that you change this setting by -// first calling get_modifier_buttons(), making -// adjustments, and passing the new value to -// set_modifier_buttons(). This way the current state -// of the modifier buttons will not be lost. -//////////////////////////////////////////////////////////////////// +/** + * Changes the set of ModifierButtons that the ButtonThrower will consider + * important enough to prepend the event name with. Normally, this set will + * be empty, and the ButtonThrower will therefore ignore all ModifierButtons + * attached to the key events, but if one or more buttons have been added to + * this set, then the event name will be prepended with the names of the + * modifier buttons. + * + * It is recommended that you change this setting by first calling + * get_modifier_buttons(), making adjustments, and passing the new value to + * set_modifier_buttons(). This way the current state of the modifier buttons + * will not be lost. + */ INLINE void ButtonThrower:: set_modifier_buttons(const ModifierButtons &mods) { _mods = mods; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::set_throw_buttons_active -// Access: Published -// Description: Sets the flag that indicates whether the -// ButtonThrower will only process events for the -// explicitly named buttons or not. Normally this is -// false, meaning all buttons are processed; set it true -// to indicate that only some buttons should be -// processed. See add_throw_button(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the ButtonThrower will only process + * events for the explicitly named buttons or not. Normally this is false, + * meaning all buttons are processed; set it true to indicate that only some + * buttons should be processed. See add_throw_button(). + */ INLINE void ButtonThrower:: set_throw_buttons_active(bool flag) { _throw_buttons_active = flag; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_throw_buttons_active -// Access: Published -// Description: Returns the flag that indicates whether the -// ButtonThrower will only process events for the -// explicitly named buttons or not. See -// set_throw_buttons_active(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the flag that indicates whether the ButtonThrower will only process + * events for the explicitly named buttons or not. See + * set_throw_buttons_active(). + */ INLINE bool ButtonThrower:: get_throw_buttons_active() const { return _throw_buttons_active; diff --git a/panda/src/tform/buttonThrower.cxx b/panda/src/tform/buttonThrower.cxx index 4d52caebcd..33c7150fb1 100644 --- a/panda/src/tform/buttonThrower.cxx +++ b/panda/src/tform/buttonThrower.cxx @@ -1,16 +1,15 @@ -// Filename: buttonThrower.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonThrower.cxx + * @author drose + * @date 2002-03-12 + */ #include "buttonThrower.h" @@ -25,11 +24,9 @@ TypeHandle ButtonThrower::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonThrower:: ButtonThrower(const string &name) : DataNode(name) @@ -44,80 +41,65 @@ ButtonThrower(const string &name) : _throw_buttons_active = false; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ButtonThrower:: ~ButtonThrower() { } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::add_parameter -// Access: Public -// Description: Adds the indicated parameter to the list of -// parameters that will be passed with each event -// generated by this ButtonThrower. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated parameter to the list of parameters that will be passed + * with each event generated by this ButtonThrower. + */ void ButtonThrower:: add_parameter(const EventParameter &obj) { _parameters.push_back(obj); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_num_parameters -// Access: Public -// Description: Returns the number of parameters that have been added -// to the list of parameters to be passed with each -// event generated by this ButtonThrower. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of parameters that have been added to the list of + * parameters to be passed with each event generated by this ButtonThrower. + */ int ButtonThrower:: get_num_parameters() const { return _parameters.size(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::get_parameter -// Access: Public -// Description: Returns the nth parameter that has been added to the -// list of parameters passed with each event generated -// by this ButtonThrower. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth parameter that has been added to the list of parameters + * passed with each event generated by this ButtonThrower. + */ EventParameter ButtonThrower:: get_parameter(int n) const { nassertr(n >= 0 && n < (int)_parameters.size(), EventParameter(0)); return _parameters[n]; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::add_throw_button -// Access: Published -// Description: Adds a new button to the set of buttons that the -// ButtonThrower explicitly processes. -// -// If set_throw_buttons_active is false (which is the -// default), the ButtonThrower will process all buttons. -// Otherwise, the ButtonThrower will only process events -// for the button(s) explicitly named by this function; -// buttons not on the list will be ignored by this -// object and passed on downstream to the child node(s) -// in the data graph. A button that *is* on the list -// will be processed by the ButtonThrower and not passed -// on to the child node(s). -// -// The return value is true if the button is added, or -// false if it was already in the set. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new button to the set of buttons that the ButtonThrower explicitly + * processes. + * + * If set_throw_buttons_active is false (which is the default), the + * ButtonThrower will process all buttons. Otherwise, the ButtonThrower will + * only process events for the button(s) explicitly named by this function; + * buttons not on the list will be ignored by this object and passed on + * downstream to the child node(s) in the data graph. A button that *is* on + * the list will be processed by the ButtonThrower and not passed on to the + * child node(s). + * + * The return value is true if the button is added, or false if it was already + * in the set. + */ bool ButtonThrower:: add_throw_button(const ModifierButtons &mods, const ButtonHandle &button) { ThrowButtonDef &def = _throw_buttons[button]; - // This is a vector of ModifierButtons for which the indicated - // button is handled. Make sure the current ModifierButtons object - // is not already on the list. + // This is a vector of ModifierButtons for which the indicated button is + // handled. Make sure the current ModifierButtons object is not already on + // the list. ThrowButtonDef::iterator di; for (di = def.begin(); di != def.end(); ++di) { if (mods.matches(*di)) { @@ -129,16 +111,13 @@ add_throw_button(const ModifierButtons &mods, const ButtonHandle &button) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::remove_throw_button -// Access: Published -// Description: Removes the indicated button from the set of buttons -// that the ButtonThrower explicitly processes. See -// add_throw_button(). -// -// The return value is true if the button is removed, or -// false if it was not on the set. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated button from the set of buttons that the ButtonThrower + * explicitly processes. See add_throw_button(). + * + * The return value is true if the button is removed, or false if it was not + * on the set. + */ bool ButtonThrower:: remove_throw_button(const ModifierButtons &mods, const ButtonHandle &button) { ThrowButtons::iterator ti = _throw_buttons.find(button); @@ -149,8 +128,8 @@ remove_throw_button(const ModifierButtons &mods, const ButtonHandle &button) { ThrowButtonDef &def = (*ti).second; - // This is a vector of ModifierButtons for which the indicated - // button is handled. + // This is a vector of ModifierButtons for which the indicated button is + // handled. ThrowButtonDef::iterator di; for (di = def.begin(); di != def.end(); ++di) { if (mods.matches(*di)) { @@ -162,18 +141,14 @@ remove_throw_button(const ModifierButtons &mods, const ButtonHandle &button) { } } - // The indicated ModifierButtons are not applied to this button in - // the set. + // The indicated ModifierButtons are not applied to this button in the set. return false; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::has_throw_button -// Access: Published -// Description: Returns true if the indicated button is on the set of -// buttons that will be processed by the ButtonThrower, -// false otherwise. See add_throw_button(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is on the set of buttons that will be + * processed by the ButtonThrower, false otherwise. See add_throw_button(). + */ bool ButtonThrower:: has_throw_button(const ModifierButtons &mods, const ButtonHandle &button) const { ThrowButtons::const_iterator ti = _throw_buttons.find(button); @@ -184,8 +159,8 @@ has_throw_button(const ModifierButtons &mods, const ButtonHandle &button) const const ThrowButtonDef &def = (*ti).second; - // This is a vector of ModifierButtons for which the indicated - // button is handled. + // This is a vector of ModifierButtons for which the indicated button is + // handled. ThrowButtonDef::const_iterator di; for (di = def.begin(); di != def.end(); ++di) { if (mods.matches(*di)) { @@ -193,22 +168,17 @@ has_throw_button(const ModifierButtons &mods, const ButtonHandle &button) const } } - // The indicated ModifierButtons are not applied to this button in - // the set. + // The indicated ModifierButtons are not applied to this button in the set. return false; } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::has_throw_button -// Access: Published -// Description: Returns true if the indicated button, in conjunction -// with any nonspecified modifier buttons, is on the set -// of buttons that will be processed by the -// ButtonThrower. That is to say, returns true if this -// button was ever passed as the second parameter -// add_throw_button(), regardless of what the first -// parameter was. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button, in conjunction with any nonspecified + * modifier buttons, is on the set of buttons that will be processed by the + * ButtonThrower. That is to say, returns true if this button was ever passed + * as the second parameter add_throw_button(), regardless of what the first + * parameter was. + */ bool ButtonThrower:: has_throw_button(const ButtonHandle &button) const { ThrowButtons::const_iterator ti = _throw_buttons.find(button); @@ -221,23 +191,18 @@ has_throw_button(const ButtonHandle &button) const { return !def.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::clear_throw_buttons -// Access: Published -// Description: Empties the set of buttons that were added via -// add_throw_button(). See add_throw_button(). -//////////////////////////////////////////////////////////////////// +/** + * Empties the set of buttons that were added via add_throw_button(). See + * add_throw_button(). + */ void ButtonThrower:: clear_throw_buttons() { _throw_buttons.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::write -// Access: Public, Virtual -// Description: Throw all events for button events found in the data -// element. -//////////////////////////////////////////////////////////////////// +/** + * Throw all events for button events found in the data element. + */ void ButtonThrower:: write(ostream &out, int indent_level) const { DataNode::write(out, indent_level); @@ -258,12 +223,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::do_specific_event -// Access: Private -// Description: Generates an event of the indicated name, adding on -// all of the user-requested parameters. -//////////////////////////////////////////////////////////////////// +/** + * Generates an event of the indicated name, adding on all of the user- + * requested parameters. + */ void ButtonThrower:: do_specific_event(const string &event_name, double time) { if (_specific_flag) { @@ -282,12 +245,9 @@ do_specific_event(const string &event_name, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::do_general_event -// Access: Private -// Description: Generates an appropriate general event, if one is -// configured. -//////////////////////////////////////////////////////////////////// +/** + * Generates an appropriate general event, if one is configured. + */ void ButtonThrower:: do_general_event(const ButtonEvent &button_event, const string &button_name) { string event_name; @@ -370,24 +330,19 @@ do_general_event(const ButtonEvent &button_event, const string &button_name) { throw_event(event); } -//////////////////////////////////////////////////////////////////// -// Function: ButtonThrower::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void ButtonThrower:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { - // Clear our outgoing button events. We'll fill it up again with - // just those events that want to carry on. + // Clear our outgoing button events. We'll fill it up again with just those + // events that want to carry on. _button_events->clear(); if (input.has_data(_button_events_input)) { @@ -402,8 +357,8 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (be._type == ButtonEvent::T_down || be._type == ButtonEvent::T_repeat) { // Button down. if (!_mods.button_down(be._button)) { - // We only prepend modifier names on the button-down events, - // and only for buttons which are not themselves modifiers. + // We only prepend modifier names on the button-down events, and + // only for buttons which are not themselves modifiers. event_name = _mods.get_prefix() + event_name; } @@ -423,28 +378,27 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, } } else if (be._type == ButtonEvent::T_resume_down) { - // Button resume down. The button was pressed at some earlier - // time, and the event was only just now detected. Don't - // throw an event now (since we already missed it), but do - // make sure our modifiers are up-to-date. + // Button resume down. The button was pressed at some earlier time, + // and the event was only just now detected. Don't throw an event now + // (since we already missed it), but do make sure our modifiers are + // up-to-date. _mods.button_down(be._button); } else if (be._type == ButtonEvent::T_up) { // Button up. _mods.button_up(be._button); - // We always throw button "up" events if we have any - // definition for the button at all, regardless of the state - // of the modifier keys. + // We always throw button "up" events if we have any definition for + // the button at all, regardless of the state of the modifier keys. if (!_throw_buttons_active || has_throw_button(be._button)) { do_specific_event(event_name + "-up", be._time); do_general_event(be, event_name); } if (_throw_buttons_active) { - // Now pass the event on to future generations. We always - // pass "up" events, even if we are intercepting this - // particular button; unless we're processing all buttons in - // which case it doesn't matter. + // Now pass the event on to future generations. We always pass "up" + // events, even if we are intercepting this particular button; + // unless we're processing all buttons in which case it doesn't + // matter. _button_events->add_event(be); } @@ -469,16 +423,16 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, do_general_event(be, event_name); } if (_throw_buttons_active) { - // Now pass the event on to future generations. We always - // pass "up" events, even if we are intercepting this - // particular button; unless we're processing all buttons in - // which case it doesn't matter. + // Now pass the event on to future generations. We always pass "up" + // events, even if we are intercepting this particular button; + // unless we're processing all buttons in which case it doesn't + // matter. _button_events->add_event(be); } } else { - // Some other kind of button event (e.g. keypress). Don't - // throw an event for this, but do pass it down. + // Some other kind of button event (e.g. keypress). Don't throw an + // event for this, but do pass it down. _button_events->add_event(be); do_general_event(be, ""); } diff --git a/panda/src/tform/buttonThrower.h b/panda/src/tform/buttonThrower.h index f62468d773..a772326fd6 100644 --- a/panda/src/tform/buttonThrower.h +++ b/panda/src/tform/buttonThrower.h @@ -1,16 +1,15 @@ -// Filename: buttonThrower.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file buttonThrower.h + * @author drose + * @date 2002-03-12 + */ #ifndef BUTTONTHROWER_H #define BUTTONTHROWER_H @@ -24,18 +23,15 @@ #include "pmap.h" #include "eventParameter.h" -//////////////////////////////////////////////////////////////////// -// Class : ButtonThrower -// Description : Throws Panda Events for button down/up events -// generated within the data graph. -// -// This is a DataNode which is intended to be parented -// to the data graph below a device which is generating -// a sequence of button events, like a MouseAndKeyboard -// device. It simply takes each button it finds and -// throws a corresponding event based on the button name -// via the throw_event() call. -//////////////////////////////////////////////////////////////////// +/** + * Throws Panda Events for button down/up events generated within the data + * graph. + * + * This is a DataNode which is intended to be parented to the data graph below + * a device which is generating a sequence of button events, like a + * MouseAndKeyboard device. It simply takes each button it finds and throws a + * corresponding event based on the button name via the throw_event() call. + */ class EXPCL_PANDA_TFORM ButtonThrower : public DataNode { PUBLISHED: ButtonThrower(const string &name); diff --git a/panda/src/tform/config_tform.cxx b/panda/src/tform/config_tform.cxx index b5bcaf7ae0..1bbb3a7e57 100644 --- a/panda/src/tform/config_tform.cxx +++ b/panda/src/tform/config_tform.cxx @@ -1,16 +1,15 @@ -// Filename: config_tform.cxx -// Created by: drose (23Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_tform.cxx + * @author drose + * @date 2000-02-23 + */ #include "config_tform.h" diff --git a/panda/src/tform/config_tform.h b/panda/src/tform/config_tform.h index 77c90c9aa4..1c1b6a9b64 100644 --- a/panda/src/tform/config_tform.h +++ b/panda/src/tform/config_tform.h @@ -1,16 +1,15 @@ -// Filename: config_tform.h -// Created by: drose (23Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_tform.h + * @author drose + * @date 2000-02-23 + */ #ifndef CONFIG_TFORM_H #define CONFIG_TFORM_H diff --git a/panda/src/tform/driveInterface.I b/panda/src/tform/driveInterface.I index 9155b596b4..0d3403f553 100644 --- a/panda/src/tform/driveInterface.I +++ b/panda/src/tform/driveInterface.I @@ -1,272 +1,208 @@ -// Filename: driveInterface.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file driveInterface.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_forward_speed -// Access: Published -// Description: Sets the speed of full forward motion, when the mouse -// is at the very top of the window. This is in units -// (e.g. feet) per second. -//////////////////////////////////////////////////////////////////// +/** + * Sets the speed of full forward motion, when the mouse is at the very top of + * the window. This is in units (e.g. feet) per second. + */ INLINE void DriveInterface:: set_forward_speed(PN_stdfloat speed) { _forward_speed = speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_forward_speed -// Access: Published -// Description: Returns the speed of full forward motion, when the -// mouse is at the very top of the window. This is in -// units (e.g. feet) per second. -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed of full forward motion, when the mouse is at the very top + * of the window. This is in units (e.g. feet) per second. + */ INLINE PN_stdfloat DriveInterface:: get_forward_speed() const { return _forward_speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_reverse_speed -// Access: Published -// Description: Sets the speed of full reverse motion, when the mouse -// is at the very bottom of the window. This is in -// units (e.g. feet) per second. -//////////////////////////////////////////////////////////////////// +/** + * Sets the speed of full reverse motion, when the mouse is at the very bottom + * of the window. This is in units (e.g. feet) per second. + */ INLINE void DriveInterface:: set_reverse_speed(PN_stdfloat speed) { _reverse_speed = speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_reverse_speed -// Access: Published -// Description: Returns the speed of full reverse motion, when the -// mouse is at the very bottom of the window. This is -// in units (e.g. feet) per second. -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed of full reverse motion, when the mouse is at the very + * bottom of the window. This is in units (e.g. feet) per second. + */ INLINE PN_stdfloat DriveInterface:: get_reverse_speed() const { return _reverse_speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_rotate_speed -// Access: Published -// Description: Sets the maximum rate at which the user can rotate -// left or right, when the mouse is at the very edge of -// the window. This is in degrees per second. -//////////////////////////////////////////////////////////////////// +/** + * Sets the maximum rate at which the user can rotate left or right, when the + * mouse is at the very edge of the window. This is in degrees per second. + */ INLINE void DriveInterface:: set_rotate_speed(PN_stdfloat speed) { _rotate_speed = speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_rotate_speed -// Access: Published -// Description: Returns the maximum rate at which the user can rotate -// left or right, when the mouse is at the very edge of -// the window. This is in degrees per second. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum rate at which the user can rotate left or right, when + * the mouse is at the very edge of the window. This is in degrees per + * second. + */ INLINE PN_stdfloat DriveInterface:: get_rotate_speed() const { return _rotate_speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_vertical_dead_zone -// Access: Published -// Description: Sets the size of the horizontal bar in the center of -// the screen that represents the "dead zone" of -// vertical motion: the region in which the mouse does -// not report vertical motion. This is in a fraction of -// the window height, so 0.5 will set a dead zone as -// large as half the screen. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the horizontal bar in the center of the screen that + * represents the "dead zone" of vertical motion: the region in which the + * mouse does not report vertical motion. This is in a fraction of the window + * height, so 0.5 will set a dead zone as large as half the screen. + */ INLINE void DriveInterface:: set_vertical_dead_zone(PN_stdfloat speed) { _vertical_dead_zone = speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_vertical_dead_zone -// Access: Published -// Description: Returns the size of the horizontal bar in the center -// of the screen that represents the "dead zone" of -// vertical motion: the region in which the mouse does -// not report vertical motion. This is in a fraction of -// the window height, so 0.5 will set a dead zone as -// large as half the screen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the horizontal bar in the center of the screen that + * represents the "dead zone" of vertical motion: the region in which the + * mouse does not report vertical motion. This is in a fraction of the window + * height, so 0.5 will set a dead zone as large as half the screen. + */ INLINE PN_stdfloat DriveInterface:: get_vertical_dead_zone() const { return _vertical_dead_zone; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_horizontal_dead_zone -// Access: Published -// Description: Sets the size of the vertical bar in the center of -// the screen that represents the "dead zone" of -// horizontal motion: the region in which the mouse does -// not report horizontal motion. This is in a fraction of -// the window width, so 0.5 will set a dead zone as -// large as half the screen. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size of the vertical bar in the center of the screen that + * represents the "dead zone" of horizontal motion: the region in which the + * mouse does not report horizontal motion. This is in a fraction of the + * window width, so 0.5 will set a dead zone as large as half the screen. + */ INLINE void DriveInterface:: set_horizontal_dead_zone(PN_stdfloat speed) { _horizontal_dead_zone = speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_horizontal_dead_zone -// Access: Published -// Description: Returns the size of the vertical bar in the center -// of the screen that represents the "dead zone" of -// horizontal motion: the region in which the mouse does -// not report horizontal motion. This is in a fraction of -// the window width, so 0.5 will set a dead zone as -// large as half the screen. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the vertical bar in the center of the screen that + * represents the "dead zone" of horizontal motion: the region in which the + * mouse does not report horizontal motion. This is in a fraction of the + * window width, so 0.5 will set a dead zone as large as half the screen. + */ INLINE PN_stdfloat DriveInterface:: get_horizontal_dead_zone() const { return _horizontal_dead_zone; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_vertical_ramp_up_time -// Access: Published -// Description: Sets the amount of time, in seconds, it takes between -// the time an up or down arrow key is pressed and the -// time it registers full forward or backward motion. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time, in seconds, it takes between the time an up or + * down arrow key is pressed and the time it registers full forward or + * backward motion. + */ INLINE void DriveInterface:: set_vertical_ramp_up_time(PN_stdfloat ramp_up_time) { _vertical_ramp_up_time = ramp_up_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_vertical_ramp_up_time -// Access: Published -// Description: Returns the amount of time, in seconds, it takes -// between the time an up or down arrow key is pressed -// and the time it registers full forward or backward -// motion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, it takes between the time an up or + * down arrow key is pressed and the time it registers full forward or + * backward motion. + */ INLINE PN_stdfloat DriveInterface:: get_vertical_ramp_up_time() const { return _vertical_ramp_up_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_vertical_ramp_down_time -// Access: Published -// Description: Sets the amount of time, in seconds, it takes between -// the time an up or down arrow key is released and the -// time it registers no motion. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time, in seconds, it takes between the time an up or + * down arrow key is released and the time it registers no motion. + */ INLINE void DriveInterface:: set_vertical_ramp_down_time(PN_stdfloat ramp_down_time) { _vertical_ramp_down_time = ramp_down_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_vertical_ramp_down_time -// Access: Published -// Description: Returns the amount of time, in seconds, it takes -// between the time an up or down arrow key is released -// and the time it registers no motion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, it takes between the time an up or + * down arrow key is released and the time it registers no motion. + */ INLINE PN_stdfloat DriveInterface:: get_vertical_ramp_down_time() const { return _vertical_ramp_down_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_horizontal_ramp_up_time -// Access: Published -// Description: Sets the amount of time, in seconds, it takes between -// the time a left or right arrow key is pressed and the -// time it registers full rotation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time, in seconds, it takes between the time a left or + * right arrow key is pressed and the time it registers full rotation. + */ INLINE void DriveInterface:: set_horizontal_ramp_up_time(PN_stdfloat ramp_up_time) { _horizontal_ramp_up_time = ramp_up_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_horizontal_ramp_up_time -// Access: Published -// Description: Returns the amount of time, in seconds, it takes -// between the time a left or right arrow key is pressed -// and the time it registers full rotation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, it takes between the time a left or + * right arrow key is pressed and the time it registers full rotation. + */ INLINE PN_stdfloat DriveInterface:: get_horizontal_ramp_up_time() const { return _horizontal_ramp_up_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_horizontal_ramp_down_time -// Access: Published -// Description: Sets the amount of time, in seconds, it takes between -// the time a left or right arrow key is released and the -// time it registers no motion. -//////////////////////////////////////////////////////////////////// +/** + * Sets the amount of time, in seconds, it takes between the time a left or + * right arrow key is released and the time it registers no motion. + */ INLINE void DriveInterface:: set_horizontal_ramp_down_time(PN_stdfloat ramp_down_time) { _horizontal_ramp_down_time = ramp_down_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_horizontal_ramp_down_time -// Access: Published -// Description: Returns the amount of time, in seconds, it takes -// between the time a left or right arrow key is released -// and the time it registers no motion. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of time, in seconds, it takes between the time a left or + * right arrow key is released and the time it registers no motion. + */ INLINE PN_stdfloat DriveInterface:: get_horizontal_ramp_down_time() const { return _horizontal_ramp_down_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_speed -// Access: Published -// Description: Returns the speed of the previous update in units/sec -//////////////////////////////////////////////////////////////////// +/** + * Returns the speed of the previous update in units/sec + */ INLINE PN_stdfloat DriveInterface:: get_speed() const { return _speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_rot_speed -// Access: Published -// Description: Returns the rot_speed of the previous update in units/sec -//////////////////////////////////////////////////////////////////// +/** + * Returns the rot_speed of the previous update in units/sec + */ INLINE PN_stdfloat DriveInterface:: get_rot_speed() const { return _rot_speed; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_pos -// Access: Published -// Description: Returns the driver's position. -//////////////////////////////////////////////////////////////////// +/** + * Returns the driver's position. + */ INLINE const LPoint3 &DriveInterface:: get_pos() const { return _xyz; @@ -288,11 +224,9 @@ get_z() const { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_pos -// Access: Published -// Description: Directly sets the driver's position. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the driver's position. + */ INLINE void DriveInterface:: set_pos(const LVecBase3 &vec) { _xyz = vec; @@ -319,11 +253,9 @@ set_z(PN_stdfloat z) { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_hpr -// Access: Published -// Description: Returns the driver's orientation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the driver's orientation. + */ INLINE const LVecBase3 &DriveInterface:: get_hpr() const { return _hpr; @@ -345,11 +277,9 @@ get_r() const { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_hpr -// Access: Published -// Description: Directly sets the driver's orientation. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the driver's orientation. + */ INLINE void DriveInterface:: set_hpr(const LVecBase3 &hpr) { set_hpr(hpr[0], hpr[1], hpr[2]); @@ -377,79 +307,62 @@ set_r(PN_stdfloat r) { _hpr[2] = _hpr_quantize * floor(r / _hpr_quantize + 0.5f); } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_ignore_mouse -// Access: Published -// Description: Changes the state of the ignore_mouse flag. If this -// flag is true, the DriveInterface will ignore mouse -// down button events (but still recognize mouse up -// button events); the user will not be able to start -// the DriveInterface going again if it is stopped, but -// if the user is currently holding down a mouse button -// it will not stop immediately until the user -// eventually releases the button. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the ignore_mouse flag. If this flag is true, the + * DriveInterface will ignore mouse down button events (but still recognize + * mouse up button events); the user will not be able to start the + * DriveInterface going again if it is stopped, but if the user is currently + * holding down a mouse button it will not stop immediately until the user + * eventually releases the button. + */ INLINE void DriveInterface:: set_ignore_mouse(bool ignore_mouse) { _ignore_mouse = ignore_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_ignore_mouse -// Access: Published -// Description: Returns the current setting of the ignore_mouse flag. -// See set_ignore_mouse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the ignore_mouse flag. See + * set_ignore_mouse(). + */ INLINE bool DriveInterface:: get_ignore_mouse() const { return _ignore_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_force_mouse -// Access: Published -// Description: Changes the state of the force_mouse flag. If this -// flag is true, the mouse button need not be held down -// in order to drive the avatar around. -//////////////////////////////////////////////////////////////////// +/** + * Changes the state of the force_mouse flag. If this flag is true, the mouse + * button need not be held down in order to drive the avatar around. + */ INLINE void DriveInterface:: set_force_mouse(bool force_mouse) { _force_mouse = force_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_force_mouse -// Access: Published -// Description: Returns the current setting of the force_mouse flag. -// See set_force_mouse(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the force_mouse flag. See + * set_force_mouse(). + */ INLINE bool DriveInterface:: get_force_mouse() const { return _force_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_stop_this_frame -// Access: Published -// Description: If stop_this_frame is true, the next time the frame -// is computed no motion will be allowed, and then the -// flag is reset to false. This can be used to prevent -// too much movement when we know a long time has -// artificially elapsed, for instance when we take a -// screenshot, without munging the clock for everything -// else. -//////////////////////////////////////////////////////////////////// +/** + * If stop_this_frame is true, the next time the frame is computed no motion + * will be allowed, and then the flag is reset to false. This can be used to + * prevent too much movement when we know a long time has artificially + * elapsed, for instance when we take a screenshot, without munging the clock + * for everything else. + */ INLINE void DriveInterface:: set_stop_this_frame(bool stop_this_frame) { _stop_this_frame = stop_this_frame; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_stop_this_frame -// Access: Published -// Description: Returns the current setting of the stop_this_frame -// flag. See set_stop_this_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the stop_this_frame flag. See + * set_stop_this_frame(). + */ INLINE bool DriveInterface:: get_stop_this_frame() const { return _stop_this_frame; diff --git a/panda/src/tform/driveInterface.cxx b/panda/src/tform/driveInterface.cxx index 278bccde59..f9324ce110 100644 --- a/panda/src/tform/driveInterface.cxx +++ b/panda/src/tform/driveInterface.cxx @@ -1,16 +1,15 @@ -// Filename: driveInterface.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file driveInterface.cxx + * @author drose + * @date 2002-03-12 + */ #include "driveInterface.h" #include "config_tform.h" @@ -41,8 +40,8 @@ PN_stdfloat DriveInterface::KeyHeld:: get_effect(PN_stdfloat ramp_up_time, PN_stdfloat ramp_down_time) { double elapsed = ClockObject::get_global_clock()->get_frame_time() - _changed_time; if (_down) { - // We are currently holding down the key. That means we base our - // effect on the ramp_up_time. + // We are currently holding down the key. That means we base our effect + // on the ramp_up_time. if (ramp_up_time == 0.0f) { _effect = 1.0f; @@ -51,8 +50,8 @@ get_effect(PN_stdfloat ramp_up_time, PN_stdfloat ramp_down_time) { _effect = min(_effect_at_change + change, (PN_stdfloat)1.0); } } else { - // We are *not* currently holding down the key. That means we - // base our effect on the ramp_down_time. + // We are *not* currently holding down the key. That means we base our + // effect on the ramp_down_time. if (ramp_down_time == 0.0f) { _effect = 0.0f; @@ -84,8 +83,7 @@ clear() { bool DriveInterface::KeyHeld:: operator < (const DriveInterface::KeyHeld &other) const { if (_down != other._down) { - // If one has the key held down and the other doesn't, the down - // key wins. + // If one has the key held down and the other doesn't, the down key wins. return _down; } @@ -93,14 +91,12 @@ operator < (const DriveInterface::KeyHeld &other) const { return _changed_time > other._changed_time; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DriveInterface:: -DriveInterface(const string &name) : - MouseInterfaceNode(name) +DriveInterface(const string &name) : + MouseInterfaceNode(name) { _xy_input = define_input("xy", EventStoreVec2::get_class_type()); _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); @@ -139,21 +135,17 @@ DriveInterface(const string &name) : -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DriveInterface:: ~DriveInterface() { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::reset -// Access: Published -// Description: Reinitializes the driver to the origin and resets any -// knowledge about buttons being held down. -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes the driver to the origin and resets any knowledge about + * buttons being held down. + */ void DriveInterface:: reset() { _xyz.set(0.0f, 0.0f, 0.0f); @@ -165,50 +157,40 @@ reset() { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_force_roll -// Access: Published -// Description: This function is no longer used and does nothing. It -// will be removed soon. -//////////////////////////////////////////////////////////////////// +/** + * This function is no longer used and does nothing. It will be removed soon. + */ void DriveInterface:: set_force_roll(PN_stdfloat) { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::set_mat -// Access: Published -// Description: Stores the indicated transform in the DriveInterface. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated transform in the DriveInterface. + */ void DriveInterface:: set_mat(const LMatrix4 &mat) { LVecBase3 scale, shear; decompose_matrix(mat, scale, shear, _hpr, _xyz); } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::get_mat -// Access: Published -// Description: Returns the current transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current transform. + */ const LMatrix4 &DriveInterface:: get_mat() { - compose_matrix(_mat, - LVecBase3(1.0f, 1.0f, 1.0f), + compose_matrix(_mat, + LVecBase3(1.0f, 1.0f, 1.0f), LVecBase3(0.0f, 0.0f, 0.0f), _hpr, _xyz); return _mat; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::force_dgraph -// Access: Public -// Description: This is a special kludge for DriveInterface to allow -// us to avoid the one-frame latency after a collision. -// It forces an immediate partial data flow for all data -// graph nodes below this node, causing all data nodes -// that depend on this matrix to be updated immediately. -//////////////////////////////////////////////////////////////////// +/** + * This is a special kludge for DriveInterface to allow us to avoid the one- + * frame latency after a collision. It forces an immediate partial data flow + * for all data graph nodes below this node, causing all data nodes that + * depend on this matrix to be updated immediately. + */ void DriveInterface:: force_dgraph() { _transform = TransformState::make_pos_hpr(_xyz, _hpr); @@ -225,13 +207,10 @@ force_dgraph() { } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::apply -// Access: Private -// Description: Applies the operation indicated by the user's mouse -// motion to the current state. Returns the matrix -// indicating the new state. -//////////////////////////////////////////////////////////////////// +/** + * Applies the operation indicated by the user's mouse motion to the current + * state. Returns the matrix indicating the new state. + */ void DriveInterface:: apply(double x, double y, bool any_button) { // First reset the speeds @@ -239,22 +218,22 @@ apply(double x, double y, bool any_button) { _rot_speed = 0.0f; if (any_button || _force_mouse) { - // If we're holding down any of the mouse buttons, do this - // computation based on the mouse position. + // If we're holding down any of the mouse buttons, do this computation + // based on the mouse position. - // Determine, based on the mouse's position and the amount of time - // elapsed since last frame, how far forward/backward we should - // move and how much we should rotate. + // Determine, based on the mouse's position and the amount of time elapsed + // since last frame, how far forwardbackward we should move and how much + // we should rotate. - // First, how fast are we moving? This is based on the mouse's - // vertical position. + // First, how fast are we moving? This is based on the mouse's vertical + // position. PN_stdfloat dead_zone_top = _vertical_center + _vertical_dead_zone; PN_stdfloat dead_zone_bottom = _vertical_center - _vertical_dead_zone; if (y >= dead_zone_top) { - // Motion is forward. Compute the throttle value: the ratio of - // the mouse pointer within the range of vertical movement. + // Motion is forward. Compute the throttle value: the ratio of the + // mouse pointer within the range of vertical movement. PN_stdfloat throttle = // double 1.0, not 1.0f, is required here to satisfy min() (min(y, 1.0) - dead_zone_top) / @@ -269,15 +248,14 @@ apply(double x, double y, bool any_button) { _speed = -throttle * _reverse_speed; } - // Now, what's our rotational velocity? This is based on the - // mouse's horizontal position. + // Now, what's our rotational velocity? This is based on the mouse's + // horizontal position. PN_stdfloat dead_zone_right = _horizontal_center + _horizontal_dead_zone; PN_stdfloat dead_zone_left = _horizontal_center - _horizontal_dead_zone; if (x >= dead_zone_right) { - // Rotation is to the right. Compute the throttle value: the - // ratio of the mouse pointer within the range of horizontal - // movement. + // Rotation is to the right. Compute the throttle value: the ratio of + // the mouse pointer within the range of horizontal movement. PN_stdfloat throttle = (min(x, 1.0) - dead_zone_right) / (1.0f - dead_zone_right); @@ -292,8 +270,8 @@ apply(double x, double y, bool any_button) { } } else { - // If we're not holding down any of the mouse buttons, do this - // computation based on the arrow keys. + // If we're not holding down any of the mouse buttons, do this computation + // based on the arrow keys. // Which vertical arrow key changed state more recently? PN_stdfloat throttle; @@ -344,8 +322,7 @@ apply(double x, double y, bool any_button) { // Now apply the vectors. - // rot_mat is the rotation matrix corresponding to our previous - // heading. + // rot_mat is the rotation matrix corresponding to our previous heading. LMatrix3 rot_mat; rot_mat.set_rotate_mat_normaxis(_hpr[0], LVector3::up()); @@ -353,9 +330,8 @@ apply(double x, double y, bool any_button) { _vel = LVector3::forward() * distance; LVector3 step = (_vel * rot_mat); - // To prevent upward drift due to numerical errors, force the - // vertical component of our step to zero (it should be pretty near - // zero anyway). + // To prevent upward drift due to numerical errors, force the vertical + // component of our step to zero (it should be pretty near zero anyway). switch (get_default_coordinate_system()) { case CS_zup_right: case CS_zup_left: @@ -375,19 +351,14 @@ apply(double x, double y, bool any_button) { _hpr[0] -= rotation; } -//////////////////////////////////////////////////////////////////// -// Function: DriveInterface::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void DriveInterface:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -399,7 +370,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, double x = 0.0f; double y = 0.0f; - //bool got_mouse = false; + // bool got_mouse = false; if (required_buttons_match && input.has_data(_xy_input)) { const EventStoreVec2 *xy; @@ -408,7 +379,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, x = p[0]; y = p[1]; - //got_mouse = true; + // got_mouse = true; } // Look for keyboard events. @@ -419,7 +390,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, const ButtonEvent &be = button_events->get_event(i); if (be._type != ButtonEvent::T_keystroke) { bool down = (be._type != ButtonEvent::T_up); - + if (be._button == KeyboardButton::up()) { _up_arrow.set_key(down); } else if (be._button == KeyboardButton::down()) { diff --git a/panda/src/tform/driveInterface.h b/panda/src/tform/driveInterface.h index b70d753d86..49c6a521d7 100644 --- a/panda/src/tform/driveInterface.h +++ b/panda/src/tform/driveInterface.h @@ -1,16 +1,15 @@ -// Filename: driveInterface.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file driveInterface.h + * @author drose + * @date 2002-03-12 + */ #ifndef DRIVEINTERFACE_H #define DRIVEINTERFACE_H @@ -24,13 +23,11 @@ #include "transformState.h" -//////////////////////////////////////////////////////////////////// -// Class : DriveInterface -// Description : This is a TFormer, similar to Trackball, that moves -// around a transform matrix in response to mouse input. -// The basic motion is on a horizontal plane, as if -// driving a vehicle. -//////////////////////////////////////////////////////////////////// +/** + * This is a TFormer, similar to Trackball, that moves around a transform + * matrix in response to mouse input. The basic motion is on a horizontal + * plane, as if driving a vehicle. + */ class EXPCL_PANDA_TFORM DriveInterface : public MouseInterfaceNode { PUBLISHED: DriveInterface(const string &name = ""); @@ -61,7 +58,7 @@ PUBLISHED: void reset(); - /// **** Translation **** + // **** Translation **** INLINE const LPoint3 &get_pos() const; INLINE PN_stdfloat get_x() const; @@ -73,7 +70,7 @@ PUBLISHED: INLINE void set_y(PN_stdfloat y); INLINE void set_z(PN_stdfloat z); - /// **** Rotation **** + // **** Rotation **** INLINE const LVecBase3 &get_hpr() const; INLINE PN_stdfloat get_h() const; @@ -112,8 +109,8 @@ private: PN_stdfloat _vertical_center; // window units, 0 = center, -1 = bottom, 1 = top PN_stdfloat _horizontal_center; // window units, 0 = center, -1 = left, 1 = right - // The time it takes to ramp up to full speed from a stop (or return - // to a stop from full speed) when using the keyboard. + // The time it takes to ramp up to full speed from a stop (or return to a + // stop from full speed) when using the keyboard. PN_stdfloat _vertical_ramp_up_time; PN_stdfloat _vertical_ramp_down_time; PN_stdfloat _horizontal_ramp_up_time; @@ -132,8 +129,8 @@ private: // This is only used to return a temporary value in get_mat(). LMatrix4 _mat; - // Remember which arrow keys are being held down and which aren't, - // and at what point they last changed state. + // Remember which arrow keys are being held down and which aren't, and at + // what point they last changed state. class KeyHeld { public: KeyHeld(); @@ -169,11 +166,10 @@ private: CPT(TransformState) _transform; PT(EventStoreVec3) _velocity; - // This is the smallest meaningful value we can set on the hpr via - // the public set_hpr() interface. It's intended to filter out - // small meaningless perturbations of hpr that may get introduced - // due to numerical inaccuracy as we compute relative orientations - // in the show. + // This is the smallest meaningful value we can set on the hpr via the + // public set_hpr() interface. It's intended to filter out small + // meaningless perturbations of hpr that may get introduced due to numerical + // inaccuracy as we compute relative orientations in the show. static const PN_stdfloat _hpr_quantize; public: diff --git a/panda/src/tform/mouseInterfaceNode.I b/panda/src/tform/mouseInterfaceNode.I index 55cda35c3c..153977b49b 100644 --- a/panda/src/tform/mouseInterfaceNode.I +++ b/panda/src/tform/mouseInterfaceNode.I @@ -1,25 +1,20 @@ -// Filename: mouseInterfaceNode.I -// Created by: drose (11Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseInterfaceNode.I + * @author drose + * @date 2004-06-11 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::is_down -// Access: Protected -// Description: Returns true if the indicated button (which must have -// been specified in a previous call to watch_button()) -// is known to be held down, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button (which must have been specified in a + * previous call to watch_button()) is known to be held down, false otherwise. + */ INLINE bool MouseInterfaceNode:: is_down(ButtonHandle button) const { return _current_button_state.is_down(button); diff --git a/panda/src/tform/mouseInterfaceNode.cxx b/panda/src/tform/mouseInterfaceNode.cxx index 4bbfbd1e0f..b69a17d06e 100644 --- a/panda/src/tform/mouseInterfaceNode.cxx +++ b/panda/src/tform/mouseInterfaceNode.cxx @@ -1,17 +1,15 @@ -// Filename: mouseInterfaceNode.cxx -// Created by: drose (11Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseInterfaceNode.cxx + * @author drose + * @date 2004-06-11 + */ #include "trackball.h" #include "buttonEvent.h" @@ -21,11 +19,9 @@ TypeHandle MouseInterfaceNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseInterfaceNode:: MouseInterfaceNode(const string &name) : DataNode(name) @@ -33,25 +29,19 @@ MouseInterfaceNode(const string &name) : _button_events_input = define_input("button_events", ButtonEventList::get_class_type()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseInterfaceNode:: ~MouseInterfaceNode() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::require_button -// Access: Published -// Description: Indicates that the indicated button must be in the -// required state (either up or down) in order for this -// particular MouseInterfaceNode to do anything. For -// instance, this may be called to make a Trackball -// object respect mouse input only when the control key -// is held down. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the indicated button must be in the required state (either + * up or down) in order for this particular MouseInterfaceNode to do anything. + * For instance, this may be called to make a Trackball object respect mouse + * input only when the control key is held down. + */ void MouseInterfaceNode:: require_button(const ButtonHandle &button, bool is_down) { _required_buttons_mask.add_button(button); @@ -66,19 +56,17 @@ require_button(const ButtonHandle &button, bool is_down) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::clear_button -// Access: Published -// Description: Removes any requirement on the indicated button set -// by an earlier call to require_button(). -//////////////////////////////////////////////////////////////////// +/** + * Removes any requirement on the indicated button set by an earlier call to + * require_button(). + */ void MouseInterfaceNode:: clear_button(const ButtonHandle &button) { _required_buttons_mask.button_up(button); _required_buttons_state.button_up(button); - // The _required_buttons_mask and state must always keep the buttons - // that are listed in _watched_buttons. + // The _required_buttons_mask and state must always keep the buttons that + // are listed in _watched_buttons. if (!_watched_buttons.has_button(button)) { _required_buttons_mask.remove_button(button); @@ -87,12 +75,10 @@ clear_button(const ButtonHandle &button) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::clear_all_button -// Access: Published -// Description: Removes all requirements on buttons set by an earlier -// call to require_button(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all requirements on buttons set by an earlier call to + * require_button(). + */ void MouseInterfaceNode:: clear_all_buttons() { _required_buttons_mask.all_buttons_up(); @@ -103,12 +89,10 @@ clear_all_buttons() { _current_button_state.set_button_list(_watched_buttons); } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::watch_button -// Access: Protected -// Description: Indicates that the derived class would like to know -// the state of the given button. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the derived class would like to know the state of the given + * button. + */ void MouseInterfaceNode:: watch_button(const ButtonHandle &button) { _watched_buttons.add_button(button); @@ -120,20 +104,16 @@ watch_button(const ButtonHandle &button) { _current_button_state.set_button_list(_required_buttons_mask); } -//////////////////////////////////////////////////////////////////// -// Function: MouseInterfaceNode::check_button_events -// Access: Protected -// Description: Gets the button events from the data graph and -// updates the ModifierButtons objects appropriately. -// -// Sets required_buttons_match to true if the required -// combination of buttons are being held down, or false -// otherwise. -// -// The return value is the list of button events -// processed this frame, or NULL if there are no button -// events. -//////////////////////////////////////////////////////////////////// +/** + * Gets the button events from the data graph and updates the ModifierButtons + * objects appropriately. + * + * Sets required_buttons_match to true if the required combination of buttons + * are being held down, or false otherwise. + * + * The return value is the list of button events processed this frame, or NULL + * if there are no button events. + */ const ButtonEventList *MouseInterfaceNode:: check_button_events(const DataNodeTransmit &input, bool &required_buttons_match) { @@ -144,7 +124,7 @@ check_button_events(const DataNodeTransmit &input, button_events->update_mods(_current_button_state); } - required_buttons_match = + required_buttons_match = (_current_button_state & _required_buttons_mask) == _required_buttons_state; return button_events; diff --git a/panda/src/tform/mouseInterfaceNode.h b/panda/src/tform/mouseInterfaceNode.h index b0a5fe30fd..02fdf2c200 100644 --- a/panda/src/tform/mouseInterfaceNode.h +++ b/panda/src/tform/mouseInterfaceNode.h @@ -1,16 +1,15 @@ -// Filename: mouseInterfaceNode.h -// Created by: drose (11Jun04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseInterfaceNode.h + * @author drose + * @date 2004-06-11 + */ #ifndef MOUSEINTERFACENODE_H #define MOUSEINTERFACENODE_H @@ -22,15 +21,13 @@ class ButtonEventList; -//////////////////////////////////////////////////////////////////// -// Class : MouseInterfaceNode -// Description : This is the base class for some classes that monitor -// the mouse and keyboard input and perform some action -// due to their state. -// -// It collects together some common interface; in -// particular, the require_button() and related methods. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for some classes that monitor the mouse and keyboard + * input and perform some action due to their state. + * + * It collects together some common interface; in particular, the + * require_button() and related methods. + */ class EXPCL_PANDA_TFORM MouseInterfaceNode : public DataNode { public: MouseInterfaceNode(const string &name); diff --git a/panda/src/tform/mouseSubregion.I b/panda/src/tform/mouseSubregion.I index 9989217f8e..b217082520 100644 --- a/panda/src/tform/mouseSubregion.I +++ b/panda/src/tform/mouseSubregion.I @@ -1,76 +1,58 @@ -// Filename: mouseSubregion.I -// Created by: drose (13May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseSubregion.I + * @author drose + * @date 2005-05-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::get_left -// Access: Published -// Description: Retrieves the x coordinate of the left edge of the -// rectangle within the window. This number will be in -// the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the left edge of the rectangle within the + * window. This number will be in the range [0..1]. + */ PN_stdfloat MouseSubregion:: get_left() const { return _l; } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::get_right -// Access: Published -// Description: Retrieves the x coordinate of the right edge of the -// rectangle within the window. This number will be in -// the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the x coordinate of the right edge of the rectangle within the + * window. This number will be in the range [0..1]. + */ PN_stdfloat MouseSubregion:: get_right() const { return _r; } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::get_bottom -// Access: Published -// Description: Retrieves the y coordinate of the bottom edge of -// the rectangle within the window. This number will be -// in the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the bottom edge of the rectangle within the + * window. This number will be in the range [0..1]. + */ PN_stdfloat MouseSubregion:: get_bottom() const { return _b; } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::get_top -// Access: Published -// Description: Retrieves the y coordinate of the top edge of the -// rectangle within the window. This number will be in -// the range [0..1]. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the y coordinate of the top edge of the rectangle within the + * window. This number will be in the range [0..1]. + */ PN_stdfloat MouseSubregion:: get_top() const { return _t; } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::set_dimensions -// Access: Published -// Description: Changes the region of the window in which the mouse -// is considered to be active. The parameters are -// identical to those for a DisplayRegion: they range -// from 0 to 1, where 0,0 is the lower left corner and -// 1,1 is the upper right; (0, 1, 0, 1) represents the -// whole window. -//////////////////////////////////////////////////////////////////// +/** + * Changes the region of the window in which the mouse is considered to be + * active. The parameters are identical to those for a DisplayRegion: they + * range from 0 to 1, where 0,0 is the lower left corner and 1,1 is the upper + * right; (0, 1, 0, 1) represents the whole window. + */ void MouseSubregion:: set_dimensions(PN_stdfloat l, PN_stdfloat r, PN_stdfloat b, PN_stdfloat t) { _l = l; diff --git a/panda/src/tform/mouseSubregion.cxx b/panda/src/tform/mouseSubregion.cxx index e7ea085db3..f342db85fe 100644 --- a/panda/src/tform/mouseSubregion.cxx +++ b/panda/src/tform/mouseSubregion.cxx @@ -1,27 +1,24 @@ -// Filename: mouseSubregion.cxx -// Created by: drose (13May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseSubregion.cxx + * @author drose + * @date 2005-05-13 + */ #include "mouseSubregion.h" #include "dataNodeTransmit.h" TypeHandle MouseSubregion::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseSubregion:: MouseSubregion(const string &name) : MouseInterfaceNode(name) @@ -42,28 +39,21 @@ MouseSubregion(const string &name) : _button_events = new ButtonEventList; } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseSubregion:: ~MouseSubregion() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseSubregion::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void MouseSubregion:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -83,8 +73,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, _xy->set_value(n); output.set_data(_xy_output, EventParameter(_xy)); - // Also compute the pixel coordinates, based on the supplied - // pixel_size. + // Also compute the pixel coordinates, based on the supplied pixel_size. if (input.has_data(_pixel_size_input)) { const EventStoreVec2 *pixel_size; DCAST_INTO_V(pixel_size, input.get_data(_pixel_size_input).get_ptr()); @@ -92,7 +81,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, PN_stdfloat xf = (1.0f + n[0]) * 0.5f * s[0]; PN_stdfloat yf = (1.0f - n[1]) * 0.5f * s[1]; - + _pixel_xy->set_value(LPoint2(xf, yf)); output.set_data(_pixel_xy_output, EventParameter(_pixel_xy)); } diff --git a/panda/src/tform/mouseSubregion.h b/panda/src/tform/mouseSubregion.h index cad1da671d..acfd8a4142 100644 --- a/panda/src/tform/mouseSubregion.h +++ b/panda/src/tform/mouseSubregion.h @@ -1,16 +1,15 @@ -// Filename: mouseSubregion.h -// Created by: drose (13May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseSubregion.h + * @author drose + * @date 2005-05-13 + */ #ifndef MOUSESUBREGION_H #define MOUSESUBREGION_H @@ -23,17 +22,14 @@ #include "buttonEventList.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseSubregion -// Description : The MouseSubregion object scales the mouse inputs -// from within a rectangular region of the screen, as if -// they were the full-screen inputs. -// -// If you choose your MouseSubregion coordinates to -// exactly match a DisplayRegion within your window, you -// end up with a virtual mouse within your -// DisplayRegion. -//////////////////////////////////////////////////////////////////// +/** + * The MouseSubregion object scales the mouse inputs from within a rectangular + * region of the screen, as if they were the full-screen inputs. + * + * If you choose your MouseSubregion coordinates to exactly match a + * DisplayRegion within your window, you end up with a virtual mouse within + * your DisplayRegion. + */ class EXPCL_PANDA_TFORM MouseSubregion : public MouseInterfaceNode { PUBLISHED: MouseSubregion(const string &name); diff --git a/panda/src/tform/mouseWatcher.I b/panda/src/tform/mouseWatcher.I index abf24c24df..389861e8d9 100644 --- a/panda/src/tform/mouseWatcher.I +++ b/panda/src/tform/mouseWatcher.I @@ -1,49 +1,39 @@ -// Filename: mouseWatcher.I -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcher.I + * @author drose + * @date 2002-03-12 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::has_mouse -// Access: Published -// Description: Returns true if the mouse is anywhere within the -// window, false otherwise. Also see is_mouse_open(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse is anywhere within the window, false otherwise. + * Also see is_mouse_open(). + */ INLINE bool MouseWatcher:: has_mouse() const { return _has_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::is_mouse_open -// Access: Published -// Description: Returns true if the mouse is within the window and -// not over some particular MouseWatcherRegion that is -// marked to suppress mouse events; that is, that the -// mouse is in open space within the window. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse is within the window and not over some particular + * MouseWatcherRegion that is marked to suppress mouse events; that is, that + * the mouse is in open space within the window. + */ INLINE bool MouseWatcher:: is_mouse_open() const { return _has_mouse && (_internal_suppress & MouseWatcherRegion::SF_mouse_position) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_mouse -// Access: Published -// Description: It is only valid to call this if has_mouse() returns -// true. If so, this returns the current position of -// the mouse within the window. -//////////////////////////////////////////////////////////////////// +/** + * It is only valid to call this if has_mouse() returns true. If so, this + * returns the current position of the mouse within the window. + */ INLINE const LPoint2 &MouseWatcher:: get_mouse() const { #ifndef NDEBUG @@ -53,515 +43,397 @@ get_mouse() const { return _mouse; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_mouse_x -// Access: Published -// Description: It is only valid to call this if has_mouse() returns -// true. If so, this returns the current X position of -// the mouse within the window. -//////////////////////////////////////////////////////////////////// +/** + * It is only valid to call this if has_mouse() returns true. If so, this + * returns the current X position of the mouse within the window. + */ INLINE PN_stdfloat MouseWatcher:: get_mouse_x() const { nassertr(_has_mouse, 0.0f); return _mouse[0]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_mouse_y -// Access: Published -// Description: It is only valid to call this if has_mouse() returns -// true. If so, this returns the current Y position of -// the mouse within the window. -//////////////////////////////////////////////////////////////////// +/** + * It is only valid to call this if has_mouse() returns true. If so, this + * returns the current Y position of the mouse within the window. + */ INLINE PN_stdfloat MouseWatcher:: get_mouse_y() const { nassertr(_has_mouse, 0.0f); return _mouse[1]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_frame -// Access: Published -// Description: Sets the frame of the MouseWatcher. See the next -// flavor of this method for a more verbose explanation. -//////////////////////////////////////////////////////////////////// +/** + * Sets the frame of the MouseWatcher. See the next flavor of this method for + * a more verbose explanation. + */ INLINE void MouseWatcher:: set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_frame(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_frame -// Access: Published -// Description: Sets the frame of the MouseWatcher. This determines -// the coordinate space in which the MouseWatcherRegions -// should be expected to live. Normally, this is left -// at -1, 1, -1, 1, which is the default setting, and -// matches the mouse coordinate range. -// -// Whatever values you specify here indicate the shape -// of the full screen, and the MouseWatcherRegions will -// be given in coordinate space matching it. For -// instance, if you specify (0, 1, 0, 1), then a -// MouseWatcherRegion with the frame (0, 1, 0, .5) will -// cover the lower half of the screen. -//////////////////////////////////////////////////////////////////// +/** + * Sets the frame of the MouseWatcher. This determines the coordinate space + * in which the MouseWatcherRegions should be expected to live. Normally, + * this is left at -1, 1, -1, 1, which is the default setting, and matches the + * mouse coordinate range. + * + * Whatever values you specify here indicate the shape of the full screen, and + * the MouseWatcherRegions will be given in coordinate space matching it. For + * instance, if you specify (0, 1, 0, 1), then a MouseWatcherRegion with the + * frame (0, 1, 0, .5) will cover the lower half of the screen. + */ INLINE void MouseWatcher:: set_frame(const LVecBase4 &frame) { _frame = frame; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_frame -// Access: Published -// Description: Returns the frame of the MouseWatcher. See -// set_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame of the MouseWatcher. See set_frame(). + */ INLINE const LVecBase4 &MouseWatcher:: get_frame() const { return _frame; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::is_over_region -// Access: Published -// Description: Returns true if the mouse is over any rectangular -// region, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse is over any rectangular region, false otherwise. + */ INLINE bool MouseWatcher:: is_over_region() const { return get_over_region() != (MouseWatcherRegion *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::is_over_region -// Access: Published -// Description: Returns true if the mouse is over any rectangular -// region, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse is over any rectangular region, false otherwise. + */ INLINE bool MouseWatcher:: is_over_region(PN_stdfloat x, PN_stdfloat y) const { return get_over_region(x, y) != (MouseWatcherRegion *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::is_over_region -// Access: Published -// Description: Returns true if the mouse is over any rectangular -// region, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse is over any rectangular region, false otherwise. + */ INLINE bool MouseWatcher:: is_over_region(const LPoint2 &pos) const { return get_over_region(pos) != (MouseWatcherRegion *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_over_region -// Access: Published -// Description: Returns the smallest region the mouse is currently -// over, or NULL if it is over no region. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest region the mouse is currently over, or NULL if it is + * over no region. + */ INLINE MouseWatcherRegion *MouseWatcher:: get_over_region() const { return _preferred_region; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_over_region -// Access: Published -// Description: Returns the smallest region the indicated point is -// over, or NULL if it is over no region. -//////////////////////////////////////////////////////////////////// +/** + * Returns the smallest region the indicated point is over, or NULL if it is + * over no region. + */ INLINE MouseWatcherRegion *MouseWatcher:: get_over_region(PN_stdfloat x, PN_stdfloat y) const { return get_over_region(LPoint2(x, y)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::is_button_down -// Access: Published -// Description: Returns true if the indicated button is currently -// being held down, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated button is currently being held down, false + * otherwise. + */ INLINE bool MouseWatcher:: is_button_down(ButtonHandle button) const { return _inactivity_state != IS_inactive && _current_buttons_down.get_bit(button.get_index()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_button_down_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when a button is depressed. This -// is a string that may contain any of the following: -// -// %r - the name of the region the mouse is over -// %b - the name of the button pressed. -// -// The event name will be based on the in_pattern -// string specified here, with all occurrences of the -// above strings replaced with the corresponding values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when a button is depressed. This is a string that may contain any of the + * following: + * + * %r - the name of the region the mouse is over %b - the name of the button + * pressed. + * + * The event name will be based on the in_pattern string specified here, with + * all occurrences of the above strings replaced with the corresponding + * values. + */ INLINE void MouseWatcher:: set_button_down_pattern(const string &pattern) { _button_down_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_button_down_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when a button is depressed. See -// set_button_down_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when a + * button is depressed. See set_button_down_pattern(). + */ INLINE const string &MouseWatcher:: get_button_down_pattern() const { return _button_down_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_button_up_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when a button is released. See -// set_button_down_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when a button is released. See set_button_down_pattern(). + */ INLINE void MouseWatcher:: set_button_up_pattern(const string &pattern) { _button_up_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_button_up_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when a button is released. See -// set_button_down_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when a + * button is released. See set_button_down_pattern(). + */ INLINE const string &MouseWatcher:: get_button_up_pattern() const { return _button_up_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_button_repeat_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when a button is continuously -// held and generates keyrepeat "down" events. This is -// a string that may contain any of the following: -// -// %r - the name of the region the mouse is over -// %b - the name of the button pressed. -// -// The event name will be based on the in_pattern -// string specified here, with all occurrences of the -// above strings replaced with the corresponding values. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when a button is continuously held and generates keyrepeat "down" events. + * This is a string that may contain any of the following: + * + * %r - the name of the region the mouse is over %b - the name of the button + * pressed. + * + * The event name will be based on the in_pattern string specified here, with + * all occurrences of the above strings replaced with the corresponding + * values. + */ INLINE void MouseWatcher:: set_button_repeat_pattern(const string &pattern) { _button_repeat_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_button_repeat_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// names are generated when a button is continuously -// held and generates keyrepeat "down" events. See -// set_button_repeat_pattern(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are names are generated + * when a button is continuously held and generates keyrepeat "down" events. + * See set_button_repeat_pattern(). + */ INLINE const string &MouseWatcher:: get_button_repeat_pattern() const { return _button_repeat_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_enter_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when the mouse enters a region. -// This is different from within_pattern, in that a -// mouse is only "entered" in the topmost region at a -// given time, while it might be "within" multiple -// nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when the mouse enters a region. This is different from within_pattern, in + * that a mouse is only "entered" in the topmost region at a given time, while + * it might be "within" multiple nested regions. + */ INLINE void MouseWatcher:: set_enter_pattern(const string &pattern) { _enter_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_enter_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when the mouse enters a region. This is -// different from within_pattern, in that a mouse is -// only "entered" in the topmost region at a given time, -// while it might be "within" multiple nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when the + * mouse enters a region. This is different from within_pattern, in that a + * mouse is only "entered" in the topmost region at a given time, while it + * might be "within" multiple nested regions. + */ INLINE const string &MouseWatcher:: get_enter_pattern() const { return _enter_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_leave_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when the mouse leaves a region. -// This is different from without_pattern, in that a -// mouse is only "entered" in the topmost region at a -// given time, while it might be "within" multiple -// nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when the mouse leaves a region. This is different from without_pattern, in + * that a mouse is only "entered" in the topmost region at a given time, while + * it might be "within" multiple nested regions. + */ INLINE void MouseWatcher:: set_leave_pattern(const string &pattern) { _leave_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_leave_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when the mouse leaves a region. This is -// different from without_pattern, in that a mouse is -// only "entered" in the topmost region at a given time, -// while it might be "within" multiple nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when the + * mouse leaves a region. This is different from without_pattern, in that a + * mouse is only "entered" in the topmost region at a given time, while it + * might be "within" multiple nested regions. + */ INLINE const string &MouseWatcher:: get_leave_pattern() const { return _leave_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_within_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when the mouse wanders over a -// region. This is different from enter_pattern, in -// that a mouse is only "entered" in the topmost region -// at a given time, while it might be "within" multiple -// nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when the mouse wanders over a region. This is different from + * enter_pattern, in that a mouse is only "entered" in the topmost region at a + * given time, while it might be "within" multiple nested regions. + */ INLINE void MouseWatcher:: set_within_pattern(const string &pattern) { _within_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_within_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when the mouse wanders over a region. This -// is different from enter_pattern, in that a mouse is -// only "entered" in the topmost region at a given time, -// while it might be "within" multiple nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when the + * mouse wanders over a region. This is different from enter_pattern, in that + * a mouse is only "entered" in the topmost region at a given time, while it + * might be "within" multiple nested regions. + */ INLINE const string &MouseWatcher:: get_within_pattern() const { return _within_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_without_pattern -// Access: Published -// Description: Sets the pattern string that indicates how the event -// names are generated when the mouse wanders out of a -// region. This is different from leave_pattern, in -// that a mouse is only "entered" in the topmost region -// at a given time, while it might be "within" multiple -// nested regions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the pattern string that indicates how the event names are generated + * when the mouse wanders out of a region. This is different from + * leave_pattern, in that a mouse is only "entered" in the topmost region at a + * given time, while it might be "within" multiple nested regions. + */ INLINE void MouseWatcher:: set_without_pattern(const string &pattern) { _without_pattern = pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_without_pattern -// Access: Published -// Description: Returns the string that indicates how event names are -// generated when the mouse wanders out of a region. -// This is different from leave_pattern, in that a mouse -// is only "entered" in the topmost region at a given -// time, while it might be "within" multiple nested -// regions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string that indicates how event names are generated when the + * mouse wanders out of a region. This is different from leave_pattern, in + * that a mouse is only "entered" in the topmost region at a given time, while + * it might be "within" multiple nested regions. + */ INLINE const string &MouseWatcher:: get_without_pattern() const { return _without_pattern; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_geometry -// Access: Published -// Description: Sets the node that will be transformed each frame by -// the mouse's coordinates. It will also be hidden when -// the mouse goes outside the window. This can be used -// to implement a software mouse pointer for when a -// hardware (or system) mouse pointer is unavailable. -//////////////////////////////////////////////////////////////////// +/** + * Sets the node that will be transformed each frame by the mouse's + * coordinates. It will also be hidden when the mouse goes outside the + * window. This can be used to implement a software mouse pointer for when a + * hardware (or system) mouse pointer is unavailable. + */ INLINE void MouseWatcher:: set_geometry(PandaNode *node) { _geometry = node; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::has_geometry -// Access: Published -// Description: Returns true if a software mouse pointer has been -// setup via set_geometry(), or false otherwise. See -// set_geometry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a software mouse pointer has been setup via set_geometry(), + * or false otherwise. See set_geometry(). + */ INLINE bool MouseWatcher:: has_geometry() const { return !_geometry.is_null(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_geometry -// Access: Published -// Description: Returns the node that has been set as the software -// mouse pointer, or NULL if no node has been set. See -// has_geometry() and set_geometry(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that has been set as the software mouse pointer, or NULL + * if no node has been set. See has_geometry() and set_geometry(). + */ INLINE PandaNode *MouseWatcher:: get_geometry() const { return _geometry; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_geometry -// Access: Published -// Description: Stops the use of the software cursor set up via -// set_geometry(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the use of the software cursor set up via set_geometry(). + */ INLINE void MouseWatcher:: clear_geometry() { _geometry.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_extra_handler -// Access: Published -// Description: As an optimization for the C++ Gui, an extra handler -// can be registered with a mouseWatcher so that events -// can be dealt with much sooner. -//////////////////////////////////////////////////////////////////// +/** + * As an optimization for the C++ Gui, an extra handler can be registered with + * a mouseWatcher so that events can be dealt with much sooner. + */ INLINE void MouseWatcher:: set_extra_handler(EventHandler *eh) { _eh = eh; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_extra_handler -// Access: Published -// Description: As an optimization for the C++ Gui, an extra handler -// can be registered with a mouseWatcher so that events -// can be dealt with much sooner. -//////////////////////////////////////////////////////////////////// +/** + * As an optimization for the C++ Gui, an extra handler can be registered with + * a mouseWatcher so that events can be dealt with much sooner. + */ INLINE EventHandler *MouseWatcher:: get_extra_handler() const { return _eh; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_modifier_buttons -// Access: Public -// Description: Sets the buttons that should be monitored as modifier -// buttons for generating events to the -// MouseWatcherRegions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the buttons that should be monitored as modifier buttons for + * generating events to the MouseWatcherRegions. + */ INLINE void MouseWatcher:: set_modifier_buttons(const ModifierButtons &mods) { _mods = mods; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_modifier_buttons -// Access: Published -// Description: Returns the set of buttons that are being monitored -// as modifier buttons, as well as their current state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of buttons that are being monitored as modifier buttons, as + * well as their current state. + */ INLINE ModifierButtons MouseWatcher:: get_modifier_buttons() const { return _mods; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_display_region -// Access: Published -// Description: Constrains the MouseWatcher to watching the mouse -// within a particular indicated region of the screen. -// DataNodes parented under the MouseWatcher will -// observe the mouse and keyboard events only when the -// mouse is within the indicated region, and the -// observed range will be from -1 .. 1 across the -// region. -// -// Do not delete the DisplayRegion while it is owned by -// the MouseWatcher. -//////////////////////////////////////////////////////////////////// +/** + * Constrains the MouseWatcher to watching the mouse within a particular + * indicated region of the screen. DataNodes parented under the MouseWatcher + * will observe the mouse and keyboard events only when the mouse is within + * the indicated region, and the observed range will be from -1 .. 1 across + * the region. + * + * Do not delete the DisplayRegion while it is owned by the MouseWatcher. + */ INLINE void MouseWatcher:: set_display_region(DisplayRegion *dr) { _display_region = dr; _button_down_display_region = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_display_region -// Access: Published -// Description: Removes the display region constraint from the -// MouseWatcher, and restores it to the default behavior -// of watching the whole window. -//////////////////////////////////////////////////////////////////// +/** + * Removes the display region constraint from the MouseWatcher, and restores + * it to the default behavior of watching the whole window. + */ INLINE void MouseWatcher:: clear_display_region() { _display_region = NULL; _button_down_display_region = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_display_region -// Access: Published -// Description: Returns the display region the MouseWatcher is -// constrained to by set_display_region(), or NULL if it -// is not constrained. -//////////////////////////////////////////////////////////////////// +/** + * Returns the display region the MouseWatcher is constrained to by + * set_display_region(), or NULL if it is not constrained. + */ INLINE DisplayRegion *MouseWatcher:: get_display_region() const { return _display_region; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::has_display_region -// Access: Published -// Description: Returns true if the MouseWatcher has been constrained -// to a particular region of the screen via -// set_display_region(), or false otherwise. If this -// returns true, get_display_region() may be used to -// return the particular region. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the MouseWatcher has been constrained to a particular + * region of the screen via set_display_region(), or false otherwise. If this + * returns true, get_display_region() may be used to return the particular + * region. + */ INLINE bool MouseWatcher:: has_display_region() const { return (_display_region != (DisplayRegion *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_inactivity_timeout -// Access: Published -// Description: Sets an inactivity timeout on the mouse activity. -// When this timeout (in seconds) is exceeded with no -// keyboard or mouse activity, all currently-held -// buttons are automatically released. This is intended -// to help protect against people who inadvertently (or -// intentionally) leave a keyboard key stuck down and -// then wander away from the keyboard. -// -// Also, when this timeout expires, the event specified -// by set_inactivity_timeout_event() will be generated. -//////////////////////////////////////////////////////////////////// +/** + * Sets an inactivity timeout on the mouse activity. When this timeout (in + * seconds) is exceeded with no keyboard or mouse activity, all currently-held + * buttons are automatically released. This is intended to help protect + * against people who inadvertently (or intentionally) leave a keyboard key + * stuck down and then wander away from the keyboard. + * + * Also, when this timeout expires, the event specified by + * set_inactivity_timeout_event() will be generated. + */ INLINE void MouseWatcher:: set_inactivity_timeout(double timeout) { _has_inactivity_timeout = true; @@ -569,37 +441,28 @@ set_inactivity_timeout(double timeout) { note_activity(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::has_inactivity_timeout -// Access: Published -// Description: Returns true if an inactivity timeout has been set, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an inactivity timeout has been set, false otherwise. + */ INLINE bool MouseWatcher:: has_inactivity_timeout() const { return _has_inactivity_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_inactivity_timeout -// Access: Published -// Description: Returns the inactivity timeout that has been set. -// It is an error to call this if -// has_inactivity_timeout() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the inactivity timeout that has been set. It is an error to call + * this if has_inactivity_timeout() returns false. + */ INLINE double MouseWatcher:: get_inactivity_timeout() const { nassertr(_has_inactivity_timeout, 0.0); return _inactivity_timeout; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_inactivity_timeout -// Access: Published -// Description: Removes the inactivity timeout and restores the -// MouseWatcher to its default behavior of allowing a -// key to be held indefinitely. -//////////////////////////////////////////////////////////////////// +/** + * Removes the inactivity timeout and restores the MouseWatcher to its default + * behavior of allowing a key to be held indefinitely. + */ INLINE void MouseWatcher:: clear_inactivity_timeout() { _has_inactivity_timeout = false; @@ -607,36 +470,28 @@ clear_inactivity_timeout() { note_activity(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_inactivity_timeout_event -// Access: Published -// Description: Specifies the event string that will be generated -// when the inactivity timeout counter expires. See -// set_inactivity_timeout(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the event string that will be generated when the inactivity + * timeout counter expires. See set_inactivity_timeout(). + */ INLINE void MouseWatcher:: set_inactivity_timeout_event(const string &event) { _inactivity_timeout_event = event; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_inactivity_timeout_event -// Access: Published -// Description: Returns the event string that will be generated -// when the inactivity timeout counter expires. See -// set_inactivity_timeout(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the event string that will be generated when the inactivity timeout + * counter expires. See set_inactivity_timeout(). + */ INLINE const string &MouseWatcher:: get_inactivity_timeout_event() const { return _inactivity_timeout_event; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::within_region -// Access: Protected -// Description: Called internally to indicate the mouse pointer has -// moved within the indicated region's boundaries. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to indicate the mouse pointer has moved within the + * indicated region's boundaries. + */ INLINE void MouseWatcher:: within_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { region->within_region(param); @@ -646,12 +501,10 @@ within_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::without_region -// Access: Protected -// Description: Called internally to indicate the mouse pointer has -// moved outside of the indicated region's boundaries. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to indicate the mouse pointer has moved outside of the + * indicated region's boundaries. + */ INLINE void MouseWatcher:: without_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { if (_enter_multiple) { @@ -661,43 +514,34 @@ without_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { throw_event_pattern(_without_pattern, region, ButtonHandle::none()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_trail_log -// Access: Published -// Description: Clears the mouse trail log. This does not prevent -// further accumulation of the log given future events. -//////////////////////////////////////////////////////////////////// +/** + * Clears the mouse trail log. This does not prevent further accumulation of + * the log given future events. + */ INLINE void MouseWatcher:: clear_trail_log() { _trail_log->clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_trail_log -// Access: Published -// Description: Obtain the mouse trail log. This is a PointerEventList. -// Does not make a copy, therefore, this PointerEventList -// will be updated each time process_events gets called. -// -// To use trail logging, you need to enable the -// generation of pointer events in the -// GraphicsWindowInputDevice and set the trail log -// duration in the MouseWatcher. Otherwise, the -// trail log will be empty. -//////////////////////////////////////////////////////////////////// +/** + * Obtain the mouse trail log. This is a PointerEventList. Does not make a + * copy, therefore, this PointerEventList will be updated each time + * process_events gets called. + * + * To use trail logging, you need to enable the generation of pointer events + * in the GraphicsWindowInputDevice and set the trail log duration in the + * MouseWatcher. Otherwise, the trail log will be empty. + */ INLINE CPT(PointerEventList) MouseWatcher:: get_trail_log() const { return _trail_log; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::num_trail_recent -// Access: Published -// Description: This counter indicates how many events were added -// to the trail log this frame. The trail log is -// updated once per frame, during the process_events -// operation. -//////////////////////////////////////////////////////////////////// +/** + * This counter indicates how many events were added to the trail log this + * frame. The trail log is updated once per frame, during the process_events + * operation. + */ INLINE int MouseWatcher:: num_trail_recent() const { return _num_trail_recent; diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 8bc19ca2d7..7f6355c135 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -1,16 +1,15 @@ -// Filename: mouseWatcher.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcher.cxx + * @author drose + * @date 2002-03-12 + */ #include "mouseWatcher.h" #include "config_tform.h" @@ -38,11 +37,9 @@ TypeHandle MouseWatcher::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseWatcher:: MouseWatcher(const string &name) : DataNode(name) @@ -85,34 +82,27 @@ MouseWatcher(const string &name) : _last_activity = 0.0; _inactivity_state = IS_active; - // When this flag is true, the mouse pointer is allowed to be - // "entered" into multiple regions simultaneously; when false, it - // will only be "within" multiple regions, but "entered" into the - // topmost of those. + // When this flag is true, the mouse pointer is allowed to be "entered" into + // multiple regions simultaneously; when false, it will only be "within" + // multiple regions, but "entered" into the topmost of those. _enter_multiple = false; - // When this flag is true, moving the pointer into a region is - // enough to click it. The click is simulated with mouse button - // one. + // When this flag is true, moving the pointer into a region is enough to + // click it. The click is simulated with mouse button one. _implicit_click = false; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseWatcher:: ~MouseWatcher() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::remove_region -// Access: Published -// Description: Removes the indicated region from the group. -// Returns true if it was successfully removed, or false -// if it wasn't there in the first place. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated region from the group. Returns true if it was + * successfully removed, or false if it wasn't there in the first place. + */ bool MouseWatcher:: remove_region(MouseWatcherRegion *region) { LightMutexHolder holder(_lock); @@ -131,15 +121,11 @@ remove_region(MouseWatcherRegion *region) { return MouseWatcherBase::do_remove_region(region); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_over_region -// Access: Published -// Description: Returns the preferred region the mouse is over. In -// the case of overlapping regions, the region with the -// largest sort order is preferred; if two regions have -// the same sort order, then the smaller region is -// preferred. -//////////////////////////////////////////////////////////////////// +/** + * Returns the preferred region the mouse is over. In the case of overlapping + * regions, the region with the largest sort order is preferred; if two + * regions have the same sort order, then the smaller region is preferred. + */ MouseWatcherRegion *MouseWatcher:: get_over_region(const LPoint2 &pos) const { LightMutexHolder holder(_lock); @@ -149,27 +135,23 @@ get_over_region(const LPoint2 &pos) const { return get_preferred_region(regions); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::add_group -// Access: Published -// Description: Adds the indicated group of regions to the set of -// regions the MouseWatcher will monitor each frame. -// -// Since the MouseWatcher itself inherits from -// MouseWatcherBase, this operation is normally not -// necessary--you can simply add the Regions you care -// about one at a time. Adding a complete group is -// useful when you may want to explicitly remove the -// regions as a group later. -// -// Returns true if the group was successfully added, or -// false if it was already on the list. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated group of regions to the set of regions the MouseWatcher + * will monitor each frame. + * + * Since the MouseWatcher itself inherits from MouseWatcherBase, this + * operation is normally not necessary--you can simply add the Regions you + * care about one at a time. Adding a complete group is useful when you may + * want to explicitly remove the regions as a group later. + * + * Returns true if the group was successfully added, or false if it was + * already on the list. + */ bool MouseWatcher:: add_group(MouseWatcherGroup *group) { LightMutexHolder holder(_lock); - // See if the group is in the set/vector already + // See if the group is in the setvector already PT(MouseWatcherGroup) pt = group; Groups::const_iterator gi = find(_groups.begin(), _groups.end(), pt); @@ -190,14 +172,11 @@ add_group(MouseWatcherGroup *group) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::remove_group -// Access: Published -// Description: Removes the indicated group from the set of extra -// groups associated with the MouseWatcher. Returns -// true if successful, or false if the group was already -// removed or was never added via add_group(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated group from the set of extra groups associated with + * the MouseWatcher. Returns true if successful, or false if the group was + * already removed or was never added via add_group(). + */ bool MouseWatcher:: remove_group(MouseWatcherGroup *group) { LightMutexHolder holder(_lock); @@ -226,7 +205,7 @@ remove_group(MouseWatcherGroup *group) { } #endif // NDEBUG - // See if the group is in the set/vector + // See if the group is in the setvector PT(MouseWatcherGroup) pt = group; Groups::iterator gi = find(_groups.begin(), _groups.end(), pt); @@ -240,18 +219,15 @@ remove_group(MouseWatcherGroup *group) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::replace_group -// Access: Published -// Description: Atomically removes old_group from the MouseWatcher, -// and replaces it with new_group. Presumably old_group -// and new_group might have some regions in common; -// these are handled properly. -// -// If old_group is not already present, simply adds -// new_group and returns false. Otherwise, removes -// old_group and adds new_group, and then returns true. -//////////////////////////////////////////////////////////////////// +/** + * Atomically removes old_group from the MouseWatcher, and replaces it with + * new_group. Presumably old_group and new_group might have some regions in + * common; these are handled properly. + * + * If old_group is not already present, simply adds new_group and returns + * false. Otherwise, removes old_group and adds new_group, and then returns + * true. + */ bool MouseWatcher:: replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { if (old_group == new_group) { @@ -302,9 +278,8 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { } } - // Don't add the new regions--we have no reason to believe these - // should become current; some of them may not even be under the - // mouse. + // Don't add the new regions--we have no reason to believe these should + // become current; some of them may not even be under the mouse. /* // And add the new regions if (!add.empty()) { @@ -352,24 +327,19 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_num_groups -// Access: Published -// Description: Returns the number of separate groups added to the -// MouseWatcher via add_group(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of separate groups added to the MouseWatcher via + * add_group(). + */ int MouseWatcher:: get_num_groups() const { LightMutexHolder holder(_lock); return _groups.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_group -// Access: Published -// Description: Returns the nth group added to the MouseWatcher via -// add_group(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth group added to the MouseWatcher via add_group(). + */ MouseWatcherGroup *MouseWatcher:: get_group(int n) const { LightMutexHolder holder(_lock); @@ -377,14 +347,11 @@ get_group(int n) const { return _groups[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_trail_log_duration -// Access: Published -// Description: If the duration is nonzero, causes the MouseWatcher -// to log the mouse's trail. Events older than the -// specified duration are discarded. If the duration is -// zero, logging is disabled. -//////////////////////////////////////////////////////////////////// +/** + * If the duration is nonzero, causes the MouseWatcher to log the mouse's + * trail. Events older than the specified duration are discarded. If the + * duration is zero, logging is disabled. + */ void MouseWatcher:: set_trail_log_duration(double duration) { if (duration < 0.0) { @@ -394,17 +361,13 @@ set_trail_log_duration(double duration) { discard_excess_trail_log(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::discard_excess_trail_log -// Access: Private -// Description: Discards trail log events whose age exceed the -// desired log duration. Keeps one event that is beyond -// the specified age, because otherwise, it is not always -// possible to determine where the mouse was for the -// full logging duration. Also, keeps a minimum of two -// events in the queue. If the duration is zero, this -// method discards all trail events. -//////////////////////////////////////////////////////////////////// +/** + * Discards trail log events whose age exceed the desired log duration. Keeps + * one event that is beyond the specified age, because otherwise, it is not + * always possible to determine where the mouse was for the full logging + * duration. Also, keeps a minimum of two events in the queue. If the + * duration is zero, this method discards all trail events. + */ void MouseWatcher:: discard_excess_trail_log() { if (_trail_log_duration == 0.0) { @@ -421,23 +384,17 @@ discard_excess_trail_log() { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_trail_node -// Access: Published -// Description: Returns a GeomNode that represents the mouse trail. -// The intent is that you should reparent this GeomNode -// to Render2D, and then forget about it. The -// MouseWatcher will continually update the trail node. -// There is only one trail node, it does not create a -// new one each time you call get_trail_node. -// -// This is not a particularly beautiful way to render -// a mouse trail. It is intended more for debugging -// purposes than for finished applications. Even so, -// It is suggested that you might want to apply a line -// thickness and antialias mode to the line --- doing -// so makes it look a lot better. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GeomNode that represents the mouse trail. The intent is that you + * should reparent this GeomNode to Render2D, and then forget about it. The + * MouseWatcher will continually update the trail node. There is only one + * trail node, it does not create a new one each time you call get_trail_node. + * + * This is not a particularly beautiful way to render a mouse trail. It is + * intended more for debugging purposes than for finished applications. Even + * so, It is suggested that you might want to apply a line thickness and + * antialias mode to the line --- doing so makes it look a lot better. + */ PT(GeomNode) MouseWatcher:: get_trail_node() { if (_trail_node == 0) { @@ -447,25 +404,20 @@ get_trail_node() { return _trail_node; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_trail_node -// Access: Published -// Description: If you have previously fetched the trail node -// using get_trail_node, then the MouseWatcher is -// continually updating the trail node every frame. -// Using clear_trail_node causes the MouseWatcher to -// forget the trail node and stop updating it. -//////////////////////////////////////////////////////////////////// +/** + * If you have previously fetched the trail node using get_trail_node, then + * the MouseWatcher is continually updating the trail node every frame. Using + * clear_trail_node causes the MouseWatcher to forget the trail node and stop + * updating it. + */ void MouseWatcher:: clear_trail_node() { _trail_node = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::update_trail_node -// Access: Private -// Description: Causes the trail node to represent the mouse trail. -//////////////////////////////////////////////////////////////////// +/** + * Causes the trail node to represent the mouse trail. + */ void MouseWatcher:: update_trail_node() { if (_trail_node == 0) { @@ -500,21 +452,16 @@ update_trail_node() { _trail_node->add_geom(l_geom); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::note_activity -// Access: Published -// Description: Can be used in conjunction with the inactivity -// timeout to inform the MouseWatcher that the user has -// just performed some action which proves he/she is -// present. It may be necessary to call this for -// external events, such as joystick action, that the -// MouseWatcher might otherwise not know about. This -// will reset the current inactivity timer. When the -// inactivity timer reaches the length of time specified -// by set_inactivity_timeout(), with no keyboard or -// mouse activity and no calls to note_activity(), then -// any buttons held will be automatically released. -//////////////////////////////////////////////////////////////////// +/** + * Can be used in conjunction with the inactivity timeout to inform the + * MouseWatcher that the user has just performed some action which proves + * he/she is present. It may be necessary to call this for external events, + * such as joystick action, that the MouseWatcher might otherwise not know + * about. This will reset the current inactivity timer. When the inactivity + * timer reaches the length of time specified by set_inactivity_timeout(), + * with no keyboard or mouse activity and no calls to note_activity(), then + * any buttons held will be automatically released. + */ void MouseWatcher:: note_activity() { _last_activity = ClockObject::get_global_clock()->get_frame_time(); @@ -536,11 +483,9 @@ note_activity() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcher:: output(ostream &out) const { LightMutexHolder holder(_lock); @@ -556,11 +501,9 @@ output(ostream &out) const { out << " (" << count << " regions)"; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcher:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -579,13 +522,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_over_regions -// Access: Protected -// Description: Fills up the "regions" list with the set of regions -// that the indicated point is over, sorted in order by -// pointer. Assumes the lock is held. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the "regions" list with the set of regions that the indicated + * point is over, sorted in order by pointer. Assumes the lock is held. + */ void MouseWatcher:: get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { nassertv(_lock.debug_is_locked()); @@ -594,8 +534,8 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { PN_stdfloat mx = (pos[0] + 1.0f) * 0.5f * (_frame[1] - _frame[0]) + _frame[0]; PN_stdfloat my = (pos[1] + 1.0f) * 0.5f * (_frame[3] - _frame[2]) + _frame[2]; - // pos[0] = 2.0f * (mx - _frame[0]) / (_frame[1] - _frame[0]) - 1.0f; - // pos[1] = 2.0f * (my - _frame[2]) / (_frame[3] - _frame[2]) - 1.0f; + // pos[0] = 2.0f * (mx - _frame[0]) (_frame[1] - _frame[0]) - 1.0f; pos[1] + // = 2.0f * (my - _frame[2]) (_frame[3] - _frame[2]) - 1.0f; // Ensure the vector is empty before we begin. regions.clear(); @@ -630,21 +570,17 @@ get_over_regions(MouseWatcher::Regions ®ions, const LPoint2 &pos) const { } } - // Now sort the regions by pointer. By convention, the Regions - // vectors are always kept in order by pointer, so we can do easy - // linear comparison and intersection operations. + // Now sort the regions by pointer. By convention, the Regions vectors are + // always kept in order by pointer, so we can do easy linear comparison and + // intersection operations. sort(regions.begin(), regions.end()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::get_preferred_region -// Access: Protected, Static -// Description: Returns the innermost region of all the regions -// indicated in the given vector (usually, the regions -// the mouse is over). This is the "preferred" region -// that gets some special treatment. Assumes the lock -// is already held. -//////////////////////////////////////////////////////////////////// +/** + * Returns the innermost region of all the regions indicated in the given + * vector (usually, the regions the mouse is over). This is the "preferred" + * region that gets some special treatment. Assumes the lock is already held. + */ MouseWatcherRegion *MouseWatcher:: get_preferred_region(const MouseWatcher::Regions ®ions) { if (regions.empty()) { @@ -667,16 +603,13 @@ get_preferred_region(const MouseWatcher::Regions ®ions) { return preferred; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_current_regions -// Access: Protected -// Description: Changes the "current" regions--the one we consider the -// mouse to be over--to the indicated list, and throws -// whatever events are appropriate because of that. -// -// The list passed in is destroyed. Assumes the lock is -// already held. -//////////////////////////////////////////////////////////////////// +/** + * Changes the "current" regions--the one we consider the mouse to be over--to + * the indicated list, and throws whatever events are appropriate because of + * that. + * + * The list passed in is destroyed. Assumes the lock is already held. + */ void MouseWatcher:: set_current_regions(MouseWatcher::Regions ®ions) { nassertv(_lock.debug_is_locked()); @@ -690,8 +623,8 @@ set_current_regions(MouseWatcher::Regions ®ions) { Regions::const_iterator new_ri = regions.begin(); Regions::const_iterator old_ri = _current_regions.begin(); - // Queue up all the new regions so we can send the within patterns - // all at once, after all of the without patterns have been thrown. + // Queue up all the new regions so we can send the within patterns all at + // once, after all of the without patterns have been thrown. vector new_regions; bool any_changes = false; @@ -734,8 +667,8 @@ set_current_regions(MouseWatcher::Regions ®ions) { } if (any_changes) { - // Now that we've compared the two vectors, simply swap them to set - // the new vector. + // Now that we've compared the two vectors, simply swap them to set the + // new vector. _current_regions.swap(regions); // And don't forget to throw all of the new regions' "within" events. @@ -747,15 +680,15 @@ set_current_regions(MouseWatcher::Regions ®ions) { } if (!_enter_multiple) { - // Determine which is the "preferred region", if any. This is the - // topmost region that the mouse cursor is over, and the one that - // we are considered "entered" into. + // Determine which is the "preferred region", if any. This is the topmost + // region that the mouse cursor is over, and the one that we are + // considered "entered" into. MouseWatcherRegion *new_preferred_region = get_preferred_region(_current_regions); if (_button_down && new_preferred_region != _preferred_button_down_region) { - // If the button's being held down, we're only allowed to select - // the preferred button down region. + // If the button's being held down, we're only allowed to select the + // preferred button down region. new_preferred_region = (MouseWatcherRegion *)NULL; } @@ -771,12 +704,9 @@ set_current_regions(MouseWatcher::Regions ®ions) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::clear_current_regions -// Access: Protected -// Description: Empties the set of current regions. Assumes the lock -// is already held. -//////////////////////////////////////////////////////////////////// +/** + * Empties the set of current regions. Assumes the lock is already held. + */ void MouseWatcher:: clear_current_regions() { nassertv(_lock.debug_is_locked()); @@ -808,12 +738,10 @@ clear_current_regions() { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::do_show_regions -// Access: Protected, Virtual -// Description: The protected implementation of show_regions(). This -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of show_regions(). This assumes the lock is + * already held. + */ void MouseWatcher:: do_show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { @@ -831,12 +759,10 @@ do_show_regions(const NodePath &render2d, const string &bin_name, #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::do_hide_regions -// Access: Protected, Virtual -// Description: The protected implementation of hide_regions(). This -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of hide_regions(). This assumes the lock is + * already held. + */ void MouseWatcher:: do_hide_regions() { MouseWatcherBase::do_hide_regions(); @@ -852,20 +778,15 @@ do_hide_regions() { } #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::intersect_regions -// Access: Protected, Static -// Description: Computes the list of regions that are in both -// regions_a and regions_b, as well as the list of -// regions only in regions_a, and the list of regions -// only in regions_b. Any or all of the three output -// lists may be the same object, but they must be -// different objects from both of the input lists. -// -// It is assumed that both vectors are already sorted in -// pointer order. It is also assumed that any relevant -// locks are already held. -//////////////////////////////////////////////////////////////////// +/** + * Computes the list of regions that are in both regions_a and regions_b, as + * well as the list of regions only in regions_a, and the list of regions only + * in regions_b. Any or all of the three output lists may be the same object, + * but they must be different objects from both of the input lists. + * + * It is assumed that both vectors are already sorted in pointer order. It is + * also assumed that any relevant locks are already held. + */ void MouseWatcher:: intersect_regions(MouseWatcher::Regions &only_a, MouseWatcher::Regions &only_b, @@ -896,14 +817,11 @@ intersect_regions(MouseWatcher::Regions &only_a, } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::remove_region_from -// Access: Protected, Static -// Description: Removes the indicated region from the given vector. -// Assumes the vector is sorted in pointer order. -// Returns true if removed, false if it wasn't there. -// Assumes any relevent locks are already held. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated region from the given vector. Assumes the vector is + * sorted in pointer order. Returns true if removed, false if it wasn't + * there. Assumes any relevent locks are already held. + */ bool MouseWatcher:: remove_region_from(MouseWatcher::Regions ®ions, MouseWatcherRegion *region) { @@ -918,12 +836,10 @@ remove_region_from(MouseWatcher::Regions ®ions, return false; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::has_region_in -// Access: Protected, Static -// Description: Returns true if the indicated region is a member of -// the given sorted list, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated region is a member of the given sorted list, + * false otherwise. + */ bool MouseWatcher:: has_region_in(const MouseWatcher::Regions ®ions, MouseWatcherRegion *region) { @@ -932,12 +848,10 @@ has_region_in(const MouseWatcher::Regions ®ions, return (ri != regions.end() && (*ri) == ptr); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::throw_event_pattern -// Access: Protected -// Description: Throws an event associated with the indicated region, -// using the given pattern. -//////////////////////////////////////////////////////////////////// +/** + * Throws an event associated with the indicated region, using the given + * pattern. + */ void MouseWatcher:: throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, const ButtonHandle &button) { @@ -953,8 +867,8 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, string button_name; if (button != ButtonHandle::none()) { if (!_mods.has_button(button)) { - // We only prepend modifier names for buttons which are not - // themselves modifiers. + // We only prepend modifier names for buttons which are not themselves + // modifiers. button_name = _mods.get_prefix(); } button_name += button.get_name(); @@ -990,12 +904,10 @@ throw_event_pattern(const string &pattern, const MouseWatcherRegion *region, } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::move -// Access: Protected -// Description: Records the indicated mouse or keyboard button as -// being moved from last position. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated mouse or keyboard button as being moved from last + * position. + */ void MouseWatcher:: move() { nassertv(_lock.debug_is_locked()); @@ -1009,12 +921,9 @@ move() { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::press -// Access: Protected -// Description: Records the indicated mouse or keyboard button as -// being depressed. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated mouse or keyboard button as being depressed. + */ void MouseWatcher:: press(ButtonHandle button, bool keyrepeat) { nassertv(_lock.debug_is_locked()); @@ -1045,33 +954,28 @@ press(ButtonHandle button, bool keyrepeat) { } } else { - // It's a keyboard button; therefore, send the event to every - // region that wants keyboard buttons, regardless of the mouse - // position. + // It's a keyboard button; therefore, send the event to every region that + // wants keyboard buttons, regardless of the mouse position. if (_preferred_region != (MouseWatcherRegion *)NULL) { - // Our current region, the one under the mouse, always get - // all the keyboard events, even if it doesn't set its - // keyboard flag. + // Our current region, the one under the mouse, always get all the + // keyboard events, even if it doesn't set its keyboard flag. _preferred_region->press(param); consider_keyboard_suppress(_preferred_region); } if ((_internal_suppress & MouseWatcherRegion::SF_other_button) == 0) { - // All the other regions only get the keyboard events if they - // set their global keyboard flag, *and* the current region does - // not suppress keyboard buttons. + // All the other regions only get the keyboard events if they set their + // global keyboard flag, *and* the current region does not suppress + // keyboard buttons. param.set_outside(true); global_keyboard_press(param); } } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::release -// Access: Protected -// Description: Records the indicated mouse or keyboard button as -// being released. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated mouse or keyboard button as being released. + */ void MouseWatcher:: release(ButtonHandle button) { nassertv(_lock.debug_is_locked()); @@ -1082,12 +986,12 @@ release(ButtonHandle button) { param.set_mouse(_mouse); if (MouseButton::is_mouse_button(button)) { - // Button up. Send the up event associated with the region(s) we - // were over when the button went down. + // Button up. Send the up event associated with the region(s) we were + // over when the button went down. - // There is some danger of losing button-up events here. If - // more than one button goes down together, we won't detect - // both of the button-up events properly. + // There is some danger of losing button-up events here. If more than one + // button goes down together, we won't detect both of the button-up events + // properly. if (_preferred_button_down_region != (MouseWatcherRegion *)NULL) { param.set_outside(_preferred_button_down_region != _preferred_region); _preferred_button_down_region->release(param); @@ -1099,9 +1003,8 @@ release(ButtonHandle button) { _preferred_button_down_region = (MouseWatcherRegion *)NULL; } else { - // It's a keyboard button; therefore, send the event to every - // region that wants keyboard buttons, regardless of the mouse - // position. + // It's a keyboard button; therefore, send the event to every region that + // wants keyboard buttons, regardless of the mouse position. if (_preferred_region != (MouseWatcherRegion *)NULL) { _preferred_region->release(param); } @@ -1111,12 +1014,9 @@ release(ButtonHandle button) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::keystroke -// Access: Protected -// Description: Records that the indicated keystroke has been -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated keystroke has been generated. + */ void MouseWatcher:: keystroke(int keycode) { nassertv(_lock.debug_is_locked()); @@ -1126,11 +1026,10 @@ keystroke(int keycode) { param.set_modifier_buttons(_mods); param.set_mouse(_mouse); - // Keystrokes go to all those regions that want keyboard events, - // regardless of which is the "preferred" region (that is, without - // respect to the mouse position). However, we do set the outside - // flag according to whether the given region is the preferred - // region or not. + // Keystrokes go to all those regions that want keyboard events, regardless + // of which is the "preferred" region (that is, without respect to the mouse + // position). However, we do set the outside flag according to whether the + // given region is the preferred region or not. Regions::const_iterator ri; for (ri = _regions.begin(); ri != _regions.end(); ++ri) { @@ -1159,12 +1058,10 @@ keystroke(int keycode) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::candidate -// Access: Protected -// Description: Records that the indicated candidate string has been -// highlighted in the IME. -//////////////////////////////////////////////////////////////////// +/** + * Records that the indicated candidate string has been highlighted in the + * IME. + */ void MouseWatcher:: candidate(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { @@ -1175,8 +1072,8 @@ candidate(const wstring &candidate_string, size_t highlight_start, param.set_modifier_buttons(_mods); param.set_mouse(_mouse); - // Candidate strings go to all those regions that want keyboard - // events, exactly like keystrokes, above. + // Candidate strings go to all those regions that want keyboard events, + // exactly like keystrokes, above. Regions::const_iterator ri; for (ri = _regions.begin(); ri != _regions.end(); ++ri) { @@ -1203,13 +1100,11 @@ candidate(const wstring &candidate_string, size_t highlight_start, } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::global_keyboard_press -// Access: Protected -// Description: Calls press() on all regions that are interested in -// receiving global keyboard events, except for the -// current region (which already received this one). -//////////////////////////////////////////////////////////////////// +/** + * Calls press() on all regions that are interested in receiving global + * keyboard events, except for the current region (which already received this + * one). + */ void MouseWatcher:: global_keyboard_press(const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); @@ -1238,13 +1133,11 @@ global_keyboard_press(const MouseWatcherParameter ¶m) { } } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::global_keyboard_release -// Access: Protected -// Description: Calls release() on all regions that are interested in -// receiving global keyboard events, except for the -// current region (which already received this one). -//////////////////////////////////////////////////////////////////// +/** + * Calls release() on all regions that are interested in receiving global + * keyboard events, except for the current region (which already received this + * one). + */ void MouseWatcher:: global_keyboard_release(const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); @@ -1272,12 +1165,10 @@ global_keyboard_release(const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::enter_region -// Access: Protected -// Description: Called internally to indicate the mouse pointer is -// favoring the indicated region. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to indicate the mouse pointer is favoring the indicated + * region. + */ void MouseWatcher:: enter_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); @@ -1291,12 +1182,10 @@ enter_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::exit_region -// Access: Protected -// Description: Called internally to indicate the mouse pointer is no -// longer favoring the indicated region. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to indicate the mouse pointer is no longer favoring the + * indicated region. + */ void MouseWatcher:: exit_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { nassertv(_lock.debug_is_locked()); @@ -1310,12 +1199,10 @@ exit_region(MouseWatcherRegion *region, const MouseWatcherParameter ¶m) { throw_event_pattern(_leave_pattern, region, ButtonHandle::none()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_no_mouse -// Access: Protected -// Description: Called from do_transmit_data() to indicate the mouse -// is not within the window. -//////////////////////////////////////////////////////////////////// +/** + * Called from do_transmit_data() to indicate the mouse is not within the + * window. + */ void MouseWatcher:: set_no_mouse() { nassertv(_lock.debug_is_locked()); @@ -1331,13 +1218,10 @@ set_no_mouse() { clear_current_regions(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::set_mouse -// Access: Protected -// Description: Called from do_transmit_data() to indicate the mouse -// is within the window, and to specify its current -// position. -//////////////////////////////////////////////////////////////////// +/** + * Called from do_transmit_data() to indicate the mouse is within the window, + * and to specify its current position. + */ void MouseWatcher:: set_mouse(const LVecBase2 &xy, const LVecBase2 &pixel_xy) { nassertv(_lock.debug_is_locked()); @@ -1360,18 +1244,14 @@ set_mouse(const LVecBase2 &xy, const LVecBase2 &pixel_xy) { set_current_regions(regions); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::consider_keyboard_suppress -// Access: Private -// Description: If we send any keyboard events to a region that has -// the SF_other_button suppress flag set, that means we -// should not send the keyboard event along the data -// graph. -// -// This method is called as each keyboard event is sent -// to a region; it should update the internal -// _keyboard_suppress bitmask to indicate this. -//////////////////////////////////////////////////////////////////// +/** + * If we send any keyboard events to a region that has the SF_other_button + * suppress flag set, that means we should not send the keyboard event along + * the data graph. + * + * This method is called as each keyboard event is sent to a region; it should + * update the internal _keyboard_suppress bitmask to indicate this. + */ void MouseWatcher:: consider_keyboard_suppress(const MouseWatcherRegion *region) { if ((region->get_suppress_flags() & MouseWatcherRegion::SF_other_button) != 0) { @@ -1379,19 +1259,14 @@ consider_keyboard_suppress(const MouseWatcherRegion *region) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void MouseWatcher:: do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -1400,8 +1275,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, bool activity = false; - // Initially, we do not suppress any events to objects below us in - // the data graph. + // Initially, we do not suppress any events to objects below us in the data + // graph. _internal_suppress = 0; _external_suppress = 0; @@ -1433,8 +1308,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, set_mouse(f, p); } else { - // The mouse is outside the display region, even though it's - // within the window. This is considered not having a mouse. + // The mouse is outside the display region, even though it's within + // the window. This is considered not having a mouse. set_no_mouse(); // This also means we should suppress mouse button events below us. @@ -1470,9 +1345,9 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, _num_trail_recent = _trail_log->get_num_events(); } - // If the mouse is over a particular region, or still considered - // owned by a region because of a recent button-down event, that - // region determines whether we suppress events below us. + // If the mouse is over a particular region, or still considered owned by a + // region because of a recent button-down event, that region determines + // whether we suppress events below us. if (_preferred_region != (MouseWatcherRegion *)NULL) { _internal_suppress |= _preferred_region->get_suppress_flags(); } @@ -1499,8 +1374,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, new_button_events.add_event(be); break; } - // The button was already depressed, so this is really just - // keyrepeat. Fall through. + // The button was already depressed, so this is really just keyrepeat. + // Fall through. case ButtonEvent::T_repeat: _current_buttons_down.set_bit(be._button.get_index()); @@ -1517,8 +1392,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, break; case ButtonEvent::T_keystroke: - // We don't consider "keystroke" an activity event, because it - // might be just keyrepeat. + // We don't consider "keystroke" an activity event, because it might + // be just keyrepeat. keystroke(be._keycode); new_button_events.add_event(be); break; @@ -1530,9 +1405,8 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, break; case ButtonEvent::T_resume_down: - //_current_buttons_down.set_bit(be._button.get_index()); - // Don't call press(), since the button wasn't actually - // pressed just now. + // _current_buttons_down.set_bit(be._button.get_index()); Don't call + // press(), since the button wasn't actually pressed just now. new_button_events.add_event(be); break; @@ -1550,10 +1424,10 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, } if (!input.has_data(_xy_input)) { - // No mouse in the window. We check this down here, below the - // button checking, in case the mouse left the window in the same - // frame it released a button (particularly likely with a - // touchscreen input that's emulating a mouse). + // No mouse in the window. We check this down here, below the button + // checking, in case the mouse left the window in the same frame it + // released a button (particularly likely with a touchscreen input that's + // emulating a mouse). set_no_mouse(); } @@ -1662,16 +1536,12 @@ do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcher::constrain_display_region -// Access: Private -// Description: Constrains the mouse coordinates to within the -// indicated DisplayRegion. If the mouse pointer does -// indeed fall within the DisplayRegion, rescales f and -// p correspondingly, and returns true. If the mouse -// pointer does not fall within the DisplayRegion, -// leaves f and p unchanged, and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Constrains the mouse coordinates to within the indicated DisplayRegion. If + * the mouse pointer does indeed fall within the DisplayRegion, rescales f and + * p correspondingly, and returns true. If the mouse pointer does not fall + * within the DisplayRegion, leaves f and p unchanged, and returns false. + */ bool MouseWatcher:: constrain_display_region(DisplayRegion *display_region, LVecBase2 &f, LVecBase2 &p, @@ -1680,15 +1550,14 @@ constrain_display_region(DisplayRegion *display_region, _button_down_display_region = NULL; } if (_button_down_display_region != NULL) { - // If the button went down over this DisplayRegion, we consider - // the button within the same DisplayRegion until it is released - // (even if it wanders outside the borders). + // If the button went down over this DisplayRegion, we consider the button + // within the same DisplayRegion until it is released (even if it wanders + // outside the borders). display_region = _button_down_display_region; } else { - // If it's a stereo DisplayRegion, we should actually call this - // method twice, once for each eye, in case we have side-by-side - // stereo. + // If it's a stereo DisplayRegion, we should actually call this method + // twice, once for each eye, in case we have side-by-side stereo. if (display_region->is_stereo()) { StereoDisplayRegion *stereo_display_region; DCAST_INTO_R(stereo_display_region, display_region, false); diff --git a/panda/src/tform/mouseWatcher.h b/panda/src/tform/mouseWatcher.h index c5e8c145e1..aa67b1b657 100644 --- a/panda/src/tform/mouseWatcher.h +++ b/panda/src/tform/mouseWatcher.h @@ -1,16 +1,15 @@ -// Filename: mouseWatcher.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcher.h + * @author drose + * @date 2002-03-12 + */ #ifndef MOUSEWATCHER_H #define MOUSEWATCHER_H @@ -37,34 +36,28 @@ class MouseWatcherParameter; class DisplayRegion; -//////////////////////////////////////////////////////////////////// -// Class : MouseWatcher -// Description : This TFormer maintains a list of rectangular regions -// on the screen that are considered special mouse -// regions; typically these will be click buttons. When -// the mouse passes in or out of one of these regions, -// or when a button is clicked while the mouse is in one -// of these regions, an event is thrown. -// -// Mouse events may also be suppressed from the rest of -// the datagraph in these special regions. -// -// This class can also implement a software mouse -// pointer by automatically generating a transform to -// apply to a piece of geometry placed under the 2-d -// scene graph. It will move the geometry around -// according to the mouse's known position. -// -// Finally, this class can keep a record of the mouse -// trail. This is useful if you want to know, not just -// where the mouse is, but the exact sequence of movements -// it took to get there. This information is mainly useful -// for gesture-recognition code. To use trail logging, -// you need to enable the generation of pointer events -// in the GraphicsWindowInputDevice and set the trail -// log duration in the MouseWatcher. Otherwise, the -// trail log will be empty. -//////////////////////////////////////////////////////////////////// +/** + * This TFormer maintains a list of rectangular regions on the screen that are + * considered special mouse regions; typically these will be click buttons. + * When the mouse passes in or out of one of these regions, or when a button + * is clicked while the mouse is in one of these regions, an event is thrown. + * + * Mouse events may also be suppressed from the rest of the datagraph in these + * special regions. + * + * This class can also implement a software mouse pointer by automatically + * generating a transform to apply to a piece of geometry placed under the 2-d + * scene graph. It will move the geometry around according to the mouse's + * known position. + * + * Finally, this class can keep a record of the mouse trail. This is useful + * if you want to know, not just where the mouse is, but the exact sequence of + * movements it took to get there. This information is mainly useful for + * gesture-recognition code. To use trail logging, you need to enable the + * generation of pointer events in the GraphicsWindowInputDevice and set the + * trail log duration in the MouseWatcher. Otherwise, the trail log will be + * empty. + */ class EXPCL_PANDA_TFORM MouseWatcher : public DataNode, public MouseWatcherBase { PUBLISHED: MouseWatcher(const string &name = ""); @@ -212,8 +205,8 @@ private: Thread *current_thread); private: - // This wants to be a set, but because you cannot export sets across - // dlls in windows, we will make it a vector instead + // This wants to be a set, but because you cannot export sets across dlls in + // windows, we will make it a vector instead typedef pvector< PT(MouseWatcherGroup) > Groups; Groups _groups; diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 559508029d..6d86c384f1 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -1,16 +1,15 @@ -// Filename: mouseWatcherBase.cxx -// Created by: rdb (13Jan14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherBase.cxx + * @author rdb + * @date 2014-01-13 + */ #include "mouseWatcherBase.h" #include "lineSegs.h" @@ -19,11 +18,9 @@ TypeHandle MouseWatcherBase::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseWatcherBase:: MouseWatcherBase() : _lock("MouseWatcherBase") @@ -35,33 +32,28 @@ MouseWatcherBase() : #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MouseWatcherBase:: ~MouseWatcherBase() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::add_region -// Access: Published -// Description: Adds the indicated region to the set of regions in -// the group. It is an error to add the same region to -// the set more than once. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated region to the set of regions in the group. It is an + * error to add the same region to the set more than once. + */ void MouseWatcherBase:: add_region(MouseWatcherRegion *region) { PT(MouseWatcherRegion) pt = region; LightMutexHolder holder(_lock); - // We will only bother to check for duplicates in the region list if - // we are building a development Panda. The overhead for doing this - // may be too high if we have many regions. + // We will only bother to check for duplicates in the region list if we are + // building a development Panda. The overhead for doing this may be too + // high if we have many regions. #ifdef _DEBUG - // See if the region is in the set/vector already + // See if the region is in the setvector already Regions::const_iterator ri = find(_regions.begin(), _regions.end(), pt); nassertv(ri == _regions.end()); @@ -79,12 +71,10 @@ add_region(MouseWatcherRegion *region) { _sorted = false; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::has_region -// Access: Published -// Description: Returns true if the indicated region has already been -// added to the MouseWatcherBase, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated region has already been added to the + * MouseWatcherBase, false otherwise. + */ bool MouseWatcherBase:: has_region(MouseWatcherRegion *region) const { LightMutexHolder holder(_lock); @@ -102,26 +92,21 @@ has_region(MouseWatcherRegion *region) const { return (ri != _regions.end()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::remove_region -// Access: Published -// Description: Removes the indicated region from the group. -// Returns true if it was successfully removed, or false -// if it wasn't there in the first place. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated region from the group. Returns true if it was + * successfully removed, or false if it wasn't there in the first place. + */ bool MouseWatcherBase:: remove_region(MouseWatcherRegion *region) { LightMutexHolder holder(_lock); return do_remove_region(region); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::find_region -// Access: Published -// Description: Returns a pointer to the first region found with the -// indicated name. If multiple regions share the same -// name, the one that is returned is indeterminate. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the first region found with the indicated name. If + * multiple regions share the same name, the one that is returned is + * indeterminate. + */ MouseWatcherRegion *MouseWatcherBase:: find_region(const string &name) const { LightMutexHolder holder(_lock); @@ -137,11 +122,9 @@ find_region(const string &name) const { return (MouseWatcherRegion *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::clear_regions -// Access: Published -// Description: Removes all the regions from the group. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the regions from the group. + */ void MouseWatcherBase:: clear_regions() { LightMutexHolder holder(_lock); @@ -157,24 +140,18 @@ clear_regions() { #endif // NDEBUG } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::sort_regions -// Access: Published -// Description: Sorts all the regions in this group into pointer -// order. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the regions in this group into pointer order. + */ void MouseWatcherBase:: sort_regions() { LightMutexHolder holder(_lock); do_sort_regions(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::is_sorted -// Access: Published -// Description: Returns true if the group has already been sorted, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the group has already been sorted, false otherwise. + */ bool MouseWatcherBase:: is_sorted() const { LightMutexHolder holder(_lock); @@ -182,11 +159,9 @@ is_sorted() const { return _sorted; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::get_num_regions -// Access: Published -// Description: Returns the number of regions in the group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of regions in the group. + */ int MouseWatcherBase:: get_num_regions() const { LightMutexHolder holder(_lock); @@ -194,14 +169,11 @@ get_num_regions() const { return _regions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::get_region -// Access: Published -// Description: Returns the nth region of the group; returns NULL if -// there is no nth region. Note that this is not -// thread-safe; another thread might have removed the -// nth region before you called this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth region of the group; returns NULL if there is no nth + * region. Note that this is not thread-safe; another thread might have + * removed the nth region before you called this method. + */ MouseWatcherRegion *MouseWatcherBase:: get_region(int n) const { LightMutexHolder holder(_lock); @@ -211,21 +183,17 @@ get_region(int n) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcherBase:: output(ostream &out) const { out << "MouseWatcherGroup (" << _regions.size() << " regions)"; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcherBase:: write(ostream &out, int indent_level) const { LightMutexHolder holder(_lock); @@ -238,14 +206,11 @@ write(ostream &out, int indent_level) const { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::show_regions -// Access: Published -// Description: Enables the visualization of all of the regions -// handled by this MouseWatcherBase. The supplied -// NodePath should be the root of the 2-d scene graph -// for the window. -//////////////////////////////////////////////////////////////////// +/** + * Enables the visualization of all of the regions handled by this + * MouseWatcherBase. The supplied NodePath should be the root of the 2-d + * scene graph for the window. + */ void MouseWatcherBase:: show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { LightMutexHolder holder(_lock); @@ -254,13 +219,10 @@ show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::set_color -// Access: Published -// Description: Specifies the color used to draw the region -// rectangles for the regions visualized by -// show_regions(). -//////////////////////////////////////////////////////////////////// +/** + * Specifies the color used to draw the region rectangles for the regions + * visualized by show_regions(). + */ void MouseWatcherBase:: set_color(const LColor &color) { LightMutexHolder holder(_lock); @@ -271,12 +233,9 @@ set_color(const LColor &color) { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::hide_regions -// Access: Published -// Description: Stops the visualization created by a previous call to -// show_regions(). -//////////////////////////////////////////////////////////////////// +/** + * Stops the visualization created by a previous call to show_regions(). + */ void MouseWatcherBase:: hide_regions() { LightMutexHolder holder(_lock); @@ -285,12 +244,9 @@ hide_regions() { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::update_regions -// Access: Published -// Description: Refreshes the visualization created by -// show_regions(). -//////////////////////////////////////////////////////////////////// +/** + * Refreshes the visualization created by show_regions(). + */ void MouseWatcherBase:: update_regions() { LightMutexHolder holder(_lock); @@ -299,12 +255,10 @@ update_regions() { #endif // NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::do_sort_regions -// Access: Protected -// Description: Sorts all the regions in this group into pointer -// order. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Sorts all the regions in this group into pointer order. Assumes the lock + * is already held. + */ void MouseWatcherBase:: do_sort_regions() { if (!_sorted) { @@ -313,12 +267,10 @@ do_sort_regions() { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::do_remove_region -// Access: Protected -// Description: The internal implementation of remove_region(); -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The internal implementation of remove_region(); assumes the lock is already + * held. + */ bool MouseWatcherBase:: do_remove_region(MouseWatcherRegion *region) { // See if the region is in the vector. @@ -355,12 +307,10 @@ do_remove_region(MouseWatcherRegion *region) { } #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::do_show_regions -// Access: Protected, Virtual -// Description: The protected implementation of show_regions(). This -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of show_regions(). This assumes the lock is + * already held. + */ void MouseWatcherBase:: do_show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { @@ -373,12 +323,10 @@ do_show_regions(const NodePath &render2d, const string &bin_name, #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::do_hide_regions -// Access: Protected, Virtual -// Description: The protected implementation of hide_regions(). This -// assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * The protected implementation of hide_regions(). This assumes the lock is + * already held. + */ void MouseWatcherBase:: do_hide_regions() { _show_regions_root.remove_node(); @@ -388,12 +336,10 @@ do_hide_regions() { #endif // NDEBUG #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::do_update_regions -// Access: Protected -// Description: Internally regenerates the show_regions() -// visualization. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Internally regenerates the show_regions() visualization. Assumes the lock + * is already held. + */ void MouseWatcherBase:: do_update_regions() { nassertv(_lock.debug_is_locked()); @@ -413,13 +359,11 @@ do_update_regions() { #ifndef NDEBUG -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherBase::make_viz_region -// Access: Private -// Description: Creates a node to represent the indicated region, and -// attaches it to the _show_regions_root. Does not add -// it to _vizzes. Assumes the lock is already held. -//////////////////////////////////////////////////////////////////// +/** + * Creates a node to represent the indicated region, and attaches it to the + * _show_regions_root. Does not add it to _vizzes. Assumes the lock is + * already held. + */ PandaNode *MouseWatcherBase:: make_viz_region(MouseWatcherRegion *region) { nassertr(_lock.debug_is_locked(), NULL); diff --git a/panda/src/tform/mouseWatcherBase.h b/panda/src/tform/mouseWatcherBase.h index c99ac726d1..962adc53b5 100644 --- a/panda/src/tform/mouseWatcherBase.h +++ b/panda/src/tform/mouseWatcherBase.h @@ -1,16 +1,15 @@ -// Filename: mouseWatcherBase.h -// Created by: rdb (13Jan14) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherBase.h + * @author rdb + * @date 2014-01-13 + */ #ifndef MOUSEWATCHERBASE_H #define MOUSEWATCHERBASE_H @@ -23,14 +22,12 @@ #include "nodePath.h" #include "lightMutex.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseWatcherBase -// Description : This represents a collection of MouseWatcherRegions -// that may be managed as a group. This is the base -// class for both MouseWatcherGroup and MouseWatcher, -// and exists so that we don't have to make MouseWatcher -// inherit from ReferenceCount more than once. -//////////////////////////////////////////////////////////////////// +/** + * This represents a collection of MouseWatcherRegions that may be managed as + * a group. This is the base class for both MouseWatcherGroup and + * MouseWatcher, and exists so that we don't have to make MouseWatcher inherit + * from ReferenceCount more than once. + */ class EXPCL_PANDA_TFORM MouseWatcherBase { public: MouseWatcherBase(); @@ -78,9 +75,9 @@ protected: Regions _regions; bool _sorted; - // This mutex protects the above list of regions, as well as the - // below list of vizzes. It is also referenced directly by - // MouseWatcher, a derived class. + // This mutex protects the above list of regions, as well as the below list + // of vizzes. It is also referenced directly by MouseWatcher, a derived + // class. LightMutex _lock; private: diff --git a/panda/src/tform/mouseWatcherGroup.cxx b/panda/src/tform/mouseWatcherGroup.cxx index 60629bb1f1..42f06c8c84 100644 --- a/panda/src/tform/mouseWatcherGroup.cxx +++ b/panda/src/tform/mouseWatcherGroup.cxx @@ -1,16 +1,15 @@ -// Filename: mouseWatcherGroup.cxx -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherGroup.cxx + * @author drose + * @date 2001-07-02 + */ #include "mouseWatcherGroup.h" diff --git a/panda/src/tform/mouseWatcherGroup.h b/panda/src/tform/mouseWatcherGroup.h index bab2b497e1..22d5b19382 100644 --- a/panda/src/tform/mouseWatcherGroup.h +++ b/panda/src/tform/mouseWatcherGroup.h @@ -1,16 +1,15 @@ -// Filename: mouseWatcherGroup.h -// Created by: drose (02Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherGroup.h + * @author drose + * @date 2001-07-02 + */ #ifndef MOUSEWATCHERGROUP_H #define MOUSEWATCHERGROUP_H @@ -19,13 +18,11 @@ #include "mouseWatcherBase.h" #include "referenceCount.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseWatcherGroup -// Description : This represents a collection of MouseWatcherRegions -// that may be managed as a group. The implementation -// for this is in MouseWatcherBase; this class exists -// so that we can inherit from ReferenceCount. -//////////////////////////////////////////////////////////////////// +/** + * This represents a collection of MouseWatcherRegions that may be managed as + * a group. The implementation for this is in MouseWatcherBase; this class + * exists so that we can inherit from ReferenceCount. + */ class EXPCL_PANDA_TFORM MouseWatcherGroup : public MouseWatcherBase, public ReferenceCount { public: diff --git a/panda/src/tform/mouseWatcherParameter.I b/panda/src/tform/mouseWatcherParameter.I index b6775af2ba..4983fcfda0 100644 --- a/panda/src/tform/mouseWatcherParameter.I +++ b/panda/src/tform/mouseWatcherParameter.I @@ -1,34 +1,28 @@ -// Filename: mouseWatcherParameter.I -// Created by: drose (06Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherParameter.I + * @author drose + * @date 2001-07-06 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseWatcherParameter:: MouseWatcherParameter() { _keycode = 0; _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseWatcherParameter:: MouseWatcherParameter(const MouseWatcherParameter ©) : _button(copy._button), @@ -39,11 +33,9 @@ MouseWatcherParameter(const MouseWatcherParameter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MouseWatcherParameter:: operator = (const MouseWatcherParameter ©) { _button = copy._button; @@ -53,35 +45,27 @@ operator = (const MouseWatcherParameter ©) { _flags = copy._flags; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseWatcherParameter:: ~MouseWatcherParameter() { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_button -// Access: Public -// Description: Sets the mouse or keyboard button that generated this -// event, if any. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mouse or keyboard button that generated this event, if any. + */ INLINE void MouseWatcherParameter:: set_button(const ButtonHandle &button) { _button = button; _flags |= F_has_button; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_keyrepeat -// Access: Public -// Description: Sets the state of the "keyrepeat" flag. This is true -// if a button-press event was generated due to -// keyrepeat, or false if it is an original button -// press. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the "keyrepeat" flag. This is true if a button-press + * event was generated due to keyrepeat, or false if it is an original button + * press. + */ INLINE void MouseWatcherParameter:: set_keyrepeat(bool flag) { if (flag) { @@ -91,23 +75,18 @@ set_keyrepeat(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_keycode -// Access: Public -// Description: Sets the keycode associated with this event, if any. -//////////////////////////////////////////////////////////////////// +/** + * Sets the keycode associated with this event, if any. + */ INLINE void MouseWatcherParameter:: set_keycode(int keycode) { _keycode = keycode; _flags |= F_has_keycode; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_candidate -// Access: Public -// Description: Sets the candidate string associated with this event, -// if any. -//////////////////////////////////////////////////////////////////// +/** + * Sets the candidate string associated with this event, if any. + */ INLINE void MouseWatcherParameter:: set_candidate(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, @@ -119,37 +98,30 @@ set_candidate(const wstring &candidate_string, _flags |= F_has_candidate; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_modifier_buttons -// Access: Public -// Description: Sets the modifier buttons that were being held while -// this event was generated. -//////////////////////////////////////////////////////////////////// +/** + * Sets the modifier buttons that were being held while this event was + * generated. + */ INLINE void MouseWatcherParameter:: set_modifier_buttons(const ModifierButtons &mods) { _mods = mods; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_mouse -// Access: Public -// Description: Sets the mouse position that was current at the time -// the event was generated. -//////////////////////////////////////////////////////////////////// +/** + * Sets the mouse position that was current at the time the event was + * generated. + */ INLINE void MouseWatcherParameter:: set_mouse(const LPoint2 &mouse) { _mouse = mouse; _flags |= F_has_mouse; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::set_outside -// Access: Public -// Description: Sets the state of the "outside" flag. This is true -// if the mouse was outside the region at the time the -// event was generated, false otherwise. This only has -// meaning for "release" events. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the "outside" flag. This is true if the mouse was + * outside the region at the time the event was generated, false otherwise. + * This only has meaning for "release" events. + */ INLINE void MouseWatcherParameter:: set_outside(bool flag) { if (flag) { @@ -159,185 +131,144 @@ set_outside(bool flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::has_button -// Access: Published -// Description: Returns true if this parameter has an associated -// mouse or keyboard button, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this parameter has an associated mouse or keyboard button, + * false otherwise. + */ INLINE bool MouseWatcherParameter:: has_button() const { return (_flags & F_has_button) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_button -// Access: Published -// Description: Returns the mouse or keyboard button associated with -// this event. If has_button(), above, returns false, -// this returns ButtonHandle::none(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the mouse or keyboard button associated with this event. If + * has_button(), above, returns false, this returns ButtonHandle::none(). + */ INLINE ButtonHandle MouseWatcherParameter:: get_button() const { return _button; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::is_keyrepeat -// Access: Published -// Description: Returns true if the button-down even was generated -// due to keyrepeat, or false if it was an original -// button down. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the button-down even was generated due to keyrepeat, or + * false if it was an original button down. + */ INLINE bool MouseWatcherParameter:: is_keyrepeat() const { return (_flags & F_is_keyrepeat) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::has_keycode -// Access: Published -// Description: Returns true if this parameter has an associated -// keycode, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this parameter has an associated keycode, false otherwise. + */ INLINE bool MouseWatcherParameter:: has_keycode() const { return (_flags & F_has_keycode) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_keycode -// Access: Published -// Description: Returns the keycode associated with this event. If -// has_keycode(), above, returns false, this returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the keycode associated with this event. If has_keycode(), above, + * returns false, this returns 0. + */ INLINE int MouseWatcherParameter:: get_keycode() const { return _keycode; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::has_candidate -// Access: Published -// Description: Returns true if this parameter has an associated -// candidate string, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this parameter has an associated candidate string, false + * otherwise. + */ INLINE bool MouseWatcherParameter:: has_candidate() const { return (_flags & F_has_candidate) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_candidate_string -// Access: Published -// Description: Returns the candidate string associated with this -// event. If has_candidate(), above, returns false, -// this returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the candidate string associated with this event. If + * has_candidate(), above, returns false, this returns the empty string. + */ INLINE const wstring &MouseWatcherParameter:: get_candidate_string() const { return _candidate_string; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_candidate_string_encoded -// Access: Published -// Description: Returns the candidate string associated with this -// event. If has_candidate(), above, returns false, -// this returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the candidate string associated with this event. If + * has_candidate(), above, returns false, this returns the empty string. + */ INLINE string MouseWatcherParameter:: get_candidate_string_encoded() const { return get_candidate_string_encoded(TextEncoder::get_default_encoding()); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_candidate_string_encoded -// Access: Published -// Description: Returns the candidate string associated with this -// event. If has_candidate(), above, returns false, -// this returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the candidate string associated with this event. If + * has_candidate(), above, returns false, this returns the empty string. + */ INLINE string MouseWatcherParameter:: get_candidate_string_encoded(TextEncoder::Encoding encoding) const { return TextEncoder::encode_wtext(_candidate_string, encoding); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_highlight_start -// Access: Published -// Description: Returns the first highlighted character in the -// candidate string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first highlighted character in the candidate string. + */ INLINE size_t MouseWatcherParameter:: get_highlight_start() const { return _highlight_start; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_highlight_end -// Access: Published -// Description: Returns one more than the last highlighted character -// in the candidate string. -//////////////////////////////////////////////////////////////////// +/** + * Returns one more than the last highlighted character in the candidate + * string. + */ INLINE size_t MouseWatcherParameter:: get_highlight_end() const { return _highlight_end; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_cursor_pos -// Access: Published -// Description: Returns the position of the user's edit cursor within -// the candidate string. -//////////////////////////////////////////////////////////////////// +/** + * Returns the position of the user's edit cursor within the candidate string. + */ INLINE size_t MouseWatcherParameter:: get_cursor_pos() const { return _cursor_pos; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_modifier_buttons -// Access: Published -// Description: Returns the set of modifier buttons that were being -// held down while the event was generated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of modifier buttons that were being held down while the + * event was generated. + */ INLINE const ModifierButtons &MouseWatcherParameter:: get_modifier_buttons() const { return _mods; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::has_mouse -// Access: Published -// Description: Returns true if this parameter has an associated -// mouse position, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this parameter has an associated mouse position, false + * otherwise. + */ INLINE bool MouseWatcherParameter:: has_mouse() const { return (_flags & F_has_mouse) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::get_mouse -// Access: Published -// Description: Returns the mouse position at the time the event was -// generated, in the normalized range (-1 .. 1). It is -// valid to call this only if has_mouse() returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mouse position at the time the event was generated, in the + * normalized range (-1 .. 1). It is valid to call this only if has_mouse() + * returned true. + */ INLINE const LPoint2 &MouseWatcherParameter:: get_mouse() const { nassertr(has_mouse(), _mouse); return _mouse; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::is_outside -// Access: Published -// Description: Returns true if the mouse was outside the region at -// the time the event was generated, false otherwise. -// This is only valid for "release" type events. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the mouse was outside the region at the time the event was + * generated, false otherwise. This is only valid for "release" type events. + */ INLINE bool MouseWatcherParameter:: is_outside() const { return (_flags & F_is_outside) != 0; diff --git a/panda/src/tform/mouseWatcherParameter.cxx b/panda/src/tform/mouseWatcherParameter.cxx index 7e3346296b..c1a697375e 100644 --- a/panda/src/tform/mouseWatcherParameter.cxx +++ b/panda/src/tform/mouseWatcherParameter.cxx @@ -1,24 +1,21 @@ -// Filename: mouseWatcherParameter.cxx -// Created by: drose (06Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherParameter.cxx + * @author drose + * @date 2001-07-06 + */ #include "mouseWatcherParameter.h" -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherParameter::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcherParameter:: output(ostream &out) const { bool output_anything = false; diff --git a/panda/src/tform/mouseWatcherParameter.h b/panda/src/tform/mouseWatcherParameter.h index 70b9b0574c..bacb2a805b 100644 --- a/panda/src/tform/mouseWatcherParameter.h +++ b/panda/src/tform/mouseWatcherParameter.h @@ -1,16 +1,15 @@ -// Filename: mouseWatcherParameter.h -// Created by: drose (06Jul01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherParameter.h + * @author drose + * @date 2001-07-06 + */ #ifndef MOUSEWATCHERPARAMETER_H #define MOUSEWATCHERPARAMETER_H @@ -22,12 +21,10 @@ #include "textEncoder.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : MouseWatcherParameter -// Description : This is sent along as a parameter to most events -// generated for a region to indicate the mouse and -// button state for the event. -//////////////////////////////////////////////////////////////////// +/** + * This is sent along as a parameter to most events generated for a region to + * indicate the mouse and button state for the event. + */ class EXPCL_PANDA_TFORM MouseWatcherParameter { public: INLINE MouseWatcherParameter(); @@ -39,7 +36,7 @@ public: INLINE void set_keyrepeat(bool flag); INLINE void set_keycode(int keycode); INLINE void set_candidate(const wstring &candidate_string, - size_t highlight_start, + size_t highlight_start, size_t higlight_end, size_t cursor_pos); INLINE void set_modifier_buttons(const ModifierButtons &mods); diff --git a/panda/src/tform/mouseWatcherRegion.I b/panda/src/tform/mouseWatcherRegion.I index 20a75458e5..cdcc71d51e 100644 --- a/panda/src/tform/mouseWatcherRegion.I +++ b/panda/src/tform/mouseWatcherRegion.I @@ -1,23 +1,19 @@ -// Filename: mouseWatcherRegion.I -// Created by: drose (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherRegion.I + * @author drose + * @date 2000-07-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseWatcherRegion:: MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) : @@ -28,11 +24,9 @@ MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, _flags = F_active; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MouseWatcherRegion:: MouseWatcherRegion(const string &name, const LVecBase4 &frame) : Namable(name), @@ -42,83 +36,65 @@ MouseWatcherRegion(const string &name, const LVecBase4 &frame) : _flags = F_active; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_frame -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MouseWatcherRegion:: set_frame(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { set_frame(LVecBase4(left, right, bottom, top)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_frame -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MouseWatcherRegion:: set_frame(const LVecBase4 &frame) { _frame = frame; _area = (_frame[1] - _frame[0]) * (_frame[3] - _frame[2]); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_frame -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const LVecBase4 &MouseWatcherRegion:: get_frame() const { return _frame; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_area -// Access: Published -// Description: Returns the area of the rectangular region. -//////////////////////////////////////////////////////////////////// +/** + * Returns the area of the rectangular region. + */ INLINE PN_stdfloat MouseWatcherRegion:: get_area() const { return _area; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_sort -// Access: Published -// Description: Changes the sorting order of this particular region. -// The sorting order is used to resolve conflicts in the -// case of overlapping region; the region with the -// highest sort value will be preferred, and between -// regions of the same sort value, the smallest region -// will be preferred. The default sorting order, if -// none is explicitly specified, is 0. -//////////////////////////////////////////////////////////////////// +/** + * Changes the sorting order of this particular region. The sorting order is + * used to resolve conflicts in the case of overlapping region; the region + * with the highest sort value will be preferred, and between regions of the + * same sort value, the smallest region will be preferred. The default + * sorting order, if none is explicitly specified, is 0. + */ INLINE void MouseWatcherRegion:: set_sort(int sort) { _sort = sort; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_sort -// Access: Published -// Description: Returns the current sorting order of this region. -// See set_sort(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current sorting order of this region. See set_sort(). + */ INLINE int MouseWatcherRegion:: get_sort() const { return _sort; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_active -// Access: Published -// Description: Sets whether the region is active or not. If it is -// not active, the MouseWatcher will never consider the -// mouse to be over the region. The region might still -// receive keypress events if its set_keyboard() flag is -// true. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the region is active or not. If it is not active, the + * MouseWatcher will never consider the mouse to be over the region. The + * region might still receive keypress events if its set_keyboard() flag is + * true. + */ INLINE void MouseWatcherRegion:: set_active(bool active) { if (active) { @@ -128,27 +104,20 @@ set_active(bool active) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_active -// Access: Published -// Description: Returns whether the region is active or not. See -// set_active(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the region is active or not. See set_active(). + */ INLINE bool MouseWatcherRegion:: get_active() const { return ((_flags & F_active) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_keyboard -// Access: Published -// Description: Sets whether the region is interested in global -// keyboard events. If this is true, then any keyboard -// button events will be passed to press() and release() -// regardless of the position of the mouse onscreen; -// otherwise, these events will only be passed if the -// mouse is over the region. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the region is interested in global keyboard events. If this + * is true, then any keyboard button events will be passed to press() and + * release() regardless of the position of the mouse onscreen; otherwise, + * these events will only be passed if the mouse is over the region. + */ INLINE void MouseWatcherRegion:: set_keyboard(bool keyboard) { if (keyboard) { @@ -158,52 +127,41 @@ set_keyboard(bool keyboard) { } } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_keyboard -// Access: Published -// Description: Returns whether the region is interested in global -// keyboard events; see set_keyboard(). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the region is interested in global keyboard events; see + * set_keyboard(). + */ INLINE bool MouseWatcherRegion:: get_keyboard() const { return ((_flags & F_keyboard) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::set_suppress_flags -// Access: Published -// Description: Sets which events are suppressed when the mouse is -// over the region. This is the union of zero or more -// various SF_* values. Normally, this is 0, indicating -// that no events are suppressed. -// -// If you set this to a non-zero value, for instance -// SF_mouse_position, then the mouse position will not -// be sent along the data graph when the mouse is over -// this particular region. -//////////////////////////////////////////////////////////////////// +/** + * Sets which events are suppressed when the mouse is over the region. This + * is the union of zero or more various SF_* values. Normally, this is 0, + * indicating that no events are suppressed. + * + * If you set this to a non-zero value, for instance SF_mouse_position, then + * the mouse position will not be sent along the data graph when the mouse is + * over this particular region. + */ INLINE void MouseWatcherRegion:: set_suppress_flags(int suppress_flags) { _flags = ((_flags & ~F_suppress_flags) | (suppress_flags & F_suppress_flags)); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::get_suppress_flags -// Access: Published -// Description: Returns the current suppress_flags. See -// set_suppress_flags(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current suppress_flags. See set_suppress_flags(). + */ INLINE int MouseWatcherRegion:: get_suppress_flags() const { return (_flags & F_suppress_flags); } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::Ordering Operator -// Access: Public -// Description: Returns true if this region should be preferred over -// the other region when they overlap, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this region should be preferred over the other region when + * they overlap, false otherwise. + */ INLINE bool MouseWatcherRegion:: operator < (const MouseWatcherRegion &other) const { if (_sort != other._sort) { diff --git a/panda/src/tform/mouseWatcherRegion.cxx b/panda/src/tform/mouseWatcherRegion.cxx index 87207fd6e1..b9905a4715 100644 --- a/panda/src/tform/mouseWatcherRegion.cxx +++ b/panda/src/tform/mouseWatcherRegion.cxx @@ -1,16 +1,15 @@ -// Filename: mouseWatcherRegion.cxx -// Created by: drose (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherRegion.cxx + * @author drose + * @date 2000-07-13 + */ #include "mouseWatcherRegion.h" @@ -19,21 +18,17 @@ TypeHandle MouseWatcherRegion::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::output -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcherRegion:: output(ostream &out) const { out << get_name() << " lrbt = " << _frame; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::write -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MouseWatcherRegion:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -41,105 +36,80 @@ write(ostream &out, int indent_level) const { << ", sort = " << _sort << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::enter_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse enters the region. The mouse is only -// considered to be "entered" in one region at a time; -// in the case of nested regions, it exits the outer -// region before entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse enters the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void MouseWatcherRegion:: enter_region(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::exit_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse exits the region. The mouse is only considered -// to be "entered" in one region at a time; in the case -// of nested regions, it exits the outer region before -// entering the inner one. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse exits the + * region. The mouse is only considered to be "entered" in one region at a + * time; in the case of nested regions, it exits the outer region before + * entering the inner one. + */ void MouseWatcherRegion:: exit_region(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::within_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves within the boundaries of the region, even -// if it is also within the boundaries of a nested -// region. This is different from "enter", which is -// only called whenever the mouse is within only that -// region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves within + * the boundaries of the region, even if it is also within the boundaries of a + * nested region. This is different from "enter", which is only called + * whenever the mouse is within only that region. + */ void MouseWatcherRegion:: within_region(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::without_region -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever the -// mouse moves completely outside the boundaries of the -// region. See within_region(). -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever the mouse moves + * completely outside the boundaries of the region. See within_region(). + */ void MouseWatcherRegion:: without_region(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::press -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button is depressed while the mouse -// is within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button is depressed while the mouse is within the region. + */ void MouseWatcherRegion:: press(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::release -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse or keyboard button previously depressed with -// press() is released. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse or keyboard + * button previously depressed with press() is released. + */ void MouseWatcherRegion:: release(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::keystroke -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// keystroke is generated by the user. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a keystroke is generated + * by the user. + */ void MouseWatcherRegion:: keystroke(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::candidate -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever an -// IME candidate is highlighted by the user. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever an IME candidate is + * highlighted by the user. + */ void MouseWatcherRegion:: candidate(const MouseWatcherParameter &) { } -//////////////////////////////////////////////////////////////////// -// Function: MouseWatcherRegion::move -// Access: Public, Virtual -// Description: This is a callback hook function, called whenever a -// mouse is moved within the region. -//////////////////////////////////////////////////////////////////// +/** + * This is a callback hook function, called whenever a mouse is moved within + * the region. + */ void MouseWatcherRegion:: move(const MouseWatcherParameter &) { } diff --git a/panda/src/tform/mouseWatcherRegion.h b/panda/src/tform/mouseWatcherRegion.h index 907ec6e939..2874082750 100644 --- a/panda/src/tform/mouseWatcherRegion.h +++ b/panda/src/tform/mouseWatcherRegion.h @@ -1,16 +1,15 @@ -// Filename: mouseWatcherRegion.h -// Created by: drose (13Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mouseWatcherRegion.h + * @author drose + * @date 2000-07-13 + */ #ifndef MOUSEWATCHERREGION_H #define MOUSEWATCHERREGION_H @@ -25,11 +24,10 @@ class MouseWatcherParameter; -//////////////////////////////////////////////////////////////////// -// Class : MouseWatcherRegion -// Description : This is the class that defines a rectangular region -// on the screen for the MouseWatcher. -//////////////////////////////////////////////////////////////////// +/** + * This is the class that defines a rectangular region on the screen for the + * MouseWatcher. + */ class EXPCL_PANDA_TFORM MouseWatcherRegion : public TypedWritableReferenceCount, public Namable { PUBLISHED: INLINE MouseWatcherRegion(const string &name, PN_stdfloat left, PN_stdfloat right, @@ -82,8 +80,8 @@ private: int _sort; enum Flags { - // F_suppress_flags is the union of all of the SuppressFlags, - // above. Presently, we reserve 8 bits for suppress flags. + // F_suppress_flags is the union of all of the SuppressFlags, above. + // Presently, we reserve 8 bits for suppress flags. F_suppress_flags = 0x0ff, F_active = 0x100, F_keyboard = 0x200, diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index bf5f8c3a23..620b52950b 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -1,16 +1,15 @@ -// Filename: trackball.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackball.cxx + * @author drose + * @date 2002-03-12 + */ #include "trackball.h" #include "buttonEvent.h" @@ -31,11 +30,9 @@ TypeHandle Trackball::_type_handle; #define B2_MASK 0x02 #define B3_MASK 0x04 -//////////////////////////////////////////////////////////////////// -// Function: Trackball::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Trackball:: Trackball(const string &name) : MouseInterfaceNode(name) @@ -66,28 +63,24 @@ Trackball(const string &name) : watch_button(MouseButton::three()); if (trackball_use_alt_keys) { - // In OSX mode, we need to use the command and option key in - // conjunction with the (one) mouse button. + // In OSX mode, we need to use the command and option key in conjunction + // with the (one) mouse button. watch_button(KeyboardButton::control()); watch_button(KeyboardButton::meta()); watch_button(KeyboardButton::alt()); } } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Trackball:: ~Trackball() { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::reset -// Access: Published -// Description: Reinitializes all transforms to identity. -//////////////////////////////////////////////////////////////////// +/** + * Reinitializes all transforms to identity. + */ void Trackball:: reset() { _rotation = LMatrix4::ident_mat(); @@ -96,36 +89,29 @@ reset() { _mat = LMatrix4::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_forward_scale -// Access: Published -// Description: Returns the scale factor applied to forward and -// backward motion. See set_forward_scale(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor applied to forward and backward motion. See + * set_forward_scale(). + */ PN_stdfloat Trackball:: get_forward_scale() const { return _fwdscale; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_forward_scale -// Access: Published -// Description: Changes the scale factor applied to forward and -// backward motion. The larger this number, the faster -// the model will move in response to dollying in and -// out. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scale factor applied to forward and backward motion. The + * larger this number, the faster the model will move in response to dollying + * in and out. + */ void Trackball:: set_forward_scale(PN_stdfloat fwdscale) { _fwdscale = fwdscale; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_pos -// Access: Published -// Description: Return the offset from the center of rotation. -//////////////////////////////////////////////////////////////////// +/** + * Return the offset from the center of rotation. + */ const LPoint3 &Trackball:: get_pos() const { return _translation; @@ -147,11 +133,9 @@ get_z() const { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_pos -// Access: Published -// Description: Directly set the offset from the rotational origin. -//////////////////////////////////////////////////////////////////// +/** + * Directly set the offset from the rotational origin. + */ void Trackball:: set_pos(const LVecBase3 &vec) { _translation = vec; @@ -183,11 +167,9 @@ set_z(PN_stdfloat z) { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_hpr -// Access: Published -// Description: Return the trackball's orientation. -//////////////////////////////////////////////////////////////////// +/** + * Return the trackball's orientation. + */ LVecBase3 Trackball:: get_hpr() const { LVecBase3 scale, shear, hpr, translate; @@ -217,11 +199,9 @@ get_r() const { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_hpr -// Access: Published -// Description: Directly set the mover's orientation. -//////////////////////////////////////////////////////////////////// +/** + * Directly set the mover's orientation. + */ void Trackball:: set_hpr(const LVecBase3 &hpr) { LVecBase3 scale, shear, old_hpr, translate; @@ -267,13 +247,10 @@ set_r(PN_stdfloat r) { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::reset_origin_here -// Access: Published -// Description: Reposition the center of rotation to coincide with -// the current translation offset. Future rotations -// will be about the current origin. -//////////////////////////////////////////////////////////////////// +/** + * Reposition the center of rotation to coincide with the current translation + * offset. Future rotations will be about the current origin. + */ void Trackball:: reset_origin_here() { recompute(); @@ -282,31 +259,25 @@ reset_origin_here() { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::move_origin -// Access: Published -// Description: Moves the center of rotation by the given amount. -//////////////////////////////////////////////////////////////////// +/** + * Moves the center of rotation by the given amount. + */ void Trackball:: move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { _rotation = LMatrix4::translate_mat(LVecBase3(x, y, z)) * _rotation; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_origin -// Access: Published -// Description: Returns the current center of rotation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current center of rotation. + */ LPoint3 Trackball:: get_origin() const { return _rotation.get_row3(3); } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_origin -// Access: Published -// Description: Directly sets the center of rotation. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the center of rotation. + */ void Trackball:: set_origin(const LVecBase3 &origin) { _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); @@ -314,115 +285,89 @@ set_origin(const LVecBase3 &origin) { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_invert -// Access: Published -// Description: Sets the invert flag. When this is set, the inverse -// matrix is generated, suitable for joining to a -// camera, instead of parenting the scene under it. -//////////////////////////////////////////////////////////////////// +/** + * Sets the invert flag. When this is set, the inverse matrix is generated, + * suitable for joining to a camera, instead of parenting the scene under it. + */ void Trackball:: set_invert(bool flag) { _invert = flag; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_invert -// Access: Published -// Description: Returns the invert flag. When this is set, the -// inverse matrix is generated, suitable for joining to -// a camera, instead of parenting the scene under it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the invert flag. When this is set, the inverse matrix is + * generated, suitable for joining to a camera, instead of parenting the scene + * under it. + */ bool Trackball:: get_invert() const { return _invert; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_control_mode -// Access: Published -// Description: Sets the control mode. Normally this is CM_default, -// which means each mouse button serves its normal -// function. When it is CM_truck, CM_pan, CM_dolly, or -// CM_roll, all of the mouse buttons serve the indicated -// function instead of their normal function. This can -// be used in conjunction with some external way of -// changing modes. -//////////////////////////////////////////////////////////////////// +/** + * Sets the control mode. Normally this is CM_default, which means each mouse + * button serves its normal function. When it is CM_truck, CM_pan, CM_dolly, + * or CM_roll, all of the mouse buttons serve the indicated function instead + * of their normal function. This can be used in conjunction with some + * external way of changing modes. + */ void Trackball:: set_control_mode(ControlMode control_mode) { _control_mode = control_mode; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_control_mode -// Access: Published -// Description: Returns the control mode. See set_control_mode(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the control mode. See set_control_mode(). + */ Trackball::ControlMode Trackball:: get_control_mode() const { return _control_mode; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_rel_to -// Access: Published -// Description: Sets the NodePath that all trackball manipulations -// are to be assumed to be relative to. For instance, -// set your camera node here to make the trackball -// motion camera relative. The default is the empty -// path, which means trackball motion is in global -// space. -//////////////////////////////////////////////////////////////////// +/** + * Sets the NodePath that all trackball manipulations are to be assumed to be + * relative to. For instance, set your camera node here to make the trackball + * motion camera relative. The default is the empty path, which means + * trackball motion is in global space. + */ void Trackball:: set_rel_to(const NodePath &rel_to) { _rel_to = rel_to; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_rel_to -// Access: Published -// Description: Returns the NodePath that all trackball manipulations -// are relative to, or the empty path. -//////////////////////////////////////////////////////////////////// +/** + * Returns the NodePath that all trackball manipulations are relative to, or + * the empty path. + */ const NodePath &Trackball:: get_rel_to() const { return _rel_to; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_coordinate_system -// Access: Published -// Description: Sets the coordinate system of the Trackball. -// Normally, this is the default coordinate system. -// This changes the axes the Trackball manipulates so -// that the user interface remains consistent across -// different coordinate systems. -//////////////////////////////////////////////////////////////////// +/** + * Sets the coordinate system of the Trackball. Normally, this is the default + * coordinate system. This changes the axes the Trackball manipulates so that + * the user interface remains consistent across different coordinate systems. + */ void Trackball:: set_coordinate_system(CoordinateSystem cs) { _cs = cs; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_coordinate_system -// Access: Published -// Description: Returns the coordinate system of the Trackball. -// See set_coordinate_system(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the coordinate system of the Trackball. See + * set_coordinate_system(). + */ CoordinateSystem Trackball:: get_coordinate_system() const { return _cs; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::set_mat -// Access: Published -// Description: Stores the indicated transform in the trackball. -// This is a transform in global space, regardless of -// the rel_to node. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated transform in the trackball. This is a transform in + * global space, regardless of the rel_to node. + */ void Trackball:: set_mat(const LMatrix4 &mat) { _orig = mat; @@ -436,37 +381,28 @@ set_mat(const LMatrix4 &mat) { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_mat -// Access: Published -// Description: Returns the matrix represented by the trackball -// rotation. -//////////////////////////////////////////////////////////////////// +/** + * Returns the matrix represented by the trackball rotation. + */ const LMatrix4 &Trackball:: get_mat() const { return _orig; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::get_trans_mat -// Access: Published -// Description: Returns the actual transform that will be applied to -// the scene graph. This is the same as get_mat(), -// unless invert is in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual transform that will be applied to the scene graph. This + * is the same as get_mat(), unless invert is in effect. + */ const LMatrix4 &Trackball:: get_trans_mat() const { return _mat; } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::apply -// Access: Private -// Description: Applies the operation indicated by the user's mouse -// motion to the current state. Returns the matrix -// indicating the new state. -//////////////////////////////////////////////////////////////////// +/** + * Applies the operation indicated by the user's mouse motion to the current + * state. Returns the matrix indicating the new state. + */ void Trackball:: apply(double x, double y, int button) { if (button && !_rel_to.is_empty()) { @@ -476,9 +412,8 @@ apply(double x, double y, int button) { } if (button == B1_MASK && _control_mode != CM_default) { - // We have a control mode set; this may change the meaning of - // button 1. Remap button to match the current control mode - // setting. + // We have a control mode set; this may change the meaning of button 1. + // Remap button to match the current control mode setting. switch (_control_mode) { case CM_truck: button = B1_MASK; @@ -510,26 +445,24 @@ apply(double x, double y, int button) { y * _fwdscale * LVector3::down(_cs); } else if (button == (B2_MASK | B3_MASK)) { - // Buttons 2 + 3: rotate about the vector perpendicular to the - // screen. + // Buttons 2 + 3: rotate about the vector perpendicular to the screen. _rotation *= LMatrix4::rotate_mat_normaxis((x - y) * _rotscale, LVector3::forward(_cs), _cs); } else if ((button == B2_MASK) || (button == (B1_MASK | B3_MASK))) { - // Button 2, or buttons 1 + 3: rotate about the right and up - // vectors. (We alternately define this as buttons 1 + 3, to - // support two-button mice.) + // Button 2, or buttons 1 + 3: rotate about the right and up vectors. (We + // alternately define this as buttons 1 + 3, to support two-button mice.) _rotation *= LMatrix4::rotate_mat_normaxis(x * _rotscale, LVector3::up(_cs), _cs) * LMatrix4::rotate_mat_normaxis(y * _rotscale, LVector3::right(_cs), _cs); } else if ((button == B3_MASK) || (button == (B1_MASK | B2_MASK))) { - // Button 3, or buttons 1 + 2: dolly in and out along the forward - // vector. (We alternately define this as buttons 1 + 2, to - // support two-button mice.) + // Button 3, or buttons 1 + 2: dolly in and out along the forward vector. + // (We alternately define this as buttons 1 + 2, to support two-button + // mice.) _translation -= y * _fwdscale * LVector3::forward(_cs); } @@ -539,12 +472,10 @@ apply(double x, double y, int button) { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::reextract -// Access: Private -// Description: Given a correctly computed _orig matrix, rederive the -// translation and rotation elements. -//////////////////////////////////////////////////////////////////// +/** + * Given a correctly computed _orig matrix, rederive the translation and + * rotation elements. + */ void Trackball:: reextract() { LMatrix4 m = _orig; @@ -558,12 +489,10 @@ reextract() { _rotation.set_row(3, LVecBase3(0.0f, 0.0f, 0.0f)); } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::recompute -// Access: Private -// Description: Rebuilds the matrix according to the stored rotation -// and translation components. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the matrix according to the stored rotation and translation + * components. + */ void Trackball:: recompute() { _orig = _rotation * LMatrix4::translate_mat(_translation); @@ -581,19 +510,14 @@ recompute() { } -//////////////////////////////////////////////////////////////////// -// Function: Trackball::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void Trackball:: do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, DataNodeTransmit &output) { @@ -609,7 +533,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, PN_stdfloat this_x = p[0]; PN_stdfloat this_y = p[1]; int this_button = 0; - + if (is_down(MouseButton::one())) { if (is_down(KeyboardButton::alt())) { // B1 + alt (option) = B2. @@ -633,14 +557,14 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &input, if (is_down(MouseButton::three())) { this_button |= B3_MASK; } - + PN_stdfloat x = this_x - _lastx; PN_stdfloat y = this_y - _lasty; if (this_button == _last_button) { apply(x, y, this_button); } - + _last_button = this_button; _lastx = this_x; _lasty = this_y; diff --git a/panda/src/tform/trackball.h b/panda/src/tform/trackball.h index 0917d1b019..964ad7d8dd 100644 --- a/panda/src/tform/trackball.h +++ b/panda/src/tform/trackball.h @@ -1,16 +1,15 @@ -// Filename: trackball.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file trackball.h + * @author drose + * @date 2002-03-12 + */ #ifndef TRACKBALL_H #define TRACKBALL_H @@ -24,19 +23,15 @@ #include "transformState.h" -//////////////////////////////////////////////////////////////////// -// Class : Trackball -// Description : Trackball acts like Performer in trackball mode. It -// can either spin around a piece of geometry directly, -// or it can spin around a camera with the inverse -// transform to make it appear that the whole world is -// spinning. -// -// The Trackball object actually just places a transform -// in the data graph; parent a Transform2SG node under -// it to actually transform objects (or cameras) in the -// world. -//////////////////////////////////////////////////////////////////// +/** + * Trackball acts like Performer in trackball mode. It can either spin around + * a piece of geometry directly, or it can spin around a camera with the + * inverse transform to make it appear that the whole world is spinning. + * + * The Trackball object actually just places a transform in the data graph; + * parent a Transform2SG node under it to actually transform objects (or + * cameras) in the world. + */ class EXPCL_PANDA_TFORM Trackball : public MouseInterfaceNode { PUBLISHED: Trackball(const string &name); @@ -47,7 +42,7 @@ PUBLISHED: PN_stdfloat get_forward_scale() const; void set_forward_scale(PN_stdfloat fwdscale); - /// **** Translation **** + // **** Translation **** const LPoint3 &get_pos() const; PN_stdfloat get_x() const; @@ -59,7 +54,7 @@ PUBLISHED: void set_y(PN_stdfloat y); void set_z(PN_stdfloat z); - /// **** Rotation **** + // **** Rotation **** LVecBase3 get_hpr() const; PN_stdfloat get_h() const; @@ -71,7 +66,7 @@ PUBLISHED: void set_p(PN_stdfloat p); void set_r(PN_stdfloat r); - /// **** Origin of Rotation **** + // **** Origin of Rotation **** void reset_origin_here(); void move_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z); @@ -79,7 +74,7 @@ PUBLISHED: LPoint3 get_origin() const; void set_origin(const LVecBase3 &origin); - /// **** Misc **** + // **** Misc **** enum ControlMode { CM_default, diff --git a/panda/src/tform/transform2sg.cxx b/panda/src/tform/transform2sg.cxx index 62850ceccf..6adfb944c4 100644 --- a/panda/src/tform/transform2sg.cxx +++ b/panda/src/tform/transform2sg.cxx @@ -1,16 +1,15 @@ -// Filename: transform2sg.cxx -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transform2sg.cxx + * @author drose + * @date 2002-03-12 + */ #include "transform2sg.h" #include "transformState.h" @@ -20,11 +19,9 @@ TypeHandle Transform2SG::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: Transform2SG::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Transform2SG:: Transform2SG(const string &name) : DataNode(name) @@ -34,41 +31,32 @@ Transform2SG(const string &name) : _node = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Transform2SG::set_node -// Access: Public -// Description: Sets the node that this object will adjust. -//////////////////////////////////////////////////////////////////// +/** + * Sets the node that this object will adjust. + */ void Transform2SG:: set_node(PandaNode *node) { _node = node; } -//////////////////////////////////////////////////////////////////// -// Function: Transform2SG::get_node -// Access: Public -// Description: Returns the node that this object will adjust, or NULL -// if the node has not yet been set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node that this object will adjust, or NULL if the node has not + * yet been set. + */ PandaNode *Transform2SG:: get_node() const { return _node; } -//////////////////////////////////////////////////////////////////// -// Function: Transform2SG::do_transmit_data -// Access: Protected, Virtual -// Description: The virtual implementation of transmit_data(). This -// function receives an array of input parameters and -// should generate an array of output parameters. The -// input parameters may be accessed with the index -// numbers returned by the define_input() calls that -// were made earlier (presumably in the constructor); -// likewise, the output parameters should be set with -// the index numbers returned by the define_output() -// calls. -//////////////////////////////////////////////////////////////////// +/** + * The virtual implementation of transmit_data(). This function receives an + * array of input parameters and should generate an array of output + * parameters. The input parameters may be accessed with the index numbers + * returned by the define_input() calls that were made earlier (presumably in + * the constructor); likewise, the output parameters should be set with the + * index numbers returned by the define_output() calls. + */ void Transform2SG:: do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &) { diff --git a/panda/src/tform/transform2sg.h b/panda/src/tform/transform2sg.h index fdd429ba6e..b5c1fa40ba 100644 --- a/panda/src/tform/transform2sg.h +++ b/panda/src/tform/transform2sg.h @@ -1,16 +1,15 @@ -// Filename: transform2sg.h -// Created by: drose (12Mar02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file transform2sg.h + * @author drose + * @date 2002-03-12 + */ #ifndef TRANSFORM2SG_H #define TRANSFORM2SG_H @@ -20,13 +19,12 @@ #include "dataNode.h" #include "pandaNode.h" -//////////////////////////////////////////////////////////////////// -// Class : Transform2SG -// Description : input: Transform (matrix) -// -// output: none, but applies the matrix as the transform -// transition for a given arc of the scene graph. -//////////////////////////////////////////////////////////////////// +/** + * input: Transform (matrix) + * + * output: none, but applies the matrix as the transform transition for a + * given arc of the scene graph. + */ class EXPCL_PANDA_TFORM Transform2SG : public DataNode { PUBLISHED: Transform2SG(const string &name); @@ -66,4 +64,3 @@ private: }; #endif - diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index 73dac78e0e..228be9a1ee 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_tinydisplay.cxx -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_tinydisplay.cxx + * @author drose + * @date 2008-04-24 + */ #include "config_tinydisplay.h" #include "tinyXGraphicsPipe.h" @@ -74,14 +73,12 @@ ConfigVariableBool td_perspective_textures "textures on the tinydisplay software renderer, for a small " "performance gain.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libtinydisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libtinydisplay() { static bool initialized = false; @@ -138,11 +135,10 @@ init_libtinydisplay() { ps->set_system_tag("TinyPanda", "", ""); } -//////////////////////////////////////////////////////////////////// -// Function: get_pipe_type_p3tinydisplay -// Description: Returns the TypeHandle index of the recommended -// graphics pipe type defined by this module. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TypeHandle index of the recommended graphics pipe type defined + * by this module. + */ int get_pipe_type_p3tinydisplay() { diff --git a/panda/src/tinydisplay/config_tinydisplay.h b/panda/src/tinydisplay/config_tinydisplay.h index 6bf867c037..2750d9cad3 100644 --- a/panda/src/tinydisplay/config_tinydisplay.h +++ b/panda/src/tinydisplay/config_tinydisplay.h @@ -1,16 +1,15 @@ -// Filename: config_tinydisplay.h -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_tinydisplay.h + * @author drose + * @date 2008-04-24 + */ #ifndef CONFIG_TINYDISPLAY_H #define CONFIG_TINYDISPLAY_H diff --git a/panda/src/tinydisplay/store_pixel.cxx b/panda/src/tinydisplay/store_pixel.cxx index 6adafc1c86..07d5e7bdf4 100644 --- a/panda/src/tinydisplay/store_pixel.cxx +++ b/panda/src/tinydisplay/store_pixel.cxx @@ -1,16 +1,15 @@ -// Filename: store_pixel.cxx -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file store_pixel.cxx + * @author drose + * @date 2008-05-12 + */ #include #include diff --git a/panda/src/tinydisplay/store_pixel.h b/panda/src/tinydisplay/store_pixel.h index 3c4a86ba3c..8352e842a4 100644 --- a/panda/src/tinydisplay/store_pixel.h +++ b/panda/src/tinydisplay/store_pixel.h @@ -1,16 +1,15 @@ -// Filename: store_pixel.h -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file store_pixel.h + * @author drose + * @date 2008-05-12 + */ /* Definition of a function to store a pixel in the framebuffer, using user-specified color blending. */ diff --git a/panda/src/tinydisplay/tinyGeomMunger.I b/panda/src/tinydisplay/tinyGeomMunger.I index 1471ece5b1..e52e9225eb 100644 --- a/panda/src/tinydisplay/tinyGeomMunger.I +++ b/panda/src/tinydisplay/tinyGeomMunger.I @@ -1,14 +1,12 @@ -// Filename: tinyGeomMunger.I -// Created by: drose (29Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGeomMunger.I + * @author drose + * @date 2008-04-29 + */ diff --git a/panda/src/tinydisplay/tinyGeomMunger.cxx b/panda/src/tinydisplay/tinyGeomMunger.cxx index 4f2b4a903c..228f1b4364 100644 --- a/panda/src/tinydisplay/tinyGeomMunger.cxx +++ b/panda/src/tinydisplay/tinyGeomMunger.cxx @@ -1,16 +1,15 @@ -// Filename: tinyGeomMunger.cxx -// Created by: drose (29Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGeomMunger.cxx + * @author drose + * @date 2008-04-29 + */ #include "tinyGeomMunger.h" #include "dcast.h" @@ -19,35 +18,28 @@ TypeHandle TinyGeomMunger::_type_handle; ALLOC_DELETED_CHAIN_DEF(TinyGeomMunger); -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGeomMunger:: TinyGeomMunger(GraphicsStateGuardian *gsg, const RenderState *state) : StandardMunger(gsg, state, 4, NT_uint8, C_color) { - // The TinyGSG can apply the color and color scale at runtime. - // _munge_color = false; - // _munge_color_scale = false; + // The TinyGSG can apply the color and color scale at runtime. _munge_color + // = false; _munge_color_scale = false; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGeomMunger:: ~TinyGeomMunger() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::munge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) TinyGeomMunger:: munge_format_impl(const GeomVertexFormat *orig, const GeomVertexAnimationSpec &animation) { @@ -59,38 +51,30 @@ munge_format_impl(const GeomVertexFormat *orig, return format; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::premunge_format_impl -// Access: Protected, Virtual -// Description: Given a source GeomVertexFormat, converts it if -// necessary to the appropriate format for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Given a source GeomVertexFormat, converts it if necessary to the + * appropriate format for rendering. + */ CPT(GeomVertexFormat) TinyGeomMunger:: premunge_format_impl(const GeomVertexFormat *orig) { return orig; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int TinyGeomMunger:: compare_to_impl(const GeomMunger *other) const { return StandardMunger::compare_to_impl(other); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGeomMunger::geom_compare_to_impl -// Access: Protected, Virtual -// Description: Called to compare two GeomMungers who are known to be -// of the same type, for an apples-to-apples comparison. -// This will never be called on two pointers of a -// different type. -//////////////////////////////////////////////////////////////////// +/** + * Called to compare two GeomMungers who are known to be of the same type, for + * an apples-to-apples comparison. This will never be called on two pointers + * of a different type. + */ int TinyGeomMunger:: geom_compare_to_impl(const GeomMunger *other) const { return StandardMunger::compare_to_impl(other); diff --git a/panda/src/tinydisplay/tinyGeomMunger.h b/panda/src/tinydisplay/tinyGeomMunger.h index 0e8065d50f..562a29dc98 100644 --- a/panda/src/tinydisplay/tinyGeomMunger.h +++ b/panda/src/tinydisplay/tinyGeomMunger.h @@ -1,16 +1,15 @@ -// Filename: tinyGeomMunger.h -// Created by: drose (29Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGeomMunger.h + * @author drose + * @date 2008-04-29 + */ #ifndef TINYGEOMMUNGER_H #define TINYGEOMMUNGER_H @@ -20,13 +19,11 @@ #include "graphicsStateGuardian.h" #include "renderState.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyGeomMunger -// Description : This specialization on GeomMunger finesses vertices -// for TinyPanda rendering. This actually doesn't have -// to do very much, since TinyPanda is not that -// particular. -//////////////////////////////////////////////////////////////////// +/** + * This specialization on GeomMunger finesses vertices for TinyPanda + * rendering. This actually doesn't have to do very much, since TinyPanda is + * not that particular. + */ class EXPCL_TINYDISPLAY TinyGeomMunger : public StandardMunger { public: TinyGeomMunger(GraphicsStateGuardian *gsg, const RenderState *state); diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.I b/panda/src/tinydisplay/tinyGraphicsBuffer.I index 6c90e7176d..6a5edd842b 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.I +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.I @@ -1,24 +1,19 @@ -// Filename: tinyGraphicsBuffer.I -// Created by: drose (08Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsBuffer.I + * @author drose + * @date 2008-08-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::get_frame_buffer -// Access: Public -// Description: Returns a direct pointer to the frame buffer used in -// this object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a direct pointer to the frame buffer used in this object. + */ ZBuffer *TinyGraphicsBuffer:: get_frame_buffer() { return _frame_buffer; diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx index f1e7bbfc3c..adeceabd01 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.cxx +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: tinyGraphicsBuffer.cxx -// Created by: drose (08Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsBuffer.cxx + * @author drose + * @date 2008-08-08 + */ #include "pandabase.h" @@ -21,13 +20,11 @@ TypeHandle TinyGraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGraphicsBuffer:: -TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, +TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -39,24 +36,19 @@ TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, _frame_buffer = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGraphicsBuffer:: ~TinyGraphicsBuffer() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool TinyGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -69,18 +61,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { tinygsg->_current_frame_buffer = _frame_buffer; tinygsg->reset_if_new(); - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void TinyGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -99,12 +89,9 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the buffer -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the buffer thread. + */ void TinyGraphicsBuffer:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -117,16 +104,13 @@ close_buffer() { _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the buffer right now. Called from the buffer -// thread. Returns true if the buffer is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the buffer right now. Called from the buffer thread. Returns true + * if the buffer is successfully opened, or false if there was a problem. + */ bool TinyGraphicsBuffer:: open_buffer() { - // GSG Creation/Initialization + // GSG CreationInitialization TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -135,7 +119,7 @@ open_buffer() { } else { DCAST_INTO_R(tinygsg, _gsg, false); } - + create_frame_buffer(); if (_frame_buffer == NULL) { tinydisplay_cat.error() @@ -144,7 +128,7 @@ open_buffer() { } tinygsg->_current_frame_buffer = _frame_buffer; - + tinygsg->reset_if_new(); if (!tinygsg->is_valid()) { close_buffer(); @@ -155,12 +139,9 @@ open_buffer() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsBuffer::create_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size. + */ void TinyGraphicsBuffer:: create_frame_buffer() { if (_frame_buffer != NULL) { @@ -170,4 +151,3 @@ create_frame_buffer() { _frame_buffer = ZB_open(get_fb_x_size(), get_fb_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0); } - diff --git a/panda/src/tinydisplay/tinyGraphicsBuffer.h b/panda/src/tinydisplay/tinyGraphicsBuffer.h index 561c3c0ff9..c7f7a1e61e 100644 --- a/panda/src/tinydisplay/tinyGraphicsBuffer.h +++ b/panda/src/tinydisplay/tinyGraphicsBuffer.h @@ -1,16 +1,15 @@ -// Filename: tinyGraphicsBuffer.h -// Created by: drose (08Aug08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsBuffer.h + * @author drose + * @date 2008-08-08 + */ #ifndef TINYGRAPHICSBUFFER_H #define TINYGRAPHICSBUFFER_H @@ -19,13 +18,12 @@ #include "graphicsBuffer.h" #include "tinyGraphicsStateGuardian.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyGraphicsBuffer -// Description : An offscreen graphics buffer. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen graphics buffer. + */ class EXPCL_TINYDISPLAY TinyGraphicsBuffer : public GraphicsBuffer { public: - TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, + TinyGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -70,4 +68,3 @@ private: #include "tinyGraphicsBuffer.I" #endif - diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I index c125cd4b37..cac827cf09 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.I +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.I @@ -1,24 +1,19 @@ -// Filename: tinyGraphicsStateGuardian.I -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsStateGuardian.I + * @author drose + * @date 2008-04-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::clear_light_state -// Access: Private -// Description: Removes the current list of active lights from the -// current state context. -//////////////////////////////////////////////////////////////////// +/** + * Removes the current list of active lights from the current state context. + */ INLINE void TinyGraphicsStateGuardian:: clear_light_state() { _c->lighting_enabled = false; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index b9efe215c5..ba33377546 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: tinyGraphicsStateGuardian.cxx -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsStateGuardian.cxx + * @author drose + * @date 2008-04-24 + */ #include "tinyGraphicsStateGuardian.h" #include "tinyGeomMunger.h" @@ -57,11 +56,9 @@ PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_perspective_pcolle PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_multitex2_pcollector("Pixels:Smooth multitex 2"); PStatCollector TinyGraphicsStateGuardian::_pixel_count_smooth_multitex3_pcollector("Pixels:Smooth multitex 3"); -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGraphicsStateGuardian:: TinyGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, TinyGraphicsStateGuardian *share_with) : @@ -74,28 +71,23 @@ TinyGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, _vertices_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyGraphicsStateGuardian:: ~TinyGraphicsStateGuardian() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void TinyGraphicsStateGuardian:: reset() { free_pointers(); GraphicsStateGuardian::reset(); - // Build _inv_state_mask as a mask of 1's where we don't care, and - // 0's where we do care, about the state. + // Build _inv_state_mask as a mask of 1's where we don't care, and 0's where + // we do care, about the state. _inv_state_mask.clear_bit(ColorAttrib::get_class_slot()); _inv_state_mask.clear_bit(ColorScaleAttrib::get_class_slot()); _inv_state_mask.clear_bit(CullFaceAttrib::get_class_slot()); @@ -144,12 +136,9 @@ reset() { add_gsg(this); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::free_pointers -// Access: Protected, Virtual -// Description: Frees some memory that was explicitly allocated -// within the glgsg. -//////////////////////////////////////////////////////////////////// +/** + * Frees some memory that was explicitly allocated within the glgsg. + */ void TinyGraphicsStateGuardian:: free_pointers() { if (_aux_frame_buffer != (ZBuffer *)NULL) { @@ -164,14 +153,11 @@ free_pointers() { _vertices_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::close_gsg -// Access: Protected, Virtual -// Description: This is called by the associated GraphicsWindow when -// close_window() is called. It should null out the -// _win pointer and possibly free any open resources -// associated with the GSG. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the associated GraphicsWindow when close_window() is + * called. It should null out the _win pointer and possibly free any open + * resources associated with the GSG. + */ void TinyGraphicsStateGuardian:: close_gsg() { GraphicsStateGuardian::close_gsg(); @@ -182,42 +168,34 @@ close_gsg() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::depth_offset_decals -// Access: Public, Virtual -// Description: Returns true if this GSG can implement decals using a -// DepthOffsetAttrib, or false if that is unreliable -// and the three-step rendering process should be used -// instead. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this GSG can implement decals using a DepthOffsetAttrib, or + * false if that is unreliable and the three-step rendering process should be + * used instead. + */ bool TinyGraphicsStateGuardian:: depth_offset_decals() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::make_geom_munger -// Access: Public, Virtual -// Description: Creates a new GeomMunger object to munge vertices -// appropriate to this GSG for the indicated state. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GeomMunger object to munge vertices appropriate to this GSG + * for the indicated state. + */ PT(GeomMunger) TinyGraphicsStateGuardian:: make_geom_munger(const RenderState *state, Thread *current_thread) { PT(TinyGeomMunger) munger = new TinyGeomMunger(this, state); return GeomMunger::register_munger(munger, current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::clear -// Access: Public -// Description: Clears the framebuffer within the current -// DisplayRegion, according to the flags indicated by -// the given DrawableRegion object. -// -// This does not set the DisplayRegion first. You -// should call prepare_display_region() to specify the -// region you wish the clear operation to apply to. -//////////////////////////////////////////////////////////////////// +/** + * Clears the framebuffer within the current DisplayRegion, according to the + * flags indicated by the given DrawableRegion object. + * + * This does not set the DisplayRegion first. You should call + * prepare_display_region() to specify the region you wish the clear operation + * to apply to. + */ void TinyGraphicsStateGuardian:: clear(DrawableRegion *clearable) { PStatTimer timer(_clear_pcollector); @@ -251,8 +229,8 @@ clear(DrawableRegion *clearable) { bool clear_z = false; int z = 0; if (clearable->get_clear_depth_active()) { - // We ignore the specified depth clear value, since we don't - // support alternate depth compare functions anyway. + // We ignore the specified depth clear value, since we don't support + // alternate depth compare functions anyway. clear_z = true; } @@ -261,12 +239,9 @@ clear(DrawableRegion *clearable) { _c->viewport.xsize, _c->viewport.ysize); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::prepare_display_region -// Access: Public, Virtual -// Description: Prepare a display region for rendering (set up -// scissor region and viewport) -//////////////////////////////////////////////////////////////////// +/** + * Prepare a display region for rendering (set up scissor region and viewport) + */ void TinyGraphicsStateGuardian:: prepare_display_region(DisplayRegionPipelineReader *dr) { nassertv(dr != (DisplayRegionPipelineReader *)NULL); @@ -277,8 +252,8 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { PN_stdfloat pixel_factor = _current_display_region->get_pixel_factor(); if (pixel_factor != 1.0) { - // Render into an aux buffer, and zoom it up into the main - // frame buffer later. + // Render into an aux buffer, and zoom it up into the main frame buffer + // later. xmin = 0; ymin = 0; xsize = int(xsize * pixel_factor); @@ -309,17 +284,14 @@ prepare_display_region(DisplayRegionPipelineReader *dr) { ymin + ysize >= 0 && ymin + ysize <= _c->zb->ysize); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::calc_projection_mat -// Access: Public, Virtual -// Description: Given a lens, calculates the appropriate projection -// matrix for use with this gsg. Note that the -// projection matrix depends a lot upon the coordinate -// system of the rendering API. -// -// The return value is a TransformState if the lens is -// acceptable, NULL if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Given a lens, calculates the appropriate projection matrix for use with + * this gsg. Note that the projection matrix depends a lot upon the + * coordinate system of the rendering API. + * + * The return value is a TransformState if the lens is acceptable, NULL if it + * is not. + */ CPT(TransformState) TinyGraphicsStateGuardian:: calc_projection_mat(const Lens *lens) { if (lens == (Lens *)NULL) { @@ -330,58 +302,48 @@ calc_projection_mat(const Lens *lens) { return NULL; } - // The projection matrix must always be right-handed Y-up, even if - // our coordinate system of choice is otherwise, because certain GL - // calls (specifically glTexGen(GL_SPHERE_MAP)) assume this kind of - // a coordinate system. Sigh. In order to implement a Z-up (or - // other arbitrary) coordinate system, we'll use a Y-up projection - // matrix, and store the conversion to our coordinate system of - // choice in the modelview matrix. + // The projection matrix must always be right-handed Y-up, even if our + // coordinate system of choice is otherwise, because certain GL calls + // (specifically glTexGen(GL_SPHERE_MAP)) assume this kind of a coordinate + // system. Sigh. In order to implement a Z-up (or other arbitrary) + // coordinate system, we'll use a Y-up projection matrix, and store the + // conversion to our coordinate system of choice in the modelview matrix. LMatrix4 result = LMatrix4::convert_mat(CS_yup_right, _current_lens->get_coordinate_system()) * lens->get_projection_mat(_current_stereo_channel); if (_scene_setup->get_inverted()) { - // If the scene is supposed to be inverted, then invert the - // projection matrix. + // If the scene is supposed to be inverted, then invert the projection + // matrix. result *= LMatrix4::scale_mat(1.0f, -1.0f, 1.0f); } return TransformState::make_mat(result); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::prepare_lens -// Access: Public, Virtual -// Description: Makes the current lens (whichever lens was most -// recently specified with set_scene()) active, so -// that it will transform future rendered geometry. -// Normally this is only called from the draw process, -// and usually it is called by set_scene(). -// -// The return value is true if the lens is acceptable, -// false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Makes the current lens (whichever lens was most recently specified with + * set_scene()) active, so that it will transform future rendered geometry. + * Normally this is only called from the draw process, and usually it is + * called by set_scene(). + * + * The return value is true if the lens is acceptable, false if it is not. + */ bool TinyGraphicsStateGuardian:: prepare_lens() { _transform_stale = true; return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_frame -// Access: Public, Virtual -// Description: Called before each frame is rendered, to allow the -// GSG a chance to do any internal cleanup before -// beginning the frame. -// -// The return value is true if successful (in which case -// the frame will be drawn and end_frame() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_frame() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called before each frame is rendered, to allow the GSG a chance to do any + * internal cleanup before beginning the frame. + * + * The return value is true if successful (in which case the frame will be + * drawn and end_frame() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_frame() will not be called). + */ bool TinyGraphicsStateGuardian:: begin_frame(Thread *current_thread) { if (!GraphicsStateGuardian::begin_frame(current_thread)) { @@ -409,40 +371,32 @@ begin_frame(Thread *current_thread) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsStateGuardian::begin_scene -// Access: Public, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the beginning of drawing commands for a "scene" -// (usually a particular DisplayRegion) within a frame. -// All 3-D drawing commands, except the clear operation, -// must be enclosed within begin_scene() .. end_scene(). -// -// The return value is true if successful (in which case -// the scene will be drawn and end_scene() will be -// called later), or false if unsuccessful (in which -// case nothing will be drawn and end_scene() will not -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the beginning of + * drawing commands for a "scene" (usually a particular DisplayRegion) within + * a frame. All 3-D drawing commands, except the clear operation, must be + * enclosed within begin_scene() .. end_scene(). + * + * The return value is true if successful (in which case the scene will be + * drawn and end_scene() will be called later), or false if unsuccessful (in + * which case nothing will be drawn and end_scene() will not be called). + */ bool TinyGraphicsStateGuardian:: begin_scene() { return GraphicsStateGuardian::begin_scene(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::end_scene -// Access: Protected, Virtual -// Description: Called between begin_frame() and end_frame() to mark -// the end of drawing commands for a "scene" (usually a -// particular DisplayRegion) within a frame. All 3-D -// drawing commands, except the clear operation, must be -// enclosed within begin_scene() .. end_scene(). -//////////////////////////////////////////////////////////////////// +/** + * Called between begin_frame() and end_frame() to mark the end of drawing + * commands for a "scene" (usually a particular DisplayRegion) within a frame. + * All 3-D drawing commands, except the clear operation, must be enclosed + * within begin_scene() .. end_scene(). + */ void TinyGraphicsStateGuardian:: end_scene() { if (_c->zb == _aux_frame_buffer) { - // Copy the aux frame buffer into the main scene now, zooming it - // up to the appropriate size. + // Copy the aux frame buffer into the main scene now, zooming it up to the + // appropriate size. int xmin, ymin, xsize, ysize; _current_display_region->get_region_pixels_i(xmin, ymin, xsize, ysize); PN_stdfloat pixel_factor = _current_display_region->get_pixel_factor(); @@ -464,13 +418,10 @@ end_scene() { GraphicsStateGuardian::end_scene(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::end_frame -// Access: Public, Virtual -// Description: Called after each frame is rendered, to allow the -// GSG a chance to do any internal cleanup after -// rendering the frame, and before the window flips. -//////////////////////////////////////////////////////////////////// +/** + * Called after each frame is rendered, to allow the GSG a chance to do any + * internal cleanup after rendering the frame, and before the window flips. + */ void TinyGraphicsStateGuardian:: end_frame(Thread *current_thread) { GraphicsStateGuardian::end_frame(current_thread); @@ -511,14 +462,11 @@ end_frame(Thread *current_thread) { } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::begin_draw_primitives -// Access: Public, Virtual -// Description: Called before a sequence of draw_primitive() -// functions are called, this should prepare the vertex -// data for rendering. It returns true if the vertices -// are ok, false to abort this group of primitives. -//////////////////////////////////////////////////////////////////// +/** + * Called before a sequence of draw_primitive() functions are called, this + * should prepare the vertex data for rendering. It returns true if the + * vertices are ok, false to abort this group of primitives. + */ bool TinyGraphicsStateGuardian:: begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, @@ -540,8 +488,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, // Set up the proper transform. if (_data_reader->is_vertex_transformed()) { // If the vertex data claims to be already transformed into clip - // coordinates, wipe out the current projection and modelview - // matrix (so we don't attempt to transform it again). + // coordinates, wipe out the current projection and modelview matrix (so + // we don't attempt to transform it again). const TransformState *ident = TransformState::make_identity(); load_matrix(&_c->matrix_model_view, ident); load_matrix(&_c->matrix_projection, _scissor_mat); @@ -582,8 +530,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, _transform_stale = false; } - // Figure out the subset of vertices we will be using in this - // operation. + // Figure out the subset of vertices we will be using in this operation. int num_vertices = data_reader->get_num_rows(); _min_vertex = num_vertices; _max_vertex = 0; @@ -600,8 +547,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return false; } - // Now copy all of those vertices into our working table, - // transforming into screen space them as we go. + // Now copy all of those vertices into our working table, transforming into + // screen space them as we go. int num_used_vertices = _max_vertex - _min_vertex + 1; if (_vertices_size < num_used_vertices) { if (_vertices_size == 0) { @@ -731,8 +678,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } if (_texturing_state != 0 && _texture_replace) { - // We don't need the vertex color or lighting calculation after - // all, since the current texture will just hide all of that. + // We don't need the vertex color or lighting calculation after all, since + // the current texture will just hide all of that. needs_color = false; needs_normal = false; } @@ -797,8 +744,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, v->edge_flag = 1; } - // Set up the appropriate function callback for filling triangles, - // according to the current state. + // Set up the appropriate function callback for filling triangles, according + // to the current state. bool srgb_blend = _current_properties->get_srgb_color(); @@ -863,8 +810,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, const ColorBlendAttrib *target_color_blend = DCAST(ColorBlendAttrib, _target_rs->get_attrib_def(ColorBlendAttrib::get_class_slot())); if (target_color_blend->get_mode() == ColorBlendAttrib::M_add) { - // If we have a color blend set that we can support, it overrides - // the transparency set. + // If we have a color blend set that we can support, it overrides the + // transparency set. LColor c = target_color_blend->get_color(); _c->zb->blend_r = (int)(c[0] * ZB_POINT_RED_MAX); _c->zb->blend_g = (int)(c[1] * ZB_POINT_GREEN_MAX); @@ -921,8 +868,8 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, const ShadeModelAttrib *target_shade_model = DCAST(ShadeModelAttrib, _target_rs->get_attrib_def(ShadeModelAttrib::get_class_slot())); ShadeModelAttrib::Mode shade_model = target_shade_model->get_mode(); if (!needs_normal && !needs_color) { - // With no per-vertex lighting, and no per-vertex colors, we might - // as well use the flat shading model. + // With no per-vertex lighting, and no per-vertex colors, we might as well + // use the flat shading model. shade_model = ShadeModelAttrib::M_flat; } int shade_model_state = 2; // smooth @@ -946,15 +893,15 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (texturing_state < 3 && (_c->matrix_model_projection_no_w_transform || _filled_flat)) { - // Don't bother with the perspective-correct algorithm if we're - // under an orthonormal lens, e.g. render2d; or if - // RenderMode::M_filled_flat is in effect. + // Don't bother with the perspective-correct algorithm if we're under an + // orthonormal lens, e.g. render2d; or if RenderMode::M_filled_flat is + // in effect. texturing_state = 1; // textured (not perspective correct) } if (_texture_replace) { - // If we're completely replacing the underlying color, then it - // doesn't matter what the color is. + // If we're completely replacing the underlying color, then it doesn't + // matter what the color is. shade_model_state = 0; } } @@ -978,11 +925,9 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::draw_triangles -// Access: Public, Virtual -// Description: Draws a series of disconnected triangles. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected triangles. + */ bool TinyGraphicsStateGuardian:: draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { PStatTimer timer(_draw_primitive_pcollector, reader->get_current_thread()); @@ -1062,11 +1007,9 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::draw_tristrips -// Access: Public, Virtual -// Description: Draws a series of triangle strips. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of triangle strips. + */ bool TinyGraphicsStateGuardian:: draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { PStatTimer timer(_draw_primitive_pcollector, reader->get_current_thread()); @@ -1077,8 +1020,8 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { } #endif // NDEBUG - // Send the individual triangle strips, stepping over the - // degenerate vertices. + // Send the individual triangle strips, stepping over the degenerate + // vertices. CPTA_int ends = reader->get_ends(); _primitive_batches_tristrip_pcollector.add_level(ends.size()); @@ -1205,11 +1148,9 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::draw_lines -// Access: Public, Virtual -// Description: Draws a series of disconnected line segments. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected line segments. + */ bool TinyGraphicsStateGuardian:: draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { PStatTimer timer(_draw_primitive_pcollector, reader->get_current_thread()); @@ -1284,11 +1225,9 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::draw_points -// Access: Public, Virtual -// Description: Draws a series of disconnected points. -//////////////////////////////////////////////////////////////////// +/** + * Draws a series of disconnected points. + */ bool TinyGraphicsStateGuardian:: draw_points(const GeomPrimitivePipelineReader *reader, bool force) { PStatTimer timer(_draw_primitive_pcollector, reader->get_current_thread()); @@ -1359,13 +1298,10 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::end_draw_primitives() -// Access: Public, Virtual -// Description: Called after a sequence of draw_primitive() -// functions are called, this should do whatever cleanup -// is appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Called after a sequence of draw_primitive() functions are called, this + * should do whatever cleanup is appropriate. + */ void TinyGraphicsStateGuardian:: end_draw_primitives() { @@ -1386,15 +1322,12 @@ end_draw_primitives() { GraphicsStateGuardian::end_draw_primitives(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::framebuffer_copy_to_texture -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display -// region from the framebuffer into texture memory. -// -// If z > -1, it is the cube map index into which to -// copy. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into texture memory. + * + * If z > -1, it is the cube map index into which to copy. + */ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, @@ -1436,16 +1369,13 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z, return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::framebuffer_copy_to_ram -// Access: Public, Virtual -// Description: Copy the pixels within the indicated display region -// from the framebuffer into system memory, not texture -// memory. Returns true on success, false on failure. -// -// This completely redefines the ram image of the -// indicated texture. -//////////////////////////////////////////////////////////////////// +/** + * Copy the pixels within the indicated display region from the framebuffer + * into system memory, not texture memory. Returns true on success, false on + * failure. + * + * This completely redefines the ram image of the indicated texture. + */ bool TinyGraphicsStateGuardian:: framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, @@ -1523,23 +1453,18 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::set_state_and_transform -// Access: Public, Virtual -// Description: Simultaneously resets the render state and the -// transform state. -// -// This transform specified is the "internal" net -// transform, already converted into the GSG's internal -// coordinate space by composing it to -// get_cs_transform(). (Previously, this used to be the -// "external" net transform, with the assumption that -// that GSG would convert it internally, but that is no -// longer the case.) -// -// Special case: if (state==NULL), then the target -// state is already stored in _target. -//////////////////////////////////////////////////////////////////// +/** + * Simultaneously resets the render state and the transform state. + * + * This transform specified is the "internal" net transform, already converted + * into the GSG's internal coordinate space by composing it to + * get_cs_transform(). (Previously, this used to be the "external" net + * transform, with the assumption that that GSG would convert it internally, + * but that is no longer the case.) + * + * Special case: if (state==NULL), then the target state is already stored in + * _target. + */ void TinyGraphicsStateGuardian:: set_state_and_transform(const RenderState *target, const TransformState *transform) { @@ -1591,7 +1516,7 @@ set_state_and_transform(const RenderState *target, int depth_offset_slot = DepthOffsetAttrib::get_class_slot(); if (_target_rs->get_attrib(depth_offset_slot) != _state_rs->get_attrib(depth_offset_slot) || !_state_mask.get_bit(depth_offset_slot)) { - //PStatTimer timer(_draw_set_state_depth_offset_pcollector); + // PStatTimer timer(_draw_set_state_depth_offset_pcollector); do_issue_depth_offset(); _state_mask.set_bit(depth_offset_slot); } @@ -1648,19 +1573,16 @@ set_state_and_transform(const RenderState *target, _state_rs = _target_rs; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::prepare_texture -// Access: Public, Virtual -// Description: Creates whatever structures the GSG requires to -// represent the texture internally, and returns a -// newly-allocated TextureContext object with this data. -// It is the responsibility of the calling function to -// later call release_texture() with this same pointer -// (which will also delete the pointer). -// -// This function should not be called directly to -// prepare a texture. Instead, call Texture::prepare(). -//////////////////////////////////////////////////////////////////// +/** + * Creates whatever structures the GSG requires to represent the texture + * internally, and returns a newly-allocated TextureContext object with this + * data. It is the responsibility of the calling function to later call + * release_texture() with this same pointer (which will also delete the + * pointer). + * + * This function should not be called directly to prepare a texture. Instead, + * call Texture::prepare(). + */ TextureContext *TinyGraphicsStateGuardian:: prepare_texture(Texture *tex, int view) { switch (tex->get_texture_type()) { @@ -1678,8 +1600,8 @@ prepare_texture(Texture *tex, int view) { } // Even though the texture might be compressed now, it might have an - // available uncompressed version that we can load. So don't reject - // it out-of-hand just because it's compressed. + // available uncompressed version that we can load. So don't reject it out- + // of-hand just because it's compressed. /* if (tex->get_ram_image_compression() != Texture::CM_off) { tinydisplay_cat.info() @@ -1694,22 +1616,16 @@ prepare_texture(Texture *tex, int view) { return gtc; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::update_texture -// Access: Public, Virtual -// Description: Ensures that the current Texture data is refreshed -// onto the GSG. This means updating the texture -// properties and/or re-uploading the texture image, if -// necessary. This should only be called within the -// draw thread. -// -// If force is true, this function will not return until -// the texture has been fully uploaded. If force is -// false, the function may choose to upload a simple -// version of the texture instead, if the texture is not -// fully resident (and if get_incomplete_render() is -// true). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the current Texture data is refreshed onto the GSG. This + * means updating the texture properties and/or re-uploading the texture + * image, if necessary. This should only be called within the draw thread. + * + * If force is true, this function will not return until the texture has been + * fully uploaded. If force is false, the function may choose to upload a + * simple version of the texture instead, if the texture is not fully resident + * (and if get_incomplete_render() is true). + */ bool TinyGraphicsStateGuardian:: update_texture(TextureContext *tc, bool force) { apply_texture(tc); @@ -1733,22 +1649,16 @@ update_texture(TextureContext *tc, bool force) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::update_texture -// Access: Public -// Description: Ensures that the current Texture data is refreshed -// onto the GSG. This means updating the texture -// properties and/or re-uploading the texture image, if -// necessary. This should only be called within the -// draw thread. -// -// If force is true, this function will not return until -// the texture has been fully uploaded. If force is -// false, the function may choose to upload a simple -// version of the texture instead, if the texture is not -// fully resident (and if get_incomplete_render() is -// true). -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the current Texture data is refreshed onto the GSG. This + * means updating the texture properties and/or re-uploading the texture + * image, if necessary. This should only be called within the draw thread. + * + * If force is true, this function will not return until the texture has been + * fully uploaded. If force is false, the function may choose to upload a + * simple version of the texture instead, if the texture is not fully resident + * (and if get_incomplete_render() is true). + */ bool TinyGraphicsStateGuardian:: update_texture(TextureContext *tc, bool force, int stage_index, bool uses_mipmaps) { if (!update_texture(tc, force)) { @@ -1790,14 +1700,11 @@ update_texture(TextureContext *tc, bool force, int stage_index, bool uses_mipmap return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::release_texture -// Access: Public, Virtual -// Description: Frees the GL resources previously allocated for the -// texture. This function should never be called -// directly; instead, call Texture::release() (or simply -// let the Texture destruct). -//////////////////////////////////////////////////////////////////// +/** + * Frees the GL resources previously allocated for the texture. This function + * should never be called directly; instead, call Texture::release() (or + * simply let the Texture destruct). + */ void TinyGraphicsStateGuardian:: release_texture(TextureContext *tc) { TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); @@ -1821,15 +1728,12 @@ release_texture(TextureContext *tc) { delete gtc; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_light -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_light() { - // Initialize the current ambient light total and newly enabled - // light list + // Initialize the current ambient light total and newly enabled light list LColor cur_ambient_light(0.0f, 0.0f, 0.0f, 0.0f); int num_enabled = 0; @@ -1870,8 +1774,7 @@ do_issue_light() { light_obj->bind(this, light, num_enabled); num_enabled++; - // Handle the diffuse color here, since all lights have this - // property. + // Handle the diffuse color here, since all lights have this property. GLLight *gl_light = _c->first_light; nassertv(gl_light != NULL); const LColor &diffuse = light_obj->get_color(); @@ -1888,19 +1791,16 @@ do_issue_light() { _c->ambient_light_model.v[2] = cur_ambient_light[2]; _c->ambient_light_model.v[3] = cur_ambient_light[3]; - // Changing the lighting state means we need to reapply the - // transform in begin_draw_primitives(). + // Changing the lighting state means we need to reapply the transform in + // begin_draw_primitives(). _transform_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void TinyGraphicsStateGuardian:: bind_light(PointLight *light_obj, const NodePath &light, int light_id) { pair lookup = _plights.insert(Lights::value_type(light, GLLight())); @@ -1915,8 +1815,8 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { gl_light->specular.v[2] = specular[2]; gl_light->specular.v[3] = specular[3]; - // Position needs to specify x, y, z, and w - // w == 1 implies non-infinite position + // Position needs to specify x, y, z, and w w == 1 implies non-infinite + // position CPT(TransformState) render_transform = _cs_transform->compose(_scene_setup->get_world_transform()); @@ -1948,14 +1848,11 @@ bind_light(PointLight *light_obj, const NodePath &light, int light_id) { _c->first_light = gl_light; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void TinyGraphicsStateGuardian:: bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { pair lookup = _dlights.insert(Lights::value_type(light, GLLight())); @@ -1970,8 +1867,8 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { gl_light->specular.v[2] = specular[2]; gl_light->specular.v[3] = specular[3]; - // Position needs to specify x, y, z, and w - // w == 0 implies light is at infinity + // Position needs to specify x, y, z, and w w == 0 implies light is at + // infinity CPT(TransformState) render_transform = _cs_transform->compose(_scene_setup->get_world_transform()); @@ -1996,8 +1893,8 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { // Cutoff == 180 means uniform point light source gl_light->spot_cutoff = 180.0f; - // Default attenuation values (only spotlight and point light can - // modify these) + // Default attenuation values (only spotlight and point light can modify + // these) gl_light->attenuation[0] = 1.0f; gl_light->attenuation[1] = 0.0f; gl_light->attenuation[2] = 0.0f; @@ -2010,14 +1907,11 @@ bind_light(DirectionalLight *light_obj, const NodePath &light, int light_id) { _c->first_light = gl_light; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::bind_light -// Access: Public, Virtual -// Description: Called the first time a particular light has been -// bound to a given id within a frame, this should set -// up the associated hardware light with the light's -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Called the first time a particular light has been bound to a given id + * within a frame, this should set up the associated hardware light with the + * light's properties. + */ void TinyGraphicsStateGuardian:: bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { pair lookup = _plights.insert(Lights::value_type(light, GLLight())); @@ -2035,8 +1929,8 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { Lens *lens = light_obj->get_lens(); nassertv(lens != (Lens *)NULL); - // Position needs to specify x, y, z, and w - // w == 1 implies non-infinite position + // Position needs to specify x, y, z, and w w == 1 implies non-infinite + // position CPT(TransformState) render_transform = _cs_transform->compose(_scene_setup->get_world_transform()); @@ -2078,15 +1972,13 @@ bind_light(Spotlight *light_obj, const NodePath &light, int light_id) { _c->first_light = gl_light; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_transform -// Access: Protected -// Description: Sends the indicated transform matrix to the graphics -// API to be applied to future vertices. -// -// This transform is the internal_transform, already -// converted into the GSG's internal coordinate system. -//////////////////////////////////////////////////////////////////// +/** + * Sends the indicated transform matrix to the graphics API to be applied to + * future vertices. + * + * This transform is the internal_transform, already converted into the GSG's + * internal coordinate system. + */ void TinyGraphicsStateGuardian:: do_issue_transform() { _transform_state_pcollector.add_level(1); @@ -2097,11 +1989,9 @@ do_issue_transform() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_render_mode -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_render_mode() { const RenderModeAttrib *target_render_mode = DCAST(RenderModeAttrib, _target_rs->get_attrib_def(RenderModeAttrib::get_class_slot())); @@ -2137,11 +2027,9 @@ do_issue_render_mode() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_rescale_normal -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_rescale_normal() { const RescaleNormalAttrib *target_rescale_normal = DCAST(RescaleNormalAttrib, _target_rs->get_attrib_def(RescaleNormalAttrib::get_class_slot())); @@ -2172,11 +2060,9 @@ do_issue_rescale_normal() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_depth_offset -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_depth_offset() { const DepthOffsetAttrib *target_depth_offset = DCAST(DepthOffsetAttrib, _target_rs->get_attrib_def(DepthOffsetAttrib::get_class_slot())); @@ -2194,11 +2080,9 @@ do_issue_depth_offset() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_cull_face -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_cull_face() { const CullFaceAttrib *target_cull_face = DCAST(CullFaceAttrib, _target_rs->get_attrib_def(CullFaceAttrib::get_class_slot())); @@ -2223,11 +2107,9 @@ do_issue_cull_face() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_material -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_material() { static Material empty; @@ -2254,11 +2136,9 @@ do_issue_material() { _c->light_model_two_side = material->get_twoside(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_texture -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_texture() { _texturing_state = 0; // untextured @@ -2316,8 +2196,8 @@ do_issue_texture() { ZTextureDef *texture_def = &_c->zb->current_textures[si]; - // Fill in the filter func pointers. These may not actually get - // called, if we decide below we can inline the filters. + // Fill in the filter func pointers. These may not actually get called, + // if we decide below we can inline the filters. SamplerState::FilterType minfilter = sampler.get_minfilter(); SamplerState::FilterType magfilter = sampler.get_magfilter(); @@ -2330,8 +2210,8 @@ do_issue_texture() { } } - // Depending on this particular texture's quality level, we may - // downgrade the requested filters. + // Depending on this particular texture's quality level, we may downgrade + // the requested filters. if (quality_level == Texture::QL_fastest) { minfilter = SamplerState::FT_nearest; magfilter = SamplerState::FT_nearest; @@ -2360,28 +2240,27 @@ do_issue_texture() { } if (wrap_u != SamplerState::WM_repeat || wrap_v != SamplerState::WM_repeat) { - // We have some nonstandard wrap mode. This will force the use - // of the general texfilter mode. + // We have some nonstandard wrap mode. This will force the use of the + // general texfilter mode. needs_general = true; - // We need another level of indirection to implement the - // different texcoord wrap modes. This means we will be using - // the _impl function pointers, which are called by the toplevel - // function. + // We need another level of indirection to implement the different + // texcoord wrap modes. This means we will be using the _impl function + // pointers, which are called by the toplevel function. texture_def->tex_minfilter_func_impl = texture_def->tex_minfilter_func; texture_def->tex_magfilter_func_impl = texture_def->tex_magfilter_func; - // Now assign the toplevel function pointer to do the - // appropriate texture coordinate wrapping/clamping. + // Now assign the toplevel function pointer to do the appropriate + // texture coordinate wrappingclamping. texture_def->tex_minfilter_func = apply_wrap_general_minfilter; texture_def->tex_magfilter_func = apply_wrap_general_magfilter; texture_def->tex_wrap_u_func = get_tex_wrap_func(wrap_u); texture_def->tex_wrap_v_func = get_tex_wrap_func(wrap_v); - // The following special cases are handled inline, rather than - // relying on the above wrap function pointers. + // The following special cases are handled inline, rather than relying + // on the above wrap function pointers. if (wrap_u && SamplerState::WM_border_color && wrap_v == SamplerState::WM_border_color) { texture_def->tex_minfilter_func = apply_wrap_border_color_minfilter; texture_def->tex_magfilter_func = apply_wrap_border_color_magfilter; @@ -2439,27 +2318,25 @@ do_issue_texture() { _texturing_state = 1; // textured (not perspective correct, no multitexture) } else { - // This is the default texture filter. We use nearest sampling if - // there are no mipmaps, and mipmap_nearest if there are any - // mipmaps--these are the two inlined filters. + // This is the default texture filter. We use nearest sampling if there + // are no mipmaps, and mipmap_nearest if there are any mipmaps--these are + // the two inlined filters. _texfilter_state = 0; // tnearest if (any_mipmap) { _texfilter_state = 1; // tmipmap } if (needs_general) { - // To support nonstandard texcoord wrapping etc, we need to - // force the general texfilter mode. + // To support nonstandard texcoord wrapping etc, we need to force the + // general texfilter mode. _texfilter_state = 2; // tgeneral } } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_issue_scissor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyGraphicsStateGuardian:: do_issue_scissor() { const ScissorAttrib *target_scissor = DCAST(ScissorAttrib, _target_rs->get_attrib_def(ScissorAttrib::get_class_slot())); @@ -2467,12 +2344,10 @@ do_issue_scissor() { set_scissor(frame[0], frame[1], frame[2], frame[3]); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::set_scissor -// Access: Private -// Description: Sets up the scissor region, as a set of coordinates -// relative to the current viewport. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the scissor region, as a set of coordinates relative to the current + * viewport. + */ void TinyGraphicsStateGuardian:: set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) { _c->scissor.left = left; @@ -2486,21 +2361,18 @@ set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat PN_stdfloat xcenter = (left + right) - 1.0f; PN_stdfloat ycenter = (bottom + top) - 1.0f; if (xsize == 0.0f || ysize == 0.0f) { - // If the scissor region is zero, nothing will be drawn anyway, so - // don't worry about it. + // If the scissor region is zero, nothing will be drawn anyway, so don't + // worry about it. _scissor_mat = TransformState::make_identity(); } else { _scissor_mat = TransformState::make_scale(LVecBase3(1.0f / xsize, 1.0f / ysize, 1.0f))->compose(TransformState::make_pos(LPoint3(-xcenter, -ycenter, 0.0f))); } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::apply_texture -// Access: Protected -// Description: Updates the graphics state with the current -// information for this texture, and makes it the -// current texture available for rendering. -//////////////////////////////////////////////////////////////////// +/** + * Updates the graphics state with the current information for this texture, + * and makes it the current texture available for rendering. + */ bool TinyGraphicsStateGuardian:: apply_texture(TextureContext *tc) { TinyTextureContext *gtc = DCAST(TinyTextureContext, tc); @@ -2509,14 +2381,12 @@ apply_texture(TextureContext *tc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::upload_texture -// Access: Protected -// Description: Uploads the texture image to the graphics state. -// -// The return value is true if successful, or false if -// the texture has no image. -//////////////////////////////////////////////////////////////////// +/** + * Uploads the texture image to the graphics state. + * + * The return value is true if successful, or false if the texture has no + * image. + */ bool TinyGraphicsStateGuardian:: upload_texture(TinyTextureContext *gtc, bool force, bool uses_mipmaps) { Texture *tex = gtc->get_texture(); @@ -2525,8 +2395,8 @@ upload_texture(TinyTextureContext *gtc, bool force, bool uses_mipmaps) { if (!tex->has_ram_image() && tex->might_have_ram_image() && tex->has_simple_ram_image() && !_loader.is_null()) { - // If we don't have the texture data right now, go get it, but in - // the meantime load a temporary simple image in its place. + // If we don't have the texture data right now, go get it, but in the + // meantime load a temporary simple image in its place. async_reload_texture(gtc); if (!tex->has_ram_image()) { if (gtc->was_simple_image_modified()) { @@ -2645,16 +2515,12 @@ upload_texture(TinyTextureContext *gtc, bool force, bool uses_mipmaps) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::upload_simple_texture -// Access: Protected -// Description: This is used as a standin for upload_texture -// when the texture in question is unavailable (e.g. it -// hasn't yet been loaded from disk). Until the texture -// image itself becomes available, we will render the -// texture's "simple" image--a sharply reduced version -// of the same texture. -//////////////////////////////////////////////////////////////////// +/** + * This is used as a standin for upload_texture when the texture in question + * is unavailable (e.g. it hasn't yet been loaded from disk). Until the + * texture image itself becomes available, we will render the texture's + * "simple" image--a sharply reduced version of the same texture. + */ bool TinyGraphicsStateGuardian:: upload_simple_texture(TinyTextureContext *gtc) { PStatTimer timer(_load_texture_pcollector); @@ -2698,14 +2564,11 @@ upload_simple_texture(TinyTextureContext *gtc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::setup_gltex -// Access: Private -// Description: Sets the GLTexture size, bits, and masks -// appropriately, and allocates space for a pixmap. -// Does not fill the pixmap contents. Returns true if -// the texture is a valid size, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the GLTexture size, bits, and masks appropriately, and allocates space + * for a pixmap. Does not fill the pixmap contents. Returns true if the + * texture is a valid size, false otherwise. + */ bool TinyGraphicsStateGuardian:: setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { int s_bits = get_tex_shift(x_size); @@ -2729,10 +2592,9 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { gltex->num_levels = num_levels; - // We allocate one big buffer, large enough to include all the - // mipmap levels, and index into that buffer for each level. This - // cuts down on the number of individual alloc calls we have to make - // for each texture. + // We allocate one big buffer, large enough to include all the mipmap + // levels, and index into that buffer for each level. This cuts down on the + // number of individual alloc calls we have to make for each texture. int total_bytecount = 0; // Count up the total bytes required for all mipmap levels. @@ -2782,9 +2644,9 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { ++level; } - // Fill out the remaining mipmap arrays with copies of the last - // level, so we don't have to be concerned with running off the end - // of this array while scanning out triangles. + // Fill out the remaining mipmap arrays with copies of the last level, so we + // don't have to be concerned with running off the end of this array while + // scanning out triangles. while (level < MAX_MIPMAP_LEVELS) { gltex->levels[level] = *dest; ++level; @@ -2793,13 +2655,11 @@ setup_gltex(GLTexture *gltex, int x_size, int y_size, int num_levels) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::get_tex_shift -// Access: Private -// Description: Calculates the bit shift count, such that (1 << shift) -// == size. Returns -1 if the size is not a power of 2 -// or is larger than our largest allowable size. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the bit shift count, such that (1 << shift) == size. Returns -1 + * if the size is not a power of 2 or is larger than our largest allowable + * size. + */ int TinyGraphicsStateGuardian:: get_tex_shift(int orig_size) { if ((orig_size & (orig_size - 1)) != 0) { @@ -2813,12 +2673,10 @@ get_tex_shift(int orig_size) { return count_bits_in_word((unsigned int)orig_size - 1); } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_lum_image -// Access: Private, Static -// Description: Copies and scales the one-channel luminance image -// from the texture into the indicated ZTexture pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the one-channel luminance image from the texture into the + * indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level) { Texture *tex = gtc->get_texture(); @@ -2853,12 +2711,10 @@ copy_lum_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_alpha_image -// Access: Private, Static -// Description: Copies and scales the one-channel alpha image -// from the texture into the indicated ZTexture pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the one-channel alpha image from the texture into the + * indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level) { Texture *tex = gtc->get_texture(); @@ -2891,13 +2747,10 @@ copy_alpha_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext * } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_one_channel_image -// Access: Private, Static -// Description: Copies and scales the one-channel image (with a -// single channel, e.g. red, green, or blue) from -// the texture into the indicated ZTexture pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the one-channel image (with a single channel, e.g. red, + * green, or blue) from the texture into the indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level, int channel) { Texture *tex = gtc->get_texture(); @@ -2959,13 +2812,10 @@ copy_one_channel_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureCon } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_la_image -// Access: Private, Static -// Description: Copies and scales the two-channel luminance-alpha -// image from the texture into the indicated ZTexture -// pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the two-channel luminance-alpha image from the texture + * into the indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_la_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level) { Texture *tex = gtc->get_texture(); @@ -2999,12 +2849,10 @@ copy_la_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_rgb_image -// Access: Private, Static -// Description: Copies and scales the three-channel RGB image from -// the texture into the indicated ZTexture pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the three-channel RGB image from the texture into the + * indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level) { Texture *tex = gtc->get_texture(); @@ -3038,12 +2886,10 @@ copy_rgb_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gt } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::copy_rgba_image -// Access: Private, Static -// Description: Copies and scales the four-channel RGBA image from -// the texture into the indicated ZTexture pixmap. -//////////////////////////////////////////////////////////////////// +/** + * Copies and scales the four-channel RGBA image from the texture into the + * indicated ZTexture pixmap. + */ void TinyGraphicsStateGuardian:: copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *gtc, int level) { Texture *tex = gtc->get_texture(); @@ -3077,12 +2923,9 @@ copy_rgba_image(ZTextureLevel *dest, int xsize, int ysize, TinyTextureContext *g } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::setup_material -// Access: Private -// Description: Applies the desired parametesr to the indicated -// GLMaterial object. -//////////////////////////////////////////////////////////////////// +/** + * Applies the desired parametesr to the indicated GLMaterial object. + */ void TinyGraphicsStateGuardian:: setup_material(GLMaterial *gl_material, const Material *material) { const LColor &specular = material->get_specular(); @@ -3123,12 +2966,10 @@ setup_material(GLMaterial *gl_material, const Material *material) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::do_auto_rescale_normal -// Access: Protected -// Description: Sets the state to either rescale or normalize the -// normals according to the current transform. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state to either rescale or normalize the normals according to the + * current transform. + */ void TinyGraphicsStateGuardian:: do_auto_rescale_normal() { if (_internal_transform->has_uniform_scale()) { @@ -3143,13 +2984,10 @@ do_auto_rescale_normal() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::load_matrix -// Access: Private, Static -// Description: Copies the Panda matrix stored in the indicated -// TransformState object into the indicated TinyGL -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Copies the Panda matrix stored in the indicated TransformState object into + * the indicated TinyGL matrix. + */ void TinyGraphicsStateGuardian:: load_matrix(M4 *matrix, const TransformState *transform) { const LMatrix4 &pm = transform->get_mat(); @@ -3161,13 +2999,11 @@ load_matrix(M4 *matrix, const TransformState *transform) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::get_color_blend_op -// Access: Private, Static -// Description: Returns the integer element of store_pixel_funcs (as -// defined by store_pixel.py) that corresponds to the -// indicated ColorBlendAttrib operand code. -//////////////////////////////////////////////////////////////////// +/** + * Returns the integer element of store_pixel_funcs (as defined by + * store_pixel.py) that corresponds to the indicated ColorBlendAttrib operand + * code. + */ int TinyGraphicsStateGuardian:: get_color_blend_op(ColorBlendAttrib::Operand operand) { switch (operand) { @@ -3215,12 +3051,10 @@ get_color_blend_op(ColorBlendAttrib::Operand operand) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::get_tex_filter_func -// Access: Private, Static -// Description: Returns the pointer to the appropriate filter -// function according to the texture's filter type. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the appropriate filter function according to the + * texture's filter type. + */ ZB_lookupTextureFunc TinyGraphicsStateGuardian:: get_tex_filter_func(SamplerState::FilterType filter) { switch (filter) { @@ -3247,12 +3081,10 @@ get_tex_filter_func(SamplerState::FilterType filter) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::get_tex_wrap_func -// Access: Private, Static -// Description: Returns the pointer to the appropriate wrap -// function according to the texture's wrap mode. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the appropriate wrap function according to the + * texture's wrap mode. + */ ZB_texWrapFunc TinyGraphicsStateGuardian:: get_tex_wrap_func(SamplerState::WrapMode wrap_mode) { switch (wrap_mode) { @@ -3274,24 +3106,20 @@ get_tex_wrap_func(SamplerState::WrapMode wrap_mode) { return &texcoord_repeat; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::texgen_null -// Access: Private, Static -// Description: Generates invalid texture coordinates. Used when -// texture coordinate params are invalid or unsupported. -//////////////////////////////////////////////////////////////////// +/** + * Generates invalid texture coordinates. Used when texture coordinate params + * are invalid or unsupported. + */ void TinyGraphicsStateGuardian:: texgen_null(V2 &result, TinyGraphicsStateGuardian::TexCoordData &) { result.v[0] = 0.0; result.v[1] = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::texgen_simple -// Access: Private, Static -// Description: Extracts a simple 2-d texture coordinate pair from -// the vertex data, without applying any texture matrix. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a simple 2-d texture coordinate pair from the vertex data, without + * applying any texture matrix. + */ void TinyGraphicsStateGuardian:: texgen_simple(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // No need to transform, so just extract as two-component. @@ -3300,12 +3128,10 @@ texgen_simple(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { result.v[1] = d[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::texgen_simple -// Access: Private, Static -// Description: Extracts a simple 2-d texture coordinate pair from -// the vertex data, and then applies a texture matrix. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a simple 2-d texture coordinate pair from the vertex data, and + * then applies a texture matrix. + */ void TinyGraphicsStateGuardian:: texgen_texmat(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // Transform texcoords as a four-component vector for most generality. @@ -3314,12 +3140,10 @@ texgen_texmat(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { result.v[1] = d[1] / d[3]; } -//////////////////////////////////////////////////////////////////// -// Function: TinyGraphicsStateGuardian::texgen_sphere_map -// Access: Private, Static -// Description: Computes appropriate sphere map texture coordinates -// based on the eye normal coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Computes appropriate sphere map texture coordinates based on the eye normal + * coordinates. + */ void TinyGraphicsStateGuardian:: texgen_sphere_map(V2 &result, TinyGraphicsStateGuardian::TexCoordData &tcdata) { // Get the normal and point in eye coordinates. diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h index 443a21cb00..65e01d7fbc 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.h +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: tinyGraphicsStateGuardian.h -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyGraphicsStateGuardian.h + * @author drose + * @date 2008-04-24 + */ #ifndef TINYGRAPHICSSTATEGUARDIAN_H #define TINYGRAPHICSSTATEGUARDIAN_H @@ -27,19 +26,15 @@ class TinyTextureContext; -//////////////////////////////////////////////////////////////////// -// Class : TinyGraphicsStateGuardian -// Description : An interface to the TinyPanda software rendering code -// within this module. -// -// TinyPanda takes its name from TinyGL, the -// public-domain software renderer (see -// http://fabrice.bellard.free.fr/TinyGL/ ) from which -// this code originated. It has since been heavily -// modified, to integrate it closely with Panda, and to -// add additional features such as blending, filtering, -// and multitexturing. -//////////////////////////////////////////////////////////////////// +/** + * An interface to the TinyPanda software rendering code within this module. + * + * TinyPanda takes its name from TinyGL, the public-domain software renderer + * (see http://fabrice.bellard.free.fr/TinyGL/ ) from which this code + * originated. It has since been heavily modified, to integrate it closely + * with Panda, and to add additional features such as blending, filtering, and + * multitexturing. + */ class EXPCL_TINYDISPLAY TinyGraphicsStateGuardian : public GraphicsStateGuardian { public: TinyGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -154,8 +149,8 @@ public: ZBuffer *_current_frame_buffer; private: - // Allocated by prepare_display_region when necessary for a zoomed - // display region. + // Allocated by prepare_display_region when necessary for a zoomed display + // region. ZBuffer *_aux_frame_buffer; GLContext *_c; @@ -173,9 +168,9 @@ private: CPT(TransformState) _scissor_mat; - // Cache the data necessary to bind each particular light each - // frame, so if we bind a given light multiple times, we only have - // to compute its data once. + // Cache the data necessary to bind each particular light each frame, so if + // we bind a given light multiple times, we only have to compute its data + // once. typedef pmap Lights; Lights _plights, _dlights, _slights; diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I index d700413a14..c5e00fb510 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: tinyOffscreenGraphicsPipe.I -// Created by: drose (09Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOffscreenGraphicsPipe.I + * @author drose + * @date 2009-02-09 + */ diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx index 591ccb7e0e..c1fbe12b67 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: tinyOffscreenGraphicsPipe.cxx -// Created by: drose (09Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOffscreenGraphicsPipe.cxx + * @author drose + * @date 2009-02-09 + */ #include "pandabase.h" @@ -22,58 +21,45 @@ TypeHandle TinyOffscreenGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyOffscreenGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyOffscreenGraphicsPipe:: TinyOffscreenGraphicsPipe() { _supported_types = OT_buffer | OT_texture_buffer; _is_valid = true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOffscreenGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyOffscreenGraphicsPipe:: ~TinyOffscreenGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyOffscreenGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string TinyOffscreenGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOffscreenGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// TinyOffscreenGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default TinyOffscreenGraphicsPipe. + */ PT(GraphicsPipe) TinyOffscreenGraphicsPipe:: pipe_constructor() { return new TinyOffscreenGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOffscreenGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) TinyOffscreenGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -93,7 +79,7 @@ make_output(const string &name, } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h index 0c08c250f0..21395b1e62 100644 --- a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: tinyOffscreenGraphicsPipe.h -// Created by: drose (09Feb09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOffscreenGraphicsPipe.h + * @author drose + * @date 2009-02-09 + */ #ifndef TINYOFFSCREENGRAPHICSPIPE_H #define TINYOFFSCREENGRAPHICSPIPE_H @@ -23,11 +22,10 @@ class FrameBufferProperties; -//////////////////////////////////////////////////////////////////// -// Class : TinyOffscreenGraphicsPipe -// Description : This graphics pipe creates offscreen buffers only, -// but is completely platform-independent. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe creates offscreen buffers only, but is completely + * platform-independent. + */ class EXPCL_TINYDISPLAY TinyOffscreenGraphicsPipe : public GraphicsPipe { public: TinyOffscreenGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.I b/panda/src/tinydisplay/tinyOsxGraphicsPipe.I index b0f76f615c..ac88123073 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.I +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: tinyOsxGraphicsPipe.I -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsPipe.I + * @author drose + * @date 2008-05-12 + */ diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx index 1c8d672479..cdb1b90f1f 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: tinyOsxGraphicsPipe.cxx -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsPipe.cxx + * @author drose + * @date 2008-05-12 + */ #include "pandabase.h" @@ -25,12 +24,10 @@ #include "nativeWindowHandle.h" TypeHandle TinyOsxGraphicsPipe::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ TinyOsxGraphicsPipe:: TinyOsxGraphicsPipe() { CGRect display_bounds = CGDisplayBounds(kCGDirectMainDisplay); @@ -38,49 +35,37 @@ TinyOsxGraphicsPipe() { _display_height = CGRectGetHeight(display_bounds); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyOsxGraphicsPipe:: ~TinyOsxGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string TinyOsxGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// TinyOsxGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default TinyOsxGraphicsPipe. + */ PT(GraphicsPipe) TinyOsxGraphicsPipe:: pipe_constructor() { return new TinyOsxGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::create_cg_image -// Access: Public, Static -// Description: Creates a new Quartz bitmap image with the data in -// the indicated PNMImage. The caller should eventually -// free this image via CGImageRelease. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Quartz bitmap image with the data in the indicated PNMImage. + * The caller should eventually free this image via CGImageRelease. + */ CGImageRef TinyOsxGraphicsPipe:: create_cg_image(const PNMImage &pnm_image) { size_t width = pnm_image.get_x_size(); @@ -145,8 +130,7 @@ create_cg_image(const PNMImage &pnm_image) { bitmap_info |= kCGImageAlphaLast; } - // Now convert the pixel data to a format friendly to - // CGImageCreate(). + // Now convert the pixel data to a format friendly to CGImageCreate(). char *char_array = (char *)PANDA_MALLOC_ARRAY(num_bytes); xelval *dp = (xelval *)char_array; @@ -166,7 +150,7 @@ create_cg_image(const PNMImage &pnm_image) { } nassertr((void *)dp == (void *)(char_array + num_bytes), NULL); - CGDataProviderRef provider = + CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, char_array, num_bytes, release_data); nassertr(provider != NULL, NULL); @@ -182,24 +166,20 @@ create_cg_image(const PNMImage &pnm_image) { return image; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::release_data -// Access: Private, Static -// Description: This callback is assigned to delete the data array -// allocated within create_cg_image(). -//////////////////////////////////////////////////////////////////// +/** + * This callback is assigned to delete the data array allocated within + * create_cg_image(). + */ void TinyOsxGraphicsPipe:: release_data(void *info, const void *data, size_t size) { char *char_array = (char *)data; PANDA_FREE_ARRAY(char_array); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window or buffer on the pipe, if possible. -// This routine is only called from GraphicsEngine::make_output. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window or buffer on the pipe, if possible. This routine is + * only called from GraphicsEngine::make_output. + */ PT(GraphicsOutput) TinyOsxGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -210,7 +190,7 @@ make_output(const string &name, GraphicsOutput *host, int retry, bool &precertify) { - + if (!_is_valid) { return NULL; } @@ -245,7 +225,7 @@ make_output(const string &name, << "Got parent_window " << *window_handle << "\n"; #ifdef SUPPORT_SUBPROCESS_WINDOW WindowHandle::OSHandle *os_handle = window_handle->get_os_handle(); - if (os_handle != NULL && + if (os_handle != NULL && os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) { return new SubprocessWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); @@ -255,7 +235,7 @@ make_output(const string &name, return new TinyOsxGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Second thing to try: a TinyGraphicsBuffer if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| @@ -264,7 +244,7 @@ make_output(const string &name, } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } diff --git a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h index 04900c366c..f0781dfb5b 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: tinyOsxGraphicsPipe.h -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsPipe.h + * @author drose + * @date 2008-05-12 + */ #ifndef TINYOSXGRAPHICSPIPE_H #define TINYOSXGRAPHICSPIPE_H @@ -19,19 +18,18 @@ #if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__ -// We have to include this early, before anyone includes -// netinet/tcp.h, which will define TCP_NODELAY and other symbols and -// confuse the Apple system headers. +// We have to include this early, before anyone includes netinettcp.h, which +// will define TCP_NODELAY and other symbols and confuse the Apple system +// headers. #include #include "graphicsPipe.h" #include "tinyGraphicsStateGuardian.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyOsxGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating TinyPanda graphics windows on a Mac client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating TinyPanda graphics + * windows on a Mac client. + */ class EXPCL_TINYDISPLAY TinyOsxGraphicsPipe : public GraphicsPipe { public: TinyOsxGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.I b/panda/src/tinydisplay/tinyOsxGraphicsWindow.I index b69a8bf785..4f9c2c76f2 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.I +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.I @@ -1,18 +1,15 @@ -// Filename: tinyOsxGraphicsWindow.I -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsWindow.I + * @author drose + * @date 2008-05-12 + */ inline void TinyOsxGraphicsWindow::SendKeyEvent( ButtonHandle key, bool down) { diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h index 459ed0eee7..1d61868c9c 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: tinyOsxGraphicsWindow.h -// Created by: drose (12May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsWindow.h + * @author drose + * @date 2008-05-12 + */ #ifndef TINYOSXGRAPHICSWINDOW_H #define TINYOSXGRAPHICSWINDOW_H @@ -25,14 +24,12 @@ #include "buttonHandle.h" #include "tinyGraphicsStateGuardian.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyOsxGraphicsWindow -// Description : Opens a window on OS X to display the TinyPanda -// software rendering. -//////////////////////////////////////////////////////////////////// +/** + * Opens a window on OS X to display the TinyPanda software rendering. + */ class TinyOsxGraphicsWindow : public GraphicsWindow { public: - TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -48,10 +45,10 @@ public: virtual void begin_flip(); virtual void process_events(); virtual bool supports_pixel_zoom() const; - + virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size); - + virtual void mouse_mode_absolute(); virtual void mouse_mode_relative(); @@ -69,9 +66,8 @@ private: bool OSOpenWindow(WindowProperties &properties); - // - // a singleton .. for the events to find the right pipe to push the event into - // + // a singleton .. for the events to find the right pipe to push the event + // into public: // do not call direct .. @@ -111,10 +107,10 @@ private: CGImageRef _pending_icon; CGImageRef _current_icon; - + int _ID; - static TinyOsxGraphicsWindow *FullScreenWindow; - + static TinyOsxGraphicsWindow *FullScreenWindow; + CFDictionaryRef _originalMode; // True if _properties.get_cursor_hidden() is true. @@ -148,4 +144,3 @@ private: #endif // IS_OSX #endif - diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index a28a6e76d8..da3630a572 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -1,15 +1,13 @@ -// Filename: tinyOsxGraphicsWindow.mm -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyOsxGraphicsWindow.mm + */ #include "pandabase.h" @@ -33,7 +31,7 @@ #include #include "pmutex.h" -//#include "mutexHolder.h" +// #include "mutexHolder.h" Mutex &OSXGloablMutex() { @@ -96,20 +94,19 @@ bool checkmywindow(WindowRef window) { -//////////////////////////////////////////////////////////////////// -// Function: GetCurrentOSxWindow -// Access: Static, -// Description: How to find the active window for events on osx.. -// -//////////////////////////////////////////////////////////////////// +/** + * How to find the active window for events on osx.. + * + */ TinyOsxGraphicsWindow* TinyOsxGraphicsWindow::GetCurrentOSxWindow(WindowRef window) { if (FullScreenWindow != NULL) return FullScreenWindow; if (NULL == window) // HID use this path { - // Assume first we are a child window. If we cant find a window of that class, then we - // are standalone and can jsut grab the front window. + // Assume first we are a child window. If we cant find a window of + // that class, then we are standalone and can jsut grab the front + // window. window = GetFrontWindowOfClass(kSimpleWindowClass, TRUE); if (NULL == window) window = FrontNonFloatingWindow(); @@ -122,12 +119,9 @@ TinyOsxGraphicsWindow* TinyOsxGraphicsWindow::GetCurrentOSxWindow(WindowRef wind } } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::event_handler -// Access: Public -// Description: The standard window event handler for non-fullscreen -// windows. -//////////////////////////////////////////////////////////////////// +/** + * The standard window event handler for non-fullscreen windows. + */ OSStatus TinyOsxGraphicsWindow:: event_handler(EventHandlerCallRef myHandler, EventRef event) { @@ -171,8 +165,8 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) { SystemSetWindowForground(false); break; case kEventWindowClose: // called when window is being closed (close box) - // This is a message from the window manager indicating that - // the user has requested to close the window. + // This is a message from the window manager indicating that the + // user has requested to close the window. user_close_request(); result = noErr; break; @@ -223,49 +217,44 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::user_close_request -// Access: Private -// Description: The user has requested to close the window, for -// instance with Cmd-W, or by clicking on the close -// button. -//////////////////////////////////////////////////////////////////// +/** + * The user has requested to close the window, for instance with Cmd-W, or by + * clicking on the close button. + */ void TinyOsxGraphicsWindow::user_close_request() { string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept the request and process it directly. + // In this case, the app has indicated a desire to intercept the request + // and process it directly. throw_event(close_request_event); } else { - // In this case, the default case, the app does not intend to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to service the + // request, so we do by closing the window. close_window(); } } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::SystemCloseWindow -// Access: Private -// Description: The Windows is closed by a OS resource not by a internal request -// -//////////////////////////////////////////////////////////////////// +/** + * The Windows is closed by a OS resource not by a internal request + * + */ void TinyOsxGraphicsWindow::SystemCloseWindow() { if (tinydisplay_cat.is_debug()) tinydisplay_cat.debug() << "System Closing Window \n"; ReleaseSystemResources(); }; -//////////////////////////////////////////////////////////////////// -// Function: windowEvtHndlr -// Access: file scope Static -// Description: The C callback for Window Events .. -// -// We only hook this up for non fullscreen window... so we only -// handle system window events.. -// -//////////////////////////////////////////////////////////////////// +/** + * The C callback for Window Events .. + * + * We only hook this up for non fullscreen window... so we only handle system + * window events.. + * + */ static pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void *userData) { #pragma unused (userData) -// volatile().lock(); +// volatile().lock(); WindowRef window = NULL; GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); @@ -273,23 +262,22 @@ static pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef if (window != NULL) { TinyOsxGraphicsWindow *osx_win = TinyOsxGraphicsWindow::GetCurrentOSxWindow(window); if (osx_win != (TinyOsxGraphicsWindow *)NULL) { - //OSXGloablMutex().release(); + // OSXGloablMutex().release(); return osx_win->event_handler(myHandler, event); } } - //OSXGloablMutex().release(); + // OSXGloablMutex().release(); return eventNotHandledErr; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::DoResize -// Access: -// Description: The C callback for Window Events .. -// -// We only hook this up for none fullscreen window... so we only handle system window events.. -// -//////////////////////////////////////////////////////////////////// +/** + * The C callback for Window Events .. + * + * We only hook this up for none fullscreen window... so we only handle system + * window events.. + * + */ void TinyOsxGraphicsWindow::DoResize(void) { tinydisplay_cat.info() << "In Resize....." << _properties << "\n"; @@ -314,20 +302,18 @@ void TinyOsxGraphicsWindow::DoResize(void) { } }; -//////////////////////////////////////////////////////////////////// -// Function: appEvtHndlr -// Access: -// Description: The C callback for APlication Events.. -// -// Hooked once for application -// -//////////////////////////////////////////////////////////////////// +/** + * The C callback for APlication Events.. + * + * Hooked once for application + * + */ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef event, void* userData) { #pragma unused (myHandler) OSStatus result = eventNotHandledErr; { - //OSXGloablMutex().lock(); + // OSXGloablMutex().lock(); TinyOsxGraphicsWindow *osx_win = NULL; WindowRef window = NULL; @@ -337,66 +323,63 @@ static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef even GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, (void*) &window); osx_win = TinyOsxGraphicsWindow::GetCurrentOSxWindow(window); if (osx_win == NULL) { - //OSXGloablMutex().release(); + // OSXGloablMutex().release(); return eventNotHandledErr; } switch (the_class) { case kEventClassTextInput: if (kind == kEventTextInputUnicodeForKeyEvent) { - osx_win->handleTextInput(myHandler, event); + osx_win->handleTextInput(myHandler, event); } - //result = noErr; - // - // can not report handled .. the os will not sent the raw key strokes then - // if (osx_win->handleTextInput(myHandler, event) == noErr) - // result = noErr; + // result = noErr; can not report handled .. the os will not sent the + // raw key strokes then if (osx_win->handleTextInput(myHandler, event) + // == noErr) result = noErr; break; case kEventClassKeyboard: { switch (kind) { - case kEventRawKeyRepeat: - case kEventRawKeyDown: - result = osx_win->handleKeyInput (myHandler, event, true); - break; - case kEventRawKeyUp: - result = osx_win->handleKeyInput (myHandler, event, false); - break; + case kEventRawKeyRepeat: + case kEventRawKeyDown: + result = osx_win->handleKeyInput (myHandler, event, true); + break; + case kEventRawKeyUp: + result = osx_win->handleKeyInput (myHandler, event, false); + break; case kEventRawKeyModifiersChanged: - { - UInt32 newModifiers; - OSStatus error = GetEventParameter(event, kEventParamKeyModifiers,typeUInt32, NULL,sizeof(UInt32), NULL, &newModifiers); - if (error == noErr) { - osx_win->HandleModifireDeleta(newModifiers); - result = noErr; - } - } - break; + { + UInt32 newModifiers; + OSStatus error = GetEventParameter(event, kEventParamKeyModifiers,typeUInt32, NULL,sizeof(UInt32), NULL, &newModifiers); + if (error == noErr) { + osx_win->HandleModifireDeleta(newModifiers); + result = noErr; + } + } + break; } } break; case kEventClassMouse: - // tinydisplay_cat.info() << "Mouse movement handled by Application handler\n"; - //if (TinyOsxGraphicsWindow::FullScreenWindow != NULL) - result = osx_win->handleWindowMouseEvents (myHandler, event); - //result = noErr; + // tinydisplay_cat.info() << "Mouse movement handled by Application + // handler\n"; if (TinyOsxGraphicsWindow::FullScreenWindow != NULL) + result = osx_win->handleWindowMouseEvents (myHandler, event); + // result = noErr; break; } - //OSXGloablMutex().release(); + // OSXGloablMutex().release(); } return result; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::handleTextInput -// Access: -// Description: Trap Unicode Input. -// -// -//////////////////////////////////////////////////////////////////// +/** + * Trap Unicode Input. + * + + * + */ OSStatus TinyOsxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, EventRef theTextEvent) { UniChar *text = NULL; UInt32 actualSize = 0; @@ -421,11 +404,9 @@ OSStatus TinyOsxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, return ret; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::ReleaseSystemResources -// Access: Private -// Description: Clean up the OS level messes.. -//////////////////////////////////////////////////////////////////// +/** + * Clean up the OS level messes.. + */ void TinyOsxGraphicsWindow::ReleaseSystemResources() { if (_is_fullscreen) { _is_fullscreen = false; @@ -468,11 +449,9 @@ void TinyOsxGraphicsWindow::ReleaseSystemResources() { static int id_seed = 100; -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyOsxGraphicsWindow::TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, @@ -505,17 +484,15 @@ TinyOsxGraphicsWindow::TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPip tinydisplay_cat.debug() << "TinyOsxGraphicsWindow::TinyOsxGraphicsWindow() -" <<_ID << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyOsxGraphicsWindow::~TinyOsxGraphicsWindow() { if (tinydisplay_cat.is_debug()) tinydisplay_cat.debug() << "TinyOsxGraphicsWindow::~TinyOsxGraphicsWindow() -" <<_ID << "\n"; - // Make sure the window callback won't come back to this - // (destructed) object any more. + // Make sure the window callback won't come back to this (destructed) object + // any more. if (_osx_window) { SetWRefCon (_osx_window, (long) NULL); } @@ -523,13 +500,10 @@ TinyOsxGraphicsWindow::~TinyOsxGraphicsWindow() { ReleaseSystemResources(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::set_icon_filename -// Access: Private -// Description: Called internally to load up an icon file that should -// be applied to the window. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Called internally to load up an icon file that should be applied to the + * window. Returns true on success, false on failure. + */ bool TinyOsxGraphicsWindow::set_icon_filename(const Filename &icon_filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -566,12 +540,9 @@ bool TinyOsxGraphicsWindow::set_icon_filename(const Filename &icon_filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::set_pointer_in_window -// Access: Private -// Description: Indicates the mouse pointer is seen within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is seen within the window. + */ void TinyOsxGraphicsWindow:: set_pointer_in_window(int x, int y) { _input_devices[0].set_pointer_in_window(x, y); @@ -587,12 +558,9 @@ set_pointer_in_window(int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::set_pointer_out_of_window -// Access: Private -// Description: Indicates the mouse pointer is no longer within the -// window. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the mouse pointer is no longer within the window. + */ void TinyOsxGraphicsWindow:: set_pointer_out_of_window() { _input_devices[0].set_pointer_out_of_window(); @@ -604,15 +572,12 @@ set_pointer_out_of_window() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool TinyOsxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector); @@ -623,9 +588,9 @@ bool TinyOsxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread) return false; } - // Now is a good time to apply the icon change that may have - // recently been requested. By this point, we should be able to get - // a handle to the dock context. + // Now is a good time to apply the icon change that may have recently been + // requested. By this point, we should be able to get a handle to the dock + // context. if (_pending_icon != NULL) { CGContextRef context = BeginCGContextForApplicationDockTile(); if (context != NULL) { @@ -651,13 +616,11 @@ bool TinyOsxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread) return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void TinyOsxGraphicsWindow::end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -672,20 +635,17 @@ void TinyOsxGraphicsWindow::end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void TinyOsxGraphicsWindow::begin_flip() { if (_osx_window == NULL) { return; @@ -730,12 +690,9 @@ void TinyOsxGraphicsWindow::begin_flip() { DisposeGWorld(pGWorld); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void TinyOsxGraphicsWindow::close_window() { SystemCloseWindow(); @@ -748,30 +705,23 @@ void TinyOsxGraphicsWindow::close_window() { GraphicsWindow::close_window(); } -// HACK ALLERT ************ Undocumented OSX calls... -// I can not find any other way to get the mouse focus to a window in OSX.. -//extern "C" { -// struct CPSProcessSerNum -// { -// UInt32 lo; -// UInt32 hi; -// }; +/* + * HACK ALLERT ************ Undocumented OSX calls... I can not find any other + * way to get the mouse focus to a window in OSX.. extern "C" { struct + * CPSProcessSerNum { UInt32 lo; UInt32 hi; }; + */ -//extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); -//extern OSErr CPSEnableForegroundOperation( struct CPSProcessSerNum *psn); -//extern OSErr CPSSetProcessName ( struct CPSProcessSerNum *psn, char *processname); -//extern OSErr CPSSetFrontProcess( struct CPSProcessSerNum *psn); -//}; +// extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); extern OSErr +// CPSEnableForegroundOperation( struct CPSProcessSerNum *psn); extern OSErr +// CPSSetProcessName ( struct CPSProcessSerNum *psn, char *processname); +// extern OSErr CPSSetFrontProcess( struct CPSProcessSerNum *psn); }; -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool TinyOsxGraphicsWindow::open_window() { - // GSG Creation/Initialization + // GSG CreationInitialization TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -797,9 +747,9 @@ bool TinyOsxGraphicsWindow::open_window() { } WindowProperties req_properties = _properties; - //OSXGloablMutex().lock(); + // OSXGloablMutex().lock(); bool answer = OSOpenWindow(req_properties); - //OSXGloablMutex().release(); + // OSXGloablMutex().release(); return answer; } @@ -808,22 +758,22 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { OSErr err = noErr; if (_current_icon != NULL && _pending_icon == NULL) { - // If we already have an icon specified, we'll need to reapply it - // when the window is successfully created. + // If we already have an icon specified, we'll need to reapply it when + // the window is successfully created. _pending_icon = _current_icon; _current_icon = NULL; } static bool GlobalInits = false; if (!GlobalInits) { - // - // one time aplication inits.. to get a window open from a standalone aplication.. + // one time aplication inits.. to get a window open from a standalone + // aplication.. EventHandlerRef application_event_ref_ref1; EventTypeSpec list1[] = { - //{ kEventClassCommand, kEventProcessCommand }, - //{ kEventClassCommand, kEventCommandUpdateStatus }, + // { kEventClassCommand, kEventProcessCommand }, { + // kEventClassCommand, kEventCommandUpdateStatus }, { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user { kEventClassMouse, kEventMouseUp }, { kEventClassMouse, kEventMouseMoved }, @@ -845,22 +795,19 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { // Determine if we're running from a bundle. CFDictionaryRef dref = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask); - // If the dictionary doesn't have "BundlePath" (or the BundlePath - // is the same as the executable path), then we're not running - // from a bundle, and we need to call TransformProcessType to make - // the process a "foreground" application, with its own icon in - // the dock and such. + // If the dictionary doesn't have "BundlePath" (or the BundlePath is the + // same as the executable path), then we're not running from a bundle, and + // we need to call TransformProcessType to make the process a "foreground" + // application, with its own icon in the dock and such. bool has_bundle = false; CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath")); if (bundle_path != NULL) { - // OK, we have a bundle path. We're probably running in a - // bundle . . . + // OK, we have a bundle path. We're probably running in a bundle . . . has_bundle = true; - // . . . unless it turns out it's the same as the executable - // path. + // . . . unless it turns out it's the same as the executable path. CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey); if (exe_path != NULL) { if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { @@ -978,28 +925,27 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { } if (req_properties.has_undecorated() && req_properties.get_undecorated()) { // create a unmovable .. no edge window.. - tinydisplay_cat.info() << "Creating undecorated window\n"; + tinydisplay_cat.info() << "Creating undecorated window\n"; // We don't want a resize box either. attributes &= ~kWindowResizableAttribute; attributes |= kWindowNoTitleBarAttribute; - CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window); + CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window); } else { // create a window with crome and sizing and sucj - // In this case, we want to constrain the window to the - // available size. - Rect bounds; - GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds); + // In this case, we want to constrain the window to the available size. + Rect bounds; + GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds); - r.left = max(r.left, bounds.left); - r.right = min(r.right, bounds.right); - r.top = max(r.top, bounds.top); - r.bottom = min(r.bottom, bounds.bottom); + r.left = max(r.left, bounds.left); + r.right = min(r.right, bounds.right); + r.top = max(r.top, bounds.top); + r.bottom = min(r.bottom, bounds.bottom); - tinydisplay_cat.info() << "Creating standard window\n"; - CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window); - AddAWindow(_osx_window); + tinydisplay_cat.info() << "Creating standard window\n"; + CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window); + AddAWindow(_osx_window); } } @@ -1036,21 +982,23 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { { NSWindow* parentWindow = (NSWindow *)req_properties.get_parent_window(); - // NSView* aView = [[parentWindow contentView] viewWithTag:378]; - // NSRect aRect = [aView frame]; - // NSPoint origin = [parentWindow convertBaseToScreen:aRect.origin]; + // NSView* aView = [[parentWindow contentView] + // viewWithTag:378]; NSRect aRect = [aView + // frame]; NSPoint origin = [parentWindow + // convertBaseToScreen:aRect.origin]; - // NSWindow* childWindow = [[NSWindow alloc] initWithWindowRef:_osx_window]; + // NSWindow* childWindow = [[NSWindow alloc] + // initWithWindowRef:_osx_window]; Post_Event_Wait(PANDA_CREATE_WINDOW,(unsigned long) _osx_window,1,[parentWindow windowNumber]); - // [childWindow setFrameOrigin:origin]; - // [childWindow setAcceptsMouseMovedEvents:YES]; - // [childWindow setBackgroundColor:[NSColor blackColor]]; - // this seems to block till the parent accepts the connection ? -// [parentWindow addChildWindow:childWindow ordered:NSWindowAbove]; -// [childWindow orderFront:nil]; + // [childWindow setFrameOrigin:origin]; [childWindow + // setAcceptsMouseMovedEvents:YES]; [childWindow + // setBackgroundColor:[NSColor blackColor]]; this seems to block till + // the parent accepts the connection ? [parentWindow + // addChildWindow:childWindow ordered:NSWindowAbove]; [childWindow + // orderFront:nil]; _properties.set_parent_window(req_properties.get_parent_window()); @@ -1079,8 +1027,8 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { } } - // Now measure the size and placement of the window we - // actually ended up with. + // Now measure the size and placement of the window we actually ended up + // with. Rect rectPort = {0,0,0,0}; GetWindowPortBounds (_osx_window, &rectPort); _properties.set_origin((int) rectPort.left, (int) rectPort.top); @@ -1102,13 +1050,11 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) { return (err == noErr); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::process_events() -// Access: Virtual, Protected -// Description: Required Event upcall . Used to dispatch Window and Aplication Events -// back into panda -// -//////////////////////////////////////////////////////////////////// +/** + * Required Event upcall . Used to dispatch Window and Aplication Events back + * into panda + * + */ void TinyOsxGraphicsWindow::process_events() { GraphicsWindow::process_events(); @@ -1119,38 +1065,32 @@ void TinyOsxGraphicsWindow::process_events() { /*if (!_properties.has_parent_window())*/ { while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent)== noErr) { - SendEventToEventTarget (theEvent, theTarget); - ReleaseEvent(theEvent); + SendEventToEventTarget (theEvent, theTarget); + ReleaseEvent(theEvent); } } } }; -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::supports_pixel_zoom -// Access: Published, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool TinyOsxGraphicsWindow:: supports_pixel_zoom() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::handleKeyInput() -// Access: Virtual, Protected -// Description: Required Event upcall . Used to dispatch Window and Aplication Events -// back into panda -//////////////////////////////////////////////////////////////////// +/** + * Required Event upcall . Used to dispatch Window and Aplication Events back + * into panda + */ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, EventRef event, Boolean keyDown) { // key input handler @@ -1164,14 +1104,13 @@ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, E << ", " << (int)keyDown << "\n"; } - //CallNextEventHandler(myHandler, event); + // CallNextEventHandler(myHandler, event); - // We don't check the result of the above function. In principle, - // this should return eventNotHandledErr if the key event is not - // handled by the OS, but in practice, testing this just seems to - // eat the Escape keypress meaninglessly. Keypresses like F11 that - // are already mapped in the desktop seem to not even come into this - // function in the first place. + // We don't check the result of the above function. In principle, this + // should return eventNotHandledErr if the key event is not handled by the + // OS, but in practice, testing this just seems to eat the Escape keypress + // meaninglessly. Keypresses like F11 that are already mapped in the + // desktop seem to not even come into this function in the first place. UInt32 newModifiers = 0; OSStatus error = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &newModifiers); if (error == noErr) { @@ -1185,9 +1124,9 @@ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, E if (keyDown) { if ((newModifiers & cmdKey) != 0) { if (button == KeyboardButton::ascii_key('q') || button == KeyboardButton::ascii_key('w')) { - // Command-Q or Command-W: quit the application or close the - // window, respectively. For now, we treat them both the - // same: close the window. + // Command-Q or Command-W: quit the application or close the window, + // respectively. For now, we treat them both the same: close the + // window. user_close_request(); } } @@ -1196,25 +1135,21 @@ OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, E SendKeyEvent(button, false); } return CallNextEventHandler(myHandler, event); -// return noErr; +// return noErr; } - //////////////////////////////////////////////////////////////////// - // Function: - // Access: - // Description: - //////////////////////////////////////////////////////////////////// +/** + * + */ void TinyOsxGraphicsWindow::SystemSetWindowForground(bool forground) { WindowProperties properties; properties.set_foreground(forground); system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: -// Access: -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { if (_osx_window != NULL) { GrafPtr savePort; @@ -1227,11 +1162,9 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { } } - //////////////////////////////////////////////////////////////////// - // Function: - // Access: - // Description: - //////////////////////////////////////////////////////////////////// +/** + * + */ OSStatus TinyOsxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandler, EventRef event) { WindowRef window = NULL; OSStatus result = eventNotHandledErr; @@ -1242,10 +1175,9 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { SInt32 this_wheel_delta; EventMouseWheelAxis wheelAxis; - //cerr <<" Start Mouse Event " << _ID << "\n"; + // cerr <<" Start Mouse Event " << _ID << "\n"; - // Mac OS X v10.1 and later - // should this be front window??? + // Mac OS X v10.1 and later should this be front window??? GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window); if (!_is_fullscreen && (window == NULL || window != _osx_window )) { @@ -1259,33 +1191,33 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { GetWindowPortBounds (window, &rectPort); - // result = CallNextEventHandler(myHandler, event); - // if (eventNotHandledErr == result) { // only handle events not already handled (prevents wierd resize interaction) + // result = CallNextEventHandler(myHandler, event); if (eventNotHandledErr + // == result) { only handle events not already handled (prevents wierd + // resize interaction) switch (kind) { - // Whenever mouse button state changes, generate the - // appropriate Panda down/up events to represent the - // change. + // Whenever mouse button state changes, generate the appropriate Panda + // downup events to represent the change. case kEventMouseDown: case kEventMouseUp: { - GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); - if (_properties.get_mouse_mode() == WindowProperties::M_relative) { - GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); - MouseData currMouse = get_pointer(0); - qdGlobalPoint.h += currMouse.get_x(); - qdGlobalPoint.v += currMouse.get_y(); - } - else - { - GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); - SystemPointToLocalPoint(qdGlobalPoint); - } + GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers); + if (_properties.get_mouse_mode() == WindowProperties::M_relative) { + GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); + MouseData currMouse = get_pointer(0); + qdGlobalPoint.h += currMouse.get_x(); + qdGlobalPoint.v += currMouse.get_y(); + } + else + { + GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); + SystemPointToLocalPoint(qdGlobalPoint); + } - set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); + set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); - UInt32 new_buttons = GetCurrentEventButtonState(); - HandleButtonDelta(new_buttons); + UInt32 new_buttons = GetCurrentEventButtonState(); + HandleButtonDelta(new_buttons); } result = noErr; break; @@ -1293,22 +1225,22 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { case kEventMouseMoved: case kEventMouseDragged: if (_properties.get_mouse_mode()==WindowProperties::M_relative) { - GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); + GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); - MouseData currMouse=get_pointer(0); - qdGlobalPoint.h+=currMouse.get_x(); - qdGlobalPoint.v+=currMouse.get_y(); + MouseData currMouse=get_pointer(0); + qdGlobalPoint.h+=currMouse.get_x(); + qdGlobalPoint.v+=currMouse.get_y(); } else { - GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); - SystemPointToLocalPoint(qdGlobalPoint); + GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint); + SystemPointToLocalPoint(qdGlobalPoint); } if (kind == kEventMouseMoved && - (qdGlobalPoint.h < 0 || qdGlobalPoint.v < 0)) { - // Moving into the titlebar region. - set_pointer_out_of_window(); + (qdGlobalPoint.h < 0 || qdGlobalPoint.v < 0)) { + // Moving into the titlebar region. + set_pointer_out_of_window(); } else { - // Moving within the window itself (or dragging anywhere). - set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); + // Moving within the window itself (or dragging anywhere). + set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); } result = noErr; @@ -1321,33 +1253,31 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { SystemPointToLocalPoint(qdGlobalPoint); if (wheelAxis == kEventMouseWheelAxisY) { - set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); - _wheel_delta += this_wheel_delta; - SInt32 wheel_scale = osx_mouse_wheel_scale; - while (_wheel_delta > wheel_scale) { - _input_devices[0].button_down(MouseButton::wheel_up()); - _input_devices[0].button_up(MouseButton::wheel_up()); - _wheel_delta -= wheel_scale; - } - while (_wheel_delta < -wheel_scale) { - _input_devices[0].button_down(MouseButton::wheel_down()); - _input_devices[0].button_up(MouseButton::wheel_down()); - _wheel_delta += wheel_scale; - } + set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v); + _wheel_delta += this_wheel_delta; + SInt32 wheel_scale = osx_mouse_wheel_scale; + while (_wheel_delta > wheel_scale) { + _input_devices[0].button_down(MouseButton::wheel_up()); + _input_devices[0].button_up(MouseButton::wheel_up()); + _wheel_delta -= wheel_scale; + } + while (_wheel_delta < -wheel_scale) { + _input_devices[0].button_down(MouseButton::wheel_down()); + _input_devices[0].button_up(MouseButton::wheel_down()); + _wheel_delta += wheel_scale; + } } result = noErr; break; } - //result = noErr; + // result = noErr; return result; } - //////////////////////////////////////////////////////////////////// - // Function: TinyOsxGraphicsWindow::OSX_TranslateKey - // Access: Private - // Description: MAC Key Codes to Panda Key Codes - //////////////////////////////////////////////////////////////////// +/** + * MAC Key Codes to Panda Key Codes + */ ButtonHandle TinyOsxGraphicsWindow::OSX_TranslateKey(UInt32 key, EventRef event) { ButtonHandle nk = ButtonHandle::none(); @@ -1404,7 +1334,8 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { case 92: nk = KeyboardButton::ascii_key('9'); break; - // case 36: nk = KeyboardButton::ret(); break; // no return in panda ??? + // case 36: nk = KeyboardButton::ret(); break; no + // return in panda ??? case 49: nk = KeyboardButton::space(); break; case 51: nk = KeyboardButton::backspace(); break; case 48: nk = KeyboardButton::tab(); break; @@ -1423,7 +1354,7 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { case 114: nk = KeyboardButton::help(); break; case 117: nk = KeyboardButton::del(); break; - // case 71: nk = KeyboardButton::num_lock() break; + // case 71: nk = KeyboardButton::num_lock() break; case 122: nk = KeyboardButton::f1(); break; case 120: nk = KeyboardButton::f2(); break; @@ -1459,12 +1390,12 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { default: if (tinydisplay_cat.is_debug()) { tinydisplay_cat.debug() - << " Untranslated KeyCode: " << key - << " (0x" << hex << key << dec << ")\n"; + << " Untranslated KeyCode: " << key + << " (0x" << hex << key << dec << ")\n"; } - // not sure this is right .. but no mapping for keypad and such - // this at least does a best gess.. + // not sure this is right .. but no mapping for keypad and such this at + // least does a best gess.. char charCode = 0; if (GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, nil, sizeof( charCode ), nil, &charCode ) == noErr) @@ -1472,11 +1403,9 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { } return nk; } - //////////////////////////////////////////////////////////////////// - // Function: TinyOsxGraphicsWindow::HandleModifireDeleta - // Access: Private - // Description: Used to emulate key events for the MAC key Modifiers.. - //////////////////////////////////////////////////////////////////// +/** + * Used to emulate key events for the MAC key Modifiers.. + */ void TinyOsxGraphicsWindow::HandleModifireDeleta(UInt32 newModifiers) { UInt32 changed = _last_key_modifiers ^ newModifiers; @@ -1500,11 +1429,9 @@ void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) { _last_key_modifiers = newModifiers; }; -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::HandleButtonDelta -// Access: Private -// Description: Used to emulate buttons events/ -//////////////////////////////////////////////////////////////////// +/** + * Used to emulate buttons events + */ void TinyOsxGraphicsWindow:: HandleButtonDelta(UInt32 new_buttons) { UInt32 changed = _last_buttons ^ new_buttons; @@ -1536,16 +1463,14 @@ HandleButtonDelta(UInt32 new_buttons) { _last_buttons = new_buttons; } - //////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool TinyOsxGraphicsWindow::move_pointer(int device, int x, int y) { if (_osx_window == NULL) { return false; @@ -1609,8 +1534,8 @@ bool TinyOsxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool } else*/ { - // We sometimes get a bogus origin of (0, 0). As a special hack, - // treat this as a special case, and ignore it. + // We sometimes get a bogus origin of (0, 0). As a special hack, treat + // this as a special case, and ignore it. if (has_origin) { if (x_origin != 0 || y_origin != 0) { MoveWindow(_osx_window, x_origin, y_origin, false); @@ -1634,25 +1559,20 @@ bool TinyOsxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) { if (tinydisplay_cat.is_debug()) { tinydisplay_cat.debug() @@ -1669,7 +1589,7 @@ void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) { } // for some changes .. a full rebuild is required for the OS layer Window. - // I think it is the crome atribute and full screen behaviour. + // I think it is the crome atribute and full screen behaviour. bool need_full_rebuild = false; // if we are not full and transitioning to full @@ -1694,9 +1614,9 @@ void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) { } if (need_full_rebuild) { - // Logic here is .. take a union of the properties .. with the - // new allowed to overwrite the old states. and start a bootstrap - // of a new window .. + // Logic here is .. take a union of the properties .. with the new + // allowed to overwrite the old states. and start a bootstrap of a new + // window .. // get a copy of my properties.. WindowProperties req_properties(_properties); @@ -1720,8 +1640,8 @@ void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) { } // An icon filename means to load up the icon and save it. We can't - // necessarily apply it immediately; it will get applied later, in - // the window event handler. + // necessarily apply it immediately; it will get applied later, in the + // window event handler. if (properties.has_icon_filename()) { if (set_icon_filename(properties.get_icon_filename())) { properties.clear_icon_filename(); @@ -1768,9 +1688,9 @@ void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) { return; } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::LocalPointToSystemPoint -//////////////////////////////////////////////////////////////////// +/** + + */ void TinyOsxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) { if (_osx_window != NULL) { GrafPtr savePort; @@ -1784,30 +1704,23 @@ void TinyOsxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::mouse_mode_relative -// Access: Protected, Virtual -// Description: Detaches mouse. Only mouse delta from now on. -//////////////////////////////////////////////////////////////////// +/** + * Detaches mouse. Only mouse delta from now on. + */ void TinyOsxGraphicsWindow::mouse_mode_relative() { CGAssociateMouseAndMouseCursorPosition(false); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::mouse_mode_absolute -// Access: Protected, Virtual -// Description: Reattaches mouse to location -//////////////////////////////////////////////////////////////////// +/** + * Reattaches mouse to location + */ void TinyOsxGraphicsWindow::mouse_mode_absolute() { CGAssociateMouseAndMouseCursorPosition(true); } -//////////////////////////////////////////////////////////////////// -// Function: TinyOsxGraphicsWindow::create_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size. + */ void TinyOsxGraphicsWindow:: create_frame_buffer() { if (_frame_buffer != NULL) { diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.I b/panda/src/tinydisplay/tinySDLGraphicsPipe.I index 8b0de6ba80..547ba45af2 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.I +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: tinySDLGraphicsPipe.I -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsPipe.I + * @author drose + * @date 2008-04-24 + */ diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx index 48605e137f..6189f61036 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: tinySDLGraphicsPipe.cxx -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsPipe.cxx + * @author drose + * @date 2008-04-24 + */ #include "pandabase.h" @@ -24,11 +23,9 @@ TypeHandle TinySDLGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinySDLGraphicsPipe:: TinySDLGraphicsPipe() { _is_valid = true; @@ -40,11 +37,9 @@ TinySDLGraphicsPipe() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinySDLGraphicsPipe:: ~TinySDLGraphicsPipe() { if (SDL_WasInit(SDL_INIT_VIDEO)) { @@ -54,38 +49,29 @@ TinySDLGraphicsPipe:: SDL_Quit(); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string TinySDLGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// TinySDLGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default TinySDLGraphicsPipe. + */ PT(GraphicsPipe) TinySDLGraphicsPipe:: pipe_constructor() { return new TinySDLGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) TinySDLGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -120,7 +106,7 @@ make_output(const string &name, return new TinySDLGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } diff --git a/panda/src/tinydisplay/tinySDLGraphicsPipe.h b/panda/src/tinydisplay/tinySDLGraphicsPipe.h index 24fa03bf04..6897e51b6b 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsPipe.h +++ b/panda/src/tinydisplay/tinySDLGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: tinySDLGraphicsPipe.h -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsPipe.h + * @author drose + * @date 2008-04-24 + */ #ifndef TINYSDLGRAPHICSPIPE_H #define TINYSDLGRAPHICSPIPE_H @@ -24,11 +23,10 @@ class FrameBufferProperties; -//////////////////////////////////////////////////////////////////// -// Class : TinySDLGraphicsPipe -// Description : This graphics pipe manages SDL windows for rendering -// TinyPanda software buffers. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe manages SDL windows for rendering TinyPanda software + * buffers. + */ class EXPCL_TINYDISPLAY TinySDLGraphicsPipe : public GraphicsPipe { public: TinySDLGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.I b/panda/src/tinydisplay/tinySDLGraphicsWindow.I index b1ea2c0425..95423dd96b 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.I +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.I @@ -1,14 +1,12 @@ -// Filename: tinySDLGraphicsWindow.I -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsWindow.I + * @author drose + * @date 2008-04-24 + */ diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx index 47631c6321..68ab836ec6 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: tinySDLGraphicsWindow.cxx -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsWindow.cxx + * @author drose + * @date 2008-04-24 + */ #include "pandabase.h" @@ -26,13 +25,11 @@ TypeHandle TinySDLGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinySDLGraphicsWindow:: -TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, +TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -51,24 +48,19 @@ TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, add_input_device(device); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinySDLGraphicsWindow:: ~TinySDLGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool TinySDLGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -81,18 +73,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { tinygsg->_current_frame_buffer = _frame_buffer; tinygsg->reset_if_new(); - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void TinySDLGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -110,16 +100,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void TinySDLGraphicsWindow:: end_flip() { if (!_flip_ready) { @@ -139,14 +126,14 @@ end_flip() { } } ZB_copyFrameBuffer(_frame_buffer, _screen->pixels, _pitch); - + if (SDL_MUSTLOCK(_screen)) { - SDL_UnlockSurface(_screen); + SDL_UnlockSurface(_screen); } } else { // Copy to another surface, then scale it onto the screen. - SDL_Surface *temp = + SDL_Surface *temp = SDL_CreateRGBSurfaceFrom(_frame_buffer->pbuf, _frame_buffer->xsize, _frame_buffer->ysize, 32, _frame_buffer->linesize, 0xff0000, 0x00ff00, 0x0000ff, 0xff000000); SDL_SetAlpha(temp, SDL_RLEACCEL, 0); @@ -158,16 +145,13 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void TinySDLGraphicsWindow:: process_events() { GraphicsWindow::process_events(); @@ -214,7 +198,7 @@ process_events() { case SDL_MOUSEMOTION: _input_devices[0].set_pointer_in_window(evt.motion.x, evt.motion.y); break; - + case SDL_VIDEORESIZE: properties.set_size(evt.resize.w, evt.resize.h); system_changed_properties(properties); @@ -222,7 +206,7 @@ process_events() { ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size()); _pitch = _screen->pitch * 32 / _screen->format->BitsPerPixel; break; - + case SDL_QUIT: // The window was closed by the user. close_window(); @@ -233,23 +217,18 @@ process_events() { } } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The return value is true if the properties are set, -// false if they are ignored. This is mainly useful for -// derived classes to implement extensions to this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The return value is true if the properties are set, false if they are + * ignored. This is mainly useful for derived classes to implement extensions + * to this function. + */ void TinySDLGraphicsWindow:: set_properties_now(WindowProperties &properties) { GraphicsWindow::set_properties_now(properties); @@ -259,47 +238,37 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::supports_pixel_zoom -// Access: Published, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool TinySDLGraphicsWindow:: supports_pixel_zoom() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void TinySDLGraphicsWindow:: close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool TinySDLGraphicsWindow:: open_window() { - // GSG Creation/Initialization + // GSG CreationInitialization TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -337,21 +306,18 @@ open_window() { tinygsg->_current_frame_buffer = _frame_buffer; - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Now that we have made the context current to a window, we can reset the + // GSG state if this is the first time it has been used. (We can't just + // call reset() when we construct the GSG, because reset() requires having a + // current context.) tinygsg->reset_if_new(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::create_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size. + */ void TinySDLGraphicsWindow:: create_frame_buffer() { if (_frame_buffer != NULL) { @@ -385,20 +351,17 @@ create_frame_buffer() { _pitch = _screen->pitch * 32 / _screen->format->BitsPerPixel; } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::get_keyboard_button -// Access: Private, Static -// Description: Maps from an SDL keysym to the corresponding Panda -// ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Maps from an SDL keysym to the corresponding Panda ButtonHandle. + */ ButtonHandle TinySDLGraphicsWindow:: get_keyboard_button(SDLKey sym) { switch (sym) { case SDLK_BACKSPACE: return KeyboardButton::backspace(); case SDLK_TAB: return KeyboardButton::tab(); - // case SDLK_CLEAR: return KeyboardButton::clear(); + // case SDLK_CLEAR: return KeyboardButton::clear(); case SDLK_RETURN: return KeyboardButton::enter(); - // case SDLK_PAUSE: return KeyboardButton::pause(); + // case SDLK_PAUSE: return KeyboardButton::pause(); case SDLK_ESCAPE: return KeyboardButton::escape(); case SDLK_SPACE: return KeyboardButton::space(); case SDLK_EXCLAIM: return KeyboardButton::ascii_key('!'); @@ -506,9 +469,9 @@ get_keyboard_button(SDLKey sym) { case SDLK_F13: return KeyboardButton::f13(); case SDLK_F14: return KeyboardButton::f14(); case SDLK_F15: return KeyboardButton::f15(); - // case SDLK_NUMLOCK: return KeyboardButton::numlock(); - // case SDLK_CAPSLOCK: return KeyboardButton::capslock(); - // case SDLK_SCROLLOCK: return KeyboardButton::scrollock(); + // case SDLK_NUMLOCK: return KeyboardButton::numlock(); case + // SDLK_CAPSLOCK: return KeyboardButton::capslock(); case SDLK_SCROLLOCK: + // return KeyboardButton::scrollock(); case SDLK_RSHIFT: return KeyboardButton::rshift(); case SDLK_LSHIFT: return KeyboardButton::lshift(); case SDLK_RCTRL: return KeyboardButton::rcontrol(); @@ -517,16 +480,15 @@ get_keyboard_button(SDLKey sym) { case SDLK_LALT: return KeyboardButton::lalt(); case SDLK_RMETA: return KeyboardButton::ralt(); case SDLK_LMETA: return KeyboardButton::lalt(); - // case SDLK_LSUPER: return KeyboardButton::left(); - // case SDLK_RSUPER: return KeyboardButton::right(); - // case SDLK_MODE: return KeyboardButton::mode(); + // case SDLK_LSUPER: return KeyboardButton::left(); case SDLK_RSUPER: + // return KeyboardButton::right(); case SDLK_MODE: return + // KeyboardButton::mode(); case SDLK_HELP: return KeyboardButton::help(); - // case SDLK_PRINT: return KeyboardButton::print-screen(); - // case SDLK_SYSREQ: return KeyboardButton::SysRq(); - // case SDLK_BREAK: return KeyboardButton::break(); - // case SDLK_MENU: return KeyboardButton::menu(); - // case SDLK_POWER: return KeyboardButton::power(); - // case SDLK_EURO: return KeyboardButton::euro(); + // case SDLK_PRINT: return KeyboardButton::print-screen(); case + // SDLK_SYSREQ: return KeyboardButton::SysRq(); case SDLK_BREAK: return + // KeyboardButton::break(); case SDLK_MENU: return KeyboardButton::menu(); + // case SDLK_POWER: return KeyboardButton::power(); case SDLK_EURO: return + // KeyboardButton::euro(); } tinydisplay_cat.info() << "unhandled keyboard button " << sym << "\n"; @@ -534,12 +496,10 @@ get_keyboard_button(SDLKey sym) { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: TinySDLGraphicsWindow::get_mouse_button -// Access: Private, Static -// Description: Maps from an SDL mouse button index to the -// corresponding Panda ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Maps from an SDL mouse button index to the corresponding Panda + * ButtonHandle. + */ ButtonHandle TinySDLGraphicsWindow:: get_mouse_button(Uint8 button) { switch (button) { diff --git a/panda/src/tinydisplay/tinySDLGraphicsWindow.h b/panda/src/tinydisplay/tinySDLGraphicsWindow.h index 0250480835..ae5793dcd4 100644 --- a/panda/src/tinydisplay/tinySDLGraphicsWindow.h +++ b/panda/src/tinydisplay/tinySDLGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: tinySDLGraphicsWindow.h -// Created by: drose (24Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinySDLGraphicsWindow.h + * @author drose + * @date 2008-04-24 + */ #ifndef TINYSDLGRAPHICSWINDOW_H #define TINYSDLGRAPHICSWINDOW_H @@ -25,13 +24,12 @@ #include "SDL.h" #include "zbuffer.h" -//////////////////////////////////////////////////////////////////// -// Class : TinySDLGraphicsWindow -// Description : This graphics window class is implemented via SDL. -//////////////////////////////////////////////////////////////////// +/** + * This graphics window class is implemented via SDL. + */ class EXPCL_TINYDISPLAY TinySDLGraphicsWindow : public GraphicsWindow { public: - TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + TinySDLGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/tinydisplay/tinyTextureContext.I b/panda/src/tinydisplay/tinyTextureContext.I index ef223f668a..10ba8332d2 100644 --- a/panda/src/tinydisplay/tinyTextureContext.I +++ b/panda/src/tinydisplay/tinyTextureContext.I @@ -1,23 +1,19 @@ -// Filename: tinyTextureContext.I -// Created by: drose (30Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyTextureContext.I + * @author drose + * @date 2008-04-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: TinyTextureContext::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TinyTextureContext:: TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : TextureContext(pgo, tex, view) @@ -27,11 +23,9 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : _gltex.total_bytecount = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TinyTextureContext::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE TinyTextureContext:: ~TinyTextureContext() { nassertv(_gltex.num_levels == 0 && _gltex.allocated_buffer == NULL && _gltex.total_bytecount == 0); diff --git a/panda/src/tinydisplay/tinyTextureContext.cxx b/panda/src/tinydisplay/tinyTextureContext.cxx index 3addd211ff..d5ec90b012 100644 --- a/panda/src/tinydisplay/tinyTextureContext.cxx +++ b/panda/src/tinydisplay/tinyTextureContext.cxx @@ -1,37 +1,31 @@ -// Filename: tinyTextureContext.cxx -// Created by: drose (30Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyTextureContext.cxx + * @author drose + * @date 2008-04-30 + */ #include "tinyTextureContext.h" #include "zgl.h" TypeHandle TinyTextureContext::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyTextureContext::evict_lru -// Access: Public, Virtual -// Description: Evicts the page from the LRU. Called internally when -// the LRU determines that it is full. May also be -// called externally when necessary to explicitly evict -// the page. -// -// It is legal for this method to either evict the page -// as requested, do nothing (in which case the eviction -// will be requested again at the next epoch), or -// requeue itself on the tail of the queue (in which -// case the eviction will be requested again much -// later). -//////////////////////////////////////////////////////////////////// +/** + * Evicts the page from the LRU. Called internally when the LRU determines + * that it is full. May also be called externally when necessary to + * explicitly evict the page. + * + * It is legal for this method to either evict the page as requested, do + * nothing (in which case the eviction will be requested again at the next + * epoch), or requeue itself on the tail of the queue (in which case the + * eviction will be requested again much later). + */ void TinyTextureContext:: evict_lru() { dequeue_lru(); diff --git a/panda/src/tinydisplay/tinyTextureContext.h b/panda/src/tinydisplay/tinyTextureContext.h index e98547bc0e..78e6af40de 100644 --- a/panda/src/tinydisplay/tinyTextureContext.h +++ b/panda/src/tinydisplay/tinyTextureContext.h @@ -1,16 +1,15 @@ -// Filename: tinyTextureContext.h -// Created by: drose (30Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyTextureContext.h + * @author drose + * @date 2008-04-30 + */ #ifndef TINYTEXTURECONTEXT_H #define TINYTEXTURECONTEXT_H @@ -20,10 +19,9 @@ #include "deletedChain.h" #include "zgl.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyTextureContext -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EXPCL_TINYDISPLAY TinyTextureContext : public TextureContext { public: INLINE TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view); diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.I b/panda/src/tinydisplay/tinyWinGraphicsPipe.I index 030d8a164a..3794ea5ef3 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.I +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: tinyWinGraphicsPipe.I -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsPipe.I + * @author drose + * @date 2008-05-06 + */ diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx index 43cc8b7c80..2371d17ba8 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: tinyWinGraphicsPipe.cxx -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsPipe.cxx + * @author drose + * @date 2008-05-06 + */ #include "pandabase.h" @@ -23,58 +22,45 @@ #include "tinyGraphicsBuffer.h" TypeHandle TinyWinGraphicsPipe::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ TinyWinGraphicsPipe:: TinyWinGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyWinGraphicsPipe:: ~TinyWinGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string TinyWinGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// TinyWinGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default TinyWinGraphicsPipe. + */ PT(GraphicsPipe) TinyWinGraphicsPipe:: pipe_constructor() { return new TinyWinGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window or buffer on the pipe, if possible. -// This routine is only called from GraphicsEngine::make_output. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window or buffer on the pipe, if possible. This routine is + * only called from GraphicsEngine::make_output. + */ PT(GraphicsOutput) TinyWinGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -85,7 +71,7 @@ make_output(const string &name, GraphicsOutput *host, int retry, bool &precertify) { - + if (!_is_valid) { return NULL; } @@ -117,17 +103,17 @@ make_output(const string &name, return new TinyWinGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Second thing to try: a TinyGraphicsBuffer if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { return NULL; } - return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, + return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } diff --git a/panda/src/tinydisplay/tinyWinGraphicsPipe.h b/panda/src/tinydisplay/tinyWinGraphicsPipe.h index 8e8d2bbfd4..fed6c7fa12 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyWinGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: tinyWinGraphicsPipe.h -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsPipe.h + * @author drose + * @date 2008-05-06 + */ #ifndef TINYWINGRAPHICSPIPE_H #define TINYWINGRAPHICSPIPE_H @@ -22,12 +21,10 @@ #include "winGraphicsPipe.h" #include "tinyGraphicsStateGuardian.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyWinGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating TinyPanda graphics windows on a -// Windows-based client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating TinyPanda graphics + * windows on a Windows-based client. + */ class EXPCL_TINYDISPLAY TinyWinGraphicsPipe : public WinGraphicsPipe { public: TinyWinGraphicsPipe(); diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.I b/panda/src/tinydisplay/tinyWinGraphicsWindow.I index 041818c115..3ca78b479e 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.I +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.I @@ -1,14 +1,12 @@ -// Filename: tinyWinGraphicsWindow.I -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsWindow.I + * @author drose + * @date 2008-05-06 + */ diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx index 3f45a741c5..afb7d1f016 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: tinyWinGraphicsWindow.cxx -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsWindow.cxx + * @author drose + * @date 2008-05-06 + */ #include "pandabase.h" @@ -27,11 +26,9 @@ TypeHandle TinyWinGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyWinGraphicsWindow:: TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -47,24 +44,19 @@ TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, update_pixel_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyWinGraphicsWindow:: ~TinyWinGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool TinyWinGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { begin_frame_spam(mode); @@ -90,13 +82,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void TinyWinGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -115,16 +105,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void TinyWinGraphicsWindow:: end_flip() { if (!_flip_ready) { @@ -147,7 +134,7 @@ end_flip() { BitBlt(_hdc, 0, 0, fb_xsize, fb_ysize, bmdc, 0, 0, SRCCOPY); } else { - // SetStretchBltMode(_hdc, HALFTONE); + // SetStretchBltMode(_hdc, HALFTONE); StretchBlt(_hdc, 0, 0, _frame_buffer->xsize, _frame_buffer->ysize, bmdc, 0, 0,fb_xsize, fb_ysize, SRCCOPY); @@ -159,31 +146,24 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::supports_pixel_zoom -// Access: Published, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool TinyWinGraphicsWindow:: supports_pixel_zoom() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void TinyWinGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -198,20 +178,17 @@ close_window() { WinGraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool TinyWinGraphicsWindow:: open_window() { if (!WinGraphicsWindow::open_window()) { return false; } - // GSG Creation/Initialization + // GSG CreationInitialization TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -241,13 +218,10 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_reshape -// Access: Protected, Virtual -// Description: Called in the window thread when the window size or -// location is changed, this updates the properties -// structure accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread when the window size or location is changed, + * this updates the properties structure accordingly. + */ void TinyWinGraphicsWindow:: handle_reshape() { WinGraphicsWindow::handle_reshape(); @@ -257,13 +231,10 @@ handle_reshape() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_fullscreen_resize -// Access: Protected, Virtual -// Description: Called in the window thread when the window size or -// location is changed, this updates the properties -// structure accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread when the window size or location is changed, + * this updates the properties structure accordingly. + */ bool TinyWinGraphicsWindow:: do_fullscreen_resize(int x_size, int y_size) { bool result = WinGraphicsWindow::do_fullscreen_resize(x_size, y_size); @@ -272,12 +243,9 @@ do_fullscreen_resize(int x_size, int y_size) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::create_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size. + */ void TinyWinGraphicsWindow:: create_frame_buffer() { if (_frame_buffer != NULL) { @@ -289,12 +257,10 @@ create_frame_buffer() { setup_bitmap_info(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyWinGraphicsWindow::setup_bitmap_info -// Access: Private -// Description: Determines the BITMAPINFO stuff for blitting the -// frame buffer to the window. -//////////////////////////////////////////////////////////////////// +/** + * Determines the BITMAPINFO stuff for blitting the frame buffer to the + * window. + */ void TinyWinGraphicsWindow:: setup_bitmap_info() { _bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); diff --git a/panda/src/tinydisplay/tinyWinGraphicsWindow.h b/panda/src/tinydisplay/tinyWinGraphicsWindow.h index 1f8c1afbdc..3140e61d27 100644 --- a/panda/src/tinydisplay/tinyWinGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyWinGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: tinyWinGraphicsWindow.h -// Created by: drose (06May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyWinGraphicsWindow.h + * @author drose + * @date 2008-05-06 + */ #ifndef TINYWINGRAPHICSWINDOW_H #define TINYWINGRAPHICSWINDOW_H @@ -22,14 +21,13 @@ #include "winGraphicsWindow.h" #include "tinyWinGraphicsPipe.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyWinGraphicsWindow -// Description : Opens a window on Microsoft Windows to display the -// TinyPanda software rendering. -//////////////////////////////////////////////////////////////////// +/** + * Opens a window on Microsoft Windows to display the TinyPanda software + * rendering. + */ class EXPCL_TINYDISPLAY TinyWinGraphicsWindow : public WinGraphicsWindow { public: - TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + TinyWinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.I b/panda/src/tinydisplay/tinyXGraphicsPipe.I index cef3ba01be..b27a152f4b 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.I +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: tinyXGraphicsPipe.I -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsPipe.I + * @author drose + * @date 2008-05-03 + */ diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index 3786850084..9bb2c4c2d6 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: tinyXGraphicsPipe.cxx -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsPipe.cxx + * @author drose + * @date 2008-05-03 + */ #include "pandabase.h" #ifdef HAVE_X11 @@ -24,56 +23,43 @@ TypeHandle TinyXGraphicsPipe::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyXGraphicsPipe:: TinyXGraphicsPipe(const string &display) : x11GraphicsPipe(display) { } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyXGraphicsPipe:: ~TinyXGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string TinyXGraphicsPipe:: get_interface_name() const { return "TinyPanda"; } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// TinyXGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default TinyXGraphicsPipe. + */ PT(GraphicsPipe) TinyXGraphicsPipe:: pipe_constructor() { return new TinyXGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window on the pipe, if possible. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window on the pipe, if possible. + */ PT(GraphicsOutput) TinyXGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -91,9 +77,9 @@ make_output(const string &name, // First thing to try: a TinyXGraphicsWindow - // We check _is_valid only in this case. The pipe will be invalid - // if it can't contact the X server, but that shouldn't prevent the - // creation of an offscreen buffer. + // We check _is_valid only in this case. The pipe will be invalid if it + // can't contact the X server, but that shouldn't prevent the creation of an + // offscreen buffer. if (retry == 0 && _is_valid) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_refuse_window)!=0)|| @@ -107,11 +93,11 @@ make_output(const string &name, return new TinyXGraphicsWindow(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Second thing to try: a TinyGraphicsBuffer - // No need to check _is_valid here. We can create an offscreen - // buffer even if the pipe is not technically valid. + // No need to check _is_valid here. We can create an offscreen buffer even + // if the pipe is not technically valid. if (retry == 1) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)) { @@ -119,7 +105,7 @@ make_output(const string &name, } return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index c05350dcfb..c6ecf15817 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: tinyXGraphicsPipe.h -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsPipe.h + * @author drose + * @date 2008-05-03 + */ #ifndef TINYXGRAPHICSPIPE_H #define TINYXGRAPHICSPIPE_H @@ -25,12 +24,10 @@ #include "lightMutex.h" #include "lightReMutex.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyXGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating TinyPanda graphics windows on an X11-based -// (e.g. Unix) client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating TinyPanda graphics + * windows on an X11-based (e.g. Unix) client. + */ class EXPCL_TINYDISPLAY TinyXGraphicsPipe : public x11GraphicsPipe { public: TinyXGraphicsPipe(const string &display = string()); diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.I b/panda/src/tinydisplay/tinyXGraphicsWindow.I index 118f944e92..3b7bfb42cf 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.I +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.I @@ -1,14 +1,12 @@ -// Filename: tinyXGraphicsWindow.I -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsWindow.I + * @author drose + * @date 2008-05-03 + */ diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 924ababedb..7b34ba0fb7 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: tinyXGraphicsWindow.cxx -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsWindow.cxx + * @author drose + * @date 2008-05-03 + */ #include "pandabase.h" @@ -33,13 +32,11 @@ TypeHandle TinyXGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyXGraphicsWindow:: -TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, +TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -56,11 +53,9 @@ TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, update_pixel_factor(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TinyXGraphicsWindow:: ~TinyXGraphicsWindow() { if (_gc != NULL && _display != NULL) { @@ -73,15 +68,12 @@ TinyXGraphicsWindow:: } } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool TinyXGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -95,8 +87,8 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } if (_awaiting_configure) { - // Don't attempt to draw while we have just reconfigured the - // window and we haven't got the notification back yet. + // Don't attempt to draw while we have just reconfigured the window and we + // haven't got the notification back yet. return false; } @@ -109,18 +101,16 @@ begin_frame(FrameMode mode, Thread *current_thread) { tinygsg->_current_frame_buffer = _full_frame_buffer; } tinygsg->reset_if_new(); - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void TinyXGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -139,16 +129,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void TinyXGraphicsWindow:: end_flip() { if (_xwindow == (X11_Window)NULL || !_flip_ready) { @@ -158,17 +145,16 @@ end_flip() { if (_reduced_frame_buffer != (ZBuffer *)NULL) { // Zoom the reduced buffer onto the full buffer. - ZB_zoomFrameBuffer(_full_frame_buffer, 0, 0, + ZB_zoomFrameBuffer(_full_frame_buffer, 0, 0, _full_frame_buffer->xsize, _full_frame_buffer->ysize, _reduced_frame_buffer, 0, 0, _reduced_frame_buffer->xsize, _reduced_frame_buffer->ysize); } - // We can't just point the XPutImage directly at our own framebuffer - // data, even if the bytes_per_pixel matches, because some X - // displays will respect the alpha channel and make the window - // transparent there. We don't want transparent windows where the - // alpha data happens to less than 1.0. + // We can't just point the XPutImage directly at our own framebuffer data, + // even if the bytes_per_pixel matches, because some X displays will respect + // the alpha channel and make the window transparent there. We don't want + // transparent windows where the alpha data happens to less than 1.0. ZB_copyFrameBufferNoAlpha(_full_frame_buffer, _ximage->data, _pitch); XPutImage(_display, _xwindow, _gc, _ximage, 0, 0, 0, 0, @@ -177,35 +163,28 @@ end_flip() { GraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::supports_pixel_zoom -// Access: Published, Virtual -// Description: Returns true if a call to set_pixel_zoom() will be -// respected, false if it will be ignored. If this -// returns false, then get_pixel_factor() will always -// return 1.0, regardless of what value you specify for -// set_pixel_zoom(). -// -// This may return false if the underlying renderer -// doesn't support pixel zooming, or if you have called -// this on a DisplayRegion that doesn't have both -// set_clear_color() and set_clear_depth() enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a call to set_pixel_zoom() will be respected, false if it + * will be ignored. If this returns false, then get_pixel_factor() will + * always return 1.0, regardless of what value you specify for + * set_pixel_zoom(). + * + * This may return false if the underlying renderer doesn't support pixel + * zooming, or if you have called this on a DisplayRegion that doesn't have + * both set_clear_color() and set_clear_depth() enabled. + */ bool TinyXGraphicsWindow:: supports_pixel_zoom() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void TinyXGraphicsWindow:: process_events() { LightReMutexHolder holder(TinyXGraphicsPipe::_x_mutex); @@ -215,9 +194,9 @@ process_events() { if (_xwindow == (X11_Window)0) { return; } - + poll_raw_mice(); - + XEvent event; XKeyEvent keyrelease_event; bool got_keyrelease_event = false; @@ -228,28 +207,27 @@ process_events() { } if (got_keyrelease_event) { - // If a keyrelease event is immediately followed by a matching - // keypress event, that's just key repeat and we should treat - // the two events accordingly. It would be nice if X provided a - // way to differentiate between keyrepeat and explicit - // keypresses more generally. + // If a keyrelease event is immediately followed by a matching keypress + // event, that's just key repeat and we should treat the two events + // accordingly. It would be nice if X provided a way to differentiate + // between keyrepeat and explicit keypresses more generally. got_keyrelease_event = false; if (event.type == KeyPress && event.xkey.keycode == keyrelease_event.keycode && (event.xkey.time - keyrelease_event.time <= 1)) { - // In particular, we only generate down messages for the - // repeated keys, not down-and-up messages. + // In particular, we only generate down messages for the repeated + // keys, not down-and-up messages. handle_keystroke(event.xkey); - // We thought about not generating the keypress event, but we - // need that repeat for backspace. Rethink later. + // We thought about not generating the keypress event, but we need + // that repeat for backspace. Rethink later. handle_keypress(event.xkey); continue; } else { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } @@ -264,12 +242,11 @@ process_events() { case ConfigureNotify: _awaiting_configure = false; if (_properties.get_fixed_size()) { - // If the window properties indicate a fixed size only, undo - // any attempt by the user to change them. In X, there - // doesn't appear to be a way to universally disallow this - // directly (although we do set the min_size and max_size to - // the same value, which seems to work for most window - // managers.) + // If the window properties indicate a fixed size only, undo any + // attempt by the user to change them. In X, there doesn't appear to + // be a way to universally disallow this directly (although we do set + // the min_size and max_size to the same value, which seems to work + // for most window managers.) WindowProperties current_props = get_properties(); if (event.xconfigure.width != current_props.get_x_size() || event.xconfigure.height != current_props.get_y_size()) { @@ -297,7 +274,7 @@ process_events() { _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y); _input_devices[0].button_down(button); break; - + case ButtonRelease: button = get_mouse_button(event.xbutton); _input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y); @@ -314,9 +291,9 @@ process_events() { break; case KeyRelease: - // The KeyRelease can't be processed immediately, because we - // have to check first if it's immediately followed by a - // matching KeyPress event. + // The KeyRelease can't be processed immediately, because we have to + // check first if it's immediately followed by a matching KeyPress + // event. keyrelease_event = event.xkey; got_keyrelease_event = true; break; @@ -355,17 +332,17 @@ process_events() { case ClientMessage: if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) { - // This is a message from the window manager indicating that - // the user has requested to close the window. + // This is a message from the window manager indicating that the user + // has requested to close the window. string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept - // the request and process it directly. + // In this case, the app has indicated a desire to intercept the + // request and process it directly. throw_event(close_request_event); } else { - // In this case, the default case, the app does not intend - // to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to + // service the request, so we do by closing the window. // TODO: don't release the gsg in the window thread. close_window(); @@ -376,9 +353,8 @@ process_events() { break; case DestroyNotify: - // Apparently, we never get a DestroyNotify on a toplevel - // window. Instead, we rely on hints from the window manager - // (see above). + // Apparently, we never get a DestroyNotify on a toplevel window. + // Instead, we rely on hints from the window manager (see above). tinydisplay_cat.info() << "DestroyNotify\n"; break; @@ -390,18 +366,15 @@ process_events() { } if (got_keyrelease_event) { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void TinyXGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -410,23 +383,20 @@ close_window() { tinygsg->_current_frame_buffer = NULL; _gsg.clear(); } - + x11GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool TinyXGraphicsWindow:: open_window() { TinyXGraphicsPipe *tinyx_pipe; DCAST_INTO_R(tinyx_pipe, _pipe, false); - // GSG Creation/Initialization + // GSG CreationInitialization TinyGraphicsStateGuardian *tinygsg; if (_gsg == 0) { // There is no old gsg. Create a new one. @@ -454,7 +424,7 @@ open_window() { int num_vinfos = 0; XVisualInfo *vinfo_array; while (try_masks[i] != 0 && num_vinfos == 0) { - vinfo_array = + vinfo_array = XGetVisualInfo(_display, try_masks[i], &vinfo_template, &num_vinfos); ++i; } @@ -480,7 +450,7 @@ open_window() { case TrueColor: tinydisplay_cat.info(false) << "TrueColor\n"; break; - + case DirectColor: tinydisplay_cat.info(false) << "DirectColor\n"; break; @@ -521,13 +491,13 @@ open_window() { nassertr(_ximage != NULL, false); tinygsg->_current_frame_buffer = _full_frame_buffer; - + tinygsg->reset_if_new(); if (!tinygsg->is_valid()) { close_window(); return false; } - + XMapWindow(_display, _xwindow); if (_properties.get_raw_mice()) { @@ -546,27 +516,22 @@ open_window() { if (_parent_window_handle != (WindowHandle *)NULL) { _parent_window_handle->attach_child(_window_handle); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::pixel_factor_changed -// Access: Protected, Virtual -// Description: Called internally when the pixel factor changes. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the pixel factor changes. + */ void TinyXGraphicsWindow:: pixel_factor_changed() { x11GraphicsWindow::pixel_factor_changed(); create_reduced_frame_buffer(); } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::create_full_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size. + */ void TinyXGraphicsWindow:: create_full_frame_buffer() { if (_full_frame_buffer != NULL) { @@ -596,12 +561,9 @@ create_full_frame_buffer() { _pitch = (_full_frame_buffer->xsize * _bytes_per_pixel + 3) & ~3; } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::create_reduced_frame_buffer -// Access: Private -// Description: Creates a suitable frame buffer for the current -// window size and pixel zoom. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable frame buffer for the current window size and pixel zoom. + */ void TinyXGraphicsWindow:: create_reduced_frame_buffer() { if (!_full_frame_buffer) { @@ -620,19 +582,16 @@ create_reduced_frame_buffer() { // No zooming is necessary. } else { - // The reduced size is different, so we need a separate buffer to - // render into. + // The reduced size is different, so we need a separate buffer to render + // into. _reduced_frame_buffer = ZB_open(x_size, y_size, _full_frame_buffer->mode, 0, 0, 0, 0); } } -//////////////////////////////////////////////////////////////////// -// Function: TinyXGraphicsWindow::create_ximage -// Access: Private -// Description: Creates a suitable XImage for the current -// window size. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable XImage for the current window size. + */ void TinyXGraphicsWindow:: create_ximage() { if (_ximage != NULL) { @@ -651,4 +610,3 @@ create_ximage() { } #endif // HAVE_X11 - diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.h b/panda/src/tinydisplay/tinyXGraphicsWindow.h index e8e1aa9193..e533f2b67d 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: tinyXGraphicsWindow.h -// Created by: drose (03May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file tinyXGraphicsWindow.h + * @author drose + * @date 2008-05-03 + */ #ifndef TINYXGRAPHICSWINDOW_H #define TINYXGRAPHICSWINDOW_H @@ -23,14 +22,12 @@ #include "x11GraphicsWindow.h" #include "buttonHandle.h" -//////////////////////////////////////////////////////////////////// -// Class : TinyXGraphicsWindow -// Description : Opens a window on X11 to display the TinyPanda -// software rendering. -//////////////////////////////////////////////////////////////////// +/** + * Opens a window on X11 to display the TinyPanda software rendering. + */ class EXPCL_TINYDISPLAY TinyXGraphicsWindow : public x11GraphicsWindow { public: - TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + TinyXGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -55,7 +52,7 @@ private: void create_full_frame_buffer(); void create_reduced_frame_buffer(); void create_ximage(); - + private: ZBuffer *_reduced_frame_buffer; ZBuffer *_full_frame_buffer; @@ -65,7 +62,7 @@ private: int _bytes_per_pixel; Visual *_visual; int _depth; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -89,4 +86,3 @@ private: #endif // HAVE_X11 #endif - diff --git a/panda/src/vision/arToolKit.I b/panda/src/vision/arToolKit.I index e9d3a1ea1e..08d754fd2e 100644 --- a/panda/src/vision/arToolKit.I +++ b/panda/src/vision/arToolKit.I @@ -1,27 +1,22 @@ -// Filename: arToolKit.I -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arToolKit.I + * @author jyelon + * @date 2007-11-01 + */ -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::set_threshold -// Access: Private -// Description: As part of its analysis, the ARToolKit occasionally -// converts images to black and white by thresholding -// them. The threshold is set to 0.5 by default, but -// you can tweak it here. -//////////////////////////////////////////////////////////////////// +/** + * As part of its analysis, the ARToolKit occasionally converts images to + * black and white by thresholding them. The threshold is set to 0.5 by + * default, but you can tweak it here. + */ INLINE void ARToolKit:: set_threshold(double thresh) { _threshold = thresh; } - diff --git a/panda/src/vision/arToolKit.cxx b/panda/src/vision/arToolKit.cxx index 9bd40652b1..0c68f5cd46 100644 --- a/panda/src/vision/arToolKit.cxx +++ b/panda/src/vision/arToolKit.cxx @@ -1,16 +1,15 @@ -// Filename: arToolKit.cxx -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arToolKit.cxx + * @author jyelon + * @date 2007-11-01 + */ #include "arToolKit.h" @@ -102,20 +101,16 @@ static void analyze_fov(double cparam[3][4], int width, int height, double &xfov yfov = 2.0 * atan(1.0/yval) * (180.0/3.141592654); } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::make -// Access: Private -// Description: Create a new ARToolKit instance. -// -// Camera must be the nodepath of a panda camera object. -// The panda camera's field of view is initialized to match -// the field of view of the physical webcam. Each time -// you call analyze, all marker nodepaths will be moved -// into a position which is relative to this camera. -// The marker_size parameter indicates how large you -// printed the physical markers. You should use the same -// size units that you wish to use in the panda code. -//////////////////////////////////////////////////////////////////// +/** + * Create a new ARToolKit instance. + * + * Camera must be the nodepath of a panda camera object. The panda camera's + * field of view is initialized to match the field of view of the physical + * webcam. Each time you call analyze, all marker nodepaths will be moved + * into a position which is relative to this camera. The marker_size + * parameter indicates how large you printed the physical markers. You should + * use the same size units that you wish to use in the panda code. + */ ARToolKit *ARToolKit:: make(NodePath camera, const Filename ¶mfile, double marker_size) { @@ -173,11 +168,9 @@ make(NodePath camera, const Filename ¶mfile, double marker_size) { } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::cleanup -// Access: Private -// Description: Pre-destructor deallocation and cleanup. -//////////////////////////////////////////////////////////////////// +/** + * Pre-destructor deallocation and cleanup. + */ void ARToolKit:: cleanup() { if (_camera_param) { @@ -187,32 +180,25 @@ cleanup() { } } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::Constructor -// Access: Private -// Description: Use ARToolKit::make to create an ARToolKit. -//////////////////////////////////////////////////////////////////// +/** + * Use ARToolKit::make to create an ARToolKit. + */ ARToolKit:: ARToolKit() : _have_prev_conv(false) { } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ARToolKit:: ~ARToolKit() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::get_pattern -// Access: Private -// Description: Load the specified pattern into the toolkit, and -// return the pattern index. Initially, the pattern -// is inactive. -//////////////////////////////////////////////////////////////////// +/** + * Load the specified pattern into the toolkit, and return the pattern index. + * Initially, the pattern is inactive. + */ int ARToolKit:: get_pattern(const Filename &filename) { PatternTable::iterator ptf = _pattern_table.find(filename); @@ -231,14 +217,11 @@ get_pattern(const Filename &filename) { return id; } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::attach_pattern -// Access: Public -// Description: Associates the specified glyph with the specified -// NodePath. Each time you call analyze, ARToolKit -// will update the NodePath's transform. If the node -// is not visible, its scale will be set to zero. -//////////////////////////////////////////////////////////////////// +/** + * Associates the specified glyph with the specified NodePath. Each time you + * call analyze, ARToolKit will update the NodePath's transform. If the node + * is not visible, its scale will be set to zero. + */ void ARToolKit:: attach_pattern(const Filename &filename, NodePath path) { int patt = get_pattern(filename); @@ -246,32 +229,26 @@ attach_pattern(const Filename &filename, NodePath path) { _controls[patt] = path; } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::detach_patterns -// Access: Public -// Description: Dissociates all patterns from all NodePaths. -//////////////////////////////////////////////////////////////////// +/** + * Dissociates all patterns from all NodePaths. + */ void ARToolKit:: detach_patterns() { _controls.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ARToolKit::analyze -// Access: Public -// Description: Analyzes the non-pad region of the specified texture. -// This causes all attached nodepaths to move. -// The parameter do_flip_texture is true by default, -// because Panda's representation of textures is -// upside down from ARToolKit. If you already have -// a texture that's upside-down, however, you should -// set it to false. -//////////////////////////////////////////////////////////////////// +/** + * Analyzes the non-pad region of the specified texture. This causes all + * attached nodepaths to move. The parameter do_flip_texture is true by + * default, because Panda's representation of textures is upside down from + * ARToolKit. If you already have a texture that's upside-down, however, you + * should set it to false. + */ void ARToolKit:: analyze(Texture *tex, bool do_flip_texture) { - // We shouldn't assert on has_ram_image since it also returns false - // when there is a ram image but it's not updated for this frame. - //nassertv(tex->has_ram_image()); + // We shouldn't assert on has_ram_image since it also returns false when + // there is a ram image but it's not updated for this frame. + // nassertv(tex->has_ram_image()); nassertv(tex->get_ram_image_compression() == Texture::CM_off); nassertv(tex->get_component_type() == Texture::T_unsigned_byte); nassertv(tex->get_texture_type() == Texture::TT_2d_texture); @@ -285,7 +262,7 @@ analyze(Texture *tex, bool do_flip_texture) { int pady = tex->get_pad_y_size(); int xsize = tex->get_x_size() - padx; int ysize = tex->get_y_size() - pady; - //int pagesize = xsize * ysize * 4; + // int pagesize = xsize * ysize * 4; nassertv((xsize > 0) && (ysize > 0)); // row length in bytes @@ -296,9 +273,9 @@ analyze(Texture *tex, bool do_flip_texture) { arInitCparam(&cparam); // Pack the data into a buffer with no padding and invert the video - // vertically (panda's representation is upside down from ARToolKit) - // Note: ARToolKit treats the images as grayscale, so the order of - // the individual R, G and B components does not matter. + // vertically (panda's representation is upside down from ARToolKit) Note: + // ARToolKit treats the images as grayscale, so the order of the individual + // R, G and B components does not matter. CPTA_uchar ri = tex->get_ram_image(); const unsigned char *ram = ri.p(); @@ -502,4 +479,3 @@ analyze(Texture *tex, bool do_flip_texture) { } #endif // HAVE_ARTOOLKIT - diff --git a/panda/src/vision/arToolKit.h b/panda/src/vision/arToolKit.h index 3439d887b4..63b558d9a6 100644 --- a/panda/src/vision/arToolKit.h +++ b/panda/src/vision/arToolKit.h @@ -1,16 +1,15 @@ -// Filename: arToolKit.h -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file arToolKit.h + * @author jyelon + * @date 2007-11-01 + */ #ifndef ARTOOLKIT_H #define ARTOOLKIT_H @@ -22,46 +21,40 @@ #include "nodePath.h" #include "texture.h" -//////////////////////////////////////////////////////////////////// -// Class : ARToolKit -// Description : ARToolKit is a software library for building -// Augmented Reality (AR) applications. These are -// applications that involve the overlay of virtual -// imagery on the real world. It was developed by -// Dr. Hirokazu Kato. Its ongoing development is -// being supported by the Human Interface Technology -// Laboratory (HIT Lab) at the University of -// Washington, HIT Lab NZ at the University of -// Canterbury, New Zealand, and ARToolworks, Inc, -// Seattle. It is available under a GPL license. -// It is also possible to negotiate other licenses -// with the copyright holders. -// -// This class is a wrapper around the ARToolKit -// library. -//////////////////////////////////////////////////////////////////// +/** + * ARToolKit is a software library for building Augmented Reality (AR) + * applications. These are applications that involve the overlay of virtual + * imagery on the real world. It was developed by Dr. Hirokazu Kato. Its + * ongoing development is being supported by the Human Interface Technology + * Laboratory (HIT Lab) at the University of Washington, HIT Lab NZ at the + * University of Canterbury, New Zealand, and ARToolworks, Inc, Seattle. It + * is available under a GPL license. It is also possible to negotiate other + * licenses with the copyright holders. + * + * This class is a wrapper around the ARToolKit library. + */ class EXPCL_VISION ARToolKit { - + PUBLISHED: static ARToolKit *make(NodePath camera, const Filename ¶mfile, double markersize); ~ARToolKit(); - + INLINE void set_threshold(double n); void attach_pattern(const Filename &pattern, NodePath path); void detach_patterns(); void analyze(Texture *tex, bool do_flip_texture = true); - + private: static int get_pattern(const Filename &pattern); ARToolKit(); void cleanup(); - + typedef pmap PatternTable; static PatternTable _pattern_table; - + typedef pmap Controls; Controls _controls; - + NodePath _camera; void *_camera_param; double _threshold; diff --git a/panda/src/vision/config_vision.cxx b/panda/src/vision/config_vision.cxx index 77a51bb28e..91c6acac86 100644 --- a/panda/src/vision/config_vision.cxx +++ b/panda/src/vision/config_vision.cxx @@ -1,16 +1,15 @@ -// Filename: config_vision.cxx -// Created by: pro-rsoft (07Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_vision.cxx + * @author rdb + * @date 2009-11-07 + */ #include "config_vision.h" #include "openCVTexture.h" @@ -31,14 +30,12 @@ ConfigureFn(config_vision) { init_libvision(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libvision -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libvision() { static bool initialized = false; @@ -69,4 +66,3 @@ init_libvision() { #endif #endif } - diff --git a/panda/src/vision/config_vision.h b/panda/src/vision/config_vision.h index eb1d4a6b17..5eec1a95b2 100644 --- a/panda/src/vision/config_vision.h +++ b/panda/src/vision/config_vision.h @@ -1,16 +1,15 @@ -// Filename: config_vision.h -// Created by: pro-rsoft (07Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_vision.h + * @author rdb + * @date 2009-11-07 + */ #ifndef CONFIG_VISION_H #define CONFIG_VISION_H @@ -23,4 +22,3 @@ NotifyCategoryDecl(vision, EXPCL_VISION, EXPTP_VISION); extern EXPCL_VISION void init_libvision(); #endif - diff --git a/panda/src/vision/openCVTexture.I b/panda/src/vision/openCVTexture.I index f744e01d3e..d9f5fa6f37 100644 --- a/panda/src/vision/openCVTexture.I +++ b/panda/src/vision/openCVTexture.I @@ -1,54 +1,43 @@ -// Filename: openCVTexture.I -// Created by: zacpavlov (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openCVTexture.I + * @author zacpavlov + * @date 2005-08-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::is_valid -// Access: Public -// Description: Returns true if this stream is open and ready, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this stream is open and ready, false otherwise. + */ INLINE bool OpenCVTexture::VideoStream:: is_valid() const { return (_capture != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::is_from_file -// Access: Public -// Description: Returns true if this stream takes its input from a -// video file, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this stream takes its input from a video file, false + * otherwise. + */ INLINE bool OpenCVTexture::VideoStream:: is_from_file() const { return !_filename.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoPage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OpenCVTexture::VideoPage:: VideoPage() { } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoPage::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OpenCVTexture::VideoPage:: VideoPage(const OpenCVTexture::VideoPage ©) : _color(copy._color), @@ -56,12 +45,9 @@ VideoPage(const OpenCVTexture::VideoPage ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoPage::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE OpenCVTexture::VideoPage:: ~VideoPage() { } - diff --git a/panda/src/vision/openCVTexture.cxx b/panda/src/vision/openCVTexture.cxx index aaa056acea..34c70284b1 100644 --- a/panda/src/vision/openCVTexture.cxx +++ b/panda/src/vision/openCVTexture.cxx @@ -1,16 +1,15 @@ -// Filename: openCVTexture.cxx -// Created by: zacpavlov (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openCVTexture.cxx + * @author zacpavlov + * @date 2005-08-19 + */ #include "pandabase.h" @@ -24,46 +23,37 @@ TypeHandle OpenCVTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::Constructor -// Access: Published -// Description: Sets up the texture to read frames from a camera -//////////////////////////////////////////////////////////////////// +/** + * Sets up the texture to read frames from a camera + */ OpenCVTexture:: -OpenCVTexture(const string &name) : - VideoTexture(name) +OpenCVTexture(const string &name) : + VideoTexture(name) { } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::Copy Constructor -// Access: Protected -// Description: Use OpenCVTexture::make_copy() to make a duplicate copy of -// an existing OpenCVTexture. -//////////////////////////////////////////////////////////////////// +/** + * Use OpenCVTexture::make_copy() to make a duplicate copy of an existing + * OpenCVTexture. + */ OpenCVTexture:: -OpenCVTexture(const OpenCVTexture ©) : +OpenCVTexture(const OpenCVTexture ©) : VideoTexture(copy), _pages(copy._pages) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenCVTexture:: ~OpenCVTexture() { } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::consider_update -// Access: Protected, Virtual -// Description: Calls update_frame() if the current frame has -// changed. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_frame() if the current frame has changed. + */ void OpenCVTexture:: consider_update() { int this_frame = ClockObject::get_global_clock()->get_frame_count(); @@ -88,19 +78,15 @@ consider_update() { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::make_copy_impl -// Access: Protected, Virtual -// Description: Returns a new copy of the same Texture. This copy, -// if applied to geometry, will be copied into texture -// as a separate texture from the original, so it will -// be duplicated in texture memory (and may be -// independently modified if desired). -// -// If the Texture is an OpenCVTexture, the resulting -// duplicate may be animated independently of the -// original. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new copy of the same Texture. This copy, if applied to geometry, + * will be copied into texture as a separate texture from the original, so it + * will be duplicated in texture memory (and may be independently modified if + * desired). + * + * If the Texture is an OpenCVTexture, the resulting duplicate may be animated + * independently of the original. + */ PT(Texture) OpenCVTexture:: make_copy_impl() { Texture::CDReader cdata_tex(Texture::_cycler); @@ -111,31 +97,25 @@ make_copy_impl() { return copy.p(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_assign -// Access: Protected -// Description: Implements make_copy(). -//////////////////////////////////////////////////////////////////// +/** + * Implements make_copy(). + */ void OpenCVTexture:: -do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, +do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, const Texture::CData *cdata_copy_tex) { VideoTexture::do_assign(cdata_tex, copy, cdata_copy_tex); _pages = copy->_pages; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::from_camera -// Access: Published -// Description: Sets up the OpenCVTexture (or the indicated page, if z -// is specified) to accept its input from the camera -// with the given index number, or the default camera if -// the index number is -1 or unspecified. -// -// If alpha_file_channel is 0, then the camera image -// becomes a normal RGB texture. If it is 1, 2, or 3, -// then the camera image becomes an alpha texture, using -// the indicated channel of the source. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the OpenCVTexture (or the indicated page, if z is specified) to + * accept its input from the camera with the given index number, or the + * default camera if the index number is -1 or unspecified. + * + * If alpha_file_channel is 0, then the camera image becomes a normal RGB + * texture. If it is 1, 2, or 3, then the camera image becomes an alpha + * texture, using the indicated channel of the source. + */ bool OpenCVTexture:: from_camera(int camera_index, int z, int alpha_file_channel, const LoaderOptions &options) { @@ -179,14 +159,11 @@ from_camera(int camera_index, int z, int alpha_file_channel, return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_modify_page -// Access: Private -// Description: Returns a reference to the zth VideoPage (level) of -// the texture. In the case of a 2-d texture, there is -// only one page, level 0; but cube maps and 3-d -// textures have more. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the zth VideoPage (level) of the texture. In the + * case of a 2-d texture, there is only one page, level 0; but cube maps and + * 3-d textures have more. + */ OpenCVTexture::VideoPage &OpenCVTexture:: do_modify_page(const Texture::CData *cdata, int z) { nassertr(z < cdata->_z_size, _pages[0]); @@ -196,17 +173,14 @@ do_modify_page(const Texture::CData *cdata, int z) { return _pages[z]; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_reconsider_video_properties -// Access: Private -// Description: Resets the internal Texture properties when a new -// video file is loaded. Returns true if the new image -// is valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Resets the internal Texture properties when a new video file is loaded. + * Returns true if the new image is valid, false otherwise. + */ bool OpenCVTexture:: do_reconsider_video_properties(Texture::CData *cdata, - const OpenCVTexture::VideoStream &stream, - int num_components, int z, + const OpenCVTexture::VideoStream &stream, + int num_components, int z, const LoaderOptions &options) { double frame_rate = 0.0f; int num_frames = 0; @@ -220,8 +194,8 @@ do_reconsider_video_properties(Texture::CData *cdata, << frame_rate << " fps\n"; } } else { - // In this case, we don't have a specific frame rate or number of - // frames. Let both values remain at 0. + // In this case, we don't have a specific frame rate or number of frames. + // Let both values remain at 0. if (vision_cat.is_debug()) { vision_cat.debug() << "Loaded camera stream\n"; @@ -237,7 +211,7 @@ do_reconsider_video_properties(Texture::CData *cdata, if (vision_cat.is_debug()) { vision_cat.debug() - << "Video stream is " << width << " by " << height + << "Video stream is " << width << " by " << height << " pixels; fitting in texture " << x_size << " by " << y_size << " texels.\n"; } @@ -247,7 +221,7 @@ do_reconsider_video_properties(Texture::CData *cdata, return false; } - if (cdata->_loaded_from_image && + if (cdata->_loaded_from_image && (get_video_width() != width || get_video_height() != height || get_num_frames() != num_frames || get_frame_rate() != frame_rate)) { vision_cat.error() @@ -260,30 +234,24 @@ do_reconsider_video_properties(Texture::CData *cdata, set_num_frames(num_frames); set_video_size(width, height); - // By default, the newly-loaded video stream will immediately start - // looping. + // By default, the newly-loaded video stream will immediately start looping. loop(true); return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::make_texture -// Access: Public, Static -// Description: A factory function to make a new OpenCVTexture, used -// to pass to the TexturePool. -//////////////////////////////////////////////////////////////////// +/** + * A factory function to make a new OpenCVTexture, used to pass to the + * TexturePool. + */ PT(Texture) OpenCVTexture:: make_texture() { return new OpenCVTexture; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_update_frame -// Access: Protected, Virtual -// Description: Called once per frame, as needed, to load the new -// image contents. -//////////////////////////////////////////////////////////////////// +/** + * Called once per frame, as needed, to load the new image contents. + */ void OpenCVTexture:: do_update_frame(Texture::CData *cdata, int frame) { int max_z = max(cdata->_z_size, (int)_pages.size()); @@ -292,12 +260,9 @@ do_update_frame(Texture::CData *cdata, int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_update_frame -// Access: Protected, Virtual -// Description: This variant of update_frame updates the -// indicated page only. -//////////////////////////////////////////////////////////////////// +/** + * This variant of update_frame updates the indicated page only. + */ void OpenCVTexture:: do_update_frame(Texture::CData *cdata, int frame, int z) { if (vision_cat.is_spam()) { @@ -335,8 +300,8 @@ do_update_frame(Texture::CData *cdata, int frame, int z) { } } else { - // The harder case--interleave in the color channels, pixel by - // pixel, possibly leaving room for alpha. + // The harder case--interleave in the color channels, pixel by pixel, + // possibly leaving room for alpha. for (int y = 0; y < get_video_height(); ++y) { int dx = 0; @@ -367,18 +332,18 @@ do_update_frame(Texture::CData *cdata, int frame, int z) { nassertv(!cdata->_ram_images.empty()) unsigned char *dest = cdata->_ram_images[0]._image.p() + do_get_expected_ram_page_size(cdata) * z; - // Interleave the alpha in with the color, pixel by pixel. - // Even though the alpha will probably be a grayscale video, - // the OpenCV library presents it as RGB. + // Interleave the alpha in with the color, pixel by pixel. Even though + // the alpha will probably be a grayscale video, the OpenCV library + // presents it as RGB. const unsigned char *sch = source[0]; if (cdata->_alpha_file_channel >= 1 && cdata->_alpha_file_channel <= 3) { sch = source[cdata->_alpha_file_channel - 1]; } - + for (int y = 0; y < get_video_height(); ++y) { - // Start dx at _num_components - 1, which writes to the last - // channel, i.e. the alpha channel. - int dx = (cdata->_num_components - 1) * cdata->_component_width; + // Start dx at _num_components - 1, which writes to the last channel, + // i.e. the alpha channel. + int dx = (cdata->_num_components - 1) * cdata->_component_width; int sx = 0; for (int x = 0; x < get_video_width(); ++x) { dest[dx] = sch[sx]; @@ -392,13 +357,10 @@ do_update_frame(Texture::CData *cdata, int frame, int z) { } } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_read_one -// Access: Protected, Virtual -// Description: Combines a color and alpha video image from the two -// indicated filenames. Both must be the same kind of -// video with similar properties. -//////////////////////////////////////////////////////////////////// +/** + * Combines a color and alpha video image from the two indicated filenames. + * Both must be the same kind of video with similar properties. + */ bool OpenCVTexture:: do_read_one(Texture::CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, @@ -460,7 +422,7 @@ do_read_one(Texture::CData *cdata, page._alpha.clear(); return false; } - + if (!do_reconsider_video_properties(cdata, page._alpha, 4, z, options)) { page._color.clear(); page._alpha.clear(); @@ -474,12 +436,10 @@ do_read_one(Texture::CData *cdata, return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::do_load_one -// Access: Protected, Virtual -// Description: Resets the texture (or the particular level of the -// texture) to the indicated static image. -//////////////////////////////////////////////////////////////////// +/** + * Resets the texture (or the particular level of the texture) to the + * indicated static image. + */ bool OpenCVTexture:: do_load_one(Texture::CData *cdata, const PNMImage &pnmimage, const string &name, @@ -493,32 +453,26 @@ do_load_one(Texture::CData *cdata, return Texture::do_load_one(cdata, pnmimage, name, z, n, options); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::register_with_read_factory -// Access: Public, Static -// Description: Factory method to generate a Texture object -//////////////////////////////////////////////////////////////////// +/** + * Factory method to generate a Texture object + */ void OpenCVTexture:: register_with_read_factory() { // Since Texture is such a funny object that is reloaded from the - // TexturePool each time, instead of actually being read fully from - // the bam file, and since the VideoTexture and OpenCVTexture - // classes don't really add any useful data to the bam record, we - // don't need to define make_from_bam(), fillin(), or - // write_datagram() in this class--we just inherit the same - // functions from Texture. + // TexturePool each time, instead of actually being read fully from the bam + // file, and since the VideoTexture and OpenCVTexture classes don't really + // add any useful data to the bam record, we don't need to define + // make_from_bam(), fillin(), or write_datagram() in this class--we just + // inherit the same functions from Texture. - // We do, however, have to register this class with the BamReader, - // to avoid warnings about creating the wrong kind of object from - // the bam file. + // We do, however, have to register this class with the BamReader, to avoid + // warnings about creating the wrong kind of object from the bam file. BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenCVTexture::VideoStream:: VideoStream() : _capture(NULL), @@ -527,18 +481,16 @@ VideoStream() : { } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenCVTexture::VideoStream:: VideoStream(const OpenCVTexture::VideoStream ©) : _capture(NULL), _camera_index(-1) { - // Rather than copying the _capture pointer, we must open a new - // stream that references the same file. + // Rather than copying the _capture pointer, we must open a new stream that + // references the same file. if (copy.is_valid()) { if (copy.is_from_file()) { read(copy._filename); @@ -548,39 +500,29 @@ VideoStream(const OpenCVTexture::VideoStream ©) : } } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ OpenCVTexture::VideoStream:: ~VideoStream() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::get_frame_data -// Access: Public -// Description: Gets the data needed to traverse through the -// decompressed buffer for the indicated frame number. -// It is most efficient to call this in increasing order -// of frame number. Returns true on success, false on -// failure. -// -// In the case of a success indication (true return -// value), the three pointers r, g, b are loaded with -// the addresses of the three components of the -// bottom-left pixel of the image. (They will be -// adjacent in memory in the case of an interleaved -// image, and separated in the case of a -// separate-channel image.) The x_pitch value is filled -// with the amount to add to each pointer to advance to -// the pixel to the right; and the y_pitch value is -// filled with the amount to add to each pointer to -// advance to the pixel above. Note that these values -// may be negative (particularly in the case of a -// top-down image). -//////////////////////////////////////////////////////////////////// +/** + * Gets the data needed to traverse through the decompressed buffer for the + * indicated frame number. It is most efficient to call this in increasing + * order of frame number. Returns true on success, false on failure. + * + * In the case of a success indication (true return value), the three pointers + * r, g, b are loaded with the addresses of the three components of the + * bottom-left pixel of the image. (They will be adjacent in memory in the + * case of an interleaved image, and separated in the case of a separate- + * channel image.) The x_pitch value is filled with the amount to add to each + * pointer to advance to the pixel to the right; and the y_pitch value is + * filled with the amount to add to each pointer to advance to the pixel + * above. Note that these values may be negative (particularly in the case of + * a top-down image). + */ bool OpenCVTexture::VideoStream:: get_frame_data(int frame, const unsigned char *&r, @@ -606,18 +548,18 @@ get_frame_data(int frame, y_pitch = image->widthStep; if (image->dataOrder == 1) { - // Separate channel images. That means a block of r, followed by - // a block of g, followed by a block of b. + // Separate channel images. That means a block of r, followed by a block + // of g, followed by a block of b. x_pitch = 1; g = r + image->height * y_pitch; b = g + image->height * y_pitch; } if (image->origin == 0) { - // The image data starts with the top row and ends with the bottom - // row--the opposite of Texture::_ram_data's storage convention. - // Therefore, we must increment the initial pointers to the last - // row, and count backwards. + // The image data starts with the top row and ends with the bottom row-- + // the opposite of Texture::_ram_data's storage convention. Therefore, we + // must increment the initial pointers to the last row, and count + // backwards. r += (image->height - 1) * y_pitch; g += (image->height - 1) * y_pitch; b += (image->height - 1) * y_pitch; @@ -627,12 +569,10 @@ get_frame_data(int frame, return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::read -// Access: Public -// Description: Sets up the stream to read the indicated file. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the stream to read the indicated file. Returns true on success, + * false on failure. + */ bool OpenCVTexture::VideoStream:: read(const Filename &filename) { clear(); @@ -646,12 +586,10 @@ read(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::from_camera -// Access: Public -// Description: Sets up the stream to display the indicated camera. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the stream to display the indicated camera. Returns true on + * success, false on failure. + */ bool OpenCVTexture::VideoStream:: from_camera(int camera_index) { clear(); @@ -664,12 +602,9 @@ from_camera(int camera_index) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: OpenCVTexture::VideoStream::clear -// Access: Public -// Description: Stops the video playback and frees the associated -// resources. -//////////////////////////////////////////////////////////////////// +/** + * Stops the video playback and frees the associated resources. + */ void OpenCVTexture::VideoStream:: clear() { if (_capture != NULL) { @@ -682,4 +617,3 @@ clear() { } #endif // HAVE_OPENCV - diff --git a/panda/src/vision/openCVTexture.h b/panda/src/vision/openCVTexture.h index 9f67858c51..ad898e51a8 100644 --- a/panda/src/vision/openCVTexture.h +++ b/panda/src/vision/openCVTexture.h @@ -1,16 +1,15 @@ -// Filename: openCVTexture.h -// Created by: zacpavlov (19Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file openCVTexture.h + * @author zacpavlov + * @date 2005-08-19 + */ #ifndef OPENCVTEXTURE_H #define OPENCVTEXTURE_H @@ -20,13 +19,13 @@ #include "videoTexture.h" -// This symbol is predefined by the Panda3D build system to select -// whether we are using the OpenCV 2.3 or later interface, or if it is -// not defined, we are using the original interface. +// This symbol is predefined by the Panda3D build system to select whether we +// are using the OpenCV 2.3 or later interface, or if it is not defined, we +// are using the original interface. #ifdef OPENCV_VER_23 #include -//#include +// #include #include #else @@ -36,13 +35,11 @@ #endif // OPENCV_VER_23 -//////////////////////////////////////////////////////////////////// -// Class : OpenCVTexture -// Description : A specialization on VideoTexture that takes its input -// using the CV library, to produce an animated texture, -// with its source taken from an .avi file or from a -// camera input. -//////////////////////////////////////////////////////////////////// +/** + * A specialization on VideoTexture that takes its input using the CV library, + * to produce an animated texture, with its source taken from an .avi file or + * from a camera input. + */ class EXPCL_VISION OpenCVTexture : public VideoTexture { PUBLISHED: OpenCVTexture(const string &name = string()); @@ -61,7 +58,7 @@ public: protected: virtual void consider_update(); virtual PT(Texture) make_copy_impl(); - void do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, + void do_assign(Texture::CData *cdata_tex, const OpenCVTexture *copy, const Texture::CData *cdata_copy_tex); virtual void do_update_frame(Texture::CData *cdata_tex, int frame); @@ -76,14 +73,14 @@ protected: const PNMImage &pnmimage, const string &name, int z, int n, const LoaderOptions &options); -private: +private: class VideoPage; class VideoStream; VideoPage &do_modify_page(const Texture::CData *cdata, int z); - bool do_reconsider_video_properties(Texture::CData *cdata, - const VideoStream &stream, - int num_components, int z, + bool do_reconsider_video_properties(Texture::CData *cdata, + const VideoStream &stream, + int num_components, int z, const LoaderOptions &options); void do_update(); diff --git a/panda/src/vision/webcamVideo.I b/panda/src/vision/webcamVideo.I index 23242cff83..dcc0f473ca 100644 --- a/panda/src/vision/webcamVideo.I +++ b/panda/src/vision/webcamVideo.I @@ -1,67 +1,53 @@ -// Filename: webcamVideo.I -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideo.I + * @author jyelon + * @date 2007-11-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_size_x -// Access: Published -// Description: Returns the camera's size_x. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera's size_x. + */ INLINE int WebcamVideo:: get_size_x() const { return _size_x; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_size_y -// Access: Published -// Description: Returns the camera's size_y. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera's size_y. + */ INLINE int WebcamVideo:: get_size_y() const { return _size_y; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_fps -// Access: Published -// Description: Returns the camera's framerate. This -// is a maximum theoretical: the actual performance -// will depend on the speed of the hardware. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera's framerate. This is a maximum theoretical: the actual + * performance will depend on the speed of the hardware. + */ INLINE double WebcamVideo:: get_fps() const { return _fps; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_pixel_format -// Access: Published -// Description: Returns the camera's pixel format, as a FourCC code, -// if known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the camera's pixel format, as a FourCC code, if known. + */ INLINE const string &WebcamVideo:: get_pixel_format() const { return _pixel_format; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::output -// Access: Public -// Description: Outputs the WebcamVideo. This function simply -// writes the name, size and FPS to the output stream. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the WebcamVideo. This function simply writes the name, size and + * FPS to the output stream. + */ INLINE void WebcamVideo:: output(ostream &out) const { out << get_name() << ": " << get_size_x() << "x" << get_size_y(); @@ -77,4 +63,3 @@ INLINE ostream &operator << (ostream &out, const WebcamVideo &n) { n.output(out); return out; } - diff --git a/panda/src/vision/webcamVideo.cxx b/panda/src/vision/webcamVideo.cxx index 2e03b024da..f13587c39b 100644 --- a/panda/src/vision/webcamVideo.cxx +++ b/panda/src/vision/webcamVideo.cxx @@ -1,16 +1,15 @@ -// Filename: webcamVideo.cxx -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideo.cxx + * @author jyelon + * @date 2007-11-01 + */ #include "webcamVideo.h" #include "pandabase.h" @@ -20,30 +19,23 @@ pvector WebcamVideo::_all_webcams; TypeHandle WebcamVideo::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideo:: ~WebcamVideo() { } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::find_all_webcams -// Access: Public -// Description: Scans the hardware for webcams, and pushes them -// onto the global list of all webcams. -// -// There are several implementations of WebcamVideo, -// including one based on DirectShow, one based on -// Video4Linux, and so forth. These implementations -// are contained in one C++ file each, and they export -// nothing at all except a single "find_all" function. -// Otherwise, they can only be accessed through the -// virtual methods of the WebcamVideo objects they -// create. -//////////////////////////////////////////////////////////////////// +/** + * Scans the hardware for webcams, and pushes them onto the global list of all + * webcams. + * + * There are several implementations of WebcamVideo, including one based on + * DirectShow, one based on Video4Linux, and so forth. These implementations + * are contained in one C++ file each, and they export nothing at all except a + * single "find_all" function. Otherwise, they can only be accessed through + * the virtual methods of the WebcamVideo objects they create. + */ void WebcamVideo:: find_all_webcams() { static bool initialized = false; @@ -66,25 +58,20 @@ find_all_webcams() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_num_options -// Access: Public, Static -// Description: Returns the number of webcam options. An "option" -// consists of a device plus a set of configuration -// parameters. For example, "Creative Webcam Live at -// 640x480, 30 fps" is an option. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of webcam options. An "option" consists of a device + * plus a set of configuration parameters. For example, "Creative Webcam Live + * at 640x480, 30 fps" is an option. + */ int WebcamVideo:: get_num_options() { find_all_webcams(); return _all_webcams.size(); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideo::get_option -// Access: Public, Static -// Description: Returns the nth webcam option. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth webcam option. + */ PT(WebcamVideo) WebcamVideo:: get_option(int n) { find_all_webcams(); diff --git a/panda/src/vision/webcamVideo.h b/panda/src/vision/webcamVideo.h index bcaafc92b4..a1a74d3562 100644 --- a/panda/src/vision/webcamVideo.h +++ b/panda/src/vision/webcamVideo.h @@ -1,27 +1,25 @@ -// Filename: webcamVideo.h -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideo.h + * @author jyelon + * @date 2007-11-01 + */ #ifndef WEBCAMVIDEO_H #define WEBCAMVIDEO_H #include "movieVideo.h" -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideo -// Description : Allows you to open a webcam or other video capture -// device as a video stream. -//////////////////////////////////////////////////////////////////// +/** + * Allows you to open a webcam or other video capture device as a video + * stream. + */ class EXPCL_VISION WebcamVideo : public MovieVideo { PUBLISHED: diff --git a/panda/src/vision/webcamVideoCursorOpenCV.cxx b/panda/src/vision/webcamVideoCursorOpenCV.cxx index 826cf16fdd..814ad9d5bb 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.cxx +++ b/panda/src/vision/webcamVideoCursorOpenCV.cxx @@ -1,16 +1,15 @@ -// Filename: webcamVideoCursorOpenCV.cxx -// Created by: drose (20Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoCursorOpenCV.cxx + * @author drose + * @date 2010-10-20 + */ #include "webcamVideoOpenCV.h" @@ -20,11 +19,9 @@ TypeHandle WebcamVideoCursorOpenCV::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorOpenCV::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorOpenCV:: WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { _size_x = src->_size_x; @@ -45,11 +42,9 @@ WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src) : MovieVideoCursor(src) { } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorOpenCV::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorOpenCV:: ~WebcamVideoCursorOpenCV() { if (_capture != NULL) { @@ -58,11 +53,9 @@ WebcamVideoCursorOpenCV:: } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorOpenCV::fetch_buffer -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(MovieVideoCursor::Buffer) WebcamVideoCursorOpenCV:: fetch_buffer() { if (!_ready) { @@ -83,7 +76,7 @@ fetch_buffer() { // The easy case--copy the whole thing in, row by row. int copy_bytes = _size_x * dest_x_pitch; nassertr(copy_bytes <= dest_y_pitch && copy_bytes <= abs(y_pitch), NULL); - + for (int y = 0; y < _size_y; ++y) { memcpy(dest, r, copy_bytes); dest += dest_y_pitch; @@ -91,9 +84,8 @@ fetch_buffer() { } } else { - // The harder case--interleave in the color channels, pixel by - // pixel. - + // The harder case--interleave in the color channels, pixel by pixel. + for (int y = 0; y < _size_y; ++y) { int dx = 0; int sx = 0; @@ -115,27 +107,20 @@ fetch_buffer() { return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorOpenCV::get_frame_data -// Access: Private -// Description: Gets the data needed to traverse through the -// decompressed buffer. Returns true on success, false -// on failure. -// -// In the case of a success indication (true return -// value), the three pointers r, g, b are loaded with -// the addresses of the three components of the -// bottom-left pixel of the image. (They will be -// adjacent in memory in the case of an interleaved -// image, and separated in the case of a -// separate-channel image.) The x_pitch value is filled -// with the amount to add to each pointer to advance to -// the pixel to the right; and the y_pitch value is -// filled with the amount to add to each pointer to -// advance to the pixel above. Note that these values -// may be negative (particularly in the case of a -// top-down image). -//////////////////////////////////////////////////////////////////// +/** + * Gets the data needed to traverse through the decompressed buffer. Returns + * true on success, false on failure. + * + * In the case of a success indication (true return value), the three pointers + * r, g, b are loaded with the addresses of the three components of the + * bottom-left pixel of the image. (They will be adjacent in memory in the + * case of an interleaved image, and separated in the case of a separate- + * channel image.) The x_pitch value is filled with the amount to add to each + * pointer to advance to the pixel to the right; and the y_pitch value is + * filled with the amount to add to each pointer to advance to the pixel + * above. Note that these values may be negative (particularly in the case of + * a top-down image). + */ bool WebcamVideoCursorOpenCV:: get_frame_data(const unsigned char *&r, const unsigned char *&g, @@ -155,18 +140,18 @@ get_frame_data(const unsigned char *&r, y_pitch = image->widthStep; if (image->dataOrder == 1) { - // Separate channel images. That means a block of r, followed by - // a block of g, followed by a block of b. + // Separate channel images. That means a block of r, followed by a block + // of g, followed by a block of b. x_pitch = 1; g = r + image->height * y_pitch; b = g + image->height * y_pitch; } if (image->origin == 0) { - // The image data starts with the top row and ends with the bottom - // row--the opposite of Texture::_ram_data's storage convention. - // Therefore, we must increment the initial pointers to the last - // row, and count backwards. + // The image data starts with the top row and ends with the bottom row-- + // the opposite of Texture::_ram_data's storage convention. Therefore, we + // must increment the initial pointers to the last row, and count + // backwards. r += (image->height - 1) * y_pitch; g += (image->height - 1) * y_pitch; b += (image->height - 1) * y_pitch; diff --git a/panda/src/vision/webcamVideoCursorOpenCV.h b/panda/src/vision/webcamVideoCursorOpenCV.h index ba793036b2..6f7e0758f6 100644 --- a/panda/src/vision/webcamVideoCursorOpenCV.h +++ b/panda/src/vision/webcamVideoCursorOpenCV.h @@ -1,16 +1,15 @@ -// Filename: webcamVideoCursorOpenCV.h -// Created by: drose (20Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoCursorOpenCV.h + * @author drose + * @date 2010-10-20 + */ #ifndef WEBCAMVIDEOCURSOROPENCV_H #define WEBCAMVIDEOCURSOROPENCV_H @@ -24,10 +23,9 @@ class WebcamVideoOpenCV; -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoCursorOpenCV -// Description : The Video4Linux implementation of webcams. -//////////////////////////////////////////////////////////////////// +/** + * The Video4Linux implementation of webcams. + */ class WebcamVideoCursorOpenCV : public MovieVideoCursor { public: WebcamVideoCursorOpenCV(WebcamVideoOpenCV *src); diff --git a/panda/src/vision/webcamVideoCursorV4L.cxx b/panda/src/vision/webcamVideoCursorV4L.cxx index 2000bf3136..c12568882d 100644 --- a/panda/src/vision/webcamVideoCursorV4L.cxx +++ b/panda/src/vision/webcamVideoCursorV4L.cxx @@ -1,16 +1,15 @@ -// Filename: webcamVideoCursorV4L.cxx -// Created by: rdb (11Jun2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoCursorV4L.cxx + * @author rdb + * @date 2010-06-11 + */ #include "webcamVideoV4L.h" @@ -192,11 +191,9 @@ static JHUFF_TBL ac_chrominance_tbl = { #endif -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorV4L::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorV4L:: WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _size_x = src->_size_x; @@ -218,8 +215,8 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { return; } - // Find the best format in our _pformats vector. - // MJPEG is preferred over YUYV, as it's much smaller. + // Find the best format in our _pformats vector. MJPEG is preferred over + // YUYV, as it's much smaller. _format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; _format.fmt.pix.pixelformat = src->_pformat; @@ -354,11 +351,9 @@ WebcamVideoCursorV4L(WebcamVideoV4L *src) : MovieVideoCursor(src) { _ready = true; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorV4L::Destructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorV4L:: ~WebcamVideoCursorV4L() { #ifdef HAVE_JPEG @@ -382,11 +377,9 @@ WebcamVideoCursorV4L:: } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorV4L::fetch_buffer -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(MovieVideoCursor::Buffer) WebcamVideoCursorV4L:: fetch_buffer() { if (!_ready) { @@ -467,7 +460,7 @@ fetch_buffer() { } free(newbuf); - // Swap red / blue + // Swap red blue unsigned char ex; for (size_t i = 0; i < new_bpl * _size_y; i += 3) { ex = block[i]; diff --git a/panda/src/vision/webcamVideoCursorV4L.h b/panda/src/vision/webcamVideoCursorV4L.h index 2dd22ee452..7eb7b02763 100644 --- a/panda/src/vision/webcamVideoCursorV4L.h +++ b/panda/src/vision/webcamVideoCursorV4L.h @@ -1,16 +1,15 @@ -// Filename: webcamVideoCursorV4L.h -// Created by: rdb (11Jun2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoCursorV4L.h + * @author rdb + * @date 2010-06-11 + */ #ifndef WEBCAMVIDEOCURSORV4L_H #define WEBCAMVIDEOCURSORV4L_H @@ -32,10 +31,9 @@ extern "C" { class WebcamVideoV4L; -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoCursorV4L -// Description : The Video4Linux implementation of webcams. -//////////////////////////////////////////////////////////////////// +/** + * The Video4Linux implementation of webcams. + */ class WebcamVideoCursorV4L : public MovieVideoCursor { public: WebcamVideoCursorV4L(WebcamVideoV4L *src); diff --git a/panda/src/vision/webcamVideoDS.cxx b/panda/src/vision/webcamVideoDS.cxx index bdbdc8d798..0996070b45 100644 --- a/panda/src/vision/webcamVideoDS.cxx +++ b/panda/src/vision/webcamVideoDS.cxx @@ -1,33 +1,28 @@ -// Filename: webcamVideoDS.cxx -// Created by: jyelon (01Nov2007) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// It goes against Panda3D coding style conventions to hide an -// entire class in a C++ file and not expose it through header -// files at all. However, in this case, these classes are so full -// of OS-specific junk that I feel it is better to hide them -// entirely. - Josh -// -//////////////////////////////////////////////////////////////////// -// -// This code was created by studying and adapting the VDOGRAB -// library by Shu-Kai Yang and the videoInput library by Theodore -// Watson. We owe both of them a great deal of thanks for -// figuring all this out. Both of their libraries have -// informal licenses (the "do whatever you want and don't blame -// me" sort), so I think there's not a problem using their code. -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoDS.cxx + * @author jyelon + * @date 2007-11-01 + * + * It goes against Panda3D coding style conventions to hide an + * entire class in a C++ file and not expose it through header + * files at all. However, in this case, these classes are so full + * of OS-specific junk that I feel it is better to hide them + * entirely. - Josh + * + * This code was created by studying and adapting the VDOGRAB + * library by Shu-Kai Yang and the videoInput library by Theodore + * Watson. We owe both of them a great deal of thanks for + * figuring all this out. Both of their libraries have + * informal licenses (the "do whatever you want and don't blame + * me" sort), so I think there's not a problem using their code. + */ #if defined(HAVE_DIRECTCAM) && !defined(CPPPARSER) @@ -63,33 +58,31 @@ #include #include -// This used to work back when qedit.h still existed. The hacks -// served to prevent it from including the defunct dxtrans.h. -//#pragma include_alias( "dxtrans.h", "qedit.h" ) -//#define __IDxtCompositor_INTERFACE_DEFINED__ -//#define __IDxtAlphaSetter_INTERFACE_DEFINED__ -//#define __IDxtJpeg_INTERFACE_DEFINED_ -//#define __IDxtKey_INTERFACE_DEFINED__ -//#define IDXEffect IUnknown -//#include +/* + * This used to work back when qedit.h still existed. The hacks served to + * prevent it from including the defunct dxtrans.h. #pragma include_alias( + * "dxtrans.h", "qedit.h" ) #define __IDxtCompositor_INTERFACE_DEFINED__ + * #define __IDxtAlphaSetter_INTERFACE_DEFINED__ #define + * __IDxtJpeg_INTERFACE_DEFINED_ #define __IDxtKey_INTERFACE_DEFINED__ #define + * IDXEffect IUnknown #include + */ -// We can use this fugly hack to still access the qedit.h interfaces. -// When this stops working, we'll have to just copy the relevant -// definitions to this file. +// We can use this fugly hack to still access the qedit.h interfaces. When +// this stops working, we'll have to just copy the relevant definitions to +// this file. #import "libid:78530B68-61F9-11D2-8CAD-00A024580902" \ no_namespace named_guids raw_interfaces_only no_implementation \ exclude("_AMMediaType", "_FilterState", "IReferenceClock", "IMediaFilter", \ - "_PinDirection", "IEnumMediaTypes", "IFilterGraph", "_FilterInfo", \ - "IGraphBuilder", "IBaseFilter", "_PinInfo", "IPin", "IEnumPins", \ - "IEnumFilters", "IEnumMediaTypes", "IAMSetErrorLog","IAMTimelineObj", \ - "IMediaDet", "IMediaSample", "IPersistStream", "IPersist", "IStream", \ - "ISequentialStream", "_LARGE_INTEGER", "_ULARGE_INTEGER", \ - "tagSTATSTG", "_FILETIME", "IPropertyBag", "IErrorLog") + "_PinDirection", "IEnumMediaTypes", "IFilterGraph", "_FilterInfo", \ + "IGraphBuilder", "IBaseFilter", "_PinInfo", "IPin", "IEnumPins", \ + "IEnumFilters", "IEnumMediaTypes", "IAMSetErrorLog","IAMTimelineObj", \ + "IMediaDet", "IMediaSample", "IPersistStream", "IPersist", "IStream", \ + "ISequentialStream", "_LARGE_INTEGER", "_ULARGE_INTEGER", \ + "tagSTATSTG", "_FILETIME", "IPropertyBag", "IErrorLog") -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoDS -// Description : The directshow implementation of webcams. -//////////////////////////////////////////////////////////////////// +/** + * The directshow implementation of webcams. + */ class WebcamVideoDS : public WebcamVideo { @@ -136,10 +129,9 @@ private: TypeHandle WebcamVideoDS::_type_handle; -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoCursorDS -// Description : The directshow implementation of webcams. -//////////////////////////////////////////////////////////////////// +/** + * The directshow implementation of webcams. + */ class WebcamVideoCursorDS : public MovieVideoCursor @@ -175,7 +167,7 @@ public: ISampleGrabber *_pSampleGrabber; IBaseFilter *_pStreamRenderer; IMediaControl *_pMediaCtrl; - // IMemAllocator *_pAllocator; + // IMemAllocator *_pAllocator; CSampleGrabberCB _sample_cb; public: @@ -198,12 +190,10 @@ private: TypeHandle WebcamVideoCursorDS::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::media_score -// Access: Public, Static -// Description: Evaluate an AM_MEDIA_TYPE to determine how -// desirable it is for our purposes. Lower is better. -//////////////////////////////////////////////////////////////////// +/** + * Evaluate an AM_MEDIA_TYPE to determine how desirable it is for our + * purposes. Lower is better. + */ int WebcamVideoDS:: media_score(AM_MEDIA_TYPE *media) { const GUID &subtype = media->subtype; @@ -214,44 +204,36 @@ media_score(AM_MEDIA_TYPE *media) { return 4; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::media_x -// Access: Public, Static -// Description: Returns the x-resolution of the AM_MEDIA_TYPE -//////////////////////////////////////////////////////////////////// +/** + * Returns the x-resolution of the AM_MEDIA_TYPE + */ int WebcamVideoDS:: media_x(AM_MEDIA_TYPE *media) { VIDEOINFOHEADER *header = (VIDEOINFOHEADER*)(media->pbFormat); return (header->bmiHeader.biWidth); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::media_y -// Access: Public, Static -// Description: Returns the y-resolution of the AM_MEDIA_TYPE -//////////////////////////////////////////////////////////////////// +/** + * Returns the y-resolution of the AM_MEDIA_TYPE + */ int WebcamVideoDS:: media_y(AM_MEDIA_TYPE *media) { VIDEOINFOHEADER *header = (VIDEOINFOHEADER*)(media->pbFormat); return (header->bmiHeader.biHeight); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::media_fps -// Access: Public, Static -// Description: Returns the frame-rate of the AM_MEDIA_TYPE -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame-rate of the AM_MEDIA_TYPE + */ int WebcamVideoDS:: media_fps(AM_MEDIA_TYPE *media) { VIDEOINFOHEADER *header = (VIDEOINFOHEADER*)(media->pbFormat); return int(10000000.0 / (header->AvgTimePerFrame)); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::delete_media_type -// Access: Public, Static -// Description: Free all memory of the AM_MEDIA_TYPE -//////////////////////////////////////////////////////////////////// +/** + * Free all memory of the AM_MEDIA_TYPE + */ void WebcamVideoDS:: delete_media_type(AM_MEDIA_TYPE *pmt) { if (pmt == NULL) { @@ -270,11 +252,9 @@ delete_media_type(AM_MEDIA_TYPE *pmt) { CoTaskMemFree(pmt); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::bstr_to_string -// Access: Public, Static -// Description: Converts a visual basic BSTR to a C++ string. -//////////////////////////////////////////////////////////////////// +/** + * Converts a visual basic BSTR to a C++ string. + */ string WebcamVideoDS:: bstr_to_string(const BSTR &source) { string res = ""; @@ -286,11 +266,9 @@ bstr_to_string(const BSTR &source) { return res; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::get_moniker_name -// Access: Public, Static -// Description: Obtains the text name associated with an IMoniker -//////////////////////////////////////////////////////////////////// +/** + * Obtains the text name associated with an IMoniker + */ string WebcamVideoDS:: get_moniker_name(IMoniker *pMoniker) { string res = "Unknown Device"; @@ -314,15 +292,12 @@ get_moniker_name(IMoniker *pMoniker) { return res; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::add_device -// Access: Public, Static -// Description: Creates a new WebcamVideoDS and adds it to the list, -// unless there is already a very similar configuration -// in the list. If there is already a very similar -// configuration, this routine will leave one or the -// other on the list based on a scoring system. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new WebcamVideoDS and adds it to the list, unless there is + * already a very similar configuration in the list. If there is already a + * very similar configuration, this routine will leave one or the other on the + * list based on a scoring system. + */ void WebcamVideoDS:: add_device(WebcamVideoList &list, IMoniker *pMoniker, AM_MEDIA_TYPE *media) { for (int i=0; i<(int)list.size(); i++) { @@ -351,12 +326,9 @@ add_device(WebcamVideoList &list, IMoniker *pMoniker, AM_MEDIA_TYPE *media) { } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::find_all_webcams_ds -// Access: Public, Static -// Description: Finds all DirectShow webcams and adds them to -// the global list _all_webcams. -//////////////////////////////////////////////////////////////////// +/** + * Finds all DirectShow webcams and adds them to the global list _all_webcams. + */ void WebcamVideoDS:: find_all_webcams_ds() { @@ -439,21 +411,17 @@ void find_all_webcams_ds() { WebcamVideoDS::find_all_webcams_ds(); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoDS::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieVideoCursor) WebcamVideoDS:: open() { return new WebcamVideoCursorDS(this); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::Constructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorDS:: WebcamVideoCursorDS(WebcamVideoDS *src) : MovieVideoCursor(src), @@ -517,8 +485,8 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } - //hResult = CoCreateInstance(CLSID_SampleGrabber,) - //CComQIPtr< IBaseFilter, &IID_IBaseFilter > pGrabberFilter(_pSampleGrabber); + // hResult = CoCreateInstance(CLSID_SampleGrabber,) CComQIPtr< IBaseFilter, + // &IID_IBaseFilter > pGrabberFilter(_pSampleGrabber); IBaseFilter *pGrabberFilter = NULL; hResult = _pSampleGrabber->QueryInterface(IID_PPV_ARGS(&pGrabberFilter)); cerr << " IID_IBaseFilter of CLSID_SampleGrabber is acquired.\n"; @@ -538,7 +506,7 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } cerr << " The sample grabber has been added to the graph.\n"; - //used to give the video stream somewhere to go to. + // used to give the video stream somewhere to go to. hResult = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&_pStreamRenderer); if(hResult != S_OK) { cerr << " Can not create the null renderer."; @@ -564,33 +532,21 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : cleanup(); return; } - // IPin *iPin; - // hResult = FindInputPin(pGrabberFilter, &iPin); - // if ((iPin == 0)||(hResult != S_OK)) { - // cerr << "Could not get sampler input pin.\n"; - // cleanup(); return; - // } - // CComQIPtr< IMemInputPin, &IID_IMemInputPin > pMemInputPin(iPin); - // if (pMemInputPin == 0) { - // cerr << "Could not get sampler meminput pin.\n"; - // cleanup(); return; - // } - // hResult = pMemInputPin->GetAllocator(&_pAllocator); - // if (hResult != S_OK) { - // cerr << "Could not get sample grabber allocator handle.\n"; - // } - // ALLOCATOR_PROPERTIES props, aprops; - // hResult = _pAllocator->GetProperties(&props); - // if (hResult != S_OK) { - // cerr << "Could not get allocator properties.\n"; - // } - // cerr << "Allocator properties: cBuffers=" << props.cBuffers << "\n"; - // props.cBuffers += 10; - // hResult = _pAllocator->SetProperties(&props, &aprops); - // if (hResult != S_OK) { - // cerr << "Could not set allocator properties.\n"; - // } - // cerr << "Allocator properties (adjusted): cBuffers=" << aprops.cBuffers << "\n"; +/* + * IPin *iPin; hResult = FindInputPin(pGrabberFilter, &iPin); if ((iPin == + * 0)||(hResult != S_OK)) { cerr << "Could not get sampler input pin.\n"; + * cleanup(); return; } CComQIPtr< IMemInputPin, &IID_IMemInputPin > + * pMemInputPin(iPin); if (pMemInputPin == 0) { cerr << "Could not get sampler + * meminput pin.\n"; cleanup(); return; } hResult = + * pMemInputPin->GetAllocator(&_pAllocator); if (hResult != S_OK) { cerr << + * "Could not get sample grabber allocator handle.\n"; } ALLOCATOR_PROPERTIES + * props, aprops; hResult = _pAllocator->GetProperties(&props); if (hResult != + * S_OK) { cerr << "Could not get allocator properties.\n"; } cerr << + * "Allocator properties: cBuffers=" << props.cBuffers << "\n"; props.cBuffers + * += 10; hResult = _pAllocator->SetProperties(&props, &aprops); if (hResult + * != S_OK) { cerr << "Could not set allocator properties.\n"; } cerr << + * "Allocator properties (adjusted): cBuffers=" << aprops.cBuffers << "\n"; + */ pVideoInfo=(VIDEOINFOHEADER*)mediaType.pbFormat; _size_x = pVideoInfo->bmiHeader.biWidth; @@ -619,8 +575,8 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : } if(pGrabberFilter != NULL) { - pGrabberFilter->Release(); - pGrabberFilter=NULL; + pGrabberFilter->Release(); + pGrabberFilter=NULL; } _pSampleGrabber->SetBufferSamples(FALSE); @@ -635,11 +591,9 @@ WebcamVideoCursorDS(WebcamVideoDS *src) : _pMediaCtrl->Run(); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::cleanup -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WebcamVideoCursorDS:: cleanup() { if (_buffer) { @@ -660,21 +614,17 @@ cleanup() { if(_pStreamConfig) { _pStreamConfig->Release(); _pStreamConfig=NULL; } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoCursorDS:: ~WebcamVideoCursorDS() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::fetch_buffer -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(MovieVideoCursor::Buffer) WebcamVideoCursorDS:: fetch_buffer() { if (!_ready) { @@ -704,11 +654,9 @@ fetch_buffer() { } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::CSampleGrabberCB::QueryInterface -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HRESULT __stdcall WebcamVideoCursorDS::CSampleGrabberCB::QueryInterface(REFIID riid, void **ppv) { if((riid == IID_ISampleGrabberCB) || (riid == IID_IUnknown)) { @@ -719,11 +667,9 @@ HRESULT __stdcall WebcamVideoCursorDS::CSampleGrabberCB::QueryInterface(REFIID r } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::CSampleGrabberCB::SampleCB -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HRESULT __stdcall WebcamVideoCursorDS::CSampleGrabberCB::SampleCB(double SampleTime, IMediaSample *pSample) { if (_host->_ready) { @@ -749,47 +695,25 @@ HRESULT __stdcall WebcamVideoCursorDS::CSampleGrabberCB::SampleCB(double SampleT return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoCursorDS::CSampleGrabberCB::BufferCB -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ HRESULT __stdcall WebcamVideoCursorDS::CSampleGrabberCB::BufferCB(double dblSampleTime, BYTE *pBuffer, long lBufferSize) { // Not used. return 0; } -//HRESULT FindInputPin(IBaseFilter *pFilter, IPin **ppPin) -//{ -// if (!pFilter || ! ppPin) -// return E_POINTER; -// -// *ppPin = 0; -// HRESULT hr; -// //Find the output pin of the Source Filter -// IEnumPins *pPinEnum; -// hr = pFilter->EnumPins(&pPinEnum); -// if (FAILED(hr)) -// return E_FAIL; -// -// IPin *pSearchPin; -// while (pPinEnum->Next(1, &pSearchPin, NULL) == S_OK) -// { -// PIN_DIRECTION pPinDir; -// hr = pSearchPin->QueryDirection(&pPinDir); -// if (FAILED(hr)) -// return E_FAIL; -// if (pPinDir == PINDIR_INPUT) -// { -// //Found out pin -// *ppPin = pSearchPin; -// break; -// } -// } -// pPinEnum->Release(); -// return hr; -//} +/* + * HRESULT FindInputPin(IBaseFilter *pFilter, IPin **ppPin) { if (!pFilter || + * ! ppPin) return E_POINTER; *ppPin = 0; HRESULT hr; Find the output pin of + * the Source Filter IEnumPins *pPinEnum; hr = pFilter->EnumPins(&pPinEnum); + * if (FAILED(hr)) return E_FAIL; IPin *pSearchPin; while (pPinEnum->Next(1, + * &pSearchPin, NULL) == S_OK) { PIN_DIRECTION pPinDir; hr = + * pSearchPin->QueryDirection(&pPinDir); if (FAILED(hr)) return E_FAIL; if + * (pPinDir == PINDIR_INPUT) { Found out pin *ppPin = pSearchPin; break; } } + * pPinEnum->Release(); return hr; } + */ #endif // HAVE_DIRECTSHOW diff --git a/panda/src/vision/webcamVideoOpenCV.cxx b/panda/src/vision/webcamVideoOpenCV.cxx index ae1dfc3f03..92a22dc4a5 100644 --- a/panda/src/vision/webcamVideoOpenCV.cxx +++ b/panda/src/vision/webcamVideoOpenCV.cxx @@ -1,16 +1,15 @@ -// Filename: webcamVideoOpenCV.cxx -// Created by: drose (20Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoOpenCV.cxx + * @author drose + * @date 2010-10-20 + */ #include "webcamVideoOpenCV.h" @@ -21,16 +20,13 @@ TypeHandle WebcamVideoOpenCV::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: find_all_webcams_opencv -// Access: Public, Static -// Description: Finds all OpenCV webcams and adds them to the global -// list _all_webcams. -//////////////////////////////////////////////////////////////////// +/** + * Finds all OpenCV webcams and adds them to the global list _all_webcams. + */ void find_all_webcams_opencv() { - // OpenCV doesn't really provide a way to enumerate cameras. We ask - // the user to do this via a config variable. + // OpenCV doesn't really provide a way to enumerate cameras. We ask the + // user to do this via a config variable. static ConfigVariableInt wemcam_opencv_camera_index ("webcam-opencv-camera-index", "0", PRC_DESC("Specify the space-separated list of integer camera index " @@ -43,25 +39,21 @@ find_all_webcams_opencv() { } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoOpenCV::Constructor -// Access: Published, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WebcamVideoOpenCV:: -WebcamVideoOpenCV(int camera_index) : - _camera_index(camera_index) +WebcamVideoOpenCV(int camera_index) : + _camera_index(camera_index) { ostringstream strm; strm << "OpenCV webcam " << _camera_index; set_name(strm.str()); } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoOpenCV::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieVideoCursor) WebcamVideoOpenCV:: open() { return new WebcamVideoCursorOpenCV(this); diff --git a/panda/src/vision/webcamVideoOpenCV.h b/panda/src/vision/webcamVideoOpenCV.h index d22b6f9cb2..211c0f80f7 100644 --- a/panda/src/vision/webcamVideoOpenCV.h +++ b/panda/src/vision/webcamVideoOpenCV.h @@ -1,16 +1,15 @@ -// Filename: webcamVideoOpenCV.h -// Created by: drose (20Oct10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoOpenCV.h + * @author drose + * @date 2010-10-20 + */ #ifndef WEBCAMVIDEOOPENCV_H #define WEBCAMVIDEOOPENCV_H @@ -23,13 +22,11 @@ class WebcamVideoCursorOpenCV; -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoOpenCV -// Description : The OpenCV implementation of webcams. Probably won't -// be needed once we have a native webcam implementation -// for each Panda3D-supported platform. (So far, we're -// 2 for 3.) -//////////////////////////////////////////////////////////////////// +/** + * The OpenCV implementation of webcams. Probably won't be needed once we + * have a native webcam implementation for each Panda3D-supported platform. + * (So far, we're 2 for 3.) + */ class WebcamVideoOpenCV : public WebcamVideo { private: WebcamVideoOpenCV(int camera_index); diff --git a/panda/src/vision/webcamVideoV4L.cxx b/panda/src/vision/webcamVideoV4L.cxx index 0c86640ea1..a71f0c9d96 100644 --- a/panda/src/vision/webcamVideoV4L.cxx +++ b/panda/src/vision/webcamVideoV4L.cxx @@ -1,16 +1,15 @@ -// Filename: webcamVideoV4L.cxx -// Created by: rdb (11Jun2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoV4L.cxx + * @author rdb + * @date 2010-06-11 + */ #include "webcamVideoV4L.h" @@ -25,11 +24,9 @@ TypeHandle WebcamVideoV4L::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: add_options_for_size -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WebcamVideoV4L:: add_options_for_size(int fd, const string &dev, const char *name, unsigned width, unsigned height, unsigned pixelformat) { struct v4l2_frmivalenum frmivalenum; @@ -75,12 +72,10 @@ add_options_for_size(int fd, const string &dev, const char *name, unsigned width } } -//////////////////////////////////////////////////////////////////// -// Function: find_all_webcams_v4l -// Access: Public, Static -// Description: Finds all Video4Linux webcams and adds them to -// the global list _all_webcams. -//////////////////////////////////////////////////////////////////// +/** + * Finds all Video4Linux webcams and adds them to the global list + * _all_webcams. + */ void find_all_webcams_v4l() { struct v4l2_capability cap2; @@ -140,8 +135,8 @@ void find_all_webcams_v4l() { case V4L2_FRMSIZE_TYPE_CONTINUOUS: { - // Okay, er, we don't have a proper handling of this, - // so let's add all powers of two in this range. + // Okay, er, we don't have a proper handling of this, so + // let's add all powers of two in this range. __u32 width = Texture::up_to_power_2(frmsizeenum.stepwise.min_width); for (; width <= frmsizeenum.stepwise.max_width; width *= 2) { @@ -180,11 +175,9 @@ void find_all_webcams_v4l() { } } -//////////////////////////////////////////////////////////////////// -// Function: WebcamVideoV4L::open -// Access: Published, Virtual -// Description: Open this video, returning a MovieVideoCursor. -//////////////////////////////////////////////////////////////////// +/** + * Open this video, returning a MovieVideoCursor. + */ PT(MovieVideoCursor) WebcamVideoV4L:: open() { return new WebcamVideoCursorV4L(this); diff --git a/panda/src/vision/webcamVideoV4L.h b/panda/src/vision/webcamVideoV4L.h index 38b6cf4f34..374daf6f76 100644 --- a/panda/src/vision/webcamVideoV4L.h +++ b/panda/src/vision/webcamVideoV4L.h @@ -1,16 +1,15 @@ -// Filename: webcamVideoV4L.h -// Created by: rdb (11Jun2010) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file webcamVideoV4L.h + * @author rdb + * @date 2010-06-11 + */ #ifndef WEBCAMVIDEOV4L_H #define WEBCAMVIDEOV4L_H @@ -23,10 +22,9 @@ class WebcamVideoCursorV4L; -//////////////////////////////////////////////////////////////////// -// Class : WebcamVideoV4L -// Description : The Video4Linux implementation of webcams. -//////////////////////////////////////////////////////////////////// +/** + * The Video4Linux implementation of webcams. + */ class WebcamVideoV4L : public WebcamVideo { private: virtual PT(MovieVideoCursor) open(); diff --git a/panda/src/vrpn/config_vrpn.cxx b/panda/src/vrpn/config_vrpn.cxx index 2228e40d83..77d2b198ee 100644 --- a/panda/src/vrpn/config_vrpn.cxx +++ b/panda/src/vrpn/config_vrpn.cxx @@ -1,16 +1,15 @@ -// Filename: config_vrpn.cxx -// Created by: jason (07Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_vrpn.cxx + * @author jason + * @date 2000-08-07 + */ #include "config_vrpn.h" #include "vrpnAnalogDevice.h" diff --git a/panda/src/vrpn/config_vrpn.h b/panda/src/vrpn/config_vrpn.h index 05c7dc0810..570ebd6d97 100644 --- a/panda/src/vrpn/config_vrpn.h +++ b/panda/src/vrpn/config_vrpn.h @@ -1,16 +1,15 @@ -// Filename: config_vrpn.h -// Created by: jason (07Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_vrpn.h + * @author jason + * @date 2000-08-07 + */ #ifndef CONFIG_VRPN_H #define CONFIG_VRPN_H diff --git a/panda/src/vrpn/vrpnAnalog.I b/panda/src/vrpn/vrpnAnalog.I index 26d1c756e6..61efae3f51 100644 --- a/panda/src/vrpn/vrpnAnalog.I +++ b/panda/src/vrpn/vrpnAnalog.I @@ -1,46 +1,38 @@ -// Filename: vrpnAnalog.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalog.I + * @author drose + * @date 2001-01-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::get_analog_name -// Access: Public -// Description: Returns the name of the analog device that was used -// to create this VrpnAnalog. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the analog device that was used to create this + * VrpnAnalog. + */ INLINE const string &VrpnAnalog:: get_analog_name() const { return _analog_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::is_empty -// Access: Public -// Description: Returns true if no VrpnAnalogDevices reference this -// VrpnAnalog, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no VrpnAnalogDevices reference this VrpnAnalog, or false + * otherwise. + */ INLINE bool VrpnAnalog:: is_empty() const { return _devices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::poll -// Access: Public -// Description: Polls the connected device. Normally you should not -// call this directly; this will be called by the -// VrpnClient. -//////////////////////////////////////////////////////////////////// +/** + * Polls the connected device. Normally you should not call this directly; + * this will be called by the VrpnClient. + */ INLINE void VrpnAnalog:: poll() { _analog->mainloop(); diff --git a/panda/src/vrpn/vrpnAnalog.cxx b/panda/src/vrpn/vrpnAnalog.cxx index 40e55796a4..0934f7a8d8 100644 --- a/panda/src/vrpn/vrpnAnalog.cxx +++ b/panda/src/vrpn/vrpnAnalog.cxx @@ -1,16 +1,15 @@ -// Filename: vrpnAnalog.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalog.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnAnalog.h" #include "vrpnAnalogDevice.h" @@ -21,11 +20,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnAnalog:: VrpnAnalog(const string &analog_name, vrpn_Connection *connection) : _analog_name(analog_name) @@ -35,22 +32,18 @@ VrpnAnalog(const string &analog_name, vrpn_Connection *connection) : _analog->register_change_handler((void*)this, &vrpn_analog_callback); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnAnalog:: ~VrpnAnalog() { delete _analog; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::mark -// Access: Public -// Description: Adds the indicated VrpnAnalogDevice to the list of -// devices that are sharing this VrpnAnalog. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated VrpnAnalogDevice to the list of devices that are sharing + * this VrpnAnalog. + */ void VrpnAnalog:: mark(VrpnAnalogDevice *device) { if (vrpn_cat.is_debug()) { @@ -59,12 +52,10 @@ mark(VrpnAnalogDevice *device) { _devices.push_back(device); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::unmark -// Access: Public -// Description: Removes the indicated VrpnAnalogDevice from the list -// of devices that are sharing this VrpnAnalog. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated VrpnAnalogDevice from the list of devices that are + * sharing this VrpnAnalog. + */ void VrpnAnalog:: unmark(VrpnAnalogDevice *device) { if (vrpn_cat.is_debug()) { @@ -79,21 +70,17 @@ unmark(VrpnAnalogDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnAnalog:: output(ostream &out) const { out << _analog_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnAnalog:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -101,13 +88,10 @@ write(ostream &out, int indent_level) const { << _devices.size() << " devices)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalog::vrpn_analog_callback -// Access: Private, Static -// Description: Receives the analog event data from the VRPN -// code and sends it to any interested -// VrpnAnalogDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the analog event data from the VRPN code and sends it to any + * interested VrpnAnalogDevices. + */ void VRPN_CALLBACK VrpnAnalog:: vrpn_analog_callback(void *userdata, const vrpn_ANALOGCB info) { VrpnAnalog *self = (VrpnAnalog *)userdata; diff --git a/panda/src/vrpn/vrpnAnalog.h b/panda/src/vrpn/vrpnAnalog.h index 5228e1d45b..0816c48ff5 100644 --- a/panda/src/vrpn/vrpnAnalog.h +++ b/panda/src/vrpn/vrpnAnalog.h @@ -1,16 +1,15 @@ -// Filename: vrpnAnalog.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalog.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNANALOG_H #define VRPNANALOG_H @@ -23,22 +22,19 @@ class VrpnAnalogDevice; -//////////////////////////////////////////////////////////////////// -// Class : VrpnAnalog -// Description : This is the actual interface to a particular VRPN -// analog device, and all of its numbered controls. A -// pointer to this object is stored in the VrpnClient -// class for each differently-named VRPN analog device -// we connect to. -// -// The VRPN callbacks go here, which in turn get -// vectored out to any VrpnAnalogDevice objects that -// register with this. When the last VrpnAnalogDevice -// object unregisters, the VrpnAnalog will be deleted -// by the VrpnClient. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual interface to a particular VRPN analog device, and all of + * its numbered controls. A pointer to this object is stored in the + * VrpnClient class for each differently-named VRPN analog device we connect + * to. + * + * The VRPN callbacks go here, which in turn get vectored out to any + * VrpnAnalogDevice objects that register with this. When the last + * VrpnAnalogDevice object unregisters, the VrpnAnalog will be deleted by the + * VrpnClient. + * + * This class does not need to be exported from the DLL. + */ class VrpnAnalog { public: VrpnAnalog(const string &analog_name, vrpn_Connection *connection); diff --git a/panda/src/vrpn/vrpnAnalogDevice.I b/panda/src/vrpn/vrpnAnalogDevice.I index b10b16935a..2a3c3af196 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.I +++ b/panda/src/vrpn/vrpnAnalogDevice.I @@ -1,25 +1,20 @@ -// Filename: vrpnAnalogDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalogDevice.I + * @author drose + * @date 2001-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalogDevice::get_vrpn_analog -// Access: Public -// Description: Returns a pointer to the particular VrpnAnalog this -// device gets its data from. This pointer may be -// shared with other VrpnAnalogDevice objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular VrpnAnalog this device gets its data + * from. This pointer may be shared with other VrpnAnalogDevice objects. + */ INLINE VrpnAnalog *VrpnAnalogDevice:: get_vrpn_analog() const { return _vrpn_analog; diff --git a/panda/src/vrpn/vrpnAnalogDevice.cxx b/panda/src/vrpn/vrpnAnalogDevice.cxx index 7b475de630..00da1a2240 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.cxx +++ b/panda/src/vrpn/vrpnAnalogDevice.cxx @@ -1,27 +1,24 @@ -// Filename: vrpnAnalogDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalogDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnAnalogDevice.h" #include "vrpnClient.h" TypeHandle VrpnAnalogDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalogDevice::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnAnalogDevice:: VrpnAnalogDevice(VrpnClient *client, const string &device_name, VrpnAnalog *vrpn_analog) : @@ -30,11 +27,9 @@ VrpnAnalogDevice(VrpnClient *client, const string &device_name, { } -//////////////////////////////////////////////////////////////////// -// Function: VrpnAnalogDevice::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnAnalogDevice:: ~VrpnAnalogDevice() { disconnect(); diff --git a/panda/src/vrpn/vrpnAnalogDevice.h b/panda/src/vrpn/vrpnAnalogDevice.h index f418b17b1f..e34f864d1c 100644 --- a/panda/src/vrpn/vrpnAnalogDevice.h +++ b/panda/src/vrpn/vrpnAnalogDevice.h @@ -1,16 +1,15 @@ -// Filename: vrpnAnalogDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnAnalogDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNANALOGDEVICE_H #define VRPNANALOGDEVICE_H @@ -22,14 +21,12 @@ class VrpnClient; class VrpnAnalog; -//////////////////////////////////////////////////////////////////// -// Class : VrpnAnalogDevice -// Description : The Panda interface to a VRPN analog device. This -// object will be returned by VrpnClient::make_device(), -// for attaching to a AnalogNode. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * The Panda interface to a VRPN analog device. This object will be returned + * by VrpnClient::make_device(), for attaching to a AnalogNode. + * + * This class does not need to be exported from the DLL. + */ class VrpnAnalogDevice : public ClientAnalogDevice { public: VrpnAnalogDevice(VrpnClient *client, const string &device_name, diff --git a/panda/src/vrpn/vrpnButton.I b/panda/src/vrpn/vrpnButton.I index a581322605..e5252a8e19 100644 --- a/panda/src/vrpn/vrpnButton.I +++ b/panda/src/vrpn/vrpnButton.I @@ -1,46 +1,38 @@ -// Filename: vrpnButton.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButton.I + * @author drose + * @date 2001-01-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::get_button_name -// Access: Public -// Description: Returns the name of the button device that was used -// to create this VrpnButton. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the button device that was used to create this + * VrpnButton. + */ INLINE const string &VrpnButton:: get_button_name() const { return _button_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::is_empty -// Access: Public -// Description: Returns true if no VrpnButtonDevices reference this -// VrpnButton, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no VrpnButtonDevices reference this VrpnButton, or false + * otherwise. + */ INLINE bool VrpnButton:: is_empty() const { return _devices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::poll -// Access: Public -// Description: Polls the connected device. Normally you should not -// call this directly; this will be called by the -// VrpnClient. -//////////////////////////////////////////////////////////////////// +/** + * Polls the connected device. Normally you should not call this directly; + * this will be called by the VrpnClient. + */ INLINE void VrpnButton:: poll() { _button->mainloop(); diff --git a/panda/src/vrpn/vrpnButton.cxx b/panda/src/vrpn/vrpnButton.cxx index 444fea8708..cf17f6bade 100644 --- a/panda/src/vrpn/vrpnButton.cxx +++ b/panda/src/vrpn/vrpnButton.cxx @@ -1,16 +1,15 @@ -// Filename: vrpnButton.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButton.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnButton.h" #include "vrpnButtonDevice.h" @@ -21,11 +20,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnButton:: VrpnButton(const string &button_name, vrpn_Connection *connection) : _button_name(button_name) @@ -35,22 +32,18 @@ VrpnButton(const string &button_name, vrpn_Connection *connection) : _button->register_change_handler((void*)this, &vrpn_button_callback); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnButton:: ~VrpnButton() { delete _button; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::mark -// Access: Public -// Description: Adds the indicated VrpnButtonDevice to the list of -// devices that are sharing this VrpnButton. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated VrpnButtonDevice to the list of devices that are sharing + * this VrpnButton. + */ void VrpnButton:: mark(VrpnButtonDevice *device) { if (vrpn_cat.is_debug()) { @@ -59,12 +52,10 @@ mark(VrpnButtonDevice *device) { _devices.push_back(device); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::unmark -// Access: Public -// Description: Removes the indicated VrpnButtonDevice from the list -// of devices that are sharing this VrpnButton. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated VrpnButtonDevice from the list of devices that are + * sharing this VrpnButton. + */ void VrpnButton:: unmark(VrpnButtonDevice *device) { if (vrpn_cat.is_debug()) { @@ -79,21 +70,17 @@ unmark(VrpnButtonDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnButton:: output(ostream &out) const { out << _button_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnButton:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -101,13 +88,10 @@ write(ostream &out, int indent_level) const { << _devices.size() << " devices)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButton::vrpn_button_callback -// Access: Private, Static -// Description: Receives the button event data from the VRPN -// code and sends it to any interested -// VrpnButtonDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the button event data from the VRPN code and sends it to any + * interested VrpnButtonDevices. + */ void VRPN_CALLBACK VrpnButton:: vrpn_button_callback(void *userdata, const vrpn_BUTTONCB info) { VrpnButton *self = (VrpnButton *)userdata; diff --git a/panda/src/vrpn/vrpnButton.h b/panda/src/vrpn/vrpnButton.h index b271b5b3ec..bdd829ab98 100644 --- a/panda/src/vrpn/vrpnButton.h +++ b/panda/src/vrpn/vrpnButton.h @@ -1,16 +1,15 @@ -// Filename: vrpnButton.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButton.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNBUTTON_H #define VRPNBUTTON_H @@ -23,22 +22,18 @@ class VrpnButtonDevice; -//////////////////////////////////////////////////////////////////// -// Class : VrpnButton -// Description : This is the actual interface to a particular VRPN -// button device, and all of its numbered buttons. A -// pointer to this object is stored in the VrpnClient -// class for each differently-named VRPN button device -// we connect to. -// -// The VRPN callbacks go here, which in turn get -// vectored out to any VrpnButtonDevice objects that -// register with this. When the last VrpnButtonDevice -// object unregisters, the VrpnButton will be deleted -// by the VrpnClient. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual interface to a particular VRPN button device, and all of + * its numbered buttons. A pointer to this object is stored in the VrpnClient + * class for each differently-named VRPN button device we connect to. + * + * The VRPN callbacks go here, which in turn get vectored out to any + * VrpnButtonDevice objects that register with this. When the last + * VrpnButtonDevice object unregisters, the VrpnButton will be deleted by the + * VrpnClient. + * + * This class does not need to be exported from the DLL. + */ class VrpnButton { public: VrpnButton(const string &button_name, vrpn_Connection *connection); diff --git a/panda/src/vrpn/vrpnButtonDevice.I b/panda/src/vrpn/vrpnButtonDevice.I index a5ad471f16..cb9f0ab600 100644 --- a/panda/src/vrpn/vrpnButtonDevice.I +++ b/panda/src/vrpn/vrpnButtonDevice.I @@ -1,25 +1,20 @@ -// Filename: vrpnButtonDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButtonDevice.I + * @author drose + * @date 2001-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VrpnButtonDevice::get_vrpn_button -// Access: Public -// Description: Returns a pointer to the particular VrpnButton this -// device gets its data from. This pointer may be -// shared with other VrpnButtonDevice objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular VrpnButton this device gets its data + * from. This pointer may be shared with other VrpnButtonDevice objects. + */ INLINE VrpnButton *VrpnButtonDevice:: get_vrpn_button() const { return _vrpn_button; diff --git a/panda/src/vrpn/vrpnButtonDevice.cxx b/panda/src/vrpn/vrpnButtonDevice.cxx index ff807fff4a..a392bbce49 100644 --- a/panda/src/vrpn/vrpnButtonDevice.cxx +++ b/panda/src/vrpn/vrpnButtonDevice.cxx @@ -1,27 +1,24 @@ -// Filename: vrpnButtonDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButtonDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnButtonDevice.h" #include "vrpnClient.h" TypeHandle VrpnButtonDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VrpnButtonDevice::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnButtonDevice:: VrpnButtonDevice(VrpnClient *client, const string &device_name, VrpnButton *vrpn_button) : @@ -30,11 +27,9 @@ VrpnButtonDevice(VrpnClient *client, const string &device_name, { } -//////////////////////////////////////////////////////////////////// -// Function: VrpnButtonDevice::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnButtonDevice:: ~VrpnButtonDevice() { disconnect(); diff --git a/panda/src/vrpn/vrpnButtonDevice.h b/panda/src/vrpn/vrpnButtonDevice.h index ca20b74613..3c88da7f2b 100644 --- a/panda/src/vrpn/vrpnButtonDevice.h +++ b/panda/src/vrpn/vrpnButtonDevice.h @@ -1,16 +1,15 @@ -// Filename: vrpnButtonDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnButtonDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNBUTTONDEVICE_H #define VRPNBUTTONDEVICE_H @@ -22,14 +21,12 @@ class VrpnClient; class VrpnButton; -//////////////////////////////////////////////////////////////////// -// Class : VrpnButtonDevice -// Description : The Panda interface to a VRPN button. This object -// will be returned by VrpnClient::make_device(), for -// attaching to a ButtonNode. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * The Panda interface to a VRPN button. This object will be returned by + * VrpnClient::make_device(), for attaching to a ButtonNode. + * + * This class does not need to be exported from the DLL. + */ class VrpnButtonDevice : public ClientButtonDevice { public: VrpnButtonDevice(VrpnClient *client, const string &device_name, diff --git a/panda/src/vrpn/vrpnClient.I b/panda/src/vrpn/vrpnClient.I index 7bc568b82e..563428d917 100644 --- a/panda/src/vrpn/vrpnClient.I +++ b/panda/src/vrpn/vrpnClient.I @@ -1,60 +1,46 @@ -// Filename: vrpnClient.I -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnClient.I + * @author jason + * @date 2000-08-04 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::get_server_name -// Access: Public -// Description: Returns the name of the server as passed to the -// VrpnClient constructor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the server as passed to the VrpnClient constructor. + */ INLINE const string &VrpnClient:: get_server_name() const { return _server_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::is_valid -// Access: Public -// Description: Returns true if everything seems to be kosher with -// the server (even if there is no connection), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if everything seems to be kosher with the server (even if + * there is no connection), or false otherwise. + */ INLINE bool VrpnClient:: is_valid() const { return (_connection->doing_okay() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::is_connected -// Access: Public -// Description: Returns true if the connection is established -// successfully, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the connection is established successfully, false + * otherwise. + */ INLINE bool VrpnClient:: is_connected() const { return (_connection->connected() != 0); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::convert_to_secs -// Access: Public, Static -// Description: Little inline function to convert a struct timeval -// to only seconds -//////////////////////////////////////////////////////////////////// +/** + * Little inline function to convert a struct timeval to only seconds + */ INLINE double VrpnClient:: convert_to_secs(struct timeval msg_time) { return (double)(msg_time.tv_sec) + (double)msg_time.tv_usec * 0.000001; @@ -65,11 +51,9 @@ convert_to_secs(struct timeval msg_time) { #if 0 -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VrpnClient:: VrpnClient(const string &server) : ClientBase(server) @@ -77,13 +61,10 @@ VrpnClient(const string &server) : _connection = vrpn_get_connection_by_name(server.c_str()); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::tracker_position -// Access: Private -// Description: Stores the latest position information as sent by -// the tracker (for the particular sensor we have -// interest in) -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest position information as sent by the tracker (for the + * particular sensor we have interest in) + */ INLINE void VrpnClient:: tracker_position(const string &tracker, const vrpn_TRACKERCB info) { double ptime = convert_to_secs(info.msg_time); @@ -93,13 +74,10 @@ tracker_position(const string &tracker, const vrpn_TRACKERCB info) { push_tracker_position(tracker, info.sensor, ptime, pos, pquat); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::tracker_velocity -// Access: Private -// Description: Stores the latest velocity information as sent by -// the tracker (for the particular sensor we have -// interest in) -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest velocity information as sent by the tracker (for the + * particular sensor we have interest in) + */ INLINE void VrpnClient:: tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { double vtime = convert_to_secs(info.msg_time); @@ -110,13 +88,10 @@ tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) { push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::tracker_acceleration -// Access: Private -// Description: Stores the latest acceleration information as sent by -// the tracker (for the particular sensor we have -// interest in) -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest acceleration information as sent by the tracker (for the + * particular sensor we have interest in) + */ INLINE void VrpnClient:: tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) { double atime = convert_to_secs(info.msg_time); @@ -128,12 +103,9 @@ tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) { push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::analog -// Access: Private -// Description: Stores the latest information as sent by -// the analog device -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest information as sent by the analog device + */ INLINE void VrpnClient:: analog(const string &analog, const vrpn_ANALOGCB info) { double atime = convert_to_secs(info.msg_time); @@ -141,12 +113,9 @@ analog(const string &analog, const vrpn_ANALOGCB info) { push_analog(analog, atime, info.channel, info.num_channel); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::button -// Access: Private -// Description: Stores the latest button pressed information as sent by -// the button -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest button pressed information as sent by the button + */ INLINE void VrpnClient:: button(const string &button, const vrpn_BUTTONCB info) { double btime = convert_to_secs(info.msg_time); @@ -154,12 +123,9 @@ button(const string &button, const vrpn_BUTTONCB info) { push_button(button, btime, info.button, info.state); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::dial -// Access: Private -// Description: Stores the latest change information as sent by -// the dial -//////////////////////////////////////////////////////////////////// +/** + * Stores the latest change information as sent by the dial + */ INLINE void VrpnClient:: dial(const string &dial, const vrpn_DIALCB info) { double dtime = convert_to_secs(info.msg_time); diff --git a/panda/src/vrpn/vrpnClient.cxx b/panda/src/vrpn/vrpnClient.cxx index 89e7a1c928..1e7ec5abf0 100644 --- a/panda/src/vrpn/vrpnClient.cxx +++ b/panda/src/vrpn/vrpnClient.cxx @@ -1,16 +1,15 @@ -// Filename: vrpnClient.cxx -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnClient.cxx + * @author jason + * @date 2000-08-04 + */ #include "vrpnClient.h" #include "vrpnTracker.h" @@ -29,11 +28,9 @@ TypeHandle VrpnClient::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnClient:: VrpnClient(const string &server_name) : _server_name(server_name) @@ -53,22 +50,18 @@ VrpnClient(const string &server_name) : } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnClient:: ~VrpnClient() { delete _connection; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::write -// Access: Public -// Description: Writes a list of the active devices that the -// VrpnClient is currently polling each frame. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the active devices that the VrpnClient is currently + * polling each frame. + */ void VrpnClient:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -123,19 +116,15 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::make_device -// Access: Protected, Virtual -// Description: Creates and returns a new ClientDevice of the -// appropriate type, according to the requested -// device_type and device_name. Returns NULL if a -// matching device cannot be found. -// -// This is guaranteed not to be called twice for a given -// device_type/device_name combination (unless -// disconnect_device() has already been called for the -// same device_type/device_name). -//////////////////////////////////////////////////////////////////// +/** + * Creates and returns a new ClientDevice of the appropriate type, according + * to the requested device_type and device_name. Returns NULL if a matching + * device cannot be found. + * + * This is guaranteed not to be called twice for a given + * device_type/device_name combination (unless disconnect_device() has already + * been called for the same device_type/device_name). + */ PT(ClientDevice) VrpnClient:: make_device(TypeHandle device_type, const string &device_name) { if (device_type == ClientTrackerDevice::get_class_type()) { @@ -155,19 +144,14 @@ make_device(TypeHandle device_type, const string &device_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::disconnect_device -// Access: Protected, Virtual -// Description: Removes the device, which is presumably about to -// destruct, from the list of connected devices, and -// frees any data required to support it. This device -// will no longer receive automatic updates with each -// poll. -// -// The return value is true if the device was -// disconnected, or false if it was unknown (e.g. it was -// disconnected previously). -//////////////////////////////////////////////////////////////////// +/** + * Removes the device, which is presumably about to destruct, from the list of + * connected devices, and frees any data required to support it. This device + * will no longer receive automatic updates with each poll. + * + * The return value is true if the device was disconnected, or false if it was + * unknown (e.g. it was disconnected previously). + */ bool VrpnClient:: disconnect_device(TypeHandle device_type, const string &device_name, ClientDevice *device) { @@ -196,15 +180,12 @@ disconnect_device(TypeHandle device_type, const string &device_name, return false; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::do_poll -// Access: Protected, Virtual -// Description: Implements the polling and updating of connected -// devices, if the ClientBase requires this. This may -// be called in a sub-thread if -// fork_asynchronous_thread() was called; otherwise, it -// will be called once per frame. -//////////////////////////////////////////////////////////////////// +/** + * Implements the polling and updating of connected devices, if the ClientBase + * requires this. This may be called in a sub-thread if + * fork_asynchronous_thread() was called; otherwise, it will be called once + * per frame. + */ void VrpnClient:: do_poll() { ClientBase::do_poll(); @@ -241,34 +222,27 @@ do_poll() { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::make_tracker_device -// Access: Private -// Description: Creates a new tracker device. The device_name is -// parsed for sensor and data_type information. -// -// The device_name may be one of the following: -// -// tracker_name -// tracker_name:N -// tracker_name:N[pva] -// -// Where N is an integer sensor number, and [pva] is one -// of the lowercase letters p, v, or a. -// -// In the first form, the device connects to the -// indicated tracker, and reports position information -// on sensor number 0. -// -// In the second form, the device connects to the -// indicated tracker, and reports position information -// on the indicated sensor number. -// -// In the third form, the device connects to the -// indicated tracker, and reports either position, -// velocity, or acceleration information on the -// indicated sensor number. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new tracker device. The device_name is parsed for sensor and + * data_type information. + * + * The device_name may be one of the following: + * + * tracker_name tracker_name:N tracker_name:N[pva] + * + * Where N is an integer sensor number, and [pva] is one of the lowercase + * letters p, v, or a. + * + * In the first form, the device connects to the indicated tracker, and + * reports position information on sensor number 0. + * + * In the second form, the device connects to the indicated tracker, and + * reports position information on the indicated sensor number. + * + * In the third form, the device connects to the indicated tracker, and + * reports either position, velocity, or acceleration information on the + * indicated sensor number. + */ PT(ClientDevice) VrpnClient:: make_tracker_device(const string &device_name) { if (vrpn_cat.is_debug()) { @@ -325,12 +299,10 @@ make_tracker_device(const string &device_name) { return device; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::make_button_device -// Access: Private -// Description: Creates a new button device. The device_name is sent -// verbatim to the VRPN library. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new button device. The device_name is sent verbatim to the VRPN + * library. + */ PT(ClientDevice) VrpnClient:: make_button_device(const string &device_name) { if (vrpn_cat.is_debug()) { @@ -352,12 +324,10 @@ make_button_device(const string &device_name) { return device; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::make_analog_device -// Access: Private -// Description: Creates a new analog device. The device_name is sent -// verbatim to the VRPN library. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new analog device. The device_name is sent verbatim to the VRPN + * library. + */ PT(ClientDevice) VrpnClient:: make_analog_device(const string &device_name) { if (vrpn_cat.is_debug()) { @@ -379,12 +349,10 @@ make_analog_device(const string &device_name) { return device; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::make_dial_device -// Access: Private -// Description: Creates a new dial device. The device_name is sent -// verbatim to the VRPN library. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new dial device. The device_name is sent verbatim to the VRPN + * library. + */ PT(ClientDevice) VrpnClient:: make_dial_device(const string &device_name) { if (vrpn_cat.is_debug()) { @@ -406,12 +374,9 @@ make_dial_device(const string &device_name) { return device; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::disconnect_tracker_device -// Access: Private -// Description: Removes the tracker device from the list of things to -// be updated. -//////////////////////////////////////////////////////////////////// +/** + * Removes the tracker device from the list of things to be updated. + */ void VrpnClient:: disconnect_tracker_device(VrpnTrackerDevice *device) { VrpnTracker *vrpn_tracker = device->get_vrpn_tracker(); @@ -421,12 +386,9 @@ disconnect_tracker_device(VrpnTrackerDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::disconnect_button_device -// Access: Private -// Description: Removes the button device from the list of things to -// be updated. -//////////////////////////////////////////////////////////////////// +/** + * Removes the button device from the list of things to be updated. + */ void VrpnClient:: disconnect_button_device(VrpnButtonDevice *device) { VrpnButton *vrpn_button = device->get_vrpn_button(); @@ -436,12 +398,9 @@ disconnect_button_device(VrpnButtonDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::disconnect_analog_device -// Access: Private -// Description: Removes the analog device from the list of things to -// be updated. -//////////////////////////////////////////////////////////////////// +/** + * Removes the analog device from the list of things to be updated. + */ void VrpnClient:: disconnect_analog_device(VrpnAnalogDevice *device) { VrpnAnalog *vrpn_analog = device->get_vrpn_analog(); @@ -451,12 +410,9 @@ disconnect_analog_device(VrpnAnalogDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::disconnect_dial_device -// Access: Private -// Description: Removes the dial device from the list of things to -// be updated. -//////////////////////////////////////////////////////////////////// +/** + * Removes the dial device from the list of things to be updated. + */ void VrpnClient:: disconnect_dial_device(VrpnDialDevice *device) { VrpnDial *vrpn_dial = device->get_vrpn_dial(); @@ -466,13 +422,10 @@ disconnect_dial_device(VrpnDialDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::get_tracker -// Access: Private -// Description: Finds a VrpnTracker of the indicated name, and -// returns it if one already exists, or creates a new -// one if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Finds a VrpnTracker of the indicated name, and returns it if one already + * exists, or creates a new one if it does not. + */ VrpnTracker *VrpnClient:: get_tracker(const string &tracker_name) { Trackers::iterator ti; @@ -493,12 +446,10 @@ get_tracker(const string &tracker_name) { return vrpn_tracker; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::free_tracker -// Access: Private -// Description: Removes and deletes the indicated VrpnTracker, which -// is no longer referenced by any VrpnTrackerDevices. -//////////////////////////////////////////////////////////////////// +/** + * Removes and deletes the indicated VrpnTracker, which is no longer + * referenced by any VrpnTrackerDevices. + */ void VrpnClient:: free_tracker(VrpnTracker *vrpn_tracker) { nassertv(vrpn_tracker->is_empty()); @@ -517,13 +468,10 @@ free_tracker(VrpnTracker *vrpn_tracker) { delete vrpn_tracker; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::get_button -// Access: Private -// Description: Finds a VrpnButton of the indicated name, and -// returns it if one already exists, or creates a new -// one if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Finds a VrpnButton of the indicated name, and returns it if one already + * exists, or creates a new one if it does not. + */ VrpnButton *VrpnClient:: get_button(const string &button_name) { Buttons::iterator bi; @@ -544,12 +492,10 @@ get_button(const string &button_name) { return vrpn_button; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::free_button -// Access: Private -// Description: Removes and deletes the indicated VrpnButton, which -// is no longer referenced by any VrpnButtonDevices. -//////////////////////////////////////////////////////////////////// +/** + * Removes and deletes the indicated VrpnButton, which is no longer referenced + * by any VrpnButtonDevices. + */ void VrpnClient:: free_button(VrpnButton *vrpn_button) { nassertv(vrpn_button->is_empty()); @@ -568,13 +514,10 @@ free_button(VrpnButton *vrpn_button) { delete vrpn_button; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::get_analog -// Access: Private -// Description: Finds a VrpnAnalog of the indicated name, and -// returns it if one already exists, or creates a new -// one if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Finds a VrpnAnalog of the indicated name, and returns it if one already + * exists, or creates a new one if it does not. + */ VrpnAnalog *VrpnClient:: get_analog(const string &analog_name) { Analogs::iterator ai; @@ -595,12 +538,10 @@ get_analog(const string &analog_name) { return vrpn_analog; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::free_analog -// Access: Private -// Description: Removes and deletes the indicated VrpnAnalog, which -// is no longer referenced by any VrpnAnalogDevices. -//////////////////////////////////////////////////////////////////// +/** + * Removes and deletes the indicated VrpnAnalog, which is no longer referenced + * by any VrpnAnalogDevices. + */ void VrpnClient:: free_analog(VrpnAnalog *vrpn_analog) { nassertv(vrpn_analog->is_empty()); @@ -619,13 +560,10 @@ free_analog(VrpnAnalog *vrpn_analog) { delete vrpn_analog; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::get_dial -// Access: Private -// Description: Finds a VrpnDial of the indicated name, and -// returns it if one already exists, or creates a new -// one if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Finds a VrpnDial of the indicated name, and returns it if one already + * exists, or creates a new one if it does not. + */ VrpnDial *VrpnClient:: get_dial(const string &dial_name) { Dials::iterator di; @@ -646,12 +584,10 @@ get_dial(const string &dial_name) { return vrpn_dial; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::free_dial -// Access: Private -// Description: Removes and deletes the indicated VrpnDial, which -// is no longer referenced by any VrpnDialDevices. -//////////////////////////////////////////////////////////////////// +/** + * Removes and deletes the indicated VrpnDial, which is no longer referenced + * by any VrpnDialDevices. + */ void VrpnClient:: free_dial(VrpnDial *vrpn_dial) { nassertv(vrpn_dial->is_empty()); @@ -682,12 +618,9 @@ typedef struct { } VrpnClientInfo; -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::add_remote_tracker -// Access: Public, Virtual -// Description: Creates a new vrpn remote tracker object and registers -// a callback with it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vrpn remote tracker object and registers a callback with it. + */ bool VrpnClient:: add_remote_tracker(const string &tracker, int sensor) { @@ -696,9 +629,9 @@ add_remote_tracker(const string &tracker, int sensor) { return false; } - //Now package up the information that needs to be passed to the - //callback function to allow it to determine for which tracker we - //are receiving information for + // Now package up the information that needs to be passed to the callback + // function to allow it to determine for which tracker we are receiving + // information for VrpnClientInfo *data = new VrpnClientInfo; data->device_name = tracker; data->self = this; @@ -714,12 +647,9 @@ add_remote_tracker(const string &tracker, int sensor) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::add_remote_analog -// Access: Public, Virtual -// Description: Creates a new vrpn remote analog object and registers -// a callback with it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vrpn remote analog object and registers a callback with it. + */ bool VrpnClient:: add_remote_analog(const string &analog) { @@ -728,9 +658,9 @@ add_remote_analog(const string &analog) { return false; } - //Now package up the information that needs to be passed to the - //callback function to allow it to determine for which analog we - //are receiving information for + // Now package up the information that needs to be passed to the callback + // function to allow it to determine for which analog we are receiving + // information for VrpnClientInfo *data = new VrpnClientInfo; data->device_name = analog; data->self = this; @@ -743,12 +673,9 @@ add_remote_analog(const string &analog) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::add_remote_button -// Access: Public, Virtual -// Description: Creates a new vrpn remote button object and registers -// a callback with it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vrpn remote button object and registers a callback with it. + */ bool VrpnClient:: add_remote_button(const string &button) { @@ -757,9 +684,9 @@ add_remote_button(const string &button) { return false; } - //Now package up the information that needs to be passed to the - //callback function to allow it to determine for which button we - //are receiving information for + // Now package up the information that needs to be passed to the callback + // function to allow it to determine for which button we are receiving + // information for VrpnClientInfo *data = new VrpnClientInfo; data->device_name = button; data->self = this; @@ -772,12 +699,9 @@ add_remote_button(const string &button) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::add_remote_dial -// Access: Public, Virtual -// Description: Creates a new vrpn remote dial object and registers -// a callback with it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new vrpn remote dial object and registers a callback with it. + */ bool VrpnClient:: add_remote_dial(const string &dial) { @@ -786,9 +710,9 @@ add_remote_dial(const string &dial) { return false; } - //Now package up the information that needs to be passed to the - //callback function to allow it to determine for which dial we - //are receiving information for + // Now package up the information that needs to be passed to the callback + // function to allow it to determine for which dial we are receiving + // information for VrpnClientInfo *data = new VrpnClientInfo; data->device_name = dial; data->self = this; @@ -801,127 +725,104 @@ add_remote_dial(const string &dial) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::max_analog_channels -// Access: Public, Virtual -// Description: Max number of analog channels -//////////////////////////////////////////////////////////////////// +/** + * Max number of analog channels + */ int VrpnClient:: max_analog_channels() { return vrpn_CHANNEL_MAX; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::poll_trackers -// Access: Public, Virtual -// Description: Calls mainloop for the registered tracker object -// Note: In a non-threaded case, this may need to come up with -// some kind of cacheing scheme so we don't call mainloop -// multiple times when a user is just asking for the data -// of multiple sensors on 1 tracker (as that is the interface -// supported). This is a non-trivial problem as it is -// difficult to know when we should and shouldn't cache. -//////////////////////////////////////////////////////////////////// +/** + * Calls mainloop for the registered tracker object Note: In a non-threaded + * case, this may need to come up with some kind of cacheing scheme so we + * don't call mainloop multiple times when a user is just asking for the data + * of multiple sensors on 1 tracker (as that is the interface supported). + * This is a non-trivial problem as it is difficult to know when we should and + * shouldn't cache. + */ void VrpnClient:: poll_tracker(const string &tracker) { _vrpn_trackers[tracker]->mainloop(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::poll_analog -// Access: Public, Virtual -// Description: Calls mainloop for the registered analog object -//////////////////////////////////////////////////////////////////// +/** + * Calls mainloop for the registered analog object + */ void VrpnClient:: poll_analog(const string &analog) { _vrpn_analogs[analog]->mainloop(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::poll_button -// Access: Public, Virtual -// Description: Calls mainloop for the registered button object -//////////////////////////////////////////////////////////////////// +/** + * Calls mainloop for the registered button object + */ void VrpnClient:: poll_button(const string &button) { _vrpn_buttons[button]->mainloop(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::poll_dial -// Access: Public, Virtual -// Description: Calls mainloop for the registered dial object -//////////////////////////////////////////////////////////////////// +/** + * Calls mainloop for the registered dial object + */ void VrpnClient:: poll_dial(const string &dial) { _vrpn_dials[dial]->mainloop(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_tracker_position -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VRPN_CALLBACK VrpnClient:: st_tracker_position(void *userdata, const vrpn_TRACKERCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; ((VrpnClient *)data->self)->tracker_position(data->device_name, info); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_tracker_velocity -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VRPN_CALLBACK VrpnClient:: st_tracker_velocity(void *userdata, const vrpn_TRACKERVELCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; ((VrpnClient *)data->self)->tracker_velocity(data->device_name, info); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_tracker_acceleration -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VRPN_CALLBACK VrpnClient:: st_tracker_acceleration(void *userdata, const vrpn_TRACKERACCCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; ((VrpnClient *)data->self)->tracker_acceleration(data->device_name, info); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_analog -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VrpnClient:: st_analog(void *userdata, const vrpn_ANALOGCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; ((VrpnClient *)data->self)->analog(data->device_name, info); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_button -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VrpnClient:: st_button(void *userdata, const vrpn_BUTTONCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; ((VrpnClient *)data->self)->button(data->device_name, info); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnClient::st_dial -// Access: Private, Static -// Description: Callback function that merely passes the data down -// to the appropriate non-static function -//////////////////////////////////////////////////////////////////// +/** + * Callback function that merely passes the data down to the appropriate non- + * static function + */ void VrpnClient:: st_dial(void *userdata, const vrpn_DIALCB info) { VrpnClientInfo *data = (VrpnClientInfo *)userdata; diff --git a/panda/src/vrpn/vrpnClient.h b/panda/src/vrpn/vrpnClient.h index 1f23ddc51b..1fd0267601 100644 --- a/panda/src/vrpn/vrpnClient.h +++ b/panda/src/vrpn/vrpnClient.h @@ -1,16 +1,15 @@ -// Filename: vrpnClient.h -// Created by: jason (04Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnClient.h + * @author jason + * @date 2000-08-04 + */ #ifndef VRPNCLIENT_H #define VRPNCLIENT_H @@ -29,12 +28,10 @@ class VrpnAnalogDevice; class VrpnDial; class VrpnDialDevice; -//////////////////////////////////////////////////////////////////// -// Class : VrpnClient -// Description : A specific ClientBase that connects to a VRPN server -// and records information on the connected VRPN -// devices. -//////////////////////////////////////////////////////////////////// +/** + * A specific ClientBase that connects to a VRPN server and records + * information on the connected VRPN devices. + */ class EXPCL_VRPN VrpnClient : public ClientBase { PUBLISHED: VrpnClient(const string &server_name); @@ -117,5 +114,3 @@ private: #include "vrpnClient.I" #endif - - diff --git a/panda/src/vrpn/vrpnDial.I b/panda/src/vrpn/vrpnDial.I index e0bdf1c7ca..240f51fa40 100644 --- a/panda/src/vrpn/vrpnDial.I +++ b/panda/src/vrpn/vrpnDial.I @@ -1,46 +1,37 @@ -// Filename: vrpnDial.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDial.I + * @author drose + * @date 2001-01-26 + */ -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::get_dial_name -// Access: Public -// Description: Returns the name of the dial device that was used -// to create this VrpnDial. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the dial device that was used to create this VrpnDial. + */ INLINE const string &VrpnDial:: get_dial_name() const { return _dial_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::is_empty -// Access: Public -// Description: Returns true if no VrpnDialDevices reference this -// VrpnDial, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no VrpnDialDevices reference this VrpnDial, or false + * otherwise. + */ INLINE bool VrpnDial:: is_empty() const { return _devices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::poll -// Access: Public -// Description: Polls the connected device. Normally you should not -// call this directly; this will be called by the -// VrpnClient. -//////////////////////////////////////////////////////////////////// +/** + * Polls the connected device. Normally you should not call this directly; + * this will be called by the VrpnClient. + */ INLINE void VrpnDial:: poll() { _dial->mainloop(); diff --git a/panda/src/vrpn/vrpnDial.cxx b/panda/src/vrpn/vrpnDial.cxx index 34d4ae549a..57de1bd59c 100644 --- a/panda/src/vrpn/vrpnDial.cxx +++ b/panda/src/vrpn/vrpnDial.cxx @@ -1,16 +1,15 @@ -// Filename: vrpnDial.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDial.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnDial.h" #include "vrpnDialDevice.h" @@ -21,11 +20,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnDial:: VrpnDial(const string &dial_name, vrpn_Connection *connection) : _dial_name(dial_name) @@ -35,22 +32,18 @@ VrpnDial(const string &dial_name, vrpn_Connection *connection) : _dial->register_change_handler((void*)this, &vrpn_dial_callback); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnDial:: ~VrpnDial() { delete _dial; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::mark -// Access: Public -// Description: Adds the indicated VrpnDialDevice to the list of -// devices that are sharing this VrpnDial. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated VrpnDialDevice to the list of devices that are sharing + * this VrpnDial. + */ void VrpnDial:: mark(VrpnDialDevice *device) { if (vrpn_cat.is_debug()) { @@ -59,12 +52,10 @@ mark(VrpnDialDevice *device) { _devices.push_back(device); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::unmark -// Access: Public -// Description: Removes the indicated VrpnDialDevice from the list -// of devices that are sharing this VrpnDial. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated VrpnDialDevice from the list of devices that are + * sharing this VrpnDial. + */ void VrpnDial:: unmark(VrpnDialDevice *device) { if (vrpn_cat.is_debug()) { @@ -79,21 +70,17 @@ unmark(VrpnDialDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnDial:: output(ostream &out) const { out << _dial_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnDial:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -101,13 +88,10 @@ write(ostream &out, int indent_level) const { << _devices.size() << " devices)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDial::vrpn_dial_callback -// Access: Private, Static -// Description: Receives the dial event data from the VRPN -// code and sends it to any interested -// VrpnDialDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the dial event data from the VRPN code and sends it to any + * interested VrpnDialDevices. + */ void VRPN_CALLBACK VrpnDial:: vrpn_dial_callback(void *userdata, const vrpn_DIALCB info) { VrpnDial *self = (VrpnDial *)userdata; diff --git a/panda/src/vrpn/vrpnDial.h b/panda/src/vrpn/vrpnDial.h index 8f8bdae725..5500d730e0 100644 --- a/panda/src/vrpn/vrpnDial.h +++ b/panda/src/vrpn/vrpnDial.h @@ -1,16 +1,15 @@ -// Filename: vrpnDial.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDial.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNDIAL_H #define VRPNDIAL_H @@ -23,22 +22,18 @@ class VrpnDialDevice; -//////////////////////////////////////////////////////////////////// -// Class : VrpnDial -// Description : This is the actual interface to a particular VRPN -// dial device, and all of its numbered dials. A -// pointer to this object is stored in the VrpnClient -// class for each differently-named VRPN dial device -// we connect to. -// -// The VRPN callbacks go here, which in turn get -// vectored out to any VrpnDialDevice objects that -// register with this. When the last VrpnDialDevice -// object unregisters, the VrpnDial will be deleted -// by the VrpnClient. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual interface to a particular VRPN dial device, and all of + * its numbered dials. A pointer to this object is stored in the VrpnClient + * class for each differently-named VRPN dial device we connect to. + * + * The VRPN callbacks go here, which in turn get vectored out to any + * VrpnDialDevice objects that register with this. When the last + * VrpnDialDevice object unregisters, the VrpnDial will be deleted by the + * VrpnClient. + * + * This class does not need to be exported from the DLL. + */ class VrpnDial { public: VrpnDial(const string &dial_name, vrpn_Connection *connection); diff --git a/panda/src/vrpn/vrpnDialDevice.I b/panda/src/vrpn/vrpnDialDevice.I index 40127f554f..0663a0bbb1 100644 --- a/panda/src/vrpn/vrpnDialDevice.I +++ b/panda/src/vrpn/vrpnDialDevice.I @@ -1,25 +1,20 @@ -// Filename: vrpnDialDevice.I -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDialDevice.I + * @author drose + * @date 2001-01-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VrpnDialDevice::get_vrpn_dial -// Access: Public -// Description: Returns a pointer to the particular VrpnDial this -// device gets its data from. This pointer may be -// shared with other VrpnDialDevice objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular VrpnDial this device gets its data + * from. This pointer may be shared with other VrpnDialDevice objects. + */ INLINE VrpnDial *VrpnDialDevice:: get_vrpn_dial() const { return _vrpn_dial; diff --git a/panda/src/vrpn/vrpnDialDevice.cxx b/panda/src/vrpn/vrpnDialDevice.cxx index 5a10f090c5..77be871f73 100644 --- a/panda/src/vrpn/vrpnDialDevice.cxx +++ b/panda/src/vrpn/vrpnDialDevice.cxx @@ -1,27 +1,24 @@ -// Filename: vrpnDialDevice.cxx -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDialDevice.cxx + * @author drose + * @date 2001-01-26 + */ #include "vrpnDialDevice.h" #include "vrpnClient.h" TypeHandle VrpnDialDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VrpnDialDevice::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnDialDevice:: VrpnDialDevice(VrpnClient *client, const string &device_name, VrpnDial *vrpn_dial) : @@ -30,11 +27,9 @@ VrpnDialDevice(VrpnClient *client, const string &device_name, { } -//////////////////////////////////////////////////////////////////// -// Function: VrpnDialDevice::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnDialDevice:: ~VrpnDialDevice() { disconnect(); diff --git a/panda/src/vrpn/vrpnDialDevice.h b/panda/src/vrpn/vrpnDialDevice.h index 6db7bfa61f..533f3b3f97 100644 --- a/panda/src/vrpn/vrpnDialDevice.h +++ b/panda/src/vrpn/vrpnDialDevice.h @@ -1,16 +1,15 @@ -// Filename: vrpnDialDevice.h -// Created by: drose (26Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnDialDevice.h + * @author drose + * @date 2001-01-26 + */ #ifndef VRPNDIALDEVICE_H #define VRPNDIALDEVICE_H @@ -22,14 +21,12 @@ class VrpnClient; class VrpnDial; -//////////////////////////////////////////////////////////////////// -// Class : VrpnDialDevice -// Description : The Panda interface to a VRPN dial device. This -// object will be returned by VrpnClient::make_device(), -// for attaching to a DialNode. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * The Panda interface to a VRPN dial device. This object will be returned by + * VrpnClient::make_device(), for attaching to a DialNode. + * + * This class does not need to be exported from the DLL. + */ class VrpnDialDevice : public ClientDialDevice { public: VrpnDialDevice(VrpnClient *client, const string &device_name, diff --git a/panda/src/vrpn/vrpnTracker.I b/panda/src/vrpn/vrpnTracker.I index 495aea1ec0..9c97e92968 100644 --- a/panda/src/vrpn/vrpnTracker.I +++ b/panda/src/vrpn/vrpnTracker.I @@ -1,46 +1,38 @@ -// Filename: vrpnTracker.I -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTracker.I + * @author drose + * @date 2001-01-25 + */ -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::get_tracker_name -// Access: Public -// Description: Returns the name of the tracker device that was used -// to create this VrpnTracker. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the tracker device that was used to create this + * VrpnTracker. + */ INLINE const string &VrpnTracker:: get_tracker_name() const { return _tracker_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::is_empty -// Access: Public -// Description: Returns true if no VrpnTrackerDevices reference this -// VrpnTracker, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if no VrpnTrackerDevices reference this VrpnTracker, or false + * otherwise. + */ INLINE bool VrpnTracker:: is_empty() const { return _devices.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::poll -// Access: Public -// Description: Polls the connected device. Normally you should not -// call this directly; this will be called by the -// VrpnClient. -//////////////////////////////////////////////////////////////////// +/** + * Polls the connected device. Normally you should not call this directly; + * this will be called by the VrpnClient. + */ INLINE void VrpnTracker:: poll() { _tracker->mainloop(); diff --git a/panda/src/vrpn/vrpnTracker.cxx b/panda/src/vrpn/vrpnTracker.cxx index c99e95b513..6427c6c392 100644 --- a/panda/src/vrpn/vrpnTracker.cxx +++ b/panda/src/vrpn/vrpnTracker.cxx @@ -1,16 +1,15 @@ -// Filename: vrpnTracker.cxx -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTracker.cxx + * @author drose + * @date 2001-01-25 + */ #include "vrpnTracker.h" #include "vrpnTrackerDevice.h" @@ -21,11 +20,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnTracker:: VrpnTracker(const string &tracker_name, vrpn_Connection *connection) : _tracker_name(tracker_name) @@ -37,22 +34,18 @@ VrpnTracker(const string &tracker_name, vrpn_Connection *connection) : _tracker->register_change_handler((void*)this, &vrpn_acceleration_callback); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnTracker:: ~VrpnTracker() { delete _tracker; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::mark -// Access: Public -// Description: Adds the indicated VrpnTrackerDevice to the list of -// devices that are sharing this VrpnTracker. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated VrpnTrackerDevice to the list of devices that are + * sharing this VrpnTracker. + */ void VrpnTracker:: mark(VrpnTrackerDevice *device) { if (vrpn_cat.is_debug()) { @@ -61,12 +54,10 @@ mark(VrpnTrackerDevice *device) { _devices.push_back(device); } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::unmark -// Access: Public -// Description: Removes the indicated VrpnTrackerDevice from the list -// of devices that are sharing this VrpnTracker. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated VrpnTrackerDevice from the list of devices that are + * sharing this VrpnTracker. + */ void VrpnTracker:: unmark(VrpnTrackerDevice *device) { if (vrpn_cat.is_debug()) { @@ -81,21 +72,17 @@ unmark(VrpnTrackerDevice *device) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnTracker:: output(ostream &out) const { out << _tracker_name; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VrpnTracker:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -103,13 +90,10 @@ write(ostream &out, int indent_level) const { << _devices.size() << " devices)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::vrpn_position_callback -// Access: Private, Static -// Description: Receives the tracker positional data from the VRPN -// code and sends it to any interested -// VrpnTrackerDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the tracker positional data from the VRPN code and sends it to any + * interested VrpnTrackerDevices. + */ void VRPN_CALLBACK VrpnTracker:: vrpn_position_callback(void *userdata, const vrpn_TRACKERCB info) { VrpnTracker *self = (VrpnTracker *)userdata; @@ -132,13 +116,10 @@ vrpn_position_callback(void *userdata, const vrpn_TRACKERCB info) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::vrpn_velocity_callback -// Access: Private, Static -// Description: Receives the tracker velocity data from the VRPN -// code and sends it to any interested -// VrpnTrackerDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the tracker velocity data from the VRPN code and sends it to any + * interested VrpnTrackerDevices. + */ void VRPN_CALLBACK VrpnTracker:: vrpn_velocity_callback(void *userdata, const vrpn_TRACKERVELCB info) { VrpnTracker *self = (VrpnTracker *)userdata; @@ -163,13 +144,10 @@ vrpn_velocity_callback(void *userdata, const vrpn_TRACKERVELCB info) { } } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTracker::vrpn_acceleration_callback -// Access: Private, Static -// Description: Receives the tracker acceleration data from the VRPN -// code and sends it to any interested -// VrpnTrackerDevices. -//////////////////////////////////////////////////////////////////// +/** + * Receives the tracker acceleration data from the VRPN code and sends it to + * any interested VrpnTrackerDevices. + */ void VRPN_CALLBACK VrpnTracker:: vrpn_acceleration_callback(void *userdata, const vrpn_TRACKERACCCB info) { VrpnTracker *self = (VrpnTracker *)userdata; diff --git a/panda/src/vrpn/vrpnTracker.h b/panda/src/vrpn/vrpnTracker.h index 3e3450107b..acfdcaff5b 100644 --- a/panda/src/vrpn/vrpnTracker.h +++ b/panda/src/vrpn/vrpnTracker.h @@ -1,16 +1,15 @@ -// Filename: vrpnTracker.h -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTracker.h + * @author drose + * @date 2001-01-25 + */ #ifndef VRPNTRACKER_H #define VRPNTRACKER_H @@ -23,21 +22,18 @@ class VrpnTrackerDevice; -//////////////////////////////////////////////////////////////////// -// Class : VrpnTracker -// Description : This is the actual interface to a particular VRPN -// tracker object, and all of its sensors. A pointer to -// this object is stored in the VrpnClient class for -// each differently-named VRPN tracker we connect to. -// -// The VRPN callbacks go here, which in turn get -// vectored out to any VrpnTrackerDevice objects that -// register with this. When the last VrpnTrackerDevice -// object unregisters, the VrpnTracker will be deleted -// by the VrpnClient. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * This is the actual interface to a particular VRPN tracker object, and all + * of its sensors. A pointer to this object is stored in the VrpnClient class + * for each differently-named VRPN tracker we connect to. + * + * The VRPN callbacks go here, which in turn get vectored out to any + * VrpnTrackerDevice objects that register with this. When the last + * VrpnTrackerDevice object unregisters, the VrpnTracker will be deleted by + * the VrpnClient. + * + * This class does not need to be exported from the DLL. + */ class VrpnTracker { public: VrpnTracker(const string &tracker_name, vrpn_Connection *connection); @@ -78,4 +74,3 @@ INLINE ostream &operator << (ostream &out, const VrpnTracker &tracker) { #include "vrpnTracker.I" #endif - diff --git a/panda/src/vrpn/vrpnTrackerDevice.I b/panda/src/vrpn/vrpnTrackerDevice.I index b0b2ada1e6..cc305ffeb8 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.I +++ b/panda/src/vrpn/vrpnTrackerDevice.I @@ -1,50 +1,39 @@ -// Filename: vrpnTrackerDevice.I -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTrackerDevice.I + * @author drose + * @date 2001-01-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VrpnTrackerDevice::get_sensor -// Access: Public -// Description: Returns the particular sensor index that this device -// wants to hear about from the VrpnTracker. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular sensor index that this device wants to hear about + * from the VrpnTracker. + */ INLINE int VrpnTrackerDevice:: get_sensor() const { return _sensor; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTrackerDevice::get_data_type -// Access: Public -// Description: Returns the type of data this device represents from -// the VrpnTracker. This may be position, velocity, or -// acceleration. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of data this device represents from the VrpnTracker. This + * may be position, velocity, or acceleration. + */ INLINE VrpnTrackerDevice::DataType VrpnTrackerDevice:: get_data_type() const { return _data_type; } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTrackerDevice::get_vrpn_tracker -// Access: Public -// Description: Returns a pointer to the particular VrpnTracker this -// device gets its data from. This pointer may be -// shared with other VrpnTrackerDevice objects (each -// representing a different portion of the tracker -// data). -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the particular VrpnTracker this device gets its data + * from. This pointer may be shared with other VrpnTrackerDevice objects + * (each representing a different portion of the tracker data). + */ INLINE VrpnTracker *VrpnTrackerDevice:: get_vrpn_tracker() const { return _vrpn_tracker; diff --git a/panda/src/vrpn/vrpnTrackerDevice.cxx b/panda/src/vrpn/vrpnTrackerDevice.cxx index dcbf00ee30..5484df2c23 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.cxx +++ b/panda/src/vrpn/vrpnTrackerDevice.cxx @@ -1,27 +1,24 @@ -// Filename: vrpnTrackerDevice.cxx -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTrackerDevice.cxx + * @author drose + * @date 2001-01-25 + */ #include "vrpnTrackerDevice.h" #include "vrpnClient.h" TypeHandle VrpnTrackerDevice::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: VrpnTrackerDevice::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnTrackerDevice:: VrpnTrackerDevice(VrpnClient *client, const string &device_name, int sensor, VrpnTrackerDevice::DataType data_type, @@ -33,11 +30,9 @@ VrpnTrackerDevice(VrpnClient *client, const string &device_name, { } -//////////////////////////////////////////////////////////////////// -// Function: VrpnTrackerDevice::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VrpnTrackerDevice:: ~VrpnTrackerDevice() { disconnect(); diff --git a/panda/src/vrpn/vrpnTrackerDevice.h b/panda/src/vrpn/vrpnTrackerDevice.h index ddfa0c2d4a..17a626795e 100644 --- a/panda/src/vrpn/vrpnTrackerDevice.h +++ b/panda/src/vrpn/vrpnTrackerDevice.h @@ -1,16 +1,15 @@ -// Filename: vrpnTrackerDevice.h -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpnTrackerDevice.h + * @author drose + * @date 2001-01-25 + */ #ifndef VRPNTRACKERDEVICE_H #define VRPNTRACKERDEVICE_H @@ -22,19 +21,16 @@ class VrpnClient; class VrpnTracker; -//////////////////////////////////////////////////////////////////// -// Class : VrpnTrackerDevice -// Description : The Panda interface to a VRPN tracker. This object -// will be returned by VrpnClient::make_device(), for -// attaching to a TrackerNode. -// -// It represents the data from just one particular -// sensor of a named VRPN tracker, and may reflect -// either the sensor's position, its velocity, or its -// acceleration. -// -// This class does not need to be exported from the DLL. -//////////////////////////////////////////////////////////////////// +/** + * The Panda interface to a VRPN tracker. This object will be returned by + * VrpnClient::make_device(), for attaching to a TrackerNode. + * + * It represents the data from just one particular sensor of a named VRPN + * tracker, and may reflect either the sensor's position, its velocity, or its + * acceleration. + * + * This class does not need to be exported from the DLL. + */ class VrpnTrackerDevice : public ClientTrackerDevice { public: enum DataType { diff --git a/panda/src/vrpn/vrpn_interface.h b/panda/src/vrpn/vrpn_interface.h index f9259d057a..99349922ec 100644 --- a/panda/src/vrpn/vrpn_interface.h +++ b/panda/src/vrpn/vrpn_interface.h @@ -1,16 +1,15 @@ -// Filename: vrpn_interface.h -// Created by: drose (25Jan01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrpn_interface.h + * @author drose + * @date 2001-01-25 + */ #ifndef VRPN_INTERFACE_H #define VRPN_INTERFACE_H diff --git a/panda/src/wgldisplay/config_wgldisplay.cxx b/panda/src/wgldisplay/config_wgldisplay.cxx index b3c04dc1ba..9cd4a149f3 100644 --- a/panda/src/wgldisplay/config_wgldisplay.cxx +++ b/panda/src/wgldisplay/config_wgldisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_wgldisplay.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_wgldisplay.cxx + * @author drose + * @date 2002-12-20 + */ #include "config_wgldisplay.h" #include "wglGraphicsBuffer.h" @@ -42,14 +41,12 @@ ConfigVariableBool gl_do_vidmemsize_check "fullscreen windows, no matter what resolution of window was " "requested. It only affects fullscreen windows.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libwgldisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libwgldisplay() { static bool initialized = false; diff --git a/panda/src/wgldisplay/config_wgldisplay.h b/panda/src/wgldisplay/config_wgldisplay.h index ecacc851f1..400b565bbd 100644 --- a/panda/src/wgldisplay/config_wgldisplay.h +++ b/panda/src/wgldisplay/config_wgldisplay.h @@ -1,16 +1,15 @@ -// Filename: config_wgldisplay.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_wgldisplay.h + * @author drose + * @date 2002-12-20 + */ #ifndef CONFIG_WGLDISPLAY_H #define CONFIG_WGLDISPLAY_H diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.I b/panda/src/wgldisplay/wglGraphicsBuffer.I index 9f97d81710..8963dc5389 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.I +++ b/panda/src/wgldisplay/wglGraphicsBuffer.I @@ -1,13 +1,12 @@ -// Filename: wglGraphicsBuffer.I -// Created by: drose (08Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsBuffer.I + * @author drose + * @date 2004-02-08 + */ diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index 38550e29de..c0b897a3a1 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -1,16 +1,15 @@ -// Filename: wglGraphicsBuffer.cxx -// Created by: drose (08Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsBuffer.cxx + * @author drose + * @date 2004-02-08 + */ #include "wglGraphicsBuffer.h" #include "wglGraphicsPipe.h" @@ -24,11 +23,9 @@ TypeHandle wglGraphicsBuffer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsBuffer:: wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -42,30 +39,25 @@ wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, _pbuffer = (HPBUFFERARB)0; _pbuffer_dc = (HDC)0; release_pbuffer(); - - // Since the pbuffer never gets flipped, we get screenshots from the - // same buffer we draw into. + + // Since the pbuffer never gets flipped, we get screenshots from the same + // buffer we draw into. _screenshot_buffer_type = _draw_buffer_type; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsBuffer:: ~wglGraphicsBuffer() { } - -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// + +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool wglGraphicsBuffer:: begin_frame(FrameMode mode, Thread *current_thread) { @@ -92,10 +84,10 @@ begin_frame(FrameMode mode, Thread *current_thread) { wglGraphicsPipe::wgl_make_current(0, 0, &_make_current_pcollector); return false; } - + wglGraphicsPipe::wgl_make_current(_pbuffer_dc, context, &_make_current_pcollector); - + if (mode == FM_render) { CDLockedReader cdata(_cycler); for (size_t i = 0; i != cdata->_textures.size(); ++i) { @@ -115,13 +107,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void wglGraphicsBuffer:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -131,28 +121,25 @@ end_frame(FrameMode mode, Thread *current_thread) { copy_to_textures(); bind_texture_to_pbuffer(); } - + _gsg->end_frame(current_thread); - + if (mode == FM_render) { trigger_flip(); clear_cube_map_selection(); } } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::bind_texture_to_pbuffer -// Access: Private -// Description: Looks for the appropriate texture, -// and binds that texture to the pbuffer. -//////////////////////////////////////////////////////////////////// +/** + * Looks for the appropriate texture, and binds that texture to the pbuffer. + */ void wglGraphicsBuffer:: bind_texture_to_pbuffer() { wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); - // Find the color texture, if there is one. That one can be bound to - // the framebuffer. All others must be marked RTM_copy_to_texture. + // Find the color texture, if there is one. That one can be bound to the + // framebuffer. All others must be marked RTM_copy_to_texture. int tex_index = -1; CDLockedReader cdata(_cycler); @@ -206,15 +193,11 @@ bind_texture_to_pbuffer() { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::select_target_tex_page -// Access: Public, Virtual -// Description: Called internally when the window is in -// render-to-a-texture mode and we are in the process of -// rendering the six faces of a cube map. This should -// do whatever needs to be done to switch the buffer to -// the indicated face. -//////////////////////////////////////////////////////////////////// +/** + * Called internally when the window is in render-to-a-texture mode and we are + * in the process of rendering the six faces of a cube map. This should do + * whatever needs to be done to switch the buffer to the indicated face. + */ void wglGraphicsBuffer:: select_target_tex_page(int page) { wglGraphicsStateGuardian *wglgsg; @@ -236,38 +219,31 @@ select_target_tex_page(int page) { wglgsg->_wglSetPbufferAttribARB(_pbuffer, iattrib_list); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void wglGraphicsBuffer:: process_events() { GraphicsBuffer::process_events(); MSG msg; - - // Handle all the messages on the queue in a row. Some of these - // might be for another window, but they will get dispatched - // appropriately. + + // Handle all the messages on the queue in a row. Some of these might be + // for another window, but they will get dispatched appropriately. while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { process_1_event(); } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::get_supports_render_texture -// Access: Published, Virtual -// Description: Returns true if this particular GraphicsOutput can -// render directly into a texture, or false if it must -// always copy-to-texture at the end of each frame to -// achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GraphicsOutput can render directly into a + * texture, or false if it must always copy-to-texture at the end of each + * frame to achieve this effect. + */ bool wglGraphicsBuffer:: get_supports_render_texture() const { if (_gsg == (GraphicsStateGuardian *)NULL) { @@ -279,12 +255,9 @@ get_supports_render_texture() const { return wglgsg->get_supports_wgl_render_texture(); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::close_buffer -// Access: Protected, Virtual -// Description: Closes the buffer right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the buffer right now. Called from the window thread. + */ void wglGraphicsBuffer:: close_buffer() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -293,31 +266,28 @@ close_buffer() { _gsg.clear(); } - + release_pbuffer(); - + _is_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::open_buffer -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool wglGraphicsBuffer:: open_buffer() { - // pbuffers don't seem to work correctly in double-buffered - // mode. Besides, the back buffer is a pointless waste of space. - // So always use a single-buffered gsg. - + // pbuffers don't seem to work correctly in double-buffered mode. Besides, + // the back buffer is a pointless waste of space. So always use a single- + // buffered gsg. + _fb_properties.set_back_buffers(0); _draw_buffer_type = RenderBuffer::T_front; _screenshot_buffer_type = RenderBuffer::T_front; - - // GSG creation/initialization. + + // GSG creationinitialization. wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { @@ -326,8 +296,8 @@ open_buffer() { wglgsg->choose_pixel_format(_fb_properties, true); _gsg = wglgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(wglgsg, _gsg, false); if ((!wglgsg->get_fb_properties().subsumes(_fb_properties))|| (!wglgsg->get_fb_properties().is_single_buffered())|| @@ -337,9 +307,9 @@ open_buffer() { _gsg = wglgsg; } } - + // Use the temp window to initialize the gsg. - + HDC twindow_dc = wglgsg->get_twindow_dc(); if (twindow_dc == 0) { // If we couldn't make a window, we can't get a GL context. @@ -361,35 +331,32 @@ open_buffer() { return false; } _fb_properties = wglgsg->get_fb_properties(); - - // Now that we have fully made a window and used that window to - // create a rendering context, we can attempt to create a pbuffer. - // This might fail if the pbuffer extensions are not supported. + + // Now that we have fully made a window and used that window to create a + // rendering context, we can attempt to create a pbuffer. This might fail + // if the pbuffer extensions are not supported. if (!rebuild_bitplanes()) { wglGraphicsPipe::wgl_make_current(0, 0, &_make_current_pcollector); _gsg = NULL; return false; } - + _is_valid = true; return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::release_pbuffer -// Access: Private -// Description: Destroys the pbuffer if it has been created. The -// intent is that this may allow it to be recreated -// with different options. -//////////////////////////////////////////////////////////////////// +/** + * Destroys the pbuffer if it has been created. The intent is that this may + * allow it to be recreated with different options. + */ void wglGraphicsBuffer:: release_pbuffer() { if (_gsg == 0) { return; } - + wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); @@ -412,14 +379,11 @@ release_pbuffer() { _pbuffer_type = Texture::TT_2d_texture; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::rebuild_bitplanes -// Access: Private -// Description: Once the GL context has been fully realized, attempts -// to create an offscreen pbuffer if the graphics API -// supports it. Returns true if successful, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Once the GL context has been fully realized, attempts to create an + * offscreen pbuffer if the graphics API supports it. Returns true if + * successful, false on failure. + */ bool wglGraphicsBuffer:: rebuild_bitplanes() { wglGraphicsStateGuardian *wglgsg; @@ -441,8 +405,7 @@ rebuild_bitplanes() { } } - // If we already have a pbuffer, and if it's lost, then - // force the rebuild. + // If we already have a pbuffer, and if it's lost, then force the rebuild. if (_pbuffer_dc) { int flag = 0; @@ -452,8 +415,8 @@ rebuild_bitplanes() { } } - // Determine what pbuffer attributes are needed - // for currently-applicable textures. + // Determine what pbuffer attributes are needed for currently-applicable + // textures. if ((_host != 0)&&(_creation_flags & GraphicsPipe::BF_size_track_host)) { if (_host->get_size() != _size) { @@ -479,7 +442,7 @@ rebuild_bitplanes() { (_pbuffer_sizey == desired_y)&& (_pbuffer_mipmap == desired_mipmap)&& (_pbuffer_type == desired_type)) { - // the pbuffer we already have is fine. Do not rebuild. + // the pbuffer we already have is fine. Do not rebuild. return true; } @@ -494,7 +457,7 @@ rebuild_bitplanes() { static const int max_attrib_list = 64; int iattrib_list[max_attrib_list]; int ni = 0; - + if (_fb_properties.get_alpha_bits()) { iattrib_list[ni++] = WGL_TEXTURE_FORMAT_ARB; iattrib_list[ni++] = WGL_TEXTURE_RGBA_ARB; @@ -513,17 +476,17 @@ rebuild_bitplanes() { iattrib_list[ni++] = WGL_TEXTURE_TARGET_ARB; iattrib_list[ni++] = WGL_TEXTURE_CUBE_MAP_ARB; break; - + case Texture::TT_1d_texture: iattrib_list[ni++] = WGL_TEXTURE_TARGET_ARB; iattrib_list[ni++] = WGL_TEXTURE_1D_ARB; break; - + default: iattrib_list[ni++] = WGL_TEXTURE_TARGET_ARB; iattrib_list[ni++] = WGL_TEXTURE_2D_ARB; } - + // Terminate the list. nassertr(ni <= max_attrib_list, false); iattrib_list[ni] = 0; @@ -532,7 +495,7 @@ rebuild_bitplanes() { if (twindow_dc == 0) { return false; } - + HGLRC context = wglgsg->get_context(twindow_dc); if (context == 0) { return false; @@ -540,9 +503,9 @@ rebuild_bitplanes() { wglGraphicsPipe::wgl_make_current(twindow_dc, context, &_make_current_pcollector); - _pbuffer = wglgsg->_wglCreatePbufferARB(twindow_dc, pfnum, + _pbuffer = wglgsg->_wglCreatePbufferARB(twindow_dc, pfnum, desired_x, desired_y, iattrib_list); - + if (_pbuffer == 0) { wgldisplay_cat.info() << "Attempt to create pbuffer failed.\n"; @@ -554,22 +517,20 @@ rebuild_bitplanes() { _pbuffer_type = desired_type; _pbuffer_sizex = desired_x; _pbuffer_sizey = desired_y; - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsBuffer::process_1_event -// Access: Private, Static -// Description: Handles one event from the message queue. -//////////////////////////////////////////////////////////////////// +/** + * Handles one event from the message queue. + */ void wglGraphicsBuffer:: process_1_event() { MSG msg; if (!GetMessage(&msg, NULL, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. - // DestroyAllWindows(false); + // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn } @@ -578,5 +539,3 @@ process_1_event() { // Call window_proc DispatchMessage(&msg); } - - diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.h b/panda/src/wgldisplay/wglGraphicsBuffer.h index 6e4fb286e8..e5155e8653 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.h +++ b/panda/src/wgldisplay/wglGraphicsBuffer.h @@ -1,16 +1,15 @@ -// Filename: wglGraphicsBuffer.h -// Created by: drose (08Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsBuffer.h + * @author drose + * @date 2004-02-08 + */ #ifndef WGLGRAPHICSBUFFER_H #define WGLGRAPHICSBUFFER_H @@ -19,27 +18,23 @@ #include "graphicsBuffer.h" #include "glgsg.h" -// This must be included after we have included glgsg.h (which -// includes gl.h). +// This must be included after we have included glgsg.h (which includes gl.h). #include "wglext.h" #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include -//////////////////////////////////////////////////////////////////// -// Class : wglGraphicsBuffer -// Description : An offscreen render buffer. In OpenGL under Windows, -// this simply renders into a window that is never made -// visible. There's a Windows interface for rendering -// into a DIB, but this puts restrictions on the kind of -// pixelformat we can use, and thus makes it difficult -// to support one GSG rendering into an offscreen buffer -// and also into a window. -//////////////////////////////////////////////////////////////////// +/** + * An offscreen render buffer. In OpenGL under Windows, this simply renders + * into a window that is never made visible. There's a Windows interface for + * rendering into a DIB, but this puts restrictions on the kind of pixelformat + * we can use, and thus makes it difficult to support one GSG rendering into + * an offscreen buffer and also into a window. + */ class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer { public: - wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, + wglGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -75,7 +70,7 @@ private: int _pbuffer_sizex; int _pbuffer_sizey; PT(Texture) _pbuffer_bound; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/panda/src/wgldisplay/wglGraphicsPipe.I b/panda/src/wgldisplay/wglGraphicsPipe.I index fa5493b953..1974f73690 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.I +++ b/panda/src/wgldisplay/wglGraphicsPipe.I @@ -1,14 +1,12 @@ -// Filename: wglGraphicsPipe.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsPipe.I + * @author drose + * @date 2002-12-20 + */ diff --git a/panda/src/wgldisplay/wglGraphicsPipe.cxx b/panda/src/wgldisplay/wglGraphicsPipe.cxx index a61819829b..ee2c2a7522 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.cxx +++ b/panda/src/wgldisplay/wglGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: wglGraphicsPipe.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsPipe.cxx + * @author drose + * @date 2002-12-20 + */ #include "wglGraphicsPipe.h" #include "config_wgldisplay.h" @@ -25,32 +24,25 @@ TypeHandle wglGraphicsPipe::_type_handle; bool wglGraphicsPipe::_current_valid; HDC wglGraphicsPipe::_current_hdc; HGLRC wglGraphicsPipe::_current_hglrc; - -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ wglGraphicsPipe:: wglGraphicsPipe() { _current_valid = false; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsPipe:: ~wglGraphicsPipe() { } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::wgl_make_current -// Access: Private, Static -// Description: a thin wrapper around wglMakeCurrent to avoid -// unnecessary OS-call overhead. -//////////////////////////////////////////////////////////////////// +/** + * a thin wrapper around wglMakeCurrent to avoid unnecessary OS-call overhead. + */ void wglGraphicsPipe:: wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { if ((_current_valid) && @@ -70,39 +62,30 @@ wgl_make_current(HDC hdc, HGLRC hglrc, PStatCollector *collector) { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::get_interface_name -// Access: Published, Virtual -// Description: Returns the name of the rendering interface -// associated with this GraphicsPipe. This is used to -// present to the user to allow him/her to choose -// between several possible GraphicsPipes available on a -// particular platform, so the name should be meaningful -// and unique for a given platform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the rendering interface associated with this + * GraphicsPipe. This is used to present to the user to allow him/her to + * choose between several possible GraphicsPipes available on a particular + * platform, so the name should be meaningful and unique for a given platform. + */ string wglGraphicsPipe:: get_interface_name() const { return "OpenGL"; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::pipe_constructor -// Access: Public, Static -// Description: This function is passed to the GraphicsPipeSelection -// object to allow the user to make a default -// wglGraphicsPipe. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the GraphicsPipeSelection object to allow the + * user to make a default wglGraphicsPipe. + */ PT(GraphicsPipe) wglGraphicsPipe:: pipe_constructor() { return new wglGraphicsPipe; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::make_output -// Access: Protected, Virtual -// Description: Creates a new window or buffer on the pipe, if possible. -// This routine is only called from GraphicsEngine::make_output. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new window or buffer on the pipe, if possible. This routine is + * only called from GraphicsEngine::make_output. + */ PT(GraphicsOutput) wglGraphicsPipe:: make_output(const string &name, const FrameBufferProperties &fb_prop, @@ -113,7 +96,7 @@ make_output(const string &name, GraphicsOutput *host, int retry, bool &precertify) { - + if (!_is_valid) { return NULL; } @@ -126,8 +109,8 @@ make_output(const string &name, bool support_rtt; support_rtt = false; if (wglgsg) { - support_rtt = - wglgsg -> get_supports_wgl_render_texture() && + support_rtt = + wglgsg -> get_supports_wgl_render_texture() && support_render_texture; } @@ -162,8 +145,8 @@ make_output(const string &name, (flags & (BF_require_parasite | BF_require_window)) != 0) { return NULL; } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if (fb_prop.get_indexed_color() || fb_prop.get_back_buffers() > 0 || @@ -176,17 +159,17 @@ make_output(const string &name, wglgsg->_glDrawBuffers == NULL) { return NULL; } else { - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify it. + // Early success - if we are sure that this buffer WILL meet specs, we + // can precertify it. precertify = true; } } return new GLGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Third thing to try: a wglGraphicsBuffer - + if (retry == 2) { if (((flags&BF_require_parasite)!=0)|| ((flags&BF_require_window)!=0)|| @@ -196,21 +179,21 @@ make_output(const string &name, if ((wglgsg != 0) && (wglgsg->is_valid()) && (!wglgsg->needs_reset()) && - !wglgsg->_supports_pbuffer) { + !wglgsg->_supports_pbuffer) { return NULL; } if (!support_rtt) { if (((flags&BF_rtt_cumulative)!=0)|| ((flags&BF_can_bind_every)!=0)) { - // If we require Render-to-Texture, but can't be sure we - // support it, bail. + // If we require Render-to-Texture, but can't be sure we support it, + // bail. return NULL; } } - // Early failure - if we are sure that this buffer WONT - // meet specs, we can bail out early. + // Early failure - if we are sure that this buffer WONT meet specs, we can + // bail out early. if ((flags & BF_fb_props_optional) == 0) { if ((fb_prop.get_aux_rgba() > 0)|| (fb_prop.get_aux_rgba() > 0)|| @@ -218,8 +201,8 @@ make_output(const string &name, return NULL; } } - // Early success - if we are sure that this buffer WILL - // meet specs, we can precertify the window. + // Early success - if we are sure that this buffer WILL meet specs, we can + // precertify the window. if ((wglgsg != 0) && (wglgsg->is_valid()) && (!wglgsg->needs_reset()) && @@ -231,32 +214,26 @@ make_output(const string &name, return new wglGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host); } - + // Nothing else left to try. return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::make_callback_gsg -// Access: Protected, Virtual -// Description: This is called when make_output() is used to create a -// CallbackGraphicsWindow. If the GraphicsPipe can -// construct a GSG that's not associated with any -// particular window object, do so now, assuming the -// correct graphics context has been set up externally. -//////////////////////////////////////////////////////////////////// +/** + * This is called when make_output() is used to create a + * CallbackGraphicsWindow. If the GraphicsPipe can construct a GSG that's not + * associated with any particular window object, do so now, assuming the + * correct graphics context has been set up externally. + */ PT(GraphicsStateGuardian) wglGraphicsPipe:: make_callback_gsg(GraphicsEngine *engine) { return new wglGraphicsStateGuardian(engine, this, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsPipe::format_pfd_flags -// Access: Private, Static -// Description: Returns pfd_flags formatted as a string in a -// user-friendly way. -//////////////////////////////////////////////////////////////////// +/** + * Returns pfd_flags formatted as a string in a user-friendly way. + */ string wglGraphicsPipe:: format_pfd_flags(DWORD pfd_flags) { struct FlagDef { diff --git a/panda/src/wgldisplay/wglGraphicsPipe.h b/panda/src/wgldisplay/wglGraphicsPipe.h index ed631e3a55..2ac6d8d29d 100644 --- a/panda/src/wgldisplay/wglGraphicsPipe.h +++ b/panda/src/wgldisplay/wglGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: wglGraphicsPipe.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsPipe.h + * @author drose + * @date 2002-12-20 + */ #ifndef WGLGRAPHICSPIPE_H #define WGLGRAPHICSPIPE_H @@ -20,12 +19,10 @@ class wglGraphicsStateGuardian; -//////////////////////////////////////////////////////////////////// -// Class : wglGraphicsPipe -// Description : This graphics pipe represents the interface for -// creating OpenGL graphics windows on the various -// Windows OSes. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating OpenGL graphics + * windows on the various Windows OSes. + */ class EXPCL_PANDAGL wglGraphicsPipe : public WinGraphicsPipe { public: wglGraphicsPipe(); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.I b/panda/src/wgldisplay/wglGraphicsStateGuardian.I index 7c652f1123..3d1410487a 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.I +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.I @@ -1,82 +1,64 @@ -// Filename: wglGraphicsStateGuardian.I -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsStateGuardian.I + * @author drose + * @date 2003-01-27 + */ -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_pfnum -// Access: Public -// Description: Returns the pixel format number chosen for windows -// that use this context. In OpenGL under Microsoft -// Windows, the window must be created first and then -// the GL context is created from the window, and the -// context inherits the pixel format of the window. -// Therefore, all windows that share a particular -// context must also share the same pixel format. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pixel format number chosen for windows that use this context. + * In OpenGL under Microsoft Windows, the window must be created first and + * then the GL context is created from the window, and the context inherits + * the pixel format of the window. Therefore, all windows that share a + * particular context must also share the same pixel format. + */ INLINE int wglGraphicsStateGuardian:: get_pfnum() const { return _pfnum; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::pfnum_supports_pbuffer -// Access: Public -// Description: Returns true if the gsg's pixel format is capable -// of supporting a pbuffer. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the gsg's pixel format is capable of supporting a pbuffer. + */ INLINE bool wglGraphicsStateGuardian:: pfnum_supports_pbuffer() const { return _pfnum_supports_pbuffer; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_fb_properties -// Access: Public -// Description: Returns the properties of the pixel format that -// was chosen for this gsg. In OpenGL under Microsoft -// Windows, the window must be created first and then -// the GL context is created from the window, and the -// context inherits the pixel format of the window. -// Therefore, all windows that share a particular -// context must also share the same pixel format. -//////////////////////////////////////////////////////////////////// +/** + * Returns the properties of the pixel format that was chosen for this gsg. + * In OpenGL under Microsoft Windows, the window must be created first and + * then the GL context is created from the window, and the context inherits + * the pixel format of the window. Therefore, all windows that share a + * particular context must also share the same pixel format. + */ INLINE const FrameBufferProperties &wglGraphicsStateGuardian:: get_fb_properties() const { return _pfnum_properties; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::made_context -// Access: Public -// Description: Returns true if the GSG has had a context made for it -// already, false otherwise. If this returns false, the -// next call to get_context() will quietly make a new -// context. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the GSG has had a context made for it already, false + * otherwise. If this returns false, the next call to get_context() will + * quietly make a new context. + */ INLINE bool wglGraphicsStateGuardian:: made_context() const { return _made_context; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_context -// Access: Public -// Description: Returns the GL context associated with the GSG. If -// the context has not yet been created, this creates a -// suitable context for rendering to the indicated -// window. This means that this method may only be -// called from within the draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GL context associated with the GSG. If the context has not yet + * been created, this creates a suitable context for rendering to the + * indicated window. This means that this method may only be called from + * within the draw thread. + */ INLINE HGLRC wglGraphicsStateGuardian:: get_context(HDC hdc) { if (!_made_context) { @@ -85,13 +67,10 @@ get_context(HDC hdc) { return _context; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_twindow_dc -// Access: Public -// Description: Returns the DC associated with the temporary, -// invisible window that was created with the gsg to -// query WGL extensions. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DC associated with the temporary, invisible window that was + * created with the gsg to query WGL extensions. + */ INLINE HDC wglGraphicsStateGuardian:: get_twindow_dc() { if (_twindow_dc == 0) { @@ -100,14 +79,11 @@ get_twindow_dc() { return _twindow_dc; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_supports_wgl_render_texture -// Access: Published -// Description: Returns true if this particular GSG can render -// from a wglGraphicsBuffer directly into a texture, or -// false if it must always copy-to-texture at the end of -// each frame to achieve this effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular GSG can render from a wglGraphicsBuffer + * directly into a texture, or false if it must always copy-to-texture at the + * end of each frame to achieve this effect. + */ INLINE bool wglGraphicsStateGuardian:: get_supports_wgl_render_texture() const { return _supports_wgl_render_texture; diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx index 575b79931d..9d916129a4 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.cxx @@ -1,16 +1,15 @@ -// Filename: wglGraphicsStateGuardian.cxx -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsStateGuardian.cxx + * @author drose + * @date 2003-01-27 + */ #include "wglGraphicsStateGuardian.h" #include "config_wgldisplay.h" @@ -23,11 +22,9 @@ TypeHandle wglGraphicsStateGuardian::_type_handle; const char * const wglGraphicsStateGuardian::_twindow_class_name = "wglGraphicsStateGuardian"; bool wglGraphicsStateGuardian::_twindow_class_registered = false; -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsStateGuardian:: wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, wglGraphicsStateGuardian *share_with) : @@ -55,11 +52,9 @@ wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, atexit(atexit_function); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsStateGuardian:: ~wglGraphicsStateGuardian() { release_twindow(); @@ -69,24 +64,19 @@ wglGraphicsStateGuardian:: } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::fail_pfnum -// Access: Public -// Description: This is called by wglGraphicsWindow when it finds it -// cannot use the pfnum determined by the GSG. Assuming -// this pfnum corresponds to an "advanced" frame buffer -// determined by wglChoosePixelFormatARB, this asks the -// GSG to swap out that pfnum for the earlier, -// "preliminary" pfnum determined via -// DescribePixelFormat(). -// -// This is a one-way operation. Once called, you can -// never go back to the advanced pfnum. -// -// This method returns true if a change was successfully -// made, or false if there was no second tier to fall -// back to. -//////////////////////////////////////////////////////////////////// +/** + * This is called by wglGraphicsWindow when it finds it cannot use the pfnum + * determined by the GSG. Assuming this pfnum corresponds to an "advanced" + * frame buffer determined by wglChoosePixelFormatARB, this asks the GSG to + * swap out that pfnum for the earlier, "preliminary" pfnum determined via + * DescribePixelFormat(). + * + * This is a one-way operation. Once called, you can never go back to the + * advanced pfnum. + * + * This method returns true if a change was successfully made, or false if + * there was no second tier to fall back to. + */ bool wglGraphicsStateGuardian:: fail_pfnum() { if (_pfnum == _pre_pfnum) { @@ -99,12 +89,10 @@ fail_pfnum() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_properties -// Access: Private -// Description: Gets the FrameBufferProperties to match the -// indicated pixel format descriptor. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated pixel format + * descriptor. + */ void wglGraphicsStateGuardian:: get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { @@ -120,8 +108,8 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { if (((pfd.dwFlags & PFD_SUPPORT_OPENGL) == 0)|| ((pfd.dwFlags & PFD_DRAW_TO_WINDOW) == 0)) { - // Return without setting either RGB or Indexed Color. - // This indicates a window that can't do anything at all. + // Return without setting either RGB or Indexed Color. This indicates a + // window that can't do anything at all. return; } @@ -158,13 +146,10 @@ get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum) { // The basic API doesn't do accum or multisample. } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_properties_advanced -// Access: Private -// Description: Gets the FrameBufferProperties to match the -// indicated pixel format descriptor, using the WGL -// extensions. -//////////////////////////////////////////////////////////////////// +/** + * Gets the FrameBufferProperties to match the indicated pixel format + * descriptor, using the WGL extensions. + */ bool wglGraphicsStateGuardian:: get_properties_advanced(FrameBufferProperties &properties, HDC window_dc, int pfnum) { @@ -260,20 +245,16 @@ get_properties_advanced(FrameBufferProperties &properties, return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::choose_pixel_format -// Access: Private -// Description: Selects a pixel format for all the windows and -// buffers that use this gsg. -//////////////////////////////////////////////////////////////////// +/** + * Selects a pixel format for all the windows and buffers that use this gsg. + */ void wglGraphicsStateGuardian:: choose_pixel_format(const FrameBufferProperties &properties, bool need_pbuffer) { - //// Choose best format available using DescribePixelFormat. - // - // In the process, we need a DC to examine the available - // pixel formats. We'll use the screen DC. + // Choose best format available using DescribePixelFormat. In the process, + // we need a DC to examine the available pixel formats. We'll use the + // screen DC. if (gl_force_pixfmt.has_value()) { wgldisplay_cat.info() @@ -324,13 +305,11 @@ choose_pixel_format(const FrameBufferProperties &properties, << _pfnum_properties << "\n"; } - //// See whether or not the wgl extensions are available. - // - // This routine is called before "reset". So the extensions - // list is empty. We need to create a twindow, make it current, - // fetch the extensions temporarily, get the few extensions - // we need, then clear the extensions list again in preparation - // for the reset. + // See whether or not the wgl extensions are available. This routine is + // called before "reset". So the extensions list is empty. We need to + // create a twindow, make it current, fetch the extensions temporarily, get + // the few extensions we need, then clear the extensions list again in + // preparation for the reset. HDC twindow_dc = get_twindow_dc(); if (twindow_dc == 0) { @@ -380,8 +359,7 @@ choose_pixel_format(const FrameBufferProperties &properties, return; } - //// Use the wgl extensions to find a better format. - // + // Use the wgl extensions to find a better format. static const int max_attrib_list = 64; int iattrib_list[max_attrib_list]; @@ -468,12 +446,9 @@ choose_pixel_format(const FrameBufferProperties &properties, release_twindow(); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::reset -// Access: Public, Virtual -// Description: Resets all internal state as if the gsg were newly -// created. -//////////////////////////////////////////////////////////////////// +/** + * Resets all internal state as if the gsg were newly created. + */ void wglGraphicsStateGuardian:: reset() { GLGraphicsStateGuardian::reset(); @@ -491,8 +466,8 @@ reset() { } if (_supports_swap_control) { - // Set the video-sync setting up front, if we have the extension - // that supports it. + // Set the video-sync setting up front, if we have the extension that + // supports it. _wglSwapIntervalEXT(sync_video ? 1 : 0); } @@ -561,21 +536,18 @@ reset() { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_extra_extensions -// Access: Protected, Virtual -// Description: This may be redefined by a derived class (e.g. glx or -// wgl) to get whatever further extensions strings may -// be appropriate to that interface, in addition to the -// GL extension strings return by glGetString(). -//////////////////////////////////////////////////////////////////// +/** + * This may be redefined by a derived class (e.g. glx or wgl) to get whatever + * further extensions strings may be appropriate to that interface, in + * addition to the GL extension strings return by glGetString(). + */ void wglGraphicsStateGuardian:: get_extra_extensions() { - // This is a little bit tricky, since the query function is itself - // an extension. + // This is a little bit tricky, since the query function is itself an + // extension. - // Look for the ARB flavor first, which wants one parameter, the HDC - // of the drawing context. + // Look for the ARB flavor first, which wants one parameter, the HDC of the + // drawing context. PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB"); if (wglGetExtensionsStringARB != NULL) { @@ -586,8 +558,7 @@ get_extra_extensions() { } } - // If that failed, look for the EXT flavor, which wants no - // parameters. + // If that failed, look for the EXT flavor, which wants no parameters. PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)wglGetProcAddress("wglGetExtensionsStringEXT"); if (wglGetExtensionsStringEXT != NULL) { @@ -595,28 +566,21 @@ get_extra_extensions() { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::do_get_extension_func -// Access: Public, Virtual -// Description: Returns the pointer to the GL extension function with -// the indicated name. It is the responsibility of the -// caller to ensure that the required extension is -// defined in the OpenGL runtime prior to calling this; -// it is an error to call this for a function that is -// not defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns the pointer to the GL extension function with the indicated name. + * It is the responsibility of the caller to ensure that the required + * extension is defined in the OpenGL runtime prior to calling this; it is an + * error to call this for a function that is not defined. + */ void *wglGraphicsStateGuardian:: do_get_extension_func(const char *name) { return (void*) wglGetProcAddress(name); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::make_context -// Access: Private -// Description: Creates a suitable context for rendering into the -// given window. This should only be called from the -// draw thread. -//////////////////////////////////////////////////////////////////// +/** + * Creates a suitable context for rendering into the given window. This + * should only be called from the draw thread. + */ void wglGraphicsStateGuardian:: make_context(HDC hdc) { // We should only call this once for a particular GSG. @@ -628,8 +592,8 @@ make_context(HDC hdc) { wglGraphicsPipe::_current_valid = false; if (_wglCreateContextAttribsARB != NULL) { - // We have a fancier version of wglCreateContext that allows us - // to specify what kind of OpenGL context we would like. + // We have a fancier version of wglCreateContext that allows us to specify + // what kind of OpenGL context we would like. int attrib_list[32]; int n = 0; attrib_list[0] = NULL; @@ -668,17 +632,17 @@ make_context(HDC hdc) { if (_share_with != (wglGraphicsStateGuardian *)NULL) { HGLRC share_context = _share_with->get_share_context(); if (share_context == NULL) { - // Whoops, the target context hasn't yet made its own context. - // In that case, it will share context with us. + // Whoops, the target context hasn't yet made its own context. In that + // case, it will share context with us. _share_with->redirect_share_pool(this); } else { if (!wglShareLists(share_context, _context)) { wgldisplay_cat.error() << "Could not share texture contexts between wglGraphicsStateGuardians.\n"; - // Too bad we couldn't detect this error sooner. Now there's - // really no way to tell the application it's hosed. - _is_valid = false; + // Too bad we couldn't detect this error sooner. Now there's really + // no way to tell the application it's hosed. + _is_valid = false; } else { _prepared_objects = _share_with->get_prepared_objects(); @@ -689,17 +653,13 @@ make_context(HDC hdc) { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_share_context -// Access: Private -// Description: Returns a wgl context handle for the purpose of -// sharing texture context with this GSG. This will -// either be the GSG's own context handle, if it exists -// yet, or the context handle of some other GSG that -// this GSG is planning to share with. If this returns -// NULL, none of the GSG's in this share pool have yet -// created their context. -//////////////////////////////////////////////////////////////////// +/** + * Returns a wgl context handle for the purpose of sharing texture context + * with this GSG. This will either be the GSG's own context handle, if it + * exists yet, or the context handle of some other GSG that this GSG is + * planning to share with. If this returns NULL, none of the GSG's in this + * share pool have yet created their context. + */ HGLRC wglGraphicsStateGuardian:: get_share_context() const { if (_made_context) { @@ -711,19 +671,14 @@ get_share_context() const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::redirect_share_pool -// Access: Private -// Description: Directs the GSG (along with all GSG's it is planning -// to share a texture context with) to share texture -// context with the indicated GSG. -// -// This assumes that this GSG's context has not yet been -// created, and neither have any of the GSG's it is -// planning to share texture context with; but the -// graphics context for the indicated GSG has already -// been created. -//////////////////////////////////////////////////////////////////// +/** + * Directs the GSG (along with all GSG's it is planning to share a texture + * context with) to share texture context with the indicated GSG. + * + * This assumes that this GSG's context has not yet been created, and neither + * have any of the GSG's it is planning to share texture context with; but the + * graphics context for the indicated GSG has already been created. + */ void wglGraphicsStateGuardian:: redirect_share_pool(wglGraphicsStateGuardian *share_with) { nassertv(!_made_context); @@ -734,16 +689,12 @@ redirect_share_pool(wglGraphicsStateGuardian *share_with) { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::make_twindow -// Access: Private -// Description: Creates an invisible window to associate with the GL -// context, even if we are not going to use it. This is -// necessary because in the Windows OpenGL API, we have -// to create window before we can create a GL -// context--even before we can ask about what GL -// extensions are available! -//////////////////////////////////////////////////////////////////// +/** + * Creates an invisible window to associate with the GL context, even if we + * are not going to use it. This is necessary because in the Windows OpenGL + * API, we have to create window before we can create a GL context--even + * before we can ask about what GL extensions are available! + */ bool wglGraphicsStateGuardian:: make_twindow() { release_twindow(); @@ -776,13 +727,10 @@ make_twindow() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::release_twindow -// Access: Private -// Description: Closes and frees the resources associated with the -// temporary window created by a previous call to -// make_twindow(). -//////////////////////////////////////////////////////////////////// +/** + * Closes and frees the resources associated with the temporary window created + * by a previous call to make_twindow(). + */ void wglGraphicsStateGuardian:: release_twindow() { if (_twindow_dc) { @@ -795,13 +743,10 @@ release_twindow() { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::register_twindow_class -// Access: Private, Static -// Description: Registers a Window class for the twindow created by -// all wglGraphicsPipes. This only needs to be done -// once per session. -//////////////////////////////////////////////////////////////////// +/** + * Registers a Window class for the twindow created by all wglGraphicsPipes. + * This only needs to be done once per session. + */ void wglGraphicsStateGuardian:: register_twindow_class() { if (_twindow_class_registered) { @@ -882,11 +827,9 @@ void _create_gamma_table (PN_stdfloat gamma, unsigned short *original_red_table, } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::get_gamma_table -// Access: Public, Static -// Description: Static function for getting the original gamma. -//////////////////////////////////////////////////////////////////// +/** + * Static function for getting the original gamma. + */ bool wglGraphicsStateGuardian:: get_gamma_table(void) { bool get; @@ -908,12 +851,9 @@ get_gamma_table(void) { return get; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::static_set_gamma -// Access: Public, Static -// Description: Static function for setting gamma which is needed -// for atexit. -//////////////////////////////////////////////////////////////////// +/** + * Static function for setting gamma which is needed for atexit. + */ bool wglGraphicsStateGuardian:: static_set_gamma(bool restore, PN_stdfloat gamma) { bool set; @@ -940,12 +880,9 @@ static_set_gamma(bool restore, PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::set_gamma -// Access: Published -// Description: Non static version of setting gamma. Returns true -// on success. -//////////////////////////////////////////////////////////////////// +/** + * Non static version of setting gamma. Returns true on success. + */ bool wglGraphicsStateGuardian:: set_gamma(PN_stdfloat gamma) { bool set; @@ -958,21 +895,17 @@ set_gamma(PN_stdfloat gamma) { return set; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::restore_gamma -// Access: Published -// Description: Restore original gamma. -//////////////////////////////////////////////////////////////////// +/** + * Restore original gamma. + */ void wglGraphicsStateGuardian:: restore_gamma() { static_set_gamma(true, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsStateGuardian::atexit_function -// Access: Public, Static -// Description: This function is passed to the atexit function. -//////////////////////////////////////////////////////////////////// +/** + * This function is passed to the atexit function. + */ void wglGraphicsStateGuardian:: atexit_function(void) { static_set_gamma(true, 1.0); diff --git a/panda/src/wgldisplay/wglGraphicsStateGuardian.h b/panda/src/wgldisplay/wglGraphicsStateGuardian.h index b76dac9578..fd4162eadb 100644 --- a/panda/src/wgldisplay/wglGraphicsStateGuardian.h +++ b/panda/src/wgldisplay/wglGraphicsStateGuardian.h @@ -1,16 +1,15 @@ -// Filename: wglGraphicsStateGuardian.h -// Created by: drose (27Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsStateGuardian.h + * @author drose + * @date 2003-01-27 + */ #ifndef WGLGRAPHICSSTATEGUARDIAN_H #define WGLGRAPHICSSTATEGUARDIAN_H @@ -19,15 +18,13 @@ #include "glgsg.h" -// This must be included after we have included glgsg.h (which -// includes gl.h). +// This must be included after we have included glgsg.h (which includes gl.h). #include "wglext.h" -//////////////////////////////////////////////////////////////////// -// Class : wglGraphicsStateGuardian -// Description : A tiny specialization on GLGraphicsStateGuardian to -// add some wgl-specific information. -//////////////////////////////////////////////////////////////////// +/** + * A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific + * information. + */ class wglGraphicsStateGuardian : public GLGraphicsStateGuardian { public: wglGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -64,16 +61,15 @@ private: void make_context(HDC hdc); HGLRC get_share_context() const; void redirect_share_pool(wglGraphicsStateGuardian *share_with); - + bool make_twindow(); void release_twindow(); static void register_twindow_class(); - // We have to save a pointer to the GSG we intend to share texture - // context with, since we don't create our own context in the - // constructor. + // We have to save a pointer to the GSG we intend to share texture context + // with, since we don't create our own context in the constructor. PT(wglGraphicsStateGuardian) _share_with; // These properties are for all wglGraphicsWindow that use this gsg. @@ -81,8 +77,8 @@ private: bool _pfnum_supports_pbuffer; int _pfnum; - // This pfnum is the pfnum chosen via DescribePixelFormat. It is - // used in case the one returned by wglChoosePixelFormatARB() fails. + // This pfnum is the pfnum chosen via DescribePixelFormat. It is used in + // case the one returned by wglChoosePixelFormatARB() fails. FrameBufferProperties _pre_pfnum_properties; int _pre_pfnum; diff --git a/panda/src/wgldisplay/wglGraphicsWindow.I b/panda/src/wgldisplay/wglGraphicsWindow.I index 1467bf73df..4a92ca7919 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.I +++ b/panda/src/wgldisplay/wglGraphicsWindow.I @@ -1,13 +1,12 @@ -// Filename: wglGraphicsWindow.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsWindow.I + * @author drose + * @date 2002-12-20 + */ diff --git a/panda/src/wgldisplay/wglGraphicsWindow.cxx b/panda/src/wgldisplay/wglGraphicsWindow.cxx index bf724f3a5f..d6fe0799b9 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.cxx +++ b/panda/src/wgldisplay/wglGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: wglGraphicsWindow.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsWindow.cxx + * @author drose + * @date 2002-12-20 + */ #include "wglGraphicsWindow.h" #include "config_wgldisplay.h" @@ -24,13 +23,11 @@ TypeHandle wglGraphicsWindow::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsWindow:: -wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, +wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, @@ -42,24 +39,19 @@ wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, _hdc = (HDC)0; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ wglGraphicsWindow:: ~wglGraphicsWindow() { } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool wglGraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { @@ -80,31 +72,29 @@ begin_frame(FrameMode mode, Thread *current_thread) { wgldisplay_cat.spam() << "Drawing " << this << ": exposed.\n"; } - + wglGraphicsStateGuardian *wglgsg; DCAST_INTO_R(wglgsg, _gsg, false); - + HGLRC context = wglgsg->get_context(_hdc); nassertr(context, false); - + wglGraphicsPipe::wgl_make_current(_hdc, context, &_make_current_pcollector); wglgsg->reset_if_new(); if (mode == FM_render) { clear_cube_map_selection(); } - + _gsg->set_current_properties(&get_fb_properties()); return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void wglGraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -123,46 +113,39 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void wglGraphicsWindow:: begin_flip() { } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::ready_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip when command, but will not actually flip -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip when command, but + * will not actually flip + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void wglGraphicsWindow:: ready_flip() { if (_hdc) { - // The documentation on SwapBuffers() is not at all clear on - // whether the GL context needs to be current before it can be - // called. Empirically, it appears that it is not necessary in - // many cases, but it definitely is necessary at least in the case - // of Mesa on Windows. + // The documentation on SwapBuffers() is not at all clear on whether the + // GL context needs to be current before it can be called. Empirically, + // it appears that it is not necessary in many cases, but it definitely is + // necessary at least in the case of Mesa on Windows. wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); HGLRC context = wglgsg->get_context(_hdc); @@ -172,24 +155,20 @@ ready_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::end_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after begin_flip() has been called on all windows, to -// finish the exchange of the front and back buffers. -// -// This should cause the window to wait for the flip, if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after begin_flip() has + * been called on all windows, to finish the exchange of the front and back + * buffers. + * + * This should cause the window to wait for the flip, if necessary. + */ void wglGraphicsWindow:: end_flip() { if (_hdc != NULL && _flip_ready) { - // The documentation on SwapBuffers() is not at all clear on - // whether the GL context needs to be current before it can be - // called. Empirically, it appears that it is not necessary in - // many cases, but it definitely is necessary at least in the case - // of Mesa on Windows. + // The documentation on SwapBuffers() is not at all clear on whether the + // GL context needs to be current before it can be called. Empirically, + // it appears that it is not necessary in many cases, but it definitely is + // necessary at least in the case of Mesa on Windows. wglGraphicsStateGuardian *wglgsg; DCAST_INTO_V(wglgsg, _gsg); HGLRC context = wglgsg->get_context(_hdc); @@ -200,12 +179,9 @@ end_flip() { WinGraphicsWindow::end_flip(); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void wglGraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -217,20 +193,17 @@ close_window() { WinGraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool wglGraphicsWindow:: open_window() { if (!WinGraphicsWindow::open_window()) { return false; } - // GSG creation/initialization. + // GSG creationinitialization. wglGraphicsStateGuardian *wglgsg; if (_gsg == 0) { @@ -239,8 +212,8 @@ open_window() { wglgsg->choose_pixel_format(_fb_properties, false); _gsg = wglgsg; } else { - // If the old gsg has the wrong pixel format, create a - // new one that shares with the old gsg. + // If the old gsg has the wrong pixel format, create a new one that shares + // with the old gsg. DCAST_INTO_R(wglgsg, _gsg, false); if (!wglgsg->get_fb_properties().subsumes(_fb_properties)) { wglgsg = new wglGraphicsStateGuardian(_engine, _pipe, wglgsg); @@ -248,13 +221,13 @@ open_window() { _gsg = wglgsg; } } - + // Set up the pixel format of the window appropriately for GL. _hdc = GetDC(_hWnd); int pfnum = wglgsg->get_pfnum(); PIXELFORMATDESCRIPTOR pixelformat; - DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), + DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pixelformat); #ifdef NOTIFY_DEBUG @@ -268,19 +241,19 @@ open_window() { if (!set_pfnum) { if (wglgsg->fail_pfnum()) { wgldisplay_cat.error() - << "SetPixelFormat(" << pfnum << ") failed; trying " + << "SetPixelFormat(" << pfnum << ") failed; trying " << wglgsg->get_pfnum() << " instead\n"; pfnum = wglgsg->get_pfnum(); - DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), + DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pixelformat); #ifdef NOTIFY_DEBUG sprintf(msg, "Selected GL PixelFormat is #%d", pfnum); print_pfd(&pixelformat, msg); #endif - - DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), + + DescribePixelFormat(_hdc, pfnum, sizeof(PIXELFORMATDESCRIPTOR), &pixelformat); set_pfnum = SetPixelFormat(_hdc, pfnum, &pixelformat); } @@ -329,13 +302,10 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::setup_colormap -// Access: Private -// Description: Sets up a colormap for the window matching the -// selected pixel format. This is necessary before -// creating a GL context. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a colormap for the window matching the selected pixel format. This + * is necessary before creating a GL context. + */ void wglGraphicsWindow:: setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat) { LOGPALETTE *logical; @@ -387,15 +357,13 @@ setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat) { #ifdef NOTIFY_DEBUG -//typedef enum {Software, MCD, ICD} OGLDriverType; +// typedef enum {Software, MCD, ICD} OGLDriverType; static char *OGLDrvStrings[3] = {"Software","MCD","ICD"}; -//////////////////////////////////////////////////////////////////// -// Function: wglGraphicsWindow::print_pfd -// Access: Private, Static -// Description: Reports information about the selected pixel format -// descriptor, along with the indicated message. -//////////////////////////////////////////////////////////////////// +/** + * Reports information about the selected pixel format descriptor, along with + * the indicated message. + */ void wglGraphicsWindow:: print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { if (!wgldisplay_cat.is_debug()) { @@ -403,7 +371,7 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { } OGLDriverType drvtype; - if ((pfd->dwFlags & PFD_GENERIC_ACCELERATED) && + if ((pfd->dwFlags & PFD_GENERIC_ACCELERATED) && (pfd->dwFlags & PFD_GENERIC_FORMAT)) { drvtype=MCD; } else if (!(pfd->dwFlags & PFD_GENERIC_ACCELERATED) && !(pfd->dwFlags & PFD_GENERIC_FORMAT)) { @@ -418,8 +386,8 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { wgldisplay_cat.debug() << msg << ", " << OGLDrvStrings[drvtype] << " driver\n" - << "PFD flags: 0x" << (void*)pfd->dwFlags << " (" - << PRINT_FLAG(GENERIC_ACCELERATED) + << "PFD flags: 0x" << (void*)pfd->dwFlags << " (" + << PRINT_FLAG(GENERIC_ACCELERATED) << PRINT_FLAG(GENERIC_FORMAT) << PRINT_FLAG(DOUBLEBUFFER) << PRINT_FLAG(SUPPORT_OPENGL) @@ -447,4 +415,3 @@ print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg) { << endl; } #endif - diff --git a/panda/src/wgldisplay/wglGraphicsWindow.h b/panda/src/wgldisplay/wglGraphicsWindow.h index 15720f06e8..9236640876 100644 --- a/panda/src/wgldisplay/wglGraphicsWindow.h +++ b/panda/src/wgldisplay/wglGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: wglGraphicsWindow.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wglGraphicsWindow.h + * @author drose + * @date 2002-12-20 + */ #ifndef WGLGRAPHICSWINDOW_H #define WGLGRAPHICSWINDOW_H @@ -18,14 +17,12 @@ #include "pandabase.h" #include "winGraphicsWindow.h" -//////////////////////////////////////////////////////////////////// -// Class : wglGraphicsWindow -// Description : A single graphics window for rendering OpenGL under -// Microsoft Windows. -//////////////////////////////////////////////////////////////////// +/** + * A single graphics window for rendering OpenGL under Microsoft Windows. + */ class EXPCL_PANDAGL wglGraphicsWindow : public WinGraphicsWindow { public: - wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, + wglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, diff --git a/panda/src/windisplay/config_windisplay.cxx b/panda/src/windisplay/config_windisplay.cxx index 4d8f8efc5b..65447af18d 100644 --- a/panda/src/windisplay/config_windisplay.cxx +++ b/panda/src/windisplay/config_windisplay.cxx @@ -1,16 +1,15 @@ -// Filename: config_windisplay.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_windisplay.cxx + * @author drose + * @date 2002-12-20 + */ #include "config_windisplay.h" #include "winGraphicsPipe.h" @@ -83,14 +82,12 @@ ConfigVariableBool swapbuffer_framelock ("swapbuffer-framelock", false, PRC_DESC("Set this true to enable HW swapbuffer frame-lock on 3dlabs cards")); -//////////////////////////////////////////////////////////////////// -// Function: init_libwindisplay -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libwindisplay() { static bool initialized = false; diff --git a/panda/src/windisplay/config_windisplay.h b/panda/src/windisplay/config_windisplay.h index a620b4e64a..3256287f5b 100644 --- a/panda/src/windisplay/config_windisplay.h +++ b/panda/src/windisplay/config_windisplay.h @@ -1,16 +1,15 @@ -// Filename: config_windisplay.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_windisplay.h + * @author drose + * @date 2002-12-20 + */ #ifndef CONFIG_WINDISPLAY_H #define CONFIG_WINDISPLAY_H diff --git a/panda/src/windisplay/winDetectDx.h b/panda/src/windisplay/winDetectDx.h index b88901143d..b57c6575a0 100644 --- a/panda/src/windisplay/winDetectDx.h +++ b/panda/src/windisplay/winDetectDx.h @@ -1,16 +1,15 @@ -// Filename: winDetectDx.h -// Created by: aignacio (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winDetectDx.h + * @author aignacio + * @date 2007-01-18 + */ #include #include "displayInformation.h" @@ -52,13 +51,13 @@ static int d3d_format_to_bits_per_pixel (D3DFORMAT d3d_format) { int bits_per_pixel; format_index = 0; - bits_per_pixel = 0; + bits_per_pixel = 0; while (display_format_array [format_index].d3d_format != D3DFMT_UNKNOWN) { if (d3d_format == display_format_array [format_index].d3d_format) { - bits_per_pixel = display_format_array [format_index].bits_per_pixel; + bits_per_pixel = display_format_array [format_index].bits_per_pixel; break; } - + format_index++; } @@ -111,7 +110,7 @@ static DWORD print_GetLastError (char *message_prefix) static int get_display_information (DisplaySearchParameters &display_search_parameters, DisplayInformation *display_information) { int debug = false; - + int success; DisplayInformation::DetectionState state; int get_adapter_display_mode_state; @@ -167,7 +166,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para video_memory = 0; texture_memory = 0; - state = DisplayInformation::DS_unknown; + state = DisplayInformation::DS_unknown; get_adapter_display_mode_state = false; get_device_caps_state = false; @@ -185,7 +184,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para month = 0; day = 0; year = 0; - + HMODULE d3d_dll; DIRECT_3D_CREATE Direct3DCreate; @@ -249,7 +248,8 @@ static int get_display_information (DisplaySearchParameters &display_search_para char system_directory [MAX_PATH]; char dll_file_path [MAX_PATH]; - // find the dll in the system directory if possible and get the date of the file + // find the dll in the system directory if possible and get the date + // of the file if (GetSystemDirectory (system_directory, MAX_PATH) > 0) { if (debug) { printf ("system_directory = %s \n", system_directory); @@ -272,14 +272,14 @@ static int get_display_information (DisplaySearchParameters &display_search_para if (debug) { printf ("Driver Date: %d/%d/%d\n", month, day, year); } - + _findclose (find); - } + } } /* HMODULE driver_dll; - + driver_dll = LoadLibrary (d3d_adapter_identifier.Driver); if (driver_dll) { @@ -293,7 +293,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para } else { - printf ("ERROR: could not get GetModuleFileName for %s \n", d3d_adapter_identifier.Driver); + printf ("ERROR: could not get GetModuleFileName for %s \n", d3d_adapter_identifier.Driver); } FreeLibrary (driver_dll); @@ -309,7 +309,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para printf ("VendorId = 0x%x\n", d3d_adapter_identifier.VendorId); printf ("DeviceId = 0x%x\n", d3d_adapter_identifier.DeviceId); } - + vendor_id = d3d_adapter_identifier.VendorId; device_id = d3d_adapter_identifier.DeviceId; @@ -321,9 +321,9 @@ static int get_display_information (DisplaySearchParameters &display_search_para if (debug) { printf ("DRIVER VERSION: %d.%d.%d.%d \n", product, version, sub_version, build); } - + WHQL whql; - + whql.whql= d3d_adapter_identifier.WHQLLevel; if (debug) { @@ -352,7 +352,8 @@ static int get_display_information (DisplaySearchParameters &display_search_para shader_model = GraphicsStateGuardian::SM_11; break; case 2: - // minimim specification for pixel shader 2.0 is 96 instruction slots + // minimim specification for pixel shader 2.0 is 96 instruction + // slots shader_model = GraphicsStateGuardian::SM_20; if (d3d_caps.PS20Caps.NumInstructionSlots >= 512) { shader_model = GraphicsStateGuardian::SM_2X; @@ -453,7 +454,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para } } } - } + } } } @@ -467,11 +468,11 @@ static int get_display_information (DisplaySearchParameters &display_search_para height = 480; // make a window - WNDCLASSEX window_class = - { - sizeof (WNDCLASSEX), CS_CLASSDC, window_procedure, 0L, 0L, + WNDCLASSEX window_class = + { + sizeof (WNDCLASSEX), CS_CLASSDC, window_procedure, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, - "class_name", NULL + "class_name", NULL }; RegisterClassEx (&window_class); @@ -509,7 +510,8 @@ static int get_display_information (DisplaySearchParameters &display_search_para else { behavior_flags = D3DCREATE_SOFTWARE_VERTEXPROCESSING; } - // This is important to prevent DirectX from forcing the FPU into single-precision mode. + // This is important to prevent DirectX from forcing the FPU into + // single-precision mode. behavior_flags |= D3DCREATE_FPU_PRESERVE; HRESULT result; @@ -517,7 +519,8 @@ static int get_display_information (DisplaySearchParameters &display_search_para result = direct_3d -> CreateDevice (adapter, device_type, window_handle, behavior_flags, &present_parameters, &direct_3d_device); if (result == D3D_OK) { - // allocate 512x512 32-bit textures (1MB size) until we run out or hit the limit + // allocate 512x512 32-bit textures (1MB size) until we run out or + // hit the limit #define MAXIMUM_TEXTURES (2048 - 1) int total_textures; @@ -631,7 +634,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para // memory bool memory_state; HMODULE kernel32_dll; - + memory_state = false; kernel32_dll = LoadLibrary ("kernel32.dll"); if (kernel32_dll) { @@ -646,7 +649,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para physical_memory = memory_status.ullTotalPhys; available_physical_memory = memory_status.ullAvailPhys; memory_state = true; - } + } } FreeLibrary (kernel32_dll); } @@ -659,7 +662,7 @@ static int get_display_information (DisplaySearchParameters &display_search_para physical_memory = memory_status.dwTotalPhys; available_physical_memory = memory_status.dwAvailPhys; } - + if (debug) { printf ("physical_memory %I64d \n", physical_memory); printf ("available_physical_memory %I64d \n", available_physical_memory); diff --git a/panda/src/windisplay/winDetectDx9.cxx b/panda/src/windisplay/winDetectDx9.cxx index 3a592331ed..2e293950f6 100644 --- a/panda/src/windisplay/winDetectDx9.cxx +++ b/panda/src/windisplay/winDetectDx9.cxx @@ -1,16 +1,15 @@ -// Filename: winDetectDx9.cxx -// Created by: aignacio (18Jan07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winDetectDx9.cxx + * @author aignacio + * @date 2007-01-18 + */ #include "pandabase.h" diff --git a/panda/src/windisplay/winGraphicsPipe.I b/panda/src/windisplay/winGraphicsPipe.I index fd191e2429..b65f0ef6e1 100644 --- a/panda/src/windisplay/winGraphicsPipe.I +++ b/panda/src/windisplay/winGraphicsPipe.I @@ -1,15 +1,12 @@ -// Filename: winGraphicsPipe.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsPipe.I + * @author drose + * @date 2002-12-20 + */ diff --git a/panda/src/windisplay/winGraphicsPipe.cxx b/panda/src/windisplay/winGraphicsPipe.cxx index 8fd031ffef..64623d6bfe 100644 --- a/panda/src/windisplay/winGraphicsPipe.cxx +++ b/panda/src/windisplay/winGraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: winGraphicsPipe.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsPipe.cxx + * @author drose + * @date 2002-12-20 + */ #include "winGraphicsPipe.h" #include "config_windisplay.h" @@ -389,7 +388,8 @@ int cpuid(int input_eax, CPU_ID_REGISTERS *cpu_id_registers) { state = false; __try { if (input_eax == 0) { - // the order of ecx and edx is swapped when saved to make a proper vendor string + // the order of ecx and edx is swapped when saved to make a proper + // vendor string #ifdef _WIN64 __cpuid((int*)cpu_id_registers, input_eax); unsigned int tmp = cpu_id_registers->edx; @@ -463,8 +463,8 @@ void parse_cpu_id(CPU_ID *cpu_id) { printf(" maximum_logical_processors %u\n", cpu_id->maximum_logical_processors); printf(" initial_apic_id %u\n", cpu_id->initial_apic_id); -// printf(" cache_line_size %u\n", cpu_id->cache_line_size); -// printf(" log_base_2_cache_line_size %u\n", cpu_id->log_base_2_cache_line_size); +// printf(" cache_line_size %u\n", cpu_id->cache_line_size); printf(" +// log_base_2_cache_line_size %u\n", cpu_id->log_base_2_cache_line_size); } if (cpu_id->cpu_id_registers_0x80000000.eax >= 0x80000005) { @@ -678,19 +678,17 @@ count_number_of_cpus(DisplayInformation *display_information) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinGraphicsPipe:: WinGraphicsPipe() { char string [512]; _supported_types = OT_window | OT_fullscreen_window; - // these fns arent defined on win95, so get dynamic ptrs to them - // to avoid ugly DLL loader failures on w95 + // these fns arent defined on win95, so get dynamic ptrs to them to avoid + // ugly DLL loader failures on w95 _pfnTrackMouseEvent = NULL; _hUser32 = (HINSTANCE)LoadLibrary("user32.dll"); @@ -796,13 +794,11 @@ WinGraphicsPipe() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsPipe::lookup_cpu_data -// Access: Public, Virtual -// Description: Looks up the detailed CPU information and stores it -// in _display_information, if supported by the OS. -// This may take a second or two. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the detailed CPU information and stores it in + * _display_information, if supported by the OS. This may take a second or + * two. + */ void WinGraphicsPipe:: lookup_cpu_data() { char string [512]; @@ -907,11 +903,9 @@ lookup_cpu_data() { count_number_of_cpus(_display_information); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinGraphicsPipe:: ~WinGraphicsPipe() { if (_hUser32 != NULL) { diff --git a/panda/src/windisplay/winGraphicsPipe.h b/panda/src/windisplay/winGraphicsPipe.h index 88d3e264d6..51ad61c8b1 100644 --- a/panda/src/windisplay/winGraphicsPipe.h +++ b/panda/src/windisplay/winGraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: winGraphicsPipe.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsPipe.h + * @author drose + * @date 2002-12-20 + */ #ifndef WINGRAPHICSPIPE_H #define WINGRAPHICSPIPE_H @@ -19,19 +18,15 @@ #include "graphicsPipe.h" #include "winGraphicsWindow.h" -//////////////////////////////////////////////////////////////////// -// Class : WinGraphicsPipe -// Description : This is an abstract base class for wglGraphicsPipe -// and wdxGraphicsPipe; that is, those graphics pipes -// that are specialized for working with Microsoft -// Windows. -// -// There isn't much code here, since most of the fancy -// stuff is handled in WinGraphicsWindow. You could -// make a case that we don't even need a WinGraphicsPipe -// class at all, but it is provided mainly for -// completeness. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class for wglGraphicsPipe and wdxGraphicsPipe; + * that is, those graphics pipes that are specialized for working with + * Microsoft Windows. + * + * There isn't much code here, since most of the fancy stuff is handled in + * WinGraphicsWindow. You could make a case that we don't even need a + * WinGraphicsPipe class at all, but it is provided mainly for completeness. + */ class EXPCL_PANDAWIN WinGraphicsPipe : public GraphicsPipe { public: WinGraphicsPipe(); diff --git a/panda/src/windisplay/winGraphicsWindow.I b/panda/src/windisplay/winGraphicsWindow.I index 094e96efcd..1a51d47988 100644 --- a/panda/src/windisplay/winGraphicsWindow.I +++ b/panda/src/windisplay/winGraphicsWindow.I @@ -1,25 +1,20 @@ -// Filename: winGraphicsWindow.I -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsWindow.I + * @author drose + * @date 2002-12-20 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::translate_mouse -// Access: Private -// Description: Translates the mouse pixel coordinate (either x or y) -// as returned by the Windows message to the signed -// number expected by Panda. -//////////////////////////////////////////////////////////////////// +/** + * Translates the mouse pixel coordinate (either x or y) as returned by the + * Windows message to the signed number expected by Panda. + */ INLINE int WinGraphicsWindow:: translate_mouse(int pos) const { if (pos & 0x8000) { @@ -28,18 +23,14 @@ translate_mouse(int pos) const { return pos; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::set_cursor_in_window -// Access: Private -// Description: Called during the window thread in response to the -// various Windows messages to indicate whether we -// believe the mouse is presently within the window's -// client rectangle or not. This in turn will determine -// whether we should call update_cursor_window() to hide -// or show the cursor (or otherwise change its -// properties) as it moves between the various -// GraphicsWindows that we control. -//////////////////////////////////////////////////////////////////// +/** + * Called during the window thread in response to the various Windows messages + * to indicate whether we believe the mouse is presently within the window's + * client rectangle or not. This in turn will determine whether we should + * call update_cursor_window() to hide or show the cursor (or otherwise change + * its properties) as it moves between the various GraphicsWindows that we + * control. + */ INLINE void WinGraphicsWindow:: set_cursor_in_window() { if (_cursor_window != this) { @@ -47,18 +38,14 @@ set_cursor_in_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::set_cursor_out_of_window -// Access: Private -// Description: Called during the window thread in response to the -// various Windows messages to indicate whether we -// believe the mouse is presently within the window's -// client rectangle or not. This in turn will determine -// whether we should call update_cursor_window() to hide -// or show the cursor (or otherwise change its -// properties) as it moves between the various -// GraphicsWindows that we control. -//////////////////////////////////////////////////////////////////// +/** + * Called during the window thread in response to the various Windows messages + * to indicate whether we believe the mouse is presently within the window's + * client rectangle or not. This in turn will determine whether we should + * call update_cursor_window() to hide or show the cursor (or otherwise change + * its properties) as it moves between the various GraphicsWindows that we + * control. + */ INLINE void WinGraphicsWindow:: set_cursor_out_of_window() { if (_cursor_window == this) { @@ -66,14 +53,11 @@ set_cursor_out_of_window() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_message_time -// Access: Private, Static -// Description: May be called only during the servicing of a Windows -// message. This returns the time the message was added -// to the Windows message queue (as reported via -// GetMessageTime()), converted into global clock units. -//////////////////////////////////////////////////////////////////// +/** + * May be called only during the servicing of a Windows message. This returns + * the time the message was added to the Windows message queue (as reported + * via GetMessageTime()), converted into global clock units. + */ INLINE double WinGraphicsWindow:: get_message_time() { DWORD now_ticks = GetTickCount(); @@ -82,11 +66,9 @@ get_message_time() { return now_time - (double)elapsed_ticks / 1000.0; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_ime_hwnd -// Access: Private -// Description: Return the IME_window handle if open -//////////////////////////////////////////////////////////////////// +/** + * Return the IME_window handle if open + */ INLINE HWND WinGraphicsWindow:: get_ime_hwnd() { if (_ime_active) @@ -95,11 +77,9 @@ get_ime_hwnd() { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::WindowClass::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WinGraphicsWindow::WindowClass:: WindowClass(const WindowProperties &props) : _icon(0) @@ -108,12 +88,10 @@ WindowClass(const WindowProperties &props) : _icon = get_icon(props.get_icon_filename()); } } - -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::WindowClass::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ INLINE bool WinGraphicsWindow::WindowClass:: operator < (const WinGraphicsWindow::WindowClass &other) const { return _icon < other._icon; diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index f270a70f61..d23c4f43dc 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: winGraphicsWindow.cxx -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsWindow.cxx + * @author drose + * @date 2002-12-20 + */ #include "winGraphicsWindow.h" #include "config_windisplay.h" @@ -41,9 +40,9 @@ bool WinGraphicsWindow::_cursor_hidden = false; RECT WinGraphicsWindow::_mouse_unconfined_cliprect; -// These are used to save the previous state of the fancy Win2000 -// effects that interfere with rendering when the mouse wanders into a -// window's client area. +// These are used to save the previous state of the fancy Win2000 effects that +// interfere with rendering when the mouse wanders into a window's client +// area. bool WinGraphicsWindow::_got_saved_params = false; int WinGraphicsWindow::_saved_mouse_trails; BOOL WinGraphicsWindow::_saved_cursor_shadow; @@ -57,12 +56,8 @@ int WinGraphicsWindow::_window_class_index = 0; static const char * const errorbox_title = "Panda3D Error"; -//////////////////////////////////////////////////////////////////// -// -// These static variables contain pointers to the Raw Input -// functions, which are dynamically extracted from USER32.DLL -// -//////////////////////////////////////////////////////////////////// +// These static variables contain pointers to the Raw Input functions, which +// are dynamically extracted from USER32.DLL typedef WINUSERAPI UINT (WINAPI *tGetRawInputDeviceList) (OUT PRAWINPUTDEVICELIST pRawInputDeviceList, IN OUT PUINT puiNumDevices, IN UINT cbSize); @@ -78,11 +73,9 @@ static tGetRawInputData pGetRawInputData; static tGetRawInputDeviceInfoA pGetRawInputDeviceInfoA; static tRegisterRawInputDevices pRegisterRawInputDevices; -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinGraphicsWindow:: WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -112,11 +105,9 @@ WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, #endif } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinGraphicsWindow:: ~WinGraphicsWindow() { if (_window_handle != (WindowHandle *)NULL) { @@ -124,21 +115,19 @@ WinGraphicsWindow:: } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool WinGraphicsWindow:: move_pointer(int device, int x, int y) { - // First, indicate that the IME is no longer active, so that it won't - // send the string through WM_IME_COMPOSITION. But we still leave - // _ime_open true, so that it also won't send the string through WM_CHAR. + // First, indicate that the IME is no longer active, so that it won't send + // the string through WM_IME_COMPOSITION. But we still leave _ime_open + // true, so that it also won't send the string through WM_CHAR. _ime_active = false; // Note: this is not thread-safe; it should be called only from App. @@ -146,7 +135,7 @@ move_pointer(int device, int x, int y) { if (device == 0) { // Move the system mouse pointer. if (!_properties.get_foreground() ) - // !_input_devices[0].get_pointer().get_in_window()) + // !_input_devices[0].get_pointer().get_in_window()) { // If the window doesn't have input focus, or the mouse isn't // currently within the window, forget it. @@ -169,12 +158,10 @@ move_pointer(int device, int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::close_ime -// Access: Published, Virtual -// Description: Forces the ime window to close, if any -// -//////////////////////////////////////////////////////////////////// +/** + * Forces the ime window to close, if any + * + */ void WinGraphicsWindow:: close_ime() { // Check if the ime window is open @@ -194,45 +181,39 @@ close_ime() { return; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::begin_flip -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after end_frame() has been called on all windows, to -// initiate the exchange of the front and back buffers. -// -// This should instruct the window to prepare for the -// flip at the next video sync, but it should not wait. -// -// We have the two separate functions, begin_flip() and -// end_flip(), to make it easier to flip all of the -// windows at the same time. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after end_frame() has + * been called on all windows, to initiate the exchange of the front and back + * buffers. + * + * This should instruct the window to prepare for the flip at the next video + * sync, but it should not wait. + * + * We have the two separate functions, begin_flip() and end_flip(), to make it + * easier to flip all of the windows at the same time. + */ void WinGraphicsWindow:: begin_flip() { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void WinGraphicsWindow:: process_events() { GraphicsWindow::process_events(); - // We can't treat the message loop specially just because the window - // is minimized, because we might be reading messages queued up for - // some other window, which is not minimized. + // We can't treat the message loop specially just because the window is + // minimized, because we might be reading messages queued up for some other + // window, which is not minimized. /* if (!_window_active) { - // Get 1 msg at a time until no more are left and we block and sleep, - // or message changes _return_control_to_app or !_window_active status + // Get 1 msg at a time until no more are left and we block and sleep, or + // message changes _return_control_to_app or !_window_active status while(!_window_active && (!_return_control_to_app)) { process_1_event(); @@ -244,33 +225,27 @@ process_events() { MSG msg; - // Handle all the messages on the queue in a row. Some of these - // might be for another window, but they will get dispatched - // appropriately. + // Handle all the messages on the queue in a row. Some of these might be + // for another window, but they will get dispatched appropriately. while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { process_1_event(); } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The properties that have been applied are cleared -// from the structure by this function; so on return, -// whatever remains in the properties structure are -// those that were unchanged for some reason (probably -// because the underlying interface does not support -// changing that property on an open window). -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The properties that have been applied are cleared from the structure by + * this function; so on return, whatever remains in the properties structure + * are those that were unchanged for some reason (probably because the + * underlying interface does not support changing that property on an open + * window). + */ void WinGraphicsWindow:: set_properties_now(WindowProperties &properties) { GraphicsWindow::set_properties_now(properties); @@ -420,20 +395,17 @@ set_properties_now(WindowProperties &properties) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::trigger_flip -// Access: Protected -// Description: To be called at the end of the frame, after the -// window has successfully been drawn and is ready to be -// flipped (if appropriate). -//////////////////////////////////////////////////////////////////// +/** + * To be called at the end of the frame, after the window has successfully + * been drawn and is ready to be flipped (if appropriate). + */ void WinGraphicsWindow:: trigger_flip() { GraphicsWindow::trigger_flip(); if (!get_unexposed_draw()) { - // Now that we've drawn or whatever, invalidate the rectangle so - // we won't redraw again until we get the WM_PAINT message. + // Now that we've drawn or whatever, invalidate the rectangle so we won't + // redraw again until we get the WM_PAINT message. InvalidateRect(_hWnd, NULL, FALSE); _got_expose_event = false; @@ -445,12 +417,9 @@ trigger_flip() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void WinGraphicsWindow:: close_window() { set_cursor_out_of_window(); @@ -468,13 +437,10 @@ close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool WinGraphicsWindow:: open_window() { if (_properties.has_cursor_filename()) { @@ -488,10 +454,9 @@ open_window() { HWND old_foreground_window = GetForegroundWindow(); - // Store the current window pointer in _creating_window, so we can - // call CreateWindow() and know which window it is sending events to - // even before it gives us a handle. Warning: this is not thread - // safe! + // Store the current window pointer in _creating_window, so we can call + // CreateWindow() and know which window it is sending events to even before + // it gives us a handle. Warning: this is not thread safe! _creating_window = this; bool opened = open_graphic_window(is_fullscreen()); _creating_window = (WinGraphicsWindow *)NULL; @@ -500,8 +465,8 @@ open_window() { return false; } - // Now that we have a window handle, store it in our global map, so - // future messages for this window can be routed properly. + // Now that we have a window handle, store it in our global map, so future + // messages for this window can be routed properly. _window_handles.insert(WindowHandles::value_type(_hWnd, this)); // move window to top of zorder. @@ -519,8 +484,8 @@ open_window() { HWND new_foreground_window = _hWnd; if (!want_foreground) { - // If we specifically requested the window not to be on top, - // restore the previous foreground window (if we can). + // If we specifically requested the window not to be on top, restore the + // previous foreground window (if we can). new_foreground_window = old_foreground_window; } @@ -530,8 +495,8 @@ open_window() { } // Let's aggressively call SetForegroundWindow() in addition to - // SetActiveWindow(). It seems to work in some cases to make the - // window come to the top, where SetActiveWindow doesn't work. + // SetActiveWindow(). It seems to work in some cases to make the window + // come to the top, where SetActiveWindow doesn't work. if (!SetForegroundWindow(new_foreground_window)) { windisplay_cat.warning() << "SetForegroundWindow() failed!\n"; @@ -578,15 +543,12 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::initialize_input_devices -// Access: Private -// Description: Creates the array of input devices. The first -// one is always the system mouse and keyboard. -// Each subsequent one is a raw mouse device. Also -// initializes a parallel array, _input_device_handle, -// with the win32 handle of each raw input device. -//////////////////////////////////////////////////////////////////// +/** + * Creates the array of input devices. The first one is always the system + * mouse and keyboard. Each subsequent one is a raw mouse device. Also + * initializes a parallel array, _input_device_handle, with the win32 handle + * of each raw input device. + */ void WinGraphicsWindow:: initialize_input_devices() { @@ -595,7 +557,7 @@ initialize_input_devices() { nassertv(_input_devices.size() == 0); - // Clear the handle array, and set up the system keyboard/mouse + // Clear the handle array, and set up the system keyboardmouse memset(_input_device_handle, 0, sizeof(_input_device_handle)); GraphicsWindowInputDevice device = GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard_mouse"); @@ -665,41 +627,32 @@ initialize_input_devices() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::fullscreen_minimized -// Access: Protected, Virtual -// Description: This is a hook for derived classes to do something -// special, if necessary, when a fullscreen window has -// been minimized. The given WindowProperties struct -// will be applied to this window's properties after -// this function returns. -//////////////////////////////////////////////////////////////////// +/** + * This is a hook for derived classes to do something special, if necessary, + * when a fullscreen window has been minimized. The given WindowProperties + * struct will be applied to this window's properties after this function + * returns. + */ void WinGraphicsWindow:: fullscreen_minimized(WindowProperties &) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::fullscreen_restored -// Access: Protected, Virtual -// Description: This is a hook for derived classes to do something -// special, if necessary, when a fullscreen window has -// been restored after being minimized. The given -// WindowProperties struct will be applied to this -// window's properties after this function returns. -//////////////////////////////////////////////////////////////////// +/** + * This is a hook for derived classes to do something special, if necessary, + * when a fullscreen window has been restored after being minimized. The + * given WindowProperties struct will be applied to this window's properties + * after this function returns. + */ void WinGraphicsWindow:: fullscreen_restored(WindowProperties &) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_reshape_request -// Access: Protected, Virtual -// Description: Called from the window thread in response to a request -// from within the code (via request_properties()) to -// change the size and/or position of the window. -// Returns true if the window is successfully changed, -// or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Called from the window thread in response to a request from within the code + * (via request_properties()) to change the size and/or position of the + * window. Returns true if the window is successfully changed, or false if + * there was a problem. + */ bool WinGraphicsWindow:: do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size) { @@ -726,8 +679,8 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, } } - // Compute the appropriate size and placement for the window, - // including decorations. + // Compute the appropriate size and placement for the window, including + // decorations. RECT view_rect; SetRect(&view_rect, x_origin, y_origin, x_origin + x_size, y_origin + y_size); @@ -759,20 +712,16 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin, return do_fullscreen_resize(x_size, y_size); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_reshape -// Access: Protected, Virtual -// Description: Called in the window thread when the window size or -// location is changed, this updates the properties -// structure accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread when the window size or location is changed, + * this updates the properties structure accordingly. + */ void WinGraphicsWindow:: handle_reshape() { RECT view_rect; if (!GetClientRect(_hWnd, &view_rect)) { - // Sometimes we get a "reshape" before the window is fully - // created, in which case GetClientRect() ought to fail. Ignore - // this. + // Sometimes we get a "reshape" before the window is fully created, in + // which case GetClientRect() ought to fail. Ignore this. if (windisplay_cat.is_debug()) { windisplay_cat.debug() << "GetClientRect() failed in handle_reshape. Ignoring.\n"; @@ -780,8 +729,8 @@ handle_reshape() { return; } - // But in practice, GetClientRect() doesn't really fail, but just - // returns all zeroes. Ignore this too. + // But in practice, GetClientRect() doesn't really fail, but just returns + // all zeroes. Ignore this too. if (view_rect.left == 0 && view_rect.right == 0 && view_rect.bottom == 0 && view_rect.top == 0) { if (windisplay_cat.is_debug()) { @@ -822,12 +771,9 @@ handle_reshape() { system_changed_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_fullscreen_resize -// Access: Protected, Virtual -// Description: Called in the window thread to resize a fullscreen -// window. -//////////////////////////////////////////////////////////////////// +/** + * Called in the window thread to resize a fullscreen window. + */ bool WinGraphicsWindow:: do_fullscreen_resize(int x_size, int y_size) { HWND hDesktopWindow = GetDesktopWindow(); @@ -837,9 +783,8 @@ do_fullscreen_resize(int x_size, int y_size) { // resize will always leave screen bitdepth unchanged - // allowing resizing of lowvidmem cards to > 640x480. why? I'll - // assume check was already done by caller, so he knows what he - // wants + // allowing resizing of lowvidmem cards to > 640x480. why? I'll assume + // check was already done by caller, so he knows what he wants DEVMODE dm; if (!find_acceptable_display_mode(x_size, y_size, @@ -878,12 +823,9 @@ do_fullscreen_resize(int x_size, int y_size) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_fullscreen_switch -// Access: Protected, Virtual -// Description: Called in the set_properties_now function -// to switch to fullscreen. -//////////////////////////////////////////////////////////////////// +/** + * Called in the set_properties_now function to switch to fullscreen. + */ bool WinGraphicsWindow:: do_fullscreen_switch() { if (!do_fullscreen_enable()) { @@ -905,12 +847,9 @@ do_fullscreen_switch() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_windowed_switch -// Access: Protected, Virtual -// Description: Called in the set_properties_now function -// to switch to windowed mode. -//////////////////////////////////////////////////////////////////// +/** + * Called in the set_properties_now function to switch to windowed mode. + */ bool WinGraphicsWindow:: do_windowed_switch() { do_fullscreen_disable(); @@ -925,8 +864,8 @@ do_windowed_switch() { } // We send SWP_FRAMECHANGED so that the new styles are taken into account. - // Also, we place the Windows at 0,0 to play safe until we decide how to - // get Panda to remember the windowed origin. + // Also, we place the Windows at 0,0 to play safe until we decide how to get + // Panda to remember the windowed origin. SetWindowPos(_hWnd, HWND_NOTOPMOST, 0, 0, metrics.width, metrics.height, @@ -935,46 +874,35 @@ do_windowed_switch() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::reconsider_fullscreen_size -// Access: Protected, Virtual -// Description: Called before creating a fullscreen window to give -// the driver a chance to adjust the particular -// resolution request, if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called before creating a fullscreen window to give the driver a chance to + * adjust the particular resolution request, if necessary. + */ void WinGraphicsWindow:: reconsider_fullscreen_size(DWORD &, DWORD &, DWORD &) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::support_overlay_window -// Access: Protected, Virtual -// Description: Some windows graphics contexts (e.g. DirectX) -// require special support to enable the displaying of -// an overlay window (particularly the IME window) over -// the fullscreen graphics window. This is a hook for -// the window to enable or disable that mode when -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Some windows graphics contexts (e.g. DirectX) require special support to + * enable the displaying of an overlay window (particularly the IME window) + * over the fullscreen graphics window. This is a hook for the window to + * enable or disable that mode when necessary. + */ void WinGraphicsWindow:: support_overlay_window(bool) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::make_style -// Access: Private -// Description: Constructs a dwStyle for the specified mode, -// be it windowed or fullscreen. -//////////////////////////////////////////////////////////////////// +/** + * Constructs a dwStyle for the specified mode, be it windowed or fullscreen. + */ DWORD WinGraphicsWindow:: make_style(bool fullscreen) { - // from MSDN: - // An OpenGL window has its own pixel format. Because of this, only - // device contexts retrieved for the client area of an OpenGL - // window are allowed to draw into the window. As a result, an - // OpenGL window should be created with the WS_CLIPCHILDREN and - // WS_CLIPSIBLINGS styles. Additionally, the window class attribute - // should not include the CS_PARENTDC style. + // from MSDN: An OpenGL window has its own pixel format. Because of this, + // only device contexts retrieved for the client area of an OpenGL window + // are allowed to draw into the window. As a result, an OpenGL window + // should be created with the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles. + // Additionally, the window class attribute should not include the + // CS_PARENTDC style. DWORD window_style = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; @@ -992,12 +920,10 @@ make_style(bool fullscreen) { return window_style; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::calculate_metrics -// Access: Private -// Description: Calculates the metrics for the specified mode, -// be it windowed or fullscreen. -//////////////////////////////////////////////////////////////////// +/** + * Calculates the metrics for the specified mode, be it windowed or + * fullscreen. + */ bool WinGraphicsWindow:: calculate_metrics(bool fullscreen, DWORD window_style, WINDOW_METRICS &metrics, bool &has_origin) { @@ -1053,11 +979,9 @@ calculate_metrics(bool fullscreen, DWORD window_style, WINDOW_METRICS &metrics, return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::open_graphic_window -// Access: Private -// Description: Creates a regular or fullscreen window. -//////////////////////////////////////////////////////////////////// +/** + * Creates a regular or fullscreen window. + */ bool WinGraphicsWindow:: open_graphic_window(bool fullscreen) { DWORD window_style = make_style(fullscreen); @@ -1069,7 +993,7 @@ open_graphic_window(bool fullscreen) { } if (!_properties.has_size()) { - //Just fill in a conservative default size if one isn't specified. + // Just fill in a conservative default size if one isn't specified. _properties.set_size(640, 480); } @@ -1132,10 +1056,11 @@ open_graphic_window(bool fullscreen) { if (_hWnd) { // join our keyboard state with the parents - // Actually, let's not. Is there really any reason to do this? - // It causes problems with the browser plugin--it deadlocks when - // the parent process is waiting on the child process. - //AttachThreadInput(GetWindowThreadProcessId(_hparent,NULL), GetCurrentThreadId(),TRUE); + // Actually, let's not. Is there really any reason to do this? It + // causes problems with the browser plugin--it deadlocks when the parent + // process is waiting on the child process. + // AttachThreadInput(GetWindowThreadProcessId(_hparent,NULL), + // GetCurrentThreadId(),TRUE); WindowProperties properties; properties.set_foreground(true); @@ -1150,9 +1075,9 @@ open_graphic_window(bool fullscreen) { return false; } - // I'd prefer to CreateWindow after DisplayChange in case it messes - // up GL somehow, but I need the window's black background to cover - // up the desktop during the mode change. + // I'd prefer to CreateWindow after DisplayChange in case it messes up GL + // somehow, but I need the window's black background to cover up the desktop + // during the mode change. if (fullscreen){ if (!do_fullscreen_enable()){ @@ -1163,22 +1088,19 @@ open_graphic_window(bool fullscreen) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_fullscreen_enable -// Access: Private -// Description: This is a low-level function that just puts Windows -// in fullscreen mode. Not to confuse with -// do_fullscreen_switch(). -//////////////////////////////////////////////////////////////////// +/** + * This is a low-level function that just puts Windows in fullscreen mode. + * Not to confuse with do_fullscreen_switch(). + */ bool WinGraphicsWindow:: do_fullscreen_enable() { HWND hDesktopWindow = GetDesktopWindow(); HDC scrnDC = GetDC(hDesktopWindow); DWORD cur_bitdepth = GetDeviceCaps(scrnDC, BITSPIXEL); - // DWORD drvr_ver = GetDeviceCaps(scrnDC, DRIVERVERSION); - // DWORD cur_scrnwidth = GetDeviceCaps(scrnDC, HORZRES); - // DWORD cur_scrnheight = GetDeviceCaps(scrnDC, VERTRES); + // DWORD drvr_ver = GetDeviceCaps(scrnDC, DRIVERVERSION); DWORD + // cur_scrnwidth = GetDeviceCaps(scrnDC, HORZRES); DWORD cur_scrnheight = + // GetDeviceCaps(scrnDC, VERTRES); ReleaseDC(hDesktopWindow, scrnDC); DWORD dwWidth = _properties.get_x_size(); @@ -1218,13 +1140,10 @@ do_fullscreen_enable() { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::do_fullscreen_disable -// Access: Private -// Description: This is a low-level function that just gets Windows -// out of fullscreen mode. Not to confuse with -// do_windowed_switch(). -//////////////////////////////////////////////////////////////////// +/** + * This is a low-level function that just gets Windows out of fullscreen mode. + * Not to confuse with do_windowed_switch(). + */ bool WinGraphicsWindow:: do_fullscreen_disable() { int chg_result = ChangeDisplaySettings(NULL, 0x0); @@ -1236,24 +1155,18 @@ do_fullscreen_disable() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::adjust_z_order -// Access: Private -// Description: Adjusts the Z-order of a window after it has been -// moved. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the Z-order of a window after it has been moved. + */ void WinGraphicsWindow:: adjust_z_order() { WindowProperties::ZOrder z_order = _properties.get_z_order(); adjust_z_order(z_order, z_order); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::adjust_z_order -// Access: Private -// Description: Adjusts the Z-order of a window after it has been -// moved. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the Z-order of a window after it has been moved. + */ void WinGraphicsWindow:: adjust_z_order(WindowProperties::ZOrder last_z_order, WindowProperties::ZOrder this_z_order) { @@ -1268,13 +1181,12 @@ adjust_z_order(WindowProperties::ZOrder last_z_order, case WindowProperties::Z_normal: if ((last_z_order != WindowProperties::Z_normal) && - // If we aren't changing the window order, don't move it to - // the top. + // If we aren't changing the window order, don't move it to the top. (last_z_order != WindowProperties::Z_bottom || _properties.get_foreground()) - // If the window was previously on the bottom, but it doesn't - // have focus now, don't move it to the top; it will get moved - // the next time we get focus. + // If the window was previously on the bottom, but it doesn't have + // focus now, don't move it to the top; it will get moved the next + // time we get focus. ) { order = HWND_NOTOPMOST; do_change = true; @@ -1296,20 +1208,17 @@ adjust_z_order(WindowProperties::ZOrder last_z_order, } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::track_mouse_leaving -// Access: Private -// Description: Intended to be called whenever mouse motion is -// detected within the window, this indicates that the -// mouse is within the window and tells Windows that we -// want to be told when the mouse leaves the window. -//////////////////////////////////////////////////////////////////// +/** + * Intended to be called whenever mouse motion is detected within the window, + * this indicates that the mouse is within the window and tells Windows that + * we want to be told when the mouse leaves the window. + */ void WinGraphicsWindow:: track_mouse_leaving(HWND hwnd) { - // Note: could use _TrackMouseEvent in comctrl32.dll (part of IE - // 3.0+) which emulates TrackMouseEvent on w95, but that requires - // another 500K of memory to hold that DLL, which is lame just to - // support w95, which probably has other issues anyway + // Note: could use _TrackMouseEvent in comctrl32.dll (part of IE 3.0+) which + // emulates TrackMouseEvent on w95, but that requires another 500K of memory + // to hold that DLL, which is lame just to support w95, which probably has + // other issues anyway WinGraphicsPipe *winpipe; DCAST_INTO_V(winpipe, _pipe); @@ -1333,20 +1242,18 @@ track_mouse_leaving(HWND hwnd) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::set_focus -// Access: Private -// Description: Attempts to set this window as the "focus" window, so -// that keyboard events come here. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to set this window as the "focus" window, so that keyboard events + * come here. + */ void WinGraphicsWindow:: set_focus() { if (SetFocus(_hWnd) == NULL && GetLastError() != 0) { - // If the SetFocus() request failed, maybe we're running in the - // plugin environment on Vista, with UAC enabled. In this case, - // we're not allowed to assign focus to the Panda window for some - // stupid reason. So instead, we have to ask the parent window - // (in the browser process) to proxy our keyboard events for us. + // If the SetFocus() request failed, maybe we're running in the plugin + // environment on Vista, with UAC enabled. In this case, we're not + // allowed to assign focus to the Panda window for some stupid reason. So + // instead, we have to ask the parent window (in the browser process) to + // proxy our keyboard events for us. if (_parent_window_handle != NULL && _window_handle != NULL) { _parent_window_handle->request_keyboard_focus(_window_handle); } else { @@ -1357,33 +1264,26 @@ set_focus() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::receive_windows_message -// Access: Public -// Description: This is called to receive a keyboard event generated -// by proxy by another window in a parent process. This -// hacky system is used in the web plugin system to -// allow the Panda window to receive keyboard events on -// Vista, which doesn't allow the Panda window to set -// keyboard focus to itself. -//////////////////////////////////////////////////////////////////// +/** + * This is called to receive a keyboard event generated by proxy by another + * window in a parent process. This hacky system is used in the web plugin + * system to allow the Panda window to receive keyboard events on Vista, which + * doesn't allow the Panda window to set keyboard focus to itself. + */ void WinGraphicsWindow:: receive_windows_message(unsigned int msg, int wparam, int lparam) { - // Well, we'll just deliver this directly to window_proc(), - // supplying our own window handle. For the most part, we don't - // care about the window handle anyway, but this might become an - // issue for the IME. TODO: investigate IME issues. + // Well, we'll just deliver this directly to window_proc(), supplying our + // own window handle. For the most part, we don't care about the window + // handle anyway, but this might become an issue for the IME. TODO: + // investigate IME issues. window_proc(_hWnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::window_proc -// Access: Public, Virtual -// Description: This is the nonstatic window_proc function. It is -// called to handle window events for this particular -// window. -//////////////////////////////////////////////////////////////////// +/** + * This is the nonstatic window_proc function. It is called to handle window + * events for this particular window. + */ LONG WinGraphicsWindow:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { if (windisplay_cat.is_spam()) { @@ -1436,10 +1336,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { /* case WM_SHOWWINDOW: - // You'd think WM_SHOWWINDOW would be just the thing for embedded - // windows, but it turns out it's not sent to the child windows - // when the parent is minimized. I guess it's only sent for an - // explicit call to ShowWindow, phooey. + // You'd think WM_SHOWWINDOW would be just the thing for embedded windows, + // but it turns out it's not sent to the child windows when the parent is + // minimized. I guess it's only sent for an explicit call to ShowWindow, + // phooey. { if (windisplay_cat.is_debug()) { windisplay_cat.debug() @@ -1458,19 +1358,19 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { */ case WM_CLOSE: - // This is a message from the system indicating that the user - // has requested to close the window (e.g. alt-f4). + // This is a message from the system indicating that the user has + // requested to close the window (e.g. alt-f4). { string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept - // the request and process it directly. + // In this case, the app has indicated a desire to intercept the + // request and process it directly. throw_event(close_request_event); return 0; } else { - // In this case, the default case, the app does not intend - // to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to service + // the request, so we do by closing the window. close_window(); properties.set_open(false); system_changed_properties(properties); @@ -1498,8 +1398,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { properties.set_foreground(true); if (is_fullscreen()) { - // When a fullscreen window goes active, it automatically gets - // un-minimized. + // When a fullscreen window goes active, it automatically gets un- + // minimized. int chg_result = ChangeDisplaySettings(&_fullscreen_display_mode, CDS_FULLSCREEN); if (chg_result != DISP_CHANGE_SUCCESSFUL) { @@ -1522,13 +1422,13 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { properties.set_foreground(false); if (is_fullscreen()) { - // When a fullscreen window goes inactive, it automatically - // gets minimized. + // When a fullscreen window goes inactive, it automatically gets + // minimized. properties.set_minimized(true); - // It seems order is important here. We must minimize the - // window before restoring the display settings, or risk - // losing the graphics context. + // It seems order is important here. We must minimize the window + // before restoring the display settings, or risk losing the + // graphics context. ShowWindow(_hWnd, SW_MINIMIZE); GdiFlush(); do_fullscreen_disable(); @@ -1553,7 +1453,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_EXITSIZEMOVE: - //handle_reshape(); + // handle_reshape(); break; case WM_WINDOWPOSCHANGED: @@ -1561,9 +1461,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_PAINT: - // In response to WM_PAINT, we check to see if there are any - // update regions at all; if there are, we declare the window - // exposed. This is used to implement !_unexposed_draw. + // In response to WM_PAINT, we check to see if there are any update + // regions at all; if there are, we declare the window exposed. This is + // used to implement !_unexposed_draw. if (GetUpdateRect(_hWnd, NULL, false)) { if (windisplay_cat.is_spam()) { windisplay_cat.spam() @@ -1696,7 +1596,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { 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(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; @@ -1718,7 +1618,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { _ime_active = false; // Sanity enforcement. } if (ime_hide) { - //if (0) { + // if (0) { COMPOSITIONFORM comf; CANDIDATEFORM canf; ImmGetCompositionWindow(hIMC, &comf); @@ -1785,11 +1685,11 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_IME_COMPOSITION: if (ime_aware) { - // If the ime window is not marked as active at this point, we - // must be in the process of closing it down (in close_ime), and - // we don't want to send the current composition string in that - // case. But we do need to return 0 to tell windows not to try - // to send the composition string through WM_CHAR messages. + // If the ime window is not marked as active at this point, we must be + // in the process of closing it down (in close_ime), and we don't want + // to send the current composition string in that case. But we do need + // to return 0 to tell windows not to try to send the composition string + // through WM_CHAR messages. if (!_ime_active) { return 0; } @@ -1831,17 +1731,16 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_CHAR: - // Ignore WM_CHAR messages if we have the IME open, since - // everything will come in through WM_IME_COMPOSITION. (It's - // supposed to come in through WM_CHAR, too, but there seems to - // be a bug in Win2000 in that it only sends question mark - // characters through here.) + // Ignore WM_CHAR messages if we have the IME open, since everything will + // come in through WM_IME_COMPOSITION. (It's supposed to come in through + // WM_CHAR, too, but there seems to be a bug in Win2000 in that it only + // sends question mark characters through here.) // Actually, probably that "bug" was due to the fact that we were - // previously using the ANSI versions of RegisterClass etc., in - // which case the actual value passed to WM_CHAR seems to be - // poorly defined. Now we are using RegisterClassW etc., which - // means WM_CHAR is absolutely supposed to be utf-16. + // previously using the ANSI versions of RegisterClass etc., in which case + // the actual value passed to WM_CHAR seems to be poorly defined. Now we + // are using RegisterClassW etc., which means WM_CHAR is absolutely + // supposed to be utf-16. if (!_ime_open) { _input_devices[0].keystroke(wparam); } @@ -1856,9 +1755,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { << "syskeydown: " << wparam << " (" << lookup_key(wparam) << ")\n"; } { - // Alt and F10 are sent as WM_SYSKEYDOWN instead of WM_KEYDOWN - // want to use defwindproc on Alt syskey so std windows cmd - // Alt-F4 works, etc + // Alt and F10 are sent as WM_SYSKEYDOWN instead of WM_KEYDOWN want to + // use defwindproc on Alt syskey so std windows cmd Alt-F4 works, etc POINT point; GetCursorPos(&point); ScreenToClient(hwnd, &point); @@ -1869,14 +1767,14 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_raw_keypress(lookup_raw_key(lparam), get_message_time()); } - // wparam does not contain left/right information for SHIFT, - // CONTROL, or ALT, so we have to track their status and do - // the right thing. We'll send the left/right specific key - // event along with the general key event. - // - // Key repeating is not being handled consistently for LALT - // and RALT, but from comments below, it's only being handled - // the way it is for backspace, so we'll leave it as is. +/* + * wparam does not contain leftright information for SHIFT, CONTROL, or ALT, + * so we have to track their status and do the right thing. We'll send the + * leftright specific key event along with the general key event. Key + * repeating is not being handled consistently for LALT and RALT, but from + * comments below, it's only being handled the way it is for backspace, so + * we'll leave it as is. + */ if (wparam == VK_MENU) { if ((GetKeyState(VK_LMENU) & 0x8000) != 0 && ! _lalt_down) { handle_keypress(KeyboardButton::lalt(), point.x, point.y, @@ -1890,8 +1788,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } if (wparam == VK_F10) { - // bypass default windproc F10 behavior (it activates the main - // menu, but we have none) + // bypass default windproc F10 behavior (it activates the main menu, + // but we have none) return 0; } } @@ -1899,14 +1797,12 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_SYSCOMMAND: if (wparam == SC_KEYMENU) { - // if Alt is released (alone w/o other keys), defwindproc will - // send this command, which will 'activate' the title bar menu - // (we have none) and give focus to it. we don't want this to - // happen, so kill this msg. + // if Alt is released (alone wo other keys), defwindproc will send this + // command, which will 'activate' the title bar menu (we have none) and + // give focus to it. we don't want this to happen, so kill this msg. - // Note that the WM_SYSKEYUP message for Alt has already - // been sent (if it is going to be), so ignoring this - // special message does no harm. + // Note that the WM_SYSKEYUP message for Alt has already been sent (if + // it is going to be), so ignoring this special message does no harm. return 0; } break; @@ -1920,9 +1816,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { << "keydown: " << wparam << " (" << lookup_key(wparam) << ")\n"; } - // If this bit is not zero, this is just a keyrepeat echo; we - // ignore these for handle_keypress (we respect keyrepeat only - // for handle_keystroke). + // If this bit is not zero, this is just a keyrepeat echo; we ignore these + // for handle_keypress (we respect keyrepeat only for handle_keystroke). if ((lparam & 0x40000000) == 0) { POINT point; GetCursorPos(&point); @@ -1931,10 +1826,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { get_message_time()); handle_raw_keypress(lookup_raw_key(lparam), get_message_time()); - // wparam does not contain left/right information for SHIFT, - // CONTROL, or ALT, so we have to track their status and do - // the right thing. We'll send the left/right specific key - // event along with the general key event. + // wparam does not contain leftright information for SHIFT, CONTROL, or + // ALT, so we have to track their status and do the right thing. We'll + // send the leftright specific key event along with the general key + // event. if (wparam == VK_SHIFT) { if ((GetKeyState(VK_LSHIFT) & 0x8000) != 0 && ! _lshift_down) { handle_keypress(KeyboardButton::lshift(), point.x, point.y, @@ -1959,16 +1854,15 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } - // Handle Cntrl-V paste from clipboard. Is there a better way - // to detect this hotkey? + // Handle Cntrl-V paste from clipboard. Is there a better way to detect + // this hotkey? if ((wparam=='V') && (GetKeyState(VK_CONTROL) < 0) && !_input_devices.empty()) { HGLOBAL hglb; char *lptstr; if (IsClipboardFormatAvailable(CF_TEXT) && OpenClipboard(NULL)) { - // Maybe we should support CF_UNICODETEXT if it is available - // too? + // Maybe we should support CF_UNICODETEXT if it is available too? hglb = GetClipboardData(CF_TEXT); if (hglb!=NULL) { lptstr = (char *) GlobalLock(hglb); @@ -1984,26 +1878,25 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } } else { - // Actually, for now we'll respect the repeat anyway, just - // so we support backspace properly. Rethink later. + // Actually, for now we'll respect the repeat anyway, just so we support + // backspace properly. Rethink later. POINT point; GetCursorPos(&point); ScreenToClient(hwnd, &point); handle_keypress(lookup_key(wparam), point.x, point.y, get_message_time()); - // wparam does not contain left/right information for SHIFT, - // CONTROL, or ALT, so we have to track their status and do - // the right thing. We'll send the left/right specific key - // event along with the general key event. - // - // If the user presses LSHIFT and then RSHIFT, the RSHIFT event - // will come in with the keyrepeat flag on (i.e. it will end up - // in this block). The logic below should detect this correctly - // and only send the RSHIFT event. Note that the CONTROL event - // will be sent twice, once for each keypress. Since keyrepeats - // are currently being sent simply as additional keypress events, - // that should be okay for now. +/* + * wparam does not contain leftright information for SHIFT, CONTROL, or ALT, + * so we have to track their status and do the right thing. We'll send the + * leftright specific key event along with the general key event. If the user + * presses LSHIFT and then RSHIFT, the RSHIFT event will come in with the + * keyrepeat flag on (i.e. it will end up in this block). The logic below + * should detect this correctly and only send the RSHIFT event. Note that the + * CONTROL event will be sent twice, once for each keypress. Since keyrepeats + * are currently being sent simply as additional keypress events, that should + * be okay for now. + */ if (wparam == VK_SHIFT) { if (((GetKeyState(VK_LSHIFT) & 0x8000) != 0) && ! _lshift_down ) { handle_keypress(KeyboardButton::lshift(), point.x, point.y, @@ -2058,10 +1951,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_keyrelease(lookup_key(wparam), get_message_time()); handle_raw_keyrelease(lookup_raw_key(lparam), get_message_time()); - // wparam does not contain left/right information for SHIFT, - // CONTROL, or ALT, so we have to track their status and do - // the right thing. We'll send the left/right specific key - // event along with the general key event. + // wparam does not contain leftright information for SHIFT, CONTROL, or + // ALT, so we have to track their status and do the right thing. We'll + // send the leftright specific key event along with the general key event. if (wparam == VK_SHIFT) { if ((GetKeyState(VK_LSHIFT) & 0x8000) == 0 && _lshift_down) { handle_keyrelease(KeyboardButton::lshift(), get_message_time()); @@ -2105,24 +1997,22 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_SETFOCUS: // You would think that this would be a good time to call - // resend_lost_keypresses(), but it turns out that we get - // WM_SETFOCUS slightly before Windows starts resending key - // up/down events to us. + // resend_lost_keypresses(), but it turns out that we get WM_SETFOCUS + // slightly before Windows starts resending key updown events to us. - // In particular, if the user restored focus using alt-tab, - // then at this point the keyboard state will indicate that - // both the alt and tab keys are held down. However, there is - // a small window of opportunity for the user to release these - // keys before Windows starts telling us about keyup events. - // Thus, if we record the fact that alt and tab are being held - // down now, we may miss the keyup events for them, and they - // can get "stuck" down. +/* + * In particular, if the user restored focus using alt-tab, then at this point + * the keyboard state will indicate that both the alt and tab keys are held + * down. However, there is a small window of opportunity for the user to + * release these keys before Windows starts telling us about keyup events. + * Thus, if we record the fact that alt and tab are being held down now, we + * may miss the keyup events for them, and they can get "stuck" down. + */ - // So we have to defer calling resend_lost_keypresses() until - // we know Windows is ready to send us key up/down events. I - // don't know when we can guarantee that, except when we - // actually do start to receive key up/down events, so that - // call is made there. + // So we have to defer calling resend_lost_keypresses() until we know + // Windows is ready to send us key updown events. I don't know when we + // can guarantee that, except when we actually do start to receive key + // updown events, so that call is made there. if (windisplay_cat.is_debug()) { windisplay_cat.debug() @@ -2156,8 +2046,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_DPICHANGED: - // The window moved to a monitor of different DPI, or someone changed - // the DPI setting in the configuration panel. + // The window moved to a monitor of different DPI, or someone changed the + // DPI setting in the configuration panel. if (windisplay_cat.is_debug()) { windisplay_cat.debug() << "DPI changed to " << LOWORD(wparam); @@ -2167,8 +2057,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { windisplay_cat.debug(false) << "\n"; } } - // Resize the window if requested to match the new DPI. - // Obviously, don't do this if a fixed size was requested. + // Resize the window if requested to match the new DPI. Obviously, don't + // do this if a fixed size was requested. if (!_properties.get_fixed_size() && dpi_window_resize) { RECT &rect = *(LPRECT)lparam; SetWindowPos(_hWnd, HWND_TOP, rect.left, rect.top, @@ -2188,7 +2078,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { #endif } - //do custom messages processing if any has been set + // do custom messages processing if any has been set for ( WinProcClasses::iterator it=_window_proc_classes.begin() ; it != _window_proc_classes.end(); it++ ){ (*it)->wnd_proc(this, hwnd, msg, wparam, lparam); } @@ -2197,13 +2087,10 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::static_window_proc -// Access: Private, Static -// Description: This is attached to the window class for all -// WinGraphicsWindow windows; it is called to handle -// window events. -//////////////////////////////////////////////////////////////////// +/** + * This is attached to the window class for all WinGraphicsWindow windows; it + * is called to handle window events. + */ LONG WINAPI WinGraphicsWindow:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // Look up the window in our global map. @@ -2224,18 +2111,16 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProcW(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::process_1_event -// Access: Private, Static -// Description: Handles one event from the message queue. -//////////////////////////////////////////////////////////////////// +/** + * Handles one event from the message queue. + */ void WinGraphicsWindow:: process_1_event() { MSG msg; if (!GetMessage(&msg, NULL, 0, 0)) { // WM_QUIT received. We need a cleaner way to deal with this. - // DestroyAllWindows(false); + // DestroyAllWindows(false); exit(msg.wParam); // this will invoke AtExitFn } @@ -2245,32 +2130,25 @@ process_1_event() { DispatchMessage(&msg); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::resend_lost_keypresses -// Access: Private, Static -// Description: Called when the keyboard focus has been restored to -// the window after it has been lost for a time, this -// rechecks the keyboard state and generates key up/down -// messages for keys that have changed state in the -// meantime. -//////////////////////////////////////////////////////////////////// +/** + * Called when the keyboard focus has been restored to the window after it has + * been lost for a time, this rechecks the keyboard state and generates key + * up/down messages for keys that have changed state in the meantime. + */ void WinGraphicsWindow:: resend_lost_keypresses() { nassertv(_lost_keypresses); - // This is now a no-op. Not sure we really want to generate new - // "down" or "resume" events for keys that were held while the - // window focus is restored. + // This is now a no-op. Not sure we really want to generate new "down" or + // "resume" events for keys that were held while the window focus is + // restored. _lost_keypresses = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::update_cursor_window -// Access: Private, Static -// Description: Changes _cursor_window from its current value to the -// indicated value. This also changes the cursor -// properties appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Changes _cursor_window from its current value to the indicated value. This + * also changes the cursor properties appropriately. + */ void WinGraphicsWindow:: update_cursor_window(WinGraphicsWindow *to_window) { bool hide_cursor = false; @@ -2291,12 +2169,11 @@ update_cursor_window(WinGraphicsWindow *to_window) { const WindowProperties &to_props = to_window->get_properties(); hide_cursor = to_props.get_cursor_hidden(); - // We are entering a graphics window; we should save and disable - // the Win2000 effects. These don't work at all well over a 3-D - // window. + // We are entering a graphics window; we should save and disable the + // Win2000 effects. These don't work at all well over a 3-D window. - // These parameters are only defined for Win2000/XP, but they - // should just cause a silent error on earlier OS's, which is OK. + // These parameters are only defined for Win2000XP, but they should just + // cause a silent error on earlier OS's, which is OK. if (!_got_saved_params) { SystemParametersInfo(SPI_GETMOUSETRAILS, NULL, &_saved_mouse_trails, NULL); @@ -2319,14 +2196,11 @@ update_cursor_window(WinGraphicsWindow *to_window) { _cursor_window = to_window; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::hide_or_show_cursor -// Access: Private, Static -// Description: Hides or shows the mouse cursor according to the -// indicated parameter. This is normally called when -// the mouse wanders into or out of a window with the -// cursor_hidden properties. -//////////////////////////////////////////////////////////////////// +/** + * Hides or shows the mouse cursor according to the indicated parameter. This + * is normally called when the mouse wanders into or out of a window with the + * cursor_hidden properties. + */ void WinGraphicsWindow:: hide_or_show_cursor(bool hide_cursor) { if (hide_cursor) { @@ -2344,16 +2218,14 @@ hide_or_show_cursor(bool hide_cursor) { // don't pick any video modes < MIN_REFRESH_RATE Hz #define MIN_REFRESH_RATE 60 -// EnumDisplaySettings may indicate 0 or 1 for refresh rate, which means use driver default rate (assume its >min_refresh_rate) +// EnumDisplaySettings may indicate 0 or 1 for refresh rate, which means use +// driver default rate (assume its >min_refresh_rate) #define ACCEPTABLE_REFRESH_RATE(RATE) ((RATE >= MIN_REFRESH_RATE) || (RATE==0) || (RATE==1)) -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::find_acceptable_display_mode -// Access: Private, Static -// Description: Looks for a fullscreen mode that meets the specified -// size and bitdepth requirements. Returns true if a -// suitable mode is found, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a fullscreen mode that meets the specified size and bitdepth + * requirements. Returns true if a suitable mode is found, false otherwise. + */ bool WinGraphicsWindow:: find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, DEVMODE &dm) { @@ -2377,13 +2249,10 @@ find_acceptable_display_mode(DWORD dwWidth, DWORD dwHeight, DWORD bpp, return false; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::show_error_message -// Access: Private, Static -// Description: Pops up a dialog box with the indicated Windows error -// message ID (or the last error message generated) for -// meaningful display to the user. -//////////////////////////////////////////////////////////////////// +/** + * Pops up a dialog box with the indicated Windows error message ID (or the + * last error message generated) for meaningful display to the user. + */ void WinGraphicsWindow:: show_error_message(DWORD message_id) { LPTSTR message_buffer; @@ -2402,11 +2271,9 @@ show_error_message(DWORD message_id) { LocalFree(message_buffer); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_keypress -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_keypress(ButtonHandle key, int x, int y, double time) { _input_devices[0].set_pointer_in_window(x, y); @@ -2415,13 +2282,10 @@ handle_keypress(ButtonHandle key, int x, int y, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_keyresume -// Access: Private -// Description: Indicates we detected a key was already down when the -// focus is restored to the window. Mainly useful for -// tracking the state of modifier keys. -//////////////////////////////////////////////////////////////////// +/** + * Indicates we detected a key was already down when the focus is restored to + * the window. Mainly useful for tracking the state of modifier keys. + */ void WinGraphicsWindow:: handle_keyresume(ButtonHandle key, double time) { if (key != ButtonHandle::none()) { @@ -2429,11 +2293,9 @@ handle_keyresume(ButtonHandle key, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_keyrelease -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_keyrelease(ButtonHandle key, double time) { if (key != ButtonHandle::none()) { @@ -2441,11 +2303,9 @@ handle_keyrelease(ButtonHandle key, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_raw_keypress -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_raw_keypress(ButtonHandle key, double time) { if (key != ButtonHandle::none()) { @@ -2453,11 +2313,9 @@ handle_raw_keypress(ButtonHandle key, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_raw_keyrelease -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_raw_keyrelease(ButtonHandle key, double time) { if (key != ButtonHandle::none()) { @@ -2465,16 +2323,14 @@ handle_raw_keyrelease(ButtonHandle key, double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::lookup_key -// Access: Private -// Description: Translates the keycode reported by Windows to an -// appropriate Panda ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Translates the keycode reported by Windows to an appropriate Panda + * ButtonHandle. + */ ButtonHandle WinGraphicsWindow:: lookup_key(WPARAM wparam) const { - // First, check for a few buttons that we filter out when the IME - // window is open. + // First, check for a few buttons that we filter out when the IME window is + // open. if (!_ime_active) { switch(wparam) { case VK_BACK: return KeyboardButton::backspace(); @@ -2488,8 +2344,8 @@ lookup_key(WPARAM wparam) const { } } - // Now check for the rest of the buttons, including the ones that - // we allow through even when the IME window is open. + // Now check for the rest of the buttons, including the ones that we allow + // through even when the IME window is open. switch(wparam) { case VK_TAB: return KeyboardButton::tab(); case VK_PRIOR: return KeyboardButton::page_up(); @@ -2530,19 +2386,16 @@ lookup_key(WPARAM wparam) const { default: int key = MapVirtualKey(wparam, 2); if (isascii(key) && key != 0) { - // We used to try to remap lowercase to uppercase keys - // here based on the state of the shift and/or caps lock - // keys. But that's a mistake, and doesn't allow for - // international or user-defined keyboards; let Windows - // do that mapping. + // We used to try to remap lowercase to uppercase keys here based on the + // state of the shift andor caps lock keys. But that's a mistake, and + // doesn't allow for international or user-defined keyboards; let + // Windows do that mapping. - // Nowadays, we make a distinction between a "button" - // and a "keystroke". A button corresponds to a - // physical button on the keyboard and has a down and up - // event associated. A keystroke may or may not - // correspond to a physical button, but will be some - // Unicode character and will not have a corresponding - // up event. + // Nowadays, we make a distinction between a "button" and a "keystroke". + // A button corresponds to a physical button on the keyboard and has a + // down and up event associated. A keystroke may or may not correspond + // to a physical button, but will be some Unicode character and will not + // have a corresponding up event. return KeyboardButton::ascii_key(tolower(key)); } break; @@ -2550,12 +2403,10 @@ lookup_key(WPARAM wparam) const { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::lookup_raw_key -// Access: Private -// Description: Translates the scancode reported by Windows to an -// appropriate Panda ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Translates the scancode reported by Windows to an appropriate Panda + * ButtonHandle. + */ ButtonHandle WinGraphicsWindow:: lookup_raw_key(LPARAM lparam) const { unsigned char vsc = (lparam & 0xff0000) >> 16; @@ -2683,15 +2534,13 @@ lookup_raw_key(LPARAM lparam) const { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_keyboard_map -// Access: Published, Virtual -// Description: Returns a ButtonMap containing the association -// between raw buttons and virtual buttons. -// -// Note that on Windows, the pause button and numpad -// keys are not mapped reliably. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ButtonMap containing the association between raw buttons and + * virtual buttons. + * + * Note that on Windows, the pause button and numpad keys are not mapped + * reliably. + */ ButtonMap *WinGraphicsWindow:: get_keyboard_map() const { ButtonMap *map = new ButtonMap; @@ -2747,11 +2596,9 @@ get_keyboard_map() const { return map; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_raw_input -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_raw_input(HRAWINPUT hraw) { LPBYTE lpb; @@ -2825,35 +2672,28 @@ handle_raw_input(HRAWINPUT hraw) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_mouse_motion -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool WinGraphicsWindow:: handle_mouse_motion(int x, int y) { _input_devices[0].set_pointer_in_window(x, y); return false; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::handle_mouse_exit -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinGraphicsWindow:: handle_mouse_exit() { // note: 'mouse_motion' is considered the 'entry' event _input_devices[0].set_pointer_out_of_window(); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_icon -// Access: Private, Static -// Description: Loads and returns an HICON corresponding to the -// indicated filename. If the file cannot be loaded, -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Loads and returns an HICON corresponding to the indicated filename. If the + * file cannot be loaded, returns 0. + */ HICON WinGraphicsWindow:: get_icon(const Filename &filename) { // First, look for the unresolved filename in our index. @@ -2864,9 +2704,8 @@ get_icon(const Filename &filename) { // If it wasn't found, resolve the filename and search for that. - // Since we have to use a Windows call to load the image from a - // filename, we can't load a virtual file and we can't use the - // virtual file system. + // Since we have to use a Windows call to load the image from a filename, we + // can't load a virtual file and we can't use the virtual file system. Filename resolved = filename; if (!resolved.resolve_filename(get_model_path())) { // The filename doesn't exist along the search path. @@ -2899,13 +2738,10 @@ get_icon(const Filename &filename) { return (HICON)h; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_cursor -// Access: Private, Static -// Description: Loads and returns an HCURSOR corresponding to the -// indicated filename. If the file cannot be loaded, -// returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Loads and returns an HCURSOR corresponding to the indicated filename. If + * the file cannot be loaded, returns 0. + */ HCURSOR WinGraphicsWindow:: get_cursor(const Filename &filename) { // The empty filename means to disable a custom cursor. @@ -2921,9 +2757,8 @@ get_cursor(const Filename &filename) { // If it wasn't found, resolve the filename and search for that. - // Since we have to use a Windows call to load the image from a - // filename, we can't load a virtual file and we can't use the - // virtual file system. + // Since we have to use a Windows call to load the image from a filename, we + // can't load a virtual file and we can't use the virtual file system. Filename resolved = filename; if (!resolved.resolve_filename(get_model_path())) { // The filename doesn't exist. @@ -2954,13 +2789,10 @@ get_cursor(const Filename &filename) { static HCURSOR get_cursor(const Filename &filename); -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::register_window_class -// Access: Private, Static -// Description: Registers a Window class appropriate for the -// indicated properties. This class may be shared by -// multiple windows. -//////////////////////////////////////////////////////////////////// +/** + * Registers a Window class appropriate for the indicated properties. This + * class may be shared by multiple windows. + */ const WinGraphicsWindow::WindowClass &WinGraphicsWindow:: register_window_class(const WindowProperties &props) { WindowClass wcreg(props); @@ -3004,11 +2836,9 @@ register_window_class(const WindowProperties &props) { return wclass; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::WinWindowHandle::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinGraphicsWindow::WinWindowHandle:: WinWindowHandle(WinGraphicsWindow *window, const WindowHandle ©) : WindowHandle(copy), @@ -3016,25 +2846,20 @@ WinWindowHandle(WinGraphicsWindow *window, const WindowHandle ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::WinWindowHandle::clear_window -// Access: Public -// Description: Should be called by the WinGraphicsWindow's -// destructor, so that we don't end up with a floating -// pointer should this object persist beyond the -// lifespan of its window. -//////////////////////////////////////////////////////////////////// +/** + * Should be called by the WinGraphicsWindow's destructor, so that we don't + * end up with a floating pointer should this object persist beyond the + * lifespan of its window. + */ void WinGraphicsWindow::WinWindowHandle:: clear_window() { _window = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::WinWindowHandle::receive_windows_message -// Access: Public, Virtual -// Description: Called on a child handle to deliver a keyboard button -// event generated in the parent window. -//////////////////////////////////////////////////////////////////// +/** + * Called on a child handle to deliver a keyboard button event generated in + * the parent window. + */ void WinGraphicsWindow::WinWindowHandle:: receive_windows_message(unsigned int msg, int wparam, int lparam) { if (_window != NULL) { @@ -3043,7 +2868,7 @@ receive_windows_message(unsigned int msg, int wparam, int lparam) { } -// pops up MsgBox w/system error msg +// pops up MsgBox wsystem error msg void PrintErrorMessage(DWORD msgID) { LPTSTR pMessageBuffer; @@ -3086,12 +2911,10 @@ ClearToBlack(HWND hWnd, const WindowProperties &props) { GdiFlush(); } -//////////////////////////////////////////////////////////////////// -// Function: get_client_rect_screen -// Description: Fills view_rect with the coordinates of the client -// area of the indicated window, converted to screen -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Fills view_rect with the coordinates of the client area of the indicated + * window, converted to screen coordinates. + */ void get_client_rect_screen(HWND hwnd, RECT *view_rect) { GetClientRect(hwnd, view_rect); @@ -3110,55 +2933,45 @@ void get_client_rect_screen(HWND hwnd, RECT *view_rect) { view_rect->bottom = lr.y; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::add_window_proc -// Access: Public, Virtual -// Description: Adds the specified Windows proc event handler to be called -// whenever a Windows event occurs. -// -//////////////////////////////////////////////////////////////////// +/** + * Adds the specified Windows proc event handler to be called whenever a + * Windows event occurs. + * + */ void WinGraphicsWindow::add_window_proc( const GraphicsWindowProc* wnd_proc ){ nassertv(wnd_proc != NULL); _window_proc_classes.insert( (GraphicsWindowProc*)wnd_proc ); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::remove_window_proc -// Access: Public, Virtual -// Description: Removes the specified Windows proc event handler. -// -//////////////////////////////////////////////////////////////////// +/** + * Removes the specified Windows proc event handler. + * + */ void WinGraphicsWindow::remove_window_proc( const GraphicsWindowProc* wnd_proc ){ nassertv(wnd_proc != NULL); _window_proc_classes.erase( (GraphicsWindowProc*)wnd_proc ); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::clear_window_procs -// Access: Public, Virtual -// Description: Removes all Windows proc event handlers. -// -//////////////////////////////////////////////////////////////////// +/** + * Removes all Windows proc event handlers. + * + */ void WinGraphicsWindow::clear_window_procs(){ _window_proc_classes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::supports_window_procs -// Access: Public, Virtual -// Description: Returns whether this window supports adding of windows proc handlers. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns whether this window supports adding of windows proc handlers. + * + */ bool WinGraphicsWindow::supports_window_procs() const{ return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::is_touch_event -// Access: Public, Virtual -// Description: Returns whether the specified event msg is a touch message. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the specified event msg is a touch message. + * + */ bool WinGraphicsWindow:: is_touch_event(GraphicsWindowProcCallbackData* callbackData){ #ifdef HAVE_WIN_TOUCHINPUT @@ -3168,12 +2981,10 @@ is_touch_event(GraphicsWindowProcCallbackData* callbackData){ #endif } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_num_touches -// Access: Public, Virtual -// Description: Returns the current number of touches on this window. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of touches on this window. + * + */ int WinGraphicsWindow:: get_num_touches(){ #ifdef HAVE_WIN_TOUCHINPUT @@ -3183,12 +2994,10 @@ get_num_touches(){ #endif } -//////////////////////////////////////////////////////////////////// -// Function: WinGraphicsWindow::get_touch_info -// Access: Public, Virtual -// Description: Returns the TouchInfo object describing the specified touch. -// -//////////////////////////////////////////////////////////////////// +/** + * Returns the TouchInfo object describing the specified touch. + * + */ TouchInfo WinGraphicsWindow:: get_touch_info(int index){ #ifdef HAVE_WIN_TOUCHINPUT diff --git a/panda/src/windisplay/winGraphicsWindow.h b/panda/src/windisplay/winGraphicsWindow.h index 1b3ee93f95..798218052a 100644 --- a/panda/src/windisplay/winGraphicsWindow.h +++ b/panda/src/windisplay/winGraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: winGraphicsWindow.h -// Created by: drose (20Dec02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winGraphicsWindow.h + * @author drose + * @date 2002-12-20 + */ #ifndef WINGRAPHICSWINDOW_H #define WINGRAPHICSWINDOW_H @@ -38,19 +37,15 @@ typedef struct { } WINDOW_METRICS; -//////////////////////////////////////////////////////////////////// -// Class : WinGraphicsWindow -// Description : An abstract base class for glGraphicsWindow and -// dxGraphicsWindow (and, in general, graphics windows -// that interface with the Microsoft Windows API). -// -// This class includes all the code for manipulating -// windows themselves: opening them, closing them, -// responding to user keyboard and mouse input, and so -// on. It does not make any 3-D rendering calls into -// the window; that is the province of the -// GraphicsStateGuardian. -//////////////////////////////////////////////////////////////////// +/** + * An abstract base class for glGraphicsWindow and dxGraphicsWindow (and, in + * general, graphics windows that interface with the Microsoft Windows API). + * + * This class includes all the code for manipulating windows themselves: + * opening them, closing them, responding to user keyboard and mouse input, + * and so on. It does not make any 3-D rendering calls into the window; that + * is the province of the GraphicsStateGuardian. + */ class EXPCL_PANDAWIN WinGraphicsWindow : public GraphicsWindow { public: WinGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -110,7 +105,7 @@ protected: virtual DWORD make_style(bool fullscreen); - virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size, + virtual void reconsider_fullscreen_size(DWORD &x_size, DWORD &y_size, DWORD &bitdepth); virtual void support_overlay_window(bool flag); @@ -168,10 +163,9 @@ private: bool _lost_keypresses; // These are used to store the status of the individual left and right - // shift, control, and alt keys. Keyboard events are not sent for - // these individual keys, but for each pair as a whole. The status - // of each key must be checked as keypress and keyrelease events are - // received. + // shift, control, and alt keys. Keyboard events are not sent for these + // individual keys, but for each pair as a whole. The status of each key + // must be checked as keypress and keyrelease events are received. bool _lshift_down; bool _rshift_down; bool _lcontrol_down; @@ -179,8 +173,7 @@ private: bool _lalt_down; bool _ralt_down; - // following adds support platform specfic window processing - // functions. + // following adds support platform specfic window processing functions. typedef pset WinProcClasses; WinProcClasses _window_proc_classes; @@ -194,19 +187,19 @@ private: typedef map WindowHandles; static WindowHandles _window_handles; - // And we need a static pointer to the current WinGraphicsWindow we - // are creating at the moment, since CreateWindow() starts - // generating window events before it gives us the window handle. + // And we need a static pointer to the current WinGraphicsWindow we are + // creating at the moment, since CreateWindow() starts generating window + // events before it gives us the window handle. static WinGraphicsWindow *_creating_window; - // This tracks the current GraphicsWindow whose client area contains - // the mouse. There will only be one of these at a time, and - // storing the pointer here allows us to handle ambiguities in the - // order in which messages are passed from Windows to the various - // windows we manage. This pointer is used by - // set_cursor_in_window() to determine when it is time to call - // update_cursor() to hide the cursor (or do other related - // operations). +/* + * This tracks the current GraphicsWindow whose client area contains the + * mouse. There will only be one of these at a time, and storing the pointer + * here allows us to handle ambiguities in the order in which messages are + * passed from Windows to the various windows we manage. This pointer is used + * by set_cursor_in_window() to determine when it is time to call + * update_cursor() to hide the cursor (or do other related operations). + */ static WinGraphicsWindow *_cursor_window; static bool _cursor_hidden; static bool _got_saved_params; @@ -217,9 +210,9 @@ private: // The mouse constraints before applying mouse mode M_confined. static RECT _mouse_unconfined_cliprect; - // Since the Panda API requests icons and cursors by filename, we - // need a table mapping filenames to handles, so we can avoid - // re-reading the file each time we change icons. + // Since the Panda API requests icons and cursors by filename, we need a + // table mapping filenames to handles, so we can avoid re-reading the file + // each time we change icons. typedef pmap IconFilenames; static IconFilenames _icon_filenames; static IconFilenames _cursor_filenames; @@ -227,10 +220,10 @@ private: static HICON get_icon(const Filename &filename); static HCURSOR get_cursor(const Filename &filename); - // The table of window classes we have registered. We need to - // register a different window class for each different window icon - // (the cursor we can specify dynamically, later). We might have - // other requirements too, later. + // The table of window classes we have registered. We need to register a + // different window class for each different window icon (the cursor we can + // specify dynamically, later). We might have other requirements too, + // later. class WindowClass { public: INLINE WindowClass(const WindowProperties &props); @@ -246,10 +239,10 @@ private: static const WindowClass ®ister_window_class(const WindowProperties &props); private: - // This subclass of WindowHandle is stored in _window_handle to - // represent this particular window. We use it to add hooks for - // communicating with the parent window, in particular to receive - // keyboard events from the parent window when necessary. + // This subclass of WindowHandle is stored in _window_handle to represent + // this particular window. We use it to add hooks for communicating with + // the parent window, in particular to receive keyboard events from the + // parent window when necessary. class WinWindowHandle : public WindowHandle { public: WinWindowHandle(WinGraphicsWindow *window, @@ -276,7 +269,7 @@ private: return get_class_type(); } virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - + private: static TypeHandle _type_handle; }; diff --git a/panda/src/x11display/config_x11display.cxx b/panda/src/x11display/config_x11display.cxx index c609a2a5d8..13b225e418 100644 --- a/panda/src/x11display/config_x11display.cxx +++ b/panda/src/x11display/config_x11display.cxx @@ -1,16 +1,15 @@ -// Filename: config_x11display.cxx -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_x11display.cxx + * @author rdb + * @date 2009-07-07 + */ #include "config_x11display.h" #include "x11GraphicsPipe.h" @@ -36,7 +35,7 @@ ConfigVariableBool x_error_abort PRC_DESC("Set this true to trigger and abort (and a stack trace) on receipt " "of an error from the X window system. This can make it easier " "to discover where these errors are generated.")); - + ConfigVariableInt x_wheel_up_button ("x-wheel-up-button", 4, PRC_DESC("This is the mouse button index of the wheel_up event: which " @@ -71,14 +70,12 @@ ConfigVariableString x_wm_class PRC_DESC("Specify the value to use for the res_class field of the window's " "WM_CLASS property.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libx11display -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libx11display() { static bool initialized = false; diff --git a/panda/src/x11display/config_x11display.h b/panda/src/x11display/config_x11display.h index e21085672d..88fb2f2133 100644 --- a/panda/src/x11display/config_x11display.h +++ b/panda/src/x11display/config_x11display.h @@ -1,16 +1,15 @@ -// Filename: config_x11display.h -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_x11display.h + * @author rdb + * @date 2009-07-07 + */ #ifndef CONFIG_X11DISPLAY_H #define CONFIG_X11DISPLAY_H diff --git a/panda/src/x11display/x11GraphicsPipe.I b/panda/src/x11display/x11GraphicsPipe.I index 67b4300788..cb452bef23 100644 --- a/panda/src/x11display/x11GraphicsPipe.I +++ b/panda/src/x11display/x11GraphicsPipe.I @@ -1,68 +1,54 @@ -// Filename: x11GraphicsPipe.I -// Created by: drose (30Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsPipe.I + * @author drose + * @date 2000-10-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_display -// Access: Public -// Description: Returns a pointer to the X display associated with -// the pipe: the display on which to create the windows. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the X display associated with the pipe: the display on + * which to create the windows. + */ INLINE X11_Display *x11GraphicsPipe:: get_display() const { return _display; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_screen -// Access: Public -// Description: Returns the X screen number associated with the pipe. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X screen number associated with the pipe. + */ INLINE int x11GraphicsPipe:: get_screen() const { return _screen; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_root -// Access: Public -// Description: Returns the handle to the root window on the pipe's -// display. -//////////////////////////////////////////////////////////////////// +/** + * Returns the handle to the root window on the pipe's display. + */ INLINE X11_Window x11GraphicsPipe:: get_root() const { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_im -// Access: Public -// Description: Returns the input method opened for the pipe, or NULL -// if the input method could not be opened for some -// reason. -//////////////////////////////////////////////////////////////////// +/** + * Returns the input method opened for the pipe, or NULL if the input method + * could not be opened for some reason. + */ INLINE XIM x11GraphicsPipe:: get_im() const { return _im; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_hidden_cursor -// Access: Public -// Description: Returns an invisible Cursor suitable for assigning to -// windows that have the cursor_hidden property set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an invisible Cursor suitable for assigning to windows that have the + * cursor_hidden property set. + */ INLINE X11_Cursor x11GraphicsPipe:: get_hidden_cursor() { if (_hidden_cursor == None) { @@ -71,47 +57,37 @@ get_hidden_cursor() { return _hidden_cursor; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::disable_x_error_messages -// Access: Public, Static -// Description: Globally disables the printing of error messages that -// are raised by the X11 system, for instance in order -// to test whether a particular X11 operation will -// succeed. Reenable error messages with a later call -// to enable_x_error_messages(). -// -// The return value is the current value of -// get_x_error_count(). -//////////////////////////////////////////////////////////////////// +/** + * Globally disables the printing of error messages that are raised by the X11 + * system, for instance in order to test whether a particular X11 operation + * will succeed. Reenable error messages with a later call to + * enable_x_error_messages(). + * + * The return value is the current value of get_x_error_count(). + */ INLINE int x11GraphicsPipe:: disable_x_error_messages() { _x_error_messages_enabled = false; return _x_error_count; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::enable_x_error_messages -// Access: Public, Static -// Description: Reenables the printing of error messages after a -// previous call to disable_x_error_messages(). -// -// The return value is the current value of -// get_x_error_count(). -//////////////////////////////////////////////////////////////////// +/** + * Reenables the printing of error messages after a previous call to + * disable_x_error_messages(). + * + * The return value is the current value of get_x_error_count(). + */ INLINE int x11GraphicsPipe:: enable_x_error_messages() { _x_error_messages_enabled = true; return _x_error_count; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_x_error_count -// Access: Public, Static -// Description: Returns the number of times an error indication has -// been raised by the X11 system since application -// start, including errors raised while error messages -// were disabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times an error indication has been raised by the X11 + * system since application start, including errors raised while error + * messages were disabled. + */ INLINE int x11GraphicsPipe:: get_x_error_count() { return _x_error_count; diff --git a/panda/src/x11display/x11GraphicsPipe.cxx b/panda/src/x11display/x11GraphicsPipe.cxx index e6fc85a3e3..9eee9f6d7a 100644 --- a/panda/src/x11display/x11GraphicsPipe.cxx +++ b/panda/src/x11display/x11GraphicsPipe.cxx @@ -1,16 +1,15 @@ -// Filename: x11GraphicsPipe.cxx -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsPipe.cxx + * @author rdb + * @date 2009-07-07 + */ #include "x11GraphicsPipe.h" #include "x11GraphicsWindow.h" @@ -28,11 +27,9 @@ int x11GraphicsPipe::_x_error_count = 0; LightReMutex x11GraphicsPipe::_x_mutex; -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ x11GraphicsPipe:: x11GraphicsPipe(const string &display) { string display_spec = display; @@ -46,13 +43,13 @@ x11GraphicsPipe(const string &display) { display_spec = ":0.0"; } - // The X docs say we should do this to get international character - // support from the keyboard. + // The X docs say we should do this to get international character support + // from the keyboard. setlocale(LC_ALL, ""); - // But it's important that we use the "C" locale for numeric - // formatting, since all of the internal Panda code assumes this--we - // need a decimal point to mean a decimal point. + // But it's important that we use the "C" locale for numeric formatting, + // since all of the internal Panda code assumes this--we need a decimal + // point to mean a decimal point. setlocale(LC_NUMERIC, "C"); _is_valid = false; @@ -99,7 +96,7 @@ x11GraphicsPipe(const string &display) { XRRRates(_display, 0, i, &num_rates); _display_information->_total_display_modes += num_rates; } - + short *rates; short counter = 0; _display_information->_display_mode_array = new DisplayMode[_display_information->_total_display_modes]; @@ -118,8 +115,7 @@ x11GraphicsPipe(const string &display) { } #endif - // Connect to an input method for supporting international text - // entry. + // Connect to an input method for supporting international text entry. _im = XOpenIM(_display, NULL, NULL, NULL); if (_im == (XIM)NULL) { x11display_cat.warning() @@ -153,11 +149,9 @@ x11GraphicsPipe(const string &display) { _net_wm_state_remove = XInternAtom(_display, "_NET_WM_STATE_REMOVE", false); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ x11GraphicsPipe:: ~x11GraphicsPipe() { release_hidden_cursor(); @@ -169,36 +163,30 @@ x11GraphicsPipe:: } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::get_preferred_window_thread -// Access: Public, Virtual -// Description: Returns an indication of the thread in which this -// GraphicsPipe requires its window processing to be -// performed: typically either the app thread (e.g. X) -// or the draw thread (Windows). -//////////////////////////////////////////////////////////////////// -GraphicsPipe::PreferredWindowThread +/** + * Returns an indication of the thread in which this GraphicsPipe requires its + * window processing to be performed: typically either the app thread (e.g. + * X) or the draw thread (Windows). + */ +GraphicsPipe::PreferredWindowThread x11GraphicsPipe::get_preferred_window_thread() const { - // Actually, since we're creating the graphics context in - // open_window() now, it appears we need to ensure the open_window() - // call is performed in the draw thread for now, even though X wants - // all of its calls to be single-threaded. + // Actually, since we're creating the graphics context in open_window() now, + // it appears we need to ensure the open_window() call is performed in the + // draw thread for now, even though X wants all of its calls to be single- + // threaded. - // This means that all X windows may have to be handled by the same - // draw thread, which we didn't intend (though the global _x_mutex - // may allow them to be technically served by different threads, - // even though the actual X calls will be serialized). There might - // be a better way. + // This means that all X windows may have to be handled by the same draw + // thread, which we didn't intend (though the global _x_mutex may allow them + // to be technically served by different threads, even though the actual X + // calls will be serialized). There might be a better way. return PWT_draw; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::make_hidden_cursor -// Access: Private -// Description: Called once to make an invisible Cursor for return -// from get_hidden_cursor(). -//////////////////////////////////////////////////////////////////// +/** + * Called once to make an invisible Cursor for return from + * get_hidden_cursor(). + */ void x11GraphicsPipe:: make_hidden_cursor() { nassertv(_hidden_cursor == None); @@ -211,17 +199,15 @@ make_hidden_cursor() { XColor black; memset(&black, 0, sizeof(black)); - _hidden_cursor = XCreatePixmapCursor(_display, empty, empty, + _hidden_cursor = XCreatePixmapCursor(_display, empty, empty, &black, &black, x_size, y_size); XFreePixmap(_display, empty); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::release_hidden_cursor -// Access: Private -// Description: Called once to release the invisible cursor created -// by make_hidden_cursor(). -//////////////////////////////////////////////////////////////////// +/** + * Called once to release the invisible cursor created by + * make_hidden_cursor(). + */ void x11GraphicsPipe:: release_hidden_cursor() { if (_hidden_cursor != None) { @@ -230,17 +216,13 @@ release_hidden_cursor() { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::install_error_handlers -// Access: Private, Static -// Description: Installs new Xlib error handler functions if this is -// the first time this function has been called. These -// error handler functions will attempt to reduce Xlib's -// annoying tendency to shut down the client at the -// first error. Unfortunately, it is difficult to play -// nice with the client if it has already installed its -// own error handlers. -//////////////////////////////////////////////////////////////////// +/** + * Installs new Xlib error handler functions if this is the first time this + * function has been called. These error handler functions will attempt to + * reduce Xlib's annoying tendency to shut down the client at the first error. + * Unfortunately, it is difficult to play nice with the client if it has + * already installed its own error handlers. + */ void x11GraphicsPipe:: install_error_handlers() { if (_error_handlers_installed) { @@ -252,12 +234,9 @@ install_error_handlers() { _error_handlers_installed = true; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::error_handler -// Access: Private, Static -// Description: This function is installed as the error handler for a -// non-fatal Xlib error. -//////////////////////////////////////////////////////////////////// +/** + * This function is installed as the error handler for a non-fatal Xlib error. + */ int x11GraphicsPipe:: error_handler(X11_Display *display, XErrorEvent *error) { ++_x_error_count; @@ -281,25 +260,22 @@ error_handler(X11_Display *display, XErrorEvent *error) { abort(); } - // We return to allow the application to continue running, unlike - // the default X error handler which exits. + // We return to allow the application to continue running, unlike the + // default X error handler which exits. return 0; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsPipe::io_error_handler -// Access: Private, Static -// Description: This function is installed as the error handler for a -// fatal Xlib error. -//////////////////////////////////////////////////////////////////// +/** + * This function is installed as the error handler for a fatal Xlib error. + */ int x11GraphicsPipe:: io_error_handler(X11_Display *display) { x11display_cat.fatal() << "X fatal error on display " << (void *)display << "\n"; - // Unfortunately, we can't continue from this function, even if we - // promise never to use X again. We're supposed to terminate - // without returning, and if we do return, the caller will exit - // anyway. Sigh. Very poor design on X's part. + // Unfortunately, we can't continue from this function, even if we promise + // never to use X again. We're supposed to terminate without returning, and + // if we do return, the caller will exit anyway. Sigh. Very poor design on + // X's part. return 0; } diff --git a/panda/src/x11display/x11GraphicsPipe.h b/panda/src/x11display/x11GraphicsPipe.h index 2cd07245b4..ab06a9b692 100644 --- a/panda/src/x11display/x11GraphicsPipe.h +++ b/panda/src/x11display/x11GraphicsPipe.h @@ -1,16 +1,15 @@ -// Filename: x11GraphicsPipe.h -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsPipe.h + * @author rdb + * @date 2009-07-07 + */ #ifndef X11GRAPHICSPIPE_H #define X11GRAPHICSPIPE_H @@ -25,11 +24,10 @@ class FrameBufferProperties; -//////////////////////////////////////////////////////////////////// -// Class : x11GraphicsPipe -// Description : This graphics pipe represents the interface for -// creating graphics windows on an X-based client. -//////////////////////////////////////////////////////////////////// +/** + * This graphics pipe represents the interface for creating graphics windows + * on an X-based client. + */ class x11GraphicsPipe : public GraphicsPipe { public: x11GraphicsPipe(const string &display = string()); @@ -84,13 +82,13 @@ private: static bool _error_handlers_installed; static ErrorHandlerFunc *_prev_error_handler; static IOErrorHandlerFunc *_prev_io_error_handler; - + static bool _x_error_messages_enabled; static int _x_error_count; public: - // This Mutex protects any X library calls, which all have to be - // single-threaded. In particular, it protects glXMakeCurrent(). + // This Mutex protects any X library calls, which all have to be single- + // threaded. In particular, it protects glXMakeCurrent(). static LightReMutex _x_mutex; public: diff --git a/panda/src/x11display/x11GraphicsWindow.I b/panda/src/x11display/x11GraphicsWindow.I index 0e43adc9fa..aab1b52fe5 100644 --- a/panda/src/x11display/x11GraphicsWindow.I +++ b/panda/src/x11display/x11GraphicsWindow.I @@ -1,23 +1,19 @@ -// Filename: x11GraphicsWindow.I -// Created by: mike (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsWindow.I + * @author mike + * @date 1999-03-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_xwindow -// Access: Public -// Description: Returns the X11 Window handle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X11 Window handle. + */ INLINE X11_Window x11GraphicsWindow:: get_xwindow() const { return _xwindow; diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 326953d0c4..6ea711b3b5 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -1,16 +1,15 @@ -// Filename: x11GraphicsWindow.cxx -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsWindow.cxx + * @author rdb + * @date 2009-07-07 + */ #include "x11GraphicsWindow.h" #include "config_x11display.h" @@ -71,11 +70,9 @@ TypeHandle x11GraphicsWindow::_type_handle; #define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)&7))) -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ x11GraphicsWindow:: x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, @@ -112,11 +109,9 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, add_input_device(device); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ x11GraphicsWindow:: ~x11GraphicsWindow() { pmap::iterator it; @@ -126,16 +121,14 @@ x11GraphicsWindow:: } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::move_pointer -// Access: Published, Virtual -// Description: Forces the pointer to the indicated position within -// the window, if possible. -// -// Returns true if successful, false on failure. This -// may fail if the mouse is not currently within the -// window, or if the API doesn't support this operation. -//////////////////////////////////////////////////////////////////// +/** + * Forces the pointer to the indicated position within the window, if + * possible. + * + * Returns true if successful, false on failure. This may fail if the mouse + * is not currently within the window, or if the API doesn't support this + * operation. + */ bool x11GraphicsWindow:: move_pointer(int device, int x, int y) { // Note: this is not thread-safe; it should be called only from App. @@ -144,8 +137,8 @@ move_pointer(int device, int x, int y) { // Move the system mouse pointer. if (!_properties.get_foreground() || !_input_devices[0].get_pointer().get_in_window()) { - // If the window doesn't have input focus, or the mouse isn't - // currently within the window, forget it. + // If the window doesn't have input focus, or the mouse isn't currently + // within the window, forget it. return false; } @@ -167,15 +160,12 @@ move_pointer(int device, int x, int y) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::begin_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// before beginning rendering for a given frame. It -// should do whatever setup is required, and return true -// if the frame should be rendered, or false if it -// should be skipped. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread before beginning + * rendering for a given frame. It should do whatever setup is required, and + * return true if the frame should be rendered, or false if it should be + * skipped. + */ bool x11GraphicsWindow:: begin_frame(FrameMode mode, Thread *current_thread) { PStatTimer timer(_make_current_pcollector, current_thread); @@ -185,14 +175,14 @@ begin_frame(FrameMode mode, Thread *current_thread) { return false; } if (_awaiting_configure) { - // Don't attempt to draw while we have just reconfigured the - // window and we haven't got the notification back yet. + // Don't attempt to draw while we have just reconfigured the window and we + // haven't got the notification back yet. return false; } - // Reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) + // Reset the GSG state if this is the first time it has been used. (We + // can't just call reset() when we construct the GSG, because reset() + // requires having a current context.) _gsg->reset_if_new(); if (mode == FM_render) { @@ -204,13 +194,11 @@ begin_frame(FrameMode mode, Thread *current_thread) { return _gsg->begin_frame(current_thread); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::end_frame -// Access: Public, Virtual -// Description: This function will be called within the draw thread -// after rendering is completed for a given frame. It -// should do whatever finalization is required. -//////////////////////////////////////////////////////////////////// +/** + * This function will be called within the draw thread after rendering is + * completed for a given frame. It should do whatever finalization is + * required. + */ void x11GraphicsWindow:: end_frame(FrameMode mode, Thread *current_thread) { end_frame_spam(mode); @@ -229,16 +217,13 @@ end_frame(FrameMode mode, Thread *current_thread) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::process_events -// Access: Public, Virtual -// Description: Do whatever processing is necessary to ensure that -// the window responds to user events. Also, honor any -// requests recently made via request_properties() -// -// This function is called only within the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Do whatever processing is necessary to ensure that the window responds to + * user events. Also, honor any requests recently made via + * request_properties() + * + * This function is called only within the window thread. + */ void x11GraphicsWindow:: process_events() { LightReMutexHolder holder(x11GraphicsPipe::_x_mutex); @@ -267,28 +252,27 @@ process_events() { } if (got_keyrelease_event) { - // If a keyrelease event is immediately followed by a matching - // keypress event, that's just key repeat and we should treat - // the two events accordingly. It would be nice if X provided a - // way to differentiate between keyrepeat and explicit - // keypresses more generally. + // If a keyrelease event is immediately followed by a matching keypress + // event, that's just key repeat and we should treat the two events + // accordingly. It would be nice if X provided a way to differentiate + // between keyrepeat and explicit keypresses more generally. got_keyrelease_event = false; if (event.type == KeyPress && event.xkey.keycode == keyrelease_event.keycode && (event.xkey.time - keyrelease_event.time <= 1)) { - // In particular, we only generate down messages for the - // repeated keys, not down-and-up messages. + // In particular, we only generate down messages for the repeated + // keys, not down-and-up messages. handle_keystroke(event.xkey); - // We thought about not generating the keypress event, but we - // need that repeat for backspace. Rethink later. + // We thought about not generating the keypress event, but we need + // that repeat for backspace. Rethink later. handle_keypress(event.xkey); continue; } else { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } @@ -300,9 +284,8 @@ process_events() { break; case ConfigureNotify: - // When resizing or moving the window, multiple ConfigureNotify - // events may be sent in rapid succession. We only respond to - // the last one. + // When resizing or moving the window, multiple ConfigureNotify events + // may be sent in rapid succession. We only respond to the last one. configure_event = event.xconfigure; got_configure_event = true; break; @@ -339,9 +322,9 @@ process_events() { break; case KeyRelease: - // The KeyRelease can't be processed immediately, because we - // have to check first if it's immediately followed by a - // matching KeyPress event. + // The KeyRelease can't be processed immediately, because we have to + // check first if it's immediately followed by a matching KeyPress + // event. keyrelease_event = event.xkey; got_keyrelease_event = true; break; @@ -385,17 +368,17 @@ process_events() { case ClientMessage: if ((Atom)(event.xclient.data.l[0]) == _wm_delete_window) { - // This is a message from the window manager indicating that - // the user has requested to close the window. + // This is a message from the window manager indicating that the user + // has requested to close the window. string close_request_event = get_close_request_event(); if (!close_request_event.empty()) { - // In this case, the app has indicated a desire to intercept - // the request and process it directly. + // In this case, the app has indicated a desire to intercept the + // request and process it directly. throw_event(close_request_event); } else { - // In this case, the default case, the app does not intend - // to service the request, so we do by closing the window. + // In this case, the default case, the app does not intend to + // service the request, so we do by closing the window. // TODO: don't release the gsg in the window thread. close_window(); @@ -406,9 +389,8 @@ process_events() { break; case DestroyNotify: - // Apparently, we never get a DestroyNotify on a toplevel - // window. Instead, we rely on hints from the window manager - // (see above). + // Apparently, we never get a DestroyNotify on a toplevel window. + // Instead, we rely on hints from the window manager (see above). x11display_cat.info() << "DestroyNotify\n"; break; @@ -423,22 +405,20 @@ process_events() { // Now handle the last configure event we found. _awaiting_configure = false; - // Is this the inner corner or the outer corner? The Xlib docs - // say it should be the outer corner, but it appears to be the - // inner corner on my own implementation, which is inconsistent - // with XConfigureWindow. (Panda really wants to work with the - // inner corner, anyway, but that means we need to fix - // XConfigureWindow too.) + // Is this the inner corner or the outer corner? The Xlib docs say it + // should be the outer corner, but it appears to be the inner corner on my + // own implementation, which is inconsistent with XConfigureWindow. + // (Panda really wants to work with the inner corner, anyway, but that + // means we need to fix XConfigureWindow too.) properties.set_origin(configure_event.x, configure_event.y); properties.set_size(configure_event.width, configure_event.height); if (_properties.get_fixed_size()) { - // If the window properties indicate a fixed size only, undo - // any attempt by the user to change them. In X, there - // doesn't appear to be a way to universally disallow this - // directly (although we do set the min_size and max_size to - // the same value, which seems to work for most window - // managers.) + // If the window properties indicate a fixed size only, undo any attempt + // by the user to change them. In X, there doesn't appear to be a way + // to universally disallow this directly (although we do set the + // min_size and max_size to the same value, which seems to work for most + // window managers.) if (configure_event.width != _fixed_size.get_x() || configure_event.height != _fixed_size.get_y()) { XWindowChanges changes; @@ -456,29 +436,24 @@ process_events() { } if (got_keyrelease_event) { - // This keyrelease event is not immediately followed by a - // matching keypress event, so it's a genuine release. + // This keyrelease event is not immediately followed by a matching + // keypress event, so it's a genuine release. handle_keyrelease(keyrelease_event); } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::set_properties_now -// Access: Public, Virtual -// Description: Applies the requested set of properties to the -// window, if possible, for instance to request a change -// in size or minimization status. -// -// The window properties are applied immediately, rather -// than waiting until the next frame. This implies that -// this method may *only* be called from within the -// window thread. -// -// The return value is true if the properties are set, -// false if they are ignored. This is mainly useful for -// derived classes to implement extensions to this -// function. -//////////////////////////////////////////////////////////////////// +/** + * Applies the requested set of properties to the window, if possible, for + * instance to request a change in size or minimization status. + * + * The window properties are applied immediately, rather than waiting until + * the next frame. This implies that this method may *only* be called from + * within the window thread. + * + * The return value is true if the properties are set, false if they are + * ignored. This is mainly useful for derived classes to implement extensions + * to this function. + */ void x11GraphicsWindow:: set_properties_now(WindowProperties &properties) { if (_pipe == (GraphicsPipe *)NULL) { @@ -490,8 +465,8 @@ set_properties_now(WindowProperties &properties) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); - // We're either going into or out of fullscreen, or are in fullscreen - // and are changing the resolution. + // We're either going into or out of fullscreen, or are in fullscreen and + // are changing the resolution. bool is_fullscreen = _properties.has_fullscreen() && _properties.get_fullscreen(); bool want_fullscreen = properties.has_fullscreen() ? properties.get_fullscreen() : is_fullscreen; @@ -534,15 +509,15 @@ set_properties_now(WindowProperties &properties) { } #endif } else { - // If we don't have Xrandr support, we fake the fullscreen - // support by setting the window size to the desktop size. + // If we don't have Xrandr support, we fake the fullscreen support by + // setting the window size to the desktop size. properties.set_size(x11_pipe->get_display_width(), x11_pipe->get_display_height()); } } else { #ifdef HAVE_XRANDR - // Change the resolution back to what it was. - // Don't remove the SizeID typecast! + // Change the resolution back to what it was. Don't remove the SizeID + // typecast! if (_have_xrandr && _orig_size_id != (SizeID) -1) { XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, x11_pipe->get_root()); XRRSetScreenConfig(_display, conf, x11_pipe->get_root(), _orig_size_id, _orig_rotation, CurrentTime); @@ -586,14 +561,14 @@ set_properties_now(WindowProperties &properties) { return; } - // The window is already open; we are limited to what we can change - // on the fly. + // The window is already open; we are limited to what we can change on the + // fly. // We'll pass some property requests on as a window manager hint. set_wm_properties(properties, true); - // The window title may be changed by issuing another hint request. - // Assume this will be honored. + // The window title may be changed by issuing another hint request. Assume + // this will be honored. if (properties.has_title()) { _properties.set_title(properties.get_title()); properties.clear_title(); @@ -605,10 +580,10 @@ set_properties_now(WindowProperties &properties) { properties.clear_fullscreen(); } - // The size and position of an already-open window are changed via - // explicit X calls. These may still get intercepted by the window - // manager. Rather than changing _properties immediately, we'll - // wait for the ConfigureNotify message to come back. + // The size and position of an already-open window are changed via explicit + // X calls. These may still get intercepted by the window manager. Rather + // than changing _properties immediately, we'll wait for the ConfigureNotify + // message to come back. XWindowChanges changes; int value_mask = 0; @@ -645,10 +620,9 @@ set_properties_now(WindowProperties &properties) { } if (properties.has_z_order()) { - // We'll send the classic stacking request through the standard - // interface, for users of primitive window managers; but we'll - // also send it as a window manager hint, for users of modern - // window managers. + // We'll send the classic stacking request through the standard interface, + // for users of primitive window managers; but we'll also send it as a + // window manager hint, for users of modern window managers. _properties.set_z_order(properties.get_z_order()); switch (properties.get_z_order()) { case WindowProperties::Z_bottom: @@ -668,8 +642,8 @@ set_properties_now(WindowProperties &properties) { properties.clear_z_order(); } - // We hide the cursor by setting it to an invisible pixmap. - // We can also load a custom cursor from a file. + // We hide the cursor by setting it to an invisible pixmap. We can also + // load a custom cursor from a file. if (properties.has_cursor_hidden() || properties.has_cursor_filename()) { if (properties.has_cursor_hidden()) { _properties.set_cursor_hidden(properties.get_cursor_hidden()); @@ -745,8 +719,8 @@ set_properties_now(WindowProperties &properties) { properties.clear_mouse_mode(); _dga_mouse_enabled = true; - // Get the real mouse position, so we can add/subtract - // our relative coordinates later. + // Get the real mouse position, so we can addsubtract our relative + // coordinates later. XEvent event; XQueryPointer(_display, _xwindow, &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root, @@ -789,8 +763,8 @@ set_properties_now(WindowProperties &properties) { } if (value_mask != 0) { - // We must call this after changing the WM properties, otherwise - // we may get misleading ConfigureNotify events in the wrong order. + // We must call this after changing the WM properties, otherwise we may + // get misleading ConfigureNotify events in the wrong order. XReconfigureWMWindow(_display, _xwindow, _screen, value_mask, &changes); // Don't draw anything until this is done reconfiguring. @@ -798,32 +772,25 @@ set_properties_now(WindowProperties &properties) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::mouse_mode_absolute -// Access: Private, Virtual -// Description: Overridden from GraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Overridden from GraphicsWindow. + */ void x11GraphicsWindow:: mouse_mode_absolute() { // unused: remove in 1.10! } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::mouse_mode_relative -// Access: Private, Virtual -// Description: Overridden from GraphicsWindow. -//////////////////////////////////////////////////////////////////// +/** + * Overridden from GraphicsWindow. + */ void x11GraphicsWindow:: mouse_mode_relative() { // unused: remove in 1.10! } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::close_window -// Access: Protected, Virtual -// Description: Closes the window right now. Called from the window -// thread. -//////////////////////////////////////////////////////////////////// +/** + * Closes the window right now. Called from the window thread. + */ void x11GraphicsWindow:: close_window() { if (_gsg != (GraphicsStateGuardian *)NULL) { @@ -845,8 +812,8 @@ close_window() { } #ifdef HAVE_XRANDR - // Change the resolution back to what it was. - // Don't remove the SizeID typecast! + // Change the resolution back to what it was. Don't remove the SizeID + // typecast! if (_have_xrandr && _orig_size_id != (SizeID) -1) { X11_Window root; if (_pipe != NULL) { @@ -854,9 +821,8 @@ close_window() { DCAST_INTO_V(x11_pipe, _pipe); root = x11_pipe->get_root(); } else { - // Oops. Looks like the pipe was destroyed - // before the window gets closed. Oh well, - // let's get the root window by ourselves. + // Oops. Looks like the pipe was destroyed before the window gets + // closed. Oh well, let's get the root window by ourselves. root = RootWindow(_display, _screen); } XRRScreenConfiguration* conf = XRRGetScreenInfo(_display, root); @@ -868,13 +834,10 @@ close_window() { GraphicsWindow::close_window(); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::open_window -// Access: Protected, Virtual -// Description: Opens the window right now. Called from the window -// thread. Returns true if the window is successfully -// opened, or false if there was a problem. -//////////////////////////////////////////////////////////////////// +/** + * Opens the window right now. Called from the window thread. Returns true + * if the window is successfully opened, or false if there was a problem. + */ bool x11GraphicsWindow:: open_window() { if (_visual_info == NULL) { @@ -982,10 +945,10 @@ open_window() { set_wm_properties(_properties, false); - // We don't specify any fancy properties of the XIC. It would be - // nicer if we could support fancy IM's that want preedit callbacks, - // etc., but that can wait until we have an X server that actually - // supports these to test it on. + // We don't specify any fancy properties of the XIC. It would be nicer if + // we could support fancy IM's that want preedit callbacks, etc., but that + // can wait until we have an X server that actually supports these to test + // it on. XIM im = x11_pipe->get_im(); _ic = NULL; if (im) { @@ -1030,19 +993,16 @@ open_window() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::set_wm_properties -// Access: Private -// Description: Asks the window manager to set the appropriate -// properties. In X, these properties cannot be -// specified directly by the application; they must be -// requested via the window manager, which may or may -// not choose to honor the request. -// -// If already_mapped is true, the window has already -// been mapped (manifested) on the display. This means -// we may need to use a different action in some cases. -//////////////////////////////////////////////////////////////////// +/** + * Asks the window manager to set the appropriate properties. In X, these + * properties cannot be specified directly by the application; they must be + * requested via the window manager, which may or may not choose to honor the + * request. + * + * If already_mapped is true, the window has already been mapped (manifested) + * on the display. This means we may need to use a different action in some + * cases. + */ void x11GraphicsWindow:: set_wm_properties(const WindowProperties &properties, bool already_mapped) { x11GraphicsPipe *x11_pipe; @@ -1058,8 +1018,8 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } } - // The size hints request a window of a particular size and/or a - // particular placement onscreen. + // The size hints request a window of a particular size andor a particular + // placement onscreen. XSizeHints *size_hints_p = NULL; if (properties.has_origin() || properties.has_size()) { size_hints_p = XAllocSizeHints(); @@ -1091,8 +1051,8 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } } - // The window manager hints include requests to the window manager - // other than those specific to window geometry. + // The window manager hints include requests to the window manager other + // than those specific to window geometry. XWMHints *wm_hints_p = NULL; wm_hints_p = XAllocWMHints(); if (wm_hints_p != (XWMHints *)NULL) { @@ -1104,9 +1064,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { wm_hints_p->flags = StateHint; } - // Two competing window manager interfaces have evolved. One of - // them allows to set certain properties as a "type"; the other one - // as a "state". We'll try to honor both. + // Two competing window manager interfaces have evolved. One of them allows + // to set certain properties as a "type"; the other one as a "state". We'll + // try to honor both. static const int max_type_data = 32; PN_int32 type_data[max_type_data]; int next_type_data = 0; @@ -1128,14 +1088,14 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { if (properties.has_fullscreen()) { if (properties.get_fullscreen()) { - // For a "fullscreen" request, we pass this through, hoping the - // window manager will support EWMH. + // For a "fullscreen" request, we pass this through, hoping the window + // manager will support EWMH. type_data[next_type_data++] = x11_pipe->_net_wm_window_type_fullscreen; // We also request it as a state. state_data[next_state_data++] = x11_pipe->_net_wm_state_fullscreen; - // Don't ask me why this has to be 1/0 and not _net_wm_state_add. - // It doesn't seem to work otherwise. + // Don't ask me why this has to be 10 and not _net_wm_state_add. It + // doesn't seem to work otherwise. set_data[next_set_data++] = SetAction(x11_pipe->_net_wm_state_fullscreen, 1); } else { @@ -1143,15 +1103,15 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { } } - // If we asked for a window without a border, there's no excellent - // way to arrange that. For users whose window managers follow the - // EWMH specification, we can ask for a "splash" screen, which is - // usually undecorated. It's not exactly right, but the spec - // doesn't give us an exactly-right option. + // If we asked for a window without a border, there's no excellent way to + // arrange that. For users whose window managers follow the EWMH + // specification, we can ask for a "splash" screen, which is usually + // undecorated. It's not exactly right, but the spec doesn't give us an + // exactly-right option. - // For other users, we'll totally punt and just set the window's - // Class to "Undecorated", and let the user configure his/her window - // manager not to put a border around windows of this class. + // For other users, we'll totally punt and just set the window's Class to + // "Undecorated", and let the user configure hisher window manager not to + // put a border around windows of this class. XClassHint *class_hints_p = NULL; if (!x_wm_class.empty()) { // Unless the user wanted to use his own WM_CLASS, of course. @@ -1217,9 +1177,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { (unsigned char *)state_data, next_state_data); if (already_mapped) { - // We have to request state changes differently when the window - // has been mapped. To do this, we need to send a client message - // to the root window for each change. + // We have to request state changes differently when the window has been + // mapped. To do this, we need to send a client message to the root + // window for each change. x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); @@ -1255,10 +1215,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { XFree(class_hints_p); } - // Also, indicate to the window manager that we'd like to get a - // chance to close our windows cleanly, rather than being rudely - // disconnected from the X server if the user requests a window - // close. + // Also, indicate to the window manager that we'd like to get a chance to + // close our windows cleanly, rather than being rudely disconnected from the + // X server if the user requests a window close. Atom protocols[] = { _wm_delete_window, }; @@ -1267,12 +1226,10 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { sizeof(protocols) / sizeof(Atom)); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::setup_colormap -// Access: Private, Virtual -// Description: Allocates a colormap appropriate to the visual and -// stores in in the _colormap method. -//////////////////////////////////////////////////////////////////// +/** + * Allocates a colormap appropriate to the visual and stores in in the + * _colormap method. + */ void x11GraphicsWindow:: setup_colormap(XVisualInfo *visual) { x11GraphicsPipe *x11_pipe; @@ -1283,11 +1240,9 @@ setup_colormap(XVisualInfo *visual) { visual->visual, AllocNone); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::open_raw_mice -// Access: Private -// Description: Adds raw mice to the _input_devices list. -//////////////////////////////////////////////////////////////////// +/** + * Adds raw mice to the _input_devices list. + */ void x11GraphicsWindow:: open_raw_mice() { #ifdef PHAVE_LINUX_INPUT_H @@ -1364,11 +1319,9 @@ open_raw_mice() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::poll_raw_mice -// Access: Private -// Description: Reads events from the raw mouse device files. -//////////////////////////////////////////////////////////////////// +/** + * Reads events from the raw mouse device files. + */ void x11GraphicsWindow:: poll_raw_mice() { #ifdef PHAVE_LINUX_INPUT_H @@ -1427,12 +1380,9 @@ poll_raw_mice() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::handle_keystroke -// Access: Private -// Description: Generates a keystroke corresponding to the indicated -// X KeyPress event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keystroke corresponding to the indicated X KeyPress event. + */ void x11GraphicsWindow:: handle_keystroke(XKeyEvent &event) { if (!_dga_mouse_enabled) { @@ -1451,8 +1401,7 @@ handle_keystroke(XKeyEvent &event) { << "Overflowed input buffer.\n"; } - // Now each of the returned wide characters represents a - // keystroke. + // Now each of the returned wide characters represents a keystroke. for (int i = 0; i < len; i++) { _input_devices[0].keystroke(buffer[i]); } @@ -1466,12 +1415,9 @@ handle_keystroke(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::handle_keypress -// Access: Private -// Description: Generates a keypress corresponding to the indicated -// X KeyPress event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keypress corresponding to the indicated X KeyPress event. + */ void x11GraphicsWindow:: handle_keypress(XKeyEvent &event) { if (!_dga_mouse_enabled) { @@ -1502,12 +1448,9 @@ handle_keypress(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::handle_keyrelease -// Access: Private -// Description: Generates a keyrelease corresponding to the indicated -// X KeyRelease event. -//////////////////////////////////////////////////////////////////// +/** + * Generates a keyrelease corresponding to the indicated X KeyRelease event. + */ void x11GraphicsWindow:: handle_keyrelease(XKeyEvent &event) { if (!_dga_mouse_enabled) { @@ -1538,20 +1481,18 @@ handle_keyrelease(XKeyEvent &event) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_button -// Access: Private -// Description: Returns the Panda ButtonHandle corresponding to the -// keyboard button indicated by the given key event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda ButtonHandle corresponding to the keyboard button + * indicated by the given key event. + */ ButtonHandle x11GraphicsWindow:: get_button(XKeyEvent &key_event, bool allow_shift) { KeySym key = XLookupKeysym(&key_event, 0); if ((key_event.state & Mod2Mask) != 0) { - // Mod2Mask corresponds to NumLock being in effect. In this case, - // we want to get the alternate keysym associated with any keypad - // keys. Weird system. + // Mod2Mask corresponds to NumLock being in effect. In this case, we want + // to get the alternate keysym associated with any keypad keys. Weird + // system. KeySym k2; ButtonHandle button; switch (key) { @@ -1594,8 +1535,8 @@ get_button(XKeyEvent &key_event, bool allow_shift) { if (button != ButtonHandle::none()) { return button; } - // If that didn't produce a button we know, just fall through - // and handle the normal, un-numlocked key. + // If that didn't produce a button we know, just fall through and handle + // the normal, un-numlocked key. break; default: @@ -1613,9 +1554,9 @@ get_button(XKeyEvent &key_event, bool allow_shift) { } } - // If caps lock is down, shift lowercase letters to uppercase. We - // can do this in just the ASCII set, because we handle - // international keyboards elsewhere (via an input context). + // If caps lock is down, shift lowercase letters to uppercase. We can do + // this in just the ASCII set, because we handle international keyboards + // elsewhere (via an input context). if ((key_event.state & (ShiftMask | LockMask)) != 0) { if (key >= XK_a and key <= XK_z) { key += (XK_A - XK_a); @@ -1626,12 +1567,10 @@ get_button(XKeyEvent &key_event, bool allow_shift) { return map_button(key); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::map_button -// Access: Private -// Description: Maps from a single X keysym to Panda's ButtonHandle. -// Called by get_button(), above. -//////////////////////////////////////////////////////////////////// +/** + * Maps from a single X keysym to Panda's ButtonHandle. Called by + * get_button(), above. + */ ButtonHandle x11GraphicsWindow:: map_button(KeySym key) const { switch (key) { @@ -1955,11 +1894,9 @@ map_button(KeySym key) const { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::map_raw_button -// Access: Private -// Description: Maps from a single X keycode to Panda's ButtonHandle. -//////////////////////////////////////////////////////////////////// +/** + * Maps from a single X keycode to Panda's ButtonHandle. + */ ButtonHandle x11GraphicsWindow:: map_raw_button(KeyCode key) const { switch (key) { @@ -2076,12 +2013,10 @@ map_raw_button(KeyCode key) const { return ButtonHandle::none(); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_mouse_button -// Access: Private -// Description: Returns the Panda ButtonHandle corresponding to the -// mouse button indicated by the given button event. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Panda ButtonHandle corresponding to the mouse button indicated + * by the given button event. + */ ButtonHandle x11GraphicsWindow:: get_mouse_button(XButtonEvent &button_event) { int index = button_event.button; @@ -2098,16 +2033,14 @@ get_mouse_button(XButtonEvent &button_event) { } } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_keyboard_map -// Access: Private, Virtual -// Description: Returns a ButtonMap containing the association -// between raw buttons and virtual buttons. -//////////////////////////////////////////////////////////////////// +/** + * Returns a ButtonMap containing the association between raw buttons and + * virtual buttons. + */ ButtonMap *x11GraphicsWindow:: get_keyboard_map() const { - // NB. This could be improved by using the Xkb API. - //XkbDescPtr desc = XkbGetMap(_display, XkbAllMapComponentsMask, XkbUseCoreKbd); + // NB. This could be improved by using the Xkb API. XkbDescPtr desc = + // XkbGetMap(_display, XkbAllMapComponentsMask, XkbUseCoreKbd); ButtonMap *map = new ButtonMap; for (int k = 9; k <= 135; ++k) { @@ -2128,14 +2061,10 @@ get_keyboard_map() const { return map; } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::check_event -// Access: Private, Static -// Description: This function is used as a predicate to -// XCheckIfEvent() to determine if the indicated queued -// X event is relevant and should be returned to this -// window. -//////////////////////////////////////////////////////////////////// +/** + * This function is used as a predicate to XCheckIfEvent() to determine if the + * indicated queued X event is relevant and should be returned to this window. + */ Bool x11GraphicsWindow:: check_event(X11_Display *display, XEvent *event, char *arg) { const x11GraphicsWindow *self = (x11GraphicsWindow *)arg; @@ -2144,13 +2073,10 @@ check_event(X11_Display *display, XEvent *event, char *arg) { return (event->xany.window == self->_xwindow); } -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::get_cursor -// Access: Private -// Description: Loads and returns a Cursor corresponding to the -// indicated filename. If the file cannot be loaded, -// returns None. -//////////////////////////////////////////////////////////////////// +/** + * Loads and returns a Cursor corresponding to the indicated filename. If the + * file cannot be loaded, returns None. + */ X11_Cursor x11GraphicsWindow:: get_cursor(const Filename &filename) { #ifndef HAVE_XCURSOR @@ -2235,13 +2161,10 @@ get_cursor(const Filename &filename) { } #ifdef HAVE_XCURSOR -//////////////////////////////////////////////////////////////////// -// Function: x11GraphicsWindow::load_ico -// Access: Private -// Description: Reads a Windows .ico or .cur file from the -// indicated stream and returns it as an X11 Cursor. -// If the file cannot be loaded, returns None. -//////////////////////////////////////////////////////////////////// +/** + * Reads a Windows .ico or .cur file from the indicated stream and returns it + * as an X11 Cursor. If the file cannot be loaded, returns None. + */ X11_Cursor x11GraphicsWindow:: read_ico(istream &ico) { // Local structs, this is just POD, make input easier @@ -2422,4 +2345,3 @@ cleanup: return ret; } #endif // HAVE_XCURSOR - diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index 5bcb8de0db..fe160284f8 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -1,16 +1,15 @@ -// Filename: x11GraphicsWindow.h -// Created by: rdb (07Jul09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file x11GraphicsWindow.h + * @author rdb + * @date 2009-07-07 + */ #ifndef X11GRAPHICSWINDOW_H #define X11GRAPHICSWINDOW_H @@ -26,10 +25,9 @@ typedef unsigned short Rotation; typedef unsigned short SizeID; #endif -//////////////////////////////////////////////////////////////////// -// Class : x11GraphicsWindow -// Description : Interfaces to the X11 window system. -//////////////////////////////////////////////////////////////////// +/** + * Interfaces to the X11 window system. + */ class x11GraphicsWindow : public GraphicsWindow { public: x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, @@ -128,9 +126,9 @@ public: private: static TypeHandle _type_handle; - // Since the Panda API requests icons and cursors by filename, we - // need a table mapping filenames to handles, so we can avoid - // re-reading the file each time we change icons. + // Since the Panda API requests icons and cursors by filename, we need a + // table mapping filenames to handles, so we can avoid re-reading the file + // each time we change icons. pmap _cursor_filenames; }; diff --git a/pandatool/src/assimp/assimpLoader.I b/pandatool/src/assimp/assimpLoader.I index 36e8aba735..5ce6c3bfdc 100644 --- a/pandatool/src/assimp/assimpLoader.I +++ b/pandatool/src/assimp/assimpLoader.I @@ -1,14 +1,12 @@ -// Filename: assimpLoader.I -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file assimpLoader.I + * @author rdb + * @date 2011-03-29 + */ diff --git a/pandatool/src/assimp/assimpLoader.cxx b/pandatool/src/assimp/assimpLoader.cxx index 30f5e2e6f8..661286d454 100644 --- a/pandatool/src/assimp/assimpLoader.cxx +++ b/pandatool/src/assimp/assimpLoader.cxx @@ -1,16 +1,15 @@ -// Filename: assimpLoader.cxx -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file assimpLoader.cxx + * @author rdb + * @date 2011-03-29 + */ #include "assimpLoader.h" @@ -52,11 +51,9 @@ struct BoneWeight { }; typedef pvector BoneWeightList; -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AssimpLoader:: AssimpLoader() : _error (false), @@ -66,22 +63,18 @@ AssimpLoader() : _importer.SetIOHandler(new PandaIOSystem); } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ AssimpLoader:: ~AssimpLoader() { _importer.FreeScene(); } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::get_extensions -// Access: Public -// Description: Returns a space-separated list of extensions that -// Assimp can load, without the leading dots. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extensions that Assimp can load, without + * the leading dots. + */ void AssimpLoader:: get_extensions(string &ext) const { aiString aexts; @@ -99,17 +92,15 @@ get_extensions(string &ext) const { } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::read -// Access: Public -// Description: Reads from the indicated file. -//////////////////////////////////////////////////////////////////// +/** + * Reads from the indicated file. + */ bool AssimpLoader:: read(const Filename &filename) { _filename = filename; - // I really don't know why we need to flip the winding order, - // but otherwise the models I tested with are showing inside out. + // I really don't know why we need to flip the winding order, but otherwise + // the models I tested with are showing inside out. _scene = _importer.ReadFile(_filename.c_str(), aiProcess_Triangulate | aiProcess_GenUVCoords | aiProcess_FlipWindingOrder); if (_scene == NULL) { _error = true; @@ -120,12 +111,10 @@ read(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::build_graph -// Access: Public -// Description: Converts scene graph structures into a Panda3D -// scene graph, with _root being the root node. -//////////////////////////////////////////////////////////////////// +/** + * Converts scene graph structures into a Panda3D scene graph, with _root + * being the root node. + */ void AssimpLoader:: build_graph() { nassertv(_scene != NULL); // read() must be called first @@ -171,11 +160,9 @@ build_graph() { delete[] _geom_matindices; } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::find_node -// Access: Private -// Description: Finds a node by name. -//////////////////////////////////////////////////////////////////// +/** + * Finds a node by name. + */ const aiNode *AssimpLoader:: find_node(const aiNode &root, const aiString &name) { const aiNode *node; @@ -194,11 +181,9 @@ find_node(const aiNode &root, const aiString &name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_texture -// Access: Private -// Description: Converts an aiTexture into a Texture. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiTexture into a Texture. + */ void AssimpLoader:: load_texture(size_t index) { const aiTexture &tex = *_scene->mTextures[index]; @@ -250,19 +235,16 @@ load_texture(size_t index) { } } - //ostringstream path; - //path << "/tmp/" << index << ".png"; - //ptex->write(path.str()); + // ostringstream path; path << "tmp" << index << ".png"; + // ptex->write(path.str()); _textures[index] = ptex; } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_texture_stage -// Access: Private -// Description: Converts an aiMaterial into a RenderState. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiMaterial into a RenderState. + */ void AssimpLoader:: load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(TextureAttrib) &tattr) { aiString path; @@ -276,10 +258,9 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur mat.GetTexture(ttype, i, &path, &mapping, NULL, &blend, &op, &mapmode); if (AI_SUCCESS != mat.Get(AI_MATKEY_UVWSRC(ttype, i), uvindex)) { - // If there's no texture coordinate set for this texture, - // assume that it's the same as the index on the stack. - //TODO: if there's only one set on the mesh, - // force everything to use just the first stage. + // If there's no texture coordinate set for this texture, assume that + // it's the same as the index on the stack. TODO: if there's only one + // set on the mesh, force everything to use just the first stage. uvindex = i; } @@ -291,8 +272,8 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur } PT(Texture) ptex = NULL; - // I'm not sure if this is the right way to handle it, as - // I couldn't find much information on embedded textures. + // I'm not sure if this is the right way to handle it, as I couldn't find + // much information on embedded textures. if (path.data[0] == '*') { long num = strtol(path.data + 1, NULL, 10); ptex = _textures[num]; @@ -333,11 +314,9 @@ load_texture_stage(const aiMaterial &mat, const aiTextureType &ttype, CPT(Textur } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_material -// Access: Private -// Description: Converts an aiMaterial into a RenderState. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiMaterial into a RenderState. + */ void AssimpLoader:: load_material(size_t index) { const aiMaterial &mat = *_scene->mMaterials[index]; @@ -375,7 +354,7 @@ load_material(size_t index) { have = true; } if (AI_SUCCESS == mat.Get(AI_MATKEY_COLOR_TRANSPARENT, col)) { - //FIXME: ??? + // FIXME: ??? } if (AI_SUCCESS == mat.Get(AI_MATKEY_SHININESS, fval)) { pmat->set_shininess(fval); @@ -394,8 +373,8 @@ load_material(size_t index) { } } - // Backface culling. Not sure if this is also supposed to - // set the twoside flag in the material, I'm guessing not. + // Backface culling. Not sure if this is also supposed to set the twoside + // flag in the material, I'm guessing not. if (AI_SUCCESS == mat.Get(AI_MATKEY_TWOSIDED, ival)) { if (ival) { state = state->add_attrib(CullFaceAttrib::make(CullFaceAttrib::M_cull_none)); @@ -415,11 +394,9 @@ load_material(size_t index) { _mat_states[index] = state; } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::create_joint -// Access: Private -// Description: Creates a CharacterJoint from an aiNode -//////////////////////////////////////////////////////////////////// +/** + * Creates a CharacterJoint from an aiNode + */ void AssimpLoader:: create_joint(Character *character, CharacterJointBundle *bundle, PartGroup *parent, const aiNode &node) { const aiMatrix4x4 &t = node.mTransformation; @@ -439,11 +416,9 @@ create_joint(Character *character, CharacterJointBundle *bundle, PartGroup *pare } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::create_anim_channel -// Access: Private -// Description: Creates a AnimChannelMatrixXfmTable from an aiNodeAnim -//////////////////////////////////////////////////////////////////// +/** + * Creates a AnimChannelMatrixXfmTable from an aiNodeAnim + */ void AssimpLoader:: create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *parent, const aiNode &node) { PT(AnimChannelMatrixXfmTable) group = new AnimChannelMatrixXfmTable(parent, node.mName.C_Str()); @@ -459,12 +434,11 @@ 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"; - //assimp_cat.debug() - // << "Num Position Keys " << node_anim->mNumPositionKeys << "\n"; - //assimp_cat.debug() - // << "Num Rotation Keys " << node_anim->mNumRotationKeys << "\n"; - //assimp_cat.debug() - // << "Num Scaling Keys " << node_anim->mNumScalingKeys << "\n"; + // assimp_cat.debug() << "Num Position Keys " << + // node_anim->mNumPositionKeys << "\n"; assimp_cat.debug() << "Num + // Rotation Keys " << node_anim->mNumRotationKeys << "\n"; + // assimp_cat.debug() << "Num Scaling Keys " << node_anim->mNumScalingKeys + // << "\n"; // Convert positions PTA_stdfloat tablex = PTA_stdfloat::empty_array(node_anim->mNumPositionKeys); @@ -520,11 +494,9 @@ create_anim_channel(const aiAnimation &anim, AnimBundle *bundle, AnimGroup *pare } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_mesh -// Access: Private -// Description: Converts an aiMesh into a Geom. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiMesh into a Geom. + */ void AssimpLoader:: load_mesh(size_t index) { const aiMesh &mesh = *_scene->mMeshes[index]; @@ -674,7 +646,8 @@ load_mesh(size_t index) { } } - //TODO: if there is only one UV set, hackily iterate over the texture stages and clear the texcoord name things + // TODO: if there is only one UV set, hackily iterate over the texture + // stages and clear the texcoord name things PT(GeomVertexFormat) format = new GeomVertexFormat; format->add_array(aformat); @@ -754,9 +727,9 @@ load_mesh(size_t index) { tbtable->set_rows(SparseArray::lower_on(vdata->get_num_rows())); } - // Now read out the primitives. - // Keep in mind that we called ReadFile with the aiProcess_Triangulate - // flag earlier, so we don't have to worry about polygons. + // Now read out the primitives. Keep in mind that we called ReadFile with + // the aiProcess_Triangulate flag earlier, so we don't have to worry about + // polygons. PT(GeomPoints) points = new GeomPoints(Geom::UH_static); PT(GeomLines) lines = new GeomLines(Geom::UH_static); PT(GeomTriangles) triangles = new GeomTriangles(Geom::UH_static); @@ -802,11 +775,9 @@ load_mesh(size_t index) { } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_node -// Access: Private -// Description: Converts an aiNode into a PandaNode. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiNode into a PandaNode. + */ void AssimpLoader:: load_node(const aiNode &node, PandaNode *parent) { PT(PandaNode) pnode; @@ -871,11 +842,9 @@ load_node(const aiNode &node, PandaNode *parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: AssimpLoader::load_light -// Access: Private -// Description: Converts an aiLight into a LightNode. -//////////////////////////////////////////////////////////////////// +/** + * Converts an aiLight into a LightNode. + */ void AssimpLoader:: load_light(const aiLight &light) { string name (light.mName.data, light.mName.length); @@ -935,7 +904,7 @@ load_light(const aiLight &light) { light.mAttenuationQuadratic)); plight->get_lens()->set_fov(light.mAngleOuterCone); - //TODO: translate mAngleInnerCone to an exponent, somehow + // TODO: translate mAngleInnerCone to an exponent, somehow // This *should* be about right. vec = light.mDirection; @@ -945,8 +914,8 @@ load_light(const aiLight &light) { plight->set_transform(TransformState::make_pos_quat_scale(pos, quat, LVecBase3(1, 1, 1))); break; } - // This is a somewhat recent addition to Assimp, so let's be kind to - // those that don't have an up-to-date version of Assimp. + // This is a somewhat recent addition to Assimp, so let's be kind to those + // that don't have an up-to-date version of Assimp. case 0x4: //aiLightSource_AMBIENT: // This is handled below. break; diff --git a/pandatool/src/assimp/assimpLoader.h b/pandatool/src/assimp/assimpLoader.h index ed390791db..85dd7f59a0 100644 --- a/pandatool/src/assimp/assimpLoader.h +++ b/pandatool/src/assimp/assimpLoader.h @@ -1,16 +1,15 @@ -// Filename: assimpLoader.h -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file assimpLoader.h + * @author rdb + * @date 2011-03-29 + */ #ifndef ASSIMPLOADER_H #define ASSIMPLOADER_H @@ -38,12 +37,10 @@ struct char_cmp { typedef pmap BoneMap; typedef pmap CharacterMap; -//////////////////////////////////////////////////////////////////// -// Class : AssimpLoader -// Description : Class that interfaces with Assimp and builds Panda -// nodes to represent the Assimp structures. -// The loader should be reusable. -//////////////////////////////////////////////////////////////////// +/** + * Class that interfaces with Assimp and builds Panda nodes to represent the + * Assimp structures. The loader should be reusable. + */ class AssimpLoader : public TypedReferenceCount { public: AssimpLoader(); diff --git a/pandatool/src/assimp/config_assimp.cxx b/pandatool/src/assimp/config_assimp.cxx index cd5f20af78..6e7dfcfe86 100644 --- a/pandatool/src/assimp/config_assimp.cxx +++ b/pandatool/src/assimp/config_assimp.cxx @@ -1,16 +1,15 @@ -// Filename: config_assimp.cxx -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_assimp.cxx + * @author rdb + * @date 2011-03-29 + */ #include "config_assimp.h" @@ -26,14 +25,12 @@ ConfigureFn(config_assimp) { init_libassimp(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libassimp -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libassimp() { static bool initialized = false; diff --git a/pandatool/src/assimp/config_assimp.h b/pandatool/src/assimp/config_assimp.h index 4c2da9d449..7ca6a98094 100644 --- a/pandatool/src/assimp/config_assimp.h +++ b/pandatool/src/assimp/config_assimp.h @@ -1,16 +1,15 @@ -// Filename: config_assimp.h -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_assimp.h + * @author rdb + * @date 2011-03-29 + */ #ifndef CONFIG_ASSIMP_H #define CONFIG_ASSIMP_H diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.cxx b/pandatool/src/assimp/loaderFileTypeAssimp.cxx index d79ae52760..cdfc9a8a22 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.cxx +++ b/pandatool/src/assimp/loaderFileTypeAssimp.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeAssimp.cxx -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeAssimp.cxx + * @author rdb + * @date 2011-03-29 + */ #include "loaderFileTypeAssimp.h" #include "config_assimp.h" @@ -18,20 +17,16 @@ TypeHandle LoaderFileTypeAssimp::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeAssimp:: LoaderFileTypeAssimp() : _loader(new AssimpLoader) { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypeAssimp:: ~LoaderFileTypeAssimp() { if (_loader != NULL) { @@ -39,33 +34,26 @@ LoaderFileTypeAssimp:: } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeAssimp:: get_name() const { return "Assimp Importer"; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypeAssimp:: get_extension() const { return ""; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::get_additional_extensions -// Access: Public, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this converter. + */ string LoaderFileTypeAssimp:: get_additional_extensions() const { string exts; @@ -73,23 +61,18 @@ get_additional_extensions() const { return exts; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypeAssimp:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypeAssimp::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypeAssimp:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { diff --git a/pandatool/src/assimp/loaderFileTypeAssimp.h b/pandatool/src/assimp/loaderFileTypeAssimp.h index f0d0490796..495130a40e 100644 --- a/pandatool/src/assimp/loaderFileTypeAssimp.h +++ b/pandatool/src/assimp/loaderFileTypeAssimp.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypeAssimp.h -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypeAssimp.h + * @author rdb + * @date 2011-03-29 + */ #ifndef LOADERFILETYPEASSIMP_H #define LOADERFILETYPEASSIMP_H @@ -20,11 +19,10 @@ class AssimpLoader; -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypeAssimp -// Description : This defines the Loader interface that uses the -// Assimp library to load various model formats. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface that uses the Assimp library to load + * various model formats. + */ class EXPCL_ASSIMP LoaderFileTypeAssimp : public LoaderFileType { public: LoaderFileTypeAssimp(); @@ -60,4 +58,3 @@ private: }; #endif - diff --git a/pandatool/src/assimp/pandaIOStream.cxx b/pandatool/src/assimp/pandaIOStream.cxx index 647af59ccc..e4dde48e79 100644 --- a/pandatool/src/assimp/pandaIOStream.cxx +++ b/pandatool/src/assimp/pandaIOStream.cxx @@ -1,34 +1,29 @@ -// Filename: pandaIOStream.cxx -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaIOStream.cxx + * @author rdb + * @date 2011-03-29 + */ #include "pandaIOStream.h" -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PandaIOStream:: PandaIOStream(istream &stream) : _istream(stream) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::FileSize -// Access: Public -// Description: Returns the size of this file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of this file. + */ size_t PandaIOStream:: FileSize() const { streampos cur = _istream.tellg(); @@ -38,32 +33,26 @@ FileSize() const { return end; } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Flush -// Access: Public -// Description: See fflush. -//////////////////////////////////////////////////////////////////// +/** + * See fflush. + */ void PandaIOStream:: Flush() { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Read -// Access: Public -// Description: See fread. -//////////////////////////////////////////////////////////////////// +/** + * See fread. + */ size_t PandaIOStream:: Read(void *buffer, size_t size, size_t count) { _istream.read((char*) buffer, size * count); return _istream.gcount(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Seek -// Access: Public -// Description: See fseek. -//////////////////////////////////////////////////////////////////// +/** + * See fseek. + */ aiReturn PandaIOStream:: Seek(size_t offset, aiOrigin origin) { switch (origin) { @@ -92,21 +81,17 @@ Seek(size_t offset, aiOrigin origin) { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Tell -// Access: Public -// Description: See ftell. -//////////////////////////////////////////////////////////////////// +/** + * See ftell. + */ size_t PandaIOStream:: Tell() const { return _istream.tellg(); } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOStream::Write -// Access: Public -// Description: See fwrite. -//////////////////////////////////////////////////////////////////// +/** + * See fwrite. + */ size_t PandaIOStream:: Write(const void *buffer, size_t size, size_t count) { nassertr(false, 0); diff --git a/pandatool/src/assimp/pandaIOStream.h b/pandatool/src/assimp/pandaIOStream.h index c89f4a15bf..913f96a740 100644 --- a/pandatool/src/assimp/pandaIOStream.h +++ b/pandatool/src/assimp/pandaIOStream.h @@ -1,16 +1,15 @@ -// Filename: pandaIOStream.h -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaIOStream.h + * @author rdb + * @date 2011-03-29 + */ #ifndef PANDAIOSTREAM_H #define PANDAIOSTREAM_H @@ -21,12 +20,10 @@ class PandaIOSystem; -//////////////////////////////////////////////////////////////////// -// Class : PandaIOStream -// Description : Custom implementation of Assimp::IOStream. It -// simply wraps around an istream object, and is -// unable to write. -//////////////////////////////////////////////////////////////////// +/** + * Custom implementation of Assimp::IOStream. It simply wraps around an + * istream object, and is unable to write. + */ class PandaIOStream : public Assimp::IOStream { public: PandaIOStream(istream &stream); diff --git a/pandatool/src/assimp/pandaIOSystem.cxx b/pandatool/src/assimp/pandaIOSystem.cxx index abaadc76c8..d64b52466f 100644 --- a/pandatool/src/assimp/pandaIOSystem.cxx +++ b/pandatool/src/assimp/pandaIOSystem.cxx @@ -1,58 +1,48 @@ -// Filename: pandaIOSystem.cxx -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaIOSystem.cxx + * @author rdb + * @date 2011-03-29 + */ #include "pandaIOSystem.h" #include "pandaIOStream.h" -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::Constructor -// Access: Public -// Description: Initializes the object with the given VFS, or the -// global one if none was specified. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the object with the given VFS, or the global one if none was + * specified. + */ PandaIOSystem:: PandaIOSystem(VirtualFileSystem *vfs) : _vfs(vfs) { } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::Exists -// Access: Public -// Description: Returns true if the file exists, duh. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file exists, duh. + */ bool PandaIOSystem:: Exists(const char *file) const { Filename fn = Filename::from_os_specific(file); return _vfs->exists(fn); } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::Close -// Access: Public -// Description: Closes the indicated file stream. -//////////////////////////////////////////////////////////////////// +/** + * Closes the indicated file stream. + */ void PandaIOSystem:: Close(Assimp::IOStream *file) { PandaIOStream *pstr = (PandaIOStream*) file; _vfs->close_read_file(&pstr->_istream); } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::ComparePaths -// Access: Public -// Description: Returns true if the two paths point to the same -// file, false if not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the two paths point to the same file, false if not. + */ bool PandaIOSystem:: ComparePaths(const char *p1, const char *p2) const { Filename fn1 = Filename::from_os_specific(p1); @@ -62,12 +52,9 @@ ComparePaths(const char *p1, const char *p2) const { return fn1 == fn2; } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::getOsSeparator -// Access: Public -// Description: Returns the path separator for this operating -// system. -//////////////////////////////////////////////////////////////////// +/** + * Returns the path separator for this operating system. + */ char PandaIOSystem:: getOsSeparator() const { #ifdef _WIN32 @@ -77,11 +64,9 @@ getOsSeparator() const { #endif } -//////////////////////////////////////////////////////////////////// -// Function: PandaIOSystem::Open -// Access: Public -// Description: Opens the indicated file. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated file. + */ Assimp::IOStream *PandaIOSystem:: Open(const char *file, const char *mode) { Filename fn = Filename::from_os_specific(file); diff --git a/pandatool/src/assimp/pandaIOSystem.h b/pandatool/src/assimp/pandaIOSystem.h index b86c1695a1..cbf3d9cf6d 100644 --- a/pandatool/src/assimp/pandaIOSystem.h +++ b/pandatool/src/assimp/pandaIOSystem.h @@ -1,16 +1,15 @@ -// Filename: pandaIOSystem.h -// Created by: rdb (29Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaIOSystem.h + * @author rdb + * @date 2011-03-29 + */ #ifndef PANDAIOSYSTEM_H #define PANDAIOSYSTEM_H @@ -20,10 +19,9 @@ #include "assimp/IOSystem.hpp" -//////////////////////////////////////////////////////////////////// -// Class : PandaIOSystem -// Description : Custom implementation of Assimp::IOSystem. -//////////////////////////////////////////////////////////////////// +/** + * Custom implementation of Assimp::IOSystem. + */ class PandaIOSystem : public Assimp::IOSystem { public: PandaIOSystem(VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr()); @@ -40,4 +38,3 @@ private: }; #endif - diff --git a/pandatool/src/assimp/pandaLogger.cxx b/pandatool/src/assimp/pandaLogger.cxx index 20de4497b7..d503dc3fbe 100644 --- a/pandatool/src/assimp/pandaLogger.cxx +++ b/pandatool/src/assimp/pandaLogger.cxx @@ -1,16 +1,15 @@ -// Filename: pandaLogger.cxx -// Created by: rdb (05May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaLogger.cxx + * @author rdb + * @date 2011-05-05 + */ #include "pandaLogger.h" @@ -18,12 +17,10 @@ PandaLogger *PandaLogger::_ptr = NULL; -//////////////////////////////////////////////////////////////////// -// Function: PandaLogger::set_default -// Access: Public -// Description: Makes sure there's a global PandaLogger object and -// makes sure that it is Assimp's default logger. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure there's a global PandaLogger object and makes sure that it is + * Assimp's default logger. + */ void PandaLogger:: set_default() { if (_ptr == NULL) { @@ -34,38 +31,30 @@ set_default() { } } -//////////////////////////////////////////////////////////////////// -// Function: PandaLogger::OnDebug -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaLogger::OnDebug(const char *message) { assimp_cat.debug() << message << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PandaLogger::OnError -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaLogger::OnError(const char *message) { assimp_cat.error() << message << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PandaLogger::OnInfo -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaLogger::OnInfo(const char *message) { assimp_cat.info() << message << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: PandaLogger::OnWarn -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PandaLogger::OnWarn(const char *message) { assimp_cat.warning() << message << "\n"; } diff --git a/pandatool/src/assimp/pandaLogger.h b/pandatool/src/assimp/pandaLogger.h index f0843af353..799784e7fc 100644 --- a/pandatool/src/assimp/pandaLogger.h +++ b/pandatool/src/assimp/pandaLogger.h @@ -1,16 +1,15 @@ -// Filename: pandaLogger.h -// Created by: rdb (05May11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandaLogger.h + * @author rdb + * @date 2011-05-05 + */ #ifndef PANDALOGGER_H #define PANDALOGGER_H @@ -19,11 +18,10 @@ #include "assimp/Logger.hpp" -//////////////////////////////////////////////////////////////////// -// Class : PandaLogger -// Description : Custom implementation of Assimp::Logger. It -// simply wraps around the assimp_cat methods. -//////////////////////////////////////////////////////////////////// +/** + * Custom implementation of Assimp::Logger. It simply wraps around the + * assimp_cat methods. + */ class PandaLogger : public Assimp::Logger { public: static void set_default(); diff --git a/pandatool/src/bam/bamInfo.cxx b/pandatool/src/bam/bamInfo.cxx index 1839c09347..9c3403dc00 100644 --- a/pandatool/src/bam/bamInfo.cxx +++ b/pandatool/src/bam/bamInfo.cxx @@ -1,16 +1,15 @@ -// Filename: bamInfo.cxx -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamInfo.cxx + * @author drose + * @date 2000-07-02 + */ #include "bamInfo.h" @@ -27,11 +26,9 @@ #include "bamCacheIndex.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamInfo:: BamInfo() { set_program_brief("describe the contents of .bam files"); @@ -61,11 +58,9 @@ BamInfo() { } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BamInfo:: run() { bool okflag = true; @@ -90,11 +85,9 @@ run() { } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BamInfo:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -111,12 +104,10 @@ handle_args(ProgramBase::Args &args) { } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::get_info -// Access: Private -// Description: Reads a single Bam file and displays its contents. -// Returns true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single Bam file and displays its contents. Returns true if + * successful, false on error. + */ bool BamInfo:: get_info(const Filename &filename) { BamFile bam_file; @@ -136,17 +127,17 @@ get_info(const Filename &filename) { } nout << filename << " : Bam version " << bam_file.get_file_major_ver() - << "." << bam_file.get_file_minor_ver() + << "." << bam_file.get_file_minor_ver() << ", " << endian << ", " << float_width << "-bit floats.\n"; Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != (TypedWritable *)NULL && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a - // BamCacheRecord, it's a cache data file; in this case, we output - // the cache record, and then pretend it doesn't exist. + // BamCacheRecord, it's a cache data file; in this case, we output the + // cache record, and then pretend it doesn't exist. DCAST(BamCacheRecord, object)->write(nout, 2); nout << "\n"; object = bam_file.read_object(); @@ -163,18 +154,18 @@ get_info(const Filename &filename) { return false; } - // We can't close the bam file until we have examined the objects, - // since closing it will decrement reference counts. + // We can't close the bam file until we have examined the objects, since + // closing it will decrement reference counts. - if (objects.size() == 1 && + if (objects.size() == 1 && objects[0]->is_of_type(PandaNode::get_class_type())) { describe_scene_graph(DCAST(PandaNode, objects[0])); - } else if (objects.size() == 1 && + } else if (objects.size() == 1 && objects[0]->is_of_type(Texture::get_class_type())) { describe_texture(DCAST(Texture, objects[0])); - } else if (objects.size() == 1 && + } else if (objects.size() == 1 && objects[0]->is_of_type(BamCacheIndex::get_class_type())) { describe_cache_index(DCAST(BamCacheIndex, objects[0])); @@ -192,20 +183,16 @@ get_info(const Filename &filename) { } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::describe_scene_graph -// Access: Private -// Description: Called for Bam files that contain a single scene -// graph and no other objects. This should describe -// that scene graph in some meaningful way. -//////////////////////////////////////////////////////////////////// +/** + * Called for Bam files that contain a single scene graph and no other + * objects. This should describe that scene graph in some meaningful way. + */ void BamInfo:: describe_scene_graph(PandaNode *node) { - // Parent the node to our own scene graph root, so we can (a) - // guarantee it won't accidentally be deleted before we're done, (b) - // easily determine the bounding volume of the scene, and (c) report - // statistics on all the bam file's scene graphs together when we've - // finished. + // Parent the node to our own scene graph root, so we can (a) guarantee it + // won't accidentally be deleted before we're done, (b) easily determine the + // bounding volume of the scene, and (c) report statistics on all the bam + // file's scene graphs together when we've finished. PT(PandaNode) root = new PandaNode("root"); root->add_child(node); @@ -223,33 +210,25 @@ describe_scene_graph(PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::describe_texture -// Access: Private -// Description: Called for Bam files that contain a Texture object. -//////////////////////////////////////////////////////////////////// +/** + * Called for Bam files that contain a Texture object. + */ void BamInfo:: describe_texture(Texture *tex) { tex->write(nout, 2); } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::describe_cache_index -// Access: Private -// Description: Called for Bam files that contain a BamCacheIndex -// object. -//////////////////////////////////////////////////////////////////// +/** + * Called for Bam files that contain a BamCacheIndex object. + */ void BamInfo:: describe_cache_index(BamCacheIndex *index) { index->write(nout, 2); } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::describe_session -// Access: Private -// Description: Called for Bam files that contain a recorded session -// table. -//////////////////////////////////////////////////////////////////// +/** + * Called for Bam files that contain a recorded session table. + */ void BamInfo:: describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { char time_buffer[1024]; @@ -273,7 +252,7 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { last_timestamp = frame->_timestamp; } } - + nout << "Session, " << last_timestamp << " secs, " << objects.size() - 1 << " frames, " << time_buffer << ".\n" @@ -286,25 +265,20 @@ describe_session(RecorderHeader *header, const BamInfo::Objects &objects) { nout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::describe_general_object -// Access: Private -// Description: Called for Bam files that contain multiple objects -// which may or may not be scene graph nodes. This -// should describe each object in some meaningful way. -//////////////////////////////////////////////////////////////////// +/** + * Called for Bam files that contain multiple objects which may or may not be + * scene graph nodes. This should describe each object in some meaningful + * way. + */ void BamInfo:: describe_general_object(TypedWritable *object) { nassertv(object != (TypedWritable *)NULL); nout << " " << object->get_type() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BamInfo::list_hierarchy -// Access: Private -// Description: Outputs the hierarchy and all of the verbose GeomNode -// information. -//////////////////////////////////////////////////////////////////// +/** + * Outputs the hierarchy and all of the verbose GeomNode information. + */ void BamInfo:: list_hierarchy(PandaNode *node, int indent_level) { indent(nout, indent_level) << *node; diff --git a/pandatool/src/bam/bamInfo.h b/pandatool/src/bam/bamInfo.h index c8123bc98f..766c6986a6 100644 --- a/pandatool/src/bam/bamInfo.h +++ b/pandatool/src/bam/bamInfo.h @@ -1,16 +1,15 @@ -// Filename: bamInfo.h -// Created by: drose (02Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamInfo.h + * @author drose + * @date 2000-07-02 + */ #ifndef BAMINFO_H #define BAMINFO_H @@ -29,10 +28,9 @@ class Texture; class BamCacheIndex; class RecorderHeader; -//////////////////////////////////////////////////////////////////// -// Class : BamInfo -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class BamInfo : public ProgramBase { public: BamInfo(); diff --git a/pandatool/src/bam/bamToEgg.cxx b/pandatool/src/bam/bamToEgg.cxx index eb2f652a3b..b3a2c48535 100644 --- a/pandatool/src/bam/bamToEgg.cxx +++ b/pandatool/src/bam/bamToEgg.cxx @@ -1,16 +1,15 @@ -// Filename: bamToEgg.cxx -// Created by: drose (25Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamToEgg.cxx + * @author drose + * @date 2001-06-25 + */ #include "bamToEgg.h" #include "save_egg_file.h" @@ -19,11 +18,9 @@ #include "bamFile.h" #include "bamCacheRecord.h" -//////////////////////////////////////////////////////////////////// -// Function: BamToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ BamToEgg:: BamToEgg() : SomethingToEgg("bam", ".bam") @@ -43,11 +40,9 @@ BamToEgg() : _coordinate_system = get_default_coordinate_system(); } -//////////////////////////////////////////////////////////////////// -// Function: BamToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void BamToEgg:: run() { BamFile bam_file; @@ -58,19 +53,19 @@ run() { } nout << _input_filename << " : Bam version " - << bam_file.get_file_major_ver() << "." + << bam_file.get_file_major_ver() << "." << bam_file.get_file_minor_ver() << "\n"; typedef pvector Objects; Objects objects; TypedWritable *object = bam_file.read_object(); - if (object != (TypedWritable *)NULL && + if (object != (TypedWritable *)NULL && object->is_exact_type(BamCacheRecord::get_class_type())) { // Here's a special case: if the first object in the file is a - // BamCacheRecord, it's really a cache data file and not a true - // bam file; but skip over the cache data record and let the user - // treat it like an ordinary bam file. + // BamCacheRecord, it's really a cache data file and not a true bam file; + // but skip over the cache data record and let the user treat it like an + // ordinary bam file. object = bam_file.read_object(); } @@ -89,7 +84,7 @@ run() { _data->set_coordinate_system(_coordinate_system); - if (objects.size() == 1 && + if (objects.size() == 1 && objects[0]->is_of_type(PandaNode::get_class_type())) { PandaNode *node = DCAST(PandaNode, objects[0]); save_egg_data(_data, node); diff --git a/pandatool/src/bam/bamToEgg.h b/pandatool/src/bam/bamToEgg.h index 9c92dee752..f5a29c3f41 100644 --- a/pandatool/src/bam/bamToEgg.h +++ b/pandatool/src/bam/bamToEgg.h @@ -1,16 +1,15 @@ -// Filename: bamToEgg.h -// Created by: drose (25Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file bamToEgg.h + * @author drose + * @date 2001-06-25 + */ #ifndef BAMTOEGG_H #define BAMTOEGG_H @@ -19,12 +18,10 @@ #include "somethingToEgg.h" -//////////////////////////////////////////////////////////////////// -// Class : BamToEgg -// Description : This program reads a bam file, for instance as -// written out from a real-time interaction session, and -// generates a corresponding egg file. -//////////////////////////////////////////////////////////////////// +/** + * This program reads a bam file, for instance as written out from a real-time + * interaction session, and generates a corresponding egg file. + */ class BamToEgg : public SomethingToEgg { public: BamToEgg(); diff --git a/pandatool/src/bam/eggToBam.cxx b/pandatool/src/bam/eggToBam.cxx index 4c1587fc99..ce9f2884a6 100644 --- a/pandatool/src/bam/eggToBam.cxx +++ b/pandatool/src/bam/eggToBam.cxx @@ -1,16 +1,15 @@ -// Filename: eggToBam.cxx -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToBam.cxx + * @author drose + * @date 2000-06-28 + */ #include "eggToBam.h" @@ -34,11 +33,9 @@ #include "frameBufferProperties.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToBam:: EggToBam() : EggToSomething("Bam", ".bam", true, false) @@ -51,8 +48,8 @@ EggToBam() : "considered replacements for egg files, but they tend to be smaller and " "load much faster than the equivalent egg files."); - // -f is always in effect for egg2bam. It doesn't make sense to - // provide it as an option to the user. + // -f is always in effect for egg2bam. It doesn't make sense to provide it + // as an option to the user. remove_option("f"); add_path_replace_options(); @@ -218,16 +215,14 @@ EggToBam() : _ctex_quality = "best"; } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToBam:: run() { if (_has_egg_flatten) { - // If the user specified some -flatten, we need to set the - // corresponding Config.prc variable. + // If the user specified some -flatten, we need to set the corresponding + // Config.prc variable. egg_flatten = (_egg_flatten != 0); } if (_has_egg_combine_geoms) { @@ -243,22 +238,22 @@ run() { compress_channels = false; } else if (_has_compression_quality) { - // Otherwise, if the user specified a compression quality with -C, - // use that quality level. + // Otherwise, if the user specified a compression quality with -C, use + // that quality level. compress_channels = true; compress_chan_quality = _compression_quality; } if (_ctex_quality != "default") { - // Override the user's config file with the command-line parameter - // for texture compression. + // Override the user's config file with the command-line parameter for + // texture compression. string prc = "texture-quality-level " + _ctex_quality; load_prc_file_data("prc", prc); } if (!_got_coordinate_system) { - // If the user didn't specify otherwise, ensure the coordinate - // system is Z-up. + // If the user didn't specify otherwise, ensure the coordinate system is + // Z-up. _data->set_coordinate_system(CS_zup_right); } @@ -285,8 +280,8 @@ run() { tex->get_ram_image(); bool want_mipmaps = (_tex_mipmap || tex->uses_mipmaps()); if (want_mipmaps) { - // Generate mipmap levels. - tex->generate_ram_mipmap_images(); + // Generate mipmap levels. + tex->generate_ram_mipmap_images(); } if (_tex_ctex) { @@ -297,15 +292,15 @@ run() { tex->set_compression(Texture::CM_on); #else // HAVE_SQUISH tex->set_keep_ram_image(true); - bool has_mipmap_levels = (tex->get_num_ram_mipmap_images() > 1); + bool has_mipmap_levels = (tex->get_num_ram_mipmap_images() > 1); if (!_engine->extract_texture_data(tex, _gsg)) { nout << " couldn't compress " << tex->get_name() << "\n"; } - if (!has_mipmap_levels && !want_mipmaps) { - // Make sure we didn't accidentally introduce mipmap levels - // by rendezvousing through the graphics card. - tex->clear_ram_mipmap_images(); - } + if (!has_mipmap_levels && !want_mipmaps) { + // Make sure we didn't accidentally introduce mipmap levels by + // rendezvousing through the graphics card. + tex->clear_ram_mipmap_images(); + } tex->set_keep_ram_image(false); #endif // HAVE_SQUISH } @@ -315,13 +310,13 @@ run() { } } } - + if (_ls) { root->ls(nout, 0); } - - // This should be guaranteed because we pass false to the - // constructor, above. + + // This should be guaranteed because we pass false to the constructor, + // above. nassertv(has_output_filename()); Filename filename = get_output_filename(); @@ -332,26 +327,23 @@ run() { nout << "Error in writing.\n"; exit(1); } - + if (!bam_file.write_object(root)) { nout << "Error in writing.\n"; exit(1); } } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggToBam:: handle_args(ProgramBase::Args &args) { - // If the user specified a path store option, we need to set the - // bam-texture-mode Config.prc variable directly to support this - // (otherwise the bam code will do what it wants to do anyway). + // If the user specified a path store option, we need to set the bam- + // texture-mode Config.prc variable directly to support this (otherwise the + // bam code will do what it wants to do anyway). if (_tex_rawdata) { bam_texture_mode = BamFile::BTM_rawdata; @@ -359,20 +351,17 @@ handle_args(ProgramBase::Args &args) { bam_texture_mode = BamFile::BTM_unchanged; } else { - // Otherwise, the default path store is absolute; then the - // bam-texture-mode can do the appropriate thing to it. + // Otherwise, the default path store is absolute; then the bam-texture- + // mode can do the appropriate thing to it. _path_replace->_path_store = PS_absolute; } return EggToSomething::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::collect_textures -// Access: Private -// Description: Recursively walks the scene graph, looking for -// Texture references. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the scene graph, looking for Texture references. + */ void EggToBam:: collect_textures(PandaNode *node) { collect_textures(node->get_state()); @@ -391,12 +380,9 @@ collect_textures(PandaNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::collect_textures -// Access: Private -// Description: Recursively walks the scene graph, looking for -// Texture references. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the scene graph, looking for Texture references. + */ void EggToBam:: collect_textures(const RenderState *state) { const TextureAttrib *tex_attrib = DCAST(TextureAttrib, state->get_attrib(TextureAttrib::get_class_type())); @@ -408,21 +394,18 @@ collect_textures(const RenderState *state) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::convert_txo -// Access: Private -// Description: If the indicated Texture was not already loaded from -// a txo file, writes it to a txo file and updates the -// Texture object to reference the new file. -//////////////////////////////////////////////////////////////////// +/** + * If the indicated Texture was not already loaded from a txo file, writes it + * to a txo file and updates the Texture object to reference the new file. + */ void EggToBam:: convert_txo(Texture *tex) { if (!tex->get_loaded_from_txo()) { Filename fullpath = tex->get_fullpath().get_filename_index(0); if (_tex_txopz) { fullpath.set_extension("txo.pz"); - // We use this clumsy syntax so that the new extension appears to be - // two separate extensions, .txo followed by .pz, which is what + // We use this clumsy syntax so that the new extension appears to be two + // separate extensions, .txo followed by .pz, which is what // Texture::write() expects to find. fullpath = Filename(fullpath.get_fullpath()); } else { @@ -453,12 +436,9 @@ convert_txo(Texture *tex) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToBam::make_buffer -// Access: Private -// Description: Creates a GraphicsBuffer for communicating with the -// graphics card. -//////////////////////////////////////////////////////////////////// +/** + * Creates a GraphicsBuffer for communicating with the graphics card. + */ bool EggToBam:: make_buffer() { if (!_load_display.empty()) { @@ -478,8 +458,8 @@ make_buffer() { FrameBufferProperties fbprops = FrameBufferProperties::get_default(); - // Some graphics drivers can only create single-buffered offscreen - // buffers. So request that. + // Some graphics drivers can only create single-buffered offscreen buffers. + // So request that. fbprops.set_back_buffers(0); WindowProperties winprops; @@ -489,9 +469,8 @@ make_buffer() { winprops.set_open(true); winprops.set_z_order(WindowProperties::Z_bottom); - // We don't care how big the buffer is; we just need it to manifest - // the GSG. - _buffer = _engine->make_output(_pipe, "buffer", 0, + // We don't care how big the buffer is; we just need it to manifest the GSG. + _buffer = _engine->make_output(_pipe, "buffer", 0, fbprops, winprops, GraphicsPipe::BF_fb_props_optional); _engine->open_windows(); diff --git a/pandatool/src/bam/eggToBam.h b/pandatool/src/bam/eggToBam.h index f583bb4a41..a2fb838871 100644 --- a/pandatool/src/bam/eggToBam.h +++ b/pandatool/src/bam/eggToBam.h @@ -1,16 +1,15 @@ -// Filename: eggToBam.h -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToBam.h + * @author drose + * @date 2000-06-28 + */ #ifndef EGGTOBAM_H #define EGGTOBAM_H @@ -28,10 +27,9 @@ class GraphicsEngine; class GraphicsStateGuardian; class GraphicsOutput; -//////////////////////////////////////////////////////////////////// -// Class : EggToBam -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EggToBam : public EggToSomething { public: EggToBam(); diff --git a/pandatool/src/bam/ptsToBam.cxx b/pandatool/src/bam/ptsToBam.cxx index c45dd6e1a3..d1d55056e4 100644 --- a/pandatool/src/bam/ptsToBam.cxx +++ b/pandatool/src/bam/ptsToBam.cxx @@ -1,16 +1,15 @@ -// Filename: ptsToBam.cxx -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ptsToBam.cxx + * @author drose + * @date 2000-06-28 + */ #include "ptsToBam.h" @@ -24,11 +23,9 @@ #include "string_utils.h" #include "config_egg2pg.h" -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PtsToBam:: PtsToBam() : WithOutputFile(true, false, true) { @@ -58,11 +55,9 @@ PtsToBam() : WithOutputFile(true, false, true) _decimate_divisor = 1.0; } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PtsToBam:: run() { pifstream pts; @@ -87,12 +82,12 @@ run() { process_line(line); } close_vertex_data(); - + nout << "\nFound " << _num_points_found << " points of " << _num_points_expected << " expected.\n"; nout << "Generated " << _num_points_added << " points to bam file.\n"; - // This should be guaranteed because we pass false to the - // constructor, above. + // This should be guaranteed because we pass false to the constructor, + // above. nassertv(has_output_filename()); Filename filename = get_output_filename(); @@ -103,18 +98,16 @@ run() { nout << "Error in writing.\n"; exit(1); } - + if (!bam_file.write_object(_gnode.p())) { nout << "Error in writing.\n"; exit(1); } } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool PtsToBam:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -132,11 +125,9 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::process_line -// Access: Private -// Description: Reads a single line from the pts file. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single line from the pts file. + */ void PtsToBam:: process_line(const string &line) { _line_number++; @@ -177,11 +168,9 @@ process_line(const string &line) { } } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::add_point -// Access: Private -// Description: Adds a point from the pts file. -//////////////////////////////////////////////////////////////////// +/** + * Adds a point from the pts file. + */ void PtsToBam:: add_point(const vector_string &words) { if (_data == NULL || _data->get_num_rows() >= egg_max_vertices) { @@ -197,11 +186,9 @@ add_point(const vector_string &words) { _num_points_added++; } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::open_vertex_data -// Access: Private -// Description: Creates a new GeomVertexData. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new GeomVertexData. + */ void PtsToBam:: open_vertex_data() { if (_data != (GeomVertexData *)NULL) { @@ -212,12 +199,9 @@ open_vertex_data() { _vertex = GeomVertexWriter(_data, "vertex"); } -//////////////////////////////////////////////////////////////////// -// Function: PtsToBam::close_vertex_data -// Access: Private -// Description: Closes a previous GeomVertexData and adds it to the -// scene graph. -//////////////////////////////////////////////////////////////////// +/** + * Closes a previous GeomVertexData and adds it to the scene graph. + */ void PtsToBam:: close_vertex_data() { if (_data == NULL) { diff --git a/pandatool/src/bam/ptsToBam.h b/pandatool/src/bam/ptsToBam.h index c6f0184837..9e6f7ac63e 100644 --- a/pandatool/src/bam/ptsToBam.h +++ b/pandatool/src/bam/ptsToBam.h @@ -1,16 +1,15 @@ -// Filename: ptsToBam.h -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file ptsToBam.h + * @author drose + * @date 2000-06-28 + */ #ifndef PTSTOBAM_H #define PTSTOBAM_H @@ -25,10 +24,9 @@ #include "geomVertexWriter.h" #include "geomNode.h" -//////////////////////////////////////////////////////////////////// -// Class : PtsToBam -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class PtsToBam : public ProgramBase, public WithOutputFile { public: PtsToBam(); diff --git a/pandatool/src/converter/eggToSomethingConverter.I b/pandatool/src/converter/eggToSomethingConverter.I index c8c9ae5d91..5e80c2cad8 100644 --- a/pandatool/src/converter/eggToSomethingConverter.I +++ b/pandatool/src/converter/eggToSomethingConverter.I @@ -1,80 +1,63 @@ -// Filename: eggToSomethingConverter.I -// Created by: drose (26Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToSomethingConverter.I + * @author drose + * @date 2012-09-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::clear_error -// Access: Public -// Description: Resets the error flag to the no-error state. -// had_error() will return false until a new error is -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Resets the error flag to the no-error state. had_error() will return false + * until a new error is generated. + */ INLINE void EggToSomethingConverter:: clear_error() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::had_error -// Access: Public -// Description: Returns true if an error was detected during the -// conversion process, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an error was detected during the conversion process, false + * otherwise. + */ INLINE bool EggToSomethingConverter:: had_error() const { return _error; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::clear_egg_data -// Access: Public -// Description: Sets the EggData to NULL and makes the converter -// invalid. -//////////////////////////////////////////////////////////////////// +/** + * Sets the EggData to NULL and makes the converter invalid. + */ INLINE void EggToSomethingConverter:: clear_egg_data() { set_egg_data((EggData *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::get_egg_data -// Access: Public -// Description: Returns the EggData structure. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggData structure. + */ INLINE EggData *EggToSomethingConverter:: get_egg_data() { return _egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::set_output_units -// Access: Public -// Description: Specifies the units that the EggData has already been -// scaled to. This is informational only; if the target -// file format supports it, this information will be -// written to the header. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the units that the EggData has already been scaled to. This is + * informational only; if the target file format supports it, this information + * will be written to the header. + */ void EggToSomethingConverter:: set_output_units(DistanceUnit output_units) { _output_units = output_units; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::get_output_units -// Access: Public -// Description: Returns the value supplied to set_output_units(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the value supplied to set_output_units(). + */ DistanceUnit EggToSomethingConverter:: get_output_units() const { return _output_units; diff --git a/pandatool/src/converter/eggToSomethingConverter.cxx b/pandatool/src/converter/eggToSomethingConverter.cxx index 50febd225b..f786c81f00 100644 --- a/pandatool/src/converter/eggToSomethingConverter.cxx +++ b/pandatool/src/converter/eggToSomethingConverter.cxx @@ -1,84 +1,68 @@ -// Filename: eggToSomethingConverter.cxx -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToSomethingConverter.cxx + * @author drose + * @date 2001-04-26 + */ #include "eggToSomethingConverter.h" #include "eggData.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToSomethingConverter:: EggToSomethingConverter() { _egg_data = (EggData *)NULL; _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToSomethingConverter:: EggToSomethingConverter(const EggToSomethingConverter ©) { _egg_data = (EggData *)NULL; _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToSomethingConverter:: ~EggToSomethingConverter() { clear_egg_data(); } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::set_egg_data -// Access: Public -// Description: Sets the egg data that will be filled in when -// convert_file() is called. This must be called before -// convert_file(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the egg data that will be filled in when convert_file() is called. + * This must be called before convert_file(). + */ void EggToSomethingConverter:: set_egg_data(EggData *egg_data) { _egg_data = egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::get_additional_extensions -// Access: Public, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this converter. + */ string EggToSomethingConverter:: get_additional_extensions() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomethingConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently save -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently save compressed files + * (with a .pz extension), false otherwise. + */ bool EggToSomethingConverter:: supports_compressed() const { return false; diff --git a/pandatool/src/converter/eggToSomethingConverter.h b/pandatool/src/converter/eggToSomethingConverter.h index a9ef4b228e..47838859d4 100644 --- a/pandatool/src/converter/eggToSomethingConverter.h +++ b/pandatool/src/converter/eggToSomethingConverter.h @@ -1,16 +1,15 @@ -// Filename: eggToSomethingConverter.h -// Created by: drose (26Sep12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToSomethingConverter.h + * @author drose + * @date 2012-09-26 + */ #ifndef EGGTOSOMETHINGCONVERTER_H #define EGGTOSOMETHINGCONVERTER_H @@ -25,16 +24,13 @@ class EggData; class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : EggToSomethingConverter -// Description : This is a base class for a family of converter -// classes that manage a conversion from egg format to -// some other file type. -// -// Classes of this type can be used to implement egg2xxx -// converter programs, as well as LoaderFileTypeXXX -// run-time savers. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for a family of converter classes that manage a + * conversion from egg format to some other file type. + * + * Classes of this type can be used to implement egg2xxx converter programs, + * as well as LoaderFileTypeXXX run-time savers. + */ class EggToSomethingConverter { public: EggToSomethingConverter(); @@ -73,5 +69,3 @@ protected: #include "eggToSomethingConverter.I" #endif - - diff --git a/pandatool/src/converter/somethingToEggConverter.I b/pandatool/src/converter/somethingToEggConverter.I index e51c9f1b13..42e9f4b2cf 100644 --- a/pandatool/src/converter/somethingToEggConverter.I +++ b/pandatool/src/converter/somethingToEggConverter.I @@ -1,508 +1,390 @@ -// Filename: somethingToEggConverter.I -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file somethingToEggConverter.I + * @author drose + * @date 2001-04-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_error -// Access: Public -// Description: Resets the error flag to the no-error state. -// had_error() will return false until a new error is -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Resets the error flag to the no-error state. had_error() will return false + * until a new error is generated. + */ INLINE void SomethingToEggConverter:: clear_error() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::had_error -// Access: Public -// Description: Returns true if an error was detected during the -// conversion process (unless _allow_errors is true), -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an error was detected during the conversion process (unless + * _allow_errors is true), false otherwise. + */ INLINE bool SomethingToEggConverter:: had_error() const { return !_allow_errors && (_error || _path_replace->had_error()); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_path_replace -// Access: Public -// Description: Replaces the PathReplace object (which specifies how -// to mangle paths from the source to the destination -// egg file) with a new one. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the PathReplace object (which specifies how to mangle paths from + * the source to the destination egg file) with a new one. + */ INLINE void SomethingToEggConverter:: set_path_replace(PathReplace *path_replace) { _path_replace = path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_path_replace -// Access: Public -// Description: Returns a pointer to the PathReplace object -// associated with this converter. If the converter is -// non-const, this returns a non-const pointer, which -// can be adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PathReplace object associated with this converter. + * If the converter is non-const, this returns a non-const pointer, which can + * be adjusted. + */ INLINE PathReplace *SomethingToEggConverter:: get_path_replace() { return _path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_path_replace -// Access: Public -// Description: Returns a pointer to the PathReplace object -// associated with this converter. If the converter is -// non-const, this returns a non-const pointer, which -// can be adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PathReplace object associated with this converter. + * If the converter is non-const, this returns a non-const pointer, which can + * be adjusted. + */ INLINE const PathReplace *SomethingToEggConverter:: get_path_replace() const { return _path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_animation_convert -// Access: Public -// Description: Specifies how source animation will be converted into -// egg structures. The default is AC_none, which means -// animation tables will be ignored. This is only -// meaningful for converters that understand animation. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how source animation will be converted into egg structures. The + * default is AC_none, which means animation tables will be ignored. This is + * only meaningful for converters that understand animation. + */ INLINE void SomethingToEggConverter:: set_animation_convert(AnimationConvert animation_convert) { _animation_convert = animation_convert; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_animation_convert -// Access: Public -// Description: Returns how source animation will be converted into -// egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Returns how source animation will be converted into egg structures. + */ INLINE AnimationConvert SomethingToEggConverter:: get_animation_convert() const { return _animation_convert; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_character_name -// Access: Public -// Description: Specifies the name of the character generated. This -// name should match between all the model and channel -// egg files for a particular character and its -// associated animations. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of the character generated. This name should match + * between all the model and channel egg files for a particular character and + * its associated animations. + */ INLINE void SomethingToEggConverter:: set_character_name(const string &character_name) { _character_name = character_name; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_character_name -// Access: Public -// Description: Returns the name of the character generated. See -// set_character_name(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the character generated. See set_character_name(). + */ INLINE const string &SomethingToEggConverter:: get_character_name() const { return _character_name; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_start_frame -// Access: Public -// Description: Specifies the starting frame of the animation to -// convert, in the units specified by -// set_input_frame_rate(). If this is unspecified, the -// starting frame is taken from the source, for instance -// from the first frame of the animation slider. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the starting frame of the animation to convert, in the units + * specified by set_input_frame_rate(). If this is unspecified, the starting + * frame is taken from the source, for instance from the first frame of the + * animation slider. + */ INLINE void SomethingToEggConverter:: set_start_frame(double start_frame) { _start_frame = start_frame; _control_flags |= CF_start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_start_frame -// Access: Public -// Description: Returns true if the starting frame has been -// explicitly specified via set_start_frame(), or false -// if the starting frame should be implicit based on the -// source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the starting frame has been explicitly specified via + * set_start_frame(), or false if the starting frame should be implicit based + * on the source. + */ INLINE bool SomethingToEggConverter:: has_start_frame() const { return (_control_flags & CF_start_frame) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_start_frame -// Access: Public -// Description: Returns the value set by a previous call to -// set_start_frame(). It is an error to call this if -// has_start_frame() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_start_frame(). It is an + * error to call this if has_start_frame() returns false. + */ INLINE double SomethingToEggConverter:: get_start_frame() const { nassertr(has_start_frame(), 0.0); return _start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_start_frame -// Access: Public -// Description: Removes the value previously set by -// set_start_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_start_frame(). + */ INLINE void SomethingToEggConverter:: clear_start_frame() { _start_frame = 0.0; _control_flags &= ~CF_start_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_end_frame -// Access: Public -// Description: Specifies the ending frame of the animation to -// convert, in the units specified by -// set_input_frame_rate(). If this is unspecified, the -// ending frame is taken from the source, for instance -// from the last frame of the animation slider. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the ending frame of the animation to convert, in the units + * specified by set_input_frame_rate(). If this is unspecified, the ending + * frame is taken from the source, for instance from the last frame of the + * animation slider. + */ INLINE void SomethingToEggConverter:: set_end_frame(double end_frame) { _end_frame = end_frame; _control_flags |= CF_end_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_end_frame -// Access: Public -// Description: Returns true if the ending frame has been -// explicitly specified via set_end_frame(), or false -// if the ending frame should be implicit based on the -// source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the ending frame has been explicitly specified via + * set_end_frame(), or false if the ending frame should be implicit based on + * the source. + */ INLINE bool SomethingToEggConverter:: has_end_frame() const { return (_control_flags & CF_end_frame) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_end_frame -// Access: Public -// Description: Returns the value set by a previous call to -// set_end_frame(). It is an error to call this if -// has_end_frame() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_end_frame(). It is an + * error to call this if has_end_frame() returns false. + */ INLINE double SomethingToEggConverter:: get_end_frame() const { nassertr(has_end_frame(), 0.0); return _end_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_end_frame -// Access: Public -// Description: Removes the value previously set by -// set_end_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_end_frame(). + */ INLINE void SomethingToEggConverter:: clear_end_frame() { _end_frame = 0.0; _control_flags &= ~CF_end_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_frame_inc -// Access: Public -// Description: Specifies the increment between frames to extract. -// This is the amount to increment the time slider (in -// units of internal_frame_rate) between extracting each -// frame. If this is not specified, the default is -// taken from the animation package, or 1.0 if the -// animation package does not specified a frame -// increment. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the increment between frames to extract. This is the amount to + * increment the time slider (in units of internal_frame_rate) between + * extracting each frame. If this is not specified, the default is taken from + * the animation package, or 1.0 if the animation package does not specified a + * frame increment. + */ INLINE void SomethingToEggConverter:: set_frame_inc(double frame_inc) { _frame_inc = frame_inc; _control_flags |= CF_frame_inc; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_frame_inc -// Access: Public -// Description: Returns true if the frame increment has been -// explicitly specified via set_frame_inc(), or false -// if the ending frame should be implicit based on the -// source. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the frame increment has been explicitly specified via + * set_frame_inc(), or false if the ending frame should be implicit based on + * the source. + */ INLINE bool SomethingToEggConverter:: has_frame_inc() const { return (_control_flags & CF_frame_inc) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_frame_inc -// Access: Public -// Description: Returns the value set by a previous call to -// set_frame_inc(). It is an error to call this if -// has_frame_inc() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_frame_inc(). It is an + * error to call this if has_frame_inc() returns false. + */ INLINE double SomethingToEggConverter:: get_frame_inc() const { nassertr(has_frame_inc(), 0.0); return _frame_inc; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_frame_inc -// Access: Public -// Description: Removes the value previously set by -// set_frame_inc(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_frame_inc(). + */ INLINE void SomethingToEggConverter:: clear_frame_inc() { _frame_inc = 0.0; _control_flags &= ~CF_frame_inc; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_neutral_frame -// Access: Public -// Description: Specifies the frame of animation to represent the -// neutral pose of the model. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the frame of animation to represent the neutral pose of the + * model. + */ INLINE void SomethingToEggConverter:: set_neutral_frame(double neutral_frame) { _neutral_frame = neutral_frame; _control_flags |= CF_neutral_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_neutral_frame -// Access: Public -// Description: Returns true if the neutral frame has been -// explicitly specified via set_neutral_frame(), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the neutral frame has been explicitly specified via + * set_neutral_frame(), or false otherwise. + */ INLINE bool SomethingToEggConverter:: has_neutral_frame() const { return (_control_flags & CF_neutral_frame) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_neutral_frame -// Access: Public -// Description: Returns the value set by a previous call to -// set_neutral_frame(). It is an error to call this if -// has_neutral_frame() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_neutral_frame(). It is an + * error to call this if has_neutral_frame() returns false. + */ INLINE double SomethingToEggConverter:: get_neutral_frame() const { nassertr(has_neutral_frame(), 0.0); return _neutral_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_neutral_frame -// Access: Public -// Description: Removes the value previously set by -// set_neutral_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_neutral_frame(). + */ INLINE void SomethingToEggConverter:: clear_neutral_frame() { _neutral_frame = 0.0; _control_flags &= ~CF_neutral_frame; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_input_frame_rate -// Access: Public -// Description: Specifies the number of frames per second that is -// represented by the "frame" unit in the animation -// package. If this is omitted, it is taken from -// whatever the file header indicates. Some animation -// packages do not encode a frame rate, in which case -// the default if this is omitted is the same as the -// output frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of frames per second that is represented by the + * "frame" unit in the animation package. If this is omitted, it is taken + * from whatever the file header indicates. Some animation packages do not + * encode a frame rate, in which case the default if this is omitted is the + * same as the output frame rate. + */ INLINE void SomethingToEggConverter:: set_input_frame_rate(double input_frame_rate) { _input_frame_rate = input_frame_rate; _control_flags |= CF_input_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_input_frame_rate -// Access: Public -// Description: Returns true if the frame rate has been -// explicitly specified via set_input_frame_rate(), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the frame rate has been explicitly specified via + * set_input_frame_rate(), or false otherwise. + */ INLINE bool SomethingToEggConverter:: has_input_frame_rate() const { return (_control_flags & CF_input_frame_rate) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_input_frame_rate -// Access: Public -// Description: Returns the value set by a previous call to -// set_input_frame_rate(). It is an error to call this -// if has_input_frame_rate() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_input_frame_rate(). It is + * an error to call this if has_input_frame_rate() returns false. + */ INLINE double SomethingToEggConverter:: get_input_frame_rate() const { nassertr(has_input_frame_rate(), 0.0); return _input_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_input_frame_rate -// Access: Public -// Description: Removes the value previously set by -// set_input_frame_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_input_frame_rate(). + */ INLINE void SomethingToEggConverter:: clear_input_frame_rate() { _input_frame_rate = 0.0; _control_flags &= ~CF_input_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_output_frame_rate -// Access: Public -// Description: Specifies the number of frames per second that the -// resulting animation should be played at. If this is -// omitted, it is taken to be the same as the input -// frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the number of frames per second that the resulting animation + * should be played at. If this is omitted, it is taken to be the same as the + * input frame rate. + */ INLINE void SomethingToEggConverter:: set_output_frame_rate(double output_frame_rate) { _output_frame_rate = output_frame_rate; _control_flags |= CF_output_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::has_output_frame_rate -// Access: Public -// Description: Returns true if the frame rate has been -// explicitly specified via set_output_frame_rate(), or -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the frame rate has been explicitly specified via + * set_output_frame_rate(), or false otherwise. + */ INLINE bool SomethingToEggConverter:: has_output_frame_rate() const { return (_control_flags & CF_output_frame_rate) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_output_frame_rate -// Access: Public -// Description: Returns the value set by a previous call to -// set_output_frame_rate(). It is an error to call this -// if has_output_frame_rate() returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value set by a previous call to set_output_frame_rate(). It is + * an error to call this if has_output_frame_rate() returns false. + */ INLINE double SomethingToEggConverter:: get_output_frame_rate() const { nassertr(has_output_frame_rate(), 0.0); return _output_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_output_frame_rate -// Access: Public -// Description: Removes the value previously set by -// set_output_frame_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Removes the value previously set by set_output_frame_rate(). + */ INLINE void SomethingToEggConverter:: clear_output_frame_rate() { _output_frame_rate = 0.0; _control_flags &= ~CF_output_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_default_frame_rate -// Access: Public, Static -// Description: Returns the default frame rate if nothing is -// specified for input_frame_rate or output_frame_rate, -// and the animation package does not have an implicit -// frame rate. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default frame rate if nothing is specified for input_frame_rate + * or output_frame_rate, and the animation package does not have an implicit + * frame rate. + */ INLINE double SomethingToEggConverter:: get_default_frame_rate() { return 24.0; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_merge_externals -// Access: Public -// Description: Sets the merge_externals flag. When this is true, -// external references within the source file are read -// in and merged directly; otherwise, only a reference -// to a similarly-named egg file is inserted. -//////////////////////////////////////////////////////////////////// +/** + * Sets the merge_externals flag. When this is true, external references + * within the source file are read in and merged directly; otherwise, only a + * reference to a similarly-named egg file is inserted. + */ INLINE void SomethingToEggConverter:: set_merge_externals(bool merge_externals) { _merge_externals = merge_externals; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_merge_externals -// Access: Public -// Description: Returns the current state of the merge_externals -// flag. See set_merge_externals(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the merge_externals flag. See + * set_merge_externals(). + */ INLINE bool SomethingToEggConverter:: get_merge_externals() const { return _merge_externals; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::clear_egg_data -// Access: Public -// Description: Sets the EggData to NULL and makes the converter -// invalid. -//////////////////////////////////////////////////////////////////// +/** + * Sets the EggData to NULL and makes the converter invalid. + */ INLINE void SomethingToEggConverter:: clear_egg_data() { set_egg_data((EggData *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_egg_data -// Access: Public -// Description: Returns the EggData structure. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggData structure. + */ INLINE EggData *SomethingToEggConverter:: get_egg_data() { return _egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::convert_model_path -// Access: Public -// Description: Converts the indicated model filename to a relative -// or absolute or whatever filename, according to -// _path_replace. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated model filename to a relative or absolute or whatever + * filename, according to _path_replace. + */ INLINE Filename SomethingToEggConverter:: convert_model_path(const Filename &orig_filename) { return _path_replace->convert_path(orig_filename); diff --git a/pandatool/src/converter/somethingToEggConverter.cxx b/pandatool/src/converter/somethingToEggConverter.cxx index cd4bbf1afd..fd5a17abf7 100644 --- a/pandatool/src/converter/somethingToEggConverter.cxx +++ b/pandatool/src/converter/somethingToEggConverter.cxx @@ -1,27 +1,24 @@ -// Filename: somethingToEggConverter.cxx -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file somethingToEggConverter.cxx + * @author drose + * @date 2001-04-26 + */ #include "somethingToEggConverter.h" #include "eggData.h" #include "eggExternalReference.h" -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SomethingToEggConverter:: SomethingToEggConverter() { _allow_errors = false; @@ -40,11 +37,9 @@ SomethingToEggConverter() { _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SomethingToEggConverter:: SomethingToEggConverter(const SomethingToEggConverter ©) : _allow_errors(copy._allow_errors), @@ -55,112 +50,87 @@ SomethingToEggConverter(const SomethingToEggConverter ©) : _error = false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SomethingToEggConverter:: ~SomethingToEggConverter() { clear_egg_data(); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::set_egg_data -// Access: Public -// Description: Sets the egg data that will be filled in when -// convert_file() is called. This must be called before -// convert_file(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the egg data that will be filled in when convert_file() is called. + * This must be called before convert_file(). + */ void SomethingToEggConverter:: set_egg_data(EggData *egg_data) { _egg_data = egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_additional_extensions -// Access: Public, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this converter. + */ string SomethingToEggConverter:: get_additional_extensions() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool SomethingToEggConverter:: supports_compressed() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::supports_convert_to_node -// Access: Published, Virtual -// Description: Returns true if this converter can directly convert -// the model type to internal Panda memory structures, -// given the indicated options, or false otherwise. If -// this returns true, then convert_to_node() may be -// called to perform the conversion, which may be faster -// than calling convert_file() if the ultimate goal is a -// PandaNode anyway. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this converter can directly convert the model type to + * internal Panda memory structures, given the indicated options, or false + * otherwise. If this returns true, then convert_to_node() may be called to + * perform the conversion, which may be faster than calling convert_file() if + * the ultimate goal is a PandaNode anyway. + */ bool SomethingToEggConverter:: supports_convert_to_node(const LoaderOptions &options) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::get_input_units -// Access: Public, Virtual -// Description: This may be called after convert_file() has been -// called and returned true, indicating a successful -// conversion. It will return the distance units -// represented by the converted egg file, if known, or -// DU_invalid if not known. -//////////////////////////////////////////////////////////////////// +/** + * This may be called after convert_file() has been called and returned true, + * indicating a successful conversion. It will return the distance units + * represented by the converted egg file, if known, or DU_invalid if not + * known. + */ DistanceUnit SomethingToEggConverter:: get_input_units() { return DU_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::convert_to_node -// Access: Public, Virtual -// Description: Reads the input file and directly produces a -// ready-to-render model file as a PandaNode. Returns -// NULL on failure, or if it is not supported. (This -// functionality is not supported by all converter -// types; see supports_convert_to_node()). -//////////////////////////////////////////////////////////////////// +/** + * Reads the input file and directly produces a ready-to-render model file as + * a PandaNode. Returns NULL on failure, or if it is not supported. (This + * functionality is not supported by all converter types; see + * supports_convert_to_node()). + */ PT(PandaNode) SomethingToEggConverter:: convert_to_node(const LoaderOptions &options, const Filename &filename) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEggConverter::handle_external_reference -// Access: Public -// Description: Handles an external reference in the source file. If -// the merge_externals flag is true (see -// set_merge_externals()), this causes the named file to -// be read in and converted, and the converted egg -// geometry is parented to egg_parent. Otherwise, only -// a reference to a similarly named egg file is parented -// to egg_parent. -// -// The parameters orig_filename and searchpath are as -// those passed to convert_model_path(). -// -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Handles an external reference in the source file. If the merge_externals + * flag is true (see set_merge_externals()), this causes the named file to be + * read in and converted, and the converted egg geometry is parented to + * egg_parent. Otherwise, only a reference to a similarly named egg file is + * parented to egg_parent. + * + * The parameters orig_filename and searchpath are as those passed to + * convert_model_path(). + * + * Returns true on success, false on failure. + */ bool SomethingToEggConverter:: handle_external_reference(EggGroupNode *egg_parent, const Filename &ref_filename) { @@ -182,8 +152,8 @@ handle_external_reference(EggGroupNode *egg_parent, return true; } else { - // If we're installing external references instead of reading - // them, we should make it into an egg filename. + // If we're installing external references instead of reading them, we + // should make it into an egg filename. Filename filename = ref_filename; filename.set_extension("egg"); diff --git a/pandatool/src/converter/somethingToEggConverter.h b/pandatool/src/converter/somethingToEggConverter.h index 636d7aa7f8..0388ca8fb4 100644 --- a/pandatool/src/converter/somethingToEggConverter.h +++ b/pandatool/src/converter/somethingToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: somethingToEggConverter.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file somethingToEggConverter.h + * @author drose + * @date 2001-04-17 + */ #ifndef SOMETHINGTOEGGCONVERTER_H #define SOMETHINGTOEGGCONVERTER_H @@ -29,16 +28,13 @@ class EggData; class EggGroupNode; class LoaderOptions; -//////////////////////////////////////////////////////////////////// -// Class : SomethingToEggConverter -// Description : This is a base class for a family of converter -// classes that manage a conversion from some file type -// to egg format. -// -// Classes of this type can be used to implement xxx2egg -// converter programs, as well as LoaderFileTypeXXX -// run-time loaders. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for a family of converter classes that manage a + * conversion from some file type to egg format. + * + * Classes of this type can be used to implement xxx2egg converter programs, + * as well as LoaderFileTypeXXX run-time loaders. + */ class SomethingToEggConverter { public: SomethingToEggConverter(); @@ -54,8 +50,8 @@ public: INLINE PathReplace *get_path_replace(); INLINE const PathReplace *get_path_replace() const; - // These methods dealing with animation and frame rate are only - // relevant to converter types that understand animation. + // These methods dealing with animation and frame rate are only relevant to + // converter types that understand animation. INLINE void set_animation_convert(AnimationConvert animation_convert); INLINE AnimationConvert get_animation_convert() const; @@ -93,7 +89,7 @@ public: INLINE void clear_output_frame_rate(); INLINE static double get_default_frame_rate(); - + INLINE void set_merge_externals(bool merge_externals); INLINE bool get_merge_externals() const; @@ -116,8 +112,7 @@ public: INLINE Filename convert_model_path(const Filename &orig_filename); - // Set this true to treat errors as warnings and generate output - // anyway. + // Set this true to treat errors as warnings and generate output anyway. bool _allow_errors; protected: @@ -151,5 +146,3 @@ protected: #include "somethingToEggConverter.I" #endif - - diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index 307196e375..1b8b43449a 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -1,16 +1,15 @@ -// Filename: cvsCopy.cxx -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsCopy.cxx + * @author drose + * @date 2000-10-31 + */ #include "cvsCopy.h" #include "cvsSourceDirectory.h" @@ -18,11 +17,9 @@ #include "pnotify.h" #include -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CVSCopy:: CVSCopy() { _model_dirname = "."; @@ -91,24 +88,19 @@ CVSCopy() { &CVSCopy::dispatch_string, NULL, &_cvs_binary); } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::import -// Access: Public -// Description: Checks for the given filename somewhere in the -// directory hierarchy, and chooses a place to import -// it. Copies the file by calling copy_file(). -// -// Extra_data may be NULL or a pointer to some -// user-defined structure; CVSCopy simply passes it -// unchanged to copy_file(). It presumably gives the -// class a hint as to how the file should be copied. -// Suggested_dir is the suggested directory in which to -// copy the file, if it does not already exist -// elsewhere. -// -// On success, returns the FilePath it was actually -// copied to. On failure, returns an invalid FilePath. -//////////////////////////////////////////////////////////////////// +/** + * Checks for the given filename somewhere in the directory hierarchy, and + * chooses a place to import it. Copies the file by calling copy_file(). + * + * Extra_data may be NULL or a pointer to some user-defined structure; CVSCopy + * simply passes it unchanged to copy_file(). It presumably gives the class a + * hint as to how the file should be copied. Suggested_dir is the suggested + * directory in which to copy the file, if it does not already exist + * elsewhere. + * + * On success, returns the FilePath it was actually copied to. On failure, + * returns an invalid FilePath. + */ CVSSourceTree::FilePath CVSCopy:: import(const Filename &source, void *extra_data, CVSSourceDirectory *suggested_dir) { @@ -156,14 +148,11 @@ import(const Filename &source, void *extra_data, return path; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::continue_after_error -// Access: Public -// Description: Prompts the user (unless -f was specified) if he -// wants to continue the copy operation after some error -// has occurred. Returns true to continue, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Prompts the user (unless -f was specified) if he wants to continue the copy + * operation after some error has occurred. Returns true to continue, false + * otherwise. + */ bool CVSCopy:: continue_after_error() { if (_force) { @@ -190,14 +179,11 @@ continue_after_error() { } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool CVSCopy:: handle_args(Args &args) { if (args.empty()) { @@ -213,16 +199,12 @@ handle_args(Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::post_command_line -// Access: Protected, Virtual -// Description: This is called after the command line has been -// completely processed, and it gives the program a -// chance to do some last-minute processing and -// validation of the options and arguments. It should -// return true if everything is fine, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * This is called after the command line has been completely processed, and it + * gives the program a chance to do some last-minute processing and validation + * of the options and arguments. It should return true if everything is fine, + * false if there is an error. + */ bool CVSCopy:: post_command_line() { if (!scan_hierarchy()) { @@ -259,26 +241,20 @@ post_command_line() { } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::verify_file -// Access: Protected, Virtual -// Description: Verifies that the file is identical and does not need -// to be recopied. Returns true if the files are -// identical, false if they differ. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the file is identical and does not need to be recopied. + * Returns true if the files are identical, false if they differ. + */ bool CVSCopy:: verify_file(const Filename &, const Filename &, CVSSourceDirectory *, void *) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::verify_binary_file -// Access: Protected -// Description: Verifies that the file is identical and does not need -// to be recopied. Returns true if the files are -// identical, false if they differ. -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the file is identical and does not need to be recopied. + * Returns true if the files are identical, false if they differ. + */ bool CVSCopy:: verify_binary_file(Filename source, Filename dest) { if (source == dest) { @@ -312,9 +288,8 @@ verify_binary_file(Filename source, Filename dest) { return false; } - // If we haven't reached the end of one of the files yet, that file - // is longer than the other one, and the files are therefore - // different. + // If we haven't reached the end of one of the files yet, that file is + // longer than the other one, and the files are therefore different. if (!s.eof() || !d.eof()) { return false; } @@ -323,16 +298,12 @@ verify_binary_file(Filename source, Filename dest) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::copy_binary_file -// Access: Protected -// Description: Copies a file without modifying it or scanning it in -// any way. This is particularly useful for copying -// textures. This is provided as a convenience function -// for derived programs because so many model file -// formats will also require copying textures or other -// black-box files. -//////////////////////////////////////////////////////////////////// +/** + * Copies a file without modifying it or scanning it in any way. This is + * particularly useful for copying textures. This is provided as a + * convenience function for derived programs because so many model file + * formats will also require copying textures or other black-box files. + */ bool CVSCopy:: copy_binary_file(Filename source, Filename dest) { if (source == dest) { @@ -374,13 +345,10 @@ copy_binary_file(Filename source, Filename dest) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::cvs_add -// Access: Protected -// Description: Invokes CVS to add the indicated filename to the -// repository, if the user so requested. Returns true -// if successful, false if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Invokes CVS to add the indicated filename to the repository, if the user so + * requested. Returns true if successful, false if there is an error. + */ bool CVSCopy:: cvs_add(const Filename &filename) { if (_no_cvs) { @@ -392,7 +360,7 @@ cvs_add(const Filename &filename) { return false; } - string command = _cvs_binary + " add -kb " + + string command = _cvs_binary + " add -kb " + protect_from_shell(filename.get_basename()); nout << command << "\n"; int result = system(command.c_str()); @@ -406,14 +374,11 @@ cvs_add(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::protect_from_shell -// Access: Protected, Static -// Description: Inserts escape characters into the indicated source -// string to protect it from the shell, so that it may -// be given on the command line. Returns the modified -// string. -//////////////////////////////////////////////////////////////////// +/** + * Inserts escape characters into the indicated source string to protect it + * from the shell, so that it may be given on the command line. Returns the + * modified string. + */ string CVSCopy:: protect_from_shell(const string &source) { string result; @@ -449,34 +414,28 @@ protect_from_shell(const string &source) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::filter_filename -// Access: Protected, Virtual -// Description: Given a source filename (including the basename only, -// without a dirname), return the appropriate -// corresponding filename within the source directory. -// This may be used by derived classes to, for instance, -// strip a version number from the filename. -//////////////////////////////////////////////////////////////////// +/** + * Given a source filename (including the basename only, without a dirname), + * return the appropriate corresponding filename within the source directory. + * This may be used by derived classes to, for instance, strip a version + * number from the filename. + */ string CVSCopy:: filter_filename(const string &source) { return source; } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::scan_hierarchy -// Access: Private -// Description: Starts the scan of the source hierarchy. This -// identifies all of the files in the source hierarchy -// we're to copy these into, so we can guess where -// referenced files should be placed. Returns true if -// everything is ok, false if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Starts the scan of the source hierarchy. This identifies all of the files + * in the source hierarchy we're to copy these into, so we can guess where + * referenced files should be placed. Returns true if everything is ok, false + * if there is an error. + */ bool CVSCopy:: scan_hierarchy() { if (!_got_root_dirname) { - // If we didn't get a root directory name, find the directory - // above this one that contains the file "Package.pp". + // If we didn't get a root directory name, find the directory above this + // one that contains the file "Package.pp". if (!scan_for_root(_model_dirname)) { return false; } @@ -488,14 +447,11 @@ scan_hierarchy() { return _tree.scan(_key_filename); } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::scan_for_root -// Access: Private -// Description: Searches for the root of the source directory by -// looking for the parent directory that contains -// "Package.pp". Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the root of the source directory by looking for the parent + * directory that contains "Package.pp". Returns true on success, false on + * failure. + */ bool CVSCopy:: scan_for_root(const string &dirname) { Filename sources = dirname + "/Sources.pp"; @@ -513,13 +469,10 @@ scan_for_root(const string &dirname) { return scan_for_root(dirname + "/.."); } -//////////////////////////////////////////////////////////////////// -// Function: CVSCopy::prompt -// Access: Private -// Description: Issues a prompt to the user and waits for a typed -// response. Returns the response (which will not be -// empty). -//////////////////////////////////////////////////////////////////// +/** + * Issues a prompt to the user and waits for a typed response. Returns the + * response (which will not be empty). + */ string CVSCopy:: prompt(const string &message) { nout << flush; diff --git a/pandatool/src/cvscopy/cvsCopy.h b/pandatool/src/cvscopy/cvsCopy.h index 3b074b9495..e8957eaa59 100644 --- a/pandatool/src/cvscopy/cvsCopy.h +++ b/pandatool/src/cvscopy/cvsCopy.h @@ -1,16 +1,15 @@ -// Filename: cvsCopy.h -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsCopy.h + * @author drose + * @date 2000-10-31 + */ #ifndef CVSCOPY_H #define CVSCOPY_H @@ -23,13 +22,11 @@ #include "filename.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : CVSCopy -// Description : This is the base class for a family of programs that -// copy files, typically model files like .flt files and -// their associated textures, into a CVS-controlled -// source tree. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a family of programs that copy files, typically + * model files like .flt files and their associated textures, into a CVS- + * controlled source tree. + */ class CVSCopy : public ProgramBase { public: CVSCopy(); diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.cxx b/pandatool/src/cvscopy/cvsSourceDirectory.cxx index 5846f5b061..02e6a9ced1 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.cxx +++ b/pandatool/src/cvscopy/cvsSourceDirectory.cxx @@ -1,16 +1,15 @@ -// Filename: cvsSourceDirectory.cxx -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsSourceDirectory.cxx + * @author drose + * @date 2000-10-31 + */ #include "cvsSourceDirectory.h" #include "cvsSourceTree.h" @@ -18,11 +17,9 @@ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CVSSourceDirectory:: CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, const string &dirname) : @@ -37,11 +34,9 @@ CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CVSSourceDirectory:: ~CVSSourceDirectory() { Children::iterator ci; @@ -50,22 +45,17 @@ CVSSourceDirectory:: } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_dirname -// Access: Public -// Description: Returns the local name of this particular directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local name of this particular directory. + */ string CVSSourceDirectory:: get_dirname() const { return _dirname; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_fullpath -// Access: Public -// Description: Returns the full pathname to this particular -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full pathname to this particular directory. + */ Filename CVSSourceDirectory:: get_fullpath() const { if (_parent == (CVSSourceDirectory *)NULL) { @@ -74,12 +64,10 @@ get_fullpath() const { return Filename(_parent->get_fullpath(), _dirname); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_path -// Access: Public -// Description: Returns the relative pathname to this particular -// directory, as seen from the root of the tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative pathname to this particular directory, as seen from + * the root of the tree. + */ Filename CVSSourceDirectory:: get_path() const { if (_parent == (CVSSourceDirectory *)NULL) { @@ -88,12 +76,10 @@ get_path() const { return Filename(_parent->get_path(), _dirname); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_rel_to -// Access: Public -// Description: Returns the relative path to the other directory from -// this one. This does not include a trailing slash. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative path to the other directory from this one. This does + * not include a trailing slash. + */ Filename CVSSourceDirectory:: get_rel_to(const CVSSourceDirectory *other) const { const CVSSourceDirectory *a = this; @@ -130,35 +116,27 @@ get_rel_to(const CVSSourceDirectory *other) const { return result.substr(0, result.length() - 1); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_num_children -// Access: Public -// Description: Returns the number of subdirectories below this -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subdirectories below this directory. + */ int CVSSourceDirectory:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::get_child -// Access: Public -// Description: Returns the nth subdirectory below this directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth subdirectory below this directory. + */ CVSSourceDirectory *CVSSourceDirectory:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::find_relpath -// Access: Public -// Description: Returns the source directory that corresponds to the -// given relative path from this directory, or NULL if -// there is no match. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source directory that corresponds to the given relative path + * from this directory, or NULL if there is no match. + */ CVSSourceDirectory *CVSSourceDirectory:: find_relpath(const string &relpath) { if (relpath.empty()) { @@ -195,13 +173,10 @@ find_relpath(const string &relpath) { return (CVSSourceDirectory *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::find_dirname -// Access: Public -// Description: Returns the source directory that corresponds to the -// given local directory name, or NULL if there is no -// match. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source directory that corresponds to the given local directory + * name, or NULL if there is no match. + */ CVSSourceDirectory *CVSSourceDirectory:: find_dirname(const string &dirname) { if (cmp_nocase(dirname, _dirname) == 0) { @@ -219,16 +194,12 @@ find_dirname(const string &dirname) { return (CVSSourceDirectory *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceDirectory::scan -// Access: Public -// Description: Recursively scans the contents of the source -// directory. Fullpath is the full path name to the -// directory; key_filename is the name of a file that -// must exist in each subdirectory for it to be -// considered part of the hierarchy. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Recursively scans the contents of the source directory. Fullpath is the + * full path name to the directory; key_filename is the name of a file that + * must exist in each subdirectory for it to be considered part of the + * hierarchy. Returns true on success, false on failure. + */ bool CVSSourceDirectory:: scan(const Filename &directory, const string &key_filename) { vector_string contents; diff --git a/pandatool/src/cvscopy/cvsSourceDirectory.h b/pandatool/src/cvscopy/cvsSourceDirectory.h index abaab78daf..e8e379c8f0 100644 --- a/pandatool/src/cvscopy/cvsSourceDirectory.h +++ b/pandatool/src/cvscopy/cvsSourceDirectory.h @@ -1,16 +1,15 @@ -// Filename: cvsSourceDirectory.h -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsSourceDirectory.h + * @author drose + * @date 2000-10-31 + */ #ifndef CVSSOURCEDIRECTORY_H #define CVSSOURCEDIRECTORY_H @@ -22,21 +21,17 @@ class CVSSourceTree; -//////////////////////////////////////////////////////////////////// -// Class : CVSSourceDirectory -// Description : This represents one particular directory in the -// hierarchy of source directory files. We must scan -// the source directory to identify where the related -// files have previously been copied. -// -// The tree is maintained in a case-insensitive manner, -// even on a non-Windows system, since you might want to -// eventually check out the CVS tree onto a Windows -// system--and if you do, you'll be sad if there are -// case conflicts within the tree. So we make an effort -// to ensure this doesn't happen by treating two files -// with a different case as the same file. -//////////////////////////////////////////////////////////////////// +/** + * This represents one particular directory in the hierarchy of source + * directory files. We must scan the source directory to identify where the + * related files have previously been copied. + * + * The tree is maintained in a case-insensitive manner, even on a non-Windows + * system, since you might want to eventually check out the CVS tree onto a + * Windows system--and if you do, you'll be sad if there are case conflicts + * within the tree. So we make an effort to ensure this doesn't happen by + * treating two files with a different case as the same file. + */ class CVSSourceDirectory { public: CVSSourceDirectory(CVSSourceTree *tree, CVSSourceDirectory *parent, diff --git a/pandatool/src/cvscopy/cvsSourceTree.cxx b/pandatool/src/cvscopy/cvsSourceTree.cxx index fc7c631683..5fea69e430 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.cxx +++ b/pandatool/src/cvscopy/cvsSourceTree.cxx @@ -1,16 +1,15 @@ -// Filename: cvsSourceTree.cxx -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsSourceTree.cxx + * @author drose + * @date 2000-10-31 + */ #include "cvsSourceTree.h" #include "cvsSourceDirectory.h" @@ -32,22 +31,18 @@ bool CVSSourceTree::_got_start_fullpath = false; Filename CVSSourceTree::_start_fullpath; -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CVSSourceTree:: CVSSourceTree() { _root = (CVSSourceDirectory *)NULL; _got_root_fullpath = false; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CVSSourceTree:: ~CVSSourceTree() { if (_root != (CVSSourceDirectory *)NULL) { @@ -55,27 +50,21 @@ CVSSourceTree:: } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::set_root -// Access: Public -// Description: Sets the root of the source directory. This must be -// called before scan(), and should not be called more -// than once. -//////////////////////////////////////////////////////////////////// +/** + * Sets the root of the source directory. This must be called before scan(), + * and should not be called more than once. + */ void CVSSourceTree:: set_root(const Filename &root_path) { nassertv(_path.empty()); _path = root_path; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::scan -// Access: Public -// Description: Scans the complete source directory starting at the -// indicated pathname. It is an error to call this more -// than once. Returns true on success, false if there -// is an error. -//////////////////////////////////////////////////////////////////// +/** + * Scans the complete source directory starting at the indicated pathname. It + * is an error to call this more than once. Returns true on success, false if + * there is an error. + */ bool CVSSourceTree:: scan(const Filename &key_filename) { nassertr(_root == (CVSSourceDirectory *)NULL, false); @@ -84,23 +73,18 @@ scan(const Filename &key_filename) { return _root->scan(_path, key_filename); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::get_root -// Access: Public -// Description: Returns the root directory of the hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root directory of the hierarchy. + */ CVSSourceDirectory *CVSSourceTree:: get_root() const { return _root; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::find_directory -// Access: Public -// Description: Returns the source directory that corresponds to the -// given path, or NULL if there is no such directory in -// the source tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source directory that corresponds to the given path, or NULL if + * there is no such directory in the source tree. + */ CVSSourceDirectory *CVSSourceTree:: find_directory(const Filename &path) { string root_fullpath = get_root_fullpath(); @@ -120,14 +104,11 @@ find_directory(const Filename &path) { return _root->find_relpath(relpath); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::find_relpath -// Access: Public -// Description: Returns the source directory that corresponds to the -// given relative path from the root, or NULL if there -// is no match. The relative path may or may not -// include the name of the root directory itself. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source directory that corresponds to the given relative path + * from the root, or NULL if there is no match. The relative path may or may + * not include the name of the root directory itself. + */ CVSSourceDirectory *CVSSourceTree:: find_relpath(const string &relpath) { CVSSourceDirectory *result = _root->find_relpath(relpath); @@ -135,8 +116,8 @@ find_relpath(const string &relpath) { return result; } - // Check for the root dirname at the front of the path, and remove - // it if it's there. + // Check for the root dirname at the front of the path, and remove it if + // it's there. size_t slash = relpath.find('/'); Filename first = relpath.substr(0, slash); Filename rest; @@ -151,28 +132,21 @@ find_relpath(const string &relpath) { return (CVSSourceDirectory *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::find_dirname -// Access: Public -// Description: Returns the source directory that corresponds to the -// given local directory name, or NULL if there -// is no match. -//////////////////////////////////////////////////////////////////// +/** + * Returns the source directory that corresponds to the given local directory + * name, or NULL if there is no match. + */ CVSSourceDirectory *CVSSourceTree:: find_dirname(const string &dirname) { return _root->find_dirname(dirname); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::choose_directory -// Access: Public -// Description: Determines where an externally referenced model file -// of the indicated name should go. It does this by -// looking for an existing model file of the same name; -// if a matching model is not found, or if multiple -// matching files are found, prompts the user for the -// directory, or uses suggested_dir. -//////////////////////////////////////////////////////////////////// +/** + * Determines where an externally referenced model file of the indicated name + * should go. It does this by looking for an existing model file of the same + * name; if a matching model is not found, or if multiple matching files are + * found, prompts the user for the directory, or uses suggested_dir. + */ CVSSourceTree::FilePath CVSSourceTree:: choose_directory(const string &basename, CVSSourceDirectory *suggested_dir, bool force, bool interactive) { @@ -193,12 +167,9 @@ choose_directory(const string &basename, CVSSourceDirectory *suggested_dir, force, interactive); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::get_root_fullpath -// Access: Public -// Description: Returns the full path from the root to the top of -// the source hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path from the root to the top of the source hierarchy. + */ Filename CVSSourceTree:: get_root_fullpath() { nassertr(!_path.empty(), Filename()); @@ -209,43 +180,34 @@ get_root_fullpath() { return _root_fullpath; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::get_root_dirname -// Access: Public -// Description: Returns the local directory name of the root of the -// tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local directory name of the root of the tree. + */ Filename CVSSourceTree:: get_root_dirname() const { nassertr(_root != (CVSSourceDirectory *)NULL, Filename()); return _root->get_dirname(); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::add_file -// Access: Public -// Description: Adds a new file to the set of known files. This is -// normally called from CVSSourceDirectory::scan() and -// should not be called directly by the user. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new file to the set of known files. This is normally called from + * CVSSourceDirectory::scan() and should not be called directly by the user. + */ void CVSSourceTree:: add_file(const string &basename, CVSSourceDirectory *dir) { FilePath file_path(dir, basename); _basenames[downcase(basename)].push_back(file_path); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::temp_chdir -// Access: Public, Static -// Description: Temporarily changes the current directory to the -// named path. Returns true on success, false on -// failure. Call restore_cwd() to restore to the -// original directory later. -//////////////////////////////////////////////////////////////////// +/** + * Temporarily changes the current directory to the named path. Returns true + * on success, false on failure. Call restore_cwd() to restore to the + * original directory later. + */ bool CVSSourceTree:: temp_chdir(const Filename &path) { - // We have to call this first to guarantee that we have already - // determined our starting directory. + // We have to call this first to guarantee that we have already determined + // our starting directory. get_start_fullpath(); string os_path = path.to_os_specific(); @@ -255,12 +217,9 @@ temp_chdir(const Filename &path) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::restore_cwd -// Access: Public, Static -// Description: Restores the current directory after changing it from -// temp_chdir(). -//////////////////////////////////////////////////////////////////// +/** + * Restores the current directory after changing it from temp_chdir(). + */ void CVSSourceTree:: restore_cwd() { Filename start_fullpath = get_start_fullpath(); @@ -275,12 +234,10 @@ restore_cwd() { } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::prompt_user -// Access: Private -// Description: Prompts the user, if necessary, to choose a directory -// to import the given file into. -//////////////////////////////////////////////////////////////////// +/** + * Prompts the user, if necessary, to choose a directory to import the given + * file into. + */ CVSSourceTree::FilePath CVSSourceTree:: prompt_user(const string &basename, CVSSourceDirectory *suggested_dir, const CVSSourceTree::FilePaths &paths, @@ -306,14 +263,14 @@ prompt_user(const string &basename, CVSSourceDirectory *suggested_dir, } } - // The file does not already exist, or the user declined to replace - // an existing file. + // The file does not already exist, or the user declined to replace an + // existing file. if (force && !interactive) { return FilePath(suggested_dir, basename); } - // Is the file already in the suggested directory? If not, prompt - // the user to put it there. + // Is the file already in the suggested directory? If not, prompt the user + // to put it there. bool found_dir = false; FilePaths::const_iterator pi; for (pi = paths.begin(); pi != paths.end(); ++pi) { @@ -334,12 +291,9 @@ prompt_user(const string &basename, CVSSourceDirectory *suggested_dir, return ask_any(basename, paths); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::ask_existing -// Access: Private -// Description: Asks the user if he wants to replace an existing -// file. -//////////////////////////////////////////////////////////////////// +/** + * Asks the user if he wants to replace an existing file. + */ CVSSourceTree::FilePath CVSSourceTree:: ask_existing(const string &basename, const CVSSourceTree::FilePath &path) { while (true) { @@ -359,12 +313,9 @@ ask_existing(const string &basename, const CVSSourceTree::FilePath &path) { } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::ask_existing -// Access: Private -// Description: Asks the user which of several existing files he -// wants to replace. -//////////////////////////////////////////////////////////////////// +/** + * Asks the user which of several existing files he wants to replace. + */ CVSSourceTree::FilePath CVSSourceTree:: ask_existing(const string &basename, const CVSSourceTree::FilePaths &paths, CVSSourceDirectory *suggested_dir) { @@ -384,8 +335,8 @@ ask_existing(const string &basename, const CVSSourceTree::FilePaths &paths, int suggested_option = -1; if (!any_suggested) { - // If it wasn't already in the suggested directory, offer to put - // it there. + // If it wasn't already in the suggested directory, offer to put it + // there. suggested_option = next_option; next_option++; nout << "\n" << suggested_option @@ -418,11 +369,9 @@ ask_existing(const string &basename, const CVSSourceTree::FilePaths &paths, } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::ask_new -// Access: Private -// Description: Asks the user if he wants to create a new file. -//////////////////////////////////////////////////////////////////// +/** + * Asks the user if he wants to create a new file. + */ CVSSourceTree::FilePath CVSSourceTree:: ask_new(const string &basename, CVSSourceDirectory *dir) { while (true) { @@ -442,12 +391,10 @@ ask_new(const string &basename, CVSSourceDirectory *dir) { } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::ask_any -// Access: Private -// Description: Asks the user to type in the name of the directory in -// which to store the file. -//////////////////////////////////////////////////////////////////// +/** + * Asks the user to type in the name of the directory in which to store the + * file. + */ CVSSourceTree::FilePath CVSSourceTree:: ask_any(const string &basename, const CVSSourceTree::FilePaths &paths) { @@ -456,9 +403,9 @@ ask_any(const string &basename, prompt("Enter the name of the directory to copy " + basename + " to: "); nassertr(!result.empty(), FilePath()); - // The user might enter a fully-qualified path to the directory, - // or a relative path from the root (with or without the root's - // dirname), or the dirname of the particular directory. + // The user might enter a fully-qualified path to the directory, or a + // relative path from the root (with or without the root's dirname), or + // the dirname of the particular directory. CVSSourceDirectory *dir = find_directory(result); if (dir == (CVSSourceDirectory *)NULL) { dir = find_relpath(result); @@ -468,8 +415,8 @@ ask_any(const string &basename, } if (dir != (CVSSourceDirectory *)NULL) { - // If the file is already in this directory, we must preserve - // its existing case. + // If the file is already in this directory, we must preserve its + // existing case. FilePaths::const_iterator pi; for (pi = paths.begin(); pi != paths.end(); ++pi) { if ((*pi)._dir == dir) { @@ -477,8 +424,7 @@ ask_any(const string &basename, } } - // Otherwise, since we're creating a new file, keep the original - // case. + // Otherwise, since we're creating a new file, keep the original case. return FilePath(dir, basename); } @@ -486,13 +432,10 @@ ask_any(const string &basename, } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::prompt -// Access: Private -// Description: Issues a prompt to the user and waits for a typed -// response. Returns the response (which will not be -// empty). -//////////////////////////////////////////////////////////////////// +/** + * Issues a prompt to the user and waits for a typed response. Returns the + * response (which will not be empty). + */ string CVSSourceTree:: prompt(const string &message) { nout << flush; @@ -518,12 +461,9 @@ prompt(const string &message) { } } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::get_actual_fullpath -// Access: Private, Static -// Description: Determines the actual full path from the root to the -// named directory. -//////////////////////////////////////////////////////////////////// +/** + * Determines the actual full path from the root to the named directory. + */ Filename CVSSourceTree:: get_actual_fullpath(const Filename &path) { Filename canon = path; @@ -532,12 +472,10 @@ get_actual_fullpath(const Filename &path) { } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::get_start_fullpath -// Access: Private, Static -// Description: Returns the full path from the root to the directory -// in which the user started the program. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path from the root to the directory in which the user + * started the program. + */ Filename CVSSourceTree:: get_start_fullpath() { if (!_got_start_fullpath) { @@ -548,23 +486,19 @@ get_start_fullpath() { } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::Constructor -// Access: Public -// Description: Creates an invalid FilePath specification. -//////////////////////////////////////////////////////////////////// +/** + * Creates an invalid FilePath specification. + */ CVSSourceTree::FilePath:: FilePath() : _dir(NULL) { } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::Constructor -// Access: Public -// Description: Creates a valid FilePath specification with the -// indicated directory and basename. -//////////////////////////////////////////////////////////////////// +/** + * Creates a valid FilePath specification with the indicated directory and + * basename. + */ CVSSourceTree::FilePath:: FilePath(CVSSourceDirectory *dir, const string &basename) : _dir(dir), @@ -572,49 +506,39 @@ FilePath(CVSSourceDirectory *dir, const string &basename) : { } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::is_valid -// Access: Public -// Description: Returns true if this FilePath represents a valid -// file, or false if it represents an error return. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this FilePath represents a valid file, or false if it + * represents an error return. + */ bool CVSSourceTree::FilePath:: is_valid() const { return (_dir != (CVSSourceDirectory *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::get_path -// Access: Public -// Description: Returns the relative path to this file from the root -// of the source tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative path to this file from the root of the source tree. + */ Filename CVSSourceTree::FilePath:: get_path() const { nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); return Filename(_dir->get_path(), _basename); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::get_fullpath -// Access: Public -// Description: Returns the full path to this file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the full path to this file. + */ Filename CVSSourceTree::FilePath:: get_fullpath() const { nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); return Filename(_dir->get_fullpath(), _basename); } -//////////////////////////////////////////////////////////////////// -// Function: CVSSourceTree::FilePath::get_rel_from -// Access: Public -// Description: Returns the relative path to this file as seen from -// the indicated source directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the relative path to this file as seen from the indicated source + * directory. + */ Filename CVSSourceTree::FilePath:: get_rel_from(const CVSSourceDirectory *other) const { nassertr(_dir != (CVSSourceDirectory *)NULL, Filename()); return Filename(other->get_rel_to(_dir), _basename); } - diff --git a/pandatool/src/cvscopy/cvsSourceTree.h b/pandatool/src/cvscopy/cvsSourceTree.h index d57113d4af..b512ce6db0 100644 --- a/pandatool/src/cvscopy/cvsSourceTree.h +++ b/pandatool/src/cvscopy/cvsSourceTree.h @@ -1,16 +1,15 @@ -// Filename: cvsSourceTree.h -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cvsSourceTree.h + * @author drose + * @date 2000-10-31 + */ #ifndef CVSSOURCETREE_H #define CVSSOURCETREE_H @@ -23,19 +22,15 @@ class CVSSourceDirectory; -//////////////////////////////////////////////////////////////////// -// Class : CVSSourceTree -// Description : This represents the root of the tree of source -// directory files. -// -// The tree is maintained in a case-insensitive manner, -// even on a non-Windows system, since you might want to -// eventually check out the CVS tree onto a Windows -// system--and if you do, you'll be sad if there are -// case conflicts within the tree. So we make an effort -// to ensure this doesn't happen by treating two files -// with a different case as the same file. -//////////////////////////////////////////////////////////////////// +/** + * This represents the root of the tree of source directory files. + * + * The tree is maintained in a case-insensitive manner, even on a non-Windows + * system, since you might want to eventually check out the CVS tree onto a + * Windows system--and if you do, you'll be sad if there are case conflicts + * within the tree. So we make an effort to ensure this doesn't happen by + * treating two files with a different case as the same file. + */ class CVSSourceTree { public: CVSSourceTree(); @@ -49,12 +44,11 @@ public: CVSSourceDirectory *find_relpath(const string &relpath); CVSSourceDirectory *find_dirname(const string &dirname); - // This nested class represents the selection of a particular - // directory in which to place a given file, given its basename. - // The basename of the file is returned as part of the answer, - // because it might have changed in case from the original basename - // (in order to match the case of an existing file in the selected - // directory). + // This nested class represents the selection of a particular directory in + // which to place a given file, given its basename. The basename of the + // file is returned as part of the answer, because it might have changed in + // case from the original basename (in order to match the case of an + // existing file in the selected directory). class FilePath { public: FilePath(); diff --git a/pandatool/src/cvscopy/testCopy.cxx b/pandatool/src/cvscopy/testCopy.cxx index 23b0ba4cfa..8f9fbce3a4 100644 --- a/pandatool/src/cvscopy/testCopy.cxx +++ b/pandatool/src/cvscopy/testCopy.cxx @@ -1,26 +1,23 @@ -// Filename: testCopy.cxx -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file testCopy.cxx + * @author drose + * @date 2000-10-31 + */ #include "testCopy.h" #include "cvsSourceDirectory.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: TestCopy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TestCopy:: TestCopy() { set_program_brief("copy files into a CVS source hierarchy"); @@ -35,11 +32,9 @@ TestCopy() { "This is primarily useful as a test program for libcvscopy."); } -//////////////////////////////////////////////////////////////////// -// Function: TestCopy::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TestCopy:: run() { SourceFiles::iterator fi; @@ -51,14 +46,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: TestCopy::copy_file -// Access: Protected, Virtual -// Description: Called by import() if the timestamps indicate that a -// file needs to be copied. This does the actual copy -// of a file from source to destination. If new_file is -// true, then dest does not already exist. -//////////////////////////////////////////////////////////////////// +/** + * Called by import() if the timestamps indicate that a file needs to be + * copied. This does the actual copy of a file from source to destination. + * If new_file is true, then dest does not already exist. + */ bool TestCopy:: copy_file(const Filename &source, const Filename &dest, CVSSourceDirectory *, void *, bool) { diff --git a/pandatool/src/cvscopy/testCopy.h b/pandatool/src/cvscopy/testCopy.h index 6fd8c6ad20..3e1b770fee 100644 --- a/pandatool/src/cvscopy/testCopy.h +++ b/pandatool/src/cvscopy/testCopy.h @@ -1,16 +1,15 @@ -// Filename: testCopy.h -// Created by: drose (31Oct00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file testCopy.h + * @author drose + * @date 2000-10-31 + */ #ifndef TESTCOPY_H #define TESTCOPY_H @@ -19,11 +18,10 @@ #include "cvsCopy.h" -//////////////////////////////////////////////////////////////////// -// Class : TestCopy -// Description : A program to copy ordinary files into the cvs tree. -// Mainly to test CVSCopy. -//////////////////////////////////////////////////////////////////// +/** + * A program to copy ordinary files into the cvs tree. Mainly to test + * CVSCopy. + */ class TestCopy : public CVSCopy { public: TestCopy(); diff --git a/pandatool/src/daeegg/config_daeegg.cxx b/pandatool/src/daeegg/config_daeegg.cxx index 24015d8821..2b36315520 100644 --- a/pandatool/src/daeegg/config_daeegg.cxx +++ b/pandatool/src/daeegg/config_daeegg.cxx @@ -1,16 +1,15 @@ -// Filename: config_daeegg.cxx -// Created by: pro-rsoft (30Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_daeegg.cxx + * @author rdb + * @date 2008-10-30 + */ #include "config_daeegg.h" #include "daeCharacter.h" @@ -25,14 +24,12 @@ ConfigureFn(config_daeegg) { init_libdaeegg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libdaeegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdaeegg() { static bool initialized = false; @@ -40,8 +37,7 @@ init_libdaeegg() { return; } initialized = true; - + DaeCharacter::init_type(); DaeMaterials::init_type(); } - diff --git a/pandatool/src/daeegg/config_daeegg.h b/pandatool/src/daeegg/config_daeegg.h index 0f13f269c6..8f60ed730f 100644 --- a/pandatool/src/daeegg/config_daeegg.h +++ b/pandatool/src/daeegg/config_daeegg.h @@ -1,16 +1,15 @@ -// Filename: config_daeegg.h -// Created by: pro-rsoft (30Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_daeegg.h + * @author rdb + * @date 2008-10-30 + */ #ifndef CONFIG_DAEEGG_H #define CONFIG_DAEEGG_H diff --git a/pandatool/src/daeegg/daeCharacter.cxx b/pandatool/src/daeegg/daeCharacter.cxx index aea226b9b6..0d6e0d1e39 100644 --- a/pandatool/src/daeegg/daeCharacter.cxx +++ b/pandatool/src/daeegg/daeCharacter.cxx @@ -1,16 +1,15 @@ -// Filename: daeCharacter.cxx -// Created by: pro-rsoft (24Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeCharacter.cxx + * @author rdb + * @date 2008-11-24 + */ #include "daeCharacter.h" #include "config_daeegg.h" @@ -35,11 +34,9 @@ TypeHandle DaeCharacter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DaeCharacter:: DaeCharacter(EggGroup *node_group, const FCDControllerInstance *instance) : _node_group(node_group), @@ -63,15 +60,12 @@ DaeCharacter(EggGroup *node_group, const FCDControllerInstance *instance) : } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::bind_joints -// Access: Public -// Description: Binds the joints to the character. This means -// changing them to the bind pose. It is necessary -// to call this before process_skin_geometry. -// -// Returns the root group. -//////////////////////////////////////////////////////////////////// +/** + * Binds the joints to the character. This means changing them to the bind + * pose. It is necessary to call this before process_skin_geometry. + * + * Returns the root group. + */ void DaeCharacter:: bind_joints(JointMap &joint_map) { _joints.clear(); @@ -94,8 +88,8 @@ bind_joints(JointMap &joint_map) { if (joint._character != (DaeCharacter *)NULL) { // In some cases, though, multiple controllers share the same joints. - // We can't support this without duplicating the joint structure, - // so we check if the bind poses are the same. + // We can't support this without duplicating the joint structure, so + // we check if the bind poses are the same. if (!joint._bind_pose.almost_equal(bind_pose, 0.0001)) { // Ugh. What else could we do? daeegg_cat.error() @@ -119,15 +113,12 @@ bind_joints(JointMap &joint_map) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::adjust_joints -// Access: Public -// Description: Traverses through the character hierarchy in order -// to bind the mesh to the character. This involves -// reorienting the joints to match the bind pose. -// -// It is important that this is called only once. -//////////////////////////////////////////////////////////////////// +/** + * Traverses through the character hierarchy in order to bind the mesh to the + * character. This involves reorienting the joints to match the bind pose. + * + * It is important that this is called only once. + */ void DaeCharacter:: adjust_joints(FCDSceneNode *node, const JointMap &joint_map, const LMatrix4d &transform) { @@ -141,15 +132,15 @@ adjust_joints(FCDSceneNode *node, const JointMap &joint_map, if (ji != joint_map.end()) { const Joint &joint = ji->second; - // Panda needs the joints to be in bind pose. Not fun! We copy the joint - // transform to the default pose, though, so that Panda will restore the - // joint transformation after binding. + // Panda needs the joints to be in bind pose. Not fun! We copy the + // joint transform to the default pose, though, so that Panda will + // restore the joint transformation after binding. if (joint._character == this) { LMatrix4d bind_pose = joint._bind_pose * _bind_shape_mat * invert(transform); - //LMatrix4d bind_pose = joint._bind_pose * _bind_shape_mat * - // joint._group->get_parent()->get_node_frame_inv(); + // LMatrix4d bind_pose = joint._bind_pose * _bind_shape_mat * + // joint._group->get_parent()->get_node_frame_inv(); this_transform = bind_pose * this_transform; joint._group->set_default_pose(*joint._group); @@ -165,22 +156,20 @@ adjust_joints(FCDSceneNode *node, const JointMap &joint_map, } } } else { - //this_transform = DAEToEggConverter::convert_matrix(node->ToMatrix()); + // this_transform = DAEToEggConverter::convert_matrix(node->ToMatrix()); } // Loop through the children joints for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) { - //if (node->GetChild(ch)->IsJoint()) { + // if (node->GetChild(ch)->IsJoint()) { adjust_joints(node->GetChild(ch), joint_map, this_transform); - //} + // } } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::influence_vertex -// Access: Public -// Description: Adds the influences for the given vertex. -//////////////////////////////////////////////////////////////////// +/** + * Adds the influences for the given vertex. + */ void DaeCharacter:: influence_vertex(int index, EggVertex *vertex) { const FCDSkinControllerVertex *influence = _skin_controller->GetVertexInfluence(index); @@ -200,12 +189,9 @@ influence_vertex(int index, EggVertex *vertex) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::collect_keys -// Access: Public -// Description: Collects all animation keys of animations applied -// to this character. -//////////////////////////////////////////////////////////////////// +/** + * Collects all animation keys of animations applied to this character. + */ void DaeCharacter:: collect_keys(pset &keys) { #if FCOLLADA_VERSION < 0x00030005 @@ -220,12 +206,9 @@ collect_keys(pset &keys) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::r_collect_keys -// Access: Public -// Description: Collects all animation keys found for the given -// node tree. -//////////////////////////////////////////////////////////////////// +/** + * Collects all animation keys found for the given node tree. + */ void DaeCharacter:: r_collect_keys(FCDSceneNode* node, pset &keys) { FCDAnimatedList animateds; @@ -255,11 +238,9 @@ r_collect_keys(FCDSceneNode* node, pset &keys) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeCharacter::build_table -// Access: Public -// Description: Processes a joint node and its transforms. -//////////////////////////////////////////////////////////////////// +/** + * Processes a joint node and its transforms. + */ void DaeCharacter:: build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { nassertv(node != NULL); @@ -325,8 +306,8 @@ build_table(EggTable *parent, FCDSceneNode* node, const pset &keys) { // Loop through the children joints for (size_t ch = 0; ch < node->GetChildrenCount(); ++ch) { - //if (node->GetChild(ch)->IsJoint()) { + // if (node->GetChild(ch)->IsJoint()) { build_table(table, node->GetChild(ch), keys); - //} + // } } } diff --git a/pandatool/src/daeegg/daeCharacter.h b/pandatool/src/daeegg/daeCharacter.h index c1f555394f..78ff504e2e 100644 --- a/pandatool/src/daeegg/daeCharacter.h +++ b/pandatool/src/daeegg/daeCharacter.h @@ -1,16 +1,15 @@ -// Filename: daeCharacter.h -// Created by: pro-rsoft (24Nov08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeCharacter.h + * @author rdb + * @date 2008-11-24 + */ #ifndef DAECHARACTER_H #define DAECHARACTER_H @@ -30,10 +29,9 @@ class DAEToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : DaeCharacter -// Description : Class representing an animated character. -//////////////////////////////////////////////////////////////////// +/** + * Class representing an animated character. + */ class DaeCharacter : public TypedReferenceCount { public: DaeCharacter(EggGroup *node_group, const FCDControllerInstance* controller_instance); diff --git a/pandatool/src/daeegg/daeMaterials.cxx b/pandatool/src/daeegg/daeMaterials.cxx index 0074e8caad..e345c4b6bd 100644 --- a/pandatool/src/daeegg/daeMaterials.cxx +++ b/pandatool/src/daeegg/daeMaterials.cxx @@ -1,16 +1,15 @@ -// Filename: daeMaterials.cxx -// Created by: pro-rsoft (03Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeMaterials.cxx + * @author rdb + * @date 2008-10-03 + */ #include "daeMaterials.h" #include "config_daeegg.h" @@ -28,15 +27,13 @@ TypeHandle DaeMaterials::_type_handle; -// luminance function, based on the ISO/CIE color standards -// see ITU-R Recommendation BT.709-4 +// luminance function, based on the ISOCIE color standards see ITU-R +// Recommendation BT.709-4 #define luminance(c) ((c[0] * 0.212671 + c[1] * 0.715160 + c[2] * 0.072169)) -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DaeMaterials:: DaeMaterials(const FCDGeometryInstance* geometry_instance) { for (size_t mi = 0; mi < geometry_instance->GetMaterialInstanceCount(); ++mi) { @@ -44,12 +41,9 @@ DaeMaterials(const FCDGeometryInstance* geometry_instance) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::add_material_instance -// Access: Public -// Description: Adds a material instance. Normally automatically -// done by constructor. -//////////////////////////////////////////////////////////////////// +/** + * Adds a material instance. Normally automatically done by constructor. + */ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { nassertv(instance != NULL); const string semantic (FROM_FSTRING(instance->GetSemantic())); @@ -92,10 +86,10 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { 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 = TO_COLOR(effect_common->GetDiffuseColor()); - //diffuse.set_w(diffuse.get_w() * (1.0f - effect_common->GetOpacity())); - //egg_material->set_diff(diffuse); + // We already process transparency using blend modes LVecBase4 diffuse = + // TO_COLOR(effect_common->GetDiffuseColor()); + // diffuse.set_w(diffuse.get_w() * (1.0f - + // effect_common->GetOpacity())); egg_material->set_diff(diffuse); egg_material->set_diff(TO_COLOR(effect_common->GetDiffuseColor())); egg_material->set_emit(TO_COLOR(effect_common->GetEmissionColor()) * effect_common->GetEmissionFactor()); egg_material->set_shininess(effect_common->GetShininess()); @@ -122,12 +116,10 @@ void DaeMaterials::add_material_instance(const FCDMaterialInstance* instance) { _materials[semantic]->_egg_material = egg_material; } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::process_texture_bucket -// Access: Private -// Description: Processes the given texture bucket and gives -// the textures in it the given envtype and format. -//////////////////////////////////////////////////////////////////// +/** + * Processes the given texture bucket and gives the textures in it the given + * envtype and format. + */ void DaeMaterials:: process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype, EggTexture::Format format) { for (size_t tx = 0; tx < effect_common->GetTextureCount(bucket); ++tx) { @@ -136,7 +128,7 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co daeegg_cat.warning() << "Texture references a nonexisting image!" << endl; } else { const FCDEffectParameterSampler* sampler = effect_common->GetTexture(bucket, tx)->GetSampler(); - // FCollada only supplies absolute paths. We need to grab the document + // FCollada only supplies absolute paths. We need to grab the document // location ourselves and make the image path absolute. Filename texpath; if (image->GetDocument()) { @@ -189,13 +181,10 @@ process_texture_bucket(const string semantic, const FCDEffectStandard* effect_co } } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::process_extra -// Access: Private -// Description: Processes the extra data in the given tag. -// If the given element is NULL, it just silently -// returns. -//////////////////////////////////////////////////////////////////// +/** + * Processes the extra data in the given tag. If the given element is + * NULL, it just silently returns. + */ void DaeMaterials:: process_extra(const string semantic, const FCDExtra* extra) { if (extra == NULL) return; @@ -216,11 +205,9 @@ process_extra(const string semantic, const FCDExtra* extra) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::apply_to -// Access: Public -// Description: Applies the stuff to the given EggPrimitive. -//////////////////////////////////////////////////////////////////// +/** + * Applies the stuff to the given EggPrimitive. + */ void DaeMaterials:: apply_to_primitive(const string semantic, const PT(EggPrimitive) to) { if (_materials.count(semantic) > 0) { @@ -233,11 +220,9 @@ apply_to_primitive(const string semantic, const PT(EggPrimitive) to) { } } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::apply_to -// Access: Public -// Description: Applies the colorblend stuff to the given EggGroup. -//////////////////////////////////////////////////////////////////// +/** + * Applies the colorblend stuff to the given EggGroup. + */ void DaeMaterials:: apply_to_group(const string semantic, const PT(EggGroup) to, bool invert_transparency) { if (_materials.count(semantic) > 0) { @@ -261,13 +246,10 @@ apply_to_group(const string semantic, const PT(EggGroup) to, bool invert_transpa } } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::get_uvset_name -// Access: Public -// Description: Returns the semantic of the uvset with the -// specified input set, or an empty string if the -// given material has no input set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the semantic of the uvset with the specified input set, or an empty + * string if the given material has no input set. + */ const string DaeMaterials:: get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set) { if (_materials.count(semantic) > 0) { @@ -281,7 +263,7 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti } } // If we can't find it, let's look again, but don't care for the - // input_semantic this time. The reason for this is that some tools + // input_semantic this time. The reason for this is that some tools // export textangents and texbinormals bound to a uvset with input // semantic TEXCOORD. for (size_t i = 0; i < _materials[semantic]->_uvsets.size(); ++i) { @@ -296,12 +278,10 @@ get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semanti return ""; } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::convert_texture_type -// Access: Public, Static -// Description: Converts an FCollada sampler type to the EggTexture -// texture type equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Converts an FCollada sampler type to the EggTexture texture type + * equivalent. + */ EggTexture::TextureType DaeMaterials:: convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type) { switch (orig_type) { @@ -319,17 +299,14 @@ convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type) { return EggTexture::TT_unspecified; } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::convert_wrap_mode -// Access: Public, Static -// Description: Converts an FCollada wrap mode to the -// EggTexture wrap mode equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Converts an FCollada wrap mode to the EggTexture wrap mode equivalent. + */ EggTexture::WrapMode DaeMaterials:: convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode) { switch (orig_mode) { case FUDaeTextureWrapMode::NONE: - //FIXME: this shouldnt be unspecified + // FIXME: this shouldnt be unspecified return EggTexture::WM_unspecified; case FUDaeTextureWrapMode::WRAP: return EggTexture::WM_repeat; @@ -347,17 +324,15 @@ convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode) { return EggTexture::WM_unspecified; } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::convert_filter_type -// Access: Public, Static -// Description: Converts an FCollada filter function to the -// EggTexture wrap type equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Converts an FCollada filter function to the EggTexture wrap type + * equivalent. + */ EggTexture::FilterType DaeMaterials:: convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type) { switch (orig_type) { case FUDaeTextureFilterFunction::NONE: - //FIXME: this shouldnt be unspecified + // FIXME: this shouldnt be unspecified return EggTexture::FT_unspecified; case FUDaeTextureFilterFunction::NEAREST: return EggTexture::FT_nearest; @@ -379,11 +354,9 @@ convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type) return EggTexture::FT_unspecified; } -//////////////////////////////////////////////////////////////////// -// Function: DaeMaterials::convert_blend -// Access: Private, Static -// Description: Converts collada blend attribs to Panda's equivalents. -//////////////////////////////////////////////////////////////////// +/** + * Converts collada blend attribs to Panda's equivalents. + */ PT(DaeMaterials::DaeBlendSettings) DaeMaterials:: convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency) { // Create the DaeBlendSettings and fill it with some defaults. diff --git a/pandatool/src/daeegg/daeMaterials.h b/pandatool/src/daeegg/daeMaterials.h index ebb0dd9252..7c2ba0d563 100644 --- a/pandatool/src/daeegg/daeMaterials.h +++ b/pandatool/src/daeegg/daeMaterials.h @@ -1,16 +1,15 @@ -// Filename: daeMaterials.h -// Created by: pro-rsoft (03Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeMaterials.h + * @author rdb + * @date 2008-10-03 + */ #ifndef DAEMATERIALS_H #define DAEMATERIALS_H @@ -32,26 +31,24 @@ #include "FCDocument/FCDEffectParameterSampler.h" #include "FCDocument/FCDExtra.h" -//////////////////////////////////////////////////////////////////// -// Class : DaeMaterials -// Description : This class is seperated from the converter file -// because otherwise it would get too big and -// needlessly complicated. -//////////////////////////////////////////////////////////////////// +/** + * This class is seperated from the converter file because otherwise it would + * get too big and needlessly complicated. + */ class DaeMaterials : public TypedReferenceCount { public: DaeMaterials(const FCDGeometryInstance* geometry_instance); virtual ~DaeMaterials() {}; - + void add_material_instance(const FCDMaterialInstance* instance); void apply_to_primitive(const string semantic, const PT(EggPrimitive) to); void apply_to_group(const string semantic, const PT(EggGroup) to, bool invert_transparency=false); const string get_uvset_name(const string semantic, FUDaeGeometryInput::Semantic input_semantic, int32 input_set); - + static EggTexture::TextureType convert_texture_type(const FCDEffectParameterSampler::SamplerType orig_type); static EggTexture::WrapMode convert_wrap_mode(const FUDaeTextureWrapMode::WrapMode orig_mode); static EggTexture::FilterType convert_filter_type(const FUDaeTextureFilterFunction::FilterFunction orig_type); - + private: // Holds stuff for color blend attribs. struct DaeBlendSettings : public ReferenceCount { @@ -60,14 +57,14 @@ private: EggGroup::BlendOperand _operand_a; EggGroup::BlendOperand _operand_b; }; - + // Holds information to bind texcoord inputs to textures. struct DaeVertexInputBinding : public ReferenceCount { int32 _input_set; FUDaeGeometryInput::Semantic _input_semantic; string _semantic; }; - + // Holds stuff for an individual material. struct DaeMaterial : public ReferenceCount { pvector _egg_textures; @@ -76,13 +73,13 @@ private: pvector _uvsets; PT(DaeBlendSettings) _blend; }; - + void process_texture_bucket(const string semantic, const FCDEffectStandard* effect_common, FUDaeTextureChannel::Channel bucket, EggTexture::EnvType envtype = EggTexture::ET_unspecified, EggTexture::Format format = EggTexture::F_unspecified); void process_extra(const string semantic, const FCDExtra* extra); static PT(DaeBlendSettings) convert_blend(FCDEffectStandard::TransparencyMode mode, const LColor &transparent, double transparency); - + pmap _materials; - + public: virtual TypeHandle get_type() const { return get_class_type(); diff --git a/pandatool/src/daeegg/daeToEggConverter.cxx b/pandatool/src/daeegg/daeToEggConverter.cxx index 88ae0c7027..0b3844549f 100644 --- a/pandatool/src/daeegg/daeToEggConverter.cxx +++ b/pandatool/src/daeegg/daeToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: daeToEggConverter.cxx -// Created by: pro-rsoft (08May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeToEggConverter.cxx + * @author rdb + * @date 2008-05-08 + */ #include "daeToEggConverter.h" #include "fcollada_utils.h" @@ -49,11 +48,9 @@ #include "FCDocument/FCDGeometryPolygonsInput.h" #endif -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DAEToEggConverter:: DAEToEggConverter() { _unit_name = "meter"; @@ -64,22 +61,18 @@ DAEToEggConverter() { _invert_transparency = false; } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DAEToEggConverter:: DAEToEggConverter(const DAEToEggConverter ©) : SomethingToEggConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DAEToEggConverter:: ~DAEToEggConverter() { if (_error_handler != NULL) { @@ -87,46 +80,35 @@ DAEToEggConverter:: } } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *DAEToEggConverter:: make_copy() { return new DAEToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string DAEToEggConverter:: get_name() const { return "COLLADA"; } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string DAEToEggConverter:: get_extension() const { return "dae"; } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + */ bool DAEToEggConverter:: convert_file(const Filename &filename) { // Reset stuff @@ -256,8 +238,8 @@ convert_file(const Filename &filename) { } } else { // No sampling parameters given; not necessarily a failure, since the - // animation may already be sampled. We use the key frames as animation - // frames. + // animation may already be sampled. We use the key frames as + // animation frames. if (_end_frame != 0.0) { // An end frame was given, chop off all keys after that. float end = _end_frame; @@ -302,8 +284,8 @@ convert_file(const Filename &filename) { } } - // It doesn't really matter which character we grab for this as - // it'll iterate over the whole graph right now anyway. + // It doesn't really matter which character we grab for this as it'll + // iterate over the whole graph right now anyway. for (size_t ch = 0; ch < visual_scene->GetChildrenCount(); ++ch) { character->build_table(skeleton, visual_scene->GetChild(ch), keys); } @@ -317,15 +299,12 @@ convert_file(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEggConverter::get_input_units -// Access: Public, Virtual -// Description: This may be called after convert_file() has been -// called and returned true, indicating a successful -// conversion. It will return the distance units -// represented by the converted egg file, if known, or -// DU_invalid if not known. -//////////////////////////////////////////////////////////////////// +/** + * This may be called after convert_file() has been called and returned true, + * indicating a successful conversion. It will return the distance units + * represented by the converted egg file, if known, or DU_invalid if not + * known. + */ DistanceUnit DAEToEggConverter:: get_input_units() { if (IS_NEARLY_EQUAL(_unit_meters, 0.001)) { @@ -385,7 +364,8 @@ process_asset() { } } -// Process the node. If forced is true, it will even process it if its known to be a skeleton root. +// Process the node. If forced is true, it will even process it if its known +// to be a skeleton root. void DAEToEggConverter:: process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { nassertv(node != NULL); @@ -413,7 +393,7 @@ process_node(EggGroupNode *parent, const FCDSceneNode* node, bool forced) { for (size_t tr = node->GetTransformCount(); tr > 0; --tr) { apply_transform(node_group, node->GetTransform(tr - 1)); } - //node_group->set_transform3d(convert_matrix(node->ToMatrix())); + // node_group->set_transform3d(convert_matrix(node->ToMatrix())); // Loop through the instances and process them for (size_t in = 0; in < node->GetInstanceCount(); ++in) { @@ -458,7 +438,7 @@ process_instance(EggGroup *parent, const FCDEntityInstance* instance) { case FCDEntityInstance::CONTROLLER: // Add the dart tag and process the controller instance - //parent->set_dart_type(EggGroup::DT_default); + // parent->set_dart_type(EggGroup::DT_default); process_controller(parent, (const FCDControllerInstance*) instance); break; @@ -510,7 +490,8 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, 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 don't have a better idea. + // This is an array of pointers, I know. But since they are refcounted, I + // don't have a better idea. PT(EggGroup) *primitive_holders = new PT(EggGroup) [mesh->GetPolygonsCount()]; for (size_t gr = 0; gr < mesh->GetPolygonsCount(); ++gr) { const FCDGeometryPolygons* polygons = mesh->GetPolygons(gr); @@ -518,9 +499,11 @@ process_mesh(EggGroup *parent, const FCDGeometryMesh* mesh, // Stores which group holds the primitives. PT(EggGroup) primitiveholder; - // If we have materials, make a group for each material. Then, apply the material's per-group stuff. + // If we have materials, make a group for each material. Then, apply the + // material's per-group stuff. if (materials != NULL && (!polygons->GetMaterialSemantic().empty()) && mesh->GetPolygonsCount() > 1) { - //primitiveholder = new EggGroup(FROM_FSTRING(mesh->GetDaeId()) + "." + material_semantic); + // primitiveholder = new EggGroup(FROM_FSTRING(mesh->GetDaeId()) + "." + + // material_semantic); primitiveholder = new EggGroup; mesh_group->add_child(primitiveholder); } else { @@ -704,7 +687,7 @@ process_spline(EggGroup *parent, const string group_name, FCDGeometrySpline* geo assert(geometry_spline != NULL); PT(EggGroup) result = new EggGroup(group_name); parent->add_child(result); - //TODO: if its not a nurbs, make it convert between the types + // TODO: if its not a nurbs, make it convert between the types if (geometry_spline->GetType() != FUDaeSplineType::NURBS) { daeegg_cat.warning() << "Only NURBS curves are supported (yet)!" << endl; } else { @@ -722,7 +705,7 @@ process_spline(EggGroup *parent, const FCDSpline* spline) { // Now load in the nurbs curve to the egg library PT(EggNurbsCurve) nurbs_curve = new EggNurbsCurve(FROM_FSTRING(spline->GetName())); parent->add_child(nurbs_curve); - //TODO: what value is this? + // TODO: what value is this? nurbs_curve->setup(0, ((const FCDNURBSSpline*) spline)->GetKnotCount()); for (size_t kn = 0; kn < ((const FCDNURBSSpline*) spline)->GetKnotCount(); ++kn) { const float* knot = ((const FCDNURBSSpline*) spline)->GetKnot(kn); @@ -772,7 +755,7 @@ process_controller(EggGroup *parent, const FCDControllerInstance *instance) { assert(morph_target != NULL); PT(EggSAnimData) target = new EggSAnimData(FROM_FSTRING(morph_target->GetGeometry()->GetName())); if (morph_target->IsAnimated()) { - //TODO + // TODO } else { target->add_data(morph_target->GetWeight()); } @@ -821,7 +804,8 @@ void DAEToEggConverter:: apply_transform(EggGroup *to, const FCDTransform* from) { assert(from != NULL); assert(to != NULL); - //to->set_transform3d(convert_matrix(from->ToMatrix()) * to->get_transform3d()); + // to->set_transform3d(convert_matrix(from->ToMatrix()) * + // to->get_transform3d()); switch (from->GetType()) { case FCDTransform::TRANSLATION: { diff --git a/pandatool/src/daeegg/daeToEggConverter.h b/pandatool/src/daeegg/daeToEggConverter.h index e2c29a1fa1..b31d439526 100644 --- a/pandatool/src/daeegg/daeToEggConverter.h +++ b/pandatool/src/daeegg/daeToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: daeToEggConverter.h -// Created by: pro-rsoft (08May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeToEggConverter.h + * @author rdb + * @date 2008-05-08 + */ #ifndef DAETOEGGCONVERTER_H #define DAETOEGGCONVERTER_H @@ -38,11 +37,10 @@ #include "daeCharacter.h" #include "pvector.h" // Include last -//////////////////////////////////////////////////////////////////// -// Class : DAEToEggConverter -// Description : This class supervises the construction of an -// EggData structure from a DAE file. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a DAE + * file. + */ class DAEToEggConverter : public SomethingToEggConverter { public: DAEToEggConverter(); diff --git a/pandatool/src/daeegg/fcollada_utils.h b/pandatool/src/daeegg/fcollada_utils.h index 10145f615b..eefe990bac 100644 --- a/pandatool/src/daeegg/fcollada_utils.h +++ b/pandatool/src/daeegg/fcollada_utils.h @@ -1,19 +1,18 @@ -// Filename: fcollada_utils.h -// Created by: pro-rsoft (22Dec08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fcollada_utils.h + * @author rdb + * @date 2008-12-22 + */ -// This file defines some conversion tools for conversion between -// FCollada and Panda3D +// This file defines some conversion tools for conversion between FCollada and +// Panda3D #ifndef FCOLLADA_UTILS_H #define FCOLLADA_UTILS_H diff --git a/pandatool/src/daeegg/pre_fcollada_include.h b/pandatool/src/daeegg/pre_fcollada_include.h index 70c80ca324..18cbe7a45d 100644 --- a/pandatool/src/daeegg/pre_fcollada_include.h +++ b/pandatool/src/daeegg/pre_fcollada_include.h @@ -1,19 +1,18 @@ -// Filename: pre_fcollada_include.h -// Created by: pro-rsoft (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pre_fcollada_include.h + * @author rdb + * @date 2008-10-04 + */ -// This file defines some stuff that need to be defined before -// one includes FCollada.h +// This file defines some stuff that need to be defined before one includes +// FCollada.h #ifndef PRE_FCOLLADA_INCLUDE_H #define PRE_FCOLLADA_INCLUDE_H diff --git a/pandatool/src/daeprogs/daeToEgg.cxx b/pandatool/src/daeprogs/daeToEgg.cxx index 38a0eb9cdb..c96f656100 100644 --- a/pandatool/src/daeprogs/daeToEgg.cxx +++ b/pandatool/src/daeprogs/daeToEgg.cxx @@ -1,27 +1,24 @@ -// Filename: daeToEgg.cxx -// Created by: pro-rsoft (08May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeToEgg.cxx + * @author rdb + * @date 2008-05-08 + */ #include "daeToEgg.h" #include "daeToEggConverter.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: DAEToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DAEToEgg:: DAEToEgg(): SomethingToEgg("COLLADA", ".dae") @@ -46,11 +43,9 @@ DAEToEgg(): _animation_convert = AC_both; } -//////////////////////////////////////////////////////////////////// -// Function: DAEToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DAEToEgg:: run() { if (_animation_convert != AC_both && _animation_convert != AC_none && diff --git a/pandatool/src/daeprogs/daeToEgg.h b/pandatool/src/daeprogs/daeToEgg.h index 555ffc99e9..7b7eb3aa19 100644 --- a/pandatool/src/daeprogs/daeToEgg.h +++ b/pandatool/src/daeprogs/daeToEgg.h @@ -1,17 +1,16 @@ -// Filename: daeToEgg.h -// Created by: pro-rsoft (08May08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file daeToEgg.h + * @author rdb + * @date 2008-05-08 + */ + #ifndef DAETOEGG_H #define DAETOEGG_H @@ -20,11 +19,9 @@ #include "somethingToEgg.h" #include "daeToEggConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : DAEToEgg -// Description : A program to read a DAE file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a DAE file and generate an egg file. + */ class DAEToEgg : public SomethingToEgg { public: DAEToEgg(); diff --git a/pandatool/src/daeprogs/eggToDAE.cxx b/pandatool/src/daeprogs/eggToDAE.cxx index d5f042ec9e..31b8f24d5d 100644 --- a/pandatool/src/daeprogs/eggToDAE.cxx +++ b/pandatool/src/daeprogs/eggToDAE.cxx @@ -1,16 +1,15 @@ -// Filename: eggToDAE.cxx -// Created by: pro-rsoft (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDAE.cxx + * @author rdb + * @date 2008-10-04 + */ #include "eggToDAE.h" #include "dcast.h" @@ -30,11 +29,9 @@ #define FROM_MAT4(v) (FMMatrix44(v.get_data())) #define FROM_FSTRING(fs) (fs.c_str()) -//////////////////////////////////////////////////////////////////// -// Function: EggToDAE::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToDAE:: EggToDAE() : EggToSomething("COLLADA", ".dae", true, false) @@ -48,30 +45,28 @@ EggToDAE() : _document = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggToDAE::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToDAE:: run() { nassertv(has_output_filename()); nassertv(_data != NULL); - + FCollada::Initialize(); _document = FCollada::NewTopDocument(); - + // Add the contributor part to the asset FCDAssetContributor* contributor = _document->GetAsset()->AddContributor(); const char* user_name = getenv("USER"); if (user_name == NULL) user_name = getenv("USERNAME"); if (user_name != NULL) contributor->SetAuthor(TO_FSTRING(user_name)); - //contributor->SetSourceData(); + // contributor->SetSourceData(); char authoring_tool[1024]; snprintf(authoring_tool, 1024, "Panda3D %s eggToDAE converter | FCollada v%d.%02d", PANDA_VERSION_STR, FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF); authoring_tool[1023] = 0; contributor->SetAuthoringTool(TO_FSTRING(authoring_tool)); - + // Set coordinate system switch (_data->get_coordinate_system()) { case CS_zup_right: @@ -81,7 +76,7 @@ run() { _document->GetAsset()->SetUpAxis(FMVector3::YAxis); break; } - + // Now actually start processing the data. FCDSceneNode* visual_scene = _document->AddVisualScene(); for (EggGroupNode::iterator it = _data->begin(); it != _data->end(); ++it) { @@ -89,16 +84,13 @@ run() { process_node(visual_scene, DCAST(EggGroup, *it)); } } - + // We're done here. FCollada::SaveDocument(_document, get_output_filename().to_os_specific().c_str()); SAFE_DELETE(_document); FCollada::Release(); - - //if (!out) { - // nout << "An error occurred while writing.\n"; - // exit(1); - //} + + // if (!out) { nout << "An error occurred while writing.\n"; exit(1); } } void EggToDAE::process_node(FCDSceneNode* parent, const PT(EggGroup) node) { diff --git a/pandatool/src/daeprogs/eggToDAE.h b/pandatool/src/daeprogs/eggToDAE.h index f20dbf7d34..5a13546485 100644 --- a/pandatool/src/daeprogs/eggToDAE.h +++ b/pandatool/src/daeprogs/eggToDAE.h @@ -1,16 +1,15 @@ -// Filename: eggToDAE.h -// Created by: pro-rsoft (04Oct08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDAE.h + * @author rdb + * @date 2008-10-04 + */ #ifndef EGGTODAE_H #define EGGTODAE_H @@ -24,10 +23,9 @@ #include "FCollada.h" #include "FCDocument/FCDSceneNode.h" -//////////////////////////////////////////////////////////////////// -// Class : EggToDAE -// Description : A program to read an egg file and write a DAE file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write a DAE file. + */ class EggToDAE : public EggToSomething { public: EggToDAE(); @@ -36,11 +34,10 @@ public: private: FCDocument* _document; - + void process_node(FCDSceneNode* parent, const PT(EggGroup) node); void apply_transform(FCDSceneNode* to, const PT(EggGroup) from); }; #endif - diff --git a/pandatool/src/dxf/dxfFile.cxx b/pandatool/src/dxf/dxfFile.cxx index aadf9d2879..b716ea11ba 100644 --- a/pandatool/src/dxf/dxfFile.cxx +++ b/pandatool/src/dxf/dxfFile.cxx @@ -1,16 +1,15 @@ -// Filename: dxfFile.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfFile.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfFile.h" #include "string_utils.h" @@ -274,13 +273,11 @@ DXFFile::Color DXFFile::_colors[DXF_num_colors] = { { 0.866, 0.866, 0.866 }, { 1, 1, 1 }, }; - -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ DXFFile:: DXFFile() { _in = NULL; @@ -290,11 +287,9 @@ DXFFile() { _color_index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFFile:: ~DXFFile() { if (_owns_in) { @@ -304,12 +299,9 @@ DXFFile:: } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::process -// Access: Public -// Description: Opens the indicated filename and reads it as a DXF -// file. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename and reads it as a DXF file. + */ void DXFFile:: process(Filename filename) { filename.set_text(); @@ -323,14 +315,11 @@ process(Filename filename) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::process -// Access: Public -// Description: Reads the indicated stream as a DXF file. If owns_in -// is true, then the istream will be deleted via -// vfs->close_read_file() when the DXFFile object -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated stream as a DXF file. If owns_in is true, then the + * istream will be deleted via vfs->close_read_file() when the DXFFile object + * destructs. + */ void DXFFile:: process(istream *in, bool owns_in) { if (_owns_in) { @@ -370,39 +359,30 @@ process(istream *in, bool owns_in) { -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::Begin File -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called whenever processing begins on the DXF file. -//////////////////////////////////////////////////////////////////// +/** + * A hook for user code, if desired. This function is called whenever + * processing begins on the DXF file. + */ void DXFFile:: begin_file() { } - -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::begin_section -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called whenever a new section in the DXF file is -// encountered. -//////////////////////////////////////////////////////////////////// + +/** + * A hook for user code, if desired. This function is called whenever a new + * section in the DXF file is encountered. + */ void DXFFile:: begin_section() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::done_vertex -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called whenever a vertex is read from the DXF file. -// This function has the default behavior of adding the -// vertex to the _verts list, so that when done_entity() -// is called later, it will have the complete list of -// vertices available to it. -//////////////////////////////////////////////////////////////////// +/** + * A hook for user code, if desired. This function is called whenever a + * vertex is read from the DXF file. This function has the default behavior + * of adding the vertex to the _verts list, so that when done_entity() is + * called later, it will have the complete list of vertices available to it. + */ void DXFFile:: done_vertex() { DXFVertex v; @@ -411,51 +391,40 @@ done_vertex() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::done_entity -// Access: Public, Virtual -// Description: This is the primary hook for user code. This -// function is called when an entity is read from the -// DXF file. This may be something like a polygon, -// point, or a polygon mesh: any geometry. It is up to -// the user code to override this function and do -// something interesting with each piece of geometry -// that is read. -//////////////////////////////////////////////////////////////////// +/** + * This is the primary hook for user code. This function is called when an + * entity is read from the DXF file. This may be something like a polygon, + * point, or a polygon mesh: any geometry. It is up to the user code to + * override this function and do something interesting with each piece of + * geometry that is read. + */ void DXFFile:: done_entity() { } - -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::end_section -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called as each section in the DXF file is finished. -//////////////////////////////////////////////////////////////////// + +/** + * A hook for user code, if desired. This function is called as each section + * in the DXF file is finished. + */ void DXFFile:: end_section() { } - -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::end_file -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called when the DXF processing is complete. -//////////////////////////////////////////////////////////////////// + +/** + * A hook for user code, if desired. This function is called when the DXF + * processing is complete. + */ void DXFFile:: end_file() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::Error -// Access: Public, Virtual -// Description: A hook for user code, if desired. This function is -// called when some unexpected error occurs while -// reading the DXF file. -//////////////////////////////////////////////////////////////////// +/** + * A hook for user code, if desired. This function is called when some + * unexpected error occurs while reading the DXF file. + */ void DXFFile:: error() { nout << "Error!\n"; @@ -463,12 +432,10 @@ error() { -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::find_color -// Access: Public, Static -// Description: Returns the index of the closest matching AutoCAD -// color to the indicated r, g, b. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index of the closest matching AutoCAD color to the indicated r, + * g, b. + */ int DXFFile:: find_color(double r, double g, double b) { double best_diff = 4.0; // 4 is greater than our expected max, 3. @@ -487,14 +454,11 @@ find_color(double r, double g, double b) { return best_index; } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::get_color -// Access: Public -// Description: This is a convenience function to return the r,g,b -// color of the current entity (at the time of -// done_entity()). It's based on the _color_index value -// that was read from the DXF file. -//////////////////////////////////////////////////////////////////// +/** + * This is a convenience function to return the r,g,b color of the current + * entity (at the time of done_entity()). It's based on the _color_index + * value that was read from the DXF file. + */ const DXFFile::Color &DXFFile:: get_color() const { if (_color_index >= 0 && _color_index <= 255) { @@ -504,16 +468,12 @@ get_color() const { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::ocs_2_wcs -// Access: Public -// Description: Assuming the current entity is a planar-based entity, -// for instance, a 2-d polygon (as opposed to a 3-d -// polygon), this converts the coordinates from the -// funny planar coordinate system to the world -// coordinates. It converts the _p value of the entity, -// as well as all vertices in the _verts list. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the current entity is a planar-based entity, for instance, a 2-d + * polygon (as opposed to a 3-d polygon), this converts the coordinates from + * the funny planar coordinate system to the world coordinates. It converts + * the _p value of the entity, as well as all vertices in the _verts list. + */ void DXFFile:: ocs_2_wcs() { compute_ocs(); @@ -534,18 +494,16 @@ ocs_2_wcs() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::compute_ocs -// Access: Protected -// Description: Computes the matrix used to convert from the planar -// coordinate system to world coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Computes the matrix used to convert from the planar coordinate system to + * world coordinates. + */ void DXFFile:: compute_ocs() { - // A 2-d entity's vertices might be defined in an "Object Coordinate - // System" which has a funny definition. Its Z axis is defined by - // _z, and its X and Y axes are inferred from that. The origin is - // the same as the world coordinate system's origin. + // A 2-d entity's vertices might be defined in an "Object Coordinate System" + // which has a funny definition. Its Z axis is defined by _z, and its X and + // Y axes are inferred from that. The origin is the same as the world + // coordinate system's origin. // The Z axis is _z. Determine the x and y axes. LVector3d x, y; @@ -570,12 +528,10 @@ compute_ocs() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::get_group -// Access: Protected -// Description: Reads the next code, string pair from the DXF file. -// This is the basic unit of data in a DXF file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the next code, string pair from the DXF file. This is the basic unit + * of data in a DXF file. + */ bool DXFFile:: get_group() { istream &in = *_in; @@ -586,8 +542,8 @@ get_group() { return false; } - // Now skip past exactly one newline character and any number of - // other whitespace characters. + // Now skip past exactly one newline character and any number of other + // whitespace characters. while (in && in.peek() != '\n') { in.get(); } @@ -611,12 +567,9 @@ get_group() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::change_state -// Access: Protected -// Description: Called as new nodes are read to update the internal -// state correctly. -//////////////////////////////////////////////////////////////////// +/** + * Called as new nodes are read to update the internal state correctly. + */ void DXFFile:: change_state(State new_state) { if (_state == ST_verts) { @@ -628,9 +581,8 @@ change_state(State new_state) { } if ((_state == ST_entity || _state == ST_verts) && new_state != ST_verts) { - // We finish an entity when we read a new entity, or when we've - // read the last vertex (if we were scanning the vertices after an - // entity). + // We finish an entity when we read a new entity, or when we've read the + // last vertex (if we were scanning the vertices after an entity). done_entity(); reset_entity(); } @@ -650,11 +602,9 @@ change_state(State new_state) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::change_section -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXFFile:: change_section(Section new_section) { change_state(ST_section); @@ -663,14 +613,11 @@ change_section(Section new_section) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::change_layer -// Access: Protected -// Description: Given a newly read layer name, sets the _layer -// pointer to point to the associate layer. If the -// layer name has not been encountered before, creates a -// new layer definition. -//////////////////////////////////////////////////////////////////// +/** + * Given a newly read layer name, sets the _layer pointer to point to the + * associate layer. If the layer name has not been encountered before, + * creates a new layer definition. + */ void DXFFile:: change_layer(const string &layer_name) { if (_layer == NULL || _layer->get_name() != layer_name) { @@ -679,17 +626,14 @@ change_layer(const string &layer_name) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::change_entity -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXFFile:: change_entity(Entity new_entity) { if (new_entity == EN_vertex && _vertices_follow) { - // If we read a new vertex and we're still scanning the vertices - // that follow an entity, keep scanning it--we haven't finished - // the entity yet. + // If we read a new vertex and we're still scanning the vertices that + // follow an entity, keep scanning it--we haven't finished the entity yet. change_state(ST_verts); } else { @@ -700,12 +644,10 @@ change_entity(Entity new_entity) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::reset_entity -// Access: Protected -// Description: Resets the current entity to its initial, default -// state prior to reading a new entity. -//////////////////////////////////////////////////////////////////// +/** + * Resets the current entity to its initial, default state prior to reading a + * new entity. + */ void DXFFile:: reset_entity() { _p.set(0.0, 0.0, 0.0); @@ -714,18 +656,16 @@ reset_entity() { _s.set(0.0, 0.0, 0.0); _z.set(0.0, 0.0, 1.0); _vertices_follow = false; - //_color_index = -1; + // _color_index = -1; _verts.erase(_verts.begin(), _verts.end()); } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::state_top -// Access: Protected -// Description: Does the DXF processing when we are at the top of the -// file, outside of any section. -//////////////////////////////////////////////////////////////////// +/** + * Does the DXF processing when we are at the top of the file, outside of any + * section. + */ void DXFFile:: state_top() { if (_code != 0) { @@ -736,7 +676,7 @@ state_top() { if (_string == "SECTION") { if (get_group()) { if (_code != 2) { - nout << "Group code 0 not immediately followed by code 2; found code " + nout << "Group code 0 not immediately followed by code 2; found code " << _code << " instead.\n"; } else { if (_string == "HEADER") { @@ -765,12 +705,9 @@ state_top() { -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::state_section -// Access: Protected -// Description: Does the DXF processing when we are within some -// section. -//////////////////////////////////////////////////////////////////// +/** + * Does the DXF processing when we are within some section. + */ void DXFFile:: state_section() { string tail; @@ -812,12 +749,9 @@ state_section() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::state_entity -// Access: Protected -// Description: Does the DXF processing when we are reading an -// entity. -//////////////////////////////////////////////////////////////////// +/** + * Does the DXF processing when we are reading an entity. + */ void DXFFile:: state_entity() { string tail; @@ -909,12 +843,10 @@ state_entity() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFFile::state_verts -// Access: Protected -// Description: Does the DXF processing when we are reading the list -// of vertices that might follow an entity. -//////////////////////////////////////////////////////////////////// +/** + * Does the DXF processing when we are reading the list of vertices that might + * follow an entity. + */ void DXFFile:: state_verts() { string tail; @@ -999,4 +931,3 @@ ostream &operator << (ostream &out, const DXFFile::Entity &entity) { } return out << "Unknown entity"; } - diff --git a/pandatool/src/dxf/dxfFile.h b/pandatool/src/dxf/dxfFile.h index 22777a52db..59d37d3057 100644 --- a/pandatool/src/dxf/dxfFile.h +++ b/pandatool/src/dxf/dxfFile.h @@ -1,16 +1,15 @@ -// Filename: dxfFile.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfFile.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFFILE_H #define DXFFILE_H @@ -28,14 +27,11 @@ static const int DXF_max_line = 256; static const int DXF_num_colors = 256; -//////////////////////////////////////////////////////////////////// -// Class : DXFFile -// Description : A generic DXF-reading class. This class can read a -// DXF file but doesn't actually do anything with the -// data; it's intended to be inherited from and the -// appropriate functions overridden (particularly -// DoneEntity()). -//////////////////////////////////////////////////////////////////// +/** + * A generic DXF-reading class. This class can read a DXF file but doesn't + * actually do anything with the data; it's intended to be inherited from and + * the appropriate functions overridden (particularly DoneEntity()). + */ class DXFFile : public MemoryBase { public: DXFFile(); @@ -44,10 +40,10 @@ public: void process(Filename filename); void process(istream *in, bool owns_in); - // These functions are called as the file is processed. These are - // the main hooks for redefining how the class should dispense its - // data. As each function is called, the state stored in the - // DXFFile class reflects the data that was most recently read. + // These functions are called as the file is processed. These are the main + // hooks for redefining how the class should dispense its data. As each + // function is called, the state stored in the DXFFile class reflects the + // data that was most recently read. virtual void begin_file(); virtual void begin_section(); @@ -57,10 +53,10 @@ public: virtual void end_file(); virtual void error(); - // new_layer() is called whenever the DXFFile class encounters a new - // Layer definition, and must allocate a DXFLayer instance. This - // function is provided so that user code may force allocate of a - // specialized DXFLayer instance instead. + // new_layer() is called whenever the DXFFile class encounters a new Layer + // definition, and must allocate a DXFLayer instance. This function is + // provided so that user code may force allocate of a specialized DXFLayer + // instance instead. virtual DXFLayer *new_layer(const string &name) { return new DXFLayer(name); } @@ -100,32 +96,30 @@ public: PF_continuous_linetype = 0x80, }; - // This is a table of standard Autocad colors. DXF files can store - // only a limited range of colors; specifically, the 255 colors - // defined by Autocad. + // This is a table of standard Autocad colors. DXF files can store only a + // limited range of colors; specifically, the 255 colors defined by Autocad. struct Color { double r, g, b; }; static Color _colors[DXF_num_colors]; - // find_color() returns the index of the closest matching AutoCAD - // color to the indicated r, g, b. + // find_color() returns the index of the closest matching AutoCAD color to + // the indicated r, g, b. static int find_color(double r, double g, double b); - // get_color() returns the r,g,b of the current entity. It is valid - // at the time done_entity() is called. + // get_color() returns the r,g,b of the current entity. It is valid at the + // time done_entity() is called. const Color &get_color() const; - // Some entities are defined in world coordinates, in 3-d space; - // other entities are inherently 2-d in nature and are defined in - // planar coordinates and must be converted to 3-d space. Call this - // function from done_entity() to convert a 2-d entity to 3-d world - // coordinates. + // Some entities are defined in world coordinates, in 3-d space; other + // entities are inherently 2-d in nature and are defined in planar + // coordinates and must be converted to 3-d space. Call this function from + // done_entity() to convert a 2-d entity to 3-d world coordinates. void ocs_2_wcs(); - // These members indicate the current state and describe properties - // of the current thing being processed. They are valid at - // done_entity(), and at other times. + // These members indicate the current state and describe properties of the + // current thing being processed. They are valid at done_entity(), and at + // other times. int _flags; Section _section; Entity _entity; @@ -134,8 +128,8 @@ public: int _color_index; DXFLayer *_layer; - // _verts is the list of vertices associated with the current - // entity. It is valid at the time done_entity() is called. + // _verts is the list of vertices associated with the current entity. It is + // valid at the time done_entity() is called. DXFVertices _verts; // This is the set of layers encountered within the DXF file. diff --git a/pandatool/src/dxf/dxfLayer.cxx b/pandatool/src/dxf/dxfLayer.cxx index 75980703a4..5ffc96a5cc 100644 --- a/pandatool/src/dxf/dxfLayer.cxx +++ b/pandatool/src/dxf/dxfLayer.cxx @@ -1,34 +1,29 @@ -// Filename: dxfLayer.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfLayer.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfLayer.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFLayer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFLayer:: DXFLayer(const string &name) : Namable(name) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFLayer::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFLayer:: ~DXFLayer() { } diff --git a/pandatool/src/dxf/dxfLayer.h b/pandatool/src/dxf/dxfLayer.h index 7ccfea0a0c..dab55adb4d 100644 --- a/pandatool/src/dxf/dxfLayer.h +++ b/pandatool/src/dxf/dxfLayer.h @@ -1,16 +1,15 @@ -// Filename: dxfLayer.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfLayer.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFLAYER_H #define DXFLAYER_H @@ -18,16 +17,14 @@ #include "pandatoolbase.h" #include "namable.h" -//////////////////////////////////////////////////////////////////// -// Class : DXFLayer -// Description : This represents a "layer" as read from the DXF file. -// A layer may be defined by reading the header part of -// the file, or it may be implicitly defined by an -// entity's having referenced it. -// -// User code may derive from DXFLayer to associate -// private data with each layer, if desired. -//////////////////////////////////////////////////////////////////// +/** + * This represents a "layer" as read from the DXF file. A layer may be + * defined by reading the header part of the file, or it may be implicitly + * defined by an entity's having referenced it. + * + * User code may derive from DXFLayer to associate private data with each + * layer, if desired. + */ class DXFLayer : public Namable { public: DXFLayer(const string &name); diff --git a/pandatool/src/dxf/dxfLayerMap.cxx b/pandatool/src/dxf/dxfLayerMap.cxx index fcdc9f8a41..447b27e8ca 100644 --- a/pandatool/src/dxf/dxfLayerMap.cxx +++ b/pandatool/src/dxf/dxfLayerMap.cxx @@ -1,31 +1,26 @@ -// Filename: dxfLayerMap.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfLayerMap.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfLayerMap.h" #include "dxfFile.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFLayerMap::get_layer -// Access: Public -// Description: Looks up the layer name in the map, and returns a -// pointer to the associated DXFLayer. If this is the -// first time this layer name has been used, creates a -// new DXFLayer by the given name. In this case, it -// calls dxffile->new_layer() to create the layer, -// allowing user code to override this function to -// create a specialized time, if desired. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the layer name in the map, and returns a pointer to the associated + * DXFLayer. If this is the first time this layer name has been used, creates + * a new DXFLayer by the given name. In this case, it calls + * dxffile->new_layer() to create the layer, allowing user code to override + * this function to create a specialized time, if desired. + */ DXFLayer *DXFLayerMap:: get_layer(const string &name, DXFFile *dxffile) { iterator lmi; @@ -41,4 +36,3 @@ get_layer(const string &name, DXFFile *dxffile) { return layer; } - diff --git a/pandatool/src/dxf/dxfLayerMap.h b/pandatool/src/dxf/dxfLayerMap.h index 1b2970552c..1dfabca80b 100644 --- a/pandatool/src/dxf/dxfLayerMap.h +++ b/pandatool/src/dxf/dxfLayerMap.h @@ -1,16 +1,15 @@ -// Filename: dxfLayerMap.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfLayerMap.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFLAYERMAP_H #define DXFLAYERMAP_H @@ -21,13 +20,11 @@ class DXFLayer; class DXFFile; -//////////////////////////////////////////////////////////////////// -// Class : DXFLayerMap -// Description : A map of string (layer name) to DXFLayer: that is, -// the layers of a file ordered by name. This is used -// as a lookup within DXFFile to locate the layer -// associated with a particular entity. -//////////////////////////////////////////////////////////////////// +/** + * A map of string (layer name) to DXFLayer: that is, the layers of a file + * ordered by name. This is used as a lookup within DXFFile to locate the + * layer associated with a particular entity. + */ class DXFLayerMap : public pmap { public: DXFLayer *get_layer(const string &name, DXFFile *dxffile); diff --git a/pandatool/src/dxf/dxfVertex.cxx b/pandatool/src/dxf/dxfVertex.cxx index 66addf6070..3802802f4a 100644 --- a/pandatool/src/dxf/dxfVertex.cxx +++ b/pandatool/src/dxf/dxfVertex.cxx @@ -1,26 +1,22 @@ -// Filename: dxfVertex.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfVertex.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfVertex.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFVertex::Ordering operator -// Access: Public -// Description: This defines a unique ordering for vertices so that -// the DXFVertexMap can group identical vertices -// together. -//////////////////////////////////////////////////////////////////// +/** + * This defines a unique ordering for vertices so that the DXFVertexMap can + * group identical vertices together. + */ int DXFVertex:: operator < (const DXFVertex &other) const { if (fabs(_p[0] - other._p[0]) > 0.0001) { @@ -33,4 +29,3 @@ operator < (const DXFVertex &other) const { return false; } - diff --git a/pandatool/src/dxf/dxfVertex.h b/pandatool/src/dxf/dxfVertex.h index 8c6c0fc5de..32494509ba 100644 --- a/pandatool/src/dxf/dxfVertex.h +++ b/pandatool/src/dxf/dxfVertex.h @@ -1,16 +1,15 @@ -// Filename: dxfVertex.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfVertex.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFVERTEX_H #define DXFVERTEX_H @@ -19,24 +18,21 @@ #include "pvector.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : DXFVertex -// Description : Stored within DXFFile, this is the basic Vertex data -// of a DXF file. When DXFFile::DoneEntity() is called, -// if the entity is a type to have vertices, then -// DXFFile::_verts contains a list of all the vertices -// that belong to the entity. -//////////////////////////////////////////////////////////////////// +/** + * Stored within DXFFile, this is the basic Vertex data of a DXF file. When + * DXFFile::DoneEntity() is called, if the entity is a type to have vertices, + * then DXFFile::_verts contains a list of all the vertices that belong to the + * entity. + */ class DXFVertex { public: DXFVertex() { } DXFVertex(const LPoint3d &p) : _p(p) { } int operator < (const DXFVertex &other) const; - + LPoint3d _p; }; typedef pvector DXFVertices; #endif - diff --git a/pandatool/src/dxfegg/dxfToEggConverter.cxx b/pandatool/src/dxfegg/dxfToEggConverter.cxx index 92af71d48b..58f2c7a758 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.cxx +++ b/pandatool/src/dxfegg/dxfToEggConverter.cxx @@ -1,102 +1,81 @@ -// Filename: dxfToEggConverter.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEggConverter.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfToEggConverter.h" #include "dxfToEggLayer.h" #include "eggData.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFToEggConverter:: DXFToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFToEggConverter:: DXFToEggConverter(const DXFToEggConverter ©) : SomethingToEggConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFToEggConverter:: ~DXFToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *DXFToEggConverter:: make_copy() { return new DXFToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string DXFToEggConverter:: get_name() const { return "DXF"; } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string DXFToEggConverter:: get_extension() const { return "dxf"; } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool DXFToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + */ bool DXFToEggConverter:: convert_file(const Filename &filename) { clear_error(); @@ -109,27 +88,22 @@ convert_file(const Filename &filename) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::new_layer -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFLayer *DXFToEggConverter:: new_layer(const string &name) { return new DXFToEggLayer(name, get_egg_data()); } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::done_entity -// Access: Protected, Virtual -// Description: If the entity is a polygon, creates the corresponding -// egg polygon. -//////////////////////////////////////////////////////////////////// +/** + * If the entity is a polygon, creates the corresponding egg polygon. + */ void DXFToEggConverter:: done_entity() { if (_entity == EN_polyline) { - // A Polyline is either an unclosed series of connected line - // segments, or a closed polygon of arbitrary complexity. + // A Polyline is either an unclosed series of connected line segments, or + // a closed polygon of arbitrary complexity. if ((_flags & PF_3d) == 0) { // it's a 2-d polygon; convert it to 3-d coordinates. @@ -147,28 +121,24 @@ done_entity() { } } else if (_entity == EN_3dface) { - // DXF can also represent a polygon as a 3DFace. This might be - // either a quad or a triangle (if two of the vertices are the - // same). We'll add the vertices to our list of vertices and then - // define the polygon. + // DXF can also represent a polygon as a 3DFace. This might be either a + // quad or a triangle (if two of the vertices are the same). We'll add + // the vertices to our list of vertices and then define the polygon. _verts.clear(); _verts.push_back(DXFVertex(_s)); _verts.push_back(DXFVertex(_r)); _verts.push_back(DXFVertex(_q)); _verts.push_back(DXFVertex(_p)); - + nassertv(_layer!=NULL); ((DXFToEggLayer *)_layer)->add_polygon(this); } } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggConverter::done_entity -// Access: Protected, Virtual -// Description: A hook for user code, if desired. This function is -// called when some unexpected error occurs while -// reading the DXF file. -//////////////////////////////////////////////////////////////////// +/** + * A hook for user code, if desired. This function is called when some + * unexpected error occurs while reading the DXF file. + */ void DXFToEggConverter:: error() { _error = true; diff --git a/pandatool/src/dxfegg/dxfToEggConverter.h b/pandatool/src/dxfegg/dxfToEggConverter.h index 7bbdf7b5d6..8a10a50fc3 100644 --- a/pandatool/src/dxfegg/dxfToEggConverter.h +++ b/pandatool/src/dxfegg/dxfToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: dxfToEggConverter.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEggConverter.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFTOEGGCONVERTER_H #define DXFTOEGGCONVERTER_H @@ -20,11 +19,10 @@ #include "somethingToEggConverter.h" #include "dxfFile.h" -//////////////////////////////////////////////////////////////////// -// Class : DXFToEggConverter -// Description : This class supervises the construction of an EggData -// structure from a DXF file. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a DXF + * file. + */ class DXFToEggConverter : public SomethingToEggConverter, public DXFFile { public: DXFToEggConverter(); @@ -48,5 +46,3 @@ protected: }; #endif - - diff --git a/pandatool/src/dxfegg/dxfToEggLayer.cxx b/pandatool/src/dxfegg/dxfToEggLayer.cxx index bf0c52e8ea..333cd5a69e 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.cxx +++ b/pandatool/src/dxfegg/dxfToEggLayer.cxx @@ -1,16 +1,15 @@ -// Filename: dxfToEggLayer.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEggLayer.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfToEggLayer.h" #include "dxfToEggConverter.h" @@ -23,11 +22,9 @@ #include "eggVertexPool.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggLayer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFToEggLayer:: DXFToEggLayer(const string &name, EggGroupNode *parent) : DXFLayer(name) { _group = new EggGroup(name); @@ -37,14 +34,11 @@ DXFToEggLayer(const string &name, EggGroupNode *parent) : DXFLayer(name) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggLayer::add_polygon -// Access: Public -// Description: Given that done_entity() has just been called and that -// the current entity represents a polygon, adds the -// corresponding polygon to the layer's EggGroup and -// vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * Given that done_entity() has just been called and that the current entity + * represents a polygon, adds the corresponding polygon to the layer's + * EggGroup and vertex pool. + */ void DXFToEggLayer:: add_polygon(const DXFToEggConverter *entity) { EggPolygon *poly = new EggPolygon; @@ -53,13 +47,12 @@ add_polygon(const DXFToEggConverter *entity) { const DXFFile::Color &color = entity->get_color(); poly->set_color(LColor(color.r, color.g, color.b, 1.0)); - // A polyline's vertices are stored in the attached vector by - // dxf.cxx. They were defined in the DXF file using a series of - // "VERTEX" entries. + // A polyline's vertices are stored in the attached vector by dxf.cxx. They + // were defined in the DXF file using a series of "VERTEX" entries. - // For a 3dface, the vertices are defined explicitly as part of the - // entity; but in this case, they were added to the vector before - // add_polygon() was called. + // For a 3dface, the vertices are defined explicitly as part of the entity; + // but in this case, they were added to the vector before add_polygon() was + // called. DXFVertices::const_iterator vi; for (vi = entity->_verts.begin(); @@ -72,12 +65,9 @@ add_polygon(const DXFToEggConverter *entity) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggLayer::add_line -// Access: Public -// Description: Similar to add_polygon(), but adds a set of point -// lights instead. -//////////////////////////////////////////////////////////////////// +/** + * Similar to add_polygon(), but adds a set of point lights instead. + */ void DXFToEggLayer:: add_line(const DXFToEggConverter *entity) { EggLine *line = new EggLine; @@ -95,14 +85,11 @@ add_line(const DXFToEggConverter *entity) { } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEggLayer::add_vertex -// Access: Public -// Description: Adds a unique vertex to the layer's vertex pool and -// returns it. If the vertex was already defined -// previously, returns the original definition. This is -// designed to share the common vertices within a layer. -//////////////////////////////////////////////////////////////////// +/** + * Adds a unique vertex to the layer's vertex pool and returns it. If the + * vertex was already defined previously, returns the original definition. + * This is designed to share the common vertices within a layer. + */ EggVertex *DXFToEggLayer:: add_vertex(const DXFVertex &vert) { EggVertex egg_vert; diff --git a/pandatool/src/dxfegg/dxfToEggLayer.h b/pandatool/src/dxfegg/dxfToEggLayer.h index f982a5c138..45a053e4df 100644 --- a/pandatool/src/dxfegg/dxfToEggLayer.h +++ b/pandatool/src/dxfegg/dxfToEggLayer.h @@ -1,16 +1,15 @@ -// Filename: dxfToEggLayer.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEggLayer.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFTOEGGLAYER_H #define DXFTOEGGLAYER_H @@ -27,14 +26,12 @@ class EggVertex; class DXFVertex; class DXFToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : DXFToEggLayer -// Description : The specialization of DXFLayer used by -// DXFToEggConverter. It contains a pointer to an -// EggGroup and a vertex pool; these are used to build -// up polygons grouped by layer in the egg file as each -// polygon is read from the DXF file. -//////////////////////////////////////////////////////////////////// +/** + * The specialization of DXFLayer used by DXFToEggConverter. It contains a + * pointer to an EggGroup and a vertex pool; these are used to build up + * polygons grouped by layer in the egg file as each polygon is read from the + * DXF file. + */ class DXFToEggLayer : public DXFLayer { public: DXFToEggLayer(const string &name, EggGroupNode *parent); @@ -42,7 +39,7 @@ public: void add_polygon(const DXFToEggConverter *entity); void add_line(const DXFToEggConverter *entity); EggVertex *add_vertex(const DXFVertex &vertex); - + PT(EggVertexPool) _vpool; PT(EggGroup) _group; }; diff --git a/pandatool/src/dxfprogs/dxfPoints.cxx b/pandatool/src/dxfprogs/dxfPoints.cxx index 14f50bb696..2dba8ae801 100644 --- a/pandatool/src/dxfprogs/dxfPoints.cxx +++ b/pandatool/src/dxfprogs/dxfPoints.cxx @@ -1,31 +1,28 @@ -// Filename: dxfPoints.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfPoints.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfPoints.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFPoints::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFPoints:: DXFPoints() : WithOutputFile(true, true, false) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = ".txt"; set_program_brief("extract points from AutoCAD .dxf files"); @@ -41,24 +38,19 @@ DXFPoints() : } -//////////////////////////////////////////////////////////////////// -// Function: DXFPoints::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXFPoints:: run() { // Invoke the DXFFile base class to process the input file. process(_input_filename); } -//////////////////////////////////////////////////////////////////// -// Function: DXFPoints::done_entity -// Access: Public, Virtual -// Description: This is inherited from DXFFile, and gets called as -// each entity (face, line, whatever) has finished -// processing. -//////////////////////////////////////////////////////////////////// +/** + * This is inherited from DXFFile, and gets called as each entity (face, line, + * whatever) has finished processing. + */ void DXFPoints:: done_entity() { if (_entity == EN_point) { @@ -70,11 +62,9 @@ done_entity() { } } -//////////////////////////////////////////////////////////////////// -// Function: DXFPoints::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool DXFPoints:: handle_args(ProgramBase::Args &args) { if (args.empty()) { diff --git a/pandatool/src/dxfprogs/dxfPoints.h b/pandatool/src/dxfprogs/dxfPoints.h index a70b8c1d4e..9715b5d655 100644 --- a/pandatool/src/dxfprogs/dxfPoints.h +++ b/pandatool/src/dxfprogs/dxfPoints.h @@ -1,16 +1,15 @@ -// Filename: dxfPoints.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfPoints.h + * @author drose + * @date 2004-05-04 + */ #ifndef DXFPOINTS_H #define DXFPOINTS_H @@ -21,11 +20,10 @@ #include "dxfFile.h" -//////////////////////////////////////////////////////////////////// -// Class : DXFPoints -// Description : A simple program to read a dxf file and list the -// points contained within it to a text file. -//////////////////////////////////////////////////////////////////// +/** + * A simple program to read a dxf file and list the points contained within it + * to a text file. + */ class DXFPoints : public ProgramBase, public WithOutputFile, public DXFFile { public: DXFPoints(); @@ -41,4 +39,3 @@ protected: }; #endif - diff --git a/pandatool/src/dxfprogs/dxfToEgg.cxx b/pandatool/src/dxfprogs/dxfToEgg.cxx index 9f2cc149f2..512c790b96 100644 --- a/pandatool/src/dxfprogs/dxfToEgg.cxx +++ b/pandatool/src/dxfprogs/dxfToEgg.cxx @@ -1,27 +1,24 @@ -// Filename: dxfToEgg.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEgg.cxx + * @author drose + * @date 2004-05-04 + */ #include "dxfToEgg.h" #include "dxfToEggConverter.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: DXFToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DXFToEgg:: DXFToEgg() : SomethingToEgg("DXF", ".dxf") @@ -45,11 +42,9 @@ DXFToEgg() : _coordinate_system = CS_zup_right; } -//////////////////////////////////////////////////////////////////// -// Function: DXFToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void DXFToEgg:: run() { nout << "Reading " << _input_filename << "\n"; diff --git a/pandatool/src/dxfprogs/dxfToEgg.h b/pandatool/src/dxfprogs/dxfToEgg.h index ff86771c77..cb8b5b6b79 100644 --- a/pandatool/src/dxfprogs/dxfToEgg.h +++ b/pandatool/src/dxfprogs/dxfToEgg.h @@ -1,17 +1,16 @@ -// Filename: dxfToEgg.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file dxfToEgg.h + * @author drose + * @date 2004-05-04 + */ + #ifndef DXFTOEGG_H #define DXFTOEGG_H @@ -20,11 +19,9 @@ #include "somethingToEgg.h" #include "dxfToEggConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : DXFToEgg -// Description : A program to read a DXF file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a DXF file and generate an egg file. + */ class DXFToEgg : public SomethingToEgg { public: DXFToEgg(); @@ -33,5 +30,3 @@ public: }; #endif - - diff --git a/pandatool/src/dxfprogs/eggToDXF.cxx b/pandatool/src/dxfprogs/eggToDXF.cxx index e2404b2007..3a3b24d564 100644 --- a/pandatool/src/dxfprogs/eggToDXF.cxx +++ b/pandatool/src/dxfprogs/eggToDXF.cxx @@ -1,27 +1,24 @@ -// Filename: eggToDXF.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDXF.cxx + * @author drose + * @date 2004-05-04 + */ #include "eggToDXF.h" #include "eggPolygon.h" #include "dcast.h" #include "pystub.h" - -//////////////////////////////////////////////////////////////////// -// Function: EggToDXF::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// + +/** + * + */ EggToDXF:: EggToDXF() : EggToSomething("DXF", ".dxf", true, false) @@ -43,11 +40,9 @@ EggToDXF() : _got_coordinate_system = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXF::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToDXF:: run() { get_layers(_data); @@ -56,13 +51,12 @@ run() { exit(1); } - // uniquify_names("layer", _layers.begin(), _layers.end()); - + // uniquify_names("layer", _layers.begin(), _layers.end()); + ostream &out = get_output(); - // Autodesk says we don't need the header, but some DXF-reading - // programs might get confused if it's missing. We'll write an - // empty header. + // Autodesk says we don't need the header, but some DXF-reading programs + // might get confused if it's missing. We'll write an empty header. out << "0\nSECTION\n" << "2\nHEADER\n" << "0\nENDSEC\n"; @@ -77,13 +71,10 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: get_layers -// Access: Private -// Description: Traverses the hierarchy, looking for groups that -// contain polygons. Any such groups are deemed to be -// layers, and are added to the layers set. -//////////////////////////////////////////////////////////////////// +/** + * Traverses the hierarchy, looking for groups that contain polygons. Any + * such groups are deemed to be layers, and are added to the layers set. + */ void EggToDXF:: get_layers(EggGroupNode *group) { bool has_polys = false; @@ -111,14 +102,11 @@ get_layers(EggGroupNode *group) { } -//////////////////////////////////////////////////////////////////// -// Function: write_tables -// Access: Private -// Description: Writes out the "layers", e.g. groups. This is just -// the layers definition in the tables section at the -// beginning of the file; the actual geometry gets -// written later, in write_entities(). -//////////////////////////////////////////////////////////////////// +/** + * Writes out the "layers", e.g. groups. This is just the layers definition + * in the tables section at the beginning of the file; the actual geometry + * gets written later, in write_entities(). + */ void EggToDXF:: write_tables(ostream &out) { out << "0\nSECTION\n" @@ -136,12 +124,9 @@ write_tables(ostream &out) { << "0\nENDSEC\n"; // End TABLES section. } -//////////////////////////////////////////////////////////////////// -// Function: write_entities -// Access: Private -// Description: Writes out the "entities", e.g. polygons, defined for -// all layers. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the "entities", e.g. polygons, defined for all layers. + */ void EggToDXF:: write_entities(ostream &out) { out << "0\nSECTION\n" diff --git a/pandatool/src/dxfprogs/eggToDXF.h b/pandatool/src/dxfprogs/eggToDXF.h index c6fa4770fc..0af0e999de 100644 --- a/pandatool/src/dxfprogs/eggToDXF.h +++ b/pandatool/src/dxfprogs/eggToDXF.h @@ -1,16 +1,15 @@ -// Filename: eggToDXF.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDXF.h + * @author drose + * @date 2004-05-04 + */ #ifndef EGGTODXF_H #define EGGTODXF_H @@ -22,10 +21,9 @@ class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : EggToDXF -// Description : A program to read an egg file and write a DXF file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write a DXF file. + */ class EggToDXF : public EggToSomething { public: EggToDXF(); @@ -43,4 +41,3 @@ private: }; #endif - diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.cxx b/pandatool/src/dxfprogs/eggToDXFLayer.cxx index 7046312eb5..c10c51f862 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.cxx +++ b/pandatool/src/dxfprogs/eggToDXFLayer.cxx @@ -1,16 +1,15 @@ -// Filename: eggToDXFLayer.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDXFLayer.cxx + * @author drose + * @date 2004-05-04 + */ #include "eggToDXFLayer.h" #include "eggToDXF.h" @@ -20,37 +19,31 @@ #include "eggPolygon.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToDXFLayer:: EggToDXFLayer(EggToDXF *egg2dxf, EggGroupNode *group) : - _egg2dxf(egg2dxf), _group(group) + _egg2dxf(egg2dxf), _group(group) { _layer_color = -1; } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToDXFLayer:: EggToDXFLayer(const EggToDXFLayer ©) : _egg2dxf(copy._egg2dxf), _group(copy._group), - _layer_color(copy._layer_color) + _layer_color(copy._layer_color) { // The copy constructor doesn't bother with the ColorCounts. } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToDXFLayer:: operator = (const EggToDXFLayer ©) { _egg2dxf = copy._egg2dxf; @@ -60,14 +53,11 @@ operator = (const EggToDXFLayer ©) { // The copy constructor doesn't bother with the ColorCounts. } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::add_color -// Access: Public -// Description: Records that one polygon is defined using the -// indicated color. This will get accumulated; the -// color used by the majority of polygons will become -// the layer color. -//////////////////////////////////////////////////////////////////// +/** + * Records that one polygon is defined using the indicated color. This will + * get accumulated; the color used by the majority of polygons will become the + * layer color. + */ void EggToDXFLayer:: add_color(const LColor &color) { int autocad_color = get_autocad_color(color); @@ -84,17 +74,14 @@ add_color(const LColor &color) { } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::choose_overall_color -// Access: Public -// Description: After all polygons have been accounted for, chooses -// the polygon color that occurred most often as the -// layer color. -//////////////////////////////////////////////////////////////////// +/** + * After all polygons have been accounted for, chooses the polygon color that + * occurred most often as the layer color. + */ void EggToDXFLayer:: choose_overall_color() { int max_count = 0; - + ColorCounts::iterator cci; for (cci = _color_counts.begin(); cci != _color_counts.end(); ++cci) { int count = (*cci).second; @@ -106,14 +93,11 @@ choose_overall_color() { } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::write_layer -// Access: Public -// Description: Writes the layer definition into the table at the -// beginning of the DXF file. This does not write the -// actual geometry; that gets done later by -// write_entities(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the layer definition into the table at the beginning of the DXF + * file. This does not write the actual geometry; that gets done later by + * write_entities(). + */ void EggToDXFLayer:: write_layer(ostream &out) { out << "0\nLAYER\n" @@ -123,11 +107,9 @@ write_layer(ostream &out) { << "6\nCONTINUOUS\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::write_polyline -// Access: Public -// Description: Writes a polygon as a POLYLINE entity. -//////////////////////////////////////////////////////////////////// +/** + * Writes a polygon as a POLYLINE entity. + */ void EggToDXFLayer:: write_polyline(EggPolygon *poly, ostream &out) { out << "0\nPOLYLINE\n" @@ -135,9 +117,9 @@ write_polyline(EggPolygon *poly, ostream &out) { << "66\n1\n" << "70\n1\n" << "62\n" << get_autocad_color(poly->get_color()) << "\n"; - - // Since DXF uses a clockwise ordering convention, we must - // reverse the order in which we write out the vertices. + + // Since DXF uses a clockwise ordering convention, we must reverse the order + // in which we write out the vertices. EggPolygon::reverse_iterator vi; for (vi = poly->rbegin(); vi != poly->rend(); ++vi) { EggVertex *vtx = (*vi); @@ -150,16 +132,14 @@ write_polyline(EggPolygon *poly, ostream &out) { out << "0\nSEQEND\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::write_3d_face -// Access: Public -// Description: Writes a polygon as a 3DFACE entity. -//////////////////////////////////////////////////////////////////// +/** + * Writes a polygon as a 3DFACE entity. + */ void EggToDXFLayer:: write_3d_face(EggPolygon *poly, ostream &out) { if (poly->size() > 4) { - // If we have a big polygon, we have to triangulate it, since - // 3DFaces can only be tris and quads. + // If we have a big polygon, we have to triangulate it, since 3DFaces can + // only be tris and quads. PT(EggGroup) group = new EggGroup; poly->triangulate_into(group, true); @@ -176,8 +156,8 @@ write_3d_face(EggPolygon *poly, ostream &out) { out << "0\n3DFACE\n" << "8\n" << _group->get_name() << "\n"; - // Since DXF uses a clockwise ordering convention, we must - // reverse the order in which we write out the vertices. + // Since DXF uses a clockwise ordering convention, we must reverse the + // order in which we write out the vertices. int i; EggPolygon::reverse_iterator vi; for (i = 0, vi = poly->rbegin(); vi != poly->rend(); ++i, ++vi) { @@ -195,14 +175,11 @@ write_3d_face(EggPolygon *poly, ostream &out) { } } } - -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::write_entities -// Access: Public -// Description: Writes out the "entities", e.g. polygons, defined for -// the current layer. -//////////////////////////////////////////////////////////////////// + +/** + * Writes out the "entities", e.g. polygons, defined for the current layer. + */ void EggToDXFLayer:: write_entities(ostream &out) { EggGroupNode::iterator ci; @@ -219,12 +196,10 @@ write_entities(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToDXFLayer::get_autocad_color -// Access: Private -// Description: Returns the AutoCAD color index that most closely -// matches the indicated EggColor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the AutoCAD color index that most closely matches the indicated + * EggColor. + */ int EggToDXFLayer:: get_autocad_color(const LColor &color) { typedef pmap ColorMap; diff --git a/pandatool/src/dxfprogs/eggToDXFLayer.h b/pandatool/src/dxfprogs/eggToDXFLayer.h index a479ca27b9..314346f7d0 100644 --- a/pandatool/src/dxfprogs/eggToDXFLayer.h +++ b/pandatool/src/dxfprogs/eggToDXFLayer.h @@ -1,16 +1,15 @@ -// Filename: eggToDXFLayer.h -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToDXFLayer.h + * @author drose + * @date 2004-05-04 + */ #ifndef EGGTODXFLAYER_H #define EGGTODXFLAYER_H @@ -24,11 +23,9 @@ class EggToDXF; class EggPolygon; class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : EggToDXFLayer -// Description : A single layer in the DXF file to be written by -// EggToDXF. -//////////////////////////////////////////////////////////////////// +/** + * A single layer in the DXF file to be written by EggToDXF. + */ class EggToDXFLayer { public: EggToDXFLayer(EggToDXF *egg2dxf, EggGroupNode *group); diff --git a/pandatool/src/egg-mkfont/eggMakeFont.cxx b/pandatool/src/egg-mkfont/eggMakeFont.cxx index 981d932b79..f51fbebc7a 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.cxx +++ b/pandatool/src/egg-mkfont/eggMakeFont.cxx @@ -1,16 +1,15 @@ -// Filename: eggMakeFont.cxx -// Created by: drose (16Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeFont.cxx + * @author drose + * @date 2001-02-16 + */ #include "eggMakeFont.h" #include "rangeIterator.h" @@ -34,11 +33,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMakeFont:: EggMakeFont() : EggWriter(true, false) { set_program_brief("generates .egg files with rasterized font glyphs"); @@ -211,7 +208,7 @@ EggMakeFont() : EggWriter(true, false) { "Specify the size of the palette texture images. This is used if " "-nopal is not specified.", &EggMakeFont::dispatch_int_pair, NULL, _palette_size); - + add_option ("face", "index", 0, "Specify the face index of the particular face within the font file " @@ -237,14 +234,11 @@ EggMakeFont() : EggWriter(true, false) { } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggMakeFont:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -257,11 +251,9 @@ handle_args(ProgramBase::Args &args) { return EggWriter::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMakeFont:: run() { if (has_output_filename() && !get_output_filename().get_dirname().empty()) { @@ -280,8 +272,8 @@ run() { } if (!_got_scale_factor) { - // The default scale factor is 4 if we are not using FreeType's - // antialias, or 2 if we are. + // The default scale factor is 4 if we are not using FreeType's antialias, + // or 2 if we are. if (_generate_distance_field) { _scale_factor = 1.0; } else if (_no_native_aa) { @@ -297,8 +289,8 @@ run() { _text_maker->set_pixels_per_unit(_pixels_per_unit); _text_maker->set_scale_factor(_scale_factor); - // The text_maker may have had to adjust the pixels per unit and the - // scale factor according to what the font supports. + // The text_maker may have had to adjust the pixels per unit and the scale + // factor according to what the font supports. _pixels_per_unit = _text_maker->get_pixels_per_unit(); _scale_factor = _text_maker->get_scale_factor(); @@ -306,18 +298,17 @@ run() { nout << "Using " << _text_maker->get_font_pixel_size() << "-pixel font.\n"; } - // Now we may want to tweak the scale factor so that fonts will - // actually be generated big. We have to do this after we have - // already send the current _scale_factor through the _text_maker - // for validation. + // Now we may want to tweak the scale factor so that fonts will actually be + // generated big. We have to do this after we have already send the current + // _scale_factor through the _text_maker for validation. _palettize_scale_factor = _scale_factor; if (_scale_factor != 1.0 && (_no_reduce || !_no_palettize)) { - // If _no_reduce is true (-nr was specified), we want to keep the - // glyph textures full-sized, because the user asked for that. + // If _no_reduce is true (-nr was specified), we want to keep the glyph + // textures full-sized, because the user asked for that. - // If _no_palettize is false (-nopal was not specified), we still - // want to keep the glyph textures full-sized, because the - // palettizer will reduce them later. + // If _no_palettize is false (-nopal was not specified), we still want to + // keep the glyph textures full-sized, because the palettizer will reduce + // them later. _tex_margin = (int)(_tex_margin * _scale_factor); _poly_margin *= _scale_factor; @@ -328,9 +319,9 @@ run() { } if (_no_reduce) { - // If -nr was specified, but we're still palettizing, we don't - // even want to reduce the palette images. Instead, we'll - // generate extra-large palette images. + // If -nr was specified, but we're still palettizing, we don't even want + // to reduce the palette images. Instead, we'll generate extra-large + // palette images. _palette_size[0] = (int)(_palette_size[0] * _palettize_scale_factor); _palette_size[1] = (int)(_palette_size[1] * _palettize_scale_factor); _palettize_scale_factor = 1.0; @@ -343,7 +334,7 @@ run() { _range.add_singleton(0xa1); // Upside down exclamation mark _range.add_singleton(0xa9); // Copyright sign _range.add_singleton(0xab); // Left double angle quote - //_range.add_singleton(0xae); // Registered sign + // _range.add_singleton(0xae); Registered sign _range.add_singleton(0xb0); // Degree symbol _range.add_singleton(0xb5); // Mu/micro _range.add_singleton(0xb8); // Cedilla @@ -352,9 +343,8 @@ run() { _range.add_singleton(0xc6); // AE ligature _range.add_singleton(0xc7); // C cedilla - //_range.add_singleton(0xd0); // Upper-case Eth - //_range.add_singleton(0xd8); // Upper-case O with line - //_range.add_singleton(0xde); // Upper-case Thorn + // _range.add_singleton(0xd0); Upper-case Eth _range.add_singleton(0xd8); + // Upper-case O with line _range.add_singleton(0xde); Upper-case Thorn _range.add_singleton(0xdf); // German Eszet _range.add_singleton(0xe6); // ae ligature _range.add_singleton(0xe7); // c cedilla @@ -362,7 +352,7 @@ run() { _range.add_singleton(0xf8); // Lower-case O with line _range.add_singleton(0xfe); // Lower-case Thorn - //_range.add_singleton(0x03c0); // pi + // _range.add_singleton(0x03c0); pi // Dotless i and j, for combining purposes. _range.add_singleton(0x0131); @@ -398,9 +388,8 @@ run() { _format = EggTexture::F_rgba; } else { if (_fg[0] == 1.0 && _bg[0] == 1.0 && _interior[0] == 1.0) { - // A special case: we only need an alpha channel. Copy the - // alpha data into the color channels so we can write out a - // one-channel image. + // A special case: we only need an alpha channel. Copy the alpha data + // into the color channels so we can write out a one-channel image. _fg[0] = _fg[1] = _fg[2] = _fg[3]; _bg[0] = _bg[1] = _bg[2] = _bg[3]; _interior[0] = _interior[1] = _interior[2] = _interior[3]; @@ -421,19 +410,18 @@ run() { } } - // Create a global Palettizer object. We'll use this even if the - // user specified -nopal, if nothing else just to hold all of the - // TextureImage pointers. + // Create a global Palettizer object. We'll use this even if the user + // specified -nopal, if nothing else just to hold all of the TextureImage + // pointers. pal = new Palettizer; pal->_generated_image_pattern = _output_palette_pattern; pal->_omit_solitary = false; pal->_round_uvs = false; - // Generate a txa script for the palettizer. We have the palettizer - // reduce all of the texture images by the inverse of our scale - // factor. + // Generate a txa script for the palettizer. We have the palettizer reduce + // all of the texture images by the inverse of our scale factor. char buffer[1024]; - sprintf(buffer, ":margin 0;:coverage 1000;:background %f %f %f %f;:palette %d %d;*: %f%% keep-format", + sprintf(buffer, ":margin 0;:coverage 1000;:background %f %f %f %f;:palette %d %d;*: %f%% keep-format", _bg[0], _bg[1], _bg[2], _bg[3], _palette_size[0], _palette_size[1], 100.0 / _palettize_scale_factor); @@ -442,9 +430,9 @@ run() { pal->all_params_set(); - // Now create all the egg structures. We can't use _data, since we - // want to pass this object to the palettizer, which will try to up - // its reference count. + // Now create all the egg structures. We can't use _data, since we want to + // pass this object to the palettizer, which will try to up its reference + // count. PT(EggData) egg_data = new EggData; _group = new EggGroup(); egg_data->add_child(_group); @@ -453,8 +441,8 @@ run() { _vpool = new EggVertexPool("vpool"); _group->add_child(_vpool); - // Make the group a sequence, as a convenience. If we view the - // egg file directly we can see all the characters one at a time. + // Make the group a sequence, as a convenience. If we view the egg file + // directly we can see all the characters one at a time. _group->set_switch_flag(true); _group->set_switch_fps(2.0); @@ -472,7 +460,8 @@ run() { _text_maker->set_distance_field_radius(4); } - // Also create an egg group indicating the font's design size and poly margin. + // Also create an egg group indicating the font's design size and poly + // margin. EggGroup *ds_group = new EggGroup("ds"); _group->add_child(ds_group); EggVertex *vtx = make_vertex(LPoint2d(margin / _pixels_per_unit, _text_maker->get_line_height())); @@ -495,8 +484,8 @@ run() { } if (_no_palettize) { - // Ok, no palettize step; just write out the egg file and all of - // the textures. + // Ok, no palettize step; just write out the egg file and all of the + // textures. Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureImage *texture = (*ti); @@ -506,8 +495,8 @@ run() { egg_data->write_egg(get_output()); } else { - // Pass the generated egg structure through egg-palettize, without - // writing it to disk first. + // Pass the generated egg structure through egg-palettize, without writing + // it to disk first. string name = get_output_filename().get_basename(); EggFile *egg_file = pal->get_egg_file(name); egg_file->from_command_line(egg_data, "", get_output_filename(), @@ -520,27 +509,23 @@ run() { if (!pal->write_eggs()) { exit(1); } - // pal->report_pi(); + // pal->report_pi(); } } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::dispatch_range -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggMakeFont:: dispatch_range(const string &, const string &arg, void *var) { RangeDescription *ip = (RangeDescription *)var; return ip->parse_parameter(arg); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::make_vertex -// Access: Private -// Description: Allocates and returns a new vertex from the vertex -// pool representing the indicated 2-d coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new vertex from the vertex pool representing the + * indicated 2-d coordinates. + */ EggVertex *EggMakeFont:: make_vertex(const LPoint2d &xy) { return @@ -548,12 +533,9 @@ make_vertex(const LPoint2d &xy) { LVector3d::rfu(xy[0], 0.0, xy[1], _coordinate_system)); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::add_character -// Access: Private -// Description: Generates the indicated character and adds it to the -// font description. -//////////////////////////////////////////////////////////////////// +/** + * Generates the indicated character and adds it to the font description. + */ void EggMakeFont:: add_character(int code) { PNMTextGlyph *glyph = _text_maker->get_glyph(code); @@ -566,11 +548,9 @@ add_character(int code) { } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::make_geom -// Access: Private -// Description: Creates the actual geometry for the glyph. -//////////////////////////////////////////////////////////////////// +/** + * Creates the actual geometry for the glyph. + */ void EggMakeFont:: make_geom(PNMTextGlyph *glyph, int character) { // Create an egg group to hold the polygon. @@ -583,13 +563,13 @@ make_geom(PNMTextGlyph *glyph, int character) { int bitmap_left = glyph->get_left(); double tex_x_size = glyph->get_width(); double tex_y_size = glyph->get_height(); - + double poly_margin = _poly_margin; double x_origin = _tex_margin; double y_origin = _tex_margin; double page_y_size = tex_y_size + _tex_margin * 2; double page_x_size = tex_x_size + _tex_margin * 2; - + // Determine the corners of the rectangle in geometric units. double tex_poly_margin = poly_margin / _pixels_per_unit; double origin_y = bitmap_top / _pixels_per_unit; @@ -598,24 +578,24 @@ make_geom(PNMTextGlyph *glyph, int character) { double left = origin_x - tex_poly_margin; double bottom = origin_y - tex_y_size / _pixels_per_unit - tex_poly_margin; double right = origin_x + tex_x_size / _pixels_per_unit + tex_poly_margin; - + // And the corresponding corners in UV units. double uv_top = 1.0f - (double)(y_origin - poly_margin) / page_y_size; double uv_left = (double)(x_origin - poly_margin) / page_x_size; double uv_bottom = 1.0f - (double)(y_origin + poly_margin + tex_y_size) / page_y_size; double uv_right = (double)(x_origin + poly_margin + tex_x_size) / page_x_size; - + // Create the vertices for the polygon. EggVertex *v1 = make_vertex(LPoint2d(left, bottom)); EggVertex *v2 = make_vertex(LPoint2d(right, bottom)); EggVertex *v3 = make_vertex(LPoint2d(right, top)); EggVertex *v4 = make_vertex(LPoint2d(left, top)); - + v1->set_uv(LTexCoordd(uv_left, uv_bottom)); v2->set_uv(LTexCoordd(uv_right, uv_bottom)); v3->set_uv(LTexCoordd(uv_right, uv_top)); v4->set_uv(LTexCoordd(uv_left, uv_top)); - + EggPolygon *poly = new EggPolygon(); group->add_child(poly); poly->set_texture(get_tref(glyph, character)); @@ -626,8 +606,7 @@ make_geom(PNMTextGlyph *glyph, int character) { poly->add_vertex(v4); } - // Now create a single point where the origin of the next character - // will be. + // Now create a single point where the origin of the next character will be. EggVertex *v0 = make_vertex(LPoint2d(glyph->get_advance() / _pixels_per_unit + _render_margin, 0.0)); EggPoint *point = new EggPoint; @@ -635,13 +614,10 @@ make_geom(PNMTextGlyph *glyph, int character) { point->add_vertex(v0); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::get_tref -// Access: Private -// Description: Returns the egg texture reference for a particular -// glyph, creating it if it has not already been -// created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the egg texture reference for a particular glyph, creating it if it + * has not already been created. + */ EggTexture *EggMakeFont:: get_tref(PNMTextGlyph *glyph, int character) { TRefs::iterator ti = _trefs.find(glyph); @@ -654,12 +630,10 @@ get_tref(PNMTextGlyph *glyph, int character) { return tref; } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::make_tref -// Access: Private -// Description: Generates a texture image for the indicated glyph, -// and returns its egg reference. -//////////////////////////////////////////////////////////////////// +/** + * Generates a texture image for the indicated glyph, and returns its egg + * reference. + */ EggTexture *EggMakeFont:: make_tref(PNMTextGlyph *glyph, int character) { char buffer[1024]; @@ -673,17 +647,16 @@ make_tref(PNMTextGlyph *glyph, int character) { image.alpha_fill(_bg[3]); } if (_got_interior) { - glyph->place(image, -glyph->get_left() + _tex_margin, + glyph->place(image, -glyph->get_left() + _tex_margin, glyph->get_top() + _tex_margin, _fg, _interior); } else { - glyph->place(image, -glyph->get_left() + _tex_margin, + glyph->place(image, -glyph->get_left() + _tex_margin, glyph->get_top() + _tex_margin, _fg); } - // We don't write the image to disk immediately, since it might just - // get palettized. But we do record it in a TextureImage object - // within the global Palettizer, so that it may be written out - // later. + // We don't write the image to disk immediately, since it might just get + // palettized. But we do record it in a TextureImage object within the + // global Palettizer, so that it may be written out later. string name = texture_filename.get_basename_wo_extension(); TextureImage *texture = pal->get_texture(name); @@ -703,12 +676,10 @@ make_tref(PNMTextGlyph *glyph, int character) { return tref; } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::add_extra_glyphs -// Access: Private -// Description: Reads the indicated filename and adds any numbered -// groups into the current egg file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated filename and adds any numbered groups into the current + * egg file. + */ void EggMakeFont:: add_extra_glyphs(const Filename &extra_filename) { PT(EggData) extra_data = new EggData; @@ -720,13 +691,10 @@ add_extra_glyphs(const Filename &extra_filename) { _group->steal_children(*extra_data); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::r_add_extra_glyphs -// Access: Private -// Description: Recursively searches for numbered groups in the -// indicated egg file, and copies them to the current -// egg file. -//////////////////////////////////////////////////////////////////// +/** + * Recursively searches for numbered groups in the indicated egg file, and + * copies them to the current egg file. + */ void EggMakeFont:: r_add_extra_glyphs(EggGroupNode *egg_group) { if (egg_group->is_of_type(EggGroup::get_class_type())) { @@ -748,12 +716,10 @@ r_add_extra_glyphs(EggGroupNode *egg_group) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeFont::is_numeric -// Access: Private, Static -// Description: Returns true if the indicated string is all numeric -// digits, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated string is all numeric digits, false + * otherwise. + */ bool EggMakeFont:: is_numeric(const string &str) { if (str.empty()) { diff --git a/pandatool/src/egg-mkfont/eggMakeFont.h b/pandatool/src/egg-mkfont/eggMakeFont.h index b11712df4e..20bd99f01f 100644 --- a/pandatool/src/egg-mkfont/eggMakeFont.h +++ b/pandatool/src/egg-mkfont/eggMakeFont.h @@ -1,16 +1,15 @@ -// Filename: eggMakeFont.h -// Created by: drose (16Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeFont.h + * @author drose + * @date 2001-02-16 + */ #ifndef EGGMAKEFONT_H #define EGGMAKEFONT_H @@ -30,15 +29,12 @@ class EggVertexPool; class EggGroup; class TextureImage; -//////////////////////////////////////////////////////////////////// -// Class : EggMakeFont -// Description : This program uses FreeType to generate an egg file -// and a series of texture images from a font file -// input, such as a TTF file. The resulting egg file -// can be loaded in Panda as a StaticTextFont object for -// rendering text, even if FreeType is not compiled into -// the executing Panda. -//////////////////////////////////////////////////////////////////// +/** + * This program uses FreeType to generate an egg file and a series of texture + * images from a font file input, such as a TTF file. The resulting egg file + * can be loaded in Panda as a StaticTextFont object for rendering text, even + * if FreeType is not compiled into the executing Panda. + */ class EggMakeFont : public EggWriter { public: EggMakeFont(); @@ -87,7 +83,7 @@ private: string _output_palette_pattern; PNMTextMaker *_text_maker; - + EggTexture::Format _format; int _num_channels; EggVertexPool *_vpool; @@ -102,4 +98,3 @@ private: #endif - diff --git a/pandatool/src/egg-mkfont/rangeDescription.I b/pandatool/src/egg-mkfont/rangeDescription.I index 68f6f34eab..b19912d303 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.I +++ b/pandatool/src/egg-mkfont/rangeDescription.I @@ -1,54 +1,43 @@ -// Filename: rangeDescription.I -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeDescription.I + * @author drose + * @date 2003-09-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::add_singleton -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RangeDescription:: add_singleton(int code) { _range_list.push_back(Range(code)); } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::add_range -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void RangeDescription:: add_range(int from_code, int to_code) { _range_list.push_back(Range(from_code, to_code)); } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::is_empty -// Access: Public -// Description: Returns true if there are no codes described in the -// range. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no codes described in the range. + */ INLINE bool RangeDescription:: is_empty() const { return _range_list.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::Range::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RangeDescription::Range:: Range(int code) : _from_code(code), @@ -56,11 +45,9 @@ Range(int code) : { } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::Range::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE RangeDescription::Range:: Range(int from_code, int to_code) : _from_code(from_code), diff --git a/pandatool/src/egg-mkfont/rangeDescription.cxx b/pandatool/src/egg-mkfont/rangeDescription.cxx index 57d562e65f..bedfc086ea 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.cxx +++ b/pandatool/src/egg-mkfont/rangeDescription.cxx @@ -1,45 +1,38 @@ -// Filename: rangeDescription.cxx -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeDescription.cxx + * @author drose + * @date 2003-09-07 + */ #include "rangeDescription.h" #include "string_utils.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ RangeDescription:: RangeDescription() { } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::parse_parameter -// Access: Public -// Description: Parses a string of comma- and hyphen-delimited -// unicode values, in decimal and/or hex, including -// possible bracket-delimited ASCII characters, as may -// have been passed on a command line. Returns true if -// the parameter is parsed correctly, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Parses a string of comma- and hyphen-delimited unicode values, in decimal + * and/or hex, including possible bracket-delimited ASCII characters, as may + * have been passed on a command line. Returns true if the parameter is + * parsed correctly, false otherwise. + */ bool RangeDescription:: parse_parameter(const string ¶m) { - // First, go through and separate the string by commas. We have to - // do this by hand instead of calling tokenize(), because we also - // have to scan for square brackets, which may contain nested - // commas. + // First, go through and separate the string by commas. We have to do this + // by hand instead of calling tokenize(), because we also have to scan for + // square brackets, which may contain nested commas. size_t p = 0; while (p < param.length()) { size_t q = param.find_first_of("[,", p); @@ -52,8 +45,8 @@ parse_parameter(const string ¶m) { if (param[q] == '[') { // A square bracket means we must search for the matching square - // bracket. However, a right bracket immediately after the left - // bracket doesn't count; we start the scan after that. + // bracket. However, a right bracket immediately after the left bracket + // doesn't count; we start the scan after that. p = param.find("]", q + 2); if ( p == string::npos) { nout << "Unclosed open bracket.\n"; @@ -65,8 +58,8 @@ parse_parameter(const string ¶m) { p = p + 1; } else { - // Otherwise, if the separator was just a comma, the next - // character begins the next word. + // Otherwise, if the separator was just a comma, the next character + // begins the next word. p = q + 1; } } @@ -74,11 +67,9 @@ parse_parameter(const string ¶m) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void RangeDescription:: output(ostream &out) const { bool first_time = true; @@ -97,14 +88,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::parse_word -// Access: Private -// Description: Parses a single "word", i.e. the text delimited by -// commas, that might be listed on the command line. -// This is generally either the empty string, a single -// number, or a pair of numbers separated by a hyphen. -//////////////////////////////////////////////////////////////////// +/** + * Parses a single "word", i.e. the text delimited by commas, that might be + * listed on the command line. This is generally either the empty string, a + * single number, or a pair of numbers separated by a hyphen. + */ bool RangeDescription:: parse_word(const string &word) { if (word.empty()) { @@ -132,20 +120,16 @@ parse_word(const string &word) { } add_range(from_code, to_code); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::parse_code -// Access: Private -// Description: Parses a single numeric value, either decimal or -// hexadecimal, and stores it in the indicated -// parameter. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Parses a single numeric value, either decimal or hexadecimal, and stores it + * in the indicated parameter. Returns true if successful, false otherwise. + */ bool RangeDescription:: -parse_code(const string &word, int &code) { +parse_code(const string &word, int &code) { string str = trim(word); const char *nptr = str.c_str(); char *endptr; @@ -158,12 +142,9 @@ parse_code(const string &word, int &code) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: RangeDescription::parse_bracket -// Access: Private -// Description: Parses the text listed between square brackets on the -// command line. -//////////////////////////////////////////////////////////////////// +/** + * Parses the text listed between square brackets on the command line. + */ bool RangeDescription:: parse_bracket(const string &str) { string::const_iterator si; diff --git a/pandatool/src/egg-mkfont/rangeDescription.h b/pandatool/src/egg-mkfont/rangeDescription.h index 3c6268df64..d1e26b573d 100644 --- a/pandatool/src/egg-mkfont/rangeDescription.h +++ b/pandatool/src/egg-mkfont/rangeDescription.h @@ -1,16 +1,15 @@ -// Filename: rangeDescription.h -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeDescription.h + * @author drose + * @date 2003-09-07 + */ #ifndef RANGEDESCRIPTION_H #define RANGEDESCRIPTION_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : RangeDescription -// Description : This describes a sparse range of Unicode character -// codes for conversion that may be specified on the -// command line. -//////////////////////////////////////////////////////////////////// +/** + * This describes a sparse range of Unicode character codes for conversion + * that may be specified on the command line. + */ class RangeDescription { public: RangeDescription(); @@ -61,4 +58,3 @@ INLINE ostream &operator << (ostream &out, const RangeDescription &range); #include "rangeDescription.I" #endif - diff --git a/pandatool/src/egg-mkfont/rangeIterator.I b/pandatool/src/egg-mkfont/rangeIterator.I index 88bf43a186..5d34d4ec94 100644 --- a/pandatool/src/egg-mkfont/rangeIterator.I +++ b/pandatool/src/egg-mkfont/rangeIterator.I @@ -1,35 +1,28 @@ -// Filename: rangeIterator.I -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeIterator.I + * @author drose + * @date 2003-09-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: RangeIterator::get_code -// Access: Public -// Description: Returns the current Unicode value represented by the -// iterator, or -1 if the iterator has reached the end. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current Unicode value represented by the iterator, or -1 if the + * iterator has reached the end. + */ INLINE int RangeIterator:: get_code() const { return _code; } -//////////////////////////////////////////////////////////////////// -// Function: RangeIterator::eof -// Access: Public -// Description: Returns true if all the code have been retrieved, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all the code have been retrieved, false otherwise. + */ INLINE bool RangeIterator:: eof() const { return (_it == _desc._range_list.end()); diff --git a/pandatool/src/egg-mkfont/rangeIterator.cxx b/pandatool/src/egg-mkfont/rangeIterator.cxx index 1d7f1d7783..0050c80b3b 100644 --- a/pandatool/src/egg-mkfont/rangeIterator.cxx +++ b/pandatool/src/egg-mkfont/rangeIterator.cxx @@ -1,30 +1,26 @@ -// Filename: rangeIterator.cxx -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeIterator.cxx + * @author drose + * @date 2003-09-07 + */ #include "rangeIterator.h" -//////////////////////////////////////////////////////////////////// -// Function: RangeIterator::Constructor -// Access: Public -// Description: Constructs an iterator to walk through the codes on -// the descriptor. It is important not to modify the -// RangeDescription object during the lifetime of the -// iterator. -//////////////////////////////////////////////////////////////////// +/** + * Constructs an iterator to walk through the codes on the descriptor. It is + * important not to modify the RangeDescription object during the lifetime of + * the iterator. + */ RangeIterator:: RangeIterator(const RangeDescription &desc) : - _desc(desc) + _desc(desc) { _it = _desc._range_list.begin(); if (_it == _desc._range_list.end()) { @@ -35,13 +31,10 @@ RangeIterator(const RangeDescription &desc) : } } -//////////////////////////////////////////////////////////////////// -// Function: RangeIterator::next -// Access: Public -// Description: Advances the iterator to the next code. Returns true -// if there is a next code, or false if there are no -// mode codes. -//////////////////////////////////////////////////////////////////// +/** + * Advances the iterator to the next code. Returns true if there is a next + * code, or false if there are no mode codes. + */ bool RangeIterator:: next() { do { @@ -62,8 +55,8 @@ next() { _code = (*_it)._from_code; } - // If this code has already been generated, repeat and skip to the - // next one. + // If this code has already been generated, repeat and skip to the next + // one. } while (!_codes_generated.insert(_code).second); return true; diff --git a/pandatool/src/egg-mkfont/rangeIterator.h b/pandatool/src/egg-mkfont/rangeIterator.h index d978b17e6f..5a9630d792 100644 --- a/pandatool/src/egg-mkfont/rangeIterator.h +++ b/pandatool/src/egg-mkfont/rangeIterator.h @@ -1,16 +1,15 @@ -// Filename: rangeIterator.h -// Created by: drose (07Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file rangeIterator.h + * @author drose + * @date 2003-09-07 + */ #ifndef RANGEITERATOR_H #define RANGEITERATOR_H @@ -20,11 +19,10 @@ #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : RangeIterator -// Description : Walks through all the Unicode characters described by -// a RangeDescription class. -//////////////////////////////////////////////////////////////////// +/** + * Walks through all the Unicode characters described by a RangeDescription + * class. + */ class RangeIterator { public: RangeIterator(const RangeDescription &desc); @@ -45,4 +43,3 @@ private: #include "rangeIterator.I" #endif - diff --git a/pandatool/src/egg-optchar/config_egg_optchar.cxx b/pandatool/src/egg-optchar/config_egg_optchar.cxx index d8aeeee5ba..ef835f1f9f 100644 --- a/pandatool/src/egg-optchar/config_egg_optchar.cxx +++ b/pandatool/src/egg-optchar/config_egg_optchar.cxx @@ -1,16 +1,15 @@ -// Filename: config_egg_optchar.cxx -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg_optchar.cxx + * @author drose + * @date 2003-07-18 + */ #include "config_egg_optchar.h" #include "eggOptcharUserData.h" @@ -24,14 +23,12 @@ ConfigureFn(config_egg_optchar) { init_egg_optchar(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libegg_optchar -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_egg_optchar() { static bool initialized = false; diff --git a/pandatool/src/egg-optchar/config_egg_optchar.h b/pandatool/src/egg-optchar/config_egg_optchar.h index b3639bdb16..a4e84c6ddb 100644 --- a/pandatool/src/egg-optchar/config_egg_optchar.h +++ b/pandatool/src/egg-optchar/config_egg_optchar.h @@ -1,16 +1,15 @@ -// Filename: config_egg_optchar.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg_optchar.h + * @author drose + * @date 2003-07-18 + */ #ifndef CONFIG_EGG_OPTCHAR_H #define CONFIG_EGG_OPTCHAR_H diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index cf22dbe394..d6f541045e 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -1,16 +1,15 @@ -// Filename: eggOptchar.cxx -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggOptchar.cxx + * @author drose + * @date 2003-07-18 + */ #include "eggOptchar.h" #include "eggOptcharUserData.h" @@ -36,11 +35,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggOptchar:: EggOptchar() { add_path_replace_options(); @@ -143,7 +140,7 @@ EggOptchar() { "Keep all joints and sliders in the character, except those named " "explicitly by -drop.", &EggOptchar::dispatch_none, &_keep_all); - + add_option ("p", "joint,parent", 0, "Moves the named joint under the named parent joint. Use " @@ -151,7 +148,7 @@ EggOptchar() { "is recomputed appropriately under its new parent so that the animation " "is not affected (the effect is similar to NodePath::wrt_reparent_to).", &EggOptchar::dispatch_vector_string_pair, NULL, &_reparent_joints); - + add_option ("new", "joint,source", 0, "Creates a new joint under the named parent joint. The new " @@ -209,20 +206,18 @@ EggOptchar() { _vref_quantum = 0.01; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggOptchar:: run() { - // We have to apply the user-specified reparent requests first, - // before we even analyze the joints. This is because reparenting - // the joints may change their properties. + // We have to apply the user-specified reparent requests first, before we + // even analyze the joints. This is because reparenting the joints may + // change their properties. if (apply_user_reparents()) { nout << "Reparenting hierarchy.\n"; - // So we'll have to call do_reparent() twice. It seems wasteful, - // but it really is necessary, and it's not that bad. + // So we'll have to call do_reparent() twice. It seems wasteful, but it + // really is necessary, and it's not that bad. do_reparent(); } @@ -261,24 +256,23 @@ run() { } } else { - // The meat of the program: determine which joints are to be - // removed, and then actually remove them. + // The meat of the program: determine which joints are to be removed, and + // then actually remove them. determine_removed_components(); move_vertices(); if (process_joints()) { do_reparent(); } - // We currently do not implement optimizing morph sliders. Need - // to add this at some point; it's quite easy. Identity and empty - // morph sliders can simply be removed, while static sliders need - // to be applied to the vertices and then removed. + // We currently do not implement optimizing morph sliders. Need to add + // this at some point; it's quite easy. Identity and empty morph sliders + // can simply be removed, while static sliders need to be applied to the + // vertices and then removed. rename_joints(); - // Quantize the vertex memberships. We call this even if - // _vref_quantum is 0, because this also normalizes the vertex - // memberships. + // Quantize the vertex memberships. We call this even if _vref_quantum is + // 0, because this also normalizes the vertex memberships. quantize_vertices(); // Also quantize the animation channels, if the user so requested. @@ -298,9 +292,8 @@ run() { } - // Finally, set the default poses. It's important not to do this - // until after we have adjusted all of the transforms for the - // various joints. + // Finally, set the default poses. It's important not to do this until + // after we have adjusted all of the transforms for the various joints. if (!_defpose.empty()) { do_defpose(); } @@ -316,14 +309,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggOptchar:: handle_args(ProgramBase::Args &args) { if (_list_hierarchy || _list_hierarchy_v || _list_hierarchy_p) { @@ -333,14 +323,11 @@ handle_args(ProgramBase::Args &args) { return EggCharacterFilter::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_vector_string_pair -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a pair of string parameters. The data pointer is to -// StringPairs vector; the pair will be pushed onto the -// end of the vector. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a pair of string + * parameters. The data pointer is to StringPairs vector; the pair will be + * pushed onto the end of the vector. + */ bool EggOptchar:: dispatch_vector_string_pair(const string &opt, const string &arg, void *var) { StringPairs *ip = (StringPairs *)var; @@ -363,15 +350,13 @@ dispatch_vector_string_pair(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_name_components -// Access: Protected, Static -// Description: Accepts a name optionally followed by a comma and some -// of the nine standard component letters, -// -// The data pointer is to StringPairs vector; the pair -// will be pushed onto the end of the vector. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a name optionally followed by a comma and some of the nine standard + * component letters, + * + * The data pointer is to StringPairs vector; the pair will be pushed onto the + * end of the vector. + */ bool EggOptchar:: dispatch_name_components(const string &opt, const string &arg, void *var) { StringPairs *ip = (StringPairs *)var; @@ -400,7 +385,7 @@ dispatch_name_components(const string &opt, const string &arg, void *var) { if (strchr(matrix_component_letters, *si) == NULL) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " - << "of component names. The standard component names are \"" + << "of component names. The standard component names are \"" << matrix_component_letters << "\".\n"; return false; } @@ -412,15 +397,13 @@ dispatch_name_components(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_double_components -// Access: Protected, Static -// Description: Accepts a double value optionally followed by a comma -// and some of the nine standard component letters, -// -// The data pointer is to a DoubleStrings vector; the -// pair will be pushed onto the end of the vector. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a double value optionally followed by a comma and some of the nine + * standard component letters, + * + * The data pointer is to a DoubleStrings vector; the pair will be pushed onto + * the end of the vector. + */ bool EggOptchar:: dispatch_double_components(const string &opt, const string &arg, void *var) { DoubleStrings *ip = (DoubleStrings *)var; @@ -457,7 +440,7 @@ dispatch_double_components(const string &opt, const string &arg, void *var) { if (strchr(matrix_component_letters, *si) == NULL) { nout << "Not a standard matrix component: \"" << *si << "\"\n" << "-" << opt << " requires a joint name followed by a set " - << "of component names. The standard component names are \"" + << "of component names. The standard component names are \"" << matrix_component_letters << "\".\n"; return false; } @@ -469,14 +452,12 @@ dispatch_double_components(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_flag_groups -// Access: Protected, Static -// Description: Accepts a set of comma-delimited group names followed -// by an optional name separated with an equal sign. -// -// The data pointer is to a FlagGroups object. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a set of comma-delimited group names followed by an optional name + * separated with an equal sign. + * + * The data pointer is to a FlagGroups object. + */ bool EggOptchar:: dispatch_flag_groups(const string &opt, const string &arg, void *var) { FlagGroups *ip = (FlagGroups *)var; @@ -493,8 +474,7 @@ dispatch_flag_groups(const string &opt, const string &arg, void *var) { FlagGroupsEntry entry; - // Check for an equal sign in the last word. This marks the name to - // assign. + // Check for an equal sign in the last word. This marks the name to assign. string &last_word = words.back(); size_t equals = last_word.rfind('='); if (equals != string::npos) { @@ -502,9 +482,8 @@ dispatch_flag_groups(const string &opt, const string &arg, void *var) { last_word = last_word.substr(0, equals); } else { - // If there's no equal sign, the default is to name all groups - // after the group itself. We leave the name empty to indicate - // that. + // If there's no equal sign, the default is to name all groups after the + // group itself. We leave the name empty to indicate that. } // Convert the words to GlobPatterns. @@ -519,12 +498,10 @@ dispatch_flag_groups(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::determine_removed_components -// Access: Private -// Description: Flag all joints and sliders that should be removed -// for optimization purposes. -//////////////////////////////////////////////////////////////////// +/** + * Flag all joints and sliders that should be removed for optimization + * purposes. + */ void EggOptchar:: determine_removed_components() { typedef pset Names; @@ -561,7 +538,7 @@ determine_removed_components() { EggComponentData *comp_data = char_data->get_component(i); nassertv(comp_data != (EggComponentData *)NULL); - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, comp_data->get_user_data()); nassertv(user_data != (EggOptcharUserData *)NULL); @@ -591,16 +568,15 @@ determine_removed_components() { // Remove this component if it's unanimated or empty. if ((user_data->_flags & (EggOptcharUserData::F_static | EggOptcharUserData::F_empty)) != 0) { if ((user_data->_flags & (EggOptcharUserData::F_top | EggOptcharUserData::F_empty)) == EggOptcharUserData::F_top) { - // Actually, we can't remove it if it's a top joint, - // unless it's also empty. That's because vertices that - // are partially assigned to this joint would then have no - // joint to represent the same partial assignment, and - // they would then appear to be wholly assigned to their - // other joint, which would be incorrect. + // Actually, we can't remove it if it's a top joint, unless it's + // also empty. That's because vertices that are partially + // assigned to this joint would then have no joint to represent + // the same partial assignment, and they would then appear to be + // wholly assigned to their other joint, which would be incorrect. } else { - // But joints that aren't top joints (or that are empty) - // are o.k. to remove. + // But joints that aren't top joints (or that are empty) are o.k. + // to remove. user_data->_flags |= EggOptcharUserData::F_remove; } } @@ -608,8 +584,8 @@ determine_removed_components() { } } - // Go back and tell the user about component names we didn't use, - // just to be helpful. + // Go back and tell the user about component names we didn't use, just to be + // helpful. for (si = _keep_components.begin(); si != _keep_components.end(); ++si) { const string &name = (*si); if (names_used.find(name) == names_used.end()) { @@ -636,36 +612,33 @@ determine_removed_components() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::move_vertices -// Access: Private -// Description: Moves the vertices from joints that are about to be -// removed into the first suitable parent. This might -// result in fewer joints being removed (because -// the parent might suddenly no longer be empty). -//////////////////////////////////////////////////////////////////// +/** + * Moves the vertices from joints that are about to be removed into the first + * suitable parent. This might result in fewer joints being removed (because + * the parent might suddenly no longer be empty). + */ void EggOptchar:: move_vertices() { int num_characters = _collection->get_num_characters(); for (int ci = 0; ci < num_characters; ci++) { EggCharacterData *char_data = _collection->get_character(ci); int num_joints = char_data->get_num_joints(); - + for (int i = 0; i < num_joints; i++) { EggJointData *joint_data = char_data->get_joint(i); - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, joint_data->get_user_data()); if ((user_data->_flags & EggOptcharUserData::F_empty) == 0 && (user_data->_flags & EggOptcharUserData::F_remove) != 0) { - // This joint has vertices, but is scheduled to be removed; - // find a suitable home for its vertices. + // This joint has vertices, but is scheduled to be removed; find a + // suitable home for its vertices. EggJointData *best_joint = find_best_vertex_joint(joint_data->get_parent()); joint_data->move_vertices_to(best_joint); // Now we can't remove the joint. if (best_joint != (EggJointData *)NULL) { - EggOptcharUserData *best_user_data = + EggOptcharUserData *best_user_data = DCAST(EggOptcharUserData, best_joint->get_user_data()); best_user_data->_flags &= ~(EggOptcharUserData::F_empty | EggOptcharUserData::F_remove); } @@ -673,16 +646,13 @@ move_vertices() { } } } - -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::process_joints -// Access: Private -// Description: Effects the actual removal of joints flagged for -// removal by reparenting the hierarchy appropriately. -// Returns true if any joints are removed, false -// otherwise. -//////////////////////////////////////////////////////////////////// + +/** + * Effects the actual removal of joints flagged for removal by reparenting the + * hierarchy appropriately. Returns true if any joints are removed, false + * otherwise. + */ bool EggOptchar:: process_joints() { bool removed_any = false; @@ -690,24 +660,24 @@ process_joints() { for (int ci = 0; ci < num_characters; ci++) { EggCharacterData *char_data = _collection->get_character(ci); int num_joints = char_data->get_num_joints(); - + int num_static = 0; int num_empty = 0; int num_identity = 0; int num_other = 0; int num_kept = 0; - + for (int i = 0; i < num_joints; i++) { EggJointData *joint_data = char_data->get_joint(i); - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, joint_data->get_user_data()); - + if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { // This joint will be removed, so reparent it to nothing. joint_data->reparent_to((EggJointData *)NULL); - - // Determine what kind of node it is we're removing, for the - // user's information. + + // Determine what kind of node it is we're removing, for the user's + // information. if ((user_data->_flags & EggOptcharUserData::F_identity) != 0) { num_identity++; } else if ((user_data->_flags & EggOptcharUserData::F_static) != 0) { @@ -720,8 +690,7 @@ process_joints() { removed_any = true; } else { - // This joint will be preserved, but maybe its parent will - // change. + // This joint will be preserved, but maybe its parent will change. EggJointData *best_parent = find_best_parent(joint_data->get_parent()); joint_data->reparent_to(best_parent); if ((user_data->_flags & EggOptcharUserData::F_expose) != 0) { @@ -752,7 +721,7 @@ process_joints() { if (num_other != 0) { nout << setw(5) << num_other << " other joints\n"; } - nout << " ----\n" + nout << " ----\n" << setw(5) << num_kept << " joints remaining\n\n"; } } @@ -760,17 +729,14 @@ process_joints() { return removed_any; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::find_best_parent -// Access: Private -// Description: Searches for the first joint at this level or above -// that is not scheduled to be removed. This is the -// joint that the first child of this joint should be -// reparented to. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the first joint at this level or above that is not scheduled + * to be removed. This is the joint that the first child of this joint should + * be reparented to. + */ EggJointData *EggOptchar:: find_best_parent(EggJointData *joint_data) const { - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, joint_data->get_user_data()); if ((user_data->_flags & EggOptcharUserData::F_remove) != 0) { @@ -784,20 +750,17 @@ find_best_parent(EggJointData *joint_data) const { return joint_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::find_best_vertex_joint -// Access: Private -// Description: Searches for the first joint at this level or above -// that is not static. This is the joint that the -// vertices of this joint should be moved into. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the first joint at this level or above that is not static. + * This is the joint that the vertices of this joint should be moved into. + */ EggJointData *EggOptchar:: find_best_vertex_joint(EggJointData *joint_data) const { if (joint_data == (EggJointData *)NULL) { return NULL; } - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, joint_data->get_user_data()); if ((user_data->_flags & EggOptcharUserData::F_static) != 0) { @@ -809,13 +772,10 @@ find_best_vertex_joint(EggJointData *joint_data) const { return joint_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::apply_user_reparents -// Access: Private -// Description: Reparents all the joints that the user suggested on -// the command line. Returns true if any operations -// were performed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reparents all the joints that the user suggested on the command line. + * Returns true if any operations were performed, false otherwise. + */ bool EggOptchar:: apply_user_reparents() { bool did_anything = false; @@ -840,9 +800,9 @@ apply_user_reparents() { << ".\n"; } else if (node_a != (EggJointData *)NULL) { - nout << "Joint " << p._a << " already exists in " + nout << "Joint " << p._a << " already exists in " << char_data->get_name() << ".\n"; - + } else { nout << "Creating new joint " << p._a << " in " << char_data->get_name() << ".\n"; @@ -892,15 +852,11 @@ apply_user_reparents() { return did_anything; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::zero_channels -// Access: Private -// Description: Zeroes out the channels specified by the user on the -// command line. -// -// Returns true if any operation was performed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Zeroes out the channels specified by the user on the command line. + * + * Returns true if any operation was performed, false otherwise. + */ bool EggOptchar:: zero_channels() { bool did_anything = false; @@ -927,15 +883,11 @@ zero_channels() { return did_anything; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::quantize_channels -// Access: Private -// Description: Quantizes the channels specified by the user on the -// command line. -// -// Returns true if any operation was performed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Quantizes the channels specified by the user on the command line. + * + * Returns true if any operation was performed, false otherwise. + */ bool EggOptchar:: quantize_channels() { bool did_anything = false; @@ -959,28 +911,25 @@ quantize_channels() { return did_anything; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::analyze_joints -// Access: Private -// Description: Recursively walks the joint hierarchy for a -// particular character, indentifying properties of each -// joint. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the joint hierarchy for a particular character, + * indentifying properties of each joint. + */ void EggOptchar:: analyze_joints(EggJointData *joint_data, int level) { PT(EggOptcharUserData) user_data = new EggOptcharUserData; joint_data->set_user_data(user_data); if (level == 1) { - // The child joints of the root joint are deemed "top" joints. - // These may not be removed unless they are empty (because their - // vertices have no joint to be moved into). + // The child joints of the root joint are deemed "top" joints. These may + // not be removed unless they are empty (because their vertices have no + // joint to be moved into). user_data->_flags |= EggOptcharUserData::F_top; } - // Analyze the table of matrices for this joint, checking to see if - // they're all the same across all frames, or if any of them are - // different; also look for empty joints (that control no vertices). + // Analyze the table of matrices for this joint, checking to see if they're + // all the same across all frames, or if any of them are different; also + // look for empty joints (that control no vertices). int num_mats = 0; bool different_mat = false; bool has_vertices = false; @@ -1019,7 +968,7 @@ analyze_joints(EggJointData *joint_data, int level) { // All the mats are the same for this joint. user_data->_flags |= EggOptcharUserData::F_static; - if (num_mats == 0 || + if (num_mats == 0 || user_data->_static_mat.almost_equal(LMatrix4d::ident_mat(), 0.0001)) { // It's not only static, but it's the identity matrix. user_data->_flags |= EggOptcharUserData::F_identity; @@ -1037,12 +986,10 @@ analyze_joints(EggJointData *joint_data, int level) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::analyze_sliders -// Access: Private -// Description: Linearly walks the slider list for a particular -// character, indentifying properties of each slider. -//////////////////////////////////////////////////////////////////// +/** + * Linearly walks the slider list for a particular character, indentifying + * properties of each slider. + */ void EggOptchar:: analyze_sliders(EggCharacterData *char_data) { int num_sliders = char_data->get_num_sliders(); @@ -1052,9 +999,9 @@ analyze_sliders(EggCharacterData *char_data) { PT(EggOptcharUserData) user_data = new EggOptcharUserData; slider_data->set_user_data(user_data); - // Analyze the table of values for this slider, checking to see if - // they're all the same across all frames, or if any of them are - // different; also look for empty sliders (that control no vertices). + // Analyze the table of values for this slider, checking to see if they're + // all the same across all frames, or if any of them are different; also + // look for empty sliders (that control no vertices). int num_values = 0; bool different_value = false; bool has_vertices = false; @@ -1066,9 +1013,9 @@ analyze_sliders(EggCharacterData *char_data) { if (model->has_vertices()) { has_vertices = true; } - + int num_frames = slider_data->get_num_frames(i); - + int f; for (f = 0; f < num_frames && !different_value; f++) { double value = slider_data->get_frame(i, f); @@ -1076,7 +1023,7 @@ analyze_sliders(EggCharacterData *char_data) { if (num_values == 1) { // This is the first value. user_data->_static_value = value; - + } else { // This is a second or later value. if (!IS_THRESHOLD_EQUAL(value, user_data->_static_value, 0.0001)) { @@ -1087,17 +1034,17 @@ analyze_sliders(EggCharacterData *char_data) { } } } - + if (!different_value) { // All the values are the same for this slider. user_data->_flags |= EggOptcharUserData::F_static; - + if (num_values == 0 || IS_THRESHOLD_ZERO(user_data->_static_value, 0.0001)) { // It's not only static, but it's the identity value. user_data->_flags |= EggOptcharUserData::F_identity; } } - + if (!has_vertices) { // There are no vertices in this slider. user_data->_flags |= EggOptcharUserData::F_empty; @@ -1105,16 +1052,13 @@ analyze_sliders(EggCharacterData *char_data) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::list_joints -// Access: Private -// Description: Outputs a list of the joint hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of the joint hierarchy. + */ void EggOptchar:: list_joints(EggJointData *joint_data, int indent_level, bool verbose) { // Don't list the root joint, which is artificially created when the - // character is loaded. Instead, list each child as it is - // encountered. + // character is loaded. Instead, list each child as it is encountered. int num_children = joint_data->get_num_children(); for (int i = 0; i < num_children; i++) { @@ -1125,12 +1069,10 @@ list_joints(EggJointData *joint_data, int indent_level, bool verbose) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::list_joints_p -// Access: Private -// Description: Outputs a list of the joint hierarchy as a series of -// -p joint,parent commands. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of the joint hierarchy as a series of -p joint,parent + * commands. + */ void EggOptchar:: list_joints_p(EggJointData *joint_data, int &col) { // As above, don't list the root joint. @@ -1140,11 +1082,10 @@ list_joints_p(EggJointData *joint_data, int &col) { for (int i = 0; i < num_children; i++) { EggJointData *child_data = joint_data->get_child(i); - // We send output to cout instead of nout to avoid the - // word-wrapping, and also to allow the user to redirect this - // easily to a file. + // We send output to cout instead of nout to avoid the word-wrapping, and + // also to allow the user to redirect this easily to a file. - string text = string(" -p ") + child_data->get_name() + + string text = string(" -p ") + child_data->get_name() + string(",") + joint_data->get_name(); if (col == 0) { cout << " " << text; @@ -1163,11 +1104,9 @@ list_joints_p(EggJointData *joint_data, int &col) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::list_scalars -// Access: Private -// Description: Outputs a list of the scalars. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a list of the scalars. + */ void EggOptchar:: list_scalars(EggCharacterData *char_data, bool verbose) { int num_sliders = char_data->get_num_sliders(); @@ -1177,21 +1116,19 @@ list_scalars(EggCharacterData *char_data, bool verbose) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::describe_component -// Access: Private -// Description: Describes one particular slider or joint. -//////////////////////////////////////////////////////////////////// +/** + * Describes one particular slider or joint. + */ void EggOptchar:: describe_component(EggComponentData *comp_data, int indent_level, bool verbose) { - // We use cout instead of nout so the user can easily redirect this - // to a file. + // We use cout instead of nout so the user can easily redirect this to a + // file. indent(cout, indent_level) << comp_data->get_name(); if (verbose) { - EggOptcharUserData *user_data = + EggOptcharUserData *user_data = DCAST(EggOptcharUserData, comp_data->get_user_data()); if (user_data->is_identity()) { cout << " (identity)"; @@ -1208,11 +1145,9 @@ describe_component(EggComponentData *comp_data, int indent_level, cout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::do_reparent -// Access: Private -// Description: Performs all of the queued up reparenting operations. -//////////////////////////////////////////////////////////////////// +/** + * Performs all of the queued up reparenting operations. + */ void EggOptchar:: do_reparent() { bool all_ok = true; @@ -1230,13 +1165,10 @@ do_reparent() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::quantize_vertices -// Access: Private -// Description: Walks through all of the loaded egg files, looking -// for vertices whose joint memberships are then -// quantized according to _vref_quantum. -//////////////////////////////////////////////////////////////////// +/** + * Walks through all of the loaded egg files, looking for vertices whose joint + * memberships are then quantized according to _vref_quantum. + */ void EggOptchar:: quantize_vertices() { Eggs::iterator ei; @@ -1245,14 +1177,10 @@ quantize_vertices() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::quantize_vertices -// Access: Private -// Description: Recursively walks through the indicated egg -// hierarchy, looking for vertices whose joint -// memberships are then quantized according to -// _vref_quantum. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the indicated egg hierarchy, looking for vertices + * whose joint memberships are then quantized according to _vref_quantum. + */ void EggOptchar:: quantize_vertices(EggNode *egg_node) { if (egg_node->is_of_type(EggVertexPool::get_class_type())) { @@ -1261,7 +1189,7 @@ quantize_vertices(EggNode *egg_node) { for (vi = vpool->begin(); vi != vpool->end(); ++vi) { quantize_vertex(*vi); } - + } else if (egg_node->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *group = DCAST(EggGroupNode, egg_node); EggGroupNode::iterator ci; @@ -1271,11 +1199,9 @@ quantize_vertices(EggNode *egg_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::quantize_vertex -// Access: Private -// Description: Quantizes the indicated vertex's joint membership. -//////////////////////////////////////////////////////////////////// +/** + * Quantizes the indicated vertex's joint membership. + */ void EggOptchar:: quantize_vertex(EggVertex *egg_vertex) { if (egg_vertex->gref_size() == 0) { @@ -1295,8 +1221,8 @@ quantize_vertex(EggVertex *egg_vertex) { } nassertv(net_membership != 0.0); - // Now normalize all the memberships so the net membership is 1.0, - // and then quantize the result (if the user so requested). + // Now normalize all the memberships so the net membership is 1.0, and then + // quantize the result (if the user so requested). double factor = 1.0 / net_membership; net_membership = 0.0; VertexMemberships::iterator mi; @@ -1304,8 +1230,8 @@ quantize_vertex(EggVertex *egg_vertex) { for (mi = memberships.begin(); mi != memberships.end(); ++mi) { if ((*largest) < (*mi)) { - // Remember the largest membership value, so we can readjust it - // at the end. + // Remember the largest membership value, so we can readjust it at the + // end. largest = mi; } @@ -1318,36 +1244,33 @@ quantize_vertex(EggVertex *egg_vertex) { net_membership += value; } - // The the largest membership value gets corrected again by the - // roundoff error. + // The the largest membership value gets corrected again by the roundoff + // error. (*largest)._membership += 1.0 - net_membership; - // Finally, walk back through and apply these computed values to the - // vertex. + // Finally, walk back through and apply these computed values to the vertex. for (mi = memberships.begin(); mi != memberships.end(); ++mi) { (*mi)._group->set_vertex_membership(egg_vertex, (*mi)._membership); } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::do_flag_groups -// Access: Private -// Description: Recursively walks the indicated egg hierarchy, -// looking for groups that match one of the group names -// in _flag_groups, and renaming geometry appropriately. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the indicated egg hierarchy, looking for groups that + * match one of the group names in _flag_groups, and renaming geometry + * appropriately. + */ void EggOptchar:: do_flag_groups(EggGroupNode *egg_group) { bool matched = false; string name; FlagGroups::const_iterator fi; - for (fi = _flag_groups.begin(); - fi != _flag_groups.end() && !matched; + for (fi = _flag_groups.begin(); + fi != _flag_groups.end() && !matched; ++fi) { const FlagGroupsEntry &entry = (*fi); Globs::const_iterator si; - for (si = entry._groups.begin(); - si != entry._groups.end() && !matched; + for (si = entry._groups.begin(); + si != entry._groups.end() && !matched; ++si) { if ((*si).matches(egg_group->get_name())) { matched = true; @@ -1361,10 +1284,9 @@ do_flag_groups(EggGroupNode *egg_group) { } if (matched) { - // Ok, this group matched one of the user's command-line renames. - // Rename all the primitives in this group and below to the - // indicated name; this will expose the primitives through the - // character loader. + // Ok, this group matched one of the user's command-line renames. Rename + // all the primitives in this group and below to the indicated name; this + // will expose the primitives through the character loader. rename_primitives(egg_group, name); } @@ -1379,12 +1301,9 @@ do_flag_groups(EggGroupNode *egg_group) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::rename_joints -// Access: Private -// Description: Rename all the joints named with the -rename -// command-line option. -//////////////////////////////////////////////////////////////////// +/** + * Rename all the joints named with the -rename command-line option. + */ void EggOptchar:: rename_joints() { for (StringPairs::iterator spi = _rename_joints.begin(); @@ -1415,12 +1334,10 @@ rename_joints() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::change_dart_type -// Access: Private -// Description: Recursively walks the indicated egg hierarchy, -// renaming geometry to the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the indicated egg hierarchy, renaming geometry to the + * indicated name. + */ void EggOptchar:: change_dart_type(EggGroupNode *egg_group, const string &new_dart_type) { EggGroupNode::iterator gi; @@ -1433,7 +1350,7 @@ change_dart_type(EggGroupNode *egg_group, const string &new_dart_type) { EggGroup::DartType dt = gr->get_dart_type(); if(dt != EggGroup::DT_none) { EggGroup::DartType newDt = gr->string_dart_type(new_dart_type); - gr->set_dart_type(newDt); + gr->set_dart_type(newDt); } } change_dart_type(group, new_dart_type); @@ -1442,12 +1359,10 @@ change_dart_type(EggGroupNode *egg_group, const string &new_dart_type) { } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::rename_primitives -// Access: Private -// Description: Recursively walks the indicated egg hierarchy, -// renaming geometry to the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the indicated egg hierarchy, renaming geometry to the + * indicated name. + */ void EggOptchar:: rename_primitives(EggGroupNode *egg_group, const string &name) { EggGroupNode::iterator gi; @@ -1464,15 +1379,13 @@ rename_primitives(EggGroupNode *egg_group, const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::do_preload -// Access: Private -// Description: Generates the preload tables for each model. -//////////////////////////////////////////////////////////////////// +/** + * Generates the preload tables for each model. + */ void EggOptchar:: do_preload() { - // First, build up the list of AnimPreload entries, one for each - // animation file. + // First, build up the list of AnimPreload entries, one for each animation + // file. PT(EggGroup) anim_group = new EggGroup("preload"); int num_characters = _collection->get_num_characters(); @@ -1495,14 +1408,14 @@ do_preload() { if (frame_rate != 0.0) { anim_preload->set_fps(frame_rate); } - + anim_group->add_child(anim_preload); } } } - // Now go back through and copy the preload tables into each of the - // model files. + // Now go back through and copy the preload tables into each of the model + // files. for (ci = 0; ci < num_characters; ++ci) { EggCharacterData *char_data = _collection->get_character(ci); @@ -1523,11 +1436,9 @@ do_preload() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggOptchar::do_defpose -// Access: Private -// Description: Sets the initial pose for the character(s). -//////////////////////////////////////////////////////////////////// +/** + * Sets the initial pose for the character(s). + */ void EggOptchar:: do_defpose() { // Split out the defpose parameter. diff --git a/pandatool/src/egg-optchar/eggOptchar.h b/pandatool/src/egg-optchar/eggOptchar.h index 58de903d36..5d461a3442 100644 --- a/pandatool/src/egg-optchar/eggOptchar.h +++ b/pandatool/src/egg-optchar/eggOptchar.h @@ -1,16 +1,15 @@ -// Filename: eggOptchar.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggOptchar.h + * @author drose + * @date 2003-07-18 + */ #ifndef EGGOPTCHAR_H #define EGGOPTCHAR_H @@ -30,14 +29,11 @@ class EggJointData; class EggSliderData; class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : EggOptchar -// Description : Performs basic optimizations of a character model and -// its associated animations, by analyzing the animation -// tables and removing unneeded joints and/or morphs. -// Can also be used to restructure the character -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Performs basic optimizations of a character model and its associated + * animations, by analyzing the animation tables and removing unneeded joints + * and/or morphs. Can also be used to restructure the character hierarchy. + */ class EggOptchar : public EggCharacterFilter { public: EggOptchar(); @@ -131,4 +127,3 @@ private: }; #endif - diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.I b/pandatool/src/egg-optchar/eggOptcharUserData.I index 325191821e..47f71ac45a 100644 --- a/pandatool/src/egg-optchar/eggOptcharUserData.I +++ b/pandatool/src/egg-optchar/eggOptcharUserData.I @@ -1,23 +1,19 @@ -// Filename: eggOptcharUserData.I -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggOptcharUserData.I + * @author drose + * @date 2003-07-18 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggOptcharUserData:: EggOptcharUserData() { _flags = 0; @@ -26,13 +22,11 @@ EggOptcharUserData() { } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggOptcharUserData:: -EggOptcharUserData(const EggOptcharUserData ©) : +EggOptcharUserData(const EggOptcharUserData ©) : EggUserData(copy), _flags(copy._flags), _static_mat(copy._static_mat), @@ -41,11 +35,9 @@ EggOptcharUserData(const EggOptcharUserData ©) : } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void EggOptcharUserData:: operator = (const EggOptcharUserData ©) { EggUserData::operator = (copy); @@ -54,41 +46,33 @@ operator = (const EggOptcharUserData ©) { _static_value = copy._static_value; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::is_static -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggOptcharUserData:: is_static() const { return (_flags & F_static) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::is_identity -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggOptcharUserData:: is_identity() const { return (_flags & F_identity) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::is_empty -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggOptcharUserData:: is_empty() const { return (_flags & F_empty) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggOptcharUserData::is_top -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool EggOptcharUserData:: is_top() const { return (_flags & F_top) != 0; diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.cxx b/pandatool/src/egg-optchar/eggOptcharUserData.cxx index 13ca2042fc..ecb6b32cd3 100644 --- a/pandatool/src/egg-optchar/eggOptcharUserData.cxx +++ b/pandatool/src/egg-optchar/eggOptcharUserData.cxx @@ -1,16 +1,15 @@ -// Filename: eggOptcharUserData.cxx -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggOptcharUserData.cxx + * @author drose + * @date 2003-07-18 + */ #include "eggOptcharUserData.h" diff --git a/pandatool/src/egg-optchar/eggOptcharUserData.h b/pandatool/src/egg-optchar/eggOptcharUserData.h index 8b374aedc0..2f12aae931 100644 --- a/pandatool/src/egg-optchar/eggOptcharUserData.h +++ b/pandatool/src/egg-optchar/eggOptcharUserData.h @@ -1,16 +1,15 @@ -// Filename: eggOptcharUserData.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggOptcharUserData.h + * @author drose + * @date 2003-07-18 + */ #ifndef EGGOPTCHARUSERDATA_H #define EGGOPTCHARUSERDATA_H @@ -19,12 +18,10 @@ #include "eggUserData.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggOptcharUserData -// Description : This class contains extra user data which is -// piggybacked onto EggGroup objects for the purpose of -// the maya converter. -//////////////////////////////////////////////////////////////////// +/** + * This class contains extra user data which is piggybacked onto EggGroup + * objects for the purpose of the maya converter. + */ class EggOptcharUserData : public EggUserData { public: INLINE EggOptcharUserData(); diff --git a/pandatool/src/egg-optchar/vertexMembership.I b/pandatool/src/egg-optchar/vertexMembership.I index 908de15fc2..f001b1d945 100644 --- a/pandatool/src/egg-optchar/vertexMembership.I +++ b/pandatool/src/egg-optchar/vertexMembership.I @@ -1,23 +1,19 @@ -// Filename: vertexMembership.I -// Created by: drose (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexMembership.I + * @author drose + * @date 2003-07-21 + */ - -//////////////////////////////////////////////////////////////////// -// Function: VertexMembership::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexMembership:: VertexMembership(EggGroup *group, double membership) : _group(group), @@ -25,11 +21,9 @@ VertexMembership(EggGroup *group, double membership) : { } -//////////////////////////////////////////////////////////////////// -// Function: VertexMembership::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE VertexMembership:: VertexMembership(const VertexMembership ©) : _group(copy._group), @@ -37,22 +31,18 @@ VertexMembership(const VertexMembership ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: VertexMembership::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void VertexMembership:: operator = (const VertexMembership ©) { _group = copy._group; _membership = copy._membership; } -//////////////////////////////////////////////////////////////////// -// Function: VertexMembership::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool VertexMembership:: operator < (const VertexMembership &other) const { if (_membership != other._membership) { diff --git a/pandatool/src/egg-optchar/vertexMembership.cxx b/pandatool/src/egg-optchar/vertexMembership.cxx index 56e36f0735..d7eab777b3 100644 --- a/pandatool/src/egg-optchar/vertexMembership.cxx +++ b/pandatool/src/egg-optchar/vertexMembership.cxx @@ -1,15 +1,14 @@ -// Filename: vertexMembership.cxx -// Created by: drose (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexMembership.cxx + * @author drose + * @date 2003-07-21 + */ #include "vertexMembership.h" diff --git a/pandatool/src/egg-optchar/vertexMembership.h b/pandatool/src/egg-optchar/vertexMembership.h index 34a69be896..31cc16ae11 100644 --- a/pandatool/src/egg-optchar/vertexMembership.h +++ b/pandatool/src/egg-optchar/vertexMembership.h @@ -1,16 +1,15 @@ -// Filename: vertexMembership.h -// Created by: drose (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vertexMembership.h + * @author drose + * @date 2003-07-21 + */ #ifndef VERTEXMEMBERSHIP_H #define VERTEXMEMBERSHIP_H @@ -21,11 +20,10 @@ class EggGroup; -//////////////////////////////////////////////////////////////////// -// Class : VertexMembership -// Description : This class is used to help EggOptchar quantize the -// membership of one vertex among its various groups. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to help EggOptchar quantize the membership of one vertex + * among its various groups. + */ class VertexMembership { public: INLINE VertexMembership(EggGroup *group, double membership); @@ -43,4 +41,3 @@ typedef pvector VertexMemberships; #include "vertexMembership.I" #endif - diff --git a/pandatool/src/egg-palettize/eggPalettize.cxx b/pandatool/src/egg-palettize/eggPalettize.cxx index 07f0ab49ed..cefec3d589 100644 --- a/pandatool/src/egg-palettize/eggPalettize.cxx +++ b/pandatool/src/egg-palettize/eggPalettize.cxx @@ -1,16 +1,15 @@ -// Filename: eggPalettize.cxx -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPalettize.cxx + * @author drose + * @date 2000-11-28 + */ #include "eggPalettize.h" #include "palettizer.h" @@ -28,11 +27,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggPalettize::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggPalettize:: EggPalettize() : EggMultiFilter(true) { set_program_brief("pack textures from various .egg models into palette images"); @@ -61,8 +58,8 @@ EggPalettize() : EggMultiFilter(true) { clear_runlines(); add_runline("[opts] file.egg [file.egg ...]"); - // We always have EggMultiBase's -f on: force complete load. In - // fact, we use -f for our own purposes, below. + // We always have EggMultiBase's -f on: force complete load. In fact, we + // use -f for our own purposes, below. remove_option("f"); _force_complete = true; @@ -121,8 +118,8 @@ EggPalettize() : EggMultiFilter(true) { "file.", &EggPalettize::dispatch_none, &_remove_eggs); - // We redefine -d using add_option() instead of redescribe_option() - // so it gets listed along with these other options that relate. + // We redefine -d using add_option() instead of redescribe_option() so it + // gets listed along with these other options that relate. add_option ("d", "dirname", 0, "The directory in which to write the palettized egg files. This is " @@ -201,8 +198,8 @@ EggPalettize() : EggMultiFilter(true) { &EggPalettize::dispatch_none, &_omitall); // This isn't even implemented yet. Presently, we never lock anyway. - // Dangerous, but hard to implement reliable file locking across - // NFS/Samba and between multiple OS's. + // Dangerous, but hard to implement reliable file locking across NFSSamba + // and between multiple OS's. /* add_option ("nolock", "", 0, @@ -222,14 +219,11 @@ EggPalettize() : EggMultiFilter(true) { } -//////////////////////////////////////////////////////////////////// -// Function: EggPalettize::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggPalettize:: handle_args(ProgramBase::Args &args) { if (_describe_input_file) { @@ -238,8 +232,8 @@ handle_args(ProgramBase::Args &args) { } if (_remove_eggs) { - // If we're removing these egg files from the database, we don't - // want to try to load them up. Instead, just save the filenames. + // If we're removing these egg files from the database, we don't want to + // try to load them up. Instead, just save the filenames. _remove_egg_list = args; return true; } @@ -248,11 +242,9 @@ handle_args(ProgramBase::Args &args) { return EggMultiFilter::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: EggPalettize::describe_input_file -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggPalettize:: describe_input_file() { nout << @@ -569,17 +561,15 @@ describe_input_file() { } -//////////////////////////////////////////////////////////////////// -// Function: EggPalettize::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggPalettize:: run() { - // Fiddle with the loader severity, so we don't confuse the user - // with spurious "reading" and "writing" messages about the state - // file. If the severity is currently NS_info (the default), set it - // to NS_warning instead. + // Fiddle with the loader severity, so we don't confuse the user with + // spurious "reading" and "writing" messages about the state file. If the + // severity is currently NS_info (the default), set it to NS_warning + // instead. Notify *notify = Notify::ptr(); NotifyCategory *loader_cat = notify->get_category(":loader"); if (loader_cat != (NotifyCategory *)NULL && @@ -591,29 +581,29 @@ run() { BamFile state_file; if (_got_txa_script) { - // If we got a command-line script instead of a .txa file, we - // won't be encoding a .boo file either. + // If we got a command-line script instead of a .txa file, we won't be + // encoding a .boo file either. _nodb = true; } else { // Look for the .txa file. if (!_txa_filename.exists() && !_got_txa_filename) { // If we did not specify a filename, and the default filename of - // "textures.txa" doesn't exist, try looking in src/maps, as - // another likely possibility. + // "textures.txa" doesn't exist, try looking in srcmaps, as another + // likely possibility. Filename maybe = _txa_filename; maybe.set_dirname("src/maps"); if (maybe.exists()) { _txa_filename = maybe; } } - + if (!_txa_filename.exists()) { nout << FilenameUnifier::make_user_filename(_txa_filename) << " does not exist; cannot run.\n"; exit(1); } - + FilenameUnifier::set_txa_filename(_txa_filename); state_filename = _txa_filename; @@ -621,8 +611,8 @@ run() { } if (_nodb) { - // -nodb means don't attempt to read textures.boo; in fact, don't - // even bother reporting this absence to the user. + // -nodb means don't attempt to read textures.boo; in fact, don't even + // bother reporting this absence to the user. pal = new Palettizer; // And -nodb implies -opt. @@ -637,9 +627,8 @@ run() { pal->_omit_everything = true; } else { - // Read the Palettizer object from the Bam file written - // previously. This will recover all of the state saved from the - // past session. + // Read the Palettizer object from the Bam file written previously. This + // will recover all of the state saved from the past session. nout << "Reading " << FilenameUnifier::make_user_filename(state_filename) << "\n"; @@ -746,10 +735,9 @@ run() { FilenameUnifier::set_rel_dirname(_rel_dirname); } - // We only omit solitary textures from palettes if we're running in - // optimal mode. Otherwise, we're likely to invalidate old egg - // files by changing a texture from solitary to nonsolitary state or - // vice-versa. + // We only omit solitary textures from palettes if we're running in optimal + // mode. Otherwise, we're likely to invalidate old egg files by changing a + // texture from solitary to nonsolitary state or vice-versa. pal->_omit_solitary = _optimal; if (_omitall) { @@ -794,8 +782,8 @@ run() { } if (_optimal) { - // If we're asking for an optimal packing, throw away the old - // packing and start fresh. + // If we're asking for an optimal packing, throw away the old packing and + // start fresh. pal->reset_images(); _all_textures = true; @@ -813,8 +801,8 @@ run() { } if (_optimal) { - // If we're asking for optimal packing, this also implies we want - // to resize the big empty palette images down. + // If we're asking for optimal packing, this also implies we want to + // resize the big empty palette images down. pal->optimal_resize(); } @@ -835,7 +823,7 @@ run() { } } } - + if (okflag) { if (!pal->write_eggs()) { okflag = false; @@ -843,16 +831,16 @@ run() { } if (!_nodb) { - // Make up a temporary filename to write the state file to, then - // move the state file into place. We do this in case the user - // interrupts us (or we core dump) before we're done; that way we - // won't leave the state file incompletely written. + // Make up a temporary filename to write the state file to, then move the + // state file into place. We do this in case the user interrupts us (or + // we core dump) before we're done; that way we won't leave the state file + // incompletely written. string dirname = state_filename.get_dirname(); if (dirname.empty()) { dirname = "."; } Filename temp_filename = Filename::temporary(dirname, "pi"); - + if (!state_file.open_write(temp_filename) || !state_file.write_object(pal)) { nout << "Unable to write palettization information to " @@ -860,7 +848,7 @@ run() { << "\n"; exit(1); } - + state_file.close(); state_filename.unlink(); if (!temp_filename.rename_to(state_filename)) { @@ -886,5 +874,3 @@ main(int argc, char *argv[]) { prog.run(); return 0; } - - diff --git a/pandatool/src/egg-palettize/eggPalettize.h b/pandatool/src/egg-palettize/eggPalettize.h index 8975406f1b..a0c6208d31 100644 --- a/pandatool/src/egg-palettize/eggPalettize.h +++ b/pandatool/src/egg-palettize/eggPalettize.h @@ -1,16 +1,15 @@ -// Filename: eggPalettize.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggPalettize.h + * @author drose + * @date 2000-11-28 + */ #ifndef EGGPALETTIZE_H #define EGGPALETTIZE_H @@ -19,12 +18,10 @@ #include "eggMultiFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggPalettize -// Description : This is the program wrapper for egg-palettize, but it -// mainly serves to read in all the command-line -// parameters and then invoke the Palettizer. -//////////////////////////////////////////////////////////////////// +/** + * This is the program wrapper for egg-palettize, but it mainly serves to read + * in all the command-line parameters and then invoke the Palettizer. + */ class EggPalettize : public EggMultiFilter { public: EggPalettize(); @@ -35,8 +32,8 @@ public: void run(); - // The following parameter values specifically relate to textures - // and palettes. These values are copied to the Palettizer. + // The following parameter values specifically relate to textures and + // palettes. These values are copied to the Palettizer. bool _got_txa_filename; Filename _txa_filename; bool _got_txa_script; @@ -56,8 +53,8 @@ public: bool _got_default_groupdir; private: - // The following values control behavior specific to this session. - // They're not saved for future sessions. + // The following values control behavior specific to this session. They're + // not saved for future sessions. bool _report_pi; bool _report_statistics; bool _all_textures; diff --git a/pandatool/src/egg-palettize/txaFileFilter.I b/pandatool/src/egg-palettize/txaFileFilter.I index 4704c85dad..44cde648be 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.I +++ b/pandatool/src/egg-palettize/txaFileFilter.I @@ -1,14 +1,12 @@ -// Filename: txaFileFilter.I -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaFileFilter.I + * @author drose + * @date 2006-07-27 + */ diff --git a/pandatool/src/egg-palettize/txaFileFilter.cxx b/pandatool/src/egg-palettize/txaFileFilter.cxx index 529b9619c1..a8f6c21507 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.cxx +++ b/pandatool/src/egg-palettize/txaFileFilter.cxx @@ -1,16 +1,15 @@ -// Filename: txaFileFilter.cxx -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaFileFilter.cxx + * @author drose + * @date 2006-07-27 + */ #include "txaFileFilter.h" #include "palettizer.h" @@ -26,8 +25,8 @@ NotifyCategoryDeclNoExport(txafile); NotifyCategoryDef(txafile, ""); -// A few lines to register this filter type with the TexturePool when -// the shared library is loaded. +// A few lines to register this filter type with the TexturePool when the +// shared library is loaded. Configure(config_txaFileFilter); ConfigureFn(config_txaFileFilter) { TxaFileFilter::init_type(); @@ -39,17 +38,13 @@ TypeHandle TxaFileFilter::_type_handle; TxaFile *TxaFileFilter::_txa_file; bool TxaFileFilter::_got_txa_file; -//////////////////////////////////////////////////////////////////// -// Function: TxaFileFilter::post_load -// Access: Public, Virtual -// Description: This method is called after each texture has been -// loaded from disk, via the TexturePool, for the first -// time. By the time this method is called, the Texture -// has already been fully read from disk. This method -// should return the Texture pointer that the -// TexturePool should actually return (usually it is the -// same as the pointer supplied). -//////////////////////////////////////////////////////////////////// +/** + * This method is called after each texture has been loaded from disk, via the + * TexturePool, for the first time. By the time this method is called, the + * Texture has already been fully read from disk. This method should return + * the Texture pointer that the TexturePool should actually return (usually it + * is the same as the pointer supplied). + */ PT(Texture) TxaFileFilter:: post_load(Texture *tex) { if (!_got_txa_file) { @@ -82,17 +77,16 @@ post_load(Texture *tex) { tex_image.post_txa_file(); - PNMImage dest(tex_image.get_x_size(), - tex_image.get_y_size(), + PNMImage dest(tex_image.get_x_size(), + tex_image.get_y_size(), tex_image.get_num_channels(), pnm_image.get_maxval()); dest.quick_filter_from(pnm_image); tex->load(dest); - // Create an EggTexture to pass back the requested alpha mode to - // the egg loader, if the texture is now being loaded from an egg - // file. + // Create an EggTexture to pass back the requested alpha mode to the egg + // loader, if the texture is now being loaded from an egg file. PT_EggTexture egg_tex = new EggTexture(tex->get_name(), tex->get_fullpath()); const TextureProperties &props = tex_image.get_properties(); @@ -107,25 +101,23 @@ post_load(Texture *tex) { return tex; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFileFilter::read_txa_file -// Access: Private, Static -// Description: Reads the textures.txa file named by the variable -// txa-file. Called only once, at startup. -//////////////////////////////////////////////////////////////////// +/** + * Reads the textures.txa file named by the variable txa-file. Called only + * once, at startup. + */ void TxaFileFilter:: read_txa_file() { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); - // We need to create a global Palettizer object to hold some of the - // global properties that may be specified in a txa file. + // We need to create a global Palettizer object to hold some of the global + // properties that may be specified in a txa file. if (pal == (Palettizer *)NULL) { pal = new Palettizer; } _txa_file = new TxaFile; _got_txa_file = true; - + ConfigVariableFilename txa_file ("txa-file", Filename("textures.txa"), PRC_DESC("Specify the name of the txa file to load when the txafile texture filter" diff --git a/pandatool/src/egg-palettize/txaFileFilter.h b/pandatool/src/egg-palettize/txaFileFilter.h index 793687526f..a2f13a7139 100644 --- a/pandatool/src/egg-palettize/txaFileFilter.h +++ b/pandatool/src/egg-palettize/txaFileFilter.h @@ -1,16 +1,15 @@ -// Filename: txaFileFilter.h -// Created by: drose (27Jul06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaFileFilter.h + * @author drose + * @date 2006-07-27 + */ #ifndef TXAFILEFILTER_H #define TXAFILEFILTER_H @@ -21,28 +20,24 @@ class TxaFile; -//////////////////////////////////////////////////////////////////// -// Class : TxaFileFilter -// Description : This is an abstract base class, a placeholder for any -// number of different classes that may wish to -// implement an effect on every texture loaded from disk -// via the TexturePool. -// -// In practice, as of the time of this writing, only the -// TxaFileFilter (in pandatool) actually implements -// this. But other kinds of filters are possible. -// -// This filter, once registered, will get a callback and -// a chance to modify each texture as it is loaded from -// disk the first time. If more than one filter is -// registered, each will be called in sequence, in the -// order in which they were registered. -// -// The filter does not get called again if the texture -// is subsequently reloaded from disk. It is suggested -// that filters for which this might be a problem should -// call tex->set_keep_ram_image(true). -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class, a placeholder for any number of different + * classes that may wish to implement an effect on every texture loaded from + * disk via the TexturePool. + * + * In practice, as of the time of this writing, only the TxaFileFilter (in + * pandatool) actually implements this. But other kinds of filters are + * possible. + * + * This filter, once registered, will get a callback and a chance to modify + * each texture as it is loaded from disk the first time. If more than one + * filter is registered, each will be called in sequence, in the order in + * which they were registered. + * + * The filter does not get called again if the texture is subsequently + * reloaded from disk. It is suggested that filters for which this might be a + * problem should call tex->set_keep_ram_image(true). + */ class EXPCL_MISC TxaFileFilter : public TexturePoolFilter { public: virtual PT(Texture) post_load(Texture *tex); diff --git a/pandatool/src/egg-qtess/config_egg_qtess.cxx b/pandatool/src/egg-qtess/config_egg_qtess.cxx index f230daa149..de3dbf956d 100644 --- a/pandatool/src/egg-qtess/config_egg_qtess.cxx +++ b/pandatool/src/egg-qtess/config_egg_qtess.cxx @@ -1,16 +1,15 @@ -// Filename: config_egg_qtess.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg_qtess.cxx + * @author drose + * @date 2003-10-13 + */ #include "config_egg_qtess.h" diff --git a/pandatool/src/egg-qtess/config_egg_qtess.h b/pandatool/src/egg-qtess/config_egg_qtess.h index 67ea79e74a..abc9ef397e 100644 --- a/pandatool/src/egg-qtess/config_egg_qtess.h +++ b/pandatool/src/egg-qtess/config_egg_qtess.h @@ -1,16 +1,15 @@ -// Filename: config_egg_qtess.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_egg_qtess.h + * @author drose + * @date 2003-10-13 + */ #ifndef CONFIG_EGG_QTESS_H #define CONFIG_EGG_QTESS_H diff --git a/pandatool/src/egg-qtess/eggQtess.cxx b/pandatool/src/egg-qtess/eggQtess.cxx index 50ae8544dd..df0e63e830 100644 --- a/pandatool/src/egg-qtess/eggQtess.cxx +++ b/pandatool/src/egg-qtess/eggQtess.cxx @@ -1,27 +1,24 @@ -// Filename: eggQtess.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggQtess.cxx + * @author drose + * @date 2003-10-13 + */ #include "eggQtess.h" #include "qtessGlobals.h" #include "dcast.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggQtess::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggQtess:: EggQtess() { add_normals_options(); @@ -114,14 +111,11 @@ EggQtess() { _total_tris = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggQtess::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggQtess:: handle_args(ProgramBase::Args &args) { if (_describe_qtess) { @@ -132,11 +126,9 @@ handle_args(ProgramBase::Args &args) { return EggFilter::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: EggQtess::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggQtess:: run() { bool read_qtess = false; @@ -162,8 +154,8 @@ run() { int num_tris = _qtess_file.count_tris(); if (_total_tris != 0) { - // Whatever number of triangles we have unaccounted for, assign to - // the default bucket. + // Whatever number of triangles we have unaccounted for, assign to the + // default bucket. int extra_tris = max(0, _total_tris - num_tris); if (read_qtess && default_entry.get_num_surfaces() != 0) { cerr << extra_tris << " triangles unaccounted for.\n"; @@ -185,7 +177,7 @@ run() { if (_qtess_output) { // Sort the names into alphabetical order for aesthetics. - //sort(_surfaces.begin(), _surfaces.end(), compare_surfaces()); + // sort(_surfaces.begin(), _surfaces.end(), compare_surfaces()); int tris = 0; @@ -194,7 +186,7 @@ run() { for (si = _surfaces.begin(); si != _surfaces.end(); ++si) { tris += (*si)->write_qtess_parameter(out); } - + cerr << tris << " tris generated.\n"; } else { @@ -205,12 +197,11 @@ run() { for (si = _surfaces.begin(); si != _surfaces.end(); ++si) { tris += (*si)->tesselate(); } - + cerr << tris << " tris generated.\n"; - // Clear out the surfaces list before removing the vertices, since - // each surface is holding reference counts to the previously-used - // vertices. + // Clear out the surfaces list before removing the vertices, since each + // surface is holding reference counts to the previously-used vertices. _surfaces.clear(); _data->remove_unused_vertices(true); @@ -218,11 +209,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggQtess::describe_qtess_format -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggQtess:: describe_qtess_format() { nout << @@ -247,7 +236,7 @@ describe_qtess_format() { show_text(" NUM", 10, "Try to achieve the indicated number of triangles over all the " "surfaces matched by this line.\n\n"); - + show_text(" NUM NUM [[!]u# [!]u# ...] [[!]v# [!]v# ...]", 10, "Tesselate to NUM x NUM quads. If u# or v# appear, they indicate " "additional isoparams to insert (or remove if preceded by an " @@ -256,7 +245,7 @@ describe_qtess_format() { show_text(" iNUM", 10, "Subdivision amount per isoparam. Equivalent to the command-line " "option -u NUM.\n\n"); - + show_text(" NUM%", 10, "This is a special parameter. This does not request any specific " "tesselation for the named surfaces, but instead gives a relative " @@ -317,16 +306,13 @@ describe_qtess_format() { "to indicate a continuation.\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggQtess::find_surfaces -// Access: Private -// Description: Recursively walks the egg graph, collecting all the -// NURBS surfaces found. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg graph, collecting all the NURBS surfaces found. + */ void EggQtess:: find_surfaces(EggNode *egg_node) { if (egg_node->is_of_type(EggNurbsSurface::get_class_type())) { - PT(QtessSurface) surface = + PT(QtessSurface) surface = new QtessSurface(DCAST(EggNurbsSurface, egg_node)); if (surface->is_valid()) { _surfaces.push_back(surface); @@ -353,4 +339,3 @@ int main(int argc, char *argv[]) { prog.run(); return 0; } - diff --git a/pandatool/src/egg-qtess/eggQtess.h b/pandatool/src/egg-qtess/eggQtess.h index 575156b25e..c18db52ef8 100644 --- a/pandatool/src/egg-qtess/eggQtess.h +++ b/pandatool/src/egg-qtess/eggQtess.h @@ -1,16 +1,15 @@ -// Filename: eggQtess.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggQtess.h + * @author drose + * @date 2003-10-13 + */ #ifndef EGGQTESS_H #define EGGQTESS_H @@ -22,12 +21,10 @@ #include "pointerTo.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : EggQtess -// Description : A program to tesselate NURBS surfaces appearing -// within an egg file into polygons, using variations on -// a quick uniform tesselation. -//////////////////////////////////////////////////////////////////// +/** + * A program to tesselate NURBS surfaces appearing within an egg file into + * polygons, using variations on a quick uniform tesselation. + */ class EggQtess : public EggFilter { public: EggQtess(); @@ -49,11 +46,9 @@ private: bool _describe_qtess; QtessInputFile _qtess_file; - + typedef pvector< PT(QtessSurface) > Surfaces; Surfaces _surfaces; }; #endif - - diff --git a/pandatool/src/egg-qtess/isoPlacer.I b/pandatool/src/egg-qtess/isoPlacer.I index d1b96e60c6..f773b8fbf8 100644 --- a/pandatool/src/egg-qtess/isoPlacer.I +++ b/pandatool/src/egg-qtess/isoPlacer.I @@ -1,33 +1,27 @@ -// Filename: isoPlacer.I -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file isoPlacer.I + * @author drose + * @date 2003-10-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IsoPlacer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IsoPlacer:: IsoPlacer() { } -//////////////////////////////////////////////////////////////////// -// Function: IsoPlacer::get_total_score -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE double IsoPlacer:: get_total_score() const { return _cint[_maxi]; diff --git a/pandatool/src/egg-qtess/isoPlacer.cxx b/pandatool/src/egg-qtess/isoPlacer.cxx index 7c22d3bafd..25c7a38b0a 100644 --- a/pandatool/src/egg-qtess/isoPlacer.cxx +++ b/pandatool/src/egg-qtess/isoPlacer.cxx @@ -1,16 +1,15 @@ -// Filename: isoPlacer.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file isoPlacer.cxx + * @author drose + * @date 2003-10-13 + */ #include "isoPlacer.h" #include "qtessSurface.h" @@ -19,11 +18,9 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Function: IsoPlacer::get_scores -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IsoPlacer:: get_scores(int subdiv, int across, double ratio, NurbsSurfaceResult *surf, bool s) { @@ -35,8 +32,7 @@ get_scores(int subdiv, int across, double ratio, _cscore.reserve(_maxi); _sscore.reserve(_maxi); - // First, tally up the curvature and stretch scores across the - // surface. + // First, tally up the curvature and stretch scores across the surface. int i = 0; for (i = 0; i < _maxi; i++) { _cscore.push_back(0.0); @@ -64,8 +60,8 @@ get_scores(int subdiv, int across, double ratio, surf->eval_point(v, u, pnext); } - // We'll ignore consecutive equal points. They don't contribute - // to curvature or size. + // We'll ignore consecutive equal points. They don't contribute to + // curvature or size. if (!pnext.almost_equal(p3)) { num_points++; p1 = p2; @@ -82,8 +78,8 @@ get_scores(int subdiv, int across, double ratio, } if (num_points >= 3) { - // We only have a meaningful v1, v2 when we've read at least - // three non-equal points. + // We only have a meaningful v1, v2 when we've read at least three + // non-equal points. double d = v1.dot(v2); _cscore[i] += acos(max(min(d, 1.0), -1.0)); @@ -105,11 +101,9 @@ get_scores(int subdiv, int across, double ratio, } } -//////////////////////////////////////////////////////////////////// -// Function: IsoPlacer::place -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IsoPlacer:: place(int count, pvector &iso_points) { int i; @@ -121,8 +115,7 @@ place(int count, pvector &iso_points) { } avg_curve /= (double)_maxi; - // Find all the local maxima in the curvature table. These are bend - // points. + // Find all the local maxima in the curvature table. These are bend points. typedef pvector BendPoints; BendPoints bpoints; BendPoints::iterator bi, bnext; @@ -132,13 +125,13 @@ place(int count, pvector &iso_points) { Segments::iterator si; /* - // Having problems with bend points right now. Maybe this is just a - // bad idea. It seems to work pretty well without them, anyway. + // Having problems with bend points right now. Maybe this is just a bad + // idea. It seems to work pretty well without them, anyway. for (i = 1; i < _maxi-1; i++) { - // A point must be measurably higher than both its neighbors, as - // well as at least 50% more curvy than the average curvature, to - // qualify as a bend point. - if (_cscore[i] > _cscore[i-1]+0.001 && + // A point must be measurably higher than both its neighbors, as well as + // at least 50% more curvy than the average curvature, to qualify as a + // bend point. + if (_cscore[i] > _cscore[i-1]+0.001 && _cscore[i] > _cscore[i+1]+0.001 && _cscore[i] > 1.5 * avg_curve) { bpoints.push_back(i); @@ -146,8 +139,8 @@ place(int count, pvector &iso_points) { } */ - // Now make sure there aren't any two bend points closer together - // than maxi/count. If there are, remove the smaller of the two. + // Now make sure there aren't any two bend points closer together than + // maxicount. If there are, remove the smaller of the two. bi = bpoints.begin(); int min_separation = _maxi/count; while (bi != bpoints.end()) { @@ -166,8 +159,8 @@ place(int count, pvector &iso_points) { } } - // Now, if we have fewer total subdivisions than bend points, then - // remove the smallest bend points. + // Now, if we have fewer total subdivisions than bend points, then remove + // the smallest bend points. while (count - 1 < (int)bpoints.size()) { bi = bpoints.begin(); BendPoints::iterator mi = bi; @@ -190,10 +183,9 @@ place(int count, pvector &iso_points) { int nr = count - segments.size(); - // Now we have subdivided the curve into a number of smaller curves - // at the bend points. We still have nr remaining cuts to make; - // distribute these cuts among the curves evenly according to - // score. + // Now we have subdivided the curve into a number of smaller curves at the + // bend points. We still have nr remaining cuts to make; distribute these + // cuts among the curves evenly according to score. // Divvy out the extra cuts. First, each segment gets an amount // proportional to its score. @@ -234,5 +226,3 @@ place(int count, pvector &iso_points) { // Oh, wait. The last segment is actually drawn all the way to 1. iso_points.back() = 1.0; } - - diff --git a/pandatool/src/egg-qtess/isoPlacer.h b/pandatool/src/egg-qtess/isoPlacer.h index 984372ed8a..b469634029 100644 --- a/pandatool/src/egg-qtess/isoPlacer.h +++ b/pandatool/src/egg-qtess/isoPlacer.h @@ -1,16 +1,15 @@ -// Filename: isoPlacer.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file isoPlacer.h + * @author drose + * @date 2003-10-13 + */ #ifndef ISOPLACER_H #define ISOPLACER_H @@ -21,11 +20,10 @@ class NurbsSurfaceResult; -//////////////////////////////////////////////////////////////////// -// Class : IsoPlacer -// Description : Contains the logic used to place isoparams where -// they'll do the most good on a surface. -//////////////////////////////////////////////////////////////////// +/** + * Contains the logic used to place isoparams where they'll do the most good + * on a surface. + */ class IsoPlacer { public: INLINE IsoPlacer(); @@ -43,4 +41,3 @@ public: #include "isoPlacer.I" #endif - diff --git a/pandatool/src/egg-qtess/qtessGlobals.cxx b/pandatool/src/egg-qtess/qtessGlobals.cxx index a8ec1f0ed1..85fb91fb17 100644 --- a/pandatool/src/egg-qtess/qtessGlobals.cxx +++ b/pandatool/src/egg-qtess/qtessGlobals.cxx @@ -1,16 +1,15 @@ -// Filename: qtessGlobals.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessGlobals.cxx + * @author drose + * @date 2003-10-13 + */ #include "qtessGlobals.h" diff --git a/pandatool/src/egg-qtess/qtessGlobals.h b/pandatool/src/egg-qtess/qtessGlobals.h index 2b5cb3a643..d741293497 100644 --- a/pandatool/src/egg-qtess/qtessGlobals.h +++ b/pandatool/src/egg-qtess/qtessGlobals.h @@ -1,28 +1,25 @@ -// Filename: qtessGlobals.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessGlobals.h + * @author drose + * @date 2003-10-13 + */ #ifndef QTESS_GLOBALS_H #define QTESS_GLOBALS_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : QtessGlobals -// Description : Simply used as a namespace to scope some global -// variables for this program, set from the command -// line. -//////////////////////////////////////////////////////////////////// +/** + * Simply used as a namespace to scope some global variables for this program, + * set from the command line. + */ class QtessGlobals { public: static bool _auto_place; @@ -32,4 +29,3 @@ public: }; #endif - diff --git a/pandatool/src/egg-qtess/qtessInputEntry.I b/pandatool/src/egg-qtess/qtessInputEntry.I index 73c3e4388f..5c8adde257 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.I +++ b/pandatool/src/egg-qtess/qtessInputEntry.I @@ -1,183 +1,149 @@ -// Filename: qtessInputEntry.I -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputEntry.I + * @author drose + * @date 2003-10-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE QtessInputEntry:: QtessInputEntry(const QtessInputEntry ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::add_node_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: add_node_name(const string &name) { _node_names.push_back(GlobPattern(name)); } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_importance -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_importance(double i) { _importance = i; _type = T_importance; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_match_uu -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_match_uu() { _type = T_match_uu; _constrain_u = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_match_vv -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_match_vv() { _type = T_match_vv; _constrain_v = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_match_uv -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_match_uv() { _type = T_match_uv; _constrain_u = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_match_vu -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_match_vu() { _type = T_match_vu; _constrain_v = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_min_u -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_min_u(int min_u) { _type = T_min_u; _num_u = min_u; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_min_v -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_min_v(int min_v) { _type = T_min_v; _num_v = min_v; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_undefined -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_undefined() { _type = T_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_omit -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_omit() { _type = T_omit; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_num_tris -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_num_tris(int nt) { _num_tris = nt; _type = T_num_tris; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_uv -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_uv(int u, int v) { set_uv(u, v, NULL, 0); } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_per_isoparam -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_per_isoparam(double pi) { _per_isoparam = pi; _type = T_per_isoparam; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_per_score -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputEntry:: set_per_score(double pi) { _per_isoparam = pi; _type = T_per_score; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::get_num_surfaces -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int QtessInputEntry:: get_num_surfaces() const { return _surfaces.size(); @@ -188,4 +154,3 @@ INLINE ostream &operator << (ostream &out, const QtessInputEntry &entry) { entry.output(out); return out; } - diff --git a/pandatool/src/egg-qtess/qtessInputEntry.cxx b/pandatool/src/egg-qtess/qtessInputEntry.cxx index fe95a59708..e7547e359e 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.cxx +++ b/pandatool/src/egg-qtess/qtessInputEntry.cxx @@ -1,16 +1,15 @@ -// Filename: qtessInputEntry.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputEntry.cxx + * @author drose + * @date 2003-10-13 + */ #include "qtessInputEntry.h" #include "qtessSurface.h" @@ -22,11 +21,9 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QtessInputEntry:: QtessInputEntry(const string &name) { _type = T_undefined; @@ -39,11 +36,9 @@ QtessInputEntry(const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void QtessInputEntry:: operator = (const QtessInputEntry ©) { _node_names = copy._node_names; @@ -64,11 +59,10 @@ operator = (const QtessInputEntry ©) { _constrain_v = copy._constrain_v; } -//////////////////////////////////////////////////////////////////// -// Class : DoublesAlmostEqual -// Description : An STL function object to determine if two doubles -// are very nearly equal. Used in set_uv(), below. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object to determine if two doubles are very nearly equal. + * Used in set_uv(), below. + */ class DoublesAlmostEqual { public: int operator ()(double a, double b) const { @@ -76,12 +70,10 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Class : DoubleAlmostMatches -// Description : An STL function object to determine if a double -// is vert nearly equal the supplied value . Used in -// set_uv(), below. -//////////////////////////////////////////////////////////////////// +/** + * An STL function object to determine if a double is vert nearly equal the + * supplied value . Used in set_uv(), below. + */ class DoubleAlmostMatches { public: DoubleAlmostMatches(double v) : _v(v) {} @@ -92,13 +84,10 @@ public: }; -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::set_uv -// Access: Public -// Description: Sets specific tesselation. The tesselation will be u -// by v quads, with the addition of any isoparams -// described in the list of params. -//////////////////////////////////////////////////////////////////// +/** + * Sets specific tesselation. The tesselation will be u by v quads, with the + * addition of any isoparams described in the list of params. + */ void QtessInputEntry:: set_uv(int u, int v, const string params[], int num_params) { _num_u = u; @@ -126,11 +115,11 @@ set_uv(int u, int v, const string params[], int num_params) { switch (tolower(param[1])) { case 'u': _auto_place = false; - _iso_u.erase(remove_if(_iso_u.begin(), _iso_u.end(), + _iso_u.erase(remove_if(_iso_u.begin(), _iso_u.end(), DoubleAlmostMatches(value)), _iso_u.end()); break; - + case 'v': _auto_place = false; _iso_v.erase(remove_if(_iso_v.begin(), _iso_v.end(), @@ -154,12 +143,12 @@ set_uv(int u, int v, const string params[], int num_params) { _auto_place = false; _iso_u.push_back(value); break; - + case 'v': _auto_place = false; _iso_v.push_back(value); break; - + default: qtess_cat.warning() << "Ignoring invalid parameter: " << params[i] << "\n"; @@ -178,37 +167,30 @@ set_uv(int u, int v, const string params[], int num_params) { } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::add_extra_u_isoparam -// Access: Public -// Description: May be called a number of times before set_uv() to add -// specific additional isoparams to the tesselation. -//////////////////////////////////////////////////////////////////// +/** + * May be called a number of times before set_uv() to add specific additional + * isoparams to the tesselation. + */ void QtessInputEntry:: add_extra_u_isoparam(double u) { _iso_u.push_back(u); } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::add_extra_v_isoparam -// Access: Public -// Description: May be called a number of times before set_uv() to add -// specific additional isoparams to the tesselation. -//////////////////////////////////////////////////////////////////// +/** + * May be called a number of times before set_uv() to add specific additional + * isoparams to the tesselation. + */ void QtessInputEntry:: add_extra_v_isoparam(double v) { _iso_v.push_back(v); } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::match -// Access: Public -// Description: Tests the surface to see if it matches any of the -// regular expressions that define this node entry. If -// so, adds it to the set of matched surfaces and -// returns the type of the matching entry. If no match -// is found, returns T_undefined. -//////////////////////////////////////////////////////////////////// +/** + * Tests the surface to see if it matches any of the regular expressions that + * define this node entry. If so, adds it to the set of matched surfaces and + * returns the type of the matching entry. If no match is found, returns + * T_undefined. + */ QtessInputEntry::Type QtessInputEntry:: match(QtessSurface *surface) { const string &name = surface->get_name(); @@ -222,14 +204,14 @@ match(QtessSurface *surface) { // We have a winner! switch (_type) { case T_importance: - // A type of "Importance" is a special case. This entry - // doesn't specify any kind of tesselation on the surface, and - // in fact doesn't preclude the surface from matching anything - // later. It just specifies the relative importance of the - // surface to all the other surfaces. + // A type of "Importance" is a special case. This entry doesn't + // specify any kind of tesselation on the surface, and in fact doesn't + // preclude the surface from matching anything later. It just + // specifies the relative importance of the surface to all the other + // surfaces. if (qtess_cat.is_debug()) { - qtess_cat.debug() - << "Assigning importance of " << _importance*100.0 + qtess_cat.debug() + << "Assigning importance of " << _importance*100.0 << "% to " << name << "\n"; } surface->set_importance(_importance); @@ -237,10 +219,9 @@ match(QtessSurface *surface) { case T_match_uu: case T_match_uv: - // Similarly for type "matchUU". This indicates that all the - // surfaces that match this one must all share the - // U-tesselation with whichever surface first matched against - // the first node name. + // Similarly for type "matchUU". This indicates that all the surfaces + // that match this one must all share the U-tesselation with whichever + // surface first matched against the first node name. if (nni == _node_names.begin() && _constrain_u==NULL) { // This is the lucky surface that dominates! _constrain_u = surface; @@ -302,23 +283,19 @@ match(QtessSurface *surface) { return T_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::count_tris -// Access: Public -// Description: Determines the tesselation u,v amounts of each -// attached surface, and stores this information in the -// surface pointer. Returns the total number of tris -// that will be produced. -//////////////////////////////////////////////////////////////////// +/** + * Determines the tesselation u,v amounts of each attached surface, and stores + * this information in the surface pointer. Returns the total number of tris + * that will be produced. + */ int QtessInputEntry:: count_tris(double tri_factor, int attempts) { int total_tris = 0; bool aim_for_tris = false; if (_type == T_num_tris && _num_patches > 0.0) { - // If we wanted to aim for a particular number of triangles for - // the group, choose a per-isoparam setting that will approximately - // achieve this. + // If we wanted to aim for a particular number of triangles for the group, + // choose a per-isoparam setting that will approximately achieve this. if (_auto_distribute) { set_per_score(sqrt(0.5 * (double)_num_tris / _num_patches / tri_factor)); } else { @@ -336,7 +313,7 @@ count_tris(double tri_factor, int attempts) { case T_omit: surface->omit(); break; - + case T_uv: if (!_iso_u.empty() && !_iso_v.empty() && !_auto_place) { surface->tesselate_specific(_iso_u, _iso_v); @@ -344,11 +321,11 @@ count_tris(double tri_factor, int attempts) { surface->tesselate_uv(_num_u, _num_v, _auto_place, _curvature_ratio); } break; - + case T_per_isoparam: surface->tesselate_per_isoparam(_per_isoparam, _auto_place, _curvature_ratio); break; - + case T_per_score: surface->tesselate_per_score(_per_isoparam, _auto_place, _curvature_ratio); break; @@ -360,11 +337,10 @@ count_tris(double tri_factor, int attempts) { total_tris += surface->count_tris(); } - if (aim_for_tris && attempts < 10 && + if (aim_for_tris && attempts < 10 && (double)total_tris / (double)_num_tris > 1.1) { - // We'd like to get within 10% of the requested number of - // triangles, if possible. Keep trying until we do, or until we - // just need to give up. + // We'd like to get within 10% of the requested number of triangles, if + // possible. Keep trying until we do, or until we just need to give up. set_num_tris(_num_tris); return count_tris(tri_factor * total_tris / _num_tris, attempts + 1); } @@ -373,12 +349,10 @@ count_tris(double tri_factor, int attempts) { } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::output_extra -// Access: Public, Static -// Description: This function is used to identify the extra isoparams -// in the list added by user control. -//////////////////////////////////////////////////////////////////// +/** + * This function is used to identify the extra isoparams in the list added by + * user control. + */ void QtessInputEntry:: output_extra(ostream &out, const pvector &iso, char axis) { pvector::const_iterator di; @@ -398,11 +372,9 @@ output_extra(ostream &out, const pvector &iso, char axis) { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void QtessInputEntry:: output(ostream &out) const { NodeNames::const_iterator nni; @@ -427,7 +399,7 @@ output(ostream &out) const { out << _num_tris; show_auto = true; break; - + case T_uv: out << _num_u << " " << _num_v; output_extra(out, _iso_u, 'u'); @@ -482,11 +454,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputEntry::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void QtessInputEntry:: write(ostream &out, int indent_level) const { indent(out, indent_level) << (*this) << "\n"; diff --git a/pandatool/src/egg-qtess/qtessInputEntry.h b/pandatool/src/egg-qtess/qtessInputEntry.h index 8d9b19f7b2..170d0fadf3 100644 --- a/pandatool/src/egg-qtess/qtessInputEntry.h +++ b/pandatool/src/egg-qtess/qtessInputEntry.h @@ -1,16 +1,15 @@ -// Filename: qtessInputEntry.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputEntry.h + * @author drose + * @date 2003-10-13 + */ #ifndef QTESSINPUTENTRY_H #define QTESSINPUTENTRY_H @@ -21,12 +20,10 @@ class QtessSurface; -//////////////////////////////////////////////////////////////////// -// Class : QtessInputEntry -// Description : Stores one entry in the qtess input file. This -// consists of a list of name patterns and a -// set of tesselation parameters. -//////////////////////////////////////////////////////////////////// +/** + * Stores one entry in the qtess input file. This consists of a list of name + * patterns and a set of tesselation parameters. + */ class QtessInputEntry { public: enum Type { @@ -91,4 +88,3 @@ INLINE ostream &operator << (ostream &out, const QtessInputEntry &entry); #include "qtessInputEntry.I" #endif - diff --git a/pandatool/src/egg-qtess/qtessInputFile.I b/pandatool/src/egg-qtess/qtessInputFile.I index 20e716895b..313b59c8a8 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.I +++ b/pandatool/src/egg-qtess/qtessInputFile.I @@ -1,34 +1,28 @@ -// Filename: qtessInputFile.I -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputFile.I + * @author drose + * @date 2003-10-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE QtessInputFile:: -QtessInputFile(const QtessInputFile ©) : - _entries(copy._entries) -{ +QtessInputFile(const QtessInputFile ©) : + _entries(copy._entries) +{ } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void QtessInputFile:: operator = (const QtessInputFile ©) { _entries = copy._entries; diff --git a/pandatool/src/egg-qtess/qtessInputFile.cxx b/pandatool/src/egg-qtess/qtessInputFile.cxx index ffa98b8273..647f0b8471 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.cxx +++ b/pandatool/src/egg-qtess/qtessInputFile.cxx @@ -1,35 +1,30 @@ -// Filename: qtessInputFile.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputFile.cxx + * @author drose + * @date 2003-10-13 + */ #include "qtessInputFile.h" #include "config_egg_qtess.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QtessInputFile:: QtessInputFile() { } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::read -// Access: Public -// Description: reads the input file. -//////////////////////////////////////////////////////////////////// +/** + * reads the input file. + */ bool QtessInputFile:: read(const Filename &filename) { _filename = Filename::text_filename(filename); @@ -49,8 +44,8 @@ read(const Filename &filename) { while (getline(input, line)) { line_number++; - // Eliminate comments. We have to scan the line repeatedly until - // we find the first hash mark that's preceded by whitespace. + // Eliminate comments. We have to scan the line repeatedly until we find + // the first hash mark that's preceded by whitespace. size_t comment = line.find('#'); while (comment != string::npos) { if (comment == 0 || isspace(line[comment - 1])) { @@ -86,24 +81,23 @@ read(const Filename &filename) { } if (colon == 0) { qtess_cat.error() - << _filename << ": line " << line_number + << _filename << ": line " << line_number << " has no nodes.\n"; return false; } - // Split the line into two groups of words at the colon: names - // before the colon, and params following it. + // Split the line into two groups of words at the colon: names before + // the colon, and params following it. vector_string names, params; extract_words(line.substr(0, colon), names); extract_words(line.substr(colon + 1), params); - + vector_string::const_iterator ni; for (ni = names.begin(); ni != names.end(); ++ni) { entry.add_node_name(*ni); } - // Scan for things like ap, ad, ar, and pull them out of the - // stream. + // Scan for things like ap, ad, ar, and pull them out of the stream. vector_string::iterator ci, cnext; ci = params.begin(); while (ci != params.end()) { @@ -129,7 +123,7 @@ read(const Filename &filename) { case 'r': if (!string_to_double(param.substr(2), entry._curvature_ratio)) { qtess_cat.error() - << _filename << ": line " << line_number + << _filename << ": line " << line_number << " - invalid field " << param << "\n"; return false; } @@ -137,7 +131,7 @@ read(const Filename &filename) { default: qtess_cat.error() - << _filename << ": invalid parameters at line " + << _filename << ": invalid parameters at line " << line_number << ".\n"; return false; } @@ -226,7 +220,7 @@ read(const Filename &filename) { if (!okflag) { qtess_cat.error() - << _filename << ": invalid parameters at line " + << _filename << ": invalid parameters at line " << line_number << ".\n"; return false; } @@ -249,14 +243,11 @@ read(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::get_default_entry -// Access: Public -// Description: Returns a reference to the last entry on the list, -// which is the "default" entry that will match any -// surface that does not get explicitly named in the -// input file. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to the last entry on the list, which is the "default" + * entry that will match any surface that does not get explicitly named in the + * input file. + */ QtessInputEntry &QtessInputFile:: get_default_entry() { if (_entries.empty()) { @@ -267,19 +258,15 @@ get_default_entry() { } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::match -// Access: Public -// Description: Attempts to find a match for the given surface in the -// user input entries. Searches in the order in which -// the entries were defined, and chooses the first -// match. -// -// When a match is found, the surface is added to the -// entry's set of matched surfaces. Returns the type of -// the matching node if a match is found, or T_undefined -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to find a match for the given surface in the user input entries. + * Searches in the order in which the entries were defined, and chooses the + * first match. + * + * When a match is found, the surface is added to the entry's set of matched + * surfaces. Returns the type of the matching node if a match is found, or + * T_undefined otherwise. + */ QtessInputEntry::Type QtessInputFile:: match(QtessSurface *surface) { QtessInputEntry::Type type; @@ -299,14 +286,11 @@ match(QtessSurface *surface) { return QtessInputEntry::T_undefined; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::count_tris -// Access: Public -// Description: Determines the tesselation u,v amounts of each -// attached surface, and stores this information in the -// surface pointer. Returns the total number of tris -// that will be produced. -//////////////////////////////////////////////////////////////////// +/** + * Determines the tesselation u,v amounts of each attached surface, and stores + * this information in the surface pointer. Returns the total number of tris + * that will be produced. + */ int QtessInputFile:: count_tris() { int total_tris = 0; @@ -318,11 +302,9 @@ count_tris() { return total_tris; } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void QtessInputFile:: write(ostream &out, int indent_level) const { Entries::const_iterator ei; @@ -331,12 +313,10 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessInputFile::add_default_entry -// Access: Private -// Description: Adds one more entry to the end of the list, to catch -// all of the surfaces that didn't get explicitly named. -//////////////////////////////////////////////////////////////////// +/** + * Adds one more entry to the end of the list, to catch all of the surfaces + * that didn't get explicitly named. + */ void QtessInputFile:: add_default_entry() { QtessInputEntry entry("*"); diff --git a/pandatool/src/egg-qtess/qtessInputFile.h b/pandatool/src/egg-qtess/qtessInputFile.h index 5d9fdef033..7b015b46ac 100644 --- a/pandatool/src/egg-qtess/qtessInputFile.h +++ b/pandatool/src/egg-qtess/qtessInputFile.h @@ -1,16 +1,15 @@ -// Filename: qtessInputFile.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessInputFile.h + * @author drose + * @date 2003-10-13 + */ #ifndef QTESSINPUTFILE_H #define QTESSINPUTFILE_H @@ -22,11 +21,10 @@ class QtessSurface; -//////////////////////////////////////////////////////////////////// -// Class : QtessInputFile -// Description : Stores all the information read from a tesselation -// input file: a list of QtessInputEntry's. -//////////////////////////////////////////////////////////////////// +/** + * Stores all the information read from a tesselation input file: a list of + * QtessInputEntry's. + */ class QtessInputFile { public: QtessInputFile(); diff --git a/pandatool/src/egg-qtess/qtessSurface.I b/pandatool/src/egg-qtess/qtessSurface.I index c37a65c808..cc53d0f403 100644 --- a/pandatool/src/egg-qtess/qtessSurface.I +++ b/pandatool/src/egg-qtess/qtessSurface.I @@ -1,145 +1,114 @@ -// Filename: qtessSurface.I -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessSurface.I + * @author drose + * @date 2003-10-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::get_name -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE const string &QtessSurface:: get_name() const { return _egg_surface->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::is_valid -// Access: Public -// Description: Returns true if the defined surface is valid, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the defined surface is valid, false otherwise. + */ INLINE bool QtessSurface:: is_valid() const { return (_nurbs != (NurbsSurfaceEvaluator *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::set_importance -// Access: Public -// Description: Sets the importance of the surface, as a ratio in -// proportion to the square of its size. -//////////////////////////////////////////////////////////////////// +/** + * Sets the importance of the surface, as a ratio in proportion to the square + * of its size. + */ INLINE void QtessSurface:: set_importance(double importance2) { _importance = sqrt(importance2); _importance2 = importance2; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::set_match_u -// Access: Public -// Description: Indicates the surface to which this surface must -// match in its U direction. If u_to_u is true, it -// matches to the other surface's U direction; -// otherwise, it matches to the other surface's V -// direction. -// -// Note that the surface pointer is an indirect pointer. -// The value passed in is the address of the pointer to -// the actual surface (which may or may not be filled in -// yet). The actual pointer may be filled in later. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the surface to which this surface must match in its U direction. + * If u_to_u is true, it matches to the other surface's U direction; + * otherwise, it matches to the other surface's V direction. + * + * Note that the surface pointer is an indirect pointer. The value passed in + * is the address of the pointer to the actual surface (which may or may not + * be filled in yet). The actual pointer may be filled in later. + */ INLINE void QtessSurface:: set_match_u(QtessSurface **match_u, bool match_u_to_u) { _match_u = match_u; _match_u_to_u = match_u_to_u; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::set_match_v -// Access: Public -// Description: Indicates the surface to which this surface must -// match in its V direction. If v_to_v is true, it -// matches to the other surface's V direction; -// otherwise, it matches to the other surface's U -// direction. -// -// Note that the surface pointer is an indirect pointer. -// The value passed in is the address of the pointer to -// the actual surface (which may or may not be filled in -// yet). The actual pointer may be filled in later. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the surface to which this surface must match in its V direction. + * If v_to_v is true, it matches to the other surface's V direction; + * otherwise, it matches to the other surface's U direction. + * + * Note that the surface pointer is an indirect pointer. The value passed in + * is the address of the pointer to the actual surface (which may or may not + * be filled in yet). The actual pointer may be filled in later. + */ INLINE void QtessSurface:: set_match_v(QtessSurface **match_v, bool match_v_to_v) { _match_v = match_v; _match_v_to_v = match_v_to_v; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::set_min_u -// Access: Public -// Description: Specifies the absolute minimum number of segments -// allowed in the U direction. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the absolute minimum number of segments allowed in the U + * direction. + */ INLINE void QtessSurface:: set_min_u(int min_u) { _min_u = min_u; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::set_min_v -// Access: Public -// Description: Specifies the absolute minimum number of segments -// allowed in the V direction. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the absolute minimum number of segments allowed in the V + * direction. + */ INLINE void QtessSurface:: set_min_v(int min_v) { _min_v = min_v; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::count_patches -// Access: Public -// Description: Returns the number of patches the NURBS contains. -// Each patch is a square area bounded by isoparams. -// This actually scales by the importance of the -// surface, if it is not 1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of patches the NURBS contains. Each patch is a square + * area bounded by isoparams. This actually scales by the importance of the + * surface, if it is not 1. + */ INLINE double QtessSurface:: count_patches() const { return _num_u * _num_v * _importance2; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::count_tris -// Access: Public -// Description: Returns the number of triangles that will be -// generated by the current tesselation parameters. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of triangles that will be generated by the current + * tesselation parameters. + */ INLINE int QtessSurface:: count_tris() const { return _tess_u * _tess_v * 2; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::get_joint_membership_index -// Access: Public -// Description: Returns the extra dimension number within the surface -// where the vertex membership in the indicated joint -// should be stored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extra dimension number within the surface where the vertex + * membership in the indicated joint should be stored. + */ INLINE int QtessSurface:: get_joint_membership_index(EggGroup *joint) { JointTable::iterator jti = _joint_table.find(joint); @@ -152,12 +121,10 @@ get_joint_membership_index(EggGroup *joint) { return d; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::get_dxyz_index -// Access: Public -// Description: Returns the extra dimension number within the surface -// where the indicated Dxyz morph offset should be stored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extra dimension number within the surface where the indicated + * Dxyz morph offset should be stored. + */ INLINE int QtessSurface:: get_dxyz_index(const string &morph_name) { MorphTable::iterator mti = _dxyz_table.find(morph_name); @@ -170,12 +137,10 @@ get_dxyz_index(const string &morph_name) { return d; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::get_drgba_index -// Access: Public -// Description: Returns the extra dimension number within the surface -// where the indicated Drgba morph offset should be stored. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extra dimension number within the surface where the indicated + * Drgba morph offset should be stored. + */ INLINE int QtessSurface:: get_drgba_index(const string &morph_name) { MorphTable::iterator mti = _drgba_table.find(morph_name); diff --git a/pandatool/src/egg-qtess/qtessSurface.cxx b/pandatool/src/egg-qtess/qtessSurface.cxx index c3d77fe85d..c0bfc175f9 100644 --- a/pandatool/src/egg-qtess/qtessSurface.cxx +++ b/pandatool/src/egg-qtess/qtessSurface.cxx @@ -1,16 +1,15 @@ -// Filename: qtessSurface.cxx -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessSurface.cxx + * @author drose + * @date 2003-10-13 + */ #include "qtessSurface.h" #include "qtessGlobals.h" @@ -24,11 +23,9 @@ #include "pset.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ QtessSurface:: QtessSurface(EggNurbsSurface *egg_surface) : _egg_surface(egg_surface) @@ -45,9 +42,9 @@ QtessSurface(EggNurbsSurface *egg_surface) : _tess_u = _tess_v = 0; _got_scores = false; - // If the surface is closed in either dimension, the mininum - // tesselation in that dimension is by default 3, so we don't - // ribbonize the surface. Otherwise the minimum is 1. + // If the surface is closed in either dimension, the mininum tesselation in + // that dimension is by default 3, so we don't ribbonize the surface. + // Otherwise the minimum is 1. _min_u = _min_v = 1; if (egg_surface->is_closed_u()) { _min_u = 3; @@ -80,17 +77,13 @@ QtessSurface(EggNurbsSurface *egg_surface) : } } -//////////////////////////////////////////////////////////////////// -// Function: get_score -// Access: Public -// Description: Computes the curvature/stretch score for the surface, -// if it has not been already computed, and returns the -// net surface score. This is used both for -// automatically distributing isoparams among the -// surfaces by curvature, as well as for automatically -// placing the isoparams within each surface by -// curvature. -//////////////////////////////////////////////////////////////////// +/** + * Computes the curvature/stretch score for the surface, if it has not been + * already computed, and returns the net surface score. This is used both for + * automatically distributing isoparams among the surfaces by curvature, as + * well as for automatically placing the isoparams within each surface by + * curvature. + */ double QtessSurface:: get_score(double ratio) { if (_nurbs == (NurbsSurfaceEvaluator *)NULL) { @@ -98,10 +91,10 @@ get_score(double ratio) { } if (!_got_scores) { - _u_placer.get_scores(_nurbs->get_num_u_segments() * 100, + _u_placer.get_scores(_nurbs->get_num_u_segments() * 100, _nurbs->get_num_v_segments() * 2, ratio, _nurbs_result, true); - _v_placer.get_scores(_nurbs->get_num_v_segments() * 100, + _v_placer.get_scores(_nurbs->get_num_v_segments() * 100, _nurbs->get_num_u_segments() * 2, ratio, _nurbs_result, false); _got_scores = true; @@ -110,14 +103,11 @@ get_score(double ratio) { return _u_placer.get_total_score() * _v_placer.get_total_score() * _importance2; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::tesselate -// Access: Public -// Description: Applies the appropriate tesselation to the surface, -// and replaces its node in the tree with an EggGroup -// containing both the new vertex pool and all of the -// polygons. -//////////////////////////////////////////////////////////////////// +/** + * Applies the appropriate tesselation to the surface, and replaces its node + * in the tree with an EggGroup containing both the new vertex pool and all of + * the polygons. + */ int QtessSurface:: tesselate() { apply_match(); @@ -138,13 +128,10 @@ tesselate() { return tris; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::write_qtess_parameter -// Access: Public -// Description: Writes a line to the given output file telling qtess -// how this surface should be tesselated uniformly. -// Returns the number of tris. -//////////////////////////////////////////////////////////////////// +/** + * Writes a line to the given output file telling qtess how this surface + * should be tesselated uniformly. Returns the number of tris. + */ int QtessSurface:: write_qtess_parameter(ostream &out) { apply_match(); @@ -166,24 +153,19 @@ write_qtess_parameter(ostream &out) { } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::omit -// Access: Public -// Description: Sets up the surface to omit itself from the output. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the surface to omit itself from the output. + */ void QtessSurface:: omit() { _tess_u = 0; _tess_v = 0; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::tesselate_uv -// Access: Public -// Description: Sets the surface up to tesselate itself uniformly at -// u x v, or if autoplace is true, automatically with u -// x v quads. -//////////////////////////////////////////////////////////////////// +/** + * Sets the surface up to tesselate itself uniformly at u x v, or if autoplace + * is true, automatically with u x v quads. + */ void QtessSurface:: tesselate_uv(int u, int v, bool autoplace, double ratio) { _tess_u = u; @@ -195,12 +177,9 @@ tesselate_uv(int u, int v, bool autoplace, double ratio) { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::tesselate_specific -// Access: Public -// Description: Sets the surface up to tesselate itself at specific -// isoparams only. -//////////////////////////////////////////////////////////////////// +/** + * Sets the surface up to tesselate itself at specific isoparams only. + */ void QtessSurface:: tesselate_specific(const pvector &u_list, const pvector &v_list) { @@ -210,12 +189,9 @@ tesselate_specific(const pvector &u_list, _tess_v = (int)_iso_v.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::tesselate_per_isoparam -// Access: Public -// Description: Sets the surface up to tesselate itself to a uniform -// amount per isoparam. -//////////////////////////////////////////////////////////////////// +/** + * Sets the surface up to tesselate itself to a uniform amount per isoparam. + */ void QtessSurface:: tesselate_per_isoparam(double pi, bool autoplace, double ratio) { if (_num_u == 0 || _num_v == 0) { @@ -233,12 +209,10 @@ tesselate_per_isoparam(double pi, bool autoplace, double ratio) { } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::TesselatePerScore -// Access: Public -// Description: Sets the surface up to tesselate itself according to -// its computed curvature score in both dimensions. -//////////////////////////////////////////////////////////////////// +/** + * Sets the surface up to tesselate itself according to its computed curvature + * score in both dimensions. + */ void QtessSurface:: tesselate_per_score(double pi, bool autoplace, double ratio) { if (get_score(ratio) <= 0.0) { @@ -255,13 +229,10 @@ tesselate_per_score(double pi, bool autoplace, double ratio) { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::tesselate_auto -// Access: Public -// Description: Sets the surface up to tesselate itself by -// automatically determining the best place to put the -// indicated u x v isoparams. -//////////////////////////////////////////////////////////////////// +/** + * Sets the surface up to tesselate itself by automatically determining the + * best place to put the indicated u x v isoparams. + */ void QtessSurface:: tesselate_auto(int u, int v, double ratio) { if (get_score(ratio) <= 0.0) { @@ -275,14 +246,11 @@ tesselate_auto(int u, int v, double ratio) { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::record_vertex_extras -// Access: Private -// Description: Records the joint membership and morph offsets of -// each control vertex in the extra-dimensional space of -// the NURBS, so that we can extract this data out again -// later to apply to the polygon vertices. -//////////////////////////////////////////////////////////////////// +/** + * Records the joint membership and morph offsets of each control vertex in + * the extra-dimensional space of the NURBS, so that we can extract this data + * out again later to apply to the polygon vertices. + */ void QtessSurface:: record_vertex_extras() { int num_u_vertices = _egg_surface->get_num_u_cvs(); @@ -304,8 +272,8 @@ record_vertex_extras() { // The xyz morphs. EggMorphVertexList::const_iterator dxi; - for (dxi = egg_vertex->_dxyzs.begin(); - dxi != egg_vertex->_dxyzs.end(); + for (dxi = egg_vertex->_dxyzs.begin(); + dxi != egg_vertex->_dxyzs.end(); ++dxi) { const string &morph_name = (*dxi).get_name(); LVector3 delta = LCAST(PN_stdfloat, (*dxi).get_offset()); @@ -315,8 +283,8 @@ record_vertex_extras() { // The rgba morphs. EggMorphColorList::const_iterator dri; - for (dri = egg_vertex->_drgbas.begin(); - dri != egg_vertex->_drgbas.end(); + for (dri = egg_vertex->_drgbas.begin(); + dri != egg_vertex->_drgbas.end(); ++dri) { const string &morph_name = (*dri).get_name(); const LVector4 &delta = (*dri).get_offset(); @@ -327,13 +295,10 @@ record_vertex_extras() { } } -//////////////////////////////////////////////////////////////////// -// Function: QtessSurface::apply_match -// Access: Private -// Description: If the surface was set up to copy its tesselation in -// either axis from another surface, makes this copy -// now. -//////////////////////////////////////////////////////////////////// +/** + * If the surface was set up to copy its tesselation in either axis from + * another surface, makes this copy now. + */ void QtessSurface:: apply_match() { if (_match_u != NULL) { @@ -379,13 +344,10 @@ apply_match() { } } -//////////////////////////////////////////////////////////////////// -// Function: do_uniform_tesselate -// Access: Private -// Description: Subdivide the surface uniformly according to the -// parameters specified by an earlier call to omit(), -// teseselate_uv(), or tesselate_per_isoparam(). -//////////////////////////////////////////////////////////////////// +/** + * Subdivide the surface uniformly according to the parameters specified by an + * earlier call to omit(), teseselate_uv(), or tesselate_per_isoparam(). + */ PT(EggGroup) QtessSurface:: do_uniform_tesselate(int &tris) const { tris = 0; @@ -401,8 +363,8 @@ do_uniform_tesselate(int &tris) const { PT(EggGroup) group = new EggGroup(_egg_surface->get_name()); - // _tess_u and _tess_v are the number of patches to create. Convert - // that to the number of vertices. + // _tess_u and _tess_v are the number of patches to create. Convert that to + // the number of vertices. int num_u = _tess_u + 1; int num_v = _tess_v + 1; @@ -414,8 +376,7 @@ do_uniform_tesselate(int &tris) const { assert(_iso_u.empty() || (int)_iso_u.size() == num_u); assert(_iso_v.empty() || (int)_iso_v.size() == num_v); - // Now how many vertices is that total, and how many vertices per - // strip? + // Now how many vertices is that total, and how many vertices per strip? int num_verts = num_u * num_v; // Create a vertex pool. @@ -430,12 +391,12 @@ do_uniform_tesselate(int &tris) const { VertexList new_verts; new_verts.reserve(num_verts); - // Also collect the vertices into this set to group them by spatial - // position only. This is relevant for calculating normals. + // Also collect the vertices into this set to group them by spatial position + // only. This is relevant for calculating normals. typedef pset NVertexGroup; typedef pmap NVertexCollection; NVertexCollection n_collection; - + for (vi = 0; vi < num_v; vi++) { if (_iso_v.empty()) { v = (double)vi / (double)(num_v-1); @@ -463,14 +424,14 @@ do_uniform_tesselate(int &tris) const { PT(EggPolygon) poly = new EggPolygon; poly->add_vertex(new_verts[vi*num_u + (ui-1)]); poly->add_vertex(new_verts[(vi-1)*num_u + (ui-1)]); - poly->add_vertex(new_verts[(vi-1)*num_u + ui]); + poly->add_vertex(new_verts[(vi-1)*num_u + ui]); poly->add_vertex(new_verts[vi*num_u + ui]); poly->copy_attributes(*_egg_surface); - // We compute a polygon normal just so we can verify the - // calculated vertex normals. It's also helpful for identifying - // degenerate polygons. + // We compute a polygon normal just so we can verify the calculated + // vertex normals. It's also helpful for identifying degenerate + // polygons. if (poly->recompute_polygon_normal()) { tris += 2; group->add_child(poly); @@ -479,24 +440,24 @@ do_uniform_tesselate(int &tris) const { } // Now check all the vertex normals by comparing them to the polygon - // normals. Some might have not been computed at all; others might - // be facing in the wrong direction. + // normals. Some might have not been computed at all; others might be + // facing in the wrong direction. // Now go back through and normalize the computed normals. NVertexCollection::const_iterator nci; for (nci = n_collection.begin(); nci != n_collection.end(); ++nci) { const NVertexGroup &group = (*nci).second; - // Calculate the normal these vertices should have based on the - // polygons that share it. + // Calculate the normal these vertices should have based on the polygons + // that share it. LNormald normal = LNormald::zero(); int num_polys = 0; NVertexGroup::const_iterator ngi; for (ngi = group.begin(); ngi != group.end(); ++ngi) { EggVertex *egg_vertex = (*ngi); EggVertex::PrimitiveRef::const_iterator pri; - for (pri = egg_vertex->pref_begin(); - pri != egg_vertex->pref_end(); + for (pri = egg_vertex->pref_begin(); + pri != egg_vertex->pref_end(); ++pri) { EggPrimitive *egg_primitive = (*pri); nassertr(egg_primitive->has_normal(), NULL); @@ -519,8 +480,7 @@ do_uniform_tesselate(int &tris) const { egg_vertex->set_normal(-egg_vertex->get_normal()); } } else { - // This vertex doesn't have a normal; it gets the computed - // normal. + // This vertex doesn't have a normal; it gets the computed normal. egg_vertex->set_normal(normal); } } @@ -530,13 +490,10 @@ do_uniform_tesselate(int &tris) const { return group; } -//////////////////////////////////////////////////////////////////// -// Function: evaluate_vertex -// Access: Private -// Description: Evaluates the surface at the given u, v position and -// sets the vertex to the appropriate values. Also sets -// the joint membership of the vertex. -//////////////////////////////////////////////////////////////////// +/** + * Evaluates the surface at the given u, v position and sets the vertex to the + * appropriate values. Also sets the joint membership of the vertex. + */ PT(EggVertex) QtessSurface:: evaluate_vertex(double u, double v) const { PT(EggVertex) egg_vertex = new EggVertex; @@ -546,9 +503,9 @@ evaluate_vertex(double u, double v) const { _nurbs_result->eval_point(u, v, point); _nurbs_result->eval_normal(u, v, normal); - // If the normal is too short, don't consider it--it's probably - // inaccurate due to numerical limitations. We'll recompute it - // later based on the polygon normals. + // If the normal is too short, don't consider it--it's probably inaccurate + // due to numerical limitations. We'll recompute it later based on the + // polygon normals. PN_stdfloat length = normal.length(); if (length > 0.0001f) { normal /= length; @@ -600,6 +557,6 @@ evaluate_vertex(double u, double v) const { egg_vertex->_drgbas.insert(EggMorphColor(morph_name, delta)); } } - + return egg_vertex; } diff --git a/pandatool/src/egg-qtess/qtessSurface.h b/pandatool/src/egg-qtess/qtessSurface.h index 48dbaa8e91..f93c57c52e 100644 --- a/pandatool/src/egg-qtess/qtessSurface.h +++ b/pandatool/src/egg-qtess/qtessSurface.h @@ -1,16 +1,15 @@ -// Filename: qtessSurface.h -// Created by: drose (13Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file qtessSurface.h + * @author drose + * @date 2003-10-13 + */ #ifndef QTESSSURFACE_H #define QTESSSURFACE_H @@ -25,12 +24,11 @@ #include "referenceCount.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : QtessSurface -// Description : A reference to an EggNurbsSurface in the egg file, -// and its parameters as set by the user input file and -// as computed in relation to the other surfaces. -//////////////////////////////////////////////////////////////////// +/** + * A reference to an EggNurbsSurface in the egg file, and its parameters as + * set by the user input file and as computed in relation to the other + * surfaces. + */ class QtessSurface : public ReferenceCount { public: QtessSurface(EggNurbsSurface *egg_surface); @@ -48,7 +46,7 @@ public: INLINE int count_tris() const; double get_score(double ratio); - + int tesselate(); int write_qtess_parameter(ostream &out); void omit(); @@ -74,9 +72,8 @@ private: PT(NurbsSurfaceResult) _nurbs_result; bool _has_vertex_color; - // Mapping arbitrary attributes to integer extended dimension - // values, so we can hang arbitrary data in the extra dimensional - // space of the surface. + // Mapping arbitrary attributes to integer extended dimension values, so we + // can hang arbitrary data in the extra dimensional space of the surface. int _next_d; typedef map JointTable; JointTable _joint_table; @@ -88,24 +85,22 @@ private: int _tess_u, _tess_v; pvector _iso_u, _iso_v; // If nonempty, isoparams at which to tess. - // _importance is the relative importance of the surface along either - // axis; _importance2 is this number squared, which is the value set by + // _importance is the relative importance of the surface along either axis; + // _importance2 is this number squared, which is the value set by // set_importance(). double _importance; double _importance2; - // _match_u and _match_v indicate which surface we must match - // exactly for tesselation in U or V. This helps get edges to line - // up properly. They are indirect pointers because we go through - // the surfaces in one pass, and might need to fill in the correct - // value later. + // _match_u and _match_v indicate which surface we must match exactly for + // tesselation in U or V. This helps get edges to line up properly. They + // are indirect pointers because we go through the surfaces in one pass, and + // might need to fill in the correct value later. QtessSurface **_match_u, **_match_v; bool _match_u_to_u, _match_v_to_v; - // _min_u and _min_v specify a mininum number of quads below which - // we should not attempt to subdivide the surface in either - // dimension. This is intended to prevent degenerate cases like - // knife-fingers. + // _min_u and _min_v specify a mininum number of quads below which we should + // not attempt to subdivide the surface in either dimension. This is + // intended to prevent degenerate cases like knife-fingers. int _min_u, _min_v; IsoPlacer _u_placer, _v_placer; @@ -115,4 +110,3 @@ private: #include "qtessSurface.I" #endif - diff --git a/pandatool/src/egg-qtess/subdivSegment.I b/pandatool/src/egg-qtess/subdivSegment.I index 0dab0ebb20..2210032e3b 100644 --- a/pandatool/src/egg-qtess/subdivSegment.I +++ b/pandatool/src/egg-qtess/subdivSegment.I @@ -1,58 +1,47 @@ -// Filename: subdivSegment.I -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subdivSegment.I + * @author drose + * @date 2003-10-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SubdivSegment::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SubdivSegment:: -SubdivSegment(const double *cint, int f, int t) : - _cint(cint), +SubdivSegment(const double *cint, int f, int t) : + _cint(cint), _f(f), - _t(t) + _t(t) { } -//////////////////////////////////////////////////////////////////// -// Function: SubdivSegment::get_score -// Access: Public -// Description: Returns the net score of the segment. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net score of the segment. + */ INLINE double SubdivSegment:: get_score() const { return _cint[_t] - _cint[_f]; } -//////////////////////////////////////////////////////////////////// -// Function: SubdivSegment::get_need -// Access: Public -// Description: Returns a score that indicates how badly the segment -// needs to be further subdivided. The greater the -// number, the greater the need. -//////////////////////////////////////////////////////////////////// +/** + * Returns a score that indicates how badly the segment needs to be further + * subdivided. The greater the number, the greater the need. + */ INLINE double SubdivSegment:: get_need() const { return get_score() / (double)(_num_cuts+1); } -//////////////////////////////////////////////////////////////////// -// Function: SubdivSegment::operator < -// Access: Public -// Description: Sorts the segments in descending order of need. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the segments in descending order of need. + */ INLINE bool SubdivSegment:: operator < (const SubdivSegment &other) const { return get_need() > other.get_need(); diff --git a/pandatool/src/egg-qtess/subdivSegment.cxx b/pandatool/src/egg-qtess/subdivSegment.cxx index feae21214b..3c036e5644 100644 --- a/pandatool/src/egg-qtess/subdivSegment.cxx +++ b/pandatool/src/egg-qtess/subdivSegment.cxx @@ -1,27 +1,24 @@ -// Filename: subdivSegment.cxx -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subdivSegment.cxx + * @author drose + * @date 2003-10-14 + */ #include "subdivSegment.h" -//////////////////////////////////////////////////////////////////// -// Function: binary_search -// Description: Performs a standard binary search. This utility -// function is used below. -//////////////////////////////////////////////////////////////////// +/** + * Performs a standard binary search. This utility function is used below. + */ static int binary_search(double val, const double *array, int bot, int top) { if (top < bot) { @@ -37,11 +34,9 @@ binary_search(double val, const double *array, int bot, int top) { } -//////////////////////////////////////////////////////////////////// -// Function: SubdivSegment::cut -// Access: Public -// Description: Applies _num_cuts cuts to the segment. -//////////////////////////////////////////////////////////////////// +/** + * Applies _num_cuts cuts to the segment. + */ void SubdivSegment:: cut() { int c; @@ -82,4 +77,3 @@ cut() { } } } - diff --git a/pandatool/src/egg-qtess/subdivSegment.h b/pandatool/src/egg-qtess/subdivSegment.h index 6b31ac9c2b..abe6e58aca 100644 --- a/pandatool/src/egg-qtess/subdivSegment.h +++ b/pandatool/src/egg-qtess/subdivSegment.h @@ -1,16 +1,15 @@ -// Filename: subdivSegment.h -// Created by: drose (14Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file subdivSegment.h + * @author drose + * @date 2003-10-14 + */ #ifndef SUBDIVSEGMENT_H #define SUBDIVSEGMENT_H @@ -19,11 +18,10 @@ #include "pvector.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : SubdivSegment -// Description : Represents a single hypothetical subdivided segment, -// under consideration by the IsoPlacer. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single hypothetical subdivided segment, under consideration by + * the IsoPlacer. + */ class SubdivSegment { public: INLINE SubdivSegment(const double *cint, int f, int t); @@ -43,4 +41,3 @@ public: #include "subdivSegment.I" #endif - diff --git a/pandatool/src/eggbase/eggBase.cxx b/pandatool/src/eggbase/eggBase.cxx index 0c98141c27..7fa0889610 100644 --- a/pandatool/src/eggbase/eggBase.cxx +++ b/pandatool/src/eggbase/eggBase.cxx @@ -1,16 +1,15 @@ -// Filename: eggBase.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBase.cxx + * @author drose + * @date 2000-02-14 + */ #include "eggBase.h" @@ -21,11 +20,9 @@ #include "dcast.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: EggBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBase:: EggBase() { add_option @@ -51,14 +48,11 @@ EggBase() { _noabs = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::add_normals_options -// Access: Public -// Description: Adds -no, -np, etc. as valid options for this -// program. If the user specifies one of the options on -// the command line, the normals will be adjusted when -// the egg file is written out. -//////////////////////////////////////////////////////////////////// +/** + * Adds -no, -np, etc. as valid options for this program. If the user + * specifies one of the options on the command line, the normals will be + * adjusted when the egg file is written out. + */ void EggBase:: add_normals_options() { static NormalsMode strip = NM_strip; @@ -110,11 +104,9 @@ add_normals_options() { &EggBase::dispatch_none, &_got_tbnauto); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::add_points_options -// Access: Public -// Description: Adds -points as a valid option for this program. -//////////////////////////////////////////////////////////////////// +/** + * Adds -points as a valid option for this program. + */ void EggBase:: add_points_options() { add_option @@ -123,14 +115,11 @@ add_points_options() { &EggBase::dispatch_none, &_make_points); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::add_transform_options -// Access: Public -// Description: Adds -TS, -TT, etc. as valid options for this -// program. If the user specifies one of the options on -// the command line, the data will be transformed when -// the egg file is written out. -//////////////////////////////////////////////////////////////////// +/** + * Adds -TS, -TT, etc. as valid options for this program. If the user + * specifies one of the options on the command line, the data will be + * transformed when the egg file is written out. + */ void EggBase:: add_transform_options() { add_option @@ -159,13 +148,10 @@ add_transform_options() { &EggBase::dispatch_translate, &_got_transform, &_transform); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::convert_paths -// Access: Public, Static -// Description: Recursively walks the egg hierarchy. Any filenames -// encountered are replaced according to the indicated -// PathReplace. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg hierarchy. Any filenames encountered are + * replaced according to the indicated PathReplace. + */ void EggBase:: convert_paths(EggNode *node, PathReplace *path_replace, const DSearchPath &additional_path) { @@ -203,60 +189,46 @@ convert_paths(EggNode *node, PathReplace *path_replace, } } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::append_command_comment -// Access: Protected -// Description: Inserts a comment into the beginning of the indicated -// egg file corresponding to the command line that -// invoked this program. -// -// Normally this function is called automatically when -// appropriate by EggWriter, and it's not necessary to -// call it explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a comment into the beginning of the indicated egg file + * corresponding to the command line that invoked this program. + * + * Normally this function is called automatically when appropriate by + * EggWriter, and it's not necessary to call it explicitly. + */ void EggBase:: append_command_comment(EggData *data) { append_command_comment(data, get_exec_command()); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::append_command_comment -// Access: Protected, Static -// Description: Inserts a comment into the beginning of the indicated -// egg file corresponding to the command line that -// invoked this program. -// -// Normally this function is called automatically when -// appropriate by EggWriter, and it's not necessary to -// call it explicitly. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a comment into the beginning of the indicated egg file + * corresponding to the command line that invoked this program. + * + * Normally this function is called automatically when appropriate by + * EggWriter, and it's not necessary to call it explicitly. + */ void EggBase:: append_command_comment(EggData *data, const string &comment) { data->insert(data->begin(), new EggComment("", comment)); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::dispatch_normals -// Access: Protected, Static -// Description: Accepts one of -no, -np, etc. and sets _normals_mode -// as indicated. The void * argument is a pointer to a -// NormalsMode variable that indicates which switch was -// passed. -//////////////////////////////////////////////////////////////////// +/** + * Accepts one of -no, -np, etc. and sets _normals_mode as indicated. The + * void * argument is a pointer to a NormalsMode variable that indicates which + * switch was passed. + */ bool EggBase:: dispatch_normals(ProgramBase *self, const string &opt, const string &arg, void *mode) { EggBase *base = (EggBase *)self; return base->ns_dispatch_normals(opt, arg, mode); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::ns_dispatch_normals -// Access: Protected -// Description: Accepts one of -no, -np, etc. and sets _normals_mode -// as indicated. The void * argument is a pointer to a -// NormalsMode variable that indicates which switch was -// passed. -//////////////////////////////////////////////////////////////////// +/** + * Accepts one of -no, -np, etc. and sets _normals_mode as indicated. The + * void * argument is a pointer to a NormalsMode variable that indicates which + * switch was passed. + */ bool EggBase:: ns_dispatch_normals(const string &opt, const string &arg, void *mode) { _normals_mode = *(NormalsMode *)mode; @@ -272,12 +244,9 @@ ns_dispatch_normals(const string &opt, const string &arg, void *mode) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::dispatch_scale -// Access: Protected, Static -// Description: Handles -TS, which specifies a scale transform. Var -// is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TS, which specifies a scale transform. Var is an LMatrix4d. + */ bool EggBase:: dispatch_scale(const string &opt, const string &arg, void *var) { LMatrix4d *transform = (LMatrix4d *)var; @@ -311,24 +280,20 @@ dispatch_scale(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::dispatch_rotate_xyz -// Access: Protected, Static -// Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TR, which specifies a rotate transform about the three cardinal + * axes. Var is an LMatrix4d. + */ bool EggBase:: dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var) { EggBase *base = (EggBase *)self; return base->ns_dispatch_rotate_xyz(opt, arg, var); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::ns_dispatch_rotate_xyz -// Access: Protected -// Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TR, which specifies a rotate transform about the three cardinal + * axes. Var is an LMatrix4d. + */ bool EggBase:: ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { LMatrix4d *transform = (LMatrix4d *)var; @@ -362,24 +327,20 @@ ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::dispatch_rotate_axis -// Access: Protected, Static -// Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TA, which specifies a rotate transform about an arbitrary axis. + * Var is an LMatrix4d. + */ bool EggBase:: dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var) { EggBase *base = (EggBase *)self; return base->ns_dispatch_rotate_axis(opt, arg, var); } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::ns_dispatch_rotate_axis -// Access: Protected -// Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TA, which specifies a rotate transform about an arbitrary axis. + * Var is an LMatrix4d. + */ bool EggBase:: ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { LMatrix4d *transform = (LMatrix4d *)var; @@ -410,12 +371,9 @@ ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggBase::dispatch_translate -// Access: Protected, Static -// Description: Handles -TT, which specifies a translate transform. -// Var is an LMatrix4d. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TT, which specifies a translate transform. Var is an LMatrix4d. + */ bool EggBase:: dispatch_translate(const string &opt, const string &arg, void *var) { LMatrix4d *transform = (LMatrix4d *)var; diff --git a/pandatool/src/eggbase/eggBase.h b/pandatool/src/eggbase/eggBase.h index ad28803ddf..3b2bb1ed68 100644 --- a/pandatool/src/eggbase/eggBase.h +++ b/pandatool/src/eggbase/eggBase.h @@ -1,16 +1,15 @@ -// Filename: eggBase.h -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBase.h + * @author drose + * @date 2000-02-14 + */ #ifndef EGGBASE_H #define EGGBASE_H @@ -20,15 +19,13 @@ #include "programBase.h" #include "eggData.h" -//////////////////////////////////////////////////////////////////// -// Class : EggBase -// Description : This is a base class for both EggSingleBase and -// EggMultiBase. Don't inherit directly from this; use -// one of those two classes instead. -// -// This is just a base class; see EggReader, EggWriter, -// or EggFilter according to your particular I/O needs. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for both EggSingleBase and EggMultiBase. Don't + * inherit directly from this; use one of those two classes instead. + * + * This is just a base class; see EggReader, EggWriter, or EggFilter according + * to your particular I/O needs. + */ class EggBase : public ProgramBase { public: EggBase(); @@ -66,7 +63,7 @@ protected: vector_string _tbn_names; bool _got_tbnall; bool _got_tbnauto; - + bool _make_points; bool _got_transform; @@ -79,5 +76,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggConverter.cxx b/pandatool/src/eggbase/eggConverter.cxx index 0937cd8c67..a55d68856f 100644 --- a/pandatool/src/eggbase/eggConverter.cxx +++ b/pandatool/src/eggbase/eggConverter.cxx @@ -1,30 +1,25 @@ -// Filename: eggConverter.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggConverter.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggConverter.h" -//////////////////////////////////////////////////////////////////// -// Function: EggConverter::Constructor -// Access: Public -// Description: The first parameter to the constructor should be the -// one-word name of the alien file format that is to be -// read or written, for instance "OpenFlight" or -// "Alias". It's just used in printing error messages -// and such. The second parameter is the preferred -// extension of files of this form, if any, with a -// leading dot. -//////////////////////////////////////////////////////////////////// +/** + * The first parameter to the constructor should be the one-word name of the + * alien file format that is to be read or written, for instance "OpenFlight" + * or "Alias". It's just used in printing error messages and such. The + * second parameter is the preferred extension of files of this form, if any, + * with a leading dot. + */ EggConverter:: EggConverter(const string &format_name, const string &preferred_extension, @@ -33,7 +28,7 @@ EggConverter(const string &format_name, EggFilter(allow_last_param, allow_stdout), _format_name(format_name) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = preferred_extension; } diff --git a/pandatool/src/eggbase/eggConverter.h b/pandatool/src/eggbase/eggConverter.h index fbe190ba3d..1dfa1b00dc 100644 --- a/pandatool/src/eggbase/eggConverter.h +++ b/pandatool/src/eggbase/eggConverter.h @@ -1,16 +1,15 @@ -// Filename: eggConverter.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggConverter.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGCONVERTER_H #define EGGCONVERTER_H @@ -19,12 +18,10 @@ #include "eggFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggConverter -// Description : This is a general base class for programs that -// convert between egg files and some other format. See -// EggToSomething and SomethingToEgg. -//////////////////////////////////////////////////////////////////// +/** + * This is a general base class for programs that convert between egg files + * and some other format. See EggToSomething and SomethingToEgg. + */ class EggConverter : public EggFilter { public: EggConverter(const string &format_name, @@ -37,5 +34,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggFilter.cxx b/pandatool/src/eggbase/eggFilter.cxx index e588f96790..ef6c296702 100644 --- a/pandatool/src/eggbase/eggFilter.cxx +++ b/pandatool/src/eggbase/eggFilter.cxx @@ -1,30 +1,27 @@ -// Filename: eggFilter.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFilter.cxx + * @author drose + * @date 2000-02-14 + */ #include "eggFilter.h" -//////////////////////////////////////////////////////////////////// -// Function: EggFilter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggFilter:: EggFilter(bool allow_last_param, bool allow_stdout) : EggWriter(allow_last_param, allow_stdout) { - // The default path store for programs that read egg files and write - // them again is PS_relative. + // The default path store for programs that read egg files and write them + // again is PS_relative. _path_replace->_path_store = PS_relative; clear_runlines(); @@ -45,14 +42,11 @@ EggFilter(bool allow_last_param, bool allow_stdout) : } -//////////////////////////////////////////////////////////////////// -// Function: EggFilter::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggFilter:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { @@ -67,11 +61,9 @@ handle_args(ProgramBase::Args &args) { return EggReader::handle_args(args); } -//////////////////////////////////////////////////////////////////// -// Function: EggFilter::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggFilter:: post_command_line() { // writer first, so we can fiddle with the _path_replace options if diff --git a/pandatool/src/eggbase/eggFilter.h b/pandatool/src/eggbase/eggFilter.h index c3b01eab4a..ebd6c87db1 100644 --- a/pandatool/src/eggbase/eggFilter.h +++ b/pandatool/src/eggbase/eggFilter.h @@ -1,16 +1,15 @@ -// Filename: eggFilter.h -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFilter.h + * @author drose + * @date 2000-02-14 + */ #ifndef EGGFILTER_H #define EGGFILTER_H @@ -20,12 +19,10 @@ #include "eggReader.h" #include "eggWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggFilter -// Description : This is the base class for a program that reads an -// egg file, operates on it, and writes another egg file -// out. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that reads an egg file, operates on + * it, and writes another egg file out. + */ class EggFilter : public EggReader, public EggWriter { public: EggFilter(bool allow_last_param = false, bool allow_stdout = true); @@ -36,5 +33,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggMakeSomething.cxx b/pandatool/src/eggbase/eggMakeSomething.cxx index c40ee1c42d..52543ec08f 100644 --- a/pandatool/src/eggbase/eggMakeSomething.cxx +++ b/pandatool/src/eggbase/eggMakeSomething.cxx @@ -1,24 +1,21 @@ -// Filename: eggMakeSomething.cxx -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeSomething.cxx + * @author drose + * @date 2003-10-01 + */ #include "eggMakeSomething.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMakeSomething::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMakeSomething:: EggMakeSomething() : EggWriter(true, true) @@ -26,4 +23,3 @@ EggMakeSomething() : add_normals_options(); add_transform_options(); } - diff --git a/pandatool/src/eggbase/eggMakeSomething.h b/pandatool/src/eggbase/eggMakeSomething.h index a70293be67..b34aa348ef 100644 --- a/pandatool/src/eggbase/eggMakeSomething.h +++ b/pandatool/src/eggbase/eggMakeSomething.h @@ -1,16 +1,15 @@ -// Filename: eggMakeSomething.h -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeSomething.h + * @author drose + * @date 2003-10-01 + */ #ifndef EGGMAKESOMETHING_H #define EGGMAKESOMETHING_H @@ -19,15 +18,13 @@ #include "eggWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMakeSomething -// Description : A base class for a family of programs that generate -// egg models of various fundamental shapes. -//////////////////////////////////////////////////////////////////// +/** + * A base class for a family of programs that generate egg models of various + * fundamental shapes. + */ class EggMakeSomething : public EggWriter { public: EggMakeSomething(); }; #endif - diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx index 27513e6dfe..1e1d548793 100644 --- a/pandatool/src/eggbase/eggMultiBase.cxx +++ b/pandatool/src/eggbase/eggMultiBase.cxx @@ -1,16 +1,15 @@ -// Filename: eggMultiBase.cxx -// Created by: drose (02Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMultiBase.cxx + * @author drose + * @date 2000-11-02 + */ #include "eggMultiBase.h" #include "eggBase.h" @@ -19,11 +18,9 @@ #include "filename.h" #include "dSearchPath.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMultiBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMultiBase:: EggMultiBase() { add_option @@ -41,19 +38,15 @@ EggMultiBase() { &EggMultiBase::dispatch_none, &_noabs); } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiBase::post_process_egg_files -// Access: Public -// Description: Performs any processing of the egg file(s) that is -// appropriate before writing them out. This includes any -// normal adjustments the user requested via -np, etc. -// -// Normally, you should not need to call this function -// directly; write_egg_files() calls it for you. You -// should call this only if you do not use -// write_egg_files() to write out the resulting egg -// files. -//////////////////////////////////////////////////////////////////// +/** + * Performs any processing of the egg file(s) that is appropriate before + * writing them out. This includes any normal adjustments the user requested + * via -np, etc. + * + * Normally, you should not need to call this function directly; + * write_egg_files() calls it for you. You should call this only if you do + * not use write_egg_files() to write out the resulting egg files. + */ void EggMultiBase:: post_process_egg_files() { if (_eggs.empty()) { @@ -114,18 +107,14 @@ post_process_egg_files() { } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiBase::read_egg -// Access: Protected, Virtual -// Description: Allocates and returns a new EggData structure that -// represents the indicated egg file. If the egg file -// cannot be read for some reason, returns NULL. -// -// This can be overridden by derived classes to control -// how the egg files are read, or to extend the -// information stored with each egg structure, by -// deriving from EggData. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggData structure that represents the indicated + * egg file. If the egg file cannot be read for some reason, returns NULL. + * + * This can be overridden by derived classes to control how the egg files are + * read, or to extend the information stored with each egg structure, by + * deriving from EggData. + */ PT(EggData) EggMultiBase:: read_egg(const Filename &filename) { PT(EggData) data = new EggData; @@ -144,12 +133,10 @@ read_egg(const Filename &filename) { DSearchPath file_path; file_path.append_directory(filename.get_dirname()); - // We always resolve filenames first based on the source egg - // filename, since egg files almost always store relative paths. - // This is a temporary kludge around integrating the path_replace - // system with the EggData better. - // - // Update: I believe this kludge is obsolete. Commenting out. - Josh. + // We always resolve filenames first based on the source egg filename, since + // egg files almost always store relative paths. This is a temporary kludge + // around integrating the path_replace system with the EggData better. + // Update: I believe this kludge is obsolete. Commenting out. - Josh. // data->resolve_filenames(file_path); if (_force_complete) { @@ -158,8 +145,8 @@ read_egg(const Filename &filename) { } } - // Now resolve the filenames again according to the user's - // specified _path_replace. + // Now resolve the filenames again according to the user's specified + // _path_replace. EggBase::convert_paths(data, _path_replace, file_path); if (_got_coordinate_system) { diff --git a/pandatool/src/eggbase/eggMultiBase.h b/pandatool/src/eggbase/eggMultiBase.h index 948347aac0..1442de61f4 100644 --- a/pandatool/src/eggbase/eggMultiBase.h +++ b/pandatool/src/eggbase/eggMultiBase.h @@ -1,16 +1,15 @@ -// Filename: eggMultiBase.h -// Created by: drose (02Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMultiBase.h + * @author drose + * @date 2000-11-02 + */ #ifndef EGGMULTIBASE_H #define EGGMULTIBASE_H @@ -24,15 +23,13 @@ class Filename; -//////////////////////////////////////////////////////////////////// -// Class : EggMultiBase -// Description : This specialization of ProgramBase is intended for -// programs that read and/or write multiple egg files. -// -// See also EggMultiFilter, for a class that also knows -// how to read a bunch of egg files in and write them -// out again. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of ProgramBase is intended for programs that read + * and/or write multiple egg files. + * + * See also EggMultiFilter, for a class that also knows how to read a bunch of + * egg files in and write them out again. + */ class EggMultiBase : public EggBase { public: EggMultiBase(); @@ -50,5 +47,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggMultiFilter.cxx b/pandatool/src/eggbase/eggMultiFilter.cxx index 58306c3eb0..8b8fd61a15 100644 --- a/pandatool/src/eggbase/eggMultiFilter.cxx +++ b/pandatool/src/eggbase/eggMultiFilter.cxx @@ -1,27 +1,24 @@ -// Filename: eggMultiFilter.cxx -// Created by: drose (02Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMultiFilter.cxx + * @author drose + * @date 2000-11-02 + */ #include "eggMultiFilter.h" #include "pnotify.h" #include "eggData.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMultiFilter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMultiFilter:: EggMultiFilter(bool allow_empty) : _allow_empty(allow_empty) { clear_runlines(); @@ -61,22 +58,18 @@ EggMultiFilter(bool allow_empty) : _allow_empty(allow_empty) { "OS-imposed limits on the length of command lines.", &EggMultiFilter::dispatch_filename, &_got_input_filename, &_input_filename); - // Derived programs will set this true when they discover some - // command-line option that will prevent the program from generating - // output. This removes some checks for an output specification in - // handle_args. + // Derived programs will set this true when they discover some command-line + // option that will prevent the program from generating output. This + // removes some checks for an output specification in handle_args. _read_only = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiFilter::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggMultiFilter:: handle_args(ProgramBase::Args &args) { if (_got_input_filename) { @@ -143,9 +136,9 @@ handle_args(ProgramBase::Args &args) { for (ai = args.begin(); ai != args.end(); ++ai) { PT(EggData) data = read_egg(Filename::from_os_specific(*ai)); if (data == (EggData *)NULL) { - // Rather than returning false, we simply exit here, so the - // ProgramBase won't try to tell the user how to run the program - // just because we got a bad egg file. + // Rather than returning false, we simply exit here, so the ProgramBase + // won't try to tell the user how to run the program just because we got + // a bad egg file. exit(1); } @@ -155,11 +148,9 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiFilter::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggMultiFilter:: post_command_line() { Eggs::iterator ei; @@ -174,13 +165,10 @@ post_command_line() { return EggMultiBase::post_command_line(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiFilter::get_output_filename -// Access: Protected -// Description: Returns the output filename of the egg file with the -// given input filename. This is based on the user's -// choice of -inplace, -o, or -d. -//////////////////////////////////////////////////////////////////// +/** + * Returns the output filename of the egg file with the given input filename. + * This is based on the user's choice of -inplace, -o, or -d. + */ Filename EggMultiFilter:: get_output_filename(const Filename &source_filename) const { if (_got_output_filename) { @@ -198,13 +186,11 @@ get_output_filename(const Filename &source_filename) const { return source_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggMultiFilter::write_eggs -// Access: Protected, Virtual -// Description: Writes out all of the egg files in the _eggs vector, -// to the output directory if one is specified, or over -// the input files if -inplace was specified. -//////////////////////////////////////////////////////////////////// +/** + * Writes out all of the egg files in the _eggs vector, to the output + * directory if one is specified, or over the input files if -inplace was + * specified. + */ void EggMultiFilter:: write_eggs() { nassertv(!_read_only); diff --git a/pandatool/src/eggbase/eggMultiFilter.h b/pandatool/src/eggbase/eggMultiFilter.h index b872d70649..402e5183b6 100644 --- a/pandatool/src/eggbase/eggMultiFilter.h +++ b/pandatool/src/eggbase/eggMultiFilter.h @@ -1,16 +1,15 @@ -// Filename: eggMultiFilter.h -// Created by: drose (02Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMultiFilter.h + * @author drose + * @date 2000-11-02 + */ #ifndef EGGMULTIFILTER_H #define EGGMULTIFILTER_H @@ -19,12 +18,11 @@ #include "eggMultiBase.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMultiFilter -// Description : This is a base class for a program that reads in a -// number of egg files, operates on them, and writes -// them out again (presumably to a different directory). -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for a program that reads in a number of egg files, + * operates on them, and writes them out again (presumably to a different + * directory). + */ class EggMultiFilter : public EggMultiBase { public: EggMultiFilter(bool allow_empty = false); @@ -51,5 +49,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index 39f3c936cf..2c2d2a0a0e 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -1,16 +1,15 @@ -// Filename: eggReader.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggReader.cxx + * @author drose + * @date 2000-02-14 + */ #include "eggReader.h" @@ -23,11 +22,9 @@ #include "string_utils.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: EggReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggReader:: EggReader() { clear_runlines(); @@ -60,19 +57,15 @@ EggReader() { _got_tex_extension = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggRead::add_texture_options -// Access: Public -// Description: Adds -td, -te, etc. as valid options for this -// program. If the user specifies one of the options on -// the command line, the textures will be copied and -// converted as each egg file is read. -// -// Note that if you call this function to add these -// options, you must call do_reader_options() at the -// appropriate point before or during processing to -// execute the options if the user specified them. -//////////////////////////////////////////////////////////////////// +/** + * Adds -td, -te, etc. as valid options for this program. If the user + * specifies one of the options on the command line, the textures will be + * copied and converted as each egg file is read. + * + * Note that if you call this function to add these options, you must call + * do_reader_options() at the appropriate point before or during processing to + * execute the options if the user specified them. + */ void EggReader:: add_texture_options() { add_option @@ -100,16 +93,13 @@ add_texture_options() { &EggReader::dispatch_image_type, NULL, &_tex_type); } -//////////////////////////////////////////////////////////////////// -// Function: EggRead::add_delod_options -// Access: Public -// Description: Adds -delod as a valid option for this program. -// -// Note that if you call this function to add these -// options, you must call do_reader_options() at the -// appropriate point before or during processing to -// execute the options if the user specified them. -//////////////////////////////////////////////////////////////////// +/** + * Adds -delod as a valid option for this program. + * + * Note that if you call this function to add these options, you must call + * do_reader_options() at the appropriate point before or during processing to + * execute the options if the user specified them. + */ void EggReader:: add_delod_options(double default_delod) { _delod = default_delod; @@ -134,41 +124,34 @@ add_delod_options(double default_delod) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::as_reader -// Access: Public, Virtual -// Description: Returns this object as an EggReader pointer, if it is -// in fact an EggReader, or NULL if it is not. -// -// This is intended to work around the C++ limitation -// that prevents downcasts past virtual inheritance. -// Since both EggReader and EggWriter inherit virtually -// from EggSingleBase, we need functions like this to downcast -// to the appropriate pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object as an EggReader pointer, if it is in fact an EggReader, + * or NULL if it is not. + * + * This is intended to work around the C++ limitation that prevents downcasts + * past virtual inheritance. Since both EggReader and EggWriter inherit + * virtually from EggSingleBase, we need functions like this to downcast to + * the appropriate pointer. + */ EggReader *EggReader:: as_reader() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::pre_process_egg_file -// Access: Public, Virtual -// Description: Performs any processing of the egg file that is -// appropriate after reading it in. -// -// Normally, you should not need to call this function -// directly; it is called automatically at startup. -//////////////////////////////////////////////////////////////////// +/** + * Performs any processing of the egg file that is appropriate after reading + * it in. + * + * Normally, you should not need to call this function directly; it is called + * automatically at startup. + */ void EggReader:: pre_process_egg_file() { } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggReader:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -176,8 +159,8 @@ handle_args(ProgramBase::Args &args) { return false; } - // Any separate egg files that are listed on the command line will - // get implicitly loaded up into one big egg file. + // Any separate egg files that are listed on the command line will get + // implicitly loaded up into one big egg file. if (!args.empty()) { _data->set_egg_filename(Filename::from_os_specific(args[0])); @@ -188,9 +171,9 @@ handle_args(ProgramBase::Args &args) { EggData file_data; if (!file_data.read(filename)) { - // Rather than returning false, we simply exit here, so the - // ProgramBase won't try to tell the user how to run the program - // just because we got a bad egg file. + // Rather than returning false, we simply exit here, so the ProgramBase + // won't try to tell the user how to run the program just because we got + // a bad egg file. exit(1); } @@ -202,15 +185,15 @@ handle_args(ProgramBase::Args &args) { DSearchPath file_path; file_path.append_directory(filename.get_dirname()); - + if (_force_complete) { if (!file_data.load_externals()) { exit(1); } } - // Now resolve the filenames again according to the user's - // specified _path_replace. + // Now resolve the filenames again according to the user's specified + // _path_replace. convert_paths(&file_data, _path_replace, file_path); _data->merge(file_data); @@ -221,29 +204,22 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::post_command_line -// Access: Protected, Virtual -// Description: This is called after the command line has been -// completely processed, and it gives the program a -// chance to do some last-minute processing and -// validation of the options and arguments. It should -// return true if everything is fine, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * This is called after the command line has been completely processed, and it + * gives the program a chance to do some last-minute processing and validation + * of the options and arguments. It should return true if everything is fine, + * false if there is an error. + */ bool EggReader:: post_command_line() { return EggSingleBase::post_command_line(); } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::do_reader_options -// Access: Protected -// Description: Postprocesses the egg file as the user requested -// according to whatever command-line options are in -// effect. Returns true if everything is done -// correctly, false if there was some problem. -//////////////////////////////////////////////////////////////////// +/** + * Postprocesses the egg file as the user requested according to whatever + * command-line options are in effect. Returns true if everything is done + * correctly, false if there was some problem. + */ bool EggReader:: do_reader_options() { bool okflag = true; @@ -261,14 +237,11 @@ do_reader_options() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::copy_textures -// Access: Private -// Description: Renames and copies the textures referenced in the egg -// file, if so specified by the -td and -te options. -// Returns true if all textures are copied successfully, -// false if any one of them failed. -//////////////////////////////////////////////////////////////////// +/** + * Renames and copies the textures referenced in the egg file, if so specified + * by the -td and -te options. Returns true if all textures are copied + * successfully, false if any one of them failed. + */ bool EggReader:: copy_textures() { bool success = true; @@ -300,7 +273,7 @@ copy_textures() { tex->set_filename(new_filename); // The new filename is different; does it need copying? - int compare = + int compare = orig_filename.compare_timestamps(new_filename, true, true); if (compare > 0) { // Yes, it does. Copy it! @@ -323,14 +296,11 @@ copy_textures() { return success; } -//////////////////////////////////////////////////////////////////// -// Function: EggReader::do_delod -// Access: Private -// Description: Removes all the LOD's in the egg file by treating the -// camera as being _delod distance from each LOD. -// Returns true if this particular group should be -// preserved, false if it should be removed. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the LOD's in the egg file by treating the camera as being + * _delod distance from each LOD. Returns true if this particular group should + * be preserved, false if it should be removed. + */ bool EggReader:: do_delod(EggNode *node) { if (node->is_of_type(EggGroup::get_class_type())) { @@ -338,12 +308,11 @@ do_delod(EggNode *node) { if (group->has_lod()) { const EggSwitchCondition &cond = group->get_lod(); if (cond.is_of_type(EggSwitchConditionDistance::get_class_type())) { - const EggSwitchConditionDistance *dist = + const EggSwitchConditionDistance *dist = DCAST(EggSwitchConditionDistance, &cond); if (_delod >= dist->_switch_out && _delod < dist->_switch_in) { - // Preserve this group node, but not the LOD information - // itself. - nout << "Preserving LOD " << node->get_name() + // Preserve this group node, but not the LOD information itself. + nout << "Preserving LOD " << node->get_name() << " (" << dist->_switch_out << " to " << dist->_switch_in << ")\n"; group->clear_lod(); diff --git a/pandatool/src/eggbase/eggReader.h b/pandatool/src/eggbase/eggReader.h index 5a7f724576..c195b0c07d 100644 --- a/pandatool/src/eggbase/eggReader.h +++ b/pandatool/src/eggbase/eggReader.h @@ -1,16 +1,15 @@ -// Filename: eggReader.h -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggReader.h + * @author drose + * @date 2000-02-14 + */ #ifndef EGGREADER_H #define EGGREADER_H @@ -22,18 +21,17 @@ class PNMFileType; -//////////////////////////////////////////////////////////////////// -// Class : EggReader -// Description : This is the base class for a program that reads egg -// files, but doesn't write an egg file. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that reads egg files, but doesn't + * write an egg file. + */ class EggReader : virtual public EggSingleBase { public: EggReader(); void add_texture_options(); void add_delod_options(double default_delod = -1.0); - + virtual EggReader *as_reader(); virtual void pre_process_egg_file(); @@ -60,5 +58,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggbase/eggSingleBase.cxx b/pandatool/src/eggbase/eggSingleBase.cxx index 19dc952029..b7fc71c45b 100644 --- a/pandatool/src/eggbase/eggSingleBase.cxx +++ b/pandatool/src/eggbase/eggSingleBase.cxx @@ -1,16 +1,15 @@ -// Filename: eggSingleBase.cxx -// Created by: drose (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSingleBase.cxx + * @author drose + * @date 2003-07-21 + */ #include "eggSingleBase.h" @@ -21,56 +20,46 @@ #include "dcast.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: EggSingleBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggSingleBase:: EggSingleBase() : _data(new EggData) { } -//////////////////////////////////////////////////////////////////// -// Function: EggSingleBase::as_reader -// Access: Public, Virtual -// Description: Returns this object as an EggReader pointer, if it is -// in fact an EggReader, or NULL if it is not. -// -// This is intended to work around the C++ limitation -// that prevents downcasts past virtual inheritance. -// Since both EggReader and EggWriter inherit virtually -// from EggSingleBase, we need functions like this to downcast -// to the appropriate pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object as an EggReader pointer, if it is in fact an EggReader, + * or NULL if it is not. + * + * This is intended to work around the C++ limitation that prevents downcasts + * past virtual inheritance. Since both EggReader and EggWriter inherit + * virtually from EggSingleBase, we need functions like this to downcast to + * the appropriate pointer. + */ EggReader *EggSingleBase:: as_reader() { return (EggReader *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggSingleBase::as_writer -// Access: Public, Virtual -// Description: Returns this object as an EggWriter pointer, if it is -// in fact an EggWriter, or NULL if it is not. -// -// This is intended to work around the C++ limitation -// that prevents downcasts past virtual inheritance. -// Since both EggReader and EggWriter inherit virtually -// from EggSingleBase, we need functions like this to downcast -// to the appropriate pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object as an EggWriter pointer, if it is in fact an EggWriter, + * or NULL if it is not. + * + * This is intended to work around the C++ limitation that prevents downcasts + * past virtual inheritance. Since both EggReader and EggWriter inherit + * virtually from EggSingleBase, we need functions like this to downcast to + * the appropriate pointer. + */ EggWriter *EggSingleBase:: as_writer() { return (EggWriter *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggSingleBase::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggSingleBase:: post_command_line() { if (_got_coordinate_system) { @@ -79,4 +68,3 @@ post_command_line() { return EggBase::post_command_line(); } - diff --git a/pandatool/src/eggbase/eggSingleBase.h b/pandatool/src/eggbase/eggSingleBase.h index 0cca35d534..32c15d83f1 100644 --- a/pandatool/src/eggbase/eggSingleBase.h +++ b/pandatool/src/eggbase/eggSingleBase.h @@ -1,16 +1,15 @@ -// Filename: eggSingleBase.h -// Created by: drose (21Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSingleBase.h + * @author drose + * @date 2003-07-21 + */ #ifndef EGGSINGLEBASE_H #define EGGSINGLEBASE_H @@ -27,16 +26,14 @@ class EggWriter; class EggNode; class PathReplace; -//////////////////////////////////////////////////////////////////// -// Class : EggSingleBase -// Description : This specialization of EggBase is intended for -// programs that read and/or write a single egg file. -// (See EggMultiBase for programs that operate on -// multiple egg files at once.) -// -// This is just a base class; see EggReader, EggWriter, -// or EggFilter according to your particular I/O needs. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of EggBase is intended for programs that read and/or + * write a single egg file. (See EggMultiBase for programs that operate on + * multiple egg files at once.) + * + * This is just a base class; see EggReader, EggWriter, or EggFilter according + * to your particular I/O needs. + */ class EggSingleBase : public EggBase { public: EggSingleBase(); @@ -52,5 +49,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggToSomething.cxx b/pandatool/src/eggbase/eggToSomething.cxx index e9003af537..942a0d82db 100644 --- a/pandatool/src/eggbase/eggToSomething.cxx +++ b/pandatool/src/eggbase/eggToSomething.cxx @@ -1,27 +1,23 @@ -// Filename: eggToSomething.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToSomething.cxx + * @author drose + * @date 2000-02-15 + */ #include "eggToSomething.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToSomething::Constructor -// Access: Public -// Description: The first parameter to the constructor should be the -// one-word name of the file format that is to be read, -// for instance "OpenFlight" or "Alias". It's just used -// in printing error messages and such. -//////////////////////////////////////////////////////////////////// +/** + * The first parameter to the constructor should be the one-word name of the + * file format that is to be read, for instance "OpenFlight" or "Alias". It's + * just used in printing error messages and such. + */ EggToSomething:: EggToSomething(const string &format_name, const string &preferred_extension, @@ -83,15 +79,12 @@ EggToSomething(const string &format_name, _output_units = DU_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomething::add_units_options -// Access: Public -// Description: Adds -ui and -uo as valid options for this program. -// If the user specifies -uo and -ui, or just -uo and -// the program specifies -ui by setting _input_units, -// the indicated units conversion will be automatically -// applied before writing out the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Adds -ui and -uo as valid options for this program. If the user specifies + * -uo and -ui, or just -uo and the program specifies -ui by setting + * _input_units, the indicated units conversion will be automatically applied + * before writing out the egg file. + */ void EggToSomething:: add_units_options() { add_option @@ -109,21 +102,17 @@ add_units_options() { &EggToSomething::dispatch_units, NULL, &_output_units); } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomething::apply_units_scale -// Access: Protected -// Description: Applies the scale indicated by the input and output -// units to the indicated egg file. This is normally -// done automatically when the file is read in. -//////////////////////////////////////////////////////////////////// +/** + * Applies the scale indicated by the input and output units to the indicated + * egg file. This is normally done automatically when the file is read in. + */ void EggToSomething:: apply_units_scale(EggData *data) { - // [gjeon] since maya's internal unit is fixed to cm - // and when we can't change UI unit without affecting data - // we need to convert data to cm for now - // this will be set later to proper output unit user provided - // by using MayaApi::set_units() in eggToMaya.cxx + // [gjeon] since maya's internal unit is fixed to cm and when we can't + // change UI unit without affecting data we need to convert data to cm for + // now this will be set later to proper output unit user provided by using + // MayaApi::set_units() in eggToMaya.cxx DistanceUnit output_units = _output_units; if (_format_name == "Maya") _output_units = DU_centimeters; @@ -138,29 +127,24 @@ apply_units_scale(EggData *data) { _output_units = output_units; } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomething::pre_process_egg_file -// Access: Protected, Virtual -// Description: Performs any processing of the egg file that is -// appropriate after reading it in. -// -// Normally, you should not need to call this function -// directly; it is called automatically at startup. -//////////////////////////////////////////////////////////////////// +/** + * Performs any processing of the egg file that is appropriate after reading + * it in. + * + * Normally, you should not need to call this function directly; it is called + * automatically at startup. + */ void EggToSomething:: pre_process_egg_file() { apply_units_scale(_data); EggConverter::pre_process_egg_file(); } -//////////////////////////////////////////////////////////////////// -// Function: EggToSomething::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggToSomething:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { diff --git a/pandatool/src/eggbase/eggToSomething.h b/pandatool/src/eggbase/eggToSomething.h index e6a518de79..56885c33aa 100644 --- a/pandatool/src/eggbase/eggToSomething.h +++ b/pandatool/src/eggbase/eggToSomething.h @@ -1,16 +1,15 @@ -// Filename: eggToSomething.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToSomething.h + * @author drose + * @date 2000-02-15 + */ #ifndef EGGTOSOMETHING_H #define EGGTOSOMETHING_H @@ -20,12 +19,10 @@ #include "eggConverter.h" #include "distanceUnit.h" -//////////////////////////////////////////////////////////////////// -// Class : EggToSomething -// Description : This is the general base class for a file-converter -// program that reads some model file format and -// generates an egg file. -//////////////////////////////////////////////////////////////////// +/** + * This is the general base class for a file-converter program that reads some + * model file format and generates an egg file. + */ class EggToSomething : public EggConverter { public: EggToSomething(const string &format_name, @@ -45,5 +42,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggbase/eggWriter.cxx b/pandatool/src/eggbase/eggWriter.cxx index 1e95e94056..28365de2c1 100644 --- a/pandatool/src/eggbase/eggWriter.cxx +++ b/pandatool/src/eggbase/eggWriter.cxx @@ -1,16 +1,15 @@ -// Filename: eggWriter.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggWriter.cxx + * @author drose + * @date 2000-02-14 + */ #include "eggWriter.h" @@ -18,31 +17,25 @@ #include "compose_matrix.h" #include "globPattern.h" -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::Constructor -// Access: Public -// Description: Egg-writing type programs may specify their output -// file using either the last-filename convention, the -// -o convention, and/or implicitly writing the result -// to standard output. Not all interfaces are -// appropriate for all applications; some may be -// confusing or dangerous. -// -// The calling application should pass allow_last_param -// true to allow the user to specify the output filename -// as the last parameter on the command line (the most -// dangerous, but convenient, method), and allow_stdout -// true to allow the user to omit the output filename -// altogether and have the output implicitly go to -// standard output (not terribly dangerous, but -// inappropriate when writing binary file formats). -//////////////////////////////////////////////////////////////////// +/** + * Egg-writing type programs may specify their output file using either the + * last-filename convention, the -o convention, and/or implicitly writing the + * result to standard output. Not all interfaces are appropriate for all + * applications; some may be confusing or dangerous. + * + * The calling application should pass allow_last_param true to allow the user + * to specify the output filename as the last parameter on the command line + * (the most dangerous, but convenient, method), and allow_stdout true to + * allow the user to omit the output filename altogether and have the output + * implicitly go to standard output (not terribly dangerous, but inappropriate + * when writing binary file formats). + */ EggWriter:: EggWriter(bool allow_last_param, bool allow_stdout) : WithOutputFile(allow_last_param, allow_stdout, false) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = ".egg"; clear_runlines(); @@ -92,35 +85,29 @@ EggWriter(bool allow_last_param, bool allow_stdout) : } -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::as_writer -// Access: Public, Virtual -// Description: Returns this object as an EggWriter pointer, if it is -// in fact an EggWriter, or NULL if it is not. -// -// This is intended to work around the C++ limitation -// that prevents downcasts past virtual inheritance. -// Since both EggReader and EggWriter inherit virtually -// from EggSingleBase, we need functions like this to downcast -// to the appropriate pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns this object as an EggWriter pointer, if it is in fact an EggWriter, + * or NULL if it is not. + * + * This is intended to work around the C++ limitation that prevents downcasts + * past virtual inheritance. Since both EggReader and EggWriter inherit + * virtually from EggSingleBase, we need functions like this to downcast to + * the appropriate pointer. + */ EggWriter *EggWriter:: as_writer() { return this; } -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::post_process_egg_file -// Access: Public, Virtual -// Description: Performs any processing of the egg file that is -// appropriate before writing it out. This includes any -// normal adjustments the user requested via -np, etc. -// -// Normally, you should not need to call this function -// directly; write_egg_file() calls it for you. You -// should call this only if you do not use -// write_egg_file() to write out the resulting egg file. -//////////////////////////////////////////////////////////////////// +/** + * Performs any processing of the egg file that is appropriate before writing + * it out. This includes any normal adjustments the user requested via -np, + * etc. + * + * Normally, you should not need to call this function directly; + * write_egg_file() calls it for you. You should call this only if you do not + * use write_egg_file() to write out the resulting egg file. + */ void EggWriter:: post_process_egg_file() { if (_got_transform) { @@ -180,29 +167,23 @@ post_process_egg_file() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::write_egg_file -// Access: Public -// Description: Writes out the egg file as the normal result of the -// program. This calls post_process_egg_file() to -// perform any last minute processing (like normal -// computation) and then writes out the file to the -// output stream returned by get_output(). -//////////////////////////////////////////////////////////////////// +/** + * Writes out the egg file as the normal result of the program. This calls + * post_process_egg_file() to perform any last minute processing (like normal + * computation) and then writes out the file to the output stream returned by + * get_output(). + */ void EggWriter:: write_egg_file() { post_process_egg_file(); _data->write_egg(get_output()); } -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggWriter:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 0)) { @@ -227,11 +208,9 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggWriter::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggWriter:: post_command_line() { if (!_allow_stdout && !_got_output_filename) { diff --git a/pandatool/src/eggbase/eggWriter.h b/pandatool/src/eggbase/eggWriter.h index 22e90e84bd..7d08eab3a0 100644 --- a/pandatool/src/eggbase/eggWriter.h +++ b/pandatool/src/eggbase/eggWriter.h @@ -1,16 +1,15 @@ -// Filename: eggWriter.h -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggWriter.h + * @author drose + * @date 2000-02-14 + */ #ifndef EGGWRITER_H #define EGGWRITER_H @@ -22,11 +21,10 @@ #include "filename.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggWriter -// Description : This is the base class for a program that generates -// an egg file output, but doesn't read any for input. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that generates an egg file output, but + * doesn't read any for input. + */ class EggWriter : virtual public EggSingleBase, public WithOutputFile { public: EggWriter(bool allow_last_param = false, bool allow_stdout = true); @@ -46,5 +44,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 152427f2ff..497761ea06 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -1,30 +1,26 @@ -// Filename: somethingToEgg.cxx -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file somethingToEgg.cxx + * @author drose + * @date 2000-02-15 + */ #include "somethingToEgg.h" #include "somethingToEggConverter.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::Constructor -// Access: Public -// Description: The first parameter to the constructor should be the -// one-word name of the file format that is to be read, -// for instance "OpenFlight" or "Alias". It's just used -// in printing error messages and such. -//////////////////////////////////////////////////////////////////// +/** + * The first parameter to the constructor should be the one-word name of the + * file format that is to be read, for instance "OpenFlight" or "Alias". It's + * just used in printing error messages and such. + */ SomethingToEgg:: SomethingToEgg(const string &format_name, const string &preferred_extension, @@ -81,15 +77,12 @@ SomethingToEgg(const string &format_name, _merge_externals = false; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::add_units_options -// Access: Public -// Description: Adds -ui and -uo as valid options for this program. -// If the user specifies -uo and -ui, or just -uo and -// the program specifies -ui by setting _input_units, -// the indicated units conversion will be automatically -// applied before writing out the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Adds -ui and -uo as valid options for this program. If the user specifies + * -uo and -ui, or just -uo and the program specifies -ui by setting + * _input_units, the indicated units conversion will be automatically applied + * before writing out the egg file. + */ void SomethingToEgg:: add_units_options() { add_option @@ -107,11 +100,9 @@ add_units_options() { &SomethingToEgg::dispatch_units, NULL, &_output_units); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::add_animation_options -// Access: Public -// Description: Adds options appropriate to animation packages. -//////////////////////////////////////////////////////////////////// +/** + * Adds options appropriate to animation packages. + */ void SomethingToEgg:: add_animation_options() { add_option @@ -171,11 +162,9 @@ add_animation_options() { &SomethingToEgg::dispatch_double, &_got_output_frame_rate, &_output_frame_rate); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::add_merge_externals_options -// Access: Public -// Description: Adds -f. -//////////////////////////////////////////////////////////////////// +/** + * Adds -f. + */ void SomethingToEgg:: add_merge_externals_options() { add_option @@ -184,13 +173,11 @@ add_merge_externals_options() { &SomethingToEgg::dispatch_none, &_merge_externals); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::apply_units_scale -// Access: Protected -// Description: Applies the scale indicated by the input and output -// units to the indicated egg file. This is normally -// done automatically when the file is written out. -//////////////////////////////////////////////////////////////////// +/** + * Applies the scale indicated by the input and output units to the indicated + * egg file. This is normally done automatically when the file is written + * out. + */ void SomethingToEgg:: apply_units_scale(EggData *data) { if (_output_units != DU_invalid && _input_units != DU_invalid && @@ -202,14 +189,11 @@ apply_units_scale(EggData *data) { } } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::apply_parameters -// Access: Protected -// Description: Copies the relevant parameters specified by the user -// on the command line (if add_path_replace_options(), -// add_path_store_options(), or add_animation_options() -// was used) to the converter. -//////////////////////////////////////////////////////////////////// +/** + * Copies the relevant parameters specified by the user on the command line + * (if add_path_replace_options(), add_path_store_options(), or + * add_animation_options() was used) to the converter. + */ void SomethingToEgg:: apply_parameters(SomethingToEggConverter &converter) { _path_replace->_noabs = _noabs; @@ -238,11 +222,9 @@ apply_parameters(SomethingToEggConverter &converter) { } } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::handle_args -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool SomethingToEgg:: handle_args(Args &args) { if (_allow_last_param && !_got_output_filename && args.size() > 1) { @@ -295,16 +277,12 @@ handle_args(Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::post_command_line -// Access: Protected, Virtual -// Description: This is called after the command line has been -// completely processed, and it gives the program a -// chance to do some last-minute processing and -// validation of the options and arguments. It should -// return true if everything is fine, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * This is called after the command line has been completely processed, and it + * gives the program a chance to do some last-minute processing and validation + * of the options and arguments. It should return true if everything is fine, + * false if there is an error. + */ bool SomethingToEgg:: post_command_line() { // Prepend the source filename to the model path. @@ -318,31 +296,25 @@ post_command_line() { return EggConverter::post_command_line(); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::post_process_egg_file -// Access: Protected, Virtual -// Description: Performs any processing of the egg file that is -// appropriate before writing it out. This includes any -// normal adjustments the user requested via -np, etc. -// -// Normally, you should not need to call this function -// directly; write_egg_file() calls it for you. You -// should call this only if you do not use -// write_egg_file() to write out the resulting egg file. -//////////////////////////////////////////////////////////////////// +/** + * Performs any processing of the egg file that is appropriate before writing + * it out. This includes any normal adjustments the user requested via -np, + * etc. + * + * Normally, you should not need to call this function directly; + * write_egg_file() calls it for you. You should call this only if you do not + * use write_egg_file() to write out the resulting egg file. + */ void SomethingToEgg:: post_process_egg_file() { apply_units_scale(_data); EggConverter::post_process_egg_file(); } -//////////////////////////////////////////////////////////////////// -// Function: SomethingToEgg::dispatch_animation_convert -// Access: Protected, Static -// Description: Dispatch function to set the given animation convert mode -// according to the specified parameter. var is a -// pointer to an AnimationConvert variable. -//////////////////////////////////////////////////////////////////// +/** + * Dispatch function to set the given animation convert mode according to the + * specified parameter. var is a pointer to an AnimationConvert variable. + */ bool SomethingToEgg:: dispatch_animation_convert(const string &opt, const string &arg, void *var) { AnimationConvert *ip = (AnimationConvert *)var; @@ -350,7 +322,7 @@ dispatch_animation_convert(const string &opt, const string &arg, void *var) { if ((*ip) == AC_invalid) { nout << "Invalid keyword for -" << opt << ": " << arg << "\n"; return false; - } + } return true; } diff --git a/pandatool/src/eggbase/somethingToEgg.h b/pandatool/src/eggbase/somethingToEgg.h index af667dbebe..263cfd5336 100644 --- a/pandatool/src/eggbase/somethingToEgg.h +++ b/pandatool/src/eggbase/somethingToEgg.h @@ -1,16 +1,15 @@ -// Filename: somethingToEgg.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file somethingToEgg.h + * @author drose + * @date 2000-02-15 + */ #ifndef SOMETHINGTOEGG_H #define SOMETHINGTOEGG_H @@ -23,12 +22,10 @@ class SomethingToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : SomethingToEgg -// Description : This is the general base class for a file-converter -// program that reads some model file format and -// generates an egg file. -//////////////////////////////////////////////////////////////////// +/** + * This is the general base class for a file-converter program that reads some + * model file format and generates an egg file. + */ class SomethingToEgg : public EggConverter { public: SomethingToEgg(const string &format_name, @@ -77,5 +74,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggcharbase/config_eggcharbase.cxx b/pandatool/src/eggcharbase/config_eggcharbase.cxx index aba96f01f9..734939a4bc 100644 --- a/pandatool/src/eggcharbase/config_eggcharbase.cxx +++ b/pandatool/src/eggcharbase/config_eggcharbase.cxx @@ -1,16 +1,15 @@ -// Filename: config_eggcharbase.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_eggcharbase.cxx + * @author drose + * @date 2001-02-26 + */ #include "config_eggcharbase.h" #include "eggBackPointer.h" @@ -35,14 +34,12 @@ ConfigureFn(config_eggcharbase) { init_libeggcharbase(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libeggcharbase -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libeggcharbase() { static bool initialized = false; diff --git a/pandatool/src/eggcharbase/config_eggcharbase.h b/pandatool/src/eggcharbase/config_eggcharbase.h index 564cf0c484..d6d1404ee2 100644 --- a/pandatool/src/eggcharbase/config_eggcharbase.h +++ b/pandatool/src/eggcharbase/config_eggcharbase.h @@ -1,24 +1,22 @@ -// Filename: config_eggcharbase.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_eggcharbase.h + * @author drose + * @date 2001-02-26 + */ #ifndef CONFIG_EGGCHARBASE_H #define CONFIG_EGGCHARBASE_H #include "pandabase.h" -// Commented out to resolve link problem -// #include "notifyCategoryProxy.h" +// Commented out to resolve link problem #include "notifyCategoryProxy.h" // NotifyCategoryDecl(eggcharbase, EXPCL_MISC, EXPTP_MISC); extern void init_libeggcharbase(); diff --git a/pandatool/src/eggcharbase/eggBackPointer.cxx b/pandatool/src/eggcharbase/eggBackPointer.cxx index 8fb0326cad..aa4a95f73a 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.cxx +++ b/pandatool/src/eggcharbase/eggBackPointer.cxx @@ -1,71 +1,59 @@ -// Filename: eggBackPointer.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBackPointer.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggBackPointer.h" TypeHandle EggBackPointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggBackPointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggBackPointer:: EggBackPointer() { } -//////////////////////////////////////////////////////////////////// -// Function: EggBackPointer::get_frame_rate -// Access: Public, Virtual -// Description: Returns the stated frame rate of this particular -// joint, or 0.0 if it doesn't state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated frame rate of this particular joint, or 0.0 if it + * doesn't state. + */ double EggBackPointer:: get_frame_rate() const { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: EggBackPointer::extend_to -// Access: Public, Virtual -// Description: Extends the table to the indicated number of frames. -//////////////////////////////////////////////////////////////////// +/** + * Extends the table to the indicated number of frames. + */ void EggBackPointer:: extend_to(int num_frames) { // Whoops, can't extend this kind of table! nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: EggBackPointer::has_vertices -// Access: Public, Virtual -// Description: Returns true if there are any vertices referenced by -// the node this points to, false otherwise. For -// certain kinds of back pointers (e.g. table animation -// entries), this is always false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any vertices referenced by the node this points + * to, false otherwise. For certain kinds of back pointers (e.g. table + * animation entries), this is always false. + */ bool EggBackPointer:: has_vertices() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggBackPointer::set_name -// Access: Public, Virtual -// Description: Applies the indicated name change to the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated name change to the egg file. + */ void EggBackPointer:: set_name(const string &name) { } diff --git a/pandatool/src/eggcharbase/eggBackPointer.h b/pandatool/src/eggcharbase/eggBackPointer.h index 7cbd02c7dc..6a0e864046 100644 --- a/pandatool/src/eggcharbase/eggBackPointer.h +++ b/pandatool/src/eggcharbase/eggBackPointer.h @@ -1,16 +1,15 @@ -// Filename: eggBackPointer.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggBackPointer.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGBACKPOINTER_H #define EGGBACKPOINTER_H @@ -19,19 +18,16 @@ #include "typedObject.h" -//////////////////////////////////////////////////////////////////// -// Class : EggBackPointer -// Description : This stores a pointer from an EggJointData or -// EggSliderData object back to the referencing data in -// an egg file. One of these objects corresponds to -// each model appearing in an egg file, and may -// reference either a single node, or a table, or a slew -// of vertices and primitives, depending on the type of -// data stored. -// -// This is just an abstract base class. The actual -// details are stored in the various subclasses. -//////////////////////////////////////////////////////////////////// +/** + * This stores a pointer from an EggJointData or EggSliderData object back to + * the referencing data in an egg file. One of these objects corresponds to + * each model appearing in an egg file, and may reference either a single + * node, or a table, or a slew of vertices and primitives, depending on the + * type of data stored. + * + * This is just an abstract base class. The actual details are stored in the + * various subclasses. + */ class EggBackPointer : public TypedObject { public: EggBackPointer(); @@ -62,5 +58,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.I b/pandatool/src/eggcharbase/eggCharacterCollection.I index 31cfdd896e..0e1c81f62a 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.I +++ b/pandatool/src/eggcharbase/eggCharacterCollection.I @@ -1,107 +1,83 @@ -// Filename: eggCharacterCollection.I -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterCollection.I + * @author drose + * @date 2001-02-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_num_eggs -// Access: Public -// Description: Returns the number of egg files that have -// successfully been added to the Character table. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of egg files that have successfully been added to the + * Character table. + */ INLINE int EggCharacterCollection:: get_num_eggs() const { return _eggs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_egg -// Access: Public -// Description: Returns the ith egg file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith egg file. + */ INLINE EggData *EggCharacterCollection:: get_egg(int i) const { nassertr(i >= 0 && i < (int)_eggs.size(), (EggData *)NULL); return _eggs[i]._egg; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_first_model_index -// Access: Public -// Description: Returns the first model index associated with the -// indicated egg file. An egg file may contain multiple -// models, which will be consecutive integers beginning -// at get_first_model_index() and continuing for -// get_num_models(). -// -// Each "model" corresponds to a single character model, -// or one LOD of a multiple-LOD model, or a single -// animation bundle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first model index associated with the indicated egg file. An + * egg file may contain multiple models, which will be consecutive integers + * beginning at get_first_model_index() and continuing for get_num_models(). + * + * Each "model" corresponds to a single character model, or one LOD of a + * multiple-LOD model, or a single animation bundle. + */ INLINE int EggCharacterCollection:: get_first_model_index(int egg_index) const { nassertr(egg_index >= 0 && egg_index < (int)_eggs.size(), 0); return _eggs[egg_index]._first_model_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_num_models -// Access: Public -// Description: Returns the number of different models found in the -// indicated egg file. An egg file may contain multiple -// models, which will be consecutive integers beginning -// at get_first_model_index() and continuing for -// get_num_models(). -// -// Each "model" corresponds to a single character model, -// or one LOD of a multiple-LOD model, or a single -// animation bundle. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of different models found in the indicated egg file. An + * egg file may contain multiple models, which will be consecutive integers + * beginning at get_first_model_index() and continuing for get_num_models(). + * + * Each "model" corresponds to a single character model, or one LOD of a + * multiple-LOD model, or a single animation bundle. + */ INLINE int EggCharacterCollection:: get_num_models(int egg_index) const { nassertr(egg_index >= 0 && egg_index < (int)_eggs.size(), 0); return _eggs[egg_index]._models.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_num_characters -// Access: Public -// Description: Returns the number of separate Characters that have -// been discovered in the various egg files added to the -// collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of separate Characters that have been discovered in the + * various egg files added to the collection. + */ INLINE int EggCharacterCollection:: get_num_characters() const { return _characters.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_character -// Access: Public -// Description: Returns the ith character in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ith character in the collection. + */ INLINE EggCharacterData *EggCharacterCollection:: get_character(int i) const { nassertr(i >= 0 && i < (int)_characters.size(), (EggCharacterData *)NULL); return _characters[i]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_character_by_model_index -// Access: Public -// Description: Returns the character associated with the indicated -// model index. -//////////////////////////////////////////////////////////////////// +/** + * Returns the character associated with the indicated model index. + */ INLINE EggCharacterData *EggCharacterCollection:: get_character_by_model_index(int model_index) const { nassertr(model_index >= 0 && model_index < (int)_characters_by_model_index.size(), @@ -109,11 +85,9 @@ get_character_by_model_index(int model_index) const { return _characters_by_model_index[model_index]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::ModelDescription::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCharacterCollection::ModelDescription:: ModelDescription() { _root_node = (EggObject *)NULL; diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.cxx b/pandatool/src/eggcharbase/eggCharacterCollection.cxx index eb13e7f1be..2a97862ea6 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.cxx +++ b/pandatool/src/eggcharbase/eggCharacterCollection.cxx @@ -1,16 +1,15 @@ -// Filename: eggCharacterCollection.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterCollection.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggCharacterCollection.h" #include "eggCharacterData.h" @@ -31,21 +30,17 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterCollection:: EggCharacterCollection() { _next_model_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterCollection:: ~EggCharacterCollection() { Characters::iterator ci; @@ -55,20 +50,17 @@ EggCharacterCollection:: } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::add_egg -// Access: Public -// Description: Adds a new egg file to the list of models and -// animation files for this particular character. -// -// Returns the new egg_index if the file is successfully -// added, or -1 if there is some problem (for instance, -// it does not contain a character model or animation -// table). -// -// If the joint hierarchy does not match the existing -// joint hierarchy, a best match is attempted. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new egg file to the list of models and animation files for this + * particular character. + * + * Returns the new egg_index if the file is successfully added, or -1 if there + * is some problem (for instance, it does not contain a character model or + * animation table). + * + * If the joint hierarchy does not match the existing joint hierarchy, a best + * match is attempted. + */ int EggCharacterCollection:: add_egg(EggData *egg) { _top_egg_nodes.clear(); @@ -83,8 +75,8 @@ add_egg(EggData *egg) { egg_info._egg = egg; egg_info._first_model_index = 0; - // Now, for each model, add an entry in the egg_info and match the - // joint hierarchy to the known joints. + // Now, for each model, add an entry in the egg_info and match the joint + // hierarchy to the known joints. TopEggNodesByName::iterator tni; for (tni = _top_egg_nodes.begin(); tni != _top_egg_nodes.end(); ++tni) { string character_name = (*tni).first; @@ -119,12 +111,10 @@ add_egg(EggData *egg) { return egg_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::get_character_by_name -// Access: Public -// Description: Returns the Character with the indicated name, if it -// exists in the collection, or NULL if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Character with the indicated name, if it exists in the + * collection, or NULL if it does not. + */ EggCharacterData *EggCharacterCollection:: get_character_by_name(const string &character_name) const { Characters::const_iterator ci; @@ -139,55 +129,41 @@ get_character_by_name(const string &character_name) const { } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::make_character_data -// Access: Public, Virtual -// Description: Allocates and returns a new EggCharacterData -// structure. This is primarily intended as a hook so -// derived classes can customize the type of -// EggCharacterData nodes used to represent the -// characters in this collection. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggCharacterData structure. This is primarily + * intended as a hook so derived classes can customize the type of + * EggCharacterData nodes used to represent the characters in this collection. + */ EggCharacterData *EggCharacterCollection:: make_character_data() { return new EggCharacterData(this); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::make_joint_data -// Access: Public, Virtual -// Description: Allocates and returns a new EggJointData structure -// for the given character. This is primarily intended -// as a hook so derived classes can customize the type -// of EggJointData nodes used to represent the joint -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggJointData structure for the given character. + * This is primarily intended as a hook so derived classes can customize the + * type of EggJointData nodes used to represent the joint hierarchy. + */ EggJointData *EggCharacterCollection:: make_joint_data(EggCharacterData *char_data) { return new EggJointData(this, char_data); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::make_slider_data -// Access: Public, Virtual -// Description: Allocates and returns a new EggSliderData structure -// for the given character. This is primarily intended -// as a hook so derived classes can customize the type -// of EggSliderData nodes used to represent the slider -// list. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggSliderData structure for the given + * character. This is primarily intended as a hook so derived classes can + * customize the type of EggSliderData nodes used to represent the slider + * list. + */ EggSliderData *EggCharacterCollection:: make_slider_data(EggCharacterData *char_data) { return new EggSliderData(this, char_data); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::make_character -// Access: Protected -// Description: Allocates and returns a new EggCharacterData object -// representing the named character, if there is not -// already a character by that name. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggCharacterData object representing the named + * character, if there is not already a character by that name. + */ EggCharacterData *EggCharacterCollection:: make_character(const string &character_name) { // Does the named character exist yet? @@ -207,18 +183,14 @@ make_character(const string &character_name) { return char_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::scan_hierarchy -// Access: Private -// Description: Walks the given egg data's hierarchy, looking for -// either the start of an animation channel or the start -// of a character model. Returns true if either (or -// both) is found, false if the model appears to have -// nothing to do with characters. -// -// Fills up the _top_egg_nodes according to the nodes -// found. -//////////////////////////////////////////////////////////////////// +/** + * Walks the given egg data's hierarchy, looking for either the start of an + * animation channel or the start of a character model. Returns true if + * either (or both) is found, false if the model appears to have nothing to do + * with characters. + * + * Fills up the _top_egg_nodes according to the nodes found. + */ bool EggCharacterCollection:: scan_hierarchy(EggNode *egg_node) { if (egg_node->is_of_type(EggGroup::get_class_type())) { @@ -252,13 +224,10 @@ scan_hierarchy(EggNode *egg_node) { return character_found; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::scan_for_top_joints -// Access: Private -// Description: Once a character model has been found, continue -// scanning the egg hierarchy to look for the topmost -// nodes encountered. -//////////////////////////////////////////////////////////////////// +/** + * Once a character model has been found, continue scanning the egg hierarchy + * to look for the topmost nodes encountered. + */ void EggCharacterCollection:: scan_for_top_joints(EggNode *egg_node, EggNode *model_root, const string &character_name) { @@ -266,9 +235,9 @@ scan_for_top_joints(EggNode *egg_node, EggNode *model_root, EggGroup *group = DCAST(EggGroup, egg_node); if (group->has_lod()) { - // This group has an LOD specification; that indicates multiple - // skeleton hierarchies for this character, one for each LOD. - // We call each of these a separate model. + // This group has an LOD specification; that indicates multiple skeleton + // hierarchies for this character, one for each LOD. We call each of + // these a separate model. model_root = group; } if (group->get_group_type() == EggGroup::GT_joint) { @@ -289,26 +258,23 @@ scan_for_top_joints(EggNode *egg_node, EggNode *model_root, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::scan_for_top_tables -// Access: Private -// Description: Once an animation has been found, continue scanning -// the egg hierarchy to look for the topmost
-// nodes encountered. -//////////////////////////////////////////////////////////////////// +/** + * Once an animation has been found, continue scanning the egg hierarchy to + * look for the topmost
nodes encountered. + */ void EggCharacterCollection:: scan_for_top_tables(EggTable *bundle, EggNode *model_root, const string &character_name) { - // We really only need to check the immediate children of the bundle - // for a table node called "". + // We really only need to check the immediate children of the bundle for a + // table node called "". EggGroupNode::iterator gi; for (gi = bundle->begin(); gi != bundle->end(); ++gi) { EggNode *child = (*gi); if (child->is_of_type(EggTable::get_class_type())) { EggTable *table = DCAST(EggTable, child); if (table->get_name() == "") { - // Here it is! Now the immediate children of this node are - // the top tables. + // Here it is! Now the immediate children of this node are the top + // tables. ModelDescription &desc = _top_egg_nodes[character_name][model_root]; desc._root_node = table; @@ -324,12 +290,10 @@ scan_for_top_tables(EggTable *bundle, EggNode *model_root, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::scan_for_morphs -// Access: Private -// Description: Go back through a model's hierarchy and look for -// morph targets on the vertices and primitives. -//////////////////////////////////////////////////////////////////// +/** + * Go back through a model's hierarchy and look for morph targets on the + * vertices and primitives. + */ void EggCharacterCollection:: scan_for_morphs(EggNode *egg_node, int model_index, EggCharacterData *char_data) { @@ -365,23 +329,20 @@ scan_for_morphs(EggNode *egg_node, int model_index, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::scan_for_sliders -// Access: Private -// Description: Go back to the animation tables and look for morph -// slider animation channels. -//////////////////////////////////////////////////////////////////// +/** + * Go back to the animation tables and look for morph slider animation + * channels. + */ void EggCharacterCollection:: scan_for_sliders(EggNode *egg_node, int model_index, EggCharacterData *char_data) { if (egg_node->is_of_type(EggTable::get_class_type())) { EggTable *bundle = DCAST(EggTable, egg_node); - // We really only need to check the immediate children of the - // bundle for a table node called "morph". This is a sibling of - // "", which we found a minute ago, but we weren't ready - // to scan for the morph sliders at the time, so we have to look - // again now. + // We really only need to check the immediate children of the bundle for a + // table node called "morph". This is a sibling of "", which we + // found a minute ago, but we weren't ready to scan for the morph sliders + // at the time, so we have to look again now. EggGroupNode::iterator gi; for (gi = bundle->begin(); gi != bundle->end(); ++gi) { @@ -389,8 +350,8 @@ scan_for_sliders(EggNode *egg_node, int model_index, if (child->is_of_type(EggTable::get_class_type())) { EggTable *table = DCAST(EggTable, child); if (table->get_name() == "morph") { - // Here it is! Now the immediate children of this node are - // all the slider channels. + // Here it is! Now the immediate children of this node are all the + // slider channels. EggGroupNode::iterator cgi; for (cgi = table->begin(); cgi != table->end(); ++cgi) { @@ -405,12 +366,10 @@ scan_for_sliders(EggNode *egg_node, int model_index, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::add_morph_back_pointers -// Access: Private -// Description: Adds the back pointers for the kinds of morphs we -// might find in an EggAttributes object. -//////////////////////////////////////////////////////////////////// +/** + * Adds the back pointers for the kinds of morphs we might find in an + * EggAttributes object. + */ void EggCharacterCollection:: add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object, int model_index, EggCharacterData *char_data) { @@ -431,12 +390,10 @@ add_morph_back_pointers(EggAttributes *attrib, EggObject *egg_object, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::add_morph_back_pointers_vertex -// Access: Private -// Description: Adds the back pointers for the kinds of morphs we -// might find in an EggVertex object. -//////////////////////////////////////////////////////////////////// +/** + * Adds the back pointers for the kinds of morphs we might find in an + * EggVertex object. + */ void EggCharacterCollection:: add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object, int model_index, EggCharacterData *char_data) { @@ -453,21 +410,17 @@ add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::match_egg_nodes -// Access: Private -// Description: Attempts to match up the indicated list of egg_nodes -// with the children of the given joint_data, by name if -// possible. -// -// Also recurses on each matched joint to build up the -// entire joint hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to match up the indicated list of egg_nodes with the children of + * the given joint_data, by name if possible. + * + * Also recurses on each matched joint to build up the entire joint hierarchy. + */ void EggCharacterCollection:: match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data, EggNodeList &egg_nodes, int egg_index, int model_index) { - // Sort the list of egg_nodes in order by name. This will make the - // matching up by names easier and more reliable. + // Sort the list of egg_nodes in order by name. This will make the matching + // up by names easier and more reliable. sort(egg_nodes.begin(), egg_nodes.end(), IndirectCompareNames()); if (joint_data->_children.empty()) { @@ -486,8 +439,8 @@ match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data, } } else { - // The EggJointData already has children; therefore, we have to - // match our joints up with the already-existing ones. + // The EggJointData already has children; therefore, we have to match our + // joints up with the already-existing ones. EggNodeList extra_egg_nodes; EggJointData::Children extra_data; @@ -537,11 +490,10 @@ match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data, } if (!extra_egg_nodes.empty()) { - // If we have some extra egg_nodes, we have to find a place to - // match them. (If we only had extra data, we don't care.) + // If we have some extra egg_nodes, we have to find a place to match + // them. (If we only had extra data, we don't care.) - // First, check to see if any of the names match any past-used - // name. + // First, check to see if any of the names match any past-used name. EggNodeList more_egg_nodes; for (ei = extra_egg_nodes.begin(); ei != extra_egg_nodes.end(); ++ei) { @@ -566,8 +518,7 @@ match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data, } if (!extra_egg_nodes.empty()) { - // Ok, we've still got to find a home for these remaining - // egg_nodes. + // Ok, we've still got to find a home for these remaining egg_nodes. if (extra_egg_nodes.size() == extra_data.size()) { // Match 'em up one-for-one. size_t i; @@ -594,19 +545,15 @@ match_egg_nodes(EggCharacterData *char_data, EggJointData *joint_data, } } - // Now sort the generated joint data hierarchy by name, just to be - // sure. + // Now sort the generated joint data hierarchy by name, just to be sure. sort(joint_data->_children.begin(), joint_data->_children.end(), IndirectCompareNames()); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::found_egg_match -// Access: Private -// Description: Marks a one-to-one association between the indicated -// EggJointData and the indicated EggNode, and then -// recurses below. -//////////////////////////////////////////////////////////////////// +/** + * Marks a one-to-one association between the indicated EggJointData and the + * indicated EggNode, and then recurses below. + */ void EggCharacterCollection:: found_egg_match(EggCharacterData *char_data, EggJointData *joint_data, EggNode *egg_node, int egg_index, int model_index) { @@ -619,12 +566,12 @@ found_egg_match(EggCharacterData *char_data, EggJointData *joint_data, if (egg_node->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *group_node = DCAST(EggGroupNode, egg_node); - // Now consider all the children of egg_node that are themselves - // joints or tables. + // Now consider all the children of egg_node that are themselves joints or + // tables. EggNodeList egg_nodes; - // Two approaches: either we are scanning a model with joints, or - // an animation bundle with tables. + // Two approaches: either we are scanning a model with joints, or an + // animation bundle with tables. if (egg_node->is_of_type(EggGroup::get_class_type())) { // A model with joints. @@ -660,13 +607,10 @@ found_egg_match(EggCharacterData *char_data, EggJointData *joint_data, } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::rename_char -// Access: Public -// Description: Renames the ith character to the indicated name. -// This name must not already be used by another -// character in the collection. -//////////////////////////////////////////////////////////////////// +/** + * Renames the ith character to the indicated name. This name must not + * already be used by another character in the collection. + */ void EggCharacterCollection:: rename_char(int i, const string &name) { nassertv(i >= 0 && i < (int)_characters.size()); @@ -678,11 +622,9 @@ rename_char(int i, const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggCharacterCollection:: write(ostream &out, int indent_level) const { Characters::const_iterator ci; @@ -693,20 +635,16 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterCollection::check_errors -// Access: Public -// Description: Can be called after the collection has been -// completely filled up with egg files to output any -// messages from warning conditions that have been -// detected, such as inconsistent animation tables. -// -// In addition to reporting this errors, calling this -// function will also ensure that they are all repaired. -// Pass force_initial_rest_frame as true to also force -// rest frames from different models to be the same if -// they are initially different. -//////////////////////////////////////////////////////////////////// +/** + * Can be called after the collection has been completely filled up with egg + * files to output any messages from warning conditions that have been + * detected, such as inconsistent animation tables. + * + * In addition to reporting this errors, calling this function will also + * ensure that they are all repaired. Pass force_initial_rest_frame as true + * to also force rest frames from different models to be the same if they are + * initially different. + */ void EggCharacterCollection:: check_errors(ostream &out, bool force_initial_rest_frame) { Characters::const_iterator ci; @@ -718,10 +656,10 @@ check_errors(ostream &out, bool force_initial_rest_frame) { if (joint_data->rest_frames_differ()) { if (force_initial_rest_frame) { joint_data->force_initial_rest_frame(); - out << "Forced rest frames the same for " << joint_data->get_name() + out << "Forced rest frames the same for " << joint_data->get_name() << ".\n"; } else { - out << "Warning: rest frames for " << joint_data->get_name() + out << "Warning: rest frames for " << joint_data->get_name() << " differ.\n"; } } @@ -731,7 +669,7 @@ check_errors(ostream &out, bool force_initial_rest_frame) { for (int mi = 0; mi < num_models; mi++) { int model_index = char_data->get_model_index(mi); if (!char_data->check_num_frames(model_index)) { - out << "Warning: animation from " + out << "Warning: animation from " << char_data->get_egg_data(model_index)->get_egg_filename().get_basename() << " had an inconsistent number of frames.\n"; } diff --git a/pandatool/src/eggcharbase/eggCharacterCollection.h b/pandatool/src/eggcharbase/eggCharacterCollection.h index 1abe61a855..57c3bc984d 100644 --- a/pandatool/src/eggcharbase/eggCharacterCollection.h +++ b/pandatool/src/eggcharbase/eggCharacterCollection.h @@ -1,16 +1,15 @@ -// Filename: eggCharacterCollection.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterCollection.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGCHARACTERCOLLECTION_H #define EGGCHARACTERCOLLECTION_H @@ -26,12 +25,10 @@ class EggTable; class EggAttributes; -//////////////////////////////////////////////////////////////////// -// Class : EggCharacterCollection -// Description : Represents a set of characters, as read and collected -// from possibly several model and/or animation egg -// files. -//////////////////////////////////////////////////////////////////// +/** + * Represents a set of characters, as read and collected from possibly several + * model and/or animation egg files. + */ class EggCharacterCollection { public: EggCharacterCollection(); @@ -93,8 +90,8 @@ private: void add_morph_back_pointers_vertex(EggVertex *vertex, EggObject *egg_object, int model_index, EggCharacterData *char_data); - // The _top_egg_nodes member is only used temporarily, when adding - // each pre-existing egg file to the structure for the first time. + // The _top_egg_nodes member is only used temporarily, when adding each pre- + // existing egg file to the structure for the first time. typedef pvector EggNodeList; class ModelDescription { public: @@ -118,5 +115,3 @@ private: #include "eggCharacterCollection.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggCharacterData.I b/pandatool/src/eggcharbase/eggCharacterData.I index d54bfc250a..7b19b079b6 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.I +++ b/pandatool/src/eggcharbase/eggCharacterData.I @@ -1,116 +1,91 @@ -// Filename: eggCharacterData.I -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterData.I + * @author drose + * @date 2001-02-23 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_num_models -// Access: Public -// Description: Returns the total number of models associated with -// this character. -// -// A "model" here is either a character model (or one -// LOD of a character model), or a character animation -// file: in either case, a hierarchy of joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of models associated with this character. + * + * A "model" here is either a character model (or one LOD of a character + * model), or a character animation file: in either case, a hierarchy of + * joints. + */ INLINE int EggCharacterData:: get_num_models() const { return _models.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_model_index -// Access: Public -// Description: Returns the model_index of the nth model associated -// with this character. This model_index may be used to -// ask questions about the particular model from the -// EggCharacterCollection object, or from the individual -// EggJointData and EggSliderData objects. -// -// A "model" here is either a character model (or one -// LOD of a character model), or a character animation -// file: in either case, a hierarchy of joints. -//////////////////////////////////////////////////////////////////// +/** + * Returns the model_index of the nth model associated with this character. + * This model_index may be used to ask questions about the particular model + * from the EggCharacterCollection object, or from the individual EggJointData + * and EggSliderData objects. + * + * A "model" here is either a character model (or one LOD of a character + * model), or a character animation file: in either case, a hierarchy of + * joints. + */ INLINE int EggCharacterData:: get_model_index(int n) const { nassertr(n >= 0 && n < (int)_models.size(), 0); return _models[n]._model_index; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_model_root -// Access: Public -// Description: Returns the model_root of the nth model associated -// with this character. -// -// This is the node at which the character, animation -// bundle, or LOD officially began within its particular -// egg file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the model_root of the nth model associated with this character. + * + * This is the node at which the character, animation bundle, or LOD + * officially began within its particular egg file. + */ INLINE EggNode *EggCharacterData:: get_model_root(int n) const { nassertr(n >= 0 && n < (int)_models.size(), (EggNode *)NULL); return _models[n]._model_root; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_egg_data -// Access: Public -// Description: Returns the EggData representing the egg file that -// defined this particular model. Note that one egg -// file might contain multiple models. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggData representing the egg file that defined this particular + * model. Note that one egg file might contain multiple models. + */ INLINE EggData *EggCharacterData:: get_egg_data(int n) const { nassertr(n >= 0 && n < (int)_models.size(), (EggData *)NULL); return _models[n]._egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_root_joint -// Access: Public -// Description: Returns the root joint of the character hierarchy. -// This root joint does not represent an actual joint in -// the hierarchy, but instead is a fictitious joint that -// is the parent of all the top joints in the hierarchy -// (since the hierarchy may actually contain zero or -// more top joints). -//////////////////////////////////////////////////////////////////// +/** + * Returns the root joint of the character hierarchy. This root joint does + * not represent an actual joint in the hierarchy, but instead is a fictitious + * joint that is the parent of all the top joints in the hierarchy (since the + * hierarchy may actually contain zero or more top joints). + */ INLINE EggJointData *EggCharacterData:: get_root_joint() const { return _root_joint; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::find_joint -// Access: Public -// Description: Returns the first joint found with the indicated -// name, or NULL if no joint has that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first joint found with the indicated name, or NULL if no joint + * has that name. + */ INLINE EggJointData *EggCharacterData:: find_joint(const string &name) const { return _root_joint->find_joint(name); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::make_new_joint -// Access: Public -// Description: Creates a new joint as a child of the indicated joint -// and returns it. The new joint will be initialized to -// the identity transform, so that in inherits the -// net transform of the indicated parent joint. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new joint as a child of the indicated joint and returns it. The + * new joint will be initialized to the identity transform, so that in + * inherits the net transform of the indicated parent joint. + */ INLINE EggJointData *EggCharacterData:: make_new_joint(const string &name, EggJointData *parent) { EggJointData *joint = parent->make_new_joint(name); @@ -119,73 +94,55 @@ make_new_joint(const string &name, EggJointData *parent) { return joint; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_num_joints -// Access: Public -// Description: Returns the total number of joints in the character -// joint hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of joints in the character joint hierarchy. + */ INLINE int EggCharacterData:: get_num_joints() const { return _joints.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_joint -// Access: Public -// Description: Returns the nth joint in the character joint -// hierarchy. This returns all of the joints in the -// hierarchy in an arbitrary ordering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth joint in the character joint hierarchy. This returns all + * of the joints in the hierarchy in an arbitrary ordering. + */ INLINE EggJointData *EggCharacterData:: get_joint(int n) const { nassertr(n >= 0 && n < (int)_joints.size(), NULL); return _joints[n]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_num_sliders -// Access: Public -// Description: Returns the number of sliders in the character -// slider list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of sliders in the character slider list. + */ INLINE int EggCharacterData:: get_num_sliders() const { return _sliders.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_slider -// Access: Public -// Description: Returns the nth slider in the character slider list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth slider in the character slider list. + */ INLINE EggSliderData *EggCharacterData:: get_slider(int n) const { nassertr(n >= 0 && n < (int)_sliders.size(), NULL); return _sliders[n]; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_num_components -// Access: Public -// Description: Returns the total number of joints and sliders in -// the character. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of joints and sliders in the character. + */ INLINE int EggCharacterData:: get_num_components() const { return _components.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_component -// Access: Public -// Description: Returns the nth joint or slider in the character. -// This can be used to walk linearly through all joints -// and sliders in the character when you don't care -// about making a distinction between the two; it -// returns the same objects that can also be discovered -// via get_slider() and get_root_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth joint or slider in the character. This can be used to walk + * linearly through all joints and sliders in the character when you don't + * care about making a distinction between the two; it returns the same + * objects that can also be discovered via get_slider() and get_root_joint(). + */ INLINE EggComponentData *EggCharacterData:: get_component(int n) const { nassertr(n >= 0 && n < (int)_components.size(), NULL); diff --git a/pandatool/src/eggcharbase/eggCharacterData.cxx b/pandatool/src/eggcharbase/eggCharacterData.cxx index 9023e4203b..6c444e6c91 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.cxx +++ b/pandatool/src/eggcharbase/eggCharacterData.cxx @@ -1,16 +1,15 @@ -// Filename: eggCharacterData.cxx -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterData.cxx + * @author drose + * @date 2001-02-23 + */ #include "eggCharacterData.h" #include "eggCharacterCollection.h" @@ -21,8 +20,8 @@ #include -// An STL function object to sort the joint list in order from highest -// to lowest in the new hierarchy. Used in do_reparent(). +// An STL function object to sort the joint list in order from highest to +// lowest in the new hierarchy. Used in do_reparent(). class OrderJointsByNewDepth { public: bool operator()(const EggJointData *a, const EggJointData *b) const { @@ -31,11 +30,9 @@ public: }; -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterData:: EggCharacterData(EggCharacterCollection *collection) : _component_names("_", "joint_") @@ -45,11 +42,9 @@ EggCharacterData(EggCharacterCollection *collection) : // The fictitious root joint is not added to the _components list. } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterData:: ~EggCharacterData() { delete _root_joint; @@ -61,16 +56,12 @@ EggCharacterData:: } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::rename_char -// Access: Public -// Description: Renames all of the models in the character data to -// the indicated name. This is the name that is used to -// identify unique skeleton hierarchies; if you set two -// different models to the same name, they will be -// loaded together as if they are expected to have the -// same skeleton hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Renames all of the models in the character data to the indicated name. + * This is the name that is used to identify unique skeleton hierarchies; if + * you set two different models to the same name, they will be loaded together + * as if they are expected to have the same skeleton hierarchy. + */ void EggCharacterData:: rename_char(const string &name) { Models::iterator mi; @@ -81,19 +72,15 @@ rename_char(const string &name) { set_name(name); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::add_model -// Access: Public -// Description: Indicates that the given model_index (with the -// indicated model_root) is associated with this -// character. This is normally called by the -// EggCharacterCollection class as new models are -// discovered. -// -// A "model" here is either a character model (or one -// LOD of a character model), or a character animation -// file: in either case, a hierarchy of joints. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given model_index (with the indicated model_root) is + * associated with this character. This is normally called by the + * EggCharacterCollection class as new models are discovered. + * + * A "model" here is either a character model (or one LOD of a character + * model), or a character animation file: in either case, a hierarchy of + * joints. + */ void EggCharacterData:: add_model(int model_index, EggNode *model_root, EggData *egg_data) { Model m; @@ -103,16 +90,12 @@ add_model(int model_index, EggNode *model_root, EggData *egg_data) { _models.push_back(m); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_num_frames -// Access: Public -// Description: Returns the number of frames of animation of the -// indicated model. This is more reliable than asking a -// particular joint or slider of the animation for its -// number of frames, since a particular joint may have -// only 1 frame (if it is unanimated), even though the -// overall animation has many frames. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation of the indicated model. This is + * more reliable than asking a particular joint or slider of the animation for + * its number of frames, since a particular joint may have only 1 frame (if it + * is unanimated), even though the overall animation has many frames. + */ int EggCharacterData:: get_num_frames(int model_index) const { int max_num_frames = 0; @@ -121,24 +104,21 @@ get_num_frames(int model_index) const { EggComponentData *component = (*ci); int num_frames = component->get_num_frames(model_index); if (num_frames > 1) { - // We have a winner. Assume all other components will be - // similar. + // We have a winner. Assume all other components will be similar. return num_frames; } max_num_frames = max(max_num_frames, num_frames); } - // Every component had either 1 frame or 0 frames. Return the - // maximum of these. + // Every component had either 1 frame or 0 frames. Return the maximum of + // these. return max_num_frames; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::get_frame_rate -// Access: Public -// Description: Returns the stated frame rate of the specified model. -// Similar to get_num_frames(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated frame rate of the specified model. Similar to + * get_num_frames(). + */ double EggCharacterData:: get_frame_rate(int model_index) const { Components::const_iterator ci; @@ -146,8 +126,7 @@ get_frame_rate(int model_index) const { EggComponentData *component = (*ci); double frame_rate = component->get_frame_rate(model_index); if (frame_rate != 0.0) { - // We have a winner. Assume all other components will be - // similar. + // We have a winner. Assume all other components will be similar. return frame_rate; } } @@ -155,16 +134,12 @@ get_frame_rate(int model_index) const { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::check_num_frames -// Access: Public -// Description: Walks through each component and ensures that all -// have the same number of frames of animation (except -// for those that contain 0 or 1 frames, of course). -// Returns true if all are valid, false if there is a -// discreprency (in which case the shorter component are -// extended). -//////////////////////////////////////////////////////////////////// +/** + * Walks through each component and ensures that all have the same number of + * frames of animation (except for those that contain 0 or 1 frames, of + * course). Returns true if all are valid, false if there is a discreprency + * (in which case the shorter component are extended). + */ bool EggCharacterData:: check_num_frames(int model_index) { int max_num_frames = 0; @@ -173,19 +148,17 @@ check_num_frames(int model_index) { for (ci = _components.begin(); ci != _components.end(); ++ci) { EggComponentData *component = (*ci); int num_frames = component->get_num_frames(model_index); - if (num_frames > 1 && max_num_frames > 1 && + if (num_frames > 1 && max_num_frames > 1 && max_num_frames != num_frames) { - // If we have two different opinions about the number of frames - // (other than 0 or 1), we have a discrepency. This is an error - // condition. + // If we have two different opinions about the number of frames (other + // than 0 or 1), we have a discrepency. This is an error condition. any_violations = true; } max_num_frames = max(max_num_frames, num_frames); } if (any_violations) { - // Now go back through and force all components to the appropriate - // length. + // Now go back through and force all components to the appropriate length. for (ci = _components.begin(); ci != _components.end(); ++ci) { EggComponentData *component = (*ci); int num_frames = component->get_num_frames(model_index); @@ -198,18 +171,14 @@ check_num_frames(int model_index) { return !any_violations; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::do_reparent -// Access: Public -// Description: Begins the process of restructuring the joint -// hierarchy according to the previous calls to -// reparent_to() on various joints. This will reparent -// the joint hierachy in all models as requested, while -// adjusting the transforms as appropriate so that each -// joint retains the same net transform across all -// frames that it had before the operation. Returns -// true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Begins the process of restructuring the joint hierarchy according to the + * previous calls to reparent_to() on various joints. This will reparent the + * joint hierachy in all models as requested, while adjusting the transforms + * as appropriate so that each joint retains the same net transform across all + * frames that it had before the operation. Returns true on success, false on + * failure. + */ bool EggCharacterData:: do_reparent() { typedef pset InvalidSet; @@ -221,14 +190,14 @@ do_reparent() { EggJointData *joint_data = (*ji); joint_data->do_begin_reparent(); } - // We also need to clear the children on the root joint, but the - // root joint doesn't get any of the other operations (including - // finish_reparent) applied to it. + // We also need to clear the children on the root joint, but the root joint + // doesn't get any of the other operations (including finish_reparent) + // applied to it. _root_joint->do_begin_reparent(); - // Now, check for cycles in the new parenting hierarchy, and also - // sort the joints in order from top to bottom in the new hierarchy. + // Now, check for cycles in the new parenting hierarchy, and also sort the + // joints in order from top to bottom in the new hierarchy. for (ji = _joints.begin(); ji != _joints.end(); ++ji) { EggJointData *joint_data = (*ji); pset chain; @@ -239,11 +208,10 @@ do_reparent() { } } sort(_joints.begin(), _joints.end(), OrderJointsByNewDepth()); - - // Now compute the new transforms for the joints' new positions. - // This is done recursively through the new parent hierarchy, so we - // can take advantage of caching the net value for a particular - // frame. + + // Now compute the new transforms for the joints' new positions. This is + // done recursively through the new parent hierarchy, so we can take + // advantage of caching the net value for a particular frame. Models::const_iterator mi; for (mi = _models.begin(); mi != _models.end(); ++mi) { EggCharacterDb db; @@ -251,7 +219,7 @@ do_reparent() { int num_frames = get_num_frames(model_index); nout << " computing " << (mi - _models.begin()) + 1 << " of " << _models.size() - << ": " << (*mi)._egg_data->get_egg_filename() + << ": " << (*mi)._egg_data->get_egg_filename() << " (" << num_frames << " frames)\n"; for (int f = 0; f < num_frames; f++) { // First, walk through all the joints and flush the computed net @@ -262,8 +230,8 @@ do_reparent() { } _root_joint->do_begin_compute_reparent(); - // Now go back through and compute the reparented transforms, - // caching net transforms as necessary. + // Now go back through and compute the reparented transforms, caching + // net transforms as necessary. for (ji = _joints.begin(); ji != _joints.end(); ++ji) { EggJointData *joint_data = (*ji); if (!joint_data->do_compute_reparent(model_index, f, db)) { @@ -288,16 +256,15 @@ do_reparent() { joint_data->do_finish_reparent(); } - // Report the set of joints that failed. It really shouldn't be - // possible for any joints to fail, so if you see anything reported - // here, something went wrong at a fundamental level. Perhaps a - // problem with decompose_matrix(). + // Report the set of joints that failed. It really shouldn't be possible + // for any joints to fail, so if you see anything reported here, something + // went wrong at a fundamental level. Perhaps a problem with + // decompose_matrix(). InvalidSet::const_iterator si; for (si = invalid_set.begin(); si != invalid_set.end(); ++si) { EggJointData *joint_data = (*si); - // Don't bother reporting joints that no longer have a parent, - // since we don't care about joints that are now outside the - // hierarchy. + // Don't bother reporting joints that no longer have a parent, since we + // don't care about joints that are now outside the hierarchy. if (joint_data->get_parent() != (EggJointData *)NULL) { nout << "Warning: reparenting " << joint_data->get_name() << " to "; @@ -313,20 +280,16 @@ do_reparent() { return invalid_set.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::choose_optimal_hierarchy -// Access: Public -// Description: Chooses the best possible parent joint for each of -// the joints in the hierarchy, based on the score -// computed by EggJointData::score_reparent_to(). This -// is a fairly expensive operation that involves lots of -// recomputing of transforms across the hierarchy. -// -// The joints are not actually reparented yet, but the -// new_parent of each joint is set. Call do_reparent() -// to actually perform the suggested reparenting -// operation. -//////////////////////////////////////////////////////////////////// +/** + * Chooses the best possible parent joint for each of the joints in the + * hierarchy, based on the score computed by + * EggJointData::score_reparent_to(). This is a fairly expensive operation + * that involves lots of recomputing of transforms across the hierarchy. + * + * The joints are not actually reparented yet, but the new_parent of each + * joint is set. Call do_reparent() to actually perform the suggested + * reparenting operation. + */ void EggCharacterData:: choose_optimal_hierarchy() { EggCharacterDb db; @@ -361,7 +324,7 @@ choose_optimal_hierarchy() { } } - if (best_parent != (EggJointData *)NULL && + if (best_parent != (EggJointData *)NULL && best_parent != joint_data->_parent) { nout << "best parent for " << joint_data->get_name() << " is " << best_parent->get_name() << "\n"; @@ -370,12 +333,10 @@ choose_optimal_hierarchy() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::find_slider -// Access: Public -// Description: Returns the slider with the indicated name, or NULL -// if no slider has that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the slider with the indicated name, or NULL if no slider has that + * name. + */ EggSliderData *EggCharacterData:: find_slider(const string &name) const { SlidersByName::const_iterator si; @@ -387,12 +348,10 @@ find_slider(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::make_slider -// Access: Public -// Description: Returns the slider matching the indicated name. If -// no such slider exists already, creates a new one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the slider matching the indicated name. If no such slider exists + * already, creates a new one. + */ EggSliderData *EggCharacterData:: make_slider(const string &name) { SlidersByName::const_iterator si; @@ -409,20 +368,16 @@ make_slider(const string &name) { return slider; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::estimate_db_size -// Access: Public -// Description: Returns the estimated amount of memory, in megabytes, -// that will be required to perform the do_reparent() -// operation. This is used mainly be EggCharacterDb to -// decide up front whether to store this data in-RAM or -// on-disk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the estimated amount of memory, in megabytes, that will be required + * to perform the do_reparent() operation. This is used mainly be + * EggCharacterDb to decide up front whether to store this data in-RAM or on- + * disk. + */ size_t EggCharacterData:: estimate_db_size() const { - // Count how much memory we will need to store the interim - // transforms. This is models * joints * frames * 3 * - // sizeof(LMatrix4d). + // Count how much memory we will need to store the interim transforms. This + // is models * joints * frames * 3 * sizeof(LMatrix4d). size_t mj_frames = 0; Models::const_iterator mi; for (mi = _models.begin(); mi != _models.end(); ++mi) { @@ -431,19 +386,16 @@ estimate_db_size() const { mj_frames += num_frames * _joints.size(); } - // We do this operation a bit carefully, to guard against integer - // overflow. + // We do this operation a bit carefully, to guard against integer overflow. size_t mb_needed = ((mj_frames * 3 / 1024) * sizeof(LMatrix4d)) / 1024; return mb_needed; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterData::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggCharacterData:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/eggcharbase/eggCharacterData.h b/pandatool/src/eggcharbase/eggCharacterData.h index c702d67b2d..d4b7125487 100644 --- a/pandatool/src/eggcharbase/eggCharacterData.h +++ b/pandatool/src/eggcharbase/eggCharacterData.h @@ -1,16 +1,15 @@ -// Filename: eggCharacterData.h -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterData.h + * @author drose + * @date 2001-02-23 + */ #ifndef EGGCHARACTERDATA_H #define EGGCHARACTERDATA_H @@ -30,33 +29,26 @@ class EggCharacterCollection; class EggSliderData; class EggCharacterDb; -//////////////////////////////////////////////////////////////////// -// Class : EggCharacterData -// Description : Represents a single character, as read and collected -// from several models and animation files. This -// contains a hierarchy of EggJointData nodes -// representing the skeleton, as well as a list of -// EggSliderData nodes representing the morph channels -// for the character. -// -// This is very similar to the Character class from -// Panda, in that it's capable of associating -// skeleton-morph animation channels with models and -// calculating the vertex position for each frame. To -// some degree, it duplicates the functionality of -// Character. However, it differs in one fundamental -// principle: it is designed to be a non-real-time -// operation, working directly on the Egg structures as -// they are, instead of first boiling the Egg data into -// native Panda Geom tables for real-time animation. -// Because of this, it is (a) double-precision instead -// of single precision, (b) capable of generating -// modified Egg files, and (c) about a hundred times -// slower than the Panda Character class. -// -// The data in this structure is normally filled in by -// the EggCharacterCollection class. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single character, as read and collected from several models + * and animation files. This contains a hierarchy of EggJointData nodes + * representing the skeleton, as well as a list of EggSliderData nodes + * representing the morph channels for the character. + * + * This is very similar to the Character class from Panda, in that it's + * capable of associating skeleton-morph animation channels with models and + * calculating the vertex position for each frame. To some degree, it + * duplicates the functionality of Character. However, it differs in one + * fundamental principle: it is designed to be a non-real-time operation, + * working directly on the Egg structures as they are, instead of first + * boiling the Egg data into native Panda Geom tables for real-time animation. + * Because of this, it is (a) double-precision instead of single precision, + * (b) capable of generating modified Egg files, and (c) about a hundred times + * slower than the Panda Character class. + * + * The data in this structure is normally filled in by the + * EggCharacterCollection class. + */ class EggCharacterData : public Namable { public: EggCharacterData(EggCharacterCollection *collection); @@ -127,5 +119,3 @@ private: #include "eggCharacterData.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggCharacterDb.I b/pandatool/src/eggcharbase/eggCharacterDb.I index 98de13a3e1..f530b93a62 100644 --- a/pandatool/src/eggcharbase/eggCharacterDb.I +++ b/pandatool/src/eggcharbase/eggCharacterDb.I @@ -1,23 +1,19 @@ -// Filename: eggCharacterDb.I -// Created by: drose (05Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterDb.I + * @author drose + * @date 2006-10-05 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::Key::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggCharacterDb::Key:: Key(const EggJointPointer *joint, TableType table_type, int frame) : _joint(joint), @@ -26,11 +22,9 @@ Key(const EggJointPointer *joint, TableType table_type, int frame) : { } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::Key::operator < -// Access: Public -// Description: Provides an arbitrary unique ordering for all keys. -//////////////////////////////////////////////////////////////////// +/** + * Provides an arbitrary unique ordering for all keys. + */ INLINE bool EggCharacterDb::Key:: operator < (const EggCharacterDb::Key &other) const { if (_joint != other._joint) { diff --git a/pandatool/src/eggcharbase/eggCharacterDb.cxx b/pandatool/src/eggcharbase/eggCharacterDb.cxx index edc162097f..e959499b46 100644 --- a/pandatool/src/eggcharbase/eggCharacterDb.cxx +++ b/pandatool/src/eggcharbase/eggCharacterDb.cxx @@ -1,31 +1,26 @@ -// Filename: eggCharacterDb.cxx -// Created by: drose (05Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterDb.cxx + * @author drose + * @date 2006-10-05 + */ #include "eggCharacterDb.h" #include "eggCharacterData.h" -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::Constructor -// Access: Public -// Description: Constructs a database for storing the interim work -// for the indicated EggCharacterData. The parameter -// max_ram_mb indicates the maximum amount of RAM (in -// MB) that the database should consume; if it the -// database would roughly fit within this limit, it will -// be stored in RAM; otherwise, it will be written to -// disk (if Berkeley DB is available). -//////////////////////////////////////////////////////////////////// +/** + * Constructs a database for storing the interim work for the indicated + * EggCharacterData. The parameter max_ram_mb indicates the maximum amount of + * RAM (in MB) that the database should consume; if it the database would + * roughly fit within this limit, it will be stored in RAM; otherwise, it will + * be written to disk (if Berkeley DB is available). + */ EggCharacterDb:: EggCharacterDb() { /* @@ -44,16 +39,14 @@ EggCharacterDb() { */ } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterDb:: ~EggCharacterDb() { /* #ifdef HAVE_BDB - if (_db != (Db *)NULL){ + if (_db != (Db *)NULL){ _db->close(0); delete _db; _db = NULL; @@ -66,14 +59,11 @@ EggCharacterDb:: */ } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::get_matrix -// Access: Public -// Description: Looks up the data for the indicated joint, type, and -// frame, and fills it in result (and returns true) if -// it is found. Returns false if this data has not been -// stored in the database. -//////////////////////////////////////////////////////////////////// +/** + * Looks up the data for the indicated joint, type, and frame, and fills it in + * result (and returns true) if it is found. Returns false if this data has + * not been stored in the database. + */ bool EggCharacterDb:: get_matrix(const EggJointPointer *joint, TableType type, int frame, LMatrix4d &mat) const { @@ -81,7 +71,7 @@ get_matrix(const EggJointPointer *joint, TableType type, /* #ifdef HAVE_BDB - if (_db != (Db *)NULL){ + if (_db != (Db *)NULL){ Dbt db_key(&key, sizeof(Key)); Dbt db_data(&mat, sizeof(LMatrix4d)); db_data.set_ulen(sizeof(LMatrix4d)); @@ -107,15 +97,11 @@ get_matrix(const EggJointPointer *joint, TableType type, return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterDb::set_matrix -// Access: Public -// Description: Stores the matrix for the indicated joint, type, and -// frame in the database. It is an error to call this -// more than once for any given key combination (not for -// any technical reason, but because we don't expect -// this to happen). -//////////////////////////////////////////////////////////////////// +/** + * Stores the matrix for the indicated joint, type, and frame in the database. + * It is an error to call this more than once for any given key combination + * (not for any technical reason, but because we don't expect this to happen). + */ void EggCharacterDb:: set_matrix(const EggJointPointer *joint, TableType type, int frame, const LMatrix4d &mat) { @@ -123,7 +109,7 @@ set_matrix(const EggJointPointer *joint, TableType type, /* #ifdef HAVE_BDB - if (_db != (Db *)NULL){ + if (_db != (Db *)NULL){ Dbt db_key(&key, sizeof(Key)); Dbt db_data((void *)&mat, sizeof(LMatrix4d)); int result = _db->put(NULL, &db_key, &db_data, DB_NOOVERWRITE); diff --git a/pandatool/src/eggcharbase/eggCharacterDb.h b/pandatool/src/eggcharbase/eggCharacterDb.h index 439ec503ae..037367dc8b 100644 --- a/pandatool/src/eggcharbase/eggCharacterDb.h +++ b/pandatool/src/eggcharbase/eggCharacterDb.h @@ -1,16 +1,15 @@ -// Filename: eggCharacterDb.h -// Created by: drose (05Oct06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterDb.h + * @author drose + * @date 2006-10-05 + */ #ifndef EGGCHARACTERDB_H #define EGGCHARACTERDB_H @@ -21,8 +20,8 @@ /* #ifdef HAVE_BDB -// Apparently, we have to define this to make db_cxx files include the -// modern header files. +// Apparently, we have to define this to make db_cxx files include the modern +// header files. #define HAVE_CXX_STDHEADERS 1 #include @@ -31,16 +30,13 @@ class EggJointPointer; -//////////////////////////////////////////////////////////////////// -// Class : EggCharacterDb -// Description : This class is used during joint optimization or -// restructuring to store the table of interim joint -// computations. -// -// That is to say, this class provides an temporary data -// store for three tables of matrices per each -// EggJointPointer per frame. -//////////////////////////////////////////////////////////////////// +/** + * This class is used during joint optimization or restructuring to store the + * table of interim joint computations. + * + * That is to say, this class provides an temporary data store for three + * tables of matrices per each EggJointPointer per frame. + */ class EggCharacterDb { public: EggCharacterDb(); @@ -85,5 +81,3 @@ private: #include "eggCharacterDb.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.cxx b/pandatool/src/eggcharbase/eggCharacterFilter.cxx index 88a4b48f7b..aba5834a66 100644 --- a/pandatool/src/eggcharbase/eggCharacterFilter.cxx +++ b/pandatool/src/eggcharbase/eggCharacterFilter.cxx @@ -1,27 +1,24 @@ -// Filename: eggCharacterFilter.cxx -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterFilter.cxx + * @author drose + * @date 2001-02-23 + */ #include "eggCharacterFilter.h" #include "eggCharacterCollection.h" #include "eggCharacterData.h" -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterFilter:: EggCharacterFilter() : EggMultiFilter(false) { _collection = (EggCharacterCollection *)NULL; @@ -29,11 +26,9 @@ EggCharacterFilter() : EggMultiFilter(false) { _force_initial_rest_frame = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCharacterFilter:: ~EggCharacterFilter() { if (_collection != (EggCharacterCollection *)NULL) { @@ -41,11 +36,9 @@ EggCharacterFilter:: } } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::add_fixrest_option -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggCharacterFilter:: add_fixrest_option() { add_option @@ -59,11 +52,9 @@ add_fixrest_option() { } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggCharacterFilter:: post_command_line() { if (_collection == (EggCharacterCollection *)NULL) { @@ -90,17 +81,15 @@ post_command_line() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::write_eggs -// Access: Protected, Virtual -// Description: Writes out all of the egg files in the _eggs vector, -// to the output directory if one is specified, or over -// the input files if -inplace was specified. -//////////////////////////////////////////////////////////////////// +/** + * Writes out all of the egg files in the _eggs vector, to the output + * directory if one is specified, or over the input files if -inplace was + * specified. + */ void EggCharacterFilter:: write_eggs() { - // Optimize (that is, collapse redudant nodes) in all of the - // characters' joint tables before writing them out. + // Optimize (that is, collapse redudant nodes) in all of the characters' + // joint tables before writing them out. int num_characters = _collection->get_num_characters(); for (int i = 0; i < num_characters; i++) { EggCharacterData *char_data = _collection->get_character(i); @@ -110,15 +99,11 @@ write_eggs() { EggMultiFilter::write_eggs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggCharacterFilter::make_collection -// Access: Protected, Virtual -// Description: Allocates and returns a new EggCharacterCollection -// structure. This is primarily intended as a hook so -// derived classes can customize the type of -// EggCharacterCollection object used to represent the -// character information. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new EggCharacterCollection structure. This is + * primarily intended as a hook so derived classes can customize the type of + * EggCharacterCollection object used to represent the character information. + */ EggCharacterCollection *EggCharacterFilter:: make_collection() { return new EggCharacterCollection; diff --git a/pandatool/src/eggcharbase/eggCharacterFilter.h b/pandatool/src/eggcharbase/eggCharacterFilter.h index a3fc98d2b2..c58536fa7c 100644 --- a/pandatool/src/eggcharbase/eggCharacterFilter.h +++ b/pandatool/src/eggcharbase/eggCharacterFilter.h @@ -1,16 +1,15 @@ -// Filename: eggCharacterFilter.h -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCharacterFilter.h + * @author drose + * @date 2001-02-23 + */ #ifndef EGGCHARACTERFILTER_H #define EGGCHARACTERFILTER_H @@ -22,17 +21,14 @@ class EggCharacterData; class EggCharacterCollection; -//////////////////////////////////////////////////////////////////// -// Class : EggCharacterFilter -// Description : This is the base class for a family of programs that -// operate on a number of character models and their -// associated animation files together. It reads in a -// number of egg files, any combination of model files -// or character files which must all represent the same -// character skeleton, and maintains a single hierarchy -// of joints and sliders that may be operated on before -// writing the files back out. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a family of programs that operate on a number of + * character models and their associated animation files together. It reads + * in a number of egg files, any combination of model files or character files + * which must all represent the same character skeleton, and maintains a + * single hierarchy of joints and sliders that may be operated on before + * writing the files back out. + */ class EggCharacterFilter : public EggMultiFilter { public: EggCharacterFilter(); @@ -51,5 +47,3 @@ protected: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggComponentData.I b/pandatool/src/eggcharbase/eggComponentData.I index 1db4623639..f706ab4b5a 100644 --- a/pandatool/src/eggcharbase/eggComponentData.I +++ b/pandatool/src/eggcharbase/eggComponentData.I @@ -1,40 +1,31 @@ -// Filename: eggComponentData.I -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComponentData.I + * @author drose + * @date 2001-02-26 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::get_num_models -// Access: Public -// Description: Returns the maximum number of back pointers this -// component may have. The component may store a back -// pointer for models indexed 0 .. num_models - -// 1. You must call has_model() on each model -// index to confirm whether a particular model in that -// range has a back pointer. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum number of back pointers this component may have. The + * component may store a back pointer for models indexed 0 .. num_models - 1. + * You must call has_model() on each model index to confirm whether a + * particular model in that range has a back pointer. + */ INLINE int EggComponentData:: get_num_models() const { return _back_pointers.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::has_model -// Access: Public -// Description: Returns true if the component has a back pointer to -// an egg file somewhere for the indicated model, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the component has a back pointer to an egg file somewhere + * for the indicated model, false otherwise. + */ INLINE bool EggComponentData:: has_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { @@ -43,12 +34,10 @@ has_model(int model_index) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::get_model -// Access: Public -// Description: Returns the back pointer to an egg file for the -// indicated model if it exists, or NULL if it does not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the back pointer to an egg file for the indicated model if it + * exists, or NULL if it does not. + */ INLINE EggBackPointer *EggComponentData:: get_model(int model_index) const { if (model_index >= 0 && model_index < (int)_back_pointers.size()) { diff --git a/pandatool/src/eggcharbase/eggComponentData.cxx b/pandatool/src/eggcharbase/eggComponentData.cxx index f65abcc14d..ceea3582a7 100644 --- a/pandatool/src/eggcharbase/eggComponentData.cxx +++ b/pandatool/src/eggcharbase/eggComponentData.cxx @@ -1,16 +1,15 @@ -// Filename: eggComponentData.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComponentData.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggComponentData.h" #include "eggBackPointer.h" @@ -21,11 +20,9 @@ TypeHandle EggComponentData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggComponentData:: EggComponentData(EggCharacterCollection *collection, EggCharacterData *char_data) : @@ -34,11 +31,9 @@ EggComponentData(EggCharacterCollection *collection, { } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggComponentData:: ~EggComponentData() { BackPointers::iterator bpi; @@ -50,16 +45,13 @@ EggComponentData:: } } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::add_name -// Access: Public -// Description: Adds the indicated name to the set of names that this -// component can be identified with. If this is the -// first name added, it becomes the primary name of the -// component; later names added do not replace the -// primary name, but do get added to the list of names -// that will be accepted by matched_name(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated name to the set of names that this component can be + * identified with. If this is the first name added, it becomes the primary + * name of the component; later names added do not replace the primary name, + * but do get added to the list of names that will be accepted by + * matched_name(). + */ void EggComponentData:: add_name(const string &name, NameUniquifier &uniquifier) { if (_names.insert(name).second) { @@ -74,13 +66,10 @@ add_name(const string &name, NameUniquifier &uniquifier) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::matches_name -// Access: Public -// Description: Returns true if the indicated name matches any name -// that was ever matched with this particular joint, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name matches any name that was ever matched + * with this particular joint, false otherwise. + */ bool EggComponentData:: matches_name(const string &name) const { if (name == get_name()) { @@ -89,12 +78,10 @@ matches_name(const string &name) const { return (_names.find(name) != _names.end()); } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::get_num_frames -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular component in the indicated model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular component in + * the indicated model. + */ int EggComponentData:: get_num_frames(int model_index) const { EggBackPointer *back = get_model(model_index); @@ -104,13 +91,10 @@ get_num_frames(int model_index) const { return back->get_num_frames(); } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::extend_to -// Access: Public, Virtual -// Description: Extends the number of frames in the indicated model -// (presumably an animation table model) to the given -// number. -//////////////////////////////////////////////////////////////////// +/** + * Extends the number of frames in the indicated model (presumably an + * animation table model) to the given number. + */ void EggComponentData:: extend_to(int model_index, int num_frames) const { EggBackPointer *back = get_model(model_index); @@ -118,12 +102,10 @@ extend_to(int model_index, int num_frames) const { back->extend_to(num_frames); } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::get_frame_rate -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular component in the indicated model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular component in + * the indicated model. + */ double EggComponentData:: get_frame_rate(int model_index) const { EggBackPointer *back = get_model(model_index); @@ -133,12 +115,9 @@ get_frame_rate(int model_index) const { return back->get_frame_rate(); } -//////////////////////////////////////////////////////////////////// -// Function: EggComponentData::set_model -// Access: Public -// Description: Sets the back_pointer associated with the given -// model_index. -//////////////////////////////////////////////////////////////////// +/** + * Sets the back_pointer associated with the given model_index. + */ void EggComponentData:: set_model(int model_index, EggBackPointer *back) { while ((int)_back_pointers.size() <= model_index) { diff --git a/pandatool/src/eggcharbase/eggComponentData.h b/pandatool/src/eggcharbase/eggComponentData.h index 285d1f45e0..4445d51fe1 100644 --- a/pandatool/src/eggcharbase/eggComponentData.h +++ b/pandatool/src/eggcharbase/eggComponentData.h @@ -1,16 +1,15 @@ -// Filename: eggComponentData.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggComponentData.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGCOMPONENTDATA_H #define EGGCOMPONENTDATA_H @@ -26,14 +25,12 @@ class EggCharacterData; class EggBackPointer; class NameUniquifier; -//////////////////////////////////////////////////////////////////// -// Class : EggComponentData -// Description : This is the base class of both EggJointData and -// EggSliderData. It represents a single component of a -// character, either a joint or a slider, along with -// back pointers to the references to this component in -// all model and animation egg files read. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class of both EggJointData and EggSliderData. It + * represents a single component of a character, either a joint or a slider, + * along with back pointers to the references to this component in all model + * and animation egg files read. + */ class EggComponentData : public EggObject, public Namable { public: EggComponentData(EggCharacterCollection *collection, @@ -57,8 +54,8 @@ public: protected: - // This points back to all the egg structures that reference this - // particular table or slider. + // This points back to all the egg structures that reference this particular + // table or slider. typedef pvector BackPointers; BackPointers _back_pointers; @@ -90,5 +87,3 @@ private: #include "eggComponentData.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggJointData.I b/pandatool/src/eggcharbase/eggJointData.I index 52cdfc815f..c6349809ae 100644 --- a/pandatool/src/eggcharbase/eggJointData.I +++ b/pandatool/src/eggcharbase/eggJointData.I @@ -1,55 +1,45 @@ -// Filename: eggJointData.I -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointData.I + * @author drose + * @date 2001-02-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_parent -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggJointData *EggJointData:: get_parent() const { return _parent; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_num_children -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE int EggJointData:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_child -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE EggJointData *EggJointData:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), (EggJointData *)NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::find_joint -// Access: Public -// Description: Returns the first descendent joint found with the -// indicated name, or NULL if no joint has that name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first descendent joint found with the indicated name, or NULL + * if no joint has that name. + */ INLINE EggJointData *EggJointData:: find_joint(const string &name) { EggJointData *joint = find_joint_exact(name); @@ -60,54 +50,43 @@ find_joint(const string &name) { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::has_rest_frame -// Access: Public -// Description: Returns true if the joint knows its rest frame, false -// otherwise. In general, this will be true as long as -// the joint is included in at least one model file, or -// false if it appears only in animation files. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the joint knows its rest frame, false otherwise. In + * general, this will be true as long as the joint is included in at least one + * model file, or false if it appears only in animation files. + */ INLINE bool EggJointData:: has_rest_frame() const { return _has_rest_frame; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::rest_frames_differ -// Access: Public -// Description: Returns true if the rest frames for different models -// differ in their initial value. This is not -// technically an error, but it is unusual enough to be -// suspicious. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the rest frames for different models differ in their + * initial value. This is not technically an error, but it is unusual enough + * to be suspicious. + */ INLINE bool EggJointData:: rest_frames_differ() const { return _rest_frames_differ; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_rest_frame -// Access: Public -// Description: Returns the rest frame of the joint. This is the -// matrix value that appears for the joint in each model -// file; it should be the same transform in each model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the rest frame of the joint. This is the matrix value that appears + * for the joint in each model file; it should be the same transform in each + * model. + */ INLINE const LMatrix4d &EggJointData:: get_rest_frame() const { nassertr(has_rest_frame(), LMatrix4d::ident_mat()); return _rest_frame; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::reparent_to -// Access: Public -// Description: Indicates an intention to change the parent of this -// joint to the indicated joint, or NULL to remove it -// from the hierarchy. The joint is not reparented -// immediately, but rather all of the joints are -// reparented at once when do_reparent() is called. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an intention to change the parent of this joint to the indicated + * joint, or NULL to remove it from the hierarchy. The joint is not + * reparented immediately, but rather all of the joints are reparented at once + * when do_reparent() is called. + */ INLINE void EggJointData:: reparent_to(EggJointData *new_parent) { _new_parent = new_parent; diff --git a/pandatool/src/eggcharbase/eggJointData.cxx b/pandatool/src/eggcharbase/eggJointData.cxx index 79966d8148..8104ee1ad7 100644 --- a/pandatool/src/eggcharbase/eggJointData.cxx +++ b/pandatool/src/eggcharbase/eggJointData.cxx @@ -1,16 +1,15 @@ -// Filename: eggJointData.cxx -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointData.cxx + * @author drose + * @date 2001-02-23 + */ #include "eggJointData.h" #include "eggJointNodePointer.h" @@ -26,11 +25,9 @@ TypeHandle EggJointData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggJointData:: EggJointData(EggCharacterCollection *collection, EggCharacterData *char_data) : @@ -42,13 +39,10 @@ EggJointData(EggCharacterCollection *collection, _rest_frames_differ = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_frame -// Access: Public -// Description: Returns the local transform matrix corresponding to -// this joint position in the nth frame in the indicated -// model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local transform matrix corresponding to this joint position in + * the nth frame in the indicated model. + */ LMatrix4d EggJointData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); @@ -62,13 +56,10 @@ get_frame(int model_index, int n) const { return joint->get_frame(n); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_net_frame -// Access: Public -// Description: Returns the complete transform from the root -// corresponding to this joint position in the nth frame -// in the indicated model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete transform from the root corresponding to this joint + * position in the nth frame in the indicated model. + */ LMatrix4d EggJointData:: get_net_frame(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); @@ -78,7 +69,7 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { EggJointPointer *joint; DCAST_INTO_R(joint, back, LMatrix4d::ident_mat()); - + LMatrix4d mat; if (!db.get_matrix(joint, EggCharacterDb::TT_net_frame, n, mat)) { // Compute this frame's net, and stuff it in. @@ -92,11 +83,9 @@ get_net_frame(int model_index, int n, EggCharacterDb &db) const { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_net_frame_inv -// Access: Public -// Description: Returns the inverse of get_net_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of get_net_frame(). + */ LMatrix4d EggJointData:: get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const { EggBackPointer *back = get_model(model_index); @@ -118,15 +107,12 @@ get_net_frame_inv(int model_index, int n, EggCharacterDb &db) const { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::force_initial_rest_frame -// Access: Public -// Description: Forces all of the joints to have the same rest frame -// value as the first joint read in. This is a drastic -// way to repair models whose rest frame values are -// completely bogus, but should not be performed on -// models that are otherwise correct. -//////////////////////////////////////////////////////////////////// +/** + * Forces all of the joints to have the same rest frame value as the first + * joint read in. This is a drastic way to repair models whose rest frame + * values are completely bogus, but should not be performed on models that are + * otherwise correct. + */ void EggJointData:: force_initial_rest_frame() { if (!has_rest_frame()) { @@ -145,13 +131,10 @@ force_initial_rest_frame() { _rest_frames_differ = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::move_vertices_to -// Access: Public -// Description: Moves the vertices assigned to this joint into the -// indicated joint, without changing their weight -// assignments. -//////////////////////////////////////////////////////////////////// +/** + * Moves the vertices assigned to this joint into the indicated joint, without + * changing their weight assignments. + */ void EggJointData:: move_vertices_to(EggJointData *new_owner) { int num_models = get_num_models(); @@ -176,28 +159,24 @@ move_vertices_to(EggJointData *new_owner) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::score_reparent_to -// Access: Public -// Description: Computes a score >= 0 reflecting the similarity of -// the current joint's animation (in world space) to -// that of the indicated potential parent joint (in -// world space). The lower the number, the more similar -// the motion, and the more suitable is the proposed -// parent-child relationship. Returns -1 if there is an -// error. -//////////////////////////////////////////////////////////////////// +/** + * Computes a score >= 0 reflecting the similarity of the current joint's + * animation (in world space) to that of the indicated potential parent joint + * (in world space). The lower the number, the more similar the motion, and + * the more suitable is the proposed parent-child relationship. Returns -1 if + * there is an error. + */ int EggJointData:: score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { if (!FFTCompressor::is_compression_available()) { - // If we don't have compression compiled in, we can't meaningfully - // score the joints. + // If we don't have compression compiled in, we can't meaningfully score + // the joints. return -1; } - // First, build up a big array of the new transforms this joint - // would receive in all frames of all models, were it reparented to - // the indicated joint. + // First, build up a big array of the new transforms this joint would + // receive in all frames of all models, were it reparented to the indicated + // joint. vector_stdfloat i, j, k, a, b, c, x, y, z; pvector hprs; int num_rows = 0; @@ -215,18 +194,18 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { if (_parent == new_parent) { // We already have this parent. transform = LMatrix4d::ident_mat(); - + } else if (_parent == (EggJointData *)NULL) { // We are moving from outside the joint hierarchy to within it. transform = new_parent->get_net_frame_inv(model_index, n, db); - + } else if (new_parent == (EggJointData *)NULL) { // We are moving from within the hierarchy to outside it. transform = _parent->get_net_frame(model_index, n, db); - + } else { // We are changing parents within the hierarchy. - transform = + transform = _parent->get_net_frame(model_index, n, db) * new_parent->get_net_frame_inv(model_index, n, db); } @@ -258,8 +237,8 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { } // Now, we derive a score, by the simple expedient of using the - // FFTCompressor to compress the generated transforms, and measuring - // the length of the resulting bitstream. + // FFTCompressor to compress the generated transforms, and measuring the + // length of the resulting bitstream. FFTCompressor compressor; Datagram dg; compressor.write_reals(dg, &i[0], num_rows); @@ -278,9 +257,8 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { return dg.get_length(); #else - // The FFTCompressor does minimal run-length encoding, but to really - // get an accurate measure we should zlib-compress the resulting - // stream. + // The FFTCompressor does minimal run-length encoding, but to really get an + // accurate measure we should zlib-compress the resulting stream. ostringstream sstr; OCompressStream zstr(&sstr, false); zstr.write((const char *)dg.get_data(), dg.get_length()); @@ -289,13 +267,10 @@ score_reparent_to(EggJointData *new_parent, EggCharacterDb &db) { #endif } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_rebuild_all -// Access: Public -// Description: Calls do_rebuild() on all models, and recursively on -// all joints at this node and below. Returns true if -// all models returned true, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Calls do_rebuild() on all models, and recursively on all joints at this + * node and below. Returns true if all models returned true, false otherwise. + */ bool EggJointData:: do_rebuild_all(EggCharacterDb &db) { bool all_ok = true; @@ -323,12 +298,10 @@ do_rebuild_all(EggCharacterDb &db) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::optimize -// Access: Public -// Description: Calls optimize() on all models, and recursively on -// all joints at this node and below. -//////////////////////////////////////////////////////////////////// +/** + * Calls optimize() on all models, and recursively on all joints at this node + * and below. + */ void EggJointData:: optimize() { BackPointers::iterator bpi; @@ -348,12 +321,10 @@ optimize() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::expose -// Access: Public -// Description: Calls expose() on all models for this joint, but does -// not recurse downwards. -//////////////////////////////////////////////////////////////////// +/** + * Calls expose() on all models for this joint, but does not recurse + * downwards. + */ void EggJointData:: expose(EggGroup::DCSType dcs_type) { BackPointers::iterator bpi; @@ -367,12 +338,10 @@ expose(EggGroup::DCSType dcs_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::zero_channels -// Access: Public -// Description: Calls zero_channels() on all models for this joint, -// but does not recurse downwards. -//////////////////////////////////////////////////////////////////// +/** + * Calls zero_channels() on all models for this joint, but does not recurse + * downwards. + */ void EggJointData:: zero_channels(const string &components) { BackPointers::iterator bpi; @@ -386,12 +355,10 @@ zero_channels(const string &components) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::quantize_channels -// Access: Public -// Description: Calls quantize_channels() on all models for this joint, -// and then recurses downwards to all joints below. -//////////////////////////////////////////////////////////////////// +/** + * Calls quantize_channels() on all models for this joint, and then recurses + * downwards to all joints below. + */ void EggJointData:: quantize_channels(const string &components, double quantum) { BackPointers::iterator bpi; @@ -411,14 +378,11 @@ quantize_channels(const string &components, double quantum) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::apply_default_pose -// Access: Public -// Description: Applies the pose from the indicated frame of the -// indicated source model_index as the initial pose for -// this joint, and does this recursively on all joints -// below. -//////////////////////////////////////////////////////////////////// +/** + * Applies the pose from the indicated frame of the indicated source + * model_index as the initial pose for this joint, and does this recursively + * on all joints below. + */ void EggJointData:: apply_default_pose(int source_model, int frame) { if (has_model(source_model)) { @@ -442,12 +406,9 @@ apply_default_pose(int source_model, int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::add_back_pointer -// Access: Public, Virtual -// Description: Adds the indicated model joint or anim table to the -// data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated model joint or anim table to the data. + */ void EggJointData:: add_back_pointer(int model_index, EggObject *egg_object) { nassertv(egg_object != (EggObject *)NULL); @@ -460,9 +421,8 @@ add_back_pointer(int model_index, EggObject *egg_object) { _has_rest_frame = true; } else { - // If this new node doesn't come within an acceptable tolerance - // of our first reading of this joint's rest frame, set a - // warning flag. + // If this new node doesn't come within an acceptable tolerance of our + // first reading of this joint's rest frame, set a warning flag. if (!_rest_frame.almost_equal(joint->get_frame(0), 0.0001)) { _rest_frames_differ = true; } @@ -478,11 +438,9 @@ add_back_pointer(int model_index, EggObject *egg_object) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggJointData:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -504,34 +462,27 @@ write(ostream &out, int indent_level) const { indent(out, indent_level) << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_begin_reparent -// Access: Protected -// Description: Clears out the _children vector in preparation for -// refilling it from the _new_parent information. -//////////////////////////////////////////////////////////////////// +/** + * Clears out the _children vector in preparation for refilling it from the + * _new_parent information. + */ void EggJointData:: do_begin_reparent() { _got_new_parent_depth = false; _children.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::calc_new_parent_depth -// Access: Protected -// Description: Calculates the number of joints above this joint in its -// intended position, as specified by a recent call to -// reparent_to(), and also checks for a cycle in the new -// parent chain. Returns true if a cycle is detected, -// and false otherwise. If a cycle is not detected, -// _new_parent_depth can be consulted for the depth in -// the new hierarchy. -// -// This is used by EggCharacterData::do_reparent() to -// determine the order in which to apply the reparent -// operations. It should be called after -// do_begin_reparent(). -//////////////////////////////////////////////////////////////////// +/** + * Calculates the number of joints above this joint in its intended position, + * as specified by a recent call to reparent_to(), and also checks for a cycle + * in the new parent chain. Returns true if a cycle is detected, and false + * otherwise. If a cycle is not detected, _new_parent_depth can be consulted + * for the depth in the new hierarchy. + * + * This is used by EggCharacterData::do_reparent() to determine the order in + * which to apply the reparent operations. It should be called after + * do_begin_reparent(). + */ bool EggJointData:: calc_new_parent_depth(pset &chain) { if (_got_new_parent_depth) { @@ -552,42 +503,35 @@ calc_new_parent_depth(pset &chain) { return cycle; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_begin_compute_reparent -// Access: Protected -// Description: Eliminates any cached values before beginning a walk -// through all the joints for do_compute_reparent(), for -// a given model/frame. -//////////////////////////////////////////////////////////////////// +/** + * Eliminates any cached values before beginning a walk through all the joints + * for do_compute_reparent(), for a given model/frame. + */ void EggJointData:: -do_begin_compute_reparent() { +do_begin_compute_reparent() { _got_new_net_frame = false; _got_new_net_frame_inv = false; _computed_reparent = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_compute_reparent -// Access: Protected -// Description: Prepares the reparent operation by computing a new -// transform for each frame of each model, designed to -// keep the net transform the same when the joint is -// moved to its new parent. Returns true on success, -// false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Prepares the reparent operation by computing a new transform for each frame + * of each model, designed to keep the net transform the same when the joint + * is moved to its new parent. Returns true on success, false on failure. + */ bool EggJointData:: do_compute_reparent(int model_index, int n, EggCharacterDb &db) { if (_computed_reparent) { - // We've already done this joint. This is possible because we - // have to recursively compute joints upwards, so we might visit - // the same joint more than once. + // We've already done this joint. This is possible because we have to + // recursively compute joints upwards, so we might visit the same joint + // more than once. return _computed_ok; } _computed_reparent = true; if (_parent == _new_parent) { - // Trivial (and most common) case: we are not moving the joint. - // No recomputation necessary. + // Trivial (and most common) case: we are not moving the joint. No + // recomputation necessary. _computed_ok = true; return true; } @@ -613,7 +557,7 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { } else { // We are changing parents within the hierarchy. - transform = + transform = _parent->get_net_frame(model_index, n, db) * _new_parent->get_new_net_frame_inv(model_index, n, db); } @@ -625,13 +569,10 @@ do_compute_reparent(int model_index, int n, EggCharacterDb &db) { return _computed_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_joint_rebuild -// Access: Protected -// Description: Calls do_rebuild() on the joint for the indicated -// model index. Returns true on success, false on -// failure (false shouldn't be possible). -//////////////////////////////////////////////////////////////////// +/** + * Calls do_rebuild() on the joint for the indicated model index. Returns + * true on success, false on failure (false shouldn't be possible). + */ bool EggJointData:: do_joint_rebuild(int model_index, EggCharacterDb &db) { bool all_ok = true; @@ -640,7 +581,7 @@ do_joint_rebuild(int model_index, EggCharacterDb &db) { if (_new_parent != NULL && _new_parent->has_model(model_index)) { DCAST_INTO_R(parent_joint, _new_parent->get_model(model_index), false); } - + if (has_model(model_index)) { EggJointPointer *joint; DCAST_INTO_R(joint, get_model(model_index), false); @@ -652,13 +593,10 @@ do_joint_rebuild(int model_index, EggCharacterDb &db) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::do_finish_reparent -// Access: Protected -// Description: Performs the actual reparenting operation -// by removing all of the old children and replacing -// them with the set of new children. -//////////////////////////////////////////////////////////////////// +/** + * Performs the actual reparenting operation by removing all of the old + * children and replacing them with the set of new children. + */ void EggJointData:: do_finish_reparent() { int num_models = get_num_models(); @@ -681,13 +619,10 @@ do_finish_reparent() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::make_new_joint -// Access: Private -// Description: Creates a new joint as a child of this joint and -// returns it. This is intended to be called only from -// EggCharacterData::make_new_joint(). -//////////////////////////////////////////////////////////////////// +/** + * Creates a new joint as a child of this joint and returns it. This is + * intended to be called only from EggCharacterData::make_new_joint(). + */ EggJointData *EggJointData:: make_new_joint(const string &name) { EggJointData *child = new EggJointData(_collection, _char_data); @@ -710,13 +645,10 @@ make_new_joint(const string &name) { return child; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::find_joint_exact -// Access: Private -// Description: The recursive implementation of find_joint, this -// flavor searches recursively for an exact match of the -// preferred joint name. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_joint, this flavor searches + * recursively for an exact match of the preferred joint name. + */ EggJointData *EggJointData:: find_joint_exact(const string &name) { Children::const_iterator ci; @@ -734,12 +666,10 @@ find_joint_exact(const string &name) { return (EggJointData *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::find_joint_matches -// Access: Private -// Description: The recursive implementation of find_joint, this -// flavor searches recursively for any acceptable match. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of find_joint, this flavor searches + * recursively for any acceptable match. + */ EggJointData *EggJointData:: find_joint_matches(const string &name) { Children::const_iterator ci; @@ -757,14 +687,11 @@ find_joint_matches(const string &name) { return (EggJointData *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::is_new_ancestor -// Access: Protected -// Description: Returns true if this joint is an ancestor of the -// indicated joint, in the "new" hierarchy (that is, the -// one defined by _new_parent, as set by reparent_to() -// before do_finish_reparent() is called). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this joint is an ancestor of the indicated joint, in the + * "new" hierarchy (that is, the one defined by _new_parent, as set by + * reparent_to() before do_finish_reparent() is called). + */ bool EggJointData:: is_new_ancestor(EggJointData *child) const { if (child == this) { @@ -778,14 +705,11 @@ is_new_ancestor(EggJointData *child) const { return is_new_ancestor(child->_new_parent); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_new_net_frame -// Access: Private -// Description: Similar to get_net_frame(), but computed for the -// prospective new parentage of the node, before -// do_finish_reparent() is called. This is generally -// useful only when called within do_compute_reparent(). -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_net_frame(), but computed for the prospective new parentage + * of the node, before do_finish_reparent() is called. This is generally + * useful only when called within do_compute_reparent(). + */ const LMatrix4d &EggJointData:: get_new_net_frame(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame) { @@ -798,11 +722,9 @@ get_new_net_frame(int model_index, int n, EggCharacterDb &db) { return _new_net_frame; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_new_net_frame_inv -// Access: Private -// Description: Returns the inverse of get_new_net_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the inverse of get_new_net_frame(). + */ const LMatrix4d &EggJointData:: get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db) { if (!_got_new_net_frame_inv) { @@ -815,14 +737,11 @@ get_new_net_frame_inv(int model_index, int n, EggCharacterDb &db) { return _new_net_frame_inv; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointData::get_new_frame -// Access: Private -// Description: Returns the local transform matrix corresponding to -// this joint position in the nth frame in the indicated -// model, as it will be when do_finish_reparent() is -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the local transform matrix corresponding to this joint position in + * the nth frame in the indicated model, as it will be when + * do_finish_reparent() is called. + */ LMatrix4d EggJointData:: get_new_frame(int model_index, int n, EggCharacterDb &db) { do_compute_reparent(model_index, n, db); diff --git a/pandatool/src/eggcharbase/eggJointData.h b/pandatool/src/eggcharbase/eggJointData.h index c5d9e6cc5e..aff56459cc 100644 --- a/pandatool/src/eggcharbase/eggJointData.h +++ b/pandatool/src/eggcharbase/eggJointData.h @@ -1,16 +1,15 @@ -// Filename: eggJointData.h -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointData.h + * @author drose + * @date 2001-02-23 + */ #ifndef EGGJOINTDATA_H #define EGGJOINTDATA_H @@ -23,14 +22,12 @@ class EggCharacterDb; -//////////////////////////////////////////////////////////////////// -// Class : EggJointData -// Description : This is one node of a hierarchy of EggJointData -// nodes, each of which represents a single joint of the -// character hierarchy across all loaded files: the -// various models, the LOD's of each model, and the -// various animation channel files. -//////////////////////////////////////////////////////////////////// +/** + * This is one node of a hierarchy of EggJointData nodes, each of which + * represents a single joint of the character hierarchy across all loaded + * files: the various models, the LOD's of each model, and the various + * animation channel files. + */ class EggJointData : public EggComponentData { public: EggJointData(EggCharacterCollection *collection, diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.cxx b/pandatool/src/eggcharbase/eggJointNodePointer.cxx index aebc02f830..3ebc85c3d4 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.cxx +++ b/pandatool/src/eggcharbase/eggJointNodePointer.cxx @@ -1,16 +1,15 @@ -// Filename: eggJointNodePointer.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointNodePointer.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggJointNodePointer.h" @@ -22,81 +21,66 @@ TypeHandle EggJointNodePointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggJointNodePointer:: EggJointNodePointer(EggObject *object) { _joint = DCAST(EggGroup, object); if (_joint != (EggGroup *)NULL && _joint->is_joint()) { - // Quietly insist that the joint has a transform, for neatness. If - // it does not, give it the identity transform. + // Quietly insist that the joint has a transform, for neatness. If it + // does not, give it the identity transform. if (!_joint->has_transform()) { _joint->set_transform3d(LMatrix4d::ident_mat()); } } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::get_num_frames -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular joint. -// -// In the case of a EggJointNodePointer, which just -// stores a pointer to a entry for a character -// model (not an animation table), there is always -// exactly one frame: the rest pose. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular joint. + * + * In the case of a EggJointNodePointer, which just stores a pointer to a + * entry for a character model (not an animation table), there is + * always exactly one frame: the rest pose. + */ int EggJointNodePointer:: get_num_frames() const { return 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::get_frame -// Access: Public, Virtual -// Description: Returns the transform matrix corresponding to this -// joint position in the nth frame. -// -// In the case of a EggJointNodePointer, which just -// stores a pointer to a entry for a character -// model (not an animation table), there is always -// exactly one frame: the rest pose. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix corresponding to this joint position in the + * nth frame. + * + * In the case of a EggJointNodePointer, which just stores a pointer to a + * entry for a character model (not an animation table), there is + * always exactly one frame: the rest pose. + */ LMatrix4d EggJointNodePointer:: get_frame(int n) const { nassertr(n == 0, LMatrix4d::ident_mat()); return _joint->get_transform3d(); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::set_frame -// Access: Public, Virtual -// Description: Sets the transform matrix corresponding to this -// joint position in the nth frame. -// -// In the case of a EggJointNodePointer, which just -// stores a pointer to a entry for a character -// model (not an animation table), there is always -// exactly one frame: the rest pose. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform matrix corresponding to this joint position in the nth + * frame. + * + * In the case of a EggJointNodePointer, which just stores a pointer to a + * entry for a character model (not an animation table), there is + * always exactly one frame: the rest pose. + */ void EggJointNodePointer:: set_frame(int n, const LMatrix4d &mat) { nassertv(n == 0); _joint->set_transform3d(mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::do_finish_reparent -// Access: Protected -// Description: Performs the actual reparenting operation -// by removing the node from its old parent and -// associating it with its new parent, if any. -//////////////////////////////////////////////////////////////////// +/** + * Performs the actual reparenting operation by removing the node from its old + * parent and associating it with its new parent, if any. + */ void EggJointNodePointer:: do_finish_reparent(EggJointPointer *new_parent) { if (new_parent == (EggJointPointer *)NULL) { @@ -108,8 +92,8 @@ do_finish_reparent(EggJointPointer *new_parent) { } } else { - // Reparent the joint to its new parent (implicitly unparenting it - // from its previous parent). + // Reparent the joint to its new parent (implicitly unparenting it from + // its previous parent). EggJointNodePointer *new_node = DCAST(EggJointNodePointer, new_parent); if (new_node->_joint != _joint->get_parent()) { new_node->_joint->add_child(_joint.p()); @@ -117,12 +101,10 @@ do_finish_reparent(EggJointPointer *new_parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::move_vertices_to -// Access: Public, Virtual -// Description: Moves the vertices assigned to this joint into the -// other joint (which should be of the same type). -//////////////////////////////////////////////////////////////////// +/** + * Moves the vertices assigned to this joint into the other joint (which + * should be of the same type). + */ void EggJointNodePointer:: move_vertices_to(EggJointPointer *new_joint) { if (new_joint == (EggJointPointer *)NULL) { @@ -136,19 +118,16 @@ move_vertices_to(EggJointPointer *new_joint) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::do_rebuild -// Access: Public, Virtual -// Description: Rebuilds the entire table all at once, based on the -// frames added by repeated calls to add_rebuild_frame() -// since the last call to begin_rebuild(). -// -// Until do_rebuild() is called, the animation table is -// not changed. -// -// The return value is true if all frames are -// acceptable, or false if there is some problem. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the entire table all at once, based on the frames added by + * repeated calls to add_rebuild_frame() since the last call to + * begin_rebuild(). + * + * Until do_rebuild() is called, the animation table is not changed. + * + * The return value is true if all frames are acceptable, or false if there is + * some problem. + */ bool EggJointNodePointer:: do_rebuild(EggCharacterDb &db) { LMatrix4d mat; @@ -161,16 +140,14 @@ do_rebuild(EggCharacterDb &db) { // We shouldn't have a frame 1. nassertr(!db.get_matrix(this, EggCharacterDb::TT_rebuild_frame, 1, mat), false); - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::expose -// Access: Public, Virtual -// Description: Flags the joint with the indicated DCS flag so that -// it will be loaded as a separate node in the player. -//////////////////////////////////////////////////////////////////// +/** + * Flags the joint with the indicated DCS flag so that it will be loaded as a + * separate node in the player. + */ void EggJointNodePointer:: expose(EggGroup::DCSType dcs_type) { if (_joint != (EggGroup *)NULL) { @@ -178,13 +155,10 @@ expose(EggGroup::DCSType dcs_type) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::apply_default_pose -// Access: Public, Virtual -// Description: Applies the pose from the indicated frame of the -// indicated source joint as the initial pose for -// this joint. -//////////////////////////////////////////////////////////////////// +/** + * Applies the pose from the indicated frame of the indicated source joint as + * the initial pose for this joint. + */ void EggJointNodePointer:: apply_default_pose(EggJointPointer *source_joint, int frame) { if (_joint != (EggGroup *)NULL) { @@ -199,14 +173,11 @@ apply_default_pose(EggJointPointer *source_joint, int frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::has_vertices -// Access: Public, Virtual -// Description: Returns true if there are any vertices referenced by -// the node this points to, false otherwise. For -// certain kinds of back pointers (e.g. table animation -// entries), this is always false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any vertices referenced by the node this points + * to, false otherwise. For certain kinds of back pointers (e.g. table + * animation entries), this is always false. + */ bool EggJointNodePointer:: has_vertices() const { if (_joint != (EggGroup *)NULL) { @@ -216,12 +187,10 @@ has_vertices() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::make_new_joint -// Access: Public, Virtual -// Description: Creates a new child of the current joint in the -// egg data, and returns a pointer to it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new child of the current joint in the egg data, and returns a + * pointer to it. + */ EggJointPointer *EggJointNodePointer:: make_new_joint(const string &name) { EggGroup *new_joint = new EggGroup(name); @@ -230,11 +199,9 @@ make_new_joint(const string &name) { return new EggJointNodePointer(new_joint); } -//////////////////////////////////////////////////////////////////// -// Function: EggJointNodePointer::set_name -// Access: Public, Virtual -// Description: Applies the indicated name change to the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated name change to the egg file. + */ void EggJointNodePointer:: set_name(const string &name) { _joint->set_name(name); diff --git a/pandatool/src/eggcharbase/eggJointNodePointer.h b/pandatool/src/eggcharbase/eggJointNodePointer.h index b3815f4696..52aacbd042 100644 --- a/pandatool/src/eggcharbase/eggJointNodePointer.h +++ b/pandatool/src/eggcharbase/eggJointNodePointer.h @@ -1,16 +1,15 @@ -// Filename: eggJointNodePointer.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointNodePointer.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGJOINTNODEPOINTER_H #define EGGJOINTNODEPOINTER_H @@ -22,10 +21,9 @@ #include "eggGroup.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : EggJointNodePointer -// Description : This stores a pointer back to a node. -//////////////////////////////////////////////////////////////////// +/** + * This stores a pointer back to a node. + */ class EggJointNodePointer : public EggJointPointer { public: EggJointNodePointer(EggObject *object); @@ -69,5 +67,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggJointPointer.I b/pandatool/src/eggcharbase/eggJointPointer.I index e60fc26835..57bd7cf35b 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.I +++ b/pandatool/src/eggcharbase/eggJointPointer.I @@ -1,14 +1,12 @@ -// Filename: eggJointPointer.I -// Created by: drose (20Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointPointer.I + * @author drose + * @date 2003-07-20 + */ diff --git a/pandatool/src/eggcharbase/eggJointPointer.cxx b/pandatool/src/eggcharbase/eggJointPointer.cxx index 2dee1f0719..350931d635 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.cxx +++ b/pandatool/src/eggcharbase/eggJointPointer.cxx @@ -1,16 +1,15 @@ -// Filename: eggJointPointer.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointPointer.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggJointPointer.h" @@ -18,94 +17,73 @@ TypeHandle EggJointPointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::add_frame -// Access: Public, Virtual -// Description: Appends a new frame onto the end of the data, if -// possible; returns true if not possible, or false -// otherwise (e.g. for a static joint). -//////////////////////////////////////////////////////////////////// +/** + * Appends a new frame onto the end of the data, if possible; returns true if + * not possible, or false otherwise (e.g. for a static joint). + */ bool EggJointPointer:: add_frame(const LMatrix4d &) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::move_vertices_to -// Access: Public, Virtual -// Description: Moves the vertices assigned to this joint into the -// other joint (which should be of the same type). -//////////////////////////////////////////////////////////////////// +/** + * Moves the vertices assigned to this joint into the other joint (which + * should be of the same type). + */ void EggJointPointer:: move_vertices_to(EggJointPointer *) { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::do_rebuild -// Access: Public, Virtual -// Description: Rebuilds the entire table all at once, based on the -// frames added by repeated calls to add_rebuild_frame() -// since the last call to begin_rebuild(). -// -// Until do_rebuild() is called, the animation table is -// not changed. -// -// The return value is true if all frames are -// acceptable, or false if there is some problem. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the entire table all at once, based on the frames added by + * repeated calls to add_rebuild_frame() since the last call to + * begin_rebuild(). + * + * Until do_rebuild() is called, the animation table is not changed. + * + * The return value is true if all frames are acceptable, or false if there is + * some problem. + */ bool EggJointPointer:: do_rebuild(EggCharacterDb &db) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::optimize -// Access: Public, Virtual -// Description: Resets the table before writing to disk so that -// redundant rows (e.g. i { 1 1 1 1 1 1 1 1 }) are -// collapsed out. -//////////////////////////////////////////////////////////////////// +/** + * Resets the table before writing to disk so that redundant rows (e.g. i { 1 + * 1 1 1 1 1 1 1 }) are collapsed out. + */ void EggJointPointer:: optimize() { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::expose -// Access: Public, Virtual -// Description: Flags the joint with the indicated DCS flag so that -// it will be loaded as a separate node in the player. -//////////////////////////////////////////////////////////////////// +/** + * Flags the joint with the indicated DCS flag so that it will be loaded as a + * separate node in the player. + */ void EggJointPointer:: expose(EggGroup::DCSType) { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::zero_channels -// Access: Public, Virtual -// Description: Zeroes out the named components of the transform in -// the animation frames. -//////////////////////////////////////////////////////////////////// +/** + * Zeroes out the named components of the transform in the animation frames. + */ void EggJointPointer:: zero_channels(const string &) { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::quantize_channels -// Access: Public, Virtual -// Description: Rounds the named components of the transform to the -// nearest multiple of quantum. -//////////////////////////////////////////////////////////////////// +/** + * Rounds the named components of the transform to the nearest multiple of + * quantum. + */ void EggJointPointer:: quantize_channels(const string &, double) { } -//////////////////////////////////////////////////////////////////// -// Function: EggJointPointer::apply_default_pose -// Access: Public, Virtual -// Description: Applies the pose from the indicated frame of the -// indicated source joint as the initial pose for -// this joint. -//////////////////////////////////////////////////////////////////// +/** + * Applies the pose from the indicated frame of the indicated source joint as + * the initial pose for this joint. + */ void EggJointPointer:: apply_default_pose(EggJointPointer *source_joint, int frame) { } diff --git a/pandatool/src/eggcharbase/eggJointPointer.h b/pandatool/src/eggcharbase/eggJointPointer.h index a1e566165d..cbb759c9d4 100644 --- a/pandatool/src/eggcharbase/eggJointPointer.h +++ b/pandatool/src/eggcharbase/eggJointPointer.h @@ -1,16 +1,15 @@ -// Filename: eggJointPointer.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggJointPointer.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGJOINTPOINTER_H #define EGGJOINTPOINTER_H @@ -22,15 +21,13 @@ class EggCharacterDb; -//////////////////////////////////////////////////////////////////// -// Class : EggJointPointer -// Description : This is a base class for EggJointNodePointer and -// EggMatrixTablePointer. It stores a back pointer to -// either a entry or an xform
data, and -// thus presents an interface that returns 1-n matrices, -// one for each frame. ( entries, for model -// files, appear the same as one-frame animations.) -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for EggJointNodePointer and EggMatrixTablePointer. It + * stores a back pointer to either a entry or an xform
data, + * and thus presents an interface that returns 1-n matrices, one for each + * frame. ( entries, for model files, appear the same as one-frame + * animations.) + */ class EggJointPointer : public EggBackPointer { public: virtual int get_num_frames() const=0; @@ -72,5 +69,3 @@ private: #include "eggJointPointer.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx index 74612f5c42..c81ae1bd1a 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.cxx @@ -1,16 +1,15 @@ -// Filename: eggMatrixTablePointer.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMatrixTablePointer.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggMatrixTablePointer.h" #include "dcast.h" @@ -20,18 +19,16 @@ TypeHandle EggMatrixTablePointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMatrixTablePointer:: EggMatrixTablePointer(EggObject *object) { _table = DCAST(EggTable, object); if (_table != (EggTable *)NULL) { - // Now search for the child named "xform". This contains the - // actual table data. + // Now search for the child named "xform". This contains the actual table + // data. EggGroupNode::iterator ci; bool found = false; for (ci = _table->begin(); ci != _table->end() && !found; ++ci) { @@ -43,8 +40,8 @@ EggMatrixTablePointer(EggObject *object) { found = true; } else if (child->is_of_type(EggXfmAnimData::get_class_type())) { - // Quietly replace old-style XfmAnim tables with new-style - // XfmSAnim tables. + // Quietly replace old-style XfmAnim tables with new-style XfmSAnim + // tables. PT(EggXfmAnimData) anim = DCAST(EggXfmAnimData, child); _xform = new EggXfmSAnim(*anim); _table->replace(ci, _xform.p()); @@ -55,12 +52,10 @@ EggMatrixTablePointer(EggObject *object) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::get_frame_rate -// Access: Public, Virtual -// Description: Returns the stated frame rate of this particular -// joint, or 0.0 if it doesn't state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated frame rate of this particular joint, or 0.0 if it + * doesn't state. + */ double EggMatrixTablePointer:: get_frame_rate() const { if (_xform == (EggXfmSAnim *)NULL || !_xform->has_fps()) { @@ -70,12 +65,9 @@ get_frame_rate() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::get_num_frames -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular joint. + */ int EggMatrixTablePointer:: get_num_frames() const { if (_xform == (EggXfmSAnim *)NULL) { @@ -85,11 +77,9 @@ get_num_frames() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::extend_to -// Access: Public, Virtual -// Description: Extends the table to the indicated number of frames. -//////////////////////////////////////////////////////////////////// +/** + * Extends the table to the indicated number of frames. + */ void EggMatrixTablePointer:: extend_to(int num_frames) { nassertv(_xform != (EggXfmSAnim *)NULL); @@ -108,17 +98,15 @@ extend_to(int num_frames) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::get_frame -// Access: Public, Virtual -// Description: Returns the transform matrix corresponding to this -// joint position in the nth frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix corresponding to this joint position in the + * nth frame. + */ LMatrix4d EggMatrixTablePointer:: get_frame(int n) const { if (get_num_frames() == 1) { - // If we have exactly one frame, then we have as many frames as we - // want; just repeat the first frame. + // If we have exactly one frame, then we have as many frames as we want; + // just repeat the first frame. n = 0; } else if (get_num_frames() == 0) { @@ -132,25 +120,20 @@ get_frame(int n) const { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::set_frame -// Access: Public, Virtual -// Description: Sets the transform matrix corresponding to this -// joint position in the nth frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets the transform matrix corresponding to this joint position in the nth + * frame. + */ void EggMatrixTablePointer:: set_frame(int n, const LMatrix4d &mat) { nassertv(n >= 0 && n < get_num_frames()); _xform->set_value(n, mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::add_frame -// Access: Public, Virtual -// Description: Appends a new frame onto the end of the data, if -// possible; returns true if not possible, or false -// otherwise (e.g. for a static joint). -//////////////////////////////////////////////////////////////////// +/** + * Appends a new frame onto the end of the data, if possible; returns true if + * not possible, or false otherwise (e.g. for a static joint). + */ bool EggMatrixTablePointer:: add_frame(const LMatrix4d &mat) { if (_xform == (EggXfmSAnim *)NULL) { @@ -160,13 +143,10 @@ add_frame(const LMatrix4d &mat) { return _xform->add_data(mat); } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::do_finish_reparent -// Access: Protected -// Description: Performs the actual reparenting operation -// by removing the node from its old parent and -// associating it with its new parent, if any. -//////////////////////////////////////////////////////////////////// +/** + * Performs the actual reparenting operation by removing the node from its old + * parent and associating it with its new parent, if any. + */ void EggMatrixTablePointer:: do_finish_reparent(EggJointPointer *new_parent) { if (new_parent == (EggJointPointer *)NULL) { @@ -177,8 +157,8 @@ do_finish_reparent(EggJointPointer *new_parent) { } } else { - // Reparent the joint to its new parent (implicitly unparenting it - // from its previous parent). + // Reparent the joint to its new parent (implicitly unparenting it from + // its previous parent). EggMatrixTablePointer *new_node = DCAST(EggMatrixTablePointer, new_parent); if (new_node->_table != _table->get_parent()) { new_node->_table->add_child(_table.p()); @@ -186,19 +166,16 @@ do_finish_reparent(EggJointPointer *new_parent) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::do_rebuild -// Access: Public, Virtual -// Description: Rebuilds the entire table all at once, based on the -// frames added by repeated calls to add_rebuild_frame() -// since the last call to begin_rebuild(). -// -// Until do_rebuild() is called, the animation table is -// not changed. -// -// The return value is true if all frames are -// acceptable, or false if there is some problem. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the entire table all at once, based on the frames added by + * repeated calls to add_rebuild_frame() since the last call to + * begin_rebuild(). + * + * Until do_rebuild() is called, the animation table is not changed. + * + * The return value is true if all frames are acceptable, or false if there is + * some problem. + */ bool EggMatrixTablePointer:: do_rebuild(EggCharacterDb &db) { LMatrix4d mat; @@ -212,7 +189,7 @@ do_rebuild(EggCharacterDb &db) { } bool all_ok = true; - + _xform->clear_data(); if (!_xform->add_data(mat)) { all_ok = false; @@ -230,13 +207,10 @@ do_rebuild(EggCharacterDb &db) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::optimize -// Access: Public, Virtual -// Description: Resets the table before writing to disk so that -// redundant rows (e.g. i { 1 1 1 1 1 1 1 1 }) are -// collapsed out. -//////////////////////////////////////////////////////////////////// +/** + * Resets the table before writing to disk so that redundant rows (e.g. i { 1 + * 1 1 1 1 1 1 1 }) are collapsed out. + */ void EggMatrixTablePointer:: optimize() { if (_xform != (EggXfmSAnim *)NULL) { @@ -244,20 +218,17 @@ optimize() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::zero_channels -// Access: Public, Virtual -// Description: Zeroes out the named components of the transform in -// the animation frames. -//////////////////////////////////////////////////////////////////// +/** + * Zeroes out the named components of the transform in the animation frames. + */ void EggMatrixTablePointer:: zero_channels(const string &components) { if (_xform == (EggXfmSAnim *)NULL) { return; } - // This is particularly easy: we only have to remove children from - // the _xform object whose name is listed in the components. + // This is particularly easy: we only have to remove children from the + // _xform object whose name is listed in the components. string::const_iterator si; for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); @@ -268,25 +239,23 @@ zero_channels(const string &components) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::quantize_channels -// Access: Public, Virtual -// Description: Rounds the named components of the transform to the -// nearest multiple of quantum. -//////////////////////////////////////////////////////////////////// +/** + * Rounds the named components of the transform to the nearest multiple of + * quantum. + */ void EggMatrixTablePointer:: quantize_channels(const string &components, double quantum) { if (_xform == (EggXfmSAnim *)NULL) { return; } - // This is similar to the above: we quantize children of the _xform - // object whose name is listed in the components. + // This is similar to the above: we quantize children of the _xform object + // whose name is listed in the components. string::const_iterator si; for (si = components.begin(); si != components.end(); ++si) { string table_name(1, *si); EggNode *child = _xform->find_child(table_name); - if (child != (EggNode *)NULL && + if (child != (EggNode *)NULL && child->is_of_type(EggSAnimData::get_class_type())) { EggSAnimData *anim = DCAST(EggSAnimData, child); anim->quantize(quantum); @@ -294,12 +263,10 @@ quantize_channels(const string &components, double quantum) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::make_new_joint -// Access: Public, Virtual -// Description: Creates a new child of the current joint in the -// egg data, and returns a pointer to it. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new child of the current joint in the egg data, and returns a + * pointer to it. + */ EggJointPointer *EggMatrixTablePointer:: make_new_joint(const string &name) { EggTable *new_table = new EggTable(name); @@ -315,11 +282,9 @@ make_new_joint(const string &name) { return new EggMatrixTablePointer(new_table); } -//////////////////////////////////////////////////////////////////// -// Function: EggMatrixTablePointer::set_name -// Access: Public, Virtual -// Description: Applies the indicated name change to the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated name change to the egg file. + */ void EggMatrixTablePointer:: set_name(const string &name) { _table->set_name(name); diff --git a/pandatool/src/eggcharbase/eggMatrixTablePointer.h b/pandatool/src/eggcharbase/eggMatrixTablePointer.h index 3089c6fe6f..c23187955b 100644 --- a/pandatool/src/eggcharbase/eggMatrixTablePointer.h +++ b/pandatool/src/eggcharbase/eggMatrixTablePointer.h @@ -1,16 +1,15 @@ -// Filename: eggMatrixTablePointer.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMatrixTablePointer.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGMATRIXTABLEPOINTER_H #define EGGMATRIXTABLEPOINTER_H @@ -23,19 +22,17 @@ #include "eggXfmSAnim.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : EggMatrixTablePointer -// Description : This stores a pointer back to an EggXfmSAnim table -// (i.e. an entry in an egg file), -// corresponding to the animation data from a single -// bundle for this joint. -//////////////////////////////////////////////////////////////////// +/** + * This stores a pointer back to an EggXfmSAnim table (i.e. an + * entry in an egg file), corresponding to the animation data from a single + * bundle for this joint. + */ class EggMatrixTablePointer : public EggJointPointer { public: EggMatrixTablePointer(EggObject *object); - virtual double get_frame_rate() const; - virtual int get_num_frames() const; + virtual double get_frame_rate() const; + virtual int get_num_frames() const; virtual void extend_to(int num_frames); virtual LMatrix4d get_frame(int n) const; virtual void set_frame(int n, const LMatrix4d &mat); @@ -76,5 +73,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx index aabaafd7a6..da104af2bd 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.cxx +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.cxx @@ -1,16 +1,15 @@ -// Filename: eggScalarTablePointer.cxx -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggScalarTablePointer.cxx + * @author drose + * @date 2003-07-18 + */ #include "eggScalarTablePointer.h" @@ -18,22 +17,18 @@ TypeHandle EggScalarTablePointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggScalarTablePointer:: EggScalarTablePointer(EggObject *object) { _data = DCAST(EggSAnimData, object); } -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::get_frame_rate -// Access: Public, Virtual -// Description: Returns the stated frame rate of this particular -// joint, or 0.0 if it doesn't state. -//////////////////////////////////////////////////////////////////// +/** + * Returns the stated frame rate of this particular joint, or 0.0 if it + * doesn't state. + */ double EggScalarTablePointer:: get_frame_rate() const { if (_data == (EggSAnimData *)NULL || !_data->has_fps()) { @@ -43,12 +38,9 @@ get_frame_rate() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::get_num_frames -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular slider. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular slider. + */ int EggScalarTablePointer:: get_num_frames() const { if (_data == (EggSAnimData *)NULL) { @@ -58,11 +50,9 @@ get_num_frames() const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::extend_to -// Access: Public, Virtual -// Description: Extends the table to the indicated number of frames. -//////////////////////////////////////////////////////////////////// +/** + * Extends the table to the indicated number of frames. + */ void EggScalarTablePointer:: extend_to(int num_frames) { nassertv(_data != (EggSAnimData *)NULL); @@ -80,17 +70,14 @@ extend_to(int num_frames) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::get_frame -// Access: Public, Virtual -// Description: Returns the value corresponding to this -// slider position in the nth frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value corresponding to this slider position in the nth frame. + */ double EggScalarTablePointer:: get_frame(int n) const { if (get_num_frames() == 1) { - // If we have exactly one frame, then we have as many frames as we - // want; just repeat the first frame. + // If we have exactly one frame, then we have as many frames as we want; + // just repeat the first frame. n = 0; } @@ -98,15 +85,13 @@ get_frame(int n) const { return _data->get_value(n); } -//////////////////////////////////////////////////////////////////// -// Function: EggScalarTablePointer::set_name -// Access: Public, Virtual -// Description: Applies the indicated name change to the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated name change to the egg file. + */ void EggScalarTablePointer:: set_name(const string &name) { - // Actually, let's not rename the slider table (yet), because we - // haven't written the code to rename all of the morph targets. + // Actually, let's not rename the slider table (yet), because we haven't + // written the code to rename all of the morph targets. - // _data->set_name(name); + // _data->set_name(name); } diff --git a/pandatool/src/eggcharbase/eggScalarTablePointer.h b/pandatool/src/eggcharbase/eggScalarTablePointer.h index c587cbe71a..f1cd226c1f 100644 --- a/pandatool/src/eggcharbase/eggScalarTablePointer.h +++ b/pandatool/src/eggcharbase/eggScalarTablePointer.h @@ -1,16 +1,15 @@ -// Filename: eggScalarTablePointer.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggScalarTablePointer.h + * @author drose + * @date 2003-07-18 + */ #ifndef EGGSCALARTABLEPOINTER_H #define EGGSCALARTABLEPOINTER_H @@ -22,18 +21,16 @@ #include "eggSAnimData.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : EggScalarTablePointer -// Description : This stores a pointer back to an EggSAnimData table -// (i.e. an entry in an egg file), -// corresponding to the animation data from a single -// bundle for this slider. -//////////////////////////////////////////////////////////////////// +/** + * This stores a pointer back to an EggSAnimData table (i.e. an + * entry in an egg file), corresponding to the animation data from a single + * bundle for this slider. + */ class EggScalarTablePointer : public EggSliderPointer { public: EggScalarTablePointer(EggObject *object); - virtual double get_frame_rate() const; + virtual double get_frame_rate() const; virtual int get_num_frames() const; virtual void extend_to(int num_frames); virtual double get_frame(int n) const; @@ -62,5 +59,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggSliderData.I b/pandatool/src/eggcharbase/eggSliderData.I index 63f060aab0..d925c04afd 100644 --- a/pandatool/src/eggcharbase/eggSliderData.I +++ b/pandatool/src/eggcharbase/eggSliderData.I @@ -1,13 +1,12 @@ -// Filename: eggSliderData.I -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSliderData.I + * @author drose + * @date 2001-02-26 + */ diff --git a/pandatool/src/eggcharbase/eggSliderData.cxx b/pandatool/src/eggcharbase/eggSliderData.cxx index 165b045265..d597adcc17 100644 --- a/pandatool/src/eggcharbase/eggSliderData.cxx +++ b/pandatool/src/eggcharbase/eggSliderData.cxx @@ -1,16 +1,15 @@ -// Filename: eggSliderData.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSliderData.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggSliderData.h" #include "eggVertexPointer.h" @@ -24,11 +23,9 @@ TypeHandle EggSliderData::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggSliderData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggSliderData:: EggSliderData(EggCharacterCollection *collection, EggCharacterData *char_data) : @@ -36,12 +33,10 @@ EggSliderData(EggCharacterCollection *collection, { } -//////////////////////////////////////////////////////////////////// -// Function: EggSliderData::get_frame -// Access: Public -// Description: Returns the value corresponding to this slider -// position in the nth frame in the indicated model. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value corresponding to this slider position in the nth frame in + * the indicated model. + */ double EggSliderData:: get_frame(int model_index, int n) const { EggBackPointer *back = get_model(model_index); @@ -55,12 +50,9 @@ get_frame(int model_index, int n) const { return slider->get_frame(n); } -//////////////////////////////////////////////////////////////////// -// Function: EggSliderData::add_back_pointer -// Access: Public, Virtual -// Description: Adds the indicated vertex, primitive, or morph table -// to the data. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated vertex, primitive, or morph table to the data. + */ void EggSliderData:: add_back_pointer(int model_index, EggObject *egg_object) { if (egg_object->is_of_type(EggPrimitive::get_class_type())) { @@ -92,11 +84,9 @@ add_back_pointer(int model_index, EggObject *egg_object) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggSliderData::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggSliderData:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/eggcharbase/eggSliderData.h b/pandatool/src/eggcharbase/eggSliderData.h index c693f3df7f..03c1d2fe3f 100644 --- a/pandatool/src/eggcharbase/eggSliderData.h +++ b/pandatool/src/eggcharbase/eggSliderData.h @@ -1,16 +1,15 @@ -// Filename: eggSliderData.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSliderData.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGSLIDERDATA_H #define EGGSLIDERDATA_H @@ -20,14 +19,12 @@ #include "eggComponentData.h" -//////////////////////////////////////////////////////////////////// -// Class : EggSliderData -// Description : This corresponds to a single morph slider control. -// It contains back pointers to all the vertices and -// primitives that reference this slider across all -// models, as well as all the tables in which it appears -// in all animation files. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to a single morph slider control. It contains back + * pointers to all the vertices and primitives that reference this slider + * across all models, as well as all the tables in which it appears in all + * animation files. + */ class EggSliderData : public EggComponentData { public: EggSliderData(EggCharacterCollection *collection, @@ -60,5 +57,3 @@ private: #include "eggSliderData.I" #endif - - diff --git a/pandatool/src/eggcharbase/eggSliderPointer.cxx b/pandatool/src/eggcharbase/eggSliderPointer.cxx index 38fedfad7a..bad2934a59 100644 --- a/pandatool/src/eggcharbase/eggSliderPointer.cxx +++ b/pandatool/src/eggcharbase/eggSliderPointer.cxx @@ -1,18 +1,16 @@ -// Filename: eggSliderPointer.cxx -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSliderPointer.cxx + * @author drose + * @date 2003-07-18 + */ #include "eggSliderPointer.h" TypeHandle EggSliderPointer::_type_handle; - diff --git a/pandatool/src/eggcharbase/eggSliderPointer.h b/pandatool/src/eggcharbase/eggSliderPointer.h index 1a82fb600f..19129f458b 100644 --- a/pandatool/src/eggcharbase/eggSliderPointer.h +++ b/pandatool/src/eggcharbase/eggSliderPointer.h @@ -1,16 +1,15 @@ -// Filename: eggSliderPointer.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggSliderPointer.h + * @author drose + * @date 2003-07-18 + */ #ifndef EGGSLIDERPOINTER_H #define EGGSLIDERPOINTER_H @@ -21,11 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : EggSliderPointer -// Description : This is a base class for EggVertexPointer and -// EggScalarTablePointer. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for EggVertexPointer and EggScalarTablePointer. + */ class EggSliderPointer : public EggBackPointer { public: virtual int get_num_frames() const=0; @@ -50,5 +47,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggcharbase/eggVertexPointer.cxx b/pandatool/src/eggcharbase/eggVertexPointer.cxx index 1f151743ff..09af9d77de 100644 --- a/pandatool/src/eggcharbase/eggVertexPointer.cxx +++ b/pandatool/src/eggcharbase/eggVertexPointer.cxx @@ -1,62 +1,50 @@ -// Filename: eggVertexPointer.cxx -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexPointer.cxx + * @author drose + * @date 2001-02-26 + */ #include "eggVertexPointer.h" TypeHandle EggVertexPointer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPointer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggVertexPointer:: EggVertexPointer(EggObject *egg_object) { } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPointer::get_num_frames -// Access: Public, Virtual -// Description: Returns the number of frames of animation for this -// particular slider. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of frames of animation for this particular slider. + */ int EggVertexPointer:: get_num_frames() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPointer::get_frame -// Access: Public, Virtual -// Description: Returns the value corresponding to this -// slider position in the nth frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the value corresponding to this slider position in the nth frame. + */ double EggVertexPointer:: get_frame(int n) const { nassertr(false, 0.0); return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: EggVertexPointer::has_vertices -// Access: Public, Virtual -// Description: Returns true if there are any vertices referenced by -// the node this points to, false otherwise. For -// certain kinds of back pointers (e.g. table animation -// entries), this is always false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are any vertices referenced by the node this points + * to, false otherwise. For certain kinds of back pointers (e.g. table + * animation entries), this is always false. + */ bool EggVertexPointer:: has_vertices() const { return true; diff --git a/pandatool/src/eggcharbase/eggVertexPointer.h b/pandatool/src/eggcharbase/eggVertexPointer.h index 21892f0bca..8403edab2d 100644 --- a/pandatool/src/eggcharbase/eggVertexPointer.h +++ b/pandatool/src/eggcharbase/eggVertexPointer.h @@ -1,16 +1,15 @@ -// Filename: eggVertexPointer.h -// Created by: drose (26Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggVertexPointer.h + * @author drose + * @date 2001-02-26 + */ #ifndef EGGVERTEXPOINTER_H #define EGGVERTEXPOINTER_H @@ -22,12 +21,10 @@ #include "eggGroup.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : EggVertexPointer -// Description : This stores a pointer back to a , or to a -// particular pritimive like a , representing a -// morph offset. -//////////////////////////////////////////////////////////////////// +/** + * This stores a pointer back to a , or to a particular pritimive like + * a , representing a morph offset. + */ class EggVertexPointer : public EggSliderPointer { public: EggVertexPointer(EggObject *egg_object); @@ -56,5 +53,3 @@ private: }; #endif - - diff --git a/pandatool/src/eggprogs/eggCrop.cxx b/pandatool/src/eggprogs/eggCrop.cxx index 73a623298c..64f2e017b4 100644 --- a/pandatool/src/eggprogs/eggCrop.cxx +++ b/pandatool/src/eggprogs/eggCrop.cxx @@ -1,16 +1,15 @@ -// Filename: eggCrop.cxx -// Created by: drose (10Jun02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCrop.cxx + * @author drose + * @date 2002-06-10 + */ #include "eggCrop.h" @@ -20,11 +19,9 @@ #include "dcast.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggCrop::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggCrop:: EggCrop() { set_program_brief("crop geometry in an .egg file"); @@ -44,31 +41,25 @@ EggCrop() { &EggCrop::dispatch_double_triple, &_got_max, &_max[0]); } -//////////////////////////////////////////////////////////////////// -// Function: EggCrop::post_command_line -// Access: Public, Virtual -// Description: This is called after the command line has been -// completely processed, and it gives the program a -// chance to do some last-minute processing and -// validation of the options and arguments. It should -// return true if everything is fine, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * This is called after the command line has been completely processed, and it + * gives the program a chance to do some last-minute processing and validation + * of the options and arguments. It should return true if everything is fine, + * false if there is an error. + */ bool EggCrop:: post_command_line() { if (!_got_min || !_got_max) { nout << "You must specify both a minimum and a maximum bounds.\n"; return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggCrop::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggCrop:: run() { int num_removed = strip_prims(_data); @@ -79,14 +70,11 @@ run() { } -//////////////////////////////////////////////////////////////////// -// Function: EggCrop::strip_prims -// Access: Private -// Description: Recursively walks the scene graph, looking for -// primitives that exceed the specified bounding volume, -// and removes them. Returns the number of primitives -// removed. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the scene graph, looking for primitives that exceed the + * specified bounding volume, and removes them. Returns the number of + * primitives removed. + */ int EggCrop:: strip_prims(EggGroupNode *group) { int num_removed = 0; @@ -107,7 +95,7 @@ strip_prims(EggGroupNode *group) { all_in = (pos[0] >= _min[0] && pos[0] <= _max[0] && pos[1] >= _min[1] && pos[1] <= _max[1] && pos[2] >= _min[2] && pos[2] <= _max[2]); - + } } diff --git a/pandatool/src/eggprogs/eggCrop.h b/pandatool/src/eggprogs/eggCrop.h index d604244bd0..df3203c848 100644 --- a/pandatool/src/eggprogs/eggCrop.h +++ b/pandatool/src/eggprogs/eggCrop.h @@ -1,16 +1,15 @@ -// Filename: eggCrop.h -// Created by: drose (10Jun02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggCrop.h + * @author drose + * @date 2002-06-10 + */ #ifndef EGGCROP_H #define EGGCROP_H @@ -21,12 +20,10 @@ class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : EggCrop -// Description : A program to read an egg file and write an equivalent -// egg file, possibly performing some minor operations -// along the way. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write an equivalent egg file, possibly + * performing some minor operations along the way. + */ class EggCrop : public EggFilter { public: EggCrop(); @@ -42,4 +39,3 @@ private: }; #endif - diff --git a/pandatool/src/eggprogs/eggListTextures.cxx b/pandatool/src/eggprogs/eggListTextures.cxx index bc1af8161f..3174e5ad87 100644 --- a/pandatool/src/eggprogs/eggListTextures.cxx +++ b/pandatool/src/eggprogs/eggListTextures.cxx @@ -1,27 +1,24 @@ -// Filename: eggListTextures.cxx -// Created by: drose (23May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggListTextures.cxx + * @author drose + * @date 2005-05-23 + */ #include "eggListTextures.h" #include "eggTextureCollection.h" #include "pnmImageHeader.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggListTextures::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggListTextures:: EggListTextures() { set_program_brief("list textures referenced by an .egg file"); @@ -32,11 +29,9 @@ EggListTextures() { "format is crafted to be compatible with that file's input format."); } -//////////////////////////////////////////////////////////////////// -// Function: EggListTextures::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggListTextures:: run() { if (!do_reader_options()) { diff --git a/pandatool/src/eggprogs/eggListTextures.h b/pandatool/src/eggprogs/eggListTextures.h index 05042e9128..5460b49e39 100644 --- a/pandatool/src/eggprogs/eggListTextures.h +++ b/pandatool/src/eggprogs/eggListTextures.h @@ -1,16 +1,15 @@ -// Filename: eggListTextures.h -// Created by: drose (23May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggListTextures.h + * @author drose + * @date 2005-05-23 + */ #ifndef EGGLISTTEXTURES_H #define EGGLISTTEXTURES_H @@ -19,11 +18,9 @@ #include "eggReader.h" -//////////////////////////////////////////////////////////////////// -// Class : EggListTextures -// Description : Reads an egg file and outputs the list of textures it -// uses. -//////////////////////////////////////////////////////////////////// +/** + * Reads an egg file and outputs the list of textures it uses. + */ class EggListTextures : public EggReader { public: EggListTextures(); @@ -32,4 +29,3 @@ public: }; #endif - diff --git a/pandatool/src/eggprogs/eggMakeTube.cxx b/pandatool/src/eggprogs/eggMakeTube.cxx index 3b8eddb5c8..efda24d353 100644 --- a/pandatool/src/eggprogs/eggMakeTube.cxx +++ b/pandatool/src/eggprogs/eggMakeTube.cxx @@ -1,16 +1,15 @@ -// Filename: eggMakeTube.cxx -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeTube.cxx + * @author drose + * @date 2003-10-01 + */ #include "eggMakeTube.h" #include "eggGroup.h" @@ -21,11 +20,9 @@ #include "look_at.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggMakeTube:: EggMakeTube() { @@ -38,33 +35,33 @@ EggMakeTube() { "case, you are generating a degenerate tube of length 0."); add_option - ("a", "x,y,z", 0, + ("a", "x,y,z", 0, "Specify the first endpoint of the tube.", &EggWriter::dispatch_double_triple, NULL, _point_a); add_option - ("b", "x,y,z", 0, + ("b", "x,y,z", 0, "Specify the second endpoint of the tube.", &EggWriter::dispatch_double_triple, &_got_point_b, _point_b); add_option - ("r", "radius", 0, + ("r", "radius", 0, "Specify the radius of the tube. The tube will extend beyond " "the endpoints in each direction by the amount of radius.", &EggWriter::dispatch_double, NULL, &_radius); add_option - ("slices", "count", 0, + ("slices", "count", 0, "Specify the number of slices appearing radially around the tube.", &EggWriter::dispatch_int, NULL, &_num_slices); add_option - ("crings", "count", 0, + ("crings", "count", 0, "Specify the number of rings appearing in each endcap of the tube.", &EggWriter::dispatch_int, NULL, &_num_crings); add_option - ("trings", "count", 0, + ("trings", "count", 0, "Specify the number of rings appearing in the cylindrical body " "of the tube.", &EggWriter::dispatch_int, NULL, &_num_trings); @@ -84,11 +81,9 @@ EggMakeTube() { _num_trings = 1; } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggMakeTube:: run() { if (!_got_point_b) { @@ -97,8 +92,8 @@ run() { _point_b[2] = _point_a[2]; } - // We will generate the vertices in the canonical space (along the y - // axis), then transform it to the desired point. + // We will generate the vertices in the canonical space (along the y axis), + // then transform it to the desired point. LVector3d direction(_point_b[0] - _point_a[0], _point_b[1] - _point_a[1], _point_b[2] - _point_a[2]); @@ -165,12 +160,10 @@ run() { write_egg_file(); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::calc_sphere1_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// first endcap hemisphere. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a particular vertex on the surface of the first endcap + * hemisphere. + */ EggVertex *EggMakeTube:: calc_sphere1_vertex(int ri, int si) { double r = (double)ri / (double)_num_crings; @@ -195,12 +188,9 @@ calc_sphere1_vertex(int ri, int si) { return _vpool->create_unique_vertex(vert); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::calc_tube_vertex -// Access: Private -// Description: Calculates a vertex on the side of the cylindrical -// body of the tube. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a vertex on the side of the cylindrical body of the tube. + */ EggVertex *EggMakeTube:: calc_tube_vertex(int ri, int si) { double r = (double)ri / (double)_num_trings; @@ -221,12 +211,10 @@ calc_tube_vertex(int ri, int si) { return _vpool->create_unique_vertex(vert); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::calc_sphere2_vertex -// Access: Private -// Description: Calculates a particular vertex on the surface of the -// second endcap hemisphere. -//////////////////////////////////////////////////////////////////// +/** + * Calculates a particular vertex on the surface of the second endcap + * hemisphere. + */ EggVertex *EggMakeTube:: calc_sphere2_vertex(int ri, int si) { double r = (double)ri / (double)_num_crings; @@ -251,13 +239,10 @@ calc_sphere2_vertex(int ri, int si) { return _vpool->create_unique_vertex(vert); } -//////////////////////////////////////////////////////////////////// -// Function: EggMakeTube::add_polygon -// Access: Private -// Description: Adds the polygon defined by the indicated four -// vertices to the group. If the first vertex is -// NULL, does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Adds the polygon defined by the indicated four vertices to the group. If + * the first vertex is NULL, does nothing. + */ void EggMakeTube:: add_polygon(EggVertex *a, EggVertex *b, EggVertex *c, EggVertex *d) { if (a == (EggVertex *)NULL) { diff --git a/pandatool/src/eggprogs/eggMakeTube.h b/pandatool/src/eggprogs/eggMakeTube.h index d1ec410857..520d178aee 100644 --- a/pandatool/src/eggprogs/eggMakeTube.h +++ b/pandatool/src/eggprogs/eggMakeTube.h @@ -1,16 +1,15 @@ -// Filename: eggMakeTube.h -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggMakeTube.h + * @author drose + * @date 2003-10-01 + */ #ifndef EGGMAKETUBE_H #define EGGMAKETUBE_H @@ -23,11 +22,10 @@ class EggGroup; class EggVertexPool; class EggVertex; -//////////////////////////////////////////////////////////////////// -// Class : EggMakeTube -// Description : A program to generate an egg file representing a tube -// model, similar in shape to a CollisionTube. -//////////////////////////////////////////////////////////////////// +/** + * A program to generate an egg file representing a tube model, similar in + * shape to a CollisionTube. + */ class EggMakeTube : public EggMakeSomething { public: EggMakeTube(); @@ -55,4 +53,3 @@ private: }; #endif - diff --git a/pandatool/src/eggprogs/eggRename.cxx b/pandatool/src/eggprogs/eggRename.cxx index a497671c79..ac28ae39b6 100644 --- a/pandatool/src/eggprogs/eggRename.cxx +++ b/pandatool/src/eggprogs/eggRename.cxx @@ -1,25 +1,22 @@ -// Filename: eggRename.cxx -// Created by: masad (22Apr05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRename.cxx + * @author masad + * @date 2005-04-22 + */ #include "eggRename.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggRename::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggRename:: EggRename() { set_program_brief("rename nodes in .egg files"); @@ -33,11 +30,9 @@ EggRename() { &EggRename::dispatch_vector_string, NULL, &_strip_prefix); } -//////////////////////////////////////////////////////////////////// -// Function: EggRename::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggRename:: run() { if (!_strip_prefix.empty()) { diff --git a/pandatool/src/eggprogs/eggRename.h b/pandatool/src/eggprogs/eggRename.h index 43715df65d..51bd53447f 100644 --- a/pandatool/src/eggprogs/eggRename.h +++ b/pandatool/src/eggprogs/eggRename.h @@ -1,16 +1,15 @@ -// Filename: eggRename.h -// Created by: masad (22Apr05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRename.h + * @author masad + * @date 2005-04-22 + */ #ifndef EGGRENAME_H #define EGGRENAME_H @@ -19,12 +18,10 @@ #include "eggMultiFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTrans -// Description : A program to read an egg file and write an equivalent -// egg file, with stripping prefix for now, but more -// along the way. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write an equivalent egg file, with + * stripping prefix for now, but more along the way. + */ class EggRename : public EggMultiFilter { public: EggRename(); @@ -35,4 +32,3 @@ public: }; #endif - diff --git a/pandatool/src/eggprogs/eggRetargetAnim.cxx b/pandatool/src/eggprogs/eggRetargetAnim.cxx index ff26b8f686..82a825a8cc 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.cxx +++ b/pandatool/src/eggprogs/eggRetargetAnim.cxx @@ -1,16 +1,15 @@ -// Filename: eggRetargetAnim.cxx -// Created by: drose (05May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRetargetAnim.cxx + * @author drose + * @date 2005-05-05 + */ #include "eggRetargetAnim.h" @@ -24,11 +23,9 @@ #include "compose_matrix.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggRetargetAnim::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggRetargetAnim:: EggRetargetAnim() { add_path_replace_options(); @@ -61,11 +58,9 @@ EggRetargetAnim() { &EggRetargetAnim::dispatch_vector_string_comma, NULL, &_keep_joints); } -//////////////////////////////////////////////////////////////////// -// Function: EggRetargetAnim::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggRetargetAnim:: run() { nassertv(_collection != (EggCharacterCollection *)NULL); @@ -82,16 +77,15 @@ run() { exit(1); } - // Read in the extra egg file that we use for extracting the - // references out. + // Read in the extra egg file that we use for extracting the references out. PT(EggData) reference_egg = read_egg(_reference_filename); if (reference_egg == (EggData *)NULL) { nout << "Cannot read " << _reference_filename << "\n"; exit(1); } - // First, we add it to a separate EggCharacterCollection, so we can - // figure out its name. + // First, we add it to a separate EggCharacterCollection, so we can figure + // out its name. EggCharacterCollection col; if (col.add_egg(reference_egg) < 0) { nout << _reference_filename @@ -106,14 +100,14 @@ run() { string ref_name = col.get_character(0)->get_name(); - // Now rename all of the animations to the same name as the - // reference model, and add the reference animation in to the same - // collection to match it up joint-for-joint. + // Now rename all of the animations to the same name as the reference model, + // and add the reference animation in to the same collection to match it up + // joint-for-joint. _collection->rename_char(0, ref_name); int reference_egg_index = _collection->add_egg(reference_egg); nassertv(reference_egg_index > 0); nassertv(_collection->get_num_characters() == 1); - + int reference_model = _collection->get_first_model_index(reference_egg_index); EggCharacterData *char_data = _collection->get_character(0); nout << "Processing " << char_data->get_name() << "\n"; @@ -134,13 +128,10 @@ run() { write_eggs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggRetargetAnim::retarget_anim -// Access: Public -// Description: Recursively replaces the scale and translate -// information on all of the joints in the char_data -// hierarchy wiht this from reference_char. -//////////////////////////////////////////////////////////////////// +/** + * Recursively replaces the scale and translate information on all of the + * joints in the char_data hierarchy wiht this from reference_char. + */ void EggRetargetAnim:: retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, int reference_model, const pset &keep_names, @@ -154,22 +145,22 @@ retarget_anim(EggCharacterData *char_data, EggJointData *joint_data, for (int i = 0; i < num_models; i++) { if (joint_data->has_model(i)) { int num_frames = char_data->get_num_frames(i); - + EggBackPointer *back = joint_data->get_model(i); nassertv(back != (EggBackPointer *)NULL); EggJointPointer *joint; DCAST_INTO_V(joint, back); - + LMatrix4d ref = joint_data->get_frame(reference_model, 0); LVecBase3d ref_scale, ref_shear, ref_hpr, ref_translate; if (!decompose_matrix(ref, ref_scale, ref_shear, ref_hpr, ref_translate)) { - nout << "Could not decompose rest frame for " + nout << "Could not decompose rest frame for " << joint_data->get_name() << "\n"; } else { int f; for (f = 0; f < num_frames; f++) { LMatrix4d mat = joint_data->get_frame(i, f); - + LVecBase3d scale, shear, hpr, translate; if (decompose_matrix(mat, scale, shear, hpr, translate)) { compose_matrix(mat, ref_scale, ref_shear, hpr, ref_translate); diff --git a/pandatool/src/eggprogs/eggRetargetAnim.h b/pandatool/src/eggprogs/eggRetargetAnim.h index 1051d69a55..bf9d94cd38 100644 --- a/pandatool/src/eggprogs/eggRetargetAnim.h +++ b/pandatool/src/eggprogs/eggRetargetAnim.h @@ -1,16 +1,15 @@ -// Filename: eggRetargetAnim.h -// Created by: drose (05May05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggRetargetAnim.h + * @author drose + * @date 2005-05-05 + */ #ifndef EGGRETARGETANIM_H #define EGGRETARGETANIM_H @@ -26,13 +25,11 @@ class EggCharacterData; class EggJointData; class EggCharacterDb; -//////////////////////////////////////////////////////////////////// -// Class : EggRetargetAnim -// Description : Retargets one or more animation files from one -// particular skeleton to a similar, but differently -// scaled skeleton by preserving the rotation -// information but discarding translation and/or scale. -//////////////////////////////////////////////////////////////////// +/** + * Retargets one or more animation files from one particular skeleton to a + * similar, but differently scaled skeleton by preserving the rotation + * information but discarding translation and/or scale. + */ class EggRetargetAnim : public EggCharacterFilter { public: EggRetargetAnim(); @@ -48,4 +45,3 @@ public: }; #endif - diff --git a/pandatool/src/eggprogs/eggTextureCards.cxx b/pandatool/src/eggprogs/eggTextureCards.cxx index b30c480059..e0363af75a 100644 --- a/pandatool/src/eggprogs/eggTextureCards.cxx +++ b/pandatool/src/eggprogs/eggTextureCards.cxx @@ -1,16 +1,15 @@ -// Filename: eggTextureCards.cxx -// Created by: drose (21Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTextureCards.cxx + * @author drose + * @date 2001-02-21 + */ #include "eggTextureCards.h" @@ -24,11 +23,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTextureCards:: EggTextureCards() : EggWriter(true, true) { set_program_brief("generate an .egg file containing texture cards"); @@ -195,14 +192,11 @@ EggTextureCards() : EggWriter(true, true) { _frame_rate = 2.0; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggTextureCards:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 0)) { @@ -222,14 +216,11 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::dispatch_wrap_mode -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// WrapMode string. The data pointer is to a WrapMode -// enum variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a WrapMode string. The data pointer is to a WrapMode + * enum variable. + */ bool EggTextureCards:: dispatch_wrap_mode(const string &opt, const string &arg, void *var) { EggTexture::WrapMode *wmp = (EggTexture::WrapMode *)var; @@ -251,14 +242,11 @@ dispatch_wrap_mode(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::dispatch_filter_type -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// FilterType string. The data pointer is to a -// FilterType enum variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a FilterType string. The data pointer is to a + * FilterType enum variable. + */ bool EggTextureCards:: dispatch_filter_type(const string &opt, const string &arg, void *var) { EggTexture::FilterType *ftp = (EggTexture::FilterType *)var; @@ -274,14 +262,11 @@ dispatch_filter_type(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::dispatch_quality_level -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// QualityLevel string. The data pointer is to a -// QualityLevel enum variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a QualityLevel string. The data pointer is to a + * QualityLevel enum variable. + */ bool EggTextureCards:: dispatch_quality_level(const string &opt, const string &arg, void *var) { EggTexture::QualityLevel *qlp = (EggTexture::QualityLevel *)var; @@ -296,14 +281,11 @@ dispatch_quality_level(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::dispatch_format -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// Format string. The data pointer is to a Format -// enum variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a Format string. The data pointer is to a Format enum + * variable. + */ bool EggTextureCards:: dispatch_format(const string &opt, const string &arg, void *var) { EggTexture::Format *fp = (EggTexture::Format *)var; @@ -319,17 +301,13 @@ dispatch_format(const string &opt, const string &arg, void *var) { } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::scan_texture -// Access: Private -// Description: Reads the texture image header to determine its size, -// and based on this size, computes the appropriate -// left,right,bottom,top geometry of the card that -// correspond to this texture. -// -// Returns true if successful, or false if the texture -// cannot be read. -//////////////////////////////////////////////////////////////////// +/** + * Reads the texture image header to determine its size, and based on this + * size, computes the appropriate left,right,bottom,top geometry of the card + * that correspond to this texture. + * + * Returns true if successful, or false if the texture cannot be read. + */ bool EggTextureCards:: scan_texture(const Filename &filename, LVecBase4d &geometry, int &num_channels) { @@ -351,21 +329,14 @@ scan_texture(const Filename &filename, LVecBase4d &geometry, return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::make_vertices -// Access: Private -// Description: Creates a set of four vertices for the polygon -// according to the left,right,bottom,top geometry. -//////////////////////////////////////////////////////////////////// +/** + * Creates a set of four vertices for the polygon according to the + * left,right,bottom,top geometry. + */ void EggTextureCards:: make_vertices(const LPoint4d &geometry, EggVertexPool *vpool, EggVertex *&v1, EggVertex *&v2, EggVertex *&v3, EggVertex *&v4) { - // - // 1 4 - // - // - // 2 3 - // + // 1 4 2 3 v1 = vpool->make_new_vertex (LPoint3d(geometry[0], geometry[3], 0.0)); @@ -382,23 +353,21 @@ make_vertices(const LPoint4d &geometry, EggVertexPool *vpool, v4->set_uv(LTexCoordd(1.0, 1.0)); } -//////////////////////////////////////////////////////////////////// -// Function: EggTextureCards::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggTextureCards:: run() { - // First, create an enclosing group and a vertex pool with four - // vertices. We can use the same four vertices on all polygons. + // First, create an enclosing group and a vertex pool with four vertices. + // We can use the same four vertices on all polygons. bool all_ok = true; EggGroup *group = new EggGroup(); _data->add_child(group); // If we have more than one tile, make the group a sequence, as a - // convenience. If we view the egg file directly we can see all the - // tiles one at a time. + // convenience. If we view the egg file directly we can see all the tiles + // one at a time. if (_texture_names.size() > 1) { group->set_switch_flag(true); group->set_switch_fps(_frame_rate); @@ -410,9 +379,8 @@ run() { EggVertex *v1, *v2, *v3, *v4; if (!_got_pixel_scale) { - // If we don't have a per-texture pixel scale, all the polygons - // will be the same size, and hence may all share the same four - // vertices. + // If we don't have a per-texture pixel scale, all the polygons will be + // the same size, and hence may all share the same four vertices. make_vertices(_polygon_geometry, vpool, v1, v2, v3, v4); } @@ -486,8 +454,8 @@ run() { group->add_child(tref); - // Each polygon gets placed in its own sub-group. This will make - // pulling them out by name at runtime possible. + // Each polygon gets placed in its own sub-group. This will make pulling + // them out by name at runtime possible. EggGroup *sub_group = new EggGroup(name); group->add_child(sub_group); EggPolygon *poly = new EggPolygon(); diff --git a/pandatool/src/eggprogs/eggTextureCards.h b/pandatool/src/eggprogs/eggTextureCards.h index 2858f8d11c..f3adde8b34 100644 --- a/pandatool/src/eggprogs/eggTextureCards.h +++ b/pandatool/src/eggprogs/eggTextureCards.h @@ -1,16 +1,15 @@ -// Filename: eggTextureCards.h -// Created by: drose (21Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTextureCards.h + * @author drose + * @date 2001-02-21 + */ #ifndef EGGTEXTURECARDS_H #define EGGTEXTURECARDS_H @@ -25,12 +24,11 @@ class EggVertexPool; class EggVertex; -//////////////////////////////////////////////////////////////////// -// Class : EggTextureCards -// Description : Generates an egg file featuring a number of polygons, -// one for each named texture. This is a support -// program for getting textures through egg-palettize. -//////////////////////////////////////////////////////////////////// +/** + * Generates an egg file featuring a number of polygons, one for each named + * texture. This is a support program for getting textures through egg- + * palettize. + */ class EggTextureCards : public EggWriter { public: EggTextureCards(); @@ -74,4 +72,3 @@ public: }; #endif - diff --git a/pandatool/src/eggprogs/eggToC.cxx b/pandatool/src/eggprogs/eggToC.cxx index 4b7fc2bae1..9a25e1615d 100644 --- a/pandatool/src/eggprogs/eggToC.cxx +++ b/pandatool/src/eggprogs/eggToC.cxx @@ -1,16 +1,15 @@ -// Filename: eggToC.cxx -// Created by: drose (03Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToC.cxx + * @author drose + * @date 2001-08-03 + */ #include "eggToC.h" @@ -24,11 +23,9 @@ #include "string_utils.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToC::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToC:: EggToC() : EggToSomething("C", ".c", true, true) @@ -40,8 +37,8 @@ EggToC() : "for the program after the fact; the program only generates tables " "of vertices and polygons."); - // -f is always in effect for egg2c. It doesn't make sense to - // provide it as an option to the user. + // -f is always in effect for egg2c. It doesn't make sense to provide it as + // an option to the user. remove_option("f"); add_option @@ -85,11 +82,9 @@ EggToC() : &EggToC::dispatch_none, &_triangulate_polygons); } -//////////////////////////////////////////////////////////////////// -// Function: EggToC::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToC:: run() { nout << "Removing invalid primitives.\n"; @@ -123,11 +118,9 @@ run() { traverse(_data); } -//////////////////////////////////////////////////////////////////// -// Function: EggToC::traverse -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToC:: traverse(EggNode *node) { if (node->is_of_type(EggVertexPool::get_class_type())) { @@ -146,18 +139,16 @@ traverse(EggNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToC::write_vertex_pool -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToC:: write_vertex_pool(EggVertexPool *vpool) { int highest_index = vpool->get_highest_index(); int i; ostream &out = get_output(); - out << "/* Vertex pool index " << _next_vpool_index + out << "/* Vertex pool index " << _next_vpool_index << ": " << vpool->get_name() << " */\n"; _vertex_pools[vpool] = _next_vpool_index; _next_vpool_index++; @@ -176,17 +167,17 @@ write_vertex_pool(EggVertexPool *vpool) { case 1: out << " vertex(" << p[0] << "), /* " << i << " */\n"; break; - + case 2: out << " vertex(" << p[0] << ", " << p[1] << "), /* " << i << " */\n"; break; - + case 3: out << " vertex(" << p[0] << ", " << p[1] << ", " << p[2] << "), /* " << i << " */\n"; break; - + case 4: out << " vertex(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << "), /* " << i << " */\n"; @@ -253,11 +244,9 @@ write_vertex_pool(EggVertexPool *vpool) { } -//////////////////////////////////////////////////////////////////// -// Function: EggToC::write_bin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToC:: write_bin(EggBin *bin) { ostream &out = get_output(); @@ -286,7 +275,7 @@ write_bin(EggBin *bin) { } else { out << " /* vpool index, num vertices, vertex0, vertex1, vertex2, ... */\n"; } - + EggGroupNode::const_iterator ci; size_t prim_index = 0; for (ci = bin->begin(); ci != bin->end(); ++ci) { @@ -323,7 +312,7 @@ write_bin(EggBin *bin) { out << "/* Polygon normals for " << bin_name << " */\n"; out << "normal polys_" << bin_name << "[" << num_children << "] = {\n"; - + EggGroupNode::const_iterator ci; size_t prim_index = 0; for (ci = bin->begin(); ci != bin->end(); ++ci) { @@ -350,7 +339,7 @@ write_bin(EggBin *bin) { out << "/* Polygon colors for " << bin_name << " */\n"; out << "color polys_" << bin_name << "[" << num_children << "] = {\n"; - + EggGroupNode::const_iterator ci; size_t prim_index = 0; for (ci = bin->begin(); ci != bin->end(); ++ci) { diff --git a/pandatool/src/eggprogs/eggToC.h b/pandatool/src/eggprogs/eggToC.h index b62218dd0a..9c5f328fa1 100644 --- a/pandatool/src/eggprogs/eggToC.h +++ b/pandatool/src/eggprogs/eggToC.h @@ -1,16 +1,15 @@ -// Filename: eggToC.h -// Created by: drose (03Aug01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToC.h + * @author drose + * @date 2001-08-03 + */ #ifndef EGGTOC_H #define EGGTOC_H @@ -25,10 +24,9 @@ class EggNode; class EggVertexPool; class EggBin; -//////////////////////////////////////////////////////////////////// -// Class : EggToC -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EggToC : public EggToSomething { public: EggToC(); diff --git a/pandatool/src/eggprogs/eggTopstrip.cxx b/pandatool/src/eggprogs/eggTopstrip.cxx index 2b833ce40d..16c7b3371a 100644 --- a/pandatool/src/eggprogs/eggTopstrip.cxx +++ b/pandatool/src/eggprogs/eggTopstrip.cxx @@ -1,16 +1,15 @@ -// Filename: eggTopstrip.cxx -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTopstrip.cxx + * @author drose + * @date 2001-02-23 + */ #include "eggTopstrip.h" @@ -24,11 +23,9 @@ #include "compose_matrix.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTopstrip:: EggTopstrip() { add_path_replace_options(); @@ -80,11 +77,9 @@ EggTopstrip() { _transform_channels = "ijkphrxyz"; } -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggTopstrip:: run() { nassertv(_collection != (EggCharacterCollection *)NULL); @@ -92,17 +87,16 @@ run() { check_transform_channels(); - // Get the number of characters first, in case adding the - // _channel_egg changes this. + // Get the number of characters first, in case adding the _channel_egg + // changes this. int num_characters = _collection->get_num_characters(); - // Determine which model and character we'll be pulling the - // animation channels from. + // Determine which model and character we'll be pulling the animation + // channels from. int from_model = -1; if (!_channel_filename.empty()) { - // Read in the extra egg file that we use for extracting the - // channels out. + // Read in the extra egg file that we use for extracting the channels out. PT(EggData) channel_egg = read_egg(_channel_filename); if (channel_egg == (EggData *)NULL) { nout << "Cannot read " << _channel_filename << "\n"; @@ -133,19 +127,18 @@ run() { EggJointData *root_joint = char_data->get_root_joint(); - // We'll read the transform to apply from this character, which - // will be the same character unless -r was specified. + // We'll read the transform to apply from this character, which will be + // the same character unless -r was specified. EggCharacterData *from_char = char_data; if (from_model != -1) { from_char = _collection->get_character_by_model_index(from_model); } - // Determine which joint we'll use to extract the transform to - // apply. + // Determine which joint we'll use to extract the transform to apply. EggJointData *top_joint = (EggJointData *)NULL; if (_top_joint_name.empty()) { - // The default top joint name is the alphabetically first joint - // in the top level. + // The default top joint name is the alphabetically first joint in the + // top level. if (root_joint->get_num_children() == 0) { nout << "Character " << from_char->get_name() << " has no joints.\n"; exit(1); @@ -167,8 +160,7 @@ run() { strip_anim(char_data, joint_data, from_model, from_char, top_joint, db); } - // We also need to transform the vertices for any models involved - // here. + // We also need to transform the vertices for any models involved here. int num_models = char_data->get_num_models(); for (int m = 0; m < num_models; m++) { EggNode *node = char_data->get_model_root(m); @@ -188,13 +180,10 @@ run() { write_eggs(); } -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::check_transform_channels -// Access: Public -// Description: Checks the _transform_channels string to ensure that -// it contains only the expected nine letters, or a -// subset. -//////////////////////////////////////////////////////////////////// +/** + * Checks the _transform_channels string to ensure that it contains only the + * expected nine letters, or a subset. + */ void EggTopstrip:: check_transform_channels() { static string expected = "ijkphrxyz"; @@ -226,13 +215,10 @@ check_transform_channels() { } -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::strip_anim -// Access: Public -// Description: Applies the channels from joint _top_joint -// in model from_model to the joint referenced by -// joint_data. -//////////////////////////////////////////////////////////////////// +/** + * Applies the channels from joint _top_joint in model from_model to the joint + * referenced by joint_data. + */ void EggTopstrip:: strip_anim(EggCharacterData *char_data, EggJointData *joint_data, int from_model, EggCharacterData *from_char, @@ -273,12 +259,10 @@ strip_anim(EggCharacterData *char_data, EggJointData *joint_data, } } -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::strip_anim_vertices -// Access: Public -// Description: Applies the channels from joint _top_joint -// in model from_model to the vertices at egg_node. -//////////////////////////////////////////////////////////////////// +/** + * Applies the channels from joint _top_joint in model from_model to the + * vertices at egg_node. + */ void EggTopstrip:: strip_anim_vertices(EggNode *egg_node, int into_model, int from_model, EggJointData *top_joint, EggCharacterDb &db) { @@ -296,18 +280,15 @@ strip_anim_vertices(EggNode *egg_node, int into_model, int from_model, } -//////////////////////////////////////////////////////////////////// -// Function: EggTopstrip::adjust_transform -// Access: Public -// Description: Adjust the transform extracted from the "top" joint -// according to the -s and -i/-n options, prior to -// applying it to the skeleton. -//////////////////////////////////////////////////////////////////// +/** + * Adjust the transform extracted from the "top" joint according to the -s and + * -i/-n options, prior to applying it to the skeleton. + */ void EggTopstrip:: adjust_transform(LMatrix4d &mat) const { if (_transform_channels.length() != 9) { - // Decompose and recompose the matrix, so we can eliminate the - // parts the user doesn't want. + // Decompose and recompose the matrix, so we can eliminate the parts the + // user doesn't want. LVecBase3d scale, hpr, translate; bool result = decompose_matrix(mat, scale, hpr, translate, _coordinate_system); diff --git a/pandatool/src/eggprogs/eggTopstrip.h b/pandatool/src/eggprogs/eggTopstrip.h index 7a9a42d5c9..efdd4c0e82 100644 --- a/pandatool/src/eggprogs/eggTopstrip.h +++ b/pandatool/src/eggprogs/eggTopstrip.h @@ -1,16 +1,15 @@ -// Filename: eggTopstrip.h -// Created by: drose (23Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTopstrip.h + * @author drose + * @date 2001-02-23 + */ #ifndef EGGTOPSTRIP_H #define EGGTOPSTRIP_H @@ -27,14 +26,11 @@ class EggCharacterDb; class EggJointData; class EggJointPointer; -//////////////////////////////////////////////////////////////////// -// Class : EggTopstrip -// Description : Reads a character model and/or animations and strips -// out the animation from one of the top joints from the -// entire character. Particularly useful for generating -// stackable character models from separately-extracted -// characters. -//////////////////////////////////////////////////////////////////// +/** + * Reads a character model and/or animations and strips out the animation from + * one of the top joints from the entire character. Particularly useful for + * generating stackable character models from separately-extracted characters. + */ class EggTopstrip : public EggCharacterFilter { public: EggTopstrip(); @@ -60,4 +56,3 @@ public: }; #endif - diff --git a/pandatool/src/eggprogs/eggTrans.cxx b/pandatool/src/eggprogs/eggTrans.cxx index 99481020db..3f86d54903 100644 --- a/pandatool/src/eggprogs/eggTrans.cxx +++ b/pandatool/src/eggprogs/eggTrans.cxx @@ -1,26 +1,23 @@ -// Filename: eggTrans.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTrans.cxx + * @author drose + * @date 2000-02-14 + */ #include "eggTrans.h" #include "eggGroupUniquifier.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggTrans:: EggTrans() { add_path_replace_options(); @@ -78,11 +75,9 @@ EggTrans() { } -//////////////////////////////////////////////////////////////////// -// Function: EggTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggTrans:: run() { if (_remove_invalid_primitives) { diff --git a/pandatool/src/eggprogs/eggTrans.h b/pandatool/src/eggprogs/eggTrans.h index 6b23aefd91..350ece14ab 100644 --- a/pandatool/src/eggprogs/eggTrans.h +++ b/pandatool/src/eggprogs/eggTrans.h @@ -1,16 +1,15 @@ -// Filename: eggTrans.h -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggTrans.h + * @author drose + * @date 2000-02-14 + */ #ifndef EGGTRANS_H #define EGGTRANS_H @@ -19,12 +18,10 @@ #include "eggFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggTrans -// Description : A program to read an egg file and write an equivalent -// egg file, possibly performing some minor operations -// along the way. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write an equivalent egg file, possibly + * performing some minor operations along the way. + */ class EggTrans : public EggFilter { public: EggTrans(); @@ -41,4 +38,3 @@ public: }; #endif - diff --git a/pandatool/src/flt/config_flt.cxx b/pandatool/src/flt/config_flt.cxx index c93592e8ca..1e4f0f9db7 100644 --- a/pandatool/src/flt/config_flt.cxx +++ b/pandatool/src/flt/config_flt.cxx @@ -1,16 +1,15 @@ -// Filename: config_flt.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_flt.cxx + * @author drose + * @date 2000-08-24 + */ #include "config_flt.h" #include "fltRecord.h" @@ -65,14 +64,12 @@ ConfigureFn(config_flt) { init_libflt(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libflt -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libflt() { static bool initialized = false; @@ -113,4 +110,3 @@ init_libflt() { FltTransformRotateScale::init_type(); FltExternalReference::init_type(); } - diff --git a/pandatool/src/flt/config_flt.h b/pandatool/src/flt/config_flt.h index 480a5337e6..789179ce86 100644 --- a/pandatool/src/flt/config_flt.h +++ b/pandatool/src/flt/config_flt.h @@ -1,16 +1,15 @@ -// Filename: config_flt.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_flt.h + * @author drose + * @date 2000-08-24 + */ #ifndef CONFIG_FLT_H #define CONFIG_FLT_H diff --git a/pandatool/src/flt/fltBead.cxx b/pandatool/src/flt/fltBead.cxx index 45bcc455d4..bfa5b3f656 100644 --- a/pandatool/src/flt/fltBead.cxx +++ b/pandatool/src/flt/fltBead.cxx @@ -1,16 +1,15 @@ -// Filename: fltBead.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltBead.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltBead.h" #include "fltRecordReader.h" @@ -30,11 +29,9 @@ TypeHandle FltBead::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltBead::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltBead:: FltBead(FltHeader *header) : FltRecord(header) { _has_transform = false; @@ -42,39 +39,31 @@ FltBead(FltHeader *header) : FltRecord(header) { _replicate_count = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::has_transform -// Access: Public -// Description: Returns true if the bead has been transformed, false -// otherwise. If this returns true, get_transform() -// will return the single-precision net transformation, -// and get_num_transform_steps() will return nonzero. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the bead has been transformed, false otherwise. If this + * returns true, get_transform() will return the single-precision net + * transformation, and get_num_transform_steps() will return nonzero. + */ bool FltBead:: has_transform() const { return _has_transform; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::get_transform -// Access: Public -// Description: Returns the single-precision 4x4 matrix that -// represents the transform applied to this bead, or the -// identity matrix if the bead has not been transformed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the single-precision 4x4 matrix that represents the transform + * applied to this bead, or the identity matrix if the bead has not been + * transformed. + */ const LMatrix4d &FltBead:: get_transform() const { return _has_transform ? _transform : LMatrix4d::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::set_transform -// Access: Public -// Description: Replaces the transform matrix on this bead. This -// implicitly removes all of the transform steps added -// previously, and replaces them with a single 4x4 -// general matrix transform step. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the transform matrix on this bead. This implicitly removes all of + * the transform steps added previously, and replaces them with a single 4x4 + * general matrix transform step. + */ void FltBead:: set_transform(const LMatrix4d &mat) { clear_transform(); @@ -83,12 +72,9 @@ set_transform(const LMatrix4d &mat) { add_transform_step(step); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::clear_transform -// Access: Public -// Description: Removes any transform matrix and all transform steps -// on this bead. -//////////////////////////////////////////////////////////////////// +/** + * Removes any transform matrix and all transform steps on this bead. + */ void FltBead:: clear_transform() { _has_transform = false; @@ -96,28 +82,21 @@ clear_transform() { _transform_steps.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::get_num_transform_steps -// Access: Public -// Description: Returns the number of individual steps that define -// the net transform on this bead as returned by -// set_transform(). Each step is a single -// transformation; the concatenation of all -// transformations will produce the matrix represented -// by set_transform(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of individual steps that define the net transform on + * this bead as returned by set_transform(). Each step is a single + * transformation; the concatenation of all transformations will produce the + * matrix represented by set_transform(). + */ int FltBead:: get_num_transform_steps() const { return _transform_steps.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::get_transform_step -// Access: Public -// Description: Returns the nth individual step that defines -// the net transform on this bead. See -// get_num_transform_steps(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth individual step that defines the net transform on this + * bead. See get_num_transform_steps(). + */ FltTransformRecord *FltBead:: get_transform_step(int n) { nassertr(n >= 0 && n < (int)_transform_steps.size(), @@ -125,13 +104,10 @@ get_transform_step(int n) { return _transform_steps[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::get_transform_step -// Access: Public -// Description: Returns the nth individual step that defines -// the net transform on this bead. See -// get_num_transform_steps(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth individual step that defines the net transform on this + * bead. See get_num_transform_steps(). + */ const FltTransformRecord *FltBead:: get_transform_step(int n) const { nassertr(n >= 0 && n < (int)_transform_steps.size(), @@ -139,12 +115,10 @@ get_transform_step(int n) const { return _transform_steps[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::add_transform_step -// Access: Public -// Description: Applies the indicated transform step to the net -// transformation applied to the bead. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated transform step to the net transformation applied to + * the bead. + */ void FltBead:: add_transform_step(FltTransformRecord *record) { if (!_has_transform) { @@ -156,42 +130,33 @@ add_transform_step(FltTransformRecord *record) { _transform_steps.push_back(record); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::get_replicate_count -// Access: Public -// Description: Returns the replicate count of this bead. If this is -// nonzero, it means that the bead is implicitly copied -// this number of additional times (for replicate_count -// + 1 total copies), applying the transform on this -// bead for each copy. In this case, the transform does -// *not* apply to the initial copy of the bead. -//////////////////////////////////////////////////////////////////// +/** + * Returns the replicate count of this bead. If this is nonzero, it means + * that the bead is implicitly copied this number of additional times (for + * replicate_count + 1 total copies), applying the transform on this bead for + * each copy. In this case, the transform does *not* apply to the initial + * copy of the bead. + */ int FltBead:: get_replicate_count() const { return _replicate_count; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::set_replicate_count -// Access: Public -// Description: Changes the replicate count of this bead. If you are -// setting the replicate count to some nonzero number, -// you must also set a transform on the bead. See -// set_replicate_count(). -//////////////////////////////////////////////////////////////////// +/** + * Changes the replicate count of this bead. If you are setting the replicate + * count to some nonzero number, you must also set a transform on the bead. + * See set_replicate_count(). + */ void FltBead:: set_replicate_count(int count) { _replicate_count = count; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltBead:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -200,15 +165,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::extract_ancillary -// Access: Protected, Virtual -// Description: Checks whether the given bead, which follows this -// bead sequentially in the file, is an ancillary record -// of this bead. If it is, extracts the relevant -// information and returns true; otherwise, leaves it -// alone and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the given bead, which follows this bead sequentially in the + * file, is an ancillary record of this bead. If it is, extracts the relevant + * information and returns true; otherwise, leaves it alone and returns false. + */ bool FltBead:: extract_ancillary(FltRecordReader &reader) { FltTransformRecord *step = (FltTransformRecord *)NULL; @@ -262,14 +223,11 @@ extract_ancillary(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltBead:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -278,13 +236,10 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::write_ancillary -// Access: Protected, Virtual -// Description: Writes whatever ancillary records are required for -// this record. Returns FE_ok on success, or something -// else if there is some error. -//////////////////////////////////////////////////////////////////// +/** + * Writes whatever ancillary records are required for this record. Returns + * FE_ok on success, or something else if there is some error. + */ FltError FltBead:: write_ancillary(FltRecordWriter &writer) const { if (_has_transform) { @@ -304,15 +259,11 @@ write_ancillary(FltRecordWriter &writer) const { return FltRecord::write_ancillary(writer); } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::extract_transform_matrix -// Access: Private -// Description: Reads a transform matrix ancillary bead. This -// defines the net transformation that has been applied -// to the bead, and precedes the set of individual -// transform steps that define how this net transform -// was computed. -//////////////////////////////////////////////////////////////////// +/** + * Reads a transform matrix ancillary bead. This defines the net + * transformation that has been applied to the bead, and precedes the set of + * individual transform steps that define how this net transform was computed. + */ bool FltBead:: extract_transform_matrix(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_transform_matrix, false); @@ -333,11 +284,9 @@ extract_transform_matrix(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::extract_replicate_count -// Access: Private -// Description: Reads a replicate count ancillary bead. -//////////////////////////////////////////////////////////////////// +/** + * Reads a replicate count ancillary bead. + */ bool FltBead:: extract_replicate_count(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_replicate, false); @@ -350,12 +299,9 @@ extract_replicate_count(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::write_transform -// Access: Private -// Description: Writes out the transformation and all of its defining -// steps. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the transformation and all of its defining steps. + */ FltError FltBead:: write_transform(FltRecordWriter &writer) const { // First, write out the initial transform indication. @@ -389,11 +335,9 @@ write_transform(FltRecordWriter &writer) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltBead::write_replicate_count -// Access: Private -// Description: Writes out the replicate count, if needed. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the replicate count, if needed. + */ FltError FltBead:: write_replicate_count(FltRecordWriter &writer) const { if (_replicate_count != 0) { diff --git a/pandatool/src/flt/fltBead.h b/pandatool/src/flt/fltBead.h index 3785f4ee60..d1b98779d9 100644 --- a/pandatool/src/flt/fltBead.h +++ b/pandatool/src/flt/fltBead.h @@ -1,16 +1,15 @@ -// Filename: fltBead.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltBead.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTBEAD_H #define FLTBEAD_H @@ -22,14 +21,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltBead -// Description : A base class for any of a broad family of flt records -// that represent particular beads in the hierarchy. -// These are things like group beads and object beads, -// as opposed to things like push and pop or comment -// records. -//////////////////////////////////////////////////////////////////// +/** + * A base class for any of a broad family of flt records that represent + * particular beads in the hierarchy. These are things like group beads and + * object beads, as opposed to things like push and pop or comment records. + */ class FltBead : public FltRecord { public: FltBead(FltHeader *header); @@ -89,5 +85,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltBeadID.cxx b/pandatool/src/flt/fltBeadID.cxx index a423869904..6346d6282e 100644 --- a/pandatool/src/flt/fltBeadID.cxx +++ b/pandatool/src/flt/fltBeadID.cxx @@ -1,16 +1,15 @@ -// Filename: fltBeadID.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltBeadID.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltBeadID.h" #include "fltRecordReader.h" @@ -18,45 +17,36 @@ TypeHandle FltBeadID::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltBeadID:: FltBeadID(FltHeader *header) : FltBead(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::get_id -// Access: Public -// Description: Returns the id (name) of this particular bead. Each -// MultiGen bead will have a unique name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the id (name) of this particular bead. Each MultiGen bead will + * have a unique name. + */ const string &FltBeadID:: get_id() const { return _id; } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::set_id -// Access: Public -// Description: Changes the id (name) of this particular bead. This -// should be a name that is unique to this bead. -//////////////////////////////////////////////////////////////////// +/** + * Changes the id (name) of this particular bead. This should be a name that + * is unique to this bead. + */ void FltBeadID:: set_id(const string &id) { _id = id; } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::output -// Access: Public -// Description: Writes a quick one-line description of the record, but -// not its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a quick one-line description of the record, but not its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltBeadID:: output(ostream &out) const { out << get_type(); @@ -65,14 +55,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltBeadID:: extract_record(FltRecordReader &reader) { if (!FltBead::extract_record(reader)) { @@ -83,15 +70,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::extract_ancillary -// Access: Protected, Virtual -// Description: Checks whether the given bead, which follows this -// bead sequentially in the file, is an ancillary record -// of this bead. If it is, extracts the relevant -// information and returns true; otherwise, leaves it -// alone and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the given bead, which follows this bead sequentially in the + * file, is an ancillary record of this bead. If it is, extracts the relevant + * information and returns true; otherwise, leaves it alone and returns false. + */ bool FltBeadID:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_long_id) { @@ -104,14 +87,11 @@ extract_ancillary(FltRecordReader &reader) { return FltBead::extract_ancillary(reader); } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltBeadID:: build_record(FltRecordWriter &writer) const { if (!FltBead::build_record(writer)) { @@ -122,19 +102,16 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltBeadID::write_ancillary -// Access: Protected, Virtual -// Description: Writes whatever ancillary records are required for -// this record. Returns FE_ok on success, or something -// else if there is some error. -//////////////////////////////////////////////////////////////////// +/** + * Writes whatever ancillary records are required for this record. Returns + * FE_ok on success, or something else if there is some error. + */ FltError FltBeadID:: write_ancillary(FltRecordWriter &writer) const { if (_id.length() > 7) { - // Although the manual mentions nothing of this, it is essential - // that the length of the record be a multiple of 4 bytes. + // Although the manual mentions nothing of this, it is essential that the + // length of the record be a multiple of 4 bytes. string id = _id; while ((id.length() % 4) != 0) { id += '\0'; diff --git a/pandatool/src/flt/fltBeadID.h b/pandatool/src/flt/fltBeadID.h index 4512b66b55..c14b82b4a3 100644 --- a/pandatool/src/flt/fltBeadID.h +++ b/pandatool/src/flt/fltBeadID.h @@ -1,16 +1,15 @@ -// Filename: fltBeadID.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltBeadID.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTBEADID_H #define FLTBEADID_H @@ -19,11 +18,9 @@ #include "fltBead.h" -//////////////////////////////////////////////////////////////////// -// Class : FltBeadID -// Description : A base class for any of a broad family of flt beads -// that include an ID. -//////////////////////////////////////////////////////////////////// +/** + * A base class for any of a broad family of flt beads that include an ID. + */ class FltBeadID : public FltBead { public: FltBeadID(FltHeader *header); @@ -62,5 +59,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltCurve.I b/pandatool/src/flt/fltCurve.I index 76f25d1dc6..cb3d37d263 100644 --- a/pandatool/src/flt/fltCurve.I +++ b/pandatool/src/flt/fltCurve.I @@ -1,34 +1,27 @@ -// Filename: fltCurve.I -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltCurve.I + * @author drose + * @date 2001-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FltCurve::get_num_control_points -// Access: Public -// Description: Returns the number of control points assigned to the -// curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of control points assigned to the curve. + */ INLINE int FltCurve:: get_num_control_points() const { return _control_points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltCurve::get_control_point -// Access: Public -// Description: Returns the nth control point assigned to the curve. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth control point assigned to the curve. + */ INLINE const LPoint3d &FltCurve:: get_control_point(int n) const { #ifndef NDEBUG diff --git a/pandatool/src/flt/fltCurve.cxx b/pandatool/src/flt/fltCurve.cxx index 997c48b374..d9b3ae8b2d 100644 --- a/pandatool/src/flt/fltCurve.cxx +++ b/pandatool/src/flt/fltCurve.cxx @@ -1,16 +1,15 @@ -// Filename: fltCurve.cxx -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltCurve.cxx + * @author drose + * @date 2001-02-28 + */ #include "fltCurve.h" #include "fltRecordReader.h" @@ -20,24 +19,19 @@ TypeHandle FltCurve::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltCurve::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltCurve:: FltCurve(FltHeader *header) : FltBeadID(header) { _curve_type = CT_b_spline; } -//////////////////////////////////////////////////////////////////// -// Function: FltCurve::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltCurve:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -63,14 +57,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltCurve::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltCurve:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { diff --git a/pandatool/src/flt/fltCurve.h b/pandatool/src/flt/fltCurve.h index ef3ed5db1f..79f19daf91 100644 --- a/pandatool/src/flt/fltCurve.h +++ b/pandatool/src/flt/fltCurve.h @@ -1,16 +1,15 @@ -// Filename: fltCurve.h -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltCurve.h + * @author drose + * @date 2001-02-28 + */ #ifndef FLTCURVE_H #define FLTCURVE_H @@ -22,10 +21,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltCurve -// Description : A single curve, like a Bezier or B-Spline. -//////////////////////////////////////////////////////////////////// +/** + * A single curve, like a Bezier or B-Spline. + */ class FltCurve : public FltBeadID { public: FltCurve(FltHeader *header); @@ -71,5 +69,3 @@ private: #include "fltCurve.I" #endif - - diff --git a/pandatool/src/flt/fltError.cxx b/pandatool/src/flt/fltError.cxx index 9a77a258a3..fe9cf918bb 100644 --- a/pandatool/src/flt/fltError.cxx +++ b/pandatool/src/flt/fltError.cxx @@ -1,16 +1,15 @@ -// Filename: fltError.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltError.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltError.h" diff --git a/pandatool/src/flt/fltError.h b/pandatool/src/flt/fltError.h index 25efd4eae0..5d4ac08165 100644 --- a/pandatool/src/flt/fltError.h +++ b/pandatool/src/flt/fltError.h @@ -1,16 +1,15 @@ -// Filename: fltError.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltError.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTERROR_H #define FLTERROR_H @@ -36,6 +35,3 @@ enum FltError { ostream &operator << (ostream &out, FltError error); #endif - - - diff --git a/pandatool/src/flt/fltExternalReference.cxx b/pandatool/src/flt/fltExternalReference.cxx index ff4047bb90..1780e577ba 100644 --- a/pandatool/src/flt/fltExternalReference.cxx +++ b/pandatool/src/flt/fltExternalReference.cxx @@ -1,16 +1,15 @@ -// Filename: fltExternalReference.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltExternalReference.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltExternalReference.h" #include "fltRecordReader.h" @@ -20,39 +19,31 @@ TypeHandle FltExternalReference::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltExternalReference:: FltExternalReference(FltHeader *header) : FltBead(header) { _flags = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::apply_converted_filenames -// Access: Public, Virtual -// Description: Walks the hierarchy at this record and below and -// copies the _converted_filename record into the -// _orig_filename record, so the flt file will be -// written out with the converted filename instead of -// what was originally read in. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy at this record and below and copies the + * _converted_filename record into the _orig_filename record, so the flt file + * will be written out with the converted filename instead of what was + * originally read in. + */ void FltExternalReference:: apply_converted_filenames() { _orig_filename = _converted_filename.to_os_generic(); FltBead::apply_converted_filenames(); } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::output -// Access: Public, Virtual -// Description: Writes a quick one-line description of the record, but -// not its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a quick one-line description of the record, but not its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltExternalReference:: output(ostream &out) const { out << "External " << get_ref_filename(); @@ -61,35 +52,28 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::get_ref_filename -// Access: Public -// Description: Returns the name of the referenced file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the referenced file. + */ Filename FltExternalReference:: get_ref_filename() const { return _converted_filename; } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::set_ref_filename -// Access: Public -// Description: Changes the name of the referenced file. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the referenced file. + */ void FltExternalReference:: set_ref_filename(const Filename &filename) { - _converted_filename = filename; + _converted_filename = filename; _orig_filename = _converted_filename.to_os_generic(); } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltExternalReference:: extract_record(FltRecordReader &reader) { if (!FltBead::extract_record(reader)) { @@ -122,14 +106,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltExternalReference::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltExternalReference:: build_record(FltRecordWriter &writer) const { if (!FltBead::build_record(writer)) { diff --git a/pandatool/src/flt/fltExternalReference.h b/pandatool/src/flt/fltExternalReference.h index c8aa7b07a0..5afe57d091 100644 --- a/pandatool/src/flt/fltExternalReference.h +++ b/pandatool/src/flt/fltExternalReference.h @@ -1,16 +1,15 @@ -// Filename: fltExternalReference.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltExternalReference.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTEXTERNALREFERENCE_H #define FLTEXTERNALREFERENCE_H @@ -21,11 +20,10 @@ #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : FltExternalReference -// Description : An external reference to another flt file (possibly -// to a specific bead within the flt file). -//////////////////////////////////////////////////////////////////// +/** + * An external reference to another flt file (possibly to a specific bead + * within the flt file). + */ class FltExternalReference : public FltBead { public: FltExternalReference(FltHeader *header); @@ -73,5 +71,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltEyepoint.cxx b/pandatool/src/flt/fltEyepoint.cxx index c63d1312a7..068fc4eeac 100644 --- a/pandatool/src/flt/fltEyepoint.cxx +++ b/pandatool/src/flt/fltEyepoint.cxx @@ -1,26 +1,23 @@ -// Filename: fltEyepoint.cxx -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltEyepoint.cxx + * @author drose + * @date 2000-08-26 + */ #include "fltEyepoint.h" #include "fltRecordReader.h" #include "fltRecordWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: FltEyepoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltEyepoint:: FltEyepoint() { _rotation_center.set(0.0, 0.0, 0.0); @@ -43,11 +40,9 @@ FltEyepoint() { _image_zoom = 1; } -//////////////////////////////////////////////////////////////////// -// Function: FltEyepoint::extract_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltEyepoint:: extract_record(FltRecordReader &reader) { DatagramIterator &iterator = reader.get_iterator(); @@ -92,11 +87,9 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltEyepoint::build_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltEyepoint:: build_record(FltRecordWriter &writer) const { Datagram &datagram = writer.update_datagram(); diff --git a/pandatool/src/flt/fltEyepoint.h b/pandatool/src/flt/fltEyepoint.h index 44f950371d..bef59fee8f 100644 --- a/pandatool/src/flt/fltEyepoint.h +++ b/pandatool/src/flt/fltEyepoint.h @@ -1,16 +1,15 @@ -// Filename: fltEyepoint.h -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltEyepoint.h + * @author drose + * @date 2000-08-26 + */ #ifndef FLTEYEPOINT_H #define FLTEYEPOINT_H @@ -22,11 +21,9 @@ class FltRecordReader; class FltRecordWriter; -//////////////////////////////////////////////////////////////////// -// Class : FltEyepoint -// Description : A single eyepoint entry in the eyepoint/trackplane -// palette. -//////////////////////////////////////////////////////////////////// +/** + * A single eyepoint entry in the eyepoint/trackplane palette. + */ class FltEyepoint { public: FltEyepoint(); @@ -56,6 +53,3 @@ public: }; #endif - - - diff --git a/pandatool/src/flt/fltFace.I b/pandatool/src/flt/fltFace.I index 10a3260706..934927d750 100644 --- a/pandatool/src/flt/fltFace.I +++ b/pandatool/src/flt/fltFace.I @@ -1,14 +1,12 @@ -// Filename: fltFace.I -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltFace.I + * @author drose + * @date 2000-08-30 + */ diff --git a/pandatool/src/flt/fltFace.cxx b/pandatool/src/flt/fltFace.cxx index c657421c6a..8770d3b62a 100644 --- a/pandatool/src/flt/fltFace.cxx +++ b/pandatool/src/flt/fltFace.cxx @@ -1,16 +1,15 @@ -// Filename: fltFace.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltFace.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltFace.h" #include "fltRecordReader.h" @@ -20,23 +19,18 @@ TypeHandle FltFace::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltFace::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltFace:: FltFace(FltHeader *header) : FltGeometry(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltFace::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltFace:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -53,14 +47,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltFace::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltFace:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { diff --git a/pandatool/src/flt/fltFace.h b/pandatool/src/flt/fltFace.h index cae75f9ac2..404a49663e 100644 --- a/pandatool/src/flt/fltFace.h +++ b/pandatool/src/flt/fltFace.h @@ -1,16 +1,15 @@ -// Filename: fltFace.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltFace.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTFACE_H #define FLTFACE_H @@ -19,10 +18,9 @@ #include "fltGeometry.h" -//////////////////////////////////////////////////////////////////// -// Class : FltFace -// Description : A single face bead, e.g. a polygon. -//////////////////////////////////////////////////////////////////// +/** + * A single face bead, e.g. a polygon. + */ class FltFace : public FltGeometry { public: FltFace(FltHeader *header); @@ -53,5 +51,3 @@ private: #include "fltFace.I" #endif - - diff --git a/pandatool/src/flt/fltGeometry.I b/pandatool/src/flt/fltGeometry.I index a5fe2a256d..3c4fae7918 100644 --- a/pandatool/src/flt/fltGeometry.I +++ b/pandatool/src/flt/fltGeometry.I @@ -1,46 +1,37 @@ -// Filename: fltGeometry.I -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltGeometry.I + * @author drose + * @date 2001-02-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::has_texture -// Access: Public -// Description: Returns true if the face has a texture applied, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the face has a texture applied, false otherwise. + */ INLINE bool FltGeometry:: has_texture() const { return (_texture_index >= 0 && _header->has_texture(_texture_index)); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_texture -// Access: Public -// Description: Returns the texture applied to this face, or NULL if -// no texture was applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture applied to this face, or NULL if no texture was + * applied. + */ INLINE FltTexture *FltGeometry:: get_texture() const { return _header->get_texture(_texture_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::set_texture -// Access: Public -// Description: Applies the indicated texture to this face, or if the -// texture is NULL, clears it. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated texture to this face, or if the texture is NULL, + * clears it. + */ INLINE void FltGeometry:: set_texture(FltTexture *texture) { if (texture == (FltTexture *)NULL) { @@ -51,34 +42,27 @@ set_texture(FltTexture *texture) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::has_material -// Access: Public -// Description: Returns true if the face has a material applied, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the face has a material applied, false otherwise. + */ INLINE bool FltGeometry:: has_material() const { return (_material_index >= 0 && _header->has_material(_material_index)); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_material -// Access: Public -// Description: Returns the material applied to this face, or NULL if -// no material was applied. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material applied to this face, or NULL if no material was + * applied. + */ INLINE FltMaterial *FltGeometry:: get_material() const { return _header->get_material(_material_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::set_material -// Access: Public -// Description: Applies the indicated material to this face, or if the -// material is NULL, clears it. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated material to this face, or if the material is NULL, + * clears it. + */ INLINE void FltGeometry:: set_material(FltMaterial *material) { if (material == (FltMaterial *)NULL) { @@ -89,18 +73,14 @@ set_material(FltMaterial *material) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::has_color -// Access: Public -// Description: Returns true if the face has a primary color -// indicated, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the face has a primary color indicated, false otherwise. + */ INLINE bool FltGeometry:: has_color() const { - // Even if the no_color bit is not set, if the color_index is -1, - // the face doesn't have a color (unless we've got packed color). - // On the other hand, if we have a material than we always have - // color. + // Even if the no_color bit is not set, if the color_index is -1, the face + // doesn't have a color (unless we've got packed color). On the other hand, + // if we have a material than we always have color. return ((_flags & F_no_color) == 0 && (_color_index != -1 || ((_flags & F_packed_color) != 0))) || has_material(); diff --git a/pandatool/src/flt/fltGeometry.cxx b/pandatool/src/flt/fltGeometry.cxx index ffe7f93d2c..25820487ea 100644 --- a/pandatool/src/flt/fltGeometry.cxx +++ b/pandatool/src/flt/fltGeometry.cxx @@ -1,16 +1,15 @@ -// Filename: fltGeometry.cxx -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltGeometry.cxx + * @author drose + * @date 2001-02-28 + */ #include "fltGeometry.h" #include "fltRecordReader.h" @@ -20,11 +19,9 @@ TypeHandle FltGeometry::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltGeometry:: FltGeometry(FltHeader *header) : FltBeadID(header) { _ir_color = 0; @@ -51,16 +48,13 @@ FltGeometry(FltHeader *header) : FltBeadID(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_color -// Access: Public -// Description: Returns the primary color of the face, as a -// four-component value (including alpha as the -// transparency channel). -// -// If has_color() is false, the result is white, but -// still reflects the transparency correctly. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primary color of the face, as a four-component value (including + * alpha as the transparency channel). + * + * If has_color() is false, the result is white, but still reflects the + * transparency correctly. + */ LColor FltGeometry:: get_color() const { LColor color; @@ -90,24 +84,19 @@ get_color() const { return color; } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::set_color -// Access: Public -// Description: Sets the primary color of the face, using the packed -// color convention. -//////////////////////////////////////////////////////////////////// +/** + * Sets the primary color of the face, using the packed color convention. + */ void FltGeometry:: set_color(const LColor &color) { set_rgb(LRGBColor(color[0], color[1], color[2])); _transparency = (int)floor((1.0 - color[3]) * 65535.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_rgb -// Access: Public -// Description: Returns the primary color of the face, as a -// three-component value ignoring transparency. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primary color of the face, as a three-component value ignoring + * transparency. + */ LRGBColor FltGeometry:: get_rgb() const { if (!has_color() || (_texwhite && has_texture())) { @@ -125,12 +114,10 @@ get_rgb() const { _packed_color); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::set_rgb -// Access: Public -// Description: Sets the primary color of the face, using the packed -// color convention; does not affect transparency. -//////////////////////////////////////////////////////////////////// +/** + * Sets the primary color of the face, using the packed color convention; does + * not affect transparency. + */ void FltGeometry:: set_rgb(const LRGBColor &rgb) { _packed_color.set_rgb(rgb); @@ -141,24 +128,18 @@ set_rgb(const LRGBColor &rgb) { _texwhite = false; } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::has_alt_color -// Access: Public -// Description: Returns true if the face has an alternate color -// indicated, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the face has an alternate color indicated, false otherwise. + */ bool FltGeometry:: has_alt_color() const { return (_flags & F_no_alt_color) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_alt_color -// Access: Public -// Description: If has_alt_color() indicates true, returns the alternate -// color of the face, as a four-component value -// (including alpha as the transparency channel). -//////////////////////////////////////////////////////////////////// +/** + * If has_alt_color() indicates true, returns the alternate color of the face, + * as a four-component value (including alpha as the transparency channel). + */ LColor FltGeometry:: get_alt_color() const { nassertr(has_alt_color(), LColor(0.0, 0.0, 0.0, 0.0)); @@ -167,13 +148,10 @@ get_alt_color() const { _alt_packed_color, _transparency); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::get_alt_rgb -// Access: Public -// Description: If has_alt_color() indicates true, returns the alternate -// color of the face, as a three-component value -// ignoring transparency. -//////////////////////////////////////////////////////////////////// +/** + * If has_alt_color() indicates true, returns the alternate color of the face, + * as a three-component value ignoring transparency. + */ LRGBColor FltGeometry:: get_alt_rgb() const { nassertr(has_alt_color(), LRGBColor(0.0, 0.0, 0.0)); @@ -182,14 +160,11 @@ get_alt_rgb() const { _alt_packed_color); } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltGeometry:: extract_record(FltRecordReader &reader) { DatagramIterator &iterator = reader.get_iterator(); @@ -223,7 +198,7 @@ extract_record(FltRecordReader &reader) { if (!_alt_packed_color.extract_record(reader)) { return false; } - + if (_header->get_flt_version() >= 1520) { _texture_mapping_index = iterator.get_be_int16(); iterator.skip_bytes(2); @@ -236,14 +211,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltGeometry::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltGeometry:: build_record(FltRecordWriter &writer) const { Datagram &datagram = writer.update_datagram(); diff --git a/pandatool/src/flt/fltGeometry.h b/pandatool/src/flt/fltGeometry.h index 97007d8f44..f8041f1079 100644 --- a/pandatool/src/flt/fltGeometry.h +++ b/pandatool/src/flt/fltGeometry.h @@ -1,16 +1,15 @@ -// Filename: fltGeometry.h -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltGeometry.h + * @author drose + * @date 2001-02-28 + */ #ifndef FLTGEOMETRY_H #define FLTGEOMETRY_H @@ -26,13 +25,11 @@ class FltTexture; class FltMaterial; -//////////////////////////////////////////////////////////////////// -// Class : FltGeometry -// Description : This is a base class for both FltFace and FltMesh, -// which are two different kinds of geometric primitives -// that might be encountered in a MultiGen file. They -// have similar properties. -//////////////////////////////////////////////////////////////////// +/** + * This is a base class for both FltFace and FltMesh, which are two different + * kinds of geometric primitives that might be encountered in a MultiGen file. + * They have similar properties. + */ class FltGeometry : public FltBeadID { public: FltGeometry(FltHeader *header); @@ -140,5 +137,3 @@ private: #include "fltGeometry.I" #endif - - diff --git a/pandatool/src/flt/fltGroup.cxx b/pandatool/src/flt/fltGroup.cxx index 0edd1265ad..c194769f74 100644 --- a/pandatool/src/flt/fltGroup.cxx +++ b/pandatool/src/flt/fltGroup.cxx @@ -1,16 +1,15 @@ -// Filename: fltGroup.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltGroup.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltGroup.h" #include "fltRecordReader.h" @@ -19,11 +18,9 @@ TypeHandle FltGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltGroup::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltGroup:: FltGroup(FltHeader *header) : FltBeadID(header) { _relative_priority = 0; @@ -34,14 +31,11 @@ FltGroup(FltHeader *header) : FltBeadID(header) { _layer_id = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltGroup::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltGroup:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -67,14 +61,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltGroup::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltGroup:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { diff --git a/pandatool/src/flt/fltGroup.h b/pandatool/src/flt/fltGroup.h index d467bdb6ad..c1f38198c1 100644 --- a/pandatool/src/flt/fltGroup.h +++ b/pandatool/src/flt/fltGroup.h @@ -1,16 +1,15 @@ -// Filename: fltGroup.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltGroup.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTGROUP_H #define FLTGROUP_H @@ -19,10 +18,9 @@ #include "fltBeadID.h" -//////////////////////////////////////////////////////////////////// -// Class : FltGroup -// Description : The main grouping bead of the flt file. -//////////////////////////////////////////////////////////////////// +/** + * The main grouping bead of the flt file. + */ class FltGroup : public FltBeadID { public: FltGroup(FltHeader *header); @@ -64,5 +62,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index db47a57ed0..062afe15fa 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -1,16 +1,15 @@ -// Filename: fltHeader.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltHeader.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltHeader.h" #include "fltRecordReader.h" @@ -26,21 +25,16 @@ TypeHandle FltHeader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::Constructor -// Access: Public -// Description: The FltHeader constructor accepts a PathReplace -// pointer; it uses this object to automatically convert -// all external filename and texture references. (This -// is necessary because the FltHeader has to look in the -// same directory as the texture to find the .attr file, -// so it must pre-convert at least the texture -// references.) -// -// Most of the other file converters do not have this -// requirement, so they do not need to pre-convert any -// pathname references. -//////////////////////////////////////////////////////////////////// +/** + * The FltHeader constructor accepts a PathReplace pointer; it uses this + * object to automatically convert all external filename and texture + * references. (This is necessary because the FltHeader has to look in the + * same directory as the texture to find the .attr file, so it must pre- + * convert at least the texture references.) + * + * Most of the other file converters do not have this requirement, so they do + * not need to pre-convert any pathname references. + */ FltHeader:: FltHeader(PathReplace *path_replace) : FltBeadID(this) { if (path_replace == (PathReplace *)NULL) { @@ -109,15 +103,12 @@ FltHeader(PathReplace *path_replace) : FltBeadID(this) { _auto_attr_update = AU_if_missing; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::apply_converted_filenames -// Access: Public, Virtual -// Description: Walks the hierarchy at this record and below and -// copies the _converted_filename record into the -// _orig_filename record, so the flt file will be -// written out with the converted filename instead of -// what was originally read in. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy at this record and below and copies the + * _converted_filename record into the _orig_filename record, so the flt file + * will be written out with the converted filename instead of what was + * originally read in. + */ void FltHeader:: apply_converted_filenames() { Textures::const_iterator ti; @@ -129,51 +120,39 @@ apply_converted_filenames() { FltBeadID::apply_converted_filenames(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::set_path_replace -// Access: Public -// Description: Replaces the PathReplace object (which specifies how -// to mangle paths from the source to the destination -// file) with a new one. -//////////////////////////////////////////////////////////////////// +/** + * Replaces the PathReplace object (which specifies how to mangle paths from + * the source to the destination file) with a new one. + */ void FltHeader:: set_path_replace(PathReplace *path_replace) { _path_replace = path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_path_replace -// Access: Public -// Description: Returns a pointer to the PathReplace object -// associated with this converter. If the converter is -// non-const, this returns a non-const pointer, which -// can be adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PathReplace object associated with this converter. + * If the converter is non-const, this returns a non-const pointer, which can + * be adjusted. + */ PathReplace *FltHeader:: get_path_replace() { return _path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_path_replace -// Access: Public -// Description: Returns a pointer to the PathReplace object -// associated with this converter. If the converter is -// non-const, this returns a non-const pointer, which -// can be adjusted. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the PathReplace object associated with this converter. + * If the converter is non-const, this returns a non-const pointer, which can + * be adjusted. + */ const PathReplace *FltHeader:: get_path_replace() const { return _path_replace; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::convert_path -// Access: Public -// Description: Uses the PathReplace object to convert the named -// filename as read from the flt record to its actual -// name. -//////////////////////////////////////////////////////////////////// +/** + * Uses the PathReplace object to convert the named filename as read from the + * flt record to its actual name. + */ Filename FltHeader:: convert_path(const Filename &orig_filename, const DSearchPath &additional_path) { DSearchPath file_path; @@ -184,36 +163,27 @@ convert_path(const Filename &orig_filename, const DSearchPath &additional_path) return _path_replace->convert_path(orig_filename, file_path); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::set_flt_filename -// Access: Public -// Description: Sets the filename--especially the directory part--in -// which the flt file is considered to reside. This is -// also implicitly set by read_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the filename--especially the directory part--in which the flt file is + * considered to reside. This is also implicitly set by read_flt(). + */ void FltHeader:: set_flt_filename(const Filename &flt_filename) { _flt_filename = flt_filename; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_flt_filename -// Access: Public -// Description: Returns the directory in which the flt file is -// considered to reside. -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory in which the flt file is considered to reside. + */ const Filename &FltHeader:: get_flt_filename() const { return _flt_filename; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::read_flt -// Access: Public -// Description: Opens the indicated filename for reading and attempts -// to read the complete Flt file. Returns FE_ok on -// success, otherwise on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for reading and attempts to read the complete + * Flt file. Returns FE_ok on success, otherwise on failure. + */ FltError FltHeader:: read_flt(Filename filename) { filename.set_binary(); @@ -230,13 +200,10 @@ read_flt(Filename filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::read_flt -// Access: Public -// Description: Attempts to read a complete Flt file from the -// already-opened stream. Returns FE_ok on success, -// otherwise on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to read a complete Flt file from the already-opened stream. + * Returns FE_ok on success, otherwise on failure. + */ FltError FltHeader:: read_flt(istream &in) { FltRecordReader reader(in); @@ -262,13 +229,10 @@ read_flt(istream &in) { } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_flt -// Access: Public -// Description: Opens the indicated filename for writing and attempts -// to write the complete Flt file. Returns FE_ok on -// success, otherwise on failure. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for writing and attempts to write the complete + * Flt file. Returns FE_ok on success, otherwise on failure. + */ FltError FltHeader:: write_flt(Filename filename) { filename.set_binary(); @@ -281,8 +245,8 @@ write_flt(Filename filename) { #ifdef HAVE_ZLIB if (filename.get_extension() == "pz") { - // The filename ends in .pz, which means to automatically compress - // the flt file that we write. + // The filename ends in .pz, which means to automatically compress the flt + // file that we write. OCompressStream compressor(&out, false); return write_flt(compressor); } @@ -291,13 +255,10 @@ write_flt(Filename filename) { return write_flt(out); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_flt -// Access: Public -// Description: Attempts to write a complete Flt file to the -// already-opened stream. Returns FE_ok on success, -// otherwise on failure. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to write a complete Flt file to the already-opened stream. + * Returns FE_ok on success, otherwise on failure. + */ FltError FltHeader:: write_flt(ostream &out) { FltRecordWriter writer(out); @@ -310,51 +271,40 @@ write_flt(ostream &out) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::set_auto_attr_update -// Access: Public -// Description: Controls whether texture .attr files are written -// automatically when write_flt() is called. There are -// three possibilities: -// -// AU_none: the .attr files are not written -// automatically; they must be written explicitly via a -// call to FltTexture::write_attr_data() if you want -// them to be written. -// -// AU_if_missing: the .attr files are written only if -// they do not already exist. This will not update any -// .attr files, even if the data is changed. -// -// AU_always: the .attr files are always rewritten, even -// if they already exist and even if the data has not -// changed. -// -// The default is AU_if_missing. -//////////////////////////////////////////////////////////////////// +/** + * Controls whether texture .attr files are written automatically when + * write_flt() is called. There are three possibilities: + * + * AU_none: the .attr files are not written automatically; they must be + * written explicitly via a call to FltTexture::write_attr_data() if you want + * them to be written. + * + * AU_if_missing: the .attr files are written only if they do not already + * exist. This will not update any .attr files, even if the data is changed. + * + * AU_always: the .attr files are always rewritten, even if they already exist + * and even if the data has not changed. + * + * The default is AU_if_missing. + */ void FltHeader:: set_auto_attr_update(FltHeader::AttrUpdate attr) { _auto_attr_update = attr; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_auto_attr_update -// Access: Public -// Description: Returns the current setting of the auto_attr_update -// flag. See sett_auto_attr_update(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the auto_attr_update flag. See + * sett_auto_attr_update(). + */ FltHeader::AttrUpdate FltHeader:: get_auto_attr_update() const { return _auto_attr_update; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_flt_version -// Access: Public -// Description: Returns the version number of the flt file as -// reported in the header, times 100. Divide by 100 to -// get the floating-point version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version number of the flt file as reported in the header, times + * 100. Divide by 100 to get the floating-point version number. + */ int FltHeader:: get_flt_version() const { if (_format_revision_level < 1420) { @@ -364,13 +314,10 @@ get_flt_version() const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::set_flt_version -// Access: Public -// Description: Changes the version number of the flt file that will -// be reported in the header. Pass in the -// floating-point version number times 100. -//////////////////////////////////////////////////////////////////// +/** + * Changes the version number of the flt file that will be reported in the + * header. Pass in the floating-point version number times 100. + */ void FltHeader:: set_flt_version(int version) { if (version < 14.2) { @@ -380,40 +327,32 @@ set_flt_version(int version) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::min_flt_version -// Access: Public, Static -// Description: Returns the earliest flt version number that this -// codebase supports (times 100). Earlier versions will -// probably not work. -//////////////////////////////////////////////////////////////////// +/** + * Returns the earliest flt version number that this codebase supports (times + * 100). Earlier versions will probably not work. + */ int FltHeader:: min_flt_version() { return 1400; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::max_flt_version -// Access: Public, Static -// Description: Returns the latest flt version number that this -// codebase is known to support (times 100). Later -// versions might work, but then again they may not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the latest flt version number that this codebase is known to + * support (times 100). Later versions might work, but then again they may + * not. + */ int FltHeader:: max_flt_version() { return 1570; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::check_version -// Access: Public -// Description: Verifies that the version number read from the header -// is an understood version number, and prints a warning -// to the user if this is not so--the read may or may -// not succeed. Returns true if the version number is -// acceptable (and no warning is printed), or false if -// it is questionable (and a warning is printed). -//////////////////////////////////////////////////////////////////// +/** + * Verifies that the version number read from the header is an understood + * version number, and prints a warning to the user if this is not so--the + * read may or may not succeed. Returns true if the version number is + * acceptable (and no warning is printed), or false if it is questionable (and + * a warning is printed). + */ bool FltHeader:: check_version() const { int version = get_flt_version(); @@ -440,13 +379,10 @@ check_version() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_units -// Access: Public -// Description: Returns the units indicated by the flt header, or -// DU_invalid if the units in the header are not -// understood. -//////////////////////////////////////////////////////////////////// +/** + * Returns the units indicated by the flt header, or DU_invalid if the units + * in the header are not understood. + */ DistanceUnit FltHeader:: get_units() const { switch (_vertex_units) { @@ -470,23 +406,18 @@ get_units() const { return DU_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::has_instance -// Access: Public -// Description: Returns true if a instance subtree with the given -// index has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a instance subtree with the given index has been defined. + */ bool FltHeader:: has_instance(int instance_index) const { return (_instances.count(instance_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_instance -// Access: Public -// Description: Returns the instance subtree associated with the -// given index, or NULL if there is no such instance. -//////////////////////////////////////////////////////////////////// +/** + * Returns the instance subtree associated with the given index, or NULL if + * there is no such instance. + */ FltInstanceDefinition *FltHeader:: get_instance(int instance_index) const { Instances::const_iterator mi; @@ -497,67 +428,52 @@ get_instance(int instance_index) const { return (FltInstanceDefinition *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::clear_instances -// Access: Public -// Description: Removes all instance subtrees from the instance pool. -//////////////////////////////////////////////////////////////////// +/** + * Removes all instance subtrees from the instance pool. + */ void FltHeader:: clear_instances() { _instances.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::add_instance -// Access: Public -// Description: Defines a new instance subtree. This subtree is not -// itself part of the hierarchy; it marks geometry that -// may be instanced to various beads elsewhere in the -// hierarchy by creating a corresponding FltInstanceRef -// bead. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new instance subtree. This subtree is not itself part of the + * hierarchy; it marks geometry that may be instanced to various beads + * elsewhere in the hierarchy by creating a corresponding FltInstanceRef bead. + */ void FltHeader:: add_instance(FltInstanceDefinition *instance) { _instances[instance->_instance_index] = instance; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::remove_instance -// Access: Public -// Description: Removes a particular instance subtree from the pool, -// if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Removes a particular instance subtree from the pool, if it exists. + */ void FltHeader:: remove_instance(int instance_index) { _instances.erase(instance_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_vertices -// Access: Public -// Description: Returns the number of vertices in the vertex palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in the vertex palette. + */ int FltHeader:: get_num_vertices() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_vertex -// Access: Public -// Description: Returns the nth vertex of the vertex palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of the vertex palette. + */ FltVertex *FltHeader:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices.size(), 0); return _vertices[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::clear_vertices -// Access: Public -// Description: Removes all vertices from the vertex palette. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices from the vertex palette. + */ void FltHeader:: clear_vertices() { _vertices.clear(); @@ -567,13 +483,10 @@ clear_vertices() { _vertex_lookups_stale = false; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::add_vertex -// Access: Public -// Description: Adds a new vertex to the end of the vertex palette. -// If this particular vertex was already present in the -// palette, does nothing. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the end of the vertex palette. If this particular + * vertex was already present in the palette, does nothing. + */ void FltHeader:: add_vertex(FltVertex *vertex) { bool inserted = _unique_vertices.insert(vertex).second; @@ -584,14 +497,11 @@ add_vertex(FltVertex *vertex) { nassertv(_unique_vertices.size() == _vertices.size()); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_vertex_by_offset -// Access: Public -// Description: Returns the particular vertex pointer associated with -// the given byte offset into the vertex palette. If -// there is no such vertex in the palette, this -// generates an error message and returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular vertex pointer associated with the given byte offset + * into the vertex palette. If there is no such vertex in the palette, this + * generates an error message and returns NULL. + */ FltVertex *FltHeader:: get_vertex_by_offset(int offset) { if (_vertex_lookups_stale) { @@ -607,14 +517,11 @@ get_vertex_by_offset(int offset) { return (*vi).second; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_offset_by_vertex -// Access: Public -// Description: Returns the byte offset into the vertex palette -// associated with the given vertex pointer. If there -// is no such vertex in the palette, this generates an -// error message and returns 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the byte offset into the vertex palette associated with the given + * vertex pointer. If there is no such vertex in the palette, this generates + * an error message and returns 0. + */ int FltHeader:: get_offset_by_vertex(FltVertex *vertex) { if (_vertex_lookups_stale) { @@ -630,31 +537,24 @@ get_offset_by_vertex(FltVertex *vertex) { return (*vi).second; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_colors -// Access: Public -// Description: Returns the total number of different colors in the -// color palette. This includes all different colors, -// and represents the complete range of alloable color -// indices. This is different from the actual number of -// color entries as read directly from the color -// palette, since each color entry defines a number of -// different intensity levels--the value returned by -// get_num_colors() is equal to get_num_color_entries() -// * get_num_color_shades(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of different colors in the color palette. This + * includes all different colors, and represents the complete range of + * alloable color indices. This is different from the actual number of color + * entries as read directly from the color palette, since each color entry + * defines a number of different intensity levels--the value returned by + * get_num_colors() is equal to get_num_color_entries() * + * get_num_color_shades(). + */ int FltHeader:: get_num_colors() const { return _colors.size() * get_num_color_shades(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_color -// Access: Public -// Description: Returns the four-component color corresponding to the -// given color index. Each component will be in the -// range [0, 1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the four-component color corresponding to the given color index. + * Each component will be in the range [0, 1]. + */ LColor FltHeader:: get_color(int color_index) const { nassertr(color_index >= 0 && color_index < get_num_colors(), @@ -670,13 +570,10 @@ get_color(int color_index) const { return color * ((double)level / (double)(num_color_shades - 1)); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_rgb -// Access: Public -// Description: Returns the three-component color corresponding to -// the given color index, ignoring the alpha component. -// Each component will be in the range [0, 1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the three-component color corresponding to the given color index, + * ignoring the alpha component. Each component will be in the range [0, 1]. + */ LRGBColor FltHeader:: get_rgb(int color_index) const { nassertr(color_index >= 0 && color_index < get_num_colors(), @@ -692,23 +589,17 @@ get_rgb(int color_index) const { return color * ((double)level / (double)(num_color_shades - 1)); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::has_color_name -// Access: Public -// Description: Returns true if the given color is named, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the given color is named, false otherwise. + */ bool FltHeader:: has_color_name(int color_index) const { return (_color_names.count(color_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_color_name -// Access: Public -// Description: Returns the name associated with the given color, if -// any. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name associated with the given color, if any. + */ string FltHeader:: get_color_name(int color_index) const { ColorNames::const_iterator ni; @@ -719,20 +610,16 @@ get_color_name(int color_index) const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_closest_color -// Access: Public -// Description: Returns the color index of the nearest color in the -// palette that matches the given four-component color, -// including alpha. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color index of the nearest color in the palette that matches + * the given four-component color, including alpha. + */ int FltHeader:: get_closest_color(const LColor &color0) const { - // Since the colortable stores the brightest colors, with - // num_color_shades scaled versions of each color implicitly - // available, we really only care about the relative brightnesses of - // the various components. Normalize the color in terms of the - // largest of these. + // Since the colortable stores the brightest colors, with num_color_shades + // scaled versions of each color implicitly available, we really only care + // about the relative brightnesses of the various components. Normalize the + // color in terms of the largest of these. LColor color = color0; double scale = 1.0; @@ -785,20 +672,16 @@ get_closest_color(const LColor &color0) const { return (best_i * num_color_shades) + shade_index; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_closest_rgb -// Access: Public -// Description: Returns the color index of the nearest color in the -// palette that matches the given three-component color, -// ignoring alpha. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color index of the nearest color in the palette that matches + * the given three-component color, ignoring alpha. + */ int FltHeader:: get_closest_rgb(const LRGBColor &color0) const { - // Since the colortable stores the brightest colors, with - // num_color_shades scaled versions of each color implicitly - // available, we really only care about the relative brightnesses of - // the various components. Normalize the color in terms of the - // largest of these. + // Since the colortable stores the brightest colors, with num_color_shades + // scaled versions of each color implicitly available, we really only care + // about the relative brightnesses of the various components. Normalize the + // color in terms of the largest of these. LRGBColor color = color0; double scale = 1.0; @@ -847,40 +730,30 @@ get_closest_rgb(const LRGBColor &color0) const { return (best_i * num_color_shades) + shade_index; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_color_entries -// Access: Public -// Description: Returns the number of actual entries in the color -// palette. This is based on the version of the flt -// file, and is usually either 512 or 1024. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of actual entries in the color palette. This is based + * on the version of the flt file, and is usually either 512 or 1024. + */ int FltHeader:: get_num_color_entries() const { return _colors.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_color_shades -// Access: Public -// Description: Returns the number of shades of brightness of each -// entry in the color palette. This is a fixed property -// of MultiGen files: each entry in the palette actually -// represents a range of this many colors. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of shades of brightness of each entry in the color + * palette. This is a fixed property of MultiGen files: each entry in the + * palette actually represents a range of this many colors. + */ int FltHeader:: get_num_color_shades() const { return 128; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_color -// Access: Public -// Description: Decodes a MultiGen color, as stored on a face or -// vertex, into an actual four-component LColor. -// Normally you need not call this directly; there are -// color accessors defined on faces and vertices that do -// this. -//////////////////////////////////////////////////////////////////// +/** + * Decodes a MultiGen color, as stored on a face or vertex, into an actual + * four-component LColor. Normally you need not call this directly; there are + * color accessors defined on faces and vertices that do this. + */ LColor FltHeader:: get_color(int color_index, bool use_packed_color, const FltPackedColor &packed_color, @@ -893,21 +766,17 @@ get_color(int color_index, bool use_packed_color, color[0] = packed_color._r / 255.0; color[1] = packed_color._g / 255.0; color[2] = packed_color._b / 255.0; - // MultiGen doesn't yet use the A component of RGBA. - //color[3] = packed_color._a / 255.0; + // MultiGen doesn't yet use the A component of RGBA. color[3] = + // packed_color._a 255.0; color[3] = 1.0 - (transparency / 65535.0); return color; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_color -// Access: Public -// Description: Decodes a MultiGen color, as stored on a face or -// vertex, into an actual three-component LRGBColor. -// Normally you need not call this directly; there are -// color accessors defined on faces and vertices that do -// this. -//////////////////////////////////////////////////////////////////// +/** + * Decodes a MultiGen color, as stored on a face or vertex, into an actual + * three-component LRGBColor. Normally you need not call this directly; there + * are color accessors defined on faces and vertices that do this. + */ LRGBColor FltHeader:: get_rgb(int color_index, bool use_packed_color, const FltPackedColor &packed_color) { @@ -922,23 +791,18 @@ get_rgb(int color_index, bool use_packed_color, return color; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::has_material -// Access: Public -// Description: Returns true if a material with the given index has -// been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a material with the given index has been defined. + */ bool FltHeader:: has_material(int material_index) const { return (_materials.count(material_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_material -// Access: Public -// Description: Returns the material associated with the given index, -// or NULL if there is no such material. -//////////////////////////////////////////////////////////////////// +/** + * Returns the material associated with the given index, or NULL if there is + * no such material. + */ FltMaterial *FltHeader:: get_material(int material_index) const { Materials::const_iterator mi; @@ -949,24 +813,19 @@ get_material(int material_index) const { return (FltMaterial *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::clear_materials -// Access: Public -// Description: Removes all materials from the palette. -//////////////////////////////////////////////////////////////////// +/** + * Removes all materials from the palette. + */ void FltHeader:: clear_materials() { _materials.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::add_material -// Access: Public -// Description: Defines a new material. The material is added in the -// position indicated by the material's index number. -// If there is already a material defined for that index -// number, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new material. The material is added in the position indicated by + * the material's index number. If there is already a material defined for + * that index number, it is replaced. + */ void FltHeader:: add_material(FltMaterial *material) { if (material->_material_index < 0) { @@ -975,42 +834,34 @@ add_material(FltMaterial *material) { _next_material_index++; } else { - // Make sure our next generated material index will be different - // from any existing material indices. + // Make sure our next generated material index will be different from any + // existing material indices. _next_material_index = max(_next_material_index, material->_material_index + 1); } _materials[material->_material_index] = material; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::remove_material -// Access: Public -// Description: Removes a particular material from the material -// palette, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Removes a particular material from the material palette, if it exists. + */ void FltHeader:: remove_material(int material_index) { _materials.erase(material_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::has_texture -// Access: Public -// Description: Returns true if a texture with the given index has -// been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a texture with the given index has been defined. + */ bool FltHeader:: has_texture(int texture_index) const { return (_textures.count(texture_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_texture -// Access: Public -// Description: Returns the texture associated with the given index, -// or NULL if there is no such texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture associated with the given index, or NULL if there is no + * such texture. + */ FltTexture *FltHeader:: get_texture(int texture_index) const { Textures::const_iterator mi; @@ -1021,24 +872,19 @@ get_texture(int texture_index) const { return (FltTexture *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::clear_textures -// Access: Public -// Description: Removes all textures from the palette. -//////////////////////////////////////////////////////////////////// +/** + * Removes all textures from the palette. + */ void FltHeader:: clear_textures() { _textures.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::add_texture -// Access: Public -// Description: Defines a new texture. The texture is added in the -// position indicated by the texture's index number. -// If there is already a texture defined for that index -// number, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new texture. The texture is added in the position indicated by + * the texture's index number. If there is already a texture defined for that + * index number, it is replaced. + */ void FltHeader:: add_texture(FltTexture *texture) { if (texture->_pattern_index < 0) { @@ -1047,42 +893,34 @@ add_texture(FltTexture *texture) { _next_pattern_index++; } else { - // Make sure our next generated pattern index will be different - // from any existing texture indices. + // Make sure our next generated pattern index will be different from any + // existing texture indices. _next_pattern_index = max(_next_pattern_index, texture->_pattern_index + 1); } _textures[texture->_pattern_index] = texture; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::remove_texture -// Access: Public -// Description: Removes a particular texture from the texture -// palette, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Removes a particular texture from the texture palette, if it exists. + */ void FltHeader:: remove_texture(int texture_index) { _textures.erase(texture_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::has_light_source -// Access: Public -// Description: Returns true if a light source with the given index -// has been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a light source with the given index has been defined. + */ bool FltHeader:: has_light_source(int light_index) const { return (_light_sources.count(light_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_light_source -// Access: Public -// Description: Returns the light source associated with the given -// index, or NULL if there is no such light source. -//////////////////////////////////////////////////////////////////// +/** + * Returns the light source associated with the given index, or NULL if there + * is no such light source. + */ FltLightSourceDefinition *FltHeader:: get_light_source(int light_index) const { LightSources::const_iterator li; @@ -1093,125 +931,98 @@ get_light_source(int light_index) const { return (FltLightSourceDefinition *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::clear_light_sources -// Access: Public -// Description: Removes all light sources from the palette. -//////////////////////////////////////////////////////////////////// +/** + * Removes all light sources from the palette. + */ void FltHeader:: clear_light_sources() { _light_sources.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::add_light_source -// Access: Public -// Description: Defines a new light source. The light source is -// added in the position indicated by its light index -// number. If there is already a light source defined -// for that index number, it is replaced. -//////////////////////////////////////////////////////////////////// +/** + * Defines a new light source. The light source is added in the position + * indicated by its light index number. If there is already a light source + * defined for that index number, it is replaced. + */ void FltHeader:: add_light_source(FltLightSourceDefinition *light_source) { _light_sources[light_source->_light_index] = light_source; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::remove_light_source -// Access: Public -// Description: Removes a particular light source from the light -// source palette, if it exists. -//////////////////////////////////////////////////////////////////// +/** + * Removes a particular light source from the light source palette, if it + * exists. + */ void FltHeader:: remove_light_source(int light_index) { _light_sources.erase(light_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::got_eyepoint_trackplane_palette -// Access: Public -// Description: Returns true if we have read an eyepoint/trackplane -// palette, and at least some of the eyepoints and -// trackplanes are therefore expected to be meaningful. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have read an eyepoint/trackplane palette, and at least + * some of the eyepoints and trackplanes are therefore expected to be + * meaningful. + */ bool FltHeader:: got_eyepoint_trackplane_palette() const { return _got_eyepoint_trackplane_palette; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::set_eyepoint_trackplane_palette -// Access: Public -// Description: Sets the state of the eyepoint/trackplane palette -// flag. When this is false, the palette is believed to -// be meaningless, and will not be written; when it is -// true, the palette is believed to contain at least -// some meaningful data, and will be written. -//////////////////////////////////////////////////////////////////// +/** + * Sets the state of the eyepoint/trackplane palette flag. When this is + * false, the palette is believed to be meaningless, and will not be written; + * when it is true, the palette is believed to contain at least some + * meaningful data, and will be written. + */ void FltHeader:: set_eyepoint_trackplane_palette(bool flag) { _got_eyepoint_trackplane_palette = flag; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_eyepoints -// Access: Public -// Description: Returns the number of eyepoints in the -// eyepoint/trackplane palette. This is presently fixed -// at 10, according to the MultiGen specs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of eyepoints in the eyepoint/trackplane palette. This + * is presently fixed at 10, according to the MultiGen specs. + */ int FltHeader:: get_num_eyepoints() const { return 10; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_eyepoint -// Access: Public -// Description: Returns the nth eyepoint in the eyepoint/trackplane -// palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth eyepoint in the eyepoint/trackplane palette. + */ FltEyepoint *FltHeader:: get_eyepoint(int n) { nassertr(n >= 0 && n < get_num_eyepoints(), (FltEyepoint *)NULL); return &_eyepoints[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_num_trackplanes -// Access: Public -// Description: Returns the number of trackplanes in the -// eyepoint/trackplane palette. This is presently fixed -// at 10, according to the MultiGen specs. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of trackplanes in the eyepoint/trackplane palette. This + * is presently fixed at 10, according to the MultiGen specs. + */ int FltHeader:: get_num_trackplanes() const { return 10; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::get_trackplane -// Access: Public -// Description: Returns the nth trackplane in the eyepoint/trackplane -// palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth trackplane in the eyepoint/trackplane palette. + */ FltTrackplane *FltHeader:: get_trackplane(int n) { nassertr(n >= 0 && n < get_num_trackplanes(), (FltTrackplane *)NULL); return &_trackplanes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::update_vertex_lookups -// Access: Public -// Description: Recomputes the offsets_by_vertex and -// vertices_by_offset tables. This reflects the flt -// file as it will be written out, but not necessarily -// as it was read in. -// -// The return value is the total length of the vertex -// palette, including the header record. -//////////////////////////////////////////////////////////////////// +/** + * Recomputes the offsets_by_vertex and vertices_by_offset tables. This + * reflects the flt file as it will be written out, but not necessarily as it + * was read in. + * + * The return value is the total length of the vertex palette, including the + * header record. + */ int FltHeader:: update_vertex_lookups() { // We start with the length of the vertex palette record itself. @@ -1231,14 +1042,11 @@ update_vertex_lookups() { return offset; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltHeader:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -1294,21 +1102,21 @@ extract_record(FltRecordReader &reader) { if (get_flt_version() >= 1520 && iterator.get_remaining_size() > 0) { iterator.skip_bytes(2 + 2 + 2 + 2); _earth_model = (EarthModel)iterator.get_be_int32(); - + // Undocumented padding. iterator.skip_bytes(4); - + if (get_flt_version() >= 1560 && iterator.get_remaining_size() > 0) { _next_adaptive_id = iterator.get_be_int16(); _next_curve_id = iterator.get_be_int16(); iterator.skip_bytes(4); - + if (get_flt_version() >= 1570 && iterator.get_remaining_size() > 0) { _delta_z = iterator.get_be_float64(); _radius = iterator.get_be_float64(); _next_mesh_id = iterator.get_be_int16(); iterator.skip_bytes(2); - + // Undocumented padding. iterator.skip_bytes(4); } @@ -1320,15 +1128,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_ancillary -// Access: Protected, Virtual -// Description: Checks whether the given bead, which follows this -// bead sequentially in the file, is an ancillary record -// of this bead. If it is, extracts the relevant -// information and returns true; otherwise, leaves it -// alone and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the given bead, which follows this bead sequentially in the + * file, is an ancillary record of this bead. If it is, extracts the relevant + * information and returns true; otherwise, leaves it alone and returns false. + */ bool FltHeader:: extract_ancillary(FltRecordReader &reader) { switch (reader.get_opcode()) { @@ -1371,14 +1175,11 @@ extract_ancillary(FltRecordReader &reader) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltHeader:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { @@ -1457,13 +1258,10 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_ancillary -// Access: Protected, Virtual -// Description: Writes whatever ancillary records are required for -// this bead. Returns FE_ok on success, or something -// else on error. -//////////////////////////////////////////////////////////////////// +/** + * Writes whatever ancillary records are required for this bead. Returns + * FE_ok on success, or something else on error. + */ FltError FltHeader:: write_ancillary(FltRecordWriter &writer) const { FltError result; @@ -1501,13 +1299,10 @@ write_ancillary(FltRecordWriter &writer) const { return FltBeadID::write_ancillary(writer); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_vertex -// Access: Private -// Description: Reads a single vertex ancillary record. It is -// assumed that all the vertex records will immediately -// follow the vertex palette record. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single vertex ancillary record. It is assumed that all the vertex + * records will immediately follow the vertex palette record. + */ bool FltHeader:: extract_vertex(FltRecordReader &reader) { FltVertex *vertex = new FltVertex(this); @@ -1525,11 +1320,9 @@ extract_vertex(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_color_palette -// Access: Private -// Description: Reads the color palette. -//////////////////////////////////////////////////////////////////// +/** + * Reads the color palette. + */ bool FltHeader:: extract_color_palette(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_color_palette, false); @@ -1574,11 +1367,9 @@ extract_color_palette(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_material -// Access: Private -// Description: Reads a single material ancillary record. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single material ancillary record. + */ bool FltHeader:: extract_material(FltRecordReader &reader) { PT(FltMaterial) material = new FltMaterial(this); @@ -1590,11 +1381,9 @@ extract_material(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_14_material_palette -// Access: Private -// Description: Reads the v14.2 material palette. -//////////////////////////////////////////////////////////////////// +/** + * Reads the v14.2 material palette. + */ bool FltHeader:: extract_14_material_palette(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_14_material_palette, false); @@ -1624,11 +1413,9 @@ extract_14_material_palette(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_texture -// Access: Private -// Description: Reads a single texture ancillary record. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single texture ancillary record. + */ bool FltHeader:: extract_texture(FltRecordReader &reader) { FltTexture *texture = new FltTexture(this); @@ -1640,19 +1427,15 @@ extract_texture(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_texture_map -// Access: Private -// Description: Reads the a single texture mapping ancillary record. -// This describes a kind of texture mapping in the -// texture mapping palette. -//////////////////////////////////////////////////////////////////// +/** + * Reads the a single texture mapping ancillary record. This describes a kind + * of texture mapping in the texture mapping palette. + */ bool FltHeader:: extract_texture_map(FltRecordReader &reader) { - // At the moment, we ignore this, since it's not needed for - // meaningful extraction of data: we can get this information from - // the UV's for a particular model. We just add an - // UnsupportedRecord for it. + // At the moment, we ignore this, since it's not needed for meaningful + // extraction of data: we can get this information from the UV's for a + // particular model. We just add an UnsupportedRecord for it. FltUnsupportedRecord *rec = new FltUnsupportedRecord(this); if (!rec->extract_record(reader)) { return false; @@ -1662,11 +1445,9 @@ extract_texture_map(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_light_source -// Access: Private -// Description: Reads a single light source ancillary record. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single light source ancillary record. + */ bool FltHeader:: extract_light_source(FltRecordReader &reader) { FltLightSourceDefinition *light_source = new FltLightSourceDefinition(this); @@ -1678,11 +1459,9 @@ extract_light_source(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::extract_eyepoint_palette -// Access: Private -// Description: Reads the eyepoint/trackplane palette. -//////////////////////////////////////////////////////////////////// +/** + * Reads the eyepoint/trackplane palette. + */ bool FltHeader:: extract_eyepoint_palette(FltRecordReader &reader) { nassertr(reader.get_opcode() == FO_eyepoint_palette, false); @@ -1708,20 +1487,17 @@ extract_eyepoint_palette(FltRecordReader &reader) { _got_eyepoint_trackplane_palette = true; if (get_flt_version() >= 1420) { - // I have no idea what bytes are supposed to be here in earlier - // versions that 14.2, but who really cares? Don't bother - // reporting it if there are too many bytes in old versions. + // I have no idea what bytes are supposed to be here in earlier versions + // that 14.2, but who really cares? Don't bother reporting it if there + // are too many bytes in old versions. check_remaining_size(iterator, "eyepoint palette"); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_vertex_palette -// Access: Private -// Description: Writes out the vertex palette with all of its -// vertices. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the vertex palette with all of its vertices. + */ FltError FltHeader:: write_vertex_palette(FltRecordWriter &writer) const { FltError result; @@ -1749,11 +1525,9 @@ write_vertex_palette(FltRecordWriter &writer) const { } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_color_palette -// Access: Private -// Description: Writes out the color palette. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the color palette. + */ FltError FltHeader:: write_color_palette(FltRecordWriter &writer) const { writer.set_opcode(FO_color_palette); @@ -1773,8 +1547,8 @@ write_color_palette(FltRecordWriter &writer) const { num_colors--; } - // Now we might need to pad the record to fill up the required - // number of colors. + // Now we might need to pad the record to fill up the required number of + // colors. if (num_colors > 0) { FltPackedColor empty; while (num_colors > 0) { @@ -1801,11 +1575,9 @@ write_color_palette(FltRecordWriter &writer) const { return writer.advance(); } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_material_palette -// Access: Private -// Description: Writes out the material palette. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the material palette. + */ FltError FltHeader:: write_material_palette(FltRecordWriter &writer) const { FltError result; @@ -1857,11 +1629,9 @@ write_material_palette(FltRecordWriter &writer) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_texture_palette -// Access: Private -// Description: Writes out the texture palette. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the texture palette. + */ FltError FltHeader:: write_texture_palette(FltRecordWriter &writer) const { FltError result; @@ -1879,11 +1649,9 @@ write_texture_palette(FltRecordWriter &writer) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_light_source_palette -// Access: Private -// Description: Writes out the light source palette. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the light source palette. + */ FltError FltHeader:: write_light_source_palette(FltRecordWriter &writer) const { FltError result; @@ -1901,12 +1669,9 @@ write_light_source_palette(FltRecordWriter &writer) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltHeader::write_eyepoint_palette -// Access: Private -// Description: Writes out the eyepoint/trackplane palette, if we -// have one. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the eyepoint/trackplane palette, if we have one. + */ FltError FltHeader:: write_eyepoint_palette(FltRecordWriter &writer) const { if (!_got_eyepoint_trackplane_palette) { diff --git a/pandatool/src/flt/fltHeader.h b/pandatool/src/flt/fltHeader.h index 98b8f920ac..0cde95d1ad 100644 --- a/pandatool/src/flt/fltHeader.h +++ b/pandatool/src/flt/fltHeader.h @@ -1,16 +1,15 @@ -// Filename: fltHeader.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltHeader.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTHEADER_H #define FLTHEADER_H @@ -35,16 +34,13 @@ #include "pset.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : FltHeader -// Description : This is the first bead in the file, the top of the -// bead hierarchy, and the primary interface to reading -// and writing a Flt file. You always read a Flt file -// by creating a header and calling read_flt(), which -// fills in its children beads automatically; you write -// a Flt file by creating a header, adding its children, -// and calling write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * This is the first bead in the file, the top of the bead hierarchy, and the + * primary interface to reading and writing a Flt file. You always read a Flt + * file by creating a header and calling read_flt(), which fills in its + * children beads automatically; you write a Flt file by creating a header, + * adding its children, and calling write_flt(). + */ class FltHeader : public FltBeadID { public: FltHeader(PathReplace *path_replace); @@ -179,8 +175,8 @@ public: int get_offset_by_vertex(FltVertex *vertex); - // Accessors into the color palette. This is read-only; why would - // you want to mess with building a new color palette? + // Accessors into the color palette. This is read-only; why would you want + // to mess with building a new color palette? int get_num_colors() const; LColor get_color(int color_index) const; LRGBColor get_rgb(int color_index) const; @@ -193,8 +189,8 @@ public: int get_num_color_entries() const; int get_num_color_shades() const; - // These functions are mainly used behind-the-scenes to decode the - // strange forest of color options defined for faces and vertices. + // These functions are mainly used behind-the-scenes to decode the strange + // forest of color options defined for faces and vertices. LColor get_color(int color_index, bool use_packed_color, const FltPackedColor &packed_color, int transparency); @@ -225,7 +221,7 @@ public: void remove_light_source(int light_index); - // Accessors into the eyepoint/trackplane palette. + // Accessors into the eyepointtrackplane palette. bool got_eyepoint_trackplane_palette() const; void set_eyepoint_trackplane_palette(bool flag); @@ -236,8 +232,8 @@ public: private: // Instance subtrees. These are standalone subtrees, which may be - // referenced by various points in the hierarchy, stored by instance - // ID number. + // referenced by various points in the hierarchy, stored by instance ID + // number. typedef pmap Instances; Instances _instances; @@ -258,8 +254,8 @@ private: bool _vertex_lookups_stale; - // This is maintained while the header is being read, to map the - // vertices to their corresponding offsets in the vertex palette. + // This is maintained while the header is being read, to map the vertices to + // their corresponding offsets in the vertex palette. int _current_vertex_offset; @@ -290,7 +286,7 @@ private: LightSources _light_sources; - // Support for the eyepoint/trackplane palette. + // Support for the eyepointtrackplane palette. bool _got_eyepoint_trackplane_palette; FltEyepoint _eyepoints[10]; FltTrackplane _trackplanes[10]; @@ -342,5 +338,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltInstanceDefinition.cxx b/pandatool/src/flt/fltInstanceDefinition.cxx index 400725a0f8..83cf32385f 100644 --- a/pandatool/src/flt/fltInstanceDefinition.cxx +++ b/pandatool/src/flt/fltInstanceDefinition.cxx @@ -1,16 +1,15 @@ -// Filename: fltInstanceDefinition.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInstanceDefinition.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltInstanceDefinition.h" #include "fltRecordReader.h" @@ -18,24 +17,19 @@ TypeHandle FltInstanceDefinition::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceDefinition::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltInstanceDefinition:: FltInstanceDefinition(FltHeader *header) : FltBead(header) { _instance_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceDefinition::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltInstanceDefinition:: extract_record(FltRecordReader &reader) { if (!FltBead::extract_record(reader)) { @@ -52,14 +46,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceDefinition::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltInstanceDefinition:: build_record(FltRecordWriter &writer) const { if (!FltBead::build_record(writer)) { diff --git a/pandatool/src/flt/fltInstanceDefinition.h b/pandatool/src/flt/fltInstanceDefinition.h index 5085a31329..0a17f01406 100644 --- a/pandatool/src/flt/fltInstanceDefinition.h +++ b/pandatool/src/flt/fltInstanceDefinition.h @@ -1,16 +1,15 @@ -// Filename: fltInstanceDefinition.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInstanceDefinition.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTINSTANCEDEFINITION_H #define FLTINSTANCEDEFINITION_H @@ -19,16 +18,13 @@ #include "fltBead.h" -//////////////////////////////////////////////////////////////////// -// Class : FltInstanceDefinition -// Description : This special kind of record marks the top node of an -// instance subtree. This subtree lives outside of the -// normal hierarchy, and is MultiGen's way of supporting -// instancing--each instance subtree has a unique index, -// which may be referenced in a FltInstanceRef object to -// make the instance appear in various places in the -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This special kind of record marks the top node of an instance subtree. + * This subtree lives outside of the normal hierarchy, and is MultiGen's way + * of supporting instancing--each instance subtree has a unique index, which + * may be referenced in a FltInstanceRef object to make the instance appear in + * various places in the hierarchy. + */ class FltInstanceDefinition : public FltBead { public: FltInstanceDefinition(FltHeader *header); @@ -61,5 +57,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltInstanceRef.cxx b/pandatool/src/flt/fltInstanceRef.cxx index e3f7243365..7f0ffd2e67 100644 --- a/pandatool/src/flt/fltInstanceRef.cxx +++ b/pandatool/src/flt/fltInstanceRef.cxx @@ -1,16 +1,15 @@ -// Filename: fltInstanceRef.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInstanceRef.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltInstanceRef.h" #include "fltRecordReader.h" @@ -20,35 +19,28 @@ TypeHandle FltInstanceRef::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltInstanceRef:: FltInstanceRef(FltHeader *header) : FltBead(header) { _instance_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::get_instance -// Access: Public -// Description: Returns the instance subtree referenced by this node, -// or NULL if the reference is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the instance subtree referenced by this node, or NULL if the + * reference is invalid. + */ FltInstanceDefinition *FltInstanceRef:: get_instance() const { return _header->get_instance(_instance_index); } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::write -// Access: Public -// Description: Writes a multiple-line description of the record and -// all of its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a multiple-line description of the record and all of its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltInstanceRef:: write(ostream &out, int indent_level) const { indent(out, indent_level) << "instance"; @@ -61,14 +53,11 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltInstanceRef:: extract_record(FltRecordReader &reader) { if (!FltBead::extract_record(reader)) { @@ -85,13 +74,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::write_record_and_children -// Access: Protected, Virtual -// Description: Writes this record out to the flt file, along with all -// of its ancillary records and children records. Returns -// FE_ok on success, or something else on error. -//////////////////////////////////////////////////////////////////// +/** + * Writes this record out to the flt file, along with all of its ancillary + * records and children records. Returns FE_ok on success, or something else + * on error. + */ FltError FltInstanceRef:: write_record_and_children(FltRecordWriter &writer) const { // First, make sure our instance definition has already been written. @@ -104,14 +91,11 @@ write_record_and_children(FltRecordWriter &writer) const { return FltBead::write_record_and_children(writer); } -//////////////////////////////////////////////////////////////////// -// Function: FltInstanceRef::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltInstanceRef:: build_record(FltRecordWriter &writer) const { if (!FltBead::build_record(writer)) { diff --git a/pandatool/src/flt/fltInstanceRef.h b/pandatool/src/flt/fltInstanceRef.h index 80f0f242e5..6bbbe11ebd 100644 --- a/pandatool/src/flt/fltInstanceRef.h +++ b/pandatool/src/flt/fltInstanceRef.h @@ -1,16 +1,15 @@ -// Filename: fltInstanceRef.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInstanceRef.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTINSTANCEREF_H #define FLTINSTANCEREF_H @@ -21,14 +20,11 @@ class FltInstanceDefinition; -//////////////////////////////////////////////////////////////////// -// Class : FltInstanceRef -// Description : This bead appears in the hierarchy to refer to a -// FltInstanceDefinition node defined elsewhere. It -// indicates that the subtree beginning at the -// FltInstanceDefinition should be considered to be -// instanced here. -//////////////////////////////////////////////////////////////////// +/** + * This bead appears in the hierarchy to refer to a FltInstanceDefinition node + * defined elsewhere. It indicates that the subtree beginning at the + * FltInstanceDefinition should be considered to be instanced here. + */ class FltInstanceRef : public FltBead { public: FltInstanceRef(FltHeader *header); @@ -63,5 +59,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltLOD.cxx b/pandatool/src/flt/fltLOD.cxx index ce08e25e19..abe655ae38 100644 --- a/pandatool/src/flt/fltLOD.cxx +++ b/pandatool/src/flt/fltLOD.cxx @@ -1,16 +1,15 @@ -// Filename: fltLOD.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLOD.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltLOD.h" #include "fltRecordReader.h" @@ -18,11 +17,9 @@ TypeHandle FltLOD::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltLOD::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltLOD:: FltLOD(FltHeader *header) : FltBeadID(header) { _switch_in = 0.0; @@ -36,14 +33,11 @@ FltLOD(FltHeader *header) : FltBeadID(header) { _transition_range = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: FltLOD::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltLOD:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -68,14 +62,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltLOD::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltLOD:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { diff --git a/pandatool/src/flt/fltLOD.h b/pandatool/src/flt/fltLOD.h index f7c812778e..36e5ccb62a 100644 --- a/pandatool/src/flt/fltLOD.h +++ b/pandatool/src/flt/fltLOD.h @@ -1,16 +1,15 @@ -// Filename: fltLOD.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLOD.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTLOD_H #define FLTLOD_H @@ -19,10 +18,9 @@ #include "fltBeadID.h" -//////////////////////////////////////////////////////////////////// -// Class : FltLOD -// Description : A Level-of-Detail record. -//////////////////////////////////////////////////////////////////// +/** + * A Level-of-Detail record. + */ class FltLOD : public FltBeadID { public: FltLOD(FltHeader *header); @@ -64,5 +62,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltLightSourceDefinition.cxx b/pandatool/src/flt/fltLightSourceDefinition.cxx index 10b19bc2d7..52964251e2 100644 --- a/pandatool/src/flt/fltLightSourceDefinition.cxx +++ b/pandatool/src/flt/fltLightSourceDefinition.cxx @@ -1,16 +1,15 @@ -// Filename: fltLightSourceDefinition.cxx -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLightSourceDefinition.cxx + * @author drose + * @date 2000-08-26 + */ #include "fltLightSourceDefinition.h" #include "fltRecordReader.h" @@ -18,11 +17,9 @@ TypeHandle FltLightSourceDefinition::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltLightSourceDefinition::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltLightSourceDefinition:: FltLightSourceDefinition(FltHeader *header) : FltRecord(header) { _light_index = 0; @@ -40,14 +37,11 @@ FltLightSourceDefinition(FltHeader *header) : FltRecord(header) { _modeling_light = false; } -//////////////////////////////////////////////////////////////////// -// Function: FltLightSourceDefinition::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltLightSourceDefinition:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -89,14 +83,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltLightSourceDefinition::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltLightSourceDefinition:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { diff --git a/pandatool/src/flt/fltLightSourceDefinition.h b/pandatool/src/flt/fltLightSourceDefinition.h index bd90057aa1..80f307de13 100644 --- a/pandatool/src/flt/fltLightSourceDefinition.h +++ b/pandatool/src/flt/fltLightSourceDefinition.h @@ -1,16 +1,15 @@ -// Filename: fltLightSourceDefinition.h -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLightSourceDefinition.h + * @author drose + * @date 2000-08-26 + */ #ifndef FLTLIGHTSOURCEDEFINITION_H #define FLTLIGHTSOURCEDEFINITION_H @@ -21,13 +20,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltLightSourceDefinition -// Description : Represents a single entry in the light source -// palette. This completely defines the color, etc. of -// a single light source, which may be referenced later -// by a FltLightSource bead in the hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single entry in the light source palette. This completely + * defines the color, etc. of a single light source, which may be referenced + * later by a FltLightSource bead in the hierarchy. + */ class FltLightSourceDefinition : public FltRecord { public: FltLightSourceDefinition(FltHeader *header); @@ -47,8 +44,8 @@ public: PN_stdfloat _exponential_dropoff; PN_stdfloat _cutoff_angle; // in degrees - // yaw and pitch only for modeling lights, which are positioned at - // the eyepoint. + // yaw and pitch only for modeling lights, which are positioned at the + // eyepoint. PN_stdfloat _yaw; PN_stdfloat _pitch; @@ -82,5 +79,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltLocalVertexPool.I b/pandatool/src/flt/fltLocalVertexPool.I index ee6c909c3f..d91696c843 100644 --- a/pandatool/src/flt/fltLocalVertexPool.I +++ b/pandatool/src/flt/fltLocalVertexPool.I @@ -1,13 +1,12 @@ -// Filename: fltLocalVertexPool.I -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLocalVertexPool.I + * @author drose + * @date 2001-02-28 + */ diff --git a/pandatool/src/flt/fltLocalVertexPool.cxx b/pandatool/src/flt/fltLocalVertexPool.cxx index 5b0951e027..96082ac7d3 100644 --- a/pandatool/src/flt/fltLocalVertexPool.cxx +++ b/pandatool/src/flt/fltLocalVertexPool.cxx @@ -1,16 +1,15 @@ -// Filename: fltLocalVertexPool.cxx -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLocalVertexPool.cxx + * @author drose + * @date 2001-02-28 + */ #include "fltLocalVertexPool.h" #include "fltRecordReader.h" @@ -20,23 +19,18 @@ TypeHandle FltLocalVertexPool::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltLocalVertexPool::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltLocalVertexPool:: FltLocalVertexPool(FltHeader *header) : FltRecord(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltLocalVertexPool::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltLocalVertexPool:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -125,14 +119,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltLocalVertexPool::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltLocalVertexPool:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -171,8 +162,8 @@ build_record(FltRecordWriter &writer) const { if ((attributes & AM_has_packed_color) != 0 && (attributes & AM_has_color_index) != 0) { - // We cannot have both a packed color and a color index. If we - // want both, used packed color. + // We cannot have both a packed color and a color index. If we want both, + // used packed color. attributes &= ~AM_has_color_index; } @@ -191,18 +182,17 @@ build_record(FltRecordWriter &writer) const { if ((attributes & AM_has_color_index) != 0) { if ((vertex->_flags & (FltVertex::F_no_color | FltVertex::F_packed_color)) != 0) { - // This particular vertex does not have a color index. - // Make it white. + // This particular vertex does not have a color index. Make it white. datagram.add_be_int32(_header->get_closest_rgb(LRGBColor(1.0, 1.0, 1.0))); } else { datagram.add_be_int32(vertex->_color_index); } } else if ((attributes & AM_has_packed_color) != 0) { - // We extract our own FltPackedColor instead of writing out the - // vertex's _packed_color directly, just in case the vertex is - // actually index colored. This bit of code will work - // regardless of the kind of color the vertex has. + // We extract our own FltPackedColor instead of writing out the vertex's + // _packed_color directly, just in case the vertex is actually index + // colored. This bit of code will work regardless of the kind of color + // the vertex has. FltPackedColor color; if (vertex->has_color()) { diff --git a/pandatool/src/flt/fltLocalVertexPool.h b/pandatool/src/flt/fltLocalVertexPool.h index b431082a61..f070dbc0a0 100644 --- a/pandatool/src/flt/fltLocalVertexPool.h +++ b/pandatool/src/flt/fltLocalVertexPool.h @@ -1,16 +1,15 @@ -// Filename: fltLocalVertexPool.h -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltLocalVertexPool.h + * @author drose + * @date 2001-02-28 + */ #ifndef FLTLOCALVERTEXPOOL_H #define FLTLOCALVERTEXPOOL_H @@ -23,17 +22,16 @@ #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : FltLocalVertexPool -// Description : A local vertex pool, as might appear in the middle of -// the hierarchy, for instance for a mesh. -//////////////////////////////////////////////////////////////////// +/** + * A local vertex pool, as might appear in the middle of the hierarchy, for + * instance for a mesh. + */ class FltLocalVertexPool : public FltRecord { public: FltLocalVertexPool(FltHeader *header); - // These bits are not stored in the vertex pool, but are read from - // the .flt file and used immediately. + // These bits are not stored in the vertex pool, but are read from the .flt + // file and used immediately. enum AttributeMask { AM_has_position = 0x80000000, AM_has_color_index = 0x40000000, @@ -77,5 +75,3 @@ private: #include "fltLocalVertexPool.I" #endif - - diff --git a/pandatool/src/flt/fltMaterial.cxx b/pandatool/src/flt/fltMaterial.cxx index 4e1a6fa4f3..8141169619 100644 --- a/pandatool/src/flt/fltMaterial.cxx +++ b/pandatool/src/flt/fltMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: fltMaterial.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMaterial.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltMaterial.h" #include "fltRecordReader.h" @@ -18,11 +17,9 @@ TypeHandle FltMaterial::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltMaterial::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltMaterial:: FltMaterial(FltHeader *header) : FltRecord(header) { _material_index = -1; @@ -35,14 +32,11 @@ FltMaterial(FltHeader *header) : FltRecord(header) { _alpha = 1.0; } -//////////////////////////////////////////////////////////////////// -// Function: FltMaterial::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltMaterial:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -75,14 +69,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMaterial::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltMaterial:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -114,14 +105,11 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMaterial::extract_14_record -// Access: Public -// Description: Fills in the information in this record based on the -// information from the current position within the v14 -// material palette. Leaves the iterator at the -// beginning of the next material. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information from the + * current position within the v14 material palette. Leaves the iterator at + * the beginning of the next material. + */ bool FltMaterial:: extract_14_record(int index, DatagramIterator &di) { _material_index = index; @@ -147,14 +135,11 @@ extract_14_record(int index, DatagramIterator &di) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMaterial::build_14_record -// Access: Public -// Description: Fills up the current record on the FltRecordWriter -// with data for this record, formatted as a part of a -// v14 material palette. Returns true on success, false -// if there is some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, formatted as a part of a v14 material palette. Returns true on + * success, false if there is some error. + */ bool FltMaterial:: build_14_record(Datagram &datagram) { datagram.add_be_float32(_ambient[0]); diff --git a/pandatool/src/flt/fltMaterial.h b/pandatool/src/flt/fltMaterial.h index 7c70446022..c801efc993 100644 --- a/pandatool/src/flt/fltMaterial.h +++ b/pandatool/src/flt/fltMaterial.h @@ -1,16 +1,15 @@ -// Filename: fltMaterial.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMaterial.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTMATERIAL_H #define FLTMATERIAL_H @@ -23,10 +22,9 @@ class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : FltMaterial -// Description : Represents a single material in the material palette. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single material in the material palette. + */ class FltMaterial : public FltRecord { public: FltMaterial(FltHeader *header); @@ -74,5 +72,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltMesh.I b/pandatool/src/flt/fltMesh.I index 3a2ef92b55..d1d9c0de4a 100644 --- a/pandatool/src/flt/fltMesh.I +++ b/pandatool/src/flt/fltMesh.I @@ -1,13 +1,12 @@ -// Filename: fltMesh.I -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMesh.I + * @author drose + * @date 2001-02-28 + */ diff --git a/pandatool/src/flt/fltMesh.cxx b/pandatool/src/flt/fltMesh.cxx index 1030341af7..47506e732a 100644 --- a/pandatool/src/flt/fltMesh.cxx +++ b/pandatool/src/flt/fltMesh.cxx @@ -1,16 +1,15 @@ -// Filename: fltMesh.cxx -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMesh.cxx + * @author drose + * @date 2001-02-28 + */ #include "fltMesh.h" #include "fltRecordReader.h" @@ -21,23 +20,18 @@ TypeHandle FltMesh::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltMesh:: FltMesh(FltHeader *header) : FltGeometry(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltMesh::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltMesh:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -57,15 +51,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMesh::extract_ancillary -// Access: Protected, Virtual -// Description: Checks whether the given bead, which follows this -// bead sequentially in the file, is an ancillary record -// of this bead. If it is, extracts the relevant -// information and returns true; otherwise, leaves it -// alone and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the given bead, which follows this bead sequentially in the + * file, is an ancillary record of this bead. If it is, extracts the relevant + * information and returns true; otherwise, leaves it alone and returns false. + */ bool FltMesh:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_local_vertex_pool) { @@ -76,14 +66,11 @@ extract_ancillary(FltRecordReader &reader) { return FltBeadID::extract_ancillary(reader); } -//////////////////////////////////////////////////////////////////// -// Function: FltMesh::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltMesh:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { @@ -102,13 +89,10 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMesh::write_ancillary -// Access: Protected, Virtual -// Description: Writes whatever ancillary records are required for -// this record. Returns FE_ok on success, or something -// else if there is some error. -//////////////////////////////////////////////////////////////////// +/** + * Writes whatever ancillary records are required for this record. Returns + * FE_ok on success, or something else if there is some error. + */ FltError FltMesh:: write_ancillary(FltRecordWriter &writer) const { if (_vpool != (FltLocalVertexPool *)NULL) { @@ -124,4 +108,3 @@ write_ancillary(FltRecordWriter &writer) const { return FltBeadID::write_ancillary(writer); } - diff --git a/pandatool/src/flt/fltMesh.h b/pandatool/src/flt/fltMesh.h index 540106289c..a66bdf6296 100644 --- a/pandatool/src/flt/fltMesh.h +++ b/pandatool/src/flt/fltMesh.h @@ -1,16 +1,15 @@ -// Filename: fltMesh.h -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMesh.h + * @author drose + * @date 2001-02-28 + */ #ifndef FLTMESH_H #define FLTMESH_H @@ -22,11 +21,9 @@ #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : FltMesh -// Description : A mesh of connected polygons and tristrips, etc., -// with a local vertex pool. -//////////////////////////////////////////////////////////////////// +/** + * A mesh of connected polygons and tristrips, etc., with a local vertex pool. + */ class FltMesh : public FltGeometry { public: FltMesh(FltHeader *header); @@ -61,5 +58,3 @@ private: #include "fltMesh.I" #endif - - diff --git a/pandatool/src/flt/fltMeshPrimitive.I b/pandatool/src/flt/fltMeshPrimitive.I index e69192cfb9..70923ab8ac 100644 --- a/pandatool/src/flt/fltMeshPrimitive.I +++ b/pandatool/src/flt/fltMeshPrimitive.I @@ -1,13 +1,12 @@ -// Filename: fltMeshPrimitive.I -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMeshPrimitive.I + * @author drose + * @date 2001-02-28 + */ diff --git a/pandatool/src/flt/fltMeshPrimitive.cxx b/pandatool/src/flt/fltMeshPrimitive.cxx index ce775f0a1e..0456cad142 100644 --- a/pandatool/src/flt/fltMeshPrimitive.cxx +++ b/pandatool/src/flt/fltMeshPrimitive.cxx @@ -1,16 +1,15 @@ -// Filename: fltMeshPrimitive.cxx -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMeshPrimitive.cxx + * @author drose + * @date 2001-02-28 + */ #include "fltMeshPrimitive.h" #include "fltRecordReader.h" @@ -20,24 +19,19 @@ TypeHandle FltMeshPrimitive::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltMeshPrimitive::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltMeshPrimitive:: FltMeshPrimitive(FltHeader *header) : FltBead(header) { _primitive_type = PT_tristrip; } -//////////////////////////////////////////////////////////////////// -// Function: FltMeshPrimitive::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltMeshPrimitive:: extract_record(FltRecordReader &reader) { if (!FltBead::extract_record(reader)) { @@ -77,14 +71,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltMeshPrimitive::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltMeshPrimitive:: build_record(FltRecordWriter &writer) const { if (!FltBead::build_record(writer)) { @@ -96,8 +87,7 @@ build_record(FltRecordWriter &writer) const { datagram.add_be_int16(_primitive_type); - // Determine the optimum index width, based on the largest vertex - // index. + // Determine the optimum index width, based on the largest vertex index. int max_index = 0; Vertices::const_iterator vi; for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) { diff --git a/pandatool/src/flt/fltMeshPrimitive.h b/pandatool/src/flt/fltMeshPrimitive.h index 608a0ac271..bca21cc432 100644 --- a/pandatool/src/flt/fltMeshPrimitive.h +++ b/pandatool/src/flt/fltMeshPrimitive.h @@ -1,16 +1,15 @@ -// Filename: fltMeshPrimitive.h -// Created by: drose (28Feb01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltMeshPrimitive.h + * @author drose + * @date 2001-02-28 + */ #ifndef FLTMESHPRIMITIVE_H #define FLTMESHPRIMITIVE_H @@ -23,11 +22,9 @@ #include "luse.h" #include "vector_int.h" -//////////////////////////////////////////////////////////////////// -// Class : FltMeshPrimitive -// Description : A single primitive of a mesh, like a triangle strip -// or fan. -//////////////////////////////////////////////////////////////////// +/** + * A single primitive of a mesh, like a triangle strip or fan. + */ class FltMeshPrimitive : public FltBead { public: FltMeshPrimitive(FltHeader *header); @@ -70,5 +67,3 @@ private: #include "fltMeshPrimitive.I" #endif - - diff --git a/pandatool/src/flt/fltObject.cxx b/pandatool/src/flt/fltObject.cxx index 90ebf0c6c5..ce80974143 100644 --- a/pandatool/src/flt/fltObject.cxx +++ b/pandatool/src/flt/fltObject.cxx @@ -1,16 +1,15 @@ -// Filename: fltObject.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltObject.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltObject.h" #include "fltRecordReader.h" @@ -18,23 +17,18 @@ TypeHandle FltObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltObject:: FltObject(FltHeader *header) : FltBeadID(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltObject::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltObject:: extract_record(FltRecordReader &reader) { if (!FltBeadID::extract_record(reader)) { @@ -56,14 +50,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltObject::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltObject:: build_record(FltRecordWriter &writer) const { if (!FltBeadID::build_record(writer)) { diff --git a/pandatool/src/flt/fltObject.h b/pandatool/src/flt/fltObject.h index 0b3b7ea398..35a77ce7bd 100644 --- a/pandatool/src/flt/fltObject.h +++ b/pandatool/src/flt/fltObject.h @@ -1,16 +1,15 @@ -// Filename: fltObject.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltObject.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTOBJECT_H #define FLTOBJECT_H @@ -19,10 +18,9 @@ #include "fltBeadID.h" -//////////////////////////////////////////////////////////////////// -// Class : FltObject -// Description : The main objecting bead of the flt file. -//////////////////////////////////////////////////////////////////// +/** + * The main objecting bead of the flt file. + */ class FltObject : public FltBeadID { public: FltObject(FltHeader *header); @@ -65,5 +63,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltOpcode.cxx b/pandatool/src/flt/fltOpcode.cxx index f45782cefb..4ca497a9ee 100644 --- a/pandatool/src/flt/fltOpcode.cxx +++ b/pandatool/src/flt/fltOpcode.cxx @@ -1,16 +1,15 @@ -// Filename: fltOpcode.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltOpcode.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltOpcode.h" diff --git a/pandatool/src/flt/fltOpcode.h b/pandatool/src/flt/fltOpcode.h index 20f9ca8a5f..2cadaeacb5 100644 --- a/pandatool/src/flt/fltOpcode.h +++ b/pandatool/src/flt/fltOpcode.h @@ -1,16 +1,15 @@ -// Filename: fltOpcode.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltOpcode.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTOPCODE_H #define FLTOPCODE_H @@ -121,4 +120,3 @@ enum FltOpcode { ostream &operator << (ostream &out, FltOpcode opcode); #endif - diff --git a/pandatool/src/flt/fltPackedColor.I b/pandatool/src/flt/fltPackedColor.I index 8eaefee12a..9b42f4d64d 100644 --- a/pandatool/src/flt/fltPackedColor.I +++ b/pandatool/src/flt/fltPackedColor.I @@ -1,16 +1,15 @@ -// Filename: fltPackedColor.I -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltPackedColor.I + * @author drose + * @date 2000-08-25 + */ INLINE ostream & operator << (ostream &out, const FltPackedColor &color) { @@ -19,11 +18,9 @@ operator << (ostream &out, const FltPackedColor &color) { } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FltPackedColor:: FltPackedColor() { _a = 0; @@ -32,35 +29,28 @@ FltPackedColor() { _r = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::get_color -// Access: Public -// Description: Returns the four-component color as a LColor, where -// each component is in the range [0, 1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the four-component color as a LColor, where each component is in + * the range [0, 1]. + */ INLINE LColor FltPackedColor:: get_color() const { return LColor(_r / 255.0, _g / 255.0, _b / 255.0, _a / 255.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::get_rgb -// Access: Public -// Description: Returns the three-component color as an LRGBColor -// (ignoring the alpha component), where each component -// is in the range [0, 1]. -//////////////////////////////////////////////////////////////////// +/** + * Returns the three-component color as an LRGBColor (ignoring the alpha + * component), where each component is in the range [0, 1]. + */ INLINE LRGBColor FltPackedColor:: get_rgb() const { return LRGBColor(_r / 255.0, _g / 255.0, _b / 255.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::set_color -// Access: Public -// Description: Sets the color according to the indicated -// four-component LColor value (including alpha). -//////////////////////////////////////////////////////////////////// +/** + * Sets the color according to the indicated four-component LColor value + * (including alpha). + */ INLINE void FltPackedColor:: set_color(const LColor &color) { _r = (int)floor(color[0] * 255.0); @@ -69,13 +59,10 @@ set_color(const LColor &color) { _a = (int)floor(color[3] * 255.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::set_rgb -// Access: Public -// Description: Sets the color according to the indicated -// three-component LRGBColor value, and set the alpha to -// 1.0. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color according to the indicated three-component LRGBColor value, + * and set the alpha to 1.0. + */ INLINE void FltPackedColor:: set_rgb(const LRGBColor &color) { _r = (int)floor(color[0] * 255.0); diff --git a/pandatool/src/flt/fltPackedColor.cxx b/pandatool/src/flt/fltPackedColor.cxx index e77c5f7c2c..cc5dc7540d 100644 --- a/pandatool/src/flt/fltPackedColor.cxx +++ b/pandatool/src/flt/fltPackedColor.cxx @@ -1,36 +1,31 @@ -// Filename: fltPackedColor.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltPackedColor.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltPackedColor.h" #include "fltRecordReader.h" #include "fltRecordWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltPackedColor:: output(ostream &out) const { out << "(" << _r << " " << _g << " " << _b << " " << _a << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::extract_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltPackedColor:: extract_record(FltRecordReader &reader) { DatagramIterator &iterator = reader.get_iterator(); @@ -43,11 +38,9 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltPackedColor::build_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltPackedColor:: build_record(FltRecordWriter &writer) const { Datagram &datagram = writer.update_datagram(); diff --git a/pandatool/src/flt/fltPackedColor.h b/pandatool/src/flt/fltPackedColor.h index 55a4b5c629..d8897363aa 100644 --- a/pandatool/src/flt/fltPackedColor.h +++ b/pandatool/src/flt/fltPackedColor.h @@ -1,16 +1,15 @@ -// Filename: fltPackedColor.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltPackedColor.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTPACKEDCOLOR_H #define FLTPACKEDCOLOR_H @@ -23,11 +22,10 @@ class FltRecordReader; class FltRecordWriter; -//////////////////////////////////////////////////////////////////// -// Class : FltPackedColor -// Description : A packed color record, A, B, G, R. This appears, for -// instance, within a face bead. -//////////////////////////////////////////////////////////////////// +/** + * A packed color record, A, B, G, R. This appears, for instance, within a + * face bead. + */ class FltPackedColor { public: INLINE FltPackedColor(); @@ -53,6 +51,3 @@ INLINE ostream &operator << (ostream &out, const FltPackedColor &color); #include "fltPackedColor.I" #endif - - - diff --git a/pandatool/src/flt/fltRecord.I b/pandatool/src/flt/fltRecord.I index 06650a13dd..39d8765018 100644 --- a/pandatool/src/flt/fltRecord.I +++ b/pandatool/src/flt/fltRecord.I @@ -1,16 +1,15 @@ -// Filename: fltRecord.I -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecord.I + * @author drose + * @date 2000-08-24 + */ INLINE ostream & operator << (ostream &out, const FltRecord &record) { diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index b618e7c441..c3dc21d070 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -1,16 +1,15 @@ -// Filename: fltRecord.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecord.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltRecord.h" #include "fltRecordReader.h" @@ -40,275 +39,217 @@ TypeHandle FltRecord::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecord:: FltRecord(FltHeader *header) : _header(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecord:: ~FltRecord() { } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_num_children -// Access: Public -// Description: Returns the number of child records of this record. -// This reflects the normal scene graph hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child records of this record. This reflects the + * normal scene graph hierarchy. + */ int FltRecord:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_child -// Access: Public -// Description: Returns the nth child of this record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of this record. + */ FltRecord *FltRecord:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), (FltRecord *)NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::clear_children -// Access: Public -// Description: Removes all children from this record. -//////////////////////////////////////////////////////////////////// +/** + * Removes all children from this record. + */ void FltRecord:: clear_children() { _children.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::add_child -// Access: Public -// Description: Adds a new child to the end of the list of children -// for this record. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new child to the end of the list of children for this record. + */ void FltRecord:: add_child(FltRecord *child) { _children.push_back(child); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_num_subfaces -// Access: Public -// Description: Returns the number of subface records of this record. -// Normally, subfaces will only be present on object -// records, although it is logically possible for them to -// appear anywhere. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of subface records of this record. Normally, subfaces + * will only be present on object records, although it is logically possible + * for them to appear anywhere. + */ int FltRecord:: get_num_subfaces() const { return _subfaces.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_subface -// Access: Public -// Description: Returns the nth subface of this record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth subface of this record. + */ FltRecord *FltRecord:: get_subface(int n) const { nassertr(n >= 0 && n < (int)_subfaces.size(), (FltRecord *)NULL); return _subfaces[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::clear_subfaces -// Access: Public -// Description: Removes all subfaces from this record. -//////////////////////////////////////////////////////////////////// +/** + * Removes all subfaces from this record. + */ void FltRecord:: clear_subfaces() { _subfaces.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::add_subface -// Access: Public -// Description: Adds a new subface to the end of the list of subfaces -// for this record. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new subface to the end of the list of subfaces for this record. + */ void FltRecord:: add_subface(FltRecord *subface) { _subfaces.push_back(subface); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_num_extensions -// Access: Public -// Description: Returns the number of extension attribute records for -// this object. These are auxiliary nodes, presumably -// of type FO_extension, that have some local meaning to -// the object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of extension attribute records for this object. These + * are auxiliary nodes, presumably of type FO_extension, that have some local + * meaning to the object. + */ int FltRecord:: get_num_extensions() const { return _extensions.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_extension -// Access: Public -// Description: Returns the nth extension of this record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth extension of this record. + */ FltRecord *FltRecord:: get_extension(int n) const { nassertr(n >= 0 && n < (int)_extensions.size(), (FltRecord *)NULL); return _extensions[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::clear_extensions -// Access: Public -// Description: Removes all extensions from this record. -//////////////////////////////////////////////////////////////////// +/** + * Removes all extensions from this record. + */ void FltRecord:: clear_extensions() { _extensions.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::add_extension -// Access: Public -// Description: Adds a new extension to the end of the list of -// extensions for this record. This should be a record -// of type FO_extension. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new extension to the end of the list of extensions for this record. + * This should be a record of type FO_extension. + */ void FltRecord:: add_extension(FltRecord *extension) { _extensions.push_back(extension); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_num_ancillary -// Access: Public -// Description: Returns the number of unsupported ancillary records -// of this record. These are ancillary records that -// appeared following this record in the flt file but that -// aren't directly understood by the flt -// loader--normally, an ancillary record is examined and -// decoded on the spot, and no pointer to it is kept. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unsupported ancillary records of this record. These + * are ancillary records that appeared following this record in the flt file + * but that aren't directly understood by the flt loader--normally, an + * ancillary record is examined and decoded on the spot, and no pointer to it + * is kept. + */ int FltRecord:: get_num_ancillary() const { return _ancillary.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_ancillary -// Access: Public -// Description: Returns the nth unsupported ancillary record of this -// record. See get_num_ancillary(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth unsupported ancillary record of this record. See + * get_num_ancillary(). + */ FltRecord *FltRecord:: get_ancillary(int n) const { nassertr(n >= 0 && n < (int)_ancillary.size(), (FltRecord *)NULL); return _ancillary[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::clear_ancillary -// Access: Public -// Description: Removes all unsupported ancillary records from this -// record. See get_num_ancillary(). -//////////////////////////////////////////////////////////////////// +/** + * Removes all unsupported ancillary records from this record. See + * get_num_ancillary(). + */ void FltRecord:: clear_ancillary() { _ancillary.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::add_ancillary -// Access: Public -// Description: Adds a new unsupported ancillary record to the end of -// the list of ancillary records for this record. This -// record will be written to the flt file following this -// record, without attempting to understand what is in it. -// -// Normally, there is no reason to use this function; if -// the data stored in the FltRecord requires one or more -// ancillary record, the appropriate records will -// automatically be generated when the record is written. -// This function is only required to output a record -// whose type is not supported by the flt loader. But -// it would be better to extend the flt loader to know -// about this new kind of data record. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new unsupported ancillary record to the end of the list of ancillary + * records for this record. This record will be written to the flt file + * following this record, without attempting to understand what is in it. + * + * Normally, there is no reason to use this function; if the data stored in + * the FltRecord requires one or more ancillary record, the appropriate + * records will automatically be generated when the record is written. This + * function is only required to output a record whose type is not supported by + * the flt loader. But it would be better to extend the flt loader to know + * about this new kind of data record. + */ void FltRecord:: add_ancillary(FltRecord *ancillary) { _ancillary.push_back(ancillary); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::has_comment -// Access: Public -// Description: Returns true if this record has a nonempty comment, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this record has a nonempty comment, false otherwise. + */ bool FltRecord:: has_comment() const { return !_comment.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::get_comment -// Access: Public -// Description: Retrieves the comment for this record, or empty -// string if the record has no comment. -//////////////////////////////////////////////////////////////////// +/** + * Retrieves the comment for this record, or empty string if the record has no + * comment. + */ const string &FltRecord:: get_comment() const { return _comment; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::clear_comment -// Access: Public -// Description: Removes the comment for this record. -//////////////////////////////////////////////////////////////////// +/** + * Removes the comment for this record. + */ void FltRecord:: clear_comment() { _comment = ""; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::set_comment -// Access: Public -// Description: Changes the comment for this record. -//////////////////////////////////////////////////////////////////// +/** + * Changes the comment for this record. + */ void FltRecord:: set_comment(const string &comment) { _comment = comment; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::check_remaining_size -// Access: Public -// Description: Checks that the iterator has no bytes left, as it -// should at the end of a successfully read record. If -// there *are* remaining bytes, print a warning message -// but otherwise don't worry about it. -// -// If we are attempting to read a flt file whose version -// is newer than the newest this program understands, -// don't even print a warning message, since this is -// exactly the sort of thing we expect. -//////////////////////////////////////////////////////////////////// +/** + * Checks that the iterator has no bytes left, as it should at the end of a + * successfully read record. If there *are* remaining bytes, print a warning + * message but otherwise don't worry about it. + * + * If we are attempting to read a flt file whose version is newer than the + * newest this program understands, don't even print a warning message, since + * this is exactly the sort of thing we expect. + */ void FltRecord:: check_remaining_size(const DatagramIterator &di, const string &name) const { if (di.get_remaining_size() == 0) { @@ -327,15 +268,12 @@ check_remaining_size(const DatagramIterator &di, const string &name) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::apply_converted_filenames -// Access: Public, Virtual -// Description: Walks the hierarchy at this record and below and -// copies the _converted_filename record into the -// _orig_filename record, so the flt file will be -// written out with the converted filename instead of -// what was originally read in. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy at this record and below and copies the + * _converted_filename record into the _orig_filename record, so the flt file + * will be written out with the converted filename instead of what was + * originally read in. + */ void FltRecord:: apply_converted_filenames() { Records::const_iterator ci; @@ -347,40 +285,31 @@ apply_converted_filenames() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::output -// Access: Public -// Description: Writes a quick one-line description of the record, but -// not its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a quick one-line description of the record, but not its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltRecord:: output(ostream &out) const { out << get_type(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::write -// Access: Public -// Description: Writes a multiple-line description of the record and -// all of its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a multiple-line description of the record and all of its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltRecord:: write(ostream &out, int indent_level) const { indent(out, indent_level) << *this; write_children(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::write_children -// Access: Protected -// Description: Assuming the current write position has been left at -// the end of the last line of the record description, -// writes out the list of children. -//////////////////////////////////////////////////////////////////// +/** + * Assuming the current write position has been left at the end of the last + * line of the record description, writes out the list of children. + */ void FltRecord:: write_children(ostream &out, int indent_level) const { if (!_ancillary.empty()) { @@ -414,17 +343,13 @@ write_children(ostream &out, int indent_level) const { virtual void build_record(Datagram &datagram) const; */ -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::is_ancillary -// Access: Protected, Static -// Description: Returns true if the indicated opcode corresponds to -// an ancillary record type, false otherwise. In -// general, this function is used to identify ancillary -// records that are not presently supported by the -// FltReader; these will be ignored. Normally, -// ancillary records will be detected and processed by -// extract_ancillary(). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated opcode corresponds to an ancillary record + * type, false otherwise. In general, this function is used to identify + * ancillary records that are not presently supported by the FltReader; these + * will be ignored. Normally, ancillary records will be detected and + * processed by extract_ancillary(). + */ bool FltRecord:: is_ancillary(FltOpcode opcode) { switch (opcode) { @@ -510,13 +435,10 @@ is_ancillary(FltOpcode opcode) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::create_new_record -// Access: Protected -// Description: Creates a new FltRecord corresponding to the opcode. -// If the opcode is unknown, creates a -// FltUnsupportedRecord. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new FltRecord corresponding to the opcode. If the opcode is + * unknown, creates a FltUnsupportedRecord. + */ FltRecord *FltRecord:: create_new_record(FltOpcode opcode) const { switch (opcode) { @@ -565,17 +487,14 @@ create_new_record(FltOpcode opcode) const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::read_record_and_children -// Access: Protected -// Description: Extracts this record information from the current -// record presented in the reader, then advances the -// reader and continues to read any children, if -// present. On return, the reader is position on the -// next sibling record to this record. -// -// Returns FE_ok if successful, otherwise on error. -//////////////////////////////////////////////////////////////////// +/** + * Extracts this record information from the current record presented in the + * reader, then advances the reader and continues to read any children, if + * present. On return, the reader is position on the next sibling record to + * this record. + * + * Returns FE_ok if successful, otherwise on error. + */ FltError FltRecord:: read_record_and_children(FltRecordReader &reader) { if (!extract_record(reader)) { @@ -609,9 +528,9 @@ read_record_and_children(FltRecordReader &reader) { } if (child->is_of_type(FltInstanceDefinition::get_class_type())) { - // A special case for an instance definition. These - // shouldn't appear in the hierarchy, but should instead be - // added directly to the header. + // A special case for an instance definition. These shouldn't + // appear in the hierarchy, but should instead be added directly to + // the header. _header->add_instance(DCAST(FltInstanceDefinition, child)); } else { @@ -683,28 +602,22 @@ read_record_and_children(FltRecordReader &reader) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltRecord:: extract_record(FltRecordReader &) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::extract_ancillary -// Access: Protected, Virtual -// Description: Checks whether the given record, which follows this -// record sequentially in the file, is an ancillary record -// of this record. If it is, extracts the relevant -// information and returns true; otherwise, leaves it -// alone and returns false. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the given record, which follows this record sequentially in + * the file, is an ancillary record of this record. If it is, extracts the + * relevant information and returns true; otherwise, leaves it alone and + * returns false. + */ bool FltRecord:: extract_ancillary(FltRecordReader &reader) { if (reader.get_opcode() == FO_comment) { @@ -715,13 +628,11 @@ extract_ancillary(FltRecordReader &reader) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::write_record_and_children -// Access: Protected, Virtual -// Description: Writes this record out to the flt file, along with all -// of its ancillary records and children records. Returns -// FE_ok on success, or something else on error. -//////////////////////////////////////////////////////////////////// +/** + * Writes this record out to the flt file, along with all of its ancillary + * records and children records. Returns FE_ok on success, or something else + * on error. + */ FltError FltRecord:: write_record_and_children(FltRecordWriter &writer) const { // First, write the record. @@ -786,8 +697,8 @@ write_record_and_children(FltRecordWriter &writer) const { } } - // We must write subfaces *after* the list of children, or Creator - // will crash trying to load the file. + // We must write subfaces *after* the list of children, or Creator will + // crash trying to load the file. if (!_subfaces.empty()) { result = writer.write_record(FO_push_face); if (result != FE_ok) { @@ -807,26 +718,20 @@ write_record_and_children(FltRecordWriter &writer) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltRecord:: build_record(FltRecordWriter &) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecord::write_ancillary -// Access: Protected, Virtual -// Description: Writes whatever ancillary records are required for -// this record. Returns FE_ok on success, or something -// else if there is some error. -//////////////////////////////////////////////////////////////////// +/** + * Writes whatever ancillary records are required for this record. Returns + * FE_ok on success, or something else if there is some error. + */ FltError FltRecord:: write_ancillary(FltRecordWriter &writer) const { if (!_comment.empty()) { diff --git a/pandatool/src/flt/fltRecord.h b/pandatool/src/flt/fltRecord.h index a2324c29b6..fc64441c7f 100644 --- a/pandatool/src/flt/fltRecord.h +++ b/pandatool/src/flt/fltRecord.h @@ -1,16 +1,15 @@ -// Filename: fltRecord.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecord.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTRECORD_H #define FLTRECORD_H @@ -29,14 +28,11 @@ class FltRecordReader; class FltRecordWriter; class DatagramIterator; -//////////////////////////////////////////////////////////////////// -// Class : FltRecord -// Description : The base class for all kinds of records in a MultiGen -// OpenFlight file. A flt file consists of a hierarchy -// of "beads" of various kinds, each of which may be -// followed by n ancillary records, written sequentially -// to the file. -//////////////////////////////////////////////////////////////////// +/** + * The base class for all kinds of records in a MultiGen OpenFlight file. A + * flt file consists of a hierarchy of "beads" of various kinds, each of which + * may be followed by n ancillary records, written sequentially to the file. + */ class FltRecord : public TypedReferenceCount { public: FltRecord(FltHeader *header); @@ -67,7 +63,7 @@ public: void clear_comment(); void set_comment(const string &comment); - void check_remaining_size(const DatagramIterator &di, + void check_remaining_size(const DatagramIterator &di, const string &name = string()) const; virtual void apply_converted_filenames(); @@ -125,5 +121,3 @@ INLINE ostream &operator << (ostream &out, const FltRecord &record); #include "fltRecord.I" #endif - - diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index ebb8b22fbe..b90e911964 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -1,16 +1,15 @@ -// Filename: fltRecordReader.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecordReader.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltRecordReader.h" #include "config_flt.h" @@ -19,11 +18,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecordReader:: FltRecordReader(istream &in) : _in(in) @@ -40,11 +37,9 @@ FltRecordReader(istream &in) : read_next_header(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecordReader:: ~FltRecordReader() { if (_iterator != (DatagramIterator *)NULL) { @@ -53,36 +48,28 @@ FltRecordReader:: } } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::get_opcode -// Access: Public -// Description: Returns the opcode associated with the current -// record. -//////////////////////////////////////////////////////////////////// +/** + * Returns the opcode associated with the current record. + */ FltOpcode FltRecordReader:: get_opcode() const { nassertr(_state == S_normal, FO_none); return _opcode; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::get_iterator -// Access: Public -// Description: Returns an iterator suitable for extracting data from -// the current record. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator suitable for extracting data from the current record. + */ DatagramIterator &FltRecordReader:: get_iterator() { nassertr(_state == S_normal, *_iterator); return *_iterator; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::get_datagram -// Access: Public -// Description: Returns the datagram representing the entire record, -// less the four-byte header. -//////////////////////////////////////////////////////////////////// +/** + * Returns the datagram representing the entire record, less the four-byte + * header. + */ const Datagram &FltRecordReader:: get_datagram() { #ifndef NDEBUG @@ -92,24 +79,18 @@ get_datagram() { return _iterator->get_datagram(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::get_record_length -// Access: Public -// Description: Returns the entire length of the record, including -// the four-byte header. -//////////////////////////////////////////////////////////////////// +/** + * Returns the entire length of the record, including the four-byte header. + */ int FltRecordReader:: get_record_length() const { return _record_length; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::advance -// Access: Public -// Description: Extracts the next record from the file. Returns true -// if there is another record, or false if the end of -// file has been reached. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the next record from the file. Returns true if there is another + * record, or false if the end of file has been reached. + */ FltError FltRecordReader:: advance(bool ok_eof) { if (_state == S_eof) { @@ -210,39 +191,31 @@ advance(bool ok_eof) { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::eof -// Access: Public -// Description: Returns true if end-of-file has been reached without -// error. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if end-of-file has been reached without error. + */ bool FltRecordReader:: eof() const { return _state == S_eof; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::error -// Access: Public -// Description: Returns true if some error has been encountered while -// reading (for instance, a truncated file). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if some error has been encountered while reading (for + * instance, a truncated file). + */ bool FltRecordReader:: error() const { return _state == S_error; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordReader::read_next_header -// Access: Private -// Description: Reads the four-byte header for the next record, which -// contains the next opcode and record length. -// -// We need read the next header in advance so we can -// check to see if it happens to be a continuation -// record. If it is, we will need to concatenate the -// records together before returning. -//////////////////////////////////////////////////////////////////// +/** + * Reads the four-byte header for the next record, which contains the next + * opcode and record length. + * + * We need read the next header in advance so we can check to see if it + * happens to be a continuation record. If it is, we will need to concatenate + * the records together before returning. + */ void FltRecordReader:: read_next_header() { char bytes[header_size]; diff --git a/pandatool/src/flt/fltRecordReader.h b/pandatool/src/flt/fltRecordReader.h index 0005cf8c56..09800f7e42 100644 --- a/pandatool/src/flt/fltRecordReader.h +++ b/pandatool/src/flt/fltRecordReader.h @@ -1,16 +1,15 @@ -// Filename: fltRecordReader.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecordReader.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTRECORDREADER_H #define FLTRECORDREADER_H @@ -23,14 +22,11 @@ #include "datagram.h" #include "datagramIterator.h" -//////////////////////////////////////////////////////////////////// -// Class : FltRecordReader -// Description : This class turns an istream into a sequence of -// FltRecords by reading a sequence of Datagrams and -// extracting the opcode from each one. It remembers -// where it is in the file and what the current record -// is. -//////////////////////////////////////////////////////////////////// +/** + * This class turns an istream into a sequence of FltRecords by reading a + * sequence of Datagrams and extracting the opcode from each one. It + * remembers where it is in the file and what the current record is. + */ class FltRecordReader { public: FltRecordReader(istream &in); @@ -69,5 +65,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index e65eed9ebd..55ca9fc0d4 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -1,16 +1,15 @@ -// Filename: fltRecordWriter.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecordWriter.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltRecordWriter.h" #include "fltInstanceDefinition.h" @@ -21,73 +20,57 @@ #include -// Don't attempt to write more than this number of bytes in one -// record. If the record requires more than this, use continuation -// records. +// Don't attempt to write more than this number of bytes in one record. If +// the record requires more than this, use continuation records. static const int max_write_length = 65532; -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecordWriter:: FltRecordWriter(ostream &out) : _out(out) { } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltRecordWriter:: ~FltRecordWriter() { } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::set_opcode -// Access: Public -// Description: Sets the opcode associated with the current record. -//////////////////////////////////////////////////////////////////// +/** + * Sets the opcode associated with the current record. + */ void FltRecordWriter:: set_opcode(FltOpcode opcode) { _opcode = opcode; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::set_datagram -// Access: Public -// Description: Sets the datagram that will be written when advance() -// is called. -//////////////////////////////////////////////////////////////////// +/** + * Sets the datagram that will be written when advance() is called. + */ void FltRecordWriter:: set_datagram(const Datagram &datagram) { _datagram = datagram; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::update_datagram -// Access: Public -// Description: Returns a modifiable reference to the datagram -// associated with the current record. This datagram -// should then be stuffed with data corresponding to the -// data in the record, in preparation for calling -// advance() to write the data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a modifiable reference to the datagram associated with the current + * record. This datagram should then be stuffed with data corresponding to + * the data in the record, in preparation for calling advance() to write the + * data. + */ Datagram &FltRecordWriter:: update_datagram() { return _datagram; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::advance -// Access: Public -// Description: Writes the current record to the flt file, and resets -// the current record to receive new data. Returns -// FE_ok on success, or something else on error. -//////////////////////////////////////////////////////////////////// +/** + * Writes the current record to the flt file, and resets the current record to + * receive new data. Returns FE_ok on success, or something else on error. + */ FltError FltRecordWriter:: advance() { int start_byte = 0; @@ -134,13 +117,10 @@ advance() { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::write_record -// Access: Public -// Description: A convenience function to quickly write a simple -// record that consists of an opcode and possibly a -// datagram. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to quickly write a simple record that consists of an + * opcode and possibly a datagram. + */ FltError FltRecordWriter:: write_record(FltOpcode opcode, const Datagram &datagram) { _opcode = opcode; @@ -148,13 +128,10 @@ write_record(FltOpcode opcode, const Datagram &datagram) { return advance(); } -//////////////////////////////////////////////////////////////////// -// Function: FltRecordWriter::write_instance_def -// Access: Public -// Description: Ensures that the given instance definition has -// already been written to the file. If it has not, -// writes it now. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that the given instance definition has already been written to the + * file. If it has not, writes it now. + */ FltError FltRecordWriter:: write_instance_def(FltHeader *header, int instance_index) { bool inserted = _instances_written.insert(instance_index).second; diff --git a/pandatool/src/flt/fltRecordWriter.h b/pandatool/src/flt/fltRecordWriter.h index de9a7f499e..6c8798937c 100644 --- a/pandatool/src/flt/fltRecordWriter.h +++ b/pandatool/src/flt/fltRecordWriter.h @@ -1,16 +1,15 @@ -// Filename: fltRecordWriter.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltRecordWriter.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTRECORDWRITER_H #define FLTRECORDWRITER_H @@ -25,11 +24,10 @@ class FltHeader; -//////////////////////////////////////////////////////////////////// -// Class : FltRecordWriter -// Description : This class writes a sequence of FltRecords to an -// ostream, handling opcode and size counts properly. -//////////////////////////////////////////////////////////////////// +/** + * This class writes a sequence of FltRecords to an ostream, handling opcode + * and size counts properly. + */ class FltRecordWriter { public: FltRecordWriter(ostream &out); @@ -57,5 +55,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTexture.cxx b/pandatool/src/flt/fltTexture.cxx index be5d3eee63..dfc2b9d987 100644 --- a/pandatool/src/flt/fltTexture.cxx +++ b/pandatool/src/flt/fltTexture.cxx @@ -1,16 +1,15 @@ -// Filename: fltTexture.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTexture.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltTexture.h" #include "fltRecordReader.h" @@ -21,11 +20,9 @@ TypeHandle FltTexture::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTexture:: FltTexture(FltHeader *header) : FltRecord(header) { _pattern_index = -1; @@ -85,71 +82,56 @@ FltTexture(FltHeader *header) : FltRecord(header) { _file_version = 1501; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::apply_converted_filenames -// Access: Public, Virtual -// Description: Walks the hierarchy at this record and below and -// copies the _converted_filename record into the -// _orig_filename record, so the flt file will be -// written out with the converted filename instead of -// what was originally read in. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy at this record and below and copies the + * _converted_filename record into the _orig_filename record, so the flt file + * will be written out with the converted filename instead of what was + * originally read in. + */ void FltTexture:: apply_converted_filenames() { _orig_filename = _converted_filename.to_os_generic(); FltRecord::apply_converted_filenames(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::get_texture_filename -// Access: Public -// Description: Returns the name of the texture image file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the texture image file. + */ Filename FltTexture:: get_texture_filename() const { return _converted_filename; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::set_texture_filename -// Access: Public -// Description: Changes the name of the texture image file. -//////////////////////////////////////////////////////////////////// +/** + * Changes the name of the texture image file. + */ void FltTexture:: set_texture_filename(const Filename &filename) { - _converted_filename = filename; + _converted_filename = filename; _orig_filename = _converted_filename.to_os_generic(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::get_attr_filename -// Access: Public -// Description: Returns the name of the texture's associated .attr -// file. This contains some additional MultiGen -// information about the texture parameters. This is, -// of course, just the name of the texture with .attr -// appended. -// -// Normally, it won't be necessary to access this file -// directly; you can call read_attr_data() or -// write_attr_data() to get at the data stored in this -// file. (And read_attr_data() is called automatically -// when the Flt file is read in.) -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the texture's associated .attr file. This contains + * some additional MultiGen information about the texture parameters. This + * is, of course, just the name of the texture with .attr appended. + * + * Normally, it won't be necessary to access this file directly; you can call + * read_attr_data() or write_attr_data() to get at the data stored in this + * file. (And read_attr_data() is called automatically when the Flt file is + * read in.) + */ Filename FltTexture:: get_attr_filename() const { string texture_filename = get_texture_filename(); return Filename::binary_filename(texture_filename + ".attr"); } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::read_attr_data -// Access: Public -// Description: Opens up the texture's .attr file and reads its data -// into the extra FltTexture fields. This is normally -// performed automatically when the Flt file is read -// from disk. -//////////////////////////////////////////////////////////////////// +/** + * Opens up the texture's .attr file and reads its data into the extra + * FltTexture fields. This is normally performed automatically when the Flt + * file is read from disk. + */ FltError FltTexture:: read_attr_data() { Filename attr_filename = get_attr_filename(); @@ -159,8 +141,7 @@ read_attr_data() { return FE_could_not_open; } - // Determine the file's size so we can read it all into one big - // datagram. + // Determine the file's size so we can read it all into one big datagram. attr.seekg(0, ios::end); if (attr.fail()) { return FE_read_error; @@ -181,24 +162,19 @@ read_attr_data() { return unpack_attr(datagram); } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::write_attr_data -// Access: Public -// Description: Writes the texture's .attr file. This may or may -// not be performed automatically, according to the -// setting of FltHeader::set_auto_attr_update(). -//////////////////////////////////////////////////////////////////// +/** + * Writes the texture's .attr file. This may or may not be performed + * automatically, according to the setting of + * FltHeader::set_auto_attr_update(). + */ FltError FltTexture:: write_attr_data() const { return write_attr_data(get_attr_filename()); } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::write_attr_data -// Access: Public -// Description: Writes the texture's .attr file to the named -// file. -//////////////////////////////////////////////////////////////////// +/** + * Writes the texture's .attr file to the named file. + */ FltError FltTexture:: write_attr_data(Filename attr_filename) const { Datagram datagram; @@ -220,14 +196,11 @@ write_attr_data(Filename attr_filename) const { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTexture:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -255,14 +228,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTexture:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -288,11 +258,9 @@ build_record(FltRecordWriter &writer) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::unpack_attr -// Access: Private -// Description: Reads the data from the attribute file. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data from the attribute file. + */ FltError FltTexture:: unpack_attr(const Datagram &datagram) { DatagramIterator iterator(datagram); @@ -399,11 +367,9 @@ unpack_attr(const Datagram &datagram) { return FE_ok; } -//////////////////////////////////////////////////////////////////// -// Function: FltTexture::pack_attr -// Access: Private -// Description: Packs the attribute data into a big datagram. -//////////////////////////////////////////////////////////////////// +/** + * Packs the attribute data into a big datagram. + */ FltError FltTexture:: pack_attr(Datagram &datagram) const { datagram.add_be_int32(_num_texels_u); diff --git a/pandatool/src/flt/fltTexture.h b/pandatool/src/flt/fltTexture.h index 2322bd7496..21e1a24141 100644 --- a/pandatool/src/flt/fltTexture.h +++ b/pandatool/src/flt/fltTexture.h @@ -1,16 +1,15 @@ -// Filename: fltTexture.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTexture.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTTEXTURE_H #define FLTTEXTURE_H @@ -22,10 +21,9 @@ #include "filename.h" #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTexture -// Description : Represents a single texture in the texture palette. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single texture in the texture palette. + */ class FltTexture : public FltRecord { public: FltTexture(FltHeader *header); @@ -252,5 +250,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTrackplane.cxx b/pandatool/src/flt/fltTrackplane.cxx index 042061fad8..13f8a58cb9 100644 --- a/pandatool/src/flt/fltTrackplane.cxx +++ b/pandatool/src/flt/fltTrackplane.cxx @@ -1,26 +1,23 @@ -// Filename: fltTrackplane.cxx -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTrackplane.cxx + * @author drose + * @date 2000-08-26 + */ #include "fltTrackplane.h" #include "fltRecordReader.h" #include "fltRecordWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: FltTrackplane::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTrackplane:: FltTrackplane() { _origin.set(0.0, 0.0, 0.0); @@ -37,11 +34,9 @@ FltTrackplane() { _grid_mask = 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltTrackplane::extract_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltTrackplane:: extract_record(FltRecordReader &reader) { DatagramIterator &iterator = reader.get_iterator(); @@ -70,11 +65,9 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTrackplane::build_record -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltTrackplane:: build_record(FltRecordWriter &writer) const { Datagram &datagram = writer.update_datagram(); diff --git a/pandatool/src/flt/fltTrackplane.h b/pandatool/src/flt/fltTrackplane.h index 7fed3f931e..306f81e9dc 100644 --- a/pandatool/src/flt/fltTrackplane.h +++ b/pandatool/src/flt/fltTrackplane.h @@ -1,16 +1,15 @@ -// Filename: fltTrackplane.h -// Created by: drose (26Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTrackplane.h + * @author drose + * @date 2000-08-26 + */ #ifndef FLTTRACKPLANE_H #define FLTTRACKPLANE_H @@ -22,11 +21,9 @@ class FltRecordReader; class FltRecordWriter; -//////////////////////////////////////////////////////////////////// -// Class : FltTrackplane -// Description : A single trackplane entry in the eyepoint/trackplane -// palette. -//////////////////////////////////////////////////////////////////// +/** + * A single trackplane entry in the eyepoint/trackplane palette. + */ class FltTrackplane { public: FltTrackplane(); @@ -50,6 +47,3 @@ public: }; #endif - - - diff --git a/pandatool/src/flt/fltTransformGeneralMatrix.cxx b/pandatool/src/flt/fltTransformGeneralMatrix.cxx index 2b54b1b847..1c8adf4c65 100644 --- a/pandatool/src/flt/fltTransformGeneralMatrix.cxx +++ b/pandatool/src/flt/fltTransformGeneralMatrix.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformGeneralMatrix.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformGeneralMatrix.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltTransformGeneralMatrix.h" #include "fltRecordReader.h" @@ -18,43 +17,34 @@ TypeHandle FltTransformGeneralMatrix::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformGeneralMatrix::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformGeneralMatrix:: FltTransformGeneralMatrix(FltHeader *header) : FltTransformRecord(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformGeneralMatrix::set_matrix -// Access: Public -// Description: Directly sets the general matrix. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the general matrix. + */ void FltTransformGeneralMatrix:: set_matrix(const LMatrix4d &matrix) { _matrix = matrix; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformGeneralMatrix::set_matrix -// Access: Public -// Description: Directly sets the general matrix. -//////////////////////////////////////////////////////////////////// +/** + * Directly sets the general matrix. + */ void FltTransformGeneralMatrix:: set_matrix(const LMatrix4f &matrix) { _matrix = LCAST(double, matrix); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformGeneralMatrix::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformGeneralMatrix:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -74,14 +64,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformGeneralMatrix::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformGeneralMatrix:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { diff --git a/pandatool/src/flt/fltTransformGeneralMatrix.h b/pandatool/src/flt/fltTransformGeneralMatrix.h index 7d0449cc38..e56fe94ec2 100644 --- a/pandatool/src/flt/fltTransformGeneralMatrix.h +++ b/pandatool/src/flt/fltTransformGeneralMatrix.h @@ -1,16 +1,15 @@ -// Filename: fltTransformGeneralMatrix.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformGeneralMatrix.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTTRANSFORMGENERALMATRIX_H #define FLTTRANSFORMGENERALMATRIX_H @@ -19,12 +18,10 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformGeneralMatrix -// Description : A general 4x4 matrix. This appears in the flt file -// when there is no record of the composition of the -// transform. -//////////////////////////////////////////////////////////////////// +/** + * A general 4x4 matrix. This appears in the flt file when there is no record + * of the composition of the transform. + */ class FltTransformGeneralMatrix : public FltTransformRecord { public: FltTransformGeneralMatrix(FltHeader *header); @@ -55,5 +52,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTransformPut.cxx b/pandatool/src/flt/fltTransformPut.cxx index 09a517b2e9..612c6b07b7 100644 --- a/pandatool/src/flt/fltTransformPut.cxx +++ b/pandatool/src/flt/fltTransformPut.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformPut.cxx -// Created by: drose (29Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformPut.cxx + * @author drose + * @date 2000-08-29 + */ #include "fltTransformPut.h" #include "fltRecordReader.h" @@ -20,11 +19,9 @@ TypeHandle FltTransformPut::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformPut:: FltTransformPut(FltHeader *header) : FltTransformRecord(header) { _from_origin.set(0.0, 0.0, 0.0); @@ -35,13 +32,10 @@ FltTransformPut(FltHeader *header) : FltTransformRecord(header) { _to_track.set(1.0, 0.0, 0.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::set -// Access: Public -// Description: Defines the put explicitly. The transformation will -// map the three "from" points to the corresponding -// three "to" points. -//////////////////////////////////////////////////////////////////// +/** + * Defines the put explicitly. The transformation will map the three "from" + * points to the corresponding three "to" points. + */ void FltTransformPut:: set(const LPoint3d &from_origin, const LPoint3d &from_align, const LPoint3d &from_track, @@ -57,71 +51,57 @@ set(const LPoint3d &from_origin, const LPoint3d &from_align, recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_from_origin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_from_origin() const { return _from_origin; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_from_align -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_from_align() const { return _from_align; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_from_track -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_from_track() const { return _from_track; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_to_origin -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_to_origin() const { return _to_origin; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_to_align -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_to_align() const { return _to_align; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::get_to_track -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformPut:: get_to_track() const { return _to_track; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformPut:: recompute_matrix() { LMatrix4d r1, r2; @@ -135,14 +115,11 @@ recompute_matrix() { LMatrix4d::translate_mat(_to_origin); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformPut:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -179,14 +156,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformPut::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformPut:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -219,4 +193,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltTransformPut.h b/pandatool/src/flt/fltTransformPut.h index a6b9f9ddd8..fdfab77825 100644 --- a/pandatool/src/flt/fltTransformPut.h +++ b/pandatool/src/flt/fltTransformPut.h @@ -1,16 +1,15 @@ -// Filename: fltTransformPut.h -// Created by: drose (29Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformPut.h + * @author drose + * @date 2000-08-29 + */ #ifndef FLTTRANSFORMPUT_H #define FLTTRANSFORMPUT_H @@ -19,12 +18,10 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformPut -// Description : A "put", which is a MultiGen concept of defining a -// transformation by mapping three arbitrary points to -// three new arbitrary points. -//////////////////////////////////////////////////////////////////// +/** + * A "put", which is a MultiGen concept of defining a transformation by + * mapping three arbitrary points to three new arbitrary points. + */ class FltTransformPut : public FltTransformRecord { public: FltTransformPut(FltHeader *header); @@ -76,5 +73,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTransformRecord.cxx b/pandatool/src/flt/fltTransformRecord.cxx index ccf6a43327..bc1275bc5a 100644 --- a/pandatool/src/flt/fltTransformRecord.cxx +++ b/pandatool/src/flt/fltTransformRecord.cxx @@ -1,37 +1,32 @@ -// Filename: fltTransformRecord.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRecord.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltTransformRecord.h" TypeHandle FltTransformRecord::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformRecord:: FltTransformRecord(FltHeader *header) : FltRecord(header) { _matrix = LMatrix4d::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRecord::get_matrix -// Access: Public -// Description: Returns the transform matrix represented by this -// particular component of the transform. -//////////////////////////////////////////////////////////////////// +/** + * Returns the transform matrix represented by this particular component of + * the transform. + */ const LMatrix4d &FltTransformRecord:: get_matrix() const { return _matrix; diff --git a/pandatool/src/flt/fltTransformRecord.h b/pandatool/src/flt/fltTransformRecord.h index 8e08a98732..b2679b8430 100644 --- a/pandatool/src/flt/fltTransformRecord.h +++ b/pandatool/src/flt/fltTransformRecord.h @@ -1,16 +1,15 @@ -// Filename: fltTransformRecord.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRecord.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTTRANSFORMRECORD_H #define FLTTRANSFORMRECORD_H @@ -21,13 +20,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformRecord -// Description : A base class for a number of types of ancillary -// records that follow beads and indicate some kind of a -// transformation. Pointers of this type are collected -// in the FltTransformation class. -//////////////////////////////////////////////////////////////////// +/** + * A base class for a number of types of ancillary records that follow beads + * and indicate some kind of a transformation. Pointers of this type are + * collected in the FltTransformation class. + */ class FltTransformRecord : public FltRecord { public: FltTransformRecord(FltHeader *header); @@ -58,5 +55,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx b/pandatool/src/flt/fltTransformRotateAboutEdge.cxx index e53c800729..ec4bbf9597 100644 --- a/pandatool/src/flt/fltTransformRotateAboutEdge.cxx +++ b/pandatool/src/flt/fltTransformRotateAboutEdge.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateAboutEdge.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateAboutEdge.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltTransformRotateAboutEdge.h" #include "fltRecordReader.h" @@ -18,11 +17,9 @@ TypeHandle FltTransformRotateAboutEdge::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformRotateAboutEdge:: FltTransformRotateAboutEdge(FltHeader *header) : FltTransformRecord(header) { _point_a.set(0.0, 0.0, 0.0); @@ -30,12 +27,10 @@ FltTransformRotateAboutEdge(FltHeader *header) : FltTransformRecord(header) { _angle = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::set -// Access: Public -// Description: Defines the rotation. The angle is given in degrees, -// counterclockwise about the axis as seen from point a. -//////////////////////////////////////////////////////////////////// +/** + * Defines the rotation. The angle is given in degrees, counterclockwise + * about the axis as seen from point a. + */ void FltTransformRotateAboutEdge:: set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle) { _point_a = point_a; @@ -45,42 +40,34 @@ set(const LPoint3d &point_a, const LPoint3d &point_b, PN_stdfloat angle) { recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::get_point_a -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateAboutEdge:: get_point_a() const { return _point_a; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::get_point_b -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateAboutEdge:: get_point_b() const { return _point_b; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::get_angle -// Access: Public -// Description: Returns the angle of rotation, in degrees -// counterclockwise about the axis as seen from point a. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle of rotation, in degrees counterclockwise about the axis + * as seen from point a. + */ PN_stdfloat FltTransformRotateAboutEdge:: get_angle() const { return _angle; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformRotateAboutEdge:: recompute_matrix() { if (_point_a == _point_b) { @@ -95,14 +82,11 @@ recompute_matrix() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformRotateAboutEdge:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -130,14 +114,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutEdge::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformRotateAboutEdge:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -161,4 +142,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltTransformRotateAboutEdge.h b/pandatool/src/flt/fltTransformRotateAboutEdge.h index adeae7ea89..34ce585479 100644 --- a/pandatool/src/flt/fltTransformRotateAboutEdge.h +++ b/pandatool/src/flt/fltTransformRotateAboutEdge.h @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateAboutEdge.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateAboutEdge.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTTRANSFORMROTATEABOUTEDGE_H #define FLTTRANSFORMROTATEABOUTEDGE_H @@ -19,11 +18,10 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformRotateAboutEdge -// Description : A transformation that rotates about a particular axis -// in space, defined by two endpoints. -//////////////////////////////////////////////////////////////////// +/** + * A transformation that rotates about a particular axis in space, defined by + * two endpoints. + */ class FltTransformRotateAboutEdge : public FltTransformRecord { public: FltTransformRotateAboutEdge(FltHeader *header); diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx b/pandatool/src/flt/fltTransformRotateAboutPoint.cxx index c04ebe5924..1c6db87989 100644 --- a/pandatool/src/flt/fltTransformRotateAboutPoint.cxx +++ b/pandatool/src/flt/fltTransformRotateAboutPoint.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateAboutPoint.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateAboutPoint.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltTransformRotateAboutPoint.h" #include "fltRecordReader.h" @@ -18,11 +17,9 @@ TypeHandle FltTransformRotateAboutPoint::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformRotateAboutPoint:: FltTransformRotateAboutPoint(FltHeader *header) : FltTransformRecord(header) { _center.set(0.0, 0.0, 0.0); @@ -30,12 +27,10 @@ FltTransformRotateAboutPoint(FltHeader *header) : FltTransformRecord(header) { _angle = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::set -// Access: Public -// Description: Defines the rotation. The angle is given in degrees, -// counterclockwise about the axis as seen from point a. -//////////////////////////////////////////////////////////////////// +/** + * Defines the rotation. The angle is given in degrees, counterclockwise + * about the axis as seen from point a. + */ void FltTransformRotateAboutPoint:: set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle) { _center = center; @@ -45,42 +40,33 @@ set(const LPoint3d ¢er, const LVector3 &axis, PN_stdfloat angle) { recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::get_center -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateAboutPoint:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::get_axis -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVector3 &FltTransformRotateAboutPoint:: get_axis() const { return _axis; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::get_angle -// Access: Public -// Description: Returns the angle of rotation, in degrees -// counterclockwise about the axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle of rotation, in degrees counterclockwise about the axis. + */ PN_stdfloat FltTransformRotateAboutPoint:: get_angle() const { return _angle; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformRotateAboutPoint:: recompute_matrix() { if (_axis == LVector3::zero()) { @@ -96,14 +82,11 @@ recompute_matrix() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformRotateAboutPoint:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -129,14 +112,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateAboutPoint::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformRotateAboutPoint:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -158,4 +138,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltTransformRotateAboutPoint.h b/pandatool/src/flt/fltTransformRotateAboutPoint.h index f61015d896..716bb56ca3 100644 --- a/pandatool/src/flt/fltTransformRotateAboutPoint.h +++ b/pandatool/src/flt/fltTransformRotateAboutPoint.h @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateAboutPoint.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateAboutPoint.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTTRANSFORMROTATEABOUTPOINT_H #define FLTTRANSFORMROTATEABOUTPOINT_H @@ -19,11 +18,10 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformRotateAboutPoint -// Description : A transformation that rotates about a particular axis -// in space, defined by a point and vector. -//////////////////////////////////////////////////////////////////// +/** + * A transformation that rotates about a particular axis in space, defined by + * a point and vector. + */ class FltTransformRotateAboutPoint : public FltTransformRecord { public: FltTransformRotateAboutPoint(FltHeader *header); diff --git a/pandatool/src/flt/fltTransformRotateScale.cxx b/pandatool/src/flt/fltTransformRotateScale.cxx index f7b5c0daba..e81dbb472e 100644 --- a/pandatool/src/flt/fltTransformRotateScale.cxx +++ b/pandatool/src/flt/fltTransformRotateScale.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateScale.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateScale.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltTransformRotateScale.h" #include "fltRecordReader.h" @@ -21,11 +20,9 @@ TypeHandle FltTransformRotateScale::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformRotateScale:: FltTransformRotateScale(FltHeader *header) : FltTransformRecord(header) { _center.set(0.0, 0.0, 0.0); @@ -36,18 +33,13 @@ FltTransformRotateScale(FltHeader *header) : FltTransformRecord(header) { _angle = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::set -// Access: Public -// Description: Defines the transform explicitly. The angle of -// rotation is determined by the angle between the -// reference point and the to point (relative to the -// center), and the scale factor is determined by the -// distance between the reference point and the center -// point. If axis_scale is true, the scale is along -// reference point axis only; otherwise, it is a uniform -// scale. -//////////////////////////////////////////////////////////////////// +/** + * Defines the transform explicitly. The angle of rotation is determined by + * the angle between the reference point and the to point (relative to the + * center), and the scale factor is determined by the distance between the + * reference point and the center point. If axis_scale is true, the scale is + * along reference point axis only; otherwise, it is a uniform scale. + */ void FltTransformRotateScale:: set(const LPoint3d ¢er, const LPoint3d &reference_point, const LPoint3d &to_point, bool axis_scale) { @@ -72,81 +64,65 @@ set(const LPoint3d ¢er, const LPoint3d &reference_point, recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_center -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateScale:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_reference_point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateScale:: get_reference_point() const { return _reference_point; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_to_point -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformRotateScale:: get_to_point() const { return _to_point; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_overall_scale -// Access: Public -// Description: Returns the overall scale factor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall scale factor. + */ PN_stdfloat FltTransformRotateScale:: get_overall_scale() const { return _overall_scale; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_axis_scale -// Access: Public -// Description: Returns the scale factor in the direction of the -// axis. -//////////////////////////////////////////////////////////////////// +/** + * Returns the scale factor in the direction of the axis. + */ PN_stdfloat FltTransformRotateScale:: get_axis_scale() const { return _axis_scale; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::get_angle -// Access: Public -// Description: Returns the angle of rotation in degrees. -//////////////////////////////////////////////////////////////////// +/** + * Returns the angle of rotation in degrees. + */ PN_stdfloat FltTransformRotateScale:: get_angle() const { return _angle; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformRotateScale:: recompute_matrix() { LVector3d v1 = _reference_point - _center; LVector3d v2 = _to_point - _center; LVector3d rotate_axis = normalize(cross(v1, v2)); - // To scale along an axis, we have to do a bit of work. First - // determine the matrices to rotate and unrotate the rotate axis - // to the y-forward axis. + // To scale along an axis, we have to do a bit of work. First determine the + // matrices to rotate and unrotate the rotate axis to the y-forward axis. LMatrix4d r1; look_at(r1, v1, rotate_axis, CS_zup_right); @@ -160,14 +136,11 @@ recompute_matrix() { LMatrix4d::translate_mat(_center); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformRotateScale:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -200,14 +173,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformRotateScale::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformRotateScale:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -236,4 +206,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltTransformRotateScale.h b/pandatool/src/flt/fltTransformRotateScale.h index d6a30a9c28..29b72ddd79 100644 --- a/pandatool/src/flt/fltTransformRotateScale.h +++ b/pandatool/src/flt/fltTransformRotateScale.h @@ -1,16 +1,15 @@ -// Filename: fltTransformRotateScale.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformRotateScale.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTTRANSFORMROTATESCALE_H #define FLTTRANSFORMROTATESCALE_H @@ -19,11 +18,10 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformRotateScale -// Description : A combination rotation and scale. This is sometimes -// called "Rotate To Point" within MultiGen. -//////////////////////////////////////////////////////////////////// +/** + * A combination rotation and scale. This is sometimes called "Rotate To + * Point" within MultiGen. + */ class FltTransformRotateScale : public FltTransformRecord { public: FltTransformRotateScale(FltHeader *header); @@ -71,5 +69,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltTransformScale.cxx b/pandatool/src/flt/fltTransformScale.cxx index a96ddf5f87..69ae6f4cef 100644 --- a/pandatool/src/flt/fltTransformScale.cxx +++ b/pandatool/src/flt/fltTransformScale.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformScale.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformScale.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltTransformScale.h" #include "fltRecordReader.h" @@ -18,22 +17,18 @@ TypeHandle FltTransformScale::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformScale:: FltTransformScale(FltHeader *header) : FltTransformRecord(header) { _center.set(0.0, 0.0, 0.0); _scale.set(1.0, 1.0, 1.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::set -// Access: Public -// Description: Defines the scale. -//////////////////////////////////////////////////////////////////// +/** + * Defines the scale. + */ void FltTransformScale:: set(const LPoint3d ¢er, const LVecBase3 &scale) { _center = center; @@ -42,48 +37,38 @@ set(const LPoint3d ¢er, const LVecBase3 &scale) { recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::has_center -// Access: Public -// Description: Returns true if the center is specified, false if it -// is not. For some reason, MultiGen stores large -// negative numbers in for the center if it is not -// specified. It is unclear what the purpose of this -// is. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the center is specified, false if it is not. For some + * reason, MultiGen stores large negative numbers in for the center if it is + * not specified. It is unclear what the purpose of this is. + */ bool FltTransformScale:: has_center() const { - return - _center[0] > -1e+08 && - _center[1] > -1e+08 && + return + _center[0] > -1e+08 && + _center[1] > -1e+08 && _center[2] > -1e+08; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::get_center -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LPoint3d &FltTransformScale:: get_center() const { return _center; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::get_scale -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVecBase3 &FltTransformScale:: get_scale() const { return _scale; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformScale:: recompute_matrix() { if (has_center()) { @@ -97,14 +82,11 @@ recompute_matrix() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformScale:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -131,14 +113,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformScale::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformScale:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -161,4 +140,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltTransformScale.h b/pandatool/src/flt/fltTransformScale.h index 492fb93d12..01bc6296ca 100644 --- a/pandatool/src/flt/fltTransformScale.h +++ b/pandatool/src/flt/fltTransformScale.h @@ -1,16 +1,15 @@ -// Filename: fltTransformScale.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformScale.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTTRANSFORMSCALE_H #define FLTTRANSFORMSCALE_H @@ -19,11 +18,9 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformScale -// Description : A transformation that applies a (possibly nonuniform) -// scale. -//////////////////////////////////////////////////////////////////// +/** + * A transformation that applies a (possibly nonuniform) scale. + */ class FltTransformScale : public FltTransformRecord { public: FltTransformScale(FltHeader *header); diff --git a/pandatool/src/flt/fltTransformTranslate.cxx b/pandatool/src/flt/fltTransformTranslate.cxx index 65777da981..1a06d761a3 100644 --- a/pandatool/src/flt/fltTransformTranslate.cxx +++ b/pandatool/src/flt/fltTransformTranslate.cxx @@ -1,16 +1,15 @@ -// Filename: fltTransformTranslate.cxx -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformTranslate.cxx + * @author drose + * @date 2000-08-30 + */ #include "fltTransformTranslate.h" #include "fltRecordReader.h" @@ -18,23 +17,18 @@ TypeHandle FltTransformTranslate::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTransformTranslate:: FltTransformTranslate(FltHeader *header) : FltTransformRecord(header) { _from.set(0.0, 0.0, 0.0); _delta.set(0.0, 0.0, 0.0); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::set -// Access: Public -// Description: Defines the translation. The "from" point seems to -// be pretty much ignored. -//////////////////////////////////////////////////////////////////// +/** + * Defines the translation. The "from" point seems to be pretty much ignored. + */ void FltTransformTranslate:: set(const LPoint3d &from, const LVector3d &delta) { _from = from; @@ -43,45 +37,36 @@ set(const LPoint3d &from, const LVector3d &delta) { recompute_matrix(); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::get_from -// Access: Public -// Description: Returns the reference point of the translation. This -// is largely meaningless. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reference point of the translation. This is largely + * meaningless. + */ const LPoint3d &FltTransformTranslate:: get_from() const { return _from; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::get_delta -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ const LVector3d &FltTransformTranslate:: get_delta() const { return _delta; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::recompute_matrix -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTransformTranslate:: recompute_matrix() { _matrix = LMatrix4d::translate_mat(_delta); } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltTransformTranslate:: extract_record(FltRecordReader &reader) { if (!FltTransformRecord::extract_record(reader)) { @@ -100,7 +85,7 @@ extract_record(FltRecordReader &reader) { _delta[1] = iterator.get_be_float64(); _delta[2] = iterator.get_be_float64(); - // iterator.skip_bytes(4); // Undocumented additional padding. + // iterator.skip_bytes(4); Undocumented additional padding. recompute_matrix(); @@ -108,14 +93,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltTransformTranslate::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltTransformTranslate:: build_record(FltRecordWriter &writer) const { if (!FltTransformRecord::build_record(writer)) { @@ -134,8 +116,7 @@ build_record(FltRecordWriter &writer) const { datagram.add_be_float64(_delta[1]); datagram.add_be_float64(_delta[2]); - // datagram.pad_bytes(4); // Undocumented additional padding. + // datagram.pad_bytes(4); Undocumented additional padding. return true; } - diff --git a/pandatool/src/flt/fltTransformTranslate.h b/pandatool/src/flt/fltTransformTranslate.h index 8da946cb09..c9a0c87929 100644 --- a/pandatool/src/flt/fltTransformTranslate.h +++ b/pandatool/src/flt/fltTransformTranslate.h @@ -1,16 +1,15 @@ -// Filename: fltTransformTranslate.h -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTransformTranslate.h + * @author drose + * @date 2000-08-30 + */ #ifndef FLTTRANSFORMTRANSLATE_H #define FLTTRANSFORMTRANSLATE_H @@ -19,10 +18,9 @@ #include "fltTransformRecord.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTransformTranslate -// Description : A transformation that applies a translation. -//////////////////////////////////////////////////////////////////// +/** + * A transformation that applies a translation. + */ class FltTransformTranslate : public FltTransformRecord { public: FltTransformTranslate(FltHeader *header); diff --git a/pandatool/src/flt/fltUnsupportedRecord.cxx b/pandatool/src/flt/fltUnsupportedRecord.cxx index f8776bc4d1..e3bcc07a2a 100644 --- a/pandatool/src/flt/fltUnsupportedRecord.cxx +++ b/pandatool/src/flt/fltUnsupportedRecord.cxx @@ -1,16 +1,15 @@ -// Filename: fltUnsupportedRecord.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltUnsupportedRecord.cxx + * @author drose + * @date 2000-08-24 + */ #include "fltUnsupportedRecord.h" #include "fltRecordReader.h" @@ -18,37 +17,29 @@ TypeHandle FltUnsupportedRecord::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltUnsupportedRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltUnsupportedRecord:: FltUnsupportedRecord(FltHeader *header) : FltRecord(header) { _opcode = FO_none; } -//////////////////////////////////////////////////////////////////// -// Function: FltUnsupportedRecord::output -// Access: Public -// Description: Writes a quick one-line description of the bead, but -// not its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a quick one-line description of the bead, but not its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltUnsupportedRecord:: output(ostream &out) const { out << "Unsupported(" << _opcode << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: FltUnsupportedRecord::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltUnsupportedRecord:: extract_record(FltRecordReader &reader) { _opcode = reader.get_opcode(); @@ -57,14 +48,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltUnsupportedRecord::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltUnsupportedRecord:: build_record(FltRecordWriter &writer) const { writer.set_opcode(_opcode); diff --git a/pandatool/src/flt/fltUnsupportedRecord.h b/pandatool/src/flt/fltUnsupportedRecord.h index bed8b7f827..02131f35f7 100644 --- a/pandatool/src/flt/fltUnsupportedRecord.h +++ b/pandatool/src/flt/fltUnsupportedRecord.h @@ -1,16 +1,15 @@ -// Filename: fltUnsupportedRecord.h -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltUnsupportedRecord.h + * @author drose + * @date 2000-08-24 + */ #ifndef FLTUNSUPPORTEDRECORD_H #define FLTUNSUPPORTEDRECORD_H @@ -21,10 +20,9 @@ #include "datagram.h" -//////////////////////////////////////////////////////////////////// -// Class : FltUnsupportedRecord -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class FltUnsupportedRecord : public FltRecord { public: FltUnsupportedRecord(FltHeader *header); @@ -60,5 +58,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltVectorRecord.cxx b/pandatool/src/flt/fltVectorRecord.cxx index 5fc7c8671b..dbe23a6342 100644 --- a/pandatool/src/flt/fltVectorRecord.cxx +++ b/pandatool/src/flt/fltVectorRecord.cxx @@ -1,16 +1,15 @@ -// Filename: fltVectorRecord.cxx -// Created by: drose (30Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVectorRecord.cxx + * @author drose + * @date 2002-08-30 + */ #include "fltVectorRecord.h" #include "fltRecordReader.h" @@ -18,34 +17,27 @@ TypeHandle FltVectorRecord::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltVectorRecord::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltVectorRecord:: FltVectorRecord(FltHeader *header) : FltRecord(header) { _vector.set(0.0f, 0.0f, 0.0f); } -//////////////////////////////////////////////////////////////////// -// Function: FltVectorRecord::get_vector -// Access: Public -// Description: Returns the vector value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the vector value. + */ const LVector3 &FltVectorRecord:: get_vector() const { return _vector; } -//////////////////////////////////////////////////////////////////// -// Function: FltVectorRecord::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltVectorRecord:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -63,14 +55,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltVectorRecord::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltVectorRecord:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -86,4 +75,3 @@ build_record(FltRecordWriter &writer) const { return true; } - diff --git a/pandatool/src/flt/fltVectorRecord.h b/pandatool/src/flt/fltVectorRecord.h index 04c10efd76..e099652e17 100644 --- a/pandatool/src/flt/fltVectorRecord.h +++ b/pandatool/src/flt/fltVectorRecord.h @@ -1,16 +1,15 @@ -// Filename: fltVectorRecord.h -// Created by: drose (30Aug02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVectorRecord.h + * @author drose + * @date 2002-08-30 + */ #ifndef FLTVECTORRECORD_H #define FLTVECTORRECORD_H @@ -21,13 +20,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltVectorRecord -// Description : This is an ancillary record of the old (pre-15.4) -// face node. Its only use is to provide the direction -// vector for unidirectional and bidirectional light -// point faces. -//////////////////////////////////////////////////////////////////// +/** + * This is an ancillary record of the old (pre-15.4) face node. Its only use + * is to provide the direction vector for unidirectional and bidirectional + * light point faces. + */ class FltVectorRecord : public FltRecord { public: FltVectorRecord(FltHeader *header); @@ -62,5 +59,3 @@ private: }; #endif - - diff --git a/pandatool/src/flt/fltVertex.I b/pandatool/src/flt/fltVertex.I index 35440e3d6a..2f7717af07 100644 --- a/pandatool/src/flt/fltVertex.I +++ b/pandatool/src/flt/fltVertex.I @@ -1,38 +1,31 @@ -// Filename: fltVertex.I -// Created by: drose (30Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVertex.I + * @author drose + * @date 2000-08-30 + */ - -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::has_color -// Access: Public -// Description: Returns true if the vertex has a primary color -// indicated, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the vertex has a primary color indicated, false otherwise. + */ INLINE bool FltVertex:: has_color() const { - // Even if the no_color bit is not set, if the color_index is -1, - // the vertex doesn't have a color (unless we've got packed color). + // Even if the no_color bit is not set, if the color_index is -1, the vertex + // doesn't have a color (unless we've got packed color). return ((_flags & F_no_color) == 0 && (_color_index != -1 || ((_flags & F_packed_color) != 0))); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::set_color -// Access: Public -// Description: Sets the color of the vertex, using the packed -// color convention. The alpha component is ignored. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the vertex, using the packed color convention. The alpha + * component is ignored. + */ INLINE void FltVertex:: set_color(const LColor &color) { set_rgb(LRGBColor(color[0], color[1], color[2])); diff --git a/pandatool/src/flt/fltVertex.cxx b/pandatool/src/flt/fltVertex.cxx index fe3aa7c759..77cac997a8 100644 --- a/pandatool/src/flt/fltVertex.cxx +++ b/pandatool/src/flt/fltVertex.cxx @@ -1,16 +1,15 @@ -// Filename: fltVertex.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVertex.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltVertex.h" #include "fltRecordReader.h" @@ -19,11 +18,9 @@ TypeHandle FltVertex::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltVertex:: FltVertex(FltHeader *header) : FltRecord(header) { _color_name_index = 0; @@ -37,12 +34,9 @@ FltVertex(FltHeader *header) : FltRecord(header) { _has_uv = false; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::get_opcode -// Access: Public -// Description: Returns the opcode that this record will be written -// as. -//////////////////////////////////////////////////////////////////// +/** + * Returns the opcode that this record will be written as. + */ FltOpcode FltVertex:: get_opcode() const { if (_has_normal) { @@ -60,12 +54,10 @@ get_opcode() const { } } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::get_record_length -// Access: Public -// Description: Returns the length of this record in bytes as it will -// be written to the flt file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the length of this record in bytes as it will be written to the flt + * file. + */ int FltVertex:: get_record_length() const { if (_header->get_flt_version() < 1520) { @@ -110,15 +102,11 @@ get_record_length() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::get_color -// Access: Public -// Description: If has_color() indicates true, returns the -// color of the vertex, as a four-component value. In -// the case of a vertex, the alpha channel will always -// be 1.0, as MultiGen does not store transparency -// per-vertex. -//////////////////////////////////////////////////////////////////// +/** + * If has_color() indicates true, returns the color of the vertex, as a four- + * component value. In the case of a vertex, the alpha channel will always be + * 1.0, as MultiGen does not store transparency per-vertex. + */ LColor FltVertex:: get_color() const { nassertr(has_color(), LColor(0.0, 0.0, 0.0, 0.0)); @@ -127,12 +115,10 @@ get_color() const { _packed_color, 0); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::get_rgb -// Access: Public -// Description: If has_color() indicates true, returns the -// color of the vertex, as a three-component value. -//////////////////////////////////////////////////////////////////// +/** + * If has_color() indicates true, returns the color of the vertex, as a three- + * component value. + */ LRGBColor FltVertex:: get_rgb() const { nassertr(has_color(), LRGBColor(0.0, 0.0, 0.0)); @@ -141,26 +127,20 @@ get_rgb() const { _packed_color); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::set_rgb -// Access: Public -// Description: Sets the color of the vertex, using the packed -// color convention. -//////////////////////////////////////////////////////////////////// +/** + * Sets the color of the vertex, using the packed color convention. + */ void FltVertex:: set_rgb(const LRGBColor &rgb) { _packed_color.set_rgb(rgb); _flags = ((_flags & ~F_no_color) | F_packed_color); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this record based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this record based on the information given in + * the indicated datagram, whose opcode has already been read. Returns true + * on success, false if the datagram is invalid. + */ bool FltVertex:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -216,10 +196,10 @@ extract_record(FltRecordReader &reader) { } if (_header->get_flt_version() >= 1520) { _color_index = iterator.get_be_int32(); - + if (_has_normal && iterator.get_remaining_size() > 0) { - // If we extracted a normal, our double-word alignment is off; now - // we have a few extra bytes to ignore. + // If we extracted a normal, our double-word alignment is off; now we + // have a few extra bytes to ignore. iterator.skip_bytes(4); } } @@ -229,14 +209,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertex::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltVertex:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { @@ -271,8 +248,8 @@ build_record(FltRecordWriter &writer) const { datagram.add_be_uint32(_color_index); if (_has_normal) { - // If we added a normal, our double-word alignment is off; now we - // have a few extra bytes to add. + // If we added a normal, our double-word alignment is off; now we have a + // few extra bytes to add. datagram.pad_bytes(4); } } diff --git a/pandatool/src/flt/fltVertex.h b/pandatool/src/flt/fltVertex.h index 8b71c202bb..9c02c37269 100644 --- a/pandatool/src/flt/fltVertex.h +++ b/pandatool/src/flt/fltVertex.h @@ -1,16 +1,15 @@ -// Filename: fltVertex.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVertex.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTVERTEX_H #define FLTVERTEX_H @@ -22,16 +21,14 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : FltVertex -// Description : Represents a single vertex in the vertex palette. -// Flt files index vertices by their byte offset in the -// vertex palette; within this library, we map those -// byte offsets to pointers automatically. -// -// This may represent a vertex with or without a normal -// or texture coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Represents a single vertex in the vertex palette. Flt files index vertices + * by their byte offset in the vertex palette; within this library, we map + * those byte offsets to pointers automatically. + * + * This may represent a vertex with or without a normal or texture + * coordinates. + */ class FltVertex : public FltRecord { public: FltVertex(FltHeader *header); @@ -92,5 +89,3 @@ private: #include "fltVertex.I" #endif - - diff --git a/pandatool/src/flt/fltVertexList.cxx b/pandatool/src/flt/fltVertexList.cxx index 260b3af63c..9659a56063 100644 --- a/pandatool/src/flt/fltVertexList.cxx +++ b/pandatool/src/flt/fltVertexList.cxx @@ -1,16 +1,15 @@ -// Filename: fltVertexList.cxx -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVertexList.cxx + * @author drose + * @date 2000-08-25 + */ #include "fltVertexList.h" #include "fltRecordReader.h" @@ -19,78 +18,62 @@ TypeHandle FltVertexList::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltVertexList:: FltVertexList(FltHeader *header) : FltRecord(header) { } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::get_num_vertices -// Access: Public -// Description: Returns the number of vertices in this vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of vertices in this vertex list. + */ int FltVertexList:: get_num_vertices() const { return _vertices.size(); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::get_vertex -// Access: Public -// Description: Returns the nth vertex of this vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth vertex of this vertex list. + */ FltVertex *FltVertexList:: get_vertex(int n) const { nassertr(n >= 0 && n < (int)_vertices.size(), 0); return _vertices[n]; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::clear_vertices -// Access: Public -// Description: Removes all vertices from this vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Removes all vertices from this vertex list. + */ void FltVertexList:: clear_vertices() { _vertices.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::add_vertex -// Access: Public -// Description: Adds a new vertex to the end of the vertex list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new vertex to the end of the vertex list. + */ void FltVertexList:: add_vertex(FltVertex *vertex) { _header->add_vertex(vertex); _vertices.push_back(vertex); } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::output -// Access: Public -// Description: Writes a quick one-line description of the record, but -// not its children. This is a human-readable -// description, primarily for debugging; to write a flt -// file, use FltHeader::write_flt(). -//////////////////////////////////////////////////////////////////// +/** + * Writes a quick one-line description of the record, but not its children. + * This is a human-readable description, primarily for debugging; to write a + * flt file, use FltHeader::write_flt(). + */ void FltVertexList:: output(ostream &out) const { out << _vertices.size() << " vertices"; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::extract_record -// Access: Protected, Virtual -// Description: Fills in the information in this bead based on the -// information given in the indicated datagram, whose -// opcode has already been read. Returns true on -// success, false if the datagram is invalid. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the information in this bead based on the information given in the + * indicated datagram, whose opcode has already been read. Returns true on + * success, false if the datagram is invalid. + */ bool FltVertexList:: extract_record(FltRecordReader &reader) { if (!FltRecord::extract_record(reader)) { @@ -110,14 +93,11 @@ extract_record(FltRecordReader &reader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltVertexList::build_record -// Access: Protected, Virtual -// Description: Fills up the current record on the FltRecordWriter with -// data for this record, but does not advance the -// writer. Returns true on success, false if there is -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the current record on the FltRecordWriter with data for this + * record, but does not advance the writer. Returns true on success, false if + * there is some error. + */ bool FltVertexList:: build_record(FltRecordWriter &writer) const { if (!FltRecord::build_record(writer)) { diff --git a/pandatool/src/flt/fltVertexList.h b/pandatool/src/flt/fltVertexList.h index 0c8059f641..449c5ab5ce 100644 --- a/pandatool/src/flt/fltVertexList.h +++ b/pandatool/src/flt/fltVertexList.h @@ -1,16 +1,15 @@ -// Filename: fltVertexList.h -// Created by: drose (25Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltVertexList.h + * @author drose + * @date 2000-08-25 + */ #ifndef FLTVERTEXLIST_H #define FLTVERTEXLIST_H @@ -23,11 +22,9 @@ #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : FltVertexList -// Description : A list of vertices, typically added as a child of a -// face bead. -//////////////////////////////////////////////////////////////////// +/** + * A list of vertices, typically added as a child of a face bead. + */ class FltVertexList : public FltRecord { public: FltVertexList(FltHeader *header); @@ -66,5 +63,3 @@ private: }; #endif - - diff --git a/pandatool/src/fltegg/fltToEggConverter.I b/pandatool/src/fltegg/fltToEggConverter.I index c6a80952d2..1168eb646b 100644 --- a/pandatool/src/fltegg/fltToEggConverter.I +++ b/pandatool/src/fltegg/fltToEggConverter.I @@ -1,14 +1,12 @@ -// Filename: fltToEggConverter.I -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggConverter.I + * @author drose + * @date 2001-04-17 + */ diff --git a/pandatool/src/fltegg/fltToEggConverter.cxx b/pandatool/src/fltegg/fltToEggConverter.cxx index 6f21965331..0f2b78e268 100644 --- a/pandatool/src/fltegg/fltToEggConverter.cxx +++ b/pandatool/src/fltegg/fltToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: fltToEggConverter.cxx -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggConverter.cxx + * @author drose + * @date 2001-04-17 + */ #include "fltToEggConverter.h" @@ -37,22 +36,18 @@ #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEggConverter:: FltToEggConverter() { _compose_transforms = false; _flt_units = DU_invalid; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEggConverter:: FltToEggConverter(const FltToEggConverter ©) : SomethingToEggConverter(copy), @@ -60,73 +55,56 @@ FltToEggConverter(const FltToEggConverter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEggConverter:: ~FltToEggConverter() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *FltToEggConverter:: make_copy() { return new FltToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string FltToEggConverter:: get_name() const { return "MultiGen"; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string FltToEggConverter:: get_extension() const { return "flt"; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool FltToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -// -// This is designed to be as generic as possible, -// generally in support of run-time loading. -// Command-line converters may choose to use -// convert_flt() instead, as it provides more control. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + * + * This is designed to be as generic as possible, generally in support of run- + * time loading. Command-line converters may choose to use convert_flt() + * instead, as it provides more control. + */ bool FltToEggConverter:: convert_file(const Filename &filename) { PT(FltHeader) header = new FltHeader(_path_replace); @@ -145,26 +123,20 @@ convert_file(const Filename &filename) { return convert_flt(header); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::get_input_units -// Access: Public, Virtual -// Description: This may be called after convert_file() has been -// called and returned true, indicating a successful -// conversion. It will return the distance units -// represented by the converted egg file, if known, or -// DU_invalid if not known. -//////////////////////////////////////////////////////////////////// +/** + * This may be called after convert_file() has been called and returned true, + * indicating a successful conversion. It will return the distance units + * represented by the converted egg file, if known, or DU_invalid if not + * known. + */ DistanceUnit FltToEggConverter:: get_input_units() { return _flt_units; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_flt -// Access: Public -// Description: Fills up the egg_data structure according to the -// indicated lwo structure. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the egg_data structure according to the indicated lwo structure. + */ bool FltToEggConverter:: convert_flt(const FltHeader *flt_header) { if (_egg_data->get_coordinate_system() == CS_default) { @@ -178,19 +150,18 @@ convert_flt(const FltHeader *flt_header) { _main_egg_vpool = new EggVertexPool("vpool"); _egg_data->add_child(_main_egg_vpool.p()); - // We could populate the vertex pool right away, but it's better to - // defer each vertex until we encounter it, since some of the - // vertices may need to be adjusted to match the particular polygon - // they're assigned to (for instance, to apply a transparency or - // something). + // We could populate the vertex pool right away, but it's better to defer + // each vertex until we encounter it, since some of the vertices may need to + // be adjusted to match the particular polygon they're assigned to (for + // instance, to apply a transparency or something). FltToEggLevelState state(this); state._egg_parent = _egg_data; convert_record(_flt_header, state); if (_main_egg_vpool->empty()) { - // If we didn't get any global vertices, remove the vertex pool - // just for cleanliness. + // If we didn't get any global vertices, remove the vertex pool just for + // cleanliness. _egg_data->remove_child(_main_egg_vpool.p()); } @@ -199,13 +170,10 @@ convert_flt(const FltHeader *flt_header) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::cleanup -// Access: Private -// Description: Frees all the internal data structures after we're -// done converting, and resets the converter to its -// initial state. -//////////////////////////////////////////////////////////////////// +/** + * Frees all the internal data structures after we're done converting, and + * resets the converter to its initial state. + */ void FltToEggConverter:: cleanup() { _flt_header.clear(); @@ -213,11 +181,9 @@ cleanup() { _textures.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_record -// Access: Private -// Description: Converts the record and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the record and all of its children. + */ void FltToEggConverter:: convert_record(const FltRecord *flt_record, FltToEggLevelState &state) { int num_children = flt_record->get_num_children(); @@ -228,12 +194,10 @@ convert_record(const FltRecord *flt_record, FltToEggLevelState &state) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::dispatch_record -// Access: Private -// Description: Determines what kind of record this is and calls the -// appropriate convert function. -//////////////////////////////////////////////////////////////////// +/** + * Determines what kind of record this is and calls the appropriate convert + * function. + */ void FltToEggConverter:: dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state) { if (flt_record->is_of_type(FltLOD::get_class_type())) { @@ -263,11 +227,9 @@ dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_lod -// Access: Private -// Description: Converts the LOD bead and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the LOD bead and all of its children. + */ void FltToEggConverter:: convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state) { EggGroup *egg_group = new EggGroup(flt_lod->get_id()); @@ -287,11 +249,9 @@ convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state) { convert_record(flt_lod, next_state); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_group -// Access: Private -// Description: Converts the group and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the group and all of its children. + */ void FltToEggConverter:: convert_group(const FltGroup *flt_group, FltToEggLevelState &state) { EggGroup *egg_group = new EggGroup(flt_group->get_id()); @@ -306,18 +266,16 @@ convert_group(const FltGroup *flt_group, FltToEggLevelState &state) { state.set_transform(flt_group, egg_group); parse_comment(flt_group, egg_group); - ///*** replicate count. + // *** replicate count. FltToEggLevelState next_state(state); next_state._egg_parent = egg_group; convert_record(flt_group, next_state); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_object -// Access: Private -// Description: Converts the object and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the object and all of its children. + */ void FltToEggConverter:: convert_object(const FltObject *flt_object, FltToEggLevelState &state) { EggGroup *egg_group = new EggGroup(flt_object->get_id()); @@ -332,12 +290,9 @@ convert_object(const FltObject *flt_object, FltToEggLevelState &state) { convert_record(flt_object, next_state); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_bead_id -// Access: Private -// Description: Converts the generic bead (with ID) and all of its -// children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the generic bead (with ID) and all of its children. + */ void FltToEggConverter:: convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state) { nout << "Don't know how to convert beads of type " << flt_bead->get_type() @@ -353,12 +308,9 @@ convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state) { convert_record(flt_bead, next_state); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_bead -// Access: Private -// Description: Converts the generic bead (without ID) and all of its -// children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the generic bead (without ID) and all of its children. + */ void FltToEggConverter:: convert_bead(const FltBead *flt_bead, FltToEggLevelState &state) { nout << "Don't know how to convert beads of type " << flt_bead->get_type() @@ -374,11 +326,9 @@ convert_bead(const FltBead *flt_bead, FltToEggLevelState &state) { convert_record(flt_bead, next_state); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_face -// Access: Private -// Description: Converts the face and all of its children. -//////////////////////////////////////////////////////////////////// +/** + * Converts the face and all of its children. + */ void FltToEggConverter:: convert_face(const FltFace *flt_face, FltToEggLevelState &state) { bool is_light; @@ -423,11 +373,9 @@ convert_face(const FltFace *flt_face, FltToEggLevelState &state) { setup_geometry(flt_face, state, egg_prim, _main_egg_vpool, vertices); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_ext_ref -// Access: Private -// Description: Converts the external reference node. -//////////////////////////////////////////////////////////////////// +/** + * Converts the external reference node. + */ void FltToEggConverter:: convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state) { // Get a group node to put the reference into. @@ -437,15 +385,12 @@ convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state) handle_external_reference(egg_parent, flt_ext->get_ref_filename()); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::setup_geometry -// Access: Private -// Description: Applies the state indicated in the FltGeometry record -// to the indicated EggPrimitive and all of its -// indicated vertices, and then officially adds the -// vertices to the vertex pool and to the primitive, and -// adds the primitive to its appropriate parent. -//////////////////////////////////////////////////////////////////// +/** + * Applies the state indicated in the FltGeometry record to the indicated + * EggPrimitive and all of its indicated vertices, and then officially adds + * the vertices to the vertex pool and to the primitive, and adds the + * primitive to its appropriate parent. + */ void FltToEggConverter:: setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, EggPrimitive *egg_prim, EggVertexPool *egg_vpool, @@ -496,8 +441,8 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, LColor face_color = flt_geom->get_color(); if (state._flt_object != (FltObject *)NULL) { - // If we have a FltObject above us, it might also specify a - // transparency. This combines with our existing transparency. + // If we have a FltObject above us, it might also specify a transparency. + // This combines with our existing transparency. PN_stdfloat alpha = 1.0 - (state._flt_object->_transparency / 65535.0); face_color[3] *= alpha; } @@ -509,19 +454,18 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, egg_prim->set_texture(make_egg_texture(flt_geom->get_texture())); if (flt_geom->_texwhite) { - // If the geometry should be colored white under the texture, - // then eliminate vertex colors. + // If the geometry should be colored white under the texture, then + // eliminate vertex colors. use_vertex_color = false; } } if (use_vertex_color) { - // If we're to use vertex color instead of the face color, remove - // the face color to eliminate any ambiguity. + // If we're to use vertex color instead of the face color, remove the face + // color to eliminate any ambiguity. egg_prim->clear_color(); - // Also, make sure the transparency is set correctly across all - // vertices. + // Also, make sure the transparency is set correctly across all vertices. for (vi = vertices.begin(); vi != vertices.end(); ++vi) { EggVertex *vertex = (*vi); if (vertex->has_color()) { @@ -530,16 +474,16 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, vertex->set_color(vertex_color); } else { if (flt_geom->has_color()) { - // If a vertex doesn't have a color but the face does, set - // the vertex to use the face color. + // If a vertex doesn't have a color but the face does, set the + // vertex to use the face color. vertex->set_color(face_color); } } } } else { - // If we're to use face color instead of vertex color, remove the - // vertex color to eliminate any ambiguity. + // If we're to use face color instead of vertex color, remove the vertex + // color to eliminate any ambiguity. for (vi = vertices.begin(); vi != vertices.end(); ++vi) { (*vi)->clear_color(); } @@ -565,18 +509,14 @@ setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state, parse_comment(flt_geom, egg_prim); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::convert_subfaces -// Access: Public -// Description: Records all of the subfaces of the indicated group as -// coplanar polygons (i.e. decals) of the group. -// -// If coplanar polygons exist, the state is modified so -// that _egg_parent is the new group to which the base -// polygons should be added. Therefore, subfaces should -// be defined before the ordinary children are -// processed. -//////////////////////////////////////////////////////////////////// +/** + * Records all of the subfaces of the indicated group as coplanar polygons + * (i.e. decals) of the group. + * + * If coplanar polygons exist, the state is modified so that _egg_parent is + * the new group to which the base polygons should be added. Therefore, + * subfaces should be defined before the ordinary children are processed. + */ void FltToEggConverter:: convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state) { int num_subfaces = flt_record->get_num_subfaces(); @@ -606,58 +546,42 @@ convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state) { } } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::parse_comment -// Access: Private -// Description: Scans the comment on this record for " { ... }" -// and parses the enclosed string as if it appeared in -// the egg file. Returns true on success, false on -// syntax error (in which case _error is also set to -// true). -//////////////////////////////////////////////////////////////////// +/** + * Scans the comment on this record for " { ... }" and parses the + * enclosed string as if it appeared in the egg file. Returns true on + * success, false on syntax error (in which case _error is also set to true). + */ bool FltToEggConverter:: parse_comment(const FltBeadID *flt_bead, EggNode *egg_node) { return parse_comment(flt_bead->get_comment(), flt_bead->get_id(), egg_node); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::parse_comment -// Access: Private -// Description: Scans the comment on this record for " { ... }" -// and parses the enclosed string as if it appeared in -// the egg file. Returns true on success, false on -// syntax error (in which case _error is also set to -// true). -//////////////////////////////////////////////////////////////////// +/** + * Scans the comment on this record for " { ... }" and parses the + * enclosed string as if it appeared in the egg file. Returns true on + * success, false on syntax error (in which case _error is also set to true). + */ bool FltToEggConverter:: parse_comment(const FltBead *flt_bead, EggNode *egg_node) { return parse_comment(flt_bead->get_comment(), "anonymous", egg_node); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::parse_comment -// Access: Private -// Description: Scans the comment on this record for " { ... }" -// and parses the enclosed string as if it appeared in -// the egg file. Returns true on success, false on -// syntax error (in which case _error is also set to -// true). -//////////////////////////////////////////////////////////////////// +/** + * Scans the comment on this record for " { ... }" and parses the + * enclosed string as if it appeared in the egg file. Returns true on + * success, false on syntax error (in which case _error is also set to true). + */ bool FltToEggConverter:: parse_comment(const FltTexture *flt_texture, EggNode *egg_node) { - return parse_comment(flt_texture->get_comment(), + return parse_comment(flt_texture->get_comment(), flt_texture->get_texture_filename(), egg_node); } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::parse_comment -// Access: Private -// Description: Scans the comment on this record for " { ... }" -// and parses the enclosed string as if it appeared in -// the egg file. Returns true on success, false on -// syntax error (in which case _error is also set to -// true). -//////////////////////////////////////////////////////////////////// +/** + * Scans the comment on this record for " { ... }" and parses the + * enclosed string as if it appeared in the egg file. Returns true on + * success, false on syntax error (in which case _error is also set to true). + */ bool FltToEggConverter:: parse_comment(const string &comment, const string &name, EggNode *egg_node) { @@ -693,8 +617,8 @@ parse_comment(const string &comment, const string &name, return false; } - // Here's the beginning of the string after " {". Now lop off - // the closing brace at the end. + // Here's the beginning of the string after " {". Now lop off the + // closing brace at the end. ++p; size_t q = comment.length() - 1; while (q > p && comment[q] != '}') { @@ -720,13 +644,10 @@ parse_comment(const string &comment, const string &name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::make_egg_vertex -// Access: Private -// Description: Makes a new EggVertex for the indicated FltVertex. -// The vertex is not automatically added to the vertex -// pool. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new EggVertex for the indicated FltVertex. The vertex is not + * automatically added to the vertex pool. + */ PT_EggVertex FltToEggConverter:: make_egg_vertex(const FltVertex *flt_vertex) { PT_EggVertex egg_vertex = new EggVertex; @@ -747,13 +668,10 @@ make_egg_vertex(const FltVertex *flt_vertex) { return egg_vertex; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggConverter::make_egg_texture -// Access: Private -// Description: Makes a new EggTexture for the indicated FltTexture, -// or returns a pointer to one previously made for the -// same FltTexture. -//////////////////////////////////////////////////////////////////// +/** + * Makes a new EggTexture for the indicated FltTexture, or returns a pointer + * to one previously made for the same FltTexture. + */ PT_EggTexture FltToEggConverter:: make_egg_texture(const FltTexture *flt_texture) { Textures::const_iterator ti; diff --git a/pandatool/src/fltegg/fltToEggConverter.h b/pandatool/src/fltegg/fltToEggConverter.h index 796628cfd6..5188c3fce4 100644 --- a/pandatool/src/fltegg/fltToEggConverter.h +++ b/pandatool/src/fltegg/fltToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: fltToEggConverter.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggConverter.h + * @author drose + * @date 2001-04-17 + */ #ifndef FLTTOEGGCONVERTER_H #define FLTTOEGGCONVERTER_H @@ -42,13 +41,11 @@ class FltTexture; class EggGroupNode; class EggPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : FltToEggConverter -// Description : This class supervises the construction of an EggData -// structure from the data represented by the FltHeader. -// Reading and writing the egg and flt structures is -// left to the user. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from the + * data represented by the FltHeader. Reading and writing the egg and flt + * structures is left to the user. + */ class FltToEggConverter : public SomethingToEggConverter { public: FltToEggConverter(); @@ -65,9 +62,9 @@ public: virtual DistanceUnit get_input_units(); bool convert_flt(const FltHeader *flt_header); - // Set this true to store transforms in egg files as the fully - // composed matrix, or false (the default) to keep them decomposed - // into elemental operations. + // Set this true to store transforms in egg files as the fully composed + // matrix, or false (the default) to keep them decomposed into elemental + // operations. bool _compose_transforms; private: @@ -112,5 +109,3 @@ private: #include "fltToEggConverter.I" #endif - - diff --git a/pandatool/src/fltegg/fltToEggLevelState.I b/pandatool/src/fltegg/fltToEggLevelState.I index d395995e30..0a1cef8f43 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.I +++ b/pandatool/src/fltegg/fltToEggLevelState.I @@ -1,22 +1,19 @@ -// Filename: fltToEggLevelState.I -// Created by: drose (18Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggLevelState.I + * @author drose + * @date 2001-04-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FltToEggLevelState:: FltToEggLevelState(FltToEggConverter *converter) : _converter(converter) @@ -25,11 +22,9 @@ FltToEggLevelState(FltToEggConverter *converter) : _egg_parent = (EggGroupNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE FltToEggLevelState:: FltToEggLevelState(const FltToEggLevelState ©) : _flt_object(copy._flt_object), @@ -39,11 +34,9 @@ FltToEggLevelState(const FltToEggLevelState ©) : // We don't bother to copy the _parents map. } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void FltToEggLevelState:: operator = (const FltToEggLevelState ©) { _flt_object = copy._flt_object; diff --git a/pandatool/src/fltegg/fltToEggLevelState.cxx b/pandatool/src/fltegg/fltToEggLevelState.cxx index 6748c67dfe..1fbe548d50 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.cxx +++ b/pandatool/src/fltegg/fltToEggLevelState.cxx @@ -1,16 +1,15 @@ -// Filename: fltToEggLevelState.cxx -// Created by: drose (18Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggLevelState.cxx + * @author drose + * @date 2001-04-18 + */ #include "fltToEggLevelState.h" #include "fltToEggConverter.h" @@ -24,11 +23,9 @@ #include "look_at.h" -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEggLevelState:: ~FltToEggLevelState() { Parents::iterator pi; @@ -37,11 +34,9 @@ FltToEggLevelState:: } } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::ParentNodes::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEggLevelState::ParentNodes:: ParentNodes() { _axial_billboard = (EggGroup *)NULL; @@ -49,37 +44,32 @@ ParentNodes() { _plain = (EggGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::get_synthetic_group -// Access: Public -// Description: Sometimes it is necessary to synthesize a group -// within a particular EggGroup, for instance to insert -// a transform or billboard flag. This function will -// synthesize a group as needed, or return an existing -// group (if the group need not be synthesized, or if a -// matching group was previously synthesized). -// -// This collects together polygons that share the same -// billboard axis and/or transform space into the same -// group, rather than wastefully creating a group per -// polygon. -//////////////////////////////////////////////////////////////////// +/** + * Sometimes it is necessary to synthesize a group within a particular + * EggGroup, for instance to insert a transform or billboard flag. This + * function will synthesize a group as needed, or return an existing group (if + * the group need not be synthesized, or if a matching group was previously + * synthesized). + * + * This collects together polygons that share the same billboard axis and/or + * transform space into the same group, rather than wastefully creating a + * group per polygon. + */ EggGroupNode *FltToEggLevelState:: get_synthetic_group(const string &name, const FltBead *transform_bead, FltGeometry::BillboardType type) { LMatrix4d transform = transform_bead->get_transform(); bool is_identity = transform.almost_equal(LMatrix4d::ident_mat()); - if (is_identity && + if (is_identity && (type != FltGeometry::BT_axial && type != FltGeometry::BT_point)) { - // Trivial case: the primitive belongs directly in its parent - // group node. + // Trivial case: the primitive belongs directly in its parent group node. return _egg_parent; } - // For other cases, we may have to create a subgroup to put the - // primitive into. + // For other cases, we may have to create a subgroup to put the primitive + // into. Parents::iterator pi; pi = _parents.find(transform); ParentNodes *nodes; @@ -129,12 +119,10 @@ get_synthetic_group(const string &name, } } -//////////////////////////////////////////////////////////////////// -// Function: FltToEggLevelState::set_transform -// Access: Public -// Description: Sets up the group to reflect the transform indicated -// by the given record, if any. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the group to reflect the transform indicated by the given record, + * if any. + */ void FltToEggLevelState:: set_transform(const FltBead *flt_bead, EggGroup *egg_group) { if (flt_bead->has_transform()) { @@ -146,10 +134,9 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) { if (num_steps == 0) { componentwise_ok = false; } else { - // Walk through each transform step and store the individual - // components in the egg file. If we come across a step we - // don't know how to interpret, just store the whole transform - // matrix in the egg file. + // Walk through each transform step and store the individual components + // in the egg file. If we come across a step we don't know how to + // interpret, just store the whole transform matrix in the egg file. egg_group->clear_transform(); for (int i = num_steps -1; i >= 0 && componentwise_ok; i--) { const FltTransformRecord *step = flt_bead->get_transform_step(i); @@ -162,7 +149,7 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) { } else if (step->is_exact_type(FltTransformRotateAboutPoint::get_class_type())) { const FltTransformRotateAboutPoint *rap; - DCAST_INTO_V(rap, step); + DCAST_INTO_V(rap, step); if (!IS_NEARLY_ZERO(rap->get_angle())) { if (!rap->get_center().almost_equal(LVector3d::zero())) { egg_group->add_translate3d(-rap->get_center()); @@ -192,12 +179,12 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) { const FltTransformScale *scale; DCAST_INTO_V(scale, step); if (!scale->get_scale().almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) { - if (scale->has_center() && + if (scale->has_center() && !scale->get_center().almost_equal(LVector3d::zero())) { egg_group->add_translate3d(-scale->get_center()); } egg_group->add_scale3d(LCAST(double, scale->get_scale())); - if (scale->has_center() && + if (scale->has_center() && !scale->get_center().almost_equal(LVector3d::zero())) { egg_group->add_translate3d(scale->get_center()); } @@ -228,8 +215,8 @@ set_transform(const FltBead *flt_bead, EggGroup *egg_group) { } } else { - // Here's a transform component we haven't implemented here. - // Give up on storing the componentwise transform. + // Here's a transform component we haven't implemented here. Give + // up on storing the componentwise transform. componentwise_ok = false; } } diff --git a/pandatool/src/fltegg/fltToEggLevelState.h b/pandatool/src/fltegg/fltToEggLevelState.h index 18960db314..876d9835e1 100644 --- a/pandatool/src/fltegg/fltToEggLevelState.h +++ b/pandatool/src/fltegg/fltToEggLevelState.h @@ -1,16 +1,15 @@ -// Filename: fltToEggLevelState.h -// Created by: drose (18Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEggLevelState.h + * @author drose + * @date 2001-04-18 + */ #ifndef FLTTOEGGLEVELSTATE_H #define FLTTOEGGLEVELSTATE_H @@ -24,11 +23,10 @@ class EggGroupNode; class EggGroup; class FltToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : FltToEggLevelState -// Description : This keeps track of relevant things about the -// traversal as we walk through the flt hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * This keeps track of relevant things about the traversal as we walk through + * the flt hierarchy. + */ class FltToEggLevelState { public: INLINE FltToEggLevelState(FltToEggConverter *converter); diff --git a/pandatool/src/fltprogs/eggToFlt.cxx b/pandatool/src/fltprogs/eggToFlt.cxx index 33cbbee7a2..36351af679 100644 --- a/pandatool/src/fltprogs/eggToFlt.cxx +++ b/pandatool/src/fltprogs/eggToFlt.cxx @@ -1,16 +1,15 @@ -// Filename: eggToFlt.cxx -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToFlt.cxx + * @author drose + * @date 2003-10-01 + */ #include "eggToFlt.h" #include "fltHeader.h" @@ -37,11 +36,9 @@ #include "vector_string.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToFlt:: EggToFlt() : EggToSomething("MultiGen", ".flt", true, false) @@ -67,19 +64,17 @@ EggToFlt() : "Specifying \"all\" causes these to be rewritten every time.", &EggToFlt::dispatch_attr, NULL, &_auto_attr_update); - // Flt files are always in the z-up coordinate system. Don't - // confuse the user with this meaningless option. + // Flt files are always in the z-up coordinate system. Don't confuse the + // user with this meaningless option. remove_option("cs"); _coordinate_system = CS_zup_right; _got_coordinate_system = true; _auto_attr_update = FltHeader::AU_if_missing; } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToFlt:: run() { _flt_header = new FltHeader(_path_replace); @@ -95,11 +90,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::dispatch_attr -// Access: Protected, Static -// Description: Dispatch function for the -attr parameter. -//////////////////////////////////////////////////////////////////// +/** + * Dispatch function for the -attr parameter. + */ bool EggToFlt:: dispatch_attr(const string &opt, const string &arg, void *var) { FltHeader::AttrUpdate *ip = (FltHeader::AttrUpdate *)var; @@ -122,11 +115,9 @@ dispatch_attr(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::traverse -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToFlt:: traverse(EggNode *egg_node, FltBead *flt_node, FltGeometry::BillboardType billboard) { @@ -160,13 +151,10 @@ traverse(EggNode *egg_node, FltBead *flt_node, } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::convert_primitive -// Access: Private -// Description: Converts an egg polygon or series of light points to -// the corresponding Flt geometry, and adds it to the -// indicated flt_node. -//////////////////////////////////////////////////////////////////// +/** + * Converts an egg polygon or series of light points to the corresponding Flt + * geometry, and adds it to the indicated flt_node. + */ void EggToFlt:: convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, FltGeometry::BillboardType billboard) { @@ -198,9 +186,9 @@ convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, flt_face->set_texture(flt_texture); } - // Create a vertex list representing the vertices in the - // primitive, and add it as a child of the face bead. This is how - // Flt files associate vertices with faces. + // Create a vertex list representing the vertices in the primitive, and add + // it as a child of the face bead. This is how Flt files associate vertices + // with faces. FltVertexList *flt_vertices = new FltVertexList(_flt_header); flt_face->add_child(flt_vertices); @@ -220,8 +208,8 @@ convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, } } if (all_verts_have_color) { - // If all the vertices of the face have a color specification, - // then we specify per-vertex color on the face. + // If all the vertices of the face have a color specification, then we + // specify per-vertex color on the face. if (all_verts_have_normal) { // And similarly with the normals. flt_face->_light_mode = FltFace::LM_vertex_with_normal; @@ -237,13 +225,10 @@ convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::convert_group -// Access: Private -// Description: Converts an egg group to the corresponding flt group, -// and adds it to the indicated parent node. Also -// recurses on the children of the egg group. -//////////////////////////////////////////////////////////////////// +/** + * Converts an egg group to the corresponding flt group, and adds it to the + * indicated parent node. Also recurses on the children of the egg group. + */ void EggToFlt:: convert_group(EggGroup *egg_group, FltBead *flt_node, FltGeometry::BillboardType billboard) { @@ -255,8 +240,8 @@ convert_group(EggGroup *egg_group, FltBead *flt_node, flt_group->set_id(egg_group->get_name()); switch (egg_group->get_billboard_type()) { - // MultiGen represents billboarding at the polygon level, so we - // have to remember this flag for later. + // MultiGen represents billboarding at the polygon level, so we have to + // remember this flag for later. case EggGroup::BT_axis: billboard = FltGeometry::BT_axial; break; @@ -290,9 +275,8 @@ convert_group(EggGroup *egg_group, FltBead *flt_node, } } - // Pick up any additional egg attributes that MultiGen doesn't - // support; these will get written to the comment field where - // flt2egg will find it. + // Pick up any additional egg attributes that MultiGen doesn't support; + // these will get written to the comment field where flt2egg will find it. egg_group->write_collide_flags(egg_syntax, 2); egg_group->write_model_flags(egg_syntax, 2); egg_group->write_object_types(egg_syntax, 2); @@ -308,12 +292,9 @@ convert_group(EggGroup *egg_group, FltBead *flt_node, } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::apply_transform -// Access: Private -// Description: Applies the indicated egg transform to the indicated -// flt bead. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated egg transform to the indicated flt bead. + */ void EggToFlt:: apply_transform(EggTransform *egg_transform, FltBead *flt_node) { flt_node->clear_transform(); @@ -464,15 +445,11 @@ apply_transform(EggTransform *egg_transform, FltBead *flt_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::apply_egg_syntax -// Access: Private -// Description: Adds the indicated sequence of egg syntax lines -// (presumably representing egg features not directly -// supported by MultiGen) to the flt record as a -// comment, so that flt2egg will reapply it to the egg -// groups. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated sequence of egg syntax lines (presumably representing + * egg features not directly supported by MultiGen) to the flt record as a + * comment, so that flt2egg will reapply it to the egg groups. + */ void EggToFlt:: apply_egg_syntax(const string &egg_syntax, FltRecord *flt_record) { if (!egg_syntax.empty()) { @@ -484,13 +461,11 @@ apply_egg_syntax(const string &egg_syntax, FltRecord *flt_record) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::get_flt_vertex -// Access: Private -// Description: Returns a FltVertex corresponding to the indicated -// EggVertex. If the vertex has not been seen before -// (in this particular vertex frame), creates a new one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FltVertex corresponding to the indicated EggVertex. If the + * vertex has not been seen before (in this particular vertex frame), creates + * a new one. + */ FltVertex *EggToFlt:: get_flt_vertex(EggVertex *egg_vertex, EggNode *context) { const LMatrix4d *frame = context->get_vertex_to_node_ptr(); @@ -526,18 +501,15 @@ get_flt_vertex(EggVertex *egg_vertex, EggNode *context) { return flt_vertex; } -//////////////////////////////////////////////////////////////////// -// Function: EggToFlt::get_flt_texture -// Access: Private -// Description: Returns a FltTexture corresponding to the indicated -// EggTexture. If the texture has not been seen before, -// creates a new one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FltTexture corresponding to the indicated EggTexture. If the + * texture has not been seen before, creates a new one. + */ FltTexture *EggToFlt:: get_flt_texture(EggTexture *egg_texture) { - // We have to maintain this map based on the filename, not the egg - // pointer, because there may be multiple EggTextures with the same - // filename, and we have to collapse them together. + // We have to maintain this map based on the filename, not the egg pointer, + // because there may be multiple EggTextures with the same filename, and we + // have to collapse them together. Filename filename = egg_texture->get_filename(); TextureMap::iterator vi = _texture_map.find(filename); if (vi != _texture_map.end()) { diff --git a/pandatool/src/fltprogs/eggToFlt.h b/pandatool/src/fltprogs/eggToFlt.h index 4eb1c16366..ebae3de586 100644 --- a/pandatool/src/fltprogs/eggToFlt.h +++ b/pandatool/src/fltprogs/eggToFlt.h @@ -1,16 +1,15 @@ -// Filename: eggToFlt.h -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToFlt.h + * @author drose + * @date 2003-10-01 + */ #ifndef EGGTOFLT_H #define EGGTOFLT_H @@ -33,10 +32,9 @@ class FltVertex; class FltBead; class FltTexture; -//////////////////////////////////////////////////////////////////// -// Class : EggToFlt -// Description : A program to read an egg file and write a flt file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write a flt file. + */ class EggToFlt : public EggToSomething { public: EggToFlt(); @@ -48,7 +46,7 @@ private: void traverse(EggNode *egg_node, FltBead *flt_node, FltGeometry::BillboardType billboard); - void convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, + void convert_primitive(EggPrimitive *egg_primitive, FltBead *flt_node, FltGeometry::BillboardType billboard); void convert_group(EggGroup *egg_group, FltBead *flt_node, FltGeometry::BillboardType billboard); @@ -60,14 +58,13 @@ private: FltHeader::AttrUpdate _auto_attr_update; PT(FltHeader) _flt_header; - + typedef pmap VertexMap; typedef pmap VertexMapPerFrame; VertexMapPerFrame _vertex_map_per_frame; - + typedef pmap TextureMap; TextureMap _texture_map; }; #endif - diff --git a/pandatool/src/fltprogs/fltCopy.cxx b/pandatool/src/fltprogs/fltCopy.cxx index d2c117d176..ea5dfbde07 100644 --- a/pandatool/src/fltprogs/fltCopy.cxx +++ b/pandatool/src/fltprogs/fltCopy.cxx @@ -1,16 +1,15 @@ -// Filename: fltCopy.cxx -// Created by: drose (01Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltCopy.cxx + * @author drose + * @date 2000-11-01 + */ #include "fltCopy.h" @@ -22,11 +21,9 @@ #include "dcast.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltCopy:: FltCopy() { set_program_brief("copy MultiGen .flt files into a CVS source hierarchy"); @@ -47,11 +44,9 @@ FltCopy() { add_path_replace_options(); } -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltCopy:: run() { SourceFiles::iterator fi; @@ -66,14 +61,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::copy_file -// Access: Protected, Virtual -// Description: Called by import() if verify_file() indicates that a -// file needs to be copied. This does the actual copy -// of a file from source to destination. If new_file is -// true, then dest does not already exist. -//////////////////////////////////////////////////////////////////// +/** + * Called by import() if verify_file() indicates that a file needs to be + * copied. This does the actual copy of a file from source to destination. + * If new_file is true, then dest does not already exist. + */ bool FltCopy:: copy_file(const Filename &source, const Filename &dest, CVSSourceDirectory *dir, void *extra_data, bool new_file) { @@ -90,18 +82,16 @@ copy_file(const Filename &source, const Filename &dest, return false; } -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::copy_flt_file -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltCopy:: copy_flt_file(const Filename &source, const Filename &dest, CVSSourceDirectory *dir) { PT(FltHeader) header = new FltHeader(_path_replace); - // We don't want to automatically generate .attr files--we'd rather - // write them out explicitly. + // We don't want to automatically generate .attr files--we'd rather write + // them out explicitly. header->set_auto_attr_update(FltHeader::AU_none); FltError result = header->read_flt(source); @@ -135,15 +125,15 @@ copy_flt_file(const Filename &source, const Filename &dest, return false; } - // Update the reference to point to the new flt filename, relative - // to the base flt file. + // Update the reference to point to the new flt filename, relative to + // the base flt file. ref->set_ref_filename(ref_path.get_rel_from(dir)); } } - // Remove all the textures from the palette, and then add back only - // those we found in use. This way we don't copy a file that - // references bogus textures. + // Remove all the textures from the palette, and then add back only those we + // found in use. This way we don't copy a file that references bogus + // textures. header->clear_textures(); Textures::const_iterator ti; @@ -165,8 +155,8 @@ copy_flt_file(const Filename &source, const Filename &dest, return false; } - // Update the texture reference to point to the new texture - // filename, relative to the flt file. + // Update the texture reference to point to the new texture filename, + // relative to the flt file. tex->set_texture_filename(texture_path.get_rel_from(dir)); header->add_texture(tex); } @@ -182,11 +172,9 @@ copy_flt_file(const Filename &source, const Filename &dest, return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::copy_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltCopy:: copy_texture(const Filename &source, const Filename &dest, CVSSourceDirectory *dir, FltTexture *tex, bool new_file) { @@ -209,13 +197,10 @@ copy_texture(const Filename &source, const Filename &dest, return true; } -//////////////////////////////////////////////////////////////////// -// Function: FltCopy::scan_flt -// Access: Private -// Description: Recursively walks through the flt file hierarchy, -// looking for texture references and external flt file -// references. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the flt file hierarchy, looking for texture + * references and external flt file references. + */ void FltCopy:: scan_flt(FltRecord *record, FltCopy::Refs &refs, FltCopy::Textures &textures) { if (record->is_of_type(FltFace::get_class_type())) { diff --git a/pandatool/src/fltprogs/fltCopy.h b/pandatool/src/fltprogs/fltCopy.h index 4c935544f5..2370fec605 100644 --- a/pandatool/src/fltprogs/fltCopy.h +++ b/pandatool/src/fltprogs/fltCopy.h @@ -1,16 +1,15 @@ -// Filename: fltCopy.h -// Created by: drose (01Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltCopy.h + * @author drose + * @date 2000-11-01 + */ #ifndef FLTCOPY_H #define FLTCOPY_H @@ -28,12 +27,10 @@ class FltRecord; class FltTexture; class FltExternalReference; -//////////////////////////////////////////////////////////////////// -// Class : FltCopy -// Description : A program to copy Multigen .flt files into the cvs -// tree. It copies the base file plus all externally -// referenced files as well as all textures. -//////////////////////////////////////////////////////////////////// +/** + * A program to copy Multigen .flt files into the cvs tree. It copies the + * base file plus all externally referenced files as well as all textures. + */ class FltCopy : public CVSCopy { public: FltCopy(); diff --git a/pandatool/src/fltprogs/fltInfo.cxx b/pandatool/src/fltprogs/fltInfo.cxx index ab83af6705..8f35093c73 100644 --- a/pandatool/src/fltprogs/fltInfo.cxx +++ b/pandatool/src/fltprogs/fltInfo.cxx @@ -1,16 +1,15 @@ -// Filename: fltInfo.cxx -// Created by: drose (05Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInfo.cxx + * @author drose + * @date 2001-09-05 + */ #include "fltInfo.h" @@ -18,11 +17,9 @@ #include "indent.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: FltInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltInfo:: FltInfo() { set_program_brief("describe the contents of a MultiGen .flt file"); @@ -40,11 +37,9 @@ FltInfo() { } -//////////////////////////////////////////////////////////////////// -// Function: FltInfo::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltInfo:: run() { PT(FltHeader) header = new FltHeader(_path_replace); @@ -65,12 +60,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: FltInfo::list_hierarchy -// Access: Protected -// Description: Recursively lists the flt file's hierarchy in a -// meaningful way. -//////////////////////////////////////////////////////////////////// +/** + * Recursively lists the flt file's hierarchy in a meaningful way. + */ void FltInfo:: list_hierarchy(FltRecord *record, int indent_level) { // Maybe in the future we can do something fancier here. @@ -78,11 +70,9 @@ list_hierarchy(FltRecord *record, int indent_level) { } -//////////////////////////////////////////////////////////////////// -// Function: FltInfo::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltInfo:: handle_args(ProgramBase::Args &args) { if (args.empty()) { diff --git a/pandatool/src/fltprogs/fltInfo.h b/pandatool/src/fltprogs/fltInfo.h index 134e940434..1dc8795330 100644 --- a/pandatool/src/fltprogs/fltInfo.h +++ b/pandatool/src/fltprogs/fltInfo.h @@ -1,16 +1,15 @@ -// Filename: fltInfo.h -// Created by: drose (05Sep01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltInfo.h + * @author drose + * @date 2001-09-05 + */ #ifndef FLTINFO_H #define FLTINFO_H @@ -21,11 +20,9 @@ class FltRecord; -//////////////////////////////////////////////////////////////////// -// Class : FltInfo -// Description : A program to read a flt file and report interesting -// things about it. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a flt file and report interesting things about it. + */ class FltInfo : public ProgramBase { public: FltInfo(); @@ -42,4 +39,3 @@ protected: }; #endif - diff --git a/pandatool/src/fltprogs/fltToEgg.cxx b/pandatool/src/fltprogs/fltToEgg.cxx index ab22aedc5c..6935e29c68 100644 --- a/pandatool/src/fltprogs/fltToEgg.cxx +++ b/pandatool/src/fltprogs/fltToEgg.cxx @@ -1,16 +1,15 @@ -// Filename: fltToEgg.cxx -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEgg.cxx + * @author drose + * @date 2001-04-17 + */ #include "fltToEgg.h" @@ -18,11 +17,9 @@ #include "config_flt.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: FltToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltToEgg:: FltToEgg() : SomethingToEgg("MultiGen", ".flt") @@ -44,8 +41,8 @@ FltToEgg() : "Specify the coordinate system of the input " + _format_name + " file. Normally, this is z-up."); - // Does anyone really care about this option? It's mainly useful - // for debugging the flt2egg logic. + // Does anyone really care about this option? It's mainly useful for + // debugging the flt2egg logic. /* add_option ("C", "", 0, @@ -59,11 +56,9 @@ FltToEgg() : _coordinate_system = CS_zup_right; } -//////////////////////////////////////////////////////////////////// -// Function: FltToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltToEgg:: run() { _data->set_coordinate_system(_coordinate_system); diff --git a/pandatool/src/fltprogs/fltToEgg.h b/pandatool/src/fltprogs/fltToEgg.h index 84506b4faf..6a756fe6b3 100644 --- a/pandatool/src/fltprogs/fltToEgg.h +++ b/pandatool/src/fltprogs/fltToEgg.h @@ -1,17 +1,16 @@ -// Filename: fltToEgg.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltToEgg.h + * @author drose + * @date 2001-04-17 + */ + #ifndef FLTTOEGG_H #define FLTTOEGG_H @@ -22,11 +21,9 @@ #include "dSearchPath.h" -//////////////////////////////////////////////////////////////////// -// Class : FltToEgg -// Description : A program to read a flt file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a flt file and generate an egg file. + */ class FltToEgg : public SomethingToEgg { public: FltToEgg(); @@ -37,4 +34,3 @@ public: }; #endif - diff --git a/pandatool/src/fltprogs/fltTrans.cxx b/pandatool/src/fltprogs/fltTrans.cxx index 8c9d095edc..3fd6ae9656 100644 --- a/pandatool/src/fltprogs/fltTrans.cxx +++ b/pandatool/src/fltprogs/fltTrans.cxx @@ -1,33 +1,30 @@ -// Filename: fltTrans.cxx -// Created by: drose (11Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTrans.cxx + * @author drose + * @date 2001-04-11 + */ #include "fltTrans.h" #include "fltHeader.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: FltTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ FltTrans:: FltTrans() : WithOutputFile(true, false, true) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = ".flt"; set_program_brief("apply various operations to a MultiGen .flt file"); @@ -58,11 +55,9 @@ FltTrans() : } -//////////////////////////////////////////////////////////////////// -// Function: FltTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void FltTrans:: run() { if (_got_new_version) { @@ -107,11 +102,9 @@ run() { } -//////////////////////////////////////////////////////////////////// -// Function: FltTrans::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool FltTrans:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { diff --git a/pandatool/src/fltprogs/fltTrans.h b/pandatool/src/fltprogs/fltTrans.h index a434e6113d..042418f6ca 100644 --- a/pandatool/src/fltprogs/fltTrans.h +++ b/pandatool/src/fltprogs/fltTrans.h @@ -1,16 +1,15 @@ -// Filename: fltTrans.h -// Created by: drose (11Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file fltTrans.h + * @author drose + * @date 2001-04-11 + */ #ifndef FLTTRANS_H #define FLTTRANS_H @@ -20,12 +19,10 @@ #include "programBase.h" #include "withOutputFile.h" -//////////////////////////////////////////////////////////////////// -// Class : FltTrans -// Description : A program to read a flt file and write an equivalent -// flt file, possibly performing some minor operations -// along the way. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a flt file and write an equivalent flt file, possibly + * performing some minor operations along the way. + */ class FltTrans : public ProgramBase, public WithOutputFile { public: FltTrans(); @@ -41,4 +38,3 @@ protected: }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStats.cxx b/pandatool/src/gtk-stats/gtkStats.cxx index bb2dffcde7..9ad165fa29 100644 --- a/pandatool/src/gtk-stats/gtkStats.cxx +++ b/pandatool/src/gtk-stats/gtkStats.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStats.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStats.cxx + * @author drose + * @date 2006-01-16 + */ #include "pandatoolbase.h" #include "gtkStats.h" @@ -23,9 +22,9 @@ static GtkStatsServer *server = NULL; static gboolean delete_event(GtkWidget *widget, - GdkEvent *event, gpointer data) { - // Returning FALSE to indicate we should destroy the main window - // when the user selects "close". + GdkEvent *event, gpointer data) { + // Returning FALSE to indicate we should destroy the main window when the + // user selects "close". return FALSE; } @@ -41,11 +40,11 @@ timer(gpointer data) { if (++count == 5) { count = 0; - // Every once in a while, say once a second, we call this - // function, which should force gdk to make all changes visible. - // We do this in case we are getting starved and falling behind, - // so that the user still gets a chance to see *something* happen - // onscreen, even if it's just increasingly old data. + // Every once in a while, say once a second, we call this function, which + // should force gdk to make all changes visible. We do this in case we + // are getting starved and falling behind, so that the user still gets a + // chance to see *something* happen onscreen, even if it's just + // increasingly old data. gdk_window_process_all_updates(); } @@ -66,10 +65,10 @@ main(int argc, char *argv[]) { // Connect the delete and destroy events, so the user can exit the // application by closing the main window. g_signal_connect(G_OBJECT(main_window), "delete_event", - G_CALLBACK(delete_event), NULL); + G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(main_window), "destroy", - G_CALLBACK(destroy), NULL); + G_CALLBACK(destroy), NULL); ostringstream stream; stream << "Listening on port " << pstats_port; @@ -90,10 +89,10 @@ main(int argc, char *argv[]) { GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(main_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", str.c_str()); + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s", str.c_str()); gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); exit(1); diff --git a/pandatool/src/gtk-stats/gtkStats.h b/pandatool/src/gtk-stats/gtkStats.h index 84751c8fd3..a2dfbfd381 100644 --- a/pandatool/src/gtk-stats/gtkStats.h +++ b/pandatool/src/gtk-stats/gtkStats.h @@ -1,16 +1,15 @@ -// Filename: gtkStats.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStats.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATS_H #define GTKSTATS_H @@ -22,4 +21,3 @@ extern GtkWidget *main_window; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx index d593662ca4..dfed8e1028 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.cxx @@ -1,25 +1,22 @@ -// Filename: gtkStatsChartMenu.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsChartMenu.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsChartMenu.h" #include "gtkStatsMonitor.h" -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsChartMenu:: GtkStatsChartMenu(GtkStatsMonitor *monitor, int thread_index) : _monitor(monitor), @@ -30,31 +27,24 @@ GtkStatsChartMenu(GtkStatsMonitor *monitor, int thread_index) : do_update(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsChartMenu:: ~GtkStatsChartMenu() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::get_menu_widget -// Access: Public -// Description: Returns the gtk widget for this particular -// menu. -//////////////////////////////////////////////////////////////////// +/** + * Returns the gtk widget for this particular menu. + */ GtkWidget *GtkStatsChartMenu:: get_menu_widget() { return _menu; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::add_to_menu_bar -// Access: Public -// Description: Adds the menu to the end of the indicated menu bar. -//////////////////////////////////////////////////////////////////// +/** + * Adds the menu to the end of the indicated menu bar. + */ void GtkStatsChartMenu:: add_to_menu_bar(GtkWidget *menu_bar, int position) { const PStatClientData *client_data = _monitor->get_client_data(); @@ -73,13 +63,10 @@ add_to_menu_bar(GtkWidget *menu_bar, int position) { gtk_menu_shell_insert(GTK_MENU_SHELL(menu_bar), menu_item, position); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::check_update -// Access: Public -// Description: Checks to see if the menu needs to be updated -// (e.g. because of new data from the client), and -// updates it if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Checks to see if the menu needs to be updated (e.g. because of new data + * from the client), and updates it if necessary. + */ void GtkStatsChartMenu:: check_update() { PStatView &view = _monitor->get_view(_thread_index); @@ -87,13 +74,10 @@ check_update() { do_update(); } } - -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::do_update -// Access: Public -// Description: Unconditionally updates the menu with the latest data -// from the client. -//////////////////////////////////////////////////////////////////// + +/** + * Unconditionally updates the menu with the latest data from the client. + */ void GtkStatsChartMenu:: do_update() { PStatView &view = _monitor->get_view(_thread_index); @@ -114,15 +98,15 @@ do_update() { int num_toplevel_collectors = client_data->get_num_toplevel_collectors(); for (int tc = 0; tc < num_toplevel_collectors; tc++) { int collector = client_data->get_toplevel_collector(tc); - if (client_data->has_collector(collector) && + if (client_data->has_collector(collector) && client_data->get_collector_has_level(collector, _thread_index)) { - // We put a separator between the above frame collector and the - // first level collector. + // We put a separator between the above frame collector and the first + // level collector. if (needs_separator) { - GtkWidget *sep = gtk_separator_menu_item_new(); - gtk_widget_show(sep); - gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep); + GtkWidget *sep = gtk_separator_menu_item_new(); + gtk_widget_show(sep); + gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep); needs_separator = false; } @@ -136,7 +120,7 @@ do_update() { GtkWidget *sep = gtk_separator_menu_item_new(); gtk_widget_show(sep); gtk_menu_shell_append(GTK_MENU_SHELL(_menu), sep); - + GtkStatsMonitor::MenuDef smd(_thread_index, -1, false); const GtkStatsMonitor::MenuDef *menu_def = _monitor->add_menu(smd); @@ -144,19 +128,17 @@ do_update() { gtk_widget_show(menu_item); gtk_menu_shell_append(GTK_MENU_SHELL(_menu), menu_item); - g_signal_connect_swapped(G_OBJECT(menu_item), "activate", - G_CALLBACK(handle_menu), (void *)(const void *)menu_def); + g_signal_connect_swapped(G_OBJECT(menu_item), "activate", + G_CALLBACK(handle_menu), (void *)(const void *)menu_def); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::add_view -// Access: Private -// Description: Adds a new entry or entries to the menu for the -// indicated view and its children. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new entry or entries to the menu for the indicated view and its + * children. + */ void GtkStatsChartMenu:: -add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, - bool show_level) { +add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, + bool show_level) { int collector = view_level->get_collector(); const PStatClientData *client_data = _monitor->get_client_data(); @@ -169,8 +151,8 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, gtk_widget_show(menu_item); gtk_menu_shell_append(GTK_MENU_SHELL(parent_menu), menu_item); - g_signal_connect_swapped(G_OBJECT(menu_item), "activate", - G_CALLBACK(handle_menu), (void *)(const void *)menu_def); + g_signal_connect_swapped(G_OBJECT(menu_item), "activate", + G_CALLBACK(handle_menu), (void *)(const void *)menu_def); int num_children = view_level->get_num_children(); if (num_children > 1) { @@ -186,20 +168,18 @@ add_view(GtkWidget *parent_menu, const PStatViewLevel *view_level, gtk_widget_show(submenu); gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenu_item), submenu); - // Reverse the order since the menus are listed from the top down; - // we want to be visually consistent with the graphs, which list - // these labels from the bottom up. + // Reverse the order since the menus are listed from the top down; we want + // to be visually consistent with the graphs, which list these labels from + // the bottom up. for (int c = num_children - 1; c >= 0; c--) { add_view(submenu, view_level->get_child(c), show_level); } } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::handle_menu -// Access: Private, Static -// Description: Callback when a menu item is selected. -//////////////////////////////////////////////////////////////////// +/** + * Callback when a menu item is selected. + */ void GtkStatsChartMenu:: handle_menu(gpointer data) { const GtkStatsMonitor::MenuDef *menu_def = (GtkStatsMonitor::MenuDef *)data; @@ -212,17 +192,15 @@ handle_menu(gpointer data) { if (menu_def->_collector_index < 0) { monitor->open_piano_roll(menu_def->_thread_index); } else { - monitor->open_strip_chart(menu_def->_thread_index, - menu_def->_collector_index, - menu_def->_show_level); + monitor->open_strip_chart(menu_def->_thread_index, + menu_def->_collector_index, + menu_def->_show_level); } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsChartMenu::remove_menu_child -// Access: Private, Static -// Description: Removes a previous menu child from the menu. -//////////////////////////////////////////////////////////////////// +/** + * Removes a previous menu child from the menu. + */ void GtkStatsChartMenu:: remove_menu_child(GtkWidget *widget, gpointer data) { GtkWidget *menu = (GtkWidget *)data; diff --git a/pandatool/src/gtk-stats/gtkStatsChartMenu.h b/pandatool/src/gtk-stats/gtkStatsChartMenu.h index ab3ad16634..6206d951ec 100644 --- a/pandatool/src/gtk-stats/gtkStatsChartMenu.h +++ b/pandatool/src/gtk-stats/gtkStatsChartMenu.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsChartMenu.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsChartMenu.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSCHARTMENU_H #define GTKSTATSCHARTMENU_H @@ -23,11 +22,9 @@ class GtkStatsMonitor; class PStatView; class PStatViewLevel; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsChartMenu -// Description : A pulldown menu of charts available for a particular -// thread. -//////////////////////////////////////////////////////////////////// +/** + * A pulldown menu of charts available for a particular thread. + */ class GtkStatsChartMenu { public: GtkStatsChartMenu(GtkStatsMonitor *monitor, int thread_index); @@ -54,4 +51,3 @@ private: }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.cxx b/pandatool/src/gtk-stats/gtkStatsGraph.cxx index 35bd8b5ebb..0c2b21f355 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.cxx +++ b/pandatool/src/gtk-stats/gtkStatsGraph.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStatsGraph.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsGraph.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsGraph.h" #include "gtkStatsMonitor.h" @@ -32,11 +31,9 @@ const GdkColor GtkStatsGraph::rgb_user_guide_bar = { 0, 0x8282, 0x9696, 0xffff }; -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsGraph:: GtkStatsGraph(GtkStatsMonitor *monitor) : _monitor(monitor) @@ -59,56 +56,56 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : _window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - // These calls were intended to kind of emulate the Windows MDI - // behavior, but it's just weird. - // gtk_window_set_transient_for(GTK_WINDOW(_window), GTK_WINDOW(parent_window)); + // These calls were intended to kind of emulate the Windows MDI behavior, + // but it's just weird. gtk_window_set_transient_for(GTK_WINDOW(_window), + // GTK_WINDOW(parent_window)); // gtk_window_set_destroy_with_parent(GTK_WINDOW(_window), TRUE); - gtk_widget_add_events(_window, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK); + gtk_widget_add_events(_window, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK); g_signal_connect(G_OBJECT(_window), "delete_event", - G_CALLBACK(window_delete_event), this); + G_CALLBACK(window_delete_event), this); g_signal_connect(G_OBJECT(_window), "destroy", - G_CALLBACK(window_destroy), this); - g_signal_connect(G_OBJECT(_window), "button_press_event", - G_CALLBACK(button_press_event_callback), this); - g_signal_connect(G_OBJECT(_window), "button_release_event", - G_CALLBACK(button_release_event_callback), this); - g_signal_connect(G_OBJECT(_window), "motion_notify_event", - G_CALLBACK(motion_notify_event_callback), this); + G_CALLBACK(window_destroy), this); + g_signal_connect(G_OBJECT(_window), "button_press_event", + G_CALLBACK(button_press_event_callback), this); + g_signal_connect(G_OBJECT(_window), "button_release_event", + G_CALLBACK(button_release_event_callback), this); + g_signal_connect(G_OBJECT(_window), "motion_notify_event", + G_CALLBACK(motion_notify_event_callback), this); _graph_window = gtk_drawing_area_new(); - gtk_widget_add_events(_graph_window, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK); - g_signal_connect(G_OBJECT(_graph_window), "expose_event", - G_CALLBACK(graph_expose_callback), this); - g_signal_connect(G_OBJECT(_graph_window), "configure_event", - G_CALLBACK(configure_graph_callback), this); - g_signal_connect(G_OBJECT(_graph_window), "button_press_event", - G_CALLBACK(button_press_event_callback), this); - g_signal_connect(G_OBJECT(_graph_window), "button_release_event", - G_CALLBACK(button_release_event_callback), this); - g_signal_connect(G_OBJECT(_graph_window), "motion_notify_event", - G_CALLBACK(motion_notify_event_callback), this); + gtk_widget_add_events(_graph_window, + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK); + g_signal_connect(G_OBJECT(_graph_window), "expose_event", + G_CALLBACK(graph_expose_callback), this); + g_signal_connect(G_OBJECT(_graph_window), "configure_event", + G_CALLBACK(configure_graph_callback), this); + g_signal_connect(G_OBJECT(_graph_window), "button_press_event", + G_CALLBACK(button_press_event_callback), this); + g_signal_connect(G_OBJECT(_graph_window), "button_release_event", + G_CALLBACK(button_release_event_callback), this); + g_signal_connect(G_OBJECT(_graph_window), "motion_notify_event", + G_CALLBACK(motion_notify_event_callback), this); // A Frame to hold the graph. GtkWidget *graph_frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(graph_frame), GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(graph_frame), _graph_window); - // A VBox to hold the graph's frame, and any numbers (scale legend? - // total?) above it. + // A VBox to hold the graph's frame, and any numbers (scale legend? total?) + // above it. _graph_vbox = gtk_vbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(_graph_vbox), graph_frame, - TRUE, TRUE, 0); + TRUE, TRUE, 0); - // An HBox to hold the graph's frame, and the scale legend to the - // right of it. + // An HBox to hold the graph's frame, and the scale legend to the right of + // it. _graph_hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(_graph_hbox), _graph_vbox, - TRUE, TRUE, 0); + TRUE, TRUE, 0); // An HPaned to hold the label stack and the graph hbox. _hpaned = gtk_hpaned_new(); @@ -125,16 +122,14 @@ GtkStatsGraph(GtkStatsMonitor *monitor) : _pause = false; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsGraph:: ~GtkStatsGraph() { _monitor = (GtkStatsMonitor *)NULL; release_pixmap(); - + Brushes::iterator bi; for (bi = _brushes.begin(); bi != _brushes.end(); ++bi) { GdkGC *gc = (*bi).second; @@ -150,84 +145,63 @@ GtkStatsGraph:: } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + */ void GtkStatsGraph:: new_collector(int new_collector) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::new_data -// Access: Public, Virtual -// Description: Called whenever new data arrives. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever new data arrives. + */ void GtkStatsGraph:: new_data(int thread_index, int frame_number) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void GtkStatsGraph:: force_redraw() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void GtkStatsGraph:: changed_graph_size(int graph_xsize, int graph_ysize) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void GtkStatsGraph:: set_time_units(int unit_mask) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speed for the graph to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speed for the graph to the indicated value. + */ void GtkStatsGraph:: set_scroll_speed(double scroll_speed) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::set_pause -// Access: Public -// Description: Changes the pause flag for the graph. When this flag -// is true, the graph does not update in response to new -// data. -//////////////////////////////////////////////////////////////////// +/** + * Changes the pause flag for the graph. When this flag is true, the graph + * does not update in response to new data. + */ void GtkStatsGraph:: set_pause(bool pause) { _pause = pause; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::user_guide_bars_changed -// Access: Public -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void GtkStatsGraph:: user_guide_bars_changed() { if (_scale_area != NULL) { @@ -236,21 +210,17 @@ user_guide_bars_changed() { gtk_widget_queue_draw(_graph_window); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void GtkStatsGraph:: clicked_label(int collector_index) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::close -// Access: Protected -// Description: Should be called when the user closes the associated -// window. This tells the monitor to remove the graph. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the user closes the associated window. This tells + * the monitor to remove the graph. + */ void GtkStatsGraph:: close() { _label_stack.clear_labels(false); @@ -265,12 +235,9 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::get_collector_gc -// Access: Protected -// Description: Returns a GC suitable for drawing in the indicated -// collector's color. -//////////////////////////////////////////////////////////////////// +/** + * Returns a GC suitable for drawing in the indicated collector's color. + */ GdkGC *GtkStatsGraph:: get_collector_gc(int collector_index) { Brushes::iterator bi; @@ -287,87 +254,71 @@ get_collector_gc(int collector_index) { c.green = (int)(rgb[1] * 65535.0f); c.blue = (int)(rgb[2] * 65535.0f); GdkGC *gc = gdk_gc_new(_pixmap); - // g_object_ref(gc); // Should this be ref_sink? + // g_object_ref(gc); Should this be ref_sink? gdk_gc_set_rgb_fg_color(gc, &c); _brushes[collector_index] = gc; return gc; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of expose_event; -// it gives a derived class opportunity to do some -// further painting into the graph window. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of expose_event; it gives a derived + * class opportunity to do some further painting into the graph window. + */ void GtkStatsGraph:: additional_graph_window_paint() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the graph window, -// look for draggable things the mouse might be hovering -// over and return the appropriate DragMode enum or -// DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the graph window, look for draggable + * things the mouse might be hovering over and return the appropriate DragMode + * enum or DM_none if nothing is indicated. + */ GtkStatsGraph::DragMode GtkStatsGraph:: consider_drag_start(int graph_x, int graph_y) { return DM_none; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::set_drag_mode -// Access: Protected, Virtual -// Description: This should be called whenever the drag mode needs to -// change state. It provides hooks for a derived class -// to do something special. -//////////////////////////////////////////////////////////////////// +/** + * This should be called whenever the drag mode needs to change state. It + * provides hooks for a derived class to do something special. + */ void GtkStatsGraph:: set_drag_mode(GtkStatsGraph::DragMode drag_mode) { _drag_mode = drag_mode; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::handle_button_press -// Access: Protected, Virtual -// Description: Called when the mouse button is depressed within the -// window, or any nested window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is depressed within the window, or any nested + * window. + */ gboolean GtkStatsGraph:: handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click) { + bool double_click) { if (_potential_drag_mode != DM_none) { set_drag_mode(_potential_drag_mode); _drag_start_x = graph_x; _drag_start_y = graph_y; - // SetCapture(_window); + // SetCapture(_window); } return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::handle_button_release -// Access: Protected, Virtual -// Description: Called when the mouse button is released within the -// window, or any nested window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is released within the window, or any nested + * window. + */ gboolean GtkStatsGraph:: handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { set_drag_mode(DM_none); - // ReleaseCapture(); + // ReleaseCapture(); return handle_motion(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::handle_motion -// Access: Protected, Virtual, Static -// Description: Called when the mouse is moved within the -// window, or any nested window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse is moved within the window, or any nested window. + */ gboolean GtkStatsGraph:: handle_motion(GtkWidget *widget, int graph_x, int graph_y) { _potential_drag_mode = consider_drag_start(graph_x, graph_y); @@ -383,11 +334,9 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::setup_pixmap -// Access: Private -// Description: Sets up a backing-store bitmap of the indicated size. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a backing-store bitmap of the indicated size. + */ void GtkStatsGraph:: setup_pixmap(int xsize, int ysize) { release_pixmap(); @@ -396,21 +345,18 @@ setup_pixmap(int xsize, int ysize) { _pixmap_ysize = max(ysize, 0); _pixmap = gdk_pixmap_new(_graph_window->window, _pixmap_xsize, _pixmap_ysize, -1); - // g_object_ref(_pixmap); // Should this be ref_sink? + // g_object_ref(_pixmap); Should this be ref_sink? _pixmap_gc = gdk_gc_new(_pixmap); - // g_object_ref(_pixmap_gc); // Should this be ref_sink? + // g_object_ref(_pixmap_gc); Should this be ref_sink? gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white); - gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, - _pixmap_xsize, _pixmap_ysize); + gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, + _pixmap_xsize, _pixmap_ysize); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::release_pixmap -// Access: Private -// Description: Frees the backing-store bitmap created by -// setup_pixmap(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the backing-store bitmap created by setup_pixmap(). + */ void GtkStatsGraph:: release_pixmap() { if (_pixmap != NULL) { @@ -419,120 +365,104 @@ release_pixmap() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::window_delete_event -// Access: Private, Static -// Description: Callback when the window is closed by the user. -//////////////////////////////////////////////////////////////////// +/** + * Callback when the window is closed by the user. + */ gboolean GtkStatsGraph:: window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { - // Returning FALSE to indicate we should destroy the window - // when the user selects "close". + // Returning FALSE to indicate we should destroy the window when the user + // selects "close". return FALSE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::window_destroy -// Access: Private, Static -// Description: Callback when the window is destroyed by the system -// (or by delete_event). -//////////////////////////////////////////////////////////////////// +/** + * Callback when the window is destroyed by the system (or by delete_event). + */ void GtkStatsGraph:: window_destroy(GtkWidget *widget, gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; self->close(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::graph_expose_callback -// Access: Private, Static -// Description: Fills in the graph window. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the graph window. + */ gboolean GtkStatsGraph:: graph_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; if (self->_pixmap != NULL) { - gdk_draw_drawable(self->_graph_window->window, - self->_graph_window->style->fg_gc[0], - self->_pixmap, 0, 0, 0, 0, - self->_pixmap_xsize, self->_pixmap_ysize); + gdk_draw_drawable(self->_graph_window->window, + self->_graph_window->style->fg_gc[0], + self->_pixmap, 0, 0, 0, 0, + self->_pixmap_xsize, self->_pixmap_ysize); } self->additional_graph_window_paint(); - + return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::configure_graph_callback -// Access: Private, Static -// Description: Changes the size of the graph window -//////////////////////////////////////////////////////////////////// +/** + * Changes the size of the graph window + */ gboolean GtkStatsGraph:: -configure_graph_callback(GtkWidget *widget, GdkEventConfigure *event, - gpointer data) { +configure_graph_callback(GtkWidget *widget, GdkEventConfigure *event, + gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; self->changed_graph_size(event->width, event->height); self->setup_pixmap(event->width, event->height); self->force_redraw(); - + return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::button_press_event_callback -// Access: Private, Static -// Description: Called when the mouse button is depressed within the -// graph window or main window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is depressed within the graph window or main + * window. + */ gboolean GtkStatsGraph:: -button_press_event_callback(GtkWidget *widget, GdkEventButton *event, - gpointer data) { +button_press_event_callback(GtkWidget *widget, GdkEventButton *event, + gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; int graph_x, graph_y; gtk_widget_translate_coordinates(widget, self->_graph_window, - (int)event->x, (int)event->y, - &graph_x, &graph_y); + (int)event->x, (int)event->y, + &graph_x, &graph_y); bool double_click = (event->type == GDK_2BUTTON_PRESS); return self->handle_button_press(widget, graph_x, graph_y, double_click); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::button_release_event_callback -// Access: Private, Static -// Description: Called when the mouse button is released within the -// graph window or main window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is released within the graph window or main + * window. + */ gboolean GtkStatsGraph:: -button_release_event_callback(GtkWidget *widget, GdkEventButton *event, - gpointer data) { +button_release_event_callback(GtkWidget *widget, GdkEventButton *event, + gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; int graph_x, graph_y; gtk_widget_translate_coordinates(widget, self->_graph_window, - (int)event->x, (int)event->y, - &graph_x, &graph_y); + (int)event->x, (int)event->y, + &graph_x, &graph_y); return self->handle_button_release(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsGraph::motion_notify_event_callback -// Access: Private, Static -// Description: Called when the mouse is moved within the -// graph window or main window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse is moved within the graph window or main window. + */ gboolean GtkStatsGraph:: -motion_notify_event_callback(GtkWidget *widget, GdkEventMotion *event, - gpointer data) { +motion_notify_event_callback(GtkWidget *widget, GdkEventMotion *event, + gpointer data) { GtkStatsGraph *self = (GtkStatsGraph *)data; int graph_x, graph_y; gtk_widget_translate_coordinates(widget, self->_graph_window, - (int)event->x, (int)event->y, - &graph_x, &graph_y); + (int)event->x, (int)event->y, + &graph_x, &graph_y); return self->handle_motion(widget, graph_x, graph_y); } diff --git a/pandatool/src/gtk-stats/gtkStatsGraph.h b/pandatool/src/gtk-stats/gtkStatsGraph.h index 0009744fa4..94efa0cb06 100644 --- a/pandatool/src/gtk-stats/gtkStatsGraph.h +++ b/pandatool/src/gtk-stats/gtkStatsGraph.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsGraph.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsGraph.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSGRAPH_H #define GTKSTATSGRAPH_H @@ -23,12 +22,10 @@ class GtkStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsGraph -// Description : This is just an abstract base class to provide a -// common pointer type for the various kinds of graphs -// that may be created for a GtkStatsMonitor. -//////////////////////////////////////////////////////////////////// +/** + * This is just an abstract base class to provide a common pointer type for + * the various kinds of graphs that may be created for a GtkStatsMonitor. + */ class GtkStatsGraph { public: // What is the user adjusting by dragging the mouse in a window? @@ -65,7 +62,7 @@ protected: virtual void set_drag_mode(DragMode drag_mode); virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click); + bool double_click); virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y); virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y); @@ -117,25 +114,24 @@ private: void setup_pixmap(int xsize, int ysize); void release_pixmap(); - static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, - gpointer data); + static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, + gpointer data); static void window_destroy(GtkWidget *widget, gpointer data); - static gboolean graph_expose_callback(GtkWidget *widget, - GdkEventExpose *event, gpointer data); - static gboolean configure_graph_callback(GtkWidget *widget, - GdkEventConfigure *event, gpointer data); + static gboolean graph_expose_callback(GtkWidget *widget, + GdkEventExpose *event, gpointer data); + static gboolean configure_graph_callback(GtkWidget *widget, + GdkEventConfigure *event, gpointer data); protected: - static gboolean button_press_event_callback(GtkWidget *widget, - GdkEventButton *event, - gpointer data); - static gboolean button_release_event_callback(GtkWidget *widget, - GdkEventButton *event, - gpointer data); - static gboolean motion_notify_event_callback(GtkWidget *widget, - GdkEventMotion *event, - gpointer data); + static gboolean button_press_event_callback(GtkWidget *widget, + GdkEventButton *event, + gpointer data); + static gboolean button_release_event_callback(GtkWidget *widget, + GdkEventButton *event, + gpointer data); + static gboolean motion_notify_event_callback(GtkWidget *widget, + GdkEventMotion *event, + gpointer data); }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.cxx b/pandatool/src/gtk-stats/gtkStatsLabel.cxx index f39d6d1a38..846aeb8a15 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabel.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStatsLabel.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsLabel.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsLabel.h" #include "gtkStatsMonitor.h" @@ -21,11 +20,9 @@ int GtkStatsLabel::_right_margin = 2; int GtkStatsLabel::_top_margin = 2; int GtkStatsLabel::_bottom_margin = 2; -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsLabel:: GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, int thread_index, int collector_index, bool use_fullname) : @@ -42,17 +39,17 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, } _widget = gtk_drawing_area_new(); - gtk_widget_add_events(_widget, - GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | - GDK_BUTTON_PRESS_MASK); - g_signal_connect(G_OBJECT(_widget), "expose_event", - G_CALLBACK(expose_event_callback), this); - g_signal_connect(G_OBJECT(_widget), "enter_notify_event", - G_CALLBACK(enter_notify_event_callback), this); - g_signal_connect(G_OBJECT(_widget), "leave_notify_event", - G_CALLBACK(leave_notify_event_callback), this); - g_signal_connect(G_OBJECT(_widget), "button_press_event", - G_CALLBACK(button_press_event_callback), this); + gtk_widget_add_events(_widget, + GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | + GDK_BUTTON_PRESS_MASK); + g_signal_connect(G_OBJECT(_widget), "expose_event", + G_CALLBACK(expose_event_callback), this); + g_signal_connect(G_OBJECT(_widget), "enter_notify_event", + G_CALLBACK(enter_notify_event_callback), this); + g_signal_connect(G_OBJECT(_widget), "leave_notify_event", + G_CALLBACK(leave_notify_event_callback), this); + g_signal_connect(G_OBJECT(_widget), "button_press_event", + G_CALLBACK(button_press_event_callback), this); gtk_widget_show(_widget); @@ -77,8 +74,8 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, _fg_color.red = _fg_color.green = _fg_color.blue = 0xffff; } - // What are the extents of the text? This determines the minimum - // size of our widget. + // What are the extents of the text? This determines the minimum size of + // our widget. int width, height; pango_layout_get_pixel_size(_layout, &width, &height); gtk_widget_set_size_request(_widget, width + 8, height); @@ -88,52 +85,41 @@ GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, _height = height; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsLabel:: ~GtkStatsLabel() { - // DeleteObject(_bg_brush); + // DeleteObject(_bg_brush); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::get_widget -// Access: Public -// Description: Returns the widget for this label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the widget for this label. + */ GtkWidget *GtkStatsLabel:: get_widget() const { return _widget; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::get_height -// Access: Public -// Description: Returns the height of the label as we requested it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the label as we requested it. + */ int GtkStatsLabel:: get_height() const { return _height; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::get_collector_index -// Access: Public -// Description: Returns the collector this label represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector this label represents. + */ int GtkStatsLabel:: get_collector_index() const { return _collector_index; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::set_highlight -// Access: Public -// Description: Enables or disables the visual highlight for this -// label. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables the visual highlight for this label. + */ void GtkStatsLabel:: set_highlight(bool highlight) { if (_highlight != highlight) { @@ -142,23 +128,17 @@ set_highlight(bool highlight) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::get_highlight -// Access: Public -// Description: Returns true if the visual highlight for this -// label is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the visual highlight for this label is enabled. + */ bool GtkStatsLabel:: get_highlight() const { return _highlight; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::set_mouse_within -// Access: Private -// Description: Used internally to indicate whether the mouse is -// within the label's widget. -//////////////////////////////////////////////////////////////////// +/** + * Used internally to indicate whether the mouse is within the label's widget. + */ void GtkStatsLabel:: set_mouse_within(bool mouse_within) { if (_mouse_within != mouse_within) { @@ -167,11 +147,9 @@ set_mouse_within(bool mouse_within) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::expose_event_callback -// Access: Private, Static -// Description: Draws the background color of the label. -//////////////////////////////////////////////////////////////////// +/** + * Draws the background color of the label. + */ gboolean GtkStatsLabel:: expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsLabel *self = (GtkStatsLabel *)data; @@ -179,63 +157,56 @@ expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GdkGC *gc = gdk_gc_new(widget->window); gdk_gc_set_rgb_fg_color(gc, &self->_bg_color); - gdk_draw_rectangle(widget->window, gc, TRUE, 0, 0, - widget->allocation.width, widget->allocation.height); + gdk_draw_rectangle(widget->window, gc, TRUE, 0, 0, + widget->allocation.width, widget->allocation.height); // Center the text within the rectangle. int width, height; pango_layout_get_pixel_size(self->_layout, &width, &height); gdk_gc_set_rgb_fg_color(gc, &self->_fg_color); - gdk_draw_layout(widget->window, gc, - (widget->allocation.width - width) / 2, 0, - self->_layout); + gdk_draw_layout(widget->window, gc, + (widget->allocation.width - width) / 2, 0, + self->_layout); // Now draw the highlight rectangle, if any. if (self->_highlight || self->_mouse_within) { - gdk_draw_rectangle(widget->window, gc, FALSE, 0, 0, - widget->allocation.width - 1, widget->allocation.height - 1); + gdk_draw_rectangle(widget->window, gc, FALSE, 0, 0, + widget->allocation.width - 1, widget->allocation.height - 1); } g_object_unref(gc); return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::enter_notify_event_callback -// Access: Private, Static -// Description: Called when the mouse enters the label region -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse enters the label region + */ gboolean GtkStatsLabel:: -enter_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event, - gpointer data) { +enter_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event, + gpointer data) { GtkStatsLabel *self = (GtkStatsLabel *)data; self->set_mouse_within(true); return TRUE; } - -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::leave_notify_event_callback -// Access: Private, Static -// Description: Called when the mouse leaves the label region -//////////////////////////////////////////////////////////////////// + +/** + * Called when the mouse leaves the label region + */ gboolean GtkStatsLabel:: -leave_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event, - gpointer data) { +leave_notify_event_callback(GtkWidget *widget, GdkEventCrossing *event, + gpointer data) { GtkStatsLabel *self = (GtkStatsLabel *)data; self->set_mouse_within(false); return TRUE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabel::button_press_event_callback -// Access: Private, Static -// Description: Called when the mouse button is depressed within the -// label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is depressed within the label. + */ gboolean GtkStatsLabel:: -button_press_event_callback(GtkWidget *widget, GdkEventButton *event, - gpointer data) { +button_press_event_callback(GtkWidget *widget, GdkEventButton *event, + gpointer data) { GtkStatsLabel *self = (GtkStatsLabel *)data; bool double_click = (event->type == GDK_2BUTTON_PRESS); if (double_click) { diff --git a/pandatool/src/gtk-stats/gtkStatsLabel.h b/pandatool/src/gtk-stats/gtkStatsLabel.h index b62cbfc17a..80f697dc4f 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabel.h +++ b/pandatool/src/gtk-stats/gtkStatsLabel.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsLabel.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsLabel.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSLABEL_H #define GTKSTATSLABEL_H @@ -22,13 +21,11 @@ class GtkStatsMonitor; class GtkStatsGraph; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsLabel -// Description : A text label that will draw in color appropriate for -// a particular collector. It also responds when the -// user double-clicks on it. This is handy for putting -// colored labels on strip charts. -//////////////////////////////////////////////////////////////////// +/** + * A text label that will draw in color appropriate for a particular + * collector. It also responds when the user double-clicks on it. This is + * handy for putting colored labels on strip charts. + */ class GtkStatsLabel { public: GtkStatsLabel(GtkStatsMonitor *monitor, GtkStatsGraph *graph, @@ -45,17 +42,17 @@ public: private: void set_mouse_within(bool mouse_within); - static gboolean expose_event_callback(GtkWidget *widget, - GdkEventExpose *event, gpointer data); - static gboolean enter_notify_event_callback(GtkWidget *widget, - GdkEventCrossing *event, - gpointer data); - static gboolean leave_notify_event_callback(GtkWidget *widget, - GdkEventCrossing *event, - gpointer data); - static gboolean button_press_event_callback(GtkWidget *widget, - GdkEventButton *event, - gpointer data); + static gboolean expose_event_callback(GtkWidget *widget, + GdkEventExpose *event, gpointer data); + static gboolean enter_notify_event_callback(GtkWidget *widget, + GdkEventCrossing *event, + gpointer data); + static gboolean leave_notify_event_callback(GtkWidget *widget, + GdkEventCrossing *event, + gpointer data); + static gboolean button_press_event_callback(GtkWidget *widget, + GdkEventButton *event, + gpointer data); GtkStatsMonitor *_monitor; GtkStatsGraph *_graph; @@ -83,4 +80,3 @@ private: }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsLabelStack.cxx b/pandatool/src/gtk-stats/gtkStatsLabelStack.cxx index 20563bc9b1..a640fb3217 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabelStack.cxx +++ b/pandatool/src/gtk-stats/gtkStatsLabelStack.cxx @@ -1,58 +1,49 @@ -// Filename: gtkStatsLabelStack.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsLabelStack.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsLabelStack.h" #include "gtkStatsLabel.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsLabelStack:: GtkStatsLabelStack() { _widget = gtk_vbox_new(FALSE, 0); _highlight_label = -1; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsLabelStack:: ~GtkStatsLabelStack() { clear_labels(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::get_widget -// Access: Public -// Description: Returns the widget for this stack. -//////////////////////////////////////////////////////////////////// +/** + * Returns the widget for this stack. + */ GtkWidget *GtkStatsLabelStack:: get_widget() const { return _widget; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::get_label_y -// Access: Public -// Description: Returns the y position of the indicated label's bottom -// edge, relative to the indicated target widget. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y position of the indicated label's bottom edge, relative to + * the indicated target widget. + */ int GtkStatsLabelStack:: get_label_y(int label_index, GtkWidget *target_widget) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), 0); @@ -63,38 +54,31 @@ get_label_y(int label_index, GtkWidget *target_widget) const { int x, y; gtk_widget_translate_coordinates(_widget, target_widget, - 0, start_y, &x, &y); + 0, start_y, &x, &y); return y; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::get_label_height -// Access: Public -// Description: Returns the height of the indicated label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the indicated label. + */ int GtkStatsLabelStack:: get_label_height(int label_index) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), 0); return _labels[label_index]->get_height(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::get_label_collector_index -// Access: Public -// Description: Returns the collector index associated with the -// indicated label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index associated with the indicated label. + */ int GtkStatsLabelStack:: get_label_collector_index(int label_index) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), -1); return _labels[label_index]->get_collector_index(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::clear_labels -// Access: Public -// Description: Removes the set of labels and starts a new set. -//////////////////////////////////////////////////////////////////// +/** + * Removes the set of labels and starts a new set. + */ void GtkStatsLabelStack:: clear_labels(bool delete_widgets) { Labels::iterator li; @@ -108,20 +92,17 @@ clear_labels(bool delete_widgets) { _labels.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::add_label -// Access: Public -// Description: Adds a new label to the top of the stack; returns the -// new label index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new label to the top of the stack; returns the new label index. + */ int GtkStatsLabelStack:: add_label(GtkStatsMonitor *monitor, GtkStatsGraph *graph, int thread_index, int collector_index, bool use_fullname) { - GtkStatsLabel *label = + GtkStatsLabel *label = new GtkStatsLabel(monitor, graph, thread_index, collector_index, use_fullname); gtk_box_pack_end(GTK_BOX(_widget), label->get_widget(), - FALSE, FALSE, 0); + FALSE, FALSE, 0); int label_index = (int)_labels.size(); _labels.push_back(label); @@ -129,24 +110,19 @@ add_label(GtkStatsMonitor *monitor, GtkStatsGraph *graph, return label_index; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::get_num_labels -// Access: Public -// Description: Returns the number of labels in the stack. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of labels in the stack. + */ int GtkStatsLabelStack:: get_num_labels() const { return _labels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsLabelStack::highlight_label -// Access: Public -// Description: Draws a highlight around the label representing the -// indicated collector, and removes the highlight from -// any other label. Specify -1 to remove the highlight -// from all labels. -//////////////////////////////////////////////////////////////////// +/** + * Draws a highlight around the label representing the indicated collector, + * and removes the highlight from any other label. Specify -1 to remove the + * highlight from all labels. + */ void GtkStatsLabelStack:: highlight_label(int collector_index) { if (_highlight_label != collector_index) { diff --git a/pandatool/src/gtk-stats/gtkStatsLabelStack.h b/pandatool/src/gtk-stats/gtkStatsLabelStack.h index 99c2d345f4..32eed06221 100644 --- a/pandatool/src/gtk-stats/gtkStatsLabelStack.h +++ b/pandatool/src/gtk-stats/gtkStatsLabelStack.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsLabelStack.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsLabelStack.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSLABELSTACK_H #define GTKSTATSLABELSTACK_H @@ -24,11 +23,9 @@ class GtkStatsLabel; class GtkStatsMonitor; class GtkStatsGraph; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsLabelStack -// Description : A widget that contains a stack of labels from bottom -// to top. -//////////////////////////////////////////////////////////////////// +/** + * A widget that contains a stack of labels from bottom to top. + */ class GtkStatsLabelStack { public: GtkStatsLabelStack(); @@ -56,4 +53,3 @@ private: }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsMenuId.h b/pandatool/src/gtk-stats/gtkStatsMenuId.h index 412125cc5b..71e2fc4223 100644 --- a/pandatool/src/gtk-stats/gtkStatsMenuId.h +++ b/pandatool/src/gtk-stats/gtkStatsMenuId.h @@ -1,27 +1,25 @@ -// Filename: gtkStatsMenuId.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsMenuId.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSMENUID_H #define GTKSTATSMENUID_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : GtkStatsMenuId -// Description : The enumerated values here are used for menu ID's for -// the various pulldown menus in the application. -//////////////////////////////////////////////////////////////////// +/** + * The enumerated values here are used for menu ID's for the various pulldown + * menus in the application. + */ enum GtkStatsMenuId { MI_none, MI_time_ms, @@ -34,10 +32,9 @@ enum GtkStatsMenuId { MI_speed_12, MI_pause, - // This one is last and represents the beginning of the range for - // the various "new chart" menu options. + // This one is last and represents the beginning of the range for the + // various "new chart" menu options. MI_new_chart }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.I b/pandatool/src/gtk-stats/gtkStatsMonitor.I index d3955b488a..71f5b43404 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.I +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.I @@ -1,23 +1,19 @@ -// Filename: gtkStatsMonitor.I -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsMonitor.I + * @author drose + * @date 2006-01-16 + */ - -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::MenuDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsMonitor::MenuDef:: MenuDef(int thread_index, int collector_index, bool show_level) : _thread_index(thread_index), @@ -27,11 +23,9 @@ MenuDef(int thread_index, int collector_index, bool show_level) : { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::MenuDef::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool GtkStatsMonitor::MenuDef:: operator < (const MenuDef &other) const { if (_thread_index != other._thread_index) { diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx index 49d535058c..fe4926cbc5 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.cxx +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStatsMonitor.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsMonitor.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsMonitor.h" #include "gtkStats.h" @@ -42,11 +41,9 @@ GtkItemFactoryEntry GtkStatsMonitor::menu_entries[] = { int GtkStatsMonitor::num_menu_entries = sizeof(menu_entries) / sizeof(GtkItemFactoryEntry); -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsMonitor:: GtkStatsMonitor(GtkStatsServer *server) : PStatMonitor(server) { _window = NULL; @@ -58,66 +55,51 @@ GtkStatsMonitor(GtkStatsServer *server) : PStatMonitor(server) { _pause = false; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsMonitor:: ~GtkStatsMonitor() { shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::get_monitor_name -// Access: Public, Virtual -// Description: Should be redefined to return a descriptive name for -// the type of PStatsMonitor this is. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return a descriptive name for the type of + * PStatsMonitor this is. + */ string GtkStatsMonitor:: get_monitor_name() { return "GtkStats"; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::initialized -// Access: Public, Virtual -// Description: Called after the monitor has been fully set up. At -// this time, it will have a valid _client_data pointer, -// and things like is_alive() and close() will be -// meaningful. However, we may not yet know who we're -// connected to (is_client_known() may return false), -// and we may not know anything about the threads or -// collectors we're about to get data on. -//////////////////////////////////////////////////////////////////// +/** + * Called after the monitor has been fully set up. At this time, it will have + * a valid _client_data pointer, and things like is_alive() and close() will + * be meaningful. However, we may not yet know who we're connected to + * (is_client_known() may return false), and we may not know anything about + * the threads or collectors we're about to get data on. + */ void GtkStatsMonitor:: initialized() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::got_hello -// Access: Public, Virtual -// Description: Called when the "hello" message has been received -// from the client. At this time, the client's hostname -// and program name will be known. -//////////////////////////////////////////////////////////////////// +/** + * Called when the "hello" message has been received from the client. At this + * time, the client's hostname and program name will be known. + */ void GtkStatsMonitor:: got_hello() { create_window(); open_strip_chart(0, 0, false); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::got_bad_version -// Access: Public, Virtual -// Description: Like got_hello(), this is called when the "hello" -// message has been received from the client. At this -// time, the client's hostname and program name will be -// known. However, the client appears to be an -// incompatible version and the connection will be -// terminated; the monitor should issue a message to -// that effect. -//////////////////////////////////////////////////////////////////// +/** + * Like got_hello(), this is called when the "hello" message has been received + * from the client. At this time, the client's hostname and program name will + * be known. However, the client appears to be an incompatible version and + * the connection will be terminated; the monitor should issue a message to + * that effect. + */ void GtkStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { @@ -146,17 +128,13 @@ got_bad_version(int client_major, int client_minor, gtk_widget_destroy(dialog); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. Generally, the client will -// send all of its collectors over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Collector -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + * Generally, the client will send all of its collectors over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Collector definitions midstream. + */ void GtkStatsMonitor:: new_collector(int collector_index) { Graphs::iterator gi; @@ -172,17 +150,13 @@ new_collector(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::new_thread -// Access: Public, Virtual -// Description: Called whenever a new Thread definition is -// received from the client. Generally, the client will -// send all of its threads over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Thread -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Thread definition is received from the client. + * Generally, the client will send all of its threads over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Thread definitions midstream. + */ void GtkStatsMonitor:: new_thread(int thread_index) { GtkStatsChartMenu *chart_menu = new GtkStatsChartMenu(this, thread_index); @@ -192,15 +166,12 @@ new_thread(int thread_index) { _chart_menus.push_back(chart_menu); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no guarantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no guarantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void GtkStatsMonitor:: new_data(int thread_index, int frame_number) { Graphs::iterator gi; @@ -211,14 +182,11 @@ new_data(int thread_index, int frame_number) { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::lost_connection -// Access: Public, Virtual -// Description: Called whenever the connection to the client has been -// lost. This is a permanent state change. The monitor -// should update its display to represent this, and may -// choose to close down automatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the connection to the client has been lost. This is a + * permanent state change. The monitor should update its display to represent + * this, and may choose to close down automatically. + */ void GtkStatsMonitor:: lost_connection() { nout << "Lost connection to " << get_client_hostname() << "\n"; @@ -226,13 +194,10 @@ lost_connection() { shutdown(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::idle -// Access: Public, Virtual -// Description: If has_idle() returns true, this will be called -// periodically to allow the monitor to update its -// display or whatever it needs to do. -//////////////////////////////////////////////////////////////////// +/** + * If has_idle() returns true, this will be called periodically to allow the + * monitor to update its display or whatever it needs to do. + */ void GtkStatsMonitor:: idle() { // Check if any of our chart menus need updating. @@ -252,22 +217,18 @@ idle() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::has_idle -// Access: Public, Virtual -// Description: Should be redefined to return true if you want to -// redefine idle() and expect it to be called. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true if you want to redefine idle() and + * expect it to be called. + */ bool GtkStatsMonitor:: has_idle() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::user_guide_bars_changed -// Access: Public, Virtual -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void GtkStatsMonitor:: user_guide_bars_changed() { Graphs::iterator gi; @@ -277,24 +238,20 @@ user_guide_bars_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::get_window -// Access: Public -// Description: Returns the window handle to the monitor's window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window handle to the monitor's window. + */ GtkWidget *GtkStatsMonitor:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::open_strip_chart -// Access: Public -// Description: Opens a new strip chart showing the indicated data. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new strip chart showing the indicated data. + */ void GtkStatsMonitor:: open_strip_chart(int thread_index, int collector_index, bool show_level) { - GtkStatsStripChart *graph = + GtkStatsStripChart *graph = new GtkStatsStripChart(this, thread_index, collector_index, show_level); add_graph(graph); @@ -303,11 +260,9 @@ open_strip_chart(int thread_index, int collector_index, bool show_level) { graph->set_pause(_pause); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::open_piano_roll -// Access: Public -// Description: Opens a new piano roll showing the indicated data. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new piano roll showing the indicated data. + */ void GtkStatsMonitor:: open_piano_roll(int thread_index) { GtkStatsPianoRoll *graph = new GtkStatsPianoRoll(this, thread_index); @@ -318,12 +273,10 @@ open_piano_roll(int thread_index) { graph->set_pause(_pause); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::add_menu -// Access: Public -// Description: Adds a new MenuDef to the monitor, or returns an -// existing one if there is already one just like it. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new MenuDef to the monitor, or returns an existing one if there is + * already one just like it. + */ const GtkStatsMonitor::MenuDef *GtkStatsMonitor:: add_menu(const MenuDef &menu_def) { pair result = _menus.insert(menu_def); @@ -336,14 +289,11 @@ add_menu(const MenuDef &menu_def) { return &new_menu_def; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::set_time_units -// Access: Public -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for all graphs to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for all graphs to the indicated mask if + * it is a time-based graph. + */ void GtkStatsMonitor:: set_time_units(int unit_mask) { _time_units = unit_mask; @@ -356,13 +306,10 @@ set_time_units(int unit_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speeds for all graphs to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speeds for all graphs to the indicated value. + */ void GtkStatsMonitor:: set_scroll_speed(double scroll_speed) { _scroll_speed = scroll_speed; @@ -375,12 +322,9 @@ set_scroll_speed(double scroll_speed) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::set_pause -// Access: Public -// Description: Called when the user selects a pause on or pause off -// option from the menu. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a pause on or pause off option from the menu. + */ void GtkStatsMonitor:: set_pause(bool pause) { _pause = pause; @@ -393,22 +337,17 @@ set_pause(bool pause) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::add_graph -// Access: Private -// Description: Adds the newly-created graph to the list of managed -// graphs. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created graph to the list of managed graphs. + */ void GtkStatsMonitor:: add_graph(GtkStatsGraph *graph) { _graphs.insert(graph); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::remove_graph -// Access: Private -// Description: Deletes the indicated graph. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the indicated graph. + */ void GtkStatsMonitor:: remove_graph(GtkStatsGraph *graph) { Graphs::iterator gi = _graphs.find(graph); @@ -418,11 +357,9 @@ remove_graph(GtkStatsGraph *graph) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::create_window -// Access: Private -// Description: Creates the window for this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this monitor. + */ void GtkStatsMonitor:: create_window() { if (_window != NULL) { @@ -432,9 +369,9 @@ create_window() { _window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(_window), "delete_event", - G_CALLBACK(window_delete_event), this); + G_CALLBACK(window_delete_event), this); g_signal_connect(G_OBJECT(_window), "destroy", - G_CALLBACK(window_destroy), this); + G_CALLBACK(window_destroy), this); _window_title = get_client_progname() + " on " + get_client_hostname(); gtk_window_set_title(GTK_WINDOW(_window), _window_title.c_str()); @@ -443,10 +380,10 @@ create_window() { // Set up the menu. GtkAccelGroup *accel_group = gtk_accel_group_new(); - _item_factory = + _item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "", accel_group); gtk_item_factory_create_items(_item_factory, num_menu_entries, menu_entries, - this); + this); gtk_window_add_accel_group(GTK_WINDOW(_window), accel_group); GtkWidget *menu_bar = gtk_item_factory_get_widget(_item_factory, ""); _next_chart_index = 2; @@ -465,24 +402,22 @@ create_window() { gtk_box_pack_start(GTK_BOX(main_vbox), menu_bar, FALSE, TRUE, 0); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(_item_factory, "/Speed/3")), - TRUE); + TRUE); set_scroll_speed(3); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item(_item_factory, "/Options/Units/ms")), - TRUE); + TRUE); set_time_units(PStatGraph::GBU_ms); - gtk_widget_show_all(_window); + gtk_widget_show_all(_window); gtk_widget_show(_window); set_pause(false); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::shutdown -// Access: Private -// Description: Closes all the graphs associated with this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Closes all the graphs associated with this monitor. + */ void GtkStatsMonitor:: shutdown() { Graphs::iterator gi; @@ -508,39 +443,31 @@ shutdown() { #endif } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::window_delete_event -// Access: Private, Static -// Description: Callback when the window is closed by the user. -//////////////////////////////////////////////////////////////////// +/** + * Callback when the window is closed by the user. + */ gboolean GtkStatsMonitor:: window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { - // Returning FALSE to indicate we should destroy the window - // when the user selects "close". + // Returning FALSE to indicate we should destroy the window when the user + // selects "close". return FALSE; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::window_destroy -// Access: Private, Static -// Description: Callback when the window is destroyed by the system -// (or by delete_event). -//////////////////////////////////////////////////////////////////// +/** + * Callback when the window is destroyed by the system (or by delete_event). + */ void GtkStatsMonitor:: window_destroy(GtkWidget *widget, gpointer data) { GtkStatsMonitor *self = (GtkStatsMonitor *)data; self->close(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::setup_frame_rate_label -// Access: Private -// Description: Creates the frame rate label on the right end of the -// menu bar. This is used as a text label to display -// the main thread's frame rate to the user, although it -// is implemented as a right-justified toplevel menu -// item that doesn't open to anything. -//////////////////////////////////////////////////////////////////// +/** + * Creates the frame rate label on the right end of the menu bar. This is + * used as a text label to display the main thread's frame rate to the user, + * although it is implemented as a right-justified toplevel menu item that + * doesn't open to anything. + */ void GtkStatsMonitor:: setup_frame_rate_label() { GtkWidget *menu_bar = gtk_item_factory_get_widget(_item_factory, ""); @@ -556,11 +483,9 @@ setup_frame_rate_label() { gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), _frame_rate_menu_item); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsMonitor::handle_menu_command -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void GtkStatsMonitor:: handle_menu_command(gpointer callback_data, guint menu_id, GtkWidget *widget) { GtkStatsMonitor *self = (GtkStatsMonitor *)callback_data; diff --git a/pandatool/src/gtk-stats/gtkStatsMonitor.h b/pandatool/src/gtk-stats/gtkStatsMonitor.h index 3ec496ede3..704a919cf8 100644 --- a/pandatool/src/gtk-stats/gtkStatsMonitor.h +++ b/pandatool/src/gtk-stats/gtkStatsMonitor.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsMonitor.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsMonitor.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSMONITOR_H #define GTKSTATSMONITOR_H @@ -29,11 +28,10 @@ class GtkStatsServer; class GtkStatsChartMenu; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsMonitor -// Description : This class represents a connection to a PStatsClient -// and manages the data exchange with the client. -//////////////////////////////////////////////////////////////////// +/** + * This class represents a connection to a PStatsClient and manages the data + * exchange with the client. + */ class GtkStatsMonitor : public PStatMonitor { public: class MenuDef { @@ -74,15 +72,15 @@ public: void set_time_units(int unit_mask); void set_scroll_speed(double scroll_speed); void set_pause(bool pause); - + private: void add_graph(GtkStatsGraph *graph); void remove_graph(GtkStatsGraph *graph); void create_window(); void shutdown(); - static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, - gpointer data); + static gboolean window_delete_event(GtkWidget *widget, GdkEvent *event, + gpointer data); static void window_destroy(GtkWidget *widget, gpointer data); void setup_frame_rate_label(); diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx index 93875870a6..f29ae4955c 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStatsPianoRoll.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsPianoRoll.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsPianoRoll.h" #include "gtkStatsMonitor.h" @@ -20,14 +19,12 @@ static const int default_piano_roll_width = 400; static const int default_piano_roll_height = 200; -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsPianoRoll:: GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) : - PStatPianoRoll(monitor, thread_index, + PStatPianoRoll(monitor, thread_index, default_piano_roll_width, default_piano_roll_height), GtkStatsGraph(monitor) @@ -35,54 +32,49 @@ GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index) : // Let's show the units on the guide bar labels. There's room. set_guide_bar_units(get_guide_bar_units() | GBU_show_units); - // Add a DrawingArea widget on top of the graph, to display all of - // the scale units. + // Add a DrawingArea widget on top of the graph, to display all of the scale + // units. _scale_area = gtk_drawing_area_new(); - g_signal_connect(G_OBJECT(_scale_area), "expose_event", - G_CALLBACK(expose_event_callback), this); + g_signal_connect(G_OBJECT(_scale_area), "expose_event", + G_CALLBACK(expose_event_callback), this); gtk_box_pack_start(GTK_BOX(_graph_vbox), _scale_area, - FALSE, FALSE, 0); + FALSE, FALSE, 0); gtk_widget_set_size_request(_scale_area, 0, 20); gtk_widget_set_size_request(_graph_window, default_piano_roll_width, - default_piano_roll_height); + default_piano_roll_height); - const PStatClientData *client_data = + const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data(); string thread_name = client_data->get_thread_name(_thread_index); string window_title = thread_name + " thread piano roll"; gtk_window_set_title(GTK_WINDOW(_window), window_title.c_str()); - - gtk_widget_show_all(_window); + + gtk_widget_show_all(_window); gtk_widget_show(_window); - // Allow the window to be resized as small as the user likes. We - // have to do this after the window has been shown; otherwise, it - // will affect the window's initial size. + // Allow the window to be resized as small as the user likes. We have to do + // this after the window has been shown; otherwise, it will affect the + // window's initial size. gtk_widget_set_size_request(_window, 0, 0); clear_region(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsPianoRoll:: ~GtkStatsPianoRoll() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::idle -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no gurantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no gurantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void GtkStatsPianoRoll:: new_data(int thread_index, int frame_number) { if (!_pause) { @@ -90,35 +82,27 @@ new_data(int thread_index, int frame_number) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void GtkStatsPianoRoll:: force_redraw() { PStatPianoRoll::force_redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void GtkStatsPianoRoll:: changed_graph_size(int graph_xsize, int graph_ysize) { PStatPianoRoll::changed_size(graph_xsize, graph_ysize); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void GtkStatsPianoRoll:: set_time_units(int unit_mask) { int old_unit_mask = get_guide_bar_units(); @@ -131,11 +115,9 @@ set_time_units(int unit_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void GtkStatsPianoRoll:: clicked_label(int collector_index) { if (collector_index >= 0) { @@ -143,12 +125,10 @@ clicked_label(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::set_horizontal_scale -// Access: Public -// Description: Changes the amount of time the width of the -// horizontal axis represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the amount of time the width of the horizontal axis represents. + * This may force a redraw. + */ void GtkStatsPianoRoll:: set_horizontal_scale(double time_width) { PStatPianoRoll::set_horizontal_scale(time_width); @@ -157,24 +137,19 @@ set_horizontal_scale(double time_width) { gtk_widget_queue_draw(_scale_area); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::clear_region -// Access: Protected -// Description: Erases the chart area. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area. + */ void GtkStatsPianoRoll:: clear_region() { gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white); - gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, - get_xsize(), get_ysize()); + gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, + get_xsize(), get_ysize()); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::begin_draw -// Access: Protected, Virtual -// Description: Erases the chart area in preparation for drawing a -// bunch of bars. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area in preparation for drawing a bunch of bars. + */ void GtkStatsPianoRoll:: begin_draw() { clear_region(); @@ -186,11 +161,9 @@ begin_draw() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::draw_bar -// Access: Protected, Virtual -// Description: Draws a single bar on the chart. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single bar on the chart. + */ void GtkStatsPianoRoll:: draw_bar(int row, int from_x, int to_x) { if (row >= 0 && row < _label_stack.get_num_labels()) { @@ -199,29 +172,25 @@ draw_bar(int row, int from_x, int to_x) { int collector_index = get_label_collector(row); GdkGC *gc = get_collector_gc(collector_index); - - gdk_draw_rectangle(_pixmap, gc, TRUE, - from_x, y - height + 2, - to_x - from_x, height - 4); + + gdk_draw_rectangle(_pixmap, gc, TRUE, + from_x, y - height + 2, + to_x - from_x, height - 4); } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::end_draw -// Access: Protected, Virtual -// Description: Called after all the bars have been drawn, this -// triggers a refresh event to draw it to the window. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the bars have been drawn, this triggers a refresh event to + * draw it to the window. + */ void GtkStatsPianoRoll:: end_draw() { gtk_widget_queue_draw(_graph_window); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::idle -// Access: Protected, Virtual -// Description: Called at the end of the draw cycle. -//////////////////////////////////////////////////////////////////// +/** + * Called at the end of the draw cycle. + */ void GtkStatsPianoRoll:: idle() { if (_labels_changed) { @@ -229,13 +198,10 @@ idle() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of expose_event; -// it gives a derived class opportunity to do some -// further painting into the graph window. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of expose_event; it gives a derived + * class opportunity to do some further painting into the graph window. + */ void GtkStatsPianoRoll:: additional_graph_window_paint() { int num_user_guide_bars = get_num_user_guide_bars(); @@ -244,14 +210,11 @@ additional_graph_window_paint() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the graph window, -// look for draggable things the mouse might be hovering -// over and return the appropriate DragMode enum or -// DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the graph window, look for draggable + * things the mouse might be hovering over and return the appropriate DragMode + * enum or DM_none if nothing is indicated. + */ GtkStatsGraph::DragMode GtkStatsPianoRoll:: consider_drag_start(int graph_x, int graph_y) { if (graph_y >= 0 && graph_y < get_ysize()) { @@ -266,8 +229,8 @@ consider_drag_start(int graph_x, int graph_y) { } } else { - // The mouse is left or right of the graph; maybe create a new - // guide bar. + // The mouse is left or right of the graph; maybe create a new guide + // bar. return DM_new_guide_bar; } } @@ -275,18 +238,15 @@ consider_drag_start(int graph_x, int graph_y) { return GtkStatsGraph::consider_drag_start(graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::handle_button_press -// Access: Protected, Virtual -// Description: Called when the mouse button is depressed within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is depressed within the graph window. + */ gboolean GtkStatsPianoRoll:: handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click) { + bool double_click) { if (double_click) { - // Double-clicking on a color bar in the graph is the same as - // double-clicking on the corresponding label. + // Double-clicking on a color bar in the graph is the same as double- + // clicking on the corresponding label. clicked_label(get_collector_under_pixel(graph_x, graph_y)); return TRUE; } @@ -294,33 +254,30 @@ handle_button_press(GtkWidget *widget, int graph_x, int graph_y, if (_potential_drag_mode == DM_none) { set_drag_mode(DM_scale); _drag_scale_start = pixel_to_height(graph_x); - //SetCapture(_graph_window); + // SetCapture(_graph_window); return TRUE; } else if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) { set_drag_mode(DM_guide_bar); _drag_start_x = graph_x; - //SetCapture(_graph_window); + // SetCapture(_graph_window); return TRUE; } - return GtkStatsGraph::handle_button_press(widget, graph_x, graph_y, - double_click); + return GtkStatsGraph::handle_button_press(widget, graph_x, graph_y, + double_click); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::handle_button_release -// Access: Protected, Virtual -// Description: Called when the mouse button is released within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is released within the graph window. + */ gboolean GtkStatsPianoRoll:: handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { if (_drag_mode == DM_scale) { set_drag_mode(DM_none); - //ReleaseCapture(); + // ReleaseCapture(); return handle_motion(widget, graph_x, graph_y); - + } else if (_drag_mode == DM_guide_bar) { if (graph_x < 0 || graph_x >= get_xsize()) { remove_user_guide_bar(_drag_guide_bar); @@ -328,19 +285,16 @@ handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { move_user_guide_bar(_drag_guide_bar, pixel_to_height(graph_x)); } set_drag_mode(DM_none); - //ReleaseCapture(); + // ReleaseCapture(); return handle_motion(widget, graph_x, graph_y); } return GtkStatsGraph::handle_button_release(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::ns_motion_notify_event_callback -// Access: Protected, Virtual -// Description: Called when the mouse is moved within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse is moved within the graph window. + */ gboolean GtkStatsPianoRoll:: handle_motion(GtkWidget *widget, int graph_x, int graph_y) { if (_drag_mode == DM_none && _potential_drag_mode == DM_none) { @@ -348,8 +302,8 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { _label_stack.highlight_label(get_collector_under_pixel(graph_x, graph_y)); /* - // Now we want to get a WM_MOUSELEAVE when the mouse leaves the - // graph window. + // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph + // window. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, @@ -372,8 +326,8 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { return TRUE; } else if (_drag_mode == DM_new_guide_bar) { - // We haven't created the new guide bar yet; we won't until the - // mouse comes within the graph's region. + // We haven't created the new guide bar yet; we won't until the mouse + // comes within the graph's region. if (graph_x >= 0 && graph_x < get_xsize()) { set_drag_mode(DM_guide_bar); _drag_guide_bar = add_user_guide_bar(pixel_to_height(graph_x)); @@ -388,12 +342,10 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { return GtkStatsGraph::handle_motion(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::get_collector_under_pixel -// Access: Private -// Description: Returns the collector index associated with the -// indicated vertical row, or -1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index associated with the indicated vertical row, or + * -1. + */ int GtkStatsPianoRoll:: get_collector_under_pixel(int xpoint, int ypoint) { if (_label_stack.get_num_labels() == 0) { @@ -410,28 +362,23 @@ get_collector_under_pixel(int xpoint, int ypoint) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::update_labels -// Access: Private -// Description: Resets the list of labels. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of labels. + */ void GtkStatsPianoRoll:: update_labels() { _label_stack.clear_labels(); for (int i = 0; i < get_num_labels(); i++) { _label_stack.add_label(GtkStatsGraph::_monitor, this, - _thread_index, - get_label_collector(i), true); + _thread_index, + get_label_collector(i), true); } _labels_changed = false; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::draw_guide_bar -// Access: Private -// Description: Draws the line for the indicated guide bar on the -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the line for the indicated guide bar on the graph. + */ void GtkStatsPianoRoll:: draw_guide_bar(GdkDrawable *surface, const PStatGraph::GuideBar &bar) { int x = height_to_pixel(bar._height); @@ -446,7 +393,7 @@ draw_guide_bar(GdkDrawable *surface, const PStatGraph::GuideBar &bar) { case GBS_user: gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_user_guide_bar); break; - + case GBS_normal: gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_dark_gray); break; @@ -455,11 +402,9 @@ draw_guide_bar(GdkDrawable *surface, const PStatGraph::GuideBar &bar) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::draw_guide_labels -// Access: Private -// Description: This is called during the servicing of expose_event. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of expose_event. + */ void GtkStatsPianoRoll:: draw_guide_labels() { int i; @@ -474,12 +419,9 @@ draw_guide_labels() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::draw_guide_label -// Access: Private -// Description: Draws the text for the indicated guide bar label at -// the top of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the text for the indicated guide bar label at the top of the graph. + */ void GtkStatsPianoRoll:: draw_guide_label(const PStatGraph::GuideBar &bar) { GdkGC *gc = gdk_gc_new(_scale_area->window); @@ -488,11 +430,11 @@ draw_guide_label(const PStatGraph::GuideBar &bar) { case GBS_target: gdk_gc_set_rgb_fg_color(gc, &rgb_light_gray); break; - + case GBS_user: gdk_gc_set_rgb_fg_color(gc, &rgb_user_guide_bar); break; - + case GBS_normal: gdk_gc_set_rgb_fg_color(gc, &rgb_dark_gray); break; @@ -519,26 +461,24 @@ draw_guide_label(const PStatGraph::GuideBar &bar) { if (x >= 0 && x < get_xsize()) { // Now convert our x to a coordinate within our drawing area. int junk_y; - + // The x coordinate comes from the graph_window. gtk_widget_translate_coordinates(_graph_window, _scale_area, - x, 0, - &x, &junk_y); - + x, 0, + &x, &junk_y); + int this_x = x - width / 2; - gdk_draw_layout(_scale_area->window, gc, this_x, - _scale_area->allocation.height - height, layout); + gdk_draw_layout(_scale_area->window, gc, this_x, + _scale_area->allocation.height - height, layout); } - + g_object_unref(layout); g_object_unref(gc); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsPianoRoll::expose_event_callback -// Access: Private, Static -// Description: Draws in the scale labels. -//////////////////////////////////////////////////////////////////// +/** + * Draws in the scale labels. + */ gboolean GtkStatsPianoRoll:: expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsPianoRoll *self = (GtkStatsPianoRoll *)data; diff --git a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h index a15369ad8f..cf54e75c66 100644 --- a/pandatool/src/gtk-stats/gtkStatsPianoRoll.h +++ b/pandatool/src/gtk-stats/gtkStatsPianoRoll.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsPianoRoll.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsPianoRoll.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSPIANOROLL_H #define GTKSTATSPIANOROLL_H @@ -25,12 +24,10 @@ class GtkStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsPianoRoll -// Description : A window that draws a piano-roll style chart, -// which shows the collectors explicitly stopping and -// starting, one frame at a time. -//////////////////////////////////////////////////////////////////// +/** + * A window that draws a piano-roll style chart, which shows the collectors + * explicitly stopping and starting, one frame at a time. + */ class GtkStatsPianoRoll : public PStatPianoRoll, public GtkStatsGraph { public: GtkStatsPianoRoll(GtkStatsMonitor *monitor, int thread_index); @@ -55,7 +52,7 @@ protected: virtual DragMode consider_drag_start(int graph_x, int graph_y); virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click); + bool double_click); virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y); virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y); @@ -66,9 +63,8 @@ private: void draw_guide_labels(); void draw_guide_label(const PStatGraph::GuideBar &bar); - static gboolean expose_event_callback(GtkWidget *widget, - GdkEventExpose *event, gpointer data); + static gboolean expose_event_callback(GtkWidget *widget, + GdkEventExpose *event, gpointer data); }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsServer.cxx b/pandatool/src/gtk-stats/gtkStatsServer.cxx index 457a3f3fb9..3b78af2dde 100644 --- a/pandatool/src/gtk-stats/gtkStatsServer.cxx +++ b/pandatool/src/gtk-stats/gtkStatsServer.cxx @@ -1,25 +1,22 @@ -// Filename: gtkStatsServer.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsServer.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsServer.h" #include "gtkStatsMonitor.h" -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsServer::make_monitor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatMonitor *GtkStatsServer:: make_monitor() { return new GtkStatsMonitor(this); diff --git a/pandatool/src/gtk-stats/gtkStatsServer.h b/pandatool/src/gtk-stats/gtkStatsServer.h index 0b722726aa..89bb025c4e 100644 --- a/pandatool/src/gtk-stats/gtkStatsServer.h +++ b/pandatool/src/gtk-stats/gtkStatsServer.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsServer.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsServer.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSSERVER_H #define GTKSTATSSERVER_H @@ -18,15 +17,12 @@ #include "pandatoolbase.h" #include "pStatServer.h" -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsServer -// Description : The class that owns the main loop, waiting for client -// connections. -//////////////////////////////////////////////////////////////////// +/** + * The class that owns the main loop, waiting for client connections. + */ class GtkStatsServer : public PStatServer { public: virtual PStatMonitor *make_monitor(); }; #endif - diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx index cc029039a9..8370cd958b 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.cxx +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.cxx @@ -1,16 +1,15 @@ -// Filename: gtkStatsStripChart.cxx -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsStripChart.cxx + * @author drose + * @date 2006-01-16 + */ #include "gtkStatsStripChart.h" #include "gtkStatsMonitor.h" @@ -20,18 +19,16 @@ static const int default_strip_chart_width = 400; static const int default_strip_chart_height = 100; -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsStripChart:: GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index, int collector_index, bool show_level) : - PStatStripChart(monitor, - show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index), + PStatStripChart(monitor, + show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index), thread_index, - collector_index, + collector_index, default_strip_chart_width, default_strip_chart_height), GtkStatsGraph(monitor) @@ -47,78 +44,70 @@ GtkStatsStripChart(GtkStatsMonitor *monitor, int thread_index, } } else { - // If it's a time-type graph, show the ms/Hz units. + // If it's a time-type graph, show the msHz units. set_guide_bar_units(get_guide_bar_units() | GBU_show_units); } // Put some stuff on top of the graph. _top_hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(_graph_vbox), _top_hbox, - FALSE, FALSE, 0); + FALSE, FALSE, 0); _smooth_check_box = gtk_check_button_new_with_label("Smooth"); - g_signal_connect(G_OBJECT(_smooth_check_box), "toggled", - G_CALLBACK(toggled_callback), this); + g_signal_connect(G_OBJECT(_smooth_check_box), "toggled", + G_CALLBACK(toggled_callback), this); _total_label = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(_top_hbox), _smooth_check_box, - FALSE, FALSE, 0); + FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(_top_hbox), _total_label, - FALSE, FALSE, 0); + FALSE, FALSE, 0); - // Add a DrawingArea widget to the right of the graph, to display - // all of the scale units. + // Add a DrawingArea widget to the right of the graph, to display all of the + // scale units. _scale_area = gtk_drawing_area_new(); - g_signal_connect(G_OBJECT(_scale_area), "expose_event", - G_CALLBACK(expose_event_callback), this); + g_signal_connect(G_OBJECT(_scale_area), "expose_event", + G_CALLBACK(expose_event_callback), this); gtk_box_pack_start(GTK_BOX(_graph_hbox), _scale_area, - FALSE, FALSE, 0); + FALSE, FALSE, 0); gtk_widget_set_size_request(_scale_area, 40, 0); gtk_widget_set_size_request(_graph_window, default_strip_chart_width, - default_strip_chart_height); + default_strip_chart_height); - gtk_widget_show_all(_window); + gtk_widget_show_all(_window); gtk_widget_show(_window); - // Allow the window to be resized as small as the user likes. We - // have to do this after the window has been shown; otherwise, it - // will affect the window's initial size. + // Allow the window to be resized as small as the user likes. We have to do + // this after the window has been shown; otherwise, it will affect the + // window's initial size. gtk_widget_set_size_request(_window, 0, 0); clear_region(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ GtkStatsStripChart:: ~GtkStatsStripChart() { } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + */ void GtkStatsStripChart:: new_collector(int collector_index) { GtkStatsGraph::new_collector(collector_index); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no gurantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no gurantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void GtkStatsStripChart:: new_data(int thread_index, int frame_number) { if (is_title_unknown()) { @@ -139,35 +128,27 @@ new_data(int thread_index, int frame_number) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void GtkStatsStripChart:: force_redraw() { PStatStripChart::force_redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void GtkStatsStripChart:: changed_graph_size(int graph_xsize, int graph_ysize) { PStatStripChart::changed_size(graph_xsize, graph_ysize); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void GtkStatsStripChart:: set_time_units(int unit_mask) { int old_unit_mask = get_guide_bar_units(); @@ -180,13 +161,10 @@ set_time_units(int unit_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speed for the graph to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speed for the graph to the indicated value. + */ void GtkStatsStripChart:: set_scroll_speed(double scroll_speed) { // The speed factor indicates chart widths per minute. @@ -195,22 +173,20 @@ set_scroll_speed(double scroll_speed) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void GtkStatsStripChart:: clicked_label(int collector_index) { if (collector_index < 0) { - // Clicking on whitespace in the graph is the same as clicking on - // the top label. + // Clicking on whitespace in the graph is the same as clicking on the top + // label. collector_index = get_collector_index(); } if (collector_index == get_collector_index() && collector_index != 0) { // Clicking on the top label means to go up to the parent level. - const PStatClientData *client_data = + const PStatClientData *client_data = GtkStatsGraph::_monitor->get_client_data(); if (client_data->has_collector(collector_index)) { const PStatCollectorDef &def = @@ -228,12 +204,10 @@ clicked_label(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::set_vertical_scale -// Access: Public -// Description: Changes the value the height of the vertical axis -// represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value the height of the vertical axis represents. This may + * force a redraw. + */ void GtkStatsStripChart:: set_vertical_scale(double value_height) { PStatStripChart::set_vertical_scale(value_height); @@ -242,11 +216,9 @@ set_vertical_scale(double value_height) { gtk_widget_queue_draw(_scale_area); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::update_labels -// Access: Protected, Virtual -// Description: Resets the list of labels. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of labels. + */ void GtkStatsStripChart:: update_labels() { PStatStripChart::update_labels(); @@ -259,55 +231,46 @@ update_labels() { _labels_changed = false; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::clear_region -// Access: Protected, Virtual -// Description: Erases the chart area. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area. + */ void GtkStatsStripChart:: clear_region() { gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white); - gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, - get_xsize(), get_ysize()); + gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, 0, 0, + get_xsize(), get_ysize()); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::copy_region -// Access: Protected, Virtual -// Description: Should be overridden by the user class to copy a -// region of the chart from one part of the chart to -// another. This is used to implement scrolling. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to copy a region of the chart from + * one part of the chart to another. This is used to implement scrolling. + */ void GtkStatsStripChart:: copy_region(int start_x, int end_x, int dest_x) { gdk_draw_drawable(_pixmap, _pixmap_gc, _pixmap, - start_x, 0, dest_x, 0, - end_x - start_x, get_ysize()); - - // Also shift the brush origin over, so we still get proper - // dithering. + start_x, 0, dest_x, 0, + end_x - start_x, get_ysize()); + + // Also shift the brush origin over, so we still get proper dithering. _brush_origin += (dest_x - start_x); - // SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL); + // SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL); GdkRectangle rect = { - dest_x, 0, end_x - start_x, get_ysize() + dest_x, 0, end_x - start_x, get_ysize() }; gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_slice -// Access: Protected, Virtual -// Description: Draws a single vertical slice of the strip chart, at -// the given pixel position, and corresponding to the -// indicated level data. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of the strip chart, at the given pixel + * position, and corresponding to the indicated level data. + */ void GtkStatsStripChart:: draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { // Start by clearing the band first. gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white); - gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0, - w + 1, get_ysize()); + gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0, + w + 1, get_ysize()); double overall_time = 0.0; int y = get_ysize(); @@ -319,8 +282,8 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { GdkGC *gc = get_collector_gc(cd._collector_index); if (overall_time > get_vertical_scale()) { - // Off the top. Go ahead and clamp it by hand, in case it's so - // far off the top we'd overflow the 16-bit pixel value. + // Off the top. Go ahead and clamp it by hand, in case it's so far off + // the top we'd overflow the 16-bit pixel value. gdk_draw_rectangle(_pixmap, gc, TRUE, x, 0, w, y); // And we can consider ourselves done now. return; @@ -332,37 +295,30 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_empty -// Access: Protected, Virtual -// Description: Draws a single vertical slice of background color. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of background color. + */ void GtkStatsStripChart:: draw_empty(int x, int w) { gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_white); - gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0, - w + 1, get_ysize()); + gdk_draw_rectangle(_pixmap, _pixmap_gc, TRUE, x, 0, + w + 1, get_ysize()); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_cursor -// Access: Protected, Virtual -// Description: Draws a single vertical slice of foreground color. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of foreground color. + */ void GtkStatsStripChart:: draw_cursor(int x) { gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_black); gdk_draw_line(_pixmap, _pixmap_gc, x, 0, x, get_ysize()); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::end_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called after drawing a series of color bars -// in the strip chart; it gives the pixel range that -// was just redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called after + * drawing a series of color bars in the strip chart; it gives the pixel range + * that was just redrawn. + */ void GtkStatsStripChart:: end_draw(int from_x, int to_x) { // Draw in the guide bars. @@ -372,18 +328,15 @@ end_draw(int from_x, int to_x) { } GdkRectangle rect = { - from_x, 0, to_x - from_x + 1, get_ysize() + from_x, 0, to_x - from_x + 1, get_ysize() }; gdk_window_invalidate_rect(_graph_window->window, &rect, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of expose_event; -// it gives a derived class opportunity to do some -// further painting into the graph window. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of expose_event; it gives a derived + * class opportunity to do some further painting into the graph window. + */ void GtkStatsStripChart:: additional_graph_window_paint() { int num_user_guide_bars = get_num_user_guide_bars(); @@ -392,14 +345,11 @@ additional_graph_window_paint() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the graph window, -// look for draggable things the mouse might be hovering -// over and return the appropriate DragMode enum or -// DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the graph window, look for draggable + * things the mouse might be hovering over and return the appropriate DragMode + * enum or DM_none if nothing is indicated. + */ GtkStatsGraph::DragMode GtkStatsStripChart:: consider_drag_start(int graph_x, int graph_y) { if (graph_x >= 0 && graph_x < get_xsize()) { @@ -414,8 +364,7 @@ consider_drag_start(int graph_x, int graph_y) { } } else { - // The mouse is above or below the graph; maybe create a new - // guide bar. + // The mouse is above or below the graph; maybe create a new guide bar. return DM_new_guide_bar; } } @@ -423,13 +372,10 @@ consider_drag_start(int graph_x, int graph_y) { return GtkStatsGraph::consider_drag_start(graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::set_drag_mode -// Access: Protected, Virtual -// Description: This should be called whenever the drag mode needs to -// change state. It provides hooks for a derived class -// to do something special. -//////////////////////////////////////////////////////////////////// +/** + * This should be called whenever the drag mode needs to change state. It + * provides hooks for a derived class to do something special. + */ void GtkStatsStripChart:: set_drag_mode(GtkStatsGraph::DragMode drag_mode) { GtkStatsGraph::set_drag_mode(drag_mode); @@ -442,27 +388,23 @@ set_drag_mode(GtkStatsGraph::DragMode drag_mode) { break; default: - // Restore smoothing according to the current setting of the check - // box. - bool active = + // Restore smoothing according to the current setting of the check box. + bool active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_smooth_check_box)); set_average_mode(active); break; } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::handle_button_press -// Access: Protected, Virtual -// Description: Called when the mouse button is depressed within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is depressed within the graph window. + */ gboolean GtkStatsStripChart:: handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click) { + bool double_click) { if (double_click) { - // Double-clicking on a color bar in the graph is the same as - // double-clicking on the corresponding label. + // Double-clicking on a color bar in the graph is the same as double- + // clicking on the corresponding label. clicked_label(get_collector_under_pixel(graph_x, graph_y)); return TRUE; } @@ -470,33 +412,30 @@ handle_button_press(GtkWidget *widget, int graph_x, int graph_y, if (_potential_drag_mode == DM_none) { set_drag_mode(DM_scale); _drag_scale_start = pixel_to_height(graph_y); - //SetCapture(_graph_window); + // SetCapture(_graph_window); return TRUE; } else if (_potential_drag_mode == DM_guide_bar && _drag_guide_bar >= 0) { set_drag_mode(DM_guide_bar); _drag_start_y = graph_y; - //SetCapture(_graph_window); + // SetCapture(_graph_window); return TRUE; } - return GtkStatsGraph::handle_button_press(widget, graph_x, graph_y, - double_click); + return GtkStatsGraph::handle_button_press(widget, graph_x, graph_y, + double_click); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::handle_button_release -// Access: Protected, Virtual -// Description: Called when the mouse button is released within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse button is released within the graph window. + */ gboolean GtkStatsStripChart:: handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { if (_drag_mode == DM_scale) { set_drag_mode(DM_none); - //ReleaseCapture(); + // ReleaseCapture(); return handle_motion(widget, graph_x, graph_y); - + } else if (_drag_mode == DM_guide_bar) { if (graph_y < 0 || graph_y >= get_ysize()) { remove_user_guide_bar(_drag_guide_bar); @@ -504,19 +443,16 @@ handle_button_release(GtkWidget *widget, int graph_x, int graph_y) { move_user_guide_bar(_drag_guide_bar, pixel_to_height(graph_y)); } set_drag_mode(DM_none); - //ReleaseCapture(); + // ReleaseCapture(); return handle_motion(widget, graph_x, graph_y); } return GtkStatsGraph::handle_button_release(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::ns_motion_notify_event_callback -// Access: Protected, Virtual -// Description: Called when the mouse is moved within the -// graph window. -//////////////////////////////////////////////////////////////////// +/** + * Called when the mouse is moved within the graph window. + */ gboolean GtkStatsStripChart:: handle_motion(GtkWidget *widget, int graph_x, int graph_y) { if (_drag_mode == DM_none && _potential_drag_mode == DM_none) { @@ -524,8 +460,8 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { _label_stack.highlight_label(get_collector_under_pixel(graph_x, graph_y)); /* - // Now we want to get a WM_MOUSELEAVE when the mouse leaves the - // graph window. + // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph + // window. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, @@ -548,8 +484,8 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { return TRUE; } else if (_drag_mode == DM_new_guide_bar) { - // We haven't created the new guide bar yet; we won't until the - // mouse comes within the graph's region. + // We haven't created the new guide bar yet; we won't until the mouse + // comes within the graph's region. if (graph_y >= 0 && graph_y < get_ysize()) { set_drag_mode(DM_guide_bar); _drag_guide_bar = add_user_guide_bar(pixel_to_height(graph_y)); @@ -564,14 +500,11 @@ handle_motion(GtkWidget *widget, int graph_x, int graph_y) { return GtkStatsGraph::handle_motion(widget, graph_x, graph_y); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_guide_bar -// Access: Private -// Description: Draws the line for the indicated guide bar on the -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the line for the indicated guide bar on the graph. + */ void GtkStatsStripChart:: -draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, +draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, const PStatGraph::GuideBar &bar) { int y = height_to_pixel(bar._height); @@ -585,7 +518,7 @@ draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, case GBS_user: gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_user_guide_bar); break; - + case GBS_normal: gdk_gc_set_rgb_fg_color(_pixmap_gc, &rgb_dark_gray); break; @@ -594,11 +527,9 @@ draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_guide_labels -// Access: Private -// Description: This is called during the servicing of expose_event. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of expose_event. + */ void GtkStatsStripChart:: draw_guide_labels() { // Draw in the labels for the guide bars. @@ -620,14 +551,11 @@ draw_guide_labels() { } } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::draw_guide_label -// Access: Private -// Description: Draws the text for the indicated guide bar label to -// the right of the graph, unless it would overlap with -// the indicated last label, whose top pixel value is -// given. Returns the top pixel value of the new label. -//////////////////////////////////////////////////////////////////// +/** + * Draws the text for the indicated guide bar label to the right of the graph, + * unless it would overlap with the indicated last label, whose top pixel + * value is given. Returns the top pixel value of the new label. + */ int GtkStatsStripChart:: draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { GdkGC *gc = gdk_gc_new(_scale_area->window); @@ -636,11 +564,11 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { case GBS_target: gdk_gc_set_rgb_fg_color(gc, &rgb_light_gray); break; - + case GBS_user: gdk_gc_set_rgb_fg_color(gc, &rgb_user_guide_bar); break; - + case GBS_normal: gdk_gc_set_rgb_fg_color(gc, &rgb_dark_gray); break; @@ -667,29 +595,27 @@ draw_guide_label(const PStatGraph::GuideBar &bar, int last_y) { if (y >= 0 && y < get_ysize()) { // Now convert our y to a coordinate within our drawing area. int junk_x; - + // The y coordinate comes from the graph_window. gtk_widget_translate_coordinates(_graph_window, _scale_area, - 0, y, - &junk_x, &y); - + 0, y, + &junk_x, &y); + int this_y = y - height / 2; if (last_y < this_y || last_y > this_y + height) { gdk_draw_layout(_scale_area->window, gc, 0, this_y, layout); last_y = this_y; } } - + g_object_unref(layout); g_object_unref(gc); return last_y; } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::toggled_callback -// Access: Private, Static -// Description: Called when the smooth check box is toggled. -//////////////////////////////////////////////////////////////////// +/** + * Called when the smooth check box is toggled. + */ void GtkStatsStripChart:: toggled_callback(GtkToggleButton *button, gpointer data) { GtkStatsStripChart *self = (GtkStatsStripChart *)data; @@ -698,11 +624,9 @@ toggled_callback(GtkToggleButton *button, gpointer data) { self->set_average_mode(active); } -//////////////////////////////////////////////////////////////////// -// Function: GtkStatsStripChart::expose_event_callback -// Access: Private, Static -// Description: Draws in the scale labels. -//////////////////////////////////////////////////////////////////// +/** + * Draws in the scale labels. + */ gboolean GtkStatsStripChart:: expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data) { GtkStatsStripChart *self = (GtkStatsStripChart *)data; diff --git a/pandatool/src/gtk-stats/gtkStatsStripChart.h b/pandatool/src/gtk-stats/gtkStatsStripChart.h index 4b476bb2f3..65bd50b598 100644 --- a/pandatool/src/gtk-stats/gtkStatsStripChart.h +++ b/pandatool/src/gtk-stats/gtkStatsStripChart.h @@ -1,16 +1,15 @@ -// Filename: gtkStatsStripChart.h -// Created by: drose (16Jan06) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file gtkStatsStripChart.h + * @author drose + * @date 2006-01-16 + */ #ifndef GTKSTATSSTRIPCHART_H #define GTKSTATSSTRIPCHART_H @@ -25,10 +24,9 @@ class GtkStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : GtkStatsStripChart -// Description : A window that draws a strip chart, given a view. -//////////////////////////////////////////////////////////////////// +/** + * A window that draws a strip chart, given a view. + */ class GtkStatsStripChart : public PStatStripChart, public GtkStatsGraph { public: GtkStatsStripChart(GtkStatsMonitor *monitor, @@ -50,7 +48,7 @@ protected: virtual void clear_region(); virtual void copy_region(int start_x, int end_x, int dest_x); - virtual void draw_slice(int x, int w, + virtual void draw_slice(int x, int w, const PStatStripChart::FrameData &fdata); virtual void draw_empty(int x, int w); virtual void draw_cursor(int x); @@ -61,19 +59,19 @@ protected: virtual void set_drag_mode(DragMode drag_mode); virtual gboolean handle_button_press(GtkWidget *widget, int graph_x, int graph_y, - bool double_click); + bool double_click); virtual gboolean handle_button_release(GtkWidget *widget, int graph_x, int graph_y); virtual gboolean handle_motion(GtkWidget *widget, int graph_x, int graph_y); private: - void draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, - const PStatGraph::GuideBar &bar); + void draw_guide_bar(GdkDrawable *surface, int from_x, int to_x, + const PStatGraph::GuideBar &bar); void draw_guide_labels(); int draw_guide_label(const PStatGraph::GuideBar &bar, int last_y); - static void toggled_callback(GtkToggleButton *button, gpointer data); - static gboolean expose_event_callback(GtkWidget *widget, - GdkEventExpose *event, gpointer data); + static void toggled_callback(GtkToggleButton *button, gpointer data); + static gboolean expose_event_callback(GtkWidget *widget, + GdkEventExpose *event, gpointer data); private: int _brush_origin; @@ -85,4 +83,3 @@ private: }; #endif - diff --git a/pandatool/src/imagebase/imageBase.cxx b/pandatool/src/imagebase/imageBase.cxx index 0a0ca69b6a..837f0bdf46 100644 --- a/pandatool/src/imagebase/imageBase.cxx +++ b/pandatool/src/imagebase/imageBase.cxx @@ -1,36 +1,30 @@ -// Filename: imageBase.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageBase.cxx + * @author drose + * @date 2000-06-19 + */ #include "imageBase.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageBase:: ImageBase() { } -//////////////////////////////////////////////////////////////////// -// Function: ImageBase::post_command_line -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ImageBase:: post_command_line() { return ProgramBase::post_command_line(); } - diff --git a/pandatool/src/imagebase/imageBase.h b/pandatool/src/imagebase/imageBase.h index cee0b04ebf..5b106c8cb0 100644 --- a/pandatool/src/imagebase/imageBase.h +++ b/pandatool/src/imagebase/imageBase.h @@ -1,16 +1,15 @@ -// Filename: imageBase.h -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageBase.h + * @author drose + * @date 2000-06-19 + */ #ifndef IMAGEBASE_H #define IMAGEBASE_H @@ -21,16 +20,14 @@ #include "coordinateSystem.h" #include "pnmImage.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageBase -// Description : This specialization of ProgramBase is intended for -// programs that read and/or write a single image file. -// (See ImageMultiBase for programs that operate on -// multiple image files at once.) -// -// This is just a base class; see ImageReader, ImageWriter, -// or ImageFilter according to your particular I/O needs. -//////////////////////////////////////////////////////////////////// +/** + * This specialization of ProgramBase is intended for programs that read + * and/or write a single image file. (See ImageMultiBase for programs that + * operate on multiple image files at once.) + * + * This is just a base class; see ImageReader, ImageWriter, or ImageFilter + * according to your particular I/O needs. + */ class ImageBase : public ProgramBase { public: ImageBase(); @@ -43,5 +40,3 @@ protected: }; #endif - - diff --git a/pandatool/src/imagebase/imageFilter.cxx b/pandatool/src/imagebase/imageFilter.cxx index 8e917b3579..63957ed519 100644 --- a/pandatool/src/imagebase/imageFilter.cxx +++ b/pandatool/src/imagebase/imageFilter.cxx @@ -1,24 +1,21 @@ -// Filename: imageFilter.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFilter.cxx + * @author drose + * @date 2000-06-19 + */ #include "imageFilter.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageFilter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageFilter:: ImageFilter(bool allow_last_param) : ImageWriter(allow_last_param) @@ -30,14 +27,11 @@ ImageFilter(bool allow_last_param) : add_runline("[opts] -o outputimage inputimage"); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFilter::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool ImageFilter:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { diff --git a/pandatool/src/imagebase/imageFilter.h b/pandatool/src/imagebase/imageFilter.h index 9c4256cca7..ae53da53c0 100644 --- a/pandatool/src/imagebase/imageFilter.h +++ b/pandatool/src/imagebase/imageFilter.h @@ -1,16 +1,15 @@ -// Filename: imageFilter.h -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFilter.h + * @author drose + * @date 2000-06-19 + */ #ifndef IMAGEFILTER_H #define IMAGEFILTER_H @@ -20,12 +19,10 @@ #include "imageReader.h" #include "imageWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageFilter -// Description : This is the base class for a program that reads an -// image file, operates on it, and writes another image -// file out. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that reads an image file, operates on + * it, and writes another image file out. + */ class ImageFilter : public ImageReader, public ImageWriter { public: ImageFilter(bool allow_last_param); @@ -35,5 +32,3 @@ protected: }; #endif - - diff --git a/pandatool/src/imagebase/imageReader.cxx b/pandatool/src/imagebase/imageReader.cxx index 4815dc95b8..4e4e6690b5 100644 --- a/pandatool/src/imagebase/imageReader.cxx +++ b/pandatool/src/imagebase/imageReader.cxx @@ -1,35 +1,30 @@ -// Filename: imageReader.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageReader.cxx + * @author drose + * @date 2000-06-19 + */ #include "imageReader.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageReader:: ImageReader() { clear_runlines(); add_runline("[opts] imagename"); } -//////////////////////////////////////////////////////////////////// -// Function: ImageReader::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ImageReader:: handle_args(ProgramBase::Args &args) { if (args.empty()) { diff --git a/pandatool/src/imagebase/imageReader.h b/pandatool/src/imagebase/imageReader.h index e2fd2e308f..c3c8185647 100644 --- a/pandatool/src/imagebase/imageReader.h +++ b/pandatool/src/imagebase/imageReader.h @@ -1,16 +1,15 @@ -// Filename: imageReader.h -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageReader.h + * @author drose + * @date 2000-06-19 + */ #ifndef IMAGEREADER_H #define IMAGEREADER_H @@ -19,11 +18,10 @@ #include "imageBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageReader -// Description : This is the base class for a program that reads an -// image file, but doesn't write an image file. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that reads an image file, but doesn't + * write an image file. + */ class ImageReader : virtual public ImageBase { public: ImageReader(); @@ -34,5 +32,3 @@ protected: }; #endif - - diff --git a/pandatool/src/imagebase/imageWriter.I b/pandatool/src/imagebase/imageWriter.I index 19a055ebc2..b8400819d1 100644 --- a/pandatool/src/imagebase/imageWriter.I +++ b/pandatool/src/imagebase/imageWriter.I @@ -1,24 +1,19 @@ -// Filename: imageWriter.I -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageWriter.I + * @author drose + * @date 2000-06-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ImageWriter::write_image -// Access: Public -// Description: Writes the generated to the user's specified output -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Writes the generated to the user's specified output filename. + */ INLINE void ImageWriter:: write_image() { write_image(_image); diff --git a/pandatool/src/imagebase/imageWriter.cxx b/pandatool/src/imagebase/imageWriter.cxx index 460a0bdad0..3a4bfc1d56 100644 --- a/pandatool/src/imagebase/imageWriter.cxx +++ b/pandatool/src/imagebase/imageWriter.cxx @@ -1,25 +1,21 @@ -// Filename: imageWriter.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageWriter.cxx + * @author drose + * @date 2000-06-19 + */ #include "imageWriter.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageWriter::Constructor -// Access: Public -// Description: Image-writing type programs *must* specify their -// output file using -o. -//////////////////////////////////////////////////////////////////// +/** + * Image-writing type programs *must* specify their output file using -o. + */ ImageWriter:: ImageWriter(bool allow_last_param) : WithOutputFile(allow_last_param, false, true) @@ -47,29 +43,23 @@ ImageWriter(bool allow_last_param) : } -//////////////////////////////////////////////////////////////////// -// Function: ImageWriter::write_image -// Access: Public -// Description: Writes the generated to the user's specified output -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Writes the generated to the user's specified output filename. + */ void ImageWriter:: write_image(const PNMImage &image) { if (!image.write(get_output_filename())) { - nout << "Unable to write output image to " + nout << "Unable to write output image to " << get_output_filename() << "\n"; exit(1); } } -//////////////////////////////////////////////////////////////////// -// Function: ImageWriter::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool ImageWriter:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 0)) { diff --git a/pandatool/src/imagebase/imageWriter.h b/pandatool/src/imagebase/imageWriter.h index 0cd455cea4..f902af29d1 100644 --- a/pandatool/src/imagebase/imageWriter.h +++ b/pandatool/src/imagebase/imageWriter.h @@ -1,16 +1,15 @@ -// Filename: imageWriter.h -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageWriter.h + * @author drose + * @date 2000-06-19 + */ #ifndef IMAGEWRITER_H #define IMAGEWRITER_H @@ -21,11 +20,10 @@ #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageWriter -// Description : This is the base class for a program that generates -// an image file output, but doesn't read any for input. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class for a program that generates an image file output, + * but doesn't read any for input. + */ class ImageWriter : virtual public ImageBase, public WithOutputFile { public: ImageWriter(bool allow_last_param); @@ -40,5 +38,3 @@ protected: #include "imageWriter.I" #endif - - diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.I b/pandatool/src/imageprogs/imageFixHiddenColor.I index 0efbb8d83e..8c41f570b5 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.I +++ b/pandatool/src/imageprogs/imageFixHiddenColor.I @@ -1,14 +1,12 @@ -// Filename: imageFixHiddenColor.I -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFixHiddenColor.I + * @author drose + * @date 2003-03-13 + */ diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.cxx b/pandatool/src/imageprogs/imageFixHiddenColor.cxx index bd291e9e57..46ff3e5636 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.cxx +++ b/pandatool/src/imageprogs/imageFixHiddenColor.cxx @@ -1,26 +1,23 @@ -// Filename: imageFixHiddenColor.cxx -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFixHiddenColor.cxx + * @author drose + * @date 2003-03-13 + */ #include "imageFixHiddenColor.h" #include "string_utils.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageFixHiddenColor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageFixHiddenColor:: ImageFixHiddenColor() : ImageFilter(true) { set_program_brief("change the color of transparent pixels in an image"); @@ -63,18 +60,15 @@ ImageFixHiddenColor() : ImageFilter(true) { _max_transparent_alpha = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFixHiddenColor::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ImageFixHiddenColor:: run() { PNMImage alpha_image; if (_alpha_filename.empty()) { - // No separate alpha file is provided; use the base file's alpha - // channel. + // No separate alpha file is provided; use the base file's alpha channel. if (!_image.has_alpha()) { nout << "Image does not have an alpha channel.\n"; exit(1); @@ -89,8 +83,8 @@ run() { } if (!alpha_image.has_alpha()) { - // Copy the grayscale value to the alpha channel for the benefit - // of the code below. + // Copy the grayscale value to the alpha channel for the benefit of the + // code below. alpha_image.add_alpha(); int xi, yi; for (yi = 0; yi < alpha_image.get_y_size(); ++yi) { diff --git a/pandatool/src/imageprogs/imageFixHiddenColor.h b/pandatool/src/imageprogs/imageFixHiddenColor.h index 242ebf1541..eb272eb025 100644 --- a/pandatool/src/imageprogs/imageFixHiddenColor.h +++ b/pandatool/src/imageprogs/imageFixHiddenColor.h @@ -1,16 +1,15 @@ -// Filename: imageFixHiddenColor.h -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFixHiddenColor.h + * @author drose + * @date 2003-03-13 + */ #ifndef IMAGEFIXHIDDENCOLOR_H #define IMAGEFIXHIDDENCOLOR_H @@ -19,11 +18,9 @@ #include "imageFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageFixHiddenColor -// Description : This program repairs an image's RGB values hidden -// behind an A value of 0. -//////////////////////////////////////////////////////////////////// +/** + * This program repairs an image's RGB values hidden behind an A value of 0. + */ class ImageFixHiddenColor : public ImageFilter { public: ImageFixHiddenColor(); @@ -39,4 +36,3 @@ private: #include "imageFixHiddenColor.I" #endif - diff --git a/pandatool/src/imageprogs/imageInfo.cxx b/pandatool/src/imageprogs/imageInfo.cxx index ea2954315b..d445e028ee 100644 --- a/pandatool/src/imageprogs/imageInfo.cxx +++ b/pandatool/src/imageprogs/imageInfo.cxx @@ -1,26 +1,23 @@ -// Filename: imageInfo.cxx -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageInfo.cxx + * @author drose + * @date 2003-03-13 + */ #include "imageInfo.h" #include "pnmImageHeader.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageInfo::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageInfo:: ImageInfo() { set_program_brief("report the size of image files"); @@ -36,11 +33,9 @@ ImageInfo() { &ImageInfo::dispatch_none, &_report_power_2, NULL); } -//////////////////////////////////////////////////////////////////// -// Function: ImageInfo::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ImageInfo:: run() { Args::const_iterator ai; @@ -56,7 +51,7 @@ run() { } } else { // Successfully read the image header. - if (!_report_power_2 || + if (!_report_power_2 || !is_power_2(header.get_x_size()) || !is_power_2(header.get_y_size())) { nout << filename << ": " << header.get_x_size() << " x " @@ -67,14 +62,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: ImageInfo::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool ImageInfo:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -86,12 +78,9 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageInfo::is_power_2 -// Access: Private -// Description: Returns true if the indicated value is a power of 2, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated value is a power of 2, false otherwise. + */ bool ImageInfo:: is_power_2(int value) const { return (value & (value - 1)) == 0; diff --git a/pandatool/src/imageprogs/imageInfo.h b/pandatool/src/imageprogs/imageInfo.h index 4765b08f29..4a6e2e9ee1 100644 --- a/pandatool/src/imageprogs/imageInfo.h +++ b/pandatool/src/imageprogs/imageInfo.h @@ -1,16 +1,15 @@ -// Filename: imageInfo.h -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageInfo.h + * @author drose + * @date 2003-03-13 + */ #ifndef IMAGEINFO_H #define IMAGEINFO_H @@ -19,12 +18,10 @@ #include "programBase.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageInfo -// Description : This program reads the headers of a series of one or -// more images and reports their sizes to standard -// output. -//////////////////////////////////////////////////////////////////// +/** + * This program reads the headers of a series of one or more images and + * reports their sizes to standard output. + */ class ImageInfo : public ProgramBase { public: ImageInfo(); @@ -42,4 +39,3 @@ private: }; #endif - diff --git a/pandatool/src/imageprogs/imageResize.I b/pandatool/src/imageprogs/imageResize.I index 5136943f64..25dd5f875e 100644 --- a/pandatool/src/imageprogs/imageResize.I +++ b/pandatool/src/imageprogs/imageResize.I @@ -1,70 +1,56 @@ -// Filename: imageResize.I -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageResize.I + * @author drose + * @date 2003-03-13 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ImageResize::SizeRequest:: SizeRequest() { _type = RT_none; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::get_type -// Access: Public -// Description: Returns the type of the size request, or RT_none if -// the request has not been specified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the type of the size request, or RT_none if the request has not + * been specified. + */ INLINE ImageResize::RequestType ImageResize::SizeRequest:: get_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::set_pixel_size -// Access: Public -// Description: Sets the size request to store an explicit pixel -// size. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size request to store an explicit pixel size. + */ INLINE void ImageResize::SizeRequest:: set_pixel_size(int pixel_size) { _type = RT_pixel_size; _e._pixel_size = pixel_size; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::get_pixel_size -// Access: Public -// Description: Returns the explicit pixel size stored within the -// size request. -//////////////////////////////////////////////////////////////////// +/** + * Returns the explicit pixel size stored within the size request. + */ INLINE int ImageResize::SizeRequest:: get_pixel_size() const { nassertr(_type == RT_pixel_size, 0); return _e._pixel_size; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::get_pixel_size -// Access: Public -// Description: Returns the explicit pixel size stored within the -// size request, or if a ratio has been stored, returns -// the computed pixel size based on the original size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the explicit pixel size stored within the size request, or if a + * ratio has been stored, returns the computed pixel size based on the + * original size. + */ INLINE int ImageResize::SizeRequest:: get_pixel_size(int orig_pixel_size) const { switch (_type) { @@ -77,37 +63,29 @@ get_pixel_size(int orig_pixel_size) const { } } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::set_ratio -// Access: Public -// Description: Sets the size request to store a specific ratio. -//////////////////////////////////////////////////////////////////// +/** + * Sets the size request to store a specific ratio. + */ INLINE void ImageResize::SizeRequest:: set_ratio(double ratio) { _type = RT_ratio; _e._ratio = ratio; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::get_ratio -// Access: Public -// Description: Returns the specific ratio stored within the -// size request. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specific ratio stored within the size request. + */ INLINE double ImageResize::SizeRequest:: get_ratio() const { nassertr(_type == RT_ratio, 0); return _e._ratio; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::SizeRequest::get_ratio -// Access: Public -// Description: Returns the specific ratio stored within the -// size request, or if a pixel size has been stored, -// returns the computed ratio based on the original -// size. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specific ratio stored within the size request, or if a pixel + * size has been stored, returns the computed ratio based on the original + * size. + */ INLINE double ImageResize::SizeRequest:: get_ratio(int orig_pixel_size) const { switch (_type) { diff --git a/pandatool/src/imageprogs/imageResize.cxx b/pandatool/src/imageprogs/imageResize.cxx index d10356f0fc..6b6a877490 100644 --- a/pandatool/src/imageprogs/imageResize.cxx +++ b/pandatool/src/imageprogs/imageResize.cxx @@ -1,26 +1,23 @@ -// Filename: imageResize.cxx -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageResize.cxx + * @author drose + * @date 2003-03-13 + */ #include "imageResize.h" #include "string_utils.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageResize:: ImageResize() : ImageFilter(true) { set_program_brief("resize an image file"); @@ -56,11 +53,9 @@ ImageResize() : ImageFilter(true) { _filter_radius = 1.0; } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ImageResize:: run() { if (_x_size.get_type() == RT_none && _y_size.get_type() == RT_none) { @@ -77,7 +72,7 @@ run() { nout << "Resizing to " << x_size << " x " << y_size << "\n"; PNMImage new_image(x_size, y_size, - _image.get_num_channels(), + _image.get_num_channels(), _image.get_maxval(), _image.get_type()); if (_use_gaussian_filter) { @@ -89,11 +84,9 @@ run() { write_image(new_image); } -//////////////////////////////////////////////////////////////////// -// Function: ImageResize::dispatch_size_request -// Access: Private, Static -// Description: Interprets the -x or -y parameters. -//////////////////////////////////////////////////////////////////// +/** + * Interprets the -x or -y parameters. + */ bool ImageResize:: dispatch_size_request(const string &opt, const string &arg, void *var) { SizeRequest *ip = (SizeRequest *)var; diff --git a/pandatool/src/imageprogs/imageResize.h b/pandatool/src/imageprogs/imageResize.h index c13a25c3da..c7e71076db 100644 --- a/pandatool/src/imageprogs/imageResize.h +++ b/pandatool/src/imageprogs/imageResize.h @@ -1,16 +1,15 @@ -// Filename: imageResize.h -// Created by: drose (13Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageResize.h + * @author drose + * @date 2003-03-13 + */ #ifndef IMAGERESIZE_H #define IMAGERESIZE_H @@ -19,11 +18,10 @@ #include "imageFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageResize -// Description : A program to read an image file and resize it to a -// larger or smaller image file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an image file and resize it to a larger or smaller image + * file. + */ class ImageResize : public ImageFilter { public: ImageResize(); @@ -68,4 +66,3 @@ private: #include "imageResize.I" #endif - diff --git a/pandatool/src/imageprogs/imageTrans.cxx b/pandatool/src/imageprogs/imageTrans.cxx index b9889f0bbb..68187459a7 100644 --- a/pandatool/src/imageprogs/imageTrans.cxx +++ b/pandatool/src/imageprogs/imageTrans.cxx @@ -1,26 +1,23 @@ -// Filename: imageTrans.cxx -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageTrans.cxx + * @author drose + * @date 2000-06-19 + */ #include "imageTrans.h" #include "string_utils.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: ImageTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageTrans:: ImageTrans() : ImageFilter(true) { set_program_brief("apply transformations to an image file"); @@ -68,11 +65,9 @@ ImageTrans() : ImageFilter(true) { _color_scale.set(1.0f, 1.0f, 1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: ImageTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ImageTrans:: run() { switch (_channels) { @@ -146,11 +141,9 @@ run() { write_image(); } -//////////////////////////////////////////////////////////////////// -// Function: ImageTrans::dispatch_channels -// Access: Private, Static -// Description: Interprets the -chan parameter. -//////////////////////////////////////////////////////////////////// +/** + * Interprets the -chan parameter. + */ bool ImageTrans:: dispatch_channels(const string &opt, const string &arg, void *var) { Channels *ip = (Channels *)var; @@ -187,12 +180,9 @@ dispatch_channels(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTrans::extract_alpha -// Access: Private -// Description: Extracts out just the alpha channel and stores it as -// a grayscale image. -//////////////////////////////////////////////////////////////////// +/** + * Extracts out just the alpha channel and stores it as a grayscale image. + */ void ImageTrans:: extract_alpha() { if (!_image.has_alpha()) { diff --git a/pandatool/src/imageprogs/imageTrans.h b/pandatool/src/imageprogs/imageTrans.h index b3a5d00876..8a4d3fffd6 100644 --- a/pandatool/src/imageprogs/imageTrans.h +++ b/pandatool/src/imageprogs/imageTrans.h @@ -1,16 +1,15 @@ -// Filename: imageTrans.h -// Created by: drose (19Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageTrans.h + * @author drose + * @date 2000-06-19 + */ #ifndef IMAGETRANS_H #define IMAGETRANS_H @@ -19,12 +18,10 @@ #include "imageFilter.h" -//////////////////////////////////////////////////////////////////// -// Class : ImageTrans -// Description : A program to read an image file and write an -// equivalent image file, possibly performing some minor -// operations along the way. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an image file and write an equivalent image file, + * possibly performing some minor operations along the way. + */ class ImageTrans : public ImageFilter { public: ImageTrans(); @@ -46,7 +43,7 @@ private: C_b, C_a }; - + Channels _channels; LColor _color_scale; bool _has_color_scale; @@ -54,4 +51,3 @@ private: }; #endif - diff --git a/pandatool/src/imageprogs/imageTransformColors.I b/pandatool/src/imageprogs/imageTransformColors.I index 28ac32b0af..6a6ba23eb0 100644 --- a/pandatool/src/imageprogs/imageTransformColors.I +++ b/pandatool/src/imageprogs/imageTransformColors.I @@ -1,14 +1,12 @@ -// Filename: imageTransformColors.I -// Created by: drose (25Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageTransformColors.I + * @author drose + * @date 2009-03-25 + */ diff --git a/pandatool/src/imageprogs/imageTransformColors.cxx b/pandatool/src/imageprogs/imageTransformColors.cxx index 6ff358b9a6..2dfec7eab2 100644 --- a/pandatool/src/imageprogs/imageTransformColors.cxx +++ b/pandatool/src/imageprogs/imageTransformColors.cxx @@ -1,16 +1,15 @@ -// Filename: imageTransformColors.cxx -// Created by: drose (25Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageTransformColors.cxx + * @author drose + * @date 2009-03-25 + */ #include "imageTransformColors.h" #include "string_utils.h" @@ -18,11 +17,9 @@ #include "pnmImage.h" #include -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageTransformColors:: ImageTransformColors() { set_program_brief("transform colors in an image file"); @@ -31,7 +28,7 @@ ImageTransformColors() { "pixels in an image, or in a series of images. This can be used, " "for instance, to increase or decrease the dynamic range; or to " "rotate the hue; or to reduce the saturation of colors in the image.\n\n" - + "Each parameter is encoded in a 4x4 matrix, which modifies the R, G, B " "colors of the image (the alpha values, if any, are not affected). " "RGB values are clamped at 0 and 1 after the operation. " @@ -71,7 +68,7 @@ ImageTransformColors() { &ImageTransformColors::dispatch_mat4, NULL, &_mat); add_option - ("mat3", "m00,m01,m02,m10,m11,m12,m20,m21,m22", 0, + ("mat3", "m00,m01,m02,m10,m11,m12,m20,m21,m22", 0, "Defines an arbitrary 3x3 RGB matrix.", &ImageTransformColors::dispatch_mat3, NULL, &_mat); @@ -98,15 +95,13 @@ ImageTransformColors() { "for an output directory; however, it's risky because the original " "input image files are lost.", &ImageTransformColors::dispatch_none, &_inplace); - + _mat = LMatrix4d::ident_mat(); } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ImageTransformColors:: run() { _mat.write(nout, 0); @@ -128,14 +123,12 @@ run() { if (!image.write(output_filename)) { nout << "Couldn't write " << output_filename << "; ignoring.\n"; } - } + } } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::dispatch_mat4 -// Access: Protected, Static -// Description: Takes a series of 16 numbers as a 4x4 matrix. -//////////////////////////////////////////////////////////////////// +/** + * Takes a series of 16 numbers as a 4x4 matrix. + */ bool ImageTransformColors:: dispatch_mat4(const string &opt, const string &arg, void *var) { LMatrix4d &orig = *(LMatrix4d *)var; @@ -176,11 +169,9 @@ dispatch_mat4(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::dispatch_mat3 -// Access: Protected, Static -// Description: Takes a series of 9 numbers as a 3x3 matrix. -//////////////////////////////////////////////////////////////////// +/** + * Takes a series of 9 numbers as a 3x3 matrix. + */ bool ImageTransformColors:: dispatch_mat3(const string &opt, const string &arg, void *var) { LMatrix4d &orig = *(LMatrix4d *)var; @@ -214,11 +205,9 @@ dispatch_mat3(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::dispatch_range -// Access: Protected, Static -// Description: Takes a min,max dynamic range. -//////////////////////////////////////////////////////////////////// +/** + * Takes a min,max dynamic range. + */ bool ImageTransformColors:: dispatch_range(const string &opt, const string &arg, void *var) { LMatrix4d &orig = *(LMatrix4d *)var; @@ -245,11 +234,9 @@ dispatch_range(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::dispatch_scale -// Access: Protected, Static -// Description: Accepts a componentwise scale. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a componentwise scale. + */ bool ImageTransformColors:: dispatch_scale(const string &opt, const string &arg, void *var) { LMatrix4d &orig = *(LMatrix4d *)var; @@ -277,11 +264,9 @@ dispatch_scale(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::dispatch_add -// Access: Protected, Static -// Description: Accepts a componentwise add. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a componentwise add. + */ bool ImageTransformColors:: dispatch_add(const string &opt, const string &arg, void *var) { LMatrix4d &orig = *(LMatrix4d *)var; @@ -309,14 +294,11 @@ dispatch_add(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool ImageTransformColors:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -364,13 +346,10 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::get_output_filename -// Access: Protected -// Description: Returns the output filename of the egg file with the -// given input filename. This is based on the user's -// choice of -inplace, -o, or -d. -//////////////////////////////////////////////////////////////////// +/** + * Returns the output filename of the egg file with the given input filename. + * This is based on the user's choice of -inplace, -o, or -d. + */ Filename ImageTransformColors:: get_output_filename(const Filename &source_filename) const { if (_got_output_filename) { @@ -467,11 +446,9 @@ rgb2hls(const LRGBColord &rgb) { return LRGBColord(h, l, s); } -//////////////////////////////////////////////////////////////////// -// Function: ImageTransformColors::process_image -// Access: Protected -// Description: Processes a single image in-place. -//////////////////////////////////////////////////////////////////// +/** + * Processes a single image in-place. + */ void ImageTransformColors:: process_image(PNMImage &image) { if (_hls) { diff --git a/pandatool/src/imageprogs/imageTransformColors.h b/pandatool/src/imageprogs/imageTransformColors.h index a389931b5f..d668ea5895 100644 --- a/pandatool/src/imageprogs/imageTransformColors.h +++ b/pandatool/src/imageprogs/imageTransformColors.h @@ -1,16 +1,15 @@ -// Filename: imageTransformColors.h -// Created by: drose (25Mar09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageTransformColors.h + * @author drose + * @date 2009-03-25 + */ #ifndef IMAGETRANSFORMCOLORS_H #define IMAGETRANSFORMCOLORS_H @@ -23,11 +22,10 @@ class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : ImageTransformColors -// Description : This program can apply a 4x4 color transform to all -// of the colors in the pixels of a series of images. -//////////////////////////////////////////////////////////////////// +/** + * This program can apply a 4x4 color transform to all of the colors in the + * pixels of a series of images. + */ class ImageTransformColors : public ProgramBase { public: ImageTransformColors(); @@ -49,7 +47,7 @@ protected: private: bool _hls; LMatrix4d _mat; - + bool _got_output_filename; Filename _output_filename; bool _got_output_dirname; @@ -63,4 +61,3 @@ private: #include "imageTransformColors.I" #endif - diff --git a/pandatool/src/lwo/config_lwo.cxx b/pandatool/src/lwo/config_lwo.cxx index 6e2d39617c..de7d924767 100644 --- a/pandatool/src/lwo/config_lwo.cxx +++ b/pandatool/src/lwo/config_lwo.cxx @@ -1,16 +1,15 @@ -// Filename: config_lwo.cxx -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_lwo.cxx + * @author drose + * @date 2001-04-23 + */ #include "config_lwo.h" #include "iffChunk.h" @@ -59,14 +58,12 @@ ConfigureFn(config_lwo) { init_liblwo(); } -//////////////////////////////////////////////////////////////////// -// Function: init_liblwo -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_liblwo() { static bool initialized = false; @@ -113,4 +110,3 @@ init_liblwo() { LwoSurfaceSmoothingAngle::init_type(); LwoVertexMap::init_type(); } - diff --git a/pandatool/src/lwo/config_lwo.h b/pandatool/src/lwo/config_lwo.h index 0cd80a4fc3..b2ed985036 100644 --- a/pandatool/src/lwo/config_lwo.h +++ b/pandatool/src/lwo/config_lwo.h @@ -1,16 +1,15 @@ -// Filename: config_lwo.h -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_lwo.h + * @author drose + * @date 2001-04-23 + */ #ifndef CONFIG_LWO_H #define CONFIG_LWO_H diff --git a/pandatool/src/lwo/iffChunk.I b/pandatool/src/lwo/iffChunk.I index 80537ac42f..716e893569 100644 --- a/pandatool/src/lwo/iffChunk.I +++ b/pandatool/src/lwo/iffChunk.I @@ -1,42 +1,34 @@ -// Filename: iffChunk.I -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffChunk.I + * @author drose + * @date 2001-04-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IffChunk:: IffChunk() { } -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::get_id -// Access: Public -// Description: Returns the ID associated with this chunk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the ID associated with this chunk. + */ INLINE IffId IffChunk:: get_id() const { return _id; } -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::set_id -// Access: Public -// Description: Changes the ID associated with this chunk. -//////////////////////////////////////////////////////////////////// +/** + * Changes the ID associated with this chunk. + */ INLINE void IffChunk:: set_id(IffId id) { _id = id; diff --git a/pandatool/src/lwo/iffChunk.cxx b/pandatool/src/lwo/iffChunk.cxx index 3f60953e20..e3ba7107a5 100644 --- a/pandatool/src/lwo/iffChunk.cxx +++ b/pandatool/src/lwo/iffChunk.cxx @@ -1,16 +1,15 @@ -// Filename: iffChunk.cxx -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffChunk.cxx + * @author drose + * @date 2001-04-23 + */ #include "iffChunk.h" #include "iffInputFile.h" @@ -19,33 +18,26 @@ TypeHandle IffChunk::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::output -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IffChunk:: output(ostream &out) const { out << _id << " (" << get_type() << ")"; } -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IffChunk:: write(ostream &out, int indent_level) const { indent(out, indent_level) << _id << " { ... }\n"; } -//////////////////////////////////////////////////////////////////// -// Function: IffChunk::make_new_chunk -// Access: Public, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *IffChunk:: make_new_chunk(IffInputFile *in, IffId id) { return in->make_new_chunk(id); diff --git a/pandatool/src/lwo/iffChunk.h b/pandatool/src/lwo/iffChunk.h index b67eb61e59..dd162497ae 100644 --- a/pandatool/src/lwo/iffChunk.h +++ b/pandatool/src/lwo/iffChunk.h @@ -1,16 +1,15 @@ -// Filename: iffChunk.h -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffChunk.h + * @author drose + * @date 2001-04-23 + */ #ifndef IFFCHUNK_H #define IFFCHUNK_H @@ -24,11 +23,10 @@ class IffInputFile; -//////////////////////////////////////////////////////////////////// -// Class : IffChunk -// Description : The basic kind of record in an EA "IFF" file, which -// the LightWave object file is based on. -//////////////////////////////////////////////////////////////////// +/** + * The basic kind of record in an EA "IFF" file, which the LightWave object + * file is based on. + */ class IffChunk : public TypedReferenceCount { public: INLINE IffChunk(); @@ -72,5 +70,3 @@ INLINE ostream &operator << (ostream &out, const IffChunk &chunk) { } #endif - - diff --git a/pandatool/src/lwo/iffGenericChunk.I b/pandatool/src/lwo/iffGenericChunk.I index bcc1132113..bfa0a13884 100644 --- a/pandatool/src/lwo/iffGenericChunk.I +++ b/pandatool/src/lwo/iffGenericChunk.I @@ -1,42 +1,34 @@ -// Filename: iffGenericChunk.I -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffGenericChunk.I + * @author drose + * @date 2001-04-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IffGenericChunk::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IffGenericChunk:: IffGenericChunk() { } -//////////////////////////////////////////////////////////////////// -// Function: IffGenericChunk::get_data -// Access: Public -// Description: Returns the data in the chunk. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data in the chunk. + */ INLINE const Datagram &IffGenericChunk:: get_data() const { return _data; } -//////////////////////////////////////////////////////////////////// -// Function: IffGenericChunk::set_data -// Access: Public -// Description: Changes the data in the chunk -//////////////////////////////////////////////////////////////////// +/** + * Changes the data in the chunk + */ INLINE void IffGenericChunk:: set_data(const Datagram &data) { _data = data; diff --git a/pandatool/src/lwo/iffGenericChunk.cxx b/pandatool/src/lwo/iffGenericChunk.cxx index 7ffa8e5eca..87625c2193 100644 --- a/pandatool/src/lwo/iffGenericChunk.cxx +++ b/pandatool/src/lwo/iffGenericChunk.cxx @@ -1,16 +1,15 @@ -// Filename: iffGenericChunk.cxx -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffGenericChunk.cxx + * @author drose + * @date 2001-04-23 + */ #include "iffGenericChunk.h" #include "iffInputFile.h" @@ -20,16 +19,12 @@ TypeHandle IffGenericChunk::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IffGenericChunk::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool IffGenericChunk:: read_iff(IffInputFile *in, size_t stop_at) { size_t length = stop_at - in->get_bytes_read(); @@ -38,14 +33,11 @@ read_iff(IffInputFile *in, size_t stop_at) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IffGenericChunk::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IffGenericChunk:: write(ostream &out, int indent_level) const { indent(out, indent_level) << get_id() << " { " << _data.get_length() << " bytes }\n"; } - diff --git a/pandatool/src/lwo/iffGenericChunk.h b/pandatool/src/lwo/iffGenericChunk.h index e48f633854..bb50fb36d4 100644 --- a/pandatool/src/lwo/iffGenericChunk.h +++ b/pandatool/src/lwo/iffGenericChunk.h @@ -1,16 +1,15 @@ -// Filename: iffGenericChunk.h -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffGenericChunk.h + * @author drose + * @date 2001-04-23 + */ #ifndef IFFGENERICCHUNK_H #define IFFGENERICCHUNK_H @@ -22,12 +21,10 @@ #include "datagram.h" -//////////////////////////////////////////////////////////////////// -// Class : IffGenericChunk -// Description : A class for a generic kind of IffChunk that is not -// understood by a particular IffReader. It remembers -// its entire contents. -//////////////////////////////////////////////////////////////////// +/** + * A class for a generic kind of IffChunk that is not understood by a + * particular IffReader. It remembers its entire contents. + */ class IffGenericChunk : public IffChunk { public: INLINE IffGenericChunk(); @@ -62,5 +59,3 @@ private: #include "iffGenericChunk.I" #endif - - diff --git a/pandatool/src/lwo/iffId.I b/pandatool/src/lwo/iffId.I index 938c4f80e9..b5775dcbaa 100644 --- a/pandatool/src/lwo/iffId.I +++ b/pandatool/src/lwo/iffId.I @@ -1,23 +1,19 @@ -// Filename: iffId.I -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffId.I + * @author drose + * @date 2001-04-23 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IffId::Default Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IffId:: IffId() { _id._c[0] = 0; @@ -26,11 +22,9 @@ IffId() { _id._c[3] = 0; } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IffId:: IffId(const char id[4]) { _id._c[0] = id[0]; @@ -39,66 +33,51 @@ IffId(const char id[4]) { _id._c[3] = id[3]; } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE IffId:: IffId(const IffId ©) { _id._n = copy._id._n; } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void IffId:: operator = (const IffId ©) { _id._n = copy._id._n; } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Equivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool IffId:: operator == (const IffId &other) const { return (_id._n == other._id._n); } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Nonequivalence Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool IffId:: operator != (const IffId &other) const { return (_id._n != other._id._n); } -//////////////////////////////////////////////////////////////////// -// Function: IffId::Ordering Operator -// Access: Public -// Description: The ordering is arbitrary, and may not even be -// consistent between different architectures -// (e.g. big-endian and little-endian). It is useful -// mainly for putting IffId's into a sorted container, -// like sets and maps. -//////////////////////////////////////////////////////////////////// +/** + * The ordering is arbitrary, and may not even be consistent between different + * architectures (e.g. big-endian and little-endian). It is useful mainly + * for putting IffId's into a sorted container, like sets and maps. + */ INLINE bool IffId:: operator < (const IffId &other) const { return (_id._n < other._id._n); } -//////////////////////////////////////////////////////////////////// -// Function: IffId::get_name -// Access: Public -// Description: Returns the four-character name of the Id, for -// outputting. -//////////////////////////////////////////////////////////////////// +/** + * Returns the four-character name of the Id, for outputting. + */ INLINE string IffId:: get_name() const { return string(_id._c, 4); diff --git a/pandatool/src/lwo/iffId.cxx b/pandatool/src/lwo/iffId.cxx index b91896721c..6d31a79bad 100644 --- a/pandatool/src/lwo/iffId.cxx +++ b/pandatool/src/lwo/iffId.cxx @@ -1,26 +1,23 @@ -// Filename: iffId.cxx -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffId.cxx + * @author drose + * @date 2001-04-23 + */ #include "iffId.h" #include -//////////////////////////////////////////////////////////////////// -// Function: IffId::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IffId:: output(ostream &out) const { // If all of the characters are printable, just output them. diff --git a/pandatool/src/lwo/iffId.h b/pandatool/src/lwo/iffId.h index b6ea727dcb..ff48a7e443 100644 --- a/pandatool/src/lwo/iffId.h +++ b/pandatool/src/lwo/iffId.h @@ -1,16 +1,15 @@ -// Filename: iffId.h -// Created by: drose (23Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffId.h + * @author drose + * @date 2001-04-23 + */ #ifndef IFFID_H #define IFFID_H @@ -19,13 +18,11 @@ #include "numeric_types.h" -//////////////////////////////////////////////////////////////////// -// Class : IffId -// Description : A four-byte chunk ID appearing in an "IFF" file. -// This is used to identify the meaning of each chunk, -// and can be treated either as a concrete object or as -// a string, something like a TypeHandle. -//////////////////////////////////////////////////////////////////// +/** + * A four-byte chunk ID appearing in an "IFF" file. This is used to identify + * the meaning of each chunk, and can be treated either as a concrete object + * or as a string, something like a TypeHandle. + */ class IffId { public: INLINE IffId(); diff --git a/pandatool/src/lwo/iffInputFile.I b/pandatool/src/lwo/iffInputFile.I index e32f888e13..18fe7e9003 100644 --- a/pandatool/src/lwo/iffInputFile.I +++ b/pandatool/src/lwo/iffInputFile.I @@ -1,69 +1,54 @@ -// Filename: iffInputFile.I -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffInputFile.I + * @author drose + * @date 2001-04-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::set_filename -// Access: Public -// Description: Indicates the filename that the InputFile is -// currently opened on. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the filename that the InputFile is currently opened on. + */ INLINE void IffInputFile:: set_filename(const Filename &filename) { _filename = filename; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_filename -// Access: Public -// Description: Returns the filename that the InputFile is -// currently opened on, if available. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename that the InputFile is currently opened on, if + * available. + */ INLINE const Filename &IffInputFile:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::is_eof -// Access: Public -// Description: Returns true if the last read operation failed -// because of reaching EOF, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the last read operation failed because of reaching EOF, + * false otherwise. + */ INLINE bool IffInputFile:: is_eof() const { return _eof; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_bytes_read -// Access: Public -// Description: Returns the number of bytes read so far from the -// input file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of bytes read so far from the input file. + */ INLINE size_t IffInputFile:: get_bytes_read() const { return _bytes_read; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::align -// Access: Public -// Description: If the current file pointer is not positioned on an -// even-byte boundary, reads and discards one byte so -// that it is. -//////////////////////////////////////////////////////////////////// +/** + * If the current file pointer is not positioned on an even-byte boundary, + * reads and discards one byte so that it is. + */ INLINE void IffInputFile:: align() { if ((_bytes_read & 1) != 0) { diff --git a/pandatool/src/lwo/iffInputFile.cxx b/pandatool/src/lwo/iffInputFile.cxx index fb8965a53d..0707d78044 100644 --- a/pandatool/src/lwo/iffInputFile.cxx +++ b/pandatool/src/lwo/iffInputFile.cxx @@ -1,16 +1,15 @@ -// Filename: iffInputFile.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffInputFile.cxx + * @author drose + * @date 2001-04-24 + */ #include "iffInputFile.h" #include "iffGenericChunk.h" @@ -20,11 +19,9 @@ TypeHandle IffInputFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IffInputFile:: IffInputFile() { _input = (istream *)NULL; @@ -34,11 +31,9 @@ IffInputFile() { _bytes_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IffInputFile:: ~IffInputFile() { if (_owns_istream) { @@ -47,12 +42,10 @@ IffInputFile:: } } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::open_read -// Access: Public -// Description: Attempts to open the indicated filename for reading. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the indicated filename for reading. Returns true if + * successful, false otherwise. + */ bool IffInputFile:: open_read(Filename filename) { filename.set_binary(); @@ -69,14 +62,11 @@ open_read(Filename filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::set_input -// Access: Public -// Description: Sets up the input to use an arbitrary istream. If -// owns_istream is true, the istream will be deleted -// (via vfs->close_read_file()) when the IffInputFile -// destructs. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the input to use an arbitrary istream. If owns_istream is true, + * the istream will be deleted (via vfs->close_read_file()) when the + * IffInputFile destructs. + */ void IffInputFile:: set_input(istream *input, bool owns_istream) { if (_owns_istream) { @@ -90,11 +80,9 @@ set_input(istream *input, bool owns_istream) { _bytes_read = 0; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_int8 -// Access: Public -// Description: Extracts a signed 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 8-bit integer. + */ PN_int8 IffInputFile:: get_int8() { Datagram dg; @@ -105,11 +93,9 @@ get_int8() { return dgi.get_int8(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_uint8 -// Access: Public -// Description: Extracts an unsigned 8-bit integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 8-bit integer. + */ PN_uint8 IffInputFile:: get_uint8() { Datagram dg; @@ -120,11 +106,9 @@ get_uint8() { return dgi.get_int8(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_be_int16 -// Access: Public -// Description: Extracts a signed 16-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 16-bit big-endian integer. + */ PN_int16 IffInputFile:: get_be_int16() { Datagram dg; @@ -135,11 +119,9 @@ get_be_int16() { return dgi.get_be_int16(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_be_int32 -// Access: Public -// Description: Extracts a signed 32-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a signed 32-bit big-endian integer. + */ PN_int32 IffInputFile:: get_be_int32() { Datagram dg; @@ -150,11 +132,9 @@ get_be_int32() { return dgi.get_be_int32(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_be_uint16 -// Access: Public -// Description: Extracts an unsigned 16-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 16-bit big-endian integer. + */ PN_uint16 IffInputFile:: get_be_uint16() { Datagram dg; @@ -165,11 +145,9 @@ get_be_uint16() { return dgi.get_be_uint16(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_be_uint32 -// Access: Public -// Description: Extracts an unsigned 32-bit big-endian integer. -//////////////////////////////////////////////////////////////////// +/** + * Extracts an unsigned 32-bit big-endian integer. + */ PN_uint32 IffInputFile:: get_be_uint32() { Datagram dg; @@ -180,12 +158,9 @@ get_be_uint32() { return dgi.get_be_uint32(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_be_float32 -// Access: Public -// Description: Extracts a 32-bit big-endian single-precision -// floating-point number. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 32-bit big-endian single-precision floating-point number. + */ PN_stdfloat IffInputFile:: get_be_float32() { Datagram dg; @@ -196,11 +171,9 @@ get_be_float32() { return dgi.get_be_float32(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_string -// Access: Public -// Description: Extracts a null-terminated string. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a null-terminated string. + */ string IffInputFile:: get_string() { string result; @@ -216,11 +189,9 @@ get_string() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_id -// Access: Public -// Description: Extracts a 4-character IFF ID. -//////////////////////////////////////////////////////////////////// +/** + * Extracts a 4-character IFF ID. + */ IffId IffInputFile:: get_id() { Datagram dg; @@ -231,15 +202,12 @@ get_id() { return IffId(id); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_chunk -// Access: Public -// Description: Reads a single IffChunk, determining its type based -// on its ID. Allocates and returns a new IffChunk -// object of the appropriate type. Returns NULL if EOF -// is reached before the chunk can be read completely, -// or if there is some other error in reading the chunk. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single IffChunk, determining its type based on its ID. Allocates + * and returns a new IffChunk object of the appropriate type. Returns NULL if + * EOF is reached before the chunk can be read completely, or if there is some + * other error in reading the chunk. + */ PT(IffChunk) IffInputFile:: get_chunk() { if (is_eof()) { @@ -284,16 +252,12 @@ get_chunk() { return (IffChunk *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::get_subchunk -// Access: Public -// Description: Similar to get_chunk(), except the chunk size is only -// a 16-bit number instead of 32-bit, and it takes a -// context, which is the chunk in which this chunk is -// encountered. The parent chunk may (or may not) -// decide what kind of chunk is meant by the various -// id's encountered. -//////////////////////////////////////////////////////////////////// +/** + * Similar to get_chunk(), except the chunk size is only a 16-bit number + * instead of 32-bit, and it takes a context, which is the chunk in which this + * chunk is encountered. The parent chunk may (or may not) decide what kind + * of chunk is meant by the various id's encountered. + */ PT(IffChunk) IffInputFile:: get_subchunk(IffChunk *context) { if (is_eof()) { @@ -338,12 +302,9 @@ get_subchunk(IffChunk *context) { return (IffChunk *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::read_byte -// Access: Public -// Description: Reads a single byte. Returns true if successful, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads a single byte. Returns true if successful, false otherwise. + */ bool IffInputFile:: read_byte(char &byte) { if (is_eof()) { @@ -356,13 +317,10 @@ read_byte(char &byte) { return !is_eof(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::read_bytes -// Access: Public -// Description: Reads a series of bytes, and stores them in the -// indicated Datagram. Returns true if successful, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads a series of bytes, and stores them in the indicated Datagram. + * Returns true if successful, false otherwise. + */ bool IffInputFile:: read_bytes(Datagram &datagram, int length) { if (is_eof()) { @@ -382,12 +340,10 @@ read_bytes(Datagram &datagram, int length) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::skip_bytes -// Access: Public -// Description: Reads a series of bytes, but does not store them. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads a series of bytes, but does not store them. Returns true if + * successful, false otherwise. + */ bool IffInputFile:: skip_bytes(int length) { if (is_eof()) { @@ -403,12 +359,10 @@ skip_bytes(int length) { return !is_eof(); } -//////////////////////////////////////////////////////////////////// -// Function: IffInputFile::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID. + */ IffChunk *IffInputFile:: make_new_chunk(IffId) { return new IffGenericChunk; diff --git a/pandatool/src/lwo/iffInputFile.h b/pandatool/src/lwo/iffInputFile.h index 8c30e33710..3afe12bae8 100644 --- a/pandatool/src/lwo/iffInputFile.h +++ b/pandatool/src/lwo/iffInputFile.h @@ -1,16 +1,15 @@ -// Filename: iffInputFile.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file iffInputFile.h + * @author drose + * @date 2001-04-24 + */ #ifndef IFFINPUTFILE_H #define IFFINPUTFILE_H @@ -25,11 +24,9 @@ class Datagram; -//////////////////////////////////////////////////////////////////// -// Class : IffInputFile -// Description : A wrapper around an istream used for reading an IFF -// file. -//////////////////////////////////////////////////////////////////// +/** + * A wrapper around an istream used for reading an IFF file. + */ class IffInputFile : public TypedObject { public: IffInputFile(); @@ -99,5 +96,3 @@ private: #include "iffInputFile.I" #endif - - diff --git a/pandatool/src/lwo/lwoBoundingBox.cxx b/pandatool/src/lwo/lwoBoundingBox.cxx index b9ee714261..8f23e7b403 100644 --- a/pandatool/src/lwo/lwoBoundingBox.cxx +++ b/pandatool/src/lwo/lwoBoundingBox.cxx @@ -1,16 +1,15 @@ -// Filename: lwoBoundingBox.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoBoundingBox.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoBoundingBox.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoBoundingBox::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoBoundingBox::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoBoundingBox:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoBoundingBox::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoBoundingBox:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoBoundingBox.h b/pandatool/src/lwo/lwoBoundingBox.h index 87a1363a54..3120bee5b0 100644 --- a/pandatool/src/lwo/lwoBoundingBox.h +++ b/pandatool/src/lwo/lwoBoundingBox.h @@ -1,16 +1,15 @@ -// Filename: lwoBoundingBox.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoBoundingBox.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOBOUNDINGBOX_H #define LWOBOUNDINGBOX_H @@ -21,11 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoBoundingBox -// Description : Stores the bounding box for the vertex data in a -// layer. Optional. -//////////////////////////////////////////////////////////////////// +/** + * Stores the bounding box for the vertex data in a layer. Optional. + */ class LwoBoundingBox : public LwoChunk { public: LVecBase3 _min; @@ -54,5 +51,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoChunk.cxx b/pandatool/src/lwo/lwoChunk.cxx index 5ef2ce8532..3abc082371 100644 --- a/pandatool/src/lwo/lwoChunk.cxx +++ b/pandatool/src/lwo/lwoChunk.cxx @@ -1,16 +1,15 @@ -// Filename: lwoChunk.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoChunk.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoChunk.h" diff --git a/pandatool/src/lwo/lwoChunk.h b/pandatool/src/lwo/lwoChunk.h index 7d4b38d8e6..7310159746 100644 --- a/pandatool/src/lwo/lwoChunk.h +++ b/pandatool/src/lwo/lwoChunk.h @@ -1,16 +1,15 @@ -// Filename: lwoChunk.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoChunk.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOCHUNK_H #define LWOCHUNK_H @@ -19,13 +18,11 @@ #include "iffChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoChunk -// Description : A specialization of IffChunk for Lightwave Object -// files. Each kind of chunk that is specific to a -// Lightwave file should inherit directly or indirectly -// from LwoChunk. -//////////////////////////////////////////////////////////////////// +/** + * A specialization of IffChunk for Lightwave Object files. Each kind of + * chunk that is specific to a Lightwave file should inherit directly or + * indirectly from LwoChunk. + */ class LwoChunk : public IffChunk { public: // No particular interface here. @@ -49,5 +46,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoClip.cxx b/pandatool/src/lwo/lwoClip.cxx index a06cdca54a..d0bda7993f 100644 --- a/pandatool/src/lwo/lwoClip.cxx +++ b/pandatool/src/lwo/lwoClip.cxx @@ -1,16 +1,15 @@ -// Filename: lwoClip.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoClip.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoClip.h" #include "iffInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoClip::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoClip::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoClip:: read_iff(IffInputFile *in, size_t stop_at) { _index = in->get_be_int32(); @@ -37,11 +32,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoClip::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoClip:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -53,13 +46,10 @@ write(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoClip::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *LwoClip:: make_new_chunk(IffInputFile *in, IffId id) { if (id == IffId("STIL")) { @@ -69,4 +59,3 @@ make_new_chunk(IffInputFile *in, IffId id) { return IffChunk::make_new_chunk(in, id); } } - diff --git a/pandatool/src/lwo/lwoClip.h b/pandatool/src/lwo/lwoClip.h index 258b9f5b38..647a2e69dd 100644 --- a/pandatool/src/lwo/lwoClip.h +++ b/pandatool/src/lwo/lwoClip.h @@ -1,16 +1,15 @@ -// Filename: lwoClip.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoClip.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOCLIP_H #define LWOCLIP_H @@ -19,11 +18,10 @@ #include "lwoGroupChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoClip -// Description : A single image file, or a numbered sequence of images -// (e.g. a texture-flip animation). -//////////////////////////////////////////////////////////////////// +/** + * A single image file, or a numbered sequence of images (e.g. a texture-flip + * animation). + */ class LwoClip : public LwoGroupChunk { public: int _index; @@ -53,5 +51,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx index 52197a4e2b..f0cab49c18 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.cxx @@ -1,16 +1,15 @@ -// Filename: lwoDiscontinuousVertexMap.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoDiscontinuousVertexMap.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoDiscontinuousVertexMap.h" #include "lwoInputFile.h" @@ -23,12 +22,10 @@ TypeHandle LwoDiscontinuousVertexMap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoDiscontinuousVertexMap::has_value -// Access: Public -// Description: Returns true if the map has a value associated with -// the given index, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the map has a value associated with the given index, false + * otherwise. + */ bool LwoDiscontinuousVertexMap:: has_value(int polygon_index, int vertex_index) const { VMad::const_iterator di; @@ -41,13 +38,10 @@ has_value(int polygon_index, int vertex_index) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: LwoDiscontinuousVertexMap::get_value -// Access: Public -// Description: Returns the mapping value associated with the given -// index, or an empty PTA_stdfloat if there is no mapping -// value associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mapping value associated with the given index, or an empty + * PTA_stdfloat if there is no mapping value associated. + */ PTA_stdfloat LwoDiscontinuousVertexMap:: get_value(int polygon_index, int vertex_index) const { VMad::const_iterator di; @@ -64,16 +58,12 @@ get_value(int polygon_index, int vertex_index) const { return PTA_stdfloat(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoDiscontinuousVertexMap::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoDiscontinuousVertexMap:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -95,8 +85,8 @@ read_iff(IffInputFile *in, size_t stop_at) { pair ir = vmap.insert(VMap::value_type(vertex_index, value)); if (!ir.second) { - // This polygon/vertex pair was repeated in the vmad. Is it - // simply redundant, or is it contradictory? + // This polygonvertex pair was repeated in the vmad. Is it simply + // redundant, or is it contradictory? PTA_stdfloat orig_value = (*ir.first).second; if (value.v() != orig_value.v()) { @@ -121,11 +111,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return (lin->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoDiscontinuousVertexMap::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoDiscontinuousVertexMap:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h index eb047d2300..1404d02ccd 100644 --- a/pandatool/src/lwo/lwoDiscontinuousVertexMap.h +++ b/pandatool/src/lwo/lwoDiscontinuousVertexMap.h @@ -1,16 +1,15 @@ -// Filename: lwoDiscontinuousVertexMap.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoDiscontinuousVertexMap.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWODISCONTINUOUSVERTEXMAP_H #define LWODISCONTINUOUSVERTEXMAP_H @@ -22,12 +21,10 @@ #include "pta_stdfloat.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoDiscontinuousVertexMap -// Description : A mapping of floating-point values per integer index. -// The meaning of these values is determined by the -// mapping type code and/or its name. -//////////////////////////////////////////////////////////////////// +/** + * A mapping of floating-point values per integer index. The meaning of these + * values is determined by the mapping type code and/or its name. + */ class LwoDiscontinuousVertexMap : public LwoChunk { public: bool has_value(int polygon_index, int vertex_index) const; @@ -65,5 +62,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoGroupChunk.cxx b/pandatool/src/lwo/lwoGroupChunk.cxx index 682404f3b1..69cd426f57 100644 --- a/pandatool/src/lwo/lwoGroupChunk.cxx +++ b/pandatool/src/lwo/lwoGroupChunk.cxx @@ -1,16 +1,15 @@ -// Filename: lwoGroupChunk.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoGroupChunk.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoGroupChunk.h" #include "lwoInputFile.h" @@ -19,36 +18,28 @@ TypeHandle LwoGroupChunk::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoGroupChunk::get_num_chunks -// Access: Public -// Description: Returns the number of child chunks of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of child chunks of this group. + */ int LwoGroupChunk:: get_num_chunks() const { return _chunks.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoGroupChunk::get_chunk -// Access: Public -// Description: Returns the nth child chunk of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child chunk of this group. + */ IffChunk *LwoGroupChunk:: get_chunk(int n) const { nassertr(n >= 0 && n < (int)_chunks.size(), (IffChunk *)NULL); return _chunks[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LwoGroupChunk::read_chunks_iff -// Access: Public -// Description: Reads a sequence of child chunks, until byte stop_at -// has been been reached, and stores them as the -// children. Returns true if successful (and exactly -// the correct number of bytes were read), or false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads a sequence of child chunks, until byte stop_at has been been reached, + * and stores them as the children. Returns true if successful (and exactly + * the correct number of bytes were read), or false otherwise. + */ bool LwoGroupChunk:: read_chunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { @@ -62,12 +53,9 @@ read_chunks_iff(IffInputFile *in, size_t stop_at) { return (in->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoGroupChunk::read_subchunks_iff -// Access: Public -// Description: Similar to read_chunks_iff(), but reads them as -// subchunks. -//////////////////////////////////////////////////////////////////// +/** + * Similar to read_chunks_iff(), but reads them as subchunks. + */ bool LwoGroupChunk:: read_subchunks_iff(IffInputFile *in, size_t stop_at) { while (in->get_bytes_read() < stop_at && !in->is_eof()) { @@ -81,12 +69,10 @@ read_subchunks_iff(IffInputFile *in, size_t stop_at) { return (in->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoGroupChunk::write_chunks -// Access: Public -// Description: Formats the list of chunks for output to the user -// (primarily for debugging), one per line. -//////////////////////////////////////////////////////////////////// +/** + * Formats the list of chunks for output to the user (primarily for + * debugging), one per line. + */ void LwoGroupChunk:: write_chunks(ostream &out, int indent_level) const { Chunks::const_iterator ci; diff --git a/pandatool/src/lwo/lwoGroupChunk.h b/pandatool/src/lwo/lwoGroupChunk.h index 27b0ed603a..fb2db24f11 100644 --- a/pandatool/src/lwo/lwoGroupChunk.h +++ b/pandatool/src/lwo/lwoGroupChunk.h @@ -1,16 +1,15 @@ -// Filename: lwoGroupChunk.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoGroupChunk.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOGROUPCHUNK_H #define LWOGROUPCHUNK_H @@ -24,11 +23,10 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoGroupChunk -// Description : A particular kind of LwoChunk that is expected to -// contain an arbitrary number of child chunks. -//////////////////////////////////////////////////////////////////// +/** + * A particular kind of LwoChunk that is expected to contain an arbitrary + * number of child chunks. + */ class LwoGroupChunk : public LwoChunk { public: int get_num_chunks() const; @@ -61,5 +59,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoHeader.I b/pandatool/src/lwo/lwoHeader.I index ce8a3e73ea..2d82f6c947 100644 --- a/pandatool/src/lwo/lwoHeader.I +++ b/pandatool/src/lwo/lwoHeader.I @@ -1,36 +1,29 @@ -// Filename: lwoHeader.I -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoHeader.I + * @author drose + * @date 2001-04-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LwoHeader::is_valid -// Access: Public -// Description: Returns true if the header represents a valid and -// recognized Lightwave header, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the header represents a valid and recognized Lightwave + * header, false otherwise. + */ INLINE bool LwoHeader:: is_valid() const { return _valid; } -//////////////////////////////////////////////////////////////////// -// Function: LwoHeader::get_version -// Access: Public -// Description: Returns the version of the Lightwave file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version of the Lightwave file. + */ INLINE double LwoHeader:: get_version() const { return _version; } - diff --git a/pandatool/src/lwo/lwoHeader.cxx b/pandatool/src/lwo/lwoHeader.cxx index c7fd32069f..4fe302f54d 100644 --- a/pandatool/src/lwo/lwoHeader.cxx +++ b/pandatool/src/lwo/lwoHeader.cxx @@ -1,16 +1,15 @@ -// Filename: lwoHeader.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoHeader.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoHeader.h" #include "lwoInputFile.h" @@ -20,27 +19,21 @@ TypeHandle LwoHeader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoHeader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoHeader:: LwoHeader() { _valid = false; _version = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: LwoHeader::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoHeader:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -64,11 +57,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoHeader::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoHeader:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoHeader.h b/pandatool/src/lwo/lwoHeader.h index e2dd6fff19..f4bbc93c8f 100644 --- a/pandatool/src/lwo/lwoHeader.h +++ b/pandatool/src/lwo/lwoHeader.h @@ -1,16 +1,15 @@ -// Filename: lwoHeader.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoHeader.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOHEADER_H #define LWOHEADER_H @@ -19,10 +18,9 @@ #include "lwoGroupChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoHeader -// Description : The first chunk in a Lightwave Object file. -//////////////////////////////////////////////////////////////////// +/** + * The first chunk in a Lightwave Object file. + */ class LwoHeader : public LwoGroupChunk { public: LwoHeader(); @@ -61,5 +59,3 @@ private: #include "lwoHeader.I" #endif - - diff --git a/pandatool/src/lwo/lwoInputFile.I b/pandatool/src/lwo/lwoInputFile.I index 40331da299..7824cdbb8f 100644 --- a/pandatool/src/lwo/lwoInputFile.I +++ b/pandatool/src/lwo/lwoInputFile.I @@ -1,40 +1,31 @@ -// Filename: lwoInputFile.I -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoInputFile.I + * @author drose + * @date 2001-04-24 + */ - -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::get_lwo_version -// Access: Public -// Description: Returns the version of the Lightwave file being read. -// This is unknown until the header record has been -// read; then it will be set by the header. -//////////////////////////////////////////////////////////////////// +/** + * Returns the version of the Lightwave file being read. This is unknown + * until the header record has been read; then it will be set by the header. + */ INLINE double LwoInputFile:: get_lwo_version() const { return _lwo_version; } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::set_lwo_version -// Access: Public -// Description: Changes the version number reported for the Lightwave -// file. Normally this is only called by LwoHeader as -// it is read. -//////////////////////////////////////////////////////////////////// +/** + * Changes the version number reported for the Lightwave file. Normally this + * is only called by LwoHeader as it is read. + */ INLINE void LwoInputFile:: set_lwo_version(double lwo_version) { _lwo_version = lwo_version; } - diff --git a/pandatool/src/lwo/lwoInputFile.cxx b/pandatool/src/lwo/lwoInputFile.cxx index e1de1ec4db..63f3b51731 100644 --- a/pandatool/src/lwo/lwoInputFile.cxx +++ b/pandatool/src/lwo/lwoInputFile.cxx @@ -1,16 +1,15 @@ -// Filename: lwoInputFile.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoInputFile.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoInputFile.h" #include "lwoBoundingBox.h" @@ -27,50 +26,40 @@ TypeHandle LwoInputFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoInputFile:: LwoInputFile() { } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoInputFile:: ~LwoInputFile() { } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::get_vx -// Access: Public -// Description: Reads a Lightwave variable-length index. This is -// either a 2-byte or 4-byte integer. -//////////////////////////////////////////////////////////////////// +/** + * Reads a Lightwave variable-length index. This is either a 2-byte or 4-byte + * integer. + */ int LwoInputFile:: get_vx() { PN_uint16 top = get_be_uint16(); if ((top & 0xff00) == 0xff00) { - // The first byte is 0xff, which indicates we have a 4-byte - // integer. + // The first byte is 0xff, which indicates we have a 4-byte integer. PN_uint16 bottom = get_be_uint16(); return ((int)(top & 0xff) << 16) | bottom; } - // The first byte is not 0xff, which indicates we have a 2-byte - // integer. + // The first byte is not 0xff, which indicates we have a 2-byte integer. return top; } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::get_vec3 -// Access: Public -// Description: Reads a three-component vector of floats. -//////////////////////////////////////////////////////////////////// +/** + * Reads a three-component vector of floats. + */ LVecBase3 LwoInputFile:: get_vec3() { LVecBase3 result; @@ -80,12 +69,10 @@ get_vec3() { return result; } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::get_filename -// Access: Public -// Description: Reads a Lightwave platform-neutral filename and -// converts it to a Panda platform-neutral filename. -//////////////////////////////////////////////////////////////////// +/** + * Reads a Lightwave platform-neutral filename and converts it to a Panda + * platform-neutral filename. + */ Filename LwoInputFile:: get_filename() { string name = get_string(); @@ -103,12 +90,10 @@ get_filename() { return Filename("/", path); } -//////////////////////////////////////////////////////////////////// -// Function: LwoInputFile::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID. + */ IffChunk *LwoInputFile:: make_new_chunk(IffId id) { if (id == IffId("FORM")) { diff --git a/pandatool/src/lwo/lwoInputFile.h b/pandatool/src/lwo/lwoInputFile.h index 3394e8f5b9..5979468453 100644 --- a/pandatool/src/lwo/lwoInputFile.h +++ b/pandatool/src/lwo/lwoInputFile.h @@ -1,16 +1,15 @@ -// Filename: lwoInputFile.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoInputFile.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOINPUTFILE_H #define LWOINPUTFILE_H @@ -21,11 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoInputFile -// Description : A specialization of IffInputFile to handle reading a -// Lightwave Object file. -//////////////////////////////////////////////////////////////////// +/** + * A specialization of IffInputFile to handle reading a Lightwave Object file. + */ class LwoInputFile : public IffInputFile { public: LwoInputFile(); @@ -65,5 +62,3 @@ private: #include "lwoInputFile.I" #endif - - diff --git a/pandatool/src/lwo/lwoLayer.cxx b/pandatool/src/lwo/lwoLayer.cxx index e06dd48807..75f4a18606 100644 --- a/pandatool/src/lwo/lwoLayer.cxx +++ b/pandatool/src/lwo/lwoLayer.cxx @@ -1,16 +1,15 @@ -// Filename: lwoLayer.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoLayer.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoLayer.h" #include "lwoInputFile.h" @@ -20,12 +19,10 @@ TypeHandle LwoLayer::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoLayer::make_generic -// Access: Public -// Description: Resets the layer's parameters to initial defaults for -// a generic layer created implicitly. -//////////////////////////////////////////////////////////////////// +/** + * Resets the layer's parameters to initial defaults for a generic layer + * created implicitly. + */ void LwoLayer:: make_generic() { _number = -1; @@ -35,16 +32,12 @@ make_generic() { _parent = -1; } -//////////////////////////////////////////////////////////////////// -// Function: LwoLayer::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoLayer:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -66,11 +59,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoLayer::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoLayer:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoLayer.h b/pandatool/src/lwo/lwoLayer.h index 8737268704..641311a5e6 100644 --- a/pandatool/src/lwo/lwoLayer.h +++ b/pandatool/src/lwo/lwoLayer.h @@ -1,16 +1,15 @@ -// Filename: lwoLayer.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoLayer.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOLAYER_H #define LWOLAYER_H @@ -21,14 +20,11 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoLayer -// Description : Signals the start of a new layer. All the data -// chunks which follow will be included in this layer -// until another layer chunk is encountered. If data is -// encountered before a layer chunk, it goes into an -// arbitrary layer. -//////////////////////////////////////////////////////////////////// +/** + * Signals the start of a new layer. All the data chunks which follow will be + * included in this layer until another layer chunk is encountered. If data + * is encountered before a layer chunk, it goes into an arbitrary layer. + */ class LwoLayer : public LwoChunk { public: void make_generic(); @@ -66,5 +62,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoPoints.cxx b/pandatool/src/lwo/lwoPoints.cxx index f26cd8a4f6..875d6e8909 100644 --- a/pandatool/src/lwo/lwoPoints.cxx +++ b/pandatool/src/lwo/lwoPoints.cxx @@ -1,16 +1,15 @@ -// Filename: lwoPoints.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPoints.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoPoints.h" #include "lwoInputFile.h" @@ -20,37 +19,29 @@ TypeHandle LwoPoints::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoPoints::get_num_points -// Access: Public -// Description: Returns the number of points of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of points of this group. + */ int LwoPoints:: get_num_points() const { return _points.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoPoints::get_point -// Access: Public -// Description: Returns the nth point of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth point of this group. + */ const LPoint3 &LwoPoints:: get_point(int n) const { nassertr(n >= 0 && n < (int)_points.size(), LPoint3::zero()); return _points[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LwoPoints::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoPoints:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -63,11 +54,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return (lin->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoPoints::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoPoints:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoPoints.h b/pandatool/src/lwo/lwoPoints.h index 56ab9d981a..5cc44bebca 100644 --- a/pandatool/src/lwo/lwoPoints.h +++ b/pandatool/src/lwo/lwoPoints.h @@ -1,16 +1,15 @@ -// Filename: lwoPoints.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPoints.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOPOINTS_H #define LWOPOINTS_H @@ -21,11 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoPoints -// Description : An array of points that will be referenced by later -// chunks. -//////////////////////////////////////////////////////////////////// +/** + * An array of points that will be referenced by later chunks. + */ class LwoPoints : public LwoChunk { public: int get_num_points() const; @@ -58,5 +55,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoPolygonTags.cxx b/pandatool/src/lwo/lwoPolygonTags.cxx index 537a82cf6b..aef4b051aa 100644 --- a/pandatool/src/lwo/lwoPolygonTags.cxx +++ b/pandatool/src/lwo/lwoPolygonTags.cxx @@ -1,16 +1,15 @@ -// Filename: lwoPolygonTags.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPolygonTags.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoPolygonTags.h" #include "lwoInputFile.h" @@ -21,23 +20,19 @@ TypeHandle LwoPolygonTags::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygonTags::has_tag -// Access: Public -// Description: Returns true if the map has a tag associated with -// the given polygon index, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the map has a tag associated with the given polygon index, + * false otherwise. + */ bool LwoPolygonTags:: has_tag(int polygon_index) const { return (_tmap.count(polygon_index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygonTags::get_tag -// Access: Public -// Description: Returns the tag associated with the given polygon -// index, or -1 if there is no tag associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the tag associated with the given polygon index, or -1 if there is + * no tag associated. + */ int LwoPolygonTags:: get_tag(int polygon_index) const { TMap::const_iterator ti; @@ -49,16 +44,12 @@ get_tag(int polygon_index) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygonTags::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoPolygonTags:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -78,11 +69,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return (lin->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygonTags::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoPolygonTags:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoPolygonTags.h b/pandatool/src/lwo/lwoPolygonTags.h index f4f5d36e85..bd93f1d524 100644 --- a/pandatool/src/lwo/lwoPolygonTags.h +++ b/pandatool/src/lwo/lwoPolygonTags.h @@ -1,16 +1,15 @@ -// Filename: lwoPolygonTags.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPolygonTags.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOPOLYGONTAGS_H #define LWOPOLYGONTAGS_H @@ -19,13 +18,11 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoPolygonTags -// Description : An association of polygons defined in the most recent -// LwoPolygons chunk to tag ids defined in the most -// recent LwoTags chunk. This associated properties -// with the polygons, depending on the tag_type. -//////////////////////////////////////////////////////////////////// +/** + * An association of polygons defined in the most recent LwoPolygons chunk to + * tag ids defined in the most recent LwoTags chunk. This associated + * properties with the polygons, depending on the tag_type. + */ class LwoPolygonTags : public LwoChunk { public: bool has_tag(int polygon_index) const; @@ -60,5 +57,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoPolygons.cxx b/pandatool/src/lwo/lwoPolygons.cxx index a1bc3749a2..76736c4f41 100644 --- a/pandatool/src/lwo/lwoPolygons.cxx +++ b/pandatool/src/lwo/lwoPolygons.cxx @@ -1,16 +1,15 @@ -// Filename: lwoPolygons.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPolygons.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoPolygons.h" #include "lwoInputFile.h" @@ -20,44 +19,36 @@ TypeHandle LwoPolygons::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygons::get_num_polygons -// Access: Public -// Description: Returns the number of polygons of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of polygons of this group. + */ int LwoPolygons:: get_num_polygons() const { return _polygons.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygons::get_polygon -// Access: Public -// Description: Returns the nth polygon of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth polygon of this group. + */ LwoPolygons::Polygon *LwoPolygons:: get_polygon(int n) const { nassertr(n >= 0 && n < (int)_polygons.size(), (Polygon *)NULL); return _polygons[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygons::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoPolygons:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); if (lin->get_lwo_version() >= 6.0) { - // 6.x style syntax: - // POLS { type[ID4], ( numvert+flags[U2], vert[VX] # numvert )* } + // 6.x style syntax: POLS { type[ID4], ( numvert+flags[U2], vert[VX] # + // numvert )* } _polygon_type = lin->get_id(); @@ -78,8 +69,8 @@ read_iff(IffInputFile *in, size_t stop_at) { } } else { - // 5.x style syntax: - // POLS { ( numvert[U2], vert[VX] # numvert, +/-(surf+1)[I2], numdetail[U2]? )* } + // 5.x style syntax: POLS { ( numvert[U2], vert[VX] # numvert, + // +-(surf+1)[I2], numdetail[U2]? )* } _polygon_type = IffId("FACE"); int num_decals = 0; @@ -108,8 +99,7 @@ read_iff(IffInputFile *in, size_t stop_at) { } } - // The surface index is stored +1 to allow signedness to be - // examined. + // The surface index is stored +1 to allow signedness to be examined. poly->_surface_index = surface - 1; _polygons.push_back(poly); @@ -119,11 +109,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoPolygons::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoPolygons:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoPolygons.h b/pandatool/src/lwo/lwoPolygons.h index 8c1e4e1f36..69d2d20e8b 100644 --- a/pandatool/src/lwo/lwoPolygons.h +++ b/pandatool/src/lwo/lwoPolygons.h @@ -1,16 +1,15 @@ -// Filename: lwoPolygons.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoPolygons.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOPOLYGONS_H #define LWOPOLYGONS_H @@ -24,11 +23,9 @@ #include "referenceCount.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoPolygons -// Description : An array of polygons that will be referenced by later -// chunks. -//////////////////////////////////////////////////////////////////// +/** + * An array of polygons that will be referenced by later chunks. + */ class LwoPolygons : public LwoChunk { public: enum PolygonFlags { @@ -36,9 +33,8 @@ public: PF_continuity_2 = 0x0800, PF_numverts_mask = 0x03f, - // This "flag" is stored artificially when reading 5.x LWOB files, - // and indicates that the polygon is a decal of a preceding - // polygon. + // This "flag" is stored artificially when reading 5.x LWOB files, and + // indicates that the polygon is a decal of a preceding polygon. PF_decal = 0x0001 }; @@ -47,10 +43,9 @@ public: int _flags; vector_int _vertices; - // This value is only filled in when reading 5.x LWOB files, and - // indicates the surface index of the polygon within a preceding - // SRFS (LwoTags) chunk. For 6.x and later files, this will be - // set to -1. + // This value is only filled in when reading 5.x LWOB files, and indicates + // the surface index of the polygon within a preceding SRFS (LwoTags) + // chunk. For 6.x and later files, this will be set to -1. int _surface_index; }; @@ -86,5 +81,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoStillImage.cxx b/pandatool/src/lwo/lwoStillImage.cxx index 0c09f0bd09..851aa6c8ef 100644 --- a/pandatool/src/lwo/lwoStillImage.cxx +++ b/pandatool/src/lwo/lwoStillImage.cxx @@ -1,16 +1,15 @@ -// Filename: lwoStillImage.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoStillImage.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoStillImage.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoStillImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoStillImage::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoStillImage:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoStillImage::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoStillImage:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoStillImage.h b/pandatool/src/lwo/lwoStillImage.h index 597e834622..c2dc02e4e2 100644 --- a/pandatool/src/lwo/lwoStillImage.h +++ b/pandatool/src/lwo/lwoStillImage.h @@ -1,16 +1,15 @@ -// Filename: lwoStillImage.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoStillImage.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSTILLIMAGE_H #define LWOSTILLIMAGE_H @@ -21,10 +20,9 @@ #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoStillImage -// Description : A single still image associated with a LwoClip chunk. -//////////////////////////////////////////////////////////////////// +/** + * A single still image associated with a LwoClip chunk. + */ class LwoStillImage : public LwoChunk { public: Filename _filename; @@ -52,5 +50,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurface.cxx b/pandatool/src/lwo/lwoSurface.cxx index eb5c608b93..edbc67506a 100644 --- a/pandatool/src/lwo/lwoSurface.cxx +++ b/pandatool/src/lwo/lwoSurface.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurface.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurface.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurface.h" #include "iffInputFile.h" @@ -24,16 +23,12 @@ TypeHandle LwoSurface::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurface::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurface:: read_iff(IffInputFile *in, size_t stop_at) { _name = in->get_string(); @@ -42,11 +37,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurface::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurface:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -58,13 +51,10 @@ write(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurface::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *LwoSurface:: make_new_chunk(IffInputFile *in, IffId id) { if (id == IffId("COLR")) { @@ -96,4 +86,3 @@ make_new_chunk(IffInputFile *in, IffId id) { return IffChunk::make_new_chunk(in, id); } } - diff --git a/pandatool/src/lwo/lwoSurface.h b/pandatool/src/lwo/lwoSurface.h index 73b3af9d50..96bb1f13d4 100644 --- a/pandatool/src/lwo/lwoSurface.h +++ b/pandatool/src/lwo/lwoSurface.h @@ -1,16 +1,15 @@ -// Filename: lwoSurface.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurface.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACE_H #define LWOSURFACE_H @@ -19,12 +18,10 @@ #include "lwoGroupChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurface -// Description : Describes the shading attributes of a surface. This -// is similar to the concept usually called a "material" -// or "shader" in other file formats. -//////////////////////////////////////////////////////////////////// +/** + * Describes the shading attributes of a surface. This is similar to the + * concept usually called a "material" or "shader" in other file formats. + */ class LwoSurface : public LwoGroupChunk { public: string _name; @@ -55,7 +52,3 @@ private: }; #endif - - - - diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index 4600f85f25..c1482bdb7d 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlock.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlock.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlock.h" #include "iffInputFile.h" @@ -28,16 +27,12 @@ TypeHandle LwoSurfaceBlock::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlock::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlock:: read_iff(IffInputFile *in, size_t stop_at) { PT(IffChunk) chunk = in->get_subchunk(this); @@ -55,11 +50,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlock::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlock:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -71,13 +64,10 @@ write(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlock::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *LwoSurfaceBlock:: make_new_chunk(IffInputFile *in, IffId id) { if (id == IffId("IMAP") || @@ -112,4 +102,3 @@ make_new_chunk(IffInputFile *in, IffId id) { return IffChunk::make_new_chunk(in, id); } } - diff --git a/pandatool/src/lwo/lwoSurfaceBlock.h b/pandatool/src/lwo/lwoSurfaceBlock.h index 57a31428b9..acd45a1dd9 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.h +++ b/pandatool/src/lwo/lwoSurfaceBlock.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlock.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlock.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCK_H #define LWOSURFACEBLOCK_H @@ -20,11 +19,9 @@ #include "lwoGroupChunk.h" #include "lwoSurfaceBlockHeader.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlock -// Description : A texture layer or shader, part of a LwoSurface -// chunk. -//////////////////////////////////////////////////////////////////// +/** + * A texture layer or shader, part of a LwoSurface chunk. + */ class LwoSurfaceBlock : public LwoGroupChunk { public: virtual bool read_iff(IffInputFile *in, size_t stop_at); @@ -39,7 +36,3 @@ private: }; #endif - - - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx index c932e9d68a..8698e9dea5 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockAxis.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockAxis.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockAxis.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockAxis::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockAxis::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockAxis:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockAxis::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockAxis:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.h b/pandatool/src/lwo/lwoSurfaceBlockAxis.h index c5c4918f3d..81633ed066 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockAxis.h +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockAxis.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockAxis.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKAXIS_H #define LWOSURFACEBLOCKAXIS_H @@ -19,13 +18,11 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockAxis -// Description : Indicates the axis for this particular shader's -// projection. This works in conjunction with -// LwoSurfaceBlockProjection. This is a subchunk of -// LwoSurfaceBlock. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the axis for this particular shader's projection. This works in + * conjunction with LwoSurfaceBlockProjection. This is a subchunk of + * LwoSurfaceBlock. + */ class LwoSurfaceBlockAxis : public LwoChunk { public: enum Axis { @@ -58,5 +55,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx index 1dd932acc9..523b379e4b 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockChannel.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockChannel.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockChannel.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockChannel::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockChannel::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockChannel:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockChannel::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockChannel:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.h b/pandatool/src/lwo/lwoSurfaceBlockChannel.h index 588f22cbd9..0849d185a1 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockChannel.h +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockChannel.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockChannel.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKCHANNEL_H #define LWOSURFACEBLOCKCHANNEL_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockChannel -// Description : Indicates which channel the texture in this -// LwoSurfaceBlock is applied to. This is a subchunk of -// LwoSurfaceBlockHeader. -//////////////////////////////////////////////////////////////////// +/** + * Indicates which channel the texture in this LwoSurfaceBlock is applied to. + * This is a subchunk of LwoSurfaceBlockHeader. + */ class LwoSurfaceBlockChannel : public LwoChunk { public: IffId _channel_id; @@ -52,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx index 31f6e2167c..4e1e3f0766 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockCoordSys.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockCoordSys.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockCoordSys.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockCoordSys::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockCoordSys::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockCoordSys:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockCoordSys::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockCoordSys:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h index beee74ce39..4c9d777ff3 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockCoordSys.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockCoordSys.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKCOORDSYS_H #define LWOSURFACEBLOCKCOORDSYS_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockCoordSys -// Description : Specifies whether texture coordinates are computed -// based on the vertices' world coordinates or local -// coordinates. -//////////////////////////////////////////////////////////////////// +/** + * Specifies whether texture coordinates are computed based on the vertices' + * world coordinates or local coordinates. + */ class LwoSurfaceBlockCoordSys : public LwoChunk { public: enum Type { @@ -57,5 +54,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx index f96f04ebda..c4d01dd557 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockEnabled.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockEnabled.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockEnabled.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockEnabled::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockEnabled::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockEnabled:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockEnabled::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockEnabled:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.h b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h index 98a3a29b05..59c42165e9 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockEnabled.h +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockEnabled.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockEnabled.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKENABLED_H #define LWOSURFACEBLOCKENABLED_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockEnabled -// Description : Indicates whether this particular layer or shader -// should be rendered or not. This is a subchunk of -// LwoSurfaceBlockHeader. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether this particular layer or shader should be rendered or + * not. This is a subchunk of LwoSurfaceBlockHeader. + */ class LwoSurfaceBlockEnabled : public LwoChunk { public: bool _enabled; @@ -52,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx index b696f0db14..a4a88d982a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockHeader.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockHeader.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockHeader.h" #include "lwoInputFile.h" @@ -24,16 +23,12 @@ TypeHandle LwoSurfaceBlockHeader::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockHeader::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockHeader:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -44,11 +39,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockHeader::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockHeader:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -68,13 +61,10 @@ write(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockHeader::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *LwoSurfaceBlockHeader:: make_new_chunk(IffInputFile *in, IffId id) { if (id == IffId("CHAN")) { @@ -93,4 +83,3 @@ make_new_chunk(IffInputFile *in, IffId id) { return IffChunk::make_new_chunk(in, id); } } - diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.h b/pandatool/src/lwo/lwoSurfaceBlockHeader.h index 7cb46c46c0..4ae37b45a5 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.h +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockHeader.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockHeader.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKHEADER_H #define LWOSURFACEBLOCKHEADER_H @@ -19,10 +18,9 @@ #include "lwoGroupChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockHeader -// Description : The header chunk within a LwoSurfaceBlock chunk. -//////////////////////////////////////////////////////////////////// +/** + * The header chunk within a LwoSurfaceBlock chunk. + */ class LwoSurfaceBlockHeader : public LwoGroupChunk { public: string _ordinal; @@ -52,7 +50,3 @@ private: }; #endif - - - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx index 5ff2f653fe..dce817b6aa 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockImage.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockImage.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockImage.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockImage::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockImage:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockImage::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockImage:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.h b/pandatool/src/lwo/lwoSurfaceBlockImage.h index bb8334a6e2..b7710d7561 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockImage.h +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockImage.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockImage.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKIMAGE_H #define LWOSURFACEBLOCKIMAGE_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockImage -// Description : Specifies the particular image that is being applied -// as a texture. This references a recently-defined -// CLIP image by index number. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the particular image that is being applied as a texture. This + * references a recently-defined CLIP image by index number. + */ class LwoSurfaceBlockImage : public LwoChunk { public: int _index; @@ -52,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx index ea3eb33678..d6554d0b82 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockOpacity.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockOpacity.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockOpacity.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockOpacity::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockOpacity::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockOpacity:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -41,11 +36,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockOpacity::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockOpacity:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h index dd2dbb4046..e923eb538b 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockOpacity.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockOpacity.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKOPACITY_H #define LWOSURFACEBLOCKOPACITY_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockOpacity -// Description : Indicates how transparent or opaque this particular -// layer is in relation to the layers beneath it. This -// is a subchunk of LwoSurfaceBlockHeader. -//////////////////////////////////////////////////////////////////// +/** + * Indicates how transparent or opaque this particular layer is in relation to + * the layers beneath it. This is a subchunk of LwoSurfaceBlockHeader. + */ class LwoSurfaceBlockOpacity : public LwoChunk { public: enum Type { @@ -64,5 +61,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx index 9ff9356e7f..2f6d214177 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockProjection.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockProjection.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockProjection.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockProjection::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockProjection::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockProjection:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockProjection::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockProjection:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.h b/pandatool/src/lwo/lwoSurfaceBlockProjection.h index 6ba8222f4e..49c816f156 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockProjection.h +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockProjection.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockProjection.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKPROJECTION_H #define LWOSURFACEBLOCKPROJECTION_H @@ -19,13 +18,11 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockProjection -// Description : Indicates the projection mode for this particular -// shader. This determines how UV coordinates should be -// computed based on the vertex positions. This is a -// subchunk of LwoSurfaceBlock. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the projection mode for this particular shader. This determines + * how UV coordinates should be computed based on the vertex positions. This + * is a subchunk of LwoSurfaceBlock. + */ class LwoSurfaceBlockProjection : public LwoChunk { public: enum Mode { @@ -61,5 +58,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx index f763d43455..d7dccc5693 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockRefObj.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockRefObj.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockRefObj.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockRefObj::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockRefObj::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockRefObj:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockRefObj::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockRefObj:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.h b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h index 6473ef6f33..65b70a958b 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRefObj.h +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockRefObj.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockRefObj.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKREFOBJ_H #define LWOSURFACEBLOCKREFOBJ_H @@ -19,11 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockRefObj -// Description : Specifies a reference object that the texture UV's -// are to be computed relative to. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a reference object that the texture UV's are to be computed + * relative to. + */ class LwoSurfaceBlockRefObj : public LwoChunk { public: string _name; @@ -51,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx index 01f0989d42..e264667caa 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockRepeat.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockRepeat.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockRepeat.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockRepeat::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockRepeat::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockRepeat:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockRepeat::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockRepeat:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h index 54ff8b2952..eb3beb251c 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockRepeat.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockRepeat.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKREPEAT_H #define LWOSURFACEBLOCKREPEAT_H @@ -19,14 +18,12 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockRepeat -// Description : For cylindrical and spherical projections, this -// parameter controls how many times the image repeats -// over each full interval, in either dimension. The -// dimension is specified by the id of the chunk, either -// WRPW or WRPH. This is a subchunk of LwoSurfaceBlock. -//////////////////////////////////////////////////////////////////// +/** + * For cylindrical and spherical projections, this parameter controls how many + * times the image repeats over each full interval, in either dimension. The + * dimension is specified by the id of the chunk, either WRPW or WRPH. This + * is a subchunk of LwoSurfaceBlock. + */ class LwoSurfaceBlockRepeat : public LwoChunk { public: PN_stdfloat _cycles; @@ -55,5 +52,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx index 7ed304a4a1..f404910611 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockTMap.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockTMap.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockTMap.h" #include "lwoInputFile.h" @@ -23,16 +22,12 @@ TypeHandle LwoSurfaceBlockTMap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockTMap::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockTMap:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -42,11 +37,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockTMap::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockTMap:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -56,13 +49,10 @@ write(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockTMap::make_new_chunk -// Access: Protected, Virtual -// Description: Allocates and returns a new chunk of the appropriate -// type based on the given ID, according to the context -// given by this chunk itself. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new chunk of the appropriate type based on the + * given ID, according to the context given by this chunk itself. + */ IffChunk *LwoSurfaceBlockTMap:: make_new_chunk(IffInputFile *in, IffId id) { if (id == IffId("CNTR") || @@ -80,4 +70,3 @@ make_new_chunk(IffInputFile *in, IffId id) { return IffChunk::make_new_chunk(in, id); } } - diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.h b/pandatool/src/lwo/lwoSurfaceBlockTMap.h index cd83c8bda4..8da9841f46 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.h +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockTMap.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockTMap.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKTMAP_H #define LWOSURFACEBLOCKTMAP_H @@ -19,10 +18,9 @@ #include "lwoGroupChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockTMap -// Description : The tMap chunk within a LwoSurfaceBlock chunk. -//////////////////////////////////////////////////////////////////// +/** + * The tMap chunk within a LwoSurfaceBlock chunk. + */ class LwoSurfaceBlockTMap : public LwoGroupChunk { public: virtual bool read_iff(IffInputFile *in, size_t stop_at); @@ -49,7 +47,3 @@ private: }; #endif - - - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx index 020c36aa90..e2fdccad18 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockTransform.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockTransform.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockTransform.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockTransform::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockTransform::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockTransform:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockTransform::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockTransform:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.h b/pandatool/src/lwo/lwoSurfaceBlockTransform.h index eb03e64beb..f8fce53163 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTransform.h +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockTransform.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockTransform.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKTRANSFORM_H #define LWOSURFACEBLOCKTRANSFORM_H @@ -21,14 +20,12 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockTransform -// Description : Specifies a center point, scale, or rotation for the -// texture coordinates in this shader's texture mapping. -// The type of transform is specified by the ID of the -// chunk; either CNTR, SIZE, or ROTA. This is a -// subchunk of LwoSurfaceBlockTMap. -//////////////////////////////////////////////////////////////////// +/** + * Specifies a center point, scale, or rotation for the texture coordinates in + * this shader's texture mapping. The type of transform is specified by the + * ID of the chunk; either CNTR, SIZE, or ROTA. This is a subchunk of + * LwoSurfaceBlockTMap. + */ class LwoSurfaceBlockTransform : public LwoChunk { public: LVecBase3 _vec; @@ -57,5 +54,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx index c83e322472..208f309e4c 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockVMapName.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockVMapName.cxx -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockVMapName.cxx + * @author drose + * @date 2001-04-30 + */ #include "lwoSurfaceBlockVMapName.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockVMapName::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockVMapName::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockVMapName:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockVMapName::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockVMapName:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockVMapName.h b/pandatool/src/lwo/lwoSurfaceBlockVMapName.h index 6bf616257a..30de8f3ad6 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockVMapName.h +++ b/pandatool/src/lwo/lwoSurfaceBlockVMapName.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockVMapName.h -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockVMapName.h + * @author drose + * @date 2001-04-30 + */ #ifndef LWOSURFACEBLOCKVMAPNAME_H #define LWOSURFACEBLOCKVMAPNAME_H @@ -19,11 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockVMapName -// Description : Specifies the name of a set of UV's defined on the -// polygons that use this model. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the name of a set of UV's defined on the polygons that use this + * model. + */ class LwoSurfaceBlockVMapName : public LwoChunk { public: string _name; @@ -51,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx index b16f7558cc..ec7cc24796 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockWrap.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockWrap.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceBlockWrap.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceBlockWrap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockWrap::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceBlockWrap:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceBlockWrap::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceBlockWrap:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.h b/pandatool/src/lwo/lwoSurfaceBlockWrap.h index 6e72298931..b046657242 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockWrap.h +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceBlockWrap.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceBlockWrap.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEBLOCKWRAP_H #define LWOSURFACEBLOCKWRAP_H @@ -19,11 +18,9 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceBlockWrap -// Description : Specifies how the texture image appears for areas -// outside the image. -//////////////////////////////////////////////////////////////////// +/** + * Specifies how the texture image appears for areas outside the image. + */ class LwoSurfaceBlockWrap : public LwoChunk { public: enum Mode { @@ -57,5 +54,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceColor.cxx b/pandatool/src/lwo/lwoSurfaceColor.cxx index 695c5669e4..ceeb5ab747 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.cxx +++ b/pandatool/src/lwo/lwoSurfaceColor.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceColor.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceColor.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceColor.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceColor::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceColor::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceColor:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceColor::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceColor:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceColor.h b/pandatool/src/lwo/lwoSurfaceColor.h index 0dc32e864f..77d0740665 100644 --- a/pandatool/src/lwo/lwoSurfaceColor.h +++ b/pandatool/src/lwo/lwoSurfaceColor.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceColor.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceColor.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACECOLOR_H #define LWOSURFACECOLOR_H @@ -21,11 +20,9 @@ #include "luse.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceColor -// Description : Records the base color of a surface, as an entry -// within a LwoSurface chunk. -//////////////////////////////////////////////////////////////////// +/** + * Records the base color of a surface, as an entry within a LwoSurface chunk. + */ class LwoSurfaceColor : public LwoChunk { public: LRGBColor _color; @@ -54,5 +51,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceParameter.cxx b/pandatool/src/lwo/lwoSurfaceParameter.cxx index f2de5782e7..f1ff64203b 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.cxx +++ b/pandatool/src/lwo/lwoSurfaceParameter.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceParameter.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceParameter.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceParameter.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceParameter::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceParameter::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceParameter:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceParameter::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceParameter:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceParameter.h b/pandatool/src/lwo/lwoSurfaceParameter.h index 6fcc10ab84..70a6188f40 100644 --- a/pandatool/src/lwo/lwoSurfaceParameter.h +++ b/pandatool/src/lwo/lwoSurfaceParameter.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceParameter.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceParameter.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACEPARAMETER_H #define LWOSURFACEPARAMETER_H @@ -19,12 +18,11 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceParameter -// Description : Records some parameter value of a surface material, -// as an entry within a LwoSurface chunk. The meaning -// of the value is determined by the id of this chunk. -//////////////////////////////////////////////////////////////////// +/** + * Records some parameter value of a surface material, as an entry within a + * LwoSurface chunk. The meaning of the value is determined by the id of this + * chunk. + */ class LwoSurfaceParameter : public LwoChunk { public: PN_stdfloat _value; @@ -53,5 +51,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.cxx b/pandatool/src/lwo/lwoSurfaceSidedness.cxx index 6a3ee1a40c..b67c1492be 100644 --- a/pandatool/src/lwo/lwoSurfaceSidedness.cxx +++ b/pandatool/src/lwo/lwoSurfaceSidedness.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceSidedness.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceSidedness.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceSidedness.h" #include "lwoInputFile.h" @@ -20,16 +19,12 @@ TypeHandle LwoSurfaceSidedness::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceSidedness::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceSidedness:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -39,11 +34,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceSidedness::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceSidedness:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceSidedness.h b/pandatool/src/lwo/lwoSurfaceSidedness.h index c3eeae2eff..cb8c75ebb2 100644 --- a/pandatool/src/lwo/lwoSurfaceSidedness.h +++ b/pandatool/src/lwo/lwoSurfaceSidedness.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceSidedness.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceSidedness.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACESIDEDNESS_H #define LWOSURFACESIDEDNESS_H @@ -19,12 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceSidedness -// Description : Records whether polygons are frontfacing only or -// backfacing also. This is associated with the -// LwoSurface chunk. -//////////////////////////////////////////////////////////////////// +/** + * Records whether polygons are frontfacing only or backfacing also. This is + * associated with the LwoSurface chunk. + */ class LwoSurfaceSidedness : public LwoChunk { public: enum Sidedness { @@ -57,5 +54,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx index a6666a76c5..1b0570c46b 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.cxx @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceSmoothingAngle.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceSmoothingAngle.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoSurfaceSmoothingAngle.h" #include "lwoInputFile.h" @@ -21,16 +20,12 @@ TypeHandle LwoSurfaceSmoothingAngle::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceSmoothingAngle::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoSurfaceSmoothingAngle:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -40,11 +35,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoSurfaceSmoothingAngle::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoSurfaceSmoothingAngle:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h index 88e464e6b6..97600b80aa 100644 --- a/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h +++ b/pandatool/src/lwo/lwoSurfaceSmoothingAngle.h @@ -1,16 +1,15 @@ -// Filename: lwoSurfaceSmoothingAngle.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoSurfaceSmoothingAngle.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOSURFACESMOOTHINGANGLE_H #define LWOSURFACESMOOTHINGANGLE_H @@ -19,11 +18,10 @@ #include "lwoChunk.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoSurfaceSmoothingAngle -// Description : Indicates the maximum angle (in radians) between -// adjacent polygons that should be smooth-shaded. -//////////////////////////////////////////////////////////////////// +/** + * Indicates the maximum angle (in radians) between adjacent polygons that + * should be smooth-shaded. + */ class LwoSurfaceSmoothingAngle : public LwoChunk { public: PN_stdfloat _angle; @@ -51,5 +49,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoTags.cxx b/pandatool/src/lwo/lwoTags.cxx index 8b265ea165..c2d9ebbc8d 100644 --- a/pandatool/src/lwo/lwoTags.cxx +++ b/pandatool/src/lwo/lwoTags.cxx @@ -1,16 +1,15 @@ -// Filename: lwoTags.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoTags.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoTags.h" #include "lwoInputFile.h" @@ -20,37 +19,29 @@ TypeHandle LwoTags::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoTags::get_num_tags -// Access: Public -// Description: Returns the number of tags of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of tags of this group. + */ int LwoTags:: get_num_tags() const { return _tags.size(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoTags::get_tag -// Access: Public -// Description: Returns the nth tag of this group. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth tag of this group. + */ string LwoTags:: get_tag(int n) const { nassertr(n >= 0 && n < (int)_tags.size(), string()); return _tags[n]; } -//////////////////////////////////////////////////////////////////// -// Function: LwoTags::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoTags:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -63,11 +54,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return (lin->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoTags::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoTags:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoTags.h b/pandatool/src/lwo/lwoTags.h index 8d29d7aaa6..5812965be6 100644 --- a/pandatool/src/lwo/lwoTags.h +++ b/pandatool/src/lwo/lwoTags.h @@ -1,16 +1,15 @@ -// Filename: lwoTags.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoTags.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOTAGS_H #define LWOTAGS_H @@ -22,16 +21,13 @@ #include "luse.h" #include "vector_string.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoTags -// Description : An array of tag strings that will be referenced by -// later chunks. -// -// This also serves as an array of surface names to be -// referenced by a later LwoPolygons chunk, in 5.x LWOB -// files. The chunk id can be used to differentiate the -// meaning (TAGS vs. SRFS). -//////////////////////////////////////////////////////////////////// +/** + * An array of tag strings that will be referenced by later chunks. + * + * This also serves as an array of surface names to be referenced by a later + * LwoPolygons chunk, in 5.x LWOB files. The chunk id can be used to + * differentiate the meaning (TAGS vs. SRFS). + */ class LwoTags : public LwoChunk { public: int get_num_tags() const; @@ -64,5 +60,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/lwoVertexMap.cxx b/pandatool/src/lwo/lwoVertexMap.cxx index ea517bfb31..396ab91b33 100644 --- a/pandatool/src/lwo/lwoVertexMap.cxx +++ b/pandatool/src/lwo/lwoVertexMap.cxx @@ -1,16 +1,15 @@ -// Filename: lwoVertexMap.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoVertexMap.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoVertexMap.h" #include "lwoInputFile.h" @@ -21,24 +20,19 @@ TypeHandle LwoVertexMap::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LwoVertexMap::has_value -// Access: Public -// Description: Returns true if the map has a value associated with -// the given index, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the map has a value associated with the given index, false + * otherwise. + */ bool LwoVertexMap:: has_value(int index) const { return (_vmap.count(index) != 0); } -//////////////////////////////////////////////////////////////////// -// Function: LwoVertexMap::get_value -// Access: Public -// Description: Returns the mapping value associated with the given -// index, or an empty PTA_stdfloat if there is no mapping -// value associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the mapping value associated with the given index, or an empty + * PTA_stdfloat if there is no mapping value associated. + */ PTA_stdfloat LwoVertexMap:: get_value(int index) const { VMap::const_iterator vi; @@ -50,16 +44,12 @@ get_value(int index) const { return PTA_stdfloat(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoVertexMap::read_iff -// Access: Public, Virtual -// Description: Reads the data of the chunk in from the given input -// file, if possible. The ID and length of the chunk -// have already been read. stop_at is the byte position -// of the file to stop at (based on the current position -// at in->get_bytes_read()). Returns true on success, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the data of the chunk in from the given input file, if possible. The + * ID and length of the chunk have already been read. stop_at is the byte + * position of the file to stop at (based on the current position at + * in->get_bytes_read()). Returns true on success, false otherwise. + */ bool LwoVertexMap:: read_iff(IffInputFile *in, size_t stop_at) { LwoInputFile *lin = DCAST(LwoInputFile, in); @@ -85,11 +75,9 @@ read_iff(IffInputFile *in, size_t stop_at) { return (lin->get_bytes_read() == stop_at); } -//////////////////////////////////////////////////////////////////// -// Function: LwoVertexMap::write -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoVertexMap:: write(ostream &out, int indent_level) const { indent(out, indent_level) diff --git a/pandatool/src/lwo/lwoVertexMap.h b/pandatool/src/lwo/lwoVertexMap.h index ef96bdc6da..abbcc0f3cc 100644 --- a/pandatool/src/lwo/lwoVertexMap.h +++ b/pandatool/src/lwo/lwoVertexMap.h @@ -1,16 +1,15 @@ -// Filename: lwoVertexMap.h -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoVertexMap.h + * @author drose + * @date 2001-04-24 + */ #ifndef LWOVERTEXMAP_H #define LWOVERTEXMAP_H @@ -21,12 +20,10 @@ #include "pta_stdfloat.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoVertexMap -// Description : A mapping of floating-point values per integer index. -// The meaning of these values is determined by the -// mapping type code and/or its name. -//////////////////////////////////////////////////////////////////// +/** + * A mapping of floating-point values per integer index. The meaning of these + * values is determined by the mapping type code and/or its name. + */ class LwoVertexMap : public LwoChunk { public: bool has_value(int index) const; @@ -63,5 +60,3 @@ private: }; #endif - - diff --git a/pandatool/src/lwo/test_lwo.cxx b/pandatool/src/lwo/test_lwo.cxx index f2a1a9e22b..3d06358ef5 100644 --- a/pandatool/src/lwo/test_lwo.cxx +++ b/pandatool/src/lwo/test_lwo.cxx @@ -1,16 +1,15 @@ -// Filename: test_lwo.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_lwo.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoInputFile.h" #include "lwoChunk.h" diff --git a/pandatool/src/lwoegg/cLwoClip.I b/pandatool/src/lwoegg/cLwoClip.I index 43f2f24e1a..8b2e4ccbea 100644 --- a/pandatool/src/lwoegg/cLwoClip.I +++ b/pandatool/src/lwoegg/cLwoClip.I @@ -1,37 +1,30 @@ -// Filename: cLwoClip.I -// Created by: drose (27Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoClip.I + * @author drose + * @date 2001-04-27 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLwoClip::get_index -// Access: Public -// Description: Returns the index number of this clip. Each clip in -// a Lightwave object file should have a unique index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of this clip. Each clip in a Lightwave object + * file should have a unique index number. + */ int CLwoClip:: get_index() const { return _clip->_index; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoClip::is_still_image -// Access: Public -// Description: Returns true if this clip represents a still image, -// as opposed to an animated image. If this is true, -// _filename will contain the image filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this clip represents a still image, as opposed to an + * animated image. If this is true, _filename will contain the image + * filename. + */ bool CLwoClip:: is_still_image() const { return _still_image; diff --git a/pandatool/src/lwoegg/cLwoClip.cxx b/pandatool/src/lwoegg/cLwoClip.cxx index be77f361c9..4285013398 100644 --- a/pandatool/src/lwoegg/cLwoClip.cxx +++ b/pandatool/src/lwoegg/cLwoClip.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoClip.cxx -// Created by: drose (27Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoClip.cxx + * @author drose + * @date 2001-04-27 + */ #include "cLwoClip.h" #include "lwoToEggConverter.h" @@ -20,11 +19,9 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoClip::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoClip:: CLwoClip(LwoToEggConverter *converter, const LwoClip *clip) : _converter(converter), diff --git a/pandatool/src/lwoegg/cLwoClip.h b/pandatool/src/lwoegg/cLwoClip.h index e465a2c913..118d883c02 100644 --- a/pandatool/src/lwoegg/cLwoClip.h +++ b/pandatool/src/lwoegg/cLwoClip.h @@ -1,16 +1,15 @@ -// Filename: cLwoClip.h -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoClip.h + * @author drose + * @date 2001-04-26 + */ #ifndef CLWOCLIP_H #define CLWOCLIP_H @@ -23,12 +22,10 @@ class LwoToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : CLwoClip -// Description : This class is a wrapper around LwoClip and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoClip and stores additional information + * useful during the conversion-to-egg process. + */ class CLwoClip { public: CLwoClip(LwoToEggConverter *converter, const LwoClip *clip); @@ -46,5 +43,3 @@ public: #include "cLwoClip.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoLayer.I b/pandatool/src/lwoegg/cLwoLayer.I index 90f450d575..56f8a4b504 100644 --- a/pandatool/src/lwoegg/cLwoLayer.I +++ b/pandatool/src/lwoegg/cLwoLayer.I @@ -1,23 +1,19 @@ -// Filename: cLwoLayer.I -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoLayer.I + * @author drose + * @date 2001-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLwoLayer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLwoLayer:: CLwoLayer(LwoToEggConverter *converter, const LwoLayer *layer) : _converter(converter), @@ -25,13 +21,10 @@ CLwoLayer(LwoToEggConverter *converter, const LwoLayer *layer) : { } -//////////////////////////////////////////////////////////////////// -// Function: CLwoLayer::get_number -// Access: Public -// Description: Returns the index number associated with this -// particular layer. This should be unique among all -// Lightwave layers in a single file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number associated with this particular layer. This + * should be unique among all Lightwave layers in a single file. + */ INLINE int CLwoLayer:: get_number() const { return _layer->_number; diff --git a/pandatool/src/lwoegg/cLwoLayer.cxx b/pandatool/src/lwoegg/cLwoLayer.cxx index dda1916272..4794ef1429 100644 --- a/pandatool/src/lwoegg/cLwoLayer.cxx +++ b/pandatool/src/lwoegg/cLwoLayer.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoLayer.cxx -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoLayer.cxx + * @author drose + * @date 2001-04-25 + */ #include "cLwoLayer.h" #include "lwoToEggConverter.h" @@ -18,30 +17,24 @@ #include "eggData.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoLayer::make_egg -// Access: Public -// Description: Creates the egg structures associated with this -// Lightwave object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the egg structures associated with this Lightwave object. + */ void CLwoLayer:: make_egg() { _egg_group = new EggGroup(_layer->_name); if (_layer->_pivot != LPoint3::zero()) { - // If we have a nonzero pivot point, that's a translation - // transform. + // If we have a nonzero pivot point, that's a translation transform. LPoint3d translate = LCAST(double, _layer->_pivot); _egg_group->set_transform3d(LMatrix4d::translate_mat(translate)); _egg_group->set_group_type(EggGroup::GT_instance); } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoLayer::connect_egg -// Access: Public -// Description: Connects all the egg structures together. -//////////////////////////////////////////////////////////////////// +/** + * Connects all the egg structures together. + */ void CLwoLayer:: connect_egg() { if (_layer->_parent != -1) { @@ -57,4 +50,3 @@ connect_egg() { _converter->get_egg_data()->add_child(_egg_group.p()); } - diff --git a/pandatool/src/lwoegg/cLwoLayer.h b/pandatool/src/lwoegg/cLwoLayer.h index fc4a01fd2d..568654ff6e 100644 --- a/pandatool/src/lwoegg/cLwoLayer.h +++ b/pandatool/src/lwoegg/cLwoLayer.h @@ -1,16 +1,15 @@ -// Filename: cLwoLayer.h -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoLayer.h + * @author drose + * @date 2001-04-25 + */ #ifndef CLWOLAYER_H #define CLWOLAYER_H @@ -23,12 +22,10 @@ class LwoToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : CLwoLayer -// Description : This class is a wrapper around LwoLayer and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoLayer and stores additional information + * useful during the conversion-to-egg process. + */ class CLwoLayer { public: INLINE CLwoLayer(LwoToEggConverter *converter, const LwoLayer *layer); @@ -45,5 +42,3 @@ public: #include "cLwoLayer.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoPoints.I b/pandatool/src/lwoegg/cLwoPoints.I index 06cc7c7d68..2d785c07be 100644 --- a/pandatool/src/lwoegg/cLwoPoints.I +++ b/pandatool/src/lwoegg/cLwoPoints.I @@ -1,23 +1,19 @@ -// Filename: cLwoPoints.I -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPoints.I + * @author drose + * @date 2001-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLwoPoints::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLwoPoints:: CLwoPoints(LwoToEggConverter *converter, const LwoPoints *points, CLwoLayer *layer) : diff --git a/pandatool/src/lwoegg/cLwoPoints.cxx b/pandatool/src/lwoegg/cLwoPoints.cxx index 0b8e6e1319..43f48ee690 100644 --- a/pandatool/src/lwoegg/cLwoPoints.cxx +++ b/pandatool/src/lwoegg/cLwoPoints.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoPoints.cxx -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPoints.cxx + * @author drose + * @date 2001-04-25 + */ #include "cLwoPoints.h" #include "lwoToEggConverter.h" @@ -20,13 +19,10 @@ #include "lwoVertexMap.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoPoints::add_vmap -// Access: Public -// Description: Associates the indicated VertexMap with the points -// set. This may define such niceties as UV coordinates -// or per-vertex color. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated VertexMap with the points set. This may define + * such niceties as UV coordinates or per-vertex color. + */ void CLwoPoints:: add_vmap(const LwoVertexMap *lwo_vmap) { IffId map_type = lwo_vmap->_map_type; @@ -51,13 +47,10 @@ add_vmap(const LwoVertexMap *lwo_vmap) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPoints::get_uv -// Access: Public -// Description: Returns true if there is a UV of the indicated name -// associated with the given vertex, false otherwise. -// If true, fills in uv with the value. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a UV of the indicated name associated with the + * given vertex, false otherwise. If true, fills in uv with the value. + */ bool CLwoPoints:: get_uv(const string &uv_name, int n, LPoint2 &uv) const { VMap::const_iterator ni = _txuv.find(uv_name); @@ -82,29 +75,23 @@ get_uv(const string &uv_name, int n, LPoint2 &uv) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPoints::make_egg -// Access: Public -// Description: Creates the egg structures associated with this -// Lightwave object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the egg structures associated with this Lightwave object. + */ void CLwoPoints:: make_egg() { - // Generate a vpool name based on the layer index, for lack of - // anything better. + // Generate a vpool name based on the layer index, for lack of anything + // better. string vpool_name = "layer" + format_string(_layer->get_number()); _egg_vpool = new EggVertexPool(vpool_name); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPoints::connect_egg -// Access: Public -// Description: Connects all the egg structures together. -//////////////////////////////////////////////////////////////////// +/** + * Connects all the egg structures together. + */ void CLwoPoints:: connect_egg() { if (!_egg_vpool->empty()) { _layer->_egg_group->add_child(_egg_vpool.p()); } } - diff --git a/pandatool/src/lwoegg/cLwoPoints.h b/pandatool/src/lwoegg/cLwoPoints.h index ec6298f634..b235c3de31 100644 --- a/pandatool/src/lwoegg/cLwoPoints.h +++ b/pandatool/src/lwoegg/cLwoPoints.h @@ -1,16 +1,15 @@ -// Filename: cLwoPoints.h -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPoints.h + * @author drose + * @date 2001-04-25 + */ #ifndef CLWOPOINTS_H #define CLWOPOINTS_H @@ -27,12 +26,10 @@ class LwoToEggConverter; class LwoVertexMap; class CLwoLayer; -//////////////////////////////////////////////////////////////////// -// Class : CLwoPoints -// Description : This class is a wrapper around LwoPoints and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoPoints and stores additional information + * useful during the conversion-to-egg process. + */ class CLwoPoints { public: INLINE CLwoPoints(LwoToEggConverter *converter, const LwoPoints *points, @@ -49,8 +46,8 @@ public: CLwoLayer *_layer; PT(EggVertexPool) _egg_vpool; - // A number of vertex maps of different types may be associated, but - // we only care about some of the types here. + // A number of vertex maps of different types may be associated, but we only + // care about some of the types here. typedef pmap VMap; VMap _txuv; VMap _pick; @@ -59,5 +56,3 @@ public: #include "cLwoPoints.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoPolygons.I b/pandatool/src/lwoegg/cLwoPolygons.I index 4d857c810f..691d706324 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.I +++ b/pandatool/src/lwoegg/cLwoPolygons.I @@ -1,23 +1,19 @@ -// Filename: cLwoPolygons.I -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPolygons.I + * @author drose + * @date 2001-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE CLwoPolygons:: CLwoPolygons(LwoToEggConverter *converter, const LwoPolygons *polygons, CLwoPoints *points) : diff --git a/pandatool/src/lwoegg/cLwoPolygons.cxx b/pandatool/src/lwoegg/cLwoPolygons.cxx index e659df7fb8..ad1f600a04 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.cxx +++ b/pandatool/src/lwoegg/cLwoPolygons.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoPolygons.cxx -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPolygons.cxx + * @author drose + * @date 2001-04-25 + */ #include "cLwoPolygons.h" #include "lwoToEggConverter.h" @@ -26,14 +25,11 @@ #include "eggPoint.h" #include "deg_2_rad.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::add_ptags -// Access: Public -// Description: Associates the indicated PolygonTags and Tags with -// the polygons in this chunk. This may define features -// such as per-polygon surfaces, parts, and smoothing -// groups. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated PolygonTags and Tags with the polygons in this + * chunk. This may define features such as per-polygon surfaces, parts, and + * smoothing groups. + */ void CLwoPolygons:: add_ptags(const LwoPolygonTags *lwo_ptags, const LwoTags *tags) { if (_tags != (LwoTags *)NULL && _tags != tags) { @@ -55,14 +51,11 @@ add_ptags(const LwoPolygonTags *lwo_ptags, const LwoTags *tags) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::add_vmad -// Access: Public -// Description: Associates the indicated DiscontinousVertexMap with -// the polygons. This can be used in conjunction with -// (or in place of) the VertexMap associated with the -// points set, to define per-polygon UV's etc. -//////////////////////////////////////////////////////////////////// +/** + * Associates the indicated DiscontinousVertexMap with the polygons. This can + * be used in conjunction with (or in place of) the VertexMap associated with + * the points set, to define per-polygon UV's etc. + */ void CLwoPolygons:: add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad) { IffId map_type = lwo_vmad->_map_type; @@ -83,12 +76,10 @@ add_vmad(const LwoDiscontinuousVertexMap *lwo_vmad) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::get_surface -// Access: Public -// Description: Returns the surface associated with the given -// polygon, or NULL if no surface is associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns the surface associated with the given polygon, or NULL if no + * surface is associated. + */ CLwoSurface *CLwoPolygons:: get_surface(int polygon_index) const { if (_surf_ptags == (LwoPolygonTags *)NULL) { @@ -121,21 +112,16 @@ get_surface(int polygon_index) const { return surface; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::get_uv -// Access: Public -// Description: Returns true if there is a UV of the indicated name -// associated with the given vertex of the indicated -// polygon, false otherwise. If true, fills in uv with -// the value. -// -// This performs a lookup in the optional -// "discontinuous" vertex mapping, which provides the -// ability to map different UV's per each polygon for -// the same vertex. If the UV is not defined here, it -// may also be defined in the standard vertex map, which -// is associated with the points themselves. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a UV of the indicated name associated with the + * given vertex of the indicated polygon, false otherwise. If true, fills in + * uv with the value. + * + * This performs a lookup in the optional "discontinuous" vertex mapping, + * which provides the ability to map different UV's per each polygon for the + * same vertex. If the UV is not defined here, it may also be defined in the + * standard vertex map, which is associated with the points themselves. + */ bool CLwoPolygons:: get_uv(const string &uv_name, int pi, int vi, LPoint2 &uv) const { VMad::const_iterator ni = _txuv.find(uv_name); @@ -160,16 +146,13 @@ get_uv(const string &uv_name, int pi, int vi, LPoint2 &uv) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::make_egg -// Access: Public -// Description: Creates the egg structures associated with this -// Lightwave object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the egg structures associated with this Lightwave object. + */ void CLwoPolygons:: make_egg() { - // First, we need a temporary group to hold all of the polygons - // we'll create. + // First, we need a temporary group to hold all of the polygons we'll + // create. _egg_group = new EggGroup; if (_polygons->_polygon_type == IffId("CURV")) { @@ -194,11 +177,9 @@ make_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::connect_egg -// Access: Public -// Description: Connects all the egg structures together. -//////////////////////////////////////////////////////////////////// +/** + * Connects all the egg structures together. + */ void CLwoPolygons:: connect_egg() { nassertv(_points->_layer->_egg_group != (EggGroup *)NULL); @@ -207,11 +188,9 @@ connect_egg() { } -//////////////////////////////////////////////////////////////////// -// Function: CLwoPolygons::make_faces -// Access: Public -// Description: Generates "face" polygons, i.e. actual polygons. -//////////////////////////////////////////////////////////////////// +/** + * Generates "face" polygons, i.e. actual polygons. + */ void CLwoPolygons:: make_faces() { PN_stdfloat smooth_angle = -1.0; @@ -228,10 +207,10 @@ make_faces() { int num_points = points->get_num_points(); EggVertexPool *egg_vpool = _points->_egg_vpool; - // We reverse the vertex ordering to compensate for Lightwave's - // clockwise ordering convention. We also want to start with the - // last vertex, so that the first convex angle is the first angle - // in the EggPolygon (for determining correct normals). + // We reverse the vertex ordering to compensate for Lightwave's clockwise + // ordering convention. We also want to start with the last vertex, so + // that the first convex angle is the first angle in the EggPolygon (for + // determining correct normals). PT(EggPrimitive) egg_prim; if (poly->_vertices.size() == 1) { @@ -241,8 +220,8 @@ make_faces() { } // First, we have to create a temporary vector of vertices for the - // polygon, so we can possibly adjust the properties of these - // vertices (like the UV's) in the shader before we create them. + // polygon, so we can possibly adjust the properties of these vertices + // (like the UV's) in the shader before we create them. vector_PT_EggVertex egg_vertices; int num_vertices = poly->_vertices.size(); @@ -261,13 +240,13 @@ make_faces() { string uv_name = surface->get_uv_name(); LPoint2 uv; if (get_uv(uv_name, pindex, vindex, uv)) { - // This UV is defined in a "discontinuous" map, that - // associated a particular UV per each polygon. + // This UV is defined in a "discontinuous" map, that associated a + // particular UV per each polygon. egg_vertex->set_uv(LCAST(double, uv)); } else if (_points->get_uv(uv_name, vindex, uv)) { - // The UV does not appear in a discontinuous map, but it - // is defined in the points set. + // The UV does not appear in a discontinuous map, but it is + // defined in the points set. egg_vertex->set_uv(LCAST(double, uv)); } } @@ -301,4 +280,3 @@ make_faces() { _egg_group->recompute_polygon_normals(cs); } } - diff --git a/pandatool/src/lwoegg/cLwoPolygons.h b/pandatool/src/lwoegg/cLwoPolygons.h index fb36f9ed8a..a11dc0987a 100644 --- a/pandatool/src/lwoegg/cLwoPolygons.h +++ b/pandatool/src/lwoegg/cLwoPolygons.h @@ -1,16 +1,15 @@ -// Filename: cLwoPolygons.h -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoPolygons.h + * @author drose + * @date 2001-04-25 + */ #ifndef CLWOPOLYGONS_H #define CLWOPOLYGONS_H @@ -30,12 +29,10 @@ class LwoTags; class LwoPolygonTags; class LwoDiscontinuousVertexMap; -//////////////////////////////////////////////////////////////////// -// Class : CLwoPolygons -// Description : This class is a wrapper around LwoPolygons and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoPolygons and stores additional + * information useful during the conversion-to-egg process. + */ class CLwoPolygons { public: INLINE CLwoPolygons(LwoToEggConverter *converter, @@ -62,8 +59,8 @@ public: const LwoPolygonTags *_surf_ptags; - // There might be named maps associated with the polygons to bring a - // per-polygon mapping to the UV's. + // There might be named maps associated with the polygons to bring a per- + // polygon mapping to the UV's. typedef pmap VMad; VMad _txuv; @@ -74,5 +71,3 @@ private: #include "cLwoPolygons.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoSurface.I b/pandatool/src/lwoegg/cLwoSurface.I index df2e355d35..80c4c2c3d6 100644 --- a/pandatool/src/lwoegg/cLwoSurface.I +++ b/pandatool/src/lwoegg/cLwoSurface.I @@ -1,51 +1,41 @@ -// Filename: cLwoSurface.I -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurface.I + * @author drose + * @date 2001-04-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::get_name -// Access: Public -// Description: Returns the name of the surface. Each surface in a -// given Lightwave file should have a unique name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the surface. Each surface in a given Lightwave file + * should have a unique name. + */ INLINE const string &CLwoSurface:: get_name() const { return _surface->_name; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::has_named_uvs -// Access: Public -// Description: Returns true if the surface is set up to reference -// UV's stored on the vertices, by name (as opposed to -// generated UV's, which is the more common Lightwave -// case). In this case, get_uv_name() can be called to -// return the name of the UV's. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the surface is set up to reference UV's stored on the + * vertices, by name (as opposed to generated UV's, which is the more common + * Lightwave case). In this case, get_uv_name() can be called to return the + * name of the UV's. + */ INLINE bool CLwoSurface:: has_named_uvs() const { return (_block != (CLwoSurfaceBlock *)NULL && _block->_projection_mode == LwoSurfaceBlockProjection::M_uv); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::get_uv_name -// Access: Public -// Description: Returns the name of the set of UV's that are -// associated with this surface, if has_named_uvs() is -// true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the set of UV's that are associated with this surface, + * if has_named_uvs() is true. + */ INLINE const string &CLwoSurface:: get_uv_name() const { return _block->_uv_name; diff --git a/pandatool/src/lwoegg/cLwoSurface.cxx b/pandatool/src/lwoegg/cLwoSurface.cxx index 5559b56ad0..f75932b975 100644 --- a/pandatool/src/lwoegg/cLwoSurface.cxx +++ b/pandatool/src/lwoegg/cLwoSurface.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoSurface.cxx -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurface.cxx + * @author drose + * @date 2001-04-25 + */ #include "cLwoSurface.h" #include "cLwoSurfaceBlock.h" @@ -28,11 +27,9 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoSurface:: CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : _converter(converter), @@ -100,8 +97,8 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : } else if (chunk->is_of_type(LwoSurfaceBlock::get_class_type())) { const LwoSurfaceBlock *lwo_block = DCAST(LwoSurfaceBlock, chunk); - // One of possibly several blocks in the texture that define - // additional fancy rendering properties. + // One of possibly several blocks in the texture that define additional + // fancy rendering properties. CLwoSurfaceBlock *block = new CLwoSurfaceBlock(_converter, lwo_block); @@ -127,8 +124,8 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : } } - // Now get the four-component color, based on combining the RGB and - // the transparency. + // Now get the four-component color, based on combining the RGB and the + // transparency. _color.set(1.0, 1.0, 1.0, 1.0); if ((_flags & F_rgb) != 0) { @@ -144,11 +141,9 @@ CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface) : _diffuse_color = _color; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoSurface:: ~CLwoSurface() { if (_block != (CLwoSurfaceBlock *)NULL) { @@ -156,22 +151,18 @@ CLwoSurface:: } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::apply_properties -// Access: Public -// Description: Applies the color, texture, etc. described by the -// surface to the indicated egg primitive. -// -// If the surface defines a smoothing angle, -// smooth_angle may be updated to reflect it if the -// angle is greater than that specified. -//////////////////////////////////////////////////////////////////// +/** + * Applies the color, texture, etc. described by the surface to the indicated + * egg primitive. + * + * If the surface defines a smoothing angle, smooth_angle may be updated to + * reflect it if the angle is greater than that specified. + */ void CLwoSurface:: apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, PN_stdfloat &smooth_angle) { if (!_surface->_source.empty()) { - // This surface is derived from another surface; apply that one - // first. + // This surface is derived from another surface; apply that one first. CLwoSurface *parent = _converter->get_surface(_surface->_source); if (parent != (CLwoSurface *)NULL && parent != this) { parent->apply_properties(egg_prim, egg_vertices, smooth_angle); @@ -203,16 +194,13 @@ apply_properties(EggPrimitive *egg_prim, vector_PT_EggVertex &egg_vertices, } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::check_texture -// Access: Public -// Description: Checks whether the surface demands a texture or not. -// Returns true if so, false otherwise. -// -// If the surface demands a texture, this also sets up -// _egg_texture and _compute_uvs as appropriate for the -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the surface demands a texture or not. Returns true if so, + * false otherwise. + * + * If the surface demands a texture, this also sets up _egg_texture and + * _compute_uvs as appropriate for the texture. + */ bool CLwoSurface:: check_texture() { if (_checked_texture) { @@ -267,15 +255,14 @@ check_texture() { break; case LwoSurfaceBlockProjection::M_front: - // Cannot generate "front" UV's, since this depends on a camera. - // Is it supposed to be updated in real time, like a projected - // texture? + // Cannot generate "front" UV's, since this depends on a camera. Is it + // supposed to be updated in real time, like a projected texture? break; case LwoSurfaceBlockProjection::M_uv: - // "uv" projection means to use the existing UV's already defined - // for the vertex. This case was already handled in the code that - // created the EggVertex pointers. + // "uv" projection means to use the existing UV's already defined for the + // vertex. This case was already handled in the code that created the + // EggVertex pointers. break; }; @@ -287,12 +274,10 @@ check_texture() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::check_material -// Access: Public -// Description: Checks whether the surface demands a material or not. -// Returns true if so, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Checks whether the surface demands a material or not. Returns true if so, + * false otherwise. + */ bool CLwoSurface:: check_material() { if (_checked_material) { @@ -313,13 +298,12 @@ check_material() { _color[1] * _diffuse, _color[2] * _diffuse, _color[3]); - // We want to avoid setting the diffuse color on the material. - // We're already setting the color explicitly on the object, so - // there's no need to also set a diffuse color on the material, - // and doing so prevents nice features like set_color() and - // set_color_scale() from working in Panda. + // We want to avoid setting the diffuse color on the material. We're + // already setting the color explicitly on the object, so there's no need + // to also set a diffuse color on the material, and doing so prevents nice + // features like set_color() and set_color_scale() from working in Panda. - //_egg_material->set_diff(_diffuse_color); + // _egg_material->set_diff(_diffuse_color); } if ((_flags & F_luminosity) != 0) { @@ -346,22 +330,19 @@ check_material() { } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::generate_uvs -// Access: Private -// Description: Computes all the UV's for the polygon's vertices, -// according to the _projection_mode defined in the -// block. -//////////////////////////////////////////////////////////////////// +/** + * Computes all the UV's for the polygon's vertices, according to the + * _projection_mode defined in the block. + */ void CLwoSurface:: generate_uvs(vector_PT_EggVertex &egg_vertices) { if (_map_uvs == NULL) { return; } - // To do this properly near seams and singularities (for instance, - // the back seam and the poles of the spherical map), we will need - // to know the polygon's centroid. + // To do this properly near seams and singularities (for instance, the back + // seam and the poles of the spherical map), we will need to know the + // polygon's centroid. LPoint3d centroid(0.0, 0.0, 0.0); vector_PT_EggVertex::const_iterator vi; @@ -382,66 +363,58 @@ generate_uvs(vector_PT_EggVertex &egg_vertices) { } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::map_planar -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a planar projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a planar projection. + */ LPoint2d CLwoSurface:: map_planar(const LPoint3d &pos, const LPoint3d &) const { - // A planar projection is about as easy as can be. We ignore the Y - // axis, and project the point into the XZ plane. Done. + // A planar projection is about as easy as can be. We ignore the Y axis, + // and project the point into the XZ plane. Done. double u = (pos[0] + 0.5); double v = (pos[2] + 0.5); return LPoint2d(u, v); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::map_spherical -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a spherical projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a spherical + * projection. + */ LPoint2d CLwoSurface:: map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const { - // To compute the x position on the frame, we only need to consider - // the angle of the vector about the Y axis. Project the vector - // into the XZ plane to do this. + // To compute the x position on the frame, we only need to consider the + // angle of the vector about the Y axis. Project the vector into the XZ + // plane to do this. LVector2d xz_orig(pos[0], pos[2]); LVector2d xz = xz_orig; double u_offset = 0.0; if (xz == LVector2d::zero()) { - // If we have a point on either pole, we've got problems. This - // point maps to the entire bottom edge of the image, so which U - // value should we choose? It does make a difference, especially - // if we have a number of polygons around the south pole that all - // share the common vertex. + // If we have a point on either pole, we've got problems. This point maps + // to the entire bottom edge of the image, so which U value should we + // choose? It does make a difference, especially if we have a number of + // polygons around the south pole that all share the common vertex. // We choose the U value based on the polygon's centroid. xz.set(centroid[0], centroid[2]); } else if (xz[1] >= 0.0 && ((xz[0] < 0.0) != (centroid[0] < 0.))) { - // Now, if our polygon crosses the seam along the back of the - // sphere--that is, the point is on the back of the sphere (xz[1] - // >= 0.0) and not on the same side of the XZ plane as the - // centroid, we've got problems too. We need to add an offset to - // the computed U value, either 1 or -1, to keep all the vertices - // of the polygon on the same side of the seam. + // Now, if our polygon crosses the seam along the back of the sphere--that + // is, the point is on the back of the sphere (xz[1] >= 0.0) and not on + // the same side of the XZ plane as the centroid, we've got problems too. + // We need to add an offset to the computed U value, either 1 or -1, to + // keep all the vertices of the polygon on the same side of the seam. u_offset = (xz[0] < 0.0) ? 1.0 : -1.0; } - // The U value is based on the longitude: the angle about the Y - // axis. + // The U value is based on the longitude: the angle about the Y axis. double u = (atan2(xz[0], -xz[1]) / (2.0 * MathNumbers::pi) + 0.5 + u_offset) * _block->_w_repeat; - // Now rotate the vector into the YZ plane, and the V value is based - // on the latitude: the angle about the X axis. + // Now rotate the vector into the YZ plane, and the V value is based on the + // latitude: the angle about the X axis. LVector2d yz(pos[1], xz_orig.length()); double v = (atan2(yz[0], yz[1]) / MathNumbers::pi + 0.5) * _block->_h_repeat; @@ -449,25 +422,23 @@ map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const { return LPoint2d(u, v); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::map_cylindrical -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a cylindrical projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a cylindrical + * projection. + */ LPoint2d CLwoSurface:: map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const { - // This is almost identical to the spherical projection, except for - // the computation of V. + // This is almost identical to the spherical projection, except for the + // computation of V. LVector2d xz(pos[0], pos[2]); double u_offset = 0.0; if (xz == LVector2d::zero()) { - // Although a cylindrical mapping does not really have a - // singularity at the pole, it's still possible to put a point - // there, and we'd like to do the right thing with the polygon - // that shares that point. So the singularity logic remains. + // Although a cylindrical mapping does not really have a singularity at + // the pole, it's still possible to put a point there, and we'd like to do + // the right thing with the polygon that shares that point. So the + // singularity logic remains. xz.set(centroid[0], centroid[2]); } else if (xz[1] >= 0.0 && ((xz[0] < 0.0) != (centroid[0] < 0.))) { @@ -478,24 +449,21 @@ map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const { double u = (atan2(xz[0], -xz[1]) / (2.0 * MathNumbers::pi) + 0.5 + u_offset) * _block->_w_repeat; - // For a cylindrical mapping, the V value comes almost directly from - // Y. Easy. + // For a cylindrical mapping, the V value comes almost directly from Y. + // Easy. double v = (pos[1] + 0.5); return LPoint2d(u, v); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurface::map_cubic -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a cubic projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a cubic projection. + */ LPoint2d CLwoSurface:: map_cubic(const LPoint3d &pos, const LPoint3d ¢roid) const { - // A cubic projection is a planar projection, but we eliminate the - // dominant axis (based on the polygon's centroid) instead of - // arbitrarily eliminating Y. + // A cubic projection is a planar projection, but we eliminate the dominant + // axis (based on the polygon's centroid) instead of arbitrarily eliminating + // Y. double x = fabs(centroid[0]); double y = fabs(centroid[1]); diff --git a/pandatool/src/lwoegg/cLwoSurface.h b/pandatool/src/lwoegg/cLwoSurface.h index 313fb1cebf..09b3762656 100644 --- a/pandatool/src/lwoegg/cLwoSurface.h +++ b/pandatool/src/lwoegg/cLwoSurface.h @@ -1,16 +1,15 @@ -// Filename: cLwoSurface.h -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurface.h + * @author drose + * @date 2001-04-25 + */ #ifndef CLWOSURFACE_H #define CLWOSURFACE_H @@ -33,12 +32,10 @@ class LwoToEggConverter; class LwoSurfaceBlock; class EggPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : CLwoSurface -// Description : This class is a wrapper around LwoSurface and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoSurface and stores additional information + * useful during the conversion-to-egg process. + */ class CLwoSurface { public: CLwoSurface(LwoToEggConverter *converter, const LwoSurface *surface); @@ -110,5 +107,3 @@ private: #include "cLwoSurface.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.I b/pandatool/src/lwoegg/cLwoSurfaceBlock.I index 6fd017504d..dde9933768 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.I +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.I @@ -1,13 +1,12 @@ -// Filename: cLwoSurfaceBlock.I -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlock.I + * @author drose + * @date 2001-04-26 + */ diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx index 123686d539..1902a28377 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoSurfaceBlock.cxx -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlock.cxx + * @author drose + * @date 2001-04-26 + */ #include "cLwoSurfaceBlock.h" #include "cLwoSurfaceBlockTMap.h" @@ -24,11 +23,9 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurfaceBlock::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoSurfaceBlock:: CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : _converter(converter), @@ -120,9 +117,8 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : _tmap->get_transform(_transform); } - // Also rotate the transform if we specify some axis other than Y. - // (All the map_* uv mapping functions are written to assume Y is - // the dominant axis.) + // Also rotate the transform if we specify some axis other than Y. (All the + // map_* uv mapping functions are written to assume Y is the dominant axis.) switch (_axis) { case LwoSurfaceBlockAxis::A_x: _transform = LMatrix4d::rotate_mat(90.0, @@ -143,11 +139,9 @@ CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block) : _inv_transform.invert_from(_transform); } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurfaceBlock::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoSurfaceBlock:: ~CLwoSurfaceBlock() { if (_tmap != (CLwoSurfaceBlockTMap *)NULL) { diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlock.h b/pandatool/src/lwoegg/cLwoSurfaceBlock.h index de2f6a2d46..d62f73684d 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlock.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlock.h @@ -1,16 +1,15 @@ -// Filename: cLwoSurfaceBlock.h -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlock.h + * @author drose + * @date 2001-04-26 + */ #ifndef CLWOSURFACEBLOCK_H #define CLWOSURFACEBLOCK_H @@ -28,12 +27,10 @@ class LwoToEggConverter; class CLwoSurfaceBlockTMap; -//////////////////////////////////////////////////////////////////// -// Class : CLwoSurfaceBlock -// Description : This class is a wrapper around LwoSurfaceBlock and stores -// additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoSurfaceBlock and stores additional + * information useful during the conversion-to-egg process. + */ class CLwoSurfaceBlock { public: CLwoSurfaceBlock(LwoToEggConverter *converter, const LwoSurfaceBlock *block); @@ -67,5 +64,3 @@ public: #include "cLwoSurfaceBlock.I" #endif - - diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.I b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.I index 2bb8808501..f267006fb1 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.I +++ b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.I @@ -1,13 +1,12 @@ -// Filename: cLwoSurfaceBlockTMap.I -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlockTMap.I + * @author drose + * @date 2001-04-30 + */ diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx index 77b31efcb0..649fd803bc 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx +++ b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.cxx @@ -1,16 +1,15 @@ -// Filename: cLwoSurfaceBlockTMap.cxx -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlockTMap.cxx + * @author drose + * @date 2001-04-30 + */ #include "cLwoSurfaceBlockTMap.h" #include "lwoToEggConverter.h" @@ -20,11 +19,9 @@ #include "compose_matrix.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurfaceBlockTMap::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ CLwoSurfaceBlockTMap:: CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tmap) : _converter(converter), @@ -62,13 +59,10 @@ CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tm } } -//////////////////////////////////////////////////////////////////// -// Function: CLwoSurfaceBlockTMap::get_transform -// Access: Public -// Description: Fills up the indicated matrix with the net transform -// indicated by the TMAP chunk, accounting for scale, -// rotate, and translate. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated matrix with the net transform indicated by the TMAP + * chunk, accounting for scale, rotate, and translate. + */ void CLwoSurfaceBlockTMap:: get_transform(LMatrix4d &mat) const { LPoint3d hpr(rad_2_deg(_rotation[0]), diff --git a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h index a5cd0a7fcd..4fde4938ca 100644 --- a/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h +++ b/pandatool/src/lwoegg/cLwoSurfaceBlockTMap.h @@ -1,16 +1,15 @@ -// Filename: cLwoSurfaceBlockTMap.h -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file cLwoSurfaceBlockTMap.h + * @author drose + * @date 2001-04-30 + */ #ifndef CLWOSURFACEBLOCKTMAP_H #define CLWOSURFACEBLOCKTMAP_H @@ -24,12 +23,10 @@ class LwoToEggConverter; -//////////////////////////////////////////////////////////////////// -// Class : CLwoSurfaceBlockTMap -// Description : This class is a wrapper around LwoSurfaceBlockTMap -// and stores additional information useful during the -// conversion-to-egg process. -//////////////////////////////////////////////////////////////////// +/** + * This class is a wrapper around LwoSurfaceBlockTMap and stores additional + * information useful during the conversion-to-egg process. + */ class CLwoSurfaceBlockTMap { public: CLwoSurfaceBlockTMap(LwoToEggConverter *converter, const LwoSurfaceBlockTMap *tmap); @@ -51,5 +48,3 @@ public: #include "cLwoSurfaceBlockTMap.I" #endif - - diff --git a/pandatool/src/lwoegg/lwoToEggConverter.I b/pandatool/src/lwoegg/lwoToEggConverter.I index 9229b2a7ae..2e7666810c 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.I +++ b/pandatool/src/lwoegg/lwoToEggConverter.I @@ -1,13 +1,12 @@ -// Filename: lwoToEggConverter.I -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoToEggConverter.I + * @author drose + * @date 2001-04-25 + */ diff --git a/pandatool/src/lwoegg/lwoToEggConverter.cxx b/pandatool/src/lwoegg/lwoToEggConverter.cxx index 3fc7239cfd..fa94f560be 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.cxx +++ b/pandatool/src/lwoegg/lwoToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: lwoToEggConverter.cxx -// Created by: drose (25Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoToEggConverter.cxx + * @author drose + * @date 2001-04-25 + */ #include "lwoToEggConverter.h" #include "cLwoLayer.h" @@ -33,94 +32,73 @@ #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoToEggConverter:: LwoToEggConverter() { _generic_layer = (CLwoLayer *)NULL; _make_materials = true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoToEggConverter:: LwoToEggConverter(const LwoToEggConverter ©) : SomethingToEggConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoToEggConverter:: ~LwoToEggConverter() { cleanup(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *LwoToEggConverter:: make_copy() { return new LwoToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string LwoToEggConverter:: get_name() const { return "Lightwave"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string LwoToEggConverter:: get_extension() const { return "lwo"; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LwoToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -// -// This is designed to be as generic as possible, -// generally in support of run-time loading. -// Command-line converters may choose to use -// convert_lwo() instead, as it provides more control. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + * + * This is designed to be as generic as possible, generally in support of run- + * time loading. Command-line converters may choose to use convert_lwo() + * instead, as it provides more control. + */ bool LwoToEggConverter:: convert_file(const Filename &filename) { LwoInputFile in; @@ -153,12 +131,9 @@ convert_file(const Filename &filename) { return convert_lwo(header); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::convert_lwo -// Access: Public -// Description: Fills up the egg_data structure according to the -// indicated lwo structure. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the egg_data structure according to the indicated lwo structure. + */ bool LwoToEggConverter:: convert_lwo(const LwoHeader *lwo_header) { if (_egg_data->get_coordinate_system() == CS_default) { @@ -178,12 +153,10 @@ convert_lwo(const LwoHeader *lwo_header) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::get_layer -// Access: Public -// Description: Returns a pointer to the layer with the given index -// number, or NULL if there is no such layer. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the layer with the given index number, or NULL if + * there is no such layer. + */ CLwoLayer *LwoToEggConverter:: get_layer(int number) const { if (number >= 0 && number < (int)_layers.size()) { @@ -192,12 +165,10 @@ get_layer(int number) const { return (CLwoLayer *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::get_clip -// Access: Public -// Description: Returns a pointer to the clip with the given index -// number, or NULL if there is no such clip. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the clip with the given index number, or NULL if there + * is no such clip. + */ CLwoClip *LwoToEggConverter:: get_clip(int number) const { if (number >= 0 && number < (int)_clips.size()) { @@ -206,12 +177,10 @@ get_clip(int number) const { return (CLwoClip *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::get_surface -// Access: Public -// Description: Returns a pointer to the surface definition with the -// given name, or NULL if there is no such surface. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the surface definition with the given name, or NULL if + * there is no such surface. + */ CLwoSurface *LwoToEggConverter:: get_surface(const string &name) const { Surfaces::const_iterator si; @@ -222,13 +191,10 @@ get_surface(const string &name) const { return (CLwoSurface *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::cleanup -// Access: Private -// Description: Frees all the internal data structures after we're -// done converting, and resets the converter to its -// initial state. -//////////////////////////////////////////////////////////////////// +/** + * Frees all the internal data structures after we're done converting, and + * resets the converter to its initial state. + */ void LwoToEggConverter:: cleanup() { _lwo_header.clear(); @@ -278,12 +244,10 @@ cleanup() { _surfaces.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::collect_lwo -// Access: Private -// Description: Walks through the chunks in the Lightwave data and -// creates wrapper objects for each relevant piece. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the chunks in the Lightwave data and creates wrapper objects + * for each relevant piece. + */ void LwoToEggConverter:: collect_lwo() { CLwoLayer *last_layer = (CLwoLayer *)NULL; @@ -389,12 +353,9 @@ collect_lwo() { } } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::make_egg -// Access: Private -// Description: Makes egg structures for all of the conversion -// wrapper objects. -//////////////////////////////////////////////////////////////////// +/** + * Makes egg structures for all of the conversion wrapper objects. + */ void LwoToEggConverter:: make_egg() { if (_generic_layer != (CLwoLayer *)NULL) { @@ -422,11 +383,9 @@ make_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::connect_egg -// Access: Private -// Description: Connects together all of the egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Connects together all of the egg structures. + */ void LwoToEggConverter:: connect_egg() { if (_generic_layer != (CLwoLayer *)NULL) { @@ -454,12 +413,10 @@ connect_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::slot_layer -// Access: Private -// Description: Ensures that there is space in the _layers array to -// store an element at position number. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that there is space in the _layers array to store an element at + * position number. + */ void LwoToEggConverter:: slot_layer(int number) { nassertv(number - (int)_layers.size() < 1000); @@ -469,12 +426,10 @@ slot_layer(int number) { nassertv(number >= 0 && number < (int)_layers.size()); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::slot_clip -// Access: Private -// Description: Ensures that there is space in the _clips array to -// store an element at position number. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that there is space in the _clips array to store an element at + * position number. + */ void LwoToEggConverter:: slot_clip(int number) { nassertv(number - (int)_clips.size() < 1000); @@ -484,15 +439,12 @@ slot_clip(int number) { nassertv(number >= 0 && number < (int)_clips.size()); } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEggConverter::make_generic_layer -// Access: Private -// Description: If a geometry definition is encountered in the -// Lightwave file before a layer definition, we should -// make a generic layer to hold the geometry. This -// makes and returns a single layer for this purpose. -// It should not be called twice. -//////////////////////////////////////////////////////////////////// +/** + * If a geometry definition is encountered in the Lightwave file before a + * layer definition, we should make a generic layer to hold the geometry. + * This makes and returns a single layer for this purpose. It should not be + * called twice. + */ CLwoLayer *LwoToEggConverter:: make_generic_layer() { nassertr(_generic_layer == (CLwoLayer *)NULL, _generic_layer); diff --git a/pandatool/src/lwoegg/lwoToEggConverter.h b/pandatool/src/lwoegg/lwoToEggConverter.h index 62496b6b65..bd4a5a2e41 100644 --- a/pandatool/src/lwoegg/lwoToEggConverter.h +++ b/pandatool/src/lwoegg/lwoToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: lwoToEggConverter.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoToEggConverter.h + * @author drose + * @date 2001-04-17 + */ #ifndef LWOTOEGGCONVERTER_H #define LWOTOEGGCONVERTER_H @@ -31,13 +30,11 @@ class CLwoPolygons; class CLwoSurface; class LwoClip; -//////////////////////////////////////////////////////////////////// -// Class : LwoToEggConverter -// Description : This class supervises the construction of an EggData -// structure from the data represented by the LwoHeader. -// Reading and writing the egg and lwo structures is -// left to the user. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from the + * data represented by the LwoHeader. Reading and writing the egg and lwo + * structures is left to the user. + */ class LwoToEggConverter : public SomethingToEggConverter { public: LwoToEggConverter(); @@ -93,5 +90,3 @@ private: #include "lwoToEggConverter.I" #endif - - diff --git a/pandatool/src/lwoprogs/lwoScan.cxx b/pandatool/src/lwoprogs/lwoScan.cxx index f8866ee75c..5b72a5be2d 100644 --- a/pandatool/src/lwoprogs/lwoScan.cxx +++ b/pandatool/src/lwoprogs/lwoScan.cxx @@ -1,16 +1,15 @@ -// Filename: lwoScan.cxx -// Created by: drose (24Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoScan.cxx + * @author drose + * @date 2001-04-24 + */ #include "lwoScan.h" @@ -19,11 +18,9 @@ #include "config_lwo.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: LwoScan::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoScan:: LwoScan() { clear_runlines(); @@ -36,11 +33,9 @@ LwoScan() { "problems with lwo2egg."); } -//////////////////////////////////////////////////////////////////// -// Function: LwoScan::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoScan:: run() { LwoInputFile in; @@ -60,11 +55,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: LwoScan::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool LwoScan:: handle_args(ProgramBase::Args &args) { if (args.empty()) { diff --git a/pandatool/src/lwoprogs/lwoScan.h b/pandatool/src/lwoprogs/lwoScan.h index be24aa0800..a602e785c8 100644 --- a/pandatool/src/lwoprogs/lwoScan.h +++ b/pandatool/src/lwoprogs/lwoScan.h @@ -1,16 +1,15 @@ -// Filename: lwoScan.h -// Created by: drose (30Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoScan.h + * @author drose + * @date 2001-04-30 + */ #ifndef LWOSCAN_H #define LWOSCAN_H @@ -18,11 +17,9 @@ #include "programBase.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoScan -// Description : A program to read a Lightwave file and report its -// structure and contents. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a Lightwave file and report its structure and contents. + */ class LwoScan : public ProgramBase { public: LwoScan(); @@ -36,4 +33,3 @@ protected: }; #endif - diff --git a/pandatool/src/lwoprogs/lwoToEgg.cxx b/pandatool/src/lwoprogs/lwoToEgg.cxx index dfaf1cb7fd..bfdc45cd33 100644 --- a/pandatool/src/lwoprogs/lwoToEgg.cxx +++ b/pandatool/src/lwoprogs/lwoToEgg.cxx @@ -1,16 +1,15 @@ -// Filename: lwoToEgg.cxx -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoToEgg.cxx + * @author drose + * @date 2001-04-17 + */ #include "lwoToEgg.h" @@ -20,11 +19,9 @@ #include "config_lwo.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: LwoToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LwoToEgg:: LwoToEgg() : SomethingToEgg("Lightwave", ".lwo") @@ -57,11 +54,9 @@ LwoToEgg() : _coordinate_system = CS_yup_left; } -//////////////////////////////////////////////////////////////////// -// Function: LwoToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void LwoToEgg:: run() { _data->set_coordinate_system(_coordinate_system); diff --git a/pandatool/src/lwoprogs/lwoToEgg.h b/pandatool/src/lwoprogs/lwoToEgg.h index fe99634145..44342fcee5 100644 --- a/pandatool/src/lwoprogs/lwoToEgg.h +++ b/pandatool/src/lwoprogs/lwoToEgg.h @@ -1,16 +1,15 @@ -// Filename: lwoToEgg.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file lwoToEgg.h + * @author drose + * @date 2001-04-17 + */ #ifndef LWOTOEGG_H #define LWOTOEGG_H @@ -22,11 +21,9 @@ #include "dSearchPath.h" -//////////////////////////////////////////////////////////////////// -// Class : LwoToEgg -// Description : A program to read a Lightwave file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a Lightwave file and generate an egg file. + */ class LwoToEgg : public SomethingToEgg { public: LwoToEgg(); @@ -35,4 +32,3 @@ public: }; #endif - diff --git a/pandatool/src/maxegg/maxEgg.cxx b/pandatool/src/maxegg/maxEgg.cxx index 22183b7925..2b77f06767 100644 --- a/pandatool/src/maxegg/maxEgg.cxx +++ b/pandatool/src/maxegg/maxEgg.cxx @@ -1,12 +1,13 @@ -/* - MaxEgg.cpp - Created by Steven "Sauce" Osman, 01/??/03 - Modified by Ken Strickland, 02/25/03 - Carnegie Mellon University, Entertainment Technology Center - - This file implements the classes that are used in the Panda 3D file - exporter for 3D Studio Max. -*/ +/** + * @file maxEgg.cxx + * @author Steven "Sauce" Osman + * @date 2003-01 + * @author Ken Strickland + * @date 2003-02-25 + * + * This file implements the classes that are used in the Panda 3D file + * exporter for 3D Studio Max. + */ #include "maxEgg.h" @@ -267,7 +268,7 @@ const double meshVerts[252][3] = { }; -//Disable the forcing int to true or false performance warning +// Disable the forcing int to true or false performance warning #pragma warning(disable: 4800) /* MaxEggPluginClassDesc - A class that describes 3DS Plugin support. @@ -309,7 +310,8 @@ INT_PTR CALLBACK MaxEggPluginOptionsDlgProc( HWND hWnd, UINT message, MaxOptionsDialog *tempEgg; int sel, res; - //We pass in our plugin through the lParam variable. Let's convert it back. + // We pass in our plugin through the lParam variable. Let's convert it + // back. MaxEggPlugin *imp = (MaxEggPlugin*)GetWindowLongPtr(hWnd,GWLP_USERDATA); if ( !imp && message != WM_INITDIALOG ) return FALSE; @@ -335,7 +337,7 @@ INT_PTR CALLBACK MaxEggPluginOptionsDlgProc( HWND hWnd, UINT message, // A control was modified case WM_COMMAND: - //The modified control is found in the lower word of the wParam long. + // The modified control is found in the lower word of the wParam long. switch( LOWORD(wParam) ) { case IDC_OVERWRITE_CHECK: imp->autoOverwrite = @@ -526,8 +528,8 @@ void MaxEggPlugin::DoExport() { for (int i = 0; i < numEggs; i++) { if (eggList[i]->_checked) { - // If "auto overwrite" was not checked and the file exists, - // ask if the user wishes to overwrite the file + // If "auto overwrite" was not checked and the file exists, ask if + // the user wishes to overwrite the file bool do_write = true; if (!autoOverwrite && GetFileAttributes(eggList[i]->_file_name) != INVALID_FILE_ATTRIBUTES) { @@ -574,7 +576,8 @@ void MaxEggPlugin::DoExport() { si.cb = sizeof(si); TCHAR cmdLine[2048]; - // If we have just one model and animation file, pview them both + // If we have just one model and animation file, pview + // them both if (numEggs == 2 && eggList[i]->_anim_type == MaxEggOptions::AT_model && eggList[1-i]->_checked && eggList[1-i]->_successful && eggList[1-i]->_anim_type == MaxEggOptions::AT_chan) { @@ -617,9 +620,8 @@ void MaxEggPlugin::BuildMesh() meshBuilt = TRUE; } -//////////////////////////////////////////////////////////////////// -// The creation callback - sets the initial position of the helper in the scene. -//////////////////////////////////////////////////////////////////// +// The creation callback - sets the initial position of the helper in the +// scene. class MaxEggPluginCreateMouseCallBack: public CreateMouseCallBack { @@ -650,9 +652,7 @@ static MaxEggPluginCreateMouseCallBack MaxEggCreateMouseCB; CreateMouseCallBack* MaxEggPlugin::GetCreateMouseCallBack() { return &MaxEggCreateMouseCB; } -//////////////////////////////////////////////////////////////////// -//Boilerplate functions for dealing with the display of the plugin -//////////////////////////////////////////////////////////////////// +// Boilerplate functions for dealing with the display of the plugin void MaxEggPlugin::GetMat(TimeValue t, INode* inode, ViewExp* vpt, Matrix3& tm) { @@ -746,9 +746,7 @@ RefTargetHandle MaxEggPlugin::Clone(RemapDir& remap) return(newob); } -//////////////////////////////////////////////////////////////////// // Loading and saving the plugin -//////////////////////////////////////////////////////////////////// IOResult MaxEggPlugin::Save(ISave *isave) { SaveCheckState(); @@ -795,11 +793,11 @@ extern ClassDesc* GetMaxEggPluginDesc(); HINSTANCE hInstance; int controlsInit = FALSE; -// This function is called by Windows when the DLL is loaded. This -// function may also be called many times during time critical operations -// like rendering. Therefore developers need to be careful what they -// do inside this function. In the code below, note how after the DLL is -// loaded the first time only a few statements are executed. +// This function is called by Windows when the DLL is loaded. This function +// may also be called many times during time critical operations like +// rendering. Therefore developers need to be careful what they do inside +// this function. In the code below, note how after the DLL is loaded the +// first time only a few statements are executed. BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { @@ -810,8 +808,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) #if MAX_VERSION_MAJOR < 14 // It appears that InitCustomControls is deprecated in 2012. - // I'm not sure if we can just remove it like this, but - // I've heard that it seems to work, so let's do it like this. + // I'm not sure if we can just remove it like this, but I've + // heard that it seems to work, so let's do it like this. InitCustomControls(hInstance); // Initialize MAX's custom controls #endif InitCommonControls(); // Initialize Win95 controls @@ -828,13 +826,14 @@ __declspec( dllexport ) const TCHAR* LibDescription() } // This function returns the number of plug-in classes this DLL operates on. -//TODO: Must change this number when adding a new class +// TODO: Must change this number when adding a new class __declspec( dllexport ) int LibNumberClasses() { return 1; } -// This function returns the descriptions of the plug-in classes this DLL operates on. +// This function returns the descriptions of the plug-in classes this DLL +// operates on. __declspec( dllexport ) ClassDesc* LibClassDesc(int i) { switch(i) { @@ -843,9 +842,9 @@ __declspec( dllexport ) ClassDesc* LibClassDesc(int i) } } -// This function returns a pre-defined constant indicating the version of -// the system under which it was compiled. It is used to allow the system -// to catch obsolete DLLs. +// This function returns a pre-defined constant indicating the version of the +// system under which it was compiled. It is used to allow the system to +// catch obsolete DLLs. __declspec( dllexport ) ULONG LibVersion() { return VERSION_3DSMAX; @@ -859,4 +858,3 @@ TCHAR *GetString(int id) return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL; return NULL; } - diff --git a/pandatool/src/maxegg/maxEgg.h b/pandatool/src/maxegg/maxEgg.h index 4024f9f845..d10d449a0f 100644 --- a/pandatool/src/maxegg/maxEgg.h +++ b/pandatool/src/maxegg/maxEgg.h @@ -1,11 +1,11 @@ /* - MaxEgg.h - Created by Steven "Sauce" Osman, 01/??/03 + MaxEgg.h + Created by Steven "Sauce" Osman, Jan03 Modified and maintained by Ken Strickland, (02/01/03)-(05/15/03) Modified and maintained by Corey Revilla, (05/22/03)-present Carnegie Mellon University, Entetainment Technology Center - This file contains a 3dsMax exporter derived from discreet's own SceneExport + This file contains a 3dsMax exporter derived from discreet's own SceneExport plug-in class; this exporter is basically a wrapper around the MaxToEgg Panda-converter class, and just sets up the interface and environment in which the MaxToEgg class can be "run" as if it were a standalone app. @@ -78,7 +78,7 @@ extern HINSTANCE hInstance; extern TCHAR *GetString(int id); /* This class defines the 3D Studio Max exporter itself. It is basically a - shell that is invoked by 3D Studio Max's export API. It then sets up + shell that is invoked by 3D Studio Max's export API. It then sets up MaxToEgg instance and attempts to "fool it" into thinking that it is actually being invoked as a standalone program. The thought behind this is that some day MaxToEgg may well be a standalone program, provided that @@ -90,7 +90,7 @@ extern TCHAR *GetString(int id); #define DefaultRemapDir NoRemap #endif -class MaxEggPlugin : public HelperObject +class MaxEggPlugin : public HelperObject { MaxOptionsDialog **eggList; int numEggs; @@ -100,18 +100,18 @@ class MaxEggPlugin : public HelperObject bool autoOverwrite; bool pview; bool logOutput; - + // Class vars static Mesh mesh; // This plugin generates no geometry, this mesh is not passed on to 3D Studio. static short meshBuilt; static HWND hMaxEggParams; static IObjParam *iObjParams; - //Constructor/Destructor + // ConstructorDestructor MaxEggPlugin(); virtual ~MaxEggPlugin(); - //Other class Methods + // Other class Methods void DoExport(); void UpdateUI(); void SaveCheckState(); @@ -121,8 +121,8 @@ class MaxEggPlugin : public HelperObject void RemoveEgg(int i); MaxOptionsDialog *GetEgg(int i) { return (i >= 0 && i < numEggs) ? eggList[i] : NULL; } - // Required implimented virtual methods: - // inherited virtual methods for Reference-management + // Required implimented virtual methods: inherited virtual methods for + // Reference-management RefResult NotifyRefChanged( Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message ); void GetMat(TimeValue t, INode* inod, ViewExp *vpt, Matrix3& mat); diff --git a/pandatool/src/maxegg/maxEggLoader.cxx b/pandatool/src/maxegg/maxEggLoader.cxx index bb5fd067e1..222738493e 100644 --- a/pandatool/src/maxegg/maxEggLoader.cxx +++ b/pandatool/src/maxegg/maxEggLoader.cxx @@ -1,22 +1,18 @@ -// Filename: maxEggLoader.cxx -// Created by: jyelon (15Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// This file contains the code for class MaxEggLoader. This class -// does the actual work of copying an EggData tree into the max scene. -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxEggLoader.cxx + * @author jyelon + * @date 2005-07-15 + * + * This file contains the code for class MaxEggLoader. This class + * does the actual work of copying an EggData tree into the max scene. + */ #include "pandatoolbase.h" #include "notifyCategoryProxy.h" @@ -82,11 +78,7 @@ Point3 MakeMaxPoint(LVector3d vec) return Point3(vec[0], vec[1], vec[2]); } -//////////////////////////////////////////////////////////////////// -// // MaxEggTex -// -//////////////////////////////////////////////////////////////////// class MaxEggTex { @@ -126,11 +118,7 @@ MaxEggTex *MaxEggLoader::GetTex(const Filename &fn) return res; } -//////////////////////////////////////////////////////////////////// -// // MaxEggJoint -// -//////////////////////////////////////////////////////////////////// class MaxEggJoint { @@ -306,11 +294,7 @@ void MaxEggJoint::CreateMaxBone(void) } } -//////////////////////////////////////////////////////////////////// -// // MaxEggMesh -// -//////////////////////////////////////////////////////////////////// typedef pair MaxEggWeight; @@ -566,14 +550,8 @@ void MaxEggLoader::CreateSkinModifier(MaxEggMesh *M) } } -//////////////////////////////////////////////////////////////////// -// -// TraverseEggData -// -// We have an EggData in memory, and now we're going to copy that -// over into the max scene graph. -// -//////////////////////////////////////////////////////////////////// +// TraverseEggData We have an EggData in memory, and now we're going to copy +// that over into the max scene graph. void MaxEggLoader::TraverseEggNode(EggNode *node, EggGroup *context) { @@ -721,11 +699,7 @@ bool MaxEggLoader::ConvertEggFile(const char *name, bool merge, bool model, bool return ConvertEggData(&data, merge, model, anim); } -//////////////////////////////////////////////////////////////////// -// // The two global functions that form the API of this module. -// -//////////////////////////////////////////////////////////////////// bool MaxLoadEggData(EggData *data, bool merge, bool model, bool anim) { @@ -738,4 +712,3 @@ bool MaxLoadEggFile(const char *name, bool merge, bool model, bool anim) MaxEggLoader loader; return loader.ConvertEggFile(name, merge, model, anim); } - diff --git a/pandatool/src/maxegg/maxEggLoader.h b/pandatool/src/maxegg/maxEggLoader.h index ce76b5dcc0..90fe897585 100644 --- a/pandatool/src/maxegg/maxEggLoader.h +++ b/pandatool/src/maxegg/maxEggLoader.h @@ -1,16 +1,15 @@ -// Filename: maxEggLoader.h -// Created by: jyelon (15jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxEggLoader.h + * @author jyelon + * @date 2005-07-15 + */ #ifndef MAXEGGLOADER_H #define MAXEGGLOADER_H @@ -21,4 +20,3 @@ bool MaxLoadEggData(EggData *data, bool merge, bool model, bool anim); bool MaxLoadEggFile(const char *name, bool merge, bool model, bool anim); #endif - diff --git a/pandatool/src/maxegg/maxNodeDesc.cxx b/pandatool/src/maxegg/maxNodeDesc.cxx index 8ce50776b4..57a9d7385f 100644 --- a/pandatool/src/maxegg/maxNodeDesc.cxx +++ b/pandatool/src/maxegg/maxNodeDesc.cxx @@ -1,29 +1,24 @@ -// Filename: maxNodeDesc.cxx -// Created by: crevilla -// from mayaNodeDesc.cxx created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxNodeDesc.cxx + * @author crevilla + * from mayaNodeDesc.cxx created by: drose (06Jun03) + */ #include "maxEgg.h" TypeHandle MaxNodeDesc::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::Constructor -// Access: Public -// Description: Creates a MaxNodeDesc. The name is copied from -// the given max node. Use from_INode to actually -// associate the desc with a given max node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a MaxNodeDesc. The name is copied from the given max node. Use + * from_INode to actually associate the desc with a given max node. + */ MaxNodeDesc:: MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : _parent(parent) { @@ -53,33 +48,27 @@ MaxNodeDesc(MaxNodeDesc *parent, INode *max_node) : } } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaxNodeDesc:: ~MaxNodeDesc() {} -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::from_INode -// Access: Public -// Description: Indicates an associated between the MaxNodeDesc and -// some Max Node instance. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an associated between the MaxNodeDesc and some Max Node instance. + */ void MaxNodeDesc:: from_INode(INode *max_node) { if (_max_node == (INode *)NULL) { _max_node = max_node; - // This is how I decided to check to see if this max node is a - // joint. It works in all instances I've seen so far, but this - // may be a good starting place to look if joints are not being - // picked up correctly in the future. + // This is how I decided to check to see if this max node is a joint. It + // works in all instances I've seen so far, but this may be a good + // starting place to look if joints are not being picked up correctly in + // the future. - //Check to see if the node's controller is a biped - //If so treat it as a joint - // Get the node's transform control + // Check to see if the node's controller is a biped If so treat it as a + // joint Get the node's transform control Control *c = max_node->GetTMController(); if (_max_node->GetBoneNodeOnOff() || (c && //c exists and it's type is a biped @@ -96,24 +85,19 @@ from_INode(INode *max_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::has_max_node -// Access: Public -// Description: Returns true if a Max INode has been associated -// with this node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a Max INode has been associated with this node, false + * otherwise. + */ bool MaxNodeDesc:: has_max_node() const { return (_max_node != (INode *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::get_max_node -// Access: Public -// Description: Returns the INode associated with this node. It -// is an error to call this unless has_max_node() -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the INode associated with this node. It is an error to call this + * unless has_max_node() returned true. + */ INode *MaxNodeDesc:: get_max_node() const { nassertr(_max_node != (INode *)NULL, _max_node); @@ -128,46 +112,34 @@ set_joint(bool onoff) { else _joint_type = JT_none; } - -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::is_joint -// Access: Private -// Description: Returns true if the node should be treated as a joint -// by the converter. -//////////////////////////////////////////////////////////////////// + +/** + * Returns true if the node should be treated as a joint by the converter. + */ bool MaxNodeDesc:: is_joint() const { return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::is_joint_parent -// Access: Private -// Description: Returns true if the node is the parent or ancestor of -// a joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is the parent or ancestor of a joint. + */ bool MaxNodeDesc:: is_joint_parent() const { return _joint_type == JT_joint_parent; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::is_joint_parent -// Access: Private -// Description: Returns true if the node is the parent or ancestor of -// a joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is the parent or ancestor of a joint. + */ bool MaxNodeDesc:: is_node_joint() const { return _joint_type == JT_node_joint; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::clear_egg -// Access: Private -// Description: Recursively clears the egg pointers from this node -// and all children. -//////////////////////////////////////////////////////////////////// +/** + * Recursively clears the egg pointers from this node and all children. + */ void MaxNodeDesc:: clear_egg() { _egg_group = (EggGroup *)NULL; @@ -181,12 +153,10 @@ clear_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::mark_joint_parent -// Access: Private -// Description: Indicates that this node has at least one child that -// is a joint or a pseudo-joint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this node has at least one child that is a joint or a + * pseudo-joint. + */ void MaxNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { @@ -197,31 +167,27 @@ mark_joint_parent() { } } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeDesc::check_pseudo_joints -// Access: Private -// Description: Walks the hierarchy, looking for non-joint nodes that -// are both children and parents of a joint. These -// nodes are deemed to be pseudo joints, since the -// converter must treat them as joints. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, looking for non-joint nodes that are both children and + * parents of a joint. These nodes are deemed to be pseudo joints, since the + * converter must treat them as joints. + */ void MaxNodeDesc:: check_pseudo_joints(bool joint_above) { if (_joint_type == JT_joint_parent && joint_above) { - // This is one such node: it is the parent of a joint - // (JT_joint_parent is set), and it is the child of a joint - // (joint_above is set). + // This is one such node: it is the parent of a joint (JT_joint_parent is + // set), and it is the child of a joint (joint_above is set). _joint_type = JT_pseudo_joint; } if (_joint_type == JT_joint) { - // If this node is itself a joint, then joint_above is true for - // all child nodes. + // If this node is itself a joint, then joint_above is true for all child + // nodes. joint_above = true; } - // Don't bother traversing further if _joint_type is none, since - // that means this node has no joint children. + // Don't bother traversing further if _joint_type is none, since that means + // this node has no joint children. if (_joint_type != JT_none) { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { diff --git a/pandatool/src/maxegg/maxNodeDesc.h b/pandatool/src/maxegg/maxNodeDesc.h index 23ec218a9b..42bb1f4acc 100644 --- a/pandatool/src/maxegg/maxNodeDesc.h +++ b/pandatool/src/maxegg/maxNodeDesc.h @@ -1,28 +1,24 @@ -// Filename: maxNodeDesc.h -// Created by: crevilla -// from mayaNodeDesc.h created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxNodeDesc.h + * @author crevilla + * from mayaNodeDesc.h created by: drose (06Jun03) + */ #ifndef MAXNODEDESC_H #define MAXNODEDESC_H -//////////////////////////////////////////////////////////////////// -// Class : MaxNodeDesc -// Description : Describes a single instance of a node in the Max -// scene graph, relating it to the corresponding egg -// structures (e.g. node, group, or table entry) that -// will be created. -//////////////////////////////////////////////////////////////////// +/** + * Describes a single instance of a node in the Max scene graph, relating it + * to the corresponding egg structures (e.g. node, group, or table entry) + * that will be created. + */ class MaxNodeDesc : public ReferenceCount, public Namable { public: MaxNodeDesc(MaxNodeDesc *parent = NULL, INode *max_node = NULL); @@ -55,7 +51,7 @@ class MaxNodeDesc : public ReferenceCount, public Namable { enum JointType { JT_none, // Not a joint. - JT_node_joint, // Node that represents a joint in the geometry + JT_node_joint, // Node that represents a joint in the geometry // but not the actual joint itself JT_joint, // An actual joint in Max. JT_pseudo_joint, // Not a joint in Max, but treated just like a diff --git a/pandatool/src/maxegg/maxNodeTree.cxx b/pandatool/src/maxegg/maxNodeTree.cxx index 825ccf9816..58f980c281 100644 --- a/pandatool/src/maxegg/maxNodeTree.cxx +++ b/pandatool/src/maxegg/maxNodeTree.cxx @@ -1,25 +1,21 @@ -// Filename: maxNodeTree.cxx -// Created by: crevilla -// from mayaNodeTree.cxx created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxNodeTree.cxx + * @author crevilla + * from mayaNodeTree.cxx created by: drose (06Jun03) + */ #include "maxEgg.h" -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaxNodeTree:: MaxNodeTree() { _root = new MaxNodeDesc; @@ -30,13 +26,10 @@ MaxNodeTree() { _skeleton_node = (EggGroupNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::build_node -// Access: Public -// Description: Returns a pointer to the node corresponding to the -// indicated INode object, creating it first if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the node corresponding to the indicated INode object, + * creating it first if necessary. + */ MaxNodeDesc *MaxNodeTree:: build_node(INode *max_node) { MaxNodeDesc *node_desc = r_build_node(max_node); @@ -48,13 +41,10 @@ build_node(INode *max_node) { return node_desc; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::build_joint -// Access: Public -// Description: Returns a pointer to the node corresponding to the -// indicated INode object, creating it first if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the node corresponding to the indicated INode object, + * creating it first if necessary. + */ MaxNodeDesc *MaxNodeTree:: build_joint(INode *max_node, MaxNodeDesc *node_joint) { MaxNodeDesc *node_desc = r_build_joint(node_joint, max_node); @@ -90,12 +80,10 @@ r_build_hierarchy(INode *root, ULONG *selection_list, int len) { } return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::build_complete_hierarchy -// Access: Public -// Description: Walks through the complete Max hierarchy and builds -// up the corresponding tree. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the complete Max hierarchy and builds up the corresponding + * tree. + */ bool MaxNodeTree:: build_complete_hierarchy(INode *root, ULONG *selection_list, int len) { @@ -115,38 +103,30 @@ build_complete_hierarchy(INode *root, ULONG *selection_list, int len) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::get_num_nodes -// Access: Public -// Description: Returns the total number of nodes in the hierarchy, -// not counting the root node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of nodes in the hierarchy, not counting the root + * node. + */ int MaxNodeTree:: get_num_nodes() const { return _nodes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::get_node -// Access: Public -// Description: Returns the nth node in the hierarchy, in an -// arbitrary ordering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth node in the hierarchy, in an arbitrary ordering. + */ MaxNodeDesc *MaxNodeTree:: get_node(int n) const { nassertr(n >= 0 && n < (int)_nodes.size(), NULL); return _nodes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::clear_egg -// Access: Public -// Description: Removes all of the references to generated egg -// structures from the tree, and prepares the tree for -// generating new egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the references to generated egg structures from the tree, + * and prepares the tree for generating new egg structures. + */ void MaxNodeTree:: -clear_egg(EggData *egg_data, EggGroupNode *egg_root, +clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node) { _root->clear_egg(); _egg_data = egg_data; @@ -154,13 +134,10 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, _skeleton_node = skeleton_node; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::get_egg_group -// Access: Public -// Description: Returns the EggGroupNode corresponding to the group -// or joint for the indicated node. Creates the group -// node if it has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggGroupNode corresponding to the group or joint for the + * indicated node. Creates the group node if it has not already been created. + */ EggGroup *MaxNodeTree:: get_egg_group(MaxNodeDesc *node_desc) { nassertr(_egg_root != (EggGroupNode *)NULL, NULL); @@ -175,8 +152,8 @@ get_egg_group(MaxNodeDesc *node_desc) { egg_group->set_group_type(EggGroup::GT_joint); } if (node_desc->_parent == _root) { - // The parent is the root. - // Set collision properties for the root if it has them: + // The parent is the root. Set collision properties for the root if it + // has them: if(!_export_mesh) { set_collision_tags(node_desc, egg_group); @@ -184,8 +161,8 @@ get_egg_group(MaxNodeDesc *node_desc) { _egg_root->add_child(egg_group); } else { - // The parent is another node. - // if export mesh, the tag should be added at the second level + // The parent is another node. if export mesh, the tag should be added + // at the second level if(_export_mesh) { if(node_desc->_parent->_parent == _root) @@ -203,13 +180,10 @@ get_egg_group(MaxNodeDesc *node_desc) { return node_desc->_egg_group; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::get_egg_table -// Access: Public -// Description: Returns the EggTable corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTable corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggTable *MaxNodeTree:: get_egg_table(MaxNodeDesc *node_desc) { nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); @@ -241,28 +215,23 @@ get_egg_table(MaxNodeDesc *node_desc) { return node_desc->_egg_table; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::get_egg_anim -// Access: Public -// Description: Returns the anim table corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anim table corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggXfmSAnim *MaxNodeTree:: get_egg_anim(MaxNodeDesc *node_desc) { get_egg_table(node_desc); return node_desc->_anim; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::r_build_node -// Access: Private -// Description: The recursive implementation of build_node(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_node(). + */ MaxNodeDesc *MaxNodeTree:: r_build_node(INode* max_node) { - // If we have already encountered this pathname, return the - // corresponding MaxNodeDesc immediately. + // If we have already encountered this pathname, return the corresponding + // MaxNodeDesc immediately. ULONG node_handle = 0; @@ -275,8 +244,8 @@ r_build_node(INode* max_node) { return (*ni).second; } - // Otherwise, we have to create it. Do this recursively, so we - // create each node along the path. + // Otherwise, we have to create it. Do this recursively, so we create each + // node along the path. MaxNodeDesc *node_desc; if (!max_node) { @@ -301,11 +270,9 @@ r_build_node(INode* max_node) { return node_desc; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::r_build_joint -// Access: Private -// Description: The recursive implementation of build_joint(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_joint(). + */ MaxNodeDesc *MaxNodeTree:: r_build_joint(MaxNodeDesc *node_desc, INode *max_node) { @@ -323,15 +290,13 @@ r_build_joint(MaxNodeDesc *node_desc, INode *max_node) } } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::find_node -// Access: Private -// Description: The recursive implementation of build_node(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_node(). + */ MaxNodeDesc *MaxNodeTree:: find_node(INode* max_node) { - // If we have already encountered this pathname, return the - // corresponding MaxNodeDesc immediately. + // If we have already encountered this pathname, return the corresponding + // MaxNodeDesc immediately. ULONG node_handle = 0; @@ -347,13 +312,11 @@ find_node(INode* max_node) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::find_joint -// Access: Private -// Description: The recursive implementation of build_node(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_node(). + */ MaxNodeDesc *MaxNodeTree:: -find_joint(INode* max_node) +find_joint(INode* max_node) { MaxNodeDesc *node = find_node(max_node); if (!node || (is_joint(max_node) && !node->is_node_joint())) @@ -361,125 +324,122 @@ find_joint(INode* max_node) return node->_joint_entry; } -//////////////////////////////////////////////////////////////////// -// Function: MaxNodeTree::set_collision_tags -// Access: Private -// Description: Sets the corresponding collision tag to the egg_group -// based on the User Defined Tab in the object properties -// panel -//////////////////////////////////////////////////////////////////// +/** + * Sets the corresponding collision tag to the egg_group based on the User + * Defined Tab in the object properties panel + */ void MaxNodeTree::set_collision_tags(MaxNodeDesc *node_desc, EggGroup *egg_group) { - //Max has huge problems passing strings and bools to Get and SetUserProp - //So instead we have to use Integers. Now we have to check - //for every collide type, then get its collide flags and - //do some number crunching to get the actual flag into the group - + // Max has huge problems passing strings and bools to Get and SetUserProp + // So instead we have to use Integers. Now we have to check for every + // collide type, then get its collide flags and do some number crunching + // to get the actual flag into the group + int check = 1; //is the value true. This could be anything really - - //We have to check each collision type in turn to see if it's true - //Ugly but it works per object, not globaly + + // We have to check each collision type in turn to see if it's true Ugly + // but it works per object, not globaly if (node_desc->get_max_node()->GetUserPropInt(_T("polyset"), check)) { - //we have a polyset. + // we have a polyset. if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_polyset); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("plane"), check)) { - //plane + // plane if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_plane); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("polygon"), check)) { - //polygon + // polygon if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_polygon); } } if (node_desc->get_max_node()->GetUserPropInt(_T("sphere"), check)) { - //sphere + // sphere if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_sphere); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("inv-sphere"), check)) { - //invsphere + // invsphere if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_inv_sphere); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("invsphere"), check)) { - //invsphere (different spelling) + // invsphere (different spelling) if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_inv_sphere); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("tube"), check)) { - //tube + // tube if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_tube); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("floor-mesh"), check)) { - //floor-mesh + // floor-mesh if (check == 1) { egg_group->set_collision_name(node_desc->get_name()); egg_group->set_cs_type(EggGroup::CST_floor_mesh); } } - + if (node_desc->get_max_node()->GetUserPropInt(_T("descend"), check)) { if (check == 1) { - //we have the descend flag specified + // we have the descend flag specified egg_group->set_collide_flags(EggGroup::CF_descend); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("event"), check)) { if (check == 1) { - //we have the event flag specified + // we have the event flag specified egg_group->set_collide_flags(EggGroup::CF_event); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("keep"), check)) { if (check == 1) { - //we have the keep flag specified + // we have the keep flag specified egg_group->set_collide_flags(EggGroup::CF_keep); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("solid"), check)) { if (check == 1) { - //we have the solid flag specified + // we have the solid flag specified egg_group->set_collide_flags(EggGroup::CF_solid); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("center"), check)) { if (check == 1) { - //we have the center flag specified + // we have the center flag specified egg_group->set_collide_flags(EggGroup::CF_center); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("turnstile"), check)) { if (check == 1) { - //we have the turnstile flag specified + // we have the turnstile flag specified egg_group->set_collide_flags(EggGroup::CF_turnstile); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("level"), check)) { if (check == 1) { - //we have the level flag specified + // we have the level flag specified egg_group->set_collide_flags(EggGroup::CF_level); } - } + } if (node_desc->get_max_node()->GetUserPropInt(_T("intangible"), check)) { if (check == 1) { - //we have the intangible flag specified + // we have the intangible flag specified egg_group->set_collide_flags(EggGroup::CF_intangible); } } diff --git a/pandatool/src/maxegg/maxNodeTree.h b/pandatool/src/maxegg/maxNodeTree.h index d7fd259c02..1c4201ad00 100644 --- a/pandatool/src/maxegg/maxNodeTree.h +++ b/pandatool/src/maxegg/maxNodeTree.h @@ -1,17 +1,15 @@ -// Filename: maxNodeTree.h -// Created by: crevilla -// from mayaNodeTree.h created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxNodeTree.h + * @author crevilla + * from mayaNodeTree.h created by: drose (06Jun03) + */ #ifndef MAXNODETREE_H #define MAXNODETREE_H @@ -19,11 +17,9 @@ class EggData; class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : MaxNodeTree -// Description : Describes a complete tree of max nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Describes a complete tree of max nodes for conversion. + */ class MaxNodeTree { public: MaxNodeTree(); @@ -36,7 +32,7 @@ public: int get_num_nodes() const; MaxNodeDesc *get_node(int n) const; - void clear_egg(EggData *egg_data, EggGroupNode *egg_root, + void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node); EggGroup *get_egg_group(MaxNodeDesc *node_desc); EggTable *get_egg_table(MaxNodeDesc *node_desc); @@ -44,10 +40,8 @@ public: MaxNodeDesc* _root; PN_stdfloat _fps; - // the flag for the setting up collision - //bool _has_collision; - //EggGroup::CollideFlags _cf_type; - //EggGroup::CollisionSolidType _cs_type; + // the flag for the setting up collision bool _has_collision; + // EggGroup::CollideFlags _cf_type; EggGroup::CollisionSolidType _cs_type; bool _export_mesh; private: diff --git a/pandatool/src/maxegg/maxOptionsDialog.cxx b/pandatool/src/maxegg/maxOptionsDialog.cxx index c343bcda52..556b1a0888 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.cxx +++ b/pandatool/src/maxegg/maxOptionsDialog.cxx @@ -5,14 +5,14 @@ This file implements the classes that are used to choose what to export from 3D Studio max - + Updated by Fei Wang, Carnegie Mellon University Entertainment Technology Center student, 14Aug2009: added enableAddCollisionChoices */ #include "maxEgg.h" -//Disable the forcing int to true or false performance warning +// Disable the forcing int to true or false performance warning #pragma warning(disable: 4800) void SetICustEdit(HWND wnd, int nIDDlgItem, TCHAR *text) @@ -161,7 +161,7 @@ public: MaxOptionsDialog *ph; //Pointer to the parent class HWND hWnd; //Handle to the parent dialog - AddNodeCB (MaxOptionsDialog *instance, HWND wnd) : + AddNodeCB (MaxOptionsDialog *instance, HWND wnd) : ph(instance), hWnd(wnd) {} #if MAX_VERSION_MAJOR < 15 @@ -176,11 +176,11 @@ public: virtual void proc(INodeTab &nodeTab); }; -//This tells what should be in the list -//Allow only triangular objects, nurbs, and joints +// This tells what should be in the list Allow only triangular objects, nurbs, +// and joints int AddNodeCB::filter(INode *node) { if (!node) return 0; - + Object *obj = node->EvalWorldState(0).obj; Control *c = node->GetTMController(); NURBSSet getSet; @@ -190,7 +190,7 @@ int AddNodeCB::filter(INode *node) { (c->ClassID() == BIPBODY_CONTROL_CLASS_ID) || (c->ClassID() == FOOTPRINT_CLASS_ID)))); - + if (IsDlgButtonChecked(hWnd, IDC_ANIMATION) == BST_CHECKED) return is_bone && !ph->FindNode(node->GetHandle()); else @@ -205,7 +205,7 @@ int AddNodeCB::filter(INode *node) { !ph->FindNode(node->GetHandle())); //Only allow items not already selected } -//Adds all of the selected items to the list +// Adds all of the selected items to the list void AddNodeCB::proc(INodeTab &nodeTab) { for (int i = 0; i < nodeTab.Count(); i++) @@ -213,14 +213,15 @@ void AddNodeCB::proc(INodeTab &nodeTab) { ph->RefreshNodeList(hWnd); } -//This callback class generates a list of nodes that have previously been selected +// This callback class generates a list of nodes that have previously been +// selected class RemoveNodeCB : public HitByNameDlgCallback { public: MaxOptionsDialog *ph; //Pointer to the parent class HWND hWnd; //Handle to the parent dialog - RemoveNodeCB (MaxOptionsDialog *instance, HWND wnd) : + RemoveNodeCB (MaxOptionsDialog *instance, HWND wnd) : ph(instance), hWnd(wnd) {} #if MAX_VERSION_MAJOR < 15 @@ -236,7 +237,7 @@ public: }; -//Adds all of the selected items to the list +// Adds all of the selected items to the list void RemoveNodeCB::proc(INodeTab &nodeTab) { for (int i = 0; i < nodeTab.Count(); i++) ph->RemoveNodeByHandle(nodeTab[i]->GetHandle()); @@ -260,28 +261,29 @@ MaxEggOptions::MaxEggOptions() { _successful = false; } -INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { TCHAR tempFilename[2048]; - //We pass in our plugin through the lParam variable. Let's convert it back. - MaxOptionsDialog *imp = (MaxOptionsDialog*)GetWindowLongPtr(hWnd,GWLP_USERDATA); + // We pass in our plugin through the lParam variable. Let's convert it + // back. + MaxOptionsDialog *imp = (MaxOptionsDialog*)GetWindowLongPtr(hWnd,GWLP_USERDATA); if ( !imp && message != WM_INITDIALOG ) return FALSE; switch(message) { case WM_INITDIALOG: // this line is very necessary to pass the plugin as the lParam - SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); + SetWindowLongPtr(hWnd,GWLP_USERDATA,lParam); ((MaxOptionsDialog*)lParam)->UpdateUI(hWnd); return TRUE; break; - + case WM_CLOSE: EndDialog(hWnd, FALSE); return TRUE; break; - + case WM_COMMAND: - //The modified control is found in the lower word of the wParam long. + // The modified control is found in the lower word of the wParam long. switch( LOWORD(wParam) ) { case IDC_MODEL: if (HIWORD(wParam) == BN_CLICKED) { @@ -296,7 +298,7 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L return TRUE; } break; - + case IDC_ANIMATION: if (HIWORD(wParam) == BN_CLICKED) { SetWindowText(GetDlgItem(hWnd, IDC_EXPORT_SELECTED), @@ -353,7 +355,7 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L return TRUE; } break; - + case IDC_EXP_SEL_FRAMES: if (HIWORD(wParam) == BN_CLICKED) { enableAnimControls(hWnd, TRUE); @@ -375,7 +377,7 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L return TRUE; } break; - + case IDC_EXPORT_SELECTED: if (HIWORD(wParam) == BN_CLICKED) { enableChooserControls(hWnd, TRUE); @@ -429,11 +431,9 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L SetFocus(GetDlgItem(hWnd, IDC_FILENAME)); if (GetSaveFileName(&ofn)) SetICustEdit(hWnd, IDC_FILENAME, ofn.lpstrFile); - //else { - // char buf[255]; - // sprintf(buf, "%d", CommDlgExtendedError()); - // MessageBox(hWnd, buf, "Error on GetSaveFileName", MB_OK); - //} + // else { char buf[255]; sprintf(buf, "%d", + // CommDlgExtendedError()); MessageBox(hWnd, buf, "Error on + // GetSaveFileName", MB_OK); } return TRUE; break; case IDC_CHECK1: if (IsDlgButtonChecked(hWnd, IDC_CHECK1)) @@ -444,9 +444,8 @@ INT_PTR CALLBACK MaxOptionsDialogProc( HWND hWnd, UINT message, WPARAM wParam, L return TRUE; break; default: - //char buf[255]; - //sprintf(buf, "%d", LOWORD(wParam)); - //MessageBox(hWnd, buf, "Unknown WParam", MB_OK); + // char buf[255]; sprintf(buf, "%d", LOWORD(wParam)); + // MessageBox(hWnd, buf, "Unknown WParam", MB_OK); break; } } @@ -479,14 +478,14 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) { int typeButton = IDC_MODEL; int anim_exp = _export_all_frames ? IDC_EXP_ALL_FRAMES : IDC_EXP_SEL_FRAMES; int model_exp = _export_whole_scene ? IDC_EXPORT_ALL : IDC_EXPORT_SELECTED; - + switch (_anim_type) { case MaxEggOptions::AT_chan: typeButton = IDC_ANIMATION; break; case MaxEggOptions::AT_both: typeButton = IDC_BOTH; break; case MaxEggOptions::AT_pose: typeButton = IDC_POSE; break; case MaxEggOptions::AT_model: typeButton = IDC_MODEL; break; } - + _prev_type = _anim_type; CheckRadioButton(hWnd, IDC_MODEL, IDC_POSE, typeButton); @@ -495,11 +494,11 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) { SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(model_exp, BN_CLICKED), 0); CheckRadioButton(hWnd, IDC_EXP_ALL_FRAMES, IDC_EXP_SEL_FRAMES, anim_exp); SendMessage(hWnd, WM_COMMAND, MAKEWPARAM(anim_exp, BN_CLICKED), 0); - + CheckDlgButton(hWnd, IDC_CHECK1, _double_sided ? BST_CHECKED : BST_UNCHECKED); - + SetICustEdit(hWnd, IDC_FILENAME, _file_name); if (_start_frame != INT_MIN) { SetICustEdit(hWnd, IDC_SF, _start_frame); @@ -508,7 +507,7 @@ void MaxOptionsDialog::UpdateUI(HWND hWnd) { SetICustEdit(hWnd, IDC_SF, _min_frame); SetICustEdit(hWnd, IDC_EF, _max_frame); } - + RefreshNodeList(hWnd); } @@ -518,7 +517,7 @@ void MaxOptionsDialog::ClearNodeList(HWND hWnd) { } void MaxOptionsDialog::RefreshNodeList(HWND hWnd) { - //Clear and repopulate the node box + // Clear and repopulate the node box HWND nodeLB = GetDlgItem(hWnd, IDC_LIST_EXPORT); SendMessage(nodeLB, LB_RESETCONTENT, 0, 0); for (int i = 0; i < _node_list.size(); i++) { @@ -596,7 +595,7 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { _tcscpy(_short_name, temp); _short_name[_tcslen(_short_name) - 4] = NULL; //Cut off the .egg } - + _start_frame = newSF; _end_frame = newEF; _anim_type = newAnimType; @@ -610,13 +609,13 @@ bool MaxOptionsDialog::UpdateFromUI(HWND hWnd) { } bool MaxOptionsDialog::FindNode(ULONG INodeHandle) { - for (int i = 0; i < _node_list.size(); i++) + for (int i = 0; i < _node_list.size(); i++) if (_node_list[i] == INodeHandle) return true; return false; } void MaxOptionsDialog::AddNode(ULONG INodeHandle) { - if (FindNode(INodeHandle)) return; + if (FindNode(INodeHandle)) return; _node_list.push_back(INodeHandle); } @@ -660,18 +659,18 @@ IOResult MaxOptionsDialog::Save(ISave *isave) { ChunkSave(isave, CHUNK_EGG_CHECKED, _checked); ChunkSave(isave, CHUNK_ALL_FRAMES, _export_all_frames); ChunkSave(isave, CHUNK_EXPORT_FULL, _export_whole_scene); - + isave->BeginChunk(CHUNK_NODE_LIST); for (int i = 0; i < _node_list.size(); i++) ChunkSave(isave, CHUNK_NODE_HANDLE, _node_list[i]); isave->EndChunk(); isave->EndChunk(); return IO_OK; -} +} IOResult MaxOptionsDialog::Load(ILoad *iload) { IOResult res = iload->OpenChunk(); - + while (res == IO_OK) { switch(iload->CurChunkID()) { case CHUNK_ANIM_TYPE: _anim_type = (Anim_Type)ChunkLoadInt(iload); break; @@ -683,7 +682,7 @@ IOResult MaxOptionsDialog::Load(ILoad *iload) { case CHUNK_EGG_CHECKED: _checked = ChunkLoadBool(iload); break; case CHUNK_ALL_FRAMES: _export_all_frames = ChunkLoadBool(iload); break; case CHUNK_EXPORT_FULL: _export_whole_scene = ChunkLoadBool(iload); break; - + case CHUNK_NODE_LIST: res = iload->OpenChunk(); while (res == IO_OK) { @@ -696,8 +695,7 @@ IOResult MaxOptionsDialog::Load(ILoad *iload) { iload->CloseChunk(); res = iload->OpenChunk(); } - + if (res == IO_END) return IO_OK; return IO_ERROR; } - diff --git a/pandatool/src/maxegg/maxOptionsDialog.h b/pandatool/src/maxegg/maxOptionsDialog.h index 236fdd179b..8e0d899f77 100644 --- a/pandatool/src/maxegg/maxOptionsDialog.h +++ b/pandatool/src/maxegg/maxOptionsDialog.h @@ -1,5 +1,5 @@ /* - maxEggExpOptions.h + maxEggExpOptions.h Created by Phillip Saltzman, 2/15/05 Carnegie Mellon University, Entetainment Technology Center @@ -17,7 +17,7 @@ /* Externed Globals */ extern HINSTANCE hInstance; -//Save/load chunk definitions +// Saveload chunk definitions #define CHUNK_OVERWRITE_FLAG 0x1000 #define CHUNK_PVIEW_FLAG 0x1001 #define CHUNK_LOG_OUTPUT 0x1002 @@ -33,12 +33,10 @@ extern HINSTANCE hInstance; #define CHUNK_ALL_FRAMES 0x1109 #define CHUNK_NODE_LIST 0x1200 #define CHUNK_NODE_HANDLE 0x1201 -// -//#define CHUNK_ADD_COLLISION 0x1202 -//#define CHUNK_CS_TYPE 0x1203 -//#define CHUNK_CF_TYPE 0x1204 +// #define CHUNK_ADD_COLLISION 0x1202 #define CHUNK_CS_TYPE 0x1203 +// #define CHUNK_CF_TYPE 0x1204 -//Global functions +// Global functions void ChunkSave(ISave *isave, int chunkid, int value); void ChunkSave(ISave *isave, int chunkid, bool value); void ChunkSave(ISave *isave, int chunkid, char *value); @@ -90,8 +88,8 @@ class MaxOptionsDialog : public MaxEggOptions MaxOptionsDialog(); ~MaxOptionsDialog(); - // All these List functions should probably take what list they need to operate on - // rather than just operating on a global list + // All these List functions should probably take what list they need to + // operate on rather than just operating on a global list void SetMaxInterface(IObjParam *iface) { _max_interface = iface; } void UpdateUI(HWND hWnd); bool UpdateFromUI(HWND hWnd); diff --git a/pandatool/src/maxegg/maxToEggConverter.cxx b/pandatool/src/maxegg/maxToEggConverter.cxx index bcc32aeff3..f0df22ddca 100644 --- a/pandatool/src/maxegg/maxToEggConverter.cxx +++ b/pandatool/src/maxegg/maxToEggConverter.cxx @@ -1,56 +1,52 @@ -// Filename: maxToEggConverter.cxx -// Created by Corey Revilla and Ken Strickland (6/22/03) -// from mayaToEggConverter.cxx created by drose (10Nov99) -// -// Updated by Fei Wang, Carnegie Mellon University Entertainment -// Technology Center student, 29Jul2009: Fixed vertex color, -// animation hierarchy, texture swapping bugs; added collision choices to -// exporter. -// -// Updated by Andrew Gartner, Carnegie Mellon University Entertainment -// Technology Center. 27Apr2010: Collision is now done through User Defined Properties -// By default a plane without a standard material gets UV's as well -// as any object without a texture but with a standard material. -// Point objects are now supported as "locators" for a point in space -// within the egg. -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxToEggConverter.cxx + * @author Corey Revilla and Ken Strickland + * @date 2003-06-22 + * from mayaToEggConverter.cxx created by drose (10Nov99) + * + * Updated by Fei Wang, Carnegie Mellon University Entertainment + * Technology Center student, 29Jul2009: Fixed vertex color, + * animation hierarchy, texture swapping bugs; added collision choices to + * exporter. + * + * Updated by Andrew Gartner, Carnegie Mellon University Entertainment + * Technology Center. 27Apr2010: Collision is now done through User Defined Properties + * By default a plane without a standard material gets UV's as well + * as any object without a texture but with a standard material. + * Point objects are now supported as "locators" for a point in space + * within the egg. + */ #include "maxEgg.h" #include "config_util.h" -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaxToEggConverter:: MaxToEggConverter() { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MaxToEggConverter:: -~MaxToEggConverter() +~MaxToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::reset -//////////////////////////////////////////////////////////////////// +/** + + */ void MaxToEggConverter::reset() { _cur_tref = 0; _current_frame = 0; @@ -58,15 +54,12 @@ void MaxToEggConverter::reset() { _egg_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::convert -// Access: Public -// Description: Fills up the egg_data structure according to the -// global Max model data. Returns true if successful, -// false if there is an error. If from_selection is -// true, the converted geometry is based on that which -// is selected; otherwise, it is the entire Max scene. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the egg_data structure according to the global Max model data. + * Returns true if successful, false if there is an error. If from_selection + * is true, the converted geometry is based on that which is selected; + * otherwise, it is the entire Max scene. + */ bool MaxToEggConverter::convert(MaxEggOptions *options) { _options = options; @@ -84,15 +77,15 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { if (_egg_data->get_coordinate_system() == CS_default) { _egg_data->set_coordinate_system(CS_zup_right); } - + // Figure out the animation parameters. - + // Get the start and end frames and the animation frame rate from Max - + Interval anim_range = _options->_max_interface->GetAnimRange(); int start_frame = anim_range.Start()/GetTicksPerFrame(); int end_frame = anim_range.End()/GetTicksPerFrame(); - + if (!_options->_export_all_frames) { if (_options->_start_frame < start_frame) _options->_start_frame = start_frame; if (_options->_start_frame > end_frame) _options->_start_frame = end_frame; @@ -102,7 +95,7 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { start_frame = _options->_start_frame; end_frame = _options->_end_frame; } - + int frame_inc = 1; int output_frame_rate = GetFrameRate(); @@ -115,30 +108,32 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { _tree._export_mesh = true; all_ok = _tree.build_complete_hierarchy(_options->_max_interface->GetRootNode(), &_options->_node_list.front(), _options->_node_list.size()); } - + if (all_ok) { switch (_options->_anim_type) { case MaxEggOptions::AT_pose: - //pose: set to a specific frame, then get out the static geometry. - //sprintf(Logger::GetLogString(), "Extracting geometry from frame #%d.", start_frame); - //Logger::Log( MTEC, Logger::SAT_MEDIUM_LEVEL, Logger::GetLogString() ); - //Logger::Log( MTEC, Logger::SAT_MEDIUM_LEVEL, "Converting static model." ); + // pose: set to a specific frame, then get out the static + // geometry. sprintf(Logger::GetLogString(), "Extracting geometry + // from frame #%d.", start_frame); Logger::Log( MTEC, + // Logger::SAT_MEDIUM_LEVEL, Logger::GetLogString() ); + // Logger::Log( MTEC, Logger::SAT_MEDIUM_LEVEL, "Converting static + // model." ); _current_frame = start_frame; all_ok = convert_hierarchy(_egg_data); break; - + case MaxEggOptions::AT_model: // model: get out an animatable model with joints and vertex // membership. all_ok = convert_char_model(); break; - + case MaxEggOptions::AT_chan: // chan: get out a series of animation tables. all_ok = convert_char_chan(start_frame, end_frame, frame_inc, output_frame_rate); break; - + case MaxEggOptions::AT_both: // both: Put a model and its animation into the same egg file. _options->_anim_type = MaxEggOptions::AT_model; @@ -153,21 +148,21 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { // Set the type back to AT_both _options->_anim_type = MaxEggOptions::AT_both; break; - + default: all_ok = false; }; - + reparent_decals(_egg_data); } - + if (all_ok) { _egg_data->recompute_tangent_binormal_auto(); _egg_data->remove_unused_vertices(true); } - + _options->_successful = all_ok; - + if (all_ok) { #ifdef _UNICODE Filename fn = Filename::from_os_specific_w(_options->_file_name); @@ -180,12 +175,10 @@ bool MaxToEggConverter::convert(MaxEggOptions *options) { } } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::convert_char_model -// Access: Private -// Description: Converts the file as an animatable character -// model, with joints and vertex membership. -//////////////////////////////////////////////////////////////////// +/** + * Converts the file as an animatable character model, with joints and vertex + * membership. + */ bool MaxToEggConverter:: convert_char_model() { std::string character_name = "character"; @@ -194,17 +187,14 @@ convert_char_model() { EggGroup *char_node = new EggGroup(character_name); _egg_data->add_child(char_node); char_node->set_dart_type(EggGroup::DT_default); - + return convert_hierarchy(char_node); } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::convert_char_chan -// Access: Private -// Description: Converts the animation as a series of tables to apply -// to the character model, as retrieved earlier via -// AC_model. -//////////////////////////////////////////////////////////////////// +/** + * Converts the animation as a series of tables to apply to the character + * model, as retrieved earlier via AC_model. + */ bool MaxToEggConverter:: convert_char_chan(double start_frame, double end_frame, double frame_inc, double output_frame_rate) { @@ -222,18 +212,17 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, // created. _tree._fps = output_frame_rate / frame_inc; _tree.clear_egg(_egg_data, NULL, skeleton_node); - - // Now we can get the animation data by walking through all of the - // frames, one at a time, and getting the joint angles at each - // frame. - - // This is just a temporary EggGroup to receive the transform for - // each joint each frame. + + // Now we can get the animation data by walking through all of the frames, + // one at a time, and getting the joint angles at each frame. + + // This is just a temporary EggGroup to receive the transform for each + // joint each frame. EggGroup* tgroup; - + int num_nodes = _tree.get_num_nodes(); int i; - + TimeValue frame = start_frame; TimeValue frame_stop = end_frame; while (frame <= frame_stop) { @@ -244,16 +233,17 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, if (node_desc->is_joint()) { tgroup = new EggGroup(); INode *max_node = node_desc->get_max_node(); - + if (node_desc->_parent && node_desc->_parent->is_joint()) { - // If this joint also has a joint as a parent, the parent's - // transformation has to be divided out of this joint's TM - get_joint_transform(max_node, node_desc->_parent->get_max_node(), + // If this joint also has a joint as a parent, the + // parent's transformation has to be divided out of this + // joint's TM + get_joint_transform(max_node, node_desc->_parent->get_max_node(), tgroup); } else { get_joint_transform(max_node, NULL, tgroup); } - + EggXfmSAnim *anim = _tree.get_egg_anim(node_desc); if (!anim->add_data(tgroup->get_transform3d())) { // *** log an error @@ -261,50 +251,44 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, delete tgroup; } } - + frame += frame_inc; } - - // Now optimize all of the tables we just filled up, for no real - // good reason, except that it makes the resulting egg file a little - // easier to read. + + // Now optimize all of the tables we just filled up, for no real good + // reason, except that it makes the resulting egg file a little easier to + // read. for (i = 0; i < num_nodes; i++) { MaxNodeDesc *node_desc = _tree.get_node(i); if (node_desc->is_joint()) { _tree.get_egg_anim(node_desc)->optimize(); } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::convert_hierarchy -// Access: Private -// Description: Generates egg structures for each node in the Max -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Generates egg structures for each node in the Max hierarchy. + */ bool MaxToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { - //int num_nodes = _tree.get_num_nodes(); - + // int num_nodes = _tree.get_num_nodes(); + _tree.clear_egg(_egg_data, egg_root, NULL); for (int i = 0; i < _tree.get_num_nodes(); i++) { if (!process_model_node(_tree.get_node(i))) { return false; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::process_model_node -// Access: Private -// Description: Converts the indicated Max node to the -// corresponding Egg structure. Returns true if -// successful, false if an error was encountered. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Max node to the corresponding Egg structure. + * Returns true if successful, false if an error was encountered. + */ bool MaxToEggConverter:: process_model_node(MaxNodeDesc *node_desc) { if (!node_desc->has_max_node()) { @@ -312,8 +296,8 @@ process_model_node(MaxNodeDesc *node_desc) { return true; } - // Skip all nodes that represent joints in the geometry, but aren't - // the actual joints themselves + // Skip all nodes that represent joints in the geometry, but aren't the + // actual joints themselves if (node_desc->is_node_joint()) { return true; } @@ -326,9 +310,8 @@ process_model_node(MaxNodeDesc *node_desc) { if (node_desc->is_joint()) { EggGroup *egg_group = _tree.get_egg_group(node_desc); - // Don't bother with joints unless we're getting an animatable - // model. - if (_options->_anim_type == MaxEggOptions::AT_model) { + // Don't bother with joints unless we're getting an animatable model. + if (_options->_anim_type == MaxEggOptions::AT_model) { get_joint_transform(max_node, egg_group); } } else { @@ -336,38 +319,38 @@ process_model_node(MaxNodeDesc *node_desc) { EggGroup *egg_group = NULL; TriObject *myMaxTriObject; Mesh max_mesh; - //Call the correct exporter based on what type of object this is. + // Call the correct exporter based on what type of object this is. switch( state.obj->SuperClassID() ){ case GEOMOBJECT_CLASS_ID: egg_group = _tree.get_egg_group(node_desc); get_transform(max_node, egg_group); - - //Try converting this geometric object to a mesh we can use. + + // Try converting this geometric object to a mesh we can use. if (!state.obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) { return false; - } - //Convert our state object to a TriObject. + } + // Convert our state object to a TriObject. myMaxTriObject = (TriObject *) state.obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0 )); - // *** Want to figure this problem out - // If actual conversion was required, then we want to delete this - // new mesh later to avoid mem leaks. **BROKEN. doesnt delete - - //Now, get the mesh. + // *** Want to figure this problem out If actual conversion + // was required, then we want to delete this new mesh later to + // avoid mem leaks. **BROKEN. doesnt delete + + // Now, get the mesh. max_mesh = myMaxTriObject->GetMesh(); make_polyset(max_node, &max_mesh, egg_group); - + if (myMaxTriObject != state.obj) delete myMaxTriObject; break; - + case SHAPE_CLASS_ID: if (state.obj->ClassID() == EDITABLE_SURF_CLASS_ID) { NURBSSet getSet; if (GetNURBSSet(state.obj, time, getSet, TRUE)) { NURBSObject *nObj = getSet.GetNURBSObject(0); if (nObj->GetType() == kNCVCurve) { - //It's a CV Curve, process it + // It's a CV Curve, process it egg_group = _tree.get_egg_group(node_desc); get_transform(max_node, egg_group); make_nurbs_curve(max_node, (NURBSCVCurve *)nObj, @@ -379,44 +362,43 @@ process_model_node(MaxNodeDesc *node_desc) { case CAMERA_CLASS_ID: break; - + case LIGHT_CLASS_ID: break; - + case HELPER_CLASS_ID: - //we should export Point objects to give Max the equivalent of Maya locators + // we should export Point objects to give Max the equivalent of + // Maya locators if (state.obj->ClassID() == Class_ID(POINTHELP_CLASS_ID, 0)) { - + egg_group = _tree.get_egg_group(node_desc); get_transform(max_node, egg_group); } else { - + break; - + } - - - + + + } } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// and applies it to the corresponding Egg node. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, and applies it to the + * corresponding Egg node. + */ void MaxToEggConverter:: get_transform(INode *max_node, EggGroup *egg_group) { if (_options->_anim_type == MaxEggOptions::AT_model) { - // When we're getting an animated model, we only get transforms - // for joints. + // When we're getting an animated model, we only get transforms for + // joints. return; } @@ -424,49 +406,49 @@ get_transform(INode *max_node, EggGroup *egg_group) { return; } - // Gets the TM for this node, a matrix which encapsulates all transformations - // it takes to get to the current node, including parent transformations. + // Gets the TM for this node, a matrix which encapsulates all + // transformations it takes to get to the current node, including parent + // transformations. Matrix3 pivot = max_node->GetNodeTM(_current_frame * GetTicksPerFrame()); - //This is the Panda-flava-flav-style matrix we'll be exporting to. + // This is the Panda-flava-flav-style matrix we'll be exporting to. Point3 row0 = pivot.GetRow(0); Point3 row1 = pivot.GetRow(1); Point3 row2 = pivot.GetRow(2); Point3 row3 = pivot.GetRow(3); - + LMatrix4d m4d(row0.x, row0.y, row0.z, 0.0f, row1.x, row1.y, row1.z, 0.0f, row2.x, row2.y, row2.z, 0.0f, row3.x, row3.y, row3.z, 1.0f ); - // Now here's the tricky part. I believe this command strips out the node - // "frame" which is the sum of all transformations enacted by the parent of - // this node. This should reduce to the transformation relative to this - // node's parent + // Now here's the tricky part. I believe this command strips out the node + // "frame" which is the sum of all transformations enacted by the parent + // of this node. This should reduce to the transformation relative to + // this node's parent m4d = m4d * egg_group->get_node_frame_inv(); if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) { egg_group->add_matrix4(m4d); } } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_object_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// and applies it to the corresponding Egg node. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, and applies it to the + * corresponding Egg node. + */ LMatrix4d MaxToEggConverter:: get_object_transform(INode *max_node) { - // Gets the TM for this node, a matrix which encapsulates all transformations - // it takes to get to the current node, including parent transformations. + // Gets the TM for this node, a matrix which encapsulates all + // transformations it takes to get to the current node, including parent + // transformations. Matrix3 pivot = max_node->GetObjectTM(_current_frame * GetTicksPerFrame()); Point3 row0 = pivot.GetRow(0); Point3 row1 = pivot.GetRow(1); Point3 row2 = pivot.GetRow(2); Point3 row3 = pivot.GetRow(3); - + LMatrix4d m4d(row0.x, row0.y, row0.z, 0.0f, row1.x, row1.y, row1.z, 0.0f, row2.x, row2.y, row2.z, 0.0f, @@ -474,16 +456,13 @@ get_object_transform(INode *max_node) { return m4d; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_joint_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// as appropriate for a joint in an animated character, -// and applies it to the indicated node. This is -// different from get_transform() in that it does not -// respect the _transform_type flag, and it does not -// consider the relative transforms within the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, as appropriate for a + * joint in an animated character, and applies it to the indicated node. This + * is different from get_transform() in that it does not respect the + * _transform_type flag, and it does not consider the relative transforms + * within the egg file. + */ void MaxToEggConverter:: get_joint_transform(INode *max_node, EggGroup *egg_group) { @@ -491,8 +470,9 @@ get_joint_transform(INode *max_node, EggGroup *egg_group) { return; } - // Gets the TM for this node, a matrix which encapsulates all transformations - // it takes to get to the current node, including parent transformations. + // Gets the TM for this node, a matrix which encapsulates all + // transformations it takes to get to the current node, including parent + // transformations. Matrix3 pivot = max_node->GetNodeTM(_current_frame * GetTicksPerFrame()); Point3 row0 = pivot.GetRow(0); Point3 row1 = pivot.GetRow(1); @@ -504,26 +484,23 @@ get_joint_transform(INode *max_node, EggGroup *egg_group) { row2.x, row2.y, row2.z, 0.0f, row3.x, row3.y, row3.z, 1.0f ); - // Now here's the tricky part. I believe this command strips out the node - // "frame" which is the sum of all transformations enacted by the parent of - // this node. This should reduce to the transformation relative to this - // node's parent + // Now here's the tricky part. I believe this command strips out the node + // "frame" which is the sum of all transformations enacted by the parent + // of this node. This should reduce to the transformation relative to + // this node's parent m4d = m4d * egg_group->get_node_frame_inv(); if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) { egg_group->add_matrix4(m4d); } } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_joint_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// as appropriate for a joint in an animated character, -// and applies it to the indicated node. This is -// different from get_transform() in that it does not -// respect the _transform_type flag, and it does not -// consider the relative transforms within the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, as appropriate for a + * joint in an animated character, and applies it to the indicated node. This + * is different from get_transform() in that it does not respect the + * _transform_type flag, and it does not consider the relative transforms + * within the egg file. + */ void MaxToEggConverter:: get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group) { @@ -531,8 +508,9 @@ get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group) { return; } - // Gets the TM for this node, a matrix which encapsulates all transformations - // it takes to get to the current node, including parent transformations. + // Gets the TM for this node, a matrix which encapsulates all + // transformations it takes to get to the current node, including parent + // transformations. Matrix3 pivot = max_node->GetNodeTM(_current_frame * GetTicksPerFrame()); Point3 row0 = pivot.GetRow(0); Point3 row1 = pivot.GetRow(1); @@ -546,7 +524,7 @@ get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group) { if (parent_node) { Matrix3 parent_pivot = parent_node->GetNodeTM(_current_frame * GetTicksPerFrame()); - // parent_pivot.Invert(); + // parent_pivot.Invert(); row0 = parent_pivot.GetRow(0); row1 = parent_pivot.GetRow(1); row2 = parent_pivot.GetRow(2); @@ -557,10 +535,10 @@ get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group) { row2.x, row2.y, row2.z, 0.0f, row3.x, row3.y, row3.z, 1.0f ); - // Now here's the tricky part. I believe this command strips out the node - // "frame" which is the sum of all transformations enacted by the parent of - // this node. This should reduce to the transformation relative to this - // node's parent + // Now here's the tricky part. I believe this command strips out the + // node "frame" which is the sum of all transformations enacted by the + // parent of this node. This should reduce to the transformation + // relative to this node's parent pi_m4d.invert_in_place(); m4d = m4d * pi_m4d; } @@ -569,16 +547,14 @@ get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group) { } } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::make_nurbs_curve -// Access: Private -// Description: Converts the indicated Maya NURBS curve (a standalone -// curve, not a trim curve) to a corresponding egg -// structure and attaches it to the indicated egg group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya NURBS curve (a standalone curve, not a trim + * curve) to a corresponding egg structure and attaches it to the indicated + * egg group. + */ bool MaxToEggConverter:: make_nurbs_curve(INode *max_node, NURBSCVCurve *curve, - TimeValue time, EggGroup *egg_group) + TimeValue time, EggGroup *egg_group) { int degree = curve->GetOrder(); int cvs = curve->GetNumCVs(); @@ -623,13 +599,10 @@ make_nurbs_curve(INode *max_node, NURBSCVCurve *curve, return true; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::make_polyset -// Access: Private -// Description: Converts the indicated Maya polyset to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya polyset to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void MaxToEggConverter:: make_polyset(INode *max_node, Mesh *mesh, EggGroup *egg_group, Shader *default_shader) { @@ -640,30 +613,28 @@ make_polyset(INode *max_node, Mesh *mesh, return; } - // One way to convert the mesh would be to first get out all the - // vertices in the mesh and add them into the vpool, then when we - // traverse the polygons we would only have to index them into the - // vpool according to their Maya vertex index. + // One way to convert the mesh would be to first get out all the vertices + // in the mesh and add them into the vpool, then when we traverse the + // polygons we would only have to index them into the vpool according to + // their Maya vertex index. - // Unfortunately, since Maya may store multiple normals and/or - // colors for each vertex according to which polygon it is in, that - // approach won't necessarily work. In egg, those split-property - // vertices have to become separate vertices. So instead of adding - // all the vertices up front, we'll start with an empty vpool, and - // add vertices to it on the fly. + // Unfortunately, since Maya may store multiple normals andor colors for + // each vertex according to which polygon it is in, that approach won't + // necessarily work. In egg, those split-property vertices have to become + // separate vertices. So instead of adding all the vertices up front, + // we'll start with an empty vpool, and add vertices to it on the fly. string node_name = max_node->GetName(); string vpool_name = node_name + ".verts"; EggVertexPool *vpool = new EggVertexPool(vpool_name); egg_group->add_child(vpool); - // We will need to transform all vertices from world coordinate - // space into the vertex space appropriate to this node. Usually, - // this is the same thing as world coordinate space, and this matrix - // will be identity; but if the node is under an instance - // (particularly, for instance, a billboard) then the vertex space - // will be different from world space. - LMatrix4d vertex_frame = get_object_transform(max_node) * + // We will need to transform all vertices from world coordinate space into + // the vertex space appropriate to this node. Usually, this is the same + // thing as world coordinate space, and this matrix will be identity; but + // if the node is under an instance (particularly, for instance, a + // billboard) then the vertex space will be different from world space. + LMatrix4d vertex_frame = get_object_transform(max_node) * egg_group->get_vertex_frame_inv(); @@ -690,8 +661,8 @@ make_polyset(INode *max_node, Mesh *mesh, // Get the vertex normal Point3 normal = get_max_vertex_normal(mesh, iFace, iVertex); LVector3d n3d(normal.x, normal.y, normal.z); - // *** Not quite sure if this transform should be applied, but it may - // explain why normals were weird previously + // *** Not quite sure if this transform should be applied, but it + // may explain why normals were weird previously n3d = n3d * vertex_frame; vert.set_normal(n3d); @@ -704,19 +675,18 @@ make_polyset(INode *max_node, Mesh *mesh, } // Get the UVs for this vertex - //first check if we returned nothing in the channels slot - //we need UV's even in this case - //because the user may not have put a material - //on the object at all + // first check if we returned nothing in the channels slot we need + // UV's even in this case because the user may not have put a + // material on the object at all if (pmat._map_channels.size() == 0) { - //since the channel will always be one because there's - //no other textures then don't bother with the name + // since the channel will always be one because there's no other + // textures then don't bother with the name UVVert uvw = get_max_vertex_texcoord(mesh, iFace, iVertex, 1); - vert.set_uv( LTexCoordd(uvw.x, uvw.y)); + vert.set_uv( LTexCoordd(uvw.x, uvw.y)); } - //otherwise go through and generate the maps per channel - //this will also generate default UV's as long - //as the user applies a standard material to the object + // otherwise go through and generate the maps per channel this + // will also generate default UV's as long as the user applies a + // standard material to the object for (int iChan=0; iChanadd_vertex(vpool->create_unique_vertex(vert)); } - //Max uses normals, not winding, to determine which way a - //polygon faces. Make sure the winding and that normal agree - + // Max uses normals, not winding, to determine which way a polygon + // faces. Make sure the winding and that normal agree + EggVertex *verts[3]; LPoint3d points[3]; - + for (int i = 0; i < 3; i++) { verts[i] = egg_poly->get_vertex(i); points[i] = verts[i]->get_pos3(); @@ -760,14 +730,14 @@ make_polyset(INode *max_node, Mesh *mesh, egg_poly->add_texture(pmat._texture_list[i]); } egg_poly->set_color(pmat._color); - + } - - // Now that we've added all the polygons (and created all the - // vertices), go back through the vertex pool and set up the - // appropriate joint membership for each of the vertices. - + + // Now that we've added all the polygons (and created all the vertices), + // go back through the vertex pool and set up the appropriate joint + // membership for each of the vertices. + if (_options->_anim_type == MaxEggOptions::AT_model) { get_vertex_weights(max_node, vpool); } @@ -794,9 +764,9 @@ VertColor MaxToEggConverter::get_max_vertex_color(Mesh *mesh,int FaceNo,int Vert { // We get the color from vcFace TVFace& _vcface = mesh->vcFace[FaceNo]; - //Get its index into the vertCol array + // Get its index into the vertCol array int VertexColorIndex = _vcface.t[VertexNo]; - //Get its color + // Get its color vc =mesh->vertCol[VertexColorIndex]; } else @@ -812,30 +782,30 @@ VertColor MaxToEggConverter::get_max_vertex_color(Mesh *mesh,int FaceNo,int Vert VertColor vc(0,0,0); // We get the color from vcFace TVFace& _vcface = mesh->vcFace[FaceNo]; - //Get its index into the vertCol array + // Get its index into the vertCol array int VertexColorIndex = _vcface.t[VertexNo]; - //Get its color + // Get its color vc =mesh->vertCol[VertexColorIndex]; return vc; } - + Point3 MaxToEggConverter::get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo) { Face f = mesh->faces[faceNo]; DWORD smGroup = f.smGroup; int vert = f.getVert(vertNo); RVertex *rv = mesh->getRVertPtr(vert); - + int numNormals; Point3 vertexNormal; - // Is normal specified - // SPCIFIED is not currently used, but may be used in future versions. + // Is normal specified SPCIFIED is not currently used, but may be used in + // future versions. if (rv->rFlags & SPECIFIED_NORMAL) { vertexNormal = rv->rn.getNormal(); } - // If normal is not specified it's only available if the face belongs - // to a smoothing group + // If normal is not specified it's only available if the face belongs to a + // smoothing group else if ((numNormals = rv->rFlags & NORCT_MASK) && smGroup) { // If there is only one vertex is found in the rn member. if (numNormals == 1) { @@ -843,8 +813,9 @@ Point3 MaxToEggConverter::get_max_vertex_normal(Mesh *mesh, int faceNo, int vert } else { // If two or more vertices are there you need to step through them - // and find the vertex with the same smoothing group as the current face. - // You will find multiple normals in the ern member. + // and find the vertex with the same smoothing group as the + // current face. You will find multiple normals in the ern + // member. for (int i = 0; i < numNormals; i++) { if (rv->ern[i].getSmGroup() & smGroup) { vertexNormal = rv->ern[i].getNormal(); @@ -856,18 +827,16 @@ Point3 MaxToEggConverter::get_max_vertex_normal(Mesh *mesh, int faceNo, int vert // Get the normal from the Face if no smoothing groups are there vertexNormal = mesh->getFaceNormal(faceNo); } - + return vertexNormal; } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_vertex_weights -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter:: get_vertex_weights(INode *max_node, EggVertexPool *vpool) { - //Try to get the weights out of a physique if one exists + // Try to get the weights out of a physique if one exists Modifier *mod = FindSkinModifier(max_node, PHYSIQUE_CLASSID); EggVertexPool::iterator vi; @@ -876,19 +845,19 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { IPhysiqueExport *pPhysiqueExport = (IPhysiqueExport *)mod->GetInterface(I_PHYINTERFACE); if (pPhysiqueExport) { // create a context export interface - IPhyContextExport *pContextExport = + IPhyContextExport *pContextExport = (IPhyContextExport *)pPhysiqueExport->GetContextInterface(max_node); if (pContextExport) { // set the flags in the context export interface pContextExport->ConvertToRigid(TRUE); pContextExport->AllowBlending(TRUE); - + for (vi = vpool->begin(); vi != vpool->end(); ++vi) { EggVertex *vert = (*vi); int max_vi = vert->get_external_index(); // get the vertex export interface - IPhyVertexExport *pVertexExport = + IPhyVertexExport *pVertexExport = (IPhyVertexExport *)pContextExport->GetVertexInterface(max_vi); if (pVertexExport) { int vertexType = pVertexExport->GetVertexType(); @@ -922,19 +891,19 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { } } } - //Release the vertex interface + // Release the vertex interface pContextExport->ReleaseVertexInterface(pVertexExport); } } - //Release the context interface + // Release the context interface pPhysiqueExport->ReleaseContextInterface(pContextExport); } - //Release the physique export interface + // Release the physique export interface mod->ReleaseInterface(I_PHYINTERFACE, pPhysiqueExport); } } else { - //No physique, try to find a skin + // No physique, try to find a skin mod = FindSkinModifier(max_node, SKIN_CLASSID); if (mod) { ISkin *skin = (ISkin*)mod->GetInterface(I_SKIN); @@ -944,7 +913,7 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { for (vi = vpool->begin(); vi != vpool->end(); ++vi) { EggVertex *vert = (*vi); int max_vi = vert->get_external_index(); - + for (int ji = 0; ji < skinMC->GetNumAssignedBones(max_vi); ++ji) { PN_stdfloat weight = skinMC->GetBoneWeight(max_vi, ji); if (weight > 0.0f) { @@ -966,12 +935,9 @@ get_vertex_weights(INode *max_node, EggVertexPool *vpool) { } -//////////////////////////////////////////////////////////////////// -// Function: MaxToEggConverter::get_material_textures -// Access: Private -// Description: Converts a Max material into a set of Panda textures -// and a primitive color. -//////////////////////////////////////////////////////////////////// +/** + * Converts a Max material into a set of Panda textures and a primitive color. + */ const MaxToEggConverter::PandaMaterial &MaxToEggConverter:: get_panda_material(Mtl *mtl, MtlID matID) { @@ -979,19 +945,19 @@ get_panda_material(Mtl *mtl, MtlID matID) { if (it != _material_map.end()) { return (*it).second; } - + PandaMaterial &pandaMat = _material_map[mtl]; pandaMat._color = LColor(1,1,1,1); pandaMat._any_diffuse = false; pandaMat._any_opacity = false; pandaMat._any_gloss = false; pandaMat._any_normal = false; - - - + + + // If it's a multi-material, dig down. - + while (( mtl != 0) && (mtl->ClassID() == Class_ID(MULTI_CLASS_ID, 0 ))) { if (matID < mtl->NumSubMtls()) { mtl = mtl->GetSubMtl(matID); @@ -1001,7 +967,7 @@ get_panda_material(Mtl *mtl, MtlID matID) { } // If it's a standard material, we're good. - + if ((mtl != 0) && (mtl->ClassID() == Class_ID(DMTL_CLASS_ID, 0 ))) { StdMat *maxMaterial = (StdMat*)mtl; analyze_diffuse_maps(pandaMat, maxMaterial->GetSubTexmap(ID_DI)); @@ -1022,7 +988,8 @@ get_panda_material(Mtl *mtl, MtlID matID) { // The existence of a texture on either color channel completely // replaces the corresponding flat color. if (!pandaMat._any_diffuse) { - // Get the default diffuse color of the material without the texture map + // Get the default diffuse color of the material without the + // texture map Point3 diffuseColor = Point3(maxMaterial->GetDiffuse(0)); pandaMat._color[0] = diffuseColor.x; pandaMat._color[1] = diffuseColor.y; @@ -1032,22 +999,19 @@ get_panda_material(Mtl *mtl, MtlID matID) { pandaMat._color[3] = (maxMaterial->GetOpacity(_current_frame * GetTicksPerFrame())); } if (pandaMat._texture_list.size() < 1) { - //if we don't have any maps whatsoever, - //give the material a dummy channel - //so that UV's get created + // if we don't have any maps whatsoever, give the material a dummy + // channel so that UV's get created pandaMat._map_channels.push_back(1); } return pandaMat; } - // Otherwise, it's unrecognizable. Leave result blank. + // Otherwise, it's unrecognizable. Leave result blank. return pandaMat; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::analyze_diffuse_maps -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter::analyze_diffuse_maps(PandaMaterial &pandaMat, Texmap *mat) { if (mat == 0) return; @@ -1090,14 +1054,12 @@ void MaxToEggConverter::analyze_diffuse_maps(PandaMaterial &pandaMat, Texmap *ma } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::analyze_opacity_maps -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter::analyze_opacity_maps(PandaMaterial &pandaMat, Texmap *mat) { if (mat == 0) return; - + if (mat->ClassID() == Class_ID(RGBMULT_CLASS_ID, 0)) { for (int i=0; iNumSubTexmaps(); i++) { analyze_opacity_maps(pandaMat, mat->GetSubTexmap(i)); @@ -1126,7 +1088,7 @@ void MaxToEggConverter::analyze_opacity_maps(PandaMaterial &pandaMat, Texmap *ma return; } } - + // Try to find a diffuse map to pair this with as an alpha-texture. std::string uvname = get_uv_name(transTex->GetMapChannel()); for (int i=0; iset_filename(outpath); @@ -1154,14 +1116,12 @@ void MaxToEggConverter::analyze_opacity_maps(PandaMaterial &pandaMat, Texmap *ma } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::analyze_glow_maps -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter::analyze_glow_maps(PandaMaterial &pandaMat, Texmap *mat) { if (mat == 0) return; - + if (mat->ClassID() == Class_ID(BMTEX_CLASS_ID, 0)) { BitmapTex *gtex = (BitmapTex *)mat; @@ -1188,7 +1148,7 @@ void MaxToEggConverter::analyze_glow_maps(PandaMaterial &pandaMat, Texmap *mat) return; } } - + // Otherwise, just create it as a separate glow-texture. PT(EggTexture) tex = new EggTexture(generate_tex_name(), ""); tex->set_env_type(EggTexture::ET_glow); @@ -1197,19 +1157,17 @@ void MaxToEggConverter::analyze_glow_maps(PandaMaterial &pandaMat, Texmap *mat) apply_texture_properties(*tex, gtex->GetMapChannel()); add_map_channel(pandaMat, gtex->GetMapChannel()); tex->set_format(EggTexture::F_alpha); - + pandaMat._texture_list.push_back(tex); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::analyze_gloss_maps -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter::analyze_gloss_maps(PandaMaterial &pandaMat, Texmap *mat) { if (mat == 0) return; - + if (mat->ClassID() == Class_ID(BMTEX_CLASS_ID, 0)) { pandaMat._any_gloss = true; BitmapTex *gtex = (BitmapTex *)mat; @@ -1237,7 +1195,7 @@ void MaxToEggConverter::analyze_gloss_maps(PandaMaterial &pandaMat, Texmap *mat) return; } } - + // Otherwise, just create it as a separate gloss-texture. PT(EggTexture) tex = new EggTexture(generate_tex_name(), ""); tex->set_env_type(EggTexture::ET_gloss); @@ -1246,19 +1204,17 @@ void MaxToEggConverter::analyze_gloss_maps(PandaMaterial &pandaMat, Texmap *mat) apply_texture_properties(*tex, gtex->GetMapChannel()); add_map_channel(pandaMat, gtex->GetMapChannel()); tex->set_format(EggTexture::F_alpha); - + pandaMat._texture_list.push_back(tex); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::analyze_normal_maps -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MaxToEggConverter::analyze_normal_maps(PandaMaterial &pandaMat, Texmap *mat) { if (mat == 0) return; - + if (mat->ClassID() == Class_ID(BMTEX_CLASS_ID, 0)) { pandaMat._any_normal = true; BitmapTex *ntex = (BitmapTex *)mat; @@ -1279,17 +1235,15 @@ void MaxToEggConverter::analyze_normal_maps(PandaMaterial &pandaMat, Texmap *mat apply_texture_properties(*tex, ntex->GetMapChannel()); add_map_channel(pandaMat, ntex->GetMapChannel()); tex->set_format(EggTexture::F_rgb); - + pandaMat._texture_list.push_back(tex); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::add_map_channel -// Access: Private -// Description: Adds the specified map channel to the map channel -// list, if it's not already there. -//////////////////////////////////////////////////////////////////// +/** + * Adds the specified map channel to the map channel list, if it's not already + * there. + */ void MaxToEggConverter::add_map_channel(PandaMaterial &pandaMat, int chan) { for (int i=0; i decal_children; @@ -1398,9 +1341,9 @@ reparent_decals(EggGroupNode *egg_parent) { } else { // All the decal children get moved to be a child of decal base. - // This usually will not affect the vertex positions, but it - // could if the decal base has a transform and the decal child - // is an instance node. So don't do that. + // This usually will not affect the vertex positions, but it could + // if the decal base has a transform and the decal child is an + // instance node. So don't do that. pvector::iterator di; for (di = decal_children.begin(); di != decal_children.end(); ++di) { EggGroup *child_group = (*di); @@ -1428,7 +1371,7 @@ reparent_decals(EggGroupNode *egg_parent) { Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type) { - // Get object from node. Abort if no object. + // Get object from node. Abort if no object. Object* pObj = node->GetObjectRef(); if (!pObj) return NULL; @@ -1441,7 +1384,7 @@ Modifier* MaxToEggConverter::FindSkinModifier (INode* node, const Class_ID &type for (int stackId = 0; stackId < pDerObj->NumModifiers(); ++stackId) { // Get current modifier. Modifier* mod = pDerObj->GetModifier(stackId); - + // Is this what we are looking for? if (mod->ClassID() == type ) return mod; diff --git a/pandatool/src/maxegg/maxToEggConverter.h b/pandatool/src/maxegg/maxToEggConverter.h index 6ecde0c86c..0225565843 100644 --- a/pandatool/src/maxegg/maxToEggConverter.h +++ b/pandatool/src/maxegg/maxToEggConverter.h @@ -1,17 +1,16 @@ -// Filename: maxToEggConverter.h -// Created by Corey Revilla and Ken Strickland (6/22/03) -// from mayaToEggConverter.cxx created by drose (10Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxToEggConverter.h + * @author Corey Revilla and Ken Strickland + * @date 2003-06-22 + * from mayaToEggConverter.cxx created by drose (10Nov99) + */ #ifndef __maxToEggConverter__H #define __maxToEggConverter__H @@ -29,21 +28,20 @@ /* External Helper Functions for UI */ -// *** Figure out why this is causing link errors -//DWORD WINAPI ProgressBarFunction(LPVOID arg); +// *** Figure out why this is causing link errors DWORD WINAPI +// ProgressBarFunction(LPVOID arg); -//////////////////////////////////////////////////////////////////// -// Class : MaxToEggConverter -// Description : This class supervises the construction of an EggData -// structure from a Max model -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a Max + * model + */ class MaxToEggConverter { public: MaxToEggConverter(); ~MaxToEggConverter(); bool convert(MaxEggOptions *options); - + private: struct PandaMaterial { std::vector _texture_list; @@ -63,21 +61,21 @@ class MaxToEggConverter { int _cur_tref; EggTextureCollection _textures; MaterialMap _material_map; - + void reset(); bool convert_char_model(); - bool convert_char_chan(double start_frame, double end_frame, + bool convert_char_chan(double start_frame, double end_frame, double frame_inc, double output_frame_rate); bool convert_hierarchy(EggGroupNode *egg_root); bool process_model_node(MaxNodeDesc *node_desc); - + void get_transform(INode *max_node, EggGroup *egg_group); LMatrix4d get_object_transform(INode *max_node); void get_joint_transform(INode *max_node, EggGroup *egg_group); - void get_joint_transform(INode *max_node, INode *parent_node, + void get_joint_transform(INode *max_node, INode *parent_node, EggGroup *egg_group); - + bool make_nurbs_curve(INode *max_node, NURBSCVCurve *curve, TimeValue time, EggGroup *egg_group); void make_polyset(INode *max_node, @@ -89,7 +87,7 @@ class MaxToEggConverter { VertColor get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo); VertColor get_max_vertex_color(Mesh *mesh,int FaceNo,int VertexNo, int channel); UVVert get_max_vertex_texcoord(Mesh *mesh, int faceNo, int vertNo, int channel); - + void get_vertex_weights(INode *max_node, EggVertexPool *vpool); const PandaMaterial &get_panda_material(Mtl *mtl, MtlID id); @@ -103,9 +101,9 @@ class MaxToEggConverter { std::string generate_tex_name(); std::string get_uv_name(int n); bool reparent_decals(EggGroupNode *egg_parent); - + public: - + Modifier* FindSkinModifier (INode* node, const Class_ID &type); }; diff --git a/pandatool/src/maxprogs/maxEggImport.cxx b/pandatool/src/maxprogs/maxEggImport.cxx index e9bb2559ac..52a9cd369f 100644 --- a/pandatool/src/maxprogs/maxEggImport.cxx +++ b/pandatool/src/maxprogs/maxEggImport.cxx @@ -1,26 +1,23 @@ -// Filename: maxEggImport.cxx -// Created by: jyelon (15Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// This is the wrapper code for the max importer plugin. -// It includes: -// -// - user interface dialogs and popups -// - plugin initialization/registration -// -// It does not include the actual code to traverse the EggData. -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maxEggImport.cxx + * @author jyelon + * @date 2005-07-15 + * + * This is the wrapper code for the max importer plugin. + * It includes: + * + * - user interface dialogs and popups + * - plugin initialization/registration + * + * It does not include the actual code to traverse the EggData. + */ // Include this before everything #include "pandatoolbase.h" @@ -201,15 +198,9 @@ int MaxEggImporter::DoImport(const TCHAR *name,ImpInterface *ii,Interface *i, BO return 1; } -//////////////////////////////////////////////////////////////////// -// -// Plugin Initialization -// -// The following code enables Max to load this DLL, get a list -// of the classes defined in this DLL, and provides a means for -// Max to create instances of those classes. -// -//////////////////////////////////////////////////////////////////// +// Plugin Initialization The following code enables Max to load this DLL, get +// a list of the classes defined in this DLL, and provides a means for Max to +// create instances of those classes. HINSTANCE hInstance; @@ -219,9 +210,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { if (!controlsInit) { controlsInit = TRUE; - // It appears that InitCustomControls is deprecated in 2012. - // I'm not sure if we can just remove it like this, but - // I've heard that it seems to work, so let's do it like this. + // It appears that InitCustomControls is deprecated in 2012. I'm not sure + // if we can just remove it like this, but I've heard that it seems to + // work, so let's do it like this. #if MAX_VERSION_MAJOR < 14 InitCustomControls(hInstance); #endif @@ -268,4 +259,3 @@ __declspec( dllexport ) ULONG LibVersion() { return VERSION_3DSMAX; } - diff --git a/pandatool/src/maya/config_maya.cxx b/pandatool/src/maya/config_maya.cxx index 630177ead4..2608243f9d 100644 --- a/pandatool/src/maya/config_maya.cxx +++ b/pandatool/src/maya/config_maya.cxx @@ -1,16 +1,15 @@ -// Filename: config_maya.cxx -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_maya.cxx + * @author drose + * @date 2002-04-15 + */ #include "config_maya.h" @@ -33,14 +32,12 @@ ConfigVariableDouble init_maya_timeout PRC_DESC("The number of seconds to wait between attempts to acquire the " "Maya license.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libmaya -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmaya() { static bool initialized = false; @@ -49,4 +46,3 @@ init_libmaya() { } initialized = true; } - diff --git a/pandatool/src/maya/config_maya.h b/pandatool/src/maya/config_maya.h index 7d639db258..256f4842e3 100644 --- a/pandatool/src/maya/config_maya.h +++ b/pandatool/src/maya/config_maya.h @@ -1,16 +1,15 @@ -// Filename: config_maya.h -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_maya.h + * @author drose + * @date 2002-04-15 + */ #ifndef CONFIG_MAYA_H #define CONFIG_MAYA_H diff --git a/pandatool/src/maya/mayaApi.cxx b/pandatool/src/maya/mayaApi.cxx index 1014b64661..be7c36ed6a 100644 --- a/pandatool/src/maya/mayaApi.cxx +++ b/pandatool/src/maya/mayaApi.cxx @@ -1,16 +1,15 @@ -// Filename: mayaApi.cxx -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaApi.cxx + * @author drose + * @date 2002-04-15 + */ #include "mayaApi.h" #include "config_maya.h" @@ -32,38 +31,35 @@ MayaApi *MayaApi::_global_api = (MayaApi *)NULL; -// We need this bogus object just to force the application to link -// with OpenMayaAnim.lib; otherwise, Maya will complain (when compiled -// on Windows) that it is unable to find source plug 'ikRPsolver.msg'. +// We need this bogus object just to force the application to link with +// OpenMayaAnim.lib; otherwise, Maya will complain (when compiled on Windows) +// that it is unable to find source plug 'ikRPsolver.msg'. static MFnAnimCurve force_link_with_OpenMayaAnim; -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::Constructor -// Access: Protected -// Description: Don't attempt to create this object directly; -// instead, use the open_api() method. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to create this object directly; instead, use the open_api() + * method. + */ MayaApi:: MayaApi(const string &program_name, bool view_license, bool revert_dir) { if (program_name == "plug-in") { - // In this special case, we are invoking the code from within a - // plug-in, so we need not (and should not) call - // MLibrary::initialize(). + // In this special case, we are invoking the code from within a plug-in, + // so we need not (and should not) call MLibrary::initialize(). _plug_in = true; _is_valid = true; return; } - // Otherwise, if program_name is any other name, we are invoking the - // code from a standalone application and we do need to call + // Otherwise, if program_name is any other name, we are invoking the code + // from a standalone application and we do need to call // MLibrary::initialize(). _plug_in = false; - // Beginning with Maya4.5, the call to initialize seems to change - // the current directory! Yikes! + // Beginning with Maya4.5, the call to initialize seems to change the + // current directory! Yikes! - // Furthermore, the current directory may change during the call to - // any Maya function! Egad! + // Furthermore, the current directory may change during the call to any Maya + // function! Egad! _cwd = ExecutionEnvironment::get_cwd(); MStatus stat = MLibrary::initialize(false, (char *)program_name.c_str(), view_license); @@ -75,22 +71,22 @@ MayaApi(const string &program_name, bool view_license, bool revert_dir) { --error_count; } - // Restore the current directory. Ever since Maya 2010, there seems to be + // Restore the current directory. Ever since Maya 2010, there seems to be // some bad mojo when you do this. if( revert_dir ){ - string dirname = _cwd.to_os_specific(); - if (chdir(dirname.c_str()) < 0) { - maya_cat.warning() - << "Unable to restore current directory to " << _cwd - << " after initializing Maya.\n"; - } else { - if (maya_cat.is_debug()) { - maya_cat.debug() - << "Restored current directory to " << _cwd << "\n"; - } - } + string dirname = _cwd.to_os_specific(); + if (chdir(dirname.c_str()) < 0) { + maya_cat.warning() + << "Unable to restore current directory to " << _cwd + << " after initializing Maya.\n"; + } else { + if (maya_cat.is_debug()) { + maya_cat.debug() + << "Restored current directory to " << _cwd << "\n"; + } + } } - + if (!stat) { stat.perror("MLibrary::initialize"); @@ -100,60 +96,49 @@ MayaApi(const string &program_name, bool view_license, bool revert_dir) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::Copy Constructor -// Access: Protected -// Description: Don't attempt to copy MayaApi objects. There should -// be only one of these in the world at a time. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy MayaApi objects. There should be only one of these + * in the world at a time. + */ MayaApi:: MayaApi(const MayaApi ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::Copy Assignment Operator -// Access: Protected -// Description: Don't attempt to copy MayaApi objects. There should -// be only one of these in the world at a time. -//////////////////////////////////////////////////////////////////// +/** + * Don't attempt to copy MayaApi objects. There should be only one of these + * in the world at a time. + */ void MayaApi:: operator = (const MayaApi ©) { nassertv(false); } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaApi:: ~MayaApi() { nassertv(_global_api == this); if (_is_valid && !_plug_in) { - // Caution! Calling this function seems to call exit() somewhere - // within Maya code. + // Caution! Calling this function seems to call exit() somewhere within + // Maya code. MLibrary::cleanup(); } _global_api = (MayaApi *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::open_api -// Access: Public, Static -// Description: Opens the Maya API, if it is not already open, and -// returns a pointer representing this connection. When -// you are done using the Maya API, let the pointer -// destruct. -// -// If program_name is supplied, it is passed to Maya as -// the name of the currently-executing program. -// Otherwise, the current program name is extracted from -// the execution environment, if possible. The special -// program_name "plug-in" is used for code that is -// intended to be invoked as a plug-in only; in this -// case, the maya library is not re-initialized. -//////////////////////////////////////////////////////////////////// +/** + * Opens the Maya API, if it is not already open, and returns a pointer + * representing this connection. When you are done using the Maya API, let + * the pointer destruct. + * + * If program_name is supplied, it is passed to Maya as the name of the + * currently-executing program. Otherwise, the current program name is + * extracted from the execution environment, if possible. The special + * program_name "plug-in" is used for code that is intended to be invoked as a + * plug-in only; in this case, the maya library is not re-initialized. + */ PT(MayaApi) MayaApi:: open_api(string program_name, bool view_license, bool revertdir) { if (_global_api == (MayaApi *)NULL) { @@ -167,22 +152,22 @@ open_api(string program_name, bool view_license, bool revertdir) { _global_api = new MayaApi(program_name, view_license, revertdir); - // Try to compare the string-formatted runtime version number with - // the numeric compile-time version number, so we can sanity check - // our runtime environment. (Sure would be nice if Maya provided - // an apples-to-apples comparison for us.) + // Try to compare the string-formatted runtime version number with the + // numeric compile-time version number, so we can sanity check our runtime + // environment. (Sure would be nice if Maya provided an apples-to-apples + // comparison for us.) - // According to the Maya specs, the numeric value is derived by - // taking the Maya version number and deleting the '.' characters, - // while also ignoring everything after the second dot (and, for - // some reason, appending a 0). + // According to the Maya specs, the numeric value is derived by taking the + // Maya version number and deleting the '.' characters, while also + // ignoring everything after the second dot (and, for some reason, + // appending a 0). string runtime_version = MGlobal::mayaVersion().asChar(); string simple_runtime_version = runtime_version; runtime_version = trim(runtime_version); - // If the version number contains a space, stop there (that would - // be "service pack 1" or whatever). + // If the version number contains a space, stop there (that would be + // "service pack 1" or whatever). size_t space = runtime_version.find(' '); if (space != string::npos) { runtime_version = runtime_version.substr(0, space); @@ -196,7 +181,7 @@ open_api(string program_name, bool view_license, bool revertdir) { } else { string_to_int(runtime_version.substr(0, dot1), rtver_a); - + size_t dot2 = runtime_version.find('.', dot1 + 1); if (dot2 == string::npos) { rtver_b = 0; @@ -210,7 +195,7 @@ open_api(string program_name, bool view_license, bool revertdir) { if (maya_cat.is_debug()) { maya_cat.debug() - << "Compiled with Maya library version " + << "Compiled with Maya library version " << (MAYA_API_VERSION / 100) << "." << (MAYA_API_VERSION / 10) % 10 << " (" << MAYA_API_VERSION << "); running with library version " << runtime_version << ".\n"; @@ -218,7 +203,7 @@ open_api(string program_name, bool view_license, bool revertdir) { if (MAYA_API_VERSION / 10 != runtime_version_int / 10) { maya_cat.warning() - << "This program was compiled using Maya version " + << "This program was compiled using Maya version " << (MAYA_API_VERSION / 100) << "." << (MAYA_API_VERSION / 10) % 10 << ", but you are now running it with Maya version " << simple_runtime_version @@ -229,12 +214,10 @@ open_api(string program_name, bool view_license, bool revertdir) { return _global_api; } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::is_valid -// Access: Public -// Description: Returns true if the API has been successfully opened -// and may be used, or false if there is some problem. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the API has been successfully opened and may be used, or + * false if there is some problem. + */ bool MayaApi:: is_valid() const { return _is_valid; @@ -255,20 +238,18 @@ back_to_front_slash(const string &str) { } #endif // WIN32 -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::read -// Access: Public -// Description: Reads the indicated maya file into the global model -// space. Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated maya file into the global model space. Returns true if + * successful, false otherwise. + */ bool MayaApi:: read(const Filename &filename) { MFileIO::newFile(true); maya_cat.info() << "Reading " << filename << "\n"; - // Load the file into Maya. Maya seems to want forward slashes, - // even on Windows. + // Load the file into Maya. Maya seems to want forward slashes, even on + // Windows. string os_filename = filename.to_os_generic(); string dirname = _cwd.to_os_specific(); @@ -278,11 +259,11 @@ read(const Filename &filename) { MFileIO::newFile(true); MStatus stat = MFileIO::open(os_filename.c_str()); - // Beginning with Maya2008, the call to read seem to change - // the current directory specially if there is a refrence file! Yikes! + // Beginning with Maya2008, the call to read seem to change the current + // directory specially if there is a refrence file! Yikes! - // Furthermore, the current directory may change during the call to - // any Maya function! Egad! + // Furthermore, the current directory may change during the call to any Maya + // function! Egad! if (chdir(dirname.c_str()) < 0) { maya_cat.warning() << "Unable to restore current directory after ::read to " << _cwd @@ -300,12 +281,10 @@ read(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::write -// Access: Public -// Description: Writes the global model space to the indicated file. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the global model space to the indicated file. Returns true if + * successful, false otherwise. + */ bool MayaApi:: write(const Filename &filename) { maya_cat.info() << "Writing " << filename << "\n"; @@ -327,11 +306,11 @@ write(const Filename &filename) { stat.perror(os_filename.c_str()); return false; } - // Beginning with Maya2008, the call to read seem to change - // the current directory specially if there is a refrence file! Yikes! + // Beginning with Maya2008, the call to read seem to change the current + // directory specially if there is a refrence file! Yikes! - // Furthermore, the current directory may change during the call to - // any Maya function! Egad! + // Furthermore, the current directory may change during the call to any Maya + // function! Egad! if (chdir(dirname.c_str()) < 0) { maya_cat.warning() << "Unable to restore current directory after ::write to " << _cwd @@ -345,13 +324,11 @@ write(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::clear -// Access: Public -// Description: Resets the global model space to the empty state, for -// instance in preparation for building a new file. -// Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Resets the global model space to the empty state, for instance in + * preparation for building a new file. Returns true if successful, false + * otherwise. + */ bool MayaApi:: clear() { MStatus stat = MFileIO::newFile(true); @@ -362,11 +339,9 @@ clear() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::get_units -// Access: Public -// Description: Returns Maya's internal units in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns Maya's internal units in effect. + */ DistanceUnit MayaApi:: get_units() { switch (MDistance::internalUnit()) { @@ -392,11 +367,9 @@ get_units() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::set_units -// Access: Public -// Description: Set Maya's UI units. -//////////////////////////////////////////////////////////////////// +/** + * Set Maya's UI units. + */ void MayaApi:: set_units(DistanceUnit unit) { switch (unit) { @@ -430,11 +403,9 @@ set_units(DistanceUnit unit) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaApi::get_coordinate_system -// Access: Public -// Description: Returns Maya's internal coordinate system in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns Maya's internal coordinate system in effect. + */ CoordinateSystem MayaApi:: get_coordinate_system() { if (MGlobal::isYAxisUp()) { diff --git a/pandatool/src/maya/mayaApi.h b/pandatool/src/maya/mayaApi.h index 0c2fe30e1a..590f7b4817 100644 --- a/pandatool/src/maya/mayaApi.h +++ b/pandatool/src/maya/mayaApi.h @@ -1,16 +1,15 @@ -// Filename: mayaApi.h -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaApi.h + * @author drose + * @date 2002-04-15 + */ #ifndef MAYAAPI_H #define MAYAAPI_H @@ -23,13 +22,11 @@ class Filename; -//////////////////////////////////////////////////////////////////// -// Class : MayaApi -// Description : This class presents a wrapper around the global -// Maya interface. While the reference count is held, -// it keeps the Maya interface open, and closes the -// interface when the object destructs. -//////////////////////////////////////////////////////////////////// +/** + * This class presents a wrapper around the global Maya interface. While the + * reference count is held, it keeps the Maya interface open, and closes the + * interface when the object destructs. + */ class MayaApi : public ReferenceCount { protected: MayaApi(const string &program_name, bool view_license = false, bool revertdir = true); diff --git a/pandatool/src/maya/mayaShader.cxx b/pandatool/src/maya/mayaShader.cxx index b008668e5b..f012539b81 100644 --- a/pandatool/src/maya/mayaShader.cxx +++ b/pandatool/src/maya/mayaShader.cxx @@ -1,18 +1,17 @@ -// Filename: mayaShader.cxx -// Created by: drose (01Feb00) -// Modified 19Mar10 by ETC PandaSE team (see -// header comment for mayaToEgg.cxx for details) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShader.cxx + * @author drose + * @date 2000-02-01 + * Modified 19Mar10 by ETC PandaSE team (see + * header comment for mayaToEgg.cxx for details) + */ #include "mayaShader.h" #include "maya_funcs.h" @@ -33,12 +32,10 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::Constructor -// Access: Public -// Description: Reads the Maya "shading engine" to determine the -// relevant shader properties. -//////////////////////////////////////////////////////////////////// +/** + * Reads the Maya "shading engine" to determine the relevant shader + * properties. + */ MayaShader:: MayaShader(MObject engine, bool legacy_shader) { MFnDependencyNode engine_fn(engine); @@ -60,7 +57,7 @@ MayaShader(MObject engine, bool legacy_shader) { maya_cat.spam() << "shader plug connected to: " << shader_pa.length() << endl; for (size_t i = 0; i < shader_pa.length() && !found_shader; i++) { MObject shader = shader_pa[0].node(); - if (shader.hasFn(MFn::kPhong)) { + if (shader.hasFn(MFn::kPhong)) { if (legacy_shader) { found_shader = find_textures_legacy(shader); } else { @@ -84,41 +81,33 @@ MayaShader(MObject engine, bool legacy_shader) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShader:: ~MayaShader() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaShader:: output(ostream &out) const { out << "Shader " << get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaShader:: write(ostream &out) const { out << "Shader " << get_name() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::get_color_def -// Access: Public -// Description: This is part of the deprecated codepath. -// return the color def i.e. texture at idx -//////////////////////////////////////////////////////////////////// +/** + * This is part of the deprecated codepath. return the color def i.e. + * texture at idx + */ MayaShaderColorDef *MayaShader:: get_color_def(size_t idx) const { if (_color.size() > 0) @@ -126,19 +115,15 @@ get_color_def(size_t idx) const { else return (MayaShaderColorDef *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::get_rgba -// Access: Public -// Description: Returns the overall color of the shader as a -// single-precision rgba value, where the alpha -// component represents transparency according to the -// Panda convention. If no overall color is specified -// (_has_flat_color is not true), this returns white. -// -// Normally, Maya makes texture color override the flat -// color, so if a texture is also applied (_has_texture -// is true), this value is not used by Maya. -//////////////////////////////////////////////////////////////////// +/** + * Returns the overall color of the shader as a single-precision rgba value, + * where the alpha component represents transparency according to the Panda + * convention. If no overall color is specified (_has_flat_color is not + * true), this returns white. + * + * Normally, Maya makes texture color override the flat color, so if a texture + * is also applied (_has_texture is true), this value is not used by Maya. + */ LColor MayaShader:: get_rgba(size_t idx) const { LColor rgba(1.0f, 1.0f, 1.0f, 1.0f); @@ -150,12 +135,12 @@ get_rgba(size_t idx) const { } if (_transparency._has_flat_color) { - // Maya supports colored transparency, but we only support - // grayscale transparency. Use the pnmimage constants to - // convert color to grayscale. + // Maya supports colored transparency, but we only support grayscale + // transparency. Use the pnmimage constants to convert color to + // grayscale. double trans = - _transparency._flat_color[0] * lumin_red + - _transparency._flat_color[1] * lumin_grn + + _transparency._flat_color[0] * lumin_red + + _transparency._flat_color[1] * lumin_grn + _transparency._flat_color[2] * lumin_blu; rgba[3] = 1.0f - (PN_stdfloat)trans; } @@ -163,11 +148,9 @@ get_rgba(size_t idx) const { return rgba; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::collect_maps -// Access: Private -// Description: Recalculates the all_maps list. -//////////////////////////////////////////////////////////////////// +/** + * Recalculates the all_maps list. + */ void MayaShader:: collect_maps() { _all_maps.clear(); @@ -190,7 +173,7 @@ collect_maps() { for (size_t i=0; i<_height_maps.size(); i++) { _all_maps.push_back(_height_maps[i]); } - + for (size_t i=0; i<_color.size(); i++) { if (_color[i]->_has_texture) { _all_maps.push_back(_color[i]); @@ -201,30 +184,27 @@ collect_maps() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::find_textures_modern -// Access: Private -// Description: Locates all file textures leading into the given -// shader. -//////////////////////////////////////////////////////////////////// +/** + * Locates all file textures leading into the given shader. + */ bool MayaShader:: find_textures_modern(MObject shader) { if (!shader.hasFn(MFn::kPhong)) { - maya_cat.warning() + maya_cat.warning() << "The new codepath expects to see phong shaders only.\n"; return false; } MStatus status; MFnPhongShader phong_fn(shader); MFnDependencyNode shader_fn(shader); - + if (maya_cat.is_spam()) { maya_cat.spam() << " Reading modern surface shader " << shader_fn.name().asChar() << "\n"; } string n = shader_fn.name().asChar(); - + MayaShaderColorDef::find_textures_modern(n, _color_maps, shader_fn.findPlug("color"), false); if (_color_maps.size() == 0) { MayaShaderColorDef::find_textures_modern(n, _color_maps, shader_fn.findPlug("colorR"), false); @@ -249,14 +229,14 @@ find_textures_modern(MObject shader) { if (_height_maps.size() == 0) { MayaShaderColorDef::find_textures_modern(n, _height_maps, shader_fn.findPlug("surfaceThicknessR"), true); } - + collect_maps(); MColor color = phong_fn.color(&status); if (status) { _flat_color.set(color.r, color.g, color.b, color.a); } - + color = phong_fn.transparency(&status); if (status) { _flat_color[3] = 1.0 - ((color[0] + color[1] + color[2]) * (1.0/3.0)); @@ -264,12 +244,10 @@ find_textures_modern(MObject shader) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::bind_uvsets -// Access: Public -// Description: Assigns the uvset_name of each MayaShaderColorDef -// using the given file-to-uvset map. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the uvset_name of each MayaShaderColorDef using the given file-to- + * uvset map. + */ void MayaShader:: bind_uvsets(MayaFileToUVSetMap &map) { for (size_t i=0; i<_all_maps.size(); i++) { @@ -281,32 +259,28 @@ bind_uvsets(MayaFileToUVSetMap &map) { def->_uvset_name = (*p).second; } } - + calculate_pairings(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::calculate_pairings -// Access: Public -// Description: For each Alpha texture, try to find an RGB texture -// that has the same properties. Attempt to make it -// so that the alpha texture isn't a separate texture, -// but rather, an Alpha-Filename associated with an -// existing texture. -//////////////////////////////////////////////////////////////////// +/** + * For each Alpha texture, try to find an RGB texture that has the same + * properties. Attempt to make it so that the alpha texture isn't a separate + * texture, but rather, an Alpha-Filename associated with an existing texture. + */ void MayaShader:: calculate_pairings() { if (_legacy_mode) { return; } - + for (size_t i=0; i<_all_maps.size(); i++) { _all_maps[i]->_opposite = 0; } - + bool using_transparency = (_trans_maps.size() > 0); - + for (int retry=0; retry<2; retry++) { bool perfect=(retry==0); for (size_t i=0; i<_color_maps.size(); i++) { @@ -318,7 +292,7 @@ calculate_pairings() { } } } - + if (!using_transparency) { for (int retry=0; retry<2; retry++) { bool perfect=(retry==0); @@ -332,7 +306,7 @@ calculate_pairings() { } } } - + for (int retry=0; retry<2; retry++) { bool perfect=(retry==0); for (size_t i=0; i<_normal_maps.size(); i++) { @@ -341,7 +315,7 @@ calculate_pairings() { } } } - + for (size_t i=0; i<_normal_maps.size(); i++) { _normal_maps[i]->_blend_type = MayaShaderColorDef::BT_normal; } @@ -379,11 +353,9 @@ calculate_pairings() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::try_pair -// Access: Private -// Description: Try to associate an RGB tex with an Alpha tex. -//////////////////////////////////////////////////////////////////// +/** + * Try to associate an RGB tex with an Alpha tex. + */ bool MayaShader::try_pair(MayaShaderColorDef *map1, MayaShaderColorDef *map2, bool perfect) { @@ -404,7 +376,7 @@ bool MayaShader::try_pair(MayaShaderColorDef *map1, return false; } } - + if ((map1->_projection_type != map2->_projection_type) || (map1->_projection_matrix != map2->_projection_matrix) || (map1->_u_angle != map2->_u_angle) || @@ -425,11 +397,9 @@ bool MayaShader::try_pair(MayaShaderColorDef *map1, return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::get_file_prefix -// Access: Private -// Description: Try to associate an RGB tex with an Alpha tex. -//////////////////////////////////////////////////////////////////// +/** + * Try to associate an RGB tex with an Alpha tex. + */ string MayaShader:: get_file_prefix(const string &fn) { Filename pfn = Filename::from_os_specific(fn); @@ -445,32 +415,28 @@ get_file_prefix(const string &fn) { return base; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::find_textures_legacy -// Access: Private -// Description: This is part of the legacy codepath. -// Extracts out the shading information from the Maya -// surface shader. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the legacy codepath. Extracts out the shading information + * from the Maya surface shader. + */ bool MayaShader:: find_textures_legacy(MObject shader) { MStatus status; MFnDependencyNode shader_fn(shader); - + if (maya_cat.is_spam()) { maya_cat.spam() << " Reading legacy surface shader " << shader_fn.name().asChar() << "\n"; } - // First, check for a connection to the color attribute. This could - // be a texture map or something, and will override whatever the - // shader says for color. + // First, check for a connection to the color attribute. This could be a + // texture map or something, and will override whatever the shader says for + // color. MPlug color_plug = shader_fn.findPlug("color"); if (color_plug.isNull()) { - // Or maybe a connection to outColor. Not sure how this differs - // from just color, but empirically it seems that either might be - // used. + // Or maybe a connection to outColor. Not sure how this differs from just + // color, but empirically it seems that either might be used. color_plug = shader_fn.findPlug("outColor"); } @@ -496,7 +462,7 @@ find_textures_legacy(MObject shader) { if (trans_plug.isNull()) { trans_plug = shader_fn.findPlug("outTransparency"); } - + if (!trans_plug.isNull()) { MPlugArray trans_pa; trans_plug.connectedTo(trans_pa, true, false); @@ -507,15 +473,14 @@ find_textures_legacy(MObject shader) { } } - // Also try to get the ordinary color directly from the surface - // shader. + // Also try to get the ordinary color directly from the surface shader. bool b_color_def = true; if (shader.hasFn(MFn::kLambert)) { MFnLambertShader lambert_fn(shader); MColor color = lambert_fn.color(&status); if (status) { - // Warning! The alpha component of color doesn't mean - // transparency in Maya. + // Warning! The alpha component of color doesn't mean transparency in + // Maya. for (size_t i=0; i<_color.size(); ++i) { _color[i]->_has_flat_color = true; _color[i]->_flat_color.set(color.r, color.g, color.b, color.a); @@ -525,7 +490,7 @@ find_textures_legacy(MObject shader) { b_color_def = false; _transparency._flat_color.set(0.0, 0.0, 0.0, 0.0); - + // Get the transparency separately. color = lambert_fn.transparency(&status); if (status) { @@ -535,7 +500,7 @@ find_textures_legacy(MObject shader) { } } } - // if (!_color._has_flat_color && !_color._has_texture) { + // if (!_color._has_flat_color && !_color._has_texture) { if (!b_color_def) { maya_cat.info() << shader_fn.name().asChar() << "Color def not found" << endl; if (maya_cat.is_spam()) { diff --git a/pandatool/src/maya/mayaShader.h b/pandatool/src/maya/mayaShader.h index 88ef39eadf..b998588122 100644 --- a/pandatool/src/maya/mayaShader.h +++ b/pandatool/src/maya/mayaShader.h @@ -1,16 +1,15 @@ -// Filename: mayaShader.h -// Created by: drose (01Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShader.h + * @author drose + * @date 2000-02-01 + */ #ifndef MAYASHADER_H #define MAYASHADER_H @@ -24,14 +23,11 @@ class MObject; -//////////////////////////////////////////////////////////////////// -// Class : MayaShader -// Description : Corresponds to a single "shader" in Maya. This -// extracts out all the parameters of a Maya shader that -// we might care about. There are many more parameters -// that we don't care about or don't know enough to -// extract. -//////////////////////////////////////////////////////////////////// +/** + * Corresponds to a single "shader" in Maya. This extracts out all the + * parameters of a Maya shader that we might care about. There are many more + * parameters that we don't care about or don't know enough to extract. + */ class MayaShader : public Namable { public: MayaShader(MObject engine, bool legacy_shader); @@ -39,7 +35,7 @@ public: void output(ostream &out) const; void write(ostream &out) const; - + private: bool find_textures_modern(MObject shader); bool find_textures_legacy(MObject shader); @@ -47,22 +43,22 @@ private: public: void collect_maps(); bool _legacy_mode; - + MayaShaderColorList _all_maps; public: // relevant only to modern mode. LColord _flat_color; - + MayaShaderColorList _color_maps; MayaShaderColorList _trans_maps; MayaShaderColorList _normal_maps; MayaShaderColorList _glow_maps; MayaShaderColorList _gloss_maps; MayaShaderColorList _height_maps; - + void bind_uvsets(MayaFileToUVSetMap &map); - + private: void calculate_pairings(); bool try_pair(MayaShaderColorDef *map1, @@ -83,4 +79,3 @@ INLINE ostream &operator << (ostream &out, const MayaShader &shader) { } #endif - diff --git a/pandatool/src/maya/mayaShaderColorDef.cxx b/pandatool/src/maya/mayaShaderColorDef.cxx index 10d9349d68..ede0bbf0d5 100644 --- a/pandatool/src/maya/mayaShaderColorDef.cxx +++ b/pandatool/src/maya/mayaShaderColorDef.cxx @@ -1,18 +1,17 @@ -// Filename: mayaShaderColorDef.cxx -// Created by: drose (12Apr03) -// Modified 19Mar10 by ETC PandaSE team (see -// header comment for mayaToEgg.cxx for details) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShaderColorDef.cxx + * @author drose + * @date 2003-04-12 + * Modified 19Mar10 by ETC PandaSE team (see + * header comment for mayaToEgg.cxx for details) + */ #include "mayaShaderColorDef.h" #include "mayaShader.h" @@ -30,11 +29,9 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShaderColorDef:: MayaShaderColorDef() { @@ -44,11 +41,11 @@ MayaShaderColorDef() { _projection_matrix = LMatrix4d::ident_mat(); _u_angle = 0.0; _v_angle = 0.0; - + _texture_filename = ""; _texture_name = ""; _color_gain.set(1.0f, 1.0f, 1.0f, 1.0f); - + _coverage.set(1.0, 1.0); _translate_frame.set(0.0, 0.0); _rotate_frame = 0.0; @@ -80,11 +77,9 @@ MayaShaderColorDef() { _map_uvs = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShaderColorDef:: MayaShaderColorDef(MayaShaderColorDef ©) { _has_texture = copy._has_texture; @@ -121,18 +116,16 @@ MayaShaderColorDef(MayaShaderColorDef ©) { _rotate_uv = copy._rotate_uv; _is_alpha = copy._is_alpha; - + _map_uvs = copy._map_uvs; _color_object = copy._color_object; - + _opposite = 0; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShaderColorDef:: ~MayaShaderColorDef() { if (_color_object != (MObject *)NULL) { @@ -140,12 +133,10 @@ MayaShaderColorDef:: } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::compute_texture_matrix -// Access: Public -// Description: Returns a texture matrix corresponding to the texture -// transforms indicated by the shader. -//////////////////////////////////////////////////////////////////// +/** + * Returns a texture matrix corresponding to the texture transforms indicated + * by the shader. + */ LMatrix3d MayaShaderColorDef:: compute_texture_matrix() const { LVector2d scale(_repeat_uv[0] / _coverage[0], @@ -161,37 +152,30 @@ compute_texture_matrix() const { LMatrix3d::translate_mat(trans); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::has_projection -// Access: Public -// Description: Returns true if the shader has a projection in effect. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the shader has a projection in effect. + */ bool MayaShaderColorDef:: has_projection() const { return (_projection_type != PT_off); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::project_uv -// Access: Public -// Description: If the shader has a projection (has_projection() -// returns true), this computes the appropriate UV -// corresponding to the indicated 3-d point. Seams that -// might be introduced on polygons that cross quadrants -// are closed up by ensuring the point is in the same -// quadrant as the indicated reference point. -//////////////////////////////////////////////////////////////////// +/** + * If the shader has a projection (has_projection() returns true), this + * computes the appropriate UV corresponding to the indicated 3-d point. + * Seams that might be introduced on polygons that cross quadrants are closed + * up by ensuring the point is in the same quadrant as the indicated reference + * point. + */ LTexCoordd MayaShaderColorDef:: project_uv(const LPoint3d &pos, const LPoint3d ¢roid) const { nassertr(_map_uvs != NULL, LTexCoordd::zero()); return (this->*_map_uvs)(pos * _projection_matrix, centroid * _projection_matrix); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaShaderColorDef:: write(ostream &out) const { if (_has_texture) { @@ -215,16 +199,14 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::reset_maya_texture -// Access: Public -// Description: Changes the texture filename stored in the Maya file -// for this particular shader. -//////////////////////////////////////////////////////////////////// +/** + * Changes the texture filename stored in the Maya file for this particular + * shader. + */ bool MayaShaderColorDef:: reset_maya_texture(const Filename &texture) { if (_color_object != (MObject *)NULL) { - _has_texture = set_string_attribute(*_color_object, "fileTextureName", + _has_texture = set_string_attribute(*_color_object, "fileTextureName", texture.to_os_generic()); _texture_filename = texture; @@ -242,13 +224,10 @@ reset_maya_texture(const Filename &texture) { } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::get_panda_uvset_name -// Access: Private -// Description: Maya's default uvset name is "map1". Panda's default -// uvset name is "default". Otherwise, leaves uvset -// name untranslated. -//////////////////////////////////////////////////////////////////// +/** + * Maya's default uvset name is "map1". Panda's default uvset name is + * "default". Otherwise, leaves uvset name untranslated. + */ string MayaShaderColorDef:: get_panda_uvset_name() { if (_uvset_name == "map1") { @@ -257,14 +236,11 @@ get_panda_uvset_name() { return _uvset_name; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::find_textures_legacy -// Access: Private -// Description: This is part of the deprecated codepath. -// Determines the surface color specified by the shader. -// This includes texturing and other advanced shader -// properties. -//////////////////////////////////////////////////////////////////// +/** + * This is part of the deprecated codepath. Determines the surface color + * specified by the shader. This includes texturing and other advanced shader + * properties. + */ void MayaShaderColorDef:: find_textures_legacy(MayaShader *shader, MObject color, bool trans) { LRGBColor color_gain; @@ -308,7 +284,7 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { get_vec2_attribute(color, "translateFrame", _translate_frame); get_angle_attribute(color, "rotateFrame", _rotate_frame); - //get_bool_attribute(color, "alphaIsLuminance", _alpha_is_luminance); + // get_bool_attribute(color, "alphaIsLuminance", _alpha_is_luminance); get_bool_attribute(color, "mirror", _mirror); get_bool_attribute(color, "stagger", _stagger); @@ -330,14 +306,14 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { if (maya_cat.is_debug()) { maya_cat.debug() << "reading a projection texture" << endl; } - // This is a projected texture. We will have to step one level - // deeper to find the actual texture. + // This is a projected texture. We will have to step one level deeper to + // find the actual texture. MFnDependencyNode projection_fn(color); MPlug image_plug = projection_fn.findPlug("image"); if (!image_plug.isNull()) { MPlugArray image_pa; image_plug.connectedTo(image_pa, true, false); - + for (size_t i = 0; i < image_pa.length(); i++) { find_textures_legacy(shader, image_pa[0].node()); } @@ -347,8 +323,7 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { _projection_matrix = LMatrix4d::ident_mat(); } - // The uAngle and vAngle might be used for certain kinds of - // projections. + // The uAngle and vAngle might be used for certain kinds of projections. if (!get_angle_attribute(color, "uAngle", _u_angle)) { _u_angle = 360.0; } @@ -396,13 +371,13 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { blendModePlug.getValue(blendValue); if (maya_cat.is_spam()) { - maya_cat.spam() + maya_cat.spam() << blendModePlug.name() << ": has value " << blendValue << endl; } MFnEnumAttribute blendModeEnum(blendModePlug); MString blendName = blendModeEnum.fieldName(blendValue, &status); - + switch (blendValue) { case 1: bt = BT_decal; @@ -429,12 +404,15 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { pl.connectedTo(pla, true, false); } for (size_t j=0; j bad_types; if (bad_types.insert(color.apiType()).second) { maya_cat.info() @@ -494,13 +472,10 @@ find_textures_legacy(MayaShader *shader, MObject color, bool trans) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::find_textures -// Access: Private -// Description: Search to find any file textures that lead into the -// given input plug. Any textures found will be added -// to the provided MayaShaderColorList. -//////////////////////////////////////////////////////////////////// +/** + * Search to find any file textures that lead into the given input plug. Any + * textures found will be added to the provided MayaShaderColorList. + */ void MayaShaderColorDef:: find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha) { @@ -518,7 +493,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug MPlug outplug = outplugs[0]; MObject source = outplug.node(); MFnDependencyNode sourceFn(source); - + if (source.hasFn(MFn::kFileTexture)) { string filename; @@ -536,9 +511,9 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug << filename << " which is a directory, ignoring it.\n"; return; } - + MayaShaderColorDef *def = new MayaShaderColorDef; - + def->_color_object = new MObject(source); def->_texture_filename = Filename::from_os_specific(filename); def->_texture_name = sourceFn.name().asChar(); @@ -546,7 +521,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug get_vec2_attribute(source, "coverage", def->_coverage); get_vec2_attribute(source, "translateFrame", def->_translate_frame); get_angle_attribute(source, "rotateFrame", def->_rotate_frame); - + get_bool_attribute(source, "mirror", def->_mirror); get_bool_attribute(source, "stagger", def->_stagger); get_bool_attribute(source, "wrapU", def->_wrap_u); @@ -566,7 +541,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug def->_color_gain[3] = alpha_gain; def->_is_alpha = is_alpha; - + if (maya_cat.is_debug()) { maya_cat.debug() << "pushed a file texture" << endl; } @@ -576,30 +551,29 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug } if (source.hasFn(MFn::kProjection)) { - // This is a projected texture. We will have to step one level - // deeper to find the actual texture. + // This is a projected texture. We will have to step one level deeper to + // find the actual texture. size_t before = list.size(); MPlug image_plug = sourceFn.findPlug("image"); if (!image_plug.isNull()) { MPlugArray image_pa; image_plug.connectedTo(image_pa, true, false); - + for (size_t i = 0; i < image_pa.length(); i++) { find_textures_modern(shadername, list, image_pa[0], is_alpha); } } - + // Now apply any inherited attributes to all textures found. - + for (size_t i=before; i_projection_matrix)) { def->_projection_matrix = LMatrix4d::ident_mat(); } - // The uAngle and vAngle might be used for certain kinds of - // projections. + // The uAngle and vAngle might be used for certain kinds of projections. if (!get_angle_attribute(source, "uAngle", def->_u_angle)) { def->_u_angle = 360.0; } @@ -614,7 +588,7 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug } return; } - + if (source.hasFn(MFn::kLayeredTexture)) { if (maya_cat.is_debug()) { maya_cat.debug() << "Found layered texture" << endl; @@ -657,15 +631,15 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug find_textures_modern(shadername, list, input_plug, is_alpha); return; } - + // This shader wasn't understood. if (maya_cat.is_debug()) { maya_cat.info() << "**Don't know how to interpret color attribute type " << source.apiTypeStr() << "\n"; } else { - // If we don't have a heavy verbose count, only report each type - // of unsupported shader once. + // If we don't have a heavy verbose count, only report each type of + // unsupported shader once. static pset bad_types; if (bad_types.insert(source.apiType()).second) { maya_cat.warning() @@ -675,20 +649,18 @@ find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::set_projection_type -// Access: Private -// Description: Sets up the shader to apply UV's according to the -// indicated projection type. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the shader to apply UV's according to the indicated projection + * type. + */ void MayaShaderColorDef:: set_projection_type(const string &type) { if (cmp_nocase(type, "planar") == 0) { _projection_type = PT_planar; _map_uvs = &MayaShaderColorDef::map_planar; - // The Planar projection normally projects to a range (-1, 1) in - // both axes. Scale this into our UV range of (0, 1). + // The Planar projection normally projects to a range (-1, 1) in both + // axes. Scale this into our UV range of (0, 1). _projection_matrix = _projection_matrix * LMatrix4d(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -698,8 +670,8 @@ set_projection_type(const string &type) { _projection_type = PT_cylindrical; _map_uvs = &MayaShaderColorDef::map_cylindrical; - // The cylindrical projection is orthographic in the Y axis; scale - // the range (-1, 1) in this axis into our UV range (0, 1). + // The cylindrical projection is orthographic in the Y axis; scale the + // range (-1, 1) in this axis into our UV range (0, 1). _projection_matrix = _projection_matrix * LMatrix4d(1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -710,8 +682,7 @@ set_projection_type(const string &type) { _map_uvs = &MayaShaderColorDef::map_spherical; } else { - // Other projection types are currently unimplemented by the - // converter. + // Other projection types are currently unimplemented by the converter. maya_cat.error() << "Don't know how to handle type " << type << " projections.\n"; _projection_type = PT_off; @@ -719,48 +690,43 @@ set_projection_type(const string &type) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::map_planar -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a planar projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a planar projection. + */ LPoint2d MayaShaderColorDef:: map_planar(const LPoint3d &pos, const LPoint3d &) const { - // A planar projection is about as easy as can be. We ignore the Z - // axis, and project the point into the XY plane. Done. + // A planar projection is about as easy as can be. We ignore the Z axis, + // and project the point into the XY plane. Done. return LPoint2d(pos[0], pos[1]); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::map_spherical -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a spherical projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a spherical + * projection. + */ LPoint2d MayaShaderColorDef:: map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const { - // To compute the x position on the frame, we only need to consider - // the angle of the vector about the Y axis. Project the vector - // into the XZ plane to do this. + // To compute the x position on the frame, we only need to consider the + // angle of the vector about the Y axis. Project the vector into the XZ + // plane to do this. LVector2d xz(pos[0], pos[2]); double xz_length = xz.length(); if (xz_length < 0.01) { - // If we have a point on or near either pole, we've got problems. - // This point maps to the entire bottom edge of the image, so - // which U value should we choose? It does make a difference, - // especially if we have a number of polygons around the south - // pole that all share the common vertex. + // If we have a point on or near either pole, we've got problems. This + // point maps to the entire bottom edge of the image, so which U value + // should we choose? It does make a difference, especially if we have a + // number of polygons around the south pole that all share the common + // vertex. // We choose the U value based on the polygon's centroid. xz.set(centroid[0], centroid[2]); } - // Now, if the polygon crosses the seam, we also have problems. - // Make sure that the u value is in the same half of the texture as - // the centroid's u value. + // Now, if the polygon crosses the seam, we also have problems. Make sure + // that the u value is in the same half of the texture as the centroid's u + // value. double u = rad_2_deg(atan2(xz[0], xz[1])) / (2.0 * _u_angle); double c = rad_2_deg(atan2(centroid[0], centroid[2])) / (2.0 * _u_angle); @@ -770,8 +736,8 @@ map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const { u += floor(c - u + 0.5); } - // Now rotate the vector into the YZ plane, and the V value is based - // on the latitude: the angle about the X axis. + // Now rotate the vector into the YZ plane, and the V value is based on the + // latitude: the angle about the X axis. LVector2d yz(pos[1], xz_length); double v = rad_2_deg(atan2(yz[0], yz[1])) / (2.0 * _v_angle); @@ -781,31 +747,30 @@ map_spherical(const LPoint3d &pos, const LPoint3d ¢roid) const { return uv; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaderColorDef::map_cylindrical -// Access: Private -// Description: Computes a UV based on the given point in space, -// using a cylindrical projection. -//////////////////////////////////////////////////////////////////// +/** + * Computes a UV based on the given point in space, using a cylindrical + * projection. + */ LPoint2d MayaShaderColorDef:: map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const { - // This is almost identical to the spherical projection, except for - // the computation of V. + // This is almost identical to the spherical projection, except for the + // computation of V. LVector2d xz(pos[0], pos[2]); double xz_length = xz.length(); if (xz_length < 0.01) { - // A cylindrical mapping has the same singularity problem at the - // pole as a spherical mapping does: points at the pole do not map - // to a single point on the texture. (It's technically a slightly - // different problem: in a cylindrical mapping, points at the pole - // do not map to any point on the texture, while in a spherical - // mapping, points at the pole map to the top or bottom edge of - // the texture. But this is a technicality that doesn't really - // apply to us.) We still solve it the same way: if our point is - // at or near the pole, compute the angle based on the centroid of - // the polygon (which we assume is further from the pole). +/* + * A cylindrical mapping has the same singularity problem at the pole as a + * spherical mapping does: points at the pole do not map to a single point on + * the texture. (It's technically a slightly different problem: in a + * cylindrical mapping, points at the pole do not map to any point on the + * texture, while in a spherical mapping, points at the pole map to the top or + * bottom edge of the texture. But this is a technicality that doesn't really + * apply to us.) We still solve it the same way: if our point is at or near + * the pole, compute the angle based on the centroid of the polygon (which we + * assume is further from the pole). + */ xz.set(centroid[0], centroid[2]); } @@ -819,8 +784,7 @@ map_cylindrical(const LPoint3d &pos, const LPoint3d ¢roid) const { u += floor(c - u + 0.5); } - // For a cylindrical mapping, the V value comes directly from Y. - // Easy. + // For a cylindrical mapping, the V value comes directly from Y. Easy. LPoint2d uv(u - 0.5, pos[1]); nassertr(fabs(u - c) <= 0.5, uv); diff --git a/pandatool/src/maya/mayaShaderColorDef.h b/pandatool/src/maya/mayaShaderColorDef.h index 36a7721f54..522146fc53 100644 --- a/pandatool/src/maya/mayaShaderColorDef.h +++ b/pandatool/src/maya/mayaShaderColorDef.h @@ -1,16 +1,15 @@ -// Filename: mayaShaderColorDef.h -// Created by: drose (12Apr03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShaderColorDef.h + * @author drose + * @date 2003-04-12 + */ #ifndef MAYASHADERCOLORDEF_H #define MAYASHADERCOLORDEF_H @@ -29,12 +28,11 @@ class MayaShaderColorDef; typedef pvector MayaShaderColorList; typedef pmap MayaFileToUVSetMap; -//////////////////////////////////////////////////////////////////// -// Class : MayaShaderColorDef -// Description : This defines the various attributes that Maya may -// associate with the "color" channel for a particular -// shader (as well as on the "transparency" channel). -//////////////////////////////////////////////////////////////////// +/** + * This defines the various attributes that Maya may associate with the + * "color" channel for a particular shader (as well as on the "transparency" + * channel). + */ class MayaShaderColorDef { public: MayaShaderColorDef(); @@ -42,17 +40,17 @@ public: ~MayaShaderColorDef(); string strip_prefix(string full_name); - + LMatrix3d compute_texture_matrix() const; bool has_projection() const; LTexCoordd project_uv(const LPoint3d &pos, const LPoint3d &ref_point) const; bool reset_maya_texture(const Filename &texture); - + void write(ostream &out) const; enum BlendType { - BT_unspecified, - BT_modulate, + BT_unspecified, + BT_modulate, BT_decal, BT_blend, BT_replace, @@ -79,21 +77,21 @@ public: PT_concentric, PT_perspective, }; - + BlendType _blend_type; ProjectionType _projection_type; LMatrix4d _projection_matrix; double _u_angle; double _v_angle; - + Filename _texture_filename; string _texture_name; LColor _color_gain; - + LVector2 _coverage; LVector2 _translate_frame; double _rotate_frame; - + bool _mirror; bool _stagger; bool _wrap_u; @@ -104,15 +102,15 @@ public: double _rotate_uv; bool _is_alpha; - + string _uvset_name; MayaShaderColorDef *_opposite; - + string get_panda_uvset_name(); private: MObject *_color_object; - + private: static void find_textures_modern(const string &shadername, MayaShaderColorList &list, MPlug inplug, bool is_alpha); void find_textures_legacy(MayaShader *shader, MObject color, bool trans=false); @@ -125,27 +123,20 @@ private: // Define a pointer to one of the above member functions. LPoint2d (MayaShaderColorDef::*_map_uvs)(const LPoint3d &pos, const LPoint3d ¢roid) const; - + friend class MayaShader; - // Legacy Fields - these fields are only used by the - // legacy codepath. These fields are deprecated for the - // following reasons: - // - // * has_texture is redundant --- if there's no - // texture, just don't allocate a MayaShaderColorDef. - // - // * has_flat_color and flat_color don't belong here, - // they belong in the shader. - // - // * has_alpha_channel is not needed - there are better - // ways to determine if a texture stage involves an alpha - // channel. - // - // * keep_color, keep_alpha, and interpolate are all - // adjuncts to blend_mode - it would make more sense just to - // add some more blend_modes. +/* + * Legacy Fields - these fields are only used by the legacy codepath. These + * fields are deprecated for the following reasons: * has_texture is redundant + * --- if there's no texture, just don't allocate a MayaShaderColorDef. * + * has_flat_color and flat_color don't belong here, they belong in the shader. + * * has_alpha_channel is not needed - there are better ways to determine if a + * texture stage involves an alpha channel. * keep_color, keep_alpha, and + * interpolate are all adjuncts to blend_mode - it would make more sense just + * to add some more blend_modes. + */ public: bool _has_texture; // deprecated, see above. @@ -159,4 +150,3 @@ public: }; #endif - diff --git a/pandatool/src/maya/mayaShaders.cxx b/pandatool/src/maya/mayaShaders.cxx index 45072dfff3..a100ad8a4e 100644 --- a/pandatool/src/maya/mayaShaders.cxx +++ b/pandatool/src/maya/mayaShaders.cxx @@ -1,16 +1,15 @@ -// Filename: mayaShaders.cxx -// Created by: drose (11Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShaders.cxx + * @author drose + * @date 2000-02-11 + */ #include "mayaShaders.h" #include "mayaShader.h" @@ -28,30 +27,24 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShaders:: MayaShaders() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaShaders:: ~MayaShaders() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::find_shader_for_node -// Access: Public -// Description: Extracts the shader assigned to the indicated node. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the shader assigned to the indicated node. + */ MayaShader *MayaShaders:: find_shader_for_node(MObject node, bool legacy_shader) { MStatus status; @@ -65,9 +58,9 @@ find_shader_for_node(MObject node, bool legacy_shader) { return (MayaShader *)NULL; } - // instObjGroups is a multi attribute, whatever that means. For - // now, we'll just get the first connection, since that's what the - // example code did. Is there any reason to search deeper? + // instObjGroups is a multi attribute, whatever that means. For now, we'll + // just get the first connection, since that's what the example code did. + // Is there any reason to search deeper? MPlug iog_plug(node, iog_attr); MPlugArray iog_pa; @@ -79,9 +72,9 @@ find_shader_for_node(MObject node, bool legacy_shader) { return (MayaShader *)NULL; } - // Now we have a number of ShadingEngines defined, one for each of - // these connections we just turned up. Usually there will only be - // one. In fact, we'll just take the first one we find. + // Now we have a number of ShadingEngines defined, one for each of these + // connections we just turned up. Usually there will only be one. In fact, + // we'll just take the first one we find. size_t i; for (i = 0; i < iog_pa.length(); i++) { @@ -97,17 +90,14 @@ find_shader_for_node(MObject node, bool legacy_shader) { return (MayaShader *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::bind_uvsets -// Access: Public -// Description: Causes all shaders in the set to use the given -// mesh as a file-to-uvset map. -//////////////////////////////////////////////////////////////////// +/** + * Causes all shaders in the set to use the given mesh as a file-to-uvset map. + */ void MayaShaders:: bind_uvsets(MObject mesh) { _uvset_names.clear(); _file_to_uvset.clear(); - + if (mesh.hasFn(MFn::kMesh)) { MFnMesh mesh_fn(mesh); MStatus status; @@ -125,21 +115,18 @@ bind_uvsets(MObject mesh) { } } } - + Shaders::iterator sha; for (sha=_shaders.begin(); sha!=_shaders.end(); sha++) { (*sha).second->bind_uvsets(_file_to_uvset); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::find_shader_for_shading_engine -// Access: Public -// Description: Returns the MayaShader object associated with the -// indicated "shading engine". This will create a new -// MayaShader object if this is the first time we have -// encountered the indicated engine. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MayaShader object associated with the indicated "shading + * engine". This will create a new MayaShader object if this is the first + * time we have encountered the indicated engine. + */ MayaShader *MayaShaders:: find_shader_for_shading_engine(MObject engine, bool legacy_shader) { MFnDependencyNode engine_fn(engine); @@ -150,23 +137,21 @@ find_shader_for_shading_engine(MObject engine, bool legacy_shader) { return (*si).second; } - // All right, this is a newly encountered shading engine. Create a - // new MayaShader object to represent it. + // All right, this is a newly encountered shading engine. Create a new + // MayaShader object to represent it. MayaShader *shader = new MayaShader(engine, legacy_shader); shader->bind_uvsets(_file_to_uvset); - + // Record this for the future. _shaders.insert(Shaders::value_type(engine_name, shader)); _shaders_in_order.push_back(shader); return shader; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::find_uv_link -// Access: Public -// Description: Returns the current mapping from file to uvset -// for the given file texture name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current mapping from file to uvset for the given file texture + * name. + */ string MayaShaders:: find_uv_link(const string &match) { MayaFileToUVSetMap::iterator it = _file_to_uvset.find(match); @@ -177,35 +162,27 @@ find_uv_link(const string &match) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::get_num_shaders -// Access: Public -// Description: Returns the number of unique MayaShaders that have -// been discovered so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique MayaShaders that have been discovered so far. + */ int MayaShaders:: get_num_shaders() const { return _shaders_in_order.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::get_shader -// Access: Public -// Description: Returns the nth MayaShader that has been discovered -// so far. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth MayaShader that has been discovered so far. + */ MayaShader *MayaShaders:: get_shader(int n) const { nassertr(n >= 0 && n < (int)_shaders_in_order.size(), NULL); return _shaders_in_order[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShaders::clear -// Access: Public -// Description: Frees all of the previously-defined MayaShader -// objects associated with this set. -//////////////////////////////////////////////////////////////////// +/** + * Frees all of the previously-defined MayaShader objects associated with this + * set. + */ void MayaShaders:: clear() { ShadersInOrder::iterator si; diff --git a/pandatool/src/maya/mayaShaders.h b/pandatool/src/maya/mayaShaders.h index 76d982efbd..7c92ae4416 100644 --- a/pandatool/src/maya/mayaShaders.h +++ b/pandatool/src/maya/mayaShaders.h @@ -1,16 +1,15 @@ -// Filename: mayaShaders.h -// Created by: drose (11Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaShaders.h + * @author drose + * @date 2000-02-11 + */ #ifndef MAYASHADERS_H #define MAYASHADERS_H @@ -24,21 +23,19 @@ class MayaShader; class MObject; -//////////////////////////////////////////////////////////////////// -// Class : MayaShaders -// Description : Collects the set of MayaShaders that have been -// encountered so far. -//////////////////////////////////////////////////////////////////// +/** + * Collects the set of MayaShaders that have been encountered so far. + */ class MayaShaders { public: MayaShaders(); ~MayaShaders(); MayaShader *find_shader_for_node(MObject node, bool legacy_shader); MayaShader *find_shader_for_shading_engine(MObject engine, bool legacy_shader); - + int get_num_shaders() const; MayaShader *get_shader(int n) const; - + MayaFileToUVSetMap _file_to_uvset; pvector _uvset_names; void clear(); @@ -53,4 +50,3 @@ private: }; #endif - diff --git a/pandatool/src/maya/maya_funcs.I b/pandatool/src/maya/maya_funcs.I index d8d9236e6f..422b525751 100644 --- a/pandatool/src/maya/maya_funcs.I +++ b/pandatool/src/maya/maya_funcs.I @@ -1,30 +1,26 @@ -// Filename: maya_funcs.I -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maya_funcs.I + * @author drose + * @date 2002-04-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MString output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream &operator << (ostream &out, const MString &str) { return out << str.asChar(); } -//////////////////////////////////////////////////////////////////// -// Function: MVector output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE ostream &operator << (ostream &out, const MVector &vec) { return out << vec.x << " " << vec.y << " " << vec.z; } diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 856f3c3aef..184a903f66 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -1,16 +1,15 @@ -// Filename: maya_funcs.cxx -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maya_funcs.cxx + * @author drose + * @date 2000-02-16 + */ #include "maya_funcs.h" @@ -32,10 +31,9 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: get_maya_plug -// Description: Gets the named MPlug associated, if any. -//////////////////////////////////////////////////////////////////// +/** + * Gets the named MPlug associated, if any. + */ bool get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug) { MStatus status; @@ -63,11 +61,10 @@ get_maya_plug(MObject &node, const string &attribute_name, MPlug &plug) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: is_connected -// Description: Returns true if the named connection exists on the -// node and is connected to anything, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the named connection exists on the node and is connected to + * anything, false otherwise. + */ bool is_connected(MObject &node, const string &attribute_name) { MPlug plug; @@ -78,13 +75,11 @@ is_connected(MObject &node, const string &attribute_name) { return plug.isConnected(); } -//////////////////////////////////////////////////////////////////// -// Function: has_attribute -// Description: Returns true if the node has the indicated attribute, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has the indicated attribute, false otherwise. + */ bool -has_attribute(MObject &node, const string &attribute_name) { +has_attribute(MObject &node, const string &attribute_name) { MStatus status; MFnDependencyNode node_fn(node, &status); if (!status) { @@ -101,11 +96,10 @@ has_attribute(MObject &node, const string &attribute_name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: remove_attribute -// Description: Removes the named attribute from the indicated Maya -// node. Returns true if successful, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named attribute from the indicated Maya node. Returns true if + * successful, false otherwise. + */ bool remove_attribute(MObject &node, const string &attribute_name) { MStatus status; @@ -122,9 +116,9 @@ remove_attribute(MObject &node, const string &attribute_name) { } { - // Just to prove the the attr is, in fact, an Attribute. - // According to the Maya docs, we shouldn't leave the MFnAttribute - // object around while we remove the attribute, though. + // Just to prove the the attr is, in fact, an Attribute. According to the + // Maya docs, we shouldn't leave the MFnAttribute object around while we + // remove the attribute, though. MFnAttribute attr_fn(attr, &status); if (!status) { maya_cat.error() @@ -153,17 +147,15 @@ remove_attribute(MObject &node, const string &attribute_name) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_bool_attribute -// Description: Extracts the named boolean attribute from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named boolean attribute from the MObject. + */ bool get_bool_attribute(MObject &node, const string &attribute_name, bool &value) { if (!has_attribute(node, attribute_name)) { - // For bool attributes only, we assume if the attribute is absent - // it's the same thing as being false. + // For bool attributes only, we assume if the attribute is absent it's the + // same thing as being false. return false; } @@ -177,11 +169,9 @@ get_bool_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_bool_attribute -// Description: Extracts the named angle in degrees from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named angle in degrees from the MObject. + */ bool get_angle_attribute(MObject &node, const string &attribute_name, double &value) { @@ -197,11 +187,9 @@ get_angle_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_vec2_attribute -// Description: Extracts the named two-component vector from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named two-component vector from the MObject. + */ bool get_vec2_attribute(MObject &node, const string &attribute_name, LVecBase2 &value) { @@ -234,11 +222,9 @@ get_vec2_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_vec3_attribute -// Description: Extracts the named three-component vector from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named three-component vector from the MObject. + */ bool get_vec3_attribute(MObject &node, const string &attribute_name, LVecBase3 &value) { @@ -271,11 +257,9 @@ get_vec3_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_vec2d_attribute -// Description: Extracts the named two-component vector from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named two-component vector from the MObject. + */ bool get_vec2d_attribute(MObject &node, const string &attribute_name, LVecBase2d &value) { @@ -308,11 +292,9 @@ get_vec2d_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_vec3d_attribute -// Description: Extracts the named three-component vector from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named three-component vector from the MObject. + */ bool get_vec3d_attribute(MObject &node, const string &attribute_name, LVecBase3d &value) { @@ -345,10 +327,9 @@ get_vec3d_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_mat4d_attribute -// Description: Extracts the named 4x4 matrix from the MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named 4x4 matrix from the MObject. + */ bool get_mat4d_attribute(MObject &node, const string &attribute_name, LMatrix4d &value) { @@ -365,7 +346,7 @@ get_mat4d_attribute(MObject &node, const string &attribute_name, << node.apiTypeStr() << ", not a Matrix.\n"; return false; } - + const MMatrix &mat = matrix_data.matrix(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { @@ -375,12 +356,10 @@ get_mat4d_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_tag_attribute_names -// Description: artists should be able to set arbitrary tags. -// Query all the attributes on this object and return -// the lists of attribute names that has "tag" prefix -//////////////////////////////////////////////////////////////////// +/** + * artists should be able to set arbitrary tags. Query all the attributes on + * this object and return the lists of attribute names that has "tag" prefix + */ void get_tag_attribute_names(MObject &node, pvector &tag_names) { MStatus status; @@ -401,7 +380,7 @@ get_tag_attribute_names(MObject &node, pvector &tag_names) { if (status) { string attribute_name = attrib.name().asChar(); if (attribute_name.find("tag", 0) != string::npos) { - maya_cat.info() << ":" << name << ":" << " is tagged with <" + maya_cat.info() << ":" << name << ":" << " is tagged with <" << attribute_name << ">" << endl; tag_names.push_back(attribute_name); } @@ -409,11 +388,9 @@ get_tag_attribute_names(MObject &node, pvector &tag_names) { } } } -//////////////////////////////////////////////////////////////////// -// Function: get_enum_attribute -// Description: Extracts the enum attribute from the MObject as a -// string value. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the enum attribute from the MObject as a string value. + */ bool get_enum_attribute(MObject &node, const string &attribute_name, string &value) { @@ -453,11 +430,9 @@ get_enum_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: get_string_attribute -// Description: Extracts the named string attribute from the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the named string attribute from the MObject. + */ bool get_string_attribute(MObject &node, const string &attribute_name, string &value) { @@ -484,11 +459,9 @@ get_string_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: set_string_attribute -// Description: Sets the named string attribute on the -// MObject. -//////////////////////////////////////////////////////////////////// +/** + * Sets the named string attribute on the MObject. + */ bool set_string_attribute(MObject &node, const string &attribute_name, const string &value) { @@ -530,15 +503,13 @@ set_string_attribute(MObject &node, const string &attribute_name, return true; } -//////////////////////////////////////////////////////////////////// -// Function: describe_compound_attribute -// Description: Extracts the children of this attribute from the -// MObject. test for now -//////////////////////////////////////////////////////////////////// -bool +/** + * Extracts the children of this attribute from the MObject. test for now + */ +bool describe_compound_attribute(MObject &node) { MStatus status; - + MFnCompoundAttribute comp_attr(node, &status); maya_cat.info() << "comp_attr has:" << comp_attr.numChildren() << " children" << endl; @@ -584,11 +555,9 @@ describe_compound_attribute(MObject &node) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: describe_maya_attribute -// Description: Writes some warning output about the indicated Maya -// attribute. -//////////////////////////////////////////////////////////////////// +/** + * Writes some warning output about the indicated Maya attribute. + */ void describe_maya_attribute(MObject &node, const string &attribute_name) { MStatus status; @@ -683,13 +652,11 @@ string_mfndata_type(MFnData::Type type) { return "**invalid**"; } -//////////////////////////////////////////////////////////////////// -// Function: list_maya_attributes -// Description: Writes some info output showing all the attributes on -// the given dependency node. Primarily useful during -// development, to figure out where the heck Maya hides -// some of the connected properties. -//////////////////////////////////////////////////////////////////// +/** + * Writes some info output showing all the attributes on the given dependency + * node. Primarily useful during development, to figure out where the heck + * Maya hides some of the connected properties. + */ void list_maya_attributes(MObject &node) { MStatus status; @@ -716,11 +683,11 @@ list_maya_attributes(MObject &node) { maya_cat.info(false) << " " << i << ". " << plug.name().asChar() << ", " - << plug.attribute().apiTypeStr() << ", " + << plug.attribute().apiTypeStr() << ", " << plug.node().apiTypeStr(); if (plug.attribute().apiType() == MFn::kCompoundAttribute) { - //maya_cat.info() << plug.info(); - //describe_compound_attribute(plug.attribute()); + // maya_cat.info() << plug.info(); + // describe_compound_attribute(plug.attribute()); } if (plug.isConnected()) { maya_cat.info(false) @@ -739,7 +706,7 @@ list_maya_attributes(MObject &node) { MFnTypedAttribute typed_attrib(attr, &status); if (status) { // It's a typed attrib. - maya_cat.info(false) + maya_cat.info(false) << " " << i << ". " << typed_attrib.name().asChar() << " [" << attr.apiTypeStr() << ", " << string_mfndata_type(typed_attrib.attrType()) << "]\n"; @@ -747,7 +714,7 @@ list_maya_attributes(MObject &node) { MFnAttribute attrib(attr, &status); if (status) { // It's a generic attrib. - maya_cat.info(false) + maya_cat.info(false) << " " << i << ". " << attrib.name().asChar() << " [" << attr.apiTypeStr() << "]\n"; } else { @@ -759,4 +726,3 @@ list_maya_attributes(MObject &node) { } } } - diff --git a/pandatool/src/maya/maya_funcs.h b/pandatool/src/maya/maya_funcs.h index 202b9bbcdc..7b2ef5df13 100644 --- a/pandatool/src/maya/maya_funcs.h +++ b/pandatool/src/maya/maya_funcs.h @@ -1,16 +1,15 @@ -// Filename: maya_funcs.h -// Created by: drose (16Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file maya_funcs.h + * @author drose + * @date 2000-02-16 + */ #ifndef MAYA_FUNCS_H #define MAYA_FUNCS_H @@ -108,9 +107,9 @@ string_mfndata_type(MFnData::Type type); void list_maya_attributes(MObject &node); -// Also, we must define some output functions for Maya objects, since -// we can't use those built into Maya (which forward-defines the -// ostream type incorrectly). +// Also, we must define some output functions for Maya objects, since we can't +// use those built into Maya (which forward-defines the ostream type +// incorrectly). INLINE ostream &operator << (ostream &out, const MString &str); INLINE ostream &operator << (ostream &out, const MVector &vec); diff --git a/pandatool/src/maya/post_maya_include.h b/pandatool/src/maya/post_maya_include.h index b32f69f9fd..341266fe9a 100644 --- a/pandatool/src/maya/post_maya_include.h +++ b/pandatool/src/maya/post_maya_include.h @@ -1,19 +1,18 @@ -// Filename: post_maya_include.h -// Created by: drose (11Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file post_maya_include.h + * @author drose + * @date 2002-04-11 + */ -// This header file works in conjunction with pre_maya_include.h; it -// cleans up some of the definitions that it left open. +// This header file works in conjunction with pre_maya_include.h; it cleans up +// some of the definitions that it left open. // Remove the symbols defined from pre_maya_include.h. #ifdef MAYA_PRE_5_0 diff --git a/pandatool/src/maya/pre_maya_include.h b/pandatool/src/maya/pre_maya_include.h index 5f6d2f9877..2556db5129 100644 --- a/pandatool/src/maya/pre_maya_include.h +++ b/pandatool/src/maya/pre_maya_include.h @@ -1,25 +1,23 @@ -// Filename: pre_maya_include.h -// Created by: drose (11Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pre_maya_include.h + * @author drose + * @date 2002-04-11 + */ -// This header file defines a few things that are necessary to define -// before including any Maya headers, just to work around some of -// Maya's assumptions about the compiler. It must not try to protect -// itself from multiple inclusion with #ifdef .. #endif, since it must -// be used each time it is included. +// This header file defines a few things that are necessary to define before +// including any Maya headers, just to work around some of Maya's assumptions +// about the compiler. It must not try to protect itself from multiple +// inclusion with #ifdef .. #endif, since it must be used each time it is +// included. -// Maya 2008 will declare some VS2005-specific hacks unless we define -// this. +// Maya 2008 will declare some VS2005-specific hacks unless we define this. #if defined(_MSC_VER) && _MSC_VER < 1400 #define MLIBRARY_DONTUSE_MFC_MANIFEST #endif @@ -30,16 +28,15 @@ #endif #ifdef MAYA_PRE_5_0 -// Old versions of Maya, before version 5.0, used -// etc. instead of the new headers. This requires some -// workarounds to make this work compatibly with Panda, which uses the -// new headers. +// Old versions of Maya, before version 5.0, used etc. instead of +// the new headers. This requires some workarounds to make this +// work compatibly with Panda, which uses the new headers. // In windows, the antiquated headers define completely unrelated (and -// incompatible) classes from those declared in the new headers. On -// the other hand, in gcc the antiquated headers seem to be references -// to the new template classes, so under gcc we also have to declare -// typedefs to make this work. +// incompatible) classes from those declared in the new headers. On the other +// hand, in gcc the antiquated headers seem to be references to the new +// template classes, so under gcc we also have to declare typedefs to make +// this work. #ifdef __GNUC__ #ifndef PRE_MAYA_INCLUDE_H #define PRE_MAYA_INCLUDE_H @@ -54,11 +51,11 @@ typedef istream maya_istream; #else // MAYA_PRE_5_0 -// In Maya 5.0, the headers seem to provide the manifest -// REQUIRE_IOSTREAM, which forces it to use the new headers -// instead of the old headers. It also says this is for -// Linux only, but it seems to work just fine on Windows, obviating -// the need for sneaky #defines in this and in post_maya_include.h. +// In Maya 5.0, the headers seem to provide the manifest REQUIRE_IOSTREAM, +// which forces it to use the new headers instead of the old +// headers. It also says this is for Linux only, but it seems to +// work just fine on Windows, obviating the need for sneaky #defines in this +// and in post_maya_include.h. #ifdef PHAVE_IOSTREAM #define REQUIRE_IOSTREAM #endif // PHAVE_IOSTREAM @@ -69,4 +66,3 @@ typedef istream maya_istream; #endif #endif // MAYA_PRE_5_0 - diff --git a/pandatool/src/mayaegg/config_mayaegg.cxx b/pandatool/src/mayaegg/config_mayaegg.cxx index 6d751dda48..396af69344 100644 --- a/pandatool/src/mayaegg/config_mayaegg.cxx +++ b/pandatool/src/mayaegg/config_mayaegg.cxx @@ -1,16 +1,15 @@ -// Filename: config_mayaegg.cxx -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_mayaegg.cxx + * @author drose + * @date 2002-04-15 + */ #include "config_mayaegg.h" #include "mayaEggGroupUserData.h" @@ -27,27 +26,24 @@ ConfigureFn(config_mayaegg) { init_libmayaegg(); } -// These control the default behavior of the mayaegg converter, but -// not necessarily the default behavior of the maya2egg command-line -// tool (which has its own defaults). +// These control the default behavior of the mayaegg converter, but not +// necessarily the default behavior of the maya2egg command-line tool (which +// has its own defaults). -// Should we respect the Maya double-sided flag (true) or ignore it -// and assume everything is single-sided (false)? +// Should we respect the Maya double-sided flag (true) or ignore it and assume +// everything is single-sided (false)? bool maya_default_double_sided; -// Should we apply vertex color even when a texture is applied (true) -// or only when no texture is applied or the vertex-color egg flag is -// set (false)? +// Should we apply vertex color even when a texture is applied (true) or only +// when no texture is applied or the vertex-color egg flag is set (false)? bool maya_default_vertex_color; -//////////////////////////////////////////////////////////////////// -// Function: init_libmayaegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmayaegg() { static bool initialized = false; @@ -60,11 +56,9 @@ init_libmayaegg() { MayaNodeDesc::init_type(); MayaBlendDesc::init_type(); - // For some reason, static init is not reliably running when this is - // loaded as a plug-in of a plug-in. Initialize these explicitly - // here. + // For some reason, static init is not reliably running when this is loaded + // as a plug-in of a plug-in. Initialize these explicitly here. maya_default_double_sided = ConfigVariableBool("maya-default-double-sided", false).get_value(); maya_default_vertex_color = ConfigVariableBool("maya-default-vertex-color", true).get_value(); } - diff --git a/pandatool/src/mayaegg/config_mayaegg.h b/pandatool/src/mayaegg/config_mayaegg.h index b5e2e6a68e..ede177ab26 100644 --- a/pandatool/src/mayaegg/config_mayaegg.h +++ b/pandatool/src/mayaegg/config_mayaegg.h @@ -1,16 +1,15 @@ -// Filename: config_mayaegg.h -// Created by: drose (15Apr02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_mayaegg.h + * @author drose + * @date 2002-04-15 + */ #ifndef CONFIG_MAYAEGG_H #define CONFIG_MAYAEGG_H diff --git a/pandatool/src/mayaegg/mayaBlendDesc.cxx b/pandatool/src/mayaegg/mayaBlendDesc.cxx index 6563280b76..c0977dcb3a 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.cxx +++ b/pandatool/src/mayaegg/mayaBlendDesc.cxx @@ -1,27 +1,24 @@ -// Filename: mayaBlendDesc.cxx -// Created by: drose (10Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaBlendDesc.cxx + * @author drose + * @date 2004-02-10 + */ #include "mayaBlendDesc.h" #include "config_mayaegg.h" TypeHandle MayaBlendDesc::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: MayaBlendDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaBlendDesc:: MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : _deformer(deformer.object()), @@ -34,22 +31,17 @@ MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index) : _anim = (EggSAnimData *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaBlendDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaBlendDesc:: ~MayaBlendDesc() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaBlendDesc::set_slider -// Access: Public -// Description: Moves the Maya slider associated with this blend -// shape to the indicated value. This will move all the -// affected vertices. -//////////////////////////////////////////////////////////////////// +/** + * Moves the Maya slider associated with this blend shape to the indicated + * value. This will move all the affected vertices. + */ void MayaBlendDesc:: set_slider(PN_stdfloat value) { MStatus status = _deformer.setWeight(_weight_index, value); @@ -59,22 +51,18 @@ set_slider(PN_stdfloat value) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaBlendDesc::get_slider -// Access: Public -// Description: Returns the current position of the Maya slider -// associated with this blend shape. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current position of the Maya slider associated with this blend + * shape. + */ PN_stdfloat MayaBlendDesc:: get_slider() const { return _deformer.weight(_weight_index); } -//////////////////////////////////////////////////////////////////// -// Function: MayaBlendDesc::clear_egg -// Access: Private -// Description: Clears the egg pointers from this blend desc. -//////////////////////////////////////////////////////////////////// +/** + * Clears the egg pointers from this blend desc. + */ void MayaBlendDesc:: clear_egg() { _anim = (EggSAnimData *)NULL; diff --git a/pandatool/src/mayaegg/mayaBlendDesc.h b/pandatool/src/mayaegg/mayaBlendDesc.h index ea60f23513..3be9183a82 100644 --- a/pandatool/src/mayaegg/mayaBlendDesc.h +++ b/pandatool/src/mayaegg/mayaBlendDesc.h @@ -1,16 +1,15 @@ -// Filename: mayaBlendDesc.h -// Created by: drose (10Feb04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaBlendDesc.h + * @author drose + * @date 2004-02-10 + */ #ifndef MAYABLENDDESC_H #define MAYABLENDDESC_H @@ -29,18 +28,15 @@ class EggTable; class EggSAnimData; -//////////////////////////////////////////////////////////////////// -// Class : MayaBlendDesc -// Description : A handle to a Maya blend shape description. This is -// just one target of a Maya BlendShape object, and -// thus corresponds more or less one-to-one with a -// single Egg morph target. (We don't attempt to -// support Maya's chained target shapes here; should we -// need to later, it would mean breaking each of those -// target shapes on the one continuous Maya slider into -// a separate MayaBlendDesc object, and synthesizing the -// egg slider values appropriately.) -//////////////////////////////////////////////////////////////////// +/** + * A handle to a Maya blend shape description. This is just one target of a + * Maya BlendShape object, and thus corresponds more or less one-to-one with a + * single Egg morph target. (We don't attempt to support Maya's chained + * target shapes here; should we need to later, it would mean breaking each of + * those target shapes on the one continuous Maya slider into a separate + * MayaBlendDesc object, and synthesizing the egg slider values + * appropriately.) + */ class MayaBlendDesc : public ReferenceCount, public Namable { public: MayaBlendDesc(MFnBlendShapeDeformer &deformer, int weight_index); diff --git a/pandatool/src/mayaegg/mayaEggGroupUserData.I b/pandatool/src/mayaegg/mayaEggGroupUserData.I index 6cdf01104d..d3e6061e73 100644 --- a/pandatool/src/mayaegg/mayaEggGroupUserData.I +++ b/pandatool/src/mayaegg/mayaEggGroupUserData.I @@ -1,23 +1,19 @@ -// Filename: mayaEggGroupUserData.I -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggGroupUserData.I + * @author drose + * @date 2003-06-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: MayaEggGroupUserData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MayaEggGroupUserData:: MayaEggGroupUserData() { _vertex_color = false; @@ -25,13 +21,11 @@ MayaEggGroupUserData() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaEggGroupUserData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE MayaEggGroupUserData:: -MayaEggGroupUserData(const MayaEggGroupUserData ©) : +MayaEggGroupUserData(const MayaEggGroupUserData ©) : EggUserData(copy), _vertex_color(copy._vertex_color), _double_sided(copy._double_sided) @@ -39,11 +33,9 @@ MayaEggGroupUserData(const MayaEggGroupUserData ©) : } -//////////////////////////////////////////////////////////////////// -// Function: MayaEggGroupUserData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void MayaEggGroupUserData:: operator = (const MayaEggGroupUserData ©) { EggUserData::operator = (copy); diff --git a/pandatool/src/mayaegg/mayaEggGroupUserData.cxx b/pandatool/src/mayaegg/mayaEggGroupUserData.cxx index 27c3a6e03a..47fd08227f 100644 --- a/pandatool/src/mayaegg/mayaEggGroupUserData.cxx +++ b/pandatool/src/mayaegg/mayaEggGroupUserData.cxx @@ -1,16 +1,15 @@ -// Filename: mayaEggGroupUserData.cxx -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggGroupUserData.cxx + * @author drose + * @date 2003-06-03 + */ #include "mayaEggGroupUserData.h" diff --git a/pandatool/src/mayaegg/mayaEggGroupUserData.h b/pandatool/src/mayaegg/mayaEggGroupUserData.h index 90b169b4a3..46b2d2ba79 100644 --- a/pandatool/src/mayaegg/mayaEggGroupUserData.h +++ b/pandatool/src/mayaegg/mayaEggGroupUserData.h @@ -1,16 +1,15 @@ -// Filename: mayaEggGroupUserData.h -// Created by: drose (03Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggGroupUserData.h + * @author drose + * @date 2003-06-03 + */ #ifndef MAYAEGGGROUPUSERDATA_H #define MAYAEGGGROUPUSERDATA_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "eggUserData.h" -//////////////////////////////////////////////////////////////////// -// Class : MayaEggGroupUserData -// Description : This class contains extra user data which is -// piggybacked onto EggGroup objects for the purpose of -// the maya converter. -//////////////////////////////////////////////////////////////////// +/** + * This class contains extra user data which is piggybacked onto EggGroup + * objects for the purpose of the maya converter. + */ class MayaEggGroupUserData : public EggUserData { public: INLINE MayaEggGroupUserData(); diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index 9c4d091461..82523d122f 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -1,22 +1,18 @@ -// Filename: mayaEggLoader.cxx -// Created by: jyelon (20Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// This file contains the code for class MayaEggLoader. This class -// does the actual work of copying an EggData tree into the maya scene. -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggLoader.cxx + * @author jyelon + * @date 2005-07-20 + * + * This file contains the code for class MayaEggLoader. This class + * does the actual work of copying an EggData tree into the maya scene. + */ #include "pandatoolbase.h" #include "notifyCategoryProxy.h" @@ -157,8 +153,8 @@ MColor MakeMayaColor(const LColor &vec) return MColor(vec[0], vec[1], vec[2], vec[3]); } -// [gjeon] to create enum attribute, -// fieldNames is a stringArray of enum names, and filedIndex is the default index value +// [gjeon] to create enum attribute, fieldNames is a stringArray of enum +// names, and filedIndex is the default index value MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName, MStringArray fieldNames, unsigned fieldIndex) { MStatus stat; @@ -205,11 +201,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName return stat; } -//////////////////////////////////////////////////////////////////// -// // MayaEggTex -// -//////////////////////////////////////////////////////////////////// class MayaEggTex { @@ -323,11 +315,7 @@ MayaEggTex *MayaEggLoader::GetTex(EggTexture* etex) return res; } -//////////////////////////////////////////////////////////////////// -// // MayaEggGroup -// -//////////////////////////////////////////////////////////////////// class MayaEggGroup { @@ -412,11 +400,7 @@ MayaEggGroup *MayaEggLoader::FindGroup(EggGroup *group) return _group_tab[group]; } -//////////////////////////////////////////////////////////////////// -// // MayaEggJoint -// -//////////////////////////////////////////////////////////////////// class MayaEggJoint { @@ -563,7 +547,7 @@ void MayaEggJoint::ChooseEndPos(double thickness) if (fwd.length() < 0.001) { fwd = parentendpos - parentpos; } - //mayaloader_cat.debug() << "fwd : " << fwd << endl; + // mayaloader_cat.debug() << "fwd : " << fwd << endl; fwd.normalize(); MayaEggJoint *child = ChooseBestChild(fwd); if (child == 0) { @@ -587,10 +571,9 @@ void MayaEggJoint::ChooseEndPos(double thickness) void MayaEggJoint::CreateMayaBone(MayaEggGroup *eggParent) { LVector3d rxv, ryv, rzv; - //GetRotation(rxv, ryv, rzv); - // [gjeon] I think we shouldn't need to use this GetRotation function here - // since this function removes scale information from the matrix. - // Let's just use the matrix directly. + // GetRotation(rxv, ryv, rzv); [gjeon] I think we shouldn't need to use this + // GetRotation function here since this function removes scale information + // from the matrix. Let's just use the matrix directly. rxv = _trans.get_row3(0); ryv = _trans.get_row3(1); rzv = _trans.get_row3(2); @@ -632,11 +615,7 @@ void MayaEggJoint::CreateMayaBone(MayaEggGroup *eggParent) } -//////////////////////////////////////////////////////////////////// -// // MayaEggGeom : base abstract class of MayaEggMesh and MayaEggNurbsSurface -// -//////////////////////////////////////////////////////////////////// typedef pair MayaEggWeight; @@ -770,7 +749,7 @@ int MayaEggGeom::GetVert(EggVertex *vert, EggGroup *context) vtx._external_index = vert->get_index()-1; EggVertex::GroupRef::const_iterator gri; - //double remaining_weight = 1.0; + // double remaining_weight = 1.0; for (gri = vert->gref_begin(); gri != vert->gref_end(); ++gri) { EggGroup *egg_joint = (*gri); double membership = egg_joint->get_vertex_membership(vert); @@ -780,7 +759,7 @@ int MayaEggGeom::GetVert(EggVertex *vert, EggGroup *context) mayaloader_cat.warning() << "negative weight value " << membership << " is replaced with 0 on: " << context->get_name() << endl; membership = 0.0; } - //remaining_weight -= membership; + // remaining_weight -= membership; vtx._weights.push_back(MayaEggWeight(membership, egg_joint)); vtx._sumWeights += membership; // [gjeon] to be used in normalizing weights } @@ -790,10 +769,10 @@ int MayaEggGeom::GetVert(EggVertex *vert, EggGroup *context) vtx._weights.push_back(MayaEggWeight(1.0, context)); vtx._sumWeights = 1.0; // [gjeon] to be used in normalizing weights } - //remaining_weight = 0.0; + // remaining_weight = 0.0; }/* else { - // some soft models came up short of 1.0 on vertex membership - // add the remainder of the weight on first joint in the membership + // some soft models came up short of 1.0 on vertex membership add the + // remainder of the weight on first joint in the membership if ((remaining_weight) > 0.01) { gri = vert->gref_begin(); EggGroup *egg_joint = (*gri); @@ -825,7 +804,7 @@ int MayaEggGeom::GetVert(EggVertex *vert, EggGroup *context) return vti->_index; } - //_vert_count++; + // _vert_count++; vtx._index = _vert_count++; /* if ((remaining_weight) > 0.01) { @@ -924,11 +903,7 @@ void MayaEggGeom::AddEggFlag(MString fieldName) { } } -//////////////////////////////////////////////////////////////////// -// // MayaEggMesh -// -//////////////////////////////////////////////////////////////////// typedef phash_map TVertTable; typedef phash_map CVertTable; @@ -979,16 +954,13 @@ int MayaEggMesh::GetTVert(const LTexCoordd &uv) int MayaEggMesh::GetCVert(const LColor &col) { - // if (_cvert_tab.count(col)) - // return _cvert_tab[col]; - // if (_cvert_count == _mesh->numCVerts) { - // int nsize = _cvert_count*2 + 100; - // _mesh->setNumVertCol(nsize, _cvert_count?TRUE:FALSE); - // } - // int idx = _cvert_count++; - // _mesh->vertCol[idx] = Point3(col.get_x(), col.get_y(), col.get_z()); - // _cvert_tab[col] = idx; - // return idx; +/* + * if (_cvert_tab.count(col)) return _cvert_tab[col]; if (_cvert_count == + * _mesh->numCVerts) { int nsize = _cvert_count*2 + 100; + * _mesh->setNumVertCol(nsize, _cvert_count?TRUE:FALSE); } int idx = + * _cvert_count++; _mesh->vertCol[idx] = Point3(col.get_x(), col.get_y(), + * col.get_z()); _cvert_tab[col] = idx; return idx; + */ return 0; } @@ -1060,11 +1032,7 @@ void MayaEggMesh::ConnectTextures(void) } -//////////////////////////////////////////////////////////////////// -// // MayaEggNurbsSurface -// -//////////////////////////////////////////////////////////////////// class MayaEggNurbsSurface : public MayaEggGeom { public: @@ -1121,10 +1089,9 @@ MayaEggNurbsSurface *MayaEggLoader::GetSurface(EggVertexPool *pool, EggGroup *pa void MayaEggNurbsSurface::ConnectTextures(void) { - // masad: since nurbs surfaces do not support vertex colors - // I am infusing the surface's first vertex color (if any) - // into the shader to achive the color. - // masad: check if there is any vertex color for this surface + // masad: since nurbs surfaces do not support vertex colors I am infusing + // the surface's first vertex color (if any) into the shader to achive the + // color. masad: check if there is any vertex color for this surface MStatus status; MColor firstColor(0.5,0.5,0.5,1.0); if (_vertColorArray.length() > 0) { @@ -1173,11 +1140,7 @@ void MayaEggNurbsSurface::PrintData(void) */ } -//////////////////////////////////////////////////////////////////// -// // MayaAnim: -// -//////////////////////////////////////////////////////////////////// class MayaAnim { public: @@ -1211,11 +1174,7 @@ void MayaAnim::PrintData(void) _pool->write(mayaloader_cat.debug(), 0); } -//////////////////////////////////////////////////////////////////// -// // MayaEggLoader functions -// -//////////////////////////////////////////////////////////////////// void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) { @@ -1356,14 +1315,8 @@ void MayaEggLoader::CreateSkinCluster(MayaEggGeom *M) } } -//////////////////////////////////////////////////////////////////// -// -// TraverseEggData -// -// We have an EggData in memory, and now we're going to copy that -// over into the maya scene graph. -// -//////////////////////////////////////////////////////////////////// +// TraverseEggData We have an EggData in memory, and now we're going to copy +// that over into the maya scene graph. void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string delim) { @@ -1567,12 +1520,11 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << delim+delstring << "found an EggSAnimData: " << node->get_name() << endl; } - //EggSAnimData *anim = DCAST(EggSAnimData, node); - //MayaAnimData *animData = GetAnimData(anim, DCAST(EggXfmSAnim, node->get_parent())); - //animData->PrintData(); - //if (_end_frame < animData->_pool->get_num_rows()) { - // _end_frame = animData->_pool->get_num_rows(); - //} + // EggSAnimData *anim = DCAST(EggSAnimData, node); MayaAnimData *animData + // = GetAnimData(anim, DCAST(EggXfmSAnim, node->get_parent())); + // animData->PrintData(); if (_end_frame < + // animData->_pool->get_num_rows()) { _end_frame = + // animData->_pool->get_num_rows(); } } else if (node->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *group = DCAST(EggGroupNode, node); if (node->is_of_type(EggGroup::get_class_type())) { @@ -1608,13 +1560,13 @@ void MayaEggLoader::TraverseEggNode(EggNode *node, EggGroup *context, string del context = group; } } else if (node->is_of_type(EggTable::get_class_type())) { - //EggTable *anim = DCAST(EggTable, node); + // EggTable *anim = DCAST(EggTable, node); if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << delim+delstring << "found an EggTable: " << node->get_name() << endl; } } else if (node->is_of_type(EggXfmSAnim::get_class_type())) { MayaAnim *anim = GetAnim(DCAST(EggXfmSAnim, node)); - //anim->PrintData(); + // anim->PrintData(); if (mayaloader_cat.is_debug()) { mayaloader_cat.debug() << delim+delstring << "found an EggXfmSAnim: " << node->get_name() << endl; } @@ -1678,7 +1630,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a continue; } - // MStatus status; + // MStatus status; MFnMesh mfn; MString cset; @@ -1727,8 +1679,8 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a } } - // Check the "Display Colors" box by default, so that vertex - // colors (if any) will be visible. + // Check the "Display Colors" box by default, so that vertex colors (if + // any) will be visible. MPlug displayColors = mfn.findPlug("displayColors"); displayColors.setValue((bool)true); @@ -1794,7 +1746,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a continue; } - // MStatus status; + // MStatus status; MFnNurbsSurface mfnNurbsSurface; MayaEggGroup *parentNode = FindGroup(surface->_parent); @@ -2016,8 +1968,7 @@ bool MayaEggLoader::ConvertEggData(EggData *data, bool merge, bool model, bool a delete (*ei).second; } - // ResumeSetKeyMode(); - // ResumeAnimate(); + // ResumeSetKeyMode(); ResumeAnimate(); mayaloader_cat.info() << "Egg import successful\n"; return true; @@ -2067,7 +2018,8 @@ void MayaEggLoader::ParseFrameInfo(string comment) mayaloader_cat.debug() << comment.substr(ls+1, le-ls-1) << endl; } _frame_rate = atoi(comment.substr(ls+1,le-ls-1).data()); - //mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; frame_rate = " << _frame_rate << endl; + // mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; + // frame_rate = " << _frame_rate << endl; switch (_frame_rate) { case 15: @@ -2151,7 +2103,8 @@ void MayaEggLoader::ParseFrameInfo(string comment) } else { _start_frame = atoi(comment.substr(ls+1,le-ls-1).data()); } - //mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; start_frame = " << _start_frame << endl; + // mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; + // start_frame = " << _start_frame << endl; } pos = comment.find("-ef"); if (pos != string::npos) { @@ -2165,7 +2118,8 @@ void MayaEggLoader::ParseFrameInfo(string comment) } else { _end_frame = atoi(comment.substr(ls+1,le-ls-1).data()); } - //mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; end_frame = " << _end_frame << endl; + // mayaloader_cat.debug() << "le = " << le << "; and ls = " << ls << "; + // end_frame = " << _end_frame << endl; } @@ -2195,8 +2149,8 @@ MObject MayaEggLoader::GetDependencyNode(string givenName) name = givenName; /* - //masad: I do not think you want to return a mesh node - //because keyframes should only apply to joint nodes. + // masad: I do not think you want to return a mesh node because keyframes + // should only apply to joint nodes. MeshTable::const_iterator ci; for (ci = _mesh_tab.begin(); ci != _mesh_tab.end(); ++ci) { MayaEggMesh *mesh = (*ci).second; @@ -2232,11 +2186,7 @@ MObject MayaEggLoader::GetDependencyNode(string givenName) return node; } -//////////////////////////////////////////////////////////////////// -// // The two global functions that form the API of this module. -// -//////////////////////////////////////////////////////////////////// bool MayaLoadEggData(EggData *data, bool merge, bool model, bool anim, bool respect_normals) { @@ -2250,4 +2200,3 @@ bool MayaLoadEggFile(const char *name, bool merge, bool model, bool anim, bool r MayaEggLoader loader; return loader.ConvertEggFile(name, merge, model, anim, respect_normals); } - diff --git a/pandatool/src/mayaegg/mayaEggLoader.h b/pandatool/src/mayaegg/mayaEggLoader.h index d203f98ead..077d0da5ae 100644 --- a/pandatool/src/mayaegg/mayaEggLoader.h +++ b/pandatool/src/mayaegg/mayaEggLoader.h @@ -1,16 +1,15 @@ -// Filename: mayaEggLoader.h -// Created by: jyelon (20jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggLoader.h + * @author jyelon + * @date 2005-07-20 + */ #ifndef MAYAEGGLOADER_H #define MAYAEGGLOADER_H @@ -21,4 +20,3 @@ bool MayaLoadEggData(EggData *data, bool merge, bool model, bool anim, bool r bool MayaLoadEggFile(const char *name, bool merge, bool model, bool anim, bool respect_normals); #endif - diff --git a/pandatool/src/mayaegg/mayaNodeDesc.cxx b/pandatool/src/mayaegg/mayaNodeDesc.cxx index ff63a4d520..72c8854976 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.cxx +++ b/pandatool/src/mayaegg/mayaNodeDesc.cxx @@ -1,16 +1,15 @@ -// Filename: mayaNodeDesc.cxx -// Created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaNodeDesc.cxx + * @author drose + * @date 2003-06-06 + */ #include "mayaNodeDesc.h" #include "mayaNodeTree.h" @@ -29,8 +28,7 @@ TypeHandle MayaNodeDesc::_type_handle; -// This is a list of the names of Maya connections that count as a -// transform. +// This is a list of the names of Maya connections that count as a transform. static const char *transform_connections[] = { "translate", "translateX", @@ -43,11 +41,9 @@ static const char *transform_connections[] = { }; static const int num_transform_connections = sizeof(transform_connections) / sizeof(const char *); -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaNodeDesc:: MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : Namable(name), @@ -69,11 +65,9 @@ MayaNodeDesc(MayaNodeTree *tree, MayaNodeDesc *parent, const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaNodeDesc:: ~MayaNodeDesc() { if (_dag_path != (MDagPath *)NULL) { @@ -81,12 +75,9 @@ MayaNodeDesc:: } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::from_dag_path -// Access: Public -// Description: Indicates an association between the MayaNodeDesc and -// some Maya instance. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an association between the MayaNodeDesc and some Maya instance. + */ void MayaNodeDesc:: from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { MStatus status; @@ -103,23 +94,22 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { } if (_dag_path->hasFn(MFn::kJoint) || converter->force_joint(name)) { - // This node is a joint, or the user specifically asked to treat - // it like a joint. + // This node is a joint, or the user specifically asked to treat it like + // a joint. _joint_type = JT_joint; if (_parent != (MayaNodeDesc *)NULL) { _parent->mark_joint_parent(); } } else { - // The node is not a joint, but maybe its transform is - // controlled by connected inputs. If so, we should treat it - // like a joint. + // The node is not a joint, but maybe its transform is controlled by + // connected inputs. If so, we should treat it like a joint. bool transform_connected = false; MStatus status; MObject node = dag_path.node(&status); if (status) { - for (int i = 0; + for (int i = 0; i < num_transform_connections && !transform_connected; i++) { if (is_connected(node, transform_connections[i])) { @@ -127,7 +117,7 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { } } } - + if (transform_connected) { _joint_type = JT_joint; if (_parent != (MayaNodeDesc *)NULL) { @@ -150,110 +140,86 @@ from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::has_dag_path -// Access: Public -// Description: Returns true if a Maya dag path has been associated -// with this node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a Maya dag path has been associated with this node, false + * otherwise. + */ bool MayaNodeDesc:: has_dag_path() const { return (_dag_path != (MDagPath *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::get_dag_path -// Access: Public -// Description: Returns the dag path associated with this node. It -// is an error to call this unless has_dag_path() -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dag path associated with this node. It is an error to call + * this unless has_dag_path() returned true. + */ const MDagPath &MayaNodeDesc:: get_dag_path() const { nassertr(_dag_path != (MDagPath *)NULL, *_dag_path); return *_dag_path; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::get_num_blend_descs -// Access: Public -// Description: Returns the number of unique MayaBlendDesc objects -// (and hence the number of morph sliders) that affect -// the geometry in this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique MayaBlendDesc objects (and hence the number of + * morph sliders) that affect the geometry in this node. + */ int MayaNodeDesc:: get_num_blend_descs() const { return _blend_descs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::get_blend_desc -// Access: Public -// Description: Returns the nth MayaBlendDesc object that affects the -// geometry in this node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth MayaBlendDesc object that affects the geometry in this + * node. + */ MayaBlendDesc *MayaNodeDesc:: get_blend_desc(int n) const { nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); return _blend_descs[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::is_joint -// Access: Public -// Description: Returns true if the node should be treated as a joint -// by the converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node should be treated as a joint by the converter. + */ bool MayaNodeDesc:: is_joint() const { - //return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; + // return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; return _joint_tagged && (_joint_type == JT_joint || _joint_type == JT_pseudo_joint); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::is_joint_parent -// Access: Public -// Description: Returns true if the node is the parent or ancestor of -// a joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is the parent or ancestor of a joint. + */ bool MayaNodeDesc:: is_joint_parent() const { return _joint_type == JT_joint_parent; - //return _joint_tagged && (_joint_type == JT_joint_parent); + // return _joint_tagged && (_joint_type == JT_joint_parent); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::is_joint_tagged -// Access: Public -// Description: Returns true if the node has been joint_tagged to be -// converted, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has been joint_tagged to be converted, false + * otherwise. + */ bool MayaNodeDesc:: is_joint_tagged() const { return _joint_tagged; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::tag_joint -// Access: Private -// Description: Tags this node for conversion, but does not tag child -// nodes. -//////////////////////////////////////////////////////////////////// +/** + * Tags this node for conversion, but does not tag child nodes. + */ void MayaNodeDesc:: tag_joint() { _joint_tagged = true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::tag_joint_recursively -// Access: Private -// Description: Tags this node and all descendant nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Tags this node and all descendant nodes for conversion. + */ void MayaNodeDesc:: tag_joint_recursively() { _joint_tagged = true; - //mayaegg_cat.info() << "tjr: " << get_name() << endl; + // mayaegg_cat.info() << "tjr: " << get_name() << endl; Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { MayaNodeDesc *child = (*ci); @@ -261,45 +227,33 @@ tag_joint_recursively() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::is_tagged -// Access: Public -// Description: Returns true if the node has been tagged to be -// converted, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node has been tagged to be converted, false otherwise. + */ bool MayaNodeDesc:: is_tagged() const { return _tagged; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::tag -// Access: Private -// Description: Tags this node for conversion, but does not tag child -// nodes. -//////////////////////////////////////////////////////////////////// +/** + * Tags this node for conversion, but does not tag child nodes. + */ void MayaNodeDesc:: tag() { _tagged = true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::untag -// Access: Private -// Description: Un-tags this node for conversion, but does not tag child -// nodes. -//////////////////////////////////////////////////////////////////// +/** + * Un-tags this node for conversion, but does not tag child nodes. + */ void MayaNodeDesc:: untag() { _tagged = false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::tag_recursively -// Access: Private -// Description: Tags this node and all descendant nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Tags this node and all descendant nodes for conversion. + */ void MayaNodeDesc:: tag_recursively() { _tagged = true; @@ -311,12 +265,9 @@ tag_recursively() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::untag_recursively -// Access: Private -// Description: Un-tags this node and all descendant nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Un-tags this node and all descendant nodes for conversion. + */ void MayaNodeDesc:: untag_recursively() { _tagged = false; @@ -328,16 +279,14 @@ untag_recursively() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::has_object_type -// Access: Public -// Description: Returns true if this node or any of its parent -// has_object_type of object_type. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node or any of its parent has_object_type of + * object_type. + */ bool MayaNodeDesc:: has_object_type(string object_type) const { bool ret = false; - if ((_egg_group != (EggGroup*) NULL) + if ((_egg_group != (EggGroup*) NULL) && _egg_group->has_object_type(object_type)) { return true; } @@ -347,12 +296,9 @@ has_object_type(string object_type) const { return ret; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::clear_egg -// Access: Private -// Description: Recursively clears the egg pointers from this node -// and all children. -//////////////////////////////////////////////////////////////////// +/** + * Recursively clears the egg pointers from this node and all children. + */ void MayaNodeDesc:: clear_egg() { _egg_group = (EggGroup *)NULL; @@ -366,12 +312,10 @@ clear_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::mark_joint_parent -// Access: Private -// Description: Indicates that this node has at least one child that -// is a joint or a pseudo-joint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this node has at least one child that is a joint or a + * pseudo-joint. + */ void MayaNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { @@ -382,14 +326,11 @@ mark_joint_parent() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::check_pseudo_joints -// Access: Private -// Description: Walks the hierarchy, looking for non-joint nodes that -// are both children and parents of a joint. These -// nodes are deemed to be pseudo joints, since the -// converter must treat them as joints. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, looking for non-joint nodes that are both children and + * parents of a joint. These nodes are deemed to be pseudo joints, since the + * converter must treat them as joints. + */ void MayaNodeDesc:: check_pseudo_joints(bool joint_above) { static PN_uint32 space_count = 0; @@ -401,20 +342,19 @@ check_pseudo_joints(bool joint_above) { mayaegg_cat.spam() << "cpj:" << space << get_name() << " joint_type: " << _joint_type << endl; } if (_joint_type == JT_joint_parent && joint_above) { - // This is one such node: it is the parent of a joint - // (JT_joint_parent is set), and it is the child of a joint - // (joint_above is set). + // This is one such node: it is the parent of a joint (JT_joint_parent is + // set), and it is the child of a joint (joint_above is set). _joint_type = JT_pseudo_joint; } if (_joint_type == JT_joint) { - // If this node is itself a joint, then joint_above is true for - // all child nodes. + // If this node is itself a joint, then joint_above is true for all child + // nodes. joint_above = true; } - // Don't bother traversing further if _joint_type is none, since - // that means this node has no joint children. + // Don't bother traversing further if _joint_type is none, since that means + // this node has no joint children. if (_joint_type != JT_none) { bool any_joints = false; @@ -425,14 +365,14 @@ check_pseudo_joints(bool joint_above) { ++space_count; } child->check_pseudo_joints(joint_above); - //if (child->is_joint()) { + // if (child->is_joint()) { if (child->_joint_type == JT_joint || child->_joint_type == JT_pseudo_joint) { any_joints = true; } } - // If any children qualify as joints, then any sibling nodes that - // are parents of joints are also elevated to joints. + // If any children qualify as joints, then any sibling nodes that are + // parents of joints are also elevated to joints. if (any_joints) { bool all_joints = true; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -474,31 +414,28 @@ check_pseudo_joints(bool joint_above) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::check_blend_shapes -// Access: Private -// Description: Looks for blend shapes on a NURBS surface or polygon -// mesh and records any blend shapes found. This is -// similar to MayaToEggConverter::get_vertex_weights(), -// which checks for membership of vertices to joints; -// Maya stores the blend shape table in the same place. -// See the comments in get_vertex_weights() for a more -// in-depth description of the iteration process here. -//////////////////////////////////////////////////////////////////// +/** + * Looks for blend shapes on a NURBS surface or polygon mesh and records any + * blend shapes found. This is similar to + * MayaToEggConverter::get_vertex_weights(), which checks for membership of + * vertices to joints; Maya stores the blend shape table in the same place. + * See the comments in get_vertex_weights() for a more in-depth description of + * the iteration process here. + */ void MayaNodeDesc:: check_blend_shapes(const MFnDagNode &node, const string &attrib_name) { MStatus status; - MObject attr = node.attribute(attrib_name.c_str()); - - MPlug history(node.object(), attr); - MItDependencyGraph it(history, MFn::kDependencyNode, - MItDependencyGraph::kUpstream, - MItDependencyGraph::kDepthFirst, + MObject attr = node.attribute(attrib_name.c_str()); + + MPlug history(node.object(), attr); + MItDependencyGraph it(history, MFn::kDependencyNode, + MItDependencyGraph::kUpstream, + MItDependencyGraph::kDepthFirst, MItDependencyGraph::kNodeLevel); while (!it.isDone()) { - MObject c_node = it.thisNode(); + MObject c_node = it.thisNode(); if (c_node.hasFn(MFn::kBlendShape)) { MFnBlendShapeDeformer blends(c_node, &status); @@ -506,9 +443,9 @@ check_blend_shapes(const MFnDagNode &node, const string &attrib_name) { status.perror("MFnBlendShapeDeformer constructor"); } else { - // Check if the slider is a "parallel blender", which is a - // construct created by Maya for Maya's internal purposes - // only. We don't want to fiddle with the parallel blenders. + // Check if the slider is a "parallel blender", which is a construct + // created by Maya for Maya's internal purposes only. We don't want + // to fiddle with the parallel blenders. MPlug plug = blends.findPlug("pb"); bool is_parallel_blender; status = plug.getValue(is_parallel_blender); @@ -517,7 +454,7 @@ check_blend_shapes(const MFnDagNode &node, const string &attrib_name) { is_parallel_blender = false; } - if (is_parallel_blender || + if (is_parallel_blender || _tree->ignore_slider(blends.name().asChar())) { _tree->report_ignored_slider(blends.name().asChar()); @@ -529,7 +466,7 @@ check_blend_shapes(const MFnDagNode &node, const string &attrib_name) { } else { for (unsigned int oi = 0; oi < base_objects.length(); oi++) { MObject base_object = base_objects[oi]; - + MIntArray index_list; status = blends.weightIndexList(index_list); if (!status) { @@ -552,20 +489,16 @@ check_blend_shapes(const MFnDagNode &node, const string &attrib_name) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeDesc::check_lods -// Access: Private -// Description: Walks through the hierarchy again and checks for LOD -// specifications. Any such specifications found are -// recorded on the child nodes of the lodGroups -// themselves: the nodes that actually switch in and -// out. (This is the way they are recorded in an egg -// file.) -//////////////////////////////////////////////////////////////////// +/** + * Walks through the hierarchy again and checks for LOD specifications. Any + * such specifications found are recorded on the child nodes of the lodGroups + * themselves: the nodes that actually switch in and out. (This is the way + * they are recorded in an egg file.) + */ void MayaNodeDesc:: check_lods() { - // Walk through the children first. This makes it easier in the - // below (we only have to return in the event of an error). + // Walk through the children first. This makes it easier in the below (we + // only have to return in the event of an error). Children::iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { MayaNodeDesc *child = (*ci); @@ -575,8 +508,7 @@ check_lods() { // Now consider whether this node is an lodGroup. if (_dag_path != (MDagPath *)NULL && _dag_path->hasFn(MFn::kLodGroup)) { - // This node is a parent lodGroup; its children, therefore, are - // LOD's. + // This node is a parent lodGroup; its children, therefore, are LOD's. MStatus status; MFnDagNode dag_node(*_dag_path, &status); if (!status) { @@ -590,8 +522,8 @@ check_lods() { return; } - // There ought to be the one fewer elements in the array than - // there are children of the node. + // There ought to be the one fewer elements in the array than there are + // children of the node. unsigned int num_elements = plug.numElements(); unsigned int num_children = _children.size(); if (num_elements + 1 != num_children) { @@ -600,10 +532,9 @@ check_lods() { << " LOD entries, but " << num_children << " children.\n"; } - // Should we also consider cameraMatrix, to transform the LOD's - // origin? It's not clear precisely what this transform matrix - // means in Maya, so we'll wait until we have a sample file that - // demonstrates its use. + // Should we also consider cameraMatrix, to transform the LOD's origin? + // It's not clear precisely what this transform matrix means in Maya, so + // we'll wait until we have a sample file that demonstrates its use. double switch_out = 0.0; unsigned int i = 0; @@ -627,14 +558,14 @@ check_lods() { } while (i < num_children) { - // Also set the last child(ren). Maya wants this to switch in - // at infinity, but Panda doesn't have such a concept; we'll - // settle for four times the switch_out distance. + // Also set the last child(ren). Maya wants this to switch in at + // infinity, but Panda doesn't have such a concept; we'll settle for + // four times the switch_out distance. MayaNodeDesc *child = _children[i]; child->_is_lod = true; child->_switch_in = switch_out * 4.0; child->_switch_out = switch_out; - + ++i; } } diff --git a/pandatool/src/mayaegg/mayaNodeDesc.h b/pandatool/src/mayaegg/mayaNodeDesc.h index 30529204a5..1c28cb1698 100644 --- a/pandatool/src/mayaegg/mayaNodeDesc.h +++ b/pandatool/src/mayaegg/mayaNodeDesc.h @@ -1,16 +1,15 @@ -// Filename: mayaNodeDesc.h -// Created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaNodeDesc.h + * @author drose + * @date 2003-06-06 + */ #ifndef MAYANODEDESC_H #define MAYANODEDESC_H @@ -33,13 +32,11 @@ class EggGroup; class EggTable; class EggXfmSAnim; -//////////////////////////////////////////////////////////////////// -// Class : MayaNodeDesc -// Description : Describes a single instance of a node in the Maya -// scene graph, relating it to the corresponding egg -// structures (e.g. node, group, or table entry) that -// will be created. -//////////////////////////////////////////////////////////////////// +/** + * Describes a single instance of a node in the Maya scene graph, relating it + * to the corresponding egg structures (e.g. node, group, or table entry) + * that will be created. + */ class MayaNodeDesc : public ReferenceCount, public Namable { public: MayaNodeDesc(MayaNodeTree *tree, @@ -64,7 +61,7 @@ public: MayaNodeDesc *_parent; typedef pvector< PT(MayaNodeDesc) > Children; Children _children; - + private: void tag(); void untag(); @@ -76,7 +73,7 @@ private: void clear_egg(); void mark_joint_parent(); void check_pseudo_joints(bool joint_above); - void check_blend_shapes(const MFnDagNode &node, + void check_blend_shapes(const MFnDagNode &node, const string &attrib_name); void check_lods(); diff --git a/pandatool/src/mayaegg/mayaNodeTree.cxx b/pandatool/src/mayaegg/mayaNodeTree.cxx index 06249d93fd..def22d13b2 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.cxx +++ b/pandatool/src/mayaegg/mayaNodeTree.cxx @@ -1,16 +1,15 @@ -// Filename: mayaNodeTree.cxx -// Created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaNodeTree.cxx + * @author drose + * @date 2003-06-06 + */ #include "mayaNodeTree.h" #include "mayaBlendDesc.h" @@ -33,11 +32,9 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaNodeTree:: MayaNodeTree(MayaToEggConverter *converter) : _converter(converter) @@ -50,13 +47,10 @@ MayaNodeTree(MayaToEggConverter *converter) : _morph_node = (EggGroupNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::build_node -// Access: Public -// Description: Returns a pointer to the node corresponding to the -// indicated dag_path object, creating it first if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the node corresponding to the indicated dag_path + * object, creating it first if necessary. + */ MayaNodeDesc *MayaNodeTree:: build_node(const MDagPath &dag_path) { MayaNodeDesc *node_desc = r_build_node(dag_path.fullPathName().asChar()); @@ -64,12 +58,10 @@ build_node(const MDagPath &dag_path) { return node_desc; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::build_hierarchy -// Access: Public -// Description: Walks through the complete Maya hierarchy but does -// not tag any nodes for conversion. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the complete Maya hierarchy but does not tag any nodes for + * conversion. + */ bool MayaNodeTree:: build_hierarchy() { MStatus status; @@ -85,11 +77,11 @@ build_hierarchy() { status = dag_iterator.reset(dag_iterator.item(),MItDag::kDepthFirst, MFn::kTransform); */ // Get the entire Maya scene. - - // This while loop walks through the entire Maya hierarchy, one - // node at a time. Maya's MItDag object automatically performs a - // depth-first traversal of its scene graph. - + + // This while loop walks through the entire Maya hierarchy, one node at a + // time. Maya's MItDag object automatically performs a depth-first + // traversal of its scene graph. + bool all_ok = true; while (!dag_iterator.isDone()) { MDagPath dag_path; @@ -99,7 +91,7 @@ build_hierarchy() { } else { build_node(dag_path); } - + dag_iterator.next(); } @@ -107,33 +99,26 @@ build_hierarchy() { _root->check_pseudo_joints(false); _root->check_lods(); } - + return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::tag_joint_all -// Access: Public -// Description: Tags the entire hierarchy for conversion. This is -// the normal behavior. -//////////////////////////////////////////////////////////////////// +/** + * Tags the entire hierarchy for conversion. This is the normal behavior. + */ void MayaNodeTree:: tag_joint_all() { _root->tag_joint_recursively(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::tag_joint_named -// Access: Public -// Description: Tags nodes matching the indicated glob (and all of -// their children) for conversion. Returns true on -// success, false otherwise (e.g. the named node does -// not exist). -//////////////////////////////////////////////////////////////////// +/** + * Tags nodes matching the indicated glob (and all of their children) for + * conversion. Returns true on success, false otherwise (e.g. the named node + * does not exist). + */ bool MayaNodeTree:: tag_joint_named(const GlobPattern &glob) { - // There might be multiple nodes matching the name; search for all - // of them. + // There might be multiple nodes matching the name; search for all of them. bool found_any = false; Nodes::iterator ni; @@ -148,29 +133,22 @@ tag_joint_named(const GlobPattern &glob) { return found_any; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::tag_all -// Access: Public -// Description: Tags the entire hierarchy for conversion. This is -// the normal behavior. -//////////////////////////////////////////////////////////////////// +/** + * Tags the entire hierarchy for conversion. This is the normal behavior. + */ void MayaNodeTree:: tag_all() { _root->tag_recursively(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::tag_named -// Access: Public -// Description: Tags nodes matching the indicated glob (and all of -// their children) for conversion. Returns true on -// success, false otherwise (e.g. the named node does -// not exist). -//////////////////////////////////////////////////////////////////// +/** + * Tags nodes matching the indicated glob (and all of their children) for + * conversion. Returns true on success, false otherwise (e.g. the named node + * does not exist). + */ bool MayaNodeTree:: tag_named(const GlobPattern &glob) { - // There might be multiple nodes matching the name; search for all - // of them. + // There might be multiple nodes matching the name; search for all of them. bool found_any = false; Nodes::iterator ni; @@ -185,18 +163,14 @@ tag_named(const GlobPattern &glob) { return found_any; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::untag_named -// Access: Public -// Description: Un-tags nodes matching the indicated glob (and all of -// their children) for conversion. Returns true on -// success, false otherwise (e.g. the named node does -// not exist). -//////////////////////////////////////////////////////////////////// +/** + * Un-tags nodes matching the indicated glob (and all of their children) for + * conversion. Returns true on success, false otherwise (e.g. the named node + * does not exist). + */ bool MayaNodeTree:: untag_named(const GlobPattern &glob) { - // There might be multiple nodes matching the name; search for all - // of them. + // There might be multiple nodes matching the name; search for all of them. bool found_any = false; Nodes::iterator ni; @@ -211,13 +185,11 @@ untag_named(const GlobPattern &glob) { return found_any; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::tag_selected -// Access: Public -// Description: Tags the just the selected hierarchy for conversion, -// or the entire hierarchy if nothing is selected. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Tags the just the selected hierarchy for conversion, or the entire + * hierarchy if nothing is selected. Returns true on success, false on + * failure. + */ bool MayaNodeTree:: tag_selected() { MStatus status; @@ -234,7 +206,7 @@ tag_selected() { status.perror("MGlobal::getActiveSelectionList"); return false; } - + if (selection.isEmpty()) { mayaegg_cat.info() << "Selection list is empty.\n"; @@ -250,8 +222,7 @@ tag_selected() { if (!status) { status.perror("MSelectionList::getDagPath"); } else { - // Now traverse through the selected dag path and all nested - // dag paths. + // Now traverse through the selected dag path and all nested dag paths. dag_iterator.reset(root_path); while (!dag_iterator.isDone()) { MDagPath dag_path; @@ -261,7 +232,7 @@ tag_selected() { } else { build_node(dag_path)->tag(); } - + dag_iterator.next(); } } @@ -274,35 +245,27 @@ tag_selected() { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_num_nodes -// Access: Public -// Description: Returns the total number of nodes in the hierarchy, -// not counting the root node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of nodes in the hierarchy, not counting the root + * node. + */ int MayaNodeTree:: get_num_nodes() const { return _nodes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_node -// Access: Public -// Description: Returns the nth node in the hierarchy, in an -// arbitrary ordering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth node in the hierarchy, in an arbitrary ordering. + */ MayaNodeDesc *MayaNodeTree:: get_node(int n) const { nassertr(n >= 0 && n < (int)_nodes.size(), NULL); return _nodes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::clear -// Access: Public -// Description: Resets the entire tree in preparation for -// repopulating with a new scene. -//////////////////////////////////////////////////////////////////// +/** + * Resets the entire tree in preparation for repopulating with a new scene. + */ void MayaNodeTree:: clear() { _root = new MayaNodeDesc(this); @@ -315,15 +278,12 @@ clear() { _nodes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::clear_egg -// Access: Public -// Description: Removes all of the references to generated egg -// structures from the tree, and prepares the tree for -// generating new egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the references to generated egg structures from the tree, + * and prepares the tree for generating new egg structures. + */ void MayaNodeTree:: -clear_egg(EggData *egg_data, EggGroupNode *egg_root, +clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node, EggGroupNode *morph_node) { _root->clear_egg(); BlendDescs::iterator bi; @@ -337,13 +297,10 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, _morph_node = morph_node; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_egg_group -// Access: Public -// Description: Returns the EggGroupNode corresponding to the group -// or joint for the indicated node. Creates the group -// node if it has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggGroupNode corresponding to the group or joint for the + * indicated node. Creates the group node if it has not already been created. + */ EggGroup *MayaNodeTree:: get_egg_group(MayaNodeDesc *node_desc) { nassertr(_egg_root != (EggGroupNode *)NULL, NULL); @@ -408,37 +365,35 @@ get_egg_group(MayaNodeDesc *node_desc) { } } - // Is the node flagged to be invisible? If it is, it is tagged - // with the "hidden" visibility flag, so it won't get converted - // in the normal case (unless it represents a collision solid or - // something). + // Is the node flagged to be invisible? If it is, it is tagged with the + // "hidden" visibility flag, so it won't get converted in the normal + // case (unless it represents a collision solid or something). bool visible = true; get_bool_attribute(dag_object, "visibility", visible); if (!visible && egg_group->get_num_object_types() == 0) { egg_group->set_visibility_mode(EggGroup::VM_hidden); } - // We treat the object type "billboard" as a special case: we - // apply this one right away and also flag the group as an - // instance. - if (egg_group->has_object_type("billboard")) { + // We treat the object type "billboard" as a special case: we apply this + // one right away and also flag the group as an instance. + if (egg_group->has_object_type("billboard")) { egg_group->remove_object_type("billboard"); egg_group->set_group_type(EggGroup::GT_instance); egg_group->set_billboard_type(EggGroup::BT_axis); - + } else if (egg_group->has_object_type("billboard-point")) { egg_group->remove_object_type("billboard-point"); egg_group->set_group_type(EggGroup::GT_instance); egg_group->set_billboard_type(EggGroup::BT_point_camera_relative); - + } else if (egg_group->has_object_type("bbpoint")) { egg_group->remove_object_type("bbpoint"); egg_group->set_group_type(EggGroup::GT_instance); egg_group->set_billboard_type(EggGroup::BT_point_camera_relative); } - - // We also treat the object type "dcs" and "model" as a special - // case, so we can test for these flags later. + + // We also treat the object type "dcs" and "model" as a special case, so + // we can test for these flags later. if (egg_group->has_object_type("dcs")) { egg_group->remove_object_type("dcs"); egg_group->set_dcs_type(EggGroup::DC_default); @@ -447,9 +402,9 @@ get_egg_group(MayaNodeDesc *node_desc) { egg_group->remove_object_type("model"); egg_group->set_model_flag(true); } - - // And "vertex-color" and "double-sided" have meaning only to - // this converter. + + // And "vertex-color" and "double-sided" have meaning only to this + // converter. MayaEggGroupUserData *user_data; if (parent_user_data == (MayaEggGroupUserData *)NULL) { user_data = new MayaEggGroupUserData; @@ -482,13 +437,10 @@ get_egg_group(MayaNodeDesc *node_desc) { return node_desc->_egg_group; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_egg_table -// Access: Public -// Description: Returns the EggTable corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTable corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggTable *MayaNodeTree:: get_egg_table(MayaNodeDesc *node_desc) { nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); @@ -519,26 +471,20 @@ get_egg_table(MayaNodeDesc *node_desc) { return node_desc->_egg_table; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_egg_anim -// Access: Public -// Description: Returns the anim table corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anim table corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggXfmSAnim *MayaNodeTree:: get_egg_anim(MayaNodeDesc *node_desc) { get_egg_table(node_desc); return node_desc->_anim; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_egg_slider -// Access: Public -// Description: Returns the anim table corresponding to the slider -// for the indicated blend. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anim table corresponding to the slider for the indicated blend. + * Creates the table node if it has not already been created. + */ EggSAnimData *MayaNodeTree:: get_egg_slider(MayaBlendDesc *blend_desc) { nassertr(_morph_node != (EggGroupNode *)NULL, NULL); @@ -555,23 +501,19 @@ get_egg_slider(MayaBlendDesc *blend_desc) { return blend_desc->_anim; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::ignore_slider -// Access: Public -// Description: Returns true if the indicated name is on the list of -// sliders to ignore, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is on the list of sliders to ignore, + * false otherwise. + */ bool MayaNodeTree:: ignore_slider(const string &name) const { return _converter->ignore_slider(name); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::report_ignored_slider -// Access: Public -// Description: Outputs a message to the user reporting that a slider -// was ignored. Each slider is only reported once. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a message to the user reporting that a slider was ignored. Each + * slider is only reported once. + */ void MayaNodeTree:: report_ignored_slider(const string &name) { if (_ignored_slider_names.insert(name).second) { @@ -580,20 +522,16 @@ report_ignored_slider(const string &name) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::add_blend_desc -// Access: Public -// Description: Adds the indicated MayaBlendDesc object to the list -// of blends collected so far. If a MayaBlendDesc -// object with the same name is already part of the -// tree, the supplied object is discarded and the -// previously-added object is returned; otherwise, the -// supplied object is added to the tree and the same -// object is returned. -// -// In either case, the return value is the MayaBlendDesc -// that should be used henceforth. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated MayaBlendDesc object to the list of blends collected so + * far. If a MayaBlendDesc object with the same name is already part of the + * tree, the supplied object is discarded and the previously-added object is + * returned; otherwise, the supplied object is added to the tree and the same + * object is returned. + * + * In either case, the return value is the MayaBlendDesc that should be used + * henceforth. + */ MayaBlendDesc *MayaNodeTree:: add_blend_desc(MayaBlendDesc *blend_desc) { BlendDescs::iterator bi = _blend_descs.insert(blend_desc).first; @@ -601,36 +539,27 @@ add_blend_desc(MayaBlendDesc *blend_desc) { return (*bi); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_num_blend_descs -// Access: Public -// Description: Returns the number of unique MayaBlendDesc objects -// (and hence the number of morph sliders) discovered in -// the tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of unique MayaBlendDesc objects (and hence the number of + * morph sliders) discovered in the tree. + */ int MayaNodeTree:: get_num_blend_descs() const { return _blend_descs.size(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::get_blend_desc -// Access: Public -// Description: Returns the nth MayaBlendDesc object discovered in -// the tree. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth MayaBlendDesc object discovered in the tree. + */ MayaBlendDesc *MayaNodeTree:: get_blend_desc(int n) const { nassertr(n >= 0 && n < (int)_blend_descs.size(), NULL); return _blend_descs[n]; } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::reset_sliders -// Access: Public -// Description: Resets all of the sliders associated with all blend -// shapes down to 0. -//////////////////////////////////////////////////////////////////// +/** + * Resets all of the sliders associated with all blend shapes down to 0. + */ void MayaNodeTree:: reset_sliders() { BlendDescs::iterator bi; @@ -640,39 +569,36 @@ reset_sliders() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaNodeTree::r_build_node -// Access: Private -// Description: The recursive implementation of build_node(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_node(). + */ MayaNodeDesc *MayaNodeTree:: r_build_node(const string &path) { - // If we have already encountered this pathname, return the - // corresponding MayaNodeDesc immediately. + // If we have already encountered this pathname, return the corresponding + // MayaNodeDesc immediately. NodesByPath::const_iterator ni = _nodes_by_path.find(path); if (ni != _nodes_by_path.end()) { return (*ni).second; } - // Otherwise, we have to create it. Do this recursively, so we - // create each node along the path. + // Otherwise, we have to create it. Do this recursively, so we create each + // node along the path. MayaNodeDesc *node_desc = NULL; - //mayaegg_cat.info() << "path: " << path << endl; + // mayaegg_cat.info() << "path: " << path << endl; if (path.empty()) { - // This is the top. - //mayaegg_cat.info() << "found empty path: " << path << endl; + // This is the top. mayaegg_cat.info() << "found empty path: " << path << + // endl; node_desc = _root; } else { - // Maya uses vertical bars to separate path components. Remove - // everything from the rightmost bar on; this will give us the - // parent's path name. + // Maya uses vertical bars to separate path components. Remove everything + // from the rightmost bar on; this will give us the parent's path name. size_t bar = path.rfind("|"); string parent_path, local_name; if (bar != string::npos) { parent_path = path.substr(0, bar); - //mayaegg_cat.info() << "parent_path: " << parent_path << endl; + // mayaegg_cat.info() << "parent_path: " << parent_path << endl; local_name = path.substr(bar + 1); if (local_name == _subroot_parent_name) { node_desc = _root; @@ -680,7 +606,7 @@ r_build_node(const string &path) { } else { local_name = path; } - //mayaegg_cat.info() << "local_name: " << local_name << endl; + // mayaegg_cat.info() << "local_name: " << local_name << endl; if (node_desc != _root) { MayaNodeDesc *parent_node_desc = r_build_node(parent_path); diff --git a/pandatool/src/mayaegg/mayaNodeTree.h b/pandatool/src/mayaegg/mayaNodeTree.h index 30f5e3cbfe..febb794f23 100644 --- a/pandatool/src/mayaegg/mayaNodeTree.h +++ b/pandatool/src/mayaegg/mayaNodeTree.h @@ -1,16 +1,15 @@ -// Filename: mayaNodeTree.h -// Created by: drose (06Jun03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaNodeTree.h + * @author drose + * @date 2003-06-06 + */ #ifndef MAYANODETREE_H #define MAYANODETREE_H @@ -32,11 +31,9 @@ class EggTable; class EggXfmSAnim; class EggSAnimData; -//////////////////////////////////////////////////////////////////// -// Class : MayaNodeTree -// Description : Describes a complete tree of maya nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Describes a complete tree of maya nodes for conversion. + */ class MayaNodeTree { public: MayaNodeTree(MayaToEggConverter *converter); @@ -44,7 +41,7 @@ public: bool build_hierarchy(); void tag_joint_all(); - // bool tag_joint_selected(); + // bool tag_joint_selected(); bool tag_joint_named(const GlobPattern &glob); void tag_all(); @@ -56,7 +53,7 @@ public: MayaNodeDesc *get_node(int n) const; void clear(); - void clear_egg(EggData *egg_data, EggGroupNode *egg_root, + void clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node, EggGroupNode *morph_node); EggGroup *get_egg_group(MayaNodeDesc *node_desc); EggTable *get_egg_table(MayaNodeDesc *node_desc); diff --git a/pandatool/src/mayaegg/mayaToEggConverter.cxx b/pandatool/src/mayaegg/mayaToEggConverter.cxx index 5b837140a1..d661af583b 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.cxx +++ b/pandatool/src/mayaegg/mayaToEggConverter.cxx @@ -1,19 +1,18 @@ -// Filename: mayaToEggConverter.cxx -// Created by: drose (10Nov99) -// Modified 19Mar10 by ETC PandaSE team -// Added set_vertex_color_modern to fix Phong shader bug; also see -// header comment for mayaToEgg.cxx for more details -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEggConverter.cxx + * @author drose + * @date 1999-11-10 + * Modified 19Mar10 by ETC PandaSE team + * Added set_vertex_color_modern to fix Phong shader bug; also see + * header comment for mayaToEgg.cxx for more details + */ #include "mayaToEggConverter.h" #include "mayaShader.h" @@ -78,11 +77,9 @@ #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggConverter:: MayaToEggConverter(const string &program_name) : _program_name(program_name), @@ -106,11 +103,9 @@ MayaToEggConverter(const string &program_name) : _transform_type = TT_model; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggConverter:: MayaToEggConverter(const MayaToEggConverter ©) : _program_name(copy._program_name), @@ -135,71 +130,54 @@ MayaToEggConverter(const MayaToEggConverter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggConverter:: ~MayaToEggConverter() { close_api(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *MayaToEggConverter:: make_copy() { return new MayaToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string MayaToEggConverter:: get_name() const { return "Maya"; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string MayaToEggConverter:: get_extension() const { return "mb"; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_additional_extensions -// Access: Public, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this converter. + */ string MayaToEggConverter:: get_additional_extensions() const { return "ma"; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -// -// This is designed to be as generic as possible, -// generally in support of run-time loading. -// Also see convert_maya(). -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + * + * This is designed to be as generic as possible, generally in support of run- + * time loading. Also see convert_maya(). + */ bool MayaToEggConverter:: convert_file(const Filename &filename) { if (!open_api()) { @@ -207,11 +185,10 @@ convert_file(const Filename &filename) { << "Maya is not available.\n"; return false; } - - // We must ensure our Maya pointers are cleared before we reset the - // Maya scene, because resetting the Maya scene will invalidate all - // the Maya pointers we are holding and cause a crash if we try to - // free them later. + + // We must ensure our Maya pointers are cleared before we reset the Maya + // scene, because resetting the Maya scene will invalidate all the Maya + // pointers we are holding and cause a crash if we try to free them later. clear(); if (!_maya->read(filename)) { @@ -227,112 +204,87 @@ convert_file(const Filename &filename) { return convert_maya(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear_subroots -// Access: Public -// Description: Empties the list of subroot nodes added via -// add_subroot(). The entire file will once again be -// converted. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of subroot nodes added via add_subroot(). The entire file + * will once again be converted. + */ void MayaToEggConverter:: clear_subroots() { _subroots.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::add_subroot -// Access: Public -// Description: Adds a name pattern to the list of subroot nodes. If -// the list of subroot nodes is not empty, then only a -// subroot of the nodes in the maya file will be -// converted: those whose names match one of the -// patterns given on this list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a name pattern to the list of subroot nodes. If the list of subroot + * nodes is not empty, then only a subroot of the nodes in the maya file will + * be converted: those whose names match one of the patterns given on this + * list. + */ void MayaToEggConverter:: add_subroot(const GlobPattern &glob) { _subroots.push_back(glob); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear_subsets -// Access: Public -// Description: Empties the list of subset nodes added via -// add_subset(). The entire file will once again be -// converted. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of subset nodes added via add_subset(). The entire file + * will once again be converted. + */ void MayaToEggConverter:: clear_subsets() { _subsets.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::add_subset -// Access: Public -// Description: Adds a name pattern to the list of subset nodes. If -// the list of subset nodes is not empty, then only a -// subset of the nodes in the maya file will be -// converted: those whose names match one of the -// patterns given on this list. -//////////////////////////////////////////////////////////////////// +/** + * Adds a name pattern to the list of subset nodes. If the list of subset + * nodes is not empty, then only a subset of the nodes in the maya file will + * be converted: those whose names match one of the patterns given on this + * list. + */ void MayaToEggConverter:: add_subset(const GlobPattern &glob) { _subsets.push_back(glob); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear_excludes -// Access: Public -// Description: Empties the list of excluded nodes added via -// add_exclude(). -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of excluded nodes added via add_exclude(). + */ void MayaToEggConverter:: clear_excludes() { _excludes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::add_exclude -// Access: Public -// Description: Adds a name pattern to the list of excluded nodes. -//////////////////////////////////////////////////////////////////// +/** + * Adds a name pattern to the list of excluded nodes. + */ void MayaToEggConverter:: add_exclude(const GlobPattern &glob) { _excludes.push_back(glob); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear_ignore_sliders -// Access: Public -// Description: Empties the list of ignore_sliders added via -// add_ignore_slider(). No sliders will be ignored. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of ignore_sliders added via add_ignore_slider(). No + * sliders will be ignored. + */ void MayaToEggConverter:: clear_ignore_sliders() { _ignore_sliders.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::add_ignore_slider -// Access: Public -// Description: Adds a name pattern to the list of ignore_sliders. -// Any slider (blend shape deformer) that matches a name -// on the list will not be converted or otherwise -// molested by the converter. This is occasionally -// necessary to filter out automatically-created sliders -// that are not intended to be used directly, but -// instead have an indirect effect on other sliders. -//////////////////////////////////////////////////////////////////// +/** + * Adds a name pattern to the list of ignore_sliders. Any slider (blend shape + * deformer) that matches a name on the list will not be converted or + * otherwise molested by the converter. This is occasionally necessary to + * filter out automatically-created sliders that are not intended to be used + * directly, but instead have an indirect effect on other sliders. + */ void MayaToEggConverter:: add_ignore_slider(const GlobPattern &glob) { _ignore_sliders.push_back(glob); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::ignore_slider -// Access: Public -// Description: Returns true if the indicated name is on the list of -// sliders to ignore, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is on the list of sliders to ignore, + * false otherwise. + */ bool MayaToEggConverter:: ignore_slider(const string &name) const { Globs::const_iterator gi; @@ -345,40 +297,33 @@ ignore_slider(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear_force_joints -// Access: Public -// Description: Empties the list of force_joints added via -// add_force_joint(). No joints will be forced. -//////////////////////////////////////////////////////////////////// +/** + * Empties the list of force_joints added via add_force_joint(). No joints + * will be forced. + */ void MayaToEggConverter:: clear_force_joints() { _force_joints.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::add_force_joint -// Access: Public -// Description: Adds a name pattern to the list of force_joints. -// -// Any DAG node that matches a name on the list will be -// treated as if it were a joint during the conversion -// process; it will receive animation and position -// information. Normally, a true Maya joint, as well as -// any DAG nodes whose transforms are animated, will -// automatically be flagged as a Panda joint. -//////////////////////////////////////////////////////////////////// +/** + * Adds a name pattern to the list of force_joints. + * + * Any DAG node that matches a name on the list will be treated as if it were + * a joint during the conversion process; it will receive animation and + * position information. Normally, a true Maya joint, as well as any DAG + * nodes whose transforms are animated, will automatically be flagged as a + * Panda joint. + */ void MayaToEggConverter:: add_force_joint(const GlobPattern &glob) { _force_joints.push_back(glob); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::force_joint -// Access: Public -// Description: Returns true if the indicated name is on the list of -// DAG nodes to treat as a joint, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated name is on the list of DAG nodes to treat as + * a joint, false otherwise. + */ bool MayaToEggConverter:: force_joint(const string &name) const { Globs::const_iterator gi; @@ -391,41 +336,32 @@ force_joint(const string &name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::set_from_selection -// Access: Public -// Description: Sets the flag that indicates whether the currently -// selected Maya geometry will be converted. If this is -// true, and the selection is nonempty, then only the -// selected geometry will be converted. If this is -// false, the entire file will be converted. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether the currently selected Maya geometry + * will be converted. If this is true, and the selection is nonempty, then + * only the selected geometry will be converted. If this is false, the entire + * file will be converted. + */ void MayaToEggConverter:: set_from_selection(bool from_selection) { _from_selection = from_selection; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_input_units -// Access: Public, Virtual -// Description: This may be called after convert_file() has been -// called and returned true, indicating a successful -// conversion. It will return the distance units -// represented by the converted egg file, if known, or -// DU_invalid if not known. -//////////////////////////////////////////////////////////////////// +/** + * This may be called after convert_file() has been called and returned true, + * indicating a successful conversion. It will return the distance units + * represented by the converted egg file, if known, or DU_invalid if not + * known. + */ DistanceUnit MayaToEggConverter:: get_input_units() { return _maya->get_units(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_maya -// Access: Public -// Description: Fills up the egg_data structure according to the -// global maya model data. Returns true if successful, -// false if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the egg_data structure according to the global maya model data. + * Returns true if successful, false if there is an error. + */ bool MayaToEggConverter:: convert_maya() { clear(); @@ -455,7 +391,8 @@ convert_maya() { end_frame = get_end_frame(); } else { end_frame = MAnimControl::maxTime().value(); - //end_frame = MAnimControl::animationEndTime().value(); //masad: we could use this + // end_frame = MAnimControl::animationEndTime().value(); masad: we could + // use this } if (has_frame_inc()) { frame_inc = get_frame_inc(); @@ -532,24 +469,23 @@ convert_maya() { << "frame " << start_frame << "\n"; MGlobal::viewFrame(MTime(start_frame, MTime::uiUnit())); // fall through - + case AC_none: // none: just get out a static model, no animation. mayaegg_cat.info() << "ac_none" << endl; all_ok = convert_hierarchy(get_egg_data()); break; - + case AC_flip: case AC_strobe: - // flip or strobe: get out a series of static models, one per - // frame, under a sequence node for AC_flip. + // flip or strobe: get out a series of static models, one per frame, + // under a sequence node for AC_flip. all_ok = convert_flip(start_frame, end_frame, frame_inc, output_frame_rate); break; case AC_model: - // model: get out an animatable model with joints and vertex - // membership. + // model: get out an animatable model with joints and vertex membership. all_ok = convert_char_model(); break; @@ -558,7 +494,7 @@ convert_maya() { all_ok = convert_char_chan(start_frame, end_frame, frame_inc, output_frame_rate); break; - + case AC_both: // both: Put a model and its animation into the same egg file. _animation_convert = AC_model; @@ -594,46 +530,36 @@ convert_maya() { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::open_api -// Access: Public -// Description: Attempts to open the Maya API if it was not already -// open, and returns true if successful, or false if -// there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the Maya API if it was not already open, and returns true + * if successful, or false if there is an error. + */ bool MayaToEggConverter:: open_api(bool revert_directory) { if (_maya == (MayaApi *)NULL || !_maya->is_valid()) { - //maya to egg converter only needs a read license. - //only egg2maya need write lisences. + // maya to egg converter only needs a read license. only egg2maya need + // write lisences. _maya = MayaApi::open_api(_program_name, true, revert_directory); } return _maya->is_valid(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::close_api -// Access: Public -// Description: Closes the Maya API, if it was previously opened. -// Caution! Maya appears to call exit() when its API is -// closed. -//////////////////////////////////////////////////////////////////// +/** + * Closes the Maya API, if it was previously opened. Caution! Maya appears + * to call exit() when its API is closed. + */ void MayaToEggConverter:: close_api() { - // We have to clear the shaders, at least, before we release the - // Maya API. + // We have to clear the shaders, at least, before we release the Maya API. clear(); _maya.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::clear -// Access: Public -// Description: Frees all of the Maya pointers kept within this -// object, in preparation for loading a new scene or -// releasing the Maya API. -//////////////////////////////////////////////////////////////////// +/** + * Frees all of the Maya pointers kept within this object, in preparation for + * loading a new scene or releasing the Maya API. + */ void MayaToEggConverter:: clear() { _tree.clear(); @@ -641,17 +567,13 @@ clear() { _shaders.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_flip -// Access: Private -// Description: Converts the animation as a series of models that -// cycle (flip) from one to the next at the appropriate -// frame rate. This is the most likely to convert -// precisely (since we ask Maya to tell us the vertex -// position each time) but it is the most wasteful in -// terms of memory utilization (since a complete of the -// model is stored for each frame). -//////////////////////////////////////////////////////////////////// +/** + * Converts the animation as a series of models that cycle (flip) from one to + * the next at the appropriate frame rate. This is the most likely to convert + * precisely (since we ask Maya to tell us the vertex position each time) but + * it is the most wasteful in terms of memory utilization (since a complete of + * the model is stored for each frame). + */ bool MayaToEggConverter:: convert_flip(double start_frame, double end_frame, double frame_inc, double output_frame_rate) { @@ -659,7 +581,7 @@ convert_flip(double start_frame, double end_frame, double frame_inc, EggGroup *sequence_node = new EggGroup(_character_name); get_egg_data()->add_child(sequence_node); - if (_animation_convert == AC_flip) { + if (_animation_convert == AC_flip) { sequence_node->set_switch_flag(true); sequence_node->set_switch_fps(output_frame_rate); } @@ -685,12 +607,10 @@ convert_flip(double start_frame, double end_frame, double frame_inc, return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_char_model -// Access: Private -// Description: Converts the file as an animatable character -// model, with joints and vertex membership. -//////////////////////////////////////////////////////////////////// +/** + * Converts the file as an animatable character model, with joints and vertex + * membership. + */ bool MayaToEggConverter:: convert_char_model() { if (has_neutral_frame()) { @@ -700,9 +620,9 @@ convert_char_model() { MGlobal::viewFrame(frame); } - // It's also important for us to reset all the blend shape sliders - // to 0 before we get out the model. Otherwise, the model we - // convert will have the current positions of the sliders baked in. + // It's also important for us to reset all the blend shape sliders to 0 + // before we get out the model. Otherwise, the model we convert will have + // the current positions of the sliders baked in. _tree.reset_sliders(); EggGroup *char_node = new EggGroup(_character_name); @@ -712,17 +632,14 @@ convert_char_model() { return convert_hierarchy(char_node); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_char_chan -// Access: Private -// Description: Converts the animation as a series of tables to apply -// to the character model, as retrieved earlier via -// AC_model. -//////////////////////////////////////////////////////////////////// +/** + * Converts the animation as a series of tables to apply to the character + * model, as retrieved earlier via AC_model. + */ bool MayaToEggConverter:: convert_char_chan(double start_frame, double end_frame, double frame_inc, double output_frame_rate) { - // MStatus status; + // MStatus status; EggTable *root_table_node = new EggTable(); get_egg_data()->add_child(root_table_node); @@ -734,17 +651,15 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, EggTable *morph_node = new EggTable("morph"); bundle_node->add_child(morph_node); - // Set the frame rate before we start asking for anim tables to be - // created. + // Set the frame rate before we start asking for anim tables to be created. _tree._fps = output_frame_rate; _tree.clear_egg(get_egg_data(), NULL, skeleton_node, morph_node); - // Now we can get the animation data by walking through all of the - // frames, one at a time, and getting the joint angles at each - // frame. + // Now we can get the animation data by walking through all of the frames, + // one at a time, and getting the joint angles at each frame. - // This is just a temporary EggGroup to receive the transform for - // each joint each frame. + // This is just a temporary EggGroup to receive the transform for each joint + // each frame. PT(EggGroup) tgroup = new EggGroup; int num_nodes = _tree.get_num_nodes(); @@ -758,8 +673,8 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, mayaegg_cat.spam(false) << "frame " << frame.value() << "\n"; } else { - // We have to write to cerr instead of mayaegg_cat to allow - // flushing without writing a newline. + // We have to write to cerr instead of mayaegg_cat to allow flushing + // without writing a newline. cerr << "." << flush; } MGlobal::viewFrame(frame); @@ -794,9 +709,9 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, frame += frame_inc; } - // Now optimize all of the tables we just filled up, for no real - // good reason, except that it makes the resulting egg file a little - // easier to read. + // Now optimize all of the tables we just filled up, for no real good + // reason, except that it makes the resulting egg file a little easier to + // read. for (i = 0; i < num_nodes; i++) { MayaNodeDesc *node_desc = _tree.get_node(i); if (node_desc->is_joint()) { @@ -809,19 +724,16 @@ convert_char_chan(double start_frame, double end_frame, double frame_inc, EggSAnimData *anim = _tree.get_egg_slider(blend_desc); anim->optimize(); } - + mayaegg_cat.info(false) << "\n"; return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::convert_hierarchy -// Access: Private -// Description: Generates egg structures for each node in the Maya -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Generates egg structures for each node in the Maya hierarchy. + */ bool MayaToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { int num_nodes = _tree.get_num_nodes(); @@ -856,14 +768,11 @@ convert_hierarchy(EggGroupNode *egg_root) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::process_model_node -// Access: Private -// Description: Converts the indicated Maya node (given a MDagPath, -// similar in concept to Panda's NodePath) to the -// corresponding Egg structure. Returns true if -// successful, false if an error was encountered. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya node (given a MDagPath, similar in concept to + * Panda's NodePath) to the corresponding Egg structure. Returns true if + * successful, false if an error was encountered. + */ bool MayaToEggConverter:: process_model_node(MayaNodeDesc *node_desc) { if (!node_desc->has_dag_path()) { @@ -922,11 +831,11 @@ process_model_node(MayaNodeDesc *node_desc) { status.perror("MFnCamera constructor"); return false; } - + // Extract some interesting Camera data if (mayaegg_cat.is_spam()) { MPoint eyePoint = camera.eyePoint(MSpace::kWorld); - mayaegg_cat.spam() << " eyePoint: " << eyePoint.x << " " + mayaegg_cat.spam() << " eyePoint: " << eyePoint.x << " " << eyePoint.y << " " << eyePoint.z << endl; mayaegg_cat.spam() << " upDirection: " << camera.upDirection(MSpace::kWorld) << endl; @@ -947,14 +856,14 @@ process_model_node(MayaNodeDesc *node_desc) { } if (node_desc->is_tagged()) { - // Presumably, the camera's position has some meaning to the - // end-user, so we will implicitly tag it with the DCS flag so it - // won't get flattened out. + // Presumably, the camera's position has some meaning to the end-user, + // so we will implicitly tag it with the DCS flag so it won't get + // flattened out. if (_animation_convert != AC_model) { - // For now, don't set the DCS flag on cameras within - // character models, since egg-optchar doesn't understand - // this. Perhaps there's no reason to ever change this, since - // cameras within character models may not be meaningful. + // For now, don't set the DCS flag on cameras within character + // models, since egg-optchar doesn't understand this. Perhaps + // there's no reason to ever change this, since cameras within + // character models may not be meaningful. egg_group->set_dcs_type(EggGroup::DC_net); } get_transform(node_desc, dag_path, egg_group); @@ -983,14 +892,14 @@ process_model_node(MayaNodeDesc *node_desc) { } if (node_desc->is_tagged()) { - // Presumably, the lighht's position has some meaning to the - // end-user, so we will implicitly tag it with the DCS flag so it - // won't get flattened out. + // Presumably, the lighht's position has some meaning to the end-user, + // so we will implicitly tag it with the DCS flag so it won't get + // flattened out. if (_animation_convert != AC_model) { - // For now, don't set the DCS flag on lights within - // character models, since egg-optchar doesn't understand - // this. Perhaps there's no reason to ever change this, since - // lights within character models may not be meaningful. + // For now, don't set the DCS flag on lights within character + // models, since egg-optchar doesn't understand this. Perhaps + // there's no reason to ever change this, since lights within + // character models may not be meaningful. egg_group->set_dcs_type(EggGroup::DC_net); } get_transform(node_desc, dag_path, egg_group); @@ -1003,7 +912,7 @@ process_model_node(MayaNodeDesc *node_desc) { } } } - + MFnLight light (dag_path, &status); if ( !status ) { status.perror("MFnLight constructor"); @@ -1014,12 +923,12 @@ process_model_node(MayaNodeDesc *node_desc) { mayaegg_cat.info() << "\"" << dag_path.partialPathName() << "\" : \n"; - // Get the translation/rotation/scale data + // Get the translationrotationscale data MObject transformNode = dag_path.transform(&status); // This node has no transform - i.e., it's the world node if (!status && status.statusCode () == MStatus::kInvalidParameter) return false; - MFnDagNode transform (transformNode, &status); + MFnDagNode transform (transformNode, &status); if (!status) { status.perror("MFnDagNode constructor"); return false; @@ -1036,12 +945,13 @@ process_model_node(MayaNodeDesc *node_desc) { if (tl.z < 0.0001) { tl.z = 0; } - // We swap Y and Z in the next few bits cuz Panda is Z-up by default and Maya is Y-up + // We swap Y and Z in the next few bits cuz Panda is Z-up by default and + // Maya is Y-up mayaegg_cat.info() << " \"translation\" : (" << tl.x << ", " << tl.z << ", " << tl.y << ")" << endl; double threeDoubles[3]; - MTransformationMatrix::RotationOrder rOrder; - + MTransformationMatrix::RotationOrder rOrder; + matrix.getRotation (threeDoubles, rOrder, MSpace::kWorld); mayaegg_cat.info() << " \"rotation\": (" << threeDoubles[0] << ", " @@ -1080,8 +990,8 @@ process_model_node(MayaNodeDesc *node_desc) { } } else if (dag_path.hasFn(MFn::kNurbsCurve)) { // Only convert NurbsCurves if we aren't making an animated model. - // Animated models, as a general rule, don't want these sorts of - // things in them. + // Animated models, as a general rule, don't want these sorts of things in + // them. if (_animation_convert != AC_model) { EggGroup *egg_group = _tree.get_egg_group(node_desc); get_transform(node_desc, dag_path, egg_group); @@ -1097,7 +1007,7 @@ process_model_node(MayaNodeDesc *node_desc) { } } } - + } else if (dag_path.hasFn(MFn::kMesh)) { if (node_desc->is_tagged()) { EggGroup *egg_group = _tree.get_egg_group(node_desc); @@ -1140,14 +1050,14 @@ process_model_node(MayaNodeDesc *node_desc) { } if (node_desc->is_tagged()) { - // Presumably, the locator's position has some meaning to the - // end-user, so we will implicitly tag it with the DCS flag so it - // won't get flattened out. + // Presumably, the locator's position has some meaning to the end-user, + // so we will implicitly tag it with the DCS flag so it won't get + // flattened out. if (_animation_convert != AC_model) { - // For now, don't set the DCS flag on locators within - // character models, since egg-optchar doesn't understand - // this. Perhaps there's no reason to ever change this, since - // locators within character models may not be meaningful. + // For now, don't set the DCS flag on locators within character + // models, since egg-optchar doesn't understand this. Perhaps there's + // no reason to ever change this, since locators within character + // models may not be meaningful. egg_group->set_dcs_type(EggGroup::DC_net); } get_transform(node_desc, dag_path, egg_group); @@ -1168,18 +1078,16 @@ process_model_node(MayaNodeDesc *node_desc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// and applies it to the corresponding Egg node. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, and applies it to the + * corresponding Egg node. + */ void MayaToEggConverter:: -get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, +get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggGroup *egg_group) { if (_animation_convert == AC_model) { - // When we're getting an animated model, we only get transforms - // for joints, and they get converted in a special way. + // When we're getting an animated model, we only get transforms for + // joints, and they get converted in a special way. if (node_desc->is_joint()) { if (mayaegg_cat.is_spam()) { @@ -1203,19 +1111,19 @@ get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, switch (_transform_type) { case TT_all: break; - + case TT_model: if (!egg_group->get_model_flag() && !egg_group->has_dcs_type()) { return; } break; - - case TT_dcs: + + case TT_dcs: if (!egg_group->has_dcs_type()) { return; } break; - + case TT_none: case TT_invalid: return; @@ -1233,9 +1141,9 @@ get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, mat[2][0], mat[2][1], mat[2][2], mat[2][3], mat[3][0], mat[3][1], mat[3][2], mat[3][3]); - // Maya has a rotate pivot, separate from its transform. Usually we - // care more about the rotate pivot than we do about the transform, - // so get the rotate pivot too. + // Maya has a rotate pivot, separate from its transform. Usually we care + // more about the rotate pivot than we do about the transform, so get the + // rotate pivot too. MFnTransform transform(transformNode, &status); if (!status) { status.perror("MFnTransform constructor"); @@ -1246,17 +1154,16 @@ get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, status.perror("Can't get rotate pivot"); return; } - - // We need to convert the pivot to world coordinates. (Maya can - // only tell it to us in local coordinates.) + + // We need to convert the pivot to world coordinates. (Maya can only tell + // it to us in local coordinates.) LPoint3d p3d(pivot[0], pivot[1], pivot[2]); p3d = p3d * m4d; // Now recenter the matrix about the pivot point. m4d.set_row(3, p3d); - // Convert the recentered matrix into the group's space and store - // it. + // Convert the recentered matrix into the group's space and store it. m4d = m4d * egg_group->get_node_frame_inv(); if (!m4d.almost_equal(LMatrix4d::ident_mat(), 0.0001)) { egg_group->add_matrix4(m4d); @@ -1264,16 +1171,13 @@ get_transform(MayaNodeDesc *node_desc, const MDagPath &dag_path, return; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_joint_transform -// Access: Private -// Description: Extracts the transform on the indicated Maya node, -// as appropriate for a joint in an animated character, -// and applies it to the indicated node. This is -// different from get_transform() in that it does not -// respect the _transform_type flag, and it does not -// consider the relative transforms within the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Maya node, as appropriate for a + * joint in an animated character, and applies it to the indicated node. This + * is different from get_transform() in that it does not respect the + * _transform_type flag, and it does not consider the relative transforms + * within the egg file. + */ void MayaToEggConverter:: get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group) { // First, make sure there's not a transform on the group already. @@ -1337,13 +1241,10 @@ get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_nurbs_surface -// Access: Private -// Description: Converts the indicated Maya NURBS surface to a -// corresponding egg structure, and attaches it to the -// indicated egg group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya NURBS surface to a corresponding egg structure, + * and attaches it to the indicated egg group. + */ void MayaToEggConverter:: make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, MFnNurbsSurface &surface, EggGroup *egg_group) { @@ -1373,15 +1274,14 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, MayaShader *shader = _shaders.find_shader_for_node(surface.object(), _legacy_shader); if (_polygon_output) { - // If we want polygon output only, tesselate the NURBS and output - // that. + // If we want polygon output only, tesselate the NURBS and output that. MTesselationParams params; params.setFormatType(MTesselationParams::kStandardFitFormat); params.setOutputType(MTesselationParams::kQuads); params.setStdFractionalTolerance(_polygon_tolerance); - // We'll create the tesselation as a sibling of the NURBS surface. - // That way we inherit all of the transformations. + // We'll create the tesselation as a sibling of the NURBS surface. That + // way we inherit all of the transformations. MDagPath polyset_path = dag_path; MObject polyset_parent = polyset_path.node(); MObject polyset = @@ -1424,8 +1324,8 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, return; } - // Also get out all the alternate blend shapes for the surface by - // applying each morph slider one at a time. + // Also get out all the alternate blend shapes for the surface by applying + // each morph slider one at a time. pvector morph_cvs; if (_animation_convert == AC_model) { int num_sliders = node_desc->get_num_blend_descs(); @@ -1433,8 +1333,8 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, for (int i = 0; i < num_sliders; i++) { MayaBlendDesc *blend_desc = node_desc->get_blend_desc(i); - // Temporarily push the slider up to 1.0 so we can see what the - // surface looks like at that value. + // Temporarily push the slider up to 1.0 so we can see what the surface + // looks like at that value. blend_desc->set_slider(1.0); MPointArray cv_array; status = surface.getCVs(cv_array, MSpace::kWorld); @@ -1469,8 +1369,8 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, int u_cvs = surface.numCVsInU(); int v_cvs = surface.numCVsInV(); - // Maya repeats CVS at the end for a periodic surface, and doesn't - // count them in the joint weight array, below. + // Maya repeats CVS at the end for a periodic surface, and doesn't count + // them in the joint weight array, below. int maya_u_cvs = (u_form == MFnNurbsSurface::kPeriodic) ? u_cvs - u_degree : u_cvs; int maya_v_cvs = (v_form == MFnNurbsSurface::kPeriodic) ? v_cvs - v_degree : v_cvs; @@ -1521,8 +1421,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, // Now generate the morph targets for the vertex. if (!morph_cvs.empty()) { - // Morph deltas are given in 3-d space, not in 4-d homogenous - // space. + // Morph deltas are given in 3-d space, not in 4-d homogenous space. LPoint3d p3d(v[0] / v[3], v[1] / v[3], v[2] / v[3]); for (unsigned int si = 0; si < morph_cvs.size(); si++) { @@ -1558,18 +1457,18 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, for (unsigned li = 0; li < num_loops; li++) { egg_trim.push_back(EggNurbsSurface::Loop()); EggNurbsSurface::Loop &egg_loop = egg_trim.back(); - + MFnNurbsSurface::BoundaryType type = surface.boundaryType(ti, li, &status); bool keep_loop = false; - + if (!status) { status.perror("MFnNurbsSurface::BoundaryType"); } else { keep_loop = (type == MFnNurbsSurface::kInner || type == MFnNurbsSurface::kOuter); } - + if (keep_loop) { unsigned num_edges = surface.numEdges(ti, li); for (unsigned ei = 0; ei < num_edges; ei++) { @@ -1606,8 +1505,8 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, } } - // We add the NURBS to the group down here, after all of the vpools - // for the trim curves have been added. + // We add the NURBS to the group down here, after all of the vpools for the + // trim curves have been added. egg_group->add_child(egg_nurbs); if (shader != (MayaShader *)NULL) { @@ -1620,7 +1519,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, pvector joints; MFloatArray weights; if (_animation_convert == AC_model) { - got_weights = + got_weights = get_vertex_weights(dag_path, surface, joints, weights); } @@ -1628,8 +1527,7 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, int num_joints = joints.size(); int num_weights = (int)weights.length(); int num_verts = num_weights / num_joints; - // The number of weights should be an even multiple of verts * - // joints. + // The number of weights should be an even multiple of verts * joints. nassertv(num_weights == num_verts * num_joints); for (i = 0; i < egg_nurbs->get_num_cvs(); i++) { @@ -1653,13 +1551,10 @@ make_nurbs_surface(MayaNodeDesc *node_desc, const MDagPath &dag_path, } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_trim_curve -// Access: Private -// Description: Converts the indicated Maya NURBS trim curve to a -// corresponding egg structure, and returns it, or NULL -// if there is a problem. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya NURBS trim curve to a corresponding egg + * structure, and returns it, or NULL if there is a problem. + */ EggNurbsCurve *MayaToEggConverter:: make_trim_curve(const MFnNurbsCurve &curve, const string &nurbs_name, EggGroupNode *egg_group, int trim_curve_index) { @@ -1737,13 +1632,11 @@ make_trim_curve(const MFnNurbsCurve &curve, const string &nurbs_name, return egg_curve; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_nurbs_curve -// Access: Private -// Description: Converts the indicated Maya NURBS curve (a standalone -// curve, not a trim curve) to a corresponding egg -// structure and attaches it to the indicated egg group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya NURBS curve (a standalone curve, not a trim + * curve) to a corresponding egg structure and attaches it to the indicated + * egg group. + */ void MayaToEggConverter:: make_nurbs_curve(const MDagPath &, const MFnNurbsCurve &curve, EggGroup *egg_group) { @@ -1825,30 +1718,24 @@ make_nurbs_curve(const MDagPath &, const MFnNurbsCurve &curve, } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::round uvs -// Access: Private -// Description: given uvsets, round them up or down -//////////////////////////////////////////////////////////////////// +/** + * given uvsets, round them up or down + */ int MayaToEggConverter:: round(double value) { if (value < 0) return -(floor(-value + 0.5)); - // or as an alternate use: - // return ceil ( value - 0.5); + // or as an alternate use: return ceil ( value - 0.5); else return floor( value + 0.5); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_polyset -// Access: Private -// Description: Converts the indicated Maya polyset to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Maya polyset to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void MayaToEggConverter:: -make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, +make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, const MFnMesh &mesh, EggGroup *egg_group, MayaShader *default_shader) { MStatus status; @@ -1881,17 +1768,16 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggVertexPool *vpool = new EggVertexPool(vpool_name); egg_group->add_child(vpool); - // One way to convert the mesh would be to first get out all the - // vertices in the mesh and add them into the vpool, then when we - // traverse the polygons we would only have to index them into the - // vpool according to their Maya vertex index. + // One way to convert the mesh would be to first get out all the vertices in + // the mesh and add them into the vpool, then when we traverse the polygons + // we would only have to index them into the vpool according to their Maya + // vertex index. - // Unfortunately, since Maya may store multiple normals and/or - // colors for each vertex according to which polygon it is in, that - // approach won't necessarily work. In egg, those split-property - // vertices have to become separate vertices. So instead of adding - // all the vertices up front, we'll start with an empty vpool, and - // add vertices to it on the fly. + // Unfortunately, since Maya may store multiple normals andor colors for + // each vertex according to which polygon it is in, that approach won't + // necessarily work. In egg, those split-property vertices have to become + // separate vertices. So instead of adding all the vertices up front, we'll + // start with an empty vpool, and add vertices to it on the fly. MObject component_obj; MItMeshPolygon pi(dag_path, component_obj, &status); @@ -1909,19 +1795,18 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, status.perror("MFnMesh::getConnectedShaders"); } - // We will need to transform all vertices from world coordinate - // space into the vertex space appropriate to this node. Usually, - // this is the same thing as world coordinate space, and this matrix - // will be identity; but if the node is under an instance - // (particularly, for instance, a billboard) then the vertex space - // will be different from world space. + // We will need to transform all vertices from world coordinate space into + // the vertex space appropriate to this node. Usually, this is the same + // thing as world coordinate space, and this matrix will be identity; but if + // the node is under an instance (particularly, for instance, a billboard) + // then the vertex space will be different from world space. LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv(); // Save these modeling flags for the check below. bool egg_vertex_color = false; bool egg_double_sided = false; if (egg_group->has_user_data(MayaEggGroupUserData::get_class_type())) { - MayaEggGroupUserData *user_data = + MayaEggGroupUserData *user_data = DCAST(MayaEggGroupUserData, egg_group->get_user_data()); egg_vertex_color = user_data->_vertex_color; egg_double_sided = user_data->_double_sided; @@ -1929,8 +1814,8 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, bool double_sided = maya_double_sided; if (!_respect_maya_double_sided) { - // If this flag is false, we respect the maya double-sided - // settings only if the egg "double-sided" flag is also set. + // If this flag is false, we respect the maya double-sided settings only + // if the egg "double-sided" flag is also set. if (!egg_double_sided) { double_sided = false; } @@ -1942,16 +1827,17 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } _shaders.bind_uvsets(mesh.object()); - + while (!pi.isDone()) { EggPolygon *egg_poly = new EggPolygon; egg_group->add_child(egg_poly); egg_poly->set_bface_flag(double_sided); - // Determine the MayaShader for this particular polygon. - // There appears to be two diverging paths for any Maya node with a Material (MayaShader) on it - // This next bit kicks us out into mayaShader et al. to pull textures and everything else. + // Determine the MayaShader for this particular polygon. There appears to + // be two diverging paths for any Maya node with a Material (MayaShader) + // on it This next bit kicks us out into mayaShader et al. to pull + // textures and everything else. MayaShader *shader = NULL; int index = pi.index(); nassertv(index >= 0 && index < (int)poly_shader_indices.length()); @@ -1962,8 +1848,9 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, MObject engine = shaders[shader_index]; shader = _shaders.find_shader_for_shading_engine(engine, _legacy_shader); //head out to the other classes - //does this mean if we didn't find a Maya shader give it a default value anyway? - } else if (default_shader != (MayaShader *)NULL) { + // does this mean if we didn't find a Maya shader give it a default + // value anyway? + } else if (default_shader != (MayaShader *)NULL) { shader = default_shader; } @@ -1975,18 +1862,17 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, default_color_def = shader->get_color_def(); } - // Should we extract the color from the vertices? Normally, in - // Maya a texture completely replaces the vertex color, so we - // should ignore the vertex color if we have a texture. + // Should we extract the color from the vertices? Normally, in Maya a + // texture completely replaces the vertex color, so we should ignore the + // vertex color if we have a texture. - // However, this is an inconvenient property of Maya; sometimes we - // really do want both vertex color and texture applied to the - // same object. To allow this, we define the special egg flag - // "vertex-color", which when set indicates that we should - // respect the vertex color anyway. + // However, this is an inconvenient property of Maya; sometimes we really + // do want both vertex color and texture applied to the same object. To + // allow this, we define the special egg flag "vertex-color", which when + // set indicates that we should respect the vertex color anyway. - // Furthermore, if _always_show_vertex_color is true, we pretend - // that the "vertex-color" flag is always set. + // Furthermore, if _always_show_vertex_color is true, we pretend that the + // "vertex-color" flag is always set. bool ignore_vertex_color = false; if ( default_color_def != (MayaShaderColorDef *)NULL) { ignore_vertex_color = default_color_def->_has_texture && !(egg_vertex_color || _always_show_vertex_color); @@ -1995,8 +1881,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, LColor poly_color(1.0f, 1.0f, 1.0f, 1.0f); if (!ignore_vertex_color) { // If we're respecting the vertex color, then remove the color - // specification from the polygon (so we can apply it to the - // vertices). + // specification from the polygon (so we can apply it to the vertices). poly_color = egg_poly->get_color(); egg_poly->clear_color(); } @@ -2007,8 +1892,8 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, LPoint3d centroid(0.0, 0.0, 0.0); if (default_color_def != (MayaShaderColorDef *)NULL && default_color_def->has_projection()) { - // If the shader has a projection, we may need to compute the - // polygon's centroid to avoid seams at the edges. + // If the shader has a projection, we may need to compute the polygon's + // centroid to avoid seams at the edges. for (i = 0; i < num_verts; i++) { MPoint p = pi.point(i, MSpace::kWorld); LPoint3d p3d(p[0], p[1], p[2]); @@ -2052,11 +1937,11 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() << "--uvset_name :" << uvset_name << endl; } - - // get the shader color def that matches this EggTexture - // Asad: optimizing uvset: to discard unused uvsets. This for - // loop figures out which ones are unused. - + + // get the shader color def that matches this EggTexture Asad: + // optimizing uvset: to discard unused uvsets. This for loop figures + // out which ones are unused. + bool keep_uv = keep_all_uvsets; bool project_uv = false; LTexCoordd uv_projection; @@ -2085,10 +1970,10 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } continue; } - + if (project_uv) { - // If the shader has a projection, use it instead of the - // polygon's built-in UV's. + // If the shader has a projection, use it instead of the polygon's + // built-in UV's. vert.set_uv(panda_uvset_name, uv_projection); } else { // Get the UV's from the polygon. @@ -2101,7 +1986,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } else { if (_round_uvs) { if (uvs[0] > 1.0 || uvs[0] < -1.0) { - // apply upto 1/1000th precision, but round up + // apply upto 11000th precision, but round up uvs[0] = (long)(uvs[0]*1000); mayaegg_cat.debug() << "before rounding uvs[0]: " << uvs[0] << endl; uvs[0] = (double)(round((double)uvs[0]/10.0)*10.0)/1000.0; @@ -2119,7 +2004,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } } } - + if (!ignore_vertex_color) { if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() << "poly_color = " << poly_color << endl; @@ -2148,10 +2033,9 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, egg_poly->set_normal(face_normal); } - // Now, check that the vertex ordering is consistent with the - // direction of the normals. If not, reverse the vertex ordering - // (since we have seen cases where Maya sets this in contradiction - // to its normals). + // Now, check that the vertex ordering is consistent with the direction of + // the normals. If not, reverse the vertex ordering (since we have seen + // cases where Maya sets this in contradiction to its normals). LNormald order_normal; if (got_face_normal && egg_poly->calculate_normal(order_normal)) { if (order_normal.dot(face_normal) < 0.0) { @@ -2162,22 +2046,22 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } } } - + pi.next(); } if (mayaegg_cat.is_spam()) { mayaegg_cat.spam() << "done traversing polys" << endl; } - // Now that we've added all the polygons (and created all the - // vertices), go back through the vertex pool and set up the - // appropriate joint membership for each of the vertices. + // Now that we've added all the polygons (and created all the vertices), go + // back through the vertex pool and set up the appropriate joint membership + // for each of the vertices. bool got_weights = false; pvector joints; MFloatArray weights; if (_animation_convert == AC_model) { - got_weights = + got_weights = get_vertex_weights(dag_path, mesh, joints, weights); } @@ -2185,8 +2069,7 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, int num_joints = joints.size(); int num_weights = (int)weights.length(); int num_verts = num_weights / num_joints; - // The number of weights should be an even multiple of verts * - // joints. + // The number of weights should be an even multiple of verts * joints. nassertv(num_weights == num_verts * num_joints); EggVertexPool::iterator vi; @@ -2208,12 +2091,11 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } - // We also need to compute the vertex morphs for the polyset, based - // on whatever blend shapes may be present. This is similar to the - // code in make_nurbs_surface(), except that since we don't have a - // one-to-one relationship of egg vertices to Maya vertices, we have - // to get the morphs down here, after we have added all of the egg - // vertices. + // We also need to compute the vertex morphs for the polyset, based on + // whatever blend shapes may be present. This is similar to the code in + // make_nurbs_surface(), except that since we don't have a one-to-one + // relationship of egg vertices to Maya vertices, we have to get the morphs + // down here, after we have added all of the egg vertices. if (_animation_convert == AC_model) { int num_orig_mesh_verts = mesh.numVertices(); @@ -2222,12 +2104,12 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, for (int i = 0; i < num_sliders; i++) { MayaBlendDesc *blend_desc = node_desc->get_blend_desc(i); - // Temporarily push the slider up to 1.0 so we can see what the - // surface looks like at that value. + // Temporarily push the slider up to 1.0 so we can see what the surface + // looks like at that value. blend_desc->set_slider(1.0); - // We have to get the mesh object from the dag again after - // fiddling with the slider. + // We have to get the mesh object from the dag again after fiddling with + // the slider. MFnMesh blend_mesh(dag_path, &status); if (!status) { mayaegg_cat.warning() @@ -2237,11 +2119,11 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } else { if (blend_mesh.numVertices() != num_orig_mesh_verts) { mayaegg_cat.warning() - << "Ignoring " << blend_desc->get_name() << " for " + << "Ignoring " << blend_desc->get_name() << " for " << name << "; blend shape has " << blend_mesh.numVertices() - << " vertices while original shape has " + << " vertices while original shape has " << num_orig_mesh_verts << ".\n"; - + } else { MPointArray verts; status = blend_mesh.getPoints(verts, MSpace::kWorld); @@ -2254,11 +2136,11 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggVertex *vert = (*vi); int maya_vi = vert->get_external_index(); nassertv(maya_vi >= 0 && maya_vi < num_verts); - + const MPoint &m = verts[maya_vi]; LPoint3d m3d(m[0] / m[3], m[1] / m[3], m[2] / m[3]); m3d = m3d * vertex_frame_inv; - + LVector3d delta = m3d - vert->get_pos3(); if (!delta.almost_equal(LVector3d::zero())) { EggMorphVertex dxyz(blend_desc->get_name(), delta); @@ -2278,11 +2160,11 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, EggVertex *vert = (*vi); int maya_vi = vert->get_external_index2(); nassertv(maya_vi >= 0 && maya_vi < num_norms); - + const MFloatVector &m = norms[maya_vi]; LVector3d m3d(m[0], m[1], m[2]); m3d = m3d * vertex_frame_inv; - + LNormald delta = m3d - vert->get_normal(); if (!delta.almost_equal(LVector3d::zero())) { EggMorphNormal dnormal(blend_desc->get_name(), delta); @@ -2298,16 +2180,12 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_locator -// Access: Private -// Description: Locators are used in Maya to indicate a particular -// position in space to the user or the modeler. We -// represent that in egg with an ordinary Group node, -// which we transform by the locator's position, so that -// the indicated point becomes the origin at this node -// and below. -//////////////////////////////////////////////////////////////////// +/** + * Locators are used in Maya to indicate a particular position in space to the + * user or the modeler. We represent that in egg with an ordinary Group node, + * which we transform by the locator's position, so that the indicated point + * becomes the origin at this node and below. + */ void MayaToEggConverter:: make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, EggGroup *egg_group) { @@ -2323,7 +2201,7 @@ make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, if (!found_locator) { mayaegg_cat.error() - << "Couldn't find locator within locator node " + << "Couldn't find locator within locator node " << dag_path.fullPathName().asChar() << "\n"; return; } @@ -2331,13 +2209,13 @@ make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, LPoint3d p3d; if (!get_vec3d_attribute(locator, "localPosition", p3d)) { mayaegg_cat.error() - << "Couldn't get position of locator " + << "Couldn't get position of locator " << dag_path.fullPathName().asChar() << "\n"; return; } - // We need to convert the position to world coordinates. For some - // reason, Maya can only tell it to us in local coordinates. + // We need to convert the position to world coordinates. For some reason, + // Maya can only tell it to us in local coordinates. MMatrix mat = dag_path.inclusiveMatrix(&status); if (!status) { status.perror("Can't get coordinate space for locator"); @@ -2355,16 +2233,12 @@ make_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, egg_group->add_translate3d(p3d); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_camera_locator -// Access: Private -// Description: Locators are used in Maya to indicate a particular -// position in space to the user or the modeler. We -// represent that in egg with an ordinary Group node, -// which we transform by the locator's position, so that -// the indicated point becomes the origin at this node -// and below. -//////////////////////////////////////////////////////////////////// +/** + * Locators are used in Maya to indicate a particular position in space to the + * user or the modeler. We represent that in egg with an ordinary Group node, + * which we transform by the locator's position, so that the indicated point + * becomes the origin at this node and below. + */ void MayaToEggConverter:: make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, EggGroup *egg_group) { @@ -2380,7 +2254,7 @@ make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, if (!found_camera) { mayaegg_cat.error() - << "Couldn't find camera" + << "Couldn't find camera" << dag_path.fullPathName().asChar() << "\n"; return; } @@ -2399,16 +2273,12 @@ make_camera_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::make_light_locator -// Access: Private -// Description: Locators are used in Maya to indicate a particular -// position in space to the user or the modeler. We -// represent that in egg with an ordinary Group node, -// which we transform by the locator's position, so that -// the indicated point becomes the origin at this node -// and below. -//////////////////////////////////////////////////////////////////// +/** + * Locators are used in Maya to indicate a particular position in space to the + * user or the modeler. We represent that in egg with an ordinary Group node, + * which we transform by the locator's position, so that the indicated point + * becomes the origin at this node and below. + */ void MayaToEggConverter:: make_light_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, EggGroup *egg_group) { @@ -2428,15 +2298,15 @@ make_light_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, if (!found_alight && !found_dlight && !found_plight) { mayaegg_cat.error() - << "Couldn't find light within locator node " + << "Couldn't find light within locator node " << dag_path.fullPathName().asChar() << "\n"; return; } LPoint3d p3d; - // We need to convert the position to world coordinates. For some - // reason, Maya can only tell it to us in local coordinates. + // We need to convert the position to world coordinates. For some reason, + // Maya can only tell it to us in local coordinates. MMatrix mat = dag_path.inclusiveMatrix(&status); if (!status) { status.perror("Can't get coordinate space for light"); @@ -2455,55 +2325,48 @@ make_light_locator(const MDagPath &dag_path, const MFnDagNode &dag_node, } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_vertex_weights -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool MayaToEggConverter:: get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh, pvector &joints, MFloatArray &weights) { MStatus status; - - // Since we are working with a mesh the input attribute that - // creates the mesh is named "inMesh" - // - MObject attr = mesh.attribute("inMesh"); - - // Create the plug to the "inMesh" attribute then use the - // DG iterator to walk through the DG, at the node level. - // - MPlug history(mesh.object(), attr); - MItDependencyGraph it(history, MFn::kDependencyNode, - MItDependencyGraph::kUpstream, - MItDependencyGraph::kDepthFirst, + + // Since we are working with a mesh the input attribute that creates the + // mesh is named "inMesh" + MObject attr = mesh.attribute("inMesh"); + + // Create the plug to the "inMesh" attribute then use the DG iterator to + // walk through the DG, at the node level. + MPlug history(mesh.object(), attr); + MItDependencyGraph it(history, MFn::kDependencyNode, + MItDependencyGraph::kUpstream, + MItDependencyGraph::kDepthFirst, MItDependencyGraph::kNodeLevel); while (!it.isDone()) { - // We will walk along the node level of the DG until we - // spot a skinCluster node. - // - MObject c_node = it.thisNode(); - if (c_node.hasFn(MFn::kSkinClusterFilter)) { - // We've found the cluster handle. Try to get the weight - // data. - // - MFnSkinCluster cluster(c_node, &status); + // We will walk along the node level of the DG until we spot a skinCluster + // node. + MObject c_node = it.thisNode(); + if (c_node.hasFn(MFn::kSkinClusterFilter)) { + // We've found the cluster handle. Try to get the weight data. + MFnSkinCluster cluster(c_node, &status); if (!status) { status.perror("MFnSkinCluster constructor"); return false; } - // Get the set of objects that influence the vertices of this - // mesh. Hopefully these will all be joints. + // Get the set of objects that influence the vertices of this mesh. + // Hopefully these will all be joints. MDagPathArray influence_objects; - cluster.influenceObjects(influence_objects, &status); + cluster.influenceObjects(influence_objects, &status); if (!status) { status.perror("MFnSkinCluster::influenceObjects"); } else { - // Fill up the vector with the corresponding table of egg - // groups for each joint. + // Fill up the vector with the corresponding table of egg groups for + // each joint. joints.clear(); for (unsigned oi = 0; oi < influence_objects.length(); oi++) { MDagPath joint_dag_path = influence_objects[oi]; @@ -2512,36 +2375,35 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh, joints.push_back(joint); } - // Now use a component object to retrieve all of the weight - // data in one API call. - MFnSingleIndexedComponent sic; - MObject sic_object = sic.create(MFn::kMeshVertComponent); - sic.setCompleteData(mesh.numVertices()); - unsigned influence_count; + // Now use a component object to retrieve all of the weight data in + // one API call. + MFnSingleIndexedComponent sic; + MObject sic_object = sic.create(MFn::kMeshVertComponent); + sic.setCompleteData(mesh.numVertices()); + unsigned influence_count; - status = cluster.getWeights(dag_path, sic_object, - weights, influence_count); + status = cluster.getWeights(dag_path, sic_object, + weights, influence_count); if (!status) { status.perror("MFnSkinCluster::getWeights"); } else { if (influence_count != influence_objects.length()) { mayaegg_cat.error() - << "MFnSkinCluster::influenceObjects() returns " + << "MFnSkinCluster::influenceObjects() returns " << influence_objects.length() << " objects, but MFnSkinCluster::getWeights() reports " << influence_count << " objects.\n"; - + } else { - // We've got the weights and the set of objects. That's all - // we need. + // We've got the weights and the set of objects. That's all we + // need. return true; } } } } else if (c_node.hasFn(MFn::kWeightGeometryFilt)) { - // We've found the joint cluster handle. (rigid Binding) - // - MFnWeightGeometryFilter cluster(c_node, &status); + // We've found the joint cluster handle. (rigid Binding) + MFnWeightGeometryFilter cluster(c_node, &status); if (!status) { status.perror("MFnWeightGeometryFilter constructor"); return false; @@ -2568,15 +2430,15 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh, MayaNodeDesc *joint_node_desc = _tree.build_node(joint_dag_path); EggGroup *joint = _tree.get_egg_group(joint_node_desc); joints.push_back(joint); - - // Now use a component object to retrieve all of the weight - // data in one API call. - MFnSingleIndexedComponent sic; - MObject sic_object = sic.create(MFn::kMeshVertComponent); - sic.setCompleteData(mesh.numVertices()); - - status = cluster.getWeights(dag_path, sic_object, - weights); + + // Now use a component object to retrieve all of the weight data + // in one API call. + MFnSingleIndexedComponent sic; + MObject sic_object = sic.create(MFn::kMeshVertComponent); + sic.setCompleteData(mesh.numVertices()); + + status = cluster.getWeights(dag_path, sic_object, + weights); if (!status) { status.perror("MFnWeightGeometryFilter::getWeights"); } else { @@ -2587,7 +2449,7 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh, } } } - } + } } it.next(); @@ -2597,56 +2459,48 @@ get_vertex_weights(const MDagPath &dag_path, const MFnMesh &mesh, return false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::get_vertex_weights -// Access: Private -// Description: As above, for a NURBS surface instead of a polygon -// mesh. -//////////////////////////////////////////////////////////////////// +/** + * As above, for a NURBS surface instead of a polygon mesh. + */ bool MayaToEggConverter:: get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface, pvector &joints, MFloatArray &weights) { MStatus status; - - // Since we are working with a NURBS surface the input attribute that - // creates the surface is named "create" - // - MObject attr = surface.attribute("create"); - - // Create the plug to the "create" attribute then use the - // DG iterator to walk through the DG, at the node level. - // - MPlug history(surface.object(), attr); - MItDependencyGraph it(history, MFn::kDependencyNode, - MItDependencyGraph::kUpstream, - MItDependencyGraph::kDepthFirst, + + // Since we are working with a NURBS surface the input attribute that + // creates the surface is named "create" + MObject attr = surface.attribute("create"); + + // Create the plug to the "create" attribute then use the DG iterator to + // walk through the DG, at the node level. + MPlug history(surface.object(), attr); + MItDependencyGraph it(history, MFn::kDependencyNode, + MItDependencyGraph::kUpstream, + MItDependencyGraph::kDepthFirst, MItDependencyGraph::kNodeLevel); while (!it.isDone()) { - // We will walk along the node level of the DG until we - // spot a skinCluster node. - // - MObject c_node = it.thisNode(); - if (c_node.hasFn(MFn::kSkinClusterFilter)) { - // We've found the cluster handle. Try to get the weight - // data. - // - MFnSkinCluster cluster(c_node, &status); + // We will walk along the node level of the DG until we spot a skinCluster + // node. + MObject c_node = it.thisNode(); + if (c_node.hasFn(MFn::kSkinClusterFilter)) { + // We've found the cluster handle. Try to get the weight data. + MFnSkinCluster cluster(c_node, &status); if (!status) { status.perror("MFnSkinCluster constructor"); return false; } - // Get the set of objects that influence the vertices of this - // surface. Hopefully these will all be joints. + // Get the set of objects that influence the vertices of this surface. + // Hopefully these will all be joints. MDagPathArray influence_objects; - cluster.influenceObjects(influence_objects, &status); + cluster.influenceObjects(influence_objects, &status); if (!status) { status.perror("MFnSkinCluster::influenceObjects"); } else { - // Fill up the vector with the corresponding table of egg - // groups for each joint. + // Fill up the vector with the corresponding table of egg groups for + // each joint. joints.clear(); for (unsigned oi = 0; oi < influence_objects.length(); oi++) { MDagPath joint_dag_path = influence_objects[oi]; @@ -2655,28 +2509,28 @@ get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface, joints.push_back(joint); } - // Now use a component object to retrieve all of the weight - // data in one API call. - MFnDoubleIndexedComponent dic; - MObject dic_object = dic.create(MFn::kSurfaceCVComponent); - dic.setCompleteData(surface.numCVsInU(), surface.numCVsInV()); - unsigned influence_count; + // Now use a component object to retrieve all of the weight data in + // one API call. + MFnDoubleIndexedComponent dic; + MObject dic_object = dic.create(MFn::kSurfaceCVComponent); + dic.setCompleteData(surface.numCVsInU(), surface.numCVsInV()); + unsigned influence_count; - status = cluster.getWeights(dag_path, dic_object, - weights, influence_count); + status = cluster.getWeights(dag_path, dic_object, + weights, influence_count); if (!status) { status.perror("MFnSkinCluster::getWeights"); } else { if (influence_count != influence_objects.length()) { mayaegg_cat.error() - << "MFnSkinCluster::influenceObjects() returns " + << "MFnSkinCluster::influenceObjects() returns " << influence_objects.length() << " objects, but MFnSkinCluster::getWeights() reports " << influence_count << " objects.\n"; - + } else { - // We've got the weights and the set of objects. That's all - // we need. + // We've got the weights and the set of objects. That's all we + // need. return true; } } @@ -2690,15 +2544,12 @@ get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface, return false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::set_shader_attributes -// Access: Private -// Description: Applies the known shader attributes to the indicated -// egg primitive. Note: For multi-textures, Maya lists -// the top most texture in slot 0. But Panda puts the -// base texture at slot 0. Hence I parse the list of -// textures from last to first. -//////////////////////////////////////////////////////////////////// +/** + * Applies the known shader attributes to the indicated egg primitive. Note: + * For multi-textures, Maya lists the top most texture in slot 0. But Panda + * puts the base texture at slot 0. Hence I parse the list of textures from + * last to first. + */ void MayaToEggConverter:: set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader, bool mesh) { @@ -2709,28 +2560,26 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader, } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::set_shader_modern -// Access: Private -// Description: The modern implementation of set_shader_attributes. -// -// In the modern codepath, the MayaShader is a direct, -// literal representation of a list of EggTextures. -// All this exporter has to do is translate the list -// without interpretation. All the complex interpretation -// is handled elsewhere, in the MayaShader module. -//////////////////////////////////////////////////////////////////// +/** + * The modern implementation of set_shader_attributes. + * + * In the modern codepath, the MayaShader is a direct, literal representation + * of a list of EggTextures. All this exporter has to do is translate the + * list without interpretation. All the complex interpretation is handled + * elsewhere, in the MayaShader module. + */ void MayaToEggConverter:: set_shader_modern(EggPrimitive &primitive, const MayaShader &shader, bool mesh) { - + for (size_t idx=0; idx < shader._all_maps.size(); idx++) { MayaShaderColorDef *def = shader._all_maps[idx]; if ((def->_is_alpha)&&(def->_opposite != 0)) { - // This texture represents an alpha-filename. It doesn't get its own + // This texture represents an alpha-filename. It doesn't get its own + // continue; } - + EggTexture tex(shader.get_name(), ""); tex.set_format(def->_is_alpha ? EggTexture::F_alpha : EggTexture::F_rgb); apply_texture_filename(tex, *def); @@ -2740,42 +2589,37 @@ set_shader_modern(EggPrimitive &primitive, const MayaShader &shader, apply_texture_uvprops(tex, *def); apply_texture_blendtype(tex, *def); tex.set_uv_name(def->get_panda_uvset_name()); - + EggTexture *new_tex = _textures.create_unique_texture(tex, ~0); primitive.add_texture(new_tex); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggConverter::set_shader_legacy -// Access: Private -// Description: The legacy implementation of set_shader_attributes. -// The old behavior of the exporter is just plain weird. -// It seems to be a result of an inexperienced coder -// who made some core mistakes, and then patched them -// up with kludges. It seems to produce plausible -// results in certain specific cases, but overall, it -// doesn't make any sense. Unfortunately, this weird -// behavior cannot be discarded - vast numbers of 3D -// models have been created that rely on this behavior. -// The solution is to compartmentalize the weirdness. -// The legacy codepath, when activated, implements the -// old weird behavior. A brand-new codepath that -// shares almost nothing with the legacy codepath -// implements a much more straightforward behavior. -//////////////////////////////////////////////////////////////////// +/** + * The legacy implementation of set_shader_attributes. The old behavior of + * the exporter is just plain weird. It seems to be a result of an + * inexperienced coder who made some core mistakes, and then patched them up + * with kludges. It seems to produce plausible results in certain specific + * cases, but overall, it doesn't make any sense. Unfortunately, this weird + * behavior cannot be discarded - vast numbers of 3D models have been created + * that rely on this behavior. The solution is to compartmentalize the + * weirdness. The legacy codepath, when activated, implements the old weird + * behavior. A brand-new codepath that shares almost nothing with the legacy + * codepath implements a much more straightforward behavior. + */ void MayaToEggConverter:: set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, bool mesh) { - - // determine if the base texture or any of the top texture need to be rgb only + + // determine if the base texture or any of the top texture need to be rgb + // only MayaShaderColorDef *color_def = NULL; bool is_rgb = false; bool is_decal = false; bool is_interpolate = false; int i; - // last shader is the base so lets skip it + // last shader is the base so lets skip it for (i=0; i<(int)shader._color.size()-1; ++i) { color_def = shader.get_color_def(i); if (color_def->_has_texture) { @@ -2783,8 +2627,8 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, is_interpolate = true; } else if ((EggTexture::EnvType)color_def->_blend_type == EggTexture::ET_modulate) { - // Maya's multiply is slightly different than panda's. Unless, _keep_alpha is set, - // we are dropping the alpha. + // Maya's multiply is slightly different than panda's. Unless, + // _keep_alpha is set, we are dropping the alpha. if (!color_def->_keep_alpha) is_rgb = true; // modulate forces the alpha to be ignored } @@ -2794,16 +2638,17 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } } - // we don't want an extra light stage for interpolate mode, it takes care of automatically + // we don't want an extra light stage for interpolate mode, it takes care of + // automatically if (is_interpolate) is_decal = false; - + // new decal mode needs an extra dummy layers of textureStage EggTexture *dummy_tex = (EggTexture *)NULL; string dummy_uvset_name; - // In Maya, a polygon is either textured or colored. The texture, - // if present, replaces the color. Also now there could be multiple textures + // In Maya, a polygon is either textured or colored. The texture, if + // present, replaces the color. Also now there could be multiple textures const MayaShaderColorDef &trans_def = shader._transparency; for (i=shader._color.size()-1; i>=0; --i) { color_def = shader.get_color_def(i); @@ -2823,19 +2668,18 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } if (color_def->_has_texture) { - // If we have a texture on color, apply it as the filename. - //if (mayaegg_cat.is_debug()) { - //mayaegg_cat.debug() << "ssa:got texture name" << color_def->_texture_filename << endl; - //} + // If we have a texture on color, apply it as the filename. if + // (mayaegg_cat.is_debug()) { mayaegg_cat.debug() << "ssa:got texture + // name" << color_def->_texture_filename << endl; } Filename filename = Filename::from_os_specific(color_def->_texture_filename); Filename fullpath, outpath; _path_replace->full_convert_path(filename, get_model_path(), fullpath, outpath); tex.set_filename(outpath); tex.set_fullpath(fullpath); apply_texture_uvprops(tex, *color_def); - - // If we also have a texture on transparency, apply it as the - // alpha filename. + + // If we also have a texture on transparency, apply it as the alpha + // filename. if (trans_def._has_texture) { if (color_def->_wrap_u != trans_def._wrap_u || color_def->_wrap_u != trans_def._wrap_u) { @@ -2843,7 +2687,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, << "Shader " << shader.get_name() << " has contradictory wrap modes on color and texture.\n"; } - + if (!compare_texture_uvprops(tex, trans_def)) { // Only report each broken shader once. static pset bad_shaders; @@ -2853,25 +2697,25 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, << shader.get_name() << "\n"; } } - //tex.set_format(EggTexture::F_rgba); - - // We should try to be smarter about whether the transparency - // value is connected to the texture's alpha channel or to its - // grayscale channel. However, I'm not sure how to detect - // this at the moment; rather than spending days trying to - // figure out, for now I'll just assume that if the same - // texture image is used for both color and transparency, then - // the artist meant to use the alpha channel for transparency. + // tex.set_format(EggTexture::F_rgba); + + // We should try to be smarter about whether the transparency value + // is connected to the texture's alpha channel or to its grayscale + // channel. However, I'm not sure how to detect this at the moment; + // rather than spending days trying to figure out, for now I'll just + // assume that if the same texture image is used for both color and + // transparency, then the artist meant to use the alpha channel for + // transparency. if (trans_def._texture_filename == color_def->_texture_filename) { - // That means that we don't need to do anything special: use - // all the channels of the texture. - + // That means that we don't need to do anything special: use all + // the channels of the texture. + } else { - // Otherwise, pull the alpha channel from the other image - // file. Ideally, we should figure out which channel from - // the other image supplies alpha (and specify this via - // set_alpha_file_channel()), but for now we assume it comes - // from the grayscale data. + // Otherwise, pull the alpha channel from the other image file. + // Ideally, we should figure out which channel from the other + // image supplies alpha (and specify this via + // set_alpha_file_channel()), but for now we assume it comes from + // the grayscale data. filename = Filename::from_os_specific(trans_def._texture_filename); _path_replace->full_convert_path(filename, get_model_path(), fullpath, outpath); @@ -2879,21 +2723,22 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, tex.set_alpha_fullpath(fullpath); } } else { - // If there is no transparency texture specified, we don't - // have any transparency, so tell the egg format to ignore any - // alpha channel that might be on the color texture. - //tex.set_format(EggTexture::F_rgb); + // If there is no transparency texture specified, we don't have any + // transparency, so tell the egg format to ignore any alpha channel + // that might be on the color texture. + // tex.set_format(EggTexture::F_rgb); } - + if (shader._color.size() > 1) { - // if multi-textured, first texture in maya is on top, so - // last shader on the list is the base one, which should always pick up the alpha - // from the texture file. But the top textures may have to strip the alpha + // if multi-textured, first texture in maya is on top, so last + // shader on the list is the base one, which should always pick up + // the alpha from the texture file. But the top textures may have + // to strip the alpha if (i!=shader._color.size()-1) { if (!i && is_interpolate) { - // this is the grass path mode where alpha on this texture determines - // whether to show layer1 or layer2. Since by now other layers are set - // lets change those to get this effect + // this is the grass path mode where alpha on this texture + // determines whether to show layer1 or layer2. Since by now + // other layers are set lets change those to get this effect tex.set_combine_mode(EggTexture::CC_rgb, EggTexture::CM_interpolate); tex.set_combine_source(EggTexture::CC_rgb, 0, EggTexture::CS_previous); tex.set_combine_operand(EggTexture::CC_rgb, 0, EggTexture::CO_src_color); @@ -2922,16 +2767,17 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, tex.set_env_type((EggTexture::EnvType)color_def->_blend_type); if (tex.get_env_type() == EggTexture::ET_modulate) { if (color_def->_has_alpha_channel) { - // lets caution the artist that they should not be using a alpha channel on - // this texture. + // lets caution the artist that they should not be using a + // alpha channel on this texture. if (mayaegg_cat.is_spam()) { - maya_cat.spam() - << color_def->_texture_name + maya_cat.spam() + << color_def->_texture_name << " should not have alpha channel in multiply mode: ignoring\n"; } } if (is_rgb) { - //tex.set_alpha_mode(EggRenderMode::AM_off); // force alpha off + // tex.set_alpha_mode(EggRenderMode::AM_off); force + // alpha off tex.set_format(EggTexture::F_rgb); // Change the format to be rgb only } } @@ -2944,10 +2790,11 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, tex.set_saved_result(true); } else if (is_decal) { - // decal in classic time, always overwrote the base color. That causes problem - // when the polygon wants to be lit or wants to retain vertex/polygon color - // In the new decal mode, we achieve this with a third dummy layer - // copy this layer to a new dummy layer + // decal in classic time, always overwrote the base color. That + // causes problem when the polygon wants to be lit or wants to + // retain vertexpolygon color In the new decal mode, we achieve + // this with a third dummy layer copy this layer to a new dummy + // layer EggTexture texDummy(shader.get_name()+".dummy", ""); if (mayaegg_cat.is_debug()) { mayaegg_cat.debug() << "creating dummy shader: " << texDummy.get_name() << endl; @@ -2968,8 +2815,8 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } } } else { // trans_def._has_texture - // We have a texture on transparency only. Apply it as the - // primary filename, and set the format accordingly. + // We have a texture on transparency only. Apply it as the primary + // filename, and set the format accordingly. Filename filename = Filename::from_os_specific(trans_def._texture_filename); Filename fullpath,outpath; _path_replace->full_convert_path(filename, get_model_path(), @@ -2979,7 +2826,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, tex.set_format(EggTexture::F_alpha); apply_texture_uvprops(tex, trans_def); } - + if (mayaegg_cat.is_debug()) { mayaegg_cat.debug() << "ssa:tref_name:" << tex.get_name() << endl; } @@ -2989,7 +2836,7 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } EggTexture *new_tex = _textures.create_unique_texture(tex, ~0); - + if (mesh) { if (uvset_name.find("not found") == -1) { primitive.add_texture(new_tex); @@ -3019,8 +2866,8 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, mayaegg_cat.spam() << "ssa:rgba = " << rgba << endl; } - // The existence of a texture on either color channel completely - // replaces the corresponding flat color. + // The existence of a texture on either color channel completely replaces + // the corresponding flat color. if (color_def && color_def->_has_texture) { rgba[0] = 1.0f; rgba[1] = 1.0f; @@ -3048,13 +2895,10 @@ set_shader_legacy(EggPrimitive &primitive, const MayaShader &shader, } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::apply_texture_uvprops -// Access: Private -// Description: Applies all the appropriate texture properties to the -// EggTexture object, including wrap modes and texture -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Applies all the appropriate texture properties to the EggTexture object, + * including wrap modes and texture matrix. + */ void MayaToEggConverter:: apply_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def) { // Let's mipmap all textures by default. @@ -3073,11 +2917,9 @@ apply_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::apply_texture_blendtype -// Access: Private -// Description: Applies the blendtype to the EggTexture. -//////////////////////////////////////////////////////////////////// +/** + * Applies the blendtype to the EggTexture. + */ void MayaToEggConverter:: apply_texture_blendtype(EggTexture &tex, const MayaShaderColorDef &color_def) { switch (color_def._blend_type) { @@ -3129,11 +2971,9 @@ apply_texture_blendtype(EggTexture &tex, const MayaShaderColorDef &color_def) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::apply_texture_filename -// Access: Private -// Description: Applies the filename to the EggTexture. -//////////////////////////////////////////////////////////////////// +/** + * Applies the filename to the EggTexture. + */ void MayaToEggConverter:: apply_texture_filename(EggTexture &tex, const MayaShaderColorDef &def) { Filename filename = Filename::from_os_specific(def._texture_filename); @@ -3143,11 +2983,9 @@ apply_texture_filename(EggTexture &tex, const MayaShaderColorDef &def) { tex.set_fullpath(fullpath); } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::apply_texture_alpha_filename -// Access: Private -// Description: Applies the alpha filename to the EggTexture. -//////////////////////////////////////////////////////////////////// +/** + * Applies the alpha filename to the EggTexture. + */ void MayaToEggConverter:: apply_texture_alpha_filename(EggTexture &tex, const MayaShaderColorDef &def) { if (def._opposite) { @@ -3162,23 +3000,20 @@ apply_texture_alpha_filename(EggTexture &tex, const MayaShaderColorDef &def) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::compare_texture_uvprops -// Access: Private -// Description: Compares the texture properties already on the -// texture (presumably set by a previous call to -// apply_texture_uvprops()) and returns false if they -// differ from that specified by the indicated color_def -// object, or true if they match. -//////////////////////////////////////////////////////////////////// +/** + * Compares the texture properties already on the texture (presumably set by a + * previous call to apply_texture_uvprops()) and returns false if they differ + * from that specified by the indicated color_def object, or true if they + * match. + */ bool MayaToEggConverter:: -compare_texture_uvprops(EggTexture &tex, +compare_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def) { bool okflag = true; EggTexture::WrapMode wrap_u = color_def._wrap_u ? EggTexture::WM_repeat : EggTexture::WM_clamp; EggTexture::WrapMode wrap_v = color_def._wrap_v ? EggTexture::WM_repeat : EggTexture::WM_clamp; - + if (wrap_u != tex.determine_wrap_u()) { // Choose the more general of the two. if (wrap_u == EggTexture::WM_repeat) { @@ -3192,7 +3027,7 @@ compare_texture_uvprops(EggTexture &tex, } okflag = false; } - + LMatrix3d m = color_def.compute_texture_matrix(); LMatrix4d mat4(m(0, 0), m(0, 1), 0.0, m(0, 2), m(1, 0), m(1, 1), 0.0, m(1, 2), @@ -3205,22 +3040,18 @@ compare_texture_uvprops(EggTexture &tex, return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::reparent_decals -// Access: Private -// Description: Recursively walks the egg hierarchy, reparenting -// "decal" type nodes below their corresponding -// "decalbase" type nodes, and setting the flags. -// -// Returns true on success, false if some nodes were -// incorrect. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg hierarchy, reparenting "decal" type nodes below + * their corresponding "decalbase" type nodes, and setting the flags. + * + * Returns true on success, false if some nodes were incorrect. + */ bool MayaToEggConverter:: reparent_decals(EggGroupNode *egg_parent) { bool okflag = true; - // First, walk through all children of this node, looking for the - // one decal base, if any. + // First, walk through all children of this node, looking for the one decal + // base, if any. EggGroup *decal_base = (EggGroup *)NULL; pvector decal_children; @@ -3261,10 +3092,10 @@ reparent_decals(EggGroupNode *egg_parent) { << " has decalbase, but no sibling nodes have decal.\n"; } else { - // All the decal children get moved to be a child of decal base. - // This usually will not affect the vertex positions, but it - // could if the decal base has a transform and the decal child - // is an instance node. So don't do that. + // All the decal children get moved to be a child of decal base. This + // usually will not affect the vertex positions, but it could if the + // decal base has a transform and the decal child is an instance node. + // So don't do that. pvector::iterator di; for (di = decal_children.begin(); di != decal_children.end(); ++di) { EggGroup *child_group = (*di); @@ -3290,12 +3121,10 @@ reparent_decals(EggGroupNode *egg_parent) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::string_transform_type -// Access: Public, Static -// Description: Returns the TransformType value corresponding to the -// indicated string, or TT_invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TransformType value corresponding to the indicated string, or + * TT_invalid. + */ MayaToEggConverter::TransformType MayaToEggConverter:: string_transform_type(const string &arg) { if (cmp_nocase(arg, "all") == 0) { @@ -3310,14 +3139,11 @@ string_transform_type(const string &arg) { return TT_invalid; } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::MayaToEggConverter::set_vertex_color -// Access: Private -// Description: Checks to see if we're using legacy or modern -// shaders and based on the result, it passes -// the vertex color calculations off to either -// the legacy or modern vertex color functions. -//////////////////////////////////////////////////////////////////// +/** + * Checks to see if we're using legacy or modern shaders and based on the + * result, it passes the vertex color calculations off to either the legacy or + * modern vertex color functions. + */ void MayaToEggConverter:: set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { if (shader == (MayaShader *)NULL || shader->_legacy_mode) { @@ -3326,15 +3152,12 @@ set_vertex_color(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const Maya set_vertex_color_modern(vert, pi, vert_index, shader, color); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::MayaToEggConverter::set_vertex_color_legacy -// Access: Private -// Description: Calls set_color on an EggVertex, determining the -// correct color values, based on the shader, vert_color -// Maya's vertex & flat color(s). This is the original -// implementation that works only on Lambert shaders/materials -// in Maya. -//////////////////////////////////////////////////////////////////// +/** + * Calls set_color on an EggVertex, determining the correct color values, + * based on the shader, vert_color Maya's vertex & flat color(s). This is the + * original implementation that works only on Lambert shaders/materials in + * Maya. + */ void MayaToEggConverter:: set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color){ if (pi.hasColor()) { @@ -3343,11 +3166,11 @@ set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con if (!status) { status.perror("MItMeshPolygon::getColor"); } else { - // I saw instances where the color components exceeded 1.0 - // so lets clamp the values to 0 to 1 + // I saw instances where the color components exceeded 1.0 so lets clamp + // the values to 0 to 1 c /= 1.0; - // The vertex color is a color scale that modifies the - // polygon color, not an override that replaces it. + // The vertex color is a color scale that modifies the polygon color, + // not an override that replaces it. vert.set_color(LColor(c.r * color[0], c.g * color[1], c.b * color[2], c.a * color[3])); if (mayaegg_cat.is_spam()) { @@ -3360,15 +3183,12 @@ set_vertex_color_legacy(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con } } -//////////////////////////////////////////////////////////////////// -// Function: MayaShader::MayaToEggConverter::set_vertex_color_modern -// Access: Private -// Description: Calls set_color on an EggVertex, determining the -// correct color values, based on the shader, vert_color -// Maya's vertex & flat color(s). This implementation -// is designed to work specifically with Phong materials -// or shaders. -//////////////////////////////////////////////////////////////////// +/** + * Calls set_color on an EggVertex, determining the correct color values, + * based on the shader, vert_color Maya's vertex & flat color(s). This + * implementation is designed to work specifically with Phong materials or + * shaders. + */ void MayaToEggConverter:: set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, const MayaShader *shader, const LColor &color) { // If there's an explicit vertex color, output it. @@ -3380,13 +3200,14 @@ set_vertex_color_modern(EggVertex &vert, MItMeshPolygon &pi, int vert_index, con return; } } - - // If there's no explicit color, use flat color, or white on a textured model. + + // If there's no explicit color, use flat color, or white on a textured + // model. if (shader->_color_maps.empty()) { const LColord &c = shader->_flat_color; vert.set_color(LColor((PN_stdfloat)c[0], (PN_stdfloat)c[1], (PN_stdfloat)c[2], (PN_stdfloat)c[3])); } else { - //there's no explicit color anywhere, must be textured (or blank) + // there's no explicit color anywhere, must be textured (or blank) vert.set_color(LColor(1.0f, 1.0f, 1.0f, 1.0f)); } } diff --git a/pandatool/src/mayaegg/mayaToEggConverter.h b/pandatool/src/mayaegg/mayaToEggConverter.h index e775374b42..6662184bd1 100644 --- a/pandatool/src/mayaegg/mayaToEggConverter.h +++ b/pandatool/src/mayaegg/mayaToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: mayaToEggConverter.h -// Created by: drose (10Nov99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEggConverter.h + * @author drose + * @date 1999-11-10 + */ #ifndef MAYATOEGGCONVERTER_H #define MAYATOEGGCONVERTER_H @@ -52,16 +51,13 @@ class MFnMesh; class MPointArray; class MFloatArray; -//////////////////////////////////////////////////////////////////// -// Class : MayaToEggConverter -// Description : This class supervises the construction of an EggData -// structure from a single Maya file, or from the data -// already in the global Maya model space. -// -// Note that since the Maya API presents just one global -// model space, it is not possible to simultaneously -// load two distinct Maya files. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a + * single Maya file, or from the data already in the global Maya model space. + * + * Note that since the Maya API presents just one global model space, it is + * not possible to simultaneously load two distinct Maya files. + */ class MayaToEggConverter : public SomethingToEggConverter { public: MayaToEggConverter(const string &program_name = ""); @@ -104,11 +100,11 @@ public: void close_api(); private: - bool convert_flip(double start_frame, double end_frame, + bool convert_flip(double start_frame, double end_frame, double frame_inc, double output_frame_rate); bool convert_char_model(); - bool convert_char_chan(double start_frame, double end_frame, + bool convert_char_chan(double start_frame, double end_frame, double frame_inc, double output_frame_rate); bool convert_hierarchy(EggGroupNode *egg_root); bool process_model_node(MayaNodeDesc *node_desc); @@ -118,20 +114,19 @@ private: void get_joint_transform(const MDagPath &dag_path, EggGroup *egg_group); void apply_lod_attributes(EggGroup *egg_group, MFnDagNode &lod_group); - // I ran into core dumps trying to pass around a MFnMesh object by - // value. From now on, all MFn* objects will be passed around by - // reference. - // void make_tex_names(const MFnMesh &mesh, const MObject &mesh_object); + // I ran into core dumps trying to pass around a MFnMesh object by value. + // From now on, all MFn* objects will be passed around by reference. void + // make_tex_names(const MFnMesh &mesh, const MObject &mesh_object); void make_nurbs_surface(MayaNodeDesc *node_desc, - const MDagPath &dag_path, + const MDagPath &dag_path, MFnNurbsSurface &surface, EggGroup *group); EggNurbsCurve *make_trim_curve(const MFnNurbsCurve &curve, const string &nurbs_name, EggGroupNode *egg_group, int trim_curve_index); - void make_nurbs_curve(const MDagPath &dag_path, + void make_nurbs_curve(const MDagPath &dag_path, const MFnNurbsCurve &curve, EggGroup *group); void make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path, @@ -147,15 +142,15 @@ private: pvector &joints, MFloatArray &weights); bool get_vertex_weights(const MDagPath &dag_path, const MFnNurbsSurface &surface, pvector &joints, MFloatArray &weights); - void apply_texture_uvprops(EggTexture &tex, + void apply_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def); - void apply_texture_blendtype(EggTexture &tex, + void apply_texture_blendtype(EggTexture &tex, const MayaShaderColorDef &color_def); - void apply_texture_filename(EggTexture &tex, + void apply_texture_filename(EggTexture &tex, const MayaShaderColorDef &color_def); - void apply_texture_alpha_filename(EggTexture &tex, + void apply_texture_alpha_filename(EggTexture &tex, const MayaShaderColorDef &color_def); - bool compare_texture_uvprops(EggTexture &tex, + bool compare_texture_uvprops(EggTexture &tex, const MayaShaderColorDef &color_def); bool reparent_decals(EggGroupNode *egg_parent); void set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader, @@ -184,7 +179,7 @@ private: Globs _force_joints; MayaNodeTree _tree; - + public: MayaShaders _shaders; EggTextureCollection _textures; diff --git a/pandatool/src/mayaprogs/blend_test.cxx b/pandatool/src/mayaprogs/blend_test.cxx index 0a3c13a1e6..cf7e880731 100644 --- a/pandatool/src/mayaprogs/blend_test.cxx +++ b/pandatool/src/mayaprogs/blend_test.cxx @@ -94,7 +94,7 @@ get_slider(MString slider_name) { cerr << "selected element is not a blend shape\n"; } } - + cerr << "Couldn't find slider " << slider_name << "\n"; exit(1); } @@ -160,7 +160,7 @@ get_mesh(MString mesh_name) { cerr << "selected element is not a mesh\n"; } } - + cerr << "Couldn't find mesh " << mesh_name << "\n"; exit(1); } @@ -170,7 +170,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { MStatus status; MPointArray verts; - // status = mesh.getPoints(verts, MSpace::kObject); + // status = mesh.getPoints(verts, MSpace::kObject); status = mesh.getPoints(verts, MSpace::kWorld); if (!status) { status.perror("mesh.getPoints"); diff --git a/pandatool/src/mayaprogs/config_mayaloader.cxx b/pandatool/src/mayaprogs/config_mayaloader.cxx index d2bfaca7c0..80ccd1f373 100644 --- a/pandatool/src/mayaprogs/config_mayaloader.cxx +++ b/pandatool/src/mayaprogs/config_mayaloader.cxx @@ -1,16 +1,15 @@ -// Filename: config_mayaloader.cxx -// Created by: drose (09Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_mayaloader.cxx + * @author drose + * @date 2003-10-09 + */ #ifdef __MACH__ #define __OPENTRANSPORTPROVIDERS__ @@ -32,14 +31,12 @@ ConfigureFn(config_mayaloader) { init_libmayaloader(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libmayaloader -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libmayaloader() { static bool initialized = false; diff --git a/pandatool/src/mayaprogs/eggToMaya.cxx b/pandatool/src/mayaprogs/eggToMaya.cxx index 4410145745..48ac972aea 100644 --- a/pandatool/src/mayaprogs/eggToMaya.cxx +++ b/pandatool/src/mayaprogs/eggToMaya.cxx @@ -1,16 +1,15 @@ -// Filename: eggToMaya.cxx -// Created by: drose (11Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToMaya.cxx + * @author drose + * @date 2005-08-11 + */ #include "eggToMaya.h" #include "mayaEggLoader.h" @@ -19,8 +18,8 @@ #include "pystub.h" #endif -// We must define this to prevent Maya from doubly-declaring its -// MApiVersion string in this file as well as in libmayaegg. +// We must define this to prevent Maya from doubly-declaring its MApiVersion +// string in this file as well as in libmayaegg. #define _MApiVersion #include "pre_maya_include.h" @@ -28,11 +27,9 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToMaya::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToMaya:: EggToMaya() : EggToSomething("Maya", ".mb", true, false) @@ -66,20 +63,17 @@ EggToMaya() : _output_units = DU_centimeters; } -//////////////////////////////////////////////////////////////////// -// Function: EggToMaya::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToMaya:: run() { if (!_convert_anim && !_convert_model) { _convert_model = true; } - // Let's convert the output file to a full path before we initialize - // Maya, since Maya now has a nasty habit of changing the current - // directory. + // Let's convert the output file to a full path before we initialize Maya, + // since Maya now has a nasty habit of changing the current directory. _output_filename.make_absolute(); nout << "Initializing Maya.\n"; @@ -96,10 +90,9 @@ run() { exit(1); } - // [gjeon] since maya's internal unit is fixed to cm - // and when we can't change UI unit without affecting data - // all distance data is converted to cm - // we need to convert them back to proper output unit user provided here + // [gjeon] since maya's internal unit is fixed to cm and when we can't + // change UI unit without affecting data all distance data is converted to + // cm we need to convert them back to proper output unit user provided here // along with UI unit maya->set_units(_output_units); @@ -118,7 +111,7 @@ run() { status.perror("Could not save file"); exit(1); } - + /* // And write out the resulting Maya file. string os_specific = _output_filename.to_os_generic(); @@ -135,7 +128,8 @@ run() { } int main(int argc, char *argv[]) { - // We don't want pystub on linux, since it gives problems with Maya's python. + // We don't want pystub on linux, since it gives problems with Maya's + // python. #ifdef _WIN32 // A call to pystub() to force libpystub.so to be linked in. pystub(); @@ -146,4 +140,3 @@ int main(int argc, char *argv[]) { prog.run(); return 0; } - diff --git a/pandatool/src/mayaprogs/eggToMaya.h b/pandatool/src/mayaprogs/eggToMaya.h index b76f36bf7f..3a103ffd2e 100644 --- a/pandatool/src/mayaprogs/eggToMaya.h +++ b/pandatool/src/mayaprogs/eggToMaya.h @@ -1,16 +1,15 @@ -// Filename: eggToMaya.h -// Created by: drose (11Aug05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToMaya.h + * @author drose + * @date 2005-08-11 + */ #ifndef EGGTOMAYA_H #define EGGTOMAYA_H @@ -19,10 +18,9 @@ #include "eggToSomething.h" -//////////////////////////////////////////////////////////////////// -// Class : EggToMaya -// Description : A program to read an egg file and write a maya file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read an egg file and write a maya file. + */ class EggToMaya : public EggToSomething { public: EggToMaya(); @@ -36,4 +34,3 @@ private: }; #endif - diff --git a/pandatool/src/mayaprogs/mayaCopy.cxx b/pandatool/src/mayaprogs/mayaCopy.cxx index 5d6520da63..eeb11eda4e 100644 --- a/pandatool/src/mayaprogs/mayaCopy.cxx +++ b/pandatool/src/mayaprogs/mayaCopy.cxx @@ -1,18 +1,17 @@ -// Filename: mayaCopy.cxx -// Created by: drose (10May02) -// Modified 19Mar10 by ETC PandaSE team (see -// header comment for mayaToEgg.cxx for more details) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaCopy.cxx + * @author drose + * @date 2002-05-10 + * Modified 19Mar10 by ETC PandaSE team (see + * header comment for mayaToEgg.cxx for more details) + */ #include "mayaCopy.h" #include "config_maya.h" @@ -36,11 +35,9 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaCopy:: MayaCopy() { set_program_brief("copy Maya .mb files into a CVS source hierarchy"); @@ -92,11 +89,9 @@ MayaCopy() { add_path_replace_options(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaCopy:: run() { _maya = MayaApi::open_api(_program_name); @@ -119,14 +114,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::copy_file -// Access: Protected, Virtual -// Description: Called by import() if verify_file() indicates that a -// file needs to be copied. This does the actual copy -// of a file from source to destination. If new_file is -// true, then dest does not already exist. -//////////////////////////////////////////////////////////////////// +/** + * Called by import() if verify_file() indicates that a file needs to be + * copied. This does the actual copy of a file from source to destination. + * If new_file is true, then dest does not already exist. + */ bool MayaCopy:: copy_file(const Filename &source, const Filename &dest, CVSSourceDirectory *dir, void *extra_data, bool new_file) { @@ -146,15 +138,12 @@ copy_file(const Filename &source, const Filename &dest, return false; } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::filter_filename -// Access: Protected, Virtual -// Description: Given a source filename (including the basename only, -// without a dirname), return the appropriate -// corresponding filename within the source directory. -// This may be used by derived classes to, for instance, -// strip a version number from the filename. -//////////////////////////////////////////////////////////////////// +/** + * Given a source filename (including the basename only, without a dirname), + * return the appropriate corresponding filename within the source directory. + * This may be used by derived classes to, for instance, strip a version + * number from the filename. + */ string MayaCopy:: filter_filename(const string &source) { if (_keep_ver) { @@ -168,9 +157,9 @@ filter_filename(const string &source) { string extension = source.substr(dot); if (extension == ".ma" || extension == ".mb") { - // If we are reading a Maya file (as opposed to a texture image), - // then we always write ".mb" files out (unless -ma was specified - // on the command line). + // If we are reading a Maya file (as opposed to a texture image), then we + // always write ".mb" files out (unless -ma was specified on the command + // line). if (_maya_ascii) { extension = ".ma"; } else { @@ -186,11 +175,9 @@ filter_filename(const string &source) { } } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::copy_maya_file -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool MayaCopy:: copy_maya_file(const Filename &source, const Filename &dest, CVSSourceDirectory *dir) { @@ -222,14 +209,16 @@ copy_maya_file(const Filename &source, const Filename &dest, status = MGlobal::executeCommand(MString(blah.c_str()), result); maya_cat.info() << "result = " << result.asChar() << endl; - // for multiple reference of the same model. maya throws in a {#} at the end, ignore that + // for multiple reference of the same model. maya throws in a {#} at the + // end, ignore that size_t dup = lookup.find('{'); if (dup != string::npos){ lookup.erase(dup); } - // to check out this specific reference is actually loaded or not - // somehow this flag order of MEL script must be observed to guarantee proper working + // to check out this specific reference is actually loaded or not somehow + // this flag order of MEL script must be observed to guarantee proper + // working string refNode = result.asChar(); string refCheckCmd = "file -rfn " + refNode + " -q -dr;"; int deferredRef; @@ -239,7 +228,7 @@ copy_maya_file(const Filename &source, const Filename &dest, continue; } - Filename filename = + Filename filename = _path_replace->convert_path(Filename::from_os_specific(lookup)); CVSSourceTree::FilePath path = @@ -290,29 +279,30 @@ copy_maya_file(const Filename &source, const Filename &dest, << "Cannot write " << dest << "\n"; return false; } - + for (ref_index = 0; ref_index < num_refs; ref_index++) { if (1) { // we may want an option later to pull in all the referenced files continue; } string lookup = refs[ref_index].asChar(); - // for multiple reference of the same model. maya throws in a {#} at the end, ignore that + // for multiple reference of the same model. maya throws in a {#} at the + // end, ignore that size_t dup = lookup.find('{'); if (dup != string::npos){ lookup.erase(dup); } - Filename filename = + Filename filename = _path_replace->convert_path(Filename::from_os_specific(lookup)); maya_cat.info() << "External ref: " << filename << "\n"; - + // Now import the file ExtraData ed; ed._type = FT_maya; - + CVSSourceTree::FilePath path = import(filename, &ed, _model_dir); if (!path.is_valid()) { exit(1); @@ -322,14 +312,11 @@ copy_maya_file(const Filename &source, const Filename &dest, return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::extract_texture -// Access: Private -// Description: Gets the texture out of the indicated color channel -// and copies it in, updating the channel with the new -// texture filename. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Gets the texture out of the indicated color channel and copies it in, + * updating the channel with the new texture filename. Returns true on + * success, false on failure. + */ bool MayaCopy:: extract_texture(MayaShaderColorDef &color_def, CVSSourceDirectory *dir) { Filename texture_filename = @@ -345,16 +332,16 @@ extract_texture(MayaShaderColorDef &color_def, CVSSourceDirectory *dir) { } else { ExtraData ed; ed._type = FT_texture; - + CVSSourceTree::FilePath texture_path = import(texture_filename, &ed, _map_dir); - + if (!texture_path.is_valid()) { return false; } - - // Update the texture reference to point to the new texture - // filename, relative to the maya file. + + // Update the texture reference to point to the new texture filename, + // relative to the maya file. Filename new_filename = texture_path.get_rel_from(dir); color_def.reset_maya_texture(new_filename); } @@ -362,11 +349,9 @@ extract_texture(MayaShaderColorDef &color_def, CVSSourceDirectory *dir) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::copy_texture -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool MayaCopy:: copy_texture(const Filename &source, const Filename &dest, CVSSourceDirectory *dir) { @@ -377,12 +362,10 @@ copy_texture(const Filename &source, const Filename &dest, return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::collect_shaders -// Access: Private -// Description: Recursively walks through the maya scene graph -// hierarchy, looking for shaders. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks through the maya scene graph hierarchy, looking for + * shaders. + */ bool MayaCopy:: collect_shaders() { MStatus status; @@ -393,9 +376,9 @@ collect_shaders() { return false; } - // This while loop walks through the entire Maya hierarchy, one node - // at a time. Maya's MItDag object automatically performs a - // depth-first traversal of its scene graph. + // This while loop walks through the entire Maya hierarchy, one node at a + // time. Maya's MItDag object automatically performs a depth-first + // traversal of its scene graph. bool all_ok = true; while (!dag_iterator.isDone()) { MDagPath dag_path; @@ -419,12 +402,9 @@ collect_shaders() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaCopy::collect_shader_for_node -// Access: Private -// Description: Gets the relevant shader on the current node, if it -// has one. -//////////////////////////////////////////////////////////////////// +/** + * Gets the relevant shader on the current node, if it has one. + */ bool MayaCopy:: collect_shader_for_node(const MDagPath &dag_path) { MStatus status; @@ -452,7 +432,7 @@ collect_shader_for_node(const MDagPath &dag_path) { if (status) { unsigned int num_shaders = shaders.length(); for (unsigned int shader_index = 0; - shader_index < num_shaders; + shader_index < num_shaders; shader_index++) { MObject engine = shaders[shader_index]; _shaders.find_shader_for_shading_engine(engine, false); @@ -469,7 +449,8 @@ collect_shader_for_node(const MDagPath &dag_path) { int main(int argc, char *argv[]) { - // We don't want pystub on linux, since it gives problems with Maya's python. + // We don't want pystub on linux, since it gives problems with Maya's + // python. #ifdef _WIN32 // A call to pystub() to force libpystub.so to be linked in. pystub(); @@ -480,4 +461,3 @@ int main(int argc, char *argv[]) { prog.run(); return 0; } - diff --git a/pandatool/src/mayaprogs/mayaCopy.h b/pandatool/src/mayaprogs/mayaCopy.h index 18bba49c9e..e48c2f9204 100644 --- a/pandatool/src/mayaprogs/mayaCopy.h +++ b/pandatool/src/mayaprogs/mayaCopy.h @@ -1,16 +1,15 @@ -// Filename: mayaCopy.h -// Created by: drose (10May02) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaCopy.h + * @author drose + * @date 2002-05-10 + */ #ifndef MAYACOPY_H #define MAYACOPY_H @@ -28,11 +27,9 @@ class MayaShader; class MayaShaderColorDef; class MDagPath; -//////////////////////////////////////////////////////////////////// -// Class : MayaCopy -// Description : A program to copy Maya .mb files into the cvs -// tree. -//////////////////////////////////////////////////////////////////// +/** + * A program to copy Maya .mb files into the cvs tree. + */ class MayaCopy : public CVSCopy { public: MayaCopy(); diff --git a/pandatool/src/mayaprogs/mayaEggImport.cxx b/pandatool/src/mayaprogs/mayaEggImport.cxx index 3b93365e91..4b4ee413f0 100644 --- a/pandatool/src/mayaprogs/mayaEggImport.cxx +++ b/pandatool/src/mayaprogs/mayaEggImport.cxx @@ -1,34 +1,31 @@ -// Filename: mayaEggImport.cxx -// Created by: jyelon (20Jul05) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// -// -// This is the wrapper code for the maya importer plugin. -// It includes: -// -// - user interface dialogs and popups -// - plugin initialization/registration -// -// It does not include the actual code to traverse the EggData. -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaEggImport.cxx + * @author jyelon + * @date 2005-07-20 + * + * This is the wrapper code for the maya importer plugin. + * It includes: + * + * - user interface dialogs and popups + * - plugin initialization/registration + * + * It does not include the actual code to traverse the EggData. + */ #include #include #include "dtoolbase.h" -// We must define this to prevent Maya from doubly-declaring its -// MApiVersion string in this file as well as in libmayaegg. +// We must define this to prevent Maya from doubly-declaring its MApiVersion +// string in this file as well as in libmayaegg. #define _MApiVersion #include "pre_maya_include.h" @@ -47,7 +44,6 @@ #include "mayaEggLoader.h" #include "notifyCategoryProxy.h" -//////////////////////////////////////////////////////////////////// class MayaEggImporter : public MPxFileTranslator { @@ -90,8 +86,7 @@ MStatus MayaEggImporter::reader ( const MFileObject& file, const MString flagModel("model"); const MString flagAnim("anim"); - // Start parsing. - // + // Start parsing. MStringArray optionList; MStringArray theOption; options.split(';', optionList); diff --git a/pandatool/src/mayaprogs/mayaPview.cxx b/pandatool/src/mayaprogs/mayaPview.cxx index 79f794695d..60af297044 100644 --- a/pandatool/src/mayaprogs/mayaPview.cxx +++ b/pandatool/src/mayaprogs/mayaPview.cxx @@ -1,16 +1,15 @@ -// Filename: mayaPview.cxx -// Created by: drose (10Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaPview.cxx + * @author drose + * @date 2003-03-10 + */ #ifdef __MACH__ #define __OPENTRANSPORTPROVIDERS__ @@ -28,8 +27,8 @@ #include "distanceUnit.h" #include "configVariableEnum.h" -// We must define this to prevent Maya from doubly-declaring its -// MApiVersion string in this file as well as in libmayaegg. +// We must define this to prevent Maya from doubly-declaring its MApiVersion +// string in this file as well as in libmayaegg. #define _MApiVersion #include "pre_maya_include.h" @@ -42,28 +41,24 @@ #include #include "post_maya_include.h" -// On Windows, we have code to fork pview as a separate process, which -// seems to be better for Maya. +// On Windows, we have code to fork pview as a separate process, which seems +// to be better for Maya. #ifdef WIN32_VC #include #include #define SEPARATE_PVIEW 1 #endif // WIN32_VC -//////////////////////////////////////////////////////////////////// -// Function: MayaPview::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaPview:: MayaPview() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaPview::doIt -// Access: Public, Virtual -// Description: Called when the plugin command is invoked. -//////////////////////////////////////////////////////////////////// +/** + * Called when the plugin command is invoked. + */ MStatus MayaPview:: doIt(const MArgList &args) { MStatus result; @@ -99,9 +94,9 @@ doIt(const MArgList &args) { Filename bam_filename = Filename::temporary("", "pview"); bam_filename.set_extension("bam"); - // Since we're just writing to a bam file in this process, and - // running pview in a separate process, we don't actually need to - // load textures at this point. Disable the loading of textures. + // Since we're just writing to a bam file in this process, and running pview + // in a separate process, we don't actually need to load textures at this + // point. Disable the loading of textures. textures_header_only = true; NodePath root("root"); @@ -122,18 +117,17 @@ doIt(const MArgList &args) { MProgressWindow::setProgressStatus("Spawning pview"); MProgressWindow::advanceProgress(1); - + // Now spawn a pview instance to view this temporary file. string pview_args = "-clD"; if (animate) { pview_args = "-clDa"; } - // On Windows, we use the spawn function to run pview - // asynchronously. + // On Windows, we use the spawn function to run pview asynchronously. string quoted = string("\"") + bam_filename.get_fullpath() + string("\""); nout << "pview " << pview_args << " " << quoted << "\n"; - int retval = _spawnlp(_P_DETACH, "pview", + int retval = _spawnlp(_P_DETACH, "pview", "pview", pview_args.c_str(), quoted.c_str(), NULL); if (retval == -1) { bam_filename.unlink(); @@ -141,17 +135,16 @@ doIt(const MArgList &args) { return MS::kFailure; } - nout << "pview running.\n"; + nout << "pview running.\n"; MProgressWindow::endProgress(); #else // SEPARATE_PVIEW // We'll run PandaFramework directly within this process. - // Maya seems to run each invocation of the plugin in a separate - // thread. To minimize conflict in our - // not-yet-completely-thread-safe Panda, we'll create a separate - // PandaFramework for each invocation, even though in principle we - // could be sharing one framework for all of them. + // Maya seems to run each invocation of the plugin in a separate thread. To + // minimize conflict in our not-yet-completely-thread-safe Panda, we'll + // create a separate PandaFramework for each invocation, even though in + // principle we could be sharing one framework for all of them. int argc = 0; char **argv = NULL; PandaFramework framework; @@ -181,8 +174,8 @@ doIt(const MArgList &args) { loading->set_align(TextNode::A_center); loading->set_text("Loading..."); - // Allow a couple of frames to go by so the window will be fully - // created and the text will be visible. + // Allow a couple of frames to go by so the window will be fully created and + // the text will be visible. framework.do_frame(Thread::get_current_thread()); framework.do_frame(Thread::get_current_thread()); @@ -213,22 +206,18 @@ doIt(const MArgList &args) { return MS::kSuccess; } -//////////////////////////////////////////////////////////////////// -// Function: MayaPview::creator -// Access: Public, Static -// Description: This is used to create a new instance of the plugin. -//////////////////////////////////////////////////////////////////// +/** + * This is used to create a new instance of the plugin. + */ void *MayaPview:: creator() { return new MayaPview; } -//////////////////////////////////////////////////////////////////// -// Function: MayaPview::convert -// Access: Private -// Description: Actually converts the Maya selection to Panda -// geometry, and parents it to the indicated NodePath. -//////////////////////////////////////////////////////////////////// +/** + * Actually converts the Maya selection to Panda geometry, and parents it to + * the indicated NodePath. + */ bool MayaPview:: convert(const NodePath &parent, bool animate) { // Now make a converter to get all the Maya structures. @@ -251,7 +240,7 @@ convert(const NodePath &parent, bool animate) { PathReplace *path_replace = converter.get_path_replace(); // Accept relative pathnames in the Maya file. - Filename source_file = + Filename source_file = Filename::from_os_specific(MFileIO::currentFile().asChar()); string source_dir = source_file.get_dirname(); if (!source_dir.empty()) { @@ -274,14 +263,14 @@ convert(const NodePath &parent, bool animate) { MProgressWindow::setProgressStatus("Converting to bam"); MProgressWindow::advanceProgress(1); - // Now the converter has filled up our egg structure with data, so - // convert this egg data to Panda data for immediate viewing. + // Now the converter has filled up our egg structure with data, so convert + // this egg data to Panda data for immediate viewing. DistanceUnit input_units = converter.get_input_units(); ConfigVariableEnum ptloader_units("ptloader-units", DU_invalid); - if (input_units != DU_invalid && ptloader_units != DU_invalid && + if (input_units != DU_invalid && ptloader_units != DU_invalid && input_units != ptloader_units) { - // Convert the file to the units specified by the ptloader-units - // Configrc variable. + // Convert the file to the units specified by the ptloader-units Configrc + // variable. nout << "Converting from " << format_long_unit(input_units) << " to " << format_long_unit(ptloader_units) << "\n"; @@ -304,16 +293,15 @@ convert(const NodePath &parent, bool animate) { -//////////////////////////////////////////////////////////////////// -// Function: initializePlugin -// Description: Called by Maya when the plugin is loaded. -//////////////////////////////////////////////////////////////////// -EXPCL_MISC MStatus +/** + * Called by Maya when the plugin is loaded. + */ +EXPCL_MISC MStatus initializePlugin(MObject obj) { - // This code is just for debugging, to cause Notify to write its - // output to a log file we can inspect, so we can see the error - // messages output by DX7 or DX8 just before it does a panic exit - // (and thereby shuts down Maya and its output window). + // This code is just for debugging, to cause Notify to write its output to a + // log file we can inspect, so we can see the error messages output by DX7 + // or DX8 just before it does a panic exit (and thereby shuts down Maya and + // its output window). /* MultiplexStream *local_nout = new MultiplexStream(); Notify::ptr()->set_ostream_ptr(local_nout, 0); @@ -331,10 +319,9 @@ initializePlugin(MObject obj) { return status; } -//////////////////////////////////////////////////////////////////// -// Function: uninitializePlugin -// Description: Called by Maya when the plugin is unloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called by Maya when the plugin is unloaded. + */ EXPCL_MISC MStatus uninitializePlugin(MObject obj) { MFnPlugin plugin(obj); diff --git a/pandatool/src/mayaprogs/mayaPview.h b/pandatool/src/mayaprogs/mayaPview.h index 2b7a42934a..79cff017f2 100644 --- a/pandatool/src/mayaprogs/mayaPview.h +++ b/pandatool/src/mayaprogs/mayaPview.h @@ -1,16 +1,15 @@ -// Filename: mayaPview.h -// Created by: drose (11Mar03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaPview.h + * @author drose + * @date 2003-03-11 + */ #ifndef MAYAPVIEW_H #define MAYAPVIEW_H @@ -24,12 +23,10 @@ #include #include "post_maya_include.h" -//////////////////////////////////////////////////////////////////// -// Class : MayaPview -// Description : This class serves as a plug-in to Maya to allow -// viewing the current Maya selection as it will be -// converted to Panda. -//////////////////////////////////////////////////////////////////// +/** + * This class serves as a plug-in to Maya to allow viewing the current Maya + * selection as it will be converted to Panda. + */ class MayaPview : public MPxCommand { public: MayaPview(); diff --git a/pandatool/src/mayaprogs/mayaSavePview.cxx b/pandatool/src/mayaprogs/mayaSavePview.cxx index 0ea6071dd5..60a115c14f 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.cxx +++ b/pandatool/src/mayaprogs/mayaSavePview.cxx @@ -1,16 +1,15 @@ -// Filename: mayaSavePview.cxx -// Created by: drose (27Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaSavePview.cxx + * @author drose + * @date 2003-10-27 + */ #include "mayaSavePview.h" @@ -27,20 +26,16 @@ #include #endif -//////////////////////////////////////////////////////////////////// -// Function: MayaSavePview::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaSavePview:: MayaSavePview() { } -//////////////////////////////////////////////////////////////////// -// Function: MayaSavePview::doIt -// Access: Public, Virtual -// Description: Called when the plugin command is invoked. -//////////////////////////////////////////////////////////////////// +/** + * Called when the plugin command is invoked. + */ MStatus MayaSavePview:: doIt(const MArgList &args) { MStatus result; @@ -60,7 +55,7 @@ doIt(const MArgList &args) { result.perror("isFlagSet"); return result; } - + // Now make sure the current buffer is saved. result = MFileIO::save(false); if (result != MS::kSuccess) { @@ -75,19 +70,17 @@ doIt(const MArgList &args) { } #ifdef WIN32_VC - // On Windows, we use the spawn function to run pview - // asynchronously. + // On Windows, we use the spawn function to run pview asynchronously. MString quoted = MString("\"") + filename + MString("\""); - int retval = _spawnlp(_P_DETACH, "pview", + int retval = _spawnlp(_P_DETACH, "pview", "pview", pview_args.asChar(), quoted.asChar(), NULL); if (retval == -1) { return MS::kFailure; } #else // WIN32_VC - // On non-Windows (e.g. Unix), we just use the system function, - // which runs synchronously. We could fork a process, but no one's - // asked for this yet. + // On non-Windows (e.g. Unix), we just use the system function, which runs + // synchronously. We could fork a process, but no one's asked for this yet. MString command = MString("pview " + pview_args + MString(" \"") + filename + MString("\"")); int command_result = system(command.asChar()); @@ -99,11 +92,9 @@ doIt(const MArgList &args) { return MS::kSuccess; } -//////////////////////////////////////////////////////////////////// -// Function: MayaSavePview::creator -// Access: Public, Static -// Description: This is used to create a new instance of the plugin. -//////////////////////////////////////////////////////////////////// +/** + * This is used to create a new instance of the plugin. + */ void *MayaSavePview:: creator() { return new MayaSavePview; @@ -111,11 +102,10 @@ creator() { -//////////////////////////////////////////////////////////////////// -// Function: initializePlugin -// Description: Called by Maya when the plugin is loaded. -//////////////////////////////////////////////////////////////////// -EXPCL_MISC MStatus +/** + * Called by Maya when the plugin is loaded. + */ +EXPCL_MISC MStatus initializePlugin(MObject obj) { MFnPlugin plugin(obj, "VR Studio", "1.0"); MStatus status; @@ -127,10 +117,9 @@ initializePlugin(MObject obj) { return status; } -//////////////////////////////////////////////////////////////////// -// Function: uninitializePlugin -// Description: Called by Maya when the plugin is unloaded. -//////////////////////////////////////////////////////////////////// +/** + * Called by Maya when the plugin is unloaded. + */ EXPCL_MISC MStatus uninitializePlugin(MObject obj) { MFnPlugin plugin(obj); diff --git a/pandatool/src/mayaprogs/mayaSavePview.h b/pandatool/src/mayaprogs/mayaSavePview.h index 5cd8d5dafd..cf961633f1 100644 --- a/pandatool/src/mayaprogs/mayaSavePview.h +++ b/pandatool/src/mayaprogs/mayaSavePview.h @@ -1,24 +1,23 @@ -// Filename: mayaSavePview.h -// Created by: drose (27Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaSavePview.h + * @author drose + * @date 2003-10-27 + */ #ifndef MAYASAVEPVIEW_H #define MAYASAVEPVIEW_H // We don't want to include pre_maya_include.h here, since that would -// necessitate linking with Pandatool's libmaya.dll, which would in -// turn bring in a lot of stuff from panda that we don't really need. -// Instead, we'll just define the Maya symbols we require here. +// necessitate linking with Pandatool's libmaya.dll, which would in turn bring +// in a lot of stuff from panda that we don't really need. Instead, we'll +// just define the Maya symbols we require here. // Maya will try to typedef bool unless this symbol is defined. #ifndef _BOOL @@ -30,14 +29,14 @@ #include "maya/OpenMayaMac.h" #endif -// Even though we don't include any Panda headers, it's safe to -// include this one, since it only defines some macros that we need to -// make this program platform-independent. +// Even though we don't include any Panda headers, it's safe to include this +// one, since it only defines some macros that we need to make this program +// platform-independent. #include "dtool_config.h" #ifdef PHAVE_IOSTREAM -// This will ask Maya 5.0 or better to use the new library -// instead of the old library. +// This will ask Maya 5.0 or better to use the new library instead +// of the old library. #define REQUIRE_IOSTREAM #endif // PHAVE_IOSTREAM @@ -45,23 +44,18 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : MayaSavePview -// Description : This class serves as a plug-in to Maya to save the -// scene and view it using the external pview program, -// rather than linking in any part of Panda to a Maya -// plugin. -// -// Since it does not link with any Panda code, and hence -// is a very lean plugin, it is less likely than -// MayaPview to cause interoperability problems within -// Maya. However, it does force a save-to-disk and a -// spawning of a separate executable, including a -// complete reloading of all of the Maya libraries, so -// it is quite a bit slower to execute. And the -// potential for interactive control is substantially -// reduced. -//////////////////////////////////////////////////////////////////// +/** + * This class serves as a plug-in to Maya to save the scene and view it using + * the external pview program, rather than linking in any part of Panda to a + * Maya plugin. + * + * Since it does not link with any Panda code, and hence is a very lean + * plugin, it is less likely than MayaPview to cause interoperability problems + * within Maya. However, it does force a save-to-disk and a spawning of a + * separate executable, including a complete reloading of all of the Maya + * libraries, so it is quite a bit slower to execute. And the potential for + * interactive control is substantially reduced. + */ class MayaSavePview : public MPxCommand { public: MayaSavePview(); @@ -71,8 +65,8 @@ public: }; // Since we don't include any of the Panda headers (other than -// dtool_config.h), we have to define this macro ourselves, to tell -// Windows to export the following functions from the DLL. +// dtool_config.h), we have to define this macro ourselves, to tell Windows to +// export the following functions from the DLL. #ifdef WIN32_VC #define EXPCL_MISC __declspec(dllexport) #else diff --git a/pandatool/src/mayaprogs/mayaToEgg.cxx b/pandatool/src/mayaprogs/mayaToEgg.cxx index a6497c46cd..a7a4cfe7c6 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg.cxx @@ -1,43 +1,42 @@ -// Filename: mayaToEgg.cxx -// Created by: drose (15Feb00) -// -// Additional Maintenance by the PandaSE team -// Carnegie Mellon Entertainment Technology Center -// Spring '10 -// Team Members: -// Deepak Chandraskeran - producer / programmer -// Andrew Gartner - programmer/technical artist -// Federico Perazzi - programmer -// Shuying Feng - programmer -// Wei-Feng Huang - programmer -// (Egger additions by Andrew Gartner and Wei-Feng Huang) -// The egger can now support vertex color in a variety -// of combinations with flat color and file color textures -// (see set_vertex_color). Also, there are two new -// command line options "legacy-shaders" and "texture-copy". -// The first treats any Maya material/shader as if it were -// a legacy shader. Passing it through the legacy codepath. -// This feature was originally intended to fix a bug where -// flat-color was being ignored in the modern (Phong) codepath -// However, with the new vertex and flat color functions it -// may not be necessary. Still, until the newer color functions -// have been tried and tested more, the feature has been left in -// to anticipate any problems that may arise. The texture copy -// feature was added to provide a way to resolve build path issues -// and can support both relative and absolute paths. The feature -// will copy any file maps/textures to the specified directory -// and update the egg file accordingly. -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg.cxx + * @author drose + * @date 2000-02-15 + * + * Additional Maintenance by the PandaSE team + * Carnegie Mellon Entertainment Technology Center + * Spring '10 + * Team Members: + * Deepak Chandraskeran - producer / programmer + * Andrew Gartner - programmer/technical artist + * Federico Perazzi - programmer + * Shuying Feng - programmer + * Wei-Feng Huang - programmer + * (Egger additions by Andrew Gartner and Wei-Feng Huang) + * The egger can now support vertex color in a variety + * of combinations with flat color and file color textures + * (see set_vertex_color). Also, there are two new + * command line options "legacy-shaders" and "texture-copy". + * The first treats any Maya material/shader as if it were + * a legacy shader. Passing it through the legacy codepath. + * This feature was originally intended to fix a bug where + * flat-color was being ignored in the modern (Phong) codepath + * However, with the new vertex and flat color functions it + * may not be necessary. Still, until the newer color functions + * have been tried and tested more, the feature has been left in + * to anticipate any problems that may arise. The texture copy + * feature was added to provide a way to resolve build path issues + * and can support both relative and absolute paths. The feature + * will copy any file maps/textures to the specified directory + * and update the egg file accordingly. + */ #include "mayaToEgg.h" #include "mayaToEggConverter.h" @@ -48,11 +47,9 @@ #include "pystub.h" #endif -//////////////////////////////////////////////////////////////////// -// Function: MayaToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEgg:: MayaToEgg() : SomethingToEgg("Maya", ".mb") @@ -194,10 +191,10 @@ MayaToEgg() : "and treat all shaders as if they were Lamberts (legacy).", &MayaToEgg::dispatch_none, &_legacy_shader); - // Unfortunately, the Maya API doesn't allow us to differentiate - // between relative and absolute pathnames--everything comes out as - // an absolute pathname, even if it is stored in the Maya file as a - // relative path. So we can't support -noabs. + // Unfortunately, the Maya API doesn't allow us to differentiate between + // relative and absolute pathnames--everything comes out as an absolute + // pathname, even if it is stored in the Maya file as a relative path. So + // we can't support -noabs. remove_option("noabs"); _verbose = 0; @@ -206,11 +203,9 @@ MayaToEgg() : _got_tbnauto = true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaToEgg:: run() { // Set the verbose level by using Notify. @@ -230,9 +225,8 @@ run() { _path_replace->_copy_into_directory = _legacy_copytex_dir; } - // Let's convert the output file to a full path before we initialize - // Maya, since Maya now has a nasty habit of changing the current - // directory. + // Let's convert the output file to a full path before we initialize Maya, + // since Maya now has a nasty habit of changing the current directory. if (_got_output_filename) { _output_filename.make_absolute(); _path_replace->_path_directory.make_absolute(); @@ -240,8 +234,8 @@ run() { nout << "Initializing Maya.\n"; MayaToEggConverter converter(_program_name); - //reverting directories is really not needed for maya2egg. It's - //more needed for mayaeggloader and such + // reverting directories is really not needed for maya2egg. It's more + // needed for mayaeggloader and such if (!converter.open_api(false)) { nout << "Unable to initialize Maya.\n"; exit(1); @@ -311,10 +305,10 @@ run() { exit(1); } - // Use the standard Maya units, if the user didn't specify - // otherwise. This always returns centimeters, which is the way all - // Maya files are stored internally (and is the units returned by - // all of the API functions called here). + // Use the standard Maya units, if the user didn't specify otherwise. This + // always returns centimeters, which is the way all Maya files are stored + // internally (and is the units returned by all of the API functions called + // here). if (_input_units == DU_invalid) { _input_units = converter.get_input_units(); } @@ -323,12 +317,10 @@ run() { nout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEgg::dispatch_transform_type -// Access: Protected, Static -// Description: Dispatches a parameter that expects a -// MayaToEggConverter::TransformType option. -//////////////////////////////////////////////////////////////////// +/** + * Dispatches a parameter that expects a MayaToEggConverter::TransformType + * option. + */ bool MayaToEgg:: dispatch_transform_type(const string &opt, const string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; @@ -344,7 +336,8 @@ dispatch_transform_type(const string &opt, const string &arg, void *var) { } int main(int argc, char *argv[]) { - // We don't want pystub on linux, since it gives problems with Maya's python. + // We don't want pystub on linux, since it gives problems with Maya's + // python. #ifdef _WIN32 // A call to pystub() to force libpystub.so to be linked in. pystub(); @@ -355,4 +348,3 @@ int main(int argc, char *argv[]) { prog.run(); return 0; } - diff --git a/pandatool/src/mayaprogs/mayaToEgg.h b/pandatool/src/mayaprogs/mayaToEgg.h index efaf1af2ef..4b3661a104 100644 --- a/pandatool/src/mayaprogs/mayaToEgg.h +++ b/pandatool/src/mayaprogs/mayaToEgg.h @@ -1,16 +1,15 @@ -// Filename: mayaToEgg.h -// Created by: drose (15Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg.h + * @author drose + * @date 2000-02-15 + */ #ifndef MAYATOEGG_H #define MAYATOEGG_H @@ -19,10 +18,9 @@ #include "somethingToEgg.h" #include "mayaToEggConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : MayaToEgg -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class MayaToEgg : public SomethingToEgg { public: MayaToEgg(); @@ -46,7 +44,7 @@ protected: Filename _legacy_copytex_dir; MayaToEggConverter::TransformType _transform_type; - vector_string _subroots; + vector_string _subroots; vector_string _subsets; vector_string _excludes; vector_string _ignore_sliders; diff --git a/pandatool/src/mayaprogs/mayaToEgg_client.cxx b/pandatool/src/mayaprogs/mayaToEgg_client.cxx index 676ea65abb..d5d3f40c9f 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_client.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_client.cxx @@ -1,27 +1,24 @@ -// Filename: mayaToEgg_client.cxx -// Adapted by: cbrunner (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg_client.cxx + * @author cbrunner + * @date 2009-11-09 + */ #include "mayaToEgg_client.h" #ifdef _WIN32 #include "pystub.h" #endif -//////////////////////////////////////////////////////////////////// -// Function: MayaToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggClient:: MayaToEggClient() : SomethingToEgg("Maya", ".mb") @@ -34,7 +31,8 @@ MayaToEggClient() : } int main(int argc, char *argv[]) { - // We don't want pystub on linux, since it gives problems with Maya's python. + // We don't want pystub on linux, since it gives problems with Maya's + // python. #ifdef _WIN32 // A call to pystub() to force libpystub.so to be linked in. pystub(); @@ -83,4 +81,3 @@ int main(int argc, char *argv[]) { Thread::sleep(0.1); } } - diff --git a/pandatool/src/mayaprogs/mayaToEgg_client.h b/pandatool/src/mayaprogs/mayaToEgg_client.h index ce43a5a5e0..f3c7192467 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_client.h +++ b/pandatool/src/mayaprogs/mayaToEgg_client.h @@ -1,16 +1,15 @@ -// Filename: mayaToEgg_client.h -// Adapted by: cbrunner (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg_client.h + * @author cbrunner + * @date 2009-11-09 + */ #ifndef MAYATOEGGCLIENT_H #define MAYATOEGGCLIENT_H @@ -20,10 +19,9 @@ #include "queuedConnectionReader.h" #include "connectionWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : MayaToEggClient -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class MayaToEggClient : public SomethingToEgg { public: MayaToEggClient(); diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.cxx b/pandatool/src/mayaprogs/mayaToEgg_server.cxx index 15a063fa6e..19fd9ac22f 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.cxx +++ b/pandatool/src/mayaprogs/mayaToEgg_server.cxx @@ -1,16 +1,15 @@ -// Filename: mayaToEgg_server.cxx -// Adapted by: cbrunner (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg_server.cxx + * @author cbrunner + * @date 2009-11-09 + */ #if defined(WIN32_VC) || defined(WIN64_VC) #include // for chdir @@ -24,11 +23,9 @@ #include "pystub.h" #endif -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggServer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggServer:: MayaToEggServer() : SomethingToEgg("Maya", ".mb") @@ -155,10 +152,10 @@ MayaToEggServer() : "and treat all shaders as if they were Lamberts (legacy).", &MayaToEggServer::dispatch_none, &_legacy_shader); - // Unfortunately, the Maya API doesn't allow us to differentiate - // between relative and absolute pathnames--everything comes out as - // an absolute pathname, even if it is stored in the Maya file as a - // relative path. So we can't support -noabs. + // Unfortunately, the Maya API doesn't allow us to differentiate between + // relative and absolute pathnames--everything comes out as an absolute + // pathname, even if it is stored in the Maya file as a relative path. So + // we can't support -noabs. remove_option("noabs"); _verbose = 0; @@ -170,18 +167,16 @@ MayaToEggServer() : qReader = new QueuedConnectionReader(qManager, 0); cWriter = new ConnectionWriter(qManager, 0); dummy = new MayaToEggConverter(); - + nout << "Initializing Maya...\n"; if (!dummy->open_api()) { nout << "Unable to initialize Maya.\n"; exit(1); } } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggServer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ MayaToEggServer:: ~MayaToEggServer() { delete qManager; @@ -191,11 +186,9 @@ MayaToEggServer:: delete dummy; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggServer::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void MayaToEggServer:: run() { // Make sure we have good clean data to start with @@ -213,9 +206,8 @@ run() { mayaegg_cat->set_severity(NS_info); } - // Let's convert the output file to a full path before we initialize - // Maya, since Maya now has a nasty habit of changing the current - // directory. + // Let's convert the output file to a full path before we initialize Maya, + // since Maya now has a nasty habit of changing the current directory. if (_got_output_filename) { _output_filename.make_absolute(); _path_replace->_path_directory.make_absolute(); @@ -285,10 +277,10 @@ run() { exit(1); } - // Use the standard Maya units, if the user didn't specify - // otherwise. This always returns centimeters, which is the way all - // Maya files are stored internally (and is the units returned by - // all of the API functions called here). + // Use the standard Maya units, if the user didn't specify otherwise. This + // always returns centimeters, which is the way all Maya files are stored + // internally (and is the units returned by all of the API functions called + // here). if (_input_units == DU_invalid) { _input_units = converter.get_input_units(); } @@ -297,7 +289,7 @@ run() { append_command_comment(_data); write_egg_file(); - + // Clean and out close_output(); _verbose = 0; @@ -335,12 +327,10 @@ run() { dummy->clear(); } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggServer::dispatch_transform_type -// Access: Protected, Static -// Description: Dispatches a parameter that expects a -// MayaToEggConverter::TransformType option. -//////////////////////////////////////////////////////////////////// +/** + * Dispatches a parameter that expects a MayaToEggConverter::TransformType + * option. + */ bool MayaToEggServer:: dispatch_transform_type(const string &opt, const string &arg, void *var) { MayaToEggConverter::TransformType *ip = (MayaToEggConverter::TransformType *)var; @@ -355,20 +345,17 @@ dispatch_transform_type(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: MayaToEggServer::poll -// Access: Public -// Description: Checks for any network activity and handles it, if -// appropriate, and then returns. This must be called -// periodically -//////////////////////////////////////////////////////////////////// +/** + * Checks for any network activity and handles it, if appropriate, and then + * returns. This must be called periodically + */ void MayaToEggServer:: poll() { // Listen for new connections qListener->poll(); - // If we have a new connection from a client create a new connection - // pointer and add it to the reader list + // If we have a new connection from a client create a new connection pointer + // and add it to the reader list if (qListener->new_connection_available()) { PT(Connection) con; PT(Connection) rv; @@ -387,7 +374,7 @@ poll() { qManager->close_connection(connection); } } - + // Poll the readers (created above) and if they have data process it qReader->poll(); if (qReader->data_available()) { @@ -398,12 +385,12 @@ poll() { // First data should be the "argc" (argument count) from the client int argc = data.get_uint8(); - // Now we have to get clever because the rest of the data comes as strings - // and parse_command_line() expects arguments of the standard argc, argv*[] - // variety. - // First, we need a string vector to hold all the strings from the datagram. - // We also need a char * array to keep track of all the pointers we're gonna - // malloc. Needed later for cleanup. + // Now we have to get clever because the rest of the data comes as + // strings and parse_command_line() expects arguments of the standard + // argc, argv*[] variety. First, we need a string vector to hold all + // the strings from the datagram. We also need a char * array to keep + // track of all the pointers we're gonna malloc. Needed later for + // cleanup. vector_string vargv; vector buffers; @@ -413,18 +400,18 @@ poll() { vargv.push_back(data.get_string()); } - // Last string is the current directory the client was run from. Not part of - // the argument list, but we still need it + // Last string is the current directory the client was run from. Not + // part of the argument list, but we still need it string cwd = data.get_string(); - // We allocate some memory to hold the pointers to the pointers we're going to - // pass in to parse_command_line(). + // We allocate some memory to hold the pointers to the pointers we're + // going to pass in to parse_command_line(). char ** cargv = (char**) malloc(sizeof(char**) * argc); - // Loop through the string arguments we got from the datagram and convert - // them to const char *'s. parse_command_line() expects char *'s, so we have - // to copy these const versions into fresh char *, since there is no casting - // from const char * to char *. + // Loop through the string arguments we got from the datagram and + // convert them to const char *'s. parse_command_line() expects char + // *'s, so we have to copy these const versions into fresh char *, since + // there is no casting from const char * to char *. for ( i = 0; i < argc; i++) { // string to const char * const char * cptr = vargv[i].c_str(); @@ -432,10 +419,11 @@ poll() { char * buffer = (char*) malloc(vargv[i].capacity()+1); // Copy the const char * to the char * strcpy(buffer, cptr); - // put this into the arry we defined above. This is what will eventually - // be passed to parse_command_line() + // put this into the arry we defined above. This is what will + // eventually be passed to parse_command_line() cargv[i] = buffer; - // keep track of the pointers to the allocated memory for cleanup later + // keep track of the pointers to the allocated memory for cleanup + // later buffers.push_back(buffer); } // Change to the client's current dir @@ -450,8 +438,7 @@ poll() { // Actually run the damn thing this->run(); - // Cleanup - // First, release the string vector + // Cleanup First, release the string vector vargv.clear(); // No, iterate through the char * vector and cleanup the malloc'd // pointers @@ -471,7 +458,8 @@ poll() { } // poll int main(int argc, char *argv[]) { - // We don't want pystub on linux, since it gives problems with Maya's python. + // We don't want pystub on linux, since it gives problems with Maya's + // python. #ifdef _WIN32 // A call to pystub() to force libpystub.so to be linked in. pystub(); @@ -494,4 +482,3 @@ int main(int argc, char *argv[]) { } return 0; } - diff --git a/pandatool/src/mayaprogs/mayaToEgg_server.h b/pandatool/src/mayaprogs/mayaToEgg_server.h index 4075aa39d4..3eaf739ada 100644 --- a/pandatool/src/mayaprogs/mayaToEgg_server.h +++ b/pandatool/src/mayaprogs/mayaToEgg_server.h @@ -1,16 +1,15 @@ -// Filename: mayaToEgg_server.h -// Adapted by: cbrunner (09Nov09) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayaToEgg_server.h + * @author cbrunner + * @date 2009-11-09 + */ #ifndef MAYATOEGGSERVER_H #define MAYATOEGGSERVER_H @@ -23,10 +22,9 @@ #include "queuedConnectionReader.h" #include "connectionWriter.h" -//////////////////////////////////////////////////////////////////// -// Class : MayaToEggServer -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class MayaToEggServer : public SomethingToEgg { public: MayaToEggServer(); @@ -59,7 +57,7 @@ protected: bool _legacy_shader; MayaToEggConverter::TransformType _transform_type; - vector_string _subroots; + vector_string _subroots; vector_string _subsets; vector_string _excludes; vector_string _ignore_sliders; diff --git a/pandatool/src/mayaprogs/mayapath.cxx b/pandatool/src/mayaprogs/mayapath.cxx index 2ecb63c1df..7de8830410 100644 --- a/pandatool/src/mayaprogs/mayapath.cxx +++ b/pandatool/src/mayaprogs/mayapath.cxx @@ -1,39 +1,38 @@ -// Filename: mayapath.cxx -// Created by: drose (07Apr08) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file mayapath.cxx + * @author drose + * @date 2008-04-07 + */ -// This program works as a stub to launch maya2egg, egg2maya, and -// similar programs that invoke OpenMaya and require certain -// environment variables to be set first. +// This program works as a stub to launch maya2egg, egg2maya, and similar +// programs that invoke OpenMaya and require certain environment variables to +// be set first. -// It used to duplicate code in mayaWrapper.cxx, but now the -// functionality for these two separate programs are unified here. +// It used to duplicate code in mayaWrapper.cxx, but now the functionality for +// these two separate programs are unified here. // If MAYAVERSION is defined at the time this is compiled, then that -// particular version of Maya is insisted upon, and the desired Maya -// location is found in the Registry; otherwise, we require that -// $MAYA_LOCATION be set at runtime and points to the desired Maya -// installation. +// particular version of Maya is insisted upon, and the desired Maya location +// is found in the Registry; otherwise, we require that $MAYA_LOCATION be set +// at runtime and points to the desired Maya installation. -// If MAYAVERSION is defined and $MAYA_LOCATION is also set, then we -// check that definition of $MAYA_LOCATION is reasonable, which we -// define as pointing to the same version of OpenMaya.dll. If so, -// then we use the runtime $MAYA_LOCATION, allowing the user to -// (slightly) override the runtime Maya directory. If $MAYA_LOCATION -// is set but points to a different version of OpenMaya.dll, we ignore -// it altogether and replace it with our registry data, which allows -// the user to have MAYA_LOCATION pointing to a different version of -// Maya without interfering with this program. +/* + * If MAYAVERSION is defined and $MAYA_LOCATION is also set, then we check + * that definition of $MAYA_LOCATION is reasonable, which we define as + * pointing to the same version of OpenMaya.dll. If so, then we use the + * runtime $MAYA_LOCATION, allowing the user to (slightly) override the + * runtime Maya directory. If $MAYA_LOCATION is set but points to a different + * version of OpenMaya.dll, we ignore it altogether and replace it with our + * registry data, which allows the user to have MAYA_LOCATION pointing to a + * different version of Maya without interfering with this program. + */ #include "dtoolbase.h" #include "filename.h" @@ -69,8 +68,8 @@ static const Filename openmaya_filename = "lib/libOpenMaya.so"; // Searches for python26.zip or whatever version it is. static Filename find_pyzip(const Filename &maya_location) { - // This is where python26.zip appears on Windows. Should it be in - // other locations on other platforms? + // This is where python26.zip appears on Windows. Should it be in other + // locations on other platforms? Filename dirname(maya_location, "bin"); vector_string results; @@ -192,8 +191,8 @@ main(int argc, char *argv[]) { pystub(); #endif - // First, get the command line and append _bin, so we will actually - // run maya2egg_bin.exe, egg2maya_bin.exe, etc. + // First, get the command line and append _bin, so we will actually run + // maya2egg_bin.exe, egg2maya_bin.exe, etc. Filename command = Filename::from_os_specific(argv[0]); if (!command.is_fully_qualified()) { DSearchPath path; @@ -216,18 +215,17 @@ main(int argc, char *argv[]) { #endif string os_command = command.to_os_specific(); - // First start with $PANDA_MAYA_LOCATION. If it is set, it - // overrides everything else. + // First start with $PANDA_MAYA_LOCATION. If it is set, it overrides + // everything else. Filename maya_location = Filename::expand_from("$PANDA_MAYA_LOCATION"); if (!maya_location.empty()) { - // Reset maya_location to its full long name, because Maya - // requires this. + // Reset maya_location to its full long name, because Maya requires this. maya_location.make_canonical(); maya_location = Filename::from_os_specific(maya_location.to_os_long_name()); } else { - // $PANDA_MAYA_LOCATION wasn't set, so check the normal locations. - // First, we get the standard location, as a point of reference. + // $PANDA_MAYA_LOCATION wasn't set, so check the normal locations. First, + // we get the standard location, as a point of reference. Filename standard_maya_location; #ifdef MAYAVERSION const char *key = get_version_number(TOSTRING(MAYAVERSION)); @@ -243,20 +241,20 @@ main(int argc, char *argv[]) { } } if (!standard_maya_location.empty()) { - // Reset standard_maya_location to its full long name, so we can - // compare reliably to the given version. + // Reset standard_maya_location to its full long name, so we can compare + // reliably to the given version. standard_maya_location.make_canonical(); standard_maya_location = Filename::from_os_specific(standard_maya_location.to_os_long_name()); } #endif // MAYAVERSION - // Now check if $MAYA_LOCATION is set. If it is, and it's - // consistent with the standard location, we respect it. + // Now check if $MAYA_LOCATION is set. If it is, and it's consistent with + // the standard location, we respect it. maya_location = Filename::expand_from("$MAYA_LOCATION"); if (!maya_location.empty()) { - // Reset maya_location to its full long name, so we can compare - // it reliably to the standard location; and also because Maya - // requires this. + // Reset maya_location to its full long name, so we can compare it + // reliably to the standard location; and also because Maya requires + // this. maya_location.make_canonical(); maya_location = Filename::from_os_specific(maya_location.to_os_long_name()); } @@ -266,15 +264,15 @@ main(int argc, char *argv[]) { maya_location = standard_maya_location; } else if (maya_location != standard_maya_location) { - // If it *is* set, we verify that OpenMaya.dll matches the - // standard version. + // If it *is* set, we verify that OpenMaya.dll matches the standard + // version. Filename openmaya_given = Filename::dso_filename(Filename(maya_location, openmaya_filename)); Filename openmaya_standard = Filename::dso_filename(Filename(standard_maya_location, openmaya_filename)); if (openmaya_given != openmaya_standard) { #ifdef HAVE_OPENSSL - // If we have OpenSSL, we can use it to check the md5 hashes of - // the DLL. + // If we have OpenSSL, we can use it to check the md5 hashes of the + // DLL. HashVal hash_given, hash_standard; if (!hash_standard.hash_file(openmaya_standard)) { // Couldn't read the standard file, so use the given one. @@ -357,9 +355,9 @@ main(int argc, char *argv[]) { string sep = ":"; #endif - // Now set PYTHONHOME & PYTHONPATH. Maya2008 requires this to be - // set and pointing within $MAYA_LOCATION, or it might get itself - // confused with another Python installation (e.g. Panda's). + // Now set PYTHONHOME & PYTHONPATH. Maya2008 requires this to be set and + // pointing within $MAYA_LOCATION, or it might get itself confused with + // another Python installation (e.g. Panda's). Filename python = Filename(maya_location, "Python"); if (python.is_directory()) { { @@ -445,12 +443,12 @@ main(int argc, char *argv[]) { #endif // IS_OSX // When this is set, Panda3D will try not to use any functions from the - // CPython API. This is necessary because Maya links with its own copy - // of Python, which may be incompatible with ours. + // CPython API. This is necessary because Maya links with its own copy of + // Python, which may be incompatible with ours. putenv((char *)"PANDA_INCOMPATIBLE_PYTHON=1"); - // Now that we have set up the environment variables properly, chain - // to the actual maya2egg_bin (or whichever) executable. + // Now that we have set up the environment variables properly, chain to the + // actual maya2egg_bin (or whichever) executable. #ifdef _WIN32 // Windows case. diff --git a/pandatool/src/mayaprogs/normal_test.cxx b/pandatool/src/mayaprogs/normal_test.cxx index c6d7e2413b..e1015f2759 100644 --- a/pandatool/src/mayaprogs/normal_test.cxx +++ b/pandatool/src/mayaprogs/normal_test.cxx @@ -96,7 +96,7 @@ get_slider(MString slider_name) { cerr << "selected element is not a blend shape\n"; } } - + cerr << "Couldn't find slider " << slider_name << "\n"; exit(1); } @@ -162,7 +162,7 @@ get_mesh(MString mesh_name) { cerr << "selected element is not a mesh\n"; } } - + cerr << "Couldn't find mesh " << mesh_name << "\n"; exit(1); } @@ -172,7 +172,7 @@ output_vertices(const char *filename, MFnMesh &mesh) { MStatus status; MPointArray verts; - // status = mesh.getPoints(verts, MSpace::kObject); + // status = mesh.getPoints(verts, MSpace::kObject); status = mesh.getPoints(verts, MSpace::kWorld); if (!status) { status.perror("mesh.getPoints"); @@ -231,21 +231,21 @@ output_normals() { } */ } - + MItMeshPolygon faceIter(*_dag_path, component, &status); if( !status ) cerr << "Error at MItMeshPolygon" << endl; - + MFnMesh meshFn(*_dag_path); - + // Traverse the polygonal face for (; !faceIter.isDone();faceIter.next()) { int nVerts = faceIter.polygonVertexCount(); - + // Traverse the vertices to get their indexes and print out the normals for (int i = 0;i= 0x80. - // table_type = "const char "; + // Actually, declaring the table as "const char" causes VC7 to yell about + // truncating all of the values >= 0x80. table_type = "const char "; length_type = "const size_t "; } @@ -128,11 +121,9 @@ run() { << dec << count << ";\n\n"; } -//////////////////////////////////////////////////////////////////// -// Function: BinToC::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool BinToC:: handle_args(ProgramBase::Args &args) { if (args.size() == 2 && !_got_output_filename) { diff --git a/pandatool/src/miscprogs/binToC.h b/pandatool/src/miscprogs/binToC.h index bb8049b508..39eff76766 100644 --- a/pandatool/src/miscprogs/binToC.h +++ b/pandatool/src/miscprogs/binToC.h @@ -1,16 +1,15 @@ -// Filename: binToC.h -// Created by: drose (18Jul03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file binToC.h + * @author drose + * @date 2003-07-18 + */ #ifndef BINTOC_H #define BINTOC_H @@ -20,13 +19,11 @@ #include "programBase.h" #include "withOutputFile.h" -//////////////////////////////////////////////////////////////////// -// Class : BinToC -// Description : A utility program to read a (binary) file and output -// a table that can be compiled via a C compiler to -// generate the same data. Handy for portably importing -// binary data into a library or executable. -//////////////////////////////////////////////////////////////////// +/** + * A utility program to read a (binary) file and output a table that can be + * compiled via a C compiler to generate the same data. Handy for portably + * importing binary data into a library or executable. + */ class BinToC : public ProgramBase, public WithOutputFile { public: BinToC(); diff --git a/pandatool/src/objegg/config_objegg.cxx b/pandatool/src/objegg/config_objegg.cxx index 1d5647f0df..7896ab3013 100644 --- a/pandatool/src/objegg/config_objegg.cxx +++ b/pandatool/src/objegg/config_objegg.cxx @@ -1,16 +1,15 @@ -// Filename: config_objegg.cxx -// Created by: drose (07Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_objegg.cxx + * @author drose + * @date 2010-12-07 + */ #include "config_objegg.h" #include "dconfig.h" @@ -22,14 +21,12 @@ ConfigureFn(config_objegg) { init_libobjegg(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libobjegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libobjegg() { static bool initialized = false; @@ -38,4 +35,3 @@ init_libobjegg() { } initialized = true; } - diff --git a/pandatool/src/objegg/config_objegg.h b/pandatool/src/objegg/config_objegg.h index af1e74a326..179d647a66 100644 --- a/pandatool/src/objegg/config_objegg.h +++ b/pandatool/src/objegg/config_objegg.h @@ -1,16 +1,15 @@ -// Filename: config_objegg.h -// Created by: drose (07Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_objegg.h + * @author drose + * @date 2010-12-07 + */ #ifndef CONFIG_OBJEGG_H #define CONFIG_OBJEGG_H diff --git a/pandatool/src/objegg/eggToObjConverter.cxx b/pandatool/src/objegg/eggToObjConverter.cxx index 314785a83d..bd359e935a 100644 --- a/pandatool/src/objegg/eggToObjConverter.cxx +++ b/pandatool/src/objegg/eggToObjConverter.cxx @@ -1,16 +1,15 @@ -// Filename: eggToObjConverter.cxx -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToObjConverter.cxx + * @author drose + * @date 2012-12-19 + */ #include "eggToObjConverter.h" #include "config_objegg.h" @@ -24,87 +23,67 @@ #include "eggLine.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToObjConverter:: EggToObjConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToObjConverter:: EggToObjConverter(const EggToObjConverter ©) : EggToSomethingConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToObjConverter:: ~EggToObjConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ EggToSomethingConverter *EggToObjConverter:: make_copy() { return new EggToObjConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string EggToObjConverter:: get_name() const { return "obj"; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string EggToObjConverter:: get_extension() const { return "obj"; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently save -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently save compressed files + * (with a .pz extension), false otherwise. + */ bool EggToObjConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::write_file -// Access: Public, Virtual -// Description: Handles the conversion of the internal EggData to the -// target file format, written to the specified -// filename. -//////////////////////////////////////////////////////////////////// +/** + * Handles the conversion of the internal EggData to the target file format, + * written to the specified filename. + */ bool EggToObjConverter:: write_file(const Filename &filename) { clear_error(); @@ -119,11 +98,9 @@ write_file(const Filename &filename) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::process -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool EggToObjConverter:: process(const Filename &filename) { _egg_data->flatten_transforms(); @@ -163,14 +140,11 @@ process(const Filename &filename) { return success; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::collect_vertices -// Access: Private -// Description: Recursively walks the egg structure, looking for -// vertices referenced by polygons or points. Any such -// vertices are added to the vertex tables for writing -// to the obj file. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg structure, looking for vertices referenced by + * polygons or points. Any such vertices are added to the vertex tables for + * writing to the obj file. + */ void EggToObjConverter:: collect_vertices(EggNode *egg_node) { if (egg_node->is_of_type(EggPrimitive::get_class_type())) { @@ -190,13 +164,10 @@ collect_vertices(EggNode *egg_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::write_faces -// Access: Private -// Description: Recursively walks the egg structure again, this time -// writing out the face records for any polygons, -// points, or lines encountered. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg structure again, this time writing out the face + * records for any polygons, points, or lines encountered. + */ void EggToObjConverter:: write_faces(ostream &out, EggNode *egg_node) { if (egg_node->is_of_type(EggPrimitive::get_class_type())) { @@ -266,12 +237,9 @@ write_faces(ostream &out, EggNode *egg_node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::write_group_reference -// Access: Private -// Description: Writes the "g" tag to describe this polygon's group, -// if needed. -//////////////////////////////////////////////////////////////////// +/** + * Writes the "g" tag to describe this polygon's group, if needed. + */ void EggToObjConverter:: write_group_reference(ostream &out, EggNode *egg_node) { EggGroupNode *egg_group = egg_node->get_parent(); @@ -290,13 +258,10 @@ write_group_reference(ostream &out, EggNode *egg_node) { _current_group = egg_group; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::get_group_name -// Access: Private -// Description: Recursively determines the appropriate string to -// write for the "g" tag to describe a particular -// EggGroupNode. -//////////////////////////////////////////////////////////////////// +/** + * Recursively determines the appropriate string to write for the "g" tag to + * describe a particular EggGroupNode. + */ void EggToObjConverter:: get_group_name(string &group_name, EggGroupNode *egg_group) { string name = trim(egg_group->get_name()); @@ -320,12 +285,10 @@ get_group_name(string &group_name, EggGroupNode *egg_group) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::record_vertex -// Access: Private -// Description: Adds the indicated EggVertex to the unique vertex -// tables, for writing later by write_vertices(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated EggVertex to the unique vertex tables, for writing later + * by write_vertices(). + */ void EggToObjConverter:: record_vertex(EggVertex *vertex) { VertexDef &vdef = _vmap[vertex]; @@ -356,69 +319,54 @@ record_vertex(EggVertex *vertex) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::record_unique -// Access: Private -// Description: Records the indicated vertex value, returning the -// shared index if this value already appears elsewhere -// in the table, or the new unique index if this is the -// first time this value appears. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated vertex value, returning the shared index if this + * value already appears elsewhere in the table, or the new unique index if + * this is the first time this value appears. + */ int EggToObjConverter:: record_unique(UniqueVertices &unique, const LVecBase4d &vec) { - // We record a zero-based index. Note that we will actually write - // out a one-based index to the obj file, as required by the - // standard. + // We record a zero-based index. Note that we will actually write out a + // one-based index to the obj file, as required by the standard. int index = unique.size(); UniqueVertices::iterator ui = unique.insert(UniqueVertices::value_type(vec, index)).first; return (*ui).second; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::record_unique -// Access: Private -// Description: Records the indicated vertex value, returning the -// shared index if this value already appears elsewhere -// in the table, or the new unique index if this is the -// first time this value appears. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated vertex value, returning the shared index if this + * value already appears elsewhere in the table, or the new unique index if + * this is the first time this value appears. + */ int EggToObjConverter:: record_unique(UniqueVertices &unique, const LVecBase3d &vec) { return record_unique(unique, LVecBase4d(vec[0], vec[1], vec[2], 0.0)); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::record_unique -// Access: Private -// Description: Records the indicated vertex value, returning the -// shared index if this value already appears elsewhere -// in the table, or the new unique index if this is the -// first time this value appears. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated vertex value, returning the shared index if this + * value already appears elsewhere in the table, or the new unique index if + * this is the first time this value appears. + */ int EggToObjConverter:: record_unique(UniqueVertices &unique, const LVecBase2d &vec) { return record_unique(unique, LVecBase4d(vec[0], vec[1], 0.0, 0.0)); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::record_unique -// Access: Private -// Description: Records the indicated vertex value, returning the -// shared index if this value already appears elsewhere -// in the table, or the new unique index if this is the -// first time this value appears. -//////////////////////////////////////////////////////////////////// +/** + * Records the indicated vertex value, returning the shared index if this + * value already appears elsewhere in the table, or the new unique index if + * this is the first time this value appears. + */ int EggToObjConverter:: record_unique(UniqueVertices &unique, double pos) { return record_unique(unique, LVecBase4d(pos, 0.0, 0.0, 0.0)); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::write_vertices -// Access: Private -// Description: Actually writes the vertex values recorded in the -// indicated table to the obj output stream. -//////////////////////////////////////////////////////////////////// +/** + * Actually writes the vertex values recorded in the indicated table to the + * obj output stream. + */ void EggToObjConverter:: write_vertices(ostream &out, const string &prefix, int num_components, const UniqueVertices &unique) { @@ -446,11 +394,9 @@ write_vertices(ostream &out, const string &prefix, int num_components, PANDA_FREE_ARRAY(vertices); } -//////////////////////////////////////////////////////////////////// -// Function: EggToObjConverter::VertexDef::Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToObjConverter::VertexDef:: VertexDef() : _vert3_index(-1), diff --git a/pandatool/src/objegg/eggToObjConverter.h b/pandatool/src/objegg/eggToObjConverter.h index 6aa191e781..a36fa77500 100644 --- a/pandatool/src/objegg/eggToObjConverter.h +++ b/pandatool/src/objegg/eggToObjConverter.h @@ -1,16 +1,15 @@ -// Filename: eggToObjConverter.h -// Created by: drose (19Dec12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToObjConverter.h + * @author drose + * @date 2012-12-19 + */ #ifndef EGGTOOBJCONVERTER_H #define EGGTOOBJCONVERTER_H @@ -21,10 +20,9 @@ #include "eggVertexPool.h" #include "eggGroup.h" -//////////////////////////////////////////////////////////////////// -// Class : EggToObjConverter -// Description : Convert an obj file to egg data. -//////////////////////////////////////////////////////////////////// +/** + * Convert an obj file to egg data. + */ class EggToObjConverter : public EggToSomethingConverter { public: EggToObjConverter(); @@ -65,7 +63,7 @@ private: int record_unique(UniqueVertices &unique, const LVecBase2d &vec); int record_unique(UniqueVertices &unique, double pos); - void write_vertices(ostream &out, const string &prefix, int num_components, + void write_vertices(ostream &out, const string &prefix, int num_components, const UniqueVertices &unique); private: diff --git a/pandatool/src/objegg/objToEggConverter.I b/pandatool/src/objegg/objToEggConverter.I index 104c8898f0..c8a2d629a7 100644 --- a/pandatool/src/objegg/objToEggConverter.I +++ b/pandatool/src/objegg/objToEggConverter.I @@ -1,24 +1,19 @@ -// Filename: objToEggConverter.I -// Created by: drose (03Jan13) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file objToEggConverter.I + * @author drose + * @date 2013-01-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexEntry::operator < -// Access: Public -// Description: Provides a unique but arbitrary ordering for -// VertexEntry objects in a map. -//////////////////////////////////////////////////////////////////// +/** + * Provides a unique but arbitrary ordering for VertexEntry objects in a map. + */ INLINE bool ObjToEggConverter::VertexEntry:: operator < (const VertexEntry &other) const { if (_vi != other._vi) { @@ -28,9 +23,8 @@ operator < (const VertexEntry &other) const { return _vti < other._vti; } - // It's important that these two tests are made last, so we can find - // the first vertex that has any normal but also matches the above - // properties. + // It's important that these two tests are made last, so we can find the + // first vertex that has any normal but also matches the above properties. if (_vni != other._vni) { return _vni < other._vni; } @@ -40,23 +34,19 @@ operator < (const VertexEntry &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexEntry::operator == -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool ObjToEggConverter::VertexEntry:: operator == (const VertexEntry &other) const { return (_vi == other._vi && _vti == other._vti && _vni == other._vni && _synth_vni == other._synth_vni); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexEntry::matches_except_normal -// Access: Public -// Description: Returns true if all the properties except _vni and _synth_vni -// are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all the properties except _vni and _synth_vni are + * equivalent. + */ INLINE bool ObjToEggConverter::VertexEntry:: matches_except_normal(const VertexEntry &other) const { return (_vi == other._vi && _vti == other._vti); diff --git a/pandatool/src/objegg/objToEggConverter.cxx b/pandatool/src/objegg/objToEggConverter.cxx index 66949fe10f..c6df68710c 100644 --- a/pandatool/src/objegg/objToEggConverter.cxx +++ b/pandatool/src/objegg/objToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: objToEggConverter.cxx -// Created by: drose (07Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file objToEggConverter.cxx + * @author drose + * @date 2010-12-07 + */ #include "objToEggConverter.h" #include "config_objegg.h" @@ -28,103 +27,79 @@ #include "triangulator3.h" #include "config_egg2pg.h" -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ObjToEggConverter:: ObjToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ObjToEggConverter:: ObjToEggConverter(const ObjToEggConverter ©) : SomethingToEggConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ObjToEggConverter:: ~ObjToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *ObjToEggConverter:: make_copy() { return new ObjToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string ObjToEggConverter:: get_name() const { return "obj"; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string ObjToEggConverter:: get_extension() const { return "obj"; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool ObjToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::supports_convert_to_node -// Access: Published, Virtual -// Description: Returns true if this converter can directly convert -// the model type to internal Panda memory structures, -// given the indicated options, or false otherwise. If -// this returns true, then convert_to_node() may be -// called to perform the conversion, which may be faster -// than calling convert_file() if the ultimate goal is a -// PandaNode anyway. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this converter can directly convert the model type to + * internal Panda memory structures, given the indicated options, or false + * otherwise. If this returns true, then convert_to_node() may be called to + * perform the conversion, which may be faster than calling convert_file() if + * the ultimate goal is a PandaNode anyway. + */ bool ObjToEggConverter:: supports_convert_to_node(const LoaderOptions &options) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + */ bool ObjToEggConverter:: convert_file(const Filename &filename) { clear_error(); @@ -139,15 +114,12 @@ convert_file(const Filename &filename) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::convert_to_node -// Access: Public, Virtual -// Description: Reads the input file and directly produces a -// ready-to-render model file as a PandaNode. Returns -// NULL on failure, or if it is not supported. (This -// functionality is not supported by all converter -// types; see supports_convert_to_node()). -//////////////////////////////////////////////////////////////////// +/** + * Reads the input file and directly produces a ready-to-render model file as + * a PandaNode. Returns NULL on failure, or if it is not supported. (This + * functionality is not supported by all converter types; see + * supports_convert_to_node()). + */ PT(PandaNode) ObjToEggConverter:: convert_to_node(const LoaderOptions &options, const Filename &filename) { clear_error(); @@ -169,11 +141,9 @@ convert_to_node(const LoaderOptions &options, const Filename &filename) { return _root_node; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process -// Access: Protected -// Description: Reads the file and converts it to egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Reads the file and converts it to egg structures. + */ bool ObjToEggConverter:: process(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -245,11 +215,9 @@ process(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_line -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_line(const string &line) { vector_string words; @@ -282,16 +250,14 @@ process_line(const string &line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_line -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_ref_plane_res(const string &line) { - // the #_ref_plane_res line is a DRZ extension that defines the - // pixel resolution of the projector device. It's needed to - // properly scale the xvt lines. + // the #_ref_plane_res line is a DRZ extension that defines the pixel + // resolution of the projector device. It's needed to properly scale the + // xvt lines. vector_string words; tokenize(line, words, " \t", true); @@ -317,11 +283,9 @@ process_ref_plane_res(const string &line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_v -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_v(vector_string &words) { if (words.size() != 4 && words.size() != 5 && @@ -351,8 +315,7 @@ process_v(vector_string &words) { _v_table.push_back(pos); - // Meshlab format might include an RGB color following the vertex - // position. + // Meshlab format might include an RGB color following the vertex position. if (words.size() == 7 && words.size() == 8) { size_t si = words.size(); LVecBase3d rgb; @@ -374,11 +337,9 @@ process_v(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_vt -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_vt(vector_string &words) { if (words.size() != 3 && words.size() != 4) { @@ -409,14 +370,11 @@ process_vt(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_xvt -// Access: Protected -// Description: "xvt" is an extended column invented by DRZ. It -// includes texture coordinates in pixel space of the -// projector device, as well as for each camera. We map -// it to the nominal texture coordinates here. -//////////////////////////////////////////////////////////////////// +/** + * "xvt" is an extended column invented by DRZ. It includes texture + * coordinates in pixel space of the projector device, as well as for each + * camera. We map it to the nominal texture coordinates here. + */ bool ObjToEggConverter:: process_xvt(vector_string &words) { if (words.size() < 3) { @@ -444,22 +402,17 @@ process_xvt(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_xvc -// Access: Protected -// Description: "xvc" is another extended column invented by DRZ. We -// quietly ignore it. -//////////////////////////////////////////////////////////////////// +/** + * "xvc" is another extended column invented by DRZ. We quietly ignore it. + */ bool ObjToEggConverter:: process_xvc(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_vn -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_vn(vector_string &words) { if (words.size() != 4) { @@ -486,11 +439,9 @@ process_vn(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_f -// Access: Protected -// Description: Defines a face in the obj file. -//////////////////////////////////////////////////////////////////// +/** + * Defines a face in the obj file. + */ bool ObjToEggConverter:: process_f(vector_string &words) { _f_given = true; @@ -508,18 +459,16 @@ process_f(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_g -// Access: Protected -// Description: Defines a group in the obj file. -//////////////////////////////////////////////////////////////////// +/** + * Defines a group in the obj file. + */ bool ObjToEggConverter:: process_g(vector_string &words) { EggGroup *group = _root_group; - // We assume the group names define a hierarchy of more-specific to - // less-specific group names, so that the first group name is the - // bottommost node, and the last group name is the topmost node. + // We assume the group names define a hierarchy of more-specific to less- + // specific group names, so that the first group name is the bottommost + // node, and the last group name is the topmost node. // Thus, iterate from the back to the front. size_t i = words.size(); @@ -537,12 +486,10 @@ process_g(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::get_face_vertex -// Access: Protected -// Description: Returns or creates a vertex in the vpool according to -// the indicated face reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns or creates a vertex in the vpool according to the indicated face + * reference. + */ EggVertex *ObjToEggConverter:: get_face_vertex(const string &reference) { VertexEntry entry(this, reference); @@ -587,13 +534,10 @@ get_face_vertex(const string &reference) { return _vpool->create_unique_vertex(synth); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::generate_egg_points -// Access: Protected -// Description: If an obj file defines no faces, create a bunch of -// EggVertex objects to illustrate the vertex positions -// at least. -//////////////////////////////////////////////////////////////////// +/** + * If an obj file defines no faces, create a bunch of EggVertex objects to + * illustrate the vertex positions at least. + */ void ObjToEggConverter:: generate_egg_points() { for (size_t vi = 0; vi < _v_table.size(); ++vi) { @@ -603,11 +547,9 @@ generate_egg_points() { } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_node -// Access: Protected -// Description: Reads the file and converts it to PandaNode structures. -//////////////////////////////////////////////////////////////////// +/** + * Reads the file and converts it to PandaNode structures. + */ bool ObjToEggConverter:: process_node(const Filename &filename) { VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); @@ -663,11 +605,9 @@ process_node(const Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_line_node -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool ObjToEggConverter:: process_line_node(const string &line) { vector_string words; @@ -700,11 +640,9 @@ process_line_node(const string &line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_f_node -// Access: Protected -// Description: Defines a face in the obj file. -//////////////////////////////////////////////////////////////////// +/** + * Defines a face in the obj file. + */ bool ObjToEggConverter:: process_f_node(vector_string &words) { _f_given = true; @@ -768,7 +706,8 @@ process_f_node(vector_string &words) { if (_current_vertex_data->_prim->get_num_vertices() + 3 * num_tris > egg_max_indices || _current_vertex_data->_entries.size() + verts.size() > egg_max_vertices) { - // We'll exceed our specified limit with these triangles; start a new Geom. + // We'll exceed our specified limit with these triangles; start a new + // Geom. _current_vertex_data->close_geom(this); } @@ -789,11 +728,9 @@ process_f_node(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::process_g_node -// Access: Protected -// Description: Defines a group in the obj file. -//////////////////////////////////////////////////////////////////// +/** + * Defines a group in the obj file. + */ bool ObjToEggConverter:: process_g_node(vector_string &words) { _current_vertex_data->close_geom(this); @@ -802,9 +739,9 @@ process_g_node(vector_string &words) { NodePath np(_root_node); - // We assume the group names define a hierarchy of more-specific to - // less-specific group names, so that the first group name is the - // bottommost node, and the last group name is the topmost node. + // We assume the group names define a hierarchy of more-specific to less- + // specific group names, so that the first group name is the bottommost + // node, and the last group name is the topmost node. // Thus, iterate from the back to the front. size_t i = words.size(); @@ -829,13 +766,10 @@ process_g_node(vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::generate_points -// Access: Protected -// Description: If an obj file defines no faces, create a bunch of -// GeomPoints to illustrate the vertex positions at -// least. -//////////////////////////////////////////////////////////////////// +/** + * If an obj file defines no faces, create a bunch of GeomPoints to illustrate + * the vertex positions at least. + */ void ObjToEggConverter:: generate_points() { CPT(GeomVertexFormat) format = GeomVertexFormat::get_v3(); @@ -860,13 +794,10 @@ generate_points() { _root_node->add_child(geom_node); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::add_synth_normal -// Access: Private -// Description: Adds a new normal to the synth_vn table, or returns -// an existing normal. In either case returns the -// 1-based index number to the normal. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new normal to the synth_vn table, or returns an existing normal. In + * either case returns the 1-based index number to the normal. + */ int ObjToEggConverter:: add_synth_normal(const LVecBase3d &normal) { pair result = _unique_synth_vn_table.insert(UniqueVec3Table::value_type(normal, _unique_synth_vn_table.size())); @@ -874,20 +805,18 @@ add_synth_normal(const LVecBase3d &normal) { int index = (*ni).second; if (result.second) { - // If the normal was added to the table, it's a unique normal, and - // now we have to add it to the table too. + // If the normal was added to the table, it's a unique normal, and now we + // have to add it to the table too. _synth_vn_table.push_back(normal); } return index + 1; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexEntry::Constructor -// Access: Public -// Description: Creates a VertexEntry from the n/n/n string format in -// the obj file face reference. -//////////////////////////////////////////////////////////////////// +/** + * Creates a VertexEntry from the n/n/n string format in the obj file face + * reference. + */ ObjToEggConverter::VertexEntry:: VertexEntry(const ObjToEggConverter *converter, const string &obj_vertex) { _vi = 0; @@ -943,11 +872,9 @@ VertexEntry(const ObjToEggConverter *converter, const string &obj_vertex) { } } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ObjToEggConverter::VertexData:: VertexData(PandaNode *parent, const string &name) : _parent(parent), _name(name) @@ -963,13 +890,10 @@ VertexData(PandaNode *parent, const string &name) : _prim = new GeomTriangles(GeomEnums::UH_static); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexData::add_vertex -// Access: Public -// Description: Adds a new entry to the vertex data for the indicated -// VertexEntry, or returns an equivalent vertex already -// present. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new entry to the vertex data for the indicated VertexEntry, or + * returns an equivalent vertex already present. + */ int ObjToEggConverter::VertexData:: add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { pair result; @@ -977,15 +901,15 @@ add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { int index; if (entry._vni != 0 || entry._synth_vni != 0) { - // If we are storing a vertex with a normal, see if we - // have already stored a vertex without a normal first. + // If we are storing a vertex with a normal, see if we have already stored + // a vertex without a normal first. VertexEntry no_normal(entry); no_normal._vni = 0; no_normal._synth_vni = 0; ni = _unique_entries.find(no_normal); if (ni != _unique_entries.end()) { - // We did have such a vertex! In this case, repurpose this - // vertex, resetting it to contain this normal. + // We did have such a vertex! In this case, repurpose this vertex, + // resetting it to contain this normal. index = (*ni).second; _unique_entries.erase(ni); result = _unique_entries.insert(UniqueVertexEntries::value_type(entry, index)); @@ -996,8 +920,8 @@ add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { return index; } } else if (entry._vni == 0 && entry._synth_vni == 0) { - // If we are storing a vertex *without* any normal, see if we have - // already stored a vertex with a normal first. + // If we are storing a vertex *without* any normal, see if we have already + // stored a vertex with a normal first. ni = _unique_entries.lower_bound(entry); if (ni != _unique_entries.end() && (*ni).first.matches_except_normal(entry)) { // We had such a vertex, so use it. @@ -1006,15 +930,15 @@ add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { } } - // We didn't already have a vertex we could repurpose, so try to add - // exactly the desired vertex. + // We didn't already have a vertex we could repurpose, so try to add exactly + // the desired vertex. result = _unique_entries.insert(UniqueVertexEntries::value_type(entry, _entries.size())); ni = result.first; index = (*ni).second; if (result.second) { - // If the vertex was added to the table, it's a unique vertex, and - // now we have to add it to the vertex data too. + // If the vertex was added to the table, it's a unique vertex, and now we + // have to add it to the vertex data too. _entries.push_back(entry); if (converter->_v4_given) { @@ -1041,14 +965,11 @@ add_vertex(const ObjToEggConverter *converter, const VertexEntry &entry) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexData::add_triangle -// Access: Public -// Description: Adds a triangle to the primitive, as a triple of -// three VertexEntry objects, which are each added to -// the vertex pool. If synth_vni is not 0, it is -// assigned to the last vertex. -//////////////////////////////////////////////////////////////////// +/** + * Adds a triangle to the primitive, as a triple of three VertexEntry objects, + * which are each added to the vertex pool. If synth_vni is not 0, it is + * assigned to the last vertex. + */ void ObjToEggConverter::VertexData:: add_triangle(const ObjToEggConverter *converter, const VertexEntry &v0, const VertexEntry &v1, const VertexEntry &v2, @@ -1070,17 +991,14 @@ add_triangle(const ObjToEggConverter *converter, const VertexEntry &v0, _prim->close_primitive(); } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEggConverter::VertexData::close_geom -// Access: Public -// Description: Finishes the current geom and stores it as a child -// in the root. Prepares for new geoms. -//////////////////////////////////////////////////////////////////// +/** + * Finishes the current geom and stores it as a child in the root. Prepares + * for new geoms. + */ void ObjToEggConverter::VertexData:: close_geom(const ObjToEggConverter *converter) { if (_prim->get_num_vertices() != 0) { - // Create a new format that includes only the columns we actually - // used. + // Create a new format that includes only the columns we actually used. PT(GeomVertexArrayFormat) aformat = new GeomVertexArrayFormat; if (_v4_given) { aformat->add_column(InternalName::get_vertex(), 4, @@ -1141,8 +1059,8 @@ close_geom(const ObjToEggConverter *converter) { normal_writer.set_row(i); normal_writer.add_data3d(converter->_synth_vn_table[entry._synth_vni - 1]); } else { - // In this case, the normal isn't used and doesn't matter; we - // fill it in a unit vector just for neatness. + // In this case, the normal isn't used and doesn't matter; we fill it + // in a unit vector just for neatness. normal_writer.set_row(i); normal_writer.add_data3d(0, 0, 1); } @@ -1165,8 +1083,7 @@ close_geom(const ObjToEggConverter *converter) { state = state->add_attrib(ColorAttrib::make_flat(LColor(1, 1, 1, 1))); } if (!_vn_given) { - // We have synthesized these normals; specify the flat-shading - // attrib. + // We have synthesized these normals; specify the flat-shading attrib. state = state->add_attrib(ShadeModelAttrib::make(ShadeModelAttrib::M_flat)); _prim->set_shade_model(GeomEnums::SM_flat_last_vertex); } diff --git a/pandatool/src/objegg/objToEggConverter.h b/pandatool/src/objegg/objToEggConverter.h index 7362cbf44d..062f08c6cd 100644 --- a/pandatool/src/objegg/objToEggConverter.h +++ b/pandatool/src/objegg/objToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: objToEggConverter.h -// Created by: drose (07Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file objToEggConverter.h + * @author drose + * @date 2010-12-07 + */ #ifndef OBJTOEGGCONVERTER_H #define OBJTOEGGCONVERTER_H @@ -28,10 +27,9 @@ #include "pvector.h" #include "epvector.h" -//////////////////////////////////////////////////////////////////// -// Class : ObjToEggConverter -// Description : Convert an Obj file to egg data. -//////////////////////////////////////////////////////////////////// +/** + * Convert an Obj file to egg data. + */ class ObjToEggConverter : public SomethingToEggConverter { public: ObjToEggConverter(); @@ -109,9 +107,8 @@ protected: INLINE bool operator == (const VertexEntry &other) const; INLINE bool matches_except_normal(const VertexEntry &other) const; - // The 1-based vertex, texcoord, and normal index numbers - // appearing in the obj file for this vertex. 0 if the index - // number is not given. + // The 1-based vertex, texcoord, and normal index numbers appearing in the + // obj file for this vertex. 0 if the index number is not given. int _vi, _vti, _vni; // The 1-based index number to the synthesized normal, if needed. diff --git a/pandatool/src/objprogs/eggToObj.cxx b/pandatool/src/objprogs/eggToObj.cxx index 8bfbe67790..a3f7a79171 100644 --- a/pandatool/src/objprogs/eggToObj.cxx +++ b/pandatool/src/objprogs/eggToObj.cxx @@ -1,16 +1,15 @@ -// Filename: eggToObj.cxx -// Created by: drose (28Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToObj.cxx + * @author drose + * @date 2012-02-28 + */ #include "eggToObj.h" #include "pystub.h" @@ -19,11 +18,9 @@ #include "dcast.h" #include "string_utils.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToObj::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToObj:: EggToObj() : EggToSomething("Obj", ".obj", true, false) @@ -48,11 +45,9 @@ EggToObj() : _got_coordinate_system = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggToObj::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToObj:: run() { if (_triangulate_polygons) { @@ -70,14 +65,11 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggToObj::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool EggToObj:: handle_args(ProgramBase::Args &args) { return EggToSomething::handle_args(args); diff --git a/pandatool/src/objprogs/eggToObj.h b/pandatool/src/objprogs/eggToObj.h index 5719e23893..b3a50215f3 100644 --- a/pandatool/src/objprogs/eggToObj.h +++ b/pandatool/src/objprogs/eggToObj.h @@ -1,16 +1,15 @@ -// Filename: eggToObj.h -// Created by: drose (25Feb12) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToObj.h + * @author drose + * @date 2012-02-25 + */ #ifndef EGGTOOBJ_H #define EGGTOOBJ_H @@ -19,10 +18,9 @@ #include "eggToSomething.h" #include "eggToObjConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : EggToObj -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class EggToObj : public EggToSomething { public: EggToObj(); diff --git a/pandatool/src/objprogs/objToEgg.cxx b/pandatool/src/objprogs/objToEgg.cxx index e670bf7ea5..db551440ae 100644 --- a/pandatool/src/objprogs/objToEgg.cxx +++ b/pandatool/src/objprogs/objToEgg.cxx @@ -1,27 +1,24 @@ -// Filename: objToEgg.cxx -// Created by: drose (04May04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file objToEgg.cxx + * @author drose + * @date 2004-05-04 + */ #include "objToEgg.h" #include "objToEggConverter.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: ObjToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ObjToEgg:: ObjToEgg() : SomethingToEgg("obj", ".obj") @@ -45,11 +42,9 @@ ObjToEgg() : _coordinate_system = CS_zup_right; } -//////////////////////////////////////////////////////////////////// -// Function: ObjToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void ObjToEgg:: run() { nout << "Reading " << _input_filename << "\n"; diff --git a/pandatool/src/objprogs/objToEgg.h b/pandatool/src/objprogs/objToEgg.h index 98786d25f0..310a5d0749 100644 --- a/pandatool/src/objprogs/objToEgg.h +++ b/pandatool/src/objprogs/objToEgg.h @@ -1,17 +1,16 @@ -// Filename: objToEgg.h -// Created by: drose (07Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file objToEgg.h + * @author drose + * @date 2010-12-07 + */ + #ifndef OBJTOEGG_H #define OBJTOEGG_H @@ -20,11 +19,9 @@ #include "somethingToEgg.h" #include "objToEggConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : ObjToEgg -// Description : A program to read a Obj file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a Obj file and generate an egg file. + */ class ObjToEgg : public SomethingToEgg { public: ObjToEgg(); diff --git a/pandatool/src/palettizer/config_palettizer.cxx b/pandatool/src/palettizer/config_palettizer.cxx index e997984a49..160fb9227c 100644 --- a/pandatool/src/palettizer/config_palettizer.cxx +++ b/pandatool/src/palettizer/config_palettizer.cxx @@ -1,16 +1,15 @@ -// Filename: config_palettizer.cxx -// Created by: drose (12Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_palettizer.cxx + * @author drose + * @date 2003-09-12 + */ #include "config_palettizer.h" #include "palettizer.h" @@ -36,14 +35,12 @@ ConfigureFn(config_palettizer) { init_palettizer(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libpalettizer -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_palettizer() { static bool initialized = false; @@ -67,8 +64,8 @@ init_palettizer() { TexturePosition::init_type(); PalettePage::init_type(); - // Registration of writable object's creation functions with - // BamReader's factory + // Registration of writable object's creation functions with BamReader's + // factory Palettizer::register_with_read_factory(); EggFile::register_with_read_factory(); PaletteGroup::register_with_read_factory(); diff --git a/pandatool/src/palettizer/config_palettizer.h b/pandatool/src/palettizer/config_palettizer.h index 4369a6fcd9..7754fe572d 100644 --- a/pandatool/src/palettizer/config_palettizer.h +++ b/pandatool/src/palettizer/config_palettizer.h @@ -1,16 +1,15 @@ -// Filename: config_palettizer.h -// Created by: drose (12Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_palettizer.h + * @author drose + * @date 2003-09-12 + */ #ifndef CONFIG_PALETTIZER_H #define CONFIG_PALETTIZER_H diff --git a/pandatool/src/palettizer/destTextureImage.cxx b/pandatool/src/palettizer/destTextureImage.cxx index e250edb59b..757772912e 100644 --- a/pandatool/src/palettizer/destTextureImage.cxx +++ b/pandatool/src/palettizer/destTextureImage.cxx @@ -1,16 +1,15 @@ -// Filename: destTextureImage.cxx -// Created by: drose (05Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file destTextureImage.cxx + * @author drose + * @date 2000-12-05 + */ #include "destTextureImage.h" #include "sourceTextureImage.h" @@ -26,21 +25,16 @@ TypeHandle DestTextureImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::Default Constructor -// Access: Private -// Description: The default constructor is only for the convenience -// of the Bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the Bam reader. + */ DestTextureImage:: DestTextureImage() { } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ DestTextureImage:: DestTextureImage(TexturePlacement *placement) { TextureImage *texture = placement->get_texture(); @@ -62,12 +56,9 @@ DestTextureImage(TexturePlacement *placement) { set_filename(placement->get_group(), texture->get_name()); } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::copy -// Access: Public -// Description: Unconditionally copies the source texture into the -// appropriate filename. -//////////////////////////////////////////////////////////////////// +/** + * Unconditionally copies the source texture into the appropriate filename. + */ void DestTextureImage:: copy(TextureImage *texture) { const PNMImage &source_image = texture->read_source_image(); @@ -91,14 +82,11 @@ copy(TextureImage *texture) { texture->release_source_image(); } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::copy_if_stale -// Access: Public -// Description: Copies the source texture into the appropriate -// filename only if the indicated old reference, which -// represents the way it was last copied, is now -// out-of-date. -//////////////////////////////////////////////////////////////////// +/** + * Copies the source texture into the appropriate filename only if the + * indicated old reference, which represents the way it was last copied, is + * now out-of-date. + */ void DestTextureImage:: copy_if_stale(const DestTextureImage *other, TextureImage *texture) { if (other->get_x_size() != get_x_size() || @@ -117,12 +105,9 @@ copy_if_stale(const DestTextureImage *other, TextureImage *texture) { } } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::to_power_2 -// Access: Private, Static -// Description: Returns the largest power of 2 less than or equal to -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the largest power of 2 less than or equal to value. + */ int DestTextureImage:: to_power_2(int value) { int x = 1; @@ -132,38 +117,29 @@ to_power_2(int value) { return x; } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void DestTextureImage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_DestTextureImage); } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void DestTextureImage:: write_datagram(BamWriter *writer, Datagram &datagram) { ImageFile::write_datagram(writer, datagram); } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::make_DestTextureImage -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* DestTextureImage:: make_DestTextureImage(const FactoryParams ¶ms) { DestTextureImage *me = new DestTextureImage; @@ -175,13 +151,10 @@ make_DestTextureImage(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: DestTextureImage::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void DestTextureImage:: fillin(DatagramIterator &scan, BamReader *manager) { ImageFile::fillin(scan, manager); diff --git a/pandatool/src/palettizer/destTextureImage.h b/pandatool/src/palettizer/destTextureImage.h index cf872ab0c4..0916661c6c 100644 --- a/pandatool/src/palettizer/destTextureImage.h +++ b/pandatool/src/palettizer/destTextureImage.h @@ -1,16 +1,15 @@ -// Filename: destTextureImage.h -// Created by: drose (05Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file destTextureImage.h + * @author drose + * @date 2000-12-05 + */ #ifndef DESTTEXTUREIMAGE_H #define DESTTEXTUREIMAGE_H @@ -22,12 +21,10 @@ class TexturePlacement; class TextureImage; -//////////////////////////////////////////////////////////////////// -// Class : DestTextureImage -// Description : This represents a texture filename as it has been -// resized and copied to the map directory (e.g. for an -// unplaced texture). -//////////////////////////////////////////////////////////////////// +/** + * This represents a texture filename as it has been resized and copied to the + * map directory (e.g. for an unplaced texture). + */ class DestTextureImage : public ImageFile { private: DestTextureImage(); @@ -75,4 +72,3 @@ operator << (ostream &out, const DestTextureImage &dest) { } #endif - diff --git a/pandatool/src/palettizer/eggFile.cxx b/pandatool/src/palettizer/eggFile.cxx index 0aa490af9e..86e7bb1a6e 100644 --- a/pandatool/src/palettizer/eggFile.cxx +++ b/pandatool/src/palettizer/eggFile.cxx @@ -1,16 +1,15 @@ -// Filename: eggFile.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFile.cxx + * @author drose + * @date 2000-11-29 + */ #include "eggFile.h" #include "textureImage.h" @@ -37,11 +36,9 @@ TypeHandle EggFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: EggFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggFile:: EggFile() { _data = (EggData *)NULL; @@ -52,13 +49,10 @@ EggFile() { _had_data = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::from_command_line -// Access: Public -// Description: Accepts the information about the egg file as -// supplied from the command line. Returns true if the -// egg file is valid, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Accepts the information about the egg file as supplied from the command + * line. Returns true if the egg file is valid, false otherwise. + */ bool EggFile:: from_command_line(EggData *data, const Filename &source_filename, @@ -68,48 +62,42 @@ from_command_line(EggData *data, _had_data = true; remove_backstage(_data); - // We save the current directory at the time the egg file appeared - // on the command line, so that we'll later be able to properly - // resolve external references (like textures) that might be - // relative to this directory. + // We save the current directory at the time the egg file appeared on the + // command line, so that we'll later be able to properly resolve external + // references (like textures) that might be relative to this directory. _current_directory = ExecutionEnvironment::get_cwd(); _source_filename = source_filename; _source_filename.make_absolute(); _dest_filename = dest_filename; _dest_filename.make_absolute(); - // We also save the command line that loaded this egg file, so we - // can continue to write it as a comment to the beginning of the egg - // file, should we need to rewrite it later. + // We also save the command line that loaded this egg file, so we can + // continue to write it as a comment to the beginning of the egg file, + // should we need to rewrite it later. _egg_comment = egg_comment; - // We save the default PaletteGroup at this point, because the egg - // file inherits the default group that was in effect when it was - // specified on the command line. + // We save the default PaletteGroup at this point, because the egg file + // inherits the default group that was in effect when it was specified on + // the command line. _default_group = pal->get_default_group(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::get_source_filename -// Access: Public -// Description: Returns the filename this egg file was read from. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename this egg file was read from. + */ const Filename &EggFile:: get_source_filename() const { return _source_filename; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::scan_textures -// Access: Public -// Description: Scans the egg file for texture references and updates -// the _textures list appropriately. This assumes the -// egg file was supplied on the command line and thus -// the _data member is available. -//////////////////////////////////////////////////////////////////// +/** + * Scans the egg file for texture references and updates the _textures list + * appropriately. This assumes the egg file was supplied on the command line + * and thus the _data member is available. + */ void EggFile:: scan_textures() { nassertv(_data != (EggData *)NULL); @@ -117,12 +105,12 @@ scan_textures() { // Extract the set of textures referenced by this egg file. EggTextureCollection tc; tc.find_used_textures(_data); - + // Make sure each tref name is unique within a given file. tc.uniquify_trefs(); - // Now build up a list of new TextureReference objects that - // represent the textures actually used and their uv range, etc. + // Now build up a list of new TextureReference objects that represent the + // textures actually used and their uv range, etc. Textures new_textures; EggTextureCollection::iterator eti; @@ -133,9 +121,9 @@ scan_textures() { ref->from_egg(this, _data, egg_tex); if (!ref->has_uvs()) { - // This texture isn't *really* referenced. (Usually this - // happens if the texture is only referenced by "backstage" - // geometry, which we don't care about.) + // This texture isn't *really* referenced. (Usually this happens if the + // texture is only referenced by "backstage" geometry, which we don't + // care about.) delete ref; } else { @@ -143,14 +131,14 @@ scan_textures() { } } - // Sort the new references into order so we can compare them with - // the original references. - sort(new_textures.begin(), new_textures.end(), + // Sort the new references into order so we can compare them with the + // original references. + sort(new_textures.begin(), new_textures.end(), IndirectLess()); - - // Sort the original references too. This should already be sorted - // from the previous run, but we might as well be neurotic about it. - sort(_textures.begin(), _textures.end(), + + // Sort the original references too. This should already be sorted from the + // previous run, but we might as well be neurotic about it. + sort(_textures.begin(), _textures.end(), IndirectLess()); // Now go through and merge the lists. @@ -163,23 +151,22 @@ scan_textures() { TextureReference *bref = (*bi); if ((*aref) < (*bref)) { - // Here's a texture reference in the original list, but not in - // the new list. Remove it. + // Here's a texture reference in the original list, but not in the new + // list. Remove it. delete aref; ++ai; } else if ((*bref) < (*aref)) { - // Here's a texture reference in the new list, but not in the - // original list. Add it. + // Here's a texture reference in the new list, but not in the original + // list. Add it. combined_textures.push_back(bref); ++bi; } else { // (*bref) == (*aref) // Here's a texture reference that was in both lists. Compare it. if (aref->is_equivalent(*bref)) { - // It hasn't changed substantially, so keep the original - // (which still has the placement references from a previous - // pass). + // It hasn't changed substantially, so keep the original (which still + // has the placement references from a previous pass). aref->from_egg_quick(*bref); combined_textures.push_back(aref); delete bref; @@ -196,16 +183,16 @@ scan_textures() { while (bi != new_textures.end()) { TextureReference *bref = (*bi); - // Here's a texture reference in the new list, but not in the - // original list. Add it. + // Here's a texture reference in the new list, but not in the original + // list. Add it. combined_textures.push_back(bref); ++bi; } while (ai != _textures.end()) { TextureReference *aref = (*ai); - // Here's a texture reference in the original list, but not in - // the new list. Remove it. + // Here's a texture reference in the original list, but not in the new + // list. Remove it. delete aref; ++ai; } @@ -213,15 +200,12 @@ scan_textures() { _textures.swap(combined_textures); } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::get_textures -// Access: Public -// Description: Fills up the indicated set with the set of textures -// referenced by this egg file. It is the user's -// responsibility to ensure the set is empty before -// making this call; otherwise, the new textures will be -// appended to the existing set. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the indicated set with the set of textures referenced by this egg + * file. It is the user's responsibility to ensure the set is empty before + * making this call; otherwise, the new textures will be appended to the + * existing set. + */ void EggFile:: get_textures(pset &result) const { Textures::const_iterator ti; @@ -230,32 +214,26 @@ get_textures(pset &result) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::pre_txa_file -// Access: Public -// Description: Does some processing prior to scanning the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Does some processing prior to scanning the .txa file. + */ void EggFile:: pre_txa_file() { _is_surprise = true; _first_txa_match = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::match_txa_groups -// Access: Public -// Description: Adds the indicated set of groups, read from the .txa -// file, to the set of groups to which the egg file is -// assigned. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated set of groups, read from the .txa file, to the set of + * groups to which the egg file is assigned. + */ void EggFile:: match_txa_groups(const PaletteGroups &groups) { if (_first_txa_match) { - // If this is the first line we matched in the .txa file, clear - // the set of groups we'd matched from before. We don't clear - // until we match a line in the .txa file, because if we don't - // match any lines we still want to remember what groups we used - // to be assigned to. + // If this is the first line we matched in the .txa file, clear the set of + // groups we'd matched from before. We don't clear until we match a line + // in the .txa file, because if we don't match any lines we still want to + // remember what groups we used to be assigned to. _explicitly_assigned_groups.clear(); _first_txa_match = false; } @@ -263,117 +241,91 @@ match_txa_groups(const PaletteGroups &groups) { _explicitly_assigned_groups.make_union(_explicitly_assigned_groups, groups); } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::post_txa_file -// Access: Public -// Description: Once the egg file has been matched against all of the -// matching lines the .txa file, do whatever adjustment -// is necessary. -//////////////////////////////////////////////////////////////////// +/** + * Once the egg file has been matched against all of the matching lines the + * .txa file, do whatever adjustment is necessary. + */ void EggFile:: post_txa_file() { } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::get_explicit_groups -// Access: Public -// Description: Returns the set of PaletteGroups that the egg file -// has been explicitly assigned to in the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of PaletteGroups that the egg file has been explicitly + * assigned to in the .txa file. + */ const PaletteGroups &EggFile:: get_explicit_groups() const { return _explicitly_assigned_groups; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::get_default_group -// Access: Public -// Description: Returns the PaletteGroup that was specified as the -// default group on the command line at the time the egg -// file last appeared on the command line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PaletteGroup that was specified as the default group on the + * command line at the time the egg file last appeared on the command line. + */ PaletteGroup *EggFile:: get_default_group() const { return _default_group; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::get_complete_groups -// Access: Public -// Description: Returns the complete set of PaletteGroups that the -// egg file is assigned to. This is the set of all the -// groups it is explicitly assigned to, plus all the -// groups that these groups depend on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the complete set of PaletteGroups that the egg file is assigned to. + * This is the set of all the groups it is explicitly assigned to, plus all + * the groups that these groups depend on. + */ const PaletteGroups &EggFile:: get_complete_groups() const { return _complete_groups; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::clear_surprise -// Access: Public -// Description: Removes the 'surprise' flag; this file has been -// successfully matched against a line in the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Removes the 'surprise' flag; this file has been successfully matched + * against a line in the .txa file. + */ void EggFile:: clear_surprise() { _is_surprise = false; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::is_surprise -// Access: Public -// Description: Returns true if this particular egg file is a -// 'surprise', i.e. it wasn't matched by a line in the -// .txa file that didn't include the keyword 'cont'. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular egg file is a 'surprise', i.e. it wasn't + * matched by a line in the .txa file that didn't include the keyword 'cont'. + */ bool EggFile:: is_surprise() const { return _is_surprise; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::mark_stale -// Access: Public -// Description: Marks this particular egg file as stale, meaning that -// something has changed, such as the location of a -// texture within its palette, which causes the egg file -// to need to be regenerated. -//////////////////////////////////////////////////////////////////// +/** + * Marks this particular egg file as stale, meaning that something has + * changed, such as the location of a texture within its palette, which causes + * the egg file to need to be regenerated. + */ void EggFile:: mark_stale() { _is_stale = true; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::is_stale -// Access: Public -// Description: Returns true if the egg file needs to be updated, -// i.e. some palettizations have changed affecting it, -// or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the egg file needs to be updated, i.e. some palettizations + * have changed affecting it, or false otherwise. + */ bool EggFile:: is_stale() const { return _is_stale; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::build_cross_links -// Access: Public -// Description: Calls TextureImage::note_egg_file() and -// SourceTextureImage::increment_egg_count() for each -// texture the egg file references, and -// PaletteGroup::increment_egg_count() for each palette -// group it wants. This sets up some of the back -// references to support determining an ideal texture -// assignment. -//////////////////////////////////////////////////////////////////// +/** + * Calls TextureImage::note_egg_file() and + * SourceTextureImage::increment_egg_count() for each texture the egg file + * references, and PaletteGroup::increment_egg_count() for each palette group + * it wants. This sets up some of the back references to support determining + * an ideal texture assignment. + */ void EggFile:: build_cross_links() { if (_explicitly_assigned_groups.empty()) { - // If the egg file has been assigned to no groups, we have to - // assign it to something. + // If the egg file has been assigned to no groups, we have to assign it to + // something. _complete_groups.clear(); _complete_groups.insert(_default_group); _complete_groups.make_complete(_complete_groups); @@ -390,9 +342,8 @@ build_cross_links() { texture->note_egg_file(this); // Actually, this may count the same egg file multiple times for a - // particular SourceTextureImage, since a given texture may be - // referenced multiples times within an egg file. No harm done, - // however. + // particular SourceTextureImage, since a given texture may be referenced + // multiples times within an egg file. No harm done, however. reference->get_source()->increment_egg_count(); } @@ -404,14 +355,11 @@ build_cross_links() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::apply_properties_to_source -// Access: Public -// Description: Calls apply_properties_to_source() for each texture -// reference, updating all the referenced source -// textures with the complete set of property -// information from this egg file. -//////////////////////////////////////////////////////////////////// +/** + * Calls apply_properties_to_source() for each texture reference, updating all + * the referenced source textures with the complete set of property + * information from this egg file. + */ void EggFile:: apply_properties_to_source() { Textures::const_iterator ti; @@ -421,18 +369,14 @@ apply_properties_to_source() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::choose_placements -// Access: Public -// Description: Once all the textures have been assigned to groups -// (but before they may actually be placed), chooses a -// suitable TexturePlacement for each texture that -// appears in the egg file. This will be necessary to -// do at some point before writing out the egg file -// anyway, and doing it before the textures are placed -// allows us to decide what the necessary UV range is -// for each to-be-placed texture. -//////////////////////////////////////////////////////////////////// +/** + * Once all the textures have been assigned to groups (but before they may + * actually be placed), chooses a suitable TexturePlacement for each texture + * that appears in the egg file. This will be necessary to do at some point + * before writing out the egg file anyway, and doing it before the textures + * are placed allows us to decide what the necessary UV range is for each to- + * be-placed texture. + */ void EggFile:: choose_placements() { Textures::const_iterator ti; @@ -442,28 +386,28 @@ choose_placements() { if (reference->get_placement() != (TexturePlacement *)NULL && texture->get_groups().count(reference->get_placement()->get_group()) != 0) { - // The egg file is already using a TexturePlacement that is - // suitable. Don't bother changing it. + // The egg file is already using a TexturePlacement that is suitable. + // Don't bother changing it. } else { // We need to select a new TexturePlacement. PaletteGroups groups; groups.make_intersection(get_complete_groups(), texture->get_groups()); - // Now groups is the set of groups that the egg file requires, - // which also happen to include the texture. + // Now groups is the set of groups that the egg file requires, which + // also happen to include the texture. if (groups.empty()) { - // It might be empty if the egg file was assigned only to the - // "null" group (since this group is not propagated to the - // textures). In this case, choose from the wider set of - // groups available to the texture. + // It might be empty if the egg file was assigned only to the "null" + // group (since this group is not propagated to the textures). In + // this case, choose from the wider set of groups available to the + // texture. groups = texture->get_groups(); } if (!groups.empty()) { - // It doesn't really matter which group in the set we choose, so - // we arbitrarily choose the first one. + // It doesn't really matter which group in the set we choose, so we + // arbitrarily choose the first one. PaletteGroup *group = (*groups.begin()); // Now get the TexturePlacement object that corresponds to the @@ -477,35 +421,28 @@ choose_placements() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::has_data -// Access: Public -// Description: Returns true if the EggData for this EggFile has -// been loaded, and not yet released. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EggData for this EggFile has been loaded, and not yet + * released. + */ bool EggFile:: has_data() const { return (_data != (EggData *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::had_data -// Access: Public -// Description: Returns true if the EggData for this EggFile has ever -// been loaded in this session. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the EggData for this EggFile has ever been loaded in this + * session. + */ bool EggFile:: had_data() const { return _had_data; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::update_egg -// Access: Public -// Description: Once all textures have been placed appropriately, -// updates the egg file with all the information to -// reference the new textures. -//////////////////////////////////////////////////////////////////// +/** + * Once all textures have been placed appropriately, updates the egg file with + * all the information to reference the new textures. + */ void EggFile:: update_egg() { nassertv(_data != (EggData *)NULL); @@ -517,12 +454,10 @@ update_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::remove_egg -// Access: Public -// Description: Removes this egg file from all things that reference -// it, in preparation for removing it from the database. -//////////////////////////////////////////////////////////////////// +/** + * Removes this egg file from all things that reference it, in preparation for + * removing it from the database. + */ void EggFile:: remove_egg() { Textures::iterator ti; @@ -533,24 +468,20 @@ remove_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::read_egg -// Access: Public -// Description: Reads in the egg file from its _source_filename. It -// is only valid to call this if it has not already been -// read in, e.g. from the command line. Returns true if -// successful, false if there is an error. -// -// This may also be called after a previous call to -// release_egg_data(), in order to re-read the same egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the egg file from its _source_filename. It is only valid to call + * this if it has not already been read in, e.g. from the command line. + * Returns true if successful, false if there is an error. + * + * This may also be called after a previous call to release_egg_data(), in + * order to re-read the same egg file. + */ bool EggFile:: read_egg(bool noabs) { nassertr(_data == (EggData *)NULL, false); nassertr(!_source_filename.empty(), false); - Filename user_source_filename = + Filename user_source_filename = FilenameUnifier::make_user_filename(_source_filename); if (!_source_filename.exists()) { @@ -573,18 +504,18 @@ read_egg(bool noabs) { // Extract the set of textures referenced by this egg file. EggTextureCollection tc; tc.find_used_textures(data); - + // Make sure each tref name is unique within a given file. tc.uniquify_trefs(); - // Now build up a list of new TextureReference objects that - // represent the textures actually used and their uv range, etc. + // Now build up a list of new TextureReference objects that represent the + // textures actually used and their uv range, etc. Textures new_textures; - // We want to search for filenames based on the egg directory, and - // also on our current directory from which we originally loaded the - // egg file. This is important because it's possible the egg file - // referenced some textures or something relative to that directory. + // We want to search for filenames based on the egg directory, and also on + // our current directory from which we originally loaded the egg file. This + // is important because it's possible the egg file referenced some textures + // or something relative to that directory. DSearchPath dir; dir.append_directory(_source_filename.get_dirname()); dir.append_directory(_current_directory); @@ -615,12 +546,9 @@ read_egg(bool noabs) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::release_egg_data -// Access: Public -// Description: Releases the memory that was loaded by a previous -// call to read_egg(). -//////////////////////////////////////////////////////////////////// +/** + * Releases the memory that was loaded by a previous call to read_egg(). + */ void EggFile:: release_egg_data() { if (_data != (EggData *)NULL) { @@ -633,13 +561,10 @@ release_egg_data() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::write_egg -// Access: Public -// Description: Writes out the egg file to its _dest_filename. -// Returns true if successful, false if there is an -// error. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the egg file to its _dest_filename. Returns true if successful, + * false if there is an error. + */ bool EggFile:: write_egg() { nassertr(_data != (EggData *)NULL, false); @@ -658,12 +583,10 @@ write_egg() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::write_description -// Access: Public -// Description: Writes a one-line description of the egg file and its -// group assignments to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a one-line description of the egg file and its group assignments to + * the indicated output stream. + */ void EggFile:: write_description(ostream &out, int indent_level) const { indent(out, indent_level) << get_name() << ": "; @@ -681,12 +604,10 @@ write_description(ostream &out, int indent_level) const { out << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::write_texture_refs -// Access: Public -// Description: Writes the list of texture references to the -// indicated output stream, one per line. -//////////////////////////////////////////////////////////////////// +/** + * Writes the list of texture references to the indicated output stream, one + * per line. + */ void EggFile:: write_texture_refs(ostream &out, int indent_level) const { Textures::const_iterator ti; @@ -696,15 +617,11 @@ write_texture_refs(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::remove_backstage -// Access: Private -// Description: Recursively walks the egg hierarchy and removes any -// "backstage" nodes found from the scene graph -// completely. These aren't part of the egg scene -// anyway, and removing them early helps reduce -// confusion. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg hierarchy and removes any "backstage" nodes found + * from the scene graph completely. These aren't part of the egg scene + * anyway, and removing them early helps reduce confusion. + */ void EggFile:: remove_backstage(EggGroupNode *node) { EggGroupNode::iterator ci; @@ -731,13 +648,10 @@ remove_backstage(EggGroupNode *node) { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::rescan_textures -// Access: Private -// Description: After reloading the egg file for the second time in a -// given session, rematches the texture pointers with -// the TextureReference objects. -//////////////////////////////////////////////////////////////////// +/** + * After reloading the egg file for the second time in a given session, + * rematches the texture pointers with the TextureReference objects. + */ void EggFile:: rescan_textures() { nassertv(_data != (EggData *)NULL); @@ -745,7 +659,7 @@ rescan_textures() { // Extract the set of textures referenced by this egg file. EggTextureCollection tc; tc.find_used_textures(_data); - + // Make sure each tref name is unique within a given file. tc.uniquify_trefs(); @@ -766,7 +680,7 @@ rescan_textures() { if (tni == by_tref_name.end()) { // We didn't find this TRef name last time around! nout << _source_filename.get_basename() - << " modified during session--TRef " << egg_tex->get_name() + << " modified during session--TRef " << egg_tex->get_name() << " is new!\n"; } else { @@ -776,25 +690,19 @@ rescan_textures() { } } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void EggFile:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_EggFile); } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void EggFile:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -816,22 +724,18 @@ write_datagram(BamWriter *writer, Datagram &datagram) { _explicitly_assigned_groups.write_datagram(writer, datagram); writer->write_pointer(datagram, _default_group); - // We don't write out _complete_groups; that is recomputed each - // session. + // We don't write out _complete_groups; that is recomputed each session. datagram.add_bool(_is_surprise); datagram.add_bool(_is_stale); } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int EggFile:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -855,14 +759,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::make_EggFile -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* EggFile:: make_EggFile(const FactoryParams ¶ms) { EggFile *me = new EggFile(); @@ -874,13 +775,10 @@ make_EggFile(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: EggFile::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void EggFile:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -902,10 +800,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _is_stale = scan.get_bool(); if (Palettizer::_read_pi_version < 11) { - // If this file was written by a version of egg-palettize prior to - // 11, we didn't store the tref names on the texture references. - // Since we need that information now, it follows that every egg - // file is stale. + // If this file was written by a version of egg-palettize prior to 11, we + // didn't store the tref names on the texture references. Since we need + // that information now, it follows that every egg file is stale. _is_stale = true; } } diff --git a/pandatool/src/palettizer/eggFile.h b/pandatool/src/palettizer/eggFile.h index 80ebbfa35e..39f3b577df 100644 --- a/pandatool/src/palettizer/eggFile.h +++ b/pandatool/src/palettizer/eggFile.h @@ -1,16 +1,15 @@ -// Filename: eggFile.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggFile.h + * @author drose + * @date 2000-11-28 + */ #ifndef EGGFILE_H #define EGGFILE_H @@ -28,14 +27,12 @@ class TextureImage; -//////////////////////////////////////////////////////////////////// -// Class : EggFile -// Description : This represents a single egg file known to the -// palettizer. It may reference a number of textures, -// and may also be assigned to a number of groups. All -// of its textures will try to assign themselves to one -// of its groups. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single egg file known to the palettizer. It may + * reference a number of textures, and may also be assigned to a number of + * groups. All of its textures will try to assign themselves to one of its + * groups. + */ class EggFile : public TypedWritable, public Namable { public: EggFile(); @@ -115,8 +112,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // This value is only filled in while reading from the bam file; - // don't use it otherwise. + // This value is only filled in while reading from the bam file; don't use + // it otherwise. int _num_textures; public: @@ -139,4 +136,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/filenameUnifier.cxx b/pandatool/src/palettizer/filenameUnifier.cxx index 99e655c6a2..f844922b65 100644 --- a/pandatool/src/palettizer/filenameUnifier.cxx +++ b/pandatool/src/palettizer/filenameUnifier.cxx @@ -1,16 +1,15 @@ -// Filename: filenameUnifier.cxx -// Created by: drose (05Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filenameUnifier.cxx + * @author drose + * @date 2000-12-05 + */ #include "filenameUnifier.h" @@ -22,16 +21,12 @@ Filename FilenameUnifier::_rel_dirname; FilenameUnifier::CanonicalFilenames FilenameUnifier::_canonical_filenames; -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::set_txa_filename -// Access: Public, Static -// Description: Notes the filename the .txa file was found in. This -// may have come from the command line, or it may have -// been implicitly located. This has other implications -// for the FilenameUnifier, particularly in locating the bam -// file that saves the filenameUnifier state from last -// session. -//////////////////////////////////////////////////////////////////// +/** + * Notes the filename the .txa file was found in. This may have come from the + * command line, or it may have been implicitly located. This has other + * implications for the FilenameUnifier, particularly in locating the bam file + * that saves the filenameUnifier state from last session. + */ void FilenameUnifier:: set_txa_filename(const Filename &txa_filename) { _txa_filename = txa_filename; @@ -42,18 +37,14 @@ set_txa_filename(const Filename &txa_filename) { make_canonical(_txa_dir); } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::set_rel_dirname -// Access: Public, Static -// Description: Sets the name of the directory that texture filenames -// will be written relative to, when generating egg -// files. This is not the directory the textures are -// actually written to (see set_map_dirname()), but -// rather is the name of some directory above that, -// which will be the starting point for the pathnames -// written to the egg files. If this is empty, the full -// pathnames will be written to the egg files. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the directory that texture filenames will be written + * relative to, when generating egg files. This is not the directory the + * textures are actually written to (see set_map_dirname()), but rather is the + * name of some directory above that, which will be the starting point for the + * pathnames written to the egg files. If this is empty, the full pathnames + * will be written to the egg files. + */ void FilenameUnifier:: set_rel_dirname(const Filename &rel_dirname) { _rel_dirname = rel_dirname; @@ -62,12 +53,10 @@ set_rel_dirname(const Filename &rel_dirname) { } } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::make_bam_filename -// Access: Public, Static -// Description: Returns a new filename that's made relative to the -// bam file itself, suitable for writing to the bam file. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new filename that's made relative to the bam file itself, + * suitable for writing to the bam file. + */ Filename FilenameUnifier:: make_bam_filename(Filename filename) { make_canonical(filename); @@ -75,13 +64,10 @@ make_bam_filename(Filename filename) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::get_bam_filename -// Access: Public, Static -// Description: Returns an absolute pathname based on the given -// relative pathname, presumably read from the bam file -// and relative to the bam file. -//////////////////////////////////////////////////////////////////// +/** + * Returns an absolute pathname based on the given relative pathname, + * presumably read from the bam file and relative to the bam file. + */ Filename FilenameUnifier:: get_bam_filename(Filename filename) { if (!filename.empty()) { @@ -90,13 +76,10 @@ get_bam_filename(Filename filename) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::make_egg_filename -// Access: Public, Static -// Description: Returns a new filename that's made relative to the -// rel_directory, suitable for writing out within egg -// files. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new filename that's made relative to the rel_directory, suitable + * for writing out within egg files. + */ Filename FilenameUnifier:: make_egg_filename(Filename filename) { if (!filename.empty()) { @@ -106,13 +89,10 @@ make_egg_filename(Filename filename) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::make_user_filename -// Access: Public, Static -// Description: Returns a new filename that's made relative to the -// current directory, suitable for reporting to the -// user. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new filename that's made relative to the current directory, + * suitable for reporting to the user. + */ Filename FilenameUnifier:: make_user_filename(Filename filename) { if (!filename.empty()) { @@ -122,15 +102,11 @@ make_user_filename(Filename filename) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: FilenameUnifier::make_canonical -// Access: Public, Static -// Description: Does the same thing as Filename::make_canonical()--it -// converts the filename to its canonical form--but -// caches the operation so that repeated calls to -// filenames in the same directory will tend to be -// faster. -//////////////////////////////////////////////////////////////////// +/** + * Does the same thing as Filename::make_canonical()--it converts the filename + * to its canonical form--but caches the operation so that repeated calls to + * filenames in the same directory will tend to be faster. + */ void FilenameUnifier:: make_canonical(Filename &filename) { if (filename.empty()) { diff --git a/pandatool/src/palettizer/filenameUnifier.h b/pandatool/src/palettizer/filenameUnifier.h index efd83dfe86..b5646f5628 100644 --- a/pandatool/src/palettizer/filenameUnifier.h +++ b/pandatool/src/palettizer/filenameUnifier.h @@ -1,16 +1,15 @@ -// Filename: filenameUnifier.h -// Created by: drose (05Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file filenameUnifier.h + * @author drose + * @date 2000-12-05 + */ #ifndef FILENAMEUNIFIER_H #define FILENAMEUNIFIER_H @@ -21,16 +20,13 @@ #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : FilenameUnifier -// Description : This static class does the job of converting -// filenames from relative to absolute to canonical or -// whatever is appropriate. Its main purpose is to -// allow us to write relative pathnames to the bam file -// and turn them back into absolute pathnames on read, -// so that a given bam file does not get tied to -// absolute pathnames. -//////////////////////////////////////////////////////////////////// +/** + * This static class does the job of converting filenames from relative to + * absolute to canonical or whatever is appropriate. Its main purpose is to + * allow us to write relative pathnames to the bam file and turn them back + * into absolute pathnames on read, so that a given bam file does not get tied + * to absolute pathnames. + */ class FilenameUnifier { public: static void set_txa_filename(const Filename &txa_filename); @@ -53,4 +49,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/imageFile.cxx b/pandatool/src/palettizer/imageFile.cxx index 089eec6fba..54071d4cb1 100644 --- a/pandatool/src/palettizer/imageFile.cxx +++ b/pandatool/src/palettizer/imageFile.cxx @@ -1,16 +1,15 @@ -// Filename: imageFile.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFile.cxx + * @author drose + * @date 2000-11-29 + */ #include "imageFile.h" #include "palettizer.h" @@ -27,11 +26,9 @@ TypeHandle ImageFile::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ImageFile:: ImageFile() { _alpha_file_channel = 0; @@ -40,22 +37,18 @@ ImageFile() { _y_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::make_shadow_image -// Access: Public -// Description: Sets up the ImageFile as a "shadow image" of a -// particular PaletteImage. This is a temporary -// ImageFile that's used to read and write the shadow -// palette image, which is used to keep a working copy -// of the palette. -// -// Returns true if the filename changes from what it was -// previously, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the ImageFile as a "shadow image" of a particular PaletteImage. + * This is a temporary ImageFile that's used to read and write the shadow + * palette image, which is used to keep a working copy of the palette. + * + * Returns true if the filename changes from what it was previously, false + * otherwise. + */ bool ImageFile:: make_shadow_image(const string &basename) { bool any_changed = false; - + if (_properties._color_type != pal->_shadow_color_type || _properties._alpha_type != pal->_shadow_alpha_type) { @@ -71,112 +64,86 @@ make_shadow_image(const string &basename) { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::is_size_known -// Access: Public -// Description: Returns true if the size of the image file is known, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the size of the image file is known, false otherwise. + */ bool ImageFile:: is_size_known() const { return _size_known; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_x_size -// Access: Public -// Description: Returns the size of the image file in pixels in the X -// direction. It is an error to call this unless -// is_size_known() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the image file in pixels in the X direction. It is an + * error to call this unless is_size_known() returns true. + */ int ImageFile:: get_x_size() const { nassertr(is_size_known(), 0); return _x_size; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_y_size -// Access: Public -// Description: Returns the size of the image file in pixels in the Y -// direction. It is an error to call this unless -// is_size_known() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the image file in pixels in the Y direction. It is an + * error to call this unless is_size_known() returns true. + */ int ImageFile:: get_y_size() const { nassertr(is_size_known(), 0); return _y_size; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::has_num_channels -// Access: Public -// Description: Returns true if the number of channels in the image -// is known, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the number of channels in the image is known, false + * otherwise. + */ bool ImageFile:: has_num_channels() const { return _properties.has_num_channels(); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_num_channels -// Access: Public -// Description: Returns the number of channels of the image. It is -// an error to call this unless has_num_channels() -// returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of channels of the image. It is an error to call this + * unless has_num_channels() returns true. + */ int ImageFile:: get_num_channels() const { return _properties.get_num_channels(); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_properties -// Access: Public -// Description: Returns the grouping properties of the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the grouping properties of the image. + */ const TextureProperties &ImageFile:: get_properties() const { return _properties; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::clear_basic_properties -// Access: Public -// Description: Resets the properties to a neutral state, for -// instance in preparation for calling -// update_properties() with all the known contributing -// properties. -//////////////////////////////////////////////////////////////////// +/** + * Resets the properties to a neutral state, for instance in preparation for + * calling update_properties() with all the known contributing properties. + */ void ImageFile:: clear_basic_properties() { _properties.clear_basic(); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::update_properties -// Access: Public -// Description: If the indicate TextureProperties structure is more -// specific than this one, updates this one. -//////////////////////////////////////////////////////////////////// +/** + * If the indicate TextureProperties structure is more specific than this one, + * updates this one. + */ void ImageFile:: update_properties(const TextureProperties &properties) { _properties.update_properties(properties); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::set_filename -// Access: Public -// Description: Sets the filename, and if applicable, the -// alpha_filename, from the indicated basename. The -// extension appropriate to the image file type -// specified in _color_type (and _alpha_type) is -// automatically applied. -// -// Returns true if the filename changes from what it was -// previously, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filename, and if applicable, the alpha_filename, from the + * indicated basename. The extension appropriate to the image file type + * specified in _color_type (and _alpha_type) is automatically applied. + * + * Returns true if the filename changes from what it was previously, false + * otherwise. + */ bool ImageFile:: set_filename(PaletteGroup *group, const string &basename) { // Synthesize the directory name based on the map_dirname set to the @@ -207,35 +174,30 @@ set_filename(PaletteGroup *group, const string &basename) { return set_filename(dirname, basename); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::set_filename -// Access: Public -// Description: Sets the filename, and if applicable, the -// alpha_filename, from the indicated basename. The -// extension appropriate to the image file type -// specified in _color_type (and _alpha_type) is -// automatically applied. -// -// Returns true if the filename changes from what it was -// previously, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the filename, and if applicable, the alpha_filename, from the + * indicated basename. The extension appropriate to the image file type + * specified in _color_type (and _alpha_type) is automatically applied. + * + * Returns true if the filename changes from what it was previously, false + * otherwise. + */ bool ImageFile:: set_filename(const string &dirname, const string &basename) { Filename orig_filename = _filename; Filename orig_alpha_filename = _alpha_filename; - + _filename = Filename(dirname, basename); _filename.standardize(); // Since we use set_extension() here, if the file already contains a // filename extension it will be lost. - // It is particularly important to note that a single embedded dot - // will appear to begin a filename extension, so if the filename - // does *not* contain an extension, but does contain an embedded - // dot, the filename will be truncated at that dot. It is therefore - // important that the supplied basename always contains either an - // extension or a terminating dot. + // It is particularly important to note that a single embedded dot will + // appear to begin a filename extension, so if the filename does *not* + // contain an extension, but does contain an embedded dot, the filename will + // be truncated at that dot. It is therefore important that the supplied + // basename always contains either an extension or a terminating dot. if (_properties._color_type != (PNMFileType *)NULL) { _filename.set_extension @@ -254,51 +216,40 @@ set_filename(const string &dirname, const string &basename) { _alpha_filename != orig_alpha_filename); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_filename -// Access: Public -// Description: Returns the primary filename of the image file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primary filename of the image file. + */ const Filename &ImageFile:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_alpha_filename -// Access: Public -// Description: Returns the alpha filename of the image file. This -// is the name of the file that contains the alpha -// channel, if it is stored in a separate file, or the -// empty string if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha filename of the image file. This is the name of the file + * that contains the alpha channel, if it is stored in a separate file, or the + * empty string if it is not. + */ const Filename &ImageFile:: get_alpha_filename() const { return _alpha_filename; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::get_alpha_file_channel -// Access: Public -// Description: Returns the particular channel number of the alpha -// image file from which the alpha channel should be -// extracted. This is normally 0 to represent the -// grayscale combination of r, g, and b; or it may be a -// 1-based channel number (for instance, 4 for the alpha -// channel of a 4-component image). -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular channel number of the alpha image file from which + * the alpha channel should be extracted. This is normally 0 to represent the + * grayscale combination of r, g, and b; or it may be a 1-based channel number + * (for instance, 4 for the alpha channel of a 4-component image). + */ int ImageFile:: get_alpha_file_channel() const { return _alpha_file_channel; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::exists -// Access: Public -// Description: Returns true if the file or files named by the image -// file exist, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file or files named by the image file exist, false + * otherwise. + */ bool ImageFile:: exists() const { if (!_filename.exists()) { @@ -315,13 +266,11 @@ exists() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::read -// Access: Public -// Description: Reads in the image (or images, if the alpha_filename -// is separate) and stores it in the indicated PNMImage. -// Returns true on success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the image (or images, if the alpha_filename is separate) and + * stores it in the indicated PNMImage. Returns true on success, false on + * failure. + */ bool ImageFile:: read(PNMImage &image) const { nassertr(!_filename.empty(), false); @@ -349,7 +298,7 @@ read(PNMImage &image) const { image.add_alpha(); - if (_alpha_file_channel == 4 || + if (_alpha_file_channel == 4 || (_alpha_file_channel == 2 && alpha_image.get_num_channels() == 2)) { // Use the alpha channel. for (int x = 0; x < image.get_x_size(); x++) { @@ -357,7 +306,7 @@ read(PNMImage &image) const { image.set_alpha(x, y, alpha_image.get_alpha(x, y)); } } - + } else if (_alpha_file_channel >= 1 && _alpha_file_channel <= 3 && alpha_image.get_num_channels() >= 3) { // Use the appropriate red, green, or blue channel. @@ -366,7 +315,7 @@ read(PNMImage &image) const { image.set_alpha(x, y, alpha_image.get_channel_val(x, y, _alpha_file_channel - 1)); } } - + } else { // Use the grayscale channel. for (int x = 0; x < image.get_x_size(); x++) { @@ -380,13 +329,10 @@ read(PNMImage &image) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::write -// Access: Public -// Description: Writes out the image in the indicated PNMImage to the -// _filename and/or _alpha_filename. Returns true on -// success, false on failure. -//////////////////////////////////////////////////////////////////// +/** + * Writes out the image in the indicated PNMImage to the _filename and/or + * _alpha_filename. Returns true on success, false on failure. + */ bool ImageFile:: write(const PNMImage &image) const { nassertr(!_filename.empty(), false); @@ -433,11 +379,9 @@ write(const PNMImage &image) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::unlink -// Access: Public -// Description: Deletes the image file or files. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the image file or files. + */ void ImageFile:: unlink() { if (!_filename.empty() && _filename.exists()) { @@ -450,11 +394,9 @@ unlink() { } } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::update_egg_tex -// Access: Public -// Description: Sets the indicated EggTexture to refer to this file. -//////////////////////////////////////////////////////////////////// +/** + * Sets the indicated EggTexture to refer to this file. + */ void ImageFile:: update_egg_tex(EggTexture *egg_tex) const { nassertv(egg_tex != (EggTexture *)NULL); @@ -473,27 +415,21 @@ update_egg_tex(EggTexture *egg_tex) const { _properties.update_egg_tex(egg_tex); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::output_filename -// Access: Public -// Description: Writes the filename (or pair of filenames) to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes the filename (or pair of filenames) to the indicated output stream. + */ void ImageFile:: output_filename(ostream &out) const { - out << FilenameUnifier::make_user_filename(_filename); + out << FilenameUnifier::make_user_filename(_filename); if (_properties.uses_alpha() && !_alpha_filename.empty()) { out << " " << FilenameUnifier::make_user_filename(_alpha_filename); } } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void ImageFile:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -506,15 +442,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { datagram.add_int32(_y_size); } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int ImageFile:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -524,13 +457,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: ImageFile::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void ImageFile:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/imageFile.h b/pandatool/src/palettizer/imageFile.h index 43b2f43420..80de6266f3 100644 --- a/pandatool/src/palettizer/imageFile.h +++ b/pandatool/src/palettizer/imageFile.h @@ -1,16 +1,15 @@ -// Filename: imageFile.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file imageFile.h + * @author drose + * @date 2000-11-28 + */ #ifndef IMAGEFILE_H #define IMAGEFILE_H @@ -26,13 +25,11 @@ class PNMImage; class EggTexture; class PaletteGroup; -//////////////////////////////////////////////////////////////////// -// Class : ImageFile -// Description : This is the base class of both TextureImage and -// PaletteImage. It encapsulates all the information -// specific to an image file that can be assigned as a -// texture image to egg geometry. -//////////////////////////////////////////////////////////////////// +/** + * This is the base class of both TextureImage and PaletteImage. It + * encapsulates all the information specific to an image file that can be + * assigned as a texture image to egg geometry. + */ class ImageFile : public TypedWritable { public: ImageFile(); @@ -101,4 +98,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/omitReason.cxx b/pandatool/src/palettizer/omitReason.cxx index 0b5f41c539..94848b865c 100644 --- a/pandatool/src/palettizer/omitReason.cxx +++ b/pandatool/src/palettizer/omitReason.cxx @@ -1,16 +1,15 @@ -// Filename: omitReason.cxx -// Created by: drose (02Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file omitReason.cxx + * @author drose + * @date 2000-12-02 + */ #include "omitReason.h" diff --git a/pandatool/src/palettizer/omitReason.h b/pandatool/src/palettizer/omitReason.h index 67cf299692..db2a7bb03f 100644 --- a/pandatool/src/palettizer/omitReason.h +++ b/pandatool/src/palettizer/omitReason.h @@ -1,27 +1,25 @@ -// Filename: omitReason.h -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file omitReason.h + * @author drose + * @date 2000-11-30 + */ #ifndef OMITREASON_H #define OMITREASON_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : OmitReason -// Description : This enumerates the reasons why a texture may not -// have been placed in a palette image. -//////////////////////////////////////////////////////////////////// +/** + * This enumerates the reasons why a texture may not have been placed in a + * palette image. + */ enum OmitReason { OR_none, // Not omitted: the texture appears on a palette image. @@ -36,19 +34,19 @@ enum OmitReason { // Too big to fit on a single palette image. OR_solitary, - // It should be placed, but it's the only one on the palette image - // so far, so there's no point. + // It should be placed, but it's the only one on the palette image so far, + // so there's no point. OR_coverage, - // The texture repeats. Specifically, the UV's for the texture - // exceed the maximum rectangle allowed by coverage_threshold. + // The texture repeats. Specifically, the UV's for the texture exceed the + // maximum rectangle allowed by coverage_threshold. OR_unknown, // The texture file cannot be read, so its size can't be determined. OR_unused, - // The texture is no longer used by any of the egg files that - // formerly referenced it. + // The texture is no longer used by any of the egg files that formerly + // referenced it. OR_default_omit, // The texture is omitted because _omit_everything is set true. @@ -57,4 +55,3 @@ enum OmitReason { ostream &operator << (ostream &out, OmitReason omit); #endif - diff --git a/pandatool/src/palettizer/pal_string_utils.cxx b/pandatool/src/palettizer/pal_string_utils.cxx index 8bbcc16e62..4fd04bbe3f 100644 --- a/pandatool/src/palettizer/pal_string_utils.cxx +++ b/pandatool/src/palettizer/pal_string_utils.cxx @@ -1,16 +1,15 @@ -// Filename: pal_string_utils.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pal_string_utils.cxx + * @author drose + * @date 2000-11-30 + */ #include "pal_string_utils.h" @@ -18,8 +17,8 @@ #include "pnmFileTypeRegistry.h" -// Extracts the first word of the string into param, and the remainder -// of the line into value. +// Extracts the first word of the string into param, and the remainder of the +// line into value. void extract_param_value(const string &str, string ¶m, string &value) { size_t i = 0; @@ -59,8 +58,8 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, string alpha_name; size_t comma = word.find(','); if (comma != string::npos) { - // If we have a comma in the image_type, it's two types: a color - // type and an alpha type. + // If we have a comma in the image_type, it's two types: a color type and + // an alpha type. color_name = word.substr(0, comma); alpha_name = word.substr(comma + 1); } @@ -83,5 +82,3 @@ parse_image_type_request(const string &word, PNMFileType *&color_type, return true; } - - diff --git a/pandatool/src/palettizer/pal_string_utils.h b/pandatool/src/palettizer/pal_string_utils.h index fd1d39afb7..6eed342977 100644 --- a/pandatool/src/palettizer/pal_string_utils.h +++ b/pandatool/src/palettizer/pal_string_utils.h @@ -1,16 +1,15 @@ -// Filename: pal_string_utils.h -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pal_string_utils.h + * @author drose + * @date 2000-11-30 + */ #ifndef PAL_STRING_UTILS_H #define PAL_STRING_UTILS_H @@ -26,4 +25,3 @@ bool parse_image_type_request(const string &word, PNMFileType *&color_type, PNMFileType *&alpha_type); #endif - diff --git a/pandatool/src/palettizer/paletteGroup.cxx b/pandatool/src/palettizer/paletteGroup.cxx index d8b8f6c98f..409bf28f33 100644 --- a/pandatool/src/palettizer/paletteGroup.cxx +++ b/pandatool/src/palettizer/paletteGroup.cxx @@ -1,16 +1,15 @@ -// Filename: paletteGroup.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteGroup.cxx + * @author drose + * @date 2000-11-30 + */ #include "paletteGroup.h" #include "palettePage.h" @@ -29,11 +28,9 @@ TypeHandle PaletteGroup::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteGroup:: PaletteGroup() { _egg_count = 0; @@ -44,48 +41,37 @@ PaletteGroup() { _margin_override = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::set_dirname -// Access: Public -// Description: Sets the directory name associated with the palette -// group. This is an optional feature that can be used -// to place the maps for the different palette groups -// into different install directories. -//////////////////////////////////////////////////////////////////// +/** + * Sets the directory name associated with the palette group. This is an + * optional feature that can be used to place the maps for the different + * palette groups into different install directories. + */ void PaletteGroup:: set_dirname(const string &dirname) { _dirname = dirname; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::has_dirname -// Access: Public -// Description: Returns true if the directory name has been -// explicitly set for this group. If it has not, -// get_dirname() returns an empty string. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the directory name has been explicitly set for this group. + * If it has not, get_dirname() returns an empty string. + */ bool PaletteGroup:: has_dirname() const { return !_dirname.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_dirname -// Access: Public -// Description: Returns the directory name associated with the -// palette group. See set_dirname(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the directory name associated with the palette group. See + * set_dirname(). + */ const string &PaletteGroup:: get_dirname() const { return _dirname; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::clear_depends -// Access: Public -// Description: Eliminates all the dependency information for this -// group. -//////////////////////////////////////////////////////////////////// +/** + * Eliminates all the dependency information for this group. + */ void PaletteGroup:: clear_depends() { _dependent.clear(); @@ -94,74 +80,57 @@ clear_depends() { _dirname_order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::group_with -// Access: Public -// Description: Indicates a dependency of this group on some other -// group. This means that the textures assigned to this -// group may be considered successfully assigned if they -// are actually placed in the other group. In practice, -// this means that the textures associated with the -// other palette group will always be resident at -// runtime when textures from this palette group are -// required. -//////////////////////////////////////////////////////////////////// +/** + * Indicates a dependency of this group on some other group. This means that + * the textures assigned to this group may be considered successfully assigned + * if they are actually placed in the other group. In practice, this means + * that the textures associated with the other palette group will always be + * resident at runtime when textures from this palette group are required. + */ void PaletteGroup:: group_with(PaletteGroup *other) { _dependent.insert(other); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_groups -// Access: Public -// Description: Returns the set of groups this group depends on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of groups this group depends on. + */ const PaletteGroups &PaletteGroup:: get_groups() const { return _dependent; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_margin_override -// Access: Public -// Description: Returns the set of groups this group depends on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of groups this group depends on. + */ int PaletteGroup:: get_margin_override() const { return _margin_override; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_margin_override -// Access: Public -// Description: Returns the set of groups this group depends on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of groups this group depends on. + */ void PaletteGroup:: set_margin_override(const int override) { _margin_override = override; _has_margin_override = true; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::has_margin_override -// Access: Public -// Description: Returns the set of groups this group depends on. -//////////////////////////////////////////////////////////////////// +/** + * Returns the set of groups this group depends on. + */ bool PaletteGroup:: has_margin_override() const { return _has_margin_override; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_placements -// Access: Public -// Description: Adds the set of TexturePlacements associated with -// this group to the indicated vector. The vector is -// not cleared before this operation; if the user wants -// to retrieve the set of placements particular to this -// group only, it is the user's responsibility to clear -// the vector first. -//////////////////////////////////////////////////////////////////// +/** + * Adds the set of TexturePlacements associated with this group to the + * indicated vector. The vector is not cleared before this operation; if the + * user wants to retrieve the set of placements particular to this group only, + * it is the user's responsibility to clear the vector first. + */ void PaletteGroup:: get_placements(pvector &placements) const { Placements::const_iterator pi; @@ -170,13 +139,10 @@ get_placements(pvector &placements) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_complete_placements -// Access: Public -// Description: Adds the set of TexturePlacements associated with -// this group and all dependent groups to the indicated -// vector. See get_placements(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the set of TexturePlacements associated with this group and all + * dependent groups to the indicated vector. See get_placements(). + */ void PaletteGroup:: get_complete_placements(pvector &placements) const { PaletteGroups complete; @@ -191,14 +157,11 @@ get_complete_placements(pvector &placements) const { get_placements(placements); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::reset_dependency_level -// Access: Public -// Description: Unconditionally sets the dependency level and order -// of this group to zero, in preparation for a later -// call to set_dependency_level(). See -// set_dependency_level(). -//////////////////////////////////////////////////////////////////// +/** + * Unconditionally sets the dependency level and order of this group to zero, + * in preparation for a later call to set_dependency_level(). See + * set_dependency_level(). + */ void PaletteGroup:: reset_dependency_level() { _dependency_level = 0; @@ -206,18 +169,14 @@ reset_dependency_level() { _dirname_order = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::set_dependency_level -// Access: Public -// Description: Sets the dependency level of this group to the -// indicated level, provided that level is not lower -// than the level that was set previously. Also -// cascades to all dependent groups. See -// get_dependency_level(). -// -// This call recurses to correctly set the dependency -// level of all PaletteGroups in the hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Sets the dependency level of this group to the indicated level, provided + * that level is not lower than the level that was set previously. Also + * cascades to all dependent groups. See get_dependency_level(). + * + * This call recurses to correctly set the dependency level of all + * PaletteGroups in the hierarchy. + */ void PaletteGroup:: set_dependency_level(int level) { if (level > _dependency_level) { @@ -230,18 +189,14 @@ set_dependency_level(int level) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::set_dependency_order -// Access: Public -// Description: Updates the dependency order of this group. This -// number is the inverse of the dependency level, and -// can be used to rank the groups in order so that all -// the groups that a given group depends on will appear -// first in the list. See get_dependency_order(). -// -// This function returns true if anything was changed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Updates the dependency order of this group. This number is the inverse of + * the dependency level, and can be used to rank the groups in order so that + * all the groups that a given group depends on will appear first in the list. + * See get_dependency_order(). + * + * This function returns true if anything was changed, false otherwise. + */ bool PaletteGroup:: set_dependency_order() { bool any_changed = false; @@ -276,80 +231,60 @@ set_dependency_order() { return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_dependency_level -// Access: Public -// Description: Returns the dependency level of this group. This is -// a measure of how specific the group is; the lower the -// dependency level, the more specific the group. -// -// Groups depend on other groups in a hierarchical -// relationship. In general, if group a depends on -// group b, then b->get_dependency_level() > -// a->get_dependency_level(). -// -// Thus, groups that lots of other groups depend on have -// a higher dependency level; groups that no one else -// depends on have a low dependency level. This is -// important when deciding which groups are best suited -// for assigning a texture to; in general, the texture -// should be assigned to the most specific suitable -// group (i.e. the one with the lowest dependency -// level). -//////////////////////////////////////////////////////////////////// +/** + * Returns the dependency level of this group. This is a measure of how + * specific the group is; the lower the dependency level, the more specific + * the group. + * + * Groups depend on other groups in a hierarchical relationship. In general, + * if group a depends on group b, then b->get_dependency_level() > + * a->get_dependency_level(). + * + * Thus, groups that lots of other groups depend on have a higher dependency + * level; groups that no one else depends on have a low dependency level. + * This is important when deciding which groups are best suited for assigning + * a texture to; in general, the texture should be assigned to the most + * specific suitable group (i.e. the one with the lowest dependency level). + */ int PaletteGroup:: get_dependency_level() const { return _dependency_level; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_dependency_order -// Access: Public -// Description: Returns the dependency order of this group. This is -// similar in principle to the dependency level, but it -// represents the inverse concept: if group a depends on -// group b, then a->get_dependency_order() > -// b->get_dependency_order(). -// -// This is not exactly the same thing as n - -// get_dependency_level(). In particular, this can be -// used to sort the groups into an ordering such that -// all the groups that group a depends on appear before -// group a in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dependency order of this group. This is similar in principle + * to the dependency level, but it represents the inverse concept: if group a + * depends on group b, then a->get_dependency_order() > + * b->get_dependency_order(). + * + * This is not exactly the same thing as n - get_dependency_level(). In + * particular, this can be used to sort the groups into an ordering such that + * all the groups that group a depends on appear before group a in the list. + */ int PaletteGroup:: get_dependency_order() const { return _dependency_order; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_dirname_order -// Access: Public -// Description: Returns the dependency order of this group. This is -// similar in principle to the dependency level, but it -// represents the inverse concept: if group a depends on -// group b, then a->get_dirname_order() > -// b->get_dirname_order(). -// -// This is not exactly the same thing as n - -// get_dependency_level(). In particular, this can be -// used to sort the groups into an ordering such that -// all the groups that group a depends on appear before -// group a in the list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the dependency order of this group. This is similar in principle + * to the dependency level, but it represents the inverse concept: if group a + * depends on group b, then a->get_dirname_order() > b->get_dirname_order(). + * + * This is not exactly the same thing as n - get_dependency_level(). In + * particular, this can be used to sort the groups into an ordering such that + * all the groups that group a depends on appear before group a in the list. + */ int PaletteGroup:: get_dirname_order() const { return _dirname_order; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::is_preferred_over -// Access: Public -// Description: Returns true if this group should be preferred for -// adding textures over the other group, if both are -// available. In other words, this is a more specific -// group than the other one. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this group should be preferred for adding textures over the + * other group, if both are available. In other words, this is a more + * specific group than the other one. + */ bool PaletteGroup:: is_preferred_over(const PaletteGroup &other) const { if (get_dirname_order() != other.get_dirname_order()) { @@ -363,38 +298,29 @@ is_preferred_over(const PaletteGroup &other) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::increment_egg_count -// Access: Public -// Description: Increments by one the number of egg files that are -// known to reference this PaletteGroup. This is -// designed to aid the heuristics in texture placing; -// it's useful to know how many different egg files are -// sharing a particular PaletteGroup. -//////////////////////////////////////////////////////////////////// +/** + * Increments by one the number of egg files that are known to reference this + * PaletteGroup. This is designed to aid the heuristics in texture placing; + * it's useful to know how many different egg files are sharing a particular + * PaletteGroup. + */ void PaletteGroup:: increment_egg_count() { _egg_count++; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_egg_count -// Access: Public -// Description: Returns the number of egg files that share this -// PaletteGroup. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of egg files that share this PaletteGroup. + */ int PaletteGroup:: get_egg_count() const { return _egg_count; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::get_page -// Access: Public -// Description: Returns the page associated with the indicated -// properties. If no page object has yet been created, -// creates one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the page associated with the indicated properties. If no page + * object has yet been created, creates one. + */ PalettePage *PaletteGroup:: get_page(const TextureProperties &properties) { Pages::iterator pi = _pages.find(properties); @@ -408,17 +334,12 @@ get_page(const TextureProperties &properties) { return page; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::prepare -// Access: Public -// Description: Marks the indicated Texture as ready for placing -// somewhere within this group, and returns a -// placeholder TexturePlacement object. The texture is -// not placed immediately, but may be placed later when -// place_all() is called; at this time, the -// TexturePlacement fields will be filled in as -// appropriate. -//////////////////////////////////////////////////////////////////// +/** + * Marks the indicated Texture as ready for placing somewhere within this + * group, and returns a placeholder TexturePlacement object. The texture is + * not placed immediately, but may be placed later when place_all() is called; + * at this time, the TexturePlacement fields will be filled in as appropriate. + */ TexturePlacement *PaletteGroup:: prepare(TextureImage *texture) { TexturePlacement *placement = new TexturePlacement(texture, this); @@ -434,8 +355,8 @@ prepare(TextureImage *texture) { ++wi; ++wi; - // [gjeon] since swapped texture usually didn't mapped to any egg file - // we need to create soucreTextureImage by using original texture file's info + // [gjeon] since swapped texture usually didn't mapped to any egg file we + // need to create soucreTextureImage by using original texture file's info const string originalTextureName = (*wi); TextureImage *originalTexture = pal->get_texture(originalTextureName); SourceTextureImage *source = originalTexture->get_preferred_source(); @@ -452,17 +373,15 @@ prepare(TextureImage *texture) { placement->_textureSwaps.push_back(swapTextureImage); ++wi; } - } + } return placement; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::unplace -// Access: Public -// Description: Removes the texture from its position on a -// PaletteImage, if it has been so placed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture from its position on a PaletteImage, if it has been so + * placed. + */ void PaletteGroup:: unplace(TexturePlacement *placement) { nassertv(placement->get_group() == this); @@ -478,21 +397,18 @@ unplace(TexturePlacement *placement) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::place_all -// Access: Public -// Description: Once all the textures have been assigned to this -// group, try to place them all onto suitable -// PaletteImages. -//////////////////////////////////////////////////////////////////// +/** + * Once all the textures have been assigned to this group, try to place them + * all onto suitable PaletteImages. + */ void PaletteGroup:: place_all() { - // First, go through our prepared textures and assign each unplaced - // one to an appropriate page. + // First, go through our prepared textures and assign each unplaced one to + // an appropriate page. Placements::iterator pli; for (pli = _placements.begin(); pli != _placements.end(); ++pli) { TexturePlacement *placement = (*pli); - + if (placement->get_omit_reason() == OR_working) { PalettePage *page = get_page(placement->get_properties()); page->assign(placement); @@ -507,14 +423,11 @@ place_all() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::update_unknown_textures -// Access: Public -// Description: Checks for new information on any textures within the -// group for which some of the saved information is -// incomplete. This may be necessary before we can -// properly place all of the textures. -//////////////////////////////////////////////////////////////////// +/** + * Checks for new information on any textures within the group for which some + * of the saved information is incomplete. This may be necessary before we + * can properly place all of the textures. + */ void PaletteGroup:: update_unknown_textures(const TxaFile &txa_file) { Placements::iterator pli; @@ -522,8 +435,7 @@ update_unknown_textures(const TxaFile &txa_file) { TexturePlacement *placement = (*pli); if (!placement->is_size_known()) { - // This texture's size isn't known; we have to determine its - // size. + // This texture's size isn't known; we have to determine its size. TextureImage *texture = placement->get_texture(); if (!texture->got_txa_file()) { // But first, we need to look up the texture in the .txa file. @@ -537,13 +449,10 @@ update_unknown_textures(const TxaFile &txa_file) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::write_image_info -// Access: Public -// Description: Writes a list of the PaletteImages associated with -// this group, and all of their textures, to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the PaletteImages associated with this group, and all of + * their textures, to the indicated output stream. + */ void PaletteGroup:: write_image_info(ostream &out, int indent_level) const { Pages::const_iterator pai; @@ -566,7 +475,7 @@ write_image_info(ostream &out, int indent_level) const { IndirectCompareNames()); pvector::const_iterator pvi; - for (pvi = placement_vector.begin(); + for (pvi = placement_vector.begin(); pvi != placement_vector.end(); ++pvi) { TexturePlacement *placement = (*pvi); @@ -578,12 +487,12 @@ write_image_info(ostream &out, int indent_level) const { case OR_coverage: out << "coverage (" << placement->get_uv_area() << ")"; break; - + case OR_size: out << "size (" << placement->get_x_size() << " " << placement->get_y_size() << ")"; break; - + default: out << placement->get_omit_reason(); } @@ -591,12 +500,9 @@ write_image_info(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::optimal_resize -// Access: Public -// Description: Attempts to resize each PalettteImage down to its -// smallest possible size. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize each PalettteImage down to its smallest possible size. + */ void PaletteGroup:: optimal_resize() { Pages::iterator pai; @@ -606,13 +512,10 @@ optimal_resize() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::reset_images -// Access: Public -// Description: Throws away all of the current PaletteImages, so that -// new ones may be created (and the packing made more -// optimal). -//////////////////////////////////////////////////////////////////// +/** + * Throws away all of the current PaletteImages, so that new ones may be + * created (and the packing made more optimal). + */ void PaletteGroup:: reset_images() { Pages::iterator pai; @@ -622,14 +525,11 @@ reset_images() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::setup_shadow_images -// Access: Public -// Description: Ensures that each PaletteImage's _shadow_image has -// the correct filename and image types, based on what -// was supplied on the command line and in the .txa -// file. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that each PaletteImage's _shadow_image has the correct filename and + * image types, based on what was supplied on the command line and in the .txa + * file. + */ void PaletteGroup:: setup_shadow_images() { Pages::iterator pai; @@ -639,12 +539,9 @@ setup_shadow_images() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::update_images -// Access: Public -// Description: Regenerates each PaletteImage on this group that needs -// it. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates each PaletteImage on this group that needs it. + */ void PaletteGroup:: update_images(bool redo_all) { Pages::iterator pai; @@ -654,25 +551,19 @@ update_images(bool redo_all) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PaletteGroup:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PaletteGroup); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void PaletteGroup:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -700,15 +591,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int PaletteGroup:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -723,10 +611,10 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { nassertr(inserted, pi); } - // We must store the list of pages in a temporary vector first. We - // can't put them directly into the map because the map requires - // that all the pointers in the page's get_properties() member have - // been filled in, which may not have happened yet. + // We must store the list of pages in a temporary vector first. We can't + // put them directly into the map because the map requires that all the + // pointers in the page's get_properties() member have been filled in, which + // may not have happened yet. _load_pages.reserve(_num_pages); for (i = 0; i < _num_pages; i++) { PalettePage *page; @@ -737,15 +625,12 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::finalize -// Access: Public, Virtual -// Description: This method is called by the BamReader after all -// pointers everywhere in the world have been completely -// read in. It's a hook at which the object can do -// whatever final setup it requires that depends on -// other pointers being valid. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader after all pointers everywhere in the + * world have been completely read in. It's a hook at which the object can do + * whatever final setup it requires that depends on other pointers being + * valid. + */ void PaletteGroup:: finalize(BamReader *) { // Now we can copy the pages into the actual map. @@ -760,14 +645,11 @@ finalize(BamReader *) { _load_pages.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::make_PaletteGroup -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable *PaletteGroup:: make_PaletteGroup(const FactoryParams ¶ms) { PaletteGroup *me = new PaletteGroup; @@ -780,13 +662,10 @@ make_PaletteGroup(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void PaletteGroup:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -804,17 +683,15 @@ fillin(DatagramIterator &scan, BamReader *manager) { _num_pages = scan.get_uint32(); manager->read_pointers(scan, _num_pages); - if(Palettizer::_read_pi_version >= 19) { + if(Palettizer::_read_pi_version >= 19) { _has_margin_override = scan.get_bool(); _margin_override = scan.get_int16(); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::add_texture_swap_info -// Access: Public -// Description: Store textureswap information from textures.txa -//////////////////////////////////////////////////////////////////// +/** + * Store textureswap information from textures.txa + */ void PaletteGroup:: add_texture_swap_info(const string sourceTextureName, const vector_string &swapTextures) { TextureSwapInfo::iterator tsi = _textureSwapInfo.find(sourceTextureName); @@ -824,12 +701,9 @@ add_texture_swap_info(const string sourceTextureName, const vector_string &swapT _textureSwapInfo.insert(TextureSwapInfo::value_type(sourceTextureName, swapTextures)); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroup::is_none_texture_swap -// Access: Public -// Description: Returns textureswap information is set or not, -// True if it's not set. -//////////////////////////////////////////////////////////////////// +/** + * Returns textureswap information is set or not, True if it's not set. + */ bool PaletteGroup:: is_none_texture_swap() const { return _textureSwapInfo.empty(); diff --git a/pandatool/src/palettizer/paletteGroup.h b/pandatool/src/palettizer/paletteGroup.h index 31490f69b4..615663b571 100644 --- a/pandatool/src/palettizer/paletteGroup.h +++ b/pandatool/src/palettizer/paletteGroup.h @@ -1,16 +1,15 @@ -// Filename: paletteGroup.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteGroup.h + * @author drose + * @date 2000-11-28 + */ #ifndef PALETTEGROUP_H #define PALETTEGROUP_H @@ -33,17 +32,14 @@ class PalettePage; class TextureImage; class TxaFile; -//////////////////////////////////////////////////////////////////// -// Class : PaletteGroup -// Description : This is the highest level of grouping for -// TextureImages. Textures are assigned to one or -// several PaletteGroups based on the information in the -// .txa file; each PaletteGroup is conceptually a -// collection of textures that are to be moved around -// (into texture memory, downloaded, etc.) in one big -// chunk. It is the set of all textures that may be -// displayed together at any given time. -//////////////////////////////////////////////////////////////////// +/** + * This is the highest level of grouping for TextureImages. Textures are + * assigned to one or several PaletteGroups based on the information in the + * .txa file; each PaletteGroup is conceptually a collection of textures that + * are to be moved around (into texture memory, downloaded, etc.) in one big + * chunk. It is the set of all textures that may be displayed together at any + * given time. + */ class PaletteGroup : public TypedWritable, public Namable { public: PaletteGroup(); @@ -123,8 +119,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // These values are only filled in while reading from the bam file; - // don't use them otherwise. + // These values are only filled in while reading from the bam file; don't + // use them otherwise. int _num_placements; int _num_pages; bool _has_margin_override; @@ -153,4 +149,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/paletteGroups.cxx b/pandatool/src/palettizer/paletteGroups.cxx index 6e99ecfb25..ae1f810d5e 100644 --- a/pandatool/src/palettizer/paletteGroups.cxx +++ b/pandatool/src/palettizer/paletteGroups.cxx @@ -1,16 +1,15 @@ -// Filename: paletteGroups.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteGroups.cxx + * @author drose + * @date 2000-11-30 + */ #include "paletteGroups.h" #include "paletteGroup.h" @@ -25,68 +24,53 @@ TypeHandle PaletteGroups::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteGroups:: PaletteGroups() { } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteGroups:: PaletteGroups(const PaletteGroups ©) : _groups(copy._groups) { } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::operator = -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PaletteGroups:: operator = (const PaletteGroups ©) { _groups = copy._groups; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::insert -// Access: Public -// Description: Inserts a new group to the set, if it is not already -// there. -//////////////////////////////////////////////////////////////////// +/** + * Inserts a new group to the set, if it is not already there. + */ void PaletteGroups:: insert(PaletteGroup *group) { _groups.insert(group); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::count -// Access: Public -// Description: Returns the number of times the given group appears -// in the set. This is either 1 if it appears at all, -// or 0 if it does not appear. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of times the given group appears in the set. This is + * either 1 if it appears at all, or 0 if it does not appear. + */ PaletteGroups::size_type PaletteGroups:: count(PaletteGroup *group) const { return _groups.count(group); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::make_complete -// Access: Public -// Description: Completes the set with the transitive closure of all -// dependencies: for each PaletteGroup already in the -// set a, all of the groups that it depends on are added -// to the set, and so on. The indicated set a may be -// the same as this set. -//////////////////////////////////////////////////////////////////// +/** + * Completes the set with the transitive closure of all dependencies: for each + * PaletteGroup already in the set a, all of the groups that it depends on are + * added to the set, and so on. The indicated set a may be the same as this + * set. + */ void PaletteGroups:: make_complete(const PaletteGroups &a) { Groups result; @@ -99,13 +83,10 @@ make_complete(const PaletteGroups &a) { _groups.swap(result); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::make_union -// Access: Public -// Description: Computes the union of PaletteGroups a and b, and -// stores the result in this object. The result may be -// the same object as either a or b. -//////////////////////////////////////////////////////////////////// +/** + * Computes the union of PaletteGroups a and b, and stores the result in this + * object. The result may be the same object as either a or b. + */ void PaletteGroups:: make_union(const PaletteGroups &a, const PaletteGroups &b) { Groups u; @@ -143,13 +124,10 @@ make_union(const PaletteGroups &a, const PaletteGroups &b) { _groups.swap(u); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::make_intersection -// Access: Public -// Description: Computes the intersection of PaletteGroups a and b, -// and stores the result in this object. The result may -// be the same object as either a or b. -//////////////////////////////////////////////////////////////////// +/** + * Computes the intersection of PaletteGroups a and b, and stores the result + * in this object. The result may be the same object as either a or b. + */ void PaletteGroups:: make_intersection(const PaletteGroups &a, const PaletteGroups &b) { Groups i; @@ -175,14 +153,11 @@ make_intersection(const PaletteGroups &a, const PaletteGroups &b) { _groups.swap(i); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::remove_null -// Access: Public -// Description: Removes the special "null" group from the set. This -// is a special group that egg files may be assigned to, -// but which textures never are; it indicates that the -// egg file should not influence the palette assignment. -//////////////////////////////////////////////////////////////////// +/** + * Removes the special "null" group from the set. This is a special group + * that egg files may be assigned to, but which textures never are; it + * indicates that the egg file should not influence the palette assignment. + */ void PaletteGroups:: remove_null() { Groups::iterator gi; @@ -194,61 +169,49 @@ remove_null() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::clear -// Access: Public -// Description: Empties the set. -//////////////////////////////////////////////////////////////////// +/** + * Empties the set. + */ void PaletteGroups:: clear() { _groups.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::empty -// Access: Public -// Description: Returns true if the set is empty, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the set is empty, false otherwise. + */ bool PaletteGroups:: empty() const { return _groups.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::size -// Access: Public -// Description: Returns the number of elements in the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of elements in the set. + */ PaletteGroups::size_type PaletteGroups:: size() const { return _groups.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::begin -// Access: Public -// Description: Returns an iterator suitable for traversing the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator suitable for traversing the set. + */ PaletteGroups::iterator PaletteGroups:: begin() const { return _groups.begin(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::end -// Access: Public -// Description: Returns an iterator suitable for traversing the set. -//////////////////////////////////////////////////////////////////// +/** + * Returns an iterator suitable for traversing the set. + */ PaletteGroups::iterator PaletteGroups:: end() const { return _groups.end(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PaletteGroups:: output(ostream &out) const { if (!_groups.empty()) { @@ -272,11 +235,9 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PaletteGroups:: write(ostream &out, int indent_level) const { // Sort the group names into order by name for output. @@ -288,20 +249,17 @@ write(ostream &out, int indent_level) const { } sort(group_vector.begin(), group_vector.end(), IndirectCompareNames()); - + pvector::const_iterator gvi; for (gvi = group_vector.begin(); gvi != group_vector.end(); ++gvi) { indent(out, indent_level) << (*gvi)->get_name() << "\n"; } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::r_make_complete -// Access: Private -// Description: The recursive implementation of make_complete(), this -// adds the indicated group and all of its dependencies -// to the set. -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of make_complete(), this adds the indicated + * group and all of its dependencies to the set. + */ void PaletteGroups:: r_make_complete(PaletteGroups::Groups &result, PaletteGroup *group) { bool inserted = result.insert(group).second; @@ -316,25 +274,19 @@ r_make_complete(PaletteGroups::Groups &result, PaletteGroup *group) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PaletteGroups:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PaletteGroups); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void PaletteGroups:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -346,15 +298,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int PaletteGroups:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -366,14 +315,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::make_PaletteGroups -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* PaletteGroups:: make_PaletteGroups(const FactoryParams ¶ms) { PaletteGroups *me = new PaletteGroups; @@ -385,13 +331,10 @@ make_PaletteGroups(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteGroups::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void PaletteGroups:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/paletteGroups.h b/pandatool/src/palettizer/paletteGroups.h index c3831c1607..2be2eb4602 100644 --- a/pandatool/src/palettizer/paletteGroups.h +++ b/pandatool/src/palettizer/paletteGroups.h @@ -1,16 +1,15 @@ -// Filename: paletteGroups.h -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteGroups.h + * @author drose + * @date 2000-11-30 + */ #ifndef PALETTEGROUPS_H #define PALETTEGROUPS_H @@ -22,12 +21,10 @@ class PaletteGroup; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : PaletteGroups -// Description : A set of PaletteGroups. This presents an interface -// very like an STL set, with a few additional -// functions. -//////////////////////////////////////////////////////////////////// +/** + * A set of PaletteGroups. This presents an interface very like an STL set, + * with a few additional functions. + */ class PaletteGroups : public TypedWritable { private: typedef pset Groups; @@ -85,8 +82,8 @@ public: void fillin(DatagramIterator &scan, BamReader *manager); private: - // This value is only filled in while reading from the bam file; - // don't use it otherwise. + // This value is only filled in while reading from the bam file; don't use + // it otherwise. int _num_groups; public: @@ -112,4 +109,3 @@ INLINE ostream &operator << (ostream &out, const PaletteGroups &groups) { } #endif - diff --git a/pandatool/src/palettizer/paletteImage.cxx b/pandatool/src/palettizer/paletteImage.cxx index 8e0edb34d8..9b664a159d 100644 --- a/pandatool/src/palettizer/paletteImage.cxx +++ b/pandatool/src/palettizer/paletteImage.cxx @@ -1,16 +1,15 @@ -// Filename: paletteImage.cxx -// Created by: drose (01Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteImage.cxx + * @author drose + * @date 2000-12-01 + */ #include "paletteImage.h" #include "palettePage.h" @@ -32,12 +31,9 @@ TypeHandle PaletteImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::Default Constructor -// Access: Public -// Description: The default constructor is only for the convenience -// of the bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the bam reader. + */ PaletteImage::ClearedRegion:: ClearedRegion() { _x = 0; @@ -46,11 +42,9 @@ ClearedRegion() { _y_size = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteImage::ClearedRegion:: ClearedRegion(TexturePlacement *placement) { _x = placement->get_placed_x(); @@ -59,11 +53,9 @@ ClearedRegion(TexturePlacement *placement) { _y_size = placement->get_placed_y_size(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteImage::ClearedRegion:: ClearedRegion(const PaletteImage::ClearedRegion ©) : _x(copy._x), @@ -73,11 +65,9 @@ ClearedRegion(const PaletteImage::ClearedRegion ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PaletteImage::ClearedRegion:: operator = (const PaletteImage::ClearedRegion ©) { _x = copy._x; @@ -86,11 +76,9 @@ operator = (const PaletteImage::ClearedRegion ©) { _y_size = copy._y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::clear -// Access: Public -// Description: Sets the appropriate region of the image to black. -//////////////////////////////////////////////////////////////////// +/** + * Sets the appropriate region of the image to black. + */ void PaletteImage::ClearedRegion:: clear(PNMImage &image) { LRGBColorf rgb(pal->_background[0], pal->_background[1], pal->_background[2]); @@ -110,12 +98,9 @@ clear(PNMImage &image) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::write_datagram -// Access: Public -// Description: Writes the contents of the ClearedRegion to the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of the ClearedRegion to the indicated datagram. + */ void PaletteImage::ClearedRegion:: write_datagram(Datagram &datagram) const { datagram.add_int32(_x); @@ -124,12 +109,9 @@ write_datagram(Datagram &datagram) const { datagram.add_int32(_y_size); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::ClearedRegion::write_datagram -// Access: Public -// Description: Extracts the contents of the ClearedRegion from the -// indicated datagram. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the contents of the ClearedRegion from the indicated datagram. + */ void PaletteImage::ClearedRegion:: fillin(DatagramIterator &scan) { _x = scan.get_int32(); @@ -143,12 +125,9 @@ fillin(DatagramIterator &scan) { -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::Default Constructor -// Access: Private -// Description: The default constructor is only for the convenience -// of the Bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the Bam reader. + */ PaletteImage:: PaletteImage() { _page = (PalettePage *)NULL; @@ -159,11 +138,9 @@ PaletteImage() { _swapped_image = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteImage:: PaletteImage(PalettePage *page, int index) : _page(page), @@ -180,11 +157,9 @@ PaletteImage(PalettePage *page, int index) : setup_filename(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PaletteImage:: PaletteImage(PalettePage *page, int index, unsigned swapIndex) : _page(page), @@ -202,24 +177,19 @@ PaletteImage(PalettePage *page, int index, unsigned swapIndex) : } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::get_page -// Access: Public -// Description: Returns the particular PalettePage this image is -// associated with. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular PalettePage this image is associated with. + */ PalettePage *PaletteImage:: get_page() const { return _page; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::is_empty -// Access: Public -// Description: Returns true if there are no textures, or only one -// "solitary" texture, placed on the image. In either -// case, the PaletteImage need not be generated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there are no textures, or only one "solitary" texture, + * placed on the image. In either case, the PaletteImage need not be + * generated. + */ bool PaletteImage:: is_empty() const { if (_placements.empty()) { @@ -227,25 +197,21 @@ is_empty() const { return true; } else if (_placements.size() == 1) { - // If the image has exactly one texture, we consider the image - // empty only if the texture is actually flagged as 'solitary'. + // If the image has exactly one texture, we consider the image empty only + // if the texture is actually flagged as 'solitary'. return (_placements[0]->get_omit_reason() == OR_solitary); } else { - // The image has more than one texture, so it's definitely not - // empty. + // The image has more than one texture, so it's definitely not empty. return false; } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::count_utilization -// Access: Public -// Description: Returns the fraction of the PaletteImage that is -// actually used by any textures. This is 1.0 if every -// pixel in the PaletteImage is used, or 0.0 if none -// are. Normally it will be somewhere in between. -//////////////////////////////////////////////////////////////////// +/** + * Returns the fraction of the PaletteImage that is actually used by any + * textures. This is 1.0 if every pixel in the PaletteImage is used, or 0.0 + * if none are. Normally it will be somewhere in between. + */ double PaletteImage:: count_utilization() const { int used_pixels = 0; @@ -265,18 +231,14 @@ count_utilization() const { return (double)used_pixels / (double)total_pixels; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::count_coverage -// Access: Public -// Description: Returns the a weighted average of the fraction of -// coverage represented by all of the textures placed on -// the palette. This number represents the fraction of -// wasted pixels in the palette image consumed by -// copying the same pixels multiple times into the -// palette, or if the number is negative, it represents -// the fraction of pixels saved by not having to copy -// the entire texture into the palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the a weighted average of the fraction of coverage represented by + * all of the textures placed on the palette. This number represents the + * fraction of wasted pixels in the palette image consumed by copying the same + * pixels multiple times into the palette, or if the number is negative, it + * represents the fraction of pixels saved by not having to copy the entire + * texture into the palette. + */ double PaletteImage:: count_coverage() const { int coverage_pixels = 0; @@ -302,13 +264,10 @@ count_coverage() const { return (double)coverage_pixels / (double)total_pixels; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::place -// Access: Public -// Description: Attempts to place the indicated texture on the image. -// Returns true if successful, or false if there was no -// available space. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to place the indicated texture on the image. Returns true if + * successful, or false if there was no available space. + */ bool PaletteImage:: place(TexturePlacement *placement) { nassertr(placement->is_size_known(), true); @@ -335,11 +294,9 @@ place(TexturePlacement *placement) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::unplace -// Access: Public -// Description: Removes the texture from the image. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture from the image. + */ void PaletteImage:: unplace(TexturePlacement *placement) { nassertv(placement->is_placed() && placement->get_image() == this); @@ -353,18 +310,15 @@ unplace(TexturePlacement *placement) { _cleared_regions.push_back(ClearedRegion(placement)); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::check_solitary -// Access: Public -// Description: To be called after all textures have been placed on -// the image, this checks to see if there is only one -// texture on the image. If there is, it is flagged as -// 'solitary' so that the egg files will not needlessly -// reference the palettized image. -// -// However, if pal->_omit_solitary is false, we -// generally don't change textures to solitary state. -//////////////////////////////////////////////////////////////////// +/** + * To be called after all textures have been placed on the image, this checks + * to see if there is only one texture on the image. If there is, it is + * flagged as 'solitary' so that the egg files will not needlessly reference + * the palettized image. + * + * However, if pal->_omit_solitary is false, we generally don't change + * textures to solitary state. + */ void PaletteImage:: check_solitary() { if (_placements.size() == 1) { @@ -374,10 +328,10 @@ check_solitary() { placement->get_omit_reason() == OR_solitary); if (pal->_omit_solitary || placement->get_omit_reason() == OR_solitary) { - // We only omit the solitary texture if (a) we have - // omit_solitary in effect, or (b) we don't have omit_solitary - // in effect now, but we did before, and the texture is still - // flagged as solitary from that previous pass. + // We only omit the solitary texture if (a) we have omit_solitary in + // effect, or (b) we don't have omit_solitary in effect now, but we did + // before, and the texture is still flagged as solitary from that + // previous pass. placement->omit_solitary(); } @@ -400,12 +354,9 @@ check_solitary() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::optimal_resize -// Access: Public -// Description: Attempts to resize the palette image to as small as -// it can go. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize the palette image to as small as it can go. + */ void PaletteImage:: optimal_resize() { if (is_empty()) { // && (_swapped_image == 0)) { @@ -440,28 +391,23 @@ optimal_resize() { for (si = _swappedImages.begin(); si != _swappedImages.end(); ++si) { PaletteImage *swappedImage = (*si); swappedImage->resize_swapped_image(_x_size, _y_size); - } + } } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::resize_image -// Access: Public -// Description: Attempts to resize the palette image, and repack all -// of the textures within the new size. Returns true if -// successful, false otherwise. If this fails, it will -// still result in repacking all the textures in the -// original size. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize the palette image, and repack all of the textures within + * the new size. Returns true if successful, false otherwise. If this fails, + * it will still result in repacking all the textures in the original size. + */ bool PaletteImage:: resize_image(int x_size, int y_size) { - // We already know we're going to be generating a new image from - // scratch after this. + // We already know we're going to be generating a new image from scratch + // after this. _cleared_regions.clear(); remove_image(); - // First, Save the current placement list, while simultaneously - // clearing it. + // First, Save the current placement list, while simultaneously clearing it. Placements saved; saved.swap(_placements); @@ -469,12 +415,11 @@ resize_image(int x_size, int y_size) { int saved_x_size = _x_size; int saved_y_size = _y_size; - // Then, sort the textures to in order from biggest to smallest, as - // an aid to optimal packing. + // Then, sort the textures to in order from biggest to smallest, as an aid + // to optimal packing. sort(saved.begin(), saved.end(), SortPlacementBySize()); - // And while we're at it, we need to officially unplace each of - // these. + // And while we're at it, we need to officially unplace each of these. Placements::iterator pi; for (pi = saved.begin(); pi != saved.end(); ++pi) { (*pi)->force_replace(); @@ -514,15 +459,11 @@ resize_image(int x_size, int y_size) { return packed; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::resize_swapped_image -// Access: Public -// Description: Attempts to resize the palette image, and repack all -// of the textures within the new size. Returns true if -// successful, false otherwise. If this fails, it will -// still result in repacking all the textures in the -// original size. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize the palette image, and repack all of the textures within + * the new size. Returns true if successful, false otherwise. If this fails, + * it will still result in repacking all the textures in the original size. + */ void PaletteImage:: resize_swapped_image(int x_size, int y_size) { // Finally, apply the new size and try to fit all the textures. @@ -530,13 +471,10 @@ resize_swapped_image(int x_size, int y_size) { _y_size = y_size; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::write_placements -// Access: Public -// Description: Writes a list of the textures that have been placed -// on this image to the indicated output stream, one per -// line. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the textures that have been placed on this image to the + * indicated output stream, one per line. + */ void PaletteImage:: write_placements(ostream &out, int indent_level) const { Placements::const_iterator pi; @@ -546,12 +484,10 @@ write_placements(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::reset_image -// Access: Public -// Description: Unpacks each texture that has been placed on this -// image, resetting the image to empty. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks each texture that has been placed on this image, resetting the + * image to empty. + */ void PaletteImage:: reset_image() { // We need a copy so we can modify this list as we traverse it. @@ -567,13 +503,10 @@ reset_image() { remove_image(); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::setup_shadow_image -// Access: Public -// Description: Ensures the _shadow_image has the correct filename -// and image types, based on what was supplied on the -// command line and in the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Ensures the _shadow_image has the correct filename and image types, based + * on what was supplied on the command line and in the .txa file. + */ void PaletteImage:: setup_shadow_image() { _shadow_image.make_shadow_image(_basename); @@ -583,22 +516,19 @@ setup_shadow_image() { for (si = _swappedImages.begin(); si != _swappedImages.end(); ++si) { PaletteImage *swappedImage = (*si); swappedImage->setup_shadow_image(); - } + } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::update_image -// Access: Public -// Description: If the palette has changed since it was last written -// out, updates the image and writes out a new one. If -// redo_all is true, regenerates the image from scratch -// and writes it out again, whether it needed it or not. -//////////////////////////////////////////////////////////////////// +/** + * If the palette has changed since it was last written out, updates the image + * and writes out a new one. If redo_all is true, regenerates the image from + * scratch and writes it out again, whether it needed it or not. + */ void PaletteImage:: update_image(bool redo_all) { if (is_empty() && pal->_aggressively_clean_mapdir) { - // If the palette image is 'empty', ensure that it doesn't exist. - // No need to clutter up the map directory. + // If the palette image is 'empty', ensure that it doesn't exist. No need + // to clutter up the map directory. remove_image(); return; } @@ -617,9 +547,9 @@ update_image(bool redo_all) { !_cleared_regions.empty(); Placements::iterator pi; - // We must continue to walk through all of the textures on the - // palette, even after we discover the palette requires an update, - // so we can determine which source images need to be recopied. + // We must continue to walk through all of the textures on the palette, even + // after we discover the palette requires an update, so we can determine + // which source images need to be recopied. for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); @@ -629,8 +559,8 @@ update_image(bool redo_all) { } else { TextureImage *texture = placement->get_texture(); - // Only check the timestamps on textures that are named - // (indirectly) on the command line. + // Only check the timestamps on textures that are named (indirectly) on + // the command line. if (texture->is_texture_named()) { SourceTextureImage *source = texture->get_preferred_source(); @@ -724,15 +654,11 @@ update_image(bool redo_all) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::update_filename -// Access: Public -// Description: Changes the image filename to match the current -// naming scheme, assuming something has changed since -// the image was created. Returns true if the image -// filename changes (which means update_image() should -// be called). -//////////////////////////////////////////////////////////////////// +/** + * Changes the image filename to match the current naming scheme, assuming + * something has changed since the image was created. Returns true if the + * image filename changes (which means update_image() should be called). + */ bool PaletteImage:: update_filename() { Filename orig_filename = _filename; @@ -740,7 +666,7 @@ update_filename() { Filename orig_shadow_filename = _shadow_image.get_filename(); if (setup_filename()) { - nout << "Renaming " << FilenameUnifier::make_user_filename(orig_filename) + nout << "Renaming " << FilenameUnifier::make_user_filename(orig_filename) << " to " << FilenameUnifier::make_user_filename(_filename) << "\n"; if (!orig_filename.empty() && orig_filename.exists()) { @@ -757,12 +683,12 @@ update_filename() { } _new_image = true; - // Since the palette filename has changed, we need to mark all of - // the egg files that referenced the old filename as stale. + // Since the palette filename has changed, we need to mark all of the egg + // files that referenced the old filename as stale. - // Marking egg files stale at this late point can cause minor - // problems; because we might do this, it's necessary for - // eggPalettize.cxx to call read_stale_eggs() twice. + // Marking egg files stale at this late point can cause minor problems; + // because we might do this, it's necessary for eggPalettize.cxx to call + // read_stale_eggs() twice. Placements::iterator pi; for (pi = _placements.begin(); pi != _placements.end(); ++pi) { TexturePlacement *placement = (*pi); @@ -775,19 +701,17 @@ update_filename() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::setup_filename -// Access: Private -// Description: Sets up the image's filename (and that of the -// _shadow_pal) according to the specified properties. -// -// Returns true if the filename changes from what it was -// previously, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the image's filename (and that of the _shadow_pal) according to the + * specified properties. + * + * Returns true if the filename changes from what it was previously, false + * otherwise. + */ bool PaletteImage:: setup_filename() { - // Build up the basename for the palette image, based on the - // supplied image pattern. + // Build up the basename for the palette image, based on the supplied image + // pattern. _basename = string(); string::iterator si = pal->_generated_image_pattern.begin(); @@ -830,11 +754,11 @@ setup_filename() { _basename += "_swp_"; _basename += format_string(_swapped_image); } - - // We must end the basename with a dot, so that it does not appear - // to have a filename extension. Otherwise, an embedded dot in the - // group's name would make everything following appear to be an - // extension, which would get lost in the set_filename() call. + + // We must end the basename with a dot, so that it does not appear to have a + // filename extension. Otherwise, an embedded dot in the group's name would + // make everything following appear to be an extension, which would get lost + // in the set_filename() call. if (_basename.empty() || _basename[_basename.length() - 1] != '.') { _basename += '.'; } @@ -848,18 +772,15 @@ setup_filename() { if (_shadow_image.make_shadow_image(_basename)) { any_changed = true; } - + return any_changed; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::find_hole -// Access: Private -// Description: Searches for a hole of at least x_size by y_size -// pixels somewhere within the PaletteImage. If a -// suitable hole is found, sets x and y to the top left -// corner and returns true; otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Searches for a hole of at least x_size by y_size pixels somewhere within + * the PaletteImage. If a suitable hole is found, sets x and y to the top + * left corner and returns true; otherwise, returns false. + */ bool PaletteImage:: find_hole(int &x, int &y, int x_size, int y_size) const { y = 0; @@ -892,17 +813,13 @@ find_hole(int &x, int &y, int x_size, int y_size) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::find_overlap -// Access: Private -// Description: If the rectangle whose top left corner is x, y and -// whose size is x_size, y_size describes an empty hole -// that does not overlap any placed images, returns -// NULL; otherwise, returns the first placed texture -// that the image does overlap. It is assumed the -// rectangle lies completely within the boundaries of -// the image itself. -//////////////////////////////////////////////////////////////////// +/** + * If the rectangle whose top left corner is x, y and whose size is x_size, + * y_size describes an empty hole that does not overlap any placed images, + * returns NULL; otherwise, returns the first placed texture that the image + * does overlap. It is assumed the rectangle lies completely within the + * boundaries of the image itself. + */ TexturePlacement *PaletteImage:: find_overlap(int x, int y, int x_size, int y_size) const { Placements::const_iterator pi; @@ -917,12 +834,10 @@ find_overlap(int x, int y, int x_size, int y_size) const { return (TexturePlacement *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::get_image -// Access: Public -// Description: Reads or generates the PNMImage that corresponds to -// the palette as it is known so far. -//////////////////////////////////////////////////////////////////// +/** + * Reads or generates the PNMImage that corresponds to the palette as it is + * known so far. + */ void PaletteImage:: get_image() { if (_got_image) { @@ -966,11 +881,9 @@ get_image() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::get_swapped_image -// Access: Public -// Description: Reads or generates the PNMImage for swapped textures -//////////////////////////////////////////////////////////////////// +/** + * Reads or generates the PNMImage for swapped textures + */ void PaletteImage:: get_swapped_image(int index) { if (_got_image) { @@ -1018,12 +931,10 @@ get_swapped_image(int index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::get_swapped_images -// Access: Public -// Description: Reads or generates the PNMImage that corresponds to -// the palette as it is known so far. -//////////////////////////////////////////////////////////////////// +/** + * Reads or generates the PNMImage that corresponds to the palette as it is + * known so far. + */ void PaletteImage:: get_swapped_images() { SwappedImages::iterator si; @@ -1033,23 +944,18 @@ get_swapped_images() { } } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::release_image -// Access: Public -// Description: Deallocates the memory allocated by a previous call to -// get_image(). -//////////////////////////////////////////////////////////////////// +/** + * Deallocates the memory allocated by a previous call to get_image(). + */ void PaletteImage:: release_image() { _image.clear(); _got_image = false; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::remove_image -// Access: Private -// Description: Deletes the image file. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the image file. + */ void PaletteImage:: remove_image() { unlink(); @@ -1059,25 +965,19 @@ remove_image() { _new_image = true; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PaletteImage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PaletteImage); } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void PaletteImage:: write_datagram(BamWriter *writer, Datagram &datagram) { ImageFile::write_datagram(writer, datagram); @@ -1099,24 +999,19 @@ write_datagram(BamWriter *writer, Datagram &datagram) { datagram.add_string(_basename); datagram.add_bool(_new_image); - // We don't write _got_image or _image. These are loaded - // per-session. + // We don't write _got_image or _image. These are loaded per-session. - // We don't write _shadow_image. This is just a runtime convenience - // for specifying the name of the shadow file, and we redefine this - // per-session (which allows us to pick up a new - // pal->_shadow_dirname if it changes). + // We don't write _shadow_image. This is just a runtime convenience for + // specifying the name of the shadow file, and we redefine this per-session + // (which allows us to pick up a new pal->_shadow_dirname if it changes). } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int PaletteImage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = ImageFile::complete_pointers(p_list, manager); @@ -1138,14 +1033,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::make_PaletteImage -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable *PaletteImage:: make_PaletteImage(const FactoryParams ¶ms) { PaletteImage *me = new PaletteImage; @@ -1157,13 +1049,10 @@ make_PaletteImage(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PaletteImage::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void PaletteImage:: fillin(DatagramIterator &scan, BamReader *manager) { ImageFile::fillin(scan, manager); diff --git a/pandatool/src/palettizer/paletteImage.h b/pandatool/src/palettizer/paletteImage.h index 0ad50e8eea..314942e8ab 100644 --- a/pandatool/src/palettizer/paletteImage.h +++ b/pandatool/src/palettizer/paletteImage.h @@ -1,16 +1,15 @@ -// Filename: paletteImage.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file paletteImage.h + * @author drose + * @date 2000-11-28 + */ #ifndef PALETTEIMAGE_H #define PALETTEIMAGE_H @@ -24,15 +23,12 @@ class PalettePage; class TexturePlacement; -//////////////////////////////////////////////////////////////////// -// Class : PaletteImage -// Description : This is a single palette image, one of several within -// a PalettePage, which is in turn one of several pages -// within a PaletteGroup. Each palette image is a -// collage of several different textures that were all -// assigned to the same PaletteGroup, and all share the -// same properties of the PalettePage. -//////////////////////////////////////////////////////////////////// +/** + * This is a single palette image, one of several within a PalettePage, which + * is in turn one of several pages within a PaletteGroup. Each palette image + * is a collage of several different textures that were all assigned to the + * same PaletteGroup, and all share the same properties of the PalettePage. + */ class PaletteImage : public ImageFile { private: PaletteImage(); @@ -72,8 +68,8 @@ private: void get_swapped_image(int index); void get_swapped_images(); - // The ClearedRegion object keeps track of TexturePlacements that - // were recently removed and thus need to be set to black. + // The ClearedRegion object keeps track of TexturePlacements that were + // recently removed and thus need to be set to black. class ClearedRegion { public: ClearedRegion(); @@ -105,7 +101,7 @@ private: bool _new_image; bool _got_image; PNMImage _image; - + unsigned _swapped_image; // 0 for non swapped image ImageFile _shadow_image; @@ -125,8 +121,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // This value is only filled in while reading from the bam file; - // don't use it otherwise. + // This value is only filled in while reading from the bam file; don't use + // it otherwise. int _num_placements; public: @@ -147,4 +143,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/palettePage.cxx b/pandatool/src/palettizer/palettePage.cxx index d5b92a85ee..8c04405927 100644 --- a/pandatool/src/palettizer/palettePage.cxx +++ b/pandatool/src/palettizer/palettePage.cxx @@ -1,16 +1,15 @@ -// Filename: palettePage.cxx -// Created by: drose (01Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file palettePage.cxx + * @author drose + * @date 2000-12-01 + */ #include "palettePage.h" #include "texturePlacement.h" @@ -28,22 +27,17 @@ TypeHandle PalettePage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::Default Constructor -// Access: Private -// Description: The default constructor is only for the convenience -// of the Bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the Bam reader. + */ PalettePage:: PalettePage() { _group = (PaletteGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PalettePage:: PalettePage(PaletteGroup *group, const TextureProperties &properties) : Namable(properties.get_string()), @@ -52,50 +46,40 @@ PalettePage(PaletteGroup *group, const TextureProperties &properties) : { } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::get_group -// Access: Public -// Description: Returns the group this particular PalettePage belongs -// to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the group this particular PalettePage belongs to. + */ PaletteGroup *PalettePage:: get_group() const { return _group; } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::get_properties -// Access: Public -// Description: Returns the texture grouping properties that all -// textures in this page share. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture grouping properties that all textures in this page + * share. + */ const TextureProperties &PalettePage:: get_properties() const { return _properties; } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::assign -// Access: Public -// Description: Adds the indicated texture to the list of textures to -// consider placing on the page. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated texture to the list of textures to consider placing on + * the page. + */ void PalettePage:: assign(TexturePlacement *placement) { _assigned.push_back(placement); } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::place_all -// Access: Public -// Description: Assigns all the textures to their final home in a -// PaletteImage somewhere. -//////////////////////////////////////////////////////////////////// +/** + * Assigns all the textures to their final home in a PaletteImage somewhere. + */ void PalettePage:: place_all() { - // Sort the textures to be placed in order from biggest to smallest, - // as an aid to optimal packing. + // Sort the textures to be placed in order from biggest to smallest, as an + // aid to optimal packing. sort(_assigned.begin(), _assigned.end(), SortPlacementBySize()); Assigned::const_iterator ai; @@ -106,9 +90,9 @@ place_all() { _assigned.clear(); - // Now, look for solitary images; these are left placed, but flagged - // with OR_solitary, so they won't go into egg references. There's - // no real point in referencing these. + // Now, look for solitary images; these are left placed, but flagged with + // OR_solitary, so they won't go into egg references. There's no real point + // in referencing these. Images::iterator ii; for (ii = _images.begin(); ii != _images.end(); ++ii) { PaletteImage *image = (*ii); @@ -116,12 +100,9 @@ place_all() { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::place -// Access: Public -// Description: Assigns the particular TexturePlacement to a -// PaletteImage where it fits. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the particular TexturePlacement to a PaletteImage where it fits. + */ void PalettePage:: place(TexturePlacement *placement) { nassertv(placement->get_omit_reason() == OR_working); @@ -146,25 +127,19 @@ place(TexturePlacement *placement) { } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::unplace -// Access: Public -// Description: Removes the TexturePlacement from wherever it has -// been placed. -//////////////////////////////////////////////////////////////////// +/** + * Removes the TexturePlacement from wherever it has been placed. + */ void PalettePage:: unplace(TexturePlacement *placement) { nassertv(placement->is_placed() && placement->get_page() == this); placement->get_image()->unplace(placement); } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::write_image_info -// Access: Public -// Description: Writes a list of the PaletteImages associated with -// this page, and all of their textures, to the -// indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes a list of the PaletteImages associated with this page, and all of + * their textures, to the indicated output stream. + */ void PalettePage:: write_image_info(ostream &out, int indent_level) const { Images::const_iterator ii; @@ -179,12 +154,9 @@ write_image_info(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::optimal_resize -// Access: Public -// Description: Attempts to resize each PalettteImage down to its -// smallest possible size. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize each PalettteImage down to its smallest possible size. + */ void PalettePage:: optimal_resize() { Images::iterator ii; @@ -194,13 +166,10 @@ optimal_resize() { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::reset_images -// Access: Public -// Description: Throws away all of the current PaletteImages, so that -// new ones may be created (and the packing made more -// optimal). -//////////////////////////////////////////////////////////////////// +/** + * Throws away all of the current PaletteImages, so that new ones may be + * created (and the packing made more optimal). + */ void PalettePage:: reset_images() { Images::iterator ii; @@ -213,14 +182,11 @@ reset_images() { _images.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::setup_shadow_images -// Access: Public -// Description: Ensures that each PaletteImage's _shadow_image has -// the correct filename and image types, based on what -// was supplied on the command line and in the .txa -// file. -//////////////////////////////////////////////////////////////////// +/** + * Ensures that each PaletteImage's _shadow_image has the correct filename and + * image types, based on what was supplied on the command line and in the .txa + * file. + */ void PalettePage:: setup_shadow_images() { Images::iterator ii; @@ -230,12 +196,9 @@ setup_shadow_images() { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::update_images -// Access: Public -// Description: Regenerates each PaletteImage on this page that needs -// it. -//////////////////////////////////////////////////////////////////// +/** + * Regenerates each PaletteImage on this page that needs it. + */ void PalettePage:: update_images(bool redo_all) { Images::iterator ii; @@ -245,25 +208,19 @@ update_images(bool redo_all) { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void PalettePage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_PalettePage); } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void PalettePage:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -281,15 +238,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int PalettePage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -312,14 +266,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::make_PalettePage -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* PalettePage:: make_PalettePage(const FactoryParams ¶ms) { PalettePage *me = new PalettePage; @@ -331,13 +282,10 @@ make_PalettePage(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: PalettePage::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void PalettePage:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/palettePage.h b/pandatool/src/palettizer/palettePage.h index a2eee5e95c..35a17841dd 100644 --- a/pandatool/src/palettizer/palettePage.h +++ b/pandatool/src/palettizer/palettePage.h @@ -1,16 +1,15 @@ -// Filename: palettePage.h -// Created by: drose (01Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file palettePage.h + * @author drose + * @date 2000-12-01 + */ #ifndef PALETTEPAGE_H #define PALETTEPAGE_H @@ -26,14 +25,11 @@ class PaletteGroup; class PaletteImage; class TexturePlacement; -//////////////////////////////////////////////////////////////////// -// Class : PalettePage -// Description : This is a particular collection of textures, within a -// PaletteGroup, that all share the same -// TextureProperties. The textures on the same page may -// therefore all be placed on the same set of -// PaletteImages together. -//////////////////////////////////////////////////////////////////// +/** + * This is a particular collection of textures, within a PaletteGroup, that + * all share the same TextureProperties. The textures on the same page may + * therefore all be placed on the same set of PaletteImages together. + */ class PalettePage : public TypedWritable, public Namable { private: PalettePage(); @@ -77,8 +73,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // This value is only filled in while reading from the bam file; - // don't use it otherwise. + // This value is only filled in while reading from the bam file; don't use + // it otherwise. int _num_images; public: @@ -101,4 +97,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/palettizer.cxx b/pandatool/src/palettizer/palettizer.cxx index 34da013974..633647cb75 100644 --- a/pandatool/src/palettizer/palettizer.cxx +++ b/pandatool/src/palettizer/palettizer.cxx @@ -1,16 +1,15 @@ -// Filename: palettizer.cxx -// Created by: drose (01Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file palettizer.cxx + * @author drose + * @date 2000-12-01 + */ #include "palettizer.h" #include "eggFile.h" @@ -32,28 +31,30 @@ Palettizer *pal = (Palettizer *)NULL; -// This number is written out as the first number to the pi file, to -// indicate the version of egg-palettize that wrote it out. This -// allows us to easily update egg-palettize to write out additional -// information to its pi file, without having it increment the bam -// version number for all bam and boo files anywhere in the world. +// This number is written out as the first number to the pi file, to indicate +// the version of egg-palettize that wrote it out. This allows us to easily +// update egg-palettize to write out additional information to its pi file, +// without having it increment the bam version number for all bam and boo +// files anywhere in the world. int Palettizer::_pi_version = 20; -// Updated to version 8 on 3/20/03 to remove extensions from texture key names. -// Updated to version 9 on 4/13/03 to add a few properties in various places. -// Updated to version 10 on 4/15/03 to add _alpha_file_channel. -// Updated to version 11 on 4/30/03 to add TextureReference::_tref_name. -// Updated to version 12 on 9/11/03 to add _generated_image_pattern. -// Updated to version 13 on 9/13/03 to add _keep_format and _background. -// Updated to version 14 on 7/26/05 to add _omit_everything. -// Updated to version 15 on 8/01/05 to make TextureImages be case-insensitive. -// Updated to version 16 on 4/03/06 to add Palettizer::_cutout_mode et al. -// Updated to version 17 on 3/02/07 to add TextureImage::_txa_wrap_u etc. -// Updated to version 18 on 5/13/08 to add TextureProperties::_quality_level. -// Updated to version 19 on 7/16/09 to add PaletteGroup::_override_margin -// Updated to version 20 on 7/27/09 to add TexturePlacement::_swapTextures +/* + * Updated to version 8 on 32003 to remove extensions from texture key names. + * Updated to version 9 on 41303 to add a few properties in various places. + * Updated to version 10 on 41503 to add _alpha_file_channel. Updated to + * version 11 on 43003 to add TextureReference::_tref_name. Updated to + * version 12 on 91103 to add _generated_image_pattern. Updated to version 13 + * on 91303 to add _keep_format and _background. Updated to version 14 on + * 72605 to add _omit_everything. Updated to version 15 on 80105 to make + * TextureImages be case-insensitive. Updated to version 16 on 40306 to add + * Palettizer::_cutout_mode et al. Updated to version 17 on 30207 to add + * TextureImage::_txa_wrap_u etc. Updated to version 18 on 51308 to add + * TextureProperties::_quality_level. Updated to version 19 on 71609 to add + * PaletteGroup::_override_margin Updated to version 20 on 72709 to add + * TexturePlacement::_swapTextures + */ int Palettizer::_min_pi_version = 8; -// Dropped support for versions 7 and below on 7/14/03. +// Dropped support for versions 7 and below on 71403. int Palettizer::_read_pi_version = 0; @@ -97,11 +98,9 @@ public: } }; -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ Palettizer:: Palettizer() { _is_valid = true; @@ -134,59 +133,46 @@ Palettizer() { get_palette_group("null"); } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::get_noabs -// Access: Public -// Description: Returns the current setting of the noabs flag. See -// set_noabs(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current setting of the noabs flag. See set_noabs(). + */ bool Palettizer:: get_noabs() const { return _noabs; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::set_noabs -// Access: Public -// Description: Changes the current setting of the noabs flag. -// -// If this flag is true, then it is an error to process -// an egg file that contains absolute pathname -// references. This flag is intended to help detect egg -// files that are incorrectly built within a model tree -// (which should use entirely relative pathnames). -// -// This flag must be set before any egg files are -// processed. -//////////////////////////////////////////////////////////////////// +/** + * Changes the current setting of the noabs flag. + * + * If this flag is true, then it is an error to process an egg file that + * contains absolute pathname references. This flag is intended to help + * detect egg files that are incorrectly built within a model tree (which + * should use entirely relative pathnames). + * + * This flag must be set before any egg files are processed. + */ void Palettizer:: set_noabs(bool noabs) { _noabs = noabs; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::is_valid -// Access: Public -// Description: Returns true if the palette information file was read -// correctly, or false if there was some error and the -// palettization can't continue. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the palette information file was read correctly, or false + * if there was some error and the palettization can't continue. + */ bool Palettizer:: is_valid() const { return _is_valid; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::report_pi -// Access: Public -// Description: Output a verbose description of all the palettization -// information to standard output, for the user's -// perusal. -//////////////////////////////////////////////////////////////////// +/** + * Output a verbose description of all the palettization information to + * standard output, for the user's perusal. + */ void Palettizer:: report_pi() const { - // Start out with the cross links and back counts; some of these are - // nice to report. + // Start out with the cross links and back counts; some of these are nice to + // report. EggFiles::const_iterator efi; for (efi = _egg_files.begin(); efi != _egg_files.end(); ++efi) { (*efi).second->build_cross_links(); @@ -253,8 +239,8 @@ report_pi() const { egg_file->write_texture_refs(cout, 4); } - // Sort the palette groups into order of preference, so that the - // more specific ones appear at the bottom. + // Sort the palette groups into order of preference, so that the more + // specific ones appear at the bottom. pvector sorted_groups; Groups::const_iterator gi; for (gi = _groups.begin(); gi != _groups.end(); ++gi) { @@ -271,7 +257,8 @@ report_pi() const { cout << "\n"; } cout << " " << group->get_name() - // << " (" << group->get_dirname_order() << "," << group->get_dependency_order() << ")" + // << " (" << group->get_dirname_order() << "," << + // group->get_dependency_order() << ")" << ": " << group->get_groups() << "\n"; group->write_image_info(cout, 4); } @@ -299,12 +286,10 @@ report_pi() const { cout << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::report_statistics -// Access: Public -// Description: Output a report of the palettization effectiveness, -// texture memory utilization, and so on. -//////////////////////////////////////////////////////////////////// +/** + * Output a report of the palettization effectiveness, texture memory + * utilization, and so on. + */ void Palettizer:: report_statistics() const { // Sort the groups into order by dependency order, for the user's @@ -357,16 +342,14 @@ report_statistics() const { } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::read_txa_file -// Access: Public -// Description: Reads in the .txa file and keeps it ready for -// matching textures and egg files. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the .txa file and keeps it ready for matching textures and egg + * files. + */ void Palettizer:: read_txa_file(istream &txa_file, const string &txa_filename) { - // Clear out the group dependencies, in preparation for reading them - // again from the .txa file. + // Clear out the group dependencies, in preparation for reading them again + // from the .txa file. Groups::iterator gi; for (gi = _groups.begin(); gi != _groups.end(); ++gi) { PaletteGroup *group = (*gi).second; @@ -388,8 +371,8 @@ read_txa_file(istream &txa_file, const string &txa_filename) { exit(1); } - // Compute the correct dependency level and order for each group. - // This will help us when we assign the textures to their groups. + // Compute the correct dependency level and order for each group. This will + // help us when we assign the textures to their groups. for (gi = _groups.begin(); gi != _groups.end(); ++gi) { PaletteGroup *group = (*gi).second; group->reset_dependency_level(); @@ -412,13 +395,10 @@ read_txa_file(istream &txa_file, const string &txa_filename) { } while (any_changed); } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::all_params_set -// Access: Public -// Description: Called after all command line parameters have been -// set up, this is a hook to do whatever initialization -// is necessary. -//////////////////////////////////////////////////////////////////// +/** + * Called after all command line parameters have been set up, this is a hook + * to do whatever initialization is necessary. + */ void Palettizer:: all_params_set() { // Make sure the palettes have their shadow images set up properly. @@ -429,23 +409,18 @@ all_params_set() { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::process_command_line_eggs -// Access: Public -// Description: Processes all the textures named in the -// _command_line_eggs, placing them on the appropriate -// palettes or whatever needs to be done with them. -// -// If force_texture_read is true, it forces each texture -// image file to be read (and thus legitimately checked -// for grayscaleness etc.) before placing. -//////////////////////////////////////////////////////////////////// +/** + * Processes all the textures named in the _command_line_eggs, placing them on + * the appropriate palettes or whatever needs to be done with them. + * + * If force_texture_read is true, it forces each texture image file to be read + * (and thus legitimately checked for grayscaleness etc.) before placing. + */ void Palettizer:: process_command_line_eggs(bool force_texture_read, const Filename &state_filename) { _command_line_textures.clear(); - // Start by scanning all the egg files we read up on the command - // line. + // Start by scanning all the egg files we read up on the command line. CommandLineEggs::const_iterator ei; for (ei = _command_line_eggs.begin(); ei != _command_line_eggs.end(); @@ -454,21 +429,21 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam egg_file->scan_textures(); egg_file->get_textures(_command_line_textures); - + egg_file->pre_txa_file(); _txa_file.match_egg(egg_file); egg_file->post_txa_file(); } - // Now that all of our egg files are read in, build in all the cross - // links and back pointers and stuff. + // Now that all of our egg files are read in, build in all the cross links + // and back pointers and stuff. EggFiles::const_iterator efi; for (efi = _egg_files.begin(); efi != _egg_files.end(); ++efi) { (*efi).second->build_cross_links(); } - // Now match each of the textures mentioned in those egg files - // against a line in the .txa file. + // Now match each of the textures mentioned in those egg files against a + // line in the .txa file. CommandLineTextures::iterator ti; for (ti = _command_line_textures.begin(); ti != _command_line_textures.end(); @@ -476,8 +451,8 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam TextureImage *texture = *ti; if (force_texture_read || texture->is_newer_than(state_filename)) { - // If we're forcing a redo, or the texture image has changed, - // re-read the complete image. + // If we're forcing a redo, or the texture image has changed, re-read + // the complete image. texture->read_source_image(); } else { // Otherwise, just the header is sufficient. @@ -490,8 +465,8 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam texture->post_txa_file(); } - // And now, assign each of the current set of textures to an - // appropriate group or groups. + // And now, assign each of the current set of textures to an appropriate + // group or groups. for (ti = _command_line_textures.begin(); ti != _command_line_textures.end(); ++ti) { @@ -499,10 +474,10 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam texture->assign_groups(); } - // And then the egg files need to sign up for a particular - // TexturePlacement, so we can determine some more properties about - // how the textures are placed (for instance, how big the UV range - // is for a particular TexturePlacement). + // And then the egg files need to sign up for a particular TexturePlacement, + // so we can determine some more properties about how the textures are + // placed (for instance, how big the UV range is for a particular + // TexturePlacement). for (efi = _egg_files.begin(); efi != _egg_files.end(); ++efi) { (*efi).second->choose_placements(); } @@ -516,8 +491,8 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam texture->determine_placement_size(); } - // Now that each texture has been assigned to a suitable group, - // make sure the textures are placed on specific PaletteImages. + // Now that each texture has been assigned to a suitable group, make sure + // the textures are placed on specific PaletteImages. Groups::iterator gi; for (gi = _groups.begin(); gi != _groups.end(); ++gi) { PaletteGroup *group = (*gi).second; @@ -526,28 +501,24 @@ process_command_line_eggs(bool force_texture_read, const Filename &state_filenam } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::process_all -// Access: Public -// Description: Reprocesses all textures known. -// -// If force_texture_read is true, it forces each texture -// image file to be read (and thus legitimately checked -// for grayscaleness etc.) before placing. -//////////////////////////////////////////////////////////////////// +/** + * Reprocesses all textures known. + * + * If force_texture_read is true, it forces each texture image file to be read + * (and thus legitimately checked for grayscaleness etc.) before placing. + */ void Palettizer:: process_all(bool force_texture_read, const Filename &state_filename) { - // First, clear all the basic properties on the source texture - // images, so we can reapply them from the complete set of egg files - // and thereby ensure they are up-to-date. + // First, clear all the basic properties on the source texture images, so we + // can reapply them from the complete set of egg files and thereby ensure + // they are up-to-date. Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureImage *texture = (*ti).second; texture->clear_source_basic_properties(); } - // If there *were* any egg files on the command line, deal with - // them. + // If there *were* any egg files on the command line, deal with them. CommandLineEggs::const_iterator ei; for (ei = _command_line_eggs.begin(); ei != _command_line_eggs.end(); @@ -567,19 +538,18 @@ process_all(bool force_texture_read, const Filename &state_filename) { egg_file->post_txa_file(); } - // Now that all of our egg files are read in, build in all the cross - // links and back pointers and stuff. + // Now that all of our egg files are read in, build in all the cross links + // and back pointers and stuff. for (efi = _egg_files.begin(); efi != _egg_files.end(); ++efi) { (*efi).second->build_cross_links(); - // Also make sure each egg file's properties are applied to the - // source image (since we reset all the source image properties, - // above). + // Also make sure each egg file's properties are applied to the source + // image (since we reset all the source image properties, above). (*efi).second->apply_properties_to_source(); } - // Now match each of the textures in the world against a line in the - // .txa file. + // Now match each of the textures in the world against a line in the .txa + // file. for (ti = _textures.begin(); ti != _textures.end(); ++ti) { TextureImage *texture = (*ti).second; if (force_texture_read || texture->is_newer_than(state_filename)) { @@ -601,10 +571,10 @@ process_all(bool force_texture_read, const Filename &state_filename) { texture->assign_groups(); } - // And then the egg files need to sign up for a particular - // TexturePlacement, so we can determine some more properties about - // how the textures are placed (for instance, how big the UV range - // is for a particular TexturePlacement). + // And then the egg files need to sign up for a particular TexturePlacement, + // so we can determine some more properties about how the textures are + // placed (for instance, how big the UV range is for a particular + // TexturePlacement). for (efi = _egg_files.begin(); efi != _egg_files.end(); ++efi) { (*efi).second->choose_placements(); } @@ -616,8 +586,8 @@ process_all(bool force_texture_read, const Filename &state_filename) { texture->determine_placement_size(); } - // Now that each texture has been assigned to a suitable group, - // make sure the textures are placed on specific PaletteImages. + // Now that each texture has been assigned to a suitable group, make sure + // the textures are placed on specific PaletteImages. Groups::iterator gi; for (gi = _groups.begin(); gi != _groups.end(); ++gi) { PaletteGroup *group = (*gi).second; @@ -626,12 +596,9 @@ process_all(bool force_texture_read, const Filename &state_filename) { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::optimal_resize -// Access: Public -// Description: Attempts to resize each PalettteImage down to its -// smallest possible size. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to resize each PalettteImage down to its smallest possible size. + */ void Palettizer:: optimal_resize() { Groups::iterator gi; @@ -641,13 +608,10 @@ optimal_resize() { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::reset_images -// Access: Public -// Description: Throws away all of the current PaletteImages, so that -// new ones may be created (and the packing made more -// optimal). -//////////////////////////////////////////////////////////////////// +/** + * Throws away all of the current PaletteImages, so that new ones may be + * created (and the packing made more optimal). + */ void Palettizer:: reset_images() { Groups::iterator gi; @@ -657,14 +621,11 @@ reset_images() { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::generate_images -// Access: Public -// Description: Actually generates the appropriate palette and -// unplaced texture images into the map directories. If -// redo_all is true, this forces a regeneration of each -// image file. -//////////////////////////////////////////////////////////////////// +/** + * Actually generates the appropriate palette and unplaced texture images into + * the map directories. If redo_all is true, this forces a regeneration of + * each image file. + */ void Palettizer:: generate_images(bool redo_all) { Groups::iterator gi; @@ -680,18 +641,14 @@ generate_images(bool redo_all) { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::read_stale_eggs -// Access: Public -// Description: Reads in any egg file that is known to be stale, even -// if it was not listed on the command line, so that it -// may be updated and written out when write_eggs() is -// called. If redo_all is true, this even reads egg -// files that were not flagged as stale. -// -// Returns true if successful, or false if there was -// some error. -//////////////////////////////////////////////////////////////////// +/** + * Reads in any egg file that is known to be stale, even if it was not listed + * on the command line, so that it may be updated and written out when + * write_eggs() is called. If redo_all is true, this even reads egg files + * that were not flagged as stale. + * + * Returns true if successful, or false if there was some error. + */ bool Palettizer:: read_stale_eggs(bool redo_all) { bool okflag = true; @@ -720,9 +677,9 @@ read_stale_eggs(bool redo_all) { EggFiles::iterator ei = (*ii); EggFile *egg_file = (*ei).second; if (egg_file->get_source_filename().exists()) { - // If there is an invalid egg file, remove it; hopefully it will - // get rebuilt properly next time. - nout << "Removing invalid egg file: " + // If there is an invalid egg file, remove it; hopefully it will get + // rebuilt properly next time. + nout << "Removing invalid egg file: " << FilenameUnifier::make_user_filename(egg_file->get_source_filename()) << "\n"; @@ -730,8 +687,8 @@ read_stale_eggs(bool redo_all) { okflag = false; } else { - // If the egg file is simply missing, quietly remove any record - // of it from the database. + // If the egg file is simply missing, quietly remove any record of it + // from the database. egg_file->remove_egg(); _egg_files.erase(ei); } @@ -746,13 +703,10 @@ read_stale_eggs(bool redo_all) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::write_eggs -// Access: Public -// Description: Adjusts the egg files to reference the newly -// generated textures, and writes them out. Returns -// true if successful, or false if there was some error. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the egg files to reference the newly generated textures, and writes + * them out. Returns true if successful, or false if there was some error. + */ bool Palettizer:: write_eggs() { bool okflag = true; @@ -783,14 +737,11 @@ write_eggs() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::get_egg_file -// Access: Public -// Description: Returns the EggFile with the given name. If there is -// no EggFile with the indicated name, creates one. -// This is the key name used to sort the egg files, -// which is typically the basename of the filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggFile with the given name. If there is no EggFile with the + * indicated name, creates one. This is the key name used to sort the egg + * files, which is typically the basename of the filename. + */ EggFile *Palettizer:: get_egg_file(const string &name) { EggFiles::iterator ei = _egg_files.find(name); @@ -804,13 +755,10 @@ get_egg_file(const string &name) { return file; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::remove_egg_file -// Access: Public -// Description: Removes the named egg file from the database, if it -// exists. Returns true if the egg file was found, -// false if it was not. -//////////////////////////////////////////////////////////////////// +/** + * Removes the named egg file from the database, if it exists. Returns true + * if the egg file was found, false if it was not. + */ bool Palettizer:: remove_egg_file(const string &name) { EggFiles::iterator ei = _egg_files.find(name); @@ -824,26 +772,20 @@ remove_egg_file(const string &name) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::add_command_line_egg -// Access: Public -// Description: Adds the indicated EggFile to the list of eggs that -// are considered to have been read on the command line. -// These will be processed by -// process_command_line_eggs(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated EggFile to the list of eggs that are considered to have + * been read on the command line. These will be processed by + * process_command_line_eggs(). + */ void Palettizer:: add_command_line_egg(EggFile *egg_file) { _command_line_eggs.push_back(egg_file); } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::get_palette_group -// Access: Public -// Description: Returns the PaletteGroup with the given name. If -// there is no PaletteGroup with the indicated name, -// creates one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PaletteGroup with the given name. If there is no PaletteGroup + * with the indicated name, creates one. + */ PaletteGroup *Palettizer:: get_palette_group(const string &name) { Groups::iterator gi = _groups.find(name); @@ -857,13 +799,10 @@ get_palette_group(const string &name) { return group; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::test_palette_group -// Access: Public -// Description: Returns the PaletteGroup with the given name. If -// there is no PaletteGroup with the indicated name, -// returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Returns the PaletteGroup with the given name. If there is no PaletteGroup + * with the indicated name, returns NULL. + */ PaletteGroup *Palettizer:: test_palette_group(const string &name) const { Groups::const_iterator gi = _groups.find(name); @@ -874,12 +813,10 @@ test_palette_group(const string &name) const { return (PaletteGroup *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::get_default_group -// Access: Public -// Description: Returns the default group to which an egg file should -// be assigned if it is not mentioned in the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the default group to which an egg file should be assigned if it is + * not mentioned in the .txa file. + */ PaletteGroup *Palettizer:: get_default_group() { PaletteGroup *default_group = get_palette_group(_default_groupname); @@ -889,26 +826,22 @@ get_default_group() { return default_group; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::get_texture -// Access: Public -// Description: Returns the TextureImage with the given name. If -// there is no TextureImage with the indicated name, -// creates one. This is the key name used to sort the -// textures, which is typically the basename of the -// primary filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextureImage with the given name. If there is no TextureImage + * with the indicated name, creates one. This is the key name used to sort + * the textures, which is typically the basename of the primary filename. + */ TextureImage *Palettizer:: get_texture(const string &name) { - // Look first in the same-case name, just in case it happens to be - // there (from an older version of egg-palettize that did this). + // Look first in the same-case name, just in case it happens to be there + // (from an older version of egg-palettize that did this). Textures::iterator ti = _textures.find(name); if (ti != _textures.end()) { return (*ti).second; } - // Then look in the downcase name, since we nowadays index textures - // only by their downcase names (to implement case insensitivity). + // Then look in the downcase name, since we nowadays index textures only by + // their downcase names (to implement case insensitivity). string downcase_name = downcase(name); ti = _textures.find(downcase_name); if (ti != _textures.end()) { @@ -917,30 +850,25 @@ get_texture(const string &name) { TextureImage *image = new TextureImage; image->set_name(name); - // image->set_filename(name); + // image->set_filename(name); _textures.insert(Textures::value_type(downcase_name, image)); return image; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::yesno -// Access: Private, Static -// Description: A silly function to return "yes" or "no" based on a -// bool flag for nicely formatted output. -//////////////////////////////////////////////////////////////////// +/** + * A silly function to return "yes" or "no" based on a bool flag for nicely + * formatted output. + */ const char *Palettizer:: yesno(bool flag) { return flag ? "yes" : "no"; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::string_remap -// Access: Public, Static -// Description: Returns the RemapUV code corresponding to the -// indicated string, or RU_invalid if the string is -// invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the RemapUV code corresponding to the indicated string, or + * RU_invalid if the string is invalid. + */ Palettizer::RemapUV Palettizer:: string_remap(const string &str) { if (str == "never") { @@ -957,13 +885,10 @@ string_remap(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::compute_statistics -// Access: Private -// Description: Determines how much memory, etc. is required by the -// indicated set of texture placements, and reports this -// to the indicated output stream. -//////////////////////////////////////////////////////////////////// +/** + * Determines how much memory, etc. is required by the indicated set of + * texture placements, and reports this to the indicated output stream. + */ void Palettizer:: compute_statistics(ostream &out, int indent_level, const Palettizer::Placements &placements) const { @@ -978,25 +903,19 @@ compute_statistics(ostream &out, int indent_level, counter.report(out, indent_level); } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void Palettizer:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_Palettizer); } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void Palettizer:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -1037,8 +956,7 @@ write_datagram(BamWriter *writer, Datagram &datagram) { writer->write_pointer(datagram, (*ei).second); } - // We don't write _command_line_eggs; that's specific to each - // session. + // We don't write _command_line_eggs; that's specific to each session. datagram.add_int32(_groups.size()); Groups::const_iterator gi; @@ -1053,15 +971,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int Palettizer:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); @@ -1108,8 +1023,8 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { string name = downcase(texture->get_name()); pair result = _textures.insert(Textures::value_type(name, texture)); if (!result.second) { - // Two textures mapped to the same slot--probably a case error - // (since we just changed this rule). + // Two textures mapped to the same slot--probably a case error (since we + // just changed this rule). _texture_conflicts.push_back(texture); } index++; @@ -1118,22 +1033,20 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::finalize -// Access: Public, Virtual -// Description: Called by the BamReader to perform any final actions -// needed for setting up the object after all objects -// have been read and all pointers have been completed. -//////////////////////////////////////////////////////////////////// +/** + * Called by the BamReader to perform any final actions needed for setting up + * the object after all objects have been read and all pointers have been + * completed. + */ void Palettizer:: finalize(BamReader *manager) { - // Walk through the list of texture names that were in conflict. - // These can only happen if there were two different names that - // different only in case, which means the textures.boo file was - // created before we introduced the rule that case is insignificant. + // Walk through the list of texture names that were in conflict. These can + // only happen if there were two different names that different only in + // case, which means the textures.boo file was created before we introduced + // the rule that case is insignificant. TextureConflicts::iterator ci; - for (ci = _texture_conflicts.begin(); - ci != _texture_conflicts.end(); + for (ci = _texture_conflicts.begin(); + ci != _texture_conflicts.end(); ++ci) { TextureImage *texture_b = (*ci); string downcase_name = downcase(texture_b->get_name()); @@ -1144,8 +1057,8 @@ finalize(BamReader *manager) { _textures.erase(ti); if (!texture_b->is_used() || !texture_a->is_used()) { - // If either texture is not used, there's not really a - // conflict--the other one wins. + // If either texture is not used, there's not really a conflict--the + // other one wins. if (texture_a->is_used()) { bool inserted1 = _textures.insert(Textures::value_type(downcase_name, texture_a)).second; nassertd(inserted1) { } @@ -1177,14 +1090,11 @@ finalize(BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::make_Palettizer -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* Palettizer:: make_Palettizer(const FactoryParams ¶ms) { Palettizer *me = new Palettizer; @@ -1198,13 +1108,10 @@ make_Palettizer(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: Palettizer::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void Palettizer:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/palettizer.h b/pandatool/src/palettizer/palettizer.h index 308093dff5..ad8c389df8 100644 --- a/pandatool/src/palettizer/palettizer.h +++ b/pandatool/src/palettizer/palettizer.h @@ -1,16 +1,15 @@ -// Filename: palettizer.h -// Created by: drose (01Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file palettizer.h + * @author drose + * @date 2000-12-01 + */ #ifndef PALETTIZER_H #define PALETTIZER_H @@ -32,14 +31,11 @@ class TextureImage; class TexturePlacement; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : Palettizer -// Description : This is the main engine behind egg-palettize. It -// contains all of the program parameters, from the -// command line or saved from a previous session, and -// serves as the driving force in the actual palettizing -// process. -//////////////////////////////////////////////////////////////////// +/** + * This is the main engine behind egg-palettize. It contains all of the + * program parameters, from the command line or saved from a previous session, + * and serves as the driving force in the actual palettizing process. + */ class Palettizer : public TypedWritable { public: Palettizer(); @@ -90,16 +86,16 @@ public: bool _is_valid; - // These values are not stored in the textures.boo file, but are - // specific to each session. + // These values are not stored in the textures.boo file, but are specific to + // each session. TxaFile _txa_file; string _default_groupname; string _default_groupdir; bool _noabs; - // The following parameter values specifically relate to textures - // and palettes. These values are stored in the textures.boo file - // for future reference. + // The following parameter values specifically relate to textures and + // palettes. These values are stored in the textures.boo file for future + // reference. string _generated_image_pattern; string _map_dirname; Filename _shadow_dirname; @@ -160,8 +156,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // These values are only filled in while reading from the bam file; - // don't use them otherwise. + // These values are only filled in while reading from the bam file; don't + // use them otherwise. int _num_egg_files; int _num_groups; int _num_textures; @@ -186,9 +182,9 @@ private: }; // This is a global Palettizer pointer that may be filled in when the -// Palettizer is created, for convenience in referencing it from -// multiple places. (Generally, a standalone program will only create -// one Palettizer object in a session.) +// Palettizer is created, for convenience in referencing it from multiple +// places. (Generally, a standalone program will only create one Palettizer +// object in a session.) extern Palettizer *pal; #endif diff --git a/pandatool/src/palettizer/sourceTextureImage.cxx b/pandatool/src/palettizer/sourceTextureImage.cxx index d2e86cd8e3..df1afec310 100644 --- a/pandatool/src/palettizer/sourceTextureImage.cxx +++ b/pandatool/src/palettizer/sourceTextureImage.cxx @@ -1,16 +1,15 @@ -// Filename: sourceTextureImage.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sourceTextureImage.cxx + * @author drose + * @date 2000-11-29 + */ #include "sourceTextureImage.h" #include "textureImage.h" @@ -24,12 +23,9 @@ TypeHandle SourceTextureImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::Default Constructor -// Access: Private -// Description: The default constructor is only for the convenience -// of the Bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the Bam reader. + */ SourceTextureImage:: SourceTextureImage() { _texture = (TextureImage *)NULL; @@ -39,11 +35,9 @@ SourceTextureImage() { _successfully_read_header = false; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SourceTextureImage:: SourceTextureImage(TextureImage *texture, const Filename &filename, const Filename &alpha_filename, int alpha_file_channel) : @@ -57,50 +51,38 @@ SourceTextureImage(TextureImage *texture, const Filename &filename, _successfully_read_header = false; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::get_texture -// Access: Public -// Description: Returns the particular texture that this image is one -// of the sources for. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular texture that this image is one of the sources for. + */ TextureImage *SourceTextureImage:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::increment_egg_count -// Access: Public -// Description: Increments by one the number of egg files that are -// known to reference this SourceTextureImage. -//////////////////////////////////////////////////////////////////// +/** + * Increments by one the number of egg files that are known to reference this + * SourceTextureImage. + */ void SourceTextureImage:: increment_egg_count() { _egg_count++; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::get_egg_count -// Access: Public -// Description: Returns the number of egg files that share this -// SourceTextureImage. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of egg files that share this SourceTextureImage. + */ int SourceTextureImage:: get_egg_count() const { return _egg_count; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::get_size -// Access: Public -// Description: Determines the size of the SourceTextureImage, if it -// is not already known. Returns true if the size was -// successfully determined (or if was already known), or -// false if the size could not be determined (for -// instance, because the image file is missing). After -// this call returns true, get_x_size() etc. may be -// safely called to return the size. -//////////////////////////////////////////////////////////////////// +/** + * Determines the size of the SourceTextureImage, if it is not already known. + * Returns true if the size was successfully determined (or if was already + * known), or false if the size could not be determined (for instance, because + * the image file is missing). After this call returns true, get_x_size() + * etc. may be safely called to return the size. + */ bool SourceTextureImage:: get_size() { if (!_size_known) { @@ -109,17 +91,13 @@ get_size() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::read_header -// Access: Public -// Description: Reads the actual image header to determine the image -// properties, like its size. Returns true if the image -// header is successfully read (or if has previously -// been successfully read this session), false -// otherwise. After this call returns true, -// get_x_size() etc. may be safely called to return the -// newly determined size. -//////////////////////////////////////////////////////////////////// +/** + * Reads the actual image header to determine the image properties, like its + * size. Returns true if the image header is successfully read (or if has + * previously been successfully read this session), false otherwise. After + * this call returns true, get_x_size() etc. may be safely called to return + * the newly determined size. + */ bool SourceTextureImage:: read_header() { if (_read_header) { @@ -131,7 +109,7 @@ read_header() { PNMImageHeader header; if (!header.read_header(_filename)) { - nout << "Warning: cannot read texture " + nout << "Warning: cannot read texture " << FilenameUnifier::make_user_filename(_filename) << "\n"; return false; } @@ -141,12 +119,10 @@ read_header() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::set_header -// Access: Public -// Description: Sets the header information associated with this -// image, as if it were loaded from the disk. -//////////////////////////////////////////////////////////////////// +/** + * Sets the header information associated with this image, as if it were + * loaded from the disk. + */ void SourceTextureImage:: set_header(const PNMImageHeader &header) { _x_size = header.get_x_size(); @@ -154,8 +130,8 @@ set_header(const PNMImageHeader &header) { int num_channels = header.get_num_channels(); if (!_alpha_filename.empty() && _alpha_filename.exists()) { - // Assume if we have an alpha filename, that we have an additional - // alpha channel. + // Assume if we have an alpha filename, that we have an additional alpha + // channel. if (num_channels == 1 || num_channels == 3) { num_channels++; } @@ -167,48 +143,37 @@ set_header(const PNMImageHeader &header) { } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void SourceTextureImage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_SourceTextureImage); } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void SourceTextureImage:: write_datagram(BamWriter *writer, Datagram &datagram) { ImageFile::write_datagram(writer, datagram); writer->write_pointer(datagram, _texture); - // We don't store _egg_count; instead, we count these up again each - // session. + // We don't store _egg_count; instead, we count these up again each session. - // We don't store _read_header or _successfully_read_header in the - // Bam file; these are transitory and we need to reread the image - // header for each session (in case the image files change between - // sessions). + // We don't store _read_header or _successfully_read_header in the Bam file; + // these are transitory and we need to reread the image header for each + // session (in case the image files change between sessions). } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int SourceTextureImage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = ImageFile::complete_pointers(p_list, manager); @@ -217,14 +182,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::make_SourceTextureImage -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable *SourceTextureImage:: make_SourceTextureImage(const FactoryParams ¶ms) { SourceTextureImage *me = new SourceTextureImage; @@ -236,13 +198,10 @@ make_SourceTextureImage(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: SourceTextureImage::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void SourceTextureImage:: fillin(DatagramIterator &scan, BamReader *manager) { ImageFile::fillin(scan, manager); diff --git a/pandatool/src/palettizer/sourceTextureImage.h b/pandatool/src/palettizer/sourceTextureImage.h index 3259c50155..09c1792222 100644 --- a/pandatool/src/palettizer/sourceTextureImage.h +++ b/pandatool/src/palettizer/sourceTextureImage.h @@ -1,16 +1,15 @@ -// Filename: sourceTextureImage.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file sourceTextureImage.h + * @author drose + * @date 2000-11-28 + */ #ifndef SOURCETEXTUREIMAGE_H #define SOURCETEXTUREIMAGE_H @@ -22,11 +21,10 @@ class TextureImage; class PNMImageHeader; -//////////////////////////////////////////////////////////////////// -// Class : SourceTextureImage -// Description : This is a texture image reference as it appears in an -// egg file: the source image of the texture. -//////////////////////////////////////////////////////////////////// +/** + * This is a texture image reference as it appears in an egg file: the source + * image of the texture. + */ class SourceTextureImage : public ImageFile { private: SourceTextureImage(); @@ -85,4 +83,3 @@ operator << (ostream &out, const SourceTextureImage &source) { } #endif - diff --git a/pandatool/src/palettizer/textureImage.cxx b/pandatool/src/palettizer/textureImage.cxx index ce287baada..54e213ed24 100644 --- a/pandatool/src/palettizer/textureImage.cxx +++ b/pandatool/src/palettizer/textureImage.cxx @@ -1,16 +1,15 @@ -// Filename: textureImage.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureImage.cxx + * @author drose + * @date 2000-11-29 + */ #include "textureImage.h" #include "sourceTextureImage.h" @@ -34,11 +33,9 @@ TypeHandle TextureImage::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureImage:: TextureImage() { _preferred_source = (SourceTextureImage *)NULL; @@ -57,33 +54,27 @@ TextureImage() { _got_txa_file = false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::note_egg_file -// Access: Public -// Description: Records that a particular egg file references this -// texture. This is essential to know when deciding how -// to assign the TextureImage to the various -// PaletteGroups. -//////////////////////////////////////////////////////////////////// +/** + * Records that a particular egg file references this texture. This is + * essential to know when deciding how to assign the TextureImage to the + * various PaletteGroups. + */ void TextureImage:: note_egg_file(EggFile *egg_file) { nassertv(!egg_file->get_complete_groups().empty()); _egg_files.insert(egg_file); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::assign_groups -// Access: Public -// Description: Assigns the texture to all of the PaletteGroups the -// various egg files that use it need. Attempts to -// choose the minimum set of PaletteGroups that -// satisfies all of the egg files. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the texture to all of the PaletteGroups the various egg files that + * use it need. Attempts to choose the minimum set of PaletteGroups that + * satisfies all of the egg files. + */ void TextureImage:: assign_groups() { if (_egg_files.empty()) { - // If we're not referenced by any egg files any more, assign us to - // no groups. + // If we're not referenced by any egg files any more, assign us to no + // groups. PaletteGroups empty; assign_to_groups(empty); return; @@ -91,19 +82,19 @@ assign_groups() { PaletteGroups definitely_in; - // First, we need to eliminate from consideration all the egg files - // that are already taken care of by the user's explicit group - // assignments for this texture. + // First, we need to eliminate from consideration all the egg files that are + // already taken care of by the user's explicit group assignments for this + // texture. WorkingEggs needed_eggs; if (_explicitly_assigned_groups.empty()) { - // If we have no explicit group assignments, we must consider all - // the egg files. + // If we have no explicit group assignments, we must consider all the egg + // files. copy(_egg_files.begin(), _egg_files.end(), back_inserter(needed_eggs)); } else { - // Otherwise, we only need to consider the egg files that don't - // have any groups in common with our explicit assignments. + // Otherwise, we only need to consider the egg files that don't have any + // groups in common with our explicit assignments. EggFiles::const_iterator ei; for (ei = _egg_files.begin(); ei != _egg_files.end(); ++ei) { @@ -113,25 +104,25 @@ assign_groups() { // This egg file is satisfied by one of the texture's explicit // assignments. - // We must use at least one of the explicitly-assigned groups - // that satisfied the egg file. We don't need to use all of - // them, however, and we choose the first one arbitrarily. + // We must use at least one of the explicitly-assigned groups that + // satisfied the egg file. We don't need to use all of them, however, + // and we choose the first one arbitrarily. definitely_in.insert(*intersect.begin()); } else { - // This egg file was not satisfied by any of the texture's - // explicit assignments. Therefore, we'll need to choose some - // additional group to assign the texture to, to make the egg - // file happy. Defer this a bit. + // This egg file was not satisfied by any of the texture's explicit + // assignments. Therefore, we'll need to choose some additional group + // to assign the texture to, to make the egg file happy. Defer this a + // bit. needed_eggs.push_back(*ei); } } } while (!needed_eggs.empty()) { - // We need to know the complete set of groups that we need to - // consider adding the texture to. This is the union of all the egg - // files' requested groups. + // We need to know the complete set of groups that we need to consider + // adding the texture to. This is the union of all the egg files' + // requested groups. PaletteGroups total; WorkingEggs::const_iterator ei; for (ei = needed_eggs.begin(); ei != needed_eggs.end(); ++ei) { @@ -144,11 +135,11 @@ assign_groups() { break; } - // Now, find the group that will satisfy the most egg files. If - // two groups satisfy the same number of egg files, choose (a) the - // most specific one, i.e. with the lowest dirname_level, or the - // lowest dependency_level if the dirname_levels are equal, and - // (b) the one that has the fewest egg files sharing it. + // Now, find the group that will satisfy the most egg files. If two + // groups satisfy the same number of egg files, choose (a) the most + // specific one, i.e. with the lowest dirname_level, or the lowest + // dependency_level if the dirname_levels are equal, and (b) the one that + // has the fewest egg files sharing it. PaletteGroups::iterator gi = total.begin(); PaletteGroup *best = (*gi); int best_egg_count = compute_egg_count(best, needed_eggs); @@ -173,8 +164,8 @@ assign_groups() { ++gi; } - // Okay, now we've picked the best group. Eliminate all the eggs - // from consideration that are satisfied by this group, and repeat. + // Okay, now we've picked the best group. Eliminate all the eggs from + // consideration that are satisfied by this group, and repeat. definitely_in.insert(best); WorkingEggs next_needed_eggs; @@ -187,32 +178,26 @@ assign_groups() { needed_eggs.swap(next_needed_eggs); } - // Finally, now that we've computed the set of groups we need to - // assign the texture to, we need to reconcile this with the set of - // groups we've assigned the texture to previously. + // Finally, now that we've computed the set of groups we need to assign the + // texture to, we need to reconcile this with the set of groups we've + // assigned the texture to previously. assign_to_groups(definitely_in); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_groups -// Access: Public -// Description: Once assign_groups() has been called, this returns -// the actual set of groups the TextureImage has been -// assigned to. -//////////////////////////////////////////////////////////////////// +/** + * Once assign_groups() has been called, this returns the actual set of groups + * the TextureImage has been assigned to. + */ const PaletteGroups &TextureImage:: get_groups() const { return _actual_assigned_groups; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_placement -// Access: Public -// Description: Gets the TexturePlacement object which represents the -// assignment of this texture to the indicated group. -// If the texture has not been assigned to the indicated -// group, returns NULL. -//////////////////////////////////////////////////////////////////// +/** + * Gets the TexturePlacement object which represents the assignment of this + * texture to the indicated group. If the texture has not been assigned to + * the indicated group, returns NULL. + */ TexturePlacement *TextureImage:: get_placement(PaletteGroup *group) const { Placement::const_iterator pi; @@ -224,14 +209,11 @@ get_placement(PaletteGroup *group) const { return (*pi).second; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::force_replace -// Access: Public -// Description: Removes the texture from any PaletteImages it is -// assigned to, but does not remove it from the groups. -// It will be re-placed within each group when -// PaletteGroup::place_all() is called. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture from any PaletteImages it is assigned to, but does not + * remove it from the groups. It will be re-placed within each group when + * PaletteGroup::place_all() is called. + */ void TextureImage:: force_replace() { Placement::iterator pi; @@ -240,15 +222,12 @@ force_replace() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::mark_eggs_stale -// Access: Public -// Description: Marks all the egg files that reference this texture -// stale. Should be called only when the texture -// properties change in some catastrophic way that will -// require every egg file referencing it to be -// regenerated, even if it is not palettized. -//////////////////////////////////////////////////////////////////// +/** + * Marks all the egg files that reference this texture stale. Should be + * called only when the texture properties change in some catastrophic way + * that will require every egg file referencing it to be regenerated, even if + * it is not palettized. + */ void TextureImage:: mark_eggs_stale() { Placement::iterator pi; @@ -257,45 +236,36 @@ mark_eggs_stale() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::mark_texture_named -// Access: Public -// Description: Indicates that this particular texture has been named -// by the user for processing this session, normally by -// listing an egg file on the command line that -// references it. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this particular texture has been named by the user for + * processing this session, normally by listing an egg file on the command + * line that references it. + */ void TextureImage:: mark_texture_named() { _texture_named = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::is_texture_named -// Access: Public -// Description: Returns true if this particular texture has been -// named by the user for procession this session, for -// instance by listing an egg file on the command line -// that references it. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular texture has been named by the user for + * procession this session, for instance by listing an egg file on the command + * line that references it. + */ bool TextureImage:: is_texture_named() const { return _texture_named; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::pre_txa_file -// Access: Public -// Description: Updates any internal state prior to reading the .txa -// file. -//////////////////////////////////////////////////////////////////// +/** + * Updates any internal state prior to reading the .txa file. + */ void TextureImage:: pre_txa_file() { // Save our current properties, so we can note if they change. _pre_txa_properties = _properties; - // Get our properties from the actual image for this texture. It's - // possible the .txa file will update them further. + // Get our properties from the actual image for this texture. It's possible + // the .txa file will update them further. SourceTextureImage *source = get_preferred_source(); if (source != (SourceTextureImage *)NULL) { _properties = source->get_properties(); @@ -308,15 +278,11 @@ pre_txa_file() { _is_surprise = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::post_txa_file -// Access: Public -// Description: Once the .txa file has been read and the TextureImage -// matched against it, considers applying the requested -// size change. Updates the TextureImage's size with -// the size the texture ought to be, if this can be -// determined. -//////////////////////////////////////////////////////////////////// +/** + * Once the .txa file has been read and the TextureImage matched against it, + * considers applying the requested size change. Updates the TextureImage's + * size with the size the texture ought to be, if this can be determined. + */ void TextureImage:: post_txa_file() { _got_txa_file = true; @@ -344,8 +310,8 @@ post_txa_file() { _txa_wrap_u = _request._wrap_u; _txa_wrap_v = _request._wrap_v; - // If the explicit wrap mode changes, we may need to regenerate - // the egg files, and/or refill the palettes. + // If the explicit wrap mode changes, we may need to regenerate the egg + // files, andor refill the palettes. mark_eggs_stale(); Placement::iterator pi; @@ -357,14 +323,14 @@ post_txa_file() { if (_properties.has_num_channels() && !_request._keep_format) { int num_channels = _properties.get_num_channels(); - // Examine the image to determine if we can downgrade the number - // of channels, for instance from color to grayscale. + // Examine the image to determine if we can downgrade the number of + // channels, for instance from color to grayscale. if (num_channels == 3 || num_channels == 4) { consider_grayscale(); } - - // Also consider the alpha properties, and whether we should - // downgrade from alpha to non-alpha. + + // Also consider the alpha properties, and whether we should downgrade + // from alpha to non-alpha. if (num_channels == 2 || num_channels == 4) { consider_alpha(); } @@ -405,24 +371,24 @@ post_txa_file() { if (_properties != _pre_txa_properties) { force_replace(); - // The above will mark the egg files stale when the texture is - // palettized (since the UV's will certainly need to be - // recomputed), but sometimes we need to mark the egg files stale - // even when the texture is not palettized (if a critical property - // has changed). The following accomplishes this: + // The above will mark the egg files stale when the texture is palettized + // (since the UV's will certainly need to be recomputed), but sometimes we + // need to mark the egg files stale even when the texture is not + // palettized (if a critical property has changed). The following + // accomplishes this: if (!_properties.egg_properties_match(_pre_txa_properties)) { mark_eggs_stale(); } } - // The alpha mode isn't stored in the properties, because it doesn't - // affect which textures may be associated into a common palette. + // The alpha mode isn't stored in the properties, because it doesn't affect + // which textures may be associated into a common palette. if (_request._alpha_mode != EggRenderMode::AM_unspecified) { _alpha_mode = _request._alpha_mode; } - // On the other hand, if we don't have an alpha channel, we - // shouldn't have an alpha mode. + // On the other hand, if we don't have an alpha channel, we shouldn't have + // an alpha mode. if (_properties.has_num_channels()) { int num_channels = _properties.get_num_channels(); if (num_channels == 1 || num_channels == 3) { @@ -430,32 +396,26 @@ post_txa_file() { } } - // If we've changed the alpha mode, we should also mark the eggs - // stale. + // If we've changed the alpha mode, we should also mark the eggs stale. if (_pre_txa_alpha_mode != _alpha_mode) { mark_eggs_stale(); } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::got_txa_file -// Access: Public -// Description: Returns true if this TextureImage has been looked up -// in the .txa file this session, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this TextureImage has been looked up in the .txa file this + * session, false otherwise. + */ bool TextureImage:: got_txa_file() const { return _got_txa_file; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::determine_placement_size -// Access: Public -// Description: Calls determine_size() on each TexturePlacement for -// the texture, to ensure that each TexturePlacement is -// still requesting the best possible size for the -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Calls determine_size() on each TexturePlacement for the texture, to ensure + * that each TexturePlacement is still requesting the best possible size for + * the texture. + */ void TextureImage:: determine_placement_size() { Placement::iterator pi; @@ -465,121 +425,94 @@ determine_placement_size() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_omit -// Access: Public -// Description: Returns true if the user specifically requested to -// omit this texture via the "omit" keyword in the .txa -// file, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the user specifically requested to omit this texture via + * the "omit" keyword in the .txa file, or false otherwise. + */ bool TextureImage:: get_omit() const { return _request._omit; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_coverage_threshold -// Access: Public -// Description: Returns the appropriate coverage threshold for this -// texture. This is either the -// Palettizer::_coverage_threshold parameter, given -// globally via -r, or a particular value for this -// texture as supplied by the "coverage" keyword in the -// .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate coverage threshold for this texture. This is + * either the Palettizer::_coverage_threshold parameter, given globally via + * -r, or a particular value for this texture as supplied by the "coverage" + * keyword in the .txa file. + */ double TextureImage:: get_coverage_threshold() const { return _request._coverage_threshold; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_margin -// Access: Public -// Description: Returns the appropriate margin for this texture. -// This is either the Palettizer::_margin parameter, or -// a particular value for this texture as supplied by -// the "margin" keyword in the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Returns the appropriate margin for this texture. This is either the + * Palettizer::_margin parameter, or a particular value for this texture as + * supplied by the "margin" keyword in the .txa file. + */ int TextureImage:: get_margin() const { return _request._margin; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::is_surprise -// Access: Public -// Description: Returns true if this particular texture is a -// 'surprise', i.e. it wasn't matched by a line in the -// .txa file that didn't include the keyword 'cont'. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular texture is a 'surprise', i.e. it wasn't + * matched by a line in the .txa file that didn't include the keyword 'cont'. + */ bool TextureImage:: is_surprise() const { if (_placement.empty()) { - // A texture that is not actually placed anywhere is not - // considered a surprise. + // A texture that is not actually placed anywhere is not considered a + // surprise. return false; } return _is_surprise; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::is_used -// Access: Public -// Description: Returns true if this particular texture has been -// placed somewhere, anywhere, or false if it is not -// used. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular texture has been placed somewhere, + * anywhere, or false if it is not used. + */ bool TextureImage:: is_used() const { return !_placement.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_alpha_mode -// Access: Public -// Description: Returns the alpha mode that should be used to render -// objects with this texture, as specified by the user -// or as determined from examining the texture's alpha -// channel. -//////////////////////////////////////////////////////////////////// +/** + * Returns the alpha mode that should be used to render objects with this + * texture, as specified by the user or as determined from examining the + * texture's alpha channel. + */ EggRenderMode::AlphaMode TextureImage:: get_alpha_mode() const { return _alpha_mode; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_txa_wrap_u -// Access: Public -// Description: Returns the wrap mode specified in the u direction in -// the txa file, or WM_unspecified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode specified in the u direction in the txa file, or + * WM_unspecified. + */ EggTexture::WrapMode TextureImage:: get_txa_wrap_u() const { return _txa_wrap_u; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_txa_wrap_v -// Access: Public -// Description: Returns the wrap mode specified in the v direction in -// the txa file, or WM_unspecified. -//////////////////////////////////////////////////////////////////// +/** + * Returns the wrap mode specified in the v direction in the txa file, or + * WM_unspecified. + */ EggTexture::WrapMode TextureImage:: get_txa_wrap_v() const { return _txa_wrap_v; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_source -// Access: Public -// Description: Returns the SourceTextureImage corresponding to the -// given filename(s). If the given filename has never -// been used as a SourceTexture for this particular -// texture, creates a new SourceTextureImage and returns -// that. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SourceTextureImage corresponding to the given filename(s). If + * the given filename has never been used as a SourceTexture for this + * particular texture, creates a new SourceTextureImage and returns that. + */ SourceTextureImage *TextureImage:: get_source(const Filename &filename, const Filename &alpha_filename, int alpha_file_channel) { @@ -595,37 +528,35 @@ get_source(const Filename &filename, const Filename &alpha_filename, new SourceTextureImage(this, filename, alpha_filename, alpha_file_channel); _sources.insert(Sources::value_type(key, source)); - // Clear out the preferred source image to force us to rederive this - // next time someone asks. + // Clear out the preferred source image to force us to rederive this next + // time someone asks. _preferred_source = (SourceTextureImage *)NULL; _read_source_image = false; return source; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_preferred_source -// Access: Public -// Description: Determines the preferred source image for examining -// size and reading pixels, etc. This is the largest -// and most recent of all the available source images. -//////////////////////////////////////////////////////////////////// +/** + * Determines the preferred source image for examining size and reading + * pixels, etc. This is the largest and most recent of all the available + * source images. + */ SourceTextureImage *TextureImage:: get_preferred_source() { if (_preferred_source != (SourceTextureImage *)NULL) { return _preferred_source; } - // Now examine all of the various source images available to us and - // pick the most suitable. We base this on the following criteria: + // Now examine all of the various source images available to us and pick the + // most suitable. We base this on the following criteria: - // (1) A suitable source image must be referenced by at least one - // egg file, unless no source images are referenced by any egg file. + // (1) A suitable source image must be referenced by at least one egg file, + // unless no source images are referenced by any egg file. // (2) A larger source image is preferable to a smaller one. - // (3) Given two source images of the same size, the more recent one - // is preferable. + // (3) Given two source images of the same size, the more recent one is + // preferable. // Are any source images referenced by an egg file? @@ -669,10 +600,10 @@ get_preferred_source() { } if (best == (SourceTextureImage *)NULL && !_sources.empty()) { - // If we didn't pick any that pass, it must be that all of them - // are unreadable. In this case, it really doesn't matter which - // one we pick, but we should at least pick one that has an egg - // reference, if any of them do. + // If we didn't pick any that pass, it must be that all of them are + // unreadable. In this case, it really doesn't matter which one we pick, + // but we should at least pick one that has an egg reference, if any of + // them do. if (any_referenced) { for (si = _sources.begin(); si != _sources.end() && best == (SourceTextureImage *)NULL; @@ -691,14 +622,11 @@ get_preferred_source() { return _preferred_source; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::clear_source_basic_properties -// Access: Public -// Description: Calls clear_basic_properties() on each source texture -// image used by this texture, to reset the properties -// in preparation for re-applying them from the set of -// all known egg files. -//////////////////////////////////////////////////////////////////// +/** + * Calls clear_basic_properties() on each source texture image used by this + * texture, to reset the properties in preparation for re-applying them from + * the set of all known egg files. + */ void TextureImage:: clear_source_basic_properties() { Sources::iterator si; @@ -708,28 +636,22 @@ clear_source_basic_properties() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::copy_unplaced -// Access: Public -// Description: Copies the texture to whichever destination -// directories are appropriate for the groups in which -// it has been unplaced. Also removes the old filenames -// for previous sessions where it was unplaced, but is -// no longer. -// -// If redo_all is true, this recopies the texture -// whether it needed to or not. -//////////////////////////////////////////////////////////////////// +/** + * Copies the texture to whichever destination directories are appropriate for + * the groups in which it has been unplaced. Also removes the old filenames + * for previous sessions where it was unplaced, but is no longer. + * + * If redo_all is true, this recopies the texture whether it needed to or not. + */ void TextureImage:: copy_unplaced(bool redo_all) { - // First, we need to build up the set of DestTextureImages that - // represents the files we need to generate. + // First, we need to build up the set of DestTextureImages that represents + // the files we need to generate. Dests generate; - // Go through all the TexturePlacements and note the ones for which - // we're unplaced. We check get_omit_reason() and not is_placed(), - // because we want to consider solitary images to be unplaced in - // this case. + // Go through all the TexturePlacements and note the ones for which we're + // unplaced. We check get_omit_reason() and not is_placed(), because we + // want to consider solitary images to be unplaced in this case. Placement::iterator pi; for (pi = _placement.begin(); pi != _placement.end(); ++pi) { TexturePlacement *placement = (*pi).second; @@ -742,8 +664,7 @@ copy_unplaced(bool redo_all) { pair insert_result = generate.insert (Dests::value_type(filename, dest)); if (!insert_result.second) { - // At least two DestTextureImages map to the same filename, no - // sweat. + // At least two DestTextureImages map to the same filename, no sweat. delete dest; dest = (*insert_result.first).second; } @@ -756,15 +677,15 @@ copy_unplaced(bool redo_all) { } if (redo_all) { - // If we're redoing everything, we remove everything first and - // then recopy it again. + // If we're redoing everything, we remove everything first and then recopy + // it again. Dests empty; remove_old_dests(empty, _dests); copy_new_dests(generate, empty); } else { - // Otherwise, we only remove and recopy the things that changed - // between this time and last time. + // Otherwise, we only remove and recopy the things that changed between + // this time and last time. remove_old_dests(generate, _dests); copy_new_dests(generate, _dests); } @@ -778,12 +699,10 @@ copy_unplaced(bool redo_all) { _dests.swap(generate); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::read_source_image -// Access: Public -// Description: Reads in the original image, if it has not already -// been read, and returns it. -//////////////////////////////////////////////////////////////////// +/** + * Reads in the original image, if it has not already been read, and returns + * it. + */ const PNMImage &TextureImage:: read_source_image() { if (!_read_source_image) { @@ -799,14 +718,11 @@ read_source_image() { return _source_image; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::release_source_image -// Access: Public -// Description: Frees the memory that was allocated by a previous -// call to read_source_image(). The next time -// read_source_image() is called, it will have to read -// the disk again. -//////////////////////////////////////////////////////////////////// +/** + * Frees the memory that was allocated by a previous call to + * read_source_image(). The next time read_source_image() is called, it will + * have to read the disk again. + */ void TextureImage:: release_source_image() { if (_read_source_image && _allow_release_source_image) { @@ -815,14 +731,11 @@ release_source_image() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::set_source_image -// Access: Public -// Description: Accepts the indicated source image as if it had been -// read from disk. This image is copied into the -// structure, and will be returned by future calls to -// read_source_image(). -//////////////////////////////////////////////////////////////////// +/** + * Accepts the indicated source image as if it had been read from disk. This + * image is copied into the structure, and will be returned by future calls to + * read_source_image(). + */ void TextureImage:: set_source_image(const PNMImage &image) { _source_image = image; @@ -831,13 +744,10 @@ set_source_image(const PNMImage &image) { _ever_read_image = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::read_header -// Access: Public -// Description: Causes the header part of the image to be reread, -// usually to confirm that its image properties (size, -// number of channels, etc.) haven't changed. -//////////////////////////////////////////////////////////////////// +/** + * Causes the header part of the image to be reread, usually to confirm that + * its image properties (size, number of channels, etc.) haven't changed. + */ void TextureImage:: read_header() { if (!_read_source_image) { @@ -848,13 +758,10 @@ read_header() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::is_newer_than -// Access: Public -// Description: Returns true if the source image is newer than the -// indicated file, false otherwise. If the image has -// already been read, this always returns false. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the source image is newer than the indicated file, false + * otherwise. If the image has already been read, this always returns false. + */ bool TextureImage:: is_newer_than(const Filename &reference_filename) { if (!_read_source_image) { @@ -868,13 +775,10 @@ is_newer_than(const Filename &reference_filename) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::write_source_pathnames -// Access: Public -// Description: Writes the list of source pathnames that might -// contribute to this texture to the indicated output -// stream, one per line. -//////////////////////////////////////////////////////////////////// +/** + * Writes the list of source pathnames that might contribute to this texture + * to the indicated output stream, one per line. + */ void TextureImage:: write_source_pathnames(ostream &out, int indent_level) const { Sources::const_iterator si; @@ -945,12 +849,9 @@ write_source_pathnames(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::write_scale_info -// Access: Public -// Description: Writes the information about the texture's size and -// placement. -//////////////////////////////////////////////////////////////////// +/** + * Writes the information about the texture's size and placement. + */ void TextureImage:: write_scale_info(ostream &out, int indent_level) { SourceTextureImage *source = get_preferred_source(); @@ -1035,13 +936,10 @@ write_scale_info(ostream &out, int indent_level) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::compute_egg_count -// Access: Private -// Description: Counts the number of egg files in the indicated set -// that will be satisfied if a texture is assigned to -// the indicated group. -//////////////////////////////////////////////////////////////////// +/** + * Counts the number of egg files in the indicated set that will be satisfied + * if a texture is assigned to the indicated group. + */ int TextureImage:: compute_egg_count(PaletteGroup *group, const TextureImage::WorkingEggs &egg_files) { @@ -1057,16 +955,12 @@ compute_egg_count(PaletteGroup *group, return count; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::assign_to_groups -// Access: Private -// Description: Assigns the texture to the indicated set of groups. -// If the texture was previously assigned to any of -// these groups, keeps the same TexturePlacement object -// for the assignment; at the same time, deletes any -// TexturePlacement objects that represent groups we are -// no longer assigned to. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the texture to the indicated set of groups. If the texture was + * previously assigned to any of these groups, keeps the same TexturePlacement + * object for the assignment; at the same time, deletes any TexturePlacement + * objects that represent groups we are no longer assigned to. + */ void TextureImage:: assign_to_groups(const PaletteGroups &groups) { PaletteGroups::const_iterator gi; @@ -1082,8 +976,8 @@ assign_to_groups(const PaletteGroups &groups) { PaletteGroup *b = (*pi).first; if (a < b) { - // Here's a group we're now assigned to that we weren't assigned - // to previously. + // Here's a group we're now assigned to that we weren't assigned to + // previously. TexturePlacement *place = a->prepare(this); new_placement.insert (new_placement.end(), Placement::value_type(a, place)); @@ -1106,8 +1000,8 @@ assign_to_groups(const PaletteGroups &groups) { } while (gi != groups.end()) { - // Here's a group we're now assigned to that we weren't assigned - // to previously. + // Here's a group we're now assigned to that we weren't assigned to + // previously. PaletteGroup *a = (*gi); TexturePlacement *place = a->prepare(this); new_placement.insert @@ -1126,22 +1020,18 @@ assign_to_groups(const PaletteGroups &groups) { _actual_assigned_groups = groups; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::consider_grayscale -// Access: Private -// Description: Examines the actual contents of the image to -// determine if it should maybe be considered a -// grayscale image (even though it has separate rgb -// components). -//////////////////////////////////////////////////////////////////// +/** + * Examines the actual contents of the image to determine if it should maybe + * be considered a grayscale image (even though it has separate rgb + * components). + */ void TextureImage:: consider_grayscale() { - // Since this isn't likely to change for a particular texture after - // its creation, we save a bit of time by not performing this check - // unless this is the first time we've ever seen this texture. This - // will save us from having to load the texture images each time we - // look at them. On the other hand, if we've already loaded up the - // image, then go ahead. + // Since this isn't likely to change for a particular texture after its + // creation, we save a bit of time by not performing this check unless this + // is the first time we've ever seen this texture. This will save us from + // having to load the texture images each time we look at them. On the + // other hand, if we've already loaded up the image, then go ahead. if (!_read_source_image && _ever_read_image) { if (_forced_grayscale) { _properties.force_grayscale(); @@ -1170,19 +1060,17 @@ consider_grayscale() { _forced_grayscale = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::consider_alpha -// Access: Private -// Description: Examines the actual contents of the image to -// determine what alpha properties it has. -//////////////////////////////////////////////////////////////////// +/** + * Examines the actual contents of the image to determine what alpha + * properties it has. + */ void TextureImage:: consider_alpha() { - // As above, we don't bother doing this if we've already done this - // in a previous session. + // As above, we don't bother doing this if we've already done this in a + // previous session. - // _alpha_bits == -1 indicates we have read an older textures.boo - // file that didn't define these bits. + // _alpha_bits == -1 indicates we have read an older textures.boo file that + // didn't define these bits. if (_read_source_image || !_ever_read_image || _alpha_bits == -1) { _alpha_bits = 0; int num_mid_pixels = 0; @@ -1220,23 +1108,23 @@ consider_alpha() { _properties.force_nonalpha(); } else if (_alpha_bits == AB_zero) { - // All alpha pixels are invisible; this is probably a mistake. - // Drop the alpha channel and complain. + // All alpha pixels are invisible; this is probably a mistake. Drop the + // alpha channel and complain. _properties.force_nonalpha(); if (_read_source_image) { nout << *this << " has an all-zero alpha channel; dropping alpha.\n"; } } else if (_alpha_mode == EggRenderMode::AM_unspecified) { - // Consider fiddling with the alpha mode, if the user hasn't - // specified a particular alpha mode in the txa file. + // Consider fiddling with the alpha mode, if the user hasn't specified a + // particular alpha mode in the txa file. if ((_alpha_bits & AB_mid) == 0) { // No middle range bits: a binary alpha image. _alpha_mode = EggRenderMode::AM_binary; } else if ((_alpha_bits & AB_one) != 0 && _mid_pixel_ratio < pal->_cutout_ratio) { - // At least some opaque bits, and relatively few middle range - // bits: a cutout image. + // At least some opaque bits, and relatively few middle range bits: a + // cutout image. _alpha_mode = pal->_cutout_mode; _is_cutout = true; @@ -1248,12 +1136,9 @@ consider_alpha() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::remove_old_dests -// Access: Private -// Description: Removes all of the filenames named in b that are not -// also named in a. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the filenames named in b that are not also named in a. + */ void TextureImage:: remove_old_dests(const TextureImage::Dests &a, const TextureImage::Dests &b) { Dests::const_iterator ai = a.begin(); @@ -1290,13 +1175,10 @@ remove_old_dests(const TextureImage::Dests &a, const TextureImage::Dests &b) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::copy_new_dests -// Access: Private -// Description: Copies a resized texture into each filename named in -// a that is not also listed in b, or whose -// corresponding listing in b is out of date. -//////////////////////////////////////////////////////////////////// +/** + * Copies a resized texture into each filename named in a that is not also + * listed in b, or whose corresponding listing in b is out of date. + */ void TextureImage:: copy_new_dests(const TextureImage::Dests &a, const TextureImage::Dests &b) { Dests::const_iterator ai = a.begin(); @@ -1330,12 +1212,10 @@ copy_new_dests(const TextureImage::Dests &a, const TextureImage::Dests &b) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::get_source_key -// Access: Private -// Description: Returns the key that a SourceTextureImage should be -// stored in, given its one or two filenames. -//////////////////////////////////////////////////////////////////// +/** + * Returns the key that a SourceTextureImage should be stored in, given its + * one or two filenames. + */ string TextureImage:: get_source_key(const Filename &filename, const Filename &alpha_filename, int alpha_file_channel) { @@ -1346,37 +1226,30 @@ get_source_key(const Filename &filename, const Filename &alpha_filename, format_string(alpha_file_channel); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void TextureImage:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_TextureImage); } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void TextureImage:: write_datagram(BamWriter *writer, Datagram &datagram) { ImageFile::write_datagram(writer, datagram); datagram.add_string(get_name()); - // We don't write out _request; this is re-read from the .txa file - // each time. + // We don't write out _request; this is re-read from the .txa file each + // time. // We don't write out _pre_txa_properties; this is transitional. - // We don't write out _preferred_source; this is redetermined each - // session. + // We don't write out _preferred_source; this is redetermined each session. datagram.add_bool(_is_surprise); datagram.add_bool(_ever_read_image); @@ -1388,8 +1261,8 @@ write_datagram(BamWriter *writer, Datagram &datagram) { datagram.add_uint8((int)_txa_wrap_u); datagram.add_uint8((int)_txa_wrap_v); - // We don't write out _explicitly_assigned_groups; this is re-read - // from the .txa file each time. + // We don't write out _explicitly_assigned_groups; this is re-read from the + // .txa file each time. _actual_assigned_groups.write_datagram(writer, datagram); @@ -1415,15 +1288,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int TextureImage:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = ImageFile::complete_pointers(p_list, manager); @@ -1466,14 +1336,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::make_TextureImage -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable *TextureImage:: make_TextureImage(const FactoryParams ¶ms) { TextureImage *me = new TextureImage; @@ -1485,13 +1352,10 @@ make_TextureImage(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: TextureImage::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void TextureImage:: fillin(DatagramIterator &scan, BamReader *manager) { ImageFile::fillin(scan, manager); diff --git a/pandatool/src/palettizer/textureImage.h b/pandatool/src/palettizer/textureImage.h index a8caf91c65..4d9b1b84e9 100644 --- a/pandatool/src/palettizer/textureImage.h +++ b/pandatool/src/palettizer/textureImage.h @@ -1,16 +1,15 @@ -// Filename: textureImage.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureImage.h + * @author drose + * @date 2000-11-28 + */ #ifndef TEXTUREIMAGE_H #define TEXTUREIMAGE_H @@ -34,20 +33,16 @@ class DestTextureImage; class TexturePlacement; class EggFile; -//////////////////////////////////////////////////////////////////// -// Class : TextureImage -// Description : This represents a single source texture that is -// referenced by one or more egg files. It may be -// assigned to multiple PaletteGroups, and thus placed -// on multiple PaletteImages (up to one per -// PaletteGroup). -// -// Since a TextureImage may be referenced by multiple -// egg files that are each assigned to a different set -// of groups, it tries to maximize sharing between egg -// files and minimize the number of different -// PaletteGroups it is assigned to. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single source texture that is referenced by one or more + * egg files. It may be assigned to multiple PaletteGroups, and thus placed + * on multiple PaletteImages (up to one per PaletteGroup). + * + * Since a TextureImage may be referenced by multiple egg files that are each + * assigned to a different set of groups, it tries to maximize sharing between + * egg files and minimize the number of different PaletteGroups it is assigned + * to. + */ class TextureImage : public ImageFile, public Namable { public: TextureImage(); @@ -127,8 +122,8 @@ private: bool _forced_grayscale; enum AlphaBits { - // consider_alpha() sets alpha_bits to the union of all of these - // pixel values that might be found in the alpha channel. + // consider_alpha() sets alpha_bits to the union of all of these pixel + // values that might be found in the alpha channel. AB_one = 0x01, AB_mid = 0x02, AB_zero = 0x04, @@ -170,8 +165,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // These values are only filled in while reading from the bam file; - // don't use them otherwise. + // These values are only filled in while reading from the bam file; don't + // use them otherwise. int _num_placement; int _num_sources; int _num_dests; @@ -198,4 +193,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/textureMemoryCounter.cxx b/pandatool/src/palettizer/textureMemoryCounter.cxx index 193c10d728..176461c832 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.cxx +++ b/pandatool/src/palettizer/textureMemoryCounter.cxx @@ -1,16 +1,15 @@ -// Filename: textureMemoryCounter.cxx -// Created by: drose (19Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureMemoryCounter.cxx + * @author drose + * @date 2000-12-19 + */ #include "textureMemoryCounter.h" #include "paletteImage.h" @@ -22,21 +21,17 @@ #include "indent.h" #include -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureMemoryCounter:: TextureMemoryCounter() { reset(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::reset -// Access: Public -// Description: Resets the count to zero. -//////////////////////////////////////////////////////////////////// +/** + * Resets the count to zero. + */ void TextureMemoryCounter:: reset() { _num_textures = 0; @@ -52,11 +47,9 @@ reset() { _palettes.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::add_placement -// Access: Public -// Description: Adds the indicated TexturePlacement to the counter. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated TexturePlacement to the counter. + */ void TextureMemoryCounter:: add_placement(TexturePlacement *placement) { TextureImage *texture = placement->get_texture(); @@ -77,18 +70,16 @@ add_placement(TexturePlacement *placement) { if (dest != (DestTextureImage *)NULL) { int bytes = count_bytes(dest); add_texture(texture, bytes); - + _bytes += bytes; _num_unplaced++; } } } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::report -// Access: Public -// Description: Reports the measured texture memory usage. -//////////////////////////////////////////////////////////////////// +/** + * Reports the measured texture memory usage. + */ void TextureMemoryCounter:: report(ostream &out, int indent_level) { indent(out, indent_level) @@ -125,13 +116,10 @@ report(ostream &out, int indent_level) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::format_memory_fraction -// Access: Private, Static -// Description: Writes to the indicated ostream an indication of the -// fraction of the total memory usage that is -// represented by fraction_bytes. -//////////////////////////////////////////////////////////////////// +/** + * Writes to the indicated ostream an indication of the fraction of the total + * memory usage that is represented by fraction_bytes. + */ ostream &TextureMemoryCounter:: format_memory_fraction(ostream &out, int fraction_bytes, int palette_bytes) { out << floor(1000.0 * (double)fraction_bytes / (double)palette_bytes + 0.5) / 10.0 @@ -139,13 +127,10 @@ format_memory_fraction(ostream &out, int fraction_bytes, int palette_bytes) { return out; } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::add_palette -// Access: Private -// Description: Adds the indicated PaletteImage to the count. If -// this is called twice for a given PaletteImage it does -// nothing. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated PaletteImage to the count. If this is called twice for + * a given PaletteImage it does nothing. + */ void TextureMemoryCounter:: add_palette(PaletteImage *image) { bool inserted = _palettes.insert(image).second; @@ -165,13 +150,10 @@ add_palette(PaletteImage *image) { _num_palettes++; } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::add_texture -// Access: Private -// Description: Adds the given TextureImage to the counter. If the -// texture image has already been added, this counts the -// smaller of the two as duplicate bytes. -//////////////////////////////////////////////////////////////////// +/** + * Adds the given TextureImage to the counter. If the texture image has + * already been added, this counts the smaller of the two as duplicate bytes. + */ void TextureMemoryCounter:: add_texture(TextureImage *texture, int bytes) { pair result; @@ -189,31 +171,27 @@ add_texture(TextureImage *texture, int bytes) { (*ti).second = max(bytes, (*ti).second); } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::count_bytes -// Access: Private -// Description: Attempts to estimate the number of bytes the given -// image file will use in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to estimate the number of bytes the given image file will use in + * texture memory. + */ int TextureMemoryCounter:: count_bytes(ImageFile *image) { return count_bytes(image, image->get_x_size(), image->get_y_size()); } -//////////////////////////////////////////////////////////////////// -// Function: TextureMemoryCounter::count_bytes -// Access: Private -// Description: Attempts to estimate the number of bytes the given -// image file will use in texture memory. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to estimate the number of bytes the given image file will use in + * texture memory. + */ int TextureMemoryCounter:: count_bytes(ImageFile *image, int x_size, int y_size) { int pixels = x_size * y_size; - // Try to guess the number of bytes per pixel this texture will - // consume in texture memory, based on its requested format. This - // is only a loose guess, because this depends of course on the - // pecularities of the particular rendering engine. + // Try to guess the number of bytes per pixel this texture will consume in + // texture memory, based on its requested format. This is only a loose + // guess, because this depends of course on the pecularities of the + // particular rendering engine. int bpp = 0; switch (image->get_properties()._format) { case EggTexture::F_rgba12: @@ -255,7 +233,7 @@ count_bytes(ImageFile *image, int x_size, int y_size) { int bytes = pixels * bpp; - // If we're mipmapping, it's worth 1/3 more bytes. + // If we're mipmapping, it's worth 13 more bytes. switch (image->get_properties()._minfilter) { case EggTexture::FT_nearest_mipmap_nearest: case EggTexture::FT_linear_mipmap_nearest: diff --git a/pandatool/src/palettizer/textureMemoryCounter.h b/pandatool/src/palettizer/textureMemoryCounter.h index d52695d1d7..47d70db230 100644 --- a/pandatool/src/palettizer/textureMemoryCounter.h +++ b/pandatool/src/palettizer/textureMemoryCounter.h @@ -1,16 +1,15 @@ -// Filename: textureMemoryCounter.h -// Created by: drose (19Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureMemoryCounter.h + * @author drose + * @date 2000-12-19 + */ #ifndef TEXTUREMEMORYCOUNTER_H #define TEXTUREMEMORYCOUNTER_H @@ -26,13 +25,11 @@ class TexturePlacement; #include "pmap.h" #include "pset.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureMemoryCounter -// Description : This class is used to gather statistics on texture -// memory usage, etc. It adds up the total texture -// memory required by a number of image files, and -// reports it at the end. -//////////////////////////////////////////////////////////////////// +/** + * This class is used to gather statistics on texture memory usage, etc. It + * adds up the total texture memory required by a number of image files, and + * reports it at the end. + */ class TextureMemoryCounter { public: TextureMemoryCounter(); diff --git a/pandatool/src/palettizer/texturePlacement.cxx b/pandatool/src/palettizer/texturePlacement.cxx index 9ca5c286d4..323fe6e368 100644 --- a/pandatool/src/palettizer/texturePlacement.cxx +++ b/pandatool/src/palettizer/texturePlacement.cxx @@ -1,16 +1,15 @@ -// Filename: texturePlacement.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePlacement.cxx + * @author drose + * @date 2000-11-30 + */ #include "texturePlacement.h" #include "textureReference.h" @@ -30,12 +29,9 @@ TypeHandle TexturePlacement::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::Default Constructor -// Access: Private -// Description: The default constructor is only for the convenience -// of the Bam reader. -//////////////////////////////////////////////////////////////////// +/** + * The default constructor is only for the convenience of the Bam reader. + */ TexturePlacement:: TexturePlacement() { _texture = (TextureImage *)NULL; @@ -48,11 +44,9 @@ TexturePlacement() { _omit_reason = OR_none; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexturePlacement:: TexturePlacement(TextureImage *texture, PaletteGroup *group) : _texture(texture), @@ -61,8 +55,8 @@ TexturePlacement(TextureImage *texture, PaletteGroup *group) : _omit_reason = OR_working; if (!texture->is_size_known()) { - // If we were never able to figure out what size the texture - // actually is, then we can't place the texture on a palette. + // If we were never able to figure out what size the texture actually is, + // then we can't place the texture on a palette. _omit_reason = OR_unknown; } @@ -73,15 +67,12 @@ TexturePlacement(TextureImage *texture, PaletteGroup *group) : _is_filled = false; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexturePlacement:: ~TexturePlacement() { - // Make sure we tell all our egg references they're not using us any - // more. + // Make sure we tell all our egg references they're not using us any more. References::iterator ri; References copy_references = _references; for (ri = copy_references.begin(); ri != copy_references.end(); ++ri) { @@ -94,59 +85,48 @@ TexturePlacement:: _group->unplace(this); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_name -// Access: Public -// Description: Returns the name of the texture that this placement -// represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the texture that this placement represents. + */ const string &TexturePlacement:: get_name() const { return _texture->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_texture -// Access: Public -// Description: Returns the texture that this placement represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the texture that this placement represents. + */ TextureImage *TexturePlacement:: get_texture() const { return _texture; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_properties -// Access: Public -// Description: Returns the grouping properties of the image. -//////////////////////////////////////////////////////////////////// +/** + * Returns the grouping properties of the image. + */ const TextureProperties &TexturePlacement:: get_properties() const { return _texture->get_properties(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_group -// Access: Public -// Description: Returns the group that this placement represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the group that this placement represents. + */ PaletteGroup *TexturePlacement:: get_group() const { return _group; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::add_egg -// Access: Public -// Description: Records the fact that a particular egg file is using -// this particular TexturePlacement. -//////////////////////////////////////////////////////////////////// +/** + * Records the fact that a particular egg file is using this particular + * TexturePlacement. + */ void TexturePlacement:: add_egg(TextureReference *reference) { reference->mark_egg_stale(); - // Turns out that turning these off is a bad idea, because it may - // make us forget the size information halfway through processing. + // Turns out that turning these off is a bad idea, because it may make us + // forget the size information halfway through processing. /* _has_uvs = false; _size_known = false; @@ -154,12 +134,10 @@ add_egg(TextureReference *reference) { _references.insert(reference); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::remove_egg -// Access: Public -// Description: Notes that a particular egg file is no longer using -// this particular TexturePlacement. -//////////////////////////////////////////////////////////////////// +/** + * Notes that a particular egg file is no longer using this particular + * TexturePlacement. + */ void TexturePlacement:: remove_egg(TextureReference *reference) { reference->mark_egg_stale(); @@ -170,13 +148,10 @@ remove_egg(TextureReference *reference) { _references.erase(reference); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::mark_eggs_stale -// Access: Public -// Description: Marks all the egg files that reference this placement -// stale. Presumably this is called after moving the -// texture around in the palette or something. -//////////////////////////////////////////////////////////////////// +/** + * Marks all the egg files that reference this placement stale. Presumably + * this is called after moving the texture around in the palette or something. + */ void TexturePlacement:: mark_eggs_stale() { References::iterator ri; @@ -187,41 +162,33 @@ mark_eggs_stale() { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::set_dest -// Access: Public -// Description: Sets the DestTextureImage that corresponds to this -// texture as it was copied to the install directory. -//////////////////////////////////////////////////////////////////// +/** + * Sets the DestTextureImage that corresponds to this texture as it was copied + * to the install directory. + */ void TexturePlacement:: set_dest(DestTextureImage *dest) { _dest = dest; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_dest -// Access: Public -// Description: Returns the DestTextureImage that corresponds to this -// texture as it was copied to the install directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the DestTextureImage that corresponds to this texture as it was + * copied to the install directory. + */ DestTextureImage *TexturePlacement:: get_dest() const { return _dest; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::determine_size -// Access: Public -// Description: Attempts to determine the appropriate size of the -// texture for the given placement. This is based on -// the UV range of the egg files that reference the -// texture. Returns true on success, or false if the -// texture size cannot be determined (e.g. the texture -// file is unknown). -// -// After this returns true, get_x_size() and -// get_y_size() may safely be called. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to determine the appropriate size of the texture for the given + * placement. This is based on the UV range of the egg files that reference + * the texture. Returns true on success, or false if the texture size cannot + * be determined (e.g. the texture file is unknown). + * + * After this returns true, get_x_size() and get_y_size() may safely be + * called. + */ bool TexturePlacement:: determine_size() { if (!_texture->is_size_known()) { @@ -232,19 +199,18 @@ determine_size() { } // This seems to be unnecessary (because of omit_solitary() and - // not_solitary()), and in fact bitches the logic in omit_solitary() - // and not_solitary() so that we call mark_egg_stale() - // unnecessarily. + // not_solitary()), and in fact bitches the logic in omit_solitary() and + // not_solitary() so that we call mark_egg_stale() unnecessarily. /* if (_omit_reason == OR_solitary) { - // If the texture was previously 'omitted' for being solitary, we - // give it a second chance now. + // If the texture was previously 'omitted' for being solitary, we give it + // a second chance now. _omit_reason = OR_none; } */ - // Determine the actual minmax of the UV's in use, as well as - // whether we should wrap or clamp. + // Determine the actual minmax of the UV's in use, as well as whether we + // should wrap or clamp. _has_uvs = false; _position._wrap_u = EggTexture::WM_clamp; _position._wrap_v = EggTexture::WM_clamp; @@ -268,8 +234,8 @@ determine_size() { } } - // If any reference repeats the texture, the texture repeats in - // the palette. + // If any reference repeats the texture, the texture repeats in the + // palette. if (reference->get_wrap_u() == EggTexture::WM_repeat) { _position._wrap_u = EggTexture::WM_repeat; } @@ -278,8 +244,7 @@ determine_size() { } } - // However, if the user specified an explicit wrap mode, allow it to - // apply. + // However, if the user specified an explicit wrap mode, allow it to apply. if (_texture->get_txa_wrap_u() != EggTexture::WM_unspecified) { _position._wrap_u = _texture->get_txa_wrap_u(); } @@ -296,13 +261,13 @@ determine_size() { LTexCoordd rounded_min_uv = min_uv; LTexCoordd rounded_max_uv = max_uv; - //cout << get_name() << endl; + // cout << get_name() << endl; - // If so requested, round the minmax out to the next _round_unit. - // This cuts down on unnecessary resizing of textures within the - // palettes as the egg references change in trivial amounts. - //cout << "rounded_min_uv: " << rounded_min_uv << endl; - //cout << "rounded_max_uv: " << rounded_max_uv << endl; + // If so requested, round the minmax out to the next _round_unit. This cuts + // down on unnecessary resizing of textures within the palettes as the egg + // references change in trivial amounts. cout << "rounded_min_uv: " << + // rounded_min_uv << endl; cout << "rounded_max_uv: " << rounded_max_uv << + // endl; if (pal->_round_uvs) { rounded_max_uv[0] = @@ -319,12 +284,12 @@ determine_size() { floor((rounded_min_uv[1] + pal->_round_fuzz) / pal->_round_unit) * pal->_round_unit; - //cout << "after rounded_min_uv: " << rounded_min_uv << endl; - //cout << "after rounded_max_uv: " << rounded_max_uv << endl; + // cout << "after rounded_min_uv: " << rounded_min_uv << endl; cout << + // "after rounded_max_uv: " << rounded_max_uv << endl; } - // Now determine the size in pixels we require based on the UV's - // that actually reference this texture. + // Now determine the size in pixels we require based on the UV's that + // actually reference this texture. compute_size_from_uvs(rounded_min_uv, rounded_max_uv); // Now, can it be placed? @@ -342,10 +307,9 @@ determine_size() { _position._y_size > pal->_pal_y_size) || (_position._x_size == pal->_pal_x_size && _position._y_size == pal->_pal_y_size)) { - // If the texture exceeds the size of an empty palette image in - // either dimension, or if it exactly equals the size of an empty - // palette image in both dimensions, we can't place it because - // it's too big. + // If the texture exceeds the size of an empty palette image in either + // dimension, or if it exactly equals the size of an empty palette image + // in both dimensions, we can't place it because it's too big. force_replace(); _omit_reason = OR_size; @@ -359,16 +323,15 @@ determine_size() { _omit_reason == OR_size || _omit_reason == OR_coverage || _omit_reason == OR_unknown) { - // On the other hand, if the texture was previously omitted - // explicitly, or because of its size or coverage, now it seems to - // fit. + // On the other hand, if the texture was previously omitted explicitly, or + // because of its size or coverage, now it seems to fit. force_replace(); mark_eggs_stale(); _omit_reason = OR_working; } else if (is_placed()) { - // It *can* be placed. If it was already placed previously, can - // we leave it where it is? + // It *can* be placed. If it was already placed previously, can we leave + // it where it is? if (_position._x_size != _placed._x_size || _position._y_size != _placed._y_size || @@ -376,13 +339,12 @@ determine_size() { _position._min_uv[1] < _placed._min_uv[1] || _position._max_uv[0] > _placed._max_uv[0] || _position._max_uv[1] > _placed._max_uv[1]) { - // If the texture was previously placed but is now the wrong - // size, or if the area we need to cover is different, we need - // to re-place it. + // If the texture was previously placed but is now the wrong size, or if + // the area we need to cover is different, we need to re-place it. - // However, we make a special exception: if it would have fit - // without rounding up the UV's, then screw rounding it up and - // just leave it alone. + // However, we make a special exception: if it would have fit without + // rounding up the UV's, then screw rounding it up and just leave it + // alone. if ((_position._x_size > _placed._x_size || _position._y_size > _placed._y_size) && pal->_round_uvs) { @@ -406,8 +368,8 @@ determine_size() { if (_position._wrap_u != _placed._wrap_u || _position._wrap_v != _placed._wrap_v) { - // The wrap mode properties have changed slightly. We may or - // may not need to re-place it, but we will need to update it. + // The wrap mode properties have changed slightly. We may or may not + // need to re-place it, but we will need to update it. _is_filled = false; _placed._wrap_u = _position._wrap_u; _placed._wrap_v = _position._wrap_v; @@ -417,68 +379,53 @@ determine_size() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::is_size_known -// Access: Public -// Description: Returns true if the texture's size is known, false -// otherwise. Usually this can only be false after -// determine_size() has been called there is something -// wrong with the texture (in which case the placement -// will automatically omit itself from the palette -// anyway). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture's size is known, false otherwise. Usually this + * can only be false after determine_size() has been called there is something + * wrong with the texture (in which case the placement will automatically omit + * itself from the palette anyway). + */ bool TexturePlacement:: is_size_known() const { return _size_known; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_omit_reason -// Access: Public -// Description: Returns the reason the texture has been omitted from -// a palette image, or OR_none if it has not. -//////////////////////////////////////////////////////////////////// +/** + * Returns the reason the texture has been omitted from a palette image, or + * OR_none if it has not. + */ OmitReason TexturePlacement:: get_omit_reason() const { return _omit_reason; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_x_size -// Access: Public -// Description: Returns the size in the X dimension, in pixels, of -// the texture image as it must appear in the palette. -// This accounts for any growing or shrinking of the -// texture due to the UV coordinate range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size in the X dimension, in pixels, of the texture image as it + * must appear in the palette. This accounts for any growing or shrinking of + * the texture due to the UV coordinate range. + */ int TexturePlacement:: get_x_size() const { nassertr(_size_known, 0); return _position._x_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_y_size -// Access: Public -// Description: Returns the size in the Y dimension, in pixels, of -// the texture image as it must appear in the palette. -// This accounts for any growing or shrinking of the -// texture due to the UV coordinate range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size in the Y dimension, in pixels, of the texture image as it + * must appear in the palette. This accounts for any growing or shrinking of + * the texture due to the UV coordinate range. + */ int TexturePlacement:: get_y_size() const { nassertr(_size_known, 0); return _position._y_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_uv_area -// Access: Public -// Description: Returns the total area of the rectangle occupied by -// the UV minmax box, in UV coordinates. 1.0 is the -// entire texture; values greater than 1 imply the -// texture repeats. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total area of the rectangle occupied by the UV minmax box, in + * UV coordinates. 1.0 is the entire texture; values greater than 1 imply the + * texture repeats. + */ double TexturePlacement:: get_uv_area() const { if (!_has_uvs) { @@ -489,102 +436,78 @@ get_uv_area() const { return range[0] * range[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::is_placed -// Access: Public -// Description: Returns true if the texture has been placed on a -// palette image, false otherwise. This will generally -// be true if get_omit_reason() returns OR_none or -// OR_solitary and false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has been placed on a palette image, false + * otherwise. This will generally be true if get_omit_reason() returns + * OR_none or OR_solitary and false otherwise. + */ bool TexturePlacement:: is_placed() const { return _image != (PaletteImage *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_image -// Access: Public -// Description: Returns the particular PaletteImage on which the -// texture has been placed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular PaletteImage on which the texture has been placed. + */ PaletteImage *TexturePlacement:: get_image() const { nassertr(is_placed(), (PaletteImage *)NULL); return _image; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_page -// Access: Public -// Description: Returns the particular PalettePage on which the -// texture has been placed. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular PalettePage on which the texture has been placed. + */ PalettePage *TexturePlacement:: get_page() const { nassertr(is_placed(), (PalettePage *)NULL); return _image->get_page(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_placed_x -// Access: Public -// Description: Returns the X pixel at which the texture has been -// placed within its PaletteImage. It is an error to -// call this unless is_placed() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the X pixel at which the texture has been placed within its + * PaletteImage. It is an error to call this unless is_placed() returns true. + */ int TexturePlacement:: get_placed_x() const { nassertr(is_placed(), 0); return _placed._x; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_placed_y -// Access: Public -// Description: Returns the Y pixel at which the texture has been -// placed within its PaletteImage. It is an error to -// call this unless is_placed() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Y pixel at which the texture has been placed within its + * PaletteImage. It is an error to call this unless is_placed() returns true. + */ int TexturePlacement:: get_placed_y() const { nassertr(is_placed(), 0); return _placed._y; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_placed_x_size -// Access: Public -// Description: Returns the size in the X dimension, in pixels, of -// the texture image as it has been placed within the -// palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size in the X dimension, in pixels, of the texture image as it + * has been placed within the palette. + */ int TexturePlacement:: get_placed_x_size() const { nassertr(is_placed(), 0); return _placed._x_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_placed_y_size -// Access: Public -// Description: Returns the size in the Y dimension, in pixels, of -// the texture image as it has been placed within the -// palette. -//////////////////////////////////////////////////////////////////// +/** + * Returns the size in the Y dimension, in pixels, of the texture image as it + * has been placed within the palette. + */ int TexturePlacement:: get_placed_y_size() const { nassertr(is_placed(), 0); return _placed._y_size; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::get_placed_uv_area -// Access: Public -// Description: Returns the total area of the rectangle occupied by -// the UV minmax box, as it has been placed. See also -// get_uv_area(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the total area of the rectangle occupied by the UV minmax box, as + * it has been placed. See also get_uv_area(). + */ double TexturePlacement:: get_placed_uv_area() const { nassertr(is_placed(), 0); @@ -592,14 +515,11 @@ get_placed_uv_area() const { return range[0] * range[1]; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::place_at -// Access: Public -// Description: Assigns the texture to a particular position within -// the indicated PaletteImage. It is an error to call -// this if the texture has already been placed -// elsewhere. -//////////////////////////////////////////////////////////////////// +/** + * Assigns the texture to a particular position within the indicated + * PaletteImage. It is an error to call this if the texture has already been + * placed elsewhere. + */ void TexturePlacement:: place_at(PaletteImage *image, int x, int y) { nassertv(!is_placed()); @@ -613,14 +533,11 @@ place_at(PaletteImage *image, int x, int y) { _omit_reason = OR_none; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::force_replace -// Access: Public -// Description: Removes the texture from its particular PaletteImage, -// but does not remove it from the PaletteGroup. It -// will be re-placed when the PaletteGroup::place_all() -// is called. -//////////////////////////////////////////////////////////////////// +/** + * Removes the texture from its particular PaletteImage, but does not remove + * it from the PaletteGroup. It will be re-placed when the + * PaletteGroup::place_all() is called. + */ void TexturePlacement:: force_replace() { if (_image != (PaletteImage *)NULL) { @@ -633,16 +550,12 @@ force_replace() { _omit_reason = OR_working; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::omit_solitary -// Access: Public -// Description: Sets the omit reason (returned by get_omit()) to -// OR_solitary, indicating that the palettized version -// of the texture should not be used because it is the -// only texture on a PaletteImage. However, the texture -// is still considered placed, and is_placed() will -// return true. -//////////////////////////////////////////////////////////////////// +/** + * Sets the omit reason (returned by get_omit()) to OR_solitary, indicating + * that the palettized version of the texture should not be used because it is + * the only texture on a PaletteImage. However, the texture is still + * considered placed, and is_placed() will return true. + */ void TexturePlacement:: omit_solitary() { nassertv(is_placed()); @@ -652,12 +565,10 @@ omit_solitary() { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::not_solitary -// Access: Public -// Description: Indicates that the texture, formerly indicated as -// solitary, is now no longer. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the texture, formerly indicated as solitary, is now no + * longer. + */ void TexturePlacement:: not_solitary() { nassertv(is_placed()); @@ -667,14 +578,11 @@ not_solitary() { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::intersects -// Access: Public -// Description: Returns true if the particular position this texture -// has been assigned to overlaps the rectangle whose -// top left corner is at x, y and whose size is given by -// x_size, y_size, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the particular position this texture has been assigned to + * overlaps the rectangle whose top left corner is at x, y and whose size is + * given by x_size, y_size, or false otherwise. + */ bool TexturePlacement:: intersects(int x, int y, int x_size, int y_size) { nassertr(is_placed(), false); @@ -689,13 +597,10 @@ intersects(int x, int y, int x_size, int y_size) { y >= mbot || hbot <= _placed._y); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::compute_tex_matrix -// Access: Public -// Description: Stores in the indicated matrix the appropriate -// texture matrix transform for the new placement of the -// texture. -//////////////////////////////////////////////////////////////////// +/** + * Stores in the indicated matrix the appropriate texture matrix transform for + * the new placement of the texture. + */ void TexturePlacement:: compute_tex_matrix(LMatrix3d &transform) { nassertv(is_placed()); @@ -731,12 +636,9 @@ compute_tex_matrix(LMatrix3d &transform) { transform = source_uvs * dest_uvs; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::write_placed -// Access: Public -// Description: Writes the placement position information on a line -// by itself. -//////////////////////////////////////////////////////////////////// +/** + * Writes the placement position information on a line by itself. + */ void TexturePlacement:: write_placed(ostream &out, int indent_level) { indent(out, indent_level) @@ -763,47 +665,38 @@ write_placed(ostream &out, int indent_level) { } }; -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::is_filled -// Access: Public -// Description: Returns true if the texture has been filled -// (i.e. fill_image() has been called) since it was -// placed. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture has been filled (i.e. fill_image() has been + * called) since it was placed. + */ bool TexturePlacement:: is_filled() const { return _is_filled; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::mark_unfilled -// Access: Public -// Description: Marks the texture as unfilled, so that it will need -// to be copied into the palette image again. -//////////////////////////////////////////////////////////////////// +/** + * Marks the texture as unfilled, so that it will need to be copied into the + * palette image again. + */ void TexturePlacement:: mark_unfilled() { _is_filled = false; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::fill_image -// Access: Public -// Description: Fills in the rectangle of the palette image -// represented by the texture placement with the image -// pixels. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the rectangle of the palette image represented by the texture + * placement with the image pixels. + */ void TexturePlacement:: fill_image(PNMImage &image) { nassertv(is_placed()); _is_filled = true; - // We determine the pixels to place the source image at by - // transforming the unit texture box: the upper-left and lower-right - // corners. These corners, in the final texture coordinate space, - // represent where on the palette image the original texture should - // be located. + // We determine the pixels to place the source image at by transforming the + // unit texture box: the upper-left and lower-right corners. These corners, + // in the final texture coordinate space, represent where on the palette + // image the original texture should be located. LMatrix3d transform; compute_tex_matrix(transform); @@ -819,15 +712,13 @@ fill_image(PNMImage &image) { int bottom = (int)floor((1.0 - lr[1]) * pal_y_size + 0.5); int right = (int)floor(lr[0] * pal_x_size + 0.5); - // And now we can determine the size to scale the image to based on - // that. This may not be the same as texture->size() because of - // margins. + // And now we can determine the size to scale the image to based on that. + // This may not be the same as texture->size() because of margins. int x_size = right - left; int y_size = bottom - top; nassertv(x_size >= 0 && y_size >= 0); - // Now we get a PNMImage that represents the source texture at that - // size. + // Now we get a PNMImage that represents the source texture at that size. const PNMImage &source_full = _texture->read_source_image(); if (!source_full.is_valid()) { flag_error_image(image); @@ -841,12 +732,11 @@ fill_image(PNMImage &image) { bool alpha = image.has_alpha(); bool source_alpha = source.has_alpha(); - // Now copy the pixels. We do this by walking through the - // rectangular region on the palette image that we have reserved for - // this texture; for each pixel in this region, we determine its - // appropriate color based on its relation to the actual texture - // image location (determined above), and on whether the texture - // wraps or clamps. + // Now copy the pixels. We do this by walking through the rectangular + // region on the palette image that we have reserved for this texture; for + // each pixel in this region, we determine its appropriate color based on + // its relation to the actual texture image location (determined above), and + // on whether the texture wraps or clamps. for (int y = _placed._y; y < _placed._y + _placed._y_size; y++) { int sy = y - top; @@ -886,24 +776,20 @@ fill_image(PNMImage &image) { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::fill_swapped_image -// Access: Public -// Description: Fills in the rectangle of the swapped palette image -// represented by the texture placement with the image -// pixels. -//////////////////////////////////////////////////////////////////// +/** + * Fills in the rectangle of the swapped palette image represented by the + * texture placement with the image pixels. + */ void TexturePlacement:: fill_swapped_image(PNMImage &image, int index) { nassertv(is_placed()); _is_filled = true; - // We determine the pixels to place the source image at by - // transforming the unit texture box: the upper-left and lower-right - // corners. These corners, in the final texture coordinate space, - // represent where on the palette image the original texture should - // be located. + // We determine the pixels to place the source image at by transforming the + // unit texture box: the upper-left and lower-right corners. These corners, + // in the final texture coordinate space, represent where on the palette + // image the original texture should be located. LMatrix3d transform; compute_tex_matrix(transform); @@ -919,15 +805,13 @@ fill_swapped_image(PNMImage &image, int index) { int bottom = (int)floor((1.0 - lr[1]) * pal_y_size + 0.5); int right = (int)floor(lr[0] * pal_x_size + 0.5); - // And now we can determine the size to scale the image to based on - // that. This may not be the same as texture->size() because of - // margins. + // And now we can determine the size to scale the image to based on that. + // This may not be the same as texture->size() because of margins. int x_size = right - left; int y_size = bottom - top; nassertv(x_size >= 0 && y_size >= 0); - // Now we get a PNMImage that represents the swapped texture at that - // size. + // Now we get a PNMImage that represents the swapped texture at that size. TextureSwaps::iterator tsi; tsi = _textureSwaps.begin() + index; TextureImage *swapTexture = (*tsi); @@ -944,12 +828,11 @@ fill_swapped_image(PNMImage &image, int index) { bool alpha = image.has_alpha(); bool source_alpha = source.has_alpha(); - // Now copy the pixels. We do this by walking through the - // rectangular region on the palette image that we have reserved for - // this texture; for each pixel in this region, we determine its - // appropriate color based on its relation to the actual texture - // image location (determined above), and on whether the texture - // wraps or clamps. + // Now copy the pixels. We do this by walking through the rectangular + // region on the palette image that we have reserved for this texture; for + // each pixel in this region, we determine its appropriate color based on + // its relation to the actual texture image location (determined above), and + // on whether the texture wraps or clamps. for (int y = _placed._y; y < _placed._y + _placed._y_size; y++) { int sy = y - top; @@ -988,13 +871,10 @@ fill_swapped_image(PNMImage &image, int index) { swapTexture->release_source_image(); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::flag_error_image -// Access: Public -// Description: Sets the rectangle of the palette image -// represented by the texture placement to red, to -// represent a missing texture. -//////////////////////////////////////////////////////////////////// +/** + * Sets the rectangle of the palette image represented by the texture + * placement to red, to represent a missing texture. + */ void TexturePlacement:: flag_error_image(PNMImage &image) { nassertv(is_placed()); @@ -1012,33 +892,30 @@ flag_error_image(PNMImage &image) { } } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::compute_size_from_uvs -// Access: Private -// Description: A support function for determine_size(), this -// computes the appropriate size of the texture in -// pixels based on the UV coverage (as well as on the -// size of the source texture). -//////////////////////////////////////////////////////////////////// +/** + * A support function for determine_size(), this computes the appropriate size + * of the texture in pixels based on the UV coverage (as well as on the size + * of the source texture). + */ void TexturePlacement:: compute_size_from_uvs(const LTexCoordd &min_uv, const LTexCoordd &max_uv) { _position._min_uv = min_uv; _position._max_uv = max_uv; LTexCoordd range = _position._max_uv - _position._min_uv; - //cout << "range: " << range << endl; + // cout << "range: " << range << endl; - //cout << "_x_size texture: " << _texture->get_x_size() << endl; - //cout << "_y_size texture: " << _texture->get_y_size() << endl; + // cout << "_x_size texture: " << _texture->get_x_size() << endl; cout << + // "_y_size texture: " << _texture->get_y_size() << endl; _position._x_size = (int)floor(_texture->get_x_size() * range[0] + 0.5); _position._y_size = (int)floor(_texture->get_y_size() * range[1] + 0.5); - //cout << "_x_size: " << _position._x_size << endl; - //cout << "_y_size: " << _position._y_size << endl; + // cout << "_x_size: " << _position._x_size << endl; cout << "_y_size: " << + // _position._y_size << endl; - // We arbitrarily require at least four pixels in each dimension. - // Fewer than this may be asking for trouble. + // We arbitrarily require at least four pixels in each dimension. Fewer + // than this may be asking for trouble. _position._x_size = max(_position._x_size, 4); _position._y_size = max(_position._y_size, 4); @@ -1047,12 +924,12 @@ compute_size_from_uvs(const LTexCoordd &min_uv, const LTexCoordd &max_uv) { } else { _position._margin = _texture->get_margin(); } - //cout << "margin: " << _position._margin << endl; - - // Normally, we have interior margins, but if the image size is too - // small--i.e. the margin size is too great a percentage of the - // image size--we'll make them exterior margins so as not to overly - // degrade the quality of the image. + // cout << "margin: " << _position._margin << endl; + + // Normally, we have interior margins, but if the image size is too small-- + // i.e. the margin size is too great a percentage of the image size--we'll + // make them exterior margins so as not to overly degrade the quality of the + // image. if ((double)_position._margin / (double)_position._x_size > 0.10) { _position._x_size += _position._margin * 2; } @@ -1065,25 +942,19 @@ compute_size_from_uvs(const LTexCoordd &min_uv, const LTexCoordd &max_uv) { -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void TexturePlacement:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_TexturePlacement); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void TexturePlacement:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -1114,15 +985,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int TexturePlacement:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); @@ -1165,14 +1033,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::make_TexturePlacement -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* TexturePlacement:: make_TexturePlacement(const FactoryParams ¶ms) { TexturePlacement *me = new TexturePlacement; @@ -1184,13 +1049,10 @@ make_TexturePlacement(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePlacement::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void TexturePlacement:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); @@ -1220,13 +1082,10 @@ fillin(DatagramIterator &scan, BamReader *manager) { } -//////////////////////////////////////////////////////////////////// -// Function: SortPlacementBySize::Function Operator -// Access: Public -// Description: Compares two TexturePlacement objects and returns -// true if the first one is bigger than the second one, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Compares two TexturePlacement objects and returns true if the first one is + * bigger than the second one, false otherwise. + */ bool SortPlacementBySize:: operator ()(TexturePlacement *a, TexturePlacement *b) const { if (a->get_y_size() < b->get_y_size()) { @@ -1241,9 +1100,10 @@ operator ()(TexturePlacement *a, TexturePlacement *b) const { } else if (b->get_x_size() < a->get_x_size()) { return true; } else if (a->get_name() < b->get_name()) { - //use this fall through case to let alphabetically smaller textures show up first + // use this fall through case to let alphabetically smaller textures show + // up first return true; } - + return false; } diff --git a/pandatool/src/palettizer/texturePlacement.h b/pandatool/src/palettizer/texturePlacement.h index 2a172e5855..be4d667a24 100644 --- a/pandatool/src/palettizer/texturePlacement.h +++ b/pandatool/src/palettizer/texturePlacement.h @@ -1,16 +1,15 @@ -// Filename: texturePlacement.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePlacement.h + * @author drose + * @date 2000-11-28 + */ #ifndef TEXTUREPLACEMENT_H #define TEXTUREPLACEMENT_H @@ -34,14 +33,11 @@ class TextureProperties; class TextureReference; class PNMImage; -//////////////////////////////////////////////////////////////////// -// Class : TexturePlacement -// Description : This corresponds to a particular assignment of a -// TextureImage with a PaletteGroup, and specifically -// describes which PaletteImage (if any), and where on -// the PaletteImage, the TextureImage has been assigned -// to. -//////////////////////////////////////////////////////////////////// +/** + * This corresponds to a particular assignment of a TextureImage with a + * PaletteGroup, and specifically describes which PaletteImage (if any), and + * where on the PaletteImage, the TextureImage has been assigned to. + */ class TexturePlacement : public TypedWritable { private: TexturePlacement(); @@ -128,8 +124,8 @@ protected: void fillin(DatagramIterator &scan, BamReader *manager); private: - // This value is only filled in while reading from the bam file; - // don't use it otherwise. + // This value is only filled in while reading from the bam file; don't use + // it otherwise. int _num_references; int _margin_override; int _num_textureSwaps; @@ -152,12 +148,11 @@ private: }; -// This is an STL object to sort an array of TexturePlacement pointers -// in order from biggest to smallest. +// This is an STL object to sort an array of TexturePlacement pointers in +// order from biggest to smallest. class SortPlacementBySize { public: bool operator ()(TexturePlacement *a, TexturePlacement *b) const; }; #endif - diff --git a/pandatool/src/palettizer/texturePosition.cxx b/pandatool/src/palettizer/texturePosition.cxx index 79313e60cd..dd7617d1d8 100644 --- a/pandatool/src/palettizer/texturePosition.cxx +++ b/pandatool/src/palettizer/texturePosition.cxx @@ -1,16 +1,15 @@ -// Filename: texturePosition.cxx -// Created by: drose (04Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePosition.cxx + * @author drose + * @date 2000-12-04 + */ #include "texturePosition.h" @@ -21,11 +20,9 @@ TypeHandle TexturePosition::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexturePosition:: TexturePosition() { _margin = 0; @@ -39,11 +36,9 @@ TexturePosition() { _wrap_v = EggTexture::WM_unspecified; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TexturePosition:: TexturePosition(const TexturePosition ©) : _margin(copy._margin), @@ -58,11 +53,9 @@ TexturePosition(const TexturePosition ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TexturePosition:: operator = (const TexturePosition ©) { _margin = copy._margin; @@ -76,25 +69,19 @@ operator = (const TexturePosition ©) { _wrap_v = copy._wrap_v; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void TexturePosition:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_TexturePosition); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void TexturePosition:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -111,14 +98,11 @@ write_datagram(BamWriter *writer, Datagram &datagram) { datagram.add_int32((int)_wrap_v); } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::make_TexturePosition -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* TexturePosition:: make_TexturePosition(const FactoryParams ¶ms) { TexturePosition *me = new TexturePosition; @@ -130,13 +114,10 @@ make_TexturePosition(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: TexturePosition::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void TexturePosition:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/texturePosition.h b/pandatool/src/palettizer/texturePosition.h index 351cdc6964..08f373a644 100644 --- a/pandatool/src/palettizer/texturePosition.h +++ b/pandatool/src/palettizer/texturePosition.h @@ -1,16 +1,15 @@ -// Filename: texturePosition.h -// Created by: drose (04Dec00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file texturePosition.h + * @author drose + * @date 2000-12-04 + */ #ifndef TEXTUREPOSITION_H #define TEXTUREPOSITION_H @@ -23,14 +22,12 @@ class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TexturePosition -// Description : This represents a particular position of a texture -// within a PaletteImage. There is only one of these -// per TexturePlacement, but it exists as a separate -// structure so the TexturePlacement can easily consider -// repositioning the texture. -//////////////////////////////////////////////////////////////////// +/** + * This represents a particular position of a texture within a PaletteImage. + * There is only one of these per TexturePlacement, but it exists as a + * separate structure so the TexturePlacement can easily consider + * repositioning the texture. + */ class TexturePosition : public TypedWritable { public: TexturePosition(); @@ -76,4 +73,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/textureProperties.cxx b/pandatool/src/palettizer/textureProperties.cxx index 3ea8b3d3c4..c8db745fc8 100644 --- a/pandatool/src/palettizer/textureProperties.cxx +++ b/pandatool/src/palettizer/textureProperties.cxx @@ -1,16 +1,15 @@ -// Filename: textureProperties.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureProperties.cxx + * @author drose + * @date 2000-11-29 + */ #include "textureProperties.h" #include "palettizer.h" @@ -23,11 +22,9 @@ TypeHandle TextureProperties::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureProperties:: TextureProperties() { _got_num_channels = false; @@ -45,11 +42,9 @@ TextureProperties() { _alpha_type = (PNMFileType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureProperties:: TextureProperties(const TextureProperties ©) : _format(copy._format), @@ -68,11 +63,9 @@ TextureProperties(const TextureProperties ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureProperties:: operator = (const TextureProperties ©) { _force_format = copy._force_format; @@ -90,12 +83,10 @@ operator = (const TextureProperties ©) { _format = copy._format; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::clear_basic -// Access: Public -// Description: Resets only the properties that might be changed by -// update_properties() to a neutral state. -//////////////////////////////////////////////////////////////////// +/** + * Resets only the properties that might be changed by update_properties() to + * a neutral state. + */ void TextureProperties:: clear_basic() { if (!_force_format) { @@ -108,36 +99,28 @@ clear_basic() { _anisotropic_degree = 0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::has_num_channels -// Access: Public -// Description: Returns true if the number of channels is known. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the number of channels is known. + */ bool TextureProperties:: has_num_channels() const { return _got_num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_num_channels -// Access: Public -// Description: Returns the number of channels (1 through 4) -// associated with the image. It is an error to call -// this unless has_num_channels() returns true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of channels (1 through 4) associated with the image. It + * is an error to call this unless has_num_channels() returns true. + */ int TextureProperties:: get_num_channels() const { nassertr(_got_num_channels, 0); return _effective_num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::set_num_channels -// Access: Public -// Description: Sets the number of channels (1 through 4) -// associated with the image, presumably after reading -// this information from the image header. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of channels (1 through 4) associated with the image, + * presumably after reading this information from the image header. + */ void TextureProperties:: set_num_channels(int num_channels) { _num_channels = num_channels; @@ -145,13 +128,10 @@ set_num_channels(int num_channels) { _got_num_channels = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::force_grayscale -// Access: Public -// Description: Sets the actual number of channels to indicate a -// grayscale image, presumably after discovering that -// the image contains no colored pixels. -//////////////////////////////////////////////////////////////////// +/** + * Sets the actual number of channels to indicate a grayscale image, + * presumably after discovering that the image contains no colored pixels. + */ void TextureProperties:: force_grayscale() { nassertv(_got_num_channels && _num_channels >= 3); @@ -159,14 +139,11 @@ force_grayscale() { _effective_num_channels = _num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::force_nonalpha -// Access: Public -// Description: Sets the actual number of channels to indicate an -// image with no alpha channel, presumably after -// discovering that the alpha channel contains no -// meaningful pixels. -//////////////////////////////////////////////////////////////////// +/** + * Sets the actual number of channels to indicate an image with no alpha + * channel, presumably after discovering that the alpha channel contains no + * meaningful pixels. + */ void TextureProperties:: force_nonalpha() { nassertv(_got_num_channels && (_num_channels == 2 || _num_channels == 4)); @@ -174,12 +151,9 @@ force_nonalpha() { _effective_num_channels = _num_channels; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::uses_alpha -// Access: Public -// Description: Returns true if the texture uses an alpha channel, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the texture uses an alpha channel, false otherwise. + */ bool TextureProperties:: uses_alpha() const { switch (_format) { @@ -199,15 +173,11 @@ uses_alpha() const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_string -// Access: Public -// Description: Returns a string corresponding to the -// TextureProperties object. Each unique set of -// TextureProperties will generate a unique string. -// This is used to generate unique palette image -// filenames. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string corresponding to the TextureProperties object. Each + * unique set of TextureProperties will generate a unique string. This is + * used to generate unique palette image filenames. + */ string TextureProperties:: get_string() const { string result; @@ -227,12 +197,10 @@ get_string() const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::update_properties -// Access: Public -// Description: If the indicate TextureProperties structure is more -// specific than this one, updates this one. -//////////////////////////////////////////////////////////////////// +/** + * If the indicate TextureProperties structure is more specific than this one, + * updates this one. + */ void TextureProperties:: update_properties(const TextureProperties &other) { if (!_got_num_channels) { @@ -260,12 +228,10 @@ update_properties(const TextureProperties &other) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::fully_define -// Access: Public -// Description: If any properties remain unspecified, specify them -// now. Also reconcile conflicting information. -//////////////////////////////////////////////////////////////////// +/** + * If any properties remain unspecified, specify them now. Also reconcile + * conflicting information. + */ void TextureProperties:: fully_define() { if (!_got_num_channels || _force_format) { @@ -306,9 +272,9 @@ fully_define() { _effective_num_channels = _num_channels; - // Respect the _generic_format flag. If this is set, it means the - // user has indicated that we should strip off any bitcount-specific - // formats and replace them with the more generic equivalents. + // Respect the _generic_format flag. If this is set, it means the user has + // indicated that we should strip off any bitcount-specific formats and + // replace them with the more generic equivalents. if (_generic_format) { switch (_format) { case EggTexture::F_unspecified: @@ -340,8 +306,8 @@ fully_define() { } } - // Make sure the format reflects the number of channels, although we - // accept a format that ignores an alpha channel. + // Make sure the format reflects the number of channels, although we accept + // a format that ignores an alpha channel. if (!_force_format && !_keep_format) { switch (_num_channels) { case 1: @@ -353,8 +319,8 @@ fully_define() { case EggTexture::F_luminance: break; - // These formats suggest an alpha channel; they are quietly - // replaced with non-alpha equivalents. + // These formats suggest an alpha channel; they are quietly replaced + // with non-alpha equivalents. case EggTexture::F_luminance_alpha: case EggTexture::F_luminance_alphamask: _format = EggTexture::F_luminance; @@ -370,7 +336,7 @@ fully_define() { case EggTexture::F_luminance_alpha: case EggTexture::F_luminance_alphamask: break; - + // These formats implicitly reduce the number of channels to 1. case EggTexture::F_red: case EggTexture::F_green: @@ -393,8 +359,8 @@ fully_define() { case EggTexture::F_rgb332: break; - // These formats suggest an alpha channel; they are quietly - // replaced with non-alpha equivalents. + // These formats suggest an alpha channel; they are quietly replaced + // with non-alpha equivalents. case EggTexture::F_rgba8: _format = EggTexture::F_rgb8; break; @@ -485,12 +451,10 @@ fully_define() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::update_egg_tex -// Access: Public -// Description: Adjusts the texture properties of the indicated egg -// reference to match these properties. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the texture properties of the indicated egg reference to match + * these properties. + */ void TextureProperties:: update_egg_tex(EggTexture *egg_tex) const { egg_tex->set_format(_format); @@ -500,14 +464,11 @@ update_egg_tex(EggTexture *egg_tex) const { egg_tex->set_anisotropic_degree(_anisotropic_degree); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::egg_properties_match -// Access: Public -// Description: Returns true if all of the properties that are -// reflected directly in an egg file match between this -// TextureProperties object and the other, or false if -// any of them differ. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all of the properties that are reflected directly in an egg + * file match between this TextureProperties object and the other, or false if + * any of them differ. + */ bool TextureProperties:: egg_properties_match(const TextureProperties &other) const { return (_format == other._format && @@ -517,11 +478,9 @@ egg_properties_match(const TextureProperties &other) const { _anisotropic_degree == other._anisotropic_degree); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Ordering Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TextureProperties:: operator < (const TextureProperties &other) const { if (_format != other._format) { @@ -550,11 +509,9 @@ operator < (const TextureProperties &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Equality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TextureProperties:: operator == (const TextureProperties &other) const { return (_format == other._format && @@ -567,22 +524,17 @@ operator == (const TextureProperties &other) const { _alpha_type == other._alpha_type)); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::Nonequality Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool TextureProperties:: operator != (const TextureProperties &other) const { return !operator == (other); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_format_string -// Access: Private, Static -// Description: Returns a short string representing the given -// EggTexture format. -//////////////////////////////////////////////////////////////////// +/** + * Returns a short string representing the given EggTexture format. + */ string TextureProperties:: get_format_string(EggTexture::Format format) { switch (format) { @@ -647,33 +599,30 @@ get_format_string(EggTexture::Format format) { return "x"; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_filter_string -// Access: Private, Static -// Description: Returns a short string representing the given -// EggTexture filter type. -//////////////////////////////////////////////////////////////////// +/** + * Returns a short string representing the given EggTexture filter type. + */ string TextureProperties:: get_filter_string(EggTexture::FilterType filter_type) { switch (filter_type) { case EggTexture::FT_unspecified: return "u"; - + case EggTexture::FT_nearest: return "n"; - + case EggTexture::FT_linear: return "l"; - + case EggTexture::FT_nearest_mipmap_nearest: return "m1"; - + case EggTexture::FT_linear_mipmap_nearest: return "m2"; - + case EggTexture::FT_nearest_mipmap_linear: return "m3"; - + case EggTexture::FT_linear_mipmap_linear: return "m"; } @@ -681,11 +630,9 @@ get_filter_string(EggTexture::FilterType filter_type) { return "x"; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_anisotropic_degree_string -// Access: Private, Static -// Description: Returns a short string describing the anisotropic degree. -//////////////////////////////////////////////////////////////////// +/** + * Returns a short string describing the anisotropic degree. + */ string TextureProperties:: get_anisotropic_degree_string(int aniso_degree) { if (aniso_degree <= 1) { @@ -695,11 +642,9 @@ get_anisotropic_degree_string(int aniso_degree) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_quality_level_string -// Access: Private, Static -// Description: Returns a short string describing the quality level. -//////////////////////////////////////////////////////////////////// +/** + * Returns a short string describing the quality level. + */ string TextureProperties:: get_quality_level_string(EggTexture::QualityLevel quality_level) { switch (quality_level) { @@ -719,12 +664,10 @@ get_quality_level_string(EggTexture::QualityLevel quality_level) { return ""; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::get_type_string -// Access: Private, Static -// Description: Returns a short string representing whether the color -// and/or alpha type has been specified or not. -//////////////////////////////////////////////////////////////////// +/** + * Returns a short string representing whether the color and/or alpha type has + * been specified or not. + */ string TextureProperties:: get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) { if (color_type == (PNMFileType *)NULL) { @@ -736,12 +679,9 @@ get_type_string(PNMFileType *color_type, PNMFileType *alpha_type) { return "a"; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::union_format -// Access: Private, Static -// Description: Returns the EggTexture format which is the more -// specific of the two. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTexture format which is the more specific of the two. + */ EggTexture::Format TextureProperties:: union_format(EggTexture::Format a, EggTexture::Format b) { switch (a) { @@ -776,12 +716,9 @@ union_format(EggTexture::Format a, EggTexture::Format b) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::union_filter -// Access: Private, Static -// Description: Returns the EggTexture filter type which is the more -// specific of the two. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTexture filter type which is the more specific of the two. + */ EggTexture::FilterType TextureProperties:: union_filter(EggTexture::FilterType a, EggTexture::FilterType b) { if ((int)a < (int)b) { @@ -791,12 +728,9 @@ union_filter(EggTexture::FilterType a, EggTexture::FilterType b) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::union_quality_level -// Access: Private, Static -// Description: Returns the EggTexture quality level which is the -// more specific of the two. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTexture quality level which is the more specific of the two. + */ EggTexture::QualityLevel TextureProperties:: union_quality_level(EggTexture::QualityLevel a, EggTexture::QualityLevel b) { if ((int)a < (int)b) { @@ -806,25 +740,19 @@ union_quality_level(EggTexture::QualityLevel a, EggTexture::QualityLevel b) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void TextureProperties:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_TextureProperties); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void TextureProperties:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); @@ -843,15 +771,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { writer->write_pointer(datagram, _alpha_type); } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int TextureProperties:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int index = TypedWritable::complete_pointers(p_list, manager); @@ -869,14 +794,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return index; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::make_TextureProperties -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* TextureProperties:: make_TextureProperties(const FactoryParams ¶ms) { TextureProperties *me = new TextureProperties; @@ -888,13 +810,10 @@ make_TextureProperties(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: TextureProperties::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void TextureProperties:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/textureProperties.h b/pandatool/src/palettizer/textureProperties.h index 58928b10b4..cfd5fd36f8 100644 --- a/pandatool/src/palettizer/textureProperties.h +++ b/pandatool/src/palettizer/textureProperties.h @@ -1,16 +1,15 @@ -// Filename: textureProperties.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureProperties.h + * @author drose + * @date 2000-11-28 + */ #ifndef TEXTUREPROPERTIES_H #define TEXTUREPROPERTIES_H @@ -23,14 +22,11 @@ class PNMFileType; class FactoryParams; -//////////////////////////////////////////////////////////////////// -// Class : TextureProperties -// Description : This is the set of characteristics of a texture that, -// if different from another texture, prevent the two -// textures from sharing a PaletteImage. It includes -// properties such as mipmapping, number of channels, -// etc. -//////////////////////////////////////////////////////////////////// +/** + * This is the set of characteristics of a texture that, if different from + * another texture, prevent the two textures from sharing a PaletteImage. It + * includes properties such as mipmapping, number of channels, etc. + */ class TextureProperties : public TypedWritable { public: TextureProperties(); @@ -118,4 +114,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/textureReference.cxx b/pandatool/src/palettizer/textureReference.cxx index 1ee7a62d27..da6a2b626f 100644 --- a/pandatool/src/palettizer/textureReference.cxx +++ b/pandatool/src/palettizer/textureReference.cxx @@ -1,16 +1,15 @@ -// Filename: textureReference.cxx -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureReference.cxx + * @author drose + * @date 2000-11-29 + */ #include "textureReference.h" #include "textureImage.h" @@ -38,11 +37,9 @@ TypeHandle TextureReference::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureReference:: TextureReference() { _egg_file = (EggFile *)NULL; @@ -59,22 +56,17 @@ TextureReference() { _wrap_v = EggTexture::WM_unspecified; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureReference:: ~TextureReference() { clear_placement(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::from_egg -// Access: Public -// Description: Sets up the TextureReference using information -// extracted from an egg file. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the TextureReference using information extracted from an egg file. + */ void TextureReference:: from_egg(EggFile *egg_file, EggData *data, EggTexture *egg_tex) { _egg_file = egg_file; @@ -109,15 +101,15 @@ from_egg(EggFile *egg_file, EggData *data, EggTexture *egg_tex) { TextureImage *texture = pal->get_texture(name); if (texture->get_name() != name) { nout << "Texture name conflict: \"" << name - << "\" conflicts with existing texture named \"" + << "\" conflicts with existing texture named \"" << texture->get_name() << "\".\n"; - // Make this a hard error; refuse to do anything else until the - // user fixes it. Case conflicts can be very bad, especially if - // CVS is involved on a Windows machine. + // Make this a hard error; refuse to do anything else until the user fixes + // it. Case conflicts can be very bad, especially if CVS is involved on a + // Windows machine. exit(1); } - _source_texture = texture->get_source(filename, alpha_filename, + _source_texture = texture->get_source(filename, alpha_filename, alpha_file_channel); _source_texture->update_properties(_properties); @@ -142,17 +134,13 @@ from_egg(EggFile *egg_file, EggData *data, EggTexture *egg_tex) { _wrap_v = _egg_tex->determine_wrap_v(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::from_egg_quick -// Access: Public -// Description: Sets up the pointers within the TextureReference -// to the same egg file pointers indicated by the other -// TextureReference object, without changing any of the -// other internal data stored here regarding the egg -// structures. This is intended for use when we have -// already shown that the two TextureReferences describe -// equivalent data. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the pointers within the TextureReference to the same egg file + * pointers indicated by the other TextureReference object, without changing + * any of the other internal data stored here regarding the egg structures. + * This is intended for use when we have already shown that the two + * TextureReferences describe equivalent data. + */ void TextureReference:: from_egg_quick(const TextureReference &other) { nassertv(_tref_name == other._tref_name); @@ -161,27 +149,21 @@ from_egg_quick(const TextureReference &other) { _egg_data = other._egg_data; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::release_egg_data -// Access: Public -// Description: Called to indicate that the EggData previously passed -// to from_egg() is about to be deallocated, and all of -// its pointers should be cleared. -//////////////////////////////////////////////////////////////////// +/** + * Called to indicate that the EggData previously passed to from_egg() is + * about to be deallocated, and all of its pointers should be cleared. + */ void TextureReference:: release_egg_data() { _egg_tex = NULL; _egg_data = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::rebind_egg_data -// Access: Public -// Description: After an EggData has previously been released via -// release_egg_data(), this can be called to indicate -// that the egg file has been reloaded and we should -// assign the indicated pointers. -//////////////////////////////////////////////////////////////////// +/** + * After an EggData has previously been released via release_egg_data(), this + * can be called to indicate that the egg file has been reloaded and we should + * assign the indicated pointers. + */ void TextureReference:: rebind_egg_data(EggData *data, EggTexture *egg_tex) { nassertv(_tref_name == egg_tex->get_name()); @@ -189,128 +171,98 @@ rebind_egg_data(EggData *data, EggTexture *egg_tex) { _egg_tex = egg_tex; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_egg_file -// Access: Public -// Description: Returns the EggFile that references this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggFile that references this texture. + */ EggFile *TextureReference:: get_egg_file() const { return _egg_file; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_source -// Access: Public -// Description: Returns the SourceTextureImage that this object -// refers to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SourceTextureImage that this object refers to. + */ SourceTextureImage *TextureReference:: get_source() const { return _source_texture; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_texture -// Access: Public -// Description: Returns the TextureImage that this object refers to. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TextureImage that this object refers to. + */ TextureImage *TextureReference:: get_texture() const { nassertr(_source_texture != (SourceTextureImage *)NULL, (TextureImage *)NULL); return _source_texture->get_texture(); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_tref_name -// Access: Public -// Description: Returns the name of the EggTexture entry that -// references this texture. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the EggTexture entry that references this texture. + */ const string &TextureReference:: get_tref_name() const { return _tref_name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::operator < -// Access: Public -// Description: Defines an ordering of TextureReference pointers in -// alphabetical order by their tref name. -//////////////////////////////////////////////////////////////////// +/** + * Defines an ordering of TextureReference pointers in alphabetical order by + * their tref name. + */ bool TextureReference:: operator < (const TextureReference &other) const { return _tref_name < other._tref_name; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::has_uvs -// Access: Public -// Description: Returns true if this TextureReference actually uses -// the texture on geometry, with UV's and everything, or -// false otherwise. Strictly speaking, this should -// always return true. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this TextureReference actually uses the texture on + * geometry, with UV's and everything, or false otherwise. Strictly speaking, + * this should always return true. + */ bool TextureReference:: has_uvs() const { return _any_uvs; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_min_uv -// Access: Public -// Description: Returns the minimum UV coordinate in use for the -// texture by this reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minimum UV coordinate in use for the texture by this reference. + */ const LTexCoordd &TextureReference:: get_min_uv() const { nassertr(_any_uvs, _min_uv); return _min_uv; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_max_uv -// Access: Public -// Description: Returns the maximum UV coordinate in use for the -// texture by this reference. -//////////////////////////////////////////////////////////////////// +/** + * Returns the maximum UV coordinate in use for the texture by this reference. + */ const LTexCoordd &TextureReference:: get_max_uv() const { nassertr(_any_uvs, _max_uv); return _max_uv; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_wrap_u -// Access: Public -// Description: Returns the specification for the wrapping in the U -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specification for the wrapping in the U direction. + */ EggTexture::WrapMode TextureReference:: get_wrap_u() const { return _wrap_u; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_wrap_v -// Access: Public -// Description: Returns the specification for the wrapping in the V -// direction. -//////////////////////////////////////////////////////////////////// +/** + * Returns the specification for the wrapping in the V direction. + */ EggTexture::WrapMode TextureReference:: get_wrap_v() const { return _wrap_v; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::is_equivalent -// Access: Public -// Description: Returns true if all essential properties of this -// TextureReference are the same as that of the other, -// or false if any of them differ. This is useful when -// reading a new egg file and comparing its references -// to its previously-defined references. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if all essential properties of this TextureReference are the + * same as that of the other, or false if any of them differ. This is useful + * when reading a new egg file and comparing its references to its previously- + * defined references. + */ bool TextureReference:: is_equivalent(const TextureReference &other) const { if (_source_texture != other._source_texture) { @@ -344,13 +296,10 @@ is_equivalent(const TextureReference &other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::set_placement -// Access: Public -// Description: Sets the particular TexturePlacement that is -// appropriate for this egg file. This is called by -// EggFile::choose_placements(). -//////////////////////////////////////////////////////////////////// +/** + * Sets the particular TexturePlacement that is appropriate for this egg file. + * This is called by EggFile::choose_placements(). + */ void TextureReference:: set_placement(TexturePlacement *placement) { if (_placement != placement) { @@ -366,35 +315,27 @@ set_placement(TexturePlacement *placement) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::clear_placement -// Access: Public -// Description: Removes any reference to a TexturePlacement. -//////////////////////////////////////////////////////////////////// +/** + * Removes any reference to a TexturePlacement. + */ void TextureReference:: clear_placement() { set_placement((TexturePlacement *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_placement -// Access: Public -// Description: Returns the particular TexturePlacement that is -// appropriate for this egg file. This will not be -// filled in until EggFile::choose_placements() has been -// called. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular TexturePlacement that is appropriate for this egg + * file. This will not be filled in until EggFile::choose_placements() has + * been called. + */ TexturePlacement *TextureReference:: get_placement() const { return _placement; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::mark_egg_stale -// Access: Public -// Description: Marks the egg file that shares this reference as -// stale. -//////////////////////////////////////////////////////////////////// +/** + * Marks the egg file that shares this reference as stale. + */ void TextureReference:: mark_egg_stale() { if (_egg_file != (EggFile *)NULL) { @@ -402,42 +343,37 @@ mark_egg_stale() { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::update_egg -// Access: Public -// Description: Updates the egg file with all the relevant -// information to reference the texture in its new home, -// wherever that might be. -//////////////////////////////////////////////////////////////////// +/** + * Updates the egg file with all the relevant information to reference the + * texture in its new home, wherever that might be. + */ void TextureReference:: update_egg() { if (_egg_tex == (EggTexture *)NULL) { - // Not much we can do if we don't have an actual egg file to - // reference. + // Not much we can do if we don't have an actual egg file to reference. return; } if (_placement == (TexturePlacement *)NULL) { - // Nor if we don't have an actual placement yet. This is possible - // if the egg was assigned to the "null" group, and the texture - // hasn't been re-assigned yet. + // Nor if we don't have an actual placement yet. This is possible if the + // egg was assigned to the "null" group, and the texture hasn't been re- + // assigned yet. return; } TextureImage *texture = get_texture(); if (texture != (TextureImage *)NULL) { - // Make sure the alpha mode is set according to what the texture - // image wants. - if (texture->has_num_channels() && + // Make sure the alpha mode is set according to what the texture image + // wants. + if (texture->has_num_channels() && !_egg_tex->has_alpha_channel(texture->get_num_channels())) { - // The egg file doesn't want to use the alpha on the texture; - // leave it unspecified so the egg loader can figure out whether - // to enable alpha or not based on the object color. + // The egg file doesn't want to use the alpha on the texture; leave it + // unspecified so the egg loader can figure out whether to enable alpha + // or not based on the object color. _egg_tex->set_alpha_mode(EggRenderMode::AM_unspecified); } else { - // The egg file does want alpha, so get the alpha mode from the - // texture. + // The egg file does want alpha, so get the alpha mode from the texture. EggRenderMode::AlphaMode am = texture->get_alpha_mode(); if (am != EggRenderMode::AM_unspecified) { _egg_tex->set_alpha_mode(am); @@ -453,41 +389,39 @@ update_egg() { } } - // We check for an OmitReason of OR_none, rather than asking - // is_placed(), because in this case we don't want to consider an - // OR_solitary texture as having been placed. + // We check for an OmitReason of OR_none, rather than asking is_placed(), + // because in this case we don't want to consider an OR_solitary texture as + // having been placed. if (_placement->get_omit_reason() == OR_unknown) { - // The texture doesn't even exist. We can't update the egg to - // point to any meaningful path; just leave it pointing to the - // source texture's basename. Maybe it will be found along the - // texture path later. + // The texture doesn't even exist. We can't update the egg to point to + // any meaningful path; just leave it pointing to the source texture's + // basename. Maybe it will be found along the texture path later. Filename orig_filename = _egg_tex->get_filename(); texture->update_egg_tex(_egg_tex); _egg_tex->set_filename(orig_filename.get_basename()); return; } if (_placement->get_omit_reason() != OR_none) { - // The texture exists but is not on a palette. This is the easy - // case; we simply have to update the texture reference to the new - // texture location. + // The texture exists but is not on a palette. This is the easy case; we + // simply have to update the texture reference to the new texture + // location. DestTextureImage *dest = _placement->get_dest(); nassertv(dest != (DestTextureImage *)NULL); dest->update_egg_tex(_egg_tex); return; } - // The texture *does* appear on a palette. This means we need to - // not only update the texture reference, but also adjust the UV's. - // In most cases, we can do this by simply applying a texture matrix - // to the reference. + // The texture *does* appear on a palette. This means we need to not only + // update the texture reference, but also adjust the UV's. In most cases, + // we can do this by simply applying a texture matrix to the reference. PaletteImage *image = _placement->get_image(); nassertv(image != (PaletteImage *)NULL); image->update_egg_tex(_egg_tex); - // Palette images never wrap, so the wrap mode doesn't matter. We - // let this default to unspecified, which means the images will - // wrap by default, which is the fastest mode for tinydisplay anyway. + // Palette images never wrap, so the wrap mode doesn't matter. We let this + // default to unspecified, which means the images will wrap by default, + // which is the fastest mode for tinydisplay anyway. _egg_tex->set_wrap_mode(EggTexture::WM_unspecified); _egg_tex->set_wrap_u(EggTexture::WM_unspecified); _egg_tex->set_wrap_v(EggTexture::WM_unspecified); @@ -495,46 +429,39 @@ update_egg() { LMatrix3d new_tex_mat; _placement->compute_tex_matrix(new_tex_mat); - // Compose the new texture matrix with whatever matrix was already - // there, if any. + // Compose the new texture matrix with whatever matrix was already there, if + // any. _egg_tex->set_transform2d(_tex_mat * new_tex_mat); - // Finally, go back and actually adjust the UV's to match what we - // claimed they could be. + // Finally, go back and actually adjust the UV's to match what we claimed + // they could be. if (_egg_tex->get_tex_gen() == EggTexture::TG_unspecified) { update_uv_range(_egg_data, pal->_remap_uv); } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::apply_properties_to_source -// Access: Public -// Description: Applies the texture properties as read from the egg -// file to the source image's properties. This updates -// the source image with the now-known properties -// indicated with in the tref block of the egg file. -//////////////////////////////////////////////////////////////////// +/** + * Applies the texture properties as read from the egg file to the source + * image's properties. This updates the source image with the now-known + * properties indicated with in the tref block of the egg file. + */ void TextureReference:: apply_properties_to_source() { nassertv(_source_texture != (SourceTextureImage *)NULL); _source_texture->update_properties(_properties); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureReference:: output(ostream &out) const { out << *_source_texture; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextureReference:: write(ostream &out, int indent_level) const { indent(out, indent_level) @@ -545,8 +472,8 @@ write(ostream &out, int indent_level) const { } if (_any_uvs) { - // Compute the fraction of the image that is covered by the UV's - // minmax rectangle. + // Compute the fraction of the image that is covered by the UV's minmax + // rectangle. LTexCoordd box = _max_uv - _min_uv; double area = box[0] * box[1]; @@ -586,27 +513,21 @@ write(ostream &out, int indent_level) const { } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_uv_range -// Access: Private -// Description: Checks the geometry in the egg file to see what range -// of UV's are requested for this particular texture -// reference. -// -// If pal->_remap_uv is not RU_never, this will also -// attempt to remap the UV's found so that the midpoint -// lies in the unit square (0,0) - (1,1), in the hopes -// of maximizing overlap of UV coordinates between -// different polygons. However, the hypothetical -// translations are not actually applied to the egg file -// at this point (because we might decide not to place -// the texture in a palette); they will actually be -// applied when update_uv_range(), below, is called -// later. -// -// The return value is true if the search should -// continue, or false if it should abort prematurely. -//////////////////////////////////////////////////////////////////// +/** + * Checks the geometry in the egg file to see what range of UV's are requested + * for this particular texture reference. + * + * If pal->_remap_uv is not RU_never, this will also attempt to remap the UV's + * found so that the midpoint lies in the unit square (0,0) - (1,1), in the + * hopes of maximizing overlap of UV coordinates between different polygons. + * However, the hypothetical translations are not actually applied to the egg + * file at this point (because we might decide not to place the texture in a + * palette); they will actually be applied when update_uv_range(), below, is + * called later. + * + * The return value is true if the search should continue, or false if it + * should abort prematurely. + */ bool TextureReference:: get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { if (group->is_of_type(EggGroup::get_class_type())) { @@ -614,8 +535,7 @@ get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { DCAST_INTO_R(egg_group, group, false); if (egg_group->get_dart_type() != EggGroup::DT_none) { - // If it's a character, we might change the kind of remapping we - // do. + // If it's a character, we might change the kind of remapping we do. remap = pal->_remap_char_uv; } } @@ -629,44 +549,40 @@ get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { if (child->is_of_type(EggNurbsSurface::get_class_type())) { EggNurbsSurface *nurbs = DCAST(EggNurbsSurface, child); if (nurbs->has_texture(_egg_tex)) { - // Here's a NURBS surface that references the texture. Unlike - // other kinds of geometries, NURBS don't store UV's; they're - // implicit in the surface. NURBS UV's will always run in the - // range (0, 0) - (1, 1). However, we do need to apply the - // texture matrix. + // Here's a NURBS surface that references the texture. Unlike other + // kinds of geometries, NURBS don't store UV's; they're implicit in + // the surface. NURBS UV's will always run in the range (0, 0) - (1, + // 1). However, we do need to apply the texture matrix. - // We also don't count the NURBS surfaces in with the group's - // UV's, because we can't adjust the UV's on a NURBS, so - // counting them up would be misleading (the reason we count - // up the group UV's is so we can consider adjusting them - // later). Instead, we just accumulate the NURBS UV's - // directly into our total. + // We also don't count the NURBS surfaces in with the group's UV's, + // because we can't adjust the UV's on a NURBS, so counting them up + // would be misleading (the reason we count up the group UV's is so we + // can consider adjusting them later). Instead, we just accumulate + // the NURBS UV's directly into our total. collect_nominal_uv_range(); } } else if (child->is_of_type(EggPrimitive::get_class_type())) { EggPrimitive *geom = DCAST(EggPrimitive, child); if (geom->has_texture(_egg_tex)) { - // Here's a piece of geometry that references this texture. - // Walk through its vertices and get its UV's. + // Here's a piece of geometry that references this texture. Walk + // through its vertices and get its UV's. if (_egg_tex->get_tex_gen() != EggTexture::TG_unspecified) { - // If the texture has a TexGen mode, we don't check the UV - // range on the model, since that doesn't matter. Instead, - // we assume the texture is used in the range (0, 0) - (1, - // 1), which will be true for a sphere map, although the - // effective range is a little less clear for the - // TG_world_position and similar modes. + // If the texture has a TexGen mode, we don't check the UV range on + // the model, since that doesn't matter. Instead, we assume the + // texture is used in the range (0, 0) - (1, 1), which will be true + // for a sphere map, although the effective range is a little less + // clear for the TG_world_position and similar modes. collect_nominal_uv_range(); - // In fact, now we can return, having found at least one - // model that references the texture; there's no need to - // search further. + // In fact, now we can return, having found at least one model that + // references the texture; there's no need to search further. return false; - + } else { LTexCoordd geom_min_uv, geom_max_uv; - + if (get_geom_uvs(geom, geom_min_uv, geom_max_uv)) { if (remap == Palettizer::RU_poly) { LVector2d trans = translate_uv(geom_min_uv, geom_max_uv); @@ -678,7 +594,7 @@ get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { } } } - + } else if (child->is_of_type(EggGroupNode::get_class_type())) { EggGroupNode *cg = DCAST(EggGroupNode, child); if (!get_uv_range(cg, remap)) { @@ -699,12 +615,10 @@ get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::update_uv_range -// Access: Private -// Description: Actually applies the UV translates that were assumed -// in the previous call to get_uv_range(). -//////////////////////////////////////////////////////////////////// +/** + * Actually applies the UV translates that were assumed in the previous call + * to get_uv_range(). + */ void TextureReference:: update_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { if (group->is_of_type(EggGroup::get_class_type())) { @@ -712,8 +626,7 @@ update_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { DCAST_INTO_V(egg_group, group); if (egg_group->get_dart_type() != EggGroup::DT_none) { - // If it's a character, we might change the kind of remapping we - // do. + // If it's a character, we might change the kind of remapping we do. remap = pal->_remap_char_uv; } } @@ -725,8 +638,8 @@ update_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { for (ci = group->begin(); ci != group->end(); ci++) { EggNode *child = (*ci); if (child->is_of_type(EggNurbsSurface::get_class_type())) { - // We do nothing at this point for a Nurbs. Nothing we can do - // about these things. + // We do nothing at this point for a Nurbs. Nothing we can do about + // these things. } else if (child->is_of_type(EggPrimitive::get_class_type())) { if (remap != Palettizer::RU_never) { @@ -772,13 +685,10 @@ update_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::get_geom_uvs -// Access: Private -// Description: Determines the minimum and maximum UV range for a -// particular primitive. Returns true if it has any -// UV's, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Determines the minimum and maximum UV range for a particular primitive. + * Returns true if it has any UV's, false otherwise. + */ bool TextureReference:: get_geom_uvs(EggPrimitive *geom, LTexCoordd &geom_min_uv, LTexCoordd &geom_max_uv) { @@ -797,12 +707,9 @@ get_geom_uvs(EggPrimitive *geom, return geom_any_uvs; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::translate_geom_uvs -// Access: Private -// Description: Applies the indicated translation to each UV in the -// primitive. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated translation to each UV in the primitive. + */ void TextureReference:: translate_geom_uvs(EggPrimitive *geom, const LTexCoordd &trans) const { string uv_name = _egg_tex->get_uv_name(); @@ -824,12 +731,10 @@ translate_geom_uvs(EggPrimitive *geom, const LTexCoordd &trans) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::collect_nominal_uv_range -// Access: Private -// Description: Updates _any_uvs, _min_uv, and _max_uv with the range -// (0, 0) - (1, 1), adjusted by the texture matrix. -//////////////////////////////////////////////////////////////////// +/** + * Updates _any_uvs, _min_uv, and _max_uv with the range (0, 0) - (1, 1), + * adjusted by the texture matrix. + */ void TextureReference:: collect_nominal_uv_range() { static const int num_nurbs_uvs = 4; @@ -839,19 +744,17 @@ collect_nominal_uv_range() { LTexCoordd(1.0, 1.0), LTexCoordd(1.0, 0.0) }; - + for (int i = 0; i < num_nurbs_uvs; i++) { LTexCoordd uv = nurbs_uvs[i] * _tex_mat; collect_uv(_any_uvs, _min_uv, _max_uv, uv, uv); } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::collect_uv -// Access: Private, Static -// Description: Updates any_uvs, min_uv, and max_uv with the -// indicated min and max UV's already determined. -//////////////////////////////////////////////////////////////////// +/** + * Updates any_uvs, min_uv, and max_uv with the indicated min and max UV's + * already determined. + */ void TextureReference:: collect_uv(bool &any_uvs, LTexCoordd &min_uv, LTexCoordd &max_uv, const LTexCoordd &got_min_uv, const LTexCoordd &got_max_uv) { @@ -868,45 +771,35 @@ collect_uv(bool &any_uvs, LTexCoordd &min_uv, LTexCoordd &max_uv, } } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::translate_uv -// Access: Private, Static -// Description: Returns the needed adjustment to translate the given -// bounding box so that its center lies in the unit -// square (0,0) - (1,1). -//////////////////////////////////////////////////////////////////// +/** + * Returns the needed adjustment to translate the given bounding box so that + * its center lies in the unit square (0,0) - (1,1). + */ LVector2d TextureReference:: translate_uv(const LTexCoordd &min_uv, const LTexCoordd &max_uv) { LTexCoordd center = (min_uv + max_uv) / 2; return LVector2d(-floor(center[0]), -floor(center[1])); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Registers the current object as something that can be read from a Bam file. + */ void TextureReference:: register_with_read_factory() { BamReader::get_factory()-> register_factory(get_class_type(), make_TextureReference); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::write_datagram -// Access: Public, Virtual -// Description: Fills the indicated datagram up with a binary -// representation of the current object, in preparation -// for writing to a Bam file. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated datagram up with a binary representation of the current + * object, in preparation for writing to a Bam file. + */ void TextureReference:: write_datagram(BamWriter *writer, Datagram &datagram) { TypedWritable::write_datagram(writer, datagram); writer->write_pointer(datagram, _egg_file); - // We don't write _egg_tex or _egg_data; that's specific to the - // session. + // We don't write _egg_tex or _egg_data; that's specific to the session. datagram.add_string(_tref_name); @@ -927,15 +820,12 @@ write_datagram(BamWriter *writer, Datagram &datagram) { _properties.write_datagram(writer, datagram); } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::complete_pointers -// Access: Public, Virtual -// Description: Called after the object is otherwise completely read -// from a Bam file, this function's job is to store the -// pointers that were retrieved from the Bam file for -// each pointer object written. The return value is the -// number of pointers processed from the list. -//////////////////////////////////////////////////////////////////// +/** + * Called after the object is otherwise completely read from a Bam file, this + * function's job is to store the pointers that were retrieved from the Bam + * file for each pointer object written. The return value is the number of + * pointers processed from the list. + */ int TextureReference:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = TypedWritable::complete_pointers(p_list, manager); @@ -960,14 +850,11 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { return pi; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::make_TextureReference -// Access: Protected -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -//////////////////////////////////////////////////////////////////// +/** + * This method is called by the BamReader when an object of this type is + * encountered in a Bam file; it should allocate and return a new object with + * all the data read. + */ TypedWritable* TextureReference:: make_TextureReference(const FactoryParams ¶ms) { TextureReference *me = new TextureReference; @@ -979,13 +866,10 @@ make_TextureReference(const FactoryParams ¶ms) { return me; } -//////////////////////////////////////////////////////////////////// -// Function: TextureReference::fillin -// Access: Protected -// Description: Reads the binary data from the given datagram -// iterator, which was written by a previous call to -// write_datagram(). -//////////////////////////////////////////////////////////////////// +/** + * Reads the binary data from the given datagram iterator, which was written + * by a previous call to write_datagram(). + */ void TextureReference:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); diff --git a/pandatool/src/palettizer/textureReference.h b/pandatool/src/palettizer/textureReference.h index 3e6d3905c9..aa555263b9 100644 --- a/pandatool/src/palettizer/textureReference.h +++ b/pandatool/src/palettizer/textureReference.h @@ -1,16 +1,15 @@ -// Filename: textureReference.h -// Created by: drose (28Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureReference.h + * @author drose + * @date 2000-11-28 + */ #ifndef TEXTUREREFERENCE_H #define TEXTUREREFERENCE_H @@ -33,13 +32,11 @@ class EggGroupNode; class EggPrimitive; class TexturePlacement; -//////////////////////////////////////////////////////////////////// -// Class : TextureReference -// Description : This is the particular reference of a texture -// filename by an egg file. It also includes -// information about the way in which the egg file uses -// the texture; e.g. does it repeat. -//////////////////////////////////////////////////////////////////// +/** + * This is the particular reference of a texture filename by an egg file. It + * also includes information about the way in which the egg file uses the + * texture; e.g. does it repeat. + */ class TextureReference : public TypedWritable { public: TextureReference(); @@ -144,5 +141,3 @@ operator << (ostream &out, const TextureReference &ref) { } #endif - - diff --git a/pandatool/src/palettizer/textureRequest.cxx b/pandatool/src/palettizer/textureRequest.cxx index bc4244530c..15756c0075 100644 --- a/pandatool/src/palettizer/textureRequest.cxx +++ b/pandatool/src/palettizer/textureRequest.cxx @@ -1,25 +1,22 @@ -// Filename: textureRequest.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureRequest.cxx + * @author drose + * @date 2000-11-30 + */ #include "textureRequest.h" #include "palettizer.h" -//////////////////////////////////////////////////////////////////// -// Function: TextureRequest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextureRequest:: TextureRequest() { _got_size = false; @@ -42,12 +39,9 @@ TextureRequest() { _coverage_threshold = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: TextureRequest::pre_txa_file -// Access: Public -// Description: Sets some state up that must be set prior to reading -// the .txa file. -//////////////////////////////////////////////////////////////////// +/** + * Sets some state up that must be set prior to reading the .txa file. + */ void TextureRequest:: pre_txa_file() { _margin = pal->_margin; diff --git a/pandatool/src/palettizer/textureRequest.h b/pandatool/src/palettizer/textureRequest.h index ce8e1a8608..ab9e0b1e19 100644 --- a/pandatool/src/palettizer/textureRequest.h +++ b/pandatool/src/palettizer/textureRequest.h @@ -1,16 +1,15 @@ -// Filename: textureRequest.h -// Created by: drose (29Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textureRequest.h + * @author drose + * @date 2000-11-29 + */ #ifndef TEXTUREREQUEST_H #define TEXTUREREQUEST_H @@ -22,12 +21,10 @@ #include "eggTexture.h" #include "eggRenderMode.h" -//////////////////////////////////////////////////////////////////// -// Class : TextureRequest -// Description : These are the things that a user might explicitly -// request to adjust on a texture via a line in the .txa -// file. -//////////////////////////////////////////////////////////////////// +/** + * These are the things that a user might explicitly request to adjust on a + * texture via a line in the .txa file. + */ class TextureRequest { public: TextureRequest(); @@ -55,4 +52,3 @@ public: }; #endif - diff --git a/pandatool/src/palettizer/txaFile.cxx b/pandatool/src/palettizer/txaFile.cxx index 79ef1b9330..7aff6ad221 100644 --- a/pandatool/src/palettizer/txaFile.cxx +++ b/pandatool/src/palettizer/txaFile.cxx @@ -1,16 +1,15 @@ -// Filename: txaFile.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaFile.cxx + * @author drose + * @date 2000-11-30 + */ #include "txaFile.h" #include "pal_string_utils.h" @@ -21,21 +20,17 @@ #include "pnotify.h" #include "pnmFileTypeRegistry.h" -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TxaFile:: TxaFile() { } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::read -// Access: Public -// Description: Reads the indicated stream, and returns true -// if successful, or false if there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated stream, and returns true if successful, or false if + * there is an error. + */ bool TxaFile:: read(istream &in, const string &filename) { string line; @@ -124,15 +119,12 @@ read(istream &in, const string &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::match_egg -// Access: Public -// Description: Searches for a matching line in the .txa file for the -// given egg file and applies its specifications. If a -// match is found, returns true; otherwise, returns -// false. Also returns false if all the matching lines -// for the egg file include the keyword "cont". -//////////////////////////////////////////////////////////////////// +/** + * Searches for a matching line in the .txa file for the given egg file and + * applies its specifications. If a match is found, returns true; otherwise, + * returns false. Also returns false if all the matching lines for the egg + * file include the keyword "cont". + */ bool TxaFile:: match_egg(EggFile *egg_file) const { Lines::const_iterator li; @@ -145,15 +137,12 @@ match_egg(EggFile *egg_file) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::match_texture -// Access: Public -// Description: Searches for a matching line in the .txa file for the -// given texture and applies its specifications. If a -// match is found, returns true; otherwise, returns -// false. Also returns false if all the matching lines -// for the texture include the keyword "cont". -//////////////////////////////////////////////////////////////////// +/** + * Searches for a matching line in the .txa file for the given texture and + * applies its specifications. If a match is found, returns true; otherwise, + * returns false. Also returns false if all the matching lines for the + * texture include the keyword "cont". + */ bool TxaFile:: match_texture(TextureImage *texture) const { Lines::const_iterator li; @@ -166,13 +155,10 @@ match_texture(TextureImage *texture) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::write -// Access: Public -// Description: Outputs a representation of the lines that were read -// in to the indicated output stream. This is primarily -// useful for debugging. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a representation of the lines that were read in to the indicated + * output stream. This is primarily useful for debugging. + */ void TxaFile:: write(ostream &out) const { Lines::const_iterator li; @@ -181,14 +167,11 @@ write(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::get_line_or_semicolon -// Access: Private, Static -// Description: Reads the next line, or the next semicolon-delimited -// phrase, from the indicated input stream. Returns -// the character that marks the end of the line, or EOF -// if the end of file has been reached. -//////////////////////////////////////////////////////////////////// +/** + * Reads the next line, or the next semicolon-delimited phrase, from the + * indicated input stream. Returns the character that marks the end of the + * line, or EOF if the end of file has been reached. + */ int TxaFile:: get_line_or_semicolon(istream &in, string &line) { line = string(); @@ -197,8 +180,7 @@ get_line_or_semicolon(istream &in, string &line) { while (ch != EOF && ch != '\n' && ch != semicolon) { if (ch == '#') { - // We don't consider a semicolon within a comment to be a line - // break. + // We don't consider a semicolon within a comment to be a line break. semicolon = EOF; } line += ch; @@ -208,13 +190,10 @@ get_line_or_semicolon(istream &in, string &line) { return ch; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_group_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":group" and indicates the relationships -// between one or more groups. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":group" and + * indicates the relationships between one or more groups. + */ bool TxaFile:: parse_group_line(const vector_string &words) { vector_string::const_iterator wi; @@ -300,13 +279,10 @@ parse_group_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_palette_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":palette" and indicates the appropriate size -// for the palette images. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":palette" and + * indicates the appropriate size for the palette images. + */ bool TxaFile:: parse_palette_line(const vector_string &words) { if (words.size() != 3) { @@ -330,13 +306,10 @@ parse_palette_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_margin_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":margin" and indicates the default margin -// size. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":margin" and + * indicates the default margin size. + */ bool TxaFile:: parse_margin_line(const vector_string &words) { if (words.size() != 2) { @@ -358,13 +331,10 @@ parse_margin_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_background_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":background" and indicates the palette -// background color. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":background" + * and indicates the palette background color. + */ bool TxaFile:: parse_background_line(const vector_string &words) { if (words.size() != 5) { @@ -386,13 +356,10 @@ parse_background_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_coverage_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":coverage" and indicates the default -// coverage threshold. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":coverage" + * and indicates the default coverage threshold. + */ bool TxaFile:: parse_coverage_line(const vector_string &words) { if (words.size() != 2) { @@ -415,13 +382,11 @@ parse_coverage_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_powertwo_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":powertwo" and indicates whether textures -// should by default be forced to a power of two. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":powertwo" + * and indicates whether textures should by default be forced to a power of + * two. + */ bool TxaFile:: parse_powertwo_line(const vector_string &words) { if (words.size() != 2) { @@ -446,13 +411,11 @@ parse_powertwo_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_imagetype_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":imagetype" and indicates the default image -// file type to convert palettes and textures to. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":imagetype" + * and indicates the default image file type to convert palettes and textures + * to. + */ bool TxaFile:: parse_imagetype_line(const vector_string &words) { if (words.size() != 2) { @@ -470,14 +433,11 @@ parse_imagetype_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_shadowtype_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":shadowtype" and indicates the image file -// type to convert working copies of the palette images -// to. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":shadowtype" + * and indicates the image file type to convert working copies of the palette + * images to. + */ bool TxaFile:: parse_shadowtype_line(const vector_string &words) { if (words.size() != 2) { @@ -496,13 +456,10 @@ parse_shadowtype_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_round_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":round" and indicates how or whether to -// round up UV minmax boxes. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":round" and + * indicates how or whether to round up UV minmax boxes. + */ bool TxaFile:: parse_round_line(const vector_string &words) { if (words.size() == 2) { @@ -538,13 +495,11 @@ parse_round_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_remap_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":remap" and indicates how or whether to -// remap UV coordinates in egg files to the unit box. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":remap" and + * indicates how or whether to remap UV coordinates in egg files to the unit + * box. + */ bool TxaFile:: parse_remap_line(const vector_string &words) { int i = 1; @@ -581,15 +536,12 @@ parse_remap_line(const vector_string &words) { } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_cutout_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":cutout" and indicates how to handle -// alpha-cutout textures: those textures that appear to -// be mostly solid parts and invisible parts, with a -// thin border of antialiased alpha along the boundary. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":cutout" and + * indicates how to handle alpha-cutout textures: those textures that appear + * to be mostly solid parts and invisible parts, with a thin border of + * antialiased alpha along the boundary. + */ bool TxaFile:: parse_cutout_line(const vector_string &words) { if (words.size() < 2 || words.size() > 3) { @@ -613,13 +565,10 @@ parse_cutout_line(const vector_string &words) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaFile::parse_textureswap_line -// Access: Private -// Description: Handles the line in a .txa file that begins with the -// keyword ":textureswap" and indicates the relationships -// between textures to be swapped. -//////////////////////////////////////////////////////////////////// +/** + * Handles the line in a .txa file that begins with the keyword ":textureswap" + * and indicates the relationships between textures to be swapped. + */ bool TxaFile:: parse_textureswap_line(const vector_string &words) { vector_string::const_iterator wi; @@ -634,14 +583,14 @@ parse_textureswap_line(const vector_string &words) { string sourceTextureName = (*wi); ++wi; - //vector_string swapTextures; - //copy(words.begin(), words.end(), swapTextures); - //group->add_texture_swap_info(sourceTextureName, swapTextures); + // vector_string swapTextures; copy(words.begin(), words.end(), + // swapTextures); group->add_texture_swap_info(sourceTextureName, + // swapTextures); size_t dot = sourceTextureName.rfind('.'); if (dot != string::npos) { sourceTextureName = sourceTextureName.substr(0, dot); } group->add_texture_swap_info(sourceTextureName, words); - + return true; } diff --git a/pandatool/src/palettizer/txaFile.h b/pandatool/src/palettizer/txaFile.h index 241309740d..507e0ac21a 100644 --- a/pandatool/src/palettizer/txaFile.h +++ b/pandatool/src/palettizer/txaFile.h @@ -1,16 +1,15 @@ -// Filename: txaFile.h -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaFile.h + * @author drose + * @date 2000-11-30 + */ #ifndef TXAFILE_H #define TXAFILE_H @@ -24,12 +23,10 @@ #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : TxaFile -// Description : This represents the .txa file (usually textures.txa) -// that contains the user instructions for resizing, -// grouping, etc. the various textures. -//////////////////////////////////////////////////////////////////// +/** + * This represents the .txa file (usually textures.txa) that contains the user + * instructions for resizing, grouping, etc. the various textures. + */ class TxaFile { public: TxaFile(); @@ -62,4 +59,3 @@ private: }; #endif - diff --git a/pandatool/src/palettizer/txaLine.cxx b/pandatool/src/palettizer/txaLine.cxx index 4048742113..0d1c655658 100644 --- a/pandatool/src/palettizer/txaLine.cxx +++ b/pandatool/src/palettizer/txaLine.cxx @@ -1,16 +1,15 @@ -// Filename: txaLine.cxx -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaLine.cxx + * @author drose + * @date 2000-11-30 + */ #include "txaLine.h" #include "pal_string_utils.h" @@ -23,11 +22,9 @@ #include "pnotify.h" #include "pnmFileType.h" -//////////////////////////////////////////////////////////////////// -// Function: TxaLine::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TxaLine:: TxaLine() { _size_type = ST_none; @@ -52,13 +49,10 @@ TxaLine() { _alpha_type = (PNMFileType *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: TxaLine::parse -// Access: Public -// Description: Accepts a string that defines a line of the .txa file -// and parses it into its constinuent parts. Returns -// true if successful, false on error. -//////////////////////////////////////////////////////////////////// +/** + * Accepts a string that defines a line of the .txa file and parses it into + * its constinuent parts. Returns true if successful, false on error. + */ bool TxaLine:: parse(const string &line) { size_t colon = line.find(':'); @@ -67,8 +61,8 @@ parse(const string &line) { return false; } - // Chop up the first part of the string (preceding the colon) into - // its individual words. These are patterns to match. + // Chop up the first part of the string (preceding the colon) into its + // individual words. These are patterns to match. vector_string words; extract_words(line.substr(0, colon), words); @@ -76,19 +70,18 @@ parse(const string &line) { for (wi = words.begin(); wi != words.end(); ++wi) { string word = (*wi); - // If the pattern ends in the string ".egg", and only if it ends - // in this string, it is deemed an egg pattern and will only be - // tested against egg files. If it ends in anything else, it is - // deemed a texture pattern and will only be tested against - // textures. + // If the pattern ends in the string ".egg", and only if it ends in this + // string, it is deemed an egg pattern and will only be tested against egg + // files. If it ends in anything else, it is deemed a texture pattern and + // will only be tested against textures. if (word.length() > 4 && word.substr(word.length() - 4) == ".egg") { GlobPattern pattern(word); pattern.set_case_sensitive(false); _egg_patterns.push_back(pattern); } else { - // However, the filename extension, if any, is stripped off - // because the texture key names nowadays don't include them. + // However, the filename extension, if any, is stripped off because the + // texture key names nowadays don't include them. size_t dot = word.rfind('.'); if (dot != string::npos) { word = word.substr(0, dot); @@ -167,8 +160,8 @@ parse(const string &line) { } } else { - // The word does not begin with a digit; therefore it's either a - // keyword or an image file type request. + // The word does not begin with a digit; therefore it's either a keyword + // or an image file type request. if (word == "omit") { _keywords.push_back(KW_omit); @@ -215,7 +208,8 @@ parse(const string &line) { return false; } if ((_aniso_degree < 2) || (_aniso_degree > 16)) { - // make it an error to specific degree 0 or 1, which means no anisotropy so it's probably an input mistake + // make it an error to specific degree 0 or 1, which means no + // anisotropy so it's probably an input mistake nout << "Invalid anistropic degree (range is 2-16): " << _aniso_degree << "\n"; return false; } @@ -241,8 +235,8 @@ parse(const string &line) { _got_coverage_threshold = true; } else if (word.substr(0, 6) == "force-") { - // Force a particular format, despite the number of channels - // in the image. + // Force a particular format, despite the number of channels in the + // image. string format_name = word.substr(6); EggTexture::Format format = EggTexture::string_format(format_name); if (format != EggTexture::F_unspecified) { @@ -254,9 +248,8 @@ parse(const string &line) { } } else if (word == "generic") { - // Genericize the image format by replacing bitcount-specific - // formats with their generic equivalents, e.g. rgba8 becomes - // rgba. + // Genericize the image format by replacing bitcount-specific formats + // with their generic equivalents, e.g. rgba8 becomes rgba. _generic_format = true; } else if (word == "keep-format") { @@ -270,9 +263,8 @@ parse(const string &line) { _palette_groups.insert(group); } else { - // Maybe it's a format name. This suggests an image format, - // but may be overridden to reflect the number of channels in - // the image. + // Maybe it's a format name. This suggests an image format, but may + // be overridden to reflect the number of channels in the image. EggTexture::Format format = EggTexture::string_format(word); if (format != EggTexture::F_unspecified) { if (!_force_format) { @@ -302,12 +294,12 @@ parse(const string &line) { case 'u': _wrap_u = wm; break; - + case 'v': _wrap_v = wm; break; } - + } else { // Maybe it's an image file request. if (!parse_image_type_request(word, _color_type, _alpha_type)) { @@ -325,17 +317,13 @@ parse(const string &line) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaLine::match_egg -// Access: Public -// Description: Compares the patterns on the line to the indicated -// EggFile. If they match, updates the egg with the -// appropriate information. Returns true if a match is -// detected and the search for another line should stop, -// or false if a match is not detected (or if the -// keyword "cont" is present, which means the search -// should continue regardless). -//////////////////////////////////////////////////////////////////// +/** + * Compares the patterns on the line to the indicated EggFile. If they match, + * updates the egg with the appropriate information. Returns true if a match + * is detected and the search for another line should stop, or false if a + * match is not detected (or if the keyword "cont" is present, which means the + * search should continue regardless). + */ bool TxaLine:: match_egg(EggFile *egg_file) const { string name = egg_file->get_name(); @@ -376,29 +364,24 @@ match_egg(EggFile *egg_file) const { egg_file->match_txa_groups(_palette_groups); if (got_cont) { - // If we have the "cont" keyword, we should keep scanning for - // another line, even though we matched this one. + // If we have the "cont" keyword, we should keep scanning for another + // line, even though we matched this one. return false; } - // Otherwise, in the normal case, a match ends the search for - // matches. + // Otherwise, in the normal case, a match ends the search for matches. egg_file->clear_surprise(); return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaLine::match_texture -// Access: Public -// Description: Compares the patterns on the line to the indicated -// TextureImage. If they match, updates the texture -// with the appropriate information. Returns true if a -// match is detected and the search for another line -// should stop, or false if a match is not detected (or -// if the keyword "cont" is present, which means the -// search should continue regardless). -//////////////////////////////////////////////////////////////////// +/** + * Compares the patterns on the line to the indicated TextureImage. If they + * match, updates the texture with the appropriate information. Returns true + * if a match is detected and the search for another line should stop, or + * false if a match is not detected (or if the keyword "cont" is present, + * which means the search should continue regardless). + */ bool TxaLine:: match_texture(TextureImage *texture) const { string name = texture->get_name(); @@ -525,23 +508,20 @@ match_texture(TextureImage *texture) const { texture->_explicitly_assigned_groups.remove_null(); if (got_cont) { - // If we have the "cont" keyword, we should keep scanning for - // another line, even though we matched this one. + // If we have the "cont" keyword, we should keep scanning for another + // line, even though we matched this one. return false; } - // Otherwise, in the normal case, a match ends the search for - // matches. + // Otherwise, in the normal case, a match ends the search for matches. texture->_is_surprise = false; return true; } -//////////////////////////////////////////////////////////////////// -// Function: TxaLine::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TxaLine:: output(ostream &out) const { Patterns::const_iterator pi; diff --git a/pandatool/src/palettizer/txaLine.h b/pandatool/src/palettizer/txaLine.h index 7699bbe5a2..98166f0bec 100644 --- a/pandatool/src/palettizer/txaLine.h +++ b/pandatool/src/palettizer/txaLine.h @@ -1,16 +1,15 @@ -// Filename: txaLine.h -// Created by: drose (30Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file txaLine.h + * @author drose + * @date 2000-11-30 + */ #ifndef TXALINE_H #define TXALINE_H @@ -29,13 +28,11 @@ class PNMFileType; class EggFile; class TextureImage; -//////////////////////////////////////////////////////////////////// -// Class : TxaLine -// Description : This is a single matching line in the .txa file. It -// consists of a list of names (texture names or egg -// file names), followed by a colon and an optional size -// and a set of keywords. -//////////////////////////////////////////////////////////////////// +/** + * This is a single matching line in the .txa file. It consists of a list of + * names (texture names or egg file names), followed by a colon and an + * optional size and a set of keywords. + */ class TxaLine { public: TxaLine(); @@ -102,4 +99,3 @@ INLINE ostream &operator << (ostream &out, const TxaLine &line) { } #endif - diff --git a/pandatool/src/pandatoolbase/animationConvert.cxx b/pandatool/src/pandatoolbase/animationConvert.cxx index 5dee4d0af6..6403da48cd 100644 --- a/pandatool/src/pandatoolbase/animationConvert.cxx +++ b/pandatool/src/pandatoolbase/animationConvert.cxx @@ -1,26 +1,24 @@ -// Filename: animationConvert.cxx -// Created by: drose (21Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animationConvert.cxx + * @author drose + * @date 2003-01-21 + */ #include "animationConvert.h" #include "string_utils.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: format_animation_convert -// Description: Returns the string corresponding to this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string corresponding to this method. + */ string format_animation_convert(AnimationConvert convert) { switch (convert) { @@ -52,21 +50,18 @@ format_animation_convert(AnimationConvert convert) { return "**"; } -//////////////////////////////////////////////////////////////////// -// Function: AnimationConvert output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, AnimationConvert convert) { return out << format_animation_convert(convert); } -//////////////////////////////////////////////////////////////////// -// Function: string_animation_convert -// Description: Converts from a string, as might be input by the -// user, to one of the known AnimationConvert types. -// Returns AC_invalid if the string is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Converts from a string, as might be input by the user, to one of the known + * AnimationConvert types. Returns AC_invalid if the string is unknown. + */ AnimationConvert string_animation_convert(const string &str) { if (cmp_nocase(str, "none") == 0) { diff --git a/pandatool/src/pandatoolbase/animationConvert.h b/pandatool/src/pandatoolbase/animationConvert.h index f98b3f9944..b5d9ec9cda 100644 --- a/pandatool/src/pandatoolbase/animationConvert.h +++ b/pandatool/src/pandatoolbase/animationConvert.h @@ -1,28 +1,25 @@ -// Filename: animationConvert.h -// Created by: drose (21Jan03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file animationConvert.h + * @author drose + * @date 2003-01-21 + */ #ifndef ANIMATIONCONVERT_H #define ANIMATIONCONVERT_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : AnimationConvert -// Description : This enumerated type lists the methods by which -// animation from an animation package might be -// represented in egg format. -//////////////////////////////////////////////////////////////////// +/** + * This enumerated type lists the methods by which animation from an animation + * package might be represented in egg format. + */ enum AnimationConvert { AC_invalid, // Never use this. AC_none, // No animation: static geometry only. diff --git a/pandatool/src/pandatoolbase/config_pandatoolbase.cxx b/pandatool/src/pandatoolbase/config_pandatoolbase.cxx index 7dcb263689..65f022286e 100644 --- a/pandatool/src/pandatoolbase/config_pandatoolbase.cxx +++ b/pandatool/src/pandatoolbase/config_pandatoolbase.cxx @@ -1,29 +1,26 @@ -// Filename: config_pandatoolbase.cxx -// Created by: drose (29Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pandatoolbase.cxx + * @author drose + * @date 2004-11-29 + */ #include "config_pandatoolbase.h" NotifyCategoryDef(pandatoolbase, ""); -//////////////////////////////////////////////////////////////////// -// Function: init_libpandatoolbase -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpandatoolbase() { static bool initialized = false; @@ -32,4 +29,3 @@ init_libpandatoolbase() { } initialized = true; } - diff --git a/pandatool/src/pandatoolbase/config_pandatoolbase.h b/pandatool/src/pandatoolbase/config_pandatoolbase.h index 27d8f6f7cf..2bfe9c9f44 100644 --- a/pandatool/src/pandatoolbase/config_pandatoolbase.h +++ b/pandatool/src/pandatoolbase/config_pandatoolbase.h @@ -1,16 +1,15 @@ -// Filename: config_pandatoolbase.h -// Created by: drose (29Nov04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pandatoolbase.h + * @author drose + * @date 2004-11-29 + */ #ifndef CONFIG_PANDATOOLBASE_H #define CONFIG_PANDATOOLBASE_H diff --git a/pandatool/src/pandatoolbase/distanceUnit.cxx b/pandatool/src/pandatoolbase/distanceUnit.cxx index 7b0641032c..d2479de244 100644 --- a/pandatool/src/pandatoolbase/distanceUnit.cxx +++ b/pandatool/src/pandatoolbase/distanceUnit.cxx @@ -1,27 +1,24 @@ -// Filename: distanceUnit.cxx -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file distanceUnit.cxx + * @author drose + * @date 2001-04-17 + */ #include "distanceUnit.h" #include "config_pandatoolbase.h" #include "string_utils.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: format_abbrev_unit -// Description: Returns the string representing the common -// abbreviation for the given unit. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string representing the common abbreviation for the given unit. + */ string format_abbrev_unit(DistanceUnit unit) { switch (unit) { @@ -59,11 +56,9 @@ format_abbrev_unit(DistanceUnit unit) { return "**"; } -//////////////////////////////////////////////////////////////////// -// Function: format_long_unit -// Description: Returns the string representing the full name (plural) -// for the given unit. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string representing the full name (plural) for the given unit. + */ string format_long_unit(DistanceUnit unit) { switch (unit) { @@ -101,19 +96,17 @@ format_long_unit(DistanceUnit unit) { return "**"; } -//////////////////////////////////////////////////////////////////// -// Function: DistanceUnit output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, DistanceUnit unit) { return out << format_abbrev_unit(unit); } -//////////////////////////////////////////////////////////////////// -// Function: DistanceUnit input operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ istream & operator >> (istream &in, DistanceUnit &unit) { string word; @@ -126,12 +119,10 @@ operator >> (istream &in, DistanceUnit &unit) { return in; } -//////////////////////////////////////////////////////////////////// -// Function: string_distance_unit -// Description: Converts from a string, as might be input by the -// user, to one of the known DistanceUnit types. -// Returns DU_invalid if the string is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Converts from a string, as might be input by the user, to one of the known + * DistanceUnit types. Returns DU_invalid if the string is unknown. + */ DistanceUnit string_distance_unit(const string &str) { if (cmp_nocase(str, "mm") == 0 || cmp_nocase(str, "millimeters") == 0) { @@ -170,12 +161,10 @@ string_distance_unit(const string &str) { } } -//////////////////////////////////////////////////////////////////// -// Function: unit_scale -// Description: Returns the number of the indicated unit per each -// centimeter. This internal function is used to -// implement convert_units(), below. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of the indicated unit per each centimeter. This + * internal function is used to implement convert_units(), below. + */ static double unit_scale(DistanceUnit unit) { switch (unit) { case DU_millimeters: @@ -213,12 +202,10 @@ static double unit_scale(DistanceUnit unit) { return 1.0; } -//////////////////////////////////////////////////////////////////// -// Function: convert_units -// Description: Returns the scaling factor that must be applied to -// convert from units of "from" to "to". -//////////////////////////////////////////////////////////////////// +/** + * Returns the scaling factor that must be applied to convert from units of + * "from" to "to". + */ double convert_units(DistanceUnit from, DistanceUnit to) { return unit_scale(from) / unit_scale(to); } - diff --git a/pandatool/src/pandatoolbase/distanceUnit.h b/pandatool/src/pandatoolbase/distanceUnit.h index e313b85c2a..4e82b74335 100644 --- a/pandatool/src/pandatoolbase/distanceUnit.h +++ b/pandatool/src/pandatoolbase/distanceUnit.h @@ -1,28 +1,25 @@ -// Filename: distanceUnit.h -// Created by: drose (17Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file distanceUnit.h + * @author drose + * @date 2001-04-17 + */ #ifndef DISTANCEUNIT_H #define DISTANCEUNIT_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : DistanceUnit -// Description : This enumerated type lists all the kinds of units -// we're likely to come across in model conversion -// programs. -//////////////////////////////////////////////////////////////////// +/** + * This enumerated type lists all the kinds of units we're likely to come + * across in model conversion programs. + */ enum DistanceUnit { DU_millimeters, DU_centimeters, diff --git a/pandatool/src/pandatoolbase/pandatoolbase.cxx b/pandatool/src/pandatoolbase/pandatoolbase.cxx index 623318c797..834ec05bf0 100644 --- a/pandatool/src/pandatoolbase/pandatoolbase.cxx +++ b/pandatool/src/pandatoolbase/pandatoolbase.cxx @@ -1,15 +1,14 @@ -// Filename: pandatoolbase.cxx -// Created by: drose (15Sep00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pandatoolbase.cxx + * @author drose + * @date 2000-09-15 + */ #include "pandatoolbase.h" diff --git a/pandatool/src/pandatoolbase/pandatoolbase.h b/pandatool/src/pandatoolbase/pandatoolbase.h index 9b2c8e4d16..2d87f29b78 100644 --- a/pandatool/src/pandatoolbase/pandatoolbase.h +++ b/pandatool/src/pandatoolbase/pandatoolbase.h @@ -1,8 +1,4 @@ -/* Filename: pandatoolbase.h - * Created by: drose (12Sep00) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file pandatoolbase.h + * @author drose + * @date 2000-09-12 + */ /* This file is included at the beginning of every header file and/or C or C++ file. It must be compilable for C as well as C++ files, @@ -23,4 +22,3 @@ #include "pandatoolsymbols.h" #endif - diff --git a/pandatool/src/pandatoolbase/pandatoolsymbols.h b/pandatool/src/pandatoolbase/pandatoolsymbols.h index 431d72f7f8..e2e16b8b3e 100644 --- a/pandatool/src/pandatoolbase/pandatoolsymbols.h +++ b/pandatool/src/pandatoolbase/pandatoolsymbols.h @@ -1,8 +1,4 @@ -/* Filename: pandatoolsymbols.h - * Created by: drose (26Apr01) - * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * +/** * PANDA 3D SOFTWARE * Copyright (c) Carnegie Mellon University. All rights reserved. * @@ -10,7 +6,10 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * @file pandatoolsymbols.h + * @author drose + * @date 2001-04-26 + */ #ifndef PANDATOOLSYMBOLS_H #define PANDATOOLSYMBOLS_H diff --git a/pandatool/src/pandatoolbase/pathReplace.I b/pandatool/src/pandatoolbase/pathReplace.I index a4958faf62..a2fde11ad8 100644 --- a/pandatool/src/pandatoolbase/pathReplace.I +++ b/pandatool/src/pandatoolbase/pathReplace.I @@ -1,118 +1,92 @@ -// Filename: pathReplace.I -// Created by: drose (07Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathReplace.I + * @author drose + * @date 2003-02-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::clear_error -// Access: Public -// Description: Resets the error flag to the no-error state. -// had_error() will return false until a new error is -// generated. -//////////////////////////////////////////////////////////////////// +/** + * Resets the error flag to the no-error state. had_error() will return false + * until a new error is generated. + */ INLINE void PathReplace:: clear_error() { _error_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::had_error -// Access: Public -// Description: Returns true if an error was detected since the last -// call to clear_error(), false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if an error was detected since the last call to clear_error(), + * false otherwise. + */ INLINE bool PathReplace:: had_error() const { return _error_flag; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::clear -// Access: Public -// Description: Removes all the patterns from the specification. -//////////////////////////////////////////////////////////////////// +/** + * Removes all the patterns from the specification. + */ INLINE void PathReplace:: clear() { clear_error(); _entries.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::add_pattern -// Access: Public -// Description: Adds the indicated original/replace pattern to the -// specification. If a filename is encountered whose -// initial prefix matches the indicated orig_prefix, -// that prefix will be replaced with replacement_prefix. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated original/replace pattern to the specification. If a + * filename is encountered whose initial prefix matches the indicated + * orig_prefix, that prefix will be replaced with replacement_prefix. + */ INLINE void PathReplace:: add_pattern(const string &orig_prefix, const string &replacement_prefix) { _entries.push_back(Entry(orig_prefix, replacement_prefix)); } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::get_num_patterns -// Access: Public -// Description: Returns the number of original/replace patterns that -// have been added. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of original/replace patterns that have been added. + */ INLINE int PathReplace:: get_num_patterns() const { return _entries.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::get_orig_prefix -// Access: Public -// Description: Returns the original prefix associated with the nth -// pattern. -//////////////////////////////////////////////////////////////////// +/** + * Returns the original prefix associated with the nth pattern. + */ INLINE const string &PathReplace:: get_orig_prefix(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), _entries[0]._orig_prefix); return _entries[n]._orig_prefix; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::get_replacement_prefix -// Access: Public -// Description: Returns the replacement prefix associated with the nth -// pattern. -//////////////////////////////////////////////////////////////////// +/** + * Returns the replacement prefix associated with the nth pattern. + */ INLINE const string &PathReplace:: get_replacement_prefix(int n) const { nassertr(n >= 0 && n < (int)_entries.size(), _entries[0]._replacement_prefix); return _entries[n]._replacement_prefix; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::is_empty -// Access: Public -// Description: Returns true if the PathReplace object specifies no -// action, or false if convert_path() may do something. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the PathReplace object specifies no action, or false if + * convert_path() may do something. + */ INLINE bool PathReplace:: is_empty() const { return (_entries.empty() && _path.is_empty() && _path_store == PS_keep); } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::convert_path -// Access: Public -// Description: Calls match_path() followed by store_path(), to -// replace the initial prefix and then convert the file -// for storing, as the user indicated. -//////////////////////////////////////////////////////////////////// +/** + * Calls match_path() followed by store_path(), to replace the initial prefix + * and then convert the file for storing, as the user indicated. + */ INLINE Filename PathReplace:: convert_path(const Filename &orig_filename, const DSearchPath &additional_path) { Filename fullpath, outpath; @@ -120,11 +94,9 @@ convert_path(const Filename &orig_filename, const DSearchPath &additional_path) return outpath; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Component::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PathReplace::Component:: Component(const string &component) : _orig_prefix(component), @@ -132,11 +104,9 @@ Component(const string &component) : { } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Component::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PathReplace::Component:: Component(const PathReplace::Component ©) : _orig_prefix(copy._orig_prefix), @@ -144,22 +114,18 @@ Component(const PathReplace::Component ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Component::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PathReplace::Component:: operator = (const PathReplace::Component ©) { _orig_prefix = copy._orig_prefix; _double_star = copy._double_star; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Entry::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE PathReplace::Entry:: Entry(const PathReplace::Entry ©) : _orig_prefix(copy._orig_prefix), @@ -169,11 +135,9 @@ Entry(const PathReplace::Entry ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Entry::Copy Assignment -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void PathReplace::Entry:: operator = (const PathReplace::Entry ©) { _orig_prefix = copy._orig_prefix; diff --git a/pandatool/src/pandatoolbase/pathReplace.cxx b/pandatool/src/pandatoolbase/pathReplace.cxx index 5a8e03c3d8..786bb6ae03 100644 --- a/pandatool/src/pandatoolbase/pathReplace.cxx +++ b/pandatool/src/pandatoolbase/pathReplace.cxx @@ -1,16 +1,15 @@ -// Filename: pathReplace.cxx -// Created by: drose (07Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathReplace.cxx + * @author drose + * @date 2003-02-07 + */ #include "pathReplace.h" #include "config_util.h" @@ -18,11 +17,9 @@ #include "indent.h" #include "virtualFileSystem.h" -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PathReplace:: PathReplace() { _path_store = PS_keep; @@ -32,26 +29,21 @@ PathReplace() { _error_flag = false; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PathReplace:: ~PathReplace() { } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::match_path -// Access: Public -// Description: Looks for a match for the given filename among all -// the replacement patterns, and returns the first match -// found. If additional_path is nonempty, it is an -// additional search path on which to look for the file. -// The model_path is always implicitly searched. -//////////////////////////////////////////////////////////////////// +/** + * Looks for a match for the given filename among all the replacement + * patterns, and returns the first match found. If additional_path is + * nonempty, it is an additional search path on which to look for the file. + * The model_path is always implicitly searched. + */ Filename PathReplace:: -match_path(const Filename &orig_filename, +match_path(const Filename &orig_filename, const DSearchPath &additional_path) { Filename match; bool got_match = false; @@ -63,28 +55,27 @@ match_path(const Filename &orig_filename, const Entry &entry = (*ei); Filename new_filename; if (entry.try_match(orig_filename, new_filename)) { - // The prefix matches. Save the resulting filename for - // posterity. + // The prefix matches. Save the resulting filename for posterity. got_match = true; match = new_filename; - + if (new_filename.is_fully_qualified()) { - // If the resulting filename is fully qualified, it's a match - // if and only if it exists. + // If the resulting filename is fully qualified, it's a match if and + // only if it exists. if (vfs->exists(new_filename)) { return new_filename; } - + } else { - // Otherwise, if it's a relative filename, attempt to look it - // up on the search path. + // Otherwise, if it's a relative filename, attempt to look it up on + // the search path. if (vfs->resolve_filename(new_filename, _path) || vfs->resolve_filename(new_filename, additional_path) || vfs->resolve_filename(new_filename, get_model_path())) { // Found it! if (_path_store == PS_keep) { - // If we asked to "keep" the pathname, we return the - // matched path, but not the found path. + // If we asked to "keep" the pathname, we return the matched path, + // but not the found path. return match; } else { // Otherwise, we return the actual, found path. @@ -92,13 +83,13 @@ match_path(const Filename &orig_filename, } } } - + // The prefix matched, but it didn't exist. Keep looking. } } - // The file couldn't be found anywhere. Did we at least get any - // prefix match? + // The file couldn't be found anywhere. Did we at least get any prefix + // match? if (got_match) { if (_exists) { _error_flag = true; @@ -113,8 +104,8 @@ match_path(const Filename &orig_filename, } if (!orig_filename.is_local()) { - // Ok, we didn't match any specified prefixes. If the file is an - // absolute pathname and we have _noabs set, that's an error. + // Ok, we didn't match any specified prefixes. If the file is an absolute + // pathname and we have _noabs set, that's an error. if (_noabs) { _error_flag = true; pandatoolbase_cat.error() @@ -125,8 +116,7 @@ match_path(const Filename &orig_filename, } } - // Well, we still haven't found it; look it up on the search path as - // is. + // Well, we still haven't found it; look it up on the search path as is. if (_path_store != PS_keep) { Filename new_filename = orig_filename; if (vfs->resolve_filename(new_filename, _path) || @@ -137,8 +127,8 @@ match_path(const Filename &orig_filename, } } - // Nope, couldn't find anything. This is an error, but just return - // the original filename. + // Nope, couldn't find anything. This is an error, but just return the + // original filename. if (_exists) { _error_flag = true; pandatoolbase_cat.error() @@ -150,14 +140,11 @@ match_path(const Filename &orig_filename, return orig_filename; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::store_path -// Access: Public -// Description: Given a path to an existing filename, converts it as -// specified in the _path_store and or _path_directory -// properties to a form suitable for storing in an -// output file. -//////////////////////////////////////////////////////////////////// +/** + * Given a path to an existing filename, converts it as specified in the + * _path_store and or _path_directory properties to a form suitable for + * storing in an output file. + */ Filename PathReplace:: store_path(const Filename &orig_filename) { if (orig_filename.empty()) { @@ -202,17 +189,13 @@ store_path(const Filename &orig_filename) { return filename; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::full_convert_path -// Access: Public -// Description: Converts the input path into two different forms: -// A resolved path, and an output path. The resolved -// path is an absolute path if at all possible. The -// output path is in the form specified by the -ps -// path store option. -//////////////////////////////////////////////////////////////////// +/** + * Converts the input path into two different forms: A resolved path, and an + * output path. The resolved path is an absolute path if at all possible. + * The output path is in the form specified by the -ps path store option. + */ void PathReplace:: -full_convert_path(const Filename &orig_filename, +full_convert_path(const Filename &orig_filename, const DSearchPath &additional_path, Filename &resolved_path, Filename &output_path) { @@ -230,22 +213,21 @@ full_convert_path(const Filename &orig_filename, const Entry &entry = (*ei); Filename new_filename; if (entry.try_match(orig_filename, new_filename)) { - // The prefix matches. Save the resulting filename for - // posterity. + // The prefix matches. Save the resulting filename for posterity. got_match = true; match = new_filename; - + if (new_filename.is_fully_qualified()) { - // If the resulting filename is fully qualified, it's a match - // if and only if it exists. + // If the resulting filename is fully qualified, it's a match if and + // only if it exists. if (vfs->exists(new_filename)) { resolved_path = new_filename; goto calculate_output_path; } - + } else { - // Otherwise, if it's a relative filename, attempt to look it - // up on the search path. + // Otherwise, if it's a relative filename, attempt to look it up on + // the search path. if (vfs->resolve_filename(new_filename, _path) || vfs->resolve_filename(new_filename, additional_path) || vfs->resolve_filename(new_filename, get_model_path())) { @@ -254,13 +236,13 @@ full_convert_path(const Filename &orig_filename, goto calculate_output_path; } } - + // The prefix matched, but it didn't exist. Keep looking. } } - // The file couldn't be found anywhere. Did we at least get any - // prefix match? + // The file couldn't be found anywhere. Did we at least get any prefix + // match? if (got_match) { if (_exists) { _error_flag = true; @@ -276,8 +258,8 @@ full_convert_path(const Filename &orig_filename, } if (!orig_filename.is_local()) { - // Ok, we didn't match any specified prefixes. If the file is an - // absolute pathname and we have _noabs set, that's an error. + // Ok, we didn't match any specified prefixes. If the file is an absolute + // pathname and we have _noabs set, that's an error. if (_noabs) { _error_flag = true; pandatoolbase_cat.error() @@ -288,8 +270,7 @@ full_convert_path(const Filename &orig_filename, } } - // Well, we still haven't found it; look it up on the search path as - // is. + // Well, we still haven't found it; look it up on the search path as is. { Filename new_filename = orig_filename; if (vfs->resolve_filename(new_filename, _path) || @@ -302,8 +283,8 @@ full_convert_path(const Filename &orig_filename, } } - // Nope, couldn't find anything. This is an error, but just return - // the original filename. + // Nope, couldn't find anything. This is an error, but just return the + // original filename. if (_exists) { _error_flag = true; pandatoolbase_cat.error() @@ -315,9 +296,8 @@ full_convert_path(const Filename &orig_filename, match = orig_filename; resolved_path = orig_filename; - // To calculate the output path, we need two inputs: - // the match, and the resolved path. Which one is used - // depends upon the path-store mode. + // To calculate the output path, we need two inputs: the match, and the + // resolved path. Which one is used depends upon the path-store mode. calculate_output_path: if (_copy_files) { @@ -336,7 +316,7 @@ full_convert_path(const Filename &orig_filename, output_path.make_relative_to(_path_directory); } break; - + case PS_absolute: if (resolved_path.empty()) output_path = resolved_path; @@ -370,17 +350,15 @@ full_convert_path(const Filename &orig_filename, } } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::write -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PathReplace:: write(ostream &out, int indent_level) const { Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { indent(out, indent_level) - << "-pr " << (*ei)._orig_prefix << "=" + << "-pr " << (*ei)._orig_prefix << "=" << (*ei)._replacement_prefix << "\n"; } int num_directories = _path.get_num_directories(); @@ -413,14 +391,11 @@ write(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::copy_this_file -// Access: Private -// Description: Copies the indicated file into the -// copy_into_directory, and adjusts filename to -// reference the new location. Returns true if the copy -// is made and the filename is changed, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Copies the indicated file into the copy_into_directory, and adjusts + * filename to reference the new location. Returns true if the copy is made + * and the filename is changed, false otherwise. + */ bool PathReplace:: copy_this_file(Filename &filename) { if (_copy_into_directory.is_local()) { @@ -429,8 +404,8 @@ copy_this_file(Filename &filename) { Copied::iterator ci = _orig_to_target.find(filename); if (ci != _orig_to_target.end()) { - // This file has already been successfully copied, so we can - // quietly return its new target filename. + // This file has already been successfully copied, so we can quietly + // return its new target filename. if (filename != (*ci).second) { filename = (*ci).second; return true; @@ -444,7 +419,7 @@ copy_this_file(Filename &filename) { if ((*ci).second != filename) { _error_flag = true; pandatoolbase_cat.error() - << "Filename conflict! Both " << (*ci).second << " and " + << "Filename conflict! Both " << (*ci).second << " and " << filename << " map to " << target_filename << "\n"; } @@ -472,11 +447,9 @@ copy_this_file(Filename &filename) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Entry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PathReplace::Entry:: Entry(const string &orig_prefix, const string &replacement_prefix) : _orig_prefix(orig_prefix), @@ -503,14 +476,11 @@ Entry(const string &orig_prefix, const string &replacement_prefix) : } } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Entry::try_match -// Access: Public -// Description: Considers whether the indicated filename matches -// this entry's prefix. If so, switches the prefix and -// stores the result in new_filename, and returns true; -// otherwise, returns false. -//////////////////////////////////////////////////////////////////// +/** + * Considers whether the indicated filename matches this entry's prefix. If + * so, switches the prefix and stores the result in new_filename, and returns + * true; otherwise, returns false. + */ bool PathReplace::Entry:: try_match(const Filename &filename, Filename &new_filename) const { if (_is_local != filename.is_local()) { @@ -537,18 +507,14 @@ try_match(const Filename &filename, Filename &new_filename) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PathReplace::Entry::r_try_match -// Access: Public -// Description: The recursive implementation of try_match(). -// Actually, this is doubly-recursive, to implement the -// "**" feature. -// -// The return value is the number of the "components" -// vector that successfully matched against all of the -// orig_components. (It's a variable number because -// there might be one or more "**" entries.) -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of try_match(). Actually, this is doubly- + * recursive, to implement the "**" feature. + * + * The return value is the number of the "components" vector that successfully + * matched against all of the orig_components. (It's a variable number + * because there might be one or more "**" entries.) + */ size_t PathReplace::Entry:: r_try_match(const vector_string &components, size_t oi, size_t ci) const { if (oi >= _orig_components.size()) { @@ -556,18 +522,17 @@ r_try_match(const vector_string &components, size_t oi, size_t ci) const { return ci; } if (ci >= components.size()) { - // If we reached the end of the string, but we still have - // user-supplied components, we failed. (Arguably there should be - // a special case here for a user-supplied string that ends in - // "**", but I don't think the user ever wants to match the - // complete string.) + // If we reached the end of the string, but we still have user-supplied + // components, we failed. (Arguably there should be a special case here + // for a user-supplied string that ends in "**", but I don't think the + // user ever wants to match the complete string.) return 0; } const Component &orig_component = _orig_components[oi]; if (orig_component._double_star) { - // If we have a double star, first consider the match if it were - // expanded as far as possible. + // If we have a double star, first consider the match if it were expanded + // as far as possible. size_t mi = r_try_match(components, oi, ci + 1); if (mi != 0) { return mi; @@ -577,8 +542,8 @@ r_try_match(const vector_string &components, size_t oi, size_t ci) const { return r_try_match(components, oi + 1, ci); } - // We don't have a double star, it's just a one-for-one component - // entry. Does it match? + // We don't have a double star, it's just a one-for-one component entry. + // Does it match? if (orig_component._orig_prefix.matches(components[ci])) { // It does! Keep going. return r_try_match(components, oi + 1, ci + 1); diff --git a/pandatool/src/pandatoolbase/pathReplace.h b/pandatool/src/pandatoolbase/pathReplace.h index 28ab3efdf1..a0ec064acd 100644 --- a/pandatool/src/pandatoolbase/pathReplace.h +++ b/pandatool/src/pandatoolbase/pathReplace.h @@ -1,16 +1,15 @@ -// Filename: pathReplace.h -// Created by: drose (07Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathReplace.h + * @author drose + * @date 2003-02-07 + */ #ifndef PATHREPLACE_H #define PATHREPLACE_H @@ -24,19 +23,16 @@ #include "pvector.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : PathReplace -// Description : This encapsulates the user's command-line request to -// replace existing, incorrect pathnames to models and -// textures from a file with correct pathnames. It -// corresponds to a sequence of -pr command-line -// options, as well as the -pp option. -// -// This can also go the next step, which is to convert a -// known file into a suitable form for storing in a -// model file. In this capacity, it corresponds to the -// -ps and -pd options. -//////////////////////////////////////////////////////////////////// +/** + * This encapsulates the user's command-line request to replace existing, + * incorrect pathnames to models and textures from a file with correct + * pathnames. It corresponds to a sequence of -pr command-line options, as + * well as the -pp option. + * + * This can also go the next step, which is to convert a known file into a + * suitable form for storing in a model file. In this capacity, it + * corresponds to the -ps and -pd options. + */ class PathReplace : public ReferenceCount { public: PathReplace(); @@ -54,13 +50,13 @@ public: INLINE bool is_empty() const; - Filename match_path(const Filename &orig_filename, + Filename match_path(const Filename &orig_filename, const DSearchPath &additional_path = DSearchPath()); Filename store_path(const Filename &orig_filename); INLINE Filename convert_path(const Filename &orig_filename, const DSearchPath &additional_path = DSearchPath()); - + void full_convert_path(const Filename &orig_filename, const DSearchPath &additional_path, Filename &resolved_path, @@ -78,14 +74,13 @@ public: bool _copy_files; Filename _copy_into_directory; - // If this is this true, then the error flag is set (see had_error() - // and clear_error()) if any Filename passed to match_path() or - // convert_path(), and unmatched by one of the prefixes, happens to - // be an absolute pathname. + // If this is this true, then the error flag is set (see had_error() and + // clear_error()) if any Filename passed to match_path() or convert_path(), + // and unmatched by one of the prefixes, happens to be an absolute pathname. bool _noabs; - // If this is true, then the error flag is set if any Filename - // passed to match_path() or convert_path() cannot be found. + // If this is true, then the error flag is set if any Filename passed to + // match_path() or convert_path() cannot be found. bool _exists; private: @@ -130,6 +125,3 @@ private: #include "pathReplace.I" #endif - - - diff --git a/pandatool/src/pandatoolbase/pathStore.cxx b/pandatool/src/pandatoolbase/pathStore.cxx index 8b049431f4..d40fe3f276 100644 --- a/pandatool/src/pandatoolbase/pathStore.cxx +++ b/pandatool/src/pandatoolbase/pathStore.cxx @@ -1,26 +1,24 @@ -// Filename: pathStore.cxx -// Created by: drose (10Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathStore.cxx + * @author drose + * @date 2003-02-10 + */ #include "pathStore.h" #include "string_utils.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: format_path_store -// Description: Returns the string corresponding to this method. -//////////////////////////////////////////////////////////////////// +/** + * Returns the string corresponding to this method. + */ string format_path_store(PathStore store) { switch (store) { @@ -46,24 +44,21 @@ format_path_store(PathStore store) { return "**"; } -//////////////////////////////////////////////////////////////////// -// Function: PathStore output operator -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ostream & operator << (ostream &out, PathStore store) { return out << format_path_store(store); } -//////////////////////////////////////////////////////////////////// -// Function: string_path_store -// Description: Stores from a string, as might be input by the -// user, to one of the known PathStore types. -// Returns PS_invalid if the string is unknown. -//////////////////////////////////////////////////////////////////// +/** + * Stores from a string, as might be input by the user, to one of the known + * PathStore types. Returns PS_invalid if the string is unknown. + */ PathStore string_path_store(const string &str) { - if (cmp_nocase(str, "relative") == 0 || + if (cmp_nocase(str, "relative") == 0 || cmp_nocase(str, "rel") == 0) { return PS_relative; diff --git a/pandatool/src/pandatoolbase/pathStore.h b/pandatool/src/pandatoolbase/pathStore.h index ed597671e6..7c15515038 100644 --- a/pandatool/src/pandatoolbase/pathStore.h +++ b/pandatool/src/pandatoolbase/pathStore.h @@ -1,28 +1,25 @@ -// Filename: pathStore.h -// Created by: drose (10Feb03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pathStore.h + * @author drose + * @date 2003-02-10 + */ #ifndef PATHSTORE_H #define PATHSTORE_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : PathStore -// Description : This enumerated type lists the methods by which -// a filename path might be mangled before storing in a -// destination file. -//////////////////////////////////////////////////////////////////// +/** + * This enumerated type lists the methods by which a filename path might be + * mangled before storing in a destination file. + */ enum PathStore { PS_invalid, // Never use this. PS_relative, // Make relative to a user-specified directory. diff --git a/pandatool/src/pfmprogs/config_pfm.cxx b/pandatool/src/pfmprogs/config_pfm.cxx index 5f058911a9..fc8cea6bf3 100644 --- a/pandatool/src/pfmprogs/config_pfm.cxx +++ b/pandatool/src/pfmprogs/config_pfm.cxx @@ -1,16 +1,15 @@ -// Filename: config_pfm.cxx -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pfm.cxx + * @author drose + * @date 2010-12-23 + */ #include "config_pfm.h" @@ -28,14 +27,12 @@ ConfigureFn(config_pfm) { init_libpfm(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libpfm -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libpfm() { static bool initialized = false; @@ -44,4 +41,3 @@ init_libpfm() { } initialized = true; } - diff --git a/pandatool/src/pfmprogs/config_pfm.h b/pandatool/src/pfmprogs/config_pfm.h index 8f15714882..5da1fcbb4e 100644 --- a/pandatool/src/pfmprogs/config_pfm.h +++ b/pandatool/src/pfmprogs/config_pfm.h @@ -1,16 +1,15 @@ -// Filename: config_pfm.h -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_pfm.h + * @author drose + * @date 2010-12-23 + */ #ifndef CONFIG_PFM_H #define CONFIG_PFM_H diff --git a/pandatool/src/pfmprogs/pfmBba.cxx b/pandatool/src/pfmprogs/pfmBba.cxx index 382768c964..cf9d47d2ab 100644 --- a/pandatool/src/pfmprogs/pfmBba.cxx +++ b/pandatool/src/pfmprogs/pfmBba.cxx @@ -1,27 +1,24 @@ -// Filename: pfmBba.cxx -// Created by: drose (02Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmBba.cxx + * @author drose + * @date 2011-03-02 + */ #include "pfmBba.h" #include "config_pfm.h" #include "pfmFile.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: PfmBba::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PfmBba:: PfmBba() { set_program_brief("generate .bba files from .pfm files"); @@ -41,11 +38,9 @@ PfmBba() { } -//////////////////////////////////////////////////////////////////// -// Function: PfmBba::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmBba:: run() { Filenames::const_iterator fi; @@ -61,11 +56,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmBba::process_pfm -// Access: Public -// Description: Handles a single pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Handles a single pfm file. + */ bool PfmBba:: process_pfm(const Filename &input_filename, PfmFile &file) { file.set_zero_special(_got_zero_special); @@ -82,7 +75,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { bba_filename.set_text(); PT(BoundingHexahedron) bounds = file.compute_planar_bounds(LPoint2f(0.5, 0.5), pfm_bba_dist[0], pfm_bba_dist[1], false); nassertr(bounds != (BoundingHexahedron *)NULL, false); - + pofstream out; if (!bba_filename.open_write(out)) { cerr << "Unable to open " << bba_filename << "\n"; @@ -106,7 +99,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { points[2] += normal; points[3] += normal; */ - + for (int i = 0; i < 8; ++i) { const LPoint3 &p = points[i]; out << p[0] << "," << p[1] << "," << p[2] << "\n"; @@ -116,14 +109,11 @@ process_pfm(const Filename &input_filename, PfmFile &file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmBba::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool PfmBba:: handle_args(ProgramBase::Args &args) { if (args.empty()) { diff --git a/pandatool/src/pfmprogs/pfmBba.h b/pandatool/src/pfmprogs/pfmBba.h index 2311fac65d..518f5568d2 100644 --- a/pandatool/src/pfmprogs/pfmBba.h +++ b/pandatool/src/pfmprogs/pfmBba.h @@ -1,16 +1,15 @@ -// Filename: pfmBba.h -// Created by: drose (02Mar11) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmBba.h + * @author drose + * @date 2011-03-02 + */ #ifndef PFMBBA_H #define PFMBBA_H @@ -24,10 +23,9 @@ class PfmFile; -//////////////////////////////////////////////////////////////////// -// Class : PfmBba -// Description : Generates a bounding-box description of a pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Generates a bounding-box description of a pfm file. + */ class PfmBba : public ProgramBase { public: PfmBba(); diff --git a/pandatool/src/pfmprogs/pfmTrans.cxx b/pandatool/src/pfmprogs/pfmTrans.cxx index db5ea973b3..02608c60f0 100644 --- a/pandatool/src/pfmprogs/pfmTrans.cxx +++ b/pandatool/src/pfmprogs/pfmTrans.cxx @@ -1,16 +1,15 @@ -// Filename: pfmTrans.cxx -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmTrans.cxx + * @author drose + * @date 2010-12-23 + */ #include "pfmTrans.h" #include "config_pfm.h" @@ -23,11 +22,9 @@ #include "string_utils.h" #include "pandaFileStream.h" -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PfmTrans:: PfmTrans() { _no_data_nan_num_channels = 0; @@ -133,11 +130,9 @@ PfmTrans() { } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PfmTrans:: run() { if ((int)(_rotate / 90) * 90 != _rotate) { @@ -166,11 +161,9 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::process_pfm -// Access: Public -// Description: Handles a single pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Handles a single pfm file. + */ bool PfmTrans:: process_pfm(const Filename &input_filename, PfmFile &file) { PfmVizzer vizzer(file); @@ -188,7 +181,7 @@ process_pfm(const Filename &input_filename, PfmFile &file) { if (_got_crop) { file.apply_crop(_crop[0], _crop[1], _crop[2], _crop[3]); - } + } if (_got_resize) { file.resize(_resize[0], _resize[1]); @@ -209,9 +202,8 @@ process_pfm(const Filename &input_filename, PfmFile &file) { case 2: // Rotate 180 degrees. - // Not sure right now why we can't flip both axes at once. But - // it works if we do one at a time. - //file.flip(true, true, false); + // Not sure right now why we can't flip both axes at once. But it works + // if we do one at a time. file.flip(true, true, false); file.flip(true, false, false); file.flip(false, true, false); break; @@ -286,14 +278,11 @@ process_pfm(const Filename &input_filename, PfmFile &file) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::add_transform_options -// Access: Public -// Description: Adds -TS, -TT, etc. as valid options for this -// program. If the user specifies one of the options on -// the command line, the data will be transformed when -// the egg file is written out. -//////////////////////////////////////////////////////////////////// +/** + * Adds -TS, -TT, etc. as valid options for this program. If the user + * specifies one of the options on the command line, the data will be + * transformed when the egg file is written out. + */ void PfmTrans:: add_transform_options() { add_option @@ -322,14 +311,11 @@ add_transform_options() { &PfmTrans::dispatch_translate, &_got_transform, &_transform); } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool PfmTrans:: handle_args(ProgramBase::Args &args) { if (args.empty()) { @@ -342,7 +328,7 @@ handle_args(ProgramBase::Args &args) { nout << "Cannot specify both -o and -d.\n"; return false; } - + } else { if (_got_output_filename) { nout << "Cannot use -o when multiple pfm files are specified.\n"; @@ -358,12 +344,9 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::dispatch_scale -// Access: Protected, Static -// Description: Handles -TS, which specifies a scale transform. Var -// is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TS, which specifies a scale transform. Var is an LMatrix4. + */ bool PfmTrans:: dispatch_scale(const string &opt, const string &arg, void *var) { LMatrix4 *transform = (LMatrix4 *)var; @@ -397,24 +380,20 @@ dispatch_scale(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::dispatch_rotate_xyz -// Access: Protected, Static -// Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TR, which specifies a rotate transform about the three cardinal + * axes. Var is an LMatrix4. + */ bool PfmTrans:: dispatch_rotate_xyz(ProgramBase *self, const string &opt, const string &arg, void *var) { PfmTrans *base = (PfmTrans *)self; return base->ns_dispatch_rotate_xyz(opt, arg, var); } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::ns_dispatch_rotate_xyz -// Access: Protected -// Description: Handles -TR, which specifies a rotate transform about -// the three cardinal axes. Var is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TR, which specifies a rotate transform about the three cardinal + * axes. Var is an LMatrix4. + */ bool PfmTrans:: ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { LMatrix4 *transform = (LMatrix4 *)var; @@ -448,24 +427,20 @@ ns_dispatch_rotate_xyz(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::dispatch_rotate_axis -// Access: Protected, Static -// Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TA, which specifies a rotate transform about an arbitrary axis. + * Var is an LMatrix4. + */ bool PfmTrans:: dispatch_rotate_axis(ProgramBase *self, const string &opt, const string &arg, void *var) { PfmTrans *base = (PfmTrans *)self; return base->ns_dispatch_rotate_axis(opt, arg, var); } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::ns_dispatch_rotate_axis -// Access: Protected -// Description: Handles -TA, which specifies a rotate transform about -// an arbitrary axis. Var is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TA, which specifies a rotate transform about an arbitrary axis. + * Var is an LMatrix4. + */ bool PfmTrans:: ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { LMatrix4 *transform = (LMatrix4 *)var; @@ -496,12 +471,9 @@ ns_dispatch_rotate_axis(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: PfmTrans::dispatch_translate -// Access: Protected, Static -// Description: Handles -TT, which specifies a translate transform. -// Var is an LMatrix4. -//////////////////////////////////////////////////////////////////// +/** + * Handles -TT, which specifies a translate transform. Var is an LMatrix4. + */ bool PfmTrans:: dispatch_translate(const string &opt, const string &arg, void *var) { LMatrix4 *transform = (LMatrix4 *)var; diff --git a/pandatool/src/pfmprogs/pfmTrans.h b/pandatool/src/pfmprogs/pfmTrans.h index 9a7eaf5c1f..c36a6b975d 100644 --- a/pandatool/src/pfmprogs/pfmTrans.h +++ b/pandatool/src/pfmprogs/pfmTrans.h @@ -1,16 +1,15 @@ -// Filename: pfmTrans.h -// Created by: drose (23Dec10) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pfmTrans.h + * @author drose + * @date 2010-12-23 + */ #ifndef PFMTRANS_H #define PFMTRANS_H @@ -24,10 +23,9 @@ class PfmFile; -//////////////////////////////////////////////////////////////////// -// Class : PfmTrans -// Description : Operates on a pfm file. -//////////////////////////////////////////////////////////////////// +/** + * Operates on a pfm file. + */ class PfmTrans : public ProgramBase { public: PfmTrans(); diff --git a/pandatool/src/progbase/programBase.I b/pandatool/src/progbase/programBase.I index 8601f536d3..698efedfdf 100644 --- a/pandatool/src/progbase/programBase.I +++ b/pandatool/src/progbase/programBase.I @@ -1,24 +1,19 @@ -// Filename: programBase.I -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file programBase.I + * @author drose + * @date 2000-06-28 + */ - -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::show_text -// Access: Public -// Description: Formats the indicated text to stderr with the known -// _terminal_width. -//////////////////////////////////////////////////////////////////// +/** + * Formats the indicated text to stderr with the known _terminal_width. + */ INLINE void ProgramBase:: show_text(const string &text) { show_text("", 0, text); diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index a9b7c666bf..86a2c17c48 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -1,16 +1,15 @@ -// Filename: programBase.cxx -// Created by: drose (13Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file programBase.cxx + * @author drose + * @date 2000-02-13 + */ #include "programBase.h" #include "wordWrapStream.h" @@ -33,10 +32,10 @@ #include #include -// This manifest is defined if we are running on a system (e.g. most -// any Unix) that allows us to determine the width of the terminal -// screen via an ioctl() call. It's just handy to know for formatting -// output nicely for the user. +// This manifest is defined if we are running on a system (e.g. most any +// Unix) that allows us to determine the width of the terminal screen via an +// ioctl() call. It's just handy to know for formatting output nicely for the +// user. #ifdef IOCTL_TERMINAL_WIDTH #include #ifndef TIOCGWINSZ @@ -54,10 +53,9 @@ operator () (const Option *a, const Option *b) const { return a->_sequence < b->_sequence; } -// This should be called at program termination just to make sure -// Notify gets properly flushed before we exit, if someone calls -// exit(). It's probably not necessary, but why not be phobic about -// it? +// This should be called at program termination just to make sure Notify gets +// properly flushed before we exit, if someone calls exit(). It's probably +// not necessary, but why not be phobic about it? static void flush_nout() { nout << flush; } @@ -75,11 +73,9 @@ static ConfigVariableBool use_terminal_width "specified by default-terminal-width even if the operating system " "appears to report a valid width.")); -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ProgramBase:: ProgramBase(const string &name) : _name(name) { // Set up Notify to write output to our own formatted stream. @@ -90,9 +86,9 @@ ProgramBase(const string &name) : _name(name) { _path_replace = new PathReplace; - // If a program never adds the path store options, the default path - // store is PS_absolute. This is the most robust solution for - // programs that read files but do not need to write them. + // If a program never adds the path store options, the default path store is + // PS_absolute. This is the most robust solution for programs that read + // files but do not need to write them. _path_replace->_path_store = PS_absolute; _got_path_store = false; _got_path_directory = false; @@ -111,33 +107,27 @@ ProgramBase(const string &name) : _name(name) { nout << "\r"; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ ProgramBase:: ~ProgramBase() { - // Reset Notify in case any messages get sent after our - // destruction--our stream is no longer valid. + // Reset Notify in case any messages get sent after our destruction--our + // stream is no longer valid. Notify::ptr()->set_ostream_ptr(NULL, false); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::show_description -// Access: Public -// Description: Writes the program description to stderr. -//////////////////////////////////////////////////////////////////// +/** + * Writes the program description to stderr. + */ void ProgramBase:: show_description() { nout << _description << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::show_usage -// Access: Public -// Description: Writes the usage line(s) to stderr. -//////////////////////////////////////////////////////////////////// +/** + * Writes the usage line(s) to stderr. + */ void ProgramBase:: show_usage() { nout << "\rUsage:\n"; @@ -150,11 +140,9 @@ show_usage() { nout << "\r"; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::show_options -// Access: Public -// Description: Describes each of the available options to stderr. -//////////////////////////////////////////////////////////////////// +/** + * Describes each of the available options to stderr. + */ void ProgramBase:: show_options() { sort_options(); @@ -173,30 +161,25 @@ show_options() { } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::show_text -// Access: Public -// Description: Formats the indicated text and its prefix for output -// to stderr with the known _terminal_width. -//////////////////////////////////////////////////////////////////// +/** + * Formats the indicated text and its prefix for output to stderr with the + * known _terminal_width. + */ void ProgramBase:: show_text(const string &prefix, int indent_width, string text) { get_terminal_width(); - // This is correct! It goes go to cerr, not to nout. Sending it to - // nout would be cyclic, since nout is redefined to map back through - // this function. + // This is correct! It goes go to cerr, not to nout. Sending it to nout + // would be cyclic, since nout is redefined to map back through this + // function. format_text(cerr, _last_newline, prefix, indent_width, text, _terminal_width); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::write_man_page -// Access: Public -// Description: Generates a man page in nroff syntax based on the -// description and options. This is useful when -// creating a man page for this utility. -//////////////////////////////////////////////////////////////////// +/** + * Generates a man page in nroff syntax based on the description and options. + * This is useful when creating a man page for this utility. + */ void ProgramBase:: write_man_page(ostream &out) { string prog = _program_name.get_basename_wo_extension(); @@ -277,22 +260,18 @@ write_man_page(ostream &out) { } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::parse_command_line -// Access: Public, Virtual -// Description: Dispatches on each of the options on the command -// line, and passes the remaining parameters to -// handle_args(). If an error on the command line is -// detected, will automatically call show_usage() and -// exit(1). -//////////////////////////////////////////////////////////////////// +/** + * Dispatches on each of the options on the command line, and passes the + * remaining parameters to handle_args(). If an error on the command line is + * detected, will automatically call show_usage() and exit(1). + */ void ProgramBase:: parse_command_line(int argc, char **argv) { preprocess_argv(argc, argv); - // Setting this variable to zero reinitializes the options parser - // This is only necessary for processing multiple command lines in - // the same program (mainly the MaxToEgg converter plugin) + // Setting this variable to zero reinitializes the options parser This is + // only necessary for processing multiple command lines in the same program + // (mainly the MaxToEgg converter plugin) extern int optind; optind = 0; @@ -306,8 +285,8 @@ parse_command_line(int argc, char **argv) { _name = _program_name.get_basename_wo_extension(); } - // Catch a special hidden option: -write-man, which causes the tool - // to generate a manual page. + // Catch a special hidden option: -write-man, which causes the tool to + // generate a manual page. if (argc > 1 && strcmp(argv[1], "-write-man") == 0) { if (argc == 2) { write_man_page(cout); @@ -336,18 +315,18 @@ parse_command_line(int argc, char **argv) { pvector long_options; string short_options; - // We also need to build a temporary map of int index numbers to - // Option pointers. We'll pass these index numbers to GNU's - // getopt_long() so we can tell one option from another. + // We also need to build a temporary map of int index numbers to Option + // pointers. We'll pass these index numbers to GNU's getopt_long() so we + // can tell one option from another. typedef pmap Options; Options options; OptionsByName::const_iterator oi; int next_index = 256; - // Let's prefix the option string with "-" to tell getopt that we - // want it to tell us the post-option arguments, instead of trying - // to meddle with ARGC and ARGV (which we aren't using directly). + // Let's prefix the option string with "-" to tell getopt that we want it to + // tell us the post-option arguments, instead of trying to meddle with ARGC + // and ARGV (which we aren't using directly). short_options = "-"; for (oi = _options_by_name.begin(); oi != _options_by_name.end(); ++oi) { @@ -355,8 +334,8 @@ parse_command_line(int argc, char **argv) { int index; if (opt._option.length() == 1) { - // This is a "short" option; its option string consists of only - // one letter. Its index is the letter itself. + // This is a "short" option; its option string consists of only one + // letter. Its index is the letter itself. index = (int)opt._option[0]; short_options += opt._option; @@ -365,8 +344,7 @@ parse_command_line(int argc, char **argv) { short_options += ':'; } } else { - // This is a "long" option; we'll assign it the next available - // index. + // This is a "long" option; we'll assign it the next available index. index = ++next_index; } @@ -377,8 +355,8 @@ parse_command_line(int argc, char **argv) { no_argument : required_argument; gopt.flag = (int *)NULL; - // Return an index into the _options_by_index array, offset by 256 - // so we don't confuse it with '?'. + // Return an index into the _options_by_index array, offset by 256 so we + // don't confuse it with '?'. gopt.val = index; long_options.push_back(gopt); @@ -386,15 +364,14 @@ parse_command_line(int argc, char **argv) { options[index] = &opt; } - // Finally, add one more structure, all zeroes, to indicate the end - // of the options. + // Finally, add one more structure, all zeroes, to indicate the end of the + // options. struct option gopt; memset(&gopt, 0, sizeof(gopt)); long_options.push_back(gopt); - // We'll use this vector to save the non-option arguments. - // Generally, these will all be at the end, but with the GNU - // extensions, they need not be. + // We'll use this vector to save the non-option arguments. Generally, these + // will all be at the end, but with the GNU extensions, they need not be. Args remaining_args; // Now call getopt_long() to actually parse the arguments. @@ -465,13 +442,10 @@ parse_command_line(int argc, char **argv) { } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::get_exec_command -// Access: Public -// Description: Returns the command that invoked this program, as a -// shell-friendly string, suitable for pasting into the -// comments of output files. -//////////////////////////////////////////////////////////////////// +/** + * Returns the command that invoked this program, as a shell-friendly string, + * suitable for pasting into the comments of output files. + */ string ProgramBase:: get_exec_command() const { string command; @@ -516,14 +490,11 @@ get_exec_command() const { } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::handle_args -// Access: Protected, Virtual -// Description: Does something with the additional arguments on the -// command line (after all the -options have been -// parsed). Returns true if the arguments are good, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Does something with the additional arguments on the command line (after all + * the -options have been parsed). Returns true if the arguments are good, + * false otherwise. + */ bool ProgramBase:: handle_args(ProgramBase::Args &args) { if (!args.empty()) { @@ -539,122 +510,93 @@ handle_args(ProgramBase::Args &args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::post_command_line -// Access: Protected, Virtual -// Description: This is called after the command line has been -// completely processed, and it gives the program a -// chance to do some last-minute processing and -// validation of the options and arguments. It should -// return true if everything is fine, false if there is -// an error. -//////////////////////////////////////////////////////////////////// +/** + * This is called after the command line has been completely processed, and it + * gives the program a chance to do some last-minute processing and validation + * of the options and arguments. It should return true if everything is fine, + * false if there is an error. + */ bool ProgramBase:: post_command_line() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::set_program_brief -// Access: Protected -// Description: Sets a brief synopsis of the program's function. -// This is currently only used for generating the -// synopsis of the program's man page. -// -// This should be of the format: -// "perform operation foo on bar files" -//////////////////////////////////////////////////////////////////// +/** + * Sets a brief synopsis of the program's function. This is currently only + * used for generating the synopsis of the program's man page. + * + * This should be of the format: "perform operation foo on bar files" + */ void ProgramBase:: set_program_brief(const string &brief) { _brief = brief; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::set_program_description -// Access: Protected -// Description: Sets the description of the program that will be -// reported by show_usage(). The description should be -// one long string of text. Embedded newline characters -// are interpreted as paragraph breaks and printed as -// blank lines. -//////////////////////////////////////////////////////////////////// +/** + * Sets the description of the program that will be reported by show_usage(). + * The description should be one long string of text. Embedded newline + * characters are interpreted as paragraph breaks and printed as blank lines. + */ void ProgramBase:: set_program_description(const string &description) { _description = description; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::clear_runlines -// Access: Protected -// Description: Removes all of the runlines that were previously -// added, presumably before adding some new ones. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the runlines that were previously added, presumably before + * adding some new ones. + */ void ProgramBase:: clear_runlines() { _runlines.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::add_runline -// Access: Protected -// Description: Adds an additional line to the list of lines that -// will be displayed to describe briefly how the program -// is to be run. Each line should be something like -// "[opts] arg1 arg2", that is, it does *not* include -// the name of the program, but it includes everything -// that should be printed after the name of the program. -// -// Normally there is only one runline for a given -// program, but it is possible to define more than one. -//////////////////////////////////////////////////////////////////// +/** + * Adds an additional line to the list of lines that will be displayed to + * describe briefly how the program is to be run. Each line should be + * something like "[opts] arg1 arg2", that is, it does *not* include the name + * of the program, but it includes everything that should be printed after the + * name of the program. + * + * Normally there is only one runline for a given program, but it is possible + * to define more than one. + */ void ProgramBase:: add_runline(const string &runline) { _runlines.push_back(runline); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::clear_options -// Access: Protected -// Description: Removes all of the options that were previously -// added, presumably before adding some new ones. -// Normally you wouldn't want to do this unless you want -// to completely replace all of the options defined by -// base classes. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the options that were previously added, presumably before + * adding some new ones. Normally you wouldn't want to do this unless you + * want to completely replace all of the options defined by base classes. + */ void ProgramBase:: clear_options() { _options_by_name.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::add_option -// Access: Protected -// Description: Adds (or redefines) a command line option. When -// parse_command_line() is executed it will look for -// these options (followed by a hyphen) on the command -// line; when a particular option is found it will call -// the indicated option_function, supplying the provided -// option_data. This allows the user to define a -// function that does some special behavior for any -// given option, or to use any of a number of generic -// pre-defined functions to fill in data for each -// option. -// -// Each option may or may not take a parameter. If -// parm_name is nonempty, it is assumed that the option -// does take a parameter (and parm_name contains the -// name that will be printed by show_options()). This -// parameter will be supplied as the second parameter to -// the dispatch function. If parm_name is empty, it is -// assumed that the option does not take a parameter. -// There is no provision for optional parameters. -// -// The options are listed first in order by their -// index_group number, and then in the order that -// add_option() was called. This provides a mechanism -// for listing the options defined in derived classes -// before those of the base classes. -//////////////////////////////////////////////////////////////////// +/** + * Adds (or redefines) a command line option. When parse_command_line() is + * executed it will look for these options (followed by a hyphen) on the + * command line; when a particular option is found it will call the indicated + * option_function, supplying the provided option_data. This allows the user + * to define a function that does some special behavior for any given option, + * or to use any of a number of generic pre-defined functions to fill in data + * for each option. + * + * Each option may or may not take a parameter. If parm_name is nonempty, it + * is assumed that the option does take a parameter (and parm_name contains + * the name that will be printed by show_options()). This parameter will be + * supplied as the second parameter to the dispatch function. If parm_name is + * empty, it is assumed that the option does not take a parameter. There is + * no provision for optional parameters. + * + * The options are listed first in order by their index_group number, and then + * in the order that add_option() was called. This provides a mechanism for + * listing the options defined in derived classes before those of the base + * classes. + */ void ProgramBase:: add_option(const string &option, const string &parm_name, int index_group, const string &description, @@ -679,23 +621,18 @@ add_option(const string &option, const string &parm_name, } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::add_option -// Access: Protected -// Description: This is another variant on add_option(), above, -// except that it receives a pointer to a "method", -// which is really just another static (or global) -// function, whose first parameter is a ProgramBase *. -// -// We can't easily add a variant that accepts a real -// method, because the C++ syntax for methods requires -// us to know exactly what class object the method is -// defined for, and we want to support adding pointers -// for methods that are defined in other classes. So we -// have this hacky thing, which requires the "method" to -// be declared static, and receive its this pointer -// explicitly, as the first argument. -//////////////////////////////////////////////////////////////////// +/** + * This is another variant on add_option(), above, except that it receives a + * pointer to a "method", which is really just another static (or global) + * function, whose first parameter is a ProgramBase *. + * + * We can't easily add a variant that accepts a real method, because the C++ + * syntax for methods requires us to know exactly what class object the method + * is defined for, and we want to support adding pointers for methods that are + * defined in other classes. So we have this hacky thing, which requires the + * "method" to be declared static, and receive its this pointer explicitly, as + * the first argument. + */ void ProgramBase:: add_option(const string &option, const string &parm_name, int index_group, const string &description, @@ -720,13 +657,10 @@ add_option(const string &option, const string &parm_name, } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::redescribe_option -// Access: Protected -// Description: Changes the description associated with a -// previously-defined option. Returns true if the -// option was changed, false if it hadn't been defined. -//////////////////////////////////////////////////////////////////// +/** + * Changes the description associated with a previously-defined option. + * Returns true if the option was changed, false if it hadn't been defined. + */ bool ProgramBase:: redescribe_option(const string &option, const string &description) { OptionsByName::iterator oi = _options_by_name.find(option); @@ -737,12 +671,10 @@ redescribe_option(const string &option, const string &description) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::remove_option -// Access: Protected -// Description: Removes a previously-defined option. Returns true if -// the option was removed, false if it hadn't existed. -//////////////////////////////////////////////////////////////////// +/** + * Removes a previously-defined option. Returns true if the option was + * removed, false if it hadn't existed. + */ bool ProgramBase:: remove_option(const string &option) { OptionsByName::iterator oi = _options_by_name.find(option); @@ -754,14 +686,11 @@ remove_option(const string &option) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::add_path_replace_options -// Access: Public -// Description: Adds -pr etc. as valid options for this program. -// These are appropriate for a model converter or model -// reader type program, and specify how to locate -// possibly-invalid pathnames in the source model file. -//////////////////////////////////////////////////////////////////// +/** + * Adds -pr etc. as valid options for this program. These are appropriate + * for a model converter or model reader type program, and specify how to + * locate possibly-invalid pathnames in the source model file. + */ void ProgramBase:: add_path_replace_options() { add_option @@ -795,18 +724,15 @@ add_path_replace_options() { &ProgramBase::dispatch_search_path, NULL, &(_path_replace->_path)); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::add_path_store_options -// Access: Public -// Description: Adds -ps etc. as valid options for this program. -// These are appropriate for a model converter type -// program, and specify how to represent filenames in -// the output file. -//////////////////////////////////////////////////////////////////// +/** + * Adds -ps etc. as valid options for this program. These are appropriate + * for a model converter type program, and specify how to represent filenames + * in the output file. + */ void ProgramBase:: add_path_store_options() { - // If a program has path store options at all, the default path - // store is relative. + // If a program has path store options at all, the default path store is + // relative. _path_replace->_path_store = PS_relative; add_option @@ -822,7 +748,7 @@ add_path_store_options() { "The option may be one of: rel, abs, rel_abs, strip, or keep. If " "either rel or rel_abs is specified, the files are made relative to " "the directory specified by -pd. The default is rel.", - &ProgramBase::dispatch_path_store, &_got_path_store, + &ProgramBase::dispatch_path_store, &_got_path_store, &(_path_replace->_path_store)); add_option @@ -830,7 +756,7 @@ add_path_store_options() { "Specifies the name of a directory to make paths relative to, if " "'-ps rel' or '-ps rel_abs' is specified. If this is omitted, the " "directory name is taken from the name of the output file.", - &ProgramBase::dispatch_filename, &_got_path_directory, + &ProgramBase::dispatch_filename, &_got_path_directory, &(_path_replace->_path_directory)); add_option @@ -838,37 +764,30 @@ add_path_store_options() { "Copies textures and other dependent files into the indicated " "directory. If a relative pathname is specified, it is relative " "to the directory specified with -pd, above.", - &ProgramBase::dispatch_filename, &(_path_replace->_copy_files), + &ProgramBase::dispatch_filename, &(_path_replace->_copy_files), &(_path_replace->_copy_into_directory)); } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_none -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// no parameters, and does nothing special. Typically -// this would be used for a boolean flag, whose presence -// means something and whose absence means something -// else. Use the bool_var parameter to add_option() to -// determine whether the option appears on the command -// line or not. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes no parameters, and does + * nothing special. Typically this would be used for a boolean flag, whose + * presence means something and whose absence means something else. Use the + * bool_var parameter to add_option() to determine whether the option appears + * on the command line or not. + */ bool ProgramBase:: dispatch_none(const string &, const string &, void *) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_true -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// no parameters, and when it is present sets a bool -// variable to the 'true' value. This is another way to -// handle a boolean flag. See also dispatch_none() and -// dispatch_false(). -// -// The data pointer is to a bool variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes no parameters, and when + * it is present sets a bool variable to the 'true' value. This is another + * way to handle a boolean flag. See also dispatch_none() and + * dispatch_false(). + * + * The data pointer is to a bool variable. + */ bool ProgramBase:: dispatch_true(const string &, const string &, void *var) { bool *bp = (bool *)var; @@ -876,17 +795,14 @@ dispatch_true(const string &, const string &, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_false -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// no parameters, and when it is present sets a bool -// variable to the 'false' value. This is another way to -// handle a boolean flag. See also dispatch_none() and -// dispatch_true(). -// -// The data pointer is to a bool variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes no parameters, and when + * it is present sets a bool variable to the 'false' value. This is another + * way to handle a boolean flag. See also dispatch_none() and + * dispatch_true(). + * + * The data pointer is to a bool variable. + */ bool ProgramBase:: dispatch_false(const string &, const string &, void *var) { bool *bp = (bool *)var; @@ -894,15 +810,12 @@ dispatch_false(const string &, const string &, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_count -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// no parameters, but whose presence on the command line -// increments an integer counter for each time it -// appears. -v is often an option that works this way. -// The data pointer is to an int counter variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes no parameters, but + * whose presence on the command line increments an integer counter for each + * time it appears. -v is often an option that works this way. The data + * pointer is to an int counter variable. + */ bool ProgramBase:: dispatch_count(const string &, const string &, void *var) { int *ip = (int *)var; @@ -911,13 +824,10 @@ dispatch_count(const string &, const string &, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_int -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as an -// integer. The data pointer is to an int variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as an integer. The data pointer is to an int variable. + */ bool ProgramBase:: dispatch_int(const string &opt, const string &arg, void *var) { int *ip = (int *)var; @@ -931,13 +841,10 @@ dispatch_int(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_int_pair -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a pair of integer parameters. The data pointer is to -// an array of two integers. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a pair of integer + * parameters. The data pointer is to an array of two integers. + */ bool ProgramBase:: dispatch_int_pair(const string &opt, const string &arg, void *var) { int *ip = (int *)var; @@ -961,13 +868,10 @@ dispatch_int_pair(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_int_quad -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a quad of integer parameters. The data pointer is to -// an array of four integers. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a quad of integer + * parameters. The data pointer is to an array of four integers. + */ bool ProgramBase:: dispatch_int_quad(const string &opt, const string &arg, void *var) { int *ip = (int *)var; @@ -993,13 +897,10 @@ dispatch_int_quad(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_double -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// double. The data pointer is to an double variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a double. The data pointer is to an double variable. + */ bool ProgramBase:: dispatch_double(const string &opt, const string &arg, void *var) { double *ip = (double *)var; @@ -1013,13 +914,10 @@ dispatch_double(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_double_pair -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a pair of double parameters. The data pointer is to -// an array of two doubles. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a pair of double + * parameters. The data pointer is to an array of two doubles. + */ bool ProgramBase:: dispatch_double_pair(const string &opt, const string &arg, void *var) { double *ip = (double *)var; @@ -1043,13 +941,10 @@ dispatch_double_pair(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_double_triple -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a triple of double parameters. The data pointer is to -// an array of three doubles. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a triple of double + * parameters. The data pointer is to an array of three doubles. + */ bool ProgramBase:: dispatch_double_triple(const string &opt, const string &arg, void *var) { double *ip = (double *)var; @@ -1074,13 +969,10 @@ dispatch_double_triple(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_double_quad -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// a quad of double parameters. The data pointer is to -// an array of four doubles. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a quad of double + * parameters. The data pointer is to an array of four doubles. + */ bool ProgramBase:: dispatch_double_quad(const string &opt, const string &arg, void *var) { double *ip = (double *)var; @@ -1106,13 +998,11 @@ dispatch_double_quad(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_color -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes a -// color, as l or l,a or r,g,b or r,g,b,a. The data -// pointer is to an array of four floats, e.g. a LColor. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes a color, as l or l,a or + * r,g,b or r,g,b,a. The data pointer is to an array of four floats, e.g. a + * LColor. + */ bool ProgramBase:: dispatch_color(const string &opt, const string &arg, void *var) { PN_stdfloat *ip = (PN_stdfloat *)var; @@ -1164,13 +1054,10 @@ dispatch_color(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_string -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// string. The data pointer is to a string variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a string. The data pointer is to a string variable. + */ bool ProgramBase:: dispatch_string(const string &, const string &arg, void *var) { string *ip = (string *)var; @@ -1179,18 +1066,14 @@ dispatch_string(const string &, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_vector_string -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// string. This is different from dispatch_string in -// that the parameter may be repeated multiple times, -// and each time the string value is appended to a -// vector. -// -// The data pointer is to a vector_string variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a string. This is different from dispatch_string in + * that the parameter may be repeated multiple times, and each time the string + * value is appended to a vector. + * + * The data pointer is to a vector_string variable. + */ bool ProgramBase:: dispatch_vector_string(const string &, const string &arg, void *var) { vector_string *ip = (vector_string *)var; @@ -1199,15 +1082,13 @@ dispatch_vector_string(const string &, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_vector_string_comma -// Access: Protected, Static -// Description: Similar to dispatch_vector_string, but a comma is -// allowed to separate multiple tokens in one argument, -// without having to repeat the argument for each token. -// -// The data pointer is to a vector_string variable. -//////////////////////////////////////////////////////////////////// +/** + * Similar to dispatch_vector_string, but a comma is allowed to separate + * multiple tokens in one argument, without having to repeat the argument for + * each token. + * + * The data pointer is to a vector_string variable. + */ bool ProgramBase:: dispatch_vector_string_comma(const string &, const string &arg, void *var) { vector_string *ip = (vector_string *)var; @@ -1223,13 +1104,11 @@ dispatch_vector_string_comma(const string &, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_filename -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// filename. The data pointer is to a Filename variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a filename. The data pointer is to a Filename + * variable. + */ bool ProgramBase:: dispatch_filename(const string &opt, const string &arg, void *var) { if (arg.empty()) { @@ -1243,16 +1122,13 @@ dispatch_filename(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_search_path -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// single directory name to add to a search path. The -// data pointer is to a DSearchPath variable. This kind -// of option may appear multiple times on the command -// line; each time, the new directory is appended. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a single directory name to add to a search path. The + * data pointer is to a DSearchPath variable. This kind of option may appear + * multiple times on the command line; each time, the new directory is + * appended. + */ bool ProgramBase:: dispatch_search_path(const string &opt, const string &arg, void *var) { if (arg.empty()) { @@ -1266,14 +1142,11 @@ dispatch_search_path(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_coordinate_system -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// coordinate system string. The data pointer is to a -// CoordinateSystem variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a coordinate system string. The data pointer is to a + * CoordinateSystem variable. + */ bool ProgramBase:: dispatch_coordinate_system(const string &opt, const string &arg, void *var) { CoordinateSystem *ip = (CoordinateSystem *)var; @@ -1289,14 +1162,11 @@ dispatch_coordinate_system(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_units -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// unit of distance measurement. The data pointer is to -// a DistanceUnit variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a unit of distance measurement. The data pointer is + * to a DistanceUnit variable. + */ bool ProgramBase:: dispatch_units(const string &opt, const string &arg, void *var) { DistanceUnit *ip = (DistanceUnit *)var; @@ -1311,14 +1181,11 @@ dispatch_units(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_image_type -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to indicate an image file -// type, like rgb, bmp, jpg, etc. The data pointer is -// to a PNMFileType pointer. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to indicate an image file type, like rgb, bmp, jpg, etc. The data pointer + * is to a PNMFileType pointer. + */ bool ProgramBase:: dispatch_image_type(const string &opt, const string &arg, void *var) { PNMFileType **ip = (PNMFileType **)var; @@ -1337,14 +1204,11 @@ dispatch_image_type(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_path_replace -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// single component of a path replace request. The data -// pointer is to a PathReplace variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a single component of a path replace request. The + * data pointer is to a PathReplace variable. + */ bool ProgramBase:: dispatch_path_replace(const string &opt, const string &arg, void *var) { PathReplace *ip = (PathReplace *)var; @@ -1359,14 +1223,11 @@ dispatch_path_replace(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::dispatch_path_store -// Access: Protected, Static -// Description: Standard dispatch function for an option that takes -// one parameter, which is to be interpreted as a -// path store string. The data pointer is to a -// PathStore variable. -//////////////////////////////////////////////////////////////////// +/** + * Standard dispatch function for an option that takes one parameter, which is + * to be interpreted as a path store string. The data pointer is to a + * PathStore variable. + */ bool ProgramBase:: dispatch_path_store(const string &opt, const string &arg, void *var) { PathStore *ip = (PathStore *)var; @@ -1382,12 +1243,10 @@ dispatch_path_store(const string &opt, const string &arg, void *var) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::handle_help_option -// Access: Protected, Static -// Description: Called when the user enters '-h', this describes how -// to use the program and then exits. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user enters '-h', this describes how to use the program and + * then exits. + */ bool ProgramBase:: handle_help_option(const string &, const string &, void *data) { ProgramBase *me = (ProgramBase *)data; @@ -1400,29 +1259,23 @@ handle_help_option(const string &, const string &, void *data) { } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::format_text -// Access: Protected, Static -// Description: Word-wraps the indicated text to the indicated output -// stream. The first line is prefixed with the -// indicated prefix, then tabbed over to indent_width -// where the text actually begins. A newline is -// inserted at or before column line_width. Each -// subsequent line begins with indent_width spaces. -// -// An embedded newline character ('\n') forces a line -// break, while an embedded carriage-return character -// ('\r'), or two or more consecutive newlines, marks a -// paragraph break, which is usually printed as a blank -// line. Redundant newline and carriage-return -// characters are generally ignored. -// -// The flag last_newline should be initialized to false -// for the first call to format_text, and then preserved -// for future calls; it tracks the state of trailing -// newline characters between calls so we can correctly -// identify doubled newlines. -//////////////////////////////////////////////////////////////////// +/** + * Word-wraps the indicated text to the indicated output stream. The first + * line is prefixed with the indicated prefix, then tabbed over to + * indent_width where the text actually begins. A newline is inserted at or + * before column line_width. Each subsequent line begins with indent_width + * spaces. + * + * An embedded newline character ('\n') forces a line break, while an embedded + * carriage-return character ('\r'), or two or more consecutive newlines, + * marks a paragraph break, which is usually printed as a blank line. + * Redundant newline and carriage-return characters are generally ignored. + * + * The flag last_newline should be initialized to false for the first call to + * format_text, and then preserved for future calls; it tracks the state of + * trailing newline characters between calls so we can correctly identify + * doubled newlines. + */ void ProgramBase:: format_text(ostream &out, bool &last_newline, const string &prefix, int indent_width, @@ -1469,8 +1322,8 @@ format_text(ostream &out, bool &last_newline, last_newline = (!text.empty() && text[text.length() - 1] == '\n'); while (p < text.length()) { - // Look for the paragraph or line break--the next newline - // character, if any. + // Look for the paragraph or line break--the next newline character, if + // any. size_t par = text.find_first_of("\n\r", p); bool is_paragraph_break = false; if (par == string::npos) { @@ -1490,9 +1343,9 @@ format_text(ostream &out, bool &last_newline, eol = par; } else { - // The paragraph doesn't fit completely on the line. Determine - // the best place to break the line. Look for the last space - // before the ideal eol. + // The paragraph doesn't fit completely on the line. Determine the best + // place to break the line. Look for the last space before the ideal + // eol. size_t min_eol = max((int)p, (int)eol - 25); size_t q = eol; while (q > min_eol && !isspace(text[q])) { @@ -1508,8 +1361,8 @@ format_text(ostream &out, bool &last_newline, eol = q + 1; } else { - // The line cannot be broken cleanly. Just let it keep going; - // don't try to wrap it. + // The line cannot be broken cleanly. Just let it keep going; don't + // try to wrap it. eol = par; } } @@ -1529,8 +1382,8 @@ format_text(ostream &out, bool &last_newline, // Print the paragraph break as a blank line. out << "\n"; if (p >= text.length()) { - // If we end on a paragraph break, don't try to insert a new - // one in the next pass. + // If we end on a paragraph break, don't try to insert a new one in + // the next pass. last_newline = false; } } @@ -1540,13 +1393,10 @@ format_text(ostream &out, bool &last_newline, } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::sort_options -// Access: Private -// Description: Puts all the options in order by index number -// (e.g. in the order they were added, within -// index_groups), for output by show_options(). -//////////////////////////////////////////////////////////////////// +/** + * Puts all the options in order by index number (e.g. in the order they were + * added, within index_groups), for output by show_options(). + */ void ProgramBase:: sort_options() { if (!_sorted_options) { @@ -1563,12 +1413,9 @@ sort_options() { } } -//////////////////////////////////////////////////////////////////// -// Function: ProgramBase::get_terminal_width -// Access: Private -// Description: Attempts to determine the ideal terminal width for -// formatting output. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to determine the ideal terminal width for formatting output. + */ void ProgramBase:: get_terminal_width() { if (!_got_terminal_width) { @@ -1584,14 +1431,14 @@ get_terminal_width() { // complaining, just punt. _terminal_width = default_terminal_width; } else { - + // Subtract 10% for the comfort margin at the edge. _terminal_width = size.ws_col - min(8, (int)(size.ws_col * 0.1)); } return; } #endif // IOCTL_TERMINAL_WIDTH - + _terminal_width = default_terminal_width; } } diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index dc58d98e01..e6b166172c 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -1,16 +1,15 @@ -// Filename: programBase.h -// Created by: drose (13Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file programBase.h + * @author drose + * @date 2000-02-13 + */ #ifndef PROGRAMBASE_H #define PROGRAMBASE_H @@ -27,13 +26,11 @@ #include "pdeque.h" #include "pmap.h" -//////////////////////////////////////////////////////////////////// -// Class : ProgramBase -// Description : This is intended to be the base class for most -// general-purpose utility programs in the PANDATOOL -// tree. It automatically handles things like -// command-line arguments in a portable way. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be the base class for most general-purpose utility + * programs in the PANDATOOL tree. It automatically handles things like + * command-line arguments in a portable way. + */ class ProgramBase { public: ProgramBase(const string &name = string()); @@ -166,5 +163,3 @@ private: #include "programBase.I" #endif - - diff --git a/pandatool/src/progbase/test_prog.cxx b/pandatool/src/progbase/test_prog.cxx index b64c4ffac7..7a4cd02529 100644 --- a/pandatool/src/progbase/test_prog.cxx +++ b/pandatool/src/progbase/test_prog.cxx @@ -1,16 +1,15 @@ -// Filename: test_prog.cxx -// Created by: drose (14Feb00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file test_prog.cxx + * @author drose + * @date 2000-02-14 + */ #include "programBase.h" diff --git a/pandatool/src/progbase/withOutputFile.I b/pandatool/src/progbase/withOutputFile.I index 6a1399c94f..1daa84871f 100644 --- a/pandatool/src/progbase/withOutputFile.I +++ b/pandatool/src/progbase/withOutputFile.I @@ -1,24 +1,20 @@ -// Filename: withOutputFile.I -// Created by: drose (01Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file withOutputFile.I + * @author drose + * @date 2003-10-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::set_binary_output -// Access: Protected -// Description: Changes the flag specifying whether the output file -// is to be opened in binary mode or not. -//////////////////////////////////////////////////////////////////// +/** + * Changes the flag specifying whether the output file is to be opened in + * binary mode or not. + */ INLINE void WithOutputFile:: set_binary_output(bool binary_output) { _binary_output = binary_output; diff --git a/pandatool/src/progbase/withOutputFile.cxx b/pandatool/src/progbase/withOutputFile.cxx index 61a786ff07..7ff8ea60d9 100644 --- a/pandatool/src/progbase/withOutputFile.cxx +++ b/pandatool/src/progbase/withOutputFile.cxx @@ -1,16 +1,15 @@ -// Filename: withOutputFile.cxx -// Created by: drose (11Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file withOutputFile.cxx + * @author drose + * @date 2001-04-11 + */ #include "withOutputFile.h" #include "executionEnvironment.h" @@ -18,11 +17,9 @@ #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WithOutputFile:: WithOutputFile(bool allow_last_param, bool allow_stdout, bool binary_output) { @@ -34,11 +31,9 @@ WithOutputFile(bool allow_last_param, bool allow_stdout, _owns_output_ptr = false; } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WithOutputFile:: ~WithOutputFile() { if (_owns_output_ptr) { @@ -47,13 +42,10 @@ WithOutputFile:: } } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::get_output -// Access: Public -// Description: Returns an output stream that corresponds to the -// user's intended egg file output--either stdout, or -// the named output file. -//////////////////////////////////////////////////////////////////// +/** + * Returns an output stream that corresponds to the user's intended egg file + * output--either stdout, or the named output file. + */ ostream &WithOutputFile:: get_output() { if (_output_ptr == (ostream *)NULL) { @@ -74,8 +66,8 @@ get_output() { bool pz_file = false; #ifdef HAVE_ZLIB if (_output_filename.get_extension() == "pz") { - // The filename ends in .pz, which means to automatically compress - // the file that we write. + // The filename ends in .pz, which means to automatically compress the + // file that we write. pz_file = true; } #endif // HAVE_ZLIB @@ -106,13 +98,10 @@ get_output() { return *_output_ptr; } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::close_output -// Access: Public -// Description: Closes the output stream previously opened by -// get_output(). A subsequent call to get_output() will -// open a new stream. -//////////////////////////////////////////////////////////////////// +/** + * Closes the output stream previously opened by get_output(). A subsequent + * call to get_output() will open a new stream. + */ void WithOutputFile:: close_output() { if (_owns_output_ptr) { @@ -125,25 +114,19 @@ close_output() { -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::has_output_filename -// Access: Public -// Description: Returns true if the user specified an output -// filename, false otherwise (e.g. the output file is -// implicitly stdout). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the user specified an output filename, false otherwise + * (e.g. the output file is implicitly stdout). + */ bool WithOutputFile:: has_output_filename() const { return _got_output_filename; } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::get_output_filename -// Access: Public -// Description: If has_output_filename() returns true, this is the -// filename that the user specified. Otherwise, it -// returns the empty string. -//////////////////////////////////////////////////////////////////// +/** + * If has_output_filename() returns true, this is the filename that the user + * specified. Otherwise, it returns the empty string. + */ Filename WithOutputFile:: get_output_filename() const { if (_got_output_filename) { @@ -152,19 +135,15 @@ get_output_filename() const { return Filename(); } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::check_last_arg -// Access: Protected -// Description: Checks if the last filename on the argument list is -// a file with the expected extension (if -// _allow_last_param was set true), and removes it from -// the argument list if it is. Returns true if the -// arguments are good, false if something is invalid. -// -// minimum_args is the number of arguments we know must -// be input parameters and therefore cannot be -// interpreted as output filenames. -//////////////////////////////////////////////////////////////////// +/** + * Checks if the last filename on the argument list is a file with the + * expected extension (if _allow_last_param was set true), and removes it from + * the argument list if it is. Returns true if the arguments are good, false + * if something is invalid. + * + * minimum_args is the number of arguments we know must be input parameters + * and therefore cannot be interpreted as output filenames. + */ bool WithOutputFile:: check_last_arg(ProgramBase::Args &args, int minimum_args) { if (_allow_last_param && !_got_output_filename && @@ -197,20 +176,15 @@ check_last_arg(ProgramBase::Args &args, int minimum_args) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WithOutputFile::verify_output_file_safe -// Access: Protected -// Description: This is called when the output file is given as the -// last parameter on the command line. Since this is a -// fairly dangerous way to specify the output file (it's -// easy to accidentally overwrite an input file this -// way), the convention is to disallow this syntax if -// the output file already exists. -// -// This function will test if the output file exists, -// and issue a warning message if it does, returning -// false. If all is well, it will return true. -//////////////////////////////////////////////////////////////////// +/** + * This is called when the output file is given as the last parameter on the + * command line. Since this is a fairly dangerous way to specify the output + * file (it's easy to accidentally overwrite an input file this way), the + * convention is to disallow this syntax if the output file already exists. + * + * This function will test if the output file exists, and issue a warning + * message if it does, returning false. If all is well, it will return true. + */ bool WithOutputFile:: verify_output_file_safe() const { nassertr(_got_output_filename, false); diff --git a/pandatool/src/progbase/withOutputFile.h b/pandatool/src/progbase/withOutputFile.h index f2f9009a5d..d77627ffa7 100644 --- a/pandatool/src/progbase/withOutputFile.h +++ b/pandatool/src/progbase/withOutputFile.h @@ -1,16 +1,15 @@ -// Filename: withOutputFile.h -// Created by: drose (11Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file withOutputFile.h + * @author drose + * @date 2001-04-11 + */ #ifndef WITHOUTPUTFILE_H #define WITHOUTPUTFILE_H @@ -20,16 +19,13 @@ #include "programBase.h" #include "filename.h" -//////////////////////////////////////////////////////////////////// -// Class : WithOutputFile -// Description : This is the bare functionality (intended to be -// inherited from along with ProgramBase or some -// derivative) for a program that might generate an -// output file. -// -// This provides the has_output_filename() and -// get_output_filename() methods. -//////////////////////////////////////////////////////////////////// +/** + * This is the bare functionality (intended to be inherited from along with + * ProgramBase or some derivative) for a program that might generate an output + * file. + * + * This provides the has_output_filename() and get_output_filename() methods. + */ class WithOutputFile { public: WithOutputFile(bool allow_last_param, bool allow_stdout, @@ -64,5 +60,3 @@ private: #include "withOutputFile.I" #endif - - diff --git a/pandatool/src/progbase/wordWrapStream.cxx b/pandatool/src/progbase/wordWrapStream.cxx index 650a150241..a3ac50b99b 100644 --- a/pandatool/src/progbase/wordWrapStream.cxx +++ b/pandatool/src/progbase/wordWrapStream.cxx @@ -1,25 +1,22 @@ -// Filename: wordWrapStream.cxx -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wordWrapStream.cxx + * @author drose + * @date 2000-06-28 + */ #include "wordWrapStream.h" -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStream::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WordWrapStream:: WordWrapStream(ProgramBase *program) : ostream(&_lsb), diff --git a/pandatool/src/progbase/wordWrapStream.h b/pandatool/src/progbase/wordWrapStream.h index d97aa3e59e..af5c2f90ab 100644 --- a/pandatool/src/progbase/wordWrapStream.h +++ b/pandatool/src/progbase/wordWrapStream.h @@ -1,16 +1,15 @@ -// Filename: wordWrapStream.h -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wordWrapStream.h + * @author drose + * @date 2000-06-28 + */ #ifndef WORDWRAPSTREAM_H #define WORDWRAPSTREAM_H @@ -19,19 +18,15 @@ #include "wordWrapStreamBuf.h" -//////////////////////////////////////////////////////////////////// -// Class : WordWrapStream -// Description : A special ostream that formats all of its output -// through ProgramBase::show_text(). This allows the -// program to easily word-wrap its output messages to -// fit the terminal width. -// -// By convention (inherited from show_text), a newline -// written to the WordWrapStream indicates a paragraph -// break, and is generally printed as a blank line. To -// force a line break without a paragraph break, use -// '\r'. -//////////////////////////////////////////////////////////////////// +/** + * A special ostream that formats all of its output through + * ProgramBase::show_text(). This allows the program to easily word-wrap its + * output messages to fit the terminal width. + * + * By convention (inherited from show_text), a newline written to the + * WordWrapStream indicates a paragraph break, and is generally printed as a + * blank line. To force a line break without a paragraph break, use '\r'. + */ class WordWrapStream : public ostream { public: WordWrapStream(ProgramBase *program); diff --git a/pandatool/src/progbase/wordWrapStreamBuf.I b/pandatool/src/progbase/wordWrapStreamBuf.I index ef80d522b0..67a0f68812 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.I +++ b/pandatool/src/progbase/wordWrapStreamBuf.I @@ -1,28 +1,22 @@ -// Filename: wordWrapStreamBuf.I -// Created by: drose (01Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wordWrapStreamBuf.I + * @author drose + * @date 2000-07-01 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::set_literal_mode -// Access: Private -// Description: An internal function called to update the internal -// state according to the current value of the -// Notify::literal flag, which might or might not be set -// of the ostream at any time. When the literal flag is -// true, we should not word-wrap, so toggling this flag -// means we need to flush the current buffer. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called to update the internal state according to the + * current value of the Notify::literal flag, which might or might not be set + * of the ostream at any time. When the literal flag is true, we should not + * word-wrap, so toggling this flag means we need to flush the current buffer. + */ INLINE void WordWrapStreamBuf:: set_literal_mode(bool mode) { if (mode != _literal_mode) { @@ -30,4 +24,3 @@ set_literal_mode(bool mode) { _literal_mode = mode; } } - diff --git a/pandatool/src/progbase/wordWrapStreamBuf.cxx b/pandatool/src/progbase/wordWrapStreamBuf.cxx index 6a9fa2aaf2..4280a3d394 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.cxx +++ b/pandatool/src/progbase/wordWrapStreamBuf.cxx @@ -1,16 +1,15 @@ -// Filename: wordWrapStreamBuf.cxx -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wordWrapStreamBuf.cxx + * @author drose + * @date 2000-06-28 + */ #include "wordWrapStreamBuf.h" #include "wordWrapStream.h" @@ -23,11 +22,9 @@ typedef int streamsize; #endif -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WordWrapStreamBuf:: WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program) : _owner(owner), @@ -36,23 +33,18 @@ WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program) : _literal_mode = false; } -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WordWrapStreamBuf:: ~WordWrapStreamBuf() { sync(); } -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::sync -// Access: Public, Virtual -// Description: Called by the system ostream implementation when the -// buffer should be flushed to output (for instance, on -// destruction). -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when the buffer should be + * flushed to output (for instance, on destruction). + */ int WordWrapStreamBuf:: sync() { streamsize n = pptr() - pbase(); @@ -64,12 +56,10 @@ sync() { return 0; // EOF to indicate write full. } -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::overflow -// Access: Public, Virtual -// Description: Called by the system ostream implementation when its -// internal buffer is filled, plus one character. -//////////////////////////////////////////////////////////////////// +/** + * Called by the system ostream implementation when its internal buffer is + * filled, plus one character. + */ int WordWrapStreamBuf:: overflow(int ch) { streamsize n = pptr() - pbase(); @@ -88,13 +78,10 @@ overflow(int ch) { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::write_chars -// Access: Public -// Description: An internal function called by sync() and overflow() -// to store one or more characters written to the stream -// into the memory buffer. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by sync() and overflow() to store one or more + * characters written to the stream into the memory buffer. + */ void WordWrapStreamBuf:: write_chars(const char *start, int length) { if (length > 0) { @@ -115,13 +102,10 @@ write_chars(const char *start, int length) { } } -//////////////////////////////////////////////////////////////////// -// Function: WordWrapStreamBuf::flush_data -// Access: Private -// Description: Writes the contents of _data to the actual output -// stream, either word-wrapped or not as appropriate, -// and empties the contents of _data. -//////////////////////////////////////////////////////////////////// +/** + * Writes the contents of _data to the actual output stream, either word- + * wrapped or not as appropriate, and empties the contents of _data. + */ void WordWrapStreamBuf:: flush_data() { if (!_data.empty()) { diff --git a/pandatool/src/progbase/wordWrapStreamBuf.h b/pandatool/src/progbase/wordWrapStreamBuf.h index 1fbeec4ca7..506f72a6ea 100644 --- a/pandatool/src/progbase/wordWrapStreamBuf.h +++ b/pandatool/src/progbase/wordWrapStreamBuf.h @@ -1,16 +1,15 @@ -// Filename: wordWrapStreamBuf.h -// Created by: drose (28Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file wordWrapStreamBuf.h + * @author drose + * @date 2000-06-28 + */ #ifndef WORDWRAPSTREAMBUF_H #define WORDWRAPSTREAMBUF_H @@ -22,11 +21,10 @@ class ProgramBase; class WordWrapStream; -//////////////////////////////////////////////////////////////////// -// Class : WordWrapStreamBuf -// Description : Used by WordWrapStream to implement an ostream that -// flushes its output to ProgramBase::show_text(). -//////////////////////////////////////////////////////////////////// +/** + * Used by WordWrapStream to implement an ostream that flushes its output to + * ProgramBase::show_text(). + */ class WordWrapStreamBuf : public streambuf { public: WordWrapStreamBuf(WordWrapStream *owner, ProgramBase *program); diff --git a/pandatool/src/pstatserver/pStatClientData.cxx b/pandatool/src/pstatserver/pStatClientData.cxx index cffeb3f1b3..4a3520b63f 100644 --- a/pandatool/src/pstatserver/pStatClientData.cxx +++ b/pandatool/src/pstatserver/pStatClientData.cxx @@ -1,16 +1,15 @@ -// Filename: pStatClientData.cxx -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientData.cxx + * @author drose + * @date 2000-07-11 + */ #include "pStatClientData.h" #include "pStatReader.h" @@ -21,11 +20,9 @@ PStatCollectorDef PStatClientData::_null_collector(-1, "Unknown"); -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientData:: PStatClientData(PStatReader *reader) : _reader(reader) @@ -33,11 +30,9 @@ PStatClientData(PStatReader *reader) : _is_alive = true; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatClientData:: ~PStatClientData() { Collectors::const_iterator ci; @@ -46,23 +41,18 @@ PStatClientData:: } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::is_alive -// Access: Public -// Description: Returns true if the data is actively getting filled -// by a connected client, or false if the client has -// terminated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the data is actively getting filled by a connected client, + * or false if the client has terminated. + */ bool PStatClientData:: is_alive() const { return _is_alive; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::close -// Access: Public -// Description: Closes the client connection if it is open. -//////////////////////////////////////////////////////////////////// +/** + * Closes the client connection if it is open. + */ void PStatClientData:: close() { if (_is_alive && _reader != (PStatReader *)NULL) { @@ -72,36 +62,28 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_num_collectors -// Access: Public -// Description: Returns the total number of collectors the Data -// knows about. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of collectors the Data knows about. + */ int PStatClientData:: get_num_collectors() const { return _collectors.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::has_collector -// Access: Public -// Description: Returns true if the indicated collector has been -// defined by the client already, false otherwise. It -// is possible for the client to start streaming data -// before all of the collectors have been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated collector has been defined by the client + * already, false otherwise. It is possible for the client to start streaming + * data before all of the collectors have been defined. + */ bool PStatClientData:: has_collector(int index) const { return (index >= 0 && index < (int)_collectors.size() && _collectors[index]._def != (PStatCollectorDef *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_collector_def -// Access: Public -// Description: Returns the nth collector definition. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth collector definition. + */ const PStatCollectorDef &PStatClientData:: get_collector_def(int index) const { if (!has_collector(index)) { @@ -110,11 +92,9 @@ get_collector_def(int index) const { return *_collectors[index]._def; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_collector_name -// Access: Public -// Description: Returns the name of the indicated collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated collector. + */ string PStatClientData:: get_collector_name(int index) const { if (!has_collector(index)) { @@ -124,14 +104,11 @@ get_collector_name(int index) const { return def->_name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_collector_fullname -// Access: Public -// Description: Returns the "full name" of the indicated collector. -// This will be the concatenation of all of the -// collector's parents' names (except Frame) and the -// collector's own name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the "full name" of the indicated collector. This will be the + * concatenation of all of the collector's parents' names (except Frame) and + * the collector's own name. + */ string PStatClientData:: get_collector_fullname(int index) const { if (!has_collector(index)) { @@ -146,16 +123,12 @@ get_collector_fullname(int index) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::set_collector_has_level -// Access: Public -// Description: Indicates whether the given collector has level data -// (and consequently, whether it should appear on the -// Levels menu). -// -// The return value is true if anything changed, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Indicates whether the given collector has level data (and consequently, + * whether it should appear on the Levels menu). + * + * The return value is true if anything changed, false otherwise. + */ bool PStatClientData:: set_collector_has_level(int index, int thread_index, bool flag) { bool any_changed = false; @@ -167,8 +140,8 @@ set_collector_has_level(int index, int thread_index, bool flag) { _collectors[index]._is_level.set_bit_to(thread_index, flag); } - // Turning this on for a given collector also implicitly turns all - // of its ancestors. + // Turning this on for a given collector also implicitly turns all of its + // ancestors. if (flag) { PStatCollectorDef *def = _collectors[index]._def; if (def != (PStatCollectorDef *)NULL && def->_parent_index != 0) { @@ -182,75 +155,58 @@ set_collector_has_level(int index, int thread_index, bool flag) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_collector_has_level -// Access: Public -// Description: Returns whether the given collector has level data -// (and consequently, whether it should appear on the -// Levels menu). -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the given collector has level data (and consequently, + * whether it should appear on the Levels menu). + */ bool PStatClientData:: get_collector_has_level(int index, int thread_index) const { return (index >= 0 && index < (int)_collectors.size() && _collectors[index]._is_level.get_bit(thread_index)); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_num_toplevel_collectors -// Access: Public -// Description: Returns the total number of collectors that are -// toplevel collectors. These are the collectors that -// are the children of "Frame", which is collector 0. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of collectors that are toplevel collectors. These + * are the collectors that are the children of "Frame", which is collector 0. + */ int PStatClientData:: get_num_toplevel_collectors() const { return _toplevel_collectors.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_toplevel_collector -// Access: Public -// Description: Returns the collector index of the nth toplevel -// collector. Use this function to iterate through the -// n toplevel collectors indicated by -// get_num_toplevel_collectors(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index of the nth toplevel collector. Use this + * function to iterate through the n toplevel collectors indicated by + * get_num_toplevel_collectors(). + */ int PStatClientData:: get_toplevel_collector(int n) const { nassertr(n >= 0 && n < (int)_toplevel_collectors.size(), 0); return _toplevel_collectors[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_num_threads -// Access: Public -// Description: Returns the total number of threads the Data -// knows about. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of threads the Data knows about. + */ int PStatClientData:: get_num_threads() const { return _threads.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::has_thread -// Access: Public -// Description: Returns true if the indicated thread has been -// defined by the client already, false otherwise. It -// is possible for the client to start streaming data -// before all of the threads have been defined. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated thread has been defined by the client + * already, false otherwise. It is possible for the client to start streaming + * data before all of the threads have been defined. + */ bool PStatClientData:: has_thread(int index) const { return (index >= 0 && index < (int)_threads.size() && !_threads[index]._name.empty()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_thread_name -// Access: Public -// Description: Returns the name of the indicated thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated thread. + */ string PStatClientData:: get_thread_name(int index) const { if (!has_thread(index)) { @@ -259,13 +215,10 @@ get_thread_name(int index) const { return _threads[index]._name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_thread_data -// Access: Public -// Description: Returns the data associated with the indicated -// thread. This will create a thread definition if it -// does not already exist. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data associated with the indicated thread. This will create a + * thread definition if it does not already exist. + */ const PStatThreadData *PStatClientData:: get_thread_data(int index) const { ((PStatClientData *)this)->define_thread(index); @@ -273,17 +226,13 @@ get_thread_data(int index) const { return _threads[index]._data; } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::get_child_distance -// Access: Public -// Description: Returns the number of Collectors between the -// indicated parent and the child Collector in the -// relationship graph. If child is the same as parent, -// returns zero. If child is an immediate child of -// parent, returns 1. If child is a grandchild of -// parent, returns 2, and so on. If child is not a -// descendant of parent at all, returns -1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of Collectors between the indicated parent and the child + * Collector in the relationship graph. If child is the same as parent, + * returns zero. If child is an immediate child of parent, returns 1. If + * child is a grandchild of parent, returns 2, and so on. If child is not a + * descendant of parent at all, returns -1. + */ int PStatClientData:: get_child_distance(int parent, int child) const { if (parent == child) { @@ -300,16 +249,13 @@ get_child_distance(int parent, int child) const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::add_collector -// Access: Public -// Description: Adds a new collector definition to the dataset. -// Presumably this is information just arrived from the -// client. -// -// The pointer will become owned by the PStatClientData -// object and will be freed on destruction. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new collector definition to the dataset. Presumably this is + * information just arrived from the client. + * + * The pointer will become owned by the PStatClientData object and will be + * freed on destruction. + */ void PStatClientData:: add_collector(PStatCollectorDef *def) { slot_collector(def->_index); @@ -323,8 +269,8 @@ add_collector(PStatCollectorDef *def) { _collectors[def->_index]._def = def; update_toplevel_collectors(); - // If we already had the _is_level flag set, it should be - // immediately applied to all ancestors. + // If we already had the _is_level flag set, it should be immediately + // applied to all ancestors. const BitArray &is_level = _collectors[def->_index]._is_level; int max_threads = is_level.get_num_bits(); for (int thread_index = 0; thread_index < max_threads; ++thread_index) { @@ -334,13 +280,10 @@ add_collector(PStatCollectorDef *def) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::define_thread -// Access: Public -// Description: Adds a new thread definition to the dataset. -// Presumably this is information just arrived from the -// client. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new thread definition to the dataset. Presumably this is + * information just arrived from the client. + */ void PStatClientData:: define_thread(int thread_index, const string &name) { // A sanity check on the index number. @@ -361,16 +304,13 @@ define_thread(int thread_index, const string &name) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::record_new_frame -// Access: Public -// Description: Makes room for and stores a new frame's worth of -// data associated with some particular thread (which -// may or may not have already been defined). -// -// The pointer will become owned by the PStatThreadData -// object and will be freed on destruction. -//////////////////////////////////////////////////////////////////// +/** + * Makes room for and stores a new frame's worth of data associated with some + * particular thread (which may or may not have already been defined). + * + * The pointer will become owned by the PStatThreadData object and will be + * freed on destruction. + */ void PStatClientData:: record_new_frame(int thread_index, int frame_number, PStatFrameData *frame_data) { @@ -379,12 +319,10 @@ record_new_frame(int thread_index, int frame_number, _threads[thread_index]._data->record_new_frame(frame_number, frame_data); } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::slot_collector -// Access: Private -// Description: Makes sure there is an entry in the array for a -// collector with the given index number. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure there is an entry in the array for a collector with the given + * index number. + */ void PStatClientData:: slot_collector(int collector_index) { // A sanity check on the index number. @@ -397,11 +335,9 @@ slot_collector(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatClientData::update_toplevel_collectors -// Access: Private -// Description: Rebuilds the list of toplevel collectors. -//////////////////////////////////////////////////////////////////// +/** + * Rebuilds the list of toplevel collectors. + */ void PStatClientData:: update_toplevel_collectors() { _toplevel_collectors.clear(); diff --git a/pandatool/src/pstatserver/pStatClientData.h b/pandatool/src/pstatserver/pStatClientData.h index 0a6b0b8481..2d4ab293d5 100644 --- a/pandatool/src/pstatserver/pStatClientData.h +++ b/pandatool/src/pstatserver/pStatClientData.h @@ -1,16 +1,15 @@ -// Filename: pStatClientData.h -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatClientData.h + * @author drose + * @date 2000-07-11 + */ #ifndef PSTATCLIENTDATA_H #define PSTATCLIENTDATA_H @@ -29,12 +28,11 @@ class PStatReader; -//////////////////////////////////////////////////////////////////// -// Class : PStatClientData -// Description : The data associated with a particular client, but not -// with any one particular frame or thread: the list of -// collectors and threads, for instance. -//////////////////////////////////////////////////////////////////// +/** + * The data associated with a particular client, but not with any one + * particular frame or thread: the list of collectors and threads, for + * instance. + */ class PStatClientData : public PStatClientVersion { public: PStatClientData(PStatReader *reader); @@ -86,7 +84,7 @@ private: typedef vector_int ToplevelCollectors; ToplevelCollectors _toplevel_collectors; - + class Thread { public: string _name; @@ -100,4 +98,3 @@ private: }; #endif - diff --git a/pandatool/src/pstatserver/pStatGraph.I b/pandatool/src/pstatserver/pStatGraph.I index 35d421c20e..b198296fd7 100644 --- a/pandatool/src/pstatserver/pStatGraph.I +++ b/pandatool/src/pstatserver/pStatGraph.I @@ -1,80 +1,63 @@ -// Filename: pStatGraph.I -// Created by: drose (19Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatGraph.I + * @author drose + * @date 2000-07-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_monitor -// Access: Public -// Description: Returns the monitor associated with this chart. -//////////////////////////////////////////////////////////////////// +/** + * Returns the monitor associated with this chart. + */ INLINE PStatMonitor *PStatGraph:: get_monitor() const { return _monitor; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_num_labels -// Access: Public -// Description: Returns the number of labels to be drawn for this -// chart. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of labels to be drawn for this chart. + */ INLINE int PStatGraph:: get_num_labels() const { return _labels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_label_collector -// Access: Public -// Description: Returns the collector index associated with the nth -// label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index associated with the nth label. + */ INLINE int PStatGraph:: get_label_collector(int n) const { nassertr(n >= 0 && n < (int)_labels.size(), 0); return _labels[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_label_name -// Access: Public -// Description: Returns the text associated with the nth label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the text associated with the nth label. + */ INLINE string PStatGraph:: get_label_name(int n) const { nassertr(n >= 0 && n < (int)_labels.size(), string()); return _monitor->get_client_data()->get_collector_name(_labels[n]); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_label_color -// Access: Public -// Description: Returns the color associated with the nth label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color associated with the nth label. + */ INLINE LRGBColor PStatGraph:: get_label_color(int n) const { nassertr(n >= 0 && n < (int)_labels.size(), LRGBColor(0.0, 0.0, 0.0)); return _monitor->get_collector_color(_labels[n]); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::set_target_frame_rate -// Access: Public -// Description: Sets the target frame rate of the application in Hz. -// This only affects the choice of initial scale and the -// placement of guide bars. -//////////////////////////////////////////////////////////////////// +/** + * Sets the target frame rate of the application in Hz. This only affects the + * choice of initial scale and the placement of guide bars. + */ INLINE void PStatGraph:: set_target_frame_rate(double frame_rate) { if (_target_frame_rate != frame_rate) { @@ -83,44 +66,35 @@ set_target_frame_rate(double frame_rate) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_target_frame_rate -// Access: Public -// Description: Returns the indicated target frame rate in Hz. See -// set_target_frame_rate(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the indicated target frame rate in Hz. See + * set_target_frame_rate(). + */ INLINE double PStatGraph:: get_target_frame_rate() const { return _target_frame_rate; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_xsize -// Access: Public -// Description: Returns the width of the chart in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the chart in pixels. + */ INLINE int PStatGraph:: get_xsize() const { return _xsize; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_ysize -// Access: Public -// Description: Returns the height of the chart in pixels. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the chart in pixels. + */ INLINE int PStatGraph:: get_ysize() const { return _ysize; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::set_guide_bar_units -// Access: Public -// Description: Sets the units that are displayed for the guide bar -// labels. This may be a union of one or more members -// of the GuideBarUnits enum. -//////////////////////////////////////////////////////////////////// +/** + * Sets the units that are displayed for the guide bar labels. This may be a + * union of one or more members of the GuideBarUnits enum. + */ INLINE void PStatGraph:: set_guide_bar_units(int guide_bar_units) { if (_guide_bar_units != guide_bar_units) { @@ -129,37 +103,28 @@ set_guide_bar_units(int guide_bar_units) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_guide_bar_units -// Access: Public -// Description: Returns the units that are displayed for the guide bar -// labels. This may be a union of one or more members -// of the GuideBarUnits enum. -//////////////////////////////////////////////////////////////////// +/** + * Returns the units that are displayed for the guide bar labels. This may be + * a union of one or more members of the GuideBarUnits enum. + */ INLINE int PStatGraph:: get_guide_bar_units() const { return _guide_bar_units; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::set_guide_bar_unit_name -// Access: Public -// Description: Sets the name of the units to be used for the guide -// bars if the units type is set to GBU_named | -// GBU_show_units. -//////////////////////////////////////////////////////////////////// +/** + * Sets the name of the units to be used for the guide bars if the units type + * is set to GBU_named | GBU_show_units. + */ INLINE void PStatGraph:: set_guide_bar_unit_name(const string &unit_name) { _unit_name = unit_name; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_guide_bar_unit_name -// Access: Public -// Description: Returns the name of the units to be used for the guide -// bars if the units type is set to GBU_named | -// GBU_show_units. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the units to be used for the guide bars if the units + * type is set to GBU_named | GBU_show_units. + */ INLINE const string &PStatGraph:: get_guide_bar_unit_name() const { return _unit_name; diff --git a/pandatool/src/pstatserver/pStatGraph.cxx b/pandatool/src/pstatserver/pStatGraph.cxx index df94bb3b7d..a216950117 100644 --- a/pandatool/src/pstatserver/pStatGraph.cxx +++ b/pandatool/src/pstatserver/pStatGraph.cxx @@ -1,16 +1,15 @@ -// Filename: pStatGraph.cxx -// Created by: drose (19Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatGraph.cxx + * @author drose + * @date 2000-07-19 + */ #include "pStatGraph.h" #include "pStatServer.h" @@ -21,11 +20,9 @@ #include // for sprintf -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::GuideBar::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatGraph::GuideBar:: GuideBar(double height, const string &label, PStatGraph::GuideBarStyle style) : _height(height), @@ -34,11 +31,9 @@ GuideBar(double height, const string &label, PStatGraph::GuideBarStyle style) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::GuideBar::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatGraph::GuideBar:: GuideBar(const PStatGraph::GuideBar ©) : _height(copy._height), @@ -47,11 +42,9 @@ GuideBar(const PStatGraph::GuideBar ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatGraph:: PStatGraph(PStatMonitor *monitor, int xsize, int ysize) : _monitor(monitor), @@ -64,39 +57,30 @@ PStatGraph(PStatMonitor *monitor, int xsize, int ysize) : _guide_bar_units = GBU_ms; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatGraph:: ~PStatGraph() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_num_guide_bars -// Access: Public -// Description: Returns the number of horizontal guide bars that -// should be drawn, based on the indicated target frame -// rate. Not all of these may be visible; some may be -// off the top of the chart because of the vertical -// scale. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of horizontal guide bars that should be drawn, based on + * the indicated target frame rate. Not all of these may be visible; some may + * be off the top of the chart because of the vertical scale. + */ int PStatGraph:: get_num_guide_bars() const { return _guide_bars.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_guide_bar -// Access: Public -// Description: Returns the nth horizontal guide bar. This should be -// drawn as a horizontal line across the chart at the y -// pixel location determined by height_to_pixel(bar._height). -// -// It is possible that this bar will be off the top of -// the chart. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth horizontal guide bar. This should be drawn as a horizontal + * line across the chart at the y pixel location determined by + * height_to_pixel(bar._height). + * + * It is possible that this bar will be off the top of the chart. + */ const PStatGraph::GuideBar &PStatGraph:: get_guide_bar(int n) const { #ifndef NDEBUG @@ -106,80 +90,63 @@ get_guide_bar(int n) const { return _guide_bars[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_num_user_guide_bars -// Access: Public -// Description: Returns the current number of user-defined guide -// bars. Not all of these may be visible. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of user-defined guide bars. Not all of these + * may be visible. + */ int PStatGraph:: get_num_user_guide_bars() const { return _monitor->get_server()->get_num_user_guide_bars(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::get_user_guide_bar -// Access: Public -// Description: Returns the nth user-defined guide bar. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth user-defined guide bar. + */ PStatGraph::GuideBar PStatGraph:: get_user_guide_bar(int n) const { double height = _monitor->get_server()->get_user_guide_bar_height(n); return make_guide_bar(height, GBS_user); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::move_user_guide_bar -// Access: Public -// Description: Adjusts the height of the nth user-defined guide bar. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the height of the nth user-defined guide bar. + */ void PStatGraph:: move_user_guide_bar(int n, double height) { _monitor->get_server()->move_user_guide_bar(n, height); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::add_user_guide_bar -// Access: Public -// Description: Creates a new user guide bar and returns its index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new user guide bar and returns its index number. + */ int PStatGraph:: add_user_guide_bar(double height) { return _monitor->get_server()->add_user_guide_bar(height); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::remove_user_guide_bar -// Access: Public -// Description: Removes the user guide bar with the indicated index -// number. All subsequent index numbers are adjusted -// down one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the user guide bar with the indicated index number. All subsequent + * index numbers are adjusted down one. + */ void PStatGraph:: remove_user_guide_bar(int n) { _monitor->get_server()->remove_user_guide_bar(n); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::find_user_guide_bar -// Access: Public -// Description: Returns the index number of the first user guide bar -// found whose height is within the indicated range, or -// -1 if no user guide bars fall within the range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first user guide bar found whose height is + * within the indicated range, or -1 if no user guide bars fall within the + * range. + */ int PStatGraph:: find_user_guide_bar(double from_height, double to_height) const { return _monitor->get_server()->find_user_guide_bar(from_height, to_height); } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::format_number -// Access: Public, Static -// Description: Returns a string representing the value nicely -// formatted for its range. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the value nicely formatted for its range. + */ string PStatGraph:: format_number(double value) { char buffer[128]; @@ -199,20 +166,16 @@ format_number(double value) { return buffer; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::format_number -// Access: Public, Static -// Description: Returns a string representing the value nicely -// formatted for its range, including the units -// as indicated. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string representing the value nicely formatted for its range, + * including the units as indicated. + */ string PStatGraph:: format_number(double value, int guide_bar_units, const string &unit_name) { string label; if ((guide_bar_units & GBU_named) != 0) { - // Units are whatever is specified by unit_name, not a time unit - // at all. + // Units are whatever is specified by unit_name, not a time unit at all. label = format_number(value); if ((guide_bar_units & GBU_show_units) != 0 && !unit_name.empty()) { label += " "; @@ -248,22 +211,20 @@ format_number(double value, int guide_bar_units, const string &unit_name) { return label; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::update_guide_bars -// Access: Protected -// Description: Resets the list of guide bars. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of guide bars. + */ void PStatGraph:: update_guide_bars(int num_bars, double scale) { _guide_bars.clear(); - // We'd like to draw about num_bars bars on the chart. But we also - // want the bars to be harmonics of the target frame rate, so that - // the bottom bar is at tfr/n or n * tfr, where n is an integer, and - // the upper bars are even multiples of that. + // We'd like to draw about num_bars bars on the chart. But we also want the + // bars to be harmonics of the target frame rate, so that the bottom bar is + // at tfrn or n * tfr, where n is an integer, and the upper bars are even + // multiples of that. - // Choose a suitable harmonic of the target frame rate near the - // bottom part of the chart. + // Choose a suitable harmonic of the target frame rate near the bottom part + // of the chart. double bottom = (double)num_bars / scale; @@ -273,11 +234,11 @@ update_guide_bars(int num_bars, double scale) { harmonic = floor(bottom / _target_frame_rate + 0.5) * _target_frame_rate; } else { - // tfr / n + // tfr n harmonic = _target_frame_rate / floor(_target_frame_rate / bottom + 0.5); } - // Now, make a few bars at k / harmonic. + // Now, make a few bars at k harmonic. for (int k = 1; k / harmonic <= scale; k++) { _guide_bars.push_back(make_guide_bar(k / harmonic)); } @@ -285,20 +246,16 @@ update_guide_bars(int num_bars, double scale) { _guide_bars_changed = true; } -//////////////////////////////////////////////////////////////////// -// Function: PStatGraph::make_guide_bar -// Access: Protected -// Description: Makes a guide bar for the indicated elapsed time or -// level units. -//////////////////////////////////////////////////////////////////// +/** + * Makes a guide bar for the indicated elapsed time or level units. + */ PStatGraph::GuideBar PStatGraph:: make_guide_bar(double value, PStatGraph::GuideBarStyle style) const { string label = format_number(value, _guide_bar_units, _unit_name); if ((style == GBS_normal) && (_guide_bar_units & GBU_named) == 0) { - // If it's a time unit, check to see if it matches our target - // frame rate. + // If it's a time unit, check to see if it matches our target frame rate. double hz = 1.0 / value; if (IS_THRESHOLD_EQUAL(hz, _target_frame_rate, 0.001)) { style = GBS_target; diff --git a/pandatool/src/pstatserver/pStatGraph.h b/pandatool/src/pstatserver/pStatGraph.h index b4347dc7bf..b7d907f52b 100644 --- a/pandatool/src/pstatserver/pStatGraph.h +++ b/pandatool/src/pstatserver/pStatGraph.h @@ -1,16 +1,15 @@ -// Filename: pStatGraph.h -// Created by: drose (19Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatGraph.h + * @author drose + * @date 2000-07-19 + */ #ifndef PSTATGRAPH_H #define PSTATGRAPH_H @@ -27,12 +26,10 @@ class PStatView; -//////////////////////////////////////////////////////////////////// -// Class : PStatGraph -// Description : This is an abstract base class for several different -// kinds of graphs that have a few things in common, -// like labels and guide bars. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class for several different kinds of graphs that + * have a few things in common, like labels and guide bars. + */ class PStatGraph { public: PStatGraph(PStatMonitor *monitor, int xsize, int ysize); @@ -56,7 +53,7 @@ public: GBS_target, GBS_user, }; - + class GuideBar { public: GuideBar(double height, const string &label, GuideBarStyle style); @@ -108,8 +105,8 @@ protected: int _xsize; int _ysize; - // Table of the collectors that should be drawn as labels, in order - // from bottom to top. + // Table of the collectors that should be drawn as labels, in order from + // bottom to top. typedef vector_int Labels; Labels _labels; diff --git a/pandatool/src/pstatserver/pStatListener.cxx b/pandatool/src/pstatserver/pStatListener.cxx index a5f7677b8c..417ad5495d 100644 --- a/pandatool/src/pstatserver/pStatListener.cxx +++ b/pandatool/src/pstatserver/pStatListener.cxx @@ -1,26 +1,23 @@ -// Filename: pStatListener.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatListener.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatListener.h" #include "pStatServer.h" #include "pStatReader.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatListener::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatListener:: PStatListener(PStatServer *manager) : ConnectionListener(manager, manager->is_thread_safe() ? 1 : 0), @@ -28,12 +25,10 @@ PStatListener(PStatServer *manager) : { } -//////////////////////////////////////////////////////////////////// -// Function: PStatListener::connection_opened -// Access: Protected, Virtual -// Description: An internal function called by ConnectionListener() -// when a new TCP connection has been established. -//////////////////////////////////////////////////////////////////// +/** + * An internal function called by ConnectionListener() when a new TCP + * connection has been established. + */ void PStatListener:: connection_opened(const PT(Connection) &, const NetAddress &address, @@ -46,8 +41,7 @@ connection_opened(const PT(Connection) &, nout << "Got new connection from " << address << "\n"; - // Make sure this connection doesn't queue up TCP packets we write - // to it. + // Make sure this connection doesn't queue up TCP packets we write to it. new_connection->set_collect_tcp(false); PStatReader *reader = new PStatReader(_manager, monitor); diff --git a/pandatool/src/pstatserver/pStatListener.h b/pandatool/src/pstatserver/pStatListener.h index 57721a79ab..b4d27690be 100644 --- a/pandatool/src/pstatserver/pStatListener.h +++ b/pandatool/src/pstatserver/pStatListener.h @@ -1,16 +1,15 @@ -// Filename: pStatListener.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatListener.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATLISTENER_H #define PSTATLISTENER_H @@ -23,12 +22,10 @@ class PStatServer; class PStatMonitor; -//////////////////////////////////////////////////////////////////// -// Class : PStatListener -// Description : This is the TCP rendezvous socket listener. We need -// one of these to listen for new connections on the -// socket(s) added to the PStatServer. -//////////////////////////////////////////////////////////////////// +/** + * This is the TCP rendezvous socket listener. We need one of these to listen + * for new connections on the socket(s) added to the PStatServer. + */ class PStatListener : public ConnectionListener { public: PStatListener(PStatServer *manager); diff --git a/pandatool/src/pstatserver/pStatMonitor.I b/pandatool/src/pstatserver/pStatMonitor.I index 3880e2a5d6..2b23d43a43 100644 --- a/pandatool/src/pstatserver/pStatMonitor.I +++ b/pandatool/src/pstatserver/pStatMonitor.I @@ -1,44 +1,35 @@ -// Filename: pStatMonitor.I -// Created by: drose (14Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatMonitor.I + * @author drose + * @date 2000-07-14 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_server -// Access: Public -// Description: Returns the server that owns this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the server that owns this monitor. + */ INLINE PStatServer *PStatMonitor:: get_server() { return _server; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_client_data -// Access: Public -// Description: Returns the client data associated with this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the client data associated with this monitor. + */ INLINE const PStatClientData *PStatMonitor:: get_client_data() const { return _client_data; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_collector_name -// Access: Public -// Description: Returns the name of the indicated collector, if it is -// known. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the indicated collector, if it is known. + */ INLINE string PStatMonitor:: get_collector_name(int collector_index) { if (!_client_data.is_null() && @@ -48,40 +39,32 @@ get_collector_name(int collector_index) { return "Unknown"; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::is_client_known -// Access: Public -// Description: Returns true if we've yet received the "hello" -// message from the client indicating its name, etc. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we've yet received the "hello" message from the client + * indicating its name, etc. + */ INLINE bool PStatMonitor:: is_client_known() const { return _client_known; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_client_hostname -// Access: Public -// Description: Returns the hostname of the client we're connected -// to, if known. This may not be known immediately at -// creation time, but should be learned shortly -// thereafter when we receive the client's "hello" -// message. See is_client_known(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the hostname of the client we're connected to, if known. This may + * not be known immediately at creation time, but should be learned shortly + * thereafter when we receive the client's "hello" message. See + * is_client_known(). + */ INLINE string PStatMonitor:: get_client_hostname() const { return _client_hostname; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_client_progname -// Access: Public -// Description: Returns the program name of the client we're -// connected to, if known. This may not be known -// immediately at creation time, but should be learned -// shortly thereafter when we receive the client's -// "hello" message. See is_client_known(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the program name of the client we're connected to, if known. This + * may not be known immediately at creation time, but should be learned + * shortly thereafter when we receive the client's "hello" message. See + * is_client_known(). + */ INLINE string PStatMonitor:: get_client_progname() const { return _client_progname; diff --git a/pandatool/src/pstatserver/pStatMonitor.cxx b/pandatool/src/pstatserver/pStatMonitor.cxx index b631dcd934..f7e70727fe 100644 --- a/pandatool/src/pstatserver/pStatMonitor.cxx +++ b/pandatool/src/pstatserver/pStatMonitor.cxx @@ -1,48 +1,40 @@ -// Filename: pStatMonitor.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatMonitor.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatMonitor.h" #include "pStatCollectorDef.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatMonitor:: PStatMonitor(PStatServer *server) : _server(server) { _client_known = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatMonitor:: ~PStatMonitor() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::hello_from -// Access: Public -// Description: Called shortly after startup time with the greeting -// from the client. This indicates the client's -// reported hostname and program name. -//////////////////////////////////////////////////////////////////// +/** + * Called shortly after startup time with the greeting from the client. This + * indicates the client's reported hostname and program name. + */ void PStatMonitor:: hello_from(const string &hostname, const string &progname) { _client_known = true; @@ -51,15 +43,12 @@ hello_from(const string &hostname, const string &progname) { got_hello(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::bad_version -// Access: Public -// Description: Called shortly after startup time with the greeting -// from the client. In this case, the client seems to -// have an incompatible version and will be -// automatically disconnected; the server should issue a -// message to that effect. -//////////////////////////////////////////////////////////////////// +/** + * Called shortly after startup time with the greeting from the client. In + * this case, the client seems to have an incompatible version and will be + * automatically disconnected; the server should issue a message to that + * effect. + */ void PStatMonitor:: bad_version(const string &hostname, const string &progname, int client_major, int client_minor, @@ -71,24 +60,19 @@ bad_version(const string &hostname, const string &progname, server_major, server_minor); } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::set_client_data -// Access: Public -// Description: Called by the PStatServer at setup time to set the -// new data pointer for the first time. -//////////////////////////////////////////////////////////////////// +/** + * Called by the PStatServer at setup time to set the new data pointer for the + * first time. + */ void PStatMonitor:: set_client_data(PStatClientData *client_data) { _client_data = client_data; initialized(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::is_alive -// Access: Public -// Description: Returns true if the client is alive and connected, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the client is alive and connected, false otherwise. + */ bool PStatMonitor:: is_alive() const { if (_client_data.is_null()) { @@ -98,11 +82,9 @@ is_alive() const { return _client_data->is_alive(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::close -// Access: Public -// Description: Closes the client connection if it is active. -//////////////////////////////////////////////////////////////////// +/** + * Closes the client connection if it is active. + */ void PStatMonitor:: close() { if (!_client_data.is_null()) { @@ -110,15 +92,12 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_collector_color -// Access: Public -// Description: Returns the color associated with the indicated -// collector. If the collector has no associated color, -// or is unknown, a new color will be made up on the -// spot and associated with this collector for the rest -// of the session. -//////////////////////////////////////////////////////////////////// +/** + * Returns the color associated with the indicated collector. If the + * collector has no associated color, or is unknown, a new color will be made + * up on the spot and associated with this collector for the rest of the + * session. + */ const LRGBColor &PStatMonitor:: get_collector_color(int collector_index) { Colors::iterator ci; @@ -141,9 +120,9 @@ get_collector_color(int collector_index) { return (*ci).second; } - // Use the fullname of the collector as a hash to seed the random - // number generator (consulted below), so we get the same color - // for a given name across sessions. + // Use the fullname of the collector as a hash to seed the random number + // generator (consulted below), so we get the same color for a given name + // across sessions. string fullname = _client_data->get_collector_fullname(collector_index); unsigned int hash = 0; for (string::const_iterator ci = fullname.begin(); ci != fullname.end(); ++ci) { @@ -162,14 +141,11 @@ get_collector_color(int collector_index) { return (*ci).second; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_view -// Access: Public -// Description: Returns a view on the given thread index. If there -// is no such view already for the indicated thread, -// this will create one. This view can be used to -// examine the accumulated data for the given thread. -//////////////////////////////////////////////////////////////////// +/** + * Returns a view on the given thread index. If there is no such view already + * for the indicated thread, this will create one. This view can be used to + * examine the accumulated data for the given thread. + */ PStatView &PStatMonitor:: get_view(int thread_index) { Views::iterator vi; @@ -181,14 +157,11 @@ get_view(int thread_index) { return (*vi).second; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::get_level_view -// Access: Public -// Description: Returns a view on the level value (as opposed to -// elapsed time) for the given collector over the given -// thread. If there is no such view already for the -// indicated thread, this will create one. -//////////////////////////////////////////////////////////////////// +/** + * Returns a view on the level value (as opposed to elapsed time) for the + * given collector over the given thread. If there is no such view already + * for the indicated thread, this will create one. + */ PStatView &PStatMonitor:: get_level_view(int collector_index, int thread_index) { LevelViews::iterator lvi; @@ -208,147 +181,111 @@ get_level_view(int collector_index, int thread_index) { return (*vi).second; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::initialized -// Access: Public, Virtual -// Description: Called after the monitor has been fully set up. At -// this time, it will have a valid _client_data pointer, -// and things like is_alive() and close() will be -// meaningful. However, we may not yet know who we're -// connected to (is_client_known() may return false), -// and we may not know anything about the threads or -// collectors we're about to get data on. -//////////////////////////////////////////////////////////////////// +/** + * Called after the monitor has been fully set up. At this time, it will have + * a valid _client_data pointer, and things like is_alive() and close() will + * be meaningful. However, we may not yet know who we're connected to + * (is_client_known() may return false), and we may not know anything about + * the threads or collectors we're about to get data on. + */ void PStatMonitor:: initialized() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::got_hello -// Access: Public, Virtual -// Description: Called when the "hello" message has been received -// from the client. At this time, the client's hostname -// and program name will be known. -//////////////////////////////////////////////////////////////////// +/** + * Called when the "hello" message has been received from the client. At this + * time, the client's hostname and program name will be known. + */ void PStatMonitor:: got_hello() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::got_bad_version -// Access: Public, Virtual -// Description: Like got_hello(), this is called when the "hello" -// message has been received from the client. At this -// time, the client's hostname and program name will be -// known. However, the client appears to be an -// incompatible version and the connection will be -// terminated; the monitor should issue a message to -// that effect. -//////////////////////////////////////////////////////////////////// +/** + * Like got_hello(), this is called when the "hello" message has been received + * from the client. At this time, the client's hostname and program name will + * be known. However, the client appears to be an incompatible version and + * the connection will be terminated; the monitor should issue a message to + * that effect. + */ void PStatMonitor:: got_bad_version(int, int, int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. Generally, the client will -// send all of its collectors over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Collector -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + * Generally, the client will send all of its collectors over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Collector definitions midstream. + */ void PStatMonitor:: new_collector(int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::new_thread -// Access: Public, Virtual -// Description: Called whenever a new Thread definition is -// received from the client. Generally, the client will -// send all of its threads over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Thread -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Thread definition is received from the client. + * Generally, the client will send all of its threads over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Thread definitions midstream. + */ void PStatMonitor:: new_thread(int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no guarantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. The use of the -// PStatFrameData / PStatView objects to report the data -// will facilitate this. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no guarantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. The use of the PStatFrameData / PStatView objects to report the + * data will facilitate this. + */ void PStatMonitor:: new_data(int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::lost_connection -// Access: Public, Virtual -// Description: Called whenever the connection to the client has been -// lost. This is a permanent state change. The monitor -// should update its display to represent this, and may -// choose to close down automatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the connection to the client has been lost. This is a + * permanent state change. The monitor should update its display to represent + * this, and may choose to close down automatically. + */ void PStatMonitor:: lost_connection() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::idle -// Access: Public, Virtual -// Description: If has_idle() returns true, this will be called -// periodically to allow the monitor to update its -// display or whatever it needs to do. -//////////////////////////////////////////////////////////////////// +/** + * If has_idle() returns true, this will be called periodically to allow the + * monitor to update its display or whatever it needs to do. + */ void PStatMonitor:: idle() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::has_idle -// Access: Public, Virtual -// Description: Should be redefined to return true if you want to -// redefine idle() and expect it to be called. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true if you want to redefine idle() and + * expect it to be called. + */ bool PStatMonitor:: has_idle() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::is_thread_safe -// Access: Public, Virtual -// Description: Should be redefined to return true if this monitor -// class can handle running in a sub-thread. -// -// This is not related to the question of whether it can -// handle multiple different PStatThreadDatas; this is -// strictly a question of whether or not the monitor -// itself wants to run in a sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true if this monitor class can handle running + * in a sub-thread. + * + * This is not related to the question of whether it can handle multiple + * different PStatThreadDatas; this is strictly a question of whether or not + * the monitor itself wants to run in a sub-thread. + */ bool PStatMonitor:: is_thread_safe() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatMonitor::user_guide_bars_changed -// Access: Public, Virtual -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void PStatMonitor:: user_guide_bars_changed() { } diff --git a/pandatool/src/pstatserver/pStatMonitor.h b/pandatool/src/pstatserver/pStatMonitor.h index 5f11c6d2d8..cd4a012069 100644 --- a/pandatool/src/pstatserver/pStatMonitor.h +++ b/pandatool/src/pstatserver/pStatMonitor.h @@ -1,16 +1,15 @@ -// Filename: pStatMonitor.h -// Created by: drose (08Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatMonitor.h + * @author drose + * @date 2000-07-08 + */ #ifndef PSTATMONITOR_H #define PSTATMONITOR_H @@ -29,21 +28,18 @@ class PStatCollectorDef; class PStatServer; -//////////////////////////////////////////////////////////////////// -// Class : PStatMonitor -// Description : This is an abstract class that presents the interface -// to any number of different front-ends for the stats -// monitor. One of these will be created by the -// PStatMonitor as each client is connected; this class -// is responsible for opening up a new strip-chart graph -// or whatever is appropriate. It defines a number of -// empty virtual functions that will be called as new -// data becomes available. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class that presents the interface to any number of + * different front-ends for the stats monitor. One of these will be created + * by the PStatMonitor as each client is connected; this class is responsible + * for opening up a new strip-chart graph or whatever is appropriate. It + * defines a number of empty virtual functions that will be called as new data + * becomes available. + */ class PStatMonitor : public ReferenceCount { public: - // The following functions are primarily for use by internal classes - // to set up the monitor. + // The following functions are primarily for use by internal classes to set + // up the monitor. PStatMonitor(PStatServer *server); virtual ~PStatMonitor(); @@ -54,8 +50,8 @@ public: void set_client_data(PStatClientData *client_data); - // The following functions are for use by user code to determine - // information about the client data available. + // The following functions are for use by user code to determine information + // about the client data available. bool is_alive() const; void close(); @@ -72,8 +68,8 @@ public: PStatView &get_level_view(int collector_index, int thread_index); - // The following virtual methods may be overridden by a derived - // monitor class to customize behavior. + // The following virtual methods may be overridden by a derived monitor + // class to customize behavior. virtual string get_monitor_name()=0; diff --git a/pandatool/src/pstatserver/pStatPianoRoll.I b/pandatool/src/pstatserver/pStatPianoRoll.I index 6104a8dee9..f0d3fe15cd 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.I +++ b/pandatool/src/pstatserver/pStatPianoRoll.I @@ -1,23 +1,20 @@ -// Filename: pStatPianoRoll.I -// Created by: drose (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatPianoRoll.I + * @author drose + * @date 2000-07-18 + */ -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::set_horizontal_scale -// Access: Public -// Description: Changes the amount of time the width of the -// horizontal axis represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the amount of time the width of the horizontal axis represents. + * This may force a redraw. + */ INLINE void PStatPianoRoll:: set_horizontal_scale(double time_width) { if (_time_width != time_width) { @@ -27,54 +24,44 @@ set_horizontal_scale(double time_width) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::get_horizontal_scale -// Access: Public -// Description: Returns the amount of total time the width of the -// horizontal axis represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of total time the width of the horizontal axis + * represents. + */ INLINE double PStatPianoRoll:: get_horizontal_scale() const { return _time_width; } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::timestamp_to_pixel -// Access: Public -// Description: Converts a timestamp to a horizontal pixel offset. -//////////////////////////////////////////////////////////////////// +/** + * Converts a timestamp to a horizontal pixel offset. + */ INLINE int PStatPianoRoll:: timestamp_to_pixel(double time) const { return (int)((double)_xsize * (time - _start_time) / _time_width); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::pixel_to_timestamp -// Access: Public -// Description: Converts a horizontal pixel offset to a timestamp. -//////////////////////////////////////////////////////////////////// +/** + * Converts a horizontal pixel offset to a timestamp. + */ INLINE double PStatPianoRoll:: pixel_to_timestamp(int x) const { return _time_width * (double)x / (double)_xsize + _start_time; } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::height_to_pixel -// Access: Public -// Description: Converts a value (i.e. a "height" in the strip chart) -// to a horizontal pixel offset. -//////////////////////////////////////////////////////////////////// +/** + * Converts a value (i.e. a "height" in the strip chart) to a horizontal + * pixel offset. + */ INLINE int PStatPianoRoll:: height_to_pixel(double value) const { return (int)((double)_xsize * value / _time_width); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::pixel_to_height -// Access: Public -// Description: Converts a horizontal pixel offset to a value (a -// "height" in the strip chart). -//////////////////////////////////////////////////////////////////// +/** + * Converts a horizontal pixel offset to a value (a "height" in the strip + * chart). + */ INLINE double PStatPianoRoll:: pixel_to_height(int x) const { return _time_width * (double)x / (double)_xsize; diff --git a/pandatool/src/pstatserver/pStatPianoRoll.cxx b/pandatool/src/pstatserver/pStatPianoRoll.cxx index 8f4a1a8dd3..517fca358a 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.cxx +++ b/pandatool/src/pstatserver/pStatPianoRoll.cxx @@ -1,16 +1,15 @@ -// Filename: pStatPianoRoll.cxx -// Created by: drose (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatPianoRoll.cxx + * @author drose + * @date 2000-07-18 + */ #include "pStatPianoRoll.h" @@ -21,35 +20,28 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::BarBuilder::Constructor -// Access: Public -// Description: This class is used internally to build up the set of -// color bars defined by a frame's worth of data. -//////////////////////////////////////////////////////////////////// +/** + * This class is used internally to build up the set of color bars defined by + * a frame's worth of data. + */ PStatPianoRoll::BarBuilder:: BarBuilder() { _is_new = true; } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::BarBuilder::clear -// Access: Public -// Description: Resets the data in the BarBuilder for a new frame. -//////////////////////////////////////////////////////////////////// +/** + * Resets the data in the BarBuilder for a new frame. + */ void PStatPianoRoll::BarBuilder:: clear() { _is_new = false; _color_bars.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::BarBuilder::add_data_point -// Access: Public -// Description: Adds a new data point. The first data point for a -// given collector turns in on (starts the bar), the -// second data point turns it off (ends the bar). -//////////////////////////////////////////////////////////////////// +/** + * Adds a new data point. The first data point for a given collector turns in + * on (starts the bar), the second data point turns it off (ends the bar). + */ void PStatPianoRoll::BarBuilder:: add_data_point(double time, bool is_start) { if (is_start) { @@ -64,8 +56,7 @@ add_data_point(double time, bool is_start) { } else { // This is a "stop" data point: end the bar. if (_color_bars.empty()) { - // A "stop" in the middle of the frame implies a "start" at time - // 0. + // A "stop" in the middle of the frame implies a "start" at time 0. ColorBar bar; bar._start = 0.0; bar._end = time; @@ -77,12 +68,10 @@ add_data_point(double time, bool is_start) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::BarBuilder::finish -// Access: Public -// Description: Makes sure that each start-bar data point was matched -// by a corresponding end-bar data point. -//////////////////////////////////////////////////////////////////// +/** + * Makes sure that each start-bar data point was matched by a corresponding + * end-bar data point. + */ void PStatPianoRoll::BarBuilder:: finish(double time) { if (!_color_bars.empty() && _color_bars.back()._end < 0.0) { @@ -90,11 +79,9 @@ finish(double time) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatPianoRoll:: PStatPianoRoll(PStatMonitor *monitor, int thread_index, int xsize, int ysize) : PStatGraph(monitor, xsize, ysize), @@ -108,26 +95,22 @@ PStatPianoRoll(PStatMonitor *monitor, int thread_index, int xsize, int ysize) : normal_guide_bars(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatPianoRoll:: ~PStatPianoRoll() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::update -// Access: Public -// Description: Updates the chart with the latest data. -//////////////////////////////////////////////////////////////////// +/** + * Updates the chart with the latest data. + */ void PStatPianoRoll:: update() { const PStatClientData *client_data = _monitor->get_client_data(); - // Don't bother to update the thread data until we know at least - // something about the collectors and threads. + // Don't bother to update the thread data until we know at least something + // about the collectors and threads. if (client_data->get_num_collectors() != 0 && client_data->get_num_threads() != 0) { const PStatThreadData *thread_data = @@ -145,14 +128,11 @@ update() { idle(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::changed_size -// Access: Protected -// Description: To be called by the user class when the widget size -// has changed. This updates the chart's internal data -// and causes it to issue redraw commands to reflect the -// new size. -//////////////////////////////////////////////////////////////////// +/** + * To be called by the user class when the widget size has changed. This + * updates the chart's internal data and causes it to issue redraw commands to + * reflect the new size. + */ void PStatPianoRoll:: changed_size(int xsize, int ysize) { if (xsize != _xsize || ysize != _ysize) { @@ -164,12 +144,10 @@ changed_size(int xsize, int ysize) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::force_redraw -// Access: Protected -// Description: To be called by the user class when the whole thing -// needs to be redrawn for some reason. -//////////////////////////////////////////////////////////////////// +/** + * To be called by the user class when the whole thing needs to be redrawn for + * some reason. + */ void PStatPianoRoll:: force_redraw() { if (!_labels.empty()) { @@ -190,88 +168,67 @@ force_redraw() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::normal_guide_bars -// Access: Protected, Virtual -// Description: Calls update_guide_bars with parameters suitable to -// this kind of graph. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_guide_bars with parameters suitable to this kind of graph. + */ void PStatPianoRoll:: normal_guide_bars() { // We want vaguely 100 pixels between guide bars. update_guide_bars(get_xsize() / 100, _time_width); } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::begin_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called before drawing any bars in the chart. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called before + * drawing any bars in the chart. + */ void PStatPianoRoll:: begin_draw() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::begin_row -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called before drawing any one row of bars. -// These bars correspond to the collector whose index is -// get_row_collector(row), and in the color -// get_row_color(row). -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called before + * drawing any one row of bars. These bars correspond to the collector whose + * index is get_row_collector(row), and in the color get_row_color(row). + */ void PStatPianoRoll:: begin_row(int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::draw_bar -// Access: Protected, Virtual -// Description: Draws a single bar in the chart for the indicated -// row, in the color get_row_color(row), for the -// indicated horizontal pixel range. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single bar in the chart for the indicated row, in the color + * get_row_color(row), for the indicated horizontal pixel range. + */ void PStatPianoRoll:: draw_bar(int, int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::end_row -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called after drawing a series of color bars -// for a single row. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called after + * drawing a series of color bars for a single row. + */ void PStatPianoRoll:: end_row(int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::end_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called after drawing a series of color bars -// in the chart. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called after + * drawing a series of color bars in the chart. + */ void PStatPianoRoll:: end_draw() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::idle -// Access: Protected, Virtual -// Description: Should be overridden by the user class to perform any -// other updates might be necessary after the bars have -// been redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to perform any other updates might + * be necessary after the bars have been redrawn. + */ void PStatPianoRoll:: idle() { } -// STL function object for sorting labels in order by the collector's -// sort index, used in compute_page(), below. +// STL function object for sorting labels in order by the collector's sort +// index, used in compute_page(), below. class SortCollectorLabels1 { public: SortCollectorLabels1(const PStatClientData *client_data) : @@ -285,19 +242,15 @@ public: const PStatClientData *_client_data; }; -//////////////////////////////////////////////////////////////////// -// Function: PStatPianoRoll::compute_page -// Access: Private -// Description: Examines the given frame data and rebuilds the -// _page_data to match it. -//////////////////////////////////////////////////////////////////// +/** + * Examines the given frame data and rebuilds the _page_data to match it. + */ void PStatPianoRoll:: compute_page(const PStatFrameData &frame_data) { _start_time = frame_data.get_start(); - // Clear out the page data and copy it to previous, so we can fill - // it up again and then check to see if we changed the set of bars - // this frame. + // Clear out the page data and copy it to previous, so we can fill it up + // again and then check to see if we changed the set of bars this frame. PageData previous; _page_data.swap(previous); @@ -324,8 +277,8 @@ compute_page(const PStatFrameData &frame_data) { } if (changed_bars) { - // If we added or removed some new bars this time, we'll have to - // update our list. + // If we added or removed some new bars this time, we'll have to update + // our list. const PStatClientData *client_data = _monitor->get_client_data(); _labels.clear(); diff --git a/pandatool/src/pstatserver/pStatPianoRoll.h b/pandatool/src/pstatserver/pStatPianoRoll.h index ef3110c90d..e1c597dccf 100644 --- a/pandatool/src/pstatserver/pStatPianoRoll.h +++ b/pandatool/src/pstatserver/pStatPianoRoll.h @@ -1,16 +1,15 @@ -// Filename: pStatPianoRoll.h -// Created by: drose (18Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatPianoRoll.h + * @author drose + * @date 2000-07-18 + */ #ifndef PSTATPIANOROLL_H #define PSTATPIANOROLL_H @@ -28,18 +27,14 @@ class PStatFrameData; -//////////////////////////////////////////////////////////////////// -// Class : PStatPianoRoll -// Description : This is an abstract class that presents the interface -// for drawing a piano-roll type chart: it shows the -// time spent in each of a number of collectors as a -// horizontal bar of color, with time as the horizontal -// axis. -// -// This class just manages all the piano-roll logic; the -// actual nuts and bolts of drawing pixels is left to a -// user-derived class. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class that presents the interface for drawing a piano- + * roll type chart: it shows the time spent in each of a number of collectors + * as a horizontal bar of color, with time as the horizontal axis. + * + * This class just manages all the piano-roll logic; the actual nuts and bolts + * of drawing pixels is left to a user-derived class. + */ class PStatPianoRoll : public PStatGraph { public: PStatPianoRoll(PStatMonitor *monitor, int thread_index, diff --git a/pandatool/src/pstatserver/pStatReader.cxx b/pandatool/src/pstatserver/pStatReader.cxx index 05e27265b9..7dbab59e74 100644 --- a/pandatool/src/pstatserver/pStatReader.cxx +++ b/pandatool/src/pstatserver/pStatReader.cxx @@ -1,16 +1,15 @@ -// Filename: pStatReader.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatReader.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatReader.h" #include "pStatServer.h" @@ -24,11 +23,9 @@ #include "datagramIterator.h" #include "connectionManager.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatReader:: PStatReader(PStatServer *manager, PStatMonitor *monitor) : #ifdef HAVE_THREADS @@ -47,38 +44,30 @@ PStatReader(PStatServer *manager, PStatMonitor *monitor) : _monitor->set_client_data(_client_data); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatReader:: ~PStatReader() { _manager->release_udp_port(_udp_port); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::close -// Access: Public -// Description: This will be called by the PStatClientData in -// response to its close() call. It will tell the -// server to let go of the reader so it can shut down -// its connection. -//////////////////////////////////////////////////////////////////// +/** + * This will be called by the PStatClientData in response to its close() call. + * It will tell the server to let go of the reader so it can shut down its + * connection. + */ void PStatReader:: close() { _manager->remove_reader(_tcp_connection, this); lost_connection(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::set_tcp_connection -// Access: Public -// Description: This is intended to be called only once, immediately -// after construction, by the PStatListener that created -// it. It tells the reader about the newly-established -// TCP connection to a client. -//////////////////////////////////////////////////////////////////// +/** + * This is intended to be called only once, immediately after construction, by + * the PStatListener that created it. It tells the reader about the newly- + * established TCP connection to a client. + */ void PStatReader:: set_tcp_connection(Connection *tcp_connection) { _tcp_connection = tcp_connection; @@ -97,13 +86,10 @@ set_tcp_connection(Connection *tcp_connection) { send_hello(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::lost_connection -// Access: Public -// Description: This is called by the PStatServer when it detects -// that the connection has been lost. It should clean -// itself up and shut down nicely. -//////////////////////////////////////////////////////////////////// +/** + * This is called by the PStatServer when it detects that the connection has + * been lost. It should clean itself up and shut down nicely. + */ void PStatReader:: lost_connection() { _client_data->_is_alive = false; @@ -116,33 +102,27 @@ lost_connection() { _udp_connection.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::idle -// Access: Public -// Description: Called each frame to do what needs to be done for the -// monitor's user-defined idle routines. -//////////////////////////////////////////////////////////////////// +/** + * Called each frame to do what needs to be done for the monitor's user- + * defined idle routines. + */ void PStatReader:: idle() { dequeue_frame_data(); _monitor->idle(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::get_monitor -// Access: Public -// Description: Returns the monitor that this reader serves. -//////////////////////////////////////////////////////////////////// +/** + * Returns the monitor that this reader serves. + */ PStatMonitor *PStatReader:: get_monitor() { return _monitor; } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::get_hostname -// Access: Private -// Description: Returns the current machine's hostname. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current machine's hostname. + */ string PStatReader:: get_hostname() { if (_hostname.empty()) { @@ -154,11 +134,9 @@ get_hostname() { return _hostname; } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::send_hello -// Access: Private -// Description: Sends the initial greeting message to the client. -//////////////////////////////////////////////////////////////////// +/** + * Sends the initial greeting message to the client. + */ void PStatReader:: send_hello() { PStatServerControlMessage message; @@ -172,12 +150,10 @@ send_hello() { _writer.send(datagram, _tcp_connection); } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::receive_datagram -// Access: Private, Virtual -// Description: Called by the net code whenever a new datagram is -// detected on a either the TCP or UDP connection. -//////////////////////////////////////////////////////////////////// +/** + * Called by the net code whenever a new datagram is detected on a either the + * TCP or UDP connection. + */ void PStatReader:: receive_datagram(const NetDatagram &datagram) { Connection *connection = datagram.get_connection(); @@ -202,12 +178,10 @@ receive_datagram(const NetDatagram &datagram) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::handle_client_control_message -// Access: Private -// Description: Called when a control message has been received by -// the client over the TCP connection. -//////////////////////////////////////////////////////////////////// +/** + * Called when a control message has been received by the client over the TCP + * connection. + */ void PStatReader:: handle_client_control_message(const PStatClientControlMessage &message) { switch (message._type) { @@ -255,20 +229,17 @@ handle_client_control_message(const PStatClientControlMessage &message) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::handle_client_udp_data -// Access: Private -// Description: Called when a UDP datagram has been received by the -// client. This should be a single frame's worth of -// data. -//////////////////////////////////////////////////////////////////// +/** + * Called when a UDP datagram has been received by the client. This should be + * a single frame's worth of data. + */ void PStatReader:: handle_client_udp_data(const Datagram &datagram) { if (!_monitor->is_client_known()) { - // If we haven't heard a "hello" from the client yet, we don't - // know what version data it will be sending us, so we can't - // decode the data. Chances are good we can't display it sensibly - // yet anyway. Ignore frame data until we get that hello. + // If we haven't heard a "hello" from the client yet, we don't know what + // version data it will be sending us, so we can't decode the data. + // Chances are good we can't display it sensibly yet anyway. Ignore frame + // data until we get that hello. return; } @@ -286,44 +257,39 @@ handle_client_udp_data(const Datagram &datagram) { data._frame_number = source.get_uint32(); data._frame_data = new PStatFrameData; data._frame_data->read_datagram(source, _client_data); - - // Queue up the data till we're ready to handle it in a - // single-threaded way. + + // Queue up the data till we're ready to handle it in a single-threaded + // way. _queued_frame_data.push_back(data); } } -//////////////////////////////////////////////////////////////////// -// Function: PStatReader::dequeue_frame_data -// Access: Private -// Description: Called during the idle loop to pull out all the frame -// data that we might have read while the threaded -// reader was running. -//////////////////////////////////////////////////////////////////// +/** + * Called during the idle loop to pull out all the frame data that we might + * have read while the threaded reader was running. + */ void PStatReader:: dequeue_frame_data() { while (!_queued_frame_data.empty()) { const FrameData &data = _queued_frame_data.front(); - nassertv(_client_data != (PStatClientData *)NULL); + nassertv(_client_data != (PStatClientData *)NULL); // Check to see if any new collectors have level data. int num_levels = data._frame_data->get_num_levels(); for (int i = 0; i < num_levels; i++) { int collector_index = data._frame_data->get_level_collector(i); if (!_client_data->get_collector_has_level(collector_index, data._thread_index)) { - // This collector is now reporting level data, and it wasn't - // before. + // This collector is now reporting level data, and it wasn't before. _client_data->set_collector_has_level(collector_index, data._thread_index, true); _monitor->new_collector(collector_index); } } - _client_data->record_new_frame(data._thread_index, - data._frame_number, + _client_data->record_new_frame(data._thread_index, + data._frame_number, data._frame_data); _monitor->new_data(data._thread_index, data._frame_number); _queued_frame_data.pop_front(); } } - diff --git a/pandatool/src/pstatserver/pStatReader.h b/pandatool/src/pstatserver/pStatReader.h index dec39e69bc..4f30fd93cd 100644 --- a/pandatool/src/pstatserver/pStatReader.h +++ b/pandatool/src/pstatserver/pStatReader.h @@ -1,16 +1,15 @@ -// Filename: pStatReader.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatReader.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATREADER_H #define PSTATREADER_H @@ -30,17 +29,15 @@ class PStatMonitor; class PStatClientControlMessage; class PStatFrameData; -// This is the maximum number of frame records that will be queued up -// from this particular client between processing loops. +// This is the maximum number of frame records that will be queued up from +// this particular client between processing loops. static const int queued_frame_records = 500; -//////////////////////////////////////////////////////////////////// -// Class : PStatReader -// Description : This is the class that does all the work for handling -// communications from a single Panda client. It reads -// sockets received from the client and boils them down -// into PStatData. -//////////////////////////////////////////////////////////////////// +/** + * This is the class that does all the work for handling communications from a + * single Panda client. It reads sockets received from the client and boils + * them down into PStatData. + */ class PStatReader : public ConnectionReader { public: PStatReader(PStatServer *manager, PStatMonitor *monitor); diff --git a/pandatool/src/pstatserver/pStatServer.cxx b/pandatool/src/pstatserver/pStatServer.cxx index fcf321ace0..ddb6926995 100644 --- a/pandatool/src/pstatserver/pStatServer.cxx +++ b/pandatool/src/pstatserver/pStatServer.cxx @@ -1,60 +1,50 @@ -// Filename: pStatServer.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatServer.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatServer.h" #include "pStatReader.h" #include "thread.h" #include "config_pstats.h" -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatServer:: PStatServer() { _listener = new PStatListener(this); _next_udp_port = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatServer:: ~PStatServer() { delete _listener; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::listen -// Access: Public -// Description: Establishes a port number that the manager will -// listen on for TCP connections. This may be called -// more than once to listen simulataneously on multiple -// connections, as if that were at all useful. -// -// The default parameter, -1, indicates the use of -// whatever port number has been indicated in the Config -// file. -// -// This function returns true if the port was -// successfully opened, or false if it could not open -// the port. -//////////////////////////////////////////////////////////////////// +/** + * Establishes a port number that the manager will listen on for TCP + * connections. This may be called more than once to listen simulataneously + * on multiple connections, as if that were at all useful. + * + * The default parameter, -1, indicates the use of whatever port number has + * been indicated in the Config file. + * + * This function returns true if the port was successfully opened, or false if + * it could not open the port. + */ bool PStatServer:: listen(int port) { if (port < 0) { @@ -79,19 +69,15 @@ listen(int port) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::poll -// Access: Public -// Description: Checks for any network activity and handles it, if -// appropriate, and then returns. This must be called -// periodically unless is_thread_safe() is redefined to -// return true on this class and also on all -// PStatMonitors in use. -// -// Alternatively, a program may call main_loop() and -// yield control of the program entirely to the -// PStatServer. -//////////////////////////////////////////////////////////////////// +/** + * Checks for any network activity and handles it, if appropriate, and then + * returns. This must be called periodically unless is_thread_safe() is + * redefined to return true on this class and also on all PStatMonitors in + * use. + * + * Alternatively, a program may call main_loop() and yield control of the + * program entirely to the PStatServer. + */ void PStatServer:: poll() { // Delete all the readers that we couldn't delete before. @@ -112,8 +98,8 @@ poll() { Readers::const_iterator ri = _readers.begin(); while (ri != _readers.end()) { - // Preincrement the iterator, in case we remove it as a result of - // calling poll(). + // Preincrement the iterator, in case we remove it as a result of calling + // poll(). Readers::const_iterator rnext = ri; ++rnext; PStatReader *reader = (*ri).second; @@ -125,19 +111,15 @@ poll() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::main_loop -// Access: Public -// Description: An alternative to repeatedly calling poll(), this -// function yields control of the program to the -// PStatServer. It does not return until the program -// is done. -// -// If interrupt_flag is non-NULL, it is the address of a -// bool variable that is initially false, and may be -// asynchronously set true to indicate the loop should -// terminate. -//////////////////////////////////////////////////////////////////// +/** + * An alternative to repeatedly calling poll(), this function yields control + * of the program to the PStatServer. It does not return until the program is + * done. + * + * If interrupt_flag is non-NULL, it is the address of a bool variable that is + * initially false, and may be asynchronously set true to indicate the loop + * should terminate. + */ void PStatServer:: main_loop(bool *interrupt_flag) { while (interrupt_flag == (bool *)NULL || !*interrupt_flag) { @@ -146,22 +128,17 @@ main_loop(bool *interrupt_flag) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::add_reader -// Access: Public -// Description: Adds the newly-created PStatReader to the list of -// currently active readers. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created PStatReader to the list of currently active readers. + */ void PStatServer:: add_reader(Connection *connection, PStatReader *reader) { _readers[connection] = reader; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::remove_reader -// Access: Public -// Description: Removes the indicated reader. -//////////////////////////////////////////////////////////////////// +/** + * Removes the indicated reader. + */ void PStatServer:: remove_reader(Connection *connection, PStatReader *reader) { Readers::iterator ri; @@ -174,14 +151,11 @@ remove_reader(Connection *connection, PStatReader *reader) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::get_udp_port -// Access: Public -// Description: Returns a new port number that will probably be free -// to use as a UDP port. The caller should be prepared -// to accept the possibility that it will be already in -// use by another process, however. -//////////////////////////////////////////////////////////////////// +/** + * Returns a new port number that will probably be free to use as a UDP port. + * The caller should be prepared to accept the possibility that it will be + * already in use by another process, however. + */ int PStatServer:: get_udp_port() { if (_available_udp_ports.empty()) { @@ -192,44 +166,34 @@ get_udp_port() { return udp_port; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::release_udp_port -// Access: Public -// Description: Indicates that the given UDP port is once again free -// for use. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that the given UDP port is once again free for use. + */ void PStatServer:: release_udp_port(int port) { _available_udp_ports.push_back(port); } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::get_num_user_guide_bars -// Access: Public -// Description: Returns the current number of user-defined guide -// bars. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current number of user-defined guide bars. + */ int PStatServer:: get_num_user_guide_bars() const { return _user_guide_bars.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::get_user_guide_bar_height -// Access: Public -// Description: Returns the height of the nth user-defined guide bar. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the nth user-defined guide bar. + */ double PStatServer:: get_user_guide_bar_height(int n) const { nassertr(n >= 0 && n < (int)_user_guide_bars.size(), 0.0f); return _user_guide_bars[n]; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::move_user_guide_bar -// Access: Public -// Description: Adjusts the height of the nth user-defined guide bar. -//////////////////////////////////////////////////////////////////// +/** + * Adjusts the height of the nth user-defined guide bar. + */ void PStatServer:: move_user_guide_bar(int n, double height) { nassertv(n >= 0 && n < (int)_user_guide_bars.size()); @@ -237,12 +201,9 @@ move_user_guide_bar(int n, double height) { user_guide_bars_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::add_user_guide_bar -// Access: Public -// Description: Creates a new user guide bar and returns its index -// number. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new user guide bar and returns its index number. + */ int PStatServer:: add_user_guide_bar(double height) { int n = (int)_user_guide_bars.size(); @@ -252,13 +213,10 @@ add_user_guide_bar(double height) { return n; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::remove_user_guide_bar -// Access: Public -// Description: Removes the user guide bar with the indicated index -// number. All subsequent index numbers are adjusted -// down one. -//////////////////////////////////////////////////////////////////// +/** + * Removes the user guide bar with the indicated index number. All subsequent + * index numbers are adjusted down one. + */ void PStatServer:: remove_user_guide_bar(int n) { nassertv(n >= 0 && n < (int)_user_guide_bars.size()); @@ -266,13 +224,11 @@ remove_user_guide_bar(int n) { user_guide_bars_changed(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::find_user_guide_bar -// Access: Public -// Description: Returns the index number of the first user guide bar -// found whose height is within the indicated range, or -// -1 if no user guide bars fall within the range. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the first user guide bar found whose height is + * within the indicated range, or -1 if no user guide bars fall within the + * range. + */ int PStatServer:: find_user_guide_bar(double from_height, double to_height) const { GuideBars::const_iterator gbi; @@ -288,11 +244,9 @@ find_user_guide_bar(double from_height, double to_height) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::user_guide_bars_changed -// Access: Private -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void PStatServer:: user_guide_bars_changed() { Readers::iterator ri; @@ -301,37 +255,28 @@ user_guide_bars_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::is_thread_safe -// Access: Public -// Description: This should be redefined to return true in derived -// classes that want to deal with multithreaded readers -// and such. If this returns true, the manager will -// create the listener in its own thread, and thus the -// PStatReader constructors at least will run in a -// different thread. -// -// This is not related to the question of whether the -// reader can handle multiple different -// PStatThreadDatas; it's strictly a question of whether -// the readers themselves can run in a separate thread. -//////////////////////////////////////////////////////////////////// +/** + * This should be redefined to return true in derived classes that want to + * deal with multithreaded readers and such. If this returns true, the + * manager will create the listener in its own thread, and thus the + * PStatReader constructors at least will run in a different thread. + * + * This is not related to the question of whether the reader can handle + * multiple different PStatThreadDatas; it's strictly a question of whether + * the readers themselves can run in a separate thread. + */ bool PStatServer:: is_thread_safe() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatServer::connection_reset -// Access: Protected, Virtual -// Description: Called when a lost connection is detected by the net -// code, this should pass the word on to the interested -// parties and clean up gracefully. -//////////////////////////////////////////////////////////////////// +/** + * Called when a lost connection is detected by the net code, this should pass + * the word on to the interested parties and clean up gracefully. + */ void PStatServer:: connection_reset(const PT(Connection) &connection, bool okflag) { - // Was this a client connection? Tell the reader about it if it - // was. + // Was this a client connection? Tell the reader about it if it was. close_connection(connection); Readers::iterator ri; @@ -340,9 +285,9 @@ connection_reset(const PT(Connection) &connection, bool okflag) { PStatReader *reader = (*ri).second; _readers.erase(ri); - // Unfortunately, we can't delete the reader right away, because - // we might have been called from a method on the reader! We'll - // have to save the reader pointer and delete it some time later. + // Unfortunately, we can't delete the reader right away, because we might + // have been called from a method on the reader! We'll have to save the + // reader pointer and delete it some time later. _lost_readers.push_back(reader); } } diff --git a/pandatool/src/pstatserver/pStatServer.h b/pandatool/src/pstatserver/pStatServer.h index cfad0ee469..dca7ec2008 100644 --- a/pandatool/src/pstatserver/pStatServer.h +++ b/pandatool/src/pstatserver/pStatServer.h @@ -1,16 +1,15 @@ -// Filename: pStatServer.h -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatServer.h + * @author drose + * @date 2000-07-09 + */ #ifndef PSTATSERVER_H #define PSTATSERVER_H @@ -24,20 +23,16 @@ class PStatReader; -//////////////////////////////////////////////////////////////////// -// Class : PStatServer -// Description : The overall manager of the network connections. This -// class gets the ball rolling; to use this package, you -// need to derive from this and define make_monitor() to -// allocate and return a PStatMonitor of the suitable -// type. -// -// Then create just one PStatServer object and call -// listen() with the port(s) you would like to listen -// on. It will automatically create PStatMonitors as -// connections are established and mark the connections -// closed as they are lost. -//////////////////////////////////////////////////////////////////// +/** + * The overall manager of the network connections. This class gets the ball + * rolling; to use this package, you need to derive from this and define + * make_monitor() to allocate and return a PStatMonitor of the suitable type. + * + * Then create just one PStatServer object and call listen() with the port(s) + * you would like to listen on. It will automatically create PStatMonitors as + * connections are established and mark the connections closed as they are + * lost. + */ class PStatServer : public ConnectionManager { public: PStatServer(); @@ -65,7 +60,7 @@ public: virtual bool is_thread_safe(); protected: - virtual void connection_reset(const PT(Connection) &connection, + virtual void connection_reset(const PT(Connection) &connection, bool okflag); private: diff --git a/pandatool/src/pstatserver/pStatStripChart.I b/pandatool/src/pstatserver/pStatStripChart.I index a478ca8369..791e722009 100644 --- a/pandatool/src/pstatserver/pStatStripChart.I +++ b/pandatool/src/pstatserver/pStatStripChart.I @@ -1,45 +1,36 @@ -// Filename: pStatStripChart.I -// Created by: drose (15Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatStripChart.I + * @author drose + * @date 2000-07-15 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_view -// Access: Public -// Description: Returns the View this chart represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the View this chart represents. + */ INLINE PStatView &PStatStripChart:: get_view() const { return _view; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_collector_index -// Access: Public -// Description: Returns the particular collector whose data this -// strip chart reflects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the particular collector whose data this strip chart reflects. + */ INLINE int PStatStripChart:: get_collector_index() const { return _collector_index; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_horizontal_scale -// Access: Public -// Description: Changes the amount of time the width of the -// horizontal axis represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the amount of time the width of the horizontal axis represents. + * This may force a redraw. + */ INLINE void PStatStripChart:: set_horizontal_scale(double time_width) { if (_time_width != time_width) { @@ -52,23 +43,19 @@ set_horizontal_scale(double time_width) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_horizontal_scale -// Access: Public -// Description: Returns the amount of total time the width of the -// horizontal axis represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the amount of total time the width of the horizontal axis + * represents. + */ INLINE double PStatStripChart:: get_horizontal_scale() const { return _time_width; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_vertical_scale -// Access: Public -// Description: Changes the value the height of the vertical axis -// represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value the height of the vertical axis represents. This may + * force a redraw. + */ INLINE void PStatStripChart:: set_vertical_scale(double value_height) { if (_value_height != value_height) { @@ -78,25 +65,19 @@ set_vertical_scale(double value_height) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_vertical_scale -// Access: Public -// Description: Returns total value the height of the vertical axis -// represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns total value the height of the vertical axis represents. + */ INLINE double PStatStripChart:: get_vertical_scale() const { return _value_height; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_scroll_mode -// Access: Public -// Description: Changes the scroll_mode flag. When true, the strip -// chart will update itself by scrolling to the left; -// when false, the strip chart will wrap around at the -// right and restart at the left end without scrolling. -//////////////////////////////////////////////////////////////////// +/** + * Changes the scroll_mode flag. When true, the strip chart will update + * itself by scrolling to the left; when false, the strip chart will wrap + * around at the right and restart at the left end without scrolling. + */ INLINE void PStatStripChart:: set_scroll_mode(bool scroll_mode) { if (_scroll_mode != scroll_mode) { @@ -105,30 +86,23 @@ set_scroll_mode(bool scroll_mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_scroll_mode -// Access: Public -// Description: Returns the current state of the scroll_mode flag. -// When true, the strip chart will update itself by -// scrolling to the left; when false, the strip chart -// will wrap around at the right and restart at the left -// end without scrolling. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the scroll_mode flag. When true, the strip + * chart will update itself by scrolling to the left; when false, the strip + * chart will wrap around at the right and restart at the left end without + * scrolling. + */ INLINE bool PStatStripChart:: get_scroll_mode() const { return _scroll_mode; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_average_mode -// Access: Public -// Description: Changes the average_mode flag. When true, the strip -// chart will average out the color values over -// pstats_average_time seconds, which hides spikes and -// makes the overall trends easier to read. When false, -// the strip chart shows the actual data as it is -// happening. -//////////////////////////////////////////////////////////////////// +/** + * Changes the average_mode flag. When true, the strip chart will average out + * the color values over pstats_average_time seconds, which hides spikes and + * makes the overall trends easier to read. When false, the strip chart shows + * the actual data as it is happening. + */ INLINE void PStatStripChart:: set_average_mode(bool average_mode) { if (_average_mode != average_mode) { @@ -137,70 +111,55 @@ set_average_mode(bool average_mode) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_average_mode -// Access: Public -// Description: Returns the current state of the average_mode flag. -// When true, the strip chart will average out the color -// values over pstats_average_time seconds, which hides -// spikes and makes the overall trends easier to read. -// When false, the strip chart shows the actual data as -// it is happening. -//////////////////////////////////////////////////////////////////// +/** + * Returns the current state of the average_mode flag. When true, the strip + * chart will average out the color values over pstats_average_time seconds, + * which hides spikes and makes the overall trends easier to read. When + * false, the strip chart shows the actual data as it is happening. + */ INLINE bool PStatStripChart:: get_average_mode() const { return _average_mode; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::timestamp_to_pixel -// Access: Public -// Description: Converts a timestamp to a horizontal pixel offset. -//////////////////////////////////////////////////////////////////// +/** + * Converts a timestamp to a horizontal pixel offset. + */ INLINE int PStatStripChart:: timestamp_to_pixel(double time) const { return (int)((double)get_xsize() * (time - _start_time) / _time_width); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::pixel_to_timestamp -// Access: Public -// Description: Converts a horizontal pixel offset to a timestamp. -//////////////////////////////////////////////////////////////////// +/** + * Converts a horizontal pixel offset to a timestamp. + */ INLINE double PStatStripChart:: pixel_to_timestamp(int x) const { return _time_width * (double)x / (double)get_xsize() + _start_time; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::height_to_pixel -// Access: Public -// Description: Converts a value (i.e. a "height" in the strip chart) -// to a vertical pixel offset. -//////////////////////////////////////////////////////////////////// +/** + * Converts a value (i.e. a "height" in the strip chart) to a vertical pixel + * offset. + */ INLINE int PStatStripChart:: height_to_pixel(double value) const { return get_ysize() - (int)((double)get_ysize() * value / _value_height); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::pixel_to_height -// Access: Public -// Description: Converts a vertical pixel offset to a value (a -// "height" in the strip chart). -//////////////////////////////////////////////////////////////////// +/** + * Converts a vertical pixel offset to a value (a "height" in the strip + * chart). + */ INLINE double PStatStripChart:: pixel_to_height(int x) const { return _value_height * (double)(get_ysize() - x) / (double)get_ysize(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::is_label_used -// Access: Protected -// Description: Returns true if the indicated collector appears -// anywhere on the chart at the current time, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the indicated collector appears anywhere on the chart at + * the current time, false otherwise. + */ INLINE bool PStatStripChart:: is_label_used(int collector_index) const { if (collector_index < (int)_label_usage.size()) { diff --git a/pandatool/src/pstatserver/pStatStripChart.cxx b/pandatool/src/pstatserver/pStatStripChart.cxx index 30f1659644..28b28d6240 100644 --- a/pandatool/src/pstatserver/pStatStripChart.cxx +++ b/pandatool/src/pstatserver/pStatStripChart.cxx @@ -1,16 +1,15 @@ -// Filename: pStatStripChart.cxx -// Created by: drose (15Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatStripChart.cxx + * @author drose + * @date 2000-07-15 + */ #include "pStatStripChart.h" #include "pStatClientData.h" @@ -23,11 +22,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatStripChart:: PStatStripChart(PStatMonitor *monitor, PStatView &view, int thread_index, int collector_index, int xsize, int ysize) : @@ -59,39 +56,33 @@ PStatStripChart(PStatMonitor *monitor, PStatView &view, set_default_vertical_scale(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatStripChart:: ~PStatStripChart() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::new_data -// Access: Public -// Description: Indicates that new data has become available. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that new data has become available. + */ void PStatStripChart:: new_data(int frame_number) { - // If the new frame is older than the last one we've drawn, we'll - // need to back up and redraw it. This can happen when frames - // arrive out of order from the client. + // If the new frame is older than the last one we've drawn, we'll need to + // back up and redraw it. This can happen when frames arrive out of order + // from the client. _next_frame = min(frame_number, _next_frame); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::update -// Access: Public -// Description: Updates the chart with the latest data. -//////////////////////////////////////////////////////////////////// +/** + * Updates the chart with the latest data. + */ void PStatStripChart:: update() { const PStatClientData *client_data = get_monitor()->get_client_data(); - // Don't bother to update the thread data until we know at least - // something about the collectors and threads. + // Don't bother to update the thread data until we know at least something + // about the collectors and threads. if (client_data->get_num_collectors() != 0 && client_data->get_num_threads() != 0) { const PStatThreadData *thread_data = _view.get_thread_data(); @@ -125,23 +116,19 @@ update() { idle(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::first_data -// Access: Public -// Description: Returns true if the chart has seen its first data -// appear on it, false if it is still a virgin chart. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the chart has seen its first data appear on it, false if it + * is still a virgin chart. + */ bool PStatStripChart:: first_data() const { return _first_data; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_collector_index -// Access: Public -// Description: Changes the collector represented by this strip -// chart. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the collector represented by this strip chart. This may force a + * redraw. + */ void PStatStripChart:: set_collector_index(int collector_index) { if (_collector_index != collector_index) { @@ -154,13 +141,10 @@ set_collector_index(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_default_vertical_scale -// Access: Public -// Description: Sets the vertical scale according to the suggested -// scale of the base collector, if any, or to center the -// target frame rate bar otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertical scale according to the suggested scale of the base + * collector, if any, or to center the target frame rate bar otherwise. + */ void PStatStripChart:: set_default_vertical_scale() { const PStatClientData *client_data = _monitor->get_client_data(); @@ -176,11 +160,9 @@ set_default_vertical_scale() { set_vertical_scale(2.0 / get_target_frame_rate()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::set_auto_vertical_scale -// Access: Public -// Description: Sets the vertical scale to make all the data visible. -//////////////////////////////////////////////////////////////////// +/** + * Sets the vertical scale to make all the data visible. + */ void PStatStripChart:: set_auto_vertical_scale() { const PStatThreadData *thread_data = _view.get_thread_data(); @@ -199,8 +181,8 @@ set_auto_vertical_scale() { } } - // Ok, now we know what the max value visible in the chart is. - // Choose a scale that will show all of this sensibly. + // Ok, now we know what the max value visible in the chart is. Choose a + // scale that will show all of this sensibly. if (max_value == 0.0) { set_vertical_scale(1.0); } else { @@ -208,24 +190,21 @@ set_auto_vertical_scale() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_collector_under_pixel -// Access: Public -// Description: Return the collector index associated with the -// particular band of color at the indicated pixel -// location, or -1 if no band of color was at the pixel. -//////////////////////////////////////////////////////////////////// +/** + * Return the collector index associated with the particular band of color at + * the indicated pixel location, or -1 if no band of color was at the pixel. + */ int PStatStripChart:: get_collector_under_pixel(int xpoint, int ypoint) { - // First, we need to know what frame it was; to know that, we need - // to determine the time corresponding to the x pixel. + // First, we need to know what frame it was; to know that, we need to + // determine the time corresponding to the x pixel. double time = pixel_to_timestamp(xpoint); // Now use that time to determine the frame. const PStatThreadData *thread_data = _view.get_thread_data(); - // And now we can determine which collector within the frame, - // based on the value height. + // And now we can determine which collector within the frame, based on the + // value height. if (_average_mode) { double start_time = pixel_to_timestamp(xpoint); int then_i = thread_data->get_frame_number_at_time(start_time - pstats_average_time); @@ -235,7 +214,7 @@ get_collector_under_pixel(int xpoint, int ypoint) { compute_average_pixel_data(fdata, then_i, now_i, start_time); double overall_value = 0.0; int y = get_ysize(); - + FrameData::const_iterator fi; for (fi = fdata.begin(); fi != fdata.end(); ++fi) { const ColorData &cd = (*fi); @@ -251,7 +230,7 @@ get_collector_under_pixel(int xpoint, int ypoint) { const FrameData &fdata = get_frame_data(frame_number); double overall_value = 0.0; int y = get_ysize(); - + FrameData::const_iterator fi; for (fi = fdata.begin(); fi != fdata.end(); ++fi) { const ColorData &cd = (*fi); @@ -262,16 +241,13 @@ get_collector_under_pixel(int xpoint, int ypoint) { } } } - + return -1; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_title_text -// Access: Private -// Description: Returns the text suitable for the title label on the -// top line. -//////////////////////////////////////////////////////////////////// +/** + * Returns the text suitable for the title label on the top line. + */ string PStatStripChart:: get_title_text() { string text; @@ -304,25 +280,21 @@ get_title_text() { return text; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::is_title_unknown -// Access: Public -// Description: Returns true if get_title_text() has never yet -// returned an answer, false if it has. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if get_title_text() has never yet returned an answer, false if + * it has. + */ bool PStatStripChart:: is_title_unknown() const { return _title_unknown; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::accumulate_frame_data -// Access: Protected, Static -// Description: Adds the data from additional into the data from -// fdata, after applying the scale weight. -//////////////////////////////////////////////////////////////////// +/** + * Adds the data from additional into the data from fdata, after applying the + * scale weight. + */ void PStatStripChart:: -accumulate_frame_data(FrameData &fdata, const FrameData &additional, +accumulate_frame_data(FrameData &fdata, const FrameData &additional, double weight) { FrameData::iterator ai; FrameData::const_iterator bi; @@ -333,9 +305,9 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional, FrameData result; if (fdata.size() == additional.size()) { - // Start out assuming that fdata and additional contain exactly - // the same set of collectors. If we discover otherwise, we'll - // have to bail at that point. + // Start out assuming that fdata and additional contain exactly the same + // set of collectors. If we discover otherwise, we'll have to bail at + // that point. while (ai != fdata.end() && (*ai)._collector_index == (*bi)._collector_index) { (*ai)._net_value += ((*bi)._net_value * weight); @@ -344,14 +316,14 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional, } if (ai == fdata.end()) { - // If we successfully reached the end of the list, great! - // We're done without any merging. + // If we successfully reached the end of the list, great! We're done + // without any merging. return; } - // Otherwise, the two lists weren't identical. In that case, copy - // the accumulated data so far and continue from this point with - // the full-blown merge. + // Otherwise, the two lists weren't identical. In that case, copy the + // accumulated data so far and continue from this point with the full- + // blown merge. result.reserve(max(fdata.size(), additional.size())); FrameData::const_iterator ci; for (ci = fdata.begin(); ci != ai; ++ci) { @@ -359,8 +331,7 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional, } } else { - // If the two lists had different lengths, clearly they aren't - // identical. + // If the two lists had different lengths, clearly they aren't identical. result.reserve(max(fdata.size(), additional.size())); } @@ -410,12 +381,9 @@ accumulate_frame_data(FrameData &fdata, const FrameData &additional, fdata.swap(result); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::scale_frame_data -// Access: Protected, Static -// Description: Applies the indicated scale to all collector values -// in data. -//////////////////////////////////////////////////////////////////// +/** + * Applies the indicated scale to all collector values in data. + */ void PStatStripChart:: scale_frame_data(FrameData &fdata, double factor) { FrameData::iterator fi; @@ -425,14 +393,11 @@ scale_frame_data(FrameData &fdata, double factor) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_frame_data -// Access: Protected -// Description: Returns the cached FrameData associated with the -// given frame number. This describes the lengths of -// the color bands for a single vertical stripe in the -// chart. -//////////////////////////////////////////////////////////////////// +/** + * Returns the cached FrameData associated with the given frame number. This + * describes the lengths of the color bands for a single vertical stripe in + * the chart. + */ const PStatStripChart::FrameData &PStatStripChart:: get_frame_data(int frame_number) { Data::const_iterator di; @@ -459,8 +424,8 @@ get_frame_data(int frame_number) { } } - // Also, there might be some value in the overall Collector that - // wasn't included in all of the children. + // Also, there might be some value in the overall Collector that wasn't + // included in all of the children. ColorData cd; cd._collector_index = (unsigned short)level->get_collector(); cd._i = (unsigned short)num_children; @@ -474,23 +439,18 @@ get_frame_data(int frame_number) { return fdata; } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::compute_average_pixel_data -// Access: Protected -// Description: Fills the indicated FrameData structure with the -// color data for the indicated pixel, averaged over the -// past pstats_average_time seconds. -// -// now is the timestamp for which we are computing the -// data; then_i and now_i are the frame numbers that -// bound (now - pstats_average_time) and now. At -// function initialization time, these should be at or -// below the actual values; they will be incremented as -// needed by this function. This allows the function to -// be called repeatedly for successive pixels. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated FrameData structure with the color data for the + * indicated pixel, averaged over the past pstats_average_time seconds. + * + * now is the timestamp for which we are computing the data; then_i and now_i + * are the frame numbers that bound (now - pstats_average_time) and now. At + * function initialization time, these should be at or below the actual + * values; they will be incremented as needed by this function. This allows + * the function to be called repeatedly for successive pixels. + */ void PStatStripChart:: -compute_average_pixel_data(PStatStripChart::FrameData &result, +compute_average_pixel_data(PStatStripChart::FrameData &result, int &then_i, int &now_i, double now) { result.clear(); @@ -514,18 +474,17 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, then = max(then, thread_data->get_frame(then_i).get_start()); - // Sum up a weighted average of all of the individual frames we - // pass. + // Sum up a weighted average of all of the individual frames we pass. - // We start with just the portion of frame then_i that actually - // does fall within our "then to now" window. - accumulate_frame_data(result, get_frame_data(then_i), + // We start with just the portion of frame then_i that actually does fall + // within our "then to now" window. + accumulate_frame_data(result, get_frame_data(then_i), thread_data->get_frame(then_i).get_end() - then); double last = thread_data->get_frame(then_i).get_end(); // Then we get all of each of the middle frames. - for (int frame_number = then_i + 1; - frame_number < now_i; + for (int frame_number = then_i + 1; + frame_number < now_i; frame_number++) { accumulate_frame_data(result, get_frame_data(frame_number), thread_data->get_frame(frame_number).get_end() - last); @@ -536,19 +495,17 @@ compute_average_pixel_data(PStatStripChart::FrameData &result, if (last <= now) { accumulate_frame_data(result, get_frame_data(now_i), now - last); } - + scale_frame_data(result, 1.0f / (now - then)); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_net_value -// Access: Protected -// Description: Returns the net value of the chart's collector for -// the indicated frame number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the net value of the chart's collector for the indicated frame + * number. + */ double PStatStripChart:: get_net_value(int frame_number) const { - const FrameData &frame = + const FrameData &frame = ((PStatStripChart *)this)->get_frame_data(frame_number); double net_value = 0.0; @@ -560,13 +517,11 @@ get_net_value(int frame_number) const { return net_value; } - -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::get_average_net_value -// Access: Protected -// Description: Computes the average value of the chart's collector -// over the past pstats_average_time number of seconds. -//////////////////////////////////////////////////////////////////// + +/** + * Computes the average value of the chart's collector over the past + * pstats_average_time number of seconds. + */ double PStatStripChart:: get_average_net_value() const { const PStatThreadData *thread_data = _view.get_thread_data(); @@ -580,10 +535,10 @@ get_average_net_value() const { int num_frames = now_i - then_i + 1; if (_collector_index == 0 && !_view.get_show_level()) { - // If we're showing the time for the whole frame, compute this - // from the total elapsed time, rather than summing up individual - // frames. This is more accurate and exactly matches what is - // reported by thread_data->get_frame_rate(). + // If we're showing the time for the whole frame, compute this from the + // total elapsed time, rather than summing up individual frames. This is + // more accurate and exactly matches what is reported by + // thread_data->get_frame_rate(). const PStatFrameData &now_frame_data = thread_data->get_frame(now_i); const PStatFrameData &then_frame_data = thread_data->get_frame(then_i); @@ -592,27 +547,26 @@ get_average_net_value() const { return elapsed_time / (double)num_frames; } else { - // On the other hand, if we're showing the time for some - // sub-frame, we have to do it the less-accurate way of summing up - // individual frames, which might introduce errors if we are - // missing data for some frames, but what can you do? + // On the other hand, if we're showing the time for some sub-frame, we + // have to do it the less-accurate way of summing up individual frames, + // which might introduce errors if we are missing data for some frames, + // but what can you do? const PStatThreadData *thread_data = _view.get_thread_data(); - + double net_value = 0.0f; double net_time = 0.0f; - // We start with just the portion of frame then_i that actually - // does fall within our "then to now" window (usually some portion - // of it will). + // We start with just the portion of frame then_i that actually does fall + // within our "then to now" window (usually some portion of it will). if (thread_data->get_frame(then_i).get_end() > then) { double this_time = (thread_data->get_frame(then_i).get_end() - then); net_value += get_net_value(then_i) * this_time; net_time += this_time; } // Then we get all of each of the remaining frames. - for (int frame_number = then_i + 1; - frame_number <= now_i; + for (int frame_number = then_i + 1; + frame_number <= now_i; frame_number++) { double this_time = thread_data->get_frame(frame_number).get_net_time(); net_value += get_net_value(frame_number) * this_time; @@ -623,14 +577,11 @@ get_average_net_value() const { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::changed_size -// Access: Protected -// Description: To be called by the user class when the widget size -// has changed. This updates the chart's internal data -// and causes it to issue redraw commands to reflect the -// new size. -//////////////////////////////////////////////////////////////////// +/** + * To be called by the user class when the widget size has changed. This + * updates the chart's internal data and causes it to issue redraw commands to + * reflect the new size. + */ void PStatStripChart:: changed_size(int xsize, int ysize) { if (xsize != _xsize || ysize != _ysize) { @@ -660,12 +611,10 @@ changed_size(int xsize, int ysize) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::force_redraw -// Access: Protected -// Description: To be called by the user class when the whole thing -// needs to be redrawn for some reason. -//////////////////////////////////////////////////////////////////// +/** + * To be called by the user class when the whole thing needs to be redrawn for + * some reason. + */ void PStatStripChart:: force_redraw() { if (!_first_data) { @@ -673,12 +622,10 @@ force_redraw() { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::force_reset -// Access: Protected -// Description: To be called by the user class to cause the chart to -// reset to empty and start filling again. -//////////////////////////////////////////////////////////////////// +/** + * To be called by the user class to cause the chart to reset to empty and + * start filling again. + */ void PStatStripChart:: force_reset() { clear_region(); @@ -686,101 +633,79 @@ force_reset() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::clear_region -// Access: Protected, Virtual -// Description: Should be overridden by the user class to wipe out -// the entire strip chart region. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to wipe out the entire strip chart + * region. + */ void PStatStripChart:: clear_region() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::copy_region -// Access: Protected, Virtual -// Description: Should be overridden by the user class to copy a -// region of the chart from one part of the chart to -// another. This is used to implement scrolling. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to copy a region of the chart from + * one part of the chart to another. This is used to implement scrolling. + */ void PStatStripChart:: copy_region(int, int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::begin_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called before drawing any color bars in the -// strip chart; it gives the pixel range that's about to -// be redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called before + * drawing any color bars in the strip chart; it gives the pixel range that's + * about to be redrawn. + */ void PStatStripChart:: begin_draw(int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::draw_slice -// Access: Protected, Virtual -// Description: Should be overridden by the user class to draw a -// single vertical slice in the strip chart at the -// indicated pixel, with the data for the indicated -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to draw a single vertical slice in + * the strip chart at the indicated pixel, with the data for the indicated + * frame. + */ void PStatStripChart:: draw_slice(int, int, const PStatStripChart::FrameData &fdata) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::draw_empty -// Access: Protected, Virtual -// Description: This is similar to draw_slice(), except it should -// draw a vertical line of the background color to -// represent a portion of the chart that has no data. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to draw_slice(), except it should draw a vertical line of + * the background color to represent a portion of the chart that has no data. + */ void PStatStripChart:: draw_empty(int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::draw_cursor -// Access: Protected, Virtual -// Description: This is similar to draw_slice(), except that it -// should draw the black vertical stripe that represents -// the current position when not in scrolling mode. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to draw_slice(), except that it should draw the black + * vertical stripe that represents the current position when not in scrolling + * mode. + */ void PStatStripChart:: draw_cursor(int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::end_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called after drawing a series of color bars -// in the strip chart; it gives the pixel range that -// was just redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called after + * drawing a series of color bars in the strip chart; it gives the pixel range + * that was just redrawn. + */ void PStatStripChart:: end_draw(int, int) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::idle -// Access: Protected, Virtual -// Description: Should be overridden by the user class to perform any -// other updates might be necessary after the color bars -// have been redrawn. For instance, it could check the -// state of _labels_changed, and redraw the labels if it -// is true. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to perform any other updates might + * be necessary after the color bars have been redrawn. For instance, it + * could check the state of _labels_changed, and redraw the labels if it is + * true. + */ void PStatStripChart:: idle() { } -// STL function object for sorting labels in order by the collector's -// sort index, used in update_labels(), below. +// STL function object for sorting labels in order by the collector's sort +// index, used in update_labels(), below. class SortCollectorLabels2 { public: SortCollectorLabels2(const PStatClientData *client_data) : @@ -794,11 +719,9 @@ public: const PStatClientData *_client_data; }; -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::update_labels -// Access: Protected, Virtual -// Description: Resets the list of labels. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of labels. + */ void PStatStripChart:: update_labels() { const PStatViewLevel *level = _view.get_level(_collector_index); @@ -823,23 +746,18 @@ update_labels() { _level_index = _view.get_level_index(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::normal_guide_bars -// Access: Protected, Virtual -// Description: Calls update_guide_bars with parameters suitable to -// this kind of graph. -//////////////////////////////////////////////////////////////////// +/** + * Calls update_guide_bars with parameters suitable to this kind of graph. + */ void PStatStripChart:: normal_guide_bars() { update_guide_bars(4, _value_height); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::draw_frames -// Access: Private -// Description: Draws the levels for the indicated frame range. -//////////////////////////////////////////////////////////////////// +/** + * Draws the levels for the indicated frame range. + */ void PStatStripChart:: draw_frames(int first_frame, int last_frame) { const PStatThreadData *thread_data = _view.get_thread_data(); @@ -873,8 +791,8 @@ draw_frames(int first_frame, int last_frame) { _first_data = false; if (last_pixel - first_pixel >= _xsize) { - // If we're drawing the whole thing all in this one swoop, just - // start over. + // If we're drawing the whole thing all in this one swoop, just start + // over. _start_time = thread_data->get_frame(last_frame).get_start() - _time_width; first_pixel = 0; last_pixel = _xsize; @@ -907,11 +825,9 @@ draw_frames(int first_frame, int last_frame) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::draw_pixels -// Access: Private -// Description: Draws the levels for the indicated pixel range. -//////////////////////////////////////////////////////////////////// +/** + * Draws the levels for the indicated pixel range. + */ void PStatStripChart:: draw_pixels(int first_pixel, int last_pixel) { begin_draw(first_pixel, last_pixel); @@ -933,15 +849,15 @@ draw_pixels(int first_pixel, int last_pixel) { } } else { - // When average mode is false, we are in frame mode; just show the - // actual frame data. + // When average mode is false, we are in frame mode; just show the actual + // frame data. int frame_number = -1; int x = first_pixel; while (x <= last_pixel) { if (x == _cursor_pixel && !_scroll_mode) { draw_cursor(x); x++; - + } else { double time = pixel_to_timestamp(x); frame_number = thread_data->get_frame_number_at_time(time, frame_number); @@ -950,7 +866,7 @@ draw_pixels(int first_pixel, int last_pixel) { if (!_scroll_mode) { stop_pixel = min(stop_pixel, _cursor_pixel); } - while (x + w < stop_pixel && + while (x + w < stop_pixel && thread_data->get_frame_number_at_time(pixel_to_timestamp(x + w), frame_number) == frame_number) { w++; } @@ -967,25 +883,20 @@ draw_pixels(int first_pixel, int last_pixel) { end_draw(first_pixel, last_pixel); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::clear_label_usage -// Access: Private -// Description: Erases all elements from the label usage data. -//////////////////////////////////////////////////////////////////// +/** + * Erases all elements from the label usage data. + */ void PStatStripChart:: clear_label_usage() { _label_usage.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::dec_label_usage -// Access: Private -// Description: Erases the indicated frame data from the current -// label usage. This indicates that the given FrameData -// has fallen off the end of the chart. This must have -// been proceeded by an earlier call to -// inc_label_usage() for the same FrameData -//////////////////////////////////////////////////////////////////// +/** + * Erases the indicated frame data from the current label usage. This + * indicates that the given FrameData has fallen off the end of the chart. + * This must have been proceeded by an earlier call to inc_label_usage() for + * the same FrameData + */ void PStatStripChart:: dec_label_usage(const FrameData &fdata) { FrameData::const_iterator fi; @@ -995,24 +906,19 @@ dec_label_usage(const FrameData &fdata) { nassertv(_label_usage[cd._collector_index] > 0); _label_usage[cd._collector_index]--; if (_label_usage[cd._collector_index] == 0) { - // If a label drops out of usage, it's time to regenerate - // labels. + // If a label drops out of usage, it's time to regenerate labels. _level_index = -1; } } } -//////////////////////////////////////////////////////////////////// -// Function: PStatStripChart::inc_label_usage -// Access: Private -// Description: Records the labels named in the indicated FrameData -// in the table of current labels in use. This should -// be called when the given FrameData has been added to -// the chart; it will increment the reference count for -// each collector named in the FrameData. The reference -// count will eventually be decremented when -// dec_label_usage() is called later. -//////////////////////////////////////////////////////////////////// +/** + * Records the labels named in the indicated FrameData in the table of current + * labels in use. This should be called when the given FrameData has been + * added to the chart; it will increment the reference count for each + * collector named in the FrameData. The reference count will eventually be + * decremented when dec_label_usage() is called later. + */ void PStatStripChart:: inc_label_usage(const FrameData &fdata) { FrameData::const_iterator fi; @@ -1024,8 +930,8 @@ inc_label_usage(const FrameData &fdata) { nassertv(_label_usage[cd._collector_index] >= 0); _label_usage[cd._collector_index]++; if (_label_usage[cd._collector_index] == 1) { - // If a label appears for the first time, it's time to - // regenerate labels. + // If a label appears for the first time, it's time to regenerate + // labels. _level_index = -1; } } diff --git a/pandatool/src/pstatserver/pStatStripChart.h b/pandatool/src/pstatserver/pStatStripChart.h index 7f9f19751d..6cfe896bf2 100644 --- a/pandatool/src/pstatserver/pStatStripChart.h +++ b/pandatool/src/pstatserver/pStatStripChart.h @@ -1,16 +1,15 @@ -// Filename: pStatStripChart.h -// Created by: drose (15Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatStripChart.h + * @author drose + * @date 2000-07-15 + */ #ifndef PSTATSTRIPCHART_H #define PSTATSTRIPCHART_H @@ -28,17 +27,14 @@ class PStatView; -//////////////////////////////////////////////////////////////////// -// Class : PStatStripChart -// Description : This is an abstract class that presents the interface -// for drawing a basic strip-chart, showing the relative -// value over an interval of time for several different -// collectors, differentiated by bands of color. -// -// This class just manages all the strip-chart logic; -// the actual nuts and bolts of drawing pixels is left -// to a user-derived class. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract class that presents the interface for drawing a basic + * strip-chart, showing the relative value over an interval of time for + * several different collectors, differentiated by bands of color. + * + * This class just manages all the strip-chart logic; the actual nuts and + * bolts of drawing pixels is left to a user-derived class. + */ class PStatStripChart : public PStatGraph { public: PStatStripChart(PStatMonitor *monitor, PStatView &view, @@ -90,7 +86,7 @@ protected: static void scale_frame_data(FrameData &fdata, double factor); const FrameData &get_frame_data(int frame_number); - void compute_average_pixel_data(PStatStripChart::FrameData &result, + void compute_average_pixel_data(PStatStripChart::FrameData &result, int &then_i, int &now_i, double now); double get_net_value(int frame_number) const; double get_average_net_value() const; diff --git a/pandatool/src/pstatserver/pStatThreadData.I b/pandatool/src/pstatserver/pStatThreadData.I index 558cb1b502..7ade3f96af 100644 --- a/pandatool/src/pstatserver/pStatThreadData.I +++ b/pandatool/src/pstatserver/pStatThreadData.I @@ -1,24 +1,19 @@ -// Filename: pStatThreadData.I -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThreadData.I + * @author drose + * @date 2000-07-10 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_client_data -// Access: Public -// Description: Returns a pointer to the ClientData structure -// associated with this data. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the ClientData structure associated with this data. + */ INLINE const PStatClientData *PStatThreadData:: get_client_data() const { return _client_data; diff --git a/pandatool/src/pstatserver/pStatThreadData.cxx b/pandatool/src/pstatserver/pStatThreadData.cxx index 852eb84135..eb3aa92702 100644 --- a/pandatool/src/pstatserver/pStatThreadData.cxx +++ b/pandatool/src/pstatserver/pStatThreadData.cxx @@ -1,16 +1,15 @@ -// Filename: pStatThreadData.cxx -// Created by: drose (09Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThreadData.cxx + * @author drose + * @date 2000-07-09 + */ #include "pStatThreadData.h" @@ -21,11 +20,9 @@ PStatFrameData PStatThreadData::_null_frame; -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatThreadData:: PStatThreadData(const PStatClientData *client_data) : _client_data(client_data) @@ -35,58 +32,44 @@ PStatThreadData(const PStatClientData *client_data) : _computed_elapsed_frames = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatThreadData:: ~PStatThreadData() { } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::is_empty -// Access: Public -// Description: Returns true if the structure contains no frames, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the structure contains no frames, false otherwise. + */ bool PStatThreadData:: is_empty() const { return _frames.empty(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_latest_frame_number -// Access: Public -// Description: Returns the frame number of the most recent frame -// stored in the data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame number of the most recent frame stored in the data. + */ int PStatThreadData:: get_latest_frame_number() const { nassertr(!_frames.empty(), 0); return _first_frame_number + _frames.size() - 1; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_oldest_frame_number -// Access: Public -// Description: Returns the frame number of the oldest frame still -// stored in the data. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame number of the oldest frame still stored in the data. + */ int PStatThreadData:: get_oldest_frame_number() const { nassertr(!_frames.empty(), 0); return _first_frame_number; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::has_frame -// Access: Public -// Description: Returns true if we have received data for the -// indicated frame number from the client and we still -// have it stored, or false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we have received data for the indicated frame number from + * the client and we still have it stored, or false otherwise. + */ bool PStatThreadData:: has_frame(int frame_number) const { int rel_frame = frame_number - _first_frame_number; @@ -95,14 +78,11 @@ has_frame(int frame_number) const { _frames[rel_frame] != (PStatFrameData *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_frame -// Access: Public -// Description: Returns a FrameData structure associated with the -// indicated frame number. If the frame data has not -// yet been received from the client, returns the newest -// frame older than the requested frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns a FrameData structure associated with the indicated frame number. + * If the frame data has not yet been received from the client, returns the + * newest frame older than the requested frame. + */ const PStatFrameData &PStatThreadData:: get_frame(int frame_number) const { int rel_frame = frame_number - _first_frame_number; @@ -134,51 +114,42 @@ get_frame(int frame_number) const { return _null_frame; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_latest_time -// Access: Public -// Description: Returns the timestamp (in seconds elapsed since -// connection) of the latest available frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp (in seconds elapsed since connection) of the latest + * available frame. + */ double PStatThreadData:: get_latest_time() const { nassertr(!_frames.empty(), 0.0); return _frames.back()->get_start(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_oldest_time -// Access: Public -// Description: Returns the timestamp (in seconds elapsed since -// connection) of the oldest available frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the timestamp (in seconds elapsed since connection) of the oldest + * available frame. + */ double PStatThreadData:: get_oldest_time() const { nassertr(!_frames.empty(), 0.0); return _frames.front()->get_start(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_frame_at_time -// Access: Public -// Description: Returns the FrameData structure associated with the -// latest frame not later than the indicated time. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FrameData structure associated with the latest frame not later + * than the indicated time. + */ const PStatFrameData &PStatThreadData:: get_frame_at_time(double time) const { return get_frame(get_frame_number_at_time(time)); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_frame_number_at_time -// Access: Public -// Description: Returns the frame number of the latest frame not -// later than the indicated time. -// -// If the hint is nonnegative, it represents a frame -// number that we believe the correct answer to be near, -// which may speed the search for the frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame number of the latest frame not later than the indicated + * time. + * + * If the hint is nonnegative, it represents a frame number that we believe + * the correct answer to be near, which may speed the search for the frame. + */ int PStatThreadData:: get_frame_number_at_time(double time, int hint) const { hint -= _first_frame_number; @@ -199,8 +170,7 @@ get_frame_number_at_time(double time, int hint) const { } } - // The hint is totally wrong. Start from the end and work - // backwards. + // The hint is totally wrong. Start from the end and work backwards. int i = _frames.size() - 1; while (i >= 0) { @@ -214,27 +184,21 @@ get_frame_number_at_time(double time, int hint) const { return _first_frame_number + i; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_latest_frame -// Access: Public -// Description: Returns the FrameData associated with the most recent -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Returns the FrameData associated with the most recent frame. + */ const PStatFrameData &PStatThreadData:: get_latest_frame() const { nassertr(!_frames.empty(), _null_frame); return *_frames.back(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_elapsed_frames -// Access: Public -// Description: Computes the oldest frame number not older than -// pstats_average_time seconds, and the newest frame -// number. Handy for computing average frame rate over -// a time. Returns true if there is any data in that -// range, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Computes the oldest frame number not older than pstats_average_time + * seconds, and the newest frame number. Handy for computing average frame + * rate over a time. Returns true if there is any data in that range, false + * otherwise. + */ bool PStatThreadData:: get_elapsed_frames(int &then_i, int &now_i) const { if (!_computed_elapsed_frames) { @@ -246,13 +210,10 @@ get_elapsed_frames(int &then_i, int &now_i) const { return _got_elapsed_frames; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_frame_rate -// Access: Public -// Description: Computes the average frame rate over the past -// pstats_average_time seconds, by counting up the -// number of frames elapsed in that time interval. -//////////////////////////////////////////////////////////////////// +/** + * Computes the average frame rate over the past pstats_average_time seconds, + * by counting up the number of frames elapsed in that time interval. + */ double PStatThreadData:: get_frame_rate() const { int then_i, now_i; @@ -267,52 +228,42 @@ get_frame_rate() const { } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::set_history -// Access: Public -// Description: Sets the number of seconds worth of frames that will -// be retained by the ThreadData structure as each new -// frame is added. This affects how old the oldest -// frame that may be queried is. -//////////////////////////////////////////////////////////////////// +/** + * Sets the number of seconds worth of frames that will be retained by the + * ThreadData structure as each new frame is added. This affects how old the + * oldest frame that may be queried is. + */ void PStatThreadData:: set_history(double time) { _history = time; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::get_history -// Access: Public -// Description: Returns the number of seconds worth of frames that -// will be retained by the ThreadData structure as each -// new frame is added. This affects how old the oldest -// frame that may be queried is. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of seconds worth of frames that will be retained by the + * ThreadData structure as each new frame is added. This affects how old the + * oldest frame that may be queried is. + */ double PStatThreadData:: get_history() const { return _history; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::record_new_frame -// Access: Public -// Description: Makes room for and stores a new frame's worth of -// data. Calling this function may cause old frame data -// to be discarded to make room, according to the amount -// of time set up via set_history(). -// -// The pointer will become owned by the PStatThreadData -// object and will be freed on destruction. -//////////////////////////////////////////////////////////////////// +/** + * Makes room for and stores a new frame's worth of data. Calling this + * function may cause old frame data to be discarded to make room, according + * to the amount of time set up via set_history(). + * + * The pointer will become owned by the PStatThreadData object and will be + * freed on destruction. + */ void PStatThreadData:: record_new_frame(int frame_number, PStatFrameData *frame_data) { nassertv(frame_data != (PStatFrameData *)NULL); nassertv(!frame_data->is_empty()); double time = frame_data->get_start(); - // First, remove all the old frames that fall outside of our - // history window. + // First, remove all the old frames that fall outside of our history window. double oldest_allowable_time = time - _history; while (!_frames.empty() && (_frames.front() == (PStatFrameData *)NULL || @@ -325,9 +276,9 @@ record_new_frame(int frame_number, PStatFrameData *frame_data) { _first_frame_number++; } - // Now, add enough empty frame definitions to account for the latest - // frame number. This might involve some skips, since we don't - // guarantee that we get all the frames in order or even at all. + // Now, add enough empty frame definitions to account for the latest frame + // number. This might involve some skips, since we don't guarantee that we + // get all the frames in order or even at all. if (_frames.empty()) { _first_frame_number = frame_number; _frames.push_back(NULL); @@ -350,20 +301,17 @@ record_new_frame(int frame_number, PStatFrameData *frame_data) { _computed_elapsed_frames = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatThreadData::compute_elapsed_frames -// Access: Private -// Description: Computes the frame numbers returned by -// get_elapsed_frames(). This is non-const, but only -// updates cached values, so may safely be called from a -// const method. -//////////////////////////////////////////////////////////////////// +/** + * Computes the frame numbers returned by get_elapsed_frames(). This is non- + * const, but only updates cached values, so may safely be called from a const + * method. + */ void PStatThreadData:: compute_elapsed_frames() { if (_frames.empty()) { // No frames in the data at all. _got_elapsed_frames = false; - + } else { _now_i = _frames.size() - 1; while (_now_i > 0 && _frames[_now_i] == (PStatFrameData *)NULL) { @@ -372,16 +320,16 @@ compute_elapsed_frames() { if (_now_i < 0) { // No frames have any real data. _got_elapsed_frames = false; - + } else { nassertv(_frames[_now_i] != (PStatFrameData *)NULL); - + double now = _frames[_now_i]->get_end(); double then = now - pstats_average_time; - + int old_i = _now_i; _then_i = _now_i; - + while (old_i >= 0) { const PStatFrameData *frame = _frames[old_i]; if (frame != (PStatFrameData *)NULL) { @@ -393,7 +341,7 @@ compute_elapsed_frames() { } old_i--; } - + nassertv(_then_i >= 0); nassertv(_frames[_then_i] != (PStatFrameData *)NULL); _got_elapsed_frames = true; @@ -402,6 +350,6 @@ compute_elapsed_frames() { _then_i += _first_frame_number; } } - + _computed_elapsed_frames = true; } diff --git a/pandatool/src/pstatserver/pStatThreadData.h b/pandatool/src/pstatserver/pStatThreadData.h index 0032796409..a22ac9509c 100644 --- a/pandatool/src/pstatserver/pStatThreadData.h +++ b/pandatool/src/pstatserver/pStatThreadData.h @@ -1,16 +1,15 @@ -// Filename: pStatThreadData.h -// Created by: drose (08Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatThreadData.h + * @author drose + * @date 2000-07-08 + */ #ifndef PSTATTHREADDATA_H #define PSTATTHREADDATA_H @@ -25,16 +24,13 @@ class PStatCollectorDef; class PStatFrameData; class PStatClientData; -//////////////////////////////////////////////////////////////////// -// Class : PStatThreadData -// Description : A collection of FrameData structures for -// recently-received frames within a particular thread. -// This holds the raw data as reported by the client, -// and it automatically handles frames received -// out-of-order or skipped. You can ask for a -// particular frame by frame number or time and receive -// the data for the nearest frame. -//////////////////////////////////////////////////////////////////// +/** + * A collection of FrameData structures for recently-received frames within a + * particular thread. This holds the raw data as reported by the client, and + * it automatically handles frames received out-of-order or skipped. You can + * ask for a particular frame by frame number or time and receive the data for + * the nearest frame. + */ class PStatThreadData : public ReferenceCount { public: PStatThreadData(const PStatClientData *client_data); @@ -85,4 +81,3 @@ private: #include "pStatThreadData.I" #endif - diff --git a/pandatool/src/pstatserver/pStatView.I b/pandatool/src/pstatserver/pStatView.I index aa07cade85..3066ba0f8c 100644 --- a/pandatool/src/pstatserver/pStatView.I +++ b/pandatool/src/pstatserver/pStatView.I @@ -1,90 +1,69 @@ -// Filename: pStatView.I -// Created by: drose (12Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatView.I + * @author drose + * @date 2000-07-12 + */ - - -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_thread_data -// Access: Public -// Description: Returns the current PStatThreadData associated with -// the view. This was set by a previous call to -// set_thread_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current PStatThreadData associated with the view. This was set + * by a previous call to set_thread_data(). + */ INLINE const PStatThreadData *PStatView:: get_thread_data() { return _thread_data; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_client_data -// Access: Public -// Description: Returns the current PStatClientData associated with -// the view. This was also set by a previous call to -// set_thread_data(). -//////////////////////////////////////////////////////////////////// +/** + * Returns the current PStatClientData associated with the view. This was + * also set by a previous call to set_thread_data(). + */ INLINE const PStatClientData *PStatView:: get_client_data() { return _client_data; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::set_to_frame -// Access: Public -// Description: Sets to a particular frame number (or the nearest -// available), extracted from the View's PStatThreadData -// pointer. See the comments in the other flavor of -// set_to_frame(). -//////////////////////////////////////////////////////////////////// +/** + * Sets to a particular frame number (or the nearest available), extracted + * from the View's PStatThreadData pointer. See the comments in the other + * flavor of set_to_frame(). + */ INLINE void PStatView:: set_to_frame(int frame_number) { set_to_frame(_thread_data->get_frame(frame_number)); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::set_to_time -// Access: Public -// Description: Sets to the frame that occurred at the indicated time -// (or the nearest available frame), extracted from the -// View's PStatThreadData pointer. See the comments in -// set_to_frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets to the frame that occurred at the indicated time (or the nearest + * available frame), extracted from the View's PStatThreadData pointer. See + * the comments in set_to_frame. + */ INLINE void PStatView:: set_to_time(double time) { set_to_frame(_thread_data->get_frame_at_time(time)); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_show_level -// Access: Public -// Description: Returns true if we are showing level data, false if -// time data. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if we are showing level data, false if time data. + */ INLINE bool PStatView:: get_show_level() const { return _show_level; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_level_index -// Access: Public -// Description: Returns an index number that can be used to determine -// when the set of known levels has changed. Each time -// the set of levels in the view changes (because of new -// data arriving from the client, for instance), this -// number is incremented. -//////////////////////////////////////////////////////////////////// +/** + * Returns an index number that can be used to determine when the set of known + * levels has changed. Each time the set of levels in the view changes + * (because of new data arriving from the client, for instance), this number + * is incremented. + */ INLINE int PStatView:: get_level_index() const { return _level_index; diff --git a/pandatool/src/pstatserver/pStatView.cxx b/pandatool/src/pstatserver/pStatView.cxx index b9315370d5..b8d6aa9793 100644 --- a/pandatool/src/pstatserver/pStatView.cxx +++ b/pandatool/src/pstatserver/pStatView.cxx @@ -1,16 +1,15 @@ -// Filename: pStatView.cxx -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatView.cxx + * @author drose + * @date 2000-07-10 + */ #include "pStatView.h" @@ -24,13 +23,11 @@ -//////////////////////////////////////////////////////////////////// -// Class : FrameSample -// Description : This class is used within this module only--in fact, -// within PStatView::set_to_frame() only--to help -// collect event data out of the PStatFrameData object -// and boil it down to a list of elapsed times. -//////////////////////////////////////////////////////////////////// +/** + * This class is used within this module only--in fact, within + * PStatView::set_to_frame() only--to help collect event data out of the + * PStatFrameData object and boil it down to a list of elapsed times. + */ class FrameSample { public: typedef plist Started; @@ -44,18 +41,17 @@ public: void data_point(double time, bool is_start, Started &started) { _touched = true; - // We only consider events that change the start/stop state. - // With two consecutive 'start' events, for instance, we ignore - // the second one. + // We only consider events that change the startstop state. With two + // consecutive 'start' events, for instance, we ignore the second one. - // *** That's not quite the right thing to do. We should keep - // track of the nesting level and bracket things correctly, so - // that we ignore the second start and the *first* stop, but - // respect the outer start/stop. For the short term, this - // works, because the client is already doing this logic and - // won't send us nested start/stop pairs, but we'd like to - // generalize this in the future so we can deal with these - // nested pairs properly. +/* + * *** That's not quite the right thing to do. We should keep track of the + * nesting level and bracket things correctly, so that we ignore the second + * start and the *first* stop, but respect the outer startstop. For the short + * term, this works, because the client is already doing this logic and won't + * send us nested startstop pairs, but we'd like to generalize this in the + * future so we can deal with these nested pairs properly. + */ nassertv(is_start != _is_started); _is_started = is_start; @@ -122,11 +118,9 @@ public: -//////////////////////////////////////////////////////////////////// -// Function: PStatView::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatView:: PStatView() { _constraint = 0; @@ -135,37 +129,30 @@ PStatView() { _level_index = 0; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatView:: ~PStatView() { clear_levels(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::constrain -// Access: Public -// Description: Changes the focus of the View. By default, the View -// reports the entire time for the frame, and all of the -// Collectors that are directly parented to "Frame". By -// constraining the view to a particular collector, you -// cause the View to zoom in on that collector's data, -// reporting only the collector and its immediate -// parents. -// -// When you constrain the view, you may also specify -// whether the view should show time data or level data -// for the indicated collector. If level data, it -// reports the levels for the collector, and all of its -// children; otherwise, it collects the elapsed time. -// -// Changing the constraint causes the current frame's -// data to become invalidated; you must then call -// set_to_frame() again to get any useful data out. -//////////////////////////////////////////////////////////////////// +/** + * Changes the focus of the View. By default, the View reports the entire + * time for the frame, and all of the Collectors that are directly parented to + * "Frame". By constraining the view to a particular collector, you cause the + * View to zoom in on that collector's data, reporting only the collector and + * its immediate parents. + * + * When you constrain the view, you may also specify whether the view should + * show time data or level data for the indicated collector. If level data, + * it reports the levels for the collector, and all of its children; + * otherwise, it collects the elapsed time. + * + * Changing the constraint causes the current frame's data to become + * invalidated; you must then call set_to_frame() again to get any useful data + * out. + */ void PStatView:: constrain(int collector, bool show_level) { _constraint = collector; @@ -173,22 +160,18 @@ constrain(int collector, bool show_level) { clear_levels(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::unconstrain -// Access: Public -// Description: Restores the view to the full frame. This is -// equivalent to calling constrain(0). -//////////////////////////////////////////////////////////////////// +/** + * Restores the view to the full frame. This is equivalent to calling + * constrain(0). + */ void PStatView:: unconstrain() { constrain(0, false); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::set_thread_data -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void PStatView:: set_thread_data(const PStatThreadData *thread_data) { _thread_data = thread_data; @@ -197,21 +180,16 @@ set_thread_data(const PStatThreadData *thread_data) { _all_collectors_known = false; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::set_to_frame -// Access: Public -// Description: Supplies the View with the data for the current -// frame. This causes the View to update all of its -// internal data to reflect the frame's data, subject to -// the current constraint. -// -// It is possible that calling this will increase the -// total number of reported levels (for instance, if -// this frame introduced a new collector that hadn't -// been active previously). In this case, the caller -// must update its display or whatever to account for -// the new level. -//////////////////////////////////////////////////////////////////// +/** + * Supplies the View with the data for the current frame. This causes the + * View to update all of its internal data to reflect the frame's data, + * subject to the current constraint. + * + * It is possible that calling this will increase the total number of reported + * levels (for instance, if this frame introduced a new collector that hadn't + * been active previously). In this case, the caller must update its display + * or whatever to account for the new level. + */ void PStatView:: set_to_frame(const PStatFrameData &frame_data) { nassertv(!_thread_data.is_null()); @@ -225,27 +203,21 @@ set_to_frame(const PStatFrameData &frame_data) { } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::all_collectors_known -// Access: Public -// Description: After a call to set_to_frame(), this returns true if -// all collectors in the FrameData are known by the -// PStatsData object, or false if some are still unknown -// (even those that do not appear in the view). -//////////////////////////////////////////////////////////////////// +/** + * After a call to set_to_frame(), this returns true if all collectors in the + * FrameData are known by the PStatsData object, or false if some are still + * unknown (even those that do not appear in the view). + */ bool PStatView:: all_collectors_known() const { return _all_collectors_known; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_net_value -// Access: Public -// Description: Returns the total value accounted for by the frame (or -// by whatever Collector we are constrained to). This -// is the sum of all of the individual levels' -// get_net_value() value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total value accounted for by the frame (or by whatever + * Collector we are constrained to). This is the sum of all of the individual + * levels' get_net_value() value. + */ double PStatView:: get_net_value() const { double net = 0.0; @@ -257,26 +229,21 @@ get_net_value() const { return net; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_top_level -// Access: Public -// Description: Returns a pointer to the level that corresponds to -// the Collector we've constrained to. This is the top -// of a graph of levels; typically the next level -// down--the children of this level--will be the levels -// you want to display to the user. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the level that corresponds to the Collector we've + * constrained to. This is the top of a graph of levels; typically the next + * level down--the children of this level--will be the levels you want to + * display to the user. + */ const PStatViewLevel *PStatView:: get_top_level() { return get_level(_constraint); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::has_level -// Access: Public -// Description: Returns true if there is a level defined for the -// particular collector, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if there is a level defined for the particular collector, + * false otherwise. + */ bool PStatView:: has_level(int collector) const { Levels::const_iterator li; @@ -284,15 +251,11 @@ has_level(int collector) const { return (li != _levels.end()); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::get_level -// Access: Public -// Description: Returns a pointer to the level that corresponds to -// the indicated Collector. If there is no such level -// in the view, one will be created--use with caution. -// Check has_level() first if you don't want this -// behavior. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the level that corresponds to the indicated Collector. + * If there is no such level in the view, one will be created--use with + * caution. Check has_level() first if you don't want this behavior. + */ PStatViewLevel *PStatView:: get_level(int collector) { Levels::const_iterator li; @@ -310,12 +273,9 @@ get_level(int collector) { return level; } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::update_time_data -// Access: Private -// Description: The implementation of set_to_frame() for views that -// show elapsed time. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of set_to_frame() for views that show elapsed time. + */ void PStatView:: update_time_data(const PStatFrameData &frame_data) { int num_events = frame_data.get_num_events(); @@ -344,19 +304,18 @@ update_time_data(const PStatFrameData &frame_data) { nassertv(collector_index >= 0 && collector_index < (int)samples.size()); if (_client_data->get_child_distance(_constraint, collector_index) >= 0) { - // Here's a data point we care about: anything at constraint - // level or below. + // Here's a data point we care about: anything at constraint level or + // below. if (is_start == samples[collector_index]._is_started) { if (!is_start) { - // A "stop" in the middle of a frame implies a "start" - // since time 0 (that is, since the first data point in - // the frame). + // A "stop" in the middle of a frame implies a "start" since time + // 0 (that is, since the first data point in the frame). samples[collector_index].data_point(frame_data.get_time(0), true, started); samples[collector_index].data_point(frame_data.get_time(i), is_start, started); } else { - // An extra "start" for a collector that's already started - // is an error. - nout << "Unexpected data point for " + // An extra "start" for a collector that's already started is an + // error. + nout << "Unexpected data point for " << _client_data->get_collector_fullname(collector_index) << "\n"; } @@ -381,13 +340,13 @@ update_time_data(const PStatFrameData &frame_data) { bool any_new_levels = false; - // Now match these samples we got up with those we already had in - // the levels. + // Now match these samples we got up with those we already had in the + // levels. Levels::iterator li, lnext; li = _levels.begin(); while (li != _levels.end()) { - // Be careful while traversing a container and calling functions - // that could modify that container. + // Be careful while traversing a container and calling functions that + // could modify that container. lnext = li; ++lnext; @@ -407,8 +366,8 @@ update_time_data(const PStatFrameData &frame_data) { li = lnext; } - // Finally, any samples left over in the got_samples set are new - // collectors that we need to add to the Levels list. + // Finally, any samples left over in the got_samples set are new collectors + // that we need to add to the Levels list. if (!got_samples.empty()) { any_new_levels = true; @@ -425,12 +384,9 @@ update_time_data(const PStatFrameData &frame_data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::update_level_data -// Access: Private -// Description: The implementation of set_to_frame() for views that -// show level values. -//////////////////////////////////////////////////////////////////// +/** + * The implementation of set_to_frame() for views that show level values. + */ void PStatView:: update_level_data(const PStatFrameData &frame_data) { _all_collectors_known = true; @@ -456,10 +412,9 @@ update_level_data(const PStatFrameData &frame_data) { } } - // Now that we've counted up the net level for each collector, - // compute the level for each collector alone by subtracting out - // each child from its parents. If a parent has no data, nothing is - // subtracted. + // Now that we've counted up the net level for each collector, compute the + // level for each collector alone by subtracting out each child from its + // parents. If a parent has no data, nothing is subtracted. GotValues alone_values = net_values; GotValues::iterator gi; @@ -467,8 +422,7 @@ update_level_data(const PStatFrameData &frame_data) { int collector_index = (*gi).first; double value = (*gi).second; - // Walk up to the top, but stop when we find a parent with actual - // data. + // Walk up to the top, but stop when we find a parent with actual data. while (collector_index != 0 && collector_index != _constraint) { const PStatCollectorDef &def = _client_data->get_collector_def(collector_index); @@ -486,13 +440,13 @@ update_level_data(const PStatFrameData &frame_data) { bool any_new_levels = false; - // Now match these samples we got up with those we already had in - // the levels. + // Now match these samples we got up with those we already had in the + // levels. Levels::iterator li, lnext; li = _levels.begin(); while (li != _levels.end()) { - // Be careful while traversing a container and calling functions - // that could modify that container. + // Be careful while traversing a container and calling functions that + // could modify that container. lnext = li; ++lnext; @@ -512,8 +466,8 @@ update_level_data(const PStatFrameData &frame_data) { li = lnext; } - // Finally, any values left over in the alone_values set are new - // collectors that we need to add to the Levels list. + // Finally, any values left over in the alone_values set are new collectors + // that we need to add to the Levels list. if (!alone_values.empty()) { any_new_levels = true; @@ -530,11 +484,9 @@ update_level_data(const PStatFrameData &frame_data) { } } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::clear_levels -// Access: Private -// Description: Resets all the levels that have been defined so far. -//////////////////////////////////////////////////////////////////// +/** + * Resets all the levels that have been defined so far. + */ void PStatView:: clear_levels() { Levels::iterator li; @@ -544,19 +496,15 @@ clear_levels() { _levels.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatView::reset_level -// Access: Private -// Description: Resets the total value of the Level to zero, and also -// makes sure it is parented to the right Level -// corresponding to its Collector's parent. Since the -// client might change its mind from time to time about -// who the Collector is parented to, we have to update -// this dynamically. -// -// Returns true if any change was made to the level's -// hierarchy, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Resets the total value of the Level to zero, and also makes sure it is + * parented to the right Level corresponding to its Collector's parent. Since + * the client might change its mind from time to time about who the Collector + * is parented to, we have to update this dynamically. + * + * Returns true if any change was made to the level's hierarchy, false + * otherwise. + */ bool PStatView:: reset_level(PStatViewLevel *level) { bool any_changed = false; @@ -581,8 +529,7 @@ reset_level(PStatViewLevel *level) { any_changed = true; } else if (level->_parent->_collector != parent_index) { - // This level knew about its parent, but now it's something - // different. + // This level knew about its parent, but now it's something different. PStatViewLevel *old_parent_level = level->_parent; nassertr(old_parent_level != level, true); @@ -609,5 +556,3 @@ reset_level(PStatViewLevel *level) { return any_changed; } - - diff --git a/pandatool/src/pstatserver/pStatView.h b/pandatool/src/pstatserver/pStatView.h index aa94d138cb..3bae72b168 100644 --- a/pandatool/src/pstatserver/pStatView.h +++ b/pandatool/src/pstatserver/pStatView.h @@ -1,16 +1,15 @@ -// Filename: pStatView.h -// Created by: drose (10Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatView.h + * @author drose + * @date 2000-07-10 + */ #ifndef PSTATVIEW_H #define PSTATVIEW_H @@ -23,14 +22,12 @@ #include "pmap.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : PStatView -// Description : A View boils down the frame data to a linear list of -// times spent in a number of different Collectors, -// within a particular thread. This automatically -// accounts for overlapping start/stop times and nested -// Collectors in a sensible way. -//////////////////////////////////////////////////////////////////// +/** + * A View boils down the frame data to a linear list of times spent in a + * number of different Collectors, within a particular thread. This + * automatically accounts for overlapping start/stop times and nested + * Collectors in a sensible way. + */ class PStatView { public: PStatView(); @@ -54,7 +51,7 @@ public: bool has_level(int collector) const; PStatViewLevel *get_level(int collector); - + INLINE bool get_show_level() const; INLINE int get_level_index() const; @@ -81,4 +78,3 @@ private: #include "pStatView.I" #endif - diff --git a/pandatool/src/pstatserver/pStatViewLevel.I b/pandatool/src/pstatserver/pStatViewLevel.I index f2371f33fc..f682c36b73 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.I +++ b/pandatool/src/pstatserver/pStatViewLevel.I @@ -1,36 +1,28 @@ -// Filename: pStatViewLevel.I -// Created by: drose (19Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatViewLevel.I + * @author drose + * @date 2000-07-19 + */ - -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::get_collector -// Access: Public -// Description: Returns the Collector index associated with this -// level. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Collector index associated with this level. + */ INLINE int PStatViewLevel:: get_collector() const { return _collector; } -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::get_value_alone -// Access: Public -// Description: Returns the total level value (or elapsed time value) -// for this Collector, not including any values -// accounted for by its child Collectors. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total level value (or elapsed time value) for this Collector, + * not including any values accounted for by its child Collectors. + */ INLINE double PStatViewLevel:: get_value_alone() const { return _value_alone; diff --git a/pandatool/src/pstatserver/pStatViewLevel.cxx b/pandatool/src/pstatserver/pStatViewLevel.cxx index daeadfb24d..04d962e833 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.cxx +++ b/pandatool/src/pstatserver/pStatViewLevel.cxx @@ -1,16 +1,15 @@ -// Filename: pStatViewLevel.cxx -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatViewLevel.cxx + * @author drose + * @date 2000-07-11 + */ #include "pStatViewLevel.h" #include "pStatClientData.h" @@ -20,13 +19,10 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::get_net_value -// Access: Public -// Description: Returns the total level value (or elapsed time) -// represented by this Collector, including all values -// in its child Collectors. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total level value (or elapsed time) represented by this + * Collector, including all values in its child Collectors. + */ double PStatViewLevel:: get_net_value() const { double net = _value_alone; @@ -40,8 +36,8 @@ get_net_value() const { } -// STL function object for sorting children in order by the -// collector's sort index, used in sort_children(), below. +// STL function object for sorting children in order by the collector's sort +// index, used in sort_children(), below. class SortCollectorLevels { public: SortCollectorLevels(const PStatClientData *client_data) : @@ -55,12 +51,10 @@ public: const PStatClientData *_client_data; }; -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::sort_children -// Access: Public -// Description: Sorts the children of this view level into order as -// specified by the client's sort index. -//////////////////////////////////////////////////////////////////// +/** + * Sorts the children of this view level into order as specified by the + * client's sort index. + */ void PStatViewLevel:: sort_children(const PStatClientData *client_data) { SortCollectorLevels sort_levels(client_data); @@ -68,24 +62,19 @@ sort_children(const PStatClientData *client_data) { sort(_children.begin(), _children.end(), sort_levels); } -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::get_num_children -// Access: Public -// Description: Returns the number of children of this -// Level/Collector. These are the Collectors whose -// value is considered to be part of the total value of -// this level's Collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of children of this Level/Collector. These are the + * Collectors whose value is considered to be part of the total value of this + * level's Collector. + */ int PStatViewLevel:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: PStatViewLevel::get_child -// Access: Public -// Description: Returns the nth child of this Level/Collector. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of this Level/Collector. + */ const PStatViewLevel *PStatViewLevel:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), NULL); diff --git a/pandatool/src/pstatserver/pStatViewLevel.h b/pandatool/src/pstatserver/pStatViewLevel.h index 87b5f05a0f..006a512ddc 100644 --- a/pandatool/src/pstatserver/pStatViewLevel.h +++ b/pandatool/src/pstatserver/pStatViewLevel.h @@ -1,16 +1,15 @@ -// Filename: pStatViewLevel.h -// Created by: drose (11Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file pStatViewLevel.h + * @author drose + * @date 2000-07-11 + */ #ifndef PSTATVIEWLEVEL_H #define PSTATVIEWLEVEL_H @@ -21,15 +20,12 @@ class PStatClientData; -//////////////////////////////////////////////////////////////////// -// Class : PStatViewLevel -// Description : This is a single level value, or band of color, -// within a View. -// -// It generally indicates either the elapsed time, or -// the "level" value, for a particular Collector within -// a given frame for a particular thread. -//////////////////////////////////////////////////////////////////// +/** + * This is a single level value, or band of color, within a View. + * + * It generally indicates either the elapsed time, or the "level" value, for a + * particular Collector within a given frame for a particular thread. + */ class PStatViewLevel { public: INLINE int get_collector() const; diff --git a/pandatool/src/ptloader/config_ptloader.cxx b/pandatool/src/ptloader/config_ptloader.cxx index bb60749dab..e3fb3f9dd9 100644 --- a/pandatool/src/ptloader/config_ptloader.cxx +++ b/pandatool/src/ptloader/config_ptloader.cxx @@ -1,22 +1,21 @@ -// Filename: config_ptloader.cxx -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ptloader.cxx + * @author drose + * @date 2001-04-26 + */ #include "config_ptloader.h" // This needs to be included first to work around a bug in OSX 10.4. #if defined(HAVE_FCOLLADA) && defined(IS_OSX) -#include "daeToEggConverter.h" +#include "daeToEggConverter.h" #endif #include "loaderFileTypePandatool.h" @@ -34,7 +33,7 @@ // Windows freaks out if this input is placed earlier. #if defined(HAVE_FCOLLADA) && !defined(IS_OSX) -#include "daeToEggConverter.h" +#include "daeToEggConverter.h" #endif #include "dconfig.h" @@ -62,14 +61,12 @@ ConfigVariableBool ptloader_load_node "always go through the egg library, which is more likely to be " "reliable.")); -//////////////////////////////////////////////////////////////////// -// Function: init_libptloader -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libptloader() { static bool initialized = false; @@ -104,17 +101,14 @@ init_libptloader() { EggToObjConverter *egg_obj = new EggToObjConverter; reg->register_type(new LoaderFileTypePandatool(obj_egg, egg_obj)); -//#ifdef HAVE_FCOLLADA -// DAEToEggConverter *dae = new DAEToEggConverter; -// reg->register_type(new LoaderFileTypePandatool(dae)); -//#endif +// #ifdef HAVE_FCOLLADA DAEToEggConverter *dae = new DAEToEggConverter; +// reg->register_type(new LoaderFileTypePandatool(dae)); #endif #ifdef HAVE_MAYA - // Register the Maya converter as a deferred type. We don't compile - // it in directly, because it's big and bulky; we don't need to - // force people to load up libmayaloader (and, along with it, all of - // the Maya API libraries) until they actually try to load a Maya - // file. + // Register the Maya converter as a deferred type. We don't compile it in + // directly, because it's big and bulky; we don't need to force people to + // load up libmayaloader (and, along with it, all of the Maya API libraries) + // until they actually try to load a Maya file. reg->register_deferred_type("mb", "mayaloader"); reg->register_deferred_type("ma", "mayaloader"); #endif diff --git a/pandatool/src/ptloader/config_ptloader.h b/pandatool/src/ptloader/config_ptloader.h index 3a8172c350..b195083b2b 100644 --- a/pandatool/src/ptloader/config_ptloader.h +++ b/pandatool/src/ptloader/config_ptloader.h @@ -1,16 +1,15 @@ -// Filename: config_ptloader.h -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_ptloader.h + * @author drose + * @date 2001-04-26 + */ #ifndef CONFIG_PTLOADER_H #define CONFIG_PTLOADER_H diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.cxx b/pandatool/src/ptloader/loaderFileTypePandatool.cxx index 7dda5f1052..b3bbdca822 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.cxx +++ b/pandatool/src/ptloader/loaderFileTypePandatool.cxx @@ -1,16 +1,15 @@ -// Filename: loaderFileTypePandatool.cxx -// Created by: drose (26Apr01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypePandatool.cxx + * @author drose + * @date 2001-04-26 + */ #include "loaderFileTypePandatool.h" #include "config_ptloader.h" @@ -25,11 +24,9 @@ TypeHandle LoaderFileTypePandatool::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypePandatool:: LoaderFileTypePandatool(SomethingToEggConverter *loader, EggToSomethingConverter *saver) : @@ -40,20 +37,16 @@ LoaderFileTypePandatool(SomethingToEggConverter *loader, } } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LoaderFileTypePandatool:: ~LoaderFileTypePandatool() { } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::get_name -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypePandatool:: get_name() const { if (_loader != (SomethingToEggConverter *)NULL) { @@ -62,11 +55,9 @@ get_name() const { return _saver->get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::get_extension -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ string LoaderFileTypePandatool:: get_extension() const { if (_loader != (SomethingToEggConverter *)NULL) { @@ -75,13 +66,10 @@ get_extension() const { return _saver->get_extension(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::get_additional_extensions -// Access: Public, Virtual -// Description: Returns a space-separated list of extension, in -// addition to the one returned by get_extension(), that -// are recognized by this converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns a space-separated list of extension, in addition to the one + * returned by get_extension(), that are recognized by this converter. + */ string LoaderFileTypePandatool:: get_additional_extensions() const { if (_loader != (SomethingToEggConverter *)NULL) { @@ -90,13 +78,10 @@ get_additional_extensions() const { return _saver->get_additional_extensions(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool LoaderFileTypePandatool:: supports_compressed() const { if (_loader != (SomethingToEggConverter *)NULL) { @@ -105,47 +90,38 @@ supports_compressed() const { return _saver->supports_compressed(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::supports_load -// Access: Published, Virtual -// Description: Returns true if the file type can be used to load -// files, and load_file() is supported. Returns false -// if load_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to load files, and load_file() is + * supported. Returns false if load_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypePandatool:: supports_load() const { return (_loader != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::supports_save -// Access: Published, Virtual -// Description: Returns true if the file type can be used to save -// files, and save_file() is supported. Returns false -// if save_file() is unimplemented and will always fail. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the file type can be used to save files, and save_file() is + * supported. Returns false if save_file() is unimplemented and will always + * fail. + */ bool LoaderFileTypePandatool:: supports_save() const { return (_saver != NULL); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::resolve_filename -// Access: Public, Virtual -// Description: Searches for the indicated filename on whatever paths -// are appropriate to this file type, and updates it if -// it is found. -//////////////////////////////////////////////////////////////////// +/** + * Searches for the indicated filename on whatever paths are appropriate to + * this file type, and updates it if it is found. + */ void LoaderFileTypePandatool:: resolve_filename(Filename &path) const { path.resolve_filename(get_model_path(), get_extension()); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::load_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PT(PandaNode) LoaderFileTypePandatool:: load_file(const Filename &path, const LoaderOptions &options, BamCacheRecord *record) const { @@ -170,11 +146,11 @@ load_file(const Filename &path, const LoaderOptions &options, case LoaderOptions::LF_convert_anim: loader->set_animation_convert(AC_both); break; - + case LoaderOptions::LF_convert_skeleton: loader->set_animation_convert(AC_model); break; - + case LoaderOptions::LF_convert_channels: loader->set_animation_convert(AC_chan); break; @@ -192,14 +168,14 @@ load_file(const Filename &path, const LoaderOptions &options, } } - // If the converter type doesn't support the direct PandaNode - // conversion, take the slower route through egg instead. + // If the converter type doesn't support the direct PandaNode conversion, + // take the slower route through egg instead. PT(EggData) egg_data = new EggData; loader->set_egg_data(egg_data); if (loader->convert_file(path)) { DistanceUnit input_units = loader->get_input_units(); - if (input_units != DU_invalid && ptloader_units != DU_invalid && + if (input_units != DU_invalid && ptloader_units != DU_invalid && input_units != ptloader_units) { // Convert the file to the units specified by the ptloader-units // Configrc variable. @@ -223,11 +199,9 @@ load_file(const Filename &path, const LoaderOptions &options, return result.p(); } -//////////////////////////////////////////////////////////////////// -// Function: LoaderFileTypePandatool::save_file -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool LoaderFileTypePandatool:: save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { diff --git a/pandatool/src/ptloader/loaderFileTypePandatool.h b/pandatool/src/ptloader/loaderFileTypePandatool.h index 943dfc37f4..3e38e3a8b9 100644 --- a/pandatool/src/ptloader/loaderFileTypePandatool.h +++ b/pandatool/src/ptloader/loaderFileTypePandatool.h @@ -1,16 +1,15 @@ -// Filename: loaderFileTypePandatool.h -// Created by: drose (20Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file loaderFileTypePandatool.h + * @author drose + * @date 2000-06-20 + */ #ifndef LOADERFILETYPEPANDATOOL_H #define LOADERFILETYPEPANDATOOL_H @@ -22,13 +21,11 @@ class SomethingToEggConverter; class EggToSomethingConverter; -//////////////////////////////////////////////////////////////////// -// Class : LoaderFileTypePandatool -// Description : This defines the Loader interface to files whose -// converters are defined within the Pandatool package -// and inherit from SomethingToEggConverter, like -// FltToEggConverter and LwoToEggConverter. -//////////////////////////////////////////////////////////////////// +/** + * This defines the Loader interface to files whose converters are defined + * within the Pandatool package and inherit from SomethingToEggConverter, like + * FltToEggConverter and LwoToEggConverter. + */ class EXPCL_PTLOADER LoaderFileTypePandatool : public LoaderFileType { public: LoaderFileTypePandatool(SomethingToEggConverter *loader, @@ -72,4 +69,3 @@ private: }; #endif - diff --git a/pandatool/src/softegg/config_softegg.cxx b/pandatool/src/softegg/config_softegg.cxx index 6f1d5a9bb2..89ad412508 100644 --- a/pandatool/src/softegg/config_softegg.cxx +++ b/pandatool/src/softegg/config_softegg.cxx @@ -1,16 +1,15 @@ -// Filename: config_softegg.cxx -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_softegg.cxx + * @author masad + * @date 2003-09-25 + */ #include "config_softegg.h" #include "softEggGroupUserData.h" @@ -25,27 +24,24 @@ ConfigureFn(config_softegg) { init_libsoftegg(); } -// These control the default behavior of the softegg converter, but -// not necessarily the default behavior of the soft2egg command-line -// tool (which has its own defaults). +// These control the default behavior of the softegg converter, but not +// necessarily the default behavior of the soft2egg command-line tool (which +// has its own defaults). -// Should we respect the Soft? double-sided flag (true) or ignore it -// and assume everything is single-sided (false)? +// Should we respect the Soft? double-sided flag (true) or ignore it and +// assume everything is single-sided (false)? ConfigVariableBool soft_default_double_sided("soft-default-double-sided", false); -// Should we apply vertex color even when a texture is applied (true) -// or only when no texture is applied or the vertex-color egg flag is -// set (false)? +// Should we apply vertex color even when a texture is applied (true) or only +// when no texture is applied or the vertex-color egg flag is set (false)? ConfigVariableBool soft_default_vertex_color("soft-default-vertex-color", true); -//////////////////////////////////////////////////////////////////// -// Function: init_libsoftegg -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libsoftegg() { static bool initialized = false; @@ -57,4 +53,3 @@ init_libsoftegg() { SoftEggGroupUserData::init_type(); SoftNodeDesc::init_type(); } - diff --git a/pandatool/src/softegg/config_softegg.h b/pandatool/src/softegg/config_softegg.h index a03fd78c10..8deb0cb7aa 100644 --- a/pandatool/src/softegg/config_softegg.h +++ b/pandatool/src/softegg/config_softegg.h @@ -1,16 +1,15 @@ -// Filename: config_softegg.h -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_softegg.h + * @author masad + * @date 2003-09-25 + */ #ifndef CONFIG_SOFTEGG_H #define CONFIG_SOFTEGG_H diff --git a/pandatool/src/softegg/soft2Egg.c b/pandatool/src/softegg/soft2Egg.c index a7f0764c48..aaad102fb4 100644 --- a/pandatool/src/softegg/soft2Egg.c +++ b/pandatool/src/softegg/soft2Egg.c @@ -1,16 +1,15 @@ -// Filename: soft2Egg.c -// Created by: masad (26Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file soft2Egg.c + * @author masad + * @date 2003-09-26 + */ #include @@ -46,7 +45,7 @@ int init_soft2egg(int, char **); static const int TEX_PER_MAT = 1; static FILE *outStream = stdout; -//static FILE *outStream = stderr; +// static FILE *outStream = stderr; class soft2egg : public EggBase { @@ -200,13 +199,10 @@ class soft2egg : public EggBase }; -//////////////////////////////////////////////////////////////////// -// Function: Help -// Access: Public, Virtual -// Description: Displays the "what is this program" message, along -// with the usage message. Should be overridden in base -// classes to describe the current program. -//////////////////////////////////////////////////////////////////// +/** + * Displays the "what is this program" message, along with the usage message. + * Should be overridden in base classes to describe the current program. + */ void soft2egg:: Help() { @@ -217,11 +213,9 @@ Help() Usage(); } -//////////////////////////////////////////////////////////////////// -// Function: Usage -// Access: Public, Virtual -// Description: Displays the usage message. -//////////////////////////////////////////////////////////////////// +/** + * Displays the usage message. + */ void soft2egg:: Usage() { cerr << "\nUsage:\n" @@ -234,20 +228,17 @@ Usage() { -//////////////////////////////////////////////////////////////////// -// Function: ShowOpts -// Access: Public, Virtual -// Description: Displays the valid options. Should be extended in -// base classes to show additional options relevant to -// the current program. -//////////////////////////////////////////////////////////////////// +/** + * Displays the valid options. Should be extended in base classes to show + * additional options relevant to the current program. + */ void soft2egg:: ShowOpts() { cerr << " -r - Used to provide soft with the resource\n" " Defaults to 'c:/Softimage/SOFT_3.9.2/3D/test'.\n" - // " Defaults to '/ful/ufs/soft371_mips2/3D/rsrc'.\n" + // " Defaults to 'fulufssoft371_mips23Drsrc'.\n" " -d - Database path.\n" " -s - Indicates that a scene will be converted.\n" " -m - Indicates that a model will be converted.\n" @@ -279,11 +270,9 @@ ShowOpts() } -//////////////////////////////////////////////////////////////////// -// Function: HandleGetopts -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ boolean soft2egg:: HandleGetopts(char flag, char *optarg, int &optind, int argc, char **argv) { @@ -407,8 +396,7 @@ HandleGetopts(char flag, char *optarg, int &optind, int argc, char **argv) break; case 'k': // Enable soft skinning - //make_soft = TRUE; - //fprintf( outStream, "enabling soft skinning\n" ); + // make_soft = TRUE; fprintf( outStream, "enabling soft skinning\n" ); fprintf( outStream, "-k flag no longer necessary\n" ); break; @@ -500,11 +488,9 @@ HandleGetopts(char flag, char *optarg, int &optind, int argc, char **argv) -//////////////////////////////////////////////////////////////////// -// Function: isNum -// Access: Public, Virtual -// Description: Take a float and make sure it is of the body. -//////////////////////////////////////////////////////////////////// +/** + * Take a float and make sure it is of the body. + */ int soft2egg:: isNum( float num ) { @@ -512,12 +498,10 @@ isNum( float num ) } -//////////////////////////////////////////////////////////////////// -// Function: GetRootName -// Access: Public -// Description: Given a string, return a copy of the string up to -// the first occurrence of '-'. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return a copy of the string up to the first occurrence of + * '-'. + */ char *soft2egg:: GetRootName( const char *name ) { @@ -544,12 +528,9 @@ GetRootName( const char *name ) } -//////////////////////////////////////////////////////////////////// -// Function: RemovePathName -// Access: Public -// Description: Given a string, return a copy of the string after -// the last occurence of '/ -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return a copy of the string after the last occurence of ' + */ char *soft2egg:: RemovePathName( const char *name ) { @@ -574,13 +555,10 @@ RemovePathName( const char *name ) return ( (char *)name ); } -//////////////////////////////////////////////////////////////////// -// Function: GetSliderName -// Access: Public -// Description: Given a string, return that part of the string after -// the first occurence of '-' and before the last -// occurance of '.' -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return that part of the string after the first occurence of + * '-' and before the last occurance of '.' + */ char *soft2egg:: GetSliderName( const char *name ) { @@ -618,12 +596,9 @@ GetSliderName( const char *name ) return( (char *)name ); } -//////////////////////////////////////////////////////////////////// -// Function: GetName -// Access: Public -// Description: Given an element, return a copy of the element's -// name WITHOUT prefix. -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a copy of the element's name WITHOUT prefix. + */ char *soft2egg:: GetName( SAA_Scene *scene, SAA_Elem *element ) { @@ -638,12 +613,9 @@ GetName( SAA_Scene *scene, SAA_Elem *element ) return name; } -//////////////////////////////////////////////////////////////////// -// Function: GetFullName -// Access: Public -// Description: Given an element, return a copy of the element's -// name complete with prefix. -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a copy of the element's name complete with prefix. + */ char *soft2egg:: GetFullName( SAA_Scene *scene, SAA_Elem *element ) { @@ -668,18 +640,15 @@ GetFullName( SAA_Scene *scene, SAA_Elem *element ) // add 'em together fullNameStrm << prefix << "-" << name << ends; - //free( name ); - //free( prefix ); + // free( name ); free( prefix ); return fullNameStrm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: GetModelNoteInfo -// Access: Public -// Description: Given an element, return a string containing the -// contents of its MODEL NOTE entry -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a string containing the contents of its MODEL NOTE + * entry + */ char *soft2egg:: GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { @@ -700,7 +669,7 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) SAA_elementGetUserData( scene, model, "MNOT", size, &bigEndian, (void *)modelNote ); - //strip off newline, if present + // strip off newline, if present char *eol = strchr( modelNote, '\n' ); if ( eol != NULL) *eol = '\0'; @@ -716,12 +685,10 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) } -//////////////////////////////////////////////////////////////////// -// Function: MakeTableName -// Access: Public -// Description: Given a string, and a number, return a new string -// consisting of "string.number". -//////////////////////////////////////////////////////////////////// +/** + * Given a string, and a number, return a new string consisting of + * "string.number". + */ char *soft2egg:: MakeTableName( const char *name, int number ) { @@ -731,12 +698,10 @@ MakeTableName( const char *name, int number ) return namestrm.str(); } -//////////////////////////////////////////////////////////////////// -// Function: FindModelByName -// Access: Public -// Description: Given a string, find the model in the scene -// whose name corresponds to the given string. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, find the model in the scene whose name corresponds to the + * given string. + */ SAA_Elem *soft2egg:: FindModelByName( char *name, SAA_Scene *scene, SAA_Elem *models, int numModels ) @@ -766,12 +731,9 @@ FindModelByName( char *name, SAA_Scene *scene, SAA_Elem *models, } -//////////////////////////////////////////////////////////////////// -// Function: DepointellizeName -// Access: Public -// Description: Given a string, return the string up to the first -// period. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return the string up to the first period. + */ char *soft2egg:: DepointellizeName( char *name ) { @@ -789,13 +751,10 @@ DepointellizeName( char *name ) } -//////////////////////////////////////////////////////////////////// -// Function: ConvertTexture -// Access: Public -// Description: Given a string, return a copy of the string without -// the leading file path, and make an rgb file of the -// same name in the tex_path directory. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return a copy of the string without the leading file path, + * and make an rgb file of the same name in the tex_path directory. + */ char *soft2egg:: ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) { @@ -811,8 +770,8 @@ ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) SAA_texture2DGetPicName( scene, texture, fileNameLen, fileName ); } - // make sure we are not being passed a NULL image, an empty image - // string or the default image created by egg2soft + // make sure we are not being passed a NULL image, an empty image string or + // the default image created by egg2soft if ( (fileName != NULL) && strlen( fileName ) && strcmp( fileName, "/fat/people/gregw/new_test/PICTURES/default") && ( strstr( fileName, "noIcon" ) == NULL) ) @@ -878,7 +837,7 @@ ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) system( command ); - //free( command ); + // free( command ); } else if ( verbose >=1 ) @@ -899,7 +858,7 @@ ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) fileNameExt ); } - //free( fileNameExt ); + // free( fileNameExt ); if (tex_path) return( texNamePath ); @@ -913,13 +872,11 @@ ConvertTexture( SAA_Scene *scene, SAA_Elem *texture ) } } -//////////////////////////////////////////////////////////////////// -// Function: FindClosestTriVert -// Access: Public -// Description: Given an egg vertex pool, map each vertex therein to -// a vertex within an array of SAA model vertices of -// size numVert. Mapping is done by closest proximity. -//////////////////////////////////////////////////////////////////// +/** + * Given an egg vertex pool, map each vertex therein to a vertex within an + * array of SAA model vertices of size numVert. Mapping is done by closest + * proximity. + */ int *soft2egg:: FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { @@ -970,13 +927,11 @@ FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) } -//////////////////////////////////////////////////////////////////// -// Function: MakeIndexMap -// Access: Public -// Description: Given an array of indices that is a map from one -// set of vertices to another, return an array that -// performs the reverse mapping of the indices array -//////////////////////////////////////////////////////////////////// +/** + * Given an array of indices that is a map from one set of vertices to + * another, return an array that performs the reverse mapping of the indices + * array + */ int *soft2egg:: MakeIndexMap( int *indices, int numIndices, int mapSize ) { @@ -1018,12 +973,9 @@ MakeIndexMap( int *indices, int numIndices, int mapSize ) return( map ); } -//////////////////////////////////////////////////////////////////// -// Function: findShapeVert -// Access: Public -// Description: given a vertex, find its corresponding shape vertex -// and return its index. -//////////////////////////////////////////////////////////////////// +/** + * given a vertex, find its corresponding shape vertex and return its index. + */ int soft2egg:: findShapeVert( SAA_DVector vertex, SAA_DVector *vertices, int numVert ) { @@ -1052,11 +1004,9 @@ findShapeVert( SAA_DVector vertex, SAA_DVector *vertices, int numVert ) } -//////////////////////////////////////////////////////////////////// -// Function: LoadSoft -// Access: Public -// Description: Open the SI database and grab the scene & model info -//////////////////////////////////////////////////////////////////// +/** + * Open the SI database and grab the scene & model info + */ void soft2egg:: LoadSoft() { @@ -1131,7 +1081,7 @@ LoadSoft() float time; fprintf( outStream, "setting Scene to frame %d...\n", pose_frame ); - //SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); + // SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); SAA_frame2Seconds( &scene, pose_frame, &time ); SAA_updatelistEvalScene( &scene, time ); sginap( 100 ); @@ -1199,11 +1149,9 @@ LoadSoft() if ( make_poly || make_nurbs ) { - // generate soft skinning assignments if desired - // - //disabled 1/1/99 to streamline joint assignments. - // all joint assignments now done here. Hard & Soft. - //if ( make_soft) + // generate soft skinning assignments if desired disabled 1199 + // to streamline joint assignments. all joint assignments now + // done here. Hard & Soft. if ( make_soft) { char *name; char *fullname; @@ -1214,8 +1162,8 @@ LoadSoft() { SAA_modelIsSkeleton( &scene, &models[i], &isSkeleton ); - // get fullname for splitting files, but - // only use it in file if requested + // get fullname for splitting files, but only use it + // in file if requested fullname = GetFullName( &scene, &models[i] ); if ( use_prefix ) name = fullname; @@ -1231,15 +1179,15 @@ LoadSoft() numModels, name ); } - //free( name ); + // free( name ); } - // make sure all vertices were assigned - // via soft skinning - if not hard assign them + // make sure all vertices were assigned via soft skinning + // - if not hard assign them for ( i = 0; i < numModels; i++ ) { - // get fullname for splitting files, but - // only use it in file if requested + // get fullname for splitting files, but only use it + // in file if requested fullname = GetFullName( &scene, &models[i] ); if ( use_prefix ) name = fullname; @@ -1250,7 +1198,7 @@ LoadSoft() if ( strstr( fullname, search_prefix ) != NULL ) CleanUpSoftSkin( &scene, &models[i], name ); - //free( name ); + // free( name ); } } @@ -1262,9 +1210,8 @@ LoadSoft() // make sure all elements have unique names _data.UniquifyNames(); - // write out the geometry data if requested - //if ( make_poly || make_nurbs ) - //{ + // write out the geometry data if requested if ( make_poly || + // make_nurbs ) { eggFile << _data << "\n"; fprintf( outStream, "\nwriting out %s...\n", eggFileName ); eggFile.close(); @@ -1296,22 +1243,22 @@ LoadSoft() } int frame; - //int frameStep; + // int frameStep; float time; - // get all the animation frame info if not specified - // on the command line + // get all the animation frame info if not specified on the + // command line if (anim_start == -1000) SAA_sceneGetPlayCtrlStartFrame( &scene, &anim_start ); if (anim_end == -1000) SAA_sceneGetPlayCtrlEndFrame( &scene, &anim_end ); - //SAA_sceneGetPlayCtrlFrameStep( &scene, &frameStep ); + // SAA_sceneGetPlayCtrlFrameStep( &scene, &frameStep ); fprintf( outStream, "\nframeStart = %d\n", anim_start ); fprintf( outStream, "frameEnd = %d\n", anim_end ); - //fprintf( outStream, "frameStep = %d\n", frameStep ); + // fprintf( outStream, "frameStep = %d\n", frameStep ); // start at first frame and go to last for ( frame = anim_start; frame <= anim_end; @@ -1333,8 +1280,8 @@ LoadSoft() SAA_modelIsSkeleton( &scene, &models[i], &isSkeleton ); - // get fullname for splitting files, but - // only use it in file if requested + // get fullname for splitting files, but only use it + // in file if requested fullname = GetFullName( &scene, &models[i] ); if ( use_prefix ) name = fullname; @@ -1365,13 +1312,13 @@ LoadSoft() if ( ( size != 0 ) && make_duv ) MakeTexAnim( &scene, &models[i], name ); - // if we have a skeleton or something that acts - // like one - build anim tables + // if we have a skeleton or something that acts like + // one - build anim tables if ( isSkeleton || ( strstr( name, "joint") != NULL ) ) MakeAnimTable( &scene, &models[i], name ); - //free( name ); + // free( name ); } if ( verbose >= 1 ) @@ -1383,7 +1330,7 @@ LoadSoft() animFile.close(); } - //free( models ); + // free( models ); } else @@ -1428,12 +1375,10 @@ LoadSoft() } -//////////////////////////////////////////////////////////////////// -// Function: MakeEgg -// Access: Public -// Description: Make egg geometry from a given model. This include -// textures, tex coords, colors, normals, and joints. -//////////////////////////////////////////////////////////////////// +/** + * Make egg geometry from a given model. This include textures, tex coords, + * colors, normals, and joints. + */ void soft2egg:: MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, SAA_Scene *scene, SAA_Elem *model ) @@ -1536,8 +1481,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, matrix[3][1], matrix[3][2], matrix[3][3] ); } - // check to see if this is a branch we don't want to descend - this - // will prevent creating geometry for animation control structures + // check to see if this is a branch we don't want to descend - this will + // prevent creating geometry for animation control structures if ( (strstr( name, "con-" ) == NULL) && (strstr( name, "con_" ) == NULL) && (strstr( name, "fly_" ) == NULL) && @@ -1568,8 +1513,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, char *tableName; - // create morph table entry for each key shape - // (start at second shape - as first is the original geometry) + // create morph table entry for each key shape (start at second shape + // - as first is the original geometry) for ( i = 1; i < numShapes; i++ ) { tableName = MakeTableName( name, i ); @@ -1581,15 +1526,15 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, fprintf( outStream, "created table named: '%s'\n", tableName ); } - //free( tableName ); + // free( tableName ); } SAA_modelGetNodeVisibility( scene, model, &visible ); if ( verbose >= 1 ) fprintf( outStream, "model visibility: %d\n", visible ); - // Only create egg polygon data if: the node is visible, and its not - // a NULL or a Joint, and we're outputing polys (or if we are outputing + // Only create egg polygon data if: the node is visible, and its not a + // NULL or a Joint, and we're outputing polys (or if we are outputing // NURBS and the model is a poly mesh or a face) if ( visible && (type != SAA_MNILL) && @@ -1628,10 +1573,9 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, SAA_modelIsSkeleton( scene, model, &isSkeleton ); - // check to see if this surface is used as a skeleton - // or is animated via constraint only ( these nodes are - // tagged by the animator with the keyword "joint" - // somewhere in the nodes name) + // check to see if this surface is used as a skeleton or is animated via + // constraint only ( these nodes are tagged by the animator with the + // keyword "joint" somewhere in the nodes name) if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { if ( verbose >= 1 ) @@ -1683,8 +1627,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, numTexLoc += numTexTri[i]; } - // don't need this anymore... - //free( numTexTri ); + // don't need this anymore... free( numTexTri ); // get local textures if present if ( numTexLoc ) @@ -1747,9 +1690,9 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, else fprintf( outStream, "Not enough Memory for control vertices...\n"); - // allocate array of control vertex indices - // this array maps from the redundant cvertices array into - // the unique vertices array (cvertices->vertices) + // allocate array of control vertex indices this array maps from the + // redundant cvertices array into the unique vertices array + // (cvertices->vertices) indices = (int *)malloc(sizeof(int)*numTri*3); if ( indices != NULL ) { @@ -1772,7 +1715,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, if ( verbose >= 2 ) fprintf( outStream, "num unique verts = %d\n", numVert ); - //allocate array of vertices + // allocate array of vertices vertices = (SAA_DVector *)malloc(sizeof(SAA_DVector)*numVert); // get the UNIQUE vertices of all triangles in model @@ -1788,10 +1731,9 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, } } - // allocate indexMap array - // we contruct this array to map from the unique vertices - // array to the redundant cvertices array - it will save - // us from doing repetitive searches later + // allocate indexMap array we contruct this array to map from the + // unique vertices array to the redundant cvertices array - it will + // save us from doing repetitive searches later indexMap = MakeIndexMap( indices, numTri*3, numVert ); // allocate array of normals @@ -1906,15 +1848,11 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, } } - //debug - //for ( i = 0; i < numTri; i++ ) - //{ - //if ( texNameArray[i] != NULL ) - //fprintf( outStream, " tritex[%d] named: %s\n", i, - //texNameArray[i] ); - //else - //fprintf( outStream, " tritex[%d] named: (null)\n", i ); - //} +/* + * debug for ( i = 0; i < numTri; i++ ) { if ( texNameArray[i] != NULL ) + * fprintf( outStream, " tritex[%d] named: %s\n", i, texNameArray[i] ); else + * fprintf( outStream, " tritex[%d] named: (null)\n", i ); } + */ } // make sure we have textures before we get t-coords else if ( numTexGlb ) @@ -2005,18 +1943,16 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, pfVec3 eggVert; pfVec3 eggNorm; - //convert to global coords + // convert to global coords SAA_DVector local = vertices[i]; SAA_DVector global; _VCT_X_MAT( global, local, matrix ); - // set vertices array to reflect global coords - //vertices[i].x = global.x; - //vertices[i].y = global.y; - //vertices[i].z = global.z; + // set vertices array to reflect global coords vertices[i].x = + // global.x; vertices[i].y = global.y; vertices[i].z = global.z; - //eggVert.set( vertices[i].x, vertices[i].y, vertices[i].z ); + // eggVert.set( vertices[i].x, vertices[i].y, vertices[i].z ); // we'll preserve original verts for now eggVert.set( global.x, global.y, global.z ); @@ -2095,16 +2031,16 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // if it has expressions we'll assume its animated if ( numExp ) { - // if animated object make base duv's, animtables - // for the duv's and store the original offsets + // if animated object make base duv's, animtables for the + // duv's and store the original offsets strstream uName, vName; // create duv target names uName << name << ".u" << ends; vName << name << ".v" << ends; - // only create tables and store offsets - // on a per model basis (not per vertex) + // only create tables and store offsets on a per model + // basis (not per vertex) if ( !i ) { @@ -2178,25 +2114,19 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, vref = new EggVertexRef( pool); for ( i = 0; i < numVert; i++ ) { - //add each vert in pool to last joint for hard skinning + // add each vert in pool to last joint for hard skinning vref->indices.push_back( EggVertexIndex( i ) ); } - // hard assign poly geometry if no soft-skinning requested - // - //disabled 1/1/99 to streamline joint assignments. - // all hard-skinning now done in CleanUpSoftSkin. - //if ( !make_soft ) - //{ - //if ( lastJoint != NULL ) - //{ - //lastJoint->vrefs.AddUniqueNode( *vref ); +/* + * hard assign poly geometry if no soft-skinning requested disabled 1199 to + * streamline joint assignments. all hard-skinning now done in + * CleanUpSoftSkin. if ( !make_soft ) { if ( lastJoint != NULL ) { + * lastJoint->vrefs.AddUniqueNode( *vref ); + */ - //if ( verbose >= 1 ) - //fprintf( outStream, "hard-skinning %s (%d vertices)\n", - //name, i+1 ); - //} - //} + // if ( verbose >= 1 ) fprintf( outStream, "hard-skinning %s + // (%d vertices)\n", name, i+1 ); } } // make an egg group to hold all triangles EggGroup *group = _data.CreateGroup( parent, name); @@ -2214,8 +2144,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, float r,g,b,a; pfVec4 color; - // make egg poly for each traingle and reference - // the appropriate vertex in the pool + // make egg poly for each traingle and reference the appropriate + // vertex in the pool poly = _data.CreatePolygon( group, pool ); poly->AddVertex(indices[i]); poly->AddVertex(indices[i+1]); @@ -2256,8 +2186,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, if ( (texNameArray[i/3] != NULL) && (strcmp(texNameArray[i/3], "NULL") != 0) ) { - // append unique identifier to texname for - // this particular object + // append unique identifier to texname for this particular + // object uniqueTexName << name << "-" << RemovePathName(texNameArray[i/3]); @@ -2273,8 +2203,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, { if ( texNameArray != NULL ) { - // append unique identifier to texname for - // this particular object + // append unique identifier to texname for this particular + // object uniqueTexName << name << "-" << RemovePathName(*texNameArray); @@ -2308,26 +2238,18 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // we're done - trash triangles... SAA_modelClearTriangles( scene, model ); - // free molloc'd memory - //free( triangles ); - //free( materials ); - //free( normals ); - //free( cvertices ); - //free( vertices ); - //free( indices ); - //free( indexMap ); +/* + * free molloc'd memory free( triangles ); free( materials ); free( normals ); + * free( cvertices ); free( vertices ); free( indices ); free( indexMap ); + */ // free these only if they were malloc'd for textures if (numTexLoc || numTexGlb) { - //free( textures ); - //free( uCoords ); - //free( vCoords ); - //free( texNameArray ); - //free( uScale ); - //free( vScale ); - //free( uOffset ); - //free( vOffset ); +/* + * free( textures ); free( uCoords ); free( vCoords ); free( texNameArray ); + * free( uScale ); free( vScale ); free( uOffset ); free( vOffset ); + */ } } } @@ -2342,10 +2264,9 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, SAA_modelIsSkeleton( scene, model, &isSkeleton ); - // check to see if this NURBS is used as a skeleton - // or is animated via constraint only ( these nodes are - // tagged by the animator with the keyword "joint" - // somewhere in the nodes name) + // check to see if this NURBS is used as a skeleton or is animated + // via constraint only ( these nodes are tagged by the animator + // with the keyword "joint" somewhere in the nodes name) if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { MakeJoint( scene, lastJoint, lastAnim, model, name ); @@ -2438,8 +2359,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, AddKnots( eggNurbsSurf->v_knots, knotsV, numKnotsV, vClosed, vDegree); - //free( knotsU ); - //free( knotsV ); + // free( knotsU ); free( knotsV ); // set sub_div so we can see it in perfly eggNurbsSurf->u_subdiv = (uRows-1)*nurbs_step; @@ -2480,7 +2400,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, _VCT_X_MAT( global, vertices[k], matrix ); - //preserve original weight + // preserve original weight global.w = vertices[k].w; // normalize coords to weight @@ -2488,25 +2408,19 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, global.y *= global.w; global.z *= global.w; - // this code is commented out because I - // am no longer sending global data to - // the other routines (ie makevertexoffset) + // this code is commented out because I am no longer sending + // global data to the other routines (ie makevertexoffset) - // set vertices array to reflect global coords - //vertices[k].x = global.x; - //vertices[k].y = global.y; - //vertices[k].z = global.z; - //vertices[k].w = global.w; + // set vertices array to reflect global coords vertices[k].x = + // global.x; vertices[k].y = global.y; vertices[k].z = + // global.z; vertices[k].w = global.w; - //if ( verbose >= 2 ) - //{ - //fprintf( outStream, "global cv[%d] = %f %f %f %f\n", k, - //vertices[k].x, vertices[k].y, vertices[k].z, - //vertices[k].w ); - //} + // if ( verbose >= 2 ) { fprintf( outStream, "global cv[%d] = + // %f %f %f %f\n", k, vertices[k].x, vertices[k].y, + // vertices[k].z, vertices[k].w ); } - //eggVert.set( vertices[k].x, vertices[k].y, vertices[k].z, - //vertices[k].w ); + // eggVert.set( vertices[k].x, vertices[k].y, vertices[k].z, + // vertices[k].w ); if ( verbose >= 2 ) { @@ -2524,7 +2438,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // add vref's to NURBS info eggNurbsSurf->AddVertex( k ); - //add each vert in pool to vref for hard skinning + // add each vert in pool to vref for hard skinning vref->indices.push_back( EggVertexIndex( k ) ); // check to see if the NURB is closed in u @@ -2537,29 +2451,21 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // add vref's to NURBS info eggNurbsSurf->AddVertex( i+((k/uRows)*uRows) ); - //add each vert to vref + // add each vert to vref vref->indices.push_back( EggVertexIndex( i+((k/uRows)*uRows) ) ); } } } - // if hard skinned or this nurb is also a joint - // - //disabled 1/1/99 to streamline joint assignments. - // all hard skinning now done in CleanUpSoftSkin. - //if (!make_soft || geom_as_joint) - //{ - //add the new cv references to the last - //joint for hard skinning only - //if ( lastJoint != NULL ) - //{ - //lastJoint->vrefs.AddUniqueNode( *vref ); - //geom_as_joint = 0; - //if ( verbose >= 1 ) - //fprintf( outStream, "Doing NURBS hard skinning...\n"); - //} - //} +/* + * if hard skinned or this nurb is also a joint disabled 1199 to streamline + * joint assignments. all hard skinning now done in CleanUpSoftSkin. if + * (!make_soft || geom_as_joint) { add the new cv references to the last joint + * for hard skinning only if ( lastJoint != NULL ) { + * lastJoint->vrefs.AddUniqueNode( *vref ); geom_as_joint = 0; if ( verbose >= + * 1 ) fprintf( outStream, "Doing NURBS hard skinning...\n"); } } + */ // check to see if the NURB is closed in v if ( vClosed && !uClosed ) @@ -2571,16 +2477,16 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // check to see if the NURB is closed in u and v else if ( vClosed && uClosed ) { - // add the first (degree) v verts and a few - // extra - for good measure + // add the first (degree) v verts and a few extra - for good + // measure for ( i = 0; i < vDegree; i++ ) { // add first vDegree rows of verts to end of list for ( j = 0; j < uRows; j++ ) eggNurbsSurf->AddVertex( j+(i*uRows) ); - // if u is closed to we have added uDegree - // verts onto the ends of the rows - add them here too + // if u is closed to we have added uDegree verts onto the + // ends of the rows - add them here too for ( k = 0; k < uDegree; k++ ) eggNurbsSurf->AddVertex( k+(i*uRows)+((k/uRows)*uRows) ); } @@ -2611,20 +2517,20 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, SAA_materialGetDiffuse( scene, &materials[0], &r, &g, &b ); SAA_materialGetTransparency( scene, &materials[0], &a ); nurbColor.set( r, g, b, 1.0f - a ); - //nurbColor.set( r, g, b, 1.0 ); + // nurbColor.set( r, g, b, 1.0 ); nurbCref = _data.CreateColor(nurbColor); eggNurbsSurf->attrib.SetCRef(nurbCref); - //get the texture of the NURBS surface from the material + // get the texture of the NURBS surface from the material int numNurbTexLoc = 0; int numNurbTexGlb = 0; // ASSUME only one texture per material SAA_Elem nurbTex; - // find out how many local textures per NURBS surface - // ASSUME it only has one material + // find out how many local textures per NURBS surface ASSUME + // it only has one material SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], FALSE, &relinfo, &numNurbTexLoc ); @@ -2670,8 +2576,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, // convert the texture to .rgb and adjust name texName = ConvertTexture( scene, &nurbTex ); - // append unique identifier to texname for - // this particular object + // append unique identifier to texname for this particular + // object uniqueTexName = (char *)malloc(sizeof(char)* (strlen(name)+strlen(texName)+3) ); sprintf( uniqueTexName, "%s-%s", name, @@ -2733,7 +2639,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, } - //call printMat + // call printMat if ( verbose >= 2 ) { fprintf( outStream, "nurb tex matrix = %f %f %f %f\n", nurbTexMat[0][0], @@ -2769,8 +2675,8 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, if ( verbose > 1 ) printf( "nurbTex has %d expressions...\n", numExp ); - // if animated object make base duv's, animtables - // for the duv's and store the original offsets + // if animated object make base duv's, animtables for + // the duv's and store the original offsets strstream uName, vName; // create duv target names @@ -2815,7 +2721,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, EggMorphOffset *duvU; EggMorphOffset *duvV; - //create uv's so we can store duv's + // create uv's so we can store duv's eggNurbsSurf->CalcActualUV( i, tmpUV ); pool->Vertex(i)->attrib.SetUV( tmpUV[0], tmpUV[1] ); @@ -2830,12 +2736,10 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, } // if ( numExp ) } // if ( numTexLoc || numTexGlb ) - //free( uScale ); - //free( vScale ); - //free( uOffset ); - //free( vOffset ); + // free( uScale ); free( vScale ); free( uOffset ); free( + // vOffset ); - //free( materials ); + // free( materials ); } else { @@ -2869,7 +2773,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, numTrims, trims, isTrim ); } - //free( trims ); + // free( trims ); } // check NURBS surface for surface curves @@ -2896,7 +2800,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, numTrims, trims, isTrim ); } - //free( trims ); + // free( trims ); } // push the NURBS into the egg data @@ -2908,17 +2812,16 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, vertices, matrix, name ); - //free( vertices ); + // free( vertices ); } // check to see if its a NURBS curve else if ( (type == SAA_MNCRV) && ( visible ) && ( make_nurbs ) ) { - // ignore for now - // make the NURBS curve and push it into the egg data - //parent->children.push_back( MakeNurbsCurve( scene, model, parent, - //matrix, name ) ); + // ignore for now make the NURBS curve and push it into the egg + // data parent->children.push_back( MakeNurbsCurve( scene, model, + // parent, matrix, name ) ); } else if ( type == SAA_MJNT ) { @@ -2957,10 +2860,10 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, SAA_modelIsSkeleton( scene, model, &isSkeleton ); - // check to see if this NULL is used as a skeleton - // or is animated via constraint only ( these nodes are - // tagged by the animator with the keyword "joint" - // somewhere in the nodes name) + // check to see if this NULL is used as a skeleton or is + // animated via constraint only ( these nodes are tagged by + // the animator with the keyword "joint" somewhere in the + // nodes name) if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { MakeJoint( scene, lastJoint, lastAnim, model, name ); @@ -3001,7 +2904,7 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, } else fprintf( outStream, "Not enough Memory for children...\n"); - //free( children ); + // free( children ); } fflush( outStream ); } @@ -3009,17 +2912,14 @@ MakeEgg( EggGroup *parent, EggJoint *lastJoint, AnimGroup *lastAnim, if ( verbose >= 1 ) fprintf( outStream, "Don't descend this branch!\n" ); - // we are done for the most part - start cleaning up memory - //free( name ); + // we are done for the most part - start cleaning up memory free( name ); } -//////////////////////////////////////////////////////////////////// -// Function: MakeSurfaceCurve -// Access: Public -// Description: Given a scene and lists of u and v samples create a -// an egg NURBS curve of degree two from the samples -//////////////////////////////////////////////////////////////////// +/** + * Given a scene and lists of u and v samples create a an egg NURBS curve of + * degree two from the samples + */ void soft2egg:: MakeSurfaceCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, EggNurbsSurface *&nurbsSurf, int numTrims, SAA_SubElem *trims, @@ -3033,7 +2933,7 @@ MakeSurfaceCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, SAA_Elem *trimCurves; char *name; - //get UV coord data + // get UV coord data numSamples = (long *)malloc(sizeof(long)*numTrims); SAA_surfaceCurveGetNbLinearSamples( scene, model, numTrims, trims, @@ -3067,8 +2967,8 @@ MakeSurfaceCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, // if it's a trim create a trim to assign trim curves to EggNurbsSurface::Trim *eggTrim = new EggNurbsSurface::Trim(); - // for each trim curve, make an egg curve and - // add it to the trims of the NURBS surface + // for each trim curve, make an egg curve and add it to the trims of the + // NURBS surface for ( i = 0; i < numTrims; i++ ) { if ( use_prefix ) @@ -3099,18 +2999,13 @@ MakeSurfaceCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, // pus trim list onto trims list nurbsSurf->trims.push_back( *eggTrim ); - //free( name ); - //free( trimCurves ); - //free( uSamples ); - //free( vSamples ); + // free( name ); free( trimCurves ); free( uSamples ); free( vSamples ); } -//////////////////////////////////////////////////////////////////// -// Function: MakeUVNurbsCurve -// Access: Public -// Description: Given a scene and lists of u and v samples create a -// an egg NURBS curve of degree two from the samples -//////////////////////////////////////////////////////////////////// +/** + * Given a scene and lists of u and v samples create a an egg NURBS curve of + * degree two from the samples + */ EggNurbsCurve *soft2egg:: MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, double *vSamples, EggGroup *parent, char *name ) @@ -3123,17 +3018,16 @@ MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, if ( verbose >= 2 ) fprintf( outStream, "nurbs UV curve %s:\n", name ); - //set sub_div so we can see it in perfly - //eggNurbsCurve->subdiv = numSamples[numCurve]/4; - // perfly chokes on big numbers - keep it reasonable + // set sub_div so we can see it in perfly eggNurbsCurve->subdiv = + // numSamples[numCurve]4; perfly chokes on big numbers - keep it + // reasonable eggNurbsCurve->subdiv = 150; - //create pool of NURBS vertices + // create pool of NURBS vertices EggVertexPool *pool = _data.CreateVertexPool( parent, name ); eggNurbsCurve->SetVertexPool( pool ); - // calculate offset to this curve's samples - // in list of all curve samples + // calculate offset to this curve's samples in list of all curve samples int offset = 0; for ( int o = 0; o < numCurve; o++ ) @@ -3150,10 +3044,10 @@ MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, fprintf( outStream, "cv[%d] = %f %f %f\n", k, eggVert[0], eggVert[1], eggVert[2] ); - //populate vertex pool + // populate vertex pool pool->AddVertex( eggVert, k ); - //add vref's to NURBS info + // add vref's to NURBS info eggNurbsCurve->AddVertex( k ); } @@ -3163,7 +3057,7 @@ MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, eggNurbsCurve->knots.push_back( k ); eggNurbsCurve->knots.push_back( numSamples[numCurve] - 1 ); - //set color to bright green for now + // set color to bright green for now EggColor *nurbCref; pfVec4 nurbColor; @@ -3174,12 +3068,10 @@ MakeUVNurbsCurve( int numCurve, long *numSamples, double *uSamples, return( eggNurbsCurve ); } -//////////////////////////////////////////////////////////////////// -// Function: MakeNurbsCurve -// Access: Public -// Description: Given a scene and a NURBS curve model create the -// the appropriate egg structures -//////////////////////////////////////////////////////////////////// +/** + * Given a scene and a NURBS curve model create the the appropriate egg + * structures + */ EggNurbsCurve *soft2egg:: MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, float matrix[4][4], char *name ) @@ -3190,7 +3082,7 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, if ( verbose >= 2 ) fprintf( outStream, "nurbs curve %s:\n", name ); - //create nurbs representation of surface + // create nurbs representation of surface SAA_nurbsCurveGetDegree( scene, model, °ree ); eggNurbsCurve->order = degree + 1; if ( verbose >= 2 ) @@ -3217,7 +3109,7 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, AddKnots( eggNurbsCurve->knots, knots, numKnots, closed, degree ); - //free( knots ); + // free( knots ); int numCV; @@ -3225,7 +3117,7 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, if ( verbose >= 2 ) fprintf( outStream, "%d CV's (=? %d)\n", numCV, (numKnots-(degree+1)) ); - //set sub_div so we can see it in perfly + // set sub_div so we can see it in perfly eggNurbsCurve->subdiv = (numCV-1)*nurbs_step; // get the CV's @@ -3234,7 +3126,7 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, SAA_modelGetVertices( scene, model, SAA_GEOM_ORIGINAL, 0, numCV, cvArray ); - //create pool of NURBS vertices + // create pool of NURBS vertices EggVertexPool *pool = _data.CreateVertexPool( parent, name ); eggNurbsCurve->SetVertexPool( pool ); @@ -3246,7 +3138,7 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, pfVec4 eggVert; - //convert to global coords + // convert to global coords SAA_DVector local = cvArray[k]; SAA_DVector global; @@ -3254,10 +3146,10 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, eggVert.set( global.x, global.y, global.z, global.w ); - //populate vertex pool + // populate vertex pool pool->AddVertex( eggVert, k ); - //add vref's to NURBS info + // add vref's to NURBS info eggNurbsCurve->AddVertex( k ); } @@ -3273,9 +3165,9 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, } } - //free( cvArray ); + // free( cvArray ); - //set color to bright green for now + // set color to bright green for now EggColor *nurbCref; pfVec4 nurbColor; @@ -3286,13 +3178,11 @@ MakeNurbsCurve( SAA_Scene *scene, SAA_Elem *model, EggGroup *parent, return( eggNurbsCurve ); } -//////////////////////////////////////////////////////////////////// -// Function: AddKnots -// Access: Public -// Description: Given a parametric surface, and its knots, create -// the appropriate egg structure by filling in Soft's -// implicit knots and assigning the rest to eggKnots. -//////////////////////////////////////////////////////////////////// +/** + * Given a parametric surface, and its knots, create the appropriate egg + * structure by filling in Soft's implicit knots and assigning the rest to + * eggKnots. + */ void soft2egg:: AddKnots( perf_vector &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree ) @@ -3310,8 +3200,8 @@ AddKnots( perf_vector &eggKnots, double *knots, int numKnots, // need to add (degree) number of knots for ( k = numKnots - 1; k >= numKnots - degree; k-- ) { - // we have to know these in order to calculate - // next knot value so hold them in temp array + // we have to know these in order to calculate next knot value so + // hold them in temp array newKnots[i] = lastKnot - (knots[k] - knots[k-1]); lastKnot = newKnots[i]; i++; @@ -3323,7 +3213,7 @@ AddKnots( perf_vector &eggKnots, double *knots, int numKnots, fprintf( outStream, "knots[%d] = %f\n", k, newKnots[k] ); } - //free( newKnots ); + // free( newKnots ); } else { @@ -3364,12 +3254,10 @@ AddKnots( perf_vector &eggKnots, double *knots, int numKnots, } } -//////////////////////////////////////////////////////////////////// -// Function: MakeJoint -// Access: Public -// Description: Given a name, a parent and a model create a new -// a new EggJoint for that model. -//////////////////////////////////////////////////////////////////// +/** + * Given a name, a parent and a model create a new a new EggJoint for that + * model. + */ void soft2egg:: MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, SAA_Elem *model, char *name ) @@ -3381,9 +3269,9 @@ MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, int scale_joint = 0; - // this is a quick fix to make scaled skeletons possible - // if the parent contains the keyword "scale" make this joint - // a global root joint instead of a child... + // this is a quick fix to make scaled skeletons possible if the parent + // contains the keyword "scale" make this joint a global root joint + // instead of a child... if (lastJoint != NULL) { if ( strstr( lastJoint->name.Str(), "scale" ) != NULL ) @@ -3394,8 +3282,8 @@ MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, } } - // if not root, flatten is false, and last joint had no scaling - // applied to it, then create joint in skeleton tree + // if not root, flatten is false, and last joint had no scaling applied to + // it, then create joint in skeleton tree if ( (lastJoint != NULL) && !flatten && !scale_joint ) { if ( verbose >= 1 ) @@ -3470,8 +3358,8 @@ MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, joint->transform = Matrix; lastAnim = rootAnim; } - // if root, make a seperate tree for skeleton and - // create required Table for the Egg heirarchy + // if root, make a seperate tree for skeleton and create required Table + // for the Egg heirarchy else { if ( verbose >= 1 ) @@ -3528,8 +3416,7 @@ MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, joint->flags |= EF_TRANSFORM; - //if ( make_anim) - //{ + // if ( make_anim) { AnimGroup *anim = animData.CreateTable( lastAnim, name ); XfmSAnimTable *table = new XfmSAnimTable( ); if ( verbose >= 1 ) @@ -3538,20 +3425,18 @@ MakeJoint( SAA_Scene *scene, EggJoint *&lastJoint, AnimGroup *&lastAnim, table->fps = anim_rate; anim->children.push_back( table ); lastAnim = anim; - //} + // } // make this joint current parent of chain lastJoint = joint; } -//////////////////////////////////////////////////////////////////// -// Function: MakeSoftSkin -// Access: Public -// Description: Given a skeleton part find its envelopes (if any) -// get the vertices associated with the envelopes and -// their weights and make vertex ref's for the joint -//////////////////////////////////////////////////////////////////// +/** + * Given a skeleton part find its envelopes (if any) get the vertices + * associated with the envelopes and their weights and make vertex ref's for + * the joint + */ void soft2egg:: MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, int numModels, char *name ) @@ -3703,9 +3588,8 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, fprintf( outStream, "envelope name %s\n", envName ); // find out if envelope geometry is poly or nurb - //SAA_modelGetType( scene, - //FindModelByName( envName, scene, - //models, numModels ), &type ); + // SAA_modelGetType( scene, FindModelByName( + // envName, scene, models, numModels ), &type ); SAA_modelGetType( scene, &envelopes[i], &type ); @@ -3758,15 +3642,15 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, modelVertices[j], matrix ); } - // find the egg vertex pool that corresponds - // to this envelope model + // find the egg vertex pool that corresponds to + // this envelope model EggVertexPool *envPool = (EggVertexPool *)(_data.pools.FindName( envName )); - // If we are outputting triangles: - // create an array that maps from a referenced - // vertex in the envelope to a corresponding - // vertex in the egg vertex pool - //if ( (type == SAA_MNSRF) && !make_nurbs ) + // If we are outputting triangles: create an array + // that maps from a referenced vertex in the + // envelope to a corresponding vertex in the egg + // vertex pool if ( (type == SAA_MNSRF) && + // !make_nurbs ) if ( !make_nurbs || (type == SAA_MSMSH) ) { vpoolMap = FindClosestTriVert( envPool, @@ -3777,13 +3661,14 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, if ( envPool != NULL ) { - // find the egg joint that corresponds to this model + // find the egg joint that corresponds to this + // model EggJoint *joint = (EggJoint *)(skeleton->FindDescendent( name )); - // this doesn't seem to be necessary 4/7/99 - //EggJoint *parent = (EggJoint *)joint->parent; - //assert(parent->IsA(NT_EggJoint)); + // this doesn't seem to be necessary 4799 EggJoint + // *parent = (EggJoint *)joint->parent; + // assert(parent->IsA(NT_EggJoint)); // for every envelope vertex for (j = 0; j < numEnvVertices[i]; j++) @@ -3805,21 +3690,21 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, j, envVtxIndices[j], scaledWeight ); envPool->Vertex(envVtxIndices[j])->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has - // been assigned + // set flag to show this vertex has been + // assigned envPool->Vertex(envVtxIndices[j])->multipleJoints = 1; } else { - //assign all the tri verts associated + // assign all the tri verts associated // with this control vertex to joint for ( k = 0; k < envPool->NumVertices(); k++ ) { if ( vpoolMap[k] == envVtxIndices[j] ) { - // add each vert in pool to last - // joint for soft skinning + // add each vert in pool to last joint + // for soft skinning joint->AddVertex(envPool->Vertex(k), scaledWeight); @@ -3848,25 +3733,24 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, if ( verbose >= 2 ) fprintf( outStream, "Couldn't find vpool %s!\n", envName ); - //free( modelVertices ); - //free( globalModelVertices ); - //free( envVtxIndices ); - //free( envName ); + // free( modelVertices ); free( + // globalModelVertices ); free( envVtxIndices ); + // free( envName ); } //if (weights) - //free( weights ); + // free( weights ); } // for i } // if (envVertices != NULL) else fprintf( outStream, "Not enough memory for envelope vertices...\n"); - //free( envVertices ); + // free( envVertices ); } // if (totalEnvVertices) else if ( verbose >= 1 ) fprintf( outStream, "No envelope vertices present...\n"); - //free( numEnvVertices ); + // free( numEnvVertices ); } // if (numEnvVertices != NULL) @@ -3876,7 +3760,7 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, else fprintf( outStream, "Not enough memory for envelopes...\n" ); - //free( envelopes ); + // free( envelopes ); } //if (numEnv) @@ -3886,13 +3770,10 @@ MakeSoftSkin( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, } -//////////////////////////////////////////////////////////////////// -// Function: CleanUpSoftSkin -// Access: Public -// Description: Given a model, make sure all its vertices have been -// soft assigned. If not hard assign to the last -// joint we saw. -//////////////////////////////////////////////////////////////////// +/** + * Given a model, make sure all its vertices have been soft assigned. If not + * hard assign to the last joint we saw. + */ void soft2egg:: CleanUpSoftSkin( SAA_Scene *scene, SAA_Elem *model, char *name ) { @@ -3911,10 +3792,10 @@ CleanUpSoftSkin( SAA_Scene *scene, SAA_Elem *model, char *name ) if ( verbose >= 1 ) fprintf( outStream, "\nCleaning up model %s\n", name ); - // this step is weird - I think I want it here but it seems - // to break some models. Files like props-props_wh_cookietime.3-0 in - // /ful/rnd/pub/vrml/chip/chips_adventure/char/zone1/rooms/warehouse_final - // need to do the "if (skel)" bit. + // this step is weird - I think I want it here but it seems to break some + // models. Files like props-props_wh_cookietime.3-0 in + // fulrndpubvrmlchipchips_adventurecharzone1roomswarehouse_final need to + // do the "if (skel)" bit. // am I a skeleton too? SAA_modelIsSkeleton( scene, model, &skel ); @@ -3985,7 +3866,7 @@ CleanUpSoftSkin( SAA_Scene *scene, SAA_Elem *model, char *name ) if ( verbose >= 1 ) fprintf( outStream, "setting joint to %s\n", parentName ); - //find the vpool for this model + // find the vpool for this model EggVertexPool *vPool = (EggVertexPool *)(_data.pools.FindName( name )); @@ -4049,14 +3930,11 @@ CleanUpSoftSkin( SAA_Scene *scene, SAA_Elem *model, char *name ) } } -//////////////////////////////////////////////////////////////////// -// Function: MakeAnimTable -// Access: Public -// Description: Given a scene and a skeleton part ,get all the -// position, rotation, and scale for the skeleton -// part for this frame and write them out as Egg -// animation tables. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene and a skeleton part ,get all the position, rotation, and + * scale for the skeleton part for this frame and write them out as Egg + * animation tables. + */ void soft2egg:: MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) { @@ -4084,15 +3962,15 @@ MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) if ( verbose >= 1 ) fprintf( outStream, " using global matrix\n" ); - //get SAA orientation + // get SAA orientation SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &p, &h, &r ); - //get SAA translation + // get SAA translation SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &x, &y, &z ); - //get SAA scaling + // get SAA scaling SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &i, &j, &k ); } @@ -4101,15 +3979,15 @@ MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) if ( verbose >= 1 ) fprintf( outStream, "using local matrix\n" ); - //get SAA orientation + // get SAA orientation SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_LOCAL, &p, &h, &r ); - //get SAA translation + // get SAA translation SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_LOCAL, &x, &y, &z ); - //get SAA scaling + // get SAA scaling SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_LOCAL, &i, &j, &k ); } @@ -4123,7 +4001,7 @@ MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) AnimGroup *thisGroup; XfmSAnimTable *thisTable; - //find the anim table associated with this group + // find the anim table associated with this group thisGroup = (AnimGroup *)(animRoot->FindDescendent( name )); if ( verbose >= 2 ) fprintf( outStream, "\nlooking for anim group %s\n", name ); @@ -4157,15 +4035,12 @@ MakeAnimTable( SAA_Scene *scene, SAA_Elem *skeletonPart, char *name ) } } -//////////////////////////////////////////////////////////////////// -// Function: MakeVertexOffsets -// Access: Public -// Description: Given a scene, a model , the vertices of its original -// shape and its name find the difference between the -// geometry of its key shapes and the models original -// geometry and add morph vertices to the egg data to -// reflect these changes. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model , the vertices of its original shape and its name + * find the difference between the geometry of its key shapes and the models + * original geometry and add morph vertices to the egg data to reflect these + * changes. + */ void soft2egg:: MakeVertexOffsets( SAA_Scene *scene, SAA_Elem *model, SAA_ModelType type, int numShapes, int numOrigVert, SAA_DVector *originalVerts, float @@ -4233,25 +4108,27 @@ MakeVertexOffsets( SAA_Scene *scene, SAA_Elem *model, SAA_ModelType type, EggVertexPool *vPool = (EggVertexPool *)(_data.pools.FindName( name )); - // for every original vertex, compare to the corresponding - // key shape vertex and see if a vertex offset is needed + // for every original vertex, compare to the corresponding key shape + // vertex and see if a vertex offset is needed for ( j=0; j < numOrigVert; j++ ) { double dx, dy, dz; if ( (type == SAA_MNSRF) && make_nurbs ) { - //dx = shapeVerts[j].x - (originalVerts[j].x/originalVerts[j].w); - //dy = shapeVerts[j].y - (originalVerts[j].y/originalVerts[j].w); - //dz = shapeVerts[j].z - (originalVerts[j].z/originalVerts[j].w); + // dx = shapeVerts[j].x - + // (originalVerts[j].xoriginalVerts[j].w); dy = + // shapeVerts[j].y - (originalVerts[j].yoriginalVerts[j].w); + // dz = shapeVerts[j].z - + // (originalVerts[j].zoriginalVerts[j].w); dx = shapeVerts[j].x - originalVerts[j].x; dy = shapeVerts[j].y - originalVerts[j].y; dz = shapeVerts[j].z - originalVerts[j].z; } else { - // we need to map from original vertices - // to triangle shape vertices here + // we need to map from original vertices to triangle shape + // vertices here offset = findShapeVert( originalVerts[j], uniqueVerts, numCV ); @@ -4310,14 +4187,11 @@ MakeVertexOffsets( SAA_Scene *scene, SAA_Elem *model, SAA_ModelType type, } -//////////////////////////////////////////////////////////////////// -// Function: MakeMorphTable -// Access: Public -// Description: Given a scene, a model, a name and a frame time, -// determine what type of shape interpolation is -// used and call the appropriate function to extract -// the shape weight info for this frame... -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, a name and a frame time, determine what type of + * shape interpolation is used and call the appropriate function to extract + * the shape weight info for this frame... + */ void soft2egg:: MakeMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, int numModels, char *name, float time ) @@ -4351,14 +4225,11 @@ MakeMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, } -//////////////////////////////////////////////////////////////////// -// Function: MakeLinearMorphTable -// Access: Public -// Description: Given a scene, a model, its name, and the time, -// get the shape fcurve for the model and determine -// the shape weights for the given time and use them -// to populate the morph table. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, its name, and the time, get the shape fcurve for + * the model and determine the shape weights for the given time and use them + * to populate the morph table. + */ void soft2egg:: MakeLinearMorphTable( SAA_Scene *scene, SAA_Elem *model, int numShapes, char *name, float time ) @@ -4391,7 +4262,7 @@ MakeLinearMorphTable( SAA_Scene *scene, SAA_Elem *model, int numShapes, if ( verbose >= 2 ) fprintf( outStream, "Linear: looking for table '%s'\n", tableName ); - //find the morph table associated with this key shape + // find the morph table associated with this key shape thisTable = (SAnimTable *)(morphRoot->FindDescendent( tableName )); if ( thisTable != NULL ) @@ -4439,16 +4310,12 @@ MakeLinearMorphTable( SAA_Scene *scene, SAA_Elem *model, int numShapes, } -//////////////////////////////////////////////////////////////////// -// Function: MakeWeightedMorphTable -// Access: Public -// Description: Given a scene, a model, a list of all models in the -// scene, the number of models in the scece, the number -// of key shapes for this model, the name of the model -// and the current time, determine what method of -// controlling the shape weights is used and call the -// appropriate routine. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, a list of all models in the scene, the number of + * models in the scece, the number of key shapes for this model, the name of + * the model and the current time, determine what method of controlling the + * shape weights is used and call the appropriate routine. + */ void soft2egg:: MakeWeightedMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, int numModels, int numShapes, char *name, float time ) @@ -4471,7 +4338,8 @@ MakeWeightedMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, { SAA_fcurveEval( scene, &weightCurves[i], time, &curveVal ); - // make sure soft gave us a reasonable number + // make sure soft gave us a + // reasonable number if (!isNum(curveVal)) curveVal = 0.0f; @@ -4482,12 +4350,13 @@ MakeWeightedMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, // derive table name from the model name tableName = MakeTableName( name, i ); - // find and populate shape table + // find and populate shape + // table if ( verbose >= 2 ) fprintf( outStream, "Weight: looking for table '%s'\n", tableName ); - //find the morph table associated with this key shape + // find the morph table associated with this key shape thisTable = (SAnimTable *)(morphRoot->FindDescendent( tableName )); if ( thisTable != NULL ) @@ -4504,14 +4373,11 @@ MakeWeightedMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, } -//////////////////////////////////////////////////////////////////// -// Function: MakeExpressionMorphTable -// Access: Public -// Description: Given a scene, a model and its number of key shapes -// generate a morph table describing transitions btwn -// the key shapes by evaluating the positions of the -// controlling sliders. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model and its number of key shapes generate a morph table + * describing transitions btwn the key shapes by evaluating the positions of + * the controlling sliders. + */ void soft2egg:: MakeExpressionMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, int numModels, int numShapes, char *name, float time ) @@ -4627,7 +4493,7 @@ MakeExpressionMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, fprintf( outStream, "Exp: looking for table '%s'\n", tableName ); - //find the morph table associated with this key shape + // find the morph table associated with this key shape thisTable = (SAnimTable *) (morphRoot->FindDescendent( tableName )); @@ -4659,13 +4525,10 @@ MakeExpressionMorphTable( SAA_Scene *scene, SAA_Elem *model, SAA_Elem *models, } -//////////////////////////////////////////////////////////////////// -// Function: MakeTexAnim -// Access: Public -// Description: Given a scene, a POLYGON model, and the name -// of the that model, get the u and v offsets for -// the current frame. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a POLYGON model, and the name of the that model, get the u + * and v offsets for the current frame. + */ void soft2egg:: MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) { @@ -4704,8 +4567,8 @@ MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) // ASSUME only one texture per material SAA_Elem tex; - // find out how many local textures per surface - // ASSUME it only has one material + // find out how many local textures per surface ASSUME it only has one + // material SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], FALSE, &relinfo, &numTexLoc ); @@ -4752,8 +4615,7 @@ MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) SAA_texture2DGetPicName( scene, &tex, texNameLen, fullTexName ); - // append unique identifier to texname for - // this particular object + // append unique identifier to texname for this particular object uniqueTexName = (char *)malloc(sizeof(char)* (strlen(modelName)+strlen(texName)+3) ); sprintf( uniqueTexName, "%s-%s", modelName, texName ); @@ -4832,11 +4694,11 @@ MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) uName << modelName << ".u" << ends; vName << modelName << ".v" << ends; - // find the appropriate table to store the - // duv animation info into + // find the appropriate table to store the duv animation + // info into SAnimTable *thisTable; - //find the duv U table associated with this model + // find the duv U table associated with this model thisTable = (SAnimTable *)(morphRoot->FindDescendent( uName.str() )); @@ -4851,7 +4713,7 @@ MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) fprintf( outStream, "Couldn't find uTable %s\n", uName.str() ); - //find the duv V table associated with this model + // find the duv V table associated with this model thisTable = (SAnimTable *)(morphRoot->FindDescendent( vName.str() )); @@ -4872,16 +4734,14 @@ MakeTexAnim( SAA_Scene *scene, SAA_Elem *model, char *modelName ) fprintf( outStream, "Couldn't find vpool %s\n", modelName ); } - //free( materials ); + // free( materials ); } } #endif -//////////////////////////////////////////////////////////////////// -// Function: Main -// Access: Private -// Description: Instantiate converter and process a file -//////////////////////////////////////////////////////////////////// +/** + * Instantiate converter and process a file + */ EXPCL_MISC SI_Error soft2egg(int argc, char *argv[]) { // pass control to the c++ system init_soft2egg(argc, argv); diff --git a/pandatool/src/softegg/softEggGroupUserData.I b/pandatool/src/softegg/softEggGroupUserData.I index db47c103b8..c6d2a5082c 100644 --- a/pandatool/src/softegg/softEggGroupUserData.I +++ b/pandatool/src/softegg/softEggGroupUserData.I @@ -1,23 +1,19 @@ -// Filename: softEggGroupUserData.I -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softEggGroupUserData.I + * @author masad + * @date 2003-09-25 + */ - -//////////////////////////////////////////////////////////////////// -// Function: SoftEggGroupUserData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SoftEggGroupUserData:: SoftEggGroupUserData() { _vertex_color = false; @@ -25,13 +21,11 @@ SoftEggGroupUserData() { } -//////////////////////////////////////////////////////////////////// -// Function: SoftEggGroupUserData::Copy constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE SoftEggGroupUserData:: -SoftEggGroupUserData(const SoftEggGroupUserData ©) : +SoftEggGroupUserData(const SoftEggGroupUserData ©) : EggUserData(copy), _vertex_color(copy._vertex_color), _double_sided(copy._double_sided) @@ -39,11 +33,9 @@ SoftEggGroupUserData(const SoftEggGroupUserData ©) : } -//////////////////////////////////////////////////////////////////// -// Function: SoftEggGroupUserData::Copy assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void SoftEggGroupUserData:: operator = (const SoftEggGroupUserData ©) { EggUserData::operator = (copy); diff --git a/pandatool/src/softegg/softEggGroupUserData.cxx b/pandatool/src/softegg/softEggGroupUserData.cxx index 1195ee2f58..1705b2b285 100644 --- a/pandatool/src/softegg/softEggGroupUserData.cxx +++ b/pandatool/src/softegg/softEggGroupUserData.cxx @@ -1,16 +1,15 @@ -// Filename: softEggGroupUserData.cxx -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softEggGroupUserData.cxx + * @author masad + * @date 2003-09-25 + */ #include "softEggGroupUserData.h" diff --git a/pandatool/src/softegg/softEggGroupUserData.h b/pandatool/src/softegg/softEggGroupUserData.h index 8cf6a6a948..b8aa6ca892 100644 --- a/pandatool/src/softegg/softEggGroupUserData.h +++ b/pandatool/src/softegg/softEggGroupUserData.h @@ -1,16 +1,15 @@ -// Filename: softEggGroupUserData.h -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softEggGroupUserData.h + * @author masad + * @date 2003-09-25 + */ #ifndef SOFTEGGGROUPUSERDATA_H #define SOFTEGGGROUPUSERDATA_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "eggUserData.h" -//////////////////////////////////////////////////////////////////// -// Class : SoftEggGroupUserData -// Description : This class contains extra user data which is -// piggybacked onto EggGroup objects for the purpose of -// the softimage converter. -//////////////////////////////////////////////////////////////////// +/** + * This class contains extra user data which is piggybacked onto EggGroup + * objects for the purpose of the softimage converter. + */ class SoftEggGroupUserData : public EggUserData { public: INLINE SoftEggGroupUserData(); diff --git a/pandatool/src/softegg/softNodeDesc.cxx b/pandatool/src/softegg/softNodeDesc.cxx index 699e4969ec..5be0b79246 100644 --- a/pandatool/src/softegg/softNodeDesc.cxx +++ b/pandatool/src/softegg/softNodeDesc.cxx @@ -1,16 +1,15 @@ -// Filename: softNodeDesc.cxx -// Created by: masad (03Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softNodeDesc.cxx + * @author masad + * @date 2003-10-03 + */ #include "softNodeDesc.h" #include "config_softegg.h" @@ -22,11 +21,9 @@ TypeHandle SoftNodeDesc::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftNodeDesc:: SoftNodeDesc(SoftNodeDesc *parent, const string &name) : Namable(name), @@ -59,7 +56,7 @@ SoftNodeDesc(SoftNodeDesc *parent, const string &name) : valid; uv_swap; - // SAA_Boolean visible; + // SAA_Boolean visible; numTexTri = NULL; textures = NULL; materials = NULL; @@ -67,16 +64,14 @@ SoftNodeDesc(SoftNodeDesc *parent, const string &name) : gtype = SAA_GEOM_ORIGINAL; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftNodeDesc:: ~SoftNodeDesc() { - // I think it is a mistake to try to delete this. This was one - // member of an entire array allocated at once; you can't delete - // individual elements of an array. + // I think it is a mistake to try to delete this. This was one member of an + // entire array allocated at once; you can't delete individual elements of + // an array. // Screw cleanup, anyway--we'll just let the array leak. /* @@ -86,23 +81,19 @@ SoftNodeDesc:: */ } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::set_model -// Access: Public -// Description: Indicates an associated between the SoftNodeDesc and -// some SAA_Elem instance. -//////////////////////////////////////////////////////////////////// +/** + * Indicates an associated between the SoftNodeDesc and some SAA_Elem + * instance. + */ void SoftNodeDesc:: set_model(SAA_Elem *model) { _model = model; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::set_parent -// Access: Public -// Description: Sometimes, parent is not known at node creation -// As soon as it is known, set the parent -//////////////////////////////////////////////////////////////////// +/** + * Sometimes, parent is not known at node creation As soon as it is known, set + * the parent + */ void SoftNodeDesc:: set_parent(SoftNodeDesc *parent) { if (_parent) { @@ -125,12 +116,10 @@ set_parent(SoftNodeDesc *parent) { _parent->_children.push_back(this); } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::set_parent -// Access: Public -// Description: Sometimes, parent is not known at node creation -// As soon as it is known, set the parent -//////////////////////////////////////////////////////////////////// +/** + * Sometimes, parent is not known at node creation As soon as it is known, set + * the parent + */ void SoftNodeDesc:: force_set_parent(SoftNodeDesc *parent) { if (_parent) @@ -145,79 +134,60 @@ force_set_parent(SoftNodeDesc *parent) { _parent->_children.push_back(this); } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::has_model -// Access: Public -// Description: Returns true if a Soft dag path has been associated -// with this node, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if a Soft dag path has been associated with this node, false + * otherwise. + */ bool SoftNodeDesc:: has_model() const { return (_model != (SAA_Elem *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::get_model -// Access: Public -// Description: Returns the SAA_Elem * associated with this node. It -// is an error to call this unless has_model() -// returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the SAA_Elem * associated with this node. It is an error to call + * this unless has_model() returned true. + */ SAA_Elem *SoftNodeDesc:: get_model() const { nassertr(_model != (SAA_Elem *)NULL, _model); return _model; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::is_joint -// Access: Private -// Description: Returns true if the node should be treated as a joint -// by the converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node should be treated as a joint by the converter. + */ bool SoftNodeDesc:: is_joint() const { - // return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; + // return _joint_type == JT_joint || _joint_type == JT_pseudo_joint; return _joint_type == JT_joint; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::is_junk -// Access: Private -// Description: Returns true if the node should be treated as a junk -// by the converter. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node should be treated as a junk by the converter. + */ bool SoftNodeDesc:: is_junk() const { return _joint_type == JT_junk; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::set_joint -// Access: Private -// Description: sets the _joint_type to JT_joint -//////////////////////////////////////////////////////////////////// +/** + * sets the _joint_type to JT_joint + */ void SoftNodeDesc:: set_joint() { _joint_type = JT_joint; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::is_joint_parent -// Access: Private -// Description: Returns true if the node is the parent or ancestor of -// a joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node is the parent or ancestor of a joint. + */ bool SoftNodeDesc:: is_joint_parent() const { return _joint_type == JT_joint_parent; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::clear_egg -// Access: Private -// Description: Recursively clears the egg pointers from this node -// and all children. -//////////////////////////////////////////////////////////////////// +/** + * Recursively clears the egg pointers from this node and all children. + */ void SoftNodeDesc:: clear_egg() { _egg_group = (EggGroup *)NULL; @@ -231,12 +201,10 @@ clear_egg() { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::mark_joint_parent -// Access: Private -// Description: Indicates that this node has at least one child that -// is a joint or a pseudo-joint. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this node has at least one child that is a joint or a + * pseudo-joint. + */ void SoftNodeDesc:: mark_joint_parent() { if (_joint_type == JT_none) { @@ -252,12 +220,10 @@ mark_joint_parent() { softegg_cat.spam() << endl; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::check_joint_parent -// Access: Private -// Description: Walks the hierarchy, if a node is joint, make -// sure all its parents are marked JT_joint_parent -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, if a node is joint, make sure all its parents are + * marked JT_joint_parent + */ void SoftNodeDesc:: check_joint_parent() { Children::const_iterator ci; @@ -271,13 +237,10 @@ check_joint_parent() { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::check_junk -// Access: Public -// Description: check to see if this is a branch we don't want to -// descend - this will prevent creating geometry for -// animation control structures -//////////////////////////////////////////////////////////////////// +/** + * check to see if this is a branch we don't want to descend - this will + * prevent creating geometry for animation control structures + */ void SoftNodeDesc:: check_junk(bool parent_junk) { const char *name = get_name().c_str(); @@ -311,13 +274,10 @@ check_junk(bool parent_junk) { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::is_partial -// Access: Public -// Description: check to see if this is a selected branch we want to -// descend - this will prevent creating geometry for -// other parts -//////////////////////////////////////////////////////////////////// +/** + * check to see if this is a selected branch we want to descend - this will + * prevent creating geometry for other parts + */ bool SoftNodeDesc:: is_partial(char *search_prefix) { const char *name = fullname; @@ -340,17 +300,15 @@ is_partial(char *search_prefix) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::set_parentJoint -// Access: Public -// Description: Go through the ancestors and figure out who is the -// immediate _parentJoint of this node -//////////////////////////////////////////////////////////////////// +/** + * Go through the ancestors and figure out who is the immediate _parentJoint + * of this node + */ void SoftNodeDesc:: set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { if (is_junk()) return; - //set its parent joint to the lastJoint + // set its parent joint to the lastJoint _parentJoint = lastJoint; softegg_cat.spam() << get_name() << ": parent joint set to :" << lastJoint; if (lastJoint) @@ -371,7 +329,7 @@ set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { // make sure _parentJoint didn't have the name "joint" in it if (strstr(_parentJoint->get_name().c_str(), "joint") == NULL) { _parentJoint = NULL; - // _parentJoint = lastJoint = NULL; + // _parentJoint = lastJoint = NULL; softegg_cat.spam() << "scale joint flag set!\n"; } } @@ -384,27 +342,23 @@ set_parentJoint(SAA_Scene *scene, SoftNodeDesc *lastJoint) { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::check_pseudo_joints -// Access: Private -// Description: Walks the hierarchy, looking for non-joint nodes that -// are both children and parents of a joint. These -// nodes are deemed to be pseudo joints, since the -// converter must treat them as joints. -//////////////////////////////////////////////////////////////////// +/** + * Walks the hierarchy, looking for non-joint nodes that are both children and + * parents of a joint. These nodes are deemed to be pseudo joints, since the + * converter must treat them as joints. + */ void SoftNodeDesc:: check_pseudo_joints(bool joint_above) { if (_joint_type == JT_joint_parent && joint_above) { - // This is one such node: it is the parent of a joint - // (JT_joint_parent is set), and it is the child of a joint - // (joint_above is set). + // This is one such node: it is the parent of a joint (JT_joint_parent is + // set), and it is the child of a joint (joint_above is set). _joint_type = JT_pseudo_joint; softegg_cat.debug() << "pseudo " << get_name() << " case1\n"; } if (_joint_type == JT_joint) { - // If this node is itself a joint, then joint_above is true for - // all child nodes. + // If this node is itself a joint, then joint_above is true for all child + // nodes. joint_above = true; } @@ -423,8 +377,8 @@ check_pseudo_joints(bool joint_above) { } } - // If any children qualify as joints, then any sibling nodes that - // are parents of joints are also elevated to joints. + // If any children qualify as joints, then any sibling nodes that are + // parents of joints are also elevated to joints. if (any_joints) { bool all_joints = true; for (ci = _children.begin(); ci != _children.end(); ++ci) { @@ -438,7 +392,8 @@ check_pseudo_joints(bool joint_above) { } if (all_joints || any_joints) { - // Finally, if all children or at least one is a joint, then we are too. + // Finally, if all children or at least one is a joint, then we are + // too. if (_joint_type == JT_joint_parent) { _joint_type = JT_pseudo_joint; softegg_cat.debug() << "pseudo " << get_name() << " case3\n"; @@ -450,12 +405,10 @@ check_pseudo_joints(bool joint_above) { softegg_cat.spam() << "found null joint " << get_name() << endl; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::get_transform -// Access: Private -// Description: Extracts the transform on the indicated Soft node, -// and applies it to the corresponding Egg node. -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Soft node, and applies it to the + * corresponding Egg node. + */ void SoftNodeDesc:: get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global) { // Get the model's matrix @@ -497,21 +450,17 @@ get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global) { return; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::get_joint_transform -// Access: Private -// Description: Extracts the transform on the indicated Soft node, -// as appropriate for a joint in an animated character, -// and applies it to the indicated node. This is -// different from get_transform() in that it does not -// respect the _transform_type flag, and it does not -// consider the relative transforms within the egg file. -// more added functionality: now fills in components of -// anim (EffXfmSAnim) class (masad). -//////////////////////////////////////////////////////////////////// +/** + * Extracts the transform on the indicated Soft node, as appropriate for a + * joint in an animated character, and applies it to the indicated node. This + * is different from get_transform() in that it does not respect the + * _transform_type flag, and it does not consider the relative transforms + * within the egg file. more added functionality: now fills in components of + * anim (EffXfmSAnim) class (masad). + */ void SoftNodeDesc:: get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, bool global) { - // SI_Error result; + // SI_Error result; SAA_Elem *skeletonPart = _model; const char *name = get_name().c_str(); @@ -526,29 +475,29 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b if (_parentJoint && !stec.flatten && !scale_joint ) { softegg_cat.debug() << "using local matrix\n"; - //get SAA orientation + // get SAA orientation SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_LOCAL, &p, &h, &r ); - //get SAA translation + // get SAA translation SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_LOCAL, &x, &y, &z ); - //get SAA scaling + // get SAA scaling SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_LOCAL, &i, &j, &k ); } else { softegg_cat.debug() << " using global matrix\n"; - //get SAA orientation + // get SAA orientation SAA_modelGetRotation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &p, &h, &r ); - //get SAA translation + // get SAA translation SAA_modelGetTranslation( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &x, &y, &z ); - //get SAA scaling + // get SAA scaling SAA_modelGetScaling( scene, skeletonPart, SAA_COORDSYS_GLOBAL, &i, &j, &k ); } @@ -558,8 +507,8 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b softegg_cat.spam() << "\t" << x << " " << y << " " << z << endl; // Encode the component multiplication ordering in the egg file. - // SoftImage always uses this order, regardless of the setting of - // temp-hpr-fix. + // SoftImage always uses this order, regardless of the setting of temp- + // hpr-fix. anim->set_order("sphrt"); // Add each component by their names @@ -578,13 +527,10 @@ get_joint_transform(SAA_Scene *scene, EggGroup *egg_group, EggXfmSAnim *anim, b } } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::load_poly_model -// Access: Private -// Description: Converts the indicated Soft polyset to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Soft polyset to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void SoftNodeDesc:: load_poly_model(SAA_Scene *scene, SAA_ModelType type) { SI_Error result; @@ -616,10 +562,9 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { SAA_modelIsSkeleton( scene, _model, &isSkeleton ); - // check to see if this surface is used as a skeleton - // or is animated via constraint only ( these nodes are - // tagged by the animator with the keyword "joint" - // somewhere in the nodes name) + // check to see if this surface is used as a skeleton or is animated via + // constraint only ( these nodes are tagged by the animator with the keyword + // "joint" somewhere in the nodes name) softegg_cat.spam() << "is Skeleton? " << isSkeleton << "\n"; /*************************************************************************************/ @@ -641,9 +586,9 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { /***********************************************************************************/ - // allocate array of materials (Asad: it gives a warning if try to get one triangle - // at a time...investigate later - // read each triangle's material into array + // allocate array of materials (Asad: it gives a warning if try to get one + // triangle at a time...investigate later read each triangle's material + // into array materials = (SAA_Elem*) new SAA_Elem[numTri]; SAA_triangleGetMaterials( scene, _model, numTri, triangles, materials ); if (!materials) { @@ -667,8 +612,7 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { numTexLoc += numTexTri[i]; } - // don't need this anymore... - //free( numTexTri ); + // don't need this anymore... free( numTexTri ); // get local textures if present if ( numTexLoc ) { @@ -790,13 +734,10 @@ load_poly_model(SAA_Scene *scene, SAA_ModelType type) { softegg_cat.spam() << "got textures" << endl; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeDesc::load_nurbs_model -// Access: Private -// Description: Converts the indicated Soft polyset to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Soft polyset to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void SoftNodeDesc:: load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) { SI_Error result; @@ -836,8 +777,8 @@ load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) { numNurbTexLoc = 0; numNurbTexGlb = 0; - // find out how many local textures per NURBS surface - // ASSUME it only has one material + // find out how many local textures per NURBS surface ASSUME it only has + // one material SAA_materialRelationGetT2DLocNbElements( scene, &materials[0], FALSE, &relinfo, &numNurbTexLoc ); // if present, get local textures @@ -918,12 +859,9 @@ load_nurbs_model(SAA_Scene *scene, SAA_ModelType type) { } } -//////////////////////////////////////////////////////////////////// -// Function: find_shape_vert -// Access: Public -// Description: given a vertex, find its corresponding shape vertex -// and return its index. -//////////////////////////////////////////////////////////////////// +/** + * given a vertex, find its corresponding shape vertex and return its index. + */ int SoftNodeDesc:: find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert) { int i, found = 0; @@ -945,15 +883,12 @@ find_shape_vert(LPoint3d p3d, SAA_DVector *vertices, int numVert) { return i; } -//////////////////////////////////////////////////////////////////// -// Function: make_vertex_offsets -// Access: Public -// Description: Given a scene, a model , the vertices of its original -// shape and its name find the difference between the -// geometry of its key shapes and the models original -// geometry and add morph vertices to the egg data to -// reflect these changes. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model , the vertices of its original shape and its name + * find the difference between the geometry of its key shapes and the models + * original geometry and add morph vertices to the egg data to reflect these + * changes. + */ void SoftNodeDesc:: make_vertex_offsets(int numShapes) { int i, j; @@ -1017,8 +952,8 @@ make_vertex_offsets(int numShapes) { } softegg_cat.spam() << endl; - // for every original vertex, compare to the corresponding - // key shape vertex and see if a vertex offset is needed + // for every original vertex, compare to the corresponding key shape + // vertex and see if a vertex offset is needed j = 0; for (vi = vpool->begin(); vi != vpool->end(); ++vi, ++j) { @@ -1036,8 +971,8 @@ make_vertex_offsets(int numShapes) { << shapeVerts[j].y << " " << shapeVerts[j].z << " " << shapeVerts[j].w << endl; } else { - // we need to map from original vertices - // to triangle shape vertices here + // we need to map from original vertices to triangle shape vertices + // here offset = find_shape_vert(p3d, uniqueVerts, numCV); dx = shapeVerts[offset].x - p3d[0]; @@ -1068,14 +1003,11 @@ make_vertex_offsets(int numShapes) { } //for i } -//////////////////////////////////////////////////////////////////// -// Function: make_morph_table -// Access: Public -// Description: Given a scene, a model, a name and a frame time, -// determine what type of shape interpolation is -// used and call the appropriate function to extract -// the shape weight info for this frame... -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, a name and a frame time, determine what type of + * shape interpolation is used and call the appropriate function to extract + * the shape weight info for this frame... + */ void SoftNodeDesc:: make_morph_table( PN_stdfloat time ) { int numShapes; @@ -1112,21 +1044,18 @@ make_morph_table( PN_stdfloat time ) { } } -//////////////////////////////////////////////////////////////////// -// Function: make_linear_morph_table -// Access: Public -// Description: Given a scene, a model, its name, and the time, -// get the shape fcurve for the model and determine -// the shape weights for the given time and use them -// to populate the morph table. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, its name, and the time, get the shape fcurve for + * the model and determine the shape weights for the given time and use them + * to populate the morph table. + */ void SoftNodeDesc:: make_linear_morph_table(int numShapes, PN_stdfloat time) { int i; PN_stdfloat curveVal; char tableName[_MAX_PATH]; SAA_Elem fcurve; - //SAnimTable *thisTable; + // SAnimTable *thisTable; EggSAnimData *anim; SAA_Elem *model = get_model(); SAA_Scene *scene = &stec.scene; @@ -1148,7 +1077,7 @@ make_linear_morph_table(int numShapes, PN_stdfloat time) { softegg_cat.spam() << "Linear: looking for table '" << tableName << "'\n"; - //find the morph table associated with this key shape + // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); if ( anim != NULL ) { @@ -1182,23 +1111,19 @@ make_linear_morph_table(int numShapes, PN_stdfloat time) { } } -//////////////////////////////////////////////////////////////////// -// Function: make_weighted_morph_table -// Access: Public -// Description: Given a scene, a model, a list of all models in the -// scene, the number of models in the scece, the number -// of key shapes for this model, the name of the model -// and the current time, determine what method of -// controlling the shape weights is used and call the -// appropriate routine. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model, a list of all models in the scene, the number of + * models in the scece, the number of key shapes for this model, the name of + * the model and the current time, determine what method of controlling the + * shape weights is used and call the appropriate routine. + */ void SoftNodeDesc:: make_weighted_morph_table(int numShapes, PN_stdfloat time) { PN_stdfloat curveVal; SI_Error result; char tableName[_MAX_PATH]; SAA_Elem *weightCurves; - //SAnimTable *thisTable; + // SAnimTable *thisTable; EggSAnimData *anim; SAA_Elem *model = get_model(); SAA_Scene *scene = &stec.scene; @@ -1212,9 +1137,8 @@ make_weighted_morph_table(int numShapes, PN_stdfloat time) { for ( int i = 1; i < numShapes; i++ ) { SAA_fcurveEval( scene, &weightCurves[i], time, &curveVal ); - // make sure soft gave us a reasonable number - //if (!isNum(curveVal)) - //curveVal = 0.0f; + // make sure soft gave us a reasonable number if (!isNum(curveVal)) + // curveVal = 0.0f; softegg_cat.spam() << "at time " << time << ", weightCurve[" << i << "] for " << get_name() << " = " << curveVal << endl; @@ -1224,7 +1148,7 @@ make_weighted_morph_table(int numShapes, PN_stdfloat time) { // find and populate shape table softegg_cat.spam() << "Weight: looking for table '" << tableName << "'\n"; - //find the morph table associated with this key shape + // find the morph table associated with this key shape anim = stec.find_morph_table(tableName); if ( anim != NULL ) { @@ -1237,25 +1161,19 @@ make_weighted_morph_table(int numShapes, PN_stdfloat time) { } } -//////////////////////////////////////////////////////////////////// -// Function: make_expression_morph_table -// Access: Public -// Description: Given a scene, a model and its number of key shapes -// generate a morph table describing transitions btwn -// the key shapes by evaluating the positions of the -// controlling sliders. -//////////////////////////////////////////////////////////////////// +/** + * Given a scene, a model and its number of key shapes generate a morph table + * describing transitions btwn the key shapes by evaluating the positions of + * the controlling sliders. + */ void SoftNodeDesc:: make_expression_morph_table(int numShapes, PN_stdfloat time) { - //int j; + // int j; int numExp; char *track; - //PN_stdfloat expVal; - //PN_stdfloat sliderVal; - //char *tableName; - //char *sliderName; - //SAnimTable *thisTable; + // PN_stdfloat expVal; PN_stdfloat sliderVal; char *tableName; char + // *sliderName; SAnimTable *thisTable; SAA_Elem *expressions; SI_Error result; @@ -1357,7 +1275,7 @@ make_expression_morph_table(int numShapes, PN_stdfloat time) fprintf( outStream, "Exp: looking for table '%s'\n", tableName ); - //find the morph table associated with this key shape + // find the morph table associated with this key shape anim = (SAnimTable *) (morphRoot->FindDescendent( tableName )); @@ -1388,7 +1306,3 @@ make_expression_morph_table(int numShapes, PN_stdfloat time) make_weighted_morph_table(numShapes, time ); } } - -// -// -// diff --git a/pandatool/src/softegg/softNodeDesc.h b/pandatool/src/softegg/softNodeDesc.h index 3dac474305..8d041377c6 100644 --- a/pandatool/src/softegg/softNodeDesc.h +++ b/pandatool/src/softegg/softNodeDesc.h @@ -1,16 +1,15 @@ -// Filename: softNodeDesc.h -// Created by: masad (03Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softNodeDesc.h + * @author masad + * @date 2003-10-03 + */ #ifndef SOFTNODEDESC_H #define SOFTNODEDESC_H @@ -36,13 +35,11 @@ class EggGroup; class EggTable; class EggXfmSAnim; -//////////////////////////////////////////////////////////////////// -// Class : SoftNodeDesc -// Description : Describes a single instance of a node aka element in the Soft -// scene graph, relating it to the corresponding egg -// structures (e.g. node, group, or table entry) that -// will be created. -//////////////////////////////////////////////////////////////////// +/** + * Describes a single instance of a node aka element in the Soft scene graph, + * relating it to the corresponding egg structures (e.g. node, group, or + * table entry) that will be created. + */ class SoftNodeDesc : public ReferenceCount, public Namable { public: SoftNodeDesc(SoftNodeDesc *parent=NULL, const string &name = string()); @@ -101,7 +98,7 @@ public: const char *fullname; int numTri; - // int numShapes; + // int numShapes; int numTexLoc; int numTexGlb; int *numTexTri; @@ -115,10 +112,10 @@ public: PN_stdfloat *vScale; PN_stdfloat *uOffset; PN_stdfloat *vOffset; - + SAA_Boolean valid; SAA_Boolean uv_swap; - // SAA_Boolean visible; + // SAA_Boolean visible; SAA_Elem *textures; SAA_Elem *materials; SAA_SubElem *triangles; diff --git a/pandatool/src/softegg/softNodeTree.cxx b/pandatool/src/softegg/softNodeTree.cxx index 0e27e24c5f..f8dda53d48 100644 --- a/pandatool/src/softegg/softNodeTree.cxx +++ b/pandatool/src/softegg/softNodeTree.cxx @@ -1,20 +1,17 @@ -// Filename: softNodeTree.cxx -// Created by: masad (26Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softNodeTree.cxx + * @author masad + * @date 2003-09-26 + */ -//////////////////////////////////////////////////////////////////// // Includes -//////////////////////////////////////////////////////////////////// #include "softNodeTree.h" #include "softEggGroupUserData.h" @@ -28,11 +25,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftNodeTree:: SoftNodeTree() { _root = new SoftNodeDesc(NULL, "----root"); @@ -44,31 +39,25 @@ SoftNodeTree() { _egg_root = (EggGroupNode *)NULL; _skeleton_node = (EggGroupNode *)NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GetName -// Access: Public -// Description: Given an element, return a copy of the element's -// name WITHOUT prefix. -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a copy of the element's name WITHOUT prefix. + */ char *SoftNodeTree:: GetName( SAA_Scene *scene, SAA_Elem *element ) { int nameLen; char *name; - + // get the name - SAA_elementGetNameLength( scene, element, &nameLen ); + SAA_elementGetNameLength( scene, element, &nameLen ); name = new char[++nameLen]; SAA_elementGetName( scene, element, nameLen, name ); return name; } -//////////////////////////////////////////////////////////////////// -// Function: GetFullName -// Access: Public -// Description: Given an element, return a copy of the element's -// name complete with prefix. -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a copy of the element's name complete with prefix. + */ char *SoftNodeTree:: GetFullName( SAA_Scene *scene, SAA_Elem *element ) { @@ -95,12 +84,10 @@ GetFullName( SAA_Scene *scene, SAA_Elem *element ) return prefix; } -//////////////////////////////////////////////////////////////////// -// Function: GetModelNoteInfo -// Access: Public -// Description: Given an element, return a string containing the -// contents of its MODEL NOTE entry -//////////////////////////////////////////////////////////////////// +/** + * Given an element, return a string containing the contents of its MODEL NOTE + * entry + */ char *SoftNodeTree:: GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { int size; @@ -112,12 +99,12 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { if ( size != 0 ) { // allocate modelNote string modelNote = new char[size + 1]; - + // get ModelNote data from this model SAA_elementGetUserData( scene, model, "MNOT", size, &bigEndian, (void *)modelNote ); - - //strip off newline, if present + + // strip off newline, if present char *eol = (char *)memchr( modelNote, '\n', size ); if ( eol != NULL) *eol = '\0'; @@ -126,25 +113,23 @@ GetModelNoteInfo( SAA_Scene *scene, SAA_Elem *model ) { softegg_cat.spam() << "\nmodelNote = " << modelNote << endl; } - + return modelNote; } -//////////////////////////////////////////////////////////////////// -// Function: GetRootName -// Access: Public -// Description: Given a string, return a copy of the string up to -// the first occurence of '-'. -//////////////////////////////////////////////////////////////////// +/** + * Given a string, return a copy of the string up to the first occurence of + * '-'. + */ char *SoftNodeTree:: GetRootName( const char *name ) { const char *hyphen; char *root; int len; - + hyphen = strchr( name, '-' ); len = hyphen-name; - + if ( (hyphen != NULL) && len ) { root = new char[len+1]; strncpy( root, name, len ); @@ -157,12 +142,10 @@ GetRootName( const char *name ) { return( root ); } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::build_complete_hierarchy -// Access: Public -// Description: Walks through the complete Soft hierarchy and builds -// up the corresponding tree. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the complete Soft hierarchy and builds up the corresponding + * tree. + */ bool SoftNodeTree:: build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { SI_Error status; @@ -172,11 +155,11 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { int numModels; SAA_Elem *models; - SAA_sceneGetNbModels( &scene, &numModels ); + SAA_sceneGetNbModels( &scene, &numModels ); softegg_cat.spam() << "Scene has " << numModels << " model(s)...\n"; - - // This while loop walks through the entire Soft hierarchy, one - // node at a time. + + // This while loop walks through the entire Soft hierarchy, one node at a + // time. bool all_ok = true; if ( numModels ) { // allocate array of models @@ -201,7 +184,7 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { softegg_cat.spam() << "jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\n"; - // check the nodes that are junk for animation/artist control purposes + // check the nodes that are junk for animationartist control purposes _root->check_junk(false); softegg_cat.spam() << "jpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjpjp\n"; @@ -222,13 +205,10 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) { return all_ok; } #if 0 -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::build_selected_hierarchy -// Access: Public -// Description: Walks through the selected subset of the Soft -// hierarchy (or the complete hierarchy, if nothing is -// selected) and builds up the corresponding tree. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the selected subset of the Soft hierarchy (or the complete + * hierarchy, if nothing is selected) and builds up the corresponding tree. + */ bool SoftNodeTree:: build_selected_hierarchy(char *scene_name) { MStatus status; @@ -246,9 +226,9 @@ build_selected_hierarchy(char *scene_name) { status.perror("MGlobal::getActiveSelectionList"); return false; } - - // Get the selected geometry only if the selection is nonempty; - // otherwise, get the whole scene anyway. + + // Get the selected geometry only if the selection is nonempty; otherwise, + // get the whole scene anyway. if (selection.isEmpty()) { softegg_cat.info() << "Selection list is empty.\n"; @@ -263,8 +243,7 @@ build_selected_hierarchy(char *scene_name) { if (!status) { status.perror("MSelectionList::getDagPath"); } else { - // Now traverse through the selected dag path and all nested - // dag paths. + // Now traverse through the selected dag path and all nested dag paths. dag_iterator.reset(root_path); while (!dag_iterator.isDone()) { MDagPath dag_path; @@ -274,7 +253,7 @@ build_selected_hierarchy(char *scene_name) { } else { build_node(dag_path); } - + dag_iterator.next(); } } @@ -287,35 +266,27 @@ build_selected_hierarchy(char *scene_name) { return all_ok; } #endif -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_num_nodes -// Access: Public -// Description: Returns the total number of nodes in the hierarchy, -// not counting the root node. -//////////////////////////////////////////////////////////////////// +/** + * Returns the total number of nodes in the hierarchy, not counting the root + * node. + */ int SoftNodeTree:: get_num_nodes() const { return _nodes.size(); } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_node -// Access: Public -// Description: Returns the nth node in the hierarchy, in an -// arbitrary ordering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth node in the hierarchy, in an arbitrary ordering. + */ SoftNodeDesc *SoftNodeTree:: get_node(int n) const { nassertr(n >= 0 && n < (int)_nodes.size(), NULL); return _nodes[n]; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_node -// Access: Public -// Description: Returns the node named 'name' in the hierarchy, in -// an arbitrary ordering. -//////////////////////////////////////////////////////////////////// +/** + * Returns the node named 'name' in the hierarchy, in an arbitrary ordering. + */ SoftNodeDesc *SoftNodeTree:: get_node(string name) const { NodesByName::const_iterator ni = _nodes_by_name.find(name); @@ -324,15 +295,12 @@ get_node(string name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::clear_egg -// Access: Public -// Description: Removes all of the references to generated egg -// structures from the tree, and prepares the tree for -// generating new egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the references to generated egg structures from the tree, + * and prepares the tree for generating new egg structures. + */ void SoftNodeTree:: -clear_egg(EggData *egg_data, EggGroupNode *egg_root, +clear_egg(EggData *egg_data, EggGroupNode *egg_root, EggGroupNode *skeleton_node) { _root->clear_egg(); _egg_data = egg_data; @@ -340,13 +308,10 @@ clear_egg(EggData *egg_data, EggGroupNode *egg_root, _skeleton_node = skeleton_node; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_egg_group -// Access: Public -// Description: Returns the EggGroupNode corresponding to the group -// or joint for the indicated node. Creates the group -// node if it has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggGroupNode corresponding to the group or joint for the + * indicated node. Creates the group node if it has not already been created. + */ EggGroup *SoftNodeTree:: get_egg_group(SoftNodeDesc *node_desc) { nassertr(_egg_root != (EggGroupNode *)NULL, NULL); @@ -362,7 +327,7 @@ get_egg_group(SoftNodeDesc *node_desc) { if (node_desc->_egg_group == (EggGroup *)NULL) { // We need to make a new group node. EggGroup *egg_group; - + egg_group = new EggGroup(node_desc->get_name()); if (node_desc->is_joint()) { egg_group->set_group_type(EggGroup::GT_joint); @@ -380,22 +345,19 @@ get_egg_group(SoftNodeDesc *node_desc) { node_desc->_egg_group = egg_group; } - + return node_desc->_egg_group; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_egg_table -// Access: Public -// Description: Returns the EggTable corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the EggTable corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggTable *SoftNodeTree:: get_egg_table(SoftNodeDesc *node_desc) { nassertr(_skeleton_node != (EggGroupNode *)NULL, NULL); nassertr(node_desc->is_joint(), NULL); - + // lets print some relationship softegg_cat.spam() << " group " << node_desc->get_name() << "(" << node_desc->_egg_group << ")"; if (node_desc->_parent) @@ -406,17 +368,17 @@ get_egg_table(SoftNodeDesc *node_desc) { if (node_desc->_egg_table == (EggTable *)NULL) { softegg_cat.spam() << "creating a new table\n"; - // We need to make a new table node. - // nassertr(node_desc->_parent != (SoftNodeDesc *)NULL, NULL); - + // We need to make a new table node. nassertr(node_desc->_parent != + // (SoftNodeDesc *)NULL, NULL); + EggTable *egg_table = new EggTable(node_desc->get_name()); node_desc->_anim = new EggXfmSAnim("xform", _egg_data->get_coordinate_system()); node_desc->_anim->set_fps(_fps); egg_table->add_child(node_desc->_anim); - + if (stec.flatten || (!node_desc->_parentJoint || node_desc->_parentJoint == _root)) { - // if (!node_desc->_parent->is_joint()) { - // The parent is not a joint; put it at the top. + // if (!node_desc->_parent->is_joint()) { The parent is not a joint; put + // it at the top. _skeleton_node->add_child(egg_table); } else { // The parent is another joint. @@ -426,44 +388,39 @@ get_egg_table(SoftNodeDesc *node_desc) { node_desc->_egg_table = egg_table; } - + return node_desc->_egg_table; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::get_egg_anim -// Access: Public -// Description: Returns the anim table corresponding to the joint -// for the indicated node. Creates the table node if it -// has not already been created. -//////////////////////////////////////////////////////////////////// +/** + * Returns the anim table corresponding to the joint for the indicated node. + * Creates the table node if it has not already been created. + */ EggXfmSAnim *SoftNodeTree:: get_egg_anim(SoftNodeDesc *node_desc) { get_egg_table(node_desc); return node_desc->_anim; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::handle_null -// Access: Public -// Description: Sets joint information for MNILL node -//////////////////////////////////////////////////////////////////// +/** + * Sets joint information for MNILL node + */ void SoftNodeTree:: handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { const char *name = node_name; SAA_AlgorithmType algo; SAA_Elem *model = node_desc->get_model(); - + SAA_modelGetAlgorithm( scene, model, &algo ); softegg_cat.spam() << " null algorithm: " << algo << endl; - + if ( algo == SAA_ALG_INV_KIN ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); + // MakeJoint( &scene, lastJoint, lastAnim, model, name ); node_desc->set_joint(); softegg_cat.spam() << " encountered IK root: " << name << endl; } else if ( algo == SAA_ALG_INV_KIN_LEAF ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); + // MakeJoint( &scene, lastJoint, lastAnim, model, name ); node_desc->set_joint(); softegg_cat.spam() << " encountered IK leaf: " << name << endl; } @@ -473,12 +430,11 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { SAA_modelIsSkeleton( scene, model, &isSkeleton ); - // check to see if this NULL is used as a skeleton - // or is animated via constraint only ( these nodes are - // tagged by the animator with the keyword "joint" - // somewhere in the nodes name) + // check to see if this NULL is used as a skeleton or is animated via + // constraint only ( these nodes are tagged by the animator with the + // keyword "joint" somewhere in the nodes name) if ( isSkeleton || (strstr( name, "joint" ) != NULL) ) { - // MakeJoint( &scene, lastJoint, lastAnim, model, name ); + // MakeJoint( &scene, lastJoint, lastAnim, model, name ); node_desc->set_joint(); softegg_cat.spam() << " animating Standard null!!!\n"; softegg_cat.spam() << "isSkeleton: " << isSkeleton << endl; @@ -488,13 +444,10 @@ handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name) { softegg_cat.spam() << " encountered some other NULL: " << algo << endl; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::build_node -// Access: Public -// Description: Returns a pointer to the node corresponding to the -// indicated dag_path object, creating it first if -// necessary. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the node corresponding to the indicated dag_path + * object, creating it first if necessary. + */ SoftNodeDesc *SoftNodeTree:: build_node(SAA_Scene *scene, SAA_Elem *model) { char *name, *fullname; @@ -521,11 +474,12 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_desc->get_model(), &type ); - + if (type == SAA_MJNT || isSkeleton || (strstr(node_desc->get_name().c_str(), "joint") != NULL)) node_desc->set_joint(); - - // treat the MNILL differently, because it needs to detect and set some joints + + // treat the MNILL differently, because it needs to detect and set some + // joints if (type == SAA_MNILL) handle_null(scene, node_desc, name); @@ -535,22 +489,22 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // get to the children SAA_modelGetNbChildren( scene, model, &numChildren ); softegg_cat.spam() << " Model " << node_name << " children: " << numChildren << endl; - + if ( numChildren ) { children = new SAA_Elem[numChildren]; SAA_modelGetChildren( scene, model, numChildren, children ); if (!children) softegg_cat.info() << "Not enough Memory for children...\n"; - + for ( thisChild = 0; thisChild < numChildren; thisChild++ ) { fullname = GetFullName(scene, &children[thisChild]); if (_use_prefix) node_name = fullname; else node_name = GetName(scene, &children[thisChild]); - + softegg_cat.spam() << " building child " << thisChild << "..."; - + SoftNodeDesc *node_child = r_build_node(node_desc, node_name); node_child->fullname = fullname; @@ -559,11 +513,12 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { // find out what type of node we're dealing with SAA_modelGetType( scene, node_child->get_model(), &type ); - + if (type == SAA_MJNT || isSkeleton || (strstr(node_child->get_name().c_str(), "joint") != NULL)) node_child->set_joint(); - // treat the MNILL differently, because it needs to detect and set some joints + // treat the MNILL differently, because it needs to detect and set some + // joints if (type == SAA_MNILL) handle_null(scene, node_child, node_name.c_str()); @@ -574,17 +529,15 @@ build_node(SAA_Scene *scene, SAA_Elem *model) { return node_desc; } -//////////////////////////////////////////////////////////////////// -// Function: SoftNodeTree::r_build_node -// Access: Private -// Description: The recursive implementation of build_node(). -//////////////////////////////////////////////////////////////////// +/** + * The recursive implementation of build_node(). + */ SoftNodeDesc *SoftNodeTree:: r_build_node(SoftNodeDesc *parent_node, const string &name) { SoftNodeDesc *node_desc; - // If we have already encountered this pathname, return the - // corresponding SoftNodeDesc immediately. + // If we have already encountered this pathname, return the corresponding + // SoftNodeDesc immediately. NodesByName::const_iterator ni = _nodes_by_name.find(name); if (ni != _nodes_by_name.end()) { softegg_cat.spam() << " already built node " << (*ni).first; @@ -593,8 +546,8 @@ r_build_node(SoftNodeDesc *parent_node, const string &name) { return node_desc; } - // Otherwise, we have to create it. Do this recursively, so we - // create each node along the path. + // Otherwise, we have to create it. Do this recursively, so we create each + // node along the path. node_desc = new SoftNodeDesc(parent_node, name); softegg_cat.spam() << " node name : " << name << endl; @@ -604,7 +557,3 @@ r_build_node(SoftNodeDesc *parent_node, const string &name) { return node_desc; } - -// -// -// diff --git a/pandatool/src/softegg/softNodeTree.h b/pandatool/src/softegg/softNodeTree.h index 83cda9d493..ba44caa810 100644 --- a/pandatool/src/softegg/softNodeTree.h +++ b/pandatool/src/softegg/softNodeTree.h @@ -1,16 +1,15 @@ -// Filename: softNodeTree.h -// Created by: masad (03Oct03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softNodeTree.h + * @author masad + * @date 2003-10-03 + */ #ifndef SOFTNODETREE_H #define SOFTNODETREE_H @@ -27,18 +26,17 @@ class EggData; class EggGroupNode; -//////////////////////////////////////////////////////////////////// -// Class : SoftNodeTree -// Description : Describes a complete tree of soft nodes for -// conversion. -//////////////////////////////////////////////////////////////////// +/** + * Describes a complete tree of soft nodes for conversion. + */ class SoftNodeTree { public: SoftNodeTree(); SoftNodeDesc *build_node(SAA_Scene *scene, SAA_Elem *model); bool build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database); void handle_null(SAA_Scene *scene, SoftNodeDesc *node_desc, const char *node_name); - // bool build_selected_hierarchy(SAA_Scene *s, SAA_Database *d, char *scene_name); + // bool build_selected_hierarchy(SAA_Scene *s, SAA_Database *d, char + // *scene_name); int get_num_nodes() const; SoftNodeDesc *get_node(int n) const; @@ -60,7 +58,7 @@ public: PN_stdfloat _fps; int _use_prefix; char *_search_prefix; - + private: diff --git a/pandatool/src/softegg/softToEggConverter.cxx b/pandatool/src/softegg/softToEggConverter.cxx index dc96ada47f..64d5da3aed 100644 --- a/pandatool/src/softegg/softToEggConverter.cxx +++ b/pandatool/src/softegg/softToEggConverter.cxx @@ -1,17 +1,15 @@ -// Filename: softToEggConverter.cxx -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softToEggConverter.cxx + * @author masad + * @date 2003-09-25 + */ #include "softToEggConverter.h" #include "config_softegg.h" @@ -38,11 +36,9 @@ SoftToEggConverter stec; const int TEX_PER_MAT = 1; -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftToEggConverter:: SoftToEggConverter(const string &program_name) : _program_name(program_name) @@ -69,8 +65,7 @@ SoftToEggConverter(const string &program_name) : // skeleton = new EggGroup(); foundRoot = FALSE; - // animRoot = NULL; - // morphRoot = NULL; + // animRoot = NULL; morphRoot = NULL; geom_as_joint = 0; make_anim = 0; make_nurbs = 0; @@ -81,7 +76,7 @@ SoftToEggConverter(const string &program_name) : make_dart = TRUE; has_morph = 0; make_pose = 0; - // animData.is_z_up = FALSE; + // animData.is_z_up = FALSE; nurbs_step = 1; anim_start = -1000; anim_end = -1000; @@ -94,11 +89,9 @@ SoftToEggConverter(const string &program_name) : use_prefix = 0; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftToEggConverter:: SoftToEggConverter(const SoftToEggConverter ©) : _from_selection(copy._from_selection), @@ -115,24 +108,19 @@ SoftToEggConverter(const SoftToEggConverter ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftToEggConverter:: ~SoftToEggConverter() { /* close_api(); */ } -//////////////////////////////////////////////////////////////////// -// Function: Help -// Access: Public -// Description: Displays the "what is this program" message, along -// with the usage message. Should be overridden in base -// classes to describe the current program. -//////////////////////////////////////////////////////////////////// +/** + * Displays the "what is this program" message, along with the usage message. + * Should be overridden in base classes to describe the current program. + */ void SoftToEggConverter:: Help() { @@ -143,16 +131,14 @@ Help() Usage(); } -//////////////////////////////////////////////////////////////////// -// Function: Usage -// Access: Public -// Description: Displays the usage message. -//////////////////////////////////////////////////////////////////// +/** + * Displays the usage message. + */ void SoftToEggConverter:: Usage() { softegg_cat.info() << "\nUsage:\n" - // << _commandName << " [opts] (must specify -m or -s)\n\n" + // << _commandName << " [opts] (must specify -m or -s)\n\n" << "soft" << " [opts] (must specify -m or -s)\n\n" << "Options:\n"; @@ -160,13 +146,10 @@ Usage() { softegg_cat.info() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: ShowOpts -// Access: Public -// Description: Displays the valid options. Should be extended in -// base classes to show additional options relevant to -// the current program. -//////////////////////////////////////////////////////////////////// +/** + * Displays the valid options. Should be extended in base classes to show + * additional options relevant to the current program. + */ void SoftToEggConverter:: ShowOpts() { @@ -200,18 +183,15 @@ ShowOpts() " -D - Don't make the output model a character.\n" " -o - Convert only models with given prefix.\n"; - // EggBase::ShowOpts(); + // EggBase::ShowOpts(); } -//////////////////////////////////////////////////////////////////// -// Function: DoGetopts -// Access: Public -// Description: Calls getopt() to parse the command-line switches. -// Calls HandleGetopts() to interpret each switch. -// Returns true if the parsing was successful; false if -// there was an error. Adjusts argc and argv to remove -// the switches from the parameter list. -//////////////////////////////////////////////////////////////////// +/** + * Calls getopt() to parse the command-line switches. Calls HandleGetopts() + * to interpret each switch. Returns true if the parsing was successful; + * false if there was an error. Adjusts argc and argv to remove the switches + * from the parameter list. + */ bool SoftToEggConverter:: DoGetopts(int &argc, char **&argv) { bool okflag = true; @@ -236,13 +216,10 @@ DoGetopts(int &argc, char **&argv) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: HandleGetopts -// Access: Public -// Description: increment idx based on what kind of option parsed -// Supported options are as follows: -// r:d:s:m:t:P:b:e:f:T:S:M:A:N:v:o:FhknpaxiucCD -//////////////////////////////////////////////////////////////////// +/** + * increment idx based on what kind of option parsed Supported options are as + * follows: r:d:s:m:t:P:b:e:f:T:S:M:A:N:v:o:FhknpaxiucCD + */ bool SoftToEggConverter:: HandleGetopts(int &idx, int argc, char **argv) { @@ -367,8 +344,7 @@ HandleGetopts(int &idx, int argc, char **argv) break; case 'k': // Enable soft skinning - //make_soft = TRUE; - //fprintf( outStream, "enabling soft skinning\n" ); + // make_soft = TRUE; fprintf( outStream, "enabling soft skinning\n" ); softegg_cat.info() << "-k flag no longer necessary\n"; break; @@ -451,55 +427,41 @@ HandleGetopts(int &idx, int argc, char **argv) return (okflag); } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *SoftToEggConverter:: make_copy() { return new SoftToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string SoftToEggConverter:: get_name() const { return "Soft"; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string SoftToEggConverter:: get_extension() const { return "mb"; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ SoftNodeDesc *SoftToEggConverter:: find_node(string name) { return _tree.get_node(name); } -//////////////////////////////////////////////////////////////////// -// Function: GetTextureName -// Access: Public -// Description: Given a texture element, return texture name -// with given tex_path -//////////////////////////////////////////////////////////////////// +/** + * Given a texture element, return texture name with given tex_path + */ char *SoftToEggConverter:: GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { char *fileName = new char[_MAX_PATH]; @@ -507,7 +469,7 @@ GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { SAA_texture2DGetPicName( scene, texture, _MAX_PATH, tempName ); if (tex_path) { - // softegg_cat.spam() << "tempName :" << tempName << endl; + // softegg_cat.spam() << "tempName :" << tempName << endl; strcpy(fileName, tex_path); // do some processing on the name string @@ -518,7 +480,7 @@ GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { else tmpName = tempName; - // softegg_cat.spam() << "tmpName : " << tmpName << endl; + // softegg_cat.spam() << "tmpName : " << tmpName << endl; strcat(fileName, "/"); strcat(fileName, tmpName); } @@ -527,22 +489,18 @@ GetTextureName( SAA_Scene *scene, SAA_Elem *texture ) { } strcat(fileName, ".pic"); - // softegg_cat.spam() << "fileName : " << fileName << endl; + // softegg_cat.spam() << "fileName : " << fileName << endl; return fileName; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -// -// This is designed to be as generic as possible, -// generally in support of run-time loading. -// Also see convert_soft(). -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + * + * This is designed to be as generic as possible, generally in support of run- + * time loading. Also see convert_soft(). + */ bool SoftToEggConverter:: convert_file(const Filename &filename) { if (!open_api()) { @@ -556,15 +514,12 @@ convert_file(const Filename &filename) { return convert_soft(false); } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::convert_soft -// Access: Public -// Description: Fills up the egg_data structure according to the -// global soft model data. Returns true if successful, -// false if there is an error. If from_selection is -// true, the converted geometry is based on that which -// is selected; otherwise, it is the entire Soft scene. -//////////////////////////////////////////////////////////////////// +/** + * Fills up the egg_data structure according to the global soft model data. + * Returns true if successful, false if there is an error. If from_selection + * is true, the converted geometry is based on that which is selected; + * otherwise, it is the entire Soft scene. + */ bool SoftToEggConverter:: convert_soft(bool from_selection) { bool all_ok = true; @@ -589,9 +544,8 @@ convert_soft(bool from_selection) { _tree._search_prefix = search_prefix; all_ok = _tree.build_complete_hierarchy(scene, database); - // Lets see if we have gotten the hierarchy right - //_tree.print_hierarchy(); - //exit(1); + // Lets see if we have gotten the hierarchy right _tree.print_hierarchy(); + // exit(1); char *root_name = _tree.GetRootName( eggFileName ); @@ -600,8 +554,7 @@ convert_soft(bool from_selection) { _character_name = root_name; if (make_poly || make_nurbs) { - // Specify that the texture names should be relative to the output - // file. + // Specify that the texture names should be relative to the output file. Filename output_filename(eggFileName); _path_replace->_path_store = PS_relative; _path_replace->_path_directory = output_filename.get_dirname(); @@ -620,7 +573,7 @@ convert_soft(bool from_selection) { all_ok = false; } - // reparent_decals(get_egg_data()); + // reparent_decals(get_egg_data()); softegg_cat.info() << "Converted Softimage file\n"; // write out the egg model file @@ -632,7 +585,7 @@ convert_soft(bool from_selection) { all_ok = false; } - // reparent_decals(get_egg_data()); + // reparent_decals(get_egg_data()); softegg_cat.info() << "Converted Softimage file\n"; // write out the egg model file @@ -642,13 +595,10 @@ convert_soft(bool from_selection) { return all_ok; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::open_api -// Access: Public -// Description: Attempts to open the Soft API if it was not already -// open, and returns true if successful, or false if -// there is an error. -//////////////////////////////////////////////////////////////////// +/** + * Attempts to open the Soft API if it was not already open, and returns true + * if successful, or false if there is an error. + */ bool SoftToEggConverter:: open_api() { if ((scene_name == NULL && model_name == NULL) || database_name == NULL) { @@ -659,27 +609,27 @@ open_api() { softegg_cat.info() << "Error: Couldn't get resource path!\n"; exit( 1 ); } - // cout << "got past init" << endl; + // cout << "got past init" << endl; if ((result = SAA_databaseLoad(database_name, &database)) != SI_SUCCESS) { softegg_cat.info() << "Error: Couldn't load database!\n"; exit( 1 ); } - // cout << "got past database load" << endl; + // cout << "got past database load" << endl; if ((result = SAA_sceneGetCurrent(&scene)) != SI_SUCCESS) { softegg_cat.info() << "Error: Couldn't get current scene!\n"; exit( 1 ); } - // cout << "got past get current" << endl; + // cout << "got past get current" << endl; if ((result = SAA_sceneLoad( &database, scene_name, &scene )) != SI_SUCCESS) { softegg_cat.info() << "Error: Couldn't load scene " << scene_name << "!\n"; exit( 1 ); } - // cout << "got past scene load" << endl; + // cout << "got past scene load" << endl; if ( SAA_updatelistGet( &scene ) == SI_SUCCESS ) { PN_stdfloat time; softegg_cat.info() << "setting Scene to frame " << pose_frame << "...\n"; - //SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); + // SAA_sceneSetPlayCtrlCurrentFrame( &scene, pose_frame ); SAA_frame2Seconds( &scene, pose_frame, &time ); SAA_updatelistEvalScene( &scene, time ); if ( make_pose ) @@ -712,24 +662,19 @@ open_api() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::close_api -// Access: Public -// Description: Closes the Soft API, if it was previously opened. -// Caution! Soft appears to call exit() when its API is -// closed. -//////////////////////////////////////////////////////////////////// +/** + * Closes the Soft API, if it was previously opened. Caution! Soft appears + * to call exit() when its API is closed. + */ void SoftToEggConverter:: close_api() { // don't know yet } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::convert_char_model -// Access: Private -// Description: Converts the file as an animatable character -// model, with joints and vertex membership. -//////////////////////////////////////////////////////////////////// +/** + * Converts the file as an animatable character model, with joints and vertex + * membership. + */ bool SoftToEggConverter:: convert_char_model() { softegg_cat.spam() << "character name " << _character_name << "\n"; @@ -740,13 +685,10 @@ convert_char_model() { return convert_hierarchy(char_node); } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::find_morph_table -// Access: Public -// Description: Given a tablename, it either creates a new -// eggSAnimData structure (if doesn't exist) or -// locates it. -//////////////////////////////////////////////////////////////////// +/** + * Given a tablename, it either creates a new eggSAnimData structure (if + * doesn't exist) or locates it. + */ EggSAnimData *SoftToEggConverter:: find_morph_table(char *name) { EggSAnimData *anim = NULL; @@ -765,13 +707,10 @@ find_morph_table(char *name) { return anim; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::convert_char_chan -// Access: Private -// Description: Converts the animation as a series of tables to apply -// to the character model, as retrieved earlier via -// AC_model. -//////////////////////////////////////////////////////////////////// +/** + * Converts the animation as a series of tables to apply to the character + * model, as retrieved earlier via AC_model. + */ bool SoftToEggConverter:: convert_char_chan() { int start_frame = -1; @@ -791,8 +730,7 @@ convert_char_chan() { morph_node = new EggTable("morph"); - // Set the frame rate before we start asking for anim tables to be - // created. + // Set the frame rate before we start asking for anim tables to be created. SAA_sceneGetPlayCtrlStartFrame(&scene, &start_frame); SAA_sceneGetPlayCtrlEndFrame(&scene, &end_frame); SAA_sceneGetPlayCtrlFrameStep( &scene, &frame_inc ); @@ -803,23 +741,21 @@ convert_char_chan() { softegg_cat.info() << "animation frame inc: " << frame_inc << endl; _tree._fps = output_frame_rate / frame_inc; - // _tree.clear_egg(get_egg_data(), NULL, root_node); + // _tree.clear_egg(get_egg_data(), NULL, root_node); _tree.clear_egg(get_egg_data(), NULL, skeleton_node); - // Now we can get the animation data by walking through all of the - // frames, one at a time, and getting the joint angles at each - // frame. + // Now we can get the animation data by walking through all of the frames, + // one at a time, and getting the joint angles at each frame. - // This is just a temporary EggGroup to receive the transform for - // each joint each frame. + // This is just a temporary EggGroup to receive the transform for each joint + // each frame. PT(EggGroup) tgroup = new EggGroup; int num_nodes = _tree.get_num_nodes(); int i; - // MTime frame(start_frame, MTime::uiUnit()); - // MTime frame_stop(end_frame, MTime::uiUnit()); - // start at first frame and go to last + // MTime frame(start_frame, MTime::uiUnit()); MTime frame_stop(end_frame, + // MTime::uiUnit()); start at first frame and go to last if (make_pose) { start_frame = pose_frame; end_frame = pose_frame; @@ -830,21 +766,17 @@ convert_char_chan() { end_frame = anim_end; for ( frame = start_frame; frame <= end_frame; frame += frame_inc) { SAA_frame2Seconds( &scene, frame, &time ); - // softegg_cat.spam() << "got time " << time << endl; + // softegg_cat.spam() << "got time " << time << endl; if (!make_pose) { SAA_updatelistEvalScene( &scene, time ); } softegg_cat.spam() << "\n> animating frame " << frame << endl; - // if (softegg_cat.is_debug()) { - // softegg_cat.debug(false) + // if (softegg_cat.is_debug()) { softegg_cat.debug(false) softegg_cat.info() << "frame " << time << "\n"; - //} else { - // We have to write to cerr instead of softegg_cat to allow - // flushing without writing a newline. - // cerr << "." << flush; - // } - // MGlobal::viewFrame(frame); + // } else { We have to write to cerr instead of softegg_cat to allow + // flushing without writing a newline. cerr << "." << flush; } + // MGlobal::viewFrame(frame); for (i = 0; i < num_nodes; i++) { SoftNodeDesc *node_desc = _tree.get_node(i); @@ -864,15 +796,15 @@ convert_char_chan() { } } - // frame += frame_inc; + // frame += frame_inc; } if (has_morph) bundle_node->add_child(morph_node); - // Now optimize all of the tables we just filled up, for no real - // good reason, except that it makes the resulting egg file a little - // easier to read. + // Now optimize all of the tables we just filled up, for no real good + // reason, except that it makes the resulting egg file a little easier to + // read. for (i = 0; i < num_nodes; i++) { SoftNodeDesc *node_desc = _tree.get_node(i); if (node_desc->is_partial(search_prefix)) @@ -889,12 +821,9 @@ convert_char_chan() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::convert_hierarchy -// Access: Private -// Description: Generates egg structures for each node in the Soft -// hierarchy. -//////////////////////////////////////////////////////////////////// +/** + * Generates egg structures for each node in the Soft hierarchy. + */ bool SoftToEggConverter:: convert_hierarchy(EggGroupNode *egg_root) { int num_nodes = _tree.get_num_nodes(); @@ -910,14 +839,11 @@ convert_hierarchy(EggGroupNode *egg_root) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::process_model_node -// Access: Private -// Description: Converts the indicated Soft node (given a MDagPath, -// similar in concept to Panda's NodePath) to the -// corresponding Egg structure. Returns true if -// successful, false if an error was encountered. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Soft node (given a MDagPath, similar in concept to + * Panda's NodePath) to the corresponding Egg structure. Returns true if + * successful, false if an error was encountered. + */ bool SoftToEggConverter:: process_model_node(SoftNodeDesc *node_desc) { EggGroup *egg_group = NULL; @@ -956,7 +882,7 @@ process_model_node(SoftNodeDesc *node_desc) { break; case SAA_MFACE: softegg_cat.debug() << "face\n"; - //break; + // break; case SAA_MSMSH: softegg_cat.debug() << "mesh\n"; node_desc->get_transform(&scene, egg_group, TRUE); @@ -993,13 +919,10 @@ process_model_node(SoftNodeDesc *node_desc) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::make_polyset -// Access: Private -// Description: Converts the indicated Soft polyset to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Soft polyset to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void SoftToEggConverter:: make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { int id = 0; @@ -1014,11 +937,9 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { SAA_modelGetNodeVisibility( &scene, node_desc->get_model(), &visible ); softegg_cat.spam() << "model visibility: " << visible << endl; -//////////////////////////////////////////////////////////////////// - // Only create egg polygon data if: the node is visible, and its not - // a NULL or a Joint, and we're outputing polys (or if we are outputing - // NURBS and the model is a poly mesh or a face) -//////////////////////////////////////////////////////////////////// + // Only create egg polygon data if: the node is visible, and its not a NULL + // or a Joint, and we're outputing polys (or if we are outputing NURBS and + // the model is a poly mesh or a face) if ( visible && (type != SAA_MNILL) && (type != SAA_MJNT) && @@ -1039,29 +960,29 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { EggVertexPool *vpool = new EggVertexPool(vpool_name); vpool->set_highest_index(0); - // add the vertices in the _tree._root node, so that - // they will be written out first in egg file. This - // solves a problem of soft-skinning trying to access - // vertex pool before it is defined. + // add the vertices in the _tree._root node, so that they will be + // written out first in egg file. This solves a problem of soft- + // skinning trying to access vertex pool before it is defined. _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool); - // We will need to transform all vertices from world coordinate - // space into the vertex space appropriate to this node. Usually, - // this is the same thing as world coordinate space, and this matrix - // will be identity; but if the node is under an instance - // (particularly, for instance, a billboard) then the vertex space - // will be different from world space. + // We will need to transform all vertices from world coordinate space + // into the vertex space appropriate to this node. Usually, this is the + // same thing as world coordinate space, and this matrix will be + // identity; but if the node is under an instance (particularly, for + // instance, a billboard) then the vertex space will be different from + // world space. LMatrix4d vertex_frame_inv = egg_group->get_vertex_frame_inv(); - // Asad: change from soft2egg.c. Here I am trying to get one triangles vertices not all + // Asad: change from soft2egg.c. Here I am trying to get one triangles + // vertices not all for (idx=0; idxnumTri; ++idx) { EggPolygon *egg_poly = new EggPolygon; egg_group->add_child(egg_poly); softegg_cat.spam() << "processing polygon " << idx << endl; - // Is this a double sided polygon? meaning check for back face flag + // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); if ( modelNoteStr != NULL ) { if ( strstr( modelNoteStr, "bface" ) != NULL ) @@ -1091,8 +1012,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { // allocate arrays for u & v coords if (node_desc->textures) { if (node_desc->numTexLoc && node_desc->numTexTri[idx]) { - // allocate arrays for u & v coords - // I think there are one texture per triangle hence we need only 3 corrdinates + // allocate arrays for u & v coords I think there are one texture + // per triangle hence we need only 3 corrdinates uCoords = new PN_stdfloat[3]; vCoords = new PN_stdfloat[3]; @@ -1135,7 +1056,8 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { for ( i=0; i < 3; i++ ) { EggVertex vert; - // There are some conversions needed from local matrix to global coords + // There are some conversions needed from local matrix to global + // coords SAA_DVector local = cvertPos[i]; SAA_DVector global = {0}; @@ -1147,7 +1069,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { softegg_cat.spam() << " global cvert[" << i << "] = " << global.x << " " << global.y << " " << global.z << " " << global.w << "\n"; - // LPoint3d p3d(cvertPos[i].x, cvertPos[i].y, cvertPos[i].z); + // LPoint3d p3d(cvertPos[i].x, cvertPos[i].y, cvertPos[i].z); LPoint3d p3d(global.x, global.y, global.z); p3d = p3d * vertex_frame_inv; vert.set_pos(p3d); @@ -1175,7 +1097,7 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { << v << endl; vert.set_uv(LTexCoordd(u, v)); - //vert.set_uv(LTexCoordd(uCoords[i], vCoords[i])); + // vert.set_uv(LTexCoordd(uCoords[i], vCoords[i])); } } vert.set_external_index(indices[i]); @@ -1231,13 +1153,10 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::make_nurb_surface -// Access: Private -// Description: Converts the indicated Soft nurbs set to a bunch of -// EggPolygons and parents them to the indicated egg -// group. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Soft nurbs set to a bunch of EggPolygons and parents + * them to the indicated egg group. + */ void SoftToEggConverter:: make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) { int id = 0; @@ -1253,9 +1172,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty softegg_cat.spam() << "model visibility: " << visible << endl; softegg_cat.spam() << "nurbs!!!surface!!!" << endl; -//////////////////////////////////////////////////////////////////// // check to see if its a nurbs surface -//////////////////////////////////////////////////////////////////// if ( (type == SAA_MNSRF) && ( visible ) && (( make_nurbs ) || ( !make_nurbs && !make_poly && make_duv )) ) { @@ -1270,19 +1187,18 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty EggVertexPool *vpool = new EggVertexPool(vpool_name); vpool->set_highest_index(0); - // add the vertices in the _tree._egg_root node, so that - // they will be written out first in egg file. This - // solves a problem of soft-skinning trying to access - // vertex pool before it is defined. + // add the vertices in the _tree._egg_root node, so that they will be + // written out first in egg file. This solves a problem of soft- + // skinning trying to access vertex pool before it is defined. - //_tree.get_egg_root()->add_child(vpool); + // _tree.get_egg_root()->add_child(vpool); _tree.get_egg_root()->insert(_tree.get_egg_root()->begin(), vpool); - //egg_group->add_child(vpool); + // egg_group->add_child(vpool); /* - // create a copy of vpool in node_desc which will be used later - // for soft_skinning + // create a copy of vpool in node_desc which will be used later for + // soft_skinning node_desc->create_vpool(vpool_name); */ @@ -1343,7 +1259,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty SAA_nurbsSurfaceSetStep( &scene, node_desc->get_model(), nurbs_step, nurbs_step ); - // Is this a double sided polygon? meaning check for back face flag + // Is this a double sided polygon? meaning check for back face flag char *modelNoteStr = _tree.GetModelNoteInfo( &scene, node_desc->get_model() ); if ( modelNoteStr != NULL ) { if ( strstr( modelNoteStr, "bface" ) != NULL ) { @@ -1399,7 +1315,7 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty softegg_cat.spam() << endl << eggNurbs->get_num_cvs() << endl << endl; - //for ( i = 0; iget_num_cvs(); i++ ) { + // for ( i = 0; iget_num_cvs(); i++ ) { for ( k = 0; kmatrix ); - //preserve original weight + // preserve original weight global.w = vertices[k].w; // normalize coords to weight @@ -1446,7 +1362,8 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty SAA_materialGetDiffuse( &scene, &node_desc->materials[0], &r, &g, &b ); SAA_materialGetTransparency( &scene, &node_desc->materials[0], &a ); verts[k].set_color(LColor(r, g, b, 1.0f - a)); - //softegg_cat.spam() << "color r = " << r << " g = " << g << " b = " << b << " a = " << a << "\n"; + // softegg_cat.spam() << "color r = " << r << " g = " << g << " b + // = " << b << " a = " << a << "\n"; } else { // no material - default to white verts[k].set_color(LColor(1.0, 1.0, 1.0, 1.0)); @@ -1475,22 +1392,21 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty } // check to see if the NURB is closed in u and v else if ( vClosed && uClosed ) { - // add the first (degree) v verts and a few - // extra - for good measure + // add the first (degree) v verts and a few extra - for good measure for ( i = 0; i < vDegree; i++ ) { // add first vDegree rows of verts to end of list for ( j = 0; j < uRows; j++ ) eggNurbs->add_vertex( vpool->get_vertex(j+(i*uRows)) ); - // if u is closed to we have added uDegree - // verts onto the ends of the rows - add them here too + // if u is closed to we have added uDegree verts onto the ends of + // the rows - add them here too for ( k = 0; k < uDegree; k++ ) eggNurbs->add_vertex( vpool->get_vertex(k+(i*uRows)+((k/uRows)*uRows)) ); } } - // We add the NURBS to the group down here, after all of the vpools - // for the trim curves have been added. + // We add the NURBS to the group down here, after all of the vpools for + // the trim curves have been added. egg_group->add_child(eggNurbs); // Now apply the shader. @@ -1507,13 +1423,11 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty } } -//////////////////////////////////////////////////////////////////// -// Function: add_knots -// Access: Public -// Description: Given a parametric surface, and its knots, create -// the appropriate egg structure by filling in Soft's -// implicit knots and assigning the rest to eggKnots. -//////////////////////////////////////////////////////////////////// +/** + * Given a parametric surface, and its knots, create the appropriate egg + * structure by filling in Soft's implicit knots and assigning the rest to + * eggKnots. + */ void SoftToEggConverter:: add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree ) { @@ -1528,8 +1442,8 @@ add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean c // need to add (degree) number of knots for ( k = numKnots - 1; k >= numKnots - degree; k-- ) { - // we have to know these in order to calculate - // next knot value so hold them in temp array + // we have to know these in order to calculate next knot value so hold + // them in temp array newKnots[i] = lastKnot - (knots[k] - knots[k-1]); lastKnot = newKnots[i]; i++; @@ -1567,13 +1481,11 @@ add_knots( vector &eggKnots, double *knots, int numKnots, SAA_Boolean c } } -//////////////////////////////////////////////////////////////////// -// Function: FindClosestTriVert -// Access: Public -// Description: Given an egg vertex pool, map each vertex therein to -// a vertex within an array of SAA model vertices of -// size numVert. Mapping is done by closest proximity. -//////////////////////////////////////////////////////////////////// +/** + * Given an egg vertex pool, map each vertex therein to a vertex within an + * array of SAA model vertices of size numVert. Mapping is done by closest + * proximity. + */ int *SoftToEggConverter:: FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { int i,j; @@ -1589,8 +1501,8 @@ FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { for (vi = vpool->begin(); vi != vpool->end(); ++vi, ++i) { EggVertex *vert = (*vi); softegg_cat.spam() << "vert external index = " << vert->get_external_index() << endl; - // softegg_cat.spam() << "found vert " << vert << endl; - // softegg_cat.spam() << "vert [" << i << "] " << vpool->get_vertex(i+1); + // softegg_cat.spam() << "found vert " << vert << endl; softegg_cat.spam() + // << "vert [" << i << "] " << vpool->get_vertex(i+1); LPoint3d p3d = vert->get_pos3(); // find closest model vertex @@ -1622,12 +1534,10 @@ FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert ) { return vertMap; } -//////////////////////////////////////////////////////////////////// -// Function: SoftToEggConverter::make_soft_skin -// Access: Private -// Description: make soft skin assignments to the mesh -// finally call cleanup_soft_skin to clean it up -//////////////////////////////////////////////////////////////////// +/** + * make soft skin assignments to the mesh finally call cleanup_soft_skin to + * clean it up + */ bool SoftToEggConverter:: make_soft_skin() { int num_nodes = _tree.get_num_nodes(); @@ -1646,9 +1556,9 @@ make_soft_skin() { if (node_desc->is_partial(search_prefix)) continue; - // Now that we've added all the polygons (and created all the - // vertices), go back through the vertex pool and set up the - // appropriate joint membership for each of the vertices. + // Now that we've added all the polygons (and created all the vertices), + // go back through the vertex pool and set up the appropriate joint + // membership for each of the vertices. // check for envelops int numEnv; @@ -1873,19 +1783,19 @@ make_soft_skin() { /* envPool->Vertex(envVtxIndices[j])->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has - // been assigned + // set flag to show this vertex has been assigned envPool->Vertex(envVtxIndices[j])->multipleJoints = 1; */ } else { - //assign all the tri verts associated - // with this control vertex to joint + // assign all the tri verts associated with this control + // vertex to joint softegg_cat.spam() << j << "--trying to find " << envVtxIndices[j] << endl; for ( k = 0; k < (int)vpool->size(); k++ ) { if ( vpoolMap[k] == envVtxIndices[j] ) { EggVertex *vert = vpool->get_vertex(k+1); - // EggVertex *vert = mesh_node->get_vpool()->get_vertex(vpoolMap[k]+1); + // EggVertex *vert = + // mesh_node->get_vpool()->get_vertex(vpoolMap[k]+1); if (!vert) { softegg_cat.debug() << "possible error: index " << k+1 << ": vert is " << vert << endl; break; @@ -1897,8 +1807,7 @@ make_soft_skin() { << "(vpool)\n"; /* envPool->Vertex(k)->AddJoint( joint, scaledWeight ); - // set flag to show this vertex has - // been assigned + // set flag to show this vertex has been assigned envPool->Vertex(k)->multipleJoints = 1; */ } @@ -1914,13 +1823,10 @@ make_soft_skin() { } return true; } -//////////////////////////////////////////////////////////////////// -// Function: cleanup_soft_skin -// Access: Public -// Description: Given a model, make sure all its vertices have been -// soft assigned. If not hard assign to the last -// joint we saw. -//////////////////////////////////////////////////////////////////// +/** + * Given a model, make sure all its vertices have been soft assigned. If not + * hard assign to the last joint we saw. + */ bool SoftToEggConverter:: cleanup_soft_skin() { @@ -1945,27 +1851,26 @@ cleanup_soft_skin() softegg_cat.debug() << "Cleaning up model------- " << node_desc->get_name() << endl; - // this step is weird - I think I want it here but it seems - // to break some models. Files like props-props_wh_cookietime.3-0 in - // /ful/rnd/pub/vrml/chip/chips_adventure/char/zone1/rooms/warehouse_final - // need to do the "if (skel)" bit. + // this step is weird - I think I want it here but it seems to break some + // models. Files like props-props_wh_cookietime.3-0 in + // fulrndpubvrmlchipchips_adventurecharzone1roomswarehouse_final need to + // do the "if (skel)" bit. - //find the vpool for this model + // find the vpool for this model string vpool_name = node_desc->get_name() + ".verts"; EggNode *t = _tree.get_egg_root()->find_child(vpool_name); if (t) DCAST_INTO_R(vpool, t, NULL); if (!vpool) { - //softegg_cat.spam() << "couldn't find vpool " << vpool_name << endl; + // softegg_cat.spam() << "couldn't find vpool " << vpool_name << endl; continue; } int numVerts = (int)vpool->size(); softegg_cat.spam() << "found vpool " << vpool_name << " w/ " << numVerts << " verts\n"; - // if this node is a joint, then these vertices belong - // to this joint + // if this node is a joint, then these vertices belong to this joint if (node_desc->is_joint()) joint = node_desc->get_egg_group(); else { @@ -1974,7 +1879,8 @@ cleanup_soft_skin() while( parentJ && !parentJ->_parentJoint) { if ( parentJ->_parent) { SAA_Boolean isSkeleton; - //softegg_cat.spam() << " checking parent " << parentJ->_parent->get_name() << endl; + // softegg_cat.spam() << " checking parent " << + // parentJ->_parent->get_name() << endl; if (parentJ->_parent->has_model()) SAA_modelIsSkeleton( &scene, parentJ->_parent->get_model(), &isSkeleton ); @@ -2004,7 +1910,8 @@ cleanup_soft_skin() for ( vi = vpool->begin(); vi != vpool->end(); ++vi) { EggVertex *vert = (*vi); - // if this vertex has not been soft assigned, then hard assign it to the parentJoint + // if this vertex has not been soft assigned, then hard assign it to the + // parentJoint if ( vert->gref_size() == 0 ) { softegg_cat.spam() << "vert " << vert->get_external_index() << " not assigned!\n"; @@ -2017,12 +1924,9 @@ cleanup_soft_skin() return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftShader::set_shader_attributes -// Access: Private -// Description: Applies the known shader attributes to the indicated -// egg primitive. -//////////////////////////////////////////////////////////////////// +/** + * Applies the known shader attributes to the indicated egg primitive. + */ void SoftToEggConverter:: set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx) { char *texName = node_desc->texNameArray[idx]; @@ -2032,20 +1936,17 @@ set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx) Filename fullpath = _path_replace->match_path(filename, get_model_path()); tex.set_filename(_path_replace->store_path(fullpath)); tex.set_fullpath(fullpath); - // tex.set_format(EggTexture::F_rgb); + // tex.set_format(EggTexture::F_rgb); apply_texture_properties(tex, node_desc->uRepeat[idx], node_desc->vRepeat[idx]); EggTexture *new_tex = _textures.create_unique_texture(tex, ~EggTexture::E_tref_name); primitive.set_texture(new_tex); } -//////////////////////////////////////////////////////////////////// -// Function: SoftShader::apply_texture_properties -// Access: Private -// Description: Applies all the appropriate texture properties to the -// EggTexture object, including wrap modes and texture -// matrix. -//////////////////////////////////////////////////////////////////// +/** + * Applies all the appropriate texture properties to the EggTexture object, + * including wrap modes and texture matrix. + */ void SoftToEggConverter:: apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat) { // Let's mipmap all textures by default. @@ -2065,15 +1966,12 @@ apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat) { */ } #if 0 -//////////////////////////////////////////////////////////////////// -// Function: SoftShader::compare_texture_properties -// Access: Private -// Description: Compares the texture properties already on the -// texture (presumably set by a previous call to -// apply_texture_properties()) and returns false if they -// differ from that specified by the indicated color_def -// object, or true if they match. -//////////////////////////////////////////////////////////////////// +/** + * Compares the texture properties already on the texture (presumably set by a + * previous call to apply_texture_properties()) and returns false if they + * differ from that specified by the indicated color_def object, or true if + * they match. + */ bool SoftToEggConverter:: compare_texture_properties(EggTexture &tex, const SoftShaderColorDef &color_def) { @@ -2104,22 +2002,18 @@ compare_texture_properties(EggTexture &tex, return okflag; } #endif -//////////////////////////////////////////////////////////////////// -// Function: SoftShader::reparent_decals -// Access: Private -// Description: Recursively walks the egg hierarchy, reparenting -// "decal" type nodes below their corresponding -// "decalbase" type nodes, and setting the flags. -// -// Returns true on success, false if some nodes were -// incorrect. -//////////////////////////////////////////////////////////////////// +/** + * Recursively walks the egg hierarchy, reparenting "decal" type nodes below + * their corresponding "decalbase" type nodes, and setting the flags. + * + * Returns true on success, false if some nodes were incorrect. + */ bool SoftToEggConverter:: reparent_decals(EggGroupNode *egg_parent) { bool okflag = true; - // First, walk through all children of this node, looking for the - // one decal base, if any. + // First, walk through all children of this node, looking for the one decal + // base, if any. EggGroup *decal_base = (EggGroup *)NULL; pvector decal_children; @@ -2160,10 +2054,10 @@ reparent_decals(EggGroupNode *egg_parent) { << " has decalbase, but no sibling nodes have decal.\n"; } else { - // All the decal children get moved to be a child of decal base. - // This usually will not affect the vertex positions, but it - // could if the decal base has a transform and the decal child - // is an instance node. So don't do that. + // All the decal children get moved to be a child of decal base. This + // usually will not affect the vertex positions, but it could if the + // decal base has a transform and the decal child is an instance node. + // So don't do that. pvector::iterator di; for (di = decal_children.begin(); di != decal_children.end(); ++di) { EggGroup *child_group = (*di); @@ -2189,12 +2083,10 @@ reparent_decals(EggGroupNode *egg_parent) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: SoftShader::string_transform_type -// Access: Public, Static -// Description: Returns the TransformType value corresponding to the -// indicated string, or TT_invalid. -//////////////////////////////////////////////////////////////////// +/** + * Returns the TransformType value corresponding to the indicated string, or + * TT_invalid. + */ SoftToEggConverter::TransformType SoftToEggConverter:: string_transform_type(const string &arg) { if (cmp_nocase(arg, "all") == 0) { @@ -2210,11 +2102,9 @@ string_transform_type(const string &arg) { } } -//////////////////////////////////////////////////////////////////// -// Function: init_soft2egg -// Access: -// Description: Invokes the softToEggConverter class -//////////////////////////////////////////////////////////////////// +/** + * Invokes the softToEggConverter class + */ extern "C" int init_soft2egg(int argc, char **argv) { stec._commandName = argv[0]; stec.rsrc_path = "c:\\Softimage\\SOFT3D_3.9.2\\3D\\rsrc"; diff --git a/pandatool/src/softegg/softToEggConverter.h b/pandatool/src/softegg/softToEggConverter.h index d0c5630756..1ac9442263 100644 --- a/pandatool/src/softegg/softToEggConverter.h +++ b/pandatool/src/softegg/softToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: softToEggConverter.h -// Created by: masad (25Sep03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softToEggConverter.h + * @author masad + * @date 2003-09-25 + */ #ifndef SOFTTOEGGCONVERTER_H #define SOFTTOEGGCONVERTER_H @@ -43,13 +42,12 @@ class EggXfmSAnim; class EggSAnimData; -//////////////////////////////////////////////////////////////////// -// Class : SoftToEggConverter -// Description : This class supervises the construction of an EggData -// structure from a single Softimage file, or from the data -// already in th cout << "egg name = " << eggFilename << endl;e global Softimage model space. -// -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a + * single Softimage file, or from the data already in th cout << "egg name + * = " << eggFilename << endl;e global Softimage model space. + * + */ class SoftToEggConverter : public SomethingToEggConverter { public: SoftToEggConverter(const string &program_name = ""); @@ -76,7 +74,7 @@ public: void close_api(); private: - bool convert_flip(double start_frame, double end_frame, + bool convert_flip(double start_frame, double end_frame, double frame_inc, double output_frame_rate); bool make_soft_skin(); @@ -109,7 +107,7 @@ public: SAA_Scene scene; char *_getopts; - + // This is argv[0]. const char *_commandName; @@ -137,7 +135,7 @@ public: int shift_textures; int ignore_tex_offsets; int use_prefix; - + bool foundRoot; bool geom_as_joint; bool make_anim; @@ -150,7 +148,7 @@ public: bool has_morph; bool make_pose; - + char *GetTextureName( SAA_Scene *scene, SAA_Elem *texture ); EggTextureCollection _textures; diff --git a/pandatool/src/softprogs/softCVS.cxx b/pandatool/src/softprogs/softCVS.cxx index cff45eac57..bbc932659a 100644 --- a/pandatool/src/softprogs/softCVS.cxx +++ b/pandatool/src/softprogs/softCVS.cxx @@ -1,16 +1,15 @@ -// Filename: softCVS.cxx -// Created by: drose (10Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softCVS.cxx + * @author drose + * @date 2000-11-10 + */ #include "softCVS.h" @@ -20,11 +19,9 @@ #include -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftCVS:: SoftCVS() { _cvs_binary = "cvs"; @@ -65,15 +62,13 @@ SoftCVS() { } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SoftCVS:: run() { - // First, check for the scenes directory. If it doesn't exist, we - // must not be in the root of a soft database. + // First, check for the scenes directory. If it doesn't exist, we must not + // be in the root of a soft database. Filename scenes = "SCENES/."; if (!scenes.exists()) { nout << "No SCENES directory found; you are not in the root of a " @@ -81,8 +76,7 @@ run() { exit(1); } - // Also, if we're expecting to use CVS, make sure the CVS directory - // exists. + // Also, if we're expecting to use CVS, make sure the CVS directory exists. Filename cvs_entries = "CVS/Entries"; if (!_no_cvs && !cvs_entries.exists()) { nout << "You do not appear to be within a CVS-controlled source " @@ -96,14 +90,14 @@ run() { // Collapse out the higher-versioned scene files. collapse_scene_files(); - // Now determine which element files are actually referenced by at - // least one of the scene files. + // Now determine which element files are actually referenced by at least one + // of the scene files. if (!get_scenes()) { exit(1); } - // Finally, remove all the element files that are no longer - // referenced by any scenes. + // Finally, remove all the element files that are no longer referenced by + // any scenes. remove_unused_elements(); // Now do all the cvs adding and removing we need. @@ -113,12 +107,10 @@ run() { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::traverse_root -// Access: Private -// Description: Reads all of the toplevel directory names, -// e.g. SCENES, MATERIALS, etc., and traverses them. -//////////////////////////////////////////////////////////////////// +/** + * Reads all of the toplevel directory names, e.g. SCENES, MATERIALS, etc., + * and traverses them. + */ void SoftCVS:: traverse_root() { Filename root("."); @@ -139,12 +131,10 @@ traverse_root() { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::traverse_subdir -// Access: Private -// Description: Reads the directory indicated by prefix and -// identifies all of the SoftImage files stored there. -//////////////////////////////////////////////////////////////////// +/** + * Reads the directory indicated by prefix and identifies all of the SoftImage + * files stored there. + */ void SoftCVS:: traverse_subdir(const Filename &directory) { // Get the list of files in the directory. @@ -154,8 +144,7 @@ traverse_subdir(const Filename &directory) { return; } - // We need to know the set of files in this directory that are CVS - // elements. + // We need to know the set of files in this directory that are CVS elements. pset cvs_elements; bool in_cvs = false; if (!_no_cvs) { @@ -166,31 +155,30 @@ traverse_subdir(const Filename &directory) { bool keep_all = false; bool wants_cvs = false; - // Now make some special-case behavior based on the particular - // SoftImage subdirectory we're in. + // Now make some special-case behavior based on the particular SoftImage + // subdirectory we're in. string dirname = directory.get_basename(); if (dirname == "SCENES") { is_scenes = true; } else if (dirname == "CAMERAS") { - // We don't want anything in the cameras directory. These may - // change arbitrarily and have no bearing on the model or - // animation that we will extract, so avoid them altogether. + // We don't want anything in the cameras directory. These may change + // arbitrarily and have no bearing on the model or animation that we will + // extract, so avoid them altogether. return; } else if (dirname == "PICTURES") { - // In the pictures directory, we must keep everything, since the - // scene files don't explicitly reference these but they're still - // important. Textures that are no longer used will pile up; we - // leave this as the user's problem. + // In the pictures directory, we must keep everything, since the scene + // files don't explicitly reference these but they're still important. + // Textures that are no longer used will pile up; we leave this as the + // user's problem. - // We not only keep the textures, but we also move them into CVS, - // since (again) they're not part of the scene files and thus - // won't get added to the multifiles. Also, some textures are - // shared between different scenes, and it would be wasteful to - // add them to each scene multifile; furthermore, some scenes are - // used for animation only, and we don't want to modify these - // multifiles when the textures change. + // We not only keep the textures, but we also move them into CVS, since + // (again) they're not part of the scene files and thus won't get added to + // the multifiles. Also, some textures are shared between different + // scenes, and it would be wasteful to add them to each scene multifile; + // furthermore, some scenes are used for animation only, and we don't want + // to modify these multifiles when the textures change. keep_all = true; wants_cvs = !_no_cvs; @@ -203,8 +191,8 @@ traverse_subdir(const Filename &directory) { // This special filename is not to be considered. } else if (filename == "Chapter.rsrc") { - // This special filename should not be considered, except to add - // it to the multifiles. + // This special filename should not be considered, except to add it to + // the multifiles. _global_files.push_back(Filename(directory, filename)); } else { @@ -234,23 +222,19 @@ traverse_subdir(const Filename &directory) { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::collapse_scene_files -// Access: Private -// Description: Walks through the list of scene files found, and -// renames the higher-versioned ones to version 1-0, -// removing the intervening versions. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the list of scene files found, and renames the higher- + * versioned ones to version 1-0, removing the intervening versions. + */ void SoftCVS:: collapse_scene_files() { - // Get a copy of the scene files vector so we can modify it. Also - // empty out the _scene_files at the same time so we can fill it up - // again. + // Get a copy of the scene files vector so we can modify it. Also empty out + // the _scene_files at the same time so we can fill it up again. SceneFiles versions; versions.swap(_scene_files); - // And sort them into order so we can easily compare higher and - // lower versions. + // And sort them into order so we can easily compare higher and lower + // versions. sort(versions.begin(), versions.end()); SceneFiles::iterator vi; @@ -259,8 +243,8 @@ collapse_scene_files() { SoftFilename &file = (*vi); if (!file.is_1_0()) { - // Here's a file that needs to be renamed. But first, identify - // all the other versions of the same file. + // Here's a file that needs to be renamed. But first, identify all the + // other versions of the same file. SceneFiles::iterator start_vi; start_vi = vi; while (vi != versions.end() && (*vi).is_same_file(file)) { @@ -278,19 +262,16 @@ collapse_scene_files() { } } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::get_scenes -// Access: Private -// Description: Walks through the list of scene files and looks for -// the set of element files referenced by each one, -// updating multifile accordingly. -//////////////////////////////////////////////////////////////////// +/** + * Walks through the list of scene files and looks for the set of element + * files referenced by each one, updating multifile accordingly. + */ bool SoftCVS:: get_scenes() { bool okflag = true; - // We will be added the multifiles to CVS if they're not already - // added, so we have to know which files are in CVS already. + // We will be added the multifiles to CVS if they're not already added, so + // we have to know which files are in CVS already. pset cvs_elements; if (!_no_cvs) { scan_cvs(".", cvs_elements); @@ -320,9 +301,9 @@ get_scenes() { okflag = false; } - // Add all the global files to the multifile too. These - // probably can't take compression (since in SoftImage they're - // just the Chapter.rsrc files, each very tiny). + // Add all the global files to the multifile too. These probably + // can't take compression (since in SoftImage they're just the + // Chapter.rsrc files, each very tiny). vector_string::const_iterator gi; for (gi = _global_files.begin(); gi != _global_files.end(); ++gi) { if (multifile.update_subfile((*gi), (*gi), 0).empty()) { @@ -362,13 +343,10 @@ get_scenes() { } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::remove_unused_elements -// Access: Private -// Description: Remove all the element files that weren't referenced -// by any scene file. Also plan to cvs add all those -// that were referenced. -//////////////////////////////////////////////////////////////////// +/** + * Remove all the element files that weren't referenced by any scene file. + * Also plan to cvs add all those that were referenced. + */ void SoftCVS:: remove_unused_elements() { ElementFiles::const_iterator fi; @@ -393,14 +371,11 @@ remove_unused_elements() { } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::rename_file -// Access: Private -// Description: Renames the first file in the indicated list to a -// version 1-0 filename, superceding all the other files -// in the list. Returns true if the file is renamed, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Renames the first file in the indicated list to a version 1-0 filename, + * superceding all the other files in the list. Returns true if the file is + * renamed, false otherwise. + */ bool SoftCVS:: rename_file(SoftCVS::SceneFiles::iterator begin, SoftCVS::SceneFiles::iterator end) { @@ -450,14 +425,11 @@ rename_file(SoftCVS::SceneFiles::iterator begin, return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::scan_cvs -// Access: Private -// Description: Scans the CVS repository in the indicated directory -// to determine which files are already versioned -// elements. Returns true if the directory is -// CVS-controlled, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Scans the CVS repository in the indicated directory to determine which + * files are already versioned elements. Returns true if the directory is + * CVS-controlled, false otherwise. + */ bool SoftCVS:: scan_cvs(const string &dirname, pset &cvs_elements) { Filename cvs_entries = dirname + "/CVS/Entries"; @@ -481,9 +453,9 @@ scan_cvs(const string &dirname, pset &cvs_elements) { string filename = line.substr(1, slash - 1); if (line.substr(slash + 1, 2) == "-1") { - // If the first number after the slash is -1, the file used - // to be here but was recently cvs removed. It counts as no - // longer being an element. + // If the first number after the slash is -1, the file used to be + // here but was recently cvs removed. It counts as no longer being + // an element. } else { cvs_elements.insert(filename); } @@ -496,17 +468,14 @@ scan_cvs(const string &dirname, pset &cvs_elements) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::scan_scene_file -// Access: Private -// Description: Reads a scene file, looking for references to element -// files. For each reference found, increments the -// appropriate element file's reference count. -//////////////////////////////////////////////////////////////////// +/** + * Reads a scene file, looking for references to element files. For each + * reference found, increments the appropriate element file's reference count. + */ bool SoftCVS:: scan_scene_file(istream &in, Multifile &multifile) { bool okflag = true; - + int c = in.get(); while (!in.eof() && !in.fail()) { // Skip whitespace. @@ -530,9 +499,9 @@ scan_scene_file(istream &in, Multifile &multifile) { ElementFiles::iterator ei; for (ei = range.first; ei != range.second; ++ei) { - // We cheat and get a non-const reference to the filename out - // of the set. We can safely do this because incrementing the - // use count won't change its position in the set. + // We cheat and get a non-const reference to the filename out of the + // set. We can safely do this because incrementing the use count + // won't change its position in the set. SoftFilename &sf = (SoftFilename &)(*ei); sf.increment_use_count(); @@ -548,13 +517,10 @@ scan_scene_file(istream &in, Multifile &multifile) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::cvs_add -// Access: Private -// Description: Invokes CVS to add just the named file to the -// repository. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes CVS to add just the named file to the repository. Returns true on + * success, false on failure. + */ bool SoftCVS:: cvs_add(const string &path) { string command = _cvs_binary + " add -kb " + path; @@ -568,13 +534,10 @@ cvs_add(const string &path) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: SoftCVS::cvs_add_or_remove -// Access: Private -// Description: Invokes CVS to add (or remove) all of the files in -// the indicated vector. Returns true on success, false -// on failure. -//////////////////////////////////////////////////////////////////// +/** + * Invokes CVS to add (or remove) all of the files in the indicated vector. + * Returns true on success, false on failure. + */ bool SoftCVS:: cvs_add_or_remove(const string &cvs_command, const vector_string &paths) { static const int max_command = 4096; diff --git a/pandatool/src/softprogs/softCVS.h b/pandatool/src/softprogs/softCVS.h index 84de2db8d0..f4907e8cbe 100644 --- a/pandatool/src/softprogs/softCVS.h +++ b/pandatool/src/softprogs/softCVS.h @@ -1,16 +1,15 @@ -// Filename: softCVS.h -// Created by: drose (10Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softCVS.h + * @author drose + * @date 2000-11-10 + */ #ifndef SOFTCVS_H #define SOFTCVS_H @@ -28,12 +27,10 @@ class Multifile; -//////////////////////////////////////////////////////////////////// -// Class : SoftCVS -// Description : This program prepares a SoftImage database for CVS by -// renaming everything to version 1-0, and adding new -// files to CVS. -//////////////////////////////////////////////////////////////////// +/** + * This program prepares a SoftImage database for CVS by renaming everything + * to version 1-0, and adding new files to CVS. + */ class SoftCVS : public ProgramBase { public: SoftCVS(); diff --git a/pandatool/src/softprogs/softFilename.cxx b/pandatool/src/softprogs/softFilename.cxx index 4d2b361ddd..16d69de675 100644 --- a/pandatool/src/softprogs/softFilename.cxx +++ b/pandatool/src/softprogs/softFilename.cxx @@ -1,26 +1,23 @@ -// Filename: softFilename.cxx -// Created by: drose (10Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softFilename.cxx + * @author drose + * @date 2000-11-10 + */ #include "softFilename.h" #include "pnotify.h" -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftFilename:: SoftFilename(const string &dirname, const string &filename) : _dirname(dirname), @@ -35,8 +32,8 @@ SoftFilename(const string &dirname, const string &filename) : _base = _filename; - // Scan for a version number and an optional extension after each - // dot in the filename. + // Scan for a version number and an optional extension after each dot in the + // filename. size_t dot = _filename.find('.'); while (dot != string::npos) { size_t m = dot + 1; @@ -64,11 +61,9 @@ SoftFilename(const string &dirname, const string &filename) : } } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ SoftFilename:: SoftFilename(const SoftFilename ©) : _dirname(copy._dirname), @@ -84,11 +79,9 @@ SoftFilename(const SoftFilename ©) : { } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::Copy Assignment operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void SoftFilename:: operator = (const SoftFilename ©) { _dirname = copy._dirname; @@ -103,102 +96,80 @@ operator = (const SoftFilename ©) { _use_count = copy._use_count; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_dirname -// Access: Public -// Description: Returns the name of the directory this file was -// found in. -//////////////////////////////////////////////////////////////////// +/** + * Returns the name of the directory this file was found in. + */ const string &SoftFilename:: get_dirname() const { return _dirname; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_filename -// Access: Public -// Description: Returns the actual filename as found in the -// directory. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual filename as found in the directory. + */ const string &SoftFilename:: get_filename() const { return _filename; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::has_version -// Access: Public -// Description: Returns true if the filename had a version number, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the filename had a version number, false otherwise. + */ bool SoftFilename:: has_version() const { return _has_version; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_1_0_filename -// Access: Public -// Description: Returns what the filename would be if it were version -// 1-0. -//////////////////////////////////////////////////////////////////// +/** + * Returns what the filename would be if it were version 1-0. + */ string SoftFilename:: get_1_0_filename() const { nassertr(_has_version, string()); return _base + "1-0" + _ext; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_base -// Access: Public -// Description: Returns the base part of the filename. This is -// everything before the version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the base part of the filename. This is everything before the + * version number. + */ const string &SoftFilename:: get_base() const { nassertr(_has_version, _filename); return _base; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_major -// Access: Public -// Description: Returns the major version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the major version number. + */ int SoftFilename:: get_major() const { nassertr(_has_version, 0); return _major; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_minor -// Access: Public -// Description: Returns the minor version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the minor version number. + */ int SoftFilename:: get_minor() const { nassertr(_has_version, 0); return _minor; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_extension -// Access: Public -// Description: Returns the extension part of the filename. This is -// everything after the version number. -//////////////////////////////////////////////////////////////////// +/** + * Returns the extension part of the filename. This is everything after the + * version number. + */ const string &SoftFilename:: get_extension() const { nassertr(_has_version, _ext); return _ext; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_non_extension -// Access: Public -// Description: Returns the filename part, without the extension. -//////////////////////////////////////////////////////////////////// +/** + * Returns the filename part, without the extension. + */ string SoftFilename:: get_non_extension() const { nassertr(_has_version, _filename); @@ -206,23 +177,18 @@ get_non_extension() const { return _filename.substr(0, _filename.length() - _ext.length()); } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::is_1_0 -// Access: Public -// Description: Returns true if this is a version 1_0 filename, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this is a version 1_0 filename, false otherwise. + */ bool SoftFilename:: is_1_0() const { nassertr(_has_version, false); return (_major == 1 && _minor == 0); } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::make_1_0 -// Access: Public -// Description: Makes this a 1_0 filename. -//////////////////////////////////////////////////////////////////// +/** + * Makes this a 1_0 filename. + */ void SoftFilename:: make_1_0() { _has_version = true; @@ -231,27 +197,21 @@ make_1_0() { _filename = get_1_0_filename(); } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::is_same_file -// Access: Public -// Description: Returns true if this file has the same base and -// extension as the other, disregarding the version -// number; false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file has the same base and extension as the other, + * disregarding the version number; false otherwise. + */ bool SoftFilename:: is_same_file(const SoftFilename &other) const { return _base == other._base && _ext == other._ext; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::Ordering operator -// Access: Public -// Description: Puts filenames in order such that the files with the -// same base are sorted together, ignoring extension; -// and within files with the same base, files are sorted -// in decreasing version number order so that the most -// recent version appears first. -//////////////////////////////////////////////////////////////////// +/** + * Puts filenames in order such that the files with the same base are sorted + * together, ignoring extension; and within files with the same base, files + * are sorted in decreasing version number order so that the most recent + * version appears first. + */ bool SoftFilename:: operator < (const SoftFilename &other) const { if (_base != other._base) { @@ -259,8 +219,8 @@ operator < (const SoftFilename &other) const { } if (_has_version != other._has_version) { - // If one has a version and the other one doesn't, the one without - // a version comes first. + // If one has a version and the other one doesn't, the one without a + // version comes first. return _has_version < other._has_version; } @@ -276,67 +236,53 @@ operator < (const SoftFilename &other) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::set_in_cvs -// Access: Public -// Description: Sets the flag that indicates whether this file is -// known to be entered into the CVS database. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether this file is known to be entered into + * the CVS database. + */ void SoftFilename:: set_in_cvs(bool in_cvs) { _in_cvs = in_cvs; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_in_cvs -// Access: Public -// Description: Returns true if this file is known to be entered in -// the CVS database, false if it is not. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file is known to be entered in the CVS database, false + * if it is not. + */ bool SoftFilename:: get_in_cvs() const { return _in_cvs; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::set_wants_cvs -// Access: Public -// Description: Sets the flag that indicates whether this file -// should be entered into the CVS database. -//////////////////////////////////////////////////////////////////// +/** + * Sets the flag that indicates whether this file should be entered into the + * CVS database. + */ void SoftFilename:: set_wants_cvs(bool wants_cvs) { _wants_cvs = wants_cvs; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_wants_cvs -// Access: Public -// Description: Returns true if this file should be entered into the -// CVS database, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file should be entered into the CVS database, false + * otherwise. + */ bool SoftFilename:: get_wants_cvs() const { return _wants_cvs; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::increment_use_count -// Access: Public -// Description: Indicates that this filename is referenced by one -// more scene file. -//////////////////////////////////////////////////////////////////// +/** + * Indicates that this filename is referenced by one more scene file. + */ void SoftFilename:: increment_use_count() { _use_count++; } -//////////////////////////////////////////////////////////////////// -// Function: SoftFilename::get_use_count -// Access: Public -// Description: Returns the number of scene files that referenced -// this filename. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of scene files that referenced this filename. + */ int SoftFilename:: get_use_count() const { return _use_count; diff --git a/pandatool/src/softprogs/softFilename.h b/pandatool/src/softprogs/softFilename.h index d25d662747..3c1e448b27 100644 --- a/pandatool/src/softprogs/softFilename.h +++ b/pandatool/src/softprogs/softFilename.h @@ -1,33 +1,29 @@ -// Filename: softFilename.h -// Created by: drose (10Nov00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file softFilename.h + * @author drose + * @date 2000-11-10 + */ #ifndef SOFTFILENAME_H #define SOFTFILENAME_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : SoftFilename -// Description : This encapsulates a SoftImage versioned filename, of -// the form base.v-v.ext: it consists of a directory -// name, a base, a major and minor version number, and -// an optional extension. -// -// It also keeps track of whether the named file has -// been added to CVS, and how many scene files it is -// referenced by, -//////////////////////////////////////////////////////////////////// +/** + * This encapsulates a SoftImage versioned filename, of the form base.v-v.ext: + * it consists of a directory name, a base, a major and minor version number, + * and an optional extension. + * + * It also keeps track of whether the named file has been added to CVS, and + * how many scene files it is referenced by, + */ class SoftFilename { public: SoftFilename(const string &dirname, const string &filename); diff --git a/pandatool/src/text-stats/textMonitor.I b/pandatool/src/text-stats/textMonitor.I index 990ea09f35..d5aba895af 100644 --- a/pandatool/src/text-stats/textMonitor.I +++ b/pandatool/src/text-stats/textMonitor.I @@ -1,14 +1,12 @@ -// Filename: textMonitor.I -// Created by: drose (13Jul07) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textMonitor.I + * @author drose + * @date 2007-07-13 + */ diff --git a/pandatool/src/text-stats/textMonitor.cxx b/pandatool/src/text-stats/textMonitor.cxx index 0ce67faa08..69b134cc8f 100644 --- a/pandatool/src/text-stats/textMonitor.cxx +++ b/pandatool/src/text-stats/textMonitor.cxx @@ -1,16 +1,15 @@ -// Filename: textMonitor.cxx -// Created by: drose (12Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textMonitor.cxx + * @author drose + * @date 2000-07-12 + */ #include "textMonitor.h" #include "textStats.h" @@ -19,62 +18,49 @@ #include "indent.h" #include // sprintf -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextMonitor:: TextMonitor(TextStats *server, ostream *outStream, bool show_raw_data ) : PStatMonitor(server) { _outStream = outStream; //[PECI] _show_raw_data = show_raw_data; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::get_server -// Access: Public -// Description: Returns the server that owns this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Returns the server that owns this monitor. + */ TextStats *TextMonitor:: get_server() { return (TextStats *)PStatMonitor::get_server(); } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::get_monitor_name -// Access: Public, Virtual -// Description: Should be redefined to return a descriptive name for -// the type of PStatsMonitor this is. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return a descriptive name for the type of + * PStatsMonitor this is. + */ string TextMonitor:: get_monitor_name() { return "Text Stats"; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::got_hello -// Access: Public, Virtual -// Description: Called when the "hello" message has been received -// from the client. At this time, the client's hostname -// and program name will be known. -//////////////////////////////////////////////////////////////////// +/** + * Called when the "hello" message has been received from the client. At this + * time, the client's hostname and program name will be known. + */ void TextMonitor:: got_hello() { nout << "Now connected to " << get_client_progname() << " on host " << get_client_hostname() << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::got_bad_version -// Access: Public, Virtual -// Description: Like got_hello(), this is called when the "hello" -// message has been received from the client. At this -// time, the client's hostname and program name will be -// known. However, the client appears to be an -// incompatible version and the connection will be -// terminated; the monitor should issue a message to -// that effect. -//////////////////////////////////////////////////////////////////// +/** + * Like got_hello(), this is called when the "hello" message has been received + * from the client. At this time, the client's hostname and program name will + * be known. However, the client appears to be an incompatible version and + * the connection will be terminated; the monitor should issue a message to + * that effect. + */ void TextMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { @@ -87,15 +73,12 @@ got_bad_version(int client_major, int client_minor, << server_major << "." << server_minor << ".\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no gurantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no gurantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void TextMonitor:: new_data(int thread_index, int frame_number) { PStatView &view = get_view(thread_index); @@ -128,7 +111,7 @@ new_data(int thread_index, int frame_number) { } else { (*_outStream) << " stop "; } - + int collector_index = frame_data.get_time_collector(i); (*_outStream) << client_data->get_collector_fullname(collector_index) << "\n"; } @@ -143,9 +126,9 @@ new_data(int thread_index, int frame_number) { int num_toplevel_collectors = client_data->get_num_toplevel_collectors(); for (int tc = 0; tc < num_toplevel_collectors; tc++) { int collector = client_data->get_toplevel_collector(tc); - if (client_data->has_collector(collector) && + if (client_data->has_collector(collector) && client_data->get_collector_has_level(collector, thread_index)) { - + PStatView &level_view = get_level_view(collector, thread_index); level_view.set_to_frame(frame_number); const PStatViewLevel *level = level_view.get_top_level(); @@ -158,40 +141,32 @@ new_data(int thread_index, int frame_number) { } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::lost_connection -// Access: Public, Virtual -// Description: Called whenever the connection to the client has been -// lost. This is a permanent state change. The monitor -// should update its display to represent this, and may -// choose to close down automatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the connection to the client has been lost. This is a + * permanent state change. The monitor should update its display to represent + * this, and may choose to close down automatically. + */ void TextMonitor:: lost_connection() { nout << "Lost connection.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::is_thread_safe -// Access: Public, Virtual -// Description: Should be redefined to return true if this monitor -// class can handle running in a sub-thread. -// -// This is not related to the question of whether it can -// handle multiple different PStatThreadDatas; this is -// strictly a question of whether or not the monitor -// itself wants to run in a sub-thread. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true if this monitor class can handle running + * in a sub-thread. + * + * This is not related to the question of whether it can handle multiple + * different PStatThreadDatas; this is strictly a question of whether or not + * the monitor itself wants to run in a sub-thread. + */ bool TextMonitor:: is_thread_safe() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::show_ms -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextMonitor:: show_ms(const PStatViewLevel *level, int indent_level) { int collector_index = level->get_collector(); @@ -208,11 +183,9 @@ show_ms(const PStatViewLevel *level, int indent_level) { } } -//////////////////////////////////////////////////////////////////// -// Function: TextMonitor::show_level -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextMonitor:: show_level(const PStatViewLevel *level, int indent_level) { int collector_index = level->get_collector(); @@ -221,7 +194,7 @@ show_level(const PStatViewLevel *level, int indent_level) { const PStatCollectorDef &def = client_data->get_collector_def(collector_index); indent((*_outStream), indent_level) - << def._name << " = " << level->get_net_value() << " " + << def._name << " = " << level->get_net_value() << " " << def._level_units << "\n"; int num_children = level->get_num_children(); diff --git a/pandatool/src/text-stats/textMonitor.h b/pandatool/src/text-stats/textMonitor.h index 2108cd7e4d..7be48fc07c 100644 --- a/pandatool/src/text-stats/textMonitor.h +++ b/pandatool/src/text-stats/textMonitor.h @@ -1,16 +1,15 @@ -// Filename: textMonitor.h -// Created by: drose (12Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textMonitor.h + * @author drose + * @date 2000-07-12 + */ #ifndef TEXTMONITOR_H #define TEXTMONITOR_H @@ -18,22 +17,21 @@ #include "pandatoolbase.h" #include "pStatMonitor.h" -//[PECI] +// [PECI] #include #include class TextStats; -//////////////////////////////////////////////////////////////////// -// Class : TextMonitor -// Description : A simple, scrolling-text stats monitor. Guaranteed -// to compile on every platform. -//////////////////////////////////////////////////////////////////// +/** + * A simple, scrolling-text stats monitor. Guaranteed to compile on every + * platform. + */ class TextMonitor : public PStatMonitor { public: TextMonitor(TextStats *server, ostream *outStream, bool show_raw_data); TextStats *get_server(); - + virtual string get_monitor_name(); virtual void got_hello(); @@ -45,7 +43,7 @@ public: void show_ms(const PStatViewLevel *level, int indent_level); void show_level(const PStatViewLevel *level, int indent_level); - + private: ostream *_outStream; //[PECI] bool _show_raw_data; diff --git a/pandatool/src/text-stats/textStats.cxx b/pandatool/src/text-stats/textStats.cxx index 0e53212246..5b975cb798 100644 --- a/pandatool/src/text-stats/textStats.cxx +++ b/pandatool/src/text-stats/textStats.cxx @@ -1,16 +1,15 @@ -// Filename: textStats.cxx -// Created by: drose (12Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textStats.cxx + * @author drose + * @date 2000-07-12 + */ #include "textStats.h" #include "textMonitor.h" @@ -29,11 +28,9 @@ static void signal_handler(int) { user_interrupted = true; } -//////////////////////////////////////////////////////////////////// -// Function: TextStats::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ TextStats:: TextStats() { set_program_brief("text-based PStats client"); @@ -58,33 +55,29 @@ TextStats() { ("o", "filename", 0, "Filename where to print. If not given then stderr is being used.", &TextStats::dispatch_string, &_got_outputFileName, &_outputFileName); - + _outFile = NULL; _port = pstats_port; } -//////////////////////////////////////////////////////////////////// -// Function: TextStats::make_monitor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatMonitor *TextStats:: make_monitor() { - + return new TextMonitor(this, _outFile, _show_raw_data); } -//////////////////////////////////////////////////////////////////// -// Function: TextStats::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void TextStats:: run() { - // Set up a global signal handler to catch Interrupt (Control-C) so - // we can clean up nicely if the user stops us. + // Set up a global signal handler to catch Interrupt (Control-C) so we can + // clean up nicely if the user stops us. signal(SIGINT, &signal_handler); if (!listen(_port)) { @@ -99,7 +92,7 @@ run() { } else { _outFile = &(nout); } - + main_loop(&user_interrupted); nout << "Exiting.\n"; } diff --git a/pandatool/src/text-stats/textStats.h b/pandatool/src/text-stats/textStats.h index ef6e1f20a3..0f8ec97ed6 100644 --- a/pandatool/src/text-stats/textStats.h +++ b/pandatool/src/text-stats/textStats.h @@ -1,16 +1,15 @@ -// Filename: textStats.h -// Created by: drose (12Jul00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file textStats.h + * @author drose + * @date 2000-07-12 + */ #ifndef TEXTSTATS_H #define TEXTSTATS_H @@ -23,11 +22,10 @@ #include #include -//////////////////////////////////////////////////////////////////// -// Class : TextStats -// Description : A simple, scrolling-text stats server. Guaranteed to -// compile on every platform. -//////////////////////////////////////////////////////////////////// +/** + * A simple, scrolling-text stats server. Guaranteed to compile on every + * platform. + */ class TextStats : public ProgramBase, public PStatServer { public: TextStats(); @@ -36,15 +34,14 @@ public: void run(); -private: +private: int _port; bool _show_raw_data; - - //[PECI] + + // [PECI] bool _got_outputFileName; string _outputFileName; ostream *_outFile; }; #endif - diff --git a/pandatool/src/vrml/parse_vrml.cxx b/pandatool/src/vrml/parse_vrml.cxx index 2c7496873f..dfa2167e7f 100644 --- a/pandatool/src/vrml/parse_vrml.cxx +++ b/pandatool/src/vrml/parse_vrml.cxx @@ -1,16 +1,15 @@ -// Filename: parse_vrml.cxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parse_vrml.cxx + * @author drose + * @date 2004-10-01 + */ /************************************************** * VRML 2.0, Draft 2 Parser @@ -38,11 +37,10 @@ extern int vrmlyy_flex_debug; extern VrmlScene *parsed_scene; -//////////////////////////////////////////////////////////////////// -// Function: get_standard_nodes -// Description: Loads the set of standard VRML node definitions into -// the parser, if it has not already been loaded. -//////////////////////////////////////////////////////////////////// +/** + * Loads the set of standard VRML node definitions into the parser, if it has + * not already been loaded. + */ static bool get_standard_nodes() { static bool got_standard_nodes = false; @@ -51,8 +49,8 @@ get_standard_nodes() { return read_ok; } - // The standardNodes.wrl file has been compiled into this binary. - // Extract it out. + // The standardNodes.wrl file has been compiled into this binary. Extract + // it out. string data((const char *)standard_nodes_data, standard_nodes_data_len); @@ -60,7 +58,7 @@ get_standard_nodes() { // The data is stored compressed; decompress it on-the-fly. istringstream inz(data); IDecompressStream in(&inz, false); - + #else // The data is stored uncompressed, so just load it. istringstream in(data); @@ -76,11 +74,10 @@ get_standard_nodes() { return read_ok; } -//////////////////////////////////////////////////////////////////// -// Function: parse_vrml -// Description: Reads the named VRML file and returns a corresponding -// VrmlScene, or NULL if there is a parse error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the named VRML file and returns a corresponding VrmlScene, or NULL if + * there is a parse error. + */ VrmlScene * parse_vrml(Filename filename) { filename.set_text(); @@ -95,11 +92,10 @@ parse_vrml(Filename filename) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: parse_vrml -// Description: Reads the indicated input stream and returns a corresponding -// VrmlScene, or NULL if there is a parse error. -//////////////////////////////////////////////////////////////////// +/** + * Reads the indicated input stream and returns a corresponding VrmlScene, or + * NULL if there is a parse error. + */ VrmlScene * parse_vrml(istream &in, const string &filename) { if (!get_standard_nodes()) { diff --git a/pandatool/src/vrml/parse_vrml.h b/pandatool/src/vrml/parse_vrml.h index 5f85efbd07..88c52e16f7 100644 --- a/pandatool/src/vrml/parse_vrml.h +++ b/pandatool/src/vrml/parse_vrml.h @@ -1,14 +1,15 @@ -// Filename: parse_vrml.h -// Created by: drose (24Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file parse_vrml.h + * @author drose + * @date 1999-06-24 + */ #ifndef PARSE_VRML_H #define PARSE_VRML_H diff --git a/pandatool/src/vrml/standard_nodes.cxx b/pandatool/src/vrml/standard_nodes.cxx index d8541c8290..221efe14fc 100644 --- a/pandatool/src/vrml/standard_nodes.cxx +++ b/pandatool/src/vrml/standard_nodes.cxx @@ -1,35 +1,34 @@ -// Filename: standard_nodes.cxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standard_nodes.cxx + * @author drose + * @date 2004-10-01 + */ #include "standard_nodes.h" -// The binary data included here was generated from standardNodes.wrl -// (in this directory) file via the utility program bin2c (defined in -// pandatool). It contains the set of VRML definitions that must be -// loaded before any standard VRML file can be properly interpreted. +// The binary data included here was generated from standardNodes.wrl (in this +// directory) file via the utility program bin2c (defined in pandatool). It +// contains the set of VRML definitions that must be loaded before any +// standard VRML file can be properly interpreted. #ifndef CPPPARSER #if defined(HAVE_ZLIB) -// If we have zlib available, we can store this file compressed, which -// is much smaller. +// If we have zlib available, we can store this file compressed, which is much +// smaller. // Regenerate this file with: -// pcompress standardNodes.wrl standardNodes.wrl.pz -// bin2c -n standard_nodes_data -o standardNodes.wrl.pz.c standardNodes.wrl.pz +// pcompress standardNodes.wrl standardNodes.wrl.pz bin2c -n +// standard_nodes_data -o standardNodes.wrl.pz.c standardNodes.wrl.pz #include "standardNodes.wrl.pz.c" diff --git a/pandatool/src/vrml/standard_nodes.h b/pandatool/src/vrml/standard_nodes.h index 58269175d9..e97101d628 100644 --- a/pandatool/src/vrml/standard_nodes.h +++ b/pandatool/src/vrml/standard_nodes.h @@ -1,16 +1,15 @@ -// Filename: standard_nodes.h -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standard_nodes.h + * @author drose + * @date 2004-10-01 + */ #ifndef STANDARD_NODES_H #define STANDARD_NODES_H @@ -25,4 +24,3 @@ extern const int standard_nodes_data_len; #endif // CPPPARSER #endif - diff --git a/pandatool/src/vrml/vrmlLexerDefs.h b/pandatool/src/vrml/vrmlLexerDefs.h index 47c1c950fd..f33a444fe4 100644 --- a/pandatool/src/vrml/vrmlLexerDefs.h +++ b/pandatool/src/vrml/vrmlLexerDefs.h @@ -1,16 +1,15 @@ -// Filename: vrmlLexerDefs.h -// Created by: drose (30Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlLexerDefs.h + * @author drose + * @date 2004-09-30 + */ #ifndef VRMLLEXERDEFS_H #define VRMLLEXERDEFS_H diff --git a/pandatool/src/vrml/vrmlNode.cxx b/pandatool/src/vrml/vrmlNode.cxx index b498bdb9e6..d21061cd3a 100644 --- a/pandatool/src/vrml/vrmlNode.cxx +++ b/pandatool/src/vrml/vrmlNode.cxx @@ -1,14 +1,15 @@ -// Filename: vrmlNode.cxx -// Created by: drose (23Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlNode.cxx + * @author drose + * @date 1999-06-23 + */ #include "vrmlNode.h" #include "vrmlParser.h" @@ -26,7 +27,7 @@ VrmlNode:: ~VrmlNode() { } - + const VrmlFieldValue &VrmlNode:: get_value(const char *field_name) const { Fields::const_iterator fi; diff --git a/pandatool/src/vrml/vrmlNode.h b/pandatool/src/vrml/vrmlNode.h index 409b9bb1fb..dad8a1bce1 100644 --- a/pandatool/src/vrml/vrmlNode.h +++ b/pandatool/src/vrml/vrmlNode.h @@ -1,14 +1,15 @@ -// Filename: vrmlNode.h -// Created by: drose (23Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlNode.h + * @author drose + * @date 1999-06-23 + */ #ifndef VRMLNODE_H #define VRMLNODE_H diff --git a/pandatool/src/vrml/vrmlParser.yxx b/pandatool/src/vrml/vrmlParser.yxx index 606aa9d896..3404f8c3f8 100644 --- a/pandatool/src/vrml/vrmlParser.yxx +++ b/pandatool/src/vrml/vrmlParser.yxx @@ -1,16 +1,15 @@ -// Filename: vrmlParser.yxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlParser.yxx + * @author drose + * @date 2004-10-01 + */ // ******************************************************* // VRML 2.0 Parser diff --git a/pandatool/src/vrml/vrmlParserDefs.h b/pandatool/src/vrml/vrmlParserDefs.h index cc253d9ebc..75464abd46 100644 --- a/pandatool/src/vrml/vrmlParserDefs.h +++ b/pandatool/src/vrml/vrmlParserDefs.h @@ -1,16 +1,15 @@ -// Filename: vrmlParserDefs.h -// Created by: drose (30Sep04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlParserDefs.h + * @author drose + * @date 2004-09-30 + */ #ifndef VRMLPARSERDEFS_H #define VRMLPARSERDEFS_H diff --git a/pandatool/src/vrmlegg/indexedFaceSet.cxx b/pandatool/src/vrmlegg/indexedFaceSet.cxx index 6033b2b1a6..96b5cc9194 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.cxx +++ b/pandatool/src/vrmlegg/indexedFaceSet.cxx @@ -1,14 +1,15 @@ -// Filename: indexedFaceSet.cxx -// Created by: drose (24Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexedFaceSet.cxx + * @author drose + * @date 1999-06-24 + */ #include "indexedFaceSet.h" #include "vrmlAppearance.h" @@ -21,11 +22,9 @@ #include "eggVertexPool.h" #include "eggPolygon.h" -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ IndexedFaceSet:: IndexedFaceSet(const VrmlNode *geometry, const VRMLAppearance &appearance) : _geometry(geometry), _appearance(appearance) @@ -44,11 +43,9 @@ IndexedFaceSet(const VrmlNode *geometry, const VRMLAppearance &appearance) : } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::convert_to_egg -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexedFaceSet:: convert_to_egg(EggGroup *group, const LMatrix4d &net_transform) { EggVertexPool *vpool = new EggVertexPool(group->get_name()); @@ -61,11 +58,9 @@ convert_to_egg(EggGroup *group, const LMatrix4d &net_transform) { } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_coord_values -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexedFaceSet:: get_coord_values() { const VrmlNode *coord = _geometry->get_value("coord")._sfnode._p; @@ -81,11 +76,9 @@ get_coord_values() { } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_polys -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexedFaceSet:: get_polys() { const MFArray *coordIndex = _geometry->get_value("coordIndex")._mf; @@ -106,12 +99,9 @@ get_polys() { } } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_vrml_colors -// Access: Private -// Description: Builds up a vector of LColor pointers corresponding -// to the VRML color node. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a vector of LColor pointers corresponding to the VRML color node. + */ void IndexedFaceSet:: get_vrml_colors(const VrmlNode *color_node, double transparency, pvector &color_list) { @@ -124,14 +114,12 @@ get_vrml_colors(const VrmlNode *color_node, double transparency, } } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_vrml_normals -// Access: Private -// Description: Builds up a vector of double array pointers corresponding -// to the VRML normal node. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a vector of double array pointers corresponding to the VRML + * normal node. + */ void IndexedFaceSet:: -get_vrml_normals(const VrmlNode *normal_node, +get_vrml_normals(const VrmlNode *normal_node, pvector &normal_list) { const MFArray *point = normal_node->get_value("vector")._mf; MFArray::const_iterator ci; @@ -142,14 +130,12 @@ get_vrml_normals(const VrmlNode *normal_node, } } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_vrml_uvs -// Access: Private -// Description: Builds up a vector of double array pointers corresponding -// to the VRML texCoord node. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a vector of double array pointers corresponding to the VRML + * texCoord node. + */ void IndexedFaceSet:: -get_vrml_uvs(const VrmlNode *texCoord_node, +get_vrml_uvs(const VrmlNode *texCoord_node, pvector &uv_list) { const MFArray *point = texCoord_node->get_value("point")._mf; MFArray::const_iterator ci; @@ -161,11 +147,9 @@ get_vrml_uvs(const VrmlNode *texCoord_node, } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_colors -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool IndexedFaceSet:: get_colors() { const VrmlNode *color = _geometry->get_value("color")._sfnode._p; @@ -173,7 +157,7 @@ get_colors() { // Vertex or face colors. pvector color_list; get_vrml_colors(color, _appearance._transparency, color_list); - + bool colorPerVertex = _geometry->get_value("colorPerVertex")._sfbool; MFArray *colorIndex = _geometry->get_value("colorIndex")._mf; if (colorPerVertex) { @@ -233,11 +217,9 @@ get_colors() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_normals -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool IndexedFaceSet:: get_normals() { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; @@ -245,7 +227,7 @@ get_normals() { // Vertex or face normals. pvector normal_list; get_vrml_normals(normal, normal_list); - + bool normalPerVertex = _geometry->get_value("normalPerVertex")._sfbool; MFArray *normalIndex = _geometry->get_value("normalIndex")._mf; MFArray::const_iterator ci; @@ -253,20 +235,19 @@ get_normals() { if (normalPerVertex && normal_list.size() == _polys.size() && normalIndex->empty()) { - // Here's an interesting formZ bug. We end up with a VRML file - // that claims to have normals per vertex, yet there is no - // normal index list, and there are exactly enough normals in - // the list to indicate one normal per face. Silly formZ. + // Here's an interesting formZ bug. We end up with a VRML file that + // claims to have normals per vertex, yet there is no normal index list, + // and there are exactly enough normals in the list to indicate one + // normal per face. Silly formZ. normalPerVertex = false; } if (normalPerVertex) { if (normalIndex->empty()) { - // If we have *no* normal index array, but we do have - // per-vertex normals, assume the VRML writer meant to imply a - // one-to-one mapping. This works around a broken formZ VRML - // file writer. + // If we have *no* normal index array, but we do have per-vertex + // normals, assume the VRML writer meant to imply a one-to-one + // mapping. This works around a broken formZ VRML file writer. for (size_t i = 0; i < normal_list.size(); i++) { VrmlFieldValue fv; fv._sfint32 = i; @@ -274,22 +255,22 @@ get_normals() { } } - // It's possible that this .wrl file indexes normals directly - // into the vertex array, instead of into the polygon list. - // Check for this possibility. This can only happen if the - // number of normal indices exactly matches the number of - // vertices, and none of the indices is -1. + // It's possible that this .wrl file indexes normals directly into the + // vertex array, instead of into the polygon list. Check for this + // possibility. This can only happen if the number of normal indices + // exactly matches the number of vertices, and none of the indices is + // -1. bool linear_list = (normalIndex->size() == _coord_values.size()); - for (ci = normalIndex->begin(); - ci != normalIndex->end() && linear_list; + for (ci = normalIndex->begin(); + ci != normalIndex->end() && linear_list; ++ci) { linear_list = ((*ci)._sfint32 >= 0); } - + if (linear_list) { - // Ok, we do have such a list. This .wrl file seems to store - // its texture coordinates one per vertex, instead of one per - // polygon vertex. + // Ok, we do have such a list. This .wrl file seems to store its + // texture coordinates one per vertex, instead of one per polygon + // vertex. _per_vertex_normals.reserve(_coord_values.size()); for (ci = normalIndex->begin(); ci != normalIndex->end(); ++ci) { @@ -304,10 +285,10 @@ get_normals() { nassertr(_per_vertex_normals.size() == _coord_values.size(), false); } else { - // This is a "correct" .wrl file that stores its texture - // coordinates one per polygon vertex. This allows a shared - // vertex to contain two different normal values in differing - // polygons (meaning it's not actually shared). + // This is a "correct" .wrl file that stores its texture coordinates + // one per polygon vertex. This allows a shared vertex to contain two + // different normal values in differing polygons (meaning it's not + // actually shared). MFArray::const_iterator ci; size_t pi = 0; @@ -368,15 +349,12 @@ get_normals() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::assign_per_vertex_normals -// Access: Private -// Description: Once the array of _per_vertex_normals has been filled -// (by a broken .wrl file that indexes the normal's -// directly into the vertex array instead of per polygon -// vertex), go back through the polygons and assign the -// normals by index number. -//////////////////////////////////////////////////////////////////// +/** + * Once the array of _per_vertex_normals has been filled (by a broken .wrl + * file that indexes the normal's directly into the vertex array instead of + * per polygon vertex), go back through the polygons and assign the normals by + * index number. + */ void IndexedFaceSet:: assign_per_vertex_normals() { for (size_t pi = 0; pi < _polys.size(); pi++) { @@ -391,11 +369,9 @@ assign_per_vertex_normals() { } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::get_uvs -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool IndexedFaceSet:: get_uvs() { const VrmlNode *texCoord = _geometry->get_value("texCoord")._sfnode._p; @@ -403,15 +379,14 @@ get_uvs() { // Vertex or face texCoords. pvector uv_list; get_vrml_uvs(texCoord, uv_list); - + MFArray *texCoordIndex = _geometry->get_value("texCoordIndex")._mf; MFArray::const_iterator ci; if (texCoordIndex->empty()) { - // If we have *no* texture coordinate index array, but we do - // have texture coordinates, assume the VRML writer meant to - // imply a one-to-one mapping. This works around a broken formZ - // VRML file writer. + // If we have *no* texture coordinate index array, but we do have + // texture coordinates, assume the VRML writer meant to imply a one-to- + // one mapping. This works around a broken formZ VRML file writer. for (size_t i = 0; i < uv_list.size(); i++) { VrmlFieldValue fv; fv._sfint32 = i; @@ -419,22 +394,22 @@ get_uvs() { } } - // It's possible that this .wrl file indexes texture coordinates - // directly into the vertex array, instead of into the polygon - // list. Check for this possibility. This can only happen if the - // number of texture coordinate indices exactly matches the number - // of vertices, and none of the indices is -1. + // It's possible that this .wrl file indexes texture coordinates directly + // into the vertex array, instead of into the polygon list. Check for + // this possibility. This can only happen if the number of texture + // coordinate indices exactly matches the number of vertices, and none of + // the indices is -1. bool linear_list = (texCoordIndex->size() == _coord_values.size()); - for (ci = texCoordIndex->begin(); - ci != texCoordIndex->end() && linear_list; + for (ci = texCoordIndex->begin(); + ci != texCoordIndex->end() && linear_list; ++ci) { linear_list = ((*ci)._sfint32 >= 0); } if (linear_list) { - // Ok, we do have such a list. This .wrl file seems to store - // its texture coordinates one per vertex, instead of one per - // polygon vertex. + // Ok, we do have such a list. This .wrl file seems to store its + // texture coordinates one per vertex, instead of one per polygon + // vertex. _per_vertex_uvs.reserve(_coord_values.size()); for (ci = texCoordIndex->begin(); ci != texCoordIndex->end(); ++ci) { @@ -449,10 +424,10 @@ get_uvs() { nassertr(_per_vertex_uvs.size() == _coord_values.size(), false); } else { - // This is a "correct" .wrl file that stores its texture - // coordinates one per polygon vertex. This allows a shared - // vertex to contain two different texture coordinate values in - // differing polygons (meaning it's not actually shared). + // This is a "correct" .wrl file that stores its texture coordinates one + // per polygon vertex. This allows a shared vertex to contain two + // different texture coordinate values in differing polygons (meaning + // it's not actually shared). size_t pi = 0; size_t pv = 0; @@ -484,15 +459,11 @@ get_uvs() { return false; } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::assign_per_vertex_uvs -// Access: Private -// Description: Once the array of _per_vertex_uvs has been filled (by -// a broken .wrl file that indexes the uv's directly -// into the vertex array instead of per polygon vertex), -// go back through the polygons and assign the UV's by -// index number. -//////////////////////////////////////////////////////////////////// +/** + * Once the array of _per_vertex_uvs has been filled (by a broken .wrl file + * that indexes the uv's directly into the vertex array instead of per polygon + * vertex), go back through the polygons and assign the UV's by index number. + */ void IndexedFaceSet:: assign_per_vertex_uvs() { for (size_t pi = 0; pi < _polys.size(); pi++) { @@ -507,13 +478,11 @@ assign_per_vertex_uvs() { } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::make_polys -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexedFaceSet:: -make_polys(EggVertexPool *vpool, EggGroup *group, +make_polys(EggVertexPool *vpool, EggGroup *group, const LMatrix4d &net_transform) { bool ccw = _geometry->get_value("ccw")._sfbool; bool solid = _geometry->get_value("solid")._sfbool; @@ -539,7 +508,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, // The vertices are counterclockwise, same as Egg. for (int pv = 0; pv < (int)_polys[pi]._verts.size(); pv++) { EggVertex vert(_polys[pi]._verts[pv]._attrib); - LVertexd pos = + LVertexd pos = _polys[pi]._verts[pv]._pos * net_transform; vert.set_pos(pos); @@ -549,7 +518,7 @@ make_polys(EggVertexPool *vpool, EggGroup *group, // The vertices are clockwise, so add 'em in reverse order. for (int pv = (int)_polys[pi]._verts.size() - 1; pv >= 0; pv--) { EggVertex vert(_polys[pi]._verts[pv]._attrib); - LVertexd pos = + LVertexd pos = _polys[pi]._verts[pv]._pos * net_transform; vert.set_pos(pos); @@ -560,11 +529,9 @@ make_polys(EggVertexPool *vpool, EggGroup *group, } -//////////////////////////////////////////////////////////////////// -// Function: IndexedFaceSet::compute_normals -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void IndexedFaceSet:: compute_normals(EggGroup *group) { const VrmlNode *normal = _geometry->get_value("normal")._sfnode._p; diff --git a/pandatool/src/vrmlegg/indexedFaceSet.h b/pandatool/src/vrmlegg/indexedFaceSet.h index f5ad84812a..48e63ae822 100644 --- a/pandatool/src/vrmlegg/indexedFaceSet.h +++ b/pandatool/src/vrmlegg/indexedFaceSet.h @@ -1,14 +1,15 @@ -// Filename: indexedFaceSet.h -// Created by: drose (24Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file indexedFaceSet.h + * @author drose + * @date 1999-06-24 + */ #ifndef INDEXEDFACESET_H #define INDEXEDFACESET_H @@ -28,11 +29,10 @@ class EggVertexPool; class VRMLAppearance; class LMatrix4d; -//////////////////////////////////////////////////////////////////// -// Class : IndexedFaceSet -// Description : Decodes the vertices and faces in a VRML indexed face -// set, and creates the corresponding egg geometry. -//////////////////////////////////////////////////////////////////// +/** + * Decodes the vertices and faces in a VRML indexed face set, and creates the + * corresponding egg geometry. + */ class IndexedFaceSet { public: IndexedFaceSet(const VrmlNode *geometry, const VRMLAppearance &appearance); diff --git a/pandatool/src/vrmlegg/vrmlAppearance.cxx b/pandatool/src/vrmlegg/vrmlAppearance.cxx index d484ae96be..fff1ec48f2 100644 --- a/pandatool/src/vrmlegg/vrmlAppearance.cxx +++ b/pandatool/src/vrmlegg/vrmlAppearance.cxx @@ -1,14 +1,15 @@ -// Filename: vrmlAppearance.cxx -// Created by: drose (24Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlAppearance.cxx + * @author drose + * @date 1999-06-24 + */ #include "vrmlAppearance.h" #include "vrmlNode.h" @@ -64,5 +65,3 @@ VRMLAppearance(const VrmlNode *appearance) { } } } - - diff --git a/pandatool/src/vrmlegg/vrmlAppearance.h b/pandatool/src/vrmlegg/vrmlAppearance.h index 2cb804174e..791d5fb66a 100644 --- a/pandatool/src/vrmlegg/vrmlAppearance.h +++ b/pandatool/src/vrmlegg/vrmlAppearance.h @@ -1,14 +1,15 @@ -// Filename: vrmlAppearance.h -// Created by: drose (24Jun99) -// -//////////////////////////////////////////////////////////////////// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlAppearance.h + * @author drose + * @date 1999-06-24 + */ #ifndef VRMLAPPEARANCE_H #define VRMLAPPEARANCE_H diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx index 8280c5cf94..4083fb0847 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.cxx +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: vrmlToEggConverter.cxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlToEggConverter.cxx + * @author drose + * @date 2004-10-01 + */ #include "vrmlToEggConverter.h" #include "vrmlAppearance.h" @@ -23,87 +22,67 @@ #include "eggData.h" #include "deg_2_rad.h" -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VRMLToEggConverter:: VRMLToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VRMLToEggConverter:: VRMLToEggConverter(const VRMLToEggConverter ©) : SomethingToEggConverter(copy) { } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VRMLToEggConverter:: ~VRMLToEggConverter() { } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *VRMLToEggConverter:: make_copy() { return new VRMLToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string VRMLToEggConverter:: get_name() const { return "VRML"; } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string VRMLToEggConverter:: get_extension() const { return "wrl"; } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool VRMLToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + */ bool VRMLToEggConverter:: convert_file(const Filename &filename) { clear_error(); @@ -117,16 +96,16 @@ convert_file(const Filename &filename) { _egg_data->set_coordinate_system(CS_yup_right); } - // First, resolve all the DEF/USE references, and count the number - // of times each node is USEd. + // First, resolve all the DEFUSE references, and count the number of times + // each node is USEd. Nodes nodes; VrmlScene::iterator si; for (si = scene->begin(); si != scene->end(); ++si) { get_all_defs((*si)._node, nodes); } - // Now go through the hierarchy again, and this time actually - // build the egg structure. + // Now go through the hierarchy again, and this time actually build the egg + // structure. VrmlScene::const_iterator csi; for (csi = scene->begin(); csi != scene->end(); ++csi) { vrml_node((*csi)._node, get_egg_data(), LMatrix4d::ident_mat()); @@ -135,20 +114,16 @@ convert_file(const Filename &filename) { return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::get_all_defs -// Access: Private -// Description: Makes a first pass through the VRML hierarchy, -// identifying all nodes marked with a DEF code, and -// also counting the times each one is referenced by -// USE. Later, we'll need this information: if a node -// is referenced at least once, we need to define it as -// an instance node. -//////////////////////////////////////////////////////////////////// +/** + * Makes a first pass through the VRML hierarchy, identifying all nodes marked + * with a DEF code, and also counting the times each one is referenced by USE. + * Later, we'll need this information: if a node is referenced at least once, + * we need to define it as an instance node. + */ void VRMLToEggConverter:: get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { Nodes::iterator ni; - + switch (vrml._type) { case SFNodeRef::T_def: // If this is a node definition, add it to the map. @@ -158,7 +133,7 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { This happens too often to bother yelling about it. ni = nodes.find(vrml._name); if (ni != nodes.end()) { - cerr << "Warning: node name " << vrml._name + cerr << "Warning: node name " << vrml._name << " appears multiple times.\n"; } */ @@ -175,8 +150,8 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { // Increment the use count of the node. (*ni).second->_use_count++; - // Store the pointer itself in the reference, so we don't have - // to do this again later. + // Store the pointer itself in the reference, so we don't have to do + // this again later. vrml._p = (*ni).second; } return; @@ -202,42 +177,35 @@ get_all_defs(SFNodeRef &vrml, VRMLToEggConverter::Nodes &nodes) { } } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::vrml_node -// Access: Public -// Description: Processes a single VRML node, converting it to egg -// and adding it to the egg file, if appropriate, or -// doing whatever else should be done. -//////////////////////////////////////////////////////////////////// +/** + * Processes a single VRML node, converting it to egg and adding it to the egg + * file, if appropriate, or doing whatever else should be done. + */ void VRMLToEggConverter:: -vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, +vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform) { const VrmlNode *node = vrml._p; if (node != NULL) { // Now add it to the egg file at this point. if (strcmp(node->_type->getName(), "Group") == 0) { - vrml_grouping_node(vrml, egg, net_transform, + vrml_grouping_node(vrml, egg, net_transform, &VRMLToEggConverter::vrml_group); } else if (strcmp(node->_type->getName(), "Transform") == 0) { - vrml_grouping_node(vrml, egg, net_transform, + vrml_grouping_node(vrml, egg, net_transform, &VRMLToEggConverter::vrml_transform); } else if (strcmp(node->_type->getName(), "Shape") == 0) { - vrml_grouping_node(vrml, egg, net_transform, + vrml_grouping_node(vrml, egg, net_transform, &VRMLToEggConverter::vrml_shape); } } } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::vrml_grouping_node -// Access: Public -// Description: Begins initial processing of a grouping-type node; -// that is, any node (like Group, Transform, or Shape) -// that maps to a or in egg. This -// create the group and does any instance-munging -// necessary, then calls the indicated method with the -// new parameters. -//////////////////////////////////////////////////////////////////// +/** + * Begins initial processing of a grouping-type node; that is, any node (like + * Group, Transform, or Shape) that maps to a or in egg. + * This create the group and does any instance-munging necessary, then calls + * the indicated method with the new parameters. + */ void VRMLToEggConverter:: vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform, @@ -257,8 +225,8 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, instance references, so we deal with VRML instances by copying. if (vrml._type == SFNodeRef::T_use) { - // If this is an instancing reference, just add the reference and - // return; no need for further processing on the node. + // If this is an instancing reference, just add the reference and return; + // no need for further processing on the node. Instances::const_iterator fi = _instances.find(node); assert(fi != _instances.end()); EggInstance *inst = _data.CreateInstance(egg); @@ -273,24 +241,22 @@ vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, LMatrix4d next_transform = net_transform; if (node->_use_count > 0) { - // If this node is referenced one or more times later in the file, - // we must make it an instance node. + // If this node is referenced one or more times later in the file, we must + // make it an instance node. group->set_group_type(EggGroup::GT_instance); next_transform = LMatrix4d::ident_mat(); - // And define the instance for future references. - // _instances[node] = group; + // And define the instance for future references. _instances[node] = + // group; } (this->*process_func)(node, group, next_transform); } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::vrml_group -// Access: Public -// Description: Creates an Egg group corresponding to the VRML group. -//////////////////////////////////////////////////////////////////// +/** + * Creates an Egg group corresponding to the VRML group. + */ void VRMLToEggConverter:: vrml_group(const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform) { @@ -301,12 +267,9 @@ vrml_group(const VrmlNode *node, EggGroup *group, } } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::vrml_transform -// Access: Public -// Description: Creates an Egg group with a transform corresponding -// to the VRML group. -//////////////////////////////////////////////////////////////////// +/** + * Creates an Egg group with a transform corresponding to the VRML group. + */ void VRMLToEggConverter:: vrml_transform(const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform) { @@ -328,42 +291,42 @@ vrml_transform(const VrmlNode *node, EggGroup *group, LMatrix4d::translate_mat(-center[0], -center[1], -center[2]); if (o[3] != 0.0) { - local_transform *= + local_transform *= LMatrix4d::rotate_mat(rad_2_deg(-o[3]), LVector3d(o[0], o[1], o[2])); local_transform *= LMatrix4d::scale_mat(scale[0], scale[1], scale[2]); - local_transform *= + local_transform *= LMatrix4d::rotate_mat(rad_2_deg(o[3]), LVector3d(o[0], o[1], o[2])); } else { local_transform *= LMatrix4d::scale_mat(scale[0], scale[1], scale[2]); } - local_transform *= + local_transform *= LMatrix4d::translate_mat(center[0], center[1], center[2]); } else { if (o[3] != 0.0) { - local_transform *= + local_transform *= LMatrix4d::rotate_mat(rad_2_deg(-o[3]), LVector3d(o[0], o[1], o[2])); local_transform *= LMatrix4d::scale_mat(scale[0], scale[1], scale[2]); - local_transform *= + local_transform *= LMatrix4d::rotate_mat(rad_2_deg(o[3]), LVector3d(o[0], o[1], o[2])); } else { local_transform *= LMatrix4d::scale_mat(scale[0], scale[1], scale[2]); } - } + } } if (rotation[3] != 0.0) { any_transform = true; if (center[0] != 0.0 || center[1] != 0.0 || center[2] != 0.0) { - local_transform *= + local_transform *= LMatrix4d::translate_mat(-center[0], -center[1], -center[2]); - local_transform *= + local_transform *= LMatrix4d::rotate_mat(rad_2_deg(rotation[3]), LVector3d(rotation[0], rotation[1], rotation[2])); local_transform *= @@ -397,13 +360,10 @@ vrml_transform(const VrmlNode *node, EggGroup *group, } } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEggConverter::vrml_shape -// Access: Public -// Description: Creates an Egg group corresponding a VRML shape. -// This will probably contain a vertex pool and a number -// of polygons. -//////////////////////////////////////////////////////////////////// +/** + * Creates an Egg group corresponding a VRML shape. This will probably + * contain a vertex pool and a number of polygons. + */ void VRMLToEggConverter:: vrml_shape(const VrmlNode *node, EggGroup *group, const LMatrix4d &net_transform) { diff --git a/pandatool/src/vrmlegg/vrmlToEggConverter.h b/pandatool/src/vrmlegg/vrmlToEggConverter.h index e25d6823b9..612881d770 100644 --- a/pandatool/src/vrmlegg/vrmlToEggConverter.h +++ b/pandatool/src/vrmlegg/vrmlToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: vrmlToEggConverter.h -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlToEggConverter.h + * @author drose + * @date 2004-10-01 + */ #ifndef VRMLTOEGGCONVERTER_H #define VRMLTOEGGCONVERTER_H @@ -26,11 +25,10 @@ class EggGroupNode; class EggGroup; class LMatrix4d; -//////////////////////////////////////////////////////////////////// -// Class : VRMLToEggConverter -// Description : This class supervises the construction of an EggData -// structure from a VRML file. -//////////////////////////////////////////////////////////////////// +/** + * This class supervises the construction of an EggData structure from a VRML + * file. + */ class VRMLToEggConverter : public SomethingToEggConverter { public: VRMLToEggConverter(); @@ -49,7 +47,7 @@ private: typedef pmap Nodes; void get_all_defs(SFNodeRef &vrml, Nodes &nodes); - void vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, + void vrml_node(const SFNodeRef &vrml, EggGroupNode *egg, const LMatrix4d &net_transform); void vrml_grouping_node(const SFNodeRef &vrml, EggGroupNode *egg, @@ -66,5 +64,3 @@ private: }; #endif - - diff --git a/pandatool/src/vrmlprogs/vrmlToEgg.cxx b/pandatool/src/vrmlprogs/vrmlToEgg.cxx index 8ade53d2e0..613f55c84b 100644 --- a/pandatool/src/vrmlprogs/vrmlToEgg.cxx +++ b/pandatool/src/vrmlprogs/vrmlToEgg.cxx @@ -1,27 +1,24 @@ -// Filename: vrmlToEgg.cxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlToEgg.cxx + * @author drose + * @date 2004-10-01 + */ #include "vrmlToEgg.h" #include "vrmlToEggConverter.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VRMLToEgg:: VRMLToEgg() : SomethingToEgg("VRML", ".wrl") @@ -43,11 +40,9 @@ VRMLToEgg() : _coordinate_system = CS_yup_right; } -//////////////////////////////////////////////////////////////////// -// Function: VRMLToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VRMLToEgg:: run() { nout << "Reading " << _input_filename << "\n"; diff --git a/pandatool/src/vrmlprogs/vrmlToEgg.h b/pandatool/src/vrmlprogs/vrmlToEgg.h index d1a43197b2..90edb3b189 100644 --- a/pandatool/src/vrmlprogs/vrmlToEgg.h +++ b/pandatool/src/vrmlprogs/vrmlToEgg.h @@ -1,17 +1,16 @@ -// Filename: vrmlToEgg.h -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlToEgg.h + * @author drose + * @date 2004-10-01 + */ + #ifndef VRMLTOEGG_H #define VRMLTOEGG_H @@ -20,11 +19,9 @@ #include "somethingToEgg.h" #include "vrmlToEggConverter.h" -//////////////////////////////////////////////////////////////////// -// Class : VRMLToEgg -// Description : A program to read a VRML file and generate an egg -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a VRML file and generate an egg file. + */ class VRMLToEgg : public SomethingToEgg { public: VRMLToEgg(); @@ -33,5 +30,3 @@ public: }; #endif - - diff --git a/pandatool/src/vrmlprogs/vrmlTrans.cxx b/pandatool/src/vrmlprogs/vrmlTrans.cxx index acf226978e..fd485eada0 100644 --- a/pandatool/src/vrmlprogs/vrmlTrans.cxx +++ b/pandatool/src/vrmlprogs/vrmlTrans.cxx @@ -1,32 +1,29 @@ -// Filename: vrmlTrans.cxx -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlTrans.cxx + * @author drose + * @date 2004-10-01 + */ #include "vrmlTrans.h" #include "parse_vrml.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: VRMLTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ VRMLTrans:: VRMLTrans() : WithOutputFile(true, true, false) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = ".wrl"; set_program_brief("reads and writes VRML 2.0 files"); @@ -49,11 +46,9 @@ VRMLTrans() : } -//////////////////////////////////////////////////////////////////// -// Function: VRMLTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void VRMLTrans:: run() { nout << "Reading " << _input_filename << "\n"; @@ -68,11 +63,9 @@ run() { } -//////////////////////////////////////////////////////////////////// -// Function: VRMLTrans::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool VRMLTrans:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { diff --git a/pandatool/src/vrmlprogs/vrmlTrans.h b/pandatool/src/vrmlprogs/vrmlTrans.h index 73b119724a..4ff49d242b 100644 --- a/pandatool/src/vrmlprogs/vrmlTrans.h +++ b/pandatool/src/vrmlprogs/vrmlTrans.h @@ -1,16 +1,15 @@ -// Filename: vrmlTrans.h -// Created by: drose (01Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file vrmlTrans.h + * @author drose + * @date 2004-10-01 + */ #ifndef VRMLTRANS_H #define VRMLTRANS_H @@ -20,12 +19,10 @@ #include "programBase.h" #include "withOutputFile.h" -//////////////////////////////////////////////////////////////////// -// Class : VRMLTrans -// Description : A program to read a VRML file and output an -// essentially similar VRML file. This is mainly useful -// to test the VRML parser used in Panda. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a VRML file and output an essentially similar VRML file. + * This is mainly useful to test the VRML parser used in Panda. + */ class VRMLTrans : public ProgramBase, public WithOutputFile { public: VRMLTrans(); @@ -39,4 +36,3 @@ protected: }; #endif - diff --git a/pandatool/src/win-stats/winStats.cxx b/pandatool/src/win-stats/winStats.cxx index 46c67e95c3..35e58f6367 100644 --- a/pandatool/src/win-stats/winStats.cxx +++ b/pandatool/src/win-stats/winStats.cxx @@ -1,16 +1,15 @@ -// Filename: winStats.cxx -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStats.cxx + * @author drose + * @date 2003-12-02 + */ #include "pandatoolbase.h" @@ -23,10 +22,9 @@ static const char *toplevel_class_name = "pstats"; static WinStatsServer *server = NULL; -//////////////////////////////////////////////////////////////////// -// Function: toplevel_window_proc -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ static LONG WINAPI toplevel_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -45,12 +43,10 @@ toplevel_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } - -//////////////////////////////////////////////////////////////////// -// Function: create_toplevel_window -// Description: Creates the initial, toplevel window for the -// application. -//////////////////////////////////////////////////////////////////// + +/** + * Creates the initial, toplevel window for the application. + */ static HWND create_toplevel_window(HINSTANCE application) { WNDCLASS wc; @@ -71,7 +67,7 @@ create_toplevel_window(HINSTANCE application) { strm << "PStats " << pstats_port; string window_name = strm.str(); - HWND toplevel_window = + HWND toplevel_window = CreateWindow(toplevel_class_name, window_name.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, application, 0); @@ -79,17 +75,17 @@ create_toplevel_window(HINSTANCE application) { nout << "Could not create toplevel window!\n"; exit(1); } - + return toplevel_window; } -// WinMain() is the correct way to start a Windows-only application, -// but it is sometimes more convenient during development to use -// main() instead, which doesn't squelch the stderr output. +// WinMain() is the correct way to start a Windows-only application, but it is +// sometimes more convenient during development to use main() instead, which +// doesn't squelch the stderr output. #ifndef DEVELOP_WINSTATS -int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) #else int main(int argc, char *argv[]) #endif @@ -103,12 +99,12 @@ int main(int argc, char *argv[]) server = new WinStatsServer; if (!server->listen()) { ostringstream stream; - stream + stream << "Unable to open port " << pstats_port << ". Try specifying a different\n" << "port number using pstats-port in your Config file."; string str = stream.str(); - MessageBox(toplevel_window, str.c_str(), "PStats error", + MessageBox(toplevel_window, str.c_str(), "PStats error", MB_OK | MB_ICONEXCLAMATION); exit(1); } diff --git a/pandatool/src/win-stats/winStats.h b/pandatool/src/win-stats/winStats.h index 7f69abec9a..a1d9ed5e17 100644 --- a/pandatool/src/win-stats/winStats.h +++ b/pandatool/src/win-stats/winStats.h @@ -1,16 +1,15 @@ -// Filename: winStats.h -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStats.h + * @author drose + * @date 2003-12-02 + */ #ifndef WINSTATS_H #define WINSTATS_H @@ -18,4 +17,3 @@ #include "pStatServer.h" #endif - diff --git a/pandatool/src/win-stats/winStatsChartMenu.cxx b/pandatool/src/win-stats/winStatsChartMenu.cxx index 30d78ad593..faeb59d874 100644 --- a/pandatool/src/win-stats/winStatsChartMenu.cxx +++ b/pandatool/src/win-stats/winStatsChartMenu.cxx @@ -1,25 +1,22 @@ -// Filename: winStatsChartMenu.cxx -// Created by: drose (08Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsChartMenu.cxx + * @author drose + * @date 2004-01-08 + */ #include "winStatsChartMenu.h" #include "winStatsMonitor.h" -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsChartMenu:: WinStatsChartMenu(WinStatsMonitor *monitor, int thread_index) : _monitor(monitor), @@ -29,31 +26,24 @@ WinStatsChartMenu(WinStatsMonitor *monitor, int thread_index) : do_update(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsChartMenu:: ~WinStatsChartMenu() { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::get_menu_handle -// Access: Public -// Description: Returns the Windows menu handle for this particular -// menu. -//////////////////////////////////////////////////////////////////// +/** + * Returns the Windows menu handle for this particular menu. + */ HMENU WinStatsChartMenu:: get_menu_handle() { return _menu; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::add_to_menu_bar -// Access: Public -// Description: Adds the menu to the end of the indicated menu bar. -//////////////////////////////////////////////////////////////////// +/** + * Adds the menu to the end of the indicated menu bar. + */ void WinStatsChartMenu:: add_to_menu_bar(HMENU menu_bar, int before_menu_id) { const PStatClientData *client_data = _monitor->get_client_data(); @@ -69,20 +59,17 @@ add_to_menu_bar(HMENU menu_bar, int before_menu_id) { memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; - mii.fType = MFT_STRING; - mii.hSubMenu = _menu; - mii.dwTypeData = (char *)thread_name.c_str(); + mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; + mii.fType = MFT_STRING; + mii.hSubMenu = _menu; + mii.dwTypeData = (char *)thread_name.c_str(); InsertMenuItem(menu_bar, before_menu_id, FALSE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::check_update -// Access: Public -// Description: Checks to see if the menu needs to be updated -// (e.g. because of new data from the client), and -// updates it if necessary. -//////////////////////////////////////////////////////////////////// +/** + * Checks to see if the menu needs to be updated (e.g. because of new data + * from the client), and updates it if necessary. + */ void WinStatsChartMenu:: check_update() { PStatView &view = _monitor->get_view(_thread_index); @@ -90,13 +77,10 @@ check_update() { do_update(); } } - -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::do_update -// Access: Public -// Description: Unconditionally updates the menu with the latest data -// from the client. -//////////////////////////////////////////////////////////////////// + +/** + * Unconditionally updates the menu with the latest data from the client. + */ void WinStatsChartMenu:: do_update() { PStatView &view = _monitor->get_view(_thread_index); @@ -123,14 +107,14 @@ do_update() { int num_toplevel_collectors = client_data->get_num_toplevel_collectors(); for (int tc = 0; tc < num_toplevel_collectors; tc++) { int collector = client_data->get_toplevel_collector(tc); - if (client_data->has_collector(collector) && + if (client_data->has_collector(collector) && client_data->get_collector_has_level(collector, _thread_index)) { - // We put a separator between the above frame collector and the - // first level collector. + // We put a separator between the above frame collector and the first + // level collector. if (needs_separator) { - mii.fMask = MIIM_FTYPE; - mii.fType = MFT_SEPARATOR; + mii.fMask = MIIM_FTYPE; + mii.fType = MFT_SEPARATOR; InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii); needs_separator = false; @@ -142,26 +126,24 @@ do_update() { } // Also a menu item for a piano roll (following a separator). - mii.fMask = MIIM_FTYPE; - mii.fType = MFT_SEPARATOR; + mii.fMask = MIIM_FTYPE; + mii.fType = MFT_SEPARATOR; InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii); WinStatsMonitor::MenuDef menu_def(_thread_index, -1, false); int menu_id = _monitor->get_menu_id(menu_def); - mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; - mii.fType = MFT_STRING; + mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; + mii.fType = MFT_STRING; mii.wID = menu_id; mii.dwTypeData = "Piano Roll"; InsertMenuItem(_menu, GetMenuItemCount(_menu), TRUE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsChartMenu::add_view -// Access: Private -// Description: Adds a new entry or entries to the menu for the -// indicated view and its children. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new entry or entries to the menu for the indicated view and its + * children. + */ void WinStatsChartMenu:: add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { int collector = view_level->get_collector(); @@ -176,10 +158,10 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); - mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; - mii.fType = MFT_STRING; + mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; + mii.fType = MFT_STRING; mii.wID = menu_id; - mii.dwTypeData = (char *)collector_name.c_str(); + mii.dwTypeData = (char *)collector_name.c_str(); InsertMenuItem(parent_menu, GetMenuItemCount(parent_menu), TRUE, &mii); int num_children = view_level->get_num_children(); @@ -190,14 +172,14 @@ add_view(HMENU parent_menu, const PStatViewLevel *view_level, bool show_level) { string submenu_name = collector_name + " components"; mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; - mii.fType = MFT_STRING; + mii.fType = MFT_STRING; mii.hSubMenu = submenu; - mii.dwTypeData = (char *)submenu_name.c_str(); + mii.dwTypeData = (char *)submenu_name.c_str(); InsertMenuItem(parent_menu, GetMenuItemCount(parent_menu), TRUE, &mii); - // Reverse the order since the menus are listed from the top down; - // we want to be visually consistent with the graphs, which list - // these labels from the bottom up. + // Reverse the order since the menus are listed from the top down; we want + // to be visually consistent with the graphs, which list these labels from + // the bottom up. for (int c = num_children - 1; c >= 0; c--) { add_view(submenu, view_level->get_child(c), show_level); } diff --git a/pandatool/src/win-stats/winStatsChartMenu.h b/pandatool/src/win-stats/winStatsChartMenu.h index c7dbf7d8a8..cc372f0a80 100644 --- a/pandatool/src/win-stats/winStatsChartMenu.h +++ b/pandatool/src/win-stats/winStatsChartMenu.h @@ -1,16 +1,15 @@ -// Filename: winStatsChartMenu.h -// Created by: drose (08Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsChartMenu.h + * @author drose + * @date 2004-01-08 + */ #ifndef WINSTATSCHARTMENU_H #define WINSTATSCHARTMENU_H @@ -23,11 +22,9 @@ class WinStatsMonitor; class PStatView; class PStatViewLevel; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsChartMenu -// Description : A pulldown menu of charts available for a particular -// thread. -//////////////////////////////////////////////////////////////////// +/** + * A pulldown menu of charts available for a particular thread. + */ class WinStatsChartMenu { public: WinStatsChartMenu(WinStatsMonitor *monitor, int thread_index); @@ -51,4 +48,3 @@ private: }; #endif - diff --git a/pandatool/src/win-stats/winStatsGraph.cxx b/pandatool/src/win-stats/winStatsGraph.cxx index 203c4011a6..ff7a831d58 100644 --- a/pandatool/src/win-stats/winStatsGraph.cxx +++ b/pandatool/src/win-stats/winStatsGraph.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsGraph.cxx -// Created by: drose (03Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsGraph.cxx + * @author drose + * @date 2003-12-03 + */ #include "winStatsGraph.h" #include "winStatsMonitor.h" @@ -19,14 +18,12 @@ bool WinStatsGraph::_graph_window_class_registered = false; const char * const WinStatsGraph::_graph_window_class_name = "graph"; -DWORD WinStatsGraph::graph_window_style = +DWORD WinStatsGraph::graph_window_style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_VISIBLE; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsGraph:: WinStatsGraph(WinStatsMonitor *monitor) : _monitor(monitor) @@ -57,11 +54,9 @@ WinStatsGraph(WinStatsMonitor *monitor) : _pause = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsGraph:: ~WinStatsGraph() { _monitor = (WinStatsMonitor *)NULL; @@ -70,7 +65,7 @@ WinStatsGraph:: DeleteObject(_dark_pen); DeleteObject(_light_pen); DeleteObject(_user_guide_bar_pen); - + Brushes::iterator bi; for (bi = _brushes.begin(); bi != _brushes.end(); ++bi) { HBRUSH brush = (*bi).second; @@ -88,105 +83,80 @@ WinStatsGraph:: } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + */ void WinStatsGraph:: new_collector(int new_collector) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::new_data -// Access: Public, Virtual -// Description: Called whenever new data arrives. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever new data arrives. + */ void WinStatsGraph:: new_data(int thread_index, int frame_number) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void WinStatsGraph:: force_redraw() { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void WinStatsGraph:: changed_graph_size(int graph_xsize, int graph_ysize) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void WinStatsGraph:: set_time_units(int unit_mask) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speed for the graph to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speed for the graph to the indicated value. + */ void WinStatsGraph:: set_scroll_speed(double scroll_speed) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::set_pause -// Access: Public -// Description: Changes the pause flag for the graph. When this flag -// is true, the graph does not update in response to new -// data. -//////////////////////////////////////////////////////////////////// +/** + * Changes the pause flag for the graph. When this flag is true, the graph + * does not update in response to new data. + */ void WinStatsGraph:: set_pause(bool pause) { _pause = pause; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::user_guide_bars_changed -// Access: Public -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void WinStatsGraph:: user_guide_bars_changed() { InvalidateRect(_window, NULL, TRUE); InvalidateRect(_graph_window, NULL, TRUE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void WinStatsGraph:: clicked_label(int collector_index) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::close -// Access: Protected -// Description: Should be called when the user closes the associated -// window. This tells the monitor to remove the graph. -//////////////////////////////////////////////////////////////////// +/** + * Should be called when the user closes the associated window. This tells + * the monitor to remove the graph. + */ void WinStatsGraph:: close() { WinStatsMonitor *monitor = _monitor; @@ -196,45 +166,36 @@ close() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::setup_label_stack -// Access: Protected -// Description: Sets up the label stack on the left edge of the -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the label stack on the left edge of the frame. + */ void WinStatsGraph:: setup_label_stack() { _label_stack.setup(_window); move_label_stack(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::move_label_stack -// Access: Protected -// Description: Repositions the label stack if its coordinates or -// size have changed. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the label stack if its coordinates or size have changed. + */ void WinStatsGraph:: move_label_stack() { if (_label_stack.is_setup()) { RECT rect; GetClientRect(_window, &rect); - + rect.left += 8; rect.right = _left_margin - 8; rect.bottom -= _bottom_margin; - - _label_stack.set_pos(rect.left, rect.top, + + _label_stack.set_pos(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::get_collector_brush -// Access: Protected -// Description: Returns a brush suitable for drawing in the indicated -// collector's color. -//////////////////////////////////////////////////////////////////// +/** + * Returns a brush suitable for drawing in the indicated collector's color. + */ HBRUSH WinStatsGraph:: get_collector_brush(int collector_index) { Brushes::iterator bi; @@ -254,13 +215,10 @@ get_collector_brush(int collector_index) { return brush; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::window_proc -// Access: Protected -// Description: This window_proc should be called up to by the -// derived classes for any messages that are not -// specifically handled by the derived class. -//////////////////////////////////////////////////////////////////// +/** + * This window_proc should be called up to by the derived classes for any + * messages that are not specifically handled by the derived class. + */ LONG WinStatsGraph:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -283,8 +241,8 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_SETCURSOR: { - // Why is it so hard to ask for the cursor position within the - // window's client area? + // Why is it so hard to ask for the cursor position within the window's + // client area? POINT point; GetCursorPos(&point); WINDOWINFO winfo; @@ -323,7 +281,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } return 0; - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: if (_drag_mode == DM_left_margin) { PN_int16 x = LOWORD(lparam); _left_margin += (x - _drag_start_x); @@ -388,11 +346,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::graph_window_proc -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsGraph:: graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -402,8 +358,8 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { break; case WM_LBUTTONDOWN: - // Vector any uncaught WM_LBUTTONDOWN into the main window, so we - // can drag margins, etc. + // Vector any uncaught WM_LBUTTONDOWN into the main window, so we can drag + // margins, etc. if (_potential_drag_mode != DM_none) { PN_int16 x = LOWORD(lparam) + _graph_left; PN_int16 y = HIWORD(lparam) + _graph_top; @@ -422,7 +378,7 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); - BitBlt(hdc, 0, 0, + BitBlt(hdc, 0, 0, _bitmap_xsize, _bitmap_ysize, _bitmap_dc, 0, 0, SRCCOPY); @@ -440,37 +396,28 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::additional_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the window (the outer window, not the -// graph window). -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the window (the outer window, + * not the graph window). + */ void WinStatsGraph:: additional_window_paint(HDC hdc) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the graph window. -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the graph window. + */ void WinStatsGraph:: additional_graph_window_paint(HDC hdc) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the window's -// client area, look for draggable things the mouse -// might be hovering over and return the appropriate -// DragMode enum or DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the window's client area, look for + * draggable things the mouse might be hovering over and return the + * appropriate DragMode enum or DM_none if nothing is indicated. + */ WinStatsGraph::DragMode WinStatsGraph:: consider_drag_start(int mouse_x, int mouse_y, int width, int height) { if (mouse_x >= _left_margin - 2 && mouse_x <= _left_margin + 2) { @@ -482,24 +429,19 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { return DM_none; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::set_drag_mode -// Access: Protected, Virtual -// Description: This should be called whenever the drag mode needs to -// change state. It provides hooks for a derived class -// to do something special. -//////////////////////////////////////////////////////////////////// +/** + * This should be called whenever the drag mode needs to change state. It + * provides hooks for a derived class to do something special. + */ void WinStatsGraph:: set_drag_mode(WinStatsGraph::DragMode drag_mode) { _drag_mode = drag_mode; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::move_graph_window -// Access: Protected, Virtual -// Description: Repositions the graph child window within the parent -// window according to the _margin variables. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the graph child window within the parent window according to + * the _margin variables. + */ void WinStatsGraph:: move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysize) { if (_graph_window == 0) { @@ -509,7 +451,7 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz _graph_left = graph_left; _graph_top = graph_top; - SetWindowPos(_graph_window, 0, + SetWindowPos(_graph_window, 0, _graph_left, _graph_top, graph_xsize, graph_ysize, SWP_NOZORDER | SWP_SHOWWINDOW); @@ -519,11 +461,9 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::setup_bitmap -// Access: Private -// Description: Sets up a backing-store bitmap of the indicated size. -//////////////////////////////////////////////////////////////////// +/** + * Sets up a backing-store bitmap of the indicated size. + */ void WinStatsGraph:: setup_bitmap(int xsize, int ysize) { release_bitmap(); @@ -541,12 +481,9 @@ setup_bitmap(int xsize, int ysize) { ReleaseDC(_window, hdc); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::release_bitmap -// Access: Private -// Description: Frees the backing-store bitmap created by -// setup_bitmap(). -//////////////////////////////////////////////////////////////////// +/** + * Frees the backing-store bitmap created by setup_bitmap(). + */ void WinStatsGraph:: release_bitmap() { if (_bitmap) { @@ -559,11 +496,9 @@ release_bitmap() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::create_graph_window -// Access: Private -// Description: Creates the child window that actually holds the graph. -//////////////////////////////////////////////////////////////////// +/** + * Creates the child window that actually holds the graph. + */ void WinStatsGraph:: create_graph_window() { if (_graph_window) { @@ -576,7 +511,7 @@ create_graph_window() { string window_title = "graph"; DWORD window_style = WS_CHILD | WS_CLIPSIBLINGS; - _graph_window = + _graph_window = CreateWindow(_graph_window_class_name, window_title.c_str(), window_style, 0, 0, 0, 0, _window, NULL, application, 0); @@ -588,12 +523,10 @@ create_graph_window() { SetWindowLongPtr(_graph_window, 0, (LONG_PTR)this); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::register_graph_window_class -// Access: Private, Static -// Description: Registers the window class for the stripChart window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the stripChart window, if it has not already + * been registered. + */ void WinStatsGraph:: register_graph_window_class(HINSTANCE application) { if (_graph_window_class_registered) { @@ -613,7 +546,7 @@ register_graph_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsGraph *); - + if (!RegisterClass(&wc)) { nout << "Could not register graph window class!\n"; exit(1); @@ -622,11 +555,9 @@ register_graph_window_class(HINSTANCE application) { _graph_window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsGraph::static_graph_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsGraph:: static_graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsGraph *self = (WinStatsGraph *)GetWindowLongPtr(hwnd, 0); diff --git a/pandatool/src/win-stats/winStatsGraph.h b/pandatool/src/win-stats/winStatsGraph.h index 01d0d50f6c..a4f9a61467 100644 --- a/pandatool/src/win-stats/winStatsGraph.h +++ b/pandatool/src/win-stats/winStatsGraph.h @@ -1,16 +1,15 @@ -// Filename: winStatsGraph.h -// Created by: drose (03Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsGraph.h + * @author drose + * @date 2003-12-03 + */ #ifndef WINSTATSGRAPH_H #define WINSTATSGRAPH_H @@ -23,12 +22,10 @@ class WinStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsGraph -// Description : This is just an abstract base class to provide a -// common pointer type for the various kinds of graphs -// that may be created for a WinStatsMonitor. -//////////////////////////////////////////////////////////////////// +/** + * This is just an abstract base class to provide a common pointer type for + * the various kinds of graphs that may be created for a WinStatsMonitor. + */ class WinStatsGraph { public: // What is the user adjusting by dragging the mouse in a window? @@ -71,7 +68,7 @@ protected: virtual void additional_window_paint(HDC hdc); virtual void additional_graph_window_paint(HDC hdc); - virtual DragMode consider_drag_start(int mouse_x, int mouse_y, + virtual DragMode consider_drag_start(int mouse_x, int mouse_y, int width, int height); virtual void set_drag_mode(DragMode drag_mode); @@ -130,4 +127,3 @@ protected: }; #endif - diff --git a/pandatool/src/win-stats/winStatsLabel.cxx b/pandatool/src/win-stats/winStatsLabel.cxx index 857e4580ad..3886cb8e15 100644 --- a/pandatool/src/win-stats/winStatsLabel.cxx +++ b/pandatool/src/win-stats/winStatsLabel.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsLabel.cxx -// Created by: drose (07Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsLabel.cxx + * @author drose + * @date 2004-01-07 + */ #include "winStatsLabel.h" #include "winStatsMonitor.h" @@ -24,11 +23,9 @@ int WinStatsLabel::_bottom_margin = 2; bool WinStatsLabel::_window_class_registered = false; const char * const WinStatsLabel::_window_class_name = "label"; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsLabel:: WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph, int thread_index, int collector_index, bool use_fullname) : @@ -74,11 +71,9 @@ WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph, _mouse_within = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsLabel:: ~WinStatsLabel() { if (_window) { @@ -88,11 +83,9 @@ WinStatsLabel:: DeleteObject(_bg_brush); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::setup -// Access: Public -// Description: Creates the actual window. -//////////////////////////////////////////////////////////////////// +/** + * Creates the actual window. + */ void WinStatsLabel:: setup(HWND parent_window) { if (_window) { @@ -103,7 +96,7 @@ setup(HWND parent_window) { create_window(parent_window); HDC hdc = GetDC(_window); - HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); + HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); SelectObject(hdc, hfnt); SIZE size; @@ -114,88 +107,70 @@ setup(HWND parent_window) { ReleaseDC(_window, hdc); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::set_pos -// Access: Public -// Description: Sets the position of the label on its parent. The -// position describes the lower-left corner of the -// rectangle, not the upper-left. -//////////////////////////////////////////////////////////////////// +/** + * Sets the position of the label on its parent. The position describes the + * lower-left corner of the rectangle, not the upper-left. + */ void WinStatsLabel:: set_pos(int x, int y, int width) { _x = x; _y = y; _width = width; - SetWindowPos(_window, 0, x, y - _height, _width, _height, + SetWindowPos(_window, 0, x, y - _height, _width, _height, SWP_NOZORDER | SWP_SHOWWINDOW); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_x -// Access: Public -// Description: Returns the x position of the label on its parent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x position of the label on its parent. + */ int WinStatsLabel:: get_x() const { return _x; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_y -// Access: Public -// Description: Returns the y position of the label on its parent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y position of the label on its parent. + */ int WinStatsLabel:: get_y() const { return _y; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_width -// Access: Public -// Description: Returns the width of the label as we requested it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the label as we requested it. + */ int WinStatsLabel:: get_width() const { return _width; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_height -// Access: Public -// Description: Returns the height of the label as we requested it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the label as we requested it. + */ int WinStatsLabel:: get_height() const { return _height; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_ideal_width -// Access: Public -// Description: Returns the width the label would really prefer to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width the label would really prefer to be. + */ int WinStatsLabel:: get_ideal_width() const { return _ideal_width; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_collector_index -// Access: Public -// Description: Returns the collector this label represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector this label represents. + */ int WinStatsLabel:: get_collector_index() const { return _collector_index; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::set_highlight -// Access: Public -// Description: Enables or disables the visual highlight for this -// label. -//////////////////////////////////////////////////////////////////// +/** + * Enables or disables the visual highlight for this label. + */ void WinStatsLabel:: set_highlight(bool highlight) { if (_highlight != highlight) { @@ -204,23 +179,17 @@ set_highlight(bool highlight) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::get_highlight -// Access: Public -// Description: Returns true if the visual highlight for this -// label is enabled. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the visual highlight for this label is enabled. + */ bool WinStatsLabel:: get_highlight() const { return _highlight; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::set_mouse_within -// Access: Private -// Description: Used internally to indicate whether the mouse is -// within the label's window. -//////////////////////////////////////////////////////////////////// +/** + * Used internally to indicate whether the mouse is within the label's window. + */ void WinStatsLabel:: set_mouse_within(bool mouse_within) { if (_mouse_within != mouse_within) { @@ -229,11 +198,9 @@ set_mouse_within(bool mouse_within) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::create_window -// Access: Private -// Description: Creates the window for this label. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this label. + */ void WinStatsLabel:: create_window(HWND parent_window) { if (_window) { @@ -243,7 +210,7 @@ create_window(HWND parent_window) { HINSTANCE application = GetModuleHandle(NULL); register_window_class(application); - _window = + _window = CreateWindow(_window_class_name, _text.c_str(), WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0, parent_window, NULL, application, 0); @@ -255,12 +222,10 @@ create_window(HWND parent_window) { SetWindowLongPtr(_window, 0, (LONG_PTR)this); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::register_window_class -// Access: Private, Static -// Description: Registers the window class for the label window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the label window, if it has not already been + * registered. + */ void WinStatsLabel:: register_window_class(HINSTANCE application) { if (_window_class_registered) { @@ -280,7 +245,7 @@ register_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsLabel *); - + if (!RegisterClass(&wc)) { nout << "Could not register Label window class!\n"; exit(1); @@ -289,11 +254,9 @@ register_window_class(HINSTANCE application) { _window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::static_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsLabel:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabel *self = (WinStatsLabel *)GetWindowLongPtr(hwnd, 0); @@ -304,25 +267,22 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabel::window_proc -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsLabel:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_LBUTTONDBLCLK: _graph->clicked_label(_collector_index); return 0; - - case WM_MOUSEMOVE: + + case WM_MOUSEMOVE: { // When the mouse enters the label area, highlight the label. set_mouse_within(true); - - // Now we want to get a WM_MOUSELEAVE when the mouse leaves the - // label. + + // Now we want to get a WM_MOUSELEAVE when the mouse leaves the label. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, @@ -333,7 +293,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_MOUSELEAVE: + case WM_MOUSELEAVE: set_mouse_within(false); break; @@ -349,7 +309,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { FrameRect(hdc, &rect, _highlight_brush); } - HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); + HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); SelectObject(hdc, hfnt); SetTextAlign(hdc, TA_RIGHT | TA_TOP); @@ -358,7 +318,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { SetTextColor(hdc, _fg_color); TextOut(hdc, _width - _right_margin, _top_margin, - _text.data(), _text.length()); + _text.data(), _text.length()); EndPaint(hwnd, &ps); return 0; } diff --git a/pandatool/src/win-stats/winStatsLabel.h b/pandatool/src/win-stats/winStatsLabel.h index 4e8081f22e..8c98f09f12 100644 --- a/pandatool/src/win-stats/winStatsLabel.h +++ b/pandatool/src/win-stats/winStatsLabel.h @@ -1,16 +1,15 @@ -// Filename: winStatsLabel.h -// Created by: drose (07Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsLabel.h + * @author drose + * @date 2004-01-07 + */ #ifndef WINSTATSLABEL_H #define WINSTATSLABEL_H @@ -22,13 +21,11 @@ class WinStatsMonitor; class WinStatsGraph; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsLabel -// Description : A text label that will draw in color appropriate for -// a particular collector. It also responds when the -// user double-clicks on it. This is handy for putting -// colored labels on strip charts. -//////////////////////////////////////////////////////////////////// +/** + * A text label that will draw in color appropriate for a particular + * collector. It also responds when the user double-clicks on it. This is + * handy for putting colored labels on strip charts. + */ class WinStatsLabel { public: WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph, @@ -85,4 +82,3 @@ private: }; #endif - diff --git a/pandatool/src/win-stats/winStatsLabelStack.cxx b/pandatool/src/win-stats/winStatsLabelStack.cxx index b912487e2e..c3d8404aa2 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.cxx +++ b/pandatool/src/win-stats/winStatsLabelStack.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsLabelStack.cxx -// Created by: drose (07Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsLabelStack.cxx + * @author drose + * @date 2004-01-07 + */ #include "winStatsLabelStack.h" #include "winStatsLabel.h" @@ -19,11 +18,9 @@ bool WinStatsLabelStack::_window_class_registered = false; const char * const WinStatsLabelStack::_window_class_name = "stack"; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsLabelStack:: WinStatsLabelStack() { _x = 0; @@ -35,11 +32,9 @@ WinStatsLabelStack() { _highlight_label = -1; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsLabelStack:: ~WinStatsLabelStack() { clear_labels(); @@ -49,11 +44,9 @@ WinStatsLabelStack:: } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::setup -// Access: Public -// Description: Creates the actual window object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the actual window object. + */ void WinStatsLabelStack:: setup(HWND parent_window) { if (_window) { @@ -72,31 +65,26 @@ setup(HWND parent_window) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::is_setup -// Access: Public -// Description: Returns true if the label stack has been set up, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the label stack has been set up, false otherwise. + */ bool WinStatsLabelStack:: is_setup() const { return (_window != 0); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::set_pos -// Access: Public -// Description: Sets the position and size of the label stack on its parent. -//////////////////////////////////////////////////////////////////// +/** + * Sets the position and size of the label stack on its parent. + */ void WinStatsLabelStack:: set_pos(int x, int y, int width, int height) { _x = x; _y = y; _width = width; _height = height; - SetWindowPos(_window, 0, x, y, _width, _height, + SetWindowPos(_window, 0, x, y, _width, _height, SWP_NOZORDER | SWP_SHOWWINDOW); - + Labels::iterator li; int yp = height; for (li = _labels.begin(); li != _labels.end(); ++li) { @@ -106,96 +94,77 @@ set_pos(int x, int y, int width, int height) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_x -// Access: Public -// Description: Returns the x position of the stack on its parent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the x position of the stack on its parent. + */ int WinStatsLabelStack:: get_x() const { return _x; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_y -// Access: Public -// Description: Returns the y position of the stack on its parent. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y position of the stack on its parent. + */ int WinStatsLabelStack:: get_y() const { return _y; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_width -// Access: Public -// Description: Returns the width of the stack as we requested it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width of the stack as we requested it. + */ int WinStatsLabelStack:: get_width() const { return _width; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_height -// Access: Public -// Description: Returns the height of the stack as we requested it. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the stack as we requested it. + */ int WinStatsLabelStack:: get_height() const { return _height; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_ideal_width -// Access: Public -// Description: Returns the width the stack would really prefer to be. -//////////////////////////////////////////////////////////////////// +/** + * Returns the width the stack would really prefer to be. + */ int WinStatsLabelStack:: get_ideal_width() const { return _ideal_width; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_label_y -// Access: Public -// Description: Returns the y position of the indicated label's bottom -// edge, relative to the label stack's parent window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the y position of the indicated label's bottom edge, relative to + * the label stack's parent window. + */ int WinStatsLabelStack:: get_label_y(int label_index) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), 0); return _labels[label_index]->get_y() + get_y(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_label_height -// Access: Public -// Description: Returns the height of the indicated label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the height of the indicated label. + */ int WinStatsLabelStack:: get_label_height(int label_index) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), 0); return _labels[label_index]->get_height(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_label_collector_index -// Access: Public -// Description: Returns the collector index associated with the -// indicated label. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index associated with the indicated label. + */ int WinStatsLabelStack:: get_label_collector_index(int label_index) const { nassertr(label_index >= 0 && label_index < (int)_labels.size(), -1); return _labels[label_index]->get_collector_index(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::clear_labels -// Access: Public -// Description: Removes the set of labels and starts a new set. -//////////////////////////////////////////////////////////////////// +/** + * Removes the set of labels and starts a new set. + */ void WinStatsLabelStack:: clear_labels() { Labels::iterator li; @@ -206,12 +175,9 @@ clear_labels() { _ideal_width = 0; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::add_label -// Access: Public -// Description: Adds a new label to the top of the stack; returns the -// new label index. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new label to the top of the stack; returns the new label index. + */ int WinStatsLabelStack:: add_label(WinStatsMonitor *monitor, WinStatsGraph *graph, int thread_index, int collector_index, bool use_fullname) { @@ -220,7 +186,7 @@ add_label(WinStatsMonitor *monitor, WinStatsGraph *graph, WinStatsLabel *top_label = _labels.back(); yp = top_label->get_y() - top_label->get_height(); } - WinStatsLabel *label = + WinStatsLabel *label = new WinStatsLabel(monitor, graph, thread_index, collector_index, use_fullname); if (_window) { label->setup(_window); @@ -234,24 +200,19 @@ add_label(WinStatsMonitor *monitor, WinStatsGraph *graph, return label_index; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::get_num_labels -// Access: Public -// Description: Returns the number of labels in the stack. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of labels in the stack. + */ int WinStatsLabelStack:: get_num_labels() const { return _labels.size(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::highlight_label -// Access: Public -// Description: Draws a highlight around the label representing the -// indicated collector, and removes the highlight from -// any other label. Specify -1 to remove the highlight -// from all labels. -//////////////////////////////////////////////////////////////////// +/** + * Draws a highlight around the label representing the indicated collector, + * and removes the highlight from any other label. Specify -1 to remove the + * highlight from all labels. + */ void WinStatsLabelStack:: highlight_label(int collector_index) { if (_highlight_label != collector_index) { @@ -265,11 +226,9 @@ highlight_label(int collector_index) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::create_window -// Access: Private -// Description: Creates the window for this stack. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this stack. + */ void WinStatsLabelStack:: create_window(HWND parent_window) { if (_window) { @@ -279,7 +238,7 @@ create_window(HWND parent_window) { HINSTANCE application = GetModuleHandle(NULL); register_window_class(application); - _window = + _window = CreateWindow(_window_class_name, "label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 0, 0, parent_window, NULL, application, 0); @@ -291,12 +250,10 @@ create_window(HWND parent_window) { SetWindowLongPtr(_window, 0, (LONG_PTR)this); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::register_window_class -// Access: Private, Static -// Description: Registers the window class for the label window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the label window, if it has not already been + * registered. + */ void WinStatsLabelStack:: register_window_class(HINSTANCE application) { if (_window_class_registered) { @@ -315,7 +272,7 @@ register_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsLabelStack *); - + if (!RegisterClass(&wc)) { nout << "Could not register Label Stack window class!\n"; exit(1); @@ -324,11 +281,9 @@ register_window_class(HINSTANCE application) { _window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::static_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsLabelStack:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsLabelStack *self = (WinStatsLabelStack *)GetWindowLongPtr(hwnd, 0); @@ -339,11 +294,9 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsLabelStack::window_proc -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsLabelStack:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { diff --git a/pandatool/src/win-stats/winStatsLabelStack.h b/pandatool/src/win-stats/winStatsLabelStack.h index e4b29ccf44..afb8ecf6c7 100644 --- a/pandatool/src/win-stats/winStatsLabelStack.h +++ b/pandatool/src/win-stats/winStatsLabelStack.h @@ -1,16 +1,15 @@ -// Filename: winStatsLabelStack.h -// Created by: drose (07Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsLabelStack.h + * @author drose + * @date 2004-01-07 + */ #ifndef WINSTATSLABELSTACK_H #define WINSTATSLABELSTACK_H @@ -24,11 +23,9 @@ class WinStatsLabel; class WinStatsMonitor; class WinStatsGraph; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsLabelStack -// Description : A window that contains a stack of labels from bottom -// to top. -//////////////////////////////////////////////////////////////////// +/** + * A window that contains a stack of labels from bottom to top. + */ class WinStatsLabelStack { public: WinStatsLabelStack(); @@ -78,4 +75,3 @@ private: }; #endif - diff --git a/pandatool/src/win-stats/winStatsMenuId.h b/pandatool/src/win-stats/winStatsMenuId.h index 12f48639ce..c06169a0fc 100644 --- a/pandatool/src/win-stats/winStatsMenuId.h +++ b/pandatool/src/win-stats/winStatsMenuId.h @@ -1,27 +1,25 @@ -// Filename: winStatsMenuId.h -// Created by: drose (11Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsMenuId.h + * @author drose + * @date 2004-01-11 + */ #ifndef WINSTATSMENUID_H #define WINSTATSMENUID_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Enum : WinStatsMenuId -// Description : The enumerated values here are used for menu ID's for -// the various pulldown menus in the application. -//////////////////////////////////////////////////////////////////// +/** + * The enumerated values here are used for menu ID's for the various pulldown + * menus in the application. + */ enum WinStatsMenuId { MI_none, MI_time_ms, @@ -34,10 +32,9 @@ enum WinStatsMenuId { MI_speed_12, MI_pause, - // This one is last and represents the beginning of the range for - // the various "new chart" menu options. + // This one is last and represents the beginning of the range for the + // various "new chart" menu options. MI_new_chart }; #endif - diff --git a/pandatool/src/win-stats/winStatsMonitor.I b/pandatool/src/win-stats/winStatsMonitor.I index d8ddbbe4bc..405f0a39f5 100644 --- a/pandatool/src/win-stats/winStatsMonitor.I +++ b/pandatool/src/win-stats/winStatsMonitor.I @@ -1,23 +1,19 @@ -// Filename: winStatsMonitor.I -// Created by: drose (09Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsMonitor.I + * @author drose + * @date 2004-01-09 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::MenuDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsMonitor::MenuDef:: MenuDef(int thread_index, int collector_index, bool show_level) : _thread_index(thread_index), @@ -26,11 +22,9 @@ MenuDef(int thread_index, int collector_index, bool show_level) : { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::MenuDef::operator < -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool WinStatsMonitor::MenuDef:: operator < (const MenuDef &other) const { if (_thread_index != other._thread_index) { diff --git a/pandatool/src/win-stats/winStatsMonitor.cxx b/pandatool/src/win-stats/winStatsMonitor.cxx index 88b2efa20e..bb412050df 100644 --- a/pandatool/src/win-stats/winStatsMonitor.cxx +++ b/pandatool/src/win-stats/winStatsMonitor.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsMonitor.cxx -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsMonitor.cxx + * @author drose + * @date 2003-12-02 + */ #include "winStatsMonitor.h" #include "winStatsServer.h" @@ -25,11 +24,9 @@ bool WinStatsMonitor::_window_class_registered = false; const char * const WinStatsMonitor::_window_class_name = "monitor"; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsMonitor:: WinStatsMonitor(WinStatsServer *server) : PStatMonitor(server) { _window = 0; @@ -42,11 +39,9 @@ WinStatsMonitor(WinStatsServer *server) : PStatMonitor(server) { _pause = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsMonitor:: ~WinStatsMonitor() { Graphs::iterator gi; @@ -72,63 +67,50 @@ WinStatsMonitor:: #endif } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::get_monitor_name -// Access: Public, Virtual -// Description: Should be redefined to return a descriptive name for -// the type of PStatsMonitor this is. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return a descriptive name for the type of + * PStatsMonitor this is. + */ string WinStatsMonitor:: get_monitor_name() { return "WinStats"; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::initialized -// Access: Public, Virtual -// Description: Called after the monitor has been fully set up. At -// this time, it will have a valid _client_data pointer, -// and things like is_alive() and close() will be -// meaningful. However, we may not yet know who we're -// connected to (is_client_known() may return false), -// and we may not know anything about the threads or -// collectors we're about to get data on. -//////////////////////////////////////////////////////////////////// +/** + * Called after the monitor has been fully set up. At this time, it will have + * a valid _client_data pointer, and things like is_alive() and close() will + * be meaningful. However, we may not yet know who we're connected to + * (is_client_known() may return false), and we may not know anything about + * the threads or collectors we're about to get data on. + */ void WinStatsMonitor:: initialized() { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::got_hello -// Access: Public, Virtual -// Description: Called when the "hello" message has been received -// from the client. At this time, the client's hostname -// and program name will be known. -//////////////////////////////////////////////////////////////////// +/** + * Called when the "hello" message has been received from the client. At this + * time, the client's hostname and program name will be known. + */ void WinStatsMonitor:: got_hello() { create_window(); open_strip_chart(0, 0, false); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::got_bad_version -// Access: Public, Virtual -// Description: Like got_hello(), this is called when the "hello" -// message has been received from the client. At this -// time, the client's hostname and program name will be -// known. However, the client appears to be an -// incompatible version and the connection will be -// terminated; the monitor should issue a message to -// that effect. -//////////////////////////////////////////////////////////////////// +/** + * Like got_hello(), this is called when the "hello" message has been received + * from the client. At this time, the client's hostname and program name will + * be known. However, the client appears to be an incompatible version and + * the connection will be terminated; the monitor should issue a message to + * that effect. + */ void WinStatsMonitor:: got_bad_version(int client_major, int client_minor, int server_major, int server_minor) { ostringstream str; - str << "Unable to honor connection attempt from " - << get_client_progname() << " on " << get_client_hostname() - << ": unsupported PStats version " + str << "Unable to honor connection attempt from " + << get_client_progname() << " on " << get_client_hostname() + << ": unsupported PStats version " << client_major << "." << client_minor; if (server_minor == 0) { @@ -138,23 +120,19 @@ got_bad_version(int client_major, int client_minor, str << " (server understands versions " << server_major << ".0 through " << server_major << "." << server_minor << ")."; } - + string message = str.str(); - MessageBox(NULL, message.c_str(), "Bad version", + MessageBox(NULL, message.c_str(), "Bad version", MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. Generally, the client will -// send all of its collectors over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Collector -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + * Generally, the client will send all of its collectors over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Collector definitions midstream. + */ void WinStatsMonitor:: new_collector(int collector_index) { Graphs::iterator gi; @@ -170,17 +148,13 @@ new_collector(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::new_thread -// Access: Public, Virtual -// Description: Called whenever a new Thread definition is -// received from the client. Generally, the client will -// send all of its threads over shortly after -// connecting, but there's no guarantee that they will -// all be received before the first frames are received. -// The monitor should be prepared to accept new Thread -// definitions midstream. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Thread definition is received from the client. + * Generally, the client will send all of its threads over shortly after + * connecting, but there's no guarantee that they will all be received before + * the first frames are received. The monitor should be prepared to accept + * new Thread definitions midstream. + */ void WinStatsMonitor:: new_thread(int thread_index) { WinStatsChartMenu *chart_menu = new WinStatsChartMenu(this, thread_index); @@ -189,15 +163,12 @@ new_thread(int thread_index) { DrawMenuBar(_window); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no guarantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no guarantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void WinStatsMonitor:: new_data(int thread_index, int frame_number) { Graphs::iterator gi; @@ -208,14 +179,11 @@ new_data(int thread_index, int frame_number) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::lost_connection -// Access: Public, Virtual -// Description: Called whenever the connection to the client has been -// lost. This is a permanent state change. The monitor -// should update its display to represent this, and may -// choose to close down automatically. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever the connection to the client has been lost. This is a + * permanent state change. The monitor should update its display to represent + * this, and may choose to close down automatically. + */ void WinStatsMonitor:: lost_connection() { nout << "Lost connection to " << get_client_hostname() << "\n"; @@ -226,13 +194,10 @@ lost_connection() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::idle -// Access: Public, Virtual -// Description: If has_idle() returns true, this will be called -// periodically to allow the monitor to update its -// display or whatever it needs to do. -//////////////////////////////////////////////////////////////////// +/** + * If has_idle() returns true, this will be called periodically to allow the + * monitor to update its display or whatever it needs to do. + */ void WinStatsMonitor:: idle() { // Check if any of our chart menus need updating. @@ -247,7 +212,7 @@ idle() { if (frame_rate != 0.0f) { char buffer[128]; sprintf(buffer, "%0.1f ms / %0.1f Hz", 1000.0f / frame_rate, frame_rate); - + MENUITEMINFO mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); @@ -258,22 +223,18 @@ idle() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::has_idle -// Access: Public, Virtual -// Description: Should be redefined to return true if you want to -// redefine idle() and expect it to be called. -//////////////////////////////////////////////////////////////////// +/** + * Should be redefined to return true if you want to redefine idle() and + * expect it to be called. + */ bool WinStatsMonitor:: has_idle() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::user_guide_bars_changed -// Access: Public, Virtual -// Description: Called when the user guide bars have been changed. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user guide bars have been changed. + */ void WinStatsMonitor:: user_guide_bars_changed() { Graphs::iterator gi; @@ -283,24 +244,20 @@ user_guide_bars_changed() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::get_window -// Access: Public -// Description: Returns the window handle to the monitor's window. -//////////////////////////////////////////////////////////////////// +/** + * Returns the window handle to the monitor's window. + */ HWND WinStatsMonitor:: get_window() const { return _window; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::open_strip_chart -// Access: Public -// Description: Opens a new strip chart showing the indicated data. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new strip chart showing the indicated data. + */ void WinStatsMonitor:: open_strip_chart(int thread_index, int collector_index, bool show_level) { - WinStatsStripChart *graph = + WinStatsStripChart *graph = new WinStatsStripChart(this, thread_index, collector_index, show_level); add_graph(graph); @@ -309,11 +266,9 @@ open_strip_chart(int thread_index, int collector_index, bool show_level) { graph->set_pause(_pause); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::open_piano_roll -// Access: Public -// Description: Opens a new piano roll showing the indicated data. -//////////////////////////////////////////////////////////////////// +/** + * Opens a new piano roll showing the indicated data. + */ void WinStatsMonitor:: open_piano_roll(int thread_index) { WinStatsPianoRoll *graph = new WinStatsPianoRoll(this, thread_index); @@ -324,13 +279,10 @@ open_piano_roll(int thread_index) { graph->set_pause(_pause); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::lookup_menu -// Access: Public -// Description: Returns the MenuDef properties associated with the -// indicated menu ID. This specifies what we expect to -// do when the given menu has been selected. -//////////////////////////////////////////////////////////////////// +/** + * Returns the MenuDef properties associated with the indicated menu ID. This + * specifies what we expect to do when the given menu has been selected. + */ const WinStatsMonitor::MenuDef &WinStatsMonitor:: lookup_menu(int menu_id) const { static MenuDef invalid(0, 0, false); @@ -339,15 +291,11 @@ lookup_menu(int menu_id) const { return _menu_by_id[menu_index]; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::get_menu_id -// Access: Public -// Description: Returns the menu ID that is reserved for the -// indicated MenuDef properties. If this is the first -// time these particular properties have been requested, -// a new menu ID is returned; otherwise, the existing -// menu ID is returned. -//////////////////////////////////////////////////////////////////// +/** + * Returns the menu ID that is reserved for the indicated MenuDef properties. + * If this is the first time these particular properties have been requested, + * a new menu ID is returned; otherwise, the existing menu ID is returned. + */ int WinStatsMonitor:: get_menu_id(const MenuDef &menu_def) { MenuByDef::iterator mi; @@ -364,14 +312,11 @@ get_menu_id(const MenuDef &menu_def) { return menu_id; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::set_time_units -// Access: Public -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for all graphs to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for all graphs to the indicated mask if + * it is a time-based graph. + */ void WinStatsMonitor:: set_time_units(int unit_mask) { _time_units = unit_mask; @@ -389,22 +334,19 @@ set_time_units(int unit_mask) { mii.cbSize = sizeof(mii); mii.fMask = MIIM_STATE; - mii.fState = ((_time_units & PStatGraph::GBU_ms) != 0) ? + mii.fState = ((_time_units & PStatGraph::GBU_ms) != 0) ? MFS_CHECKED : MFS_UNCHECKED; SetMenuItemInfo(_options_menu, MI_time_ms, FALSE, &mii); - mii.fState = ((_time_units & PStatGraph::GBU_hz) != 0) ? + mii.fState = ((_time_units & PStatGraph::GBU_hz) != 0) ? MFS_CHECKED : MFS_UNCHECKED; SetMenuItemInfo(_options_menu, MI_time_hz, FALSE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speeds for all graphs to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speeds for all graphs to the indicated value. + */ void WinStatsMonitor:: set_scroll_speed(double scroll_speed) { _scroll_speed = scroll_speed; @@ -443,12 +385,9 @@ set_scroll_speed(double scroll_speed) { SetMenuItemInfo(_speed_menu, MI_speed_12, FALSE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::set_pause -// Access: Public -// Description: Called when the user selects a pause on or pause off -// option from the menu. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a pause on or pause off option from the menu. + */ void WinStatsMonitor:: set_pause(bool pause) { _pause = pause; @@ -470,22 +409,17 @@ set_pause(bool pause) { SetMenuItemInfo(_speed_menu, MI_pause, FALSE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::add_graph -// Access: Private -// Description: Adds the newly-created graph to the list of managed -// graphs. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created graph to the list of managed graphs. + */ void WinStatsMonitor:: add_graph(WinStatsGraph *graph) { _graphs.insert(graph); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::remove_graph -// Access: Private -// Description: Deletes the indicated graph. -//////////////////////////////////////////////////////////////////// +/** + * Deletes the indicated graph. + */ void WinStatsMonitor:: remove_graph(WinStatsGraph *graph) { Graphs::iterator gi = _graphs.find(graph); @@ -495,11 +429,9 @@ remove_graph(WinStatsGraph *graph) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::create_window -// Access: Private -// Description: Creates the window for this monitor. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this monitor. + */ void WinStatsMonitor:: create_window() { if (_window) { @@ -521,10 +453,10 @@ create_window() { } _window_title = get_client_progname() + " on " + get_client_hostname(); - DWORD window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | + DWORD window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE; - _window = + _window = CreateWindow(_window_class_name, _window_title.c_str(), window_style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, _menu_bar, application, 0); @@ -535,17 +467,15 @@ create_window() { SetWindowLongPtr(_window, 0, (LONG_PTR)this); - // For some reason, SW_SHOWNORMAL doesn't always work, but - // SW_RESTORE seems to. + // For some reason, SW_SHOWNORMAL doesn't always work, but SW_RESTORE seems + // to. ShowWindow(_window, SW_RESTORE); SetForegroundWindow(_window); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::setup_options_menu -// Access: Private -// Description: Creates the "Options" pulldown menu. -//////////////////////////////////////////////////////////////////// +/** + * Creates the "Options" pulldown menu. + */ void WinStatsMonitor:: setup_options_menu() { _options_menu = CreatePopupMenu(); @@ -555,19 +485,18 @@ setup_options_menu() { mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; - mii.fType = MFT_STRING; + mii.fType = MFT_STRING; mii.hSubMenu = _options_menu; - // One day, when there is more than one option here, we will - // actually present this to the user as the "Options" menu. For - // now, the only option we have is time units. - //mii.dwTypeData = "Options"; - mii.dwTypeData = "Units"; + // One day, when there is more than one option here, we will actually + // present this to the user as the "Options" menu. For now, the only option + // we have is time units. mii.dwTypeData = "Options"; + mii.dwTypeData = "Units"; InsertMenuItem(_menu_bar, GetMenuItemCount(_menu_bar), TRUE, &mii); - + mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; - mii.fType = MFT_STRING | MFT_RADIOCHECK; + mii.fType = MFT_STRING | MFT_RADIOCHECK; mii.hbmpChecked = NULL; mii.hbmpUnchecked = NULL; mii.fState = MFS_UNCHECKED; @@ -582,11 +511,9 @@ setup_options_menu() { set_time_units(PStatGraph::GBU_ms); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::setup_speed_menu -// Access: Private -// Description: Creates the "Speed" pulldown menu. -//////////////////////////////////////////////////////////////////// +/** + * Creates the "Speed" pulldown menu. + */ void WinStatsMonitor:: setup_speed_menu() { _speed_menu = CreatePopupMenu(); @@ -596,14 +523,14 @@ setup_speed_menu() { mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_SUBMENU; - mii.fType = MFT_STRING; + mii.fType = MFT_STRING; mii.hSubMenu = _speed_menu; - mii.dwTypeData = "Speed"; + mii.dwTypeData = "Speed"; InsertMenuItem(_menu_bar, GetMenuItemCount(_menu_bar), TRUE, &mii); - + mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; - mii.fType = MFT_STRING | MFT_RADIOCHECK; + mii.fType = MFT_STRING | MFT_RADIOCHECK; mii.hbmpChecked = NULL; mii.hbmpUnchecked = NULL; mii.fState = MFS_UNCHECKED; @@ -627,12 +554,12 @@ setup_speed_menu() { mii.dwTypeData = "12"; InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii); - mii.fMask = MIIM_FTYPE; - mii.fType = MFT_SEPARATOR; + mii.fMask = MIIM_FTYPE; + mii.fType = MFT_SEPARATOR; InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii); mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_CHECKMARKS | MIIM_STATE; - mii.fType = MFT_STRING; + mii.fType = MFT_STRING; mii.wID = MI_pause; mii.dwTypeData = "pause"; InsertMenuItem(_speed_menu, GetMenuItemCount(_speed_menu), TRUE, &mii); @@ -641,15 +568,12 @@ setup_speed_menu() { set_pause(false); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::setup_frame_rate_label -// Access: Private -// Description: Creates the frame rate label on the right end of the -// menu bar. This is used as a text label to display -// the main thread's frame rate to the user, although it -// is implemented as a right-justified toplevel menu -// item that doesn't open to anything. -//////////////////////////////////////////////////////////////////// +/** + * Creates the frame rate label on the right end of the menu bar. This is + * used as a text label to display the main thread's frame rate to the user, + * although it is implemented as a right-justified toplevel menu item that + * doesn't open to anything. + */ void WinStatsMonitor:: setup_frame_rate_label() { MENUITEMINFO mii; @@ -657,18 +581,16 @@ setup_frame_rate_label() { mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID; - mii.fType = MFT_STRING | MFT_RIGHTJUSTIFY; + mii.fType = MFT_STRING | MFT_RIGHTJUSTIFY; mii.wID = MI_frame_rate_label; - mii.dwTypeData = ""; + mii.dwTypeData = ""; InsertMenuItem(_menu_bar, GetMenuItemCount(_menu_bar), TRUE, &mii); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::register_window_class -// Access: Private, Static -// Description: Registers the window class for the monitor window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the monitor window, if it has not already + * been registered. + */ void WinStatsMonitor:: register_window_class(HINSTANCE application) { if (_window_class_registered) { @@ -688,7 +610,7 @@ register_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsMonitor *); - + if (!RegisterClass(&wc)) { nout << "Could not register monitor window class!\n"; exit(1); @@ -697,11 +619,9 @@ register_window_class(HINSTANCE application) { _window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::static_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsMonitor:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsMonitor *self = (WinStatsMonitor *)GetWindowLongPtr(hwnd, 0); @@ -712,11 +632,9 @@ static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::window_proc -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsMonitor:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -739,11 +657,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return DefWindowProc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsMonitor::handle_menu_command -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void WinStatsMonitor:: handle_menu_command(int menu_id) { switch (menu_id) { diff --git a/pandatool/src/win-stats/winStatsMonitor.h b/pandatool/src/win-stats/winStatsMonitor.h index cc59ba6587..8d4ccf473d 100644 --- a/pandatool/src/win-stats/winStatsMonitor.h +++ b/pandatool/src/win-stats/winStatsMonitor.h @@ -1,16 +1,15 @@ -// Filename: winStatsMonitor.h -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsMonitor.h + * @author drose + * @date 2003-12-02 + */ #ifndef WINSTATSMONITOR_H #define WINSTATSMONITOR_H @@ -29,11 +28,10 @@ class WinStatsServer; class WinStatsChartMenu; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsMonitor -// Description : This class represents a connection to a PStatsClient -// and manages the data exchange with the client. -//////////////////////////////////////////////////////////////////// +/** + * This class represents a connection to a PStatsClient and manages the data + * exchange with the client. + */ class WinStatsMonitor : public PStatMonitor { public: class MenuDef { @@ -74,7 +72,7 @@ public: void set_time_units(int unit_mask); void set_scroll_speed(double scroll_speed); void set_pause(bool pause); - + private: void add_graph(WinStatsGraph *graph); void remove_graph(WinStatsGraph *graph); diff --git a/pandatool/src/win-stats/winStatsPianoRoll.cxx b/pandatool/src/win-stats/winStatsPianoRoll.cxx index 8f0cd70369..6084c91dbb 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.cxx +++ b/pandatool/src/win-stats/winStatsPianoRoll.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsPianoRoll.cxx -// Created by: drose (03Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsPianoRoll.cxx + * @author drose + * @date 2003-12-03 + */ #include "winStatsPianoRoll.h" #include "winStatsMonitor.h" @@ -22,14 +21,12 @@ static const int default_piano_roll_height = 200; bool WinStatsPianoRoll::_window_class_registered = false; const char * const WinStatsPianoRoll::_window_class_name = "piano"; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsPianoRoll:: WinStatsPianoRoll(WinStatsMonitor *monitor, int thread_index) : - PStatPianoRoll(monitor, thread_index, + PStatPianoRoll(monitor, thread_index, default_piano_roll_width, default_piano_roll_height), WinStatsGraph(monitor) @@ -46,24 +43,19 @@ WinStatsPianoRoll(WinStatsMonitor *monitor, int thread_index) : clear_region(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsPianoRoll:: ~WinStatsPianoRoll() { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::idle -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no gurantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no gurantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void WinStatsPianoRoll:: new_data(int thread_index, int frame_number) { if (!_pause) { @@ -71,35 +63,27 @@ new_data(int thread_index, int frame_number) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void WinStatsPianoRoll:: force_redraw() { PStatPianoRoll::force_redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void WinStatsPianoRoll:: changed_graph_size(int graph_xsize, int graph_ysize) { PStatPianoRoll::changed_size(graph_xsize, graph_ysize); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void WinStatsPianoRoll:: set_time_units(int unit_mask) { int old_unit_mask = get_guide_bar_units(); @@ -115,11 +99,9 @@ set_time_units(int unit_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void WinStatsPianoRoll:: clicked_label(int collector_index) { if (collector_index >= 0) { @@ -127,12 +109,10 @@ clicked_label(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::set_horizontal_scale -// Access: Public -// Description: Changes the amount of time the width of the -// horizontal axis represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the amount of time the width of the horizontal axis represents. + * This may force a redraw. + */ void WinStatsPianoRoll:: set_horizontal_scale(double time_width) { PStatPianoRoll::set_horizontal_scale(time_width); @@ -143,23 +123,18 @@ set_horizontal_scale(double time_width) { InvalidateRect(_window, &rect, TRUE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::clear_region -// Access: Protected -// Description: Erases the chart area. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area. + */ void WinStatsPianoRoll:: clear_region() { RECT rect = { 0, 0, get_xsize(), get_ysize() }; FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::begin_draw -// Access: Protected, Virtual -// Description: Erases the chart area in preparation for drawing a -// bunch of bars. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area in preparation for drawing a bunch of bars. + */ void WinStatsPianoRoll:: begin_draw() { clear_region(); @@ -171,18 +146,16 @@ begin_draw() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::draw_bar -// Access: Protected, Virtual -// Description: Draws a single bar on the chart. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single bar on the chart. + */ void WinStatsPianoRoll:: draw_bar(int row, int from_x, int to_x) { if (row >= 0 && row < _label_stack.get_num_labels()) { int y = _label_stack.get_label_y(row) - _graph_top; int height = _label_stack.get_label_height(row); - RECT rect = { + RECT rect = { from_x, y - height + 2, to_x, y - 2, }; @@ -192,22 +165,18 @@ draw_bar(int row, int from_x, int to_x) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::end_draw -// Access: Protected, Virtual -// Description: Called after all the bars have been drawn, this -// triggers a refresh event to draw it to the window. -//////////////////////////////////////////////////////////////////// +/** + * Called after all the bars have been drawn, this triggers a refresh event to + * draw it to the window. + */ void WinStatsPianoRoll:: end_draw() { InvalidateRect(_graph_window, NULL, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::idle -// Access: Protected, Virtual -// Description: Called at the end of the draw cycle. -//////////////////////////////////////////////////////////////////// +/** + * Called at the end of the draw cycle. + */ void WinStatsPianoRoll:: idle() { if (_labels_changed) { @@ -215,11 +184,9 @@ idle() { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::window_proc -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsPianoRoll:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -238,11 +205,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return WinStatsGraph::window_proc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::graph_window_proc -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsPianoRoll:: graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -263,15 +228,15 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: if (_drag_mode == DM_none && _potential_drag_mode == DM_none) { // When the mouse is over a color bar, highlight it. PN_int16 x = LOWORD(lparam); PN_int16 y = HIWORD(lparam); _label_stack.highlight_label(get_collector_under_pixel(x, y)); - // Now we want to get a WM_MOUSELEAVE when the mouse leaves the - // graph window. + // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph + // window. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, @@ -294,8 +259,8 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return 0; } else if (_drag_mode == DM_new_guide_bar) { - // We haven't created the new guide bar yet; we won't until the - // mouse comes within the graph's region. + // We haven't created the new guide bar yet; we won't until the mouse + // comes within the graph's region. PN_int16 x = LOWORD(lparam); if (x >= 0 && x < get_xsize()) { set_drag_mode(DM_guide_bar); @@ -336,8 +301,8 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_LBUTTONDBLCLK: { - // Double-clicking on a color bar in the graph is the same as - // double-clicking on the corresponding label. + // Double-clicking on a color bar in the graph is the same as double- + // clicking on the corresponding label. PN_int16 x = LOWORD(lparam); PN_int16 y = HIWORD(lparam); clicked_label(get_collector_under_pixel(x, y)); @@ -352,18 +317,15 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return WinStatsGraph::graph_window_proc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::additional_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the window (the outer window, not the -// graph window). -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the window (the outer window, + * not the graph window). + */ void WinStatsPianoRoll:: additional_window_paint(HDC hdc) { // Draw in the labels for the guide bars. - HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); + HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); SelectObject(hdc, hfnt); SetTextAlign(hdc, TA_LEFT | TA_BOTTOM); SetBkMode(hdc, TRANSPARENT); @@ -382,14 +344,11 @@ additional_window_paint(HDC hdc) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the window (the outer window, not the -// graph window). -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the window (the outer window, + * not the graph window). + */ void WinStatsPianoRoll:: additional_graph_window_paint(HDC hdc) { int num_user_guide_bars = get_num_user_guide_bars(); @@ -398,14 +357,11 @@ additional_graph_window_paint(HDC hdc) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the window's -// client area, look for draggable things the mouse -// might be hovering over and return the apprioprate -// DragMode enum or DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the window's client area, look for + * draggable things the mouse might be hovering over and return the + * apprioprate DragMode enum or DM_none if nothing is indicated. + */ WinStatsGraph::DragMode WinStatsPianoRoll:: consider_drag_start(int mouse_x, int mouse_y, int width, int height) { if (mouse_y >= _graph_top && mouse_y < _graph_top + get_ysize()) { @@ -421,8 +377,8 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { } else if (mouse_x < _left_margin - 2 || mouse_x > width - _right_margin + 2) { - // The mouse is left or right of the graph; maybe create a new - // guide bar. + // The mouse is left or right of the graph; maybe create a new guide + // bar. return DM_new_guide_bar; } } @@ -430,12 +386,10 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { return WinStatsGraph::consider_drag_start(mouse_x, mouse_y, width, height); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::get_collector_under_pixel -// Access: Private -// Description: Returns the collector index associated with the -// indicated vertical row, or -1. -//////////////////////////////////////////////////////////////////// +/** + * Returns the collector index associated with the indicated vertical row, or + * -1. + */ int WinStatsPianoRoll:: get_collector_under_pixel(int xpoint, int ypoint) { if (_label_stack.get_num_labels() == 0) { @@ -452,16 +406,14 @@ get_collector_under_pixel(int xpoint, int ypoint) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::update_labels -// Access: Private -// Description: Resets the list of labels. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of labels. + */ void WinStatsPianoRoll:: update_labels() { _label_stack.clear_labels(); for (int i = 0; i < get_num_labels(); i++) { - int label_index = + int label_index = _label_stack.add_label(WinStatsGraph::_monitor, this, _thread_index, get_label_collector(i), true); @@ -469,12 +421,9 @@ update_labels() { _labels_changed = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::draw_guide_bar -// Access: Private -// Description: Draws the line for the indicated guide bar on the -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the line for the indicated guide bar on the graph. + */ void WinStatsPianoRoll:: draw_guide_bar(HDC hdc, const PStatGraph::GuideBar &bar) { int x = height_to_pixel(bar._height); @@ -489,7 +438,7 @@ draw_guide_bar(HDC hdc, const PStatGraph::GuideBar &bar) { case GBS_user: SelectObject(hdc, _user_guide_bar_pen); break; - + case GBS_normal: SelectObject(hdc, _dark_pen); break; @@ -499,23 +448,20 @@ draw_guide_bar(HDC hdc, const PStatGraph::GuideBar &bar) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::draw_guide_label -// Access: Private -// Description: Draws the text for the indicated guide bar label at -// the top of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the text for the indicated guide bar label at the top of the graph. + */ void WinStatsPianoRoll:: draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) { switch (bar._style) { case GBS_target: SetTextColor(hdc, _light_color); break; - + case GBS_user: SetTextColor(hdc, _user_guide_bar_color); break; - + case GBS_normal: SetTextColor(hdc, _dark_color); break; @@ -538,15 +484,13 @@ draw_guide_label(HDC hdc, int y, const PStatGraph::GuideBar &bar) { int this_x = _graph_left + x - size.cx / 2; if (x >= 0 && x < get_xsize()) { TextOut(hdc, this_x, y, - label.data(), label.length()); + label.data(), label.length()); } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::create_window -// Access: Private -// Description: Creates the window for this strip chart. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this strip chart. + */ void WinStatsPianoRoll:: create_window() { if (_window) { @@ -556,22 +500,22 @@ create_window() { HINSTANCE application = GetModuleHandle(NULL); register_window_class(application); - const PStatClientData *client_data = + const PStatClientData *client_data = WinStatsGraph::_monitor->get_client_data(); string thread_name = client_data->get_thread_name(_thread_index); string window_title = thread_name + " thread piano roll"; - RECT win_rect = { + RECT win_rect = { 0, 0, - _left_margin + get_xsize() + _right_margin, + _left_margin + get_xsize() + _right_margin, _top_margin + get_ysize() + _bottom_margin - }; - + }; + // compute window size based on desired client area size AdjustWindowRect(&win_rect, graph_window_style, FALSE); - _window = + _window = CreateWindow(_window_class_name, window_title.c_str(), graph_window_style, CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, @@ -586,16 +530,14 @@ create_window() { setup_label_stack(); // Ensure that the window is on top of the stack. - SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, + SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::register_window_class -// Access: Private, Static -// Description: Registers the window class for the pianoRoll window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the pianoRoll window, if it has not already + * been registered. + */ void WinStatsPianoRoll:: register_window_class(HINSTANCE application) { if (_window_class_registered) { @@ -615,7 +557,7 @@ register_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsPianoRoll *); - + if (!RegisterClass(&wc)) { nout << "Could not register PianoRoll window class!\n"; exit(1); @@ -624,11 +566,9 @@ register_window_class(HINSTANCE application) { _window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsPianoRoll::static_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsPianoRoll:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsPianoRoll *self = (WinStatsPianoRoll *)GetWindowLongPtr(hwnd, 0); diff --git a/pandatool/src/win-stats/winStatsPianoRoll.h b/pandatool/src/win-stats/winStatsPianoRoll.h index 266ad4da0d..b0c9410003 100644 --- a/pandatool/src/win-stats/winStatsPianoRoll.h +++ b/pandatool/src/win-stats/winStatsPianoRoll.h @@ -1,16 +1,15 @@ -// Filename: winStatsPianoRoll.h -// Created by: drose (12Jan04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsPianoRoll.h + * @author drose + * @date 2004-01-12 + */ #ifndef WINSTATSPIANOROLL_H #define WINSTATSPIANOROLL_H @@ -25,12 +24,10 @@ class WinStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsPianoRoll -// Description : A window that draws a piano-roll style chart, -// which shows the collectors explicitly stopping and -// starting, one frame at a time. -//////////////////////////////////////////////////////////////////// +/** + * A window that draws a piano-roll style chart, which shows the collectors + * explicitly stopping and starting, one frame at a time. + */ class WinStatsPianoRoll : public PStatPianoRoll, public WinStatsGraph { public: WinStatsPianoRoll(WinStatsMonitor *monitor, int thread_index); @@ -55,7 +52,7 @@ protected: virtual LONG graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); virtual void additional_window_paint(HDC hdc); virtual void additional_graph_window_paint(HDC hdc); - virtual DragMode consider_drag_start(int mouse_x, int mouse_y, + virtual DragMode consider_drag_start(int mouse_x, int mouse_y, int width, int height); private: @@ -74,4 +71,3 @@ private: }; #endif - diff --git a/pandatool/src/win-stats/winStatsServer.cxx b/pandatool/src/win-stats/winStatsServer.cxx index ef5b688201..91ee84134a 100644 --- a/pandatool/src/win-stats/winStatsServer.cxx +++ b/pandatool/src/win-stats/winStatsServer.cxx @@ -1,25 +1,22 @@ -// Filename: winStatsServer.cxx -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsServer.cxx + * @author drose + * @date 2003-12-02 + */ #include "winStatsServer.h" #include "winStatsMonitor.h" -//////////////////////////////////////////////////////////////////// -// Function: WinStatsServer::make_monitor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ PStatMonitor *WinStatsServer:: make_monitor() { return new WinStatsMonitor(this); diff --git a/pandatool/src/win-stats/winStatsServer.h b/pandatool/src/win-stats/winStatsServer.h index 2afe1f0860..e1da88f5e2 100644 --- a/pandatool/src/win-stats/winStatsServer.h +++ b/pandatool/src/win-stats/winStatsServer.h @@ -1,16 +1,15 @@ -// Filename: winStatsServer.h -// Created by: drose (02Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsServer.h + * @author drose + * @date 2003-12-02 + */ #ifndef WINSTATSSERVER_H #define WINSTATSSERVER_H @@ -18,15 +17,12 @@ #include "pandatoolbase.h" #include "pStatServer.h" -//////////////////////////////////////////////////////////////////// -// Class : WinStatsServer -// Description : The class that owns the main loop, waiting for client -// connections. -//////////////////////////////////////////////////////////////////// +/** + * The class that owns the main loop, waiting for client connections. + */ class WinStatsServer : public PStatServer { public: virtual PStatMonitor *make_monitor(); }; #endif - diff --git a/pandatool/src/win-stats/winStatsStripChart.cxx b/pandatool/src/win-stats/winStatsStripChart.cxx index 49a983b474..2e1d346f3b 100644 --- a/pandatool/src/win-stats/winStatsStripChart.cxx +++ b/pandatool/src/win-stats/winStatsStripChart.cxx @@ -1,16 +1,15 @@ -// Filename: winStatsStripChart.cxx -// Created by: drose (03Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsStripChart.cxx + * @author drose + * @date 2003-12-03 + */ #include "winStatsStripChart.h" #include "winStatsMonitor.h" @@ -20,27 +19,25 @@ static const int default_strip_chart_width = 400; static const int default_strip_chart_height = 100; -// Surely we aren't expected to hardcode the size of a normal -// checkbox. But Windows seems to require this data to be passed to -// CreateWindow(), so what else can I do? +// Surely we aren't expected to hardcode the size of a normal checkbox. But +// Windows seems to require this data to be passed to CreateWindow(), so what +// else can I do? size_t WinStatsStripChart::_check_box_height = 13; size_t WinStatsStripChart::_check_box_width = 13; bool WinStatsStripChart::_window_class_registered = false; const char * const WinStatsStripChart::_window_class_name = "strip"; -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsStripChart:: WinStatsStripChart(WinStatsMonitor *monitor, int thread_index, int collector_index, bool show_level) : - PStatStripChart(monitor, - show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index), + PStatStripChart(monitor, + show_level ? monitor->get_level_view(collector_index, thread_index) : monitor->get_view(thread_index), thread_index, - collector_index, + collector_index, default_strip_chart_width, default_strip_chart_height), WinStatsGraph(monitor) @@ -61,7 +58,7 @@ WinStatsStripChart(WinStatsMonitor *monitor, int thread_index, } } else { - // If it's a time-type graph, show the ms/Hz units. + // If it's a time-type graph, show the msHz units. set_guide_bar_units(get_guide_bar_units() | GBU_show_units); } @@ -71,35 +68,27 @@ WinStatsStripChart(WinStatsMonitor *monitor, int thread_index, clear_region(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ WinStatsStripChart:: ~WinStatsStripChart() { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::new_collector -// Access: Public, Virtual -// Description: Called whenever a new Collector definition is -// received from the client. -//////////////////////////////////////////////////////////////////// +/** + * Called whenever a new Collector definition is received from the client. + */ void WinStatsStripChart:: new_collector(int collector_index) { WinStatsGraph::new_collector(collector_index); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::new_data -// Access: Public, Virtual -// Description: Called as each frame's data is made available. There -// is no gurantee the frames will arrive in order, or -// that all of them will arrive at all. The monitor -// should be prepared to accept frames received -// out-of-order or missing. -//////////////////////////////////////////////////////////////////// +/** + * Called as each frame's data is made available. There is no gurantee the + * frames will arrive in order, or that all of them will arrive at all. The + * monitor should be prepared to accept frames received out-of-order or + * missing. + */ void WinStatsStripChart:: new_data(int thread_index, int frame_number) { if (is_title_unknown()) { @@ -123,35 +112,27 @@ new_data(int thread_index, int frame_number) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::force_redraw -// Access: Public, Virtual -// Description: Called when it is necessary to redraw the entire graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when it is necessary to redraw the entire graph. + */ void WinStatsStripChart:: force_redraw() { PStatStripChart::force_redraw(); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::changed_graph_size -// Access: Public, Virtual -// Description: Called when the user has resized the window, forcing -// a resize of the graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user has resized the window, forcing a resize of the graph. + */ void WinStatsStripChart:: changed_graph_size(int graph_xsize, int graph_ysize) { PStatStripChart::changed_size(graph_xsize, graph_ysize); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::set_time_units -// Access: Public, Virtual -// Description: Called when the user selects a new time units from -// the monitor pulldown menu, this should adjust the -// units for the graph to the indicated mask if it is a -// time-based graph. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new time units from the monitor pulldown + * menu, this should adjust the units for the graph to the indicated mask if + * it is a time-based graph. + */ void WinStatsStripChart:: set_time_units(int unit_mask) { int old_unit_mask = get_guide_bar_units(); @@ -171,13 +152,10 @@ set_time_units(int unit_mask) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::set_scroll_speed -// Access: Public -// Description: Called when the user selects a new scroll speed from -// the monitor pulldown menu, this should adjust the -// speed for the graph to the indicated value. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user selects a new scroll speed from the monitor pulldown + * menu, this should adjust the speed for the graph to the indicated value. + */ void WinStatsStripChart:: set_scroll_speed(double scroll_speed) { // The speed factor indicates chart widths per minute. @@ -186,22 +164,20 @@ set_scroll_speed(double scroll_speed) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::clicked_label -// Access: Public, Virtual -// Description: Called when the user single-clicks on a label. -//////////////////////////////////////////////////////////////////// +/** + * Called when the user single-clicks on a label. + */ void WinStatsStripChart:: clicked_label(int collector_index) { if (collector_index < 0) { - // Clicking on whitespace in the graph is the same as clicking on - // the top label. + // Clicking on whitespace in the graph is the same as clicking on the top + // label. collector_index = get_collector_index(); } if (collector_index == get_collector_index() && collector_index != 0) { // Clicking on the top label means to go up to the parent level. - const PStatClientData *client_data = + const PStatClientData *client_data = WinStatsGraph::_monitor->get_client_data(); if (client_data->has_collector(collector_index)) { const PStatCollectorDef &def = @@ -219,12 +195,10 @@ clicked_label(int collector_index) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::set_vertical_scale -// Access: Public -// Description: Changes the value the height of the vertical axis -// represents. This may force a redraw. -//////////////////////////////////////////////////////////////////// +/** + * Changes the value the height of the vertical axis represents. This may + * force a redraw. + */ void WinStatsStripChart:: set_vertical_scale(double value_height) { PStatStripChart::set_vertical_scale(value_height); @@ -235,11 +209,9 @@ set_vertical_scale(double value_height) { InvalidateRect(_window, &rect, TRUE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::update_labels -// Access: Protected, Virtual -// Description: Resets the list of labels. -//////////////////////////////////////////////////////////////////// +/** + * Resets the list of labels. + */ void WinStatsStripChart:: update_labels() { PStatStripChart::update_labels(); @@ -252,49 +224,40 @@ update_labels() { _labels_changed = false; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::clear_region -// Access: Protected, Virtual -// Description: Erases the chart area. -//////////////////////////////////////////////////////////////////// +/** + * Erases the chart area. + */ void WinStatsStripChart:: clear_region() { RECT rect = { 0, 0, get_xsize(), get_ysize() }; FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::copy_region -// Access: Protected, Virtual -// Description: Should be overridden by the user class to copy a -// region of the chart from one part of the chart to -// another. This is used to implement scrolling. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class to copy a region of the chart from + * one part of the chart to another. This is used to implement scrolling. + */ void WinStatsStripChart:: copy_region(int start_x, int end_x, int dest_x) { - BitBlt(_bitmap_dc, dest_x, 0, + BitBlt(_bitmap_dc, dest_x, 0, end_x - start_x, get_ysize(), _bitmap_dc, start_x, 0, SRCCOPY); - // Also shift the brush origin over, so we still get proper - // dithering. + // Also shift the brush origin over, so we still get proper dithering. _brush_origin += (dest_x - start_x); SetBrushOrgEx(_bitmap_dc, _brush_origin, 0, NULL); - RECT rect = { - dest_x, 0, dest_x + end_x - start_x, get_ysize() + RECT rect = { + dest_x, 0, dest_x + end_x - start_x, get_ysize() }; InvalidateRect(_graph_window, &rect, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::draw_slice -// Access: Protected, Virtual -// Description: Draws a single vertical slice of the strip chart, at -// the given pixel position, and corresponding to the -// indicated level data. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of the strip chart, at the given pixel + * position, and corresponding to the indicated level data. + */ void WinStatsStripChart:: draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { // Start by clearing the band first. @@ -311,8 +274,8 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { HBRUSH brush = get_collector_brush(cd._collector_index); if (overall_time > get_vertical_scale()) { - // Off the top. Go ahead and clamp it by hand, in case it's so - // far off the top we'd overflow the 16-bit pixel value. + // Off the top. Go ahead and clamp it by hand, in case it's so far off + // the top we'd overflow the 16-bit pixel value. rect.top = 0; rect.bottom = y; FillRect(_bitmap_dc, &rect, brush); @@ -328,36 +291,29 @@ draw_slice(int x, int w, const PStatStripChart::FrameData &fdata) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::draw_empty -// Access: Protected, Virtual -// Description: Draws a single vertical slice of background color. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of background color. + */ void WinStatsStripChart:: draw_empty(int x, int w) { RECT rect = { x, 0, x + w, get_ysize() }; FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::draw_cursor -// Access: Protected, Virtual -// Description: Draws a single vertical slice of foreground color. -//////////////////////////////////////////////////////////////////// +/** + * Draws a single vertical slice of foreground color. + */ void WinStatsStripChart:: draw_cursor(int x) { RECT rect = { x, 0, x + 1, get_ysize() }; FillRect(_bitmap_dc, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH)); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::end_draw -// Access: Protected, Virtual -// Description: Should be overridden by the user class. This hook -// will be called after drawing a series of color bars -// in the strip chart; it gives the pixel range that -// was just redrawn. -//////////////////////////////////////////////////////////////////// +/** + * Should be overridden by the user class. This hook will be called after + * drawing a series of color bars in the strip chart; it gives the pixel range + * that was just redrawn. + */ void WinStatsStripChart:: end_draw(int from_x, int to_x) { // Draw in the guide bars. @@ -366,17 +322,15 @@ end_draw(int from_x, int to_x) { draw_guide_bar(_bitmap_dc, from_x, to_x, get_guide_bar(i)); } - RECT rect = { - from_x, 0, to_x + 1, get_ysize() + RECT rect = { + from_x, 0, to_x + 1, get_ysize() }; InvalidateRect(_graph_window, &rect, FALSE); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::window_proc -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsStripChart:: window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -407,11 +361,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return WinStatsGraph::window_proc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::graph_window_proc -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WinStatsStripChart:: graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { @@ -432,15 +384,15 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { } break; - case WM_MOUSEMOVE: + case WM_MOUSEMOVE: if (_drag_mode == DM_none && _potential_drag_mode == DM_none) { // When the mouse is over a color bar, highlight it. PN_int16 x = LOWORD(lparam); PN_int16 y = HIWORD(lparam); _label_stack.highlight_label(get_collector_under_pixel(x, y)); - // Now we want to get a WM_MOUSELEAVE when the mouse leaves the - // graph window. + // Now we want to get a WM_MOUSELEAVE when the mouse leaves the graph + // window. TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, @@ -463,8 +415,8 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return 0; } else if (_drag_mode == DM_new_guide_bar) { - // We haven't created the new guide bar yet; we won't until the - // mouse comes within the graph's region. + // We haven't created the new guide bar yet; we won't until the mouse + // comes within the graph's region. PN_int16 y = HIWORD(lparam); if (y >= 0 && y < get_ysize()) { set_drag_mode(DM_guide_bar); @@ -505,8 +457,8 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { case WM_LBUTTONDBLCLK: { - // Double-clicking on a color bar in the graph is the same as - // double-clicking on the corresponding label. + // Double-clicking on a color bar in the graph is the same as double- + // clicking on the corresponding label. PN_int16 x = LOWORD(lparam); PN_int16 y = HIWORD(lparam); clicked_label(get_collector_under_pixel(x, y)); @@ -521,18 +473,15 @@ graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { return WinStatsGraph::graph_window_proc(hwnd, msg, wparam, lparam); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::additional_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the window (the outer window, not the -// graph window). -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the window (the outer window, + * not the graph window). + */ void WinStatsStripChart:: additional_window_paint(HDC hdc) { // Draw in the labels for the guide bars. - HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); + HFONT hfnt = (HFONT)GetStockObject(ANSI_VAR_FONT); SelectObject(hdc, hfnt); SetTextAlign(hdc, TA_LEFT | TA_TOP); SetBkMode(hdc, TRANSPARENT); @@ -561,24 +510,21 @@ additional_window_paint(HDC hdc) { SetTextAlign(hdc, TA_RIGHT | TA_BOTTOM); SetTextColor(hdc, RGB(0, 0, 0)); TextOut(hdc, rect.right - _right_margin, _top_margin, - _net_value_text.data(), _net_value_text.length()); + _net_value_text.data(), _net_value_text.length()); - // Also draw the "Smooth" label on the check box. This isn't part - // of the check box itself, because doing that doesn't use the right - // font! Surely this isn't the correct Windows(tm) way to do this - // sort of thing, but I don't know any better for now. + // Also draw the "Smooth" label on the check box. This isn't part of the + // check box itself, because doing that doesn't use the right font! Surely + // this isn't the correct Windows(tm) way to do this sort of thing, but I + // don't know any better for now. SetTextAlign(hdc, TA_LEFT | TA_BOTTOM); TextOut(hdc, _left_margin + _check_box_width + 2, _top_margin, "Smooth", 6); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::additional_graph_window_paint -// Access: Protected, Virtual -// Description: This is called during the servicing of WM_PAINT; it -// gives a derived class opportunity to do some further -// painting into the window (the outer window, not the -// graph window). -//////////////////////////////////////////////////////////////////// +/** + * This is called during the servicing of WM_PAINT; it gives a derived class + * opportunity to do some further painting into the window (the outer window, + * not the graph window). + */ void WinStatsStripChart:: additional_graph_window_paint(HDC hdc) { int num_user_guide_bars = get_num_user_guide_bars(); @@ -587,14 +533,11 @@ additional_graph_window_paint(HDC hdc) { } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::consider_drag_start -// Access: Protected, Virtual -// Description: Based on the mouse position within the window's -// client area, look for draggable things the mouse -// might be hovering over and return the apprioprate -// DragMode enum or DM_none if nothing is indicated. -//////////////////////////////////////////////////////////////////// +/** + * Based on the mouse position within the window's client area, look for + * draggable things the mouse might be hovering over and return the + * apprioprate DragMode enum or DM_none if nothing is indicated. + */ WinStatsGraph::DragMode WinStatsStripChart:: consider_drag_start(int mouse_x, int mouse_y, int width, int height) { if (mouse_x >= _graph_left && mouse_x < _graph_left + get_xsize()) { @@ -609,8 +552,7 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { } } else { - // The mouse is above or below the graph; maybe create a new - // guide bar. + // The mouse is above or below the graph; maybe create a new guide bar. return DM_new_guide_bar; } } @@ -618,13 +560,10 @@ consider_drag_start(int mouse_x, int mouse_y, int width, int height) { return WinStatsGraph::consider_drag_start(mouse_x, mouse_y, width, height); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::set_drag_mode -// Access: Protected, Virtual -// Description: This should be called whenever the drag mode needs to -// change state. It provides hooks for a derived class -// to do something special. -//////////////////////////////////////////////////////////////////// +/** + * This should be called whenever the drag mode needs to change state. It + * provides hooks for a derived class to do something special. + */ void WinStatsStripChart:: set_drag_mode(WinStatsGraph::DragMode drag_mode) { WinStatsGraph::set_drag_mode(drag_mode); @@ -639,24 +578,21 @@ set_drag_mode(WinStatsGraph::DragMode drag_mode) { break; default: - // Restore smoothing according to the current setting of the check - // box. + // Restore smoothing according to the current setting of the check box. int result = SendMessage(_smooth_check_box, BM_GETCHECK, 0, 0); set_average_mode(result == BST_CHECKED); } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::move_graph_window -// Access: Protected, Virtual -// Description: Repositions the graph child window within the parent -// window according to the _margin variables. -//////////////////////////////////////////////////////////////////// +/** + * Repositions the graph child window within the parent window according to + * the _margin variables. + */ void WinStatsStripChart:: move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysize) { WinStatsGraph::move_graph_window(graph_left, graph_top, graph_xsize, graph_ysize); if (_smooth_check_box != 0) { - SetWindowPos(_smooth_check_box, 0, + SetWindowPos(_smooth_check_box, 0, _left_margin, _top_margin - _check_box_height - 1, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); @@ -664,14 +600,11 @@ move_graph_window(int graph_left, int graph_top, int graph_xsize, int graph_ysiz } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::draw_guide_bar -// Access: Private -// Description: Draws the line for the indicated guide bar on the -// graph. -//////////////////////////////////////////////////////////////////// +/** + * Draws the line for the indicated guide bar on the graph. + */ void WinStatsStripChart:: -draw_guide_bar(HDC hdc, int from_x, int to_x, +draw_guide_bar(HDC hdc, int from_x, int to_x, const PStatGraph::GuideBar &bar) { int y = height_to_pixel(bar._height); @@ -685,7 +618,7 @@ draw_guide_bar(HDC hdc, int from_x, int to_x, case GBS_user: SelectObject(hdc, _user_guide_bar_pen); break; - + case GBS_normal: SelectObject(hdc, _dark_pen); break; @@ -695,25 +628,22 @@ draw_guide_bar(HDC hdc, int from_x, int to_x, } } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::draw_guide_label -// Access: Private -// Description: Draws the text for the indicated guide bar label to -// the right of the graph, unless it would overlap with -// the indicated last label, whose top pixel value is -// given. Returns the top pixel value of the new label. -//////////////////////////////////////////////////////////////////// +/** + * Draws the text for the indicated guide bar label to the right of the graph, + * unless it would overlap with the indicated last label, whose top pixel + * value is given. Returns the top pixel value of the new label. + */ int WinStatsStripChart:: draw_guide_label(HDC hdc, int x, const PStatGraph::GuideBar &bar, int last_y) { switch (bar._style) { case GBS_target: SetTextColor(hdc, _light_color); break; - + case GBS_user: SetTextColor(hdc, _user_guide_bar_color); break; - + case GBS_normal: SetTextColor(hdc, _dark_color); break; @@ -737,7 +667,7 @@ draw_guide_label(HDC hdc, int x, const PStatGraph::GuideBar &bar, int last_y) { if (y >= 0 && y < get_ysize() && (last_y < this_y || last_y > this_y + size.cy)) { TextOut(hdc, x, this_y, - label.data(), label.length()); + label.data(), label.length()); last_y = this_y; } @@ -745,11 +675,9 @@ draw_guide_label(HDC hdc, int x, const PStatGraph::GuideBar &bar, int last_y) { } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::create_window -// Access: Private -// Description: Creates the window for this strip chart. -//////////////////////////////////////////////////////////////////// +/** + * Creates the window for this strip chart. + */ void WinStatsStripChart:: create_window() { if (_window) { @@ -761,16 +689,16 @@ create_window() { string window_title = get_title_text(); - RECT win_rect = { + RECT win_rect = { 0, 0, - _left_margin + get_xsize() + _right_margin, + _left_margin + get_xsize() + _right_margin, _top_margin + get_ysize() + _bottom_margin - }; - + }; + // compute window size based on desired client area size AdjustWindowRect(&win_rect, graph_window_style, FALSE); - _window = + _window = CreateWindow(_window_class_name, window_title.c_str(), graph_window_style, CW_USEDEFAULT, CW_USEDEFAULT, win_rect.right - win_rect.left, @@ -784,23 +712,21 @@ create_window() { SetWindowLongPtr(_window, 0, (LONG_PTR)this); setup_label_stack(); - _smooth_check_box = + _smooth_check_box = CreateWindow("BUTTON", "", WS_CHILD | BS_AUTOCHECKBOX, 0, 0, _check_box_width, _check_box_height, _window, NULL, application, 0); // Ensure that the window is on top of the stack. - SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, + SetWindowPos(_window, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::register_window_class -// Access: Private, Static -// Description: Registers the window class for the stripChart window, if -// it has not already been registered. -//////////////////////////////////////////////////////////////////// +/** + * Registers the window class for the stripChart window, if it has not already + * been registered. + */ void WinStatsStripChart:: register_window_class(HINSTANCE application) { if (_window_class_registered) { @@ -820,7 +746,7 @@ register_window_class(HINSTANCE application) { // Reserve space to associate the this pointer with the window. wc.cbWndExtra = sizeof(WinStatsStripChart *); - + if (!RegisterClass(&wc)) { nout << "Could not register StripChart window class!\n"; exit(1); @@ -829,11 +755,9 @@ register_window_class(HINSTANCE application) { _window_class_registered = true; } -//////////////////////////////////////////////////////////////////// -// Function: WinStatsStripChart::static_window_proc -// Access: Private, Static -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ LONG WINAPI WinStatsStripChart:: static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { WinStatsStripChart *self = (WinStatsStripChart *)GetWindowLongPtr(hwnd, 0); diff --git a/pandatool/src/win-stats/winStatsStripChart.h b/pandatool/src/win-stats/winStatsStripChart.h index 3ca8d12b60..8ca08fee23 100644 --- a/pandatool/src/win-stats/winStatsStripChart.h +++ b/pandatool/src/win-stats/winStatsStripChart.h @@ -1,16 +1,15 @@ -// Filename: winStatsStripChart.h -// Created by: drose (03Dec03) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file winStatsStripChart.h + * @author drose + * @date 2003-12-03 + */ #ifndef WINSTATSSTRIPCHART_H #define WINSTATSSTRIPCHART_H @@ -25,10 +24,9 @@ class WinStatsMonitor; -//////////////////////////////////////////////////////////////////// -// Class : WinStatsStripChart -// Description : A window that draws a strip chart, given a view. -//////////////////////////////////////////////////////////////////// +/** + * A window that draws a strip chart, given a view. + */ class WinStatsStripChart : public PStatStripChart, public WinStatsGraph { public: WinStatsStripChart(WinStatsMonitor *monitor, @@ -50,7 +48,7 @@ protected: virtual void clear_region(); virtual void copy_region(int start_x, int end_x, int dest_x); - virtual void draw_slice(int x, int w, + virtual void draw_slice(int x, int w, const PStatStripChart::FrameData &fdata); virtual void draw_empty(int x, int w); virtual void draw_cursor(int x); @@ -60,7 +58,7 @@ protected: virtual LONG graph_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); virtual void additional_window_paint(HDC hdc); virtual void additional_graph_window_paint(HDC hdc); - virtual DragMode consider_drag_start(int mouse_x, int mouse_y, + virtual DragMode consider_drag_start(int mouse_x, int mouse_y, int width, int height); virtual void set_drag_mode(DragMode drag_mode); virtual void move_graph_window(int graph_left, int graph_top, @@ -85,4 +83,3 @@ private: }; #endif - diff --git a/pandatool/src/xfile/config_xfile.cxx b/pandatool/src/xfile/config_xfile.cxx index e79d7aa67b..b3f878c0f3 100644 --- a/pandatool/src/xfile/config_xfile.cxx +++ b/pandatool/src/xfile/config_xfile.cxx @@ -1,16 +1,15 @@ -// Filename: config_xfile.cxx -// Created by: drose (24Aug00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_xfile.cxx + * @author drose + * @date 2000-08-24 + */ #include "config_xfile.h" #include "xFile.h" @@ -31,24 +30,21 @@ Configure(config_xfile); NotifyCategoryDef(xfile, ""); -// This is set true, typically by the user's command-line options, to -// indicate that when a X file is generated it should include all -// geometry in one big mesh, instead of preserving the hierarchy -// from the source egg file. +// This is set true, typically by the user's command-line options, to indicate +// that when a X file is generated it should include all geometry in one big +// mesh, instead of preserving the hierarchy from the source egg file. bool xfile_one_mesh = false; ConfigureFn(config_xfile) { init_libxfile(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libxfile -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libxfile() { static bool initialized = false; @@ -70,4 +66,3 @@ init_libxfile() { XFileNode::init_type(); XFileTemplate::init_type(); } - diff --git a/pandatool/src/xfile/config_xfile.h b/pandatool/src/xfile/config_xfile.h index 35a388f66a..770d058fe3 100644 --- a/pandatool/src/xfile/config_xfile.h +++ b/pandatool/src/xfile/config_xfile.h @@ -1,16 +1,15 @@ -// Filename: config_xfile.h -// Created by: drose (22Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file config_xfile.h + * @author drose + * @date 2001-06-22 + */ #ifndef CONFIG_XFILE_H #define CONFIG_XFILE_H diff --git a/pandatool/src/xfile/standard_templates.cxx b/pandatool/src/xfile/standard_templates.cxx index 4b2f19df67..d9706bb9dd 100644 --- a/pandatool/src/xfile/standard_templates.cxx +++ b/pandatool/src/xfile/standard_templates.cxx @@ -1,35 +1,34 @@ -// Filename: standard_templates.cxx -// Created by: drose (04Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standard_templates.cxx + * @author drose + * @date 2004-10-04 + */ #include "standard_templates.h" -// The binary data included here was generated from standardTemplates.x -// (in this directory) file via the utility program bin2c (defined in -// pandatool). It contains the set of template definitions that must be -// loaded before any standard template file can be properly interpreted. +// The binary data included here was generated from standardTemplates.x (in +// this directory) file via the utility program bin2c (defined in pandatool). +// It contains the set of template definitions that must be loaded before any +// standard template file can be properly interpreted. #ifndef CPPPARSER #if defined(HAVE_ZLIB) -// If we have zlib available, we can store this file compressed, which -// is much smaller. +// If we have zlib available, we can store this file compressed, which is much +// smaller. // Regenerate this file with: -// pcompress standardTemplates.x standardTemplates.x.pz -// bin2c -n standard_templates_data -o standardTemplates.x.pz.c standardTemplates.x.pz +// pcompress standardTemplates.x standardTemplates.x.pz bin2c -n +// standard_templates_data -o standardTemplates.x.pz.c standardTemplates.x.pz #include "standardTemplates.x.pz.c" @@ -39,11 +38,11 @@ // Regenerate this file with: -// bin2c -n standard_templates_data -o standardTemplates.x.c standardTemplates.x +// bin2c -n standard_templates_data -o standardTemplates.x.c +// standardTemplates.x #include "standardTemplates.x.c" #endif // HAVE_ZLIB #endif // CPPPARSER - diff --git a/pandatool/src/xfile/standard_templates.h b/pandatool/src/xfile/standard_templates.h index 3e576c1553..b542f667e6 100644 --- a/pandatool/src/xfile/standard_templates.h +++ b/pandatool/src/xfile/standard_templates.h @@ -1,16 +1,15 @@ -// Filename: standard_templates.h -// Created by: drose (04Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file standard_templates.h + * @author drose + * @date 2004-10-04 + */ #ifndef STANDARD_TEMPLATES_H #define STANDARD_TEMPLATES_H @@ -25,4 +24,3 @@ extern const int standard_templates_data_len; #endif // CPPPARSER #endif - diff --git a/pandatool/src/xfile/windowsGuid.I b/pandatool/src/xfile/windowsGuid.I index 17f2dc4cf9..95591161d0 100644 --- a/pandatool/src/xfile/windowsGuid.I +++ b/pandatool/src/xfile/windowsGuid.I @@ -1,38 +1,32 @@ -// Filename: windowsGuid.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowsGuid.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowsGuid:: WindowsGuid() { memset(this, 0, sizeof(WindowsGuid)); } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowsGuid:: -WindowsGuid(unsigned long data1, +WindowsGuid(unsigned long data1, unsigned short data2, unsigned short data3, - unsigned char b1, unsigned char b2, unsigned char b3, - unsigned char b4, unsigned char b5, unsigned char b6, + unsigned char b1, unsigned char b2, unsigned char b3, + unsigned char b4, unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8) : _data1(data1), _data2(data2), @@ -48,63 +42,50 @@ WindowsGuid(unsigned long data1, { } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE WindowsGuid:: WindowsGuid(const WindowsGuid ©) { (*this) = copy; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::Copy Assignment Operator -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE void WindowsGuid:: operator = (const WindowsGuid ©) { memcpy(this, ©, sizeof(WindowsGuid)); } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::operator == -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool WindowsGuid:: operator == (const WindowsGuid &other) const { return compare_to(other) == 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::operator != -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool WindowsGuid:: operator != (const WindowsGuid &other) const { return compare_to(other) != 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::operator < -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE bool WindowsGuid:: operator < (const WindowsGuid &other) const { return compare_to(other) < 0; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::compare_to -// Access: Published -// Description: Returns a number less than zero if this WindowsGuid -// sorts before the other one, greater than zero if it -// sorts after, or zero if they are equivalent. -//////////////////////////////////////////////////////////////////// +/** + * Returns a number less than zero if this WindowsGuid sorts before the other + * one, greater than zero if it sorts after, or zero if they are equivalent. + */ INLINE int WindowsGuid:: compare_to(const WindowsGuid &other) const { return memcmp(this, &other, sizeof(WindowsGuid)); @@ -115,4 +96,3 @@ operator << (ostream &out, const WindowsGuid &guid) { guid.output(out); return out; } - diff --git a/pandatool/src/xfile/windowsGuid.cxx b/pandatool/src/xfile/windowsGuid.cxx index 6849a2e8cc..101e2b98cf 100644 --- a/pandatool/src/xfile/windowsGuid.cxx +++ b/pandatool/src/xfile/windowsGuid.cxx @@ -1,30 +1,26 @@ -// Filename: windowsGuid.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowsGuid.cxx + * @author drose + * @date 2004-10-03 + */ #include "windowsGuid.h" #include "pnotify.h" #include // for sscanf, sprintf -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::parse_string -// Access: Public -// Description: Parses the hex representation in the indicated string -// and stores it in the WindowsGuid object. Returns -// true if successful, false if the string -// representation is malformed. -//////////////////////////////////////////////////////////////////// +/** + * Parses the hex representation in the indicated string and stores it in the + * WindowsGuid object. Returns true if successful, false if the string + * representation is malformed. + */ bool WindowsGuid:: parse_string(const string &str) { unsigned long data1; @@ -53,16 +49,14 @@ parse_string(const string &str) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::format_string -// Access: Public -// Description: Returns a hex representation of the GUID. -//////////////////////////////////////////////////////////////////// +/** + * Returns a hex representation of the GUID. + */ string WindowsGuid:: format_string() const { static const int buf_length = 128; // Actually, we only need 36 + 1 == 37. char buffer[buf_length]; - sprintf(buffer, + sprintf(buffer, "%08lx-%04hx-%04hx-%02x%02x-%02x%02x%02x%02x%02x%02x", _data1, _data2, _data3, _b1, _b2, _b3, _b4, _b5, _b6, _b7, _b8); @@ -71,11 +65,9 @@ format_string() const { return string(buffer); } -//////////////////////////////////////////////////////////////////// -// Function: WindowsGuid::output -// Access: Public -// Description: Outputs a hex representation of the GUID. -//////////////////////////////////////////////////////////////////// +/** + * Outputs a hex representation of the GUID. + */ void WindowsGuid:: output(ostream &out) const { out << format_string(); diff --git a/pandatool/src/xfile/windowsGuid.h b/pandatool/src/xfile/windowsGuid.h index 21227b4a04..30296782f4 100644 --- a/pandatool/src/xfile/windowsGuid.h +++ b/pandatool/src/xfile/windowsGuid.h @@ -1,16 +1,15 @@ -// Filename: windowsGuid.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file windowsGuid.h + * @author drose + * @date 2004-10-03 + */ #ifndef WINDOWS_GUID_H #define WINDOWS_GUID_H @@ -19,20 +18,18 @@ #include // For memcpy, memcmp -//////////////////////////////////////////////////////////////////// -// Class : WindowsGuid -// Description : This is an implementation of the Windows GUID object, -// used everywhere as a world-unique identifier for -// anything and everything. In particular, it's used in -// the X file format to identify standard templates. -//////////////////////////////////////////////////////////////////// +/** + * This is an implementation of the Windows GUID object, used everywhere as a + * world-unique identifier for anything and everything. In particular, it's + * used in the X file format to identify standard templates. + */ class WindowsGuid { public: INLINE WindowsGuid(); - INLINE WindowsGuid(unsigned long data1, + INLINE WindowsGuid(unsigned long data1, unsigned short data2, unsigned short data3, - unsigned char b1, unsigned char b2, unsigned char b3, - unsigned char b4, unsigned char b5, unsigned char b6, + unsigned char b1, unsigned char b2, unsigned char b3, + unsigned char b4, unsigned char b5, unsigned char b6, unsigned char b7, unsigned char b8); INLINE WindowsGuid(const WindowsGuid ©); INLINE void operator = (const WindowsGuid ©); @@ -59,4 +56,3 @@ INLINE ostream &operator << (ostream &out, const WindowsGuid &guid); #include "windowsGuid.I" #endif - diff --git a/pandatool/src/xfile/xFile.I b/pandatool/src/xfile/xFile.I index 9353a7a073..cf22395517 100644 --- a/pandatool/src/xfile/xFile.I +++ b/pandatool/src/xfile/xFile.I @@ -1,14 +1,12 @@ -// Filename: xFile.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFile.I + * @author drose + * @date 2004-10-03 + */ diff --git a/pandatool/src/xfile/xFile.cxx b/pandatool/src/xfile/xFile.cxx index 4468b79f18..26791ed403 100644 --- a/pandatool/src/xfile/xFile.cxx +++ b/pandatool/src/xfile/xFile.cxx @@ -1,16 +1,15 @@ -// Filename: xFile.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFile.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFile.h" #include "xParserDefs.h" @@ -26,11 +25,9 @@ TypeHandle XFile::_type_handle; PT(XFile) XFile::_standard_templates; -//////////////////////////////////////////////////////////////////// -// Function: XFile::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFile:: XFile(bool keep_names) : XFileNode(this, "") { _major_version = 3; @@ -40,22 +37,18 @@ XFile(bool keep_names) : XFileNode(this, "") { _keep_names = keep_names; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFile:: ~XFile() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::clear -// Access: Public, Virtual -// Description: Removes all of the classes defined within the XFile -// and prepares it for reading a new file. -//////////////////////////////////////////////////////////////////// +/** + * Removes all of the classes defined within the XFile and prepares it for + * reading a new file. + */ void XFile:: clear() { XFileNode::clear(); @@ -63,18 +56,14 @@ clear() { _nodes_by_guid.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::read -// Access: Public -// Description: Opens and reads the indicated .x file by name. The -// nodes and templates defined in the file will be -// appended to the set of nodes already recorded, if -// any. -// -// Returns true if the file is successfully read, false -// if there was an error (in which case the file might -// have been partially read). -//////////////////////////////////////////////////////////////////// +/** + * Opens and reads the indicated .x file by name. The nodes and templates + * defined in the file will be appended to the set of nodes already recorded, + * if any. + * + * Returns true if the file is successfully read, false if there was an error + * (in which case the file might have been partially read). + */ bool XFile:: read(Filename filename) { filename.set_text(); @@ -90,22 +79,16 @@ read(Filename filename) { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::read -// Access: Public -// Description: Parses the already-opened input stream for -// distributed class descriptions. The filename -// parameter is optional and is only used when reporting -// errors. -// -// The distributed classes defined in the file will be -// appended to the set of distributed classes already -// recorded, if any. -// -// Returns true if the file is successfully read, false -// if there was an error (in which case the file might -// have been partially read). -//////////////////////////////////////////////////////////////////// +/** + * Parses the already-opened input stream for distributed class descriptions. + * The filename parameter is optional and is only used when reporting errors. + * + * The distributed classes defined in the file will be appended to the set of + * distributed classes already recorded, if any. + * + * Returns true if the file is successfully read, false if there was an error + * (in which case the file might have been partially read). + */ bool XFile:: read(istream &in, const string &filename) { if (!read_header(in)) { @@ -113,16 +96,16 @@ read(istream &in, const string &filename) { } if (_format_type != FT_text) { - // Does anyone actually use the binary format? It wouldn't be too - // hard to support it if there were any reason at all to do so. + // Does anyone actually use the binary format? It wouldn't be too hard to + // support it if there were any reason at all to do so. xfile_cat.error() << "Cannot read binary .x files at this time.\n"; return false; } - // We must call this first so the standard templates file will be - // parsed and available by the time we need it--it's tricky to - // invoke the parser from within another parser instance. + // We must call this first so the standard templates file will be parsed and + // available by the time we need it--it's tricky to invoke the parser from + // within another parser instance. get_standard_templates(); x_init_parser(in, filename, *this); @@ -132,22 +115,18 @@ read(istream &in, const string &filename) { return (x_error_count() == 0); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::write -// Access: Public -// Description: Opens the indicated filename for output and writes a -// parseable description of all the known distributed -// classes to the file. -// -// Returns true if the description is successfully -// written, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Opens the indicated filename for output and writes a parseable description + * of all the known distributed classes to the file. + * + * Returns true if the description is successfully written, false otherwise. + */ bool XFile:: write(Filename filename) const { ofstream out; - // We actually open the file to write in binary mode, to avoid the - // MS-DOS newline characters (since Windows seems to do this too). + // We actually open the file to write in binary mode, to avoid the MS-DOS + // newline characters (since Windows seems to do this too). filename.set_binary(); filename.open_write(out); @@ -159,8 +138,8 @@ write(Filename filename) const { #ifdef HAVE_ZLIB if (filename.get_extension() == "pz") { - // The filename ends in .pz, which means to automatically compress - // the X file that we write. + // The filename ends in .pz, which means to automatically compress the X + // file that we write. OCompressStream compressor(&out, false); return write(compressor); } @@ -169,15 +148,12 @@ write(Filename filename) const { return write(out); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::write -// Access: Public -// Description: Writes a parseable description of all the known -// nodes and templates to the stream. -// -// Returns true if the description is successfully -// written, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes a parseable description of all the known nodes and templates to the + * stream. + * + * Returns true if the description is successfully written, false otherwise. + */ bool XFile:: write(ostream &out) const { if (!write_header(out)) { @@ -189,12 +165,10 @@ write(ostream &out) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_template -// Access: Public -// Description: Returns the template associated with the indicated -// name, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the template associated with the indicated name, if any, or NULL if + * none. + */ XFileTemplate *XFile:: find_template(const string &name) const { XFileTemplate *standard = (XFileTemplate *)NULL; @@ -208,10 +182,10 @@ find_template(const string &name) const { child->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, child); if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { - // If the template matches a standard template, return the - // standard instead. The assumption is that code may expect a - // certain naming scheme for the data elements of the standard - // template, so we want to be sure to provide it. + // If the template matches a standard template, return the standard + // instead. The assumption is that code may expect a certain naming + // scheme for the data elements of the standard template, so we want to + // be sure to provide it. return standard; } return xtemplate; @@ -220,12 +194,10 @@ find_template(const string &name) const { return standard; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_template -// Access: Public -// Description: Returns the template associated with the indicated -// GUID, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the template associated with the indicated GUID, if any, or NULL if + * none. + */ XFileTemplate *XFile:: find_template(const WindowsGuid &guid) const { XFileTemplate *standard = (XFileTemplate *)NULL; @@ -236,14 +208,14 @@ find_template(const WindowsGuid &guid) const { NodesByGuid::const_iterator gi; gi = _nodes_by_guid.find(guid); - if (gi != _nodes_by_guid.end() && + if (gi != _nodes_by_guid.end() && (*gi).second->is_of_type(XFileTemplate::get_class_type())) { XFileTemplate *xtemplate = DCAST(XFileTemplate, (*gi).second); if (standard != (XFileTemplate *)NULL && xtemplate->matches(standard)) { - // If the template matches a standard template, return the - // standard instead. The assumption is that code may expect a - // certain naming scheme for the data elements of the standard - // template, so we want to be sure to provide it. + // If the template matches a standard template, return the standard + // instead. The assumption is that code may expect a certain naming + // scheme for the data elements of the standard template, so we want to + // be sure to provide it. return standard; } return xtemplate; @@ -252,36 +224,30 @@ find_template(const WindowsGuid &guid) const { return standard; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_standard_template -// Access: Public, Static -// Description: Returns the standard template associated with the -// indicated name, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the standard template associated with the indicated name, if any, + * or NULL if none. + */ XFileTemplate *XFile:: find_standard_template(const string &name) { const XFile *standard_templates = get_standard_templates(); return standard_templates->find_template(name); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_standard_template -// Access: Public, Static -// Description: Returns the template associated with the indicated -// GUID, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the template associated with the indicated GUID, if any, or NULL if + * none. + */ XFileTemplate *XFile:: find_standard_template(const WindowsGuid &guid) { const XFile *standard_templates = get_standard_templates(); return standard_templates->find_template(guid); } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_data_object -// Access: Public -// Description: Returns the data object associated with the indicated -// name, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data object associated with the indicated name, if any, or NULL + * if none. + */ XFileDataNodeTemplate *XFile:: find_data_object(const string &name) const { XFileNode *child = find_descendent(name); @@ -293,17 +259,15 @@ find_data_object(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::find_data_object -// Access: Public -// Description: Returns the data object associated with the indicated -// GUID, if any, or NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data object associated with the indicated GUID, if any, or NULL + * if none. + */ XFileDataNodeTemplate *XFile:: find_data_object(const WindowsGuid &guid) const { NodesByGuid::const_iterator gi; gi = _nodes_by_guid.find(guid); - if (gi != _nodes_by_guid.end() && + if (gi != _nodes_by_guid.end() && (*gi).second->is_of_type(XFileDataNodeTemplate::get_class_type())) { return DCAST(XFileDataNodeTemplate, (*gi).second); } @@ -311,12 +275,9 @@ find_data_object(const WindowsGuid &guid) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFile:: write_text(ostream &out, int indent_level) const { Children::const_iterator ci; @@ -326,12 +287,10 @@ write_text(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFile::read_header -// Access: Private -// Description: Reads the header and magic number associated with the -// file. Returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Reads the header and magic number associated with the file. Returns true + * on success, false otherwise. + */ bool XFile:: read_header(istream &in) { char magic[4]; @@ -407,12 +366,10 @@ read_header(istream &in) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::write_header -// Access: Private -// Description: Writes the header and magic number associated with the -// file. Returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the header and magic number associated with the file. Returns true + * on success, false otherwise. + */ bool XFile:: write_header(ostream &out) const { out.write("xof ", 4); @@ -432,11 +389,11 @@ write_header(ostream &out) const { case FT_text: out.write("txt ", 4); break; - + case FT_binary: out.write("bin ", 4); break; - + case FT_compressed: out.write("cmp ", 4); break; @@ -456,7 +413,7 @@ write_header(ostream &out) const { case FS_32: out.write("0032", 4); break; - + case FS_64: out.write("0064", 4); break; @@ -475,18 +432,15 @@ write_header(ostream &out) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFile::get_standard_templates -// Access: Private, Static -// Description: Returns a global XFile object that contains the -// standard list of Direct3D template definitions that -// may be assumed to be at the head of every file. -//////////////////////////////////////////////////////////////////// +/** + * Returns a global XFile object that contains the standard list of Direct3D + * template definitions that may be assumed to be at the head of every file. + */ const XFile *XFile:: get_standard_templates() { if (_standard_templates == (XFile *)NULL) { - // The standardTemplates.x file has been compiled into this - // binary. Extract it out. + // The standardTemplates.x file has been compiled into this binary. + // Extract it out. string data((const char *)standard_templates_data, standard_templates_data_len); @@ -494,12 +448,12 @@ get_standard_templates() { // The data is stored compressed; decompress it on-the-fly. istringstream inz(data); IDecompressStream in(&inz, false); - + #else // The data is stored uncompressed, so just load it. istringstream in(data); #endif // HAVE_ZLIB - + _standard_templates = new XFile; if (!_standard_templates->read(in, "standardTemplates.x")) { xfile_cat.error() @@ -515,6 +469,6 @@ get_standard_templates() { } } } - + return _standard_templates; } diff --git a/pandatool/src/xfile/xFile.h b/pandatool/src/xfile/xFile.h index 3ad14a8895..fa43e5ab77 100644 --- a/pandatool/src/xfile/xFile.h +++ b/pandatool/src/xfile/xFile.h @@ -1,16 +1,15 @@ -// Filename: xFile.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFile.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILE_H #define XFILE_H @@ -26,12 +25,10 @@ class XFileTemplate; class XFileDataNodeTemplate; -//////////////////////////////////////////////////////////////////// -// Class : XFile -// Description : This represents the complete contents of an X file -// (file.x) in memory. It may be read or written from -// or to a disk file. -//////////////////////////////////////////////////////////////////// +/** + * This represents the complete contents of an X file (file.x) in memory. It + * may be read or written from or to a disk file. + */ class XFile : public XFileNode { public: XFile(bool keep_names=false); @@ -69,19 +66,19 @@ public: private: bool read_header(istream &in); bool write_header(ostream &out) const; - + static const XFile *get_standard_templates(); int _major_version, _minor_version; FormatType _format_type; FloatSize _float_size; bool _keep_names; - + typedef pmap NodesByGuid; NodesByGuid _nodes_by_guid; static PT(XFile) _standard_templates; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -105,5 +102,3 @@ private: #include "xFile.I" #endif - - diff --git a/pandatool/src/xfile/xFileArrayDef.I b/pandatool/src/xfile/xFileArrayDef.I index 56e68c7ebe..bb06c75fb8 100644 --- a/pandatool/src/xfile/xFileArrayDef.I +++ b/pandatool/src/xfile/xFileArrayDef.I @@ -1,23 +1,19 @@ -// Filename: xFileArrayDef.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileArrayDef.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileArrayDef:: XFileArrayDef(int fixed_size) : _fixed_size(fixed_size), @@ -25,11 +21,9 @@ XFileArrayDef(int fixed_size) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileArrayDef:: XFileArrayDef(XFileDataDef *dynamic_size) : _fixed_size(0), @@ -37,39 +31,30 @@ XFileArrayDef(XFileDataDef *dynamic_size) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::is_fixed_size -// Access: Public -// Description: Returns true if this array definition specifies a -// const-size array, false if it is a dynamic-size -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this array definition specifies a const-size array, false + * if it is a dynamic-size array. + */ INLINE bool XFileArrayDef:: is_fixed_size() const { return (_dynamic_size == (XFileDataDef *)NULL); } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::get_fixed_size -// Access: Public -// Description: Returns the const size of the array, if -// is_fixed_size() returned true. -//////////////////////////////////////////////////////////////////// +/** + * Returns the const size of the array, if is_fixed_size() returned true. + */ INLINE int XFileArrayDef:: get_fixed_size() const { nassertr(is_fixed_size(), 0); return _fixed_size; } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::get_dynamic_size -// Access: Public -// Description: Returns the data element that names the dynamic size -// of the array, if is_fixed_size() returned false. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data element that names the dynamic size of the array, if + * is_fixed_size() returned false. + */ INLINE XFileDataDef *XFileArrayDef:: get_dynamic_size() const { nassertr(!is_fixed_size(), NULL); return _dynamic_size; } - diff --git a/pandatool/src/xfile/xFileArrayDef.cxx b/pandatool/src/xfile/xFileArrayDef.cxx index 9bd9726896..7bde81d7e0 100644 --- a/pandatool/src/xfile/xFileArrayDef.cxx +++ b/pandatool/src/xfile/xFileArrayDef.cxx @@ -1,31 +1,26 @@ -// Filename: xFileArrayDef.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileArrayDef.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileArrayDef.h" #include "xFileDataDef.h" #include "xFileDataObject.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::get_size -// Access: Public -// Description: Returns the size of the array dimension. If this is -// a fixed array, the size is trivial; if it is dynamic, -// the size is determined by looking up the dynamic_size -// element in the prev_data table (which lists all of -// the data values already defined at this scoping -// level). -//////////////////////////////////////////////////////////////////// +/** + * Returns the size of the array dimension. If this is a fixed array, the + * size is trivial; if it is dynamic, the size is determined by looking up the + * dynamic_size element in the prev_data table (which lists all of the data + * values already defined at this scoping level). + */ int XFileArrayDef:: get_size(const XFileNode::PrevData &prev_data) const { if (is_fixed_size()) { @@ -39,11 +34,9 @@ get_size(const XFileNode::PrevData &prev_data) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::output -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void XFileArrayDef:: output(ostream &out) const { if (is_fixed_size()) { @@ -53,15 +46,11 @@ output(ostream &out) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileArrayDef::matches -// Access: Public, Virtual -// Description: Returns true if the node, particularly a template -// node, is structurally equivalent to the other node -// (which must be of the same type). This checks data -// element types, but does not compare data element -// names. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node, particularly a template node, is structurally + * equivalent to the other node (which must be of the same type). This checks + * data element types, but does not compare data element names. + */ bool XFileArrayDef:: matches(const XFileArrayDef &other, const XFileDataDef *parent, const XFileDataDef *other_parent) const { @@ -75,7 +64,7 @@ matches(const XFileArrayDef &other, const XFileDataDef *parent, } else { int child_index = parent->find_child_index(get_dynamic_size()); - int other_child_index = + int other_child_index = other_parent->find_child_index(other.get_dynamic_size()); if (other_child_index != child_index) { return false; diff --git a/pandatool/src/xfile/xFileArrayDef.h b/pandatool/src/xfile/xFileArrayDef.h index d8ddd987ba..2c8f79d443 100644 --- a/pandatool/src/xfile/xFileArrayDef.h +++ b/pandatool/src/xfile/xFileArrayDef.h @@ -1,16 +1,15 @@ -// Filename: xFileArrayDef.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileArrayDef.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILEARRAYDEF_H #define XFILEARRAYDEF_H @@ -21,11 +20,9 @@ class XFileDataDef; -//////////////////////////////////////////////////////////////////// -// Class : XFileArrayDef -// Description : Defines one level of array bounds for an associated -// XFileDataDef element. -//////////////////////////////////////////////////////////////////// +/** + * Defines one level of array bounds for an associated XFileDataDef element. + */ class XFileArrayDef { public: INLINE XFileArrayDef(int fixed_size); @@ -50,6 +47,3 @@ private: #include "xFileArrayDef.I" #endif - - - diff --git a/pandatool/src/xfile/xFileDataDef.I b/pandatool/src/xfile/xFileDataDef.I index 0de48efee7..59dd89db50 100644 --- a/pandatool/src/xfile/xFileDataDef.I +++ b/pandatool/src/xfile/xFileDataDef.I @@ -1,25 +1,21 @@ -// Filename: xFileDataDef.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataDef.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileDataDef:: -XFileDataDef(XFile *x_file, const string &name, +XFileDataDef(XFile *x_file, const string &name, XFileDataDef::Type type, XFileTemplate *xtemplate) : XFileNode(x_file, name), _type(type), @@ -27,48 +23,37 @@ XFileDataDef(XFile *x_file, const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::get_data_type -// Access: Public -// Description: Returns the primitive type of this element, or -// T_template if this represents a nested template -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the primitive type of this element, or T_template if this + * represents a nested template object. + */ INLINE XFileDataDef::Type XFileDataDef:: get_data_type() const { return _type; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::get_template -// Access: Public -// Description: If get_data_type() returned T_template, this returns -// the particular template pointer that this object -// represents. -//////////////////////////////////////////////////////////////////// +/** + * If get_data_type() returned T_template, this returns the particular + * template pointer that this object represents. + */ INLINE XFileTemplate *XFileDataDef:: get_template() const { return _template; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::get_num_array_defs -// Access: Public -// Description: Returns the number of dimensions of array elements on -// this data object, or 0 if the data object is not an -// array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of dimensions of array elements on this data object, or + * 0 if the data object is not an array. + */ INLINE int XFileDataDef:: get_num_array_defs() const { return _array_def.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::get_array_def -// Access: Public -// Description: Returns the description of the nth dimension of array -// elements on this data object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the description of the nth dimension of array elements on this data + * object. + */ INLINE const XFileArrayDef &XFileDataDef:: get_array_def(int i) const { nassertr(i >= 0 && i < (int)_array_def.size(), _array_def[0]); diff --git a/pandatool/src/xfile/xFileDataDef.cxx b/pandatool/src/xfile/xFileDataDef.cxx index a36f4bd299..4e47187b6a 100644 --- a/pandatool/src/xfile/xFileDataDef.cxx +++ b/pandatool/src/xfile/xFileDataDef.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataDef.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataDef.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileDataDef.h" #include "indent.h" @@ -25,44 +24,34 @@ TypeHandle XFileDataDef::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataDef:: ~XFileDataDef() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::clear -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void XFileDataDef:: clear() { XFileNode::clear(); _array_def.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::add_array_def -// Access: Public -// Description: Adds an additional array dimension to the data -// description. -//////////////////////////////////////////////////////////////////// +/** + * Adds an additional array dimension to the data description. + */ void XFileDataDef:: add_array_def(const XFileArrayDef &array_def) { _array_def.push_back(array_def); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataDef:: write_text(ostream &out, int indent_level) const { indent(out, indent_level); @@ -133,21 +122,17 @@ write_text(ostream &out, int indent_level) const { out << ";\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::repack_data -// Access: Public, Virtual -// Description: This is called on the template that defines an -// object, once the data for the object has been parsed. -// It is responsible for identifying which component of -// the template owns each data element, and packing the -// data elements appropriately back into the object. -// -// It returns true on success, or false on an error -// (e.g. not enough data elements, mismatched data -// type). -//////////////////////////////////////////////////////////////////// +/** + * This is called on the template that defines an object, once the data for + * the object has been parsed. It is responsible for identifying which + * component of the template owns each data element, and packing the data + * elements appropriately back into the object. + * + * It returns true on success, or false on an error (e.g. not enough data + * elements, mismatched data type). + */ bool XFileDataDef:: -repack_data(XFileDataObject *object, +repack_data(XFileDataObject *object, const XFileParseDataList &parse_data_list, XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { @@ -195,17 +180,14 @@ repack_data(XFileDataObject *object, prev_data[this] = data_value; } - return XFileNode::repack_data(object, parse_data_list, + return XFileNode::repack_data(object, parse_data_list, prev_data, index, sub_index); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::fill_zero_data -// Access: Public, Virtual -// Description: This is similar to repack_data(), except it is used -// to fill the initial values for a newly-created -// template object to zero. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to repack_data(), except it is used to fill the initial + * values for a newly-created template object to zero. + */ bool XFileDataDef:: fill_zero_data(XFileDataObject *object) const { PT(XFileDataObject) data_value; @@ -244,15 +226,11 @@ fill_zero_data(XFileDataObject *object) const { return XFileNode::fill_zero_data(object); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::matches -// Access: Public, Virtual -// Description: Returns true if the node, particularly a template -// node, is structurally equivalent to the other node -// (which must be of the same type). This checks data -// element types, but does not compare data element -// names. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node, particularly a template node, is structurally + * equivalent to the other node (which must be of the same type). This checks + * data element types, but does not compare data element names. + */ bool XFileDataDef:: matches(const XFileNode *other) const { if (!XFileNode::matches(other)) { @@ -284,12 +262,10 @@ matches(const XFileNode *other) const { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::unpack_integer_value -// Access: Private -// Description: Unpacks and returns the next sequential integer value -// from the parse_data_list. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks and returns the next sequential integer value from the + * parse_data_list. + */ PT(XFileDataObject) XFileDataDef:: unpack_integer_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, @@ -303,7 +279,7 @@ unpack_integer_value(const XFileParseDataList &parse_data_list, nassertr(sub_index < parse_data._int_list.size(), NULL); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectInteger(this, value); - + sub_index++; if (sub_index >= parse_data._int_list.size()) { index++; @@ -317,12 +293,10 @@ unpack_integer_value(const XFileParseDataList &parse_data_list, return data_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::unpack_double_value -// Access: Private -// Description: Unpacks and returns the next sequential double value -// from the parse_data_list. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks and returns the next sequential double value from the + * parse_data_list. + */ PT(XFileDataObject) XFileDataDef:: unpack_double_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, @@ -336,7 +310,7 @@ unpack_double_value(const XFileParseDataList &parse_data_list, nassertr(sub_index < parse_data._double_list.size(), NULL); double value = parse_data._double_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); - + sub_index++; if (sub_index >= parse_data._double_list.size()) { index++; @@ -347,7 +321,7 @@ unpack_double_value(const XFileParseDataList &parse_data_list, nassertr(sub_index < parse_data._int_list.size(), NULL); int value = parse_data._int_list[sub_index]; data_value = new XFileDataObjectDouble(this, value); - + sub_index++; if (sub_index >= parse_data._int_list.size()) { index++; @@ -361,12 +335,10 @@ unpack_double_value(const XFileParseDataList &parse_data_list, return data_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::unpack_string_value -// Access: Private -// Description: Unpacks and returns the next sequential string value -// from the parse_data_list. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks and returns the next sequential string value from the + * parse_data_list. + */ PT(XFileDataObject) XFileDataDef:: unpack_string_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, @@ -388,20 +360,18 @@ unpack_string_value(const XFileParseDataList &parse_data_list, return data_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::unpack_template_value -// Access: Private -// Description: Unpacks a nested template object's data. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks a nested template object's data. + */ PT(XFileDataObject) XFileDataDef:: unpack_template_value(const XFileParseDataList &parse_data_list, const XFileDataDef::PrevData &prev_data, size_t &index, size_t &sub_index) const { - PT(XFileDataNodeTemplate) data_value = + PT(XFileDataNodeTemplate) data_value = new XFileDataNodeTemplate(get_x_file(), get_name(), _template); PrevData nested_prev_data(prev_data); - if (!_template->repack_data(data_value, parse_data_list, + if (!_template->repack_data(data_value, parse_data_list, nested_prev_data, index, sub_index)) { return NULL; } @@ -409,21 +379,18 @@ unpack_template_value(const XFileParseDataList &parse_data_list, return data_value.p(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::unpack_value -// Access: Private -// Description: Unpacks and returns the next sequential value, of the -// type supported by the unpack_method. If the value -// is an array type, unpacks all the elements of the -// array. -//////////////////////////////////////////////////////////////////// +/** + * Unpacks and returns the next sequential value, of the type supported by the + * unpack_method. If the value is an array type, unpacks all the elements of + * the array. + */ PT(XFileDataObject) XFileDataDef:: unpack_value(const XFileParseDataList &parse_data_list, int array_index, const XFileDataDef::PrevData &prev_data, - size_t &index, size_t &sub_index, + size_t &index, size_t &sub_index, XFileDataDef::UnpackMethod unpack_method) const { PT(XFileDataObject) data_value; - + if (array_index == (int)_array_def.size()) { if (index >= parse_data_list._list.size()) { xyyerror("Not enough data elements in structure at " + get_name()); @@ -443,7 +410,7 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, return data_value; } - PT(XFileDataObject) array_element = + PT(XFileDataObject) array_element = unpack_value(parse_data_list, array_index + 1, prev_data, index, sub_index, unpack_method); @@ -457,45 +424,36 @@ unpack_value(const XFileParseDataList &parse_data_list, int array_index, return data_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::zero_fill_integer_value -// Access: Private -// Description: Returns a newly-allocated zero integer value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated zero integer value. + */ PT(XFileDataObject) XFileDataDef:: zero_fill_integer_value() const { return new XFileDataObjectInteger(this, 0); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::zero_fill_double_value -// Access: Private -// Description: Returns a newly-allocated zero floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated zero floating-point value. + */ PT(XFileDataObject) XFileDataDef:: zero_fill_double_value() const { return new XFileDataObjectDouble(this, 0.0); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::zero_fill_string_value -// Access: Private -// Description: Returns a newly-allocated empty string value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated empty string value. + */ PT(XFileDataObject) XFileDataDef:: zero_fill_string_value() const { return new XFileDataObjectString(this, ""); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::zero_fill_template_value -// Access: Private -// Description: Returns a newly-allocated zero-filled nested template -// value. -//////////////////////////////////////////////////////////////////// +/** + * Returns a newly-allocated zero-filled nested template value. + */ PT(XFileDataObject) XFileDataDef:: zero_fill_template_value() const { - PT(XFileDataObject) data_value = + PT(XFileDataObject) data_value = new XFileDataNodeTemplate(get_x_file(), get_name(), _template); if (!_template->fill_zero_data(data_value)) { return NULL; @@ -504,19 +462,16 @@ zero_fill_template_value() const { return data_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataDef::zero_fill_value -// Access: Private -// Description: Creates a zero-valued element for the next sequential -// value, of the type returned by the zero_fill_method. -// If the value is a fixed-size array type, zero-fills -// all the elements of the array. -//////////////////////////////////////////////////////////////////// +/** + * Creates a zero-valued element for the next sequential value, of the type + * returned by the zero_fill_method. If the value is a fixed-size array type, + * zero-fills all the elements of the array. + */ PT(XFileDataObject) XFileDataDef:: -zero_fill_value(int array_index, +zero_fill_value(int array_index, XFileDataDef::ZeroFillMethod zero_fill_method) const { PT(XFileDataObject) data_value; - + if (array_index == (int)_array_def.size()) { data_value = (this->*zero_fill_method)(); @@ -528,7 +483,7 @@ zero_fill_value(int array_index, } for (int i = 0; i < array_size; i++) { - PT(XFileDataObject) array_element = + PT(XFileDataObject) array_element = zero_fill_value(array_index + 1, zero_fill_method); if (array_element == (XFileDataObject *)NULL) { return NULL; diff --git a/pandatool/src/xfile/xFileDataDef.h b/pandatool/src/xfile/xFileDataDef.h index 6ff672d6b4..7d489ceafd 100644 --- a/pandatool/src/xfile/xFileDataDef.h +++ b/pandatool/src/xfile/xFileDataDef.h @@ -1,16 +1,15 @@ -// Filename: xFileDataDef.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataDef.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILEDATADEF_H #define XFILEDATADEF_H @@ -24,14 +23,11 @@ #include "pvector.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataDef -// Description : A definition of a single data element appearing -// within a template record. This class represents the -// *definition* of the data element (e.g. DWORD -// nVertices); see XFileDataObject for its *value* -// (e.g. 12). -//////////////////////////////////////////////////////////////////// +/** + * A definition of a single data element appearing within a template record. + * This class represents the *definition* of the data element (e.g. DWORD + * nVertices); see XFileDataObject for its *value* (e.g. 12). + */ class XFileDataDef : public XFileNode { public: enum Type { @@ -49,7 +45,7 @@ public: T_template, }; - INLINE XFileDataDef(XFile *x_file, const string &name, + INLINE XFileDataDef(XFile *x_file, const string &name, Type type, XFileTemplate *xtemplate = NULL); virtual ~XFileDataDef(); @@ -60,11 +56,11 @@ public: INLINE XFileTemplate *get_template() const; INLINE int get_num_array_defs() const; - INLINE const XFileArrayDef &get_array_def(int i) const; + INLINE const XFileArrayDef &get_array_def(int i) const; virtual void write_text(ostream &out, int indent_level) const; - virtual bool repack_data(XFileDataObject *object, + virtual bool repack_data(XFileDataObject *object, const XFileParseDataList &parse_data_list, PrevData &prev_data, size_t &index, size_t &sub_index) const; @@ -74,31 +70,31 @@ public: virtual bool matches(const XFileNode *other) const; private: - typedef PT(XFileDataObject) - (XFileDataDef::*UnpackMethod)(const XFileParseDataList &parse_data_list, + typedef PT(XFileDataObject) + (XFileDataDef::*UnpackMethod)(const XFileParseDataList &parse_data_list, const PrevData &prev_data, size_t &index, size_t &sub_index) const; - typedef PT(XFileDataObject) + typedef PT(XFileDataObject) (XFileDataDef::*ZeroFillMethod)() const; - PT(XFileDataObject) + PT(XFileDataObject) unpack_integer_value(const XFileParseDataList &parse_data_list, const PrevData &prev_data, size_t &index, size_t &sub_index) const; - PT(XFileDataObject) + PT(XFileDataObject) unpack_double_value(const XFileParseDataList &parse_data_list, const PrevData &prev_data, size_t &index, size_t &sub_index) const; - PT(XFileDataObject) + PT(XFileDataObject) unpack_string_value(const XFileParseDataList &parse_data_list, const PrevData &prev_data, size_t &index, size_t &sub_index) const; - PT(XFileDataObject) + PT(XFileDataObject) unpack_template_value(const XFileParseDataList &parse_data_list, const PrevData &prev_data, size_t &index, size_t &sub_index) const; - PT(XFileDataObject) + PT(XFileDataObject) unpack_value(const XFileParseDataList &parse_data_list, int array_index, const PrevData &prev_data, size_t &index, size_t &sub_index, @@ -108,16 +104,16 @@ private: PT(XFileDataObject) zero_fill_double_value() const; PT(XFileDataObject) zero_fill_string_value() const; PT(XFileDataObject) zero_fill_template_value() const; - PT(XFileDataObject) + PT(XFileDataObject) zero_fill_value(int array_index, ZeroFillMethod zero_fill_method) const; - + private: Type _type; PT(XFileTemplate) _template; - + typedef pvector ArrayDef; ArrayDef _array_def; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -139,6 +135,3 @@ private: #include "xFileDataDef.I" #endif - - - diff --git a/pandatool/src/xfile/xFileDataNode.I b/pandatool/src/xfile/xFileDataNode.I index 8d2af5531e..23e63eb321 100644 --- a/pandatool/src/xfile/xFileDataNode.I +++ b/pandatool/src/xfile/xFileDataNode.I @@ -1,56 +1,45 @@ -// Filename: xFileDataNode.I -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNode.I + * @author drose + * @date 2004-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::get_data_child -// Access: Public -// Description: Since the children of an XFileDataNode are -// syntactically constrained to themselves be -// XFileDataNodes, this is a convenience function that -// returns the same thing as XFileNode::get_child(), but -// it is cast to a type XFileDataNode and dereferenced. -//////////////////////////////////////////////////////////////////// +/** + * Since the children of an XFileDataNode are syntactically constrained to + * themselves be XFileDataNodes, this is a convenience function that returns + * the same thing as XFileNode::get_child(), but it is cast to a type + * XFileDataNode and dereferenced. + */ INLINE const XFileDataNode &XFileDataNode:: get_data_child(int n) const { return *DCAST(XFileDataNode, get_child(n)); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::get_template -// Access: Public -// Description: Returns the template used to define this data object. -// Since the only classes to inherit from XFileDataNode -// are XFileDataNodeTemplate and XFileDataNodeReference, -// both of which represent a class that is defined by a -// template, it makes sense to put this common method -// here in the base class. -//////////////////////////////////////////////////////////////////// +/** + * Returns the template used to define this data object. Since the only + * classes to inherit from XFileDataNode are XFileDataNodeTemplate and + * XFileDataNodeReference, both of which represent a class that is defined by + * a template, it makes sense to put this common method here in the base + * class. + */ INLINE XFileTemplate *XFileDataNode:: get_template() const { return _template; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::get_template_name -// Access: Public -// Description: A convenience function to return the name of the -// template used to define this data object. -//////////////////////////////////////////////////////////////////// +/** + * A convenience function to return the name of the template used to define + * this data object. + */ INLINE const string &XFileDataNode:: get_template_name() const { return _template->get_name(); } - diff --git a/pandatool/src/xfile/xFileDataNode.cxx b/pandatool/src/xfile/xFileDataNode.cxx index 70d9ab138d..d0ebb6dba8 100644 --- a/pandatool/src/xfile/xFileDataNode.cxx +++ b/pandatool/src/xfile/xFileDataNode.cxx @@ -1,27 +1,24 @@ -// Filename: xFileDataNode.cxx -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNode.cxx + * @author drose + * @date 2004-10-08 + */ #include "xFileDataNode.h" #include "indent.h" TypeHandle XFileDataNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataNode:: XFileDataNode(XFile *x_file, const string &name, XFileTemplate *xtemplate) : @@ -30,32 +27,24 @@ XFileDataNode(XFile *x_file, const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::is_object -// Access: Public, Virtual -// Description: Returns true if this node represents a data object -// that is the instance of some template, or false -// otherwise. This also returns true for references to -// objects (which are generally treated just like the -// objects themselves). -// -// If this returns true, the node must be of type -// XFileDataNode (it is either an XFileDataNodeTemplate -// or an XFileDataNodeReference). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents a data object that is the instance of + * some template, or false otherwise. This also returns true for references + * to objects (which are generally treated just like the objects themselves). + * + * If this returns true, the node must be of type XFileDataNode (it is either + * an XFileDataNodeTemplate or an XFileDataNodeReference). + */ bool XFileDataNode:: is_object() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::is_standard_object -// Access: Public, Virtual -// Description: Returns true if this node represents an instance of -// the standard template with the indicated name, or -// false otherwise. If this returns true, the object -// must be of type XFileDataNode. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents an instance of the standard template + * with the indicated name, or false otherwise. If this returns true, the + * object must be of type XFileDataNode. + */ bool XFileDataNode:: is_standard_object(const string &template_name) const { if (_template->is_standard() && @@ -66,12 +55,10 @@ is_standard_object(const string &template_name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNode::get_type_name -// Access: Public, Virtual -// Description: Returns a string that represents the type of object -// this data object represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that represents the type of object this data object + * represents. + */ string XFileDataNode:: get_type_name() const { return _template->get_name(); diff --git a/pandatool/src/xfile/xFileDataNode.h b/pandatool/src/xfile/xFileDataNode.h index f0953dc115..78bf6da05d 100644 --- a/pandatool/src/xfile/xFileDataNode.h +++ b/pandatool/src/xfile/xFileDataNode.h @@ -1,16 +1,15 @@ -// Filename: xFileDataNode.h -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNode.h + * @author drose + * @date 2004-10-08 + */ #ifndef XFILEDATANODE_H #define XFILEDATANODE_H @@ -22,17 +21,15 @@ #include "pointerTo.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataNode -// Description : This is an abstract base class for an XFileNode which -// is also an XFileDataObject. That is to say, objects -// that inherit from this class may be added to the -// toplevel X file graph as nodes, and they also may be -// containers for data elements. -// -// Specifically, this is the base class of both -// XFileDataNodeTemplate and XFileDataNodeReference. -//////////////////////////////////////////////////////////////////// +/** + * This is an abstract base class for an XFileNode which is also an + * XFileDataObject. That is to say, objects that inherit from this class may + * be added to the toplevel X file graph as nodes, and they also may be + * containers for data elements. + * + * Specifically, this is the base class of both XFileDataNodeTemplate and + * XFileDataNodeReference. + */ class XFileDataNode : public XFileNode, public XFileDataObject { public: XFileDataNode(XFile *x_file, const string &name, @@ -73,7 +70,3 @@ private: #include "xFileDataNode.I" #endif - - - - diff --git a/pandatool/src/xfile/xFileDataNodeReference.I b/pandatool/src/xfile/xFileDataNodeReference.I index 7f4339a8d5..ea98beecee 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.I +++ b/pandatool/src/xfile/xFileDataNodeReference.I @@ -1,23 +1,19 @@ -// Filename: xFileDataNodeReference.I -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeReference.I + * @author drose + * @date 2004-10-08 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::get_object -// Access: Public -// Description: Returns the actual data object being referenced. -//////////////////////////////////////////////////////////////////// +/** + * Returns the actual data object being referenced. + */ INLINE XFileDataNodeTemplate *XFileDataNodeReference:: get_object() const { return _object; diff --git a/pandatool/src/xfile/xFileDataNodeReference.cxx b/pandatool/src/xfile/xFileDataNodeReference.cxx index 500ce64dad..157acdbba6 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.cxx +++ b/pandatool/src/xfile/xFileDataNodeReference.cxx @@ -1,116 +1,93 @@ -// Filename: xFileDataNodeReference.cxx -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeReference.cxx + * @author drose + * @date 2004-10-08 + */ #include "xFileDataNodeReference.h" #include "indent.h" TypeHandle XFileDataNodeReference::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataNodeReference:: XFileDataNodeReference(XFileDataNodeTemplate *object) : XFileDataNode(object->get_x_file(), object->get_name(), object->get_template()), _object(object) { - // We steal a copy of the referenced object's children. This is - // just a one-time copy, so if you go and change the list of - // children of the referenced object, it won't be reflected here in - // the reference. Since presumably the reference is only used when - // parsing static files, that shouldn't be a problem; but you do - // need to be aware of it. + // We steal a copy of the referenced object's children. This is just a one- + // time copy, so if you go and change the list of children of the referenced + // object, it won't be reflected here in the reference. Since presumably + // the reference is only used when parsing static files, that shouldn't be a + // problem; but you do need to be aware of it. _children = object->_children; _objects = object->_objects; _children_by_name = object->_children_by_name; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::is_reference -// Access: Public, Virtual -// Description: Returns true if this node represents an indirect -// reference to an object defined previously in the -// file. References are generally transparent, so in -// most cases you never need to call this, unless you -// actually need to differentiate between references and -// instances; you can simply use the reference node as -// if it were itself the object it references. -// -// If this returns true, the node must be of type -// XFileDataNodeReference. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents an indirect reference to an object + * defined previously in the file. References are generally transparent, so + * in most cases you never need to call this, unless you actually need to + * differentiate between references and instances; you can simply use the + * reference node as if it were itself the object it references. + * + * If this returns true, the node must be of type XFileDataNodeReference. + */ bool XFileDataNodeReference:: is_reference() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::is_complex_object -// Access: Public, Virtual -// Description: Returns true if this kind of data object is a complex -// object that can hold nested data elements, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of data object is a complex object that can hold + * nested data elements, false otherwise. + */ bool XFileDataNodeReference:: is_complex_object() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataNodeReference:: write_text(ostream &out, int indent_level) const { indent(out, indent_level) << "{ " << _object->get_name() << " }\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::get_num_elements -// Access: Protected, Virtual -// Description: Returns the number of nested data elements within the -// object. This may be, e.g. the size of the array, if -// it is an array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested data elements within the object. This may be, + * e.g. the size of the array, if it is an array. + */ int XFileDataNodeReference:: get_num_elements() const { return _object->size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::get_element -// Access: Protected, Virtual -// Description: Returns the nth nested data element within the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested data element within the object. + */ XFileDataObject *XFileDataNodeReference:: get_element(int n) { return &((*_object)[n]); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeReference::get_element -// Access: Protected, Virtual -// Description: Returns the nested data element within the -// object that has the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nested data element within the object that has the indicated + * name. + */ XFileDataObject *XFileDataNodeReference:: get_element(const string &name) { return &((*_object)[name]); diff --git a/pandatool/src/xfile/xFileDataNodeReference.h b/pandatool/src/xfile/xFileDataNodeReference.h index 0435d73679..294b8a105d 100644 --- a/pandatool/src/xfile/xFileDataNodeReference.h +++ b/pandatool/src/xfile/xFileDataNodeReference.h @@ -1,16 +1,15 @@ -// Filename: xFileDataNodeReference.h -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeReference.h + * @author drose + * @date 2004-10-08 + */ #ifndef XFILEDATANODEREFERENCE_H #define XFILEDATANODEREFERENCE_H @@ -19,15 +18,14 @@ #include "xFileDataNodeTemplate.h" #include "pointerTo.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataNodeReference -// Description : This is a nested reference to an instance of a -// template object, declared via the syntax: -// -// { InstanceName } -// -// in the X File. -//////////////////////////////////////////////////////////////////// +/** + * This is a nested reference to an instance of a template object, declared + * via the syntax: + * + * { InstanceName } + * + * in the X File. + */ class XFileDataNodeReference : public XFileDataNode { public: XFileDataNodeReference(XFileDataNodeTemplate *object); @@ -69,7 +67,3 @@ private: #include "xFileDataNodeReference.I" #endif - - - - diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.I b/pandatool/src/xfile/xFileDataNodeTemplate.I index baaf26f0f8..5e3f660454 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.I +++ b/pandatool/src/xfile/xFileDataNodeTemplate.I @@ -1,14 +1,12 @@ -// Filename: xFileDataNodeTemplate.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeTemplate.I + * @author drose + * @date 2004-10-03 + */ diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.cxx b/pandatool/src/xfile/xFileDataNodeTemplate.cxx index 34dc63f2b5..1e0e153438 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.cxx +++ b/pandatool/src/xfile/xFileDataNodeTemplate.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataNodeTemplate.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeTemplate.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileDataNodeTemplate.h" #include "indent.h" @@ -20,11 +19,9 @@ TypeHandle XFileDataNodeTemplate::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataNodeTemplate:: XFileDataNodeTemplate(XFile *x_file, const string &name, XFileTemplate *xtemplate) : @@ -32,36 +29,27 @@ XFileDataNodeTemplate(XFile *x_file, const string &name, { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::zero_fill -// Access: Public -// Description: Fills the data node with zero-valued elements -// appropriate to the template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the data node with zero-valued elements appropriate to the template. + */ void XFileDataNodeTemplate:: zero_fill() { _template->fill_zero_data(this); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::is_complex_object -// Access: Public, Virtual -// Description: Returns true if this kind of data object is a complex -// object that can hold nested data elements, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of data object is a complex object that can hold + * nested data elements, false otherwise. + */ bool XFileDataNodeTemplate:: is_complex_object() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::add_parse_double -// Access: Public -// Description: Adds the indicated list of doubles as a data element -// encountered in the parser. It will later be -// processed by finalize_parse_data(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated list of doubles as a data element encountered in the + * parser. It will later be processed by finalize_parse_data(). + */ void XFileDataNodeTemplate:: add_parse_double(PTA_double double_list) { XFileParseData pdata; @@ -71,13 +59,10 @@ add_parse_double(PTA_double double_list) { _parse_data_list._list.push_back(pdata); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::add_parse_int -// Access: Public -// Description: Adds the indicated list of ints as a data element -// encountered in the parser. It will later be -// processed by finalize_parse_data(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated list of ints as a data element encountered in the + * parser. It will later be processed by finalize_parse_data(). + */ void XFileDataNodeTemplate:: add_parse_int(PTA_int int_list) { XFileParseData pdata; @@ -87,13 +72,10 @@ add_parse_int(PTA_int int_list) { _parse_data_list._list.push_back(pdata); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::add_parse_string -// Access: Public -// Description: Adds the indicated string as a data element -// encountered in the parser. It will later be -// processed by finalize_parse_data(). -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated string as a data element encountered in the parser. It + * will later be processed by finalize_parse_data(). + */ void XFileDataNodeTemplate:: add_parse_string(const string &str) { XFileParseData pdata; @@ -103,25 +85,22 @@ add_parse_string(const string &str) { _parse_data_list._list.push_back(pdata); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::finalize_parse_data -// Access: Public -// Description: Processes all of the data elements added by -// add_parse_*(), checks them for syntactic and semantic -// correctness against the Template definition, and -// stores the appropriate child data elements. Returns -// true on success, false if there is a mismatch. -//////////////////////////////////////////////////////////////////// +/** + * Processes all of the data elements added by add_parse_*(), checks them for + * syntactic and semantic correctness against the Template definition, and + * stores the appropriate child data elements. Returns true on success, false + * if there is a mismatch. + */ bool XFileDataNodeTemplate:: finalize_parse_data() { - // Recursively walk through our template definition, while - // simultaneously walking through the list of parse data elements we - // encountered, and re-pack them as actual nested elements. + // Recursively walk through our template definition, while simultaneously + // walking through the list of parse data elements we encountered, and re- + // pack them as actual nested elements. PrevData prev_data; size_t index = 0; size_t sub_index = 0; - if (!_template->repack_data(this, _parse_data_list, + if (!_template->repack_data(this, _parse_data_list, prev_data, index, sub_index)) { return false; } @@ -129,30 +108,24 @@ finalize_parse_data() { if (index != _parse_data_list._list.size()) { xyywarning("Too many data elements in structure."); } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::add_element -// Access: Public, Virtual -// Description: Adds the indicated element as a nested data element, -// if this data object type supports it. Returns true -// if added successfully, false if the data object type -// does not support nested data elements. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated element as a nested data element, if this data object + * type supports it. Returns true if added successfully, false if the data + * object type does not support nested data elements. + */ bool XFileDataNodeTemplate:: add_element(XFileDataObject *element) { _nested_elements.push_back(element); return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataNodeTemplate:: write_text(ostream &out, int indent_level) const { indent(out, indent_level) @@ -172,12 +145,9 @@ write_text(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataNodeTemplate:: write_data(ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { @@ -185,8 +155,7 @@ write_data(ostream &out, int indent_level, const char *separator) const { for (size_t i = 0; i < _nested_elements.size() - 1; i++) { XFileDataObject *object = _nested_elements[i]; if (object->is_complex_object()) { - // If we have a "complex" nested object, output it on its own - // line. + // If we have a "complex" nested object, output it on its own line. if (indented) { out << "\n"; indented = false; @@ -203,8 +172,8 @@ write_data(ostream &out, int indent_level, const char *separator) const { } } - // The last object is the set is different, because it gets - // separator appended to it, and it always gets a newline. + // The last object is the set is different, because it gets separator + // appended to it, and it always gets a newline. XFileDataObject *object = _nested_elements.back(); if (object->is_complex_object()) { if (indented) { @@ -222,36 +191,28 @@ write_data(ostream &out, int indent_level, const char *separator) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::get_num_elements -// Access: Protected, Virtual -// Description: Returns the number of nested data elements within the -// object. This may be, e.g. the size of the array, if -// it is an array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested data elements within the object. This may be, + * e.g. the size of the array, if it is an array. + */ int XFileDataNodeTemplate:: get_num_elements() const { return _nested_elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::get_element -// Access: Protected, Virtual -// Description: Returns the nth nested data element within the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested data element within the object. + */ XFileDataObject *XFileDataNodeTemplate:: get_element(int n) { nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); return _nested_elements[n]; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataNodeTemplate::get_element -// Access: Protected, Virtual -// Description: Returns the nested data element within the -// object that has the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nested data element within the object that has the indicated + * name. + */ XFileDataObject *XFileDataNodeTemplate:: get_element(const string &name) { int child_index = _template->find_child_index(name); diff --git a/pandatool/src/xfile/xFileDataNodeTemplate.h b/pandatool/src/xfile/xFileDataNodeTemplate.h index 33dd350c60..32c3a74460 100644 --- a/pandatool/src/xfile/xFileDataNodeTemplate.h +++ b/pandatool/src/xfile/xFileDataNodeTemplate.h @@ -1,16 +1,15 @@ -// Filename: xFileDataNodeTemplate.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataNodeTemplate.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILEDATANODETEMPLATE_H #define XFILEDATANODETEMPLATE_H @@ -23,14 +22,11 @@ #include "pta_int.h" #include "pta_double.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataNodeTemplate -// Description : This is a node which contains all of the data -// elements defined by a template. See XFileTemplate -// for the definition of the template; this class only -// contains the data members for a particular instance -// of a template. -//////////////////////////////////////////////////////////////////// +/** + * This is a node which contains all of the data elements defined by a + * template. See XFileTemplate for the definition of the template; this class + * only contains the data members for a particular instance of a template. + */ class XFileDataNodeTemplate : public XFileDataNode { public: XFileDataNodeTemplate(XFile *x_file, const string &name, @@ -58,7 +54,7 @@ protected: private: XFileParseDataList _parse_data_list; - + typedef pvector< PT(XFileDataObject) > NestedElements; NestedElements _nested_elements; @@ -83,7 +79,3 @@ private: #include "xFileDataNodeTemplate.I" #endif - - - - diff --git a/pandatool/src/xfile/xFileDataObject.I b/pandatool/src/xfile/xFileDataObject.I index f5e7dd8e7a..ebe25becc1 100644 --- a/pandatool/src/xfile/xFileDataObject.I +++ b/pandatool/src/xfile/xFileDataObject.I @@ -1,266 +1,208 @@ -// Filename: xFileDataObject.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObject.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileDataObject:: XFileDataObject(const XFileDataDef *data_def) : _data_def(data_def) { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_data_def -// Access: Public -// Description: Returns the data object that this object is -// represented by, if any, or NULL if there is none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the data object that this object is represented by, if any, or NULL + * if there is none. + */ INLINE const XFileDataDef *XFileDataObject:: get_data_def() const { return _data_def; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (int) -// Access: Public -// Description: Stores the indicated integer value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that cannot accept an integer value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated integer value into the object, if it makes sense to do + * so. It is an error to call this on an object that cannot accept an integer + * value. + */ INLINE void XFileDataObject:: operator = (int int_value) { set(int_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (double) -// Access: Public -// Description: Stores the indicated floating-point value into the -// object, if it makes sense to do so. It is an error -// to call this on an object that cannot accept a -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated floating-point value into the object, if it makes + * sense to do so. It is an error to call this on an object that cannot + * accept a floating-point value. + */ INLINE void XFileDataObject:: operator = (double double_value) { set(double_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (string) -// Access: Public -// Description: Stores the indicated string value into the -// object, if it makes sense to do so. It is an error -// to call this on an object that cannot accept a -// string value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated string value into the object, if it makes sense to do + * so. It is an error to call this on an object that cannot accept a string + * value. + */ INLINE void XFileDataObject:: operator = (const string &string_value) { set(string_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (vec2) -// Access: Public -// Description: Stores the indicated Vec2 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store two -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec2 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store two + * floating-point values. + */ INLINE void XFileDataObject:: operator = (const LVecBase2d &vec) { set(vec); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (vec3) -// Access: Public -// Description: Stores the indicated Vec3 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store three -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec3 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store three + * floating-point values. + */ INLINE void XFileDataObject:: operator = (const LVecBase3d &vec) { set(vec); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (vec4) -// Access: Public -// Description: Stores the indicated Vec4 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store four -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec4 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store four + * floating-point values. + */ INLINE void XFileDataObject:: operator = (const LVecBase4d &vec) { set(vec); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator = (mat) -// Access: Public -// Description: Stores the indicated Matrix value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store sixteen -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Matrix value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store sixteen + * floating-point values. + */ INLINE void XFileDataObject:: operator = (const LMatrix4d &mat) { set(mat); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(int) -// Access: Public -// Description: Stores the indicated integer value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that cannot accept an integer value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated integer value into the object, if it makes sense to do + * so. It is an error to call this on an object that cannot accept an integer + * value. + */ INLINE void XFileDataObject:: set(int int_value) { set_int_value(int_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(double) -// Access: Public -// Description: Stores the indicated floating-point value into the -// object, if it makes sense to do so. It is an error -// to call this on an object that cannot accept a -// floating-point value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated floating-point value into the object, if it makes + * sense to do so. It is an error to call this on an object that cannot + * accept a floating-point value. + */ INLINE void XFileDataObject:: set(double double_value) { set_double_value(double_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(string) -// Access: Public -// Description: Stores the indicated string value into the -// object, if it makes sense to do so. It is an error -// to call this on an object that cannot accept a -// string value. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated string value into the object, if it makes sense to do + * so. It is an error to call this on an object that cannot accept a string + * value. + */ INLINE void XFileDataObject:: set(const string &string_value) { set_string_value(string_value); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(vec2) -// Access: Public -// Description: Stores the indicated Vec2 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store two -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec2 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store two + * floating-point values. + */ INLINE void XFileDataObject:: set(const LVecBase2d &vec) { store_double_array(2, vec.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(vec3) -// Access: Public -// Description: Stores the indicated Vec3 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store three -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec3 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store three + * floating-point values. + */ INLINE void XFileDataObject:: set(const LVecBase3d &vec) { store_double_array(3, vec.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(vec4) -// Access: Public -// Description: Stores the indicated Vec4 value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store four -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Vec4 value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store four + * floating-point values. + */ INLINE void XFileDataObject:: set(const LVecBase4d &vec) { store_double_array(4, vec.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set(mat) -// Access: Public -// Description: Stores the indicated Matrix value into the object, -// if it makes sense to do so. It is an error to call -// this on an object that does not store sixteen -// floating-point values. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated Matrix value into the object, if it makes sense to do + * so. It is an error to call this on an object that does not store sixteen + * floating-point values. + */ INLINE void XFileDataObject:: set(const LMatrix4d &mat) { store_double_array(16, mat.get_data()); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::i -// Access: Public -// Description: Unambiguously returns the object's representation as -// an integer, or 0 if the object has no integer -// representation. See also get_data_def() to determine -// what kind of representation this object has. -//////////////////////////////////////////////////////////////////// +/** + * Unambiguously returns the object's representation as an integer, or 0 if + * the object has no integer representation. See also get_data_def() to + * determine what kind of representation this object has. + */ INLINE int XFileDataObject:: i() const { return get_int_value(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::d -// Access: Public -// Description: Unambiguously returns the object's representation as -// a double, or 0.0 if the object has no double -// representation. See also get_data_def() to determine -// what kind of representation this object has. -//////////////////////////////////////////////////////////////////// +/** + * Unambiguously returns the object's representation as a double, or 0.0 if + * the object has no double representation. See also get_data_def() to + * determine what kind of representation this object has. + */ INLINE double XFileDataObject:: d() const { return get_double_value(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::s -// Access: Public -// Description: Unambiguously returns the object's representation as -// a string, or empty string if the object has no string -// representation. See also get_data_def() to determine -// what kind of representation this object has. -//////////////////////////////////////////////////////////////////// +/** + * Unambiguously returns the object's representation as a string, or empty + * string if the object has no string representation. See also get_data_def() + * to determine what kind of representation this object has. + */ INLINE string XFileDataObject:: s() const { return get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::vec2 -// Access: Public -// Description: Returns the object's representation as an LVecBase2d. -// It is an error if the object does not have two nested -// objects that store a double value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an LVecBase2d. It is an error if + * the object does not have two nested objects that store a double value. + */ INLINE LVecBase2d XFileDataObject:: vec2() const { LVecBase2d vec; @@ -268,13 +210,10 @@ vec2() const { return vec; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::vec3 -// Access: Public -// Description: Returns the object's representation as an LVecBase3d. -// It is an error if the object does not have three nested -// objects that store a double value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an LVecBase3d. It is an error if + * the object does not have three nested objects that store a double value. + */ INLINE LVecBase3d XFileDataObject:: vec3() const { LVecBase3d vec; @@ -282,13 +221,10 @@ vec3() const { return vec; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::vec4 -// Access: Public -// Description: Returns the object's representation as an LVecBase4d. -// It is an error if the object does not have four nested -// objects that store a double value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an LVecBase4d. It is an error if + * the object does not have four nested objects that store a double value. + */ INLINE LVecBase4d XFileDataObject:: vec4() const { LVecBase4d vec; @@ -296,13 +232,10 @@ vec4() const { return vec; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::mat4 -// Access: Public -// Description: Returns the object's representation as an LMatrix4d. -// It is an error if the object does not have sixteen -// nested objects that store a double value. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an LMatrix4d. It is an error if the + * object does not have sixteen nested objects that store a double value. + */ INLINE LMatrix4d XFileDataObject:: mat4() const { LMatrix4d mat; @@ -310,24 +243,18 @@ mat4() const { return mat; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::size -// Access: Public -// Description: Returns the number of nested data objects within this -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested data objects within this object. + */ INLINE int XFileDataObject:: size() const { return get_num_elements(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator [] (int) -// Access: Public -// Description: Returns the nth nested object within this object. -// Call get_num_children() to determine the number of -// nested objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested object within this object. Call get_num_children() + * to determine the number of nested objects. + */ INLINE const XFileDataObject &XFileDataObject:: operator [] (int n) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(n); @@ -335,13 +262,11 @@ operator [] (int n) const { return *element; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator [] (string) -// Access: Public -// Description: Returns the named nested object within this object. -// It is an error if the named object does not exist. -// Call find_child() instead if there is any doubt. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named nested object within this object. It is an error if the + * named object does not exist. Call find_child() instead if there is any + * doubt. + */ INLINE const XFileDataObject &XFileDataObject:: operator [] (const string &name) const { const XFileDataObject *element = ((XFileDataObject *)this)->get_element(name); @@ -349,13 +274,10 @@ operator [] (const string &name) const { return *element; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator [] (int) -// Access: Public -// Description: Returns the nth nested object within this object. -// Call get_num_children() to determine the number of -// nested objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested object within this object. Call get_num_children() + * to determine the number of nested objects. + */ INLINE XFileDataObject &XFileDataObject:: operator [] (int n) { XFileDataObject *element = get_element(n); @@ -363,13 +285,11 @@ operator [] (int n) { return *element; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::operator [] (string) -// Access: Public -// Description: Returns the named nested object within this object. -// It is an error if the named object does not exist. -// Call find_child() instead if there is any doubt. -//////////////////////////////////////////////////////////////////// +/** + * Returns the named nested object within this object. It is an error if the + * named object does not exist. Call find_child() instead if there is any + * doubt. + */ INLINE XFileDataObject &XFileDataObject:: operator [] (const string &name) { XFileDataObject *element = get_element(name); diff --git a/pandatool/src/xfile/xFileDataObject.cxx b/pandatool/src/xfile/xFileDataObject.cxx index 9a0d0b8acd..e170b901ea 100644 --- a/pandatool/src/xfile/xFileDataObject.cxx +++ b/pandatool/src/xfile/xFileDataObject.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataObject.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObject.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileDataObject.h" #include "xFileTemplate.h" @@ -24,96 +23,78 @@ TypeHandle XFileDataObject::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataObject:: ~XFileDataObject() { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::is_complex_object -// Access: Public, Virtual -// Description: Returns true if this kind of data object is a complex -// object that can hold nested data elements, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of data object is a complex object that can hold + * nested data elements, false otherwise. + */ bool XFileDataObject:: is_complex_object() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_type_name -// Access: Public, Virtual -// Description: Returns a string that represents the type of object -// this data object represents. -//////////////////////////////////////////////////////////////////// +/** + * Returns a string that represents the type of object this data object + * represents. + */ string XFileDataObject:: get_type_name() const { return get_type().get_name(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_int -// Access: Public -// Description: Appends a new integer value to the data object, if it -// makes sense to do so. Normally, this is valid only -// for a DataObjectArray, or in certain special cases for -// a DataNodeTemplate. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new integer value to the data object, if it makes sense to do so. + * Normally, this is valid only for a DataObjectArray, or in certain special + * cases for a DataNodeTemplate. + */ XFileDataObject &XFileDataObject:: add_int(int int_value) { - XFileDataObject *object = + XFileDataObject *object = new XFileDataObjectInteger(get_data_def(), int_value); add_element(object); return *object; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_double -// Access: Public -// Description: Appends a new floating-point value to the data -// object, if it makes sense to do so. Normally, this -// is valid only for a DataObjectArray, or in certain -// special cases for a DataNodeTemplate. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new floating-point value to the data object, if it makes sense to + * do so. Normally, this is valid only for a DataObjectArray, or in certain + * special cases for a DataNodeTemplate. + */ XFileDataObject &XFileDataObject:: add_double(double double_value) { - XFileDataObject *object = + XFileDataObject *object = new XFileDataObjectDouble(get_data_def(), double_value); add_element(object); return *object; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_string -// Access: Public -// Description: Appends a new string value to the data object, if it -// makes sense to do so. Normally, this is valid only -// for a DataObjectArray, or in certain special cases for -// a DataNodeTemplate. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new string value to the data object, if it makes sense to do so. + * Normally, this is valid only for a DataObjectArray, or in certain special + * cases for a DataNodeTemplate. + */ XFileDataObject &XFileDataObject:: add_string(const string &string_value) { - XFileDataObject *object = + XFileDataObject *object = new XFileDataObjectString(get_data_def(), string_value); add_element(object); return *object; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_Vector -// Access: Public -// Description: Appends a new Vector instance. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new Vector instance. + */ XFileDataObject &XFileDataObject:: add_Vector(XFile *x_file, const LVecBase3d &vector) { XFileTemplate *xtemplate = XFile::find_standard_template("Vector"); nassertr(xtemplate != (XFileTemplate *)NULL, *this); - XFileDataNodeTemplate *node = + XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); node->zero_fill(); @@ -123,16 +104,14 @@ add_Vector(XFile *x_file, const LVecBase3d &vector) { return *node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_MeshFace -// Access: Public -// Description: Appends a new MeshFace instance. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new MeshFace instance. + */ XFileDataObject &XFileDataObject:: add_MeshFace(XFile *x_file) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshFace"); nassertr(xtemplate != (XFileTemplate *)NULL, *this); - XFileDataNodeTemplate *node = + XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); node->zero_fill(); @@ -140,16 +119,14 @@ add_MeshFace(XFile *x_file) { return *node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_IndexedColor -// Access: Public -// Description: Appends a new IndexedColor instance. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new IndexedColor instance. + */ XFileDataObject &XFileDataObject:: add_IndexedColor(XFile *x_file, int index, const LColor &color) { XFileTemplate *xtemplate = XFile::find_standard_template("IndexedColor"); nassertr(xtemplate != (XFileTemplate *)NULL, *this); - XFileDataNodeTemplate *node = + XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); node->zero_fill(); @@ -160,16 +137,14 @@ add_IndexedColor(XFile *x_file, int index, const LColor &color) { return *node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_Coords2d -// Access: Public -// Description: Appends a new Coords2d instance. -//////////////////////////////////////////////////////////////////// +/** + * Appends a new Coords2d instance. + */ XFileDataObject &XFileDataObject:: add_Coords2d(XFile *x_file, const LVecBase2d &coords) { XFileTemplate *xtemplate = XFile::find_standard_template("Coords2d"); nassertr(xtemplate != (XFileTemplate *)NULL, *this); - XFileDataNodeTemplate *node = + XFileDataNodeTemplate *node = new XFileDataNodeTemplate(x_file, "", xtemplate); add_element(node); node->zero_fill(); @@ -179,91 +154,70 @@ add_Coords2d(XFile *x_file, const LVecBase2d &coords) { return *node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::add_element -// Access: Public, Virtual -// Description: Adds the indicated element as a nested data element, -// if this data object type supports it. Returns true -// if added successfully, false if the data object type -// does not support nested data elements. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated element as a nested data element, if this data object + * type supports it. Returns true if added successfully, false if the data + * object type does not support nested data elements. + */ bool XFileDataObject:: add_element(XFileDataObject *element) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::output_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObject:: output_data(ostream &out) const { out << "(" << get_type() << "::output_data() not implemented.)"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObject:: write_data(ostream &out, int indent_level, const char *) const { indent(out, indent_level) << "(" << get_type() << "::write_data() not implemented.)\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set_int_value -// Access: Protected, Virtual -// Description: Sets the object's value as an integer, if this is -// legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as an integer, if this is legal. + */ void XFileDataObject:: set_int_value(int int_value) { xfile_cat.error() << get_type_name() << " does not support integer values.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set_double_value -// Access: Protected, Virtual -// Description: Sets the object's value as a floating-point number, -// if this is legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as a floating-point number, if this is legal. + */ void XFileDataObject:: set_double_value(double double_value) { xfile_cat.error() << get_type_name() << " does not support floating-point values.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::set_string_value -// Access: Protected, Virtual -// Description: Sets the object's value as a string, if this is -// legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as a string, if this is legal. + */ void XFileDataObject:: set_string_value(const string &string_value) { xfile_cat.error() << get_type_name() << " does not support string values.\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::store_double_array -// Access: Protected -// Description: Stores the indicated array of doubles in the nested -// elements within this object. There must be exactly -// the indicated number of nested values, and they must -// all accept a double. -//////////////////////////////////////////////////////////////////// +/** + * Stores the indicated array of doubles in the nested elements within this + * object. There must be exactly the indicated number of nested values, and + * they must all accept a double. + */ void XFileDataObject:: store_double_array(int num_elements, const double *values) { if (get_num_elements() != num_elements) { xfile_cat.error() - << get_type_name() << " does not accept " + << get_type_name() << " does not accept " << num_elements << " values.\n"; return; } @@ -274,52 +228,40 @@ store_double_array(int num_elements, const double *values) { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_int_value -// Access: Protected, Virtual -// Description: Returns the object's representation as an integer, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an integer, if it has one. + */ int XFileDataObject:: get_int_value() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_double_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a double, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a double, if it has one. + */ double XFileDataObject:: get_double_value() const { return 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_string_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a string, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a string, if it has one. + */ string XFileDataObject:: get_string_value() const { return string(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_double_array -// Access: Protected -// Description: Fills the indicated array of doubles with the values -// from the nested elements within this object. There -// must be exactly the indicated number of nested -// values, and they must all return a double. -//////////////////////////////////////////////////////////////////// +/** + * Fills the indicated array of doubles with the values from the nested + * elements within this object. There must be exactly the indicated number of + * nested values, and they must all return a double. + */ void XFileDataObject:: get_double_array(int num_elements, double *values) const { if (get_num_elements() != num_elements) { xfile_cat.error() - << get_type_name() << " does not contain " + << get_type_name() << " does not contain " << num_elements << " values.\n"; return; } @@ -329,42 +271,34 @@ get_double_array(int num_elements, double *values) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_num_elements -// Access: Protected, Virtual -// Description: Returns the number of nested data elements within the -// object. This may be, e.g. the size of the array, if -// it is an array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested data elements within the object. This may be, + * e.g. the size of the array, if it is an array. + */ int XFileDataObject:: get_num_elements() const { return 0; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_element -// Access: Protected, Virtual -// Description: Returns the nth nested data element within the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested data element within the object. + */ XFileDataObject *XFileDataObject:: get_element(int n) { xfile_cat.warning() - << "Looking for [" << n << "] within data object of type " + << "Looking for [" << n << "] within data object of type " << get_type_name() << ", does not support nested objects.\n"; return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObject::get_element -// Access: Protected, Virtual -// Description: Returns the nested data element within the -// object that has the indicated name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nested data element within the object that has the indicated + * name. + */ XFileDataObject *XFileDataObject:: get_element(const string &name) { xfile_cat.warning() - << "Looking for [\"" << name << "\"] within data object of type " + << "Looking for [\"" << name << "\"] within data object of type " << get_type_name() << ", does not support nested objects.\n"; return NULL; } diff --git a/pandatool/src/xfile/xFileDataObject.h b/pandatool/src/xfile/xFileDataObject.h index 8cecf61dc1..ac7d8001f3 100644 --- a/pandatool/src/xfile/xFileDataObject.h +++ b/pandatool/src/xfile/xFileDataObject.h @@ -1,16 +1,15 @@ -// Filename: xFileDataObject.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObject.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILEDATAOBJECT_H #define XFILEDATAOBJECT_H @@ -24,12 +23,10 @@ class XFile; class XFileDataDef; -//////////////////////////////////////////////////////////////////// -// Class : XFileDataObject -// Description : The abstract base class for a number of different -// types of data elements that may be stored in the X -// file. -//////////////////////////////////////////////////////////////////// +/** + * The abstract base class for a number of different types of data elements + * that may be stored in the X file. + */ class XFileDataObject : virtual public ReferenceCount { public: INLINE XFileDataObject(const XFileDataDef *data_def = NULL); @@ -71,19 +68,19 @@ public: INLINE XFileDataObject &operator [] (int n); INLINE XFileDataObject &operator [] (const string &name); - // The following methods can be used to add elements of a specific - // type to a complex object, e.g. an array or a template object. + // The following methods can be used to add elements of a specific type to a + // complex object, e.g. an array or a template object. XFileDataObject &add_int(int int_value); XFileDataObject &add_double(double double_value); XFileDataObject &add_string(const string &string_value); - // The following methods can be used to add elements of a specific - // type, based on one of the standard templates. + // The following methods can be used to add elements of a specific type, + // based on one of the standard templates. XFileDataObject &add_Vector(XFile *x_file, const LVecBase3d &vector); XFileDataObject &add_MeshFace(XFile *x_file); - XFileDataObject &add_IndexedColor(XFile *x_file, int index, + XFileDataObject &add_IndexedColor(XFile *x_file, int index, const LColor &color); XFileDataObject &add_Coords2d(XFile *x_file, const LVecBase2d &coords); @@ -134,6 +131,3 @@ INLINE ostream &operator << (ostream &out, const XFileDataObject &data_object); #include "xFileDataObject.I" #endif - - - diff --git a/pandatool/src/xfile/xFileDataObjectArray.I b/pandatool/src/xfile/xFileDataObjectArray.I index b866c212e5..fefe7e60a8 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.I +++ b/pandatool/src/xfile/xFileDataObjectArray.I @@ -1,23 +1,19 @@ -// Filename: xFileDataObjectArray.I -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectArray.I + * @author drose + * @date 2004-10-07 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataObjectArray:: XFileDataObjectArray(const XFileDataDef *data_def) : XFileDataObject(data_def) diff --git a/pandatool/src/xfile/xFileDataObjectArray.cxx b/pandatool/src/xfile/xFileDataObjectArray.cxx index 7649b9bf05..90d9948860 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.cxx +++ b/pandatool/src/xfile/xFileDataObjectArray.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectArray.cxx -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectArray.cxx + * @author drose + * @date 2004-10-07 + */ #include "xFileDataObjectArray.h" #include "string_utils.h" @@ -18,38 +17,29 @@ TypeHandle XFileDataObjectArray::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::is_complex_object -// Access: Public, Virtual -// Description: Returns true if this kind of data object is a complex -// object that can hold nested data elements, false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this kind of data object is a complex object that can hold + * nested data elements, false otherwise. + */ bool XFileDataObjectArray:: is_complex_object() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::add_element -// Access: Public, Virtual -// Description: Adds the indicated element as a nested data element, -// if this data object type supports it. Returns true -// if added successfully, false if the data object type -// does not support nested data elements. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated element as a nested data element, if this data object + * type supports it. Returns true if added successfully, false if the data + * object type does not support nested data elements. + */ bool XFileDataObjectArray:: add_element(XFileDataObject *element) { _nested_elements.push_back(element); return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectArray:: write_data(ostream &out, int indent_level, const char *separator) const { if (!_nested_elements.empty()) { @@ -58,8 +48,8 @@ write_data(ostream &out, int indent_level, const char *separator) const { XFileDataObject *object = _nested_elements[i]; if (object->is_complex_object() || _nested_elements.size() > 16) { - // If we have a "complex" nested object, or more than 16 - // elements in the array, output it on its own line. + // If we have a "complex" nested object, or more than 16 elements in + // the array, output it on its own line. if (indented) { out << "\n"; indented = false; @@ -76,8 +66,8 @@ write_data(ostream &out, int indent_level, const char *separator) const { } } - // The last object in the set is different, because it gets - // separator instead of a semicolon, and it always gets a newline. + // The last object in the set is different, because it gets separator + // instead of a semicolon, and it always gets a newline. XFileDataObject *object = _nested_elements.back(); if (object->is_complex_object()) { if (indented) { @@ -94,24 +84,18 @@ write_data(ostream &out, int indent_level, const char *separator) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::get_num_elements -// Access: Protected, Virtual -// Description: Returns the number of nested data elements within the -// object. This may be, e.g. the size of the array, if -// it is an array. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of nested data elements within the object. This may be, + * e.g. the size of the array, if it is an array. + */ int XFileDataObjectArray:: get_num_elements() const { return _nested_elements.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectArray::get_element -// Access: Protected, Virtual -// Description: Returns the nth nested data element within the -// object. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth nested data element within the object. + */ XFileDataObject *XFileDataObjectArray:: get_element(int n) { nassertr(n >= 0 && n < (int)_nested_elements.size(), NULL); diff --git a/pandatool/src/xfile/xFileDataObjectArray.h b/pandatool/src/xfile/xFileDataObjectArray.h index e252fb21ed..e42df7845d 100644 --- a/pandatool/src/xfile/xFileDataObjectArray.h +++ b/pandatool/src/xfile/xFileDataObjectArray.h @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectArray.h -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectArray.h + * @author drose + * @date 2004-10-07 + */ #ifndef XFILEDATAOBJECTARRAY_H #define XFILEDATAOBJECTARRAY_H @@ -18,10 +17,9 @@ #include "pandatoolbase.h" #include "xFileDataObject.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataObjectArray -// Description : An array of nested data elements. -//////////////////////////////////////////////////////////////////// +/** + * An array of nested data elements. + */ class XFileDataObjectArray : public XFileDataObject { public: INLINE XFileDataObjectArray(const XFileDataDef *data_def); @@ -40,7 +38,7 @@ protected: private: typedef pvector< PT(XFileDataObject) > NestedElements; NestedElements _nested_elements; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/pandatool/src/xfile/xFileDataObjectDouble.I b/pandatool/src/xfile/xFileDataObjectDouble.I index 40a42c4253..339d3b0848 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.I +++ b/pandatool/src/xfile/xFileDataObjectDouble.I @@ -1,14 +1,12 @@ -// Filename: xFileDataObjectDouble.I -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectDouble.I + * @author drose + * @date 2004-10-07 + */ diff --git a/pandatool/src/xfile/xFileDataObjectDouble.cxx b/pandatool/src/xfile/xFileDataObjectDouble.cxx index 8b9276724f..3abd4fa909 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.cxx +++ b/pandatool/src/xfile/xFileDataObjectDouble.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectDouble.cxx -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectDouble.cxx + * @author drose + * @date 2004-10-07 + */ #include "xFileDataObjectDouble.h" #include "string_utils.h" @@ -18,11 +17,9 @@ TypeHandle XFileDataObjectDouble::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataObjectDouble:: XFileDataObjectDouble(const XFileDataDef *data_def, double value) : XFileDataObject(data_def), @@ -30,86 +27,65 @@ XFileDataObjectDouble(const XFileDataDef *data_def, double value) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::output_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectDouble:: output_data(ostream &out) const { out << get_string_value(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectDouble:: write_data(ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << get_string_value() << separator << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::set_int_value -// Access: Protected, Virtual -// Description: Sets the object's value as an integer, if this is -// legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as an integer, if this is legal. + */ void XFileDataObjectDouble:: set_int_value(int int_value) { _value = (double)int_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::set_double_value -// Access: Protected, Virtual -// Description: Sets the object's value as a floating-point number, -// if this is legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as a floating-point number, if this is legal. + */ void XFileDataObjectDouble:: set_double_value(double double_value) { _value = double_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::get_int_value -// Access: Protected, Virtual -// Description: Returns the object's representation as an integer, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an integer, if it has one. + */ int XFileDataObjectDouble:: get_int_value() const { return (int)_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::get_double_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a double, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a double, if it has one. + */ double XFileDataObjectDouble:: get_double_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectDouble::get_string_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a string, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a string, if it has one. + */ string XFileDataObjectDouble:: get_string_value() const { - // It's important to format with a decimal point, even if the value - // is integral, since the DirectX .x reader differentiates betweens - // doubles and integers on parsing. + // It's important to format with a decimal point, even if the value is + // integral, since the DirectX .x reader differentiates betweens doubles and + // integers on parsing. char buffer[128]; sprintf(buffer, "%f", _value); - + return buffer; } diff --git a/pandatool/src/xfile/xFileDataObjectDouble.h b/pandatool/src/xfile/xFileDataObjectDouble.h index 94dd00c10b..afa20ee859 100644 --- a/pandatool/src/xfile/xFileDataObjectDouble.h +++ b/pandatool/src/xfile/xFileDataObjectDouble.h @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectDouble.h -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectDouble.h + * @author drose + * @date 2004-10-07 + */ #ifndef XFILEDATAOBJECTDOUBLE_H #define XFILEDATAOBJECTDOUBLE_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "xFileDataObject.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataObjectDouble -// Description : An double-valued data element. This matches one -// double data member of a template, or a single -// element of an double array. -//////////////////////////////////////////////////////////////////// +/** + * An double-valued data element. This matches one double data member of a + * template, or a single element of an double array. + */ class XFileDataObjectDouble : public XFileDataObject { public: XFileDataObjectDouble(const XFileDataDef *data_def, double value); @@ -42,7 +39,7 @@ protected: private: double _value; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/pandatool/src/xfile/xFileDataObjectInteger.I b/pandatool/src/xfile/xFileDataObjectInteger.I index 86fd390616..07f27b7a8e 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.I +++ b/pandatool/src/xfile/xFileDataObjectInteger.I @@ -1,14 +1,12 @@ -// Filename: xFileDataObjectInteger.I -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectInteger.I + * @author drose + * @date 2004-10-07 + */ diff --git a/pandatool/src/xfile/xFileDataObjectInteger.cxx b/pandatool/src/xfile/xFileDataObjectInteger.cxx index be18220a9c..821363f339 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.cxx +++ b/pandatool/src/xfile/xFileDataObjectInteger.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectInteger.cxx -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectInteger.cxx + * @author drose + * @date 2004-10-07 + */ #include "xFileDataObjectInteger.h" #include "string_utils.h" @@ -18,11 +17,9 @@ TypeHandle XFileDataObjectInteger::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataObjectInteger:: XFileDataObjectInteger(const XFileDataDef *data_def, int value) : XFileDataObject(data_def), @@ -30,68 +27,50 @@ XFileDataObjectInteger(const XFileDataDef *data_def, int value) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::output_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectInteger:: output_data(ostream &out) const { out << _value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectInteger:: write_data(ostream &out, int indent_level, const char *separator) const { indent(out, indent_level) << _value << separator << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInt::set_int_value -// Access: Protected, Virtual -// Description: Sets the object's value as an integer, if this is -// legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as an integer, if this is legal. + */ void XFileDataObjectInteger:: set_int_value(int int_value) { _value = int_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::get_int_value -// Access: Protected, Virtual -// Description: Returns the object's representation as an integer, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as an integer, if it has one. + */ int XFileDataObjectInteger:: get_int_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::get_double_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a double, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a double, if it has one. + */ double XFileDataObjectInteger:: get_double_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectInteger::get_string_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a string, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a string, if it has one. + */ string XFileDataObjectInteger:: get_string_value() const { return format_string(_value); diff --git a/pandatool/src/xfile/xFileDataObjectInteger.h b/pandatool/src/xfile/xFileDataObjectInteger.h index 8fa96bcbfd..59e3ea13d3 100644 --- a/pandatool/src/xfile/xFileDataObjectInteger.h +++ b/pandatool/src/xfile/xFileDataObjectInteger.h @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectInteger.h -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectInteger.h + * @author drose + * @date 2004-10-07 + */ #ifndef XFILEDATAOBJECTINTEGER_H #define XFILEDATAOBJECTINTEGER_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "xFileDataObject.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataObjectInteger -// Description : An integer-valued data element. This matches one -// integer data member of a template, or a single -// element of an integer array. -//////////////////////////////////////////////////////////////////// +/** + * An integer-valued data element. This matches one integer data member of a + * template, or a single element of an integer array. + */ class XFileDataObjectInteger : public XFileDataObject { public: XFileDataObjectInteger(const XFileDataDef *data_def, int value); @@ -41,7 +38,7 @@ protected: private: int _value; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/pandatool/src/xfile/xFileDataObjectString.I b/pandatool/src/xfile/xFileDataObjectString.I index b46b95fa77..8e55118de7 100644 --- a/pandatool/src/xfile/xFileDataObjectString.I +++ b/pandatool/src/xfile/xFileDataObjectString.I @@ -1,14 +1,12 @@ -// Filename: xFileDataObjectString.I -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectString.I + * @author drose + * @date 2004-10-08 + */ diff --git a/pandatool/src/xfile/xFileDataObjectString.cxx b/pandatool/src/xfile/xFileDataObjectString.cxx index 8ee1e5c1e4..3425925b22 100644 --- a/pandatool/src/xfile/xFileDataObjectString.cxx +++ b/pandatool/src/xfile/xFileDataObjectString.cxx @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectString.cxx -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectString.cxx + * @author drose + * @date 2004-10-08 + */ #include "xFileDataObjectString.h" #include "string_utils.h" @@ -18,11 +17,9 @@ TypeHandle XFileDataObjectString::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileDataObjectString:: XFileDataObjectString(const XFileDataDef *data_def, const string &value) : XFileDataObject(data_def), @@ -30,23 +27,17 @@ XFileDataObjectString(const XFileDataDef *data_def, const string &value) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::output_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectString:: output_data(ostream &out) const { enquote_string(out); } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::write_data -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileDataObjectString:: write_data(ostream &out, int indent_level, const char *separator) const { indent(out, indent_level); @@ -54,40 +45,30 @@ write_data(ostream &out, int indent_level, const char *separator) const { out << separator << "\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::set_string_value -// Access: Protected, Virtual -// Description: Sets the object's value as a string, if this is -// legal. -//////////////////////////////////////////////////////////////////// +/** + * Sets the object's value as a string, if this is legal. + */ void XFileDataObjectString:: set_string_value(const string &string_value) { _value = string_value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::get_string_value -// Access: Protected, Virtual -// Description: Returns the object's representation as a string, if -// it has one. -//////////////////////////////////////////////////////////////////// +/** + * Returns the object's representation as a string, if it has one. + */ string XFileDataObjectString:: get_string_value() const { return _value; } -//////////////////////////////////////////////////////////////////// -// Function: XFileDataObjectString::enquote_string -// Access: Private -// Description: Writes the string to the output stream without -// quotation marks, quoting special characters as -// needed. -//////////////////////////////////////////////////////////////////// +/** + * Writes the string to the output stream without quotation marks, quoting + * special characters as needed. + */ void XFileDataObjectString:: enquote_string(ostream &out) const { - // Actually, the XFile spec doesn't tell us how to escape special - // characters within quotation marks. We'll just take a stab in the - // dark here. + // Actually, the XFile spec doesn't tell us how to escape special characters + // within quotation marks. We'll just take a stab in the dark here. out << '"'; string::const_iterator si; diff --git a/pandatool/src/xfile/xFileDataObjectString.h b/pandatool/src/xfile/xFileDataObjectString.h index 3062799c97..20dd503e06 100644 --- a/pandatool/src/xfile/xFileDataObjectString.h +++ b/pandatool/src/xfile/xFileDataObjectString.h @@ -1,16 +1,15 @@ -// Filename: xFileDataObjectString.h -// Created by: drose (08Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileDataObjectString.h + * @author drose + * @date 2004-10-08 + */ #ifndef XFILEDATAOBJECTSTRING_H #define XFILEDATAOBJECTSTRING_H @@ -18,12 +17,10 @@ #include "pandatoolbase.h" #include "xFileDataObject.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileDataObjectString -// Description : An string-valued data element. This matches one -// string data member of a template, or a single -// element of an string array. -//////////////////////////////////////////////////////////////////// +/** + * An string-valued data element. This matches one string data member of a + * template, or a single element of an string array. + */ class XFileDataObjectString : public XFileDataObject { public: XFileDataObjectString(const XFileDataDef *data_def, const string &value); @@ -40,7 +37,7 @@ private: void enquote_string(ostream &out) const; string _value; - + public: static TypeHandle get_class_type() { return _type_handle; diff --git a/pandatool/src/xfile/xFileNode.I b/pandatool/src/xfile/xFileNode.I index 9e224f008c..b23bea089d 100644 --- a/pandatool/src/xfile/xFileNode.I +++ b/pandatool/src/xfile/xFileNode.I @@ -1,72 +1,58 @@ -// Filename: xFileNode.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileNode.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_num_children -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFile *XFileNode:: get_x_file() const { return _x_file; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_num_children -// Access: Public -// Description: Returns the list of children of this node. This -// list includes templates as well as data objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of children of this node. This list includes templates as + * well as data objects. + */ INLINE int XFileNode:: get_num_children() const { return _children.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_child -// Access: Public -// Description: Returns the nth child of this node. This list -// includes templates as well as data objects. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child of this node. This list includes templates as well + * as data objects. + */ INLINE XFileNode *XFileNode:: get_child(int n) const { nassertr(n >= 0 && n < (int)_children.size(), NULL); return _children[n]; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_num_objects -// Access: Public -// Description: Returns the list of child objects of this node. This -// list does not include template definitions; it is -// strictly the list of children that are also data -// objects (instances of templates). -//////////////////////////////////////////////////////////////////// +/** + * Returns the list of child objects of this node. This list does not include + * template definitions; it is strictly the list of children that are also + * data objects (instances of templates). + */ INLINE int XFileNode:: get_num_objects() const { return _objects.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_object -// Access: Public -// Description: Returns the nth child object of this node. This -// list does not include template definitions; it is -// strictly the list of children that are also data -// objects (instances of templates). -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth child object of this node. This list does not include + * template definitions; it is strictly the list of children that are also + * data objects (instances of templates). + */ INLINE XFileDataNode *XFileNode:: get_object(int n) const { nassertr(n >= 0 && n < (int)_objects.size(), NULL); diff --git a/pandatool/src/xfile/xFileNode.cxx b/pandatool/src/xfile/xFileNode.cxx index f7e258da87..61d9d17d8f 100644 --- a/pandatool/src/xfile/xFileNode.cxx +++ b/pandatool/src/xfile/xFileNode.cxx @@ -1,16 +1,15 @@ -// Filename: xFileNode.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileNode.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileNode.h" #include "windowsGuid.h" @@ -24,11 +23,9 @@ TypeHandle XFileNode::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileNode:: XFileNode(XFile *x_file, const string &name) : Namable(), @@ -41,22 +38,17 @@ XFileNode(XFile *x_file, const string &name) : } } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileNode:: ~XFileNode() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::find_child -// Access: Public -// Description: Returns the child with the indicated name, if any, or -// NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the child with the indicated name, if any, or NULL if none. + */ XFileNode *XFileNode:: find_child(const string &name) const { ChildrenByName::const_iterator ni; @@ -68,12 +60,10 @@ find_child(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::find_child_index -// Access: Public -// Description: Returns the index number of the child with the -// indicated name, if any, or -1 if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the child with the indicated name, if any, or + * -1 if none. + */ int XFileNode:: find_child_index(const string &name) const { ChildrenByName::const_iterator ni; @@ -85,12 +75,9 @@ find_child_index(const string &name) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::find_child_index -// Access: Public -// Description: Returns the index number of the indicated child, -// or -1 if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the index number of the indicated child, or -1 if none. + */ int XFileNode:: find_child_index(const XFileNode *child) const { for (int i = 0; i < (int)_children.size(); i++) { @@ -102,13 +89,10 @@ find_child_index(const XFileNode *child) const { return -1; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::find_descendent -// Access: Public -// Description: Returns the first child or descendent found with the -// indicated name after a depth-first search, if any, or -// NULL if none. -//////////////////////////////////////////////////////////////////// +/** + * Returns the first child or descendent found with the indicated name after a + * depth-first search, if any, or NULL if none. + */ XFileNode *XFileNode:: find_descendent(const string &name) const { XFileNode *child = find_child(name); @@ -119,7 +103,7 @@ find_descendent(const string &name) const { Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { XFileNode *child = (*ci)->find_descendent(name); - if (child != (XFileNode *)NULL){ + if (child != (XFileNode *)NULL){ return child; } } @@ -127,105 +111,80 @@ find_descendent(const string &name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::has_guid -// Access: Public, Virtual -// Description: Returns true if this node has a GUID associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node has a GUID associated. + */ bool XFileNode:: has_guid() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::get_guid -// Access: Public, Virtual -// Description: If has_guid() returned true, returns the particular -// GUID associated with this node. -//////////////////////////////////////////////////////////////////// +/** + * If has_guid() returned true, returns the particular GUID associated with + * this node. + */ const WindowsGuid &XFileNode:: get_guid() const { static WindowsGuid empty; return empty; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::is_template_def -// Access: Public, Virtual -// Description: Returns true if this node represents the definition -// of some template. This is the template definition, -// not an actual data object that represents an instance -// of the template. If the file strictly uses standard -// templates, the presence of template definitions is -// optional. -// -// If this returns true, the node must be of type -// XFileTemplate. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents the definition of some template. This + * is the template definition, not an actual data object that represents an + * instance of the template. If the file strictly uses standard templates, + * the presence of template definitions is optional. + * + * If this returns true, the node must be of type XFileTemplate. + */ bool XFileNode:: is_template_def() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::is_reference -// Access: Public, Virtual -// Description: Returns true if this node represents an indirect -// reference to an object defined previously in the -// file. References are generally transparent, so in -// most cases you never need to call this, unless you -// actually need to differentiate between references and -// instances; you can simply use the reference node as -// if it were itself the object it references. -// -// If this returns true, the node must be of type -// XFileDataNodeReference. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents an indirect reference to an object + * defined previously in the file. References are generally transparent, so + * in most cases you never need to call this, unless you actually need to + * differentiate between references and instances; you can simply use the + * reference node as if it were itself the object it references. + * + * If this returns true, the node must be of type XFileDataNodeReference. + */ bool XFileNode:: is_reference() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::is_object -// Access: Public, Virtual -// Description: Returns true if this node represents a data object -// that is the instance of some template, or false -// otherwise. This also returns true for references to -// objects (which are generally treated just like the -// objects themselves). -// -// If this returns true, the node must be of type -// XFileDataNode (it is either an XFileDataNodeTemplate -// or an XFileDataNodeReference). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents a data object that is the instance of + * some template, or false otherwise. This also returns true for references + * to objects (which are generally treated just like the objects themselves). + * + * If this returns true, the node must be of type XFileDataNode (it is either + * an XFileDataNodeTemplate or an XFileDataNodeReference). + */ bool XFileNode:: is_object() const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::is_standard_object -// Access: Public, Virtual -// Description: Returns true if this node represents an instance of -// the standard template with the indicated name, or -// false otherwise. This returns also returns true for -// references to standard objects. -// -// If this returns true, the node must be of type -// XFileDataNode (it is either an XFileDataNodeTemplate -// or an XFileDataNodeReference). -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents an instance of the standard template + * with the indicated name, or false otherwise. This returns also returns + * true for references to standard objects. + * + * If this returns true, the node must be of type XFileDataNode (it is either + * an XFileDataNodeTemplate or an XFileDataNodeReference). + */ bool XFileNode:: is_standard_object(const string &template_name) const { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_child -// Access: Public -// Description: Adds the indicated node as a child of this node. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated node as a child of this node. + */ void XFileNode:: add_child(XFileNode *node) { if (node->has_name()) { @@ -240,12 +199,10 @@ add_child(XFileNode *node) { _children.push_back(node); } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::clear -// Access: Public, Virtual -// Description: Removes all children from the node, and otherwise -// resets it to its initial state. -//////////////////////////////////////////////////////////////////// +/** + * Removes all children from the node, and otherwise resets it to its initial + * state. + */ void XFileNode:: clear() { _children.clear(); @@ -253,12 +210,9 @@ clear() { _children_by_name.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileNode:: write_text(ostream &out, int indent_level) const { Children::const_iterator ci; @@ -267,32 +221,28 @@ write_text(ostream &out, int indent_level) const { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::repack_data -// Access: Public, Virtual -// Description: This is called on the template that defines an -// object, once the data for the object has been parsed. -// It is responsible for identifying which component of -// the template owns each data element, and packing the -// data elements appropriately back into the object. -// -// It returns true on success, or false on an error -// (e.g. not enough data elements, mismatched data -// type). -//////////////////////////////////////////////////////////////////// +/** + * This is called on the template that defines an object, once the data for + * the object has been parsed. It is responsible for identifying which + * component of the template owns each data element, and packing the data + * elements appropriately back into the object. + * + * It returns true on success, or false on an error (e.g. not enough data + * elements, mismatched data type). + */ bool XFileNode:: -repack_data(XFileDataObject *object, +repack_data(XFileDataObject *object, const XFileParseDataList &parse_data_list, XFileNode::PrevData &prev_data, size_t &index, size_t &sub_index) const { - // This method should be specialized for data types that actually - // consume a data element. Here in the base class, it just walks - // through its children, asking each one to pull off the appropriate - // number of data elements. + // This method should be specialized for data types that actually consume a + // data element. Here in the base class, it just walks through its + // children, asking each one to pull off the appropriate number of data + // elements. Children::const_iterator ci; for (ci = _children.begin(); ci != _children.end(); ++ci) { - if (!(*ci)->repack_data(object, parse_data_list, + if (!(*ci)->repack_data(object, parse_data_list, prev_data, index, sub_index)) { return false; } @@ -301,13 +251,10 @@ repack_data(XFileDataObject *object, return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::fill_zero_data -// Access: Public, Virtual -// Description: This is similar to repack_data(), except it is used -// to fill the initial values for a newly-created -// template object to zero. -//////////////////////////////////////////////////////////////////// +/** + * This is similar to repack_data(), except it is used to fill the initial + * values for a newly-created template object to zero. + */ bool XFileNode:: fill_zero_data(XFileDataObject *object) const { Children::const_iterator ci; @@ -320,15 +267,11 @@ fill_zero_data(XFileDataObject *object) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::matches -// Access: Public, Virtual -// Description: Returns true if the node, particularly a template -// node, is structurally equivalent to the other node -// (which must be of the same type). This checks data -// element types, but does not compare data element -// names. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node, particularly a template node, is structurally + * equivalent to the other node (which must be of the same type). This checks + * data element types, but does not compare data element names. + */ bool XFileNode:: matches(const XFileNode *other) const { if (other->get_type() != get_type()) { @@ -348,11 +291,9 @@ matches(const XFileNode *other) const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_Mesh -// Access: Public -// Description: Creates a new Mesh instance, as a child of this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Mesh instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_Mesh(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Mesh"); @@ -365,12 +306,9 @@ add_Mesh(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_MeshNormals -// Access: Public -// Description: Creates a new MeshNormals instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new MeshNormals instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_MeshNormals(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshNormals"); @@ -383,12 +321,9 @@ add_MeshNormals(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_MeshVertexColors -// Access: Public -// Description: Creates a new MeshVertexColors instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new MeshVertexColors instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_MeshVertexColors(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshVertexColors"); @@ -401,12 +336,9 @@ add_MeshVertexColors(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_MeshTextureCoords -// Access: Public -// Description: Creates a new MeshTextureCoords instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new MeshTextureCoords instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_MeshTextureCoords(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshTextureCoords"); @@ -419,12 +351,9 @@ add_MeshTextureCoords(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_MeshMaterialList -// Access: Public -// Description: Creates a new MeshMaterialList instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new MeshMaterialList instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_MeshMaterialList(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("MeshMaterialList"); @@ -437,12 +366,9 @@ add_MeshMaterialList(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_Material -// Access: Public -// Description: Creates a new Material instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Material instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_Material(const string &name, const LColor &face_color, double power, const LRGBColor &specular_color, @@ -469,12 +395,9 @@ add_Material(const string &name, const LColor &face_color, return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_TextureFilename -// Access: Public -// Description: Creates a new TextureFilename instance, as a child of -// this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new TextureFilename instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_TextureFilename(const string &name, const Filename &filename) { XFileTemplate *xtemplate = XFile::find_standard_template("TextureFilename"); @@ -489,12 +412,9 @@ add_TextureFilename(const string &name, const Filename &filename) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_Frame -// Access: Public -// Description: Creates a new Frame instance, as a child of this -// node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new Frame instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_Frame(const string &name) { XFileTemplate *xtemplate = XFile::find_standard_template("Frame"); @@ -507,18 +427,15 @@ add_Frame(const string &name) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::add_FrameTransformMatrix -// Access: Public -// Description: Creates a new FrameTransformMatrix instance, as a -// child of this node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new FrameTransformMatrix instance, as a child of this node. + */ XFileDataNode *XFileNode:: add_FrameTransformMatrix(const LMatrix4d &mat) { - XFileTemplate *xtemplate = + XFileTemplate *xtemplate = XFile::find_standard_template("FrameTransformMatrix"); nassertr(xtemplate != (XFileTemplate *)NULL, NULL); - XFileDataNodeTemplate *node = + XFileDataNodeTemplate *node = new XFileDataNodeTemplate(get_x_file(), "", xtemplate); add_child(node); node->zero_fill(); @@ -547,12 +464,10 @@ add_FrameTransformMatrix(const LMatrix4d &mat) { return node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNode::make_nice_name -// Access: Protected, Static -// Description: Transforms the indicated egg name to a name that is -// acceptable for a node in the X File format. -//////////////////////////////////////////////////////////////////// +/** + * Transforms the indicated egg name to a name that is acceptable for a node + * in the X File format. + */ string XFileNode:: make_nice_name(const string &str) { string result; @@ -573,9 +488,8 @@ make_nice_name(const string &str) { } if (str.empty() || isdigit(str[0])) { - // If the name begins with a digit, or if it - // is empty, then we must make it begin with - // something else, like for instance an underscore. + // If the name begins with a digit, or if it is empty, then we must make + // it begin with something else, like for instance an underscore. result = '_' + result; } diff --git a/pandatool/src/xfile/xFileNode.h b/pandatool/src/xfile/xFileNode.h index 202b8490c1..89ab1a1ba8 100644 --- a/pandatool/src/xfile/xFileNode.h +++ b/pandatool/src/xfile/xFileNode.h @@ -1,16 +1,15 @@ -// Filename: xFileNode.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileNode.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILENODE_H #define XFILENODE_H @@ -34,11 +33,9 @@ class XFileDataNode; class XFileDataNodeTemplate; class Filename; -//////////////////////////////////////////////////////////////////// -// Class : XFileNode -// Description : A single node of an X file. This may be either a -// template or a data node. -//////////////////////////////////////////////////////////////////// +/** + * A single node of an X file. This may be either a template or a data node. + */ class XFileNode : public TypedObject, public Namable, virtual public ReferenceCount { public: @@ -72,7 +69,7 @@ public: typedef pmap PrevData; - virtual bool repack_data(XFileDataObject *object, + virtual bool repack_data(XFileDataObject *object, const XFileParseDataList &parse_data_list, PrevData &prev_data, size_t &index, size_t &sub_index) const; @@ -81,10 +78,9 @@ public: virtual bool matches(const XFileNode *other) const; - // The following methods can be used to create instances of the - // standard template objects. These definitions match those defined - // in standardTemplates.x in this directory (and compiled into the - // executable). + // The following methods can be used to create instances of the standard + // template objects. These definitions match those defined in + // standardTemplates.x in this directory (and compiled into the executable). XFileDataNode *add_Mesh(const string &name); XFileDataNode *add_MeshNormals(const string &name); XFileDataNode *add_MeshVertexColors(const string &name); @@ -93,7 +89,7 @@ public: XFileDataNode *add_Material(const string &name, const LColor &face_color, double power, const LRGBColor &specular_color, const LRGBColor &emissive_color); - XFileDataNode *add_TextureFilename(const string &name, + XFileDataNode *add_TextureFilename(const string &name, const Filename &filename); XFileDataNode *add_Frame(const string &name); XFileDataNode *add_FrameTransformMatrix(const LMatrix4d &mat); @@ -103,10 +99,10 @@ public: protected: XFile *_x_file; - + typedef pvector< PT(XFileNode) > Children; Children _children; - + typedef pvector Objects; Objects _objects; @@ -138,6 +134,3 @@ private: #include "xFileNode.I" #endif - - - diff --git a/pandatool/src/xfile/xFileParseData.I b/pandatool/src/xfile/xFileParseData.I index cdacd6d527..641997370e 100644 --- a/pandatool/src/xfile/xFileParseData.I +++ b/pandatool/src/xfile/xFileParseData.I @@ -1,14 +1,12 @@ -// Filename: xFileParseData.I -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// - +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileParseData.I + * @author drose + * @date 2004-10-07 + */ diff --git a/pandatool/src/xfile/xFileParseData.cxx b/pandatool/src/xfile/xFileParseData.cxx index 0e2ad78cf4..aeafa42a6f 100644 --- a/pandatool/src/xfile/xFileParseData.cxx +++ b/pandatool/src/xfile/xFileParseData.cxx @@ -1,45 +1,38 @@ -// Filename: xFileParseData.cxx -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileParseData.cxx + * @author drose + * @date 2004-10-07 + */ #include "xFileParseData.h" #include "xLexerDefs.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileParseData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileParseData:: XFileParseData() : _parse_flags(0) { - // Save the line number, column number, and line text in case we - // detect an error later and want to report a meaningful message to - // the user. + // Save the line number, column number, and line text in case we detect an + // error later and want to report a meaningful message to the user. _line_number = x_line_number; _col_number = x_col_number; _current_line = x_current_line; } -//////////////////////////////////////////////////////////////////// -// Function: XFileParseData::yyerror -// Access: Public -// Description: Reports a parsing error message to the user, showing -// the line and column from which this object was -// originally parsed. -//////////////////////////////////////////////////////////////////// +/** + * Reports a parsing error message to the user, showing the line and column + * from which this object was originally parsed. + */ void XFileParseData:: yyerror(const string &message) const { xyyerror(message, _line_number, _col_number, _current_line); diff --git a/pandatool/src/xfile/xFileParseData.h b/pandatool/src/xfile/xFileParseData.h index 47d6382217..c31089274b 100644 --- a/pandatool/src/xfile/xFileParseData.h +++ b/pandatool/src/xfile/xFileParseData.h @@ -1,16 +1,15 @@ -// Filename: xFileParseData.h -// Created by: drose (07Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileParseData.h + * @author drose + * @date 2004-10-07 + */ #ifndef XFILEPARSEDATA_H #define XFILEPARSEDATA_H @@ -22,14 +21,12 @@ #include "pta_double.h" #include "pvector.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileParseData -// Description : This class is used to fill up the data into an -// XFileDataNodeTemplate object as the data values are -// parsed out of the X file. It only has a temporary -// lifespan; it will be converted into actual data by -// XFileDataNodeTemplate::finalize_parse_data(). -//////////////////////////////////////////////////////////////////// +/** + * This class is used to fill up the data into an XFileDataNodeTemplate object + * as the data values are parsed out of the X file. It only has a temporary + * lifespan; it will be converted into actual data by + * XFileDataNodeTemplate::finalize_parse_data(). + */ class XFileParseData { public: XFileParseData(); @@ -56,14 +53,12 @@ public: string _current_line; }; -//////////////////////////////////////////////////////////////////// -// Class : XFileParseDataList -// Description : A container for a pvector of the above objects. We -// need this wrapper class to avoid circular #includes; -// this allows XFileNode to define a forward reference -// to this class (without having to include this file or -// know that it contains a template class). -//////////////////////////////////////////////////////////////////// +/** + * A container for a pvector of the above objects. We need this wrapper class + * to avoid circular #includes; this allows XFileNode to define a forward + * reference to this class (without having to include this file or know that + * it contains a template class). + */ class XFileParseDataList { public: typedef pvector List; @@ -73,4 +68,3 @@ public: #include "xFileParseData.I" #endif - diff --git a/pandatool/src/xfile/xFileTemplate.I b/pandatool/src/xfile/xFileTemplate.I index 9f276ca2c0..3d7e52ec61 100644 --- a/pandatool/src/xfile/xFileTemplate.I +++ b/pandatool/src/xfile/xFileTemplate.I @@ -1,87 +1,68 @@ -// Filename: xFileTemplate.I -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileTemplate.I + * @author drose + * @date 2004-10-03 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::is_standard -// Access: Public -// Description: Returns true if this particular template is one of -// the "standard" templates defined by -// standardTemplates.x in this directory (and compiled -// into the binary), or false if it is a user-custom -// template. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this particular template is one of the "standard" templates + * defined by standardTemplates.x in this directory (and compiled into the + * binary), or false if it is a user-custom template. + */ INLINE bool XFileTemplate:: is_standard() const { return _is_standard; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::set_open -// Access: Public -// Description: Sets whether the template is considered "open" or -// not. If it is open (this flag is true), the set of -// options is ignored and the instances of this -// template may include any types of children. If it is -// closed (false), only the named types may be added. -//////////////////////////////////////////////////////////////////// +/** + * Sets whether the template is considered "open" or not. If it is open (this + * flag is true), the set of options is ignored and the instances of this + * template may include any types of children. If it is closed (false), only + * the named types may be added. + */ INLINE void XFileTemplate:: set_open(bool open) { _open = open; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::get_open -// Access: Public -// Description: Returns whether the template is considered "open" or -// not. If it is open (this flag is true), the set of -// options is ignored and the instances of this -// template may include any types of children. If it is -// closed (false), only the named types may be added. -//////////////////////////////////////////////////////////////////// +/** + * Returns whether the template is considered "open" or not. If it is open + * (this flag is true), the set of options is ignored and the instances of + * this template may include any types of children. If it is closed (false), + * only the named types may be added. + */ INLINE bool XFileTemplate:: get_open() const { return _open; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::add_option -// Access: Public -// Description: Adds a new type to the list of allowable types of -// child nodes for an instance of this template. -//////////////////////////////////////////////////////////////////// +/** + * Adds a new type to the list of allowable types of child nodes for an + * instance of this template. + */ INLINE void XFileTemplate:: add_option(XFileTemplate *option) { _options.push_back(option); } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::get_num_options -// Access: Public -// Description: Returns the number of templates on the options -// list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of templates on the options list. + */ INLINE int XFileTemplate:: get_num_options() const { return _options.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::get_option -// Access: Public -// Description: Returns the nth template on the options list. -//////////////////////////////////////////////////////////////////// +/** + * Returns the nth template on the options list. + */ INLINE XFileTemplate *XFileTemplate:: get_option(int n) const { nassertr(n >= 0 && n < (int)_options.size(), NULL); diff --git a/pandatool/src/xfile/xFileTemplate.cxx b/pandatool/src/xfile/xFileTemplate.cxx index 018e16ff60..5c9691d02a 100644 --- a/pandatool/src/xfile/xFileTemplate.cxx +++ b/pandatool/src/xfile/xFileTemplate.cxx @@ -1,29 +1,26 @@ -// Filename: xFileTemplate.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileTemplate.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileTemplate.h" #include "indent.h" TypeHandle XFileTemplate::_type_handle; -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileTemplate:: -XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid) : +XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid) : XFileNode(x_file, name), _guid(guid), _is_standard(false), @@ -31,72 +28,56 @@ XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid) : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::Destructor -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileTemplate:: ~XFileTemplate() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::has_guid -// Access: Public, Virtual -// Description: Returns true if this node has a GUID associated. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node has a GUID associated. + */ bool XFileTemplate:: has_guid() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::get_guid -// Access: Public, Virtual -// Description: Returns the GUID associated with this template. -//////////////////////////////////////////////////////////////////// +/** + * Returns the GUID associated with this template. + */ const WindowsGuid &XFileTemplate:: get_guid() const { return _guid; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::is_template_def -// Access: Public, Virtual -// Description: Returns true if this node represents the definition -// of some template. This is the template definition, -// not an actual data object that represents an instance -// of the template. If the file strictly uses standard -// templates, the presence of template definitions is -// optional. -// -// If this returns true, the node must be of type -// XFileTemplate. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this node represents the definition of some template. This + * is the template definition, not an actual data object that represents an + * instance of the template. If the file strictly uses standard templates, + * the presence of template definitions is optional. + * + * If this returns true, the node must be of type XFileTemplate. + */ bool XFileTemplate:: is_template_def() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::clear -// Access: Public, Virtual -// Description: Removes all children from the node, and otherwise -// resets it to its initial state. -//////////////////////////////////////////////////////////////////// +/** + * Removes all children from the node, and otherwise resets it to its initial + * state. + */ void XFileTemplate:: clear() { XFileNode::clear(); _options.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::write_text -// Access: Public, Virtual -// Description: Writes a suitable representation of this node to an -// .x file in text mode. -//////////////////////////////////////////////////////////////////// +/** + * Writes a suitable representation of this node to an .x file in text mode. + */ void XFileTemplate:: write_text(ostream &out, int indent_level) const { indent(out, indent_level) @@ -119,7 +100,7 @@ write_text(ostream &out, int indent_level) const { Options::const_iterator ri; for (ri = _options.begin(); ri != _options.end(); ++ri) { XFileTemplate *option = (*ri); - out << delimiter << " " + out << delimiter << " " << option->get_name() << " <" << option->get_guid() << ">"; delimiter = ','; @@ -131,24 +112,20 @@ write_text(ostream &out, int indent_level) const { << "}\n"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileTemplate::matches -// Access: Public, Virtual -// Description: Returns true if the node, particularly a template -// node, is structurally equivalent to the other node -// (which must be of the same type). This checks data -// element types, but does not compare data element -// names. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if the node, particularly a template node, is structurally + * equivalent to the other node (which must be of the same type). This checks + * data element types, but does not compare data element names. + */ bool XFileTemplate:: matches(const XFileNode *other) const { if (!XFileNode::matches(other)) { return false; } - // We *could* compare the open/closed/options associated with the - // template, but since this is only used for validating the set of - // children for the instances of this template (which we don't even - // bother to do anyway), it doesn't seem to matter. + // We *could* compare the openclosedoptions associated with the template, + // but since this is only used for validating the set of children for the + // instances of this template (which we don't even bother to do anyway), it + // doesn't seem to matter. return true; } diff --git a/pandatool/src/xfile/xFileTemplate.h b/pandatool/src/xfile/xFileTemplate.h index dde685fd90..2f4770c66a 100644 --- a/pandatool/src/xfile/xFileTemplate.h +++ b/pandatool/src/xfile/xFileTemplate.h @@ -1,16 +1,15 @@ -// Filename: xFileTemplate.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileTemplate.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILETEMPLATE_H #define XFILETEMPLATE_H @@ -21,11 +20,10 @@ class XFileDataDef; -//////////////////////////////////////////////////////////////////// -// Class : XFileTemplate -// Description : A template definition in the X file. This defines -// the data structures that may be subsequently read. -//////////////////////////////////////////////////////////////////// +/** + * A template definition in the X file. This defines the data structures that + * may be subsequently read. + */ class XFileTemplate : public XFileNode { public: XFileTemplate(XFile *x_file, const string &name, const WindowsGuid &guid); @@ -49,7 +47,7 @@ public: INLINE XFileTemplate *get_option(int n) const; virtual bool matches(const XFileNode *other) const; - + private: WindowsGuid _guid; bool _is_standard; @@ -57,7 +55,7 @@ private: typedef pvector< PT(XFileTemplate) > Options; Options _options; - + public: static TypeHandle get_class_type() { return _type_handle; @@ -81,6 +79,3 @@ private: #include "xFileTemplate.I" #endif - - - diff --git a/pandatool/src/xfile/xLexerDefs.h b/pandatool/src/xfile/xLexerDefs.h index 4b46fef3d1..eb600edb32 100644 --- a/pandatool/src/xfile/xLexerDefs.h +++ b/pandatool/src/xfile/xLexerDefs.h @@ -1,16 +1,15 @@ -// Filename: xLexerDefs.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xLexerDefs.h + * @author drose + * @date 2004-10-03 + */ #ifndef XLEXERDEFS_H #define XLEXERDEFS_H @@ -22,7 +21,7 @@ int x_error_count(); int x_warning_count(); void xyyerror(const string &msg); -void xyyerror(const string &msg, int line_number, int col_number, +void xyyerror(const string &msg, int line_number, int col_number, const string ¤t_line); void xyywarning(const string &msg); diff --git a/pandatool/src/xfile/xParser.yxx b/pandatool/src/xfile/xParser.yxx index b22804e212..4aa8ffd3b3 100644 --- a/pandatool/src/xfile/xParser.yxx +++ b/pandatool/src/xfile/xParser.yxx @@ -1,7 +1,8 @@ -// Filename: xParser.yxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// +/** + * @file xParser.yxx + * @author drose + * @date 2004-10-03 + */ // The grammar defined in this file is taken more-or-less from the // Microsoft DirectX File Format Specification document, version 1.13. diff --git a/pandatool/src/xfile/xParserDefs.h b/pandatool/src/xfile/xParserDefs.h index f06fe7bca4..898d4a150e 100644 --- a/pandatool/src/xfile/xParserDefs.h +++ b/pandatool/src/xfile/xParserDefs.h @@ -1,16 +1,15 @@ -// Filename: xParserDefs.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xParserDefs.h + * @author drose + * @date 2004-10-03 + */ #ifndef XPARSERDEFS_H #define XPARSERDEFS_H @@ -28,12 +27,11 @@ void x_init_parser(istream &in, const string &filename, XFile &file); void x_cleanup_parser(); int xyyparse(); -// This structure holds the return value for each token. -// Traditionally, this is a union, and is declared with the %union -// declaration in the parser.y file, but unions are pretty worthless -// in C++ (you can't include an object that has member functions in a -// union), so we'll use a class instead. That means we need to -// declare it externally, here. +// This structure holds the return value for each token. Traditionally, this +// is a union, and is declared with the %union declaration in the parser.y +// file, but unions are pretty worthless in C++ (you can't include an object +// that has member functions in a union), so we'll use a class instead. That +// means we need to declare it externally, here. class XTokenType { public: @@ -48,8 +46,8 @@ public: PTA_int int_list; }; -// The yacc-generated code expects to use the symbol 'YYSTYPE' to -// refer to the above class. +// The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the +// above class. #define YYSTYPE XTokenType #endif diff --git a/pandatool/src/xfileegg/xFileAnimationSet.I b/pandatool/src/xfileegg/xFileAnimationSet.I index ec63aed775..a8501f9c64 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.I +++ b/pandatool/src/xfileegg/xFileAnimationSet.I @@ -1,23 +1,19 @@ -// Filename: xFileAnimationSet.I -// Created by: drose (04Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileAnimationSet.I + * @author drose + * @date 2004-10-04 + */ - -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::FrameEntry::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileAnimationSet::FrameEntry:: FrameEntry() : _scale(1.0, 1.0, 1.0), @@ -27,13 +23,10 @@ FrameEntry() : { } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::FrameEntry::get_mat -// Access: Public -// Description: Returns the frame's data as a matrix, composing the -// matrix first if necessary, as indicated by the -// FrameData's _flags member. -//////////////////////////////////////////////////////////////////// +/** + * Returns the frame's data as a matrix, composing the matrix first if + * necessary, as indicated by the FrameData's _flags member. + */ INLINE const LMatrix4d &XFileAnimationSet::FrameEntry:: get_mat(int flags) const { if ((flags & FDF_mat) == 0) { @@ -43,11 +36,9 @@ get_mat(int flags) const { return _mat; } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::FrameData::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ INLINE XFileAnimationSet::FrameData:: FrameData() : _flags(0) diff --git a/pandatool/src/xfileegg/xFileAnimationSet.cxx b/pandatool/src/xfileegg/xFileAnimationSet.cxx index 9bce47b3df..25e9136c94 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.cxx +++ b/pandatool/src/xfileegg/xFileAnimationSet.cxx @@ -1,16 +1,15 @@ -// Filename: xFileAnimationSet.cxx -// Created by: drose (02Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileAnimationSet.cxx + * @author drose + * @date 2004-10-02 + */ #include "xFileAnimationSet.h" #include "xFileToEggConverter.h" @@ -21,43 +20,36 @@ #include "eggXfmSAnim.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileAnimationSet:: XFileAnimationSet() { _frame_rate = 0.0; } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileAnimationSet:: ~XFileAnimationSet() { } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::create_hierarchy -// Access: Public -// Description: Sets up the hierarchy of EggTables corresponding to -// this AnimationSet. -//////////////////////////////////////////////////////////////////// +/** + * Sets up the hierarchy of EggTables corresponding to this AnimationSet. + */ bool XFileAnimationSet:: create_hierarchy(XFileToEggConverter *converter) { - // Egg animation tables start off with one Table entry, enclosing a - // Bundle entry. + // Egg animation tables start off with one Table entry, enclosing a Bundle + // entry. EggTable *table = new EggTable(get_name()); converter->get_egg_data()->add_child(table); EggTable *bundle = new EggTable(converter->_char_name); table->add_child(bundle); bundle->set_table_type(EggTable::TT_bundle); - // Then the Bundle contains a "" entry, which begins the - // animation table hierarchy. + // Then the Bundle contains a "" entry, which begins the animation + // table hierarchy. EggTable *skeleton = new EggTable(""); bundle->add_child(skeleton); @@ -102,12 +94,9 @@ create_hierarchy(XFileToEggConverter *converter) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::get_table -// Access: Public -// Description: Returns the table associated with the indicated joint -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns the table associated with the indicated joint name. + */ EggXfmSAnim *XFileAnimationSet:: get_table(const string &joint_name) const { Tables::const_iterator ti; @@ -118,27 +107,21 @@ get_table(const string &joint_name) const { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::create_frame_data -// Access: Public -// Description: Returns a reference to a new FrameData table -// corresponding to the indicated joint. -//////////////////////////////////////////////////////////////////// +/** + * Returns a reference to a new FrameData table corresponding to the indicated + * joint. + */ XFileAnimationSet::FrameData &XFileAnimationSet:: create_frame_data(const string &joint_name) { return _joint_data[joint_name]; } -//////////////////////////////////////////////////////////////////// -// Function: XFileAnimationSet::mirror_table -// Access: Private -// Description: Builds up a new set of EggTable nodes, as a -// mirror of the existing set of EggGroup (joint) -// nodes, and saves each new table in the _tables -// record. -//////////////////////////////////////////////////////////////////// +/** + * Builds up a new set of EggTable nodes, as a mirror of the existing set of + * EggGroup (joint) nodes, and saves each new table in the _tables record. + */ void XFileAnimationSet:: -mirror_table(XFileToEggConverter *converter, +mirror_table(XFileToEggConverter *converter, EggGroup *model_node, EggTable *anim_node) { EggGroupNode::iterator gi; for (gi = model_node->begin(); gi != model_node->end(); ++gi) { @@ -149,7 +132,7 @@ mirror_table(XFileToEggConverter *converter, // When we come to a , create a new Table for it. EggTable *new_table = new EggTable(group->get_name()); anim_node->add_child(new_table); - CoordinateSystem cs = + CoordinateSystem cs = converter->get_egg_data()->get_coordinate_system(); EggXfmSAnim *xform = new EggXfmSAnim("xform", cs); new_table->add_child(xform); diff --git a/pandatool/src/xfileegg/xFileAnimationSet.h b/pandatool/src/xfileegg/xFileAnimationSet.h index 3b38331989..9ef7e1d134 100644 --- a/pandatool/src/xfileegg/xFileAnimationSet.h +++ b/pandatool/src/xfileegg/xFileAnimationSet.h @@ -1,16 +1,15 @@ -// Filename: xFileAnimationSet.h -// Created by: drose (02Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileAnimationSet.h + * @author drose + * @date 2004-10-02 + */ #ifndef XFILEANIMATIONSET_H #define XFILEANIMATIONSET_H @@ -26,14 +25,11 @@ class EggGroup; class EggTable; class EggXfmSAnim; -//////////////////////////////////////////////////////////////////// -// Class : XFileAnimationSet -// Description : This represents a tree of EggTables, corresponding to -// Animation entries in the X file. There is one -// EggTable for each joint in the character's joint -// set, and the whole tree is structured as a -// mirror of the joint set. -//////////////////////////////////////////////////////////////////// +/** + * This represents a tree of EggTables, corresponding to Animation entries in + * the X file. There is one EggTable for each joint in the character's joint + * set, and the whole tree is structured as a mirror of the joint set. + */ class XFileAnimationSet : public Namable { public: XFileAnimationSet(); @@ -68,7 +64,7 @@ public: FrameEntries _entries; int _flags; }; - + FrameData &create_frame_data(const string &joint_name); public: @@ -94,4 +90,3 @@ private: #include "xFileAnimationSet.I" #endif - diff --git a/pandatool/src/xfileegg/xFileFace.cxx b/pandatool/src/xfileegg/xFileFace.cxx index 830d9ed01d..ecb1378c88 100644 --- a/pandatool/src/xfileegg/xFileFace.cxx +++ b/pandatool/src/xfileegg/xFileFace.cxx @@ -1,40 +1,35 @@ -// Filename: xFileFace.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileFace.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileFace.h" #include "xFileMesh.h" #include "eggPolygon.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileFace::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileFace:: XFileFace() { _material_index = -1; } -//////////////////////////////////////////////////////////////////// -// Function: XFileFace::set_from_egg -// Access: Public -// Description: Sets the structure up from the indicated egg data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the structure up from the indicated egg data. + */ void XFileFace:: set_from_egg(XFileMesh *mesh, EggPolygon *egg_poly) { - // Walk through the polygon's vertices in reverse order, to change - // from Egg's counter-clockwise convention to DX's clockwise. + // Walk through the polygon's vertices in reverse order, to change from + // Egg's counter-clockwise convention to DX's clockwise. EggPolygon::reverse_iterator vi; for (vi = egg_poly->rbegin(); vi != egg_poly->rend(); ++vi) { EggVertex *egg_vertex = (*vi); diff --git a/pandatool/src/xfileegg/xFileFace.h b/pandatool/src/xfileegg/xFileFace.h index d323250c19..788d664ee7 100644 --- a/pandatool/src/xfileegg/xFileFace.h +++ b/pandatool/src/xfileegg/xFileFace.h @@ -1,16 +1,15 @@ -// Filename: xFileFace.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileFace.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEFACE_H #define XFILEFACE_H @@ -21,10 +20,9 @@ class XFileMesh; class EggPolygon; -//////////////////////////////////////////////////////////////////// -// Class : XFileFace -// Description : This represents a single face of an XFileMesh. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single face of an XFileMesh. + */ class XFileFace { public: XFileFace(); @@ -42,4 +40,3 @@ public: }; #endif - diff --git a/pandatool/src/xfileegg/xFileMaker.cxx b/pandatool/src/xfileegg/xFileMaker.cxx index 64a8966930..915fa4ff20 100644 --- a/pandatool/src/xfileegg/xFileMaker.cxx +++ b/pandatool/src/xfileegg/xFileMaker.cxx @@ -1,16 +1,15 @@ -// Filename: xFileMaker.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMaker.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileMaker.h" #include "xFileMesh.h" @@ -31,45 +30,36 @@ #include "string_utils.h" #include "datagram.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMaker:: XFileMaker() { _mesh_index = 0; _x_file = new XFile; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMaker:: ~XFileMaker() { } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::write -// Access: Public -// Description: Writes the .x file data to the indicated filename; -// returns true on success, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Writes the .x file data to the indicated filename; returns true on success, + * false otherwise. + */ bool XFileMaker:: write(const Filename &filename) { return _x_file->write(filename); } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::add_tree -// Access: Public -// Description: Adds the egg tree rooted at the indicated node to the -// X structure. This may be somewhat destructive of -// the egg tree. Returns true on success, false on -// failure. -//////////////////////////////////////////////////////////////////// +/** + * Adds the egg tree rooted at the indicated node to the X structure. This + * may be somewhat destructive of the egg tree. Returns true on success, + * false on failure. + */ bool XFileMaker:: add_tree(EggData *egg_data) { _meshes.clear(); @@ -95,12 +85,9 @@ add_tree(EggData *egg_data) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::add_node -// Access: Private -// Description: Adds the node to the DX structure, in whatever form -// it is supported. -//////////////////////////////////////////////////////////////////// +/** + * Adds the node to the DX structure, in whatever form it is supported. + */ bool XFileMaker:: add_node(EggNode *egg_node, XFileNode *x_parent) { if (egg_node->is_of_type(EggBin::get_class_type())) { @@ -114,8 +101,7 @@ add_node(EggNode *egg_node, XFileNode *x_parent) { EggGroupNode *egg_group = DCAST(EggGroupNode, egg_node); if (xfile_one_mesh) { - // Don't create any additional frames representing the egg - // hierarchy. + // Don't create any additional frames representing the egg hierarchy. if (!recurse_nodes(egg_group, x_parent)) { return false; } @@ -128,7 +114,7 @@ add_node(EggNode *egg_node, XFileNode *x_parent) { return false; } } - + return true; } @@ -136,16 +122,13 @@ add_node(EggNode *egg_node, XFileNode *x_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::add_group -// Access: Private -// Description: Adds a frame for the indicated group node. -//////////////////////////////////////////////////////////////////// +/** + * Adds a frame for the indicated group node. + */ bool XFileMaker:: add_group(EggGroup *egg_group, XFileNode *x_parent) { if (xfile_one_mesh) { - // Don't create any additional frames representing the egg - // hierarchy. + // Don't create any additional frames representing the egg hierarchy. if (!recurse_nodes(egg_group, x_parent)) { return false; } @@ -167,12 +150,10 @@ add_group(EggGroup *egg_group, XFileNode *x_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::add_bin -// Access: Private -// Description: Determines what kind of object needs to be added for -// the indicated bin node. -//////////////////////////////////////////////////////////////////// +/** + * Determines what kind of object needs to be added for the indicated bin + * node. + */ bool XFileMaker:: add_bin(EggBin *egg_bin, XFileNode *x_parent) { switch (egg_bin->get_bin_number()) { @@ -185,12 +166,10 @@ add_bin(EggBin *egg_bin, XFileNode *x_parent) { return false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::add_polyset -// Access: Private -// Description: Adds a mesh object corresponding to the collection of -// polygons within the indicated bin. -//////////////////////////////////////////////////////////////////// +/** + * Adds a mesh object corresponding to the collection of polygons within the + * indicated bin. + */ bool XFileMaker:: add_polyset(EggBin *egg_bin, XFileNode *x_parent) { // Make sure that all our polygons are reasonable. @@ -209,13 +188,11 @@ add_polyset(EggBin *egg_bin, XFileNode *x_parent) { return true; } - -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::recurse_nodes -// Access: Private -// Description: Adds each child of the indicated Node as a child of -// the indicated DX object. -//////////////////////////////////////////////////////////////////// + +/** + * Adds each child of the indicated Node as a child of the indicated DX + * object. + */ bool XFileMaker:: recurse_nodes(EggGroupNode *egg_node, XFileNode *x_parent) { EggGroupNode::iterator ci; @@ -229,18 +206,16 @@ recurse_nodes(EggGroupNode *egg_node, XFileNode *x_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::get_mesh -// Access: Private -// Description: Returns a suitable XFileMesh object for creating -// meshes within the indicated x_parent object. -//////////////////////////////////////////////////////////////////// +/** + * Returns a suitable XFileMesh object for creating meshes within the + * indicated x_parent object. + */ XFileMesh *XFileMaker:: get_mesh(XFileNode *x_parent) { Meshes::iterator mi = _meshes.find(x_parent); if (mi != _meshes.end()) { - // We've already started working on this x_parent before; use the - // same mesh object. + // We've already started working on this x_parent before; use the same + // mesh object. return (*mi).second; } @@ -251,12 +226,10 @@ get_mesh(XFileNode *x_parent) { } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaker::finalize_mesh -// Access: Private -// Description: Creates the actual X structures corresponding to -// the indicated XFileMesh object. -//////////////////////////////////////////////////////////////////// +/** + * Creates the actual X structures corresponding to the indicated XFileMesh + * object. + */ bool XFileMaker:: finalize_mesh(XFileNode *x_parent, XFileMesh *mesh) { // Get a unique number for each mesh. diff --git a/pandatool/src/xfileegg/xFileMaker.h b/pandatool/src/xfileegg/xFileMaker.h index 7a1698333b..18ba2a99f3 100644 --- a/pandatool/src/xfileegg/xFileMaker.h +++ b/pandatool/src/xfileegg/xFileMaker.h @@ -1,16 +1,15 @@ -// Filename: xFileMaker.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMaker.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEMAKER_H #define XFILEMAKER_H @@ -31,11 +30,9 @@ class EggVertexPool; class Datagram; class XFileMesh; -//////////////////////////////////////////////////////////////////// -// Class : XFileMaker -// Description : This class converts a Panda scene graph into a .X -// file and writes it out. -//////////////////////////////////////////////////////////////////// +/** + * This class converts a Panda scene graph into a .X file and writes it out. + */ class XFileMaker { public: XFileMaker(); @@ -65,4 +62,3 @@ private: }; #endif - diff --git a/pandatool/src/xfileegg/xFileMaterial.cxx b/pandatool/src/xfileegg/xFileMaterial.cxx index 938a24f76e..4efa732b4d 100644 --- a/pandatool/src/xfileegg/xFileMaterial.cxx +++ b/pandatool/src/xfileegg/xFileMaterial.cxx @@ -1,16 +1,15 @@ -// Filename: xFileMaterial.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMaterial.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileMaterial.h" #include "xFileToEggConverter.h" @@ -22,11 +21,9 @@ #include // for strcmp, strdup -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMaterial:: XFileMaterial() { _face_color.set(1.0, 1.0, 1.0, 1.0); @@ -38,20 +35,16 @@ XFileMaterial() { _has_texture = false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMaterial:: ~XFileMaterial() { } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::set_from_egg -// Access: Public -// Description: Sets the structure up from the indicated egg data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the structure up from the indicated egg data. + */ void XFileMaterial:: set_from_egg(EggPrimitive *egg_prim) { // First, determine the face color. @@ -89,12 +82,9 @@ set_from_egg(EggPrimitive *egg_prim) { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::apply_to_egg -// Access: Public -// Description: Applies the properties in the material to the -// indicated egg primitive. -//////////////////////////////////////////////////////////////////// +/** + * Applies the properties in the material to the indicated egg primitive. + */ void XFileMaterial:: apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter) { // Is there a texture? @@ -128,11 +118,9 @@ apply_to_egg(EggPrimitive *egg_prim, XFileToEggConverter *converter) { egg_prim->set_color(_face_color); } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int XFileMaterial:: compare_to(const XFileMaterial &other) const { int ct; @@ -152,37 +140,29 @@ compare_to(const XFileMaterial &other) const { return ct; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::has_material -// Access: Public -// Description: Returns true if this material represents something -// meaningful, or false if the default material is -// sufficient. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this material represents something meaningful, or false if + * the default material is sufficient. + */ bool XFileMaterial:: has_material() const { return _has_material; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::has_texture -// Access: Public -// Description: Returns true if this material includes a texture map, -// false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this material includes a texture map, false otherwise. + */ bool XFileMaterial:: has_texture() const { return _has_texture; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::make_x_material -// Access: Public -// Description: Creates a Material object for the material list. -//////////////////////////////////////////////////////////////////// +/** + * Creates a Material object for the material list. + */ XFileDataNode *XFileMaterial:: make_x_material(XFileNode *x_meshMaterials, const string &suffix) { - XFileDataNode *x_material = + XFileDataNode *x_material = x_meshMaterials->add_Material("material" + suffix, _face_color, _power, _specular_color, _emissive_color); @@ -194,12 +174,10 @@ make_x_material(XFileNode *x_meshMaterials, const string &suffix) { return x_material; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMaterial::fill_material -// Access: Public -// Description: Fills the structure based on the raw data from the -// X file's Material object. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the X file's Material + * object. + */ bool XFileMaterial:: fill_material(XFileDataNode *obj) { _face_color = LCAST(PN_stdfloat, (*obj)["faceColor"].vec4()); @@ -208,8 +186,8 @@ fill_material(XFileDataNode *obj) { _emissive_color = LCAST(PN_stdfloat, (*obj)["emissiveColor"].vec3()); _has_material = true; - // Walk through the children of the material. If there are any, - // there should be only one, and it should be just a Texture. + // Walk through the children of the material. If there are any, there + // should be only one, and it should be just a Texture. int num_objects = obj->get_num_objects(); for (int i = 0; i < num_objects; i++) { XFileDataNode *child = obj->get_object(i); diff --git a/pandatool/src/xfileegg/xFileMaterial.h b/pandatool/src/xfileegg/xFileMaterial.h index 5aef759355..915bff11b0 100644 --- a/pandatool/src/xfileegg/xFileMaterial.h +++ b/pandatool/src/xfileegg/xFileMaterial.h @@ -1,16 +1,15 @@ -// Filename: xFileMaterial.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMaterial.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEMATERIAL_H #define XFILEMATERIAL_H @@ -25,11 +24,10 @@ class XFileToEggConverter; class XFileNode; class XFileDataNode; -//////////////////////////////////////////////////////////////////// -// Class : XFileMaterial -// Description : This represents an X file "material", which consists -// of a color, lighting, and/or texture specification. -//////////////////////////////////////////////////////////////////// +/** + * This represents an X file "material", which consists of a color, lighting, + * and/or texture specification. + */ class XFileMaterial { public: XFileMaterial(); @@ -58,4 +56,3 @@ private: }; #endif - diff --git a/pandatool/src/xfileegg/xFileMesh.cxx b/pandatool/src/xfileegg/xFileMesh.cxx index 979650d74e..7298ef118b 100644 --- a/pandatool/src/xfileegg/xFileMesh.cxx +++ b/pandatool/src/xfileegg/xFileMesh.cxx @@ -1,16 +1,15 @@ -// Filename: xFileMesh.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMesh.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileMesh.h" #include "xFileFace.h" @@ -25,11 +24,9 @@ #include "eggPolygon.h" #include "eggGroupNode.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMesh:: XFileMesh(CoordinateSystem cs) : _cs(cs) { _has_normals = false; @@ -39,21 +36,17 @@ XFileMesh(CoordinateSystem cs) : _cs(cs) { _egg_parent = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileMesh:: ~XFileMesh() { clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::clear -// Access: Public -// Description: Empties all data from the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Empties all data from the mesh. + */ void XFileMesh:: clear() { Vertices::iterator vi; @@ -92,11 +85,9 @@ clear() { _has_materials = false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_polygon -// Access: Public -// Description: Adds the indicated polygon to the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Adds the indicated polygon to the mesh. + */ void XFileMesh:: add_polygon(EggPolygon *egg_poly) { XFileFace *face = new XFileFace; @@ -104,13 +95,10 @@ add_polygon(EggPolygon *egg_poly) { _faces.push_back(face); } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_vertex -// Access: Public -// Description: Creates a new XFileVertex, if one does not already -// exist for the indicated vertex, and returns its -// index. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new XFileVertex, if one does not already exist for the indicated + * vertex, and returns its index. + */ int XFileMesh:: add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) { int next_index = _vertices.size(); @@ -139,13 +127,10 @@ add_vertex(EggVertex *egg_vertex, EggPrimitive *egg_prim) { } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_normal -// Access: Public -// Description: Creates a new XFileNormal, if one does not already -// exist for the indicated normal, and returns its -// index. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new XFileNormal, if one does not already exist for the indicated + * normal, and returns its index. + */ int XFileMesh:: add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim) { int next_index = _normals.size(); @@ -170,13 +155,10 @@ add_normal(EggVertex *egg_vertex, EggPrimitive *egg_prim) { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_material -// Access: Public -// Description: Creates a new XFileMaterial, if one does not already -// exist for the indicated material, and returns its -// index. -//////////////////////////////////////////////////////////////////// +/** + * Creates a new XFileMaterial, if one does not already exist for the + * indicated material, and returns its index. + */ int XFileMesh:: add_material(EggPrimitive *egg_prim) { int next_index = _materials.size(); @@ -202,14 +184,11 @@ add_material(EggPrimitive *egg_prim) { } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_vertex -// Access: Public -// Description: Adds the newly-created XFileVertex unequivocally to -// the mesh, returning its index number. The XFileMesh -// object becomes the owner of the XFileVertex -// pointer, and will delete it when it destructs. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created XFileVertex unequivocally to the mesh, returning its + * index number. The XFileMesh object becomes the owner of the XFileVertex + * pointer, and will delete it when it destructs. + */ int XFileMesh:: add_vertex(XFileVertex *vertex) { if (vertex->_has_color) { @@ -225,14 +204,11 @@ add_vertex(XFileVertex *vertex) { return next_index; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_normal -// Access: Public -// Description: Adds the newly-created XFileNormal unequivocally to -// the mesh, returning its index number. The XFileMesh -// object becomes the owner of the XFileNormal -// pointer, and will delete it when it destructs. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created XFileNormal unequivocally to the mesh, returning its + * index number. The XFileMesh object becomes the owner of the XFileNormal + * pointer, and will delete it when it destructs. + */ int XFileMesh:: add_normal(XFileNormal *normal) { if (normal->_has_normal) { @@ -245,14 +221,11 @@ add_normal(XFileNormal *normal) { return next_index; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::add_material -// Access: Public -// Description: Adds the newly-created XFileMaterial unequivocally to -// the mesh, returning its index number. The XFileMesh -// object becomes the owner of the XFileMaterial -// pointer, and will delete it when it destructs. -//////////////////////////////////////////////////////////////////// +/** + * Adds the newly-created XFileMaterial unequivocally to the mesh, returning + * its index number. The XFileMesh object becomes the owner of the + * XFileMaterial pointer, and will delete it when it destructs. + */ int XFileMesh:: add_material(XFileMaterial *material) { if (material->has_material()) { @@ -265,13 +238,10 @@ add_material(XFileMaterial *material) { return next_index; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::set_egg_parent -// Access: Public -// Description: Specifies the egg node that will eventually be the -// parent of this mesh, when create_polygons() is later -// called. -//////////////////////////////////////////////////////////////////// +/** + * Specifies the egg node that will eventually be the parent of this mesh, + * when create_polygons() is later called. + */ void XFileMesh:: set_egg_parent(EggGroupNode *egg_parent) { // We actually put the mesh under its own group. @@ -281,13 +251,10 @@ set_egg_parent(EggGroupNode *egg_parent) { _egg_parent = egg_group; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::create_polygons -// Access: Public -// Description: Creates a slew of EggPolygons according to the faces -// in the mesh, and adds them to the -// previously-indicated parent node. -//////////////////////////////////////////////////////////////////// +/** + * Creates a slew of EggPolygons according to the faces in the mesh, and adds + * them to the previously-indicated parent node. + */ bool XFileMesh:: create_polygons(XFileToEggConverter *converter) { nassertr(_egg_parent != (EggGroupNode *)NULL, false); @@ -336,10 +303,10 @@ create_polygons(XFileToEggConverter *converter) { temp_vtx.set_normal(normal->_normal); } - // We are given the vertex in local space; we need to transform - // it into global space. If the vertex has been skinned, that - // means the global space of all of its joints (modified by the - // matrix_offset provided in the skinning data). + // We are given the vertex in local space; we need to transform it into + // global space. If the vertex has been skinned, that means the global + // space of all of its joints (modified by the matrix_offset provided in + // the skinning data). double net_weight = 0.0; LMatrix4d weighted_transform(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -368,8 +335,8 @@ create_polygons(XFileToEggConverter *converter) { } else { // The vertex was skinned into one or more joints. Therefore, - // transform it according to the blended matrix_offset from - // the skinning data. + // transform it according to the blended matrix_offset from the + // skinning data. weighted_transform /= net_weight; temp_vtx.transform(weighted_transform); } @@ -408,87 +375,71 @@ create_polygons(XFileToEggConverter *converter) { } if (!has_normals()) { - // If we don't have explicit normals, make some up, per the DX - // spec. Since the DX spec doesn't mention anything about a - // crease angle, we should be as generous as possible. + // If we don't have explicit normals, make some up, per the DX spec. + // Since the DX spec doesn't mention anything about a crease angle, we + // should be as generous as possible. _egg_parent->recompute_vertex_normals(180.0, _cs); } return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::has_normals -// Access: Public -// Description: Returns true if any of the vertices or faces added to -// this mesh used a normal, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the vertices or faces added to this mesh used a + * normal, false otherwise. + */ bool XFileMesh:: has_normals() const { return _has_normals; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::has_colors -// Access: Public -// Description: Returns true if any of the vertices or faces added to -// this mesh used a color, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the vertices or faces added to this mesh used a + * color, false otherwise. + */ bool XFileMesh:: has_colors() const { return _has_colors; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::has_uvs -// Access: Public -// Description: Returns true if any of the vertices added to this -// mesh used a texture coordinate, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the vertices added to this mesh used a texture + * coordinate, false otherwise. + */ bool XFileMesh:: has_uvs() const { return _has_uvs; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::has_materials -// Access: Public -// Description: Returns true if any of the faces added to this mesh -// used a real material, false otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if any of the faces added to this mesh used a real material, + * false otherwise. + */ bool XFileMesh:: has_materials() const { return _has_materials; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::get_num_materials -// Access: Public -// Description: Returns the number of distinct materials associated -// with the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Returns the number of distinct materials associated with the mesh. + */ int XFileMesh:: get_num_materials() const { return _materials.size(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::get_material -// Access: Public -// Description: Returns a pointer to the nth materials associated -// with the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Returns a pointer to the nth materials associated with the mesh. + */ XFileMaterial *XFileMesh:: get_material(int n) const { nassertr(n >= 0 && n < (int)_materials.size(), (XFileMaterial *)NULL); return _materials[n]; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::make_x_mesh -// Access: Public -// Description: Creates an X structure corresponding to the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Creates an X structure corresponding to the mesh. + */ XFileDataNode *XFileMesh:: make_x_mesh(XFileNode *x_parent, const string &suffix) { XFileDataNode *x_mesh = x_parent->add_Mesh("mesh" + suffix); @@ -543,11 +494,9 @@ make_x_mesh(XFileNode *x_parent, const string &suffix) { return x_mesh; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::make_x_normals -// Access: Public -// Description: Creates a MeshNormals table for the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Creates a MeshNormals table for the mesh. + */ XFileDataNode *XFileMesh:: make_x_normals(XFileNode *x_mesh, const string &suffix) { XFileDataNode *x_meshNormals = x_mesh->add_MeshNormals("norms" + suffix); @@ -582,11 +531,9 @@ make_x_normals(XFileNode *x_mesh, const string &suffix) { return x_meshNormals; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::make_x_colors -// Access: Public -// Description: Creates a MeshVertexColors table for the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Creates a MeshVertexColors table for the mesh. + */ XFileDataNode *XFileMesh:: make_x_colors(XFileNode *x_mesh, const string &suffix) { XFileDataNode *x_meshColors = x_mesh->add_MeshVertexColors("colors" + suffix); @@ -603,21 +550,19 @@ make_x_colors(XFileNode *x_mesh, const string &suffix) { } (*x_meshColors)["nVertexColors"] = x_colors.size(); - + return x_meshColors; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::make_x_uvs -// Access: Public -// Description: Creates a MeshTextureCoords table for the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Creates a MeshTextureCoords table for the mesh. + */ XFileDataNode *XFileMesh:: make_x_uvs(XFileNode *x_mesh, const string &suffix) { XFileDataNode *x_meshUvs = x_mesh->add_MeshTextureCoords("uvs" + suffix); XFileDataObject &x_uvs = (*x_meshUvs)["textureCoords"]; - + Vertices::const_iterator vi; for (vi = _vertices.begin(); vi != _vertices.end(); ++vi) { XFileVertex *vertex = (*vi); @@ -629,14 +574,12 @@ make_x_uvs(XFileNode *x_mesh, const string &suffix) { return x_meshUvs; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::make_x_material_list -// Access: Public -// Description: Creates a MeshMaterialList table for the mesh. -//////////////////////////////////////////////////////////////////// +/** + * Creates a MeshMaterialList table for the mesh. + */ XFileDataNode *XFileMesh:: make_x_material_list(XFileNode *x_mesh, const string &suffix) { - XFileDataNode *x_meshMaterials = + XFileDataNode *x_meshMaterials = x_mesh->add_MeshMaterialList("materials" + suffix); // First, build up the list of faces the reference the materials. @@ -650,9 +593,8 @@ make_x_material_list(XFileNode *x_mesh, const string &suffix) { (*x_meshMaterials)["nFaceIndexes"] = x_indexes.size(); - // Now, build up the list of materials themselves. Each material is - // a child of the MeshMaterialList node, rather than an element of - // an array. + // Now, build up the list of materials themselves. Each material is a child + // of the MeshMaterialList node, rather than an element of an array. for (size_t i = 0; i < _materials.size(); i++) { XFileMaterial *material = _materials[i]; @@ -665,12 +607,9 @@ make_x_material_list(XFileNode *x_mesh, const string &suffix) { return x_meshMaterials; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_mesh -// Access: Public -// Description: Fills the structure based on the raw data from the -// X file's Mesh object. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the X file's Mesh object. + */ bool XFileMesh:: fill_mesh(XFileDataNode *obj) { clear(); @@ -711,12 +650,9 @@ fill_mesh(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_mesh_child -// Access: Public -// Description: Fills the structure based on one of the children of -// the Mesh object. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on one of the children of the Mesh object. + */ bool XFileMesh:: fill_mesh_child(XFileDataNode *obj) { if (obj->is_standard_object("MeshNormals")) { @@ -741,7 +677,7 @@ fill_mesh_child(XFileDataNode *obj) { } else if (obj->is_standard_object("XSkinMeshHeader")) { // Quietly ignore a skin mesh header. - + } else if (obj->is_standard_object("SkinWeights")) { if (!fill_skin_weights(obj)) { return false; @@ -754,16 +690,13 @@ fill_mesh_child(XFileDataNode *obj) { << obj->get_template_name() << "\n"; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_normals -// Access: Public -// Description: Fills the structure based on the raw data from the -// MeshNormals template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the MeshNormals template. + */ bool XFileMesh:: fill_normals(XFileDataNode *obj) { int i, j; @@ -779,7 +712,7 @@ fill_normals(XFileDataNode *obj) { const XFileDataObject &faceNormals = (*obj)["faceNormals"]; if (faceNormals.size() != (int)_faces.size()) { xfile_cat.warning() - << "Incorrect number of faces in MeshNormals within " + << "Incorrect number of faces in MeshNormals within " << get_name() << "\n"; } @@ -790,7 +723,7 @@ fill_normals(XFileDataNode *obj) { const XFileDataObject &faceIndices = faceNormals[i]["faceVertexIndices"]; if (faceIndices.size() != (int)face->_vertices.size()) { - xfile_cat.warning() + xfile_cat.warning() << "Incorrect number of vertices for face in MeshNormals within " << get_name() << "\n"; } @@ -804,12 +737,10 @@ fill_normals(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_colors -// Access: Public -// Description: Fills the structure based on the raw data from the -// MeshVertexColors template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the MeshVertexColors + * template. + */ bool XFileMesh:: fill_colors(XFileDataNode *obj) { const XFileDataObject &vertexColors = (*obj)["vertexColors"]; @@ -817,7 +748,7 @@ fill_colors(XFileDataNode *obj) { int vertex_index = vertexColors[i]["index"].i(); if (vertex_index < 0 || vertex_index >= (int)_vertices.size()) { xfile_cat.warning() - << "Vertex index out of range in MeshVertexColors within " + << "Vertex index out of range in MeshVertexColors within " << get_name() << "\n"; continue; } @@ -830,18 +761,16 @@ fill_colors(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_uvs -// Access: Public -// Description: Fills the structure based on the raw data from the -// MeshTextureCoords template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the MeshTextureCoords + * template. + */ bool XFileMesh:: fill_uvs(XFileDataNode *obj) { const XFileDataObject &textureCoords = (*obj)["textureCoords"]; if (textureCoords.size() != (int)_vertices.size()) { xfile_cat.warning() - << "Wrong number of vertices in MeshTextureCoords within " + << "Wrong number of vertices in MeshTextureCoords within " << get_name() << "\n"; } @@ -855,16 +784,13 @@ fill_uvs(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_skin_weights -// Access: Public -// Description: Fills the structure based on the raw data from the -// SkinWeights template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the SkinWeights template. + */ bool XFileMesh:: fill_skin_weights(XFileDataNode *obj) { - // Create a new SkinWeightsData record for the table. We'll need - // this data later when we create the vertices. + // Create a new SkinWeightsData record for the table. We'll need this data + // later when we create the vertices. _skin_weights.push_back(SkinWeightsData()); SkinWeightsData &data = _skin_weights.back(); @@ -898,12 +824,10 @@ fill_skin_weights(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileMesh::fill_material_list -// Access: Public -// Description: Fills the structure based on the raw data from the -// MeshMaterialList template. -//////////////////////////////////////////////////////////////////// +/** + * Fills the structure based on the raw data from the MeshMaterialList + * template. + */ bool XFileMesh:: fill_material_list(XFileDataNode *obj) { const XFileDataObject &faceIndexes = (*obj)["faceIndexes"]; @@ -921,16 +845,16 @@ fill_material_list(XFileDataNode *obj) { i++; } - // The rest of the faces get the same material index as the last - // one in the list. + // The rest of the faces get the same material index as the last one in the + // list. while (i < (int)_faces.size()) { XFileFace *face = _faces[i]; face->_material_index = material_index; i++; } - // Now look for children of the MaterialList object. These should - // all be Material objects. + // Now look for children of the MaterialList object. These should all be + // Material objects. int num_objects = obj->get_num_objects(); for (i = 0; i < num_objects; i++) { XFileDataNode *child = obj->get_object(i); diff --git a/pandatool/src/xfileegg/xFileMesh.h b/pandatool/src/xfileegg/xFileMesh.h index 8e60722aae..8c300f2db6 100644 --- a/pandatool/src/xfileegg/xFileMesh.h +++ b/pandatool/src/xfileegg/xFileMesh.h @@ -1,16 +1,15 @@ -// Filename: xFileMesh.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileMesh.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEMESH_H #define XFILEMESH_H @@ -38,10 +37,9 @@ class EggPolygon; class EggPrimitive; class Datagram; -//////////////////////////////////////////////////////////////////// -// Class : XFileMesh -// Description : This is a collection of polygons; i.e. a polyset. -//////////////////////////////////////////////////////////////////// +/** + * This is a collection of polygons; i.e. a polyset. + */ class XFileMesh : public Namable { public: XFileMesh(CoordinateSystem cs = CS_yup_left); @@ -124,4 +122,3 @@ private: }; #endif - diff --git a/pandatool/src/xfileegg/xFileNormal.cxx b/pandatool/src/xfileegg/xFileNormal.cxx index 316f5ce224..748cdd8c47 100644 --- a/pandatool/src/xfileegg/xFileNormal.cxx +++ b/pandatool/src/xfileegg/xFileNormal.cxx @@ -1,38 +1,33 @@ -// Filename: xFileNormal.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileNormal.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileNormal.h" #include "eggVertex.h" #include "eggPrimitive.h" #include "config_xfile.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileNormal::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileNormal:: XFileNormal() { _normal.set(0.0, 0.0, 0.0); _has_normal = false; } -//////////////////////////////////////////////////////////////////// -// Function: XFileNormal::set_from_egg -// Access: Public -// Description: Sets the structure up from the indicated egg data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the structure up from the indicated egg data. + */ void XFileNormal:: set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { if (egg_vertex->has_normal() || egg_prim->has_normal()) { @@ -44,8 +39,8 @@ set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { } if (xfile_one_mesh) { - // If this is going into one big mesh, we must ensure every - // vertex is in world coordinates. + // If this is going into one big mesh, we must ensure every vertex is in + // world coordinates. norm = norm * egg_prim->get_vertex_frame(); } else { // Otherwise, we ensure the vertex is in local coordinates. @@ -57,11 +52,9 @@ set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileNormal::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int XFileNormal:: compare_to(const XFileNormal &other) const { int ct; diff --git a/pandatool/src/xfileegg/xFileNormal.h b/pandatool/src/xfileegg/xFileNormal.h index 66e5b827f2..f87199362a 100644 --- a/pandatool/src/xfileegg/xFileNormal.h +++ b/pandatool/src/xfileegg/xFileNormal.h @@ -1,16 +1,15 @@ -// Filename: xFileNormal.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileNormal.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILENORMAL_H #define XFILENORMAL_H @@ -21,13 +20,11 @@ class EggVertex; class EggPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : XFileNormal -// Description : This represents a single normal associated with an -// XFileFace. It is separate from XFileVertex, because -// the X syntax supports a different table of normals -// than that of vertices. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single normal associated with an XFileFace. It is + * separate from XFileVertex, because the X syntax supports a different table + * of normals than that of vertices. + */ class XFileNormal { public: XFileNormal(); @@ -39,4 +36,3 @@ public: }; #endif - diff --git a/pandatool/src/xfileegg/xFileToEggConverter.cxx b/pandatool/src/xfileegg/xFileToEggConverter.cxx index e2982c3327..5b1c6459af 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.cxx +++ b/pandatool/src/xfileegg/xFileToEggConverter.cxx @@ -1,16 +1,15 @@ -// Filename: xFileToEggConverter.cxx -// Created by: drose (21Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileToEggConverter.cxx + * @author drose + * @date 2001-06-21 + */ #include "xFileToEggConverter.h" #include "xFileMesh.h" @@ -27,11 +26,9 @@ #include "eggTextureCollection.h" #include "dcast.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileToEggConverter:: XFileToEggConverter() { _make_char = false; @@ -40,11 +37,9 @@ XFileToEggConverter() { _dart_node = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::Copy Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileToEggConverter:: XFileToEggConverter(const XFileToEggConverter ©) : SomethingToEggConverter(copy), @@ -54,73 +49,56 @@ XFileToEggConverter(const XFileToEggConverter ©) : _dart_node = NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileToEggConverter:: ~XFileToEggConverter() { close(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::make_copy -// Access: Public, Virtual -// Description: Allocates and returns a new copy of the converter. -//////////////////////////////////////////////////////////////////// +/** + * Allocates and returns a new copy of the converter. + */ SomethingToEggConverter *XFileToEggConverter:: make_copy() { return new XFileToEggConverter(*this); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::get_name -// Access: Public, Virtual -// Description: Returns the English name of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the English name of the file type this converter supports. + */ string XFileToEggConverter:: get_name() const { return "DirectX"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::get_extension -// Access: Public, Virtual -// Description: Returns the common extension of the file type this -// converter supports. -//////////////////////////////////////////////////////////////////// +/** + * Returns the common extension of the file type this converter supports. + */ string XFileToEggConverter:: get_extension() const { return "x"; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::supports_compressed -// Access: Published, Virtual -// Description: Returns true if this file type can transparently load -// compressed files (with a .pz extension), false -// otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns true if this file type can transparently load compressed files + * (with a .pz extension), false otherwise. + */ bool XFileToEggConverter:: supports_compressed() const { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_file -// Access: Public, Virtual -// Description: Handles the reading of the input file and converting -// it to egg. Returns true if successful, false -// otherwise. -// -// This is designed to be as generic as possible, -// generally in support of run-time loading. -// Command-line converters may choose to use -// convert_flt() instead, as it provides more control. -//////////////////////////////////////////////////////////////////// +/** + * Handles the reading of the input file and converting it to egg. Returns + * true if successful, false otherwise. + * + * This is designed to be as generic as possible, generally in support of run- + * time loading. Command-line converters may choose to use convert_flt() + * instead, as it provides more control. + */ bool XFileToEggConverter:: convert_file(const Filename &filename) { close(); @@ -160,20 +138,17 @@ convert_file(const Filename &filename) { if (_keep_model && !_keep_animation) { strip_nodes(EggTable::get_class_type()); } - + if (_keep_animation && !_keep_model) { strip_nodes(EggGroup::get_class_type()); } - + return !had_error(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::close -// Access: Public -// Description: Finalizes and closes the file previously opened via -// convert_file(). -//////////////////////////////////////////////////////////////////// +/** + * Finalizes and closes the file previously opened via convert_file(). + */ void XFileToEggConverter:: close() { _x_file->clear(); @@ -184,7 +159,7 @@ close() { delete (*mi); } _meshes.clear(); - + AnimationSets::const_iterator asi; for (asi = _animation_sets.begin(); asi != _animation_sets.end(); ++asi) { delete (*asi); @@ -194,12 +169,10 @@ close() { _joints.clear(); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::strip_nodes -// Access: Public -// Description: Removes all groups of the given type. This is used -// to implement the -anim and -model options. -//////////////////////////////////////////////////////////////////// +/** + * Removes all groups of the given type. This is used to implement the -anim + * and -model options. + */ void XFileToEggConverter:: strip_nodes(TypeHandle t) { pvector garbage; @@ -215,49 +188,38 @@ strip_nodes(TypeHandle t) { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::get_dart_node -// Access: Public -// Description: Returns the root of the joint hierarchy, if -// _make_char is true, or NULL otherwise. -//////////////////////////////////////////////////////////////////// +/** + * Returns the root of the joint hierarchy, if _make_char is true, or NULL + * otherwise. + */ EggGroup *XFileToEggConverter:: get_dart_node() const { return _dart_node; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::create_unique_texture -// Access: Public -// Description: Returns an EggTexture pointer whose properties match -// that of the the given EggTexture, except for the tref -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggTexture pointer whose properties match that of the the given + * EggTexture, except for the tref name. + */ EggTexture *XFileToEggConverter:: create_unique_texture(const EggTexture ©) { return _textures.create_unique_texture(copy, ~EggTexture::E_tref_name); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::create_unique_material -// Access: Public -// Description: Returns an EggMaterial pointer whose properties match -// that of the the given EggMaterial, except for the mref -// name. -//////////////////////////////////////////////////////////////////// +/** + * Returns an EggMaterial pointer whose properties match that of the the given + * EggMaterial, except for the mref name. + */ EggMaterial *XFileToEggConverter:: create_unique_material(const EggMaterial ©) { return _materials.create_unique_material(copy, ~EggMaterial::E_mref_name); } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::find_joint -// Access: Public -// Description: This is called by set_animation_frame, for -// the purposes of building the frame data for the -// animation--it needs to know the original rest frame -// transform. -//////////////////////////////////////////////////////////////////// +/** + * This is called by set_animation_frame, for the purposes of building the + * frame data for the animation--it needs to know the original rest frame + * transform. + */ EggGroup *XFileToEggConverter:: find_joint(const string &joint_name) { Joints::iterator ji; @@ -272,9 +234,8 @@ find_joint(const string &joint_name) { return joint; } - // Joint name is unknown. Issue a warning, then insert NULL into - // the table so we don't get the same warning again with the next - // polygon. + // Joint name is unknown. Issue a warning, then insert NULL into the table + // so we don't get the same warning again with the next polygon. if (_make_char) { xfile_cat.warning() << "Joint name " << joint_name << " in animation data is undefined.\n"; @@ -284,13 +245,10 @@ find_joint(const string &joint_name) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::get_toplevel -// Access: Private -// Description: Pulls off all of the top-level objects in the .x file -// and converts them, and their descendents, to the -// appropriate egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Pulls off all of the top-level objects in the .x file and converts them, + * and their descendents, to the appropriate egg structures. + */ bool XFileToEggConverter:: get_toplevel() { int num_objects = _x_file->get_num_objects(); @@ -298,8 +256,8 @@ get_toplevel() { _ticks_per_second = 4800; // X File default. - // First, make a pass through the toplevel objects and see if we - // have frames and/or animation. + // First, make a pass through the toplevel objects and see if we have frames + // andor animation. _any_frames = false; _any_animation = false; for (i = 0; i < num_objects; i++) { @@ -317,9 +275,9 @@ get_toplevel() { } EggGroupNode *egg_parent = _egg_data; - - // If we are converting an animatable model, make an extra node to - // represent the root of the hierarchy. + + // If we are converting an animatable model, make an extra node to represent + // the root of the hierarchy. if (_make_char) { _dart_node = new EggGroup(_char_name); egg_parent->add_child(_dart_node); @@ -337,20 +295,18 @@ get_toplevel() { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_toplevel_object -// Access: Private -// Description: Converts the indicated object, encountered outside of -// any Frames, to the appropriate egg structures. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated object, encountered outside of any Frames, to the + * appropriate egg structures. + */ bool XFileToEggConverter:: convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent) { if (obj->is_standard_object("Header")) { // Quietly ignore headers. } else if (obj->is_standard_object("Material")) { - // Quietly ignore toplevel materials. These will presumably be - // referenced below. + // Quietly ignore toplevel materials. These will presumably be referenced + // below. } else if (obj->is_standard_object("Frame")) { if (!convert_frame(obj, egg_parent)) { @@ -366,11 +322,11 @@ convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent) { _ticks_per_second = (*obj)[0].i(); } else if (obj->is_standard_object("Mesh")) { - // If there are any Frames at all in the file, then assume a Mesh - // at the toplevel is just present to define a reference that will - // be included below--so we ignore it here. On the other hand, if - // the file has no Frames, then a Mesh at the toplevel must be - // actual geometry, so convert it now. + // If there are any Frames at all in the file, then assume a Mesh at the + // toplevel is just present to define a reference that will be included + // below--so we ignore it here. On the other hand, if the file has no + // Frames, then a Mesh at the toplevel must be actual geometry, so convert + // it now. if (!_any_frames) { if (!convert_mesh(obj, egg_parent)) { return false; @@ -384,16 +340,13 @@ convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent) { << obj->get_template_name() << "\n"; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_object -// Access: Private -// Description: Converts the indicated object to the appropriate egg -// structures. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated object to the appropriate egg structures. + */ bool XFileToEggConverter:: convert_object(XFileDataNode *obj, EggGroupNode *egg_parent) { if (obj->is_standard_object("Header")) { @@ -421,23 +374,20 @@ convert_object(XFileDataNode *obj, EggGroupNode *egg_parent) { << obj->get_template_name() << "\n"; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_frame -// Access: Private -// Description: Converts the indicated frame to the appropriate egg -// structures. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated frame to the appropriate egg structures. + */ bool XFileToEggConverter:: convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent) { string name = obj->get_name(); EggGroup *group = new EggGroup(name); egg_parent->add_child(group); - + if (_make_char) { group->set_group_type(EggGroup::GT_joint); if (name.empty()) { @@ -465,15 +415,11 @@ convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_transform -// Access: Private -// Description: Reads a transform matrix, a child of a given frame, -// and applies it to the node. Normally this can only -// be done if the node in question is an EggGroup, which -// should be the case if the transform was a child of a -// frame. -//////////////////////////////////////////////////////////////////// +/** + * Reads a transform matrix, a child of a given frame, and applies it to the + * node. Normally this can only be done if the node in question is an + * EggGroup, which should be the case if the transform was a child of a frame. + */ bool XFileToEggConverter:: convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent) { LMatrix4d mat = (*obj)["frameMatrix"]["matrix"].mat4(); @@ -491,13 +437,10 @@ convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_animation_set -// Access: Private -// Description: Begins an AnimationSet. This is the root of one -// particular animation (table of frames per joint) to -// be applied to the model within this file. -//////////////////////////////////////////////////////////////////// +/** + * Begins an AnimationSet. This is the root of one particular animation + * (table of frames per joint) to be applied to the model within this file. + */ bool XFileToEggConverter:: convert_animation_set(XFileDataNode *obj) { XFileAnimationSet *animation_set = new XFileAnimationSet(); @@ -506,8 +449,8 @@ convert_animation_set(XFileDataNode *obj) { _total_tick_deltas = 0; _num_ticks = 0; - // Now walk through the children of the set; each one animates a - // different joint. + // Now walk through the children of the set; each one animates a different + // joint. int num_objects = obj->get_num_objects(); for (int i = 0; i < num_objects; i++) { if (!convert_animation_set_object(obj->get_object(i), *animation_set)) { @@ -529,14 +472,11 @@ convert_animation_set(XFileDataNode *obj) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_animation_set_object -// Access: Private -// Description: Converts the indicated object, a child of a -// AnimationSet. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated object, a child of a AnimationSet. + */ bool XFileToEggConverter:: -convert_animation_set_object(XFileDataNode *obj, +convert_animation_set_object(XFileDataNode *obj, XFileAnimationSet &animation_set) { if (obj->is_standard_object("Animation")) { if (!convert_animation(obj, animation_set)) { @@ -550,24 +490,22 @@ convert_animation_set_object(XFileDataNode *obj, << obj->get_template_name() << "\n"; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_animation -// Access: Private -// Description: Converts the indicated Animation template object. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated Animation template object. + */ bool XFileToEggConverter:: convert_animation(XFileDataNode *obj, XFileAnimationSet &animation_set) { - // Within an Animation template, we expect to find a reference to a - // frame, possibly an AnimationOptions object, and one or more - // AnimationKey objects. + // Within an Animation template, we expect to find a reference to a frame, + // possibly an AnimationOptions object, and one or more AnimationKey + // objects. - // First, walk through the list of children, to find the one that is - // the frame reference. We need to know this up front so we know - // which table we should be building up. + // First, walk through the list of children, to find the one that is the + // frame reference. We need to know this up front so we know which table we + // should be building up. string frame_name; bool got_frame_name = false; @@ -600,12 +538,9 @@ convert_animation(XFileDataNode *obj, XFileAnimationSet &animation_set) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_animation_object -// Access: Private -// Description: Converts the indicated object, a child of a -// Animation. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated object, a child of a Animation. + */ bool XFileToEggConverter:: convert_animation_object(XFileDataNode *obj, const string &joint_name, XFileToEggConverter::FrameData &table) { @@ -627,30 +562,28 @@ convert_animation_object(XFileDataNode *obj, const string &joint_name, << obj->get_template_name() << "\n"; } } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_animation_key -// Access: Private -// Description: Converts the indicated AnimationKey template object. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated AnimationKey template object. + */ bool XFileToEggConverter:: -convert_animation_key(XFileDataNode *obj, const string &joint_name, +convert_animation_key(XFileDataNode *obj, const string &joint_name, XFileToEggConverter::FrameData &table) { int key_type = (*obj)["keyType"].i(); - + const XFileDataObject &keys = (*obj)["keys"]; int last_time = 0; for (int i = 0; i < keys.size(); i++) { - // The time value is problematic, since it allows x files to - // specify keyframes of arbitrary duration. Panda doesn't support - // this; all frames in Panda must be of a constant duration. - // Thus, we largely ignore the time value, but we take the average - // of all deltas as the duration. This will correctly handle .x - // files with uniform keyframes, at least. + // The time value is problematic, since it allows x files to specify + // keyframes of arbitrary duration. Panda doesn't support this; all + // frames in Panda must be of a constant duration. Thus, we largely + // ignore the time value, but we take the average of all deltas as the + // duration. This will correctly handle .x files with uniform keyframes, + // at least. int this_time = keys[i]["time"].i(); if (i != 0) { @@ -668,14 +601,12 @@ convert_animation_key(XFileDataNode *obj, const string &joint_name, return true; } - -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::set_animation_frame -// Access: Private -// Description: Sets a single frame of the animation data. -//////////////////////////////////////////////////////////////////// + +/** + * Sets a single frame of the animation data. + */ bool XFileToEggConverter:: -set_animation_frame(const string &joint_name, +set_animation_frame(const string &joint_name, XFileToEggConverter::FrameData &table, int frame, int key_type, const XFileDataObject &values) { if ((int)table._entries.size() <= frame) { @@ -688,9 +619,8 @@ set_animation_frame(const string &joint_name, // Now modify the last row in the table. switch (key_type) { case 0: - // Key type 0: rotation. - // This appears to be a quaternion. Hope we get the coordinate - // system right. + // Key type 0: rotation. This appears to be a quaternion. Hope we get + // the coordinate system right. if (values.size() != 4) { xfile_cat.error() << "Incorrect number of values in animation table: " @@ -711,7 +641,7 @@ set_animation_frame(const string &joint_name, frame_entry._scale = values.vec3(); table._flags |= XFileAnimationSet::FDF_scale; break; - + case 2: // Key type 2: position if (values.size() != 3) { @@ -747,16 +677,13 @@ set_animation_frame(const string &joint_name, << "Unsupported key type " << key_type << " in animation table.\n"; return false; } - + return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::convert_mesh -// Access: Private -// Description: Converts the indicated mesh to the appropriate egg -// structures. -//////////////////////////////////////////////////////////////////// +/** + * Converts the indicated mesh to the appropriate egg structures. + */ bool XFileToEggConverter:: convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent) { XFileMesh *mesh = new XFileMesh(_egg_data->get_coordinate_system()); @@ -773,12 +700,9 @@ convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent) { return true; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::create_polygons -// Access: Private -// Description: Creates all the polygons associated with -// previously-saved meshes. -//////////////////////////////////////////////////////////////////// +/** + * Creates all the polygons associated with previously-saved meshes. + */ bool XFileToEggConverter:: create_polygons() { bool okflag = true; @@ -795,12 +719,10 @@ create_polygons() { return okflag; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEggConverter::create_hierarchy -// Access: Private -// Description: Creates the animation table hierarchies for the -// previously-saved animation sets. -//////////////////////////////////////////////////////////////////// +/** + * Creates the animation table hierarchies for the previously-saved animation + * sets. + */ bool XFileToEggConverter:: create_hierarchy() { bool okflag = true; diff --git a/pandatool/src/xfileegg/xFileToEggConverter.h b/pandatool/src/xfileegg/xFileToEggConverter.h index 2c3b9ec181..c853cae4ca 100644 --- a/pandatool/src/xfileegg/xFileToEggConverter.h +++ b/pandatool/src/xfileegg/xFileToEggConverter.h @@ -1,16 +1,15 @@ -// Filename: xFileToEggConverter.h -// Created by: drose (21Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileToEggConverter.h + * @author drose + * @date 2001-06-21 + */ #ifndef XFILETOEGGCONVERTER_H #define XFILETOEGGCONVERTER_H @@ -35,10 +34,9 @@ class EggTexture; class EggMaterial; class XFileDataObject; -//////////////////////////////////////////////////////////////////// -// Class : XFileToEggConverter -// Description : -//////////////////////////////////////////////////////////////////// +/** + * + */ class XFileToEggConverter : public SomethingToEggConverter { public: XFileToEggConverter(); @@ -70,24 +68,24 @@ public: private: typedef XFileAnimationSet::FrameData FrameData; - + bool get_toplevel(); bool convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent); bool convert_object(XFileDataNode *obj, EggGroupNode *egg_parent); bool convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent); bool convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent); bool convert_animation_set(XFileDataNode *obj); - bool convert_animation_set_object(XFileDataNode *obj, + bool convert_animation_set_object(XFileDataNode *obj, XFileAnimationSet &animation_set); - bool convert_animation(XFileDataNode *obj, + bool convert_animation(XFileDataNode *obj, XFileAnimationSet &animation_set); - bool convert_animation_object(XFileDataNode *obj, + bool convert_animation_object(XFileDataNode *obj, const string &joint_name, FrameData &table); bool convert_animation_key(XFileDataNode *obj, const string &joint_name, FrameData &table); - bool set_animation_frame(const string &joint_name, FrameData &table, + bool set_animation_frame(const string &joint_name, FrameData &table, int frame, int key_type, - const XFileDataObject &values); + const XFileDataObject &values); bool convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent); bool create_polygons(); @@ -106,7 +104,7 @@ private: typedef pvector AnimationSets; AnimationSets _animation_sets; - + typedef pmap Joints; Joints _joints; diff --git a/pandatool/src/xfileegg/xFileVertex.cxx b/pandatool/src/xfileegg/xFileVertex.cxx index af7db14b3b..6fb3e105ad 100644 --- a/pandatool/src/xfileegg/xFileVertex.cxx +++ b/pandatool/src/xfileegg/xFileVertex.cxx @@ -1,27 +1,24 @@ -// Filename: xFileVertex.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileVertex.cxx + * @author drose + * @date 2001-06-19 + */ #include "xFileVertex.h" #include "eggVertex.h" #include "eggPrimitive.h" #include "config_xfile.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileVertex::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileVertex:: XFileVertex() { _has_color = false; @@ -31,18 +28,16 @@ XFileVertex() { _color.set(1.0f, 1.0f, 1.0f, 1.0f); } -//////////////////////////////////////////////////////////////////// -// Function: XFileVertex::set_from_egg -// Access: Public -// Description: Sets the structure up from the indicated egg data. -//////////////////////////////////////////////////////////////////// +/** + * Sets the structure up from the indicated egg data. + */ void XFileVertex:: set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { LVertexd pos = egg_vertex->get_pos3(); if (xfile_one_mesh) { - // If this is going into one big mesh, we must ensure every - // vertex is in world coordinates. + // If this is going into one big mesh, we must ensure every vertex is in + // world coordinates. pos = pos * egg_prim->get_vertex_frame(); } else { // Otherwise, we ensure the vertex is in local coordinates. @@ -76,11 +71,9 @@ set_from_egg(EggVertex *egg_vertex, EggPrimitive *egg_prim) { } } -//////////////////////////////////////////////////////////////////// -// Function: XFileVertex::compare_to -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ int XFileVertex:: compare_to(const XFileVertex &other) const { int ct; diff --git a/pandatool/src/xfileegg/xFileVertex.h b/pandatool/src/xfileegg/xFileVertex.h index 5a86bf66d2..2d88a3613f 100644 --- a/pandatool/src/xfileegg/xFileVertex.h +++ b/pandatool/src/xfileegg/xFileVertex.h @@ -1,16 +1,15 @@ -// Filename: xFileVertex.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileVertex.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEVERTEX_H #define XFILEVERTEX_H @@ -21,11 +20,9 @@ class EggVertex; class EggPrimitive; -//////////////////////////////////////////////////////////////////// -// Class : XFileVertex -// Description : This represents a single vertex associated with an -// XFileFace. -//////////////////////////////////////////////////////////////////// +/** + * This represents a single vertex associated with an XFileFace. + */ class XFileVertex { public: XFileVertex(); @@ -40,4 +37,3 @@ public: }; #endif - diff --git a/pandatool/src/xfileegg/xFileVertexPool.h b/pandatool/src/xfileegg/xFileVertexPool.h index 6281be33ca..3c99836c22 100644 --- a/pandatool/src/xfileegg/xFileVertexPool.h +++ b/pandatool/src/xfileegg/xFileVertexPool.h @@ -1,27 +1,25 @@ -// Filename: xFileVertexPool.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileVertexPool.h + * @author drose + * @date 2001-06-19 + */ #ifndef XFILEVERTEXPOOL_H #define XFILEVERTEXPOOL_H #include "pandatoolbase.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileVertexPool -// Description : This is a collection of unique vertices as extracted -// out of a Geom or a series of Geoms. -//////////////////////////////////////////////////////////////////// +/** + * This is a collection of unique vertices as extracted out of a Geom or a + * series of Geoms. + */ class XFileVertexPool { public: XFileVertexPool(); @@ -35,7 +33,7 @@ public: const LTexCoord *get_uvs(); const LColor *get_colors(); - + void set_normal(const LNormal &normal); void set_uv(const LTexCoord &uv); @@ -51,4 +49,3 @@ private: }; #endif - diff --git a/pandatool/src/xfileprogs/eggToX.cxx b/pandatool/src/xfileprogs/eggToX.cxx index 244da4405e..37c0fc8658 100644 --- a/pandatool/src/xfileprogs/eggToX.cxx +++ b/pandatool/src/xfileprogs/eggToX.cxx @@ -1,26 +1,23 @@ -// Filename: eggToX.cxx -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToX.cxx + * @author drose + * @date 2001-06-19 + */ #include "eggToX.h" #include "config_xfile.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: EggToX::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ EggToX:: EggToX() : EggToSomething("DirectX", ".x", true, false) { add_texture_options(); @@ -51,11 +48,9 @@ EggToX() : EggToSomething("DirectX", ".x", true, false) { } -//////////////////////////////////////////////////////////////////// -// Function: EggToX::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void EggToX:: run() { if (!do_reader_options()) { diff --git a/pandatool/src/xfileprogs/eggToX.h b/pandatool/src/xfileprogs/eggToX.h index 97eae0176d..9abef22581 100644 --- a/pandatool/src/xfileprogs/eggToX.h +++ b/pandatool/src/xfileprogs/eggToX.h @@ -1,16 +1,15 @@ -// Filename: eggToX.h -// Created by: drose (19Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file eggToX.h + * @author drose + * @date 2001-06-19 + */ #ifndef EGGTOX_H #define EGGTOX_H @@ -25,12 +24,10 @@ class Node; -//////////////////////////////////////////////////////////////////// -// Class : EggToX -// Description : A program to read in a egg file and write an -// equivalent, or nearly equivalent, DirectX-style "x" -// file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read in a egg file and write an equivalent, or nearly + * equivalent, DirectX-style "x" file. + */ class EggToX : public EggToSomething { public: EggToX(); diff --git a/pandatool/src/xfileprogs/xFileToEgg.cxx b/pandatool/src/xfileprogs/xFileToEgg.cxx index 046761e409..e7026b6642 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.cxx +++ b/pandatool/src/xfileprogs/xFileToEgg.cxx @@ -1,27 +1,24 @@ -// Filename: xFileToEgg.cxx -// Created by: drose (21Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileToEgg.cxx + * @author drose + * @date 2001-06-21 + */ #include "xFileToEgg.h" #include "xFileToEggConverter.h" #include "config_xfile.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileToEgg::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileToEgg:: XFileToEgg() : SomethingToEgg("DirectX", ".x") @@ -87,11 +84,9 @@ XFileToEgg() : _coordinate_system = CS_yup_left; } -//////////////////////////////////////////////////////////////////// -// Function: XFileToEgg::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void XFileToEgg:: run() { _data->set_coordinate_system(_coordinate_system); @@ -104,7 +99,7 @@ run() { converter._char_name = _char_name; converter._keep_model = _keep_model; converter._keep_animation = _keep_animation; - + // Copy in the path and animation parameters. apply_parameters(converter); diff --git a/pandatool/src/xfileprogs/xFileToEgg.h b/pandatool/src/xfileprogs/xFileToEgg.h index a7edf19c8d..2adbc7e2f7 100644 --- a/pandatool/src/xfileprogs/xFileToEgg.h +++ b/pandatool/src/xfileprogs/xFileToEgg.h @@ -1,16 +1,15 @@ -// Filename: xFileToEgg.h -// Created by: drose (21Jun01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileToEgg.h + * @author drose + * @date 2001-06-21 + */ #ifndef XFILETOEGG_H #define XFILETOEGG_H @@ -21,11 +20,9 @@ #include "dSearchPath.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileToEgg -// Description : A program to read a DirectX "x" file and generate an -// egg file. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a DirectX "x" file and generate an egg file. + */ class XFileToEgg : public SomethingToEgg { public: XFileToEgg(); @@ -41,4 +38,3 @@ public: }; #endif - diff --git a/pandatool/src/xfileprogs/xFileTrans.cxx b/pandatool/src/xfileprogs/xFileTrans.cxx index 8e1b406df4..0c5335055b 100644 --- a/pandatool/src/xfileprogs/xFileTrans.cxx +++ b/pandatool/src/xfileprogs/xFileTrans.cxx @@ -1,32 +1,29 @@ -// Filename: xFileTrans.cxx -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileTrans.cxx + * @author drose + * @date 2004-10-03 + */ #include "xFileTrans.h" #include "xFile.h" #include "pystub.h" -//////////////////////////////////////////////////////////////////// -// Function: XFileTrans::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ XFileTrans:: XFileTrans() : WithOutputFile(true, false, true) { - // Indicate the extension name we expect the user to supply for - // output files. + // Indicate the extension name we expect the user to supply for output + // files. _preferred_extension = ".x"; set_program_brief("reads and writes DirectX .x files"); @@ -48,11 +45,9 @@ XFileTrans() : } -//////////////////////////////////////////////////////////////////// -// Function: XFileTrans::run -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ void XFileTrans:: run() { nout << "Reading " << _input_filename << "\n"; @@ -70,11 +65,9 @@ run() { } -//////////////////////////////////////////////////////////////////// -// Function: XFileTrans::handle_args -// Access: Protected, Virtual -// Description: -//////////////////////////////////////////////////////////////////// +/** + * + */ bool XFileTrans:: handle_args(ProgramBase::Args &args) { if (!check_last_arg(args, 1)) { diff --git a/pandatool/src/xfileprogs/xFileTrans.h b/pandatool/src/xfileprogs/xFileTrans.h index 69c2dce236..85c77fd54c 100644 --- a/pandatool/src/xfileprogs/xFileTrans.h +++ b/pandatool/src/xfileprogs/xFileTrans.h @@ -1,16 +1,15 @@ -// Filename: xFileTrans.h -// Created by: drose (03Oct04) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) Carnegie Mellon University. All rights reserved. -// -// All use of this software is subject to the terms of the revised BSD -// license. You should have received a copy of this license along -// with this source code in a file named "LICENSE." -// -//////////////////////////////////////////////////////////////////// +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file xFileTrans.h + * @author drose + * @date 2004-10-03 + */ #ifndef XFILETRANS_H #define XFILETRANS_H @@ -20,12 +19,10 @@ #include "programBase.h" #include "withOutputFile.h" -//////////////////////////////////////////////////////////////////// -// Class : XFileTrans -// Description : A program to read a X file and output an -// essentially similar X file. This is mainly useful -// to test the X file parser used in Panda. -//////////////////////////////////////////////////////////////////// +/** + * A program to read a X file and output an essentially similar X file. This + * is mainly useful to test the X file parser used in Panda. + */ class XFileTrans : public ProgramBase, public WithOutputFile { public: XFileTrans(); @@ -39,4 +36,3 @@ protected: }; #endif - From 862f0e4db2a4b8c81d400af4d69fc6e65a3570e9 Mon Sep 17 00:00:00 2001 From: tobspr Date: Thu, 18 Feb 2016 18:34:54 +0100 Subject: [PATCH 12/31] Add more formats to TexturePeeker, emit error if format is not supported --- panda/src/gobj/texturePeeker.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index 35d691bab0..7ee9c87c70 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -91,8 +91,11 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { switch (_format) { case Texture::F_depth_stencil: case Texture::F_depth_component: - + case Texture::F_depth_component16: + case Texture::F_depth_component24: + case Texture::F_depth_component32: case Texture::F_red: + case Texture::F_r16: _get_texel = get_texel_r; break; @@ -109,23 +112,30 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { break; case Texture::F_luminance: + case Texture::F_sluminance: _get_texel = get_texel_l; break; case Texture::F_luminance_alpha: + case Texture::F_sluminance_alpha: case Texture::F_luminance_alphamask: _get_texel = get_texel_la; break; case Texture::F_rgb: + case Texture::F_srgb: case Texture::F_rgb5: case Texture::F_rgb8: case Texture::F_rgb12: + case Texture::F_rgb16: case Texture::F_rgb332: + case Texture::F_r11_g11_b10: + case Texture::F_rgb9_e5: _get_texel = get_texel_rgb; break; case Texture::F_rgba: + case Texture::F_srgb_alpha: case Texture::F_rgbm: case Texture::F_rgba4: case Texture::F_rgba5: @@ -133,10 +143,13 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { case Texture::F_rgba12: case Texture::F_rgba16: case Texture::F_rgba32: + case Texture::F_rgb10_a2: _get_texel = get_texel_rgba; break; default: // Not supported. + gobj_cat.error() << "Unsupported texture peeker format: " + << Texture::format_format(_format) << endl; _image.clear(); return; } From 1c9985d2f759a283bef9515acec39e03bb2d768c Mon Sep 17 00:00:00 2001 From: tobspr Date: Thu, 18 Feb 2016 19:43:26 +0100 Subject: [PATCH 13/31] Add bilinear filtering to TexturePeeker --- panda/src/gobj/texturePeeker.I | 8 +++++ panda/src/gobj/texturePeeker.cxx | 59 +++++++++++++++++++++++++++++++- panda/src/gobj/texturePeeker.h | 3 ++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/panda/src/gobj/texturePeeker.I b/panda/src/gobj/texturePeeker.I index 39246f70f3..da2a18d54d 100644 --- a/panda/src/gobj/texturePeeker.I +++ b/panda/src/gobj/texturePeeker.I @@ -48,3 +48,11 @@ INLINE int TexturePeeker:: get_z_size() const { return _z_size; } + +/** + * Returns whether a given coordinate is inside of the texture dimensions. + */ +INLINE bool TexturePeeker:: +has_pixel(size_t x, size_t y) const { + return x >= 0 && y >= 0 && x < _x_size && y < _y_size; +} diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index 7ee9c87c70..cbe9003def 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -168,13 +168,70 @@ void TexturePeeker:: lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const { int x = int((u - cfloor(u)) * (PN_stdfloat)_x_size) % _x_size; int y = int((v - cfloor(v)) * (PN_stdfloat)_y_size) % _y_size; + fetch_pixel(color, x, y); +} +/** + * Works like TexturePeeker::lookup(), but instead uv-coordinates integer + * coordinates are used. + */ +void TexturePeeker:: +fetch_pixel(LColor& color, size_t x, size_t y) const { nassertv(x >= 0 && x < _x_size && y >= 0 && y < _y_size); const unsigned char *p = _image.p() + (y * _x_size + x) * _pixel_width; - (*_get_texel)(color, p, _get_component); } + +/** + * Performs a bilinear lookup to retrieve the color value stored at the uv + * coordinate (u, v). + * + * In case the point is outside of the uv range, color is set to zero, + * and false is returned. Otherwise true is returned. + */ +bool TexturePeeker:: +lookup_bilinear(LColor &color, PN_stdfloat u, PN_stdfloat v) const { + color = LColor::zero(); + + u = u * _x_size - 0.5; + v = v * _y_size - 0.5; + + int min_u = int(floor(u)); + int min_v = int(floor(v)); + + PN_stdfloat frac_u = u - min_u; + PN_stdfloat frac_v = v - min_v; + + LColor p00(LColor::zero()), p01(LColor::zero()), p10(LColor::zero()), p11(LColor::zero()); + PN_stdfloat w00 = 0.0, w01 = 0.0, w10 = 0.0, w11 = 0.0; + + if (has_pixel(min_u, min_v)) { + w00 = (1.0 - frac_v) * (1.0 - frac_u); + fetch_pixel(p00, min_u, min_v); + } + if (has_pixel(min_u + 1, min_v)) { + w10 = (1.0 - frac_v) * frac_u; + fetch_pixel(p10, min_u + 1, min_v); + } + if (has_pixel(min_u, min_v + 1)) { + w01 = frac_v * (1.0 - frac_u); + fetch_pixel(p01, min_u, min_v + 1); + } + if (has_pixel(min_u + 1, min_v + 1)) { + w11 = frac_v * frac_u; + fetch_pixel(p11, min_u + 1, min_v + 1); + } + + PN_stdfloat net_w = w00 + w01 + w10 + w11; + if (net_w == 0.0) { + return false; + } + + color = (p00 * w00 + p01 * w01 + p10 * w10 + p11 * w11) / net_w; + return true; +} + /** * Fills "color" with the RGBA color of the texel at point (u, v, w). * diff --git a/panda/src/gobj/texturePeeker.h b/panda/src/gobj/texturePeeker.h index 14eaf5f0e9..e9af394dec 100644 --- a/panda/src/gobj/texturePeeker.h +++ b/panda/src/gobj/texturePeeker.h @@ -36,8 +36,11 @@ PUBLISHED: INLINE int get_y_size() const; INLINE int get_z_size() const; + INLINE bool has_pixel(size_t x, size_t y) const; void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v) const; void lookup(LColor &color, PN_stdfloat u, PN_stdfloat v, PN_stdfloat w) const; + void fetch_pixel(LColor &color, size_t x, size_t y) const; + bool lookup_bilinear(LColor &color, PN_stdfloat u, PN_stdfloat v) const; void filter_rect(LColor &color, PN_stdfloat min_u, PN_stdfloat min_v, PN_stdfloat max_u, PN_stdfloat max_v) const; From 0385da0f443cd357c3aa225aceaa8b80f1699391 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 19 Feb 2016 18:11:57 -0800 Subject: [PATCH 14/31] add PfmFile::indirect_1d_lookup() --- panda/src/pnmimage/pfmFile.cxx | 58 +++++++++++++++++++++++++++++++++ panda/src/pnmimage/pfmFile.h | 3 ++ panda/src/pnmimage/pnmImage.cxx | 4 +-- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index 45127887e4..b8d775ca1f 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -2158,6 +2158,64 @@ operator *= (float multiplier) { } } +/** + * index_image is a WxH 1-channel image, while pixel_values is an Nx1 + * image with any number of channels. Typically pixel_values will be + * a 256x1 image. + * + * Fills the PfmFile with a new image the same width and height as + * index_image, with the same number of channels as pixel_values. + * + * Each pixel of the new image is computed with the formula: + * + * new_image(x, y) = pixel_values(index_image(x, y)[channel], 0) + * + * At present, no interpolation is performed; the nearest value in + * pixel_values is discovered. This may change in the future. + */ +void PfmFile:: +indirect_1d_lookup(const PfmFile &index_image, int channel, + const PfmFile &pixel_values) { + clear(index_image.get_x_size(), index_image.get_y_size(), + pixel_values.get_num_channels()); + + for (int yi = 0; yi < get_y_size(); ++yi) { + switch (get_num_channels()) { + case 1: + for (int xi = 0; xi < get_x_size(); ++xi) { + int v = int(index_image.get_channel(xi, yi, channel) * (pixel_values.get_x_size() - 1) + 0.5); + nassertv(v >= 0 && v < pixel_values.get_x_size()); + set_point1(xi, yi, pixel_values.get_point1(v, 0)); + } + break; + + case 2: + for (int xi = 0; xi < get_x_size(); ++xi) { + int v = int(index_image.get_channel(xi, yi, channel) * (pixel_values.get_x_size() - 1) + 0.5); + nassertv(v >= 0 && v < pixel_values.get_x_size()); + set_point2(xi, yi, pixel_values.get_point2(v, 0)); + } + break; + + case 3: + for (int xi = 0; xi < get_x_size(); ++xi) { + int v = int(index_image.get_channel(xi, yi, channel) * (pixel_values.get_x_size() - 1) + 0.5); + nassertv(v >= 0 && v < pixel_values.get_x_size()); + set_point3(xi, yi, pixel_values.get_point3(v, 0)); + } + break; + + case 4: + for (int xi = 0; xi < get_x_size(); ++xi) { + int v = int(index_image.get_channel(xi, yi, channel) * (pixel_values.get_x_size() - 1) + 0.5); + nassertv(v >= 0 && v < pixel_values.get_x_size()); + set_point4(xi, yi, pixel_values.get_point4(v, 0)); + } + break; + } + } +} + /** * Adjusts each channel of the image by raising the corresponding component * value to the indicated exponent, such that L' = L ^ exponent. diff --git a/panda/src/pnmimage/pfmFile.h b/panda/src/pnmimage/pfmFile.h index ea99d011cb..d1bb93bcc4 100644 --- a/panda/src/pnmimage/pfmFile.h +++ b/panda/src/pnmimage/pfmFile.h @@ -158,6 +158,9 @@ PUBLISHED: void operator *= (float multiplier); + void indirect_1d_lookup(const PfmFile &index_image, int channel, + const PfmFile &pixel_values); + INLINE void gamma_correct(float from_gamma, float to_gamma); INLINE void gamma_correct_alpha(float from_gamma, float to_gamma); INLINE void apply_exponent(float gray_exponent); diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 7429f38ce7..3e3829ac52 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -1667,8 +1667,8 @@ fill_distance_outside(const PNMImage &mask, float threshold, int radius) { * * new_image(x, y) = pixel_values(index_image(x, y)[channel], 0) * - * No interpolation is performed; the nearest value in pixel_values is - * discovered. + * At present, no interpolation is performed; the nearest value in + * pixel_values is discovered. This may change in the future. */ void PNMImage:: indirect_1d_lookup(const PNMImage &index_image, int channel, From aa4a73af7d695cc85d3cc4a504c73d3130da3401 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 20 Feb 2016 19:11:23 +0100 Subject: [PATCH 15/31] Support for imageCubeArray, remove _EXT suffix This PR adds support for the imageCubeArray GLSL type (GL_IMAGE_CUBE_MAP_ARRAY). Also, the _EXT suffix is removed from the GL_IMAGE types. --- panda/src/glstuff/glShaderContext_src.cxx | 39 ++++++++++++----------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 94cef280d7..708347a119 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -1462,24 +1462,27 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) { return; } #ifndef OPENGLES - case GL_IMAGE_1D_EXT: - case GL_IMAGE_2D_EXT: - case GL_IMAGE_3D_EXT: - case GL_IMAGE_CUBE_EXT: - case GL_IMAGE_2D_ARRAY_EXT: - case GL_IMAGE_BUFFER_EXT: - case GL_INT_IMAGE_1D_EXT: - case GL_INT_IMAGE_2D_EXT: - case GL_INT_IMAGE_3D_EXT: - case GL_INT_IMAGE_CUBE_EXT: - case GL_INT_IMAGE_2D_ARRAY_EXT: - case GL_INT_IMAGE_BUFFER_EXT: - case GL_UNSIGNED_INT_IMAGE_1D_EXT: - case GL_UNSIGNED_INT_IMAGE_2D_EXT: - case GL_UNSIGNED_INT_IMAGE_3D_EXT: - case GL_UNSIGNED_INT_IMAGE_CUBE_EXT: - case GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT: - case GL_UNSIGNED_INT_IMAGE_BUFFER_EXT: + case GL_IMAGE_1D: + case GL_IMAGE_2D: + case GL_IMAGE_3D: + case GL_IMAGE_CUBE: + case GL_IMAGE_2D_ARRAY: + case GL_IMAGE_CUBE_MAP_ARRAY: + case GL_IMAGE_BUFFER: + case GL_INT_IMAGE_1D: + case GL_INT_IMAGE_2D: + case GL_INT_IMAGE_3D: + case GL_INT_IMAGE_CUBE: + case GL_INT_IMAGE_2D_ARRAY: + case GL_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_INT_IMAGE_BUFFER: + case GL_UNSIGNED_INT_IMAGE_1D: + case GL_UNSIGNED_INT_IMAGE_2D: + case GL_UNSIGNED_INT_IMAGE_3D: + case GL_UNSIGNED_INT_IMAGE_CUBE: + case GL_UNSIGNED_INT_IMAGE_2D_ARRAY: + case GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: + case GL_UNSIGNED_INT_IMAGE_BUFFER: // This won't really change at runtime, so we might as well bind once // and then forget about it. _glgsg->_glUniform1i(p, _glsl_img_inputs.size()); From 1795a7c8dd86c70e485ff0eefc93f502ca8f7786 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 20 Feb 2016 19:55:49 +0100 Subject: [PATCH 16/31] Work arround timestamp precision in ramdisks This fixes the timestamp precision when mounting RamDisks, by ensuring that the modified timestamp is always greater than the original timestamp. --- panda/src/express/virtualFileMountRamdisk.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/panda/src/express/virtualFileMountRamdisk.cxx b/panda/src/express/virtualFileMountRamdisk.cxx index 9f10931985..244f5c79df 100644 --- a/panda/src/express/virtualFileMountRamdisk.cxx +++ b/panda/src/express/virtualFileMountRamdisk.cxx @@ -235,7 +235,13 @@ open_write_file(const Filename &file, bool truncate) { if (truncate) { // Reset to an empty string. f->_data.str(string()); - f->_timestamp = time(NULL); + + // Instead of setting the time, we ensure that we always store a newer time. + // This is a workarround for the case that a file is written twice per + // second, since the timer only has a one second precision. The proper + // solution to fix this would be to switch to a higher precision + // timer everywhere. + f->_timestamp = max(f->_timestamp + 1, time(NULL)); } return new OSubStream(&f->_wrapper, 0, 0); @@ -275,7 +281,9 @@ open_read_write_file(const Filename &file, bool truncate) { if (truncate) { // Reset to an empty string. f->_data.str(string()); - f->_timestamp = time(NULL); + + // See open_write_file + f->_timestamp = max(f->_timestamp + 1, time(NULL)); } return new SubStream(&f->_wrapper, 0, 0); From 844a284925a97a111f010a53c1c2ff6627689cea Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 22 Feb 2016 19:47:08 +0100 Subject: [PATCH 17/31] Fix mipmap level count calculation for texture arrays --- panda/src/gobj/texture.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 539195dcfd..e61f272d86 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5672,7 +5672,10 @@ do_set_simple_ram_image(CData *cdata, CPTA_uchar image, int x_size, int y_size) //////////////////////////////////////////////////////////////////// int Texture:: do_get_expected_num_mipmap_levels(const CData *cdata) const { - int size = max(cdata->_x_size, max(cdata->_y_size, cdata->_z_size)); + int size = max(cdata->_x_size, cdata->_y_size); + if (cdata->_texture_type == Texture::TT_3d_texture) { + size = max(size, cdata->_z_size); + } int count = 1; while (size > 1) { size >>= 1; From 2ad07ac1fb5afde95e3f6947970d487c1dd16184 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 22 Feb 2016 16:02:38 -0800 Subject: [PATCH 18/31] fix PfmFile::xform() for files with other than 3 channels --- panda/src/pnmimage/pfmFile.cxx | 63 ++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index b8d775ca1f..75bb06682f 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -1211,14 +1211,65 @@ void PfmFile:: xform(const LMatrix4f &transform) { nassertv(is_valid()); - for (int yi = 0; yi < _y_size; ++yi) { - for (int xi = 0; xi < _x_size; ++xi) { - if (!has_point(xi, yi)) { - continue; + int num_channels = get_num_channels(); + switch (num_channels) { + case 1: + { + for (int yi = 0; yi < _y_size; ++yi) { + for (int xi = 0; xi < _x_size; ++xi) { + if (!has_point(xi, yi)) { + continue; + } + PN_float32 pi = get_point1(xi, yi); + LPoint3f po = transform.xform_point(LPoint3f(pi, 0.0, 0.0)); + set_point1(xi, yi, po[0]); + } } - LPoint3f &p = modify_point(xi, yi); - transform.xform_point_general_in_place(p); } + break; + + case 2: + { + for (int yi = 0; yi < _y_size; ++yi) { + for (int xi = 0; xi < _x_size; ++xi) { + if (!has_point(xi, yi)) { + continue; + } + LPoint2f pi = get_point2(xi, yi); + LPoint3f po = transform.xform_point(LPoint3f(pi[0], pi[1], 0.0)); + set_point2(xi, yi, LPoint2f(po[0], po[1])); + } + } + } + break; + + case 3: + { + for (int yi = 0; yi < _y_size; ++yi) { + for (int xi = 0; xi < _x_size; ++xi) { + if (!has_point(xi, yi)) { + continue; + } + LPoint3f &p = modify_point3(xi, yi); + transform.xform_point_general_in_place(p); + } + } + } + break; + + case 4: + { + for (int yi = 0; yi < _y_size; ++yi) { + for (int xi = 0; xi < _x_size; ++xi) { + if (!has_point(xi, yi)) { + continue; + } + LPoint4f &p = modify_point4(xi, yi); + transform.xform_in_place(p); + } + } + } + break; } } From d9ec4d402aabf5132ced6937150024ef72e18711 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 23 Feb 2016 18:06:13 +0100 Subject: [PATCH 19/31] Add print-pipe-types prc variable to prevent pipe output --- direct/src/showbase/ShowBase.py | 10 ++++++++-- panda/src/framework/config_framework.cxx | 2 ++ panda/src/framework/config_framework.h | 1 + panda/src/framework/pandaFramework.cxx | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 13ffbc7f45..0a3abdc07b 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -532,12 +532,19 @@ class ShowBase(DirectObject.DirectObject): del self.winList del self.pipe - def makeDefaultPipe(self, printPipeTypes = True): + def makeDefaultPipe(self, printPipeTypes = None): """ Creates the default GraphicsPipe, which will be used to make windows unless otherwise specified. """ assert self.pipe == None + + if printPipeTypes is None: + # When the user didn't specify an explicit setting, take the value + # from the config variable. We could just omit the parameter, however + # this way we can keep backward compatibility. + printPipeTypes = ConfigVariableBool("print-pipe-types", True) + selection = GraphicsPipeSelection.getGlobalPtr() if printPipeTypes: selection.printPipeTypes() @@ -567,7 +574,6 @@ class ShowBase(DirectObject.DirectObject): Creates all GraphicsPipes that the system knows about and fill up self.pipeList with them. """ - shouldPrintPipes = 0 selection = GraphicsPipeSelection.getGlobalPtr() selection.loadAuxModules() diff --git a/panda/src/framework/config_framework.cxx b/panda/src/framework/config_framework.cxx index aed06fa8ed..e5c5d42e70 100644 --- a/panda/src/framework/config_framework.cxx +++ b/panda/src/framework/config_framework.cxx @@ -31,6 +31,8 @@ ConfigVariableBool show_frame_rate_meter ("show-frame-rate-meter", false); ConfigVariableBool show_scene_graph_analyzer_meter ("show-scene-graph-analyzer-meter", false); +ConfigVariableBool print_pipe_types +("print-pipe-types", true); ConfigVariableString window_type ("window-type", "onscreen"); diff --git a/panda/src/framework/config_framework.h b/panda/src/framework/config_framework.h index 28ac64f177..9dd5dfad5c 100644 --- a/panda/src/framework/config_framework.h +++ b/panda/src/framework/config_framework.h @@ -27,6 +27,7 @@ NotifyCategoryDecl(framework, EXPCL_FRAMEWORK, EXPTP_FRAMEWORK); extern ConfigVariableDouble aspect_ratio; extern ConfigVariableBool show_frame_rate_meter; extern ConfigVariableBool show_scene_graph_analyzer_meter; +extern ConfigVariableBool print_pipe_types; extern ConfigVariableString window_type; extern ConfigVariableString record_session; diff --git a/panda/src/framework/pandaFramework.cxx b/panda/src/framework/pandaFramework.cxx index 05d4a4edb9..435be0e348 100644 --- a/panda/src/framework/pandaFramework.cxx +++ b/panda/src/framework/pandaFramework.cxx @@ -769,7 +769,11 @@ make_default_pipe() { // folks) that have been loaded in at runtime from the load-display andor // aux-display Configrc variables. GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); - selection->print_pipe_types(); + + if (print_pipe_types) { + selection->print_pipe_types(); + } + _default_pipe = selection->make_default_pipe(); if (_default_pipe == (GraphicsPipe*)NULL) { From 9f0cd818032400521e944bb862c87f6f7057fc16 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 27 Feb 2016 12:03:29 +0100 Subject: [PATCH 20/31] Make OpenGL performance warnings "info", not "warning" category --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 84e32b4336..c4701a245f 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -414,7 +414,12 @@ debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei l break; case GL_DEBUG_SEVERITY_MEDIUM: - level = NS_warning; + if (type == GL_DEBUG_TYPE_PERFORMANCE) { + // Performance warnings should really be "info". + level = NS_info; + } else { + level = NS_warning; + } break; case GL_DEBUG_SEVERITY_LOW: From f933eb4e96655ac6608db9c63fe4050219d31d7f Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 27 Feb 2016 16:45:22 +0100 Subject: [PATCH 21/31] Fix compile warnings (incl. "Attempt to define invalid type" spam), define _Dtool_CheckErrorOccurred in release builds for binary compat --- dtool/src/interrogate/interrogateBuilder.cxx | 4 +--- dtool/src/interrogatedb/py_panda.cxx | 2 +- dtool/src/interrogatedb/py_panda.h | 3 ++- panda/src/gobj/texturePeeker.I | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 0521852fdc..b11b2a4d3e 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -1870,9 +1870,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP iproperty._scoped_name = descope(make_property->get_local_name(&parser)); if (return_type != NULL) { - iproperty._type = get_type(return_type, false); - // if (iproperty._type == 0) { parser.warning("cannot determine property - // type", make_property->_ident->_loc); } + iproperty._type = get_type(TypeManager::unwrap_reference(return_type), false); } else { iproperty._type = 0; } diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index 5b92e5ef3f..fc6338170e 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -183,7 +183,7 @@ void *DTOOL_Call_GetPointerThis(PyObject *self) { * In the NDEBUG case, this is simply a #define to _PyErr_OCCURRED() (which is * an undocumented inline version of PyErr_Occurred()). */ -bool Dtool_CheckErrorOccurred() { +bool _Dtool_CheckErrorOccurred() { if (_PyErr_OCCURRED()) { return true; } diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 14310c8052..422fb5ffe1 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -313,12 +313,13 @@ template INLINE bool DTOOL_Call_ExtractThisPointer(PyObject *self, T *& } // Functions related to error reporting. +EXPCL_INTERROGATEDB bool _Dtool_CheckErrorOccurred(); #ifdef NDEBUG // _PyErr_OCCURRED is an undocumented inline version of PyErr_Occurred. #define Dtool_CheckErrorOccurred() (_PyErr_OCCURRED() != NULL) #else -EXPCL_INTERROGATEDB bool Dtool_CheckErrorOccurred(); +#define Dtool_CheckErrorOccurred() _Dtool_CheckErrorOccurred() #endif EXPCL_INTERROGATEDB PyObject *Dtool_Raise_AssertionError(); diff --git a/panda/src/gobj/texturePeeker.I b/panda/src/gobj/texturePeeker.I index da2a18d54d..d41ee14db9 100644 --- a/panda/src/gobj/texturePeeker.I +++ b/panda/src/gobj/texturePeeker.I @@ -54,5 +54,5 @@ get_z_size() const { */ INLINE bool TexturePeeker:: has_pixel(size_t x, size_t y) const { - return x >= 0 && y >= 0 && x < _x_size && y < _y_size; + return x < _x_size && y < _y_size; } From d50a326ca7d25a0ac3147bc2e0217e4b387ddd09 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 29 Feb 2016 19:49:26 +0100 Subject: [PATCH 22/31] Fix silly multiple uncompress&recompress when generating mips for compressed texture --- panda/src/egg2pg/eggLoader.cxx | 5 +++++ panda/src/gobj/config_gobj.cxx | 7 ------- panda/src/gobj/config_gobj.h | 1 - panda/src/gobj/texture.I | 7 +++++-- panda/src/gobj/texture.cxx | 29 +++++++++++++++++++++-------- panda/src/gobj/texture.h | 2 +- panda/src/putil/config_util.cxx | 7 +++++++ panda/src/putil/config_util.h | 1 + panda/src/putil/loaderOptions.cxx | 8 ++++++++ panda/src/putil/loaderOptions.h | 1 + 10 files changed, 49 insertions(+), 19 deletions(-) diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index ad309e0174..feeab556c5 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -950,6 +950,11 @@ load_texture(TextureDef &def, EggTexture *egg_tex) { } } + // Allow the texture loader to pre-compress the texture. + if (egg_tex->get_compression_mode() == EggTexture::CM_on) { + options.set_texture_flags(options.get_texture_flags() | LoaderOptions::TF_allow_compression); + } + PT(Texture) tex; switch (egg_tex->get_texture_type()) { case EggTexture::TT_unspecified: diff --git a/panda/src/gobj/config_gobj.cxx b/panda/src/gobj/config_gobj.cxx index f753126f19..4df77f0527 100644 --- a/panda/src/gobj/config_gobj.cxx +++ b/panda/src/gobj/config_gobj.cxx @@ -112,13 +112,6 @@ ConfigVariableBool keep_texture_ram "texture image from disk; but it will consume memory somewhat " "wastefully.")); -ConfigVariableBool compressed_textures -("compressed-textures", false, - PRC_DESC("Set this to true to compress textures as they are loaded into " - "texture memory, if the driver supports this. Specifically, this " - "changes the meaning of set_compression(Texture::CM_default) to " - "Texture::CM_on.")); - ConfigVariableBool driver_compress_textures ("driver-compress-textures", false, PRC_DESC("Set this true to ask the graphics driver to compress textures, " diff --git a/panda/src/gobj/config_gobj.h b/panda/src/gobj/config_gobj.h index e9780873ea..d3b651d3d4 100644 --- a/panda/src/gobj/config_gobj.h +++ b/panda/src/gobj/config_gobj.h @@ -36,7 +36,6 @@ extern EXPCL_PANDA_GOBJ ConfigVariableList exclude_texture_scale; extern EXPCL_PANDA_GOBJ ConfigVariableBool keep_texture_ram; -extern EXPCL_PANDA_GOBJ ConfigVariableBool compressed_textures; extern EXPCL_PANDA_GOBJ ConfigVariableBool driver_compress_textures; extern EXPCL_PANDA_GOBJ ConfigVariableBool driver_generate_mipmaps; extern EXPCL_PANDA_GOBJ ConfigVariableBool vertex_buffers; diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index eefbb090fe..534b7aad00 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -1678,9 +1678,12 @@ clear_ram_mipmap_images() { */ INLINE void Texture:: generate_ram_mipmap_images() { - CDWriter cdata(_cycler, unlocked_ensure_ram_image(false)); + // Don't use unlocked_ensure_ram_image here, because + // do_generate_ram_mipmap_images will want to decompress and recompress the + // image itself. + CDWriter cdata(_cycler, false); cdata->inc_image_modified(); - do_generate_ram_mipmap_images(cdata); + do_generate_ram_mipmap_images(cdata, true); } /** diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 4b3ac328e9..0d0054fed7 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -2708,7 +2708,8 @@ do_read(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpath, // If we intend to keep the ram image around, consider compressing it // etc. bool generate_mipmaps = ((options.get_texture_flags() & LoaderOptions::TF_generate_mipmaps) != 0); - do_consider_auto_process_ram_image(cdata, generate_mipmaps || uses_mipmaps(), true); + bool allow_compression = ((options.get_texture_flags() & LoaderOptions::TF_allow_compression) != 0); + do_consider_auto_process_ram_image(cdata, generate_mipmaps || uses_mipmaps(), allow_compression); } } @@ -4277,7 +4278,12 @@ do_reload_ram_image(CData *cdata, bool allow_compression) { int orig_num_components = cdata->_num_components; LoaderOptions options; - options.set_texture_flags(LoaderOptions::TF_preload); + if (allow_compression) { + options.set_texture_flags(LoaderOptions::TF_preload | + LoaderOptions::TF_allow_compression); + } else { + options.set_texture_flags(LoaderOptions::TF_preload); + } do_read(cdata, cdata->_fullpath, cdata->_alpha_fullpath, cdata->_primary_file_num_channels, cdata->_alpha_file_channel, z, n, cdata->_has_read_pages, cdata->_has_read_mipmaps, options, NULL); @@ -4618,7 +4624,7 @@ do_consider_auto_process_ram_image(CData *cdata, bool generate_mipmaps, if (generate_mipmaps && !driver_generate_mipmaps && cdata->_ram_images.size() == 1) { - do_generate_ram_mipmap_images(cdata); + do_generate_ram_mipmap_images(cdata, false); modified = true; } @@ -4725,7 +4731,7 @@ do_compress_ram_image(CData *cdata, Texture::CompressionMode compression, if (!do_has_all_ram_mipmap_images(cdata)) { // If we're about to compress the RAM image, we should ensure that we // have all of the mipmap levels first. - do_generate_ram_mipmap_images(cdata); + do_generate_ram_mipmap_images(cdata, false); } RamImages compressed_ram_images; @@ -6334,10 +6340,12 @@ do_clear_ram_mipmap_images(CData *cdata) { } /** - * + * Generates the RAM mipmap images for this texture, first uncompressing it as + * required. Will recompress the image if it was originally compressed, + * unless allow_recompress is true. */ void Texture:: -do_generate_ram_mipmap_images(CData *cdata) { +do_generate_ram_mipmap_images(CData *cdata, bool allow_recompress) { nassertv(do_has_ram_image(cdata)); if (do_get_expected_num_mipmap_levels(cdata) == 1) { @@ -6399,7 +6407,7 @@ do_generate_ram_mipmap_images(CData *cdata) { } } - if (orig_compression_mode != CM_off) { + if (orig_compression_mode != CM_off && allow_recompress) { // Now attempt to recompress the mipmap images according to the original // compression mode. We don't need to bother compressing the first image // (it was already compressed, after all), so temporarily remove it from @@ -6418,6 +6426,11 @@ do_generate_ram_mipmap_images(CData *cdata) { bool success = do_compress_ram_image(cdata, orig_compression_mode, QL_default, NULL); // Now restore the toplevel image. if (success) { + if (gobj_cat.is_debug()) { + gobj_cat.debug() + << "Compressed " << get_name() << " generated mipmaps with " + << cdata->_ram_image_compression << "\n"; + } cdata->_ram_images.insert(cdata->_ram_images.begin(), orig_compressed_image); } else { cdata->_ram_images.insert(cdata->_ram_images.begin(), uncompressed_image); @@ -8255,7 +8268,7 @@ do_squish(CData *cdata, Texture::CompressionMode compression, int squish_flags) if (!do_has_all_ram_mipmap_images(cdata)) { // If we're about to compress the RAM image, we should ensure that we have // all of the mipmap levels first. - do_generate_ram_mipmap_images(cdata); + do_generate_ram_mipmap_images(cdata, false); } RamImages compressed_ram_images; diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index fa64b0fa42..15f465ac4d 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -697,7 +697,7 @@ protected: INLINE void do_clear_ram_image(CData *cdata); void do_clear_simple_ram_image(CData *cdata); void do_clear_ram_mipmap_images(CData *cdata); - void do_generate_ram_mipmap_images(CData *cdata); + void do_generate_ram_mipmap_images(CData *cdata, bool allow_recompress); void do_set_pad_size(CData *cdata, int x, int y, int z); virtual bool do_can_reload(const CData *cdata) const; bool do_reload(CData *cdata); diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index 25277a436e..e12d66d066 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -143,6 +143,13 @@ ConfigVariableBool preload_simple_textures "in a sub-thread. It's not generally necessary if you are " "loading bam files that were generated via egg2bam.")); +ConfigVariableBool compressed_textures +("compressed-textures", false, + PRC_DESC("Set this to true to compress textures as they are loaded into " + "texture memory, if the driver supports this. Specifically, this " + "changes the meaning of set_compression(Texture::CM_default) to " + "Texture::CM_on.")); + ConfigVariableBool cache_check_timestamps ("cache-check-timestamps", true, PRC_DESC("Set this true to check the timestamps on disk (when possible) " diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h index 1127d35fe4..5fb669d86c 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_util.h @@ -46,6 +46,7 @@ extern ConfigVariableDouble sleep_precision; extern EXPCL_PANDA_PUTIL ConfigVariableBool preload_textures; extern EXPCL_PANDA_PUTIL ConfigVariableBool preload_simple_textures; +extern EXPCL_PANDA_PUTIL ConfigVariableBool compressed_textures; extern EXPCL_PANDA_PUTIL ConfigVariableBool cache_check_timestamps; extern EXPCL_PANDA_PUTIL void init_libputil(); diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 5743deaa63..61aeb4f5d1 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/panda/src/putil/loaderOptions.cxx @@ -28,12 +28,16 @@ LoaderOptions(int flags) : // Shadowing the variables in config_util for static init ordering issues. static ConfigVariableBool *preload_textures; static ConfigVariableBool *preload_simple_textures; + static ConfigVariableBool *compressed_textures; if (preload_textures == NULL) { preload_textures = new ConfigVariableBool("preload-textures", true); } if (preload_simple_textures == NULL) { preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false); } + if (compressed_textures == NULL) { + compressed_textures = new ConfigVariableBool("compressed-textures", false); + } if (*preload_textures) { _texture_flags |= TF_preload; @@ -41,6 +45,9 @@ LoaderOptions(int flags) : if (*preload_simple_textures) { _texture_flags |= TF_preload_simple; } + if (*compressed_textures) { + _texture_flags |= TF_allow_compression; + } } /** @@ -77,6 +84,7 @@ output(ostream &out) const { write_texture_flag(out, sep, "TF_preload_simple", TF_preload_simple); write_texture_flag(out, sep, "TF_allow_1d", TF_allow_1d); write_texture_flag(out, sep, "TF_generate_mipmaps", TF_generate_mipmaps); + write_texture_flag(out, sep, "TF_allow_compression", TF_allow_compression); if (sep.empty()) { out << "0"; } diff --git a/panda/src/putil/loaderOptions.h b/panda/src/putil/loaderOptions.h index 3db6f81f5a..50c73f983e 100644 --- a/panda/src/putil/loaderOptions.h +++ b/panda/src/putil/loaderOptions.h @@ -45,6 +45,7 @@ PUBLISHED: TF_multiview = 0x0040, // Load a multiview texture in pages TF_integer = 0x0080, // Load as an integer (RGB) texture TF_float = 0x0100, // Load as a floating-point (depth) texture + TF_allow_compression = 0x0200, // Consider compressing RAM image }; LoaderOptions(int flags = LF_search | LF_report_errors); From 711c97ad6db9aa021bef4caee4aab71b8adfeca2 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 2 Mar 2016 16:24:38 +0100 Subject: [PATCH 23/31] A few glgsg fixes from tobspr --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 13 ++++++++----- panda/src/glstuff/glGraphicsStateGuardian_src.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index c4701a245f..62a0f43b50 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -169,7 +169,7 @@ static const string default_fshader = "#version 130\n" "in vec2 texcoord;\n" "in vec4 color;\n" - "out vec4 p3d_FragColor;" + "out vec4 p3d_FragColor;\n" "uniform sampler2D p3d_Texture0;\n" "uniform vec4 p3d_TexAlphaOnly;\n" #else @@ -2518,7 +2518,7 @@ reset() { if (core_profile) { // TODO: better detection mechanism? - _supports_stencil = true; + _supports_stencil = support_stencil; } #ifdef SUPPORT_FIXED_FUNCTION else if (support_stencil) { @@ -2989,7 +2989,7 @@ clear(DrawableRegion *clearable) { mask |= GL_DEPTH_BUFFER_BIT; } - if (clearable->get_clear_stencil_active()) { + if (_supports_stencil && clearable->get_clear_stencil_active()) { glStencilMask(~0); glClearStencil(clearable->get_clear_stencil()); mask |= GL_STENCIL_BUFFER_BIT; @@ -4817,6 +4817,7 @@ update_texture(TextureContext *tc, bool force) { if (gtc->was_properties_modified()) { specify_texture(gtc, tex->get_default_sampler()); } + bool okflag = upload_texture(gtc, force, tex->uses_mipmaps()); if (!okflag) { GLCAT.error() @@ -6238,7 +6239,9 @@ do_issue_render_mode() { } report_my_gl_errors(); +#ifdef SUPPORT_FIXED_FUNCTION do_point_size(); +#endif } /** @@ -12703,9 +12706,9 @@ extract_texture_image(PTA_uchar &image, size_t &page_size, * Internally sets the point size parameters after any of the properties have * changed that might affect this. */ +#ifdef SUPPORT_FIXED_FUNCTION void CLP(GraphicsStateGuardian):: do_point_size() { -#ifndef OPENGLES_2 if (!_point_perspective) { // Normal, constant-sized points. Here _point_size is a width in pixels. static LVecBase3f constant(1.0f, 0.0f, 0.0f); @@ -12735,8 +12738,8 @@ do_point_size() { } report_my_gl_errors(); -#endif } +#endif /** * Returns true if this particular GSG supports the specified Cg Shader diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index c2909e3b3e..73afe5a44e 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -567,7 +567,9 @@ protected: Texture::ComponentType type, Texture::CompressionMode compression, int n); +#ifdef SUPPORT_FIXED_FUNCTION void do_point_size(); +#endif enum AutoAntialiasMode { AA_poly, From 2971915618053b159069b5dcb28ed55ac826f1a3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 2 Mar 2016 17:00:22 +0100 Subject: [PATCH 24/31] Bam 6.41: lenses and light changes, add max_distance --- panda/src/gobj/lens.cxx | 60 +++++++++++++++++++++++- panda/src/gobj/matrixLens.cxx | 38 +++++++++++++++ panda/src/gobj/matrixLens.h | 2 + panda/src/pgraph/camera.cxx | 26 ++++++++++- panda/src/pgraph/camera.h | 2 + panda/src/pgraph/lensNode.cxx | 40 ++++++++++++++-- panda/src/pgraph/pandaNode.cxx | 2 + panda/src/pgraphnodes/pointLight.I | 26 ++++++++++- panda/src/pgraphnodes/pointLight.cxx | 15 +++++- panda/src/pgraphnodes/pointLight.h | 5 ++ panda/src/pgraphnodes/spotlight.I | 26 ++++++++++- panda/src/pgraphnodes/spotlight.cxx | 15 +++++- panda/src/pgraphnodes/spotlight.h | 5 ++ panda/src/putil/bam.h | 69 ++++++++++++++-------------- panda/src/putil/bamReader.cxx | 3 +- panda/src/putil/bamWriter.I | 16 +++++++ panda/src/putil/bamWriter.cxx | 4 ++ panda/src/putil/bamWriter.h | 4 ++ 18 files changed, 305 insertions(+), 53 deletions(-) diff --git a/panda/src/gobj/lens.cxx b/panda/src/gobj/lens.cxx index fc5c5222d8..8b7df0b5ac 100644 --- a/panda/src/gobj/lens.cxx +++ b/panda/src/gobj/lens.cxx @@ -139,7 +139,7 @@ get_min_fov() const { /** * Returns the default near plane distance that will be assigned to each - * newly-created lens. This is read from the Configrc file. + * newly-created lens. This is read from the Config.prc file. */ PN_stdfloat Lens:: get_default_near() { @@ -148,7 +148,7 @@ get_default_near() { /** * Returns the default far plane distance that will be assigned to each newly- - * created lens. This is read from the Configrc file. + * created lens. This is read from the Config.prc file. */ PN_stdfloat Lens:: get_default_far() { @@ -1930,6 +1930,35 @@ write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_stdfloat(_near_distance); dg.add_stdfloat(_far_distance); dg.add_uint16(_user_flags); + + if (manager->get_file_minor_ver() < 41) { + return; + } + + dg.add_stdfloat(_min_fov); + dg.add_stdfloat(_interocular_distance); + dg.add_stdfloat(_convergence_distance); + + if (_user_flags & UF_view_hpr) { + _view_hpr.write_datagram(dg); + } + + if (_user_flags & UF_view_vector) { + _view_vector.write_datagram(dg); + _up_vector.write_datagram(dg); + } + + if (_user_flags & UF_view_mat) { + _lens_mat.write_datagram(dg); + } + + if (_user_flags & UF_keystone) { + _keystone.write_datagram(dg); + } + + if (_user_flags & UF_custom_film_mat) { + _custom_film_mat.write_datagram(dg); + } } /** @@ -1949,6 +1978,33 @@ fillin(DatagramIterator &scan, BamReader *manager) { _far_distance = scan.get_stdfloat(); _user_flags = scan.get_uint16(); + if (manager->get_file_minor_ver() >= 41) { + _min_fov = scan.get_stdfloat(); + _interocular_distance = scan.get_stdfloat(); + _convergence_distance = scan.get_stdfloat(); + + if (_user_flags & UF_view_hpr) { + _view_hpr.read_datagram(scan); + } + + if (_user_flags & UF_view_vector) { + _view_vector.read_datagram(scan); + _up_vector.read_datagram(scan); + } + + if (_user_flags & UF_view_mat) { + _lens_mat.read_datagram(scan); + } + + if (_user_flags & UF_keystone) { + _keystone.read_datagram(scan); + } + + if (_user_flags & UF_custom_film_mat) { + _custom_film_mat.read_datagram(scan); + } + } + _comp_flags = 0; } diff --git a/panda/src/gobj/matrixLens.cxx b/panda/src/gobj/matrixLens.cxx index d2254f7175..169de788b1 100644 --- a/panda/src/gobj/matrixLens.cxx +++ b/panda/src/gobj/matrixLens.cxx @@ -77,6 +77,23 @@ register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } +/** + * Writes the contents of this object to the datagram for shipping out to a + * Bam file. + */ +void MatrixLens:: +write_datagram(BamWriter *manager, Datagram &dg) { + dg.add_uint8(_ml_flags); + _user_mat.write_datagram(dg); + + if (_ml_flags & MF_has_left_eye) { + _left_eye_mat.write_datagram(dg); + } + if (_ml_flags & MF_has_right_eye) { + _left_eye_mat.write_datagram(dg); + } +} + /** * This function is called by the BamReader's factory when a new object of * type Lens is encountered in the Bam file. It should create the Lens and @@ -93,3 +110,24 @@ make_from_bam(const FactoryParams ¶ms) { return lens; } + +/** + * This internal function is called by make_from_bam to read in all of the + * relevant data from the BamFile for the new MatrixLens. + */ +void MatrixLens:: +fillin(DatagramIterator &scan, BamReader *manager) { + Lens::fillin(scan, manager); + + if (manager->get_file_minor_ver() >= 41) { + _ml_flags = scan.get_uint8(); + + _user_mat.read_datagram(scan); + if (_ml_flags & MF_has_left_eye) { + _left_eye_mat.read_datagram(scan); + } + if (_ml_flags & MF_has_right_eye) { + _right_eye_mat.read_datagram(scan); + } + } +} diff --git a/panda/src/gobj/matrixLens.h b/panda/src/gobj/matrixLens.h index 812cd7b55a..0b4f068b88 100644 --- a/panda/src/gobj/matrixLens.h +++ b/panda/src/gobj/matrixLens.h @@ -70,9 +70,11 @@ private: public: static void register_with_read_factory(); + virtual void write_datagram(BamWriter *manager, Datagram &dg); protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); + void fillin(DatagramIterator &scan, BamReader *manager); public: virtual TypeHandle get_type() const { diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index e2e1bef0f9..575b5236ed 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -26,9 +26,9 @@ Camera(const string &name, Lens *lens) : LensNode(name, lens), _active(true), _camera_mask(~PandaNode::get_overall_bit()), - _initial_state(RenderState::make_empty()) + _initial_state(RenderState::make_empty()), + _lod_scale(1) { - set_lod_scale(1.0); } /** @@ -271,6 +271,23 @@ write_datagram(BamWriter *manager, Datagram &dg) { dg.add_bool(_active); dg.add_uint32(_camera_mask.get_word()); + + manager->write_pointer(dg, _initial_state); + dg.add_stdfloat(_lod_scale); +} + +//////////////////////////////////////////////////////////////////// +// Function: Camera::complete_pointers +// Access: Public, Virtual +// Description: Receives an array of pointers, one for each time +// manager->read_pointer() was called in fillin(). +// Returns the number of pointers processed. +//////////////////////////////////////////////////////////////////// +int Camera:: +complete_pointers(TypedWritable **p_list, BamReader *manager) { + int pi = LensNode::complete_pointers(p_list, manager); + _initial_state = DCAST(RenderState, p_list[pi++]); + return pi; } /** @@ -300,4 +317,9 @@ fillin(DatagramIterator &scan, BamReader *manager) { _active = scan.get_bool(); _camera_mask.set_word(scan.get_uint32()); + + if (manager->get_file_minor_ver() >= 41) { + manager->read_pointer(scan); + _lod_scale = scan.get_stdfloat(); + } } diff --git a/panda/src/pgraph/camera.h b/panda/src/pgraph/camera.h index 71b15ec243..8d30d146da 100644 --- a/panda/src/pgraph/camera.h +++ b/panda/src/pgraph/camera.h @@ -124,6 +124,8 @@ private: public: static void register_with_read_factory(); virtual void write_datagram(BamWriter *manager, Datagram &dg); + virtual int complete_pointers(TypedWritable **plist, + BamReader *manager); protected: static TypedWritable *make_from_bam(const FactoryParams ¶ms); diff --git a/panda/src/pgraph/lensNode.cxx b/panda/src/pgraph/lensNode.cxx index 108d482aa5..4fa15e2aa7 100644 --- a/panda/src/pgraph/lensNode.cxx +++ b/panda/src/pgraph/lensNode.cxx @@ -218,9 +218,18 @@ void LensNode:: write_datagram(BamWriter *manager, Datagram &dg) { PandaNode::write_datagram(manager, dg); - // For now, we only write out lens 0, simply because that's what we always - // have done. Should probably write out all lenses for the future. - manager->write_pointer(dg, get_lens(0)); + if (manager->get_file_minor_ver() < 41) { + // Prior to bam 6.41, we stored only one lens. + manager->write_pointer(dg, get_lens(0)); + } else { + dg.add_uint16(_lenses.size()); + + Lenses::const_iterator li; + for (li = _lenses.begin(); li != _lenses.end(); ++li) { + manager->write_pointer(dg, (*li)._lens); + dg.add_bool((*li)._is_active); + } + } } /** @@ -230,7 +239,16 @@ write_datagram(BamWriter *manager, Datagram &dg) { int LensNode:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = PandaNode::complete_pointers(p_list, manager); - set_lens(0, DCAST(Lens, p_list[pi++])); + + Lenses::iterator li; + for (li = _lenses.begin(); li != _lenses.end(); ++li) { + (*li)._lens = DCAST(Lens, p_list[pi++]); + } + + if (_shown_frustum != (PandaNode *)NULL) { + show_frustum(); + } + return pi; } @@ -259,5 +277,17 @@ void LensNode:: fillin(DatagramIterator &scan, BamReader *manager) { PandaNode::fillin(scan, manager); - manager->read_pointer(scan); + if (manager->get_file_minor_ver() < 41) { + // Prior to bam 6.41, we stored only one lens. + _lenses.resize(1); + manager->read_pointer(scan); + + } else { + _lenses.resize(scan.get_uint16()); + Lenses::iterator li; + for (li = _lenses.begin(); li != _lenses.end(); ++li) { + manager->read_pointer(scan); + (*li)._is_active = scan.get_bool(); + } + } } diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 644696f4b3..827ae89c31 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -3750,6 +3750,8 @@ void PandaNode:: fillin(DatagramIterator &scan, BamReader *manager) { TypedWritable::fillin(scan, manager); + remove_all_children(); + string name = scan.get_string(); set_name(name); diff --git a/panda/src/pgraphnodes/pointLight.I b/panda/src/pgraphnodes/pointLight.I index 672d35042a..f231449be8 100644 --- a/panda/src/pgraphnodes/pointLight.I +++ b/panda/src/pgraphnodes/pointLight.I @@ -18,6 +18,7 @@ INLINE PointLight::CData:: CData() : _specular_color(1.0f, 1.0f, 1.0f, 1.0f), _attenuation(1.0f, 0.0f, 0.0f), + _max_distance(make_inf((PN_stdfloat)0)), _point(0.0f, 0.0f, 0.0f) { } @@ -29,6 +30,7 @@ INLINE PointLight::CData:: CData(const PointLight::CData ©) : _specular_color(copy._specular_color), _attenuation(copy._attenuation), + _max_distance(copy._max_distance), _point(copy._point) { } @@ -88,9 +90,29 @@ set_attenuation(const LVecBase3 &attenuation) { cdata->_attenuation = attenuation; } +/** + * Returns the maximum distance at which the light has any effect, as previously + * specified by set_max_distance. + */ +INLINE PN_stdfloat PointLight:: +get_max_distance() const { + CDReader cdata(_cycler); + return cdata->_max_distance; +} + +/** + * Sets the radius of the light's sphere of influence. Beyond this distance, the + * light may be attenuated to zero, if this is supported by the shader. + */ +INLINE void PointLight:: +set_max_distance(PN_stdfloat max_distance) { + CDWriter cdata(_cycler); + cdata->_max_distance = max_distance; +} + /** * Returns the point in space at which the light is located. This is local to - * the coordinate space in which the light is assigned. + * the coordinate space in which the light is assigned, and is usually 0. */ INLINE const LPoint3 &PointLight:: get_point() const { @@ -99,7 +121,7 @@ get_point() const { } /** - * Sets the point in space at which the light is located. + * Sets the point in space at which the light is located. Usually 0. */ INLINE void PointLight:: set_point(const LPoint3 &point) { diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 2c4bf1641e..ecb93bc768 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -33,9 +33,12 @@ make_copy() const { * Bam file. */ void PointLight::CData:: -write_datagram(BamWriter *, Datagram &dg) const { +write_datagram(BamWriter *manager, Datagram &dg) const { _specular_color.write_datagram(dg); _attenuation.write_datagram(dg); + if (manager->get_file_minor_ver() >= 41) { + dg.add_stdfloat(_max_distance); + } _point.write_datagram(dg); } @@ -44,9 +47,12 @@ write_datagram(BamWriter *, Datagram &dg) const { * relevant data from the BamFile for the new Light. */ void PointLight::CData:: -fillin(DatagramIterator &scan, BamReader *) { +fillin(DatagramIterator &scan, BamReader *manager) { _specular_color.read_datagram(scan); _attenuation.read_datagram(scan); + if (manager->get_file_minor_ver() >= 41) { + _max_distance = scan.get_stdfloat(); + } _point.read_datagram(scan); } @@ -127,6 +133,11 @@ write(ostream &out, int indent_level) const { } indent(out, indent_level + 2) << "attenuation " << get_attenuation() << "\n"; + + if (!cinf(get_max_distance())) { + indent(out, indent_level + 2) + << "max distance " << get_max_distance() << "\n"; + } } /** diff --git a/panda/src/pgraphnodes/pointLight.h b/panda/src/pgraphnodes/pointLight.h index 508cee5db7..c0907dba01 100644 --- a/panda/src/pgraphnodes/pointLight.h +++ b/panda/src/pgraphnodes/pointLight.h @@ -48,6 +48,10 @@ PUBLISHED: INLINE void set_attenuation(const LVecBase3 &attenuation); MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation); + INLINE PN_stdfloat get_max_distance() const; + INLINE void set_max_distance(PN_stdfloat max_distance); + MAKE_PROPERTY(max_distance, get_max_distance, set_max_distance); + INLINE const LPoint3 &get_point() const; INLINE void set_point(const LPoint3 &point); MAKE_PROPERTY(point, get_point, set_point); @@ -75,6 +79,7 @@ private: LColor _specular_color; LVecBase3 _attenuation; + PN_stdfloat _max_distance; LPoint3 _point; }; diff --git a/panda/src/pgraphnodes/spotlight.I b/panda/src/pgraphnodes/spotlight.I index 1f42638873..98c80d99b2 100644 --- a/panda/src/pgraphnodes/spotlight.I +++ b/panda/src/pgraphnodes/spotlight.I @@ -18,7 +18,8 @@ INLINE Spotlight::CData:: CData() : _exponent(50.0f), _specular_color(1.0f, 1.0f, 1.0f, 1.0f), - _attenuation(1.0f, 0.0f, 0.0f) + _attenuation(1.0f, 0.0f, 0.0f), + _max_distance(make_inf((PN_stdfloat)0)) { } @@ -29,7 +30,8 @@ INLINE Spotlight::CData:: CData(const Spotlight::CData ©) : _exponent(copy._exponent), _specular_color(copy._specular_color), - _attenuation(copy._attenuation) + _attenuation(copy._attenuation), + _max_distance(copy._max_distance) { } @@ -111,3 +113,23 @@ set_attenuation(const LVecBase3 &attenuation) { CDWriter cdata(_cycler); cdata->_attenuation = attenuation; } + +/** + * Returns the maximum distance at which the light has any effect, as previously + * specified by set_max_distance. + */ +INLINE PN_stdfloat Spotlight:: +get_max_distance() const { + CDReader cdata(_cycler); + return cdata->_max_distance; +} + +/** + * Sets the radius of the light's sphere of influence. Beyond this distance, the + * light may be attenuated to zero, if this is supported by the shader. + */ +INLINE void Spotlight:: +set_max_distance(PN_stdfloat max_distance) { + CDWriter cdata(_cycler); + cdata->_max_distance = max_distance; +} diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index b9de0ea121..8e46ab213e 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -37,10 +37,13 @@ make_copy() const { * Bam file. */ void Spotlight::CData:: -write_datagram(BamWriter *, Datagram &dg) const { +write_datagram(BamWriter *manager, Datagram &dg) const { dg.add_stdfloat(_exponent); _specular_color.write_datagram(dg); _attenuation.write_datagram(dg); + if (manager->get_file_minor_ver() >= 41) { + dg.add_stdfloat(_max_distance); + } } /** @@ -48,10 +51,13 @@ write_datagram(BamWriter *, Datagram &dg) const { * relevant data from the BamFile for the new Light. */ void Spotlight::CData:: -fillin(DatagramIterator &scan, BamReader *) { +fillin(DatagramIterator &scan, BamReader *manager) { _exponent = scan.get_stdfloat(); _specular_color.read_datagram(scan); _attenuation.read_datagram(scan); + if (manager->get_file_minor_ver() >= 41) { + _max_distance = scan.get_stdfloat(); + } } /** @@ -113,6 +119,11 @@ write(ostream &out, int indent_level) const { indent(out, indent_level + 2) << "exponent " << get_exponent() << "\n"; + if (!cinf(get_max_distance())) { + indent(out, indent_level + 2) + << "max distance " << get_max_distance() << "\n"; + } + Lens *lens = get_lens(); if (lens != (Lens *)NULL) { lens->write(out, indent_level + 2); diff --git a/panda/src/pgraphnodes/spotlight.h b/panda/src/pgraphnodes/spotlight.h index 5a5cb18c01..6cc175fe61 100644 --- a/panda/src/pgraphnodes/spotlight.h +++ b/panda/src/pgraphnodes/spotlight.h @@ -59,6 +59,10 @@ PUBLISHED: INLINE void set_attenuation(const LVecBase3 &attenuation); MAKE_PROPERTY(attenuation, get_attenuation, set_attenuation); + INLINE PN_stdfloat get_max_distance() const; + INLINE void set_max_distance(PN_stdfloat max_distance); + MAKE_PROPERTY(max_distance, get_max_distance, set_max_distance); + virtual int get_class_priority() const; static PT(Texture) make_spot(int pixel_width, PN_stdfloat full_radius, @@ -92,6 +96,7 @@ private: PN_stdfloat _exponent; LColor _specular_color; LVecBase3 _attenuation; + PN_stdfloat _max_distance; }; PipelineCycler _cycler; diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index ca6d0a2800..4251751135 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -25,42 +25,41 @@ static const string _bam_header = string("pbj\0\n\r", 6); static const unsigned short _bam_major_ver = 6; -// Bumped to major version 2 on 7600 due to major changes in Character. -// Bumped to major version 3 on 12800 to change float64's to float32's. -// Bumped to major version 4 on 41002 to store new scene graph. Bumped to -// major version 5 on 5605 for new Geom implementation. Bumped to major -// version 6 on 21106 to factor out PandaNode::CData. +// Bumped to major version 2 on 2000-07-06 due to major changes in Character. +// Bumped to major version 3 on 2000-12-08 to change float64's to float32's. +// Bumped to major version 4 on 2002-04-10 to store new scene graph. +// Bumped to major version 5 on 2005-05-06 for new Geom implementation. +// Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData. static const unsigned short _bam_first_minor_ver = 14; -static const unsigned short _bam_minor_ver = 40; -/* - * Bumped to minor version 14 on 121907 to change default ColorAttrib. Bumped - * to minor version 15 on 4908 to add TextureAttrib::_implicit_sort. Bumped - * to minor version 16 on 51308 to add Texture::_quality_level. Bumped to - * minor version 17 on 8608 to add PartBundle::_anim_preload. Bumped to minor - * version 18 on 81408 to add Texture::_simple_ram_image. Bumped to minor - * version 19 on 81408 to add PandaNode::_bounds_type. Bumped to minor - * version 20 on 42109 to add MovingPartBase::_forced_channel. Bumped to - * minor version 21 on 22608 to add BamEnums::BamObjectCode. Bumped to minor - * version 22 on 73109 to add UvScrollNode R speed. Bumped to minor version - * 23 on 5410 to add internal TextureAttrib overrides. Bumped to minor - * version 24 on 5410 to add internal TexMatrixAttrib overrides. Bumped to - * minor version 25 on 62211 to add support for caching movie files. Bumped - * to minor version 26 on 8511 to add multiview (stereo) Textures. Bumped to - * minor version 27 on 10911 to add stdfloat_double. Bumped to minor version - * 28 on 112811 to add Texture::_auto_texture_scale. Bumped to minor version - * 29 on 121711 to add GeomVertexColumn::_column_alignment. Bumped to minor - * version 30 on 12212 to add Texture::_pad_*_size. Bumped to minor version - * 31 on 21612 to add DepthOffsetAttrib::_min_value, _max_value. Bumped to - * minor version 32 on 61112 to add Texture::_has_read_mipmaps. Bumped to - * minor version 33 on 81713 to add UvScrollNode::_w_speed. Bumped to minor - * version 34 on 91614 to add ScissorAttrib::_off. Bumped to minor version 35 - * on 12314 to change StencilAttrib. Bumped to minor version 36 on 12914 to - * add samplers and lod settings. Bumped to minor version 37 on 12215 to add - * GeomVertexArrayFormat::_divisor. Bumped to minor version 38 on 41515 to - * add various Bullet classes. Bumped to minor version 39 on 1916 to change - * lights and materials. Bumped to minor version 40 on 11116 to make - * NodePaths writable. - */ +static const unsigned short _bam_minor_ver = 41; +// Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib. +// Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort. +// Bumped to minor version 16 on 2008-05-13 to add Texture::_quality_level. +// Bumped to minor version 17 on 2008-08-06 to add PartBundle::_anim_preload. +// Bumped to minor version 18 on 2008-08-14 to add Texture::_simple_ram_image. +// Bumped to minor version 19 on 2008-08-14 to add PandaNode::_bounds_type. +// Bumped to minor version 20 on 2009-04-21 to add MovingPartBase::_forced_channel. +// Bumped to minor version 21 on 2008-02-26 to add BamEnums::BamObjectCode. +// Bumped to minor version 22 on 2009-07-31 to add UvScrollNode R speed. +// Bumped to minor version 23 on 2010-05-04 to add internal TextureAttrib overrides. +// Bumped to minor version 24 on 2010-05-04 to add internal TexMatrixAttrib overrides. +// Bumped to minor version 25 on 2011-06-22 to add support for caching movie files. +// Bumped to minor version 26 on 2011-08-05 to add multiview (stereo) Textures. +// Bumped to minor version 27 on 2011-10-09 to add stdfloat_double. +// Bumped to minor version 28 on 2011-11-28 to add Texture::_auto_texture_scale. +// Bumped to minor version 29 on 2011-12-17 to add GeomVertexColumn::_column_alignment. +// Bumped to minor version 30 on 2012-01-22 to add Texture::_pad_*_size. +// Bumped to minor version 31 on 2012-02-16 to add DepthOffsetAttrib::_min_value, _max_value. +// Bumped to minor version 32 on 2012-06-11 to add Texture::_has_read_mipmaps. +// Bumped to minor version 33 on 2013-08-17 to add UvScrollNode::_w_speed. +// Bumped to minor version 34 on 2014-09-16 to add ScissorAttrib::_off. +// Bumped to minor version 35 on 2014-12-03 to change StencilAttrib. +// Bumped to minor version 36 on 2014-12-09 to add samplers and lod settings. +// Bumped to minor version 37 on 2015-01-22 to add GeomVertexArrayFormat::_divisor. +// Bumped to minor version 38 on 2015-04-15 to add various Bullet classes. +// Bumped to minor version 39 on 2016-01-09 to change lights and materials. +// Bumped to minor version 40 on 2016-01-11 to make NodePaths writable. +// Bumped to minor version 41 on 2016-03-02 to change LensNode, Lens, and Camera. #endif diff --git a/panda/src/putil/bamReader.cxx b/panda/src/putil/bamReader.cxx index a7eaea125c..8831a1ca7e 100644 --- a/panda/src/putil/bamReader.cxx +++ b/panda/src/putil/bamReader.cxx @@ -236,7 +236,8 @@ read_object() { * This flavor of read_object() returns both a TypedWritable and a * ReferenceCount pointer to the same object, so the reference count may be * tracked reliably, without having to know precisely what type of object we - * have. It returns true on success, or false on failure. + * have. + * @return true on success, or false on failure. */ bool BamReader:: read_object(TypedWritable *&ptr, ReferenceCount *&ref_ptr) { diff --git a/panda/src/putil/bamWriter.I b/panda/src/putil/bamWriter.I index 65335d5bac..e620ade5bf 100644 --- a/panda/src/putil/bamWriter.I +++ b/panda/src/putil/bamWriter.I @@ -34,6 +34,22 @@ get_filename() const { return empty_filename; } +/** + * Returns the major version number of the Bam file currently being written. + */ +INLINE int BamWriter:: +get_file_major_ver() const { + return _file_major; +} + +/** + * Returns the minor version number of the Bam file currently being written. + */ +INLINE int BamWriter:: +get_file_minor_ver() const { + return _file_minor; +} + /** * Returns the endian preference indicated by the Bam file currently being * written. This does not imply that every number is stored using the diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index e26b2c0d8c..9ad37a798f 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -41,6 +41,8 @@ BamWriter(DatagramSink *target) : _next_pta_id = 1; _long_pta_id = false; + _file_major = _bam_major_ver; + _file_minor = _bam_minor_ver; _file_endian = bam_endian; _file_stdfloat_double = bam_stdfloat_double; _file_texture_mode = bam_texture_mode; @@ -96,6 +98,8 @@ init() { _next_pta_id = 1; _long_pta_id = false; + _file_major = _bam_major_ver; + _file_minor = _bam_minor_ver; _file_endian = bam_endian; _file_texture_mode = bam_texture_mode; diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index cd948a928e..dc04a22f20 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -74,6 +74,9 @@ PUBLISHED: bool has_object(const TypedWritable *obj) const; void flush(); + INLINE int get_file_major_ver() const; + INLINE int get_file_minor_ver() const; + INLINE BamEndian get_file_endian() const; INLINE bool get_file_stdfloat_double() const; @@ -115,6 +118,7 @@ private: int enqueue_object(const TypedWritable *object); bool flush_queue(); + int _file_major, _file_minor; BamEndian _file_endian; bool _file_stdfloat_double; BamTextureMode _file_texture_mode; From 2bf886fc5b086e92ef86b25c652f7257521365d7 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 2 Mar 2016 17:55:34 +0100 Subject: [PATCH 25/31] Add premultiplied alpha mode, for convenience --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 7 +++++++ panda/src/egg/eggRenderMode.cxx | 4 ++++ panda/src/egg/eggRenderMode.h | 3 ++- panda/src/egg2pg/eggRenderState.cxx | 4 ++++ panda/src/egg2pg/eggSaver.cxx | 8 +++++--- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 13 +++++++++++++ panda/src/pgraph/cullResult.cxx | 1 + panda/src/pgraph/cullTraverserData.cxx | 2 +- panda/src/pgraph/renderState.cxx | 9 +++++---- panda/src/pgraph/transparencyAttrib.cxx | 7 ++++--- panda/src/pgraph/transparencyAttrib.h | 2 +- panda/src/pgraphnodes/shaderGenerator.cxx | 1 + .../src/tinydisplay/tinyGraphicsStateGuardian.cxx | 15 +++++++++++++++ 13 files changed, 63 insertions(+), 13 deletions(-) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 5cc7d8d0f6..f71e01d298 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3822,6 +3822,13 @@ do_issue_blending() { set_render_state(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); return; + case TransparencyAttrib::M_premultiplied_alpha: + set_render_state(D3DRS_ALPHABLENDENABLE, TRUE); + set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD); + set_render_state(D3DRS_SRCBLEND, D3DBLEND_ONE); + set_render_state(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); + return; + default: dxgsg9_cat.error() << "invalid transparency mode " << (int)transparency_mode << endl; diff --git a/panda/src/egg/eggRenderMode.cxx b/panda/src/egg/eggRenderMode.cxx index 0be5d41edf..7c7e478a6d 100644 --- a/panda/src/egg/eggRenderMode.cxx +++ b/panda/src/egg/eggRenderMode.cxx @@ -183,6 +183,8 @@ string_alpha_mode(const string &string) { return AM_binary; } else if (cmp_nocase_uh(string, "dual") == 0) { return AM_dual; + } else if (cmp_nocase_uh(string, "premultiplied") == 0) { + return AM_premultiplied; } else { return AM_unspecified; } @@ -260,6 +262,8 @@ ostream &operator << (ostream &out, EggRenderMode::AlphaMode mode) { return out << "binary"; case EggRenderMode::AM_dual: return out << "dual"; + case EggRenderMode::AM_premultiplied: + return out << "premultiplied"; } nassertr(false, out); diff --git a/panda/src/egg/eggRenderMode.h b/panda/src/egg/eggRenderMode.h index b4664db736..66d9a6c645 100644 --- a/panda/src/egg/eggRenderMode.h +++ b/panda/src/egg/eggRenderMode.h @@ -45,7 +45,8 @@ PUBLISHED: AM_ms, // TransparencyAttrib::M_multisample AM_ms_mask, // TransparencyAttrib::M_multisample_mask AM_binary, // TransparencyAttrib::M_binary - AM_dual // TransparencyAttrib::M_dual + AM_dual, // TransparencyAttrib::M_dual + AM_premultiplied // TransparencyAttrib::M_premultiplied_alpha }; enum DepthWriteMode { diff --git a/panda/src/egg2pg/eggRenderState.cxx b/panda/src/egg2pg/eggRenderState.cxx index 1f068c4655..cb8a9681e3 100644 --- a/panda/src/egg2pg/eggRenderState.cxx +++ b/panda/src/egg2pg/eggRenderState.cxx @@ -333,6 +333,10 @@ fill_state(EggPrimitive *egg_prim) { add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_dual)); break; + case EggRenderMode::AM_premultiplied: + add_attrib(TransparencyAttrib::make(TransparencyAttrib::M_premultiplied_alpha)); + break; + default: break; } diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index 4ca97a9aeb..103ba24fe2 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -686,12 +686,15 @@ convert_primitive(const GeomVertexData *vertex_data, break; case TransparencyAttrib::M_alpha: if (has_depthwrite && (depthwrite == DepthWriteAttrib::M_off)) { - tex_trans = EggRenderMode::AM_blend_no_occlude; - has_depthwrite = false; + tex_trans = EggRenderMode::AM_blend_no_occlude; + has_depthwrite = false; } else { tex_trans = EggRenderMode::AM_blend; } break; + case TransparencyAttrib::M_premultiplied_alpha: + tex_trans = EggRenderMode::AM_premultiplied; + break; case TransparencyAttrib::M_multisample: tex_trans = EggRenderMode::AM_ms; break; @@ -705,7 +708,6 @@ convert_primitive(const GeomVertexData *vertex_data, tex_trans = EggRenderMode::AM_dual; break; default: // intentional fall-through - case TransparencyAttrib::M_notused: break; } if (tex_trans != EggRenderMode::AM_unspecified) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 62a0f43b50..dc5d3e31e8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -6722,6 +6722,19 @@ do_issue_blending() { } return; + case TransparencyAttrib::M_premultiplied_alpha: + enable_multisample_alpha_one(false); + enable_multisample_alpha_mask(false); + enable_blend(true); + _glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + if (GLCAT.is_spam()) { + GLCAT.spam() << "glBlendEquation(GL_FUNC_ADD)\n"; + GLCAT.spam() << "glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)\n"; + } + return; + case TransparencyAttrib::M_multisample: // We need to enable *both* of these in M_multisample case. enable_multisample_alpha_one(true); diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index 3cc5380ab2..53751f07ca 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -131,6 +131,7 @@ add_object(CullableObject *object, const CullTraverser *traverser) { if (object->_state->get_attrib(trans)) { switch (trans->get_mode()) { case TransparencyAttrib::M_alpha: + case TransparencyAttrib::M_premultiplied_alpha: // M_alpha implies an alpha-write test, so we don't waste time writing // 0-valued pixels. object->_state = object->_state->compose(get_alpha_state()); diff --git a/panda/src/pgraph/cullTraverserData.cxx b/panda/src/pgraph/cullTraverserData.cxx index 186869cde6..d5ad3cba4f 100644 --- a/panda/src/pgraph/cullTraverserData.cxx +++ b/panda/src/pgraph/cullTraverserData.cxx @@ -47,7 +47,7 @@ apply_transform_and_state(CullTraverser *trav) { _node_reader.compose_draw_mask(_draw_mask); apply_transform_and_state(trav, _node_reader.get_transform(), - node_state, _node_reader.get_effects(), + MOVE(node_state), _node_reader.get_effects(), _node_reader.get_off_clip_planes()); } diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 86437c3122..0555d300a3 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -1853,8 +1853,8 @@ determine_bin_index() { string bin_name; _draw_order = 0; - const CullBinAttrib *bin = DCAST(CullBinAttrib, get_attrib(CullBinAttrib::get_class_slot())); - if (bin != (const CullBinAttrib *)NULL) { + const CullBinAttrib *bin; + if (get_attrib(bin)) { bin_name = bin->get_bin_name(); _draw_order = bin->get_draw_order(); } @@ -1864,10 +1864,11 @@ determine_bin_index() { // opaque or transparent, based on the transparency setting. bin_name = "opaque"; - const TransparencyAttrib *transparency = DCAST(TransparencyAttrib, get_attrib(TransparencyAttrib::get_class_slot())); - if (transparency != (const TransparencyAttrib *)NULL) { + const TransparencyAttrib *transparency; + if (get_attrib(transparency)) { switch (transparency->get_mode()) { case TransparencyAttrib::M_alpha: + case TransparencyAttrib::M_premultiplied_alpha: case TransparencyAttrib::M_dual: // These transparency modes require special back-to-front sorting. bin_name = "transparent"; diff --git a/panda/src/pgraph/transparencyAttrib.cxx b/panda/src/pgraph/transparencyAttrib.cxx index 358008ac1f..4dd7d0a1c2 100644 --- a/panda/src/pgraph/transparencyAttrib.cxx +++ b/panda/src/pgraph/transparencyAttrib.cxx @@ -55,6 +55,10 @@ output(ostream &out) const { out << "alpha"; break; + case M_premultiplied_alpha: + out << "premultiplied alpha"; + break; + case M_multisample: out << "multisample"; break; @@ -70,9 +74,6 @@ output(ostream &out) const { case M_dual: out << "dual"; break; - - case M_notused: - break; } } diff --git a/panda/src/pgraph/transparencyAttrib.h b/panda/src/pgraph/transparencyAttrib.h index fe49dc938e..2baf3710a1 100644 --- a/panda/src/pgraph/transparencyAttrib.h +++ b/panda/src/pgraph/transparencyAttrib.h @@ -36,7 +36,7 @@ PUBLISHED: // corresponded to M_none or M_alpha). M_none = 0, // No transparency. M_alpha = 1, // Normal transparency, panda will sort back-to-front. - M_notused, // Unused placeholder. Do not use this. + M_premultiplied_alpha, // Assume textures use premultiplied alpha. M_multisample, // Uses ms buffer, alpha values modified to 1.0. M_multisample_mask, // Uses ms buffer, alpha values not modified. M_binary, // Only writes pixels with alpha >= 0.5. diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 794c3123a9..2c840e46ee 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -209,6 +209,7 @@ analyze_renderstate(const RenderState *rs) { const TransparencyAttrib *transparency; rs->get_attrib_def(transparency); if ((transparency->get_mode() == TransparencyAttrib::M_alpha)|| + (transparency->get_mode() == TransparencyAttrib::M_premultiplied_alpha)|| (transparency->get_mode() == TransparencyAttrib::M_dual)) { _have_alpha_blend = true; } diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index ba33377546..dacb90c88e 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -804,6 +804,21 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } break; + case TransparencyAttrib::M_premultiplied_alpha: + { + // Implement a color mask, with pre-multiplied alpha blending. + int op_a = get_color_blend_op(ColorBlendAttrib::O_one); + int op_b = get_color_blend_op(ColorBlendAttrib::O_one_minus_incoming_alpha); + + if (srgb_blend) { + _c->zb->store_pix_func = store_pixel_funcs_sRGB[op_a][op_b][color_channels]; + } else { + _c->zb->store_pix_func = store_pixel_funcs[op_a][op_b][color_channels]; + } + color_write_state = 2; // cgeneral + } + break; + default: break; } From 37aaa49529cc415b20b3e0d80cbcb482584fcf2f Mon Sep 17 00:00:00 2001 From: tobspr Date: Thu, 3 Mar 2016 13:53:59 +0100 Subject: [PATCH 26/31] Change message emitted by nvidia driver workaround to info --- panda/src/glstuff/glShaderContext_src.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 708347a119..c2f7edaa48 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -594,7 +594,7 @@ reflect_uniform_block(int i, const char *name, char *name_buffer, GLsizei name_b break; default: - GLCAT.warning() << "Ignoring uniform '" << name_buffer + GLCAT.info() << "Ignoring uniform '" << name_buffer << "' with unsupported type 0x" << hex << param_type << dec << "\n"; continue; } From 46562b700dd3e0300bd6ac15df078525b89a6cdf Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 12 Mar 2016 20:42:27 +0100 Subject: [PATCH 27/31] Support FBOs without any attachments --- panda/src/glstuff/glGraphicsBuffer_src.cxx | 29 +++++++++++++++---- .../glstuff/glGraphicsStateGuardian_src.cxx | 10 +++++++ .../src/glstuff/glGraphicsStateGuardian_src.h | 5 ++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 9d06e21348..b750233520 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -509,6 +509,7 @@ rebuild_bitplanes() { // Now create the FBO's. _have_any_color = false; + bool have_any_depth = false; if (num_fbos > _fbo.size()) { // Generate more FBO handles. @@ -542,8 +543,10 @@ rebuild_bitplanes() { // For all slots, update the slot. if (_use_depth_stencil) { bind_slot(layer, rb_resize, attach, RTP_depth_stencil, GL_DEPTH_ATTACHMENT_EXT); + have_any_depth = true; } else if (attach[RTP_depth] || _fb_properties.get_depth_bits() > 0) { bind_slot(layer, rb_resize, attach, RTP_depth, GL_DEPTH_ATTACHMENT_EXT); + have_any_depth = true; } int next = GL_COLOR_ATTACHMENT0_EXT; @@ -581,11 +584,23 @@ rebuild_bitplanes() { } #endif // OPENGLES - // Clear if the fbo was just created, regardless of the clear settings per - // frame. - if (_initial_clear) { - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + if (_have_any_color || have_any_depth) { + // Clear if the fbo was just created, regardless of the clear settings per + // frame. + if (_initial_clear) { + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + } +#ifndef OPENGLES + } else if (glgsg->_supports_empty_framebuffer) { + // Set the "default" width and height, which is required to have an FBO + // without any attachments. + glgsg->_glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, _rb_size_x); + glgsg->_glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, _rb_size_y); +#endif + } else { + // If all else fails, just bind a "dummy" attachment. + bind_slot(layer, rb_resize, attach, RTP_color, next++); } } @@ -1363,8 +1378,10 @@ open_buffer() { _fb_properties.set_depth_bits(32); } else if (_fb_properties.get_depth_bits() > 16) { _fb_properties.set_depth_bits(24); - } else { + } else if (_fb_properties.get_depth_bits() > 0) { _fb_properties.set_depth_bits(16); + } else { + _fb_properties.set_depth_bits(0); } // We're not going to get more than this, ever. At least not until OpenGL diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index dc5d3e31e8..d308af9aa8 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -1945,6 +1945,16 @@ reset() { } #endif +#ifndef OPENGLES + if (is_at_least_gl_version(4, 3) || has_extension("GL_ARB_framebuffer_no_attachments")) { + _glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC) + get_extension_func("glFramebufferParameteri"); + _supports_empty_framebuffer = true; + } else { + _supports_empty_framebuffer = false; + } +#endif + _supports_framebuffer_multisample = false; if (has_extension("GL_EXT_framebuffer_multisample")) { _supports_framebuffer_multisample = true; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 73afe5a44e..9d73f69130 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -830,6 +830,11 @@ public: PFNGLGENERATETEXTUREMIPMAPPROC _glGenerateTextureMipmap; #endif +#ifndef OPENGLES + bool _supports_empty_framebuffer; + PFNGLFRAMEBUFFERPARAMETERIPROC _glFramebufferParameteri; +#endif + bool _supports_framebuffer_multisample; bool _supports_framebuffer_multisample_coverage_nv; INLINE bool get_supports_framebuffer_multisample(); From 5cfe2b89e797ed553f5a27d4baed7fc9af0c231c Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 12 Mar 2016 21:01:57 +0100 Subject: [PATCH 28/31] Support getting FBO attachment with only 8 red bits --- makepanda/config.in | 2 +- panda/src/display/frameBufferProperties.cxx | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/makepanda/config.in b/makepanda/config.in index 9b0943918d..e61f73f04b 100755 --- a/makepanda/config.in +++ b/makepanda/config.in @@ -41,7 +41,7 @@ framebuffer-software #f # consistent with the other framebuffer requirements. depth-bits 1 -color-bits 1 +color-bits 1 1 1 alpha-bits 0 stencil-bits 0 multisamples 0 diff --git a/panda/src/display/frameBufferProperties.cxx b/panda/src/display/frameBufferProperties.cxx index 5cb0f05973..4d0751a7d2 100644 --- a/panda/src/display/frameBufferProperties.cxx +++ b/panda/src/display/frameBufferProperties.cxx @@ -138,6 +138,9 @@ get_default() { break; case 1: default_props.set_color_bits(color_bits[0]); + default_props.set_red_bits(1); + default_props.set_green_bits(1); + default_props.set_blue_bits(1); break; case 3: default_props.set_color_bits(color_bits[0] + color_bits[1] + color_bits[2]); @@ -649,13 +652,14 @@ setup_color_texture(Texture *tex) const { // as the below one would be generated dynamically by the GSG to reflect the // formats that are supported for render-to-texture. - static const int num_formats = 13; + static const int num_formats = 15; static const struct { unsigned char color_bits, red_bits, green_bits, blue_bits, alpha_bits; bool has_float; Texture::Format format; } formats[num_formats] = { - // { 1, 1, 0, 0, 0, false, Texture::F_red}, + { 1, 1, 0, 0, 0, false, Texture::F_red }, + { 1, 1, 1, 0, 0, false, Texture::F_rg }, { 1, 1, 1, 1, 0, false, Texture::F_rgb }, { 1, 1, 1, 1, 1, false, Texture::F_rgba }, { 24, 8, 8, 8, 0, false, Texture::F_rgb8 }, From d28608aed13853f6eed991d420d924783f3c433e Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 15 Mar 2016 18:08:03 -0700 Subject: [PATCH 29/31] cppparser: Fix missing includes. --- dtool/src/cppparser/cppExpression.cxx | 1 + dtool/src/cppparser/cppInstanceIdentifier.cxx | 1 + dtool/src/cppparser/cppScope.cxx | 1 + 3 files changed, 3 insertions(+) diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 5adfb28232..8456c402f5 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -17,6 +17,7 @@ #include "cppType.h" #include "cppSimpleType.h" #include "cppPointerType.h" +#include "cppEnumType.h" #include "cppConstType.h" #include "cppArrayType.h" #include "cppPreprocessor.h" diff --git a/dtool/src/cppparser/cppInstanceIdentifier.cxx b/dtool/src/cppparser/cppInstanceIdentifier.cxx index 052b1067ed..96f14e27ce 100644 --- a/dtool/src/cppparser/cppInstanceIdentifier.cxx +++ b/dtool/src/cppparser/cppInstanceIdentifier.cxx @@ -17,6 +17,7 @@ #include "cppArrayType.h" #include "cppConstType.h" #include "cppFunctionType.h" +#include "cppSimpleType.h" #include "cppParameterList.h" #include "cppIdentifier.h" diff --git a/dtool/src/cppparser/cppScope.cxx b/dtool/src/cppparser/cppScope.cxx index 54bc80fe2a..158c3884d2 100644 --- a/dtool/src/cppparser/cppScope.cxx +++ b/dtool/src/cppparser/cppScope.cxx @@ -26,6 +26,7 @@ #include "cppPreprocessor.h" #include "cppTemplateScope.h" #include "cppClassTemplateParameter.h" +#include "cppConstType.h" #include "cppFunctionType.h" #include "cppUsing.h" #include "cppBisonDefs.h" From f0bed9ab1cff11e88b7b1ef73053d741be40e2b3 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 15 Mar 2016 18:19:45 -0700 Subject: [PATCH 30/31] pnmtext: Remove unused local. --- panda/src/pnmtext/pnmTextMaker.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index ad435ffa00..af6f400341 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -193,7 +193,6 @@ make_glyph(int glyph_index) { PN_stdfloat tex_x_size, tex_y_size, tex_x_orig, tex_y_orig; FT_BBox bounds; - TransparencyAttrib::Mode alpha_mode; // Calculate suitable texture dimensions for the signed distance field. // This is the same calculation that Freetype uses in its bitmap From 6b8f78c9e008b8cd772eaf849b897106f1afe090 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 15 Mar 2016 18:29:22 -0700 Subject: [PATCH 31/31] general: Fix missing includes. --- panda/src/particlesystem/colorInterpolationManager.cxx | 1 + panda/src/pnmtext/pnmTextMaker.cxx | 2 ++ panda/src/text/dynamicTextFont.cxx | 1 + 3 files changed, 4 insertions(+) diff --git a/panda/src/particlesystem/colorInterpolationManager.cxx b/panda/src/particlesystem/colorInterpolationManager.cxx index 90f30de6b2..27268c2ef8 100644 --- a/panda/src/particlesystem/colorInterpolationManager.cxx +++ b/panda/src/particlesystem/colorInterpolationManager.cxx @@ -11,6 +11,7 @@ * @date 2005-06-02 */ +#include "colorInterpolationManager.h" #include "mathNumbers.h" TypeHandle ColorInterpolationFunction::_type_handle; diff --git a/panda/src/pnmtext/pnmTextMaker.cxx b/panda/src/pnmtext/pnmTextMaker.cxx index af6f400341..1c11dac21c 100644 --- a/panda/src/pnmtext/pnmTextMaker.cxx +++ b/panda/src/pnmtext/pnmTextMaker.cxx @@ -16,6 +16,8 @@ #include "filename.h" #include "pnmImage.h" +#include FT_OUTLINE_H + /** * The constructor expects the name of some font file that FreeType can read, * along with face_index, indicating which font within the file to load diff --git a/panda/src/text/dynamicTextFont.cxx b/panda/src/text/dynamicTextFont.cxx index 6143db7f61..705bd1a943 100644 --- a/panda/src/text/dynamicTextFont.cxx +++ b/panda/src/text/dynamicTextFont.cxx @@ -42,6 +42,7 @@ // #include "renderModeAttrib.h" #include "antialiasAttrib.h" #include "colorAttrib.h" #include "textureAttrib.h" +#include "transparencyAttrib.h" TypeHandle DynamicTextFont::_type_handle;